diff --git a/.azure-pipelines/windows-layout-steps.yml b/.azure-pipelines/windows-layout-steps.yml index afd897817904947..e15729fac3443db 100644 --- a/.azure-pipelines/windows-layout-steps.yml +++ b/.azure-pipelines/windows-layout-steps.yml @@ -12,7 +12,7 @@ steps: displayName: Show layout info (${{ parameters.kind }}) - ${{ if eq(parameters.fulltest, 'true') }}: - - script: .\python.exe -m test -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0 --junit-xml="$(Build.BinariesDirectory)\test-results-${{ parameters.kind }}.xml" --tempdir "$(Build.BinariesDirectory)\tmp-${{ parameters.kind }}-$(arch)" -i test_launcher + - script: .\python.exe -m test -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0 --junit-xml="$(Build.BinariesDirectory)\test-results-${{ parameters.kind }}.xml" --tempdir "$(Build.BinariesDirectory)\tmp-${{ parameters.kind }}-$(arch)" workingDirectory: $(Build.BinariesDirectory)\layout-${{ parameters.kind }}-$(arch) displayName: ${{ parameters.kind }} Tests env: diff --git a/.gitattributes b/.gitattributes index 4d52f900b93179e..d41390e814096f1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -19,7 +19,7 @@ *.zip binary # Specific binary files -PC/classicAppCompat.* binary +# -- None right now -- # Text files that should not be subject to eol conversion [attr]noeol -text @@ -80,12 +80,12 @@ Include/internal/pycore_ast_state.h generated Include/internal/pycore_opcode.h generated Include/internal/pycore_opcode_metadata.h generated Include/internal/pycore_*_generated.h generated +Include/internal/pycore_token.h generated Include/internal/pycore_uop_ids.h generated Include/internal/pycore_uop_metadata.h generated Include/opcode.h generated Include/opcode_ids.h generated Include/slots_generated.h generated -Include/token.h generated Lib/_opcode_metadata.py generated Lib/idlelib/help.html generated Lib/keyword.py generated @@ -102,6 +102,7 @@ Modules/_testinternalcapi/test_cases.c.h generated Modules/_testinternalcapi/test_targets.h generated PC/python3dll.c generated Parser/parser.c generated +Parser/parser_invalid.c generated Parser/token.c generated Programs/test_frozenmain.h generated Python/Python-ast.c generated diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 0cdf17838b5798f..a95eb943e4a4e7c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -63,14 +63,14 @@ .azure-pipelines/ @AA-Turner # GitHub & related scripts -.github/ @ezio-melotti @hugovk @AA-Turner @webknjaz @itamaro @JacobCoffee -Tools/build/compute-changes.py @AA-Turner @hugovk @webknjaz -Lib/test/test_tools/test_compute_changes.py @AA-Turner @hugovk @webknjaz +.github/ @ezio-melotti @hugovk @AA-Turner @webknjaz @itamaro @JacobCoffee @StanFromIreland +Tools/build/compute-changes.py @AA-Turner @hugovk @webknjaz @StanFromIreland +Lib/test/test_tools/test_compute_changes.py @AA-Turner @hugovk @webknjaz @StanFromIreland Tools/build/verify_ensurepip_wheels.py @AA-Turner @pfmoore @pradyunsg # Pre-commit -.pre-commit-config.yaml @hugovk @JacobCoffee -.ruff.toml @hugovk @AlexWaygood @AA-Turner @JacobCoffee +.pre-commit-config.yaml @hugovk @JacobCoffee @StanFromIreland +.ruff.toml @hugovk @AlexWaygood @AA-Turner @JacobCoffee @StanFromIreland # Patchcheck Tools/patchcheck/ @AA-Turner @itamaro @@ -171,12 +171,13 @@ Mac/ @python/macos-team Lib/_osx_support.py @python/macos-team Lib/test/test__osx_support.py @python/macos-team -# WebAssembly -Tools/wasm/README.md @brettcannon @freakboy3742 @emmatyping - # WebAssembly (Emscripten) -Platforms/emscripten @freakboy3742 @emmatyping -Tools/wasm/emscripten @freakboy3742 @emmatyping +Platforms/emscripten @freakboy3742 @emmatyping @hoodmane +Tools/wasm/emscripten @freakboy3742 @emmatyping @hoodmane +Python/wasm_trampoline.c @hoodmane +Python/emscripten_signal.c @hoodmane +Python/emscripten_syscalls.c @hoodmane +.github/workflows/reusable-emscripten.yml @hoodmane # WebAssembly (WASI) Platforms/WASI @brettcannon @emmatyping @savannahostrowski @@ -188,12 +189,8 @@ Tools/wasm/wasi @brettcannon @emmatyping @savannahostrowski PC/ @python/windows-team PCbuild/ @python/windows-team -# Windows installer packages -Tools/msi/ @python/windows-team -Tools/nuget/ @python/windows-team - -# Windows Launcher -PC/launcher.c @python/windows-team @vsajip +# Windows Venv launcher/redirector +PC/venvlauncher.c @python/windows-team @vsajip # ---------------------------------------------------------------------------- @@ -230,7 +227,7 @@ Tools/cases_generator/ @markshannon Python/assemble.c @markshannon @iritkatriel Python/codegen.c @markshannon @iritkatriel Python/compile.c @markshannon @iritkatriel -Python/flowgraph.c @markshannon @iritkatriel +Python/flowgraph.c @markshannon @iritkatriel @eclips4 Python/instruction_sequence.c @iritkatriel Python/symtable.c @JelleZijlstra @carljm @@ -290,25 +287,26 @@ Programs/_bootstrap_python.c @ericsnowcurrently @FFY00 Programs/python.c @ericsnowcurrently @FFY00 # JIT -.github/workflows/jit.yml @savannahostrowski -Include/internal/pycore_jit.h @brandtbucher @savannahostrowski @diegorusso -Python/jit.c @brandtbucher @savannahostrowski @diegorusso -Tools/jit/ @brandtbucher @savannahostrowski @diegorusso -InternalDocs/jit.md @brandtbucher @savannahostrowski @diegorusso @AA-Turner +Include/internal/pycore_jit.h @brandtbucher @diegorusso +Python/jit.c @brandtbucher @diegorusso +Tools/jit/ @brandtbucher @diegorusso +InternalDocs/jit.md @brandtbucher @diegorusso @AA-Turner # Lazy imports (PEP 810) -Objects/lazyimportobject.c @yhg1s @DinoV @pablogsal -Include/internal/pycore_lazyimportobject.h @yhg1s @DinoV @pablogsal -Lib/test/test_lazy_import @yhg1s @DinoV @pablogsal +.github/workflows/reusable-test-lazy-imports-all.yml @yhg1s @DinoV @pablogsal +Objects/lazyimportobject.c @yhg1s @DinoV @pablogsal +Include/internal/pycore_lazyimportobject.h @yhg1s @DinoV @pablogsal +Lib/test/test_lazy_import @yhg1s @DinoV @pablogsal # Micro-op / μop / Tier 2 Optimiser Python/optimizer.c @markshannon @Fidget-Spinner -Python/optimizer_analysis.c @markshannon @tomasr8 @Fidget-Spinner @savannahostrowski -Python/optimizer_bytecodes.c @markshannon @tomasr8 @Fidget-Spinner @savannahostrowski -Python/optimizer_symbols.c @markshannon @tomasr8 @Fidget-Spinner @savannahostrowski +Python/optimizer_analysis.c @markshannon @tomasr8 @Fidget-Spinner +Python/optimizer_bytecodes.c @markshannon @tomasr8 @Fidget-Spinner +Python/optimizer_symbols.c @markshannon @tomasr8 @Fidget-Spinner # Parser, Lexer, and Grammar Grammar/python.gram @pablogsal @lysnikolaou +Grammar/invalid.gram @pablogsal @lysnikolaou Lib/test/test_peg_generator/ @pablogsal @lysnikolaou Lib/test/test_tokenize.py @pablogsal @lysnikolaou Lib/tokenize.py @pablogsal @lysnikolaou @@ -339,7 +337,6 @@ Modules/_remote_debugging/ @pablogsal # Sub-Interpreters **/*crossinterp* @ericsnowcurrently -**/*interpreteridobject.* @ericsnowcurrently Doc/library/concurrent.interpreters.rst @ericsnowcurrently Lib/concurrent/futures/interpreter.py @ericsnowcurrently Lib/concurrent/interpreters/ @ericsnowcurrently @@ -439,6 +436,7 @@ Lib/test/test_*time.py @pganssle @StanFromIreland Modules/*zoneinfo* @pganssle @StanFromIreland Modules/*time* @pganssle @StanFromIreland Python/pytime.c @pganssle @StanFromIreland +Python/_strptime.c @pganssle @StanFromIreland # Dbm Doc/library/dbm.rst @corona10 @erlend-aasland @serhiy-storchaka @@ -500,6 +498,11 @@ Lib/_markupbase.py @ezio-melotti Lib/test/test_html*.py @ezio-melotti Tools/build/parse_html5_entities.py @ezio-melotti +# HTTP +Doc/library/http* @orsenthil +Lib/http/ @orsenthil +Lib/test/test_http*.py @orsenthil + # IDLE Doc/library/idle.rst @terryjreedy Lib/idlelib/ @terryjreedy @@ -516,6 +519,13 @@ Doc/library/importlib.resources.rst @jaraco @warsaw @FFY00 Lib/importlib/resources/ @jaraco @warsaw @FFY00 Lib/test/test_importlib/resources/ @jaraco @warsaw @FFY00 +# IO +Doc/library/io.rst @cmaloney +Lib/_pyio.py @cmaloney +Lib/io.py @cmaloney +Lib/test/test_io/ @cmaloney +Modules/_io/ @cmaloney + # Itertools Doc/library/itertools.rst @rhettinger Lib/test/test_itertools.py @rhettinger @@ -606,6 +616,12 @@ Doc/library/tomllib.rst @encukou @hauntsaninja Lib/test/test_tomllib/ @encukou @hauntsaninja Lib/tomllib/ @encukou @hauntsaninja +# Turtle +Doc/library/turtle.rst @StanFromIreland +Doc/library/turtle-star.png @StanFromIreland +Lib/test/test_turtle.py @StanFromIreland +Lib/turtle.py @StanFromIreland + # Typing Doc/library/typing.rst @JelleZijlstra @AlexWaygood Lib/test/test_typing.py @JelleZijlstra @AlexWaygood @@ -622,12 +638,23 @@ Modules/_typesmodule.c @AA-Turner Lib/unittest/mock.py @cjw296 Lib/test/test_unittest/testmock/ @cjw296 +# Urllib +Doc/library/urllib* @orsenthil +Lib/urllib/ @orsenthil +Lib/test/test_urllib*.py @orsenthil + # Venv **/*venv* @vsajip @FFY00 # Weakref **/*weakref* @kumaraditya303 +# Zlib +Doc/library/zlib.rst @StanFromIreland +Lib/compression/zlib.py @StanFromIreland +Lib/test/test_zlib.py @StanFromIreland +Modules/zlibmodule.c @StanFromIreland + # Zipfile.Path Lib/test/test_zipfile/_path/ @jaraco Lib/zipfile/_path/ @jaraco @@ -650,3 +677,9 @@ Modules/**/clinic/ Objects/**/clinic/ PC/**/clinic/ Python/**/clinic/ + +# Exclude Lazy Imports=all CI carve out file +Lib/test/lazy_imports_all_exclude.txt + +# Exclude HTML IDs list +Doc/tools/removed-ids.txt diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 177615621f6b8c7..61e4e04ba272dc8 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -16,7 +16,7 @@ body: Make sure to also search the [CPython issue tracker](https://github.com/python/cpython/issues?q=is%3Aissue+sort%3Acreated-desc) to check that the bug has not already been reported. - type: textarea attributes: - label: "Bug description:" + label: "Bug report" description: > Give a clear and concise description of what happened. Include a [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) if possible. @@ -34,7 +34,6 @@ body: label: "CPython versions tested on:" multiple: true options: - - "3.10" - "3.11" - "3.12" - "3.13" diff --git a/.github/ISSUE_TEMPLATE/crash.yml b/.github/ISSUE_TEMPLATE/crash.yml index 81ae91e5b0af973..973d4c38528f3e6 100644 --- a/.github/ISSUE_TEMPLATE/crash.yml +++ b/.github/ISSUE_TEMPLATE/crash.yml @@ -10,8 +10,9 @@ body: The CPython interpreter is written in a different programming language, C. A "CPython crash" is when Python itself fails, leading to a traceback in the C stack. - type: textarea attributes: - label: What happened? + label: Crash report description: > + Give a clear and concise description of what happened. Include a [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) if possible. [Copy and paste code where possible rather than using screenshots](https://meta.stackoverflow.com/a/285557/13990016), and put any code blocks inside triple backticks. @@ -27,7 +28,6 @@ body: label: "CPython versions tested on:" multiple: true options: - - "3.10" - "3.11" - "3.12" - "3.13" diff --git a/.github/ISSUE_TEMPLATE/documentation.yml b/.github/ISSUE_TEMPLATE/documentation.yml index d720cf9c4de91e2..d21e2a88604087f 100644 --- a/.github/ISSUE_TEMPLATE/documentation.yml +++ b/.github/ISSUE_TEMPLATE/documentation.yml @@ -7,10 +7,16 @@ body: value: | > [!NOTE] > Trivial changes (for example typos) don’t require an issue before opening a PR. + - type: input + id: url + attributes: + label: "Documentation URL" + description: "A link to the relevant documentation page, if applicable." + placeholder: "https://docs.python.org/3/..." - type: textarea id: description attributes: label: "Documentation" - description: "A clear and concise description of the issue. Include a link to the page." + description: "A clear and concise description of the issue." validations: required: true diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml index 4361ab2bf827fb6..3ecae7112170e0a 100644 --- a/.github/ISSUE_TEMPLATE/feature.yml +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -12,7 +12,7 @@ body: Major feature proposals should generally be discussed on [Discourse](https://discuss.python.org/c/ideas/6) before opening a GitHub issue. Wait until it's clear that most people support your idea before filling in this form. - type: textarea attributes: - label: "Proposal:" + label: "Feature or enhancement" description: > Explain your proposal, why it should be implemented, and how it would be used. Add examples, if applicable. diff --git a/.github/VULNERABILITY_REPORT.yml b/.github/VULNERABILITY_REPORT.yml new file mode 100644 index 000000000000000..55f2157a77f00ef --- /dev/null +++ b/.github/VULNERABILITY_REPORT.yml @@ -0,0 +1,71 @@ +name: Vulnerability report +description: Privately report a potential security vulnerability in CPython +body: + - type: markdown + attributes: + value: | + **Not all bugs are vulnerabilities.** Before submitting, read the [Python security policy](https://devguide.python.org/security/policy/) to understand which issues are vulnerabilities and what versions of Python accept reports. + + Keep the report short and in plain text: no headers, tables, PDFs, binaries, or severity and CVSS information. + + Reports that do not contain a potential security vulnerability will be discarded without a reply. + + To report vulnerabilities that affect other projects (such as pip or python.org), or if you are not sure where to send your report, email [security@python.org](mailto:security@python.org). + - type: textarea + id: summary + attributes: + label: Summary + description: A few sentences describing the vulnerability. + validations: + required: true + - type: textarea + id: threat_model + attributes: + label: Threat model + description: > + What does the attacker control, and what do they gain? Describe the code, configuration, or deployment that may exist in the real world and is exploitable. Where possible, cite the relevant part of the [security policy](https://devguide.python.org/security/policy/#what-types-of-bugs-are-vulnerabilities). + validations: + required: true + - type: textarea + id: proof_of_concept + attributes: + label: Proof of concept + description: > + A script that reproduces the issue and clearly indicates whether the vulnerability is present, such as exiting with `1` if vulnerable and `0` if not. If it depends on a specially constructed binary file, include a script to construct the file rather than the file itself. + + Wrap scripts longer than a few lines in a [collapsed section](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections) using `
...
`. + validations: + required: true + - type: dropdown + id: versions + attributes: + label: "CPython versions tested on:" + description: > + If any tested version was not vulnerable, say which in the summary. Only [supported versions](https://devguide.python.org/versions/) accept reports. + multiple: true + options: + - "3.11" + - "3.12" + - "3.13" + - "3.14" + - "3.15" + - "3.16" + - "CPython main branch" + - type: textarea + id: patch + attributes: + label: Suggested fix + description: Ideally, a minimal patch with the mitigation. + validations: + required: false + - type: checkboxes + id: checklist + attributes: + label: Before submitting + options: + - label: I have read the security policy and evaluated this report against it. + required: true + - label: I have checked that this issue is not already resolved on the `main` branch. + required: true + - label: I have verified the factual validity of everything in this report, including any content produced by an LLM. + required: true diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml index 61ee08db9919bb9..37d9121dadfc8f8 100644 --- a/.github/actionlint.yaml +++ b/.github/actionlint.yaml @@ -12,3 +12,6 @@ paths: ignore: - 1st argument of function call is not assignable - SC2(015|038|086|091|097|098|129|155) + # Pending release of actionlint > 1.7.12 for `$/` self-repository syntax: + # https://github.com/rhysd/actionlint/issues/711 + - reusable workflow call "\$/[^"]+" at "uses" is not following the format diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 4b77646e22db4ba..0d367e01bca224f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,11 +7,6 @@ updates: labels: - "skip issue" - "skip news" - ignore: - - dependency-name: "*" - update-types: - - "version-update:semver-minor" - - "version-update:semver-patch" groups: actions: patterns: @@ -21,12 +16,141 @@ updates: # Cooldowns protect against supply chain attacks by avoiding the # highest-risk window immediately after new releases. default-days: 14 + - package-ecosystem: "pip" directory: "/Tools/" schedule: interval: "quarterly" - labels: - - "skip issue" - - "skip news" + labels: ["skip issue", "skip news"] + groups: + pip: + patterns: ["*"] + cooldown: + default-days: 14 + + - package-ecosystem: "npm" + directory: "/Platforms/emscripten/browser_test/" + schedule: + interval: "quarterly" + labels: ["OS-emscripten", "skip issue", "skip news"] + groups: + npm: + patterns: ["*"] + cooldown: + default-days: 14 + + # Release branches: Dependabot only reads this file from the default + # branch, so each branch that should get its own actions bumps needs an + # entry here with `target-branch`. Add one when a new release branch is + # created, and remove when the branch reaches end-of-life. + - package-ecosystem: "github-actions" + target-branch: "3.15" + directory: "/" + schedule: + interval: "quarterly" + labels: ["skip issue", "skip news"] + groups: + actions: + patterns: ["*"] + cooldown: + default-days: 14 + + - package-ecosystem: "github-actions" + target-branch: "3.14" + directory: "/" + schedule: + interval: "quarterly" + labels: ["skip issue", "skip news"] + groups: + actions: + patterns: ["*"] + cooldown: + default-days: 14 + + - package-ecosystem: "github-actions" + target-branch: "3.13" + directory: "/" + schedule: + interval: "quarterly" + labels: ["skip issue", "skip news"] + groups: + actions: + patterns: ["*"] + cooldown: + default-days: 14 + + - package-ecosystem: "github-actions" + target-branch: "3.12" + directory: "/" + schedule: + interval: "quarterly" + labels: ["skip issue", "skip news"] + groups: + actions: + patterns: ["*"] + cooldown: + default-days: 14 + + - package-ecosystem: "github-actions" + target-branch: "3.11" + directory: "/" + schedule: + interval: "quarterly" + labels: ["skip issue", "skip news"] + groups: + actions: + patterns: ["*"] + cooldown: + default-days: 14 + + # Only bump bugfix branches for pip. Remove + # the entry when branch goes security-only. + - package-ecosystem: "pip" + target-branch: "3.15" + directory: "/Tools/" + schedule: + interval: "quarterly" + labels: ["skip issue", "skip news"] + groups: + pip: + patterns: ["*"] + cooldown: + default-days: 14 + + - package-ecosystem: "pip" + target-branch: "3.14" + directory: "/Tools/" + schedule: + interval: "quarterly" + labels: ["skip issue", "skip news"] + groups: + pip: + patterns: ["*"] + cooldown: + default-days: 14 + + # Only bump bugfix branches for npm. Remove + # the entry when branch goes security-only. + - package-ecosystem: "npm" + target-branch: "3.15" + directory: "/Platforms/emscripten/browser_test/" + schedule: + interval: "quarterly" + labels: ["OS-emscripten", "skip issue", "skip news"] + groups: + npm: + patterns: ["*"] + cooldown: + default-days: 14 + + - package-ecosystem: "npm" + target-branch: "3.14" + directory: "/Platforms/emscripten/browser_test/" + schedule: + interval: "quarterly" + labels: ["OS-emscripten", "skip issue", "skip news"] + groups: + npm: + patterns: ["*"] cooldown: default-days: 14 diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock new file mode 100644 index 000000000000000..9e4ec30ba9d2546 --- /dev/null +++ b/.github/workflows/actions.lock @@ -0,0 +1,161 @@ +# This file is machine-generated by `gh actions-lock`. +# Do not edit by hand; run `gh actions-lock` to update. +# Docs: https://gh.io/actions-lockfile +version: 'v0.0.3' +workflows: + '.github/workflows/build.yml': + - 'actions/cache@v6.1.0' + - 'actions/checkout@v7.0.1' + - 'actions/setup-python@v7.0.0' + - 'actions/upload-artifact@v7.0.1' + - 're-actors/alls-green@v1.3.0' + '.github/workflows/cache-cleanup-codeql.yml': [] + '.github/workflows/jit.yml': + - 'actions/checkout@v7.0.1' + - 'actions/setup-python@v7.0.0' + '.github/workflows/lint.yml': + - 'actions/checkout@v7.0.1' + - 'j178/prek-action@v3.0.0' + '.github/workflows/mypy.yml': + - 'actions/checkout@v7.0.1' + - 'astral-sh/setup-uv@v10.2.0' + '.github/workflows/new-bugs-announce-notifier.yml': + - 'actions/github-script@v9.0.0' + - 'actions/setup-node@v7.0.0' + '.github/workflows/require-pr-label.yml': + - 'mheap/github-action-required-labels@v5.6.0' + '.github/workflows/reusable-check-c-api-docs.yml': + - 'actions/checkout@v7.0.1' + - 'actions/setup-python@v7.0.0' + '.github/workflows/reusable-check-html-ids.yml': + - 'actions/checkout@v7.0.1' + - 'actions/download-artifact@v8.0.1' + - 'actions/setup-python@v7.0.0' + '.github/workflows/reusable-cifuzz.yml': + - 'actions/upload-artifact@v7.0.1' + - 'github/codeql-action@v4.38.2' + - 'google/oss-fuzz@ed23f8af80ff82b25ca67cd9b101e690b8897b3f' + '.github/workflows/reusable-context.yml': + - 'actions/checkout@v7.0.1' + - 'actions/setup-python@v7.0.0' + '.github/workflows/reusable-docs.yml': + - 'actions/cache@v6.1.0' + - 'actions/checkout@v7.0.1' + - 'actions/setup-python@v7.0.0' + - 'actions/upload-artifact@v7.0.1' + '.github/workflows/reusable-emscripten.yml': + - 'actions/cache@v6.1.0' + - 'actions/checkout@v7.0.1' + - 'actions/setup-node@v7.0.0' + - 'actions/setup-python@v7.0.0' + '.github/workflows/reusable-install.yml': + - 'actions/checkout@v7.0.1' + '.github/workflows/reusable-macos.yml': + - 'actions/checkout@v7.0.1' + '.github/workflows/reusable-san.yml': + - 'actions/cache@v6.1.0' + - 'actions/checkout@v7.0.1' + - 'actions/upload-artifact@v7.0.1' + '.github/workflows/reusable-test-lazy-imports-all.yml': + - 'actions/checkout@v7.0.1' + '.github/workflows/reusable-ubuntu.yml': + - 'actions/cache@v6.1.0' + - 'actions/checkout@v7.0.1' + '.github/workflows/reusable-wasi.yml': + - 'actions/checkout@v7.0.1' + - 'actions/setup-python@v7.0.0' + - 'bytecodealliance/actions@v1.1.3' + - 'bytecodealliance/setup-wasi-sdk-action@v1.0.0' + '.github/workflows/reusable-windows.yml': + - 'actions/checkout@v7.0.1' + '.github/workflows/stale.yml': + - 'actions/stale@v11.0.0' + '.github/workflows/tail-call.yml': + - 'actions/checkout@v7.0.1' + - 'actions/setup-python@v7.0.0' + '.github/workflows/verify-ensurepip-wheels.yml': + - 'actions/checkout@v7.0.1' + - 'actions/setup-python@v7.0.0' + '.github/workflows/verify-expat.yml': + - 'actions/checkout@v7.0.1' +dependencies: + 'actions/cache@v6.1.0': + ref: 'v6.1.0' + commit: 'sha1-55cc8345863c7cc4c66a329aec7e433d2d1c52a9' + owner_id: 44036562 + repo_id: 215566462 + 'actions/checkout@v7.0.1': + ref: 'v7.0.1' + commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1' + owner_id: 44036562 + repo_id: 197814629 + 'actions/download-artifact@v8.0.1': + ref: 'v8.0.1' + commit: 'sha1-3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c' + owner_id: 44036562 + repo_id: 192626254 + 'actions/github-script@v9.0.0': + ref: 'v9.0.0' + commit: 'sha1-3a2844b7e9c422d3c10d287c895573f7108da1b3' + owner_id: 44036562 + repo_id: 205262760 + 'actions/setup-node@v7.0.0': + ref: 'v7.0.0' + commit: 'sha1-820762786026740c76f36085b0efc47a31fe5020' + owner_id: 44036562 + repo_id: 189476904 + 'actions/setup-python@v7.0.0': + ref: 'v7.0.0' + commit: 'sha1-5fda3b95a4ea91299a34e894583c3862153e4b97' + owner_id: 44036562 + repo_id: 192625525 + 'actions/stale@v11.0.0': + ref: 'v11.0.0' + commit: 'sha1-4391f3da665fdf50b6810c1a66712fb9ba21aa93' + owner_id: 44036562 + repo_id: 200437066 + 'actions/upload-artifact@v7.0.1': + ref: 'v7.0.1' + commit: 'sha1-043fb46d1a93c77aae656e7c1c64a875d1fc6a0a' + owner_id: 44036562 + repo_id: 192625955 + 'astral-sh/setup-uv@v10.2.0': + ref: 'v10.2.0' + commit: 'sha1-c18668ad3cf93ea998bef934396af7bb5c839dc7' + owner_id: 115962839 + repo_id: 846733598 + 'bytecodealliance/actions@v1.1.3': + ref: 'v1.1.3' + commit: 'sha1-9152e710e9f7182e4c29ad218e4f335a7b203613' + owner_id: 54038801 + repo_id: 697422232 + 'bytecodealliance/setup-wasi-sdk-action@v1.0.0': + ref: 'v1.0.0' + commit: 'sha1-77d09f3df1e8da344d8403cf8631af8977938b4c' + owner_id: 54038801 + repo_id: 1113975359 + 'github/codeql-action@v4.38.2': + ref: 'v4.38.2' + commit: 'sha1-2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2' + owner_id: 9919 + repo_id: 259445878 + 'google/oss-fuzz@ed23f8af80ff82b25ca67cd9b101e690b8897b3f': + ref: 'master' + commit: 'sha1-ed23f8af80ff82b25ca67cd9b101e690b8897b3f' + owner_id: 1342004 + repo_id: 63809205 + 'j178/prek-action@v3.0.0': + ref: 'v3.0.0' + commit: 'sha1-4e14d07f9231acabce116ccfca13b13dd9755ece' + owner_id: 10510431 + repo_id: 1052387486 + 'mheap/github-action-required-labels@v5.6.0': + ref: 'v5.6.0' + commit: 'sha1-23e10fde7e062233401931a0eece796cd9bf3177' + owner_id: 59130 + repo_id: 272521528 + 're-actors/alls-green@v1.3.0': + ref: 'v1.3.0' + commit: 'sha1-b5b5b37504aa4183270bd3d855c52a67f212be35' + owner_id: 46427759 + repo_id: 434447646 diff --git a/.github/workflows/add-issue-header.yml b/.github/workflows/add-issue-header.yml deleted file mode 100644 index 55095f17bb4cce9..000000000000000 --- a/.github/workflows/add-issue-header.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Add issue header -# Automatically edits an issue's descriptions with a header, -# one of: -# -# - Bug report -# - Crash report -# - Feature or enhancement - -on: - issues: - types: - # Only ever run once - - opened - -permissions: - contents: read - -jobs: - add-header: - runs-on: ubuntu-slim - permissions: - issues: write - timeout-minutes: 5 - steps: - - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - with: - # language=JavaScript - script: | - // https://devguide.python.org/triage/labels/#type-labels - const HEADERS = new Map([ - ['type-bug', 'Bug report'], - ['type-crash', 'Crash report'], - ['type-feature', 'Feature or enhancement'], - ]); - let issue_data = await github.rest.issues.get({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo - }).then(issue => issue.data); - let header = ''; - for (const label_data of issue_data.labels) { - const label_name = (typeof label_data === 'string') ? label_data : label_data.name; - if (HEADERS.has(label_name)) { - header = HEADERS.get(label_name); - break; - } - } - if (header !== '') { - console.log(`Setting new header: ${header}`); - await github.rest.issues.update({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `# ${header}\n\n${issue_data.body.replaceAll('\r', '')}` - }); - } diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d247f99aefe174c..97971504cb70c96 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,13 +41,13 @@ jobs: # || 'falsy-branch' # }} # - uses: ./.github/workflows/reusable-context.yml + uses: $/.github/workflows/reusable-context.yml check-docs: name: Docs needs: build-context if: fromJSON(needs.build-context.outputs.run-docs) - uses: ./.github/workflows/reusable-docs.yml + uses: $/.github/workflows/reusable-docs.yml check-autoconf-regen: name: 'Check if Autoconf files are up to date' @@ -64,7 +64,7 @@ jobs: run: | apt update && apt install git -yq git config --global --add safe.directory "$GITHUB_WORKSPACE" - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: fetch-depth: 1 persist-credentials: false @@ -101,10 +101,10 @@ jobs: needs: build-context if: needs.build-context.outputs.run-tests == 'true' steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + - uses: actions/setup-python@v7.0.0 with: python-version: '3.x' - name: Runner image version @@ -147,7 +147,7 @@ jobs: if: >- needs.build-context.outputs.run-tests == 'true' || needs.build-context.outputs.run-docs == 'true' - uses: ./.github/workflows/reusable-check-c-api-docs.yml + uses: $/.github/workflows/reusable-check-c-api-docs.yml build-windows: name: >- @@ -167,36 +167,18 @@ jobs: - true interpreter: - switch-case + - tail-call exclude: # Skip Win32 on free-threaded builds - { arch: Win32, free-threading: true } - include: - # msvc::musttail is currently only supported on x64, - # and only supported on 3.15+. - - { arch: x64, free-threading: false, interpreter: tail-call } - - { arch: x64, free-threading: true, interpreter: tail-call } - uses: ./.github/workflows/reusable-windows.yml + # Skip Win32 on tail-call interpreter builds + - { arch: Win32, interpreter: tail-call } + uses: $/.github/workflows/reusable-windows.yml with: arch: ${{ matrix.arch }} free-threading: ${{ matrix.free-threading }} interpreter: ${{ matrix.interpreter }} - build-windows-msi: - # ${{ '' } is a hack to nest jobs under the same sidebar category. - name: Windows MSI${{ '' }} # zizmor: ignore[obfuscation] - needs: build-context - if: fromJSON(needs.build-context.outputs.run-windows-msi) - strategy: - fail-fast: false - matrix: - arch: - - x86 - - x64 - - arm64 - uses: ./.github/workflows/reusable-windows-msi.yml - with: - arch: ${{ matrix.arch }} - build-macos: name: >- macOS @@ -217,7 +199,7 @@ jobs: exclude: - os: macos-26-intel free-threading: true - uses: ./.github/workflows/reusable-macos.yml + uses: $/.github/workflows/reusable-macos.yml with: free-threading: ${{ matrix.free-threading }} os: ${{ matrix.os }} @@ -254,13 +236,19 @@ jobs: bolt: false free-threading: false test-opts: '-u cpu' - uses: ./.github/workflows/reusable-ubuntu.yml + uses: $/.github/workflows/reusable-ubuntu.yml with: bolt-optimizations: ${{ matrix.bolt }} free-threading: ${{ matrix.free-threading }} os: ${{ matrix.os }} test-opts: ${{ matrix.test-opts || '' }} + build-ubuntu-installed: + name: 'Ubuntu (installed)' + needs: build-context + if: needs.build-context.outputs.run-ubuntu == 'true' + uses: $/.github/workflows/reusable-install.yml + build-ubuntu-ssltests: name: 'Ubuntu SSL tests' runs-on: ${{ matrix.os }} @@ -278,20 +266,19 @@ jobs: # unsupported as it most resembles other 1.1.1-work-a-like ssl APIs # supported by important vendors such as AWS-LC. - { name: openssl, version: 1.1.1w } - - { name: openssl, version: 3.0.21 } - - { name: openssl, version: 3.4.6 } - - { name: openssl, version: 3.5.7 } - - { name: openssl, version: 3.6.3 } - - { name: openssl, version: 4.0.1 } + - { name: openssl, version: 3.4.8 } + - { name: openssl, version: 3.5.9 } + - { name: openssl, version: 3.6.5 } + - { name: openssl, version: 4.0.3 } ## AWS-LC - - { name: aws-lc, version: 5.0.0 } + - { name: aws-lc, version: 5.10.0 } env: SSLLIB_VER: ${{ matrix.ssllib.version }} MULTISSL_DIR: ${{ github.workspace }}/multissl SSLLIB_DIR: ${{ github.workspace }}/multissl/${{ matrix.ssllib.name }}/${{ matrix.ssllib.version }} LD_LIBRARY_PATH: ${{ github.workspace }}/multissl/${{ matrix.ssllib.name }}/${{ matrix.ssllib.version }}/lib steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Runner image version @@ -302,7 +289,7 @@ jobs: run: sudo ./.github/workflows/posix-deps-apt.sh - name: 'Restore SSL library build' id: cache-ssl-lib - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 + uses: actions/cache@v6.1.0 with: path: ./multissl/${{ matrix.ssllib.name }}/${{ matrix.ssllib.version }} key: ${{ matrix.os }}-multissl-${{ matrix.ssllib.name }}-${{ matrix.ssllib.version }} @@ -350,37 +337,47 @@ jobs: runs-on: ${{ matrix.runs-on }} steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Build and test - run: JAVA_HOME="${JAVA_HOME_21_X64:-$JAVA_HOME_21_arm64}" python3 Platforms/Android ci --fast-ci ${{ matrix.arch }}-linux-android + run: python3 Platforms/Android ci --fast-ci ${{ matrix.arch }}-linux-android build-ios: - name: iOS + name: >- + iOS + ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} needs: build-context if: needs.build-context.outputs.run-ios == 'true' timeout-minutes: 60 runs-on: macos-26 + strategy: + fail-fast: false + matrix: + free-threading: + - false + - true steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Build and test - run: python3 Platforms/Apple ci iOS --fast-ci + run: >- + python3 Platforms/Apple ci iOS --fast-ci + ${{ fromJSON(matrix.free-threading) && '--abiflags t' || '' }} build-emscripten: name: 'Emscripten' needs: build-context if: needs.build-context.outputs.run-emscripten == 'true' - uses: ./.github/workflows/reusable-emscripten.yml + uses: $/.github/workflows/reusable-emscripten.yml build-wasi: name: 'WASI' needs: build-context if: needs.build-context.outputs.run-wasi == 'true' - uses: ./.github/workflows/reusable-wasi.yml + uses: $/.github/workflows/reusable-wasi.yml test-hypothesis: name: "Hypothesis tests on Ubuntu" @@ -389,10 +386,10 @@ jobs: needs: build-context if: needs.build-context.outputs.run-ubuntu == 'true' env: - OPENSSL_VER: 3.5.7 + OPENSSL_VER: 3.5.9 PYTHONSTRICTEXTENSIONBUILD: 1 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Register gcc problem matcher @@ -406,7 +403,7 @@ jobs: echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> "$GITHUB_ENV" - name: 'Restore OpenSSL build' id: cache-openssl - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 + uses: actions/cache@v6.1.0 with: path: ./multissl/openssl/${{ env.OPENSSL_VER }} key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }} @@ -453,7 +450,7 @@ jobs: ./python -m venv "$VENV_LOC" && "$VENV_PYTHON" -m pip install -r "${GITHUB_WORKSPACE}/Tools/requirements-hypothesis.txt" - name: 'Restore Hypothesis database' id: cache-hypothesis-database - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 + uses: actions/cache@v6.1.0 with: path: ${{ env.CPYTHON_BUILDDIR }}/.hypothesis/ key: hypothesis-database-${{ github.head_ref || github.run_id }} @@ -480,58 +477,17 @@ jobs: -x test_subprocess \ -x test_signal \ -x test_sysconfig - - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + - uses: actions/upload-artifact@v7.0.1 if: always() with: name: hypothesis-example-db path: ${{ env.CPYTHON_BUILDDIR }}/.hypothesis/examples/ - build-asan: - name: 'Address sanitizer' - runs-on: ${{ matrix.os }} - timeout-minutes: 60 + test-lazy-imports-all: + name: 'Lazy imports enabled' needs: build-context - if: needs.build-context.outputs.run-ubuntu == 'true' - strategy: - fail-fast: false - matrix: - os: [ubuntu-26.04] - env: - OPENSSL_VER: 3.5.7 - PYTHONSTRICTEXTENSIONBUILD: 1 - ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0 - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - - name: Runner image version - run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV" - - name: Register gcc problem matcher - run: echo "::add-matcher::.github/problem-matchers/gcc.json" - - name: Install dependencies - run: sudo ./.github/workflows/posix-deps-apt.sh - - name: Configure OpenSSL env vars - run: | - echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV" - echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> "$GITHUB_ENV" - echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> "$GITHUB_ENV" - - name: 'Restore OpenSSL build' - id: cache-openssl - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 - with: - path: ./multissl/openssl/${{ env.OPENSSL_VER }} - key: ${{ matrix.os }}-multissl-openssl-${{ env.OPENSSL_VER }} - - name: Install OpenSSL - if: steps.cache-openssl.outputs.cache-hit != 'true' - run: python3 Tools/ssl/multissltests.py --steps=library --base-directory "$MULTISSL_DIR" --openssl "$OPENSSL_VER" --system Linux - - name: Configure CPython - run: ./configure --config-cache --with-address-sanitizer --without-pymalloc --with-openssl="$OPENSSL_DIR" - - name: Build CPython - run: make -j4 - - name: Display build info - run: make pythoninfo - - name: Tests - run: xvfb-run make ci + if: fromJSON(needs.build-context.outputs.run-tests) + uses: $/.github/workflows/reusable-test-lazy-imports-all.yml build-san: # ${{ '' } is a hack to nest jobs under the same sidebar category. @@ -549,10 +505,16 @@ jobs: sanitizer: - TSan include: + - check-name: Address + sanitizer: ASan + free-threading: false - check-name: Undefined behavior sanitizer: UBSan free-threading: false - uses: ./.github/workflows/reusable-san.yml + - check-name: Memory + sanitizer: MSan + free-threading: false + uses: $/.github/workflows/reusable-san.yml with: sanitizer: ${{ matrix.sanitizer }} free-threading: ${{ matrix.free-threading }} @@ -564,7 +526,7 @@ jobs: needs: build-context if: needs.build-context.outputs.run-ubuntu == 'true' steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Runner image version @@ -585,13 +547,21 @@ jobs: run: | "$BUILD_DIR/host-python/bin/python3" -m test test_sysconfig test_site test_embed - name: Configure cross build - run: ./configure --prefix="$BUILD_DIR/cross-python" --with-build-python="$BUILD_DIR/host-python/bin/python3" + run: | + # Exercise a native build whose builtin modules differ from the build Python. + echo '_bisect _bisectmodule.c' > Modules/Setup.local + ./configure --prefix="$BUILD_DIR/cross-python" --with-build-python="$BUILD_DIR/host-python/bin/python3" - name: Install cross Python run: make -j8 install + - name: Check native extension modules with a build Python + run: | + "$BUILD_DIR/host-python/bin/python3" -c "import sys; assert '_bisect' not in sys.builtin_module_names" + "$BUILD_DIR/cross-python/bin/python3" -c "import _bisect, sys; assert '_bisect' in sys.builtin_module_names" + PYTHONSTRICTEXTENSIONBUILD=1 make checksharedmods - name: Display build info run: | "$BUILD_DIR/cross-python/bin/python3" -m test.pythoninfo - - name: Run test subset with host build + - name: Run test subset with cross build run: | "$BUILD_DIR/cross-python/bin/python3" -m test test_sysconfig test_site test_embed @@ -634,7 +604,7 @@ jobs: && 'no-exclude' || 'python3-libraries' }} - uses: ./.github/workflows/reusable-cifuzz.yml + uses: $/.github/workflows/reusable-cifuzz.yml with: oss-fuzz-project-name: ${{ matrix.oss-fuzz-project-name }} sanitizer: ${{ matrix.sanitizer }} @@ -650,15 +620,15 @@ jobs: - check-generated-files - check-c-api-docs - build-windows - - build-windows-msi - build-macos - build-ubuntu + - build-ubuntu-installed - build-ubuntu-ssltests - build-ios - build-emscripten - build-wasi - test-hypothesis - - build-asan + - test-lazy-imports-all - build-san - cross-build-linux - cifuzz @@ -666,12 +636,11 @@ jobs: steps: - name: Check whether the needed jobs succeeded or failed - uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe + uses: re-actors/alls-green@v1.3.0 with: allowed-failures: >- build-android, build-emscripten, - build-windows-msi, build-ubuntu-ssltests, test-hypothesis, cifuzz, @@ -703,9 +672,9 @@ jobs: !fromJSON(needs.build-context.outputs.run-ubuntu) && ' build-ubuntu, + build-ubuntu-installed, build-ubuntu-ssltests, test-hypothesis, - build-asan, build-san, cross-build-linux, ' @@ -715,4 +684,5 @@ jobs: ${{ !fromJSON(needs.build-context.outputs.run-ios) && 'build-ios,' || '' }} ${{ !fromJSON(needs.build-context.outputs.run-emscripten) && 'build-emscripten,' || '' }} ${{ !fromJSON(needs.build-context.outputs.run-wasi) && 'build-wasi,' || '' }} + ${{ !fromJSON(needs.build-context.outputs.run-tests) && 'test-lazy-imports-all,' || '' }} jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/jit.yml b/.github/workflows/jit.yml index 813589c2bc14c8b..21ecb2c958c12d3 100644 --- a/.github/workflows/jit.yml +++ b/.github/workflows/jit.yml @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-26.04 timeout-minutes: 60 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Install dependencies @@ -72,10 +72,10 @@ jobs: architecture: ARM64 runner: windows-11-arm steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + - uses: actions/setup-python@v7.0.0 with: python-version: '3.11' # PCbuild downloads LLVM automatically: @@ -87,29 +87,21 @@ jobs: ./PCbuild/rt.bat ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3 macos: - name: ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) + name: aarch64-apple-darwin/clang (${{ matrix.debug && 'Debug' || 'Release' }}) - runs-on: ${{ matrix.runner }} + runs-on: macos-26 timeout-minutes: 60 strategy: fail-fast: false matrix: - target: - - x86_64-apple-darwin/clang - - aarch64-apple-darwin/clang debug: - true - false - include: - - target: x86_64-apple-darwin/clang - runner: macos-26-intel - - target: aarch64-apple-darwin/clang - runner: macos-26 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + - uses: actions/setup-python@v7.0.0 with: python-version: '3.11' - name: Install LLVM @@ -149,10 +141,10 @@ jobs: - target: aarch64-unknown-linux-gnu/gcc runner: ubuntu-26.04-arm steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + - uses: actions/setup-python@v7.0.0 with: python-version: '3.11' - name: Install dependencies @@ -190,10 +182,10 @@ jobs: use_clang: true run_tests: false steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + - uses: actions/setup-python@v7.0.0 with: python-version: '3.11' - name: Install dependencies diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8a79ea20d5f50bc..0b89ebe92d367d4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,7 +19,22 @@ jobs: timeout-minutes: 10 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: j178/prek-action@bdca6f102f98e2b4c7029491a53dfd366469e33d # v2.0.4 + - uses: j178/prek-action@v3.0.0 + + # Fails when .github/workflows/actions.lock is out of sync with the + # workflows or a locked pin no longer verifies upstream. + lockfile: + runs-on: ubuntu-slim + timeout-minutes: 10 + env: + GH_TOKEN: ${{ github.token }} + + steps: + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + - run: gh extension install github/gh-actions-lock --pin v0.4.1 + - run: gh actions-lock --verify diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 3cdce4f5952e3d0..6109870724ea59c 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -66,10 +66,10 @@ jobs: "Tools/peg_generator", ] steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + - uses: astral-sh/setup-uv@v10.2.0 with: python-version: "3.15" activate-environment: true diff --git a/.github/workflows/new-bugs-announce-notifier.yml b/.github/workflows/new-bugs-announce-notifier.yml index 864d0f48904bcc3..8a1c59f50d8d1de 100644 --- a/.github/workflows/new-bugs-announce-notifier.yml +++ b/.github/workflows/new-bugs-announce-notifier.yml @@ -15,12 +15,14 @@ jobs: issues: read timeout-minutes: 10 steps: - - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + - uses: actions/setup-node@v7.0.0 with: node-version: 20 - - run: npm install mailgun.js form-data + # TODO: Replace with a committed lockfile and `npm ci`, or drop npm + # and call the Mailgun REST API from the standard library. + - run: npm install mailgun.js form-data # zizmor: ignore[adhoc-packages] - name: Send notification - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + uses: actions/github-script@v9.0.0 env: MAILGUN_API_KEY: ${{ secrets.MAILGUN_PYTHON_ORG_MAILGUN_KEY }} with: diff --git a/.github/workflows/require-pr-label.yml b/.github/workflows/require-pr-label.yml index 8af254c10786e1b..58d223bb34f203c 100644 --- a/.github/workflows/require-pr-label.yml +++ b/.github/workflows/require-pr-label.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Check there's no DO-NOT-MERGE - uses: mheap/github-action-required-labels@0ac283b4e65c1fb28ce6079dea5546ceca98ccbe # v5.5.2 + uses: mheap/github-action-required-labels@v5.6.0 with: mode: exactly count: 0 @@ -36,7 +36,7 @@ jobs: steps: # Check that the PR is not awaiting changes from the author due to previous review. - name: Check there's no required changes - uses: mheap/github-action-required-labels@0ac283b4e65c1fb28ce6079dea5546ceca98ccbe # v5.5.2 + uses: mheap/github-action-required-labels@v5.6.0 with: mode: exactly count: 0 @@ -45,7 +45,7 @@ jobs: awaiting change review - id: is-feature name: Check whether this PR is a feature (contains a "type-feature" label) - uses: mheap/github-action-required-labels@0ac283b4e65c1fb28ce6079dea5546ceca98ccbe # v5.5.2 + uses: mheap/github-action-required-labels@v5.6.0 with: mode: exactly count: 1 @@ -56,9 +56,12 @@ jobs: - id: awaiting-merge if: steps.is-feature.outputs.status == 'success' name: Check for complete review - uses: mheap/github-action-required-labels@0ac283b4e65c1fb28ce6079dea5546ceca98ccbe # v5.5.2 + uses: mheap/github-action-required-labels@v5.6.0 with: mode: exactly count: 1 labels: | awaiting merge + message: >- + This PR is labelled type-feature. All features require approval from a + core team member before merge. Found: {{ applied }} diff --git a/.github/workflows/reusable-check-c-api-docs.yml b/.github/workflows/reusable-check-c-api-docs.yml index db030c80008b1ed..ed4b3f86df4e00b 100644 --- a/.github/workflows/reusable-check-c-api-docs.yml +++ b/.github/workflows/reusable-check-c-api-docs.yml @@ -15,10 +15,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + - uses: actions/setup-python@v7.0.0 with: python-version: '3.x' - name: Check for undocumented C APIs diff --git a/.github/workflows/reusable-check-html-ids.yml b/.github/workflows/reusable-check-html-ids.yml index 41ba1288be1ecf4..bd258ecd971a7ad 100644 --- a/.github/workflows/reusable-check-html-ids.yml +++ b/.github/workflows/reusable-check-html-ids.yml @@ -16,7 +16,7 @@ jobs: timeout-minutes: 30 steps: - name: 'Check out PR head' - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + uses: actions/checkout@v7.0.1 with: persist-credentials: false ref: ${{ github.event.pull_request.head.sha }} @@ -43,7 +43,7 @@ jobs: MERGE_BASE: ${{ steps.merge-base.outputs.sha }} run: git worktree add /tmp/merge-base "$MERGE_BASE" --detach - name: 'Set up Python' - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + uses: actions/setup-python@v7.0.0 with: python-version: '3' cache: 'pip' @@ -55,7 +55,7 @@ jobs: - name: 'Collect HTML IDs' run: python Doc/tools/check-html-ids.py collect /tmp/merge-base/Doc/build/html -o /tmp/html-ids-base.json.gz - name: 'Download PR head HTML IDs' - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + uses: actions/download-artifact@v8.0.1 with: name: html-ids-head.json.gz path: /tmp diff --git a/.github/workflows/reusable-cifuzz.yml b/.github/workflows/reusable-cifuzz.yml index 0d02232686339bf..e14c842d7a8dafe 100644 --- a/.github/workflows/reusable-cifuzz.yml +++ b/.github/workflows/reusable-cifuzz.yml @@ -37,13 +37,13 @@ jobs: sanitizer: ${{ inputs.sanitizer }} - name: Upload crash if: failure() && steps.build.outcome == 'success' - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + uses: actions/upload-artifact@v7.0.1 with: name: ${{ inputs.sanitizer }}-artifacts path: ./out/artifacts - name: Upload SARIF if: always() && steps.build.outcome == 'success' - uses: github/codeql-action/upload-sarif@38697555549f1db7851b81482ff19f1fa5c4fedc # v4.34.1 + uses: github/codeql-action/upload-sarif@v4.38.2 with: sarif_file: cifuzz-sarif/results.sarif checkout_path: cifuzz-sarif diff --git a/.github/workflows/reusable-context.yml b/.github/workflows/reusable-context.yml index 6595aef0377e500..6c3b454d1a40997 100644 --- a/.github/workflows/reusable-context.yml +++ b/.github/workflows/reusable-context.yml @@ -47,9 +47,6 @@ on: # yamllint disable-line rule:truthy run-wasi: description: Whether to run the WASI tests value: ${{ jobs.compute-changes.outputs.run-wasi }} # bool - run-windows-msi: - description: Whether to run the MSI installer smoke tests - value: ${{ jobs.compute-changes.outputs.run-windows-msi }} # bool run-windows-tests: description: Whether to run the Windows tests value: ${{ jobs.compute-changes.outputs.run-windows-tests }} # bool @@ -73,18 +70,17 @@ jobs: run-ubuntu: ${{ steps.changes.outputs.run-ubuntu }} run-emscripten: ${{ steps.changes.outputs.run-emscripten }} run-wasi: ${{ steps.changes.outputs.run-wasi }} - run-windows-msi: ${{ steps.changes.outputs.run-windows-msi }} run-windows-tests: ${{ steps.changes.outputs.run-windows-tests }} steps: - name: Set up Python - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + uses: actions/setup-python@v7.0.0 with: python-version: "3" - run: >- echo '${{ github.event_name }}' - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false ref: >- diff --git a/.github/workflows/reusable-docs.yml b/.github/workflows/reusable-docs.yml index 199e0fd8d181f0b..b60bdfd302db8fa 100644 --- a/.github/workflows/reusable-docs.yml +++ b/.github/workflows/reusable-docs.yml @@ -38,7 +38,7 @@ jobs: refspec_pr: '+${{ github.event.pull_request.head.sha }}:remotes/origin/${{ github.event.pull_request.head.ref }}' steps: - name: 'Check out latest PR branch commit' - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + uses: actions/checkout@v7.0.1 with: persist-credentials: false ref: >- @@ -63,7 +63,7 @@ jobs: git fetch origin "${refspec_base}" --shallow-since="${DATE}" \ --no-tags --prune --no-recurse-submodules - name: 'Set up Python' - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + uses: actions/setup-python@v7.0.0 with: python-version: '3' cache: 'pip' @@ -86,12 +86,15 @@ jobs: --fail-if-regression \ --fail-if-improved \ --fail-if-new-news-nit + - name: 'Build list of changes' + run: | + make -C Doc/ PYTHON=../python changes - name: 'Collect HTML IDs' if: github.event_name == 'pull_request' run: python Doc/tools/check-html-ids.py collect Doc/build/html -o Doc/build/html-ids-head.json.gz - name: 'Upload HTML IDs' if: github.event_name == 'pull_request' - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + uses: actions/upload-artifact@v7.0.1 with: name: html-ids-head path: Doc/build/html-ids-head.json.gz @@ -101,7 +104,7 @@ jobs: name: 'Check for removed HTML IDs' needs: build-doc if: github.event_name == 'pull_request' - uses: ./.github/workflows/reusable-check-html-ids.yml + uses: $/.github/workflows/reusable-check-html-ids.yml # Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release doctest: @@ -109,10 +112,10 @@ jobs: runs-on: ubuntu-26.04 timeout-minutes: 60 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 + - uses: actions/cache@v6.1.0 with: path: ~/.cache/pip key: ubuntu-doc-${{ hashFiles('Doc/requirements.txt') }} @@ -135,11 +138,11 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: 'Set up Python' - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + uses: actions/setup-python@v7.0.0 with: python-version: '3' cache: 'pip' diff --git a/.github/workflows/reusable-emscripten.yml b/.github/workflows/reusable-emscripten.yml index c8832342d9892da..6565e671420f09e 100644 --- a/.github/workflows/reusable-emscripten.yml +++ b/.github/workflows/reusable-emscripten.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-26.04 timeout-minutes: 40 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: "Read Emscripten config" @@ -39,20 +39,20 @@ jobs: f.write(f"node-version={config['node-version']}\n") f.write(f"deps-hash={h.hexdigest()}\n") with open(os.environ["GITHUB_ENV"], "a") as f: - f.write(f"EMSDK_CACHE={emsdk_cache}\n") + f.write(f"PY_EMSDK_CACHE={emsdk_cache}\n") - name: "Install Node.js" - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + uses: actions/setup-node@v7.0.0 with: node-version: ${{ steps.emscripten-config.outputs.node-version }} - name: "Cache Emscripten SDK" id: emsdk-cache - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 + uses: actions/cache@v6.1.0 with: - path: ${{ env.EMSDK_CACHE }} + path: ${{ env.PY_EMSDK_CACHE }} key: emsdk-${{ steps.emscripten-config.outputs.emscripten-version }}-${{ steps.emscripten-config.outputs.deps-hash }} restore-keys: emsdk-${{ steps.emscripten-config.outputs.emscripten-version }} - name: "Install Python" - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + uses: actions/setup-python@v7.0.0 with: python-version: '3.x' - name: "Runner image version" @@ -79,3 +79,5 @@ jobs: run: python3 Platforms/emscripten run --test - name: "Test Repl" run: Platforms/emscripten/browser_test/run_test.sh + - name: "Test embedding" + run: Platforms/emscripten/web_embed_test/run_test.sh diff --git a/.github/workflows/reusable-install.yml b/.github/workflows/reusable-install.yml new file mode 100644 index 000000000000000..fa09a9a4f34c58d --- /dev/null +++ b/.github/workflows/reusable-install.yml @@ -0,0 +1,44 @@ +name: Reusable Ubuntu (installed) + +on: + workflow_call: + +permissions: + contents: read + +env: + FORCE_COLOR: 1 + +jobs: + build-install-test: + name: build, install and test + runs-on: ubuntu-26.04-arm + timeout-minutes: 60 + env: + PYTHONSTRICTEXTENSIONBUILD: 1 + steps: + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + - name: Register gcc problem matcher + run: echo "::add-matcher::.github/problem-matchers/gcc.json" + - name: Set install dir + run: + echo "INSTALL_DIR=$(realpath "${GITHUB_WORKSPACE}/../installed-python")" >> "$GITHUB_ENV" + - name: Install dependencies + run: sudo ./.github/workflows/posix-deps-apt.sh + - name: Configure CPython + run: ./configure --config-cache --prefix="$INSTALL_DIR" + - name: Build CPython + run: make -j + - name: Install CPython + run: make install + - name: Set installed interpreter + run: | + ldversion=$(./python -c 'import sysconfig; print(sysconfig.get_config_var("LDVERSION"))') + echo "INSTALLED_PYTHON=${INSTALL_DIR}/bin/python${ldversion}" >> "$GITHUB_ENV" + - name: Display build info + run: | + "$INSTALLED_PYTHON" -m test.pythoninfo + - name: Test the installed Python + run: xvfb-run "$INSTALLED_PYTHON" -m test --fast-ci --timeout=900 diff --git a/.github/workflows/reusable-macos.yml b/.github/workflows/reusable-macos.yml index 5393e9e34040b95..ec9fd64b282aa1c 100644 --- a/.github/workflows/reusable-macos.yml +++ b/.github/workflows/reusable-macos.yml @@ -31,7 +31,7 @@ jobs: PYTHONSTRICTEXTENSIONBUILD: 1 TERM: linux steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Runner image version @@ -51,6 +51,7 @@ jobs: --enable-slower-safety \ --enable-safety \ ${{ inputs.free-threading && '--disable-gil' || '' }} \ + --with-tail-call-interp \ --prefix=/opt/python-dev \ --with-openssl="$(brew --prefix openssl@3.5)" - name: Build CPython diff --git a/.github/workflows/reusable-san.yml b/.github/workflows/reusable-san.yml index 40464695a281afd..fb7d84e889e118f 100644 --- a/.github/workflows/reusable-san.yml +++ b/.github/workflows/reusable-san.yml @@ -17,7 +17,7 @@ permissions: env: FORCE_COLOR: 1 - OPENSSL_VER: 3.5.7 + OPENSSL_VER: 3.5.9 jobs: build-san-reusable: @@ -30,7 +30,7 @@ jobs: runs-on: ubuntu-26.04 timeout-minutes: 60 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Runner image version @@ -43,6 +43,15 @@ jobs: # please update the versions in `Tools/pixi-packages/variants.yaml` too. echo "CC=clang" >> "$GITHUB_ENV" echo "CXX=clang++" >> "$GITHUB_ENV" + - name: ASan option setup + if: inputs.sanitizer == 'ASan' + run: | + echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV" + echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> "$GITHUB_ENV" + echo "ASAN_OPTIONS=${SAN_LOG_OPTION} detect_leaks=0 allocator_may_return_null=1 handle_segv=0" >> "$GITHUB_ENV" + echo "PYTHONSTRICTEXTENSIONBUILD=1" >> "$GITHUB_ENV" + env: + SAN_LOG_OPTION: log_path=${{ github.workspace }}/san_log - name: TSan option setup if: inputs.sanitizer == 'TSan' run: | @@ -55,12 +64,12 @@ jobs: SAN_LOG_OPTION: log_path=${{ github.workspace }}/san_log SUPPRESSIONS_SUFFIX: >- ${{ - fromJSON(inputs.free-threading) + inputs.free-threading && '_free_threading' || '' }} - name: UBSan option setup - if: inputs.sanitizer != 'TSan' + if: inputs.sanitizer == 'UBSan' run: >- echo "UBSAN_OPTIONS=${SAN_LOG_OPTION} @@ -69,19 +78,38 @@ jobs: >> "$GITHUB_ENV" env: SAN_LOG_OPTION: log_path=${{ github.workspace }}/san_log + - name: MSan option setup + if: inputs.sanitizer == 'MSan' + run: | + sudo sysctl -w vm.mmap_rnd_bits=28 # Reduce ASLR to avoid MSan re-executing + + echo "MSAN_OPTIONS=${SAN_LOG_OPTION} allocator_may_return_null=1 handle_segv=0" >> "$GITHUB_ENV" + # MSan reports false positives for memory initialized by libraries + # that are not built with MSan, so disable modules that use them. + # _remote_debugging links to libzstd directly, but we unpoision the memory. + { + echo '*disabled*' + echo '_bz2 _ctypes _curses _curses_panel _dbm _decimal _gdbm _hashlib' + echo '_lzma _sqlite3 _ssl _tkinter _uuid _zstd readline zlib' + } > Modules/Setup.local + env: + SAN_LOG_OPTION: log_path=${{ github.workspace }}/san_log - name: Add ccache to PATH run: | echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV" - - name: 'Restore OpenSSL build (TSan)' + - name: 'Restore OpenSSL build' id: cache-openssl - if: inputs.sanitizer == 'TSan' - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 + if: inputs.sanitizer == 'TSan' || inputs.sanitizer == 'ASan' + uses: actions/cache@v6.1.0 with: path: ./multissl/openssl/${{ env.OPENSSL_VER }} - key: ${{ env.IMAGE_OS_VERSION }}-multissl-openssl-tsan-${{ env.OPENSSL_VER }} - - name: Install OpenSSL (TSan) + key: >- + ${{ env.IMAGE_OS_VERSION }}-multissl-openssl-${{ + inputs.sanitizer == 'TSan' && 'tsan-' || '' + }}${{ env.OPENSSL_VER }} + - name: Install OpenSSL if: >- - inputs.sanitizer == 'TSan' + (inputs.sanitizer == 'TSan' || inputs.sanitizer == 'ASan') && steps.cache-openssl.outputs.cache-hit != 'true' run: >- python3 Tools/ssl/multissltests.py @@ -89,19 +117,33 @@ jobs: --base-directory="${MULTISSL_DIR}" --openssl="${OPENSSL_VER}" --system=Linux - --tsan + ${{ inputs.sanitizer == 'TSan' && '--tsan' || '' }} + # gh-157958: -O2 instead of the pydebug default -Og to avoid a clang 21 + # compile-time blowup on some interpreter files. + # (https://github.com/llvm/llvm-project/issues/179695) + # MSan uses --with-assertions instead of --with-pydebug because its + # hooks on the Python memory allocators hide uninitialized reads. - name: Configure CPython run: >- ./configure --config-cache + OPT="-O2 -g" ${{ - inputs.sanitizer == 'TSan' + inputs.sanitizer == 'ASan' + && '--with-address-sanitizer --without-pymalloc' + || inputs.sanitizer == 'TSan' && '--with-thread-sanitizer' + || inputs.sanitizer == 'MSan' + && '--with-memory-sanitizer' || '--with-undefined-behavior-sanitizer --with-strict-overflow' }} - --with-pydebug - ${{ inputs.sanitizer == 'TSan' && '--with-openssl="$OPENSSL_DIR" --with-openssl-rpath=auto' || '' }} - ${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }} + ${{ inputs.sanitizer == 'MSan' && '--with-assertions' || '--with-pydebug' }} + ${{ + (inputs.sanitizer == 'TSan' || inputs.sanitizer == 'ASan') + && '--with-openssl="$OPENSSL_DIR" --with-openssl-rpath=auto' + || '' + }} + ${{ inputs.free-threading && '--disable-gil' || '' }} - name: Build CPython run: make -j4 - name: Display build info @@ -114,18 +156,18 @@ jobs: - name: Parallel tests if: >- inputs.sanitizer == 'TSan' - && fromJSON(inputs.free-threading) + && inputs.free-threading run: ./python -m test --tsan-parallel --parallel-threads=4 -j4 -W --timeout=600 --slowest - name: Display logs if: always() run: find "${GITHUB_WORKSPACE}" -name 'san_log.*' | xargs head -n 1000 - name: Archive logs if: always() - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + uses: actions/upload-artifact@v7.0.1 with: name: >- ${{ inputs.sanitizer }}-logs-${{ - fromJSON(inputs.free-threading) + inputs.free-threading && 'free-threading' || 'default' }} diff --git a/.github/workflows/reusable-test-lazy-imports-all.yml b/.github/workflows/reusable-test-lazy-imports-all.yml new file mode 100644 index 000000000000000..ea2615b880558b0 --- /dev/null +++ b/.github/workflows/reusable-test-lazy-imports-all.yml @@ -0,0 +1,81 @@ +name: Reusable Lazy Imports Tests + +# Run the CPython test suite with global lazy imports forced on +# (``-X lazy_imports=all``). +# +# Modules that are known to fail under lazy imports are listed in +# Lib/test/lazy_imports_all_exclude.txt and skipped here. Remove entries from +# that file as the modules are fixed so this workflow starts guarding them +# against regressions. Excluded modules are also checked separately so the +# workflow fails when one starts passing and its exclusion should be removed. + +on: + workflow_call: + +permissions: + contents: read + +env: + FORCE_COLOR: 1 + +jobs: + test-lazy-imports-all: + name: 'Run Tests with lazy_imports=all' + runs-on: ubuntu-26.04 + timeout-minutes: 60 + env: + EXCLUDE_FILE: Lib/test/lazy_imports_all_exclude.txt + steps: + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + - name: Register gcc problem matcher + run: echo "::add-matcher::.github/problem-matchers/gcc.json" + - name: Install dependencies + run: sudo ./.github/workflows/posix-deps-apt.sh + - name: Configure CPython + run: ./configure --config-cache --with-pydebug + - name: Build CPython + run: make -j4 + - name: Display build info + run: make pythoninfo + - name: Verify lazy imports are fully enabled + run: ./python -X lazy_imports=all -c "import sys; assert sys.flags.lazy_imports == 1, sys.flags.lazy_imports; print('lazy imports all enabled')" + - name: Build test list (all tests minus the known-failing exclusions) + run: | + set -euo pipefail + ./python -m test --list-tests > all_tests.txt + # Strip comments/blank lines from the exclusion file, then drop those + # exact test names (whole-line, fixed-string match) from the run list. + grep -vE '^\s*(#.*)?$' "$EXCLUDE_FILE" > exclude_tests.txt || true + grep -vxF -f exclude_tests.txt all_tests.txt > run_tests.txt + # Fail loudly if any exclusion entry matched nothing: a stale or + # mistyped name (or a change in `--list-tests` output) would otherwise + # silently stop excluding a module and let it fail the run. + stale=$(comm -23 <(sort -u exclude_tests.txt) <(sort -u all_tests.txt)) + if [ -n "$stale" ]; then + echo "::error::Stale entries in $EXCLUDE_FILE (no longer match 'python -m test --list-tests'); remove or fix them:" + echo "$stale" + exit 1 + fi + echo "Excluding $(wc -l < exclude_tests.txt) module(s); running $(wc -l < run_tests.txt) of $(wc -l < all_tests.txt)." + - name: Run tests with lazy imports + run: xvfb-run xargs -a run_tests.txt ./python -X lazy_imports=all -m test --fast-ci --timeout=900 < /dev/null + - name: Verify excluded tests still need exclusion + run: | + set -euo pipefail + # Failures are expected here, don't report them to the job summary + unset GITHUB_STEP_SUMMARY + unexpected_passes=() + while IFS= read -r test_name; do + [ -n "$test_name" ] || continue + echo "Checking excluded test: $test_name" + if xvfb-run ./python -X lazy_imports=all -m test --fast-ci --timeout=900 "$test_name"; then + unexpected_passes+=("$test_name") + fi + done < exclude_tests.txt + if [ "${#unexpected_passes[@]}" -ne 0 ]; then + echo "::error::These tests still appear in $EXCLUDE_FILE but now pass with -X lazy_imports=all. Remove them from the exclude file:" + printf '%s\n' "${unexpected_passes[@]}" + exit 1 + fi diff --git a/.github/workflows/reusable-ubuntu.yml b/.github/workflows/reusable-ubuntu.yml index 4ecc541e6aa7d02..f6e42e1861349c4 100644 --- a/.github/workflows/reusable-ubuntu.yml +++ b/.github/workflows/reusable-ubuntu.yml @@ -14,14 +14,14 @@ on: type: boolean default: false os: - description: OS to run the job - required: true - type: string + description: OS to run the job + required: true + type: string test-opts: - description: Extra options to pass to the test runner via TESTOPTS - required: false - type: string - default: '' + description: Extra options to pass to the test runner via TESTOPTS + required: false + type: string + default: '' permissions: contents: read @@ -35,11 +35,11 @@ jobs: runs-on: ${{ inputs.os }} timeout-minutes: 60 env: - OPENSSL_VER: 3.5.7 + OPENSSL_VER: 3.5.9 PYTHONSTRICTEXTENSIONBUILD: 1 TERM: linux steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Register gcc problem matcher @@ -47,7 +47,7 @@ jobs: - name: Install dependencies run: sudo ./.github/workflows/posix-deps-apt.sh - name: Install Clang and BOLT - if: ${{ fromJSON(inputs.bolt-optimizations) }} + if: inputs.bolt-optimizations run: | # On ubuntu-26.04 image, LLVM is LLVM-21 by default sudo apt-get install --no-install-recommends bolt-21 @@ -59,7 +59,7 @@ jobs: echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> "$GITHUB_ENV" - name: 'Restore OpenSSL build' id: cache-openssl - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 + uses: actions/cache@v6.1.0 with: path: ./multissl/openssl/${{ env.OPENSSL_VER }} key: ${{ inputs.os }}-multissl-openssl-${{ env.OPENSSL_VER }} @@ -88,10 +88,10 @@ jobs: --enable-slower-safety --enable-safety --with-openssl="$OPENSSL_DIR" - ${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }} - ${{ fromJSON(inputs.bolt-optimizations) && '--enable-bolt' || '' }} + ${{ inputs.free-threading && '--disable-gil' || '' }} + ${{ inputs.bolt-optimizations && '--enable-bolt' || '' }} - name: Build CPython out-of-tree - if: ${{ inputs.free-threading }} + if: inputs.free-threading working-directory: ${{ env.CPYTHON_BUILDDIR }} run: make -j - name: Build CPython out-of-tree (for compiler warning check) diff --git a/.github/workflows/reusable-wasi.yml b/.github/workflows/reusable-wasi.yml index b0dda62d0b291c2..d4d51fbd1f3029c 100644 --- a/.github/workflows/reusable-wasi.yml +++ b/.github/workflows/reusable-wasi.yml @@ -15,15 +15,14 @@ jobs: runs-on: ubuntu-26.04-arm timeout-minutes: 60 env: - WASMTIME_VERSION: 38.0.3 - CROSS_BUILD_WASI: cross-build/wasm32-wasip1 + WASMTIME_VERSION: 48.0.2 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false # No problem resolver registered as one doesn't currently exist for Clang. - name: "Install wasmtime" - uses: bytecodealliance/actions/wasmtime/setup@9152e710e9f7182e4c29ad218e4f335a7b203613 # v1.1.3 + uses: bytecodealliance/actions/wasmtime/setup@v1.1.3 with: version: ${{ env.WASMTIME_VERSION }} - name: "Read WASI SDK version" @@ -39,12 +38,12 @@ jobs: shell: python - name: "Install WASI SDK" id: install-wasi-sdk - uses: bytecodealliance/setup-wasi-sdk-action@b2de090b44eb70013ee96b393727d473b35e1728 + uses: bytecodealliance/setup-wasi-sdk-action@v1.0.0 with: version: ${{ steps.wasi-sdk-version.outputs.version }} add-to-path: false - name: "Install Python" - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + uses: actions/setup-python@v7.0.0 with: python-version: '3.x' - name: "Runner image version" @@ -65,4 +64,4 @@ jobs: - name: "Display build info of the host/WASI Python" run: python3 Platforms/WASI pythoninfo-host - name: "Test" - run: make --directory "${CROSS_BUILD_WASI}" test + run: python3 Platforms/WASI test diff --git a/.github/workflows/reusable-windows-msi.yml b/.github/workflows/reusable-windows-msi.yml deleted file mode 100644 index d57046ae5ca8f00..000000000000000 --- a/.github/workflows/reusable-windows-msi.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Reusable Windows MSI - -on: - workflow_call: - inputs: - arch: - description: CPU architecture - required: true - type: string - -permissions: - contents: read - -env: - FORCE_COLOR: 1 - -jobs: - build: - name: installer for ${{ inputs.arch }} - runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2025' }} - timeout-minutes: 60 - env: - ARCH: ${{ inputs.arch }} - IncludeFreethreaded: true - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - - name: Build CPython installer - run: ./Tools/msi/build.bat --doc -"${ARCH}" - shell: bash diff --git a/.github/workflows/reusable-windows.yml b/.github/workflows/reusable-windows.yml index 707b8d7efb5e0db..eb6c22f2c4cf437 100644 --- a/.github/workflows/reusable-windows.yml +++ b/.github/workflows/reusable-windows.yml @@ -31,7 +31,7 @@ jobs: env: ARCH: ${{ inputs.arch }} steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Register MSVC problem matcher @@ -45,7 +45,7 @@ jobs: -e -v ${{ inputs.interpreter == 'switch-case' && '-d' || '--tail-call-interp -c Release' }} -p "${ARCH}" - ${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }} + ${{ inputs.free-threading && '--disable-gil' || '' }} shell: bash - name: Display build info run: .\\python.bat -m test.pythoninfo @@ -55,5 +55,5 @@ jobs: -p "${ARCH}" -q --fast-ci ${{ inputs.interpreter == 'switch-case' && '-d' || '' }} - ${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }} + ${{ inputs.free-threading && '--disable-gil' || '' }} shell: bash diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 0283e9f621dcf05..4b528a6f9861778 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -18,7 +18,7 @@ jobs: steps: - name: "Check PRs" - uses: actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f # v10.2.0 + uses: actions/stale@v11.0.0 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-pr-message: 'This PR is stale because it has been open for 90 days with no activity.' diff --git a/.github/workflows/tail-call.yml b/.github/workflows/tail-call.yml index 81e8235f236ea70..c302f543a8fd746 100644 --- a/.github/workflows/tail-call.yml +++ b/.github/workflows/tail-call.yml @@ -23,40 +23,6 @@ env: LLVM_VERSION: 21 jobs: - macos: - name: ${{ matrix.target }} - runs-on: ${{ matrix.runner }} - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - target: x86_64-apple-darwin/clang - runner: macos-26-intel - - target: aarch64-apple-darwin/clang - runner: macos-26 - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - with: - persist-credentials: false - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 - with: - python-version: '3.11' - - name: Install dependencies - run: | - brew update - brew install llvm@${{ env.LLVM_VERSION }} - - name: Build - run: | - export SDKROOT="$(xcrun --show-sdk-path)" - export PATH="/usr/local/opt/llvm@${{ env.LLVM_VERSION }}/bin:$PATH" - export PATH="/opt/homebrew/opt/llvm@${{ env.LLVM_VERSION }}/bin:$PATH" - CC=clang-${{ env.LLVM_VERSION }} ./configure --with-tail-call-interp - make all --jobs 4 - - name: Test - run: | - ./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3 - linux: name: ${{ matrix.target }} runs-on: ${{ matrix.runner }} @@ -75,10 +41,10 @@ jobs: runner: ubuntu-26.04-arm configure_flags: --with-pydebug steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + - uses: actions/setup-python@v7.0.0 with: python-version: '3.11' - name: Build diff --git a/.github/workflows/verify-ensurepip-wheels.yml b/.github/workflows/verify-ensurepip-wheels.yml index 7def8c9e78abb8d..89083b65d71bfa3 100644 --- a/.github/workflows/verify-ensurepip-wheels.yml +++ b/.github/workflows/verify-ensurepip-wheels.yml @@ -25,10 +25,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + - uses: actions/setup-python@v7.0.0 with: python-version: '3' - name: Compare checksum of bundled wheels to the ones published on PyPI diff --git a/.github/workflows/verify-expat.yml b/.github/workflows/verify-expat.yml index b96e71b487dbe57..ce1ae0ee8a77fca 100644 --- a/.github/workflows/verify-expat.yml +++ b/.github/workflows/verify-expat.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-slim timeout-minutes: 5 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Download and verify bundled libexpat files diff --git a/.gitignore b/.gitignore index 118eb5ee76e8051..91659803f5faf2e 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ *.pyo *.rej *.swp +*.pickle *~ *.gc?? *.profclang? @@ -50,7 +51,7 @@ gmon.out *.exe -# Ignore core dumps... but not Tools/msi/core/ or the like. +# Ignore core dumps... but not .../core/ subdirectories core !core/ @@ -72,16 +73,19 @@ Lib/test/data/* /_bootstrap_python /Makefile /Makefile.pre -/iOSTestbed.* -Apple/iOS/Frameworks/ -Apple/iOS/Resources/Info.plist -Apple/testbed/build -Apple/testbed/Python.xcframework/*/bin -Apple/testbed/Python.xcframework/*/include -Apple/testbed/Python.xcframework/*/lib -Apple/testbed/Python.xcframework/*/Python.framework -Apple/testbed/*Testbed.xcodeproj/project.xcworkspace -Apple/testbed/*Testbed.xcodeproj/xcuserdata +/AppleTestbed.* +Platforms/Apple/iOS/Frameworks/* +Platforms/Apple/iOS/Resources/Info.plist +Platforms/Apple/testbed/Python*.xcframework/*/bin +Platforms/Apple/testbed/Python*.xcframework/*/include +Platforms/Apple/testbed/Python*.xcframework/*/lib +Platforms/Apple/testbed/Python*.xcframework/*/Python*.framework +Platforms/Apple/tvOS/Frameworks/* +Platforms/Apple/tvOS/Resources/Info.plist +Platforms/Apple/visionOS/Frameworks/* +Platforms/Apple/visionOS/Resources/Info.plist +Platforms/Apple/watchOS/Frameworks/* +Platforms/Apple/watchOS/Resources/Info.plist Mac/Makefile Mac/PythonLauncher/Info.plist Mac/PythonLauncher/Makefile @@ -99,6 +103,7 @@ Modules/Setup.config Modules/Setup.local Modules/Setup.stdlib Modules/config.c +Modules/config_bootstrap.c Modules/ld_so_aix Programs/_freeze_module Programs/_testembed @@ -124,10 +129,14 @@ PCbuild/*-pgo PCbuild/*.VC.db PCbuild/*.VC.opendb PCbuild/amd64/ +PCbuild/amd64t/ PCbuild/arm32/ +PCbuild/arm32t/ PCbuild/arm64/ +PCbuild/arm64t/ PCbuild/obj/ PCbuild/win32/ +PCbuild/win32t/ Tools/unicode/data/ /autom4te.cache /build/ @@ -139,6 +148,7 @@ Tools/unicode/data/ /config.status.lineno /.ccache /cross-build*/ +/dist/ /jit_stencils*.h /jit_unwind_info*.h .jit-stamp @@ -158,7 +168,6 @@ Tools/unicode/data/ /coverage/ /externals/ /htmlcov/ -Tools/msi/obj Tools/ssl/amd64 Tools/ssl/win32 Tools/freeze/test/outdir @@ -174,8 +183,13 @@ Python/frozen_modules/MANIFEST /python !/Python/ -# People's custom https://docs.anthropic.com/en/docs/claude-code/memory configs. -/.claude/ +# Local AI agent scratch state (per-PR and per-branch notebooks, sandbox +# experiments) and personal agent overrides, none of which are committed. +/do-not-commit/ +/.claude/pr-* +/.claude/branch-* +/.claude/sandbox/ +AGENTS.local.md CLAUDE.local.md #### main branch only stuff below this line, things to backport go above. #### diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 615ba587c6a4005..bda616bad11c54f 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: 3b3f7c3f57fe9925356faf5fe6230835138be230 # frozen: v0.15.17 + rev: c0f278f1254ccc8fb09676bcdb8d847e7db493e5 # frozen: v0.17.4 hooks: - id: ruff-check name: Run Ruff (lint) on Platforms/Apple/ @@ -70,7 +70,7 @@ repos: files: ^Tools/wasm/ - repo: https://github.com/psf/black-pre-commit-mirror - rev: ea488cebbfd88a5f50b8bd95d5c829d0bb76feb8 # frozen: 26.1.0 + rev: a5439e9af2ff9371297bb1a76a01b8ad17989b88 # frozen: 26.10.1 hooks: - id: black name: Run Black on Tools/jit/ @@ -104,7 +104,7 @@ repos: files: '^\.github/CODEOWNERS|\.(gram)$' - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 9f48a48aa91a6040d749ad68ec70907d907a5a7f # frozen: 0.37.0 + rev: a76b92851fc9eede9f9bc4073eb55202f34eb0df # frozen: 0.39.0 hooks: - id: check-dependabot - id: check-github-workflows @@ -116,7 +116,7 @@ repos: - id: actionlint - repo: https://github.com/zizmorcore/zizmor-pre-commit - rev: b546b77c44c466a54a42af5499dcc0dcc1a3193f # frozen: v1.22.0 + rev: 06a39750ec31860bb44f2acf67182c40016cd1e7 # frozen: v1.32.0 hooks: - id: zizmor @@ -143,6 +143,15 @@ repos: entry: Space found in path, move to Misc/NEWS.d/next/Core_and_Builtins/ files: Misc/NEWS.d/next/Core and Builtins/20.*.rst + - repo: local + hooks: + - id: check-capi-macros + name: Check C API macros start with Py + language: python + entry: python Tools/build/check_capi_macros.py + pass_filenames: false + files: ^(Include/(cpython/)?[^/]+\.h|pyconfig\.h\.in|Tools/build/check_capi_macros) + - repo: meta hooks: - id: check-hooks-apply diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 000000000000000..ce4489146a9ee92 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,29 @@ +# AI agent guidance + +CPython has a [policy on the use of AI tools](https://devguide.python.org/getting-started/ai-tools/). +All use of AI tools and agents when working on or interacting with CPython +must follow it. + +> [!important] +> **Primary directive**: Read the policy before making or proposing any changes. + +When acting on this repository, apply the policy's core principles: + +- Consider whether the change is necessary. +- Make minimal, focused changes. +- Follow existing coding style and patterns. +- Write tests that exercise the change. +- Keep backwards compatibility with prior releases in mind. + +## Opening issues + +Do not auto-generate issues with AI tools. + +Search GitHub for duplicate issues before opening a new issue. Do not open +duplicates. + +```bash +gh search issues --repo python/cpython "" +gh search issues --repo python/cpython "" +gh issue list --repo python/cpython --state all --label "" --search "" +``` diff --git a/Doc/Makefile b/Doc/Makefile index d77ece1e681bcfc..0d5fd41627ff292 100644 --- a/Doc/Makefile +++ b/Doc/Makefile @@ -32,6 +32,7 @@ help: @echo "Please use \`make ' where is one of" @echo " clean to remove build files" @echo " venv to create a venv with necessary tools" + @echo " lock to regenerate the pinned dependencies in $(REQUIREMENTS)" @echo " html to make standalone HTML files" @echo " gettext to generate POT files" @echo " htmlview to open the index page built by the html target in your browser" @@ -185,6 +186,20 @@ venv: echo "The venv has been created in the $(VENVDIR) directory"; \ fi +.PHONY: lock +lock: +# Dependencies have a 14 day cooldown period to mitigate supply chain attacks, +# except for blurb, python-docs-theme and sphinx_linklint, which are maintained by +# core team members. + $(UV) pip compile requirements.txt \ + --upgrade --exclude-newer P14D \ + --exclude-newer-package blurb=PT0S \ + --exclude-newer-package python-docs-theme=PT0S \ + --exclude-newer-package sphinx_linklint=PT0S \ + --no-cache --output-file $(REQUIREMENTS) \ + --python-version 3.12 --universal \ + --custom-compile-command="make lock" + .PHONY: dist-no-html dist-no-html: dist-text dist-epub dist-texinfo diff --git a/Doc/README.rst b/Doc/README.rst index 2d1148753e0c6bb..e33569f298ca3c0 100644 --- a/Doc/README.rst +++ b/Doc/README.rst @@ -21,6 +21,7 @@ tree but are maintained separately and are available from * `Sphinx `_ * `blurb `_ * `python-docs-theme `_ +* `sphinx-linklint `_ The easiest way to install these tools is to create a virtual environment and install the tools into there. @@ -57,6 +58,8 @@ Available make targets are: * "venv", which creates a virtual environment with all necessary tools installed. +* "lock", which regenerates the pinned dependencies in ``pylock.toml``. + * "html", which builds standalone HTML files for offline viewing. * "htmlview", which re-uses the "html" builder, but then opens the main page @@ -79,6 +82,9 @@ Available make targets are: * "text", which builds a plain text file for each source file. +* "texinfo", which builds Texinfo source files as input to ``makeinfo`` to + produce Info documents. + * "epub", which builds an EPUB document, suitable to be viewed on e-book readers. @@ -97,6 +103,10 @@ Available make targets are: plain text documentation for the labels defined in ``tools/pyspecific.py`` -- pydoc needs these to show topic and keyword help. +* "doctest", which runs doctests in the documentation. + +* "gettext", which generates gettext message catalog templates. + * "check", which checks for frequent markup errors. * "dist", (Unix only) which creates distributable archives of HTML, text, diff --git a/Doc/_static/tachyon-example-flamegraph.html b/Doc/_static/tachyon-example-flamegraph.html index 701c959bda3ccc0..0563e7ce4acfe6e 100644 --- a/Doc/_static/tachyon-example-flamegraph.html +++ b/Doc/_static/tachyon-example-flamegraph.html @@ -1,5 +1,5 @@ - + @@ -166,6 +166,14 @@ /* Heatmap span highlighting colors */ --span-hot-base: 255, 100, 50; --span-cold-base: 150, 150, 150; + + /* Summary card colors - optimized for 4.5:1 contrast on light bg */ + --card-blue: 44, 102, 149; + --card-green: 26, 116, 49; + --card-yellow: 134, 100, 4; + --card-purple: 102, 57, 166; + --card-red: 180, 40, 50; + --card-orange: 166, 90, 0; } /* Dark theme */ @@ -190,15 +198,15 @@ --header-gradient: linear-gradient(135deg, #21262d 0%, #30363d 100%); - /* Dark mode heat palette - muted colors that provide sufficient contrast with light text */ - --heat-1: rgba(74, 123, 167, 0.35); - --heat-2: rgba(90, 159, 168, 0.38); - --heat-3: rgba(106, 181, 181, 0.40); - --heat-4: rgba(126, 196, 136, 0.42); - --heat-5: rgba(160, 216, 120, 0.45); - --heat-6: rgba(196, 222, 106, 0.48); - --heat-7: rgba(244, 212, 77, 0.50); - --heat-8: rgba(255, 107, 53, 0.55); + /* Dark mode heat palette - cool to warm gradient for visualization */ + --heat-1: rgba(90, 123, 167, 1); + --heat-2: rgba(106, 148, 168, 1); + --heat-3: rgba(122, 172, 172, 1); + --heat-4: rgba(142, 196, 152, 1); + --heat-5: rgba(168, 216, 136, 1); + --heat-6: rgba(200, 222, 122, 1); + --heat-7: rgba(244, 212, 93, 1); + --heat-8: rgba(255, 122, 69, 1); /* Code view specific - dark mode */ --code-bg: #0d1117; @@ -228,6 +236,14 @@ /* Heatmap span highlighting colors - dark theme */ --span-hot-base: 255, 107, 53; --span-cold-base: 189, 189, 189; + + /* Summary card colors - optimized for 4.5:1 contrast on dark bg */ + --card-blue: 88, 166, 255; + --card-green: 63, 185, 80; + --card-yellow: 210, 153, 34; + --card-purple: 163, 113, 247; + --card-red: 248, 113, 113; + --card-orange: 251, 146, 60; } /* -------------------------------------------------------------------------- @@ -571,6 +587,46 @@ This file extends the shared foundation with flamegraph-specific styles. ========================================================================== */ +/* -------------------------------------------------------------------------- + Differential Flamegraph + -------------------------------------------------------------------------- */ + +:root { + /* Regression colors */ + --diff-regression-deep: #d32f2f; + --diff-regression-medium: #e57373; + --diff-regression-light: #ef9a9a; + --diff-regression-verylight: #ffcdd2; + + /* Improvement colors */ + --diff-improvement-deep: #1976d2; + --diff-improvement-medium: #42a5f5; + --diff-improvement-light: #64b5f6; + --diff-improvement-verylight: #90caf9; + + /* Other differential colors */ + --diff-neutral: #bdbdbd; + --diff-new: #9575cd; + --diff-elided: #b39ddb; +} + +/* Dark mode differential colors - adjusted for contrast against dark backgrounds */ +[data-theme="dark"] { + --diff-regression-deep: #ef5350; + --diff-regression-medium: #e57373; + --diff-regression-light: #ef9a9a; + --diff-regression-verylight: #ffcdd2; + + --diff-improvement-deep: #42a5f5; + --diff-improvement-medium: #64b5f6; + --diff-improvement-light: #90caf9; + --diff-improvement-verylight: #bbdefb; + + --diff-neutral: #757575; + --diff-new: #b39ddb; + --diff-elided: #ce93d8; +} + /* -------------------------------------------------------------------------- Layout Overrides (Flamegraph-specific) -------------------------------------------------------------------------- */ @@ -841,9 +897,17 @@ } /* View Mode Section */ +.view-mode-section { + display: flex; + flex-direction: column; + gap: 8px; +} + .view-mode-section .section-content { display: flex; - justify-content: center; + flex-direction: column; + gap: 10px; + align-items: center; } /* Collapsible sections */ @@ -912,10 +976,10 @@ position: relative; } -.summary-card:nth-child(1) { --i: 0; --card-color: 55, 118, 171; } -.summary-card:nth-child(2) { --i: 1; --card-color: 40, 167, 69; } -.summary-card:nth-child(3) { --i: 2; --card-color: 255, 193, 7; } -.summary-card:nth-child(4) { --i: 3; --card-color: 111, 66, 193; } +.summary-card:nth-child(1) { --i: 0; --card-color: var(--card-blue); } +.summary-card:nth-child(2) { --i: 1; --card-color: var(--card-green); } +.summary-card:nth-child(3) { --i: 2; --card-color: var(--card-yellow); } +.summary-card:nth-child(4) { --i: 3; --card-color: var(--card-purple); } .summary-card:hover { border-color: rgba(var(--card-color), 0.6); @@ -971,21 +1035,18 @@ text-overflow: ellipsis; } -/* Efficiency Bar */ -.efficiency-section { - margin-top: 10px; - padding-top: 10px; - border-top: 1px solid var(--border); -} +/* -------------------------------------------------------------------------- + Progress Bars + -------------------------------------------------------------------------- */ -.efficiency-header { +.bar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; } -.efficiency-label { +.bar-label { font-size: 9px; font-weight: 600; color: var(--text-secondary); @@ -993,21 +1054,21 @@ letter-spacing: 0.2px; } -.efficiency-value { +.bar-value { font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--accent); } -.efficiency-bar { +.bar { height: 6px; background: var(--bg-tertiary); border-radius: 3px; overflow: hidden; } -.efficiency-fill { +.bar-fill { height: 100%; background: linear-gradient(90deg, #28a745 0%, #20c997 50%, #17a2b8 100%); border-radius: 3px; @@ -1016,7 +1077,7 @@ overflow: hidden; } -.efficiency-fill::after { +.bar-fill::after { content: ''; position: absolute; top: 0; @@ -1033,68 +1094,56 @@ } /* -------------------------------------------------------------------------- - Thread Stats Grid (in Sidebar) + Efficiency Section Container + -------------------------------------------------------------------------- */ + +.efficiency-section { + margin-top: 10px; + padding-top: 10px; + border-top: 1px solid var(--border); +} + +/* -------------------------------------------------------------------------- + Thread Stats Progress Bars (in Sidebar) -------------------------------------------------------------------------- */ .thread-stats-section { display: block; } -.stats-grid { - display: grid; - grid-template-columns: 1fr 1fr; - gap: 8px; +.stats-container { + display: flex; + flex-direction: column; + gap: 10px; } -.stat-tile { - background: var(--bg-primary); - border-radius: 8px; - padding: 10px; - text-align: center; - border: 2px solid var(--border); - transition: all var(--transition-fast); +.stat-item { animation: fadeIn 0.4s ease-out backwards; animation-delay: calc(var(--i, 0) * 0.05s); } -.stat-tile:nth-child(1) { --i: 0; } -.stat-tile:nth-child(2) { --i: 1; } -.stat-tile:nth-child(3) { --i: 2; } -.stat-tile:nth-child(4) { --i: 3; } +.stat-item:nth-child(1) { --i: 0; } +.stat-item:nth-child(2) { --i: 1; } +.stat-item:nth-child(3) { --i: 2; } +.stat-item:nth-child(4) { --i: 3; } +.stat-item:nth-child(5) { --i: 4; } -.stat-tile:hover { - transform: translateY(-2px); - box-shadow: var(--shadow-sm); +/* Color variants for bar-fill */ +.bar-fill--green { + background: linear-gradient(90deg, #28a745 0%, #20c997 100%); } -.stat-tile-value { - font-family: var(--font-mono); - font-size: 16px; - font-weight: 700; - color: var(--text-primary); - line-height: 1.2; +.bar-fill--yellow { + background: linear-gradient(90deg, #ffc107 0%, #ffdb4d 100%); } -.stat-tile-label { - font-size: 9px; - font-weight: 600; - text-transform: uppercase; - letter-spacing: 0.3px; - color: var(--text-muted); - margin-top: 2px; +.bar-fill--purple { + background: linear-gradient(90deg, #6f42c1 0%, #9b6dd6 100%); } -/* Stat tile color variants */ -.stat-tile--green { --tile-color: 40, 167, 69; --tile-text: #28a745; } -.stat-tile--red { --tile-color: 220, 53, 69; --tile-text: #dc3545; } -.stat-tile--yellow { --tile-color: 255, 193, 7; --tile-text: #d39e00; } -.stat-tile--purple { --tile-color: 111, 66, 193; --tile-text: #6f42c1; } - -.stat-tile[class*="--"] { - border-color: rgba(var(--tile-color), 0.4); - background: linear-gradient(135deg, rgba(var(--tile-color), 0.08) 0%, var(--bg-primary) 100%); +.bar-fill--red { + background: linear-gradient(90deg, #dc3545 0%, #ff6b7a 100%); } -.stat-tile[class*="--"] .stat-tile-value { color: var(--tile-text); } /* -------------------------------------------------------------------------- Hotspot Cards @@ -1396,6 +1445,41 @@ color: var(--accent); } +.tooltip-diff { + margin-top: 12px; + padding-top: 12px; + border-top: 1px solid var(--border); +} + +.tooltip-diff-title { + font-size: 11px; + font-weight: 600; + color: var(--accent); + margin-bottom: 8px; +} + +.tooltip-diff-row { + display: grid; + grid-template-columns: auto 1fr; + gap: 4px 14px; + font-size: 12px; + margin-bottom: 4px; +} + +.tooltip-diff-row.regression .tooltip-stat-value { + color: var(--diff-regression-deep); + font-weight: 700; +} + +.tooltip-diff-row.improvement .tooltip-stat-value { + color: var(--diff-improvement-deep); + font-weight: 700; +} + +.tooltip-diff-row.neutral .tooltip-stat-value { + color: var(--text-secondary); +} + .tooltip-source { margin-top: 10px; padding-top: 10px; @@ -1551,10 +1635,6 @@ .brand-info { display: none; } - - .stats-grid { - grid-template-columns: 1fr; - } } /* -------------------------------------------------------------------------- @@ -1574,7 +1654,9 @@ Flamegraph-Specific Toggle Override -------------------------------------------------------------------------- */ -#toggle-invert .toggle-track.on { +#toggle-invert .toggle-track.on, +#toggle-elided .toggle-track.on, +#toggle-path-display .toggle-track.on { background: #8e44ad; border-color: #8e44ad; box-shadow: 0 0 8px rgba(142, 68, 173, 0.3); @@ -1674,7 +1756,7 @@ &')] + )], + ) + ] + collector.collect(frames) + + with captured_stdout(), captured_stderr(): + export_ok = collector.export(flamegraph_out.name) + self.assertTrue(export_ok) + + with open(flamegraph_out.name, "r", encoding="utf-8") as f: + content = f.read() + + # The funcname's must be escaped in the embedded data so it + # cannot close the inline ", content) + + # The tooltip inserts the function name as HTML after resolving it. + self.assertIn( + "const funcname = escapeHtml(" + 'resolveString(d.data.funcname) || resolveString(d.data.name) || "");', + content, + ) def test_flamegraph_collector_empty_export_fails(self): """Test empty flamegraph export reports no output.""" @@ -585,6 +670,39 @@ def test_flamegraph_collector_empty_export_fails(self): self.assertFalse(export_ok) self.assertEqual(os.path.getsize(flamegraph_out.name), 0) + @run_with_limited_c_stack(size=1024 * 1024) + def test_flamegraph_deep_stack_export(self): + flamegraph_out = tempfile.NamedTemporaryFile( + suffix=".html", delete=False + ) + self.addCleanup(close_and_unlink, flamegraph_out) + + collector = FlamegraphCollector(1000) + # Deeper than the default recursion limit. + frames = [MockFrameInfo("f.py", i + 1, f"f{i}") for i in range(1536)] + collector.collect( + [MockInterpreterInfo(0, [MockThreadInfo(1, frames)])]) + + with set_recursion_limit(1000), captured_stdout(), captured_stderr(): + export_ok = collector.export(flamegraph_out.name) + self.assertEqual(sys.getrecursionlimit(), 1000) + + self.assertTrue(export_ok) + self.assertGreater(os.path.getsize(flamegraph_out.name), 0) + + def test_flamegraph_export_restores_recursion_limit(self): + collector = FlamegraphCollector(1000) + frame = MockFrameInfo("f.py", 1, "f") + with set_recursion_limit(500), captured_stdout(), captured_stderr(): + self.assertFalse(collector.export(None)) + self.assertEqual(sys.getrecursionlimit(), 500) + collector.collect([ + MockInterpreterInfo(0, [MockThreadInfo(1, [ + frame, MockFrameInfo("f.py", 2, "caller")])])]) + with self.assertRaises(TypeError): + collector.export(None) + self.assertEqual(sys.getrecursionlimit(), 500) + def test_gecko_collector_basic(self): """Test basic GeckoCollector functionality.""" collector = GeckoCollector(1000) @@ -682,6 +800,51 @@ def test_gecko_collector_basic(self): self.assertGreater(stack_table["length"], 0) self.assertGreater(len(stack_table["frame"]), 0) + def test_gecko_collector_preserves_source_file_paths(self): + """Test that GeckoCollector preserves source file paths and distinguishes + files with the same basename in different directories.""" + collector = GeckoCollector(1000) + file_a = os.path.join("pkg_a", "__init__.py") + file_b = os.path.join("pkg_b", "__init__.py") + + test_frames = [ + MockInterpreterInfo( + 0, + [ + MockThreadInfo( + 1, + [ + MockFrameInfo(file_a, 10, "func_a"), + MockFrameInfo(file_b, 20, "func_b"), + ], + status=THREAD_STATUS_MAIN_THREAD, + ) + ], + ) + ] + collector.collect(test_frames) + profile_data = collector._build_profile() + + string_array = profile_data["shared"]["stringArray"] + func_table = profile_data["threads"][0]["funcTable"] + + self.assertEqual(func_table["length"], 2) + + funcs_by_name = { + string_array[func_table["name"][i]]: ( + func_table["fileName"][i], + string_array[func_table["fileName"][i]], + ) + for i in range(func_table["length"]) + } + + file_idx_a, resolved_file_a = funcs_by_name["func_a"] + file_idx_b, resolved_file_b = funcs_by_name["func_b"] + + self.assertEqual(resolved_file_a, file_a) + self.assertEqual(resolved_file_b, file_b) + self.assertNotEqual(file_idx_a, file_idx_b) + def test_gecko_collector_async_aware(self): collector = GeckoCollector(1000) @@ -1013,6 +1176,36 @@ def test_gecko_collector_markers(self): f"Marker {i} should have valid category", ) + def test_gecko_collector_replay_out_of_order_batches(self): + """Open markers are closed at the latest replayed sample.""" + collector = GeckoCollector(1000) + # Binary replay can send thread 2's last batch after thread 1's later + # samples + batches = [ + (1, [1000], THREAD_STATUS_ON_CPU), + (2, [1500], 0), + (1, [2000], THREAD_STATUS_ON_CPU), + (1, [3000, 4000], 0), + (2, [2500], 0), + ] + for tid, timestamps, status in batches: + frames = [MockFrameInfo(f"t{tid}.py", 10, f"func{tid}")] + collector.collect( + [MockInterpreterInfo(0, [MockThreadInfo(tid, frames, status=status)])], + timestamps_us=timestamps, + ) + + profile_data = collector._build_profile() + + end_times = [] + for thread_data in profile_data["threads"]: + markers = thread_data["markers"] + for start_time, end_time in zip(markers["startTime"], + markers["endTime"]): + self.assertLessEqual(start_time, end_time) + end_times.append(end_time) + self.assertEqual(max(end_times), 3.0) + def test_pstats_collector_export(self): collector = PstatsCollector( sample_interval_usec=1000000 @@ -1156,6 +1349,30 @@ def test_flamegraph_collector_stats_accumulation(self): collector.collect(stack_frames_gc) self.assertEqual(collector.samples_with_gc_frames, 2) + def test_flamegraph_collector_restores_replay_stats(self): + """Replay restores measured values from binary metadata.""" + collector = FlamegraphCollector(1000) + collector.set_replay_stats({ + "duration_sec": 1.25, + "sample_rate": 4.0, + "error_rate": 2.5, + "missed_samples": 1.5, + }) + + self.assertEqual(collector.stats["duration_sec"], 1.25) + self.assertEqual(collector.stats["sample_rate"], 4.0) + self.assertEqual(collector.stats["error_rate"], 2.5) + self.assertEqual(collector.stats["missed_samples"], 1.5) + + def test_flamegraph_collector_leaves_legacy_replay_stats_unavailable(self): + collector = FlamegraphCollector(1000) + original_stats = collector.stats.copy() + collector.set_replay_stats({ + "duration_sec": None, + "sample_rate": None, + }) + self.assertEqual(collector.stats, original_stats) + def test_flamegraph_collector_per_thread_stats(self): """Test per-thread statistics tracking in FlamegraphCollector.""" collector = FlamegraphCollector(sample_interval_usec=1000) @@ -1336,6 +1553,87 @@ def test_flamegraph_collector_json_structure_includes_stats(self): self.assertIn("gc_pct", thread_data) self.assertIn("total", thread_data) + def test_flamegraph_nodes_include_per_thread_values(self): + collector = FlamegraphCollector(sample_interval_usec=1000) + root = MockFrameInfo("app.py", 1, "main") + collector.process_frames( + [MockFrameInfo("app.py", 10, "worker_a"), root], + thread_id=1, + weight=2, + ) + collector.process_frames( + [MockFrameInfo("app.py", 20, "worker_b"), root], + thread_id=2, + weight=3, + ) + + data = collector._convert_to_flamegraph_format() + + self.assertEqual(data["thread_values"], {1: [2, 0], 2: [3, 0]}) + children_by_line = {child["lineno"]: child for child in data["children"]} + self.assertEqual(children_by_line[10]["thread_values"], {1: [2, 2]}) + self.assertEqual(children_by_line[20]["thread_values"], {2: [3, 3]}) + + def test_flamegraph_pruning_preserves_low_volume_thread(self): + collector = FlamegraphCollector(sample_interval_usec=1000) + collector.process_frames( + [MockFrameInfo("app.py", 10, "busy")], + thread_id=1, + weight=1999, + ) + collector.process_frames( + [MockFrameInfo("app.py", 20, "rare")], + thread_id=2, + ) + + data = collector._convert_to_flamegraph_format() + + self.assertEqual(data["thread_values"], {1: [1999, 0], 2: [1, 0]}) + children_by_line = {child["lineno"]: child for child in data["children"]} + self.assertEqual(children_by_line[10]["thread_values"], {1: [1999, 1999]}) + self.assertEqual(children_by_line[20]["thread_values"], {2: [1, 1]}) + + def test_flamegraph_does_not_promote_incomplete_root(self): + collector = FlamegraphCollector(sample_interval_usec=1000) + collector.process_frames( + [MockFrameInfo("app.py", 1, "busy")], + thread_id=1, + weight=2000, + ) + for line in range(2, 2002): + collector.process_frames( + [MockFrameInfo("app.py", line, f"fragment_{line}")], + thread_id=2, + ) + + data = collector._convert_to_flamegraph_format() + + self.assertNotIn("filename", data) + self.assertEqual(data["thread_values"], {1: [2000, 0], 2: [2000, 0]}) + self.assertEqual(len(data["children"]), 1) + self.assertEqual(data["children"][0]["thread_values"], {1: [2000, 2000]}) + + def test_flamegraph_nodes_include_per_thread_opcodes(self): + collector = FlamegraphCollector(sample_interval_usec=1000) + collector.process_frames( + [MockFrameInfo("app.py", 10, "worker", opcode=100)], + thread_id=1, + weight=2, + ) + collector.process_frames( + [MockFrameInfo("app.py", 10, "worker", opcode=101)], + thread_id=2, + weight=3, + ) + + data = collector._convert_to_flamegraph_format() + + self.assertEqual(data["opcodes"], {100: 2, 101: 3}) + self.assertEqual( + data["thread_opcodes"], + {1: {100: 2}, 2: {101: 3}}, + ) + def test_flamegraph_collector_per_thread_gc_percentage(self): """Test that per-thread GC percentage uses total samples as denominator.""" collector = FlamegraphCollector(sample_interval_usec=1000) @@ -1500,7 +1798,8 @@ def test_diff_flamegraph_changed_functions(self): ]) ] - # Baseline: 2 samples, current: 4, scale = 2.0 + # Baseline: 2 samples, current: 4. Profiles are compared in absolute + # time rather than normalized to the same total duration. diff = make_diff_collector_with_mock_baseline( [hot_leaf_sample, cold_leaf_sample] ) @@ -1510,7 +1809,7 @@ def test_diff_flamegraph_changed_functions(self): data = diff._convert_to_flamegraph_format() strings = data.get("strings", []) - self.assertAlmostEqual(data["stats"]["baseline_scale"], 2.0) + self.assertAlmostEqual(data["stats"]["baseline_scale"], 1.0) children = data.get("children", []) hot_node = find_child_by_name(children, strings, "hot_leaf") @@ -1518,20 +1817,64 @@ def test_diff_flamegraph_changed_functions(self): self.assertIsNotNone(hot_node) self.assertIsNotNone(cold_node) - # hot_leaf regressed (+50%) - self.assertAlmostEqual(hot_node["baseline"], 2.0) + # hot_leaf regressed (+200%) + self.assertAlmostEqual(hot_node["baseline"], 1.0) self.assertEqual(hot_node["self_time"], 3) - self.assertAlmostEqual(hot_node["diff"], 1.0) - self.assertAlmostEqual(hot_node["diff_pct"], 50.0) + self.assertAlmostEqual(hot_node["diff"], 2.0) + self.assertAlmostEqual(hot_node["diff_pct"], 200.0) - # cold_leaf improved (-50%) - self.assertAlmostEqual(cold_node["baseline"], 2.0) + # cold_leaf is unchanged + self.assertAlmostEqual(cold_node["baseline"], 1.0) self.assertEqual(cold_node["self_time"], 1) - self.assertAlmostEqual(cold_node["diff"], -1.0) - self.assertAlmostEqual(cold_node["diff_pct"], -50.0) + self.assertAlmostEqual(cold_node["diff"], 0.0) + self.assertAlmostEqual(cold_node["diff_pct"], 0.0) - def test_diff_flamegraph_scale_factor(self): - """Scale factor adjusts when sample counts differ.""" + def test_diff_flamegraph_rejects_mismatched_profiling_modes(self): + from profiling.sampling.binary_collector import BinaryCollector + from profiling.sampling.stack_collector import DiffFlamegraphCollector + + bin_file = tempfile.NamedTemporaryFile(suffix=".bin", delete=False) + self.addCleanup(close_and_unlink, bin_file) + writer = BinaryCollector( + bin_file.name, + sample_interval_usec=1000, + compression="none", + mode=PROFILING_MODE_CPU, + ) + writer.export(None) + + diff = DiffFlamegraphCollector( + 1000, + baseline_binary_path=bin_file.name, + mode=PROFILING_MODE_WALL, + ) + with self.assertRaisesRegex(ValueError, "profiling mode"): + diff._convert_to_flamegraph_format() + + def test_diff_flamegraph_rejects_mismatched_capture_config(self): + from profiling.sampling.binary_collector import BinaryCollector + from profiling.sampling.stack_collector import DiffFlamegraphCollector + + bin_file = tempfile.NamedTemporaryFile(suffix=".bin", delete=False) + self.addCleanup(close_and_unlink, bin_file) + writer = BinaryCollector( + bin_file.name, + sample_interval_usec=1000, + compression="none", + capture_config={"all_threads": True}, + ) + writer.export(None) + + diff = DiffFlamegraphCollector( + 1000, + baseline_binary_path=bin_file.name, + capture_config={"all_threads": False}, + ) + with self.assertRaisesRegex(ValueError, "all_threads"): + diff._convert_to_flamegraph_format() + + def test_diff_flamegraph_does_not_normalize_duration(self): + """A longer current run is compared in absolute time.""" baseline_frames = [ MockInterpreterInfo(0, [ MockThreadInfo(1, [ @@ -1546,15 +1889,74 @@ def test_diff_flamegraph_scale_factor(self): diff.collect(baseline_frames) data = diff._convert_to_flamegraph_format() - self.assertAlmostEqual(data["stats"]["baseline_scale"], 4.0) + self.assertAlmostEqual(data["stats"]["baseline_scale"], 1.0) children = data.get("children", []) self.assertEqual(len(children), 1) func1_node = children[0] self.assertEqual(func1_node["self_time"], 4) - self.assertAlmostEqual(func1_node["baseline"], 4.0) - self.assertAlmostEqual(func1_node["diff"], 0.0) - self.assertAlmostEqual(func1_node["diff_pct"], 0.0) + self.assertAlmostEqual(func1_node["baseline"], 1.0) + self.assertAlmostEqual(func1_node["diff"], 3.0) + self.assertAlmostEqual(func1_node["diff_pct"], 300.0) + + def test_diff_flamegraph_scale_factor_uses_sample_intervals(self): + """Baseline samples are converted to current sample units.""" + frames = [ + MockInterpreterInfo(0, [ + MockThreadInfo(1, [MockFrameInfo("file.py", 10, "func1")]) + ]) + ] + + diff = make_diff_collector_with_mock_baseline( + [frames] * 10, + baseline_interval=1000, + current_interval=10000, + ) + diff.collect(frames) + + data = diff._convert_to_flamegraph_format() + self.assertAlmostEqual(data["stats"]["baseline_scale"], 0.1) + self.assertAlmostEqual(data["baseline"], 1.0) + self.assertEqual(data["self_time"], 1) + self.assertAlmostEqual(data["diff"], 0.0) + self.assertAlmostEqual(data["diff_pct"], 0.0) + + def test_diff_flamegraph_elided_values_use_current_interval(self): + """Elided geometry and metadata use the same sample units.""" + baseline_frames = [ + MockInterpreterInfo(0, [ + MockThreadInfo(1, [ + MockFrameInfo("file.py", 10, "old_func"), + MockFrameInfo("file.py", 30, "parent"), + ]) + ]) + ] + current_frames = [ + MockInterpreterInfo(0, [ + MockThreadInfo(1, [ + MockFrameInfo("file.py", 20, "new_func"), + MockFrameInfo("file.py", 30, "parent"), + ]) + ]) + ] + + diff = make_diff_collector_with_mock_baseline( + [baseline_frames] * 10, + baseline_interval=1000, + current_interval=10000, + ) + diff.collect(current_frames) + + data = diff._convert_to_flamegraph_format() + elided = data["stats"]["elided_flamegraph"] + self.assertAlmostEqual(elided["value"], 1.0) + self.assertEqual(elided["self"], 0) + self.assertAlmostEqual(elided["baseline_total"], 1.0) + child, = elided["children"] + self.assertAlmostEqual(child["value"], 1.0) + self.assertAlmostEqual(child["self"], 1.0) + self.assertAlmostEqual(child["baseline"], 1.0) + self.assertAlmostEqual(child["diff"], -1.0) def test_diff_flamegraph_elided_stacks(self): """Paths in baseline but not current produce elided stacks.""" @@ -1581,7 +1983,7 @@ def test_diff_flamegraph_elided_stacks(self): data = diff._convert_to_flamegraph_format() - self.assertGreater(data["stats"]["elided_count"], 0) + self.assertEqual(data["stats"]["elided_count"], 1) self.assertIn("elided_flamegraph", data["stats"]) elided = data["stats"]["elided_flamegraph"] self.assertTrue(elided["stats"]["is_differential"]) @@ -1597,6 +1999,74 @@ def test_diff_flamegraph_elided_stacks(self): self.assertGreater(child["baseline"], 0) self.assertAlmostEqual(child["diff"], -child["baseline"]) + def test_diff_flamegraph_counts_elided_stacks_not_paths(self): + """Internal and leaf stack endings are counted separately.""" + internal_stack = [ + MockInterpreterInfo(0, [ + MockThreadInfo(1, [ + MockFrameInfo("file.py", 20, "old_mid"), + MockFrameInfo("file.py", 10, "root"), + ]) + ]) + ] + leaf_stack = [ + MockInterpreterInfo(0, [ + MockThreadInfo(1, [ + MockFrameInfo("file.py", 30, "old_leaf"), + MockFrameInfo("file.py", 20, "old_mid"), + MockFrameInfo("file.py", 10, "root"), + ]) + ]) + ] + current_frames = [ + MockInterpreterInfo(0, [ + MockThreadInfo(1, [MockFrameInfo("file.py", 10, "root")]) + ]) + ] + + diff = make_diff_collector_with_mock_baseline( + [internal_stack, leaf_stack] + ) + diff.collect(current_frames) + + data = diff._convert_to_flamegraph_format() + self.assertEqual(data["stats"]["elided_count"], 2) + + def test_diff_flamegraph_renders_small_elided_stack(self): + """Elided stacks are not removed by the significance filter.""" + common_frames = [ + MockInterpreterInfo(0, [ + MockThreadInfo(1, [ + MockFrameInfo("file.py", 20, "common"), + MockFrameInfo("file.py", 10, "root"), + ]) + ]) + ] + old_frames = [ + MockInterpreterInfo(0, [ + MockThreadInfo(1, [ + MockFrameInfo("file.py", 30, "old_tiny"), + MockFrameInfo("file.py", 10, "root"), + ]) + ]) + ] + + diff = make_diff_collector_with_mock_baseline( + [common_frames] * 1999 + [old_frames] + ) + for _ in range(1999): + diff.collect(common_frames) + + data = diff._convert_to_flamegraph_format() + self.assertEqual(data["stats"]["elided_count"], 1) + self.assertIn("elided_flamegraph", data["stats"]) + + elided = data["stats"]["elided_flamegraph"] + strings = elided["strings"] + self.assertIsNotNone( + find_child_by_name(elided.get("children", []), strings, "old_tiny") + ) + def test_diff_flamegraph_elided_top_level_root(self): """Elided top-level roots do not crash metadata generation.""" baseline_frames_1 = [ @@ -1664,6 +2134,123 @@ def test_diff_flamegraph_function_matched_despite_line_change(self): self.assertAlmostEqual(child["diff"], 0.0, places=1) self.assertAlmostEqual(child["diff_pct"], 0.0, places=1) + def test_diff_flamegraph_does_not_duplicate_line_values(self): + """Function aggregates are apportioned across line nodes.""" + def sample(line): + return [ + MockInterpreterInfo(0, [ + MockThreadInfo(1, [ + MockFrameInfo("file.py", line, "func"), + MockFrameInfo("file.py", 1, "caller"), + ]) + ]) + ] + + diff = make_diff_collector_with_mock_baseline( + [sample(10), sample(20)] + ) + diff.collect(sample(10)) + diff.collect(sample(20)) + + data = diff._convert_to_flamegraph_format() + children = data["children"] + self.assertEqual(sum(node["self"] for node in children), 2) + self.assertEqual(sum(node["self_time"] for node in children), 2) + self.assertEqual(sum(node["baseline"] for node in children), 2) + for node in children: + self.assertEqual(node["self"], 1) + self.assertEqual(node["self_time"], 1) + self.assertAlmostEqual(node["baseline"], 1.0) + self.assertAlmostEqual(node["diff"], 0.0) + + def test_diff_flamegraph_line_totals_include_allocated_self(self): + """A line's baseline self time cannot exceed its inclusive time.""" + def sample(*frames): + return [ + MockInterpreterInfo(0, [MockThreadInfo(1, list(frames))]) + ] + + target_10 = MockFrameInfo("file.py", 10, "target") + target_20 = MockFrameInfo("file.py", 20, "target") + child = MockFrameInfo("file.py", 30, "child") + + diff = make_diff_collector_with_mock_baseline( + [sample(target_10)] * 100 + ) + for _ in range(10): + diff.collect(sample(target_10)) + for _ in range(90): + diff.collect(sample(child, target_20)) + + data = diff._convert_to_flamegraph_format() + nodes = data["children"] + self.assertEqual(sum(node["baseline"] for node in nodes), 100) + self.assertEqual(sum(node["baseline_total"] for node in nodes), 100) + for node in nodes: + self.assertGreaterEqual(node["baseline"], 0) + self.assertLessEqual(node["baseline"], node["baseline_total"]) + + def test_diff_flamegraph_does_not_duplicate_elided_line_values(self): + """Elided metadata uses each rendered line node's samples.""" + def sample(line, funcname="old_func"): + return [ + MockInterpreterInfo(0, [ + MockThreadInfo(1, [ + MockFrameInfo("file.py", line, funcname), + MockFrameInfo("file.py", 1, "caller"), + ]) + ]) + ] + + diff = make_diff_collector_with_mock_baseline( + [sample(10), sample(20)] + ) + diff.collect(sample(30, "new_func")) + + data = diff._convert_to_flamegraph_format() + elided = data["stats"]["elided_flamegraph"] + children = elided["children"] + scale = data["stats"]["baseline_scale"] + self.assertEqual(sum(node["self"] for node in children), 2) + self.assertEqual(sum(node["baseline"] for node in children), 2 * scale) + for node in children: + self.assertEqual(node["self"], 1) + self.assertAlmostEqual(node["baseline"], scale) + self.assertAlmostEqual(node["diff"], -scale) + + def test_diff_flamegraph_elided_ancestors_have_no_lost_self_time(self): + """Matched ancestors only carry inclusive elided geometry.""" + root = MockFrameInfo("file.py", 10, "root") + common = MockFrameInfo("file.py", 20, "common", opcode=100) + old = MockFrameInfo("file.py", 30, "old") + + common_sample = [ + MockInterpreterInfo(0, [MockThreadInfo(1, [common, root])]) + ] + old_sample = [ + MockInterpreterInfo(0, [MockThreadInfo(1, [old, common, root])]) + ] + + diff = make_diff_collector_with_mock_baseline( + [common_sample] * 3 + [old_sample] + ) + diff.collect(common_sample) + + data = diff._convert_to_flamegraph_format() + elided_root = data["stats"]["elided_flamegraph"] + common_node = elided_root["children"][0] + old_node = common_node["children"][0] + + for ancestor in (elided_root, common_node): + self.assertEqual(ancestor["self"], 0) + self.assertEqual(ancestor["baseline"], 0) + self.assertNotIn("opcodes", ancestor) + self.assertLessEqual( + ancestor["baseline"], ancestor["baseline_total"] + ) + self.assertEqual(old_node["self"], 1) + self.assertEqual(old_node["baseline"], old_node["baseline_total"]) + def test_diff_flamegraph_empty_current(self): """Empty current profile still produces differential metadata and elided paths.""" baseline_frames = [ @@ -1672,7 +2259,11 @@ def test_diff_flamegraph_empty_current(self): ]) ] - diff = make_diff_collector_with_mock_baseline([baseline_frames]) + diff = make_diff_collector_with_mock_baseline( + [baseline_frames] * 10, + baseline_interval=1000, + current_interval=10000, + ) # Don't collect anything in current data = diff._convert_to_flamegraph_format() @@ -1682,6 +2273,11 @@ def test_diff_flamegraph_empty_current(self): self.assertTrue(data["stats"]["is_differential"]) # All baseline paths should be elided since current is empty self.assertGreater(data["stats"]["elided_count"], 0) + self.assertAlmostEqual(data["stats"]["baseline_scale"], 0.1) + elided = data["stats"]["elided_flamegraph"] + self.assertAlmostEqual(elided["value"], 1.0) + self.assertAlmostEqual(elided["baseline"], 1.0) + self.assertAlmostEqual(elided["diff"], -1.0) def test_diff_flamegraph_empty_baseline(self): """Empty baseline with non-empty current uses scale=1.0 fallback.""" @@ -1848,7 +2444,8 @@ def test_diff_flamegraph_load_baseline(self): make_frame("file.py", 20, "caller"), ])])] - # Baseline: 2 samples, current: 4, scale = 2.0 + # Baseline: 2 samples, current: 4. Profiles are compared in absolute + # time rather than normalized to the same total duration. bin_file = tempfile.NamedTemporaryFile(suffix=".bin", delete=False) self.addCleanup(close_and_unlink, bin_file) @@ -1878,7 +2475,7 @@ def test_diff_flamegraph_load_baseline(self): strings = data.get("strings", []) self.assertTrue(data["stats"]["is_differential"]) - self.assertAlmostEqual(data["stats"]["baseline_scale"], 2.0) + self.assertAlmostEqual(data["stats"]["baseline_scale"], 1.0) children = data.get("children", []) hot_node = find_child_by_name(children, strings, "hot_leaf") @@ -1886,17 +2483,17 @@ def test_diff_flamegraph_load_baseline(self): self.assertIsNotNone(hot_node) self.assertIsNotNone(cold_node) - # hot_leaf regressed (+50%) - self.assertAlmostEqual(hot_node["baseline"], 2.0) + # hot_leaf regressed (+200%) + self.assertAlmostEqual(hot_node["baseline"], 1.0) self.assertEqual(hot_node["self_time"], 3) - self.assertAlmostEqual(hot_node["diff"], 1.0) - self.assertAlmostEqual(hot_node["diff_pct"], 50.0) + self.assertAlmostEqual(hot_node["diff"], 2.0) + self.assertAlmostEqual(hot_node["diff_pct"], 200.0) - # cold_leaf improved (-50%) - self.assertAlmostEqual(cold_node["baseline"], 2.0) + # cold_leaf is unchanged + self.assertAlmostEqual(cold_node["baseline"], 1.0) self.assertEqual(cold_node["self_time"], 1) - self.assertAlmostEqual(cold_node["diff"], -1.0) - self.assertAlmostEqual(cold_node["diff_pct"], -50.0) + self.assertAlmostEqual(cold_node["diff"], 0.0) + self.assertAlmostEqual(cold_node["diff_pct"], 0.0) def test_jsonl_collector_export_exact_output(self): jsonl_out = tempfile.NamedTemporaryFile(delete=False) @@ -2494,20 +3091,6 @@ def test_extract_lineno_from_none(self): """Test extracting lineno from None (synthetic frames).""" self.assertEqual(extract_lineno(None), 0) - def test_extract_lineno_from_int(self): - """Test extracting lineno from a bare integer line number. - - Mirrors normalize_location's int contract so callers like the - collapsed/flamegraph collectors do not crash on a bare-int location. - """ - self.assertEqual(extract_lineno(42), 42) - self.assertEqual(extract_lineno(0), 0) - - def test_normalize_location_with_int(self): - """Test normalize_location expands a legacy integer line number.""" - result = normalize_location(42) - self.assertEqual(result, (42, 42, -1, -1)) - def test_normalize_location_with_location_info(self): """Test normalize_location passes through LocationInfo.""" loc = LocationInfo(10, 15, 0, 5) diff --git a/Lib/test/test_profiling/test_sampling_profiler/test_integration.py b/Lib/test/test_profiling/test_sampling_profiler/test_integration.py index 3487647b76683ee..0b9d55bacc6659c 100644 --- a/Lib/test/test_profiling/test_sampling_profiler/test_integration.py +++ b/Lib/test/test_profiling/test_sampling_profiler/test_integration.py @@ -508,7 +508,10 @@ def test_sampling_with_collapsed_export(self): if ";" in stack_trace: stack_parts = stack_trace.split(";") for part in stack_parts: - # Each part should be file:function:line + # Special frames, such as and , + # do not have file and line information. + if part.startswith("<") and part.endswith(">"): + continue self.assertIn(":", part) def test_sampling_all_threads(self): diff --git a/Lib/test/test_profiling/test_sampling_profiler/test_live_collector_ui.py b/Lib/test/test_profiling/test_sampling_profiler/test_live_collector_ui.py index ae4ee969f34d8b3..dff6c7e3ab26316 100644 --- a/Lib/test/test_profiling/test_sampling_profiler/test_live_collector_ui.py +++ b/Lib/test/test_profiling/test_sampling_profiler/test_live_collector_ui.py @@ -12,6 +12,7 @@ import unittest from unittest import mock from test.support import requires, requires_remote_subprocess_debugging +from test.support import os_helper from test.support.import_helper import import_module # Only run these tests if curses is available @@ -870,8 +871,11 @@ def test_run_failed_module_live(self): ), mock.patch('curses.wrapper', side_effect=self.mock_curses_wrapper), mock.patch("sys.argv", args), - mock.patch('sys.stderr', new=io.StringIO()) as fake_stderr + mock.patch('sys.stderr', new=io.StringIO()) as fake_stderr, + os_helper.EnvironmentVarGuard() as env, ): + # Don't report the crash to the CI running this test + env.unset('GITHUB_STEP_SUMMARY') main() self.assertIn( 'test test_asdasd crashed -- Traceback (most recent call last):', diff --git a/Lib/test/test_profiling/test_sampling_profiler/test_profiler.py b/Lib/test/test_profiling/test_sampling_profiler/test_profiler.py index 2f5a5e273286590..b1fbfb5a0de34dd 100644 --- a/Lib/test/test_profiling/test_sampling_profiler/test_profiler.py +++ b/Lib/test/test_profiling/test_sampling_profiler/test_profiler.py @@ -17,7 +17,7 @@ "Test only runs when _remote_debugging is available" ) -from test.support import force_not_colorized_test_class +from test.support import force_colorized, force_not_colorized_test_class def print_sampled_stats(stats, sort=-1, limit=None, show_summary=True, sample_interval_usec=100): @@ -484,6 +484,15 @@ def test_print_sampled_stats_basic(self): self.assertIn("func1", result) self.assertIn("func2", result) self.assertIn("func3", result) + self.assertNotIn("\x1b[", result) + + @force_colorized + def test_print_sampled_stats_colorized(self): + with io.StringIO() as output, mock.patch("sys.stdout", output): + print_sampled_stats(self.mock_stats) + result = output.getvalue() + + self.assertIn("\x1b[1;34mProfile Stats:", result) def test_print_sampled_stats_sorting(self): """Test different sorting options.""" @@ -751,6 +760,7 @@ def test_print_sampled_stats_sort_by_name(self): and not "calls" in line # Skip summary lines and not "total time" in line # Skip summary lines and not "cumulative time" in line + and not "filename:lineno(function)" in line # Skip header line ): # Skip summary lines data_lines.append(line) diff --git a/Lib/test/test_profiling/test_sampling_profiler/test_sync_coordinator.py b/Lib/test/test_profiling/test_sampling_profiler/test_sync_coordinator.py new file mode 100644 index 000000000000000..936c01e206f9fbe --- /dev/null +++ b/Lib/test/test_profiling/test_sampling_profiler/test_sync_coordinator.py @@ -0,0 +1,113 @@ +"""Tests for the sampling profiler's synchronization coordinator.""" + +import os +import socket +import subprocess +import sys +import tempfile +import unittest + +from test.support import SHORT_TIMEOUT, os_helper, requires_subprocess + + +@requires_subprocess() +class TestSyncCoordinatorScriptExecution(unittest.TestCase): + """Tests for how the coordinator executes a target script.""" + + def run_coordinator(self, cwd, target, *target_args): + """Execute *target* from *cwd* with the sync coordinator. + + Returns the ``(stdout, stderr)`` captured from the coordinator. + """ + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as server: + server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + server.bind(("127.0.0.1", 0)) + server.listen(1) + server.settimeout(SHORT_TIMEOUT) + port = server.getsockname()[1] + + cmd = ( + sys.executable, + "-m", + "profiling.sampling._sync_coordinator", + str(port), + cwd, + target, + ) + tuple(target_args) + process = subprocess.Popen( + cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, + ) + try: + conn, _ = server.accept() + with conn: + # _signal_readiness() sends b"ready" before running target. + self.assertEqual(conn.recv(64), b"ready") + stdout, stderr = process.communicate(timeout=SHORT_TIMEOUT) + finally: + if process.poll() is None: + process.kill() + process.wait() + return stdout, stderr + + def test_script_directory_on_sys_path(self): + # gh-158540: The coordinator must put the directory containing the + # script (not the working directory) on sys.path, matching + # ``python script.py``, so that modules next to the script can be + # imported even when the coordinator runs from another directory. + with tempfile.TemporaryDirectory() as tmpdir: + script_dir = os.path.join(tmpdir, "sub") + os.mkdir(script_dir) + with open(os.path.join(script_dir, "helper.py"), "w") as f: + f.write("message = 'helper imported'\n") + with open(os.path.join(script_dir, "where.py"), "w") as f: + f.write( + "import os\n" + "import sys\n" + "print('PATH0:', os.path.realpath(sys.path[0]))\n" + "import helper\n" + "print('HELPER:', helper.message)\n" + ) + + stdout, stderr = self.run_coordinator( + tmpdir, os.path.join("sub", "where.py") + ) + + self.assertNotIn("ModuleNotFoundError", stderr) + self.assertIn("HELPER: helper imported", stdout) + self.assertIn(f"PATH0: {os.path.realpath(script_dir)}", stdout) + + @os_helper.skip_unless_symlink + def test_symlinked_script_uses_real_directory(self): + # gh-158540: ``python script.py`` resolves symlinks when computing + # sys.path[0], so a symlinked script must import modules next to the + # real script, not next to the link. + with tempfile.TemporaryDirectory() as tmpdir: + script_dir = os.path.join(tmpdir, "sub") + os.mkdir(script_dir) + with open(os.path.join(script_dir, "helper.py"), "w") as f: + f.write("message = 'helper imported'\n") + with open(os.path.join(script_dir, "where.py"), "w") as f: + f.write( + "import os\n" + "import sys\n" + "print('PATH0:', os.path.realpath(sys.path[0]))\n" + "import helper\n" + "print('HELPER:', helper.message)\n" + ) + os.symlink( + os.path.join("sub", "where.py"), + os.path.join(tmpdir, "link.py"), + ) + + stdout, stderr = self.run_coordinator(tmpdir, "link.py") + + self.assertNotIn("ModuleNotFoundError", stderr) + self.assertIn("HELPER: helper imported", stdout) + self.assertIn(f"PATH0: {os.path.realpath(script_dir)}", stdout) + + +if __name__ == "__main__": + unittest.main() diff --git a/Lib/test/test_profiling/test_tracing_profiler.py b/Lib/test/test_profiling/test_tracing_profiler.py index 8a7070142b60eec..ac8fdf343b4fd16 100644 --- a/Lib/test/test_profiling/test_tracing_profiler.py +++ b/Lib/test/test_profiling/test_tracing_profiler.py @@ -1,4 +1,5 @@ """Test suite for the cProfile module.""" +import multiprocessing import sys import unittest @@ -84,6 +85,74 @@ def __call__(self): profiler_with_evil_timer.clear() self.assertEqual(cm.unraisable.exc_type, RuntimeError) + def test_external_timer_result_reentry(self): + import _lsprof + + class Ticks: + def __index__(self): + profiler.clear() + return 0 + + profiler = _lsprof.Profiler(Ticks, timeunit=1) + with support.catch_unraisable_exception() as cm: + profiler.enable() + try: + (lambda: None)() + finally: + profiler.disable() + self.assertIs(cm.unraisable.exc_type, RuntimeError) + + def test_external_timer_reinitializes_profiler(self): + import _lsprof + + def timer(): + profiler.__init__() + return 0 + + profiler = _lsprof.Profiler(timer) + with support.catch_unraisable_exception() as cm: + profiler.enable() + try: + (lambda: None)() + finally: + profiler.disable() + self.assertIs(cm.unraisable.exc_type, RuntimeError) + + def test_enable_in_external_timer(self): + # gh-157639: Enabling the profiler from an external timer should not crash + import _lsprof + + # the timer re-arms monitoring from inside disable(), so the tool + # id stays claimed once the profiler is torn down + self.addCleanup(sys.monitoring.free_tool_id, sys.monitoring.PROFILER_ID) + + def timer(): + try: + profiler.enable() + except Exception: + pass + return 0 + + profiler = _lsprof.Profiler(timer=timer) + profiler.enable() + (lambda: None)() + profiler.disable() + profiler.clear() + + def test_external_timer_is_none(self): + # gh-161233 + def work(): + pass + + for kwargs in ({}, {'timer': None}): + with self.subTest(kwargs=kwargs): + profiler = cProfile.Profile(**kwargs) + profiler.enable() + with support.catch_unraisable_exception() as cm: + work() + self.assertIsNone(cm.unraisable) + profiler.disable() + def test_profile_enable_disable(self): prof = self.profilerclass() # Make sure we clean ourselves up if the test fails for some reason. @@ -220,8 +289,8 @@ def test_process_spawn_pickle(self): # gh-140729: test use Process in cProfile. self._test_process_run_pickle('spawn') - @unittest.skipIf(sys.platform == 'win32', - "No 'forkserver' start method on Windows") + @unittest.skipUnless("forkserver" in multiprocessing.get_all_start_methods(), + "forkserver start method is not available") def test_process_forkserver_pickle(self): # gh-140729: test use Process in cProfile. self._test_process_run_pickle('forkserver') diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py index 26aefdbf0421dda..3c02330f09a0810 100644 --- a/Lib/test/test_property.py +++ b/Lib/test/test_property.py @@ -260,7 +260,7 @@ def test_property_set_name_incorrect_args(self): for i in (0, 1, 3): with self.assertRaisesRegex( TypeError, - fr'^__set_name__\(\) takes 2 positional arguments but {i} were given$' + fr'^__set_name__ expected 2 arguments?, got {i}$' ): p.__set_name__(*([0] * i)) diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py index bdf57776c82be13..2ad89444348376d 100644 --- a/Lib/test/test_pwd.py +++ b/Lib/test/test_pwd.py @@ -50,7 +50,7 @@ def test_values_extended(self): # check whether the entry returned by getpwuid() # for each uid is among those from getpwall() for this uid for e in entries: - if not e[0] or e[0] == '+': + if not e.pw_name or e.pw_name == '+': continue # skip NIS entries etc. self.assertIn(pwd.getpwnam(e.pw_name), entriesbyname[e.pw_name]) self.assertIn(pwd.getpwuid(e.pw_uid), entriesbyuid[e.pw_uid]) @@ -61,8 +61,8 @@ def test_errors(self): self.assertRaises(TypeError, pwd.getpwuid, 0.0) self.assertRaises(TypeError, pwd.getpwuid, 0, 0) # should be out of uid_t range - self.assertRaises(KeyError, pwd.getpwuid, 2**128) - self.assertRaises(KeyError, pwd.getpwuid, -2**128) + self.assertRaises(OverflowError, pwd.getpwuid, 2**128) + self.assertRaises(OverflowError, pwd.getpwuid, -2**128) self.assertRaises(TypeError, pwd.getpwnam) self.assertRaises(TypeError, pwd.getpwnam, 42) self.assertRaises(TypeError, pwd.getpwnam, b'root') diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py index b4265e6a0b458db..616e5d0c7cf971c 100644 --- a/Lib/test/test_py_compile.py +++ b/Lib/test/test_py_compile.py @@ -1,4 +1,3 @@ -import functools import importlib.util import os import py_compile @@ -11,43 +10,7 @@ from test import support from test.support import os_helper, script_helper - - -def without_source_date_epoch(fxn): - """Runs function with SOURCE_DATE_EPOCH unset.""" - @functools.wraps(fxn) - def wrapper(*args, **kwargs): - with os_helper.EnvironmentVarGuard() as env: - env.unset('SOURCE_DATE_EPOCH') - return fxn(*args, **kwargs) - return wrapper - - -def with_source_date_epoch(fxn): - """Runs function with SOURCE_DATE_EPOCH set.""" - @functools.wraps(fxn) - def wrapper(*args, **kwargs): - with os_helper.EnvironmentVarGuard() as env: - env['SOURCE_DATE_EPOCH'] = '123456789' - return fxn(*args, **kwargs) - return wrapper - - -# Run tests with SOURCE_DATE_EPOCH set or unset explicitly. -class SourceDateEpochTestMeta(type(unittest.TestCase)): - def __new__(mcls, name, bases, dct, *, source_date_epoch): - cls = super().__new__(mcls, name, bases, dct) - - for attr in dir(cls): - if attr.startswith('test_'): - meth = getattr(cls, attr) - if source_date_epoch: - wrapper = with_source_date_epoch(meth) - else: - wrapper = without_source_date_epoch(meth) - setattr(cls, attr, wrapper) - - return cls +from test.support.os_helper import SourceDateEpochTestMeta class PyCompileTestsBase: diff --git a/Lib/test/test_pydoc/test_pydoc.py b/Lib/test/test_pydoc/test_pydoc.py index 25f94c4c740e1ea..552b0c7d0759498 100644 --- a/Lib/test/test_pydoc/test_pydoc.py +++ b/Lib/test/test_pydoc/test_pydoc.py @@ -19,6 +19,7 @@ import unittest import unittest.mock import urllib.parse +import urllib.request import xml.etree import xml.etree.ElementTree import textwrap @@ -228,10 +229,13 @@ class C(builtins.object) for s in expected_data_docstrings) # output pattern for missing module -missing_pattern = '''\ -No Python documentation found for %r. -Use help() to get the interactive help utility. -Use help(str) for help on the str class.'''.replace('\n', os.linesep) +def missing_pattern(name, dunder=False): + dunderhelp = "Use help('specialnames') for a list of special names for which help is available.\n" if dunder else "" + return ('''\ +No help entry found for %r. +%sUse help() to get the interactive help utility. +Use help(str) for help on the str class. +Additional documentation is available online at https://docs.python.org/%s.%s/''' % (name, dunderhelp, *sys.version_info[:2])).replace('\n', os.linesep) # output pattern for module with bad imports badimport_pattern = "problem in %s - ModuleNotFoundError: No module named %r" @@ -369,7 +373,7 @@ def html2text(html): Tailored for pydoc tests only. """ - html = html.replace("
", "\n") + html = re.sub(r"]*>", "\n", html) html = html.replace("
", "-"*70) html = re.sub("<.*?>", "", html) html = pydoc.replace(html, " ", " ", ">", ">", "<", "<") @@ -429,7 +433,7 @@ def test_html_doc(self): expected_lines = [line.strip() for line in expected_lines if line] self.assertEqual(text_lines, expected_lines) mod_file = inspect.getabsfile(pydoc_mod) - mod_url = urllib.parse.quote(mod_file) + mod_url = urllib.request.pathname2url(mod_file) self.assertIn(mod_url, result) self.assertIn(mod_file, result) self.assertIn(doc_loc, result) @@ -522,10 +526,34 @@ class B: def test_not_here(self): missing_module = "test.i_am_not_here" result = str(run_pydoc_fail(missing_module), 'ascii') - expected = missing_pattern % missing_module + expected = missing_pattern(missing_module) self.assertEqual(expected, result, "documentation for missing module found") + def test_dunder_help(self): + def get_main_output(topic): + return run_pydoc(topic).split(b'Related help topics:')[0].strip() + + # check that each dunder method maps to a help topic that includes its + # name + for name in pydoc.Helper.dunders: + self.assertIn(name.encode('ascii'), get_main_output(name)) + + # check that right-hand and in-place versions match + self.assertEqual(get_main_output('__add__'), get_main_output('__radd__')) + self.assertEqual(get_main_output('__add__'), get_main_output('__iadd__')) + + def test_dunder_main(self): + self.assertEqual(run_pydoc('__main__').splitlines(False)[0], + '"__main__" — Top-level code environment'.encode('utf-8')) + self.assertEqual(run_pydoc('__name__').splitlines(False)[0], + '''"__name__ == '__main__'"'''.encode('utf-8')) + + def test_dunder_not_here(self): + result = str(run_pydoc_fail("__dict__"), 'ascii') + expected = missing_pattern("__dict__", dunder=True) + self.assertEqual(expected, result) + @requires_docstrings def test_not_ascii(self): result = run_pydoc('test.test_pydoc.test_pydoc.nonascii', PYTHONIOENCODING='ascii') @@ -535,7 +563,7 @@ def test_not_ascii(self): def test_input_strip(self): missing_module = " test.i_am_not_here " result = str(run_pydoc_fail(missing_module), 'ascii') - expected = missing_pattern % missing_module.strip() + expected = missing_pattern(missing_module.strip()) self.assertEqual(expected, result) def test_stripid(self): @@ -689,10 +717,10 @@ def test_builtin_on_metaclasses(self): self.assertNotIn('Built-in subclasses', text) def test_fail_help_cli(self): - elines = (missing_pattern % 'abd').splitlines() + elines = (missing_pattern("abd")).splitlines() with spawn_python("-c" "help()") as proc: out, _ = proc.communicate(b"abd") - olines = out.decode().splitlines()[-9:-6] + olines = out.decode().splitlines()[-10:-6] olines[0] = olines[0].removeprefix('help> ') self.assertEqual(elines, olines) @@ -700,7 +728,7 @@ def test_fail_help_output_redirect(self): with StringIO() as buf: helper = pydoc.Helper(output=buf) helper.help("abd") - expected = missing_pattern % "abd" + expected = missing_pattern("abd") self.assertEqual(expected, buf.getvalue().strip().replace('\n', os.linesep)) @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), @@ -762,6 +790,8 @@ def run_pydoc_for_request(request, expected_text_part): run_pydoc_for_request('keywords', 'Here is a list of the Python keywords.') # test for "symbols" run_pydoc_for_request('symbols', 'Here is a list of the punctuation symbols') + # test for "specialnames" + run_pydoc_for_request('specialnames', 'Here is a list of special names') # test for "topics" run_pydoc_for_request('topics', 'Here is a list of available topics.') # test for "modules" skipped, see test_modules() @@ -1024,6 +1054,31 @@ def test_synopsis_sourceless_empty_doc(self): synopsis_cached = pydoc.synopsis(cached_path, {}) self.assertIsNone(synopsis_cached) + @unittest.skipUnless(os_helper.TESTFN_UNDECODABLE, + 'requires undecodable file names') + def test_html_doc_undecodable_path(self): + # gh-69371: the path of the module is not encodable in UTF-8. + with os_helper.temp_cwd() as test_dir: + subdir = os.path.join(os.fsencode(test_dir), + os_helper.TESTFN_UNDECODABLE) + try: + os.mkdir(subdir) + except OSError: + self.skipTest('undecodable paths are not supported') + with open(os.path.join(subdir, b'undecodable_mod.py'), 'w') as f: + f.write('"""Module docstring."""\n') + with import_helper.DirsOnSysPath(os.fsdecode(subdir)): + mod = import_helper.import_fresh_module('undecodable_mod') + doc = pydoc.HTMLDoc().docmodule(mod) + with captured_stdout(): + pydoc.writedoc(mod) + # The link contains the percent-encoded path... + path = inspect.getabsfile(mod) + self.assertIn(urllib.request.pathname2url(path), doc) + # ...and the page can be written and served as UTF-8. + with open('undecodable_mod.html', encoding='utf-8') as f: + self.assertIn('undecodable_mod', f.read()) + def test_splitdoc_with_description(self): example_string = "I Am A Doc\n\n\nHere is my description" self.assertEqual(pydoc.splitdoc(example_string), @@ -1913,7 +1968,7 @@ async def coro_function(ign) -> int: html = pydoc.HTMLDoc().document(coro_function) self.assertIn( - 'async coro_function', + 'async coro_function', html) def test_async_generator_annotation(self): @@ -1925,7 +1980,7 @@ async def an_async_generator(): html = pydoc.HTMLDoc().document(an_async_generator) self.assertIn( - 'async an_async_generator', + 'async an_async_generator', html) @requires_docstrings @@ -2091,7 +2146,7 @@ def test_html_doc_routines_in_module(self): doc = pydoc.HTMLDoc() result = doc.docmodule(pydocfodder) result = html2text(result) - lines = self.getsection(result, ' Functions', None) + lines = self.getsection(result, 'Functions', None) # function alias self.assertIn(' global_func_alias = global_func(x, y)', lines) self.assertIn(' A_staticmethod(x, y)', lines) @@ -2239,6 +2294,27 @@ def test_keywords(self): self.assertEqual(sorted(pydoc.Helper.keywords), sorted(keyword.kwlist + ['case', 'match', 'lazy'])) + def test_related_topics(self): + # Every related help topic and alias must be something help() can + # document. + for name, target in (*pydoc.Helper.topics.items(), + *pydoc.Helper.keywords.items()): + if isinstance(target, str): + target = ('', target) + for xref in target[1].split(): + with self.subTest(topic=name, xref=xref): + buf = StringIO() + pydoc.Helper(output=buf).help(xref) + self.assertNotIn('No help entry found', buf.getvalue()) + + def test_symbols(self): + # gh-161414 + for symbol in pydoc.Helper.symbols: + with self.subTest(symbol=symbol): + buf = StringIO() + pydoc.Helper(output=buf).showsymbol(symbol) + self.assertNotIn('no documentation found', buf.getvalue()) + def test_interact_empty_line_continues(self): # gh-138568: test pressing Enter without input should continue in help session self.assertEqual( @@ -2435,7 +2511,7 @@ def test_sys_path_adjustment_when_curdir_already_included(self): trailing_argv0dir = trailing_curdir + [self.argv0dir] self.assertIsNone(self._get_revised_path(trailing_argv0dir)) - def test__get_version(self): + def test__get_metadata(self): import json import warnings @@ -2451,17 +2527,27 @@ def __version__(self): doc = pydoc.Doc() with warnings.catch_warnings(record=True) as w: # TODO: remove in 3.20 warnings.simplefilter("always") - version = doc._get_version(json) + version = doc._get_metadata(json, '__version__') self.assertEqual(version, "2.0.9") + author = doc._get_metadata(json, '__author__') + self.assertEqual(author, "Bob Ippolito ") self.assertEqual(len(w), 0) with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") - version = doc._get_version(module) + version = doc._get_metadata(module, '__version__') self.assertEqual(version, "1.2.3") self.assertEqual(len(w), 1) +class TestModule(unittest.TestCase): + def test_deprecated_module_attributes(self): + support.check_deprecated_module_attributes( + self, pydoc, "__author__", "__date__", "__credits__", + remove=(3, 20), + ) + + def setUpModule(): thread_info = threading_helper.threading_setup() unittest.addModuleCleanup(threading_helper.threading_cleanup, *thread_info) diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py index 98be98a25278024..b962f47bc844c4d 100644 --- a/Lib/test/test_pyexpat.py +++ b/Lib/test/test_pyexpat.py @@ -275,6 +275,89 @@ def test_parse_again(self): self.assertEqual(expat.ErrorString(cm.exception.code), expat.errors.XML_ERROR_FINISHED) + @support.subTests("encoding", ("utf-8", "utf-16")) + def test_parse_reentrancy_with_encoding(self, encoding): + # See https://github.com/python/cpython/issues/146169. + parser = expat.ParserCreate(encoding=encoding) + + def CharacterDataHandler(data): + return parser.Parse(data, False) + CharacterDataHandler = mock.Mock(wraps=CharacterDataHandler) + parser.CharacterDataHandler = CharacterDataHandler + + payload = "x".encode(encoding) + msg = re.escape("cannot call Parse() from within a handler") + with self.assertRaisesRegex(RuntimeError, msg): + for i in range(len(payload)): + parser.Parse(payload[i:i+1], i == len(payload) - 1) + CharacterDataHandler.assert_called_once_with("x") + + @support.subTests("encoding", ("utf-8", "utf-16")) + def test_parse_file_reentrancy_with_encoding(self, encoding): + # See https://github.com/python/cpython/issues/146169. + parser = expat.ParserCreate(encoding=encoding) + + def CharacterDataHandler(data): + return parser.ParseFile(BytesIO(data.encode(encoding))) + CharacterDataHandler = mock.Mock(wraps=CharacterDataHandler) + parser.CharacterDataHandler = CharacterDataHandler + + payload = "x".encode(encoding) + payload_buffer = BytesIO(payload) + msg = re.escape("cannot call ParseFile() from within a handler") + with self.assertRaisesRegex(RuntimeError, msg): + parser.ParseFile(payload_buffer) + CharacterDataHandler.assert_called_once_with("x") + + @support.subTests("encoding", ("utf-8", "utf-16")) + def test_parse_reentrancy_allowed_for_external_parser(self, encoding): + parser = expat.ParserCreate(encoding=encoding) + subparser = parser.ExternalEntityParserCreate(None, encoding) + payload_extstr = '' + + def ExternalEntityRefHandler(*args): + subparser.Parse(payload_extstr, True) + # return a nonzero integer to indicate that parsing continues + return 1 + ExternalEntityRefHandler = mock.Mock(wraps=ExternalEntityRefHandler) + parser.ExternalEntityRefHandler = ExternalEntityRefHandler + + payload = textwrap.dedent(f"""\ + + + &ext; + """).encode(encoding) + + # Check that external parsers be called from parent's handlers. + for i in range(len(payload)): + parser.Parse(payload[i:i+1], i == len(payload) - 1) + external_ref_args = ('ext', None, 'entity.file', None) + ExternalEntityRefHandler.assert_called_once_with(*external_ref_args) + + @support.subTests("encoding", ("utf-8", "utf-16")) + def test_parse_file_reentrancy_allowed_for_external_parser(self, encoding): + parser = expat.ParserCreate(encoding=encoding) + subparser = parser.ExternalEntityParserCreate(None, encoding) + payload_extstr = '' + + def ExternalEntityRefHandler(*args): + subparser.ParseFile(BytesIO(payload_extstr.encode(encoding))) + # return a nonzero integer to indicate that parsing continues + return 1 + ExternalEntityRefHandler = mock.Mock(wraps=ExternalEntityRefHandler) + parser.ExternalEntityRefHandler = ExternalEntityRefHandler + + payload = textwrap.dedent(f"""\ + + + &ext; + """).encode(encoding) + + # Check that external parsers be called from parent's handlers. + parser.ParseFile(BytesIO(payload)) + external_ref_args = ('ext', None, 'entity.file', None) + ExternalEntityRefHandler.assert_called_once_with(*external_ref_args) + @support.subTests('encoding', [ # built-in Expat encodings 'iso-8859-1', 'utf-8', 'utf-16', 'utf-16be', 'utf-16le', @@ -751,6 +834,103 @@ def handler(text): self.assertRaises(SpecificException, parser.Parse, xml.encode('iso8859')) + +class DefaultHandlerExceptionTest(unittest.TestCase): + # In a document that is not UTF-8, Expat passes a long piece of text such + # as this comment to the default handler in chunks of at most 1024 bytes, + # re-reading the handler between chunks. Clearing the handler from within + # the callback, by raising or by setting it to None, must not crash. + xml = ("" + % ('a' * 2000)).encode('iso8859') + + class SpecificException(Exception): + pass + + def check(self, name): + def handler(text): + if text.startswith('" + % ('a' * 2000)).encode('iso8859') + parser.Parse(xml, True) + + def test_CharacterDataHandler_with_buffer_text(self): + # With buffer_text, buffered character data is passed to the + # CharacterDataHandler just before the default handler is called; + # an exception there clears the handlers while Expat is still + # passing the comment to the default handler. + def handler(text): + raise self.SpecificException + + parser = expat.ParserCreate() + parser.buffer_text = True + parser.CharacterDataHandler = handler + parser.DefaultHandler = lambda text: None + xml = ("a" + % ('a' * 2000)).encode('iso8859') + self.assertRaises(self.SpecificException, parser.Parse, xml, True) + + class ChardataBufferTest(unittest.TestCase): """ test setting of chardata buffer size @@ -827,6 +1007,34 @@ def test_disabling_buffer(self): parser.Parse(xml3, True) self.assertEqual(self.n, 12) + def test_disable_buffer_in_character_handler(self): + parser = expat.ParserCreate() + parser.buffer_size = 2 + parser.buffer_text = True + seen = [] + + def consume(text): + seen.append(text) + if len(seen) == 1: + parser.buffer_text = False + + parser.CharacterDataHandler = consume + parser.Parse(b'aAbc', True) + self.assertEqual(''.join(seen), 'aAbc') + + def test_clear_element_handler_during_flush(self): + parser = expat.ParserCreate() + parser.buffer_text = True + elements = [] + + def consume(text): + parser.StartElementHandler = None + + parser.CharacterDataHandler = consume + parser.StartElementHandler = lambda name, attrs: elements.append(name) + parser.Parse(b'abc', True) + self.assertEqual(elements, ['r']) + def counting_handler(self, text): self.n += 1 @@ -904,7 +1112,7 @@ def test_trigger_leak(self): parser.ElementDeclHandler = lambda _1, _2: None self.assertRaises(TypeError, parser.Parse, data, True) - @support.skip_if_unlimited_stack_size + @support.run_with_limited_c_stack(800_000) @support.skip_emscripten_stack_overflow() @support.skip_wasi_stack_overflow() def test_deeply_nested_content_model(self): @@ -1045,6 +1253,16 @@ def test_parent_parser_outlives_its_subparsers__chain(self): del parser del subparser + # gh-155485: GetReparseDeferralEnabled always returns False with Expat <2.6.0. + @unittest.skipIf(not expat.ParserCreate().GetReparseDeferralEnabled(), + "requires Python compiled with Expat >= 2.6.0") + def test_subparser_inherits_reparse_deferral(self): + for enabled in (True, False): + parser = expat.ParserCreate() + parser.SetReparseDeferralEnabled(enabled) + subparser = parser.ExternalEntityParserCreate(None) + self.assertEqual(subparser.GetReparseDeferralEnabled(), enabled) + class ExternalEntityParserCreateErrorTest(unittest.TestCase): """ExternalEntityParserCreate error paths should not crash or leak @@ -1067,18 +1285,9 @@ def test_error_path_no_crash(self): parser.buffer_text = True rc_before = sys.getrefcount(parser) - # We avoid self.assertRaises(MemoryError) here because the - # context manager itself needs memory allocations that fail - # while the nomemory hook is active. - self.testcapi.set_nomemory(1, 10) - raised = False - try: - parser.ExternalEntityParserCreate(None) - except MemoryError: - raised = True - finally: - self.testcapi.remove_mem_hooks() - self.assertTrue(raised, "MemoryError not raised") + with self.assertRaises(MemoryError): + with support.inject_memory_error_cm(1, 10): + parser.ExternalEntityParserCreate(None) rc_after = sys.getrefcount(parser) self.assertEqual(rc_after, rc_before) @@ -1392,5 +1601,34 @@ def test_set_maximum_amplification__amplification_not_exceeded(self): self.assertIsNotNone(parser.Parse(payload, True)) +class VersionTest(unittest.TestCase): + + def _test_version_info(self, v): + self.assertIsInstance(v[:], tuple) + self.assertEqual(len(v), 3) + self.assertIsInstance(v[0], int) + self.assertIsInstance(v[1], int) + self.assertIsInstance(v[2], int) + self.assertIsInstance(v.major, int) + self.assertIsInstance(v.minor, int) + self.assertIsInstance(v.micro, int) + self.assertEqual(v[0], v.major) + self.assertEqual(v[1], v.minor) + self.assertEqual(v[2], v.micro) + self.assertGreaterEqual(v.major, 2) + self.assertGreaterEqual(v.minor, 0) + self.assertGreaterEqual(v.micro, 0) + + def test_version_info(self): + if support.verbose: + print(f'EXPAT_VERSION = {expat.EXPAT_VERSION}', flush=True) + print(f'VERSION_INFO = {expat.VERSION_INFO}', flush=True) + print(f'version_info = {expat.version_info}', flush=True) + self._test_version_info(expat.VERSION_INFO) + self._test_version_info(expat.version_info) + self.assertEqual(expat.EXPAT_VERSION, 'expat_%d.%d.%d' % expat.version_info) + self.assertEqual(expat.VERSION_INFO[0], expat.version_info[0]) + + if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_pyrepl/test_interact.py b/Lib/test/test_pyrepl/test_interact.py index fd4530ebc004aa7..041cbd02ad48139 100644 --- a/Lib/test/test_pyrepl/test_interact.py +++ b/Lib/test/test_pyrepl/test_interact.py @@ -1,16 +1,58 @@ import contextlib import io +import sys import warnings import unittest -from unittest.mock import patch +from unittest.mock import ANY, patch from textwrap import dedent from test.support import force_not_colorized from _pyrepl.console import InteractiveColoredConsole -from _pyrepl.simple_interact import _more_lines +from _pyrepl.simple_interact import ( + _more_lines, + run_multiline_interactive_console, +) class TestSimpleInteract(unittest.TestCase): + def test_prompts_are_converted_to_strings(self): + console = InteractiveColoredConsole() + + class Prompt: + def __init__(self, value): + self.value = value + + def __str__(self): + return self.value + + with ( + patch.object(sys, "ps1", Prompt("primary"), create=True), + patch.object(sys, "ps2", Prompt("secondary"), create=True), + patch("_pyrepl.readline._setup"), + patch( + "_pyrepl.simple_interact.multiline_input", side_effect=EOFError + ) as multiline_input, + ): + run_multiline_interactive_console(console) + + multiline_input.assert_called_once_with(ANY, "primary", "secondary") + + def test_ps1_str_error_uses_default_prompt(self): + class Prompt: + def __str__(self): + return 1 / 0 + + with ( + patch.object(sys, "ps1", Prompt(), create=True), + patch("_pyrepl.readline._setup"), + patch( + "_pyrepl.simple_interact.multiline_input", side_effect=EOFError + ) as multiline_input, + ): + run_multiline_interactive_console(InteractiveColoredConsole()) + + multiline_input.assert_called_once_with(ANY, ">>> ", ANY) + def test_multiple_statements(self): namespace = {} code = dedent("""\ @@ -131,6 +173,17 @@ def test_runsource_shows_syntax_error_for_failed_compilation(self): console.runsource(source) mock_showsyntaxerror.assert_called_once() + @force_not_colorized + def test_runsource_compile_error(self): + # Any error raised by compile() is reported (gh-69919). + console = InteractiveColoredConsole() + source = '-' * 100_000 + '1' + f = io.StringIO() + with contextlib.redirect_stderr(f): + result = console.runsource(source) + self.assertFalse(result) + self.assertRegex(f.getvalue(), r'^(MemoryError|RecursionError): ') + def test_runsource_survives_null_bytes(self): console = InteractiveColoredConsole() source = "\x00\n" @@ -182,6 +235,12 @@ def test_invalid_syntax_single_line(self): console = InteractiveColoredConsole(namespace, filename="") self.assertFalse(_more_lines(console, code)) + def test_compile_error_single_line(self): + namespace = {} + code = '-' * 100_000 + '1' # MemoryError or RecursionError + console = InteractiveColoredConsole(namespace, filename="") + self.assertFalse(_more_lines(console, code)) + def test_empty_line(self): namespace = {} code = "" diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py index 4240a3c31749599..c11c759f559affa 100644 --- a/Lib/test/test_pyrepl/test_pyrepl.py +++ b/Lib/test/test_pyrepl/test_pyrepl.py @@ -13,7 +13,7 @@ import tempfile from functools import partial from pkgutil import ModuleInfo -from unittest import TestCase, skipUnless, skipIf, SkipTest +from unittest import TestCase, skipUnless, SkipTest from unittest.mock import Mock, patch import warnings from test.support import ( @@ -37,6 +37,7 @@ code_to_events, ) from _colorize import ANSIColors, get_theme +from _pyrepl import terminfo from _pyrepl.console import Event from _pyrepl.completing_reader import stripcolor from _pyrepl._module_completer import ( @@ -689,6 +690,74 @@ def test_get_line_buffer_returns_str(self): wrapper = _ReadlineWrapper(f_in=None, f_out=None, reader=reader) self.assertIs(type(wrapper.get_line_buffer()), str) + def test_input_does_not_add_history(self): + for history in ([], ["previous input"]): + with self.subTest(history=history): + reader = self.prepare_reader( + code_to_events("first input\nsecond input\n1+1\n") + ) + reader.history[:] = history + wrapper = _ReadlineWrapper(f_in=None, f_out=None, reader=reader) + + self.assertEqual(wrapper.input(), "first input") + self.assertEqual(reader.history, history) + self.assertEqual(wrapper.input(), "second input") + self.assertEqual(reader.history, history) + self.assertEqual(multiline_input(reader), "1+1") + self.assertEqual(reader.history, [*history, "1+1"]) + + def test_input_can_read_history(self): + events = [ + Event(evt="key", data="up", raw=bytearray(b"\x1bOA")), + Event(evt="key", data="\n", raw=bytearray(b"\n")), + ] + reader = self.prepare_reader(events) + reader.history.append("previous input") + wrapper = _ReadlineWrapper(f_in=None, f_out=None, reader=reader) + + self.assertEqual(wrapper.input(), "previous input") + self.assertEqual(reader.history, ["previous input"]) + + def test_input_does_not_modify_history(self): + events = itertools.chain( + [Event(evt="key", data="up", raw=bytearray(b"\x1bOA"))], + code_to_events(" edited"), + [Event(evt="key", data="down", raw=bytearray(b"\x1bOB"))], + code_to_events("new input\n"), + ) + reader = self.prepare_reader(events) + reader.history.append("previous input") + wrapper = _ReadlineWrapper(f_in=None, f_out=None, reader=reader) + + self.assertEqual(wrapper.input(), "new input") + self.assertEqual(reader.history, ["previous input"]) + + def test_input_is_not_syntax_highlighted(self): + reader = self.prepare_reader(code_to_events("def f(): pass\n")) + reader.can_colorize = True + reader.gen_colors = Mock(return_value=()) + wrapper = _ReadlineWrapper(f_in=None, f_out=None, reader=reader) + + self.assertEqual(wrapper.input(), "def f(): pass") + reader.gen_colors.assert_not_called() + self.assertTrue(reader.can_colorize) + + def test_input_error_does_not_modify_history(self): + for text, exception in ( + ("partial input\x03", KeyboardInterrupt), + ("\x04", EOFError), + ): + with self.subTest(exception=exception): + reader = self.prepare_reader(code_to_events(text + "1+1\n")) + reader.history.append("previous input") + wrapper = _ReadlineWrapper(f_in=None, f_out=None, reader=reader) + + with self.assertRaises(exception): + wrapper.input() + self.assertEqual(reader.history, ["previous input"]) + self.assertEqual(multiline_input(reader), "1+1") + self.assertEqual(reader.history, ["previous input", "1+1"]) + def test_multiline_edit(self): events = itertools.chain( code_to_events("def f():\n...\n\n"), @@ -1172,13 +1241,27 @@ def test_completions(self): ("import foo, impo\t\n", "import foo, importlib"), ("import foo as bar, impo\t\n", "import foo as bar, importlib"), ("from impo\t\n", "from importlib"), + ("from impo\t\t\n", "from importlib import "), + ("from impo\t\t\t\n", "from importlib import "), + ("from impo \t\n", "from impo import "), + ("from importlib\t\n", "from importlib import "), ("from importlib.res\t\n", "from importlib.resources"), ("from importlib.\t\tres\t\n", "from importlib.resources"), + ("from importlib.res\t\t\n", "from importlib.resources import "), + ("from importlib.res \t\n", "from importlib.res import "), + ("from importlib.resources\t\n", "from importlib.resources import "), ("from importlib.resources.ab\t\n", "from importlib.resources.abc"), ("from importlib import mac\t\n", "from importlib import machinery"), ("from importlib import res\t\n", "from importlib import resources"), ("from importlib.res\t import a\t\n", "from importlib.resources import abc"), + ("from importlib.res\t\ta\t\n", "from importlib.resources import abc"), ("from __phello__ import s\t\n", "from __phello__ import spam"), # frozen module + ("import importlib .res\t\n", "import importlib .resources"), + ("import importlib. res\t\n", "import importlib. resources"), + ("import importlib . res\t\n", "import importlib . resources"), + ("import importlib .metadata.\t\n", "import importlib .metadata.diagnose"), + ("import importlib .metadata .\t\n", "import importlib .metadata .diagnose"), + ("from importlib .resources .a\t\n", "from importlib .resources .abc"), ) for code, expected in cases: with self.subTest(code=code): @@ -1466,7 +1549,10 @@ def test_attribute_completion(self): reader = self.prepare_reader(events, namespace={}) output = reader.readline() self.assertEqual(output, expected) - new_imports = sys.modules.keys() - _imported + # The reader imports its own helpers lazily. + new_imports = {name for name in + sys.modules.keys() - _imported + if not name.startswith('_pyrepl.')} self.assertEqual(new_imports, expected_imports) @patch.dict(sys.modules) @@ -1548,41 +1634,48 @@ def test_get_path_and_prefix(self): def test_parse(self): cases = ( - ('import ', (None, '')), - ('import foo', (None, 'foo')), - ('import foo,', (None, '')), - ('import foo, ', (None, '')), - ('import foo, bar', (None, 'bar')), - ('import foo, bar, baz', (None, 'baz')), - ('import foo as bar,', (None, '')), - ('import foo as bar, ', (None, '')), - ('import foo as bar, baz', (None, 'baz')), - ('import a.', (None, 'a.')), - ('import a.b', (None, 'a.b')), - ('import a.b.', (None, 'a.b.')), - ('import a.b.c', (None, 'a.b.c')), - ('import a.b.c, foo', (None, 'foo')), - ('import a.b.c, foo.bar', (None, 'foo.bar')), - ('import a.b.c, foo.bar,', (None, '')), - ('import a.b.c, foo.bar, ', (None, '')), - ('from foo', ('foo', None)), - ('from a.', ('a.', None)), - ('from a.b', ('a.b', None)), - ('from a.b.', ('a.b.', None)), - ('from a.b.c', ('a.b.c', None)), - ('from foo import ', ('foo', '')), - ('from foo import a', ('foo', 'a')), - ('from ', ('', None)), - ('from . import a', ('.', 'a')), - ('from .foo import a', ('.foo', 'a')), - ('from ..foo import a', ('..foo', 'a')), - ('from foo import (', ('foo', '')), - ('from foo import ( ', ('foo', '')), - ('from foo import (a', ('foo', 'a')), - ('from foo import (a,', ('foo', '')), - ('from foo import (a, ', ('foo', '')), - ('from foo import (a, c', ('foo', 'c')), - ('from foo import (a as b, c', ('foo', 'c')), + ('import ', (None, '', True)), + ('import foo', (None, 'foo', False)), + ('import foo,', (None, '', False)), + ('import foo, ', (None, '', True)), + ('import foo, bar', (None, 'bar', False)), + ('import foo, bar, baz', (None, 'baz', False)), + ('import foo as bar,', (None, '', False)), + ('import foo as bar, ', (None, '', True)), + ('import foo as bar, baz', (None, 'baz', False)), + ('import a.', (None, 'a.', False)), + ('import a.b', (None, 'a.b', False)), + ('import a.b.', (None, 'a.b.', False)), + ('import a.b.c', (None, 'a.b.c', False)), + ('import a.b.c, foo', (None, 'foo', False)), + ('import a.b.c, foo.bar', (None, 'foo.bar', False)), + ('import a.b.c, foo.bar,', (None, '', False)), + ('import a.b.c, foo.bar, ', (None, '', True)), + ('from foo', ('foo', None, False)), + ('from foo ', ('foo', None, True)), + ('from a.', ('a.', None, False)), + ('from a .', ('a.', None, False)), + ('from a .', ('a.', None, False)), + ('from a .', ('a.', None, False)), + ('from a.b', ('a.b', None, False)), + ('from a.b.', ('a.b.', None, False)), + ('from a.b ', ('a.b', None, True)), + ('from a. b.', ('a.b.', None, False)), + ('from a . b .', ('a.b.', None, False)), + ('from a.b.c', ('a.b.c', None, False)), + ('from foo import ', ('foo', '', True)), + ('from foo import a', ('foo', 'a', False)), + ('from ', ('', None, True)), + ('from . import a', ('.', 'a', False)), + ('from .foo import a', ('.foo', 'a', False)), + ('from ..foo import a', ('..foo', 'a', False)), + ('from foo import (', ('foo', '', False)), + ('from foo import ( ', ('foo', '', True)), + ('from foo import (a', ('foo', 'a', False)), + ('from foo import (a,', ('foo', '', False)), + ('from foo import (a, ', ('foo', '', True)), + ('from foo import (a, c', ('foo', 'c', False)), + ('from foo import (a as b, c', ('foo', 'c', False)), ) for code, parsed in cases: parser = ImportParser(code) @@ -1606,12 +1699,9 @@ def test_parse_error(self): cases = ( '', 'import foo ', - 'from foo ', 'import foo. ', 'import foo.bar ', - 'from foo ', 'from foo. ', - 'from foo.bar ', 'from foo import bar ', 'from foo import (bar ', 'from foo import bar, baz ', @@ -1650,9 +1740,9 @@ def test_parse_error(self): 'if 1:\n pass\n\tpass', # _tokenize TabError -> tokenize TabError ) for code in cases: - parser = ImportParser(code) - actual = parser.parse() with self.subTest(code=code): + parser = ImportParser(code) + actual = parser.parse() self.assertEqual(actual, None) @patch.dict(sys.modules) @@ -1998,8 +2088,20 @@ def test_dumb_terminal_exits_cleanly(self): self.assertNotIn("Traceback", output) +def supports_pyrepl(): + # pyrepl falls back to the basic REPL if the terminal lacks any of the + # capabilities which UnixConsole requires. This covers an unset or + # "dumb" TERM as well, they are resolved to the "dumb" capabilities. + try: + info = terminfo.TermInfo(None) + except Exception: + return False + return all(info.get(cap) is not None + for cap in ("bel", "clear", "cup", "el")) + + @skipUnless(pty, "requires pty") -@skipIf((os.environ.get("TERM") or "dumb") == "dumb", "can't use pyrepl in dumb terminal") +@skipUnless(supports_pyrepl(), "can't use pyrepl in this terminal") class TestMain(ReplTestCase): def setUp(self): # Cleanup from PYTHON* variables to isolate from local @@ -2415,6 +2517,8 @@ def test_no_newline(self): env = os.environ.copy() env.pop("PYTHON_BASIC_REPL", "") env["PYTHON_BASIC_REPL"] = "1" + # Ensure user's .inputrc doesn't interfere with basic REPL output + env["INPUTRC"] = "/dev/null" commands = "print('Something pretty long', end='')\nexit()\n" expected_output_sequence = "Something pretty long>>> exit()" diff --git a/Lib/test/test_pyrepl/test_reader.py b/Lib/test/test_pyrepl/test_reader.py index 0b32ead357c2c0d..fd9900d9a32b3d2 100644 --- a/Lib/test/test_pyrepl/test_reader.py +++ b/Lib/test/test_pyrepl/test_reader.py @@ -4,7 +4,8 @@ from textwrap import dedent from unittest import TestCase from unittest.mock import MagicMock -from test.support import force_colorized_test_class, force_not_colorized_test_class +from test.support import force_colorized, force_colorized_test_class +from test.support import force_not_colorized_test_class from .support import handle_all_events, handle_events_narrow_console from .support import ScreenEqualMixin, code_to_events @@ -72,6 +73,31 @@ def test_calc_screen_wrap_wide_characters(self): reader, _ = handle_events_narrow_console(events) self.assert_screen_equal(reader, f"{8*"a"}\\\n樂") + def test_messages_wrap_on_tight_screens(self): + console = prepare_console((), width=3) + reader = prepare_reader(console) + + reader.msg = "\x1b[31mabcdef\x1b[0m" + lines = reader._render_message_lines() + self.assertEqual( + [line.text for line in lines], + ["\x1b[31mabc\x1b[0m", "\x1b[31mdef\x1b[0m"], + ) + + reader.msg = "ab樂c" + console.width = 4 + lines = reader._render_message_lines() + self.assertEqual([line.text for line in lines], ["ab樂", "c"]) + self.assertEqual([line.width for line in lines], [4, 1]) + + reader.msg = "ab\N{COMBINING ACUTE ACCENT}cd" + console.width = 3 + lines = reader._render_message_lines() + self.assertEqual( + [line.text for line in lines], + ["ab\N{COMBINING ACUTE ACCENT}c", "d"], + ) + def test_calc_screen_wrap_three_lines(self): events = code_to_events(20 * "a") reader, _ = handle_events_narrow_console(events) @@ -431,6 +457,109 @@ def test_setpos_from_xy_for_non_printing_char(self): reader.setpos_from_xy(8, 0) self.assertEqual(reader.pos, 7) + +@force_not_colorized_test_class +class TestErrorMessages(TestCase): + @force_colorized + def test_colorized_error_message(self): + console = prepare_console(code_to_events("\x19")) + reader = prepare_reader(console) + + reader.handle1() + + theme = default_theme.syntax + self.assertEqual( + reader.msg, + f"{theme.error}! {theme.reset}nothing to yank", + ) + + def _test_error_message( + self, + keys: str, + expected: str, + *, + command: str | None = None, + binding: str | None = None, + **reader_kwargs, + ): + console = prepare_console(code_to_events(keys)) + reader = prepare_reader(console, **reader_kwargs) + if command is not None: + reader.bind(binding or keys, command) + + while not reader.msg: + reader.handle1() + + self.assertEqual(reader.msg, f"! {expected}") + self.assertEqual(reader.screen[-1], f"! {expected}") + console.beep.assert_called_once() + + def test_invalid_key_message(self): + self._test_error_message("\x1bo", "no command is bound to this key") + + def test_unimplemented_command_message(self): + self._test_error_message( + "x", + "command 'missing-command' is not implemented", + command="missing-command", + ) + + def test_nothing_to_yank_message(self): + self._test_error_message("\x19", "nothing to yank") + + def test_yank_pop_with_empty_kill_ring_message(self): + self._test_error_message("\x1by", "nothing to yank") + + def test_yank_pop_after_other_command_message(self): + self._test_error_message( + "x\x01\x0b\x1by", + "previous command was not a yank", + ) + + def test_start_of_history_message(self): + self._test_error_message("\x10", "start of history list") + + def test_end_of_history_message(self): + self._test_error_message("\x0e", "end of history list") + + def test_yank_arg_at_beginning_of_history_message(self): + self._test_error_message( + "\x1b.\x1b.\x1b.", + "beginning of history list", + history=["one"], + historyi=1, + ) + + def test_yank_arg_with_no_argument_message(self): + self._test_error_message( + "\x1b.", + "no such arg", + history=[""], + historyi=1, + ) + + def test_empty_incremental_search_backspace_message(self): + self._test_error_message( + "x", + "nothing to rubout", + command="isearch-backspace", + ) + + def test_history_search_not_found_message(self): + self._test_error_message( + "missingx", + "not found", + command="history-search-backward", + binding="x", + ) + + def test_incremental_search_not_found_message(self): + self._test_error_message("\x12x", "not found") + + def test_no_completion_matches_message(self): + self._test_error_message("does_not_exist\t", "no matches") + + @force_colorized_test_class class TestReaderInColor(ScreenEqualMixin, TestCase): def test_syntax_highlighting_basic(self): diff --git a/Lib/test/test_pyrepl/test_render.py b/Lib/test/test_pyrepl/test_render.py index 5479f2eb4bae398..7293f0f33f7405f 100644 --- a/Lib/test/test_pyrepl/test_render.py +++ b/Lib/test/test_pyrepl/test_render.py @@ -55,6 +55,15 @@ def test_from_rendered_text_empty_string(self): self.assertEqual(line.text, "") self.assertEqual(line.width, 0) + def test_from_rendered_text_with_osc_control(self): + osc = "\x1b]633;A\x1b\\" + prompt = ">>> " + line = RenderLine.from_rendered_text(osc + prompt) + + self.assertEqual(line.width, len(prompt)) + self.assertEqual(line.cells[0].controls, (osc,)) + self.assertEqual(line.cells[0].text, "") + def test_from_rendered_text_with_non_sgr_controls(self): # \x1b[H is a cursor-home control (not SGR since it doesn't end with 'm') line = RenderLine.from_rendered_text("\x1b[Hx") diff --git a/Lib/test/test_pyrepl/test_unix_console.py b/Lib/test/test_pyrepl/test_unix_console.py index 2fc8398923cbf38..05c716f4a75a9cd 100644 --- a/Lib/test/test_pyrepl/test_unix_console.py +++ b/Lib/test/test_pyrepl/test_unix_console.py @@ -1,6 +1,7 @@ import errno import itertools import os +import select import signal import sys import threading @@ -8,6 +9,7 @@ from functools import partial from _colorize import ANSIColors from test.support import force_color, os_helper, force_not_colorized_test_class +from test.support import is_android, is_apple_mobile, is_wasm32 from test.support import threading_helper from unittest import TestCase @@ -257,6 +259,27 @@ def test_cursor_back_write(self, _os_write): _os_write.assert_any_call(ANY, b"2") con.restore() + def test_insert_char_only_for_midline_insert(self, _os_write): + insert_char = b"" + events = itertools.chain( + code_to_events("1"), + [Event(evt="key", data="left", raw=bytearray(b"\x1bOD"))], + code_to_events("2"), + ) + _, con = handle_all_events( + events, + prepare_console=partial(unix_console, ich1=insert_char), + ) + relevant_writes = [] + for write in _os_write.call_args_list: + output = write.args[1] + if insert_char in output: + relevant_writes.append(insert_char) + elif output in {b"1", b"2"}: + relevant_writes.append(output) + self.assertEqual(relevant_writes, [b"1", insert_char, b"2"]) + con.restore() + def test_multiline_function_move_up_short_terminal(self, _os_write): # fmt: off code = ( @@ -424,3 +447,93 @@ def test_eio_error_handling_in_restore(self, mock_tcgetattr, mock_tcsetattr): # EIO error should be handled gracefully in restore() console.restore() + + +try: + import pty + import termios as _termios +except ImportError: + pty = None + + +@unittest.skipIf(sys.platform == "win32", "No Unix console on Windows") +@unittest.skipUnless(pty, "requires pty") +@unittest.skipIf(is_android or is_apple_mobile or is_wasm32, + "pty is not available on this platform") +class TestUnixConsoleInputHook(TestCase): + # gh-152907: the console must restore cooked output (OPOST) around + # input-hook calls, then re-enter raw mode. + + def test_input_hook_output_is_cooked(self): + master_fd, slave_fd = pty.openpty() + self.addCleanup(os.close, master_fd) + + # tcsetattr(TCSADRAIN) blocks on some platforms (e.g. macOS) while the + # master still holds unread output, so empty it before each mode switch. + def drain(): + out = b"" + while select.select([master_fd], [], [], 0)[0]: + try: + data = os.read(master_fd, 4096) + except OSError: + break + if not data: + break + out += data + return out + + # Start from a cooked terminal so there are saved flags to restore. + attr = _termios.tcgetattr(slave_fd) + attr[1] |= _termios.OPOST | _termios.ONLCR + _termios.tcsetattr(slave_fd, _termios.TCSANOW, attr) + + console = UnixConsole(slave_fd, slave_fd, term="xterm") + console.prepare() + try: + drain() # discard prepare()'s own setup sequences + # pyrepl's own rendering runs with OPOST cleared. + self.assertFalse(_termios.tcgetattr(slave_fd)[1] & _termios.OPOST) + + observed = {} + + def fake_hook(): + observed["oflag"] = _termios.tcgetattr(slave_fd)[1] + os.write(slave_fd, b"line1\nline2\n") + observed["output"] = drain() + return 0 + + with patch("_pyrepl.unix_console.posix") as mock_posix: + mock_posix._is_inputhook_installed.return_value = True + mock_posix._inputhook.side_effect = fake_hook + hook = console.input_hook + self.assertIsNotNone(hook) + self.assertEqual(hook(), 0) + + # The hook ran with cooked output (OPOST on)... + self.assertTrue(observed["oflag"] & _termios.OPOST) + # ...and raw mode was restored afterwards. + self.assertFalse(_termios.tcgetattr(slave_fd)[1] & _termios.OPOST) + # The tty translated the hook's bare '\n' into '\r\n'. + self.assertEqual(observed["output"], b"line1\r\nline2\r\n") + finally: + # restore() writes and only then switches modes, so there is no + # point left to drain from here; keep the master empty elsewhere. + stop = threading.Event() + + def pump(): + while not stop.is_set(): + if select.select([master_fd], [], [], 0.05)[0]: + try: + if not os.read(master_fd, 4096): + break + except OSError: + break + + pump_thread = threading.Thread(target=pump) + pump_thread.start() + try: + console.restore() + finally: + stop.set() + pump_thread.join() + os.close(slave_fd) diff --git a/Lib/test/test_pyrepl/test_utils.py b/Lib/test/test_pyrepl/test_utils.py index ebbd06213c69aff..9ff178c74a091c2 100644 --- a/Lib/test/test_pyrepl/test_utils.py +++ b/Lib/test/test_pyrepl/test_utils.py @@ -47,6 +47,14 @@ def test_wlen(self): self.assertEqual(wlen('e\N{COMBINING ACUTE ACCENT}'), 1) self.assertEqual(wlen('a\N{ZERO WIDTH JOINER}b'), 2) + def test_wlen_with_osc_sequence(self): + prompt = ">>> " + self.assertEqual(wlen("\x1b]633;A\x07" + prompt), len(prompt)) + + def test_wlen_with_unterminated_osc_sequence_as_individual_characters(self): + # \x1b is treated as a single character (ESC) + self.assertEqual(wlen("\x1b]633;A"), len("\x1b]633;A")) + def test_prev_next_window(self): def gen_normal(): yield 1 @@ -159,3 +167,90 @@ def test_gen_colors_keyword_highlighting(self): span_text = code[color.span.start:color.span.end + 1] actual_highlights.append((span_text, color.tag)) self.assertEqual(actual_highlights, expected_highlights) + + def test_gen_colors_soft_keywords_after_blank_lines(self): + cases = [ + ( + "def f(): pass\n", + "match -1:\n case _: pass", + ["match", "case", "_"], + ), + ( + "def f(): pass\n", + "match value:\n case _: pass", + ["match", "case", "_"], + ), + ( + "match value:\n case 0: pass\n", + " case -1: pass", + ["match", "case", "case"], + ), + ( + "match value:\n case 0: pass\n", + " case other: pass", + ["match", "case", "case"], + ), + ("def f(): pass\n", "type Alias = int", ["type"]), + ("def f(): pass\n", "lazy import mod", ["lazy"]), + ("def f(): pass\n", "lazy from mod import name", ["lazy"]), + ] + for prefix, statement, expected in cases: + for blank_line in ("\n", " \n", "# comment\n"): + code = prefix + blank_line + statement + with self.subTest(code=code): + actual = [ + code[color.span.start:color.span.end + 1] + for color in gen_colors(code) + if color.tag == "soft_keyword" + ] + self.assertEqual(actual, expected) + + def test_gen_colors_match_after_dedent(self): + for subject in ("-1", "value"): + for separator in ("", "\n", "# comment\n"): + code = ( + "if x:\n pass\n" + f"{separator}match {subject}:\n case _: pass" + ) + with self.subTest(code=code): + actual = [ + code[color.span.start:color.span.end + 1] + for color in gen_colors(code) + if color.tag == "soft_keyword" + ] + self.assertEqual(actual, ["match", "case", "_"]) + + def test_gen_colors_soft_keyword_names_in_brackets(self): + for opening, closing in ("()", "[]", "{}"): + for name in ("match", "case"): + code = f"{opening}\n{name} - 1\n{closing}" + with self.subTest(code=code): + self.assertNotIn( + "soft_keyword", [color.tag for color in gen_colors(code)] + ) + + def test_gen_colors_command_highlighting(self): + cases = [ + # highlights bare command names (after stripping whitespaces) + ("exit", [("exit", "command")]), + ("quit", [("quit", "command")]), + ("copyright", [("copyright", "command")]), + ("help", [("help", "command")]), + ("clear", [("clear", "command")]), + (" clear ", [("clear", "command")]), + # no highlight when not the only token on the line + ("x = exit", [("=", "op"), ("exit", "builtin")]), + ("obj.exit", [(".", "op")]), + # falls through to builtin when called as function or used in expression + ("exit()", [("exit", "builtin"), ("(", "op"), (")", "op")]), + ("quit(0)", [("quit", "builtin"), ("(", "op"), ("0", "number"), (")", "op")]), + ("print(exit)", [("print", "builtin"), ("(", "op"), ("exit", "builtin"), (")", "op")]), + ] + for code, expected_highlights in cases: + with self.subTest(code=code): + colors = list(gen_colors(code)) + actual_highlights = [] + for color in colors: + span_text = code[color.span.start:color.span.end + 1] + actual_highlights.append((span_text, color.tag)) + self.assertEqual(actual_highlights, expected_highlights) diff --git a/Lib/test/test_pyrepl/test_windows_console.py b/Lib/test/test_pyrepl/test_windows_console.py index 32c4255aa6b1904..784b33d9247c112 100644 --- a/Lib/test/test_pyrepl/test_windows_console.py +++ b/Lib/test/test_pyrepl/test_windows_console.py @@ -399,7 +399,7 @@ def test_reset_on_restore(self): _, con = self.handle_events(events) con._WindowsConsole__vt_support = True con._WindowsConsole__original_input_mode = 0 - with patch.object(wc, "SetConsoleMode", return_value=1): + with patch.object(wc._winapi, "SetConsoleMode"): con.restore() con.out.write.assert_any_call(ANSIColors.RESET.encode(con.encoding)) diff --git a/Lib/test/test_queue.py b/Lib/test/test_queue.py index f2898de469e349b..e1a4515500625bd 100644 --- a/Lib/test/test_queue.py +++ b/Lib/test/test_queue.py @@ -956,6 +956,11 @@ def test_negative_timeout_raises_exception(self): with self.assertRaises(ValueError): q.get(timeout=-1) + def test_nonblocking_ignores_timeout(self): + q = self.q + with self.assertRaises(self.queue.Empty): + q.get(block=False, timeout=-1) + def test_order(self): # Test a pair of concurrent put() and get() q = self.q diff --git a/Lib/test/test_quopri.py b/Lib/test/test_quopri.py index 152d1858dcdd242..2e013e9e4c80b31 100644 --- a/Lib/test/test_quopri.py +++ b/Lib/test/test_quopri.py @@ -140,8 +140,10 @@ def test_decodestring(self): @withpythonimplementation def test_decodestring_double_equals(self): # Issue 21511 - Ensure that byte string is compared to byte string - # instead of int byte value - decoded_value, encoded_value = (b"123=four", b"123==four") + # instead of int byte value. + # A stray "=" not starting a valid escape is left in place, so the + # following "=four" is decoded as a fresh (invalid) escape too. + decoded_value, encoded_value = (b"123==four", b"123==four") self.assertEqual(quopri.decodestring(encoded_value), decoded_value) @withpythonimplementation @@ -171,6 +173,30 @@ def test_embedded_ws(self): self.assertEqual(quopri.encodestring(p, quotetabs=True), e) self.assertEqual(quopri.decodestring(e), p) + @withpythonimplementation + def test_decode_strip_ws(self): + # By default trailing whitespace is kept; with strip_ws it is + # removed at the end of a line (RFC 2045), while encoded whitespace + # (=20/=09) is preserved. + self.assertEqual(quopri.decodestring(b"foo \n"), b"foo \n") + self.assertEqual(quopri.decodestring(b"foo \n", strip_ws=True), b"foo\n") + self.assertEqual(quopri.decodestring(b"a b \nc\n", strip_ws=True), b"a b\nc\n") + self.assertEqual(quopri.decodestring(b"a=20 \n", strip_ws=True), b"a \n") + self.assertEqual(quopri.decodestring(b"= \n", strip_ws=True), b"") + self.assertEqual(quopri.decodestring(b"foo =\n", strip_ws=True), b"foo ") + self.assertEqual(quopri.decodestring(b"foo \r\n", strip_ws=True), b"foo\r\n") + # A bare CR is not a line separator, so whitespace before it is kept. + self.assertEqual(quopri.decodestring(b"foo \rbar", strip_ws=True), b"foo \rbar") + + @withpythonimplementation + def test_decode_soft_line_break(self): + # A "=" at the end of a line is a soft line break, for both "\n" and + # "\r\n" line endings; other line endings are preserved as-is. + self.assertEqual(quopri.decodestring(b"=\nAB"), b"AB") + self.assertEqual(quopri.decodestring(b"=\r\nAB"), b"AB") + self.assertEqual(quopri.decodestring(b"foo=\r\nbar"), b"foobar") + self.assertEqual(quopri.decodestring(b"foo\r\nbar"), b"foo\r\nbar") + @withpythonimplementation def test_encode_header(self): for p, e in self.HSTRINGS: diff --git a/Lib/test/test_raise.py b/Lib/test/test_raise.py index 645ef291a584993..fa4306d2077357a 100644 --- a/Lib/test/test_raise.py +++ b/Lib/test/test_raise.py @@ -257,7 +257,7 @@ def test_attrs(self): self.assertIs(tb.tb_next.tb_next, None) # Invalid assignments - with self.assertRaises(TypeError): + with self.assertRaises(AttributeError): del tb.tb_next with self.assertRaises(TypeError): diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index dbd3b855f536a0d..80af93d6e45ba20 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -1082,6 +1082,14 @@ def test_binomialvariate_log_zero(self): self.assertIsInstance(result, int) self.assertIn(result, range(11)) + def test_binomialvariate_btrs_random_zero(self): + for p, expected in ((0.25, 25), (0.75, 75)): + with self.subTest(p=p): + g = random.Random() + with unittest.mock.patch.object( + g, 'random', side_effect=(0.0, 0.5, 0.5)): + self.assertEqual(g.binomialvariate(100, p), expected) + def test_constant(self): g = random.Random() N = 100 @@ -1435,29 +1443,23 @@ def test_after_fork(self): class CommandLineTest(unittest.TestCase): @support.force_not_colorized def test_parse_args(self): - args, help_text = random._parse_args(shlex.split("--choice a b c")) + args, parser = random._parse_args(shlex.split("--choice a b c")) self.assertEqual(args.choice, ["a", "b", "c"]) - self.assertStartsWith(help_text, "usage: ") - args, help_text = random._parse_args(shlex.split("--integer 5")) + args, parser = random._parse_args(shlex.split("--integer 5")) self.assertEqual(args.integer, 5) - self.assertStartsWith(help_text, "usage: ") - args, help_text = random._parse_args(shlex.split("--float 2.5")) + args, parser = random._parse_args(shlex.split("--float 2.5")) self.assertEqual(args.float, 2.5) - self.assertStartsWith(help_text, "usage: ") - args, help_text = random._parse_args(shlex.split("a b c")) + args, parser = random._parse_args(shlex.split("a b c")) self.assertEqual(args.input, ["a", "b", "c"]) - self.assertStartsWith(help_text, "usage: ") - args, help_text = random._parse_args(shlex.split("5")) + args, parser = random._parse_args(shlex.split("5")) self.assertEqual(args.input, ["5"]) - self.assertStartsWith(help_text, "usage: ") - args, help_text = random._parse_args(shlex.split("2.5")) + args, parser = random._parse_args(shlex.split("2.5")) self.assertEqual(args.input, ["2.5"]) - self.assertStartsWith(help_text, "usage: ") def test_main(self): for command, expected in [ @@ -1474,6 +1476,20 @@ def test_main(self): random.seed(0) self.assertEqual(random.main(shlex.split(command)), expected) + @support.force_not_colorized + def test_empty_integer_range_error(self): + # An integer input is the same as --integer, even when it is + # not positive. + for value in ["0", "-5"]: + err_msg = f"error: integer must be 1 or greater, got {value}\n" + for args in [[value], ["--integer", value]]: + with self.subTest(args=args): + with (support.captured_stderr() as stderr, + self.assertRaises(SystemExit) as cm): + random.main(args) + self.assertEqual(cm.exception.code, 2) + self.assertEndsWith(stderr.getvalue(), err_msg) + if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index af6e4612dcfaef5..41ee35958b77314 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -1,3 +1,4 @@ +from test import support from test.support import (gc_collect, bigmemtest, _2G, cpython_only, captured_stdout, check_disallow_instantiation, linked_to_musl, @@ -8,6 +9,7 @@ import sys import unittest import warnings +import weakref from re import Scanner from weakref import proxy @@ -1537,6 +1539,10 @@ def test_set_operations(self): with warnings.catch_warnings(): warnings.simplefilter('error', FutureWarning) re.compile(r'[a-z--[aeiou]]') + # A reserved construct inside a nested operand warns against the caller. + with self.assertWarnsRegex(FutureWarning, 'Possible nested set ') as w: + re.compile(r'[\w--[[:digit:]]]') + self.assertEqual(w.filename, __file__) # Set union A||B == A or B (an explicit form of [AB]); flat operands # merge into one charset, otherwise the operations are alternated. @@ -1557,6 +1563,10 @@ def test_set_operations(self): self.assertEqual(re.findall(r'[\d~~1]', s), list('0123456789~')) self.assertEqual(w.filename, __file__) self.assertEqual(re.findall(r'[~~1]', s), list('1~')) + with self.assertWarnsRegex(FutureWarning, + 'Possible set symmetric difference ') as w: + re.compile(r'[\w--[\d~~1]]') + self.assertEqual(w.filename, __file__) def test_search_coverage(self): self.assertEqual(re.search(r"\s(b)", " b").group(1), "b") @@ -1931,6 +1941,27 @@ def test_finditer(self): self.assertEqual([item.group(0) for item in iter], ["::", "::"]) + def test_finditer_gc(self): + class Text(str): + pass + + class Buffer(bytearray): + pass + + text = Text('a') + text.iterator = re.finditer('a', text) + ref = weakref.ref(text) + del text + gc_collect() + self.assertIsNone(ref()) + + buffer = Buffer(b'a') + buffer.iterator = re.finditer(b'a', buffer) + ref = weakref.ref(buffer) + del buffer + gc_collect() + self.assertIsNone(ref()) + def test_bug_926075(self): self.assertIsNot(re.compile('bug_926075'), re.compile(b'bug_926075')) @@ -2145,6 +2176,28 @@ def test_locale_flag(self): self.assertRaises(ValueError, re.compile, b'(?a)', re.LOCALE) self.assertRaises(re.PatternError, re.compile, b'(?aL)') + def test_locale_ignorecase_negated_set(self): + IL = re.LOCALE | re.IGNORECASE + # [bc] matches b'B', so [^bc] must not. + self.assertTrue(re.fullmatch(rb'[bc]', b'B', IL)) + self.assertIsNone(re.fullmatch(rb'[^bc]', b'B', IL)) + self.assertIsNone(re.fullmatch(rb'[^b-c]', b'C', IL)) + self.assertIsNone(re.fullmatch(rb'[^bc]', b'c', IL)) + self.assertTrue(re.fullmatch(rb'[^bc]', b'a', IL)) + # A one-member set compiles to NOT_LITERAL_LOC_IGNORE. + self.assertIsNone(re.fullmatch(rb'[^b]', b'B', IL)) + self.assertTrue(re.fullmatch(rb'[^b]', b'a', IL)) + self.assertIsNone(re.fullmatch(rb'[^\wq]', b'Q', IL)) + # A sparse set compiles to a bitmap instead of ranges. + self.assertTrue(re.fullmatch(rb'[ace]', b'C', IL)) + self.assertIsNone(re.fullmatch(rb'[^ace]', b'C', IL)) + self.assertTrue(re.fullmatch(rb'[^ace]', b'b', IL)) + # An alternation folded into a set puts NEGATE in the middle of it. + self.assertIsNone(re.fullmatch(rb'(?:a|[^bc])', b'B', IL)) + self.assertTrue(re.fullmatch(rb'(?:a|[^bc])', b'A', IL)) + self.assertIsNone(re.fullmatch(rb'\w(??') - readline.set_completer_delims(' \t\n`@#%^&*()=+[{]}\\|;:\'",<>?') - readline.get_completer_delims() - - count = 40 - barrier = threading.Barrier(count) - threads = [threading.Thread(target=completer_delims, args=(barrier,)) for _ in range(count)] - - with threading_helper.start_threads(threads): - pass - - if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py index 6d30d267cd5ad29..cd2cd8a21e8ea7f 100644 --- a/Lib/test/test_regrtest.py +++ b/Lib/test/test_regrtest.py @@ -20,11 +20,16 @@ import sys import sysconfig import tempfile +import threading import textwrap +import types import unittest import unittest.mock from xml.etree import ElementTree +from test.libregrtest.findtests import collect_cases +from test.libregrtest.filter import set_match_tests +from test.libregrtest.run_workers import MultiprocessIterator from test import support from test.support import import_helper from test.support import os_helper @@ -32,8 +37,10 @@ from test.libregrtest import main from test.libregrtest import setup from test.libregrtest import utils -from test.libregrtest.filter import get_match_tests, set_match_tests, match_test -from test.libregrtest.result import TestStats +from test.libregrtest.filter import get_match_tests, match_test +from test.libregrtest.reporter import GitHubActionsReporter +from test.libregrtest.result import State, TestResult, TestStats +from test.libregrtest.results import TestResults from test.libregrtest.utils import normalize_test_name if not support.has_subprocess_support: @@ -44,7 +51,7 @@ LOG_PREFIX = ( r'[0-9]+:[0-9]+:[0-9]+ ' r'(?:load avg: [0-9]+\.[0-9]{2} )?' - r'(?:mem: [0-9]+\.[0-9] (?:MiB|GiB) )?' + r'(?:mem: +[0-9]+\.[0-9] (?:MiB|GiB) )?' ) RESULT_REGEX = ( 'passed', @@ -170,21 +177,20 @@ def test_randomize(self): ns = self.parse_args([opt]) self.assertTrue(ns.randomize) - with os_helper.EnvironmentVarGuard() as env: - # with SOURCE_DATE_EPOCH - env['SOURCE_DATE_EPOCH'] = '1697839080' - ns = self.parse_args(['--randomize']) - regrtest = main.Regrtest(ns) - self.assertFalse(regrtest.randomize) - self.assertIsInstance(regrtest.random_seed, str) - self.assertEqual(regrtest.random_seed, '1697839080') - - # without SOURCE_DATE_EPOCH - del env['SOURCE_DATE_EPOCH'] - ns = self.parse_args(['--randomize']) - regrtest = main.Regrtest(ns) - self.assertTrue(regrtest.randomize) - self.assertIsInstance(regrtest.random_seed, int) + @os_helper.with_source_date_epoch(epoch=1697839080) + def test_randomize_with_source_date_epoch(self): + ns = self.parse_args(['--randomize']) + regrtest = main.Regrtest(ns) + self.assertFalse(regrtest.randomize) + self.assertIsInstance(regrtest.random_seed, str) + self.assertEqual(regrtest.random_seed, '1697839080') + + @os_helper.without_source_date_epoch + def test_randomize_without_source_date_epoch(self): + ns = self.parse_args(['--randomize']) + regrtest = main.Regrtest(ns) + self.assertTrue(regrtest.randomize) + self.assertIsInstance(regrtest.random_seed, int) def test_no_randomize(self): ns = self.parse_args([]) @@ -575,6 +581,30 @@ def test_single_process(self): self.assertEqual(regrtest.num_workers, 0) self.assertTrue(regrtest.single_process) + def test_single_process_per_case(self): + ns = self.parse_args(['--single-process-per-case']) + self.assertTrue(ns.single_process_per_case) + + # No -j given: default to one worker + regrtest = self.create_regrtest(['--single-process-per-case']) + self.assertEqual(regrtest.num_workers, 1) + + # Explicit -j2 is respected + regrtest = self.create_regrtest(['-j2', '--single-process-per-case']) + self.assertEqual(regrtest.num_workers, 2) + + def test_single_process_per_case_conflicts(self): + # --single-process-per-case doesn't compose with options that + # re-run or restrict test selection after collection (gh-109817) + self.checkError(['--single-process-per-case', '--rerun'], + "don't go together") + self.checkError(['--single-process-per-case', '--single-process'], + "don't go together") + self.checkError(['--single-process-per-case', '--pgo'], + "don't go together") + self.checkError(['--single-process-per-case', '--fast-ci'], + "don't go together") + def test_pythoninfo(self): ns = self.parse_args([]) self.assertFalse(ns.pythoninfo) @@ -601,6 +631,10 @@ def setUp(self): self.tmptestdir = tempfile.mkdtemp() self.addCleanup(os_helper.rmtree, self.tmptestdir) + # Don't report the failures of the tests to the CI running this test + env = self.enterContext(os_helper.EnvironmentVarGuard()) + env.unset('GITHUB_STEP_SUMMARY') + def create_test(self, name=None, code=None): if not name: name = 'noop%s' % BaseTestCase.TEST_UNIQUE_ID @@ -716,9 +750,13 @@ def list_regex(line_format, tests): self.check_line(output, regex) if env_changed: - regex = list_regex(r'%s test%s altered the execution environment ' - r'\(env changed\)', - env_changed) + # Every test is listed on a separate line, followed by the + # reasons why the environment was altered, one per line. + count = len(env_changed) + regex = (r'%s test%s altered the execution environment ' + r'\(env changed\):\n' % (count, plural(count))) + regex += ''.join(r' %s:?\n(?: .*\n)*' % re.escape(name) + for name in sorted(env_changed)) self.check_line(output, regex) if omitted: @@ -807,7 +845,8 @@ def list_regex(line_format, tests): state = ', '.join(state) if rerun is not None: new_state = 'SUCCESS' if rerun.success else 'FAILURE' - state = f'{state} then {new_state}' + if new_state != state: + state = f'{state} then {new_state}' self.check_line(output, f'Result: {state}', full=True) def parse_random_seed(self, output: str) -> str: @@ -1283,29 +1322,47 @@ def test_run(self): forever=True) @support.requires_jit_disabled - def check_leak(self, code, what, *, run_workers=False): - test = self.create_test('huntrleaks', code=code) + def check_leak(self, code, what, *, run_workers=False, + name='huntrleaks', deltas=(1, 1, 1)): + test = self.create_test(name, code=code) + leak = all(delta >= 1 for delta in deltas) filename = 'reflog.txt' self.addCleanup(os_helper.unlink, filename) cmd = ['--huntrleaks', '3:3:'] if run_workers: cmd.append('-j1') cmd.append(test) + if leak: + exitcode = EXITCODE_BAD_TEST + kwargs = dict(failed=test) + else: + exitcode = 0 + kwargs = {} + + try: + os_helper.unlink(filename) + except FileNotFoundError: + pass output = self.run_tests(*cmd, - exitcode=EXITCODE_BAD_TEST, + exitcode=exitcode, stderr=subprocess.STDOUT) - self.check_executed_tests(output, [test], failed=test, stats=1) + self.check_executed_tests(output, [test], stats=1, **kwargs) - line = r'beginning 6 repetitions. .*\n123:456\n[.0-9X]{3} 111\n' + digits = ''.join('1' if delta >= 1 else '.' for delta in deltas) + line = r'beginning 6 repetitions. .*\n123:456\n[.0-9X]{3} %s\n' % digits self.check_line(output, line) - line2 = '%s leaked [1, 1, 1] %s, sum=3\n' % (test, what) - self.assertIn(line2, output) + if leak: + line2 = f'{test} leaked {repr(list(deltas))} {what}, sum=3\n' + self.assertIn(line2, output) - with open(filename) as fp: - reflog = fp.read() - self.assertIn(line2, reflog) + if leak: + with open(filename) as fp: + reflog = fp.read() + self.assertIn(line2, reflog) + else: + self.assertFalse(os.path.exists(filename)) @unittest.skipUnless(support.Py_DEBUG, 'need a debug build') def check_huntrleaks(self, *, run_workers: bool): @@ -1382,6 +1439,60 @@ def test_leak(self): """) self.check_leak(code, 'file descriptors') + # Ignore false positive: deltas [1, -1, 0] + code = textwrap.dedent(""" + import os + import unittest + + RUN = 0 + FD = None + + class FDLeakTest(unittest.TestCase): + def test_leak(self): + global RUN, FD + RUN += 1 + if RUN == 4: + # Create a fd without closing it: leak! (delta=1) + FD = os.open(__file__, os.O_RDONLY) + elif RUN == 5: + # Close fd created in previous run (delta=-1) + os.close(FD) + else: + # Do nothing at the warmup (steps 1-3) and step 6 (delta=0) + pass + """) + self.check_leak(code, 'file descriptors', + name='no_fd_leak', deltas=(1, -1, 0)) + + @unittest.skipUnless(support.Py_DEBUG, 'need a debug build') + @unittest.skipUnless(support.MS_WINDOWS, 'test specific to Windows') + def test_huntrleaks_handle_leak(self): + # test --huntrleaks for Windows handle leak + code = textwrap.dedent(""" + import unittest + import _winapi + + handle = None + + class HandleLeakTest(unittest.TestCase): + def test_leak(self): + global handle + if handle is None: + handle = _winapi.CreateFile( + __file__, _winapi.GENERIC_READ, + 0, _winapi.NULL, + _winapi.OPEN_EXISTING, + 0, _winapi.NULL) + else: + hproc = _winapi.GetCurrentProcess() + copy = _winapi.DuplicateHandle( + hproc, handle, + hproc, 0, False, + _winapi.DUPLICATE_SAME_ACCESS) + # bug! the new handle is never closed + """) + self.check_leak(code, 'handles') + def test_list_tests(self): # test --list-tests tests = [self.create_test() for i in range(5)] @@ -1535,6 +1646,35 @@ def test_env_changed(self): success=True), stats=2) + def test_reporter(self): + code = textwrap.dedent(""" + import os, unittest + + class Tests(unittest.TestCase): + def test_fail(self): + self.fail() + """) + fail = self.create_test('reporter_fail', code) + crash = self.create_test('reporter_crash', + code.replace('self.fail()', 'os._exit(1)')) + summary = os.path.join(self.tmptestdir, 'summary.md') + env = dict(os.environ, GITHUB_STEP_SUMMARY=summary) + + def reported(*args, exitcode=EXITCODE_BAD_TEST): + output = self.run_tests('-j1', *args, env=env, exitcode=exitcode) + return re.findall(r'^::error file=.*,title=(\w+)', output, + re.MULTILINE) + + self.assertEqual(reported(self.create_test(), exitcode=0), []) + self.assertFalse(os.path.exists(summary)) + # Quiet mode doesn't print the failure, but reports it + self.assertEqual(reported(fail), ['test_fail']) + # Only the re-run is reported + self.assertEqual(reported('--rerun', fail, crash), + ['test_fail', crash]) + with open(summary, encoding='utf-8') as fp: + self.assertIn('2 test files and 1 test case failed', fp.read()) + def test_rerun_fail(self): # FAILURE then FAILURE code = textwrap.dedent(""" @@ -2152,6 +2292,18 @@ def load_tests(loader, tests, pattern): failed=[testname], parallel=True, stats=TestStats(1, 2, 1)) + # A single -v reports the test names, not the examples. + self.assertNotIn('Trying:', output) + + # -vv reports every example, without changing what is run. + output = self.run_tests("--fail-env-changed", "-vv", "-j1", testname, + exitcode=EXITCODE_BAD_TEST) + self.check_executed_tests(output, [testname], + failed=[testname], + parallel=True, + stats=TestStats(1, 2, 1)) + self.assertIn('Trying:\n 1 + 1\n', output) + self.assertIn('Expecting:\n 2\n', output) def _check_random_seed(self, run_workers: bool): # gh-109276: When -r/--randomize is used, random.seed() is called @@ -2333,6 +2485,94 @@ def test_crash(self): self.assertIn(f"Exit code {exitcode} (SIGSEGV)", output) self.check_line(output, "just before crash!", full=True, regex=False) + def test_single_process_per_case(self): + code = textwrap.dedent(""" + import unittest + + class Tests(unittest.TestCase): + def test_one(self): + pass + def test_two(self): + pass + """) + testname = self.create_test(code=code) + + output = self.run_tests('--single-process-per-case', '-v', testname) + # Each case is reported individually (progress lines have a + # timestamp prefix, so match mid-line with assertIn) + self.assertIn(f'{testname}.Tests.test_one passed', output) + self.assertIn(f'{testname}.Tests.test_two passed', output) + self.check_line(output, 'All 2 tests OK.', regex=False) + + def test_single_process_per_case_order_independence(self): + # A module where test_b only passes if it runs in isolation. + # This simulates the real order-dependency bugs this feature + # is meant to catch (gh-109817): running each case in its own + # process means test_b can never observe state left behind + # by test_a. + code = textwrap.dedent(""" + import unittest + + counter = {'n': 0} + + class Tests(unittest.TestCase): + def test_a(self): + counter['n'] += 1 + def test_b(self): + self.assertEqual(counter['n'], 0) + """) + testname = self.create_test(code=code) + + output = self.run_tests('--single-process-per-case', '-v', testname) + self.assertIn(f'{testname}.Tests.test_a passed', output) + self.assertIn(f'{testname}.Tests.test_b passed', output) + self.check_line(output, 'All 2 tests OK.', regex=False) + + def test_single_process_per_case_failure_isolated(self): + # One failing case must not abort or contaminate sibling + # cases in the same module. + code = textwrap.dedent(""" + import unittest + + class Tests(unittest.TestCase): + def test_pass(self): + pass + def test_fail(self): + self.fail("expected failure") + """) + testname = self.create_test(code=code) + + output = self.run_tests('--single-process-per-case', testname, + exitcode=EXITCODE_BAD_TEST) + # The failing case is reported by its case ID... + self.assertIn(f'{testname}.Tests.test_fail failed', output) + self.check_line(output, '1 test failed:', regex=False) + self.assertIn(f' {testname}.Tests.test_fail', output) + # ...and the sibling case in the same module still ran and passed + self.assertIn(f'{testname}.Tests.test_pass passed', output) + self.check_line(output, '1 test OK.', regex=False) + + def test_single_process_per_case_import_error(self): + testname = self.create_test(code='raise ImportError("boom")') + + output = self.run_tests('--single-process-per-case', testname, + exitcode=EXITCODE_BAD_TEST) + self.check_executed_tests(output, [testname], failed=[testname], + stats=0) + self.assertNotIn('_FailedTest', output) + + def test_single_process_per_case_skipped_module(self): + code = textwrap.dedent(""" + import unittest + raise unittest.SkipTest("nope") + """) + testname = self.create_test(code=code) + + output = self.run_tests('--single-process-per-case', testname) + self.check_executed_tests(output, [testname], + skipped=[testname], stats=0) + + def test_verbose3(self): code = textwrap.dedent(r""" import unittest @@ -2443,6 +2683,113 @@ def test_pythoninfo(self): self.assertIn("Python build information", output) +class FindTestsTestCase(BaseTestCase): + def test_collect_cases_groups_by_module(self): + code = textwrap.dedent(""" + import unittest + + class Tests(unittest.TestCase): + def test_one(self): + pass + def test_two(self): + pass + """) + testname = self.create_test(code=code) + sys.path.insert(0, self.tmptestdir) + self.addCleanup(sys.path.remove, self.tmptestdir) + self.addCleanup(sys.modules.pop, testname, None) + self.addCleanup(set_match_tests, None) + + cases_by_module, skipped = collect_cases((testname,), + test_dir=self.tmptestdir) + self.assertIn(testname, cases_by_module) + self.assertEqual(len(cases_by_module[testname]), 2) + self.assertEqual(skipped, []) + + def test_collect_cases_match_tests_filters(self): + code = textwrap.dedent(""" + import unittest + + class Tests(unittest.TestCase): + def test_keep(self): + pass + def test_drop(self): + pass + """) + testname = self.create_test(code=code) + sys.path.insert(0, self.tmptestdir) + self.addCleanup(sys.path.remove, self.tmptestdir) + self.addCleanup(sys.modules.pop, testname, None) + self.addCleanup(set_match_tests, None) + + cases_by_module, _ = collect_cases( + (testname,), + match_tests=[('*test_keep*', True)], + test_dir=self.tmptestdir) + case_ids = cases_by_module.get(testname, []) + self.assertTrue(any('test_keep' in c for c in case_ids)) + self.assertFalse(any('test_drop' in c for c in case_ids)) + + def test_collect_cases_skiptest(self): + code = textwrap.dedent(""" + import unittest + raise unittest.SkipTest("module-level skip") + """) + testname = self.create_test(code=code) + sys.path.insert(0, self.tmptestdir) + self.addCleanup(sys.path.remove, self.tmptestdir) + self.addCleanup(sys.modules.pop, testname, None) + self.addCleanup(set_match_tests, None) + + cases_by_module, skipped = collect_cases((testname,), + test_dir=self.tmptestdir) + self.assertEqual(cases_by_module, {}) + self.assertIn(testname, skipped) + + +class MultiprocessIteratorTestCase(unittest.TestCase): + def test_yields_all_groups_once(self): + groups = [("mod_a", ("mod_a.A.t1", "mod_a.A.t2")), + ("mod_b", ("mod_b.B.t1",))] + it = MultiprocessIterator(iter(groups)) + seen = [] + while (g := next(it, None)) is not None: + seen.append(g) + self.assertEqual(seen, groups) + + def test_exhausted_returns_none(self): + it = MultiprocessIterator(iter([])) + self.assertIsNone(next(it, None)) + + def test_stop_halts_iteration(self): + groups = [("mod_a", ("mod_a.A.t1",)), ("mod_b", ("mod_b.B.t1",))] + it = MultiprocessIterator(iter(groups)) + next(it, None) + it.stop() + self.assertIsNone(next(it, None)) + + def test_thread_safety_no_duplicate_or_lost_groups(self): + n = 200 + groups = [(f"mod_{i}", (f"mod_{i}.T.t",)) for i in range(n)] + it = MultiprocessIterator(iter(groups)) + results = [] + results_lock = threading.Lock() + + def worker(): + while (g := next(it, None)) is not None: + with results_lock: + results.append(g) + + threads = [threading.Thread(target=worker) for _ in range(8)] + for t in threads: + t.start() + for t in threads: + t.join() + + self.assertEqual(sorted(results), sorted(groups)) + self.assertEqual(len(results), n) + + class TestUtils(unittest.TestCase): def test_format_duration(self): self.assertEqual(utils.format_duration(0), @@ -2634,8 +2981,89 @@ def test_sanitize_xml(self): self.assertEqual(sanitize_xml('valid t\xe9xt \u20ac'), 'valid t\xe9xt \u20ac') + def test_cleanup_test_name(self): + cleanup_test_name = utils.cleanup_test_name -from test.libregrtest.results import TestResults + # Strip "test." prefix + self.assertEqual(cleanup_test_name('test.test_asyncio.test_graph'), + 'test_asyncio.test_graph') + self.assertEqual(cleanup_test_name('test.test_multiprocessing_spawn.test_manager'), + 'test_multiprocessing_spawn.test_manager') + + # No change + self.assertEqual(cleanup_test_name('test_cmath'), + 'test_cmath') + self.assertEqual(cleanup_test_name('test_asyncio.test_graph'), + 'test_asyncio.test_graph') + + +class GitHubActionsReporterTestCase(unittest.TestCase): + def setUp(self): + self.reporter = GitHubActionsReporter() + self.reporter.run_started(types.SimpleNamespace( + final_run=True, fail_env_changed=True, test_dir=None)) + + def test_test_case_failed(self): + stdlib_dir = os.path.dirname(os.__file__) + traceback = textwrap.dedent(f"""\ + Traceback (most recent call last): + File "{stdlib_dir}/test/test_x.py", line 3, in test_x + helper() + File "{stdlib_dir}/helper.py", line 9, in helper + raise ValueError('50%') + ValueError: 50% + more + """) + stream = io.StringIO() + self.reporter.test_case_failed('test_x (a: b, c)', traceback, stream) + self.assertEqual( + stream.getvalue(), + '::error file=Lib/test/test_x.py,line=3,' + 'title=test_x (a%3A b%2C c)::ValueError: 50%25%0Amore\n') + + def test_test_result(self): + result = TestResult('test_x', state=State.ENV_CHANGED, + env_changed_reasons=['dangling thread']) + with support.captured_stdout() as stdout: + self.reporter.test_result(result) + self.assertEqual(stdout.getvalue(), + '::error title=test_x::' + 'test_x failed (env changed)%0Adangling thread\n') + + def test_summary(self): + results = TestResults() + results.rerun_results = [ + TestResult('test_x', state=State.FAILED, + failures=[('test_a ()', + 'Traceback\nAssertionError\n')]), + TestResult('test_y', state=State.ENV_CHANGED, + env_changed_reasons=['dangling thread']), + ] + self.addCleanup(os_helper.unlink, os_helper.TESTFN) + with os_helper.EnvironmentVarGuard() as env: + env['GITHUB_STEP_SUMMARY'] = os_helper.TESTFN + self.reporter.summary(results, 'FAILURE') + with open(os_helper.TESTFN, encoding='utf-8') as fp: + summary = fp.read() + self.assertEqual(summary, textwrap.dedent("""\ + ## FAILURE: 2 test files and 1 test case failed + + ### test_x failed (1 failure) + +
test_a (<T>) + + ```pytb + Traceback + AssertionError + ``` + +
+ + ### test_y failed (env changed) + + - dangling thread + + """)) class TestColorized(unittest.TestCase): diff --git a/Lib/test/test_remote_pdb.py b/Lib/test/test_remote_pdb.py index d26d63faa61ddb6..e5387526090536d 100644 --- a/Lib/test/test_remote_pdb.py +++ b/Lib/test/test_remote_pdb.py @@ -8,6 +8,7 @@ import subprocess import sys import textwrap +import threading import unittest import unittest.mock from contextlib import closing, contextmanager, redirect_stdout, redirect_stderr, ExitStack @@ -18,6 +19,11 @@ import pdb from pdb import _PdbServer, _PdbClient +try: + import pty +except ImportError: + pty = None + if not sys.is_remote_debug_enabled(): raise unittest.SkipTest('remote debugging is disabled') @@ -1090,6 +1096,45 @@ def _connect_and_get_client_file(self): return process, client_file + def _connect_and_get_client_file_via_pty(self): + """Like _connect_and_get_client_file, but run the target under a pty. + + With a real terminal on stdin/stdout, PyREPL is available *inside the + target process*, which is the condition that exercises pdb's PyREPL + input handling in the remote server. + """ + controller, worker = pty.openpty() + self.addCleanup(os.close, controller) + env = dict(os.environ, TERM="xterm-256color") + env.pop("PYTHON_BASIC_REPL", None) # don't opt out of PyREPL + process = subprocess.Popen( + [sys.executable, self.script_path], + stdin=worker, stdout=worker, stderr=worker, env=env, close_fds=True, + ) + os.close(worker) # only the child keeps the worker end open + + # Continuously drain the terminal so the child never blocks on a write. + drainer = threading.Thread( + target=self._drain_until_eof, args=(controller,), daemon=True + ) + drainer.start() + self.addCleanup(drainer.join, SHORT_TIMEOUT) + + client_sock, _ = self.server_sock.accept() + client_file = client_sock.makefile('rwb') + self.addCleanup(client_file.close) + self.addCleanup(client_sock.close) + + return process, client_file + + @staticmethod + def _drain_until_eof(fd): + try: + while os.read(fd, 1024): + pass + except OSError: + pass # controller closed, or the pty went away with the child + def _read_until_prompt(self, client_file): """Helper to read messages until a prompt is received.""" messages = [] @@ -1292,6 +1337,81 @@ def test_handle_eof(self): self.assertEqual(process.returncode, 0) self.assertEqual(stderr, "") + def test_colorized_list_has_no_caret_encoded_newlines(self): + """A colorized ``list`` must not append "^J" to each source line. + + The remote server colorizes the source it sends to the client. The + colorizer renders control characters in caret notation, so a source + line's trailing newline has to be stripped *before* it is colorized; + otherwise every listed line ends with a spurious "^J". ``where`` was + unaffected because it strips the line before colorizing. See + gh-154470. + """ + # colorize=True is what attaching from a color-capable terminal passes + # to the server, and it is what makes the server colorize ``list``. + script = textwrap.dedent(f""" + import pdb, sys + def helper(): + x = 42 + return x + def connect(): + frame = sys._getframe() + pdb._connect( + host='127.0.0.1', + port={self.port}, + frame=frame, + commands="", + version=pdb._PdbServer.protocol_version(), + signal_raising_thread=False, + colorize=True, + ) + return helper() + connect() + """) + self._create_script(script=script) + process, client_file = self._connect_and_get_client_file() + + with kill_on_error(process): + self._read_until_prompt(client_file) + self._send_command(client_file, "l 1, 15") + messages = self._read_until_prompt(client_file) + source = "".join(m["message"] for m in messages if "message" in m) + + # Sanity: we really did receive colorized source ... + self.assertIn("helper", source) + self.assertIn("\x1b[", source) # ANSI color escapes are present + # ... and no trailing newline leaked through as caret notation. + self.assertNotIn("^J", source) + self._send_command(client_file, "c") + process.wait(timeout=SHORT_TIMEOUT) + self.assertEqual(process.returncode, 0) + + @unittest.skipUnless(pty, "requires pty") + def test_prompt_with_interactive_terminal(self): + """The server must send "(Pdb) " even when the target owns a terminal. + + The remote server transmits its prompt string to the client, which + displays it. When the target process has an interactive terminal, + PyREPL is enabled inside it; the base pdb machinery then blanks + ``self.prompt`` (a local PyREPL would draw the prompt itself). The + remote server has no local PyREPL -- it reads input from the socket -- + so it must keep the real prompt rather than transmit an empty one. + Regression test for gh-154467, where attaching with ``pdb -p`` to a + process running at an interactive prompt showed a blank prompt. + """ + self._create_script() + process, client_file = self._connect_and_get_client_file_via_pty() + + with kill_on_error(process): + messages = self._read_until_prompt(client_file) + # The message that ended the read is the prompt request. + self.assertEqual(messages[-1], {"prompt": "(Pdb) ", "state": "pdb"}) + + # Let the target run to completion so nothing is left attached. + self._send_command(client_file, "c") + process.wait(timeout=SHORT_TIMEOUT) + self.assertEqual(process.returncode, 0) + def test_protocol_version(self): """Test that incompatible protocol versions are properly detected.""" # Create a script using an incompatible protocol version diff --git a/Lib/test/test_repl.py b/Lib/test/test_repl.py index 0f5009c32124902..3525dee84493acc 100644 --- a/Lib/test/test_repl.py +++ b/Lib/test/test_repl.py @@ -104,10 +104,11 @@ def test_no_memory(self): # no memory. Check also that the fix does not break the interactive # loop when an exception is raised. user_input = """ - import sys, _testcapi + import sys + from test import support 1/0 print('After the exception.') - _testcapi.set_nomemory(0) + support.inject_memory_error() sys.exit(0) """ user_input = dedent(user_input) @@ -152,21 +153,69 @@ def test_multiline_string_parsing(self): output = kill_python(p) self.assertEqual(p.returncode, 0) + @unittest.skipIf(sys.platform == "win32", "select() cannot wait for pipes") + def test_secondary_prompt_is_not_read_ahead(self): + process = spawn_repl() + output = "" + + def read_until(marker, start=0): + nonlocal output + while marker not in output[start:]: + ready, _, _ = select.select( + [process.stdout], [], [], SHORT_TIMEOUT + ) + self.assertTrue(ready, output) + data = os.read(process.stdout.fileno(), 4096) + self.assertTrue(data, output) + output += data.decode() + + try: + read_until(">>> ") + process.stdin.write("(\n") + process.stdin.flush() + read_until("... ") + after_secondary_prompt = len(output) + + process.stdin.write("1)\n") + process.stdin.flush() + read_until(">>> ", after_secondary_prompt) + self.assertEqual(output[after_secondary_prompt:], "1\n>>> ") + finally: + kill_python(process) + @cpython_only def test_lexer_buffer_realloc_with_null_start(self): - # gh-144759: NULL pointer arithmetic in the lexer when start and - # multi_line_start are NULL (uninitialized in tok_mode_stack[0]) - # and the lexer buffer is reallocated while parsing long input. - long_value = "a" * 2000 + # gh-144759: NULL pointer arithmetic when the lexer buffer grows + # while parsing long input. + long_value = "é漢" * 2000 user_input = dedent(f"""\ x = f'{{{long_value!r}}}' print(x) """) + for newline in ("\n", "\r\n"): + with self.subTest(newline=newline): + p = spawn_repl(encoding="utf-8") + # Bypass Windows text-mode translation of CRLF to CRCRLF. + p.stdin.buffer.write(user_input.replace("\n", newline).encode("utf-8")) + output = kill_python(p) + self.assertEqual(p.returncode, 0) + self.assertIn(long_value, output) + + @cpython_only + def test_multiline_fstring_source_reallocation(self): + long_line = " " * 9000 + "+ 2" + user_input = ( + 'value = f"""{(\n' + '1\n' + f'{long_line}\n' + ')}"""\n' + 'print(value)\n' + ) p = spawn_repl() p.stdin.write(user_input) output = kill_python(p) self.assertEqual(p.returncode, 0) - self.assertIn(long_value, output) + self.assertIn(">>> 3\n>>> ", output) def test_close_stdin(self): user_input = dedent(''' diff --git a/Lib/test/test_reprlib.py b/Lib/test/test_reprlib.py index 5a95a05c6496a29..ecfd199fde45315 100644 --- a/Lib/test/test_reprlib.py +++ b/Lib/test/test_reprlib.py @@ -27,6 +27,14 @@ def nestedTuple(nesting): class ReprTests(unittest.TestCase): + def test_repr(self): + self.assertEqual( + repr(Repr(maxlevel=3, fillvalue='***', indent='\t')), + "Repr(maxlevel=3, maxtuple=6, maxlist=6, maxarray=5, maxdict=4, " + "maxset=6, maxfrozenset=6, maxdeque=6, maxstring=30, maxlong=40, " + "maxother=30, fillvalue='***', indent='\\t')", + ) + def test_init_kwargs(self): example_kwargs = { "maxlevel": 101, diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index 6ea27c463f31484..97d2ae4e33c548b 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -99,6 +99,11 @@ def expected(cur): # silently converted the limit value to RLIM_INFINITY. if sys.maxsize < 2**32 <= cur <= resource.RLIM_INFINITY: return [(resource.RLIM_INFINITY, max), (cur, max)] + # Solaris silently converts limits that do not fit in a signed + # 64-bit integer to RLIM_INFINITY. + if cur >= 2**63-1: + return [(resource.RLIM_INFINITY, max), + (min(cur, resource.RLIM_INFINITY), max)] return [(min(cur, resource.RLIM_INFINITY), max)] resource.setrlimit(resource.RLIMIT_FSIZE, (2**31-5, max)) diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py index 9693cfc259286d4..504180a282da370 100644 --- a/Lib/test/test_robotparser.py +++ b/Lib/test/test_robotparser.py @@ -875,5 +875,80 @@ def test_read_404(self): self.assertIsNone(parser.crawl_delay('*')) self.assertIsNone(parser.request_rate('*')) + +class RepeatedUserAgentTest(unittest.TestCase): + + def test_many_duplicate_user_agents(self): + # gh-162282: a User-agent repeated within one group must not be + # merged into that group once per repetition (quadratic time). + body = "User-agent: evil\n" * 1000 + "Disallow: /\n" + parser = urllib.robotparser.RobotFileParser() + parser.parse(body.splitlines()) + entry = parser.groups["evil"] + self.assertIs(entry, parser.entries[0]) + self.assertEqual(len(entry.rulelines), 1) + self.assertFalse(parser.can_fetch("evil", "/")) + + def test_many_groups_for_same_user_agent(self): + body = "User-agent: evil\nDisallow: /x\n\n" * 999 + parser = urllib.robotparser.RobotFileParser() + parser.parse(body.splitlines()) + entry = parser.groups["evil"] + self.assertEqual(len(entry.rulelines), 999) + # The merged entry is extended in place rather than copied. + parser.parse("User-agent: evil\nDisallow: /x\nCrawl-delay: 5".splitlines()) + self.assertIs(parser.groups["evil"], entry) + self.assertEqual(len(entry.rulelines), 1000) + self.assertEqual(entry.delay, 5) + # The original entries are left intact. + self.assertEqual([len(e.rulelines) for e in parser.entries], [1] * 1000) + self.assertIsNone(parser.entries[-2].delay) + + def test_merged_group_shared_by_user_agents(self): + parser = urllib.robotparser.RobotFileParser() + parser.parse("""\ +User-agent: a +User-agent: b +User-agent: c +Disallow: /x + +User-agent: a +User-agent: b +Disallow: /y + +User-agent: a +Disallow: /z +""".splitlines()) + groups = parser.groups + self.assertIs(groups["c"], parser.entries[0]) + self.assertEqual(list(map(str, groups["a"].rulelines)), + ["Disallow: /x", "Disallow: /y", "Disallow: /z"]) + self.assertEqual(list(map(str, groups["b"].rulelines)), + ["Disallow: /x", "Disallow: /y"]) + self.assertEqual(list(map(str, groups["c"].rulelines)), + ["Disallow: /x"]) + self.assertFalse(parser.can_fetch("a", "/z")) + self.assertTrue(parser.can_fetch("b", "/z")) + self.assertTrue(parser.can_fetch("c", "/y")) + + def test_many_user_agents_in_one_group(self): + body = "".join(f"User-agent: bot{i}\n" for i in range(1000)) + body += "Disallow: /\n\nUser-agent: other\nDisallow: /x\n" + parser = urllib.robotparser.RobotFileParser() + parser.parse(body.splitlines()) + self.assertIs(parser.groups["bot0"], parser.groups["bot999"]) + calls = [] + orig = urllib.robotparser.Entry.applies_to + def applies_to(entry, useragent): + calls.append(entry) + return orig(entry, useragent) + with support.swap_attr(urllib.robotparser.Entry, "applies_to", + applies_to): + self.assertTrue(parser.can_fetch("unknown", "/")) + self.assertFalse(parser.can_fetch("xbot5x", "/")) + # Each distinct entry is checked at most once per lookup. + self.assertEqual(len(calls), 2 + 1) + + if __name__=='__main__': unittest.main() diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py index 55b9673ef6c91c0..fbe83131ff99cd4 100644 --- a/Lib/test/test_runpy.py +++ b/Lib/test/test_runpy.py @@ -14,13 +14,11 @@ import warnings from test.support import ( force_not_colorized_test_class, - infinite_recursion, - no_tracing, - requires_resource, requires_subprocess, verbose, ) from test import support +from test.support import os_helper from test.support.import_helper import forget, make_legacy_pyc, unload from test.support.os_helper import create_empty_file, temp_dir, FakePath from test.support.script_helper import make_script, make_zip_script @@ -771,17 +769,17 @@ def test_zipfile_error(self): msg = "can't find '__main__' module in %r" % zip_name self._check_import_error(zip_name, msg) - @no_tracing - @requires_resource('cpu') - def test_main_recursion_error(self): + def test_main_no_recursion(self): + # gh-75221: __main__ is searched only in the executed directory or + # zipfile, so running a directory without __main__ from a zipfile's + # __main__ fails instead of recursing. with temp_dir() as script_dir, temp_dir() as dummy_dir: mod_name = '__main__' source = ("import runpy\n" "runpy.run_path(%r)\n") % dummy_dir script_name = self._make_test_script(script_dir, mod_name, source) zip_name, fname = make_zip_script(script_dir, 'test_zip', script_name) - with infinite_recursion(25): - self.assertRaises(RecursionError, run_path, zip_name) + self.assertRaises(ImportError, run_path, zip_name) def test_encoding(self): with temp_dir() as script_dir: @@ -917,5 +915,95 @@ def test_pymain_run_module(self): self.assertSigInt(["-m", ham.stem], cwd=ham.parent) +class MiscTests(unittest.TestCase): + def test_remove_sys_path0(self): + # Check that all path0 copies are removed + PATH0 = '/path/zero' + STDLIB_PATH = '/to/stdlib' + OTHER_PATH = '/other/path' + sys_path = [PATH0, STDLIB_PATH, PATH0, '', OTHER_PATH, PATH0] + expected = [STDLIB_PATH, '', OTHER_PATH] + with (support.swap_attr(sys, '_stdlib_dir', STDLIB_PATH), + support.swap_attr(sys, '_path0', PATH0), + support.swap_attr(sys, 'path', sys_path)): + runpy._remove_sys_path0() + self.assertEqual(sys.path, expected) + + # Calling it twice does nothing + runpy._remove_sys_path0() + self.assertEqual(sys.path, expected) + + # Do nothing if sys._path0 is sys._stdlib_dir + sys_path = ['', STDLIB_PATH, OTHER_PATH] + expected = sys_path.copy() + with (support.swap_attr(sys, '_stdlib_dir', STDLIB_PATH), + support.swap_attr(sys, '_path0', STDLIB_PATH), + support.swap_attr(sys, 'path', sys_path)): + runpy._remove_sys_path0() + self.assertEqual(sys.path, expected) + + # Do nothing if sys._path0 is None + sys_path = ['', STDLIB_PATH, OTHER_PATH] + expected = sys_path.copy() + with (support.swap_attr(sys, '_stdlib_dir', STDLIB_PATH), + support.swap_attr(sys, '_path0', None), + support.swap_attr(sys, 'path', sys_path)): + runpy._remove_sys_path0() + self.assertEqual(sys.path, expected) + + def run_python(self, *args, PYTHONPATH=None): + cmd = [sys.executable, *args] + env = support.make_clean_env() + if PYTHONPATH: + env['PYTHONPATH'] = PYTHONPATH + proc = subprocess.run(cmd, text=True, stderr=subprocess.PIPE, env=env) + self.assertEqual(proc.returncode, 0, proc.stderr) + + @support.requires_subprocess() + def test_remove_sys_path0_run_python(self): + CODE = textwrap.dedent(""" + import runpy, sys + + # Remove sys.path[0] + orig_path = sys.path.copy() + path0 = sys._path0 + runpy._remove_sys_path0() + + if path0 is not None and path0 in sys.path: + raise Exception(f"path0 {path0!r} found in sys.path {sys.path!r}") + if not sys.flags.safe_path: + if sys.path == orig_path: + raise Exception("sys.path was not changed") + else: + if sys.path != orig_path: + raise Exception("sys.path was changed") + + # Calling it twice must do nothing + clean_path = sys.path.copy() + runpy._remove_sys_path0() + if sys.path != clean_path: + raise Exception("sys.path was changed") + """) + + # Test "python -c code" + self.run_python('-c', CODE) + self.run_python('-P', '-c', CODE) + + with tempfile.TemporaryDirectory() as tmpdir: + name = 'test_remove_sys_path0' + filename = os.path.join(tmpdir, f'{name}.py') + with open(filename, 'w') as fp: + fp.write(CODE) + + # Test "python script.py" + self.run_python(filename) + self.run_python('-P', filename) + + with os_helper.change_cwd(tmpdir): + # Test "python -m module" + self.run_python('-m', name) + self.run_python('-P', '-m', name, PYTHONPATH=tmpdir) + + if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_samply_profiler.py b/Lib/test/test_samply_profiler.py index 6c3be8f38ed0c00..ae3f047b15194a8 100644 --- a/Lib/test/test_samply_profiler.py +++ b/Lib/test/test_samply_profiler.py @@ -1,7 +1,6 @@ import unittest import subprocess import sys -import sysconfig import os import pathlib from test import support @@ -14,20 +13,13 @@ if not support.has_subprocess_support: raise unittest.SkipTest("test module requires subprocess") -if support.check_sanitizer(address=True, memory=True, ub=True, function=True): +if support.check_sanitizer(address=True, memory=True, function=False): # gh-109580: Skip the test because it does crash randomly if Python is # built with ASAN. - raise unittest.SkipTest("test crash randomly on ASAN/MSAN/UBSAN build") + raise unittest.SkipTest("test crash randomly on ASAN/MSAN build") -def supports_trampoline_profiling(): - perf_trampoline = sysconfig.get_config_var("PY_HAVE_PERF_TRAMPOLINE") - if not perf_trampoline: - return False - return int(perf_trampoline) == 1 - - -if not supports_trampoline_profiling(): +if not support.supports_perf_trampoline_profiling(): raise unittest.SkipTest("perf trampoline profiling not supported") diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py index 29babd7bf6996ad..b1cbbce72e30f43 100644 --- a/Lib/test/test_sax.py +++ b/Lib/test/test_sax.py @@ -24,8 +24,9 @@ import sys from urllib.error import URLError import urllib.request -from test.support import os_helper -from test.support import findfile, check__all__ +from test import support +from test.support import (check__all__, cpython_only, findfile, + import_helper, os_helper) from test.support.os_helper import FakePath, TESTFN @@ -614,6 +615,22 @@ def test_xmlgen_ns(self): '' % ns_uri)) + def test_xmlgen_ns_escaped_uri(self): + uri = 'http://example.org/?a="1"&b=<2>' + result = self.ioclass() + gen = XMLGenerator(result) + + gen.startDocument() + gen.startPrefixMapping("ns1", uri) + gen.startElementNS((uri, "doc"), "ns1:doc", {}) + gen.endElementNS((uri, "doc"), "ns1:doc") + gen.endPrefixMapping("ns1") + gen.endDocument() + + self.assertEqual(result.getvalue(), self.xml( + """""" + "")) + def test_xmlgen_ns_empty(self): result = self.ioclass() gen = XMLGenerator(result, short_empty_elements=True) @@ -1574,15 +1591,18 @@ def test_all(self): class TestModule(unittest.TestCase): - def test_deprecated__version__and__date__(self): + def test_deprecated_module_attributes(self): for module in (sax.expatreader, sax.handler): with self.subTest(module=module): - with self.assertWarnsRegex( - DeprecationWarning, - "'version' is deprecated and slated for removal in Python 3.20", - ) as cm: - getattr(module, "version") - self.assertEqual(cm.filename, __file__) + support.check_deprecated_module_attributes( + self, module, "version", remove=(3, 20), + ) + + @cpython_only + def test_lazy_import(self): + import_helper.ensure_lazy_imports( + "xml.sax.saxutils", {"urllib.parse", "urllib.request"} + ) if __name__ == "__main__": diff --git a/Lib/test/test_script_helper.py b/Lib/test/test_script_helper.py index eeea6c4842b4881..e65b3efdcd0a701 100644 --- a/Lib/test/test_script_helper.py +++ b/Lib/test/test_script_helper.py @@ -12,7 +12,7 @@ class TestScriptHelper(unittest.TestCase): def test_assert_python_ok(self): t = script_helper.assert_python_ok('-c', 'import sys; sys.exit(0)') - self.assertEqual(0, t[0], 'return code was not 0') + self.assertEqual(0, t.rc, 'return code was not 0') def test_assert_python_failure(self): # I didn't import the sys module so this child will fail. diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py index 9bfd4bc7d636699..54d229b71def9a7 100644 --- a/Lib/test/test_set.py +++ b/Lib/test/test_set.py @@ -762,6 +762,17 @@ def test_constructor_identity(self): t = self.thetype(s) self.assertEqual(id(s), id(t)) + def test_gc_tracking(self): + # gh-140232: frozensets whose elements can never be tracked by the + # GC are not tracked, including the compiled frozenset({...}) form + s = {1, 2} + self.assertFalse(gc.is_tracked(frozenset(s))) + self.assertFalse(gc.is_tracked(frozenset({1, 2}))) + self.assertFalse(gc.is_tracked(frozenset({x for x in range(2)}))) + class C: + pass + self.assertTrue(gc.is_tracked(frozenset({C()}))) + def test_hash(self): self.assertEqual(hash(self.thetype('abcdeb')), hash(self.thetype('ebecda'))) diff --git a/Lib/test/test_shlex.py b/Lib/test/test_shlex.py index 2adaee81b063085..4c0cd88bbcda14f 100644 --- a/Lib/test/test_shlex.py +++ b/Lib/test/test_shlex.py @@ -1,8 +1,11 @@ import io import itertools +import os import shlex import string +import tempfile import unittest +from unittest.mock import patch from test.support import cpython_only from test.support import import_helper @@ -376,6 +379,203 @@ def testPunctuationCharsReadOnly(self): with self.assertRaises(AttributeError): shlex_instance.punctuation_chars = False + def testLinenoAfterNewLine(self): + s = shlex.shlex("line 1\nline 2") + self.assertEqual(s.lineno, 1) # before consumption + list(s) + self.assertEqual(s.lineno, 2) + + def testLinenoAfterComment(self): + """Comment handler increments lineno even without a trailing newline.""" + s = shlex.shlex("line 1 # line 2") + list(s) + self.assertEqual(s.lineno, 2) + + def testPushToken(self): + s = shlex.shlex("b c") + s.push_token("a") + self.assertListEqual(list(s), ["a", "b", "c"]) + + def testPushTokenLifo(self): + s = shlex.shlex("") + s.push_token("first") + s.push_token("last") + self.assertListEqual(list(s), ["last", "first"]) + + def testPushTokenDebug(self): + s = shlex.shlex("") + s.debug = 1 + tok = "a" + with patch("builtins.print") as mock_print: + s.push_token(tok) + mock_print.assert_called_once_with(f"shlex: pushing token {tok!r}") + + def testPushSourceString(self): + s = shlex.shlex("world") + s.push_source("hello") + self.assertListEqual(list(s), ["hello", "world"]) + + def testPushSourceStream(self): + s = shlex.shlex("world") + s.push_source(io.StringIO("hello")) + self.assertListEqual(list(s), ["hello", "world"]) + + def testPushSourceStreamDebug(self): + s = shlex.shlex("") + stream = io.StringIO("hello") + s.debug = 1 + with patch("builtins.print") as mock_print: + s.push_source(stream) + mock_print.assert_called_once_with(f"shlex: pushing to stream {stream}") + + def testPushSourceNewfile(self): + """shlex.push_source sets infile to newfile; pop_source restores the original on exhaustion.""" + original_file = "original.sh" + new_file = "new.sh" + s = shlex.shlex("b", infile=original_file) + s.debug = 1 + with patch("builtins.print") as mock_print: + s.push_source("a", newfile=new_file) + mock_print.assert_called_once_with(f"shlex: pushing to file {new_file}") + self.assertEqual(s.infile, new_file) + s.debug = 0 + list(s) + self.assertEqual(s.infile, original_file) + + def testPopSourceDebug(self): + """pop_source emits debug output when debug is set.""" + s = shlex.shlex("b") + original_stream = s.instream + s.push_source("a") + s.debug = 1 + with patch("builtins.print") as mock_print: + list(s) # exhausts pushed source and triggers pop_source internally + mock_print.assert_any_call(f"shlex: popping to {original_stream}, line 1") + + def testErrorLeaderTracksPosition(self): + infile_label = "test.sh" + s = shlex.shlex("line 1\nline 2", infile=infile_label) + list(s) + result = s.error_leader() + self.assertEqual(result, f'"{infile_label}", line 2: ') + + def testErrorLeaderOverrides(self): + s = shlex.shlex("foo", infile="original.sh") + infile_label_override = "override.sh" + lineno_override = 42 + result = s.error_leader(infile=infile_label_override, lineno=lineno_override) + self.assertEqual(result, f'"{infile_label_override}", line {lineno_override}: ') + + def testNoClosingQuotation(self): + s = shlex.shlex('"foo') + with self.assertRaisesRegex(ValueError, "No closing quotation"): + list(s) + + def testNoEscapedCharacter(self): + s = shlex.shlex("\\", posix=True) + with self.assertRaisesRegex(ValueError, "No escaped character"): + list(s) + + def testSourcehookStripsQuotes(self): + with tempfile.NamedTemporaryFile(mode="w", suffix=".sh", delete_on_close=False) as f: + f.write("hello") + f.close() + s = shlex.shlex("") + newfile, stream = s.sourcehook(f'"{f.name}"') + stream.close() + self.assertEqual(newfile, f.name) + + def testSourcehookAbsolutePath(self): + with tempfile.NamedTemporaryFile(mode="w", delete_on_close=False) as f: + f.close() + s = shlex.shlex("", infile="/some/dir/main.sh") + newfile, stream = s.sourcehook(f.name) + stream.close() + self.assertEqual(newfile, f.name) + + def testSourcehookRelativePath(self): + with tempfile.TemporaryDirectory() as d: + fpath = os.path.join(d, "included.sh") + with open(fpath, "w"): + pass + s = shlex.shlex("", infile=os.path.join(d, "main.sh")) + newfile, stream = s.sourcehook("included.sh") + stream.close() + self.assertEqual(newfile, fpath) + + def testSourceInclusion(self): + """shlex.source sets a trigger keyword: when the lexer reads a token equal + to it, the next token is consumed as a filename and passed to + sourcehook, which returns a stream to push onto the input stack. + Tokens flow from that stream first, then resume from the original. + """ + s = shlex.shlex("trigger filename remaining") + s.source = "trigger" + s.sourcehook = lambda f: (f, io.StringIO("included")) + self.assertEqual(list(s), ["included", "remaining"]) + + def testGetTokenPopsPushbackDebug(self): + s = shlex.shlex("") + s.push_token("hello") + s.debug = 1 # set after push_token to isolate the pop-token branch + with patch("builtins.print") as mock_print: + tok = s.get_token() + self.assertEqual(tok, "hello") + mock_print.assert_called_once_with("shlex: popping token 'hello'") + + def testDebugWhitespaceInWhitespaceState(self): + s = shlex.shlex(" a") + s.debug = 2 + with patch("builtins.print") as mock_print: + list(s) + mock_print.assert_any_call("shlex: I see whitespace in whitespace state") + + def testDebugWhitespaceInWordState(self): + s = shlex.shlex("a b") + s.debug = 2 + with patch("builtins.print") as mock_print: + list(s) + mock_print.assert_any_call("shlex: I see whitespace in word state") + + def testDebugPunctuationInWordState(self): + s = shlex.shlex("a(") + s.debug = 2 + with patch("builtins.print") as mock_print: + list(s) + mock_print.assert_any_call("shlex: I see punctuation in word state") + + def testDebugRawToken(self): + s = shlex.shlex("hello") + s.debug = 2 + with patch("builtins.print") as mock_print: + list(s) + mock_print.assert_any_call("shlex: raw token='hello'") + + def testDebugEOFInQuote(self): + s = shlex.shlex('"oops', posix=True) + s.debug = 2 + with patch('builtins.print') as mock_print: + with self.assertRaises(ValueError): + list(s) + msgs = [call.args[0] for call in mock_print.call_args_list] + self.assertTrue(any("EOF in quotes" in m for m in msgs)) + + def testDebugEOFInEscape(self): + s = shlex.shlex("oops\\", posix=True) + s.debug = 2 + with patch("builtins.print") as mock_print: + with self.assertRaises(ValueError): + list(s) + msgs = [call.args[0] for call in mock_print.call_args_list] + self.assertTrue(any("EOF in escape" in m for m in msgs)) + + def testDebugStateTrace(self): + s = shlex.shlex("a") + s.debug = 3 + with patch("builtins.print") as mock_print: + list(s) + mock_print.assert_any_call("shlex: in state ' ' I see character: 'a'") + @cpython_only def test_lazy_imports(self): import_helper.ensure_lazy_imports('shlex', {'collections', 're', 'os'}) diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index 6832bea094fc1dc..47221d1bf46fa18 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -32,6 +32,7 @@ from test import support from test.support import os_helper, socket_helper from test.support.os_helper import TESTFN, FakePath +from test.support.import_helper import ensure_lazy_imports TESTFN2 = TESTFN + "2" TESTFN_SRC = TESTFN + "_SRC" @@ -494,6 +495,37 @@ def check_args_to_onexc(self, func, arg, exc): self.assertTrue(isinstance(exc, OSError)) self.errorState = 3 + @os_helper.skip_if_dac_override + @os_helper.skip_unless_working_chmod + @unittest.skipUnless(shutil.rmtree.avoids_symlink_attacks, + 'requires the fd based implementation of rmtree()') + def test_on_exc_kwargs(self): + os.mkdir(TESTFN) + self.addCleanup(shutil.rmtree, TESTFN) + + child_dir_path = os.path.join(TESTFN, 'b') + child_file_path = os.path.join(child_dir_path, 'a') + os.mkdir(child_dir_path) + os_helper.create_empty_file(child_file_path) + old_child_dir_mode = os.stat(child_dir_path).st_mode + # Make unwritable. + new_mode = stat.S_IREAD|stat.S_IEXEC + os.chmod(child_dir_path, new_mode) + + self.addCleanup(os.chmod, child_dir_path, old_child_dir_mode) + + calls = [] + def onexc(func, path, err, direntry=None, dir_fd=None): + calls.append((func, path, err)) + if func is os.unlink: + self.assertEqual(direntry.name, os.path.basename(path)) + self.assertTrue(os.path.samestat( + os.stat(path), os.stat(direntry.name, dir_fd=dir_fd))) + + shutil.rmtree(TESTFN, onexc=onexc, _onexc_kwargs=True) + self.assertIn((os.unlink, child_file_path), + [(func, path) for func, path, err in calls]) + @unittest.skipIf(sys.platform[:6] == 'cygwin', "This test can't be run on Cygwin (issue #1071513).") @os_helper.skip_if_dac_override @@ -534,6 +566,63 @@ def onexc(*args): self.assertTrue(onexc_called) self.assertFalse(onerror_called) + @unittest.skipUnless(shutil.rmtree.avoids_symlink_attacks, + 'requires the fd based implementation of rmtree()') + def test_onexc_kwargs_dir_fd(self): + os.mkdir(TESTFN) + self.addCleanup(os_helper.rmtree, TESTFN) + top_name = os.path.join(TESTFN, 'top') + child_name = os.path.join(TESTFN, 'top', 'child') + os.mkdir(top_name) + os.mkdir(child_name) + parent_fd = os.open(TESTFN, os.O_RDONLY) + self.addCleanup(os.close, parent_fd) + + errors = [] + def onexc(func, path, err, direntry=None, dir_fd=None): + errors.append((func, path.replace(os.path.sep, '/'))) + name = path if direntry is None else direntry.name + self.assertEqual(name, os.path.basename(path)) + self.assertTrue(os.path.samestat( + os.stat(os.path.join(TESTFN, path)), + os.stat(name, dir_fd=dir_fd))) + + def failing_rmdir(path, *, dir_fd=None): + raise PermissionError(errno.EACCES, 'simulated') + with unittest.mock.patch('os.rmdir', failing_rmdir): + shutil.rmtree('top', dir_fd=parent_fd, onexc=onexc, + _onexc_kwargs=True) + self.assertEqual( + errors, + [(failing_rmdir, 'top/child'), (failing_rmdir, 'top')]) + + child_stat = os.stat(child_name) + scandir = os.scandir + + # Fail for the top-level directory + errors.clear() + def failing_scandir(fd): + raise PermissionError(errno.EACCES, 'simulated') + with unittest.mock.patch('os.scandir', failing_scandir): + shutil.rmtree('top', dir_fd=parent_fd, onexc=onexc, + _onexc_kwargs=True) + self.assertEqual( + errors, + [(failing_scandir, 'top'), (os.rmdir, 'top')]) + self.assertTrue(os.path.exists(top_name)) + + # Fail for the child (which is empty, so the rmdir succeeds) + errors.clear() + def failing_scandir_2(fd): + if not os.path.samestat(os.fstat(fd), child_stat): + return scandir(fd) + raise PermissionError(errno.EACCES, 'simulated') + with unittest.mock.patch('os.scandir', failing_scandir_2): + shutil.rmtree('top', dir_fd=parent_fd, onexc=onexc, + _onexc_kwargs=True) + self.assertEqual(errors, [(failing_scandir_2, 'top/child')]) + self.assertFalse(os.path.exists(top_name)) + def test_rmtree_does_not_choke_on_failing_lstat(self): try: orig_lstat = os.lstat @@ -551,11 +640,7 @@ def raiser(fn, *args, **kwargs): os.lstat = orig_lstat def test_rmtree_uses_safe_fd_version_if_available(self): - _use_fd_functions = ({os.open, os.stat, os.unlink, os.rmdir} <= - os.supports_dir_fd and - os.listdir in os.supports_fd and - os.stat in os.supports_follow_symlinks) - if _use_fd_functions: + if shutil._use_fd_functions: self.assertTrue(shutil.rmtree.avoids_symlink_attacks) tmp_dir = self.mkdtemp() d = os.path.join(tmp_dir, 'a') @@ -960,6 +1045,47 @@ def test_copytree_retains_permissions(self): self.assertEqual(os.stat(restrictive_subdir).st_mode, os.stat(restrictive_subdir_dst).st_mode) + @os_helper.skip_unless_working_chmod + def test_copytree_no_copy_dir_stat(self): + tmp_dir = self.mkdtemp() + src_dir = os.path.join(tmp_dir, 'source') + sub_dir = os.path.join(src_dir, 'sub') + os.makedirs(sub_dir) + dst_dir = os.path.join(tmp_dir, 'destination') + self.addCleanup(shutil.rmtree, tmp_dir) + old_time = 1_000_000_000 # 2001-09-09, far from "now" + for path in (sub_dir, src_dir): + os.utime(path, (old_time, old_time)) + os.chmod(path, 0o555) + self.addCleanup(os.chmod, path, 0o700) + + shutil.copytree(src_dir, dst_dir, copy_dir_stat=False) + for src_path, dst_path in ((src_dir, dst_dir), + (sub_dir, os.path.join(dst_dir, 'sub'))): + mode = stat.S_IMODE(os.stat(dst_path).st_mode) + self.assertNotEqual(mode, 0o555) + self.assertTrue(mode & stat.S_IWUSR, oct(mode)) + self.assertNotEqual(os.stat(src_path).st_mtime, + os.stat(dst_path).st_mtime) + + @os_helper.skip_unless_working_chmod + def test_copytree_no_copy_dir_stat_keeps_file_metadata(self): + tmp_dir = self.mkdtemp() + src_dir = os.path.join(tmp_dir, 'source') + os.mkdir(src_dir) + dst_dir = os.path.join(tmp_dir, 'destination') + self.addCleanup(shutil.rmtree, tmp_dir) + + create_file((src_dir, 'restricted.txt'), '123') + os.chmod(os.path.join(src_dir, 'restricted.txt'), 0o600) + os.chmod(src_dir, 0o555) + self.addCleanup(os.chmod, src_dir, 0o700) + + shutil.copytree(src_dir, dst_dir, copy_dir_stat=False) + self.assertNotEqual(stat.S_IMODE(os.stat(dst_dir).st_mode), 0o555) + self.assertEqual(os.stat(os.path.join(src_dir, 'restricted.txt')).st_mode, + os.stat(os.path.join(dst_dir, 'restricted.txt')).st_mode) + @unittest.mock.patch('os.chmod') def test_copytree_winerror(self, mock_patch): # When copying to VFAT, copystat() raises OSError. On Windows, the @@ -1574,6 +1700,47 @@ def test_copyfile_socket(self): self.assertRaisesRegex(shutil.SpecialFileError, 'is a socket', shutil.copyfile, __file__, sock_path) + def _check_copyfile_symlink_to_special_file(self, target): + tmp_dir = self.mkdtemp() + src = os.path.join(tmp_dir, 'src') + dst = os.path.join(tmp_dir, 'dst') + os.symlink(target, src) + + shutil.copyfile(src, dst, follow_symlinks=False) + + self.assertTrue(os.path.islink(dst)) + self.assertEqual(os.readlink(dst), target) + + @os_helper.skip_unless_symlink + @unittest.skipUnless(os.path.exists('/dev/null'), 'requires /dev/null') + def test_copyfile_symlink_to_character_device(self): + self._check_copyfile_symlink_to_special_file('/dev/null') + + @os_helper.skip_unless_symlink + @unittest.skipUnless(hasattr(os, "mkfifo"), 'requires os.mkfifo()') + @unittest.skipIf(sys.platform == "vxworks", + "fifo requires special path on VxWorks") + def test_copyfile_symlink_to_named_pipe(self): + fifo_path = os.path.join(self.mkdtemp(), 'fifo') + try: + os.mkfifo(fifo_path) + except PermissionError as e: + self.skipTest('os.mkfifo(): %s' % e) + self._check_copyfile_symlink_to_special_file(fifo_path) + + @os_helper.skip_unless_symlink + @socket_helper.skip_unless_bind_unix_socket + def test_copyfile_symlink_to_socket(self): + sock_path = os.path.join(self.mkdtemp(), 'sock') + sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + self.addCleanup(sock.close) + try: + socket_helper.bind_unix_socket(sock, sock_path) + except OSError as e: + self.skipTest(f'cannot bind AF_UNIX socket: {e}') + self.addCleanup(os_helper.unlink, sock_path) + self._check_copyfile_symlink_to_special_file(sock_path) + @unittest.skipUnless(os.path.exists('/dev/null'), 'requires /dev/null') def test_copyfile_character_device(self): self.assertRaisesRegex(shutil.SpecialFileError, 'is a character device', @@ -1958,8 +2125,8 @@ def test_make_archive_owner_group(self): # testing make_archive with owner and group, with various combinations # this works even if there's not gid/uid support if UID_GID_SUPPORT: - group = grp.getgrgid(0)[0] - owner = pwd.getpwuid(0)[0] + group = grp.getgrgid(0).gr_name + owner = pwd.getpwuid(0).pw_name else: group = owner = 'root' @@ -1986,8 +2153,8 @@ def test_make_archive_owner_group(self): def test_tarfile_root_owner(self): root_dir, base_dir = self._create_files() base_name = os.path.join(self.mkdtemp(), 'archive') - group = grp.getgrgid(0)[0] - owner = pwd.getpwuid(0)[0] + group = grp.getgrgid(0).gr_name + owner = pwd.getpwuid(0).pw_name with os_helper.change_cwd(root_dir), no_chdir: archive_name = make_archive(base_name, 'gztar', root_dir, 'dist', owner=owner, group=group) @@ -2079,6 +2246,21 @@ def test_make_zipfile_in_curdir(self): # root_dir must be None, so the archive path is relative. self.assertEqual(make_archive('test', 'zip'), 'test.zip') self.assertTrue(os.path.isfile('test.zip')) + # The archive does not contain itself. + with zipfile.ZipFile('test.zip') as zf: + self.assertEqual(zf.namelist(), []) + + @support.requires_zlib() + @os_helper.skip_unless_symlink + def test_make_zipfile_symlink_to_archive(self): + root_dir, base_dir = self._create_files('') + os.symlink('archive.zip', os.path.join(root_dir, 'link')) + base_name = os.path.join(root_dir, 'archive') + with no_chdir: + archive = make_archive(base_name, 'zip', root_dir) + with zipfile.ZipFile(archive) as zf: + self.assertCountEqual(zf.namelist(), + ['sub/', 'sub2/', 'file1', 'file2', 'sub/file3']) def test_make_archive_pathlike_cwd_default(self): called_args = [] @@ -2177,12 +2359,18 @@ def check_unpack_archive(self, format, **kwargs): self.check_unpack_archive_with_converter(format, FakePath, **kwargs) def check_unpack_archive_with_converter(self, format, converter, **kwargs): + make_format = kwargs.pop("make_format", format) + extension = kwargs.pop("extension", None) root_dir, base_dir = self._create_files() expected = rlistdir(root_dir) expected.remove('outer') base_name = os.path.join(self.mkdtemp(), 'archive') - filename = make_archive(base_name, format, root_dir, base_dir) + filename = make_archive(base_name, make_format, root_dir, base_dir) + if extension is not None: + new_filename = os.path.splitext(filename)[0] + extension + os.rename(filename, new_filename) + filename = new_filename # let's try to unpack it now tmpdir2 = self.mkdtemp() @@ -2230,6 +2418,13 @@ def test_unpack_archive_zip(self): with self.assertRaises(TypeError): self.check_unpack_archive('zip', filter='data') + @support.requires_zlib() + def test_unpack_archive_whl(self): + self.check_unpack_archive('whl', make_format='zip', extension='.whl') + with self.assertRaises(TypeError): + self.check_unpack_archive('whl', filter='data', make_format='zip', + extension='.whl') + def test_unpack_archive_zip_badpaths(self): srcdir = self.mkdtemp() zipname = os.path.join(srcdir, 'test.zip') @@ -2321,6 +2516,14 @@ def _boo(filename, extract_dir, extra): unregister_unpack_format('Boo2') self.assertEqual(get_unpack_formats(), formats) + def test_compression_wrappers_not_imported_by_shutil(self): + # gh-154904: Importing shutil must not pull in the compression + # wrappers: they are only needed once an archive is actually created + # or extracted, and importing them measurably slows down every + # process that uses shutil. + ensure_lazy_imports("shutil", + {"bz2", "lzma", "compression", "compression.zstd"}) + class TestMisc(BaseTest, unittest.TestCase): @@ -2392,8 +2595,8 @@ def check_chown(path, uid=None, gid=None): check_chown(dirname, gid=gid) try: - user = pwd.getpwuid(uid)[0] - group = grp.getgrgid(gid)[0] + user = pwd.getpwuid(uid).pw_name + group = grp.getgrgid(gid).gr_name except KeyError: # On some systems uid/gid cannot be resolved. pass @@ -2468,6 +2671,10 @@ def test_basic(self): rv = shutil.which(self.file, path=self.dir) self.assertEqual(rv, self.filepath) + def test_pathlike_cmd(self): + rv = shutil.which(FakePath(self.file), path=self.dir) + self.assertEqual(rv, self.filepath) + def test_absolute_cmd(self): # When given the fully qualified path to an executable that exists, # it should be returned. diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py index 2cad18a69ff7c02..a8f82faee775533 100644 --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -1231,6 +1231,17 @@ def setsig(self, signum, handler): old_handler = signal.signal(signum, handler) self.addCleanup(signal.signal, signum, old_handler) + def wait_for_signals(self, sigs, expected_sigs, deadline): + # Wait for the handlers to run, so that pending signals are not + # coalesced. + # + # Signals normally arrive within microseconds, so poll with a short + # sleep rather than sleeping_retry() whose 10 ms minimum delay + # dominates the runtime (and is stretched by timer coalescing on + # macOS). + while len(sigs) < expected_sigs and time.monotonic() < deadline: + time.sleep(1e-5) + def measure_itimer_resolution(self): N = 20 times = [] @@ -1302,14 +1313,11 @@ def second_handler(signum=None, frame=None): while expected_sigs < N: os.kill(os.getpid(), signal.SIGPROF) expected_sigs += 1 - # Wait for handlers to run to avoid signal coalescing - while len(sigs) < expected_sigs and time.monotonic() < deadline: - time.sleep(1e-5) + self.wait_for_signals(sigs, expected_sigs, deadline) os.kill(os.getpid(), signal.SIGUSR1) expected_sigs += 1 - while len(sigs) < expected_sigs and time.monotonic() < deadline: - time.sleep(1e-5) + self.wait_for_signals(sigs, expected_sigs, deadline) # All ITIMER_REAL signals should have been delivered to the # Python handler @@ -1334,6 +1342,8 @@ def handler(signum, frame): self.setsig(signal.SIGALRM, handler) # for ITIMER_REAL expected_sigs = 0 + deadline = time.monotonic() + support.SHORT_TIMEOUT + while expected_sigs < N: # Hopefully the SIGALRM will be received somewhere during # initial processing of SIGUSR2. @@ -1341,10 +1351,7 @@ def handler(signum, frame): os.kill(os.getpid(), signal.SIGUSR2) expected_sigs += 2 - # Wait for handlers to run to avoid signal coalescing - for _ in support.sleeping_retry(support.SHORT_TIMEOUT): - if len(sigs) >= expected_sigs: - break + self.wait_for_signals(sigs, expected_sigs, deadline) # All ITIMER_REAL signals should have been delivered to the # Python handler diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index bcb51ed7d8476a8..9bc7bc8b710b579 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -14,11 +14,13 @@ from test.support import captured_stderr from test.support.os_helper import TESTFN, EnvironmentVarGuard from test.support.script_helper import spawn_python, kill_python +from test.support.venv import VirtualEnvironmentMixin import ast import builtins import contextlib import glob import io +import json import os import re import shutil @@ -29,6 +31,7 @@ import tempfile from textwrap import dedent from types import SimpleNamespace +import textwrap import urllib.error import urllib.request from unittest import mock @@ -247,6 +250,23 @@ def test_sitedir_variable(self): sitedir = stdout.getvalue().rstrip() self.assertEqual(sitedir, pth_dir) + def test_fullname_variable(self): + # gh-156404: ".pth" files generated before Python 3.15 read the path + # of the file being processed from the frame executing the import + # line, under the name "fullname". For example, "wheel-axle" + # generates: "import wheel_axle.runtime; + # wheel_axle.runtime.finalize(fullname);" + code = '; '.join(( + "import sys", + "print(fullname)", + "print(filename)", + )) + pth_dir, pth_fn = self.make_pth(code) + with support.captured_stdout() as stdout: + site.addpackage(pth_dir, pth_fn, set()) + expected = os.path.join(pth_dir, pth_fn) + self.assertEqual(stdout.getvalue().splitlines(), [expected, expected]) + # This tests _getuserbase, hence the double underline # to distinguish from a test for getuserbase def test__getuserbase(self): @@ -468,7 +488,7 @@ def cleanup(self, prep=False): os.rmdir(self.bad_dir_path) -class ImportSideEffectTests(unittest.TestCase): +class ImportSideEffectTests(unittest.TestCase, VirtualEnvironmentMixin): """Test side-effects from importing 'site'.""" def setUp(self): @@ -587,6 +607,48 @@ def test_lazy_imports(self): "textwrap", ]) + @support.requires_subprocess() + def test_system_site_packages(self): + script = textwrap.dedent(""" + import sys, json + + print(json.dumps( + sys.path, + indent=2, + )) + """) + + # Use the base interpreter's scheme and prefixes, even when running + # inside a virtual environment. + system_scheme_name = sysconfig._get_preferred_schemes()['prefix'] + system_paths = sysconfig.get_paths(system_scheme_name, vars={ + 'base': sys.base_prefix, + 'platbase': sys.base_exec_prefix, + }) + + with self.venv(system_site_packages=False) as venv: + sys_path = json.loads(venv.run('-c', script).stdout) + self.assertNotIn(system_paths['purelib'], sys_path) + self.assertNotIn(system_paths['platlib'], sys_path) + + # site.py only adds site directories that exist on disk + # (addsitedir guards on os.path.isdir), so the system + # site-packages can only be detected when the directories exist, + # e.g. with an installed Python. Skip on in-tree builds where the + # nominal install directories were never created (gh-128779). + system_site_packages = {system_paths['purelib'], + system_paths['platlib']} + if not all(map(os.path.isdir, system_site_packages)): + self.skipTest( + f"system site-packages directories do not exist: " + f"{sorted(system_site_packages)}" + ) + + with self.venv(system_site_packages=True) as venv: + sys_path = json.loads(venv.run('-c', script).stdout) + self.assertIn(system_paths['purelib'], sys_path) + self.assertIn(system_paths['platlib'], sys_path) + class StartupImportTests(unittest.TestCase): diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 542d97e3f886e24..bb0cfe7502f2aba 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -55,6 +55,13 @@ VSOCKPORT = 1234 AIX = platform.system() == "AIX" SOLARIS = sys.platform.startswith("sunos") +# NetBSD, OpenBSD and DragonFly deliver the file descriptors from only one +# SCM_RIGHTS control message when several are sent in a single sendmsg(). +BSD_COMBINES_SCM_RIGHTS = sys.platform.startswith( + ("netbsd", "openbsd", "dragonfly")) +# OpenBSD and DragonFly fail recvmsg() with EMSGSIZE, instead of setting +# MSG_CTRUNC, when the ancillary data buffer is too small for a cmsghdr. +CMSG_TRUNC_RAISES_EMSGSIZE = sys.platform.startswith(("openbsd", "dragonfly")) WSL = "microsoft-standard-WSL" in platform.release() try: @@ -1295,7 +1302,8 @@ def testGetServBy(self): # protocol, at least for modern Linuxes. if ( sys.platform.startswith( - ('linux', 'android', 'freebsd', 'netbsd', 'gnukfreebsd')) + ('linux', 'android', 'freebsd', 'dragonfly', 'netbsd', + 'gnukfreebsd')) or is_apple ): # avoid the 'echo' service on this platform, as there is an @@ -1779,6 +1787,23 @@ def testGetaddrinfo(self): except socket.gaierror: pass + @unittest.skipUnless(hasattr(socket, 'AI_NUMERICSERV'), + 'needs socket.AI_NUMERICSERV') + @support.thread_unsafe('setlocale is not thread-safe') + @support.run_with_locales('LC_ALL', + 'uk_UA.KOI8-U', 'uk_UA', 'ja_JP.eucJP', 'ja_JP.SJIS', 'ja_JP', + 'ko_KR.eucKR', 'zh_CN.GB18030', 'el_GR.ISO8859-7', + 'de_DE.ISO8859-1', 'ja_JP.UTF-8', + '') + def test_getaddrinfo_localized_error(self): + # gh-93251: the localized gai_strerror() message could fail to be + # decoded as UTF-8, so UnicodeDecodeError was raised + # instead of gaierror. + with self.assertRaises(socket.gaierror) as cm: + socket.getaddrinfo("localhost", "http", + flags=socket.AI_NUMERICSERV) + str(cm.exception) + @unittest.skipIf(_testcapi is None, "requires _testcapi") def test_getaddrinfo_int_port_overflow(self): # gh-74895: Test that getaddrinfo does not raise OverflowError on port. @@ -1944,6 +1969,25 @@ def test_makefile_mode(self): with sock.makefile(mode, encoding=encoding) as fp: self.assertEqual(fp.mode, mode) + def test_makefile_line_buffering(self): + with socket.socket() as sock: + for mode in 'r', 'w': + with self.subTest(mode=mode): + with sock.makefile(mode, buffering=1, + encoding="utf-8") as fp: + self.assertTrue(fp.line_buffering) + + def test_makefile_line_buffering_binary(self): + # Line buffering is not supported in binary mode, as in open(). + with socket.socket() as sock: + for mode in 'rb', 'wb': + with self.subTest(mode=mode): + with self.assertWarnsRegex( + RuntimeWarning, + "line buffering .* isn't supported in binary " + "mode"): + sock.makefile(mode, buffering=1).close() + def test_makefile_invalid_mode(self): for mode in 'rt', 'x', '+', 'a': with self.subTest(mode=mode): @@ -2060,6 +2104,39 @@ def test_getnameinfo_ipv6_scopeid_numeric(self): nameinfo = socket.getnameinfo(sockaddr, socket.NI_NUMERICHOST | socket.NI_NUMERICSERV) self.assertEqual(nameinfo, ('ff02::1de:c0:face:8d%' + str(ifindex), '1234')) + def test_getaddrinfo_null_bytes(self): + # getaddrinfo() must reject embedded null bytes instead of silently + # truncating the host or port at the C boundary. The checks run + # before any name resolution, so no network access is needed. + hosts = [ + # embedded + 'local\0host', b'local\0host', + # trailing + 'localhost\0', b'localhost\0', + # leading (truncates to '') + '\0localhost', b'\0localhost', + '\0', b'\0', + # non-ASCII, goes through IDNA + 'b\xfccher\0.example', + ] + for host in hosts: + with self.subTest(host=host): + with self.assertRaisesRegex(ValueError, 'host'): + socket.getaddrinfo(host, 80) + + ports = [ + '8\x000', + b'8\x000', + 'http\0', + b'http\0', + '\0', + b'\0' + ] + for port in ports: + with self.subTest(port=port): + with self.assertRaisesRegex(ValueError, 'port'): + socket.getaddrinfo("localhost", port) + def test_str_for_enums(self): # Make sure that the AF_* and SOCK_* constants have enum-like string # reprs. @@ -3151,6 +3228,26 @@ def testFromFd(self): def _testFromFd(self): self.serv_conn.send(MSG) + def testFromFdError(self): + # Make sure that the fromfd() duplicated socket is closed on error. + fd = self.cli_conn.fileno() + # Wait for the client thread to close its socket, otherwise + # fd_count() can race with clientTearDown(). + self.done.wait() + fd_count_before = os_helper.fd_count() + + with self.assertRaises(TypeError): + socket.fromfd(fd, "not-a-valid-family", socket.SOCK_STREAM) + with self.assertRaises(TypeError): + socket.fromfd(fd, socket.AF_INET, "not-a-valid-type") + with self.assertRaises(OverflowError): + socket.fromfd(fd, socket.AF_INET, 1 << 100) + + self.assertEqual(os_helper.fd_count(), fd_count_before) + + def _testFromFdError(self): + pass + def testDup(self): # Testing dup() sock = self.cli_conn.dup() @@ -4178,6 +4275,7 @@ def _testFDPassCMSG_LEN(self): @unittest.skipIf(is_apple, "skipping, see issue #12958") @unittest.skipIf(SOLARIS, "skipping, see gh-91214") @unittest.skipIf(AIX, "skipping, see issue #22397") + @unittest.skipIf(BSD_COMBINES_SCM_RIGHTS, "skipping, see gh-125860") @requireAttrs(socket, "CMSG_SPACE") def testFDPassSeparate(self): # Pass two FDs in two separate arrays. Arrays may be combined @@ -4190,6 +4288,7 @@ def testFDPassSeparate(self): @unittest.skipIf(is_apple, "skipping, see issue #12958") @unittest.skipIf(SOLARIS, "skipping, see gh-91214") @unittest.skipIf(AIX, "skipping, see issue #22397") + @unittest.skipIf(BSD_COMBINES_SCM_RIGHTS, "skipping, see gh-125860") def _testFDPassSeparate(self): fd0, fd1 = self.newFDs(2) self.assertEqual( @@ -4204,6 +4303,7 @@ def _testFDPassSeparate(self): @unittest.skipIf(is_apple, "skipping, see issue #12958") @unittest.skipIf(SOLARIS, "skipping, see gh-91214") @unittest.skipIf(AIX, "skipping, see issue #22397") + @unittest.skipIf(BSD_COMBINES_SCM_RIGHTS, "skipping, see gh-125860") @requireAttrs(socket, "CMSG_SPACE") def testFDPassSeparateMinSpace(self): # Pass two FDs in two separate arrays, receiving them into the @@ -4219,6 +4319,7 @@ def testFDPassSeparateMinSpace(self): @unittest.skipIf(is_apple, "skipping, see issue #12958") @unittest.skipIf(SOLARIS, "skipping, see gh-91214") @unittest.skipIf(AIX, "skipping, see issue #22397") + @unittest.skipIf(BSD_COMBINES_SCM_RIGHTS, "skipping, see gh-125860") def _testFDPassSeparateMinSpace(self): fd0, fd1 = self.newFDs(2) self.assertEqual( @@ -4343,6 +4444,7 @@ def _testCmsgTrunc0(self): # (but still too small) buffer sizes. @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") + @unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240") def testCmsgTrunc1(self): self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), 1)) @@ -4351,6 +4453,7 @@ def _testCmsgTrunc1(self): self.createAndSendFDs(1) @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") + @unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240") def testCmsgTrunc2Int(self): # The cmsghdr structure has at least three members, two of # which are ints, so we still shouldn't see any ancillary @@ -4363,6 +4466,7 @@ def _testCmsgTrunc2Int(self): self.createAndSendFDs(1) @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") + @unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240") def testCmsgTruncLen0Minus1(self): self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), socket.CMSG_LEN(0) - 1)) @@ -4400,6 +4504,7 @@ def checkTruncatedArray(self, ancbuf, maxdata, mindata=0): self.checkFDs(fds) @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") + @unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240") def testCmsgTruncLen0(self): self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0), maxdata=0) @@ -4408,6 +4513,7 @@ def _testCmsgTruncLen0(self): self.createAndSendFDs(1) @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") + @unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240") def testCmsgTruncLen0Plus1(self): self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0) + 1, maxdata=1) @@ -4416,6 +4522,7 @@ def _testCmsgTruncLen0Plus1(self): self.createAndSendFDs(2) @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") + @unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240") def testCmsgTruncLen1(self): self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(SIZEOF_INT), maxdata=SIZEOF_INT) @@ -4426,6 +4533,7 @@ def _testCmsgTruncLen1(self): @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") + @unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240") def testCmsgTruncLen2Minus1(self): self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(2 * SIZEOF_INT) - 1, maxdata=(2 * SIZEOF_INT) - 1) @@ -4698,6 +4806,7 @@ def _testSingleCmsgTrunc0(self): # (but still too small) buffer sizes. @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") + @unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240") def testSingleCmsgTrunc1(self): self.checkHopLimitTruncatedHeader(ancbufsize=1) @@ -4707,6 +4816,7 @@ def _testSingleCmsgTrunc1(self): self.sendToServer(MSG) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") + @unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240") def testSingleCmsgTrunc2Int(self): self.checkHopLimitTruncatedHeader(ancbufsize=2 * SIZEOF_INT) @@ -4716,6 +4826,7 @@ def _testSingleCmsgTrunc2Int(self): self.sendToServer(MSG) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") + @unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240") def testSingleCmsgTruncLen0Minus1(self): self.checkHopLimitTruncatedHeader(ancbufsize=socket.CMSG_LEN(0) - 1) @@ -4725,6 +4836,7 @@ def _testSingleCmsgTruncLen0Minus1(self): self.sendToServer(MSG) @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT") + @unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240") def testSingleCmsgTruncInData(self): # Test truncation of a control message inside its associated # data. The message may be returned with its data truncated, @@ -4797,6 +4909,7 @@ def _testSecondCmsgTrunc0(self): @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") + @unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240") def testSecondCmsgTrunc1(self): self.checkTruncatedSecondHeader(socket.CMSG_SPACE(SIZEOF_INT) + 1) @@ -4807,6 +4920,7 @@ def _testSecondCmsgTrunc1(self): @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") + @unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240") def testSecondCmsgTrunc2Int(self): self.checkTruncatedSecondHeader(socket.CMSG_SPACE(SIZEOF_INT) + 2 * SIZEOF_INT) @@ -4818,6 +4932,7 @@ def _testSecondCmsgTrunc2Int(self): @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") + @unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240") def testSecondCmsgTruncLen0Minus1(self): self.checkTruncatedSecondHeader(socket.CMSG_SPACE(SIZEOF_INT) + socket.CMSG_LEN(0) - 1) @@ -4829,6 +4944,7 @@ def _testSecondCmsgTruncLen0Minus1(self): @requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT", "IPV6_RECVTCLASS", "IPV6_TCLASS") + @unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240") def testSecondCmsgTruncInData(self): # Test truncation of the second of two control messages inside # its associated data. @@ -5717,10 +5833,20 @@ def testReadline(self): # Performing file readline test line = self.read_file.readline() self.assertEqual(line, self.read_msg) + # Readline mode + if self.bufsize == 1 and self.read_mode == "r": + self.assertTrue(self.read_file.line_buffering) def _testReadline(self): self.write_file.write(self.write_msg) - self.write_file.flush() + # Readline mode: no need to flush + if self.bufsize == 1 and self.write_mode == "w": + self.assertTrue(self.write_file.line_buffering) + else: + self.write_file.flush() + # Prevent garbage collection from flushing + # until the server has finished + self.assertTrue(self.serv_finished.wait(5.0)) def testCloseAfterMakefile(self): # The file returned by makefile should keep the socket open. @@ -5878,11 +6004,6 @@ def _testWriteNonBlocking(self): self.serv_skipped = "failed to saturate the socket buffer" -class LineBufferedFileObjectClassTestCase(FileObjectClassTestCase): - - bufsize = 1 # Default-buffered for reading; line-buffered for writing - - class SmallBufferedFileObjectClassTestCase(FileObjectClassTestCase): bufsize = 2 # Exercise the buffering code @@ -5918,6 +6039,16 @@ class UnicodeReadWriteFileObjectClassTestCase(FileObjectClassTestCase): newline = '' +class UnicodeLineBufferedFileObjectClassTestCase(FileObjectClassTestCase): + + bufsize = 1 # Default-buffered for reading; line-buffered for writing + read_mode = 'r' + read_msg = MSG.decode('utf-8') + write_mode = 'w' + write_msg = MSG.decode('utf-8') + newline = '' + + class NetworkConnectionTest(object): """Prove network connection.""" diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py index ca33a9a6dac8d34..4f2ed7140a749b3 100644 --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -516,13 +516,10 @@ class MyServer(socketserver.ThreadingMixIn, socketserver.TCPServer): class TestModule(unittest.TestCase): - def test_deprecated__version__(self): - with self.assertWarnsRegex( - DeprecationWarning, - "'__version__' is deprecated and slated for removal in Python 3.20", - ) as cm: - getattr(socketserver, "__version__") - self.assertEqual(cm.filename, __file__) + def test_deprecated_module_attributes(self): + test.support.check_deprecated_module_attributes( + self, socketserver, "__version__", remove=(3, 20), + ) if __name__ == "__main__": diff --git a/Lib/test/test_source_encoding.py b/Lib/test/test_source_encoding.py index 53fffe7cfb56d09..3c29002025575e1 100644 --- a/Lib/test/test_source_encoding.py +++ b/Lib/test/test_source_encoding.py @@ -3,8 +3,8 @@ import unittest from test import support from test.support import script_helper -from test.support.os_helper import TESTFN, unlink, rmtree -from test.support.import_helper import unload +from test.support.os_helper import TESTFN, TESTFN_ASCII, unlink, rmtree +from test.support.import_helper import import_module, unload import importlib import os import sys @@ -29,6 +29,30 @@ def test_compilestring(self): exec(c, d) self.assertEqual(d['u'], '\xf3') + def test_compilestring_line_endings(self): + for newline in ('\n', '\r', '\r\n', '\r\r\n'): + expected = 'é\n\ntext' if newline == '\r\r\n' else 'é\ntext' + for suffix in ('', newline): + for mode in ('exec', 'eval'): + source = f"'''é{newline}text'''{suffix}" + if mode == 'exec': + source = 'value = ' + source + for encoding in (None, 'utf-8', 'latin-1'): + with self.subTest(newline=newline, suffix=suffix, + mode=mode, encoding=encoding): + input = source + if encoding is not None: + input = (f'# coding: {encoding}{newline}' + + source).encode(encoding) + code = compile(input, '', mode) + if mode == 'exec': + namespace = {} + exec(code, namespace) + value = namespace['value'] + else: + value = eval(code) + self.assertEqual(value, expected) + def test_issue2301(self): try: compile(b"# coding: cp932\nprint '\x94\x4e'", "dummy", "exec") @@ -82,6 +106,69 @@ def test_truncated_utf8_at_eof(self): with self.subTest(seq=seq): self.assertRaises(SyntaxError, compile, seq, '', 'exec') + def test_invalid_utf8_offset_after_non_ascii(self): + for name in ('é', 'éé', '𝒜'): + with self.subTest(name=name): + source = ('x = ' + name).encode() + b'\xff\n' + with self.assertRaises(SyntaxError) as caught: + compile(source, '', 'exec') + error = caught.exception + self.assertEqual( + (error.lineno, error.offset, error.end_lineno, error.end_offset), + (1, 5 + len(name), 1, 5 + len(name)), + ) + + @support.cpython_only + def test_invalid_utf8_file_offset_after_non_ascii(self): + _testcapi = import_module('_testcapi') + self.addCleanup(unlink, TESTFN_ASCII) + with open(TESTFN_ASCII, 'wb') as f: + f.write(b'\nx = \xc3\xa9\xc3\xa9\xff\n') + with self.assertRaises(SyntaxError) as caught: + _testcapi.run_file( + os.fsencode(TESTFN_ASCII), _testcapi.Py_file_input, {}) + error = caught.exception + self.assertEqual( + (error.lineno, error.offset, error.end_lineno, error.end_offset), + (2, 7, 2, 7), + ) + + def test_long_bom_conflict_message_is_not_truncated(self): + encoding = "x" * 400 + source = b"\xef\xbb\xbf# coding:" + encoding.encode() + b"\n" + with self.assertRaises(SyntaxError) as caught: + compile(source, "", "exec") + self.assertEqual( + caught.exception.msg, + f"encoding problem: {encoding} with BOM", + ) + + def _assert_python_file_ok(self, source): + with tempfile.TemporaryDirectory() as directory: + filename = script_helper.make_script(directory, "source", source) + script_helper.assert_python_ok(filename) + + @support.requires_subprocess() + def test_stateful_file_decoder_spans_lines(self): + encoded_name = "変数".encode("iso2022_jp") + payload = encoded_name[3:-3] + source = ( + b"# coding: iso2022_jp\n" + b"# \x1b$B" + payload + b"\n" + + payload + b"\x1b(B = 1\n" + ) + self._assert_python_file_ok(source) + + @support.requires_subprocess() + def test_stateful_file_decoder_preserves_buffered_text(self): + source = b"# coding: hz\nx~\ny = 1\nassert xy == 1\n" + self._assert_python_file_ok(source) + + @support.requires_subprocess() + def test_stateful_file_decoder_finalizes_before_implicit_newline(self): + source = b"# coding: hz\n# ~{1dA?" + self._assert_python_file_ok(source) + @support.requires_subprocess() def test_20731(self): sub = subprocess.Popen([sys.executable, diff --git a/Lib/test/test_sqlite3/test_cli.py b/Lib/test/test_sqlite3/test_cli.py index 1fc0236780fa8ba..2dced0ee1f52753 100644 --- a/Lib/test/test_sqlite3/test_cli.py +++ b/Lib/test/test_sqlite3/test_cli.py @@ -82,6 +82,7 @@ class InteractiveSession(unittest.TestCase): MEMORY_DB_MSG = "Connected to a transient in-memory database" PS1 = "\001\002sqlite> \001\002" PS2 = "\001\002 ... \001\002" + EOF_KEY = "CTRL-Z" if sys.platform == "win32" else "CTRL-D" def run_cli(self, *args, commands=()): with ( @@ -104,11 +105,19 @@ def run_cli(self, *args, commands=()): def test_interact(self): out, err = self.run_cli() self.assertIn(self.MEMORY_DB_MSG, err) - self.assertIn(self.MEMORY_DB_MSG, err) + self.assertIn(f'type ".quit" or {self.EOF_KEY} to quit', err) self.assertEndsWith(out, self.PS1) self.assertEqual(out.count(self.PS1), 1) self.assertEqual(out.count(self.PS2), 0) + def test_interact_help(self): + out, err = self.run_cli(commands=(".help",)) + self.assertIn(self.MEMORY_DB_MSG, err) + self.assertIn(f"Exit the CLI, equivalent to {self.EOF_KEY}", out) + self.assertEndsWith(out, self.PS1) + self.assertEqual(out.count(self.PS1), 2) + self.assertEqual(out.count(self.PS2), 0) + def test_interact_quit(self): out, err = self.run_cli(commands=(".quit",)) self.assertIn(self.MEMORY_DB_MSG, err) @@ -223,6 +232,9 @@ def setUpClass(cls): readline = import_module("readline") if readline.backend == "editline": raise unittest.SkipTest("libedit readline is not supported") + if sys.platform.startswith("openbsd"): + # OpenBSD's readline does not honor "completion-query-items 0". + raise unittest.SkipTest("OpenBSD readline hangs on completion") def write_input(self, input_, env=None): script = textwrap.dedent(""" @@ -323,6 +335,8 @@ def test_complete_columns(self): input_ = textwrap.dedent("""\ CREATE TABLE _table (_col_table); CREATE TEMP TABLE _temp_table (_col_temp); + CREATE VIEW _view AS SELECT _col_table AS _col_table_alias + FROM _table; ATTACH ':memory:' AS attached; CREATE TABLE attached._attached_table (_col_attached); @@ -337,9 +351,9 @@ def test_complete_columns(self): candidates = [l.strip() for l in lines[start+1:end]] self.assertEqual( - candidates, ["_col_attached", "_col_table", "_col_temp"] + candidates, + ["_col_attached", "_col_table", "_col_table_alias", "_col_temp"], ) - @unittest.skipIf(sqlite3.sqlite_version_info < (3, 30, 0), "PRAGMA function_list is not available until " "SQLite 3.30.0") @@ -378,10 +392,10 @@ def test_complete_schemata(self): self.assertIn("main", candidates) self.assertIn("temp", candidates) - @unittest.skipIf(sys.platform.startswith("freebsd"), + @unittest.skipIf(sys.platform.startswith(("freebsd", "dragonfly", "sunos")), "Two actual tabs are inserted when there are no matching" " completions in the pseudo-terminal opened by run_pty()" - " on FreeBSD") + " on this platform") def test_complete_no_match(self): input_ = b"xyzzy\t\t\b\b\b\b\b\b\b.quit\n" # Set NO_COLOR to disable coloring for self.PS1. diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py index 5f6cb527955ca17..bbb7c1f8b615938 100644 --- a/Lib/test/test_sqlite3/test_dbapi.py +++ b/Lib/test/test_sqlite3/test_dbapi.py @@ -31,6 +31,7 @@ import urllib.parse import warnings +from test import support from test.support import ( SHORT_TIMEOUT, check_disallow_instantiation, requires_subprocess ) @@ -88,6 +89,33 @@ def test_programming_error(self): def test_not_supported_error(self): self.assertIsSubclass(sqlite.NotSupportedError, sqlite.DatabaseError) + def _test_sqlite_version(self, v, string): + self.assertIsInstance(v[:], tuple) + self.assertEqual(len(v), 3) + self.assertIsInstance(v[0], int) + self.assertIsInstance(v[1], int) + self.assertIsInstance(v[2], int) + self.assertIsInstance(v.major, int) + self.assertIsInstance(v.minor, int) + self.assertIsInstance(v.patch, int) + self.assertEqual(v[0], v.major) + self.assertEqual(v[1], v.minor) + self.assertEqual(v[2], v.patch) + self.assertGreaterEqual(v.major, 3) + self.assertGreaterEqual(v.minor, 0) + self.assertGreaterEqual(v.patch, 0) + self.assertEqual(string, '%d.%d.%d' % v) + + def test_sqlite_version(self): + if support.verbose: + print(f'SQLITE_VERSION = {sqlite.SQLITE_VERSION}', flush=True) + print(f'sqlite_version = {sqlite.sqlite_version}', flush=True) + print(f'SQLITE_VERSION_INFO = {sqlite.SQLITE_VERSION_INFO}', flush=True) + print(f'sqlite_version_info = {sqlite.sqlite_version_info}', flush=True) + self._test_sqlite_version(sqlite.SQLITE_VERSION_INFO, sqlite.SQLITE_VERSION) + self._test_sqlite_version(sqlite.sqlite_version_info, sqlite.sqlite_version) + self.assertEqual(sqlite.SQLITE_VERSION_INFO[0], sqlite.sqlite_version_info[0]) + def test_module_constants(self): consts = [ "SQLITE_ABORT", @@ -487,6 +515,13 @@ def test_connection_init_good_isolation_levels(self): cx.isolation_level = level self.assertEqual(cx.isolation_level, level) + def test_connection_delete_isolation_level(self): + with memory_database() as cx: + with self.assertRaisesRegex(AttributeError, + "cannot delete attribute"): + del cx.isolation_level + self.assertEqual(cx.isolation_level, "") + def test_connection_reinit(self): with memory_database() as cx: cx.text_factory = bytes @@ -1075,9 +1110,16 @@ def test_invalid_array_size(self): UINT32_MAX = (1 << 32) - 1 setter = functools.partial(setattr, self.cu, 'arraysize') + self.cu.arraysize = 2 self.assertRaises(TypeError, setter, 1.0) self.assertRaises(ValueError, setter, -3) self.assertRaises(OverflowError, setter, UINT32_MAX + 1) + self.assertRaises(OverflowError, setter, 2**1000) + self.assertRaises(ValueError, setter, -2**1000) + self.assertRaisesRegex(AttributeError, 'cannot be deleted', + delattr, self.cu, 'arraysize') + # a failed assignment does not change the value + self.assertEqual(self.cu.arraysize, 2) def test_fetchmany(self): # no active SQL statement @@ -1390,12 +1432,37 @@ def test_blob_get_slice_negative_index(self): def test_blob_get_slice_with_skip(self): self.assertEqual(self.blob[0:10:2], b"ti lb") + def test_blob_get_slice_with_negative_step(self): + # gh-150449: negative-step slices must not crash + self.assertEqual(self.blob[9:0:-2], self.data[9:0:-2]) + self.assertEqual(self.blob[9::-2], self.data[9::-2]) + self.assertEqual(self.blob[::-1], self.data[::-1]) + # When start <= stop with a negative step the slice is empty; this + # must return b"" rather than crashing or raising an exception. + self.assertEqual(self.blob[3:8:-1], self.data[3:8:-1]) # b"" + self.assertEqual(self.blob[5:5:-1], self.data[5:5:-1]) # b"" + # Extreme step values: cur += (size_t)step must not overflow. + self.assertEqual(self.blob[5::sys.maxsize], self.data[5::sys.maxsize]) + self.assertEqual(self.blob[::-sys.maxsize - 1], self.data[::-sys.maxsize - 1]) + def test_blob_set_slice(self): self.blob[0:5] = b"12345" expected = b"12345" + self.data[5:] actual = self.cx.execute("select b from test").fetchone()[0] self.assertEqual(actual, expected) + def test_blob_set_slice_with_step_keeps_bytes_intact(self): + # The buffer used for the read-patch-write cycle must not be the + # bytes object read from the blob: for a single byte it is an + # immortal singleton. + old_byte = self.data[5] + self.blob[5:6:2] = b"\xab" + self.assertEqual(bytes([old_byte])[0], old_byte) + self.assertEqual(self.blob[5:6], b"\xab") + expected = self.data[:5] + b"\xab" + self.data[6:] + actual = self.cx.execute("select b from test").fetchone()[0] + self.assertEqual(actual, expected) + def test_blob_set_empty_slice(self): self.blob[0:0] = b"" self.assertEqual(self.blob[:], self.data) @@ -1418,6 +1485,43 @@ def test_blob_set_slice_with_skip(self): expected = b"1h2s3b4o5 " + self.data[10:] self.assertEqual(actual, expected) + def test_blob_set_slice_with_negative_step(self): + # gh-150449: negative-step slice assignment must not crash + expected = bytearray(self.data) + expected[9:0:-2] = b"12345" + self.blob[9:0:-2] = b"12345" + actual = self.cx.execute("select b from test").fetchone()[0] + self.assertEqual(actual, bytes(expected)) + + # Also verify a slice that includes index 0 + expected2 = bytearray(self.data) + expected2[9::-2] = b"12345" + self.blob[9::-2] = b"12345" + actual2 = self.cx.execute("select b from test").fetchone()[0] + self.assertEqual(actual2, bytes(expected2)) + + # When start <= stop with a negative step the slice is empty; + # assigning b"" to it must be a no-op (blob contents unchanged). + state_before = bytes(self.blob[:]) + self.blob[3:8:-1] = b"" + self.assertEqual(bytes(self.blob[:]), state_before) + + def test_blob_set_slice_with_extreme_positive_step(self): + expected = bytearray(self.data) + expected[5::sys.maxsize] = b"\xab" + self.blob[5::sys.maxsize] = b"\xab" + actual = self.cx.execute("select b from test").fetchone()[0] + self.assertEqual(actual, bytes(expected)) + self.assertEqual(actual[5], 0xab) + + def test_blob_set_slice_with_extreme_negative_step(self): + expected = bytearray(self.data) + expected[::-sys.maxsize - 1] = b"\xcd" + self.blob[::-sys.maxsize - 1] = b"\xcd" + actual = self.cx.execute("select b from test").fetchone()[0] + self.assertEqual(actual, bytes(expected)) + self.assertEqual(actual[-1], 0xcd) + def test_blob_mapping_invalid_index_type(self): msg = "indices must be integers" with self.assertRaisesRegex(TypeError, msg): diff --git a/Lib/test/test_sqlite3/test_factory.py b/Lib/test/test_sqlite3/test_factory.py index b9b18fdee872269..8b92f3f0a419ee9 100644 --- a/Lib/test/test_sqlite3/test_factory.py +++ b/Lib/test/test_sqlite3/test_factory.py @@ -21,6 +21,7 @@ # 3. This notice may not be removed or altered from any source distribution. import unittest +import weakref import sqlite3 as sqlite from collections.abc import Sequence @@ -156,6 +157,25 @@ def test_delete_connection_text_factory(self): with self.assertRaises(AttributeError): del self.con.text_factory + def test_replace_active_row_factory(self): + class Factory: + def row(self, cursor, values): + cursor.row_factory = None + return factory_ref() is not None + + cursor = self.con.cursor() + cursor.row_factory = Factory().row + factory_ref = weakref.ref(cursor.row_factory) + self.assertIs(cursor.execute("select 1").fetchone(), True) + + def test_delete_cursor_row_factory(self): + # gh-149738: deleting row_factory should raise an exception + cur = self.con.cursor() + with self.assertRaises(AttributeError): + del cur.row_factory + # Executing a query here should succeed. + self.assertEqual(tuple(cur.execute("select 1").fetchone()), (1,)) + def test_sqlite_row_index_unicode(self): row = self.con.execute("select 1 as \xff").fetchone() self.assertEqual(row["\xff"], 1) diff --git a/Lib/test/test_sqlite3/test_hooks.py b/Lib/test/test_sqlite3/test_hooks.py index 7e5117771b379f5..a9373df4d70417d 100644 --- a/Lib/test/test_sqlite3/test_hooks.py +++ b/Lib/test/test_sqlite3/test_hooks.py @@ -450,7 +450,7 @@ def test_trace_bad_handler(self): def test_set_trace_callback_keyword_args(self): with self.assertRaisesRegex(TypeError, - 'takes exactly 1 positional argument'): + 'takes no keyword arguments'): self.con.set_trace_callback(trace_callback=lambda: None) # When a handler has an invalid signature, the exception raised is diff --git a/Lib/test/test_sqlite3/test_transactions.py b/Lib/test/test_sqlite3/test_transactions.py index a3de7a7a82ec1cb..2e5d60fe9ba5fc0 100644 --- a/Lib/test/test_sqlite3/test_transactions.py +++ b/Lib/test/test_sqlite3/test_transactions.py @@ -389,10 +389,25 @@ def test_autocommit_setget(self): def test_autocommit_setget_invalid(self): msg = "autocommit must be True, False, or.*LEGACY" - for mode in "a", 12, (), None: + for mode in "a", 12, (), None, 2**1000, -2**1000: with self.subTest(mode=mode): with self.assertRaisesRegex(ValueError, msg): sqlite.connect(":memory:", autocommit=mode) + with memory_database() as cx: + with self.assertRaisesRegex(ValueError, msg): + cx.autocommit = mode + # a failed assignment does not change the value + self.assertEqual(cx.autocommit, + sqlite.LEGACY_TRANSACTION_CONTROL) + + def test_autocommit_delete(self): + with memory_database() as cx: + cx.autocommit = False + with self.assertRaisesRegex(AttributeError, + "cannot delete autocommit attribute"): + del cx.autocommit + # a failed deletion does not change the value + self.assertIs(cx.autocommit, False) def test_autocommit_disabled(self): expected = [ diff --git a/Lib/test/test_sqlite3/test_userfunctions.py b/Lib/test/test_sqlite3/test_userfunctions.py index 11cf877a011c785..fdfc14d49d601ce 100644 --- a/Lib/test/test_sqlite3/test_userfunctions.py +++ b/Lib/test/test_sqlite3/test_userfunctions.py @@ -720,7 +720,7 @@ def test_aggr_text(self): def test_agg_keyword_args(self): with self.assertRaisesRegex(TypeError, - 'takes exactly 3 positional arguments'): + 'takes no keyword arguments'): self.con.create_aggregate("test", 1, aggregate_class=AggrText) @@ -767,7 +767,7 @@ def test_clear_authorizer(self): def test_authorizer_keyword_args(self): with self.assertRaisesRegex(TypeError, - 'takes exactly 1 positional argument'): + 'takes no keyword arguments'): self.con.set_authorizer(authorizer_callback=lambda: None) diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 352a9c2a0c6106f..837445dc06d67b9 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -14,11 +14,14 @@ from test.support import warnings_helper from test.support import asyncore import array +import base64 import re import socket import select import struct +import tempfile import time +import zipfile import enum import gc import http.client @@ -37,6 +40,10 @@ import ctypes except ImportError: ctypes = None +try: + from _hashlib import get_fips_mode +except ImportError: + def get_fips_mode(): return False ssl = import_helper.import_module("ssl") @@ -49,12 +56,15 @@ PROTOCOLS = sorted(ssl._PROTOCOL_NAMES) HOST = socket_helper.HOST IS_AWS_LC = "AWS-LC" in ssl.OPENSSL_VERSION +IS_LIBRESSL = "LibreSSL" in ssl.OPENSSL_VERSION IS_OPENSSL_3_0_0 = ssl.OPENSSL_VERSION_INFO >= (3, 0, 0) CAN_GET_SELECTED_OPENSSL_GROUP = ssl.OPENSSL_VERSION_INFO >= (3, 2) CAN_IGNORE_UNKNOWN_OPENSSL_GROUPS = ssl.OPENSSL_VERSION_INFO >= (3, 3) CAN_GET_AVAILABLE_OPENSSL_GROUPS = ssl.OPENSSL_VERSION_INFO >= (3, 5) CAN_GET_AVAILABLE_OPENSSL_SIGALGS = ssl.OPENSSL_VERSION_INFO >= (3, 4) -CAN_SET_CLIENT_SIGALGS = not IS_AWS_LC +# LibreSSL does not provide SSL_CTX_set1_(client_)sigalgs_list(). +CAN_SET_CLIENT_SIGALGS = not IS_AWS_LC and not IS_LIBRESSL +CAN_SET_SERVER_SIGALGS = not IS_LIBRESSL CAN_IGNORE_UNKNOWN_OPENSSL_SIGALGS = ssl.OPENSSL_VERSION_INFO >= (3, 3) CAN_GET_SELECTED_OPENSSL_SIGALG = ssl.OPENSSL_VERSION_INFO >= (3, 5) PY_SSL_DEFAULT_CIPHERS = sysconfig.get_config_var('PY_SSL_DEFAULT_CIPHERS') @@ -127,6 +137,19 @@ def data_file(*name): LEAF_MISSING_AKI_CERTFILE_HOSTNAME = "example.com" LEAF_MISSING_AKI_CA = data_file("leaf-missing-aki.ca.pem") +# gh-160040: a leaf signed by a compromised eMudhra intermediate whose public +# key is on the _ssl distrusted list. The chain to distrusted_root.pem is +# otherwise valid. +# The PEMs live in a password-protected zip so the compromised eMudhra certs +# don't trip security scanners that cannot tell internal test fixtures from +# production secrets and flag any certificate or private key they find. It is +# encrypted, not merely zipped, because such scanners read inside plain archives. +# The password is fixed, public, and not a secret; it only keeps the archive +# from storing the PEMs in the clear. +DISTRUSTED_SPKI_ZIP = data_file("distrusted.zip") +DISTRUSTED_SPKI_CHOSEN_KNIGHT = b"Brave Sir Robin" # not a secret, see comment +DISTRUSTED_SPKI_HOSTNAME = "localhost" + # Same certificate as pycacert.pem, but without extra text in file SIGNING_CA = data_file("capath", "ceff1710.0") # cert with all kinds of subject alt names @@ -396,6 +419,34 @@ def do_ssl_object_handshake(sslobject, outgoing, max_retry=25): return data +def connected_bio_pair(client_context, server_context, hostname, max_retry=5): + """Handshake a client and a server SSLObject against each other. + + Everything happens in memory, so this needs no socket and no thread. + Returns the two objects followed by their four BIOs, in the order + client, server, c_in, c_out, s_in, s_out. + """ + c_in, c_out = ssl.MemoryBIO(), ssl.MemoryBIO() + s_in, s_out = ssl.MemoryBIO(), ssl.MemoryBIO() + client = client_context.wrap_bio(c_in, c_out, server_hostname=hostname) + server = server_context.wrap_bio(s_in, s_out, server_side=True) + + # Loop on the handshake for a bit to get it settled + for _ in range(max_retry): + with contextlib.suppress(ssl.SSLWantReadError): + client.do_handshake() + if c_out.pending: + s_in.write(c_out.read()) + with contextlib.suppress(ssl.SSLWantReadError): + server.do_handshake() + if s_out.pending: + c_in.write(s_out.read()) + # Now the handshakes should be complete (don't raise WantReadError) + client.do_handshake() + server.do_handshake() + return client, server, c_in, c_out, s_in, s_out + + class BasicSocketTests(unittest.TestCase): def test_constants(self): @@ -410,6 +461,7 @@ def test_constants(self): self.assertEqual(ssl.HAS_ECDH, True) self.assertIsInstance(ssl.HAS_TLSv1_2, bool) self.assertEqual(ssl.HAS_TLSv1_3, True) + self.assertIsInstance(ssl.HAS_ECH, bool) ssl.OP_NO_SSLv2 ssl.OP_NO_SSLv3 ssl.OP_NO_TLSv1 @@ -466,6 +518,8 @@ def test_random(self): if v: data = ssl.RAND_bytes(16) self.assertEqual(len(data), 16) + + self.assertEqual(ssl.RAND_bytes(0), b'') else: self.assertRaises(ssl.SSLError, ssl.RAND_bytes, 16) @@ -540,7 +594,7 @@ def test_parse_cert_CVE_2013_4238(self): (('emailAddress', 'python-dev@python.org'),)) self.assertEqual(p['subject'], subject) self.assertEqual(p['issuer'], subject) - if ssl._OPENSSL_API_VERSION >= (0, 9, 8): + if ssl.OPENSSL_API_VERSION_INFO >= (0, 9, 8): san = (('DNS', 'altnull.python.org\x00example.com'), ('email', 'null@python.org\x00user@example.org'), ('URI', 'http://null.python.org\x00http://example.org'), @@ -596,6 +650,14 @@ def test_openssl_version(self): self.assertIsInstance(n, int) self.assertIsInstance(t, tuple) self.assertIsInstance(s, str) + self.assertEqual(len(t), 5) + self.assertEqual(t, (t.major, t.minor, t.fix, t.patch, t.status)) + a = ssl.OPENSSL_API_VERSION_INFO + self.assertIsInstance(a, tuple) + self.assertEqual(len(a), 5) + self.assertEqual(a, (a.major, a.minor, a.fix, a.patch, a.status)) + self.assertIs(ssl._OPENSSL_API_VERSION, a) + self.assertEqual(a.major, t.major) # Some sanity checks follow # >= 1.1.1 self.assertGreaterEqual(n, 0x10101000) @@ -1080,6 +1142,8 @@ def test_set_client_sigalgs(self): if CAN_IGNORE_UNKNOWN_OPENSSL_SIGALGS: self.assertIsNone(ctx.set_client_sigalgs('rsa_pss_rsae_sha256:?foo')) + @unittest.skipUnless(CAN_SET_SERVER_SIGALGS, + "SSL library doesn't support setting server sigalgs") def test_set_server_sigalgs(self): ctx = ssl.create_default_context() @@ -1092,6 +1156,16 @@ def test_set_server_sigalgs(self): if CAN_IGNORE_UNKNOWN_OPENSSL_SIGALGS: self.assertIsNone(ctx.set_server_sigalgs('rsa_pss_rsae_sha256:?foo')) + @unittest.skipUnless(CAN_GET_SELECTED_OPENSSL_GROUP, + "SSL library doesn't support getting selected group") + def test_no_session_group_does_not_crash(self): + # Ensure that .group() does not crash because of OpenSSL itself. + # See https://github.com/python/cpython/issues/155782. + ctx = ssl.create_default_context() + ctx.check_hostname = False + obj = ctx.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO()) + self.assertIsNone(obj.group()) + def test_options(self): # Test default SSLContext options ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) @@ -1812,6 +1886,62 @@ def test__create_stdlib_context(self): self.assertEqual(ctx.verify_mode, ssl.CERT_NONE) self._assert_context_options(ctx) + def test__create_stdlib_context_check_hostname(self): + # gh-114905: check_hostname cannot be combined with CERT_NONE, + # the default for cert_reqs. + msg = "Cannot set verify_mode to CERT_NONE when check_hostname" + with self.assertRaisesRegex(ValueError, msg): + ssl._create_stdlib_context(check_hostname=True) + with self.assertRaisesRegex(ValueError, msg): + ssl._create_stdlib_context(cert_reqs=ssl.CERT_NONE, + check_hostname=True) + + # Accepted before 3.10 with a legacy protocol. + if has_tls_protocol('PROTOCOL_TLSv1_2'): + with warnings_helper.check_warnings(): + with self.assertRaisesRegex(ValueError, msg): + ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1_2, + cert_reqs=ssl.CERT_NONE, + check_hostname=True) + + # cert_reqs=None leaves PROTOCOL_TLS_CLIENT's CERT_REQUIRED. + ctx = ssl._create_stdlib_context(cert_reqs=None, check_hostname=True) + self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED) + self.assertTrue(ctx.check_hostname) + + # CERT_REQUIRED is covered by test__create_stdlib_context(). + ctx = ssl._create_stdlib_context(cert_reqs=ssl.CERT_OPTIONAL, + check_hostname=True) + self.assertEqual(ctx.verify_mode, ssl.CERT_OPTIONAL) + self.assertTrue(ctx.check_hostname) + + def test_delete_sslobject_attributes(self): + # None of the attributes of _ssl._SSLSocket can be deleted. + ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) + ctx.check_hostname = False + sslobj = ctx.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO())._sslobj + for name in 'context', 'owner', 'session', 'session_reused': + with self.subTest(name=name): + value = getattr(sslobj, name) + with self.assertRaises(AttributeError): + delattr(sslobj, name) + self.assertEqual(getattr(sslobj, name), value) + + def test_delete_attributes(self): + # None of the attributes implemented in C can be deleted. + ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) + names = ['check_hostname', 'verify_mode', 'verify_flags', 'options', + 'minimum_version', 'maximum_version', 'sni_callback', + '_host_flags', 'security_level', 'post_handshake_auth'] + if hasattr(ctx, 'num_tickets'): + names.append('num_tickets') + for name in names: + with self.subTest(name=name): + value = getattr(ctx, name) + with self.assertRaises(AttributeError): + delattr(ctx, name) + self.assertEqual(getattr(ctx, name), value) + def test_check_hostname(self): with warnings_helper.check_warnings(): ctx = ssl.SSLContext(ssl.PROTOCOL_TLS) @@ -1934,6 +2064,497 @@ def psk_server_callback(*args, _=ctx, **kwargs): ... ctx.set_psk_server_callback(psk_server_callback) +class ECHTests(unittest.TestCase): + requires_ech_x25519 = unittest.skipUnless( + ssl.HAS_ECH + and 'x25519' in ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT).get_groups(), + 'requires ECH with X25519', + ) + + # An ECHConfigList for localhost using X25519, HKDF-SHA256 and AES-128-GCM. + ECH_CONFIG = bytes.fromhex( + '003c fe0d 0038 db 0020 0020' + '696c2bdc8e1cfa03453ed9bf8c3adee2e676835c8746af33c10994b8e603405c' + '0004 0001 0001 00 09 6c6f63616c686f7374 0000' + ) + + def make_ssl_objects(self, context): + obj = context.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(), + server_hostname='localhost') + sock, peer = socket.socketpair() + self.addCleanup(sock.close) + self.addCleanup(peer.close) + ssock = context.wrap_socket(sock, server_hostname='localhost', + do_handshake_on_connect=False) + self.addCleanup(ssock.close) + return obj, ssock + + def test_availability(self): + self.assertEqual(hasattr(ssl, 'ECHStatus'), ssl.HAS_ECH) + for module in (ssl, _ssl): + names = [name for name in dir(module) + if name.startswith(('ECH_STATUS_', 'OP_ECH_'))] + with self.subTest(module=module): + self.assertEqual(bool(names), ssl.HAS_ECH) + + self.assertTrue(issubclass(ssl.SSLECHRejectedError, ssl.SSLError)) + context_methods = ('set_ech_config', 'load_ech_keys', + '_set_outer_alpn_protocols') + socket_methods = ('set_ech_config', 'get_ech_status', + 'get_ech_retry_config') + for owner, names in ( + (_ssl._SSLContext, context_methods), + (ssl.SSLContext, (*context_methods, 'set_outer_alpn_protocols')), + (_ssl._SSLSocket, socket_methods), + (ssl.SSLObject, (*socket_methods, 'outer_server_hostname')), + (ssl.SSLSocket, (*socket_methods, 'outer_server_hostname')), + ): + for name in names: + with self.subTest(owner=owner, name=name): + self.assertEqual(hasattr(owner, name), ssl.HAS_ECH) + + @unittest.skipUnless(ssl.HAS_ECH, 'requires ECH') + def test_socket_without_ssl_object(self): + ctx = make_test_context() + with ctx.wrap_socket(socket.socket()) as sock: + self.assertIsNone(sock.outer_server_hostname) + self.assertIsNone(sock.get_ech_status()) + self.assertIsNone(sock.get_ech_retry_config()) + self.assertIsNone(sock.outer_server_hostname) + self.assertIsNone(sock.get_ech_status()) + self.assertIsNone(sock.get_ech_retry_config()) + + @requires_ech_x25519 + def test_set_ech_config(self): + ctx = make_test_context() + for config in (self.ECH_CONFIG, bytearray(self.ECH_CONFIG), + memoryview(self.ECH_CONFIG)): + with self.subTest(type=type(config)): + self.assertIsNone(ctx.set_ech_config(config)) + config = bytearray(self.ECH_CONFIG) + ctx.set_ech_config(config) + config.clear() # The input buffer must have been released. + for config in (None, 'config', 42): + with self.subTest(config=config): + self.assertRaises(TypeError, ctx.set_ech_config, config) + for config in (b'', b'\x00', b'\x00\x00', b'invalid', + self.ECH_CONFIG[:-1], self.ECH_CONFIG + b'\x00'): + with self.subTest(config=config): + self.assertRaises(ssl.SSLError, ctx.set_ech_config, config) + self.assertIsNone(ctx.set_ech_config(self.ECH_CONFIG)) + + @requires_ech_x25519 + def test_set_ech_config_base64(self): + ctx = make_test_context() + self.assertIsNone(ctx.set_ech_config(base64.b64encode(self.ECH_CONFIG))) + + @requires_ech_x25519 + def test_context_roles(self): + client_ctx, server_ctx, _ = testing_context() + with self.assertRaisesRegex(ssl.SSLError, 'PROTOCOL_TLS_SERVER'): + server_ctx.set_ech_config(self.ECH_CONFIG) + with self.assertRaisesRegex(ssl.SSLError, 'PROTOCOL_TLS_CLIENT'): + client_ctx.load_ech_keys(data_file('ech.pem')) + with warnings_helper.check_warnings(): + ctx = ssl.SSLContext(ssl.PROTOCOL_TLS) + self.assertIsNone(ctx.set_ech_config(self.ECH_CONFIG)) + self.assertIsNone(ctx.load_ech_keys(data_file('ech.pem'))) + + @requires_ech_x25519 + def test_mixed_ech_config_versions(self): + ctx = make_test_context() + supported = self.ECH_CONFIG[2:] + unsupported = b'\xff\xff\x00\x01\x00' + # OpenSSL's binary format detection requires a known version first. + entries = unsupported + supported + config = len(entries).to_bytes(2, 'big') + entries + self.assertRaises(ssl.SSLError, ctx.set_ech_config, config) + entries = supported + unsupported + config = len(entries).to_bytes(2, 'big') + entries + self.assertIsNone(ctx.set_ech_config(config)) + + @requires_ech_x25519 + def test_mixed_ech_config_unsupported_suites(self): + ctx = make_test_context() + supported = self.ECH_CONFIG[2:] + for algorithm, offset in (('KEM', 5), ('KDF', 43), ('AEAD', 45)): + unsupported = bytearray(supported) + unsupported[offset:offset + 2] = b'\xff\xff' + with self.subTest(algorithm=algorithm): + config = len(unsupported).to_bytes(2, 'big') + unsupported + self.assertRaises(ssl.SSLError, ctx.set_ech_config, config) + # OpenSSL currently rejects the whole list even if another + # entry has a supported suite. That should probably be fixed + # upstream, since it disagrees with the RFC. + for entries in (unsupported + supported, + supported + unsupported): + with self.subTest(entries=entries): + config = len(entries).to_bytes(2, 'big') + entries + self.assertRaises(ssl.SSLError, ctx.set_ech_config, + config) + + def read_ech_key_and_config(self, filename='ech.pem'): + # Generated with: + # openssl ech -public_name public.example -suite 0x20,1,1 + # ech-localhost.pem uses -public_name localhost, so that the test + # certificate also authenticates the outer ClientHello. + with open(data_file(filename), 'rb') as f: + key, config = f.read().split(b'-----BEGIN ECHCONFIG-----') + config = base64.b64decode(config.split(b'-----END ECHCONFIG-----')[0]) + return key, config + + def stale_config(self, config): + # A config whose HPKE public key the server does not have. + stale = bytearray(config) + stale[11] ^= 1 + return bytes(stale) + + def handshake_bio_pair(self, client, server, c_in, c_out, s_in, s_out): + for _ in range(5): + with contextlib.suppress(ssl.SSLWantReadError): + client.do_handshake() + s_in.write(c_out.read()) + with contextlib.suppress(ssl.SSLWantReadError): + server.do_handshake() + c_in.write(s_out.read()) + + def echo_server_thread(self, server_ctx, sock): + def serve(): + try: + with server_ctx.wrap_socket(sock, server_side=True) as ssock: + ssock.sendall(ssock.recv(1024)) + except OSError: + pass + finally: + sock.close() + thread = threading.Thread(target=serve) + thread.start() + self.addCleanup(thread.join) + + @requires_ech_x25519 + def test_connection_ech_config(self): + key, config = self.read_ech_key_and_config('ech-localhost.pem') + client_ctx, server_ctx, hostname = testing_context() + server_ctx.load_ech_keys(data_file('ech-localhost.pem')) + # The context has a configuration the server cannot decrypt; the + # connection's configuration must replace it. + client_ctx.set_ech_config(self.stale_config(config)) + for ctx_config in (False, True): + with self.subTest(context_configured=ctx_config): + if not ctx_config: + client_ctx, _, hostname = testing_context() + c_in, c_out = ssl.MemoryBIO(), ssl.MemoryBIO() + s_in, s_out = ssl.MemoryBIO(), ssl.MemoryBIO() + client = client_ctx.wrap_bio(c_in, c_out, server_hostname=hostname, + ech_config=config) + server = server_ctx.wrap_bio(s_in, s_out, server_side=True) + self.handshake_bio_pair(client, server, c_in, c_out, s_in, s_out) + for obj in (client, server): + self.assertEqual(obj.get_ech_status(), + ssl.ECHStatus.ECH_STATUS_SUCCESS) + with self.assertRaisesRegex(ValueError, 'after handshake'): + client.set_ech_config(config) + + with self.assertRaisesRegex(ValueError, 'client mode'): + server_ctx.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(), + server_side=True, ech_config=config) + with socket.socket() as sock: + with self.assertRaisesRegex(ValueError, 'client mode'): + server_ctx.wrap_socket(sock, server_side=True, + ech_config=config) + obj = client_ctx.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(), + server_hostname=hostname) + self.assertRaises(TypeError, obj.set_ech_config, 'config') + self.assertRaises(ssl.SSLError, obj.set_ech_config, b'invalid') + self.assertIsNone(obj.set_ech_config(bytearray(config))) + + # An unconnected socket applies the configuration when connecting. + with client_ctx.wrap_socket(socket.socket(), server_hostname=hostname, + ech_config=config) as sock: + self.assertIs(sock._ech_config, config) + sock.set_ech_config(bytearray(config)) + self.assertEqual(sock._ech_config, config) + + @requires_ech_x25519 + def test_rejected_ech_retry_config(self): + key, config = self.read_ech_key_and_config('ech-localhost.pem') + stale = self.stale_config(config) + client_ctx, server_ctx, hostname = testing_context() + server_ctx.load_ech_keys(data_file('ech-localhost.pem')) + + c_in, c_out = ssl.MemoryBIO(), ssl.MemoryBIO() + s_in, s_out = ssl.MemoryBIO(), ssl.MemoryBIO() + client = client_ctx.wrap_bio(c_in, c_out, server_hostname=hostname, + ech_config=stale) + server = server_ctx.wrap_bio(s_in, s_out, server_side=True) + with self.assertRaises(ssl.SSLECHRejectedError) as cm: + self.handshake_bio_pair(client, server, c_in, c_out, s_in, s_out) + self.assertEqual(cm.exception.reason, 'ECH_REQUIRED') + self.assertEqual(cm.exception.retry_config, config) + self.assertEqual(client.get_ech_status(), + ssl.ECHStatus.ECH_STATUS_FAILED_ECH) + self.assertEqual(client.get_ech_retry_config(), config) + + # The retry configuration from the exception must be usable for a + # new connection, even though wrap_socket() closed the first one. + sock, peer = socket.socketpair() + sock.settimeout(support.SHORT_TIMEOUT) + self.echo_server_thread(server_ctx, peer) + with self.assertRaises(ssl.SSLECHRejectedError) as cm: + client_ctx.wrap_socket(sock, server_hostname=hostname, + ech_config=stale) + self.assertEqual(cm.exception.retry_config, config) + sock, peer = socket.socketpair() + sock.settimeout(support.SHORT_TIMEOUT) + self.echo_server_thread(server_ctx, peer) + with client_ctx.wrap_socket(sock, server_hostname=hostname, + ech_config=cm.exception.retry_config) as ssock: + self.assertEqual(ssock.get_ech_status(), + ssl.ECHStatus.ECH_STATUS_SUCCESS) + ssock.sendall(b'hello') + self.assertEqual(ssock.recv(1024), b'hello') + + @requires_ech_x25519 + def test_outer_alpn_with_connection_ech_config(self): + key, config = self.read_ech_key_and_config('ech-localhost.pem') + client_ctx, server_ctx, hostname = testing_context() + server_ctx.load_ech_keys(data_file('ech-localhost.pem')) + client_ctx.set_alpn_protocols(['h2']) + client_ctx.set_outer_alpn_protocols(['http/1.1']) + server_ctx.set_alpn_protocols(['h2', 'http/1.1']) + for current, expected in ((config, 'h2'), + (self.stale_config(config), 'http/1.1')): + with self.subTest(expected=expected): + c_in, c_out = ssl.MemoryBIO(), ssl.MemoryBIO() + s_in, s_out = ssl.MemoryBIO(), ssl.MemoryBIO() + client = client_ctx.wrap_bio(c_in, c_out, server_hostname=hostname, + ech_config=current) + server = server_ctx.wrap_bio(s_in, s_out, server_side=True) + # When the server rejects ECH it only ever saw the outer + # ClientHello, so it selects from the outer ALPN. OpenSSL 4.0 + # incorrectly checks that choice against the inner list, + # raising BAD_EXTENSION instead of SSLECHRejectedError. + # https://github.com/python/cpython/pull/160318#discussion_r4362699854 + with contextlib.suppress(ssl.SSLError): + self.handshake_bio_pair(client, server, + c_in, c_out, s_in, s_out) + self.assertEqual(server.selected_alpn_protocol(), expected) + + @requires_ech_x25519 + def test_load_ech_keys(self): + client_ctx, ctx, hostname = testing_context() + filename = data_file('ech.pem') + for path in (filename, os.fsencode(filename), + os_helper.FakePath(filename)): + self.assertIsNone(ctx.load_ech_keys(path)) + self.assertRaises(TypeError, ctx.load_ech_keys, None) + self.assertRaises(ValueError, ctx.load_ech_keys, 'key\x00file') + with self.assertRaises(OSError) as cm: + ctx.load_ech_keys(NONEXISTINGKEY) + self.assertEqual(cm.exception.errno, errno.ENOENT) + self.assertEqual(cm.exception.filename, NONEXISTINGKEY) + + key, config = self.read_ech_key_and_config() + public = (b'-----BEGIN ECHCONFIG-----\n' + base64.b64encode(config) + + b'\n-----END ECHCONFIG-----\n') + mismatched = bytearray(config) + mismatched[11] ^= 1 # Change one bit of the HPKE public key. + mismatched = (key + b'-----BEGIN ECHCONFIG-----\n' + + base64.b64encode(mismatched) + + b'\n-----END ECHCONFIG-----\n') + with open(ONLYKEY_PROTECTED, 'rb') as f: + encrypted = f.read() + public + self.addCleanup(os_helper.unlink, os_helper.TESTFN) + for pem in (b'invalid', public, mismatched, encrypted): + with self.subTest(pem=pem): + with open(os_helper.TESTFN, 'wb') as f: + f.write(pem) + self.assertRaises(ssl.SSLError, ctx.load_ech_keys, + os_helper.TESTFN) + # Failed loads must leave the previously loaded keys usable. + client_ctx.minimum_version = ssl.TLSVersion.TLSv1_3 + client_ctx.set_ech_config(config) + client, server, *_ = connected_bio_pair(client_ctx, ctx, hostname) + self.assertEqual(client.get_ech_status(), + ssl.ECHStatus.ECH_STATUS_SUCCESS) + + @requires_ech_x25519 + def test_load_ech_keys_password(self): + ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) + # ech.pem's key encrypted with: + # openssl pkey -in ech.pem -aes-256-cbc -passout pass:somepass + filename = data_file('ech-encrypted.pem') + for password in (KEY_PASSWORD, lambda: KEY_PASSWORD): + self.assertIsNone(ctx.load_ech_keys(filename, password=password)) + + def password_error(): + raise ValueError('password callback failed') + + with self.assertRaisesRegex(ValueError, 'password callback failed'): + ctx.load_ech_keys(filename, password=password_error) + self.assertIsNone(ctx.load_ech_keys(data_file('ech.pem'), + password=password_error)) + + @requires_ech_x25519 + def test_ech_handshake(self): + key, config = self.read_ech_key_and_config() + other_config = bytearray(config) + other_config[6] ^= 1 # A different config_id using the same key. + self.addCleanup(os_helper.unlink, os_helper.TESTFN) + with open(os_helper.TESTFN, 'wb') as f: + f.write(key + b'-----BEGIN ECHCONFIG-----\n' + + base64.b64encode(other_config) + + b'\n-----END ECHCONFIG-----\n') + client_ctx, server_ctx, hostname = testing_context() + client_ctx.minimum_version = ssl.TLSVersion.TLSv1_3 + server_ctx.load_ech_keys(data_file('ech.pem'), for_retry=False) + server_ctx.load_ech_keys(os_helper.TESTFN) + # Both the old and newly appended configurations must work. + for current_config in (config, other_config): + with self.subTest(config_id=current_config[6]): + client_ctx.set_ech_config(current_config) + seen_names = [] + + def sni_callback(obj, name, ctx): + seen_names.append(name) + + server_ctx.sni_callback = sni_callback + client, server, c_in, c_out, s_in, s_out = connected_bio_pair( + client_ctx, server_ctx, hostname) + for obj in (client, server): + self.assertEqual(obj.get_ech_status(), + ssl.ECHStatus.ECH_STATUS_SUCCESS) + self.assertEqual(obj.outer_server_hostname, + 'public.example') + self.assertEqual(seen_names, [hostname]) + client.write(b'hello') + s_in.write(c_out.read()) + self.assertEqual(server.read(), b'hello') + server.write(b'world') + c_in.write(s_out.read()) + self.assertEqual(client.read(), b'world') + client_ctx, _, hostname = testing_context() + client_ctx.options |= ssl.OP_ECH_GREASE + client, server, *_ = connected_bio_pair(client_ctx, server_ctx, hostname) + self.assertEqual(client.get_ech_retry_config(), bytes(other_config)) + + @requires_ech_x25519 + def test_status_before_handshake(self): + ctx = make_test_context() + for configured in (False, True): + if configured: + ctx.set_ech_config(self.ECH_CONFIG) + expected = ssl.ECHStatus.ECH_STATUS_NOT_TRIED + else: + expected = ssl.ECHStatus.ECH_STATUS_NOT_CONFIGURED + for obj in self.make_ssl_objects(ctx): + with self.subTest(configured=configured, type=type(obj)): + status = obj.get_ech_status() + self.assertIsInstance(status, ssl.ECHStatus) + self.assertEqual(status, expected) + self.assertEqual(obj._sslobj.get_ech_status(), + (expected, None, None)) + self.assertIsNone(obj.outer_server_hostname) + self.assertEqual(obj.get_ech_retry_config(), b'') + + @unittest.skipUnless(ssl.HAS_ECH, 'requires ECH') + def test_set_outer_alpn_protocols(self): + ctx = make_test_context() + for protocols in (['h2'], ['h2', 'http/1.1'], []): + with self.subTest(protocols=protocols): + self.assertIsNone(ctx.set_outer_alpn_protocols(protocols)) + for protocols in ([''], ['a' * 256]): + self.assertRaises(ssl.SSLError, + ctx.set_outer_alpn_protocols, protocols) + self.assertRaises(UnicodeEncodeError, + ctx.set_outer_alpn_protocols, ['non-ascii-\u00e9']) + self.assertRaises(TypeError, ctx.set_outer_alpn_protocols, [42]) + + @unittest.skipUnless(ssl.HAS_ECH, 'requires ECH') + def test_outer_alpn_does_not_replace_inner(self): + client_ctx, server_ctx, hostname = testing_context() + for ctx in (client_ctx, server_ctx): + ctx.set_alpn_protocols(['h2']) + ctx.set_outer_alpn_protocols(['http/1.1']) + client_ctx.set_outer_alpn_protocols([]) + client, server, *_ = connected_bio_pair(client_ctx, server_ctx, hostname) + self.assertEqual(client.selected_alpn_protocol(), 'h2') + self.assertEqual(server.selected_alpn_protocol(), 'h2') + + @unittest.skipUnless(ssl.HAS_ECH, 'requires ECH') + # At 2026-11-13 (OpenSSL 4.0.3 on Fedora 45), the test is incompatible + # with FIPS mode: https://github.com/openssl/openssl/issues/33724 + @unittest.skipIf(get_fips_mode(), 'gh-161932: test incompatible with FIPS') + def test_outer_alpn_without_ech_config(self): + for options in (0, ssl.OP_ECH_GREASE): + client_ctx, server_ctx, hostname = testing_context() + client_ctx.options |= options + client_ctx.set_alpn_protocols(['h2']) + client_ctx.set_outer_alpn_protocols(['http/1.1']) + server_ctx.set_alpn_protocols(['h2', 'http/1.1']) + client, server, *_ = connected_bio_pair( + client_ctx, server_ctx, hostname) + self.assertEqual(client.selected_alpn_protocol(), 'h2') + self.assertEqual(server.selected_alpn_protocol(), 'h2') + + @unittest.skipUnless(ssl.HAS_ECH, 'requires ECH') + # At 2026-11-13 (OpenSSL 4.0.3 on Fedora 45), the test is incompatible + # with FIPS mode: https://github.com/openssl/openssl/issues/33724 + @unittest.skipIf(get_fips_mode(), 'gh-161932: test incompatible with FIPS') + def test_grease(self): + client_ctx, server_ctx, hostname = testing_context() + client_ctx.options |= ssl.OP_ECH_GREASE + client, server, *_ = connected_bio_pair(client_ctx, server_ctx, hostname) + self.assertEqual(client.get_ech_status(), + ssl.ECHStatus.ECH_STATUS_GREASE) + self.assertIsNone(client.outer_server_hostname) + self.assertEqual(client.get_ech_retry_config(), b'') + self.assertEqual(server.get_ech_status(), + ssl.ECHStatus.ECH_STATUS_NOT_CONFIGURED) + + def make_rejected_client(self): + client_ctx, server_ctx, hostname = testing_context() + client_ctx.set_ech_config(self.ECH_CONFIG) + c_in, c_out = ssl.MemoryBIO(), ssl.MemoryBIO() + s_in, s_out = ssl.MemoryBIO(), ssl.MemoryBIO() + client = client_ctx.wrap_bio(c_in, c_out, server_hostname=hostname) + server = server_ctx.wrap_bio(s_in, s_out, server_side=True) + with self.assertRaisesRegex(ssl.SSLECHRejectedError, + 'ECH_REQUIRED') as cm: + self.handshake_bio_pair(client, server, c_in, c_out, s_in, s_out) + # A server without ECH sends no retry configuration. + self.assertEqual(cm.exception.retry_config, b'') + return client + + @requires_ech_x25519 + def test_rejected_ech(self): + client = self.make_rejected_client() + self.assertEqual(client.get_ech_status(), ssl.ECHStatus.ECH_STATUS_FAILED) + self.assertEqual(client._sslobj.get_ech_status(), + (ssl.ECHStatus.ECH_STATUS_FAILED, + 'localhost', 'localhost')) + self.assertEqual(client.outer_server_hostname, 'localhost') + self.assertEqual(client.get_ech_retry_config(), b'') + + @requires_ech_x25519 + @support.nomemtest + def test_status_allocation_failure(self): + import _testcapi + + client = self.make_rejected_client() + get_status = client._sslobj.get_ech_status + failures = 0 + for fail_at in range(10): + try: + _testcapi.call_with_nomemory(fail_at, fail_at + 1, get_status) + except MemoryError: + failures += 1 + self.assertEqual(get_status(), + (ssl.ECHStatus.ECH_STATUS_FAILED, + 'localhost', 'localhost')) + self.assertGreaterEqual(failures, 2) + + class SSLErrorTests(unittest.TestCase): def test_str(self): @@ -1983,6 +2604,10 @@ def test_subclass(self): def test_bad_server_hostname(self): ctx = ssl.create_default_context() + # Omitting the name entirely is bad too: this context checks it. + with self.assertRaises(ValueError): + ctx.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(), + server_hostname=None) with self.assertRaises(ValueError): ctx.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(), server_hostname="") @@ -2067,6 +2692,64 @@ def test_private_init(self): with self.assertRaisesRegex(TypeError, "public constructor"): ssl.SSLObject(bio, bio) + def test_check_hostname_requires_server_hostname(self): + # wrap_bio() used to accept a context asking for hostname checking + # without a name to check against, and then verify the certificate + # chain but never the peer's identity, with check_hostname still + # reporting True and nothing reporting the check had been skipped. + # It must refuse that call, as wrap_socket() already did. + client_context, _, hostname = testing_context() + self.assertTrue(client_context.check_hostname) + + for server_hostname in (None, ""): + with self.subTest(server_hostname=server_hostname): + with self.assertRaisesRegex( + ValueError, + "check_hostname requires server_hostname"): + client_context.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(), + server_hostname=server_hostname) + # The sibling constructor refuses the very same call. + with socket.socket() as sock: + with self.assertRaisesRegex( + ValueError, + "check_hostname requires server_hostname"): + client_context.wrap_socket( + sock, server_hostname=server_hostname) + + # A name was all that was missing. + client_context.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(), + server_hostname=hostname) + + # Asking for no hostname check remains a way to say so explicitly. + context = make_test_context() + self.assertFalse(context.check_hostname) + context.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO()) + + def test_server_side_bad_params(self): + # A server neither sends a hostname nor resumes a client's session, + # so wrap_bio() rejects both in server mode like wrap_socket() + client_context, server_context, hostname = testing_context() + + with self.assertRaisesRegex( + ValueError, + "server_hostname can only be specified in client mode"): + server_context.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(), + server_side=True, + server_hostname=hostname) + + client, server, *_ = connected_bio_pair( + client_context, server_context, hostname) + session = client.session + self.assertIsNotNone(session) + with self.assertRaisesRegex( + ValueError, "session can only be specified in client mode"): + server_context.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(), + server_side=True, session=session) + + # Neither argument is what a server passes, so this still works. + server_context.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(), + server_side=True) + def test_unwrap(self): client_ctx, server_ctx, hostname = testing_context() c_in = ssl.MemoryBIO() @@ -2109,6 +2792,108 @@ def test_unwrap(self): c_in.write(s_out.read()) client.unwrap() + def test_distrusted_spki(self): + # gh-160040: the server chain is otherwise valid, but the eMudhra + # intermediate's public key is on the _ssl distrusted list, so + # verification rejects it. + client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) + server_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) + # the contexts load the PEMs now, so the files are only needed here + with tempfile.TemporaryDirectory() as tmpdir: + with zipfile.ZipFile(DISTRUSTED_SPKI_ZIP) as z: + z.extractall(tmpdir, pwd=DISTRUSTED_SPKI_CHOSEN_KNIGHT) + certdir = os.path.join(tmpdir, "distrusted") + client_context.load_verify_locations( + os.path.join(certdir, "distrusted_root.pem")) + server_context.load_cert_chain( + os.path.join(certdir, "distrusted_keycert.pem")) + + with self.assertRaises(ssl.SSLCertVerificationError) as cm: + connected_bio_pair(client_context, server_context, + DISTRUSTED_SPKI_HOSTNAME) + # X509_V_ERR_CERT_REJECTED + self.assertEqual(cm.exception.verify_code, 28) + + def test_sni_callback_context_released_and_callback_raises(self): + # Variant of the test below without a HelloRetryRequest: the callback + # switches the connection to another context, drops the last + # references to the context that carries it, and raises. The C + # callback must not touch that context after the Python callback + # returned. + client_ctx, server_ctx, hostname = testing_context() + leaf_ctx = server_ctx + + def sni_cb(sslobj, server_name, ctx): + sslobj.context = leaf_ctx + del ctx + raise LookupError("no certificate for " + repr(server_name)) + + def make_server(): + dispatch_ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) + dispatch_ctx.load_cert_chain(SIGNED_CERTFILE) + dispatch_ctx.sni_callback = sni_cb + s_in, s_out = ssl.MemoryBIO(), ssl.MemoryBIO() + server = dispatch_ctx.wrap_bio(s_in, s_out, server_side=True) + return server, s_in, s_out + + server, s_in, s_out = make_server() + c_in, c_out = ssl.MemoryBIO(), ssl.MemoryBIO() + client = client_ctx.wrap_bio(c_in, c_out, server_hostname=hostname) + with self.assertRaises(ssl.SSLWantReadError): + client.do_handshake() + s_in.write(c_out.read()) + with support.catch_unraisable_exception() as cm: + with self.assertRaises(ssl.SSLError): + server.do_handshake() + self.assertIsInstance(cm.unraisable.exc_value, LookupError) + self.assertIs(server.context, leaf_ctx) + + def test_sni_callback_context_released_before_second_client_hello(self): + # The SSLContext carrying sni_callback may be released by the + # application once the callback has switched the connection over to + # another context. If the server then sends a HelloRetryRequest, the + # second ClientHello makes OpenSSL consult the original SSL_CTX's + # servername callback again; that must not use the deallocated + # SSLContext object. + client_ctx, leaf_ctx, hostname = testing_context() + calls = [] + + def make_server(): + dispatch_ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) + dispatch_ctx.load_cert_chain(SIGNED_CERTFILE) + # Force a HelloRetryRequest: the client offers an X25519 key + # share first, the server only accepts P-384. + dispatch_ctx.set_ecdh_curve("secp384r1") + def sni_cb(sslobj, server_name, ctx): + calls.append(server_name) + sslobj.context = leaf_ctx + dispatch_ctx.sni_callback = sni_cb + s_in, s_out = ssl.MemoryBIO(), ssl.MemoryBIO() + server = dispatch_ctx.wrap_bio(s_in, s_out, server_side=True) + return server, s_in, s_out, weakref.ref(dispatch_ctx) + + # After this only the C-level SSL object references dispatch_ctx. + server, s_in, s_out, dispatch_ref = make_server() + c_in, c_out = ssl.MemoryBIO(), ssl.MemoryBIO() + client = client_ctx.wrap_bio(c_in, c_out, server_hostname=hostname) + for _ in range(10): + for obj, out, peer_in in ((client, c_out, s_in), + (server, s_out, c_in)): + try: + obj.do_handshake() + except ssl.SSLWantReadError: + pass + if out.pending: + peer_in.write(out.read()) + client.do_handshake() + server.do_handshake() + support.gc_collect() + self.assertIsNone(dispatch_ref()) + self.assertGreaterEqual(len(calls), 1) + self.assertEqual(calls[0], hostname) + self.assertIs(server.context, leaf_ctx) + self.assertIsNotNone(client.cipher()) + class SimpleBackgroundTests(unittest.TestCase): """Tests that connect to a simple server running in the background""" @@ -2337,6 +3122,10 @@ def test_get_server_certificate_fail(self): # independent test method _test_get_server_certificate_fail(self, *self.server_addr) + def test_get_server_certificate_fail_by_hostname(self): + _, port = self.server_addr + _test_get_server_certificate_fail(self, socket_helper.HOSTv4, port, SIGNING_CA) + def test_get_server_certificate_timeout(self): def servername_cb(ssl_sock, server_name, initial_context): time.sleep(0.2) @@ -2589,10 +3378,10 @@ def _test_get_server_certificate(test, host, port, cert=None): if support.verbose: sys.stdout.write("\nVerified certificate for %s:%s is\n%s\n" % (host, port ,pem)) -def _test_get_server_certificate_fail(test, host, port): +def _test_get_server_certificate_fail(test, host, port, ca_certs=CERTFILE): with warnings_helper.check_no_resource_warning(test): try: - pem = ssl.get_server_certificate((host, port), ca_certs=CERTFILE) + pem = ssl.get_server_certificate((host, port), ca_certs=ca_certs) except ssl.SSLError as x: #should fail if support.verbose: @@ -2766,11 +3555,19 @@ def run(self): cert = self.sslconn.getpeercert() self.write(repr(cert).encode("us-ascii") + b"\n") elif stripped == b'VERIFIEDCHAIN': - certs = self.sslconn._sslobj.get_verified_chain() - self.write(len(certs).to_bytes(1, "big") + b"\n") + try: + certs = self.sslconn.get_verified_chain() + except Exception as e: + self.write(repr(e).encode("us-ascii") + b"\n") + else: + self.write(len(certs).to_bytes(1, "big") + b"\n") elif stripped == b'UNVERIFIEDCHAIN': - certs = self.sslconn._sslobj.get_unverified_chain() - self.write(len(certs).to_bytes(1, "big") + b"\n") + try: + certs = self.sslconn.get_unverified_chain() + except Exception as e: + self.write(repr(e).encode("us-ascii") + b"\n") + else: + self.write(len(certs).to_bytes(1, "big") + b"\n") else: if (support.verbose and self.server.connectionchatty): @@ -3430,8 +4227,6 @@ def test_ecc_cert(self): s.connect((HOST, server.port)) cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") - cipher = s.cipher()[0].split('-') - self.assertTrue(cipher[:2], ('ECDHE', 'ECDSA')) @unittest.skipUnless(IS_OPENSSL_3_0_0, "test requires RFC 5280 check added in OpenSSL 3.0+") @@ -3489,7 +4284,7 @@ def test_dual_rsa_ecc(self): cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") cipher = s.cipher()[0].split('-') - self.assertTrue(cipher[:2], ('ECDHE', 'ECDSA')) + self.assertEqual(cipher[:2], ['ECDHE', 'ECDSA']) def test_check_hostname_idn(self, warnings_filters=True): if support.verbose: @@ -3784,6 +4579,8 @@ def test_protocol_tlsv1_1(self): try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_TLSv1_1, False) @requires_tls_version('TLSv1_2') + @unittest.skipUnless(hasattr(ssl, 'PROTOCOL_TLSv1_2'), + 'needs ssl.PROTOCOL_TLSv1_2') def test_protocol_tlsv1_2(self): """Connecting to a TLSv1.2 server with various client options. Testing against older TLS versions.""" @@ -4593,6 +5390,8 @@ def test_client_sigalgs_mismatch(self): chatty=True, connectionchatty=True, sni_name=hostname) + @unittest.skipUnless(CAN_SET_SERVER_SIGALGS, + "SSL library doesn't support setting server sigalgs") def test_server_sigalgs(self): # server rsa_pss_rsae_sha384, client auto sigalg = "rsa_pss_rsae_sha384" @@ -4613,6 +5412,8 @@ def test_server_sigalgs(self): if CAN_GET_SELECTED_OPENSSL_SIGALG: self.assertEqual(stats['server_sigalg'], sigalg) + @unittest.skipUnless(CAN_SET_SERVER_SIGALGS, + "SSL library doesn't support setting server sigalgs") def test_server_sigalgs_mismatch(self): client_context, server_context, hostname = testing_context() client_context.set_server_sigalgs("rsa_pss_rsae_sha256") @@ -4953,7 +5754,6 @@ def test_psk(self): client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) client_context.check_hostname = False - client_context.verify_mode = ssl.CERT_NONE client_context.maximum_version = ssl.TLSVersion.TLSv1_2 client_context.set_ciphers('PSK') client_context.set_psk_client_callback(lambda hint: (None, psk)) @@ -5033,7 +5833,6 @@ def server_callback(identity): client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) client_context.check_hostname = False - client_context.verify_mode = ssl.CERT_NONE client_context.minimum_version = ssl.TLSVersion.TLSv1_3 client_context.set_ciphers('PSK') client_context.set_psk_client_callback(client_callback) @@ -5047,6 +5846,7 @@ def server_callback(identity): with server: with client_context.wrap_socket(socket.socket()) as s: s.connect((HOST, server.port)) + self.assertTrue(s.session_reused) @support.skip_if_sanitizer("gh-150191: OpenSSL races on SSL->rwstate and " "the socket BIO flags with concurrent read " @@ -5446,6 +6246,66 @@ def test_internal_chain_server(self): res = s.recv(1024) self.assertEqual(res, b'\x02\n') + def test_internal_chain_server_resumed_session(self): + # A session resumed from a ticket stores the client's certificate + # but not the chain it was sent with. + for version in ssl.TLSVersion.TLSv1_2, ssl.TLSVersion.TLSv1_3: + if not has_tls_version(version): + continue + with self.subTest(version=version.name): + self.check_chain_server_resumed_session(version) + + def check_chain_server_resumed_session(self, version): + client_context, server_context, hostname = testing_context() + client_context.load_cert_chain(SIGNED_CERTFILE) + server_context.verify_mode = ssl.CERT_REQUIRED + client_context.minimum_version = version + client_context.maximum_version = version + + server = ThreadedEchoServer(context=server_context, chatty=False) + with server: + with client_context.wrap_socket( + socket.socket(), + server_hostname=hostname + ) as s: + s.connect((HOST, server.port)) + s.write(b'UNVERIFIEDCHAIN\n') + res = s.recv(1024) + self.assertEqual(res, b'\x02\n') + # TLS 1.3 sends the ticket after the handshake, so only + # get the session once data was received. + session = s.session + self.assertTrue(session.has_ticket) + with client_context.wrap_socket( + socket.socket(), + server_hostname=hostname, + session=session + ) as s: + s.connect((HOST, server.port)) + self.assertTrue(s.session_reused) + s.write(b'UNVERIFIEDCHAIN\n') + res = s.recv(1024) + self.assertEqual(res, b'\x01\n') + # The verified chain is not stored with the session at all. + s.write(b'VERIFIEDCHAIN\n') + res = s.recv(1024) + self.assertEqual(res, b'\x00\n') + + def test_internal_chain_server_no_client_cert(self): + client_context, server_context, hostname = testing_context() + server_context.verify_mode = ssl.CERT_OPTIONAL + + server = ThreadedEchoServer(context=server_context, chatty=False) + with server: + with client_context.wrap_socket( + socket.socket(), + server_hostname=hostname + ) as s: + s.connect((HOST, server.port)) + s.write(b'UNVERIFIEDCHAIN\n') + res = s.recv(1024) + self.assertEqual(res, b'\x00\n') + class TestSSLDebug(unittest.TestCase): @@ -5480,6 +6340,12 @@ def test_keylog_defaults(self): with self.assertRaises(TypeError): ctx.keylog_filename = 1 + ctx.keylog_filename = os_helper.TESTFN + with self.assertRaisesRegex(AttributeError, 'cannot be deleted'): + del ctx.keylog_filename + # a failed deletion does not change the value + self.assertEqual(ctx.keylog_filename, os_helper.TESTFN) + def test_keylog_filename(self): self.addCleanup(os_helper.unlink, os_helper.TESTFN) client_context, server_context, hostname = testing_context() @@ -5554,6 +6420,18 @@ def msg_cb(conn, direction, version, content_type, msg_type, data): with self.assertRaises(TypeError): client_context._msg_callback = object() + # the attribute of the underlying C type accepts only a callable + # and cannot be deleted + descr = _ssl._SSLContext.__dict__['_msg_callback'] + with self.assertRaises(TypeError): + descr.__set__(client_context, object()) + # a failed assignment does not change the value + self.assertIs(client_context._msg_callback, msg_cb) + with self.assertRaisesRegex(AttributeError, 'cannot be deleted'): + descr.__delete__(client_context) + # a failed deletion does not change the value + self.assertIs(client_context._msg_callback, msg_cb) + def test_msg_callback_exception(self): client_context, server_context, hostname = testing_context() @@ -5654,7 +6532,11 @@ def __exit__(self, *args): self.listener.close() except OSError: pass - self.join() + timeout = support.SHORT_TIMEOUT + self.join(timeout=timeout) + if self.is_alive(): + raise AssertionError("failed to join the server thread " + f"in {timeout} seconds") self.wrap_error = None # avoid dangling references def start(self): @@ -5860,28 +6742,30 @@ def call_after_accept(conn_to_client): call_after_accept=call_after_accept, name="non_tls_http_RST_responder", timeout=timeout) - self.enterContext(server) # starts it & unittest.TestCase stops it. - # Redundant; call_after_accept sets SO_LINGER on the accepted conn. - set_socket_so_linger_on_with_zero_timeout(server.listener) - - connection = SynchronizedHTTPSConnection( - server.listener.getsockname()[0], - port=server.port, - context=ssl.create_default_context(), - timeout=timeout, - ) - # There are lots of reasons this raises as desired, long before this - # test was added. Sending the request requires a successful TLS wrapped - # socket; that fails if the connection is broken. It may seem pointless - # to test this. It serves as an illustration of something that we never - # want to happen... properly not happening. - with warnings_helper.check_no_resource_warning(self), \ - self.assertRaises(OSError): - connection.request("HEAD", "/test", headers={"Host": "localhost"}) - response = connection.getresponse() + with server: + # Redundant; call_after_accept sets SO_LINGER on the accepted conn. + set_socket_so_linger_on_with_zero_timeout(server.listener) + + connection = SynchronizedHTTPSConnection( + server.listener.getsockname()[0], + port=server.port, + context=ssl.create_default_context(), + timeout=timeout, + ) - server.join() + # There are lots of reasons this raises as desired, long before this + # test was added. Sending the request requires a successful TLS wrapped + # socket; that fails if the connection is broken. It may seem pointless + # to test this. It serves as an illustration of something that we never + # want to happen... properly not happening. + with warnings_helper.check_no_resource_warning(self), \ + self.assertRaises(OSError): + try: + connection.request("HEAD", "/test", headers={"Host": "localhost"}) + response = connection.getresponse() + finally: + connection.close() class TestEnumerations(unittest.TestCase): diff --git a/Lib/test/test_stable_abi_ctypes.py b/Lib/test/test_stable_abi_ctypes.py index 09ee2d53f98f585..f9125f395de0b4b 100644 --- a/Lib/test/test_stable_abi_ctypes.py +++ b/Lib/test/test_stable_abi_ctypes.py @@ -802,6 +802,19 @@ def test_windows_feature_macros(self): "PyUnicodeTranslateError_SetEnd", "PyUnicodeTranslateError_SetReason", "PyUnicodeTranslateError_SetStart", + "PyUnicodeWriter_Create", + "PyUnicodeWriter_DecodeUTF8Stateful", + "PyUnicodeWriter_Discard", + "PyUnicodeWriter_Finish", + "PyUnicodeWriter_Format", + "PyUnicodeWriter_WriteASCII", + "PyUnicodeWriter_WriteChar", + "PyUnicodeWriter_WriteRepr", + "PyUnicodeWriter_WriteStr", + "PyUnicodeWriter_WriteSubstring", + "PyUnicodeWriter_WriteUCS4", + "PyUnicodeWriter_WriteUTF8", + "PyUnicodeWriter_WriteWideChar", "PyUnicode_Append", "PyUnicode_AppendAndDel", "PyUnicode_AsASCIIString", @@ -929,6 +942,7 @@ def test_windows_feature_macros(self): "Py_GetRecursionLimit", "Py_GetVersion", "Py_HasFileSystemDefaultEncoding", + "Py_HashBuffer", "Py_IS_TYPE", "Py_IncRef", "Py_Initialize", diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py index 700c5ac304f7179..266d92828fe154a 100644 --- a/Lib/test/test_statistics.py +++ b/Lib/test/test_statistics.py @@ -2790,6 +2790,66 @@ def test_sqrtprod_helper_function_fundamentals(self): self.assertEqual(actual, expected) self.assertEqual(sign(actual), sign(expected)) + @requires_IEEE_754 + def test_sqrtprod_helper_function_subnormal_products(self): + # gh-161259: accuracy was lost when the product or the correction + # term was subnormal. The reference scales the inputs by an exact + # power of two so that the product is a normal float. + scale = 2.0 ** 600 + for x, y in [ + (2e-200, 2e-124), + (1e-160, 3e-150), + (3e-170, 7e-140), + (1e-160, 1e-135), + ]: + expected = math.sqrt((scale * x) * (scale * y)) / scale + actual = statistics._sqrtprod(x, y) + with self.subTest(x=x, y=y, expected=expected, actual=actual): + self.assertAlmostEqual(actual / expected, 1.0, delta=2**-50) + + @requires_IEEE_754 + def test_sqrtprod_helper_function_subnormal_boundary(self): + # sqrt(3 * 7) * 2**e straddles the 2**-485 cutoff where the + # correction term can become subnormal. + scale = 2.0 ** 600 + for e in (-488, -487): + x = 3.0 * 2.0 ** e + y = 7.0 * 2.0 ** e + expected = math.sqrt((scale * x) * (scale * y)) / scale + actual = statistics._sqrtprod(x, y) + with self.subTest(e=e, expected=expected, actual=actual): + self.assertAlmostEqual(actual / expected, 1.0, delta=2**-50) + + cutoff = 2.0 ** -485 + self.assertEqual(statistics._sqrtprod(cutoff, cutoff), cutoff) + + @requires_IEEE_754 + def test_correlation_tiny_inputs(self): + # gh-161259: correlation() is scale-invariant, even when the + # intermediate sums of squares are tiny. + x = [1e-100, 2e-100, 3e-100] + y = [1e-62, 2e-62, 3e-62] + self.assertAlmostEqual(statistics.correlation(x, y), 1.0) + + @requires_IEEE_754 + def test_correlation_asymmetric_scales(self): + for a, b in [ + (2.0 ** 50, 2.0 ** -537), + (1.3 * 2.0 ** -260, 2.7 * 2.0 ** -270), + ]: + x = [-a, 0.0, a] + y = [0.0, -b, b] + with self.subTest(a=a, b=b): + self.assertAlmostEqual(statistics.correlation(x, y), 0.5, + delta=2**-50) + + @requires_IEEE_754 + def test_correlation_tiny_products_max_recursion(self): + # Make both sums of squares round to the smallest subnormal. + a = 2.0 ** -537 + x = [0.0, 0.0, 0.0, a] + self.assertEqual(statistics.correlation(x, x), 1.0) + @requires_IEEE_754 @skip_if_double_rounding @support.cpython_only # Allow for a weaker sumprod() implementation diff --git a/Lib/test/test_str.py b/Lib/test/test_str.py index 979bfe36fff680d..5e553094cac107f 100644 --- a/Lib/test/test_str.py +++ b/Lib/test/test_str.py @@ -267,6 +267,30 @@ class MyStr(str): pass self.checkequal(3, MyStr('aaa'), 'count', 'a') + def test_find_adaptive_widths(self): + # The adaptive path in Objects/stringlib/fastsearch.h needs a haystack + # of at least 2500 characters and a needle of at least a third of it, + # and it is compiled once per character width. Exercise all four. + cases = [ + ('ascii', 'a', 'b', 'c'), + ('latin1', '\xe9', '\xea', '\xeb'), + ('ucs2', '\u0100', '\u0101', '\u0102'), + ('ucs4', '\U0001d11e', '\U0001d11f', '\U0001d120'), + ] + for kind, c, d, x in cases: + # A needle of 2000 characters, none of which is x. + needle = c * 1000 + d * 1000 + with self.subTest(kind=kind): + # 4000 characters, mostly x: the skip branches jump by m. + haystack = c * 1000 + x * 3000 + self.assertEqual(haystack.find(needle), -1) + self.assertEqual(haystack.count(needle), 0) + # A match at 3000 in a haystack of 5000, so count() reaches + # the match branch inside adaptive_find rather than two-way. + haystack = c * 1000 + x * 2000 + needle + self.assertEqual(haystack.find(needle), 3000) + self.assertEqual(haystack.count(needle), 1) + def test_find(self): string_tests.StringLikeTest.test_find(self) # test implementation details of the memchr fast path @@ -566,6 +590,18 @@ def __str__(self): return self.sval self.checkequalnofix('a b c d', ' ', 'join', ['a', 'b', 'c', 'd']) self.checkequalnofix('abcd', '', 'join', ('a', 'b', 'c', 'd')) self.checkequalnofix('w x y z', ' ', 'join', string_tests.Sequence('wxyz')) + # mixed kinds of the separator and the items + self.checkequalnofix('a\xe9b', '\xe9', 'join', ['a', 'b']) + self.checkequalnofix('a\u20acb', '\u20ac', 'join', ['a', 'b']) + self.checkequalnofix('a\xe9', '', 'join', ['a', '\xe9']) + self.checkequalnofix('\u20ac\xe9', '', 'join', ['\u20ac', '\xe9']) + self.checkequalnofix('\xe9-\u20ac-\U0001f600', '-', 'join', + ['\xe9', '\u20ac', '\U0001f600']) + self.checkequalnofix('\U0001f600-a', '-', 'join', ['\U0001f600', 'a']) + # a single item which is a str subclass is copied + class S(str): pass + for s in 'a', '\xe9', '\u20ac', '\U0001f600': + self.checkequalnofix(s, '-', 'join', [S(s)]) self.checkraises(TypeError, ' ', 'join', ['1', '2', MyWrapper('foo')]) self.checkraises(TypeError, ' ', 'join', ['1', '2', '3', bytes()]) self.checkraises(TypeError, ' ', 'join', [1, 2, 3]) @@ -613,14 +649,9 @@ def test_replace_oom(self): s1 = "轘" * 4 s2 = "&" s3 = "&" - assertion = self.assertRaises(MemoryError) - _testcapi.set_nomemory(0, 0) - try: - # No allocations made in the test itself: - with assertion: + with self.assertRaises(MemoryError): + with support.inject_memory_error_cm(): s1.replace(s2, s3) # this line used to crash before - finally: - _testcapi.remove_mem_hooks() def test_repeat_id_preserving(self): a = '123abc1@' @@ -2610,7 +2641,7 @@ def test_compare(self): self.assertFalse(copy1 != copy2) self.assertTrue(copy1 <= copy2) - self.assertTrue(copy2 >= copy2) + self.assertTrue(copy1 >= copy2) self.assertTrue(ascii < ascii2) self.assertTrue(ascii < latin) diff --git a/Lib/test/test_string_literals.py b/Lib/test/test_string_literals.py index 1800b17e1df3d72..bfdb368a6aa532e 100644 --- a/Lib/test/test_string_literals.py +++ b/Lib/test/test_string_literals.py @@ -54,6 +54,10 @@ assert ord(h) == 0x1d120 i = r'\U0001d120' assert list(map(ord, i)) == [92, 85, 48, 48, 48, 49, 100, 49, 50, 48] +j = 'ä' +assert list(map(ord, j)) == [228] +k = '\ä' +assert list(map(ord, k)) == [92, 228] """ @@ -76,7 +80,7 @@ def test_template(self): # Check that the template doesn't contain any non-printables # except for \n. for c in TEMPLATE: - assert c == '\n' or ' ' <= c <= '~', repr(c) + assert c == '\n' or ' ' <= c <= '~' or c == 'ä', repr(c) def test_eval_str_normal(self): self.assertEqual(eval(""" 'x' """), 'x') @@ -88,6 +92,21 @@ def test_eval_str_normal(self): self.assertEqual(eval(""" '\u1881' """), chr(0x1881)) self.assertEqual(eval(r""" '\U0001d120' """), chr(0x1d120)) self.assertEqual(eval(""" '\U0001d120' """), chr(0x1d120)) + # Lone "\" character at the end + self.assertEqual(eval(r"'abc\\'"), 'abc\\') + + def test_eval_str_unicode(self): + for s in ( + 'ϼўТλФЙ', + 'A͏B ﬖ̳AA̝', + '\U00100000\U0010ffff\U0010fffd', + 'ä', + '\\ä', + "\\П", + "áàäéèęöő.\\n", + ): + with self.subTest(s=s): + self.assertEqual(eval(f"{s!r}"), s) def test_eval_str_incomplete(self): self.assertRaises(SyntaxError, eval, r""" '\x' """) diff --git a/Lib/test/test_stringprep.py b/Lib/test/test_stringprep.py index d4b4a13d0de2645..a4ddc8b33e2570b 100644 --- a/Lib/test/test_stringprep.py +++ b/Lib/test/test_stringprep.py @@ -13,11 +13,11 @@ def test(self): self.assertTrue(in_table_b1("\u00ad")) self.assertFalse(in_table_b1("\u00ae")) - self.assertTrue(map_table_b2("\u0041"), "\u0061") - self.assertTrue(map_table_b2("\u0061"), "\u0061") + self.assertEqual(map_table_b2("\u0041"), "\u0061") + self.assertEqual(map_table_b2("\u0061"), "\u0061") - self.assertTrue(map_table_b3("\u0041"), "\u0061") - self.assertTrue(map_table_b3("\u0061"), "\u0061") + self.assertEqual(map_table_b3("\u0041"), "\u0061") + self.assertEqual(map_table_b3("\u0061"), "\u0061") self.assertTrue(in_table_c11("\u0020")) self.assertFalse(in_table_c11("\u0021")) diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index e95cc6db170e243..d70837ea63f5474 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -236,7 +236,8 @@ def test_ValueError(self): directive = bad_format[1:].rstrip() with (self.subTest(format=bad_format), self.assertRaisesRegex(ValueError, - f"'{re.escape(directive)}' is a bad directive in format ")): + f"{re.escape(repr(directive))} is a bad directive " + f"in format ")): _strptime._strptime_time("2005", bad_format) msg_week_no_year_or_weekday = r"ISO week directive '%V' must be used with " \ @@ -303,6 +304,11 @@ def test_unconverteddata(self): # Check ValueError is raised when there is unconverted data self.assertRaises(ValueError, _strptime._strptime_time, "10 12", "%m") + # gh-141540: a trailing newline must be visible in the message + with self.assertRaisesRegex(ValueError, + r"unconverted data remains: '\\n'"): + _strptime._strptime_time("2001-02-03\n", "%Y-%m-%d") + def roundtrip(self, fmt, position, time_tuple=None): """Helper fxn in testing.""" if time_tuple is None: @@ -451,7 +457,8 @@ def test_bad_offset(self): with self.assertRaises(ValueError) as err: _strptime._strptime("-01:3030", "%z") - self.assertEqual("Inconsistent use of : in -01:3030", str(err.exception)) + self.assertEqual("Inconsistent use of : in '-01:3030'", + str(err.exception)) with self.assertRaises(ValueError) as err: _strptime._strptime("-01:3030", "%:z") self.assertEqual("Missing colon in %:z before '30', got '-01:3030'", diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index 3809f2d26438955..d0773490ac807b4 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -424,6 +424,20 @@ def test_705836(self): self.assertRaises(OverflowError, struct.pack, "Zf", ":2: EncodingWarning: ") @@ -2449,6 +2465,16 @@ def test_CalledProcessError_str(self): err = subprocess.CalledProcessError(-9876543, "fake cmd") self.assertEqual(str(err), "Command 'fake cmd' died with unknown signal 9876543.") + # returncode which is not an integer, which happens for example when + # Popen is mocked: str() must not fail + for returncode in (None, "2", 2.5, [2]): + with self.subTest(returncode=returncode): + err = subprocess.CalledProcessError(returncode, "fake cmd") + self.assertEqual( + str(err), + f"Command 'fake cmd' returned non-zero " + f"exit status {returncode}.") + def test_preexec(self): # DISCLAIMER: Setting environment variables is *not* a good use # of a preexec_fn. This is merely a test. @@ -3564,6 +3590,74 @@ def test_communicate_BrokenPipeError_stdin_close_with_timeout(self): proc.communicate(timeout=999) mock_proc_stdin.close.assert_called_once_with() + def _spuriously_writable_selector(self): + # A selector that reports stdin as writable whenever it is + # registered. poll() on macOS and FreeBSD can do this for a full + # pipe when many pipes are in use system-wide (gh-162016). + class AlwaysWritableSelector(subprocess._PopenSelector): + spurious_events = 0 + + def select(self, timeout=None): + ready = super().select(0) + writable = {key.fd for key, events in ready + if events & selectors.EVENT_WRITE} + for key in self.get_map().values(): + if (key.events & selectors.EVENT_WRITE + and key.fd not in writable): + ready.append((key, selectors.EVENT_WRITE)) + type(self).spurious_events += 1 + return ready or super().select(timeout) + + return AlwaysWritableSelector + + def test_communicate_timeout_stdin_spuriously_writable(self): + # The child never reads stdin, so the pipe fills up. communicate() + # must neither block in write() past its timeout nor spin on a pipe + # that keeps being reported as writable. + selector = self._spuriously_writable_selector() + sleep = support.SHORT_TIMEOUT + with mock.patch.object(subprocess, '_PopenSelector', selector), \ + subprocess.Popen([sys.executable, '-c', + f'import time; time.sleep({sleep})'], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE) as proc: + try: + start = time.monotonic() + with self.assertRaises(subprocess.TimeoutExpired): + proc.communicate(b'x' * support.PIPE_MAX_SIZE, + timeout=0.5) + self.assertLess(time.monotonic() - start, sleep) + # communicate() must wait between attempts to write to a + # full pipe. Retrying in a busy loop would produce many + # thousands of these events within the timeout. + self.assertLess(selector.spurious_events, 100) + self.assertTrue(os.get_blocking(proc.stdin.fileno())) + finally: + proc.kill() + + def test_communicate_stdin_spuriously_writable_last_pipe(self): + # All input must still arrive when stdin is full, is reported as + # writable, and is the only pipe communicate() has left to service. + selector = self._spuriously_writable_selector() + data = bytes(range(256)) * (support.PIPE_MAX_SIZE // 256) + code = textwrap.dedent(f""" + import os, sys, time + os.close(1) + time.sleep(0.1) # Let the parent fill the stdin pipe. + data = bytes(range(256)) * {len(data) // 256} + sys.exit(sys.stdin.buffer.read() != data) + """) + with mock.patch.object(subprocess, '_PopenSelector', selector), \ + subprocess.Popen([sys.executable, '-c', code], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE) as proc: + try: + proc.communicate(data, timeout=support.SHORT_TIMEOUT) + self.assertEqual(proc.returncode, 0) + self.assertGreater(selector.spurious_events, 0) + finally: + proc.kill() + @unittest.skipUnless(_testcapi is not None and hasattr(_testcapi, 'W_STOPCODE'), 'need _testcapi.W_STOPCODE') @@ -3707,6 +3801,34 @@ def test_vfork_used_when_expected(self): @unittest.skipUnless(mswindows, "Windows specific tests") class Win32ProcessTestCase(BaseTestCase): + def test_createprocess_bad_cwd_includes_filename(self): + # gh-119646: invalid cwd should appear on OSError.filename. + missing_cwd = r'C:\some\nonexistent\directory' + with self.assertRaises(OSError) as c: + subprocess.Popen([sys.executable, '-c', 'pass'], cwd=missing_cwd) + self.assertEqual(c.exception.filename, missing_cwd) + self.assertEqual(c.exception.winerror, 267) + + def test_command_string_filename_omits_later_args(self): + # gh-119646: a command-line string must not put later arguments + # on OSError.filename. Those arguments can hold secrets. + missing = r'C:\opt\nonexistent_binary' + secret = 'NOT-A-REAL-SECRET' + quoted = r'C:\Program Files\nonexistent_binary' + cases = [ + (missing, missing), + (f'{missing} --token {secret}', missing), + (f'"{missing}" --token {secret}', missing), + (f'"{quoted}" --token {secret}', quoted), + ] + for command, expected in cases: + with self.subTest(command=command): + with self.assertRaises(FileNotFoundError) as c: + subprocess.call(command) + self.assertEqual(c.exception.filename, expected) + self.assertNotIn(secret, c.exception.filename or '') + self.assertNotIn(secret, str(c.exception)) + def test_startupinfo(self): # startupinfo argument # We uses hardcoded constants, because we do not want to @@ -3767,6 +3889,34 @@ def test_startupinfo_copy(self): self.assertEqual(startupinfo.wShowWindow, subprocess.SW_HIDE) self.assertEqual(startupinfo.lpAttributeList, {"handle_list": []}) + def test_startupinfo_shell_show_window(self): + # gh-85028: shell=True must not override wShowWindow set by the caller + import _winapi + SW_MAXIMIZE = 3 + used = [] + create_process = _winapi.CreateProcess + + def spy(*args): + # The startup info is the last argument of CreateProcess() + used.append(args[-1]) + return create_process(*args) + + startupinfo = subprocess.STARTUPINFO( + dwFlags=subprocess.STARTF_USESHOWWINDOW, + wShowWindow=SW_MAXIMIZE) + with mock.patch.object(_winapi, 'CreateProcess', spy): + rc = subprocess.call(ZERO_RETURN_CMD, shell=True, + startupinfo=startupinfo) + self.assertEqual(rc, 0) + rc = subprocess.call(ZERO_RETURN_CMD, shell=True) + self.assertEqual(rc, 0) + + requested, default = used + self.assertEqual(requested.wShowWindow, SW_MAXIMIZE) + # Without STARTF_USESHOWWINDOW the shell window is still hidden. + self.assertTrue(default.dwFlags & subprocess.STARTF_USESHOWWINDOW) + self.assertEqual(default.wShowWindow, subprocess.SW_HIDE) + # CREATE_NEW_CONSOLE creates a "popup" window. @support.requires_resource('gui') def test_creationflags(self): @@ -4300,5 +4450,31 @@ def test_fast_path_avoid_busy_loop(self): self.assertEqual(p.wait(timeout=support.LONG_TIMEOUT), 0) self.assertFalse(m.called) + @unittest.skipIf(mswindows, "requires the POSIX wait implementation") + def test_wait_huge_timeout(self): + # gh-154836: very large timeout values used to overflow the C + # timestamp conversion in poll() / kqueue.control() and raise + # OverflowError / TypeError. + for timeout in (10**10, sys.maxsize, float('inf')): + with self.subTest(timeout=timeout): + p = subprocess.Popen(ZERO_RETURN_CMD) + self.assertEqual(p.wait(timeout=timeout), 0) + + @unittest.skipIf(mswindows, "requires the POSIX wait implementation") + def test_run_huge_timeout(self): + # gh-154836: same as test_wait_huge_timeout, via the + # subprocess.run() / communicate() code path. + cp = subprocess.run(ZERO_RETURN_CMD, timeout=1e10) + self.assertEqual(cp.returncode, 0) + + @unittest.skipIf(mswindows, "requires the POSIX wait implementation") + def test_wait_slices_do_not_expire_early(self): + # A clamped wait slice must not raise TimeoutExpired before the + # real deadline: with a tiny slice limit, a process that + # outlives many slices must still be waited for successfully. + with mock.patch.object(subprocess, "_MAXIMUM_WAIT_TIMEOUT", 0.01): + p = subprocess.Popen(self.COMMAND) # sleeps 0.3s + self.assertEqual(p.wait(timeout=support.SHORT_TIMEOUT), 0) + if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py deleted file mode 100644 index d6d08ee53f821cf..000000000000000 --- a/Lib/test/test_sundry.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Do a minimal test of all the modules that aren't otherwise tested.""" -import importlib -from test import support -from test.support import import_helper -from test.support import warnings_helper -import unittest - -class TestUntestedModules(unittest.TestCase): - def test_untested_modules_can_be_imported(self): - untested = ('encodings',) - with warnings_helper.check_warnings(quiet=True): - for name in untested: - try: - import_helper.import_module('test.test_{}'.format(name)) - except unittest.SkipTest: - importlib.import_module(name) - else: - self.fail('{} has tests even though test_sundry claims ' - 'otherwise'.format(name)) - - import html.entities # noqa: F401 - - try: - # Not available on Windows - import tty # noqa: F401 - except ImportError: - if support.verbose: - print("skipping tty") - - -if __name__ == "__main__": - unittest.main() diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index d556f96bc532ed1..b83e0c371db33d4 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -19,6 +19,7 @@ import warnings from test import support +from test.support import isolation from test.support import hashlib_helper from test.support import import_helper from test.support import os_helper @@ -26,6 +27,10 @@ from test.support import socket_helper from test.support import warnings_helper +if support.MS_WINDOWS: + import _winapi + + TESTFN = os_helper.TESTFN @@ -623,6 +628,20 @@ def test_fd_count(self): os.close(fd) self.assertEqual(more - start, 1) + @unittest.skipUnless(support.MS_WINDOWS, "test specific to Windows") + def test_handle_count(self): + start = os_helper.handle_count() + handle = _winapi.CreateFile( + __file__, _winapi.GENERIC_READ, + 0, _winapi.NULL, + _winapi.OPEN_EXISTING, + 0, _winapi.NULL) + try: + more = os_helper.handle_count() + finally: + _winapi.CloseHandle(handle) + self.assertEqual(more - start, 1) + def check_print_warning(self, msg, expected): stderr = io.StringIO() with support.swap_attr(support.print_warning, 'orig_stderr', stderr): @@ -819,6 +838,10 @@ def test_linked_to_musl(self): for v in linked: self.assertIsInstance(v, int) + def test_built_with_c_assertions(self): + # Check that calling the function doesn't raise an exception + result = support.built_with_c_assertions() + self.assertIsInstance(result, bool) # XXX -follows a list of untested API # make_legacy_pyc @@ -1075,5 +1098,247 @@ def test_disable_hash_md5_in_fips_mode_allow_all(self): self.assertIsInstance(h, self._hashlib.HASH) +class TestIsolated(unittest.TestCase): + # Drive the sample tests in test._isolated_sample (which really spawn + # subprocesses through @isolation.runInSubprocess()) under a private + # TestResult, and check that each subprocess outcome is replayed in the parent. + + @staticmethod + def _run(name): + suite = unittest.TestLoader().loadTestsFromName( + 'test._isolated_sample.' + name) + result = unittest.TestResult() + suite.run(result) + return result + + @staticmethod + def _names(items): + # Map outcome entries (which are (test, detail) pairs, except + # unexpectedSuccesses which are bare tests) to their method names. + names = [] + for item in items: + test = item[0] if isinstance(item, tuple) else item + names.append(test.id().rpartition('.')[2]) + return sorted(names) + + @support.requires_subprocess() + def test_method_outcomes(self): + result = self._run('MethodSample') + self.assertEqual(result.testsRun, 6) + self.assertEqual(self._names(result.failures), ['test_fail']) + self.assertEqual(self._names(result.errors), ['test_error']) + self.assertEqual(self._names(result.skipped), ['test_skip']) + self.assertEqual(self._names(result.expectedFailures), + ['test_expected_failure']) + self.assertEqual(self._names(result.unexpectedSuccesses), + ['test_unexpected_success']) + + @support.requires_subprocess() + def test_class_outcomes(self): + result = self._run('ClassSample') + self.assertEqual(result.testsRun, 3) + self.assertEqual(self._names(result.failures), ['test_fail']) + self.assertEqual(self._names(result.expectedFailures), + ['test_expected_failure']) + self.assertEqual(result.errors, []) + self.assertEqual(result.unexpectedSuccesses, []) + + @support.requires_subprocess() + def test_subtests_reported_individually(self): + result = self._run('SubtestSample') + self.assertEqual(result.testsRun, 1) + self.assertEqual(len(result.failures), 1) + test, _ = result.failures[0] + self.assertIn('i=1', str(test)) + + @support.requires_subprocess() + def test_skip_reason_propagated(self): + result = self._run('MethodSample.test_skip') + self.assertEqual([reason for _, reason in result.skipped], ['nope']) + + @support.requires_subprocess() + def test_subprocess_traceback_is_cause(self): + result = self._run('MethodSample.test_fail') + self.assertEqual(len(result.failures), 1) + _, tb = result.failures[0] + # The real assertion that failed in the subprocess is shown ... + self.assertIn('self.assertEqual(1, 2)', tb) + # ... as the direct cause of the replayed failure ... + self.assertIn('direct cause', tb) + # ... without leaking the parent-side replay frames. + self.assertNotIn('isolation.py', tb) + + @support.requires_subprocess() + def test_durations_forwarded_for_class(self): + from test._isolated_sample import DURATION_SLEEP + result = unittest.TestResult() + suite = unittest.TestLoader().loadTestsFromName( + 'test._isolated_sample.DurationSample') + suite.run(result) + # The duration reported in the parent is the one measured in the + # subprocess (around the sleep), not the near-instant replay time. + self.assertEqual(len(result.collectedDurations), 1) + name, elapsed = result.collectedDurations[0] + self.assertEqual(name.split()[0], 'test_slow') + self.assertGreaterEqual(elapsed, DURATION_SLEEP / 2) + + @support.requires_subprocess() + def test_subclass_of_isolated_class(self): + # Both samples pass only if the fixtures are bound to the runtime class + # and what the subclass adds or overrides runs in the subprocess. + for name, count in (('SubclassingSample', 1), ('SubclassSample', 2)): + with self.subTest(sample=name): + result = self._run(name) + self.assertEqual(result.testsRun, count) + self.assertEqual(result.failures, []) + self.assertEqual(result.errors, []) + + @support.requires_subprocess() + def test_subclass_bypassing_setupclass_is_reported(self): + # A class that never ran in a subprocess must error out, not pass with + # no outcome to replay. + result = self._run('BrokenSubclassSample') + self.assertEqual(result.testsRun, 1) + self.assertEqual(len(result.errors), 1) + self.assertIn('did not run in a subprocess', result.errors[0][1]) + + @support.requires_subprocess() + def test_subprocess_dying_after_the_test_is_reported(self): + from test._isolated_sample import EXIT_CODE + result = self._run('MethodExitSample.test_passes_then_dies') + self.assertEqual(result.testsRun, 1) + self.assertEqual(len(result.errors), 1) + self.assertIn(f'exited with code {EXIT_CODE}', result.errors[0][1]) + + @support.requires_subprocess() + def test_subprocess_dying_does_not_hide_the_failure(self): + result = self._run('MethodExitSample.test_fails_and_dies') + self.assertEqual(self._names(result.failures), ['test_fails_and_dies']) + self.assertEqual(result.errors, []) + + @support.requires_subprocess() + def test_class_subprocess_dying_after_the_tests_is_reported(self): + # The tests that ran are still reported, and the crash once, for the class. + from test._isolated_sample import EXIT_CODE + result = self._run('ClassExitSample') + self.assertEqual(result.testsRun, 2) + self.assertEqual(result.failures, []) + self.assertEqual(len(result.errors), 1) + self.assertIn('tearDownClass', str(result.errors[0][0])) + self.assertIn(f'exited with code {EXIT_CODE}', result.errors[0][1]) + + @support.requires_subprocess() + def test_options_passed_to_subprocess(self): + result = self._run('OptionsSample') + self.assertEqual(result.testsRun, 1) + self.assertEqual(result.failures, []) + self.assertEqual(result.errors, []) + + @support.requires_subprocess() + def test_env_passed_to_subprocess(self): + # The samples check the variable, so set it here to let them tell + # env= from the inherited environment. + with os_helper.EnvironmentVarGuard() as env: + env['_PYTHON_ISOLATION_PROBE'] = 'set-by-parent' + result = self._run('EnvSample') + self.assertEqual(result.testsRun, 3) + self.assertEqual(result.failures, []) + self.assertEqual(result.errors, []) + + @support.requires_subprocess() + def test_timeout_reported_as_error(self): + from test._isolated_sample import TIMEOUT + result = self._run('TimeoutSample') + self.assertEqual(result.testsRun, 1) + self.assertEqual(len(result.errors), 1) + self.assertIn(f'within {TIMEOUT} seconds', result.errors[0][1]) + + @support.requires_subprocess() + def test_bigmemtest_isolates_a_real_run(self): + # A dummy run (no -M) stays in this process, a real run does not. + for memlimit in (0, support._1G): + with self.subTest(real_max_memuse=memlimit): + with support.swap_attr(support, 'real_max_memuse', memlimit): + result = self._run('BigmemSample') + self.assertEqual(result.testsRun, 1) + self.assertEqual(self._names(result.failures), []) + self.assertEqual(self._names(result.errors), []) + + def test_skipped_without_subprocess_support(self): + # On a platform without subprocess support the test is skipped in the + # parent, before any subprocess is spawned. + calls = [] + orig = isolation._start_test + with support.swap_attr(support, 'has_subprocess_support', False): + isolation._start_test = lambda *a, **k: calls.append(a) + try: + result = self._run('MethodSample.test_pass') + finally: + isolation._start_test = orig + self.assertEqual(result.testsRun, 1) + self.assertEqual(len(result.skipped), 1) + self.assertEqual(calls, []) + + +class TestSubTests(unittest.TestCase): + + def run_test(self, cls): + result = unittest.TestResult() + cls('test_it').run(result) + return result + + def test_sync(self): + ran = [] + + class Sample(unittest.TestCase): + @support.subTests('a', [1, 2, 3]) + def test_it(self, a): + ran.append(a) + self.assertNotEqual(a, 2) + + result = self.run_test(Sample) + self.assertEqual(ran, [1, 2, 3]) + self.assertEqual(result.testsRun, 1) + self.assertEqual(len(result.failures), 1) + self.assertEndsWith(result.failures[0][0].id(), 'test_it (a=2)') + + # Running an asyncio event loop needs a working socket. + @support.requires_working_socket() + def test_async(self): + # An asynchronous test must be awaited: a synchronous wrapper would + # make it silently not run at all. + ran = [] + + class Sample(unittest.IsolatedAsyncioTestCase): + @support.subTests('a', [1, 2, 3]) + async def test_it(self, a): + ran.append(a) + self.assertNotEqual(a, 2) + + result = self.run_test(Sample) + self.assertEqual(ran, [1, 2, 3]) + self.assertEqual(result.testsRun, 1) + self.assertEqual(len(result.failures), 1) + self.assertEndsWith(result.failures[0][0].id(), 'test_it (a=2)') + + def test_multiple_parameters(self): + ran = [] + + class Sample(unittest.TestCase): + @support.subTests('a,b', [(1, 'x'), (2, 'y')]) + def test_it(self, a, b): + ran.append((a, b)) + + result = self.run_test(Sample) + self.assertTrue(result.wasSuccessful(), result.errors) + self.assertEqual(ran, [(1, 'x'), (2, 'y')]) + + def test_cannot_decorate_class(self): + with self.assertRaises(TypeError): + @support.subTests('a', [1]) + class Sample(unittest.TestCase): + pass + + if __name__ == '__main__': unittest.main() diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index ce02b27c599c420..da00b0bfa74b125 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -426,12 +426,12 @@ def test_symbol_repr(self): "") st1 = symtable.symtable("[x for x in [1]]", "?", "exec") - self.assertEqual(repr(st1.lookup("x")), + self.assertEqual(repr(st1.get_children()[0].lookup("x")), "") st2 = symtable.symtable("[(lambda: x) for x in [1]]", "?", "exec") - self.assertEqual(repr(st2.lookup("x")), - "") + self.assertEqual(repr(st2.get_children()[0].lookup("x")), + "") st3 = symtable.symtable("def f():\n" " x = 1\n" @@ -502,6 +502,255 @@ def test_nested_genexpr(self): self.assertEqual(sorted(st.get_identifiers()), [".0", "y"]) self.assertEqual(st.get_children(), []) + def test_inlined_comprehension_in_genexpr(self): + st = symtable.symtable("([y for y in x] for x in a)", "?", "exec") + self.assertEqual(len(st.get_children()), 1) + st = st.get_children()[0] + self.assertIs(st.get_type(), symtable.SymbolTableType.FUNCTION) + self.assertEqual(st.get_name(), "") + self.assertFalse(st.is_nested()) + self.assertEqual(sorted(st.get_identifiers()), [".0", "x"]) + children = st.get_children() + self.assertEqual(len(children), 1) + self.check_inlined_listcomp(children[0], ["y"], nested=True) + + def check_inlined_listcomp(self, st, identifiers, *, nested, nchildren=0): + self.assertIs(st.get_type(), symtable.SymbolTableType.INLINED_COMPREHENSION) + self.assertEqual(st.get_name(), "") + self.assertEqual(st.is_nested(), nested) + self.assertEqual(sorted(st.get_identifiers()), identifiers) + children = st.get_children() + self.assertEqual(len(children), nchildren) + return children + + def check_nested_inlined_listcomp(self, outer, outer_ids, inner_ids, *, nested): + inner, = self.check_inlined_listcomp( + outer, outer_ids, nested=nested, nchildren=1) + self.check_inlined_listcomp(inner, inner_ids, nested=True) + return inner + + def test_inlined_comprehension(self): + st = symtable.symtable("[x for x in [1]]", "?", "exec") + self.assertEqual(sorted(st.get_identifiers()), []) + children = st.get_children() + self.assertEqual(len(children), 1) + self.check_inlined_listcomp(children[0], ["x"], nested=False) + + def test_inlined_nested_comprehension(self): + st = symtable.symtable("[[y for y in x] for x in [1]]", "?", "exec") + self.assertEqual(sorted(st.get_identifiers()), []) + children = st.get_children() + self.assertEqual(len(children), 1) + self.check_nested_inlined_listcomp( + children[0], ["x"], ["y"], nested=False) + + def test_inlined_comprehension_use_of_enclosing_free_in_function(self): + # x is used only in the inlined listcomp; inner still reports USE. + st = symtable.symtable( + "def outer(x):\n" + " def inner():\n" + " return [x for y in ()]", + "?", "exec") + inner = find_block(find_block(st, "outer"), "inner") + self.assertTrue(inner.lookup("x").is_free()) + self.assertTrue(inner.lookup("x").is_referenced()) + comp, = inner.get_children() + self.assertTrue(comp.lookup("x").is_free()) + self.assertTrue(comp.lookup("x").is_referenced()) + + def test_inlined_comprehension_use_of_nonlocal_in_function(self): + st = symtable.symtable( + "def outer():\n" + " x = 1\n" + " def inner():\n" + " nonlocal x\n" + " return [x for _ in ()]", + "?", "exec") + inner = find_block(find_block(st, "outer"), "inner") + self.assertTrue(inner.lookup("x").is_nonlocal()) + self.assertTrue(inner.lookup("x").is_free()) + self.assertTrue(inner.lookup("x").is_referenced()) + comp, = inner.get_children() + self.assertTrue(comp.lookup("x").is_free()) + self.assertTrue(comp.lookup("x").is_referenced()) + + def test_inlined_comprehension_use_of_explicit_global_in_function(self): + st = symtable.symtable( + "def f():\n" + " global g\n" + " return [g for _ in ()]", + "?", "exec") + f = find_block(st, "f") + self.assertTrue(f.lookup("g").is_global()) + self.assertTrue(f.lookup("g").is_declared_global()) + self.assertFalse(f.lookup("g").is_referenced()) + comp, = f.get_children() + self.assertTrue(comp.lookup("g").is_global()) + self.assertTrue(comp.lookup("g").is_referenced()) + + def test_inlined_comprehension_nested_function_use_not_on_enclosing(self): + # The load of x is in the lambda's code object, not inner's. + st = symtable.symtable( + "def outer(x):\n" + " def inner():\n" + " return [(lambda: x) for y in ()]", + "?", "exec") + inner = find_block(find_block(st, "outer"), "inner") + self.assertTrue(inner.lookup("x").is_free()) + self.assertFalse(inner.lookup("x").is_referenced()) + comp, = inner.get_children() + self.assertTrue(comp.lookup("x").is_free()) + self.assertFalse(comp.lookup("x").is_referenced()) + lam, = comp.get_children() + self.assertTrue(lam.lookup("x").is_free()) + self.assertTrue(lam.lookup("x").is_referenced()) + + def test_inlined_comprehension_comp_cell_not_on_enclosing(self): + st = symtable.symtable( + "def f():\n" + " x = 1\n" + " return [(lambda: x) for x in [1]]", + "?", "exec") + f = find_block(st, "f") + self.assertTrue(f.lookup("x").is_cell()) + self.assertFalse(f.lookup("x").is_comp_cell()) + comp, = (c for c in f.get_children() + if c.get_type() is symtable.SymbolTableType.INLINED_COMPREHENSION) + self.assertTrue(comp.lookup("x").is_cell()) + self.assertTrue(comp.lookup("x").is_comp_cell()) + + def test_inlined_comprehension_use_of_enclosing_free_in_class(self): + st = symtable.symtable( + "def f():\n" + " y = 1\n" + " class C:\n" + " y = 2\n" + " vals = [(x, y) for x in range(2)]", + "?", "exec") + f = find_block(st, "f") + self.assertTrue(f.lookup("y").is_cell()) + C = find_block(f, "C") + self.assertTrue(C.lookup("y").is_local()) + self.assertFalse(C.lookup("y").is_free()) + self.assertTrue(C.lookup("y").is_free_class()) + comp, = C.get_children() + self.assertTrue(comp.lookup("y").is_free()) + self.assertTrue(comp.lookup("y").is_referenced()) + self.assertTrue(comp.lookup("x").is_local()) + + def test_inlined_comprehension_class_closure_names_are_free(self): + st = symtable.symtable( + "class C:\n" + " [__class__ for x in [1]]", + "?", "exec") + C = find_block(st, "C") + comp, = C.get_children() + self.assertTrue(comp.lookup("__class__").is_free()) + self.assertTrue(comp.lookup("__class__").is_referenced()) + with self.assertRaises(KeyError): + C.lookup("__class__") + + def test_inlined_nested_comprehension_class_iter_var(self): + st = symtable.symtable( + "class C:\n" + " x = 99\n" + " [[x for _ in (0,)] for x in (42,)]", + "?", "exec") + C = find_block(st, "C") + children = C.get_children() + self.assertEqual(len(children), 1) + inner = self.check_nested_inlined_listcomp( + children[0], ["x"], ["_", "x"], nested=False) + self.assertFalse(C.lookup("x").is_free()) + self.assertTrue(C.lookup("x").is_local()) + self.assertFalse(C.lookup("x").is_comp_cell()) + self.assertFalse(children[0].lookup("x").is_free()) + self.assertTrue(children[0].lookup("x").is_local()) + self.assertFalse(children[0].lookup("x").is_cell()) + self.assertFalse(children[0].lookup("x").is_comp_cell()) + self.assertTrue(children[0].lookup("x").is_referenced()) + self.assertFalse(inner.lookup("_").is_free()) + self.assertTrue(inner.lookup("x").is_free()) + self.assertTrue(inner.lookup("x").is_referenced()) + + def test_inlined_nested_comprehension_iter_var_is_fast_local(self): + st = symtable.symtable( + "def f():\n" + " return [[x for _ in (0,)] for x in (42,)]", + "?", "exec") + f = find_block(st, "f") + with self.assertRaises(KeyError): + f.lookup("x") + outer, = f.get_children() + inner = self.check_nested_inlined_listcomp( + outer, ["x"], ["_", "x"], nested=True) + self.assertTrue(outer.lookup("x").is_local()) + self.assertFalse(outer.lookup("x").is_cell()) + self.assertFalse(outer.lookup("x").is_comp_cell()) + self.assertTrue(outer.lookup("x").is_referenced()) + self.assertTrue(inner.lookup("x").is_free()) + self.assertTrue(inner.lookup("x").is_referenced()) + + def test_inlined_nested_mixed_comprehension_iter_var_is_referenced(self): + st = symtable.symtable( + "def f():\n" + " return [{x for _ in (0,)} for x in (42,)]", + "?", "exec") + f = find_block(st, "f") + with self.assertRaises(KeyError): + f.lookup("x") + outer, = f.get_children() + self.assertTrue(outer.lookup("x").is_local()) + self.assertTrue(outer.lookup("x").is_referenced()) + inner, = outer.get_children() + self.assertTrue(inner.lookup("x").is_free()) + self.assertTrue(inner.lookup("x").is_referenced()) + + def test_inlined_nested_comprehension_captured_iter_is_cell(self): + st = symtable.symtable( + "def f():\n" + " return [[(lambda: x) for _ in (0,)] for x in (1, 2)]", + "?", "exec") + f = find_block(st, "f") + with self.assertRaises(KeyError): + f.lookup("x") + outer, = (c for c in f.get_children() + if c.get_type() is symtable.SymbolTableType.INLINED_COMPREHENSION) + inner, = (c for c in outer.get_children() + if c.get_type() is symtable.SymbolTableType.INLINED_COMPREHENSION) + self.assertTrue(outer.lookup("x").is_cell()) + self.assertTrue(outer.lookup("x").is_comp_cell()) + self.assertTrue(inner.lookup("x").is_free()) + lam, = inner.get_children() + self.assertTrue(lam.lookup("x").is_free()) + + def test_inlined_sibling_nested_comprehensions(self): + st = symtable.symtable( + "def f(): [[y for y in x] for x in [1]]; [[w for w in z] for z in [2]]", + "?", "exec") + f = find_block(st, "f") + self.assertIs(f.get_type(), symtable.SymbolTableType.FUNCTION) + self.assertEqual(sorted(f.get_identifiers()), []) + children = f.get_children() + self.assertEqual(len(children), 2) + self.check_nested_inlined_listcomp( + children[0], ["x"], ["y"], nested=True) + self.check_nested_inlined_listcomp( + children[1], ["z"], ["w"], nested=True) + + def test_deeply_nested_inlined_comprehensions(self): + depth = 24 + source = "[" * depth + "0" + " for x in ()]" * depth + st = symtable.symtable(source, "?", "exec") + cur = st + for _ in range(depth): + children = cur.get_children() + self.assertEqual(len(children), 1) + cur = children[0] + self.assertIs(cur.get_type(), + symtable.SymbolTableType.INLINED_COMPREHENSION) + self.assertEqual(cur.get_children(), []) + def test__symtable_refleak(self): # Regression test for reference leak in PyUnicode_FSDecoder. # See https://github.com/python/cpython/issues/139748. diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index a63042055210c5c..04c759310d3d956 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -1502,6 +1502,50 @@ Traceback (most recent call last): SyntaxError: invalid syntax +Ensure that alternative patterns bind the same names (when there is +a single capture in the first pattern that is not uniformly captured, +the error message is sightly different). + + >>> match 1: + ... case x | 1: pass + Traceback (most recent call last): + SyntaxError: name capture 'x' makes remaining patterns unreachable + + >>> match 1: + ... case x | y: pass + Traceback (most recent call last): + SyntaxError: name capture 'x' makes remaining patterns unreachable + + >>> match 1: + ... case 1 | x: pass + Traceback (most recent call last): + SyntaxError: alternative patterns bind different names (pattern 1 binds nothing, pattern 2 binds ['x']) + + >>> match 1: + ... case (x, y) | 1: pass + Traceback (most recent call last): + SyntaxError: alternative patterns bind different names (pattern 1 binds ['x', 'y'], pattern 2 binds nothing) + + >>> match 1: + ... case 1 | ("point", {"x": x, "y": y}): pass + Traceback (most recent call last): + SyntaxError: alternative patterns bind different names (pattern 1 binds nothing, pattern 2 binds ['x', 'y']) + + >>> match 1: + ... case ("point", {"x": x, "y": y}) | 1: pass + Traceback (most recent call last): + SyntaxError: alternative patterns bind different names (pattern 1 binds ['x', 'y'], pattern 2 binds nothing) + + >>> match 1: + ... case ("user", {"id": id}) | ("admin", {"name": name}): pass + Traceback (most recent call last): + SyntaxError: alternative patterns bind different names (pattern 1 binds ['id'], pattern 2 binds ['name']) + + >>> match 1: + ... case ("user", {"id": id}) | ("admin", {"id": id}) | ("other", {"ip": ip}): pass + Traceback (most recent call last): + SyntaxError: alternative patterns bind different names (pattern 1 binds ['id'], pattern 3 binds ['ip']) + Incomplete dictionary literals >>> {1:2, 3:4, 5} @@ -3393,10 +3437,14 @@ def test_invalid_line_continuation_error_position(self): self._check_error('\nfgdfgf\n1,\\#\n2\n', "unexpected character after line continuation character", lineno=3, offset=4) + for prefix in ("f", "t"): + self._check_error(f'{prefix}"""{{\n\\ x}}"""', + "unexpected character after line continuation character", + lineno=2, offset=2) def test_invalid_line_continuation_left_recursive(self): # Check bpo-42218: SyntaxErrors following left-recursive rules - # (t_primary_raw in this case) need to be tested explicitly + # (primary_raw in this case) need to be tested explicitly self._check_error("A.\u018a\\ ", "unexpected character after line continuation character") self._check_error("A.\u03bc\\\n", @@ -3519,6 +3567,38 @@ def test_syntax_error_on_deeply_nested_blocks(self): """ self._check_error(source, "too many statically nested blocks") + @support.cpython_only + def test_nested_inlined_comprehensions_block_limit(self): + # Each inlined comprehension with locals emits SETUP_FINALLY, which + # must count toward CO_MAXBLOCKS (gh-156091). + def src(depth): + e = "i for i in r" + for _ in range(depth - 1): + e = "[" + e + "] for i in r" + return "x = [" + e + "]" + + CO_MAXBLOCKS = 21 + compile(src(CO_MAXBLOCKS), "", "exec") + self._check_error(src(CO_MAXBLOCKS + 1), + "too many statically nested blocks") + + def test_invalid_starred_for_target_in_async_comprehension(self): + sources = [ + "async def f():\n {a async for b in d for *(b,) in e}", + "async def f():\n [a async for b in d for *(b,) in e]", + "async def f():\n {a: a async for b in d for *(b,) in e}", + ] + for src in sources: + with self.subTest(src=src): + self._check_error( + src, "starred assignment target must be in a list or tuple") + + def test_syntax_error_in_nested_inlined_async_comprehension(self): + self._check_error( + "async def f(it):\n" + " return [[f(a=1, a=2) for y in z] async for x in it]\n", + "keyword argument repeated") + @support.cpython_only def test_error_on_parser_stack_overflow(self): source = "-" * 100000 + "4" @@ -3608,6 +3688,31 @@ def test_ifexp_body_stmt_else_stmt(self): ]: self._check_error(f"x = {lhs_stmt} if 1 else {rhs_stmt}", msg) + def test_diamond_operator(self): + self._check_error( + "1<>2", + r"Maybe you meant '!=' instead of '<>'\?", + lineno=1, + end_lineno=1, + offset=2, + end_offset=4, + ) + + def test_diamond_operator_barry_as_flufl(self): + # Under barry_as_FLUFL, '<>' is the valid "not equal" operator + compile( + "from __future__ import barry_as_FLUFL\n1<>2", + "", "exec", + ) + self._check_error( + "from __future__ import barry_as_FLUFL\na != b", + "with Barry as BDFL, use '<>' instead of '!='", + lineno=2, + end_lineno=2, + offset=3, + end_offset=5, + ) + def test_double_ampersand(self): self._check_error( "a && b", diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 56c5c2aa2025b9a..3b65bf5128cdbf2 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -265,6 +265,17 @@ def test_exit(self): self.assertEqual(out, b'') self.assertEqual(err, b'') + # test EXIT_SUCCESS and EXIT_FAILURE constants + self.assertNotEqual(sys.EXIT_SUCCESS, sys.EXIT_FAILURE) + rc, out, err = assert_python_ok('-c', 'import sys; sys.exit(sys.EXIT_SUCCESS)') + self.assertEqual(rc, sys.EXIT_SUCCESS) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + rc, out, err = assert_python_failure('-c', 'import sys; sys.exit(sys.EXIT_FAILURE)') + self.assertEqual(rc, sys.EXIT_FAILURE) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + def check_exit_message(code, expected, **env_vars): rc, out, err = assert_python_failure('-c', code, **env_vars) self.assertEqual(rc, 1) @@ -425,6 +436,7 @@ def test_getwindowsversion(self): self.assertEqual(v[2], v.build) self.assertEqual(v[3], v.platform) self.assertEqual(v[4], v.service_pack) + support.check_immutable_type(self, type(v)) # This is how platform.py calls it. Make sure tuple # still has 5 elements @@ -562,6 +574,38 @@ def g456(): leave_g.set() t.join() + @support.cpython_only + @requires_subinterpreters + @threading_helper.requires_working_threading() + def test_current_frames_other_interpreters(self): + # gh-158364: sys._current_frames() would access frames of another + # interpreter and crash + import threading + + entered = threading.Event() + left = threading.Event() + + def park(): + entered.set() + left.wait() + + t = threading.Thread(target=park) + with threading_helper.start_threads([t], unlock=left.set): + entered.wait() + interp = interpreters.create() + try: + interp.exec(f"""if True: + import sys + import threading + + frames = sys._current_frames() + assert threading.get_ident() in frames, frames + assert frames[threading.get_ident()].f_globals is globals() + assert {t.ident} not in frames, frames + """) + finally: + interp.close() + @threading_helper.reap_threads @threading_helper.requires_working_threading() def test_current_exceptions(self): @@ -628,6 +672,39 @@ def g456(): leave_g.set() t.join() + @support.cpython_only + @requires_subinterpreters + @threading_helper.requires_working_threading() + def test_current_exceptions_other_interpreters(self): + # gh-158364: sys._current_exceptions() would hand out exceptions of + # another interpreter and crash + import threading + + entered = threading.Event() + left = threading.Event() + + def hold(): + # The thread has to be handling an exception, otherwise + # sys._current_exceptions() has nothing to report for it. + try: + raise ValueError + except ValueError: + entered.set() + left.wait() + + t = threading.Thread(target=hold) + with threading_helper.start_threads([t], unlock=left.set): + entered.wait() + interp = interpreters.create() + try: + interp.exec(f"""if True: + import sys + + assert {t.ident} not in sys._current_exceptions() + """) + finally: + interp.close() + def test_attributes(self): self.assertIsInstance(sys.api_version, int) self.assertIsInstance(sys.argv, list) @@ -690,6 +767,7 @@ def test_attributes(self): self.assertEqual(algo, 0) self.assertGreaterEqual(sys.hash_info.cutoff, 0) self.assertLess(sys.hash_info.cutoff, 8) + support.check_immutable_type(self, type(sys.hash_info)) self.assertIsInstance(sys.maxsize, int) self.assertIsInstance(sys.maxunicode, int) @@ -757,6 +835,16 @@ def test_emscripten_info(self): self.assertIsInstance(sys._emscripten_info.pthreads, bool) self.assertIsInstance(sys._emscripten_info.shared_memory, bool) + @unittest.skipUnless(support.is_wasi, "only available on WASI") + def test_wasi_info(self): + info = sys._wasi_info + self.assertIn(info.wasi_version, {'p1', 'p2', 'p3'}) + self.assertIn('.', info.wasi_sdk_version) + sdk_major, _, sdk_minor = info.wasi_sdk_version.partition('.') + self.assertGreaterEqual(int(sdk_major), 1) + self.assertGreaterEqual(int(sdk_minor), 0) + self.assertIsInstance(info.cooperative_threads, bool) + def test_43581(self): # Can't use sys.stdout, as this is a StringIO object when # the test runs under regrtest. @@ -893,11 +981,13 @@ def assert_raise_on_new_sys_type(self, sys_attr): # sys.flags, sys.version_info, and sys.getwindowsversion. support.check_disallow_instantiation(self, type(sys_attr), sys_attr) - def test_sys_flags_no_instantiation(self): + def test_sys_flags_type(self): self.assert_raise_on_new_sys_type(sys.flags) + support.check_immutable_type(self, type(sys.flags)) - def test_sys_version_info_no_instantiation(self): + def test_sys_version_info_type(self): self.assert_raise_on_new_sys_type(sys.version_info) + support.check_immutable_type(self, type(sys.version_info)) def test_sys_getwindowsversion_no_instantiation(self): # Skip if not being run on Windows. @@ -1125,8 +1215,10 @@ def test_debugmallocstats(self): # The sysconfig vars are not available on Windows. if sys.platform != "win32": with_pymalloc = sysconfig.get_config_var("WITH_PYMALLOC") + with_sanitizer = support.check_sanitizer(address=True, memory=True) self.assertIn(b"free PyDictObjects", err) - if with_pymalloc: + # ASan and MSan builds default to malloc, even with pymalloc. + if with_pymalloc and not with_sanitizer: self.assertIn(b'Small block threshold', err) # The function has no parameter @@ -1370,6 +1462,46 @@ def test_int_max_str_digits(self): with self.assertRaises(TypeError): sys.set_int_max_str_digits(2_048.0) + @test.support.cpython_only + def test_is_immortal(self): + is_immortal = sys._is_immortal + + # Singletons + self.assertTrue(is_immortal(None)) + self.assertTrue(is_immortal(False)) + self.assertTrue(is_immortal(True)) + self.assertTrue(is_immortal(0)) + self.assertTrue(is_immortal(b'')) + self.assertTrue(is_immortal('')) + self.assertTrue(is_immortal(b'x')) + self.assertTrue(is_immortal('x')) + self.assertTrue(is_immortal(())) + + # Static types + self.assertTrue(is_immortal(int)) + self.assertTrue(is_immortal(dict)) + + # Test some mortal objects + class PythonType: + pass + self.assertFalse(is_immortal([1, 2, 3])) + self.assertFalse(is_immortal({'key': 5})) + self.assertFalse(is_immortal(object())) + self.assertFalse(is_immortal(PythonType)) + self.assertFalse(is_immortal(2 ** 100)) + # Use encode/decode to get a fresh object + self.assertFalse(is_immortal(b'abc'.decode())) + self.assertFalse(is_immortal('abc'.encode())) + + def test_path(self): + self.assertIsInstance(sys.path, list) + for path in sys.path: + self.assertIsInstance(path, str) + + def test_path0(self): + self.assertTrue(sys._path0 is None or isinstance(sys._path0, str), + sys._path0) + @test.support.cpython_only @test.support.force_not_colorized_test_class @@ -1722,7 +1854,7 @@ def get_gen(): yield 1 check(iter('abc'), size('lP')) # callable-iterator import re - check(re.finditer('',''), size('2P')) + check(re.finditer('',''), size('3P')) # list check(list([]), vsize('Pn')) check(list([1]), vsize('Pn') + 2*self.P) @@ -1809,7 +1941,7 @@ def delx(self): del self.__x check((1,2,3), vsize('') + self.P + 3*self.P) # type # static type: PyTypeObject - fmt = 'P2nPI13Pl4Pn9Pn12PI2Pc' + fmt = 'P2nPI13Pl4Pn9Pn12PI2PcP' s = vsize(fmt) check(int, s) typeid = 'n' if support.Py_GIL_DISABLED else '' @@ -1919,7 +2051,7 @@ def test_pythontypes(self): check = self.check_sizeof # _ast.AST import _ast - check(_ast.Module(), size('3P')) + check(_ast.Module(), size('2P')) try: raise TypeError except TypeError as e: @@ -1954,6 +2086,7 @@ def test_asyncgen_hooks(self): cur = sys.get_asyncgen_hooks() self.assertIsNone(cur.firstiter) self.assertIsNone(cur.finalizer) + support.check_immutable_type(self, type(cur)) # gh-118473 with self.assertRaises(TypeError): @@ -1997,6 +2130,7 @@ def write(self, s): self.assertEqual(out, b"") self.assertEqual(err, b"") + @test.support.support_remote_exec_only @test.support.cpython_only class TestRemoteExec(unittest.TestCase): @@ -2261,16 +2395,20 @@ def test_remote_exec_deleted_libpython(self): if not os.path.exists(source_libpython): self.skipTest(f'{source_libpython!r} does not exist') - with os_helper.temp_dir() as lib_dir: - copied_libpython = os.path.join(lib_dir, instsoname) + with os_helper.temp_dir(os_helper.TESTFN) as lib_dir: + copied_libpython = os.path.abspath( + os.path.join(lib_dir, instsoname)) shutil.copy2(source_libpython, copied_libpython) if ldlibrary != instsoname: os.symlink(instsoname, os.path.join(lib_dir, ldlibrary)) env = os.environ.copy() - ld_library_path = env.get('LD_LIBRARY_PATH') - env['LD_LIBRARY_PATH'] = lib_dir if not ld_library_path else ( - lib_dir + os.pathsep + ld_library_path) + # Preload the copy even when `RPATH` overrides `LD_LIBRARY_PATH`. + # Use a relative path to avoid spaces or colons in parent directories. + preload = os.path.join(os.curdir, lib_dir, instsoname) + ld_preload = env.get('LD_PRELOAD') + env['LD_PRELOAD'] = preload if not ld_preload else ( + preload + os.pathsep + ld_preload) self._run_remote_exec_with_deleted_mapping(copied_libpython, env=env) diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index e6f99581f0b7a66..af642e25ac8c3df 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -1,3 +1,4 @@ +import itertools import platform import re import unittest @@ -21,7 +22,8 @@ ) from test.support.import_helper import import_module from test.support.os_helper import (TESTFN, unlink, skip_unless_symlink, - change_cwd, EnvironmentVarGuard) + change_cwd, temp_dir, + EnvironmentVarGuard) from test.support.venv import VirtualEnvironmentMixin import sysconfig @@ -29,7 +31,7 @@ get_path, get_path_names, _INSTALL_SCHEMES, get_default_scheme, get_scheme_names, get_config_var, _expand_vars, _get_preferred_schemes, - is_python_build, _PROJECT_BASE) + is_python_build, _PROJECT_BASE, parse_config_h) from sysconfig.__main__ import _main, _parse_makefile, _get_pybuilddir, _get_json_data_name import _imp import _osx_support @@ -64,6 +66,8 @@ def setUp(self): self.isabs = os.path.isabs self.splitdrive = os.path.splitdrive self._config_vars = sysconfig._CONFIG_VARS, copy(sysconfig._CONFIG_VARS) + self._cached_prefixes = (sysconfig._config_vars_cached_prefix, + sysconfig._config_vars_cached_exec_prefix) self._added_envvars = [] self._changed_envvars = [] for var in ('MACOSX_DEPLOYMENT_TARGET', 'PATH'): @@ -92,6 +96,11 @@ def tearDown(self): sysconfig._CONFIG_VARS = self._config_vars[0] sysconfig._CONFIG_VARS.clear() sysconfig._CONFIG_VARS.update(self._config_vars[1]) + # Restoring _CONFIG_VARS is not enough: if the cached prefixes are + # left over from the test, the next get_config_vars() call finds + # the cache stale and replaces _CONFIG_VARS with a new dict. + (sysconfig._config_vars_cached_prefix, + sysconfig._config_vars_cached_exec_prefix) = self._cached_prefixes for var, value in self._changed_envvars: os.environ[var] = value for var in self._added_envvars: @@ -457,6 +466,15 @@ def test_soabi(self): soabi = sysconfig.get_config_var('SOABI') self.assertIn(soabi, _imp.extension_suffixes()[0]) + @unittest.skipIf(not _imp.extension_suffixes(), "stub loader has no suffixes") + @unittest.skipIf(sys.platform == "win32", "Does not apply to Windows") + @unittest.skipIf(sysconfig.get_config_var('SOABI_PLATFORM') == 0, + "SOABI_PLATFORM is undefined") + def test_soabi_platform(self): + soabi_platform = sysconfig.get_config_var('SOABI_PLATFORM') + soabi = sysconfig.get_config_var('SOABI') + self.assertIn(soabi_platform, soabi) + def test_library(self): library = sysconfig.get_config_var('LIBRARY') ldlibrary = sysconfig.get_config_var('LDLIBRARY') @@ -567,7 +585,7 @@ def test_linux_ext_suffix(self): ctypes = import_module('ctypes') machine = platform.machine() suffix = sysconfig.get_config_var('EXT_SUFFIX') - if re.match('(aarch64|arm|mips|ppc|powerpc|s390|sparc)', machine): + if re.match('(aarch64|arm|mips|ppc|powerpc|riscv|s390|sparc)', machine): self.assertTrue('linux' in suffix, suffix) if re.match('(i[3-6]86|x86_64)$', machine): if ctypes.sizeof(ctypes.c_char_p()) == 4: @@ -751,6 +769,139 @@ def test_sysconfig_config_vars_no_prefix_cache(self): self.assertEqual(config_vars['exec_prefix'], sys.exec_prefix) self.assertEqual(config_vars['platbase'], sys.exec_prefix) + @unittest.skipUnless(os.name == 'posix', 'python-config.sh is POSIX only') + @unittest.skipIf(is_wasi, "Incompatible with WASI mapdir and OOT builds") + @unittest.skipIf(is_android or is_apple_mobile, + 'Android and iOS do not ship python-config') + @requires_subprocess() + def test_python_config_sh_prefix_special_characters(self): + # gh-159819: the shell variant of python-config must report the + # directory it was installed to even if that path contains spaces or + # characters special to the shell, sed or echo. + if is_python_build(): + script = os.path.join(_PROJECT_BASE, 'python-config') + else: + ldversion = get_config_var('LDVERSION') + script = os.path.join(os.path.dirname(sys.executable), + f'python{ldversion}-config') + if not os.path.isfile(script): + self.skipTest(f'{script!r} does not exist') + with open(script, encoding='utf-8') as f: + if f.readline().rstrip() != '#!/bin/sh': + self.skipTest('python-config is not the shell script variant') + + with open(script, encoding='utf-8') as f: + script_text = f.read() + makefile_vars = _parse_makefile(sysconfig.get_makefile_filename()) + configured_prefix = makefile_vars['prefix'] + + def check(script_copy, option, expected): + proc = subprocess.run(['/bin/sh', script_copy, option], + capture_output=True, text=True) + self.assertEqual(proc.returncode, 0, proc.stderr) + self.assertEqual(proc.stdout.rstrip('\n'), expected) + self.assertEqual(proc.stderr, '') + + # '#', '&' and '\' were special to the sed replacement, and '\c' makes + # some echo implementations stop printing. + names = ['path with spaces', 'path#with&', r'back\slash\cdir'] + # The configured prefix is also matched literally. Simulate a build + # configured with special characters in its prefix by substituting + # them into a copy of the script. + fake_prefixes = [None] + if configured_prefix != '/': + fake_prefixes.append('/conf#with&special\\chars') + for name, fake_prefix in itertools.product(names, fake_prefixes): + with (self.subTest(name=name, configured_prefix=fake_prefix), + temp_dir() as tmpdir): + prefix = os.path.realpath(os.path.join(tmpdir, name)) + bindir = os.path.join(prefix, 'bin') + os.mkdir(prefix) + os.mkdir(bindir) + script_copy = os.path.join(bindir, 'python-config') + text = script_text + if fake_prefix is not None: + text = text.replace(configured_prefix, fake_prefix) + with open(script_copy, 'w', encoding='utf-8') as f: + f.write(text) + + check(script_copy, '--prefix', prefix) + check(script_copy, '--exec-prefix', prefix) + + # The script rewrites the configured include directory by + # replacing the configured prefix with the actual one. + includedir = makefile_vars['INCLUDEDIR'].replace( + configured_prefix, prefix, 1) + incdir = os.path.join(includedir, 'python{VERSION}{ABIFLAGS}' + .format_map(makefile_vars)) + check(script_copy, '--includes', f'-I{incdir} -I{incdir}') + + def test_parse_config_h(self): + config = textwrap.dedent(''' + #ifndef Py_PYCONFIG_H + #define Py_PYCONFIG_H + + /* C comment */ + + #define ALIGNOF_LONG 8 + #define HAVE_ACCEPT 1 + #define _Py_HAVE_COSPI 1 + #define INVALID_NUMBER abc + #define ALT_SOABI "cpython-316t-x86_64-linux-gnu" + + // Undef macros must be written as "/* #undef NAME */": + // name must be valid and there is not value. + /* #undef ANDROID_API_LEVEL */ + #undef IGNORE_UNDEF + /* #undef IGNORE_VALUE 1 */ + + # _ALWAYS_STR: don't convert values to an integer, + # but quotes are removed + #define IPHONEOS_DEPLOYMENT_TARGET "13.0" + #define MACOSX_DEPLOYMENT_TARGET 10 + + // Spaces are tolerated after the name, not before + #define SPACES_AFTER 1 + #define IGNORED_SPACES_BEFORE 1 + + // Ignore macro without value + #define IGNORE_NO_VALUE + + // Ignore macros with an invalid name + #define _PRIVATE_IGNORED 1 + #define aLOWER_IGNORED 1 + #define 123IGNORED 1 + #define INVALID-NAME 1 + #define INVALID#NAME 1 + #define NONASCII_NAME_é 1 + + // Ignore single letter names + #define A 1 + /* #undef A */ + + #endif /*Py_PYCONFIG_H*/ + ''') + + filename = TESTFN + self.addCleanup(unlink, filename) + with open(filename, "w", encoding="utf-8") as fp: + fp.write(config) + vars = {} + with open(filename, encoding="utf-8") as fp: + parse_config_h(fp, vars) + expected = { + 'ALIGNOF_LONG': 8, + 'HAVE_ACCEPT': 1, + '_Py_HAVE_COSPI': 1, + 'INVALID_NUMBER': 'abc', + 'ALT_SOABI': 'cpython-316t-x86_64-linux-gnu', + 'ANDROID_API_LEVEL': 0, + 'IPHONEOS_DEPLOYMENT_TARGET': '13.0', + 'MACOSX_DEPLOYMENT_TARGET': '10', # str, not int + 'SPACES_AFTER': 1, + } + self.assertEqual(vars, expected) + class MakefileTests(unittest.TestCase): diff --git a/Lib/test/test_syslog.py b/Lib/test/test_syslog.py index 54db80fa9df1afa..e6e3ccab35fa9f8 100644 --- a/Lib/test/test_syslog.py +++ b/Lib/test/test_syslog.py @@ -142,6 +142,29 @@ def test_subinterpreter_closelog(self): finally: syslog.closelog() + @threading_helper.requires_working_threading() + def test_subinterpreter_concurrent_syslog(self): + # gh-158929: This used to crash. + from concurrent import interpreters + + interp = interpreters.create() + try: + def in_interpreter(): + import syslog + + for _ in range(40000): + try: + syslog.syslog('my hovercraft is full of eels') + except RuntimeError: + pass + thread = interp.call_in_thread(in_interpreter) + for i in range(40000): + syslog.openlog(f"python{i}") + syslog.closelog() + thread.join() + finally: + interp.close() + if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_tabnanny.py b/Lib/test/test_tabnanny.py index e575aac037e9172..e41616423b546dc 100644 --- a/Lib/test/test_tabnanny.py +++ b/Lib/test/test_tabnanny.py @@ -7,12 +7,13 @@ from unittest import TestCase, main, mock import errno import os +import sys import tabnanny import tokenize import tempfile import textwrap -from test.support import (captured_stderr, captured_stdout, script_helper, - findfile) +from test import support +from test.support import captured_stderr, captured_stdout, script_helper from test.support.os_helper import unlink @@ -328,8 +329,7 @@ def test_with_error_free_file(self): def test_command_usage(self): """Should display usage on no arguments.""" - path = findfile('tabnanny.py') - stderr = f"Usage: {path} [-v] file_or_directory ..." + stderr = f"Usage: {sys.executable} -m tabnanny [-v] file_or_directory ..." self.validate_cmd(stderr=stderr, expect_failure=True) def test_quiet_flag(self): @@ -356,13 +356,10 @@ def test_double_verbose_mode(self): class TestModule(TestCase): - def test_deprecated__version__(self): - with self.assertWarnsRegex( - DeprecationWarning, - "'__version__' is deprecated and slated for removal in Python 3.20", - ) as cm: - getattr(tabnanny, "__version__") - self.assertEqual(cm.filename, __file__) + def test_deprecated_module_attributes(self): + support.check_deprecated_module_attributes( + self, tabnanny, "__version__", remove=(3, 20), + ) if __name__ == "__main__": diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index c86bcb79eb85d89..1927ff227d5356f 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -1,7 +1,9 @@ +import copy import errno import sys import os import io +import ntpath from hashlib import sha256 from contextlib import contextmanager, ExitStack from random import Random @@ -254,6 +256,19 @@ def test_add_dir_getmember(self): self.add_dir_and_getmember('bar') self.add_dir_and_getmember('a'*101) + def test_extract_name_with_trailing_slash(self): + # gh-127636: './mydir/' is deliberately a regular-file member + # (REGTYPE, not DIRTYPE) whose stored name ends in a slash. It + # extracts as a file. Do not "fix" this by setting DIRTYPE; the + # trailing-slash name on a non-directory is what is being tested. + with tarfile.open(tmpname, 'w') as tar: + tar.addfile(tarfile.TarInfo('./mydir/')) + with os_helper.temp_dir() as tmpdir, tarfile.open(tmpname) as tar: + names = tar.getnames() + self.assertEqual(names, ['./mydir/']) + tar.extract(names[0], tmpdir, filter='fully_trusted') + self.assertTrue(os.path.isfile(os.path.join(tmpdir, 'mydir'))) + @unittest.skipUnless(hasattr(os, "getuid") and hasattr(os, "getgid"), "Missing getuid or getgid implementation") def add_dir_and_getmember(self, name): @@ -1046,6 +1061,44 @@ def test_compare_members(self): finally: tar1.close() + def test_ignore_zeros_concatenated(self): + # gh-159643: reading past the end of the compressed data + # must not raise EOFError. + with self.open(tmpname, "wb") as fobj: + for name in ("a", "b"): + with tarfile.open(fileobj=fobj, mode="w") as tar: + tar.addfile(tarfile.TarInfo(name)) + with tarfile.open(tmpname, self.mode, ignore_zeros=True) as tar: + self.assertEqual(tar.getnames(), ["a", "b"]) + + def test_no_end_of_archive_blocks(self): + # gh-159643 + tarinfo = tarfile.TarInfo("a") + tarinfo.size = 5 + with self.open(tmpname, "wb") as fobj: + fobj.write(tarinfo.tobuf()) + fobj.write(b"hello".ljust(tarfile.BLOCKSIZE, b"\0")) + with tarfile.open(tmpname, self.mode) as tar: + self.assertEqual(tar.getnames(), ["a"]) + + def test_data_after_end_of_stream(self): + # gh-159643: with a small bufsize, the compressed data spans + # several reads of the file and the padding that follows it + # is not read together with the end of the compressed data. + bufsize = tarfile.BLOCKSIZE + data = Random(0).randbytes(8 * bufsize) + tarinfo = tarfile.TarInfo("a") + tarinfo.size = len(data) + with self.open(tmpname, "wb") as fobj: + with tarfile.open(fileobj=fobj, mode="w") as tar: + tar.addfile(tarinfo, io.BytesIO(data)) + with open(tmpname, "ab") as fobj: + fobj.write(bytes(4 * bufsize)) + with tarfile.open(tmpname, self.mode, bufsize=bufsize, + ignore_zeros=True) as tar: + members = [(m.name, tar.extractfile(m).read()) for m in tar] + self.assertEqual(members, [("a", data)]) + class GzipStreamReadTest(GzipTest, GzipReadTestBase, StreamReadTest): pass @@ -1190,6 +1243,72 @@ def runTest(self): tarfile.open(fileobj=f, mode='r|gz') +class FileInFileExceptionWrappingTest(unittest.TestCase): + """ + See: https://github.com/python/cpython/issues/156057 + + _FileInFile.read() must wrap whatever exception type its + underlying fileobj.read() raises for corrupt compressed data, + using the exception class attribute each TarFile.*open() + classmethod configures, in tarfile.ReadError -- and must not + swallow an exception of an unconfigured type. + """ + + class _FakeFileobj: + def __init__(self, exc): + self.exc = exc + + def seek(self, position): + pass + + def read(self, size): + raise self.exc + + def test_wraps_configured_exception_type(self): + class Boom(Exception): + pass + + fif = tarfile._FileInFile( + self._FakeFileobj(Boom("simulated corrupt compressed data")), + offset=0, size=10, name="member", exception=Boom) + with self.assertRaises(tarfile.ReadError): + fif.read() + + def test_does_not_wrap_unconfigured_exception_type(self): + class Boom(Exception): + pass + + class Unrelated(Exception): + pass + + fif = tarfile._FileInFile( + self._FakeFileobj(Unrelated("not the configured exception type")), + offset=0, size=10, name="member", exception=Boom) + with self.assertRaises(Unrelated): + fif.read() + + +@support.requires_gzip() +class GzipExtractfileWrapsCompressionErrorTest(unittest.TestCase): + """ + See: https://github.com/python/cpython/issues/156057 + + Confirms the real gzopen() -> ExFileObject -> _FileInFile wiring: + a zlib.error raised while reading a member's compressed data past + the header surfaces as tarfile.ReadError, not the raw zlib.error. + """ + + def test_extractfile_read_wraps_zlib_error(self): + with tarfile.open(gzipname, mode='r:gz') as tar: + tarinfo = tar.getmember("ustar/regtype") + with tar.extractfile(tarinfo) as fobj: + with unittest.mock.patch.object( + tar.fileobj, "read", + side_effect=zlib.error("simulated corrupt data")): + with self.assertRaises(tarfile.ReadError): + fobj.read() + + class MemberReadTest(ReadTest, unittest.TestCase): def _test_member(self, tarinfo, chksum=None, **kwargs): @@ -1399,6 +1518,65 @@ def test_sparse_file_01(self): def test_sparse_file_10(self): self._test_sparse_file("gnu/sparse-1.0") + def test_sparse_file_10_pax_size(self): + # gh-83869: when the pax header replaces the size field, the offset + # of the next header must be computed from the size of the data in + # the archive, not from the apparent size of the sparse file. + data = b"payload!" * 4 + realsize = 1 << 20 + smap = b"1\n%d\n%d\n" % (realsize - len(data), len(data)) + smap += b"\0" * (-len(smap) % tarfile.BLOCKSIZE) + + sparse = tarfile.TarInfo("sparse") + sparse.size = len(smap) + len(data) + sparse.pax_headers = { + "GNU.sparse.major": "1", + "GNU.sparse.minor": "0", + "GNU.sparse.name": "sparse", + "GNU.sparse.realsize": str(realsize), + "size": str(sparse.size), + } + buf = sparse.tobuf(tarfile.PAX_FORMAT) + buf += smap + data + b"\0" * (-len(data) % tarfile.BLOCKSIZE) + + last = tarfile.TarInfo("last") + last.size = len(data) + buf += last.tobuf(tarfile.PAX_FORMAT) + buf += data + b"\0" * (-len(data) % tarfile.BLOCKSIZE) + buf += b"\0" * (tarfile.BLOCKSIZE * 2) + + with tarfile.open(fileobj=io.BytesIO(buf)) as tar: + self.assertEqual(tar.getnames(), ["sparse", "last"]) + self.assertEqual(tar.extractfile("last").read(), data) + + def test_pax_size_with_gnu_longname(self): + # gh-159435: a GNU long-name header between a pax header and its + # member must not make the member header get read a second time. + long_name = "long-name-" * 12 + "file.txt" + + def header(name, type, size): + info = tarfile.TarInfo(name) + info.type = type + info.size = size + return info.tobuf(tarfile.USTAR_FORMAT) + + def padded(data): + return data + b"\0" * (-len(data) % tarfile.BLOCKSIZE) + + pax_record = b"9 size=5\n" + buf = header("././@PaxHeader", tarfile.XHDTYPE, len(pax_record)) + buf += padded(pax_record) + longname = long_name.encode() + b"\0" + buf += header("././@LongLink", tarfile.GNUTYPE_LONGNAME, len(longname)) + buf += padded(longname) + buf += header("member-short", tarfile.REGTYPE, 5) + padded(b"hello") + buf += header("next.txt", tarfile.REGTYPE, 3) + padded(b"bye") + buf += b"\0" * (tarfile.BLOCKSIZE * 2) + + with tarfile.open(fileobj=io.BytesIO(buf)) as tar: + self.assertEqual(tar.getnames(), [long_name, "next.txt"]) + self.assertEqual(tar.extractfile("next.txt").read(), b"bye") + @staticmethod def _fs_supports_holes(): # Return True if the platform knows the st_blocks stat attribute and @@ -1472,6 +1650,31 @@ def test_pax_global_headers(self): finally: tar.close() + def test_offset_after_global_header(self): + # gh-83869: a global header is a member of its own, the member which + # follows it keeps the offset of its own header. + rec = b"30 comment=global header here\n" + glob = tarfile.TarInfo("././@PaxHeader") + glob.type = tarfile.XGLTYPE + glob.size = len(rec) + buf = glob.tobuf(tarfile.USTAR_FORMAT) + buf += rec + b"\0" * (-len(rec) % tarfile.BLOCKSIZE) + + member = tarfile.TarInfo("member") + data = b"hello\n" + member.size = len(data) + offset = len(buf) + buf += member.tobuf(tarfile.USTAR_FORMAT) + buf += data + b"\0" * (-len(data) % tarfile.BLOCKSIZE) + buf += b"\0" * (tarfile.BLOCKSIZE * 2) + + with tarfile.open(fileobj=io.BytesIO(buf)) as tar: + tarinfo = tar.getmember("member") + self.assertEqual(tarinfo.offset, offset) + self.assertEqual(tarinfo.pax_headers.get("comment"), + "global header here") + self.assertEqual(tar.extractfile(tarinfo).read(), data) + def test_pax_number_fields(self): # All following number fields are read from the pax header. tar = tarfile.open(tarname, encoding="iso8859-1") @@ -1564,6 +1767,29 @@ class WriteTest(WriteTestBase, unittest.TestCase): prefix = "w:" + def test_addfile_sets_offsets(self): + # gh-150075: addfile() must set offset and offset_data on the + # TarInfo stored in the archive so they match a subsequent read. + data = b"data" + + with tarfile.open(tmpname, self.mode) as tar: + t1 = tarfile.TarInfo("test1.txt") + t1.size = len(data) + tar.addfile(t1, io.BytesIO(data)) + + t2 = tarfile.TarInfo("test2.txt") + t2.size = len(data) + tar.addfile(t2, io.BytesIO(data)) + + write_members = tar.getmembers() + + with tarfile.open(tmpname) as tar: + read_members = tar.getmembers() + + for w, r in zip(write_members, read_members): + self.assertEqual(w.offset, r.offset) + self.assertEqual(w.offset_data, r.offset_data) + def test_100_char_name(self): # The name field in a tar header stores strings of at most 100 chars. # If a string is shorter than 100 chars it has to be padded with '\0', @@ -1980,6 +2206,44 @@ def test_create_with_mtime(self): fobj.read() self.assertEqual(fobj.mtime, 0) + def test_create_with_mtime_out_of_range(self): + # gh-133998: an mtime outside the gzip header's 32-bit range is + # stored as 0 rather than raising struct.error. + self.addCleanup(os_helper.unlink, tmpname) + for mtime in (-1, 2**32): + with self.subTest(mtime=mtime): + tarfile.open(tmpname, self.mode, mtime=mtime).close() + with self.open(tmpname, 'r') as fobj: + fobj.read() + self.assertEqual(fobj.mtime, 0) + + def test_create_with_mtime_at_boundary(self): + # gh-133998: the largest in-range mtime is preserved, not clamped. + mtime = 2**32 - 1 + tarfile.open(tmpname, self.mode, mtime=mtime).close() + with self.open(tmpname, 'r') as fobj: + fobj.read() + self.assertEqual(fobj.mtime, mtime) + + def test_create_with_out_of_range_clock(self): + # gh-133998: an out-of-range system clock (mtime defaulting to + # time.time()) is stored as 0 rather than raising struct.error. + for clock in (-1, 2**32): + with self.subTest(clock=clock): + with unittest.mock.patch('time.time', return_value=float(clock)): + tarfile.open(tmpname, self.mode).close() + with self.open(tmpname, 'r') as fobj: + fobj.read() + self.assertEqual(fobj.mtime, 0) + os_helper.unlink(tmpname) + + def test_create_with_float_mtime(self): + # gh-133998: a float mtime is truncated like gzip, not rejected. + tarfile.open(tmpname, self.mode, mtime=123456789.9).close() + with self.open(tmpname, 'r') as fobj: + fobj.read() + self.assertEqual(fobj.mtime, 123456789) + def test_create_without_mtime(self): before = int(time.time()) tarfile.open(tmpname, self.mode).close() @@ -2386,6 +2650,43 @@ def test_dereference_hardlink(self): class PaxWriteTest(GNUWriteTest): + def test_100_byte_names(self): + for field, offset in (("name", 0), ("linkname", 157)): + with self.subTest(field=field): + name = "a" * 100 + tarinfo = tarfile.TarInfo("test") + if field == "linkname": + tarinfo.type = tarfile.SYMTYPE + setattr(tarinfo, field, name) + header = tarinfo.tobuf(format=tarfile.PAX_FORMAT) + self.assertEqual(len(header), tarfile.BLOCKSIZE) + self.assertEqual(header[offset:offset + 100], + name.encode("ascii")) + with tarfile.open(fileobj=io.BytesIO(header)) as tar: + member = tar.next() + self.assertEqual(getattr(member, field), name) + self.assertEqual(member.pax_headers, {}) + + def test_owner_names(self): + for field, offset in (("uname", 265), ("gname", 297)): + for length in (0, 31, 32, 33, 40): + with self.subTest(field=field, length=length): + name = "a" * length + tarinfo = tarfile.TarInfo("test") + setattr(tarinfo, field, name) + header = tarinfo.tobuf(format=tarfile.PAX_FORMAT) + # The base header must leave room for a NUL terminator. + base_header = header[-tarfile.BLOCKSIZE:] + self.assertEqual(base_header[offset:offset + 32], + name[:31].encode().ljust(32, b"\0")) + with tarfile.open(fileobj=io.BytesIO(header)) as tar: + member = tar.next() + self.assertEqual(getattr(member, field), name) + if length > 31: + self.assertEqual(member.pax_headers[field], name) + else: + self.assertNotIn(field, member.pax_headers) + def _test(self, name, link=None): # See GNUWriteTest. tarinfo = tarfile.TarInfo(name) @@ -2442,6 +2743,35 @@ def test_pax_global_header(self): finally: tar.close() + def test_pax_global_header_empty_archive(self): + # An archive that contains only a global header and no regular + # members should be opened successfully (gh-149578). + pax_headers = {"foo": "bar"} + + # Create a PAX archive with global headers but no file entries. + with tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, + pax_headers=pax_headers): + pass + + # Reading the archive should work and preserve global headers. + with tarfile.open(tmpname) as tar: + self.assertEqual(tar.pax_headers, pax_headers) + self.assertEqual(tar.getmembers(), []) + + # Appending to the archive should work. + with tarfile.open(tmpname, "a") as tar: + self.assertEqual(tar.pax_headers, pax_headers) + self.assertEqual(tar.getmembers(), []) + tar.addfile(tarfile.TarInfo("test")) + + # Verify the appended member is present and global headers + # are preserved. + with tarfile.open(tmpname) as tar: + self.assertEqual(tar.pax_headers, pax_headers) + members = tar.getmembers() + self.assertEqual(len(members), 1) + self.assertEqual(members[0].name, "test") + def test_pax_extended_header(self): # The fields from the pax header have priority over the # TarInfo. @@ -3351,12 +3681,12 @@ def root_is_uid_gid_0(): except ImportError: return False try: - if pwd.getpwuid(0)[0] != 'root': + if pwd.getpwuid(0).pw_name != 'root': return False except KeyError: # On Cygwin, there is no root user (uid 0) return False - if grp.getgrgid(0)[0] != 'root': + if grp.getgrgid(0).gr_name != 'root': return False return True @@ -3524,6 +3854,16 @@ def test_replace_internal(self): with self.assertRaises(TypeError): member.replace(offset=123456789) + def test_copy_replace(self): + member = self.tar.getmember('ustar/regtype') + replaced = copy.replace(member, name='misc/other', mode=0o644) + self.assertEqual(replaced.name, 'misc/other') + self.assertEqual(replaced.mode, 0o644) + self.assertEqual(replaced.size, member.size) + self.assertEqual(member.name, 'ustar/regtype') + with self.assertRaises(TypeError): + copy.replace(member, offset=123456789) + class NoneInfoExtractTests(ReadTest): # These mainly check that all kinds of members are extracted successfully @@ -4025,6 +4365,61 @@ def test_absolute(self): tarfile.AbsolutePathError, """['"].*escaped.evil['"] has an absolute path""") + def test_drive_relative(self): + # Test names and link targets that have a drive but no root. + # They are not absolute, but os.path.join() does not put them + # below a destination that has no drive or another drive. + # Windows path handling is used on all platforms. + dest = r'C:\outerdir\dest' + with support.swap_attr(os, 'path', ntpath): + for name in 'C:escaped.evil', 'x/../C:escaped.evil': + for filter in tarfile.tar_filter, tarfile.data_filter: + with self.subTest(name=name, filter=filter.__name__): + with self.assertRaises(tarfile.AbsolutePathError): + filter(tarfile.TarInfo(name), dest) + + for linkname in 'C:escaped.evil', 'x/../C:escaped.evil', './C:evil': + for type in tarfile.SYMTYPE, tarfile.LNKTYPE: + with self.subTest(linkname=linkname, type=type): + member = tarfile.TarInfo('link') + member.type = type + member.linkname = linkname + with self.assertRaises(tarfile.AbsoluteLinkError): + tarfile.data_filter(member, dest) + + member = tarfile.TarInfo('x/../C/benign.txt') + member = tarfile.data_filter(member, dest) + self.assertEqual(member.name, r'C\benign.txt') + + @unittest.skipUnless(os.name == 'nt', 'requires Windows drives') + def test_drive_relative_to_cwd(self): + # Test a name like 'C:escaped.evil' with a destination that has no + # drive. The file must not be created in the current directory. + with os_helper.temp_cwd() as cwd: + drive = os.path.splitdrive(cwd)[0] + with ArchiveMaker() as arc: + arc.add(f'{drive}escaped.evil') + + for filter in 'tar', 'data': + with self.subTest(filter=filter), arc.open() as tar: + with self.assertRaises(tarfile.AbsolutePathError): + tar.extractall('dest', filter=filter) + self.assertFalse(os.path.lexists('escaped.evil')) + + def test_parent_dir_out_and_back(self): + # Test a member that leaves the destination and comes back. + # The containment check looks at the resolved path, which stays + # inside, but the intermediate directories are created from the + # name as given, which does not. + with ArchiveMaker() as arc: + arc.add(f'../escaped.evil/../{self.destdir.name}/sub/file', + content='content') + + for filter in 'tar', 'data': + with self.subTest(filter): + with self.check_context(arc.open(), filter): + self.expect_file('sub/file', content='content') + @symlink_test def test_parent_symlink(self): # Test interplaying symlinks @@ -4219,6 +4614,62 @@ def test_parent_symlink2(self): self.expect_file('current/') self.expect_file('parent/evil') + @symlink_test + def test_parent_symlink3(self): + # Test a dangling symlink reached through a symlink to a directory + + with ArchiveMaker() as arc: + + # `current` links to `.` which is both the destination directory + # and `current` itself + arc.add('current', symlink_to='.') + + # `current/link` is also available as `./link`, and points + # to a file outside the destination which does not exist yet + arc.add('current/link', symlink_to='../evil') + + # Writing through the link creates `../evil` + arc.add('current/link', content='evil') + + with self.check_context(arc.open(), 'fully_trusted'): + if os_helper.can_symlink(): + self.expect_file('current', symlink_to='.') + self.expect_file('link', symlink_to='../evil') + self.expect_file('../evil', content='evil') + else: + self.expect_file('current/link', content='evil') + + with self.check_context(arc.open(), 'tar'): + if os_helper.can_symlink(): + # Fail when extracting a file outside destination + self.expect_exception( + tarfile.OutsideDestinationError, + "'current/link' would be extracted to " + + """['"].*evil['"], which is outside """ + + "the destination") + else: + self.expect_file('current/link', content='evil') + + with self.check_context(arc.open(), 'data'): + if os_helper.can_symlink(): + if self.dotdot_resolves_early: + # 'current/../evil' normalises to 'evil', so the link is + # created; fail when extracting a file through it + self.expect_exception( + tarfile.OutsideDestinationError, + "'current/link' would be extracted to " + + """['"].*evil['"], which is outside """ + + "the destination") + else: + # Fail as soon as we have a symlink outside the destination + self.expect_exception( + tarfile.LinkOutsideDestinationError, + "'current/link' would link to " + + """['"].*evil['"], which is outside """ + + "the destination") + else: + self.expect_file('current/link', content='evil') + @symlink_test def test_absolute_symlink(self): # Test symlink to an absolute path @@ -4384,8 +4835,10 @@ def test_link_at_destination(self): t.linkname = '.' arc.tar_w.addfile(t) - with self.check_context(arc.open(), 'data'): - self.expect_exception(tarfile.OutsideDestinationError) + for filter in 'tar', 'data': + with self.subTest(name=name, filter=filter): + with self.check_context(arc.open(), filter): + self.expect_exception(tarfile.OutsideDestinationError) @symlink_test @os_helper.skip_unless_symlink @@ -4498,9 +4951,15 @@ def test_sneaky_hardlink_fallback(self): for filter in 'tar', 'fully_trusted': with self.subTest(filter), self.check_context(arc.open(), filter): if not os_helper.can_symlink(): - self.expect_file("a/t/dummy") - self.expect_file("b/") - self.expect_file("c/") + if filter == 'fully_trusted' or sys.platform == "win32": + self.expect_file("a/t/dummy") + self.expect_file("b/") + self.expect_file("c/") + else: + self.expect_exception( + tarfile.LinkFallbackError, + "link 'boom' would be extracted as a copy of " + + "'c/escape', which was rejected") else: self.expect_file("a/t/dummy") self.expect_file("b/") @@ -4532,6 +4991,51 @@ def test_sneaky_hardlink_fallback_deep(self): self.expect_file("a/b/s", symlink_to=os.path.join('..', 'escape')) self.expect_file("s", symlink_to=os.path.join('..', 'escape')) + @symlink_test + def test_sneaky_hardlink_fallback_attrs(self): + # Test that when a hardlink is extracted as a copy of a symlink + # member, the hardlink's attributes are not applied to the file + # the symlink points to. + with ArchiveMaker() as arc: + arc.add("a/s", symlink_to=os.path.join("..", "flag")) + arc.add("s", hardlink_to=os.path.join("a", "s"), + mode='-rwxr-xr-x', mtime=86400, uid=1337, gid=1337) + + for filter in 'tar', 'fully_trusted': + with ( + self.subTest(filter), + unittest.mock.patch("os.chown", create=True) as mock_chown, + self.check_context(arc.open(), filter) as cc, + ): + if not os_helper.can_symlink(): + self.expect_file("a/") + else: + self.expect_file("a/s", symlink_to=os.path.join('..', 'flag')) + self.expect_file("s", symlink_to=os.path.join('..', 'flag')) + st = (cc.outerdir / 'flag').stat() + self.assertNotEqual(st.st_mtime, 86400) + if sys.platform != "win32": + self.assertNotEqual(st.st_mode & 0o777, 0o755) + mock_chown.assert_not_called() + + @symlink_test + @os_helper.skip_unless_hardlink + def test_sneaky_hardlink_relocation(self): + with ArchiveMaker() as arc: + arc.add("a/escape", content="decoy") + arc.add("a/b/s", symlink_to=os.path.join("..", "escape")) + arc.add("s", hardlink_to=os.path.join("a", "b", "s")) + + for filter in 'data', 'tar': + with self.subTest(filter), self.check_context(arc.open(), filter): + self.expect_file("a/escape", content="decoy") + if os_helper.can_symlink(): + self.expect_file("a/b/s", symlink_to=os.path.join('..', 'escape')) + else: + self.expect_file("a/b/s", content="decoy") + self.expect_file("s", content="decoy") + self.assertFalse((self.destdir / "s").is_symlink()) + @symlink_test def test_exfiltration_via_symlink(self): # (CVE-2025-4138) @@ -4679,6 +5183,25 @@ def testing_filter(member, path): if os_helper.can_chmod(): self.assertFalse(path.stat().st_mode & stat.S_IWUSR) + @symlink_test + def test_extract_filters_target_none(self): + # Test that when extract() falls back to extracting (rather than + # linking) a hardlink target, the member is skipped if the filter + # returns None. + with ArchiveMaker() as arc: + arc.add('a/b/s', symlink_to='../escape') + arc.add('q', hardlink_to='a/b/s') + def filter_unsafe_members(member, path): + try: + return tarfile.data_filter(member, path) + except tarfile.FilterError as error: + return None + with self.check_context(arc.open(), filter_unsafe_members): + if os_helper.can_symlink(): + self.expect_file('a/b/s', symlink_to='../escape') + else: + self.expect_file('a/b/') # symlink is not extracted + def test_link_fallback_normalizes(self): # Make sure hardlink fallbacks work for non-normalized paths for all # filters @@ -5247,13 +5770,11 @@ def test_ignore_invalid_offset_headers(self): class TestModule(unittest.TestCase): - def test_deprecated_version(self): - with self.assertWarnsRegex( - DeprecationWarning, - "'version' is deprecated and slated for removal in Python 3.20", - ) as cm: - getattr(tarfile, "version") - self.assertEqual(cm.filename, __file__) + def test_deprecated_module_attributes(self): + support.check_deprecated_module_attributes( + self, tarfile, "version", "__author__", "__credits__", + remove=(3, 20), + ) def setUpModule(): diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py index 26be4ee0d7afe44..46a18f727e40d27 100644 --- a/Lib/test/test_tcl.py +++ b/Lib/test/test_tcl.py @@ -2,9 +2,12 @@ import subprocess import sys import os +import threading from test import support from test.support import import_helper from test.support import os_helper +from test.support import threading_helper +from test.support.isolation import runInSubprocess # Skip this test if the _tkinter module wasn't built. _tkinter = import_helper.import_module('_tkinter') @@ -33,6 +36,29 @@ def testFlattenLen(self): self.assertRaises(TypeError, _tkinter._flatten, 'string') self.assertRaises(TypeError, _tkinter._flatten, {'set'}) + @unittest.skipUnless(support.Py_GIL_DISABLED, + 'requires the free-threaded build') + @threading_helper.requires_working_threading() + @runInSubprocess() + def test_create_concurrent(self): + # gh-154923: Create Tcl interpreters in different threads at once. + # Run in a fresh process, where no interpreter was created yet. + nthreads = 16 + start = threading.Barrier(nthreads) + errors = [] + def worker(): + try: + start.wait() + for _ in range(8): + _tkinter.create(None, '', 'Tk', False, 1, False, False, + None) + except Exception as e: + errors.append(e) + threads = [threading.Thread(target=worker) for _ in range(nthreads)] + with threading_helper.start_threads(threads): + pass + self.assertEqual(errors, []) + class TclTest(unittest.TestCase): @@ -565,6 +591,65 @@ class List(list): self.assertEqual(self.passValue(values := [Value(), "pad"]), expect) self.assertEqual(self.passValue(values := List([Value(), "pad"])), expect) + def test_passing_deeply_nested(self): + call = self.interp.tk.call + setvar = self.interp.tk.setvar + for wrap in (lambda x: [x]), (lambda x: (x,)): + value = 'a' + for i in range(1001): + value = wrap(value) + self.assertEqual(int(call('string', 'length', value)), 1) + value = wrap(value) + self.assertRaises(ValueError, call, 'set', '_', value) + self.assertRaises(ValueError, setvar, '_', value) + for i in range(support.exceeds_recursion_limit()): + value = wrap(value) + self.assertRaises(ValueError, call, 'set', '_', value) + self.assertRaises(ValueError, setvar, '_', value) + value = ['a', 1] + value.append(value) + self.assertRaises(ValueError, call, 'set', '_', value) + self.assertRaises(ValueError, setvar, '_', value) + + @support.run_with_limited_c_stack() + def test_returning_deeply_nested(self): + if not self.wantobjects: + self.skipTest('requires wantobjects') + # run_with_limited_c_stack() runs the test in a new thread, and a + # Tcl interpreter can only be used in the thread that created it. + interp = Tcl() + interp.eval('set x a; for {set i 0} {$i < %d} {incr i} {set x [list $x]}' + % support.exceeds_recursion_limit()) + self.assertRaises(RecursionError, interp.getvar, 'x') + interp = None + + # gh-161353: Clean up explicitly per-thread state to avoid leaking an + # event handle on Windows when test_tcl is run with -R 3:3 option. + _tkinter._finalize_thread() + + def test_setvar_evil(self): + # gh-161388 + class StrRaises: + def __str__(self): + raise RuntimeError("setvar evil") + + value = StrRaises() + tk = self.interp.tk + + with self.assertRaisesRegex(RuntimeError, "setvar evil"): + tk.setvar("local_name1", value) + self.assertRaises(TclError, tk.getvar, "local_name1") + with self.assertRaisesRegex(RuntimeError, "setvar evil"): + tk.setvar("local_name2", "local_name3", value) + self.assertRaises(TclError, tk.getvar, "local_name2", "local_name3") + + with self.assertRaisesRegex(RuntimeError, "setvar evil"): + tk.globalsetvar("global_name1", value) + self.assertRaises(TclError, tk.globalgetvar, "global_name1") + with self.assertRaisesRegex(RuntimeError, "setvar evil"): + tk.globalsetvar("global_name2", "global_name3", value) + self.assertRaises(TclError, tk.globalgetvar, "global_name2", "global_name3") + def test_user_command(self): result = None def testfunc(arg): @@ -805,7 +890,7 @@ def test_huge_string_call(self, size): @support.cpython_only @unittest.skipUnless(INT_MAX < PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX") - @support.bigmemtest(size=INT_MAX + 1, memuse=2, dry_run=False) + @support.bigmemtest(size=INT_MAX + 1, memuse=3, dry_run=False) def test_huge_string_builtins(self, size): tk = self.interp.tk value = '1' + ' ' * size diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py index e33cc65e090e3b4..3e87ccfc436d121 100644 --- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -14,6 +14,7 @@ import gc import shutil import subprocess +import sysconfig from unittest import mock import unittest @@ -1652,10 +1653,14 @@ def __exit__(self, *exc_info): class TestTemporaryDirectory(BaseTestCase): """Test TemporaryDirectory().""" - def do_create(self, dir=None, pre="", suf="", recurse=1, dirs=1, files=1, + def do_create(self, dir=None, pre=None, suf=None, recurse=1, dirs=1, files=1, ignore_cleanup_errors=False): if dir is None: dir = tempfile.gettempdir() + if pre is None: + pre = type(dir)() + if suf is None: + suf = type(dir)() tmp = tempfile.TemporaryDirectory( dir=dir, prefix=pre, suffix=suf, ignore_cleanup_errors=ignore_cleanup_errors) @@ -1665,13 +1670,17 @@ def do_create(self, dir=None, pre="", suf="", recurse=1, dirs=1, files=1, def do_create2(self, path, recurse=1, dirs=1, files=1): # Create subdirectories and some files + def join(name): + if isinstance(path, bytes): + name = os.fsencode(name) + return os.path.join(path, name) if recurse: for i in range(dirs): - name = os.path.join(path, "dir%d" % i) + name = join("dir%d" % i) os.mkdir(name) self.do_create2(name, recurse-1, dirs, files) for i in range(files): - with open(os.path.join(path, "test%d.txt" % i), "wb") as f: + with open(join("test%d.txt" % i), "wb") as f: f.write(b"Hello world!") def test_mkdtemp_failure(self): @@ -1697,6 +1706,15 @@ def test_explicit_cleanup(self): finally: os.rmdir(dir) + def test_explicit_cleanup_bytes(self): + # A TemporaryDirectory with a bytes name is deleted when cleaned up + with tempfile.TemporaryDirectory() as working_dir: + d = self.do_create(dir=os.fsencode(working_dir), recurse=2) + self.assertIsInstance(d.name, bytes) + self.assertTrue(os.path.exists(d.name)) + d.cleanup() + self.assertFalse(os.path.exists(d.name)) + def test_explicit_cleanup_ignore_errors(self): """Test that cleanup doesn't return an error when ignoring them.""" with tempfile.TemporaryDirectory() as working_dir: @@ -1861,6 +1879,135 @@ def test(target, target_is_directory): new_flags = os.stat(dir1).st_flags self.assertEqual(new_flags, old_flags) + @os_helper.skip_unless_symlink + @os_helper.skip_unless_working_chmod + @support.requires_non_root_user + @unittest.skipIf(support.is_emscripten, 'Fails due to Emscripten bug:' + 'emscripten-core/emscripten#27761') + @unittest.skipUnless(shutil.rmtree.avoids_symlink_attacks, + 'requires the fd based implementation of rmtree()') + def test_cleanup_with_symlink_race(self): + # cleanup() should not operate on files outside of the temporary + # directory when a directory is replaced with a symlink while it + # recovers from a PermissionError (CVE-2026-12345). + with self.do_create(recurse=0) as target: + target_file = os.path.join(target, 'file1') + open(target_file, 'wb').close() + target_mode = os.stat(target_file).st_mode + + d1 = self.do_create(recurse=0) + dir1 = os.path.join(d1.name, 'dir1') + os.mkdir(dir1) + open(os.path.join(dir1, 'file1'), 'wb').close() + # Removing contents of dir1 fails with a PermissionError, and + # dir1 is replaced with a symlink to target at the very moment + # cleanup() starts to recover from that error. + os.chmod(dir1, 0o500) + unlink = os.unlink + def hook(path, *, dir_fd=None): + try: + return unlink(path, dir_fd=dir_fd) + except PermissionError: + if not os.path.islink(dir1): + os.chmod(dir1, 0o700) + os.rename(dir1, dir1 + '_moved') + os.symlink(target, dir1) + raise + try: + with mock.patch('os.unlink', hook): + with contextlib.suppress(OSError): + d1.cleanup() + finally: + if os.path.islink(dir1): + os.unlink(dir1) + os.rename(dir1 + '_moved', dir1) + os.chmod(dir1, 0o700) + d1.cleanup() + + self.assertTrue(os.path.exists(target_file)) + self.assertEqual(os.stat(target_file).st_mode, target_mode) + + def _make_unopenable_subdir(self): + # Create the following structure: + # work/ - top-level + # / - tempdir to clean up (random name) + # sub/ - an unopenable dir + # subsub/ + # file + # Return: + # - `work` name (str) + # - `d` (TemporaryDirectory) + # - `subsub` stat result + work = self.enterContext(os_helper.temp_dir()) + d = tempfile.TemporaryDirectory(dir=work) + sub = os.path.join(d.name, 'sub') + subsub = os.path.join(sub, 'subsub') + os.mkdir(sub) + os.mkdir(subsub) + subsub_stat = os.lstat(subsub) + with open(os.path.join(subsub, 'file'), 'w') as f: + f.write("rm me pls") + os.chmod(sub, 0) + # If the test fails, make sure everything can still be removed. + self.addCleanup(d.cleanup) + @self.addCleanup + def _clean(): + if os.path.isdir(sub): + os.chmod(sub, 0o700) + return work, d, subsub_stat + + @os_helper.skip_unless_working_chmod + @support.requires_non_root_user + @unittest.skipUnless(tempfile._rmtree_use_dir_fd + and shutil.rmtree.avoids_symlink_attacks, + 'requires the fd based cleanup') + def test_cleanup_nested_toplevel_error(self): + # rmtree() reports errors relative to the correct parent directory + work, d, subsub_stat = self._make_unopenable_subdir() + # An unrelated directory with the same name; should not be touched + unrelated = os.path.join(work, 'sub') + os.mkdir(unrelated) + + rmdir = os.rmdir + failed_path = None + def failing_rmdir(path, *, dir_fd=None): + nonlocal failed_path + if path == 'sub' and dir_fd is not None and failed_path is None: + failed_path = path + raise PermissionError(errno.EPERM, 'simulated', path) + return rmdir(path, dir_fd=dir_fd) + with os_helper.change_cwd(work), mock.patch('os.rmdir', failing_rmdir): + d.cleanup() + self.assertEqual(failed_path, 'sub') + self.assertFalse(os.path.exists(d.name)) + self.assertTrue(os.path.exists(unrelated)) + + @os_helper.skip_unless_working_chmod + @support.requires_non_root_user + @unittest.skipUnless(tempfile._rmtree_use_dir_fd + and shutil.rmtree.avoids_symlink_attacks, + 'requires the fd based cleanup') + def test_cleanup_nested_scandir_error(self): + # A scandir() error is reported relative to the parent directory. + work, d, subsub_stat = self._make_unopenable_subdir() + + scandir = os.scandir + failed = False + def failing_scandir(path='.'): + nonlocal failed + if ( + not failed + and isinstance(path, int) + and os.path.samestat(os.fstat(path), subsub_stat) + ): + failed = True + raise PermissionError(errno.EACCES, 'simulated') + return scandir(path) + with os_helper.change_cwd(work), mock.patch('os.scandir', failing_scandir): + d.cleanup() + self.assertTrue(failed) + self.assertFalse(os.path.exists(d.name)) + @support.cpython_only def test_del_on_collection(self): # A TemporaryDirectory is deleted when garbage collected @@ -2019,11 +2166,17 @@ def test_context_manager(self): self.assertEqual(name, d.name) self.assertFalse(os.path.exists(name)) - def test_modes(self): + @support.subTests('bytes_name', (False, True)) + def test_modes(self, bytes_name): for mode in range(8): mode <<= 6 with self.subTest(mode=format(mode, '03o')): - d = self.do_create(recurse=3, dirs=2, files=2) + if bytes_name: + d = self.do_create(recurse=3, dirs=2, files=2, + dir=tempfile.gettempdirb()) + else: + d = self.do_create(recurse=3, dirs=2, files=2) + self.assertIsInstance(d.name, bytes if bytes_name else str) with d: # Change files and directories mode recursively. for root, dirs, files in os.walk(d.name, topdown=False): @@ -2033,6 +2186,33 @@ def test_modes(self): d.cleanup() self.assertFalse(os.path.exists(d.name)) + @support.subTests('ignore_errors', (True, False)) + @support.subTests('bytes_name', (False, True)) + def test_parent_mode_preserved(self, ignore_errors, bytes_name): + # Test that cleanup does not touch the parent directory, + # even if that prevents removal. + for mode in range(8): + mode <<= 6 + with self.subTest(mode=format(mode, '03o')): + if bytes_name: + outer = self.do_create(dir=tempfile.gettempdirb()) + else: + outer = self.do_create() + with outer: + d = self.do_create(dir=outer.name, dirs=2, files=2, + ignore_cleanup_errors=ignore_errors) + with d: + os.chmod(outer.name, mode) + orig_mode = os.stat(outer.name).st_mode + try: + d.cleanup() + except PermissionError: + if ignore_errors: + raise + self.assertEqual(os.stat(outer.name).st_mode, orig_mode) + outer.cleanup() + self.assertFalse(os.path.exists(outer.name)) + def check_flags(self, flags): # skip the test if these flags are not supported (ex: FreeBSD 13) filename = os_helper.TESTFN @@ -2070,5 +2250,58 @@ def test_delete_false(self): self.assertTrue(os.path.exists(working_dir)) shutil.rmtree(working_dir) + @unittest.skipUnless( + sysconfig.get_config_var('PY_SUPPORT_TIER') + and sysconfig.get_config_var('PY_SUPPORT_TIER') <= 3, + 'regression test for supported platforms') + @unittest.skipIf(support.MS_WINDOWS, 'dirfd not used on Windows') + @unittest.skipIf(support.is_wasi, 'WASI has no chmod') + def test_cleanup_safe(self): + """Verify that cleanup uses the safer code path""" + # This is a regression test. Feel free to add exceptions for new + # platforms, but don't forget to update the docs. + self.assertTrue(tempfile._rmtree_use_dir_fd) + + +class TestMisc(BaseTestCase): + def test_prefix_suffix_error(self): + tests = [ + f"dir{os.sep}name", + f"{os.sep}abs_name", + ] + if os.altsep is not None: + tests.extend(( + f"dir{os.altsep}name", + f"{os.altsep}abs_name", + )) + if support.MS_WINDOWS: + tests.append('C:name') + tests.extend(tuple(os.fsencode(path) for path in tests)) + + PREFIX_ERR = "prefix can't contain a directory component" + SUFFIX_ERR = "suffix can't contain a directory component" + for value in tests: + with self.subTest(value): + # test prefix + with self.assertRaisesRegex(ValueError, PREFIX_ERR): + tempfile.mkstemp(prefix=value) + with self.assertRaisesRegex(ValueError, PREFIX_ERR): + tempfile.mkdtemp(prefix=value) + with self.assertRaisesRegex(ValueError, PREFIX_ERR): + tempfile.TemporaryFile(prefix=value) + with self.assertRaisesRegex(ValueError, PREFIX_ERR): + tempfile.NamedTemporaryFile(prefix=value) + + # test suffix + with self.assertRaisesRegex(ValueError, SUFFIX_ERR): + tempfile.mkstemp(suffix=value) + with self.assertRaisesRegex(ValueError, SUFFIX_ERR): + tempfile.mkdtemp(suffix=value) + with self.assertRaisesRegex(ValueError, SUFFIX_ERR): + tempfile.TemporaryFile(suffix=value) + with self.assertRaisesRegex(ValueError, SUFFIX_ERR): + tempfile.NamedTemporaryFile(suffix=value) + + if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_termios.py b/Lib/test/test_termios.py index 3dcf5bd13791dc1..2739b990e0906e5 100644 --- a/Lib/test/test_termios.py +++ b/Lib/test/test_termios.py @@ -117,7 +117,7 @@ def test_tcsetattr_errors(self): @support.skip_android_selinux('tcsendbreak') def test_tcsendbreak(self): with skip_enotty_error(self, 'tcsendbreak', - ('freebsd', 'netbsd', 'cygwin')): + ('freebsd', 'netbsd', 'openbsd', 'dragonfly', 'cygwin')): termios.tcsendbreak(self.fd, 1) termios.tcsendbreak(self.stream, 1) @@ -194,6 +194,9 @@ def test_tcflow(self): termios.tcflow(self.fd, termios.TCOON) termios.tcflow(self.fd, termios.TCIOFF) termios.tcflow(self.fd, termios.TCION) + # Discard the transmitted STOP and START characters, + # otherwise closing the pseudo-terminal can block. + termios.tcflush(self.fd, termios.TCOFLUSH) @support.skip_android_selinux('tcflow') def test_tcflow_errors(self): diff --git a/Lib/test/test_thread_local_bytecode.py b/Lib/test/test_thread_local_bytecode.py index 6a1ae4064b5daf1..6f76f1bc33561fb 100644 --- a/Lib/test/test_thread_local_bytecode.py +++ b/Lib/test/test_thread_local_bytecode.py @@ -108,7 +108,6 @@ def f(a, b, q=None): """) assert_python_ok("-X", "tlbc=1", "-c", code) - @support.skip_if_sanitizer("gh-129752: data race on adaptive counter", thread=True) def test_no_copies_if_tlbc_disabled(self): code = textwrap.dedent(""" import queue diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index 3d01804513bde98..96b43936be92cda 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -326,9 +326,13 @@ def f(mutex): @cpython_only def test_PyThreadState_SetAsyncExc(self): ctypes = import_module("ctypes") + import ctypes.util # noqa: F811 - set_async_exc = ctypes.pythonapi.PyThreadState_SetAsyncExc - set_async_exc.argtypes = (ctypes.c_ulong, ctypes.py_object) + @ctypes.util.wrap_dll_function(ctypes.pythonapi) + def PyThreadState_SetAsyncExc(id: ctypes.c_ulong, + exc: ctypes.py_object) -> ctypes.c_int: + pass + set_async_exc = PyThreadState_SetAsyncExc class AsyncExc(Exception): pass @@ -485,7 +489,17 @@ def test_finalize_running_thread(self): import_module("ctypes") rc, out, err = assert_python_failure("-c", """if 1: - import ctypes, sys, time, _thread + import ctypes.util, sys, time, _thread + + PyGILState_STATE = ctypes.c_int # enum + + @ctypes.util.wrap_dll_function(ctypes.pythonapi) + def PyGILState_Ensure() -> PyGILState_STATE: + pass + + @ctypes.util.wrap_dll_function(ctypes.pythonapi) + def PyGILState_Release(oldstate: PyGILState_STATE) -> None: + pass # This lock is used as a simple event variable. ready = _thread.allocate_lock() @@ -494,8 +508,8 @@ def test_finalize_running_thread(self): # Module globals are cleared before __del__ is run # So we save the functions in class dict class C: - ensure = ctypes.pythonapi.PyGILState_Ensure - release = ctypes.pythonapi.PyGILState_Release + ensure = PyGILState_Ensure + release = PyGILState_Release def __del__(self): state = self.ensure() self.release(state) diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index 985984b55123ce6..861076357e0019a 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -21,10 +21,11 @@ from test.support import skip_if_buggy_ucrt_strfptime, SuppressCrashReport -# Max year is only limited by the size of C int. +# Years are limited by the range of struct tm's int tm_year field. SIZEOF_INT = sysconfig.get_config_var('SIZEOF_INT') or 4 -TIME_MAXYEAR = (1 << 8 * SIZEOF_INT - 1) - 1 -TIME_MINYEAR = -TIME_MAXYEAR - 1 + 1900 +C_INT_MAX = (1 << 8 * SIZEOF_INT - 1) - 1 +TIME_MAXYEAR = C_INT_MAX + 1900 +TIME_MINYEAR = -C_INT_MAX - 1 + 1900 SEC_TO_US = 10 ** 6 US_TO_NS = 10 ** 3 @@ -153,6 +154,23 @@ def test_clock_settime(self): self.assertRaises(OSError, time.clock_settime, time.CLOCK_MONOTONIC, 0) + def test_large_timestamp_year(self): + # 2147483648-06-29 00:00:00 UTC, away from local year boundaries. + timestamp = 67_767_976_249_084_800 + for convert in (time.gmtime, time.localtime, time.ctime): + with self.subTest(convert=convert): + try: + result = convert(timestamp) + except (OverflowError, OSError): + self.skipTest('timestamp out of range on this platform') + if isinstance(result, str): + year = int(result.rsplit(' ', 1)[-1]) + else: + year = result.tm_year + self.assertEqual(year, 2**31) + if convert is time.localtime: + self.assertEqual(time.asctime(result), time.ctime(timestamp)) + def test_conversions(self): self.assertEqual(time.ctime(self.t), time.asctime(time.localtime(self.t))) @@ -371,6 +389,64 @@ def test_strptime(self): self.fail("conversion specifier %r failed with '%s' input." % (format, strf_output)) + def test_strptime_whitespace(self): + whitespace = (' ', '\t\n\r\v\f', '\x1c', '\xa0', '\u2003', '\u202f') + for input_space in whitespace: + for format_space in whitespace: + with self.subTest(input_space=input_space, + format_space=format_space): + text = input_space.join(('2024-02-29', '12:34:56')) + fmt = format_space.join(('%Y-%m-%d', '%H:%M:%S')) + self.assertEqual(time.strptime(text, fmt), + (2024, 2, 29, 12, 34, 56, 3, 60, -1)) + + def test_strptime_whitespace_before_adjacent_fields(self): + for separator in ('\x1c', '\x1d', '\x1e', '\x1f'): + with self.subTest(separator=separator): + text = f'2024{separator} 112 34{separator} 123' + fmt = f'%Y{separator}%d%m %M{separator}%H%S' + self.assertEqual(time.strptime(text, fmt), + (2024, 2, 11, 12, 34, 3, 6, 42, -1)) + + def test_strptime_numeric_calendar(self): + cases = ( + ('0001-01-01', 1, 1, 1, 0, 1), + ('1900-03-01', 1900, 3, 1, 3, 60), + ('2000-02-29', 2000, 2, 29, 1, 60), + ('2000-03-01', 2000, 3, 1, 2, 61), + ('2024-12-31', 2024, 12, 31, 1, 366), + ('2100-03-01', 2100, 3, 1, 0, 60), + ('9999-12-31', 9999, 12, 31, 4, 365), + ) + for text, year, month, day, weekday, yday in cases: + with self.subTest(text=text): + result = time.strptime(text, '%Y-%m-%d') + self.assertIs(type(result), time.struct_time) + self.assertEqual(result, + (year, month, day, 0, 0, 0, weekday, yday, -1)) + self.assertIsNone(result.tm_zone) + self.assertIsNone(result.tm_gmtoff) + + def test_strptime_numeric_offset(self): + for text, offset in (('', None), ('Z', 0), ('+0000', 0), + ('-00:00', 0), ('+0530', 19800), + ('-03:30', -12600), ('+2359', 86340), + ('+01:02:03.456', 3723)): + with self.subTest(text=text): + result = time.strptime('12:34:56.123' + text, '%H:%M:%S.%f%z') + self.assertEqual(result, (1900, 1, 1, 12, 34, 56, 0, 1, -1)) + self.assertIsNone(result.tm_zone) + self.assertEqual(result.tm_gmtoff, offset) + + @support.run_with_locale('LC_TIME', 'C') + def test_strptime_default_format(self): + self.assertEqual(time.strptime('Thu Feb 29 12:34:56 2024'), + (2024, 2, 29, 12, 34, 56, 3, 60, -1)) + for args in ((), ('2024', '%Y', 'extra'), (None, '%Y')): + with self.subTest(args=args): + with self.assertRaises(TypeError): + time.strptime(*args) + def test_strptime_bytes(self): # Make sure only strings are accepted as arguments to strptime. self.assertRaises(TypeError, time.strptime, b'2009', "%Y") @@ -398,7 +474,7 @@ def test_strptime_leap_year(self): def test_asctime(self): time.asctime(time.gmtime(self.t)) - # Max year is only limited by the size of C int. + # The year offset must fit into a C int. for bigyear in TIME_MAXYEAR, TIME_MINYEAR: asc = time.asctime((bigyear, 6, 1) + (0,) * 6) self.assertEqual(asc[-len(str(bigyear)):], str(bigyear)) @@ -486,8 +562,8 @@ def test_tzset(self): # on some operating systems (e.g. FreeBSD), which is wrong. See for # example this bug: # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=93810 - self.assertIn(time.tzname[0], ('AEST' 'EST'), time.tzname[0]) - self.assertTrue(time.tzname[1] in ('AEDT', 'EDT'), str(time.tzname[1])) + self.assertIn(time.tzname[0], ('AEST', 'EST')) + self.assertIn(time.tzname[1], ('AEDT', 'EDT')) self.assertEqual(len(time.tzname), 2) self.assertEqual(time.daylight, 1) self.assertEqual(time.timezone, -36000) @@ -769,7 +845,7 @@ def test_year(self, fmt=None, func=None): def test_large_year(self): self.assertEqual(self.yearstr(12345).lstrip('+'), '12345') self.assertEqual(self.yearstr(123456789).lstrip('+'), '123456789') - self.assertEqual(self.yearstr(TIME_MAXYEAR).lstrip('+'), str(TIME_MAXYEAR)) + self.assertEqual(self.yearstr(C_INT_MAX).lstrip('+'), str(C_INT_MAX)) self.assertRaises(OverflowError, self.yearstr, TIME_MAXYEAR + 1) def test_negative(self): diff --git a/Lib/test/test_tkinter/support.py b/Lib/test/test_tkinter/support.py index 31feee2b8a40ee6..8d4ad2345a16510 100644 --- a/Lib/test/test_tkinter/support.py +++ b/Lib/test/test_tkinter/support.py @@ -61,6 +61,16 @@ def require_mapped(self, widget, timeout=None): f'(timed out after {timeout:g}s)') +class AbstractDialogTest(AbstractTkTest): + # Tk delivers generated keyboard events to the focused window. Hide the + # root window, otherwise the window manager can take the focus back from + # the dialog (gh-154357). + + def setUp(self): + super().setUp() + self.root.withdraw() + + class AbstractDefaultRootTest: def setUp(self): @@ -112,6 +122,7 @@ def wait_until_mapped(widget, timeout=None, *, full_size=False): timeout = support.LOOPBACK_TIMEOUT deadline = time.monotonic() + timeout widget.update_idletasks() + reset = False while True: widget.update() # drain pending Map/Configure events if widget.winfo_ismapped(): @@ -123,6 +134,11 @@ def wait_until_mapped(widget, timeout=None, *, full_size=False): h_ok = widget.winfo_height() > 1 if w_ok and h_ok: return True + if full_size and not reset: + # Tk no longer resizes the toplevel to fit its content if + # the window manager has resized it. Undo this. + widget.winfo_toplevel().wm_geometry('') + reset = True if time.monotonic() >= deadline: return False time.sleep(0.01) diff --git a/Lib/test/test_tkinter/test_filedialog.py b/Lib/test/test_tkinter/test_filedialog.py index f65ed19895a1ed4..2df77c0e23e92d8 100644 --- a/Lib/test/test_tkinter/test_filedialog.py +++ b/Lib/test/test_tkinter/test_filedialog.py @@ -6,7 +6,7 @@ from tkinter.commondialog import Dialog from test.support import requires, swap_attr from test.test_tkinter.support import setUpModule # noqa: F401 -from test.test_tkinter.support import AbstractTkTest +from test.test_tkinter.support import AbstractDialogTest, AbstractTkTest requires('gui') @@ -72,7 +72,7 @@ def test_results_preserved(self): ('/a', '/b')) -class FileDialogTest(AbstractTkTest, unittest.TestCase): +class FileDialogTest(AbstractDialogTest, unittest.TestCase): # The pure-Python FileDialog runs its own modal loop in go(); its logic is # exercised here without entering the loop. @@ -164,8 +164,8 @@ def test_alt_key(self): d = self.open() invoked = [] d.cancel_button.configure(command=lambda: invoked.append(True)) - d.top.focus_force() d.top.update() + d.top.focus_force() d.top.event_generate('') # "&Cancel" d.top.update() self.assertTrue(invoked) @@ -174,8 +174,8 @@ def test_escape_cancels(self): # The Escape key cancels the dialog. d = self.open() d.how = 'spam' - d.top.focus_force() d.top.update() + d.top.focus_force() d.top.event_generate('') d.top.update() self.assertIsNone(d.how) @@ -195,8 +195,10 @@ def test_type_ahead(self): d.files.delete(0, 'end') for name in ('alpha', 'bravo', 'charlie'): d.files.insert('end', name) - d.files.focus_force() d.top.update() + # Force the focus right before generating the event: the window + # manager can take it back. + d.files.focus_force() d.files.event_generate('', keysym='c') d.top.update() sel = d.files.curselection() diff --git a/Lib/test/test_tkinter/test_font.py b/Lib/test/test_tkinter/test_font.py index 3d76ae630d97e38..4217bed966131b2 100644 --- a/Lib/test/test_tkinter/test_font.py +++ b/Lib/test/test_tkinter/test_font.py @@ -2,6 +2,7 @@ import unittest import tkinter from tkinter import font +from test import support from test.support import requires, gc_collect, ALWAYS_EQ from test.test_tkinter.support import setUpModule # noqa: F401 from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest @@ -24,6 +25,16 @@ def actual_size(self, desc): # The requested size is not always available (e.g. bitmap fonts). return self.root.tk.call('font', 'actual', desc, '-size') + def tcl_font_object(self, desc): + # Return a font name or description as a Tcl object representing a + # font, as Tk returns for example from ttk.Style().lookup(). + tk = self.root.tk + tk.call('set', '_font', desc) + tk.eval('font measure $_font x') # convert the Tcl object to a font + obj = tk.call('set', '_font') + tk.call('unset', '_font') + return obj + def test_configure(self): self.assertEqual(self.font.config, self.font.configure) options = self.font.configure() @@ -150,6 +161,36 @@ def test_existing(self): # A name or a description is required. self.assertRaises(TypeError, font.Font, root=self.root, exists=True) + def test_tcl_object(self): + # Tk can return a font as a Tcl object (gh-156961). + if not self.wantobjects: + self.skipTest('Tcl objects are converted to strings') + obj = self.tcl_font_object(fontname) + self.assertEqual(obj.typename, 'font') + + # It can be used as the name of an existing named font. + for f in (font.Font(root=self.root, name=obj, exists=True), + font.nametofont(obj, root=self.root)): + # The Tcl object is kept as is, so that it is passed back to Tk. + self.assertIs(f.name, obj) + self.assertEqual(str(f), fontname) + self.assertEqual(f.actual(), self.font.actual()) + self.assertEqual(f, self.font) + self.assertEqual(self.font, f) + # Referring to a non-existent named font still fails. + self.assertRaisesRegex(tkinter.TclError, 'named font nosuchfont', + font.Font, root=self.root, exists=True, + name=self.tcl_font_object('nosuchfont')) + + # It can also be wrapped as a font description. + obj = self.tcl_font_object(('Times', 20, 'bold')) + f = font.Font(root=self.root, font=obj, exists=True) + self.assertIs(f.name, obj) + self.assertEqual(str(f), 'Times 20 bold') + self.assertNotIn(f.name, font.names(self.root)) + self.assertEqual(f.actual('weight'), 'bold') + self.assertEqual(f.actual('size'), self.actual_size(('Times', 20, 'bold'))) + def test_copy(self): # size=-20 (pixels): copy() copies the configured options, so the # size is preserved rather than resolved (gh-143990). @@ -209,11 +250,6 @@ def test_equality(self): self.assertEqual(w1, w2) w3 = font.Font(root=self.root, font=('Times', 12), exists=True) self.assertNotEqual(w1, w3) - # A wrapped description never equals a named font, even one whose name - # is the string form of the description. - named = font.Font(root=self.root, name=str(w1), family='Courier') - self.assertNotEqual(w1, named) - self.assertNotEqual(named, w1) self.assertNotEqual(font1, 0) self.assertEqual(font1, ALWAYS_EQ) @@ -324,13 +360,10 @@ def test_nametofont(self): class TestModule(unittest.TestCase): - def test_deprecated__version__(self): - with self.assertWarnsRegex( - DeprecationWarning, - "'__version__' is deprecated and slated for removal in Python 3.20", - ) as cm: - getattr(font, "__version__") - self.assertEqual(cm.filename, __file__) + def test_deprecated_module_attributes(self): + support.check_deprecated_module_attributes( + self, font, "__version__", remove=(3, 20), + ) if __name__ == "__main__": diff --git a/Lib/test/test_tkinter/test_geometry_managers.py b/Lib/test/test_tkinter/test_geometry_managers.py index e98a6af060e80bc..1823d7a58ad5ba4 100644 --- a/Lib/test/test_tkinter/test_geometry_managers.py +++ b/Lib/test/test_tkinter/test_geometry_managers.py @@ -5,7 +5,7 @@ from test.support import requires from test.test_tkinter.support import setUpModule # noqa: F401 -from test.test_tkinter.support import pixels_conv +from test.test_tkinter.support import pixels_conv, get_tk_patchlevel from test.test_tkinter.widget_tests import AbstractWidgetTest requires('gui') @@ -233,8 +233,8 @@ def test_pack_forget(self): def test_pack_info(self): pack, a, b, c, d = self.create2() - with self.assertRaisesRegex(TclError, 'window "%s" isn\'t packed' % a): - a.pack_info() + if get_tk_patchlevel(self.root) >= (9, 1, 1): + self.assertEqual(a.pack_info(), {}) a.pack_configure() b.pack_configure(side='right', in_=a, anchor='s', expand=True, fill='x', ipadx=5, padx=10, ipady=2, pady=(5, 15)) diff --git a/Lib/test/test_tkinter/test_misc.py b/Lib/test/test_tkinter/test_misc.py index a225079dd99091b..7978a8d5e3eeff1 100644 --- a/Lib/test/test_tkinter/test_misc.py +++ b/Lib/test/test_tkinter/test_misc.py @@ -3,24 +3,74 @@ import os import gc import platform +import signal import sys import textwrap +import threading import time import unittest import weakref +import _tkinter import tkinter from tkinter import TclError, ttk import enum from test import support +from test.support import import_helper from test.support import os_helper +from test.support import threading_helper +from test.support.isolation import runInSubprocess from test.support.script_helper import assert_python_ok from test.test_tkinter.support import setUpModule # noqa: F401 from test.test_tkinter.support import (AbstractTkTest, AbstractDefaultRootTest, requires_tk, get_tk_patchlevel, - tcl_version, tk_version) + tcl_version, tk_version, + wait_until_mapped) support.requires('gui') +def check_version_info(test, vi): + # The following is almost a copy of tests for sys.version_info. + test.assertIsInstance(vi[:], tuple) + test.assertEqual(len(vi), 5) + test.assertIsInstance(vi[0], int) + test.assertIsInstance(vi[1], int) + test.assertIsInstance(vi[2], int) + test.assertIn(vi[3], ("alpha", "beta", "candidate", "final")) + test.assertIsInstance(vi[4], int) + test.assertIsInstance(vi.major, int) + test.assertIsInstance(vi.minor, int) + test.assertIsInstance(vi.micro, int) + test.assertIn(vi.releaselevel, ("alpha", "beta", "final")) + test.assertIsInstance(vi.serial, int) + test.assertEqual(vi[0], vi.major) + test.assertEqual(vi[1], vi.minor) + test.assertEqual(vi[2], vi.micro) + test.assertEqual(vi[3], vi.releaselevel) + test.assertEqual(vi[4], vi.serial) + test.assertTrue(vi > (1,0,0)) + if vi.releaselevel == 'final': + test.assertEqual(vi.serial, 0) + else: + test.assertEqual(vi.micro, 0) + test.assertStartsWith(str(vi), f'{vi.major}.{vi.minor}') + + +class VersionTest(unittest.TestCase): + + def test_version_info(self): + for vi, version, patchlevel in ( + (tkinter.TCL_VERSION_INFO, _tkinter.TCL_VERSION, _tkinter.TCL_PATCH_LEVEL), + (tkinter.TK_VERSION_INFO, _tkinter.TK_VERSION, _tkinter.TK_PATCH_LEVEL), + ): + with self.subTest(patchlevel=patchlevel): + check_version_info(self, vi) + self.assertEqual(str(vi), patchlevel) + self.assertEqual(f'{vi.major}.{vi.minor}', version) + self.assertEqual(tkinter.TclVersion, + float(f'{tkinter.TCL_VERSION_INFO.major}.' + f'{tkinter.TCL_VERSION_INFO.minor}')) + + class MiscTest(AbstractTkTest, unittest.TestCase): def test_all(self): @@ -508,15 +558,20 @@ def test_focus_methods(self): self.root.update_idletasks() f.focus_force() self.root.update() - self.assertIs(self.root.focus_get(), f) - self.assertIs(self.root.focus_displayof(), f) + # The window manager can take the focus away, and then focus_get() + # and focus_displayof() return None. + if self.root.focus_displayof() is not None: + self.assertIs(self.root.focus_get(), f) + self.assertIs(self.root.focus_displayof(), f) self.assertIs(f.focus_lastfor(), f) b = tkinter.Button(f) b.pack() self.root.update() b.focus_set() self.root.update() - self.assertIs(self.root.focus_get(), b) + if self.root.focus_displayof() is not None: + self.assertIs(self.root.focus_get(), b) + self.assertIs(f.focus_lastfor(), b) def test_focus_methods_unresolvable(self): # The focus may be on a widget that tkinter did not create and so @@ -660,6 +715,109 @@ def test_tk_print(self): self.assertNotHasAttr(tkinter.Frame, 'tk_print') self.assertNotHasAttr(tkinter.Misc, 'tk_print') + @requires_tk(9, 1) + def test_accessible(self): + # Without an active screen reader every "tk accessible" call is + # a no-op returning 0, so only test that the calls do not raise + # and check the values when a screen reader is active. + try: + sr = self.root.tk_check_screenreader() + except tkinter.TclError: + # Tk 9.1a0 or Tk compiled without accessibility support + # (e.g. without ATK on X11). + self.skipTest('the "tk accessible" command is not supported') + self.assertIsInstance(sr, bool) + f = tkinter.Frame(self.root) + acc = f.accessible + self.assertIsInstance(acc, tkinter.Accessible) + self.assertIs(f.accessible, acc) + # The role has to be set first, it creates the table in which + # other attributes are stored. + acc.role = 'Label' + result = acc.role + if sr: + self.assertEqual(result, 'Label') + # Reading an attribute that has not been set raises TclError. + with self.assertRaises(tkinter.TclError): + acc.help + for attr in ('name', 'description', 'value', 'state', + 'action', 'help'): + with self.subTest(attr=attr): + setattr(acc, attr, 'spam') + result = getattr(acc, attr) + if sr: + self.assertEqual(result, 'spam') + acc.add_object() + acc.emit_selection_change() + if self.root._windowingsystem != 'aqua': + acc.emit_focus_change() + + @unittest.skipUnless(sys.platform == 'win32', 'requires Windows') + def test_callback_from_foreign_event_loop(self): + # gh-84256: Tk can call an event handler when Tcl was not entered + # by tkinter, for example when a window message is dispatched + # from a foreign event loop while the GIL is released. + ctypes = import_helper.import_module('ctypes') + from ctypes import wintypes + user32 = ctypes.WinDLL('user32') + user32.SendMessageW.argtypes = [wintypes.HWND, wintypes.UINT, + wintypes.WPARAM, wintypes.LPARAM] + user32.SetWindowPos.argtypes = [wintypes.HWND, wintypes.HWND, + ctypes.c_int, ctypes.c_int, + ctypes.c_int, ctypes.c_int, + wintypes.UINT] + WM_ENTERSIZEMOVE = 0x0231 + WM_EXITSIZEMOVE = 0x0232 + SWP_NOMOVE = 0x0002 + SWP_NOZORDER = 0x0004 + SWP_NOACTIVATE = 0x0010 + + top = tkinter.Toplevel(self.root) + top.geometry('200x150') + if not wait_until_mapped(top): + self.skipTest('the window is not mapped') + sizes = [] + def callback(event): + # Call Tcl from the handler. + sizes.append((event.width, event.height, top.winfo_width())) + top.bind('', callback) + hwnd = int(top.wm_frame(), 16) + # Emulate resizing the window with the mouse: Tk handles the + # resulting window messages in its window procedure, outside + # of the Tcl event loop run by tkinter. + user32.SendMessageW(hwnd, WM_ENTERSIZEMOVE, 0, 0) + try: + user32.SetWindowPos(hwnd, None, 0, 0, 250, 180, + SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE) + finally: + user32.SendMessageW(hwnd, WM_EXITSIZEMOVE, 0, 0) + self.assertTrue(sizes) + + def test_nested_mainloop(self): + # gh-162650: Calls from other thread are still dispatched after + # a nested mainloop() exits. + root = self.root + results = [] + def call(): + try: + results.append(root.tk.call('expr', '6*7')) + except RuntimeError as e: + results.append(e) + def start(): + root.after(0, root.quit) + root.mainloop() # nested + thread = threading.Thread(target=call) + thread.start() + def wait(): + if thread.is_alive(): + root.after(10, wait) + else: + root.quit() + wait() + root.after(0, start) + root.mainloop() + self.assertEqual(results, [42]) + def test_wait_variable(self): var = tkinter.StringVar(self.root) self.assertEqual(self.root.waitvar, self.root.wait_variable) @@ -822,30 +980,10 @@ def test_info_patchlevel(self): vi = self.root.info_patchlevel() f = tkinter.Frame(self.root) self.assertEqual(f.info_patchlevel(), vi) - # The following is almost a copy of tests for sys.version_info. - self.assertIsInstance(vi[:], tuple) - self.assertEqual(len(vi), 5) - self.assertIsInstance(vi[0], int) - self.assertIsInstance(vi[1], int) - self.assertIsInstance(vi[2], int) - self.assertIn(vi[3], ("alpha", "beta", "candidate", "final")) - self.assertIsInstance(vi[4], int) - self.assertIsInstance(vi.major, int) - self.assertIsInstance(vi.minor, int) - self.assertIsInstance(vi.micro, int) - self.assertIn(vi.releaselevel, ("alpha", "beta", "final")) - self.assertIsInstance(vi.serial, int) - self.assertEqual(vi[0], vi.major) - self.assertEqual(vi[1], vi.minor) - self.assertEqual(vi[2], vi.micro) - self.assertEqual(vi[3], vi.releaselevel) - self.assertEqual(vi[4], vi.serial) - self.assertTrue(vi > (1,0,0)) - if vi.releaselevel == 'final': - self.assertEqual(vi.serial, 0) - else: - self.assertEqual(vi.micro, 0) - self.assertStartsWith(str(vi), f'{vi.major}.{vi.minor}') + check_version_info(self, vi) + # The Tcl library loaded at runtime should be compatible with + # the one used for building the module. + self.assertEqual(vi[:2], tkinter.TCL_VERSION_INFO[:2]) def test_embedded_null(self): widget = tkinter.Entry(self.root) @@ -868,6 +1006,91 @@ def test_iterable_protocol(self): widget in widget +@unittest.skipIf(sys.platform == 'darwin', + 'Tk only works in the main thread on macOS') +@threading_helper.requires_working_threading() +class MainloopThreadsTest(unittest.TestCase): + # gh-162647: The mainloop() of Tcl interpreters in different threads + # should not affect each other. + + def setUp(self): + # Tk objects created in other threads must not become the default + # root. + self.addCleanup(setattr, tkinter, '_support_default_root', + tkinter._support_default_root) + tkinter._support_default_root = False + self.roots = {} + self.results = [] + + def mainloop_thread(self, name, ticking=False): + # Return a thread which runs mainloop() of a new Tk. + def run(): + root = tkinter.Tk() + root.withdraw() + if ticking: + def tick(): + root.after(20, tick) + tick() + self.roots[name] = root + try: + root.mainloop() + self.results.append((name, None)) + except BaseException as e: + self.results.append((name, e)) + finally: + # The interpreter should be deleted in its thread. + del self.roots[name] + root.destroy() + del root + _tkinter._finalize_thread() + return threading.Thread(target=run) + + def wait_mainloop(self, name): + for _ in support.sleeping_retry(support.SHORT_TIMEOUT): + if name in self.roots: + break + # A call from other thread waits until mainloop() runs. + self.roots[name].tk.call('info', 'patchlevel') + + def quit_all(self): + for root in list(self.roots.values()): + root.quit() + + def test_quit(self): + threads = [self.mainloop_thread('a'), + self.mainloop_thread('b', ticking=True)] + with threading_helper.start_threads(threads, unlock=self.quit_all): + self.wait_mainloop('a') + self.wait_mainloop('b') + # quit() stops the mainloop() of its interpreter even if it + # waits for events, and does not stop other mainloop(). + self.roots['a'].quit() + threads[0].join(support.SHORT_TIMEOUT) + self.assertEqual(self.results, [('a', None)]) + self.assertEqual(self.results, [('a', None), ('b', None)]) + + def test_callback_error(self): + threads = [self.mainloop_thread('b', ticking=True)] + with threading_helper.start_threads(threads, unlock=self.quit_all): + self.wait_mainloop('b') + root = tkinter.Tk() + self.addCleanup(root.destroy) + root.withdraw() + def callback(): + raise ZeroDivisionError + root.tk.createcommand('callback', callback) + root.tk.call('after', 0, 'callback') + root.update() + # Let the mainloop() in other thread run for a while. + time.sleep(0.2) + # The error was not raised in other thread... + self.assertEqual(self.results, [('b', None)]) + # ...but by the next mainloop() in this thread. + root.after(100, root.quit) + with self.assertRaises(ZeroDivisionError): + root.mainloop() + + class TkTest(AbstractTkTest, unittest.TestCase): def test_readprofile(self): @@ -1128,6 +1351,8 @@ def test_wm_attribute(self): w.wm_attributes(alpha=1.0) self.assertEqual(w.wm_attributes('alpha'), 1.0 if self.wantobjects else '1.0') + with self.assertRaisesRegex(TypeError, r'^wm_attributes\(\) options'): + w.wm_attributes('alpha', alpha=0.5) def test_wm_iconbitmap(self): t = tkinter.Toplevel(self.root) @@ -1319,9 +1544,15 @@ def test_wm_transient(self): def test_wm_stackorder(self): t1 = tkinter.Toplevel(self.root) t2 = tkinter.Toplevel(self.root) + if self.root._windowingsystem == 'x11': + # Bypass the window manager, which may ignore lift() or reorder + # the windows while they are being mapped. + t1.overrideredirect(True) + t2.overrideredirect(True) t1.deiconify() t2.deiconify() - self.root.update() + wait_until_mapped(t1) + wait_until_mapped(t2) t1.lift(t2) # Raise t1 above t2. self.root.update() order = self.root.wm_stackorder() @@ -1361,7 +1592,9 @@ def test_focus(self): f.focus_force() self.root.update() - self.assertEqual(len(events), 1, events) + # The window manager can take the focus away and give it back, + # which makes Tk generate additional focus events. + self.assertGreaterEqual(len(events), 1, events) e = events[0] self.assertIs(e.type, tkinter.EventType.FocusIn) self.assertIs(e.widget, f) @@ -2135,6 +2368,18 @@ def _info_commands(widget, pattern=None): return widget.tk.splitlist(widget.tk.call('info', 'commands', pattern)) +class SignalTest(unittest.TestCase): + + @runInSubprocess() + def test_sigint_handler(self): + # gh-157672: Tk on macOS replaced the SIGINT handler with its own, + # which exits the process. + root = tkinter.Tk() + self.addCleanup(root.destroy) + with self.assertRaises(KeyboardInterrupt): + signal.raise_signal(signal.SIGINT) + + class TclObjTypeTest(AbstractTkTest, unittest.TestCase): # See FromObj() in Modules/_tkinter.c: Tcl object types are converted to # appropriate Python types. These conversions only happen in the object diff --git a/Lib/test/test_tkinter/test_simpledialog.py b/Lib/test/test_tkinter/test_simpledialog.py index be0be8d3f546311..3da9375158bd026 100644 --- a/Lib/test/test_tkinter/test_simpledialog.py +++ b/Lib/test/test_tkinter/test_simpledialog.py @@ -1,9 +1,10 @@ +import sys import unittest import tkinter from tkinter import messagebox, ttk from test.support import requires, swap_attr from test.test_tkinter.support import setUpModule # noqa: F401 -from test.test_tkinter.support import AbstractDefaultRootTest, AbstractTkTest +from test.test_tkinter.support import AbstractDefaultRootTest, AbstractDialogTest from tkinter.simpledialog import (Dialog, SimpleDialog, askinteger, askfloat, askstring, _QueryInteger, _QueryFloat, _QueryString, @@ -12,7 +13,7 @@ requires('gui') -class SimpleDialogTest(AbstractTkTest, unittest.TestCase): +class SimpleDialogTest(AbstractDialogTest, unittest.TestCase): # SimpleDialog's modal loop is in go(); its bindings are exercised here by # generating events on the constructed dialog, without entering the loop. @@ -45,8 +46,8 @@ def test_use_ttk(self): ttk.Style(d.root).lookup('.', 'background')) # The bindings work with the themed buttons too. self.require_mapped(d.root) - d._buttons[0].focus_force() d.root.update() + d._buttons[0].focus_force() d.root.event_generate('') d.root.update() self.assertEqual(d.num, 0) @@ -144,8 +145,8 @@ def test_alt_key(self): # the matching button (cf. tk::AmpWidget in tk::MessageBox). d = self.create(buttons=['Yes', {'text': 'No', 'underline': 0}]) self.require_mapped(d.root) - d._buttons[0].focus_force() d.root.update() + d._buttons[0].focus_force() d.root.event_generate('') # "No" -> underline 0 -> "N" d.root.update() self.assertEqual(d.num, 1) @@ -155,8 +156,8 @@ def test_return_invokes_focused_button(self): # default and the focus was not moved by keyboard traversal. d = self.create(buttons=['Yes', 'No']) # default 0 self.require_mapped(d.root) - d._buttons[1].focus_force() d.root.update() + d._buttons[1].focus_force() d.root.event_generate('') d.root.update() self.assertEqual(d.num, 1) @@ -165,8 +166,8 @@ def test_focus_next_then_return(self): # moves the focus to the next button; invokes it. d = self.create(buttons=['Yes', 'No']) self.require_mapped(d.root) - d._buttons[0].focus_force() d.root.update() + d._buttons[0].focus_force() d._buttons[0].event_generate('') d.root.update() d.root.event_generate('') @@ -177,8 +178,8 @@ def test_focus_prev_then_return(self): # moves the focus to the previous button. d = self.create(buttons=['Yes', 'No']) self.require_mapped(d.root) - d._buttons[1].focus_force() d.root.update() + d._buttons[1].focus_force() d._buttons[1].event_generate('') d.root.update() d.root.event_generate('') @@ -189,8 +190,8 @@ def test_return_activates_default(self): # with the focus off the buttons invokes the default button. d = self.create() # default 0 self.require_mapped(d.root) - d.root.focus_force() # the dialog, not a button, has the focus d.root.update() + d.root.focus_force() # the dialog, not a button, has the focus d.root.event_generate('') d.root.update() self.assertEqual(d.num, 0) @@ -245,8 +246,28 @@ def test_go(self): d.root.after(1, lambda: d._buttons[0].invoke()) self.assertEqual(d.go(), 0) + def test_go_foreign_grab(self): + # gh-157676: the grab and the focus can be in a window which was not + # created by tkinter, such as a native message box; they must be + # restored after the dialog. + tk = self.root.tk + tk.call('toplevel', '.foreign') + self.addCleanup(tk.call, 'destroy', '.foreign') + tk.call('wm', 'deiconify', '.foreign') + tk.call('update') + tk.call('grab', 'set', '.foreign') + tk.call('focus', '-force', '.foreign') + d = self.create() + d.root.after(1, lambda: d._buttons[0].invoke()) + self.assertEqual(d.go(), 0) + self.assertEqual(tk.call('grab', 'current', self.root._w), '.foreign') + # On Windows the application can lose the focus when the dialog is + # destroyed, and then "focus" returns an empty string. + if sys.platform != 'win32': + self.assertEqual(tk.call('focus'), '.foreign') + -class DialogTest(AbstractTkTest, unittest.TestCase): +class DialogTest(AbstractDialogTest, unittest.TestCase): # Dialog's button box is modelled on tk::MessageBox. def open(self, **kw): @@ -279,8 +300,8 @@ def test_use_classic(self): invoked = [] cancel = d.children['cancel'] cancel.configure(command=lambda: invoked.append(True)) - cancel.focus_force() d.update() + cancel.focus_force() d.event_generate('') d.update() self.assertTrue(invoked) @@ -359,8 +380,8 @@ def test_alt_key(self): invoked = [] cancel = d.children['cancel'] # "&Cancel" cancel.configure(command=lambda: invoked.append(True)) - d.focus_force() d.update() + d.focus_force() d.event_generate('') d.update() self.assertTrue(invoked) @@ -371,8 +392,8 @@ def test_return_invokes_focused_button(self): invoked = [] cancel = d.children['cancel'] cancel.configure(command=lambda: invoked.append(True)) - cancel.focus_force() d.update() + cancel.focus_force() d.event_generate('') d.update() self.assertEqual(invoked, [True]) @@ -384,8 +405,8 @@ def test_focus_next_then_return(self): for name in ('ok', 'cancel'): d.children[name].configure(command=lambda name=name: invoked.append(name)) ok = d.children['ok'] - ok.focus_force() d.update() + ok.focus_force() ok.event_generate('') # OK -> Cancel d.update() d.event_generate('') @@ -399,8 +420,8 @@ def test_focus_prev_then_return(self): for name in ('ok', 'cancel'): d.children[name].configure(command=lambda name=name: invoked.append(name)) cancel = d.children['cancel'] - cancel.focus_force() d.update() + cancel.focus_force() cancel.event_generate('') # Cancel -> OK d.update() d.event_generate('') @@ -432,7 +453,7 @@ def mock_wait_window(w): self.assertRaises(RuntimeError, askinteger, "Go To Line", "Line number") -class QueryDialogTest(AbstractTkTest, unittest.TestCase): +class QueryDialogTest(AbstractDialogTest, unittest.TestCase): # The query dialogs are modal: their __init__ blocks in wait_window(). # Mock that out so the dialog stays alive and can be driven with generated # events, exercising the / bindings and the validation. diff --git a/Lib/test/test_tkinter/test_text.py b/Lib/test/test_tkinter/test_text.py index 27423006a7e71b8..c28f4e3f130d7af 100644 --- a/Lib/test/test_tkinter/test_text.py +++ b/Lib/test/test_tkinter/test_text.py @@ -774,10 +774,16 @@ def test_count(self): self.assertRaises(TclError, text.count, '1.0', 'end', 'spam') self.assertRaises(TclError, text.count, '1.0', 'end', '-lines') - self.assertIsInstance(text.count('1.3', '1.5', 'ypixels', return_ints=True), int) - self.assertIsInstance(text.count('1.3', '1.5', 'ypixels'), tuple) - self.assertIsInstance(text.count('1.3', '1.5', 'update', 'ypixels', return_ints=True), int) - self.assertIsInstance(text.count('1.3', '1.5', 'update', 'ypixels'), int) + # The ypixels counts depend on the widget geometry. + text.update() + + # Indices on the same display line have zero vertical distance. + self.assertEqual(text.count('1.3', '1.5', 'ypixels', return_ints=True), 0) + self.assertIsNone(text.count('1.3', '1.5', 'ypixels')) + self.assertIsInstance(text.count('1.3', '2.5', 'ypixels', return_ints=True), int) + self.assertIsInstance(text.count('1.3', '2.5', 'ypixels'), tuple) + self.assertIsInstance(text.count('1.3', '2.5', 'update', 'ypixels', return_ints=True), int) + self.assertIsInstance(text.count('1.3', '2.5', 'update', 'ypixels'), int) self.assertEqual(text.count('1.3', '1.3', 'update', 'ypixels', return_ints=True), 0) self.assertEqual(text.count('1.3', '1.3', 'update', 'ypixels'), None) self.assertEqual(text.count('1.3', '1.5', 'update', 'indices', return_ints=True), 2) diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py index e2db09d61f409bd..6d9f7f21f42954e 100644 --- a/Lib/test/test_tokenize.py +++ b/Lib/test/test_tokenize.py @@ -1,4 +1,5 @@ import contextlib +import _tokenize import itertools import os import re @@ -7,6 +8,7 @@ import token import tokenize import unittest +import weakref from io import BytesIO, StringIO from textwrap import dedent from unittest import TestCase, mock @@ -1233,6 +1235,20 @@ def test_multiline_non_ascii_fstring_with_expr(self): FSTRING_END \'"\' (2, 2) (2, 3) """) + def test_ineq_tokens(self): + self.check_tokenize("1 != 2", """\ + NUMBER '1' (1, 0) (1, 1) + OP '!=' (1, 2) (1, 4) + NUMBER '2' (1, 5) (1, 6) +""") + self.check_tokenize("1 <> 2", """\ + NUMBER '1' (1, 0) (1, 1) + OP '<' (1, 2) (1, 3) + OP '>' (1, 3) (1, 4) + NUMBER '2' (1, 5) (1, 6) +""") + + class GenerateTokensTest(TokenizeTest): def check_tokenize(self, s, expected): # Format the tokens in s in a table format. @@ -2253,6 +2269,18 @@ def check_tokenize(self, s, expected): ) self.assertEqual(result, expected.rstrip().splitlines()) + def test_readline_reference_cycle(self): + class Readline: + def __call__(self): + return "" + + readline = Readline() + readline.iterator = _tokenize.TokenizerIter(readline, extra_tokens=True) + ref = weakref.ref(readline) + del readline + support.gc_collect() + self.assertIsNone(ref()) + def test_encoding(self): def readline(encoding): yield "1+1".encode(encoding) @@ -2273,6 +2301,203 @@ def readline(encoding): )) self.assertEqual(tokens, expected) + def test_stateful_decoder_spans_readline_calls(self): + encoded_name = "変数".encode("iso2022_jp") + payload = encoded_name[3:-3] + lines = iter([ + b"# \x1b$B" + payload + b"\n", + payload + b"\x1b(B\n", + b"", + ]) + tokens = list(tokenize._generate_tokens_from_c_tokenizer( + lines.__next__, + extra_tokens=True, + encoding="iso2022_jp", + )) + self.assertEqual(tokens, [ + tokenize.TokenInfo( + token.COMMENT, "# 変数", (1, 0), (1, 4), "# 変数\n" + ), + tokenize.TokenInfo(token.NL, "\n", (1, 4), (1, 5), "# 変数\n"), + tokenize.TokenInfo(token.NAME, "変数", (2, 0), (2, 2), "変数\n"), + tokenize.TokenInfo(token.NEWLINE, "\n", (2, 2), (2, 3), "変数\n"), + tokenize.TokenInfo(token.ENDMARKER, "", (3, 0), (3, 0), ""), + ]) + + def test_utf16_bom_in_each_readline_chunk(self): + lines = iter([ + "x\n".encode("utf-16"), + "y\n".encode("utf-16"), + b"", + ]) + tokens = _tokenize.TokenizerIter( + lines.__next__, encoding="utf-16", extra_tokens=True + ) + self.assertEqual(list(tokens), [ + (token.NAME, "x", (1, 0), (1, 1), "x\n"), + (token.NEWLINE, "\n", (1, 1), (1, 2), "x\n"), + (token.NAME, "y", (2, 0), (2, 1), "y\n"), + (token.NEWLINE, "\n", (2, 1), (2, 2), "y\n"), + (token.ENDMARKER, "", (3, 0), (3, 0), ""), + ]) + + def test_utf8_decoder_spans_readline_calls(self): + lines = iter([b"x\xc3", b"\xa9\n", b""]) + tokens = list(tokenize._generate_tokens_from_c_tokenizer( + lines.__next__, + extra_tokens=True, + encoding="utf-8", + )) + self.assertEqual(tokens, [ + tokenize.TokenInfo(token.NAME, "xé", (1, 0), (1, 2), "xé\n"), + tokenize.TokenInfo(token.NEWLINE, "\n", (1, 2), (1, 3), "xé\n"), + tokenize.TokenInfo(token.ENDMARKER, "", (2, 0), (2, 0), ""), + ]) + + def test_utf8_decoder_spans_many_readline_calls(self): + for prefix in (b"", b"previous\n"): + with self.subTest(prefix=prefix): + chunks = ([prefix + b"x\xc3"] + [b"\xa9\xc3"] * 100 + + [b"\xa9\n", b"z\xc3", b"\xa9\n", b""]) + source = b"".join(chunks) + expected = list(_tokenize.TokenizerIter( + BytesIO(source).readline, encoding="utf-8", extra_tokens=True + )) + tokens = list(_tokenize.TokenizerIter( + iter(chunks).__next__, encoding="utf-8", extra_tokens=True + )) + self.assertEqual(tokens, expected) + + def test_utf8_decoder_replaces_incomplete_input_at_eof(self): + expected = [ + tokenize.TokenInfo(token.NAME, "x�", (1, 0), (1, 2), "x�"), + tokenize.TokenInfo(token.NEWLINE, "", (1, 2), (1, 3), "x�"), + tokenize.TokenInfo(token.ENDMARKER, "", (2, 0), (2, 0), ""), + ] + for chunks in ([b"x\xe9", b""], [b"x\xe9"]): + with self.subTest(chunks=chunks): + lines = iter(chunks) + tokens = list(tokenize._generate_tokens_from_c_tokenizer( + lines.__next__, + extra_tokens=True, + encoding="utf-8", + )) + self.assertEqual(tokens, expected) + + def test_multiline_readline_chunk(self): + expected = [ + tokenize.TokenInfo(token.NAME, "x", (1, 0), (1, 1), "x=1\n"), + tokenize.TokenInfo(token.OP, "=", (1, 1), (1, 2), "x=1\n"), + tokenize.TokenInfo(token.NUMBER, "1", (1, 2), (1, 3), "x=1\n"), + tokenize.TokenInfo(token.NEWLINE, "\n", (1, 3), (1, 4), "x=1\n"), + tokenize.TokenInfo(token.NAME, "y", (2, 0), (2, 1), "y=2\n"), + tokenize.TokenInfo(token.OP, "=", (2, 1), (2, 2), "y=2\n"), + tokenize.TokenInfo(token.NUMBER, "2", (2, 2), (2, 3), "y=2\n"), + tokenize.TokenInfo(token.NEWLINE, "\n", (2, 3), (2, 4), "y=2\n"), + tokenize.TokenInfo(token.ENDMARKER, "", (3, 0), (3, 0), ""), + ] + lines = iter([b"x=1\ny=2\n", b""]) + tokens = list(tokenize._generate_tokens_from_c_tokenizer( + lines.__next__, + extra_tokens=True, + encoding="utf-8", + )) + self.assertEqual(tokens, expected) + + def test_multiline_readline_chunk_with_unterminated_tail(self): + readline = mock.Mock(side_effect=["x\nz", ""]) + iterator = _tokenize.TokenizerIter(readline, extra_tokens=True) + expected = [ + (token.NAME, "x", (1, 0), (1, 1), "x\n"), + (token.NEWLINE, "\n", (1, 1), (1, 2), "x\n"), + (token.NAME, "z", (2, 0), (2, 1), "z"), + (token.NEWLINE, "", (2, 1), (2, 2), "z"), + ] + self.assertEqual(readline.call_count, 0) + for token_info in expected: + self.assertEqual(next(iterator), token_info) + self.assertEqual(readline.call_count, 1) + self.assertEqual( + next(iterator), + (token.ENDMARKER, "", (3, 0), (3, 0), ""), + ) + self.assertEqual(readline.call_count, 2) + + def test_readline_memory_error_in_string(self): + readline = mock.Mock(side_effect=['"""first\n', MemoryError]) + iterator = _tokenize.TokenizerIter(readline, extra_tokens=True) + with self.assertRaises(MemoryError): + next(iterator) + + def test_readline_callback_is_not_read_ahead(self): + readline = mock.Mock(side_effect=["x\n", "y\n", ""]) + iterator = _tokenize.TokenizerIter(readline, extra_tokens=True) + expected = [ + ((token.NAME, "x", (1, 0), (1, 1), "x\n"), 1), + ((token.NEWLINE, "\n", (1, 1), (1, 2), "x\n"), 1), + ((token.NAME, "y", (2, 0), (2, 1), "y\n"), 2), + ] + self.assertEqual(readline.call_count, 0) + for token_info, calls in expected: + self.assertEqual(next(iterator), token_info) + self.assertEqual(readline.call_count, calls) + + def test_encoded_readline_replaces_invalid_bytes(self): + lines = iter([b"\xff\n", b""]) + tokens = list(tokenize._generate_tokens_from_c_tokenizer( + lines.__next__, + extra_tokens=True, + encoding="utf-8", + )) + self.assertEqual(tokens, [ + tokenize.TokenInfo(token.NAME, "�", (1, 0), (1, 1), "�\n"), + tokenize.TokenInfo(token.NEWLINE, "\n", (1, 1), (1, 2), "�\n"), + tokenize.TokenInfo(token.ENDMARKER, "", (2, 0), (2, 0), ""), + ]) + + def test_stop_iteration_skips_encoded_readline_codec_lookup(self): + iterator = _tokenize.TokenizerIter( + lambda: b"", + extra_tokens=True, + encoding="missing-tokenizer-codec", + ) + with self.assertRaises(LookupError): + next(iterator) + + iterator = _tokenize.TokenizerIter( + iter(()).__next__, + extra_tokens=True, + encoding="missing-tokenizer-codec", + ) + self.assertEqual( + next(iterator), + (token.ENDMARKER, "", (1, 0), (1, 0), ""), + ) + + def test_fstring_offsets_survive_buffer_reallocation(self): + for prefix in ("f", "t"): + for extra_tokens in (False, True): + with self.subTest(prefix=prefix, extra_tokens=extra_tokens): + physical_lines = [ + prefix + '"""\n', + "{(\n", + " " * 9000 + "1\n", + ")=:>{2}}\n", + '"""\n', + ] + source = "".join(physical_lines) + chunks = iter([ + "".join(physical_lines[:2]), + "".join(physical_lines[2:4]), + physical_lines[4], + "", + ]) + expected = self._get_tokens( + source, extra_tokens=extra_tokens) + tokens = list(tokenize._generate_tokens_from_c_tokenizer( + chunks.__next__, extra_tokens=extra_tokens)) + self.assertEqual(tokens, expected) + def test_extra_tokens_relaxes_lexer_errors(self): cases = [ ( @@ -2395,6 +2620,40 @@ def test_degraded_fstring_format_spec(self): ("f-string: single '}' is not allowed", (1, 11)), ) + def test_carriage_return_after_debug_comment(self): + for prefix in ("f", "t"): + with self.subTest(prefix=prefix): + tokens = self._get_tokens(f"{prefix}'''{{x=# comment\r}}'''") + self.assertEqual(tokens[4].string, "# comment\r}") + + def test_incomplete_formatted_string_comment_after_carriage_return(self): + for prefix in ("f", "t"): + with self.subTest(prefix=prefix): + for extra_tokens in (False, True): + with self.assertRaises(tokenize.TokenError) as caught: + self._get_tokens( + f"{prefix}'{{#\r!", extra_tokens=extra_tokens + ) + self.assertEqual( + caught.exception.args, + ("unexpected EOF in multi-line statement", (1, 7)), + ) + + def test_formatted_string_nesting_limit(self): + def nested_string(depth, prefix): + source = "'x'" + for _ in range(depth): + source = f'{prefix}"{{{source}}}"' + return source + + for prefix in ("f", "t"): + with self.subTest(prefix=prefix): + self._get_tokens(nested_string(149, prefix)) + with self.assertRaisesRegex( + tokenize.TokenError, + "too many nested f-strings or t-strings"): + self._get_tokens(nested_string(150, prefix)) + def test_escaped_fstring_brace_has_a_position_gap(self): tokens = self._get_tokens('f"a{{"', extra_tokens=True) self.assertEqual( @@ -2412,19 +2671,21 @@ def test_tolerant_incompatible_prefix_position_after_non_ascii(self): self._get_tokens('bé )tf"2 ', extra_tokens=True) self.assertEqual( caught.exception.args, - ("'f' and 't' prefixes are incompatible", (1, 6)), + ("'f' and 't' prefixes are incompatible", (1, 5)), ) def test_tolerant_fstring_closer_at_expression_entry_depth(self): - source = "f'1:{]]{}}r}''" - for extra_tokens, position in ((False, (1, 6)), (True, (1, 7))): - with self.subTest(extra_tokens=extra_tokens): - with self.assertRaises(tokenize.TokenError) as caught: - self._get_tokens(source, extra_tokens=extra_tokens) - self.assertEqual( - caught.exception.args, - ("f-string: unmatched ']'", position), - ) + cases = [ + ("f'1:{]]{}}r}''", ("f-string: unmatched ']'", (1, 6))), + ("f'{]a'", ("f-string: unmatched ']'", (1, 4))), + ("t'{\nx)'", ("t-string: unmatched ')'", (2, 2))), + ] + for source, error in cases: + for extra_tokens in (False, True): + with self.subTest(source=source, extra_tokens=extra_tokens): + with self.assertRaises(tokenize.TokenError) as caught: + self._get_tokens(source, extra_tokens=extra_tokens) + self.assertEqual(caught.exception.args, error) def test_int(self): @@ -3637,5 +3898,12 @@ def test_prefixes(self): self.assertEqual(defined_prefixes, self.determine_valid_prefixes()) +class TestModule(unittest.TestCase): + def test_deprecated_module_attributes(self): + support.check_deprecated_module_attributes( + self, tokenize, "__author__", "__credits__", remove=(3, 20), + ) + + if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_tools/__init__.py b/Lib/test/test_tools/__init__.py index c4395c7c0ad0c98..310bf48c2ef03a1 100644 --- a/Lib/test/test_tools/__init__.py +++ b/Lib/test/test_tools/__init__.py @@ -32,7 +32,10 @@ def skip_if_missing(tool=None): @contextlib.contextmanager def imports_under_tool(name, *subdirs): tooldir = os.path.join(toolsdir, name, *subdirs) - with import_helper.DirsOnSysPath(tooldir) as cm: + with ( + import_helper.force_eager_imports(), + import_helper.DirsOnSysPath(tooldir) as cm, + ): yield cm def import_tool(toolname): diff --git a/Lib/test/test_tools/i18n_data/noheader.pot b/Lib/test/test_tools/i18n_data/noheader.pot new file mode 100644 index 000000000000000..834006e42732e56 --- /dev/null +++ b/Lib/test/test_tools/i18n_data/noheader.pot @@ -0,0 +1,8 @@ +#: noheader.py:3 +msgid "Foo" +msgstr "" + +#: noheader.py:5 +msgid "Bar" +msgstr "" + diff --git a/Lib/test/test_tools/i18n_data/noheader.py b/Lib/test/test_tools/i18n_data/noheader.py new file mode 100644 index 000000000000000..23971799af23c67 --- /dev/null +++ b/Lib/test/test_tools/i18n_data/noheader.py @@ -0,0 +1,5 @@ +from gettext import gettext as _ + +_('Foo') + +_('Bar') diff --git a/Lib/test/test_tools/msgfmt_data/fuzzy.mo b/Lib/test/test_tools/msgfmt_data/fuzzy.mo index 4b144831cf5f75c..273edbbbd7cbd79 100644 Binary files a/Lib/test/test_tools/msgfmt_data/fuzzy.mo and b/Lib/test/test_tools/msgfmt_data/fuzzy.mo differ diff --git a/Lib/test/test_tools/msgfmt_data/general.mo b/Lib/test/test_tools/msgfmt_data/general.mo index ee905cbb3ec58db..3107f6711bdd10b 100644 Binary files a/Lib/test/test_tools/msgfmt_data/general.mo and b/Lib/test/test_tools/msgfmt_data/general.mo differ diff --git a/Lib/test/test_tools/test_compute_changes.py b/Lib/test/test_tools/test_compute_changes.py index eb1ecd447a7ce0a..4c2b9966c4cd5b6 100644 --- a/Lib/test/test_tools/test_compute_changes.py +++ b/Lib/test/test_tools/test_compute_changes.py @@ -109,15 +109,6 @@ def test_unix(self): self.assertTrue(result.run_tests) self.assertFalse(result.run_windows_tests) - def test_msi(self): - for f in ( - ".github/workflows/reusable-windows-msi.yml", - "Tools/msi/build.bat", - ): - with self.subTest(f=f): - result = process_changed_files({Path(f)}) - self.assertTrue(result.run_windows_msi) - def test_all_run(self): for f in ( ".github/workflows/some-new-workflow.yml", diff --git a/Lib/test/test_tools/test_i18n.py b/Lib/test/test_tools/test_i18n.py index 7583b61480e3709..2dafdd3d059afaf 100644 --- a/Lib/test/test_tools/test_i18n.py +++ b/Lib/test/test_tools/test_i18n.py @@ -606,6 +606,7 @@ def extract_from_snapshots(): 'custom_keywords.py': ('--keyword=foo', '--keyword=nfoo:1,2', '--keyword=pfoo:1c,2', '--keyword=npfoo:1c,2,3', '--keyword=_:1,2'), + 'noheader.py': ('--omit-header',), 'multiple_keywords.py': ('--keyword=foo:1c,2,3', '--keyword=foo:1c,2', '--keyword=foo:1,2', # repeat a keyword to make sure it is extracted only once diff --git a/Lib/test/test_tools/test_inspection.py b/Lib/test/test_tools/test_inspection.py new file mode 100644 index 000000000000000..f4a0d163adbc562 --- /dev/null +++ b/Lib/test/test_tools/test_inspection.py @@ -0,0 +1,111 @@ +"""Tests for snippets in Tools/inspection.""" + +import unittest +from types import SimpleNamespace + +from test.test_tools import imports_under_tool, skip_if_missing + + +skip_if_missing("inspection") +with imports_under_tool("inspection"): + import snippets + + +def frame(funcname, *, filename="", lineno=None): + location = SimpleNamespace(lineno=lineno) if lineno is not None else None + return SimpleNamespace( + funcname=funcname, + filename=filename, + location=location, + ) + + +def frames(*names): + return [frame(name) for name in names] + + +class ClassifierTests(unittest.TestCase): + def test_classifiers(self): + flat_lines = snippets.FLAT_ALTERNATING_LINES + short_line = min(snippets.SHARED_LEAF_SHORT_LINES) + flat_a = [ + frame("leaf_a", lineno=flat_lines["leaf_a"]), + frame("hot_a", lineno=flat_lines["hot_a"]), + ] + flat_crossed = [ + frame("hot_a", lineno=flat_lines["hot_a"]), + frame("hot_b", lineno=flat_lines["hot_b"]), + ] + shared_a = [ + frame("shared_leaf", lineno=short_line), + frame("a_wrapper"), + ] + shared_crossed = [ + frame("shared_leaf", lineno=short_line), + frame("b_wrapper"), + ] + cases = [ + (snippets.classify_flat, flat_a, False), + (snippets.classify_flat, flat_crossed, True), + ( + snippets.classify_nested, + frames("burn_a", "a_leaf", "a_parent"), + False, + ), + ( + snippets.classify_nested, + frames("a_parent", "a_leaf", "burn_a"), + True, + ), + (snippets.classify_shared, shared_a, False), + (snippets.classify_shared, shared_crossed, True), + (snippets.classify_gen, frames("agen", "drv_a"), False), + (snippets.classify_gen, frames("agen", "drv_b"), True), + (snippets.classify_gen, frames("bgen", "drv_a"), True), + (snippets.classify_gen, frames("agen"), False), + ( + snippets.classify_gen, + frames("agen", "agen", "drv_a"), + False, + ), + + (snippets.classify_recursion, frames("a", "a"), False), + (snippets.classify_recursion, frames("a", "b"), True), + ( + snippets.classify_async_running_task, + (None, "hot", None, frames("leaf_hot")), + False, + ), + ( + snippets.classify_async_running_task, + (None, "hot", None, frames("leaf_rare")), + True, + ), + ( + snippets.classify_code_object_reuse, + [frame("func_a", filename="A_file.py")], + False, + ), + ( + snippets.classify_code_object_reuse, + [frame("func_a", filename="B_file.py")], + True, + ), + ( + snippets.classify_oversized_chunk, + [frame("big_a", filename="a.py")], + False, + ), + ( + snippets.classify_oversized_chunk, + [frame("big_b", filename="a.py")], + True, + ), + ] + for classifier, sample, expected in cases: + with self.subTest(classifier=classifier.__name__, sample=sample): + self.assertEqual(classifier(sample), expected) + + +if __name__ == "__main__": + unittest.main() diff --git a/Lib/test/test_tools/test_msgfmt.py b/Lib/test/test_tools/test_msgfmt.py index 7be606bbff606a3..0b39f509e0a415d 100644 --- a/Lib/test/test_tools/test_msgfmt.py +++ b/Lib/test/test_tools/test_msgfmt.py @@ -4,8 +4,11 @@ import struct import sys import unittest +from contextlib import redirect_stderr from gettext import GNUTranslations +from io import StringIO from pathlib import Path +from textwrap import dedent from test.support.os_helper import temp_cwd from test.support.script_helper import assert_python_failure, assert_python_ok @@ -44,6 +47,29 @@ def test_compilation(self): self.assertDictEqual(actual._catalog, expected._catalog) + def test_hash_table(self): + # Check _hashpjw generates correct hash values + self.assertEqual(msgfmt._hashpjw(b"stan"), 502398) + self.assertEqual(msgfmt._hashpjw(b"foo"), 27999) + # Carries into bit 32 are discarded, as GNU gettext does + self.assertEqual(msgfmt._hashpjw(b"kL{M-#[J)pxyz"), 32778) + + # Check hash table is generated correctly for general.po + with temp_cwd(): + tmp_mo_file = "messages.mo" + compile_messages(data_dir / "general.po", tmp_mo_file) + with open(tmp_mo_file, "rb") as f: + mo_data = f.read() + + header = struct.unpack("=7I", mo_data[:28]) + hash_table_size, hash_table_offset = header[5:7] + + hash_tab_end = hash_table_offset + hash_table_size * 4 + hash_tab = struct.unpack(f"={hash_table_size}I", + mo_data[hash_table_offset:hash_tab_end]) + + self.assertEqual(hash_tab, (1, 3, 0, 8, 9, 7, 2, 0, 4, 5, 0, 6, 0)) + def test_binary_header(self): with temp_cwd(): tmp_mo_file = 'messages.mo' @@ -66,8 +92,8 @@ def test_binary_header(self): self.assertEqual(num_strings, 9) self.assertEqual(orig_table_offset, 28) self.assertEqual(trans_table_offset, 100) - self.assertEqual(hash_table_size, 0) - self.assertEqual(hash_table_offset, 0) + self.assertEqual(hash_table_size, 13) + self.assertEqual(hash_table_offset, 172) def test_translations(self): with open(data_dir / 'general.mo', 'rb') as f: @@ -240,6 +266,227 @@ def test_strings(self): with self.assertRaises(Exception): msgfmt.make('messages.po', 'messages.mo') + def test_general_syntax_errors(self): + # 2-tuples of input PO files and expected error messages + invalid_po_files = ( + ('', None), + ('"', None), + ('""', 'Syntax error on messages.po:1 before:'), + ('"foo"', f'Syntax error on messages.po:1 before:\nfoo'), + # 'msgid', # invalid but currently accepted + ('msgstr', None), + ('msgid_plural', 'msgid_plural not preceded by msgid on messages.po:1'), + # 'msgctxt', # invalid but currently accepted + ('msgstr', None), + ('msgstr[0]', None), + ('[0]', f'Syntax error on messages.po:1 before:\n[0]'), + # unclosed string + ( + dedent('''\ + msgid " + msgstr "bar" + '''), + None + ), + # unclosed string + ( + dedent('''\ + msgid "foo + msgstr "bar" + '''), + None + ), + # unclosed string + ( + dedent('''\ + msgid "foo" " + msgstr "bar" + '''), + None + ), + # unclosed string + ( + dedent('''\ + msgid "foo" + " + msgstr "bar" + '''), + None + ), + # illegal backslash + ( + dedent('''\ + msgid "foo\\" + " + msgstr "bar" + '''), + None + ), + # msgid with an index + ( + dedent('''\ + msgid[0] "foo" + msgstr "bar" + '''), + None + ), + # invalid plural index + ( + dedent('''\ + msgid "foo" + msgid_plural "foos" + msgstr[0 "baz" + '''), + None + ), + # invalid plural index + ( + dedent('''\ + msgid "foo" + msgid_plural "foos" + msgstr1] "baz" + '''), + 'indexed msgstr required for plural on messages.po:3' + ), + # invalid plural index + ( + dedent('''\ + msgid "foo" + msgid_plural "foos" + msgstr[[0]] "baz" + '''), + None + ) + ) + with temp_cwd(): + for invalid_po, err_msg in invalid_po_files: + with self.subTest(invalid_po=invalid_po): + Path('messages.po').write_text(invalid_po) + # Reset the global MESSAGES dictionary + msgfmt.MESSAGES.clear() + with redirect_stderr(StringIO()) as output: + with self.assertRaises((SystemExit, UnboundLocalError, + IndexError, SyntaxError)): + msgfmt.make('messages.po', 'messages.mo') + if err_msg: + self.assertEqual(output.getvalue().strip(), err_msg) + + def test_semantic_errors(self): + # 2-tuples of input PO files and expected error messages + invalid_po_files = ( + # msgid_plural must be preceded by msgid + ( + dedent('''\ + msgid_plural "foos" + + msgid "bar" + msgstr "baz" + '''), + 'msgid_plural not preceded by msgid on messages.po:1' + ), + # msgid_plural not allowed after comment + ( + dedent('''\ + # comment + msgid_plural "foos" + + msgid "bar" + msgstr "baz" + '''), + 'msgid_plural not preceded by msgid on messages.po:2' + ), + # msgid_plural not allowed after msgctxt + ( + dedent('''\ + msgctxt "foo" + msgid_plural "foos" + + msgid "bar" + msgstr "baz" + '''), + 'msgid_plural not preceded by msgid on messages.po:2' + ), + # msgid_plural not allowed after msgstr + ( + dedent('''\ + msgid "foo" + msgstr "bar" + msgid_plural "foos" + + msgid "bar" + msgstr "baz" + '''), + 'msgid_plural not preceded by msgid on messages.po:3' + ), + # msgstr must be preceded by msgid + ( + dedent('''\ + msgstr "foo" + + msgid "bar" + msgstr "baz" + '''), + None + ), + # msgstr not allowed after msgctxt + ( + dedent('''\ + msgctxt "foo" + msgstr "bar" + + msgid "foo" + msgstr "bar" + '''), + None + ), + # missing msgid_plural section + ( + dedent('''\ + msgid "foo" + msgstr[0] "bar" + + msgid "bar" + msgstr "baz" + '''), + 'plural without msgid_plural on messages.po:2' + ), + ) + with temp_cwd(): + for invalid_po, err_msg in invalid_po_files: + with self.subTest(invalid_po=invalid_po): + Path('messages.po').write_text(invalid_po) + # Reset the global MESSAGES dictionary + msgfmt.MESSAGES.clear() + with redirect_stderr(StringIO()) as output: + with self.assertRaises((SystemExit, UnboundLocalError)): + msgfmt.make('messages.po', 'messages.mo') + if err_msg: + self.assertEqual(output.getvalue().strip(), err_msg) + + def test_msgstr_invalid_indices(self): + # 2-tuples of input PO files and expected error messages + invalid_po_files = ( + # msgstr not pluralized + ( + dedent('''\ + msgid "foo" + msgid_plural "foos" + msgstr "bar" + '''), + 'indexed msgstr required for plural on messages.po:3' + ), + ) + with temp_cwd(): + for invalid_po, err_msg in invalid_po_files: + with self.subTest(invalid_po=invalid_po): + Path('messages.po').write_text(invalid_po) + # Reset the global MESSAGES dictionary + msgfmt.MESSAGES.clear() + with redirect_stderr(StringIO()) as output: + with self.assertRaises(SystemExit): + msgfmt.make('messages.po', 'messages.mo') + self.assertEqual(output.getvalue().strip(), err_msg) + class CLITest(unittest.TestCase): diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py index 19eee19bdea6d5b..241e841d732f5ea 100644 --- a/Lib/test/test_trace.py +++ b/Lib/test/test_trace.py @@ -1,5 +1,5 @@ import os -from pickle import dump +from pickle import dump, load import sys from test.support import captured_stdout, requires_resource from test.support.os_helper import (TESTFN, rmtree, unlink) @@ -561,6 +561,28 @@ def f(): self.assertIn('lines cov% module (path)', stdout) self.assertIn(f'6 100.0% {modulename} ({filename})', stdout) + def test_count_no_report_accumulates_counts(self): + # --no-report must still save the --file counts so they accumulate. + filename = f'{TESTFN}.py' + countsfile = f'{TESTFN}.counts' + with open(filename, 'w', encoding='utf-8') as fd: + self.addCleanup(unlink, filename) + self.addCleanup(unlink, countsfile) + fd.write('for i in range(3):\n pass\n') + argv = ('-m', 'trace', '--count', '--no-report', + '--file', countsfile, filename) + assert_python_ok(*argv, PYTHONIOENCODING='utf-8') + self.assertTrue(os.path.exists(countsfile)) + with open(countsfile, 'rb') as fd: + counts = load(fd)[0] + self.assertTrue(counts) + # A second run accumulates into the same file. + assert_python_ok(*argv, PYTHONIOENCODING='utf-8') + with open(countsfile, 'rb') as fd: + accumulated = load(fd)[0] + self.assertEqual(accumulated, + {key: 2 * value for key, value in counts.items()}) + def test_run_as_module(self): assert_python_ok('-m', 'trace', '-l', '--module', 'timeit', '-n', '1') assert_python_failure('-m', 'trace', '-l', '--module', 'not_a_module_zzz') diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index e38d0942e463e9c..40663e7d887e14b 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -587,6 +587,13 @@ def test_format_exception_only_exc(self): output = traceback.format_exception_only(Exception("projector")) self.assertEqual(output, ["Exception: projector\n"]) + @support.subTests("arg", [NotImplemented, "invalid syntax"]) + def test_format_syntax_error_message(self, arg): + exc = SyntaxError(arg) + lines = traceback.format_exception_only(type(exc), exc) + result = "".join(lines) + self.assertIn(str(arg), result) + def test_exception_is_None(self): NONE_EXC_STRING = 'NoneType: None\n' excfile = StringIO() @@ -3904,7 +3911,7 @@ def f(): def test_dont_swallow_cause_or_context_of_falsey_exception(self): # see gh-132308: Ensure that __cause__ or __context__ attributes of exceptions # that evaluate as falsey are included in the output. For falsey term, - # see https://docs.python.org/3/library/stdtypes.html#truth-value-testing. + # see https://docs.python.org/3/builtins/stdtypes.html#truth-value-testing. try: raise FalseyException from KeyError @@ -4123,7 +4130,7 @@ def test_comparison(self): def test_dont_swallow_subexceptions_of_falsey_exceptiongroup(self): # see gh-132308: Ensure that subexceptions of exception groups # that evaluate as falsey are displayed in the output. For falsey term, - # see https://docs.python.org/3/library/stdtypes.html#truth-value-testing. + # see https://docs.python.org/3/builtins/stdtypes.html#truth-value-testing. try: raise FalseyExceptionGroup("Gih", (KeyError(), NameError())) @@ -5109,6 +5116,32 @@ def func(): actual = self.get_suggestion(func) self.assertIn("forget to import '_io'", actual) + def test_name_error_with_bad_getattr(self): + class A: + def __getattr__(self, x): + spam + + actual = self.get_suggestion(A(), "eggs") + self.assertIn("name 'spam' is not defined", actual) + + def test_name_error_with_bad_getattribute(self): + + class A: + def __getattribute__(self, x): + spam + + actual = self.get_suggestion(A(), "eggs") + self.assertIn("name 'spam' is not defined", actual) + + def test_name_error_with_bad_property(self): + class A: + @property + def eggs(self): + eggs + + actual = self.get_suggestion(A(), "eggs") + self.assertIn("name 'eggs' is not defined", actual) + class PurePythonSuggestionFormattingTests( @@ -5611,11 +5644,11 @@ class TestLazyImportSuggestions(unittest.TestCase): def test_attribute_error_does_not_reify_lazy_imports(self): """Printing an AttributeError should not trigger lazy import reification.""" - # pkg.bar prints "BAR_MODULE_LOADED" when imported. + # lazypkg.bar prints "BAR_MODULE_LOADED" when imported. # If lazy import is reified during suggestion computation, we'll see it. code = textwrap.dedent(""" - lazy import test.test_lazy_import.data.pkg.bar - test.test_lazy_import.data.pkg.nonexistent + lazy import test.test_lazy_import.data.lazypkg + test.test_lazy_import.data.lazypkg.nonexistent """) rc, stdout, stderr = assert_python_failure('-c', code) self.assertNotIn(b"BAR_MODULE_LOADED", stdout) @@ -5624,9 +5657,9 @@ def test_traceback_formatting_does_not_reify_lazy_imports(self): """Formatting a traceback should not trigger lazy import reification.""" code = textwrap.dedent(""" import traceback - lazy import test.test_lazy_import.data.pkg.bar + lazy import test.test_lazy_import.data.lazypkg try: - test.test_lazy_import.data.pkg.nonexistent + test.test_lazy_import.data.lazypkg.nonexistent except AttributeError: traceback.format_exc() print("OK") @@ -5638,9 +5671,9 @@ def test_traceback_formatting_does_not_reify_lazy_imports(self): def test_suggestion_still_works_for_non_lazy_attributes(self): """Suggestions should still work for non-lazy module attributes.""" code = textwrap.dedent(""" - lazy import test.test_lazy_import.data.pkg.bar + lazy import test.test_lazy_import.data.lazypkg # Typo for __name__ - test.test_lazy_import.data.pkg.__nme__ + test.test_lazy_import.data.lazypkg.__nme__ """) rc, stdout, stderr = assert_python_failure('-c', code) self.assertIn(b"__name__", stderr) diff --git a/Lib/test/test_tracemalloc.py b/Lib/test/test_tracemalloc.py index 9d3ff8a620b6f26..32a869c706270da 100644 --- a/Lib/test/test_tracemalloc.py +++ b/Lib/test/test_tracemalloc.py @@ -41,6 +41,8 @@ def get_frames(nframe, lineno_delta): def allocate_bytes(size): nframe = tracemalloc.get_traceback_limit() bytes_len = (size - EMPTY_STRING_SIZE) + if bytes_len < 0: + raise ValueError(f"{size} bytes is too small") frames = get_frames(nframe, 1) data = b'x' * bytes_len return data, tracemalloc.Traceback(frames, min(len(frames), nframe)) @@ -158,7 +160,7 @@ def test_new_reference(self): self.assertEqual(traceback, obj_traceback) def test_set_traceback_limit(self): - obj_size = 10 + obj_size = 123 tracemalloc.stop() self.assertRaises(ValueError, tracemalloc.start, -1) @@ -1056,8 +1058,8 @@ def test_track(self): self.check_track(False) def test_track_without_gil(self): - # check that calling _PyTraceMalloc_Track() without holding the GIL - # works too + # check that calling PyTraceMalloc_Track() without the GIL + # (detached thread state) still captures the Python traceback self.check_track(True) def test_track_already_tracked(self): diff --git a/Lib/test/test_tstring.py b/Lib/test/test_tstring.py index 74653c77c55de17..ea20688fdc97536 100644 --- a/Lib/test/test_tstring.py +++ b/Lib/test/test_tstring.py @@ -1,5 +1,8 @@ import unittest +from test import support +from test.support.os_helper import temp_cwd +from test.support.script_helper import assert_python_ok from test.test_string._support import TStringBaseCase, fstring @@ -79,6 +82,31 @@ def upper(self): ) self.assertEqual(fstring(t), "Name: Bob, Age: 30") + def test_interpolation_expression_in_file_after_buffer_resize(self): + expression = "(\n" + (" " * 64 + "\n") * 256 + "1\n)" + with temp_cwd(): + script = 'script.py' + source = ( + f"template = t'''{{{expression}}}'''\n" + "interpolation = template.interpolations[0]\n" + f"assert interpolation.expression == {expression!r}\n" + ) + with open(script, 'w') as f: + f.write(source) + assert_python_ok(script) + + @support.requires_resource('cpu') + def test_many_tstrings_in_module(self): + fields = ''.join(f'{{x{i}}}' for i in range(100)) + source = ''.join( + f"value_{i} = t'{fields}'\n" for i in range(1_000) + ) + namespace = {f'x{i}': str(i) for i in range(100)} + expected = ''.join(str(i) for i in range(100)) + exec(source, namespace) + self.assertEqual(fstring(namespace['value_0']), expected) + self.assertEqual(fstring(namespace['value_999']), expected) + def test_format_specifiers(self): # Test basic format specifiers value = 3.14159 @@ -88,6 +116,14 @@ def test_format_specifiers(self): ) self.assertEqual(fstring(t), "Pi: 3.14") + a = 3 + b = 4 + t = t"{a!=b:>10}" + self.assertTStringEqual( + t, ("", ""), [(a != b, "a!=b", None, ">10")] + ) + self.assertEqual(fstring(t), " 1") + def test_conversions(self): # Test !s conversion (str) obj = object() @@ -136,10 +172,91 @@ def test_debug_specifier(self): # Test white space in debug specifier t = t"Value: {value = }" self.assertTStringEqual( - t, ("Value: value = ", ""), [(value, "value", "r")] + t, ("Value: value = ", ""), [(value, "value ", "r")] ) self.assertEqual(fstring(t), "Value: value = 42") + # Explicit line continuations after the debug marker are part of + # the debug text, not the interpolation expression. + for template, strings, interpolation, rendered in ( + ( + t"""Value: {value =\ +}""", + ("Value: value =\\\n", ""), + (value, "value ", "r"), + "Value: value =\\\n42", + ), + ( + t"""Value: {value =\ +!r}""", + ("Value: value =\\\n", ""), + (value, "value ", "r"), + "Value: value =\\\n42", + ), + ( + t"""Value: {value =\ +:04}""", + ("Value: value =\\\n", ""), + (value, "value ", None, "04"), + "Value: value =\\\n0042", + ), + ( + t"""Value: {value =\ +\ +}""", + ("Value: value =\\\n\\\n", ""), + (value, "value ", "r"), + "Value: value =\\\n\\\n42", + ), + ): + with self.subTest(template=template): + self.assertTStringEqual(template, strings, [interpolation]) + self.assertEqual(fstring(template), rendered) + + class C: + def __format__(self, spec): + return f"FORMAT-{spec}" + + x = y = C() + t = t"{x:{y:{value=}}}" + self.assertEqual(t.interpolations[0].format_spec, + "FORMAT-value=42") + + def test_interpolation_expression_whitespace(self): + x = 42 + for template, expected in ( + (t"{x}", "x"), + (t"{x }", "x "), + (t"{ x}", " x"), + (t"{ x }", " x "), + (t"{ x }", " x "), + (t"""{ + x +}""", "\n x\n"), + (t"{ x !r}", " x "), + (t"{ x :.2f}", " x "), + (t"{ x = }", " x "), + (t"{ x = !r}", " x "), + (t"{ x = :.2f}", " x "), + (t"{x == 42 = }", "x == 42 "), + ): + with self.subTest(template=template): + self.assertEqual( + template.interpolations[0].expression, + expected, + ) + + def test_interpolation_expression_with_reconstructed_metadata(self): + regular = t'''{( + 1, # Force lexer metadata reconstruction. + "\"#")}''' + debug = t'''{( + 1, # Force lexer metadata reconstruction. + "\"#")=}''' + expected = '(\n 1, \n "\\"#")' + self.assertEqual(regular.interpolations[0].expression, expected) + self.assertEqual(debug.interpolations[0].expression, expected) + def test_raw_tstrings(self): path = r"C:\Users" t = rt"{path}\Documents" @@ -150,6 +267,14 @@ def test_raw_tstrings(self): t = tr"{path}\Documents" self.assertTStringEqual(t, ("", r"\Documents"), [(path, "path")]) + value = 42 + t = rt"{value:{f'\xFF'}}\n" + self.assertTStringEqual( + t, ("", "\\n"), [(value, "value", None, 'ÿ')]) + t = t"{value:{rf'\xFF'}}\n" + self.assertTStringEqual( + t, ("", "\n"), [(value, "value", None, '\\xFF')]) + def test_template_concatenation(self): # Test template + template t1 = t"Hello, " @@ -198,6 +323,8 @@ def test_nested_templates(self): def test_syntax_errors(self): for case, err in ( + ('t"""{(\n1\n)}\ntail', "unterminated triple-quoted t-string literal"), + ('f"""{(\n1\n)}\ntail', "unterminated triple-quoted f-string literal"), ("t'", "unterminated t-string literal"), ("t'''", "unterminated triple-quoted t-string literal"), ("t''''", "unterminated triple-quoted t-string literal"), @@ -217,6 +344,10 @@ def test_syntax_errors(self): ("t'{x=!}'", "t-string: missing conversion character"), ("t'{x!z}'", "t-string: invalid conversion character 'z': " "expected 's', 'r', or 'a'"), + ("f\"{t'{x!z}'}\"", "t-string: invalid conversion character 'z': " + "expected 's', 'r', or 'a'"), + ("t'{f\"{x!z}\"}'", "f-string: invalid conversion character 'z': " + "expected 's', 'r', or 'a'"), ("t'{lambda:1}'", "t-string: lambda expressions are not allowed " "without parentheses"), ("t'{x:{;}}'", "t-string: expecting a valid expression after '{'"), @@ -287,5 +418,22 @@ def test_triple_quoted(self): ) self.assertEqual(fstring(t), "\n Hello,\n Python\n ") + t = t'{"""a" # inside"""}' + self.assertEqual(t.interpolations[0].expression, + '"""a" # inside"""') + + t = t'{"""a""""#" # outside +}' + self.assertEqual(t.interpolations[0].expression, '"""a""""#" \n') + + x, y = 1, 2 + t = t'{x != y # outside +}' + self.assertEqual(t.interpolations[0].expression, 'x != y \n') + + d = {'a#b': 42} + t = t'''{f"{d["a#b"]}"}''' + self.assertEqual(t.interpolations[0].expression, 'f"{d["a#b"]}"') + if __name__ == '__main__': unittest.main() diff --git a/Lib/test/test_ttk/__init__.py b/Lib/test/test_ttk/__init__.py index 7a47f44ca382218..d066b70873c4392 100644 --- a/Lib/test/test_ttk/__init__.py +++ b/Lib/test/test_ttk/__init__.py @@ -20,13 +20,10 @@ class TestModule(unittest.TestCase): - def test_deprecated__version__(self): - with self.assertWarnsRegex( - DeprecationWarning, - "'__version__' is deprecated and slated for removal in Python 3.20", - ) as cm: - getattr(ttk, "__version__") - self.assertEqual(cm.filename, __file__) + def test_deprecated_module_attributes(self): + support.check_deprecated_module_attributes( + self, ttk, "__version__", "__author__", remove=(3, 20), + ) def setUpModule(): diff --git a/Lib/test/test_ttk/test_widgets.py b/Lib/test/test_ttk/test_widgets.py index 4fa6a032e97c5f8..223078625ecaad4 100644 --- a/Lib/test/test_ttk/test_widgets.py +++ b/Lib/test/test_ttk/test_widgets.py @@ -214,6 +214,13 @@ class LabelTest(AbstractLabelTest, unittest.TestCase): def create(self, **kwargs): return ttk.Label(self.root, **kwargs) + def test_configure_anchor(self): + widget = self.create() + values = ('n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'center') + if get_tk_patchlevel(self.root) >= (9, 0, 5): + values += ('',) + self.checkEnumParam(widget, 'anchor', *values) + test_configure_justify = StandardOptionsTests.test_configure_justify @@ -347,6 +354,7 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase): def setUp(self): super().setUp() self.entry = self.create() + self._allow_empty_justify = get_tk_patchlevel(self.root) >= (9, 0, 5) def create(self, **kwargs): return ttk.Entry(self.root, **kwargs) @@ -2024,19 +2032,23 @@ def test_virtual_events(self): lambda e: selects.append(self.tv.selection())) self.tv.bind('<>', lambda e: opens.append(self.tv.focus())) self.tv.bind('<>', lambda e: closes.append(self.tv.focus())) - self.tv.focus_force() self.tv.focus(parent) self.tv.selection_set(parent) self.tv.update() + # Force the focus right before generating the event: the window + # manager can take it back. + self.tv.focus_force() self.tv.event_generate('') # Open the focused parent. self.tv.update() self.assertEqual(opens, [parent]) + self.tv.focus_force() self.tv.event_generate('') # Close it again. self.tv.update() self.assertEqual(closes, [parent]) + self.tv.focus_force() self.tv.event_generate('') # Move the selection. self.tv.update() self.assertEqual(self.tv.selection(), (item2,)) diff --git a/Lib/test/test_ttk_textonly.py b/Lib/test/test_ttk_textonly.py index e6525c4d6c69822..7fecbb6305442be 100644 --- a/Lib/test/test_ttk_textonly.py +++ b/Lib/test/test_ttk_textonly.py @@ -169,7 +169,7 @@ def test_format_mapdict(self): def test_format_elemcreate(self): - self.assertTrue(ttk._format_elemcreate(None), (None, ())) + self.assertEqual(ttk._format_elemcreate(None), ((),)) ## Testing type = image # image type expects at least an image name, so this should raise diff --git a/Lib/test/test_tuple.py b/Lib/test/test_tuple.py index e533392b8cae94a..a3bd60eca4f6b15 100644 --- a/Lib/test/test_tuple.py +++ b/Lib/test/test_tuple.py @@ -38,6 +38,10 @@ def test_constructors(self): self.assertEqual(tuple(x for x in range(10) if x % 2), (1, 3, 5, 7, 9)) + def test_too_many_args(self): + with self.assertRaises(TypeError): + tuple([1, 2], 3) + def test_keyword_args(self): with self.assertRaisesRegex(TypeError, 'keyword argument'): tuple(sequence=()) @@ -119,6 +123,18 @@ def check_one_exact(t, e32, e64): check_one_exact((0.5, (), (-2, 3, (4, 6))), 714642271, -1845940830829704396) + @support.skip_if_huge_c_stack(500_000) + @support.skip_wasi_stack_overflow() + @support.skip_emscripten_stack_overflow() + def test_hash_deeply_nested(self): + # This should raise a RecursionError and not crash. + # See https://github.com/python/cpython/issues/154318. + t = () + for _ in range(500_000): + t = (t,) + with self.assertRaisesRegex(RecursionError, "while hashing a tuple"): + hash(t) + # Various tests for hashing of tuples to check that we get few collisions. # Does something only if RUN_ALL_HASH_TESTS is true. # @@ -434,6 +450,45 @@ def test_lexicographic_ordering(self): self.assertLess(a, b) self.assertLess(b, c) + def test_hash_unhashable_note(self): + with self.assertRaisesRegex(TypeError, "unhashable type: 'list'") as cm: + hash(("alice", [])) + self.assertEqual(cm.exception.__notes__, + ["when hashing tuple item 1"]) + + with self.assertRaisesRegex(TypeError, "unhashable type: 'list'") as cm: + hash((("alice", []), 42)) + self.assertEqual(cm.exception.__notes__, + ["when hashing tuple item 1", + "when hashing tuple item 0"]) + + class BrokenHash: + def __hash__(self): + raise TypeError("custom failure") + + with self.assertRaisesRegex(TypeError, "custom failure") as cm: + hash((BrokenHash(),)) + self.assertEqual(cm.exception.__notes__, ["when hashing tuple item 0"]) + + class BrokenHashNote: + def __hash__(self): + exc = TypeError("custom failure") + exc.add_note("from custom hash") + raise exc + + with self.assertRaisesRegex(TypeError, "custom failure") as cm: + hash((BrokenHashNote(),)) + self.assertEqual(cm.exception.__notes__, + ["from custom hash", "when hashing tuple item 0"]) + + class BrokenHashValueError: + def __hash__(self): + raise ValueError("custom failure") + + with self.assertRaisesRegex(ValueError, "custom failure") as cm: + hash((BrokenHashValueError(),)) + self.assertFalse(hasattr(cm.exception, "__notes__")) + # Notes on testing hash codes. The primary thing is that Python doesn't # care about "random" hash codes. To the contrary, we like them to be # very regular when possible, so that the low-order bits are as evenly diff --git a/Lib/test/test_turtle.py b/Lib/test/test_turtle.py index c49ce9cdb6f6d95..88e18e7daa5c5a4 100644 --- a/Lib/test/test_turtle.py +++ b/Lib/test/test_turtle.py @@ -7,6 +7,7 @@ from test import support from test.support import import_helper from test.support import os_helper +from test.support.script_helper import assert_python_ok turtle = import_helper.import_module('turtle') @@ -693,6 +694,34 @@ def test_dot_signature(self): self.assertRaises(turtle.TurtleGraphicsError, self.turtle.dot, 0, (0, 257, 0)) self.assertRaises(turtle.TurtleGraphicsError, self.turtle.dot, 0, 0, 257, 0) + def test_circle_undo(self): + self.turtle.circle(50, 90) + self.turtle.undo() + self.assertEqual(self.turtle.pos(), (0, 0)) + self.assertEqual(self.turtle.undobufferentries(), 0) + + def test_undo_sequence_resets_after_exception(self): + with unittest.mock.patch.object(self.turtle, "_write", + side_effect=ValueError): + self.assertRaises(ValueError, self.turtle.write, "spam") + self.assertFalse(self.turtle.undobuffer.cumulate) + + def test_nested_undo_sequence(self): + with self.turtle._undo_sequence(): + self.turtle.teleport(10, 20) + self.turtle.forward(10) + self.assertEqual(self.turtle.undobufferentries(), 1) + self.turtle.undo() + self.assertEqual(self.turtle.pos(), (0, 0)) + + def test_stamp_without_undobuffer(self): + shape = turtle.Shape("polygon", ((0, 0), (5, 9), (-5, 9))) + self.turtle.screen._shapes = {self.turtle.shape(): shape} + self.turtle.setundobuffer(None) + stamp = self.turtle.stamp() + self.turtle.clearstamp(stamp) + self.assertEqual(self.turtle.stampItems, []) + class TestModuleLevel(unittest.TestCase): def test_all_signatures(self): import inspect @@ -713,5 +742,33 @@ def test_all_signatures(self): self.assertEqual(str(sig), known_signatures[name]) +class TurtleDocstringTranslationTest(unittest.TestCase): + + def _make_translation(self, dirname, filename, docstring): + with open(os.path.join(dirname, filename), 'w') as f: + f.write('docsdict = {"Turtle.forward": %r}\n' % docstring) + + def _get_forward_docstring(self, dirname, lang): + rc, out, err = assert_python_ok( + '-c', 'import turtle; print(turtle.forward.__doc__)', + PYTHONPATH=dirname, PYTHON_TURTLE_LANG=lang) + return out.decode() + + def test_translation(self): + with os_helper.temp_dir() as dirname: + self._make_translation(dirname, 'turtle_docstringdict_ga.py', + 'chun tosaigh') + + out = self._get_forward_docstring(dirname, 'ga') + self.assertIn('chun tosaigh', out) + + def test_unknown_language(self): + with os_helper.temp_dir() as dirname: + out = self._get_forward_docstring(dirname, 'ga') + + self.assertIn('Cannot find docsdict for ga', out) + self.assertIn('Move the turtle forward', out) + + if __name__ == '__main__': unittest.main() diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index 05bc6a80888a067..d80a7fbfd18796d 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -1,7 +1,8 @@ import pickle import types import unittest -from test.support import check_syntax_error, run_code +import weakref +from test.support import check_syntax_error, gc_collect, run_code from test.typinganndata import mod_generics_cache from typing import ( @@ -131,6 +132,24 @@ def more_generic[T, *Ts, **P](): T, Ts, P = more_generic.__type_params__ self.assertEqual(alias.__value__, tuple[Callable[P, tuple[T, *Ts]], Callable[P2, tuple[T2, *Ts2]]]) + def test_reentrant_value_does_not_leak(self): + class Value: + pass + + refs = [] + + def compute(): + value = Value() + refs.append(weakref.ref(value)) + if len(refs) == 1: + Alias.__value__ + return value + + type Alias = compute() + self.assertIs(Alias.__value__, refs[0]()) + gc_collect() + self.assertIsNone(refs[1]()) + def test_subscripting(self): type NonGeneric = int type Generic[A] = dict[A, A] diff --git a/Lib/test/test_type_annotations.py b/Lib/test/test_type_annotations.py index b751f825bb97d59..02f3e8b9caddb4c 100644 --- a/Lib/test/test_type_annotations.py +++ b/Lib/test/test_type_annotations.py @@ -1,5 +1,6 @@ import annotationlib import inspect +import itertools import textwrap import types import unittest @@ -152,7 +153,11 @@ class D(metaclass=C): self.assertEqual(D.__annotations__, {}) def test_partially_executed_module(self): - partialexe = import_helper.import_fresh_module("test.typinganndata.partialexecution") + # Results are different with and without lazy imports, we need both: + partialexe = import_helper.import_fresh_module( + "test.typinganndata.partialexecution", + eager_imports=False, + ) self.assertEqual( partialexe.a.__annotations__, {"v1": int, "v2": int}, @@ -327,6 +332,18 @@ def check_annotations(self, f): f.__annotations__ = {"z": 43} self.assertIs(f.__annotate__, None) + def test_annotate_sets_annotations(self): + # If __annotate__ sets the function's annotations while it runs, + # those are kept instead of the result of the call. + def f(): + pass + def annotate(format): + f.__annotations__ = {"x": int} + return {"y": str} + f.__annotate__ = annotate + self.assertEqual(f.__annotations__, {"x": int}) + self.assertIs(f.__annotate__, None) + def test_user_defined_annotate(self): class X: a: int @@ -492,6 +509,32 @@ class C: """) self.assertEqual(ns["C"].__annotations__, {"__classdict__": int}) + def test_class_binds_dunder_classdict(self): + # The class body binding __classdict__ must not hide the cell that + # annotation and type parameter scopes use to see the class namespace. + for binding in ( + "__classdict__ = 1", + "__classdict__: str = 1", + "for __classdict__ in (1,): pass", + "global __classdict__", + ): + with self.subTest(binding=binding): + ns = run_code(f""" + class C: + {binding} + y = int + def f(x: y): pass + class D[T: y]: pass + class E[T]: pass + type A[T: y] = y + """) + C = ns["C"] + self.assertEqual(C.f.__annotations__, {"x": int}) + self.assertIs(C.D.__type_params__[0].__bound__, int) + self.assertEqual(C.E.__type_params__[0].__name__, "T") + self.assertIs(C.A.__type_params__[0].__bound__, int) + self.assertIs(C.A.__value__, int) + def test_future_annotations(self): code = """ from __future__ import annotations @@ -896,3 +939,18 @@ class Generic: mod = build_module(code) annos = mod.__annotations__ self.assertEqual(annos, {"annotated_name": 0}) + + # gh-154902 + def test_conditional_annotations_rebound(self): + # user code can rebind __conditional_annotations__ to any object + lefts = ("__conditional_annotations__", + 'globals()["__conditional_annotations__"]') + values = ("0", "{}", "[]", "''", "object()", "frozenset()") + for left, value in itertools.product(lefts, values): + with self.subTest(left=left, value=value): + code = f""" + {left} = {value} + x: int + """ + with self.assertRaises(TypeError): + run_code(code) diff --git a/Lib/test/test_type_cache.py b/Lib/test/test_type_cache.py index 849a2afd8ed7986..0031e4b59c67c9b 100644 --- a/Lib/test/test_type_cache.py +++ b/Lib/test/test_type_cache.py @@ -1,6 +1,7 @@ """ Tests for the internal type cache in CPython. """ import collections.abc import dis +import sys import unittest import warnings from test import support @@ -10,13 +11,15 @@ except ImportError: _clear_type_cache = None -# Skip this test if the _testcapi module isn't available. +# Skip this test if the _testcapi modules are not available. _testcapi = import_helper.import_module("_testcapi") +_testlimitedcapi = import_helper.import_module("_testlimitedcapi") _testinternalcapi = import_helper.import_module("_testinternalcapi") + type_get_version = _testcapi.type_get_version type_assign_specific_version_unsafe = _testinternalcapi.type_assign_specific_version_unsafe type_assign_version = _testcapi.type_assign_version -type_modified = _testcapi.type_modified +type_modified = _testlimitedcapi.type_modified def clear_type_cache(): with warnings.catch_warnings(): @@ -281,5 +284,163 @@ def to_bool_2(instance): self._check_specialization(to_bool_2, H(), "TO_BOOL", should_specialize=False) +@support.cpython_only +class PerTypeLookupCacheTests(unittest.TestCase): + """Tests for the per-type lookup cache.""" + + type_cache_lookup = staticmethod(_testinternalcapi.type_cache_lookup) + type_cache_invalidate = staticmethod(_testinternalcapi.type_cache_invalidate) + + def _make_type(self): + class C: + x = "x-value" + return C + + def test_lookup_miss_on_empty_cache(self): + # A freshly-created type has not cached any names yet; the cache + # should report a miss for an arbitrary name. + C = self._make_type() + hit, value, version = self.type_cache_lookup(C, "x") + self.assertEqual(hit, 0) + self.assertIsNone(value) + self.assertEqual(version, 0) + + def test_lookup_hit_after_access(self): + # Reading an attribute goes through _PyType_Lookup which + # caches the result. Subsequent lookups for the same name + # should hit the cache. + C = self._make_type() + hit, value, version = self.type_cache_lookup(C, "x") + self.assertEqual(hit, 0) + attr = C.x + hit, value, version = self.type_cache_lookup(C, "x") + self.assertEqual(hit, 1) + self.assertIs(value, attr) + self.assertNotEqual(version, 0) + self.assertEqual(version, type_get_version(C)) + + def test_lookup_caches_missing_name(self): + # _PyType_Lookup caches negative results too: a name that is not in + # the MRO should still produce a cache hit with a None value. + C = self._make_type() + with self.assertRaises(AttributeError): + C.does_not_exist + hit, value, _ = self.type_cache_lookup(C, "does_not_exist") + self.assertEqual(hit, 1) + self.assertIsNone(value) + + def test_lookup_on_static_type(self): + # The cache for static types is stored on interpreter for isolation + # between subinterpreters, test that cache works for them as well. + self.type_cache_invalidate(int) + name = sys.intern("bit_length") + self.assertEqual(self.type_cache_lookup(int, name)[0], 0) + attr = getattr(int, name) + hit, value, _ = self.type_cache_lookup(int, name) + self.assertEqual(hit, 1) + self.assertIs(value, attr) + + def test_invalidate_clears_cache(self): + C = self._make_type() + C.x # populate cache + self.assertEqual(self.type_cache_lookup(C, "x")[0], 1) + + self.type_cache_invalidate(C) + hit, value, _ = self.type_cache_lookup(C, "x") + self.assertEqual(hit, 0) + self.assertIsNone(value) + + def test_setattr_invalidates_cache(self): + # Mutating a type's attributes must invalidate any cached entries + # for that type. + C = self._make_type() + C.x + self.assertEqual(self.type_cache_lookup(C, "x")[0], 1) + + C.x = "new-value" + hit, _, _ = self.type_cache_lookup(C, "x") + self.assertEqual(hit, 0) + + # The next access should re-populate the cache with the new value. + self.assertEqual(C.x, "new-value") + hit, value, _ = self.type_cache_lookup(C, "x") + self.assertEqual(hit, 1) + self.assertEqual(value, "new-value") + + def test_setattr_on_subclass_preserves_base(self): + # Adding an attribute to a subclass changes the lookup result for + # the subclass, so its cache must be invalidated, but the base's + # cache for the same name stays valid. + class Base: + x = "base" + class Sub(Base): + pass + + self.assertEqual(Sub.x, "base") + self.assertEqual(Base.x, "base") + self.assertEqual(self.type_cache_lookup(Sub, "x")[0], 1) + self.assertEqual(self.type_cache_lookup(Base, "x")[0], 1) + + Sub.x = "sub" + # Sub's cache should be invalidated. + self.assertEqual(self.type_cache_lookup(Sub, "x")[0], 0) + # Base is untouched. + hit, value, _ = self.type_cache_lookup(Base, "x") + self.assertEqual(hit, 1) + self.assertEqual(value, "base") + + def test_setattr_on_base_invalidates_subclass(self): + class Base: + x = "base" + class Sub(Base): + pass + + Sub.x + self.assertEqual(self.type_cache_lookup(Sub, "x")[0], 1) + + Base.x = "new-base" + # Modifying the base must invalidate the subclass cache too. + self.assertEqual(self.type_cache_lookup(Sub, "x")[0], 0) + + def test_lookup_detects_stale_cache_version(self): + # The cache stores the type's tp_version_tag alongside its entries + # and re-checks it after locating a hit. If the type version moves + # forward without the cache being invalidated (the race window in + # lock-free invalidation), the consistency check must downgrade + # the hit to a miss. + C = self._make_type() + C.x # populate cache + orig_version = type_get_version(C) + self.assertNotEqual(orig_version, 0) + self.assertEqual(self.type_cache_lookup(C, "x")[0], 1) + + # Bump the type version directly without touching the cache slot + # (PyType_Modified would also invalidate, defeating the test). + type_assign_specific_version_unsafe(C, orig_version + 1) + self.assertEqual(type_get_version(C), orig_version + 1) + + hit, value, _ = self.type_cache_lookup(C, "x") + self.assertEqual(hit, 0) + self.assertIsNone(value) + + def test_setattr_on_unrelated_type_preserves_cache(self): + # Modifying one type must not invalidate a sibling's cache. + class A: + x = "a" + class B: + x = "b" + + A.x + B.x + self.assertEqual(self.type_cache_lookup(A, "x")[0], 1) + self.assertEqual(self.type_cache_lookup(B, "x")[0], 1) + + B.x = "b2" + # A's cache is unaffected. + hit, value, _ = self.type_cache_lookup(A, "x") + self.assertEqual(hit, 1) + self.assertEqual(value, "a") + + if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_type_comments.py b/Lib/test/test_type_comments.py index d827ac271085bdd..832a1e283e0c279 100644 --- a/Lib/test/test_type_comments.py +++ b/Lib/test/test_type_comments.py @@ -338,6 +338,16 @@ def test_ignores(self): tree = self.classic_parse(ignores) self.assertEqual(tree.type_ignores, []) + def test_many_ignores(self): + comment_count = 25 + tags = [f"[tag_{index}]" for index in range(comment_count)] + source = "".join(f"pass # type: ignore{tag}\n" for tag in tags) + for tree in self.parse_all(source): + self.assertEqual( + [(item.lineno, item.tag) for item in tree.type_ignores], + list(enumerate(tags, start=1)), + ) + def test_longargs(self): for tree in self.parse_all(longargs, minver=8): for t in tree.body: diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 17574c7f03d8e1e..3879c49c714dd9b 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -1,4 +1,5 @@ import annotationlib +import atexit import contextlib import collections import collections.abc @@ -20,7 +21,7 @@ from typing import Any, NoReturn, Never, assert_never from typing import overload, get_overloads, clear_overloads -from typing import TypeVar, TypeVarTuple, Unpack, AnyStr +from typing import TypeVar, TypeVarTuple, Unpack from typing import T, KT, VT # Not in __all__. from typing import Union, Optional, Literal from typing import Tuple, List, Dict, MutableMapping @@ -52,6 +53,8 @@ from test.support import ( captured_stderr, cpython_only, requires_docstrings, import_helper, run_code, subTests, EqualToForwardRef, + exceeds_recursion_limit, run_with_limited_c_stack, + skip_wasi_stack_overflow, skip_emscripten_stack_overflow, ) from test.typinganndata import ( ann_module695, mod_generics_cache, _typed_dict_helper, @@ -486,7 +489,6 @@ def test_repr(self): self.assertEqual(repr(T), '~T') self.assertEqual(repr(KT), '~KT') self.assertEqual(repr(VT), '~VT') - self.assertEqual(repr(AnyStr), '~AnyStr') T_co = TypeVar('T_co', covariant=True) self.assertEqual(repr(T_co), '+T_co') T_contra = TypeVar('T_contra', contravariant=True) @@ -2801,8 +2803,14 @@ def test_args(self): self.assertEqual(Literal[1, 2, 3].__args__, (1, 2, 3)) self.assertEqual(Literal[1, 2, 3, 3].__args__, (1, 2, 3)) self.assertEqual(Literal[1, Literal[2], Literal[3, 4]].__args__, (1, 2, 3, 4)) - # Mutable arguments will not be deduplicated - self.assertEqual(Literal[[], []].__args__, ([], [])) + # Unhashable arguments will be deduplicated too + self.assertEqual(Literal[[], []].__args__, ([],)) + self.assertEqual(Literal[{"a": 1}, {"a": 1}].__args__, ({"a": 1},)) + self.assertEqual( + Literal[1, {'a': 'b'}, 2, {'a': 'b'}, 3].__args__, + (1, {'a': 'b'}, 2, 3), + ) + self.assertEqual(Literal[{1}, {1}, {2}, {2}].__args__, ({1}, {2})) def test_flatten(self): l1 = Literal[Literal[1], Literal[2], Literal[3]] @@ -5088,6 +5096,17 @@ class MM2(collections.abc.MutableMapping, MutableMapping[str, str]): pass self.assertEqual(MM2.__bases__, (collections.abc.MutableMapping, Generic)) + @cpython_only + @run_with_limited_c_stack() + @skip_wasi_stack_overflow() + @skip_emscripten_stack_overflow() + def test_parameters_deep_recursion(self): + x = [0] + for _ in range(exceeds_recursion_limit()): + x = [x] + with self.assertRaisesRegex(RecursionError, "in __parameter__ calculation"): + list[x].__parameters__ + def test_orig_bases(self): T = TypeVar('T') class C(typing.Dict[str, T]): ... @@ -6034,6 +6053,22 @@ class A: with self.assertRaises(TypeError): a[int] + def test_parameter_added_after_parameters_cached(self): + # gh-155752: GenericAlias parameters are cached before substitution, so + # an argument can gain __typing_subst__ after the tuple is calculated. + class Parameter: + pass + + first = Parameter() + first.__typing_subst__ = lambda value: value + late = Parameter() + alias = types.GenericAlias(dict, (first, late)) + self.assertEqual(alias.__parameters__, (first,)) + late.__typing_subst__ = lambda value: value + + with self.assertRaisesRegex(TypeError, "not found in __parameters__"): + alias[0] + def test_return_non_tuple_while_unpacking(self): # GH-138497: GenericAlias objects didn't ensure that __typing_subst__ actually # returned a tuple @@ -6352,13 +6387,15 @@ def on_bottom(self, a: int) -> int: class CastTests(BaseTestCase): def test_basics(self): + T = TypeVar("T") + self.assertEqual(cast(int, 42), 42) self.assertEqual(cast(float, 42), 42) self.assertIs(type(cast(float, 42)), int) self.assertEqual(cast(Any, 42), 42) self.assertEqual(cast(list, 42), 42) self.assertEqual(cast(Union[str, float], 42), 42) - self.assertEqual(cast(AnyStr, 42), 42) + self.assertEqual(cast(T, 42), 42) self.assertEqual(cast(None, 42), 42) def test_errors(self): @@ -6371,9 +6408,10 @@ class AssertTypeTests(BaseTestCase): def test_basics(self): arg = 42 + T = TypeVar("T") self.assertIs(assert_type(arg, int), arg) self.assertIs(assert_type(arg, str | float), arg) - self.assertIs(assert_type(arg, AnyStr), arg) + self.assertIs(assert_type(arg, T), arg) self.assertIs(assert_type(arg, None), arg) def test_errors(self): @@ -6531,6 +6569,14 @@ class F: class InternalsTests(BaseTestCase): def test_collect_parameters(self): typing = import_helper.import_fresh_module("typing") + # Importing typing registers an internal function named _clear_caches + # with atexit. The throwaway module created here installs its own + # handler, which holds the module alive and keeps references until + # interpreter shutdown even after the test finishes. Each repetition + # of this test under -R would therefore leak another module copy. To + # avoid this, we unregister the handler once the test is done. + self.addCleanup(atexit.unregister, typing._clear_caches) + with self.assertWarnsRegex( DeprecationWarning, "The private _collect_parameters function is deprecated" @@ -7700,6 +7746,10 @@ def test_bytestring(self): with self.assertWarns(DeprecationWarning): from typing import ByteString + # Drop the exit handler of this throwaway copy, see the comment in + # InternalsTests.test_collect_parameters. + self.addCleanup(atexit.unregister, sys.modules["typing"]._clear_caches) + with self.assertWarns(DeprecationWarning): self.assertIsInstance(b'', ByteString) with self.assertWarns(DeprecationWarning): @@ -9589,12 +9639,15 @@ def test_no_isinstance(self): class IOTests(BaseTestCase): def test_io(self): - - def stuff(a: IO) -> AnyStr: + def stuff(a: IO): return a.readline() a = stuff.__annotations__['a'] - self.assertEqual(a.__parameters__, (AnyStr,)) + self.assertEqual(len(a.__parameters__), 1) + any_str = a.__parameters__[0] + self.assertEqual(repr(any_str), 'AnyStr') + self.assertEqual(any_str.__bound__, None) + self.assertEqual(any_str.__constraints__, (bytes, str)) def test_textio(self): @@ -9774,6 +9827,7 @@ def test_order_in_union(self): for args in itertools.permutations(get_args(expr1)): with self.subTest(args=args): self.assertEqual(expr1, reduce(operator.or_, args)) + self.assertEqual(expr1, Union[args]) expr2 = Union[Annotated[int, 1], str, Annotated[str, {}], int] for args in itertools.permutations(get_args(expr2)): @@ -10250,6 +10304,17 @@ def test_args_kwargs(self): self.assertEqual(repr(P.args), "P.args") self.assertEqual(repr(P.kwargs), "P.kwargs") + def test_args_kwargs_weakrefs(self): + P = ParamSpec('P') + for attr_name in ('args', 'kwargs'): + with self.subTest(attr_name=attr_name): + callback_fired = [] + attr = getattr(P, attr_name) + ref = weakref.ref(attr, lambda _: callback_fired.append(True)) + del attr + self.assertEqual(callback_fired, [True]) + self.assertIsNone(ref()) + def test_stringized(self): P = ParamSpec('P') class C(Generic[P]): @@ -11225,13 +11290,23 @@ def test_all_exported_names(self): # there's a few types and metaclasses that aren't exported not k.endswith(('Meta', '_contra', '_co')) and not k.upper() == k and - k not in {"ByteString"} and + k not in {"ByteString", "AnyStr"} and # but export all other things that have __module__ == 'typing' getattr(v, '__module__', None) == typing.__name__ ) } self.assertSetEqual(computed_all, actual_all) + def test_any_str_deprecated(self): + # gh-105578 + fresh = import_helper.import_fresh_module('typing') + self.addCleanup(atexit.unregister, fresh._clear_caches) + + with self.assertWarnsRegex(DeprecationWarning, r'typing\.AnyStr'): + fresh.AnyStr + + self.assertEqual(repr(fresh.AnyStr), '~AnyStr') + class TypeIterationTests(BaseTestCase): _UNITERABLE_TYPES = ( diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py index ad25be3da8cb347..317195283255a42 100644 --- a/Lib/test/test_unicodedata.py +++ b/Lib/test/test_unicodedata.py @@ -55,9 +55,9 @@ def download_test_data_file(filename): class UnicodeMethodsTest(unittest.TestCase): # update this, if the database changes - expectedchecksum = ('47a99fa654ef1f50e89d2e9697b7b041fccb5a05' + expectedchecksum = ('2bb59305a65254fee9cd6ef981cc3cab7551c60e' if quicktest else - '8b2615a9fc627676cbc0b6fac0191177df97ef5f') + 'bb69894a259aee5971445eca8e617a1686a432e2') def test_method_checksum(self): h = hashlib.sha1() @@ -321,7 +321,7 @@ def test_category(self): self.assertRaises(TypeError, self.db.category, 'xx') def test_bidirectional(self): - self.assertEqual(self.db.bidirectional('\uFFFE'), 'BN') + self.assertEqual(self.db.bidirectional('\uFFFE'), '' if self.old else 'BN') self.assertEqual(self.db.bidirectional(' '), 'WS') self.assertEqual(self.db.bidirectional('A'), 'L') self.assertEqual(self.db.bidirectional('\U00020000'), 'L') @@ -350,15 +350,13 @@ def test_bidirectional(self): self.assertRaises(TypeError, self.db.bidirectional, 'xx') def test_bidirectional_unassigned(self): - if self.old: - return - self.assertEqual(self.db.bidirectional('\u0378'), 'L') - self.assertEqual(self.db.bidirectional('\u077F'), 'AL') - self.assertEqual(self.db.bidirectional('\u20CF'), 'ET') - self.assertEqual(self.db.bidirectional('\u0590'), 'R') - self.assertEqual(self.db.bidirectional('\uFFFF'), 'BN') - self.assertEqual(self.db.bidirectional('\U0001FFFE'), 'BN') - self.assertEqual(self.db.bidirectional('\U00010D01'), 'AL') + self.assertEqual(self.db.bidirectional('\u0378'), '' if self.old else 'L') + self.assertEqual(self.db.bidirectional('\u077F'), '' if self.old else 'AL') + self.assertEqual(self.db.bidirectional('\u20CF'), '' if self.old else 'ET') + self.assertEqual(self.db.bidirectional('\u0590'), '' if self.old else 'R') + self.assertEqual(self.db.bidirectional('\uFFFF'), '' if self.old else 'BN') + self.assertEqual(self.db.bidirectional('\U0001FFFE'), '' if self.old else 'BN') + self.assertEqual(self.db.bidirectional('\U00010D01'), '' if self.old else 'AL') def test_decomposition(self): self.assertEqual(self.db.decomposition('\uFFFE'),'') @@ -702,7 +700,7 @@ def test_east_asian_width(self): def test_east_asian_width_unassigned(self): eaw = self.db.east_asian_width # unassigned - for char in '\u0530\u0ecf\u10c6\u20fc\uaaca\U000107bd\U000115f2': + for char in '\u0530\u0ecf\u10c6\u20fc\uaaca\U000107c0\U000115f2': self.assertEqual(eaw(char), 'N') self.assertIs(self.db.name(char, None), None) @@ -723,9 +721,9 @@ class UnicodeFunctionsTest(unittest.TestCase, BaseUnicodeFunctionsTest): # Update this if the database changes. Make sure to do a full rebuild # (e.g. 'make distclean && make') to get the correct checksum. - expectedchecksum = ('00b13fa975a60b1d3f490f1fc8c126ab24990c75' + expectedchecksum = ('04a01eac45fd6ca3cfa5aafe90f278c1f7d62aa2' if quicktest else - 'ebfc9dd281c2226998fd435744dd2e9321899beb') + '33777a351769adcffb3c53f4c25cf8a8e102b622') @requires_resource('network') def test_all_names(self): @@ -994,6 +992,15 @@ def graphemes(*args): ['\u0915\u094D\u094D\u0924']) self.assertEqual(graphemes('\u0915\u094D\u0924\u094D\u092F'), ['\u0915\u094D\u0924\u094D\u092F']) + self.assertEqual(graphemes('\u094D\u0924'), ['\u094D\u0924']) + self.assertEqual(graphemes('\u094D\u0300\u0924'), + ['\u094D\u0300\u0924']) + self.assertEqual(graphemes('\u1CF5\u0915'), ['\u1CF5\u0915']) + self.assertEqual(graphemes('\u0915\u0924'), ['\u0915', '\u0924']) + self.assertEqual(graphemes('\u094D\u0924\u0924'), + ['\u094D\u0924', '\u0924']) + self.assertEqual(graphemes('\u094D\u200C\u0924'), + ['\u094D\u200C', '\u0924']) # GB11 self.assertEqual(graphemes( '\U0001F9D1\U0001F3FE\u200D\u2764\uFE0F' @@ -1104,9 +1111,9 @@ def test_block_invalid_input(self): class Unicode_3_2_0_FunctionsTest(unittest.TestCase, BaseUnicodeFunctionsTest): db = unicodedata.ucd_3_2_0 old = True - expectedchecksum = ('cb5bbbd1f55b67371e18222b90a8e21c87f16b72' + expectedchecksum = ('883824cb6c0ccf994e4451ebf281e2d6d479af47' if quicktest else - '74936dffe949d99203a47e6a66565b2fc337bae7') + '677542db0fed40ddbd491b95622cb649a4b7fca0') class UnicodeMiscTest(unittest.TestCase): diff --git a/Lib/test/test_unittest/test_discovery.py b/Lib/test/test_unittest/test_discovery.py index 38c9779daaf87d4..da184bd12be8d17 100644 --- a/Lib/test/test_unittest/test_discovery.py +++ b/Lib/test/test_unittest/test_discovery.py @@ -635,7 +635,7 @@ def test_command_line_handling_discover_by_default_with_options(self): program._do_discovery = args.append program.parseArgs(['something', '-v', '-b', '-v', '-c', '-f']) self.assertEqual(args, [[]]) - self.assertEqual(program.verbosity, 2) + self.assertEqual(program.verbosity, 3) # -v is passed twice self.assertIs(program.buffer, True) self.assertIs(program.catchbreak, True) self.assertIs(program.failfast, True) diff --git a/Lib/test/test_unittest/test_program.py b/Lib/test/test_unittest/test_program.py index 8ed92373e5e984a..a9a73f0d057ee81 100644 --- a/Lib/test/test_unittest/test_program.py +++ b/Lib/test/test_unittest/test_program.py @@ -267,6 +267,32 @@ def testVerbosity(self): program.parseArgs([None, opt]) self.assertEqual(program.verbosity, 2) + # -v can be repeated to ask for more details. + for args, verbosity in ( + (['-vv'], 3), + (['-v', '-v'], 3), + (['--verbose', '--verbose'], 3), + (['-vvv'], 4), + # -q overrides any number of -v. + (['-v', '-q'], 0), + ): + with self.subTest(args=args): + program.verbosity = 1 + program.parseArgs([None, *args]) + self.assertEqual(program.verbosity, verbosity) + + def testVerbosityCountedOnce(self): + # "python -m unittest -v" falls back to test discovery, which parses + # arguments again: -v must not be counted twice. + program = self.program + program.verbosity = 1 + program.parseArgs([None, '-v']) + self.assertEqual(program.verbosity, 2) + + program.verbosity = 1 + program.parseArgs([None, 'discover', '-vv']) + self.assertEqual(program.verbosity, 3) + def testBufferCatchFailfast(self): program = self.program for arg, attr in (('buffer', 'buffer'), ('failfast', 'failfast'), diff --git a/Lib/test/test_unittest/test_result.py b/Lib/test/test_unittest/test_result.py index 3f44e617303f81d..cb591c23fc964fd 100644 --- a/Lib/test/test_unittest/test_result.py +++ b/Lib/test/test_unittest/test_result.py @@ -54,6 +54,13 @@ def test_init(self): self.assertEqual(result.shouldStop, False) self.assertIsNone(result._stdout_buffer) self.assertIsNone(result._stderr_buffer) + self.assertEqual(result.verbosity, 1) + + def test_init_verbosity(self): + for verbosity in range(4): + with self.subTest(verbosity=verbosity): + result = unittest.TestResult(None, None, verbosity) + self.assertEqual(result.verbosity, verbosity) # "This method can be called to signal that the set of tests being # run should be aborted by setting the TestResult's shouldStop diff --git a/Lib/test/test_unittest/test_runner.py b/Lib/test/test_unittest/test_runner.py index a47e2ebb59da028..195d5e928030927 100644 --- a/Lib/test/test_unittest/test_runner.py +++ b/Lib/test/test_unittest/test_runner.py @@ -1363,6 +1363,35 @@ def MockResultClass(*args): expectedresult = (runner.stream, DESCRIPTIONS, VERBOSITY) self.assertEqual(runner._makeResult(), expectedresult) + def test_verbosity_set_on_result(self): + class Suite: + def __call__(self, result): + pass + + for verbosity in range(4): + with self.subTest(verbosity=verbosity): + runner = unittest.TextTestRunner(io.StringIO(), + verbosity=verbosity) + result = runner.run(Suite()) + self.assertEqual(result.verbosity, verbosity) + + def test_verbosity_set_on_filtering_result(self): + # A result class is free to filter the verbosity which its + # constructor gets, as test.libregrtest does. + class FilteringResult(unittest.TextTestResult): + def __init__(self, stream, descriptions, verbosity): + super().__init__(stream, descriptions, + 2 if verbosity else 0) + + class Suite: + def __call__(self, result): + pass + + runner = unittest.TextTestRunner(io.StringIO(), verbosity=3, + resultclass=FilteringResult) + result = runner.run(Suite()) + self.assertEqual(result.verbosity, 3) + @support.force_not_colorized @support.requires_subprocess() def test_warnings(self): diff --git a/Lib/test/test_unittest/testmock/testhelpers.py b/Lib/test/test_unittest/testmock/testhelpers.py index 0e82c723ec3eaa2..476e9105063bf99 100644 --- a/Lib/test/test_unittest/testmock/testhelpers.py +++ b/Lib/test/test_unittest/testmock/testhelpers.py @@ -1,8 +1,9 @@ import inspect -import time import types import unittest +from test.support import import_helper + from unittest.mock import ( call, _Call, create_autospec, MagicMock, Mock, ANY, _CallList, patch, PropertyMock, _callable @@ -929,8 +930,10 @@ def check_data_descriptor(mock_attr): def test_autospec_on_bound_builtin_function(self): - meth = types.MethodType(time.ctime, time.time()) - self.assertIsInstance(meth(), str) + _testcapi = import_helper.import_module('_testcapi') + # This function is defined without a signature. + meth = types.MethodType(_testcapi.docstring_no_signature, object()) + self.assertIsNone(meth()) mocked = create_autospec(meth) # no signature, so no spec to check against diff --git a/Lib/test/test_unittest/testmock/testmock.py b/Lib/test/test_unittest/testmock/testmock.py index 764585ec5d54688..ffc89dc5ce1562d 100644 --- a/Lib/test/test_unittest/testmock/testmock.py +++ b/Lib/test/test_unittest/testmock/testmock.py @@ -1073,6 +1073,10 @@ def test_dir(self): mock.__iter__ = lambda s: iter([]) self.assertIn('__iter__', dir(mock)) + # spec from a tuple + mock_tuple_spec = Mock(spec=('something',)) + self.assertIn('something', dir(mock_tuple_spec)) + def test_dir_from_spec(self): mock = Mock(spec=unittest.TestCase) diff --git a/Lib/test/test_unittest/testmock/testpatch.py b/Lib/test/test_unittest/testmock/testpatch.py index bd85fdcfc472a61..bd2a7fb6d6731d7 100644 --- a/Lib/test/test_unittest/testmock/testpatch.py +++ b/Lib/test/test_unittest/testmock/testpatch.py @@ -5,6 +5,7 @@ import os import sys from collections import OrderedDict +from types import LazyImportType, ModuleType import unittest import test @@ -2101,5 +2102,39 @@ def test(_): test() +class PatchLazyImportTest(unittest.TestCase): + + def lazy_module(self): + # `lazy from` binds eagerly when the module it imports from is already + # imported, so publish the target only once the statement has run. + self.enterContext(uncache('lazy_patch_user', 'lazy_patch_target')) + user = ModuleType('lazy_patch_user') + exec('lazy from lazy_patch_target import function', user.__dict__) + sys.modules['lazy_patch_user'] = user + target = ModuleType('lazy_patch_target') + exec('def function(arg): pass', target.__dict__) + sys.modules['lazy_patch_target'] = target + + self.assertIsInstance(user.__dict__['function'], LazyImportType) + return user + + def test_autospec(self): + module = self.lazy_module() + with patch.object(module, 'function', autospec=True) as mock_function: + mock_function('arg') + with self.assertRaises(TypeError): + mock_function('arg', 'extra') + + def test_spec(self): + module = self.lazy_module() + with patch.object(module, 'function', spec=True) as mock_function: + mock_function('arg') + + def test_spec_set(self): + module = self.lazy_module() + with patch.object(module, 'function', spec_set=True) as mock_function: + mock_function('arg') + + if __name__ == '__main__': unittest.main() diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py index dcaad49ffab5d26..3025a86b3b7328c 100644 --- a/Lib/test/test_unparse.py +++ b/Lib/test/test_unparse.py @@ -216,6 +216,15 @@ def test_tstrings(self): self.check_ast_roundtrip('t""') self.check_ast_roundtrip("t'{(lambda x: x)}'") self.check_ast_roundtrip("t'{t'{x}'}'") + self.check_ast_roundtrip( + r"""t'''{( + 1, # Force lexer metadata reconstruction. + "\"#")}'''""" + ) + self.check_ast_roundtrip( + r'''t"""Value: {value =\ +}"""''' + ) def test_tstring_with_nonsensical_str_field(self): # `value` suggests that the original code is `t'{test1}`, but `str` suggests otherwise @@ -326,6 +335,14 @@ def test_unary_parens(self): def test_integer_parens(self): self.check_ast_roundtrip("3 .__abs__()") + def test_attribute_on_bool(self): + # gh-158237: True.real should not gain a space + self.check_src_roundtrip("x = True.real") + self.check_src_roundtrip("x = False.__class__") + + def test_attribute_on_int_still_spaced(self): + self.check_src_roundtrip("x = 3 .__abs__()") + def test_huge_float(self): self.check_ast_roundtrip("1e1000") self.check_ast_roundtrip("-1e1000") @@ -684,6 +701,24 @@ def test_unparse_interactive_integrity_3(self): self.check_src_roundtrip(src, out, mode='single') + @test.support.subTests('case', [ + "case 'a string':", + "case True:", + "case _:", + "case [*_]:", + "case tuple():", + "case cls(arg, more=arg2):", + "case tuple() | list():", + "case [tuple() as obj, _, {'a': a, **more}]:", + "case -2:", + "case +2:", + "case 2 + 3j:", + "case +2 - 3j:", + ]) + def test_unparse_match(self, case): + src = 'match x:\n ' + case + '\n pass' + self.check_src_roundtrip(src) + class CosmeticTestCase(ASTTestCase): """Test if there are cosmetic issues caused by unnecessary additions""" @@ -886,6 +921,12 @@ def test_backslash_in_format_spec(self): self.check_ast_roundtrip("""f"{x:\\\\\\\\ }" """) + def test_braces_in_format_spec(self): + for prefix in "ft": + self.check_ast_roundtrip(prefix + r'"{value:\x7b>3}"') + self.check_ast_roundtrip(prefix + r'"{value:\x7d>3}"') + self.check_ast_roundtrip(r't"{value:\x7bwidth\x7d}"') + def test_quote_in_format_spec(self): self.check_ast_roundtrip("""f"{x:'}" """) self.check_ast_roundtrip("""f"{x:\\'}" """) diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index 2dd739b77b8e4d1..3858b03546061e6 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -7,6 +7,7 @@ import email.message import io import unittest +import unittest.mock from test import support from test.support import os_helper from test.support import socket_helper @@ -400,11 +401,17 @@ def test_url_host_with_newline_header_injection_rejected(self): host = "localhost\r\nX-injected: header\r\n" schemeless_url = "//" + host + ":8080/test/?test=a" try: - InvalidURL = http.client.InvalidURL + # Once \r\n are stripped from the URL, the ':' in + # "X-injected:" is mistaken for the port separator, and + # urlsplit()/urlparse() now reject the resulting + # non-numeric "port" at parse time, before a Request is + # even built -- rejecting the injection earlier than + # http.client's own InvalidURL check ever gets a chance to. with self.assertRaisesRegex( - InvalidURL, r"contain control.*\\r"): + ValueError, "Port could not be cast to integer value"): urllib.request.urlopen(f"http:{schemeless_url}") - with self.assertRaisesRegex(InvalidURL, r"contain control.*\\n"): + with self.assertRaisesRegex( + ValueError, "Port could not be cast to integer value"): urllib.request.urlopen(f"https:{schemeless_url}") finally: self.unfakehttp() @@ -467,6 +474,25 @@ def test_redirect_limit_independent(self): finally: self.unfakehttp() + def test_http_error_attribute_values(self): + hdrs = { + "Authorization": "Bearer foobar", + "Accept": "application/json" + } + err = urllib.error.HTTPError("http://something", 404, "foo", hdrs, None) + self.assertEqual(err.filename, "http://something") + self.assertEqual(err.code, 404) + self.assertEqual(err.msg, "foo") + self.assertEqual(err.reason, "foo") + self.assertEqual(err.hdrs, hdrs) + self.assertEqual(err.headers, hdrs) + err.close() + + def test_http_error_default_fp(self): + err = urllib.error.HTTPError("http://something", 404, "foo", {}, None) + self.assertIsInstance(err.fp, io.BytesIO) + err.close() + def test_empty_socket(self): # urlopen() raises OSError if the underlying socket does not send any # data. (#1680230) @@ -513,6 +539,11 @@ def test_ftp_nonexisting(self): self.assertFalse(e.exception.filename) self.assertTrue(e.exception.reason) + def test_url_error_stringified(self): + reason = 'sixseven' + err = urllib.error.URLError(reason) + self.assertEqual(str(err), f'') + class urlopen_DataTests(unittest.TestCase): """Test urlopen() opening a data URL.""" @@ -783,6 +814,61 @@ def test_short_content_raises_ContentTooShortError_without_reporthook(self): self.unfakehttp() +class urlcleanup_Tests(unittest.TestCase, FakeHTTPMixin): + """Test urllib.request.urlcleanup()""" + + def setUp(self): + self.addCleanup(urllib.request.urlcleanup) + + def urlretrieve(self): + self.fakehttp(b'HTTP/1.1 200 OK\r\n\r\ndata') + try: + filename, headers = urllib.request.urlretrieve( + support.TEST_HTTP_URL) + finally: + self.unfakehttp() + self.addCleanup(os_helper.unlink, filename) + return filename + + def fake_urlopen(self, data): + self.fakehttp(b'HTTP/1.1 200 OK\r\n\r\n' + data) + try: + with urllib.request.urlopen(support.TEST_HTTP_URL) as fp: + return fp.read() + finally: + self.unfakehttp() + + def test_temporary_files(self): + filename = self.urlretrieve() + self.assertTrue(os.path.exists(filename)) + + urllib.request.urlcleanup() + self.assertFalse(os.path.exists(filename)) + + # A file created after the cleanup is not deleted. + os_helper.create_empty_file(filename) + urllib.request.urlcleanup() + self.assertTrue(os.path.exists(filename)) + + def test_opener(self): + # The implicitly created opener supports http. + self.assertEqual(self.fake_urlopen(b'first'), b'first') + + # An installed opener replaces it and supports only its handlers. + opener = urllib.request.OpenerDirector() + opener.add_handler(urllib.request.DataHandler()) + opener.add_handler(urllib.request.UnknownHandler()) + urllib.request.install_opener(opener) + with urllib.request.urlopen('data:,hello') as fp: + self.assertEqual(fp.read(), b'hello') + with self.assertRaises(urllib.error.URLError): + self.fake_urlopen(b'') + + # urlcleanup() resets the opener. + urllib.request.urlcleanup() + self.assertEqual(self.fake_urlopen(b'second'), b'second') + + class QuotingTests(unittest.TestCase): r"""Tests for urllib.quote() and urllib.quote_plus() @@ -1593,6 +1679,17 @@ def test_url2pathname_resolve_host(self): self.assertEqual(fn(f'//{socket.gethostname()}/foo/bar'), f'{sep}foo{sep}bar') self.assertEqual(fn(f'//{socket.gethostname()}/foo/bar', resolve_host=True), f'{sep}foo{sep}bar') + def test_url2pathname_win_netloc_not_validated_as_port(self): + # The Windows branch of url2pathname() stuffs things like drive + # letters into the netloc (e.g. '//C:\\' -> authority 'C:\\'), + # which is not a real host[:port] pair. url2pathname() must not + # reject it as an invalid port; run the Windows branch directly + # so this is exercised on every platform, not just win32. + with unittest.mock.patch('os.name', 'nt'): + fn = urllib.request.url2pathname + self.assertEqual(fn('//C:\\'), 'C:\\') + self.assertEqual(fn('//C:80/'), 'C:80\\') + @unittest.skipUnless(sys.platform == 'win32', 'test specific to Windows pathnames.') def test_url2pathname_win(self): diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index d2fd111f6d9de02..be1da0735b98fd2 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -8,6 +8,7 @@ import os import io +import hashlib import ftplib import socket import array @@ -30,6 +31,11 @@ support.requires_working_socket(module=True) +skip_libssl_fips_mode = unittest.skipIf( + support.is_libssl_fips_mode(), + "conservative skip due to OpenSSL FIPS mode possible algorithm nerfing", +) + # XXX # Request # CacheFTPHandler (hard to write) @@ -82,6 +88,37 @@ def test_parse_http_list(self): def test_URLError_reasonstr(self): err = urllib.error.URLError('reason') self.assertIn(err.reason, str(err)) + self.assertIsNone(err.errno) + self.assertIsNone(err.strerror) + + def test_URLError_OSError_attributes(self): + # gh-50720: errno and strerror are copied from a wrapped OSError. + socket_error = socket.gaierror(-2, 'Name or service not known') + + class FailingHTTPConnection(MockHTTPClass): + def request(self, *args, **kwargs): + raise socket_error + + h = urllib.request.AbstractHTTPHandler() + req = Request("http://example.com/") + req.timeout = None + + with self.assertRaises(urllib.error.URLError) as cm: + h.do_open(FailingHTTPConnection(), req) + err = cm.exception + self.assertIs(err.reason, socket_error) + self.assertEqual(err.errno, -2) + self.assertEqual(err.strerror, 'Name or service not known') + + @unittest.skipUnless(sys.platform == "win32", "Windows-specific test") + def test_URLError_OSError_attributes_winerror(self): + # gh-50720: OSError(errno, strerror, filename, winerror): + # on Windows the constructor derives errno from winerror. + os_error = OSError(0, "The system cannot find the path specified", None, 3) + + err = urllib.error.URLError(os_error) + self.assertEqual(err.winerror, 3) + self.assertEqual(err.strerror, os_error.strerror) class RequestHdrsTests(unittest.TestCase): @@ -270,6 +307,50 @@ def test_password_manager_default_port(self): self.assertEqual(find_user_pass("i", "http://j.example.com:80"), (None, None)) + def test_password_manager_scheme(self): + mgr = urllib.request.HTTPPasswordMgr() + mgr.add_password( + "realm", "https://example.com/", "user", "password") + + self.assertEqual( + mgr.find_user_password("realm", "https://example.com/"), + ("user", "password")) + self.assertEqual( + mgr.find_user_password("realm", "http://example.com/"), + (None, None)) + # Support an authority without a scheme. + self.assertEqual( + mgr.find_user_password("realm", "example.com"), + ("user", "password")) + # An authority without a scheme continues to match any scheme. + mgr.add_password( + "realm", "schemeless.example.com", "user", "password") + for scheme in "http", "https": + with self.subTest(scheme=scheme): + self.assertEqual( + mgr.find_user_password( + "realm", f"{scheme}://schemeless.example.com/"), + ("user", "password")) + + # A network-path reference also has no scheme. + mgr.add_password( + "realm", "//network-path.example.com/", "user", "password") + self.assertEqual( + mgr.find_user_password( + "realm", "https://network-path.example.com/"), + ("user", "password")) + + def test_password_manager_reduced_uri(self): + mgr = urllib.request.HTTPPasswordMgr() + + self.assertEqual( + mgr.reduce_uri("http://example.com/path"), + ("example.com:80", "/path")) + self.assertTrue( + mgr.is_suburi( + ("example.com", "/path"), + ("example.com", "/path/subpath"))) + class MockOpener: addheaders = [] @@ -537,6 +618,42 @@ def https_open(self, req): return self.do_open(self.httpconn, req) +class MockHTTPTunnelClass(MockHTTPClass): + # Stands in for a proxy that requires authentication: CONNECT fails + # with tunnel_code until the credentials arrive in the tunnel headers + # (tunnel_code=None: no authentication). The origin then answers + # through the tunnel with origin_code. + def __init__(self, tunnel_code=407, challenge='Basic realm="proxy"', + origin_code=200): + super().__init__() + self.tunnel_code = tunnel_code + self.challenge = challenge + self.origin_code = origin_code + self.tunnel_requests = [] + + def challenge_headers(self): + return http.client.parse_headers(io.BytesIO( + b'Proxy-Authenticate: %s\r\n\r\n' % self.challenge.encode())) + + def request(self, method, url, body=None, headers=None, *, + encode_chunked=False): + self.tunnel_requests.append(dict(self._tunnel_headers)) + if (self.tunnel_code is not None and + "Proxy-Authorization" not in self._tunnel_headers): + raise http.client.ProxyTunnelError( + self.tunnel_code, http.client.responses[self.tunnel_code], + self.challenge_headers()) + super().request(method, url, body, headers, + encode_chunked=encode_chunked) + + def getresponse(self): + response = super().getresponse() + response.code = self.origin_code + if self.origin_code != 200: + response.info = self.challenge_headers + return response + + class MockHTTPHandlerCheckAuth(urllib.request.BaseHandler): # useful for testing auth # sends supplied code response @@ -871,9 +988,9 @@ def test_file(self): parsed._replace(netloc='localhost:80').geturl(), "file:///file_does_not_exist.txt", "file://not-a-local-host.com//dir/file.txt", - "file://%s:80%s/%s" % (socket.gethostbyname('localhost'), + "file://%s:80/%s/%s" % (socket.gethostbyname('localhost'), os.getcwd(), TESTFN), - "file://somerandomhost.ontheinternet.com%s/%s" % + "file://somerandomhost.ontheinternet.com/%s/%s" % (os.getcwd(), TESTFN), ]: try: @@ -1409,8 +1526,15 @@ def test_redirect_fragment(self): fp = o.open('http://www.example.com') self.assertEqual(fp.geturl(), redirected_url.strip()) + def unset_proxy_env(self): + # Keep the test independent from proxy-related environment settings. + env = self.enterContext(os_helper.EnvironmentVarGuard()) + env.unset("http_proxy", "https_proxy", "all_proxy", "no_proxy", + "HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY", "NO_PROXY") + def test_redirect_no_path(self): # Issue 14132: Relative redirect strips original path + self.unset_proxy_env() # clear _opener global variable self.addCleanup(urllib.request.urlcleanup) @@ -1444,6 +1568,7 @@ def http_open(self, req): b'123' ) return result + self.unset_proxy_env() handler = Handler() opener = urllib.request.build_opener(handler) tests = ( @@ -1557,6 +1682,142 @@ def test_proxy_https_proxy_authorization(self): self.assertEqual(req.host, "proxy.example.com:3128") self.assertEqual(req.get_header("Proxy-authorization"), "FooBar") + def _open_through_tunnel(self, httpconn, password_mgr, + auth_handler=urllib.request.ProxyBasicAuthHandler, + url="https://www.example.com/path"): + https_handler = MockHTTPSHandler() + https_handler.httpconn = httpconn + opener = urllib.request.build_opener( + urllib.request.ProxyHandler(dict(https="proxy.example.com:3128")), + auth_handler(password_mgr), + https_handler) + return opener.open(url) + + @unittest.skipUnless(hasattr(http.client, 'HTTPSConnection'), 'HTTPSConnection required for HTTPS tests.') + def test_proxy_https_basic_auth_handler(self): + # gh-51540: a 407 from the proxy to CONNECT is passed to + # ProxyBasicAuthHandler, which retries with credentials + password_mgr = urllib.request.HTTPPasswordMgr() + password_mgr.add_password("proxy", "proxy.example.com:3128", + "user", "pass") + httpconn = MockHTTPTunnelClass() + response = self._open_through_tunnel(httpconn, password_mgr) + self.assertEqual(response.code, 200) + + self.assertEqual(len(httpconn.tunnel_requests), 2) + self.assertNotIn("Proxy-Authorization", httpconn.tunnel_requests[0]) + self.assertEqual(httpconn.tunnel_requests[1]["Proxy-Authorization"], + "Basic dXNlcjpwYXNz") + # The credentials go to the proxy only, not to the origin. + self.assertEqual(httpconn._tunnel_host, "www.example.com") + self.assertEqual(httpconn.selector, "/path") + self.assertNotIn("Proxy-Authorization", + dict(httpconn.req_headers)) + + @unittest.skipUnless(hasattr(http.client, 'HTTPSConnection'), 'HTTPSConnection required for HTTPS tests.') + @skip_libssl_fips_mode # Uses MD5 algorithm in challenge + def test_proxy_https_digest_auth_handler(self): + # gh-51540: a 407 from the proxy to CONNECT is passed to + # ProxyDigestAuthHandler, which retries with credentials + password_mgr = urllib.request.HTTPPasswordMgr() + password_mgr.add_password("proxy", "proxy.example.com:3128", + "user", "pass") + httpconn = MockHTTPTunnelClass( + challenge='Digest realm="proxy", nonce="abcdef0123456789", ' + 'qop="auth"') + response = self._open_through_tunnel( + httpconn, password_mgr, urllib.request.ProxyDigestAuthHandler) + self.assertEqual(response.code, 200) + + self.assertEqual(len(httpconn.tunnel_requests), 2) + self.assertNotIn("Proxy-Authorization", httpconn.tunnel_requests[0]) + self.assertStartsWith( + httpconn.tunnel_requests[1]["Proxy-Authorization"], + 'Digest username="user", realm="proxy", ') + self.assertEqual(httpconn.selector, "/path") + self.assertNotIn("Proxy-Authorization", + dict(httpconn.req_headers)) + + @unittest.skipUnless(hasattr(http.client, 'HTTPSConnection'), 'HTTPSConnection required for HTTPS tests.') + @skip_libssl_fips_mode # Uses MD5 algorithm in challenge + def test_proxy_https_digest_auth_connect(self): + # Through an https tunnel, the digest covers the CONNECT request + # (method CONNECT, request-target host:port), not the request + # later sent to the origin + def md5(text): + return hashlib.md5(text.encode("ascii")).hexdigest() + + nonce = "abcdef0123456789" + for url, target in [ + ("https://www.example.com/path", "www.example.com:443"), + ("https://www.example.com:8443/path", "www.example.com:8443"), + ]: + with self.subTest(url=url): + password_mgr = urllib.request.HTTPPasswordMgr() + password_mgr.add_password("proxy", "proxy.example.com:3128", + "user", "pass") + httpconn = MockHTTPTunnelClass( + challenge='Digest realm="proxy", nonce="%s"' % nonce) + self._open_through_tunnel( + httpconn, password_mgr, + urllib.request.ProxyDigestAuthHandler, url) + + expected = md5("%s:%s:%s" % (md5("user:proxy:pass"), nonce, + md5("CONNECT:" + target))) + auth = httpconn.tunnel_requests[1]["Proxy-Authorization"] + self.assertIn('uri="%s"' % target, auth) + self.assertIn('response="%s"' % expected, auth) + self.assertEqual(httpconn.selector, "/path") + + @unittest.skipUnless(hasattr(http.client, 'HTTPSConnection'), 'HTTPSConnection required for HTTPS tests.') + def test_proxy_https_origin_407(self): + # A 407 sent by the origin through the tunnel is retried like one + # from the proxy, but the credentials only go on the CONNECT + password_mgr = urllib.request.HTTPPasswordMgr() + password_mgr.add_password("proxy", "proxy.example.com:3128", + "user", "pass") + httpconn = MockHTTPTunnelClass(tunnel_code=None, origin_code=407) + with self.assertRaises(urllib.error.HTTPError) as cm: + self._open_through_tunnel(httpconn, password_mgr) + with cm.exception as err: + self.assertEqual(err.code, 407) + + self.assertEqual(len(httpconn.tunnel_requests), 2) + self.assertNotIn("Proxy-Authorization", httpconn.tunnel_requests[0]) + self.assertEqual(httpconn.tunnel_requests[1]["Proxy-Authorization"], + "Basic dXNlcjpwYXNz") + # Neither request to the origin carried the credentials. + self.assertNotIn("Proxy-Authorization", + dict(httpconn.req_headers)) + + @unittest.skipUnless(hasattr(http.client, 'HTTPSConnection'), 'HTTPSConnection required for HTTPS tests.') + def test_proxy_https_basic_auth_handler_no_password(self): + password_mgr = urllib.request.HTTPPasswordMgr() + httpconn = MockHTTPTunnelClass() + with self.assertRaises(urllib.error.HTTPError) as cm: + self._open_through_tunnel(httpconn, password_mgr) + with cm.exception as err: + self.assertEqual(err.code, 407) + self.assertEqual(err.reason, "Proxy Authentication Required") + self.assertEqual(err.headers["Proxy-Authenticate"], + 'Basic realm="proxy"') + self.assertEqual(err.read(), b"") + self.assertEqual(len(httpconn.tunnel_requests), 1) + + @unittest.skipUnless(hasattr(http.client, 'HTTPSConnection'), 'HTTPSConnection required for HTTPS tests.') + def test_proxy_https_tunnel_error(self): + # Other failures to CONNECT are still raised as URLError + password_mgr = urllib.request.HTTPPasswordMgr() + password_mgr.add_password("proxy", "proxy.example.com:3128", + "user", "pass") + httpconn = MockHTTPTunnelClass(tunnel_code=403) + with self.assertRaises(urllib.error.URLError) as cm: + self._open_through_tunnel(httpconn, password_mgr) + self.assertNotIsInstance(cm.exception, urllib.error.HTTPError) + self.assertIsInstance(cm.exception.reason, + http.client.ProxyTunnelError) + self.assertEqual(cm.exception.reason.code, 403) + @unittest.skipUnless(os.name == "nt", "only relevant for Windows") def test_winreg_proxy_bypass(self): proxy_override = "www.example.com;*.example.net; 192.168.0.1" @@ -1581,6 +1842,14 @@ def test_winreg_proxy_bypass(self): "expect to bypass intranet address '%s'" % host) + # empty entries (e.g. a trailing ';') must not match every host + for proxy_override in ("www.example.com;", ";", " ; ", + "www.example.com;;*.example.net"): + self.assertFalse(proxy_bypass("www.python.org", proxy_override), + "expected empty entry in %r not to bypass" + % proxy_override) + self.assertTrue(proxy_bypass("www.example.com", "www.example.com;")) + @unittest.skipUnless(sys.platform == 'darwin', "only relevant for OSX") def test_osx_proxy_bypass(self): bypass = { @@ -1691,6 +1960,144 @@ def test_proxy_basic_auth(self): "proxy.example.com:3128", ) + @skip_libssl_fips_mode # Uses MD5 algorithm in challenge + def test_proxy_digest_auth(self): + # gh-60299: ProxyDigestAuthHandler must look up credentials using + # the proxy's authority + opener = OpenerDirector() + ph = urllib.request.ProxyHandler(dict(http="proxy.example.com:3128")) + opener.add_handler(ph) + password_manager = MockPasswordManager() + digest_handler = urllib.request.ProxyDigestAuthHandler(password_manager) + realm = "ACME Networks" + http_handler = MockHTTPHandlerRedirect( + 407, + 'Proxy-Authenticate: Digest realm="%s", nonce="abcdef0123456789", ' + 'qop="auth"\r\n\r\n' % realm) + opener.add_handler(digest_handler) + opener.add_handler(http_handler) + + user, password = "wile", "coyote" + request_url = "http://acme.example.com/protected" + proxy_authority = "proxy.example.com:3128" + + digest_handler.add_password(realm, proxy_authority, user, password) + self.assertEqual(realm, password_manager.realm) + self.assertEqual(proxy_authority, password_manager.url) + + opener.open(request_url) + + self.assertEqual(password_manager.target_realm, realm) + self.assertEqual(password_manager.target_url, proxy_authority) + + self.assertEqual(len(http_handler.requests), 2) + self.assertFalse( + http_handler.requests[0].has_header("Proxy-authorization")) + self.assertTrue( + http_handler.requests[1].has_header("Proxy-authorization")) + self.assertTrue( + http_handler.requests[1] + .get_header("Proxy-authorization").startswith("Digest ")) + + def test_proxy_digest_auth_uri(self): + # The digest-uri of a request sent through an HTTP proxy is the + # absolute URL, matching the absolute-form request line + opener = OpenerDirector() + ph = urllib.request.ProxyHandler(dict(http="proxy.example.com:3128")) + opener.add_handler(ph) + password_manager = urllib.request.HTTPPasswordMgr() + digest_handler = urllib.request.ProxyDigestAuthHandler(password_manager) + realm = "ACME Networks" + http_handler = MockHTTPHandlerRedirect( + 407, + 'Proxy-Authenticate: Digest realm="%s", nonce="abcdef0123456789", ' + 'algorithm="SHA-256"\r\n\r\n' % realm) + opener.add_handler(digest_handler) + opener.add_handler(http_handler) + + request_url = "http://acme.example.com/protected" + digest_handler.add_password(realm, "proxy.example.com:3128", + "wile", "coyote") + opener.open(request_url) + + self.assertEqual(len(http_handler.requests), 2) + auth = http_handler.requests[1].get_header("Proxy-authorization") + self.assertIn('uri="%s"' % request_url, auth) + + @skip_libssl_fips_mode # Uses MD5 algorithm in challenge + def test_digest_auth_uses_full_url(self): + # The non-proxy case must keep using the full request URL (not + # just the host) for the password lookup, so that sub-URI realm + # matching (HTTPPasswordMgr.is_suburi) keeps working + opener = OpenerDirector() + password_manager = MockPasswordManager() + digest_handler = urllib.request.HTTPDigestAuthHandler(password_manager) + realm = "ACME Networks" + request_url = "http://acme.example.com/protected" + http_handler = MockHTTPHandlerRedirect( + 401, + 'WWW-Authenticate: Digest realm="%s", nonce="abcdef0123456789", ' + 'qop="auth"\r\n\r\n' % realm) + opener.add_handler(digest_handler) + opener.add_handler(http_handler) + + digest_handler.add_password(realm, request_url, "wile", "coyote") + opener.open(request_url) + + self.assertEqual(password_manager.target_realm, realm) + self.assertEqual(password_manager.target_url, request_url) + + def test_digest_auth_empty_path(self): + # gh-53089: the digest-uri must match the Request-URI, which is + # '/' for a URL with an empty path + password_manager = urllib.request.HTTPPasswordMgr() + digest_handler = urllib.request.HTTPDigestAuthHandler(password_manager) + realm = "ACME Networks" + digest_handler.add_password(realm, "http://acme.example.com", + "wile", "coyote") + req = Request("http://acme.example.com") + chal = {"realm": realm, "nonce": "abcdef0123456789", + "algorithm": "SHA-256"} + + auth = digest_handler.get_authorization(req, chal) + + H, KD = digest_handler.get_algorithm_impls("SHA-256") + respdig = KD(H("wile:%s:coyote" % realm), + "abcdef0123456789:%s" % H("GET:/")) + self.assertIn('uri="/"', auth) + self.assertIn('response="%s"' % respdig, auth) + + def test_proxy_auth_ignores_direct_407(self): + # gh-158907: a direct HTTP origin that returns 407 must not receive + # credentials registered for the same authority over HTTPS. + realm = "test-realm" + cases = [ + (urllib.request.ProxyBasicAuthHandler, + 'Basic realm="%s"' % realm), + (urllib.request.ProxyDigestAuthHandler, + 'Digest realm="%s", nonce="abc", qop="auth"' % realm), + ] + for handler_class, challenge in cases: + with self.subTest(handler=handler_class.__name__): + opener = OpenerDirector() + opener.add_handler(urllib.request.ProxyHandler({})) + password_manager = urllib.request.HTTPPasswordMgr() + auth_handler = handler_class(password_manager) + http_handler = MockHTTPHandlerRedirect( + 407, 'Proxy-Authenticate: %s\r\n\r\n' % challenge) + opener.add_handler(auth_handler) + opener.add_handler(http_handler) + + password_manager.add_password( + realm, "https://example.com/", + "victim-user", "victim-secret") + opener.open("http://example.com/resource") + + self.assertEqual(len(http_handler.requests), 1) + self.assertFalse( + http_handler.requests[0].has_header( + "Proxy-authorization")) + def test_basic_and_digest_auth_handlers(self): # HTTPDigestAuthHandler raised an exception if it couldn't handle a 40* # response (https://bugs.python.org/issue1479302), where it should instead @@ -1751,6 +2158,141 @@ def test_unsupported_auth_digest_handler(self): opener.add_handler(http_handler) self.assertRaises(ValueError, opener.open, "http://www.example.com") + def check_digest_auth(self, headers, realm): + with self.subTest(headers=headers): + opener = OpenerDirector() + password_manager = MockPasswordManager() + auth_handler = urllib.request.HTTPDigestAuthHandler( + password_manager) + auth_handler.add_password(realm, "http://acme.example.com/", + "wile", "coyote") + body = '\r\n'.join(headers) + '\r\n\r\n' + http_handler = MockHTTPHandlerRedirect(401, body) + opener.add_handler(auth_handler) + opener.add_handler(http_handler) + opener.open("http://acme.example.com/protected") + self.assertEqual(password_manager.target_realm, realm) + auth = http_handler.requests[1].unredirected_hdrs["Authorization"] + self.assertStartsWith(auth, "Digest ") + self.assertIn(f'realm="{realm}"', auth) + self.assertIn('nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093"', auth) + self.assertIn('opaque="5ccc069c403ebaf9f0171e9517f40e41"', auth) + + @skip_libssl_fips_mode + def test_digest_auth_multiple_challenges(self): + realm = "digest@example.com" + digest = (f'Digest realm="{realm}", ' + f'qop="auth, auth-int", ' + f'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' + f'opaque="5ccc069c403ebaf9f0171e9517f40e41"') + basic = 'Basic realm="basic@example.com"' + other = 'Otherscheme xxx' + + # Multiple challenges per header. + for challenges in ( + digest, + f'{basic}, {digest}', + f'{digest}, {basic}', + f'{other}, {digest}', + f'{basic}, {digest}, {other}', + ): + self.check_digest_auth([f'WWW-Authenticate: {challenges}'], realm) + + # Multiple headers: one challenge per header. + for challenges in ( + [basic, digest], + [digest, basic], + [other, digest], + ): + headers = [f'WWW-Authenticate: {challenge}' + for challenge in challenges] + self.check_digest_auth(headers, realm) + + def test_digest_auth_handler_ignores_basic_challenge(self): + # Leave Basic challenges to HTTPBasicAuthHandler, even when an + # unsupported scheme is present as well. + for headers in ( + 'WWW-Authenticate: Basic realm="x"\r\n\r\n', + 'WWW-Authenticate: Kerberos, Basic realm="x"\r\n\r\n', + 'WWW-Authenticate: Kerberos\r\n' + 'WWW-Authenticate: Basic realm="x"\r\n\r\n', + ): + with self.subTest(headers=headers): + opener = OpenerDirector() + opener.add_handler(urllib.request.HTTPDigestAuthHandler(None)) + opener.add_handler(MockHTTPHandlerRedirect(401, headers)) + self.assertIsNone(opener.open("http://www.example.com")) + + def test_digest_auth_parse_challenges(self): + parse = AbstractDigestAuthHandler()._parse_challenges + self.assertEqual(list(parse('')), []) + self.assertEqual(list(parse('Digest realm="a"')), + [('Digest', 'Digest realm="a"')]) + # Commas and quotes inside a quoted string do not split challenges. + self.assertEqual( + list(parse(r'Digest realm="a, Basic realm=\"b\"", nonce="n", ' + r'Basic realm="c"')), + [('Digest', r'Digest realm="a, Basic realm=\"b\"", nonce="n"'), + ('Basic', 'Basic realm="c"')]) + # Whitespace around "=" does not start a new challenge. + self.assertEqual( + list(parse('Digest realm = "a", nonce = "n", Basic realm="b"')), + [('Digest', 'Digest realm = "a", nonce = "n"'), + ('Basic', 'Basic realm="b"')]) + self.assertEqual( + list(parse('Negotiate, Bearer abc==, Digest realm="a",, ')), + [('Negotiate', 'Negotiate'), ('Bearer', 'Bearer abc=='), + ('Digest', 'Digest realm="a"')]) + + @skip_libssl_fips_mode + def test_proxy_digest_auth_multiple_challenges(self): + realm = "digest@example.com" + digest = (f'Digest realm="{realm}", ' + f'qop="auth", ' + f'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093"') + basic = 'Basic realm="basic@example.com"' + for headers in ( + [f'Proxy-Authenticate: {basic}, {digest}'], + [f'Proxy-Authenticate: {basic}', f'Proxy-Authenticate: {digest}'], + ): + with self.subTest(headers=headers): + opener = OpenerDirector() + opener.add_handler(urllib.request.ProxyHandler( + dict(http="proxy.example.com:3128"))) + password_manager = MockPasswordManager() + auth_handler = urllib.request.ProxyDigestAuthHandler( + password_manager) + auth_handler.add_password(realm, "proxy.example.com:3128", + "wile", "coyote") + body = '\r\n'.join(headers) + '\r\n\r\n' + http_handler = MockHTTPHandlerRedirect(407, body) + opener.add_handler(auth_handler) + opener.add_handler(http_handler) + opener.open("http://acme.example.com/protected") + self.assertEqual(password_manager.target_realm, realm) + auth = http_handler.requests[1].unredirected_hdrs[ + "Proxy-authorization"] + self.assertStartsWith(auth, "Digest ") + self.assertIn(f'realm="{realm}"', auth) + def test_digest_auth_failure_code(self): + # gh-53852: a failed proxy digest auth must report 407, not 401. + headers = http.client.HTTPMessage() + for handler_class, auth_header, code in [ + (urllib.request.HTTPDigestAuthHandler, + 'www-authenticate', 401), + (urllib.request.ProxyDigestAuthHandler, + 'proxy-authenticate', 407)]: + with self.subTest(handler=handler_class.__name__): + handler = handler_class() + handler.retried = 6 + req = Request("http://www.example.com/") + with self.assertRaises(urllib.error.HTTPError) as cm: + handler.http_error_auth_reqed(auth_header, + "www.example.com", + req, headers) + self.assertEqual(cm.exception.code, code) + cm.exception.close() + def test_unsupported_auth_basic_handler(self): # While using BasicAuthHandler opener = OpenerDirector() @@ -1825,6 +2367,18 @@ def test_basic_prior_auth_auto_send(self): # expect request to be sent with auth header self.assertTrue(http_handler.has_auth_header) + def test_basic_prior_auth_different_scheme(self): + pwd_manager = HTTPPasswordMgrWithPriorAuth() + auth_handler = HTTPBasicAuthHandler(pwd_manager) + auth_handler.add_password( + None, "https://example.com/", "user", "password", + is_authenticated=True) + + request = Request("http://example.com/") + auth_handler.http_request(request) + + self.assertFalse(request.has_header("Authorization")) + def test_basic_prior_auth_send_after_first_success(self): # Auto send auth header after authentication is successful once @@ -2014,12 +2568,6 @@ def test_parse_proxy(self): self.assertRaises(ValueError, _parse_proxy, 'file:/ftp.example.com'), -skip_libssl_fips_mode = unittest.skipIf( - support.is_libssl_fips_mode(), - "conservative skip due to OpenSSL FIPS mode possible algorithm nerfing", -) - - class TestDigestAuthAlgorithms(unittest.TestCase): def setUp(self): self.handler = AbstractDigestAuthHandler() diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py index 9186436183aae18..8f93ee74252f5c6 100644 --- a/Lib/test/test_urllib2_localnet.py +++ b/Lib/test/test_urllib2_localnet.py @@ -351,6 +351,8 @@ def create_fake_proxy_handler(*args, **kwargs): self.server.start() self.server.ready.wait() proxy_url = "http://127.0.0.1:%d" % self.server.port + # Credentials must be registered against proxy authority + self.proxy_authority = "127.0.0.1:%d" % self.server.port handler = urllib.request.ProxyHandler({"http" : proxy_url}) self.proxy_digest_handler = urllib.request.ProxyDigestAuthHandler() self.opener = urllib.request.build_opener( @@ -361,21 +363,23 @@ def stop_server(self): self.server = None def test_proxy_with_bad_password_raises_httperror(self): - self.proxy_digest_handler.add_password(self.REALM, self.URL, + self.proxy_digest_handler.add_password(self.REALM, self.proxy_authority, self.USER, self.PASSWD+"bad") self.digest_auth_handler.set_qop("auth") with self.assertRaises(urllib.error.HTTPError) as cm: self.opener.open(self.URL) + self.assertEqual(cm.exception.code, 407) cm.exception.close() def test_proxy_with_no_password_raises_httperror(self): self.digest_auth_handler.set_qop("auth") with self.assertRaises(urllib.error.HTTPError) as cm: self.opener.open(self.URL) + self.assertEqual(cm.exception.code, 407) cm.exception.close() def test_proxy_qop_auth_works(self): - self.proxy_digest_handler.add_password(self.REALM, self.URL, + self.proxy_digest_handler.add_password(self.REALM, self.proxy_authority, self.USER, self.PASSWD) self.digest_auth_handler.set_qop("auth") with self.opener.open(self.URL) as result: @@ -383,7 +387,7 @@ def test_proxy_qop_auth_works(self): pass def test_proxy_qop_auth_int_works_or_throws_urlerror(self): - self.proxy_digest_handler.add_password(self.REALM, self.URL, + self.proxy_digest_handler.add_password(self.REALM, self.proxy_authority, self.USER, self.PASSWD) self.digest_auth_handler.set_qop("auth-int") try: diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index a5b7966c7780e9e..37e172f7f2caca3 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -917,9 +917,8 @@ def test_urlsplit_attributes(self): # Verify an illegal port raises ValueError url = b"HTTP://WWW.PYTHON.ORG:65536/doc/#frag" - p = urllib.parse.urlsplit(url) with self.assertRaisesRegex(ValueError, "out of range"): - p.port + urllib.parse.urlsplit(url) def test_urlsplit_remove_unsafe_bytes(self): # Remove ASCII tabs and newlines from input @@ -1029,10 +1028,8 @@ def test_attributes_bad_port(self, bytes, parse, port): self.skipTest('non-ASCII bytes') netloc = str_encode(netloc) url = str_encode(url) - p = parse(url) - self.assertEqual(p.netloc, netloc) with self.assertRaises(ValueError): - p.port + parse(url) @support.subTests('bytes', (False, True)) @support.subTests('parse', (urllib.parse.urlsplit, urllib.parse.urlparse)) @@ -1255,6 +1252,12 @@ def test_mixed_types_rejected(self): with self.assertRaisesRegex(TypeError, "Cannot mix str"): urllib.parse.urljoin(b"http://python.org", "http://python.org") + def test_non_string_true_values_rejected(self): + # True values raise informative TypeErrors + msg = "Expected str, bytes or None, not " + with self.assertRaisesRegex(TypeError, msg): + urllib.parse.urlsplit(1, b'http') + def _check_result_type(self, str_type, str_args): bytes_type = str_type._encoded_counterpart self.assertIs(bytes_type._decoded_counterpart, str_type) @@ -1670,13 +1673,11 @@ def test_splitting_bracketed_hosts(self): def test_port_casting_failure_message(self): message = "Port could not be cast to integer value as 'oracle'" - p1 = urllib.parse.urlparse('http://Server=sde; Service=sde:oracle') with self.assertRaisesRegex(ValueError, message): - p1.port + urllib.parse.urlparse('http://Server=sde; Service=sde:oracle') - p2 = urllib.parse.urlsplit('http://Server=sde; Service=sde:oracle') with self.assertRaisesRegex(ValueError, message): - p2.port + urllib.parse.urlsplit('http://Server=sde; Service=sde:oracle') def test_telurl_params(self): p1 = urllib.parse.urlparse('tel:123-4;phone-context=+1-650-516') @@ -1992,6 +1993,23 @@ def test_to_bytes_deprecation(self): self.assertEqual(str(cm.warning), 'urllib.parse.to_bytes() is deprecated as of 3.8') + def test_falsey_deprecation(self): + cases = [ + (urllib.parse.urljoin, ['http://www.python.org', []]), + (urllib.parse.urljoin, [[], b'docs']), + (urllib.parse.urlparse, [b'www.python.org', {}]), + (urllib.parse.urlparse, [{}, '']), + (urllib.parse.urlsplit, [0, b'http']), + (urllib.parse.urlsplit, [b'http://www.python.org', 0]), + (urllib.parse.urldefrag, [{}]), + (urllib.parse.urlunparse, [[None, b'www.python.org', (), (), (), ()]]), + (urllib.parse.urlunsplit, [['http', 0, '', '', '']]), + ] + for func, args in cases: + with self.subTest(callable=func.__name__, args=args): + with self.assertWarnsRegex(DeprecationWarning, "false value"): + func(*args) + def str_encode(s): if s is None: diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py index cc85c06bf933633..1ba5b661aba016b 100644 --- a/Lib/test/test_userstring.py +++ b/Lib/test/test_userstring.py @@ -121,6 +121,32 @@ def test_mixed_cmp(self): self._assert_cmp(a, 'a', 1) self._assert_cmp(a, 'ac', -1) + @support.subTests('str_class', (UserString, UserStringSubclass)) + def test_startswith_userstring(self, str_class): + s = UserString('hello world') + self.assertTrue(s.startswith(str_class('hello'))) + self.assertFalse(s.startswith(str_class('world'))) + self.assertTrue(s.startswith(str_class(''))) + self.assertFalse(s.startswith(str_class('hello world!'))) + self.assertTrue(s.startswith(str_class('world'), 6)) + self.assertTrue(s.startswith(str_class('world'), 6, 11)) + self.assertFalse(s.startswith(str_class('world'), 6, 10)) + self.assertTrue(s.startswith(str_class('world'), -5)) + self.assertTrue(s.startswith(str_class('world'), start=6, end=11)) + + @support.subTests('str_class', (UserString, UserStringSubclass)) + def test_endswith_userstring(self, str_class): + s = UserString('hello world') + self.assertTrue(s.endswith(str_class('world'))) + self.assertFalse(s.endswith(str_class('hello'))) + self.assertTrue(s.endswith(str_class(''))) + self.assertFalse(s.endswith(str_class('hello world!'))) + self.assertTrue(s.endswith(str_class('world'), 6)) + self.assertTrue(s.endswith(str_class('hello'), 0, 5)) + self.assertFalse(s.endswith(str_class('hello'), 1, 5)) + self.assertTrue(s.endswith(str_class('hello'), -11, -6)) + self.assertTrue(s.endswith(str_class('hello'), start=0, end=5)) + def test_rmod(self): class ustr2(UserString): pass diff --git a/Lib/test/test_utf8_mode.py b/Lib/test/test_utf8_mode.py index b8e49440c9f7da6..6cd156b7e9293ac 100644 --- a/Lib/test/test_utf8_mode.py +++ b/Lib/test/test_utf8_mode.py @@ -29,11 +29,11 @@ def posix_locale(self): def get_output(self, *args, failure=False, **kw): kw = dict(self.DEFAULT_ENV, **kw) if failure: - out = assert_python_failure(*args, **kw) - out = out[2] + proc = assert_python_failure(*args, **kw) + out = proc.err else: - out = assert_python_ok(*args, **kw) - out = out[1] + proc = assert_python_ok(*args, **kw) + out = proc.out return out.decode().rstrip("\n\r") @unittest.skipIf(MS_WINDOWS, 'Windows has no POSIX locale') diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py index 055be2994bf435e..fb278b6c4044c21 100755 --- a/Lib/test/test_uuid.py +++ b/Lib/test/test_uuid.py @@ -7,13 +7,19 @@ import pickle import random import sys +import textwrap import unittest import weakref +from collections import UserDict from itertools import product +from types import MappingProxyType from unittest import mock from test import support -from test.support import force_not_colorized_test_class, import_helper, warnings_helper +from test.support import ( + force_not_colorized_test_class, import_helper, threading_helper, + warnings_helper, +) from test.support.script_helper import assert_python_ok py_uuid = import_helper.import_fresh_module('uuid', blocked=['_uuid']) @@ -35,6 +41,7 @@ def get_command_stdout(command, args): class BaseTestUUID: uuid = None + is_c_uuid = False def test_nil_uuid(self): nil_uuid = self.uuid.NIL @@ -270,6 +277,40 @@ def test_UUID(self): resorted.sort() equal(ascending, resorted) + def test_UUID_prefixes(self): + # Python removes both URN components regardless of their order. Check + # that both implementations accept them with each UUID string format. + value = '12345678-1234-5678-1234-567812345678' + expected = self.uuid.UUID(value) + for prefix in ('', 'urn:', 'uuid:', 'urn:uuid:', 'uuid:urn:'): + for text in (value, value.replace('-', ''), '{' + value + '}'): + with self.subTest(prefix=prefix, text=text): + self.assertEqual(self.uuid.UUID(prefix + text), expected) + + def test_UUID_strip_braces(self): + # str.strip('{}') removes runs of either brace at both ends, without + # requiring matching pairs. Keep the C parser's behavior identical. + value = '12345678-1234-5678-1234-567812345678' + expected = self.uuid.UUID(value) + for leading in ('', '{', '}', '{{{', '}}}', '{}}{'): + for trailing in ('', '{', '}', '{{{', '}}}', '{}}{'): + with self.subTest(leading=leading, trailing=trailing): + self.assertEqual( + self.uuid.UUID(leading + value + trailing), expected) + # Braces within the UUID and inputs containing only braces are invalid. + for text in ('{{}}', '{}{}', value[:8] + '{}' + value[8:]): + with self.subTest(text=text): + with self.assertRaises(ValueError): + self.uuid.UUID(text) + + def test_repr_subclass_str(self): + # repr() must call the subclass's __str__, as the Python version does. + class CustomUUID(self.uuid.UUID): + def __str__(self): + return 'custom uuid' + + self.assertEqual(repr(CustomUUID(int=1)), "CustomUUID('custom uuid')") + def test_exceptions(self): badvalue = lambda f: self.assertRaises(ValueError, f) badtype = lambda f: self.assertRaises(TypeError, f) @@ -282,14 +323,16 @@ def test_exceptions(self): badvalue(lambda: self.uuid.UUID('123456781234567812345678z2345678')) # Badly formed bytes. - badvalue(lambda: self.uuid.UUID(bytes='abc')) - badvalue(lambda: self.uuid.UUID(bytes='\0'*15)) - badvalue(lambda: self.uuid.UUID(bytes='\0'*17)) + badtype(lambda: self.uuid.UUID(bytes='abc')) + badvalue(lambda: self.uuid.UUID(bytes=b'abc')) + badvalue(lambda: self.uuid.UUID(bytes=b'\0'*15)) + badvalue(lambda: self.uuid.UUID(bytes=b'\0'*17)) # Badly formed bytes_le. - badvalue(lambda: self.uuid.UUID(bytes_le='abc')) - badvalue(lambda: self.uuid.UUID(bytes_le='\0'*15)) - badvalue(lambda: self.uuid.UUID(bytes_le='\0'*17)) + badtype(lambda: self.uuid.UUID(bytes_le='abc')) + badvalue(lambda: self.uuid.UUID(bytes_le=b'abc')) + badvalue(lambda: self.uuid.UUID(bytes_le=b'\0'*15)) + badvalue(lambda: self.uuid.UUID(bytes_le=b'\0'*17)) # Badly formed fields. badvalue(lambda: self.uuid.UUID(fields=(1,))) @@ -365,6 +408,70 @@ def test_exceptions(self): badtype(lambda: u < object()) badtype(lambda: u > object()) + def test_constructor_none(self): + # Explicit None has the same meaning as omitting an input argument. + expected = self.uuid.UUID('12345678-1234-5678-1234-567812345678') + inputs = { + 'hex': expected.hex, + 'bytes': expected.bytes, + 'bytes_le': expected.bytes_le, + 'fields': expected.fields, + 'int': expected.int, + } + for name, value in inputs.items(): + with self.subTest(input=name): + kwargs = dict.fromkeys(inputs) + kwargs[name] = value + self.assertEqual(self.uuid.UUID(**kwargs, version=None), expected) + self.assertEqual( + self.uuid.UUID(*kwargs.values(), version=None), expected) + + with self.assertRaisesRegex(TypeError, 'one of the hex, bytes, bytes_le'): + self.uuid.UUID(**dict.fromkeys(inputs)) + + def test_constructor_bytes_type(self): + # A buffer interface alone does not satisfy the bytes arguments. + for name in ('bytes', 'bytes_le'): + for value in (bytearray(16), memoryview(bytes(16)), 'x' * 16, + [0] * 16, 16, object()): + with self.subTest(argument=name, type=type(value)): + with self.assertRaisesRegex( + TypeError, f'^{name} must be a bytes object$' + ): + self.uuid.UUID(**{name: value}) + + def test_constructor_bytes_subclass(self): + class BytesSubclass(bytes): + pass + + expected = self.uuid.UUID('12345678-1234-5678-1234-567812345678') + for name in ('bytes', 'bytes_le'): + with self.subTest(argument=name): + value = BytesSubclass(getattr(expected, name)) + self.assertEqual(self.uuid.UUID(**{name: value}), expected) + + def test_constructor_is_safe_none(self): + # is_safe is stored as supplied; None is distinct from SafeUUID.unknown. + self.assertIsNone(self.uuid.UUID(int=1, is_safe=None).is_safe) + + def test_constructor_fields_length_error(self): + error = RuntimeError('fields length failed') + + class Fields(tuple): + def __len__(self): + raise error + + class NonSequence: + def __len__(self): + raise error + + # Preserve __len__ errors, including for objects without __getitem__. + for fields in (Fields((0,) * 6), NonSequence()): + with self.subTest(type=type(fields)): + with self.assertRaises(RuntimeError) as cm: + self.uuid.UUID(fields=fields) + self.assertIs(cm.exception, error) + def test_getnode(self): node1 = self.uuid.getnode() self.assertTrue(0 < node1 < (1 << 48), '%012x' % node1) @@ -388,6 +495,65 @@ def check(actual, expected): with self.subTest(protocol=proto): check(pickle.loads(pickle.dumps(u, proto)), u) + def test_setstate_mapping(self): + # State restoration accepts mappings and decodes serialized safety values. + safety_states = [({}, self.uuid.SafeUUID.unknown)] + safety_states.extend( + ({'is_safe': safety.value}, safety) + for safety in self.uuid.SafeUUID + ) + with support.swap_item(sys.modules, 'uuid', self.uuid): + for mapping in (dict, frozendict, UserDict, MappingProxyType): + for safety_state, expected_safety in safety_states: + with self.subTest(mapping=mapping, state=safety_state): + u = self.uuid.UUID(int=0, is_safe=self.uuid.SafeUUID.safe) + state = mapping({'int': 1, **safety_state}) + self.assertIsNone(u.__setstate__(state)) + self.assertEqual(u.int, 1) + self.assertIs(u.is_safe, expected_safety) + + def test_setstate_missing_int(self): + # A missing required key must retain the mapping's KeyError and key. + for mapping in (dict, frozendict, UserDict, MappingProxyType): + with self.subTest(mapping=mapping): + u = self.uuid.UUID(int=1) + with self.assertRaises(KeyError) as cm: + u.__setstate__(mapping({})) + self.assertEqual(cm.exception.args, ('int',)) + self.assertEqual(u.int, 1) + + def test_setstate_lookup_error(self): + class State(dict): + def __getitem__(self, key): + if key == bad_key: + raise RuntimeError('lookup failed') + return super().__getitem__(key) + + # Honor overridden lookups, including on dict subclasses. + for bad_key in ('int', 'is_safe'): + with self.subTest(key=bad_key): + u = self.uuid.UUID(int=1) + state = State(int=2, is_safe=0) + with self.assertRaisesRegex(RuntimeError, 'lookup failed'): + u.__setstate__(state) + + def test_setstate_contains_error(self): + class State(dict): + def __contains__(self, key): + raise RuntimeError('membership test failed') + + # Errors checking for the optional key must propagate as well. + u = self.uuid.UUID(int=1) + state = State(int=2) + with self.assertRaisesRegex(RuntimeError, 'membership test failed'): + u.__setstate__(state) + + def test_setstate_invalid_is_safe(self): + u = self.uuid.UUID(int=0) + with support.swap_item(sys.modules, 'uuid', self.uuid): + with self.assertRaisesRegex(ValueError, '42 is not a valid SafeUUID'): + u.__setstate__({'int': 1, 'is_safe': 42}) + def test_unpickle_previous_python_versions(self): def check(actual, expected): self.assertEqual(actual, expected) @@ -877,12 +1043,18 @@ def test_uuid6_test_vectors(self): equal((u.int >> 80) & 0xffff, 0x232a) equal((u.int >> 96) & 0xffff_ffff, 0x1ec9_414c) - def test_uuid7(self): + def test_uuid7_functional(self): equal = self.assertEqual u = self.uuid.uuid7() equal(u.variant, self.uuid.RFC_4122) equal(u.version, 7) + def test_uuid7_mock(self): + if self.is_c_uuid: + self.skipTest("C implementation of uuid7 cannot be tested with mocks") + + equal = self.assertEqual + # 1 Jan 2023 12:34:56.123_456_789 timestamp_ns = 1672533296_123_456_789 # ns precision timestamp_ms, _ = divmod(timestamp_ns, 1_000_000) @@ -940,7 +1112,15 @@ def test_uuid7_uniqueness(self): versions = {u.version for u in uuids} self.assertSetEqual(versions, {7}) - def test_uuid7_monotonicity(self): + def test_uuid7_monotonicity_functional(self): + equal = self.assertEqual + us = [self.uuid.uuid7() for _ in range(10_000)] + equal(us, sorted(us)) + + def test_uuid7_monotonicity_mock(self): + if self.is_c_uuid: + self.skipTest("C implementation of uuid7 cannot be tested with mocks") + equal = self.assertEqual us = [self.uuid.uuid7() for _ in range(10_000)] @@ -1003,7 +1183,10 @@ def test_uuid7_monotonicity(self): self.assertLess(u1, u2) - def test_uuid7_timestamp_backwards(self): + def test_uuid7_timestamp_backwards_mock(self): + if self.is_c_uuid: + self.skipTest("C implementation of uuid7 cannot be tested with mocks") + equal = self.assertEqual # 1 Jan 2023 12:34:56.123_456_789 timestamp_ns = 1672533296_123_456_789 # ns precision @@ -1043,7 +1226,10 @@ def test_uuid7_timestamp_backwards(self): equal((u.int >> 32) & 0x3fff_ffff, counter_lo + 1) equal(u.int & 0xffff_ffff, tail) - def test_uuid7_overflow_counter(self): + def test_uuid7_overflow_counter_mock(self): + if self.is_c_uuid: + self.skipTest("C implementation of uuid7 cannot be tested with mocks") + equal = self.assertEqual # 1 Jan 2023 12:34:56.123_456_789 timestamp_ns = 1672533296_123_456_789 # ns precision @@ -1149,6 +1335,7 @@ def test_uuid_weakref(self): class CommandLineTestCases: uuid = None # to be defined in subclasses + is_c_uuid = False def do_test_standalone_uuid(self, version): stdout = io.StringIO() @@ -1313,6 +1500,7 @@ class TestUUIDWithoutExtModule(CommandLineTestCases, BaseTestUUID, unittest.Test @unittest.skipUnless(c_uuid, 'requires the C _uuid module') class TestUUIDWithExtModule(CommandLineTestCases, BaseTestUUID, unittest.TestCase): uuid = c_uuid + is_c_uuid = True def check_has_stable_libuuid_extractable_node(self): if not self.uuid._has_stable_extractable_node: @@ -1343,6 +1531,7 @@ def test_windows_getnode_from_libuuid(self): class BaseTestInternals: _uuid = py_uuid + is_c_uuid = False def check_parse_mac(self, aix): if not aix: @@ -1536,6 +1725,7 @@ class TestInternalsWithoutExtModule(BaseTestInternals, unittest.TestCase): @unittest.skipUnless(c_uuid, 'requires the C _uuid module') class TestInternalsWithExtModule(BaseTestInternals, unittest.TestCase): uuid = c_uuid + is_c_uuid = True @unittest.skipUnless(os.name == 'posix', 'requires Posix') def test_unix_getnode(self): @@ -1553,5 +1743,432 @@ def test_windll_getnode(self): self.check_node(node) +class TestModule(unittest.TestCase): + def test_deprecated_module_attributes(self): + support.check_deprecated_module_attributes( + self, py_uuid, "__author__", remove=(3, 20), + ) + + +class UuidHooks: + + def __init__(self, *, start_at=0, inc_by=0, seed=0): + self._time = start_at + self._inc_by = inc_by + self._rnd = random.Random(seed) + + def random_func(self, size): + ret = b'' + for _ in range(size): + ret += self._rnd.getrandbits(8).to_bytes(1, 'big') + return ret + + def time_func(self): + self._time += self._inc_by + return self._time + + +@unittest.skipUnless(c_uuid, "requires the C _uuid module") +class TestCImplementationCompat(unittest.TestCase): + def test_is_safe_lookup_error(self): + # Force the lazy SafeUUID lookup to fail before it is cached. The getter + # must propagate AttributeError and recover when the attribute returns. + # Run in a subprocess because using the failed lookup can crash Python. + assert_python_ok('-c', textwrap.dedent(''' + import uuid + + obj = uuid.UUID(int=1) + SafeUUID = uuid.SafeUUID + del uuid.SafeUUID + try: + try: + obj.is_safe + except AttributeError as exc: + assert 'SafeUUID' in str(exc) + else: + raise AssertionError('SafeUUID lookup unexpectedly succeeded') + finally: + uuid.SafeUUID = SafeUUID + assert obj.is_safe is SafeUUID.unknown + ''')) + + def test_compatibility(self): + import uuid + + PU = uuid._py_UUID + CU = uuid._c_UUID + N = 1000 + + uuids = [ + "00000000-0000-0000-0000-000000000000", + "ffffffff-ffff-ffff-ffff-ffffffffffff", + "c0bec4fd-e4e3-050c-a362-da3f734ffd56", # regression + *(str(uuid.uuid4()) for _ in range(N)), + *(str(uuid.uuid7()) for _ in range(N)), + *(str(uuid.uuid1()) for _ in range(N)), + *(str(uuid.UUID(bytes=os.urandom(16))) for _ in range(N)), + ] + + def full_test(p, u): + self.assertEqual(p, u) + self.assertEqual(p.hex, u.hex) + self.assertEqual(p.int, u.int) + self.assertEqual(p.variant, u.variant) + self.assertEqual(p.version, u.version) + self.assertEqual(p.is_safe, u.is_safe) + self.assertEqual(p.bytes, u.bytes) + self.assertEqual(p.bytes_le, u.bytes_le) + self.assertEqual(p.fields, u.fields) + self.assertEqual(p.time_low, u.time_low) + self.assertEqual(p.time_mid, u.time_mid) + self.assertEqual(p.time_hi_version, u.time_hi_version) + self.assertEqual(p.clock_seq_hi_variant, u.clock_seq_hi_variant) + self.assertEqual(p.clock_seq_low, u.clock_seq_low) + self.assertEqual(p.node, u.node) + + all_ps = set() + all_us = set() + for uuid_str in uuids: + with self.subTest(uuid=uuid_str): + p = PU(uuid_str) + u = CU(uuid_str) + full_test(p, u) + + u2 = CU(bytes_le=p.bytes_le) + full_test(p, u2) + + u3 = CU(fields=p.fields) + full_test(p, u3) + + u4 = CU(int=p.int) + full_test(p, u4) + + u5 = CU( + hex=p.hex, + is_safe=uuid.SafeUUID.safe, + ) + full_test( + PU( + uuid_str, + is_safe=uuid.SafeUUID.safe, + ), + u5, + ) + + all_ps.add(p) + all_us.add(u) + + self.assertEqual(len(all_ps), len(all_us)) + self.assertEqual(len(all_ps), len(uuids)) + + def _install_hooks(self, uuid_mod, *, start_at=0, inc_by=0, seed=0): + py_hooks = UuidHooks(start_at=start_at, inc_by=inc_by, seed=seed) + uuid_mod._install_py_hooks( + random_func=py_hooks.random_func, + time_func=py_hooks.time_func + ) + + c_hooks = UuidHooks(start_at=start_at, inc_by=inc_by, seed=seed) + uuid_mod._install_c_hooks( + random_func=c_hooks.random_func, + time_func=c_hooks.time_func + ) + + def _reset_hooks(self, uuid_mod): + uuid_mod._install_c_hooks(random_func=None, time_func=None) + uuid_mod._install_py_hooks(random_func=None, time_func=None) + + def test_invalid_time_hook_result(self): + import uuid + + class IntSubclass(int): + pass + + class Indexable: + def __index__(self): + raise AssertionError('invalid results must not be converted') + + # Invalid results must be rejected before integer conversion. + for value in (None, False, 1.0, '1', object(), + IntSubclass(1), Indexable()): + with self.subTest(value=value): + uuid._install_c_hooks(random_func=None, + time_func=lambda: value) + try: + with self.assertRaisesRegex(ValueError, + '^time_func must return int$'): + uuid.uuid7() + finally: + uuid._install_c_hooks(random_func=None, time_func=None) + + def test_time_hook_exception(self): + import uuid + + def time_func(): + raise RuntimeError('time hook failed') + + uuid._install_c_hooks(random_func=None, time_func=time_func) + try: + with self.assertRaisesRegex(RuntimeError, 'time hook failed'): + uuid.uuid7() + finally: + uuid._install_c_hooks(random_func=None, time_func=None) + + def test_exact_same_algo_uuid4(self): + import uuid + + self._install_hooks(uuid) + try: + for seq_number in range(100): + with self.subTest(seq_number=seq_number): + self.assertEqual( + uuid._py_uuid4().hex, + uuid._c_uuid4().hex, + ) + finally: + self._reset_hooks(uuid) + + @threading_helper.requires_working_threading() + @threading_helper.reap_threads + def test_concurrent_entropy_refill(self): + # Concurrent calls must not consume the same cached entropy. Pause one + # UUIDv4 call during a refill after it consumes a partial cached block, + # then run another call. Each thread supplies its ID as entropy, making + # it possible to detect reuse of the first thread's cached prefix. + from concurrent.futures import ThreadPoolExecutor + import threading + import uuid + + entered = threading.Event() + resume = threading.Event() + local = threading.local() + local.id = 1 + local.pause_refill = False + + def random_func(size): + local.refill_size = size + if local.pause_refill: + entered.set() + if not resume.wait(support.SHORT_TIMEOUT): + raise TimeoutError('entropy refill was not resumed') + return bytes([local.id]) * size + + def generate(thread_id): + local.id = thread_id + local.pause_refill = thread_id == 1 + return uuid.uuid4() + + uuid._install_c_hooks(random_func=random_func, time_func=lambda: 0) + self.addCleanup(uuid._install_c_hooks, random_func=None, time_func=None) + + # UUIDv7 consumes 10 bytes initially. Leave less than one UUIDv4's + # entropy cached, so the next call must combine cached and fresh bytes. + uuid.uuid7() + size = len(uuid.UUID(int=0).bytes) + cached = local.refill_size - 10 + for _ in range(cached // size): + uuid.uuid4() + remaining = cached % size + self.assertGreater(remaining, 0) + + with ThreadPoolExecutor(2) as pool: + pending = pool.submit(generate, 1) + try: + self.assertTrue(entered.wait(support.SHORT_TIMEOUT)) + other = pool.submit(generate, 2).result( + timeout=support.SHORT_TIMEOUT) + finally: + resume.set() + first = pending.result(timeout=support.SHORT_TIMEOUT) + + # The waiting call reserved the cached prefix; the other call must + # obtain its prefix from a new entropy block instead of reusing it. + self.assertNotEqual(first.bytes[:remaining], other.bytes[:remaining]) + + @threading_helper.requires_working_threading() + @threading_helper.reap_threads + def test_concurrent_uuid7_state(self): + # UUIDv7 must recheck its counter if a refill lets another call advance + # it. Pause one call in the entropy hook and complete another first; + # with fixed time and entropy, the resumed call needs a higher counter. + # Exercise both the first UUIDv7 call and an already initialized counter. + from concurrent.futures import ThreadPoolExecutor + import threading + import uuid + + for initialized in (False, True): + with self.subTest(initialized=initialized): + entered = threading.Event() + resume = threading.Event() + calls = [] + lock = threading.Lock() + blocked_call = 2 if initialized else 1 + + def random_func(size): + with lock: + calls.append(size) + call = len(calls) + if call == blocked_call: + entered.set() + if not resume.wait(support.SHORT_TIMEOUT): + raise TimeoutError('entropy refill was not resumed') + # Keep time and entropy identical, so only the shared + # counter can distinguish the concurrent UUIDs. + return bytes(size) + + uuid._install_c_hooks(random_func=random_func, + time_func=lambda: 0) + try: + if initialized: + uuid.uuid7() + # Consume the remaining cache in four-byte tails, + # leaving the next UUIDv7 call to trigger a refill. + for _ in range((calls[0] - 10) // 4): + uuid.uuid7() + + with ThreadPoolExecutor(1) as pool: + pending = pool.submit(uuid.uuid7) + try: + self.assertTrue(entered.wait(support.SHORT_TIMEOUT)) + other = uuid.uuid7() + finally: + resume.set() + first = pending.result(timeout=support.SHORT_TIMEOUT) + + # A call resumed after another UUID was generated must + # advance from that UUID's state, not its stale snapshot. + self.assertGreater(first, other) + finally: + uuid._install_c_hooks(random_func=None, time_func=None) + + def test_exact_same_algo_uuid7(self): + import uuid + + try: + for start_at, inc_by in [ + (0, 0), (0, 10_000_000), (10_000_000 + 142, 1131827398127397) + ]: + self._install_hooks(uuid, start_at=start_at, inc_by=inc_by) + for seq_number in range(100): + with self.subTest( + seq_number=seq_number, start_at=start_at, inc_by=inc_by, + ): + self.assertEqual( + uuid._py_uuid7().hex, + uuid._c_uuid7().hex, + ) + finally: + self._reset_hooks(uuid) + + def test_subclassing(self): + import uuid + + class U(uuid._c_UUID): + pass + + u = U(int=1) + u_str = str(u) + del u + self.assertEqual(u_str, '00000000-0000-0000-0000-000000000001') + + def test_subclass_allocation(self): + # Subclasses must bypass the base UUID freelist and get enough storage + # for their slots and dictionary, with GC tracking for reference cycles. + # Run in a subprocess because an incorrectly sized or reused object + # can corrupt memory before the assertions detect it. + assert_python_ok('-c', textwrap.dedent(''' + import gc + import uuid + import weakref + + class U(uuid.UUID): + __slots__ = ('extra', '__dict__') + + # Exercise both the constructor and the internal factory. + for factory in (lambda cls: cls(int=1), lambda cls: cls._from_int(1)): + # Leave a base UUID available in the freelist. + base = uuid.UUID(int=0) + del base + u = factory(U) + # A subclass must not receive a cached base UUID. + assert type(u) is U + assert u.int == 1 + # Allocation must include storage for subclass slots and a dict. + object.__setattr__(u, 'extra', u) + object.__setattr__(u, 'other', 42) + assert u.extra is u + assert u.other == 42 + # The self-reference requires GC tracking to collect the object. + ref = weakref.ref(u) + del u + gc.collect() + assert ref() is None + + # Subclass allocation must leave the base freelist usable. + base = uuid.UUID(int=2) + assert type(base) is uuid.UUID + assert base.int == 2 + ''')) + + def test_subclass_module_finalization(self): + # GC may clear the base type's module reference before a subclass-owned + # instance is destroyed. Drop both modules and collect the subclass's + # class/instance cycle; deallocation must work without module state. + # Isolate the module removals and a possible crash in a subprocess. + assert_python_ok('-c', textwrap.dedent(''' + import gc + import sys + import weakref + + for from_int in (False, True): + import uuid + + module = sys.modules['_uuid'] + UUID = module.UUID + assert uuid.UUID is UUID + + # Remove the module's UUID constants before creating the cycle. + del sys.modules['uuid'] + del uuid + gc.collect() + + class Sub(UUID): + pass + + if from_int: + Sub.keep = Sub._from_int(1) + else: + Sub.keep = Sub(int=1) + refs = [weakref.ref(obj) for obj in + (module, UUID, Sub, Sub.keep)] + + del sys.modules['_uuid'] + del module, UUID, Sub + gc.collect() + assert all(ref() is None for ref in refs) + ''')) + + def test_freelist_type_lifetime(self): + # Reused live instances must keep their type and module alive, while + # cached instances must allow both to be collected. + module = import_helper.import_fresh_module('_uuid') + module_ref = weakref.ref(module) + type_ref = weakref.ref(module.UUID) + # Leave a base UUID available in the freelist. + obj = module.UUID(int=0) + del obj + # A reused live instance must still keep its type and module alive. + obj = module.UUID(int=1) + del module + support.gc_collect() + self.assertIsNotNone(type_ref()) + self.assertIsNotNone(module_ref()) + self.assertEqual(obj.int, 1) + del obj + support.gc_collect() + self.assertIsNone(type_ref()) + self.assertIsNone(module_ref()) + + if __name__ == '__main__': unittest.main() diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 58ae85fb268042e..eded0e5040d1480 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -133,6 +133,31 @@ def test_defaults_with_pathlike(self): self.run_with_capture(venv.create, FakePath(self.env_dir)) self._check_output_of_default_create() + def test_envbuilder_symlinks(self): + for kwargs, expected in ( + ({}, os.name != 'nt'), + ({'symlinks': None}, os.name != 'nt'), + ({'symlinks': True}, True), + ({'symlinks': False}, False), + ): + with self.subTest(kwargs=kwargs): + builder = venv.EnvBuilder(**kwargs) + self.assertIs(builder.symlinks, expected) + + def test_create_symlinks(self): + for kwargs, expected in ( + ({}, os.name != 'nt'), + ({'symlinks': None}, os.name != 'nt'), + ({'symlinks': True}, True), + ({'symlinks': False}, False), + ): + with self.subTest(kwargs=kwargs): + with patch.object(venv.EnvBuilder, 'create', autospec=True) as create: + venv.create(self.env_dir, **kwargs) + builder, env_dir = create.call_args.args + self.assertIs(builder.symlinks, expected) + self.assertEqual(env_dir, self.env_dir) + def _check_output_of_default_create(self): self.isdir(self.bindir) self.isdir(self.include) @@ -146,8 +171,7 @@ def _check_output_of_default_create(self): self.assertIn('home = %s' % path, data) self.assertIn('executable = %s' % os.path.realpath(sys.executable), data) - copies = '' if os.name=='nt' else ' --copies' - cmd = (f'command = {sys.executable} -m venv{copies} --without-pip ' + cmd = (f'command = {sys.executable} -m venv --without-pip ' f'--without-scm-ignore-files {self.env_dir}') self.assertIn(cmd, data) fn = self.get_env_file(self.bindir, self.exe) @@ -156,6 +180,7 @@ def _check_output_of_default_create(self): print('Contents of %r:' % bd) print(' %r' % os.listdir(bd)) self.assertTrue(os.path.exists(fn), 'File %r should exist.' % fn) + self.assertEqual(os.path.islink(fn), os.name != 'nt' and can_symlink()) def test_config_file_command_key(self): options = [ @@ -277,6 +302,28 @@ def test_prefixes(self): self.assertEqual(pathlib.Path(out.strip().decode()), pathlib.Path(expected), prefix) + # gh-157917: the "\\?\" extended-length prefix must not leak into the prefix + @requireVenvCreate + @unittest.skipUnless(os.name == 'nt', 'only relevant on Windows') + def test_prefixes_extended_length_path(self): + """ + Test that invoking a venv through a "\\?\" extended-length path does + not leave that prefix behind in the prefixes. Windows does not + resolve relative components (such as ".." or "/") in such paths, so + they break tools that join them onto sysconfig-derived paths. + """ + rmtree(self.env_dir) + self.run_with_capture(venv.create, self.env_dir) + envpy = os.path.join('\\\\?\\' + self.env_dir, self.bindir, self.exe) + for prefix in ('prefix', 'exec_prefix'): + with self.subTest(prefix): + out, err = check_output( + [envpy, '-c', 'import sys; print(sys.%s)' % prefix], + encoding='utf-8') + self.assertFalse(out.strip().startswith('\\\\?\\'), out) + self.assertEqual(pathlib.Path(out.strip()), + pathlib.Path(self.env_dir), prefix) + @requireVenvCreate def test_sysconfig(self): """ @@ -603,6 +650,27 @@ def test_install_scripts_selinux(self): venv.create(self.env_dir) listxattr_mock.assert_not_called() + @unittest.skipIf(os.name == 'nt', 'POSIX-specific permission test') + def test_install_scripts_honors_umask(self): + """ + gh-127172: Activation scripts must inherit the process umask (and any + default ACL) like every other created file, rather than a fixed mode + copied from the source template. + """ + old_umask = os.umask(0o002) + try: + venv.create(self.env_dir, with_pip=False) + bindir = os.path.join(self.env_dir, self.bindir) + control = os.path.join(bindir, 'control') + with open(control, 'w'): + pass + expected = os.stat(control).st_mode & 0o777 + for name in ('activate', 'activate.csh', 'activate.fish'): + mode = os.stat(os.path.join(bindir, name)).st_mode & 0o777 + self.assertEqual(mode, expected) + finally: + os.umask(old_umask) + def test_overwrite_existing(self): """ Test creating environment in an existing directory. @@ -638,6 +706,24 @@ def test_unoverwritable_fails(self): self.assertRaises((ValueError, OSError), venv.create, self.env_dir) self.clear_directory(self.env_dir) + @unittest.skipUnless(can_symlink(), 'Needs symlinks') + def test_symlinked_directory_error(self): + """ + Test that venv creation fails when a directory inside the target + directory is a symlink. + """ + outside = tempfile.mkdtemp() + self.addCleanup(rmtree, outside) + for n in range(1, len(self.lib) + 1): + subdirs = self.lib[:n] + with self.subTest(subdirs=subdirs): + rmtree(self.env_dir) + os.makedirs(os.path.join(self.env_dir, *subdirs[:-1])) + os.symlink(outside, os.path.join(self.env_dir, *subdirs), + target_is_directory=True) + self.assertRaises(ValueError, venv.create, self.env_dir) + self.assertEqual(os.listdir(outside), []) + def test_upgrade(self): """ Test upgrading an existing environment directory. @@ -783,8 +869,16 @@ def test_fish_activate_shadowed_builtins(self): shadows one of those builtins (a common pattern for `.`-style directory navigators) must not hijack the prompt or break status restoration. """ - fish = shutil.which('fish') - if fish is None: + # Some systems have an unrelated "fish" game (see fish(6)), which + # can precede the fish shell in PATH. + for dirname in None, *os.get_exec_path(): + fish = shutil.which('fish', path=dirname) + if fish is not None and subprocess.run( + [fish, '-c', 'echo $FISH_VERSION'], + stdin=subprocess.DEVNULL, + capture_output=True).stdout.strip(): + break + else: self.skipTest('fish required for this test') rmtree(self.env_dir) builder = venv.EnvBuilder(clear=True) @@ -813,6 +907,18 @@ def test_fish_activate_shadowed_builtins(self): self.assertNotIn('LEAK', text) self.assertIn('OLDSTATUS=7', text) + def test_fish_quoting(self): + """ + Test that the template strings are quoted properly (fish) + """ + builder = venv.EnvBuilder() + context = builder.ensure_directories(self.env_dir) + context.script_path = 'activate.fish' + context.prompt = r"x\'$(echo PWNED)'\'" + self.assertEqual( + builder.replace_variables('__VENV_PROMPT__', context), + r"'x\\\'$(echo PWNED)\'\\\''") + # gh-124651: test quoted strings on Windows @unittest.skipUnless(os.name == 'nt', 'only relevant on Windows') def test_special_chars_windows(self): @@ -913,6 +1019,33 @@ def test_failed_symlink(self): filepath_regex = r"'[A-Z]:\\\\(?:[^\\\\]+\\\\)*[^\\\\]+'" self.assertRegex(err, rf"Unable to symlink {filepath_regex} to {filepath_regex}") + @requireVenvCreate + @unittest.skipIf(os.name == 'nt', 'not relevant on Windows') + @unittest.skipUnless(can_symlink(), 'Needs symlinks') + def test_broken_symlink_in_existing_venv(self): + """ + Test creating a venv when a stale venv with broken symlinks exists. + """ + bindir = os.path.join(self.env_dir, self.bindir) + os.makedirs(bindir) + python = os.path.join(bindir, 'python3') + os.symlink('/path/to/deleted/env/bin/python3', python) + self.assertTrue(os.path.islink(python)) + self.assertFalse(os.path.exists(python)) + + builder = venv.EnvBuilder(with_pip=False, symlinks=True) + self.run_with_capture(builder.create, self.env_dir) + self.assertTrue(os.path.islink(python)) + self.assertTrue(os.path.exists(python)) + + rmtree(self.env_dir) + os.makedirs(bindir) + os.symlink('/path/to/deleted/env/bin/python3', python) + builder = venv.EnvBuilder(with_pip=False, symlinks=False) + self.run_with_capture(builder.create, self.env_dir) + self.assertFalse(os.path.islink(python)) + self.assertTrue(os.path.exists(python)) + @requireVenvCreate def test_multiprocessing(self): """ @@ -1270,7 +1403,13 @@ def test_devnull(self): def do_test_with_pip(self, system_site_packages): rmtree(self.env_dir) + os.mkdir(self.env_dir) + # Both ensurepip and its pip subprocess run with the venv as cwd. + for name in ('ensurepip.py', 'subprocess.py'): + pathlib.Path(self.env_dir, name).write_text( + 'raise AssertionError(__file__)\n', encoding='utf-8') with EnvironmentVarGuard() as envvars: + envvars["PYTHONSAFEPATH"] = "" # pip's cross-version compatibility may trigger deprecation # warnings in current versions of Python. Ensure related # environment settings don't cause venv to fail. diff --git a/Lib/test/test_warnings/__init__.py b/Lib/test/test_warnings/__init__.py index bf1bcf8e6ed5d9a..c069b81eb91c2ef 100644 --- a/Lib/test/test_warnings/__init__.py +++ b/Lib/test/test_warnings/__init__.py @@ -13,7 +13,9 @@ import unittest from test import support from test.support import import_helper +from test.support import isolation from test.support import os_helper +from test.support import threading_helper from test.support import warnings_helper from test.support import force_not_colorized from test.support.script_helper import assert_python_ok, assert_python_failure @@ -696,6 +698,20 @@ def test_skip_file_prefixes_type_errors(self): with self.assertRaises(TypeError): warn("msg", skip_file_prefixes="a sequence of strs") + def test_skip_file_prefixes_empty_tuple_subclass(self): + with warnings_state(self.module): + self.module.simplefilter("always") + warn = warning_tests.warnings.warn + class EmptyTuple(tuple): + pass + # Passing an empty tuple subclass used to lead to a crash. + for _ in range(3): + with self.module.catch_warnings(record=True) as w: + warn("msg", skip_file_prefixes=EmptyTuple()) + self.assertEqual(len(w), 1) + self.assertEqual(w[-1].filename, __file__) + self.assertEqual(w[-1].module, __name__) + def test_exec_filename_module(self): filename = "" codeobj = compile(("import warnings\n" @@ -1518,49 +1534,74 @@ class PyCatchWarningTests(CatchWarningTests, unittest.TestCase): module = py_warnings -class EnvironmentVariableTests(BaseTest): +_NONASCII_WARNOPTION = 'ignore:DeprecationWarning' + os_helper.FS_NONASCII + +class WarnOptionsTests(unittest.TestCase): + """Tests of the -W option and the PYTHONWARNINGS environment variable. + + sys.warnoptions is set by the interpreter, so these tests do not depend + on the used implementation of the warnings module. + """ + + @isolation.runInSubprocess( + env={'PYTHONWARNINGS': 'ignore::DeprecationWarning', + 'PYTHONDEVMODE': ''}) def test_single_warning(self): - rc, stdout, stderr = assert_python_ok("-c", - "import sys; sys.stdout.write(str(sys.warnoptions))", - PYTHONWARNINGS="ignore::DeprecationWarning", - PYTHONDEVMODE="") - self.assertEqual(stdout, b"['ignore::DeprecationWarning']") + self.assertEqual(sys.warnoptions, ['ignore::DeprecationWarning']) + @isolation.runInSubprocess( + env={'PYTHONWARNINGS': 'ignore::DeprecationWarning,' + 'ignore::UnicodeWarning', + 'PYTHONDEVMODE': ''}) def test_comma_separated_warnings(self): - rc, stdout, stderr = assert_python_ok("-c", - "import sys; sys.stdout.write(str(sys.warnoptions))", - PYTHONWARNINGS="ignore::DeprecationWarning,ignore::UnicodeWarning", - PYTHONDEVMODE="") - self.assertEqual(stdout, - b"['ignore::DeprecationWarning', 'ignore::UnicodeWarning']") + self.assertEqual(sys.warnoptions, ['ignore::DeprecationWarning', + 'ignore::UnicodeWarning']) - @force_not_colorized + @isolation.runInSubprocess( + options=['-Wignore::UnicodeWarning'], + env={'PYTHONWARNINGS': 'ignore::DeprecationWarning', + 'PYTHONDEVMODE': ''}) def test_envvar_and_command_line(self): - rc, stdout, stderr = assert_python_ok("-Wignore::UnicodeWarning", "-c", - "import sys; sys.stdout.write(str(sys.warnoptions))", - PYTHONWARNINGS="ignore::DeprecationWarning", - PYTHONDEVMODE="") - self.assertEqual(stdout, - b"['ignore::DeprecationWarning', 'ignore::UnicodeWarning']") + self.assertEqual(sys.warnoptions, ['ignore::DeprecationWarning', + 'ignore::UnicodeWarning']) + + @unittest.skipUnless(sys.getfilesystemencoding() != 'ascii', + 'requires non-ascii filesystemencoding') + @isolation.runInSubprocess( + env={'PYTHONWARNINGS': _NONASCII_WARNOPTION, + 'PYTHONDEVMODE': ''}) + def test_nonascii(self): + self.assertEqual(sys.warnoptions, [_NONASCII_WARNOPTION]) + + +class EnvironmentVariableTests(BaseTest): + + def prepare_code(self, code): + """Make the subprocess use the tested implementation.""" + if self.module is py_warnings: + # Disable the warnings acceleration module in the subprocess. + code = ("import sys; sys.modules.pop('warnings', None); " + "sys.modules['_warnings'] = None; ") + code + return code @force_not_colorized def test_conflicting_envvar_and_command_line(self): - rc, stdout, stderr = assert_python_failure("-Werror::DeprecationWarning", "-c", + code = self.prepare_code( "import sys, warnings; sys.stdout.write(str(sys.warnoptions)); " - "warnings.warn('Message', DeprecationWarning)", + "warnings.warn('Message', DeprecationWarning)") + rc, stdout, stderr = assert_python_failure( + "-Werror::DeprecationWarning", "-c", code, PYTHONWARNINGS="default::DeprecationWarning", PYTHONDEVMODE="") self.assertEqual(stdout, b"['default::DeprecationWarning', 'error::DeprecationWarning']") - self.assertEqual(stderr.splitlines(), - [b"Traceback (most recent call last):", - b" File \"\", line 1, in ", - b' import sys, warnings; sys.stdout.write(str(sys.warnoptions)); warnings.w' - b"arn('Message', DeprecationWarning)", - b' ~~~~~~~~~~' - b'~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', - b"DeprecationWarning: Message"]) + # The traceback of the Python implementation contains additional + # frames, so only the ends of the traceback are checked. + lines = stderr.splitlines() + self.assertEqual(lines[0], b"Traceback (most recent call last):") + self.assertEqual(lines[1], b' File "", line 1, in ') + self.assertEqual(lines[-1], b"DeprecationWarning: Message") def test_default_filter_configuration(self): pure_python_api = self.module is py_warnings @@ -1580,12 +1621,8 @@ def test_default_filter_configuration(self): ] expected_output = [str(f).encode() for f in expected_default_filters] - if pure_python_api: - # Disable the warnings acceleration module in the subprocess - code = "import sys; sys.modules.pop('warnings', None); sys.modules['_warnings'] = None; " - else: - code = "" - code += "import warnings; [print(f) for f in warnings._get_filters()]" + code = self.prepare_code( + "import warnings; [print(f) for f in warnings._get_filters()]") rc, stdout, stderr = assert_python_ok("-c", code, __isolated=True) stdout_lines = [line.strip() for line in stdout.splitlines()] @@ -1593,17 +1630,6 @@ def test_default_filter_configuration(self): self.assertEqual(stdout_lines, expected_output) - @unittest.skipUnless(sys.getfilesystemencoding() != 'ascii', - 'requires non-ascii filesystemencoding') - def test_nonascii(self): - PYTHONWARNINGS="ignore:DeprecationWarning" + os_helper.FS_NONASCII - rc, stdout, stderr = assert_python_ok("-c", - "import sys; sys.stdout.write(str(sys.warnoptions))", - PYTHONIOENCODING="utf-8", - PYTHONWARNINGS=PYTHONWARNINGS, - PYTHONDEVMODE="") - self.assertEqual(stdout, str([PYTHONWARNINGS]).encode()) - class CEnvironmentVariableTests(EnvironmentVariableTests, unittest.TestCase): module = c_warnings @@ -1621,6 +1647,100 @@ def test_release_lock_no_lock(self): ): c_warnings._release_lock() + @support.cpython_only + @unittest.skipUnless(support.has_fork_support, 'requires working os.fork') + @threading_helper.requires_working_threading() + def test_fork_other_thread_holds_lock(self): + code = textwrap.dedent(''' + import _warnings + import os + import threading + import warnings + from test import support + + parent_pid = os.getpid() + read_fd, write_fd = os.pipe() + local = threading.local() + ready = threading.Event() + release = threading.Event() + warnings.simplefilter('ignore', DeprecationWarning) + warnings.simplefilter('ignore', ResourceWarning) + + class WarnOnDelete: + def __del__(self): + if os.getpid() != parent_pid: + # Even an ignored warning must acquire the lock. + warnings.warn('child cleanup', ResourceWarning) + os.write(write_fd, b'finalized') + + def worker(): + local.obj = WarnOnDelete() + _warnings._acquire_lock() + _warnings._acquire_lock() + try: + ready.set() + release.wait() + finally: + _warnings._release_lock() + _warnings._release_lock() + + thread = threading.Thread(target=worker) + thread.start() + # Release the worker before fork's parent-side warning attempts + # to acquire the warnings lock. + os.register_at_fork(after_in_parent=release.set) + try: + assert ready.wait(support.LONG_TIMEOUT) + pid = os.fork() + if pid == 0: + # The finalizer must run before os.fork() returns. + os._exit(0) + support.wait_process(pid, exitcode=0) + finally: + release.set() + thread.join() + os.close(write_fd) + assert os.read(read_fd, 100) == b'finalized' + os.close(read_fd) + ''') + assert_python_ok('-c', code) + + @support.cpython_only + @unittest.skipUnless(support.has_fork_support, 'requires working os.fork') + def test_fork_current_thread_holds_lock(self): + code = textwrap.dedent(''' + import _warnings + import os + import warnings + from test import support + + warnings.simplefilter('ignore') + for _ in range(3): + _warnings._acquire_lock() + pid = os.fork() + try: + # A warning must not change the inherited recursion depth. + warnings.warn('after fork') + for _ in range(3): + _warnings._release_lock() + try: + _warnings._release_lock() + except RuntimeError: + pass + else: + raise AssertionError('unexpected recursion depth') + _warnings._acquire_lock() + _warnings._release_lock() + except BaseException: + if pid == 0: + os._exit(1) + raise + if pid == 0: + os._exit(0) + support.wait_process(pid, exitcode=0) + ''') + assert_python_ok('-c', code) + class _DeprecatedTest(BaseTest, unittest.TestCase): @@ -1661,6 +1781,37 @@ def test_RuntimeError(self): _version=version) +class WarnExplicitSourceTests(BaseTest): + # gh-155319: the source line is taken from the loader of the module + # whose globals are passed as module_globals, if the file which name + # is passed as filename cannot be read. + + def warn_explicit(self, lineno): + with support.captured_stderr() as stderr: + with self.module.catch_warnings(): + self.module.simplefilter("always") + self.module.warn_explicit( + 'eggs', UserWarning, 'nonexistent', lineno, + module_globals=warning_tests.__dict__) + return stderr.getvalue() + + def test_source_line(self): + source = warning_tests.__loader__.get_source(warning_tests.__name__) + expected = source.splitlines()[0].strip() + self.assertEqual(self.warn_explicit(1), + f'nonexistent:1: UserWarning: eggs\n {expected}\n') + + def test_source_line_out_of_range(self): + self.assertEqual(self.warn_explicit(1000), + 'nonexistent:1000: UserWarning: eggs\n') + +class CWarnExplicitSourceTests(WarnExplicitSourceTests, unittest.TestCase): + module = c_warnings + +class PyWarnExplicitSourceTests(WarnExplicitSourceTests, unittest.TestCase): + module = py_warnings + + class BootstrapTest(unittest.TestCase): def test_issue_8766(self): @@ -1675,6 +1826,59 @@ def test_issue_8766(self): assert_python_ok('-c', 'pass', '-W', 'always', PYTHONPATH=cwd) +class WarnExplicitMainTests(BaseTest): + # gh-123011: warn_explicit() with module globals of the __main__ module, + # no matter how it is executed. + code = ('import warnings\n' + 'warnings.warn_explicit("eggs", UserWarning, "bar", 1,\n' + ' module_globals=globals())\n') + + def prepare_code(self): + """Make the subprocess use the tested implementation.""" + if self.module is py_warnings: + return ("import sys\n" + "sys.modules['_warnings'] = None\n") + self.code + return self.code + + def check(self, err): + lines = err.decode().splitlines() + # Only the Python implementation adds the source line. + if len(lines) > 1 and lines[1].startswith(' '): + del lines[1] + self.assertEqual(lines, ['bar:1: UserWarning: eggs']) + + def make_script(self, dirname): + filename = os.path.join(dirname, 'spam.py') + with open(filename, 'w', encoding='utf-8') as f: + f.write(self.prepare_code()) + return filename + + def test_script(self): + # __main__ has __spec__ set to None. + with os_helper.temp_dir() as dirname: + filename = self.make_script(dirname) + rc, out, err = assert_python_ok(filename) + self.check(err) + + def test_module(self): + # __main__ has __spec__ of the module executed with -m. + with os_helper.temp_dir() as dirname: + self.make_script(dirname) + rc, out, err = assert_python_ok('-m', 'spam', PYTHONPATH=dirname) + self.check(err) + + def test_command(self): + # __main__ has the built-in importer as a loader. + rc, out, err = assert_python_ok('-c', self.prepare_code()) + self.check(err) + +class CWarnExplicitMainTests(WarnExplicitMainTests, unittest.TestCase): + module = c_warnings + +class PyWarnExplicitMainTests(WarnExplicitMainTests, unittest.TestCase): + module = py_warnings + + class FinalizationTest(unittest.TestCase): def test_finalization(self): # Issue #19421: warnings.warn() should not crash @@ -1816,6 +2020,7 @@ class ThreadTests(BaseTest): def setUp(self): super().setUp() + self.enterContext(self.module.catch_warnings()) self.module.resetwarnings() @unittest.skipIf(not ENABLE_THREAD_TESTS, @@ -1865,6 +2070,29 @@ def run_threads(): run_threads() + @threading_helper.requires_working_threading() + def test_lock_not_held_while_showing(self): + # showwarning() must not run with the warnings lock held, otherwise + # another thread that needs the lock would block. + import threading + + def other_thread(): + self.module.filterwarnings("always", category=TestWarning) + + def showwarning(*args, **kwargs): + t = threading.Thread(target=other_thread) + t.start() + t.join(timeout=support.SHORT_TIMEOUT) + alive.append(t.is_alive()) + + alive = [] + with self.module.catch_warnings(): + self.module.simplefilter("always") + self.module.showwarning = showwarning + self.module.warn("test", TestWarning) + self.module.warn_explicit("test", TestWarning, "file.py", 1) + self.assertEqual(alive, [False, False]) + class CThreadTests(ThreadTests, unittest.TestCase): module = c_warnings diff --git a/Lib/test/test_wave.py b/Lib/test/test_wave.py index d3723c04820d9d4..c482de12f7829b0 100644 --- a/Lib/test/test_wave.py +++ b/Lib/test/test_wave.py @@ -172,6 +172,19 @@ def test__all__(self): not_exported = {'KSDATAFORMAT_SUBTYPE_PCM'} support.check__all__(self, wave, not_exported=not_exported) + def test_getfp(self): + fp = io.BytesIO() + with wave.open(fp, 'wb') as w: + w.setnchannels(1) + w.setsampwidth(1) + w.setframerate(11025) + fp.seek(0) + with wave.open(fp) as r: + chunk = r.getfp() + self.assertIsNotNone(chunk) + self.assertIs(chunk.file, fp) + self.assertEqual(chunk.chunkname, b'RIFF') + class WaveLowLevelTest(unittest.TestCase): @@ -474,6 +487,184 @@ def test_open_pathlike(self): with wave.open(fake_path, 'rb') as f: pass + def test_open_invalid_mode(self): + with self.assertRaisesRegex(wave.Error, "mode must be"): + wave.open(io.BytesIO(), 'xb') + + +class WaveReadErrorTest(unittest.TestCase): + """Cover error and edge paths of Wave_read, and wave.open().""" + + FMT_PCM = struct.pack('\n text\n') + # an element with mixed content is not indented elem = ET.XML("texttail") ET.indent(elem) - self.assertEqual(ET.tostring(elem), b'\n texttail') + self.assertEqual(ET.tostring(elem), b'texttail') elem = ET.XML("

par

\n

text

\t


") ET.indent(elem) @@ -845,6 +846,45 @@ def test_indent_space_caching(self): len({id(el.tail) for el in elem.iter()}), ) + def test_indent_non_xml_whitespace(self): + # only " \t\r\n" are whitespace in XML (see XML 1.0, 2.3) + elem = ET.XML('\xa0

text

\xa0') + ET.indent(elem) + self.assertEqual( + ET.tostring(elem), + b' 

text

 ' + ) + + def test_indent_preserve(self): + # xml:space="preserve" applies to the whole subtree + elem = ET.XML('

text

') + ET.indent(elem) + self.assertEqual( + ET.tostring(elem), + b'

text

' + ) + # other values do not preserve whitespace + elem = ET.XML('

text

') + ET.indent(elem) + self.assertEqual( + ET.tostring(elem), + b'\n' + b' \n' + b'

text

\n' + b' \n' + b'' + ) + + def test_indent_mixed_content(self): + # whitespace in an element which contains text is significant + elem = ET.XML('

hello x y

') + ET.indent(elem) + self.assertEqual(ET.tostring(elem), b'

hello x y

') + # the subtree of such element is not indented either + elem = ET.XML('

hello y

') + ET.indent(elem) + self.assertEqual(ET.tostring(elem), b'

hello y

') + def test_indent_level(self): elem = ET.XML("

pre
post

text

") with self.assertRaises(ValueError): @@ -901,6 +941,70 @@ def test_tostring_default_namespace_original_no_namespace(self): with self.assertRaisesRegex(ValueError, EXPECTED_MSG): ET.tostring(elem, encoding='unicode', default_namespace='foobar') + def test_tostring_default_namespace_attributes(self): + # gh-61290: the default namespace does not apply to attribute names + elem = ET.XML('' + '') + self.assertEqual( + ET.tostring(elem, encoding='unicode', + default_namespace='http://effbot.org/ns'), + '' + '' + ) + + def test_tostring_default_namespace_qualified_attributes(self): + # a qualified attribute name always needs a prefix, even if it is + # in the default namespace + elem = ET.Element('{http://effbot.org/ns}body', + {'{http://effbot.org/ns}attr': 'value'}) + self.assertEqual( + ET.tostring(elem, encoding='unicode', + default_namespace='http://effbot.org/ns'), + '' + ) + # an attribute in another namespace uses the prefix of that namespace + elem = ET.Element('{http://effbot.org/ns}body', + {'{foobar}attr': 'value', 'plain': 'value'}) + self.assertEqual( + ET.tostring(elem, encoding='unicode', + default_namespace='http://effbot.org/ns'), + '' + ) + + def test_tostring_default_namespace_attributes_round_trip(self): + xml = ('') + elem = ET.XML(xml) + self.assertEqual( + ET.tostring(elem, encoding='unicode', + default_namespace='http://effbot.org/ns'), + xml + ) + self.assertEqual( + [sorted(e.attrib.items()) for e in ET.XML(xml).iter()], + [sorted(e.attrib.items()) for e in elem.iter()] + ) + + def test_tostring_default_namespace_registered_empty_prefix(self): + # gh-118416: the empty prefix is registered for other namespace, + # so it cannot be used for the default namespace + nsmap = ET.register_namespace._namespace_map + self.addCleanup(nsmap.pop, 'default', None) + ET.register_namespace('', 'default') + elem = ET.Element('{default}elem') + self.assertEqual( + ET.tostring(elem, encoding='unicode', + default_namespace='otherdefault'), + '' + ) + # without the option the registered prefix is used + self.assertEqual( + ET.tostring(elem, encoding='unicode'), + '' + ) + def test_tostring_no_xml_declaration(self): elem = ET.XML('') self.assertEqual( @@ -933,6 +1037,7 @@ def test_tostring_xml_declaration_cases(self): (b"\n" b"\xf8", 'ISO-8859-1', None), ('ø', 'unicode', None), + (b"\xef\xbb\xbf\xc3\xb8", 'utf-8-sig', None), # ... xml_declaration = False (b"ø", None, False), @@ -940,6 +1045,7 @@ def test_tostring_xml_declaration_cases(self): (b"ø", 'US-ASCII', False), (b"\xf8", 'ISO-8859-1', False), ("ø", 'unicode', False), + (b"\xef\xbb\xbf\xc3\xb8", 'utf-8-sig', False), # ... xml_declaration = True (b"\n" @@ -952,6 +1058,8 @@ def test_tostring_xml_declaration_cases(self): b"\xf8", 'ISO-8859-1', True), ("\n" "ø", 'unicode', True), + (b"\xef\xbb\xbf\n" + b"\xc3\xb8", 'utf-8-sig', True), ] for expected_retval, encoding, xml_declaration in TESTCASES: @@ -966,6 +1074,96 @@ def test_tostring_xml_declaration_cases(self): expected_retval ) + def test_tostring_default_namespace_attributes_html(self): + elem = ET.XML('') + self.assertEqual( + ET.tostring(elem, encoding='unicode', method='html', + default_namespace='http://effbot.org/ns'), + '' + ) + + def test_tostring_standalone(self): + elem = ET.XML('') + self.assertEqual( + ET.tostring(elem, encoding='unicode', standalone=True), + "\n" + "" + ) + self.assertEqual( + ET.tostring(elem, encoding='unicode', standalone=False), + "\n" + "" + ) + # the XML declaration is written even if it would be omitted + self.assertEqual( + ET.tostring(elem, standalone=True), + b"\n" + b"" + ) + self.assertEqual( + ET.tostring(elem, encoding='UTF-8', standalone=False), + b"\n" + b"" + ) + + def test_tostring_standalone_none(self): + elem = ET.XML('') + self.assertEqual( + ET.tostring(elem, encoding='unicode', standalone=None), + '' + ) + self.assertEqual( + ET.tostring(elem, encoding='unicode', xml_declaration=True, + standalone=None), + "\n" + ) + + def test_tostring_standalone_without_xml_declaration(self): + elem = ET.XML('') + for standalone in True, False: + for xml_declaration in False, 0, '': + with self.subTest(standalone=standalone, + xml_declaration=xml_declaration): + with self.assertRaises(ValueError): + ET.tostring(elem, xml_declaration=xml_declaration, + standalone=standalone) + + def test_tostring_standalone_text_method(self): + elem = ET.XML('text') + self.assertEqual( + ET.tostring(elem, encoding='unicode', method='text', + standalone=True), + 'text' + ) + + def test_tostringlist_standalone(self): + elem = ET.XML('') + self.assertEqual( + b''.join(ET.tostringlist(elem, standalone=True)), + b"\n" + b"" + ) + with self.assertRaises(ValueError): + ET.tostringlist(elem, xml_declaration=False, standalone=False) + + def test_write_standalone(self): + elem = ET.XML('') + tree = ET.ElementTree(elem) + for standalone, expected in [ + (True, "standalone='yes'"), (False, "standalone='no'")]: + with self.subTest(standalone=standalone): + file = io.StringIO() + tree.write(file, encoding='unicode', standalone=standalone) + self.assertEqual( + file.getvalue(), + "\n" + "" % expected + ) + file = io.StringIO() + with self.assertRaises(ValueError): + tree.write(file, encoding='unicode', xml_declaration=False, + standalone=True) + def test_tostringlist_default_namespace(self): elem = ET.XML('') self.assertEqual( @@ -1064,6 +1262,74 @@ def bxml(encoding, body=''): self.assertRaises(ValueError, ET.XML, xml('undefined').encode('ascii')) self.assertRaises(LookupError, ET.XML, xml('xxx').encode('ascii')) + def test_parse_text_source(self): + # gh-99064: The encoding declared in the document does not apply + # to a source which is already decoded. + def check(encoding, body): + xml = (f"" + f"{body}") + with self.subTest(encoding=encoding): + self.assertEqual(ET.parse(io.StringIO(xml)).getroot().text, + body) + # the same with an explicitly created parser + self.assertEqual( + ET.parse(io.StringIO(xml), ET.XMLParser()).getroot().text, + body) + check("ascii", 'a') + check("iso-8859-1", '\xbd') + check("iso-8859-15", '\u20ac') + check("cp437", '\u221a') + check("utf-8", '\u4e2d') + # not ASCII compatible, unsupported for a bytes source + check("utf-16", '\u4e2d') + check("utf-32", '\u4e2d') + + def test_parse_text_source_multiple_chunks(self): + # the encoding is overridden before the first chunk is parsed + body = '\xe4' * 100_000 + xml = "%s" % body + self.assertEqual(ET.parse(io.StringIO(xml)).getroot().text, body) + + def test_parse_input_larger_than_chunk(self): + # gh-83895: the C implementation feeds Expat in chunks of 1 MiB + size = 3 * (1 << 20) + xml = '
%s' % ('x' * size) + for source in xml, xml.encode(): + with self.subTest(type=type(source).__name__): + root = ET.fromstring(source) + self.assertEqual(len(root[0].text), size) + self.assertEqual(root[1].tag, 'b') + + # gh-83895: input larger than INT_MAX is fed to Expat in chunks. + # memuse is 3 for the Python implementation, which joins the collected + # data, 2 would be enough for the C implementation. + @support.bigmemtest(size=support._2G + 100, memuse=3, dry_run=False) + def test_large_input(self, size): + data = b'' + b'x' * size + b'' + root = None + try: + parser = ET.XMLParser() + parser.feed(data) + data = None + root = parser.close() + self.assertEqual(len(root.text), size) + finally: + data = None + root = None + + def test_parse_error_after_chunk_boundary(self): + # the reported position accounts for the preceding chunks + size = 2 * (1 << 20) + with self.assertRaises(ET.ParseError) as cm: + ET.fromstring('%s<' % ('x' * size)) + self.assertEqual(cm.exception.position, (1, size + 4)) + + def test_parse_error_msg_is_string(self): + with self.assertRaises(ET.ParseError) as cm: + ET.XML("<") + self.assertIsInstance(cm.exception.msg, str) + self.assertEqual(cm.exception.msg, "unclosed token: line 1, column 0") + @support.subTests('sample,exception', [ (b' \xa1', UnicodeDecodeError), # crashed (b' \xa1\n" @@ -1909,6 +2212,76 @@ def __next__(self): self._feed(parser, "bar") self.assert_event_tags(parser, [('start', 'foo'), ('end', 'foo')]) + # gh-63102: the pull parser reports events from any target + class SimpleTarget: + def start(self, tag, attrib): + return ('start', tag) + def end(self, tag): + return ('end', tag) + def data(self, data): + pass + def comment(self, text): + return ('comment', text) + def pi(self, target, data=None): + return ('pi', target) + def close(self): + return 'closed' + + def test_custom_target(self): + parser = ET.XMLPullParser(events=('start', 'end'), + target=self.SimpleTarget()) + self._feed(parser, "") + self.assert_event_tuples(parser, [ + ('start', ('start', 'root')), + ('start', ('start', 'element')), + ('end', ('end', 'element')), + ('end', ('end', 'root')), + ]) + + def test_custom_target_comment_pi(self): + parser = ET.XMLPullParser(events=('comment', 'pi'), + target=self.SimpleTarget()) + self._feed(parser, "") + self.assert_event_tuples(parser, [ + ('comment', ('comment', ' text ')), + ('pi', ('pi', 'pitarget')), + ]) + + def test_custom_target_without_method(self): + class Target: + def close(self): + pass + for event in ('start', 'end', 'comment', 'pi'): + with self.subTest(event=event): + with self.assertRaisesRegex(TypeError, + "the target does not support %r events" % event): + ET.XMLPullParser(events=(event,), target=Target()) + # the namespace events do not need methods of the target + parser = ET.XMLPullParser(events=('start-ns', 'end-ns'), + target=Target()) + self._feed(parser, "") + self.assert_event_tuples(parser, [ + ('start-ns', ('', 'namespace')), + ('end-ns', None), + ]) + + def test_custom_target_ns_events(self): + # the target does not implement start_ns()/end_ns(), + # so the prefix and the uri are reported + parser = ET.XMLPullParser(events=('start-ns', 'end-ns'), + target=self.SimpleTarget()) + self._feed(parser, "") + self.assert_event_tuples(parser, [ + ('start-ns', ('', 'namespace')), + ('end-ns', None), + ]) + + def test_custom_target_close(self): + parser = ET.XMLPullParser(events=('end',), target=self.SimpleTarget()) + self._feed(parser, "") + parser.close() + self.assert_event_tuples(parser, [('end', ('end', 'root'))]) + def test_unknown_event(self): with self.assertRaises(ValueError): ET.XMLPullParser(events=('start', 'end', 'bogus')) @@ -3246,7 +3619,7 @@ def __deepcopy__(self, memo): self.assertEqual([c.tag for c in children[3:]], [a.tag, b.tag, a.tag, b.tag]) - @support.skip_if_unlimited_stack_size + @support.run_with_limited_c_stack(500_000) @support.skip_emscripten_stack_overflow() @support.skip_wasi_stack_overflow() def test_deeply_nested_deepcopy(self): @@ -3477,6 +3850,37 @@ def test_find_xpath(self): self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[last()-0]') self.assertRaisesRegex(SyntaxError, 'XPath', e.find, './tag[last()+1]') + def test_find_xpath_index_no_quadratic_complexity(self): + class CountingElement(ET.Element): + findall_calls = 0 + def findall(self, *args, **kwargs): + type(self).findall_calls += 1 + return super().findall(*args, **kwargs) + + def work(n, pattern): + root = CountingElement("root") + for _ in range(n): + ET.SubElement(root, "a") + CountingElement.findall_calls = 0 + root.findall(pattern) + return CountingElement.findall_calls + + for pattern in [".//a[1]", ".//a[last()]"]: + w1 = work(1024, pattern) + w2 = work(2048, pattern) + w3 = work(4096, pattern) + + self.assertGreater(w1, 0) + r1 = w2 / w1 + r2 = w3 / w2 + # Doubling N must not ~double the parent.findall calls. + # Linear-in-N call counts indicate the cache is missing. + self.assertLess( + max(r1, r2), 1.5, + msg=f"Possible quadratic behavior on {pattern!r}: " + f"calls={w1, w2, w3} ratios={r1, r2}", + ) + def test_findall(self): e = ET.XML(SAMPLE_XML) e[2] = ET.XML(SAMPLE_SECTION) @@ -3665,6 +4069,19 @@ def test_bad_find(self): with self.assertRaisesRegex(SyntaxError, 'cannot use absolute path'): e.findall('/tag') + def test_find_invalid_path(self): + e = ET.XML(SAMPLE_XML) + paths = ('@', './x=y', './(', './)', './]', './!=', './::', + './()', "./'tag'", './"tag"', 'tag/@') + for obj in (e, ET.ElementTree(e)): + for method in ('find', 'findall', 'findtext', 'iterfind'): + for path in paths: + with self.subTest(type=type(obj).__name__, + method=method, path=path): + self.assertRaisesRegex( + SyntaxError, '^invalid path$', + getattr(obj, method), path) + def test_find_through_ElementTree(self): e = ET.XML(SAMPLE_XML) self.assertEqual(ET.ElementTree(e).find('tag').tag, 'tag') @@ -4022,6 +4439,21 @@ def close(self): ('html', '-//W3C//DTD XHTML 1.0 Transitional//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd')) + for doctype, expected in [ + ('', ('html', None, None)), + (']>', ('html', None, None)), + ('', ('html', None, 'a.dtd')), + (']>', + ('html', None, 'a.dtd')), + ('', ('html', '-//P', 'a.dtd')), + ("", + ('html', '-//P', 'a.dtd')), + ]: + with self.subTest(doctype=doctype): + parser = ET.XMLParser(target=DoctypeParser()) + parser.feed(doctype + '') + self.assertEqual(parser.close(), expected) + def test_builder_lookup_errors(self): class RaisingBuilder: def __init__(self, raise_in=None, what=ValueError): @@ -4720,6 +5152,11 @@ def test_simple_roundtrip(self): xml = '' self.assertEqual(c14n_roundtrip(xml), xml) + def test_c14n_strip_non_xml_whitespace(self): + # only " \t\r\n" are whitespace in XML (see XML 1.0, 2.3) + self.assertEqual(c14n_roundtrip(" \xa0x\xa0 ", strip_text=True), + "\xa0x\xa0") + def test_c14n_exclusion(self): xml = textwrap.dedent("""\ @@ -4904,13 +5341,10 @@ def get_option(config, option_name, default=None): class TestModule(unittest.TestCase): - def test_deprecated_version(self): - with self.assertWarnsRegex( - DeprecationWarning, - "'VERSION' is deprecated and slated for removal in Python 3.20", - ) as cm: - getattr(ET, "VERSION") - self.assertEqual(cm.filename, __file__) + def test_deprecated_module_attributes(self): + support.check_deprecated_module_attributes( + self, ET, "VERSION", remove=(3, 20), + ) # -------------------------------------------------------------------- diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py index 270b9d6da8e7b9e..cf616f300670a3c 100644 --- a/Lib/test/test_xml_etree_c.py +++ b/Lib/test/test_xml_etree_c.py @@ -15,16 +15,6 @@ @unittest.skipUnless(cET, 'requires _elementtree') class MiscTests(unittest.TestCase): - # Issue #8651. - @support.bigmemtest(size=support._2G + 100, memuse=1, dry_run=False) - def test_length_overflow(self, size): - data = b'x' * size - parser = cET.XMLParser() - try: - self.assertRaises(OverflowError, parser.feed, data) - finally: - data = None - def test_del_attribute(self): element = cET.Element('tag') @@ -171,6 +161,35 @@ def test_xmlpullparser_leaks(self): del parser support.gc_collect() + def test_iter_tag_reentrant_compare(self): + destroyed = [] + compared = [] + + class Tag: + def __del__(self): + destroyed.append(True) + + def __eq__(self, other): + child.tag = "replaced" + return NotImplemented + + __hash__ = object.__hash__ + + class Sought: + def __eq__(self, other): + if isinstance(other, Tag): + compared.append(not destroyed) + return NotImplemented + + __hash__ = object.__hash__ + + root = cET.Element("root") + child = cET.SubElement(root, "x") + child.tag = Tag() + self.assertEqual(list(root.iter(Sought())), []) + self.assertEqual(compared, [True]) + self.assertEqual(child.tag, "replaced") + def test_dict_disappearing_during_get_item(self): # test fix for seg fault reported in issue 27946 class X: @@ -194,8 +213,7 @@ def test_immutable_types(self): ) for tp in dataset: with self.subTest(tp=tp): - with self.assertRaisesRegex(TypeError, "immutable"): - tp.foo = 1 + support.check_immutable_type(self, tp) @support.cpython_only def test_disallow_instantiation(self): diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py index ee0e24f6e86ae33..78dbb5459cf6ae0 100644 --- a/Lib/test/test_xmlrpc.py +++ b/Lib/test/test_xmlrpc.py @@ -252,6 +252,18 @@ def test_loads_unsupported(self): '') self.assertRaises(ResponseError, xmlrpclib.loads, data) + def test_loads_nested_scalars(self): + template = '%s' + # CDATA splits 'ab' into two fragments so that joining them again + # would allocate another string. str.join() can reuse a single fragment. + data = template % 'a' + values, _ = xmlrpclib.loads(data) + self.assertEqual(values, ('ab', '')) + + data = template % '12' + values, _ = xmlrpclib.loads(data) + self.assertEqual(values, (1, 2)) + def check_loads(self, s, value, **kwargs): dump = '%s' % s result, m = xmlrpclib.loads(dump, **kwargs) diff --git a/Lib/test/test_zipapp.py b/Lib/test/test_zipapp.py index 8fb0a68deba535c..88cc55716f59a80 100644 --- a/Lib/test/test_zipapp.py +++ b/Lib/test/test_zipapp.py @@ -366,6 +366,24 @@ def test_shebang_is_executable(self): zipapp.create_archive(str(source), str(target), interpreter='python') self.assertTrue(target.stat().st_mode & stat.S_IEXEC) + @unittest.skipIf(sys.platform == 'win32', + 'Windows does not support an executable bit') + @os_helper.skip_unless_working_chmod + def test_copied_archive_with_pathlike_target_is_executable(self): + # Test that copying an archive to a PathLike target makes it executable. + source = self.tmpdir / 'source' + source.mkdir() + (source / '__main__.py').touch() + target = self.tmpdir / 'source.pyz' + zipapp.create_archive(source, target, interpreter='python') + # Copying an archive uses a different code path than creating + # one from scratch. Ensure that the executable bit is set + # even if the target is a path-like object. + # See https://github.com/python/cpython/issues/156568 + new_target = self.tmpdir / 'changed.pyz' + zipapp.create_archive(target, new_target, interpreter='python') + self.assertTrue(new_target.stat().st_mode & stat.S_IEXEC) + @unittest.skipIf(sys.platform == 'win32', 'Windows does not support an executable bit') def test_no_shebang_is_not_executable(self): diff --git a/Lib/test/test_zipfile/_path/_test_params.py b/Lib/test/test_zipfile/_path/_test_params.py index 00a9eaf2f99c1ae..8aaf7aa67a4dfb9 100644 --- a/Lib/test/test_zipfile/_path/_test_params.py +++ b/Lib/test/test_zipfile/_path/_test_params.py @@ -1,5 +1,6 @@ import functools import types +from contextlib import AbstractContextManager from ._itertools import always_iterable @@ -9,6 +10,8 @@ def parameterize(names, value_groups): Decorate a test method to run it as a set of subtests. Modeled after pytest.parametrize. + + Context Manager types are entered and exited. """ def decorator(func): @@ -17,6 +20,9 @@ def wrapped(self): for values in value_groups: resolved = map(Invoked.eval, always_iterable(values)) params = dict(zip(always_iterable(names), resolved)) + for value in params.values(): + if isinstance(value, AbstractContextManager): + self.enterContext(value) with self.subTest(**params): func(self, **params) diff --git a/Lib/test/test_zipfile/_path/test_complexity.py b/Lib/test/test_zipfile/_path/test_complexity.py index 7c108fc6ab8191d..f72b5b90c4510dd 100644 --- a/Lib/test/test_zipfile/_path/test_complexity.py +++ b/Lib/test/test_zipfile/_path/test_complexity.py @@ -17,7 +17,7 @@ class TestComplexity(unittest.TestCase): @pytest.mark.flaky def test_implied_dirs_performance(self): - best, others = big_o.big_o( + best, _others = big_o.big_o( compose(consume, zipfile._path.CompleteDirs._implied_dirs), lambda size: [ '/'.join(string.ascii_lowercase + str(n)) for n in range(size) @@ -66,7 +66,7 @@ def make_deep_path(cls, depth): return ''.join(('d/',) * depth) def test_baseline_regex_complexity(self): - best, others = big_o.big_o( + best, _others = big_o.big_o( lambda path: re.fullmatch(r'[^/]*\\.txt', path), self.make_deep_path, max_n=100, @@ -76,7 +76,7 @@ def test_baseline_regex_complexity(self): @pytest.mark.flaky def test_glob_depth(self): - best, others = big_o.big_o( + best, _others = big_o.big_o( lambda path: consume(path.glob('*.txt')), self.make_zip_path, max_n=100, @@ -86,7 +86,7 @@ def test_glob_depth(self): @pytest.mark.flaky def test_glob_width(self): - best, others = big_o.big_o( + best, _others = big_o.big_o( lambda path: consume(path.glob('*.txt')), lambda size: self.make_zip_path(width=size), max_n=100, @@ -96,7 +96,7 @@ def test_glob_width(self): @pytest.mark.flaky def test_glob_width_and_depth(self): - best, others = big_o.big_o( + best, _others = big_o.big_o( lambda path: consume(path.glob('*.txt')), lambda size: self.make_zip_path(depth=size, width=size), max_n=10, diff --git a/Lib/test/test_zipfile/_path/test_path.py b/Lib/test/test_zipfile/_path/test_path.py index e7931b6f394075d..eec79311947f6cd 100644 --- a/Lib/test/test_zipfile/_path/test_path.py +++ b/Lib/test/test_zipfile/_path/test_path.py @@ -1,4 +1,3 @@ -import contextlib import io import itertools import pathlib @@ -83,12 +82,8 @@ def build_alpharep_fixture(): class TestPath(unittest.TestCase): - def setUp(self): - self.fixtures = contextlib.ExitStack() - self.addCleanup(self.fixtures.close) - def zipfile_ondisk(self, alpharep): - tmpdir = pathlib.Path(self.fixtures.enter_context(temp_dir())) + tmpdir = pathlib.Path(self.enterContext(temp_dir())) buffer = alpharep.fp alpharep.close() path = tmpdir / alpharep.filename @@ -100,7 +95,7 @@ def zipfile_ondisk(self, alpharep): def test_iterdir_and_types(self, alpharep): root = zipfile.Path(alpharep) assert root.is_dir() - a, n, b, g, j = root.iterdir() + a, n, b, g, j = root.iterdir() # noqa: RUF059 assert a.is_file() assert b.is_dir() assert g.is_dir() @@ -120,8 +115,8 @@ def test_is_file_missing(self, alpharep): @pass_alpharep def test_iterdir_on_file(self, alpharep): root = zipfile.Path(alpharep) - a, n, b, g, j = root.iterdir() - with self.assertRaises(ValueError): + a, n, b, g, j = root.iterdir() # noqa: RUF059 + with self.assertRaises(NotADirectoryError): a.iterdir() @pass_alpharep @@ -135,7 +130,7 @@ def test_subdir_is_dir(self, alpharep): @pass_alpharep def test_open(self, alpharep): root = zipfile.Path(alpharep) - a, n, b, g, j = root.iterdir() + a, n, b, g, j = root.iterdir() # noqa: RUF059 with a.open(encoding="utf-8") as strm: data = strm.read() self.assertEqual(data, "content of a") @@ -145,7 +140,7 @@ def test_open(self, alpharep): def test_open_encoding_utf16(self): in_memory_file = io.BytesIO() - zf = zipfile.ZipFile(in_memory_file, "w") + zf = self.enterContext(zipfile.ZipFile(in_memory_file, "w")) zf.writestr("path/16.txt", "This was utf-16".encode("utf-16")) zf.filename = "test_open_utf16.zip" root = zipfile.Path(zf) @@ -160,7 +155,7 @@ def test_open_encoding_utf16(self): def test_open_encoding_errors(self): in_memory_file = io.BytesIO() - zf = zipfile.ZipFile(in_memory_file, "w") + zf = self.enterContext(zipfile.ZipFile(in_memory_file, "w")) zf.writestr("path/bad-utf8.bin", b"invalid utf-8: \xff\xff.") zf.filename = "test_read_text_encoding_errors.zip" root = zipfile.Path(zf) @@ -178,24 +173,30 @@ def test_open_encoding_errors(self): data = u16.read_text("utf-8", encoding="utf-8") # both keyword arguments work. - with u16.open("r", encoding="utf-8", errors="strict") as f: - # error during decoding with wrong codec. - with self.assertRaises(UnicodeDecodeError): - f.read() + # error during decoding with wrong codec. + with ( + u16.open("r", encoding="utf-8", errors="strict") as f, + self.assertRaises(UnicodeDecodeError), + ): + f.read() @unittest.skipIf( not getattr(sys.flags, 'warn_default_encoding', 0), "Requires warn_default_encoding", ) + @unittest.skipIf( + sys.implementation.name == 'pypy' and sys.pypy_version_info < (7, 3, 18), + "Older PyPy versions set the wrong stacklevel in text_encoding()", + ) @pass_alpharep def test_encoding_warnings(self, alpharep): """EncodingWarning must blame the read_text and open calls.""" assert sys.flags.warn_default_encoding root = zipfile.Path(alpharep) - with self.assertWarns(EncodingWarning) as wc: # noqa: F821 (astral-sh/ruff#13296) + with self.assertWarns(EncodingWarning) as wc: root.joinpath("a.txt").read_text() assert __file__ == wc.filename - with self.assertWarns(EncodingWarning) as wc: # noqa: F821 (astral-sh/ruff#13296) + with self.assertWarns(EncodingWarning) as wc: root.joinpath("a.txt").open("r").close() assert __file__ == wc.filename @@ -204,7 +205,8 @@ def test_open_write(self): If the zipfile is open for write, it should be possible to write bytes or text to it. """ - zf = zipfile.Path(zipfile.ZipFile(io.BytesIO(), mode='w')) + zip_file = self.enterContext(zipfile.ZipFile(io.BytesIO(), mode='w')) + zf = zipfile.Path(zip_file) with zf.joinpath('file.bin').open('wb') as strm: strm.write(b'binary contents') with zf.joinpath('file.txt').open('w', encoding="utf-8") as strm: @@ -239,7 +241,7 @@ def test_open_missing_directory(self, alpharep): @pass_alpharep def test_read(self, alpharep): root = zipfile.Path(alpharep) - a, n, b, g, j = root.iterdir() + a, n, b, g, j = root.iterdir() # noqa: RUF059 assert a.read_text(encoding="utf-8") == "content of a" # Also check positional encoding arg (gh-101144). assert a.read_text("utf-8") == "content of a" @@ -306,7 +308,7 @@ def test_mutability(self, alpharep): reflect that change. """ root = zipfile.Path(alpharep) - a, n, b, g, j = root.iterdir() + a, n, b, g, j = root.iterdir() # noqa: RUF059 alpharep.writestr('foo.txt', 'foo') alpharep.writestr('bar/baz.txt', 'baz') assert any(child.name == 'foo.txt' for child in root.iterdir()) @@ -319,7 +321,7 @@ def test_mutability(self, alpharep): def huge_zipfile(self): """Create a read-only zipfile with a huge number of entries.""" strm = io.BytesIO() - zf = zipfile.ZipFile(strm, "w") + zf = self.enterContext(zipfile.ZipFile(strm, "w")) for entry in map(str, range(self.HUGE_ZIPFILE_NUM_ENTRIES)): zf.writestr(entry, entry) zf.mode = 'r' @@ -351,6 +353,21 @@ class Subclass(zipfile.Path): root = Subclass(alpharep) assert isinstance(root / 'b', Subclass) + def test_at(self): + zip_file = self.enterContext(zipfile.ZipFile(io.BytesIO(), 'w')) + root = zipfile.Path(zip_file) + assert root.at == '' + assert (root / 'foo' / 'bar').at == 'foo/bar' + + def test_str(self): + """ + An unnamed zip file is indicated by ":zipfile:" + """ + zip_file = self.enterContext(zipfile.ZipFile(io.BytesIO(), 'w')) + root = zipfile.Path(zip_file) + assert str(root) == ':zipfile:' + assert str(root / 'foo' / 'bar') == ':zipfile:/foo/bar' + @pass_alpharep def test_filename(self, alpharep): root = zipfile.Path(alpharep) @@ -529,8 +546,30 @@ def test_glob_chars(self, alpharep): zipfile.Path(alpharep, "j/l.baz"), ] + @parameterize( + ['alpharep', 'pattern', 'expected'], + [ + (alpharep, pattern, expected) + for alpharep in alpharep_generators + for pattern, expected in [ + ('[!a].txt', {'n.txt'}), + ('[!an].txt', set()), + ('[!b]', {'g/', 'j/'}), + ('j/[!k].b*', {'j/l.baz', 'j/m.bar'}), + ('j/[^k].b*', {'j/k.bin'}), + ('j/[!k-l].b*', {'j/m.bar'}), + ('j/[k-l].b*', {'j/k.bin', 'j/l.baz'}), + ('b[!x]c.txt', set()), + ] + ], + ) + def test_glob_character_class_syntax(self, alpharep, pattern, expected): + root = zipfile.Path(alpharep) + assert {path.at for path in root.glob(pattern)} == expected + def test_glob_empty(self): - root = zipfile.Path(zipfile.ZipFile(io.BytesIO(), 'w')) + zip_file = self.enterContext(zipfile.ZipFile(io.BytesIO(), 'w')) + root = zipfile.Path(zip_file) with self.assertRaises(ValueError): root.glob('') @@ -580,7 +619,7 @@ def test_pickle(self, alpharep, path_type, subpath): saved_1 = pickle.dumps(root) root.root.close() restored_1 = pickle.loads(saved_1) - first, *rest = restored_1.iterdir() + first, *_rest = restored_1.iterdir() assert first.read_text(encoding='utf-8').startswith('content of ') restored_1.root.close() @@ -614,7 +653,7 @@ def test_malformed_paths(self): Paths with dots are treated like regular files. """ data = io.BytesIO() - zf = zipfile.ZipFile(data, "w") + zf = self.enterContext(zipfile.ZipFile(data, "w")) zf.writestr("/one-slash.txt", b"content") zf.writestr("//two-slash.txt", b"content") zf.writestr("../parent.txt", b"content") @@ -632,7 +671,7 @@ def test_unsupported_names(self): in the zip file. """ data = io.BytesIO() - zf = zipfile.ZipFile(data, "w") + zf = self.enterContext(zipfile.ZipFile(data, "w")) zf.writestr("path?", b"content") zf.writestr("V: NMS.flac", b"fLaC...") zf.filename = '' @@ -647,7 +686,7 @@ def test_backslash_not_separator(self): In a zip file, backslashes are not separators. """ data = io.BytesIO() - zf = zipfile.ZipFile(data, "w") + zf = self.enterContext(zipfile.ZipFile(data, "w")) zf.writestr(DirtyZipInfo("foo\\bar")._for_archive(zf), b"content") zf.filename = '' root = zipfile.Path(zf) diff --git a/Lib/test/test_zipfile/test_core.py b/Lib/test/test_zipfile/test_core.py index 4f20209927e7b3d..ccb8b87023eb5e6 100644 --- a/Lib/test/test_zipfile/test_core.py +++ b/Lib/test/test_zipfile/test_core.py @@ -1,6 +1,7 @@ import _pyio import array import contextlib +import errno import importlib.util import io import itertools @@ -21,16 +22,20 @@ from random import randint, random, randbytes from test import archiver_tests -from test.support import script_helper, os_helper +from test.support import script_helper from test.support import ( findfile, requires_zlib, requires_bz2, requires_lzma, requires_zstd, captured_stdout, captured_stderr, requires_subprocess, - cpython_only + cpython_only, gc_collect, catch_unraisable_exception ) from test.support.os_helper import ( - TESTFN, unlink, rmtree, temp_dir, temp_cwd, fd_count, FakePath + TESTFN, unlink, rmtree, temp_dir, temp_cwd, fd_count, FakePath, + with_source_date_epoch, without_source_date_epoch, ) from test.support.import_helper import ensure_lazy_imports +from test.support.warnings_helper import ( + check_no_resource_warning, ignore_warnings, +) TESTFN2 = TESTFN + "2" @@ -53,6 +58,15 @@ def get_files(test): test.assertFalse(f.closed) +@contextlib.contextmanager +def save_restore_sys_path(): + old_path = sys.path.copy() + try: + yield + finally: + sys.path[:] = old_path + + class LazyImportTest(unittest.TestCase): @cpython_only def test_lazy_import(self): @@ -497,7 +511,7 @@ def zip_test_writestr_permissions(self, f, compression): self.make_test_archive(f, compression) with zipfile.ZipFile(f, "r") as zipfp: zinfo = zipfp.getinfo('strfile') - self.assertEqual(zinfo.external_attr, 0o600 << 16) + self.assertEqual(zinfo.external_attr, 0o100600 << 16) zinfo2 = zipfp.getinfo('written-open-w') self.assertEqual(zinfo2.external_attr, 0o600 << 16) @@ -655,6 +669,12 @@ def test_add_file_after_2107(self): os.utime(TESTFN, (ts, ts)) except OverflowError: self.skipTest('Host fs cannot set timestamp to required value.') + except OSError as exc: + # Some file systems (e.g. UFS and ZFS on illumos) do not + # support timestamps that do not fit in 32 bits. + if exc.errno != errno.EOVERFLOW: + raise + self.skipTest('Host fs cannot set timestamp to required value.') mtime_ns = os.stat(TESTFN).st_mtime_ns if mtime_ns != (4386268800 * 10**9): @@ -1953,6 +1973,7 @@ def test_repack_file_entry_before_first_file(self): with zipfile.ZipFile(TESTFN) as zh: self.assertIsNone(zh.testzip()) + @without_source_date_epoch # SOURCE_DATE_EPOCH would bypass the time mock below @mock.patch.object(time, 'time', new=lambda: 315590400) # fix time for ZipFile.writestr() def test_repack_bytes_before_removed_files(self): """Should preserve if there are bytes before stale local file entries.""" @@ -1997,6 +2018,7 @@ def test_repack_bytes_before_removed_files(self): with zipfile.ZipFile(TESTFN) as zh: self.assertIsNone(zh.testzip()) + @without_source_date_epoch # SOURCE_DATE_EPOCH would bypass the time mock below @mock.patch.object(time, 'time', new=lambda: 315590400) # fix time for ZipFile.writestr() def test_repack_bytes_after_removed_files(self): """Should keep extra bytes if there are bytes after stale local file entries.""" @@ -2040,6 +2062,7 @@ def test_repack_bytes_after_removed_files(self): with zipfile.ZipFile(TESTFN) as zh: self.assertIsNone(zh.testzip()) + @without_source_date_epoch # SOURCE_DATE_EPOCH would bypass the time mock below @mock.patch.object(time, 'time', new=lambda: 315590400) # fix time for ZipFile.writestr() def test_repack_bytes_between_removed_files(self): """Should strip only local file entries before random bytes.""" @@ -2244,6 +2267,7 @@ def test_repack_removed_partial(self): with zipfile.ZipFile(TESTFN) as zh: self.assertIsNone(zh.testzip()) + @without_source_date_epoch # SOURCE_DATE_EPOCH would bypass the time mock below @mock.patch.object(time, 'time', new=lambda: 315590400) # fix time for ZipFile.writestr() def test_repack_removed_bytes_between_files(self): """Should not remove bytes between local file entries.""" @@ -2375,6 +2399,18 @@ def test_repack_writing(self, m_repack): zh.repack() m_repack.assert_not_called() + @mock.patch.object(zipfile, '_ZipRepacker') + def test_repack_reading(self, m_repack): + self._prepare_zip_from_test_files(TESTFN, self.test_files) + with zipfile.ZipFile(TESTFN, 'a') as zh: + with zh.open(self.test_files[0][0]): + with self.assertRaises(ValueError): + zh.repack() + m_repack.assert_not_called() + # Allowed once the reading handle is closed. + zh.repack() + m_repack.assert_called_once() + @mock.patch.object(zipfile, '_ZipRepacker') def test_repack_mode_r(self, m_repack): self._prepare_zip_from_test_files(TESTFN, self.test_files) @@ -3996,29 +4032,24 @@ def test_writestr_extended_local_header_issue1202(self): zinfo.flag_bits |= zipfile._MASK_USE_DATA_DESCRIPTOR # Include an extended local header. orig_zip.writestr(zinfo, data) + @with_source_date_epoch(epoch=1735715999) def test_write_with_source_date_epoch(self): - with os_helper.EnvironmentVarGuard() as env: - # Set the SOURCE_DATE_EPOCH environment variable to a specific timestamp - env['SOURCE_DATE_EPOCH'] = "1735715999" - - with zipfile.ZipFile(TESTFN, "w") as zf: - zf.writestr("test_source_date_epoch.txt", "Testing SOURCE_DATE_EPOCH") + with zipfile.ZipFile(TESTFN, "w") as zf: + zf.writestr("test_source_date_epoch.txt", "Testing SOURCE_DATE_EPOCH") - with zipfile.ZipFile(TESTFN, "r") as zf: - zip_info = zf.getinfo("test_source_date_epoch.txt") - expected_utc = (2025, 1, 1, 7, 19, 58) - self.assertEqual(zip_info.date_time, expected_utc) + with zipfile.ZipFile(TESTFN, "r") as zf: + zip_info = zf.getinfo("test_source_date_epoch.txt") + expected_utc = (2025, 1, 1, 7, 19, 58) + self.assertEqual(zip_info.date_time, expected_utc) + @without_source_date_epoch def test_write_without_source_date_epoch(self): - with os_helper.EnvironmentVarGuard() as env: - del env['SOURCE_DATE_EPOCH'] - - with zipfile.ZipFile(TESTFN, "w") as zf: - zf.writestr("test_no_source_date_epoch.txt", "Testing without SOURCE_DATE_EPOCH") + with zipfile.ZipFile(TESTFN, "w") as zf: + zf.writestr("test_no_source_date_epoch.txt", "Testing without SOURCE_DATE_EPOCH") - with zipfile.ZipFile(TESTFN, "r") as zf: - zip_info = zf.getinfo("test_no_source_date_epoch.txt") - self.assertTimestampAlmostEqual(time.localtime(), zip_info.date_time, tolerance=2) + with zipfile.ZipFile(TESTFN, "r") as zf: + zip_info = zf.getinfo("test_no_source_date_epoch.txt") + self.assertTimestampAlmostEqual(time.localtime(), zip_info.date_time, tolerance=2) def assertTimestampAlmostEqual(self, time1, time2, tolerance): import datetime @@ -4051,6 +4082,43 @@ def test_close_on_exception(self): except zipfile.BadZipFile: self.assertIsNone(zipfp2.fp, 'zipfp is not closed') + def test_garbage_collection(self): + # gh-81954: Warn if a writable zipfile is closed by GC. + with self.assertWarns(ResourceWarning): + zipfile.ZipFile(io.BytesIO(), "w") + gc_collect() + + # Only warn if there is possible data loss. + # Properly closed via context manager. + buf = io.BytesIO() + with zipfile.ZipFile(buf, "w") as zf: + zf.writestr("f.txt", b"data") + + with check_no_resource_warning(self): + # Read mode: No possible data loss. + zipfile.ZipFile(buf, "r") + + # Write with manual explicit close: No pending data. + zf = zipfile.ZipFile(io.BytesIO(), "w") + zf.writestr("f.txt", b"data") + zf.close() + del zf + + # ResourceWarning escalated to an error is reported as unraisable, + # and the archive is still closed. + buf = io.BytesIO() + zf = zipfile.ZipFile(buf, "w") + zf.writestr("f.txt", b"data") + with (warnings.catch_warnings(action="error", category=ResourceWarning), + catch_unraisable_exception() as cm): + del zf + gc_collect() + self.assertIs(cm.unraisable.exc_type, ResourceWarning) + + with zipfile.ZipFile(buf, "r") as zf: + self.assertEqual(zf.namelist(), ["f.txt"]) + self.assertEqual(zf.read("f.txt"), b"data") + def test_unsupported_version(self): # File has an extract_version of 120 data = (b'PK\x03\x04x\x00\x00\x00\x00\x00!p\xa1@\x00\x00\x00\x00\x00\x00' @@ -4241,6 +4309,20 @@ def test_is_zip_valid_file(self): self.assertTrue(zipfile.is_zipfile(fp)) self.assertEqual(fp.tell(), mid) + def test_is_zip_bad_central_directory_offset(self): + """Check that is_zipfile() rejects a central directory before the file.""" + fp = io.BytesIO() + with zipfile.ZipFile(fp, mode="w") as zipf: + zipf.writestr("foo.txt", b"O, for a Muse of Fire!") + data = bytearray(fp.getvalue()) + endrec = len(data) - zipfile.sizeEndCentDir + struct.pack_into("> 16, filemode) self.assertEqual(zi.external_attr & 0xFF, 0) # no MS-DOS flag @@ -4556,6 +4709,8 @@ def test_open_conflicting_handles(self): zipf.writestr('str', 'abcde') with self.assertRaises(ValueError): zipf.write(__file__, 'file') + with self.assertRaises(ValueError): + zipf.mkdir('directory') with self.assertRaises(ValueError): zipf.close() w1.write(msg2) @@ -4832,6 +4987,117 @@ def tearDown(self): unlink(TESTFN2) +class AbstractBoundedDecompressTests: + # ZipExtFile._read1() bounds the output of each decompress() call so that a + # small member declaring a large uncompressed size cannot expand into one + # unbounded read. + def test_read1_output_is_bounded(self): + buf = io.BytesIO() + with zipfile.ZipFile(buf, "w", compression=self.compression) as zf: + zf.writestr("big", b"\0" * (4 * 1024 * 1024)) + with zipfile.ZipFile(io.BytesIO(buf.getvalue())) as zf: + with zf.open("big") as f: + self.assertLessEqual(len(f._read1(100)), f.MIN_READ_SIZE) + + +class StoredBoundedDecompressTests(AbstractBoundedDecompressTests, + unittest.TestCase): + compression = zipfile.ZIP_STORED + + +@requires_zlib() +class DeflateBoundedDecompressTests(AbstractBoundedDecompressTests, + unittest.TestCase): + compression = zipfile.ZIP_DEFLATED + + +@requires_bz2() +class Bzip2BoundedDecompressTests(AbstractBoundedDecompressTests, + unittest.TestCase): + compression = zipfile.ZIP_BZIP2 + + +@requires_lzma() +class LzmaBoundedDecompressTests(AbstractBoundedDecompressTests, + unittest.TestCase): + compression = zipfile.ZIP_LZMA + + +@requires_zstd() +class ZstdBoundedDecompressTests(AbstractBoundedDecompressTests, + unittest.TestCase): + compression = zipfile.ZIP_ZSTANDARD + + +class MonkeypatchedDecompressorTests(unittest.TestCase): + # Some third-party projects monkey-patch _get_decompressor() to add + # additional compression schemes. This can break at any time as the + # internal compressor objects change. + # To protect users, we try to keep this case working. + # See also: GH-156002 and GH-113767. + COMPRESSION = 99 + + class Compressor: + """Compressor with only the original BZ2Compressor API""" + def compress(self, data): + return data.swapcase() + + def flush(self): + return b'' + + class Decompressor: + """Decompressor with only the 3.3+ BZ2Decompressor API""" + eof = False + + def decompress(self, data): + return data.swapcase() + + def setUp(self): + orig_check_compression = zipfile._check_compression + orig_get_compressor = zipfile._get_compressor + orig_get_decompressor = zipfile._get_decompressor + + def check_compression(compression): + if compression != self.COMPRESSION: + orig_check_compression(compression) + + def get_compressor(compress_type, compresslevel=None): + if compress_type == self.COMPRESSION: + return self.Compressor() + return orig_get_compressor(compress_type, compresslevel) + + def get_decompressor(compress_type): + if compress_type == self.COMPRESSION: + return self.Decompressor() + return orig_get_decompressor(compress_type) + + self.enterContext(mock.patch.object( + zipfile, '_check_compression', check_compression)) + self.enterContext(mock.patch.object( + zipfile, '_get_compressor', get_compressor)) + self.enterContext(mock.patch.object( + zipfile, '_get_decompressor', get_decompressor)) + + def test_roundtrip_monkeypatched_decompressor(self): + data = bytes(range(256)) * 8 + buf = io.BytesIO() + with zipfile.ZipFile(buf, "w", compression=self.COMPRESSION) as zf: + zf.writestr("member", data) + self.assertIn(data.swapcase(), buf.getvalue()) + with (ignore_warnings(category=DeprecationWarning, + message='.*two arguments.*'), + zipfile.ZipFile(io.BytesIO(buf.getvalue())) as zf): + self.assertEqual(zf.read("member"), data) + with zf.open("member") as f: + self.assertEqual(f.read(100), data[:100]) + self.assertEqual(f.read1(100), data[100:200]) + f.seek(-100, os.SEEK_END) + self.assertEqual(f.read(), data[-100:]) + # Rewinding past the read buffer re-creates the decompressor. + f.seek(0) + self.assertEqual(f.read(), data) + + class AbstractBadCrcTests: def test_testzip_with_bad_crc(self): """Tests that files with bad CRCs return their name from testzip.""" @@ -5412,14 +5678,14 @@ def test_write_dir(self): self.assertEqual(zinfo.external_attr, (mode << 16) | 0x10) zipf.write(dirpath, "y") zinfo = zipf.filelist[1] - self.assertTrue(zinfo.filename, "y/") + self.assertEqual(zinfo.filename, "y/") self.assertEqual(zinfo.external_attr, (mode << 16) | 0x10) with zipfile.ZipFile(TESTFN, "r") as zipf: zinfo = zipf.filelist[0] self.assertEndsWith(zinfo.filename, "/x/") self.assertEqual(zinfo.external_attr, (mode << 16) | 0x10) zinfo = zipf.filelist[1] - self.assertTrue(zinfo.filename, "y/") + self.assertEqual(zinfo.filename, "y/") self.assertEqual(zinfo.external_attr, (mode << 16) | 0x10) target = os.path.join(TESTFN2, "target") os.mkdir(target) @@ -5476,6 +5742,9 @@ def test_mkdir(self): zf.extractall(target) self.assertEqual(set(os.listdir(target)), {"directory", "directory2", "directory3", "directory4"}) + with self.assertRaises(ValueError): + zf.mkdir("closed") + def test_create_directory_with_write(self): with zipfile.ZipFile(TESTFN, "w") as zf: zf.writestr(zipfile.ZipInfo('directory/'), '') @@ -5503,10 +5772,10 @@ def test_root_folder_in_zipfile(self): the zip file, this is a strange behavior, but we should support it. """ in_memory_file = io.BytesIO() - zf = zipfile.ZipFile(in_memory_file, "w") - zf.mkdir('/') - zf.writestr('./a.txt', 'aaa') - zf.extractall(TESTFN2) + with zipfile.ZipFile(in_memory_file, "w") as zf: + zf.mkdir('/') + zf.writestr('./a.txt', 'aaa') + zf.extractall(TESTFN2) def tearDown(self): rmtree(TESTFN2) @@ -5798,17 +6067,18 @@ def test_add_comment(self): def test_cli_with_metadata_encoding(self): errmsg = "Non-conforming encodings not supported with -c." args = ["--metadata-encoding=shift_jis", "-c", "nonesuch", "nonesuch"] - with captured_stdout() as stdout: - with captured_stderr() as stderr: + with (captured_stdout() as stdout, + captured_stderr() as stderr, + save_restore_sys_path()): self.assertRaises(SystemExit, zipfile.main, args) self.assertEqual(stdout.getvalue(), "") self.assertIn(errmsg, stderr.getvalue()) - with captured_stdout() as stdout: + with captured_stdout() as stdout, save_restore_sys_path(): zipfile.main(["--metadata-encoding=shift_jis", "-t", TESTFN]) listing = stdout.getvalue() - with captured_stdout() as stdout: + with captured_stdout() as stdout, save_restore_sys_path(): zipfile.main(["--metadata-encoding=shift_jis", "-l", TESTFN]) listing = stdout.getvalue() for name in self.file_names: @@ -5827,7 +6097,9 @@ def test_cli_with_metadata_encoding_extract(self): except UnicodeEncodeError: self.skipTest(f'cannot encode file name {fn!a}') - zipfile.main(["--metadata-encoding=shift_jis", "-e", TESTFN, TESTFN2]) + with save_restore_sys_path(): + zipfile.main(["--metadata-encoding=shift_jis", "-e", + TESTFN, TESTFN2]) listing = os.listdir(TESTFN2) for name in self.file_names: self.assertIn(name, listing) diff --git a/Lib/test/test_zipfile64.py b/Lib/test/test_zipfile64.py index 7d802d59849ce1f..e13f064f2ac4fd4 100644 --- a/Lib/test/test_zipfile64.py +++ b/Lib/test/test_zipfile64.py @@ -17,6 +17,7 @@ import sys import unittest.mock as mock +from contextlib import contextmanager from tempfile import TemporaryFile from test.support import os_helper @@ -91,176 +92,133 @@ def tearDown(self): os_helper.unlink(TESTFN2) -class TestRepack(unittest.TestCase): - def setUp(self): - # Create test data. - line_gen = ("Test of zipfile line %d." % i for i in range(1000000)) - self.data = '\n'.join(line_gen).encode('ascii') - - # It will contain enough copies of self.data to reach about 8 GiB. - self.datacount = 8*1024**3 // len(self.data) +class TestRepacker(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.largefilename = 'largefile.txt' - # memory usage should not exceed 10 MiB - self.allowed_memory = 10*1024**2 + line_gen = ("Test of zipfile line %d." % i for i in range(1000000)) + cls.chunk = '\n'.join(line_gen).encode('ascii') + + # It will contain enough copies of cls.chunk to reach about 4.1 GiB. + cls.chunkcount = int(4.1*1024**3 / len(cls.chunk)) + + cls.filename = 'file.txt' + cls.lorem = b'Sed ut perspiciatis unde omnis iste natus error sit voluptatem' + + # Memory usage should not exceed 10 MiB during repacking. + # This empirical threshold ensures that the internal processing + # like signature scanning, compressed block end tracing, and + # data copying are properly buffered without loading the entire + # large file into memory. + cls.allowed_memory = 10*1024**2 + + @contextmanager + def assert_memory_usage(self, threshold): + tracemalloc.start() + try: + yield + finally: + current, peak = tracemalloc.get_traced_memory() + tracemalloc.stop() + self.assertLess(peak, threshold) def _write_large_file(self, fh): next_time = time.monotonic() + _PRINT_WORKING_MSG_INTERVAL - for num in range(self.datacount): - fh.write(self.data) + for num in range(self.chunkcount): + fh.write(self.chunk) # Print still working message since this test can be really slow if next_time <= time.monotonic(): next_time = time.monotonic() + _PRINT_WORKING_MSG_INTERVAL print(( ' writing %d of %d, be patient...' % - (num, self.datacount)), file=sys.__stdout__) + (num, self.chunkcount)), file=sys.__stdout__) sys.__stdout__.flush() def test_strip_removed_large_file(self): """Should move the physical data of a file positioned after a large removed file without causing a memory issue.""" - # Try the temp file. If we do TESTFN2, then it hogs - # gigabytes of disk space for the duration of the test. with TemporaryFile() as f: - tracemalloc.start() - self._test_strip_removed_large_file(f) - self.assertFalse(f.closed) - current, peak = tracemalloc.get_traced_memory() - tracemalloc.stop() - self.assertLess(peak, self.allowed_memory) - - def _test_strip_removed_large_file(self, f): - file = 'file.txt' - file1 = 'largefile.txt' - data = b'Sed ut perspiciatis unde omnis iste natus error sit voluptatem' - with zipfile.ZipFile(f, 'w') as zh: - with zh.open(file1, 'w', force_zip64=True) as fh: - self._write_large_file(fh) - zh.writestr(file, data) - - with zipfile.ZipFile(f, 'a') as zh: - zh.remove(file1) - zh.repack() - self.assertIsNone(zh.testzip()) + with zipfile.ZipFile(f, 'w') as zh: + with zh.open(self.largefilename, 'w', force_zip64=True) as fh: + self._write_large_file(fh) + zh.writestr(self.filename, self.lorem) + + with self.assert_memory_usage(self.allowed_memory), \ + zipfile.ZipFile(f, 'a') as zh: + zh.remove(self.largefilename) + zh.repack() + self.assertIsNone(zh.testzip()) def test_strip_removed_file_before_large_file(self): """Should move the physical data of a large file positioned after a removed file without causing a memory issue.""" - # Try the temp file. If we do TESTFN2, then it hogs - # gigabytes of disk space for the duration of the test. with TemporaryFile() as f: - tracemalloc.start() - self._test_strip_removed_file_before_large_file(f) - self.assertFalse(f.closed) - current, peak = tracemalloc.get_traced_memory() - tracemalloc.stop() - self.assertLess(peak, self.allowed_memory) - - def _test_strip_removed_file_before_large_file(self, f): - file = 'file.txt' - file1 = 'largefile.txt' - data = b'Sed ut perspiciatis unde omnis iste natus error sit voluptatem' - with zipfile.ZipFile(f, 'w') as zh: - zh.writestr(file, data) - with zh.open(file1, 'w', force_zip64=True) as fh: - self._write_large_file(fh) - - with zipfile.ZipFile(f, 'a') as zh: - zh.remove(file) - zh.repack() - self.assertIsNone(zh.testzip()) + with zipfile.ZipFile(f, 'w') as zh: + zh.writestr(self.filename, self.lorem) + with zh.open(self.largefilename, 'w', force_zip64=True) as fh: + self._write_large_file(fh) + + with self.assert_memory_usage(self.allowed_memory), \ + zipfile.ZipFile(f, 'a') as zh: + zh.remove(self.filename) + zh.repack() + self.assertIsNone(zh.testzip()) def test_strip_removed_large_file_with_dd(self): """Should scan for the data descriptor of a removed large file without causing a memory issue.""" - # Try the temp file. If we do TESTFN2, then it hogs - # gigabytes of disk space for the duration of the test. with TemporaryFile() as f: - tracemalloc.start() - self._test_strip_removed_large_file_with_dd(f) - self.assertFalse(f.closed) - current, peak = tracemalloc.get_traced_memory() - tracemalloc.stop() - self.assertLess(peak, self.allowed_memory) - - def _test_strip_removed_large_file_with_dd(self, f): - file = 'file.txt' - file1 = 'largefile.txt' - data = b'Sed ut perspiciatis unde omnis iste natus error sit voluptatem' - with zipfile.ZipFile(Unseekable(f), 'w') as zh: - with zh.open(file1, 'w', force_zip64=True) as fh: - self._write_large_file(fh) - zh.writestr(file, data) - - with zipfile.ZipFile(f, 'a') as zh: - zh.remove(file1) - zh.repack() - self.assertIsNone(zh.testzip()) + with zipfile.ZipFile(Unseekable(f), 'w') as zh: + with zh.open(self.largefilename, 'w', force_zip64=True) as fh: + self._write_large_file(fh) + zh.writestr(self.filename, self.lorem) + + with self.assert_memory_usage(self.allowed_memory), \ + zipfile.ZipFile(f, 'a') as zh: + zh.remove(self.largefilename) + zh.repack() + self.assertIsNone(zh.testzip()) def test_strip_removed_large_file_with_dd_no_sig(self): - """Should scan for the data descriptor (without signature) of a removed - large file without causing a memory issue.""" + """Should scan for the unsigned data descriptor of a removed large file + without causing a memory issue.""" # Reduce data scale for this test, as it's especially slow... - self.datacount = 30*1024**2 // len(self.data) - self.allowed_memory = 200*1024 + self.chunkcount = int(30*1024**2 / len(self.chunk)) - # Try the temp file. If we do TESTFN2, then it hogs - # gigabytes of disk space for the duration of the test. with TemporaryFile() as f: - tracemalloc.start() - self._test_strip_removed_large_file_with_dd_no_sig(f) - self.assertFalse(f.closed) - current, peak = tracemalloc.get_traced_memory() - tracemalloc.stop() - self.assertLess(peak, self.allowed_memory) - - def _test_strip_removed_large_file_with_dd_no_sig(self, f): - file = 'file.txt' - file1 = 'largefile.txt' - data = b'Sed ut perspiciatis unde omnis iste natus error sit voluptatem' - with mock.patch('zipfile.struct.pack', side_effect=struct_pack_no_dd_sig): - with zipfile.ZipFile(Unseekable(f), 'w') as zh: - with zh.open(file1, 'w', force_zip64=True) as fh: + with mock.patch('zipfile.struct.pack', side_effect=struct_pack_no_dd_sig), \ + zipfile.ZipFile(Unseekable(f), 'w') as zh: + with zh.open(self.largefilename, 'w', force_zip64=True) as fh: self._write_large_file(fh) - zh.writestr(file, data) + zh.writestr(self.filename, self.lorem) - with zipfile.ZipFile(f, 'a') as zh: - zh.remove(file1) - # strict_descriptor=False to scan the unsigned data descriptor - # (scanning is disabled under the strict_descriptor=True default) - zh.repack(strict_descriptor=False) - self.assertIsNone(zh.testzip()) + with self.assert_memory_usage(self.allowed_memory), \ + zipfile.ZipFile(f, 'a') as zh: + zh.remove(self.largefilename) + # strict_descriptor=False to scan the unsigned data descriptor + # (scanning is disabled under the strict_descriptor=True default) + zh.repack(strict_descriptor=False) + self.assertIsNone(zh.testzip()) @requires_zlib() def test_strip_removed_large_file_with_dd_no_sig_by_decompression(self): - """Should scan for the data descriptor (without signature) of a removed - large file without causing a memory issue.""" - # Try the temp file. If we do TESTFN2, then it hogs - # gigabytes of disk space for the duration of the test. + """Should scan for the unsigned data descriptor (via tracing compressed + block end) of a removed large file without causing a memory issue.""" with TemporaryFile() as f: - tracemalloc.start() - self._test_strip_removed_large_file_with_dd_no_sig_by_decompression( - f, zipfile.ZIP_DEFLATED) - self.assertFalse(f.closed) - current, peak = tracemalloc.get_traced_memory() - tracemalloc.stop() - self.assertLess(peak, self.allowed_memory) - - def _test_strip_removed_large_file_with_dd_no_sig_by_decompression(self, f, method): - file = 'file.txt' - file1 = 'largefile.txt' - data = b'Sed ut perspiciatis unde omnis iste natus error sit voluptatem' - with mock.patch('zipfile.struct.pack', side_effect=struct_pack_no_dd_sig): - with zipfile.ZipFile(Unseekable(f), 'w', compression=method) as zh: - with zh.open(file1, 'w', force_zip64=True) as fh: + with mock.patch('zipfile.struct.pack', side_effect=struct_pack_no_dd_sig), \ + zipfile.ZipFile(Unseekable(f), 'w', compression=zipfile.ZIP_DEFLATED) as zh: + with zh.open(self.largefilename, 'w', force_zip64=True) as fh: self._write_large_file(fh) - zh.writestr(file, data) - - with zipfile.ZipFile(f, 'a') as zh: - zh.remove(file1) - # strict_descriptor=False to detect the unsigned data descriptor - # (scanning is disabled under the strict_descriptor=True default) - zh.repack(strict_descriptor=False) - self.assertIsNone(zh.testzip()) + zh.writestr(self.filename, self.lorem) + + with self.assert_memory_usage(self.allowed_memory), \ + zipfile.ZipFile(f, 'a') as zh: + zh.remove(self.largefilename) + # strict_descriptor=False to detect the unsigned data descriptor + # (scanning is disabled under the strict_descriptor=True default) + zh.repack(strict_descriptor=False) + self.assertIsNone(zh.testzip()) class OtherTests(unittest.TestCase): diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py index 76cd85709a63af8..94875d7153f9c5b 100644 --- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -9,6 +9,7 @@ import time import unittest import unittest.mock +import warnings from test import support from test.support import import_helper @@ -229,6 +230,81 @@ def testPy(self): files = {TESTMOD + ".py": test_src} self.doTest(".py", files, TESTMOD) + def test_syntax_warning(self): + files = {TESTMOD + ".py": "x = 1 is 1\n"} + self.makeZip(files) + zi = zipimport.zipimporter(TEMP_ZIP) + + with warnings.catch_warnings(record=True) as caught: + warnings.simplefilter("always", SyntaxWarning) + spec = zi.find_spec(TESTMOD) + self.assertIsNotNone(spec) + self.assertEqual(caught, []) + + mod = importlib.util.module_from_spec(spec) + spec.loader.exec_module(mod) + + self.assertEqual(len(caught), 1) + self.assertIsInstance(caught[0].message, SyntaxWarning) + + def test_syntax_error_defers_to_exec(self): + files = {TESTMOD + ".py": "x =\n"} + self.makeZip(files) + zi = zipimport.zipimporter(TEMP_ZIP) + expected_path = os.path.join(TEMP_ZIP, TESTMOD + ".py") + + spec = zi.find_spec(TESTMOD) + self.assertIsNotNone(spec) + self.assertEqual(spec.origin, expected_path) + self.assertEqual(zi.get_filename(TESTMOD), expected_path) + + mod = importlib.util.module_from_spec(spec) + with self.assertRaises(SyntaxError): + spec.loader.exec_module(mod) + + def test_get_filename_no_warnings(self): + files = {TESTMOD + ".py": "x = 1 is 1\n"} + self.makeZip(files) + zi = zipimport.zipimporter(TEMP_ZIP) + + with warnings.catch_warnings(record=True) as caught: + warnings.simplefilter("always", SyntaxWarning) + zi.get_filename(TESTMOD) + + self.assertEqual(caught, []) + + def test_syntax_error_in_source_with_valid_pyc(self): + bad_src = "x =\n" + files = {TESTMOD + ".py": bad_src, + TESTMOD + pyc_ext: make_pyc(test_co, NOW, len(bad_src))} + self.makeZip(files) + zi = zipimport.zipimporter(TEMP_ZIP) + expected_path = os.path.join(TEMP_ZIP, TESTMOD + pyc_ext) + + spec = zi.find_spec(TESTMOD) + self.assertIsNotNone(spec) + self.assertEqual(spec.origin, expected_path) + + mod = importlib.util.module_from_spec(spec) + spec.loader.exec_module(mod) + self.assertEqual(mod.get_file(), expected_path) + + def test_syntax_error_in_package_init_no_fallthrough(self): + packdir = TESTPACK + os.sep + files = {packdir + "__init__.py": "x =\n", + TESTPACK + ".py": test_src} + self.makeZip(files) + zi = zipimport.zipimporter(TEMP_ZIP) + expected_path = os.path.join(TEMP_ZIP, TESTPACK, "__init__.py") + + spec = zi.find_spec(TESTPACK) + self.assertIsNotNone(spec) + self.assertEqual(spec.origin, expected_path) + + mod = importlib.util.module_from_spec(spec) + with self.assertRaises(SyntaxError): + spec.loader.exec_module(mod) + def testPyc(self): files = {TESTMOD + pyc_ext: test_pyc} self.doTest(pyc_ext, files, TESTMOD) @@ -1026,6 +1102,62 @@ class DeflateCompressedZipImportTestCase(UncompressedZipImportTestCase): class ZStdCompressedZipImportTestCase(UncompressedZipImportTestCase): compression = ZIP_ZSTANDARD + def test_concatenated_frames(self): + from compression import zstd + import zipfile + + class ConcatenatedFrameCompressor: + def compress(self, data): + return b"".join(zstd.compress(bytes([byte])) for byte in data) + + def flush(self): + return b"" + + with unittest.mock.patch.object( + zipfile, + "_get_compressor", + return_value=ConcatenatedFrameCompressor(), + ): + self.doTest(".py", {TESTMOD + ".py": test_src}, TESTMOD) + + def test_concatenated_frames_linear_input(self): + from compression import zstd + + frame_count = 100 + frame = zstd.compress(b"x") + compressed = frame * frame_count + input_sizes = [] + decompressor_class = zipimport._get_zstd_decompressor_class() + + class RecordingDecompressor: + def __init__(self): + self._decompressor = decompressor_class() + + def __getattr__(self, name): + return getattr(self._decompressor, name) + + def decompress(self, data, max_length=-1): + input_sizes.append(memoryview(data).nbytes) + return self._decompressor.decompress(data, max_length) + + with unittest.mock.patch.object( + zipimport, "_zstd_decompressor_class", RecordingDecompressor + ): + self.assertEqual( + zipimport._zstd_decompress(compressed), b"x" * frame_count + ) + + self.assertEqual(sum(input_sizes), len(compressed)) + + def test_truncated_frame(self): + from compression import zstd + + compressed = zstd.compress(b"x") + for data in (b"", compressed[:-1]): + with self.subTest(data=data): + with self.assertRaises(zipimport.ZipImportError): + zipimport._zstd_decompress(data) + class BadFileZipImportTestCase(unittest.TestCase): def assertZipFailure(self, filename): @@ -1074,6 +1206,24 @@ def testNotZipFile(self): fp.close() self.assertZipFailure(TESTMOD) + def testInvalidUTF8FileName(self): + # A UTF-8-flagged file name that is not valid UTF-8 raises ZipImportError. + UTF8_FLAG = 0x800 + name = b'\xff\xfe\xff' + cdh = b'PK\x01\x02' + struct.pack( + '= (1, 2, 5, 3): + if zlib.zlib_version_info >= (1, 2, 5, 3): sync_opt.append('Z_BLOCK') sync_opt = [getattr(zlib, opt) for opt in sync_opt @@ -719,6 +782,20 @@ def test_decompress_eof_incomplete_stream(self): dco.flush() self.assertFalse(dco.eof) + def test_decompress_flush_corrupt_stream(self): + x = b'x\x9cK\xcb\xcf\x07\x00\x02\x82\x01E' # 'foo' + corrupt = x[:-1] + b'\x00' + dco = zlib.decompressobj() + self.assertEqual(dco.decompress(corrupt, 1), b'f') + self.assertRaises(zlib.error, dco.flush) + + def test_decompress_flush_twice(self): + x = b'x\x9cK\xcb\xcf\x07\x00\x02\x82\x01E' # 'foo' + dco = zlib.decompressobj() + self.assertEqual(dco.decompress(x), b'foo') + self.assertEqual(dco.flush(), b'') + self.assertEqual(dco.flush(), b'') + def test_decompress_unused_data(self): # Repeated calls to decompress() after EOF should accumulate data in # dco.unused_data, instead of just storing the arg to the last call. @@ -745,6 +822,18 @@ def test_decompress_unused_data(self): self.assertEqual(dco.unconsumed_tail, b'') self.assertEqual(dco.unused_data, remainder) + def test_decompress_unconsumed_tail_after_eof(self): + source = b'abcdefghijklmnopqrstuvwxyz' + remainder = b'0123456789' + dco = zlib.decompressobj() + data = dco.decompress(zlib.compress(source) + remainder, 1) + data += dco.decompress(dco.unconsumed_tail) + + self.assertTrue(dco.eof) + self.assertEqual(data, source) + self.assertEqual(dco.unconsumed_tail, b'') + self.assertEqual(dco.unused_data, remainder) + # issue27164 def test_decompress_raw_with_dictionary(self): zdict = b'abcdefghijklmnopqrstuvwxyz' @@ -918,7 +1007,7 @@ def test_large_unconsumed_tail(self, size): def test_wbits(self): # wbits=0 only supported since zlib v1.2.3.5 - supports_wbits_0 = ZLIB_RUNTIME_VERSION_TUPLE >= (1, 2, 3, 5) + supports_wbits_0 = zlib.zlib_version_info >= (1, 2, 3, 5) co = zlib.compressobj(level=1, wbits=15) zlib15 = co.compress(HAMLET_SCENE) + co.flush() @@ -1090,7 +1179,7 @@ def testEOFError(self): self.assertRaises(EOFError, zlibd.decompress, b"") @support.skip_if_pgo_task - @bigmemtest(size=_4G + 100, memuse=3.3) + @bigmemtest(size=_4G + 100, memuse=4.5) def testDecompress4G(self, size): # "Test zlib._ZlibDecompressor.decompress() with >4GiB input" blocksize = min(10 * 1024 * 1024, size) @@ -1223,13 +1312,10 @@ def __index__(self): class TestModule(unittest.TestCase): - def test_deprecated__version__(self): - with self.assertWarnsRegex( - DeprecationWarning, - "'__version__' is deprecated and slated for removal in Python 3.20", - ) as cm: - getattr(zlib, "__version__") - self.assertEqual(cm.filename, __file__) + def test_deprecated_module_attributes(self): + support.check_deprecated_module_attributes( + self, zlib, "__version__", remove=(3, 20), + ) if __name__ == "__main__": diff --git a/Lib/test/test_zoneinfo/test_zoneinfo.py b/Lib/test/test_zoneinfo/test_zoneinfo.py index a10f434eb27590d..6656d7c1dc2cd67 100644 --- a/Lib/test/test_zoneinfo/test_zoneinfo.py +++ b/Lib/test/test_zoneinfo/test_zoneinfo.py @@ -6,16 +6,20 @@ import importlib.metadata import io import json +import ntpath import os import pathlib import pickle import re import shutil import struct +import sys import tempfile +import types import unittest from datetime import date, datetime, time, timedelta, timezone from functools import cached_property +from unittest import mock from test.support import MISSING_C_DOCSTRINGS from test.support.os_helper import EnvironmentVarGuard, FakePath @@ -316,6 +320,18 @@ def test_unambiguous(self): self.assertEqual(dt.utcoffset(), offset.utcoffset, dt) self.assertEqual(dt.dst(), offset.dst, dt) + def test_datetime_subclass_negative_components(self): + class MinusOneDateTime(datetime): + hour = minute = second = -1 + + zi = self.zone_from_key("UTC") + dt = MinusOneDateTime(2024, 1, 1, tzinfo=zi) + + self.assertEqual(dt.utcoffset(), ZERO) + self.assertEqual(dt.dst(), ZERO) + self.assertEqual(dt.tzname(), "UTC") + self.assertEqual(zi.fromutc(dt), datetime(2024, 1, 1, tzinfo=zi)) + def test_folds_and_gaps(self): test_cases = [] for key in self.zones(): @@ -630,6 +646,26 @@ def test_one_transition(self): dt_utc_actual = dt_local.astimezone(timezone.utc) self.assertEqual(dt_utc_actual, dt_utc) + def test_one_transition_fold(self): + GMT = ZoneOffset("-00", ZERO) + N03 = ZoneOffset("-03", -timedelta(hours=3)) + + transitions = [ + ZoneTransition(datetime(1976, 12, 1), GMT, N03), + ] + + after = "<-03>3" + + zf = self.construct_zone(transitions, after) + zi = self.klass.from_file(zf) + + dt_utc = datetime(1976, 12, 1, 1, tzinfo=timezone.utc) + dt_local = dt_utc.astimezone(zi) + + self.assertEqual(dt_local.fold, 1) + self.assertEqual(dt_local.utcoffset(), N03.utcoffset) + self.assertEqual(dt_local.astimezone(timezone.utc), dt_utc) + def test_one_zone_dst(self): DST = ZoneOffset("DST", ONE_H, ONE_H) transitions = [ @@ -759,6 +795,34 @@ def test_invalid_transition_index(self): with self.assertRaises(ValueError): self.klass.from_file(f) + def test_invalid_charcnt(self): + # 128 local time types whose abbreviations are the suffixes of a + # single long abbreviation spanning the entire block: every index + # would get its own copy of most of the block. + types = b"".join(struct.pack(">lbb", 3600, 0, i) for i in range(128)) + chars = b"A" * 65535 + b"\x00" + + # With a negative charcnt the block would be the rest of the file + for charcnt in (len(chars), -1): + with self.subTest(charcnt=charcnt): + header = b"TZif" + b"\x00" * 16 + header += struct.pack(">6l", 0, 0, 0, 0, 128, charcnt) + f = io.BytesIO(header + types + chars) + + with self.assertRaises(ValueError): + self.klass.from_file(f) + + def test_abbreviation_index_above_127(self): + chars = b"X" * 129 + b"\x00" + b"ABC\x00" + header = b"TZif" + b"\x00" * 16 + header += struct.pack(">6l", 0, 0, 0, 0, 1, len(chars)) + types = struct.pack(">lbB", 3600, 0, 130) + zi = self.klass.from_file(io.BytesIO(header + types + chars)) + + dt = datetime(2026, 1, 1, tzinfo=zi) + self.assertEqual(dt.tzname(), "ABC") + self.assertEqual(dt.utcoffset(), ONE_H) + def test_transition_lookahead_out_of_bounds(self): STD = ZoneOffset("STD", ZERO) DST = ZoneOffset("DST", ONE_H, ONE_H) @@ -1480,6 +1544,33 @@ def _add(): (datetime(2020, 12, 31, 23, 59, 59, 999999), AAA, NORMAL), ) + @call + def _add(): + # Julian days 58, 59 and 60 always mean February 27, February 28 + # and March 1, including in leap years. + AAA = ZoneOffset("AAA", ZERO) + BBB = ZoneOffset("BBB", ONE_H, ONE_H) + + for start, end, start_date, end_date in ( + (58, 59, (2, 27), (2, 28)), + (59, 60, (2, 28), (3, 1)), + ): + tzstr = f"AAA0BBB,J{start}/12,J{end}/12" + cases[tzstr] = [] + for year in (2019, 2020, 2000, 2100): + start_dt = datetime(year, *start_date, 12) + end_dt = datetime(year, *end_date, 12) + cases[tzstr].extend(( + (start_dt - timedelta(seconds=1), AAA, NORMAL), + (start_dt, AAA, GAP), + (start_dt.replace(fold=1), BBB, GAP), + (start_dt + ONE_H, BBB, NORMAL), + (end_dt - ONE_H - timedelta(seconds=1), BBB, NORMAL), + (end_dt - ONE_H, BBB, FOLD), + ((end_dt - ONE_H).replace(fold=1), AAA, FOLD), + (end_dt, AAA, NORMAL), + )) + @call def _add(): # Taken from America/Godthab, this rule has a transition on the @@ -1632,6 +1723,13 @@ def __eq__(self, other): except CustomError: pass + def test_clear_cache_non_string_keys(self): + la0 = self.klass("America/Los_Angeles") + self.klass.clear_cache(only_keys=[None, 1]) + la1 = self.klass("America/Los_Angeles") + + self.assertIs(la0, la1) + def test_weak_cache_descriptor_use_after_free(self): class BombDescriptor: def __get__(self, obj, owner): @@ -1656,6 +1754,70 @@ class EvilZoneInfo(self.klass): class CZoneInfoCacheTest(ZoneInfoCacheTest): module = c_zoneinfo + def test_strong_cache_path_like_key(self): + # A non-str key is matched by identity, and comparing it against a + # str key must not raise TypeError. + class Key: + def __fspath__(self): + return "UTC" + + def __len__(self): + return 3 + + def split(self, sep): + return ["UTC"] + + key = Key() + original = self.klass(key) + self.assertIs(self.klass(key), original) + self.assertIsNot(self.klass("UTC"), original) + self.klass.clear_cache(only_keys=(key,)) + self.assertIsNot(self.klass(key), original) + + def test_strong_cache_str_subclass(self): + class Stringy(str): + def __eq__(self, other): + raise CustomError + + __hash__ = str.__hash__ + + for cached_type, lookup_type in ((str, Stringy), (Stringy, str), + (Stringy, Stringy)): + with self.subTest(cached_type=cached_type, lookup_type=lookup_type): + self.klass.clear_cache() + original = self.klass(cached_type("America/Los_Angeles")) + self.assertIs( + self.klass(lookup_type("America/Los_Angeles")), original + ) + + def test_strong_cache_reentrant_clear(self): + self._test_strong_cache_reentrant_clear("lookup") + + def test_strong_cache_reentrant_clear_only_keys(self): + self._test_strong_cache_reentrant_clear("clear") + + def _test_strong_cache_reentrant_clear(self, operation): + klass = self.klass + + class Stringy(str): + cleared = False + + def __eq__(self, other): + if not self.cleared: + self.cleared = True + klass.clear_cache(only_keys=(self,)) + return super().__eq__(other) + + __hash__ = str.__hash__ + + original = klass(Stringy("America/Los_Angeles")) + key = Stringy("America/Los_Angeles") + if operation == "lookup": + self.assertIs(klass(key), original) + else: + klass.clear_cache(only_keys=(key,)) + self.assertIsNot(klass("America/Los_Angeles"), original) + def test_inconsistent_weak_cache_get(self): class Cache: def get(self, key, default=None): @@ -1957,6 +2119,38 @@ def test_tzpath_type_error(self): with self.assertRaises(TypeError): self.module.reset_tzpath(bad_value) + def test_validate_key_windows_paths(self): + # Check the key validation with Windows path rules on every platform. + tzpath = self.module._tzpath + base = ntpath.normpath(ntpath.join("_", "_"))[:-1] + fake_os = types.SimpleNamespace(path=ntpath) + + good_keys = [ + "UTC", + "America/New_York", + "America/Argentina/Buenos_Aires", + "Etc/GMT+1", + ] + bad_keys = [ + "C:\\Windows\\win.ini", + "America/C:\\Windows\\win.ini", # Drive in a component + "America/C:/Windows/win.ini", + "America/D:secret", # Drive-relative component + "America/Argentina/D:secret", + "America/\\Windows\\win.ini", # Rooted component + "America/\\\\server\\share\\file", # UNC component + ] + + with mock.patch.object(tzpath, "os", fake_os): + for key in good_keys: + with self.subTest(key=key): + tzpath._validate_tzfile_path(key, _base=base) + + for key in bad_keys: + with self.subTest(key=key): + with self.assertRaises(ValueError): + tzpath._validate_tzfile_path(key, _base=base) + def test_tzpath_attribute(self): tzpath_0 = [f"{DRIVE}/one", f"{DRIVE}/two"] tzpath_1 = [f"{DRIVE}/three"] @@ -2142,6 +2336,8 @@ def test_pydatetime(self): PYTHONTZPATH=str(ZONEINFO_DATA.tzpath)) +@unittest.skipIf(sys.modules.get("_zoneinfo") is None, + "_zoneinfo C module not available") class ExtensionBuiltTest(unittest.TestCase): """Smoke test to ensure that the C and Python extensions are both tested. diff --git a/Lib/test/test_zstd.py b/Lib/test/test_zstd.py index 9225c42e0e711aa..0763ba31737a4ca 100644 --- a/Lib/test/test_zstd.py +++ b/Lib/test/test_zstd.py @@ -7,9 +7,12 @@ import os import unittest import tempfile +import textwrap import threading +from test import support from test.support.import_helper import import_module +from test.support.script_helper import assert_python_ok from test.support import threading_helper from test.support import _1M @@ -24,8 +27,6 @@ ZstdDecompressor, ZstdDict, ZstdError, - zstd_version, - zstd_version_info, COMPRESSION_LEVEL_DEFAULT, get_frame_info, get_frame_size, @@ -133,9 +134,33 @@ def setUpModule(): class FunctionsTestCase(unittest.TestCase): - def test_version(self): - s = ".".join((str(i) for i in zstd_version_info)) - self.assertEqual(s, zstd_version) + def _test_zstd_version(self, v, string): + self.assertIsInstance(v[:], tuple) + self.assertEqual(len(v), 3) + self.assertIsInstance(v[0], int) + self.assertIsInstance(v[1], int) + self.assertIsInstance(v[2], int) + self.assertIsInstance(v.major, int) + self.assertIsInstance(v.minor, int) + self.assertIsInstance(v.patch, int) + self.assertEqual(v[0], v.major) + self.assertEqual(v[1], v.minor) + self.assertEqual(v[2], v.patch) + self.assertGreaterEqual(v.major, 0) + self.assertGreaterEqual(v.minor, 0) + self.assertGreaterEqual(v.patch, 0) + + self.assertEqual(string, '%d.%d.%d' % v) + + def test_zstd_version(self): + if support.verbose: + print(f'ZSTD_VERSION = {zstd.ZSTD_VERSION}', flush=True) + print(f'zstd_version = {zstd.zstd_version}', flush=True) + print(f'ZSTD_VERSION_INFO = {zstd.ZSTD_VERSION_INFO}', flush=True) + print(f'zstd_version_info = {zstd.zstd_version_info}', flush=True) + self._test_zstd_version(zstd.ZSTD_VERSION_INFO, zstd.ZSTD_VERSION) + self._test_zstd_version(zstd.zstd_version_info, zstd.zstd_version) + self.assertEqual(zstd.ZSTD_VERSION_INFO[0], zstd.zstd_version_info[0]) def test_compressionLevel_values(self): min, max = CompressionParameter.compression_level.bounds() @@ -188,6 +213,52 @@ def test_decompress_2x130_1K(self): dat = decompress(DAT_130K_C + DAT_130K_C) self.assertEqual(len(dat), 2 * _130_1K) + def test_decompress_multi_frames(self): + big = random.randbytes(100_000) + frames = [b"a" * 100, b"", big, b"b" * 100, big] + expected = b"".join(frames) + dat = b"".join(map(compress, frames)) + self.assertEqual(decompress(dat), expected) + self.assertEqual(decompress(bytearray(dat)), expected) + self.assertEqual(decompress(memoryview(dat)), expected) + with self.assertRaisesRegex(ZstdError, "Compressed data ended before"): + decompress(dat[:-50_000]) + with self.assertRaisesRegex(ZstdError, "Unknown frame descriptor"): + decompress(dat + b"junk") + + def test_decompress_error_releases_buffer(self): + # The argument can be resized while the exception is handled. + for dat in COMPRESSED_100_PLUS_32KB[:-10], b"junk" * 10: + with self.subTest(dat=dat[:10]): + dat = bytearray(dat) + try: + decompress(dat) + except ZstdError: + dat += b"more" + else: + self.fail("no exception") + + def test_decompress_many_frames(self): + # The amount of data passed to the decompressors should grow + # linearly with the number of frames. + class Decompressor: + def __init__(self, *args, **kwargs): + self.decomp = ZstdDecompressor(*args, **kwargs) + def __getattr__(self, name): + return getattr(self.decomp, name) + def decompress(self, data): + nonlocal fed + fed += len(data) + return self.decomp.decompress(data) + dat = compress(b"") + with support.swap_attr(zstd, "ZstdDecompressor", Decompressor): + fed = 0 + self.assertEqual(decompress(dat * 1000), b"") + fed1 = fed + fed = 0 + self.assertEqual(decompress(dat * 2000), b"") + self.assertLess(fed, fed1 * 3) + class CompressorTestCase(unittest.TestCase): @@ -346,6 +417,58 @@ def test_zstd_multithread_compress(self): with ZstdFile(io.BytesIO(), 'w', options=options) as f: f.write(b) + @unittest.skipIf(not SUPPORT_MULTITHREADING, + "zstd build doesn't support multi-threaded compression") + def test_free_busy_multithread_compressor_with_dict(self): + # A compressor can be freed while a worker thread is still + # compressing with a dictionary that the compression context owns. + # Whether a failure is detected depends on the memory allocator, + # so use a fresh process for each case. + code = textwrap.dedent(""" + import gc, random, sys + from compression.zstd import (CompressionParameter, + ZstdCompressor, ZstdDict) + + job_size = 1 << 20 + zd = ZstdDict(random.randbytes(1 << 10) * (1 << 10), is_raw=True) + options = {CompressionParameter.compression_level: 10, + CompressionParameter.nb_workers: 1, + CompressionParameter.job_size: job_size} + c = ZstdCompressor(options=options, zstd_dict=zd) + # Returns while the worker thread is compressing the first job. + c.compress(random.randbytes(1 << 10) * ((job_size >> 10) + 64)) + if sys.argv[1] == 'error': + # A failed call does not wait for the worker thread either. + import _testcapi + _testcapi.set_nomemory(0) + try: + c.compress(b'x') + except MemoryError: + pass + finally: + _testcapi.remove_mem_hooks() + if sys.argv[1] == 'gc': + # The garbage collector clears the compressor before + # deallocating it. + cycle = [c] + cycle.append(cycle) + del c, cycle + gc.collect() + elif sys.argv[1] != 'exit': + del c + # Otherwise the compressor is freed at interpreter exit. + """) + cases = ['del', 'gc', 'exit'] + try: + import _testcapi # noqa: F401 + except ImportError: + pass + else: + cases.append('error') + for case in cases: + with self.subTest(case=case): + assert_python_ok('-c', code, case) + def test_compress_flushblock(self): point = len(THIS_FILE_BYTES) // 2 @@ -1548,6 +1671,42 @@ def test_len(self): self.assertEqual(len(TRAINED_DICT), len(TRAINED_DICT.dict_content)) self.assertIn(str(len(TRAINED_DICT)), str(TRAINED_DICT)) + @unittest.skipUnless(SUPPORT_MULTITHREADING, + "zstd build doesn't support multi-threaded compression") + @support.requires_subprocess() + def test_collect_cycle_with_busy_compressor(self): + # The dictionary must outlive the compression context when both are + # collected by the garbage collector while a worker thread is still + # using the dictionary. Whether the failure is detected depends on + # the memory allocator, so use a fresh process for each case. + code = textwrap.dedent(""" + import gc, random, sys + from compression.zstd import (CompressionParameter, + ZstdCompressor, ZstdDict) + + class Cycle: + pass + + job_size = 1 << 20 + content = random.randbytes(1 << 10) * (1 << 8) + zd = ZstdDict(content, is_raw=True) + options = {CompressionParameter.compression_level: 10, + CompressionParameter.nb_workers: 1, + CompressionParameter.job_size: job_size} + c = ZstdCompressor(options=options, + zstd_dict=getattr(zd, sys.argv[1])) + cycle = Cycle() + cycle.cycle = cycle + cycle.compressor = c + # Returns while the worker thread is compressing the first job. + c.compress(random.randbytes(1 << 10) * ((job_size >> 10) + 64)) + del zd, c, cycle + gc.collect() + """) + for attr in 'as_digested_dict', 'as_prefix': + with self.subTest(attr=attr): + assert_python_ok('-c', code, attr) + class FileTestCase(unittest.TestCase): def setUp(self): self.DECOMPRESSED_42 = b'a'*42 diff --git a/Lib/test/translationdata/argparse/msgids.txt b/Lib/test/translationdata/argparse/msgids.txt index ae89ac74726ecfc..8a2305b89a56672 100644 --- a/Lib/test/translationdata/argparse/msgids.txt +++ b/Lib/test/translationdata/argparse/msgids.txt @@ -18,7 +18,7 @@ invalid %(type)s value: %(value)r invalid choice: %(value)r (choose from %(choices)s) invalid choice: %(value)r, maybe you meant %(closest)r? (choose from %(choices)s) not allowed with argument %s -one of the arguments %s is required +one of the following arguments is required: %s option '%(option)s' is deprecated options positional arguments diff --git a/Lib/test/wheeldata/setuptools-79.0.1-py3-none-any.whl b/Lib/test/wheeldata/setuptools-79.0.1-py3-none-any.whl deleted file mode 100644 index 3eb896915897fb7..000000000000000 Binary files a/Lib/test/wheeldata/setuptools-79.0.1-py3-none-any.whl and /dev/null differ diff --git a/Lib/test/wheeldata/setuptools-84.2.1-py3-none-any.whl b/Lib/test/wheeldata/setuptools-84.2.1-py3-none-any.whl new file mode 100644 index 000000000000000..f708be8904f2d5e Binary files /dev/null and b/Lib/test/wheeldata/setuptools-84.2.1-py3-none-any.whl differ diff --git a/Lib/test/win_console_handler.py b/Lib/test/win_console_handler.py index e7779b9363503b4..a1c7c42c109330b 100644 --- a/Lib/test/win_console_handler.py +++ b/Lib/test/win_console_handler.py @@ -15,7 +15,7 @@ import sys # Function prototype for the handler function. Returns BOOL, takes a DWORD. -HandlerRoutine = WINFUNCTYPE(wintypes.BOOL, wintypes.DWORD) +HANDLER_ROUTINE = WINFUNCTYPE(wintypes.BOOL, wintypes.DWORD) def _ctrl_handler(sig): """Handle a sig event and return 0 to terminate the process""" @@ -27,12 +27,13 @@ def _ctrl_handler(sig): print("UNKNOWN EVENT") return 0 -ctrl_handler = HandlerRoutine(_ctrl_handler) +ctrl_handler = HANDLER_ROUTINE(_ctrl_handler) -SetConsoleCtrlHandler = ctypes.windll.kernel32.SetConsoleCtrlHandler -SetConsoleCtrlHandler.argtypes = (HandlerRoutine, wintypes.BOOL) -SetConsoleCtrlHandler.restype = wintypes.BOOL +@ctypes.util.wrap_dll_function(ctypes.windll.kernel32) +def SetConsoleCtrlHandler(HandlerRoutine: HANDLER_ROUTINE, + Add: wintypes.BOOL) -> wintypes.BOOL: + pass if __name__ == "__main__": # Add our console control handling function with value 1 diff --git a/Lib/threading.py b/Lib/threading.py index abac31e25886fae..507d40a1baa275f 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -363,10 +363,11 @@ def wait(self, timeout=None): waiter.acquire() gotit = True else: - if timeout > 0: - gotit = waiter.acquire(True, timeout) - else: + if timeout <= 0: gotit = waiter.acquire(False) + else: + # A NaN timeout is rejected by acquire(). + gotit = waiter.acquire(True, timeout) return gotit finally: self._acquire_restore(saved_state) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index dde4accecf61ba4..8147b2898139710 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -170,6 +170,9 @@ def _parse_version(version): releaselevel = {'a': 'alpha', 'b': 'beta'}[releaselevel] return _VersionInfoType(major, minor, micro, releaselevel, serial) +TCL_VERSION_INFO = _parse_version(_tkinter.TCL_PATCH_LEVEL) +TK_VERSION_INFO = _parse_version(_tkinter.TK_PATCH_LEVEL) + @enum._simple_enum(enum.StrEnum) class EventType: @@ -818,6 +821,25 @@ def tk_inactive(self, reset=False, *, displayof=0): else: return self.tk.getint(self.tk.call(args)) + def tk_check_screenreader(self): + """Return whether a screen reader is currently running. + + Requires Tk 9.1 or newer.""" + return self.tk.getboolean(self.tk.call( + 'tk', 'accessible', 'check_screenreader')) + + @property + def accessible(self): + """The accessible attributes of the widget, as an Accessible + object. + + Requires Tk 9.1 or newer.""" + try: + return self._accessible_object + except AttributeError: + self._accessible_object = Accessible(self) + return self._accessible_object + def wait_variable(self, name): """Wait until the variable is modified. @@ -2307,6 +2329,68 @@ def yview_scroll(self, number, what): self.tk.call(self._w, 'yview', 'scroll', number, what) +def _accessible_attribute(name): + """Internal function. Create an Accessible attribute property.""" + def getter(self): + widget = self._widget + return widget.tk.call('tk', 'accessible', 'get_acc_' + name, + widget._w) + def setter(self, value): + widget = self._widget + widget.tk.call('tk', 'accessible', 'set_acc_' + name, + widget._w, value) + return property(getter, setter, + doc=f'The accessible {name} of the widget.') + + +class Accessible: + """The accessible attributes of a widget. + + Returned by the accessible property of a widget. The attributes + are exposed to assistive technologies such as screen readers. + Requires Tk 9.1 or newer. + + If no assistive technology is active when the application starts, + setting an attribute has no effect and reading it returns 0. + Reading an attribute that has not been set raises TclError. + A widget must have a role before other attributes can be used. + """ + + def __init__(self, widget): + self._widget = widget + + def __repr__(self): + return f'' + + role = _accessible_attribute('role') + name = _accessible_attribute('name') + description = _accessible_attribute('description') + value = _accessible_attribute('value') + state = _accessible_attribute('state') + action = _accessible_attribute('action') + help = _accessible_attribute('help') + + def add_object(self): + """Register the widget with the platform accessibility API.""" + widget = self._widget + widget.tk.call('tk', 'accessible', 'add_acc_object', widget._w) + + def emit_selection_change(self): + """Notify the platform accessibility API that the selection + in the widget has changed.""" + widget = self._widget + widget.tk.call('tk', 'accessible', 'emit_selection_change', + widget._w) + + def emit_focus_change(self): + """Notify the platform accessibility API that the widget has + received focus. + + Not available on macOS.""" + widget = self._widget + widget.tk.call('tk', 'accessible', 'emit_focus_change', widget._w) + + class Wm: """Provides functions for the communication with the window manager.""" @@ -2352,7 +2436,7 @@ def wm_attributes(self, *args, return_python_dict=False, **kwargs): # TODO: deprecate return self.tk.call('wm', 'attributes', self._w, *args) elif args: - raise TypeError('wm_attribute() options have been specified as ' + raise TypeError('wm_attributes() options have been specified as ' 'positional and keyword arguments') else: self.tk.call('wm', 'attributes', self._w, *self._options(kwargs)) diff --git a/Lib/tkinter/constants.py b/Lib/tkinter/constants.py index 63eee33d24d6c7e..dcc326673b51744 100644 --- a/Lib/tkinter/constants.py +++ b/Lib/tkinter/constants.py @@ -18,6 +18,16 @@ NSEW='nsew' CENTER='center' +# -labelanchor, in addition to the values above +EN='en' +ES='es' +WN='wn' +WS='ws' + +# -compound +TEXT='text' +IMAGE='image' + # -fill NONE='none' X='x' @@ -54,8 +64,38 @@ # -bordermode INSIDE='inside' +IGNORE='ignore' OUTSIDE='outside' +# -direction +ABOVE='above' +BELOW='below' +FLUSH='flush' + +# -stretch +ALWAYS='always' +MIDDLE='middle' +NEVER='never' + +# -tabstyle +TABULAR='tabular' +WORDPROCESSOR='wordprocessor' + +# -insertunfocussed (Tk 8.6+) +HOLLOW='hollow' + +# -mode +DETERMINATE='determinate' +INDETERMINATE='indeterminate' + +# -selecttype (Tk 9.0+) +ITEM='item' +CELL='cell' + +# -show +TREE='tree' +HEADINGS='headings' + # Special tags, marks and insert positions SEL='sel' SEL_FIRST='sel.first' @@ -72,6 +112,29 @@ ACTIVE='active' # Canvas state HIDDEN='hidden' +# Entry and ttk widget states +READONLY='readonly' +# Other ttk widget states +ALTERNATE='alternate' +BACKGROUND='background' +FOCUS='focus' +HOVER='hover' +INVALID='invalid' +PRESSED='pressed' +SELECTED='selected' +# ttk widget states for Treeview items and Notebook tabs (Tk 9.1+) +# FIRST='first' and LAST='last' are also used +LEAF='leaf' +OPEN='open' + +# -validate +# ALL='all', FOCUS='focus' and NONE='none' are also valid +KEY='key' +FOCUSIN='focusin' +FOCUSOUT='focusout' + +# Validation reasons, in addition to the values above +FORCED='forced' # Menu item types CASCADE='cascade' @@ -80,6 +143,10 @@ RADIOBUTTON='radiobutton' SEPARATOR='separator' +# -type for menus +MENUBAR='menubar' +TEAROFF='tearoff' + # Selection modes for list boxes SINGLE='single' BROWSE='browse' @@ -108,3 +175,4 @@ SCROLL='scroll' UNITS='units' PAGES='pages' +PIXELS='pixels' diff --git a/Lib/tkinter/font.py b/Lib/tkinter/font.py index 5b663a4e456456b..1349e49fbd68a5b 100644 --- a/Lib/tkinter/font.py +++ b/Lib/tkinter/font.py @@ -104,7 +104,8 @@ def __init__(self, root=None, font=None, name=None, exists=False, if exists: self.name = name # confirm font exists - if self.name not in tk.splitlist(tk.call("font", "names")): + name = getattr(name, 'string', name) # can be a Tcl object + if name not in tk.splitlist(tk.call("font", "names")): raise tkinter._tkinter.TclError( "named font %s does not already exist" % (self.name,)) # if font config info supplied, apply it @@ -123,11 +124,11 @@ def __init__(self, root=None, font=None, name=None, exists=False, self._call = tk.call def __str__(self): - # A wrapped description is a list or tuple, not a string; format it as - # a Tcl word so it can be used as an option value (as ttk does). - if isinstance(self.name, str): - return self.name - return tkinter._join(self.name) + # A wrapped description can be a list or tuple; format it as a Tcl + # word so it can be used as an option value (as ttk does). + if isinstance(self.name, (list, tuple)): + return tkinter._join(self.name) + return str(self.name) def __repr__(self): return f"<{self.__class__.__module__}.{self.__class__.__qualname__}" \ @@ -136,7 +137,13 @@ def __repr__(self): def __eq__(self, other): if not isinstance(other, Font): return NotImplemented - return self.name == other.name and self._tk == other._tk + name = self.name + other_name = other.name + if type(name) is not type(other_name): + # A Tcl object does not compare equal to a string. + name = getattr(name, 'string', name) + other_name = getattr(other_name, 'string', other_name) + return name == other_name and self._tk == other._tk def __getitem__(self, key): return self.cget(key) diff --git a/Lib/tkinter/simpledialog.py b/Lib/tkinter/simpledialog.py index 1b0cf51317ee082..caef785f936db36 100644 --- a/Lib/tkinter/simpledialog.py +++ b/Lib/tkinter/simpledialog.py @@ -722,12 +722,13 @@ def askstring(title, prompt, **kw): @contextlib.contextmanager def _temp_grab_focus(grab, focus=None, destroy=True): - old_focus = grab.focus_get() - old_grab = grab.grab_current() - if old_grab is not None and old_grab.winfo_exists(): - old_status = old_grab.grab_status() - else: - old_status = None + # Use Tcl window names rather than widgets, because the focus and the + # grab can be in a window which was not created by tkinter, such as + # a native message box. + tk = grab.tk + old_focus = tk.call('focus') + old_grab = tk.call('grab', 'current', grab._w) + old_status = tk.call('grab', 'status', old_grab) if old_grab else None # The "grab" command will fail if another application # already holds the grab. So catch it. try: @@ -741,9 +742,11 @@ def _temp_grab_focus(grab, focus=None, destroy=True): yield finally: - if old_focus is not None: + # The old windows and even the whole application can be destroyed + # by now, so catch errors. + if old_focus: try: - old_focus.focus_set() + tk.call('focus', old_focus) except TclError: pass try: @@ -755,15 +758,17 @@ def _temp_grab_focus(grab, focus=None, destroy=True): grab.destroy() except TclError: pass - if (old_grab is not None and old_grab.winfo_exists() - and old_grab.winfo_ismapped()): - # The "grab" command will fail if another application - # already holds the grab. So catch it. + if old_grab: + # Do not restore the grab if the window is no longer mapped: + # a local grab on an unmapped window would block the application. + # The "grab" command will fail if another application already + # holds the grab on a window with the same name. So catch it. try: - if old_status == 'global': - old_grab.grab_set_global() - else: - old_grab.grab_set() + if grab.getboolean(tk.call('winfo', 'ismapped', old_grab)): + if old_status == 'global': + tk.call('grab', 'set', '-global', old_grab) + else: + tk.call('grab', 'set', old_grab) except TclError: pass diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py index 57953d90b672a2c..73d2b63ad445f87 100644 --- a/Lib/tkinter/ttk.py +++ b/Lib/tkinter/ttk.py @@ -12,7 +12,7 @@ of the widgets appearance lies at Themes. """ -__author__ = "Guilherme Polo " +# Original author: Guilherme Polo __all__ = ["Button", "Checkbutton", "Combobox", "Entry", "Frame", "Label", "Labelframe", "LabelFrame", "Menubutton", "Notebook", "Panedwindow", @@ -24,6 +24,7 @@ "tclobjs_to_py", "setup_master"] import tkinter +lazy import warnings from tkinter import _flatten, _join, _stringify, _splitdict @@ -2210,9 +2211,10 @@ def destroy(self): def __getattr__(name): - if name == "__version__": - from warnings import _deprecated - - _deprecated("__version__", remove=(3, 20)) - return "0.3.1" # Do not change + if name in ("__version__", "__author__"): + warnings._deprecated(name, remove=(3, 20)) + return { # Do not change + "__version__": "0.3.1", + "__author__": "Guilherme Polo ", + }[name] raise AttributeError(f"module {__name__!r} has no attribute {name!r}") diff --git a/Lib/tokenize.py b/Lib/tokenize.py index 3545d92c4f5d7ff..3cde65d0a707ae9 100644 --- a/Lib/tokenize.py +++ b/Lib/tokenize.py @@ -20,10 +20,10 @@ which tells you which encoding was used to decode the bytes stream. """ -__author__ = 'Ka-Ping Yee ' -__credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, ' - 'Skip Montanaro, Raymond Hettinger, Trent Nelson, ' - 'Michael Foord') +# Original author: Ka-Ping Yee +# Credits: ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip Montanaro, +# Raymond Hettinger, Trent Nelson, Michael Foord + from builtins import open as _builtin_open from codecs import lookup, BOM_UTF8 import collections @@ -36,6 +36,7 @@ from token import EXACT_TOKEN_TYPES import _tokenize lazy import _colorize +lazy import warnings cookie_re = re.compile(br'^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)', re.ASCII) blank_re = re.compile(br'^[ \t\f]*(?:[#\r\n]|$)', re.ASCII) @@ -640,5 +641,17 @@ def _generate_tokens_from_c_tokenizer(source, encoding=None, extra_tokens=False) raise TokenError(msg, (e.lineno, e.offset)) from None +def __getattr__(name): + if name in ("__author__", "__credits__"): + warnings._deprecated(name, remove=(3, 20)) + return { # Do not change + "__author__": 'Ka-Ping Yee', + "__credits__": ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, ' + 'Skip Montanaro, Raymond Hettinger, Trent Nelson, ' + 'Michael Foord'), + }[name] + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") + + if __name__ == "__main__": _main() diff --git a/Lib/trace.py b/Lib/trace.py index 43ec201c4696d1d..66471f45e1c0040 100644 --- a/Lib/trace.py +++ b/Lib/trace.py @@ -287,8 +287,11 @@ def write_results(self, show_missing=True, summary=False, coverdir=None, *, n_lines, n_hits, modulename, filename = sums[m] print(f"{n_lines:5d} {n_hits/n_lines:.1%} {modulename} ({filename})") + self._save_counts() + + def _save_counts(self): + """Save the accumulated counts to ``self.outfile`` if one was given.""" if self.outfile: - # try and store counts and module info into self.outfile try: with open(self.outfile, 'wb') as f: pickle.dump((self.counts, self.calledfuncs, self.callers), @@ -744,6 +747,8 @@ def parse_ignore_dir(s): if not opts.no_report: results.write_results(opts.missing, opts.summary, opts.coverdir) + else: + results._save_counts() if __name__=='__main__': main() diff --git a/Lib/traceback.py b/Lib/traceback.py index dcdab1f12e9a168..3ecb1dd318fbcb7 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -1611,7 +1611,11 @@ def _format_syntax_error(self, stype, **kwargs): ) else: yield ' {}\n'.format(ltext) - msg = self.msg or "" + try: + if not (msg := self.msg): + msg = "" + except TypeError: + pass yield "{}{}{}: {}{}{}{}\n".format( theme.type, stype, @@ -1954,31 +1958,34 @@ def _compute_suggestion_error(exc_value, tb, wrong_name): return None else: assert isinstance(exc_value, NameError) - # find most recent frame - if tb is None: + try: + # find most recent frame + if tb is None: + return None + while tb.tb_next is not None: + tb = tb.tb_next + frame = tb.tb_frame + d = ( + list(frame.f_locals) + + list(frame.f_globals) + + list(frame.f_builtins) + ) + d = [x for x in d if isinstance(x, str)] + if not_normalized and wrong_name in d: + return wrong_name + + # Check first if we are in a method and the instance + # has the wrong name as attribute + if 'self' in frame.f_locals: + self = frame.f_locals['self'] + try: + has_wrong_name = hasattr(self, wrong_name) + except Exception: + has_wrong_name = False + if has_wrong_name: + return f"self.{wrong_name}" + except Exception: return None - while tb.tb_next is not None: - tb = tb.tb_next - frame = tb.tb_frame - d = ( - list(frame.f_locals) - + list(frame.f_globals) - + list(frame.f_builtins) - ) - d = [x for x in d if isinstance(x, str)] - if not_normalized and wrong_name in d: - return wrong_name - - # Check first if we are in a method and the instance - # has the wrong name as attribute - if 'self' in frame.f_locals: - self = frame.f_locals['self'] - try: - has_wrong_name = hasattr(self, wrong_name) - except Exception: - has_wrong_name = False - if has_wrong_name: - return f"self.{wrong_name}" if not_normalized and wrong_name in d: return wrong_name diff --git a/Lib/tracemalloc.py b/Lib/tracemalloc.py index cec99c59700fe05..426981ebe97b4de 100644 --- a/Lib/tracemalloc.py +++ b/Lib/tracemalloc.py @@ -119,6 +119,7 @@ def _sort_key(self): def _compare_grouped_stats(old_group, new_group): statistics = [] + old_group = dict(old_group) for traceback, stat in new_group.items(): previous = old_group.pop(traceback, None) if previous is not None: @@ -478,7 +479,7 @@ def _group_by(self, key_type, cumulative): if key_type not in ('traceback', 'filename', 'lineno'): raise ValueError("unknown key_type: %r" % (key_type,)) if cumulative and key_type not in ('lineno', 'filename'): - raise ValueError("cumulative mode cannot by used " + raise ValueError("cumulative mode cannot be used " "with key type %r" % key_type) stats = {} diff --git a/Lib/turtle.py b/Lib/turtle.py index af2c7448a0af17f..a060d3aa651013b 100644 --- a/Lib/turtle.py +++ b/Lib/turtle.py @@ -1,4 +1,3 @@ -# # turtle.py: a Tkinter based turtle graphics module for Python # Version 1.1b - 4. 5. 2009 # @@ -22,80 +21,17 @@ # 3. This notice may not be removed or altered from any source distribution. """ -Turtle graphics is a popular way for introducing programming to -kids. It was part of the original Logo programming language developed -by Wally Feurzig and Seymour Papert in 1966. - -Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an ``import turtle``, give it -the command turtle.forward(15), and it moves (on-screen!) 15 pixels in -the direction it is facing, drawing a line as it moves. Give it the -command turtle.right(25), and it rotates in-place 25 degrees clockwise. - -By combining together these and similar commands, intricate shapes and -pictures can easily be drawn. - ------ turtle.py - -This module is an extended reimplementation of turtle.py from the -Python standard distribution up to Python 2.5. (See: https://www.python.org) - -It tries to keep the merits of turtle.py and to be (nearly) 100% -compatible with it. This means in the first place to enable the -learning programmer to use all the commands, classes and methods -interactively when using the module from within IDLE run with -the -n switch. - -Roughly it has the following features added: - -- Better animation of the turtle movements, especially of turning the - turtle. So the turtles can more easily be used as a visual feedback - instrument by the (beginning) programmer. - -- Different turtle shapes, image files as turtle shapes, user defined - and user controllable turtle shapes, among them compound - (multicolored) shapes. Turtle shapes can be stretched and tilted, which - makes turtles very versatile geometrical objects. - -- Fine control over turtle movement and screen updates via delay(), - and enhanced tracer() and speed() methods. - -- Aliases for the most commonly used commands, like fd for forward etc., - following the early Logo traditions. This reduces the boring work of - typing long sequences of commands, which often occur in a natural way - when kids try to program fancy pictures on their first encounter with - turtle graphics. - -- Turtles now have an undo()-method with configurable undo-buffer. - -- Some simple commands/methods for creating event driven programs - (mouse-, key-, timer-events). Especially useful for programming games. - -- A scrollable Canvas class. The default scrollable Canvas can be - extended interactively as needed while playing around with the turtle(s). - -- A TurtleScreen class with methods controlling background color or - background image, window and canvas size and other properties of the - TurtleScreen. - -- There is a method, setworldcoordinates(), to install a user defined - coordinate-system for the TurtleScreen. - -- The implementation uses a 2-vector class named Vec2D, derived from tuple. - This class is public, so it can be imported by the application programmer, - which makes certain types of computations very natural and compact. - -- Appearance of the TurtleScreen and the Turtles at startup/import can be - configured by means of a turtle.cfg configuration file. - The default configuration mimics the appearance of the old turtle module. - -- If configured appropriately the module reads in docstrings from a docstring - dictionary in some different language, supplied separately and replaces - the English ones by those read in. There is a utility function - write_docstringdict() to write a dictionary with the original (English) - docstrings to disc, so it can serve as a template for translations. - -Behind the scenes there are some features included with possible -extensions in mind. These will be commented and documented elsewhere. +Imagine a robotic turtle starting at (0, 0) in the x-y plane. +After an `import turtle`, give it the command `turtle.forward(15)`, and it +moves (on-screen!) 15 pixels in the direction it is facing, drawing a line as +it moves. Give it the command `turtle.right(25)`, and it rotates in-place 25 +degrees clockwise. + +Turtle graphics is an implementation of the drawing tools introduced in Logo +in 1967. It was created as an educational tool, and its instant, visible +feedback makes it an effective way for learners to encounter programming +concepts. It is also a convenient way to produce simple graphical output +without bringing in external libraries. """ import tkinter as TK @@ -105,6 +41,7 @@ import inspect import sys +from os import environ from os.path import isfile, split, join from pathlib import Path from contextlib import contextmanager @@ -166,7 +103,7 @@ } def config_dict(filename): - """Convert content of config-file into dictionary.""" + """Convert the content of a config file into a dict.""" with open(filename, "r") as f: cfglines = f.readlines() cfgdict = {} @@ -177,7 +114,7 @@ def config_dict(filename): try: key, value = line.split("=") except ValueError: - print("Bad line in config-file %s:\n%s" % (filename,line)) + print(f"Bad line in config-file {filename}:\n{line}") continue key = key.strip() value = value.strip() @@ -195,17 +132,17 @@ def config_dict(filename): return cfgdict def readconfig(cfgdict): - """Read config-files, change configuration-dict accordingly. + """Read config files and update the configuration dict accordingly. If there is a turtle.cfg file in the current working directory, - read it from there. If this contains an importconfig-value, - say 'myway', construct filename turtle_mayway.cfg else use - turtle.cfg and read it from the import-directory, where - turtle.py is located. - Update configuration dictionary first according to config-file, - in the import directory, then according to config-file in the - current working directory. - If no config-file is found, the default configuration is used. + read it. If it contains an importconfig value, say 'myway', + use the filename turtle_myway.cfg, otherwise turtle.cfg, and + read that file from the directory where turtle.py is located. + + The configuration dict is updated first from the config file in + the turtle.py directory, then from the one in the current working + directory. If no config file is found, the default configuration + is used. """ default_cfg = "turtle.cfg" cfgdict1 = {} @@ -231,46 +168,54 @@ def readconfig(cfgdict): class Vec2D(tuple): - """A 2 dimensional vector class, used as a helper class - for implementing turtle graphics. - May be useful for turtle graphics programs also. - Derived from tuple, so a vector is a tuple! + """A two-dimensional vector class, used as a helper class for + implementing turtle graphics. May be useful for turtle graphics + programs too. Derived from tuple, so a vector is a tuple! Provides (for a, b vectors, k number): - a+b vector addition - a-b vector subtraction - a*b inner product - k*a and a*k multiplication with scalar - |a| absolute value of a - a.rotate(angle) rotation + a + b: vector addition + a - b: vector subtraction + a * b: inner product + k * a and a * k: multiplication with scalar + abs(a): absolute value of a + a.rotate(angle): rotation """ + def __new__(cls, x, y): return tuple.__new__(cls, (x, y)) + def __add__(self, other): return Vec2D(self[0]+other[0], self[1]+other[1]) + def __mul__(self, other): if isinstance(other, Vec2D): return self[0]*other[0]+self[1]*other[1] return Vec2D(self[0]*other, self[1]*other) + def __rmul__(self, other): if isinstance(other, int) or isinstance(other, float): return Vec2D(self[0]*other, self[1]*other) return NotImplemented + def __sub__(self, other): return Vec2D(self[0]-other[0], self[1]-other[1]) + def __neg__(self): return Vec2D(-self[0], -self[1]) + def __abs__(self): return math.hypot(*self) + def rotate(self, angle): - """rotate self counterclockwise by angle - """ + """Rotate self counterclockwise by angle.""" perp = Vec2D(-self[1], self[0]) angle = math.radians(angle) c, s = math.cos(angle), math.sin(angle) return Vec2D(self[0]*c+perp[0]*s, self[1]*c+perp[1]*s) + def __getnewargs__(self): return (self[0], self[1]) + def __repr__(self): return "(%.2f,%.2f)" % self @@ -280,11 +225,11 @@ def __repr__(self): ### May be replaced by an interface to some different graphics toolkit ### ############################################################################## -## helper functions for Scrolled Canvas, to forward Canvas-methods +## Helper functions for Scrolled Canvas, to forward Canvas-methods ## to ScrolledCanvas class def __methodDict(cls, _dict): - """helper function for Scrolled Canvas""" + """Helper function for Scrolled Canvas.""" baseList = list(cls.__bases__) baseList.reverse() for _super in baseList: @@ -294,7 +239,7 @@ def __methodDict(cls, _dict): _dict[key] = value def __methods(cls): - """helper function for Scrolled Canvas""" + """Helper function for Scrolled Canvas.""" _dict = {} __methodDict(cls, _dict) return _dict.keys() @@ -325,11 +270,12 @@ def __forwardmethods(fromClass, toClass, toPart, exclude = ()): class ScrolledCanvas(TK.Frame): - """Modeled after the scrolled canvas class from Grayons's Tkinter book. + """Modeled after the scrolled canvas class from Grayson's Tkinter book. Used as the default canvas, which pops up automatically when using turtle graphics functions or the Turtle class. """ + def __init__(self, master, width=500, height=350, canvwidth=600, canvheight=500): TK.Frame.__init__(self, master, width=width, height=height) @@ -356,7 +302,7 @@ def __init__(self, master, width=500, height=350, self._rootwindow.bind('', self.onResize) def reset(self, canvwidth=None, canvheight=None, bg = None): - """Adjust canvas and scrollbars according to given canvas size.""" + """Adjust canvas size, background color and scrollbars.""" if canvwidth: self.canvwidth = canvwidth if canvheight: @@ -374,8 +320,7 @@ def reset(self, canvwidth=None, canvheight=None, bg = None): def adjustScrolls(self): - """ Adjust scrollbars according to window- and canvas-size. - """ + """Adjust scrollbars according to window and canvas size.""" cwidth = self._canvas.winfo_width() cheight = self._canvas.winfo_height() self._canvas.xview_moveto(0.5*(self.canvwidth-cwidth)/self.canvwidth) @@ -394,33 +339,27 @@ def onResize(self, event): self.adjustScrolls() def bbox(self, *args): - """ 'forward' method, which canvas itself has inherited... - """ + """Forward to the canvas method of the same name.""" return self._canvas.bbox(*args) def cget(self, *args, **kwargs): - """ 'forward' method, which canvas itself has inherited... - """ + """Forward to the canvas method of the same name.""" return self._canvas.cget(*args, **kwargs) def config(self, *args, **kwargs): - """ 'forward' method, which canvas itself has inherited... - """ + """Forward to the canvas method of the same name.""" self._canvas.config(*args, **kwargs) def bind(self, *args, **kwargs): - """ 'forward' method, which canvas itself has inherited... - """ + """Forward to the canvas method of the same name.""" self._canvas.bind(*args, **kwargs) def unbind(self, *args, **kwargs): - """ 'forward' method, which canvas itself has inherited... - """ + """Forward to the canvas method of the same name.""" self._canvas.unbind(*args, **kwargs) def focus_force(self): - """ 'forward' method, which canvas itself has inherited... - """ + """Forward to the canvas method of the same name.""" self._canvas.focus_force() __forwardmethods(ScrolledCanvas, TK.Canvas, '_canvas') @@ -428,6 +367,7 @@ def focus_force(self): class _Root(TK.Tk): """Root class for Screen based on Tkinter.""" + def __init__(self): TK.Tk.__init__(self) @@ -439,7 +379,7 @@ def _getcanvas(self): return self._canvas def set_geometry(self, width, height, startx, starty): - self.geometry("%dx%d%+d%+d"%(width, height, startx, starty)) + self.geometry("%dx%d%+d%+d" % (width, height, startx, starty)) def ondestroy(self, destroy): self.wm_protocol("WM_DELETE_WINDOW", destroy) @@ -453,23 +393,22 @@ def win_height(self): Canvas = TK.Canvas -class TurtleScreenBase(object): +class TurtleScreenBase: """Provide the basic graphics functionality. - Interface between Tkinter and turtle.py. + Interface between Tkinter and turtle.py. - To port turtle.py to some different graphics toolkit - a corresponding TurtleScreenBase class has to be implemented. + To port turtle.py to a different graphics toolkit, + a corresponding TurtleScreenBase class must be implemented. """ def _blankimage(self): - """return a blank image object - """ + """Return a blank image object.""" img = TK.PhotoImage(width=1, height=1, master=self.cv) img.blank() return img def _image(self, filename): - """return an image object containing the + """Return an image object containing the imagedata from an image file named filename. """ return TK.PhotoImage(file=filename, master=self.cv) @@ -489,20 +428,21 @@ def __init__(self, cv): self._updating = False def _createpoly(self): - """Create an invisible polygon item on canvas self.cv) - """ + """Create an invisible polygon item on canvas self.cv.""" return self.cv.create_polygon((0, 0, 0, 0, 0, 0), fill="", outline="") def _drawpoly(self, polyitem, coordlist, fill=None, outline=None, width=None, top=False): - """Configure polygonitem polyitem according to provided - arguments: - coordlist is sequence of coordinates - fill is filling color - outline is outline color - top is a boolean value, which specifies if polyitem - will be put on top of the canvas' displaylist so it - will not be covered by other items. + """Configure polygon item polyitem according to the given arguments. + + Arguments: + coordlist -- a sequence of coordinates + fill -- the fill color + outline -- the outline color + width -- the outline width + top -- a boolean value, which specifies if polyitem will be + put on top of the canvas' display list so it will not + be covered by other items """ cl = [] for x, y in coordlist: @@ -519,20 +459,21 @@ def _drawpoly(self, polyitem, coordlist, fill=None, self.cv.tag_raise(polyitem) def _createline(self): - """Create an invisible line item on canvas self.cv) - """ + """Create an invisible line item on canvas self.cv.""" return self.cv.create_line(0, 0, 0, 0, fill="", width=2, capstyle = TK.ROUND) def _drawline(self, lineitem, coordlist=None, fill=None, width=None, top=False): - """Configure lineitem according to provided arguments: - coordlist is sequence of coordinates - fill is drawing color - width is width of drawn line. - top is a boolean value, which specifies if polyitem - will be put on top of the canvas' displaylist so it - will not be covered by other items. + """Configure line item lineitem according to the given arguments. + + Arguments: + coordlist -- a sequence of coordinates + fill -- the drawing color + width -- the width of the drawn line + top -- a boolean value, which specifies if lineitem will be + put on top of the canvas' display list so it will not + be covered by other items """ if coordlist is not None: cl = [] @@ -549,13 +490,13 @@ def _drawline(self, lineitem, coordlist=None, def _delete(self, item): """Delete graphics item from canvas. - If item is"all" delete all graphics items. + + If item is "all", delete all graphics items. """ self.cv.delete(item) def _update(self): - """Redraw graphics items on canvas - """ + """Redraw graphics items on canvas.""" if self._updating: # Reentrant call (e.g. a drag handler moving the turtle, # gh-50966): flush drawing without reprocessing input. @@ -572,8 +513,7 @@ def _delay(self, delay): self.cv.after(delay) def _iscolorstring(self, color): - """Check if the string color is a legal Tkinter color string. - """ + """Check if the string color is a legal Tkinter color string.""" try: self.cv.winfo_rgb(color) ok = True @@ -591,10 +531,11 @@ def _bgcolor(self, color=None): return self.cv.cget("bg") def _write(self, pos, txt, align, font, pencolor): - """Write txt at pos in canvas with specified font - and color. - Return text item and x-coord of right bottom corner - of text's bounding box.""" + """Write txt at pos on the canvas with specified font and color. + + Return text item and x-coord of right bottom corner of text's + bounding box. + """ x, y = pos x = x * self.xscale y = y * self.yscale @@ -611,31 +552,28 @@ def _onclick(self, item, fun, num=1, add=None): num, the number of the mouse-button defaults to 1 """ if fun is None: - self.cv.tag_unbind(item, "" % num) + self.cv.tag_unbind(item, f"") else: def eventfun(event): x, y = (self.cv.canvasx(event.x)/self.xscale, -self.cv.canvasy(event.y)/self.yscale) fun(x, y) - self.cv.tag_bind(item, "" % num, eventfun, add) + self.cv.tag_bind(item, f"", eventfun, add) def _onrelease(self, item, fun, num=1, add=None): """Bind fun to mouse-button-release event on turtle. fun must be a function with two arguments, the coordinates of the point on the canvas where mouse button is released. num, the number of the mouse-button defaults to 1 - - If a turtle is clicked, first _onclick-event will be performed, - then _onscreensclick-event. """ if fun is None: - self.cv.tag_unbind(item, "" % num) + self.cv.tag_unbind(item, f"") else: def eventfun(event): x, y = (self.cv.canvasx(event.x)/self.xscale, -self.cv.canvasy(event.y)/self.yscale) fun(x, y) - self.cv.tag_bind(item, "" % num, + self.cv.tag_bind(item, f"", eventfun, add) def _ondrag(self, item, fun, num=1, add=None): @@ -648,7 +586,7 @@ def _ondrag(self, item, fun, num=1, add=None): mouse-click event on that turtle. """ if fun is None: - self.cv.tag_unbind(item, "" % num) + self.cv.tag_unbind(item, f"") else: def eventfun(event): try: @@ -657,7 +595,7 @@ def eventfun(event): fun(x, y) except Exception: pass - self.cv.tag_bind(item, "" % num, eventfun, add) + self.cv.tag_bind(item, f"", eventfun, add) def _onscreenclick(self, fun, num=1, add=None): """Bind fun to mouse-click event on canvas. @@ -666,27 +604,28 @@ def _onscreenclick(self, fun, num=1, add=None): num, the number of the mouse-button defaults to 1 If a turtle is clicked, first _onclick-event will be performed, - then _onscreensclick-event. + then _onscreenclick-event. """ if fun is None: - self.cv.unbind("" % num) + self.cv.unbind(f"") else: def eventfun(event): x, y = (self.cv.canvasx(event.x)/self.xscale, -self.cv.canvasy(event.y)/self.yscale) fun(x, y) - self.cv.bind("" % num, eventfun, add) + self.cv.bind(f"", eventfun, add) def _onkeyrelease(self, fun, key): """Bind fun to key-release event of key. - Canvas must have focus. See method listen + + Canvas must have focus. See the listen() method. """ if fun is None: - self.cv.unbind("" % key, None) + self.cv.unbind(f"", None) else: def eventfun(event): fun() - self.cv.bind("" % key, eventfun) + self.cv.bind(f"", eventfun) def _onkeypress(self, fun, key=None): """If key is given, bind fun to key-press event of key. @@ -697,37 +636,32 @@ def _onkeypress(self, fun, key=None): if key is None: self.cv.unbind("", None) else: - self.cv.unbind("" % key, None) + self.cv.unbind(f"", None) else: def eventfun(event): fun() if key is None: self.cv.bind("", eventfun) else: - self.cv.bind("" % key, eventfun) + self.cv.bind(f"", eventfun) def _listen(self): - """Set focus on canvas (in order to collect key-events) - """ + """Set focus on canvas (in order to collect key-events).""" self.cv.focus_force() def _ontimer(self, fun, t): - """Install a timer, which calls fun after t milliseconds. - """ + """Install a timer, which calls fun after t milliseconds.""" if t == 0: self.cv.after_idle(fun) else: self.cv.after(t, fun) def _createimage(self, image): - """Create and return image item on canvas. - """ + """Create and return image item on canvas.""" return self.cv.create_image(0, 0, image=image) def _drawimage(self, item, pos, image): - """Configure image item as to draw image object - at position (x,y) on canvas) - """ + """Configure the canvas item to show image at position pos.""" x, y = pos self.cv.coords(item, (x * self.xscale, -y * self.yscale)) self.cv.itemconfig(item, image=image) @@ -736,24 +670,22 @@ def _setbgpic(self, item, image): """Configure image item as to draw image object at center of canvas. Set item to the first item in the displaylist, so it will be drawn below - any other item .""" + any other item.""" self.cv.itemconfig(item, image=image) self.cv.tag_lower(item) def _type(self, item): - """Return 'line' or 'polygon' or 'image' depending on - type of item. - """ + """Return 'line' or 'polygon' or 'image' depending on type of item.""" return self.cv.type(item) def _pointlist(self, item): - """returns list of coordinate-pairs of points of item - Example (for insiders): - >>> from turtle import * - >>> getscreen()._pointlist(getturtle().turtle._item) - [(0.0, 9.9999999999999982), (0.0, -9.9999999999999982), - (9.9999999999999982, 0.0)] - >>> """ + """Return list of coordinate pairs of points of item. + + For example: + >>> getscreen()._pointlist(getturtle().turtle._item) + [(0.0, 9.9999999999999982), (0.0, -9.9999999999999982), + (9.9999999999999982, 0.0)] + """ cl = self.cv.coords(item) pl = [(cl[i], -cl[i+1]) for i in range(0, len(cl), 2)] return pl @@ -774,8 +706,9 @@ def _rescale(self, xscalefactor, yscalefactor): self.cv.coords(item, *newcoordlist) def _resize(self, canvwidth=None, canvheight=None, bg=None): - """Resize the canvas the turtles are drawing on. Does - not alter the drawing window. + """Resize the canvas the turtles are drawing on. + + Does not alter the drawing window. """ # needs amendment if not isinstance(self.cv, ScrolledCanvas): @@ -789,8 +722,7 @@ def _resize(self, canvwidth=None, canvheight=None, bg=None): self.cv.reset(canvwidth, canvheight, bg) def _window_size(self): - """ Return the width and height of the turtle window. - """ + """Return the width and height of the turtle window.""" width = self.cv.winfo_width() if width <= 1: # the window isn't managed by a geometry manager width = self.cv['width'] @@ -800,52 +732,51 @@ def _window_size(self): return width, height def mainloop(self): - """Starts event loop - calling Tkinter's mainloop function. - - No argument. - - Must be last statement in a turtle graphics program. - Must NOT be used if a script is run from within IDLE in -n mode - (No subprocess) - for interactive use of turtle graphics. - - Example (for a TurtleScreen instance named screen): - >>> screen.mainloop() + """Start the event loop by calling Tkinter's mainloop method. + Must be the last statement in a turtle graphics program. Must not + be used if a script is run from within IDLE in -n mode (no + subprocess). """ self.cv.tk.mainloop() def textinput(self, title, prompt): """Pop up a dialog window for input of a string. - Arguments: title is the title of the dialog window, - prompt is a text mostly describing what information to input. - - Return the string input + title is the title of the dialog window and prompt is a text + describing what information to input. Return the string entered. If the dialog is canceled, return None. - Example (for a TurtleScreen instance named screen): - >>> screen.textinput("NIM", "Name of first player:") + Arguments: + title -- a string + prompt -- a string + Example (for a TurtleScreen instance named screen): + >>> screen.textinput("NIM", "Name of first player:") """ return simpledialog.askstring(title, prompt, parent=self.cv) def numinput(self, title, prompt, default=None, minval=None, maxval=None): """Pop up a dialog window for input of a number. - Arguments: title is the title of the dialog window, - prompt is a text mostly describing what numerical information to input. - default: default value - minval: minimum value for input - maxval: maximum value for input + title is the title of the dialog window and prompt is a text + describing what numerical information to input. default is the + default value, minval and maxval are the minimum and maximum + values for input. If these are given and the number entered is not + between minval and maxval, a hint is issued and the dialog remains + open for correction. Return the number entered. If the dialog is + canceled, return None. - The number input must be in the range minval .. maxval if these are - given. If not, a hint is issued and the dialog remains open for - correction. Return the number input. - If the dialog is canceled, return None. + Arguments: + title -- a string + prompt -- a string + default -- a number or None + minval -- a number or None + maxval -- a number or None Example (for a TurtleScreen instance named screen): - >>> screen.numinput("Poker", "Your stakes:", 1000, minval=10, maxval=10000) - + >>> screen.numinput("Poker", "Your stakes:", 1000, + ... minval=10, maxval=10000) """ return simpledialog.askfloat(title, prompt, initialvalue=default, minvalue=minval, maxvalue=maxval, @@ -857,27 +788,28 @@ def numinput(self, title, prompt, default=None, minval=None, maxval=None): ############################################################################## -class Terminator (Exception): - """Will be raised in TurtleScreen.update, if _RUNNING becomes False. +class Terminator(Exception): + """Raised by turtle commands after the turtle screen has been closed. - This stops execution of a turtle graphics script. - Main purpose: use in the Demo-Viewer turtle.Demo.py. + This stops the execution of a turtle graphics script. It is mainly + used by the turtledemo viewer. """ - pass class TurtleGraphicsError(Exception): - """Some TurtleGraphics Error - """ + """Raised for invalid arguments or operations.""" -class Shape(object): +class Shape: """Data structure modeling shapes. - attribute _type is one of "polygon", "image", "compound" - attribute _data is - depending on _type a poygon-tuple, - an image or a list constructed using the addcomponent method. + type_ is one of the strings "polygon", "image" or "compound". What + data must be depends on type_: for "polygon" a tuple of pairs of + coordinates, for "image" an image (only used internally), and for + "compound" None, as a compound shape is built up using the + addcomponent method. """ + def __init__(self, type_, data=None): self._type = type_ if type_ == "polygon": @@ -888,40 +820,44 @@ def __init__(self, type_, data=None): elif type_ == "compound": data = [] else: - raise TurtleGraphicsError("There is no shape type %s" % type_) + raise TurtleGraphicsError(f"There is no shape type {type_!r}") self._data = data def addcomponent(self, poly, fill, outline=None): - """Add component to a shape of type compound. + """Add a component to a shape of type "compound". - Arguments: poly is a polygon, i. e. a tuple of number pairs. - fill is the fillcolor of the component, - outline is the outline color of the component. + poly is a polygon, a tuple of pairs of numbers. fill is the color + the polygon is filled with and outline is the color of its + outline. If outline is not given, fill is used for it as well. - call (for a Shapeobject namend s): - -- s.addcomponent(((0,0), (10,10), (-10,10)), "red", "blue") + Arguments: + poly -- a tuple of pairs of numbers + fill -- a color + outline -- a color or None Example: - >>> poly = ((0,0),(10,-5),(0,10),(-10,-5)) - >>> s = Shape("compound") - >>> s.addcomponent(poly, "red", "blue") - >>> # .. add more components and then use register_shape() + >>> poly = ((0,0), (10,-5), (0,10), (-10,-5)) + >>> s = Shape("compound") + >>> s.addcomponent(poly, "red", "blue") + >>> # ... add more components and then use register_shape() """ if self._type != "compound": - raise TurtleGraphicsError("Cannot add component to %s Shape" - % self._type) + raise TurtleGraphicsError(f"Cannot add component to {self._type!r} Shape") + if outline is None: outline = fill self._data.append([poly, fill, outline]) -class Tbuffer(object): - """Ring buffer used as undobuffer for RawTurtle objects.""" +class Tbuffer: + """Ring buffer used as undo buffer for RawTurtle objects.""" + def __init__(self, bufsize=10): self.bufsize = bufsize self.buffer = [[None]] * bufsize self.ptr = -1 self.cumulate = False + def reset(self, bufsize=None): if bufsize is None: for i in range(self.bufsize): @@ -930,6 +866,7 @@ def reset(self, bufsize=None): self.bufsize = bufsize self.buffer = [[None]] * bufsize self.ptr = -1 + def push(self, item): if self.bufsize > 0: if not self.cumulate: @@ -937,6 +874,7 @@ def push(self, item): self.buffer[self.ptr] = item else: self.buffer[self.ptr].append(item) + def pop(self): if self.bufsize > 0: item = self.buffer[self.ptr] @@ -946,20 +884,31 @@ def pop(self): self.buffer[self.ptr] = [None] self.ptr = (self.ptr - 1) % self.bufsize return (item) + + def remove(self, item): + if item not in self.buffer: + return + index = self.buffer.index(item) + self.buffer.remove(item) + if index <= self.ptr: + self.ptr = (self.ptr - 1) % self.bufsize + self.buffer.insert((self.ptr+1) % self.bufsize, [None]) + def nr_of_items(self): return self.bufsize - self.buffer.count([None]) + def __repr__(self): return str(self.buffer) + " " + str(self.ptr) - class TurtleScreen(TurtleScreenBase): - """Provides screen oriented methods like bgcolor etc. + """Provides the screen-oriented methods, such as bgcolor(). - Only relies upon the methods of TurtleScreenBase and NOT - upon components of the underlying graphics toolkit - - which is Tkinter in this case. + Only relies upon the methods of TurtleScreenBase and not upon + components of the underlying graphics toolkit, which is Tkinter + in this case. """ + _RUNNING = True def __init__(self, cv, mode=_CFG["mode"], @@ -1002,18 +951,19 @@ def __init__(self, cv, mode=_CFG["mode"], rootwindow.wm_attributes(topmost=True) rootwindow.wm_attributes(topmost=False) + # A new screen means that turtle graphics is running again. + TurtleScreen._RUNNING = True + def clear(self): """Delete all drawings and all turtles from the TurtleScreen. - No argument. - - Reset empty TurtleScreen to its initial state: white background, - no backgroundimage, no eventbindings and tracing on. + Aliases: clear | clearscreen - Example (for a TurtleScreen instance named screen): - >>> screen.clear() - - Note: this method is not available as function. + Reset the now empty TurtleScreen to its initial state: white + background, no background image, no event bindings and tracing on. + As a function, this method is only available under the name + clearscreen. The function clear is derived from the Turtle method + clear. """ self._delayvalue = _CFG["delay"] self._colormode = _CFG["colormode"] @@ -1033,26 +983,29 @@ def clear(self): Turtle._pen = None def mode(self, mode=None): - """Set turtle-mode ('standard', 'logo' or 'world') and perform reset. + """Set the turtle mode and perform a reset. - Optional argument: - mode -- one of the strings 'standard', 'logo' or 'world' + mode is one of the strings "standard", "logo" or "world". If mode + is not given, return the current mode. - Mode 'standard' is compatible with turtle.py. - Mode 'logo' is compatible with most Logo-Turtle-Graphics. - Mode 'world' uses userdefined 'worldcoordinates'. *Attention*: in - this mode angles appear distorted if x/y unit-ratio doesn't equal 1. - If mode is not given, return the current mode. + Mode "standard" is compatible with the old turtle module. Mode + "logo" is compatible with most Logo turtle graphics. Mode "world" + uses user-defined world coordinates, see setworldcoordinates(). In + this mode, angles appear distorted if the x and y units are not of + equal length. Mode Initial turtle heading positive angles ------------|-------------------------|------------------- - 'standard' to the right (east) counterclockwise - 'logo' upward (north) clockwise + "standard" to the right (east) counterclockwise + "logo" upward (north) clockwise + + Argument: + mode -- a string or None - Examples: - >>> mode('logo') # resets turtle heading to north - >>> mode() - 'logo' + Example (for a TurtleScreen instance named screen): + >>> screen.mode("logo") # resets turtle heading to north + >>> screen.mode() + 'logo' """ if mode is None: return self._mode @@ -1067,26 +1020,29 @@ def mode(self, mode=None): self.reset() def setworldcoordinates(self, llx, lly, urx, ury): - """Set up a user defined coordinate-system. - - Arguments: - llx -- a number, x-coordinate of lower left corner of canvas - lly -- a number, y-coordinate of lower left corner of canvas - urx -- a number, x-coordinate of upper right corner of canvas - ury -- a number, y-coordinate of upper right corner of canvas + """Set up a user-defined coordinate system. - Set up user coodinat-system and switch to mode 'world' if necessary. - This performs a screen.reset. If mode 'world' is already active, - all drawings are redrawn according to the new coordinates. + llx and lly are the x and y coordinates of the lower left corner of + the canvas. urx and ury are the x and y coordinates of the upper + right corner. Switch to mode "world" if necessary, which performs a + reset. If mode "world" is already active, all drawings are redrawn + according to the new coordinates. In user-defined coordinate + systems, angles may appear distorted, see mode(). - But ATTENTION: in user-defined coordinatesystems angles may appear - distorted. (see Screen.mode()) + Arguments: + llx -- a number + lly -- a number + urx -- a number + ury -- a number Example (for a TurtleScreen instance named screen): - >>> screen.setworldcoordinates(-10,-0.5,50,1.5) - >>> for _ in range(36): - ... left(10) - ... forward(0.5) + >>> screen.reset() + >>> screen.setworldcoordinates(-50,-7.5,50,7.5) + >>> for _ in range(72): + ... left(10) + ... + >>> for _ in range(8): + ... left(45); fd(2) # a regular octagon """ if self.mode() != "world": self.mode("world") @@ -1106,31 +1062,35 @@ def setworldcoordinates(self, llx, lly, urx, ury): self.update() def register_shape(self, name, shape=None): - """Adds a turtle shape to TurtleScreen's shapelist. + """Add a turtle shape to the TurtleScreen's shape list. + + Aliases: register_shape | addshape + + It can be called in four different ways: + + (1) name is the name of an image file (PNG, GIF, PGM, and PPM) and + shape is None. Install the corresponding image shape. + (2) name is an arbitrary string and shape is the name of an image + file (PNG, GIF, PGM, and PPM). Install the corresponding image + shape. + (3) name is an arbitrary string and shape is a tuple of pairs of + coordinates. Install the corresponding polygon shape. + (4) name is an arbitrary string and shape is a (compound) Shape + object. Install the corresponding compound shape. + + Image shapes do not rotate when turning the turtle, so they do not + display the heading of the turtle. To use a registered shape, call + shape() with its name. Arguments: - (1) name is the name of an image file (PNG, GIF, PGM, and PPM) and shape is None. - Installs the corresponding image shape. - !! Image-shapes DO NOT rotate when turning the turtle, - !! so they do not display the heading of the turtle! - (2) name is an arbitrary string and shape is the name of an image file (PNG, GIF, PGM, and PPM). - Installs the corresponding image shape. - !! Image-shapes DO NOT rotate when turning the turtle, - !! so they do not display the heading of the turtle! - (3) name is an arbitrary string and shape is a tuple - of pairs of coordinates. Installs the corresponding - polygon shape - (4) name is an arbitrary string and shape is a - (compound) Shape object. Installs the corresponding - compound shape. - To use a shape, you have to issue the command shape(shapename). - - call: register_shape("turtle.gif") - --or: register_shape("tri", ((0,0), (10,10), (-10,10))) + name -- a string + shape -- a string, a tuple of pairs of numbers, a Shape object + or None Example (for a TurtleScreen instance named screen): - >>> screen.register_shape("triangle", ((5,-3),(0,5),(-5,-3))) - + >>> screen.register_shape("turtle.gif") + >>> screen.register_shape("turtle", "turtle.gif") + >>> screen.register_shape("triangle", ((5,-3), (0,5), (-5,-3))) """ if shape is None: shape = Shape("image", self._image(name)) @@ -1142,14 +1102,12 @@ def register_shape(self, name, shape=None): self._shapes[name] = shape def _colorstr(self, color): - """Return color string corresponding to args. + """Return the color string corresponding to color. - Argument may be a string or a tuple of three - numbers corresponding to actual colormode, - i.e. in the range 0<=n<=colormode. + color may be a string or a tuple of three numbers, each between 0 and + the current colormode. - If the argument doesn't represent a color, - an error is raised. + If color doesn't represent a color, an error is raised. """ if len(color) == 1: color = color[0] @@ -1182,16 +1140,24 @@ def _color(self, cstr): def colormode(self, cmode=None): """Return the colormode or set it to 1.0 or 255. - Optional argument: - cmode -- one of the values 1.0 or 255 + After setting it, the r, g and b values of color triples have to + be between 0 and cmode. - r, g, b values of colortriples have to be in range 0..cmode. + Argument: + cmode -- a number or None Example (for a TurtleScreen instance named screen): - >>> screen.colormode() - 1.0 - >>> screen.colormode(255) - >>> pencolor(240,160,80) + >>> screen.colormode(1) + >>> turtle.pencolor(240, 160, 80) + Traceback (most recent call last): + ... + turtle.TurtleGraphicsError: bad color sequence: (240, 160, 80) + >>> screen.colormode() + 1.0 + >>> screen.colormode(255) + >>> screen.colormode() + 255 + >>> turtle.pencolor(240,160,80) """ if cmode is None: return self._colormode @@ -1201,12 +1167,13 @@ def colormode(self, cmode=None): self._colormode = int(cmode) def reset(self): - """Reset all Turtles on the Screen to their initial state. + """Reset all turtles on the screen to their initial state. - No argument. + Aliases: reset | resetscreen - Example (for a TurtleScreen instance named screen): - >>> screen.reset() + As a function, this method is only available under the name + resetscreen. The function reset is derived from the Turtle method + reset(). """ for turtle in self._turtles: turtle._setmode(self._mode) @@ -1216,40 +1183,40 @@ def turtles(self): """Return the list of turtles on the screen. Example (for a TurtleScreen instance named screen): - >>> screen.turtles() - [] + >>> for turtle in screen.turtles(): + ... turtle.color("red") """ return self._turtles def bgcolor(self, *args): - """Set or return backgroundcolor of the TurtleScreen. + """Return or set the background color of the TurtleScreen. Four input formats are allowed: - bgcolor() - Return the current background color as color specification + Return the current background color as a color specification string or as a tuple (see example). May be used as input - to another color/pencolor/fillcolor/bgcolor call. + to another color(), pencolor(), fillcolor() or bgcolor() call. - bgcolor(colorstring) Set the background color to colorstring, which is a Tk color specification string, such as "red", "yellow", or "#33cc8c". - bgcolor((r, g, b)) Set the background color to the RGB color represented by - the tuple of r, g, and b. Each of r, g, and b must be in - the range 0..colormode, where colormode is either 1.0 or 255 + the tuple of r, g, and b. Each of r, g, and b must be + between 0 and colormode, where colormode is either 1.0 or 255 (see colormode()). - bgcolor(r, g, b) Set the background color to the RGB color represented by - r, g, and b. Each of r, g, and b must be in the range - 0..colormode. + r, g, and b. Each of r, g, and b must be between 0 and + colormode. Example (for a TurtleScreen instance named screen): - >>> screen.bgcolor("orange") - >>> screen.bgcolor() - 'orange' - >>> colormode(255) - >>> screen.bgcolor('#800080') - >>> screen.bgcolor() - (128.0, 0.0, 128.0) + >>> screen.bgcolor("orange") + >>> screen.bgcolor() + 'orange' + >>> screen.colormode(255) + >>> screen.bgcolor("#800080") + >>> screen.bgcolor() + (128.0, 0.0, 128.0) """ if args: color = self._colorstr(args) @@ -1261,23 +1228,26 @@ def bgcolor(self, *args): return color def tracer(self, n=None, delay=None): - """Turns turtle animation on/off and set delay for update drawings. + """Turn turtle animation on or off and set the drawing delay. - Optional arguments: - n -- nonnegative integer - delay -- nonnegative integer + If n is given, only every n-th regular screen update is performed, + which can be used to speed up the drawing of complex graphics. If + n is 0, animation is turned off and the screen is only updated by + calling update(). If delay is given, it sets the drawing delay, see + delay(). When called without arguments, return the current value + of n. - If n is given, only each n-th regular screen update is really performed. - (Can be used to accelerate the drawing of complex graphics.) - Second arguments sets delay value (see RawTurtle.delay()) + Arguments: + n -- a nonnegative integer or None + delay -- a nonnegative integer or None Example (for a TurtleScreen instance named screen): - >>> screen.tracer(8, 25) - >>> dist = 2 - >>> for i in range(200): - ... fd(dist) - ... rt(90) - ... dist += 2 + >>> screen.tracer(8, 25) + >>> dist = 2 + >>> for i in range(200): + ... fd(dist) + ... rt(90) + ... dist += 2 """ if n is None: return self._tracing @@ -1289,15 +1259,21 @@ def tracer(self, n=None, delay=None): self.update() def delay(self, delay=None): - """ Return or set the drawing delay in milliseconds. + """Return or set the drawing delay in milliseconds. + + This is approximately the time interval between two consecutive + canvas updates. The longer the drawing delay, the slower the + animation. - Optional argument: - delay -- positive integer + Argument: + delay -- a nonnegative integer or None Example (for a TurtleScreen instance named screen): - >>> screen.delay(15) - >>> screen.delay() - 15 + >>> screen.delay() + 10 + >>> screen.delay(5) + >>> screen.delay() + 5 """ if delay is None: return self._delayvalue @@ -1305,16 +1281,17 @@ def delay(self, delay=None): @contextmanager def no_animation(self): - """Temporarily turn off auto-updating the screen. + """Temporarily turn off turtle animation. - This is useful for drawing complex shapes where even the fastest setting - is too slow. Once this context manager is exited, the drawing will - be displayed. + The code inside the with block is not animated. Once the block is + exited, the drawing appears. This is useful for drawing complex + shapes where even the fastest speed setting is too slow. - Example (for a TurtleScreen instance named screen - and a Turtle instance named turtle): - >>> with screen.no_animation(): - ... turtle.circle(50) + Example (for a TurtleScreen instance named screen): + >>> with screen.no_animation(): + ... for dist in range(2, 400, 2): + ... fd(dist) + ... rt(90) """ tracer = self.tracer() try: @@ -1324,7 +1301,7 @@ def no_animation(self): self.tracer(tracer) def _incrementudc(self): - """Increment update counter.""" + """Increment the update counter.""" if not TurtleScreen._RUNNING: TurtleScreen._RUNNING = True raise Terminator @@ -1334,6 +1311,8 @@ def _incrementudc(self): def update(self): """Perform a TurtleScreen update. + + To be used when tracer() is turned off. """ tracing = self._tracing self._tracing = True @@ -1344,85 +1323,91 @@ def update(self): self._update() def window_width(self): - """ Return the width of the turtle window. + """Return the width of the turtle window. Example (for a TurtleScreen instance named screen): - >>> screen.window_width() - 640 + >>> screen.window_width() + 640 """ return self._window_size()[0] def window_height(self): - """ Return the height of the turtle window. + """Return the height of the turtle window. Example (for a TurtleScreen instance named screen): - >>> screen.window_height() - 480 + >>> screen.window_height() + 480 """ return self._window_size()[1] def getcanvas(self): """Return the Canvas of this TurtleScreen. - No argument. - Example (for a Screen instance named screen): - >>> cv = screen.getcanvas() - >>> cv - + >>> cv = screen.getcanvas() + >>> cv + """ return self.cv def getshapes(self): """Return a list of names of all currently available turtle shapes. - No argument. - Example (for a TurtleScreen instance named screen): - >>> screen.getshapes() - ['arrow', 'blank', 'circle', ... , 'turtle'] + >>> screen.getshapes() + ['arrow', 'blank', 'circle', ..., 'turtle'] """ return sorted(self._shapes.keys()) def onclick(self, fun, btn=1, add=None): - """Bind fun to mouse-click event on canvas. + """Bind fun to mouse-click events on this screen. - Arguments: - fun -- a function with two arguments, the coordinates of the - clicked point on the canvas. - btn -- the number of the mouse-button, defaults to 1 + Aliases: onclick | onscreenclick + + fun is called with the coordinates of the clicked point on the + canvas. If fun is None, existing bindings are removed. btn is the + number of the mouse button and defaults to 1, the left mouse + button. If add is True, a new binding is added, otherwise it + replaces a previous binding. As a function, this method is only + available under the name onscreenclick. The function onclick is + derived from the Turtle method onclick. - Example (for a TurtleScreen instance named screen) + Arguments: + fun -- a function with two arguments or None + btn -- an integer + add -- a boolean or None - >>> screen.onclick(goto) - >>> # Subsequently clicking into the TurtleScreen will - >>> # make the turtle move to the clicked point. - >>> screen.onclick(None) + Example (for a TurtleScreen instance named screen): + >>> screen.onscreenclick(turtle.goto) + >>> # Subsequently clicking into the TurtleScreen will + >>> # make the turtle move to the clicked point. + >>> screen.onscreenclick(None) # remove event binding again """ self._onscreenclick(fun, btn, add) def onkey(self, fun, key): - """Bind fun to key-release event of key. + """Bind fun to the key-release event of key. - Arguments: - fun -- a function with no arguments - key -- a string: key (e.g. "a") or key-symbol (e.g. "space") - - In order to be able to register key-events, TurtleScreen - must have focus. (See method listen.) + Aliases: onkey | onkeyrelease - Example (for a TurtleScreen instance named screen): + key is a key, such as "a", or a key symbol, such as "space". If + fun is None, the event binding is removed. To be able to receive + key events, the TurtleScreen must have focus, see listen(). - >>> def f(): - ... fd(50) - ... lt(60) - ... - >>> screen.onkey(f, "Up") - >>> screen.listen() + Arguments: + fun -- a function with no arguments or None + key -- a string - Subsequently the turtle can be moved by repeatedly pressing - the up-arrow key, consequently drawing a hexagon + Example (for a TurtleScreen instance named screen): + >>> def f(): + ... fd(50) + ... lt(60) + ... + >>> screen.onkey(f, "Up") + >>> screen.listen() + The turtle can then be moved by repeatedly pressing the up-arrow + key, drawing a hexagon. """ if fun is None: if key in self._keys: @@ -1432,29 +1417,28 @@ def onkey(self, fun, key): self._onkeyrelease(fun, key) def onkeypress(self, fun, key=None): - """Bind fun to key-press event of key if key is given, - or to any key-press-event if no key is given. + """Bind fun to the key-press event of key. - Arguments: - fun -- a function with no arguments - key -- a string: key (e.g. "a") or key-symbol (e.g. "space") + key is a key, such as "a", or a key symbol, such as "space". If + key is not given, fun is bound to the key-press event of any key. + If fun is None, the event binding is removed. To be able to + receive key events, the TurtleScreen must have focus, see + listen(). - In order to be able to register key-events, TurtleScreen - must have focus. (See method listen.) - - Example (for a TurtleScreen instance named screen - and a Turtle instance named turtle): + Arguments: + fun -- a function with no arguments or None + key -- a string or None - >>> def f(): - ... fd(50) - ... lt(60) - ... - >>> screen.onkeypress(f, "Up") - >>> screen.listen() + Example (for a TurtleScreen instance named screen): + >>> def f(): + ... fd(50) + ... lt(60) + ... + >>> screen.onkeypress(f, "Up") + >>> screen.listen() - Subsequently the turtle can be moved by repeatedly pressing - the up-arrow key, or by keeping pressed the up-arrow key. - consequently drawing a hexagon. + The turtle can then be moved by pressing or holding down the + up-arrow key, drawing a hexagon. """ if fun is None: if key in self._keys: @@ -1464,54 +1448,54 @@ def onkeypress(self, fun, key=None): self._onkeypress(fun, key) def listen(self, xdummy=None, ydummy=None): - """Set focus on TurtleScreen (in order to collect key-events) + """Set focus on the TurtleScreen so that it receives key events. - No arguments. - Dummy arguments are provided in order - to be able to pass listen to the onclick method. + The two dummy arguments are only there so that listen() can be + passed to onclick(). - Example (for a TurtleScreen instance named screen): - >>> screen.listen() + Arguments: + xdummy -- ignored + ydummy -- ignored """ self._listen() def ontimer(self, fun, t=0): - """Install a timer, which calls fun after t milliseconds. + """Install a timer that calls fun after t milliseconds. Arguments: - fun -- a function with no arguments. - t -- a number >= 0 + fun -- a function with no arguments + t -- a nonnegative number Example (for a TurtleScreen instance named screen): - - >>> running = True - >>> def f(): - ... if running: - ... fd(50) - ... lt(60) - ... screen.ontimer(f, 250) - ... - >>> f() # makes the turtle marching around - >>> running = False + >>> running = True + >>> def f(): + ... if running: + ... fd(50) + ... lt(60) + ... screen.ontimer(f, 250) + ... + >>> f() # makes the turtle march around + >>> running = False """ self._ontimer(fun, t) def bgpic(self, picname=None): - """Set background image or return name of current backgroundimage. + """Set the background image or return the name of the current one. - Optional argument: - picname -- a string, name of an image file (PNG, GIF, PGM, and PPM) or "nopic". + If picname is the name of an image file (PNG, GIF, PGM, and PPM), + set that image as the background. If picname is "nopic", delete + the background image, if present. If picname is None, return the + filename of the current background image. - If picname is a filename, set the corresponding image as background. - If picname is "nopic", delete backgroundimage, if present. - If picname is None, return the filename of the current backgroundimage. + Argument: + picname -- a string or None Example (for a TurtleScreen instance named screen): - >>> screen.bgpic() - 'nopic' - >>> screen.bgpic("landscape.gif") - >>> screen.bgpic() - 'landscape.gif' + >>> screen.bgpic() + 'nopic' + >>> screen.bgpic("landscape.gif") + >>> screen.bgpic() + 'landscape.gif' """ if picname is None: return self._bgpicname @@ -1523,34 +1507,44 @@ def bgpic(self, picname=None): def screensize(self, canvwidth=None, canvheight=None, bg=None): """Resize the canvas the turtles are drawing on. - Optional arguments: - canvwidth -- positive integer, new width of canvas in pixels - canvheight -- positive integer, new height of canvas in pixels - bg -- colorstring or color-tuple, new backgroundcolor - If no arguments are given, return current (canvaswidth, canvasheight) + canvwidth and canvheight are the new width and height of the + canvas in pixels, and bg is the new background color. If no + arguments are given, return the current canvas width and height. - Do not alter the drawing window. To observe hidden parts of - the canvas use the scrollbars. (Can make visible those parts - of a drawing, which were outside the canvas before!) + The drawing window is not altered. To see hidden parts of the + canvas, use the scrollbars. This can make visible those parts of a + drawing which were outside the canvas before, for example to find + a turtle that has wandered off the canvas. - Example (for a Turtle instance named turtle): - >>> turtle.screensize(2000,1500) - >>> # e.g. to search for an erroneously escaped turtle ;-) + Arguments: + canvwidth -- a positive integer or None + canvheight -- a positive integer or None + bg -- a colorstring or None + + Example (for a TurtleScreen instance named screen): + >>> screen.screensize() + (400, 300) + >>> screen.screensize(2000,1500) + >>> screen.screensize() + (2000, 1500) """ return self._resize(canvwidth, canvheight, bg) def save(self, filename, *, overwrite=False): - """Save the drawing as a PostScript file + """Save the current drawing and the turtles as a PostScript file. - Arguments: - filename -- a string, the path of the created file. - Must end with '.ps' or '.eps'. + filename is the path of the file to create. It must end with + ".ps" or ".eps". If a file with that name already exists, a + FileExistsError is raised, unless overwrite is True. overwrite + must be given by name, as in overwrite=True. - Optional arguments: - overwrite -- boolean, if true, then existing files will be overwritten + Arguments: + filename -- a string + overwrite -- a boolean Example (for a TurtleScreen instance named screen): - >>> screen.save('my_drawing.eps') + >>> screen.save("my_drawing.ps") + >>> screen.save("my_drawing.ps", overwrite=True) """ filename = Path(filename) if not filename.parent.exists(): @@ -1572,20 +1566,26 @@ def save(self, filename, *, overwrite=False): postscript = self.cv.postscript() filename.write_text(postscript) + # Aliases for the commonly used commands: + onscreenclick = onclick resetscreen = reset clearscreen = clear addshape = register_shape onkeyrelease = onkey -class TNavigator(object): - """Navigation part of the RawTurtle. + +class TNavigator: + """The navigation part of RawTurtle. + Implements methods for turtle movement. """ + START_ORIENTATION = { "standard": Vec2D(1.0, 0.0), "world" : Vec2D(1.0, 0.0), - "logo" : Vec2D(0.0, 1.0) } + "logo" : Vec2D(0.0, 1.0), + } DEFAULT_MODE = "standard" DEFAULT_ANGLEOFFSET = 0 DEFAULT_ANGLEORIENT = 1 @@ -1601,16 +1601,15 @@ def __init__(self, mode=DEFAULT_MODE): TNavigator.reset(self) def reset(self): - """reset turtle to its initial values + """Reset the turtle to its initial values. - Will be overwritten by parent class + Will be overwritten by the child class. """ self._position = Vec2D(0.0, 0.0) self._orient = TNavigator.START_ORIENTATION[self._mode] def _setmode(self, mode=None): - """Set turtle-mode to 'standard', 'world' or 'logo'. - """ + """Set the turtle's mode to 'standard', 'world' or 'logo'.""" if mode is None: return self._mode if mode not in ["standard", "logo", "world"]: @@ -1624,7 +1623,7 @@ def _setmode(self, mode=None): self._angleOrient = -1 def _setDegreesPerAU(self, fullcircle): - """Helper function for degrees() and radians()""" + """Helper function for degrees() and radians().""" self._fullcircle = fullcircle self._degreesPerAU = 360/fullcircle if self._mode == "standard": @@ -1633,60 +1632,80 @@ def _setDegreesPerAU(self, fullcircle): self._angleOffset = fullcircle/4. def degrees(self, fullcircle=360.0): - """ Set angle measurement units to degrees. + """Set the angle measurement units to degrees. - Optional argument: - fullcircle - a number + The number of degrees in a full circle is set to fullcircle, which + defaults to 360. - Set angle measurement units, i. e. set number - of 'degrees' for a full circle. Default value is - 360 degrees. + Argument: + fullcircle -- a number Example (for a Turtle instance named turtle): - >>> turtle.left(90) - >>> turtle.heading() - 90 - - Change angle measurement unit to grad (also known as gon, - grade, or gradian and equals 1/100-th of the right angle.) - >>> turtle.degrees(400.0) - >>> turtle.heading() - 100 - + >>> turtle.home() + >>> turtle.left(90) + >>> turtle.heading() + 90.0 + + >>> # Change angle measurement unit to grad (also known as gon, + >>> # grade, or gradian and equals 1/100-th of the right angle.) + >>> turtle.degrees(400.0) + >>> turtle.heading() + 100.0 + >>> turtle.degrees(360) + >>> turtle.heading() + 90.0 """ self._setDegreesPerAU(fullcircle) def radians(self): - """ Set the angle measurement units to radians. + """Set the angle measurement units to radians. - No arguments. + Equivalent to degrees(2 * math.pi). Example (for a Turtle instance named turtle): - >>> turtle.heading() - 90 - >>> turtle.radians() - >>> turtle.heading() - 1.5707963267948966 + >>> turtle.home() + >>> turtle.left(90) + >>> turtle.heading() + 90.0 + >>> turtle.radians() + >>> turtle.heading() + 1.5707963267948966 """ self._setDegreesPerAU(math.tau) def _go(self, distance): - """move turtle forward by specified distance""" + """Move the turtle forward by the specified distance.""" ende = self._position + self._orient * distance self._goto(ende) def _rotate(self, angle): - """Turn turtle counterclockwise by specified angle if angle > 0.""" + """Turn the turtle counterclockwise by specified angle, if the angle > 0.""" angle *= self._degreesPerAU self._orient = self._orient.rotate(angle) def _goto(self, end): - """move turtle to position end.""" + """Move the turtle to the end position.""" self._position = end + @contextmanager + def _undo_sequence(self): + """Record the enclosed actions as a single undo step.""" + undobuffer = self.undobuffer + if not undobuffer or undobuffer.cumulate: + yield + return + undobuffer.push(["seq"]) + undobuffer.cumulate = True + try: + yield + finally: + undobuffer.cumulate = False + def teleport(self, x=None, y=None, *, fill_gap: bool = False) -> None: - """To be overwritten by child class RawTurtle. - Includes no TPen references.""" + """To be overwritten by the child class RawTurtle. + + Includes no TPen references. + """ new_x = x if x is not None else self._position[0] new_y = y if y is not None else self._position[1] self._position = Vec2D(new_x, new_y) @@ -1696,21 +1715,20 @@ def forward(self, distance): Aliases: forward | fd - Argument: - distance -- a number (integer or float) + The turtle moves in the direction it is headed. - Move the turtle forward by the specified distance, in the direction - the turtle is headed. + Argument: + distance -- a number Example (for a Turtle instance named turtle): - >>> turtle.position() - (0.00,0.00) - >>> turtle.forward(25) - >>> turtle.position() - (25.00,0.00) - >>> turtle.forward(-75) - >>> turtle.position() - (-50.00,0.00) + >>> turtle.position() + (0.00,0.00) + >>> turtle.forward(25) + >>> turtle.position() + (25.00,0.00) + >>> turtle.forward(-75) + >>> turtle.position() + (-50.00,0.00) """ self._go(distance) @@ -1719,134 +1737,125 @@ def back(self, distance): Aliases: back | backward | bk - Argument: - distance -- a number + The turtle moves opposite to the direction it is headed. + The turtle's heading does not change. - Move the turtle backward by distance, opposite to the direction the - turtle is headed. Do not change the turtle's heading. + Argument: + distance -- a number Example (for a Turtle instance named turtle): - >>> turtle.position() - (0.00,0.00) - >>> turtle.backward(30) - >>> turtle.position() - (-30.00,0.00) + >>> turtle.position() + (0.00,0.00) + >>> turtle.backward(30) + >>> turtle.position() + (-30.00,0.00) """ self._go(-distance) def right(self, angle): - """Turn turtle right by angle units. + """Turn the turtle right by the specified angle. Aliases: right | rt - Argument: - angle -- a number (integer or float) + The angle is measured in degrees by default; the unit can be + changed with degrees() or radians(). How the heading is measured + depends on the turtle mode, see mode(). - Turn turtle right by angle units. (Units are by default degrees, - but can be set via the degrees() and radians() functions.) - Angle orientation depends on mode. (See this.) + Argument: + angle -- a number Example (for a Turtle instance named turtle): - >>> turtle.heading() - 22.0 - >>> turtle.right(45) - >>> turtle.heading() - 337.0 + >>> turtle.heading() + 22.0 + >>> turtle.right(45) + >>> turtle.heading() + 337.0 """ self._rotate(-angle) def left(self, angle): - """Turn turtle left by angle units. + """Turn the turtle left by the specified angle. Aliases: left | lt - Argument: - angle -- a number (integer or float) + The angle is measured in degrees by default; the unit can be + changed with degrees() or radians(). How the heading is measured + depends on the turtle mode, see mode(). - Turn turtle left by angle units. (Units are by default degrees, - but can be set via the degrees() and radians() functions.) - Angle orientation depends on mode. (See this.) + Argument: + angle -- a number Example (for a Turtle instance named turtle): - >>> turtle.heading() - 22.0 - >>> turtle.left(45) - >>> turtle.heading() - 67.0 + >>> turtle.heading() + 22.0 + >>> turtle.left(45) + >>> turtle.heading() + 67.0 """ self._rotate(angle) def pos(self): - """Return the turtle's current location (x,y), as a Vec2D-vector. + """Return the turtle's current location (x,y) as a Vec2D vector. Aliases: pos | position - No arguments. - Example (for a Turtle instance named turtle): - >>> turtle.pos() - (0.00, 240.00) + >>> turtle.pos() + (0.00,240.00) """ return self._position def xcor(self): - """ Return the turtle's x coordinate. - - No arguments. + """Return the turtle's x coordinate. Example (for a Turtle instance named turtle): - >>> reset() - >>> turtle.left(60) - >>> turtle.forward(100) - >>> print(turtle.xcor()) - 50.0 + >>> turtle.home() + >>> turtle.left(50) + >>> turtle.forward(100) + >>> print(round(turtle.xcor(), 5)) + 64.27876 """ return self._position[0] def ycor(self): - """ Return the turtle's y coordinate - --- - No arguments. + """Return the turtle's y coordinate. Example (for a Turtle instance named turtle): - >>> reset() - >>> turtle.left(60) - >>> turtle.forward(100) - >>> print(turtle.ycor()) - 86.6025403784 + >>> turtle.home() + >>> turtle.left(60) + >>> turtle.forward(100) + >>> print(round(turtle.ycor(), 5)) + 86.60254 """ return self._position[1] def goto(self, x, y=None): - """Move turtle to an absolute position. + """Move the turtle to an absolute position. - Aliases: setpos | setposition | goto: + Aliases: goto | setpos | setposition - Arguments: - x -- a number or a pair/vector of numbers - y -- a number None + If y is None, x must be a pair of coordinates or a Vec2D, for + example as returned by pos(). If the pen is down, a line is drawn. + The turtle's heading does not change. - call: goto(x, y) # two coordinates - --or: goto((x, y)) # a pair (tuple) of coordinates - --or: goto(vec) # e.g. as returned by pos() - - Move turtle to an absolute position. If the pen is down, - a line will be drawn. The turtle's orientation does not change. + Arguments: + x -- a number or a pair of numbers + y -- a number or None Example (for a Turtle instance named turtle): - >>> tp = turtle.pos() - >>> tp - (0.00,0.00) - >>> turtle.setpos(60,30) - >>> turtle.pos() - (60.00,30.00) - >>> turtle.setpos((20,80)) - >>> turtle.pos() - (20.00,80.00) - >>> turtle.setpos(tp) - >>> turtle.pos() - (0.00,0.00) + >>> tp = turtle.pos() + >>> tp + (0.00,0.00) + >>> turtle.goto(60,30) + >>> turtle.pos() + (60.00,30.00) + >>> turtle.goto((20,80)) + >>> turtle.pos() + (20.00,80.00) + >>> turtle.goto(tp) + >>> turtle.pos() + (0.00,0.00) """ if y is None: self._goto(Vec2D(*x)) @@ -1854,76 +1863,79 @@ def goto(self, x, y=None): self._goto(Vec2D(x, y)) def home(self): - """Move turtle to the origin - coordinates (0,0). + """Move the turtle to the origin, coordinates (0,0). - No arguments. - - Move turtle to the origin - coordinates (0,0) and set its - heading to its start-orientation (which depends on mode). + The turtle's heading is set to its start orientation, which + depends on the turtle mode, see mode(). Example (for a Turtle instance named turtle): - >>> turtle.home() + >>> turtle.heading() + 90.0 + >>> turtle.position() + (0.00,-10.00) + >>> turtle.home() + >>> turtle.position() + (0.00,0.00) + >>> turtle.heading() + 0.0 """ self.goto(0, 0) self.setheading(0) def setx(self, x): - """Set the turtle's first coordinate to x + """Set the turtle's x coordinate to x. - Argument: - x -- a number (integer or float) + The y coordinate is unchanged. - Set the turtle's first coordinate to x, leave second coordinate - unchanged. + Argument: + x -- a number Example (for a Turtle instance named turtle): - >>> turtle.position() - (0.00, 240.00) - >>> turtle.setx(10) - >>> turtle.position() - (10.00, 240.00) + >>> turtle.position() + (0.00,240.00) + >>> turtle.setx(10) + >>> turtle.position() + (10.00,240.00) """ self._goto(Vec2D(x, self._position[1])) def sety(self, y): - """Set the turtle's second coordinate to y + """Set the turtle's y coordinate to y. - Argument: - y -- a number (integer or float) + The x coordinate is unchanged. - Set the turtle's first coordinate to x, second coordinate remains - unchanged. + Argument: + y -- a number Example (for a Turtle instance named turtle): - >>> turtle.position() - (0.00, 40.00) - >>> turtle.sety(-10) - >>> turtle.position() - (0.00, -10.00) + >>> turtle.position() + (0.00,40.00) + >>> turtle.sety(-10) + >>> turtle.position() + (0.00,-10.00) """ self._goto(Vec2D(self._position[0], y)) def distance(self, x, y=None): """Return the distance from the turtle to (x,y) in turtle step units. - Arguments: - x -- a number or a pair/vector of numbers or a turtle instance - y -- a number None None + If y is None, x must be a pair of coordinates, a Vec2D, for example + as returned by pos(), or another turtle. - call: distance(x, y) # two coordinates - --or: distance((x, y)) # a pair (tuple) of coordinates - --or: distance(vec) # e.g. as returned by pos() - --or: distance(mypen) # where mypen is another turtle + Arguments: + x -- a number or a pair of numbers or a turtle instance + y -- a number if x is a number, else None Example (for a Turtle instance named turtle): - >>> turtle.pos() - (0.00,0.00) - >>> turtle.distance(30,40) - 50.0 - >>> pen = Turtle() - >>> pen.forward(77) - >>> turtle.distance(pen) - 77.0 + >>> turtle.home() + >>> turtle.distance(30,40) + 50.0 + >>> turtle.distance((30,40)) + 50.0 + >>> joe = Turtle() + >>> joe.forward(77) + >>> turtle.distance(joe) + 77.0 """ if y is not None: pos = Vec2D(x, y) @@ -1936,26 +1948,21 @@ def distance(self, x, y=None): return abs(pos - self._position) def towards(self, x, y=None): - """Return the angle of the line from the turtle's position to (x, y). - - Arguments: - x -- a number or a pair/vector of numbers or a turtle instance - y -- a number None None + """Return the angle of the line from the turtle's position to (x,y). - call: distance(x, y) # two coordinates - --or: distance((x, y)) # a pair (tuple) of coordinates - --or: distance(vec) # e.g. as returned by pos() - --or: distance(mypen) # where mypen is another turtle + If y is None, x must be a pair of coordinates, a Vec2D, for example + as returned by pos(), or another turtle. The angle is measured from + the turtle's start orientation, which depends on the turtle mode, + see mode(). - Return the angle, between the line from turtle-position to position - specified by x, y and the turtle's start orientation. (Depends on - modes - "standard" or "logo") + Arguments: + x -- a number or a pair of numbers or a turtle instance + y -- a number if x is a number, else None Example (for a Turtle instance named turtle): - >>> turtle.pos() - (10.00, 10.00) - >>> turtle.towards(0,0) - 225.0 + >>> turtle.goto(10, 10) + >>> turtle.towards(0,0) + 225.0 """ if y is not None: pos = Vec2D(x, y) @@ -1971,14 +1978,15 @@ def towards(self, x, y=None): return (self._angleOffset + self._angleOrient*result) % self._fullcircle def heading(self): - """ Return the turtle's current heading. + """Return the turtle's current heading. - No arguments. + The value depends on the turtle mode, see mode(). Example (for a Turtle instance named turtle): - >>> turtle.left(67) - >>> turtle.heading() - 67.0 + >>> turtle.home() + >>> turtle.left(67) + >>> turtle.heading() + 67.0 """ x, y = self._orient result = round(math.degrees(math.atan2(y, x)), 10) % 360.0 @@ -1986,72 +1994,63 @@ def heading(self): return (self._angleOffset + self._angleOrient*result) % self._fullcircle def setheading(self, to_angle): - """Set the orientation of the turtle to to_angle. + """Set the turtle's heading to to_angle. - Aliases: setheading | seth + Aliases: setheading | seth - Argument: - to_angle -- a number (integer or float) - - Set the orientation of the turtle to to_angle. Here are some common directions in degrees: - standard - mode: logo-mode: - -------------------|-------------------- - 0 - east 0 - north - 90 - north 90 - east - 180 - west 180 - south - 270 - south 270 - west + standard mode logo mode + -------------------|--------------- + 0 - east 0 - north + 90 - north 90 - east + 180 - west 180 - south + 270 - south 270 - west + + Argument: + to_angle -- a number Example (for a Turtle instance named turtle): - >>> turtle.setheading(90) - >>> turtle.heading() - 90 + >>> turtle.setheading(90) + >>> turtle.heading() + 90.0 """ - angle = (to_angle - self.heading())*self._angleOrient + angle = (to_angle - self.heading()) * self._angleOrient full = self._fullcircle angle = (angle+full/2.)%full - full/2. self._rotate(angle) def circle(self, radius, extent = None, steps = None): - """ Draw a circle with given radius. + """Draw a circle with the given radius. - Arguments: - radius -- a number - extent (optional) -- a number - steps (optional) -- an integer - - Draw a circle with given radius. The center is radius units left - of the turtle; extent - an angle - determines which part of the - circle is drawn. If extent is not given, draw the entire circle. - If extent is not a full circle, one endpoint of the arc is the - current pen position. Draw the arc in counterclockwise direction - if radius is positive, otherwise in clockwise direction. Finally - the direction of the turtle is changed by the amount of extent. + The center is radius units left of the turtle; extent, an angle, + determines which part of the circle is drawn. If extent is not + given, draw the entire circle. If extent is not a full circle, one + endpoint of the arc is the current pen position. Draw the arc in + the counterclockwise direction if radius is positive, otherwise in + the clockwise direction. Finally, the turtle's heading is changed by + extent. As the circle is approximated by an inscribed regular polygon, - steps determines the number of steps to use. If not given, - it will be calculated automatically. Maybe used to draw regular + steps determines the number of steps to use. If not given, it + will be calculated automatically. May be used to draw regular polygons. - call: circle(radius) # full circle - --or: circle(radius, extent) # arc - --or: circle(radius, extent, steps) - --or: circle(radius, steps=6) # 6-sided polygon + Arguments: + radius -- a number + extent -- a number or None + steps -- an integer or None Example (for a Turtle instance named turtle): - >>> turtle.circle(50) - >>> turtle.circle(120, 180) # semicircle + >>> turtle.circle(50) + >>> turtle.circle(120, 180) # draw a semicircle """ - if self.undobuffer: - self.undobuffer.push(["seq"]) - self.undobuffer.cumulate = True speed = self.speed() if extent is None: extent = self._fullcircle if steps is None: frac = abs(extent)/self._fullcircle - steps = 1+int(min(11+abs(radius)/6.0, 59.0)*frac) + steps = 1 + int(min(11 + abs(radius) / 6.0, 59.0) * frac) w = 1.0 * extent / steps w2 = 0.5 * w l = 2.0 * radius * math.sin(math.radians(w2)*self._degreesPerAU) @@ -2059,31 +2058,32 @@ def circle(self, radius, extent = None, steps = None): l, w, w2 = -l, -w, -w2 tr = self._tracer() dl = self._delay() - if speed == 0: - self._tracer(0, 0) - else: - self.speed(0) - self._rotate(w2) - for i in range(steps): + with self._undo_sequence(): + if speed == 0: + self._tracer(0, 0) + else: + self.speed(0) + self._rotate(w2) + for i in range(steps): + self.speed(speed) + self._go(l) + self.speed(0) + self._rotate(w) + self._rotate(-w2) + if speed == 0: + self._tracer(tr, dl) self.speed(speed) - self._go(l) - self.speed(0) - self._rotate(w) - self._rotate(-w2) - if speed == 0: - self._tracer(tr, dl) - self.speed(speed) - if self.undobuffer: - self.undobuffer.cumulate = False -## three dummy methods to be implemented by child class: + # Three dummy methods to be implemented by the child class: def speed(self, s=0): - """dummy method - to be overwritten by child class""" + """Dummy method - to be overwritten by the child class.""" def _tracer(self, a=None, b=None): - """dummy method - to be overwritten by child class""" + """Dummy method - to be overwritten by the child class.""" def _delay(self, n=None): - """dummy method - to be overwritten by child class""" + """Dummy method - to be overwritten by the child class.""" + + # Aliases for the commonly used commands: fd = forward bk = back @@ -2096,10 +2096,12 @@ def _delay(self, n=None): seth = setheading -class TPen(object): +class TPen: """Drawing part of the RawTurtle. + Implements drawing properties. """ + def __init__(self, resizemode=_CFG["resizemode"]): self._resizemode = resizemode # or "user" or "noresize" self.undobuffer = None @@ -2120,26 +2122,29 @@ def _reset(self, pencolor=_CFG["pencolor"], self._outlinewidth = 1 def resizemode(self, rmode=None): - """Set resizemode to one of the values: "auto", "user", "noresize". - - (Optional) Argument: - rmode -- one of the strings "auto", "user", "noresize" - - Different resizemodes have the following effects: - - "auto" adapts the appearance of the turtle - corresponding to the value of pensize. - - "user" adapts the appearance of the turtle according to the - values of stretchfactor and outlinewidth (outline), - which are set by shapesize() - - "noresize" no adaption of the turtle's appearance takes place. - If no argument is given, return current resizemode. - resizemode("user") is called by a call of shapesize with arguments. - - - Examples (for a Turtle instance named turtle): - >>> turtle.resizemode("noresize") - >>> turtle.resizemode() - 'noresize' + """Set the resizemode to "auto", "user" or "noresize". + + If rmode is not given, return the current resizemode. The + different resizemodes have the following effects: + + - "auto": the turtle is resized according to the value of + pensize(). + - "user": the turtle is resized according to the stretch factors + and outline width, which are set by shapesize(). + - "noresize": the turtle is not resized. + + resizemode("user") is called by shapesize() when used with + arguments. + + Argument: + rmode -- a string or None + + Example (for a Turtle instance named turtle): + >>> turtle.resizemode() + 'noresize' + >>> turtle.resizemode("auto") + >>> turtle.resizemode() + 'auto' """ if rmode is None: return self._resizemode @@ -2148,103 +2153,105 @@ def resizemode(self, rmode=None): self.pen(resizemode=rmode) def pensize(self, width=None): - """Set or return the line thickness. + """Return or set the line thickness. - Aliases: pensize | width + Aliases: pensize | width - Argument: - width -- positive number + If width is not given, return the current pensize. If resizemode + is set to "auto" and the turtle shape is a polygon, that polygon is + drawn with the same line thickness. - Set the line thickness to width or return it. If resizemode is set - to "auto" and turtleshape is a polygon, that polygon is drawn with - the same line thickness. If no argument is given, current pensize - is returned. + Argument: + width -- a positive number or None Example (for a Turtle instance named turtle): - >>> turtle.pensize() - 1 - >>> turtle.pensize(10) # from here on lines of width 10 are drawn + >>> turtle.pensize() + 1 + >>> turtle.pensize(10) # from here on lines of width 10 are drawn """ if width is None: return self._pensize self.pen(pensize=width) - def penup(self): - """Pull the pen up -- no drawing when moving. + """Lift the pen. Aliases: penup | pu | up - No argument - - Example (for a Turtle instance named turtle): - >>> turtle.penup() + The turtle does not draw when it moves. """ if not self._drawing: return self.pen(pendown=False) def pendown(self): - """Pull the pen down -- drawing when moving. + """Lower the pen. Aliases: pendown | pd | down - No argument. - - Example (for a Turtle instance named turtle): - >>> turtle.pendown() + The turtle draws a line when it moves. """ if self._drawing: return self.pen(pendown=True) def isdown(self): - """Return True if pen is down, False if it's up. - - No argument. + """Return True if the pen is down, False if it's up. Example (for a Turtle instance named turtle): - >>> turtle.penup() - >>> turtle.isdown() - False - >>> turtle.pendown() - >>> turtle.isdown() - True + >>> turtle.penup() + >>> turtle.isdown() + False + >>> turtle.pendown() + >>> turtle.isdown() + True """ return self._drawing def speed(self, speed=None): - """ Return or set the turtle's speed. + """Return or set the turtle's speed. - Optional argument: - speed -- an integer in the range 0..10 or a speedstring (see below) + If speed is not given, return the current speed. Otherwise set the + turtle's speed to an integer from 0 to 10. A number above 0.5 and + below 10.5 is rounded to the nearest integer. Any other number sets + the speed to 0. You can also use these names instead of numbers: - Set the turtle's speed to an integer value in the range 0 .. 10. - If no argument is given: return current speed. + "fastest": 0 + "fast": 10 + "normal": 6 + "slow": 3 + "slowest": 1 - If input is a number greater than 10 or smaller than 0.5, - speed is set to 0. - Speedstrings are mapped to speedvalues in the following way: - 'fastest' : 0 - 'fast' : 10 - 'normal' : 6 - 'slow' : 3 - 'slowest' : 1 - speeds from 1 to 10 enforce increasingly faster animation of - line drawing and turtle turning. + Speeds from 1 to 10 give increasingly faster animation of line + drawing and turtle turning. A speed of 0 means that no animation + takes place: forward() and back() make the turtle jump, and + likewise left() and right() make the turtle turn instantly. - Attention: - speed = 0 : *no* animation takes place. forward/back makes turtle jump - and likewise left/right make the turtle turn instantly. + Argument: + speed -- an integer, a string or None Example (for a Turtle instance named turtle): - >>> turtle.speed(3) - """ - speeds = {'fastest':0, 'fast':10, 'normal':6, 'slow':3, 'slowest':1 } + >>> turtle.speed() + 3 + >>> turtle.speed('normal') + >>> turtle.speed() + 6 + >>> turtle.speed(9) + >>> turtle.speed() + 9 + """ + speed_strings = { + 'fastest': 0, + 'fast': 10, + 'normal': 6, + 'slow': 3, + 'slowest': 1, + } + if speed is None: return self._speed - if speed in speeds: - speed = speeds[speed] + if speed in speed_strings: + speed = speed_strings[speed] elif 0.5 < speed < 10.5: speed = int(round(speed)) else: @@ -2254,32 +2261,30 @@ def speed(self, speed=None): def color(self, *args): """Return or set the pencolor and fillcolor. - Arguments: - Several input formats are allowed. - They use 0 to 3 arguments as follows: + Several input formats are allowed. They use 0 to 3 arguments as follows: - color() Return the current pencolor and the current fillcolor as a pair of color specification strings or tuples as returned by pencolor() and fillcolor(). - color(colorstring), color((r,g,b)), color(r,g,b) - Inputs as in pencolor(), set both, fillcolor and pencolor, - to the given value. + Inputs as in pencolor(). Set both the pencolor and the + fillcolor to the given value. - color(colorstring1, colorstring2), color((r1,g1,b1), (r2,g2,b2)) Equivalent to pencolor(colorstring1) and fillcolor(colorstring2) and analogously if the other input format is used. - If turtleshape is a polygon, outline and interior of that polygon - is drawn with the newly set colors. - For more info see: pencolor, fillcolor + If the turtle shape is a polygon, the outline and interior of that + polygon are drawn with the newly set colors. For more information, + see pencolor() and fillcolor(). Example (for a Turtle instance named turtle): - >>> turtle.color('red', 'green') - >>> turtle.color() - ('red', 'green') - >>> colormode(255) - >>> color(('#285078', '#a0c8f0')) - >>> color() - ((40.0, 80.0, 120.0), (160.0, 200.0, 240.0)) + >>> turtle.color("red", "green") + >>> turtle.color() + ('red', 'green') + >>> colormode(255) + >>> turtle.color("#285078", "#a0c8f0") + >>> turtle.color() + ((40.0, 80.0, 120.0), (160.0, 200.0, 240.0)) """ if args: l = len(args) @@ -2296,37 +2301,36 @@ def color(self, *args): return self._color(self._pencolor), self._color(self._fillcolor) def pencolor(self, *args): - """ Return or set the pencolor. + """Return or set the pencolor. - Arguments: Four input formats are allowed: - pencolor() Return the current pencolor as color specification string or as a tuple (see example). May be used as input to another - color/pencolor/fillcolor/bgcolor call. + color(), pencolor(), fillcolor() or bgcolor() call. - pencolor(colorstring) - Set pencolor to colorstring, which is a Tk color + Set the pencolor to colorstring, which is a Tk color specification string, such as "red", "yellow", or "#33cc8c". - pencolor((r, g, b)) - Set pencolor to the RGB color represented by the tuple of - r, g, and b. Each of r, g, and b must be in the range - 0..colormode, where colormode is either 1.0 or 255 (see + Set the pencolor to the RGB color represented by the tuple of + r, g, and b. Each of r, g, and b must be between 0 and + colormode, where colormode is either 1.0 or 255 (see colormode()). - pencolor(r, g, b) - Set pencolor to the RGB color represented by r, g, and b. - Each of r, g, and b must be in the range 0..colormode. + Set the pencolor to the RGB color represented by r, g, and b. + Each of r, g, and b must be between 0 and colormode. - If turtleshape is a polygon, the outline of that polygon is drawn - with the newly set pencolor. + If the turtle shape is a polygon, the outline of that polygon is + drawn with the newly set pencolor. Example (for a Turtle instance named turtle): - >>> turtle.pencolor('brown') - >>> turtle.pencolor() - 'brown' - >>> colormode(255) - >>> turtle.pencolor('#32c18f') - >>> turtle.pencolor() - (50.0, 193.0, 143.0) + >>> turtle.pencolor("brown") + >>> turtle.pencolor() + 'brown' + >>> colormode(255) + >>> turtle.pencolor("#32c18f") + >>> turtle.pencolor() + (50.0, 193.0, 143.0) """ if args: color = self._colorstr(args) @@ -2337,37 +2341,36 @@ def pencolor(self, *args): return self._color(self._pencolor) def fillcolor(self, *args): - """ Return or set the fillcolor. + """Return or set the fillcolor. - Arguments: Four input formats are allowed: - fillcolor() Return the current fillcolor as color specification string, possibly in tuple format (see example). May be used as - input to another color/pencolor/fillcolor/bgcolor call. + input to another color(), pencolor(), fillcolor() or bgcolor() call. - fillcolor(colorstring) - Set fillcolor to colorstring, which is a Tk color + Set the fillcolor to colorstring, which is a Tk color specification string, such as "red", "yellow", or "#33cc8c". - fillcolor((r, g, b)) - Set fillcolor to the RGB color represented by the tuple of - r, g, and b. Each of r, g, and b must be in the range - 0..colormode, where colormode is either 1.0 or 255 (see + Set the fillcolor to the RGB color represented by the tuple of + r, g, and b. Each of r, g, and b must be between 0 and + colormode, where colormode is either 1.0 or 255 (see colormode()). - fillcolor(r, g, b) - Set fillcolor to the RGB color represented by r, g, and b. - Each of r, g, and b must be in the range 0..colormode. + Set the fillcolor to the RGB color represented by r, g, and b. + Each of r, g, and b must be between 0 and colormode. - If turtleshape is a polygon, the interior of that polygon is drawn - with the newly set fillcolor. + If the turtle shape is a polygon, the interior of that polygon is + drawn with the newly set fillcolor. Example (for a Turtle instance named turtle): - >>> turtle.fillcolor('violet') - >>> turtle.fillcolor() - 'violet' - >>> colormode(255) - >>> turtle.fillcolor('#ffffff') - >>> turtle.fillcolor() - (255.0, 255.0, 255.0) + >>> turtle.fillcolor("violet") + >>> turtle.fillcolor() + 'violet' + >>> colormode(255) + >>> turtle.fillcolor("#ffffff") + >>> turtle.fillcolor() + (255.0, 255.0, 255.0) """ if args: color = self._colorstr(args) @@ -2378,7 +2381,8 @@ def fillcolor(self, *args): return self._color(self._fillcolor) def teleport(self, x=None, y=None, *, fill_gap: bool = False) -> None: - """To be overwritten by child class RawTurtle. + """To be overwritten by the child class RawTurtle. + Includes no TNavigator references. """ pendown = self.isdown() @@ -2387,92 +2391,78 @@ def teleport(self, x=None, y=None, *, fill_gap: bool = False) -> None: self.pen(pendown=pendown) def showturtle(self): - """Makes the turtle visible. + """Make the turtle visible. Aliases: showturtle | st - - No argument. - - Example (for a Turtle instance named turtle): - >>> turtle.hideturtle() - >>> turtle.showturtle() """ self.pen(shown=True) def hideturtle(self): - """Makes the turtle invisible. + """Make the turtle invisible. Aliases: hideturtle | ht - No argument. - - It's a good idea to do this while you're in the - middle of a complicated drawing, because hiding - the turtle speeds up the drawing observably. - - Example (for a Turtle instance named turtle): - >>> turtle.hideturtle() + If the pen is down, movement still draws. """ self.pen(shown=False) def isvisible(self): - """Return True if the Turtle is shown, False if it's hidden. - - No argument. + """Return True if the turtle is visible, False if it's hidden. Example (for a Turtle instance named turtle): - >>> turtle.hideturtle() - >>> print(turtle.isvisible()) - False + >>> turtle.hideturtle() + >>> turtle.isvisible() + False + >>> turtle.showturtle() + >>> turtle.isvisible() + True """ return self._shown def pen(self, pen=None, **pendict): """Return or set the pen's attributes. + The attributes are returned as a dictionary with the following + keys and values: + + - "shown": True or False + - "pendown": True or False + - "pencolor": a color string or a color tuple + - "fillcolor": a color string or a color tuple + - "pensize": a positive number + - "speed": a number from 0 to 10 + - "resizemode": "auto", "user" or "noresize" + - "stretchfactor": a pair of positive numbers + - "shearfactor": a number + - "outline": a positive number + - "tilt": a number + + Such a dictionary can be passed as pen to restore a former pen + state. The attributes can also be given as keyword arguments, + which can be used to set several of them in one statement. + Arguments: - pen -- a dictionary with some or all of the below listed keys. - **pendict -- one or more keyword-arguments with the below - listed keys as keywords. - - Return or set the pen's attributes in a 'pen-dictionary' - with the following key/value pairs: - "shown" : True/False - "pendown" : True/False - "pencolor" : color-string or color-tuple - "fillcolor" : color-string or color-tuple - "pensize" : positive number - "speed" : number in range 0..10 - "resizemode" : "auto" or "user" or "noresize" - "stretchfactor": (positive number, positive number) - "shearfactor": number - "outline" : positive number - "tilt" : number - - This dictionary can be used as argument for a subsequent - pen()-call to restore the former pen-state. Moreover one - or more of these attributes can be provided as keyword-arguments. - This can be used to set several pen attributes in one statement. - - - Examples (for a Turtle instance named turtle): - >>> turtle.pen(fillcolor="black", pencolor="red", pensize=10) - >>> turtle.pen() - {'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1, - 'pencolor': 'red', 'pendown': True, 'fillcolor': 'black', - 'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0} - >>> penstate=turtle.pen() - >>> turtle.color("yellow","") - >>> turtle.penup() - >>> turtle.pen() - {'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1, - 'pencolor': 'yellow', 'pendown': False, 'fillcolor': '', - 'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0} - >>> p.pen(penstate, fillcolor="green") - >>> p.pen() - {'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1, - 'pencolor': 'red', 'pendown': True, 'fillcolor': 'green', - 'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0} + pen -- a dictionary or None + pendict -- keyword arguments with the keys above + + Example (for a Turtle instance named turtle): + >>> turtle.pen(fillcolor="black", pencolor="red", pensize=10) + >>> turtle.pen() + {'shown': True, 'pendown': True, 'pencolor': 'red', + 'fillcolor': 'black', 'pensize': 10, 'speed': 3, + 'resizemode': 'noresize', 'stretchfactor': (1.0, 1.0), + 'shearfactor': 0.0, 'outline': 1, 'tilt': 0.0} + >>> penstate = turtle.pen() + >>> turtle.color("yellow", "") + >>> turtle.penup() + >>> turtle.pen()["pencolor"] + 'yellow' + >>> # restore the saved pen state, but with a green fill + >>> turtle.pen(penstate, fillcolor="green") + >>> turtle.pen()["pencolor"] + 'red' + >>> turtle.pen()["fillcolor"] + 'green' """ _pd = {"shown" : self._shown, "pendown" : self._drawing, @@ -2552,16 +2542,18 @@ def pen(self, pen=None, **pendict): -scx*sa, scy*(ca - shf*sa)) self._update() -## three dummy methods to be implemented by child class: + # Three dummy methods to be implemented by the child class: def _newLine(self, usePos = True): - """dummy method - to be overwritten by child class""" + """Dummy method - to be overwritten by the child class.""" def _update(self, count=True, forced=False): - """dummy method - to be overwritten by child class""" + """Dummy method - to be overwritten by the child class.""" def _color(self, args): - """dummy method - to be overwritten by child class""" + """Dummy method - to be overwritten by the child class.""" def _colorstr(self, args): - """dummy method - to be overwritten by child class""" + """Dummy method - to be overwritten by the child class.""" + + # Aliases for the commonly used commands: width = pensize up = penup @@ -2572,9 +2564,8 @@ def _colorstr(self, args): ht = hideturtle -class _TurtleImage(object): - """Helper class: Datatype to store Turtle attributes - """ +class _TurtleImage: + """Helper class holding the canvas items that display a turtle's shape.""" def __init__(self, screen, shapeIndex): self.screen = screen @@ -2604,9 +2595,10 @@ def _setshape(self, shapeIndex): class RawTurtle(TPen, TNavigator): - """Animation part of the RawTurtle. - Puts RawTurtle upon a TurtleScreen and provides tools for - its animation. + """A turtle that draws on the given canvas or TurtleScreen. + + Combines the navigation part (TNavigator) and the drawing part (TPen) + and adds the animation of the turtle on the screen. """ screens = [] @@ -2629,7 +2621,7 @@ def __init__(self, canvas=None, self.screen = TurtleScreen(canvas) RawTurtle.screens.append(self.screen) else: - raise TurtleGraphicsError("bad canvas argument %s" % canvas) + raise TurtleGraphicsError(f"Bad canvas argument {canvas!r}") screen = self.screen TNavigator.__init__(self, screen.mode()) @@ -2651,23 +2643,22 @@ def __init__(self, canvas=None, self._update() def reset(self): - """Delete the turtle's drawings and restore its default values. + """Delete the turtle's drawings and re-center the turtle. - No argument. - - Delete the turtle's drawings from the screen, re-center the turtle - and set variables to the default values. + The turtle's settings are restored to their default values. Example (for a Turtle instance named turtle): - >>> turtle.position() - (0.00,-22.00) - >>> turtle.heading() - 100.0 - >>> turtle.reset() - >>> turtle.position() - (0.00,0.00) - >>> turtle.heading() - 0.0 + >>> turtle.goto(0,-22) + >>> turtle.left(100) + >>> turtle.position() + (0.00,-22.00) + >>> turtle.heading() + 100.0 + >>> turtle.reset() + >>> turtle.position() + (0.00,0.00) + >>> turtle.heading() + 0.0 """ TNavigator.reset(self) TPen._reset(self) @@ -2676,18 +2667,17 @@ def reset(self): self._update() def setundobuffer(self, size): - """Set or disable undobuffer. + """Set or disable the undo buffer. - Argument: - size -- an integer or None + If size is an integer, an empty undo buffer of the given size is + installed. size is the maximum number of turtle actions that can + be undone by undo(). If size is None, the undo buffer is disabled. - If size is an integer an empty undobuffer of given size is installed. - Size gives the maximum number of turtle-actions that can be undone - by the undo() function. - If size is None, no undobuffer is present. + Argument: + size -- an integer or None Example (for a Turtle instance named turtle): - >>> turtle.setundobuffer(42) + >>> turtle.setundobuffer(42) """ if size is None or size <= 0: self.undobuffer = None @@ -2695,20 +2685,18 @@ def setundobuffer(self, size): self.undobuffer = Tbuffer(size) def undobufferentries(self): - """Return count of entries in the undobuffer. - - No argument. + """Return the number of entries in the undo buffer. Example (for a Turtle instance named turtle): - >>> while undobufferentries(): - ... undo() + >>> while turtle.undobufferentries(): + ... turtle.undo() """ if self.undobuffer is None: return 0 return self.undobuffer.nr_of_items() def _clear(self): - """Delete all of pen's drawings""" + """Delete all of the pen's drawings.""" self._fillitem = self._fillpath = None for item in self.items: self.screen._delete(item) @@ -2722,16 +2710,10 @@ def _clear(self): def clear(self): - """Delete the turtle's drawings from the screen. Do not move turtle. - - No arguments. + """Delete the turtle's drawings from the screen. - Delete the turtle's drawings from the screen. Do not move turtle. - State and position of the turtle as well as drawings of other - turtles are not affected. - - Examples (for a Turtle instance named turtle): - >>> turtle.clear() + The state and position of the turtle as well as the drawings of + other turtles are not affected. """ self._clear() self._update() @@ -2745,8 +2727,7 @@ def _update_data(self): self._pencolor, self._pensize) def _update(self): - """Perform a Turtle-data update. - """ + """Perform a Turtle-data update.""" screen = self.screen if screen._tracing == 0: return @@ -2763,24 +2744,7 @@ def _update(self): screen._update() def _tracer(self, flag=None, delay=None): - """Turns turtle animation on/off and set delay for update drawings. - - Optional arguments: - n -- nonnegative integer - delay -- nonnegative integer - - If n is given, only each n-th regular screen update is really performed. - (Can be used to accelerate the drawing of complex graphics.) - Second arguments sets delay value (see RawTurtle.delay()) - - Example (for a Turtle instance named turtle): - >>> turtle.tracer(8, 25) - >>> dist = 2 - >>> for i in range(200): - ... turtle.fd(dist) - ... turtle.rt(90) - ... dist += 2 - """ + """Forward flag and delay to the screen's tracer() method.""" return self.screen.tracer(flag, delay) def _color(self, args): @@ -2790,8 +2754,7 @@ def _colorstr(self, args): return self.screen._colorstr(args) def _cc(self, args): - """Convert colortriples to hexstrings. - """ + """Convert colortriples to hexstrings.""" if isinstance(args, str): return args try: @@ -2805,64 +2768,60 @@ def _cc(self, args): return "#%02x%02x%02x" % (r, g, b) def teleport(self, x=None, y=None, *, fill_gap: bool = False) -> None: - """Instantly move turtle to an absolute position. + """Teleport, or instantly move, the turtle to an absolute position. + + Unlike goto(), no line is drawn. If x or y is not given, that + coordinate is kept as it is. The turtle's heading does not change. + + If the turtle is filling a shape, the shape drawn so far is + finished and filled before teleporting, and filling starts again + at the new position. Pass fill_gap=True to keep filling one shape + instead. The teleport then counts as an edge of the shape, as it + would with goto(). Arguments: - x -- a number or None - y -- a number None - fill_gap -- a boolean This argument must be specified by name. - - call: teleport(x, y) # two coordinates - --or: teleport(x) # teleport to x position, keeping y as is - --or: teleport(y=y) # teleport to y position, keeping x as is - --or: teleport(x, y, fill_gap=True) - # teleport but fill the gap in between - - Move turtle to an absolute position. Unlike goto(x, y), a line will not - be drawn. The turtle's orientation does not change. If currently - filling, the polygon(s) teleported from will be filled after leaving, - and filling will begin again after teleporting. This can be disabled - with fill_gap=True, which makes the imaginary line traveled during - teleporting act as a fill barrier like in goto(x, y). + x -- a number or None + y -- a number or None + fill_gap -- a boolean Example (for a Turtle instance named turtle): - >>> tp = turtle.pos() - >>> tp - (0.00,0.00) - >>> turtle.teleport(60) - >>> turtle.pos() - (60.00,0.00) - >>> turtle.teleport(y=10) - >>> turtle.pos() - (60.00,10.00) - >>> turtle.teleport(20, 30) - >>> turtle.pos() - (20.00,30.00) + >>> tp = turtle.pos() + >>> tp + (0.00,0.00) + >>> turtle.teleport(60) + >>> turtle.pos() + (60.00,0.00) + >>> turtle.teleport(y=10) + >>> turtle.pos() + (60.00,10.00) + >>> turtle.teleport(20, 30) + >>> turtle.pos() + (20.00,30.00) """ pendown = self.isdown() was_filling = self.filling() - if pendown: - self.pen(pendown=False) - if was_filling and not fill_gap: - self.end_fill() - new_x = x if x is not None else self._position[0] - new_y = y if y is not None else self._position[1] - self._position = Vec2D(new_x, new_y) - self.pen(pendown=pendown) - if was_filling and not fill_gap: - self.begin_fill() + with self._undo_sequence(): + if pendown: + self.pen(pendown=False) + if was_filling and not fill_gap: + self.end_fill() + new_x = x if x is not None else self._position[0] + new_y = y if y is not None else self._position[1] + if self.undobuffer: + self.undobuffer.push(("teleport", self._position)) + self._position = Vec2D(new_x, new_y) + self.pen(pendown=pendown) + if was_filling and not fill_gap: + self.begin_fill() def clone(self): """Create and return a clone of the turtle. - No argument. + The clone has the same position, heading and turtle properties. - Create and return a clone of the turtle with same position, heading - and turtle properties. - - Example (for a Turtle instance named mick): - mick = Turtle() - joe = mick.clone() + Example: + >>> leonel = Turtle() + >>> marco = leonel.clone() """ screen = self.screen self._newLine(self._drawing) @@ -2893,24 +2852,23 @@ def clone(self): return q def shape(self, name=None): - """Set turtle shape to shape with given name / return current shapename. + """Set the turtle shape to the named shape. - Optional argument: - name -- a string, which is a valid shapename + If name is not given, return the name of the current shape. The + shape must exist in the TurtleScreen's shape list. Initially + there are the following shapes: "arrow", "turtle", "circle", + "square", "triangle" and "classic". To add shapes, see the Screen + method register_shape(). - Set turtle shape to shape with given name or, if name is not given, - return name of current shape. - Shape with name must exist in the TurtleScreen's shape dictionary. - Initially there are the following polygon shapes: - 'arrow', 'turtle', 'circle', 'square', 'triangle', 'classic'. - To learn about how to deal with shapes see Screen-method register_shape. + Argument: + name -- a string or None Example (for a Turtle instance named turtle): - >>> turtle.shape() - 'arrow' - >>> turtle.shape("turtle") - >>> turtle.shape() - 'turtle' + >>> turtle.shape() + 'classic' + >>> turtle.shape("turtle") + >>> turtle.shape() + 'turtle' """ if name is None: return self.turtle.shapeIndex @@ -2920,25 +2878,39 @@ def shape(self, name=None): self._update() def shapesize(self, stretch_wid=None, stretch_len=None, outline=None): - """Set/return turtle's stretchfactors/outline. Set resizemode to "user". - - Optional arguments: - stretch_wid : positive number - stretch_len : positive number - outline : positive number - - Return or set the pen's attributes x/y-stretchfactors and/or outline. - Set resizemode to "user". - If and only if resizemode is set to "user", the turtle will be displayed - stretched according to its stretchfactors: - stretch_wid is stretchfactor perpendicular to orientation - stretch_len is stretchfactor in direction of turtles orientation. - outline determines the width of the shapes's outline. - - Examples (for a Turtle instance named turtle): - >>> turtle.resizemode("user") - >>> turtle.shapesize(5, 5, 12) - >>> turtle.shapesize(outline=8) + """Return or set the turtle's stretch factors and outline width. + + Aliases: shapesize | turtlesize + + If no arguments are given, return the current values. Otherwise + set resizemode to "user", so that the turtle is displayed + stretched according to its stretch factors: + + - stretch_wid: the stretch factor perpendicular to the turtle's + heading + - stretch_len: the stretch factor in the direction of the + turtle's heading + - outline: the width of the shape's outline + + For example, shapesize(2, 1) makes the turtle twice as wide + without changing its length. If only stretch_wid is given, + stretch_len is set to the same value. + + Arguments: + stretch_wid -- a positive number or None + stretch_len -- a positive number or None + outline -- a positive number or None + + Example (for a Turtle instance named turtle): + >>> turtle.shapesize() + (1.0, 1.0, 1) + >>> turtle.resizemode("user") + >>> turtle.shapesize(5, 5, 12) + >>> turtle.shapesize() + (5, 5, 12) + >>> turtle.shapesize(outline=8) + >>> turtle.shapesize() + (5, 5, 8) """ if stretch_wid is stretch_len is outline is None: stretch_wid, stretch_len = self._stretchfactor @@ -2960,55 +2932,60 @@ def shapesize(self, stretch_wid=None, stretch_len=None, outline=None): stretchfactor=stretchfactor, outline=outline) def shearfactor(self, shear=None): - """Set or return the current shearfactor. - - Optional argument: shear -- number, tangent of the shear angle - - Shear the turtleshape according to the given shearfactor shear, - which is the tangent of the shear angle. DO NOT change the - turtle's heading (direction of movement). - If shear is not given: return the current shearfactor, i. e. the - tangent of the shear angle, by which lines parallel to the - heading of the turtle are sheared. - - Examples (for a Turtle instance named turtle): - >>> turtle.shape("circle") - >>> turtle.shapesize(5,2) - >>> turtle.shearfactor(0.5) - >>> turtle.shearfactor() - >>> 0.5 + """Return or set the current shear factor. + + Shearing slants the turtle shape, like the slant of italic + letters. The shear factor says how much it is slanted: 0 is not + slanted at all, and the larger the number, the stronger the + slant. Negative numbers slant the other way. If shear is not + given, return the current shear factor. Otherwise slant the + turtle shape accordingly and set resizemode to "user". The + turtle's heading does not change. Precisely, the shear factor is + the tangent of the shear angle. + + Argument: + shear -- a number or None + + Example (for a Turtle instance named turtle): + >>> turtle.shape("circle") + >>> turtle.shapesize(5,2) + >>> turtle.shearfactor(0.5) + >>> turtle.shearfactor() + 0.5 """ if shear is None: return self._shearfactor self.pen(resizemode="user", shearfactor=shear) def tiltangle(self, angle=None): - """Set or return the current tilt-angle. - - Optional argument: angle -- number - - Rotate the turtleshape to point in the direction specified by angle, - regardless of its current tilt-angle. DO NOT change the turtle's - heading (direction of movement). - If angle is not given: return the current tilt-angle, i. e. the angle - between the orientation of the turtleshape and the heading of the - turtle (its direction of movement). - - Examples (for a Turtle instance named turtle): - >>> turtle.shape("circle") - >>> turtle.shapesize(5, 2) - >>> turtle.tiltangle() - 0.0 - >>> turtle.tiltangle(45) - >>> turtle.tiltangle() - 45.0 - >>> turtle.stamp() - >>> turtle.fd(50) - >>> turtle.tiltangle(-45) - >>> turtle.tiltangle() - 315.0 - >>> turtle.stamp() - >>> turtle.fd(50) + """Return or set the current tilt angle. + + The tilt angle is the angle between the direction the turtle shape + points in and the direction the turtle moves in. Normally the + shape points in the direction of movement, so the tilt angle is + 0. If angle is given, turn the turtle shape to that tilt angle, no + matter what it was before, and set resizemode to "user". The + turtle's heading does not change. If angle is not given, return + the current tilt angle. + + Argument: + angle -- a number or None + + Example (for a Turtle instance named turtle): + >>> turtle.shape("circle") + >>> turtle.shapesize(5, 2) + >>> turtle.tiltangle() + 0.0 + >>> turtle.tiltangle(45) + >>> turtle.tiltangle() + 45.0 + >>> stamp_id = turtle.stamp() + >>> turtle.fd(50) + >>> turtle.tiltangle(-45) + >>> turtle.tiltangle() + 315.0 + >>> stamp_id = turtle.stamp() + >>> turtle.fd(50) """ if angle is None: tilt = -math.degrees(self._tilt) * self._angleOrient @@ -3019,43 +2996,47 @@ def tiltangle(self, angle=None): self.pen(resizemode="user", tilt=tilt) def tilt(self, angle): - """Rotate the turtleshape by angle. + """Turn the turtle shape by angle from its current tilt angle. + + The turtle's heading does not change, so the turtle keeps moving + in the same direction. See tiltangle(). Argument: - angle - a number - - Rotate the turtleshape by angle from its current tilt-angle, - but do NOT change the turtle's heading (direction of movement). - - Examples (for a Turtle instance named turtle): - >>> turtle.shape("circle") - >>> turtle.shapesize(5,2) - >>> turtle.tilt(30) - >>> turtle.fd(50) - >>> turtle.tilt(30) - >>> turtle.fd(50) + angle -- a number + + Example (for a Turtle instance named turtle): + >>> turtle.shape("circle") + >>> turtle.shapesize(5,2) + >>> turtle.tilt(30) + >>> turtle.fd(50) + >>> turtle.tilt(30) + >>> turtle.fd(50) """ self.tiltangle(angle + self.tiltangle()) def shapetransform(self, t11=None, t12=None, t21=None, t22=None): - """Set or return the current transformation matrix of the turtle shape. - - Optional arguments: t11, t12, t21, t22 -- numbers. - - If none of the matrix elements are given, return the transformation - matrix. - Otherwise set the given elements and transform the turtleshape - according to the matrix consisting of first row t11, t12 and - second row t21, 22. - Modify stretchfactor, shearfactor and tiltangle according to the - given matrix. - - Examples (for a Turtle instance named turtle): - >>> turtle.shape("square") - >>> turtle.shapesize(4,2) - >>> turtle.shearfactor(-0.5) - >>> turtle.shapetransform() - (4.0, -1.0, -0.0, 2.0) + """Return or set the transformation matrix of the turtle shape. + + The matrix combines the stretch factors, the shear factor and the + tilt angle of the turtle shape into four numbers: t11 and t12 form + its first row, t21 and t22 its second. If none of them are given, + return the current matrix as a tuple of four numbers. Otherwise + set the given elements and update the stretch factors, shear + factor and tilt angle accordingly. t11 * t22 - t12 * t21 must not + be zero, otherwise an error is raised. + + Arguments: + t11 -- a number or None + t12 -- a number or None + t21 -- a number or None + t22 -- a number or None + + Example (for a Turtle instance named turtle): + >>> turtle.shape("square") + >>> turtle.shapesize(4,2) + >>> turtle.shearfactor(-0.5) + >>> turtle.shapetransform() + (4.0, -1.0, -0.0, 2.0) """ if t11 is t12 is t21 is t22 is None: return self._shapetrafo @@ -3090,21 +3071,21 @@ def _polytrafo(self, poly): for (x, y) in poly] def get_shapepoly(self): - """Return the current shape polygon as tuple of coordinate pairs. + """Return the points that form the outline of the current turtle shape + as a tuple of (x, y) coordinate pairs. - No argument. - - Examples (for a Turtle instance named turtle): - >>> turtle.shape("square") - >>> turtle.shapetransform(4, -1, 0, 2) - >>> turtle.get_shapepoly() - ((50, -20), (30, 20), (-50, 20), (-30, -20)) + These points can be used to define a new shape or parts of a + compound shape. + Example (for a Turtle instance named turtle): + >>> turtle.shape("square") + >>> turtle.shapetransform(4, -1, 0, 2) + >>> turtle.get_shapepoly() + ((50, -20), (30, 20), (-50, 20), (-30, -20)) """ shape = self.screen._shapes[self.turtle.shapeIndex] if shape._type == "polygon": return self._getshapepoly(shape._data, shape._type == "compound") - # else return None def _getshapepoly(self, polygon, compound=False): """Calculate transformed shape polygon according to resizemode @@ -3120,8 +3101,9 @@ def _getshapepoly(self, polygon, compound=False): return tuple((t11*x + t12*y, t21*x + t22*y) for (x, y) in polygon) def _drawturtle(self): - """Manages the correct rendering of the turtle with respect to - its shape, resizemode, stretch and tilt etc.""" + """Draw the turtle according to its shape, resizemode, stretch + factors and tilt, or hide it if it is not shown. + """ screen = self.screen shape = screen._shapes[self.turtle.shapeIndex] ttype = shape._type @@ -3160,19 +3142,15 @@ def _drawturtle(self): ############################## stamp stuff ############################### def stamp(self): - """Stamp a copy of the turtleshape onto the canvas and return its id. + """Stamp a copy of the turtle shape onto the canvas and return its id. - No argument. - - Stamp a copy of the turtle shape onto the canvas at the current - turtle position. Return a stamp_id for that stamp, which can be - used to delete it by calling clearstamp(stamp_id). + The stamp is placed at the current turtle position. The returned + id can be used to delete the stamp with clearstamp(). Example (for a Turtle instance named turtle): - >>> turtle.color("blue") - >>> turtle.stamp() - 13 - >>> turtle.fd(50) + >>> turtle.color("blue") + >>> stamp_id = turtle.stamp() + >>> turtle.fd(50) """ screen = self.screen shape = screen._shapes[self.turtle.shapeIndex] @@ -3180,9 +3158,12 @@ def stamp(self): tshape = shape._data if ttype == "polygon": stitem = screen._createpoly() - if self._resizemode == "noresize": w = 1 - elif self._resizemode == "auto": w = self._pensize - else: w =self._outlinewidth + if self._resizemode == "noresize": + w = 1 + elif self._resizemode == "auto": + w = self._pensize + else: + w =self._outlinewidth shape = self._polytrafo(self._getshapepoly(tshape)) fc, oc = self._fillcolor, self._pencolor screen._drawpoly(stitem, shape, fill=fc, outline=oc, @@ -3201,12 +3182,12 @@ def stamp(self): screen._drawpoly(item, poly, fill=self._cc(fc), outline=self._cc(oc), width=self._outlinewidth, top=True) self.stampItems.append(stitem) - self.undobuffer.push(("stamp", stitem)) + if self.undobuffer: + self.undobuffer.push(("stamp", stitem)) return stitem def _clearstamp(self, stampid): - """does the work for clearstamp() and clearstamps() - """ + """Does the work for clearstamp() and clearstamps().""" if stampid in self.stampItems: if isinstance(stampid, tuple): for subitem in stampid: @@ -3216,48 +3197,44 @@ def _clearstamp(self, stampid): self.stampItems.remove(stampid) # Delete stampitem from undobuffer if necessary # if clearstamp is called directly. - item = ("stamp", stampid) - buf = self.undobuffer - if item not in buf.buffer: - return - index = buf.buffer.index(item) - buf.buffer.remove(item) - if index <= buf.ptr: - buf.ptr = (buf.ptr - 1) % buf.bufsize - buf.buffer.insert((buf.ptr+1)%buf.bufsize, [None]) + if self.undobuffer: + self.undobuffer.remove(("stamp", stampid)) def clearstamp(self, stampid): - """Delete stamp with given stampid + """Delete the stamp with the given stampid. + + stampid must be the return value of a previous stamp() call. Argument: - stampid - an integer, must be return value of previous stamp() call. + stampid -- an integer Example (for a Turtle instance named turtle): - >>> turtle.color("blue") - >>> astamp = turtle.stamp() - >>> turtle.fd(50) - >>> turtle.clearstamp(astamp) + >>> turtle.color("blue") + >>> astamp = turtle.stamp() + >>> turtle.fd(50) + >>> turtle.clearstamp(astamp) """ self._clearstamp(stampid) self._update() def clearstamps(self, n=None): - """Delete all or first/last n of turtle's stamps. + """Delete all or the first or last n of the turtle's stamps. - Optional argument: - n -- an integer + If n is not given, delete all stamps. If n is positive, delete the + first n stamps. If n is negative, delete the last n stamps, so -2 + deletes the last two. - If n is None, delete all of pen's stamps, - else if n > 0 delete first n stamps - else if n < 0 delete last n stamps. + Argument: + n -- an integer or None Example (for a Turtle instance named turtle): - >>> for i in range(8): - ... turtle.stamp(); turtle.fd(30) - ... - >>> turtle.clearstamps(2) - >>> turtle.clearstamps(-2) - >>> turtle.clearstamps() + >>> for i in range(8): + ... unused_stamp_id = turtle.stamp() + ... turtle.fd(30) + ... + >>> turtle.clearstamps(2) + >>> turtle.clearstamps(-2) + >>> turtle.clearstamps() """ if n is None: toDelete = self.stampItems[:] @@ -3323,13 +3300,13 @@ def _goto(self, end): self._update() #count=True) def _undogoto(self, entry): - """Reverse a _goto. Used for undo() - """ + """Reverse a _goto(). Used for undo().""" old, new, go_modes, coodata = entry drawing, pc, ps, filling = go_modes cLI, cL, pl, items = coodata screen = self.screen if abs(self._position - new) > 0.5: + # XXX(Stan): Figure out what on earth this is. print ("undogoto: HALLO-DA-STIMMT-WAS-NICHT!") # restore former situation self.currentLineItem = cLI @@ -3388,8 +3365,7 @@ def _undogoto(self, entry): self._update() #count=True) def _rotate(self, angle): - """Turns pen clockwise by angle. - """ + """Turn the turtle counterclockwise by angle.""" if self.undobuffer: self.undobuffer.push(("rot", angle, self._degreesPerAU)) angle *= self._degreesPerAU @@ -3406,9 +3382,10 @@ def _rotate(self, angle): self._update() def _newLine(self, usePos=True): - """Closes current line item and starts a new one. - Remark: if current line became too long, animation - performance (via _drawline) slowed down considerably. + """Closes the current line item and starts a new one. + + If the current line becomes too long, animation performance (via _drawline) + can slow down considerably. """ if len(self.currentLine) > 1: self.screen._drawline(self.currentLineItem, self.currentLine, @@ -3422,30 +3399,32 @@ def _newLine(self, usePos=True): self.currentLine = [self._position] def filling(self): - """Return fillstate (True if filling, False else). - - No argument. + """Return True if the turtle is filling, False otherwise. Example (for a Turtle instance named turtle): - >>> turtle.begin_fill() - >>> if turtle.filling(): - ... turtle.pensize(5) - ... else: - ... turtle.pensize(3) + >>> turtle.begin_fill() + >>> if turtle.filling(): + ... turtle.pensize(5) + ... else: + ... turtle.pensize(3) """ return isinstance(self._fillpath, list) @contextmanager def fill(self): - """A context manager for filling a shape. - - Implicitly ensures the code block is wrapped with - begin_fill() and end_fill(). + """Fill the shape drawn in the with block. Example (for a Turtle instance named turtle): - >>> turtle.color("black", "red") - >>> with turtle.fill(): - ... turtle.circle(60) + >>> turtle.color("black", "red") + >>> with turtle.fill(): + ... turtle.circle(80) + + fill() is a context manager, so using it is the same as calling + begin_fill() before the block and end_fill() after it: + >>> turtle.color("black", "red") + >>> turtle.begin_fill() + >>> turtle.circle(80) + >>> turtle.end_fill() """ self.begin_fill() try: @@ -3454,15 +3433,15 @@ def fill(self): self.end_fill() def begin_fill(self): - """Called just before drawing a shape to be filled. + """Call just before drawing a shape to be filled. - No argument. + The shape is filled by the next call to end_fill(). Example (for a Turtle instance named turtle): - >>> turtle.color("black", "red") - >>> turtle.begin_fill() - >>> turtle.circle(60) - >>> turtle.end_fill() + >>> turtle.color("black", "red") + >>> turtle.begin_fill() + >>> turtle.circle(80) + >>> turtle.end_fill() """ if not self.filling(): self._fillitem = self.screen._createpoly() @@ -3474,15 +3453,17 @@ def begin_fill(self): self._update() def end_fill(self): - """Fill the shape drawn after the call begin_fill(). + """Fill the shape drawn after the last call to begin_fill(). - No argument. + If the shape crosses itself or several shapes overlap, whether the + overlapping parts are filled depends on the operating system, the + type of overlap and how many there are. Example (for a Turtle instance named turtle): - >>> turtle.color("black", "red") - >>> turtle.begin_fill() - >>> turtle.circle(60) - >>> turtle.end_fill() + >>> turtle.color("black", "red") + >>> turtle.begin_fill() + >>> turtle.circle(80) + >>> turtle.end_fill() """ if self.filling(): if len(self._fillpath) > 2: @@ -3494,18 +3475,19 @@ def end_fill(self): self._update() def dot(self, size=None, *color): - """Draw a dot with diameter size, using color. + """Draw a circular dot with diameter size, using color. - Optional arguments: - size -- an integer >= 1 (if given) - color -- a colorstring or a numeric color tuple + If size is not given, the larger of pensize + 4 and 2 * pensize is + used. If color is not given, the current pencolor is used. - Draw a circular dot with diameter size, using color. - If size is not given, the maximum of pensize+4 and 2*pensize is used. + Arguments: + size -- a positive integer or None + color -- a colorstring or a numeric color tuple Example (for a Turtle instance named turtle): - >>> turtle.dot() - >>> turtle.fd(50); turtle.dot(20, "blue"); turtle.fd(50) + >>> turtle.home() + >>> turtle.dot() + >>> turtle.fd(50); turtle.dot(20, "blue"); turtle.fd(50) """ if not color: if isinstance(size, (str, tuple)): @@ -3521,24 +3503,19 @@ def dot(self, size=None, *color): color = self._colorstr(color) # If screen were to gain a dot function, see GH #104218. pen = self.pen() - if self.undobuffer: - self.undobuffer.push(["seq"]) - self.undobuffer.cumulate = True - try: - if self.resizemode() == 'auto': - self.ht() - self.pendown() - self.pensize(size) - self.pencolor(color) - self.forward(0) - finally: - self.pen(pen) - if self.undobuffer: - self.undobuffer.cumulate = False + with self._undo_sequence(): + try: + if self.resizemode() == 'auto': + self.ht() + self.pendown() + self.pensize(size) + self.pencolor(color) + self.forward(0) + finally: + self.pen(pen) def _write(self, txt, align, font): - """Performs the writing for write() - """ + """Performs the writing for write().""" item, end = self.screen._write(self._position, txt, align, font, self._pencolor) self._update() @@ -3550,46 +3527,47 @@ def _write(self, txt, align, font): def write(self, arg, move=False, align="left", font=("Arial", 8, "normal")): """Write text at the current turtle position. - Arguments: - arg -- info, which is to be written to the TurtleScreen - move (optional) -- True/False - align (optional) -- one of the strings "left", "center" or right" - font (optional) -- a triple (fontname, fontsize, fonttype) + The text is the string representation of arg. align is one of + the strings "left", "center" or "right" and says how the text is + placed relative to the turtle position. font is a triple of font + name, font size and font type. If move is True, the pen is moved + to the bottom-right corner of the text. - Write text - the string representation of arg - at the current - turtle position according to align ("left", "center" or right") - and with the given font. - If move is True, the pen is moved to the bottom-right corner - of the text. By default, move is False. + Arguments: + arg -- an object + move -- a boolean + align -- a string + font -- a tuple of a string, an integer and a string Example (for a Turtle instance named turtle): - >>> turtle.write('Home = ', True, align="center") - >>> turtle.write((0,0), True) + >>> turtle.write("Home = ", True, align="center") + >>> turtle.write((0,0), True) """ - if self.undobuffer: - self.undobuffer.push(["seq"]) - self.undobuffer.cumulate = True - end = self._write(str(arg), align.lower(), font) - if move: - x, y = self.pos() - self.setpos(end, y) - if self.undobuffer: - self.undobuffer.cumulate = False + with self._undo_sequence(): + end = self._write(str(arg), align.lower(), font) + if move: + x, y = self.pos() + self.setpos(end, y) @contextmanager def poly(self): - """A context manager for recording the vertices of a polygon. - - Implicitly ensures that the code block is wrapped with - begin_poly() and end_poly() - - Example (for a Turtle instance named turtle) where we create a - triangle as the polygon and move the turtle 100 steps forward: - >>> with turtle.poly(): - ... for side in range(3) - ... turtle.forward(50) - ... turtle.right(60) - >>> turtle.forward(100) + """Record the vertices of a polygon drawn in the with block. + + The first and last vertices will be connected. + + Example (for a Turtle instance named turtle): + >>> with turtle.poly(): + ... turtle.forward(100) + ... turtle.right(60) + ... turtle.forward(100) + + poly() is a context manager, so using it is the same as calling + begin_poly() before the block and end_poly() after it: + >>> turtle.begin_poly() + >>> turtle.forward(100) + >>> turtle.right(60) + >>> turtle.forward(100) + >>> turtle.end_poly() """ self.begin_poly() try: @@ -3600,13 +3578,7 @@ def poly(self): def begin_poly(self): """Start recording the vertices of a polygon. - No argument. - - Start recording the vertices of a polygon. Current turtle position - is first point of polygon. - - Example (for a Turtle instance named turtle): - >>> turtle.begin_poly() + The current turtle position is the first vertex of the polygon. """ self._poly = [self._position] self._creatingPoly = True @@ -3614,59 +3586,56 @@ def begin_poly(self): def end_poly(self): """Stop recording the vertices of a polygon. - No argument. - - Stop recording the vertices of a polygon. Current turtle position is - last point of polygon. This will be connected with the first point. - - Example (for a Turtle instance named turtle): - >>> turtle.end_poly() + The current turtle position is the last vertex of the polygon. + This will be connected with the first vertex. """ self._creatingPoly = False def get_poly(self): - """Return the lastly recorded polygon. - - No argument. + """Return the last recorded polygon. Example (for a Turtle instance named turtle): - >>> p = turtle.get_poly() - >>> turtle.register_shape("myFavouriteShape", p) - """ - ## check if there is any poly? + >>> turtle.home() + >>> turtle.begin_poly() + >>> turtle.fd(100) + >>> turtle.left(20) + >>> turtle.fd(30) + >>> turtle.left(60) + >>> turtle.fd(50) + >>> turtle.end_poly() + >>> p = turtle.get_poly() + >>> register_shape("myFavouriteShape", p) + """ + # Check if there are any poly? if self._poly is not None: return tuple(self._poly) def getscreen(self): - """Return the TurtleScreen object, the turtle is drawing on. - - No argument. + """Return the TurtleScreen object the turtle is drawing on. - Return the TurtleScreen object, the turtle is drawing on. So TurtleScreen-methods can be called for that object. Example (for a Turtle instance named turtle): - >>> ts = turtle.getscreen() - >>> ts - - >>> ts.bgcolor("pink") + >>> ts = turtle.getscreen() + >>> ts + + >>> ts.bgcolor("pink") """ return self.screen def getturtle(self): - """Return the Turtleobject itself. + """Return the Turtle object itself. - No argument. + Aliases: getturtle | getpen - Only reasonable use: as a function to return the 'anonymous turtle': + Call getturtle() to get the turtle used by functions such as + forward() and left(). Example: - >>> pet = getturtle() - >>> pet.fd(50) - >>> pet - - >>> turtles() - [] + >>> pet = getturtle() + >>> pet.fd(50) + >>> pet + """ return self @@ -3678,80 +3647,91 @@ def getturtle(self): ################################################################ def _delay(self, delay=None): - """Set delay value which determines speed of turtle animation. - """ + """Set the delay which determines the speed of turtle animation.""" return self.screen.delay(delay) def onclick(self, fun, btn=1, add=None): - """Bind fun to mouse-click event on this turtle on canvas. + """Bind fun to mouse-click events on this turtle. + + fun is called with the coordinates of the clicked point on the + canvas. If fun is None, existing bindings are removed. btn is the + number of the mouse button and defaults to 1, the left mouse + button. If add is True, a new binding is added, otherwise it + replaces a previous binding. Arguments: - fun -- a function with two arguments, to which will be assigned - the coordinates of the clicked point on the canvas. - btn -- number of the mouse-button defaults to 1 (left mouse button). - add -- True or False. If True, new binding will be added, otherwise - it will replace a former binding. - - Example for the anonymous turtle, i. e. the procedural way: - - >>> def turn(x, y): - ... left(360) - ... - >>> onclick(turn) # Now clicking into the turtle will turn it. - >>> onclick(None) # event-binding will be removed + fun -- a function with two arguments or None + btn -- an integer + add -- a boolean or None + + Example for the anonymous turtle, that is, the procedural way: + >>> def turn(x, y): + ... left(180) + ... + >>> onclick(turn) # Now clicking into the turtle will turn it. + >>> onclick(None) # event-binding will be removed """ self.screen._onclick(self.turtle._item, fun, btn, add) self._update() def onrelease(self, fun, btn=1, add=None): - """Bind fun to mouse-button-release event on this turtle on canvas. + """Bind fun to mouse-button-release events on this turtle. + + fun is called with the coordinates of the point on the canvas + where the mouse button is released. If fun is None, existing + bindings are removed. btn is the number of the mouse button and + defaults to 1, the left mouse button. If add is True, a new + binding is added, otherwise it replaces a previous binding. Arguments: - fun -- a function with two arguments, to which will be assigned - the coordinates of the clicked point on the canvas. - btn -- number of the mouse-button defaults to 1 (left mouse button). + fun -- a function with two arguments or None + btn -- an integer + add -- a boolean or None Example (for a MyTurtle instance named joe): - >>> class MyTurtle(Turtle): - ... def glow(self,x,y): - ... self.fillcolor("red") - ... def unglow(self,x,y): - ... self.fillcolor("") - ... - >>> joe = MyTurtle() - >>> joe.onclick(joe.glow) - >>> joe.onrelease(joe.unglow) - - Clicking on joe turns fillcolor red, unclicking turns it to - transparent. + >>> class MyTurtle(Turtle): + ... def glow(self,x,y): + ... self.fillcolor("red") + ... + ... def unglow(self,x,y): + ... self.fillcolor("") + ... + >>> joe = MyTurtle() + >>> joe.onclick(joe.glow) + >>> joe.onrelease(joe.unglow) + + Clicking on joe turns its fill color red, releasing the mouse button + turns it transparent again. """ self.screen._onrelease(self.turtle._item, fun, btn, add) self._update() def ondrag(self, fun, btn=1, add=None): - """Bind fun to mouse-move event on this turtle on canvas. + """Bind fun to mouse-move events on this turtle. - Arguments: - fun -- a function with two arguments, to which will be assigned - the coordinates of the clicked point on the canvas. - btn -- number of the mouse-button defaults to 1 (left mouse button). + fun is called with the coordinates of the mouse pointer on the + canvas. If fun is None, existing bindings are removed. btn is the + number of the mouse button and defaults to 1, the left mouse + button. If add is True, a new binding is added, otherwise it + replaces a previous binding. Every sequence of mouse-move events on + a turtle is preceded by a mouse-click event on that turtle. - Every sequence of mouse-move-events on a turtle is preceded by a - mouse-click event on that turtle. + Arguments: + fun -- a function with two arguments or None + btn -- an integer + add -- a boolean or None Example (for a Turtle instance named turtle): - >>> turtle.ondrag(turtle.goto) + >>> turtle.ondrag(turtle.goto) - Subsequently clicking and dragging a Turtle will move it - across the screen thereby producing handdrawings (if pen is - down). + Clicking and dragging the turtle then moves it across the screen, + drawing by hand if the pen is down. """ self.screen._ondrag(self.turtle._item, fun, btn, add) def _undo(self, action, data): - """Does the main part of the work for undo() - """ + """Does the main part of the work for undo().""" if self.undobuffer is None: return if action == "rot": @@ -3763,6 +3743,9 @@ def _undo(self, action, data): self.clearstamp(stitem) elif action == "go": self._undogoto(data) + elif action == "teleport": + self._position = data[0] + self._update() elif action in ["wri", "dot"]: item = data[0] self.screen._delete(item) @@ -3782,21 +3765,19 @@ def _undo(self, action, data): self.undobuffer.pop() def undo(self): - """undo (repeatedly) the last turtle action. - - No argument. + """Undo the last turtle action. - undo (repeatedly) the last turtle action. - Number of available undo actions is determined by the size of - the undobuffer. + Calling undo() repeatedly undoes one action at a time. The number + of actions that can be undone is set by the size of the undo + buffer, see setundobuffer(). Example (for a Turtle instance named turtle): - >>> for i in range(4): - ... turtle.fd(50); turtle.lt(80) - ... - >>> for i in range(8): - ... turtle.undo() - ... + >>> for i in range(4): + ... turtle.fd(50); turtle.lt(80) + ... + >>> for i in range(8): + ... turtle.undo() + ... """ if self.undobuffer is None: return @@ -3817,9 +3798,10 @@ def undo(self): ### Screen - Singleton ######################## def Screen(): - """Return the singleton screen object. - If none exists at the moment, create a new one and return it, - else return the existing one.""" + """Return the single screen object. + + If it does not exist yet, create it. Otherwise return the existing one. + """ if Turtle._screen is None: Turtle._screen = _Screen() return Turtle._screen @@ -3849,28 +3831,32 @@ def __init__(self): def setup(self, width=_CFG["width"], height=_CFG["height"], startx=_CFG["leftright"], starty=_CFG["topbottom"]): - """ Set the size and position of the main window. + """Set the size and position of the main window. - Arguments: - width: as integer a size in pixels, as float a fraction of the screen. - Default is 50% of screen. - height: as integer the height in pixels, as float a fraction of the - screen. Default is 75% of screen. - startx: if positive, starting position in pixels from the left - edge of the screen, if negative from the right edge - Default, startx=None is to center window horizontally. - starty: if positive, starting position in pixels from the top - edge of the screen, if negative from the bottom edge - Default, starty=None is to center window vertically. + width and height are the size of the window. As integers they are + sizes in pixels, as floats they are fractions of the screen, so + 0.5 is half the screen. The defaults are 50% of the screen width + and 75% of its height. - Examples (for a Screen instance named screen): - >>> screen.setup (width=200, height=200, startx=0, starty=0) + startx and starty are the position of the window. If positive, + they are the distance in pixels from the left and top edges of the + screen, if negative from the right and bottom edges. If None, the + window is centered in that direction. - sets window to 200x200 pixels, in upper left of screen + The default values of all arguments are stored in the + configuration dictionary and can be changed with a turtle.cfg file. - >>> screen.setup(width=.75, height=0.5, startx=None, starty=None) + Arguments: + width -- an integer or a float + height -- an integer or a float + startx -- an integer or None + starty -- an integer or None - sets window to 75% of screen by 50% of screen and centers + Example (for a Screen instance named screen): + >>> screen.setup(width=200, height=200, startx=0, starty=0) + >>> # sets window to 200x200 pixels, in upper left of screen + >>> screen.setup(width=0.75, height=0.5) + >>> # sets window to 75% of screen by 50% of screen and centers """ if not hasattr(self._root, "set_geometry"): return @@ -3888,17 +3874,17 @@ def setup(self, width=_CFG["width"], height=_CFG["height"], self.update() def title(self, titlestring): - """Set title of turtle-window + """Set the title of the turtle window to titlestring. - Argument: - titlestring -- a string, to appear in the titlebar of the - turtle graphics window. + The title is shown in the title bar of the turtle graphics window. + This is a method of the Screen class. It is not available for + TurtleScreen objects. - This is a method of Screen-class. Not available for TurtleScreen- - objects. + Argument: + titlestring -- a string Example (for a Screen instance named screen): - >>> screen.title("Welcome to the turtle-zoo!") + >>> screen.title("Welcome to the turtle zoo!") """ if _Screen._root is not None: _Screen._root.title(titlestring) @@ -3915,31 +3901,18 @@ def _destroy(self): root.destroy() def bye(self): - """Shut the turtlegraphics window. - - Example (for a TurtleScreen instance named screen): - >>> screen.bye() - """ + """Close the turtle graphics window.""" self._destroy() def exitonclick(self): - """Go into mainloop until the mouse is clicked. - - No arguments. - - Bind bye() method to mouseclick on TurtleScreen. - If "using_IDLE" - value in configuration dictionary is False - (default value), enter mainloop. - If IDLE with -n switch (no subprocess) is used, this value should be - set to True in turtle.cfg. In this case IDLE's mainloop - is active also for the client script. + """Bind bye() to mouse clicks on the screen and start the event loop. - This is a method of the Screen-class and not available for - TurtleScreen instances. - - Example (for a Screen instance named screen): - >>> screen.exitonclick() + Clicking on the screen then closes the turtle graphics window. If + the configuration value using_IDLE is True, the event loop is not + started, see mainloop(). + This is a method of the Screen class. It is not available for + TurtleScreen objects. """ def exitGracefully(x, y): """Screen.bye() with two dummy-parameters""" @@ -3975,16 +3948,15 @@ def __init__(self, Pen = Turtle def write_docstringdict(filename="turtle_docstringdict"): - """Create and write docstring-dictionary to file. + """Write the docstring dictionary to a Python script. - Optional argument: - filename -- a string, used as filename - default value is turtle_docstringdict + The dictionary is written to the file filename.py. It is intended to + serve as a template for translating the docstrings into different + languages. This function has to be called explicitly. It is not used + by the turtle graphics classes. - Has to be called explicitly, (not used by the turtle-graphics classes) - The docstring dictionary will be written to the Python script .py - It is intended to serve as a template for translation of the docstrings - into different languages. + Argument: + filename -- a string """ docsdict = {} @@ -4009,23 +3981,29 @@ def write_docstringdict(filename="turtle_docstringdict"): f.close() def read_docstrings(lang): - """Read in docstrings from lang-specific docstring dictionary. + """Read in docstrings from a language-specific docstring dictionary. Transfer docstrings, translated to lang, from a dictionary-file to the methods of classes Screen and Turtle and - in revised form - to the corresponding functions. + + Entries naming a method which does not exist in this version are + ignored. """ - modname = "turtle_docstringdict_%(language)s" % {'language':lang.lower()} - module = __import__(modname) + module = __import__(f"turtle_docstringdict_{lang.lower()}") docsdict = module.docsdict for key in docsdict: try: # eval(key).im_func.__doc__ = docsdict[key] eval(key).__doc__ = docsdict[key] + except AttributeError: + pass except Exception: print("Bad docstring-entry: %s" % key) _LANGUAGE = _CFG["language"] +if not sys.flags.ignore_environment: + _LANGUAGE = environ.get("PYTHON_TURTLE_LANG") or _LANGUAGE try: if _LANGUAGE != "english": @@ -4038,10 +4016,10 @@ def read_docstrings(lang): def getmethparlist(ob): - """Get strings describing the arguments for the given object + """Get strings describing the arguments for the given object. Returns a pair of strings representing function parameter lists - including parenthesis. The first string is suitable for use in + including parentheses. The first string is suitable for use in function definition and the second is suitable for use in function call. The "self" parameter is not included. """ @@ -4074,8 +4052,7 @@ def getmethparlist(ob): return str(func_sig), call_text def _turtle_docrevise(docstr): - """To reduce docstrings from RawTurtle class for functions - """ + """To reduce docstrings from the RawTurtle class for functions.""" import re if docstr is None: return None @@ -4086,8 +4063,7 @@ def _turtle_docrevise(docstr): return newdocstr def _screen_docrevise(docstr): - """To reduce docstrings from TurtleScreen class for functions - """ + """To reduce docstrings from the TurtleScreen class for functions.""" import re if docstr is None: return None diff --git a/Lib/turtledemo/__main__.py b/Lib/turtledemo/__main__.py index 7c2d753f4c31113..cffc08f59b99d26 100644 --- a/Lib/turtledemo/__main__.py +++ b/Lib/turtledemo/__main__.py @@ -333,7 +333,7 @@ def loadfile(self, filename): modname = 'turtledemo.' + filename __import__(modname) self.module = sys.modules[modname] - with open(self.module.__file__, 'r') as f: + with open(self.module.__file__, encoding='utf-8') as f: chars = f.read() self.text.delete("1.0", "end") self.text.insert("1.0", chars) diff --git a/Lib/turtledemo/sorting_animate.py b/Lib/turtledemo/sorting_animate.py index e0a2877cd5d621a..8bfaa74b719c6b5 100644 --- a/Lib/turtledemo/sorting_animate.py +++ b/Lib/turtledemo/sorting_animate.py @@ -178,7 +178,6 @@ def enable_keys(): onkey(start_ssort, "s") onkey(start_qsort, "q") onkey(randomize, "r") - onkey(bye, "space") def main(): getscreen().clearscreen() @@ -191,7 +190,7 @@ def main(): return "EVENTLOOP" instructions1 = "press i for insertion sort, s for selection sort, q for quicksort" -instructions2 = "spacebar to quit, r to randomize" +instructions2 = "r to randomize" if __name__=="__main__": msg = main() diff --git a/Lib/typing.py b/Lib/typing.py index 933336ff4cf37e2..b8545cae052e6f9 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -19,11 +19,13 @@ """ from abc import abstractmethod, ABCMeta +import atexit import collections from collections import defaultdict import collections.abc import copyreg import functools +import keyword import operator import sys import types @@ -121,7 +123,6 @@ 'TextIO', # One-off things. - 'AnyStr', 'assert_type', 'assert_never', 'cast', @@ -392,6 +393,16 @@ def _flatten_literal_params(parameters): _caches = {} +def _clear_caches(): + for cleanup in _cleanups: + cleanup() + + +# Release the LRU caches at shutdown, they otherwise redistribute reference +# leaks of one extension to types of unrelated ones. See GH-151728. +atexit.register(_clear_caches) + + def _tp_cache(func=None, /, *, typed=False): """Internal wrapper caching __getitem__ of generic types. @@ -463,6 +474,9 @@ def _eval_type(t, globalns, localns, type_params, *, recursive_guard=frozenset() type_params=type_params, owner=owner, _recursive_guard=recursive_guard, format=format) if isinstance(t, (_GenericAlias, GenericAlias, Union)): + if isinstance(t, _LiteralGenericAlias): + # Unlike other generic aliases, Literal arguments aren't type expressions + return t if isinstance(t, GenericAlias): args = tuple( _make_forward_ref(arg, parent_fwdref=parent_fwdref) if isinstance(arg, str) else arg @@ -483,7 +497,7 @@ def _eval_type(t, globalns, localns, type_params, *, recursive_guard=frozenset() if isinstance(t, GenericAlias): return _rebuild_generic_alias(t, ev_args) if isinstance(t, Union): - return functools.reduce(operator.or_, ev_args) + return Union[ev_args] else: return t.copy_with(ev_args) return t @@ -775,13 +789,16 @@ def open_helper(file: str, mode: MODE) -> str: # There is no '_type_check' call because arguments to Literal[...] are # values, not types. parameters = _flatten_literal_params(parameters) + value_and_type_parameters = list(_value_and_type_iter(parameters)) + deduplicated_parameters = tuple( + p + for p, _ in _deduplicate( + value_and_type_parameters, + unhashable_fallback=True, + ) + ) - try: - parameters = tuple(p for p, _ in _deduplicate(list(_value_and_type_iter(parameters)))) - except TypeError: # unhashable parameters - pass - - return _LiteralGenericAlias(self, parameters) + return _LiteralGenericAlias(self, deduplicated_parameters) @_SpecialForm @@ -984,8 +1001,12 @@ def _make_forward_ref(code, *, parent_fwdref=None, **kwargs): if parent_fwdref.__owner__ is not None: kwargs['owner'] = parent_fwdref.__owner__ forward_ref = annotationlib.ForwardRef(code, **kwargs) - # For compatibility, eagerly compile the forwardref's code. - forward_ref.__forward_code__ + # For compatibility, eagerly compile the forwardref's code so that any + # SyntaxError is raised immediately rather than when the forward + # reference is evaluated. Similar to 'ForwardRef.evaluate()', we only compile + # it if necessary: + if not (code.isidentifier() and not keyword.iskeyword(code)): + forward_ref.__forward_code__ return forward_ref @@ -2532,7 +2553,7 @@ def _strip_annotations(t): stripped_args = tuple(_strip_annotations(a) for a in t.__args__) if stripped_args == t.__args__: return t - return functools.reduce(operator.or_, stripped_args) + return Union[stripped_args] return t @@ -2818,11 +2839,6 @@ class Disjoint3(Disjoint1, Disjoint2): pass # Type checker error CT_co = TypeVar('CT_co', covariant=True, bound=type) -# A useful type variable with constraints. This represents string types. -# (This one *is* for export!) -AnyStr = TypeVar('AnyStr', bytes, str) - - # Various ABCs mimicking those in collections.abc. _alias = _SpecialGenericAlias @@ -3526,8 +3542,9 @@ def __ror__(self, other): # Constant that's True when type checking, but False here. TYPE_CHECKING = False - -class IO(Generic[AnyStr]): +# Since `AnyStr` public API is deprecated since 3.16 and will be removed +# in 3.21, we need to keep `IO` protocol the same as it used to be: +class IO[AnyStr: (bytes, str)]: """Generic base class for TextIO and BinaryIO. This is an abstract, generic version of the return of open(). @@ -3927,6 +3944,20 @@ def __subclasscheck__(self, cls): ) return ByteString + elif attr == "AnyStr": + import warnings + + warnings._deprecated( + "typing.AnyStr", + message=( + "{name!r} is deprecated and slated for removal " + "in Python {remove}. Use PEP 695 type parameters " + "with constraints instead" + ), + remove=(3, 21), + ) + AnyStr = globals()["AnyStr"] = TypeVar('AnyStr', bytes, str) + return AnyStr else: raise AttributeError(f"module {__name__!r} has no attribute {attr!r}") globals()[attr] = obj diff --git a/Lib/unittest/main.py b/Lib/unittest/main.py index 6eeebf9657a3c7b..850c825a7366579 100644 --- a/Lib/unittest/main.py +++ b/Lib/unittest/main.py @@ -161,9 +161,12 @@ def _initArgParsers(self): def _getParentArgParser(self): parser = argparse.ArgumentParser(add_help=False) + # Counted, not a constant: the namespace is the TestProgram, whose + # verbosity is already 1, so -v still gives 2 and -vv gives 3. parser.add_argument('-v', '--verbose', dest='verbosity', - action='store_const', const=2, - help='Verbose output') + action='count', default=1, + help='Verbose output, twice to also report ' + 'the examples of a doctest') parser.add_argument('-q', '--quiet', dest='verbosity', action='store_const', const=0, help='Quiet output') diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index 49011faaa51eaed..d3d47ff81e85969 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -35,7 +35,7 @@ import threading from annotationlib import Format from dataclasses import fields, is_dataclass -from types import CodeType, ModuleType, MethodType +from types import CodeType, LazyImportType, ModuleType, MethodType from unittest.util import safe_repr from functools import wraps, partial from threading import RLock @@ -595,7 +595,7 @@ def __set_return_value(self, value): __return_value_doc = "The value to be returned when the mock is called." return_value = property(__get_return_value, __set_return_value, - __return_value_doc) + doc=__return_value_doc) @property @@ -798,7 +798,7 @@ def __dir__(self): from_type = [e for e in from_type if not e.startswith('_')] from_dict = [e for e in from_dict if not e.startswith('_') or _is_magic(e)] - return sorted(set(extras + from_type + from_dict + from_child_mocks)) + return sorted({*extras, *from_type, *from_dict, *from_child_mocks}) def __setattr__(self, name, value): @@ -1507,6 +1507,10 @@ def __enter__(self): original, local = self.get_original() + if (isinstance(original, LazyImportType) + and (spec is True or spec_set is True or autospec is True)): + original = original.resolve() + if new is DEFAULT and autospec is None: inherit = False if spec is True: diff --git a/Lib/unittest/result.py b/Lib/unittest/result.py index b8ea396db6772ed..a787686a5bea4ce 100644 --- a/Lib/unittest/result.py +++ b/Lib/unittest/result.py @@ -37,6 +37,9 @@ class TestResult(object): _moduleSetUpFailed = False def __init__(self, stream=None, descriptions=None, verbosity=None): self.failfast = False + # How much the test runner reports: 0 -- quiet, 1 -- progress dots, + # 2 -- test names, 3 -- also the examples of a doctest. + self.verbosity = 1 if verbosity is None else verbosity self.failures = [] self.errors = [] self.testsRun = 0 diff --git a/Lib/unittest/runner.py b/Lib/unittest/runner.py index 893fcba968c3ef8..f19d7b6e446d2ac 100644 --- a/Lib/unittest/runner.py +++ b/Lib/unittest/runner.py @@ -244,6 +244,9 @@ def run(self, test): result.failfast = self.failfast result.buffer = self.buffer result.tb_locals = self.tb_locals + # Not left to _makeResult(): a result class is free to filter the + # verbosity which its constructor gets. + result.verbosity = self.verbosity with warnings.catch_warnings(): if self.warnings: # if self.warnings is set, use it to filter all the warnings diff --git a/Lib/urllib/error.py b/Lib/urllib/error.py index beb32d0df48610d..cc9a9254d760f7f 100644 --- a/Lib/urllib/error.py +++ b/Lib/urllib/error.py @@ -11,6 +11,7 @@ response. """ import io +import sys import urllib.response __all__ = ['URLError', 'HTTPError', 'ContentTooShortError'] @@ -27,6 +28,13 @@ def __init__(self, reason, filename=None): self.reason = reason if filename is not None: self.filename = filename + if isinstance(reason, OSError): + # OSError.__init__() is not called, so copy the attributes + # it would have set from the wrapped error (gh-50720). + self.errno = reason.errno + self.strerror = reason.strerror + if sys.platform == 'win32': + self.winerror = reason.winerror def __str__(self): return '' % self.reason diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index 4247b9a4b07fa3f..f6c94060054e48f 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -125,6 +125,13 @@ def _coerce_args(*args): # - encoding function otherwise str_input = None for arg in args: + if not (arg is None or isinstance(arg, str) or hasattr(arg, 'decode')): + if arg: + raise TypeError("Expected str, bytes or None, " + f"not {type(arg).__name__}") + warnings.warn(f"Accepting {type(arg).__name__} objects with false " + f"value in urllib.parse is deprecated as of 3.16", + DeprecationWarning, stacklevel=3) if arg: if str_input is None: str_input = isinstance(arg, str) @@ -140,6 +147,27 @@ def _coerce_args(*args): return args + (_noop,) return _decode_args(args) + (_encode_result,) +def _parse_hostinfo(netloc): + _, _, hostinfo = netloc.rpartition('@') + _, have_open_br, bracketed = hostinfo.partition('[') + if have_open_br: + hostname, _, port = bracketed.partition(']') + _, _, port = port.partition(':') + else: + hostname, _, port = hostinfo.partition(':') + if not port: + port = None + return hostname, port + +def _validate_port(port): + if port.isdigit() and port.isascii(): + port = int(port) + else: + raise ValueError(f"Port could not be cast to integer value as {port!r}") + if not (0 <= port <= 65535): + raise ValueError("Port out of range 0-65535") + return port + # Result objects are more helpful than simple tuples class _ResultMixinStr(object): """Standard approach to encoding parsed results from str to bytes""" @@ -198,12 +226,7 @@ def hostname(self): def port(self): port = self._hostinfo[1] if port is not None: - if port.isdigit() and port.isascii(): - port = int(port) - else: - raise ValueError(f"Port could not be cast to integer value as {port!r}") - if not (0 <= port <= 65535): - raise ValueError("Port out of range 0-65535") + port = _validate_port(port) return port __class_getitem__ = classmethod(types.GenericAlias) @@ -231,16 +254,7 @@ def _hostinfo(self): netloc = self.netloc if netloc is None: return None, None - _, _, hostinfo = netloc.rpartition('@') - _, have_open_br, bracketed = hostinfo.partition('[') - if have_open_br: - hostname, _, port = bracketed.partition(']') - _, _, port = port.partition(':') - else: - hostname, _, port = hostinfo.partition(':') - if not port: - port = None - return hostname, port + return _parse_hostinfo(netloc) class _NetlocResultMixinBytes(_NetlocResultMixinBase, _ResultMixinBytes): @@ -506,9 +520,7 @@ def _splitnetloc(url, start=0): delim = min(delim, wdelim) # use earliest delim position return url[start:delim], url[delim:] # return (domain, rest) -def _checknetloc(netloc): - if not netloc or netloc.isascii(): - return +def _checknetloc_nfkc(netloc): # looking for characters like \u2100 that expand to 'a/c' # IDNA uses NFKC equivalence, so normalize for this check import unicodedata @@ -524,6 +536,16 @@ def _checknetloc(netloc): raise ValueError("netloc '" + netloc + "' contains invalid " + "characters under NFKC normalization") +def _checknetloc(netloc): + if not netloc: + return + if not netloc.isascii(): + _checknetloc_nfkc(netloc) + + _, port = _parse_hostinfo(netloc) + if port is not None: + _validate_port(port) + def _check_bracketed_netloc(netloc): # Note that this function must mirror the splitting # done in NetlocResultMixins._hostinfo(). @@ -697,12 +719,12 @@ def _urlunsplit(scheme, netloc, url, query, fragment): def urljoin(base, url, allow_fragments=True): """Join a base URL and a possibly relative URL to form an absolute interpretation of the latter.""" + base, url, _coerce_result = _coerce_args(base, url) if not base: - return url + return _coerce_result(url) if not url: - return base + return _coerce_result(base) - base, url, _coerce_result = _coerce_args(base, url) bscheme, bnetloc, bpath, bquery, bfragment = \ _urlsplit(base, None, allow_fragments) scheme, netloc, path, query, fragment = \ diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 660301fef612588..26c27fd5b2c3ab6 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -101,7 +101,8 @@ from urllib.parse import ( urlparse, urlsplit, urljoin, unwrap, quote, unquote, _splittype, _splithost, _splitport, _splituser, _splitpasswd, - _splitattr, _splitvalue, _splittag, + _splitattr, _splitvalue, _splittag, _splitnetloc, + _WHATWG_C0_CONTROL_OR_SPACE, _UNSAFE_URL_BYTES_TO_REMOVE, unquote_to_bytes, urlunparse) from urllib.response import addinfourl, addclosehook @@ -274,7 +275,7 @@ def request_host(request): """ url = request.full_url - host = urlparse(url)[1] + host = urlparse(url).netloc if host == "": host = request.get_header("Host", "") @@ -356,8 +357,10 @@ def get_full_url(self): return self.full_url def set_proxy(self, host, type): - if self.type == 'https' and not self._tunnel_host: - self._tunnel_host = self.host + if self.type == 'https': + # A retried request keeps the tunnel host set on the first pass. + if not self._tunnel_host: + self._tunnel_host = self.host else: self.type= type self.selector = self.full_url @@ -815,16 +818,17 @@ def add_password(self, realm, uri, user, passwd): self.passwd[realm] = {} for default_port in True, False: reduced_uri = tuple( - self.reduce_uri(u, default_port) for u in uri) + self._reduce_uri_with_scheme(u, default_port) for u in uri) self.passwd[realm][reduced_uri] = (user, passwd) def find_user_password(self, realm, authuri): domains = self.passwd.get(realm, {}) for default_port in True, False: - reduced_authuri = self.reduce_uri(authuri, default_port) + reduced_authuri = self._reduce_uri_with_scheme( + authuri, default_port) for uris, authinfo in domains.items(): for uri in uris: - if self.is_suburi(uri, reduced_authuri): + if self._is_suburi_with_scheme(uri, reduced_authuri): return authinfo return None, None @@ -832,11 +836,11 @@ def reduce_uri(self, uri, default_port=True): """Accept authority or URI and extract only the authority and path.""" # note HTTP URLs do not have a userinfo component parts = urlsplit(uri) - if parts[1]: + if parts.netloc: # URI - scheme = parts[0] - authority = parts[1] - path = parts[2] or '/' + scheme = parts.scheme + authority = parts.netloc + path = parts.path or '/' else: # host or host:port scheme = None @@ -851,6 +855,17 @@ def reduce_uri(self, uri, default_port=True): authority = "%s:%d" % (host, dport) return authority, path + def _reduce_uri_with_scheme(self, uri, default_port=True): + parts = urlsplit(uri) + scheme = parts[0] if parts[1] else None + return (scheme or None, *self.reduce_uri(uri, default_port)) + + def _is_suburi_with_scheme(self, base, test): + if (base[0] is not None and test[0] is not None and + base[0] != test[0]): + return False + return self.is_suburi(base[1:], test[1:]) + def is_suburi(self, base, test): """Check if test is below base in a URI tree @@ -896,14 +911,15 @@ def update_authenticated(self, uri, is_authenticated=False): for default_port in True, False: for u in uri: - reduced_uri = self.reduce_uri(u, default_port) + reduced_uri = self._reduce_uri_with_scheme(u, default_port) self.authenticated[reduced_uri] = is_authenticated def is_authenticated(self, authuri): for default_port in True, False: - reduced_authuri = self.reduce_uri(authuri, default_port) + reduced_authuri = self._reduce_uri_with_scheme( + authuri, default_port) for uri in self.authenticated: - if self.is_suburi(uri, reduced_authuri): + if self._is_suburi_with_scheme(uri, reduced_authuri): return self.authenticated[uri] @@ -1035,6 +1051,9 @@ class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler): auth_header = 'Proxy-authorization' def http_error_407(self, req, fp, code, msg, headers): + # gh-158907: a 407 from a direct origin is not a proxy challenge + if not req.has_proxy() and not req._tunnel_host: + return None # http_error_auth_reqed requires that there is no userinfo component in # authority. Assume there isn't one, since urllib.request does not (and # should not, RFC 3986 s. 3.2.1) support requests for URLs containing @@ -1072,25 +1091,87 @@ def __init__(self, passwd=None): def reset_retry_count(self): self.retried = 0 + def _parse_challenges(self, header): + # Yield (scheme, challenge) for each challenge in a WWW-Authenticate + # header value. Commas separate both challenges and the auth-params + # of a challenge, so an element which starts with a token that is not + # followed by "=" starts a new challenge (RFC 9110, section 11.6.1). + # + # For example, the header value + # + # Basic realm="a", Digest realm="b", nonce="n" + # + # is split on commas into the elements 'Basic realm="a"', + # 'Digest realm="b"' and 'nonce="n"'. "Basic" and "Digest" are not + # followed by "=", so they start challenges; 'nonce="n"' continues + # the Digest one. This yields: + # + # ('Basic', 'Basic realm="a"') + # ('Digest', 'Digest realm="b", nonce="n"') + elements = [] + start = 0 + quote = escape = False + for i, c in enumerate(header): + if escape: + escape = False + elif quote: + if c == '\\': + escape = True + elif c == '"': + quote = False + elif c == '"': + quote = True + elif c == ',': + elements.append((start, i)) + start = i + 1 + elements.append((start, len(header))) + + scheme = begin = end = None + for elt_start, elt_end in elements: + words = header[elt_start:elt_end].split(None, 1) + if not words: + continue + rest = words[1] if len(words) > 1 else '' + if '=' not in words[0] and not rest.startswith('='): + if scheme is not None: + yield scheme, header[begin:end].strip() + scheme = words[0] + begin = elt_start + end = elt_end + if scheme is not None: + yield scheme, header[begin:end].strip() + def http_error_auth_reqed(self, auth_header, host, req, headers): - authreq = headers.get(auth_header, None) + authreqs = headers.get_all(auth_header) if self.retried > 5: # Don't fail endlessly - if we failed once, we'll probably # fail a second time. Hm. Unless the Password Manager is # prompting for the information. Crap. This isn't great # but it's better than the current 'repeat until recursion # depth exceeded' approach - raise HTTPError(req.full_url, 401, "digest auth failed", + if auth_header.lower() == 'proxy-authenticate': + code = 407 + else: + code = 401 + raise HTTPError(req.full_url, code, "digest auth failed", headers, None) else: self.retried += 1 - if authreq: - scheme = authreq.split()[0] - if scheme.lower() == 'digest': - return self.retry_http_digest_auth(req, authreq) - elif scheme.lower() != 'basic': - raise ValueError("AbstractDigestAuthHandler does not support" - " the following scheme: '%s'" % scheme) + if not authreqs: + return None + unsupported = None + basic_found = False + for authreq in authreqs: + for scheme, challenge in self._parse_challenges(authreq): + if scheme.lower() == 'digest': + return self.retry_http_digest_auth(req, challenge) + if scheme.lower() == 'basic': + basic_found = True + elif unsupported is None: + unsupported = scheme + if unsupported is not None and not basic_found: + raise ValueError("AbstractDigestAuthHandler does not support" + " the following scheme: '%s'" % unsupported) def retry_http_digest_auth(self, req, auth): token, challenge = auth.split(' ', 1) @@ -1131,7 +1212,13 @@ def get_authorization(self, req, chal): if H is None: return None - user, pw = self.passwd.find_user_password(realm, req.full_url) + # proxy auth is looked up by the proxy's authority + # req.host, set by Request.set_proxy() + if self.auth_header == 'Proxy-Authorization': + authority = req.host + else: + authority = req.full_url + user, pw = self.passwd.find_user_password(realm, authority) if user is None: return None @@ -1141,10 +1228,24 @@ def get_authorization(self, req, chal): else: entdig = None + # The digest-uri is the request-target as sent on the request line: + # the path, or the absolute URL when the request goes through an + # HTTP proxy. RFC 7616, Section 3.4 allows both. An empty path is + # sent as '/' by http.client, so use the same here. + + if self.auth_header == 'Proxy-Authorization' and req._tunnel_host: + # For an https URL the proxy authenticates the CONNECT request, + # whose request-target is host:port, as sent by http.client. + method = 'CONNECT' + host, port = _splitport(req._tunnel_host) + uri = '%s:%s' % (host.encode('idna').decode('ascii'), + port or http.client.HTTPS_PORT) + else: + method = req.get_method() + uri = req.selector or '/' + A1 = "%s:%s:%s" % (user, realm, pw) - A2 = "%s:%s" % (req.get_method(), - # XXX selector: what about proxies and full urls - req.selector) + A2 = "%s:%s" % (method, uri) # NOTE: As per RFC 2617, when server sends "auth,auth-int", the client could use either `auth` # or `auth-int` to the response back. we use `auth` to send the response back. if qop is None: @@ -1166,8 +1267,7 @@ def get_authorization(self, req, chal): # XXX should the partial digests be encoded too? base = 'username="%s", realm="%s", nonce="%s", uri="%s", ' \ - 'response="%s"' % (user, realm, nonce, req.selector, - respdig) + 'response="%s"' % (user, realm, nonce, uri, respdig) if opaque: base += ', opaque="%s"' % opaque if entdig: @@ -1209,7 +1309,7 @@ class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler): handler_order = 490 # before Basic auth def http_error_401(self, req, fp, code, msg, headers): - host = urlparse(req.full_url)[1] + host = urlparse(req.full_url).netloc retry = self.http_error_auth_reqed('www-authenticate', host, req, headers) self.reset_retry_count() @@ -1222,12 +1322,35 @@ class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler): handler_order = 490 # before Basic auth def http_error_407(self, req, fp, code, msg, headers): + # gh-158907: a 407 from a direct origin is not a proxy challenge + if not req.has_proxy() and not req._tunnel_host: + return None host = req.host retry = self.http_error_auth_reqed('proxy-authenticate', host, req, headers) self.reset_retry_count() return retry +class _ProxyTunnelResponse(io.BytesIO): + """The proxy's error response to CONNECT, as an empty-bodied response.""" + + def __init__(self, err, url): + super().__init__() + self.url = url + self.code = self.status = err.code + self.msg = self.reason = err.reason + self.headers = err.headers + + def info(self): + return self.headers + + def geturl(self): + return self.url + + def getcode(self): + return self.code + + class AbstractHTTPHandler(BaseHandler): def __init__(self, debuglevel=None): @@ -1321,6 +1444,12 @@ def do_open(self, http_class, req, **http_conn_args): try: h.request(req.get_method(), req.selector, req.data, headers, encode_chunked=req.has_header('Transfer-encoding')) + except http.client.ProxyTunnelError as err: + if err.code != 407: + raise URLError(err) + # Pass the proxy's challenge to CONNECT on to the + # http_error_407 handlers, like any other error response. + return _ProxyTunnelResponse(err, req.full_url) except OSError as err: # timeout error raise URLError(err) r = h.getresponse() @@ -1668,7 +1797,22 @@ def url2pathname(url, *, require_scheme=False, resolve_host=False): """ if not require_scheme: url = 'file:' + url - scheme, authority, url = urlsplit(url)[:3] # Discard query and fragment. + # Match urlsplit()'s own control-character handling up front, so the + # except branch below can reuse this same cleaned-up string. + url = url.lstrip(_WHATWG_C0_CONTROL_OR_SPACE) + for b in _UNSAFE_URL_BYTES_TO_REMOVE: + url = url.replace(b, '') + try: + scheme, authority, url = urlsplit(url)[:3] # Discard query and fragment. + except ValueError: + # The authority here is not a real host[:port] pair -- it may + # hold a Windows drive letter (e.g. 'C:\\') -- so urlsplit()'s + # eager port check doesn't apply; split without it instead. + scheme, _, url = url.partition(':') + scheme = scheme.lower() + authority = '' + if url[:2] == '//': + authority, url = _splitnetloc(url, 2) if scheme != 'file': raise URLError("URL is missing a 'file:' scheme") if os.name == 'nt': diff --git a/Lib/urllib/robotparser.py b/Lib/urllib/robotparser.py index 8d0311d96f5e0b4..d50cb70e03813ea 100644 --- a/Lib/urllib/robotparser.py +++ b/Lib/urllib/robotparser.py @@ -30,6 +30,8 @@ class RobotFileParser: def __init__(self, url=''): self.entries = [] self.groups = {} + # Merged entries in self.groups -> number of agents sharing them. + self._merged_refs = {} self.sitemaps = [] self.default_entry = None self.disallow_all = False @@ -62,7 +64,9 @@ def set_url(self, url): if isinstance(url, urllib.request.Request): url = url.full_url - self.host, self.path = urllib.parse.urlsplit(url)[1:3] + parts = urllib.parse.urlsplit(url) + self.host = parts.netloc + self.path = parts.path def read(self): """Reads the robots.txt URL and feeds it to the parser.""" @@ -88,12 +92,32 @@ def read(self): def _add_entry(self, entry): self.entries.append(entry) + to_merge = {} for agent in entry.useragents: agent = agent.lower() - if agent not in self.groups: + old = self.groups.get(agent) + if old is None: self.groups[agent] = entry - else: - self.groups[agent] = merge_entries(self.groups[agent], entry) + elif old is not entry: + to_merge.setdefault(old, set()).add(agent) + if not to_merge: + return + refs = self._merged_refs + entry_agents = set(entry.useragents) + for old, agents in to_merge.items(): + if refs.get(old) == len(agents): + # No other agent shares this merged entry, so it can be + # extended in place instead of being copied again. + _merge_into(old, entry, entry_agents) + continue + new = merge_entries(old, entry, entry_agents) + for agent in agents: + self.groups[agent] = new + refs[new] = len(agents) + if old in refs: + refs[old] -= len(agents) + if not refs[old]: + del refs[old] def parse(self, lines): """Parse the input lines from a robots.txt file. @@ -172,7 +196,8 @@ def _find_entry(self, useragent): entry = self.groups.get(useragent.lower()) if entry is not None: return entry - for entry in self.groups.values(): + # Many agents can share the same entry; check each entry only once. + for entry in dict.fromkeys(self.groups.values()): if entry.applies_to(useragent): return entry return self.groups.get('*') @@ -359,10 +384,21 @@ def translate_pattern(path): parts[-1] = f'.*{parts[-1]}' return ''.join(parts) -def merge_entries(e1, e2): +def merge_entries(e1, e2, e2_agents=None): entry = Entry() - entry.useragents = list(filter(set(e2.useragents).__contains__, e1.useragents)) - entry.rulelines = e1.rulelines + e2.rulelines - entry.delay = e1.delay if e2.delay is None else e2.delay - entry.req_rate = e1.req_rate if e2.req_rate is None else e2.req_rate + entry.useragents = e1.useragents + entry.rulelines = e1.rulelines.copy() + entry.delay = e1.delay + entry.req_rate = e1.req_rate + _merge_into(entry, e2, e2_agents) return entry + +def _merge_into(e1, e2, e2_agents=None): + if e2_agents is None: + e2_agents = set(e2.useragents) + e1.useragents = list(filter(e2_agents.__contains__, e1.useragents)) + e1.rulelines.extend(e2.rulelines) + if e2.delay is not None: + e1.delay = e2.delay + if e2.req_rate is not None: + e1.req_rate = e2.req_rate diff --git a/Lib/uuid.py b/Lib/uuid.py index 4bdcb67775a2ea1..485f5bd8477cdd3 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -43,7 +43,7 @@ >>> x.bytes b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f' - # make a UUID from a 16-byte string + # make a UUID from a 16-byte bytes object >>> uuid.UUID(bytes=x.bytes) UUID('00010203-0405-0607-0809-0a0b0c0d0e0f') @@ -59,11 +59,11 @@ import os import sys import time +lazy import warnings from enum import Enum, _simple_enum - -__author__ = 'Ka-Ping Yee ' +# Original author: Ka-Ping Yee # The recognized platforms - known behaviors if sys.platform in {'win32', 'darwin', 'emscripten', 'wasi'}: @@ -99,6 +99,7 @@ class SafeUUID: _UINT_128_MAX = (1 << 128) - 1 + # 128-bit mask to clear the variant and version bits of a UUID integral value _RFC_4122_CLEARFLAGS_MASK = ~((0xf000 << 64) | (0xc000 << 48)) # RFC 4122 variant bits and version bits to activate on a UUID integral value. @@ -110,6 +111,46 @@ class SafeUUID: _RFC_4122_VERSION_7_FLAGS = ((7 << 76) | (0x8000 << 48)) _RFC_4122_VERSION_8_FLAGS = ((8 << 76) | (0x8000 << 48)) +_random_hook = None +_time_hook = None + + +def _gen_random(size): + if _random_hook is None: + return os.urandom(size) + else: + return _random_hook(size) + + +def _gen_time(): + if _time_hook is None: + return time.time_ns() + else: + return _time_hook() + + +def _install_py_hooks(*, random_func, time_func): + global _random_hook + global _time_hook + global _last_timestamp_v7 + _random_hook = random_func + _time_hook = time_func + # Reset _last_timestamp_v7 for repeatability of tests + _last_timestamp_v7 = None + + +# Import optional C extension at toplevel, to help disabling it when testing +try: + import _uuid + _generate_time_safe = getattr(_uuid, "generate_time_safe", None) + _has_stable_extractable_node = _uuid.has_stable_extractable_node + _UuidCreate = getattr(_uuid, "UuidCreate", None) +except ImportError: + _uuid = None + _generate_time_safe = None + _has_stable_extractable_node = False + _UuidCreate = None + class UUID: """Instances of the UUID class represent UUIDs as specified in RFC 4122. @@ -118,19 +159,19 @@ class UUID: '12345678-1234-1234-1234-123456789abc'. The UUID constructor accepts five possible forms: a similar string of hexadecimal digits, or a tuple of six integer fields (with 32-bit, 16-bit, 16-bit, 8-bit, 8-bit, and - 48-bit values respectively) as an argument named 'fields', or a string - of 16 bytes (with all the integer fields in big-endian order) as an - argument named 'bytes', or a string of 16 bytes (with the first three - fields in little-endian order) as an argument named 'bytes_le', or a - single 128-bit integer as an argument named 'int'. + 48-bit values respectively) as an argument named 'fields', or a 16-byte + bytes object (with all the integer fields in big-endian order) as an + argument named 'bytes', or a 16-byte bytes object (with the first three + fields in little-endian order) as an argument named 'bytes_le', or a single + 128-bit integer as an argument named 'int'. UUIDs have these read-only attributes: - bytes the UUID as a 16-byte string (containing the six + bytes the UUID as a 16-byte bytes object (containing the six integer fields in big-endian byte order) - bytes_le the UUID as a 16-byte string (with time_low, time_mid, - and time_hi_version in little-endian byte order) + bytes_le the UUID as a 16-byte bytes object (with time_low, + time_mid, and time_hi_version in little-endian byte order) fields a tuple of the six integer fields of the UUID, which are also available as six individual attributes @@ -179,7 +220,7 @@ def __init__(self, hex=None, bytes=None, bytes_le=None, fields=None, int=None, version=None, *, is_safe=SafeUUID.unknown): r"""Create a UUID from either a string of 32 hexadecimal digits, - a string of 16 bytes as the 'bytes' argument, a string of 16 bytes + a 16-byte bytes object as the 'bytes' argument, a 16-byte bytes object in little-endian order as the 'bytes_le' argument, a tuple of six integers (32-bit time_low, 16-bit time_mid, 16-bit time_hi_version, 8-bit clock_seq_hi_variant, 8-bit clock_seq_low, 48-bit node) as @@ -191,9 +232,9 @@ def __init__(self, hex=None, bytes=None, bytes_le=None, fields=None, UUID('{12345678-1234-5678-1234-567812345678}') UUID('12345678123456781234567812345678') UUID('urn:uuid:12345678-1234-5678-1234-567812345678') - UUID(bytes='\x12\x34\x56\x78'*4) - UUID(bytes_le='\x78\x56\x34\x12\x34\x12\x78\x56' + - '\x12\x34\x56\x78\x12\x34\x56\x78') + UUID(bytes=b'\x12\x34\x56\x78'*4) + UUID(bytes_le=b'\x78\x56\x34\x12\x34\x12\x78\x56' + + b'\x12\x34\x56\x78\x12\x34\x56\x78') UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678)) UUID(int=0x12345678123456781234567812345678) @@ -219,22 +260,24 @@ def __init__(self, hex=None, bytes=None, bytes_le=None, fields=None, raise ValueError('badly formed hexadecimal UUID string') int = int_(hex, 16) elif bytes_le is not None: + if not isinstance(bytes_le, bytes_): + raise TypeError('bytes_le must be a bytes object') if len(bytes_le) != 16: raise ValueError('bytes_le is not a 16-char string') - assert isinstance(bytes_le, bytes_), repr(bytes_le) bytes = (bytes_le[4-1::-1] + bytes_le[6-1:4-1:-1] + bytes_le[8-1:6-1:-1] + bytes_le[8:]) int = int_.from_bytes(bytes) # big endian elif bytes is not None: + if not isinstance(bytes, bytes_): + raise TypeError('bytes must be a bytes object') if len(bytes) != 16: raise ValueError('bytes is not a 16-char string') - assert isinstance(bytes, bytes_), repr(bytes) int = int_.from_bytes(bytes) # big endian elif fields is not None: if len(fields) != 6: raise ValueError('fields is not a 6-tuple') (time_low, time_mid, time_hi_version, - clock_seq_hi_variant, clock_seq_low, node) = fields + clock_seq_hi_variant, clock_seq_low, node) = fields if not 0 <= time_low < (1 << 32): raise ValueError('field 1 out of range (need a 32-bit value)') if not 0 <= time_mid < (1 << 16): @@ -249,7 +292,7 @@ def __init__(self, hex=None, bytes=None, bytes_le=None, fields=None, raise ValueError('field 6 out of range (need a 48-bit value)') clock_seq = (clock_seq_hi_variant << 8) | clock_seq_low int = ((time_low << 96) | (time_mid << 80) | - (time_hi_version << 64) | (clock_seq << 48) | node) + (time_hi_version << 64) | (clock_seq << 48) | node) if not 0 <= int <= _UINT_128_MAX: raise ValueError('int is out of range (need a 128-bit value)') if version is not None: @@ -629,19 +672,6 @@ def _netstat_getnode(): return _find_mac_under_heading('netstat', '-ian', b'Address') -# Import optional C extension at toplevel, to help disabling it when testing -try: - import _uuid - _generate_time_safe = getattr(_uuid, "generate_time_safe", None) - _has_stable_extractable_node = _uuid.has_stable_extractable_node - _UuidCreate = getattr(_uuid, "UuidCreate", None) -except ImportError: - _uuid = None - _generate_time_safe = None - _has_stable_extractable_node = False - _UuidCreate = None - - def _unix_getnode(): """Get the hardware address on Unix using the _uuid extension module.""" if _generate_time_safe and _has_stable_extractable_node: @@ -774,7 +804,7 @@ def uuid3(namespace, name): def uuid4(): """Generate a random UUID.""" - int_uuid_4 = int.from_bytes(os.urandom(16)) + int_uuid_4 = int.from_bytes(_gen_random(16)) int_uuid_4 &= _RFC_4122_CLEARFLAGS_MASK int_uuid_4 |= _RFC_4122_VERSION_4_FLAGS return UUID._from_int(int_uuid_4) @@ -834,7 +864,8 @@ def uuid6(node=None, clock_seq=None): _last_counter_v7 = 0 # 42-bit counter def _uuid7_get_counter_and_tail(): - rand = int.from_bytes(os.urandom(10)) + rand = int.from_bytes(_gen_random(10)) + # 42-bit counter with MSB set to 0 counter = (rand >> 32) & 0x1ff_ffff_ffff # 32-bit random data @@ -863,7 +894,7 @@ def uuid7(): global _last_timestamp_v7 global _last_counter_v7 - nanoseconds = time.time_ns() + nanoseconds = _gen_time() timestamp_ms = nanoseconds // 1_000_000 if _last_timestamp_v7 is None or timestamp_ms > _last_timestamp_v7: @@ -879,7 +910,7 @@ def uuid7(): counter, tail = _uuid7_get_counter_and_tail() else: # 32-bit random data - tail = int.from_bytes(os.urandom(4)) + tail = int.from_bytes(_gen_random(4)) unix_ts_ms = timestamp_ms & 0xffff_ffff_ffff counter_msbs = counter >> 30 @@ -932,6 +963,21 @@ def uuid8(a=None, b=None, c=None): return UUID._from_int(int_uuid_8) +_py_uuid4 = uuid4 +_py_uuid7 = uuid7 +_py_UUID = UUID +try: + from _uuid import UUID, uuid4, uuid7 + from _uuid import _install_c_hooks as _install_c_hooks +except ImportError: + _c_UUID = None + _c_uuid4 = None + _c_uuid7 = None +else: + _c_UUID = UUID + _c_uuid4 = uuid4 + _c_uuid7 = uuid7 + def main(): """Run the uuid command line interface.""" uuid_funcs = { @@ -1009,5 +1055,12 @@ def main(): NIL = UUID('00000000-0000-0000-0000-000000000000') MAX = UUID('ffffffff-ffff-ffff-ffff-ffffffffffff') +def __getattr__(name): + if name == "__author__": + warnings._deprecated("__author__", remove=(3, 20)) + return 'Ka-Ping Yee' # Do not change + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") + + if __name__ == "__main__": main() diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py index bd2762d55ef6961..0e9ee18892b9338 100644 --- a/Lib/venv/__init__.py +++ b/Lib/venv/__init__.py @@ -27,16 +27,15 @@ class EnvBuilder: By default, the builder makes the system (global) site-packages dir *un*available to the created environment. - If invoked using the Python -m option, the default is to use copying - on Windows platforms but symlinks elsewhere. If instantiated some - other way, the default is to *not* use symlinks. + By default, the builder uses copying on Windows platforms but symlinks + elsewhere, matching the behaviour when invoked using the Python -m option. :param system_site_packages: If True, the system (global) site-packages dir is available to created environments. :param clear: If True, delete the contents of the environment directory if it already exists, before environment creation. :param symlinks: If True, attempt to symlink rather than copy files into - virtual environment. + virtual environment. If None, use the platform default. :param upgrade: If True, upgrade an existing virtual environment. :param with_pip: If True, ensure pip is installed in the virtual environment @@ -47,11 +46,11 @@ class EnvBuilder: """ def __init__(self, system_site_packages=False, clear=False, - symlinks=False, upgrade=False, with_pip=False, prompt=None, + symlinks=None, upgrade=False, with_pip=False, prompt=None, upgrade_deps=False, *, scm_ignore_files=frozenset()): self.system_site_packages = system_site_packages self.clear = clear - self.symlinks = symlinks + self.symlinks = os.name != 'nt' if symlinks is None else symlinks self.upgrade = upgrade self.with_pip = with_pip self.orig_prompt = prompt @@ -142,6 +141,12 @@ def ensure_directories(self, env_dir): """ def create_if_needed(d): + path = env_dir + for part in os.path.relpath(d, env_dir).split(os.sep)[:-1]: + path = os.path.join(path, part) + if os.path.islink(path) or os.path.isjunction(path): + raise ValueError(f'Refusing to create a venv in {env_dir} ' + f'because {path} is a link.') if not os.path.exists(d): os.makedirs(d) elif os.path.islink(d) or os.path.isfile(d): @@ -267,6 +272,8 @@ def symlink_or_copy(self, src, dst, relative_symlinks_ok=False): switch to a different set of files instead.) """ assert os.name != 'nt' + if os.path.islink(dst) and not os.path.exists(dst): + os.unlink(dst) force_copy = not self.symlinks if not force_copy: try: @@ -445,14 +452,15 @@ def setup_python(self, context): def _call_new_python(self, context, *py_args, **kwargs): """Executes the newly created Python using safe-ish options""" # gh-98251: We do not want to just use '-I' because that masks - # legitimate user preferences (such as not writing bytecode). All we - # really need is to ensure that the path variables do not overrule - # normal venv handling. + # legitimate user preferences (such as not writing bytecode). args = [context.env_exec_cmd, *py_args] kwargs['env'] = env = os.environ.copy() env['VIRTUAL_ENV'] = context.env_dir env.pop('PYTHONHOME', None) env.pop('PYTHONPATH', None) + # Keep the working directory off sys.path, including in the + # subprocess that ensurepip starts to run pip. + env['PYTHONSAFEPATH'] = '1' kwargs['cwd'] = context.env_dir kwargs['executable'] = context.env_exec_cmd subprocess.check_output(args, **kwargs) @@ -519,6 +527,11 @@ def quote_ps1(s): def quote_bat(s): return s + def quote_fish(s): + # gh-160782: fish reads \\ and \' as escapes inside single quotes + s = s.replace('\\', '\\\\').replace("'", "\\'") + return f"'{s}'" + # gh-124651: need to quote the template strings properly quote = shlex.quote script_path = context.script_path @@ -526,6 +539,8 @@ def quote_bat(s): quote = quote_ps1 elif script_path.endswith('.bat'): quote = quote_bat + elif script_path.endswith('.fish'): + quote = quote_fish else: # fallbacks to POSIX shell compliant quote quote = shlex.quote @@ -592,11 +607,10 @@ def skip_file(f): 'may be binary: %s', srcfile, e) continue if new_data == data: - shutil.copy(srcfile, dstfile) + shutil.copyfile(srcfile, dstfile) else: with open(dstfile, 'wb') as f: f.write(new_data) - shutil.copymode(srcfile, dstfile) def upgrade_dependencies(self, context): logger.debug( @@ -607,7 +621,7 @@ def upgrade_dependencies(self, context): def create(env_dir, system_site_packages=False, clear=False, - symlinks=False, with_pip=False, prompt=None, upgrade_deps=False, + symlinks=None, with_pip=False, prompt=None, upgrade_deps=False, *, scm_ignore_files=frozenset()): """Create a virtual environment in a directory.""" builder = EnvBuilder(system_site_packages=system_site_packages, diff --git a/Lib/venv/scripts/posix/activate.csh b/Lib/venv/scripts/posix/activate.csh index 2a3fa835476ab9b..7226034df0f3941 100644 --- a/Lib/venv/scripts/posix/activate.csh +++ b/Lib/venv/scripts/posix/activate.csh @@ -16,10 +16,12 @@ setenv PATH "$VIRTUAL_ENV/"__VENV_BIN_NAME__":$PATH" setenv VIRTUAL_ENV_PROMPT __VENV_PROMPT__ -set _OLD_VIRTUAL_PROMPT="$prompt" +if ($?prompt) then + set _OLD_VIRTUAL_PROMPT="$prompt" -if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then - set prompt = "("__VENV_PROMPT__") $prompt:q" + if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then + set prompt = "("__VENV_PROMPT__") $prompt:q" + endif endif alias pydoc python -m pydoc diff --git a/Lib/weakref.py b/Lib/weakref.py index af7244553c908ce..fc895d4033300ba 100644 --- a/Lib/weakref.py +++ b/Lib/weakref.py @@ -22,6 +22,7 @@ from _weakrefset import WeakSet import _collections_abc # Import after _weakref to avoid circular import. +import copyreg import sys import itertools @@ -35,6 +36,12 @@ _collections_abc.MutableSet.register(WeakSet) + +# Pickle reconstructs a reference to a dead object as this singleton -- all +# dead references are interchangeable. Born dead: nothing else holds the set. +_dead_ref = ref(set()) + + class WeakMethod(ref): """ A custom `weakref.ref` subclass which simulates a weak reference to @@ -89,12 +96,34 @@ def __ne__(self, other): __hash__ = ref.__hash__ +# Pickling support for weak methods. A WeakMethod is reduced to a weak +# reference to its instance; the bound method is rebuilt on unpickling by +# looking the function up on the instance. The callback is not preserved. + +def _restore_weakmethod(obj_ref, name): + return WeakMethod(getattr(obj_ref(), name)) + + +def _reduce_weakmethod(self): + meth = self() + if meth is None: + raise TypeError( + "cannot pickle a weak reference to a dead object") + return (_restore_weakmethod, (ref(meth.__self__), meth.__func__.__name__)) + +copyreg.pickle(WeakMethod, _reduce_weakmethod) + + class WeakValueDictionary(_collections_abc.MutableMapping): """Mapping class that references values weakly. Entries in the dictionary will be discarded when no strong reference to the value exists anymore """ + # Slots give __getstate__() a uniform (dict, slots) shape for __reduce__. + # __dict__ carries user attributes; the removal callback needs __weakref__. + __slots__ = '__dict__', '__weakref__', 'data', '_remove' + # We inherit the constructor without worrying about the input # dictionary; since it uses our .update() method, we get the right # checks (if the other dictionary is a WeakValueDictionary, @@ -157,6 +186,16 @@ def __deepcopy__(self, memo): new[deepcopy(key, memo)] = o return new + def __reduce__(self): + # Pickle the values as weak references; data and _remove are rebuilt + # by the reconstructor. Copying uses __copy__/__deepcopy__ instead. + dict, slots = self.__getstate__() + for name in ('data', '_remove'): + slots.pop(name, None) + state = (dict, slots) if dict or slots else None + items = [(key, ref(o)) for key, o in self.items()] + return (_restore_weakvaluedict, (self.__class__, items), state) + def get(self, key, default=None): try: wr = self.data[key] @@ -274,6 +313,16 @@ def __ror__(self, other): return NotImplemented +def _restore_weakvaluedict(cls, items): + self = cls.__new__(cls) + WeakValueDictionary.__init__(self) + for key, r in items: + o = r() + if o is not None: + self[key] = o + return self + + class KeyedRef(ref): """Specialized reference that includes a key corresponding to the value. @@ -305,6 +354,8 @@ class WeakKeyDictionary(_collections_abc.MutableMapping): can be especially useful with objects that override attribute accesses. """ + # See the comment on WeakValueDictionary.__slots__. + __slots__ = '__dict__', '__weakref__', 'data', '_remove' def __init__(self, dict=None): self.data = {} @@ -353,6 +404,16 @@ def __deepcopy__(self, memo): new[o] = deepcopy(value, memo) return new + def __reduce__(self): + # Pickle the keys as weak references; data and _remove are rebuilt + # by the reconstructor. Copying uses __copy__/__deepcopy__ instead. + dict, slots = self.__getstate__() + for name in ('data', '_remove'): + slots.pop(name, None) + state = (dict, slots) if dict or slots else None + items = [(ref(key), value) for key, value in self.items()] + return (_restore_weakkeydict, (self.__class__, items), state) + def get(self, key, default=None): return self.data.get(ref(key),default) @@ -439,6 +500,16 @@ def __ror__(self, other): return NotImplemented +def _restore_weakkeydict(cls, items): + self = cls.__new__(cls) + WeakKeyDictionary.__init__(self) + for r, value in items: + key = r() + if key is not None: + self[key] = value + return self + + class finalize: """Class for finalization of weakrefable objects diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index ec8b544a6b05235..260208440230dca 100644 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -505,7 +505,8 @@ def register_standard_browsers(): # macOS can use below Unix support (but we prefer using the macOS # specific stuff) - if sys.platform == "ios": + if sys.platform in {"ios", "visionos"}: + # iOS and visionOS provide a browser; tvOS and watchOS don't. register("iosbrowser", None, IOSBrowser(), preferred=True) if sys.platform == "serenityos": @@ -744,9 +745,10 @@ def open(self, url, new=0, autoraise=True): return not rc # -# Platform support for iOS +# Platform support for Apple Mobile platforms that provide a browser +# (i.e., iOS and visionOS) # -if sys.platform == "ios": +if sys.platform in {"ios", "visionos"}: from _ios_support import objc if objc: # If objc exists, we know ctypes is also importable. diff --git a/Lib/wsgiref/validate.py b/Lib/wsgiref/validate.py index 1a1853cd63a0d2a..cc572e8a179d1eb 100644 --- a/Lib/wsgiref/validate.py +++ b/Lib/wsgiref/validate.py @@ -334,7 +334,7 @@ def check_environ(environ): # @@: these need filling out: if environ['REQUEST_METHOD'] not in ( - 'GET', 'HEAD', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE', 'TRACE'): + 'GET', 'HEAD', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE', 'QUERY', 'TRACE'): warnings.warn( "Unknown REQUEST_METHOD: %r" % environ['REQUEST_METHOD'], WSGIWarning) diff --git a/Lib/xml/dom/expatbuilder.py b/Lib/xml/dom/expatbuilder.py index 7dd667bf3fbe042..e3917c1cc682880 100644 --- a/Lib/xml/dom/expatbuilder.py +++ b/Lib/xml/dom/expatbuilder.py @@ -30,7 +30,8 @@ from xml.dom import xmlbuilder, minidom, Node from xml.dom import EMPTY_NAMESPACE, EMPTY_PREFIX, XMLNS_NAMESPACE from xml.parsers import expat -from xml.dom.minidom import _append_child, _set_attribute_node +from xml.dom.minidom import (_append_child, _set_attribute_node, + _XML_WHITESPACE) from xml.dom.NodeFilter import NodeFilter TEXT_NODE = Node.TEXT_NODE @@ -159,7 +160,6 @@ def getParser(self): self._intern_setdefault = self._parser.intern.setdefault self._parser.buffer_text = True self._parser.ordered_attributes = True - self._parser.specified_attributes = True self.install(self._parser) return self._parser @@ -352,11 +352,13 @@ def start_element_handler(self, name, attributes): self.curNode = node if attributes: + specified = self.getParser().GetSpecifiedAttributeCount() for i in range(0, len(attributes), 2): a = minidom.Attr(attributes[i], EMPTY_NAMESPACE, None, EMPTY_PREFIX) value = attributes[i+1] a.value = value + a.specified = i < specified a.ownerDocument = self.document _set_attribute_node(node, a) @@ -412,7 +414,8 @@ def _handle_white_text_nodes(self, node, info): # whitespace. L = [] for child in node.childNodes: - if child.nodeType == TEXT_NODE and not child.data.strip(): + if (child.nodeType == TEXT_NODE + and not child.data.strip(_XML_WHITESPACE)): L.append(child) # Remove ignorable whitespace from the tree. @@ -760,6 +763,7 @@ def start_element_handler(self, name, attributes): node._ensure_attributes() _attrs = node._attrs _attrsNS = node._attrsNS + specified = self.getParser().GetSpecifiedAttributeCount() for i in range(0, len(attributes), 2): aname = attributes[i] value = attributes[i+1] @@ -775,6 +779,7 @@ def start_element_handler(self, name, attributes): _attrsNS[(EMPTY_NAMESPACE, aname)] = a a.ownerDocument = self.document a.value = value + a.specified = i < specified a.ownerElement = node if __debug__: diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 16b33b90184dc59..fb6c1462fc5e9e6 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -16,9 +16,11 @@ """ import io +import xml import xml.dom -from xml.dom import EMPTY_NAMESPACE, EMPTY_PREFIX, XMLNS_NAMESPACE, domreg +from xml.dom import (EMPTY_NAMESPACE, EMPTY_PREFIX, XML_NAMESPACE, + XMLNS_NAMESPACE, domreg) from xml.dom.minicompat import * from xml.dom.xmlbuilder import DOMImplementationLS, DocumentLS @@ -30,6 +32,9 @@ _nodeTypes_with_children = (xml.dom.Node.ELEMENT_NODE, xml.dom.Node.ENTITY_REFERENCE_NODE) +# The white space characters of the XML specification (see XML 1.0, 2.3). +_XML_WHITESPACE = " \t\r\n" + class Node(xml.dom.Node): namespaceURI = None # this is non-null only for elements and attributes @@ -79,15 +84,32 @@ def _get_lastChild(self): if self.childNodes: return self.childNodes[-1] + def _check_new_child(self, newChild, oldChild=None): + # Common checks for insertBefore(), appendChild() and replaceChild(). + doc = self.ownerDocument or self + newChildDoc = newChild.ownerDocument + if newChildDoc is not doc and newChildDoc is not None: + raise xml.dom.WrongDocumentErr( + "%s was created by a different document" % repr(newChild)) + if newChild.nodeType not in self._child_node_types: + raise xml.dom.HierarchyRequestErr( + "%s cannot be child of %s" % (repr(newChild), repr(self))) + if newChild is self: + raise xml.dom.HierarchyRequestErr( + "%s cannot be child of itself" % repr(self)) + # A node without children cannot be an ancestor, and testing this + # first keeps appending leaf nodes linear in the depth of the tree. + if newChild.childNodes and _is_ancestor(newChild, self): + raise xml.dom.HierarchyRequestErr( + "%s is an ancestor of %s" % (repr(newChild), repr(self))) + def insertBefore(self, newChild, refChild): if newChild.nodeType == self.DOCUMENT_FRAGMENT_NODE: for c in tuple(newChild.childNodes): self.insertBefore(c, refChild) ### The DOM does not clearly specify what to return in this case return newChild - if newChild.nodeType not in self._child_node_types: - raise xml.dom.HierarchyRequestErr( - "%s cannot be child of %s" % (repr(newChild), repr(self))) + self._check_new_child(newChild) if newChild.parentNode is not None: newChild.parentNode.removeChild(newChild) if refChild is None: @@ -117,10 +139,8 @@ def appendChild(self, node): self.appendChild(c) ### The DOM does not clearly specify what to return in this case return node - if node.nodeType not in self._child_node_types: - raise xml.dom.HierarchyRequestErr( - "%s cannot be child of %s" % (repr(node), repr(self))) - elif node.nodeType in _nodeTypes_with_children: + self._check_new_child(node) + if node.nodeType in _nodeTypes_with_children: _clear_id_cache(self) if node.parentNode is not None: node.parentNode.removeChild(node) @@ -133,11 +153,9 @@ def replaceChild(self, newChild, oldChild): refChild = oldChild.nextSibling self.removeChild(oldChild) return self.insertBefore(newChild, refChild) - if newChild.nodeType not in self._child_node_types: - raise xml.dom.HierarchyRequestErr( - "%s cannot be child of %s" % (repr(newChild), repr(self))) if newChild is oldChild: return + self._check_new_child(newChild, oldChild) if newChild.parentNode is not None: newChild.parentNode.removeChild(newChild) try: @@ -282,6 +300,72 @@ def __exit__(self, et, ev, tb): defproperty(Node, "localName", doc="Namespace-local name of this node.") +# PubidChar (see XML 1.0, 2.3, [13]). +_PUBID_CHARS = frozenset( + " \r\n-'()+,./:=?;!*#@$_%" + "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz") + + +def _quote_literal(text): + """Quote a system literal or a public identifier. + + A literal is delimited with a quote which it does not contain + (see XML 1.0, 2.3, [11] and [12]). + """ + if "'" not in text: + return "'%s'" % text + if '"' not in text: + return '"%s"' % text + raise ValueError("a literal cannot contain both quotes: %r" % (text,)) + + +def _check_name(name): + if not xml.is_valid_name(name): + raise xml.dom.InvalidCharacterErr( + "%r is not a valid XML name" % (name,)) + + +def _check_prefix(prefix, namespaceURI, attribute=False): + if not xml.is_valid_name(prefix) or ':' in prefix: + raise xml.dom.InvalidCharacterErr( + "%r is not a valid namespace prefix" % (prefix,)) + if not namespaceURI: + raise xml.dom.NamespaceErr( + "cannot use the prefix %r with an empty namespace" % (prefix,)) + if prefix == "xml" and namespaceURI != XML_NAMESPACE: + raise xml.dom.NamespaceErr( + "illegal use of the 'xml' prefix for the wrong namespace") + if attribute and (prefix == "xmlns") != (namespaceURI == XMLNS_NAMESPACE): + raise xml.dom.NamespaceErr( + "illegal use of the 'xmlns' prefix for the wrong namespace") + + +def _check_qualified_name(namespaceURI, qualifiedName, attribute=False): + """Check a namespace URI and a qualified name (see DOM Level 2 Core).""" + _check_name(qualifiedName) + prefix, sep, localName = qualifiedName.partition(':') + if sep: + if not localName or ':' in localName or not xml.is_valid_name(localName): + raise xml.dom.NamespaceErr( + "%r is not a valid qualified name" % (qualifiedName,)) + _check_prefix(prefix, namespaceURI, attribute) + elif attribute and (qualifiedName == "xmlns") != (namespaceURI == XMLNS_NAMESPACE): + raise xml.dom.NamespaceErr( + "illegal use of the 'xmlns' attribute for the wrong namespace") + + +def _is_ancestor(node, other): + "Returns true iff node is an ancestor of other." + other = other.parentNode + while other is not None: + if other is node: + return True + other = other.parentNode + return False + + def _append_child(self, node): # fast path with less checks; usable by DOM builders if careful childNodes = self.childNodes @@ -316,6 +400,109 @@ def _write_data(writer, text, attr): text = text.replace("\t", " ") writer.write(text) + +# The "xml" prefix is bound by definition and is never declared. +_ROOT_NSMAP = {"xml": XML_NAMESPACE} + + +def _bind_namespace(nsmap, inherited, prefix, uri): + """Bind *prefix* in *nsmap*, copying it if it is still the inherited one.""" + if nsmap is inherited: + nsmap = dict(inherited) + nsmap[prefix] = uri + return nsmap + + +def _in_scope_namespaces(element): + """Return the namespaces in scope for *element*, as written by writexml.""" + ancestors = [] + node = element.parentNode + while node is not None and node.nodeType == Node.ELEMENT_NODE: + ancestors.append(node) + node = node.parentNode + nsmap = _ROOT_NSMAP + for node in reversed(ancestors): + nsmap, _ = _fixup_namespaces(node, nsmap) + return nsmap + + +def _fixup_namespaces(element, nsmap): + """Compute namespace declarations missing for the serialized element. + + *nsmap* is the mapping of prefixes to namespace URIs in scope for the + element. Return the mapping in scope for its children and the list of + (name, value) pairs of the attributes to be written, starting with the + added namespace declarations. The element and its attributes are not + modified. + """ + attrs = element._attrs + uri = element.namespaceURI + if not attrs and not uri and not nsmap.get(None): + # Neither the element nor its attributes need a declaration. + return nsmap, () + + inherited = nsmap + declarations = [] + # (name, value, namespace URI, attribute) of the attributes to write. + entries = [] + if attrs: + for attr in attrs.values(): + name = attr.name + attr_uri = attr.namespaceURI + if (attr_uri == XMLNS_NAMESPACE or name == "xmlns" + or name.startswith("xmlns:")): + # Declarations already present in the document take precedence. + nsmap = _bind_namespace( + nsmap, inherited, + attr.localName if attr.prefix else None, attr.value) + attr_uri = None + elif attr_uri == XML_NAMESPACE: + # The xml prefix is bound by definition. + attr_uri = None + entries.append((name, attr.value, attr_uri, attr)) + + if uri: + prefix, _, _ = element.tagName.rpartition(':') + prefix = prefix or None + if nsmap.get(prefix) != uri: + nsmap = _bind_namespace(nsmap, inherited, prefix, uri) + declarations.append(("xmlns:" + prefix if prefix else "xmlns", uri)) + elif nsmap.get(None) and ':' not in element.tagName: + # The element is in no namespace, undeclare the default one. + nsmap = _bind_namespace(nsmap, inherited, None, None) + declarations.append(("xmlns", "")) + + items = [] + prefixes = None # namespace URI -> prefix, built only when needed + n = 0 + for name, value, attr_uri, attr in entries: + if attr_uri is not None: + # Unprefixed attributes are in no namespace, so an attribute + # in a namespace always needs a prefix. + prefix, _, _ = name.rpartition(':') + if not prefix: + # Reuse a prefix bound to the namespace, or invent one. + if prefixes is None: + prefixes = {u: p for p, u in nsmap.items() + if p is not None} + prefix = prefixes.get(attr_uri) + if prefix is None: + while nsmap.get("ns%d" % n) is not None: + n += 1 + prefix = "ns%d" % n + name = "%s:%s" % (prefix, attr.localName) + if nsmap.get(prefix) != attr_uri: + nsmap = _bind_namespace(nsmap, inherited, prefix, attr_uri) + declarations.append(("xmlns:" + prefix, attr_uri)) + if prefixes is not None: + prefixes[attr_uri] = prefix + items.append((name, value)) + + if declarations: + return nsmap, declarations + items + return nsmap, items + + def _get_elements_by_tagName_helper(parent, name, rc): for node in parent.childNodes: if node.nodeType == Node.ELEMENT_NODE and \ @@ -344,12 +531,15 @@ class DocumentFragment(Node): Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE, Node.PROCESSING_INSTRUCTION_NODE, - Node.COMMENT_NODE, - Node.NOTATION_NODE) + Node.COMMENT_NODE) def __init__(self): self.childNodes = NodeList() + def writexml(self, writer, indent="", addindent="", newl=""): + for node in self.childNodes: + node.writexml(writer, indent, addindent, newl) + class Attr(Node): __slots__=('_name', '_value', 'namespaceURI', @@ -412,11 +602,8 @@ def _get_prefix(self): return self._prefix def _set_prefix(self, prefix): - nsuri = self.namespaceURI - if prefix == "xmlns": - if nsuri and nsuri != XMLNS_NAMESPACE: - raise xml.dom.NamespaceErr( - "illegal use of 'xmlns' prefix for the wrong namespace") + if prefix is not None: + _check_prefix(prefix, self.namespaceURI, True) self._prefix = prefix if prefix is None: newName = self.localName @@ -620,6 +807,12 @@ def setNamedItem(self, node): if not isinstance(node, Attr): raise xml.dom.HierarchyRequestErr( "%s cannot be child of %s" % (repr(node), repr(self))) + owner = self._ownerElement + if node.ownerDocument not in (None, owner.ownerDocument): + raise xml.dom.WrongDocumentErr( + "%s was created by another document" % repr(node)) + if node.ownerElement not in (None, owner): + raise xml.dom.InuseAttributeErr("attribute node already owned") old = self._attrs.get(node.name) if old: old.unlink() @@ -758,6 +951,7 @@ def getAttributeNS(self, namespaceURI, localName): def setAttribute(self, attname, value): attr = self.getAttributeNode(attname) if attr is None: + _check_name(attname) attr = Attr(attname) attr.value = value # also sets nodeValue attr.ownerDocument = self.ownerDocument @@ -768,6 +962,7 @@ def setAttribute(self, attname, value): _clear_id_cache(self) def setAttributeNS(self, namespaceURI, qualifiedName, value): + _check_qualified_name(namespaceURI, qualifiedName, True) prefix, localname = _nssplit(qualifiedName) attr = self.getAttributeNodeNS(namespaceURI, localname) if attr is None: @@ -795,6 +990,9 @@ def getAttributeNodeNS(self, namespaceURI, localName): return self._attrsNS.get((namespaceURI, localName)) def setAttributeNode(self, attr): + if attr.ownerDocument not in (None, self.ownerDocument): + raise xml.dom.WrongDocumentErr( + "%s was created by another document" % repr(attr)) if attr.ownerElement not in (None, self): raise xml.dom.InuseAttributeErr("attribute node already owned") self._ensure_attributes() @@ -816,22 +1014,17 @@ def setAttributeNode(self, attr): setAttributeNodeNS = setAttributeNode def removeAttribute(self, name): - if self._attrsNS is None: - raise xml.dom.NotFoundErr() - try: - attr = self._attrs[name] - except KeyError: - raise xml.dom.NotFoundErr() - self.removeAttributeNode(attr) + # The DOM specifies that removing an absent attribute has no effect. + if self._attrs is not None: + attr = self._attrs.get(name) + if attr is not None: + self.removeAttributeNode(attr) def removeAttributeNS(self, namespaceURI, localName): - if self._attrsNS is None: - raise xml.dom.NotFoundErr() - try: - attr = self._attrsNS[(namespaceURI, localName)] - except KeyError: - raise xml.dom.NotFoundErr() - self.removeAttributeNode(attr) + if self._attrsNS is not None: + attr = self._attrsNS.get((namespaceURI, localName)) + if attr is not None: + self.removeAttributeNode(attr) def removeAttributeNode(self, node): if node is None: @@ -879,7 +1072,8 @@ def getElementsByTagNameNS(self, namespaceURI, localName): def __repr__(self): return "" % (self.tagName, id(self)) - def writexml(self, writer, indent="", addindent="", newl=""): + def writexml(self, writer, indent="", addindent="", newl="", *, + _nsmap=None): """Write an XML element to a file-like object Write the element to the writer object that must provide @@ -888,13 +1082,14 @@ def writexml(self, writer, indent="", addindent="", newl=""): # indent = current indentation # addindent = indentation to add to higher levels # newl = newline string + if _nsmap is None: + _nsmap = _in_scope_namespaces(self) writer.write(indent+"<" + self.tagName) - attrs = self._get_attributes() - - for a_name in attrs.keys(): + nsmap, items = _fixup_namespaces(self, _nsmap) + for a_name, value in items: writer.write(" %s=\"" % a_name) - _write_data(writer, attrs[a_name].value, True) + _write_data(writer, value, True) writer.write("\"") if self.childNodes: writer.write(">") @@ -902,15 +1097,46 @@ def writexml(self, writer, indent="", addindent="", newl=""): self.childNodes[0].nodeType in ( Node.TEXT_NODE, Node.CDATA_SECTION_NODE)): self.childNodes[0].writexml(writer, '', '', '') + elif self._preserves_whitespace(): + # Adding whitespace here would change the content. + for node in self.childNodes: + node.writexml(writer, '', '', '') else: writer.write(newl) for node in self.childNodes: - node.writexml(writer, indent+addindent, addindent, newl) + if type(node).writexml is Element.writexml: + # Pass the namespaces in scope to the standard + # implementation; an overridden writexml() has the + # documented signature and computes them itself. + node.writexml(writer, indent+addindent, addindent, + newl, _nsmap=nsmap) + else: + node.writexml(writer, indent+addindent, addindent, + newl) writer.write(indent) writer.write("%s" % (self.tagName, newl)) else: writer.write("/>%s"%(newl)) + def _preserves_whitespace(self): + """Returns true iff whitespace in the content is significant. + + This is the case if the element is marked with xml:space="preserve", + if the DTD declares that its content model is not element content, + or, in absence of such declaration, if it contains text. + """ + if self.getAttribute("xml:space") == "preserve": + return True + doc = self.ownerDocument + info = doc and doc._get_elem_info(self) + if info is not None: + # Only whitespace in element content is ignorable + # (see XML 1.0, 3.2.1). + return not info.isElementContent() + return any(node.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE) + and node.data.strip(_XML_WHITESPACE) + for node in self.childNodes) + def _get_attributes(self): self._ensure_attributes() return NamedNodeMap(self._attrs, self._attrsNS, self) @@ -1023,7 +1249,20 @@ def _set_nodeName(self, value): nodeName = property(_get_nodeName, _set_nodeName) def writexml(self, writer, indent="", addindent="", newl=""): - writer.write("%s%s" % (indent,self.target, self.data, newl)) + target = self.target + # PITarget is a Name, except the names matching "xml" in any case + # (see XML 1.0, 2.6, [17]). + _check_name(target) + if target.lower() == "xml": + raise ValueError("%r is a reserved processing instruction target" + % (target,)) + data = self.data + # The data cannot contain "?>", which ends the instruction + # (see XML 1.0, 2.6, [16]). + if "?>" in data: + raise ValueError("'?>' is not allowed in a processing " + "instruction node") + writer.write("%s%s" % (indent, target, data, newl)) class CharacterData(Childless, Node): @@ -1174,7 +1413,7 @@ def replaceWholeText(self, content): return None def _get_isWhitespaceInElementContent(self): - if self.data.strip(): + if self.data.strip(_XML_WHITESPACE): return False elem = _get_containing_element(self) if elem is None: @@ -1218,9 +1457,14 @@ def __init__(self, data): self._data = data def writexml(self, writer, indent="", addindent="", newl=""): - if "--" in self.data: + data = self.data + # The data cannot contain "--", and cannot end with "-", which + # would be fused with the closing "-->" (see XML 1.0, 2.5, [15]). + if "--" in data: raise ValueError("'--' is not allowed in a comment node") - writer.write("%s%s" % (indent, self.data, newl)) + if data.endswith("-"): + raise ValueError("a comment node cannot end with '-'") + writer.write("%s%s" % (indent, data, newl)) class CDATASection(Text): @@ -1366,10 +1610,20 @@ def writexml(self, writer, indent="", addindent="", newl=""): writer.write("\n" % ( - declared_encoding,)) + if standalone is None: + sddecl = "" + else: + sddecl = " standalone='%s'" % ( + "yes" if standalone else "no",) + write("\n" % ( + declared_encoding, sddecl)) if method == "text": _serialize_text(write, self._root) else: - qnames, namespaces = _namespaces(self._root, default_namespace) + qnames, attr_qnames, namespaces = _namespaces( + self._root, default_namespace) serialize = _serialize[method] - serialize(write, self._root, qnames, namespaces, + serialize(write, self._root, qnames, attr_qnames, namespaces, short_empty_elements=short_empty_elements) - def write_c14n(self, file): - # lxml.etree compatibility. use output method instead - return self.write(file, method="c14n") - # -------------------------------------------------------------------- # serialization support @@ -811,28 +821,59 @@ def _namespaces(elem, default_namespace=None): # maps qnames to *encoded* prefix:local names qnames = {None: None} + # The default namespace declaration does not apply to attribute names, + # so they are encoded separately: an unqualified name is left as is, + # and a qualified name always gets a prefix. + attr_qnames = {None: None} if default_namespace else qnames - # maps uri:s to prefixes + # maps prefixes to uri:s namespaces = {} + # maps uri:s to prefixes, "" is the prefix of the default namespace + prefixes = {} + # maps uri:s to prefixes usable in attribute names + attr_prefixes = {} if default_namespace else prefixes if default_namespace: - namespaces[default_namespace] = "" - - def add_qname(qname): + namespaces[""] = default_namespace + prefixes[default_namespace] = "" + + def get_prefix(uri, isattr): + # find or create the prefix for the namespace uri + if isattr: + prefix = attr_prefixes.get(uri) + if prefix is None: + # the empty prefix is of no use for an attribute name + prefix = prefixes.get(uri) or None + else: + prefix = prefixes.get(uri) + if prefix is not None: + return prefix + prefix = _namespace_map.get(uri) + if prefix is None or not prefix and (isattr or default_namespace): + # the empty prefix is of no use for an attribute name, + # and the default namespace is used for other uri + prefix = "ns%d" % len(namespaces) + if prefix != "xml": + namespaces[prefix] = uri + if isattr: + attr_prefixes[uri] = prefix + prefixes.setdefault(uri, prefix) + return prefix + + def add_qname(qname, isattr=False): # calculate serialized qname representation try: if qname[:1] == "{": uri, tag = qname[1:].rsplit("}", 1) - prefix = namespaces.get(uri) - if prefix is None: - prefix = _namespace_map.get(uri) - if prefix is None: - prefix = "ns%d" % len(namespaces) - if prefix != "xml": - namespaces[uri] = prefix + prefix = get_prefix(uri, isattr) if prefix: - qnames[qname] = "%s:%s" % (prefix, tag) + if isattr: + attr_qnames[qname] = "%s:%s" % (prefix, tag) + else: + qnames[qname] = "%s:%s" % (prefix, tag) else: qnames[qname] = tag # default element + elif isattr: + attr_qnames[qname] = qname else: if default_namespace: # FIXME: can this be handled in XML 1.0? @@ -858,16 +899,16 @@ def add_qname(qname): for key, value in elem.items(): if isinstance(key, QName): key = key.text - if key not in qnames: - add_qname(key) + if key not in attr_qnames: + add_qname(key, isattr=True) if isinstance(value, QName) and value.text not in qnames: add_qname(value.text) text = elem.text if isinstance(text, QName) and text.text not in qnames: add_qname(text.text) - return qnames, namespaces + return qnames, attr_qnames, namespaces -def _serialize_xml(write, elem, qnames, namespaces, +def _serialize_xml(write, elem, qnames, attr_qnames, namespaces, short_empty_elements, **kwargs): tag = elem.tag text = elem.text @@ -881,15 +922,14 @@ def _serialize_xml(write, elem, qnames, namespaces, if text: write(_escape_cdata(text)) for e in elem: - _serialize_xml(write, e, qnames, None, + _serialize_xml(write, e, qnames, attr_qnames, None, short_empty_elements=short_empty_elements) else: write("<" + tag) items = list(elem.items()) if items or namespaces: if namespaces: - for v, k in sorted(namespaces.items(), - key=lambda x: x[1]): # sort on prefix + for k, v in sorted(namespaces.items()): # sort on prefix if k: k = ":" + k write(" xmlns%s=\"%s\"" % ( @@ -903,13 +943,13 @@ def _serialize_xml(write, elem, qnames, namespaces, v = qnames[v.text] else: v = _escape_attrib(v) - write(" %s=\"%s\"" % (qnames[k], v)) + write(" %s=\"%s\"" % (attr_qnames[k], v)) if text or len(elem) or not short_empty_elements: write(">") if text: write(_escape_cdata(text)) for e in elem: - _serialize_xml(write, e, qnames, None, + _serialize_xml(write, e, qnames, attr_qnames, None, short_empty_elements=short_empty_elements) write("") else: @@ -924,7 +964,7 @@ def _serialize_xml(write, elem, qnames, namespaces, "img", "input", "isindex", "link", "meta", "param", "source", "track", "wbr", "plaintext"} -def _serialize_html(write, elem, qnames, namespaces, **kwargs): +def _serialize_html(write, elem, qnames, attr_qnames, namespaces, **kwargs): tag = elem.tag text = elem.text if tag is Comment: @@ -937,14 +977,13 @@ def _serialize_html(write, elem, qnames, namespaces, **kwargs): if text: write(_escape_cdata(text)) for e in elem: - _serialize_html(write, e, qnames, None) + _serialize_html(write, e, qnames, attr_qnames, None) else: write("<" + tag) items = list(elem.items()) if items or namespaces: if namespaces: - for v, k in sorted(namespaces.items(), - key=lambda x: x[1]): # sort on prefix + for k, v in sorted(namespaces.items()): # sort on prefix if k: k = ":" + k write(" xmlns%s=\"%s\"" % ( @@ -954,7 +993,7 @@ def _serialize_html(write, elem, qnames, namespaces, **kwargs): for k, v in items: if isinstance(k, QName): k = k.text - k = qnames[k] + k = attr_qnames[k] if v is None: write(" %s" % k) # empty attr else: @@ -971,7 +1010,7 @@ def _serialize_html(write, elem, qnames, namespaces, **kwargs): else: write(_escape_cdata(text)) for e in elem: - _serialize_html(write, e, qnames, None) + _serialize_html(write, e, qnames, attr_qnames, None) if ltag not in HTML_EMPTY: write("") if elem.tail: @@ -987,8 +1026,6 @@ def _serialize_text(write, elem): "xml": _serialize_xml, "html": _serialize_html, "text": _serialize_text, -# this optional method is imported at the end of the module -# "c14n": _serialize_c14n, } @@ -1092,7 +1129,7 @@ def _escape_attrib_html(text): def tostring(element, encoding=None, method=None, *, xml_declaration=None, default_namespace=None, - short_empty_elements=True): + short_empty_elements=True, standalone=None): """Generate string representation of XML element. All subelements are included. If encoding is "unicode", a string @@ -1100,8 +1137,10 @@ def tostring(element, encoding=None, method=None, *, *element* is an Element instance, *encoding* is an optional output encoding defaulting to US-ASCII, *method* is an optional output which - can be one of "xml" (default), "html", "text" or "c14n", - *default_namespace* sets the default XML namespace (for "xmlns"). + can be one of "xml" (default), "html" or "text", + *default_namespace* sets the default XML namespace (for "xmlns"), + *standalone* is the value of the standalone document declaration + in the XML declaration (omitted if None). Returns an (optionally) encoded string containing the XML data. @@ -1111,7 +1150,8 @@ def tostring(element, encoding=None, method=None, *, xml_declaration=xml_declaration, default_namespace=default_namespace, method=method, - short_empty_elements=short_empty_elements) + short_empty_elements=short_empty_elements, + standalone=standalone) return stream.getvalue() class _ListDataStream(io.BufferedIOBase): @@ -1133,14 +1173,15 @@ def tell(self): def tostringlist(element, encoding=None, method=None, *, xml_declaration=None, default_namespace=None, - short_empty_elements=True): + short_empty_elements=True, standalone=None): lst = [] stream = _ListDataStream(lst) ElementTree(element).write(stream, encoding, xml_declaration=xml_declaration, default_namespace=default_namespace, method=method, - short_empty_elements=short_empty_elements) + short_empty_elements=short_empty_elements, + standalone=standalone) return lst @@ -1188,7 +1229,20 @@ def indent(tree, space=" ", level=0): # Reduce the memory consumption by reusing indentation strings. indentations = ["\n" + level * space] + def _preserves_whitespace(elem): + # True iff whitespace in the content of the element is significant. + if elem.get(_XML_SPACE) == "preserve": + return True + if elem.text and elem.text.strip(_XML_WHITESPACE): + return True + return any(child.tail and child.tail.strip(_XML_WHITESPACE) + for child in elem) + def _indent_children(elem, level): + if _preserves_whitespace(elem): + # Adding whitespace here would change the content. + return + # Start a new indentation level for the first child. child_level = level + 1 try: @@ -1197,18 +1251,15 @@ def _indent_children(elem, level): child_indentation = indentations[level] + space indentations.append(child_indentation) - if not elem.text or not elem.text.strip(): - elem.text = child_indentation + elem.text = child_indentation for child in elem: if len(child): _indent_children(child, child_level) - if not child.tail or not child.tail.strip(): - child.tail = child_indentation + child.tail = child_indentation # Dedent after the last child by overwriting the previous indentation. - if not child.tail.strip(): - child.tail = indentations[level] + child.tail = indentations[level] _indent_children(tree, 0) @@ -1231,7 +1282,7 @@ def parse(source, parser=None): return tree -def iterparse(source, events=None, parser=None): +def iterparse(source, events=None, parser=None, *, target=None): """Incrementally parse XML document into ElementTree. This class also reports what's going on to the user based on the @@ -1242,14 +1293,14 @@ def iterparse(source, events=None, parser=None): *source* is a filename or file object containing XML data, *events* is a list of events to report back, *parser* is an optional parser - instance. + instance, *target* is an optional target of the standard parser. Returns an iterator providing (event, elem) pairs. """ # Use the internal, undocumented _parser argument for now; When the # parser argument of iterparse is removed, this can be killed. - pullparser = XMLPullParser(events=events, _parser=parser) + pullparser = XMLPullParser(events=events, target=target, _parser=parser) if not hasattr(source, "read"): source = open(source, "rb") @@ -1301,13 +1352,19 @@ def __del__(self, _warn=warnings.warn): class XMLPullParser: - def __init__(self, events=None, *, _parser=None): + def __init__(self, events=None, *, target=None, _parser=None): # The _parser argument is for internal use only and must not be relied # upon in user code. It will be removed in a future release. # See https://bugs.python.org/issue17741 for more details. self._events_queue = collections.deque() - self._parser = _parser or XMLParser(target=TreeBuilder()) + if _parser is None: + if target is None: + target = TreeBuilder() + _parser = XMLParser(target=target) + elif target is not None: + raise ValueError("can't specify both parser and target") + self._parser = _parser # wire up the parser for event reporting if events is None: events = ("end",) @@ -1583,10 +1640,10 @@ def __init__(self, *, target=None, encoding=None): parser.CommentHandler = target.comment if hasattr(target, 'pi'): parser.ProcessingInstructionHandler = target.pi + parser.StartDoctypeDeclHandler = self._start_doctype # Configure pyexpat: buffering, new-style attribute handling. parser.buffer_text = 1 parser.ordered_attributes = 1 - self._doctype = None self.entity = {} try: self.version = "Expat %d.%d.%d" % expat.version_info @@ -1603,6 +1660,10 @@ def _setevents(self, events_queue, events_to_report): parser = self._parser append = events_queue.append for event_name in events_to_report: + if (event_name in ("start", "end", "comment", "pi") + and not hasattr(self.target, event_name)): + raise TypeError("the target does not support %r events" + % event_name) if event_name == "start": parser.ordered_attributes = 1 def handler(tag, attrib_in, event=event_name, append=append, @@ -1635,19 +1696,20 @@ def handler(prefix, event=event_name, append=append): append((event, None)) parser.EndNamespaceDeclHandler = handler elif event_name == 'comment': - def handler(text, event=event_name, append=append, self=self): - append((event, self.target.comment(text))) + def handler(text, event=event_name, append=append, + comment=self.target.comment): + append((event, comment(text))) parser.CommentHandler = handler elif event_name == 'pi': def handler(pi_target, data, event=event_name, append=append, - self=self): - append((event, self.target.pi(pi_target, data))) + pi=self.target.pi): + append((event, pi(pi_target, data))) parser.ProcessingInstructionHandler = handler else: raise ValueError("unknown event %r" % event_name) def _raiseerror(self, value): - err = ParseError(value) + err = ParseError(str(value)) err.code = value.code err.position = value.lineno, value.offset raise err @@ -1705,38 +1767,15 @@ def _default(self, text): err.lineno = self.parser.ErrorLineNumber err.offset = self.parser.ErrorColumnNumber raise err - elif prefix == "<" and text[:9] == "": - self._doctype = None - return - text = text.strip() - if not text: - return - self._doctype.append(text) - n = len(self._doctype) - if n > 2: - type = self._doctype[1] - if type == "PUBLIC" and n == 4: - name, type, pubid, system = self._doctype - if pubid: - pubid = pubid[1:-1] - elif type == "SYSTEM" and n == 3: - name, type, system = self._doctype - pubid = None - else: - return - if hasattr(self.target, "doctype"): - self.target.doctype(name, pubid, system[1:-1]) - elif hasattr(self, "doctype"): - warnings.warn( - "The doctype() method of XMLParser is ignored. " - "Define doctype() method on the TreeBuilder target.", - RuntimeWarning) - self._doctype = None + def _start_doctype(self, name, system, pubid, has_internal_subset): + if hasattr(self.target, "doctype"): + self.target.doctype(name, pubid, system) + elif hasattr(self, "doctype"): + warnings.warn( + "The doctype() method of XMLParser is ignored. " + "Define doctype() method on the TreeBuilder target.", + RuntimeWarning) def feed(self, data): """Feed encoded data to parser.""" @@ -1928,7 +1967,7 @@ def _flush(self, _join_text=''.join): data = _join_text(self._data) del self._data[:] if self._strip_text and not self._preserve_space[-1]: - data = data.strip() + data = data.strip(_XML_WHITESPACE) if self._pending_start is not None: args, self._pending_start = self._pending_start, None qname_text = data if data and _looks_like_prefix_name(data) else None diff --git a/Lib/xml/sax/__init__.py b/Lib/xml/sax/__init__.py index fe4582c6f8b758c..45f69c6bc223c5f 100644 --- a/Lib/xml/sax/__init__.py +++ b/Lib/xml/sax/__init__.py @@ -27,12 +27,21 @@ def parse(source, handler, errorHandler=ErrorHandler()): + """Parse an XML document with the default parser. + + source is a system identifier, a path-like object or a file object, + handler is a ContentHandler instance, and errorHandler is an + ErrorHandler instance. All work is done by the handler.""" parser = make_parser() parser.setContentHandler(handler) parser.setErrorHandler(errorHandler) parser.parse(source) def parseString(string, handler, errorHandler=ErrorHandler()): + """Parse an XML document from a string with the default parser. + + string is a str or a bytes-like object, the other arguments are the + same as for parse().""" import io if errorHandler is None: errorHandler = ErrorHandler() diff --git a/Lib/xml/sax/saxutils.py b/Lib/xml/sax/saxutils.py index c1612ea1cebc5d0..8225989d60ecec8 100644 --- a/Lib/xml/sax/saxutils.py +++ b/Lib/xml/sax/saxutils.py @@ -3,9 +3,12 @@ convenience of application and driver writers. """ -import os, urllib.parse, urllib.request -import io import codecs +import io +import os +import sys +lazy import urllib.parse +lazy import urllib.request from . import handler from . import xmlreader @@ -70,7 +73,6 @@ def quoteattr(data, entities={}): def _gettextwriter(out, encoding): if out is None: - import sys return sys.stdout if isinstance(out, io.TextIOBase): @@ -110,6 +112,7 @@ def __getattr__(self, name): write_through=True) class XMLGenerator(handler.ContentHandler): + """Content handler which writes the events back as an XML document.""" def __init__(self, out=None, encoding="iso-8859-1", short_empty_elements=False): handler.ContentHandler.__init__(self) @@ -186,9 +189,9 @@ def startElementNS(self, name, qname, attrs): for prefix, uri in self._undeclared_ns_maps: if prefix: - self._write(' xmlns:%s="%s"' % (prefix, uri)) + self._write(' xmlns:%s=%s' % (prefix, quoteattr(uri))) else: - self._write(' xmlns="%s"' % uri) + self._write(' xmlns=%s' % quoteattr(uri)) self._undeclared_ns_maps = [] for (name, value) in attrs.items(): diff --git a/Lib/xml/sax/xmlreader.py b/Lib/xml/sax/xmlreader.py index e906121d23b9ef3..98e93113fbb5ab9 100644 --- a/Lib/xml/sax/xmlreader.py +++ b/Lib/xml/sax/xmlreader.py @@ -89,7 +89,7 @@ def setProperty(self, name, value): raise SAXNotRecognizedException("Property '%s' not recognized" % name) class IncrementalParser(XMLReader): - """This interface adds three extra methods to the XMLReader + """This interface adds four extra methods to the XMLReader interface that allow XML parsers to support incremental parsing. Support for this interface is optional, since not all underlying XML parsers support this functionality. @@ -104,7 +104,7 @@ class IncrementalParser(XMLReader): is, after parse has been called and before it returns. By default, the class also implements the parse method of the XMLReader - interface using the feed, close and reset methods of the + interface using the prepareParser, feed and close methods of the IncrementalParser interface as a convenience to SAX 2.0 driver writers.""" @@ -274,6 +274,7 @@ def getCharacterStream(self): # ===== ATTRIBUTESIMPL ===== class AttributesImpl: + """Implementation of the Attributes interface.""" def __init__(self, attrs): """Non-NS-aware implementation. diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py index 84e4e4d11a7319e..0d26ad03c51e735 100644 --- a/Lib/xmlrpc/client.py +++ b/Lib/xmlrpc/client.py @@ -677,7 +677,9 @@ def end(self, tag): f = self.dispatch[tag.split(':')[-1]] except KeyError: return # unknown tag ? - return f(self, "".join(self._data)) + data = "".join(self._data) + self._data.clear() + return f(self, data) # # accelerator support diff --git a/Lib/xmlrpc/server.py b/Lib/xmlrpc/server.py index 3e6871157d09299..5ef68640a09ba4b 100644 --- a/Lib/xmlrpc/server.py +++ b/Lib/xmlrpc/server.py @@ -752,7 +752,7 @@ def docroutine(self, object, name, mod=None, anchor = (cl and cl.__name__ or '') + '-' + name note = '' - title = '%s' % ( + title = '%s' % ( self.escape(anchor), self.escape(name)) if callable(object): @@ -766,13 +766,13 @@ def docroutine(self, object, name, mod=None, else: docstring = pydoc.getdoc(object) - decl = title + argspec + (note and self.grey( - '%s' % note)) + decl = title + argspec + (note and + '%s' % note) doc = self.markup( docstring, self.preformat, funcs, classes, methods) - doc = doc and '
%s
' % doc - return '
%s
%s
\n' % (decl, doc) + doc = doc and '
%s
' % doc + return '
%s
%s
\n' % (decl, doc) def docserver(self, server_name, package_documentation, methods): """Produce HTML documentation for an XML-RPC server.""" @@ -783,12 +783,11 @@ def docserver(self, server_name, package_documentation, methods): fdict[value] = fdict[key] server_name = self.escape(server_name) - head = '%s' % server_name - result = self.heading(head) + result = self.heading(server_name) doc = self.markup(package_documentation, self.preformat, fdict) - doc = doc and '%s' % doc - result = result + '

%s

\n' % doc + doc = doc and '
%s
\n' % doc + result = result + doc contents = [] method_items = sorted(methods.items()) @@ -807,12 +806,15 @@ def page(self, title, contents): '' % css_path) return '''\ - + + Python: %s -%s%s''' % (title, css_link, contents) +%s +%s +''' % (title, css_link, contents) class XMLRPCDocGenerator: """Generates documentation for an XML-RPC server. diff --git a/Lib/zipapp.py b/Lib/zipapp.py index a1cef18ada9d05d..39e765d1ffdc6d4 100644 --- a/Lib/zipapp.py +++ b/Lib/zipapp.py @@ -69,7 +69,7 @@ def _copy_archive(archive, new_archive, interpreter=None): dst.write(first_2) shutil.copyfileobj(src, dst) - if interpreter and isinstance(new_archive, str): + if interpreter and isinstance(new_archive, (str, os.PathLike)): os.chmod(new_archive, os.stat(new_archive).st_mode | stat.S_IEXEC) diff --git a/Lib/zipfile/__init__.py b/Lib/zipfile/__init__.py index 418933a2e8d9e87..4909e680621ed71 100644 --- a/Lib/zipfile/__init__.py +++ b/Lib/zipfile/__init__.py @@ -12,6 +12,7 @@ import sys import threading import time +import warnings # must stay eager to support finalization try: import zlib # We may need its compression method @@ -239,8 +240,9 @@ def _check_zipfile(fp): return True # Empty zipfiles are still zipfiles elif endrec[_ECD_DISK_NUMBER] == endrec[_ECD_DISK_START]: # Central directory is on the same disk - fp.seek(sum(_handle_prepended_data(endrec))) - if endrec[_ECD_SIZE] >= sizeCentralDir: + start_dir = sum(_handle_prepended_data(endrec)) + if start_dir >= 0 and endrec[_ECD_SIZE] >= sizeCentralDir: + fp.seek(start_dir) data = fp.read(sizeCentralDir) # CD is where we expect it to be if len(data) == sizeCentralDir: centdir = struct.unpack(structCentralDir, data) # CD is the right size @@ -575,11 +577,11 @@ def FileHeader(self, zip64=None): def _encodeFilenameFlags(self): if self.flag_bits & _MASK_UTF_FILENAME: - encoding = 'ascii' + encoding = 'utf-8' else: encoding = 'cp437' try: - return self.filename.encode(encoding), self.flag_bits & ~_MASK_UTF_FILENAME + return self.filename.encode(encoding), self.flag_bits except UnicodeEncodeError: return self.filename.encode('utf-8'), self.flag_bits | _MASK_UTF_FILENAME @@ -619,7 +621,6 @@ def _decodeExtra(self, filename_crc): if up_unicode_name: self.filename = _sanitize_filename(up_unicode_name) else: - import warnings warnings.warn("Empty unicode path extra field (0x7075)", stacklevel=2) except struct.error as e: raise BadZipFile("Corrupt unicode path extra field (0x7075)") from e @@ -689,7 +690,7 @@ def _for_archive(self, archive): self.external_attr = 0o40775 << 16 # drwxrwxr-x self.external_attr |= 0x10 # MS-DOS directory flag else: - self.external_attr = 0o600 << 16 # ?rw------- + self.external_attr = 0o100600 << 16 # -rw------- return self def is_dir(self): @@ -801,7 +802,16 @@ def unused_data(self): except AttributeError: return b'' - def decompress(self, data): + @property + def needs_input(self): + # While the LZMA properties header is still being buffered, more input + # is required; afterwards defer to the wrapped decompressor so a bounded + # decompress() call can be drained across reads. + if self._decomp is None: + return True + return self._decomp.needs_input + + def decompress(self, data, max_length=-1): if self._decomp is None: self._unconsumed += data if len(self._unconsumed) <= 4: @@ -817,7 +827,7 @@ def decompress(self, data): data = self._unconsumed[4 + psize:] del self._unconsumed - result = self._decomp.decompress(data) + result = self._decomp.decompress(data, max_length) self.eof = self._decomp.eof return result @@ -1186,8 +1196,15 @@ def _read1(self, n): data = self._decompressor.unconsumed_tail if n > len(data): data += self._read2(n - len(data)) - else: + elif self._compress_type == ZIP_STORED: data = self._read2(n) + else: + # bzip2/lzma/zstd: a bounded decompress() call may leave input + # buffered inside the decompressor; drain that before reading more. + if getattr(self._decompressor, "needs_input", True): + data = self._read2(n) + else: + data = b'' if self._compress_type == ZIP_STORED: self._eof = self._compress_left <= 0 @@ -1200,8 +1217,26 @@ def _read1(self, n): if self._eof: data += self._decompressor.flush() else: - data = self._decompressor.decompress(data) - self._eof = self._decompressor.eof or self._compress_left <= 0 + # Bound the output of a single decompress() call (mirroring the + # DEFLATE path above) so that a small compressed member cannot + # expand into one unbounded read. + try: + data = self._decompressor.decompress(data, max(n, self.MIN_READ_SIZE)) + except TypeError: + # See MonkeypatchedDecompressorTests in test_core.py + warnings._deprecated( + 'one-argument decompress()', + 'The decompress() method of ' + + type(self._decompressor).__name__ + + ' should take two arguments, data and max_length.' + + ' One-argument calls will stop working before' + + ' Python 3.21.', + remove=(3, 21), + stacklevel=4) + data = self._decompressor.decompress(data) + self._eof = (self._decompressor.eof or + self._compress_left <= 0 and + getattr(self._decompressor, "needs_input", True)) data = data[:self._left] self._left -= len(data) @@ -1523,7 +1558,7 @@ def repack(self, zfile, removed=None): zinfo.header_offset, entry_size, used_entry_size) if used_entry_size > entry_size: raise BadZipFile( - f"Overlapped entries: {zinfo.orig_filename!r} ") + f"Overlapped entries: {zinfo.orig_filename!r}") if removed is not None and zinfo not in removed_zinfos: used_entry_size = entry_size @@ -2152,7 +2187,6 @@ def comment(self, comment): raise TypeError("comment: expected bytes, got %s" % type(comment).__name__) # check for valid comment length if len(comment) > ZIP_MAX_COMMENT: - import warnings warnings.warn('Archive comment is too long; truncating to %d bytes' % ZIP_MAX_COMMENT, stacklevel=2) comment = comment[:ZIP_MAX_COMMENT] @@ -2240,10 +2274,16 @@ def open(self, name, mode="r", pwd=None, *, force_zip64=False): 'File name in directory %r and header %r differ.' % (zinfo.orig_filename, fname)) + local_method = fheader[_FH_COMPRESSION_METHOD] + if local_method != zinfo.compress_type: + raise BadZipFile( + f"Compression method for {zinfo.orig_filename!r} differs " + f"between the central directory ({zinfo.compress_type}) " + f"and the local file header ({local_method}).") + if (zinfo._end_offset is not None and zef_file.tell() + zinfo.compress_size > zinfo._end_offset): if zinfo._end_offset == zinfo.header_offset: - import warnings warnings.warn( f"Overlapped entries: {zinfo.orig_filename!r} " f"(possible zip bomb)", @@ -2286,7 +2326,9 @@ def _open_to_write(self, zinfo, force_zip64=False): zinfo.compress_size = 0 zinfo.CRC = 0 - zinfo.flag_bits = _MASK_UTF_FILENAME + zinfo.flag_bits &= _MASK_UTF_FILENAME + if not zinfo.filename.isascii(): + zinfo.flag_bits |= _MASK_UTF_FILENAME if zinfo.compress_type == ZIP_LZMA: # Compressed data includes an end-of-stream (EOS) marker zinfo.flag_bits |= _MASK_COMPRESS_OPTION_1 @@ -2397,15 +2439,16 @@ def repack(self, removed=None, *, strict_descriptor=True, truncation.""" if self.mode != 'a': raise ValueError("repack() requires mode 'a'") - if not self.fp: - raise ValueError( - "Attempt to write to ZIP archive that was already closed") - if self._writing: - raise ValueError( - "Can't write to ZIP archive while an open writing handle exists" - ) with self._lock: + if not self.fp: + raise ValueError( + "Attempt to write to ZIP archive that was already closed") + if self._writing or self._fileRefCnt > 1: + raise ValueError( + "Can't repack ZIP archive while an open handle exists" + ) + self._writing = True try: repacker = _ZipRepacker( @@ -2493,7 +2536,6 @@ def _extract_member(self, member, targetpath, pwd): def _writecheck(self, zinfo): """Check for errors before writing a file to the archive.""" if zinfo.filename in self.NameToInfo: - import warnings warnings.warn('Duplicate name: %r' % zinfo.filename, stacklevel=3) if self.mode not in ('w', 'x', 'a'): raise ValueError("write() requires mode 'w', 'x', or 'a'") @@ -2598,6 +2640,15 @@ def mkdir(self, zinfo_or_directory_name, mode=511): else: raise TypeError("Expected type str or ZipInfo") + if not self.fp: + raise ValueError( + "Attempt to write to ZIP archive that was already closed" + ) + if self._writing: + raise ValueError( + "Can't write to ZIP archive while an open writing handle exists." + ) + with self._lock: if self._seekable: self.fp.seek(self.start_dir) @@ -2614,9 +2665,18 @@ def mkdir(self, zinfo_or_directory_name, mode=511): self.fp.write(zinfo.FileHeader(False)) self.start_dir = self.fp.tell() - def __del__(self): + def __del__(self, _warn=warnings.warn): """Call the "close()" method in case the user forgot.""" - self.close() + # gh-81954: Warn if writable ZipFile is implicitly closed. + # GC cleanup order is non-deterministic and can result in data loss. + try: + # Wrap within a try to ensure the file is closed even if + # warnings raises. + if self.fp is not None and self.mode in ('w', 'x', 'a'): + _warn(f"unclosed ZipFile {self!r}", + ResourceWarning, source=self, stacklevel=2) + finally: + self.close() def close(self): """Close the file, and for mode 'w', 'x' and 'a' write the ending @@ -2875,6 +2935,10 @@ def _get_code(self, pathname, basename): def main(args=None): import argparse + import runpy + + # Prevent shadowing stdlib modules from extracted files + runpy._remove_sys_path0() description = 'A simple command-line interface for zipfile module.' parser = argparse.ArgumentParser(description=description) diff --git a/Lib/zipfile/_path/__init__.py b/Lib/zipfile/_path/__init__.py index faae4c84cae5ed2..aba7bf91ccf47f8 100644 --- a/Lib/zipfile/_path/__init__.py +++ b/Lib/zipfile/_path/__init__.py @@ -14,10 +14,9 @@ import posixpath import re import stat -import sys import zipfile -from ._functools import save_method_args +from ._functools import none_as, save_method_args from .glob import Translator __all__ = ['Path'] @@ -66,7 +65,7 @@ def _ancestry(path): path = path.rstrip(posixpath.sep) while path.rstrip(posixpath.sep): yield path - path, tail = posixpath.split(path) + path, _tail = posixpath.split(path) _dedupe = dict.fromkeys @@ -156,10 +155,7 @@ def make(cls, source): return cls(source) # Only allow for FastLookup when supplied zipfile is read-only - if 'r' not in source.mode: - cls = CompleteDirs - - source.__class__ = cls + source.__class__ = cls if 'r' in source.mode else CompleteDirs return source @classmethod @@ -195,12 +191,7 @@ def _name_set_prop(self): def _extract_text_encoding(encoding=None, *args, **kwargs): - # compute stack level so that the caller of the caller sees any warning. - is_pypy = sys.implementation.name == 'pypy' - # PyPy no longer special cased after 7.3.19 (or maybe 7.3.18) - # See jaraco/zipp#143 - is_old_pypi = is_pypy and sys.pypy_version_info < (7, 3, 19) - stack_level = 3 + is_old_pypi + stack_level = 3 return io.text_encoding(encoding, stack_level), args, kwargs @@ -276,7 +267,7 @@ class Path: resolve to the zipfile. >>> str(path) - 'mem/abcde.zip/' + 'mem/abcde.zip' >>> path.name 'abcde.zip' >>> path.filename == pathlib.Path('mem/abcde.zip') @@ -403,7 +394,7 @@ def exists(self): def iterdir(self): if not self.is_dir(): - raise ValueError("Can't listdir a file") + raise NotADirectoryError("Can't listdir a file") subs = map(self._next, self.root.namelist()) return filter(self._is_child, subs) @@ -434,7 +425,8 @@ def relative_to(self, other, *extra): return posixpath.relpath(str(self), str(other.joinpath(*extra))) def __str__(self): - return posixpath.join(self.root.filename, self.at) + root = none_as(self.root.filename, ':zipfile:') + return posixpath.join(root, self.at) if self.at else root def __repr__(self): return self.__repr.format(self=self) diff --git a/Lib/zipfile/_path/_functools.py b/Lib/zipfile/_path/_functools.py index 7390be21873e4ba..7d82636ac8d627a 100644 --- a/Lib/zipfile/_path/_functools.py +++ b/Lib/zipfile/_path/_functools.py @@ -18,3 +18,14 @@ def wrapper(self, /, *args, **kwargs): return method(self, *args, **kwargs) return wrapper + + +# from jaraco.functools 4.3 +def none_as(value, replacement=None): + """ + >>> none_as(None, 'foo') + 'foo' + >>> none_as('bar', 'foo') + 'bar' + """ + return replacement if value is None else value diff --git a/Lib/zipfile/_path/glob.py b/Lib/zipfile/_path/glob.py index bd2839304b7db2a..5239772a600f8ba 100644 --- a/Lib/zipfile/_path/glob.py +++ b/Lib/zipfile/_path/glob.py @@ -1,3 +1,4 @@ +import fnmatch import os import re @@ -67,8 +68,32 @@ def replace(self, match): """ Perform the replacements for a match from :func:`separate`. """ - return match.group('set') or ( - re.escape(match.group(0)) + handler = self._replace_set if match.group('set') else self._replace_plain + return handler(match.group(0)) + + def _replace_set(self, character_set): + r""" + Translate a character set using shell-style semantics. + + Glob character sets treat a leading ``!`` as negation and ``^`` + as a literal (unlike regex), so defer to fnmatch, but guard + against matching a separator. + + >>> Translator('/')._replace_set('[!a]') + '(?![/])[^a]' + >>> Translator('/')._replace_set('[^a]') + '(?![/])[\\^a]' + """ + translated = _strip_fnmatch(fnmatch.translate(character_set)) + return rf'(?![{re.escape(self.seps)}]){translated}' + + def _replace_plain(self, text): + """ + Escape the text, translating any wildcards. + """ + return ( + re + .escape(text) .replace('\\*\\*', r'.*') .replace('\\*', rf'[^{re.escape(self.seps)}]*') .replace('\\?', r'[^/]') @@ -111,3 +136,15 @@ def separate(pattern): ['a', '[?]', 'txt'] """ return re.finditer(r'([^\[]+)|(?P[\[].*?[\]])|([\[][^\]]*$)', pattern) + + +def _strip_fnmatch(translated): + r""" + Strip fnmatch's outer group and end marker. + + >>> _strip_fnmatch(r'(?s:[^a])\z') + '[^a]' + >>> _strip_fnmatch(r'(?s:[^a])\Z') + '[^a]' + """ + return re.fullmatch(r'\(\?s:(.*)\)\\[zZ]', translated, re.DOTALL).group(1) diff --git a/Lib/zipimport.py b/Lib/zipimport.py index 19279d1c2bea368..09a85f6d7f58e86 100644 --- a/Lib/zipimport.py +++ b/Lib/zipimport.py @@ -159,11 +159,12 @@ def get_filename(self, fullname): """get_filename(fullname) -> filename string. Return the filename for the specified module or raise ZipImportError - if it couldn't be imported. + if it couldn't be found. """ # Deciding the filename requires working out where the code # would come from if the module was actually loaded - code, ispackage, modpath = _get_module_code(self, fullname) + _, _, modpath = _get_module_code( + self, fullname, compile_source=False) return modpath @@ -427,7 +428,12 @@ def _read_directory(archive): if flags & 0x800: # UTF-8 file names extension - name = name.decode() + try: + name = name.decode() + except UnicodeDecodeError as exc: + raise ZipImportError( + f"can't decode file name in Zip file: {archive!r}", + path=archive) from exc else: # Historical ZIP filename encoding try: @@ -584,12 +590,13 @@ def _get_zlib_decompress_func(): _importing_zstd = False _zstd_decompressor_class = None +_zstd_get_frame_size = None # Return the _zstd.ZstdDecompressor function object, or NULL if _zstd couldn't # be imported. The result is cached when found. def _get_zstd_decompressor_class(): - global _zstd_decompressor_class - if _zstd_decompressor_class: + global _zstd_decompressor_class, _zstd_get_frame_size + if _zstd_decompressor_class and _zstd_get_frame_size: return _zstd_decompressor_class global _importing_zstd @@ -601,7 +608,10 @@ def _get_zstd_decompressor_class(): _importing_zstd = True try: - from _zstd import ZstdDecompressor as _zstd_decompressor_class + from _zstd import ( + ZstdDecompressor as _zstd_decompressor_class, + get_frame_size as _zstd_get_frame_size, + ) except Exception: _bootstrap._verbose_message("zipimport: zstd UNAVAILABLE") raise ZipImportError("can't decompress data; zstd not available") @@ -615,16 +625,24 @@ def _get_zstd_decompressor_class(): def _zstd_decompress(data): # A simple version of compression.zstd.decompress() as we cannot import # that here as the stdlib itself could be being zipimported. + decomp_class = _get_zstd_decompressor_class() + data = memoryview(data) + if not data: + raise ZipImportError("zipimport: zstd compressed data ended before " + "the end-of-stream marker") results = [] - while True: - decomp = _get_zstd_decompressor_class()() - results.append(decomp.decompress(data)) + while data: + try: + frame_size = _zstd_get_frame_size(data) + except Exception: + raise ZipImportError("zipimport: zstd compressed data ended before " + "the end-of-stream marker") from None + decomp = decomp_class() + results.append(decomp.decompress(data[:frame_size])) if not decomp.eof: raise ZipImportError("zipimport: zstd compressed data ended before " "the end-of-stream marker") - data = decomp.unused_data - if not data: - break + data = data[frame_size:] return b"".join(results) @@ -793,9 +811,9 @@ def _get_pyc_source(self, path): return _get_data(self.archive, toc_entry) -# Get the code object associated with the module specified by -# 'fullname'. -def _get_module_code(self, fullname): +# Get the code object associated with the module specified by 'fullname'. +# If compile_source is false, return None for source code without reading or compiling it. +def _get_module_code(self, fullname, *, compile_source=True): path = _get_module_path(self, fullname) import_error = None for suffix, isbytecode, ispackage in _zip_searchorder: @@ -807,6 +825,8 @@ def _get_module_code(self, fullname): pass else: modpath = toc_entry[0] + if not isbytecode and not compile_source: + return None, ispackage, modpath data = _get_data(self.archive, toc_entry) code = None if isbytecode: @@ -820,7 +840,6 @@ def _get_module_code(self, fullname): # bad magic number or non-matching mtime # in byte code, try next continue - modpath = toc_entry[0] return code, ispackage, modpath else: if import_error: diff --git a/Lib/zoneinfo/_common.py b/Lib/zoneinfo/_common.py index caa3a5b583bab32..071ca714be30ab4 100644 --- a/Lib/zoneinfo/_common.py +++ b/Lib/zoneinfo/_common.py @@ -78,7 +78,7 @@ def load_data(fobj): # Read the ttinfo struct, (utoff, isdst, abbrind) if typecnt: utcoff, isdst, abbrind = zip( - *(struct.unpack(">lbb", fobj.read(6)) for i in range(typecnt)) + *(struct.unpack(">lbB", fobj.read(6)) for i in range(typecnt)) ) else: utcoff = () @@ -89,6 +89,14 @@ def load_data(fobj): # not by position in the array but by position in the unsplit # abbreviation string. I suppose this makes more sense in C, which uses # null to terminate the strings, but it's inconvenient here... + # + # Each abbreviation index is a single unsigned byte, so only about the + # first 256 characters of the block can be referenced. A much longer + # block holds nothing usable, and reading it would copy most of the + # block for every local time type. + if not 0 <= charcnt <= 512: + raise ValueError(f"Invalid TZif file: invalid charcnt: {charcnt}") + abbr_vals = {} abbr_chars = fobj.read(charcnt) diff --git a/Lib/zoneinfo/_tzpath.py b/Lib/zoneinfo/_tzpath.py index 3661c837daa0a41..7b6396444fd9110 100644 --- a/Lib/zoneinfo/_tzpath.py +++ b/Lib/zoneinfo/_tzpath.py @@ -111,6 +111,17 @@ def _validate_tzfile_path(path, _base=_TEST_PATH): f"ZoneInfo keys must refer to subdirectories of TZPATH, got: {path}" ) + # load_tzdata() joins the last "/"-separated component of the key to the + # tzdata package directory on its own. On Windows a component with a + # drive or root, such as "C:\\file" in "America/C:\\file", would replace + # that directory instead of being looked up inside it. + for component in path.split("/"): + drive, root, _ = os.path.splitroot(component) + if drive or root: + raise ValueError( + f"ZoneInfo keys must not contain drives or roots, got: {path}" + ) + del _TEST_PATH diff --git a/Lib/zoneinfo/_zoneinfo.py b/Lib/zoneinfo/_zoneinfo.py index 48154775568b6dc..7cdb4c22fa8932a 100644 --- a/Lib/zoneinfo/_zoneinfo.py +++ b/Lib/zoneinfo/_zoneinfo.py @@ -144,7 +144,7 @@ def fromutc(self, dt): if num_trans > 1 and timestamp >= self._trans_utc[1]: tti_prev, tti = self._ttinfos[idx - 2 : idx] elif timestamp > self._trans_utc[-1]: - tti_prev = self._ttinfos[-1] + tti_prev = self._tti_before tti = self._tz_after else: tti_prev = self._tti_before @@ -535,7 +535,7 @@ def year_to_epoch(self, year): days_before_year = _post_epoch_days_before_year(year) d = self.d - if self.julian and d >= 59 and calendar.isleap(year): + if self.julian and d >= 60 and calendar.isleap(year): d += 1 epoch = (days_before_year + d) * 86400 diff --git a/Mac/BuildScript/README.rst b/Mac/BuildScript/README.rst index 54341a81c26743f..1d4fab4ef97fa28 100644 --- a/Mac/BuildScript/README.rst +++ b/Mac/BuildScript/README.rst @@ -1,7 +1,7 @@ Building a Python Mac OS X distribution ======================================= -The ``build-install.py`` script creates Python distributions, including +The ``build-installer.py`` script creates Python distributions, including certain third-party libraries as necessary. It builds a complete framework-based Python out-of-tree, installs it in a funny place with $DESTROOT, massages that installation to remove .pyc files and such, creates @@ -12,7 +12,7 @@ package. This format is deprecated and is no longer supported by modern macOS systems; it is usable on macOS 10.6 and earlier systems. To be usable on newer versions of macOS, the bits in the bundle package must be assembled in a macOS flat installer package, using current -versions of the pkgbuild and productbuild utilities. To pass macoS +versions of the pkgbuild and productbuild utilities. To pass macOS Gatekeeper download quarantine, the final package must be signed with a valid Apple Developer ID certificate using productsign. Starting with macOS 10.15 Catalina, Gatekeeper now also requires @@ -28,7 +28,7 @@ A goal of PSF-provided (python.org) Python binaries for macOS is to support a wide-range of operating system releases with one set of binaries. Currently, the oldest release supported by python.org binaries is macOS 10.9; it should still be possible to build Python and -Python installers on older versions of macOS but we not regularly +Python installers on older versions of macOS but we do not regularly test on those systems nor provide binaries for them. Prior to Python 3.9.1, no Python releases supported building on a @@ -74,7 +74,7 @@ download them. - builds the following third-party libraries * OpenSSL 3.5.x - * Tcl/Tk 8.6.x + * Tcl/Tk 9.0.x * NCurses * SQLite * XZ diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py index 16ad3fd111f65d6..c45430243343cc7 100755 --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -246,9 +246,9 @@ def library_recipes(): result.extend([ dict( - name="OpenSSL 3.5.7", - url="https://github.com/openssl/openssl/releases/download/openssl-3.5.7/openssl-3.5.7.tar.gz", - checksum="a8c0d28a529ca480f9f36cf5792e2cd21984552a3c8e4aa11a24aa31aeac98e8", + name="OpenSSL 3.5.9", + url="https://github.com/openssl/openssl/releases/download/openssl-3.5.9/openssl-3.5.9.tar.gz", + checksum="603f5602e2eef00d77fbd429d34dcd5822bb301757a1bc9cdb24c670f1eb859a", buildrecipe=build_universal_openssl, configure=None, install=None, @@ -359,9 +359,9 @@ def library_recipes(): ), ), dict( - name="SQLite 3.53.3", - url="https://www.sqlite.org/2026/sqlite-autoconf-3530300.tar.gz", - checksum="c917d7db16648ec95f714974ace5e5dcf46b7dc70e26600a0a102a3141125db0", + name="SQLite 3.53.4", + url="https://www.sqlite.org/2026/sqlite-autoconf-3530400.tar.gz", + checksum="0e9483900e92cd5de8fd48d16bf9200145a61f7fd5be542a5ac81d8a9516eb9c", extra_cflags=('-Os ' '-DSQLITE_ENABLE_FTS5 ' '-DSQLITE_ENABLE_FTS4 ' @@ -1402,7 +1402,10 @@ def patchFile(inPath, outPath): data = data.replace('$FULL_VERSION', getFullVersion()) data = data.replace('$VERSION', getVersion()) data = data.replace('$MACOSX_DEPLOYMENT_TARGET', ''.join((DEPTARGET, ' or later'))) - data = data.replace('$ARCHITECTURES', ", ".join(universal_opts_map[UNIVERSALARCHS])) + archs = universal_opts_map[UNIVERSALARCHS] + data = data.replace('$ARCHITECTURES', ", ".join(archs)) + data = data.replace('$ARCHITECTURE_NOUN', + "architecture" if len(archs) == 1 else "architectures") data = data.replace('$INSTALL_SIZE', installSize()) data = data.replace('$THIRD_PARTY_LIBS', "\\\n".join(THIRD_PARTY_LIBS)) diff --git a/Mac/BuildScript/resources/ReadMe.rtf b/Mac/BuildScript/resources/ReadMe.rtf index d19b542b7e6c5a8..47f607d2f3c6ea5 100644 --- a/Mac/BuildScript/resources/ReadMe.rtf +++ b/Mac/BuildScript/resources/ReadMe.rtf @@ -6,7 +6,7 @@ \margl1440\margr1440\vieww15140\viewh15740\viewkind0 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0 -\f0\fs24 \cf0 This package will install Python $FULL_VERSION for macOS $MACOSX_DEPLOYMENT_TARGET for the following architecture(s): $ARCHITECTURES.\ +\f0\fs24 \cf0 This package will install Python $FULL_VERSION for macOS $MACOSX_DEPLOYMENT_TARGET for the following $ARCHITECTURE_NOUN: $ARCHITECTURES.\ \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0 diff --git a/Mac/BuildScript/resources/install_certificates.command b/Mac/BuildScript/resources/install_certificates.command index 700eb462b68c187..aa44961da7f4680 100755 --- a/Mac/BuildScript/resources/install_certificates.command +++ b/Mac/BuildScript/resources/install_certificates.command @@ -1,4 +1,8 @@ #!/bin/sh +# Installing into the global environment is the point; ensure that the user +# hasn't configured pip to always require a virtual environment. +unset PIP_REQUIRE_VENV +unset PIP_REQUIRE_VIRTUALENV /Library/Frameworks/Python.framework/Versions/@PYVER@/bin/python@PYVER@ << "EOF" diff --git a/Mac/README.rst b/Mac/README.rst index 8a6e52725615aae..487f1a9c78065af 100644 --- a/Mac/README.rst +++ b/Mac/README.rst @@ -97,8 +97,8 @@ machines. In macOS 10.5 support was extended to 64-bit Intel and 64-bit PPC architectures. It is possible to build Python with various combinations of architectures depending on the build tools and macOS version in use. Note that PPC support was removed in macOS 10.7 and 32-bit Intel support -was removed in macOS 10.15. So currently as of macOS 10.15, macOS only -supports one execution architecture, 64-bit Intel (``x86_64``). +was removed in macOS 10.15. macOS 11 added support for Apple Silicon +(``arm64``). 2. How do I build a universal binary ------------------------------------ @@ -173,8 +173,8 @@ following combinations of SDKs and universal-archs flavors are available: * 11.0 and later SDKs support ``universal2`` The makefile for a framework build will also install ``python3.x-32`` -binaries when the universal architecture includes at least one 32-bit -architecture (that is, for all flavors but ``64-bit`` and ``intel-64``). +binaries when the universal architecture includes both 32-bit and 64-bit +architectures (that is, for the ``all``, ``intel`` and ``3-way`` flavors). It will also install ``python3.x-intel64`` binaries in the ``universal2`` case to allow easy execution with the Rosetta 2 Intel emulator on Apple Silicon Macs. @@ -225,7 +225,7 @@ While it is technically possible to create a .app without using frameworks you will have to do the work yourself if you really want this. A second reason for using frameworks is that they put Python-related items in -only two places: "/Library/Framework/Python.framework" and +only two places: "/Library/Frameworks/Python.framework" and "/Applications/Python " where ```` can be e.g. "3.8", "2.7", etc. This simplifies matters for users installing Python from a binary distribution if they want to get rid of it again. Moreover, @@ -275,7 +275,7 @@ in the sequence 3. make install -This sequence will put the framework in ``/Library/Framework/Python.framework``, +This sequence will put the framework in ``/Library/Frameworks/Python.framework``, the applications in ``/Applications/Python `` and the unix tools in ``/usr/local/bin``. @@ -283,7 +283,7 @@ Installing in another place, for instance ``$HOME/Library/Frameworks`` if you have no admin privileges on your machine, is possible. This can be accomplished by configuring with ``--enable-framework=$HOME/Library/Frameworks``. The other two directories will then also be installed in your home directory, -at ``$HOME/Applications/Python-`` and ``$HOME/bin``. +at ``$HOME/Applications/Python `` and ``$HOME/bin``. If you want to install some part, but not all, read the main Makefile. The frameworkinstall is composed of a couple of sub-targets that install the @@ -326,11 +326,8 @@ documentation set for this release for inclusion in the framework. The installer package will create links to the documentation for use by IDLE, pydoc, shell users, and Finder user. -The script will build a universal binary so you'll therefore have to run this -script on macOS 10.4 or later and with Xcode 2.1 or later installed. -However, the Python build process itself has several build dependencies not -available out of the box with macOS 10.4 so you may have to install -additional software beyond what is provided with Xcode 2. +The script will build a universal binary. See ``Mac/BuildScript/README.rst`` +for the recommended build environment. It should be possible to use SDKs and/or older versions of Xcode to build installers that are compatible with older systems on a newer system but this may not be completely foolproof so the resulting diff --git a/Makefile.pre.in b/Makefile.pre.in index b42a8491733c636..c265f9b3e1e44c7 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -25,6 +25,13 @@ MODSHARED_NAMES= _MODSHARED_NAMES_ MODDISABLED_NAMES= _MODDISABLED_NAMES_ MODOBJS= _MODOBJS_ MODLIBS= _MODLIBS_ +# Objects and libraries of the bootstrap modules (Modules/Setup.bootstrap) +# only. These are the only static modules linked into the build helper +# programs (Programs/_freeze_module, _bootstrap_python), so that other +# builtin modules (Modules/Setup.local, MODULE_BUILDTYPE=static) may depend +# on products of those helpers (frozen modules, getpath). +BOOTSTRAP_MODOBJS= _BOOTSTRAP_MODOBJS_ +BOOTSTRAP_MODLIBS= _BOOTSTRAP_MODLIBS_ # === Variables set by configure VERSION= @VERSION@ @@ -50,6 +57,7 @@ GITBRANCH= @GITBRANCH@ PGO_PROF_GEN_FLAG=@PGO_PROF_GEN_FLAG@ PGO_PROF_USE_FLAG=@PGO_PROF_USE_FLAG@ LLVM_PROF_MERGER=@LLVM_PROF_MERGER@ +LLVM_PROF_SHOW=@LLVM_PROF_SHOW@ LLVM_PROF_FILE=@LLVM_PROF_FILE@ LLVM_PROF_ERR=@LLVM_PROF_ERR@ DTRACE= @DTRACE@ @@ -127,7 +135,7 @@ PY_CORE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE # LDFLAGS used to build executables and shared targets. PY_CORE_LDFLAGS=$(PY_LDFLAGS) $(PY_LDFLAGS_NODIST) CONFIGURE_EXE_LDFLAGS=@EXE_LDFLAGS@ -PY_CORE_EXE_LDFLAGS:= $(if $(CONFIGURE_EXE_LDFLAGS), $(CONFIGURE_EXE_LDFLAGS) $(PY_LDFLAGS_NODIST), $(PY_CORE_LDFLAGS)) +PY_CORE_EXE_LDFLAGS= $(if $(CONFIGURE_EXE_LDFLAGS), $(CONFIGURE_EXE_LDFLAGS) $(PY_LDFLAGS_NODIST), $(PY_CORE_LDFLAGS)) # Strict or non-strict aliasing flags used to compile dtoa.c, see above CFLAGS_ALIASING=@CFLAGS_ALIASING@ # Compilation flags only for ceval.c. @@ -217,6 +225,12 @@ IPHONEOS_DEPLOYMENT_TARGET=@IPHONEOS_DEPLOYMENT_TARGET@ BUILD_DETAILS=@BUILD_DETAILS@ +# visionOS Deployment target is *actually* used during the build, by the +# compiler shims; export. +XROS_DEPLOYMENT_TARGET=@XROS_DEPLOYMENT_TARGET@ +@EXPORT_XROS_DEPLOYMENT_TARGET@export XROS_DEPLOYMENT_TARGET + + # Option to install to strip binaries STRIPFLAG=-s @@ -228,6 +242,7 @@ LIPO_INTEL64_FLAGS=@LIPO_INTEL64_FLAGS@ # Environment to run shared python without installed libraries RUNSHARED= @RUNSHARED@ +RUNSHARED_FOR_BUILD= @RUNSHARED_FOR_BUILD@ # ensurepip options ENSUREPIP= @ENSUREPIP@ @@ -285,6 +300,7 @@ DIST= $(DISTFILES) $(DISTDIRS) LIBRARY= @LIBRARY@ LDLIBRARY= @LDLIBRARY@ BLDLIBRARY= @BLDLIBRARY@ +MODULE_LDFLAGS_SHARED=$(if $(LIBPYTHON),$(BLDLIBRARY)) PY3LIBRARY= @PY3LIBRARY@ DLLLIBRARY= @DLLLIBRARY@ LDLIBRARYDIR= @LDLIBRARYDIR@ @@ -316,6 +332,7 @@ HOSTRUNNER= @HOSTRUNNER@ PYTHON_FOR_REGEN?=@PYTHON_FOR_REGEN@ UPDATE_FILE=$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/update_file.py PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@ +MODULE_CHECK_COMMAND=@MODULE_CHECK_COMMAND@ # Single-platform builds depend on $(BUILDPYTHON). Cross builds use an # external "build Python" and have an empty PYTHON_FOR_BUILD_DEPS. PYTHON_FOR_BUILD_DEPS=@PYTHON_FOR_BUILD_DEPS@ @@ -351,11 +368,14 @@ COVERAGE_REPORT_OPTIONS=--rc lcov_branch_coverage=1 --branch-coverage --title "C ########################################################################## # Modules -MODULE_OBJS= \ - Modules/config.o \ +MODULE_OBJS_COMMON= \ Modules/main.o \ Modules/gcmodule.o +MODULE_OBJS= \ + Modules/config.o \ + $(MODULE_OBJS_COMMON) + IO_H= Modules/_io/_iomodule.h IO_OBJS= \ @@ -374,6 +394,7 @@ IO_OBJS= \ MIMALLOC_HEADERS= \ $(srcdir)/Include/internal/pycore_mimalloc.h \ $(srcdir)/Include/internal/mimalloc/mimalloc.h \ + $(srcdir)/Include/internal/mimalloc/mimalloc-stats.h \ $(srcdir)/Include/internal/mimalloc/mimalloc/atomic.h \ $(srcdir)/Include/internal/mimalloc/mimalloc/internal.h \ $(srcdir)/Include/internal/mimalloc/mimalloc/prim.h \ @@ -389,19 +410,20 @@ PEGEN_OBJS= \ Parser/pegen_errors.o \ Parser/action_helpers.o \ Parser/parser.o \ + Parser/parser_invalid.o \ Parser/string_parser.o \ Parser/peg_api.o TOKENIZER_OBJS= \ - Parser/lexer/buffer.o \ Parser/lexer/lexer.o \ + Parser/lexer/layout.o \ Parser/lexer/number.o \ Parser/lexer/state.o \ Parser/lexer/string.o \ - Parser/tokenizer/file_tokenizer.o \ - Parser/tokenizer/readline_tokenizer.o \ - Parser/tokenizer/string_tokenizer.o \ - Parser/tokenizer/utf8_tokenizer.o \ + Parser/tokenizer/decoder.o \ + Parser/tokenizer/api.o \ + Parser/tokenizer/reader.o \ + Parser/tokenizer/source.o \ Parser/tokenizer/helpers.o PEGEN_HEADERS= \ @@ -410,10 +432,12 @@ PEGEN_HEADERS= \ $(srcdir)/Parser/string_parser.h TOKENIZER_HEADERS= \ - Parser/lexer/buffer.h \ - Parser/lexer/lexer.h \ Parser/lexer/lexer_internal.h \ Parser/lexer/state.h \ + Parser/tokenizer/reader.h \ + Parser/tokenizer/reader_internal.h \ + Parser/tokenizer/source.h \ + Parser/tokenizer/types.h \ Parser/tokenizer/tokenizer.h \ Parser/tokenizer/helpers.h @@ -431,6 +455,7 @@ PARSER_HEADERS= \ PYTHON_OBJS= \ Python/_contextvars.o \ + Python/_strptime.o \ Python/_warnings.o \ Python/Python-ast.o \ Python/Python-tokenize.o \ @@ -511,6 +536,7 @@ PYTHON_OBJS= \ Python/thread.o \ Python/traceback.o \ Python/tracemalloc.o \ + Python/typecache.o \ Python/uniqueid.o \ Python/getopt.o \ Python/pystrcmp.o \ @@ -600,6 +626,19 @@ LIBRARY_OBJS= \ Modules/getpath.o \ Python/frozen.o +# objects that get linked into the build helper programs +# (Programs/_freeze_module, _bootstrap_python): the core, plus the bootstrap +# modules only (see BOOTSTRAP_MODOBJS). Does not include frozen modules nor +# getpath, which the helpers are used to build. +BOOTSTRAP_LIBRARY_OBJS= \ + Modules/getbuildinfo_bootstrap.o \ + $(PARSER_OBJS) \ + $(OBJECT_OBJS) \ + $(PYTHON_OBJS) \ + Modules/config_bootstrap.o \ + $(MODULE_OBJS_COMMON) \ + $(BOOTSTRAP_MODOBJS) + LINK_PYTHON_OBJS=@LINK_PYTHON_OBJS@ ########################################################################## @@ -614,6 +653,7 @@ DTRACE_DEPS = \ # pyexpat's expat library LIBEXPAT_OBJS= \ + Modules/expat/xcs.o \ Modules/expat/xmlparse.o \ Modules/expat/xmlrole.o \ Modules/expat/xmltok.o @@ -621,10 +661,12 @@ LIBEXPAT_OBJS= \ LIBEXPAT_HEADERS= \ Modules/expat/ascii.h \ Modules/expat/asciitab.h \ + Modules/expat/entities.h \ Modules/expat/expat.h \ Modules/expat/expat_config.h \ Modules/expat/expat_external.h \ Modules/expat/fallthrough.h \ + Modules/expat/hash_table.h \ Modules/expat/iasciitab.h \ Modules/expat/internal.h \ Modules/expat/latin1tab.h \ @@ -633,7 +675,7 @@ LIBEXPAT_HEADERS= \ Modules/expat/pyexpatns.h \ Modules/expat/siphash.h \ Modules/expat/utf8tab.h \ - Modules/expat/xcsinc.c \ + Modules/expat/xcs.h \ Modules/expat/xmlrole.h \ Modules/expat/xmltok.h \ Modules/expat/xmltok_impl.h \ @@ -843,6 +885,7 @@ profile-run-stamp: @ # FIXME: can't run for a cross build $(LLVM_PROF_FILE) $(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK) $(LLVM_PROF_MERGER) + $(LLVM_PROF_SHOW) # Remove profile generation binary since we are done with it. $(MAKE) clean-retain-profile # This is an expensive target to build and it does not have proper @@ -964,12 +1007,15 @@ clinic: check-clean-src clinic-tests: check-clean-src $(srcdir)/Lib/test/clinic.test.c $(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py -f $(srcdir)/Lib/test/clinic.test.c +# Objects linked into the interpreter only, not into libpython. +PLATFORM_MAIN_OBJS= @PLATFORM_MAIN_OBJS@ + # Build the interpreter -$(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS) - $(LINKCC) $(PY_CORE_EXE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) +$(BUILDPYTHON): Programs/python.o $(PLATFORM_MAIN_OBJS) $(LINK_PYTHON_DEPS) + $(LINKCC) $(PY_CORE_EXE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(PLATFORM_MAIN_OBJS) $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) platform: $(PYTHON_FOR_BUILD_DEPS) pybuilddir.txt - $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform + $(RUNSHARED_FOR_BUILD) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform # Create build directory and generate the sysconfig build-time data there. # pybuilddir.txt contains the name of the build dir and is used for @@ -980,7 +1026,7 @@ platform: $(PYTHON_FOR_BUILD_DEPS) pybuilddir.txt # or removed in case of failure. pybuilddir.txt: $(PYTHON_FOR_BUILD_DEPS) @echo "none" > ./pybuilddir.txt - $(RUNSHARED) $(PYTHON_FOR_BUILD) -S -X pathconfig_warnings=0 -m sysconfig --generate-posix-vars ;\ + $(RUNSHARED_FOR_BUILD) $(PYTHON_FOR_BUILD) -S -X pathconfig_warnings=0 -m sysconfig --generate-posix-vars ;\ if test $$? -ne 0 ; then \ echo "generate-posix-vars failed" ; \ rm -f ./pybuilddir.txt ; \ @@ -988,7 +1034,7 @@ pybuilddir.txt: $(PYTHON_FOR_BUILD_DEPS) fi $(BUILD_DETAILS): pybuilddir.txt - $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/generate-build-details.py `cat pybuilddir.txt`/$(BUILD_DETAILS) + $(RUNSHARED_FOR_BUILD) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/generate-build-details.py `cat pybuilddir.txt`/$(BUILD_DETAILS) # Build static library $(LIBRARY): $(LIBRARY_OBJS) @@ -1010,7 +1056,7 @@ libpython3.so: libpython$(LDVERSION).so $(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^ libpython$(LDVERSION).dylib: $(LIBRARY_OBJS) - $(CC) -dynamiclib $(PY_CORE_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(DTRACE_OBJS) $(SHLIBS) $(LIBC) $(LIBM); \ + $(CC) -dynamiclib $(PY_CORE_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(DTRACE_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM); \ libpython$(VERSION).sl: $(LIBRARY_OBJS) @@ -1044,7 +1090,7 @@ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \ -install_name $(PYTHONFRAMEWORKINSTALLNAMEPREFIX)/$(PYTHONFRAMEWORK) \ -compatibility_version $(VERSION) \ -current_version $(VERSION) \ - -framework CoreFoundation $(LIBS); + -framework CoreFoundation $(MODLIBS) $(LIBS); $(INSTALL) -d -m $(DIRMODE) \ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj $(INSTALL_DATA) $(RESSRCDIR)/Info.plist \ @@ -1065,7 +1111,7 @@ $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK): \ -install_name $(PYTHONFRAMEWORKINSTALLNAMEPREFIX)/$(PYTHONFRAMEWORK) \ -compatibility_version $(VERSION) \ -current_version $(VERSION) \ - -framework CoreFoundation $(LIBS); + -framework CoreFoundation $(MODLIBS) $(LIBS); $(INSTALL_DATA) $(RESSRCDIR)/Info.plist $(PYTHONFRAMEWORKDIR)/Info.plist # This rule builds the Cygwin Python DLL and import library if configured @@ -1113,6 +1159,20 @@ web_example/python.mjs web_example/python.wasm: $(BUILDPYTHON) cp python.mjs web_example/python.mjs cp python.wasm web_example/python.wasm +WEB_EMBED_TEST_DIR=$(EMSCRIPTEN_DIR)/web_embed_test + +# Linked like an embedder would: against libpython.a, without $(LINKFORSHARED) +# and so without -sMAIN_MODULE or the interpreter's -sEXPORTED_FUNCTIONS. +web_embed_test/main.js: $(WEB_EMBED_TEST_DIR)/main.c $(LIBRARY) $(ZIP_STDLIB) + @mkdir -p web_embed_test + $(LINKCC) $(PY_STDMODULE_CFLAGS) $(PY_CORE_EXE_LDFLAGS) -O2 -g0 -o $@ \ + $(WEB_EMBED_TEST_DIR)/main.c $(LIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) \ + -sALLOW_MEMORY_GROWTH -sSTACK_SIZE=5MB \ + --preload-file $(ZIP_STDLIB)@/lib/stdlib.zip + +.PHONY: web_embed_test +web_embed_test: web_embed_test/main.js + .PHONY: web_example web_example: web_example/python.mjs web_example/python.worker.mjs web_example/index.html web_example/server.py web_example/$(ZIP_STDLIB) @@ -1339,6 +1399,7 @@ PYTHON_HEADERS= \ $(srcdir)/Include/internal/pycore_getopt.h \ $(srcdir)/Include/internal/pycore_gil.h \ $(srcdir)/Include/internal/pycore_global_objects.h \ + $(srcdir)/Include/internal/pycore_global_objects_fini.h \ $(srcdir)/Include/internal/pycore_global_objects_fini_generated.h \ $(srcdir)/Include/internal/pycore_global_strings.h \ $(srcdir)/Include/internal/pycore_hamt.h \ @@ -1355,6 +1416,7 @@ PYTHON_HEADERS= \ $(srcdir)/Include/internal/pycore_interpframe_structs.h \ $(srcdir)/Include/internal/pycore_interpolation.h \ $(srcdir)/Include/internal/pycore_intrinsics.h \ + $(srcdir)/Include/internal/pycore_iterobject.h \ $(srcdir)/Include/internal/pycore_jit.h \ $(srcdir)/Include/internal/pycore_lazyimportobject.h \ $(srcdir)/Include/internal/pycore_list.h \ @@ -1419,6 +1481,7 @@ PYTHON_HEADERS= \ $(srcdir)/Include/internal/pycore_tracemalloc.h \ $(srcdir)/Include/internal/pycore_tstate.h \ $(srcdir)/Include/internal/pycore_tuple.h \ + $(srcdir)/Include/internal/pycore_typecache.h \ $(srcdir)/Include/internal/pycore_typedefs.h \ $(srcdir)/Include/internal/pycore_typeobject.h \ $(srcdir)/Include/internal/pycore_typevarobject.h \ @@ -1431,6 +1494,7 @@ PYTHON_HEADERS= \ $(srcdir)/Include/internal/pycore_uop.h \ $(srcdir)/Include/internal/pycore_uop_ids.h \ $(srcdir)/Include/internal/pycore_uop_metadata.h \ + $(srcdir)/Include/internal/pycore_wasm_trampoline.h \ $(srcdir)/Include/internal/pycore_warnings.h \ $(srcdir)/Include/internal/pycore_weakref.h \ $(DTRACE_HEADERS) \ @@ -1442,6 +1506,9 @@ PYTHON_HEADERS= \ # Build static libexpat.a LIBEXPAT_CFLAGS=@LIBEXPAT_CFLAGS@ $(PY_STDMODULE_CFLAGS) $(CCSHARED) +Modules/expat/xcs.o: $(srcdir)/Modules/expat/xcs.c $(LIBEXPAT_HEADERS) $(PYTHON_HEADERS) + $(CC) -c $(LIBEXPAT_CFLAGS) -o $@ $(srcdir)/Modules/expat/xcs.c + Modules/expat/xmlparse.o: $(srcdir)/Modules/expat/xmlparse.c $(LIBEXPAT_HEADERS) $(PYTHON_HEADERS) $(CC) -c $(LIBEXPAT_CFLAGS) -o $@ $(srcdir)/Modules/expat/xmlparse.c @@ -1539,11 +1606,11 @@ sharedmods: $(SHAREDMODS) pybuilddir.txt .PHONY: checksharedmods checksharedmods: sharedmods $(PYTHON_FOR_BUILD_DEPS) $(BUILDPYTHON) @if [ -n "@MISSING_STDLIB_CONFIG@" ]; then \ - $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/check_extension_modules.py --generate-missing-stdlib-info --with-missing-stdlib-config="@MISSING_STDLIB_CONFIG@"; \ + $(MODULE_CHECK_COMMAND) --generate-missing-stdlib-info --with-missing-stdlib-config="@MISSING_STDLIB_CONFIG@"; \ else \ - $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/check_extension_modules.py --generate-missing-stdlib-info; \ + $(MODULE_CHECK_COMMAND) --generate-missing-stdlib-info; \ fi - @$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/check_extension_modules.py + @$(MODULE_CHECK_COMMAND) .PHONY: rundsymutil rundsymutil: sharedmods $(PYTHON_FOR_BUILD_DEPS) $(BUILDPYTHON) @@ -1572,7 +1639,7 @@ Modules/Setup.bootstrap: $(srcdir)/Modules/Setup.bootstrap.in config.status Modules/Setup.stdlib: $(srcdir)/Modules/Setup.stdlib.in config.status ./config.status $@ -Makefile Modules/config.c: Makefile.pre \ +Makefile Modules/config.c Modules/config_bootstrap.c: Makefile.pre \ $(srcdir)/Modules/config.c.in \ $(MAKESETUP) \ $(srcdir)/Modules/Setup \ @@ -1583,9 +1650,9 @@ Makefile Modules/config.c: Makefile.pre \ -s Modules \ Modules/Setup.local \ Modules/Setup.stdlib \ - Modules/Setup.bootstrap \ + -b Modules/Setup.bootstrap \ $(srcdir)/Modules/Setup - @mv config.c Modules + @mv config.c config_bootstrap.c Modules @echo "The Makefile was updated, you may need to re-run make." .PHONY: regen-test-frozenmain @@ -1606,8 +1673,8 @@ regen-re: $(BUILDPYTHON) # using Tools/build/generate_re_casefix.py $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/generate_re_casefix.py $(srcdir)/Lib/re/_casefix.py -Programs/_testembed: Programs/_testembed.o $(LINK_PYTHON_DEPS) - $(LINKCC) $(PY_CORE_EXE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) +Programs/_testembed: Programs/_testembed.o $(PLATFORM_MAIN_OBJS) $(LINK_PYTHON_DEPS) + $(LINKCC) $(PY_CORE_EXE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(PLATFORM_MAIN_OBJS) $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) ############################################################################ # "Bootstrap Python" used to run Programs/_freeze_module.py @@ -1615,13 +1682,14 @@ Programs/_testembed: Programs/_testembed.o $(LINK_PYTHON_DEPS) BOOTSTRAP_HEADERS = \ Python/frozen_modules/importlib._bootstrap.h \ Python/frozen_modules/importlib._bootstrap_external.h \ - Python/frozen_modules/zipimport.h + Python/frozen_modules/zipimport.h \ + Python/frozen_modules/builtins.h Programs/_bootstrap_python.o: Programs/_bootstrap_python.c $(BOOTSTRAP_HEADERS) $(PYTHON_HEADERS) -_bootstrap_python: $(LIBRARY_OBJS_OMIT_FROZEN) Programs/_bootstrap_python.o Modules/getpath.o Modules/Setup.local - $(LINKCC) $(PY_LDFLAGS_NOLTO) -o $@ $(LIBRARY_OBJS_OMIT_FROZEN) \ - Programs/_bootstrap_python.o Modules/getpath.o $(LIBS) $(MODLIBS) $(SYSLIBS) +_bootstrap_python: $(BOOTSTRAP_LIBRARY_OBJS) Programs/_bootstrap_python.o Modules/getpath.o Modules/Setup.local + $(LINKCC) $(PY_LDFLAGS_NOLTO) -o $@ $(BOOTSTRAP_LIBRARY_OBJS) \ + Programs/_bootstrap_python.o Modules/getpath.o $(LIBS) $(BOOTSTRAP_MODLIBS) $(SYSLIBS) # Dummy pybuilddir.txt is needed for _bootstrap_python to be runnable @echo "none" > ./pybuilddir.txt @@ -1639,6 +1707,9 @@ _bootstrap_python: $(LIBRARY_OBJS_OMIT_FROZEN) Programs/_bootstrap_python.o Modu # # Standard build process: # 1) compile minimal core objects for Py_Compile*() and PyMarshal_Write*(). +# Only the bootstrap modules (Modules/Setup.bootstrap) are part of these +# objects (see BOOTSTRAP_LIBRARY_OBJS), so other builtin modules may +# depend on the output of the following steps. # 2) build Programs/_freeze_module binary. # 3) create frozen module headers for importlib and getpath. # 4) build _bootstrap_python binary. @@ -1656,13 +1727,9 @@ FROZEN_FILES_IN = \ Lib/importlib/_bootstrap.py \ Lib/importlib/_bootstrap_external.py \ Lib/zipimport.py \ + Lib/_pybuiltins.py \ Lib/abc.py \ Lib/codecs.py \ - Lib/encodings/__init__.py \ - Lib/encodings/aliases.py \ - Lib/encodings/utf_8.py \ - Lib/encodings/_win_cp_codecs.py \ - Lib/encodings/_iconv_codecs.py \ Lib/io.py \ Lib/_collections_abc.py \ Lib/_sitebuiltins.py \ @@ -1687,13 +1754,9 @@ FROZEN_FILES_OUT = \ Python/frozen_modules/importlib._bootstrap.h \ Python/frozen_modules/importlib._bootstrap_external.h \ Python/frozen_modules/zipimport.h \ + Python/frozen_modules/builtins.h \ Python/frozen_modules/abc.h \ Python/frozen_modules/codecs.h \ - Python/frozen_modules/encodings.h \ - Python/frozen_modules/encodings.aliases.h \ - Python/frozen_modules/encodings.utf_8.h \ - Python/frozen_modules/encodings._win_cp_codecs.h \ - Python/frozen_modules/encodings._iconv_codecs.h \ Python/frozen_modules/io.h \ Python/frozen_modules/_collections_abc.h \ Python/frozen_modules/_sitebuiltins.h \ @@ -1719,8 +1782,8 @@ Programs/_freeze_module.o: Programs/_freeze_module.c Makefile Modules/getpath_noop.o: $(srcdir)/Modules/getpath_noop.c Makefile -Programs/_freeze_module: Programs/_freeze_module.o Modules/getpath_noop.o $(LIBRARY_OBJS_OMIT_FROZEN) - $(LINKCC) $(PY_CORE_LDFLAGS) -o $@ Programs/_freeze_module.o Modules/getpath_noop.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS) +Programs/_freeze_module: Programs/_freeze_module.o Modules/getpath_noop.o $(BOOTSTRAP_LIBRARY_OBJS) + $(LINKCC) $(PY_CORE_LDFLAGS) -o $@ Programs/_freeze_module.o Modules/getpath_noop.o $(BOOTSTRAP_LIBRARY_OBJS) $(LIBS) $(BOOTSTRAP_MODLIBS) $(SYSLIBS) # We manually freeze getpath.py rather than through freeze_modules Python/frozen_modules/getpath.h: Modules/getpath.py $(FREEZE_MODULE_BOOTSTRAP_DEPS) @@ -1737,27 +1800,15 @@ Python/frozen_modules/importlib._bootstrap_external.h: Lib/importlib/_bootstrap_ Python/frozen_modules/zipimport.h: Lib/zipimport.py $(FREEZE_MODULE_BOOTSTRAP_DEPS) $(FREEZE_MODULE_BOOTSTRAP) zipimport $(srcdir)/Lib/zipimport.py Python/frozen_modules/zipimport.h +Python/frozen_modules/builtins.h: Lib/_pybuiltins.py $(FREEZE_MODULE_BOOTSTRAP_DEPS) + $(FREEZE_MODULE_BOOTSTRAP) builtins $(srcdir)/Lib/_pybuiltins.py Python/frozen_modules/builtins.h + Python/frozen_modules/abc.h: Lib/abc.py $(FREEZE_MODULE_DEPS) $(FREEZE_MODULE) abc $(srcdir)/Lib/abc.py Python/frozen_modules/abc.h Python/frozen_modules/codecs.h: Lib/codecs.py $(FREEZE_MODULE_DEPS) $(FREEZE_MODULE) codecs $(srcdir)/Lib/codecs.py Python/frozen_modules/codecs.h -Python/frozen_modules/encodings.h: Lib/encodings/__init__.py $(FREEZE_MODULE_DEPS) - $(FREEZE_MODULE) encodings $(srcdir)/Lib/encodings/__init__.py Python/frozen_modules/encodings.h - -Python/frozen_modules/encodings.aliases.h: Lib/encodings/aliases.py $(FREEZE_MODULE_DEPS) - $(FREEZE_MODULE) encodings.aliases $(srcdir)/Lib/encodings/aliases.py Python/frozen_modules/encodings.aliases.h - -Python/frozen_modules/encodings.utf_8.h: Lib/encodings/utf_8.py $(FREEZE_MODULE_DEPS) - $(FREEZE_MODULE) encodings.utf_8 $(srcdir)/Lib/encodings/utf_8.py Python/frozen_modules/encodings.utf_8.h - -Python/frozen_modules/encodings._win_cp_codecs.h: Lib/encodings/_win_cp_codecs.py $(FREEZE_MODULE_DEPS) - $(FREEZE_MODULE) encodings._win_cp_codecs $(srcdir)/Lib/encodings/_win_cp_codecs.py Python/frozen_modules/encodings._win_cp_codecs.h - -Python/frozen_modules/encodings._iconv_codecs.h: Lib/encodings/_iconv_codecs.py $(FREEZE_MODULE_DEPS) - $(FREEZE_MODULE) encodings._iconv_codecs $(srcdir)/Lib/encodings/_iconv_codecs.py Python/frozen_modules/encodings._iconv_codecs.h - Python/frozen_modules/io.h: Lib/io.py $(FREEZE_MODULE_DEPS) $(FREEZE_MODULE) io $(srcdir)/Lib/io.py Python/frozen_modules/io.h @@ -1866,6 +1917,7 @@ regen-unicodedata: # Regenerate all generated files # "clinic" is regenerated implicitly via "regen-global-objects". +# Keep the list of targets to run manually in sync with Doc/using/configure.rst. .PHONY: regen-all regen-all: regen-cases regen-slots \ regen-token regen-ast regen-keyword regen-sre regen-frozen \ @@ -1885,11 +1937,24 @@ Modules/getbuildinfo.o: $(PARSER_OBJS) \ $(MODOBJS) \ $(DTRACE_OBJS) \ $(srcdir)/Modules/getbuildinfo.c - $(CC) -c $(PY_CORE_CFLAGS) \ + $(CC) -c $(PY_CORE_CFLAGS) $(GETBUILDINFO_CFLAGS) \ + -o $@ $(srcdir)/Modules/getbuildinfo.c + +# Separate object for the build helper programs: it must not depend on +# $(MODOBJS), which may in turn depend on the helpers' output. +Modules/getbuildinfo_bootstrap.o: $(PARSER_OBJS) \ + $(OBJECT_OBJS) \ + $(PYTHON_OBJS) \ + $(MODULE_OBJS_COMMON) \ + $(BOOTSTRAP_MODOBJS) \ + $(srcdir)/Modules/getbuildinfo.c + $(CC) -c $(PY_CORE_CFLAGS) $(GETBUILDINFO_CFLAGS) \ + -o $@ $(srcdir)/Modules/getbuildinfo.c + +GETBUILDINFO_CFLAGS= \ -DGITVERSION="\"`LC_ALL=C $(GITVERSION)`\"" \ -DGITTAG="\"`LC_ALL=C $(GITTAG)`\"" \ - -DGITBRANCH="\"`LC_ALL=C $(GITBRANCH)`\"" \ - -o $@ $(srcdir)/Modules/getbuildinfo.c + -DGITBRANCH="\"`LC_ALL=C $(GITBRANCH)`\"" Modules/getpath.o: $(srcdir)/Modules/getpath.c Python/frozen_modules/getpath.h Makefile $(PYTHON_HEADERS) $(CC) -c $(PY_CORE_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \ @@ -1966,6 +2031,7 @@ regen-pegen: $(srcdir)/Grammar/Tokens \ -o $(srcdir)/Parser/parser.c.new $(UPDATE_FILE) --create $(srcdir)/Parser/parser.c $(srcdir)/Parser/parser.c.new + $(UPDATE_FILE) --create $(srcdir)/Parser/parser_invalid.c $(srcdir)/Parser/parser_invalid.c.new .PHONY: regen-ast regen-ast: @@ -2090,9 +2156,12 @@ Objects/obmalloc.o: $(srcdir)/Objects/mimalloc/alloc.c \ $(srcdir)/Objects/mimalloc/alloc-aligned.c \ $(srcdir)/Objects/mimalloc/alloc-posix.c \ $(srcdir)/Objects/mimalloc/arena.c \ + $(srcdir)/Objects/mimalloc/arena-abandon.c \ $(srcdir)/Objects/mimalloc/bitmap.c \ + $(srcdir)/Objects/mimalloc/free.c \ $(srcdir)/Objects/mimalloc/heap.c \ $(srcdir)/Objects/mimalloc/init.c \ + $(srcdir)/Objects/mimalloc/libc.c \ $(srcdir)/Objects/mimalloc/options.c \ $(srcdir)/Objects/mimalloc/os.c \ $(srcdir)/Objects/mimalloc/page.c \ @@ -2101,6 +2170,7 @@ Objects/obmalloc.o: $(srcdir)/Objects/mimalloc/alloc.c \ $(srcdir)/Objects/mimalloc/segment-map.c \ $(srcdir)/Objects/mimalloc/stats.c \ $(srcdir)/Objects/mimalloc/prim/prim.c \ + $(srcdir)/Objects/mimalloc/prim/emscripten/prim.c \ $(srcdir)/Objects/mimalloc/prim/osx/prim.c \ $(srcdir)/Objects/mimalloc/prim/unix/prim.c \ $(srcdir)/Objects/mimalloc/prim/wasi/prim.c @@ -2252,7 +2322,7 @@ regen-slots: Python/slots.toml $(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_slots.py \ --generate-all -$(LIBRARY_OBJS) $(MODOBJS) Programs/python.o: $(PYTHON_HEADERS) +$(LIBRARY_OBJS) $(MODOBJS) Modules/config_bootstrap.o Programs/python.o $(PLATFORM_MAIN_OBJS): $(PYTHON_HEADERS) ###################################################################### @@ -2293,32 +2363,31 @@ testuniversal: all $(RUNSHARED) /usr/libexec/oah/translate \ ./$(BUILDPYTHON) -E -m test -j 0 -u all $(TESTOPTS) -# Run the test suite on the iOS simulator. Must be run on a macOS machine with -# a full Xcode install that has an iPhone SE (3rd edition) simulator available. +# Run the test suite on an Apple Mobile (i.e., iOS/tvOS/watchOS/visionOS) +# device simulator. Must be run on a macOS machine with a full Xcode install +# that has an SE-class simulator available for the chosen platform. # This must be run *after* a `make install` has completed the build. The -# `--with-framework-name` argument *cannot* be used when configuring the build. -XCFOLDER:=iOSTestbed.$(MULTIARCH).$(shell date +%s).$$PPID +# testbed is configured for the framework name used to configure the build; +# that name is expected to be `Python`, optionally followed by uppercased ABI +# flags (e.g., `PythonT`). +XCFOLDER:=AppleTestbed.$(MULTIARCH).$(shell date +%s).$$PPID .PHONY: testios testios: - @if test "$(MACHDEP)" != "ios"; then \ - echo "Cannot run the iOS testbed for a non-iOS build."; \ + @if test "$(MACHDEP)" != "ios" -a "$(MACHDEP)" != "tvos" -a "$(MACHDEP)" != "visionos" -a "$(MACHDEP)" != "watchos" ; then \ + echo "Cannot run the Apple mobile testbed for a $(MACHDEP) build."; \ exit 1;\ fi - @if test "$(findstring -iphonesimulator,$(MULTIARCH))" != "-iphonesimulator"; then \ - echo "Cannot run the iOS testbed for non-simulator builds."; \ - exit 1;\ - fi - @if test $(PYTHONFRAMEWORK) != "Python"; then \ - echo "Cannot run the iOS testbed with a non-default framework name."; \ + @if test "$(findstring simulator,$(MULTIARCH))" != "simulator"; then \ + echo "Cannot run the Apple mobile testbed for non-simulator builds."; \ exit 1;\ fi @if ! test -d $(PYTHONFRAMEWORKPREFIX); then \ - echo "Cannot find a finalized iOS Python.framework. Have you run 'make install' to finalize the framework build?"; \ + echo "Cannot find a finalized Python.framework. Have you run 'make install' to finalize the framework build?"; \ exit 1;\ fi # Clone the testbed project into the XCFOLDER - $(PYTHON_FOR_BUILD) $(srcdir)/Platforms/Apple/testbed clone --framework $(PYTHONFRAMEWORKPREFIX) "$(XCFOLDER)" + $(PYTHON_FOR_BUILD) $(srcdir)/Platforms/Apple/testbed clone --platform $(MACHDEP) --framework $(PYTHONFRAMEWORKPREFIX) "$(XCFOLDER)" # Run the testbed project $(PYTHON_FOR_BUILD) "$(XCFOLDER)" run --verbose -- test -uall --single-process --rerun -W --pythoninfo @@ -2370,7 +2439,7 @@ install: @FRAMEWORKINSTALLFIRST@ @INSTALLTARGETS@ @FRAMEWORKINSTALLLAST@ upgrade) ensurepip="--upgrade" ;; \ install|*) ensurepip="" ;; \ esac; \ - $(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \ + $(RUNSHARED_FOR_BUILD) $(PYTHON_FOR_BUILD) -m ensurepip \ $$ensurepip --root=$(DESTDIR)/ ; \ fi @@ -2381,7 +2450,7 @@ altinstall: commoninstall upgrade) ensurepip="--altinstall --upgrade" ;; \ install|*) ensurepip="--altinstall" ;; \ esac; \ - $(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \ + $(RUNSHARED_FOR_BUILD) $(PYTHON_FOR_BUILD) -m ensurepip \ $$ensurepip --root=$(DESTDIR)/ ; \ fi @@ -2417,7 +2486,7 @@ sharedinstall: all # Install the interpreter with $(VERSION) affixed # This goes into $(exec_prefix) .PHONY: altbininstall -altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@ +altbininstall: all @FRAMEWORKPYTHONW@ @for i in $(BINDIR) $(LIBDIR); \ do \ if test ! -d $(DESTDIR)$$i; then \ @@ -2622,7 +2691,6 @@ TESTSUBDIRS= idlelib/idle_test \ test/test_capi \ test/test_cext \ test/test_concurrent_futures \ - test/test_cppext \ test/test_ctypes \ test/test_dataclasses \ test/test_doctest \ @@ -2687,6 +2755,7 @@ TESTSUBDIRS= idlelib/idle_test \ test/test_lazy_import/data/pkg \ test/test_lazy_import/data/badsyntax \ test/test_lazy_import/data/circular_import_pkg \ + test/test_lazy_import/data/lazypkg \ test/test_lazy_import/data/metasyntactic \ test/test_lazy_import/data/metasyntactic/foo \ test/test_lazy_import/data/metasyntactic/foo/ack \ @@ -2847,12 +2916,12 @@ libinstall: all $(srcdir)/Modules/xxmodule.c patch --force --reject-file "$(abs_builddir)/app-store-compliance.rej" --strip 2 --directory "$(DESTDIR)$(LIBDEST)" --input "$(abs_srcdir)/$(APP_STORE_COMPLIANCE_PATCH)" || true ; \ fi @ # Build PYC files for the 3 optimization levels (0, 1, 2) - -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ + -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED_FOR_BUILD) \ $(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \ -o 0 -o 1 -o 2 $(COMPILEALL_OPTS) -d $(LIBDEST) -f \ -x 'bad_coding|badsyntax|site-packages' \ $(DESTDIR)$(LIBDEST) - -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ + -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED_FOR_BUILD) \ $(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \ -o 0 -o 1 -o 2 $(COMPILEALL_OPTS) -d $(LIBDEST)/site-packages -f \ -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages @@ -2936,8 +3005,11 @@ inclinstall: $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/internal; \ done @if test "$(INSTALL_MIMALLOC)" = "yes"; then \ - echo $(INSTALL_DATA) $(srcdir)/Include/internal/mimalloc/mimalloc.h $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc.h; \ - $(INSTALL_DATA) $(srcdir)/Include/internal/mimalloc/mimalloc.h $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc.h; \ + for i in $(srcdir)/Include/internal/mimalloc/*.h; \ + do \ + echo $(INSTALL_DATA) $$i $(INCLUDEPY)/internal/mimalloc; \ + $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/internal/mimalloc; \ + done; \ for i in $(srcdir)/Include/internal/mimalloc/mimalloc/*.h; \ do \ echo $(INSTALL_DATA) $$i $(INCLUDEPY)/internal/mimalloc/mimalloc; \ @@ -2977,6 +3049,9 @@ libainstall: all scripts fi; \ fi; \ $(INSTALL_DATA) Programs/python.o $(DESTDIR)$(LIBPL)/python.o; \ + for i in $(PLATFORM_MAIN_OBJS); do \ + $(INSTALL_DATA) $$i $(DESTDIR)$(LIBPL); \ + done; \ fi $(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c $(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in @@ -3066,7 +3141,7 @@ frameworkinstallunversionedstructure: $(LDLIBRARY) rm -rf $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/include; \ fi $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR) - sed 's/%VERSION%/'"`$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import platform; print(platform.python_version())'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Info.plist + sed 's/%VERSION%/'"`$(RUNSHARED_FOR_BUILD) $(PYTHON_FOR_BUILD) -c 'import platform; print(platform.python_version())'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Info.plist $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY) $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBDIR) $(LN) -fs "../$(LDLIBRARY)" "$(DESTDIR)$(prefix)/lib/libpython$(LDVERSION).dylib" @@ -3164,13 +3239,6 @@ Python/asm_trampoline_universal2.o: $(srcdir)/Python/asm_trampoline_aarch64.S $( rm -f Python/asm_trampoline_arm64-apple-darwin.o \ Python/asm_trampoline_x86_64-apple-darwin.o -Python/emscripten_trampoline_inner.wasm: $(srcdir)/Python/emscripten_trampoline_inner.c - # emcc has a path that ends with emsdk/upstream/emscripten/emcc, we're looking for emsdk/upstream/bin/clang. - $$(em-config LLVM_ROOT)/clang -o $@ $< -mgc -O2 -Wl,--no-entry -Wl,--import-table -Wl,--import-memory -target wasm32-unknown-unknown -nostdlib - -Python/emscripten_trampoline_wasm.c: Python/emscripten_trampoline_inner.wasm - $(PYTHON_FOR_REGEN) $(srcdir)/Platforms/emscripten/prepare_external_wasm.py $< $@ getWasmTrampolineModule - JIT_SHIM_BUILD_OBJS= @JIT_SHIM_BUILD_O@ JIT_UNWIND_INFO_H= $(if $(JIT_OBJS),jit_unwind_info.h $(patsubst jit_stencils-%.h,jit_unwind_info-%.h,@JIT_STENCILS_H@)) JIT_BUILD_TARGETS= jit_stencils.h @JIT_STENCILS_H@ $(JIT_UNWIND_INFO_H) $(JIT_SHIM_BUILD_OBJS) @@ -3298,7 +3366,7 @@ clean-retain-profile: pycremoval find build -name '*.py[co]' -exec rm -f {} ';' || true -rm -f pybuilddir.txt -rm -f _bootstrap_python - -rm -rf web_example python.mjs python.wasm python*.symbols python*.map + -rm -rf web_example web_embed_test python.mjs python.wasm python*.symbols python*.map -rm -f Programs/_testembed Programs/_freeze_module -rm -rf Python/deepfreeze -rm -f Python/frozen_modules/*.h @@ -3340,7 +3408,7 @@ clean: clean-profile clean-jit-stencils clobber: clean -rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \ tags TAGS \ - config.cache config.log pyconfig.h Modules/config.c + config.cache config.log pyconfig.h Modules/config.c Modules/config_bootstrap.c -rm -rf build platform -rm -rf $(PYTHONFRAMEWORKDIR) -rm -rf Platforms/Apple/iOS/Frameworks @@ -3457,9 +3525,9 @@ MODULE__CTYPES_DEPS=$(srcdir)/Modules/_ctypes/ctypes.h MODULE__CTYPES_TEST_DEPS=$(srcdir)/Modules/_ctypes/_ctypes_test_generated.c.h MODULE__CTYPES_MALLOC_CLOSURE=@MODULE__CTYPES_MALLOC_CLOSURE@ MODULE__ELEMENTTREE_DEPS=$(srcdir)/Modules/pyexpat.c @LIBEXPAT_INTERNAL@ -MODULE__HASHLIB_DEPS=$(srcdir)/Modules/hashlib.h +MODULE__HASHLIB_DEPS=$(srcdir)/Modules/hashlib.h $(srcdir)/Modules/_openssl_mem.h MODULE__IO_DEPS=$(srcdir)/Modules/_io/_iomodule.h -MODULE__REMOTE_DEBUGGING_DEPS=$(srcdir)/Modules/_remote_debugging/_remote_debugging.h $(srcdir)/Modules/_remote_debugging/gc_stats.h +MODULE__REMOTE_DEBUGGING_DEPS=$(srcdir)/Modules/_remote_debugging/_remote_debugging.h $(srcdir)/Modules/_remote_debugging/binary_io.h $(srcdir)/Modules/_remote_debugging/gc_stats.h # HACL*-based cryptographic primitives MODULE__MD5_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_MD5_HEADERS) $(LIBHACL_MD5_LIB_@LIBHACL_LDEPS_LIBTYPE@) @@ -3476,10 +3544,10 @@ MODULE__HMAC_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_HMAC_HEADERS) $(LIBHACL_ MODULE__HMAC_LDEPS=$(LIBHACL_HMAC_LIB_@LIBHACL_LDEPS_LIBTYPE@) MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h $(srcdir)/Modules/addrinfo.h $(srcdir)/Modules/getaddrinfo.c $(srcdir)/Modules/getnameinfo.c -MODULE__SSL_DEPS=$(srcdir)/Modules/_ssl.h $(srcdir)/Modules/_ssl/cert.c $(srcdir)/Modules/_ssl/debughelpers.c $(srcdir)/Modules/_ssl/misc.c $(srcdir)/Modules/_ssl_data_111.h $(srcdir)/Modules/_ssl_data_300.h $(srcdir)/Modules/socketmodule.h +MODULE__SSL_DEPS=$(srcdir)/Modules/_ssl.h $(srcdir)/Modules/_openssl_mem.h $(srcdir)/Modules/_ssl/cert.c $(srcdir)/Modules/_ssl/debughelpers.c $(srcdir)/Modules/_ssl/misc.c $(srcdir)/Modules/_ssl/distrusted_spki.h $(srcdir)/Modules/_ssl_data_111.h $(srcdir)/Modules/_ssl_data_300.h $(srcdir)/Modules/socketmodule.h MODULE__TESTCAPI_DEPS=$(srcdir)/Modules/_testcapi/parts.h $(srcdir)/Modules/_testcapi/util.h MODULE__TESTLIMITEDCAPI_DEPS=$(srcdir)/Modules/_testlimitedcapi/testcapi_long.h $(srcdir)/Modules/_testlimitedcapi/parts.h $(srcdir)/Modules/_testlimitedcapi/util.h -MODULE__TESTINTERNALCAPI_DEPS=$(srcdir)/Modules/_testinternalcapi/parts.h $(srcdir)/Python/ceval.h $(srcdir)/Modules/_testinternalcapi/test_targets.h $(srcdir)/Modules/_testinternalcapi/test_cases.c.h +MODULE__TESTINTERNALCAPI_DEPS=$(srcdir)/Modules/_testinternalcapi/parts.h $(srcdir)/Parser/tokenizer/source.h $(srcdir)/Parser/tokenizer/types.h $(srcdir)/Python/ceval.h $(srcdir)/Modules/_testinternalcapi/test_targets.h $(srcdir)/Modules/_testinternalcapi/test_cases.c.h MODULE__SQLITE3_DEPS=$(srcdir)/Modules/_sqlite/connection.h $(srcdir)/Modules/_sqlite/cursor.h $(srcdir)/Modules/_sqlite/microprotocols.h $(srcdir)/Modules/_sqlite/module.h $(srcdir)/Modules/_sqlite/prepare_protocol.h $(srcdir)/Modules/_sqlite/row.h $(srcdir)/Modules/_sqlite/util.h MODULE__ZSTD_DEPS=$(srcdir)/Modules/_zstd/_zstdmodule.h $(srcdir)/Modules/_zstd/buffer.h $(srcdir)/Modules/_zstd/zstddict.h diff --git a/Misc/ACKS b/Misc/ACKS index fec00c1b272f4ea..c3ecfc1e315a595 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -117,6 +117,7 @@ Cesar Eduardo Barros Des Barry Emanuel Barry Ulf Bartelt +Tim Bartlett Campbell Barton Don Bashford Pior Bastida @@ -426,6 +427,7 @@ Hauke Dämpfling Evan Dandrea Eric Daniel Scott David Daniels +Aaron Davidson Derzsi Dániel Lawrence D'Anna Steven D'Aprano @@ -748,6 +750,7 @@ Peter Harris Jonathan Hartley Travis B. Hartwell Henrik Harutyunyan +Ashley Harvey Shane Harvey Larry Hastings Tim Hatch @@ -882,6 +885,7 @@ Dean Inwood Bob Ippolito Roger Irwin Atsuo Ishimoto +Timofei Ivankov Alexey Izbyshev Kasia Jachim Adam Jackson @@ -1104,6 +1108,7 @@ Michael Layzell Michael Lazar Peter Lazorchak Brian Leair +Iain Learmonth Mathieu Leduc-Hamel Amandine Lee Antony Lee @@ -1141,6 +1146,7 @@ Ivan Levkivskyi Ben Lewis William Lewis Akira Li +Han Li Jiahao Li Robert Li Xuanji Li @@ -1265,6 +1271,7 @@ Rihaan Meher Bill van Melle Lucas Prado Melo Ezio Melotti +Ashwin Menon Doug Mennella Dimitri Merejkowsky Brian Merrell @@ -2043,6 +2050,7 @@ Sjoerd de Vries Jonas Wagner Daniel Wagner-Hall Niki W. Waibel +WakaTaira Wojtek Walczak Charles Waldman Richard Walker diff --git a/Misc/NEWS.d/3.14.0a6.rst b/Misc/NEWS.d/3.14.0a6.rst index 5fb5306eeaedf56..ae3338d8337ed98 100644 --- a/Misc/NEWS.d/3.14.0a6.rst +++ b/Misc/NEWS.d/3.14.0a6.rst @@ -1398,11 +1398,13 @@ Python 3.18: replace ``_PyUnicodeWriter_WriteSubstring(&writer, str, start, end)`` with :c:func:`PyUnicodeWriter_WriteSubstring(writer, str, start, end) `. * :c:func:`!_PyUnicodeWriter_WriteASCIIString`: - replace ``_PyUnicodeWriter_WriteASCIIString(&writer, str)`` with - :c:func:`PyUnicodeWriter_WriteUTF8(writer, str) `. + replace ``_PyUnicodeWriter_WriteASCIIString(&writer, str, size)`` with + :c:func:`PyUnicodeWriter_WriteUTF8(writer, str, size) `. * :c:func:`!_PyUnicodeWriter_WriteLatin1String`: - replace ``_PyUnicodeWriter_WriteLatin1String(&writer, str)`` with - :c:func:`PyUnicodeWriter_WriteUTF8(writer, str) `. + replace ``_PyUnicodeWriter_WriteLatin1String(&writer, str, size)`` by + decoding the string with :c:func:`PyUnicode_DecodeLatin1`, writing the + result with :c:func:`PyUnicodeWriter_WriteStr`, and releasing the result + with :c:func:`Py_DECREF`. * :c:func:`!_PyUnicodeWriter_Prepare`: (no replacement). * :c:func:`!_PyUnicodeWriter_PrepareKind`: (no replacement). diff --git a/Misc/NEWS.d/3.15.0a1.rst b/Misc/NEWS.d/3.15.0a1.rst index c7e3a872fe72858..d71401e03472602 100644 --- a/Misc/NEWS.d/3.15.0a1.rst +++ b/Misc/NEWS.d/3.15.0a1.rst @@ -2768,8 +2768,8 @@ Fix the "Invalid error handling" exception in .. nonce: Gpr2GB .. section: Library -+Accept leading zeros in precision and width fields for -+:class:`~decimal.Decimal` formatting, for example ``format(Decimal(1.25), +Accept leading zeros in precision and width fields for +:class:`~decimal.Decimal` formatting, for example ``format(Decimal(1.25), '.016f')``. .. @@ -5914,8 +5914,8 @@ Exception text when trying to delete attributes of types was clarified. .. nonce: ALByCb .. section: C API -Function watchers can now receive a PyFunction_PYFUNC_EVENT_MODIFY_QUALNAME -event when a watched functions qualname is changed. +Function watchers can now receive a PyFunction_EVENT_MODIFY_QUALNAME +event when a watched function's qualname is changed. .. diff --git a/Misc/NEWS.d/3.15.0b1.rst b/Misc/NEWS.d/3.15.0b1.rst index e0fcab0eef870fc..b53733f7b5df3bb 100644 --- a/Misc/NEWS.d/3.15.0b1.rst +++ b/Misc/NEWS.d/3.15.0b1.rst @@ -1081,10 +1081,10 @@ Deprecate :meth:`http.cookies.Morsel.js_output` and .. nonce: iHWO0v .. section: Library -Add a *canonical* keyword-only parameter to the base16, base32, base64, -base85, ascii85, and Z85 decoders in :mod:`base64` and :mod:`binascii`. When -true, encodings with non-zero padding bits (base16/32/64) or non-canonical -encodings (base85/ascii85) are rejected. Single-character final groups in +Add a *canonical* keyword-only parameter to the base32, base64, base85, +ascii85, and Z85 decoders in :mod:`base64` and :mod:`binascii`. When true, +encodings with non-zero padding bits (base32/64) or non-canonical encodings +(base85/ascii85) are rejected. Single-character final groups in :func:`binascii.a2b_ascii85` and :func:`binascii.a2b_base85` are now always rejected as encoding violations, regardless of *canonical*; previously they were silently ignored and produced no output bytes. diff --git a/Misc/NEWS.d/3.16.0a1.rst b/Misc/NEWS.d/3.16.0a1.rst new file mode 100644 index 000000000000000..158d83e6bd72b1f --- /dev/null +++ b/Misc/NEWS.d/3.16.0a1.rst @@ -0,0 +1,11791 @@ +.. date: 2026-09-29-16-32-46 +.. gh-issue: 158446 +.. nonce: dToaPr +.. release date: 2026-10-13 +.. section: Security + +Fix a crash or incorrect output that could occur when formatting a +:class:`float` or :class:`complex` with a precision close to the platform's +``INT_MAX``. :c:func:`PyOS_double_to_string` now raises :exc:`ValueError` +for any precision of that magnitude, regardless of presentation type or +value, as the format string parsers already did for precisions above +``INT_MAX``. + +.. + +.. date: 2026-09-23-11-34-30 +.. gh-issue: 156793 +.. nonce: zC_AjF +.. section: Security + +:mod:`asyncio`: :meth:`loop.start_tls() ` and +:meth:`loop.create_connection() ` now +validate the *server_hostname* argument if an :class:`ssl.SSLContext` is +passed with *check_hostname* set to ``True``. + +.. + +.. date: 2026-09-16-14-05-19 +.. gh-issue: 156793 +.. nonce: Qa1T5Z +.. section: Security + +:meth:`ssl.SSLContext.wrap_bio` now validates its *server_side*, +*server_hostname* and *session* arguments similar to +:meth:`ssl.SSLContext.wrap_socket`. + +In particular, a context with :attr:`~ssl.SSLContext.check_hostname` enabled +and no *server_hostname* passed to :meth:`!wrap_bio` now raises +:exc:`ValueError` instead of completing a handshake that verified the +certificate chain without verifying the peer's identity, with no indication +that the check had been skipped. + +.. + +.. date: 2026-09-10-13-38-11 +.. gh-issue: 157265 +.. nonce: -vYuMp +.. section: Security + +In :mod:`tarfile`, when extracting a link falls back to extracting a member +of the archive, skip the member when the filter function returns None when +called with the extracted member's name replaced with the link's. + +.. + +.. date: 2026-08-31-16-47-33 +.. gh-issue: 157953 +.. nonce: KxCF5N +.. section: Security + +Update bundled `libexpat `_ to version 2.8.5. + +.. + +.. date: 2026-08-18-13-54-05 +.. gh-issue: 156002 +.. nonce: CcWXPP +.. section: Security + +Bound the amount of data :mod:`zipfile` decompresses per read for members +compressed with bzip2, LZMA, or Zstandard, matching the existing limit for +deflate. A small archive member could previously expand into an unbounded +allocation even when read in small chunks. + +.. + +.. date: 2026-08-14-11-55-00 +.. gh-issue: 157579 +.. nonce: Kq3Vt2 +.. section: Security + +Fix a race condition in the cleanup of :class:`tempfile.TemporaryDirectory`. +When working around file system permission errors, files are now removed +relative to open directory file descriptors instead of resolving their path +again, so that replacing a directory of the tree with a symbolic link can no +longer make the cleanup delete files outside of the temporary directory. +This addresses :cve:`2026-12345`. + +.. + +.. date: 2026-08-13-13-08-11 +.. gh-issue: 155999 +.. nonce: Xt4rWq +.. section: Security + +Fix the :mod:`tarfile` ``tar`` and ``data`` extraction filters creating +directories outside the destination for members whose name leaves the +destination and returns to it, such as ``../evil/../dest/sub/file``. The +containment check used the resolved path, but intermediate directories were +created from the name as given. + +.. + +.. date: 2026-08-10-12-00-00 +.. gh-issue: 156293 +.. nonce: sNIcbk +.. section: Security + +Fix a crash in :mod:`ssl` when an :attr:`~ssl.SSLContext.sni_callback` +switches a connection to another :class:`~ssl.SSLContext` and the context +that carries the callback is no longer referenced by the application. +Servers that keep their ``sni_callback`` context alive (the usual case when +it wraps the listening socket or is stored on the server object) were not +affected. This addresses :cve:`2026-19445`. + +.. + +.. date: 2026-08-06-11-43-20 +.. gh-issue: 155292 +.. nonce: j4pHBO +.. section: Security + +Change the :mod:`stringprep` module and :mod:`encodings.idna` codec to not +consider Unicode codepoint attributes beyond those defined in :rfc:`3454`. + +.. + +.. date: 2026-07-31-16-20-17 +.. gh-issue: 155694 +.. nonce: SsxlKG +.. section: Security + +Fix :cve:`2026-15806` by scoping :class:`~urllib.request.HTTPPasswordMgr` +credentials to the URL scheme, preventing credentials stored for an HTTPS +URL from being used for a matching HTTP URL, while URIs without a scheme +continue to match any scheme. + +.. + +.. date: 2026-07-04-17-00-00 +.. gh-issue: 153030 +.. nonce: RovkP6 +.. section: Security + +Fixed quadratic complexity in incremental parsing of long unterminated +constructs (such as tags or comments) in :class:`html.parser.HTMLParser`, +which could be exploited for a denial of service. + +.. + +.. date: 2026-06-30-13-24-13 +.. gh-issue: 152674 +.. nonce: -2QVoL +.. section: Security + +The :class:`xml.etree.ElementTree.Element` methods +:meth:`~xml.etree.ElementTree.Element.findall`, +:meth:`~xml.etree.ElementTree.Element.iterfind` and +:meth:`~xml.etree.ElementTree.Element.find` avoid quadratic behavior when +using XPath index predicates (``[1]``, ``[last()]``, ``[last()-N]``) on XML +documents with many same-tag siblings. + +.. + +.. date: 2026-06-25-20-44-20 +.. gh-issue: 152216 +.. nonce: VxiK5y +.. section: Security + +Update bundled `libexpat `_ to version 2.8.2. + +.. + +.. date: 2026-06-23-14-19-30 +.. gh-issue: 151987 +.. nonce: 8mNIMf +.. section: Security + +The :meth:`tarfile.TarFile.extract` method now applies the given filter when +it extracts a link target from the archive as a fallback. + +.. + +.. date: 2026-06-23-13-28-16 +.. gh-issue: 151981 +.. nonce: xBHEcU +.. section: Security + +In :mod:`tarfile`, seeking a stream now stops when end of the stream is +reached. + +.. + +.. date: 2026-06-16-14-58-02 +.. gh-issue: 151544 +.. nonce: _bexVy +.. section: Security + +:file:`Modules/Setup.local` is no longer used as a landmark to discover +whether Python is running in a source tree, as it could potentially affect +actual installs. The :file:`pybuilddir.txt` file is now the sole indicator +of running in a source tree. + +.. + +.. date: 2026-06-10-13-08-19 +.. gh-issue: 151558 +.. nonce: mL74i2 +.. section: Security + +Fixed an vulnerability in the :mod:`tarfile` ``data`` and ``tar`` extraction +filters where crafted archives could create a symlink pointing outside the +destination directory. This was a bypass of :cve:`2025-4330`. + +.. + +.. date: 2026-05-30-09-36-20 +.. gh-issue: 150599 +.. nonce: nlHqU- +.. section: Security + +Fix a possible stack buffer overflow in :mod:`bz2` when a +:class:`bz2.BZ2Decompressor` is reused after a decompression error. The +decompressor now becomes unusable after libbz2 reports an error. + +.. + +.. date: 2026-05-30-00-00-00 +.. gh-issue: 150743 +.. nonce: httpdos +.. section: Security + +:mod:`http.client` now limits the number of chunked-response trailer lines +it will read to :attr:`~http.client.HTTPConnection.max_response_headers` +(100 by default), and the number of interim (1xx) responses it will skip to +100. A malicious or broken server could previously stream trailer lines or +``100 Continue`` responses forever, hanging the client even when a socket +timeout was in use. Reported by ``@YLChen-007`` via GHSA-w4q2-g22w-6fr4. + +.. + +.. date: 2026-05-18-17-46-00 +.. gh-issue: 149835 +.. nonce: EebFlk +.. section: Security + +:func:`shutil.move` now resolves symlinks via :func:`os.path.realpath` when +checking whether the destination is inside the source directory, preventing +a symlink-based bypass of that guard. + +.. + +.. date: 2026-05-11-21-15-07 +.. gh-issue: 149698 +.. nonce: OudOcW +.. section: Security + +Update bundled `libexpat `_ to version 2.8.1 +for the fix for :cve:`2026-45186`. + +.. + +.. date: 2026-05-10-18-05-32 +.. gh-issue: 87451 +.. nonce: XkKB6M +.. section: Security + +The :mod:`ftplib` module's undocumented ``ftpcp`` function no longer trusts +the IPv4 address value returned from the source server in response to the +``PASV`` command by default, completing the fix for CVE-2021-4189. As with +:class:`ftplib.FTP`, the former behavior can be re-enabled by setting the +``trust_server_pasv_ipv4_address`` attribute on the source +:class:`ftplib.FTP` instance to ``True``. Thanks to Qi Deng at Aurascape AI +for the report. + +.. + +.. date: 2026-05-08-02-18-54 +.. gh-issue: 149474 +.. nonce: ujQ-mu +.. section: Security + +Fix the binary writer in :mod:`profiling.sampling` not firing the audit +(:pep:`578`) when creating the output file. The writer and the reader now +accept any path-like object. Patch by Maurycy Pawłowski-Wieroński. + +.. + +.. date: 2026-05-03-21-00-00 +.. gh-issue: 149486 +.. nonce: tarflt +.. section: Security + +:func:`tarfile.data_filter` now validates link targets using the same +normalised value that is written to disk, strips trailing separators from +the member name when resolving a symlink's directory, and rejects link +members that would replace the destination directory itself. This closes +several path-traversal bypasses of the ``data`` extraction filter. + +.. + +.. date: 2026-04-27-16-36-11 +.. gh-issue: 149079 +.. nonce: vKl-LM +.. section: Security + +Fix a potential denial of service in :func:`unicodedata.normalize`. The +canonical ordering step of Unicode normalization used a quadratic-time +insertion sort for reordering combining characters, which could be exploited +with crafted input containing many combining characters in non-canonical +order. Replaced with a linear-time counting sort for long runs. + +.. + +.. date: 2026-04-26-19-30-45 +.. gh-issue: 149018 +.. nonce: a9SqWb +.. section: Security + +Improved protection against XML hash-flooding attacks in +:mod:`xml.parsers.expat` and :mod:`xml.etree.ElementTree` when Python is +compiled with libExpat 2.8.0 or later. + +.. + +.. date: 2026-01-16-11-58-19 +.. gh-issue: 143927 +.. nonce: aviFeG +.. section: Security + +Normalize all line endings (CR, CRLF, and LF) to LF+TAB when writing +multi-line configparser values. + +.. + +.. date: 2026-10-12-23-32-50 +.. gh-issue: 159285 +.. nonce: nlLuwQ +.. section: Core and Builtins + +Fix a crash in a debug build when copying an empty :class:`dict` fails with +:exc:`MemoryError`. Patch by Christian Aurich Zanettini Martins. + +.. + +.. date: 2026-10-11-01-41-31 +.. gh-issue: 129724 +.. nonce: Kq3vTz +.. section: Core and Builtins + +Fix the output of :mod:`marshal` for compiled code, and so the content of +``.pyc`` files, varying with what was imported or compiled earlier in the +process. Strings in :class:`slice` constants made only of ASCII letters, +digits and underscores are now interned in the default build, like those of +other constants. + +.. + +.. date: 2026-10-10-23-50-00 +.. gh-issue: 159137 +.. nonce: gcWalk +.. section: Core and Builtins + +Speed up the garbage collector by untracking tuples and counting the +surviving objects while it looks for unreachable objects, which saves two +walks of the collected generation in every collection. + +.. + +.. date: 2026-10-10-00-00-00 +.. gh-issue: 159137 +.. nonce: gcReuse +.. section: Core and Builtins + +Avoid a second reachability analysis in the garbage collector when no +weakref callback, finalizer, or collectable-object debug output ran. +Finished generators, coroutines, and async generators can skip this analysis +even when finalized. Free-threaded builds also avoid a second stop-the-world +pause in this case. + +.. + +.. date: 2026-10-06-14-12-49 +.. gh-issue: 158918 +.. nonce: TDVkZx +.. section: Core and Builtins + +Reduce C stack usage of ``_PyModule_IsPossiblyShadowing``, which could +potentially cause stack overflows during module attribute access while +deeply recursing in agressively optimized builds. + +.. + +.. date: 2026-10-06-05-12-21 +.. gh-issue: 158803 +.. nonce: iYTpRQ +.. section: Core and Builtins + +Fix a crash in :meth:`bytes.join` and :meth:`bytearray.join` in the +:term:`free-threaded build` when another thread concurrently mutates the +list being joined. Patch by Christian Aurich Zanettini Martins. + +.. + +.. date: 2026-10-05-03-25-30 +.. gh-issue: 158824 +.. nonce: h-hJj7 +.. section: Core and Builtins + +Fix module-level :meth:`~module.__getattr__` being called before a module's +own lazy imports were resolved, which allowed it to shadow them. + +.. + +.. date: 2026-10-05-01-59-22 +.. gh-issue: 158820 +.. nonce: 3KLyOT +.. section: Core and Builtins + +Fix a crash when a :ref:`lazy import ` is declared or resolved +by a finalizer running during interpreter shutdown. + +.. + +.. date: 2026-10-04-11-59-33 +.. gh-issue: 158592 +.. nonce: _BpoeY +.. section: Core and Builtins + +Skip the array reallocation when shrinking a small :class:`list`. Patch by +Donghee Na. + +.. + +.. date: 2026-10-04-01-40-31 +.. gh-issue: 158790 +.. nonce: F3kQ7z +.. section: Core and Builtins + +Speed up :meth:`list.insert` and item deletion via :keyword:`del` in +free-threaded builds by using :manpage:`memmove(3)`. + +.. + +.. date: 2026-10-03-19-11-03 +.. gh-issue: 130706 +.. nonce: 01-O6U +.. section: Core and Builtins + +Add a fast path to ``_Py_Dealloc()`` for non-GC objects. Patch by Donghee +Na. + +.. + +.. date: 2026-10-03-16-14-26 +.. gh-issue: 158583 +.. nonce: 7EUMvS +.. section: Core and Builtins + +:meth:`bytes.fromhex` and :meth:`bytearray.fromhex`: Fix uninitialized +memory read. Patch by Victor Stinner. + +.. + +.. date: 2026-10-02-16-19-35 +.. gh-issue: 158592 +.. nonce: V6W21J +.. section: Core and Builtins + +``del list[index]`` now triggers shrinking the list's internal array. + +.. + +.. date: 2026-10-01-20-00-00 +.. gh-issue: 158140 +.. nonce: small +.. section: Core and Builtins + +Resolve lazily imported sibling submodules independently, so accessing one +does not import another merely because its declaration came last. + +.. + +.. date: 2026-09-30-10-12-41 +.. gh-issue: 158316 +.. nonce: Yv3kQe +.. section: Core and Builtins + +On Free Threading, speed up :meth:`bytearray.decode` by decoding the +underlying storage directly instead of going through the buffer protocol. + +.. + +.. date: 2026-09-30-01-30-58 +.. gh-issue: 158486 +.. nonce: cqmMwv +.. section: Core and Builtins + +Fix the PowerSort mask calculation in :meth:`list.sort` for very large +lists. + +.. + +.. date: 2026-09-29-07-28-20 +.. gh-issue: 158380 +.. nonce: F0J0PO +.. section: Core and Builtins + +Fix incorrect type guards for ``dict`` reads and writes in the experimental +JIT. + +.. + +.. date: 2026-09-28-18-58-27 +.. gh-issue: 158364 +.. nonce: jBqmTs +.. section: Core and Builtins + +Fix crash when :func:`sys._current_frames` or +:func:`sys._current_exceptions` is called while another interpreter is +running. + +.. + +.. date: 2026-09-28-11-52-49 +.. gh-issue: 158219 +.. nonce: tNjBVV +.. section: Core and Builtins + +Fix :class:`bytearray` constructor: do not use a bytes object if its hash +value is already computed. Patch by Cody Maloney and Victor Stinner. + +.. + +.. date: 2026-09-26-23-44-44 +.. gh-issue: 158241 +.. nonce: NZ9OSU +.. section: Core and Builtins + +Fix a crash and possible code object corruption following a +:exc:`MemoryError` while compiling Python code. + +.. + +.. date: 2026-09-26-15-39-32 +.. gh-issue: 158254 +.. nonce: qT7vRk +.. section: Core and Builtins + +Reverse iterators over a :class:`dict` and its views now raise +:exc:`RuntimeError` if the dictionary's keys change during iteration, like +forward iterators, instead of yielding entries for the new keys. + +.. + +.. date: 2026-09-25-22-34-50 +.. gh-issue: 158165 +.. nonce: GVPxKy +.. section: Core and Builtins + +Fix compilation of ``_Py_get_machine_stack_pointer()`` with MinGW on +Windows. Patch by Donghee Na. + +.. + +.. date: 2026-09-24-18-44-40 +.. gh-issue: 158072 +.. nonce: mHveWw +.. section: Core and Builtins + +Fix a JIT crash when a class is instantiated with their default arguments + +.. + +.. date: 2026-09-24-18-20-00 +.. gh-issue: 153569 +.. nonce: diagnostics +.. section: Core and Builtins + +Correct missing-brace error messages for multiline f-strings and t-strings. +Improve tokenization of UTF-8 input split across many readline calls. +Preserve source order when reading files with stateful encodings. Preserve +input errors when scanning string literals. + +.. + +.. date: 2026-09-24-17-30-48 +.. gh-issue: 157914 +.. nonce: 5fVJob +.. section: Core and Builtins + +Revert :gh:`146064`. The linked PyMutex change was causing a significant +performance regression in some cases. + +.. + +.. date: 2026-09-22-12-00-00 +.. gh-issue: 157838 +.. nonce: brcMrg +.. section: Core and Builtins + +Merge biased reference counts on behalf of threads that are detached instead +of waiting for them to attach again, in the free-threaded build. + +.. + +.. date: 2026-09-20-12-11-01 +.. gh-issue: 157840 +.. nonce: EAo1Kp +.. section: Core and Builtins + +Speed up calls to :func:`hasattr` and three-argument :func:`getattr` for +unassigned attributes in an object's :attr:`~object.__slots__` by roughly +6x. + +.. + +.. date: 2026-09-20-08-59-48 +.. gh-issue: 157833 +.. nonce: 3b0bac +.. section: Core and Builtins + +Fix call specialization for C functions and methods with ``METH_CLASS``, +``METH_STATIC``, or ``METH_COEXIST`` flags, improving their call +performance. + +.. + +.. date: 2026-09-19-12-00-00 +.. gh-issue: 157778 +.. nonce: fstring-brace +.. section: Core and Builtins + +Include the line number of the opening brace in the :exc:`SyntaxError` for +an unclosed f-string or t-string replacement field when a matching quote on +a later line is interpreted as the start of an unterminated string. + +.. + +.. date: 2026-09-18-20-24-43 +.. gh-issue: 157468 +.. nonce: zVIAva +.. section: Core and Builtins + +Fix the JIT optimizer folding a builtin name to a constant taken from the +interpreter's builtins dictionary even when the running function uses a +different ``__builtins__`` mapping, such as one created with +``vars(builtins).copy()``. The optimizer now only folds when the function's +builtins is the interpreter's, and the folded constant is guarded at runtime +so that another function sharing the same code object but a different +builtins mapping does not use it. + +.. + +.. date: 2026-09-18-15-20-00 +.. gh-issue: 157757 +.. nonce: Kq3Lm7 +.. section: Core and Builtins + +Fix a lazy ``import a.b as c`` reading ``b`` off ``a`` instead of importing +the module ``a.b``. It now binds the submodule, and raises +:exc:`ModuleNotFoundError` when no module backs the name. + +.. + +.. date: 2026-09-16-15-02-11 +.. gh-issue: 155695 +.. nonce: Kf3xQa +.. section: Core and Builtins + +Resolved names are now removed from :data:`sys.lazy_modules` more +consistently: a lazy import of an already loaded module is no longer +recorded, and reifying ``lazy from pkg import attr`` now discards the +``pkg.attr`` entry. + +.. + +.. date: 2026-09-15-17-04-54 +.. gh-issue: 155742 +.. nonce: 2DUW_9 +.. section: Core and Builtins + +In debug mode at Python exit, check if immutable singleton objects have been +modified by mistake to detect bugs in C extensions. Patch by Victor Stinner. + +.. + +.. date: 2026-09-14-23-16-26 +.. gh-issue: 156939 +.. nonce: oZqlSt +.. section: Core and Builtins + +When Python is built in debug mode, :class:`bytes` and :class:`bytearray` +destructors now check if the trailing null byte has been overridden to +detect buffer overflow. Patch by Victor Stinner. + +.. + +.. date: 2026-09-13-21-00-00 +.. gh-issue: 153568 +.. nonce: prefix-cache +.. section: Core and Builtins + +Speed up parsing by reusing memoized rule prefixes across consecutive +grammar alternatives, avoiding repeated rule calls and cache lookups. + +.. + +.. date: 2026-09-13-17-00-00 +.. gh-issue: 153568 +.. nonce: target-grammar +.. section: Core and Builtins + +Speed up parsing by sharing expression rules with assignment and deletion +targets, and simplify comparison and keyword argument rules. + +.. + +.. date: 2026-09-13-12-46-10 +.. gh-issue: 157378 +.. nonce: Rg7Tq2 +.. section: Core and Builtins + +Fix ``SyntaxError.offset`` and ``SyntaxError.end_offset`` for the "Non-UTF-8 +code starting with ..." error when a non-ASCII character precedes the +invalid byte on the same line. Patch by Shamil Abdulaev. + +.. + +.. date: 2026-09-13-10-43-24 +.. gh-issue: 156762 +.. nonce: Kbf2mo +.. section: Core and Builtins + +Fix undefined behaviour in :class:`operator.methodcaller`: its +:c:member:`~PyTypeObject.tp_clear` slot function returned ``void`` instead +of ``int``, so the garbage collector called it through an incompatible +function type. Patched by Shamil Abdulaev. + +.. + +.. date: 2026-09-12-22-29-51 +.. gh-issue: 157377 +.. nonce: O6WYlM +.. section: Core and Builtins + +Fix :func:`gc.get_count` on the free-threaded build resetting the +thread-local allocation counter that schedules automatic garbage collection. +A thread that called it while allocating could prevent cyclic garbage from +ever being collected. + +.. + +.. date: 2026-09-12-16-40-00 +.. gh-issue: 157361 +.. nonce: anextpy +.. section: Core and Builtins + +Implement :func:`anext` in Python instead of C, in a frozen ``_pybuiltins`` +module. The awaitable returned by ``anext(it, default)`` is now a plain +coroutine, so introspection tools such as :func:`asyncio.print_call_graph` +can see through it into :meth:`~object.__anext__`. + +.. + +.. date: 2026-09-12-12-00-00 +.. gh-issue: 153568 +.. nonce: parser +.. section: Core and Builtins + +Reduce temporary allocations while parsing Python source. + +.. + +.. date: 2026-09-10-08-21-07 +.. gh-issue: 157247 +.. nonce: Zv4bz2 +.. section: Core and Builtins + +Fix :func:`sys.activate_stack_trampoline` allowing activation from a +subinterpreter while the JIT is enabled in the main interpreter. + +.. + +.. date: 2026-09-10-02-50-14 +.. gh-issue: 157242 +.. nonce: LsqOUJ +.. section: Core and Builtins + +If :meth:`bytearray.resize` or :meth:`bytearray.take_bytes` fails, leave the +:class:`bytearray` unchanged, instead of clearing it. Patch by Victor +Stinner. + +.. + +.. date: 2026-09-05-17-32-11 +.. gh-issue: 156995 +.. nonce: Tk3bYt +.. section: Core and Builtins + +Fix :class:`bytearray` sharing its buffer with the single-byte +:class:`bytes` object of the same value, so that writing to the bytearray +modified that :class:`bytes` object. This happened with +:meth:`bytearray.take_bytes` when exactly one byte remained, and on the +free-threaded build when a bytearray was shrunk to one byte from another +thread. + +.. + +.. date: 2026-09-04-22-00-00 +.. gh-issue: 156910 +.. nonce: aBcD3f +.. section: Core and Builtins + +Fix a deadlock in the :term:`free threaded ` build when +setting ``__abstractmethods__`` on a type while another thread holds the +type lock. + +.. + +.. date: 2026-09-04-16-12-30 +.. gh-issue: 156942 +.. nonce: Qk7Rw2 +.. section: Core and Builtins + +:mod:`marshal` no longer replaces the exception raised while marshalling the +value with a generic ``ValueError("unmarshallable object")``. Error +messages now name the type of the unsupported object and, for the types +supported only by newer data formats, the required version. + +.. + +.. date: 2026-09-04-14-06-00 +.. gh-issue: 156091 +.. nonce: nested-comp +.. section: Core and Builtins + +Fix a crash when compiling deeply nested inlined list, set, or dict +comprehensions. A :exc:`SyntaxError` is now raised when the nesting exceeds +the compiler's static block limit. + +.. + +.. date: 2026-09-04-05-25-35 +.. gh-issue: 156865 +.. nonce: 7c5SBs +.. section: Core and Builtins + +Raise :exc:`ValueError`'s for overflows, while trying to change +:class:`memoryview` elements with ``'f'`` and ``'Zf'`` format codes. Patch +by Sergey B Kirpichev. + +.. + +.. date: 2026-09-03-15-20-00 +.. gh-issue: 156894 +.. nonce: Rt9Bx4 +.. section: Core and Builtins + +Fix the position of syntax errors which cover a range if the line contains +non-ASCII characters before the error. + +.. + +.. date: 2026-09-03-12-40-00 +.. gh-issue: 156886 +.. nonce: Kx7mQt +.. section: Core and Builtins + +Fix :exc:`ZeroDivisionError` spuriously raised for a complex power with a +non-zero base when the phase of the result is infinite, e.g. +``1e300**1e308j`` or ``complex('inf')**1j``. + +.. + +.. date: 2026-09-01-07-15-20 +.. gh-issue: 155525 +.. nonce: A7kP2m +.. section: Core and Builtins + +Fix quadratic-time tokenization of modules containing many f-strings or +t-strings. + +.. + +.. date: 2026-08-31-10-45-11 +.. gh-issue: 156689 +.. nonce: Jq3xNv +.. section: Core and Builtins + +Fix an out-of-bounds read in :func:`compile` and :func:`ast.parse` when an +AST object is passed with ``mode='func_type'``. + +.. + +.. date: 2026-08-27-13-26-50 +.. gh-issue: 156459 +.. nonce: Z8Zqik +.. section: Core and Builtins + +Fix cleanup on error in ``compiler_set_qualname``. Previously it was called +in ``_PyCompile_EnterScope``, after the scope had been entered, and this was +not reversed in case of an error. + +.. + +.. date: 2026-08-26-10-00-00 +.. gh-issue: 155725 +.. nonce: tRcMal +.. section: Core and Builtins + +:mod:`tracemalloc` no longer acquires the :term:`GIL` nor creates a +temporary thread state to trace memory allocations: traceback frames now +store plain UTF-8 strings instead of Python str objects, and tracebacks are +captured using the Python thread state already associated with the calling +thread, even if it is not attached. Threads without a Python thread state +record the traceback as ````. + +.. + +.. date: 2026-08-26-01-08-38 +.. gh-issue: 156371 +.. nonce: USpwKG +.. section: Core and Builtins + +Fix missing ``PyRefTracer_DESTROY`` events for trashcan deferred objects. +Patch by Donghee Na. + +.. + +.. date: 2026-08-24-12-00-00 +.. gh-issue: 156310 +.. nonce: pSqIter +.. section: Core and Builtins + +Fix memory safety issues in the :func:`iter` fallback for objects that +implement :meth:`~object.__getitem__` without :meth:`~object.__iter__` +(``PySeqIter_Type``). Sharing an iterator between threads in the +free-threaded build could use the underlying sequence after it was freed, +and re-entrant exhaustion in the default build could decrement the +sequence's reference count twice. Concurrent iteration may still see +duplicate or missing items, but it no longer corrupts the interpreter state. + +.. + +.. date: 2026-08-23-21-30-00 +.. gh-issue: 64862 +.. nonce: Kx7Qm2 +.. section: Core and Builtins + +The :func:`iter` function now accepts the *stop_exception* parameter. The +created iterator stops when the callable raises the specified exception. The +second parameter is now named *stop_value* and can be passed by keyword. +:func:`aiter` now accepts the same *stop_value* and *stop_exception* +parameters, calling an asynchronous callable and awaiting the result. + +.. + +.. date: 2026-08-23-12-00-00 +.. gh-issue: 156114 +.. nonce: Kq7fXz +.. section: Core and Builtins + +Fix a crash in the perf trampoline when a code object has a name or filename +that cannot be encoded to UTF-8. Patched by Shamil Abdulaev. + +.. + +.. date: 2026-08-21-18-49-12 +.. gh-issue: 156204 +.. nonce: ZusA7e +.. section: Core and Builtins + +Fix a crash in :c:func:`PyErr_GivenExceptionMatches` when evaluating deeply +nested exception tuples. The recursion is now bounded, and exceeding the +limit is reported as an unraisable exception. + +.. + +.. date: 2026-08-21-14-38-06 +.. gh-issue: 148750 +.. nonce: xBijjR +.. section: Core and Builtins + +:mod:`encodings` is no longer frozen, due to issues importing submodules +when using a zipped standard library. + +.. + +.. date: 2026-08-20-22-13-20 +.. gh-issue: 156126 +.. nonce: pXm4Qr +.. section: Core and Builtins + +Fix a crash when importing a module whose name contains characters that +cannot be encoded to UTF-8 (such as lone surrogates) while :option:`-X +importtime <-X>` is enabled. + +.. + +.. date: 2026-08-19-06-43-54 +.. gh-issue: 144446 +.. nonce: k3QzXa +.. section: Core and Builtins + +Fix thread safety of the :attr:`!generator.gi_frame`, +:attr:`!coroutine.cr_frame` and :attr:`!agen.ag_frame` attributes in the +free-threading build. + +.. + +.. date: 2026-08-18-18-13-47 +.. gh-issue: 156021 +.. nonce: 3mK5c5 +.. section: Core and Builtins + +Empty :mod:`AST ` node representations no longer include ``...`` when +the recursion depth limit is exceeded, making them easier to distinguish +from non-empty ones. Patch by Bartosz Sławecki. + +.. + +.. date: 2026-08-18-14-19-51 +.. gh-issue: 155254 +.. nonce: 75TMlb +.. section: Core and Builtins + +Avoid warning about missing standard library when using +:ref:`sys-path-init-_pth-files`. + +.. + +.. date: 2026-08-17-15-13-14 +.. gh-issue: 155978 +.. nonce: 4ztALD +.. section: Core and Builtins + +Fix a memory leak in the free-threaded build when setting or deleting a +special method (such as ``__repr__``) on a class that has many subclasses. + +.. + +.. date: 2026-08-16-19-33-01 +.. gh-issue: 148653 +.. nonce: Kt3vQx +.. section: Core and Builtins + +Forbid :mod:`marshalling ` recursive tuples, and fix a crash when +unmarshalling a self-referencing tuple. + +.. + +.. date: 2026-08-15-20-31-20 +.. gh-issue: 155823 +.. nonce: OhNmzi +.. section: Core and Builtins + +Fix a JIT bug where the side exit taken when a virtual iterator is exhausted +left a stale value on the stack, so the tier one interpreter resumed with +corrupted state and ``yield from`` raised :exc:`AttributeError` instead of +finishing normally. + +.. + +.. date: 2026-08-14-19-00-00 +.. gh-issue: 155141 +.. nonce: call-kw +.. section: Core and Builtins + +Compile pure-keyword calls with 16 to 29 keyword arguments using the faster +``CALL_KW`` instruction. This includes common cases such as dataclass +constructors with many fields. + +.. + +.. date: 2026-08-13-13-50-00 +.. gh-issue: 155752 +.. nonce: Rp7K2x +.. section: Core and Builtins + +Fix a crash when a :class:`types.GenericAlias` argument gains a +``__typing_subst__`` hook after the alias parameters have been cached. + +.. + +.. date: 2026-08-11-13-50-35 +.. gh-issue: 155504 +.. nonce: PsTqZm +.. section: Core and Builtins + +Fix a crash when thread state creation fails before the thread state is +fully initialized. + +.. + +.. date: 2026-08-11-06-04-26 +.. gh-issue: 155526 +.. nonce: W7ZHXu +.. section: Core and Builtins + +Fix spurious :exc:`OverflowError` for ``abs(nanj)`` in case :c:data:`errno` +was previously set to :c:macro:`!ERANGE` by some library call. Patch by +Sergey B Kirpichev. + +.. + +.. date: 2026-08-11-01-45-24 +.. gh-issue: 129752 +.. nonce: Zo3OUx +.. section: Core and Builtins + +Don't update adaptive counters in the free-threaded build when thread-local +bytecode is disabled (``-X tlbc=0``). Patch by Donghee Na. + +.. + +.. date: 2026-08-10-11-20-00 +.. gh-issue: 155515 +.. nonce: Lp3qWc +.. section: Core and Builtins + +Track the internal HAMT iterators, which back iteration over a +:class:`contextvars.Context`, with the garbage collector. A reference cycle +running through such an iterator was never collected, leaking the whole +context it iterated over. + +.. + +.. date: 2026-08-07-18-32-15 +.. gh-issue: 155400 +.. nonce: Kq3Vpt +.. section: Core and Builtins + +Fix a deadlock in the free-threaded build between two threads assigning to a +special method of the same class. While applying the type slot updates with +the world stopped, only the type lock was prevented from being released; the +type dict mutex could still be released and re-acquired, in the wrong order, +if the thread blocked on the stop-the-world mutex. + +.. + +.. date: 2026-08-07-14-45-02 +.. gh-issue: 155315 +.. nonce: Mk9Fd2 +.. section: Core and Builtins + +Fix :mod:`marshal` so that a ``frozendict`` referenced more than once in the +serialized data round-trips correctly, instead of failing to load with +:exc:`ValueError`. Patch by tonghuaroot. + +.. + +.. date: 2026-08-07-13-40-12 +.. gh-issue: 155363 +.. nonce: Qk3Vt9 +.. section: Core and Builtins + +Fix a leak in the :term:`free-threaded build` when creating a thread state +fails after an internal QSBR slot has been reserved for it. The slot could +never be reclaimed, so the QSBR array grew without bound across repeated +failures. + +.. + +.. date: 2026-08-07-10-14-56 +.. gh-issue: 154701 +.. nonce: zulh2S +.. section: Core and Builtins + +Fix an infinite loop in JIT when a ``FOR_ITER`` side exit links an executor +back to itself. + +.. + +.. date: 2026-08-02-17-55-29 +.. gh-issue: 154937 +.. nonce: m9IBba +.. section: Core and Builtins + +Fix a data race on thread handle identifiers when ``_thread._shutdown()`` +runs concurrently with the startup of non-daemon threads in the +:term:`free-threaded build`. + +.. + +.. date: 2026-08-01-18-04-11 +.. gh-issue: 120321 +.. nonce: k3XvQb +.. section: Core and Builtins + +Fix thread safety of :term:`asynchronous generators ` when iterated, closed or thrown into concurrently from multiple +threads on the :term:`free threading` build. Also make an ``athrow()`` +awaitable single-use: reusing it after completion now raises +:exc:`RuntimeError` instead of resuming the generator again. + +.. + +.. date: 2026-08-01-15-07-10 +.. gh-issue: 154902 +.. nonce: DIi6sf +.. section: Core and Builtins + +Fix a crash when ``__conditional_annotations__`` is rebound to a non-set +object. + +.. + +.. date: 2026-07-29-08-43-14 +.. gh-issue: 151464 +.. nonce: o_mtmz +.. section: Core and Builtins + +Exclude invalid token ``<>`` from :mod:`tokenize` output. :exc:`SyntaxError` +for ``<>`` now suggests ``!=``. + +.. + +.. date: 2026-07-28-10-00-00 +.. gh-issue: 133931 +.. nonce: fnQzxD +.. section: Core and Builtins + +Fix data races when setting attributes of function objects on the +:term:`free threaded ` build. + +.. + +.. date: 2026-07-27-17-20-49 +.. gh-issue: 154719 +.. nonce: eI88Gs +.. section: Core and Builtins + +Trailing whitespace in a t-string interpolation expression is now preserved +in :attr:`string.templatelib.Interpolation.expression`, up to the closing +``}`` or the conversion (``!``), format (``:``), or debug (``=``) delimiter. +Explicit line continuations following a debug ``=`` remain part of the debug +text and are excluded from +:attr:`~string.templatelib.Interpolation.expression`. + +.. + +.. date: 2026-07-27-16-29-10 +.. gh-issue: 154775 +.. nonce: _ISRIk +.. section: Core and Builtins + +When matching a complex literal in :keyword:`case` statements, an extraneous +``+`` sign (for example, ``1++1j`` or ``1-+1j``) is no longer allowed. + +.. + +.. date: 2026-07-26-09-07-41 +.. gh-issue: 154709 +.. nonce: M2uZ76 +.. section: Core and Builtins + +Fix an out-of-bounds access in reverse dictionary iterators when the +underlying dictionary is cleared and modified after the iterator is created. + +.. + +.. date: 2026-07-25-17-35-14 +.. gh-issue: 154695 +.. nonce: aQWLLv +.. section: Core and Builtins + +Fix :class:`asyncio.Task` raising :exc:`AttributeError` when created with +``eager_start=True`` and no explicit *loop* argument. + +.. + +.. date: 2026-07-25-12-44-13 +.. gh-issue: 154044 +.. nonce: GBa2wP +.. section: Core and Builtins + +Fix a data race on a descriptor's ``__qualname__`` cache in the +:term:`free-threaded build`. + +.. + +.. date: 2026-07-25-12-43-42 +.. gh-issue: 154196 +.. nonce: 0rAdob +.. section: Core and Builtins + +Improve :exc:`AttributeError` messages from unresolved lazy imports. Patch +by Bartosz Sławecki. + +.. + +.. date: 2026-07-24-13-15-31 +.. gh-issue: 153809 +.. nonce: JFA6GT +.. section: Core and Builtins + +Fix interpreter crash while deallocating objects of :class:`asyncio.Task` on +free-threaded builds. Contributed by Sergey Miryanov. + +.. + +.. date: 2026-07-22-14-30-00 +.. gh-issue: 154429 +.. nonce: Qk9mZ2 +.. section: Core and Builtins + +Slightly speed up deallocation of objects that are not tracked by the +garbage collector, such as :class:`int`, :class:`float` and :class:`str`. + +.. + +.. date: 2026-07-21-14-38-49 +.. gh-issue: 145868 +.. nonce: 7iGRvU +.. section: Core and Builtins + +Suggest the closest valid feature name in the :exc:`SyntaxError` message +when an unknown name is imported from :mod:`__future__`. + +.. + +.. date: 2026-07-20-20-16-08 +.. gh-issue: 154275 +.. nonce: l961cA +.. section: Core and Builtins + +Fix a crash when getting deeply nested ``__parameters__`` from a +:class:`types.GenericAlias` objects. + +.. + +.. date: 2026-07-19-19-14-39 +.. gh-issue: 154043 +.. nonce: Kych7F +.. section: Core and Builtins + +Fix a data race when iterating a shared :class:`types.GenericAlias` iterator +from multiple threads under the :term:`free-threaded build`. + +.. + +.. date: 2026-07-19-16-18-25 +.. gh-issue: 154014 +.. nonce: CJsjVL +.. section: Core and Builtins + +Fix a JIT assertion during interpreter shutdown by initializing ``vm_data`` +fields for cold executors that bypass ``_Py_ExecutorInit()``. + +.. + +.. date: 2026-07-19-12-33-27 +.. gh-issue: 153932 +.. nonce: lKw2bo +.. section: Core and Builtins + +Fix thread safety issue in the ``__reduce__`` method of +:py:class:`enumerate`. + +.. + +.. date: 2026-07-17-22-03-39 +.. gh-issue: 153881 +.. nonce: oDa06s +.. section: Core and Builtins + +Fix potential data race when calling :meth:`~object.__getstate__` under the +:term:`free-threaded build`. + +.. + +.. date: 2026-07-16-02-50-01 +.. gh-issue: 153785 +.. nonce: fJqPKC +.. section: Core and Builtins + +:exc:`AttributeError`: The default error message is now generated from +``name`` and ``obj`` attributes when both are set and the exception was +constructed with no positional arguments, or with a single positional +argument equal to ``name``. Patch by Bartosz Sławecki. + +.. + +.. date: 2026-07-14-20-19-48 +.. gh-issue: 152075 +.. nonce: V9Rwhp +.. section: Core and Builtins + +Reduced lock contention during LOAD_GLOBAL bytecode specialization under +free threading. + +.. + +.. date: 2026-07-13-13-05-00 +.. gh-issue: 78959 +.. nonce: Xy4a2B +.. section: Core and Builtins + +Add the *order* parameter to :meth:`memoryview.cast`. With ``order='F'`` it +creates a zero-copy Fortran-contiguous (column-major) view of a flat buffer, +mirroring the *order* argument of :meth:`memoryview.tobytes`. + +.. + +.. date: 2026-07-11-16-53-21 +.. gh-issue: 153568 +.. nonce: newlines +.. section: Core and Builtins + +Speed up the tokenizer by copying source text verbatim when it contains no +carriage returns. + +.. + +.. date: 2026-07-11-15-45-00 +.. gh-issue: 153578 +.. nonce: Qm4Zt9 +.. section: Core and Builtins + +Fix an out-of-bounds write in :meth:`bytearray.extend` when the bytearray is +resized while the argument's :meth:`~object.__buffer__` is being acquired, +for example by another thread. Patch by tonghuaroot. + +.. + +.. date: 2026-07-11-15-30-00 +.. gh-issue: 153570 +.. nonce: Kb7Xd2 +.. section: Core and Builtins + +Fix a use-after-free in :meth:`bytearray.take_bytes` when the argument's +:meth:`~object.__index__` method resizes the bytearray. Patch by +tonghuaroot. + +.. + +.. date: 2026-07-11-15-07-49 +.. gh-issue: 153568 +.. nonce: identcache +.. section: Core and Builtins + +Speed up the parser by caching repeated identifiers during a parse. + +.. + +.. date: 2026-07-11-15-01-45 +.. gh-issue: 153568 +.. nonce: toktext +.. section: Core and Builtins + +Speed up the parser by not materializing the text of tokens whose text is +never read. + +.. + +.. date: 2026-07-11-14-59-17 +.. gh-issue: 153568 +.. nonce: leftrec +.. section: Core and Builtins + +Speed up parsing of left-recursive rules by updating their memoization +entries in place. + +.. + +.. date: 2026-07-11-14-58-24 +.. gh-issue: 153568 +.. nonce: stackchk +.. section: Core and Builtins + +Speed up the parser by turning its per-rule C-stack check into a single +inline comparison. + +.. + +.. date: 2026-07-11-14-57-19 +.. gh-issue: 153568 +.. nonce: memoflt +.. section: Core and Builtins + +Speed up the parser by letting memoization lookups that cannot match return +immediately. + +.. + +.. date: 2026-07-11-01-17-57 +.. gh-issue: 153419 +.. nonce: U8HJOJ +.. section: Core and Builtins + +Fix multiple :class:`bytearray` crashes and reference leaks caused by +skipping :meth:`~object.__init__` and broken state setup code. + +.. + +.. date: 2026-07-09-13-28-27 +.. gh-issue: 153354 +.. nonce: It4Jj_ +.. section: Core and Builtins + +Fix a crash in compiler-generated ``__annotate__`` functions when the +annotation format comparison returned a non-boolean result. + +.. + +.. date: 2026-07-08-13-23-11 +.. gh-issue: 153298 +.. nonce: wvcXxN +.. section: Core and Builtins + +Fixes a data race in :class:`types.GenericAlias` ``__parameters__`` +initialization on free-threading builds. + +.. + +.. date: 2026-07-07-04-16-48 +.. gh-issue: 153205 +.. nonce: 5fE8QZ +.. section: Core and Builtins + +Fix a potential :exc:`SystemError` during vector calls when memory +allocation fails. A :exc:`MemoryError` is now raised instead. + +.. + +.. date: 2026-07-06-18-00-00 +.. gh-issue: 153171 +.. nonce: errloc1 +.. section: Core and Builtins + +Improve syntax error messages for misplaced ``not`` after an operator in +contexts where a generic "invalid syntax" error was previously reported, +such as ``1 << 2 + not x`` and ``1 * + not x``. + +.. + +.. date: 2026-07-06-16-30-00 +.. gh-issue: 153236 +.. nonce: lazy-import-errors +.. section: Core and Builtins + +Propagate exceptions raised while importing lazy submodules instead of +reporting them as missing attributes. + +.. + +.. date: 2026-07-01-12-00-00 +.. gh-issue: 102960 +.. nonce: fR8kJa +.. section: Core and Builtins + +:ref:`Frame objects ` now support :mod:`weak references +`. Patch by Łukasz Langa. + +.. + +.. date: 2026-06-30-14-50-00 +.. gh-issue: 152708 +.. nonce: aBcDeF +.. section: Core and Builtins + +Fix AST generation asymmetry where unary positive ``+`` was implicitly +dropped in pattern match expressions, restoring parsing parity with unary +negative ``-``. + +.. + +.. date: 2026-06-30-14-00-00 +.. gh-issue: 152682 +.. nonce: yId7e5 +.. section: Core and Builtins + +Fix NULL pointer dereference in :func:`compile` when a reserved name (e.g. +``__classdict__``) is used as a type parameter name and memory allocation +fails while formatting the error message. + +.. + +.. date: 2026-06-29-23-29-14 +.. gh-issue: 152635 +.. nonce: O21J0O +.. section: Core and Builtins + +Fix a crash caused when running out of memory creating a +:mod:`!_interpchannels` channel. Now a :exc:`MemoryError` is correctly +raised. + +.. + +.. date: 2026-06-28-14-39-05 +.. gh-issue: 152405 +.. nonce: -_3YRo +.. section: Core and Builtins + +Do not expose the internal mapping of :class:`types.MappingProxyType` when +performing rich-compare operations with non-stdlib types. Previously, it was +possible to mutate the internal mapping of a proxy there. Now we pass not +the original :class:`dict` instance, but its copy, when dealing with custom +types. + +.. + +.. date: 2026-06-28-14-31-03 +.. gh-issue: 152492 +.. nonce: _09Zee +.. section: Core and Builtins + +:type:`collections.OrderedDict` ``update`` method can now accept +:type:`frozendict` as an argument. + +.. + +.. date: 2026-06-27-10-05-12 +.. gh-issue: 152375 +.. nonce: L-ZBk6 +.. section: Core and Builtins + +Fix undefined behaviour when a :mod:`sys.monitoring` callback raised an +exception while the program was following a branch or loop. + +.. + +.. date: 2026-06-26-22-38-21 +.. gh-issue: 152192 +.. nonce: lX2jIM +.. section: Core and Builtins + +Fix a truncated ``oparg`` being passed to JIT trace initialization for a +``JUMP_BACKWARD`` with an ``EXTENDED_ARG``. + +.. + +.. date: 2026-06-26-22-03-16 +.. gh-issue: 152235 +.. nonce: ZKWiWk +.. section: Core and Builtins + +Defer GC tracking of :meth:`set.intersection`, :meth:`set.difference`, +:meth:`set.symmetric_difference`, :meth:`set.union` and ``set.__sub__``. +Patch by Donghee Na. + +.. + +.. date: 2026-06-26-20-37-22 +.. gh-issue: 152315 +.. nonce: iVS7u5 +.. section: Core and Builtins + +:exc:`TypeError` messages for some instance methods called with too many +positional arguments now suggest checking whether the method definition is +missing the ``self`` parameter. + +.. + +.. date: 2026-06-26-05-49-13 +.. gh-issue: 152235 +.. nonce: YU20T9 +.. section: Core and Builtins + +Defer GC tracking of a :class:`set` or :class:`frozenset` to the end of its +construction from iterable. Patch by Donghee Na. + +.. + +.. date: 2026-06-25-21-34-15 +.. gh-issue: 152228 +.. nonce: a6K14K +.. section: Core and Builtins + +Fix an assertion failure when python is built in a debug mode that happened +in :meth:`str.replace` under a limited memory situation. + +.. + +.. date: 2026-06-24-14-05-00 +.. gh-issue: 152107 +.. nonce: K3jX9p +.. section: Core and Builtins + +Fix a crash when creating a :class:`dict` item iterator (for example +``iter(d.items())`` or ``reversed(d.items())``) under a memory-allocation +failure. Patch by Jiucheng Zang. + +.. + +.. date: 2026-06-24-13-36-31 +.. gh-issue: 151722 +.. nonce: lWKfE1 +.. section: Core and Builtins + +:meth:`!frozendict.fromkeys` now only tracks the :class:`frozendict` in the +garbage collector once the dictionary is fully initialized. Patch by Donghee +Na and Victor Stinner. + +.. + +.. date: 2026-06-23-23-48-54 +.. gh-issue: 151763 +.. nonce: Eu8pYQ +.. section: Core and Builtins + +Fixes possible crash on :class:`types.CodeType` deallocation. + +.. + +.. date: 2026-06-23-19-50-22 +.. gh-issue: 152020 +.. nonce: DTKXjR +.. section: Core and Builtins + +On the free-threaded build, :func:`asyncio.all_tasks` no longer loses +eager-started tasks when called from a thread other than the one running the +event loop. + +.. + +.. date: 2026-06-23-12-03-55 +.. gh-issue: 151763 +.. nonce: K7QfWG +.. section: Core and Builtins + +Fix a potential crash in :func:`compile`, :func:`exec`, :func:`eval` and +:func:`ast.parse` when an allocation fails: the parser or compiler could +return without setting an exception. + +.. + +.. date: 2026-06-22-14-48-22 +.. gh-issue: 151912 +.. nonce: YcxfnU +.. section: Core and Builtins + +Fixed a crash in ``type()`` when selecting a metaclass whose ``tp_new`` slot +is ``NULL``. Such metaclasses are now rejected with ``TypeError`` instead of +causing a NULL pointer dereference. + +.. + +.. date: 2026-06-22-11-05-56 +.. gh-issue: 151895 +.. nonce: QQsjUQ +.. section: Core and Builtins + +Fixed a crash in :func:`marshal.loads` when an allocation failed while +loading a reference-tracked dictionary; it now raises :exc:`MemoryError`. + +.. + +.. date: 2026-06-22-06-26-34 +.. gh-issue: 151905 +.. nonce: FOLMYg +.. section: Core and Builtins + +Fix OOM error handling in :c:func:`PyFrame_GetBack` to propagate exceptions +instead of masking them as None. + +.. + +.. date: 2026-06-22-02-42-38 +.. gh-issue: 151907 +.. nonce: 6Tol_J +.. section: Core and Builtins + +Avoid creating :class:`list` objects in comprehensions when the +comprehension is not used as a value. + +.. + +.. date: 2026-06-21-16-00-00 +.. gh-issue: 151773 +.. nonce: mN4kRt +.. section: Core and Builtins + +Fix a crash in :func:`contextvars.ContextVar.set` when memory allocation +fails. + +.. + +.. date: 2026-06-21-12-55-18 +.. gh-issue: 151665 +.. nonce: 82fmzx +.. section: Core and Builtins + +:func:`inspect.signature` now works on the lazy evaluators of type aliases +and type parameters instead of raising :exc:`ValueError`. + +.. + +.. date: 2026-06-20-10-01-26 +.. gh-issue: 151672 +.. nonce: K-w7j0 +.. section: Core and Builtins + +Fix an inconsistency where calling ``__lazy_import__`` with a string +``fromlist`` would return a :class:`types.LazyImportType` that resolves to +the named member, rather than the module being imported. + +.. + +.. date: 2026-06-20-00-30-47 +.. gh-issue: 151722 +.. nonce: RPMPIY +.. section: Core and Builtins + +Defer GC tracking of :class:`frozendict` to end of construction. Patch by +Donghee Na. + +.. + +.. date: 2026-06-19-16-40-01 +.. gh-issue: 151619 +.. nonce: 35yyJW +.. section: Core and Builtins + +Fix an issue where using non-module global or builtin namespaces (such as +dictionaries passed to :func:`exec`) could cause cached global loads to +produce unresolved :ref:`lazy imports `. + +.. + +.. date: 2026-06-19-12-00-00 +.. gh-issue: 151646 +.. nonce: Gc5tAt +.. section: Core and Builtins + +Fix a data race in free-threading builds between :func:`gc.get_stats` and a +concurrent garbage collection cycle. Access to the per-generation +statistics is now serialized with a mutex so the reader observes a +consistent snapshot. + +.. + +.. date: 2026-06-18-16-00-10 +.. gh-issue: 151126 +.. nonce: tBqn6I +.. section: Core and Builtins + +Fix a crash when sharing :class:`memoryview` objects between interpreters +fails due to running out of memory. It now raises a proper +:exc:`MemoryError`. + +.. + +.. date: 2026-06-18-00-00-00 +.. gh-issue: 151644 +.. nonce: 5cFffN +.. section: Core and Builtins + +Fix a data race in :func:`sys.setdlopenflags` and :func:`sys.getdlopenflags` +when called concurrently in the free-threaded build. The underlying +``_PyImport_GetDLOpenFlags`` and ``_PyImport_SetDLOpenFlags`` functions now +use atomic load/store operations. + +.. + +.. date: 2026-06-17-16-46-07 +.. gh-issue: 151126 +.. nonce: vhTL0T +.. section: Core and Builtins + +Avoid possible crash in ``_winapi.c`` where a device has no memory left. Now +it properly raises a :exc:`MemoryError`. Patch by Ivy Xu. + +.. + +.. date: 2026-06-17-16-26-45 +.. gh-issue: 151126 +.. nonce: Yc_6wC +.. section: Core and Builtins + +Avoid possible crash in ``getpath.c`` where a device has no memory left. Now +it properly raises a :exc:`MemoryError`. Patch by Ivy Xu. + +.. + +.. date: 2026-06-16-19-20-00 +.. gh-issue: 151518 +.. nonce: e6v0Js +.. section: Core and Builtins + +Fix a free-threaded stop-the-world fairness issue that could starve a thread +reattaching after being suspended while detached. + +.. + +.. date: 2026-06-16-17-23-37 +.. gh-issue: 151546 +.. nonce: LhiaZz +.. section: Core and Builtins + +Fix the stack limit check if Python is linked to musl (ex: Alpine Linux). +Use the stack size set by the linker to compute the stack limits. Patch by +Victor Stinner. + +.. + +.. date: 2026-06-16-00-45-42 +.. gh-issue: 151510 +.. nonce: HJ-kGn +.. section: Core and Builtins + +Fix a crash in :func:`!__lazy_import__` when called without an explicit +``globals`` argument and without a current Python frame. + +.. + +.. date: 2026-06-14-05-05-15 +.. gh-issue: 151461 +.. nonce: 5q0s88 +.. section: Core and Builtins + +Fix direct execution of files with invalid source encodings to report the +underlying codec lookup or decoding error instead of the generic +``SyntaxError: encoding problem`` message. Patch by Bartosz Sławecki. + +.. + +.. date: 2026-06-12-17-15-53 +.. gh-issue: 151377 +.. nonce: bQSQUk +.. section: Core and Builtins + +Fix races in free-threaded builds when updating type slots for newly created +classes and when removing entries from a base type's subclasses dictionary. + +.. + +.. date: 2026-06-12-15-30-25 +.. gh-issue: 151218 +.. nonce: 5M_nv8 +.. section: Core and Builtins + +:c:func:`PyConfig_Set` and :func:`sys.set_int_max_str_digits` now replace +:data:`sys.flags` (create a new object), instead of modifying +:data:`sys.flags` in-place. Patch by Victor Stinner. + +.. + +.. date: 2026-06-11-16-03-23 +.. gh-issue: 151297 +.. nonce: NGPkUM +.. section: Core and Builtins + +Fix an invalid pointer dereference that could occur when calling +:c:func:`PyObject_Realloc` with a NULL pointer in :term:`free-threaded +builds ` or with :envvar:`PYTHONMALLOC` set to +``mimalloc``. + +.. + +.. date: 2026-06-10-15-42-46 +.. gh-issue: 151253 +.. nonce: 7MMQ8P +.. section: Core and Builtins + +If ``import encodings`` (first import) fails at Python startup, dump the +Python path configuration to help users debugging their configuration. Patch +by Victor Stinner. + +.. + +.. date: 2026-06-10-15-19-58 +.. gh-issue: 151238 +.. nonce: C9Wu4x +.. section: Core and Builtins + +Fix a crash when compiling a concatenated f-string or t-string if an error +occurs when processing one of it's parts. + +.. + +.. date: 2026-06-09-12-24-35 +.. gh-issue: 151112 +.. nonce: 4RKCkD +.. section: Core and Builtins + +Fix a crash in the compiler that could occur when running out of memory. + +.. + +.. date: 2026-06-09-10-28-30 +.. gh-issue: 151126 +.. nonce: DKa6Sl +.. section: Core and Builtins + +Fix a crash, when there's no memory left on a device, which happened in: +code compilation, :mod:`!_interpchannels` module, +:func:`!_winapi.CreateProcess` function. + +Now these places raise proper :exc:`MemoryError` errors. + +.. + +.. date: 2026-06-08-13-14-42 +.. gh-issue: 150902 +.. nonce: -CWZ66 +.. section: Core and Builtins + +Apply an existing optimization of PyCriticalSection (single mutex) to +PyCriticalSection2: avoid acquiring the same locks that the current CS has +already acquired. + +.. + +.. date: 2026-06-08-05-31-22 +.. gh-issue: 151065 +.. nonce: _o_31F +.. section: Core and Builtins + +Fix memory leak when using the :ref:`mimalloc memory allocator `. + +.. + +.. date: 2026-06-06-20-15-08 +.. gh-issue: 151029 +.. nonce: A33CKK +.. section: Core and Builtins + +On Linux, fix :func:`sys.remote_exec` unable to find remote writable memory +when ``libpython`` replaced on disk. + +.. + +.. date: 2026-06-06-08-20-00 +.. gh-issue: 150942 +.. nonce: Jk9pQr +.. section: Core and Builtins + +Speed up frame local variable item collection by appending result pairs to +the output list without an extra reference-count round-trip (using the +internal reference-stealing list append helper). Patch by Omkar Kabde. + +.. + +.. date: 2026-06-05-22-52-41 +.. gh-issue: 150988 +.. nonce: fDKfMJ +.. section: Core and Builtins + +Fix a reference leak in :exc:`OSError` when attributes are set before +``super().__init__()``. + +.. + +.. date: 2026-06-05-09-25-08 +.. gh-issue: 145685 +.. nonce: afO33b +.. section: Core and Builtins + +The internal method cache used for types is now a per-type cache instead of +a global per-interpreter one, improving performance and reducing cache +misses. Patch by Kumar Aditya. + +.. + +.. date: 2026-06-04-15-02-35 +.. gh-issue: 146495 +.. nonce: wWRRvx +.. section: Core and Builtins + +Improve :exc:`SyntaxError` message for ``&&`` and ``||`` operators, +suggesting ``and``/``&`` and ``or``/``|`` respectively. + +.. + +.. date: 2026-06-04-12-53-10 +.. gh-issue: 148874 +.. nonce: r121cG +.. section: Core and Builtins + +Ignore interrupts immediately after calling the ``__enter__`` method of a +context menager in a ``with`` statement. This ensures that the ``__exit__`` +method is always called in a ``with`` statement. + +.. + +.. date: 2026-06-03-21-14-28 +.. gh-issue: 150459 +.. nonce: qpsCEl +.. section: Core and Builtins + +Fix :exc:`SyntaxError` error message for ``from x lazy import y``. Raise +:exc:`SyntaxWarning` on ``from . lazy import x`` (with whitespace between +the dots and a module named ``lazy``). + +.. + +.. date: 2026-06-03-16-27-00 +.. gh-issue: 150858 +.. nonce: j2dSkD +.. section: Core and Builtins + +Fix a data race while changing ``__qualname__`` of a type concurrently on +free-threaded builds. + +.. + +.. date: 2026-06-02-16-21-02 +.. gh-issue: 150737 +.. nonce: LoYUFY +.. section: Core and Builtins + +Optimize bytecode for empty unpack cases such as ``{*()}``. + +.. + +.. date: 2026-06-01-19-24-12 +.. gh-issue: 150723 +.. nonce: WlcL_- +.. section: Core and Builtins + +Fix perf jitdump timestamps on macOS. Events were stamped using +``CLOCK_MONOTONIC``, but macOS profilers timestamp their samples with +``mach_absolute_time()``. The mismatch prevented the JIT code mappings from +lining up with the samples, so no Python frame could be resolved. + +.. + +.. date: 2026-06-01-19-21-01 +.. gh-issue: 150723 +.. nonce: Hb3JDG +.. section: Core and Builtins + +Fix malformed perf jitdump thread ids on macOS. The ``thread_id`` field of +the ``JR_CODE_LOAD`` record was written as a 64-bit value instead of the +32-bit value required by the jitdump format, which shifted every following +field and prevented profilers from resolving Python frames. + +.. + +.. date: 2026-06-01-19-00-00 +.. gh-issue: 150700 +.. nonce: W8CzVR +.. section: Core and Builtins + +Fix a :exc:`SystemError` when compiling a class-scope comprehension +containing a ``lambda`` that references ``__class__``, ``__classdict__``, or +``__conditional_annotations__``. Patch by Bartosz Sławecki. + +.. + +.. date: 2026-05-30-20-19-35 +.. gh-issue: 150633 +.. nonce: XkNul0 +.. section: Core and Builtins + +Fix the frozen importer accepting module names with embedded null bytes, +which caused it to bypass the :data:`sys.modules` cache and create duplicate +module objects. + +.. + +.. date: 2026-05-29-17-51-11 +.. gh-issue: 144774 +.. nonce: jPcixe +.. section: Core and Builtins + +Fix data race in :class:`BaseException` when an exception is copied while +being mutated. + +.. + +.. date: 2026-05-26-00-06-30 +.. gh-issue: 150411 +.. nonce: u-d-_5 +.. section: Core and Builtins + +Fix a data race in the free-threaded build when :func:`gc.get_count` reads +the young generation allocation count while another thread updates it. + +.. + +.. date: 2026-05-25-16-00-22 +.. gh-issue: 150374 +.. nonce: Emu6d8 +.. section: Core and Builtins + +Fix double release of the import lock on lazy import reification errors. + +.. + +.. date: 2026-05-24-22-46-49 +.. gh-issue: 148613 +.. nonce: PLpmyd +.. section: Core and Builtins + +Fix a data race in the free-threaded build between :func:`gc.set_threshold` +and garbage collection scheduling during object allocation. + +.. + +.. date: 2026-05-24-14-45-00 +.. gh-issue: 149156 +.. nonce: NP73rB +.. section: Core and Builtins + +Fix an intermittent crash after :func:`os.fork` when perf trampoline +profiling is enabled and the child returns through trampoline frames +inherited from the parent process. + +.. + +.. date: 2026-05-23-22-08-01 +.. gh-issue: 149449 +.. nonce: 2lhQFF +.. section: Core and Builtins + +Fix a use-after-free crash when the :mod:`unicodedata` module was removed +from :data:`sys.modules` and garbage-collected between calls that decode +``\N{...}`` escapes or use the ``namereplace`` codec error handler. + +.. + +.. date: 2026-05-22-21-52-38 +.. gh-issue: 150207 +.. nonce: l2BUtI +.. section: Core and Builtins + +Fix a crash when a memory allocation fails during tokenizer initialization. +A proper :exc:`MemoryError` is now raised instead. + +.. + +.. date: 2026-05-22-17-10-29 +.. gh-issue: 149816 +.. nonce: u1-iqT +.. section: Core and Builtins + +Fix a Use-After-Free race condition in ``subtype_getweakref()`` during +concurrent weakref creation and destruction in the free-threading build. + +.. + +.. date: 2026-05-22-17-09-28 +.. gh-issue: 150107 +.. nonce: GD72-D +.. section: Core and Builtins + +:mod:`asyncio`: ``sendfile()`` and ``sock_sendfile()`` event loop methods +now call ``file.seek(offset)`` if *file* has a ``seek()`` method, even if +*offset* is ``0`` (default value). + +.. + +.. date: 2026-05-21-21-04-43 +.. gh-issue: 150208 +.. nonce: VOkxRG +.. section: Core and Builtins + +Avoid double-quoting string values from ``pyconfig.h`` in ``sysconfigdata`` +variables. + +.. + +.. date: 2026-05-20-13-06-17 +.. gh-issue: 150146 +.. nonce: i5m_SL +.. section: Core and Builtins + +Fix a crash on a complex type variable substitution. + +``from typing import TypeVar; memoryview[TypeVar("")][*typing.Mapping[..., +...]]`` used to fail due to missing ``NULL`` check on ``_unpack_args`` C +function call. + +.. + +.. date: 2026-05-18-18-36-28 +.. gh-issue: 148587 +.. nonce: -RD3z5 +.. section: Core and Builtins + +:py:attr:`sys.lazy_modules` is now a set instead of a dict as initially +spelled out in PEP 810. + +.. + +.. date: 2026-05-18-17-16-51 +.. gh-issue: 150027 +.. nonce: sJgLvd +.. section: Core and Builtins + +Improve performance of :class:`frozenset` objects by avoiding copies during +construction. + +.. + +.. date: 2026-05-18-16-54-54 +.. gh-issue: 150042 +.. nonce: LSr5W8 +.. section: Core and Builtins + +Fix refleak in queue.SimpleQueue.put if memory allocation fails. + +.. + +.. date: 2026-05-18-13-47-17 +.. gh-issue: 149590 +.. nonce: IPBeQx +.. section: Core and Builtins + +Fix crash when faulthandler is imported more than once. + +.. + +.. date: 2026-05-18-12-32-33 +.. gh-issue: 149816 +.. nonce: v18Ypf +.. section: Core and Builtins + +Fix race conditions in ``invoke_gc_callback`` iterating ``gc.callbacks`` in +free-threading mode. + +.. + +.. date: 2026-05-17-12-00-00 +.. gh-issue: 138325 +.. nonce: h2XSfe +.. section: Core and Builtins + +Speed up converting a list to a tuple in the ``tuple(genexpr)`` fast path +and in starred tuple displays (e.g. ``(*a, *b)``) by stealing the list's +items into the tuple instead of copying them. + +.. + +.. date: 2026-05-16-11-03-54 +.. gh-issue: 149816 +.. nonce: X_gqMT +.. section: Core and Builtins + +Fix a race condition in ``_PyBytes_FromList`` in free-threading mode. + +.. + +.. date: 2026-05-15-20-13-41 +.. gh-issue: 157407 +.. nonce: 4Lso8S +.. section: Core and Builtins + +Argument Clinic now parses arguments of positional-only methods with a +*defining class* directly, without a :c:type:`!_PyArg_Parser`. + +.. + +.. date: 2026-05-15-11-31-57 +.. gh-issue: 149816 +.. nonce: ugN2rx +.. section: Core and Builtins + +Fix a race condition in :class:`memoryview` with free-threading. + +.. + +.. date: 2026-05-14-19-41-03 +.. gh-issue: 149807 +.. nonce: IwGaCo +.. section: Core and Builtins + +Fix ``hash(frozendict)``: compute the hash of each ``(key, value)`` pair +correctly. Patch by Victor Stinner. + +.. + +.. date: 2026-05-13-21-26-26 +.. gh-issue: 149805 +.. nonce: IG6cza +.. section: Core and Builtins + +Fix a :exc:`SystemError` when compiling a compiling ``__classdict__`` class +annotation. Found by OSS-Fuzz in :oss-fuzz:`512907042`. + +.. + +.. date: 2026-05-13-06-54-41 +.. gh-issue: 149738 +.. nonce: 4BLFoH +.. section: Core and Builtins + +:mod:`sqlite3`: Disallow removing ``row_factory`` and ``text_factory`` +attributes of a connection or cursor to prevent a crash on a query. + +.. + +.. date: 2026-05-12-16-47-23 +.. gh-issue: 139808 +.. nonce: iIs7_E +.. section: Core and Builtins + +Add branch protections for AArch64 (BTI/PAC) in assembly code used by +:option:`-X perf_jit <-X>` (Linux perf profiler integration). + +.. + +.. date: 2026-05-12-12-49-30 +.. gh-issue: 127727 +.. nonce: hNmj9G +.. section: Core and Builtins + +Warn when running a virtual environment created for a different minor Python +version than the current interpreter, and suggest using ``python -m venv +--upgrade``. + +.. + +.. date: 2026-05-11-18-20-41 +.. gh-issue: 148871 +.. nonce: AeCbq7 +.. section: Core and Builtins + +The empty tuple ``()`` is now loaded via :opcode:`LOAD_COMMON_CONSTANT` +instead of :opcode:`LOAD_CONST`, removing it from per-code-object +:attr:`~codeobject.co_consts` tuples. + +.. + +.. date: 2026-05-11-15-58-23 +.. gh-issue: 149689 +.. nonce: 9Ht49z +.. section: Core and Builtins + +Fix missing error propagation in parser action helpers when memory +allocation fails. Patch by Thomas Kowalski. + +.. + +.. date: 2026-05-11-14-48-56 +.. gh-issue: 149676 +.. nonce: 6aTrw1 +.. section: Core and Builtins + +Fix ``frozendict | frozendict`` hash. + +.. + +.. date: 2026-05-10-16-43-50 +.. gh-issue: 148829 +.. nonce: gscS14 +.. section: Core and Builtins + +:class:`sentinel` objects now support a ``repr=`` argument and their +:attr:`~sentinel.__module__` attribute is writable. + +.. + +.. date: 2026-05-10-07-42-36 +.. gh-issue: 149642 +.. nonce: 6ZksML +.. section: Core and Builtins + +Allow imports inside ``exec()`` calls within functions under +``PYTHON_LAZY_IMPORTS=all``. + +.. + +.. date: 2026-05-09-15-22-32 +.. gh-issue: 144957 +.. nonce: u1F2aQ +.. section: Core and Builtins + +Fix lazy ``from`` imports of module attributes provided by module-level +``__getattr__``. + +.. + +.. date: 2026-05-07-03-18-59 +.. gh-issue: 149459 +.. nonce: 5fhAqP +.. section: Core and Builtins + +Fix a crash in the JIT optimizer when a specialized ``LOAD_SPECIAL`` guard +deoptimized after inserting the synthetic ``NULL`` stack entry. + +.. + +.. date: 2026-05-05-12-00-00 +.. gh-issue: 149321 +.. nonce: remove-lazy-imports-none +.. section: Core and Builtins + +Do not support ``none`` as a lazy imports mode. + +.. + +.. date: 2026-04-29-15-10-59 +.. gh-issue: 149162 +.. nonce: BPPyrq +.. section: Core and Builtins + +Fix a potential deadlock in :c:func:`PyUnicode_InternFromString` and other +interning functions in the :term:`free-threaded build` when called from C++ +static local initializers. + +.. + +.. date: 2026-04-26-15-08-53 +.. gh-issue: 148817 +.. nonce: cuN07H +.. section: Core and Builtins + +Fold large constant list and set literals used as the iterable of a +:keyword:`for` loop or ``in``/``not in`` test into a constant :class:`tuple` +or :class:`frozenset`, restoring an optimization previously done by the AST +optimizer that was lost when constant folding moved to the CFG. + +.. + +.. date: 2026-04-21-15-07-03 +.. gh-issue: 148825 +.. nonce: AbJzmZ +.. section: Core and Builtins + +Fix build error if specialization is disabled. + +.. + +.. date: 2026-04-15-15-48-04 +.. gh-issue: 148450 +.. nonce: 2MEVqH +.. section: Core and Builtins + +Fix ``abc.register()`` so it invalidates type version tags for registered +classes. + +.. + +.. date: 2026-04-13-00-00-00 +.. gh-issue: 148442 +.. nonce: aBcDeF +.. section: Core and Builtins + +Fix a race condition in ``list.__lt__``, ``list.__le__``, ``list.__gt__``, +and ``list.__ge__``. Previously, under concurrent list mutation, the items +being compared could be replaced with other objects before the final +comparison, causing the final comparison result to be incorrect. + +.. + +.. date: 2026-03-31-16-15-15 +.. gh-issue: 75723 +.. nonce: BZ4Rsn +.. section: Core and Builtins + +Avoid re-executing ``.pth`` files when :func:`site.addsitedir` is called for +a known directory. + +.. + +.. date: 2026-03-23-00-45-44 +.. gh-issue: 145857 +.. nonce: dB66WV +.. section: Core and Builtins + +The ``DELETE_GLOBAL`` opcode is now replaced with ``PUSH_NULL; +STORE_GLOBAL``. + +.. + +.. date: 2026-03-20-16-27-15 +.. gh-issue: 145855 +.. nonce: 3yaHO4 +.. section: Core and Builtins + +The ``DELETE_ATTR`` opcode is now replaced with ``PUSH_NULL; STORE_ATTR``. + +.. + +.. date: 2026-03-16-02-23-48 +.. gh-issue: 145854 +.. nonce: rRexF3 +.. section: Core and Builtins + +The ``DELETE_NAME`` opcode is now replaced with ``PUSH_NULL; STORE_NAME``. + +.. + +.. date: 2026-02-14-16-19-22 +.. gh-issue: 138912 +.. nonce: TKMC9K +.. section: Core and Builtins + +Add fast path for :keyword:`match` class patterns without any sub-patterns +to improve performance by ~15%. + +.. + +.. date: 2025-08-15-06-28-45 +.. gh-issue: 91484 +.. nonce: huCgHt +.. section: Core and Builtins + +:meth:`memoryview.cast` now allows casting from N-D to 1-D for F-contiguous. + +.. + +.. date: 2024-12-24-08-44-49 +.. gh-issue: 128213 +.. nonce: Y71jDi +.. section: Core and Builtins + +Speed up :class:`bytes` creation from :class:`list` and :class:`tuple` of +integers. + +Patch by Ben Hsing and Pieter Eendebak + +.. + +.. date: 2024-09-19-15-47-50 +.. gh-issue: 117999 +.. nonce: Iq4jEG +.. section: Core and Builtins + +Fix calculation of powers of complex numbers. Small integer powers now +produce correct sign of zero components. Negative powers of infinite numbers +now evaluate to zero instead of NaN. Powers of infinite numbers no longer +raise OverflowError. + +.. + +.. date: 2020-06-23-13-59-37 +.. gh-issue: 85260 +.. nonce: o_LJ76 +.. section: Core and Builtins + +:func:`compile` now raises :exc:`ValueError` instead of crashing on a debug +build if an identifier field of an AST node (such as the name of a function, +a class, an imported module or a caught exception) is ``"None"``, ``"True"`` +or ``"False"``. + +.. + +.. bpo: 38131 +.. date: 2019-12-27-19-20-33 +.. nonce: J5fv54 +.. section: Core and Builtins + +Produce more meaningful messages when compiling AST objects with wrong field +values. Patch by Batuhan Taskaya. + +.. + +.. date: 2026-10-11-08-41-00 +.. gh-issue: 159184 +.. nonce: Nn4tOr +.. section: Library + +Fix :func:`marshal.dumps` raising :exc:`TypeError` for a set or frozenset +containing several complex NaNs, which also made it impossible to write a +:file:`.pyc` file for source code containing such a constant. + +.. + +.. date: 2026-10-11-08-40-00 +.. gh-issue: 159185 +.. nonce: Sq7cZd +.. section: Library + +Fix a crash in :func:`marshal.dumps` and :func:`marshal.dump` when a set is +modified while its elements are serialized, for example by the +:meth:`~object.__buffer__` method of one of its elements. +:exc:`RuntimeError` is now raised. + +.. + +.. date: 2026-10-11-06-00-00 +.. gh-issue: 129724 +.. nonce: mRsh1x +.. section: Library + +Make the output of :func:`marshal.dumps` and :func:`marshal.dump`, and so +the content of :file:`.pyc` files, independent of the reference counts of +the serialized objects. The format is unchanged, but the data is not +byte-for-byte identical to that written by previous Python versions. + +.. + +.. date: 2026-10-08-16-18-43 +.. gh-issue: 87720 +.. nonce: Elqdl9 +.. section: Library + +Fixed error in :mod:`email` new policies where header folding failed to +detect the need to re-quote text obtained from encoded words in certain +cases. + +.. + +.. date: 2026-10-07-20-32-20 +.. gh-issue: 158929 +.. nonce: 6dwqfQ +.. section: Library + +Fix crash when calling :func:`syslog.syslog` while a subinterpreter in +another thread calls :func:`syslog.openlog` or :func:`syslog.closelog`. + +.. + +.. date: 2026-10-07-02-29-45 +.. gh-issue: 158897 +.. nonce: jH3FwQ +.. section: Library + +Optimize :meth:`!io.BufferedReader.readline` when lines are close to the +buffer size (128 kB by default) or longer than the buffer size. Replace the +C loop searching for the newline byte in the buffer with a :c:func:`!memchr` +call which is more efficient. In the good case, it makes ``readline()`` up +to 4x faster! Patch by Victor Stinner. + +.. + +.. date: 2026-10-06-20-33-52 +.. gh-issue: 158936 +.. nonce: flCm_m +.. section: Library + +:func:`~dataclasses.dataclass` no longer fails when a string annotation +names a :ref:`lazy import ` that cannot be resolved, matching +the behavior for non-string annotations. + +.. + +.. date: 2026-10-06-20-03-01 +.. gh-issue: 158893 +.. nonce: B6A53q +.. section: Library + +Make :func:`os.strerror` thread-safe: use the reentrant ``strerror_r()`` +function if available. Patch by Victor Stinner. + +.. + +.. date: 2026-10-05-18-00-01 +.. gh-issue: 158539 +.. nonce: k8Lv2a +.. section: Library + +Fix macOS runtime section lookup for remote debugging when virtual memory +region sizes differ from Mach-O segment file sizes. + +.. + +.. date: 2026-10-05-18-00-00 +.. gh-issue: 156545 +.. nonce: z1mQp7 +.. section: Library + +Fix deep flamegraph exports on platforms with small C stacks by falling back +to the Python JSON encoder when the C encoder runs out of stack space. + +.. + +.. date: 2026-10-05-13-57-08 +.. gh-issue: 79459 +.. nonce: 2RgBDL +.. section: Library + +:mod:`tempfile` functions that take a ``prefix`` or ``suffix`` argument now +raise a :exc:`ValueError` if they contain a directory component: +:func:`tempfile.mkstemp`, :func:`tempfile.mkdtemp`, +:func:`tempfile.TemporaryFile`, :func:`tempfile.NamedTemporaryFile`. + +.. + +.. date: 2026-10-04-20-00-00 +.. gh-issue: 158552 +.. nonce: windows +.. section: Library + +Wait for Windows threads to finish suspending before reading target memory +in the sampling profiler's blocking mode. Resume the target if waiting for +suspension fails. + +.. + +.. date: 2026-10-01-16-45-00 +.. gh-issue: 156321 +.. nonce: Kq3xVt +.. section: Library + +Fix :func:`asyncio.shield` reporting an exception from the inner future +through the loop exception handler as soon as it completes after the shield +was cancelled, even when the exception is retrieved afterwards. The +exception is now reported only if it is never retrieved, as with any other +future. + +.. + +.. date: 2026-10-01-14-00-00 +.. gh-issue: 158539 +.. nonce: q1w2e3 +.. section: Library + +Fix :mod:`profiling.sampling` exception mode discarding samples for code +running inside an ``except`` block in a generator or coroutine. The remote +debugger now follows ``tstate->exc_info`` and its ``previous_item`` chain +instead of only reading the embedded ``exc_state``, matching the exception +that :func:`sys.exception` reports. + +.. + +.. date: 2026-10-01-13-59-02 +.. gh-issue: 158563 +.. nonce: kR7wQe +.. section: Library + +Fix :func:`turtle.undo` after :func:`turtle.teleport` and after an exception +in :func:`turtle.circle`, :func:`turtle.dot` or :func:`turtle.write`. Fix +:func:`turtle.stamp`, :func:`turtle.clearstamp`, :func:`turtle.clear` and +:func:`turtle.reset` when the undo buffer is disabled. + +.. + +.. date: 2026-09-30-22-10-00 +.. gh-issue: 158540 +.. nonce: kQ9vXm +.. section: Library + +Fix :mod:`profiling.sampling` not adding the directory containing the +profiled script to :data:`sys.path`, which prevented the script from +importing modules placed next to it. The script's directory is now added, +matching the behavior of ``python script.py``. + +.. + +.. date: 2026-09-30-20-09-46 +.. gh-issue: 158522 +.. nonce: L6j7tU +.. section: Library + +Fix :mod:`profiling.sampling` showing a single frame for a task whose +coroutine recurses. Patch by Timofei Ivankov. + +.. + +.. date: 2026-09-26-22-07-09 +.. gh-issue: 158237 +.. nonce: AbCdEf +.. section: Library + +Fix :func:`ast.unparse` to not insert a space before attribute access on +bool constants (e.g. ``True.real`` instead of ``True .real``). + +.. + +.. date: 2026-09-25-22-15-54 +.. gh-issue: 158169 +.. nonce: ZlibTail +.. section: Library + +Fix :attr:`zlib.Decompress.unconsumed_tail` duplicating +:attr:`~zlib.Decompress.unused_data` after end of stream when *max_length* +was used. + +.. + +.. date: 2026-09-19-20-31-58 +.. gh-issue: 141540 +.. nonce: phc605 +.. section: Library + +Quote the unconverted data and the format in the error messages of +:func:`time.strptime` and :meth:`datetime.datetime.strptime` so that +whitespace such as a trailing newline is visible. + +.. + +.. date: 2026-09-19-14-10-18 +.. gh-issue: 157788 +.. nonce: v70Lxd +.. section: Library + +Fix ``python -m asyncio ps`` failing on a process that has a task with a +name longer than 255 characters. + +.. + +.. date: 2026-09-19-12-00-00 +.. gh-issue: 157605 +.. nonce: Qh92xZ +.. section: Library + +Fix :mod:`profiling.sampling` failing when a native thread has an empty +Python stack. + +.. + +.. date: 2026-09-18-17-33-31 +.. gh-issue: 157763 +.. nonce: Wd0_Uo +.. section: Library + +The undocumented :func:`!ctypes.util.test` function is now :term:`soft +deprecated` and a no-op at runtime. + +.. + +.. date: 2026-09-18-12-00-00 +.. gh-issue: 157660 +.. nonce: tlbc +.. section: Library + +Fix :mod:`profiling.sampling` reporting errors or incorrect line numbers in +free-threaded builds when a thread-local bytecode array grows or gains +entries after being cached. + +.. + +.. date: 2026-09-17-21-05-42 +.. gh-issue: 153888 +.. nonce: Ht7Yqb +.. section: Library + +Fix :func:`unittest.mock.patch` with ``autospec``, ``spec``, or ``spec_set`` +when used with lazy-imported objects. + +.. + +.. date: 2026-09-17-17-30-00 +.. gh-issue: 119646 +.. nonce: kP8nQm +.. section: Library + +On Windows, :exc:`OSError` from :mod:`subprocess` now includes the attempted +executable or working directory in ``filename``. + +.. + +.. date: 2026-09-17-15-14-08 +.. gh-issue: 157675 +.. nonce: C4-ze9 +.. section: Library + +:func:`encodings.idna.nameprep` now takes a *limit* argument that allows +rejecting extremely large input early. The ``idna`` encoding and the +:func:`!encodings.idna.ToASCII` and :func:`!encodings.idna.ToUnicode` +functions use this to avoid passing unbounded input to quadratic-time +algorithms. + +.. + +.. date: 2026-09-17-14-00-00 +.. gh-issue: 157672 +.. nonce: tksigs +.. section: Library + +Fix :mod:`tkinter` on macOS: creating a :class:`~tkinter.Tk` instance no +longer replaces the Python handlers of SIGINT, SIGHUP and SIGTERM with Tk's +handler which exits the process, so Ctrl-C raises :exc:`KeyboardInterrupt` +again. + +.. + +.. date: 2026-09-17-03-20-24 +.. gh-issue: 157639 +.. nonce: VP3kc4 +.. section: Library + +Fix a crash in :mod:`!cProfile` when an external timer re-enters the +profiler. Profiling events raised while the external timer runs are now +ignored. + +.. + +.. date: 2026-09-16-14-04-38 +.. gh-issue: 157621 +.. nonce: R6v2S8 +.. section: Library + +Fix a crash when a weak-reference callback is attached to a +:class:`typing.ParamSpecArgs` or :class:`typing.ParamSpecKwargs` instance. + +.. + +.. date: 2026-09-16-09-28-42 +.. gh-issue: 157633 +.. nonce: EvGFI0 +.. section: Library + +Update :mod:`unicodedata` database to Unicode 18.0.0. + +.. + +.. date: 2026-09-15-16-37-19 +.. gh-issue: 69919 +.. nonce: izH1zP +.. section: Library + +:meth:`code.InteractiveInterpreter.runsource` and the REPL now report any +exception raised by compiling the source, such as :exc:`MemoryError` or +:exc:`RecursionError` for too deeply nested source, instead of propagating +it or printing a traceback of the REPL internals. + +.. + +.. date: 2026-09-14-18-36-32 +.. gh-issue: 157514 +.. nonce: 02FZED +.. section: Library + +Add constants :const:`tkinter.TCL_VERSION_INFO` and +:const:`tkinter.TK_VERSION_INFO`, named tuples with the versions of the Tcl +and Tk libraries that were used for building the module, and +``_tkinter.TCL_PATCH_LEVEL`` and ``_tkinter.TK_PATCH_LEVEL`` strings. + +.. + +.. date: 2026-09-14-18-36-31 +.. gh-issue: 157513 +.. nonce: EW4QOC +.. section: Library + +:const:`ssl.OPENSSL_VERSION_INFO` is now a named tuple. Add +:const:`ssl.OPENSSL_API_VERSION_INFO` which provides information about the +version of the OpenSSL library that was used for building the module. + +.. + +.. date: 2026-09-14-12-05-02 +.. gh-issue: 157487 +.. nonce: ID-qIv +.. section: Library + +Add constants :const:`ctypes.LIBFFI_VERSION`, +:const:`ctypes.libffi_version`, :const:`ctypes.LIBFFI_VERSION_INFO` and +:const:`ctypes.libffi_version_info`, which provide information about the +version of the libffi library in use. They are only available with libffi +3.5 or later. + +.. + +.. date: 2026-09-14-11-38-23 +.. gh-issue: 157485 +.. nonce: yAK9LN +.. section: Library + +Add constants :const:`readline.READLINE_VERSION_INFO`, +:const:`readline.readline_version_info` and +:const:`readline.readline_version`, which provide information about the +version of the Readline library in use. + +.. + +.. date: 2026-09-14-10-39-05 +.. gh-issue: 157480 +.. nonce: to5EnW +.. section: Library + +Add constants in :mod:`dbm.ndbm` which provide information about the version +of the underlying library in use: :const:`~dbm.ndbm.GDBM_VERSION_INFO`, +:const:`~dbm.ndbm.gdbm_version_info` and :const:`~dbm.ndbm.gdbm_version` if +it is GDBM, or :const:`~dbm.ndbm.BDB_VERSION`, +:const:`~dbm.ndbm.bdb_version`, :const:`~dbm.ndbm.BDB_VERSION_INFO` and +:const:`~dbm.ndbm.bdb_version_info` if it is Berkeley DB. +:const:`dbm.ndbm.library` is now ``'ndbm'`` instead of ``'GNU gdbm'`` for a +classic NDBM library. + +.. + +.. date: 2026-09-14-10-22-36 +.. gh-issue: 157478 +.. nonce: F4cBKN +.. section: Library + +Add constants :const:`dbm.gnu.GDBM_VERSION_INFO`, +:const:`dbm.gnu.gdbm_version_info` and :const:`dbm.gnu.gdbm_version`, which +provide information about the version of the GDBM library in use. The +private constant ``_gdbm._GDBM_VERSION`` has been removed. + +.. + +.. date: 2026-09-14-09-28-35 +.. gh-issue: 157475 +.. nonce: dvuniU +.. section: Library + +Add constants :const:`decimal.LIBMPDEC_VERSION`, +:const:`decimal.libmpdec_version`, :const:`decimal.LIBMPDEC_VERSION_INFO`, +and :const:`decimal.libmpdec_version_info` in the C implementation, which +provide information about the version of the libmpdec library in use. + +.. + +.. date: 2026-09-14-09-02-19 +.. gh-issue: 157473 +.. nonce: LlzPyM +.. section: Library + +Add constant :const:`xml.parsers.expat.VERSION_INFO` which provides +information about the version of the Expat library that was used for +building the module. :const:`xml.parsers.expat.version_info` is now a named +tuple. + +.. + +.. date: 2026-09-14-07-49-51 +.. gh-issue: 157470 +.. nonce: jgEHYK +.. section: Library + +Add constants :const:`sqlite3.SQLITE_VERSION` and +:const:`sqlite3.SQLITE_VERSION_INFO` which provide information about the +version of the SQLite library that was used for building the module. +:const:`sqlite3.sqlite_version_info` is now a named tuple. + +.. + +.. date: 2026-09-14-00-30-00 +.. gh-issue: 157451 +.. nonce: k7Qm2x +.. section: Library + +Fix :mod:`gettext` plural form selection when the ``Plural-Forms`` +expression combines the unary ``!`` operator with a binary operator, for +example ``!n + 1`` or ``2 * !n``. The latter raised :exc:`SyntaxError`. + +.. + +.. date: 2026-09-13-21-45-00 +.. gh-issue: 150816 +.. nonce: pQ3kZs +.. section: Library + +Speed up :func:`inspect.signature` for Python functions by skipping +redundant validation when creating :class:`inspect.Parameter` objects. + +.. + +.. date: 2026-09-13-15-58-28 +.. gh-issue: 157335 +.. nonce: efaMah +.. section: Library + +Fix out-of-bounds write in ``mmap.mmap.__setitem__`` that could occur when +converting the index or the assigned value (via :meth:`~object.__index__` +for a single item, or via the buffer protocol for a slice) resized or closed +the mmap object during the assignment. + +.. + +.. date: 2026-09-13-10-30-00 +.. gh-issue: 157406 +.. nonce: a3kZq7 +.. section: Library + +Fix the Python implementation of :class:`xml.etree.ElementTree.XMLParser`: +the ``doctype()`` method of the target is now called for a document type +declaration without an external identifier, like ````, as in +the C implementation. + +.. + +.. date: 2026-09-13-07-14-35 +.. gh-issue: 128509 +.. nonce: 9F2GCE +.. section: Library + +:func:`marshal.load` and :func:`marshal.loads` can now get 1-byte string +singletons. Patch by Victor Stinner. + +.. + +.. date: 2026-09-12-18-03-15 +.. gh-issue: 157364 +.. nonce: Qd7mKs +.. section: Library + +Fix a use-after-free in :class:`io.TextIOWrapper` when a call to the +underlying buffer reentrantly detaches it. Patched by Shamil Abdulaev. + +.. + +.. date: 2026-09-12-15-50-23 +.. gh-issue: 157366 +.. nonce: djwD2M +.. section: Library + +Remove the accidental acceptance of :class:`bytes` in the C implementation +of :mod:`xml.etree.ElementTree`, a leftover of the Python 2 to Python 3 +migration, for paths of :meth:`~xml.etree.ElementTree.Element.find` and +similar methods, for the tag of :meth:`~xml.etree.ElementTree.Element.iter`, +and for the names of events of :class:`~xml.etree.ElementTree.XMLPullParser` +and :func:`~xml.etree.ElementTree.iterparse`. It now raises the same +exceptions as the Python implementation. + +.. + +.. date: 2026-09-12-03-14-57 +.. gh-issue: 157242 +.. nonce: ycbtjC +.. section: Library + +:class:`io.BytesIO` is no longer closed on ``write()`` and ``truncate()`` +failure (:exc:`MemoryError`). Patch by Victor Stinner. + +.. + +.. date: 2026-09-11-16-50-11 +.. gh-issue: 157325 +.. nonce: hzTild +.. section: Library + +Fix an out-of-bounds read in the ``hz`` incremental decoder when the input +ends with ``~``. + +.. + +.. date: 2026-09-11-14-14-51 +.. gh-issue: 157301 +.. nonce: QxcE2r +.. section: Library + +Fix :class:`asyncio.Task` hanging the event loop when an eager start fails +to enter the task's context. + +.. + +.. date: 2026-09-11-12-00-00 +.. gh-issue: 156955 +.. nonce: bLtmAp +.. section: Library + +Speed up :func:`csv.writer` by caching the set of characters that need +quoting or escaping in the dialect. Writing long fields is now up to 5 times +faster. + +.. + +.. date: 2026-09-09-13-46-38 +.. gh-issue: 157213 +.. nonce: rYg7pO +.. section: Library + +Fix :func:`asyncio.gather` leaving stale await-graph edges on children that +outlive it. + +.. + +.. date: 2026-09-08-15-55-00 +.. gh-issue: 157176 +.. nonce: yZ8a1B +.. section: Library + +Make the :class:`time.struct_time` type immutable to prevent reference +cycles between the type and its instances. Patch by Shamil Abdulaev. + +.. + +.. date: 2026-09-08-13-06-29 +.. gh-issue: 156002 +.. nonce: vmOC8T +.. section: Library + +:mod:`zipfile` again reads members through a third-party decompressor +installed by monkey-patching the private ``_get_decompressor()`` to return +an object that only implements old BZ2Decompressor API from Python 3.3. +Calling decompress() with one argument is deprecated. Note that +decompressors without ``needs_input`` and two-argument ``decompress()`` are +vulnerable to :cve:`2026-15310`. + +.. + +.. date: 2026-09-08-09-30-00 +.. gh-issue: 157159 +.. nonce: tabNny +.. section: Library + +The usage message printed by ``python -m tabnanny`` when no arguments are +given now suggests ``python -m`` instead of the source file. + +.. + +.. date: 2026-09-08-04-10-00 +.. gh-issue: 123018 +.. nonce: hV2kQe +.. section: Library + +Fix :func:`readline.write_history_file` and +:func:`readline.append_history_file` producing a history file that +:func:`readline.read_history_file` could not load when a limit was set with +:func:`readline.set_history_length` and Python was built against +``libedit``. This works around `NetBSD PR 60322 +`_. + +.. + +.. date: 2026-09-08-00-31-56 +.. gh-issue: 157127 +.. nonce: gduPd0 +.. section: Library + +Reword the :mod:`argparse` error message reported for a missing required +mutually exclusive group to ``one of the following arguments is required: +--foo, --bar``, so that the argument names are separated by commas. + +.. + +.. date: 2026-09-07-23-40-00 +.. gh-issue: 157146 +.. nonce: lczip1 +.. section: Library + +:mod:`linecache` can now read the source of a module that was imported from +a zip archive on :data:`sys.path` when given only the file name, as +:mod:`pdb`, :mod:`warnings` and :mod:`doctest` do. + +.. + +.. date: 2026-09-07-12-24-11 +.. gh-issue: 157058 +.. nonce: 2SoQU7 +.. section: Library + +:func:`asyncio.wait_for` with a non-positive timeout now records the waiter +in the call graph. + +.. + +.. date: 2026-09-07-00-21-31 +.. gh-issue: 156933 +.. nonce: OalCjC +.. section: Library + +Fix incorrect integer return values from :mod:`ctypes` callbacks on some +platforms, such as s390x. + +.. + +.. date: 2026-09-06-15-23-24 +.. gh-issue: 157048 +.. nonce: UtFyiJ +.. section: Library + +Preserve the position and contents of :class:`io.BytesIO` when +:meth:`!BytesIO.__init__` fails because a buffer is exported. + +.. + +.. date: 2026-09-06-15-12-18 +.. gh-issue: 157025 +.. nonce: ZvFpFT +.. section: Library + +Fix transport cleanup when cancelling :meth:`asyncio.loop.sendfile` while +waiting for the write buffer to drain in the native implementation. + +.. + +.. date: 2026-09-05-22-39-22 +.. gh-issue: 156961 +.. nonce: ZtYqoA +.. section: Library + +Fix :func:`tkinter.font.nametofont` and the :class:`tkinter.font.Font` +constructor for a font name or description returned by Tk as a Tcl object, +for example by :meth:`ttk.Style.lookup() `. + +.. + +.. date: 2026-09-05-18-23-30 +.. gh-issue: 156988 +.. nonce: nEUQE6 +.. section: Library + +:func:`asyncio.print_call_graph` no longer truncates the call stack at a +synchronous generator. + +.. + +.. date: 2026-09-05-15-27-11 +.. gh-issue: 156970 +.. nonce: DxlgbB +.. section: Library + +Set the docstring of :attr:`unittest.mock.Mock.return_value`. + +.. + +.. date: 2026-09-04-16-05-45 +.. gh-issue: 156946 +.. nonce: 0ZYCdh +.. section: Library + +Fix a crash in :mod:`curses.panel` when the finalizer of a panel's user +pointer runs while the panel is being deallocated. The panel is now taken +off the panel stack before its user pointer is dropped. + +.. + +.. date: 2026-09-04-14-15-31 +.. gh-issue: 156924 +.. nonce: 3Ux7IJ +.. section: Library + +:meth:`annotationlib.ForwardRef.evaluate` now resolves :ref:`lazy import +` proxies found in the namespace. With +:attr:`~annotationlib.Format.FORWARDREF`, a lazy import that fails to +resolve now results in a :class:`~annotationlib.ForwardRef` instead of the +:class:`lazy import proxy `, and with +:attr:`~annotationlib.Format.VALUE` the underlying exception is propagated. + +.. + +.. date: 2026-09-04-11-45-08 +.. gh-issue: 156865 +.. nonce: mrdfKJ +.. section: Library + +Don't raise exceptions on overflows in :class:`ctypes.c_float_complex`. +Patch by Sergey B Kirpichev. + +.. + +.. date: 2026-09-04-09-18-05 +.. gh-issue: 156920 +.. nonce: lONsKT +.. section: Library + +Fix :mod:`asyncio` on Windows: closing a :class:`~asyncio.DatagramTransport` +under :class:`~asyncio.ProactorEventLoop` while datagrams were still queued, +or while an in-flight write failed right as ``close()`` was draining the +buffer, could strand the queued data and never call ``connection_lost()``, +hanging the close indefinitely. + +.. + +.. date: 2026-09-03-04-51-46 +.. gh-issue: 156864 +.. nonce: Pbe7Tl +.. section: Library + +:func:`array.array` setter now correctly detects overflows for the ``'e'``, +``'f'`` and ``'Zf'`` type codes. Patch by Sergey B Kirpichev. + +.. + +.. date: 2026-09-03-04-32-06 +.. gh-issue: 156867 +.. nonce: hq3efC +.. section: Library + +Raise :exc:`OverflowError`'s for native ``'Zf'`` format in +:func:`struct.pack`, like for ``'f'`` format. Previously overflows in the +:c:expr:`float complex` type were silent. Patch by Sergey B Kirpichev. + +.. + +.. date: 2026-09-02-17-28-16 +.. gh-issue: 156810 +.. nonce: cLpEnc +.. section: Library + +Fix a :exc:`UnicodeEncodeError` crash in the sampling profiler's +collapsed-stack export (``--collapsed``) when a sampled frame's function or +file name contains non-ASCII or surrogate-escaped characters. The output +file is now written as UTF-8. + +.. + +.. date: 2026-09-02-12-11-00 +.. gh-issue: 124697 +.. nonce: sUbScp +.. section: Library + +The :mod:`symtable` module now represents inlined list, set and dict +comprehensions (:pep:`709`) as their own symbol table entries of type +:attr:`~symtable.SymbolTableType.INLINED_COMPREHENSION`. + +.. + +.. date: 2026-09-01-16-58-30 +.. gh-issue: 156797 +.. nonce: Qm4tRs +.. section: Library + +Fix :class:`xml.sax.saxutils.XMLGenerator`: the namespace URI is now escaped +in the namespace declaration. Previously a URI containing ``&``, ``<`` or a +quote character produced a document which cannot be parsed. + +.. + +.. date: 2026-09-01-02-30-00 +.. gh-issue: 63102 +.. nonce: Pz3wK8 +.. section: Library + +:class:`~xml.etree.ElementTree.XMLPullParser` and +:func:`~xml.etree.ElementTree.iterparse` now support the *target* parameter. +The reported object is the value returned by the corresponding method of the +target, so no tree is built if the target does not build one. Only the +standard :class:`~xml.etree.ElementTree.TreeBuilder` was supported in the C +implementation before. + +.. + +.. date: 2026-09-01-00-30-00 +.. gh-issue: 61290 +.. nonce: Vx7pQ2 +.. section: Library + +:mod:`xml.etree.ElementTree` no longer refuses to serialize attributes +without a namespace when the *default_namespace* option is used. The default +namespace declaration does not apply to attribute names, so an unqualified +attribute name is written as is, and a qualified attribute name is always +written with a prefix. + +.. + +.. date: 2026-08-31-23-10-00 +.. gh-issue: 83895 +.. nonce: Jm5tR3 +.. section: Library + +:mod:`xml.etree.ElementTree` now accepts input larger than 2 GiB in the C +implementation. The data is fed to Expat in chunks, as +:mod:`xml.parsers.expat` already did, instead of raising +:exc:`OverflowError`. + +.. + +.. date: 2026-08-31-20-30-00 +.. gh-issue: 99064 +.. nonce: Rt4mZ9 +.. section: Library + +Fix :func:`xml.etree.ElementTree.parse` with a text file or other source of +:class:`str` data in the C implementation. The encoding declared in the +document was applied to the already decoded text, which produced mojibake. +It is now ignored, as when parsing with :meth:`!XMLParser.feed` or +:func:`~xml.etree.ElementTree.fromstring`. + +.. + +.. date: 2026-08-31-19-30-00 +.. gh-issue: 89499 +.. nonce: Kx8vQ1 +.. section: Library + +:meth:`ElementTree.write() `, +:func:`~xml.etree.ElementTree.tostring` and +:func:`~xml.etree.ElementTree.tostringlist` now support the *standalone* +parameter, the value of the standalone document declaration in the XML +declaration. + +.. + +.. date: 2026-08-31-17-10-00 +.. gh-issue: 156713 +.. nonce: Nt2URL +.. section: Library + +Fix :func:`!nturl2path.pathname2url` and :func:`!nturl2path.url2pathname`: +the filesystem encoding and error handler are now used for percent-encoding +and decoding, as in :mod:`urllib.request`. Previously paths containing +surrogate characters raised :exc:`UnicodeEncodeError`. + +.. + +.. date: 2026-08-31-11-40-00 +.. gh-issue: 156774 +.. nonce: Pd8Lz1 +.. section: Library + +Speed up :mod:`pdb` startup by only importing :mod:`asyncio` when the +program being debugged has already imported it. + +.. + +.. date: 2026-08-31-09-01-22 +.. gh-issue: 156439 +.. nonce: j9WHCc +.. section: Library + +:func:`socket.if_nametoindex` and :func:`socket.if_indextoname` are now +available on platforms that provide them but not ``if_nameindex``, such as +Android before API level 24. + +.. + +.. date: 2026-08-31-00-00-00 +.. gh-issue: 156698 +.. nonce: gyDxUe +.. section: Library + +Fix :class:`asyncio.ProactorEventLoop` UDP transports so that a write error +no longer strands a paused protocol: the write loop is now rescheduled when +data remains buffered, and the protocol is resumed when the buffer has +drained. + +.. + +.. date: 2026-08-31-00-00-00 +.. gh-issue: 127057 +.. nonce: N9yg62 +.. section: Library + +Fix :class:`asyncio.ProactorEventLoop` UDP transports so that a +:exc:`ConnectionResetError` raised by ``WSARecvFrom`` no longer stops the +read loop. + +.. + +.. date: 2026-08-30-21-00-00 +.. gh-issue: 156665 +.. nonce: Jm3Kp9 +.. section: Library + +:mod:`xml.dom.minidom` now validates namespaces in +:meth:`~xml.dom.Document.createElementNS`, +:meth:`~xml.dom.Document.createAttributeNS` and +:meth:`~xml.dom.Element.setAttributeNS`, and when setting +:attr:`~xml.dom.Node.prefix` of an attribute. :exc:`~xml.dom.NamespaceErr` +is now raised for a malformed qualified name, for a prefix with an empty +namespace, and for illegal use of the ``xml`` and ``xmlns`` prefixes. + +.. + +.. date: 2026-08-30-19-30-00 +.. gh-issue: 156658 +.. nonce: Xq5Nt7 +.. section: Library + +:mod:`xml.dom` and :mod:`xml.etree.ElementTree` no longer treat characters +which are not white space in XML (such as U+00A0) as white space. Previously +they could be lost in :func:`~xml.etree.ElementTree.indent`, +:func:`~xml.etree.ElementTree.canonicalize` with ``strip_text=True``, and +when parsing with the ``whitespace-in-element-content`` feature turned off. + +.. + +.. date: 2026-08-30-18-00-00 +.. gh-issue: 81623 +.. nonce: Vh2Kt6 +.. section: Library + +:meth:`~xml.dom.minidom.Node.toprettyxml` in :mod:`xml.dom.minidom` and +:func:`~xml.etree.ElementTree.indent` in :mod:`xml.etree.ElementTree` no +longer add whitespace inside an element which is marked with +``xml:space="preserve"`` or which contains text (:meth:`!toprettyxml` also +takes into account the content model declared in the DTD). Previously such +indentation changed the content of the element. + +.. + +.. date: 2026-08-30-13-37-47 +.. gh-issue: 54092 +.. nonce: Tq8Wm3 +.. section: Library + +Implement :meth:`~xml.dom.minidom.Node.writexml` for document fragments in +:mod:`xml.dom.minidom`, so that :meth:`~xml.dom.minidom.Node.toxml` and +:meth:`~xml.dom.minidom.Node.toprettyxml` now work for them. They write the +children of the fragment, without adding a level of indentation. + +.. + +.. date: 2026-08-30-13-25-53 +.. gh-issue: 156512 +.. nonce: tVTOIV +.. section: Library + +Fix :mod:`asyncio` losing a connection twice when ``resume_writing()`` +closes the transport. + +.. + +.. date: 2026-08-30-12-00-00 +.. gh-issue: 44376 +.. nonce: Kp4Vz9 +.. section: Library + +:meth:`~xml.dom.minidom.Node.writexml` in :mod:`xml.dom.minidom` now writes +the namespace declarations needed to serialize the namespaces of the element +and its attributes, if they are not already declared for an ancestor. The +document is not modified. + +.. + +.. date: 2026-08-29-11-37-40 +.. gh-issue: 156545 +.. nonce: fLaMe1 +.. section: Library + +Fix the sampling profiler's flamegraph export so that profiling a deeply +recursive program no longer fails with :exc:`RecursionError` instead of +producing a flamegraph. Patch by tonghuaroot. + +.. + +.. date: 2026-08-28-18-10-25 +.. gh-issue: 156523 +.. nonce: llJqo9 +.. section: Library + +Fix :func:`asyncio.as_completed` not recording the awaiting task in the call +graph. + +.. + +.. date: 2026-08-28-00-59-00 +.. gh-issue: 156476 +.. nonce: rQhxc7 +.. section: Library + +The pure Python implementation of :meth:`queue.SimpleQueue.get` now ignores +*timeout* when *block* is false, matching the documented behavior and the C +implementation. It previously raised :exc:`ValueError`. + +.. + +.. date: 2026-08-27-08-31-29 +.. gh-issue: 156444 +.. nonce: klcySy +.. section: Library + +Fix matching of a negated character set in a bytes pattern compiled with +both :const:`re.IGNORECASE` and :const:`re.LOCALE`. The case closure is now +applied to the members of the set, so that ``[^bc]`` no longer matches +``b'B'``. + +.. + +.. date: 2026-08-26-15-28-59 +.. gh-issue: 156360 +.. nonce: ctZMHf +.. section: Library + +Add the :envvar:`PYTHON_TURTLE_LANG` environment variable to select the +language of :mod:`turtle` docstrings. Docstring dictionary entries naming a +method which does not exist in the running version are no longer reported. + +.. + +.. date: 2026-08-26-13-58-01 +.. gh-issue: 156400 +.. nonce: dGrmP1 +.. section: Library + +Fix socket and pipe leaks in :mod:`asyncio` when ``protocol_factory()`` +raises in :meth:`loop.create_datagram_endpoint +`, :meth:`loop.connect_read_pipe +`, and :meth:`loop.connect_write_pipe +`. The socket or pipe is now closed instead +of leaking until garbage collection. + +.. + +.. date: 2026-08-26-12-48-10 +.. gh-issue: 156408 +.. nonce: -Yd0k7 +.. section: Library + +Fix :func:`asyncio.print_call_graph` raising :exc:`AttributeError` when +called on a task that has already finished. + +.. + +.. date: 2026-08-26-08-20-07 +.. gh-issue: 156404 +.. nonce: 2gP33I +.. section: Library + +Restore compatibility with :file:`.pth` files generated before Python 3.15 +in the :mod:`site` module. Inject the ``fullname`` variable in the frame +which executes pth code. + +.. + +.. date: 2026-08-26-02-30-00 +.. gh-issue: 156353 +.. nonce: abcdef +.. section: Library + +Fix :mod:`configparser` parsing when using whitespace in *delimiters*. + +.. + +.. date: 2026-08-24-22-20-55 +.. gh-issue: 156327 +.. nonce: arC8Ph +.. section: Library + +Fix :func:`asyncio.print_call_graph` including its own frame in the printed +call stack. + +.. + +.. date: 2026-08-24-14-28-47 +.. gh-issue: 108549 +.. nonce: XZ34WD +.. section: Library + +Fix :class:`asyncio.Task`, when the task has a pending cancellation, replace +**exc** exception with a :exc:`asyncio.CancelledError` unless it is +:exc:`SystemExit` or :exc:`KeyboardInterrupt`, which must propagate +unchanged. + +.. + +.. date: 2026-08-22-19-00-00 +.. gh-issue: 156261 +.. nonce: Nq4tWv +.. section: Library + +:func:`pwd.getpwuid` now raises :exc:`OverflowError` instead of +:exc:`KeyError` if the user id is out of the range of the C ``uid_t`` type, +as :func:`grp.getgrgid` does for the group id. + +.. + +.. date: 2026-08-22-14-12-40 +.. gh-issue: 156230 +.. nonce: Lt9wQd +.. section: Library + +:meth:`curses.window.instr`, :meth:`~curses.window.in_wstr` and +:meth:`~curses.window.in_wchstr` no longer limit the count to 2047, which +silently truncated a longer line. + +.. + +.. date: 2026-08-22-10-30-00 +.. gh-issue: 156228 +.. nonce: k3Rmxw +.. section: Library + +The :mod:`ssl` and :mod:`hashlib` modules now route OpenSSL memory +allocations through the Python raw memory allocators, making OpenSSL memory +usage visible to :mod:`tracemalloc` and to custom allocators installed with +:c:func:`PyMem_SetAllocator`. + +.. + +.. date: 2026-08-21-14-30-00 +.. gh-issue: 156180 +.. nonce: Qz3Lv8 +.. section: Library + +:func:`zlib.adler32_combine` and :func:`zlib.crc32_combine` now raise +:exc:`ValueError` if the *len2* argument is negative, instead of returning +rubbish or hanging indefinitely, respectively. + +.. + +.. date: 2026-08-21-13-30-00 +.. gh-issue: 156166 +.. nonce: Xv8pQm +.. section: Library + +:mod:`ssl`: A failed assignment or deletion of the ``_msg_callback`` +attribute of :class:`ssl.SSLContext` no longer removes the current callback. +Deleting it now raises :exc:`AttributeError` instead of :exc:`TypeError`. + +.. + +.. date: 2026-08-21-11-56-28 +.. gh-issue: 156173 +.. nonce: mhZa8a +.. section: Library + +Calling :meth:`zlib.Decompress.flush` on invalid compressed data now raises +:exc:`zlib.error` instead of being silently ignored. + +.. + +.. date: 2026-08-20-16-30-00 +.. gh-issue: 156124 +.. nonce: Kq3vXz +.. section: Library + +Fix a crash in the free-threaded build when deleting the :attr:`!contents` +attribute of a :mod:`ctypes` pointer. + +.. + +.. date: 2026-08-20-13-50-49 +.. gh-issue: 156112 +.. nonce: yEcma8 +.. section: Library + +:mod:`!_ios_support` no longer fails to import when +:func:`ctypes.util.find_library` cannot resolve the ObjC runtime through the +dyld shared cache, as is the case on iOS 13. The runtime is now loaded by +name, which dyld resolves against the cache directly. + +.. + +.. date: 2026-08-20-12-10-00 +.. gh-issue: 156101 +.. nonce: Qb2xNv +.. section: Library + +Fix :attr:`sqlite3.Cursor.arraysize` being set to 0 if the assigned value is +too large. The attribute is now left unchanged if the assignment fails. + +.. + +.. date: 2026-08-20-12-05-00 +.. gh-issue: 156100 +.. nonce: Lm7qWz +.. section: Library + +Fix crashes in :class:`sqlite3.Connection` when deleting the +:attr:`~sqlite3.Connection.autocommit` attribute or setting it to an integer +which does not fit in C :c:expr:`long`. Both now raise an exception. + +.. + +.. date: 2026-08-20-12-00-00 +.. gh-issue: 156099 +.. nonce: Kp4vRt +.. section: Library + +Fix a crash when deleting the ``keylog_filename`` attribute of +:class:`ssl.SSLContext`. It now raises :exc:`AttributeError`. + +.. + +.. date: 2026-08-19-21-01-19 +.. gh-issue: 156067 +.. nonce: 1CXkqc +.. section: Library + +Fix error handling in the :mod:`zoneinfo` accelerator module when a +transition index is ``-1`` or a TZ string's ``__bool__`` raises. + +.. + +.. date: 2026-08-18-13-41-00 +.. gh-issue: 155997 +.. nonce: CjbD1F +.. section: Library + +Fix :func:`concurrent.interpreters.list_all`. It failed if an interpreter +was destroyed during the call, in particular by a garbage collection which +finalized the object owning the last reference to it. + +.. + +.. date: 2026-08-17-22-51-22 +.. gh-issue: 155974 +.. nonce: Qz3Vb7 +.. section: Library + +Fix a regression in Python 3.15: :meth:`~curses.window.addstr`, +:meth:`~curses.window.addnstr`, :meth:`~curses.window.insstr` and +:meth:`~curses.window.insnstr` again restore the window attributes when the +write fails, instead of leaving the temporary *attr* applied. + +.. + +.. date: 2026-08-17-21-00-00 +.. gh-issue: 155941 +.. nonce: strmCb +.. section: Library + +Fix :func:`asyncio.start_server` when a plain-function *client_connected_cb* +raises: the error is now reported like the coroutine case and the transport +is closed, instead of leaving the connection open forever (which also made +:meth:`asyncio.Server.wait_closed` hang). + +.. + +.. date: 2026-08-17-18-00-00 +.. gh-issue: 155934 +.. nonce: acCept +.. section: Library + +Fix a socket leak in :mod:`asyncio` when transport creation fails for a +connection accepted by a server, and report the error via the loop exception +handler even when debug mode is disabled. + +.. + +.. date: 2026-08-17-17-39-41 +.. gh-issue: 155966 +.. nonce: 0YOADY +.. section: Library + +:func:`math.tanpi` now raises :exc:`ValueError` for half-integer values +(e.g., ``tanpi(1.5)``), as these are poles of the function. + +.. + +.. date: 2026-08-17-12-40-00 +.. gh-issue: 155952 +.. nonce: Vq3Lm8 +.. section: Library + +Fix the signatures of :meth:`sqlite3.Connection.execute`, +:func:`warnings.warn` and :func:`locale.setlocale` which rendered +```` instead of the correct defaults for parameters. + +.. + +.. date: 2026-08-17-12-07-38 +.. gh-issue: 155596 +.. nonce: Rt4mZq +.. section: Library + +Fix :func:`pprint.pprint` and :func:`pprint.pformat` with ``expand=True`` +not honouring *width* for nested values. The width of the ``'key':`` prefix +was not counted when deciding whether a value fitted on the current line, so +values under long keys could overflow *width* instead of being expanded. + +.. + +.. date: 2026-08-16-11-38-17 +.. gh-issue: 155888 +.. nonce: pO-nAp +.. section: Library + +Fix :meth:`asyncio.WriteTransport.writelines` hanging the transport when the +last data chunk is empty. + +.. + +.. date: 2026-08-15-21-55-31 +.. gh-issue: 155869 +.. nonce: yRUnQW +.. section: Library + +Fix :meth:`!reorganize` in :mod:`dbm.dumb` failing to persist updated value +offsets, which could cause data loss after reopening the database. + +.. + +.. date: 2026-08-15-18-16-16 +.. gh-issue: 121291 +.. nonce: WljPkh +.. section: Library + +:class:`enum.Flag` (and :class:`enum.IntFlag`) subclasses no longer have a +mixin base's own ``__or__``, ``__and__``, ``__xor__``, ``__ror__``, +``__rand__``, ``__rxor__``, or ``__invert__`` override silently replaced by +:class:`~enum.Flag`'s default implementation. + +.. + +.. date: 2026-08-15-17-40-12 +.. gh-issue: 155863 +.. nonce: Kw3Vqp +.. section: Library + +Add the ``WACS_*`` constants to the :mod:`curses` module. They are the +counterparts of the ``ACS_*`` line-drawing codes as +:class:`curses.complexchar` cells, and are added, like the latter, by +:func:`curses.initscr` and :func:`curses.newterm`. + +.. + +.. date: 2026-08-15-13-54-22 +.. gh-issue: 155843 +.. nonce: PD5Af3 +.. section: Library + +:mod:`hmac`: ensure that HMAC objects are properly initialized to prevent +rare crashes on allocation failures. Patch by Bénédikt Tran. + +.. + +.. date: 2026-08-15-13-18-01 +.. gh-issue: 155835 +.. nonce: mlyLWp +.. section: Library + +:mod:`hashlib`: Fix a data race when accessing +:attr:`~hashlib.hash.digest_size` on BLAKE-2 objects. Patch by Bénédikt +Tran. + +.. + +.. date: 2026-08-15-13-12-09 +.. gh-issue: 155835 +.. nonce: DsbSmy +.. section: Library + +:mod:`hashlib`: Fix data races when accessing +:attr:`~hashlib.hash.digest_size` and :attr:`~hashlib.hash.block_size` on +SHA-3 objects. Patch by Bénédikt Tran. + +.. + +.. date: 2026-08-15-10-20-40 +.. gh-issue: 155811 +.. nonce: knP-YB +.. section: Library + +Add a sequence counter to GC statistics to prevent :mod:`!_remote_debugging` +returning inconsistent snapshots caused by non-atomic reads. Patch by +Maurycy Pawłowski-Wieroński. + +.. + +.. date: 2026-08-15-09-47-23 +.. gh-issue: 155717 +.. nonce: jWFLR2 +.. section: Library + +:mod:`multiprocessing`'s default start method is now :ref:`"spawn" +` instead of ``"forkserver"`` when there is +no writable temporary directory, such as on a read-only file system. +Previously starting a process failed with an :exc:`OSError` there. Patch by +Bénédikt Tran. + +.. + +.. date: 2026-08-14-14-10-00 +.. gh-issue: 155775 +.. nonce: Kq3vTx +.. section: Library + +Fix a regression in :mod:`imaplib` introduced in the fix for :gh:`63121`: +refreshing the capabilities after a successful :meth:`~imaplib.IMAP4.login` +or :meth:`~imaplib.IMAP4.authenticate` consumed the ``CAPABILITY`` response, +so it could no longer be read with :meth:`~imaplib.IMAP4.response`. + +.. + +.. date: 2026-08-14-12-46-07 +.. gh-issue: 113318 +.. nonce: DYGQjo +.. section: Library + +Fix crashes when deleting an attribute whose setter is generated by Argument +Clinic and is not prepared for deletion, among them +:attr:`frame.f_trace_opcodes` and the ``context``, ``owner`` and ``session`` +attributes of ``_ssl._SSLSocket``. Deleting such attribute now raises +:exc:`AttributeError`. + +.. + +.. date: 2026-08-14-11-12-18 +.. gh-issue: 155781 +.. nonce: sqlite-converter +.. section: Library + +Fix a possible crash in free-threaded builds when the :mod:`sqlite3` +converter registry is modified concurrently while a cursor builds its row +cast map. + +.. + +.. date: 2026-08-14-10-49-45 +.. gh-issue: 83371 +.. nonce: Km4Rt7 +.. section: Library + +Fix a deadlock in :class:`multiprocessing.pool.Pool` when *callback* or +*error_callback* raises an exception. It killed the thread which handles +results, so that the pool hung forever. The exception is now the result of +the job, as an error raised while iterating the input, and is raised by +:meth:`!AsyncResult.get`. + +.. + +.. date: 2026-08-13-16-02-13 +.. gh-issue: 155702 +.. nonce: Kb7Qm4 +.. section: Library + +Fix :class:`sqlite3.Blob` slice assignment with a step. It patched the bytes +object read from the blob, which for a single byte is an immortal singleton, +so that the value of that byte was changed in the whole process. + +.. + +.. date: 2026-08-12-22-15-00 +.. gh-issue: 90756 +.. nonce: Qn7dLm +.. section: Library + +:meth:`xml.etree.ElementTree.ElementTree.write` now treats the ``utf-8-sig`` +encoding as ``utf-8`` in the XML declaration. + +.. + +.. date: 2026-08-12-21-34-12 +.. gh-issue: 44871 +.. nonce: Rt7Nv2 +.. section: Library + +Parser objects of the :mod:`XML parser ` have a new +method :meth:`!GetSpecifiedAttributeCount`. It tells how many of the +attributes reported to :attr:`!StartElementHandler` were given in the start +tag rather than defaulted from the DTD. + +.. + +.. date: 2026-08-12-21-34-12 +.. gh-issue: 44871 +.. nonce: Qw3Lm8 +.. section: Library + +:mod:`xml.dom.minidom` now conforms closer to the DOM Level 1 specification. +The factory methods now raise :exc:`~xml.dom.InvalidCharacterErr` if the +name is not a valid XML name. Removing an absent attribute with +:meth:`!Element.removeAttribute` or :meth:`!Element.removeAttributeNS` no +longer raises :exc:`~xml.dom.NotFoundErr`, it has no effect as the DOM +specifies. Inserting or setting a node created by another document now +raises :exc:`~xml.dom.WrongDocumentErr`, setting an attribute node which +belongs to another element now raises :exc:`~xml.dom.InuseAttributeErr`, and +inserting a node into itself or its descendant now raises +:exc:`~xml.dom.HierarchyRequestErr`. A document can no longer have two +element or two document type children, and a document fragment can no longer +have notation children. Attributes defaulted in the DTD are no longer +omitted when parsing, and :attr:`!Attr.specified` now reports whether the +attribute was given in the start tag. :class:`!EntityReference` nodes and +:meth:`!Document.createEntityReference` are now implemented. + +.. + +.. date: 2026-08-12-14-30-00 +.. gh-issue: 80762 +.. nonce: Kp3vQa +.. section: Library + +Fix :func:`dir` on :class:`unittest.mock.Mock` objects created with a tuple +*spec*: it raised :exc:`TypeError`. Such *spec* is now also documented. + +.. + +.. date: 2026-08-12-09-30-00 +.. gh-issue: 61366 +.. nonce: Wr7cKm +.. section: Library + +:meth:`!http.cookiejar.MozillaCookieJar.save` now writes ``0`` in the +expiration time field for session cookies, as curl and Wget do. Previously +this field was left empty, and such lines were ignored by curl and Wget. + +.. + +.. date: 2026-08-10-22-23-29 +.. gh-issue: 153400 +.. nonce: nucElC +.. section: Library + +On Linux, :func:`os.copy_file_range` and :func:`os.memfd_create` now fall +back to the raw syscall when the libc Python is built against does not +provide the wrapper function, so they stay available on interpreters built +against a libc older than glibc 2.27. + +.. + +.. date: 2026-08-10-22-11-15 +.. gh-issue: 153400 +.. nonce: Ds3GI3 +.. section: Library + +:mod:`os` and :mod:`signal`: Use glibc functions instead of ``syscall()``: +``pidfd_open()``, ``pidfd_getfd()`` and ``pidfd_send_signal()`` (glibc +2.36), ``gettid()`` and ``getdents64()`` (glibc 2.30), and ``getrandom()`` +(glibc 2.25). Patch by Victor Stinner. + +.. + +.. date: 2026-08-10-19-49-12 +.. gh-issue: 155496 +.. nonce: tJtiAt +.. section: Library + +The ``ctypes.set_errno`` and ``ctypes.set_last_error`` auditing events are +now raised after the argument is converted to an integer, therefore they are +no longer raised if the argument is invalid. + +.. + +.. date: 2026-08-10-19-49-11 +.. gh-issue: 155496 +.. nonce: B4rMR1 +.. section: Library + +:meth:`io.RawIOBase.readinto` and :meth:`io.RawIOBase.write` now raise +:exc:`TypeError` instead of :exc:`NotImplementedError` if they are called +without the required argument. + +.. + +.. date: 2026-08-10-15-24-13 +.. gh-issue: 155468 +.. nonce: W7qL2p +.. section: Library + +Fix :mod:`netrc` to distinguish empty quoted tokens from end-of-file, so +malformed files no longer cause the remaining content to be silently +ignored. + +.. + +.. date: 2026-08-10-13-27-36 +.. gh-issue: 155519 +.. nonce: 9M6SFX +.. section: Library + +Avoid a data-race in free-threaded builds when reading and writing context +variables from different threads. + +.. + +.. date: 2026-08-10-09-00-18 +.. gh-issue: 155336 +.. nonce: vrTXoU +.. section: Library + +Fix error handling in :func:`socket.gethostbyaddr` and +:func:`socket.gethostbyname_ex` when hostname resolution fails. + +.. + +.. date: 2026-08-09-21-30-00 +.. gh-issue: 118318 +.. nonce: Xr4Kd8 +.. section: Library + +Remove the ``write_c14n()`` method of +:class:`xml.etree.ElementTree.ElementTree` and the support of +``method="c14n"`` in :meth:`~xml.etree.ElementTree.ElementTree.write` and +:func:`~xml.etree.ElementTree.tostring`. They never worked and always +raised :exc:`ValueError`. Use :func:`xml.etree.ElementTree.canonicalize` +instead. + +.. + +.. date: 2026-08-09-16-14-38 +.. gh-issue: 155433 +.. nonce: KL7tHV +.. section: Library + +Fix :class:`asyncio.TaskGroup` losing outside cancellation after +``cancel()``. + +.. + +.. date: 2026-08-09-14-27-23 +.. gh-issue: 155418 +.. nonce: kCXUIG +.. section: Library + +Fix :class:`asyncio.TaskGroup` hang when a task created by +:func:`asyncio.eager_task_factory` cancels the group before suspending. + +.. + +.. date: 2026-08-09-01-30-00 +.. gh-issue: 102475 +.. nonce: rpjoin +.. section: Library + +Fix :func:`os.path.realpath` on Windows: the unresolved part of the path is +now appended, not joined, so a file name which looks like a drive (e.g. +``spam:eggs``) no longer discards the resolved part. A path relative to +another drive is now resolved against the root directory of that drive. + +.. + +.. date: 2026-08-09-00-30-00 +.. gh-issue: 89760 +.. nonce: rpvol +.. section: Library + +Fix :func:`os.path.realpath` on Windows: the ``\\?\`` prefix is no longer +stripped from a volume GUID path, which made the result invalid. + +.. + +.. date: 2026-08-08-21-40-00 +.. gh-issue: 84419 +.. nonce: statexe +.. section: Library + +Fix :func:`os.stat` on Windows: trailing dots and spaces, which are ignored +by the operating system, are no longer taken into account when the execute +permissions are guessed from the file extension. + +.. + +.. date: 2026-08-08-18-30-00 +.. gh-issue: 111331 +.. nonce: bioclose +.. section: Library + +Closing a :class:`io.BytesIO` object which has exported buffers no longer +fails with :exc:`BufferError`. The exported buffers keep the data alive and +stay usable. As a result, destroying or garbage collecting such object no +longer emits an unraisable exception. + +.. + +.. date: 2026-08-08-09-14-22 +.. gh-issue: 108885 +.. nonce: C4ktfw +.. section: Library + +Doctests run by the :mod:`unittest` test runner now report every example, as +in verbose mode, if the runner reports more than the test names, i.e. its +verbosity is 3 or higher. The :option:`!-v` option of :mod:`unittest` can +now be repeated, so ``python -m unittest -vv`` asks for this. Added also +the :attr:`~unittest.TestResult.verbosity` attribute of +:class:`unittest.TestResult`. + +.. + +.. date: 2026-08-07-02-20-00 +.. gh-issue: 155319 +.. nonce: srcline +.. section: Library + +:func:`warnings.warn_explicit` now displays the source line taken from the +loader of the module whose globals are passed as *module_globals*. It also +no longer raises :exc:`IndexError` if *lineno* is out of the range of the +module source. + +.. + +.. date: 2026-08-07-01-10-00 +.. gh-issue: 123011 +.. nonce: warnexp +.. section: Library + +:func:`warnings.warn_explicit` no longer emits a spurious +:exc:`DeprecationWarning` or raises :exc:`ImportError` when it is called +with the globals of the :mod:`__main__` module. + +.. + +.. date: 2026-08-05-17-30-00 +.. gh-issue: 69370 +.. nonce: inspCLI +.. section: Library + +:program:`python -m inspect --details` no longer fails with +:exc:`UnicodeEncodeError` if the path of the module contains characters +unencodable in the encoding of :data:`sys.stdout`. Such characters are now +escaped with backslashes. + +.. + +.. date: 2026-08-05-16-40-00 +.. gh-issue: 69371 +.. nonce: pyDocU +.. section: Library + +Fix :mod:`pydoc` for modules whose path contains undecodable bytes. +:func:`!pydoc.writedoc` and the pydoc HTTP server no longer fail with +:exc:`UnicodeEncodeError`: the file URL is now percent-encoded using the +filesystem encoding, and characters unencodable in the generated HTML page +are escaped with backslashes. + +.. + +.. date: 2026-08-05-16-30-12 +.. gh-issue: 155236 +.. nonce: Kd7pQr +.. section: Library + +Add the *dedent* parameter in :func:`inspect.cleandoc` and +:func:`inspect.getdoc`. :mod:`pydoc` no longer dedents documentation +strings, so the indentation of the parameter descriptions generated by +Argument Clinic is preserved. + +.. + +.. date: 2026-08-05-02-36-18 +.. gh-issue: 155009 +.. nonce: YiJAiP +.. section: Library + +Fix :class:`argparse.ArgumentParser` to preserve the program name from +``sys.argv[0]`` when a named module is executed as the main program without +replacing ``sys.argv[0]``. + +.. + +.. date: 2026-08-04-19-50-52 +.. gh-issue: 150942 +.. nonce: B8ytes +.. section: Library + +Improve the performance of :meth:`~io.IOBase.readlines` for +:class:`io.BytesIO`. + +.. + +.. date: 2026-08-04-19-03-20 +.. gh-issue: 155063 +.. nonce: gN_mCU +.. section: Library + +Bump the version of pip bundled in ensurepip to version 26.2.1 + +.. + +.. date: 2026-08-04-14-14-31 +.. gh-issue: 153711 +.. nonce: PBpc1g +.. section: Library + +On macOS, add run-time checks around the syscalls :manpage:`pipe2 (2)` and +:manpage:`dup3 (2)`, in addition to the existing build-time checks. This +means that Python built on macOS 27 (where these calls are available) can +run on macOS 26 (where they aren't). + +.. + +.. date: 2026-08-03-22-46-07 +.. gh-issue: 155143 +.. nonce: 9-byZp +.. section: Library + +Fix :func:`asyncio.shield` leaking the calling task via the await-graph and +callbacks when called on a future that never resolves. + +.. + +.. date: 2026-08-01-23-50-47 +.. gh-issue: 75008 +.. nonce: 0Boa3r +.. section: Library + +:meth:`csv.Sniffer.sniff` now detects the *lineterminator* parameter by a +majority vote among the line endings of the sample. + +.. + +.. date: 2026-08-01-21-00-00 +.. gh-issue: 155051 +.. nonce: Lc1Non +.. section: Library + +:func:`decimal.localcontext` now raises :exc:`TypeError` if a keyword +argument is ``None``, as the pure Python implementation already did. +Previously the C implementation silently ignored it. + +.. + +.. date: 2026-08-01-20-21-37 +.. gh-issue: 99772 +.. nonce: q7M3vP +.. section: Library + +Fix comparisons and hashing of :class:`datetime.time` objects with +sub-minute UTC offsets. + +.. + +.. date: 2026-08-01-19-05-00 +.. gh-issue: 155044 +.. nonce: Op1Val +.. section: Library + +:class:`optparse.Values` objects now support :func:`copy.replace`. + +.. + +.. date: 2026-08-01-19-04-00 +.. gh-issue: 155043 +.. nonce: Ar1Nsp +.. section: Library + +:class:`argparse.Namespace` objects now support :func:`copy.replace`. + +.. + +.. date: 2026-08-01-19-02-00 +.. gh-issue: 155041 +.. nonce: Dc1Ctx +.. section: Library + +:class:`decimal.Context` objects now support :func:`copy.replace`. + +.. + +.. date: 2026-08-01-19-01-00 +.. gh-issue: 155040 +.. nonce: Tr1nFo +.. section: Library + +:class:`tarfile.TarInfo` objects now support :func:`copy.replace`. + +.. + +.. date: 2026-08-01-18-37-56 +.. gh-issue: 155063 +.. nonce: xC9PcH +.. section: Library + +Bump the version of pip bundled in ensurepip to version 26.2 + +.. + +.. date: 2026-08-01-12-00-00 +.. gh-issue: 155033 +.. nonce: dR3pLc +.. section: Library + +CSV dialects (instances of :class:`csv.Dialect` subclasses and dialect +objects returned by :func:`csv.get_dialect`) now support +:func:`copy.replace`. + +.. + +.. date: 2026-07-30-23-29-56 +.. gh-issue: 154936 +.. nonce: a90443 +.. section: Library + +Fix the pure Python :mod:`json` decoder to report the correct position for +invalid literal control characters in JSON strings. + +.. + +.. date: 2026-07-30-02-15-00 +.. gh-issue: 154904 +.. nonce: Kx9mAq +.. section: Library + +Speed up :mod:`shutil` import by probing the ``_bz2``, ``_lzma`` and +``_zstd`` extension modules instead of importing the :mod:`bz2`, :mod:`lzma` +and :mod:`compression.zstd` wrappers, which are now only imported when an +archive is actually created or extracted. + +.. + +.. date: 2026-07-29-21-37-39 +.. gh-issue: 154892 +.. nonce: eQyJ3Z +.. section: Library + +Fix a bug in the C accelerator for :mod:`zoneinfo` where +:class:`datetime.datetime` subclasses returning ``-1`` for ``hour``, +``minute``, or ``second`` could incorrectly raise a :exc:`SystemError`. + +.. + +.. date: 2026-07-29-19-48-59 +.. gh-issue: 154871 +.. nonce: tgZILS +.. section: Library + +Fixed a crash in :meth:`asyncio.Task.get_context` when called on an +uninitialized task. + +.. + +.. date: 2026-07-29-18-30-00 +.. gh-issue: 154848 +.. nonce: Fr4meB +.. section: Library + +The :mod:`pickle` C accelerator now enforces frame boundaries when +unpickling, as the pure Python implementation already did. An argument that +straddles a frame boundary, or a frame that begins before the previous one +has ended, now raises :exc:`pickle.UnpicklingError` instead of being +silently read across the boundary. This prevents the loaded data from +diverging from the :mod:`pickletools` disassembly of the same pickle. + +.. + +.. date: 2026-07-29-16-53-50 +.. gh-issue: 154885 +.. nonce: ptofmI +.. section: Library + +:func:`os.get_terminal_size` now checks ``isatty`` before calling ``ioctl``, +which reduces log noise on Android. + +.. + +.. date: 2026-07-29-14-20-40 +.. gh-issue: 154855 +.. nonce: vfF453 +.. section: Library + +Fix :meth:`curses.window.instr`, :meth:`~curses.window.in_wstr` and +:meth:`~curses.window.in_wchstr` returning one character too few when the +:mod:`curses` module is built against a curses library that counts the +terminator in the requested length, such as the NetBSD one. + +.. + +.. date: 2026-07-29-11-58-17 +.. gh-issue: 154874 +.. nonce: NAPdBp +.. section: Library + +Fix :func:`curses.termattrs` returning a negative value on a terminal that +supports :const:`curses.A_ITALIC`, which left its result unusable as an +attribute mask. + +.. + +.. date: 2026-07-29-11-05-00 +.. gh-issue: 151728 +.. nonce: Kq3vTn +.. section: Library + +Clear the internal :mod:`typing` caches from an exit handler. Previously, an +extension module that leaked a reference to :mod:`typing` would also keep +every subscripted type alive past interpreter shutdown, including types +owned by unrelated extension modules. + +.. + +.. date: 2026-07-28-08-02-41 +.. gh-issue: 154791 +.. nonce: ey7POa +.. section: Library + +Fix :class:`asyncio.Future` (C implementation) losing the initial exception +traceback frames when ``Future.result()`` is called more than once. +Previously, the C implementation cleared the stored traceback after the +first call, causing subsequent raises to omit the original raise site. The +pure-Python implementation was unaffected. + +.. + +.. date: 2026-07-27-12-00-00 +.. gh-issue: 94984 +.. nonce: Xr3vFq +.. section: Library + +Add the *mode* parameter to :meth:`asyncio.loop.create_unix_server` and +:func:`asyncio.start_unix_server` to set the permissions of the Unix socket +file created for *path*, applied before the server starts accepting +connections. + +.. + +.. date: 2026-07-26-13-40-00 +.. gh-issue: 154744 +.. nonce: Sk1Psp +.. section: Library + +Improve detection of ``skipinitialspace`` in :meth:`csv.Sniffer.sniff`. + +.. + +.. date: 2026-07-26-11-45-34 +.. gh-issue: 154726 +.. nonce: hLJk5- +.. section: Library + +Fix :func:`shutil.copyfile` to copy a symbolic link to a special file when +``follow_symlinks=False`` instead of raising +:exc:`~shutil.SpecialFileError`. + +.. + +.. date: 2026-07-26-00-00-00 +.. gh-issue: 154738 +.. nonce: Rd5Pxe +.. section: Library + +Fix :meth:`!ExternalEntityParserCreate` not propagating the reparse-deferral +setting to the subparser, which left :meth:`!GetReparseDeferralEnabled` +returning an uninitialized value. Patch by tonghuaroot. + +.. + +.. date: 2026-07-25-13-30-00 +.. gh-issue: 93251 +.. nonce: gAiErr +.. section: Library + +Fix :exc:`UnicodeDecodeError` in :mod:`socket` functions (such as +:func:`~socket.getaddrinfo` and :func:`~socket.gethostbyaddr`) when the +localized error message of the C library is not UTF-8: decode it from the +locale encoding. + +.. + +.. date: 2026-07-24-21-49-45 +.. gh-issue: 148468 +.. nonce: pHoF_Q +.. section: Library + +Fix a regression in :mod:`argparse` where colorized argument help containing +format specifiers did not accept string-like proxy objects. + +.. + +.. date: 2026-07-24-17-02-46 +.. gh-issue: 154638 +.. nonce: 7YnFHH +.. section: Library + +Improve import time of :mod:`argparse` by lazily importing several +dependencies. + +.. + +.. date: 2026-07-24-15-54-35 +.. gh-issue: 142035 +.. nonce: ZpNfl6 +.. section: Library + +Fix incorrect wrapping of :mod:`argparse` help text when color is enabled. + +.. + +.. date: 2026-07-24-12-29-15 +.. gh-issue: 135736 +.. nonce: DyvA2m +.. section: Library + +Fix ::class:`asyncio.TaskGroup` to not wrap a :exc:`GeneratorExit` into a +:exc:`BaseExceptionGroup` if it was raised by the body of the task group and +none of the tasks in the group raised exceptions. + +.. + +.. date: 2026-07-24-00-02-00 +.. gh-issue: 154594 +.. nonce: Xk7mQ2 +.. section: Library + +Fix :func:`copy.deepcopy` so that an object whose deep copy is ``None`` is +still memoized. Patch by tonghuaroot. + +.. + +.. date: 2026-07-23-21-00-00 +.. gh-issue: 154568 +.. nonce: float16-reconstructor +.. section: Library + +Fix :mod:`array` unpickling of little-endian float16. + +.. + +.. date: 2026-07-23-20-00-00 +.. gh-issue: 154566 +.. nonce: byteswap-zd +.. section: Library + +Fix :meth:`array.array.byteswap` corrupting data for ``'Zd'`` (complex +double) arrays with more than one element: the 16-byte item loop advanced +the buffer pointer by only 8 bytes per iteration, causing items after the +first to be scrambled. + +.. + +.. date: 2026-07-23-19-45-00 +.. gh-issue: 154551 +.. nonce: Ct7pL9 +.. section: Library + +Fix :func:`ctypes.util.find_library` returning ``None`` in non-UTF-8 +locales. + +.. + +.. date: 2026-07-23-18-53-48 +.. gh-issue: 154523 +.. nonce: XUSRBO +.. section: Library + +Fixed data-race when calling :meth:`io.TextIOBase.detach` in +:term:`free-threaded build`. + +.. + +.. date: 2026-07-23-14-13-39 +.. gh-issue: 135683 +.. nonce: droBu7 +.. section: Library + +:class:`logging.FileHandler` and +:class:`logging.handlers.WatchedFileHandler` now honor +:data:`logging.raiseExceptions` for errors that occur while opening the +file, like for other errors during logging. + +.. + +.. date: 2026-07-23-13-09-25 +.. gh-issue: 154199 +.. nonce: hmBfrS +.. section: Library + +Make :func:`ctypes.util.find_msvcrt` always return ``None`` for +compatibility reasons. + +.. + +.. date: 2026-07-23-12-27-52 +.. gh-issue: 135736 +.. nonce: hkuGvu +.. section: Library + +Fix :class:`asyncio.TaskGroup` silently discarding errors from sibling tasks +whenever the ``async with`` block exits with a :exc:`SystemExit` or +:exc:`KeyboardInterrupt`. These errors are now reported via +:meth:`loop.call_exception_handler() ` +instead of being lost. + +.. + +.. date: 2026-07-23-06-53-01 +.. gh-issue: 79366 +.. nonce: 3gMT7I +.. section: Library + +Fixed a race condition in :mod:`logging`: if a handler was removed while a +record was being emitted, the following handlers of the same logger could be +skipped. + +.. + +.. date: 2026-07-22-19-21-20 +.. gh-issue: 82535 +.. nonce: METFqd +.. section: Library + +:class:`logging.handlers.SysLogHandler` no longer fails if the address +cannot be resolved when the handler is created. The address is resolved +again when a record is emitted. + +.. + +.. date: 2026-07-22-17-35-24 +.. gh-issue: 70990 +.. nonce: xVHKwt +.. section: Library + +:class:`logging.handlers.SysLogHandler` now accepts a :class:`bytes` address +of a Unix domain socket, including an address in the abstract namespace. +Previously only :class:`str` was recognized, and a :class:`bytes` address +raised :exc:`ValueError`. + +.. + +.. date: 2026-07-22-15-56-11 +.. gh-issue: 154189 +.. nonce: 7zWWNZ +.. section: Library + +Fixed a potential use-after-free when calling :func:`functools.partial`. +Now, when invoking a :func:`~functools.partial` object, the stored function, +positional arguments, and keyword arguments are preserved for the duration +of the call in case of reentrancy. + +.. + +.. date: 2026-07-22-13-39-58 +.. gh-issue: 154470 +.. nonce: zGcz6K +.. section: Library + +Fixed a spurious ``^J`` printed at the end of every source line by the +``list`` command of :mod:`pdb` when the output is colorized (for example +when attaching to a running process). The source line is now stripped before +it is colorized, like the ``where`` command already did. + +.. + +.. date: 2026-07-22-13-01-24 +.. gh-issue: 73458 +.. nonce: byxSPi +.. section: Library + +Fix :func:`logging.config.listen`: it left the caller waiting for the +``ready`` event forever if the server could not be started, for example if +the port was invalid or already in use. It now also binds to an IPv6 address +if the host has no IPv4 address, for example if ``localhost`` is only +aliased to ``::1``. + +.. + +.. date: 2026-07-22-13-00-00 +.. gh-issue: 154460 +.. nonce: wCsFtM +.. section: Library + +Fix :func:`time.strftime` and :meth:`datetime.datetime.strftime` returning a +wrong ISO 8601 week number (``%V``) on OpenBSD. + +.. + +.. date: 2026-07-22-12-59-26 +.. gh-issue: 154467 +.. nonce: AA9w1D +.. section: Library + +Fixed :mod:`pdb` remote attaching (``python -m pdb -p PID``) sending an +empty prompt to the client instead of ``(Pdb)`` when the target process has +an interactive terminal. + +.. + +.. date: 2026-07-22-12-00-00 +.. gh-issue: 153970 +.. nonce: Kq7Wn3 +.. section: Library + +Calling :func:`str` on a :exc:`subprocess.CalledProcessError` no longer +raises :exc:`TypeError` when its :attr:`!returncode` is not an integer, such +as ``None``. + +.. + +.. date: 2026-07-22-10-30-08 +.. gh-issue: 154435 +.. nonce: xCxm0T +.. section: Library + +Fix :func:`os.posix_fadvise` and :func:`os.posix_fallocate` on DragonFly +BSD: they raised :exc:`OSError` with a meaningless error code, because these +functions return -1 and set ``errno`` there. + +.. + +.. date: 2026-07-21-21-36-59 +.. gh-issue: 154399 +.. nonce: VSa6oH +.. section: Library + +Fix :mod:`venv` activation in a non-interactive csh: ``activate.csh`` no +longer fails when the ``prompt`` variable is not set. + +.. + +.. date: 2026-07-21-20-34-05 +.. gh-issue: 154389 +.. nonce: DlTiii +.. section: Library + +Fix :func:`uuid.uuid1` on OpenBSD: it returned a version 4 UUID, because +``uuid_create()`` generates random UUIDs on this platform. + +.. + +.. date: 2026-07-21-12-23-48 +.. gh-issue: 154335 +.. nonce: SRf8Gr +.. section: Library + +The :mod:`profiling.sampling` profiler now respects ``NO_COLOR``, +``FORCE_COLOR``, and ``PYTHON_COLORS`` and avoids colored output when not +writing to a terminal. + +.. + +.. date: 2026-07-21-08-31-55 +.. gh-issue: 154324 +.. nonce: vDxV5U +.. section: Library + +Fix :func:`os.sendfile` on illumos: it no longer reports a successful +transfer when the underlying system call failed without writing any data. + +.. + +.. date: 2026-07-21-01-13-39 +.. gh-issue: 154307 +.. nonce: UNFKL4 +.. section: Library + +Fix :meth:`tempfile.TemporaryDirectory.cleanup` on DragonFly BSD, where +removing a file with the ``UF_NOUNLINK`` flag failed with ``EISDIR`` instead +of ``EPERM``. + +.. + +.. date: 2026-07-20-22-03-44 +.. gh-issue: 154291 +.. nonce: Mi5HeQ +.. section: Library + +Fix :func:`socket.has_dualstack_ipv6` to return ``False`` on platforms such +as DragonFly BSD where setting ``IPV6_V6ONLY`` to 0 silently has no effect. + +.. + +.. date: 2026-07-20-21-36-40 +.. gh-issue: 154283 +.. nonce: Xip7xE +.. section: Library + +On DragonFly BSD, :func:`threading.get_native_id` now returns a value that +is unique across processes, matching the other platforms. + +.. + +.. date: 2026-07-20-18-30-00 +.. gh-issue: 154258 +.. nonce: mmapresize +.. section: Library + +Fix a crash in :meth:`mmap.mmap.resize` on NetBSD when growing a shared +anonymous mapping. :meth:`!resize` now raises :exc:`ValueError` in this +case, as it already did on Linux. + +.. + +.. date: 2026-07-20-17-15-00 +.. gh-issue: 131565 +.. nonce: dllist +.. section: Library + +:func:`ctypes.util.dllist` now works on NetBSD. It is implemented in the +:mod:`!_ctypes` extension module so that ``dl_iterate_phdr()`` reports all +loaded shared libraries: on NetBSD it only reports the link-map group of the +calling object, which excluded them when called through ctypes. + +.. + +.. date: 2026-07-20-14-10-00 +.. gh-issue: 154225 +.. nonce: openpty +.. section: Library + +Fix :func:`os.openpty` on Solaris and illumos: it no longer leaves the +pseudo-terminal as the controlling terminal of the calling process. + +.. + +.. date: 2026-07-20-14-00-00 +.. gh-issue: 154227 +.. nonce: openpt +.. section: Library + +Fix :func:`os.posix_openpt` on OpenBSD, where it rejected the +:data:`~os.O_CLOEXEC` flag. + +.. + +.. date: 2026-07-20-12-45-00 +.. gh-issue: 139373 +.. nonce: qL7xKm +.. section: Library + +Fix :meth:`asyncio.subprocess.Process.communicate` losing already-read +output when it is cancelled; the output is now retained and returned by a +subsequent ``communicate()`` call. Patch by Kumar Aditya. + +.. + +.. date: 2026-07-20-12-40-00 +.. gh-issue: 145030 +.. nonce: TFJm6k +.. section: Library + +Fix :mod:`asyncio` write pipe transports for named FIFOs on macOS and +Solaris. Unread data sitting in the FIFO made the transport misinterpret a +poll event as the reader disconnecting, wrongly closing the transport. + +.. + +.. date: 2026-07-19-22-08-05 +.. gh-issue: 154194 +.. nonce: 1bqRdx +.. section: Library + +Fix the sampling profiler dropping entire samples when a non-fatal read +fails; frames now keep any readable metadata, and long funcnames and +filenames are truncated instead. Patch by Maurycy Pawłowski-Wieroński. + +.. + +.. date: 2026-07-19-21-30-00 +.. gh-issue: 154176 +.. nonce: strxfrm +.. section: Library + +Fix a crash in :func:`locale.strxfrm` on DragonFly BSD, whose ``wcsxfrm()`` +does not support the zero size. + +.. + +.. date: 2026-07-19-20-00-00 +.. gh-issue: 154836 +.. nonce: kqWait +.. section: Library + +Fix :meth:`subprocess.Popen.wait` raising :exc:`TypeError` (macOS and other +BSDs) or :exc:`OverflowError` (Linux) for very large *timeout* values such +as ``float('inf')``, a 3.15 regression in the new event-driven wait. Also +fix :meth:`select.kqueue.control` masking :exc:`OverflowError` for +out-of-range timeouts as :exc:`TypeError`. + +.. + +.. date: 2026-07-19-19-05-00 +.. gh-issue: 154146 +.. nonce: acospi +.. section: Library + +Fix accuracy of :func:`math.acospi` for arguments close to 1 on platforms +that do not provide ``acospi()`` in libm. + +.. + +.. date: 2026-07-19-17-45-00 +.. gh-issue: 153005 +.. nonce: F6WH92 +.. section: Library + +:meth:`!concurrent.interpreters.Queue.get` and +:meth:`!concurrent.interpreters.Queue.put` now compute their ``timeout`` +deadline from :func:`time.monotonic` instead of the wall clock, so adjusting +the system clock during the call no longer makes them over- or under-wait. + +.. + +.. date: 2026-07-19-17-05-00 +.. gh-issue: 153772 +.. nonce: cobjTK +.. section: Library + +:func:`isinstance` checks against :mod:`collections.abc` classes such as +:class:`~collections.abc.Mapping` no longer raise :exc:`AttributeError` when +the instance has no ``__class__``. The abstract base class machinery now +falls back to the object's type in that case, matching the behaviour of the +built-in :func:`isinstance`. + +.. + +.. date: 2026-07-19-14-00-00 +.. gh-issue: 154090 +.. nonce: q2kH1b +.. section: Library + +Record the profiling mode in Tachyon binary profiles and reject differential +comparisons whose known modes do not match. + +.. + +.. date: 2026-07-19-13-00-00 +.. gh-issue: 154086 +.. nonce: MJKrQV +.. section: Library + +Store per-thread sample counts in Tachyon flamegraphs so filtering a thread +updates frame widths and totals. + +.. + +.. date: 2026-07-19-12-10-00 +.. gh-issue: 154060 +.. nonce: cR6tYn +.. section: Library + +Store measured duration and sampling rate in Tachyon binary profiles so they +remain available in replayed flamegraphs. + +.. + +.. date: 2026-07-19-12-00-00 +.. gh-issue: 154085 +.. nonce: Qm8fLd +.. section: Library + +Prevent differential flamegraphs from duplicating self time across line +nodes for the same function. + +.. + +.. date: 2026-07-19-11-30-00 +.. gh-issue: 154088 +.. nonce: pC7nRa +.. section: Library + +Make Tachyon count and render elided stacks consistently in differential +flamegraphs. + +.. + +.. date: 2026-07-19-11-20-00 +.. gh-issue: 154089 +.. nonce: Vp2qHx +.. section: Library + +Do not show unavailable sampling efficiency statistics in replayed Tachyon +flamegraphs. + +.. + +.. date: 2026-07-19-11-00-00 +.. gh-issue: 154062 +.. nonce: N5ks3A +.. section: Library + +Stop normalizing differential flamegraph baselines to the duration of the +current profile. + +.. + +.. date: 2026-07-19-00-00-00 +.. gh-issue: 154053 +.. nonce: LibreSSLsigalgs +.. section: Library + +Fix compilation of the :mod:`ssl` module against LibreSSL, which does not +provide ``SSL_CTX_set1_sigalgs_list()`` and +``SSL_CTX_set1_client_sigalgs_list()``. The :meth:`!set_server_sigalgs` and +:meth:`!set_client_sigalgs` methods of :class:`ssl.SSLContext` now raise +:exc:`NotImplementedError` on LibreSSL. + +.. + +.. date: 2026-07-18-18-12-44 +.. gh-issue: 154002 +.. nonce: Qw9zTn +.. section: Library + +The pure-Python :mod:`pickle` unpickler no longer replaces a +:exc:`TypeError` raised by an old-style instance constructor with a new one +carrying the traceback object in its ``args``. The original error now +propagates, as it already did in the C implementation. + +.. + +.. date: 2026-07-18-17-09-49 +.. gh-issue: 154001 +.. nonce: 3brrUv +.. section: Library + +Fix :func:`random.binomialvariate` raising :exc:`ZeroDivisionError` when +:func:`random.random` returns zero. + +.. + +.. date: 2026-07-18-16-43-02 +.. gh-issue: 118150 +.. nonce: x0mV8P +.. section: Library + +Expose automated junk heuristic kwarg-only flag ``autojunk`` from +:class:`difflib.SequenceMatcher` to the public functions and class methods +in the :mod:`difflib`. See :class:`difflib.SequenceMatcher` documentation +for details and issue :gh:`118150` for the motivation. + +.. + +.. date: 2026-07-18-16-05-38 +.. gh-issue: 153967 +.. nonce: -OUNXe +.. section: Library + +:meth:`argparse.ArgumentParser.print_usage` and +:meth:`argparse.ArgumentParser.print_help` won't silently fail when an +invalid file object is specified. Patch by Timothy Poon. + +.. + +.. date: 2026-07-18-13-30-00 +.. gh-issue: 153906 +.. nonce: mHtNdY +.. section: Library + +Modernize the HTML output of :mod:`pydoc`: use semantic HTML5 markup and a +new style sheet based on the python-docs-theme used by docs.python.org, with +dark mode support. Class members inherited from other classes are now +collapsed by default. + +.. + +.. date: 2026-07-18-11-16-41 +.. gh-issue: 153908 +.. nonce: 82FiGk +.. section: Library + +Fix data race when calling :func:`repr` on :class:`itertools.count` under +the :term:`free-threaded build`. + +.. + +.. date: 2026-07-18-10-52-10 +.. gh-issue: 153896 +.. nonce: 87oevp +.. section: Library + +Deduplicate unhashable args in :data:`typing.Literal`. + +.. + +.. date: 2026-07-18-06-16-55 +.. gh-issue: 153903 +.. nonce: mJFrs8 +.. section: Library + +Add :func:`ctypes.util.wrap_dll_function` for creating +:class:`~ctypes._CFuncPtr` objects from a function signature. + +.. + +.. date: 2026-07-18-04-09-44 +.. gh-issue: 81241 +.. nonce: gGRbBr +.. section: Library + +Fix :exc:`OSError` when importing :mod:`ctypes` from a statically linked +interpreter. + +.. + +.. date: 2026-07-17-20-56-32 +.. gh-issue: 153864 +.. nonce: WmA9By +.. section: Library + +On a wide :mod:`curses` build, :meth:`curses.window.insch` now inserts a +non-ASCII byte as the character it encodes in the window's encoding, +consistently with :meth:`~curses.window.addch`, instead of its code point. + +.. + +.. date: 2026-07-17-20-31-00 +.. gh-issue: 153862 +.. nonce: X3kjoY +.. section: Library + +On a wide :mod:`curses` build, :meth:`curses.window.inch` now returns the +locale-encoded byte of a non-ASCII character, matching +:meth:`~curses.window.instr`, instead of the low byte of its code point. + +.. + +.. date: 2026-07-17-14-30-00 +.. gh-issue: 153856 +.. nonce: JEHepm +.. section: Library + +Add :data:`os.RWF_NOSIGNAL` constant for Linux 6.18+. + +.. + +.. date: 2026-07-17-14-30-00 +.. gh-issue: 153844 +.. nonce: pYs7Kq +.. section: Library + +:func:`symtable.symtable` now accepts an AST object, like the builtin +:func:`compile`. + +.. + +.. date: 2026-07-17-12-00-00 +.. gh-issue: 153838 +.. nonce: HmCp5s +.. section: Library + +Skip non-regular files in the ``profiling.sampling`` heatmap exporter +instead of reading them unconditionally. Patch by tonghuaroot. + +.. + +.. date: 2026-07-15-21-56-40 +.. gh-issue: 146011 +.. nonce: nWmHif +.. section: Library + +Fix a heap-use-after-free in the C implementation of :mod:`decimal` when +calling :func:`repr` after deleting the :class:`~decimal.Context`. + +.. + +.. date: 2026-07-15-21-45-33 +.. gh-issue: 141276 +.. nonce: xH7qP2 +.. section: Library + +Fix duplicate :exc:`SyntaxWarning` messages when importing source modules +from ZIP archives. :meth:`zipimport.zipimporter.get_filename`, and therefore +:meth:`~zipimport.zipimporter.find_spec`, no longer compile source modules. +A :exc:`SyntaxError` in a zipped source module is now raised when the module +is executed rather than when it is found, matching the behavior of +filesystem-based loaders. + +.. + +.. date: 2026-07-15-15-19-08 +.. gh-issue: 104533 +.. nonce: pQJxCk +.. section: Library + +Add :func:`ctypes.util.struct` and :class:`ctypes.util.CFieldInfo` for +generating structure types using annotations. + +.. + +.. date: 2026-07-15-14-24-18 +.. gh-issue: 153761 +.. nonce: 8jqs67 +.. section: Library + +Fix cancelling :meth:`asyncio.loop.sock_accept` dropping a pending +connection. + +.. + +.. date: 2026-07-14-19-45-21 +.. gh-issue: 153695 +.. nonce: UYdZJZ +.. section: Library + +Hashing a :class:`sqlite3.Row` that contains an unhashable value now raises +:exc:`TypeError` instead of :exc:`SystemError`. Patch by tonghuaroot. + +.. + +.. date: 2026-07-14-15-00-00 +.. gh-issue: 127049 +.. nonce: pQw7Rk +.. section: Library + +Fix a race condition in :mod:`asyncio` on Unix where +:meth:`asyncio.subprocess.Process.send_signal`, +:meth:`~asyncio.subprocess.Process.terminate` or +:meth:`~asyncio.subprocess.Process.kill` could signal an unrelated process +that was recycled onto the PID of the already-reaped child when +ThreadedChildWatcher is used. Patch by Kumar Aditya. + +.. + +.. date: 2026-07-14-12-00-00 +.. gh-issue: 83273 +.. nonce: SnifQ7 +.. section: Library + +:meth:`csv.Sniffer.sniff` now deduces the dialect by trial parsing with the +actual CSV parser instead of heuristics based on matching isolated fragments +and on character frequencies. It can now detect the *escapechar* parameter, +accepts non-ASCII delimiters in the *delimiters* argument, no longer +misdetects the delimiter when the sample contains delimiter characters +inside quoted fields, handles samples truncated at an arbitrary point, and +no longer takes quadratic time on quoted samples. A sample consisting of a +single column of quoted fields now raises :exc:`csv.Error` instead of +guessing a delimiter from the content of the fields. + +.. + +.. date: 2026-07-13-10-27-08 +.. gh-issue: 153658 +.. nonce: A6o4n5 +.. section: Library + +Fix :meth:`sqlite3.Connection.iterdump` raising +:exc:`sqlite3.OperationalError` when a table name contains a single quote. +Patch by tonghuaroot. + +.. + +.. date: 2026-07-12-10-00-00 +.. gh-issue: 98078 +.. nonce: fA3lRt +.. section: Library + +Fix :mod:`asyncio` SSL transports not sending the fatal TLS alert to the +peer when the TLS handshake fails or when receiving corrupted data, and not +sending the ``close_notify`` alert to the peer when the TLS shutdown fails. +The peer can now tell why the connection was dropped (for example, +certificate verification failure or no TLS version in common) instead of +seeing the connection abruptly closed. + +.. + +.. date: 2026-07-12-00-00-00 +.. gh-issue: 85943 +.. nonce: 8f906e +.. section: Library + +Fix :mod:`struct` functions raising :exc:`BytesWarning` under the ``-bb`` +command line option when a :class:`str` format is used after an equal +:class:`bytes` format (or vice versa). The internal format cache no longer +mixes :class:`str` and :class:`bytes` keys. + +.. + +.. date: 2026-07-11-13-24-49 +.. gh-issue: 153603 +.. nonce: YbKlry +.. section: Library + +Fix a crash in the ISO-2022 decoders when decoding a byte after an unknown +charset designation is set via the decoder's ``setstate`` method. Patch by +tonghuaroot. + +.. + +.. date: 2026-07-11-12-21-12 +.. gh-issue: 153539 +.. nonce: gBs2T5 +.. section: Library + +Fix a crash in the C implementation of :meth:`io.TextIOWrapper.tell` when +the decoder's ``getstate`` method triggers a reentrant seek, or when another +thread seeks the same stream concurrently. Patch by tonghuaroot. + +.. + +.. date: 2026-07-10-18-30-00 +.. gh-issue: 153502 +.. nonce: uIdKw0 +.. section: Library + +:meth:`imaplib.IMAP4.copy`, :meth:`~imaplib.IMAP4.move`, +:meth:`~imaplib.IMAP4.fetch`, :meth:`~imaplib.IMAP4.store`, +:meth:`~imaplib.IMAP4.search`, :meth:`~imaplib.IMAP4.sort`, +:meth:`~imaplib.IMAP4.thread` and :meth:`~imaplib.IMAP4.expunge` now accept +a keyword-only *uid* argument that selects the corresponding ``UID`` +command, as a more convenient alternative to :meth:`~imaplib.IMAP4.uid`. + +.. + +.. date: 2026-07-10-16-00-00 +.. gh-issue: 153494 +.. nonce: qCh8rT +.. section: Library + +:meth:`imaplib.IMAP4.search`, :meth:`~imaplib.IMAP4.sort` and +:meth:`~imaplib.IMAP4.thread` (and the corresponding ``uid`` commands) now +encode :class:`str` search criteria to the declared *charset*, so +international search text can be passed as ordinary :class:`str`. When +*charset* is ``None`` (as it must be under ``UTF8=ACCEPT``), the criteria +are sent using the connection encoding instead. A criterion passed as +:class:`bytes` is sent unchanged, for use with a charset that Python has no +codec for. + +.. + +.. date: 2026-07-10-12-33-30 +.. gh-issue: 153513 +.. nonce: GxrPuY +.. section: Library + +Values of several Tcl object types returned by :mod:`tkinter` are now +converted to the corresponding Python type instead of being wrapped in a +:class:`!_tkinter.Tcl_Obj`: ``index``, ``window``, ``nsName`` and +``parsedVarName`` objects to :class:`str`, and ``pixel`` screen distances +with no unit suffix to :class:`int` or :class:`float`. + +.. + +.. date: 2026-07-09-16-35-47 +.. gh-issue: 153404 +.. nonce: daRkes +.. section: Library + +:class:`urllib.robotparser.RobotFileParser` now silently ignores a +``Crawl-delay`` or ``Request-rate`` value written with non-decimal digits +(such as ``U+00B2 SUPERSCRIPT TWO``) instead of raising :exc:`ValueError` +and aborting the parse of the whole ``robots.txt`` file. + +.. + +.. date: 2026-07-09-15-18-23 +.. gh-issue: 151292 +.. nonce: f4NQSW +.. section: Library + +Store the sample count in :mod:`profiling.sampling` binary format, as a +64-bit integer, widening from previously used 32-bit integer. This breaks +the existing recordings. Long or thread-heavy profiling sessions will no +longer fail because of :exc:`OverflowError`. Patch by Maurycy +Pawłowski-Wieroński. + +.. + +.. date: 2026-07-09-14-56-24 +.. gh-issue: 152754 +.. nonce: CyyC5j +.. section: Library + +Fix a crash when the same :func:`os.scandir` iterator is used concurrently +from multiple threads. It no longer releases the directory handle while +another thread is reading from it. Sharing an iterator between threads +remains subject to race conditions: which entries each thread receives is +unspecified. + +.. + +.. date: 2026-07-09-14-00-00 +.. gh-issue: 153417 +.. nonce: Bw7Rq2 +.. section: Library + +Error messages from :meth:`imaplib.IMAP4.select` and +:meth:`imaplib.IMAP4.uid` no longer raise :exc:`BytesWarning` under +:option:`!-bb` when the mailbox or command argument is :class:`bytes`. + +.. + +.. date: 2026-07-09-12-35-19 +.. gh-issue: 153422 +.. nonce: tKb0Xq +.. section: Library + +:meth:`!winfo_exists`, :meth:`!winfo_ismapped` and :meth:`!winfo_viewable` +methods of :mod:`tkinter` widgets and :meth:`!edit_modified` of +:class:`tkinter.Text` now return a :class:`bool` instead of an integer or, +depending on ``wantobjects``, a string. + +.. + +.. date: 2026-07-09-12-00-00 +.. gh-issue: 49555 +.. nonce: Ka9Lm2 +.. section: Library + +:mod:`imaplib` now encodes non-ASCII mailbox names as modified UTF-7 +(:rfc:`3501`, section 5.1.3) in the default mode, so international mailbox +names can be passed as ordinary :class:`str`; under ``UTF8=ACCEPT`` they are +sent as UTF-8 instead. A name that is not valid modified UTF-7, such as one +with a bare ``&``, is now encoded correctly instead of being sent as is. A +``str`` that is already valid modified UTF-7, or a :class:`bytes` object, is +sent unchanged. + +.. + +.. date: 2026-07-09-10-14-08 +.. gh-issue: 153395 +.. nonce: N8FuG3 +.. section: Library + +:mod:`curses.ascii` predicates and the :func:`~curses.ascii.ctrl` and +:func:`~curses.ascii.unctrl` functions now accept a +:class:`curses.complexchar`. :func:`~curses.ascii.ctrl` now returns a +non-ASCII argument unchanged instead of masking it to a control character. + +.. + +.. date: 2026-07-09-08-40-00 +.. gh-issue: 153290 +.. nonce: GTzSEa +.. section: Library + +Fix a data race on the free-threaded build when +:meth:`!io.BytesIO.__setstate__` installs the instance dictionary while +another thread concurrently calls a method on the same object. + +.. + +.. date: 2026-07-09-00-00-00 +.. gh-issue: 153406 +.. nonce: vyMmB6 +.. section: Library + +:func:`email.utils.parsedate_to_datetime` now raises :exc:`ValueError` +instead of :exc:`OverflowError` when the parsed year or timezone offset is +out of range, matching its documented behavior. + +.. + +.. date: 2026-07-08-23-20-00 +.. gh-issue: 152907 +.. nonce: oyPV9Y +.. section: Library + +Restore cooked-mode terminal output flags around :c:data:`PyOS_InputHook` +callbacks in the new :term:`REPL` (:mod:`!_pyrepl`), so that output written +by an input hook (for example a GUI toolkit event loop) is no longer emitted +with ``OPOST`` disabled and keeps its carriage returns. + +.. + +.. date: 2026-07-08-22-18-04 +.. gh-issue: 153364 +.. nonce: JBFHEg +.. section: Library + +Make frame, coroutine and task-waiter walks iterative and bounded, avoiding +potential hangs and stack overflows. Fix asyncio task inspection when +awaited-by sets contain removed entries. Patch by Maurycy +Pawłowski-Wieroński. + +.. + +.. date: 2026-07-08-21-15-00 +.. gh-issue: 153333 +.. nonce: Kp3mZq +.. section: Library + +The ``readprofile`` method of :class:`tkinter.Tk` now reads the user's +profile scripts using the encoding declared in the file, instead of the +locale encoding. + +.. + +.. date: 2026-07-08-19-40-00 +.. gh-issue: 153319 +.. nonce: Qk7bE2 +.. section: Library + +The :mod:`turtledemo` viewer now reads each demo script as UTF-8 instead of +the locale encoding. + +.. + +.. date: 2026-07-08-15-26-00 +.. gh-issue: 153296 +.. nonce: Twix12 +.. section: Library + +Fix a data race and use-after-free when iterating over an +:class:`io.StringIO` object while it is being concurrently mutated. The +``__next__`` method now properly acquires the object's lock. + +.. + +.. date: 2026-07-08-06-54-57 +.. gh-issue: 152936 +.. nonce: TaFl0J +.. section: Library + +:func:`os.chroot`, :func:`os.initgroups`, :func:`os.setegid`, +:func:`os.seteuid`, :func:`os.setgid`, :func:`os.setregid`, +:func:`os.setresgid`, :func:`os.setresuid`, :func:`os.setreuid`, +:func:`os.setuid`, and :func:`socket.sethostname` are now available on +Android. Calling them without sufficient privileges now raises +:exc:`PermissionError` instead of the functions being unavailable. + +.. + +.. date: 2026-07-08-01-47-15 +.. gh-issue: 153083 +.. nonce: XbKZCp +.. section: Library + +Defer GC tracking of an :class:`array.array` to the end of its construction. +Patch by Donghee Na. + +.. + +.. date: 2026-07-08-01-03-17 +.. gh-issue: 153292 +.. nonce: oHDt3l +.. section: Library + +Fix data race in repr of :class:`threading.RLock` in free-threading build. + +.. + +.. date: 2026-07-08-00-00-00 +.. gh-issue: 153291 +.. nonce: rdlnCS +.. section: Library + +Fix a data race in :func:`readline.get_completer` and +:func:`readline.get_pre_input_hook` on the :term:`free-threaded ` build: the getters read the stored hook without the critical +section that the corresponding setters hold. + +.. + +.. date: 2026-07-07-22-06-52 +.. gh-issue: 153293 +.. nonce: 0DvYdc +.. section: Library + +Fix the live sampling profiler TUI keeping stale aggregated opcode +statistics after a stats reset. + +.. + +.. date: 2026-07-07-17-50-54 +.. gh-issue: 143990 +.. nonce: FoNtCf +.. section: Library + +A :class:`tkinter.font.Font` created from a named font, including by +:meth:`~tkinter.font.Font.copy`, now copies its configured options rather +than the options resolved by Tcl's ``font actual``, preserving a size +specified in pixels (a negative size). + +.. + +.. date: 2026-07-07-13-31-52 +.. gh-issue: 148286 +.. nonce: -qu-em +.. section: Library + +Fix undefined behavior in +:attr:`compression.zstd.ZstdDecompressor.unused_data` when a complete frame +was decompressed in a single call. + +.. + +.. date: 2026-07-07-02-26-43 +.. gh-issue: 153210 +.. nonce: LUXIcm +.. section: Library + +Fix crash on :mod:`array` import under a memory pressure. + +.. + +.. date: 2026-07-06-14-30-00 +.. gh-issue: 153521 +.. nonce: iMaP47 +.. section: Library + +Add support for structured arguments in :mod:`imaplib` command methods. A +*message_set* and lists of flags or other atoms can now be passed as +sequences instead of preformatted strings, and the +:meth:`~imaplib.IMAP4.search`, :meth:`~imaplib.IMAP4.fetch`, +:meth:`~imaplib.IMAP4.sort`, :meth:`~imaplib.IMAP4.thread` and +:meth:`~imaplib.IMAP4.uid` methods accept a *params* keyword argument that +substitutes and quotes ``?`` placeholders. + +.. + +.. date: 2026-07-06-14-18-33 +.. gh-issue: 153256 +.. nonce: tkPrnt +.. section: Library + +Added the :meth:`!tk_print` method to :class:`tkinter.Canvas` and +:class:`tkinter.Text` which prints the contents of the widget using the +native print dialog. It requires Tk 8.7/9.0 or newer. + +.. + +.. date: 2026-07-06-14-05-40 +.. gh-issue: 153259 +.. nonce: sysTr1 +.. section: Library + +Added the :mod:`tkinter.systray` module which provides the +:class:`~tkinter.systray.SysTrayIcon` class as an interface to the system +tray icon and the :func:`~tkinter.systray.notify` function which sends a +desktop notification. They require Tk 8.7/9.0 or newer. + +.. + +.. date: 2026-07-06-13-42-17 +.. gh-issue: 72880 +.. nonce: fcXhWr +.. section: Library + +Added the :mod:`tkinter.fontchooser` module which provides the +:class:`~tkinter.fontchooser.FontChooser` class as an interface to the +native font selection dialog. + +.. + +.. date: 2026-07-06-12-00-00 +.. gh-issue: 153200 +.. nonce: isqrtLt +.. section: Library + +Fix :func:`math.isqrt` returning an incorrect result for arguments not less +than 2**64 that are instances of an :class:`int` subclass with an overridden +comparison operator. + +.. + +.. date: 2026-07-06-10-30-00 +.. gh-issue: 153158 +.. nonce: m0nthP +.. section: Library + +Remove the erroneous *width* argument of +:meth:`!calendar.HTMLCalendar.formatmonthpage`, which could drop the year +from the heading. + +.. + +.. date: 2026-07-05-22-30-00 +.. gh-issue: 66788 +.. nonce: tM7pQ2 +.. section: Library + +Add the ``utf-7-imap`` codec, implementing the modified UTF-7 encoding used +for international IMAP4 mailbox names (:rfc:`3501`, section 5.1.3). + +.. + +.. date: 2026-07-05-21-40-00 +.. gh-issue: 89869 +.. nonce: XG7aHz +.. section: Library + +Add :meth:`imaplib.IMAP4.login_plain`, which authenticates using the +``PLAIN`` SASL mechanism (:rfc:`4616`). Unlike +:meth:`~imaplib.IMAP4.login`, it supports non-ASCII user names and +passwords. + +.. + +.. date: 2026-07-05-20-15-00 +.. gh-issue: 98092 +.. nonce: iDcmd1 +.. section: Library + +Add :meth:`imaplib.IMAP4.id`, a wrapper for the IMAP ``ID`` command +(:rfc:`2971`). + +.. + +.. date: 2026-07-05-17-39-16 +.. gh-issue: 153133 +.. nonce: kKSH7g +.. section: Library + +Fix a socket leak in :meth:`asyncio.loop.create_connection` when the +transport cannot be created. + +.. + +.. date: 2026-07-05-16-09-31 +.. gh-issue: 153068 +.. nonce: huY9Jh +.. section: Library + +Fix :meth:`!cProfile.Profile.enable` to no longer overwrite errors from +:mod:`sys.monitoring`. + +.. + +.. date: 2026-07-05-14-30-00 +.. gh-issue: 153062 +.. nonce: teeFT1 +.. section: Library + +Fix a crash when concurrently iterating an :func:`itertools.tee` iterator on +the free-threaded build. + +.. + +.. date: 2026-07-05-12-00-00 +.. gh-issue: 153056 +.. nonce: tMpLat +.. section: Library + +Fix :class:`string.Template` raising a spurious :exc:`ValueError` when the +*pattern* attribute is a compiled regular expression object, which the +documentation allows. On the free-threaded build this also occurred as a +data race on the first concurrent use. + +.. + +.. date: 2026-07-05-11-36-51 +.. gh-issue: 59396 +.. nonce: Apl7sI +.. section: Library + +:class:`tkinter.scrolledtext.ScrolledText` gained a *use_ttk* parameter to +use the themed :mod:`tkinter.ttk` frame and scroll bar instead of the +classic :mod:`tkinter` widgets. + +.. + +.. date: 2026-07-05-10-24-30 +.. gh-issue: 143921 +.. nonce: wQx3Tn +.. section: Library + +Narrow the control character check in :mod:`imaplib` commands: only NUL, CR +and LF are now rejected. Other control characters are valid in quoted +strings and can occur in mailbox names returned by the server, so they are +now accepted and sent quoted. + +.. + +.. date: 2026-07-04-20-28-51 +.. gh-issue: 153037 +.. nonce: XUSp_g +.. section: Library + +Fix :class:`~compression.zstd.ZstdFile` raising :exc:`AttributeError` +instead of :exc:`io.UnsupportedOperation` when iterating over a file that is +not open for reading. + +.. + +.. date: 2026-07-04-13-00-00 +.. gh-issue: 135661 +.. nonce: CIkADG +.. section: Library + +Fix :class:`html.parser.HTMLParser`: an abruptly closed empty comment +(```` or ````) no longer extends up to a later ``-->`` in the +same :meth:`~html.parser.HTMLParser.feed` call. + +.. + +.. date: 2026-07-04-11-26-24 +.. gh-issue: 153009 +.. nonce: KGl-nQ +.. section: Library + +Fix compilation of :mod:`curses` on platforms that define the ``stdscr`` +macro. Patch by Bénédikt Tran. + +.. + +.. date: 2026-07-04-11-14-06 +.. gh-issue: 152851 +.. nonce: diYvTf +.. section: Library + +Prevent a crash when allocation fails while copying a :func:`BLAKE-2s/2b +` object. Patch by Bénédikt Tran. + +.. + +.. date: 2026-07-04-00-19-23 +.. gh-issue: 127636 +.. nonce: o_uD9U +.. section: Library + +Fix :meth:`tarfile.TarFile.extract` to accept archive member names with a +trailing forward slash, including those returned by +:meth:`tarfile.TarFile.getnames`. Contributed by Xiao Yuan. + +.. + +.. date: 2026-07-03-21-10-00 +.. gh-issue: 54930 +.. nonce: hq09Er +.. section: Library + +Error responses of :class:`http.server.BaseHTTPRequestHandler` to malformed +request lines now include a status line and headers instead of being sent in +the bare HTTP/0.9 style. Only a valid HTTP/0.9 request (a two-word ``GET`` +request line) now receives an HTTP/0.9 style response. + +.. + +.. date: 2026-07-03-19-51-47 +.. gh-issue: 152997 +.. nonce: i1ErzB +.. section: Library + +On platforms providing the C library's :manpage:`iconv(3)` function, the +:mod:`codecs` module now exposes every encoding known to ``iconv`` for which +Python has no built-in codec. Such an encoding can be used by its name (for +example ``"cp1133"``) or, to force the ``iconv``-based engine even when a +built-in codec exists, with an ``"iconv:"`` prefix (for example +``"iconv:latin1"``). + +.. + +.. date: 2026-07-03-18-30-00 +.. gh-issue: 119592 +.. nonce: mQr3Vx +.. section: Library + +Fix :class:`concurrent.futures.ProcessPoolExecutor` stranding submitted work +forever when a worker process exited upon reaching its *max_tasks_per_child* +limit after :meth:`~concurrent.futures.Executor.shutdown` was called with +``wait=False``: a replacement worker is now spawned and the remaining work +executed as documented. If the executor has instead been garbage collected +without ``shutdown()`` (:gh:`152967`), or a replacement worker cannot be +started, the remaining futures now fail with +:exc:`~concurrent.futures.process.BrokenProcessPool` instead of never +resolving. A worker exit racing ``shutdown(wait=False)`` can also no longer +crash the executor management thread. + +.. + +.. date: 2026-07-03-17-29-34 +.. gh-issue: 150579 +.. nonce: 0tLpQukIU +.. section: Library + +:mod:`concurrent.futures` now uses lazy imports for its executor submodules +instead of a module ``__getattr__`` hook. + +.. + +.. date: 2026-07-03-14-54-33 +.. gh-issue: 152951 +.. nonce: u8tPCI +.. section: Library + +:class:`collections.deque` prevent rare crash when calling ``extend`` under +high memory pressure conditions. + +.. + +.. date: 2026-07-03-02-11-00 +.. gh-issue: 152912 +.. nonce: Mv3KpR +.. section: Library + +``sys.addaudithook()`` now correctly suppresses only :exc:`RuntimeError` +instead of all :exc:`Exception` subclasses when an existing audit hook +raises during hook registration. Patch by Yeongu Kim. + +.. + +.. date: 2026-07-02-22-19-53 +.. gh-issue: 150880 +.. nonce: vPZ7jK +.. section: Library + +Normalize non-extended Windows paths before appending the wildcard used by +``os.listdir()`` and ``os.scandir()``, making paths with trailing spaces +behave consistently with other filesystem APIs. + +.. + +.. date: 2026-07-02-19-21-15 +.. gh-issue: 152068 +.. nonce: ThsmJU +.. section: Library + +Fixes a bug when a line was split (particularly on macOS Terminal.app) in +the middle of a colorized keyword, causing the ANSI Color Reset sequence +(ESC0m) to not be properly printed, causing the output to be colored when it +shouldn't + +.. + +.. date: 2026-07-02-15-26-51 +.. gh-issue: 151292 +.. nonce: nmnQlp +.. section: Library + +Fix ``profiling.sampling --binary`` leaving unreadable profile files when +the binary format reaches a size limit. Preserve collected samples when the +writer can still finalize safely. Patch by Maurycy Pawłowski-Wieroński. + +.. + +.. date: 2026-07-02-13-30-00 +.. gh-issue: 152849 +.. nonce: K9dRvP +.. section: Library + +Out-of-range float and integer timestamps now raise :exc:`OverflowError` +with the same message. Patch by tonghuaroot. + +.. + +.. date: 2026-07-02-12-00-00 +.. gh-issue: 152847 +.. nonce: PitKqc +.. section: Library + +Reject a POSIX TZ transition rule with non-digit characters in the +day-of-year field in the pure-Python :mod:`zoneinfo` parser. Patch by +tonghuaroot. + +.. + +.. date: 2026-07-01-23-17-27 +.. gh-issue: 152905 +.. nonce: wLnGqR +.. section: Library + +On glibc, :func:`locale.nl_langinfo` now decodes the ``LC_TIME`` items (such +as the month and day names) using the wide locale data, so the result no +longer depends on the ``LC_CTYPE`` encoding. + +.. + +.. date: 2026-07-01-22-59-25 +.. gh-issue: 152586 +.. nonce: WuEae6 +.. section: Library + +:class:`!tempfile._TemporaryFileWrapper` has been renamed to the public +:class:`tempfile.TemporaryFileWrapper`. The old private name is kept as a +deprecated alias and will be removed in Python 3.21. + +.. + +.. date: 2026-07-01-18-00-00 +.. gh-issue: 152721 +.. nonce: rlequad +.. section: Library + +Fix quadratic replay time in the :mod:`profiling.sampling` binary reader +when a profile's run-length-encoded samples alternate thread status. + +.. + +.. date: 2026-07-01-15-30-00 +.. gh-issue: 77508 +.. nonce: Bn2kXt +.. section: Library + +Add :meth:`imaplib.IMAP4.move`, a wrapper for the IMAP ``MOVE`` command +(:rfc:`6851`), analogous to :meth:`~imaplib.IMAP4.copy`. + +.. + +.. date: 2026-07-01-14-00-00 +.. gh-issue: 49680 +.. nonce: Lm5rQv +.. section: Library + +Add the *translate_line_endings* parameter to :meth:`imaplib.IMAP4.append`. +By default line endings in the message are translated to CRLF, as before; +passing ``False`` sends the message literal exactly as given, preserving +bare CR or LF octets. + +.. + +.. date: 2026-07-01-12-00-00 +.. gh-issue: 152718 +.. nonce: pr0f1l +.. section: Library + +Fix unbounded memory allocation in the :mod:`profiling.sampling` binary +profile reader when a file declares more string or frame entries than it +contains. + +.. + +.. date: 2026-07-01-12-00-00 +.. gh-issue: 108280 +.. nonce: Nq8vTr +.. section: Library + +Connecting :mod:`imaplib` to a server that does not send a valid IMAP4 +greeting (for example a POP3 server answering on the IMAP port) now raises +an error reporting the server's response instead of ``imaplib.IMAP4.error: +None``. + +.. + +.. date: 2026-07-01-11-29-13 +.. gh-issue: 151126 +.. nonce: eElGy5 +.. section: Library + +Fix a crash caused by failing to set :exc:`MemoryError` on allocation +failure when passing :class:`ctypes.Structure` or :class:`ctypes.Union` +instances by value to ctypes foreign functions. + +.. + +.. date: 2026-07-01-10-30-00 +.. gh-issue: 63121 +.. nonce: Rm4tZp +.. section: Library + +:mod:`imaplib` now refreshes the cached capability list after a successful +:meth:`~imaplib.IMAP4.login` or :meth:`~imaplib.IMAP4.authenticate`, using +the ``CAPABILITY`` response sent by the server or, if none was sent, by +querying it, so that capabilities that become available only after +authentication (such as ``ENABLE`` on Gmail) are recognized. Capabilities +advertised in the server greeting are now also used, avoiding a redundant +``CAPABILITY`` command. + +.. + +.. date: 2026-07-01-10-00-00 +.. gh-issue: 88574 +.. nonce: Kz3wQm +.. section: Library + +:mod:`imaplib` no longer fails when a server sends a spurious blank line +after the counted data of a literal, including after a literal that +terminates a response (such as a mailbox name returned by ``LIST``). Such +blank lines are now skipped without swallowing the following line. + +.. + +.. date: 2026-06-30-15-00-00 +.. gh-issue: 152692 +.. nonce: tr3pr0 +.. section: Library + +Fix :func:`annotationlib.type_repr` returning a string such as +``None.list.append`` for bound built-in methods, whose ``__module__`` is +``None``. It now returns the qualified name, as it already did for other +builtins. + +.. + +.. date: 2026-06-30-14-30-00 +.. gh-issue: 152502 +.. nonce: Mq7Kx2 +.. section: Library + +Detect the :mod:`curses` mouse interface (:func:`~curses.getmouse`, +:func:`~curses.has_mouse`, the ``BUTTON*`` constants, and others) and the +window ``is_*`` state-query methods with configure capability probes or +library macros instead of gating them on ncurses-specific macros. They are +now also available with other curses implementations that provide them, such +as NetBSD curses and PDCurses (the latter underpins ``windows-curses``). + +.. + +.. date: 2026-06-30-13-00-00 +.. gh-issue: 151842 +.. nonce: OOM31g +.. section: Library + +Fix a crash in :func:`!_interpreters.capture_exception` when +:exc:`MemoryError` happens. Patch by Amrutha Modela. + +.. + +.. date: 2026-06-30-12-00-00 +.. gh-issue: 40038 +.. nonce: qK7mGv +.. section: Library + +:mod:`imaplib` now again quotes command arguments when necessary, for +example mailbox names containing a space. Such quoting was inadvertently +disabled when the module was ported to Python 3, and the arguments are now +quoted according to the :rfc:`3501` grammar. For backward compatibility, an +argument already enclosed in double quotes is left unchanged, so code that +quotes arguments itself keeps working. + +.. + +.. date: 2026-06-29-22-16-57 +.. gh-issue: 50966 +.. nonce: Tq5mLp +.. section: Library + +Fix unbounded recursion in :mod:`turtle` when a mouse event handler that +moves the turtle is reentered while the screen is being redrawn, for example +with ``screen.ondrag(turtle.goto)``. This could previously crash the +interpreter. + +.. + +.. date: 2026-06-29-21-59-08 +.. gh-issue: 152638 +.. nonce: 92dpzo +.. section: Library + +Deprecate :func:`tkinter.filedialog.askopenfiles`. Opening several files at +once is error-prone and the returned list cannot be used in a +:keyword:`with` statement; iterate over the names returned by +:func:`tkinter.filedialog.askopenfilenames` and open them one by one +instead. + +.. + +.. date: 2026-06-29-12-50-28 +.. gh-issue: 152587 +.. nonce: Lq8wVn +.. section: Library + +In :mod:`tkinter`, the *name* parameter of the +:meth:`~tkinter.Misc.wait_variable`, :meth:`~tkinter.Misc.setvar` and +:meth:`~tkinter.Misc.getvar` methods and the *value* parameter of +:meth:`!setvar` are now required. Their former default values (``'PY_VAR'`` +and ``'1'``) were not meaningful. + +.. + +.. date: 2026-06-29-09-45-00 +.. gh-issue: 152569 +.. nonce: Kf7Lq2 +.. section: Library + +Fix :func:`asyncio.wait` leaking waiting tasks via the await-graph when +racing a future that never resolves. The waiting task is now discarded from +every future's ``awaited_by`` set once :func:`~asyncio.wait` returns, even +for pending futures. + +.. + +.. date: 2026-06-29-01-08-53 +.. gh-issue: 110357 +.. nonce: QGWdZQ +.. section: Library + +Importing :mod:`hashlib` no longer logs an error to stderr when a normally +guaranteed hash algorithm is unavailable in the current runtime (for example +under an OpenSSL FIPS configuration or a build using +:option:`--without-builtin-hashlib-hashes <--with-builtin-hashlib-hashes>`). +Code that actually uses the missing algorithm still gets a clear +:exc:`ValueError`. + +.. + +.. date: 2026-06-28-16-20-07 +.. gh-issue: 152503 +.. nonce: N55ose +.. section: Library + +Fix :meth:`curses.window.in_wch`, :meth:`curses.window.in_wchstr` and +:meth:`curses.window.getbkgrnd` returning garbage text when :mod:`curses` is +built against a curses library that does not NUL-terminate the ``cchar_t`` +text array (such as NetBSD curses). + +.. + +.. date: 2026-06-28-12-45-09 +.. gh-issue: 152356 +.. nonce: Dr4w2Q +.. section: Library + +Fix a hang in ``profiling.sampling run --blocking`` on Windows when the +target process exits. The profiler now finalizes binary profiles instead of +continuing to sample the exited process. + +.. + +.. date: 2026-06-28-12-00-00 +.. gh-issue: 152470 +.. nonce: Wn7Kp3 +.. section: Library + +The wide-character :mod:`curses` functions and methods +:meth:`curses.window.get_wch`, :meth:`curses.window.get_wstr`, +:func:`curses.unget_wch`, :func:`curses.erasewchar`, +:func:`curses.killwchar` and :func:`curses.wunctrl` now also work when +Python is not built against a wide-character-aware curses library, on an +8-bit locale, where each character is a single byte in the relevant +encoding. :func:`curses.ungetch` now also accepts a one-character string, +like :func:`curses.unget_wch`; on a wide-character build it can be any +character (previously a multibyte character raised :exc:`OverflowError`). + +.. + +.. date: 2026-06-28-11-00-40 +.. gh-issue: 78335 +.. nonce: Kp3mWq +.. section: Library + +Update the docstrings of :mod:`tkinter` and :mod:`tkinter.ttk` widget +classes to list all supported widget options, including options added in Tk +9.0 and 9.1. ``tkinter.Menubutton`` and ``tkinter.Message`` previously had +no option list at all. + +.. + +.. date: 2026-06-28-00-00-00 +.. gh-issue: 152431 +.. nonce: Ja3K9m +.. section: Library + +Fix ``asyncio.StreamWriter.start_tls()`` to keep the linked ``StreamReader`` +transport in sync with the upgraded transport. + +.. + +.. date: 2026-06-27-19-02-17 +.. gh-issue: 103878 +.. nonce: 216fa7 +.. section: Library + +The :mod:`tkinter.filedialog` functions that return a filename +(:func:`~tkinter.filedialog.askopenfilename`, +:func:`~tkinter.filedialog.asksaveasfilename` and +:func:`~tkinter.filedialog.askdirectory`) now consistently return an empty +string when the dialog is cancelled, instead of an empty tuple or ``b''`` on +some platforms. :func:`~tkinter.filedialog.askopenfilenames` likewise +always returns an empty tuple, and :func:`~tkinter.filedialog.askopenfiles` +an empty list. + +.. + +.. date: 2026-06-27-17-19-09 +.. gh-issue: 151126 +.. nonce: huUyOM +.. section: Library + +Fix two crashes in :mod:`tkinter` and :mod:`socket` modules initialization +under a memory pressure. Sets missing :exc:`MemoryError`. + +.. + +.. date: 2026-06-27-12-45-00 +.. gh-issue: 133031 +.. nonce: Wide00 +.. section: Library + +:class:`curses.textpad.Textbox` now supports entering and reading back the +full Unicode range, including combining characters, when curses is built +with wide-character support. + +.. + +.. date: 2026-06-27-12-30-00 +.. gh-issue: 133031 +.. nonce: Na8Bit +.. section: Library + +:class:`curses.textpad.Textbox` now enters and reads back the non-ASCII +characters of an 8-bit locale encoding, instead of mangling them with a +7-bit mask. + +.. + +.. date: 2026-06-27-12-00-00 +.. gh-issue: 43699 +.. nonce: Zt46MI +.. section: Library + +The drag cursor in :mod:`tkinter.dnd` is now changed only once the pointer +starts moving rather than on the initial button press, so that a plain click +no longer flashes it. + +.. + +.. date: 2026-06-27-11-32-37 +.. gh-issue: 50409 +.. nonce: Pw3Kq9 +.. section: Library + +Deprecate the *tagOrId* parameter of +:meth:`!tkinter.PanedWindow.paneconfigure` (and its :meth:`!paneconfig` +alias) in favor of *child*, for consistency with the other pane methods; it +will be removed in Python 3.18. + +.. + +.. date: 2026-06-27-10-30-00 +.. gh-issue: 152409 +.. nonce: Tr8cE2 +.. section: Library + +Fix the :mod:`trace` command-line tool not saving the ``--file`` counts when +``--no-report`` is used, which prevented accumulating counts over several +runs. Patch by tonghuaroot. + +.. + +.. date: 2026-06-26-23-56-40 +.. gh-issue: 71880 +.. nonce: 782D31 +.. section: Library + +:class:`curses.textpad.Textbox` now lets the lower-right cell of the window +be edited. Writing it with :meth:`~curses.window.addch` would move the +cursor past the end of the window, raising an error and scrolling a +scrollable window, so it is now written with :meth:`~curses.window.insch`, +which keeps the cursor in place. + +.. + +.. date: 2026-06-26-22-50-00 +.. gh-issue: 152334 +.. nonce: Mt7vQx +.. section: Library + +Add the :func:`curses.define_key`, :func:`curses.key_defined` and +:func:`curses.keyok` key-management functions. + +.. + +.. date: 2026-06-26-22-15-00 +.. gh-issue: 152332 +.. nonce: Lp3WqN +.. section: Library + +Add the :func:`curses.term_attrs` function, the counterpart of +:func:`curses.termattrs` for the ``WA_*`` attributes. + +.. + +.. date: 2026-06-26-22-06-07 +.. gh-issue: 87904 +.. nonce: F71C70 +.. section: Library + +The :mod:`curses` types and exceptions now report their public module in +:attr:`~type.__module__`, :func:`repr` and :func:`help` -- for example +``curses.window`` instead of ``_curses.window`` and ``curses.panel.error`` +instead of ``_curses_panel.error``. + +.. + +.. date: 2026-06-26-21-30-00 +.. gh-issue: 152325 +.. nonce: Km9xQr +.. section: Library + +Add the :func:`curses.has_mouse` function and the +:meth:`curses.window.mouse_trafo` method. + +.. + +.. date: 2026-06-26-19-01-13 +.. gh-issue: 121249 +.. nonce: p1SBW0 +.. section: Library + +Deprecate using ``'F'`` and ``'D'`` type codes in the :mod:`struct` module. + +.. + +.. date: 2026-06-26-17-18-01 +.. gh-issue: 152275 +.. nonce: V64zKa +.. section: Library + +The :mod:`curses` module now raises :exc:`OverflowError` instead of silently +truncating an out-of-range value: :func:`curses.color_pair` rejects a color +pair number that does not fit in the ``chtype`` color field, and the +``attr`` argument of the character-cell and attribute methods +(:meth:`~curses.window.addch`, :meth:`~curses.window.addstr`, +:meth:`~curses.window.attron`, :meth:`~curses.window.attrset` and others) is +checked against the ``chtype`` range. + +.. + +.. date: 2026-06-26-16-30-00 +.. gh-issue: 83274 +.. nonce: Kx9mQv +.. section: Library + +Deallocating a :mod:`tkinter` application from a thread other than the one +it was created in no longer crashes the interpreter. The underlying Tcl +interpreter is leaked instead, and a :exc:`RuntimeWarning` is reported. + +.. + +.. date: 2026-06-26-16-15-55 +.. gh-issue: 81954 +.. nonce: MfUjgS +.. section: Library + +Deleting a writable, open :class:`zipfile.ZipFile` now emits a +:exc:`ResourceWarning`. Use as a :term:`context manager` or call +:meth:`~zipfile.ZipFile.close` explicitly. + +.. + +.. date: 2026-06-26-15-41-34 +.. gh-issue: 152305 +.. nonce: WnbbBc +.. section: Library + +Fix the pure-Python :meth:`datetime.time.strftime` implementation raising +:exc:`AttributeError` for the year directives. Patch by tonghuaroot. + +.. + +.. date: 2026-06-26-15-30-00 +.. gh-issue: 88758 +.. nonce: Qw7nLp +.. section: Library + +:meth:`!tkinter.Misc.focus_get`, :meth:`!focus_displayof`, +:meth:`!focus_lastfor` and :meth:`!winfo_containing` now return ``None`` +instead of raising :exc:`KeyError` when the widget was not created by +:mod:`tkinter` (for example a torn-off menu). + +.. + +.. date: 2026-06-26-15-10-00 +.. gh-issue: 152260 +.. nonce: Rk4nP9 +.. section: Library + +Add the :mod:`curses` functions :func:`~curses.scr_dump`, +:func:`~curses.scr_restore`, :func:`~curses.scr_init` and +:func:`~curses.scr_set`, which dump the whole screen to a file and restore +it. + +.. + +.. date: 2026-06-26-15-00-00 +.. gh-issue: 38464 +.. nonce: yDPjKH +.. section: Library + +:meth:`!tkinter.Misc.nametowidget` now resolves the auto-generated names of +cloned menus (a menu used as a menubar or a cascade) back to the original +widget. + +.. + +.. date: 2026-06-26-14-34-28 +.. gh-issue: 152263 +.. nonce: 5PHQP4 +.. section: Library + +Add the soft-label-key functions to the :mod:`curses` module: +:func:`~curses.slk_init`, :func:`~curses.slk_set`, +:func:`~curses.slk_label`, :func:`~curses.slk_refresh`, +:func:`~curses.slk_noutrefresh`, :func:`~curses.slk_clear`, +:func:`~curses.slk_restore`, :func:`~curses.slk_touch`, +:func:`~curses.slk_attron`, :func:`~curses.slk_attroff`, +:func:`~curses.slk_attrset`, :func:`~curses.slk_attr`, +:func:`~curses.slk_attr_on`, :func:`~curses.slk_attr_off`, +:func:`~curses.slk_attr_set` and :func:`~curses.slk_color`. + +.. + +.. date: 2026-06-26-14-05-00 +.. gh-issue: 116946 +.. nonce: Kp7raZ +.. section: Library + +The internal :mod:`!_tkinter` ``tkapp`` and ``tktimertoken`` types now +implement the garbage collector protocol, so reference cycles involving a +Tcl interpreter or a timer handler can be collected. + +.. + +.. date: 2026-06-26-13-40-00 +.. gh-issue: 152258 +.. nonce: Qe7Lm3 +.. section: Library + +Add the :mod:`curses` window method :meth:`~curses.window.dupwin`, which +returns a new window that is an independent duplicate of an existing one. + +.. + +.. date: 2026-06-26-13-39-11 +.. gh-issue: 152248 +.. nonce: N2Rmaf +.. section: Library + +Make the C and pure-Python :mod:`zoneinfo` parsers validate POSIX TZ +abbreviations consistently, rejecting unquoted abbreviations with non-letter +characters and empty quoted abbreviations. Patch by tonghuaroot. + +.. + +.. date: 2026-06-26-13-10-00 +.. gh-issue: 80937 +.. nonce: Hq3mNp +.. section: Library + +Fix a memory leak in :mod:`tkinter` when a Tcl command created with +``createcommand`` was not explicitly removed before the interpreter was +deleted. The command no longer keeps the interpreter alive through a +reference cycle. + +.. + +.. date: 2026-06-26-13-00-46 +.. gh-issue: 111330 +.. nonce: DBcCXA +.. section: Library + +Update pure-Python :class:`io.BytesIO` to close cleanly when the data has an +export such as a :class:`memoryview`. + +.. + +.. date: 2026-06-26-12-50-26 +.. gh-issue: 152246 +.. nonce: MfXMd1 +.. section: Library + +Fix the pure-Python :mod:`zoneinfo` parser accepting an invalid POSIX TZ +transition rule with a non-period separator. Patch by tonghuaroot. + +.. + +.. date: 2026-06-26-11-20-00 +.. gh-issue: 152233 +.. nonce: Kp7mQ2 +.. section: Library + +Add the :class:`curses.complexstr` type, an immutable string of styled +character cells (the counterpart of :class:`curses.complexchar`), and the +:mod:`curses` window method :meth:`~curses.window.in_wchstr` that returns +one. The string-cell methods :meth:`~curses.window.addstr`, +:meth:`~curses.window.addnstr`, :meth:`~curses.window.insstr` and +:meth:`~curses.window.insnstr` now also accept a +:class:`~curses.complexstr`. Like :class:`curses.complexchar`, it works +whether or not Python was built against a wide-character-aware curses +library. + +.. + +.. date: 2026-06-25-22-41-49 +.. gh-issue: 152233 +.. nonce: pEhm3q +.. section: Library + +Add the :class:`curses.complexchar` type, representing a styled character +cell (text, attributes and color pair), and the :mod:`curses` window methods +:meth:`~curses.window.in_wch` and :meth:`~curses.window.getbkgrnd` that +return one. The character-cell methods (:meth:`~curses.window.addch`, +:meth:`~curses.window.bkgd`, :meth:`~curses.window.border`, +:meth:`~curses.window.hline` and others) now also accept a +:class:`~curses.complexchar`. This works whether or not Python was built +against a wide-character-aware curses library; on a narrow build a cell +holds a single character representable as one byte in the window's encoding. + +.. + +.. date: 2026-06-25-22-19-04 +.. gh-issue: 152099 +.. nonce: L7fKq9 +.. section: Library + +``asyncio``'s ``loop.sendfile(..., fallback=False)`` now consistently raises +:exc:`asyncio.SendfileNotAvailableError` for fallback-only transports, such +as SSL/TLS transports, when native sendfile cannot be used. Previously, this +case raised :exc:`RuntimeError`. + +.. + +.. date: 2026-06-25-20-00-00 +.. gh-issue: 151496 +.. nonce: kMnT3x +.. section: Library + +Fixed ``profiling.sampling --gecko`` with ``--async-aware`` by flattening +async task stacks before generating Gecko samples. ``--binary`` now rejects +``--async-aware`` until the binary format supports async task data. + +.. + +.. date: 2026-06-25-19-44-16 +.. gh-issue: 152219 +.. nonce: ndj4Ib +.. section: Library + +Add the :mod:`curses` window methods :meth:`~curses.window.attr_get`, +:meth:`~curses.window.attr_set`, :meth:`~curses.window.attr_on`, +:meth:`~curses.window.attr_off` and :meth:`~curses.window.color_set`, which +use a separate color pair argument instead of packing it into the attribute +value, and the corresponding ``WA_*`` attribute constants. + +.. + +.. date: 2026-06-25-14-32-43 +.. gh-issue: 139816 +.. nonce: Lq2vXa +.. section: Library + +Fix a hang in :mod:`tkinter` on interactive Python built without +:mod:`readline`. An exception raised in a callback no longer causes the +event loop to stop and wait for the user to press Enter; pending callbacks +now keep running until input is actually available on stdin. + +.. + +.. date: 2026-06-25-14-32-42 +.. gh-issue: 139145 +.. nonce: kT9rmP +.. section: Library + +Fix a busy loop in :mod:`tkinter` on interactive Python. When a Tcl command +running its own event loop (such as ``vwait`` or :meth:`!wait_variable`) was +active and input arrived on stdin, the event loop kept spinning at 100% CPU. +The stdin file handler is now removed as soon as input is available. Based +on a patch by Michiel de Hoon. + +.. + +.. date: 2026-06-25-14-05-00 +.. gh-issue: 152204 +.. nonce: k9Qm3v +.. section: Library + +Fix the pure-Python implementations of :meth:`datetime.date.fromisoformat`, +:meth:`datetime.time.fromisoformat` and +:meth:`datetime.datetime.fromisoformat` silently accepting some malformed +ISO 8601 strings, such as non-ASCII digits or a sign in a fixed-width field +(for example ``'2020+12'`` or ``'20201212T0102٣٤'``). Each field is now +required to be exactly *N* ASCII digits, matching the C implementation. + +.. + +.. date: 2026-06-25-12-00-00 +.. gh-issue: 152212 +.. nonce: Zk7Qm2 +.. section: Library + +Fix the pure-Python :mod:`zoneinfo` parser accepting a POSIX TZ string with +a ``std`` abbreviation but no offset. This is invalid per POSIX and now +raises :exc:`ValueError`, matching the C accelerator. Patch by tonghuaroot. + +.. + +.. date: 2026-06-25-10-07-54 +.. gh-issue: 152156 +.. nonce: gscPU9 +.. section: Library + +Fix a possible crash in :func:`concurrent.interpreters.create` under limited +memory conditions. + +.. + +.. date: 2026-06-25-07-08-17 +.. gh-issue: 152157 +.. nonce: dt5Ef0 +.. section: Library + +The C implementations of :meth:`~datetime.datetime.fromisoformat` and +:meth:`~datetime.time.fromisoformat` now reject a decimal separator that is +not followed by any fractional digit before a timezone designator. + +.. + +.. date: 2026-06-25-01-00-43 +.. gh-issue: 151763 +.. nonce: wWeHBe +.. section: Library + +Fix crash in :func:`!_interpqueues.create` whe :exc:`MemoryError` happens on +queue creation. + +.. + +.. date: 2026-06-24-23-28-42 +.. gh-issue: 151669 +.. nonce: tPUavQ +.. section: Library + +On Windows, when populating tar archives from filesystem content, to conform +to the tar format standard, backslashes in symlink targets are be replaced +by slashes. + +.. + +.. date: 2026-06-24-22-16-35 +.. gh-issue: 105895 +.. nonce: hRkuEw +.. section: Library + +Add :keyword:`match` and :keyword:`case` to the list of supported topics by +:func:`help`. + +.. + +.. date: 2026-06-24-16-40-15 +.. gh-issue: 151378 +.. nonce: iYWa_6 +.. section: Library + +Fix a bug in the binary collector in Tachyon that caused unbounded memory +growth while profiling a thread that stayed asleep. Patch by Maurycy +Pawłowski-Wieroński. + +.. + +.. date: 2026-06-24-16-08-44 +.. gh-issue: 152074 +.. nonce: PsbS-I +.. section: Library + +Increase the buffer size to 256 KiB in :meth:`asyncio.loop.sendfile` method +fallback. + +.. + +.. date: 2026-06-24-12-00-00 +.. gh-issue: 152100 +.. nonce: Set0ps +.. section: Library + +Support set operations and nested sets in regular expression character +classes, as described in Unicode Technical Standard #18: set difference +(``[A--B]``), intersection (``[A&&B]``) and union (``[A||B]``). + +.. + +.. date: 2026-06-24-12-00-00 +.. gh-issue: 152079 +.. nonce: f1tzus +.. section: Library + +Fix :meth:`datetime.datetime.fromisoformat` in the C implementation dropping +the sub-second part of a UTC offset whose whole-second part is zero, +matching the pure-Python implementation. + +.. + +.. date: 2026-06-24-12-00-00 +.. gh-issue: 152052 +.. nonce: yBssDE +.. section: Library + +The :mod:`json` C accelerator now correctly reports an unterminated string +for a ``\uXXXX`` escape at the end of the input. + +.. + +.. date: 2026-06-24-10-46-35 +.. gh-issue: 152060 +.. nonce: f2asrt +.. section: Library + +Fix :meth:`datetime.datetime.fromisoformat` raising :exc:`AssertionError` +instead of :exc:`ValueError` for some malformed strings in the pure-Python +implementation, matching the C implementation. + +.. + +.. date: 2026-06-24-10-30-00 +.. gh-issue: 152056 +.. nonce: Qk7mZ2 +.. section: Library + +Optimize matching of a character set that contains a single character +category, such as ``[\d]`` or ``[^\s]``: it is now compiled to a single +``CATEGORY`` opcode, the same as the corresponding ``\d`` or ``\S`` escape, +instead of being wrapped in an ``IN`` block. This speeds up matching and +reduces the size of the compiled byte code. Patch by Pieter Eendebak. + +.. + +.. date: 2026-06-23-22-15-00 +.. gh-issue: 152033 +.. nonce: Ct1Egy +.. section: Library + +Optimize matching of character class escapes (``\d``, ``\D``, ``\s``, +``\S``, ``\w`` and ``\W``) that occur outside a character set: they are now +compiled to a single ``CATEGORY`` opcode instead of being wrapped in an +``IN`` block. This speeds up patterns such as ``\d+`` and reduces the size +of the compiled byte code. + +.. + +.. date: 2026-06-23-18-42-37 +.. gh-issue: 143990 +.. nonce: o65v7O +.. section: Library + +:class:`tkinter.font.Font` can now wrap a font description without creating +a new named font, by passing it as *font* with ``exists=True`` and no +*name*. This avoids a loss of precision in +:meth:`~tkinter.font.Font.actual`, :meth:`~tkinter.font.Font.measure` and +:meth:`~tkinter.font.Font.metrics`. Keyword options now override the +corresponding settings of the given *font* instead of being ignored. + +.. + +.. date: 2026-06-23-17-14-04 +.. gh-issue: 127802 +.. nonce: nGSxo6 +.. section: Library + +The deprecated :class:`tkinter.Variable` methods :meth:`!trace_variable`, +:meth:`!trace`, :meth:`!trace_vdelete` and :meth:`!trace_vinfo` are now +scheduled for removal in Python 3.17. + +.. + +.. date: 2026-06-23-13-27-14 +.. gh-issue: 126219 +.. nonce: kOfv2g +.. section: Library + +Fixed a crash in :class:`tkinter.Tk` when *className* contains a non-BMP +character and tkinter is built against Tcl/Tk 8.x. Such a name is now +rejected with a :exc:`ValueError`. + +.. + +.. date: 2026-06-23-12-00-00 +.. gh-issue: 101284 +.. nonce: Ab3Xy9 +.. section: Library + +:class:`tkinter.OptionMenu` now accepts arbitrary +:class:`!tkinter.Menubutton` options as keyword arguments and uses them to +override its default appearance. + +.. + +.. date: 2026-06-23-11-00-03 +.. gh-issue: 143070 +.. nonce: fV5w7s +.. section: Library + +Automatically generated :mod:`tkinter` widget names now start with ``"+"`` +instead of ``"!"``, so that they can be used as tags in the +:class:`!tkinter.Canvas` and :class:`!tkinter.Text` widgets. + +.. + +.. date: 2026-06-22-18-01-00 +.. gh-issue: 151955 +.. nonce: 6u5iwm +.. section: Library + +Allow more types to be used in the ``bound`` argument to +:class:`typing.ParamSpec` and :class:`typing.TypeVarTuple`. + +.. + +.. date: 2026-06-22-14-30-00 +.. gh-issue: 151920 +.. nonce: Th3mSt +.. section: Library + +Add the :meth:`ttk.Style.theme_styles ` +method, wrapping the Tk ``ttk::style theme styles`` subcommand, which +returns the list of styles defined in a theme. + +.. + +.. date: 2026-06-22-12-00-00 +.. gh-issue: 95555 +.. nonce: Pr0p18 +.. section: Library + +Regular expressions now support Unicode property escapes ``\p{...}`` and +``\P{...}`` for properties that the engine can resolve without the +unicodedata database: many ``General_Category`` values, a number of binary +properties, the POSIX compatibility classes, and properties derivable from +the code point. + +.. + +.. date: 2026-06-22-10-30-22 +.. gh-issue: 151910 +.. nonce: ayi8xK +.. section: Library + +Added :class:`tkinter.ttk.Treeview` methods wrapping the enhanced +``ttk::treeview`` widget commands added in Tk 9.1 (and the ``detached`` +query added in Tk 9.0): item navigation and queries, opening, hiding, +sorting and searching of items, and cell focus, selection and tagging. The +:meth:`~tkinter.ttk.Treeview.expand` and +:meth:`~tkinter.ttk.Treeview.collapse` methods (without recursion) also work +on Tk older than 9.1. + +.. + +.. date: 2026-06-22-02-29-02 +.. gh-issue: 151890 +.. nonce: gT6JwI +.. section: Library + +Add the *format* parameter to the :meth:`tkinter.PhotoImage.put` method, the +*metadata* parameter to the :meth:`~tkinter.PhotoImage.put`, +:meth:`~tkinter.PhotoImage.read`, :meth:`~tkinter.PhotoImage.write` and +:meth:`~tkinter.PhotoImage.data` methods, and the *withalpha* parameter to +the :meth:`~tkinter.PhotoImage.get` method. The *metadata* and *withalpha* +parameters require Tcl/Tk 9.0 or newer. + +.. + +.. date: 2026-06-22-01-57-55 +.. gh-issue: 151888 +.. nonce: hO7mxi +.. section: Library + +Add the :meth:`!tkinter.PhotoImage.redither` method, wrapping the photo +image ``redither`` Tk command. + +.. + +.. date: 2026-06-22-01-51-06 +.. gh-issue: 151886 +.. nonce: MsLlNz +.. section: Library + +Add the :meth:`!tkinter.Misc.tk_appname`, +:meth:`!tkinter.Misc.tk_useinputmethods` and :meth:`!tkinter.Misc.tk_caret` +methods, wrapping the ``tk appname``, ``tk useinputmethods`` and ``tk +caret`` Tk commands. + +.. + +.. date: 2026-06-22-01-39-38 +.. gh-issue: 151881 +.. nonce: ShACSZ +.. section: Library + +Add the :meth:`tkinter.Menu.postcascade` method and the +:meth:`!tkinter.Misc.tk_scaling` and :meth:`!tkinter.Misc.tk_inactive` +methods, wrapping the ``postcascade``, ``tk scaling`` and ``tk inactive`` Tk +commands. + +.. + +.. date: 2026-06-22-01-02-33 +.. gh-issue: 151878 +.. nonce: IFIA5C +.. section: Library + +Add the :meth:`!validate` method to the :class:`tkinter.Entry` and +:class:`tkinter.Spinbox` widgets, forcing an evaluation of the validation +command. + +.. + +.. date: 2026-06-22-00-55-07 +.. gh-issue: 151876 +.. nonce: sVe0xx +.. section: Library + +Add the :class:`tkinter.Canvas` methods :meth:`!rchars` and :meth:`!rotate`, +wrapping the ``rchars`` and ``rotate`` Tk canvas commands. + +.. + +.. date: 2026-06-22-00-46-57 +.. gh-issue: 151874 +.. nonce: 8VtTrq +.. section: Library + +Add the :mod:`tkinter` methods :meth:`!Misc.winfo_isdark`, +:meth:`!Wm.wm_iconbadge` and :meth:`!Wm.wm_stackorder`, wrapping the ``winfo +isdark``, ``wm iconbadge`` and ``wm stackorder`` Tk commands. + +.. + +.. date: 2026-06-21-23-17-12 +.. gh-issue: 59396 +.. nonce: Fd9Tk2 +.. section: Library + +The :class:`!tkinter.filedialog.FileDialog` dialog and its +:class:`!tkinter.filedialog.LoadFileDialog` and +:class:`!tkinter.filedialog.SaveFileDialog` subclasses, which follow the +layout of the classic Motif file selection dialog, were modernized to match +its look and feel more closely. They are now built from the themed +:mod:`tkinter.ttk` widgets instead of the classic :mod:`tkinter` widgets, +and gained a *use_ttk* parameter that selects between the classic Tk widgets +and the themed ttk widgets. The buttons and field labels gained :kbd:`Alt` +key accelerators, the default ring follows the keyboard focus, and the +:kbd:`Escape` key cancels the dialog. The directory and file lists gained a +horizontal scrollbar and type-ahead selection. The dialog is now centered +over its parent, and the overwrite confirmation of :class:`!SaveFileDialog` +uses a themed message box. + +.. + +.. date: 2026-06-21-15-50-24 +.. gh-issue: 86165 +.. nonce: dyac1G +.. section: Library + +Fix :func:`imaplib.Time2Internaldate` to use the local timezone offset for +``time.struct_time`` values with ``tm_gmtoff`` set to ``None``, as returned +by ``datetime.datetime.timetuple()``. Contributed by Xiao Yuan. + +.. + +.. date: 2026-06-21-00-00-57 +.. gh-issue: 151822 +.. nonce: bOC2G56F +.. section: Library + +Colorize ``exit``, ``quit``, ``copyright``, ``help``, and ``clear`` as +commands in the :term:`REPL` when typed alone on a line. Patch by Bartosz +Sławecki. + +.. + +.. date: 2026-06-20-22-55-22 +.. gh-issue: 59396 +.. nonce: kT9wPq +.. section: Library + +The :mod:`tkinter.simpledialog` dialogs were modernized to match the look +and feel of the native Tk dialogs. +:class:`!tkinter.simpledialog.SimpleDialog` and the +:func:`~tkinter.simpledialog.askinteger`, +:func:`~tkinter.simpledialog.askfloat` and +:func:`~tkinter.simpledialog.askstring` dialogs are now built from the +themed :mod:`tkinter.ttk` widgets instead of the classic :mod:`tkinter` +widgets; the :class:`!tkinter.simpledialog.Dialog` base class still defaults +to the classic widgets for compatibility. Both :class:`!Dialog` and +:class:`!SimpleDialog` gained a *use_ttk* parameter that selects between the +classic Tk widgets and the themed ttk widgets. :class:`!SimpleDialog` also +gained *bitmap* and *detail* parameters, draws the standard icons with +themed images in the ttk version, and accepts mappings of button options as +*buttons* entries, where an ``underline`` option adds an :kbd:`Alt` key +accelerator. The font and wrap length of the message and the detail message +are taken from the Tk option database and can be overridden by the +application. The dialogs also follow the keyboard conventions of the Tk +message box: the default ring follows the keyboard focus, the Return key +activates the focused button, and the :class:`!Dialog` OK and Cancel buttons +gained :kbd:`Alt` key accelerators. Several bugs were also fixed. + +.. + +.. date: 2026-06-20-21-15-13 +.. gh-issue: 151814 +.. nonce: OIbgsO +.. section: Library + +Fix unbounded memory growth in :class:`io.TextIOWrapper` when repeatedly +writing an empty string. + +.. + +.. date: 2026-06-20-20-24-03 +.. gh-issue: 133998 +.. nonce: nkqhMz +.. section: Library + +Fix :func:`tarfile.open` in streaming write mode (``w|gz``) raising +:exc:`struct.error` when given an *mtime* outside the range of the gzip +header's 32-bit timestamp field. Out-of-range values are now stored as +``0``, matching :mod:`gzip`. + +.. + +.. date: 2026-06-20-15-00-00 +.. gh-issue: 75666 +.. nonce: Kt9xQ2 +.. section: Library + +Fix a reference leak in :mod:`tkinter`: the Tcl commands created for event +callbacks are now deleted when a binding is replaced or unbound. + +.. + +.. date: 2026-06-20-15-00-00 +.. gh-issue: 151770 +.. nonce: dtiso0 +.. section: Library + +Fix :meth:`datetime.datetime.fromisoformat` raising :exc:`AssertionError` +instead of :exc:`ValueError` for an out-of-range month combined with a +``24:00`` time. + +.. + +.. date: 2026-06-20-12-10-02 +.. gh-issue: 151776 +.. nonce: BtsXIF +.. section: Library + +Add :mod:`curses` functions and window methods that report state which could +previously only be set: the window methods +:meth:`~curses.window.is_cleared`, :meth:`~curses.window.is_idcok`, +:meth:`~curses.window.is_idlok`, :meth:`~curses.window.is_immedok`, +:meth:`~curses.window.is_keypad`, :meth:`~curses.window.is_leaveok`, +:meth:`~curses.window.is_nodelay`, :meth:`~curses.window.is_notimeout`, +:meth:`~curses.window.is_pad`, :meth:`~curses.window.is_scrollok`, +:meth:`~curses.window.is_subwin`, :meth:`~curses.window.is_syncok`, +:meth:`~curses.window.getdelay`, :meth:`~curses.window.getparent` and +:meth:`~curses.window.getscrreg`, and the functions +:func:`curses.is_cbreak`, :func:`curses.is_echo`, :func:`curses.is_nl` and +:func:`curses.is_raw`. They are only available when built against an +ncurses with ``NCURSES_EXT_FUNCS``. + +.. + +.. date: 2026-06-20-11-11-22 +.. gh-issue: 151774 +.. nonce: O6nrvs +.. section: Library + +Add the :mod:`curses` functions :func:`curses.alloc_pair`, +:func:`curses.find_pair`, :func:`curses.free_pair` and +:func:`curses.reset_color_pairs` for dynamic color-pair management. They +are only available when Python is built against a wide-character version of +the underlying curses library with extended-color support. + +.. + +.. date: 2026-06-20-02-14-55 +.. gh-issue: 151757 +.. nonce: TP9A2x +.. section: Library + +The :mod:`curses` character-cell window methods now accept a full character +cell -- a spacing character optionally followed by combining characters -- +in addition to a single integer or byte character. Add the wide-character +read methods :meth:`curses.window.get_wstr` and +:meth:`curses.window.in_wstr`, and the functions :func:`curses.erasewchar`, +:func:`curses.killwchar` and :func:`curses.wunctrl`. On a narrow +(non-ncursesw) build the character cell holds a single character without +combining marks, representable as one byte in the window's encoding, and +:meth:`curses.window.in_wstr` returns its decoded text. + +.. + +.. date: 2026-06-19-18-40-00 +.. gh-issue: 151744 +.. nonce: Kp7mNq +.. section: Library + +Add :func:`curses.nofilter`, which undoes the effect of +:func:`curses.filter`. + +.. + +.. date: 2026-06-19-12-19-30 +.. gh-issue: 90092 +.. nonce: yBVc0C +.. section: Library + +Add support for multiple terminals to the :mod:`curses` module: the new +functions :func:`curses.newterm`, :func:`curses.set_term` and +:func:`curses.new_prescr`, the corresponding :ref:`screen +` object, and the :meth:`curses.window.use` method. + +.. + +.. date: 2026-06-19-12-00-01 +.. gh-issue: 151675 +.. nonce: acLD7L +.. section: Library + +Add the :meth:`~tkinter.Text.sync` and :meth:`~tkinter.Text.pendingsync` +methods of :class:`!tkinter.Text`, wrapping the Tk ``sync`` and +``pendingsync`` subcommands. + +.. + +.. date: 2026-06-19-12-00-00 +.. gh-issue: 151674 +.. nonce: FCYTvs +.. section: Library + +Add the :meth:`~tkinter.Text.edit_canundo` and +:meth:`~tkinter.Text.edit_canredo` methods of :class:`!tkinter.Text`, +wrapping the Tk ``edit canundo`` and ``edit canredo`` subcommands. + +.. + +.. date: 2026-06-19-08-30-00 +.. gh-issue: 151627 +.. nonce: xY7kLm +.. section: Library + +Fix a crash in :class:`collections.OrderedDict` iterators in free-threaded +builds when the dictionary is concurrently cleared or updated. + +.. + +.. date: 2026-06-19-07-26-20 +.. gh-issue: 151695 +.. nonce: IBDlkN +.. section: Library + +Fix a use-after-free in the :mod:`curses` module. The encoding of the +initial screen, used by :func:`curses.unctrl` and :func:`curses.ungetch` to +encode non-ASCII characters, is now kept as a private copy instead of a +borrowed pointer to a window object that may be deallocated. + +.. + +.. date: 2026-06-18-23-59-46 +.. gh-issue: 151596 +.. nonce: 5ma144 +.. section: Library + +Add missing ``size`` positional argument to the pure-Python implementation +of :meth:`io.TextIOBase.readline`. + +.. + +.. date: 2026-06-18-12-48-03 +.. gh-issue: 151640 +.. nonce: R4c3Fx +.. section: Library + +Fix a data race in :class:`io.BytesIO` in free-threaded builds when +whole-buffer reads or peeks, or :meth:`~io.BytesIO.getvalue`, share the +internal buffer with concurrent writes. + +.. + +.. date: 2026-06-18-00-39-58 +.. gh-issue: 151615 +.. nonce: PBsCE1 +.. section: Library + +Fix :mod:`asyncio` servers repeatedly logging and rescheduling on a single +event loop iteration when ``accept()`` fails with a resource errors. + +.. + +.. date: 2026-06-17-22-31-57 +.. gh-issue: 151613 +.. nonce: n0nua1 +.. section: Library + +Fix another way the Tachyon profiler frame cache could produce impossible +mixed stack traces when ``_PyInterpreterFrame`` addresses are reused, by +validating cached frame anchors with a sequence counter. + +.. + +.. date: 2026-06-17-00-00-00 +.. gh-issue: 148660 +.. nonce: odcopy +.. section: Library + +Fix a crash in :meth:`!collections.OrderedDict.copy` when a key's ``__eq__`` +or a subclass method mutates the dict during the copy. Now raises +:exc:`RuntimeError` instead, as iteration does. + +.. + +.. date: 2026-06-15-15-32-36 +.. gh-issue: 151497 +.. nonce: 1cfmSV +.. section: Library + +Opening a :mod:`tarfile` archive no longer attempts to pre-allocate a huge +buffer when a crafted or truncated member claims an oversized extended +header (a GNU long name/link or a pax header). The extended header is now +read in bounded chunks, so its size field can no longer trigger memory +exhaustion. + +.. + +.. date: 2026-06-15-07-42-12 +.. gh-issue: 151485 +.. nonce: NiYQPZ +.. section: Library + +Fix command quoting in :exc:`subprocess.CalledProcessError`. Contributed by +Benjy Wiener. + +.. + +.. date: 2026-06-13-11-57-48 +.. gh-issue: 151436 +.. nonce: UEDowO +.. section: Library + +Fix skewed stack traces in the Tachyon profiler when caching is enabled and +when generators and coroutines are profiled, by updating +``tstate->last_profiled_frame`` at every frame-removal site. The issue +resulted in total erasure of some callers. Patch by Maurycy +Pawłowski-Wieroński. + +.. + +.. date: 2026-06-13-04-11-00 +.. gh-issue: 151426 +.. nonce: f2V67e +.. section: Library + +Fix impossible stack traces (callers and callees cross called, orphans and +incorrect lines) in the Tachyon profiler when caching frames, by +snapshotting the stack chunks before walking the frame chain on a cache +miss. Patch by Maurycy Pawłowski-Wieroński. + +.. + +.. date: 2026-06-12-22-46-31 +.. gh-issue: 151403 +.. nonce: DalZWh +.. section: Library + +Fixed a crash in :class:`subprocess.Popen` (and +``_posixsubprocess.fork_exec``) when an ``argv`` item's +:meth:`~os.PathLike.__fspath__` concurrently mutates the ``args`` sequence +being converted. + +.. + +.. date: 2026-06-12-07-20-08 +.. gh-issue: 151390 +.. nonce: CmYN9EeJ +.. section: Library + +Colorize ``match`` in the :term:`REPL` when followed by a unary ``+`` or +``-`` operator. Patch by Bartosz Sławecki. + +.. + +.. date: 2026-06-12-00-17-29 +.. gh-issue: 151128 +.. nonce: -LYO3a +.. section: Library + +Cross-language keyword suggestions are now shown for :exc:`SyntaxError` +messages. For example, ``switch x:`` suggests ``match``, ``delete x`` +suggests ``del``, ``function f():`` suggests ``def``. Contributed by Zang +Langyan. + +.. + +.. date: 2026-06-12-00-04-34 +.. gh-issue: 151126 +.. nonce: aHaBYq +.. section: Library + +Fix crash on unset :exc:`MemoryError` on allocation failure in +:func:`ctypes.get_errno`. + +.. + +.. date: 2026-06-12-00-00-00 +.. gh-issue: 151416 +.. nonce: spawnUA +.. section: Library + +Fix a crash in :func:`os.spawnv` and :func:`os.spawnve` when an *argv* +item's :meth:`~os.PathLike.__fspath__` method mutates the *argv* list during +argument conversion. :func:`!os.spawnv` argument conversion errors other +than :exc:`TypeError`, such as the :exc:`ValueError` for an embedded null, +are no longer replaced with a generic :exc:`TypeError`. + +.. + +.. date: 2026-06-11-21-43-24 +.. gh-issue: 151337 +.. nonce: JSVV18 +.. section: Library + +Avoid possible memory leak in ``tkinter.c`` on Windows. + +.. + +.. date: 2026-06-11-19-46-16 +.. gh-issue: 150285 +.. nonce: wuhAsL +.. section: Library + +:mod:`pydoc` now uses all available space (80 columns) for formatting reprs +of module and class data, but ensure that they do not overflow. + +.. + +.. date: 2026-06-11-16-25-38 +.. gh-issue: 151126 +.. nonce: bh_Usy +.. section: Library + +Fix a crash when :exc:`MemoryError` in :func:`!os._path_splitroot` was not +set properly. + +.. + +.. date: 2026-06-11-11-52-23 +.. gh-issue: 149671 +.. nonce: 6Rpr5r +.. section: Library + +Restore compatibility with setuptools ``-nspkg.pth`` files in the +:mod:`site` module. Inject ``sitedir`` variable in the frame which executes +pth code. Patch by Victor Stinner. + +.. + +.. date: 2026-06-11-10-00-00 +.. gh-issue: 119710 +.. nonce: Qz7Kp2 +.. section: Library + +Fix :mod:`asyncio` subprocess :meth:`~asyncio.subprocess.Process.wait` +hanging when the process has exited but one of its pipes is kept open by an +inherited child process (so the pipe never reaches EOF). ``wait()`` now +returns as soon as the process exits, regardless of the pipes' state. + +.. + +.. date: 2026-06-11-00-00-00 +.. gh-issue: 151295 +.. nonce: NQYUzW +.. section: Library + +Fixed a crash (use-after-free) in :meth:`bytes.join` and +:meth:`bytearray.join` that could occur if an item's +:meth:`~object.__buffer__` concurrently mutates the sequence being joined. +The mutation is now reported as a :exc:`RuntimeError` instead. + +.. + +.. date: 2026-06-10-00-00-02 +.. gh-issue: 109940 +.. nonce: Cx1099 +.. section: Library + +Fix Windows :mod:`venv` activation in ``cmd.exe`` to respect +``VIRTUAL_ENV_DISABLE_PROMPT``. + +.. + +.. date: 2026-06-10-00-00-01 +.. gh-issue: 117807 +.. nonce: Cx1178 +.. section: Library + +Fix :mod:`mimetypes` initialization from MIME map files containing invalid +UTF-8 bytes. + +.. + +.. date: 2026-06-09-19-43-24 +.. gh-issue: 151179 +.. nonce: hl_6Z0 +.. section: Library + +Fix a pidfd leak in ``_PidfdChildWatcher`` on Linux: the watcher no longer +leaks the process file descriptor when ``waitpid()`` fails with an error +other than :exc:`ChildProcessError`. + +.. + +.. date: 2026-06-09-14-49-17 +.. gh-issue: 80384 +.. nonce: ttRAja +.. section: Library + +:func:`weakref.ref` and :func:`weakref.proxy` now raise :exc:`TypeError` if +the *callback* argument is not callable or ``None``. + +.. + +.. date: 2026-06-09-12-00-00 +.. gh-issue: 150771 +.. nonce: K7mNx2 +.. section: Library + +Fix :mod:`email` messages created with ``shift_jis`` or ``euc-jp`` charsets. +``set_content()`` now stores the payload using the output charset +(``iso-2022-jp``) so printing the message no longer raises +:exc:`UnicodeEncodeError`. + +.. + +.. date: 2026-06-08-15-04-35 +.. gh-issue: 150285 +.. nonce: -Tj94n +.. section: Library + +:mod:`pydoc` now wraps long single-line summary in text output. + +.. + +.. date: 2026-06-07-23-30-34 +.. gh-issue: 151049 +.. nonce: mBlToO +.. section: Library + +:mod:`ipaddress`: fix ``is_global`` and ``is_private`` for the +``2001:1::3/128`` (DNS-SD Service Registration Protocol Anycast) address, +which IANA registered as globally reachable per :rfc:`9665`. It is now +correctly reported with ``is_global`` ``True`` and ``is_private`` ``False``. + +.. + +.. date: 2026-06-07-17-29-33 +.. gh-issue: 151039 +.. nonce: AZ0qBn +.. section: Library + +Fix a crash when static :mod:`datetime` types outlive the ``_datetime`` +module. + +.. + +.. date: 2026-06-07-13-47-05 +.. gh-issue: 151042 +.. nonce: NMdzF2 +.. section: Library + +Fixed venv exporting mixed path styles to PATH on Windows inside fish (via +Cygwin, MinGW or MSYS2) + +.. + +.. date: 2026-06-06-15-20-54 +.. gh-issue: 151021 +.. nonce: J4qk2A +.. section: Library + +Fix :meth:`mmap.mmap.find` and :meth:`~mmap.mmap.rfind` to return ``-1`` +when searching for an empty subsequence with a start position past the end +of the mapping. + +.. + +.. date: 2026-06-06-15-04-37 +.. gh-issue: 151022 +.. nonce: 1Aw8Tk +.. section: Library + +Fix ``_remote_debugging`` stack traces for code objects with large line +tables. + +.. + +.. date: 2026-06-06-06-29-17 +.. gh-issue: 150994 +.. nonce: I2119M +.. section: Library + +Make the type annotations in the private ``_colorize`` module resolvable. + +.. + +.. date: 2026-06-05-16-57-03 +.. gh-issue: 143768 +.. nonce: RbLnkFx +.. section: Library + +:mod:`venv`: Replace a dangling interpreter symlink in an existing virtual +environment instead of failing or silently leaving it broken. Fix by Clay +Dugo. + +.. + +.. date: 2026-06-04-23-10-31 +.. gh-issue: 62825 +.. nonce: BtG_yQ +.. section: Library + +Encodings "KS_C_5601-1987", "KS X 1001", etc are now aliases of "CP949" +instead of "EUC-KR". + +.. + +.. date: 2026-06-04-21-49-18 +.. gh-issue: 150913 +.. nonce: EmptyBl +.. section: Library + +Fix :class:`sqlite3.Blob` slice assignment to raise :exc:`TypeError` and +:exc:`IndexError` for type and size mismatches respectively, even when the +target slice is empty. + +.. + +.. date: 2026-06-04-19-24-13 +.. gh-issue: 140006 +.. nonce: TD8HKl +.. section: Library + +The :mod:`venv` ``activate.fish`` script now calls fish builtins through +``builtin`` so a user function that shadows ``.``/``source``, ``echo``, +``printf``, ``set_color``, or ``functions`` can no longer hijack the virtual +environment prompt or break exit-status reporting. + +.. + +.. date: 2026-06-04-18-22-56 +.. gh-issue: 143008 +.. nonce: z5tw-J +.. section: Library + +Fix race conditions when re-initializing a :class:`io.TextIOWrapper` object. + +.. + +.. date: 2026-06-04-10-44-36 +.. gh-issue: 150889 +.. nonce: UYNLR_ +.. section: Library + +Speed up :func:`unicodedata.normalize` for the NFC and NFKC forms of +non-ASCII text up to a factor 2. + +.. + +.. date: 2026-06-04-06-50-06 +.. gh-issue: 150898 +.. nonce: 1LkLA3 +.. section: Library + +Unconditionally assume :attr:`ssl.SSLContext.keylog_filename` exists. + +.. + +.. date: 2026-06-03-21-59-11 +.. gh-issue: 150886 +.. nonce: r2c25g +.. section: Library + +Remove the private, undocumented function +``importlib._bootstrap._object_name()``. It had no caller after +``load_module()`` and its deprecation warnings were removed from +:mod:`importlib`. + +.. + +.. date: 2026-06-03-19-35-32 +.. gh-issue: 150583 +.. nonce: dedI24 +.. section: Library + +Correctly set the default compression level in :mod:`compression.zstd` when +passing a digested dictionary during compression. + +.. + +.. date: 2026-06-03-18-41-42 +.. gh-issue: 150866 +.. nonce: gXGyX- +.. section: Library + +Fix :meth:`asyncio.loop.shutdown_asyncgens` to report any +:exc:`BaseException` raised during asynchronous generator cleanup. + +.. + +.. date: 2026-06-03-13-51-29 +.. gh-issue: 150662 +.. nonce: ELT8Vg +.. section: Library + +Fix the ``--gecko`` collector in :mod:`profiling.sampling` that kept every +sample in memory. It now writes sample and marker data to temporary files +and reads them back, ultimately building the output file at the end. Patch +by Pablo Galindo and Maurycy Pawłowski-Wieroński. + +.. + +.. date: 2026-06-02-15-45-00 +.. gh-issue: 150820 +.. nonce: W7tpO7 +.. section: Library + +Speed up :func:`json.dumps` for small documents. Patch by Bernát Gábor. + +.. + +.. date: 2026-06-02-15-44-58 +.. gh-issue: 150818 +.. nonce: Orcefu +.. section: Library + +Speed up :func:`logging.getLogger` with a lock-free fast path that returns +an already-registered logger without acquiring the logging lock. Patch by +Bernát Gábor. + +.. + +.. date: 2026-06-02-15-44-57 +.. gh-issue: 150817 +.. nonce: lpFCh0 +.. section: Library + +Speed up the ``|``, ``&`` and ``^`` operations on :class:`enum.Flag` +members. Patch by Bernát Gábor. + +.. + +.. date: 2026-06-02-14-21-46 +.. gh-issue: 150750 +.. nonce: SVS2o0 +.. section: Library + +Fix a race condition in :meth:`collections.deque.index` with free-threading. + +.. + +.. date: 2026-06-02-13-10-00 +.. gh-issue: 150751 +.. nonce: Hk2Vw9 +.. section: Library + +:mod:`http.client` now validates the ``Content-Length`` header and the +chunked ``chunk-size`` against the RFC 9112 grammar (``1*DIGIT`` and +``1*HEXDIG``) before parsing them, rejecting values such as ``+5``, ``5_0`` +or a ``0x``-prefixed or negative chunk size that :func:`int` would otherwise +accept. This avoids framing a response differently from a strict peer. + +.. + +.. date: 2026-06-01-08-12-34 +.. gh-issue: 150717 +.. nonce: LVRJXH +.. section: Library + +Avoid an unnecessary per-call memory allocation when matching :mod:`re` +patterns that have no capturing groups. Patch by Bernát Gábor. + +.. + +.. date: 2026-05-31-17-47-30 +.. gh-issue: 150685 +.. nonce: EBB2mU +.. section: Library + +Update bundled pip to 26.1.2 + +.. + +.. date: 2026-05-31-14-39-25 +.. gh-issue: 150641 +.. nonce: LLIhd1 +.. section: Library + +Fix bug where :func:`typing.evaluate_forward_ref` with the ``STRING`` format +could leak internal names used by the annotation machinery. + +.. + +.. date: 2026-05-31-12-00-00 +.. gh-issue: 150942 +.. nonce: Re7Ref +.. section: Library + +Speed up :func:`re.findall`, :func:`re.sub` and :func:`re.subn` by appending +result items to the output list without an extra reference-count round-trip +(using the internal reference-stealing list append helper). + +.. + +.. date: 2026-05-31-10-00-00 +.. gh-issue: 150942 +.. nonce: Tk9aRef +.. section: Library + +Speed up :func:`json.loads` decoding of arrays and objects by storing parsed +values into the result list/dict without an extra reference-count round-trip +(using the internal reference-stealing append/insert helpers). + +.. + +.. date: 2026-05-29-10-11-34 +.. gh-issue: 117404 +.. nonce: EeP6xe +.. section: Library + +Add a number of constants in modules :mod:`zlib`, :mod:`bz2`, :mod:`lzma`, +and :mod:`compression.zstd`, which provide information about the version of +libraries that were used for building the module and that are actually +loaded. Make :const:`compression.zstd.zstd_version_info` a named tuple. + +.. + +.. date: 2026-05-28-23-38-46 +.. gh-issue: 150478 +.. nonce: qEr0E- +.. section: Library + +Add ``show_jit`` option to ``dis.dis`` to show JIT entry points in the +bytecode. This is useful for visualizing where JIT traces are entered from +the interpreter. + +.. + +.. date: 2026-05-27-23-47-31 +.. gh-issue: 148932 +.. nonce: Y1xmvA +.. section: Library + +Fix ``profiling.sampling`` on Windows virtual environments to resolve the +actual Python PID from a virtual environment shim. + +.. + +.. date: 2026-05-27-15-51-29 +.. gh-issue: 150534 +.. nonce: 3Nan6S +.. section: Library + +Added trigonometric functions that work in units of half turns, rather than +radians. The new functions :func:`math.acospi`, :func:`math.asinpi`, +:func:`math.atanpi`, and :func:`math.atan2pi` return half-turn angles. The +new functions :func:`math.cospi`, :func:`math.sinpi`, and :func:`math.tanpi` +take half-turn angle arguments. These functions are recommended by IEEE +754-2019 and standardized in C23. + +.. + +.. date: 2026-05-27-11-18-36 +.. gh-issue: 150228 +.. nonce: pNPiO- +.. section: Library + +The new :class:`site.StartupState` class lets callers batch-process +:pep:`829` startup configuration files across multiple site directories +before any startup code runs, with public +:meth:`~site.StartupState.addsitedir`, +:meth:`~site.StartupState.addusersitepackages`, +:meth:`~site.StartupState.addsitepackages`, and +:meth:`~site.StartupState.process` methods. The signature of +:func:`site.addsitedir` is unchanged from Python 3.14. The +:data:`!defer_processing_start_files` argument and the +``process_startup_files()`` function added earlier in the 3.15 cycle have +been removed; use :class:`!site.StartupState` instead. + +.. + +.. date: 2026-05-26-19-30-00 +.. gh-issue: 150479 +.. nonce: Kq7Lm2 +.. section: Library + +:func:`email.utils.formataddr` now raises :exc:`ValueError` when the name or +address contains a carriage return or line feed, matching +:class:`email.headerregistry.Address`. This check can be disabled by +passing ``strict=False``. + +.. + +.. date: 2026-05-26-15-53-50 +.. gh-issue: 150449 +.. nonce: GfDWxl +.. section: Library + +:class:`sqlite3.Blob` now supports negative-step slices for reading and +writing (e.g. ``blob[9:0:-2]``). Previously, such slices would raise +:exc:`SystemError` or :exc:`ValueError`. + +.. + +.. date: 2026-05-25-17-00-00 +.. gh-issue: 150406 +.. nonce: jF3g63 +.. section: Library + +Fix a possible crash occurring during :mod:`socket` module initialization +when the system is out of memory on platforms without a reentrant +``gethostbyname``. + +.. + +.. date: 2026-05-25-07-22-05 +.. gh-issue: 150372 +.. nonce: 9hLqhe +.. section: Library + +:mod:`readline`: Fix a potential crash during tab completion caused by an +out-of-memory error during module initialization. + +.. + +.. date: 2026-05-22-15-30-00 +.. gh-issue: 132372 +.. nonce: YP4a6x +.. section: Library + +Speed up :func:`logging.config.fileConfig` and +:func:`logging.config.dictConfig` when handling many existing loggers. + +.. + +.. date: 2026-05-21-20-47-45 +.. gh-issue: 150157 +.. nonce: ZvmO-bQZ +.. section: Library + +Fix a crash in free-threaded builds that occurs when pickling by name +objects without a ``__module__`` attribute while :data:`sys.modules` is +concurrently being modified. + +.. + +.. date: 2026-05-21-11-25-58 +.. gh-issue: 150175 +.. nonce: 8H4Caz +.. section: Library + +Fix race condition in :class:`unittest.mock.ThreadingMock` where concurrent +calls could lose increments to ``call_count`` and other attributes due to a +missing lock in ``_increment_mock_call``. + +.. + +.. date: 2026-05-20-14-00-00 +.. gh-issue: 145856 +.. nonce: Pl5kZx +.. section: Library + +Fix :func:`plistlib.dumps` and :func:`plistlib.dump` so that +``skipkeys=True`` together with ``sort_keys=True`` correctly drops +non-string keys when the dictionary contains a mix of string and non-string +keys. Previously the sort ran before the filter and raised +:exc:`TypeError`. + +.. + +.. date: 2026-05-19-19-00-49 +.. gh-issue: 84353 +.. nonce: ZU5zaQ +.. section: Library + +Preserve non-UTF-8 encoded filenames when appending to a +:class:`zipfile.ZipFile`. Previously, non-ASCII names stored in a legacy +encoding (without the UTF-8 flag bit set) could be corrupted when the +central directory was rewritten: they were decoded as cp437 and then +re-stored as UTF-8. + +.. + +.. date: 2026-05-19-18-25-00 +.. gh-issue: 150077 +.. nonce: zstopen-close +.. section: Library + +Fix ``tarfile.TarFile.zstopen`` to close the underlying zstd file object +when opening the tar archive is interrupted by a :exc:`BaseException` +subclass such as :exc:`KeyboardInterrupt`. + +.. + +.. date: 2026-05-19-12-00-00 +.. gh-issue: 149980 +.. nonce: Kx7p2A +.. section: Library + +Fix :mod:`tarfile` so that GNU long-name directory entries have all trailing +slashes stripped from their names, matching the behavior for short-name +entries. Previously, only a single trailing slash was removed. + +.. + +.. date: 2026-05-19-11-42-37 +.. gh-issue: 127949 +.. nonce: Ab3kZq +.. section: Library + +Remove the deprecated :mod:`asyncio` event loop policy system. Patch by +Kumar Aditya. + +.. + +.. date: 2026-05-18-22-45-54 +.. gh-issue: 149816 +.. nonce: T68vc_ +.. section: Library + +Fix race condition in :attr:`ssl.SSLContext.sni_callback` + +.. + +.. date: 2026-05-18-17-17-20 +.. gh-issue: 149189 +.. nonce: a8IooK +.. section: Library + +Revert the changes to :mod:`pprint` defaults. Patch by Hugo van Kemenade. + +.. + +.. date: 2026-05-18-13-43-06 +.. gh-issue: 79413 +.. nonce: OpTXbV +.. section: Library + +Update :func:`dataclasses.make_dataclass` to add a *qualname* parameter. The +*qualname* parameter will be used to set the :attr:`!__qualname__` of the +created ``dataclass``. + +.. + +.. date: 2026-05-18-12-42-31 +.. gh-issue: 149816 +.. nonce: F98iME +.. section: Library + +Fix a potential use after free condition in :func:`pickle.dumps` in +free-threaded mode when serializing lists. + +.. + +.. date: 2026-05-18-07-44-46 +.. gh-issue: 149995 +.. nonce: vvtFHn +.. section: Library + +Update various docstrings in :mod:`typing`. + +.. + +.. date: 2026-05-17-22-37-02 +.. gh-issue: 88726 +.. nonce: BAoL6j +.. section: Library + +The :mod:`email` package now uses standard MIME charset names "gb2312" and +"big5" instead of non-standard names "eucgb2312_cn" and "big5_tw". + +.. + +.. date: 2026-05-17-12-37-59 +.. gh-issue: 53144 +.. nonce: c5tr1p +.. section: Library + +The :mod:`email` package now supports all aliases of Python codecs and uses +MIME/IANA names for all IANA registered charsets. + +.. + +.. date: 2026-05-17-02-25-56 +.. gh-issue: 149571 +.. nonce: LNyuWJ +.. section: Library + +Fix the C implementation of :meth:`xml.etree.ElementTree.Element.itertext`: +it no longer emits text for comments and processing instructions. + +.. + +.. date: 2026-05-16-22-00-00 +.. gh-issue: 146406 +.. nonce: 10e0da +.. section: Library + +Add cross-language hints for ``.clear()`` on :class:`tuple`, +:class:`frozenset`, and :class:`frozendict`, suggesting the mutable +counterpart. Follow-up to :gh:`146406`. + +.. + +.. date: 2026-05-16-21-08-33 +.. gh-issue: 149921 +.. nonce: I1yNML +.. section: Library + +Fix reference leaks in error paths of the :mod:`!_interpchannels` and +:mod:`!_interpqueues` extension modules. + +.. + +.. date: 2026-05-15-19-52-41 +.. gh-issue: 149891 +.. nonce: BJUIGB +.. section: Library + +Add support for more encoding aliases `officially registered in IANA +`__. + +.. + +.. date: 2026-05-15-18-44-20 +.. gh-issue: 142349 +.. nonce: fHK3v1 +.. section: Library + +Add :keyword:`lazy` to the list of support topic by :func:`help`. + +.. + +.. date: 2026-05-15-16-28-00 +.. gh-issue: 149819 +.. nonce: fixpth +.. section: Library + +Fix regression in :func:`site.addsitedir` where ``.pth`` files were no +longer processed in Python subprocesses. This happened because +:func:`site.main` seeded ``known_paths`` with entries inherited from the +parent process, causing ``addsitedir`` to skip ``.pth`` processing. + +.. + +.. date: 2026-05-14-17-01-19 +.. gh-issue: 62259 +.. nonce: ytlFD5 +.. section: Library + +Add support for multiple multi-byte encodings in the :mod:`XML parser +`: "cp932", "cp949", "cp950", "Big5","EUC-JP", "GB2312", +"GBK", "johab", and "Shift_JIS". Add partial support (only BMP characters) +for multi-byte encodings "Big5-HKSCS", "EUC_JIS-2004", "EUC_JISX0213", +"Shift_JIS-2004", "Shift_JISX0213", "utf-8-sig" and non-standard aliases +like "UTF8" (without hyphen). The parser now raises :exc:`ValueError` for +known unsupported multi-byte encodings such us "ISO-2022-JP" or +"raw-unicode-escape" instead of failing later, when encounter non-ASCII +data. + +.. + +.. date: 2026-05-14-15-55-28 +.. gh-issue: 149816 +.. nonce: ZaXQ0q +.. section: Library + +Fix a race condition in ``_random.Random.__init__`` method in free-threading +mode. + +.. + +.. date: 2026-05-13-23-18-39 +.. gh-issue: 149801 +.. nonce: S_FfGr +.. section: Library + +Add IANA registered names and aliases with leading zeros before number (like +IBM00858, CP00858, IBM01140, CP01140) for corresponding codecs. + +.. + +.. date: 2026-05-13-12-16-54 +.. gh-issue: 149473 +.. nonce: nOQZqn +.. section: Library + +Calling ``os.environ.clear()`` now emits ``os._clearenv`` auditing event. +Patch by Victor Stinner. + +.. + +.. date: 2026-05-12-14-44-39 +.. gh-issue: 149720 +.. nonce: ccsoW- +.. section: Library + +Remove support for undotted *ext* in :meth:`mimetypes.MimeTypes.add_type`. + +.. + +.. date: 2026-05-12-13-03-45 +.. gh-issue: 149718 +.. nonce: SaM1NJ +.. section: Library + +Coalesce consecutive identical stack frames in Tachyon, so aggregating +collectors (pstats, collapsed, flamegraph, gecko) receive one collect. +Improves sample rate 3x, error rate and missed rate drop by 70%. Patch by +Maurycy Pawłowski-Wieroński. + +.. + +.. date: 2026-05-12-06-24-54 +.. gh-issue: 149701 +.. nonce: 8v9RTm +.. section: Library + +Fix bad return code from Lib/venv/bin/activate if hashing is disabled + +.. + +.. date: 2026-05-10-23-51-23 +.. gh-issue: 149504 +.. nonce: pDSCbn +.. section: Library + +Fix :func:`site.addsitedir` to allow re-entrant calls from within startup +files. Previously, a ``.pth`` file containing an ``import`` line that +called :func:`site.addsitedir` (or a ``.start`` entry point doing the same) +could crash with ``RuntimeError: dictionary changed size during iteration`` +during site initialization, breaking tools such as ``uv run --with``. + +.. + +.. date: 2026-05-10-19-26-50 +.. gh-issue: 149584 +.. nonce: x7Qm9A +.. section: Library + +Fix excessive overhead in the Tachyon profiler when inspecting a remote +process by avoiding repeated remote page-cache scans, batching predicted +remote reads, and reusing cached profiler result objects. Patch by Pablo +Galindo and Maurycy Pawłowski-Wieroński. + +.. + +.. date: 2026-05-10-16-06-27 +.. gh-issue: 149609 +.. nonce: yLKPXo +.. section: Library + +Raise :exc:`DeprecationWarning` on using :class:`abc.abstractclassmethod`, +:class:`abc.abstractstaticmethod`, and :class:`abc.abstractproperty`, +schedule its removal for Python 3.21. + +.. + +.. date: 2026-05-10-14-10-00 +.. gh-issue: 149634 +.. nonce: iT5cwC +.. section: Library + +Remove deprecated and unused :attr:`!tarfile.TarInfo.tarfile` attribute. + +.. + +.. date: 2026-05-10-12-00-00 +.. gh-issue: 149578 +.. nonce: 5cgq7iV +.. section: Library + +Fix :func:`tarfile.open` failing with :exc:`~tarfile.ReadError` when opening +a PAX format tar archive that contains only global headers and no regular +members. + +.. + +.. date: 2026-05-10-07-21-51 +.. gh-issue: 139489 +.. nonce: rS7LTA +.. section: Library + +Add :func:`xml.is_valid_text` to ``xml.__all__``. + +.. + +.. date: 2026-05-09-21-02-08 +.. gh-issue: 149614 +.. nonce: U4snj3 +.. section: Library + +Fix a regression that broke the ability to deepcopy +:class:`argparse.ArgumentParser` instances. + +.. + +.. date: 2026-05-09-15-42-54 +.. gh-issue: 149600 +.. nonce: ZbL-iv +.. section: Library + +Remove deprecated :func:`!asyncio.iscoroutinefunction` function. + +.. + +.. date: 2026-05-09-15-17-59 +.. gh-issue: 149598 +.. nonce: aLrXRw +.. section: Library + +Remove support of deprecated *strm* argument for :mod:`logging` handlers. + +.. + +.. date: 2026-05-09-11-22-29 +.. gh-issue: 149595 +.. nonce: 1nuYXw +.. section: Library + +Remove the :func:`!sys._enablelegacywindowsfsencoding` function which has +been deprecated since Python 3.13. + +.. + +.. date: 2026-05-08-16-44-20 +.. gh-issue: 149567 +.. nonce: iiZKEj +.. section: Library + +Remove the :exc:`!shutil.ExecError` exception which has been deprecated +since Python 3.14. + +.. + +.. date: 2026-05-08-15-08-35 +.. gh-issue: 112821 +.. nonce: t9T1YD +.. section: Library + +In the REPL, autocompletion might run arbitrary code in the getter of a +descriptor. If that getter raised an exception, autocompletion would fail to +present any options for the entire object. Autocompletion now works as +expected for these objects. + +.. + +.. date: 2026-05-08-14-24-16 +.. gh-issue: 149436 +.. nonce: dEV02X +.. section: Library + +Improve performance of :meth:`inspect.getattr_static`. + +.. + +.. date: 2026-05-08-09-11-48 +.. gh-issue: 149534 +.. nonce: Tw7eeY +.. section: Library + +Fix merging of :class:`collections.defaultdict` and :class:`frozendict`. + +.. + +.. date: 2026-05-08-08-24-01 +.. gh-issue: 149537 +.. nonce: hVFVnt +.. section: Library + +Remove kw parameters from python version of :func:`functools.reduce` +function. + +.. + +.. date: 2026-05-08-07-51-54 +.. gh-issue: 80480 +.. nonce: nnA4p1 +.. section: Library + +Remove deprecated ``'u'`` type code (:c:type:`wchar_t`) for the :mod:`array` +module. Use ``'w'`` format code instead (:c:type:`Py_UCS4`, always 4 +bytes). + +.. + +.. date: 2026-05-08-06-56-57 +.. gh-issue: 149530 +.. nonce: cl2AJ8 +.. section: Library + +Removed :meth:`!symtable.Class.get_methods` which has been deprecated since +3.14. + +.. + +.. date: 2026-05-08-06-12-26 +.. gh-issue: 149528 +.. nonce: AxdDxa +.. section: Library + +Remove ``annotationlib.ForwardRef._evaludate`` deprecated method. + +.. + +.. date: 2026-05-07-21-58-17 +.. gh-issue: 149388 +.. nonce: DDBPeA +.. section: Library + +Make :class:`!asyncio.windows_utils.PipeHandle` closing idempotent. + +.. + +.. date: 2026-05-07-17-35-47 +.. gh-issue: 149499 +.. nonce: G2ER-R +.. section: Library + +Removed the :func:`!sysconfig.expand_makefile_vars` function which has been +deprecated since Python 3.14. Use the ``vars`` argument of +:func:`sysconfig.get_paths` instead. + +.. + +.. date: 2026-05-07-14-18-47 +.. gh-issue: 149489 +.. nonce: bX9iHe +.. section: Library + +Fix :mod:`~xml.etree.ElementTree` serialization to HTML. The content of +comments, processing instructions and elements "xmp", "iframe", "noembed", +"noframes", and "plaintext" is no longer escaped. The "plaintext" element no +longer have the closing tag. Add support of empty attributes (with value +``None``). + +.. + +.. date: 2026-05-06-23-13-40 +.. gh-issue: 149319 +.. nonce: PLM93t +.. section: Library + +The :mod:`asyncio` REPL now ignores :envvar:`PYTHONSTARTUP` and +:envvar:`PYTHON_BASIC_REPL` when :option:`-E` or :option:`-I` is used. Patch +by Jonathan Dung. + +.. + +.. date: 2026-05-06-20-10-44 +.. gh-issue: 149464 +.. nonce: 3mPhcr +.. section: Library + +Add :func:`os.pidfd_getfd` for duplicating a file descriptor from another +process via a pidfd. Available on Linux 5.6+. Patch by Maurycy +Pawłowski-Wieroński. + +.. + +.. date: 2026-04-29-08-10-17 +.. gh-issue: 149056 +.. nonce: jnaD4W +.. section: Library + +Fix :func:`json.load` not forwarding the *array_hook* argument to +:func:`json.loads`. Patch by Thomas Kowalski. + +.. + +.. date: 2026-04-27-11-12-00 +.. gh-issue: 149046 +.. nonce: 74shDd +.. section: Library + +:mod:`io`: Fix :class:`io.StringIO` serialization: no longer call +``str(obj)`` on :class:`str` subclasses. Patch by Thomas Kowalski. + +.. + +.. date: 2026-04-26-11-25-38 +.. gh-issue: 118158 +.. nonce: xIy05H +.. section: Library + +Ensure py_compile CLI error messages end with a newline. Contributed by Xiao +Yuan. + +.. + +.. date: 2026-04-24-19-54-00 +.. gh-issue: 148954 +.. nonce: v1 +.. section: Library + +Fix XML injection vulnerability in :func:`xmlrpc.client.dumps` where the +``methodname`` was not being escaped before interpolation into the XML body. + +.. + +.. date: 2026-04-23-12-50-15 +.. gh-issue: 148441 +.. nonce: zvpCkR +.. section: Library + +:mod:`xml.parsers.expat`: prevent a crash in +:meth:`~xml.parsers.expat.xmlparser.CharacterDataHandler` when the character +data size exceeds the parser's :attr:`buffer size +`. + +.. + +.. date: 2026-04-21-06-30-59 +.. gh-issue: 119670 +.. nonce: pMWZfY +.. section: Library + +Add keyword-only parameter *force* to :func:`shlex.quote` to force quoting a +string, even if it is already safe for a shell without being quoted. + +.. + +.. date: 2026-04-20-01-24-22 +.. gh-issue: 92455 +.. nonce: vXhmad +.. section: Library + +Fix :mod:`mimetypes` to prefer case-sensitive matches for suffix mappings +and MIME type suffixes before falling back to case-insensitive matches. +Contributed by Xiao Yuan. + +.. + +.. date: 2026-04-18-12-00-00 +.. gh-issue: 148736 +.. nonce: ag-frame +.. section: Library + +Fix a latent :exc:`AttributeError` in :mod:`asyncio` call-graph capture when +walking an async generator's ``ag_await`` chain: the walker referenced +``cr_frame`` instead of ``ag_frame``. + +.. + +.. date: 2026-04-17-05-58-27 +.. gh-issue: 148665 +.. nonce: AlUajE +.. section: Library + +socket.shutdown function is now enabled for Emscripten builds. However, if +the runtime does not implement the shutdown syscall, it will show "Function +not implemented" error. + +.. + +.. date: 2026-04-04-14-25-43 +.. gh-issue: 148085 +.. nonce: o97yTo +.. section: Library + +Speed up :meth:`~datetime.date.timetuple` and +:meth:`~datetime.date.strftime` by caching the ``time.struct_time`` and +``time.strftime`` lookups, and :meth:`~datetime.datetime.today` by reading +the clock directly instead of calling :func:`time.time`. Patching +:mod:`time` after importing :mod:`datetime` no longer affects these methods. +Patch by Maurycy Pawłowski-Wieroński. + +.. + +.. date: 2026-03-31-21-25-44 +.. gh-issue: 147950 +.. nonce: 5JR0sK +.. section: Library + +Bind ``yank-arg`` to :kbd:`M-_` in the REPL. + +.. + +.. date: 2026-03-26-09-30-00 +.. gh-issue: 146452 +.. nonce: Y2N6qZ8J +.. section: Library + +Fix segfault in :mod:`pickle` when pickling a dictionary concurrently +mutated by another thread in the free-threaded build. + +.. + +.. date: 2026-03-26-00-00-00 +.. gh-issue: 47005 +.. nonce: xxc89c +.. section: Library + +Fix :meth:`!urllib.request.AbstractHTTPHandler.do_open` to give regular +headers set via :meth:`~urllib.request.Request.add_header` priority over +unredirected headers, consistent with +:meth:`~urllib.request.Request.get_header` and +:meth:`~urllib.request.Request.header_items`. + +.. + +.. date: 2026-02-22-11-27-57 +.. gh-issue: 145107 +.. nonce: ZlQXEZ +.. section: Library + +Simplify ``asyncio.staggered_race`` by using ``eager_start=False``. + +.. + +.. date: 2026-02-11-16-47-27 +.. gh-issue: 140729 +.. nonce: 2uTPQp +.. section: Library + +Fix a pickling error in the ``cProfile`` module when profiling a script that +uses :class:`multiprocessing.Process` with the ``spawn`` and ``forkserver`` +start methods. + +.. + +.. date: 2026-01-18-06-42-47 +.. gh-issue: 143988 +.. nonce: MtLtCP +.. section: Library + +Fixed crashes in :meth:`socket.socket.sendmsg` and +:meth:`socket.socket.recvmsg_into` that could occur if buffer sequences are +concurrently mutated. + +.. + +.. date: 2025-12-21-17-56-37 +.. gh-issue: 143008 +.. nonce: aakErJ +.. section: Library + +Fix crash in :class:`io.TextIOWrapper` when reentrant +:meth:`io.TextIOBase.detach` is called reentrantly from the underlying +buffer. + +.. + +.. date: 2025-12-14-06-44-34 +.. gh-issue: 81881 +.. nonce: qancdQ +.. section: Library + +:func:`shutil.copyfile` now raises :exc:`~shutil.SpecialFileError` for +sockets and device files. + +.. + +.. date: 2025-11-02-22-24-13 +.. gh-issue: 140924 +.. nonce: NQVbR_ +.. section: Library + +Add :func:`locale.localize`, :func:`locale.delocalize` and platform-specific +locale constants from the :mod:`!_locale` module to ``locale.__all__``. + +.. + +.. date: 2025-11-02-05-28-56 +.. gh-issue: 115634 +.. nonce: JbcNnF +.. section: Library + +Fix a deadlock in :class:`concurrent.futures.ProcessPoolExecutor` when using +``max_tasks_per_child``, present since the feature was introduced in Python +3.11. The executor stopped scheduling queued tasks after a worker process +exited upon reaching its task limit. Based on a fix proposed by Tabrez +Mohammed. + +.. + +.. date: 2025-10-20-09-12-18 +.. gh-issue: 140344 +.. nonce: WjbYg- +.. section: Library + +The classes ``ast.slice``, ``ast.ExtSlice``, ``ast.Index``, ``ast.Suite``, +``ast.AugLoad``, ``ast.AugStore``, and ``ast.Param``, deprecated since +Python 3.9, now issue deprecation warnings on use. They are now scheduled +for removal in Python 3.21. + +The ``dims`` property of ``ast.Tuple`` objects, deprecated since Python 3.9, +now issues a deprecation warning when accessed. The property is scheduled +for removal in Python 3.21. Use the (non-deprecated) ``elts`` property of +``ast.Tuple`` objects instead. + +The deprecated global names are also no longer imported by ``from ast import +*``. + +.. + +.. date: 2025-10-19-17-34-07 +.. gh-issue: 140326 +.. nonce: kZM0pV +.. section: Library + +Fix the :mod:`asyncio` REPL namespace so that relative imports no longer +resolve against the :mod:`asyncio` package and ``__file__`` is no longer +set. + +.. + +.. date: 2025-10-12-08-46-26 +.. gh-issue: 139398 +.. nonce: hESOMl +.. section: Library + +Add supported ``_sunder_`` names to the :func:`dir` method of the +:mod:`enum` module to support them in :term:`REPL` autocompletion. + +.. + +.. date: 2025-10-09-12-13-29 +.. gh-issue: 139819 +.. nonce: YxUDyH +.. section: Library + +:mod:`rlcompleter`: Avoid suggesting attributes that are not accessible on +instances (e.g., Enum members showing ``__name__``). Patch by Peter +(ttw225). + +.. + +.. date: 2025-09-05-20-50-35 +.. gh-issue: 79638 +.. nonce: Y-JfaH +.. section: Library + +Disallow all access in :mod:`urllib.robotparser` if the ``robots.txt`` file +is unreachable due to server or network errors. + +.. + +.. date: 2025-08-30-07-44-30 +.. gh-issue: 86533 +.. nonce: pathlib +.. section: Library + +The :func:`os.makedirs` function and :meth:`pathlib.Path.mkdir` method now +have a *parent_mode* parameter to specify the mode for intermediate +directories when creating parent directories. This allows one to match the +behavior from Python 3.6 and earlier for :func:`os.makedirs`. + +.. + +.. date: 2025-07-28-11-00-49 +.. gh-issue: 64192 +.. nonce: 7htLtg +.. section: Library + +Add the optional ``buffersize`` parameter to +:meth:`multiprocessing.pool.Pool.imap` and +:meth:`multiprocessing.pool.Pool.imap_unordered` to limit the number of +submitted tasks whose results have not yet been yielded. If the buffer is +full, iteration over the *iterables* pauses until a result is yielded from +the buffer. To fully utilize pool's capacity when using this feature, set +*buffersize* at least to the number of processes in pool (to consume +*iterable* as you go), or even higher (to prefetch the next +``N=buffersize-processes`` arguments). + +.. + +.. date: 2025-05-24-11-17-34 +.. gh-issue: 51067 +.. nonce: yHOgfy +.. section: Library + +Add :meth:`~zipfile.ZipFile.remove` and :meth:`~zipfile.ZipFile.repack` to +:class:`~zipfile.ZipFile`. + +.. + +.. date: 2025-05-19-21-08-25 +.. gh-issue: 134261 +.. nonce: ravGYm +.. section: Library + +zip: On reproducible builds, ZipFile uses UTC instead of the local time when +writing file datetimes to avoid underflows. + +.. + +.. date: 2025-05-19-20-29-35 +.. gh-issue: 133998 +.. nonce: KmElUw +.. section: Library + +Fix :exc:`struct.error` exception when creating a file with +:class:`gzip.GzipFile` or compressing data with :func:`gzip.compress` if the +system time is outside the range 00:00:00 UTC, January 1, 1970 through +06:28:15 UTC, February 7, 2106, or explicitly passed *mtime* argument is +outside the range ``0`` to ``2**32-1``. + +.. + +.. date: 2025-05-19-07-32-51 +.. gh-issue: 68164 +.. nonce: XhFbJD +.. section: Library + +Fix :func:`zipfile.ZipFile.writestr` so it sets the "regular file" bit by +default. + +.. + +.. date: 2025-05-07-18-31-31 +.. gh-issue: 46927 +.. nonce: sF02gj +.. section: Library + +Prevent :mod:`readline` from overriding the ``COLUMNS`` and ``LINES`` +environment variables, as values are not updated on terminal resize. + +.. + +.. date: 2025-05-01-16-44-16 +.. gh-issue: 72902 +.. nonce: 19qwJW +.. section: Library + +Optimize (~x1.4 speedup) :meth:`fractions.Fraction.from_decimal` and +:meth:`fractions.Fraction.from_float` for :class:`~decimal.Decimal` and +:class:`float` inputs, respectively. Patch by Sergey B Kirpichev. + +.. + +.. date: 2025-03-01-13-36-02 +.. gh-issue: 128110 +.. nonce: 9wx_G0 +.. section: Library + +Fix bug in the parsing of :mod:`email` address headers that could result in +extraneous spaces in the decoded text when using a modern email policy. +Space between pairs of adjacent :rfc:`2047` encoded-words is now ignored, +per section 6.2 (and consistent with existing parsing of unstructured +headers like *Subject*). + +.. + +.. date: 2025-01-31-02-27-53 +.. gh-issue: 129382 +.. nonce: GI93CM +.. section: Library + +The :class:`venv.EnvBuilder` and :func:`venv.create` APIs now use the +platform-dependent default for symlinks from :mod:`venv`'s command-line +interface. + +.. + +.. date: 2024-11-08-18-39-50 +.. gh-issue: 125763 +.. nonce: F2p5_U +.. section: Library + +Remove the broken spacebar quit binding from :mod:`turtledemo`\s +``sorting_animate`` example. + +.. + +.. date: 2024-11-02-02-02-31 +.. gh-issue: 107398 +.. nonce: uUtA6Q +.. section: Library + +Fix :mod:`tarfile` stream mode exception when process the file with the gzip +extra field. + +.. + +.. date: 2024-07-02-20-57-43 +.. gh-issue: 121109 +.. nonce: Tp6R2s +.. section: Library + +Fix :mod:`tarfile` performance issue when reading archives in streaming mode +(e.g. ``r|*``). + +.. + +.. date: 2024-06-18-04-08-37 +.. gh-issue: 120665 +.. nonce: x7T1hV +.. section: Library + +Fixed an issue where ``unittest`` loaders would load and instantiate +:class:`unittest.TestCase`-derived subclasses that are also abstract base +classes, which can't be instantiated. + +.. + +.. date: 2024-03-17-22-16-53 +.. gh-issue: 115988 +.. nonce: EshSDM +.. section: Library + +:mod:`lzma` adds constants to support the newer BCJ filters for ARM64 and +RISC-V. + +.. + +.. date: 2024-02-04-13-56-48 +.. gh-issue: 108518 +.. nonce: 6NCPk_ +.. section: Library + +The iterator returned by :meth:`concurrent.futures.Executor.map` is no +longer automatically closed if a function call raises an exception. Use +method :meth:`!close` to explicitly close the iterator. + +.. + +.. date: 2023-12-20-22-05-40 +.. gh-issue: 113329 +.. nonce: 1CJy3o +.. section: Library + +Fix :exc:`OSError` being raised when trying to run doctests on a class +objects in the REPL. Patch by Sten Wessel. + +.. + +.. date: 2023-06-12-21-31-02 +.. gh-issue: 105708 +.. nonce: 5fFwP8 +.. section: Library + +Accept an uppercase V prefix in IPvFuture addresses in +:func:`urllib.parse.urlsplit`. + +.. + +.. date: 2023-04-27-14-50-03 +.. gh-issue: 103925 +.. nonce: khC-El +.. section: Library + +Fix :meth:`csv.Sniffer.sniff` for a sample with ``\r\n`` line endings in +which a quoted field ends a line: a letter could be detected as the +delimiter. + +.. + +.. date: 2023-04-24-11-12-00 +.. gh-issue: 60055 +.. nonce: UjP6aX +.. section: Library + +Let ``urllib.robotparser.RobotFileParser`` accept a +``urllib.request.Request`` object as well as a url string when setting a +robots.txt url. + +.. + +.. date: 2023-03-23-19-47-05 +.. gh-issue: 102967 +.. nonce: gfIYkN +.. section: Library + +A bug in :func:`!doctest._SpoofOut.truncate` was causing None to be passed +to :func:`!StringIO.seek` when no size was given. A simple fix skips the +seek call when no size is given so the buffer can be truncated from the +current position. + +.. + +.. date: 2023-02-26-14-07-18 +.. gh-issue: 91099 +.. nonce: _QPbEL +.. section: Library + +:meth:`imaplib.IMAP4.login` now raises exceptions with :class:`str` instead +of :class:`bytes`. Patch by Florian Best. + +.. + +.. date: 2023-02-11-09-49-49 +.. gh-issue: 82039 +.. nonce: caTE7O +.. section: Library + +:meth:`http.cookiejar.FileCookieJar.load` now checks the first, format +signature line in a case-insensitive manner. Patch by Ashley Harvey. + +.. + +.. date: 2023-01-23-21-23-50 +.. gh-issue: 101267 +.. nonce: _f-cFH +.. section: Library + +When a worker process terminates unexpectedly, +:class:`concurrent.futures.ProcessPoolExecutor` now sets a separate +:exc:`~concurrent.futures.process.BrokenProcessPool` exception on each +pending future instead of sharing a single instance among them all. Sharing +one exception produced malformed tracebacks: each :meth:`Future.result() +` call re-raised the same object, +appending another copy of the traceback to it. + +.. + +.. bpo: 46375 +.. date: 2022-04-10-20-10-59 +.. nonce: 8j1ogZ +.. section: Library + +Add :meth:`io.BytesIO.peek` method to read without advancing position. + +.. + +.. bpo: 47216 +.. date: 2022-04-04-17-58-05 +.. nonce: gPyPte +.. section: Library + +Added *mtime* option to :func:`gzip.open`, which will be passed to the +constructor of :class:`~gzip.GzipFile`. + +.. + +.. date: 2022-01-03-12-50-42 +.. gh-issue: 70758 +.. nonce: 2NjFW_ +.. section: Library + +Creating a new :mod:`turtle` screen after the previous one was closed no +longer raises ``turtle.Terminator`` on the first turtle command. + +.. + +.. bpo: 45509 +.. date: 2021-10-18-13-46-55 +.. nonce: Upwb60 +.. section: Library + +Gzip headers are now checked for corrupted NAME, COMMENT and HCRC fields. + +.. + +.. date: 2021-09-09-10-15-54 +.. gh-issue: 75245 +.. nonce: tLeTkn +.. section: Library + +:meth:`socket.socket.makefile` now supports line buffering (``buffering=1``) +in text mode, as :func:`open` does and as it worked in Python 2. Previously +it silently used block buffering. In binary mode it now emits a +:exc:`RuntimeWarning` and uses the default buffer size, also as :func:`open` +does. + +.. + +.. bpo: 44012 +.. date: 2021-06-03-22-23-38 +.. nonce: BK3HfA +.. section: Library + +The ``exploded`` attribute of :class:`ipaddress.IPv6Address` and +:class:`ipaddress.IPv6Interface` now supports addresses with a scope ID +(link-local addresses). Previously the former raised +:exc:`~ipaddress.AddressValueError` and the latter omitted the scope ID. + +.. + +.. bpo: 40469 +.. date: 2021-02-26-13-17-57 +.. nonce: yJHeQg +.. section: Library + +:class:`~logging.handlers.TimedRotatingFileHandler` now uses the creation +time instead of the last modification time of an existing log file as the +basis for the first rotation after handler creation, if supported by the OS +and file system. This allows it to be used in short-running programs that +start and end before the rotation interval expires. + +.. + +.. bpo: 42861 +.. date: 2021-01-09-18-40-15 +.. nonce: T7Ge9O +.. section: Library + +Add :meth:`IPv4Network.next_network() ` +and :meth:`IPv6Network.next_network() `. +Patch by Faisal Mahmood. + +.. + +.. date: 2020-05-05-06-05-24 +.. gh-issue: 84687 +.. nonce: ggjoGl +.. section: Library + +The :func:`os.exec\* ` functions now set the +:attr:`~OSError.filename` attribute of the raised :exc:`FileNotFoundError` +or :exc:`NotADirectoryError` to the program name passed by the caller. + +.. + +.. date: 2020-02-19-16-35-52 +.. gh-issue: 83869 +.. nonce: EPD_zn +.. section: Library + +Fix :mod:`tarfile` reading an archive with a GNU sparse 1.0 member whose +size is set in the pax extended header. The offset of the next header was +computed from the offset of the data, which is already past the sparse map, +and from the size of the member, which can be the apparent size of the +sparse file. All following members were unreachable. + +.. + +.. date: 2019-02-08-17-33-49 +.. gh-issue: 61366 +.. nonce: k6W5Sp +.. section: Library + +:class:`http.cookiejar.MozillaCookieJar` now reads session cookies written +by curl and Wget, which use ``0`` in the expiration time field. Contributed +by Jérémie Detrey. + +.. + +.. date: 2026-09-24-10-10-15 +.. gh-issue: 57491 +.. nonce: UA-2uN +.. section: Documentation + +Reduce the depth of the table of contents in the EPUB documentation from +three levels to two, making it much shorter and easier to navigate in e-book +readers. + +.. + +.. date: 2026-09-24-01-20-36 +.. gh-issue: 142083 +.. nonce: WOlkvr +.. section: Documentation + +Document the ``'w'`` type code in the :class:`array.array` docstring, so +that it lists the same type codes as :data:`array.typecodes` and the +:mod:`array` module documentation. + +.. + +.. date: 2026-07-17-22-33-43 +.. gh-issue: 118150 +.. nonce: m7iFdP +.. section: Documentation + +Clarify in the :mod:`difflib` documentation what *junk* actually does, its +drawbacks, and how to control it. + +.. + +.. date: 2026-06-18-16-58-52 +.. gh-issue: 59551 +.. nonce: oNkjTG +.. section: Documentation + +Rename Doc/library/dialog.rst to tkinter.dialogs.rst. + +.. + +.. date: 2026-06-17-12-00-00 +.. gh-issue: 86726 +.. nonce: __bOgH +.. section: Documentation + +Greatly expand the :mod:`tkinter` documentation to cover the full public API +of the package and its submodules. The descriptions are oriented towards +Python rather than Tcl/Tk, with corrected return types and +``versionadded``/``versionchanged`` information. + +.. + +.. date: 2026-05-23-17-27-41 +.. gh-issue: 150319 +.. nonce: ol9tWK +.. section: Documentation + +Generic builtin and standard library types now document the meaning of their +type parameters. + +.. + +.. date: 2023-09-16-23-42-27 +.. gh-issue: 109503 +.. nonce: mZ-kdU +.. section: Documentation + +Fix documentation for :func:`shutil.move` on usage of :func:`os.rename` +since nonatomic move might be used even if the files are on the same +filesystem. Patch by Fang Li + +.. + +.. date: 2026-10-12-11-26-01 +.. gh-issue: 159211 +.. nonce: FWFj-p +.. section: Tests + +The iOS testbed no longer gathers simulator diagnostics when a test run +fails. + +.. + +.. date: 2026-09-24-10-40-28 +.. gh-issue: 158051 +.. nonce: B1ZBTA +.. section: Tests + +The iOS testbed has been updated for compatibilty with Xcode 27. + +.. + +.. date: 2026-09-16-17-06-54 +.. gh-issue: 157628 +.. nonce: KAwhlY +.. section: Tests + +In regrtest, only consider that a test leaks if all test runs leak at least +one file descriptor. For example, ignore "[0, 1, -1] file descriptors, +sum=0" deltas, instead of reporting a leak. Patch by Victor Stinner. + +.. + +.. date: 2026-09-14-14-50-42 +.. gh-issue: 140550 +.. nonce: 7jirEN +.. section: Tests + +Enable limited C API tests on Free Threading in test_cext and test_cppext: +test the :c:macro:`Py_TARGET_ABI3T` macro. Patch by Victor Stinner. + +.. + +.. date: 2026-08-18-19-40-22 +.. gh-issue: 75876 +.. nonce: IOiCcK +.. section: Tests + +In verbose mode, a test decorated with :func:`~test.support.bigmemtest` now +reports how much memory it really used, and the number of major page faults +it took, if any. + +.. + +.. date: 2026-08-18-10-16-44 +.. gh-issue: 75876 +.. nonce: PEZplM +.. section: Tests + +A test decorated with :func:`~test.support.bigmemtest` now runs in a +subprocess if it really allocates the memory it asks for (that is, if the +``-M`` option is used), so that the memory it uses and the address space it +fragments are released when it ends. A dummy run stays in the process. The +separate memory watchdog process is no longer needed: the parent process +watches the memory usage of the subprocess. + +.. + +.. date: 2026-08-12-20-52-16 +.. gh-issue: 109817 +.. nonce: GZHUNg +.. section: Tests + +Add the ``--single-process-per-case`` option to libregrtest to run every +test case in a separate process. Test cases from the same test module are +run sequentially. This helps to detect order dependencies and environment +leaks between test cases. + +.. + +.. date: 2026-08-09-14-00-00 +.. gh-issue: 155411 +.. nonce: Qw8Lm2 +.. section: Tests + +Fix :func:`!test.support.subTests` for asynchronous test methods. They were +wrapped in a synchronous function, which discarded the coroutine without +awaiting it, so the test silently did not run at all. + +.. + +.. date: 2026-08-08-09-15-08 +.. gh-issue: 108885 +.. nonce: Qm3vLp +.. section: Tests + +Running the Python test suite with ``-vv`` now reports every example of a +doctest. A single ``-v`` reports the test names, as before. + +.. + +.. date: 2026-08-06-18-20-00 +.. gh-issue: 132581 +.. nonce: envchg +.. section: Tests + +The list of tests which altered the execution environment now includes the +reasons why the environment was considered altered, for example an +unraisable exception or a modified :data:`sys.path`. The final result no +longer repeats the same state twice (like ``ENV CHANGED then ENV CHANGED``). + +.. + +.. date: 2026-08-03-20-15-00 +.. gh-issue: 155109 +.. nonce: limstack +.. section: Tests + +Add ``test.support.run_with_limited_c_stack()`` and use it in tests that +exhaust the C stack with a fixed number of recursive calls, so that their +outcome no longer depends on the C stack size. + +.. + +.. date: 2026-07-24-12-00-00 +.. gh-issue: 76595 +.. nonce: KfF5xR +.. section: Tests + +Add C API tests for :c:func:`PyCapsule_Import`. + +.. + +.. date: 2026-07-20-11-30-00 +.. gh-issue: 154211 +.. nonce: hugestack +.. section: Tests + +Add ``test.support.skip_if_huge_c_stack()`` and use it to skip tests that +exhaust the C stack if the stack limit is very large (e.g. on DragonFly BSD +or with ``ulimit -s unlimited``). + +.. + +.. date: 2026-07-19-20-15-00 +.. gh-issue: 154167 +.. nonce: sigint +.. section: Tests + +The test runner (regrtest) now restores the default SIGINT handler if it was +inherited as ignored, so the test suite no longer hangs when run as a shell +background job. + +.. + +.. date: 2026-07-19-18-20-00 +.. gh-issue: 154144 +.. nonce: tcbool +.. section: Tests + +Fix building the :mod:`!_testcapi` module on NetBSD. + +.. + +.. date: 2026-07-19-15-59-41 +.. gh-issue: 154137 +.. nonce: N689bE +.. section: Tests + +Check for Windows handle leaks in regrtest. Patch by Victor Stinner. + +.. + +.. date: 2026-06-29-10-14-09 +.. gh-issue: 152548 +.. nonce: Khw9J7 +.. section: Tests + +Add the :func:`test.support.isolation.runInSubprocess` decorator to run a +test method or ``TestCase`` subclass in a fresh interpreter subprocess, +isolated from the rest of the test run. + +.. + +.. date: 2026-06-22-19-45-00 +.. gh-issue: 151626 +.. nonce: K9pZ2x +.. section: Tests + +Fix several tests in ``test.test_inspect``, ``test.test_import``, +``test.test_importlib``, ``test.test_py_compile`` and +``test.test_compileall`` that failed when the test suite was run with +:envvar:`PYTHONPYCACHEPREFIX` set. These tests now neutralize the pycache +prefix where they assume the default ``__pycache__`` bytecode layout. + +.. + +.. date: 2026-06-16-05-11-38 +.. gh-issue: 151096 +.. nonce: Kq3Lp9 +.. section: Tests + +Fix ``test_embed`` failing when CPython is configured with a split exec +prefix (``--exec-prefix`` differing from ``--prefix``). + +.. + +.. date: 2026-06-09-11-52-52 +.. gh-issue: 151130 +.. nonce: 1vslPH +.. section: Tests + +Add more tests for ``PyWeakref_*`` C API. + +.. + +.. date: 2026-06-06-16-22-00 +.. gh-issue: 150966 +.. nonce: 7N9x5Q +.. section: Tests + +Avoid prematurely terminating failing live sampling profiler test targets, +which made stderr assertions flaky on ASAN buildbots. + +.. + +.. date: 2026-05-25-15-39-53 +.. gh-issue: 150387 +.. nonce: yzZ7jq +.. section: Tests + +Fix hang in +``test.test_profiling.test_sampling_profiler.test_live_collector_ui.TestLiveModeErrors.test_run_failed_script_live`` +on slow buildbots. The test now always queues a final ``q`` keystroke so the +live TUI loop exits even when the profiler collects enough samples to enter +the post-finished input loop. + +.. + +.. date: 2026-05-22-16-41-45 +.. gh-issue: 150114 +.. nonce: UdMikH +.. section: Tests + +On Linux, regrtest now logs the total memory usage of all Python processes. +Read the private memory in ``/proc/pid/smaps``. Patch by Victor Stinner. + +.. + +.. date: 2026-05-13-14-53-23 +.. gh-issue: 149776 +.. nonce: orqgsn +.. section: Tests + +Fix test_socket on Linux kernel 7.1 and newer: skip UDP Lite tests if it's +not supported. Patch by Victor Stinner. + +.. + +.. date: 2026-04-24-01-38-56 +.. gh-issue: 148853 +.. nonce: _uM4_Q +.. section: Tests + +Fix tests failing on FreeBSD in test.support's +in_systemd_nspawn_sync_suppressed() due to unreadable /run directory. + +.. + +.. date: 2026-01-21-02-03-31 +.. gh-issue: 142414 +.. nonce: CfcgiR +.. section: Tests + +Isolate reloading modules in test_interpreters to avoid having broken +references. + +.. + +.. date: 2026-10-05-12-15-57 +.. gh-issue: 158878 +.. nonce: KWLqLy +.. section: Build + +Stop creating an empty Modules/Setup.local file as it no longer seems to be +required to statically link the extension modules. + +.. + +.. date: 2026-10-03-23-23-12 +.. gh-issue: 158683 +.. nonce: eMlp60 +.. section: Build + +Fix the :file:`Modules/Setup` entry for the :mod:`!_zstd` module by adding +missing source files. + +.. + +.. date: 2026-10-02-12-18-20 +.. gh-issue: 129040 +.. nonce: 6wJPY6 +.. section: Build + +Added support for function call adaptor trampolines for wasi to prevent +traps when C handlers take the wrong number of arguments. Dropped Emscripten +function call adaptors support for JS runtimes that don't support wasm-gc. + +.. + +.. date: 2026-09-29-09-40-25 +.. gh-issue: 158010 +.. nonce: H4Top_ +.. section: Build + +Update Android and iOS build scripts to use OpenSSL 3.5.9. + +.. + +.. date: 2026-09-21-19-20-42 +.. gh-issue: 136872 +.. nonce: a2tSc_ +.. section: Build + +Python built with :option:`--with-address-sanitizer` or +:option:`--with-memory-sanitizer` now includes pymalloc, but uses ``malloc`` +as the default memory allocator. Set :envvar:`PYTHONMALLOC=pymalloc +` to use pymalloc. + +.. + +.. date: 2026-09-21-10-50-31 +.. gh-issue: 157923 +.. nonce: OffPYn +.. section: Build + +Support WASI SDK 34. + +.. + +.. date: 2026-09-19-16-54-58 +.. gh-issue: 157549 +.. nonce: uk6QNH +.. section: Build + +Use ``sysconf(_SC_PAGESIZE)`` instead of ``getpagesize()`` in +``remote_debug.h`` so ``_remote_debugging`` builds on Darwin with +``-Werror=implicit-function-declaration``. + +.. + +.. date: 2026-09-07-23-40-00 +.. gh-issue: 157142 +.. nonce: gpnoop +.. section: Build + +Fix the link of ``Programs/_freeze_module`` when extension modules are built +in (``MODULE_BUILDTYPE=static``) and the test modules are enabled: +``Modules/getpath_noop.c`` now defines ``_Py_Get_Getpath_CodeObject()``, +which ``_testinternalcapi`` uses. + +.. + +.. date: 2026-09-07-15-13-19 +.. gh-issue: 155292 +.. nonce: _WNxL7 +.. section: Build + +In ``makeunicodedata.py``, the script for updating Unicode data, skip +generating ``stringprep.py`` if the current interpreter's Unicode data +version does not match the target version. + +.. + +.. date: 2026-08-31-15-50-04 +.. gh-issue: 156049 +.. nonce: FCf6hP +.. section: Build + +Add :option:`--with-hwaddress-sanitizer` to build with `HWAddressSanitizer +`_. + +.. + +.. date: 2026-08-29-15-14-45 +.. gh-issue: 156554 +.. nonce: 64SZb1 +.. section: Build + +Update ``PY_SUPPORT_TIER`` according to :pep:`11` for these target triples: +``aarch64-*-linux-gnu/gcc``, ``aarch64-pc-windows-msvc/msvc``, +``x86_64-apple-darwin*/clang``, and ``powerpc64le-*-linux-gnu/gcc``. + +.. + +.. date: 2026-08-23-12-10-45 +.. gh-issue: 156244 +.. nonce: Rv6qXt +.. section: Build + +Update :program:`configure` to reflect that the +``riscv64-unknown-linux-gnu`` target triple is now a :pep:`11` tier 3 +supported platform. + +.. + +.. date: 2026-08-20-17-41-11 +.. gh-issue: 155911 +.. nonce: yL3z8q +.. section: Build + +Fix curses detection with libraries in ``LIBS`` and +:option:`--without-curses`. Patch by Shamil Abdulaev. + +.. + +.. date: 2026-08-20-14-02-33 +.. gh-issue: 156115 +.. nonce: KXr8wU +.. section: Build + +iOS simulator builds are now configured with ``-mios-simulator-version-min`` +instead of the device's ``-mios-version-min``. The device flag made the +linker reject libraries resolved from the simulator SDK, so library +detection silently failed. + +.. + +.. date: 2026-08-20-13-32-54 +.. gh-issue: 156109 +.. nonce: ZTJHi9 +.. section: Build + +iOS builds may now be configured without a framework, producing a static +``libpython`` for embedding in an app binary. Such a build cannot load +extension modules at runtime, and requires ``MODULE_BUILDTYPE=static`` and +``--disable-test-modules`` to be requested explicitly. A shared iOS build +must still be a framework build. + +.. + +.. date: 2026-08-14-20-16-55 +.. gh-issue: 153400 +.. nonce: 9Oxi-N +.. section: Build + +Support os.getrandom() when building Python with old glibc versions and +recent Linux kernel (glibc 2.25 or older and Linux kernel 3.17 or newer). +Get the syscall number from kernel headers, rather than glibc headers. + +.. + +.. date: 2026-08-10-12-00-00 +.. gh-issue: 90604 +.. nonce: Kx7pQn +.. section: Build + +``configure`` no longer sets ``MULTIARCH`` on OpenBSD platforms. + +.. + +.. date: 2026-08-02-12-00-01 +.. gh-issue: 152023 +.. nonce: pT7dKb +.. section: Build + +Update Android builds to SQLite 3.53.4. Additionally, enable the +``median()`` and ``percentile()`` functions. + +.. + +.. date: 2026-07-20-20-30-00 +.. gh-issue: 154271 +.. nonce: solxopen +.. section: Build + +Define ``_XOPEN_SOURCE=600`` on Solaris and illumos, so that on illumos the +socket module is built with :meth:`~socket.socket.sendmsg`, +:meth:`~socket.socket.recvmsg` and the ``CMSG_*`` helpers. This also +enables the ``forkserver`` :mod:`multiprocessing` start method. + +.. + +.. date: 2026-07-19-16-45-00 +.. gh-issue: 154136 +.. nonce: mathpi +.. section: Build + +Fix building the :mod:`math` module on FreeBSD. Define ``_ISOC23_SOURCE`` to +make the C23 library declarations (such as ``sinpi()`` in ``math.h``) +visible. + +.. + +.. date: 2026-07-19-12-16-31 +.. gh-issue: 154070 +.. nonce: f5da07 +.. section: Build + +Build the :mod:`curses` module against a wide-character capable ncurses even +when it is not named ``ncursesw`` -- for example the pkgsrc ncurses on +NetBSD and illumos, or the system ncurses on macOS. Such a library +previously produced a narrow build. + +.. + +.. date: 2026-07-19-12-06-45 +.. gh-issue: 152902 +.. nonce: 0BXdab +.. section: Build + +Added Intel ``icx`` compiler support to ``configure.ac``. Contributed by +High Performance Kernels LLC. + +.. + +.. date: 2026-07-19-07-48-43 +.. gh-issue: 154055 +.. nonce: FemUJU +.. section: Build + +The :mod:`curses` and :mod:`curses.panel` modules can now be built against a +curses library that lacks the X/Open ``attr_t`` and soft-label attribute +functions, ``scr_set()`` or ``resizeterm()`` -- such as the native SVr4 +curses of illumos and Solaris. These functions are probed and used only +when present. + +.. + +.. date: 2026-07-18-14-30-12 +.. gh-issue: 136687 +.. nonce: teaPCG +.. section: Build + +Add the :option:`--with-curses` option to :program:`configure` to select the +curses backend (``ncursesw``, ``ncurses`` or the system's native ``curses``) +or, as :option:`--without-curses`, to exclude the :mod:`curses` and +:mod:`curses.panel` modules from the build. + +.. + +.. date: 2026-07-11-07-26-16 +.. gh-issue: 126877 +.. nonce: Zt7Kq2 +.. section: Build + +Fix the :program:`configure` check for Tcl/Tk which could wrongly succeed +with optimizing compilers when the libraries are missing. + +.. + +.. date: 2026-07-10-13-25-55 +.. gh-issue: 153511 +.. nonce: dCPBwU +.. section: Build + +Removes the legacy MSI and Nuget build scripts, the legacy ``py.exe`` +launcher (now replaced by the Python install manager), and adds a +``PC/layout`` readme. + +.. + +.. date: 2026-07-09-22-45-00 +.. gh-issue: 153438 +.. nonce: Qr7N2p +.. section: Build + +Update Windows build and installer tooling and documentation to use the +current download URL for ``nuget.exe``. + +.. + +.. date: 2026-07-02-16-25-13 +.. gh-issue: 152870 +.. nonce: oh9eD1 +.. section: Build + +Fix a compilation error in the :mod:`decimal` C extension (``_decimal``) +when it is built with ``EXTRA_FUNCTIONALITY``. ``Context.apply()`` called +the internal ``_apply`` helper using its pre-Argument-Clinic signature; the +call is now made through the generated ``_impl`` function. + +.. + +.. date: 2026-07-01-17-53-00 +.. gh-issue: 152769 +.. nonce: Kp7mQ2 +.. section: Build + +Enable the :ref:`perf profiler ` trampoline on Alpine Linux +with the musl C library on ``x86_64`` and ``aarch64``. The trampoline is +architecture-specific and does not depend on the C library, so the same +assembly trampoline used for glibc is reused for musl. + +.. + +.. date: 2026-06-28-16-17-55 +.. gh-issue: 152502 +.. nonce: 6SNqMg +.. section: Build + +The :mod:`curses` module now detects its optional functions with +:program:`configure` capability probes instead of assuming ncurses, so it +builds against narrow (non-wide) ncurses and other curses implementations +such as NetBSD curses, exposing exactly the functions they provide. + +.. + +.. date: 2026-06-26-16-30-00 +.. gh-issue: 152240 +.. nonce: loongarch +.. section: Build + +Fix C stack unwinding tests on Linux LoongArch builds by teaching the manual +frame pointer unwinder to recognize the LoongArch frame layout. + +.. + +.. date: 2026-06-09-11-54-13 +.. gh-issue: 151163 +.. nonce: vFAtjv +.. section: Build + +Updated Android build to include SQLite version 3.53.2. + +.. + +.. date: 2026-05-27-14-28-36 +.. gh-issue: 115119 +.. nonce: wotFWh +.. section: Build + +Fix the detection of libmpdec header when no .pc files are available. + +.. + +.. date: 2026-05-21-15-14-59 +.. gh-issue: 148294 +.. nonce: VtFaW4 +.. section: Build + +Corrected the use of ``AC_PATH_TOOL`` in ``configure.ac`` to allow a C++ +compiler to be found on :envvar:`!PATH`. + +.. + +.. date: 2026-05-19-12-45-23 +.. gh-issue: 131372 +.. nonce: oJykeB +.. section: Build + +Add a :option:`--with-build-details-suffix` configure flag to allow Linux +distributions that co-install multiple versions of Python in the same tree +to avoid ``build-details.json`` clashes. + +.. + +.. date: 2026-05-18-16-00-41 +.. gh-issue: 148260 +.. nonce: UwFiIX +.. section: Build + +On Linux when Python is linked to the musl C library, use a thread stack +size of at least 1 MiB instead of musl default which is 128 kiB. Patch by +Victor Stinner. + +.. + +.. date: 2026-04-21-17-27-52 +.. gh-issue: 148832 +.. nonce: Kx9aQ1 +.. section: Build + +Fix :option:`--enable-bolt` build by switching the default BOLT flag from +``-icf=1`` to ``-icf=0``. ``-icf=1`` folds address-taken functions and +breaks type-slot dispatch, crashing on :mod:`list` and :mod:`tuple` +concatenation. Patched by Shamil Abdulaev. + +.. + +.. date: 2026-03-11-17-23-39 +.. gh-issue: 144712 +.. nonce: fix-jit-entry +.. section: Build + +Fix ``_testinternalcapi`` import failure due to missing ``_Py_jit_entry`` +symbol when built with :option:`--enable-experimental-jit`. Patch by Shamil +Abdulaev. + +.. + +.. date: 2026-03-07-02-09-57 +.. gh-issue: 138800 +.. nonce: VD8qbz +.. section: Build + +Fix library name in python3.pc on Android. + +.. + +.. date: 2025-09-25-01-33-12 +.. gh-issue: 139314 +.. nonce: _m9BUl +.. section: Build + +Add the :option:`--with-zlib` and :option:`--with-bzip2` +:program:`configure` options to select the zlib and bzip2 implementations +used to build the :mod:`zlib` and :mod:`bz2` modules. In addition to the +default system libraries, they can build against `zlib-rs +`__ and `libbzip2-rs +`__, and +``--with-zlib=zlib-ng`` verifies that the detected zlib is `zlib-ng +`__. :option:`--without-zlib` and +:option:`--without-bzip2` exclude the modules from the build. + +.. + +.. date: 2025-05-13-12-38-26 +.. gh-issue: 115119 +.. nonce: 7n0nx3 +.. section: Build + +Removed bundled copy of the libmpdec, use system library if it's available. +Patch by Sergey B Kirpichev. + +.. + +.. date: 2026-09-29-09-56-14 +.. gh-issue: 158010 +.. nonce: MPQX4w +.. section: Windows + +Updated Windows builds to use OpenSSL 3.5.9. + +.. + +.. date: 2026-09-21-20-54-37 +.. gh-issue: 157906 +.. nonce: RlyLkY +.. section: Windows + +Fix an incorrect architecture macro check that prevented CPU prefetching in +the free-threaded garbage collector on 32-bit Windows builds. + +.. + +.. date: 2026-09-19-13-18-48 +.. gh-issue: 157789 +.. nonce: o6-rmo +.. section: Windows + +Use compiler option ``-Og`` in case of clang-cl debug builds on Windows to +reduce stack usage. Patch by Chris Eibl. + +.. + +.. date: 2026-09-12-18-59-21 +.. gh-issue: 157368 +.. nonce: 2DirHP +.. section: Windows + +Fix truncated :data:`sys.version` in the case of clang-cl versions 22 or +newer on Windows. Also fixes the Windows on Arm case, where the Microsoft +compiler was reported instead of clang. Patch by Chris Eibl. + +.. + +.. date: 2026-09-10-02-00-00 +.. gh-issue: 157212 +.. nonce: x18TEB +.. section: Windows + +Fix ``_Py_ThreadId()`` compilation on Windows ARM64 with MinGW toolchains, +where ``__getReg()`` is unavailable. The TEB address is now read directly +from ``x18``. Patch by Christian Aurich. + +.. + +.. date: 2026-09-05-10-14-50 +.. gh-issue: 152433 +.. nonce: _LtjIg +.. section: Windows + +Allow build :mod:`socket` module for Universal Windows Platform. + +.. + +.. date: 2026-08-09-17-30-00 +.. gh-issue: 68048 +.. nonce: Mq8Vd4 +.. section: Windows + +Creating a :class:`mmap.mmap` object on Windows no longer resets the +position of the underlying file to zero, as on other platforms. + +.. + +.. date: 2026-08-09-15-40-00 +.. gh-issue: 85470 +.. nonce: Lm4Xt9 +.. section: Windows + +Importing :mod:`ctypes` on Windows no longer loads ``user32.dll``, which +made the system treat the process as a GUI process and stop sending logoff +and shutdown console control events to it. ``ole32.dll``, which pulled +``user32.dll`` in, is now delay loaded. + +.. + +.. date: 2026-08-09-14-20-00 +.. gh-issue: 72353 +.. nonce: Vw7Kq2 +.. section: Windows + +Reading from the console on Windows now continues if the read was cancelled +by Ctrl+C, but the :const:`~signal.SIGINT` handler did not raise an +exception. Previously the read ended as if at end of file. + +.. + +.. date: 2026-08-09-05-30-00 +.. gh-issue: 86427 +.. nonce: legacystdio +.. section: Windows + +Fix the encoding of the standard streams in the legacy Windows stdio mode +(:envvar:`PYTHONLEGACYWINDOWSSTDIO`). It is now the encoding of the device +the stream is connected to, as in Python 3.7, not the ANSI code page. + +.. + +.. date: 2026-08-09-04-00-00 +.. gh-issue: 87587 +.. nonce: devenc +.. section: Windows + +:func:`os.device_encoding` on Windows now returns the code page of any +console file descriptor, not only 0, 1 and 2, and returns ``None`` for other +character devices like ``NUL``. The UTF-8 code page is now reported as +``"utf-8"`` instead of ``"cp65001"``. + +.. + +.. date: 2026-08-02-12-00-00 +.. gh-issue: 152023 +.. nonce: wXn4Qs +.. section: Windows + +Update Windows builds to SQLite 3.53.4. Additionally, enable the +``median()`` and ``percentile()`` functions. + +.. + +.. date: 2026-07-31-18-40-43 +.. gh-issue: 152433 +.. nonce: Pq3-U- +.. section: Windows + +Changed :mod:`!winreg` to conditional import for Universal Windows Platform +compatibility. + +.. + +.. date: 2026-07-21-10-42-18 +.. gh-issue: 69573 +.. nonce: Kv7QpX +.. section: Windows + +:func:`msvcrt.putch` and :func:`msvcrt.putwch` now check the return value of +the underlying ``_putch()`` and ``_putwch()`` C functions and raise +:exc:`OSError` on failure, for example when the process has no console +attached, instead of silently ignoring the error. + +.. + +.. date: 2026-07-18-11-56-53 +.. gh-issue: 124111 +.. nonce: m4OBX8 +.. section: Windows + +Updated Windows builds to use Tcl/Tk 9.0.4. + +.. + +.. date: 2026-07-17-16-21-17 +.. gh-issue: 152433 +.. nonce: 45rR2A +.. section: Windows + +Modernize fileutils removing GetFileInformationByHandle API calls and allow +build for Universal Windows Platform. + +.. + +.. date: 2026-07-04-20-12-24 +.. gh-issue: 152433 +.. nonce: NtWEoL +.. section: Windows + +Allow build ``ceval.c`` for Windows UWP. + +.. + +.. date: 2026-07-04-18-57-47 +.. gh-issue: 152433 +.. nonce: tO5k5t +.. section: Windows + +Allow build :mod:`!_overlapped` module for Universal Windows Platform. + +.. + +.. date: 2026-07-03-17-07-40 +.. gh-issue: 152433 +.. nonce: Lc6HmG +.. section: Windows + +``_winapi`` module: improve UWP compatibility + +.. + +.. date: 2026-07-01-17-31-05 +.. gh-issue: 152433 +.. nonce: dod-DF +.. section: Windows + +make ``dynload_win.c`` UWP compatible. + +.. + +.. date: 2026-07-01-17-00-52 +.. gh-issue: 152433 +.. nonce: kSd1bW +.. section: Windows + +Allow build :mod:`!_ctypes` for Universal Windows Platform. + +.. + +.. date: 2026-07-01-16-38-24 +.. gh-issue: 152433 +.. nonce: jvEiHh +.. section: Windows + +:mod:`ssl`: improve UWP build compatibility. + +.. + +.. date: 2026-06-30-16-40-00 +.. gh-issue: 152433 +.. nonce: VaeEwR +.. section: Windows + +``_winapi``: implement ``GetVersion()`` UWP alternative. + +.. + +.. date: 2026-06-29-17-17-10 +.. gh-issue: 152433 +.. nonce: AhW--j +.. section: Windows + +Fix errors in :func:`sys.getwindowsversion` for Universal Windows Platform +build. + +.. + +.. date: 2026-06-29-16-29-50 +.. gh-issue: 152433 +.. nonce: _nhCjt +.. section: Windows + +Restores the ``mmap`` module when CPython is built from source for specific +Windows API sets. + +.. + +.. date: 2026-06-28-13-03-57 +.. gh-issue: 152433 +.. nonce: jUXFwC +.. section: Windows + +Use the Windows API ``GetFileSizeEx()`` for memory mapped files, rather than +the older ``GetFileSize()``. + +.. + +.. date: 2026-06-28-12-37-08 +.. gh-issue: 152433 +.. nonce: FTMgqF +.. section: Windows + +Implement :func:`os.cpu_count` for Universal Windows Platform. + +.. + +.. date: 2026-06-09-11-55-41 +.. gh-issue: 151163 +.. nonce: oizZYV +.. section: Windows + +Updated Windows builds to include SQLite version 3.53.2. + +.. + +.. date: 2026-06-04-18-53-18 +.. gh-issue: 150836 +.. nonce: Wci7bZ +.. section: Windows + +Make installed tkinter work with Tcl/Tk 9 builds that embed the Tk script +library in the Tk DLL on Windows. + +.. + +.. date: 2026-05-14-22-09-46 +.. gh-issue: 149786 +.. nonce: UI-HZM +.. section: Windows + +Fixes virtual environment launchers on Windows free-threaded builds. + +.. + +.. date: 2026-04-29-14-44-51 +.. gh-issue: 138489 +.. nonce: 234aj6 +.. section: Windows + +Windows distributions now include a :file:`build-details.json` file (see +:pep:`739`). The legacy installer does not install it, but all other +distributions from python.org and all preset configurations in the +``PC\layout`` script will include one. + +.. + +.. date: 2026-04-21-16-07-11 +.. gh-issue: 140146 +.. nonce: TAcUHA +.. section: Windows + +Prevent :mod:`tkinter` from hanging on Windows if stdin is redirected to a +pipe in an interactive session. This is helpful for testing interactive +usage of tkinter from a script, for example as part of the cpython test +suite. + +.. + +.. date: 2025-04-29-17-55-55 +.. gh-issue: 86768 +.. nonce: uIDTHc +.. section: Windows + +:func:`os.lseek` and :meth:`~io.IOBase.seek` of file objects now raise +:exc:`OSError` for pipes on Windows, and :meth:`~io.IOBase.seekable` now +returns ``False`` for them. Previously seeking a pipe silently appeared to +succeed. As a consequence, opening a pipe in a read-write binary mode +(``'r+b'`` or ``'w+b'``) now raises :exc:`io.UnsupportedOperation` unless +buffering is disabled. + +.. + +.. bpo: 40851 +.. date: 2020-06-19-00-14-52 +.. nonce: 0-3EJP +.. section: Windows + +:class:`subprocess.Popen` with ``shell=True`` on Windows now honors +``wShowWindow`` of the *startupinfo* argument, so the console window of the +started program can be shown. Previously it was always hidden. + +.. + +.. date: 2026-09-29-09-29-17 +.. gh-issue: 158010 +.. nonce: 2zJnoj +.. section: macOS + +Update macOS installer to use OpenSSL 3.5.9. + +.. + +.. date: 2026-08-27-04-10-12 +.. gh-issue: 152023 +.. nonce: RNIecw +.. section: macOS + +Update macOS installer builds to SQLite 3.53.4. + +.. + +.. date: 2026-07-17-23-35-36 +.. gh-issue: 124111 +.. nonce: dmM4lk +.. section: macOS + +Update macOS installer to use Tcl/Tk 9.0.4. + +.. + +.. date: 2026-07-17-23-20-27 +.. gh-issue: 152023 +.. nonce: QAAgdj +.. section: macOS + +Update macOS installer builds to SQLite 3.53.3. Enable median() and +percentile() functions. + +.. + +.. date: 2026-06-09-11-52-35 +.. gh-issue: 151163 +.. nonce: RlPXHq +.. section: macOS + +Updated macOS installer to include SQLite version 3.53.2. + +.. + +.. date: 2026-05-31-10-40-00 +.. gh-issue: 150644 +.. nonce: zLWyjj +.. section: macOS + +When system logging is enabled (with ``config.use_system_logger``, messages +are now tagged as public. This allows the macOS 26 system logger to view +messages without special configuration. + +.. + +.. date: 2026-09-24-12-00-00 +.. gh-issue: 158067 +.. nonce: opnPy1 +.. section: IDLE + +Fix the IDLE File Open dialog listing text files before Python files when +opened from the Shell or an Output window. + +.. + +.. date: 2026-09-17-23-00-00 +.. gh-issue: 56596 +.. nonce: capslock +.. section: IDLE + +Make IDLE keyboard shortcuts with ascii letters work when Caps Lock is on +even when only one of the upper and lowercase versions are defined. + +.. + +.. date: 2026-09-17-22-00-00 +.. gh-issue: 75512 +.. nonce: asyncout +.. section: IDLE + +Output from a thread printed in the IDLE Shell while a statement is being +entered no longer takes over the prompt of the statement. + +.. + +.. date: 2026-09-17-21-00-00 +.. gh-issue: 64007 +.. nonce: inputcolor +.. section: IDLE + +IDLE no longer applies syntax coloring to the text entered for :func:`input` +in the Shell. + +.. + +.. date: 2026-09-17-18-00-00 +.. gh-issue: 85560 +.. nonce: elseexpr +.. section: IDLE + +Fix IDLE failing to find the opening parenthesis when a continuation line +inside the parentheses starts with ``else`` of a conditional expression or +with ``yield``. + +.. + +.. date: 2026-09-17-17-00-00 +.. gh-issue: 75487 +.. nonce: blankint +.. section: IDLE + +Fix saving a truncated number when an integer entry in the IDLE Settings +dialog is blanked with the Backspace key. + +.. + +.. date: 2026-09-17-12-00-00 +.. gh-issue: 74112 +.. nonce: sigint +.. section: IDLE + +Ctrl-C in the IDLE Shell now interrupts blocking calls such as +:func:`time.sleep` and :meth:`socket.recv `. + +.. + +.. date: 2026-09-17-08-53-12 +.. gh-issue: 151471 +.. nonce: -yvE03 +.. section: IDLE + +Colorize the soft keyword ``type`` in IDLE. + +.. + +.. date: 2026-09-17-02-00-00 +.. gh-issue: 103089 +.. nonce: longline +.. section: IDLE + +IDLE no longer hangs when opening a file with very long lines. Only the +first 2,000 characters of a line are colorized. + +.. + +.. date: 2026-09-17-01-00-00 +.. gh-issue: 89544 +.. nonce: rstbuf +.. section: IDLE + +Fix IDLE hanging after Restart Shell while receiving a large output from the +user process. + +.. + +.. date: 2026-09-16-22-00-00 +.. gh-issue: 70331 +.. nonce: shadow +.. section: IDLE + +IDLE no longer fails to start with ``python -m idlelib``, and its user +process no longer fails to start, when the current directory contains user +files with the same names as standard library modules that IDLE imports, +such as ``random.py`` or ``tkinter.py``. + +.. + +.. date: 2026-09-16-20-00-00 +.. gh-issue: 93016 +.. nonce: cliarg +.. section: IDLE + +Fix parsing of command line arguments in the IDLE "Run... Customized" dialog +on Windows: backslashes are no longer treated as escape characters. Fix also +display of the previous arguments in the dialog. + +.. + +.. date: 2026-09-16-18-00-00 +.. gh-issue: 59568 +.. nonce: tilde1 +.. section: IDLE + +Fix "Save As" and "Open" dialogs in IDLE for a file whose name starts with +``~`` on Windows and X11 with Tcl/Tk older than 9. + +.. + +.. date: 2026-09-15-23-27-38 +.. gh-issue: 69004 +.. nonce: Z7Ym9G +.. section: IDLE + +The Debugger item of the IDLE Debug menu is now disabled while user code +runs, like Stack Viewer. + +.. + +.. date: 2026-09-15-22-34-33 +.. gh-issue: 69365 +.. nonce: KehjZN +.. section: IDLE + +The IDLE search dialogs now show a regular expression error below the entry +instead of in a message box. + +.. + +.. date: 2026-09-15-22-10-17 +.. gh-issue: 93966 +.. nonce: ch4fTB +.. section: IDLE + +The highlighting of a syntax error in the IDLE Shell is now removed when the +next statement is entered, not only when the next syntax error occurs. + +.. + +.. date: 2026-09-15-21-54-04 +.. gh-issue: 105689 +.. nonce: ASoU37 +.. section: IDLE + +Fix calltips, parenthesis matching and auto-indent in the IDLE Shell after +output containing unbalanced quotes or parentheses. + +.. + +.. date: 2026-09-15-21-44-35 +.. gh-issue: 60402 +.. nonce: iFz6X6 +.. section: IDLE + +In IDLE, Tab in a string that is not the start of a file name inserts a tab +instead of opening the completion list. + +.. + +.. date: 2026-09-15-21-20-04 +.. gh-issue: 68453 +.. nonce: hlxbog +.. section: IDLE + +Fix running IDLE with the -s option together with -c, -r or -: the command +or script now runs after the startup file, without an error dialog and +without restarting the shell. + +.. + +.. date: 2026-09-15-20-14-08 +.. gh-issue: 75234 +.. nonce: O8ZNFV +.. section: IDLE + +Fix editing help sources and key bindings in the IDLE Settings dialog after +selecting them with the keyboard. + +.. + +.. date: 2026-09-15-16-37-19 +.. gh-issue: 69919 +.. nonce: f6AamT +.. section: IDLE + +IDLE now reports any exception raised by compiling the source, such as +:exc:`MemoryError` for too deeply nested source, instead of hanging the +Shell. + +.. + +.. date: 2026-09-15-16-19-25 +.. gh-issue: 91398 +.. nonce: PBdiDB +.. section: IDLE + +Remove the border around the IDLE Shell sidebar, which was drawn in the +window background color and stood out with dark themes. + +.. + +.. date: 2026-09-15-15-46-35 +.. gh-issue: 71136 +.. nonce: vwGO0v +.. section: IDLE + +Fix a hang of the IDLE Shell when code run under the debugger raises +:exc:`KeyboardInterrupt`. + +.. + +.. date: 2026-09-05-16-00-00 +.. gh-issue: 154511 +.. nonce: hV2wQn +.. section: IDLE + +Consolidate IDLE's mouse wheel handling in ``idlelib.util``. ``wheel_event`` +moves there from ``idlelib.tree`` and joins ``x11_buttons``, which tells +whether Tk reports wheel rotations to a widget as +````/```` events, and ``bind_wheel``, which binds +whichever events Tk sends. + +.. + +.. date: 2026-09-03-17-16-26 +.. gh-issue: 156896 +.. nonce: XTQJlq +.. section: IDLE + +Stop deleting tkinter submodules when idlelib.run is imported. + +.. + +.. date: 2026-07-10-19-41-00 +.. gh-issue: 153480 +.. nonce: EdMt1x +.. section: IDLE + +Fix IDLE failing to start when opening a file which does not exist yet. Fix +a traceback when a file open in the IDLE editor is deleted by another +program; IDLE now asks whether to close the window, save the file elsewhere, +or ignore it. + +.. + +.. date: 2026-07-01-21-00-00 +.. gh-issue: 55646 +.. nonce: kBind9 +.. section: IDLE + +Fix IDLE crash at startup when the user configuration contains an invalid +key binding, such as ```` instead of ````. The +invalid binding is now ignored with a warning. + +.. + +.. date: 2026-07-01-19-00-00 +.. gh-issue: 82183 +.. nonce: rNsTrt +.. section: IDLE + +When the shell is busy running code, using "Run... Customized" with "Restart +shell" unchecked now reports that the shell is executing instead of +restarting it anyway. + +.. + +.. date: 2026-07-01-18-00-00 +.. gh-issue: 83653 +.. nonce: cFgInt +.. section: IDLE + +Blanking an integer entry in IDLE's Settings dialog, such as "Auto squeeze +min lines", no longer saves an empty string as an invalid configuration +value. + +.. + +.. date: 2026-07-01-17-00-00 +.. gh-issue: 65339 +.. nonce: oUtTxt +.. section: IDLE + +Saving the IDLE Shell or an Output window now defaults to a ``.txt`` +extension and lists text files before Python files, since their content is +not Python source. + +.. + +.. date: 2026-07-01-16-00-00 +.. gh-issue: 80504 +.. nonce: gReP +.. section: IDLE + +The "In files:" field of IDLE's Find in Files dialog now always contains a +full directory path, even for an unsaved editor or the Shell. This shows in +the grep output which directory was searched. + +.. + +.. date: 2026-07-01-15-00-00 +.. gh-issue: 134300 +.. nonce: iDlPaT +.. section: IDLE + +Do not add the ``idlelib`` directory to the path of the IDLE user process. +User code run in IDLE can no longer import ``idlelib`` submodules as +top-level modules, such as ``import help``. + +.. + +.. date: 2026-07-01-14-00-00 +.. gh-issue: 89360 +.. nonce: mUlTiC +.. section: IDLE + +Fix a rare crash in the IDLE editor when the completion window is closed: +deleting a key binding for a sequence that is not bound to the virtual event +is now ignored instead of raising a ``ValueError``. + +.. + +.. date: 2026-07-01-13-30-00 +.. gh-issue: 66172 +.. nonce: Qm4xR7 +.. section: IDLE + +IDLE no longer fails to start when a user configuration file is corrupt. The +unparsable file is renamed with a ".bad" suffix, default settings are used +instead, and a warning lists the affected files. + +.. + +.. date: 2026-07-01-12-00-00 +.. gh-issue: 71956 +.. nonce: rPlAlL +.. section: IDLE + +Fix Replace All in the IDLE editor's Replace dialog when the search +direction is "Up" and "Wrap around" is off: it now replaces all matches +above the current position instead of only the first one. + +.. + +.. date: 2026-07-01-00-15-58 +.. gh-issue: 152728 +.. nonce: yxIhMN +.. section: IDLE + +Move functions run.fix_scaling, editor.fixwordbreaks (as fix_word_breaks) +and pyshell.fix_x11_paste to idlelib.util. + +.. + +.. date: 2026-07-01-00-00-00 +.. gh-issue: 66331 +.. nonce: wMcLaS +.. section: IDLE + +Set the ``WM_CLASS`` window property of IDLE's windows to ``Idle`` on X11, +so that window managers group and label them correctly instead of using the +default ``Toplevel``. + +.. + +.. date: 2026-06-28-06-46-46 +.. gh-issue: 85320 +.. nonce: Hq2vKn +.. section: IDLE + +IDLE now reads and writes its configuration files and the breakpoints file +using UTF-8 instead of the locale encoding. This keeps non-ASCII data (such +as non-ASCII paths) from being corrupted and makes the files portable +between environments. + +.. + +.. date: 2026-06-27-17-27-21 +.. gh-issue: 90304 +.. nonce: 464d22 +.. section: IDLE + +Prevent IDLE from failing to start when a font reports a zero width for the +``'0'`` character. Such a broken font caused a :exc:`ZeroDivisionError`; +the editor now falls back to the configured width. + +.. + +.. date: 2025-08-08-10-50-59 +.. gh-issue: 135511 +.. nonce: 9Rw5Zg +.. section: IDLE + +Fix display of :exc:`NameError` and :exc:`AttributeError` with multi-line +message. + +.. + +.. bpo: 6699 +.. date: 2019-12-12-03-18-02 +.. nonce: 1CqJFG +.. section: IDLE + +Warn the user if a file will be overwritten when saving. + +.. + +.. date: 2026-09-30-06-55-37 +.. gh-issue: 158451 +.. nonce: pZE56z +.. section: Tools/Demos + +``python-gdb.py`` is now able to format an invalid Unicode string: render +invalid characters as ``\Uhhhhhhhh`` instead of raising an exception. Patch +by Victor Stinner. + +.. + +.. date: 2026-08-23-18-10-00 +.. gh-issue: 156261 +.. nonce: Rw8pKd +.. section: Tools/Demos + +Argument Clinic: the ``pid_t``, ``uid_t``, ``gid_t``, ``Py_off_t``, +``HANDLE``, ``DWORD`` and ``BOOL`` converters, previously defined in +individual files, are now provided by Argument Clinic itself. + +.. + +.. date: 2026-08-22-11-00-00 +.. gh-issue: 156219 +.. nonce: Wq2nRt +.. section: Tools/Demos + +Fix Argument Clinic generating code which reads an optional positional +argument which was not passed, if the function has a ``**kwds`` parameter. + +.. + +.. date: 2026-08-14-13-15-35 +.. gh-issue: 113318 +.. nonce: oHjvUR +.. section: Tools/Demos + +The value of a setter generated by Argument Clinic is now a parameter, which +can use a converter, and a getter can define a return converter. It is +optional to declare the value of the setter. The accessors of the same +attribute are now identified by the Python name of that attribute instead of +the C basename, so they can use different C basenames, and several +implementations of the same accessor can be defined in different +preprocessor conditional blocks. + +.. + +.. date: 2026-08-14-12-45-57 +.. gh-issue: 113318 +.. nonce: G1B0oH +.. section: Tools/Demos + +Fix Argument Clinic for ``@getter`` and ``@setter`` in a preprocessor +conditional block. It failed with an internal error. Argument Clinic now +also rejects the accessors of the same attribute with different C basenames, +and the same accessor defined twice, which silently generated invalid or +duplicated entries of :c:type:`PyGetSetDef`. + +.. + +.. date: 2026-08-08-12-40-00 +.. gh-issue: 155373 +.. nonce: Wq3xTm +.. section: Tools/Demos + +Argument Clinic now generates the inlined code of the converters for +functions with optional groups, instead of a ``PyArg_ParseTuple()`` call for +every number of arguments. Every argument is now parsed once, most such +functions now use the fastcall convention, and the errors for a wrong type +of an argument are the same as in other functions. + +.. + +.. date: 2026-08-06-11-40-49 +.. gh-issue: 64660 +.. nonce: MswRQB +.. section: Tools/Demos + +Argument Clinic return converters no longer need to hardcode the name of the +variable returned by the parsing function. It is now available as +``data.parser_retval``. + +.. + +.. date: 2026-08-06-10-54-12 +.. gh-issue: 155266 +.. nonce: NEngp9 +.. section: Tools/Demos + +Fix Argument Clinic for a function whose only parameter is in an optional +group. It generated ``METH_O``, which made the argument mandatory and did +not pass the flag of the group. + +.. + +.. date: 2026-08-06-09-43-16 +.. gh-issue: 64595 +.. nonce: W75XZK +.. section: Tools/Demos + +Argument Clinic now touches the source file if a file generated from it was +changed, and keeps the generated files newer than the source file. The build +system does not know that the source file depends on the files generated +from it, so it did not recompile the source file if only the generated file +was changed. + +.. + +.. date: 2026-08-06-08-32-53 +.. gh-issue: 155263 +.. nonce: RCcjtk +.. section: Tools/Demos + +Add the ``--list`` option to Argument Clinic. It prints the modules, classes +and functions which Argument Clinic defines in the specified files, each +function with its signature. + +.. + +.. date: 2026-08-05-18-56-17 +.. gh-issue: 107570 +.. nonce: wXxtw2 +.. section: Tools/Demos + +Argument Clinic: report errors on the offending line. Errors in a docstring +were reported on the line which ends the block, and errors detected when +generating the code were reported without any position. + +.. + +.. date: 2026-08-05-18-16-24 +.. gh-issue: 108270 +.. nonce: kVDJSS +.. section: Tools/Demos + +Argument Clinic: add support for deprecating a parameter with the ``[until +X.Y]`` marker. Passing such argument emits a :exc:`DeprecationWarning`. + +.. + +.. date: 2026-08-05-18-16-23 +.. gh-issue: 108271 +.. nonce: Yvq2Tv +.. section: Tools/Demos + +Argument Clinic: add support for parameter aliases. A keyword-only parameter +with a default value which shares the C name of a preceding parameter +declares an alternative name for it. + +.. + +.. date: 2026-08-05-14-02-55 +.. gh-issue: 155218 +.. nonce: Nq4xZv +.. section: Tools/Demos + +Fix Argument Clinic generating the flags of the optional groups in different +order on 32-bit and 64-bit platforms. + +.. + +.. date: 2026-08-05-12-40-08 +.. gh-issue: 155212 +.. nonce: Lx8vTm +.. section: Tools/Demos + +The ``--converters`` option of Argument Clinic now accepts file names and +can be used with ``--make``. It prints the converters and return converters +which the specified files define, instead of the built-in ones. + +.. + +.. date: 2026-08-05-10-24-17 +.. gh-issue: 155207 +.. nonce: Wv3nKq +.. section: Tools/Demos + +Argument Clinic now supports the ``--dry-run`` and ``--diff`` options. They +list the files which would be changed, or write a unified diff of the +changes to the standard output, without modifying any file. + +.. + +.. date: 2026-08-04-19-05-41 +.. gh-issue: 64502 +.. nonce: Rb2wKt +.. section: Tools/Demos + +Argument Clinic now supports several optional groups on the same nesting +level, like in ``[y, x,] [n,] attr``. Such groups can be omitted +independently of each other. + +.. + +.. date: 2026-08-04-17-12-33 +.. gh-issue: 64502 +.. nonce: Qv7mLp +.. section: Tools/Demos + +Fix Argument Clinic support of parameters with a default value used together +with optional groups. Such parameters were always required in the generated +parsing code. + +.. + +.. date: 2026-07-24-09-30-00 +.. gh-issue: 154580 +.. nonce: Kp3nQ2 +.. section: Tools/Demos + +Fix ``python-gdb.py`` raising :exc:`UnicodeEncodeError` when pretty-printing +a non-ASCII :class:`str` in a locale whose host charset cannot encode it, +such as any non-ASCII string in the C locale. + +.. + +.. date: 2026-07-19-00-00-00 +.. gh-issue: 154059 +.. nonce: JiBcOM +.. section: Tools/Demos + +Fix the time units in Tachyon flame graph tooltips by accounting for the +sampling interval when converting samples to milliseconds. + +.. + +.. date: 2026-07-16-11-38-15 +.. gh-issue: 153804 +.. nonce: KSTYg7 +.. section: Tools/Demos + +Add ``Tools/inspection/oracle_external_inspection.py``, a harness for +measuring the accuracy of Tachyon. It reports impossible-stack rates, speed, +error rates and the statistical distance from the blocking non-cached best +reference on selected snippets. Patch by Maurycy Pawłowski-Wieroński. + +.. + +.. date: 2026-07-10-14-38-31 +.. gh-issue: 152384 +.. nonce: uaPADM +.. section: Tools/Demos + +The CPython Pixi packages are now all accessible at the same +``Tools/pixi-packages`` subdirectory, rather than at +``Tools/pixi-packages/{variant}`` as before. Variants are now selected not +via subdirectory but via ``flags``; see +https://pixi.prefix.dev/latest/concepts/package_specifications/#extras-and-flags +for usage instructions. The ``tsan-freethreading`` variant has been renamed +to ``tsan_freethreading``, while the ``default``, ``asan``, and +``freethreading`` variants retain their previous names. + +.. + +.. date: 2026-05-22-18-51-09 +.. gh-issue: 150258 +.. nonce: dh8GVK +.. section: Tools/Demos + +Update the tooltip on the Tachyon flame graph to show both absolute and +relative percentages. + +.. + +.. date: 2026-02-28-20-35-47 +.. gh-issue: 87613 +.. nonce: Nwzu6U +.. section: Tools/Demos + +Add a ``@vectorcall`` decorator to Argument Clinic to generate +:ref:`vectorcall` parsing code for :func:`object.__init__` and +:func:`object.__new__`. + +.. + +.. date: 2025-02-27-19-00-00 +.. gh-issue: 130647 +.. nonce: uwda2h +.. section: Tools/Demos + +Add ``--omit-header`` option to :program:`pygettext`. + +.. + +.. date: 2024-06-17-13-52-04 +.. gh-issue: 111501 +.. nonce: syFLAV +.. section: Tools/Demos + +PS1 is no longer exported by venv activate script + +.. + +.. date: 2026-10-11-06-20-11 +.. gh-issue: 129724 +.. nonce: Wq3nTb +.. section: C API + +Make :c:func:`PyMarshal_WriteObjectToFile` write nothing to the file if the +object cannot be marshalled, instead of partial data. + +.. + +.. date: 2026-10-05-17-09-35 +.. gh-issue: 149044 +.. nonce: 1HUiag +.. section: C API + +Fix the :c:macro:`PySlot_END` macro for C++: initialize all members to avoid +compiler warnings. Patch by Victor Stinner. + +.. + +.. date: 2026-10-05-15-24-22 +.. gh-issue: 158842 +.. nonce: g7eLtE +.. section: C API + +Add :c:macro:`Py_SETREF` and :c:macro:`Py_XSETREF` macros to the limited C +API. Patch by Nathan Goldbaum and Victor Stinner. + +.. + +.. date: 2026-10-05-01-09-32 +.. gh-issue: 158810 +.. nonce: F1p-PK +.. section: C API + +Fix :c:macro:`Py_ARRAY_LENGTH()` macro on C++: do not use +``__builtin_types_compatible_p()`` on C++. Patch by Victor Stinner. + +.. + +.. date: 2026-09-30-03-19-34 +.. gh-issue: 158451 +.. nonce: pUb2BJ +.. section: C API + +Fix :c:func:`!_PyUnicodeWriter_WriteLatin1String` when the writer buffer +kind is UCS-2 or UCS-4. Patch by Victor Stinner. + +.. + +.. date: 2026-09-29-19-01-56 +.. gh-issue: 158439 +.. nonce: ybKo_6 +.. section: C API + +If :c:func:`PyUnicodeWriter_WriteUTF8` or :c:func:`PyUnicodeWriter_Format` +fails, :c:func:`PyUnicodeWriter_Finish` now checks if the string uses the +most efficient storage. Previously, :c:func:`PyUnicodeWriter_Finish` could +return a string with an inefficient storage. Patch by Victor Stinner. + +.. + +.. date: 2026-09-24-15-27-35 +.. gh-issue: 158080 +.. nonce: YIqypf +.. section: C API + +Deprecate :c:func:`PyInitConfig_GetExitCode`, :c:func:`PyStatus_Exit`, and +:c:func:`PyStatus_IsExit` functions, and :c:member:`PyStatus.exitcode` +member. :c:func:`Py_InitializeFromInitConfig` and +:c:func:`Py_InitializeFromConfig` can no longer return an exit code. +Instead, if a command line option wants to exit Python, the option is now +processed in :c:func:`Py_RunMain`. Patch by Victor Stinner. + +.. + +.. date: 2026-09-24-14-14-34 +.. gh-issue: 154757 +.. nonce: -b-Fs7 +.. section: C API + +:c:func:`PyModule_GetFilename` is no longer deprecated, but using +:c:func:`PyModule_GetFilenameObject` instead is still recommended. Patch by +Victor Stinner. + +.. + +.. date: 2026-09-24-11-47-32 +.. gh-issue: 157649 +.. nonce: 3HSU2h +.. section: C API + +Fix :c:macro:`Py_CLEAR` and :c:macro:`Py_SETREF` macros on C++: implement +them using ``auto`` instead of ``decltype()``. Using ``decltype()`` +produced invalid code when clearing/setting an array item. Patch by Victor +Stinner. + +.. + +.. date: 2026-09-23-23-52-55 +.. gh-issue: 154757 +.. nonce: EUVFeZ +.. section: C API + +Remove :c:func:`!PyEval_InitThreads` function which did nothing since Python +3.7 and was deprecated since Python 3.9. Patch by Victor Stinner. + +.. + +.. date: 2026-09-23-21-45-43 +.. gh-issue: 158001 +.. nonce: R_wX4E +.. section: C API + +Remove :c:func:`!Py_SetProgramName`, :c:func:`!Py_SetPythonHome`, +:c:func:`!PySys_SetArgv` and :c:func:`!PySys_SetArgvEx` functions, +deprecated since Python 3.11. Patch by Victor Stinner. + +.. + +.. date: 2026-09-23-19-37-53 +.. gh-issue: 158001 +.. nonce: X_Xamm +.. section: C API + +Remove 21 global configuration variables: + +* :c:var:`!Py_BytesWarningFlag`, +* :c:var:`!Py_DebugFlag`, +* :c:var:`!Py_DontWriteBytecodeFlag`, +* :c:var:`!Py_FileSystemDefaultEncodeErrors`, +* :c:var:`!Py_FileSystemDefaultEncoding`, +* :c:var:`!Py_FrozenFlag`, +* :c:var:`!Py_HasFileSystemDefaultEncoding`, +* :c:var:`!Py_HashRandomizationFlag`, +* :c:var:`!Py_IgnoreEnvironmentFlag`, +* :c:var:`!Py_InspectFlag`, +* :c:var:`!Py_InteractiveFlag`, +* :c:var:`!Py_IsolatedFlag`, +* :c:var:`!Py_LegacyWindowsFSEncodingFlag`, +* :c:var:`!Py_LegacyWindowsStdioFlag`, +* :c:var:`!Py_NoSiteFlag`, +* :c:var:`!Py_NoUserSiteDirectory`, +* :c:var:`!Py_OptimizeFlag`, +* :c:var:`!Py_QuietFlag`, +* :c:var:`!Py_UTF8Mode`, +* :c:var:`!Py_UnbufferedStdioFlag`, +* :c:var:`!Py_VerboseFlag`. + +Patch by Victor Stinner. + +.. + +.. date: 2026-09-22-23-20-53 +.. gh-issue: 148233 +.. nonce: U_2x-F +.. section: C API + +Add :c:func:`Py_HashBuffer` to the limited C API. Patch by Victor Stinner. + +.. + +.. date: 2026-09-18-00-29-49 +.. gh-issue: 157710 +.. nonce: Q_AD8D +.. section: C API + +When Python is built in debug mode, :c:func:`PyUnicodeWriter_Finish` now +checks if the trailing null byte has been overridden to detect buffer +overflow. Patch by Victor Stinner. + +.. + +.. date: 2026-09-17-23-18-12 +.. gh-issue: 157710 +.. nonce: 1xKQAH +.. section: C API + +Soft deprecate functions modifying Unicode strings: :c:func:`PyUnicode_New`, +:c:func:`PyUnicode_CopyCharacters`, :c:func:`PyUnicode_Fill`, +:c:func:`PyUnicode_Resize`, :c:func:`PyUnicode_WRITE` and +:c:func:`PyUnicode_WriteChar`. Use the :c:type:`PyUnicodeWriter` API +instead. Patch by Victor Stinner. + +.. + +.. date: 2026-09-16-21-24-36 +.. gh-issue: 142217 +.. nonce: 44sqt4 +.. section: C API + +Add tests on the undocumented and deprecated ``_Py_Identifier`` C API. Patch +by Victor Stinner. + +.. + +.. date: 2026-09-14-18-07-43 +.. gh-issue: 140550 +.. nonce: fLVOGn +.. section: C API + +Fix the :c:macro:`PyABIInfo_VAR` macro: remove redundant ``;``. Before, +``PyABIInfo_VAR(abi_info);`` code added two ``;;`` which is illegal in +C++03. Patch by Victor Stinner. + +.. + +.. date: 2026-09-14-16-10-23 +.. gh-issue: 157495 +.. nonce: LzMLtE +.. section: C API + +If ``typeof()`` is available, implement :c:macro:`Py_MIN`, :c:macro:`Py_MAX` +and :c:macro:`Py_ABS` using ``typeof()`` and statement expression to only +evaluate each argument once. Patch by Victor Stinner. + +.. + +.. date: 2026-09-12-18-37-22 +.. gh-issue: 157384 +.. nonce: LGsy8K +.. section: C API + +:c:func:`PyImport_CreateModuleFromInitfunc` now sets the package context +while calling *initfunc*, so that a single-phase init submodule created with +only the last component of its name gets the full name from the spec. + +.. + +.. date: 2026-09-10-15-19-16 +.. gh-issue: 155526 +.. nonce: kMKhyp +.. section: C API + +:c:func:`_Py_c_abs` no longer sets :c:data:`errno` to zero on success, but +rather leaves it unchanged. Patch by Sergey B Kirpichev. + +.. + +.. date: 2026-09-10-02-51-26 +.. gh-issue: 157242 +.. nonce: tfXIsf +.. section: C API + +Fix :c:func:`PyBytesWriter_Resize` to handle properly memory allocation +failure. Leave the writer unchanged on error, instead of leaving it in an +inconsistent state. Patch by Victor Stinner. + +.. + +.. date: 2026-09-04-16-41-07 +.. gh-issue: 156939 +.. nonce: bKaQuE +.. section: C API + +When Python is built in debug mode, :c:type:`PyBytesWriter` now detects +buffer overflow. Patch by Victor Stinner. + +.. + +.. date: 2026-08-31-19-14-15 +.. gh-issue: 156101 +.. nonce: d4PSIF +.. section: C API + +Don't set the result in error in :c:func:`PyLong_AsInt32`, +:c:func:`PyLong_AsUInt32`, :c:func:`PyLong_AsInt64` and +:c:func:`PyLong_AsUInt64`. Leave the result unchanged in this case. Patch by +Victor Stinner. + +.. + +.. date: 2026-08-25-12-00-00 +.. gh-issue: 131740 +.. nonce: Ft7Rz2 +.. section: C API + +On the free-threaded build, :c:func:`PyUnstable_GC_VisitObjects` now also +visits frozen objects (objects moved to the permanent generation by +:func:`gc.freeze`), matching the behavior of the default build. + +.. + +.. date: 2026-08-16-20-48-08 +.. gh-issue: 155907 +.. nonce: Vb3xTn +.. section: C API + +:c:func:`PyMarshal_ReadObjectFromFile` and other functions reading +marshalled data from a :c:expr:`FILE*` now raise :exc:`OSError` for I/O +errors and :exc:`KeyboardInterrupt` for interrupted reading, instead of +:exc:`EOFError`. :c:func:`PyMarshal_WriteObjectToFile` and +:c:func:`PyMarshal_WriteLongToFile` now detect I/O errors and interrupted +writing instead of ignoring them. :c:func:`PyMarshal_WriteObjectToFile` now +also sets the error indicator if the value cannot be marshalled. + +.. + +.. date: 2026-08-14-14-47-08 +.. gh-issue: 155742 +.. nonce: UGI3Pn +.. section: C API + +:c:func:`PyBytesWriter_FinishWithSize` now returns single byte singletons if +*size* equals to ``1``. Patch by Victor Stinner. + +.. + +.. date: 2026-07-30-16-58-36 +.. gh-issue: 152105 +.. nonce: 1Jz1YH +.. section: C API + +Remove the :c:var:`!PyUnstable_ExecutableKinds` array, as well as the macros +:c:macro:`!PyUnstable_EXECUTABLE_KIND_SKIP`, +:c:macro:`!PyUnstable_EXECUTABLE_KIND_PY_FUNCTION`, +:c:macro:`!PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION`, +:c:macro:`!PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR` and +:c:macro:`!PyUnstable_EXECUTABLE_KINDS`, from the C API. + +.. + +.. date: 2026-07-28-04-29-52 +.. gh-issue: 153740 +.. nonce: 7_LMSA +.. section: C API + +If available on the platform, use native :c:type:`_Float16` in +:c:func:`PyFloat_Pack2` and :c:func:`PyFloat_Unpack2` functions. Patch by +Sergey B Kirpichev. + +.. + +.. date: 2026-07-09-17-33-29 +.. gh-issue: 152132 +.. nonce: Ma8MJZ +.. section: C API + +Fix :c:func:`Py_RunMain` to return an exit code, rather than calling +:c:func:`Py_Exit`, when running a script, a command, or the REPL. Patch by +Victor Stinner. + +.. + +.. date: 2026-07-09-16-46-30 +.. gh-issue: 145633 +.. nonce: jyNwAs +.. section: C API + +:c:func:`PyFloat_Pack8` and ``PyFloat_Unpack*`` functions are no longer +guaranteed to always succeed on CPython. + +.. + +.. date: 2026-07-08-00-38-32 +.. gh-issue: 153300 +.. nonce: lVoWyR +.. section: C API + +:c:func:`PyConfig_Set()` now also set global configuration variables. For +example, ``PyConfig_Set("inspect", value)`` now also sets +:c:var:`!Py_InspectFlag`. Patch by Victor Stinner. + +.. + +.. date: 2026-06-18-18-24-11 +.. gh-issue: 141510 +.. nonce: -EOHJ1 +.. section: C API + +Add :class:`frozendict` to the fast paths of +:c:func:`PyMapping_GetOptionalItem`, :c:func:`PyMapping_Keys`, +:c:func:`PyMapping_Values`, and :c:func:`PyMapping_Items`. + +.. + +.. date: 2026-06-10-16-43-37 +.. gh-issue: 123619 +.. nonce: dV82r6 +.. section: C API + +:c:func:`PyUnstable_Object_EnableDeferredRefcount` now returns ``0`` if the +object is not tracked by the garbage collector: if :func:`gc.is_tracked` is +false. Patch by Victor Stinner. + +.. + +.. date: 2026-06-10-15-22-44 +.. gh-issue: 149044 +.. nonce: O7KEcs +.. section: C API + +Improved error message when specifying non-type base classes in +:c:macro:`Py_tp_bases`, :c:macro:`Py_tp_base`, and *bases* argument to +:c:func:`PyType_FromMetaclass` and other ``PyType_From*`` functions. + +.. + +.. date: 2026-06-09-14-50-35 +.. gh-issue: 80384 +.. nonce: UEGyvB +.. section: C API + +:c:func:`PyWeakref_NewRef` and :c:func:`PyWeakref_NewProxy` now raise +:exc:`TypeError` if the *callback* argument is not callable, ``None``, or +``NULL``. + +.. + +.. date: 2026-06-04-14-26-17 +.. gh-issue: 150907 +.. nonce: CA91_B +.. section: C API + +Fix ``dynamic_annotations.h`` header file when built with C++ and Valgrind: +add ``extern "C++" scope`` for the C++ template. Patch by Victor Stinner. + +.. + +.. date: 2026-05-31-15-39-58 +.. gh-issue: 150671 +.. nonce: bTkDVC +.. section: C API + +Deprecate these C-API functions: :c:func:`PyGen_New`, +:c:func:`PyGen_NewWithQualName`, :c:func:`PyCoro_New`, and +:c:func:`PyAsyncGen_New`. Schedule them for removal in 3.18 + +.. + +.. date: 2026-05-12-16-47-21 +.. gh-issue: 149725 +.. nonce: HZLBTZ +.. section: C API + +Add :c:func:`PySentinel_CheckExact` for exact :class:`sentinel` type tests +to accompany the existing :c:func:`PySentinel_Check`. + +.. + +.. date: 2026-02-25-13-37-10 +.. gh-issue: 145235 +.. nonce: -1ySNR +.. section: C API + +Made :c:func:`PyDict_AddWatcher`, :c:func:`PyDict_ClearWatcher`, +:c:func:`PyDict_Watch`, and :c:func:`PyDict_Unwatch` thread-safe on the +:term:`free threaded ` build. + +.. + +.. date: 2024-08-12-09-48-04 +.. gh-issue: 122931 +.. nonce: x435Mb +.. section: C API + +Allow importing stable ABI C extensions that include a multiarch tuple in +their filename, e.g. ``foo.abi3-x86-64-linux-gnu.so``. + +.. + +.. bpo: 32414 +.. date: 2018-05-16-13-47-18 +.. nonce: NODPbj +.. section: C API + +:c:func:`PyCapsule_Import` now imports submodules if needed. Previously +names like ``package.module.attribute`` worked only if ``package.module`` +was already imported. diff --git a/Misc/NEWS.d/3.16.0a2.rst b/Misc/NEWS.d/3.16.0a2.rst new file mode 100644 index 000000000000000..629953ebd574298 --- /dev/null +++ b/Misc/NEWS.d/3.16.0a2.rst @@ -0,0 +1,4357 @@ +.. cve: CVE-2026-115791 +.. date: 2026-11-07-15-56-47 +.. gh-issue: 161705 +.. nonce: OjDK2d +.. release date: 2026-11-10 +.. section: Security + +Remove ``sys.path[0]`` in :mod:`gzip`, :mod:`tarfile` and :mod:`zipfile` +command line interface to prevent shadowing standard library modules from +extracted files. Issue reported by Jelle Zijlstra, patch by Gregory P. Smith +and Victor Stinner. + +.. + +.. cve: CVE-2026-124249 +.. date: 2026-11-07-01-43-49 +.. gh-issue: 161569 +.. nonce: cookiej +.. section: Security + +Fix :class:`http.cookiejar.CookieJar` deleting a stored cookie when a +response from an unrelated host sets an already expired cookie with a +``Domain`` or ``Path`` attribute pointing at that cookie. The cookie policy +is now consulted before an expired cookie is allowed to delete an existing +one. + +.. + +.. cve: CVE-2026-19552 +.. date: 2026-11-06-16-22-47 +.. gh-issue: 161503 +.. nonce: FkIl87 +.. section: Security + +:func:`ssl.get_server_certificate` now verifies that the server hostname +matches its certificate when the caller specifies *ca_certs*. + +.. + +.. date: 2026-11-02-18-30-09 +.. gh-issue: 161192 +.. nonce: 2ScSRO +.. section: Security + +Update bundled `libexpat `_ to version 2.10.0 +for the fixes to :cve:`2026-113351`, :cve:`2026-115506`, :cve:`2026-117610` +and :cve:`2026-118370`. + +.. + +.. cve: CVE-2026-116566 +.. date: 2026-10-27-16-25-40 +.. gh-issue: 160898 +.. nonce: epi53X +.. section: Security + +:func:`socket.getaddrinfo` now rejects null bytes within *host* and *port* +parameters as this previously caused the values to be silently truncated. + +.. + +.. cve: CVE-2026-115559 +.. date: 2026-10-22-21-59-39 +.. gh-issue: 160369 +.. nonce: imapTLS +.. section: Security + +:meth:`imaplib.IMAP4.starttls` now rejects unexpected plaintext buffered +after the STARTTLS response, preventing it from being processed as +TLS-protected data. + +.. + +.. date: 2026-10-22-11-09-30 +.. gh-issue: 160279 +.. nonce: 9BtxeF +.. section: Security + +Prevent :mod:`venv` from importing modules from the root of an existing +virtual environment when installing or upgrading pip. + +.. + +.. date: 2026-10-22-08-08-57 +.. gh-issue: 160499 +.. nonce: pf9H9g +.. section: Security + +Fix unbounded memory growth in :mod:`asyncio` TLS connections when a peer +stops reading but keeps sending records that make OpenSSL generate its own +replies (such as TLS 1.2 renegotiation alerts). Reading from the peer is +now paused when this output accumulates, instead of only when application +data does. + +.. + +.. date: 2026-10-22-08-08-23 +.. gh-issue: 160506 +.. nonce: rN4dLq +.. section: Security + +Fix :func:`os.path.realpath` on Windows returning the wrong path for a +broken relative symbolic link reached through a symbolic link to a +directory. This allowed :mod:`tarfile` extraction with the ``'data'`` or +``'tar'`` filter to create a file outside the destination directory. + +.. + +.. date: 2026-10-22-08-07-52 +.. gh-issue: 161323 +.. nonce: q7Drv2 +.. section: Security + +On Windows, the ``'tar'`` and ``'data'`` :mod:`tarfile` extraction filters +now refuse member names and link targets that have a drive but are not +absolute, such as ``C:foo``, with :exc:`~tarfile.AbsolutePathError` or +:exc:`~tarfile.AbsoluteLinkError`. Such members could be extracted outside +the destination directory. Fixes :cve:`2026-107784`. + +.. + +.. date: 2026-10-22-08-05-32 +.. gh-issue: 160420 +.. nonce: tZ9dRv +.. section: Security + +Fix :class:`zoneinfo.ZoneInfo` on Windows accepting keys in which a +component after a ``/`` starts with a drive letter, such as +``America/C:\file``. Such a key could open a file outside the ``tzdata`` +package; it now raises :exc:`ValueError`. + +.. + +.. date: 2026-10-22-08-04-33 +.. gh-issue: 160300 +.. nonce: q7Zk2B +.. section: Security + +Fix :class:`http.cookiejar.DefaultCookiePolicy` accepting and returning +cookies with a negative ``Version`` attribute without checking their domain +against the request host. Such cookies are now ignored. + +.. + +.. cve: CVE-2026-114583 +.. date: 2026-10-21-19-58-53 +.. gh-issue: 160097 +.. nonce: -opfAL +.. section: Security + +:func:`tarfile.tar_filter` now rejects link members whose path resolves to +the destination directory itself, as :func:`tarfile.data_filter` already +did. + +.. + +.. cve: CVE-2026-115557 +.. date: 2026-10-21-16-55-07 +.. gh-issue: 160040 +.. nonce: 9PjFjC +.. section: Security + +:mod:`ssl` now rejects TLS certificate chains that contain any of a set of +compromised eMudhra intermediate CA keys. This is an extraordinary measure +and a last line of defense: removing trust is primarily the job of the +platform root store, and the built-in denylist only blocks connections while +that update has not yet reached the OS, a container image, or a bundled +trust store in various Python packages. Entries are added to the denylist +only under a very high threshold. The denylist matches on the public key +(the SHA-256 digest of the :rfc:`5280` ``SubjectPublicKeyInfo``), so it also +covers the cross-signed certificates that reuse one of the distrusted keys. + +.. + +.. date: 2026-10-20-13-15-00 +.. gh-issue: 159894 +.. nonce: 8Kp4mN +.. section: Security + +Bump the version of :pypi:`pip` bundled in :mod:`ensurepip` to version +26.2.2. + +.. + +.. date: 2026-10-15-03-47-08 +.. gh-issue: 159428 +.. nonce: XHRKwY +.. section: Security + +:mod:`mimetypes` no longer reads the files listed in +:data:`mimetypes.knownfiles` by default on Windows, and uses only the +registry. + +.. + +.. date: 2026-10-06-12-30-00 +.. gh-issue: 158928 +.. nonce: Zd9Ybv +.. section: Security + +Fix a buffer overflow when initializing a :class:`bytearray` from an +iterator. + +.. + +.. date: 2026-08-31-16-47-33 +.. gh-issue: 157953 +.. nonce: KxCFSN +.. section: Security + +Update bundled `libexpat `_ to version 2.9.0. + +.. + +.. date: 2026-11-09-14-30-00 +.. gh-issue: 160267 +.. nonce: sTfrEe +.. section: Core and Builtins + +Fix a crash when :mod:`profiling.sampling` profiles a process that creates +and destroys threads or subinterpreters quickly. Memory of deleted thread +and interpreter states is now reused for new states instead of being freed +until the runtime is finalized. + +.. + +.. date: 2026-11-07-09-30-00 +.. gh-issue: 161420 +.. nonce: mIdFre +.. section: Core and Builtins + +Restore ``mimalloc``'s previous behavior of processing delayed frees from +other threads on every generic malloc call, reverting the change introduced +in v2.2.2. + +.. + +.. date: 2026-11-06-21-21-04 +.. gh-issue: 161242 +.. nonce: d4vNgC +.. section: Core and Builtins + +Speed up :exc:`AttributeError`, :exc:`ImportError` and :exc:`NameError` by +enabling :ref:`vectorcall`. Unexpected keyword arguments are now reported by +name. + +.. + +.. date: 2026-11-06-15-15-00 +.. gh-issue: 161433 +.. nonce: A9b3Kq +.. section: Core and Builtins + +Add context notes to :exc:`TypeError` raised while hashing a :class:`tuple`, +identifying the index of the item whose hash failed. + +.. + +.. date: 2026-11-06-02-30-00 +.. gh-issue: 129724 +.. nonce: Mn8sLq +.. section: Core and Builtins + +Fix the :mod:`marshal` output of compiled code, and so ``.pyc`` files, +differing for the same source depending on what ran before in the process. +This affected private names in classes with non-ASCII names, and +:func:`compile` of an AST with names not created by :func:`ast.parse`. + +.. + +.. date: 2026-11-05-21-00-57 +.. gh-issue: 161366 +.. nonce: ouxAvv +.. section: Core and Builtins + +Fix a deadlock in the garbage collector of the :term:`free-threaded build` +when :data:`gc.DEBUG_COLLECTABLE` is set and another thread is writing to +:data:`sys.stderr`. The debug output is now written after the other threads +are resumed. + +.. + +.. date: 2026-11-05-10-19-48 +.. gh-issue: 161419 +.. nonce: wc4DV0 +.. section: Core and Builtins + +Fix a crash in the :term:`free-threaded build` where a weak reference could +revive an object whose finalizer had already run during deallocation, +causing it to be deallocated twice. + +.. + +.. date: 2026-11-03-20-28-15 +.. gh-issue: 161288 +.. nonce: LikC_U +.. section: Core and Builtins + +Fix a crash in the perf trampoline (:option:`-X perf <-X>`) on builds with +clang's ``-fsanitize=function``, which ``-fsanitize=undefined`` enables +since clang 17. + +.. + +.. date: 2026-11-03-13-44-26 +.. gh-issue: 159184 +.. nonce: X_sOdY +.. section: Core and Builtins + +Fix a leak of NaN constants in code objects created by :func:`marshal.loads` +on the free-threaded build. + +.. + +.. date: 2026-11-03-05-52-49 +.. gh-issue: 161229 +.. nonce: 8pOPOI +.. section: Core and Builtins + +:func:`!__lazy_import__` now treats ``None`` for *globals* and *locals* the +same as omitting them, matching its signature. + +.. + +.. date: 2026-11-02-05-50-35 +.. gh-issue: 160872 +.. nonce: x8NvzN +.. section: Core and Builtins + +Optimize division and remainder operations on large :class:`int` values. + +.. + +.. date: 2026-10-28-13-47-43 +.. gh-issue: 160773 +.. nonce: 7VFxkA +.. section: Core and Builtins + +Fix a crash in :func:`str` of an :exc:`OSError` when formatting one of its +attributes modifies the others. + +.. + +.. date: 2026-10-26-12-00-00 +.. gh-issue: 160682 +.. nonce: Q7mK2x +.. section: Core and Builtins + +Fix a bug in the :term:`free-threaded build` where garbage collection could +prematurely collect the function object of a running method. + +.. + +.. date: 2026-10-24-19-07-34 +.. gh-issue: 153568 +.. nonce: 6sVdqs +.. section: Core and Builtins + +Speed up :func:`ast.parse` by ~15.8% and reduce the memory used by ~51.6% by +storing node attributes as inline values instead of in a per-node +dictionary. + +.. + +.. date: 2026-10-23-20-15-24 +.. gh-issue: 160491 +.. nonce: yIQ_Vf +.. section: Core and Builtins + +Fix the location reported for invalid escape sequences in f-strings and +t-strings. The :exc:`SyntaxError` now points at the literal part that +contains the escape, instead of at the closing quote. + +.. + +.. date: 2026-10-23-19-37-00 +.. gh-issue: 160050 +.. nonce: aB3x9Q +.. section: Core and Builtins + +Use asymptotically faster :func:`divmod` implementation for integer modulo +of large integers. + +.. + +.. date: 2026-10-22-17-37-27 +.. gh-issue: 160268 +.. nonce: gJ2iDx +.. section: Core and Builtins + +Fix a crash in :mod:`tokenize` when a mismatched closing bracket follows the +opening brace of an f-string or t-string replacement field, as in +``f'{]a'``. It now raises the same "unmatched" error as the parser. + +.. + +.. date: 2026-10-22-14-45-00 +.. gh-issue: 160245 +.. nonce: mEmO24 +.. section: Core and Builtins + +Reduce the size of parser memo entries on 64-bit platforms by reordering +fields to remove padding. Patch by Shamil Abdulaev. + +.. + +.. date: 2026-10-22-12-30-11 +.. gh-issue: 106045 +.. nonce: fkMW34 +.. section: Core and Builtins + +Fix :mod:`venv` path discovery when the base executable resolves to a +location outside the installation pointed to by the ``home`` key in +``pyvenv.cfg``. The standard library is now found from ``home``, and +extension modules from the resolved executable's installation, instead of +falling back to the compiled-in prefix. + +.. + +.. date: 2026-10-22-00-30-21 +.. gh-issue: 160162 +.. nonce: lShf32 +.. section: Core and Builtins + +Fix a crash on 32-bit platforms when left shifting an :class:`int` by a +count close to ``sys.maxsize * sys.int_info.bits_per_digit``. +:exc:`OverflowError` is now raised, as for other too large counts. + +.. + +.. date: 2026-10-22-00-30-02 +.. gh-issue: 160179 +.. nonce: dQ2e7m +.. section: Core and Builtins + +Fix :meth:`!bytearray.__init__` leaving uninitialized memory in the object +when it fails on a :class:`list` or :class:`tuple` containing an integer not +in ``range(256)``. The object is now empty after the failed call. + +.. + +.. date: 2026-10-21-23-18-38 +.. gh-issue: 160132 +.. nonce: Nj4rQa +.. section: Core and Builtins + +Reduce memory usage during compilation by reordering the fields of the +internal basic block structure to reduce padding. Patch by Shamil Abdulaev. + +.. + +.. date: 2026-10-21-21-26-10 +.. gh-issue: 159739 +.. nonce: Zw43uX +.. section: Core and Builtins + +Raise :exc:`MemoryError` instead of returning an incorrect result if +:func:`round` runs out of memory while rounding a float. + +.. + +.. date: 2026-10-21-21-26-10 +.. gh-issue: 159739 +.. nonce: CbTE4N +.. section: Core and Builtins + +Fix a possible crash when assigning metadata to :class:`classmethod` or +:class:`staticmethod` objects. + +.. + +.. date: 2026-10-21-21-26-10 +.. gh-issue: 159739 +.. nonce: Aw61LR +.. section: Core and Builtins + +Fix a race in ``list.__sizeof__()`` when a list is concurrently resized on a +free-threaded build. + +.. + +.. date: 2026-10-21-19-55-00 +.. gh-issue: 159739 +.. nonce: tali01 +.. section: Core and Builtins + +Fix a reference leak when the value of a type alias is evaluated recursively +or concurrently. + +.. + +.. date: 2026-10-21-19-55-00 +.. gh-issue: 159739 +.. nonce: codc01 +.. section: Core and Builtins + +Fix a crash in free-threaded builds when :func:`codecs.unregister` is called +concurrently. + +.. + +.. date: 2026-10-21-18-00-00 +.. gh-issue: 160368 +.. nonce: sem-clockwait +.. section: Core and Builtins + +On Linux, allow timed semaphore waits to use the monotonic clock when +``sem_clockwait`` is available at runtime, even if Python was built with +older libc headers. + +.. + +.. date: 2026-10-21-14-00-00 +.. gh-issue: 159493 +.. nonce: sfLf1b +.. section: Core and Builtins + +Superinstructions are now formed after the compiler decides which +:opcode:`LOAD_FAST` instructions can borrow their reference. This fixes +reference count contention slowdown on the free-threaded build for +single-line loops and comprehensions. + +.. + +.. date: 2026-10-20-22-00-00 +.. gh-issue: 159963 +.. nonce: pLkHld +.. section: Core and Builtins + +Fix a regression in Python 3.15.0 where threads importing submodules of +packages for the first time could raise ``_DeadlockError`` or a spurious +"partially initialized module" :exc:`ImportError`, or block one another, +with no circular import involved. :func:`importlib.import_module` now +returns the partially initialized module in a cross-thread circular import, +as the :keyword:`import` statement does, instead of raising +``_DeadlockError``. + +.. + +.. date: 2026-10-20-20-38-38 +.. gh-issue: 159101 +.. nonce: vFwrZY +.. section: Core and Builtins + +Fix use-after-free when :meth:`~object.__del__` changes the base class. +Patch by Sergey Miryanov. + +.. + +.. date: 2026-10-20-10-00-00 +.. gh-issue: 158195 +.. nonce: UnpinTL +.. section: Core and Builtins + +Fix a deadlock in the free-threaded build between a thread that stops the +world while running Python code under the type lock (for example a custom +metaclass ``mro()`` or the ``__eq__`` of a :class:`str` subclass used as a +class ``__dict__`` key) and a thread that assigns to a special method or to +``__bases__`` of a class. The type lock is no longer held while waiting for +a stop-the-world; the prepared slot, MRO and bases updates are validated +with the world stopped and recomputed if they went stale. + +.. + +.. date: 2026-10-20-00-00-00 +.. gh-issue: 159739 +.. nonce: da0f04 +.. section: Core and Builtins + +Fix reference leaks when free-threaded garbage collection aborts early +because of an allocation error. + +.. + +.. date: 2026-10-20-00-00-00 +.. gh-issue: 159739 +.. nonce: d76e6d +.. section: Core and Builtins + +Prevent free-threaded builds from interning and immortalizing complex +subclasses in code object constants. + +.. + +.. date: 2026-10-20-00-00-00 +.. gh-issue: 159739 +.. nonce: bf569b +.. section: Core and Builtins + +Fix a reference leak in binary, ternary, and comparison operations on weak +reference proxies when another operand is a dead proxy. + +.. + +.. date: 2026-10-20-00-00-00 +.. gh-issue: 159739 +.. nonce: a3cc5d +.. section: Core and Builtins + +Fix a crash when constructing an error for invalid generic alias arguments. + +.. + +.. date: 2026-10-20-00-00-00 +.. gh-issue: 159739 +.. nonce: 848b18 +.. section: Core and Builtins + +Allow the garbage collector to break reference cycles involving property +accessors or names. + +.. + +.. date: 2026-10-19-21-30-00 +.. gh-issue: 159860 +.. nonce: qsbr128 +.. section: Core and Builtins + +Fix false sharing between the per-thread QSBR states in the +:term:`free-threaded build` on AArch64 CPUs with 128-byte cache lines, such +as Apple Silicon. CPU-bound threads that share no objects now scale like +processes there. + +.. + +.. date: 2026-10-19-20-38-17 +.. gh-issue: 159739 +.. nonce: fc0ed2 +.. section: Core and Builtins + +Avoid a crash if allocation fails while creating a +:class:`string.templatelib.Template` iterator. + +.. + +.. date: 2026-10-19-20-38-17 +.. gh-issue: 159739 +.. nonce: b62fc9 +.. section: Core and Builtins + +Propagate errors during generic class construction and avoid a crash after +failed generic alias substitution. + +.. + +.. date: 2026-10-19-20-38-17 +.. gh-issue: 159739 +.. nonce: 78e530 +.. section: Core and Builtins + +Raise :exc:`OverflowError` when the absolute value of a dynamic printf-style +formatting width is too large. + +.. + +.. date: 2026-10-19-20-38-17 +.. gh-issue: 159739 +.. nonce: 55fd08 +.. section: Core and Builtins + +Fix a reference leak in :func:`gc.get_objects` and :func:`gc.get_referrers` +when an internal allocation fails in the free-threaded build. + +.. + +.. date: 2026-10-19-19-33-35 +.. gh-issue: 159739 +.. nonce: f81734 +.. section: Core and Builtins + +Fix a crash in :func:`warnings.warn` when ``skip_file_prefixes`` is an empty +tuple subclass. Propagate allocation errors when creating the fallback +filename. + +.. + +.. date: 2026-10-19-19-33-35 +.. gh-issue: 159739 +.. nonce: c25c27 +.. section: Core and Builtins + +Fix memory leaks during interpreter startup when a path configuration file +is empty or too large, or when an audit hook rejects a command. + +.. + +.. date: 2026-10-19-19-33-35 +.. gh-issue: 159739 +.. nonce: a8775b +.. section: Core and Builtins + +Avoid a crash when an interpreter configuration string cannot be encoded as +UTF-8. + +.. + +.. date: 2026-10-19-19-33-35 +.. gh-issue: 159739 +.. nonce: 1fc3af +.. section: Core and Builtins + +Preserve the original :exc:`SyntaxError` if allocating optional error +metadata fails. + +.. + +.. date: 2026-10-19-19-33-35 +.. gh-issue: 159739 +.. nonce: 173d49 +.. section: Core and Builtins + +Avoid a crash if formatting an integer with the ``c`` presentation type runs +out of memory. + +.. + +.. date: 2026-10-19-19-33-35 +.. gh-issue: 159739 +.. nonce: 09590b +.. section: Core and Builtins + +Avoid a crash when a module filename cannot be encoded as UTF-8. + +.. + +.. date: 2026-10-19-16-38-39 +.. gh-issue: 159813 +.. nonce: wHfSOc +.. section: Core and Builtins + +Add a fast path for :const:`None` in :c:func:`PyUnicodeWriter_WriteRepr`. +Patch by Donghee Na. + +.. + +.. date: 2026-10-18-00-30-00 +.. gh-issue: 159652 +.. nonce: Qk3vLm +.. section: Core and Builtins + +Fix a hang when an import fails with :exc:`RecursionError` because the C +stack is nearly exhausted: releasing the import locks could itself fail and +leave the global import lock or a module lock held forever, so that later +imports in other threads blocked indefinitely. The import system now raises +:exc:`RecursionError` before taking an import lock when there is not enough +stack left to release it. + +.. + +.. date: 2026-10-17-02-47-26 +.. gh-issue: 159603 +.. nonce: OFagJz +.. section: Core and Builtins + +On FreeBSD, call ``pthread_attr_get_np()`` to get the stack size (and guard +size) of the current thread. Patch by Victor Stinner. + +.. + +.. date: 2026-10-16-18-25-48 +.. gh-issue: 159564 +.. nonce: WMRRFA +.. section: Core and Builtins + +Improve the performance and thread scaling of dereferencing weak references +in the :term:`free-threaded build`. Dereferencing a weak reference no +longer takes a lock. + +.. + +.. date: 2026-10-15-12-40-00 +.. gh-issue: 87613 +.. nonce: Sl1ceV +.. section: Core and Builtins + +Speed up calling :class:`slice` by adding a vectorcall implementation of the +constructor generated by Argument Clinic. Patch by Pieter Eendebak. + +.. + +.. date: 2026-10-15-12-36-09 +.. gh-issue: 130279 +.. nonce: N9N-sw +.. section: Core and Builtins + +Fix bug where compiler did not set the right exception handler for some jump +instructions. + +.. + +.. date: 2026-10-15-12-10-00 +.. gh-issue: 87613 +.. nonce: Wr4fvc +.. section: Core and Builtins + +Speed up creating :class:`weakref.ref` objects by adding a vectorcall +implementation of the constructor generated by Argument Clinic. Patch by +Pieter Eendebak. + +.. + +.. date: 2026-10-15-10-15-27 +.. gh-issue: 159449 +.. nonce: xsdzFf +.. section: Core and Builtins + +Fix a free-threaded asyncio race leading to segfaults. + +.. + +.. date: 2026-10-14-23-05-00 +.. gh-issue: 132042 +.. nonce: k7Qs2w +.. section: Core and Builtins + +Speed up class creation by resolving the special method slots of a new class +with one pass over each class dict along the MRO instead of one lookup per +slot name and per class. + +.. + +.. date: 2026-10-14-19-16-53 +.. gh-issue: 159434 +.. nonce: T4AsrQ +.. section: Core and Builtins + +Fix reading a function's :attr:`~function.__annotations__` using borrowed +references to :attr:`~function.__annotate__` and the internal annotations +tuple while running code that can replace them. If ``__annotations__`` is +set while ``__annotate__`` runs, the newly set value is now kept. + +.. + +.. date: 2026-10-14-18-45-35 +.. gh-issue: 159431 +.. nonce: mVTMsA +.. section: Core and Builtins + +Fix an assertion failure, or an immortal object becoming mortal, on the +:term:`free threaded ` build when an object passed to the +internal delayed decref mechanism is immortal or becomes immortal before the +delayed decref is processed by the garbage collector. + +.. + +.. date: 2026-10-14-11-40-06 +.. gh-issue: 159430 +.. nonce: OWpyPm +.. section: Core and Builtins + +Report the correct exception if looking up :meth:`~object.__bytes__` raises +an exception while performing %-formatting of :class:`bytes`. + +.. + +.. date: 2026-10-14-07-36-44 +.. gh-issue: 159399 +.. nonce: cjuE0N +.. section: Core and Builtins + +Fix a crash in :func:`codecs.encode` and :func:`codecs.decode` in the +:term:`free-threaded build` when another thread concurrently unregisters a +codec search function. Patch by Christian Aurich Zanettini Martins. + +.. + +.. date: 2026-10-13-16-38-00 +.. gh-issue: 159320 +.. nonce: _Yhg1s +.. section: Core and Builtins + +Add dynamic detection of stack sizes on Android, allowing safer deep +recursion. + +.. + +.. date: 2026-10-13-06-23-56 +.. gh-issue: 159294 +.. nonce: 9LTsNA +.. section: Core and Builtins + +Fix a crash in a debug build when creating an :exc:`ExceptionGroup` or +:exc:`BaseExceptionGroup` fails with :exc:`MemoryError`. Patch by Christian +Aurich Zanettini Martins. + +.. + +.. date: 2026-10-13-04-03-48 +.. gh-issue: 159288 +.. nonce: vhqBQG +.. section: Core and Builtins + +Fix a crash when walking a very long chain of lazy import placeholders, as +created by an aliased dotted import such as ``lazy import a.b.c as d``. +:exc:`RecursionError` is now raised instead. + +.. + +.. date: 2026-10-12-20-00-00 +.. gh-issue: 159136 +.. nonce: fnAttr +.. section: Core and Builtins + +Setting ``__name__``, ``__qualname__``, ``__doc__`` or ``__module__`` on a +function no longer stops all threads in the free-threaded build. The setters +now use the per-object lock and defer freeing the old value with QSBR, the +same approach used for generator ``__name__``. This fixes a large slowdown +in multi-threaded code using :func:`functools.wraps` since 3.14.7. Readers +of these attributes now use atomic loads, and argument error reporting reads +``__qualname__`` after keyword comparisons, which may execute Python code +and replace it. Previously this could use a freed object. + +.. + +.. date: 2026-10-12-16-00-34 +.. gh-issue: 159244 +.. nonce: ThiobE +.. section: Core and Builtins + +Fix a crash in :class:`dict` and :meth:`dict.update` in the +:term:`free-threaded build` when another thread concurrently mutates a list +used as a key/value pair. Patch by Christian Aurich Zanettini Martins. + +.. + +.. date: 2026-10-12-11-59-37 +.. gh-issue: 68241 +.. nonce: jVpLIJ +.. section: Core and Builtins + +Add EXIT_FAILURE and EXIT_SUCCESS in the sys module. + +.. + +.. date: 2026-10-11-06-36-25 +.. gh-issue: 159188 +.. nonce: Fq7wLm +.. section: Core and Builtins + +In the :term:`free-threaded build`, :func:`compile` no longer immortalizes +the constants of the code objects when it is given an AST object, as was +already the case for a source string. The output of :mod:`marshal` for such +code no longer depends on the code objects which were created before in the +process. + +.. + +.. date: 2026-10-10-20-21-13 +.. gh-issue: 159111 +.. nonce: XVf2k- +.. section: Core and Builtins + +Update mimalloc version from 2.1.2 to 2.5.2. Patch by Donghee Na. + +.. + +.. date: 2026-10-09-16-04-40 +.. gh-issue: 159041 +.. nonce: PUP8bU +.. section: Core and Builtins + +Fix a use-after-free in :mod:`asyncio` task bookkeeping when a finalizer +creates a task during thread shutdown. + +.. + +.. date: 2026-10-07-00-00-00 +.. gh-issue: 158973 +.. nonce: warnings-fork +.. section: Core and Builtins + +Reset the warnings lock in the child after :func:`os.fork`, before clearing +other threads' states, to avoid deadlocks when their finalizers issue +warnings. Preserve the lock's recursion depth if the forking thread owns it. + +.. + +.. date: 2026-10-05-13-19-49 +.. gh-issue: 87613 +.. nonce: JLTGBy +.. section: Core and Builtins + +Speed up :class:`bytes` and :class:`bytearray` construction by adding +:ref:`vectorcall` support. + +.. + +.. date: 2026-10-04-20-04-55 +.. gh-issue: 158816 +.. nonce: 9ulhWb +.. section: Core and Builtins + +Speed up deleting items from split dictionaries (for example the +materialized ``__dict__`` of an instance with inline values) by skipping a +redundant hash table probe. + +.. + +.. date: 2026-10-03-13-00-00 +.. gh-issue: 158197 +.. nonce: Qk7sVd +.. section: Core and Builtins + +Fix crashes and debug-build assertion failures in the :term:`free-threaded +build` when iterating over a split dictionary while another thread deletes +entries or clears it. Publish insertion-order updates atomically so readers +cannot observe an increased size before the corresponding order entry is +initialized. + +.. + +.. date: 2026-10-01-00-00-00 +.. gh-issue: 158525 +.. nonce: Xw3K9a +.. section: Core and Builtins + +Fix slow ``dict.copy()`` for dicts with many deleted entries in the +free-threaded build. + +.. + +.. date: 2026-09-30-21-29-54 +.. gh-issue: 158529 +.. nonce: kZO7mX +.. section: Core and Builtins + +Fixed crash on Android x86_64, API levels 27-28, caused by mimalloc calling +system calls directly. + +.. + +.. date: 2026-09-29-14-35-00 +.. gh-issue: 158121 +.. nonce: Kj4nQ8 +.. section: Core and Builtins + +Fix missing :mod:`sys.monitoring` ``INSTRUCTION`` events when a ``LINE`` +callback returns :data:`sys.monitoring.DISABLE`. + +.. + +.. date: 2026-09-28-10-12-25 +.. gh-issue: 158304 +.. nonce: 3pdcnJ +.. section: Core and Builtins + +Speed up iteration over asynchronous generators: values yielded to ``async +for`` no longer create and discard a :exc:`StopIteration` exception at every +nesting level. The ``async_generators`` pyperformance benchmark is about 30% +faster. Patch by Shamil Abdulaev. + +.. + +.. date: 2026-09-25-11-05-00 +.. gh-issue: 157746 +.. nonce: q7Lk3d +.. section: Core and Builtins + +Reduce the overhead of :c:func:`PyErr_CheckSignals` when no signal is +pending: the cheap flag checks are now done before the main-thread check and +the remote debugger configuration lookup. + +.. + +.. date: 2026-09-21-12-44-38 +.. gh-issue: 132414 +.. nonce: uwxmd5 +.. section: Core and Builtins + +Quote the invalid option in the error message for an unknown command-line +option: ``Invalid option '-z'`` instead of ``Unknown option: -z``. A stray +space, as passed by a shebang line like ``#!/usr/bin/python3 -q -i``, is now +reported as ``Invalid option '- '``. + +.. + +.. date: 2026-09-13-10-00-00 +.. gh-issue: 157361 +.. nonce: aiterpy +.. section: Core and Builtins + +Implement :func:`aiter` in Python instead of C, in the frozen +``_pybuiltins`` module. The async iterator returned by ``aiter(callable, +...)`` now has a plain coroutine ``__anext__()``, so introspection tools +such as :func:`asyncio.print_call_graph` can see through it into the awaited +callable result. + +.. + +.. date: 2026-09-08-17-40-00 +.. gh-issue: 157194 +.. nonce: 17Ffhk +.. section: Core and Builtins + +Fix a data race in the free-threaded build, reported by ThreadSanitizer, +between the specializer reading an instruction opcode and another thread +writing it. Only reachable when thread-local bytecode is disabled with ``-X +tlbc=0``, which makes threads share one copy of the bytecode. + +.. + +.. date: 2026-09-07-09-52-21 +.. gh-issue: 156443 +.. nonce: tT40sm +.. section: Core and Builtins + +Speed up :func:`float` conversion and true division of large :class:`int` +values. + +.. + +.. date: 2026-08-30-16-30-00 +.. gh-issue: 135385 +.. nonce: Wn7Rd4 +.. section: Core and Builtins + +Reduce the memory consumption of instances of classes which define +``__slots__`` and also have a ``__dict__``. Space for the attributes stored +in slots is no longer reserved in the inline values of every instance. + +.. + +.. date: 2026-08-27-17-26-21 +.. gh-issue: 106045 +.. nonce: wzTH7f +.. section: Core and Builtins + +Fix standard library discovery in virtual environments created from a Python +executable symlink located outside its base installation. + +.. + +.. date: 2026-08-27-00-00-00 +.. gh-issue: 156399 +.. nonce: aB3xYz +.. section: Core and Builtins + +Fix a regression where attribute access on a :class:`types.ModuleType` +subclass could bypass a data descriptor defined on the subclass. The +``LOAD_ATTR_MODULE`` specialization guarded on ``tp_getattro``, which +subclasses inherit, and then read the module dictionary directly. + +.. + +.. date: 2026-08-21-14-37-50 +.. gh-issue: 127716 +.. nonce: KrPth8 +.. section: Core and Builtins + +On the free-threaded build, :class:`memoryview` lifetime and bookkeeping +operations are now thread safe: an operation that reads the buffer holds the +managed buffer for its duration, so a concurrent :meth:`~memoryview.release` +can no longer free the buffer under it; slicing a memoryview from several +threads no longer loses buffer registrations and raises ``ValueError: +operation forbidden on released memoryview object``; and :func:`hash` of a +memoryview is no longer a data race. As a result :meth:`~memoryview.release` +may now return while an operation started by another thread is still +running, see :ref:`thread-safety-memoryview`. + +.. + +.. date: 2026-07-21-10-42-15 +.. gh-issue: 154318 +.. nonce: Kq3Wm7 +.. section: Core and Builtins + +Fix a crash when hashing a deeply nested :class:`tuple` or +:class:`frozendict`. A :exc:`RecursionError` is now raised instead of +overflowing the C stack. + +.. + +.. date: 2026-07-11-15-00-13 +.. gh-issue: 153568 +.. nonce: atomfp +.. section: Core and Builtins + +Speed up parsing of simple expressions by recognizing single-token atoms +without descending the full precedence rule chain. + +.. + +.. date: 2026-07-04-18-00-00 +.. gh-issue: 153014 +.. nonce: gCdBg1 +.. section: Core and Builtins + +Fix a data race on the garbage collector debug flag in free-threading +builds: :func:`gc.set_debug` and :func:`gc.get_debug` now access it +atomically. + +.. + +.. date: 2026-06-29-23-01-07 +.. gh-issue: 152631 +.. nonce: LKgCM_ +.. section: Core and Builtins + +Fix :func:`ast.parse` ability to parse lazy imports with *feature_version* +older than 3.15, now it properly raises :exc:`SyntaxError`. + +.. + +.. date: 2026-06-26-00-02-29 +.. gh-issue: 149816 +.. nonce: JKN-5B +.. section: Core and Builtins + +Fix a race in free-threaded builds where storing an instance attribute could +use a stale borrowed reference to an instance ``__dict__`` after another +thread replaced it. + +.. + +.. date: 2026-06-20-18-00-00 +.. gh-issue: 151818 +.. nonce: LsApDf +.. section: Core and Builtins + +Fix a double-free crash in ``list.append()`` (the specialized +``CALL_LIST_APPEND`` instruction) when growing the list fails with +:exc:`MemoryError`. + +.. + +.. date: 2026-06-07-22-03-20 +.. gh-issue: 151060 +.. nonce: tdexEE +.. section: Core and Builtins + +Fix a crash or memory corruption in :func:`sum` when summing a +:class:`float` subclass instance into a complex running total. + +.. + +.. date: 2026-05-21-14-21-06 +.. gh-issue: 150075 +.. nonce: dLI21Z +.. section: Core and Builtins + +tar.addfile() now sets member offsets in TarInfo objects + +.. + +.. date: 2026-04-23-08-36-47 +.. gh-issue: 148891 +.. nonce: AMMHow +.. section: Core and Builtins + +Fix a crash in :func:`contextvars.Context.run` where a GC invocation could +free the current HAMT during traverse. + +.. + +.. date: 2026-04-15-21-55-45 +.. gh-issue: 69605 +.. nonce: NwoP6l +.. section: Core and Builtins + +Fix :term:`REPL` completions inserted incorrectly when there was spaces in +import statements. + +.. + +.. date: 2026-04-12-13-48-26 +.. gh-issue: 69605 +.. nonce: T9HWOL +.. section: Core and Builtins + +Insert ``import`` after ``from x.y.z `` in the :term:`REPL` +auto-completion. + +.. + +.. date: 2026-03-14-11-20-52 +.. gh-issue: 145019 +.. nonce: ls2EXo +.. section: Core and Builtins + +Improve :exc:`SyntaxError` when :keyword:`match` alternative patterns bind +different names. Patch by Bénédikt Tran. + +.. + +.. date: 2025-08-19-16-10-26 +.. gh-issue: 137966 +.. nonce: nEgFAt +.. section: Core and Builtins + +Add support for additional special names to the built-in :func:`help` +function. Patch by Adam Hartz. + +.. + +.. date: 2024-10-27-22-23-57 +.. gh-issue: 125873 +.. nonce: BG97KU +.. section: Core and Builtins + +Improved error message when an environment variable is misconfigured. + +.. + +.. date: 2024-08-11-12-06-23 +.. gh-issue: 122901 +.. nonce: B2Huom +.. section: Core and Builtins + +Speed up creating :class:`str` objects from non-ASCII character data. + +.. + +.. date: 2024-03-07-22-38-07 +.. gh-issue: 116477 +.. nonce: AqwRAV +.. section: Core and Builtins + +Speed up the :class:`range` object constructor in the case of a single +argument. + +.. + +.. date: 2026-11-06-11-59-26 +.. gh-issue: 161475 +.. nonce: 82LWf4 +.. section: Library + +Fix :mod:`ctypes` structures containing arrays of floating-point type +returned by value on 64-bit Linux SPARC. + +.. + +.. date: 2026-11-06-05-42-11 +.. gh-issue: 71199 +.. nonce: qJN4cV +.. section: Library + +Change :mod:`os` module types such as :class:`~os.DirEntry` to report ``os`` +as their module on every platform. :ref:`Pickled ` objects +using the platform-specific qualified name, such as ``nt.times_result``, +still load. + +.. + +.. date: 2026-11-06-00-00-00 +.. gh-issue: 142782 +.. nonce: qU7nE4 +.. section: Library + +Fix a use-after-free in :class:`zoneinfo.ZoneInfo` when a key's ``__eq__`` +clears the cache during a lookup. Strong cache keys are now compared by +string contents. + +.. + +.. date: 2026-11-05-12-00-24 +.. gh-issue: 161415 +.. nonce: NJhrAR +.. section: Library + +Remove ``FILES`` and ``unicode`` from the related help topics listed by +:func:`help` for the ``TYPES`` and ``UNICODE`` topics. Neither exists in +Python 3, so asking for help on them failed. + +.. + +.. date: 2026-11-05-11-59-58 +.. gh-issue: 161414 +.. nonce: Xnxe8A +.. section: Library + +Remove the backquote from the symbols listed by :func:`help`, asking for +help on it reported that no documentation was found. + +.. + +.. date: 2026-11-05-11-56-50 +.. gh-issue: 161389 +.. nonce: EIl2E6 +.. section: Library + +Fixes a crash in :class:`decimal.Context` when passing invalid signaling +dicts as *flags* and *traps*. + +.. + +.. date: 2026-11-05-10-05-00 +.. gh-issue: 161387 +.. nonce: def456 +.. section: Library + +Fix a crash in :mod:`decimal` when the internal ``decimal_context`` +:class:`contextvars.ContextVar` holds a value that is not a context. + +.. + +.. date: 2026-11-03-21-26-09 +.. gh-issue: 161295 +.. nonce: IJqoJM +.. section: Library + +:class:`reprlib.Repr` objects now have a meaningful :meth:`~object.__repr__` +describing the instance attributes. + +.. + +.. date: 2026-11-03-18-56-28 +.. gh-issue: 161259 +.. nonce: iyZz6y +.. section: Library + +Improved the accuracy of :func:`statistics.correlation` for very small +inputs, where the product of the sums of squares is subnormal rather than +zero. + +.. + +.. date: 2026-11-03-12-00-00 +.. gh-issue: 93821 +.. nonce: aCcRsT +.. section: Library + +Fix :class:`asyncio.ProactorEventLoop` servers that stopped accepting new +connections on Windows when a client reset its connection before it was +accepted (``WinError 64``, ``ERROR_NETNAME_DELETED``). The listening socket +is now kept open and the server continues to accept connections. + +.. + +.. date: 2026-11-03-12-00-00 +.. gh-issue: 161076 +.. nonce: nOdLy1 +.. section: Library + +Fix :mod:`asyncio` leaving a half-created transport registered with the +event loop and the server when setting ``TCP_NODELAY`` on a socket fails. +Such a failure could make :meth:`asyncio.Server.wait_closed` hang and +prevent new connections from being served. Errors from +``setsockopt(TCP_NODELAY)`` are now ignored. + +.. + +.. date: 2026-11-03-10-33-33 +.. gh-issue: 161233 +.. nonce: _9VrfL +.. section: Library + +Fix unraisable :exc:`TypeError` when ``None`` was passed as a *timer* to +:class:`cProfile.Profile `. + +.. + +.. date: 2026-11-02-21-10-00 +.. gh-issue: 161212 +.. nonce: pip263 +.. section: Library + +Bump the version of :pypi:`pip` bundled in :mod:`ensurepip` to version 26.3. + +.. + +.. date: 2026-11-02-16-28-11 +.. gh-issue: 161178 +.. nonce: D3-23R +.. section: Library + +Fix :meth:`asyncio.Task.print_stack` to include frames from async generator +operations. Patch by Timofei Ivankov + +.. + +.. date: 2026-11-02-13-26-36 +.. gh-issue: 161179 +.. nonce: H8Yyaw +.. section: Library + +Fix the function names in the error messages of :func:`os.spawnve`, +:func:`os.preadv` and :meth:`tkinter.Wm.wm_attributes`. + +.. + +.. date: 2026-11-02-13-11-30 +.. gh-issue: 161166 +.. nonce: zfFDlW +.. section: Library + +Fix :meth:`asyncio.Task.print_stack` displaying an incorrect exception line +after a ``finally`` block. Patch by Timofei Ivankov. + +.. + +.. date: 2026-11-01-22-07-24 +.. gh-issue: 161124 +.. nonce: c2YmcV +.. section: Library + +Fix :func:`asyncio.print_call_graph` reporting event loop frames when +*depth* exceeds the task stack. Patch by Timofei Ivankov. + +.. + +.. date: 2026-11-01-19-38-33 +.. gh-issue: 161083 +.. nonce: PM21lv +.. section: Library + +Fix stale task nodes left by :func:`asyncio.gather` when argument validation +fails. Patch by Timofei Ivankov + +.. + +.. date: 2026-10-31-21-34-00 +.. gh-issue: 161039 +.. nonce: k7_pTD +.. section: Library + +Fix the :mod:`pydoc` pager not detecting ``less`` 706 and newer. + +.. + +.. date: 2026-10-30-12-00-00 +.. gh-issue: 137549 +.. nonce: Tm0Bxg +.. section: Library + +:func:`asyncio.timeout` now inserts :exc:`TimeoutError` into the context +chain of sub-exceptions of a :exc:`BaseExceptionGroup`, as it already did +for :exc:`ExceptionGroup`. + +.. + +.. date: 2026-10-30-10-36-30 +.. gh-issue: 160782 +.. nonce: n6JCUU +.. section: Library + +:mod:`venv`: a symbolic link or junction in place of a directory inside the +environment now raises :exc:`ValueError` instead of being followed. + +.. + +.. date: 2026-10-29-23-25-31 +.. gh-issue: 160782 +.. nonce: 1ZwCOr +.. section: Library + +:mod:`venv`: a backslash before a quote in the prompt or the path no longer +breaks ``activate.fish``. + +.. + +.. date: 2026-10-29-21-43-53 +.. gh-issue: 160429 +.. nonce: eWapMs +.. section: Library + +Fix :class:`asyncio.ProactorEventLoop` socket transports leaving the socket +open, and :meth:`asyncio.Server.wait_closed` hanging, when the peer resets +the connection while the transport is being closed. + +.. + +.. date: 2026-10-29-21-36-08 +.. gh-issue: 160929 +.. nonce: mK8n2Q +.. section: Library + +Fix reverse union with :class:`~collections.ChainMap` to preserve its lookup +semantics for defaulting mappings such as :class:`~collections.Counter` and +:class:`~collections.defaultdict`. + +.. + +.. date: 2026-10-29-20-52-57 +.. gh-issue: 50720 +.. nonce: Kd1VMR +.. section: Library + +:exc:`urllib.error.URLError` now sets the :attr:`~OSError.errno` and +:attr:`~OSError.strerror` attributes from +:attr:`~urllib.error.URLError.reason` when it is an :exc:`OSError`. On +Windows, :attr:`~OSError.winerror` is set as well. + +.. + +.. date: 2026-10-29-19-42-53 +.. gh-issue: 53089 +.. nonce: ewaIBvY6 +.. section: Library + +:class:`urllib.request.HTTPDigestAuthHandler` now sends ``uri="/"`` in the +Digest ``Authorization`` header for URLs with an empty path, such as +``http://example.com``, matching the request-target sent by +:mod:`http.client`. Previously it sent ``uri=""``, which servers could +reject. Patch by Senthil Kumaran. + +.. + +.. date: 2026-10-28-20-36-44 +.. gh-issue: 109564 +.. nonce: WqoyNE +.. section: Library + +Fix a race in :mod:`asyncio` where closing a server after it accepted a +connection, but before the connection's transport was created, reported an +:exc:`AssertionError` to the exception handler. Such connections are now +closed quietly. + +.. + +.. date: 2026-10-28-16-40-00 +.. gh-issue: 66333 +.. nonce: pdb-sigint +.. section: Library + +Allow Ctrl-C to interrupt execution resumed with the :mod:`pdb` ``next``, +``until``, and ``return`` commands without unwinding the debugged program, +as with ``continue``. + +.. + +.. date: 2026-10-28-13-23-28 +.. gh-issue: 59515 +.. nonce: wt31yNN4 +.. section: Library + +:class:`urllib.request.HTTPDigestAuthHandler` and +:class:`urllib.request.ProxyDigestAuthHandler` now parse all +``WWW-Authenticate`` (or ``Proxy-Authenticate``) headers and accept multiple +challenges per header: the first Digest challenge is used. + +.. + +.. date: 2026-10-28-12-00-00 +.. gh-issue: 53852 +.. nonce: Pr0xy4 +.. section: Library + +:class:`urllib.request.ProxyDigestAuthHandler` now raises +:exc:`~urllib.error.HTTPError` with status code 407 (Proxy Authentication +Required) instead of 401 when proxy authentication fails. + +.. + +.. date: 2026-10-28-08-12-33 +.. gh-issue: 160811 +.. nonce: wQ3xT7 +.. section: Library + +Fix :meth:`io.TextIOWrapper.tell` reading past the end of the buffer after +:meth:`~io.TextIOWrapper.seek`. + +.. + +.. date: 2026-10-28-07-34-05 +.. gh-issue: 160806 +.. nonce: ZZRkhi +.. section: Library + +Fix the pure-Python implementation of :class:`datetime.timedelta` losing +sub-second precision with large float arguments. It now gives the same +results as the C implementation. + +.. + +.. date: 2026-10-28-07-26-47 +.. gh-issue: 160804 +.. nonce: R5HeTQ +.. section: Library + +:mod:`asyncio` call graph introspection now includes frames of generator +based awaitables, such as generators returned by ``__await__`` and +:func:`types.coroutine` generators. + +.. + +.. date: 2026-10-27-15-42-16 +.. gh-issue: 160781 +.. nonce: VGLB9S +.. section: Library + +Fix :class:`io.BytesIO` implementation of :meth:`io.IOBase.truncate` +rejecting sizes larger than ``2**31 - 1`` on Windows. + +.. + +.. date: 2026-10-27-15-27-32 +.. gh-issue: 160781 +.. nonce: kARuHu +.. section: Library + +Fix :class:`io.StringIO` implementation of :meth:`io.IOBase.truncate` +rejecting sizes larger than ``2**31 - 1`` on Windows. + +.. + +.. date: 2026-10-27-15-26-53 +.. gh-issue: 160781 +.. nonce: 4VSeQK +.. section: Library + +Fix :class:`io.BytesIO` raising :exc:`SystemError` instead of +:exc:`OverflowError` when writing at a position close to +:data:`sys.maxsize`. + +.. + +.. date: 2026-10-26-21-37-42 +.. gh-issue: 158500 +.. nonce: zxyuq5 +.. section: Library + +:meth:`datetime.date.fromisoformat` now rejects strings with trailing +characters after a basic-format date, such as ``'2020010112'``. The +pure-Python :meth:`datetime.datetime.fromisoformat` now rejects a date +followed by a bare separator, such as ``'2020-01-01T'``, matching the C +implementation. + +.. + +.. date: 2026-10-26-16-17-45 +.. gh-issue: 160708 +.. nonce: w7z33g +.. section: Library + +Fix out-of-bounds memory access in :func:`bool` on :mod:`ctypes` simple +objects enlarged by :func:`ctypes.resize`, and when passing such objects to +a foreign function. + +.. + +.. date: 2026-10-26-16-15-29 +.. gh-issue: 160427 +.. nonce: 9G4EBb +.. section: Library + +Fix :attr:`~io.TextIOBase.buffer` of a detached :class:`io.TextIOWrapper` +raising :exc:`ValueError` instead of returning ``None``. + +.. + +.. date: 2026-10-24-22-32-23 +.. gh-issue: 160596 +.. nonce: RKll-Z +.. section: Library + +Fix the error message for invalid data passed to +:meth:`!asyncio.proactor_events.sendto`. + +.. + +.. date: 2026-10-24-07-58-00 +.. gh-issue: 160561 +.. nonce: b3Kq1z +.. section: Library + +Fix a descriptor leak in :func:`socket.fromfd` when the socket constructor +rejects its arguments. The duplicated descriptor was never closed. + +.. + +.. date: 2026-10-24-01-53-42 +.. gh-issue: 160433 +.. nonce: DSTlog +.. section: Library + +Fix incorrect backup names around daylight saving time changes in +:class:`logging.handlers.TimedRotatingFileHandler`, including delayed +rollovers. + +.. + +.. date: 2026-10-23-23-21-21 +.. gh-issue: 160549 +.. nonce: q7ZdMt +.. section: Library + +Fix a crash when a :class:`compression.zstd.ZstdCompressor` that uses worker +threads and a :class:`~compression.zstd.ZstdDict` is deallocated, or the +interpreter exits, while data passed to +:meth:`~compression.zstd.ZstdCompressor.compress` is still being compressed. + +.. + +.. date: 2026-10-23-22-34-55 +.. gh-issue: 160535 +.. nonce: Zk3dGc +.. section: Library + +Fix a crash in :mod:`compression.zstd` when the garbage collector frees a +:class:`~compression.zstd.ZstdCompressor` that uses worker threads together +with its :class:`~compression.zstd.ZstdDict` before the compression of +already submitted data has finished. + +.. + +.. date: 2026-10-23-21-52-40 +.. gh-issue: 60299 +.. nonce: Af6IzL +.. section: Library + +Fix :class:`urllib.request.ProxyDigestAuthHandler` failing to authenticate. +It looked up credentials using the target request URL instead of the proxy's +authority, so passwords registered via ``add_password()`` against the proxy +never matched. Patch by Senthil Kumaran. + +.. + +.. date: 2026-10-22-22-51-40 +.. gh-issue: 160386 +.. nonce: wYyboz +.. section: Library + +Applied changes to ``importlib.metadata`` from `importlib_metadata 9.1 +`_: +distribution discovery now prefers the greater of several metadata +directories supplied by one path, so stale metadata left by an unclean +upgrade no longer shadows the version in use; a missing required metadata +field now raises a ``KeyError`` naming both the field and the distribution; +``EntryPoint`` value validation is deferred until the value is used, so one +malformed entry point no longer prevents others from being selected; +``importlib.metadata.diagnose`` no longer crashes on a metadata directory +with no metadata file or no declared name; and ``SimplePath.joinpath`` and +``SimplePath.__truediv__`` take ``other`` positional-only. + +.. + +.. date: 2026-10-22-18-30-00 +.. gh-issue: 160520 +.. nonce: sSdTmo +.. section: Library + +Fix :mod:`asyncio` SSL transports not applying *ssl_shutdown_timeout* when +the peer has sent EOF but does not read the data still queued for it. +Closing such a connection could wait indefinitely; it is now aborted with +:exc:`TimeoutError` once the timeout expires. + +.. + +.. date: 2026-10-22-18-30-00 +.. gh-issue: 160326 +.. nonce: nAn7Tq +.. section: Library + +Raise :exc:`ValueError` for a NaN *timeout* in +:meth:`threading.Condition.wait` and the blocking calls built on it, such as +:meth:`threading.Event.wait`, :meth:`threading.Semaphore.acquire` and +:meth:`queue.Queue.get`, instead of returning at once or looping without +ever timing out. + +.. + +.. date: 2026-10-22-18-30-00 +.. gh-issue: 160314 +.. nonce: q7RkZd +.. section: Library + +Raise an error in :class:`lzma.LZMAFile`, :func:`lzma.decompress`, +:class:`bz2.BZ2File` and :func:`bz2.decompress` for a damaged ``.xz`` or +bzip2 stream that follows another stream, instead of silently ignoring it +and everything after it as trailing data. + +.. + +.. date: 2026-10-22-16-30-00 +.. gh-issue: 159739 +.. nonce: tRq417 +.. section: Library + +Fix crashes in :mod:`sqlite3` when a row or text factory is replaced during +a query, when cursor metadata is read during execution in a free-threaded +build, or when allocating cursor metadata fails. + +.. + +.. date: 2026-10-22-16-30-00 +.. gh-issue: 159739 +.. nonce: mFWntK +.. section: Library + +Fix crashes in :mod:`profiling.tracing` when a custom timer reinitializes +the profiler or its result clears or disables the profiler during conversion +or cleanup. + +.. + +.. date: 2026-10-22-16-23-01 +.. gh-issue: 159739 +.. nonce: XmlH3a +.. section: Library + +Fix crashes in :mod:`xml.parsers.expat` when a character data callback +disables buffering or clears another handler during a flush, or when +interning an attribute name changes +:attr:`~xml.parsers.expat.xmlparser.ordered_attributes`. + +.. + +.. date: 2026-10-22-16-23-01 +.. gh-issue: 159739 +.. nonce: CjkR5a +.. section: Library + +Fix the ``hz`` codec sometimes encoding ``~`` as a single ``~`` in text that +mixes ASCII and Chinese characters, and the incremental ``iso2022_*`` codecs +mishandling an escape sequence split across calls or keeping the previous +character set after :meth:`!reset`. Also fix possible crashes in the CJK +incremental and stream codecs when their ``errors`` attribute or their +class's ``codec`` attribute is replaced while they are in use. + +.. + +.. date: 2026-10-22-16-18-42 +.. gh-issue: 159739 +.. nonce: TioR3a +.. section: Library + +Fix crashes in :class:`io.TextIOWrapper` and +:class:`io.IncrementalNewlineDecoder` when a callback changes the active +codec or decoded buffer. :class:`io.StringIO` now raises :exc:`ValueError` +if converting the size passed to ``truncate()`` closes the stream. + +.. + +.. date: 2026-10-22-08-34-22 +.. gh-issue: 160310 +.. nonce: q7Zm2K +.. section: Library + +Fix quadratic time complexity of :func:`gzip.decompress`, +:func:`bz2.decompress`, :func:`lzma.decompress` and +:func:`compression.zstd.decompress` on data consisting of many concatenated +members. + +.. + +.. date: 2026-10-22-08-18-31 +.. gh-issue: 160522 +.. nonce: cJkSt8 +.. section: Library + +Fix the incremental encoders and stream writers of the stateful CJK codecs +(``iso2022_*`` and ``hz``) keeping a changed shift state after an +:meth:`!encode` or :meth:`!write` call failed. The next call could omit the +escape sequence, writing multibyte characters in ASCII mode. + +.. + +.. date: 2026-10-22-08-17-51 +.. gh-issue: 160316 +.. nonce: sRe9pQ +.. section: Library + +Fix :meth:`re.Pattern.match`, :meth:`re.Pattern.prefixmatch`, +:meth:`re.Pattern.fullmatch` and the ``match()`` and ``prefixmatch()`` +methods of scanner objects returning an empty match, or reading past the end +of the string, when *pos* is greater than *endpos*. They now return +``None``, as documented. + +.. + +.. date: 2026-10-22-08-15-56 +.. gh-issue: 160324 +.. nonce: sIoRlz +.. section: Library + +Fix a crash or garbage data when an :class:`io.StringIO` object is used +again after one of its methods failed with :exc:`MemoryError`. The object +now keeps its contents. + +.. + +.. date: 2026-10-22-08-09-29 +.. gh-issue: 160406 +.. nonce: q7Rk2d +.. section: Library + +Fix in-place filtering in :mod:`fileinput` deleting the file when it cannot +be opened or the output file cannot be created: the backup file is now kept. +The output file is now created exclusively, so :exc:`FileExistsError` is +raised if a file or symbolic link appears under the name of the input file. + +.. + +.. date: 2026-10-22-08-06-39 +.. gh-issue: 160513 +.. nonce: q7RkZd +.. section: Library + +Fix :meth:`asyncio.loop.start_tls` and +:meth:`asyncio.StreamWriter.start_tls` not calling the protocol's +:meth:`~asyncio.BaseProtocol.connection_lost` when the connection is lost, +the handshake times out or the call is cancelled during the TLS handshake. +:meth:`asyncio.StreamWriter.wait_closed` no longer waits forever after such +a failure. + +.. + +.. date: 2026-10-22-08-04-26 +.. gh-issue: 160297 +.. nonce: hL4kQz +.. section: Library + +Fix :meth:`tarfile.TarFile.extractall` and :meth:`tarfile.TarFile.extract` +changing the mode, modification time and owner of a file outside the +destination directory when a hard link member is extracted as a copy of a +symbolic link member, for example with the ``'tar'`` filter. + +.. + +.. date: 2026-10-22-05-24-34 +.. gh-issue: 161086 +.. nonce: FGPjqA +.. section: Library + +Fix the :mod:`gzip` command-line interface ignoring :option:`gzip --fast` +and :option:`gzip --best` when compressing files given as arguments. + +.. + +.. date: 2026-10-22-05-24-21 +.. gh-issue: 161112 +.. nonce: BFrZRw +.. section: Library + +Fix :func:`shutil.make_archive` adding the zip archive being created to +itself when it is written inside the directory being archived or a symbolic +link in that directory refers to it. + +.. + +.. date: 2026-10-22-05-23-40 +.. gh-issue: 161088 +.. nonce: _-HEWz +.. section: Library + +Fix the :mod:`gzip` command-line interface writing through a symbolic link +at the output file name. Like :program:`gzip`, it now replaces an existing +output file with a new one that has the permission bits of the input file. + +.. + +.. date: 2026-10-22-05-21-00 +.. gh-issue: 161094 +.. nonce: MDjCNm +.. section: Library + +Fix :func:`zipfile.is_zipfile` raising :exc:`ValueError` instead of +returning ``False`` for a file-like object, such as :class:`io.BytesIO`, +whose end of central directory record places the central directory before +the start of the file. + +.. + +.. date: 2026-10-22-05-20-52 +.. gh-issue: 161096 +.. nonce: vkhfyy +.. section: Library + +Fix :meth:`zoneinfo.ZoneInfo.from_file` accepting TZif data with a negative +or oversized abbreviation block, which could use hundreds of times the file +size in memory; it now raises :exc:`ValueError`. Abbreviation indexes above +127 now also give the correct time zone abbreviation. + +.. + +.. date: 2026-10-22-05-20-44 +.. gh-issue: 161106 +.. nonce: t0ux5q +.. section: Library + +Fix :func:`plistlib.dump` and :func:`plistlib.dumps` with +:data:`~plistlib.FMT_BINARY` holding on to memory proportional to the size +of large arrays and dictionaries after the call returns. + +.. + +.. date: 2026-10-22-05-20-27 +.. gh-issue: 161098 +.. nonce: voMVnd +.. section: Library + +Fix :class:`multiprocessing.shared_memory.ShareableList` leaving its newly +created shared memory block behind when a value cannot be stored, such as an +integer outside the signed 64-bit range. + +.. + +.. date: 2026-10-22-05-20-18 +.. gh-issue: 161108 +.. nonce: xOVsRA +.. section: Library + +Fix quadratic time complexity of :meth:`!clear` and :meth:`!popitem` on +:class:`configparser.ConfigParser` objects and their section proxies. +Clearing a section no longer fails part way with +:exc:`~configparser.InterpolationError` on a value it removes. + +.. + +.. date: 2026-10-22-05-20-11 +.. gh-issue: 161110 +.. nonce: miKrSQ +.. section: Library + +Fix :meth:`~xml.dom.Document.getElementById` in :mod:`xml.dom.minidom` so +that it returns the first element in document order when several elements +have the same ID. Previously, the result could differ between calls on an +unmodified document. + +.. + +.. date: 2026-10-22-05-20-06 +.. gh-issue: 161100 +.. nonce: pLgnlA +.. section: Library + +Fix :attr:`!ipaddress.IPv6Interface.is_unspecified` returning ``False`` for +the IPv4-mapped address ``::ffff:0.0.0.0``. It now gives the same result as +:attr:`ipaddress.IPv6Address.is_unspecified`. + +.. + +.. date: 2026-10-22-05-20-02 +.. gh-issue: 161102 +.. nonce: gqDOIM7X +.. section: Library + +Fix the incremental decoder of the :mod:`idna ` codec +decoding some dots twice when its input starts with empty labels, for +example ``b".example.com"``. Reading a run of dots through +:class:`io.TextIOWrapper` no longer produces quadratically more text than +the input holds. + +.. + +.. date: 2026-10-22-05-20-02 +.. gh-issue: 161092 +.. nonce: OtC5l6 +.. section: Library + +Fix the ``uu`` codec decoder taking any line that starts with ``begin``, +such as ``beginning of the report``, as the header of the encoded data. Like +the :mod:`email` package, it now requires ``begin`` followed by an octal +mode and skips other lines as leading text. + +.. + +.. date: 2026-10-22-05-19-56 +.. gh-issue: 161090 +.. nonce: pxZ1IA +.. section: Library + +Fix the ``punycode`` codec accepting a delimiter (``-``) that is not +preceded by any basic code point. Such input, for example ``b'-80a1acny'``, +now raises :exc:`UnicodeDecodeError`, as required by :rfc:`3492`. + +.. + +.. date: 2026-10-22-03-55-33 +.. gh-issue: 159739 +.. nonce: ce26e1 +.. section: Library + +Fix :mod:`time` functions returning a negative year or failing to accept +their own output for large timestamps on platforms that support them. Avoid +reporting an incorrect year in errors raised by :mod:`datetime` for those +timestamps. + +.. + +.. date: 2026-10-22-03-55-33 +.. gh-issue: 159739 +.. nonce: b4c371 +.. section: Library + +Fix a crash when a :mod:`ctypes` structure subclass cannot be created due to +an allocation failure. + +.. + +.. date: 2026-10-22-03-55-33 +.. gh-issue: 159739 +.. nonce: a8bf30 +.. section: Library + +Fix clearing a :class:`pickle.Unpickler` memo so that the unpickler can be +reused for independent records. + +.. + +.. date: 2026-10-22-00-33-42 +.. gh-issue: 160171 +.. nonce: 11l4om +.. section: Library + +On the server side, :meth:`ssl.SSLSocket.get_unverified_chain` now returns +the client's certificate when the session was resumed from a session ticket, +instead of an empty list, and returns an empty list instead of raising +:exc:`AttributeError` when the client sent no certificate. + +.. + +.. date: 2026-10-22-00-32-51 +.. gh-issue: 160181 +.. nonce: nnEeg1 +.. section: Library + +Fix :meth:`io.BytesIO.getvalue` sometimes returning a :class:`bytes` object +with the hash of earlier contents after the buffer was written to, which +made :class:`dict` and :class:`set` lookups with it fail. + +.. + +.. date: 2026-10-22-00-30-04 +.. gh-issue: 160187 +.. nonce: 9dcj2B +.. section: Library + +Fix the ISO-2022 decoders (``iso2022_jp``, ``iso2022_kr`` and related) +accepting escape sequences that designate a character set to the wrong code +element (G0, G1 or G2). Such sequences now raise :exc:`UnicodeDecodeError` +instead of producing wrong text or :exc:`RuntimeError`. + +.. + +.. date: 2026-10-22-00-29-55 +.. gh-issue: 160185 +.. nonce: BPz40E +.. section: Library + +Fix :meth:`codecs.StreamWriter.reset` of the stateful CJK codecs (``hz`` and +the ``iso2022_*`` family) not writing the sequence that returns the output +to ASCII. ``seek(0)`` of :class:`codecs.StreamWriter`, +:class:`codecs.StreamReaderWriter` and :class:`codecs.StreamRecoder` now +resets the writer before moving the stream position. + +.. + +.. date: 2026-10-22-00-29-50 +.. gh-issue: 160176 +.. nonce: tkNst1 +.. section: Library + +Fix a crash in :mod:`tkinter` when a deeply nested or recursive list or +tuple is passed to Tcl, or a deeply nested Tcl list is converted to Python. +These now raise :exc:`ValueError` (beyond 1000 levels) and +:exc:`RecursionError` respectively. + +.. + +.. date: 2026-10-21-21-26-10 +.. gh-issue: 159739 +.. nonce: yBc6Ei +.. section: Library + +Fix a possible crash in :class:`abc.ABCMeta` instance checks when a +subclass-checking callback changes the instance’s class. + +.. + +.. date: 2026-10-21-21-26-10 +.. gh-issue: 159739 +.. nonce: rVWF2a +.. section: Library + +Fix the ``truncate`` method on :class:`io.BytesIO` when converting its size +argument closes the stream or exports its buffer. + +.. + +.. date: 2026-10-21-21-26-10 +.. gh-issue: 159739 +.. nonce: k8uuGe +.. section: Library + +Raise :exc:`TypeError` if a string subclass returns a non-string during +newline translation in :class:`io.TextIOWrapper`. Recheck the stream state +if the replacement callback closes, detaches or reinitializes the stream. + +.. + +.. date: 2026-10-21-21-26-10 +.. gh-issue: 159739 +.. nonce: ghGctt +.. section: Library + +Fix :class:`contextvars.ContextVar` returning a stale value after a +reentrant finalizer changes it during :meth:`~contextvars.ContextVar.reset`. + +.. + +.. date: 2026-10-21-21-26-10 +.. gh-issue: 159739 +.. nonce: b4ueJ7 +.. section: Library + +Detect recursive ``_as_parameter_`` chains for :mod:`ctypes` calls without +argument types. + +.. + +.. date: 2026-10-21-21-26-10 +.. gh-issue: 159739 +.. nonce: JIqZRY +.. section: Library + +Fix a possible crash when a list of :mod:`sqlite3` parameters is modified +concurrently on a free-threaded build. + +.. + +.. date: 2026-10-21-20-05-00 +.. gh-issue: 160104 +.. nonce: BUAL5C +.. section: Library + +Synchronized :class:`zipfile.Path` with :pypi:`zipp` 4.1.2. +:meth:`zipfile.Path.iterdir` now raises :exc:`NotADirectoryError` instead of +:exc:`ValueError` when the path does not reference a directory. Character +classes in :meth:`!zipfile.Path.glob` and :meth:`!zipfile.Path.rglob` +patterns now follow shell-style semantics, treating a leading ``!`` as +negation and ``^`` as a literal, and no longer match path separators. + +.. + +.. date: 2026-10-21-19-55-00 +.. gh-issue: 159739 +.. nonce: tloc01 +.. section: Library + +Avoid a crash when a :class:`threading.local` subclass finalizer accesses +attributes after construction fails. + +.. + +.. date: 2026-10-21-19-55-00 +.. gh-issue: 159739 +.. nonce: sque01 +.. section: Library + +Avoid a crash when a :class:`queue.SimpleQueue` subclass finalizer adds an +item after construction fails. + +.. + +.. date: 2026-10-21-19-40-00 +.. gh-issue: 100609 +.. nonce: THXgRC +.. section: Library + +``str()`` of a :class:`zipfile.Path` whose underlying zipfile has no +filename, such as one constructed from an :class:`io.BytesIO`, now renders +that filename as ``:zipfile:`` instead of raising :exc:`TypeError`. The root +of a zipfile is also no longer rendered with a trailing slash. Synchronized +with :pypi:`zipp` 3.23.1. + +.. + +.. date: 2026-10-21-19-38-33 +.. gh-issue: 89721 +.. nonce: uMpxRw +.. section: Library + +Add ``copy_dir_stat`` parameter to :func:`shutil.copytree`: set it to false +to skip copying permissions and times of directories with +:func:`shutil.copystat`, e.g. when copying a read-only tree. + +.. + +.. date: 2026-10-21-15-42-29 +.. gh-issue: 159875 +.. nonce: p6j3yW +.. section: Library + +Fix :exc:`AttributeError` from the methods of an :mod:`asyncio` SSL +transport, such as :meth:`~asyncio.WriteTransport.write` and +:meth:`~asyncio.BaseTransport.set_protocol`, when the transport is closed +after its connection was lost. This also affected the fallback of +:meth:`loop.sendfile() ` over SSL when the peer went +away mid-transfer. The SSL context is still released once the connection is +lost. + +.. + +.. date: 2026-10-21-15-10-00 +.. gh-issue: 160125 +.. nonce: pdbpkg +.. section: Library + +Support setting breakpoints with the :mod:`pdb` ``break`` and ``tbreak`` +commands using ``package.module.function`` names when the module has not +been imported in the current namespace. + +.. + +.. date: 2026-10-20-17-29-14 +.. gh-issue: 138641 +.. nonce: FN6qM0 +.. section: Library + +Ignore :func:`pdb.set_trace` when called directly at the :mod:`pdb` prompt. + +.. + +.. date: 2026-10-20-16-00-00 +.. gh-issue: 159868 +.. nonce: qLhYkP +.. section: Library + +Allow :meth:`!collections.UserString.startswith` and +:meth:`!collections.UserString.endswith` to accept a +:class:`~collections.UserString` instance as the prefix or suffix argument. + +.. + +.. date: 2026-10-20-12-30-00 +.. gh-issue: 159864 +.. nonce: 4FZ6MR +.. section: Library + +Fix a crash in :func:`syslog.openlog` under the free-threaded build when +:data:`sys.argv` is modified concurrently. + +.. + +.. date: 2026-10-20-00-12-05 +.. gh-issue: 159690 +.. nonce: vZgLP6 +.. section: Library + +Fix :class:`logging.handlers.TimedRotatingFileHandler` permanently stopping +rollover after a rollover failed or its backup file already existed, for +example at a DST change. + +.. + +.. date: 2026-10-20-00-00-00 +.. gh-issue: 159739 +.. nonce: eb8987 +.. section: Library + +Avoid undefined behavior when :func:`struct.pack_into` copies a bytearray +into overlapping output. + +.. + +.. date: 2026-10-20-00-00-00 +.. gh-issue: 159739 +.. nonce: 9ef89c +.. section: Library + +Fix allocation error handling in the fallback implementation of +``getaddrinfo()``. + +.. + +.. date: 2026-10-20-00-00-00 +.. gh-issue: 159739 +.. nonce: 5d4269 +.. section: Library + +Fix a double free if remote unwinder initialization runs out of memory. + +.. + +.. date: 2026-10-20-00-00-00 +.. gh-issue: 159739 +.. nonce: 4c9783 +.. section: Library + +Fix :meth:`io.IOBase.readline` returning more bytes than requested when a +stream supports :meth:`!peek` and returns short reads. + +.. + +.. date: 2026-10-20-00-00-00 +.. gh-issue: 159739 +.. nonce: 3660a6 +.. section: Library + +Fix multibyte encoders silently consuming a non-BMP character when looking +up a two-character mapping. + +.. + +.. date: 2026-10-20-00-00-00 +.. gh-issue: 159739 +.. nonce: 35942a +.. section: Library + +Improve performance when parsing email address groups with many members. + +.. + +.. date: 2026-10-20-00-00-00 +.. gh-issue: 159739 +.. nonce: 1e4599 +.. section: Library + +Fix off-by-one output buffer checks in the fallback implementation of +``getnameinfo()``. + +.. + +.. date: 2026-10-20-00-00-00 +.. gh-issue: 159739 +.. nonce: 0c4ae9 +.. section: Library + +Fix reference cycles involving the types of grapheme iterators and segments +created by :func:`unicodedata.iter_graphemes`. + +.. + +.. date: 2026-10-19-23-25-29 +.. gh-issue: 159811 +.. nonce: cMB4DO +.. section: Library + +Fix a crash in :mod:`hashlib` when the OpenSSL routine used by +:meth:`hash.update() ` or by hash object constructors +fails on data larger than 2048 bytes. Patch by Bénédikt Tran. + +.. + +.. date: 2026-10-19-23-25-29 +.. gh-issue: 159811 +.. nonce: P6yy0z +.. section: Library + +Fix a crash in :mod:`hmac` when the OpenSSL routine used by +:meth:`hmac.HMAC.update` or by :func:`hmac.new` fails on data larger than +2048 bytes. Patch by Bénédikt Tran. + +.. + +.. date: 2026-10-19-21-20-28 +.. gh-issue: 159786 +.. nonce: fThehQ +.. section: Library + +Fix the error handling of the HACL* routine used by :func:`hmac.new` and +:meth:`hmac.HMAC.update`. If the maximum input length of the underlying hash +function is exceeded, an :exc:`OverflowError` is now raised on all builds, +instead of crashing on DEBUG builds and being silently ignored otherwise. +Code correctness. Realistically this can only happen at implausible sizes. +Patch by Bénédikt Tran. + +.. + +.. date: 2026-10-19-20-38-17 +.. gh-issue: 159739 +.. nonce: ff088c +.. section: Library + +Fix copying :class:`collections.deque` subclasses with a large maximum +length. + +.. + +.. date: 2026-10-19-20-38-17 +.. gh-issue: 159739 +.. nonce: bc65da +.. section: Library + +Allow cyclic garbage collection to reclaim group records returned by +:mod:`grp`. + +.. + +.. date: 2026-10-19-20-38-17 +.. gh-issue: 159739 +.. nonce: a81270 +.. section: Library + +Fix :class:`io.BytesIO` reads into overlapping views of the same buffer. + +.. + +.. date: 2026-10-19-20-38-17 +.. gh-issue: 159739 +.. nonce: 5a6e94 +.. section: Library + +Avoid a crash when memory allocation fails while creating a +:class:`collections.OrderedDict` items iterator. + +.. + +.. date: 2026-10-19-20-38-17 +.. gh-issue: 159739 +.. nonce: 243aa8 +.. section: Library + +Avoid reading past the end of an encoding name when the ``surrogatepass`` +error handler receives a truncated UTF-16 or UTF-32 name. + +.. + +.. date: 2026-10-19-20-38-17 +.. gh-issue: 159739 +.. nonce: 08caa7 +.. section: Library + +Fix incorrect :mod:`ctypes` scalar values after :func:`ctypes.resize` +enlarges the object. + +.. + +.. date: 2026-10-19-19-33-35 +.. gh-issue: 159739 +.. nonce: b5fbca +.. section: Library + +Fix a memory leak when Unicode normalization cannot grow its temporary +buffer. + +.. + +.. date: 2026-10-19-19-33-35 +.. gh-issue: 159739 +.. nonce: a1c3c7 +.. section: Library + +Fix resource leaks in :mod:`ssl` when certificate conversion or key log +setup fails. + +.. + +.. date: 2026-10-19-16-49-09 +.. gh-issue: 159706 +.. nonce: ushGrx +.. section: Library + +Fix the pure-Python :class:`zoneinfo.ZoneInfo` setting ``fold=0`` in +:meth:`~datetime.tzinfo.fromutc` for times in the fold created by the only +transition of a zone with a single transition. + +.. + +.. date: 2026-10-19-16-26-57 +.. gh-issue: 71990 +.. nonce: K3FlJ9 +.. section: Library + +:mod:`ctypes`: objects with an :attr:`!_as_parameter_` attribute are now +implicitly converted when passed for a :func:`~ctypes.POINTER` argument. + +.. + +.. date: 2026-10-19-16-00-00 +.. gh-issue: 139122 +.. nonce: bYtEs1 +.. section: Library + +:class:`uuid.UUID` now consistently raises :exc:`TypeError` when the *bytes* +or *bytes_le* argument is not a :class:`bytes` object. Previously, some +invalid inputs raised :exc:`AssertionError` or :exc:`ValueError`. + +.. + +.. date: 2026-10-19-12-00-00 +.. gh-issue: 78327 +.. nonce: Qk3hzA +.. section: Library + +:mod:`ctypes` data types now set :meth:`~object.__hash__` to ``None``, so +:class:`collections.abc.Hashable` checks report them correctly. + +.. + +.. date: 2026-10-19-12-00-00 +.. gh-issue: 159714 +.. nonce: j59fix +.. section: Library + +Fix :class:`zoneinfo.ZoneInfo` interpreting the Julian day rule ``J59`` as +February 29 in leap years instead of February 28. + +.. + +.. date: 2026-10-19-00-00-00 +.. gh-issue: 149015 +.. nonce: bdb +.. section: Library + +Fix :meth:`bdb.Bdb.clear_all_file_breaks` leaving breakpoints behind when +multiple breakpoints are set on the same line. + +.. + +.. date: 2026-10-18-16-09-24 +.. gh-issue: 159684 +.. nonce: VHVYjVuE +.. section: Library + +Update :mod:`configparser` and its tests to modern linter standards: +printf-style and :meth:`str.format` call sites are now f-strings, and a +handful of constructs have simpler spellings. No behavior change. + +.. + +.. date: 2026-10-18-12-20-00 +.. gh-issue: 159465 +.. nonce: partial-escapes +.. section: Library + +Preserve :exc:`SyntaxError` for malformed escapes in unfinished f-strings +and t-strings passed to :func:`codeop.compile_command`. + +.. + +.. date: 2026-10-18-08-30-10 +.. gh-issue: 155976 +.. nonce: feSum4_j +.. section: Library + +:func:`curses.set_term` and :meth:`curses.screen.use` now update +:data:`curses.LINES`, :data:`curses.COLS`, :data:`curses.COLORS` and +:data:`curses.COLOR_PAIRS` for the current screen. + +.. + +.. date: 2026-10-17-19-41-12 +.. gh-issue: 157210 +.. nonce: o9hycSeJ +.. section: Library + +Fix entering a combining character in the lower-right cell of +:class:`curses.textpad.Textbox`: it no longer takes a cell of its own, +pushing its base character off the window. In insert mode, a combining +character no longer shifts the following text. + +.. + +.. date: 2026-10-17-19-33-13 +.. gh-issue: 159643 +.. nonce: EJfe0IXetV +.. section: Library + +Fix :exc:`EOFError` raised by :mod:`tarfile` in stream mode with bz2, xz or +zstd compression when reading past the end of the compressed data, for +example with *ignore_zeros* or an archive without end-of-archive blocks. + +.. + +.. date: 2026-10-17-15-22-16 +.. gh-issue: 159620 +.. nonce: Ynsu5L +.. section: Library + +Fix ``python -m asyncio ps``, ``pstree`` and async-aware +:mod:`profiling.sampling` stacks stopping at asynchronous generators. Patch +by Timofei Ivankov. + +.. + +.. date: 2026-10-16-18-23-03 +.. gh-issue: 159558 +.. nonce: ctRelk +.. section: Library + +Speed up assignment to the ``value`` attribute of simple :mod:`ctypes` +types, to the ``contents`` attribute of :mod:`ctypes` pointers and to +:mod:`ctypes` structure fields, array items and pointer items on the +free-threaded build by not re-entering the critical section already held on +the object. + +.. + +.. date: 2026-10-16-13-00-00 +.. gh-issue: 159435 +.. nonce: OMNI +.. section: Library + +Fix an offset calculation in :mod:`tarfile` when a PAX header with a +``size`` record is followed by a GNU long-name header. Such archives could +duplicate or skip members while being read. + +.. + +.. date: 2026-10-16-10-25-22 +.. gh-issue: 159458 +.. nonce: q02EnY +.. section: Library + +Fix a ThreadSanitizer data race on the static cache in +``normalize_century()`` of the datetime module under the free-threaded +build. + +.. + +.. date: 2026-10-16-01-56-15 +.. gh-issue: 159503 +.. nonce: WgYiow +.. section: Library + +Fix quadratic copying in :mod:`asyncio` selector socket transports on +partial sends. A :class:`bytearray` passed to +:meth:`~asyncio.WriteTransport.write` now stays locked against resizing +until it has been sent. + +.. + +.. date: 2026-10-15-18-38-22 +.. gh-issue: 159500 +.. nonce: OjAQ8W +.. section: Library + +Speed up :meth:`asyncio.StreamReader.readline` and +:meth:`asyncio.StreamReader.readuntil` when the data is already buffered, +and stop :meth:`~asyncio.StreamReader.readuntil` with a tuple of separators +from scanning the whole buffer on every call. + +.. + +.. date: 2026-10-15-13-44-03 +.. gh-issue: 159465 +.. nonce: Ph-m8w +.. section: Library + +Improve incomplete input detection in :mod:`codeop` without an extra parser +pass, and preserve syntax and compiler errors. + +.. + +.. date: 2026-10-14-14-47-05 +.. gh-issue: 81954 +.. nonce: KvM0gY +.. section: Library + +Fix :class:`zipfile.ZipFile` not being closed at interpreter shutdown when +emitting its :exc:`ResourceWarning` failed with an :exc:`ImportError`. + +.. + +.. date: 2026-10-14-11-41-00 +.. gh-issue: 159430 +.. nonce: ZEW-mx +.. section: Library + +Report the correct exception if looking up ``__name__`` raises an exception +when calling :func:`repr` on a :class:`weakref.ref`. + +.. + +.. date: 2026-10-14-10-26-10 +.. gh-issue: 159387 +.. nonce: xMbQbB +.. section: Library + +Fix :mod:`ssl` reporting TLS 1.0, 1.1, and 1.2 as unavailable when built +with OpenSSL 4.0, despite support for these protocol versions. + +.. + +.. date: 2026-10-14-08-50-00 +.. gh-issue: 159398 +.. nonce: k2Xd7q +.. section: Library + +Fix the sampling profiler crashing when a string read from the target +process contains code points above ``U+10FFFF``. + +.. + +.. date: 2026-10-13-19-10-00 +.. gh-issue: 159322 +.. nonce: hP6k3A +.. section: Library + +Fix :mod:`tarfile` to NUL-terminate user and group names in PAX archive +headers and use extended headers for names longer than 31 characters. + +.. + +.. date: 2026-10-13-12-00-00 +.. gh-issue: 159304 +.. nonce: mFbYq2 +.. section: Library + +Fix :exc:`AttributeError` in :meth:`email.message.EmailMessage.get_body` +when a nested ``multipart`` part is malformed and its payload is a string. + +.. + +.. date: 2026-10-12-21-20-00 +.. gh-issue: 159225 +.. nonce: T8jlor +.. section: Library + +Prevent ``input`` calls in PyREPL from modifying readline history. + +.. + +.. date: 2026-10-12-18-21-06 +.. gh-issue: 159240 +.. nonce: a1b2c3 +.. section: Library + +Deprecate, and schedule for removal in Python 3.20, the ``__author__``, +``__credits__``, ``__copyright__`` and ``__date__`` attributes of +:mod:`bz2`, :mod:`concurrent.futures`, :mod:`inspect`, :mod:`io`, +:mod:`json`, :mod:`logging`, :mod:`optparse`, :mod:`platform`, :mod:`pydoc`, +:mod:`tarfile`, :mod:`tkinter.ttk`, :mod:`tokenize` and :mod:`uuid`. + +.. + +.. date: 2026-10-12-13-05-00 +.. gh-issue: 158501 +.. nonce: n7Qp3k +.. section: Library + +:meth:`datetime.time.fromisoformat` and +:meth:`datetime.datetime.fromisoformat` now reject stray text between the +time and a UTC offset. The C implementation previously accepted strings that +the pure-Python implementation rejected. + +.. + +.. date: 2026-10-12-12-00-00 +.. gh-issue: 72113 +.. nonce: njkm8v +.. section: Library + +Speed up creating a :mod:`ctypes` array from initializers, such as ``(c_int +* 3)(1, 2, 3)``, by roughly 3x. + +.. + +.. date: 2026-10-12-11-36-48 +.. gh-issue: 158856 +.. nonce: jLR-Lv +.. section: Library + +Improve large Enum creation performance. + +.. + +.. date: 2026-10-12-00-00-00 +.. gh-issue: 159044 +.. nonce: Tr8kXv +.. section: Library + +Restore the previous behaviour of +:meth:`http.client.HTTPConnection.set_tunnel` where header values that are +not strings (such as :const:`None`, :class:`int` or other objects) are +converted with :class:`str` instead of raising :exc:`AttributeError` when +the request is sent. + +.. + +.. date: 2026-10-11-13-40-44 +.. gh-issue: 159168 +.. nonce: z3KjB8 +.. section: Library + +Fix :exc:`RecursionError` in ``python -m asyncio pstree`` on a deep chain of +awaiting tasks. Patch by Timofei Ivankov. + +.. + +.. date: 2026-10-11-13-08-07 +.. gh-issue: 88037 +.. nonce: CzKcxh +.. section: Library + +:func:`urllib.parse.urlsplit` and :func:`urllib.parse.urlparse` now raise +:exc:`ValueError` for an invalid port when the URL is parsed, instead of +when the :attr:`!port` attribute is read. Patch by Miguel Brito and Senthil +Kumaran. + +.. + +.. date: 2026-10-11-08-42-00 +.. gh-issue: 159184 +.. nonce: Tq2nSe +.. section: Library + +The output of :func:`marshal.dumps` no longer depends on the order of the +elements of a set which have the same marshalled form, such as NaNs which +are distinct objects. + +.. + +.. date: 2026-10-10-22-29-13 +.. gh-issue: 159049 +.. nonce: eJUiKL +.. section: Library + +Fix reference cycles in :meth:`asyncio.loop.create_connection` and +:meth:`asyncio.loop.start_tls` after a failed TLS handshake. Patch by +Timofei Ivankov. + +.. + +.. date: 2026-10-10-22-14-22 +.. gh-issue: 150751 +.. nonce: JInuGL +.. section: Library + +:mod:`http.client` now ignores optional whitespace around the +``Content-Length`` header value when validating it, as required by +:rfc:`9112`. Previously a value with trailing whitespace (for example +``Content-Length: 5`` followed by a space) was treated as missing and the +response body was read until the connection was closed. + +.. + +.. date: 2026-10-08-21-02-38 +.. gh-issue: 158998 +.. nonce: DZYJI7 +.. section: Library + +Fix :func:`os.statx` ignoring the *follow_symlinks* argument. + +.. + +.. date: 2026-10-08-11-58-52 +.. gh-issue: 158628 +.. nonce: NJxwuw +.. section: Library + +Implement :data:`sys._wasi_info` for exposing WASI-specific system details. + +.. + +.. date: 2026-10-07-17-30-00 +.. gh-issue: 158287 +.. nonce: xY9zQp +.. section: Library + +Fix a bug in :mod:`asyncio` where stopping a child process (such as with +``SIGSTOP``) on macOS caused the event loop to block indefinitely. + +.. + +.. date: 2026-10-07-10-59-27 +.. gh-issue: 155233 +.. nonce: YGuQGK +.. section: Library + +Fix :meth:`asyncio.Barrier.wait` returning duplicate indices when a waiting +task is cancelled before the barrier is released.``` + +.. + +.. date: 2026-10-05-14-58-12 +.. gh-issue: 158839 +.. nonce: wYd6fI +.. section: Library + +The log functions in the :mod:`logging` module and the +:class:`logging.Logger` class now normalize falsy ``exc_info`` arguments to +``None`` before passing them to :meth:`logging.Logger.makeRecord` and +subsequently to :class:`logging.LogRecord`. This aligns +``logging.LogRecord.exc_info`` with the documentation. + +.. + +.. date: 2026-10-05-08-35-10 +.. gh-issue: 130698 +.. nonce: iibO9V +.. section: Library + +Fix PyREPL to convert :data:`sys.ps1` and :data:`sys.ps2` to strings before +use, and fall back to the default prompts if the conversion raises. + +.. + +.. date: 2026-09-29-19-34-30 +.. gh-issue: 158192 +.. nonce: 6wPjiU +.. section: Library + +Expose the future being waited on by a ``FutureIter`` as ``fi_future``. + +.. + +.. date: 2026-09-28-00-00-00 +.. gh-issue: 158370 +.. nonce: ctxmgr +.. section: Library + +:class:`concurrent.interpreters.Interpreter` objects now support the +:term:`context manager` protocol. + +.. + +.. date: 2026-09-27-14-00-00 +.. gh-issue: 158277 +.. nonce: aBcDeF +.. section: Library + +Fix :mod:`sqlite3` CLI completer to include view columns in column-name +completion. + +.. + +.. date: 2026-09-26-05-18-21 +.. gh-issue: 144650 +.. nonce: zqHLOW +.. section: Library + +Use Argument Clinic vectorcall support for the :class:`decimal.Decimal` +type. This offers 1.10x speedup on creation of small instances. + +.. + +.. date: 2026-09-25-17-04-45 +.. gh-issue: 158159 +.. nonce: lbEalG +.. section: Library + +Fix a use-after-free in :meth:`asyncio.Task.get_name` when formatting the +default task name triggers a garbage collection whose finalizers call +:meth:`~asyncio.Task.get_name` on the same task. + +.. + +.. date: 2026-09-25-01-29-55 +.. gh-issue: 158126 +.. nonce: nWmFnq +.. section: Library + +Speed up :func:`pickle.dumps` and creating a :class:`pickle.Pickler` by +avoiding the creation of an :exc:`AttributeError` when looking up the +optional ``reducer_override`` and ``dispatch_table`` attributes. + +.. + +.. date: 2026-09-24-14-59-08 +.. gh-issue: 158095 +.. nonce: lcKOT4 +.. section: Library + +Fix a memory leak in :func:`re.finditer` and regular expression scanners +when their input participates in a reference cycle. + +.. + +.. date: 2026-09-23-23-34-30 +.. gh-issue: 144812 +.. nonce: ujptbVOI +.. section: Library + +Make :class:`argparse.ArgumentGroup` and +:class:`argparse.MutuallyExclusiveGroup` public. The private +``_ArgumentGroup`` and ``_MutuallyExclusiveGroup`` names remain as aliases. + +.. + +.. date: 2026-09-23-19-59-03 +.. gh-issue: 158004 +.. nonce: p68swW +.. section: Library + +Fix :func:`asyncio.as_completed` to continue yielding every awaitable after +a pending iteration step is cancelled. + +.. + +.. date: 2026-09-23-09-21-25 +.. gh-issue: 89977 +.. nonce: fmia18 +.. section: Library + +Avoid releasing the GIL for :meth:`socket.socket.setblocking`, +:meth:`socket.socket.getsockname`, :meth:`socket.socket.getpeername`, and +:func:`socket.gethostname`. + +.. + +.. date: 2026-09-21-21-07-12 +.. gh-issue: 157928 +.. nonce: ZPlNYC +.. section: Library + +Correctly detect and handle OSC sequences in PyREPL. + +.. + +.. date: 2026-09-21-14-41-07 +.. gh-issue: 157899 +.. nonce: s6vBQC +.. section: Library + +:func:`os.readlink` now accepts a file descriptor referring to a symlink on +Linux, Android, macOS and iOS. + +.. + +.. date: 2026-09-20-21-24-05 +.. gh-issue: 157880 +.. nonce: aE7wIu +.. section: Library + +Fix :class:`mailbox.Babyl` to write the visible headers of a +:class:`mailbox.BabylMessage` to the mailbox file. + +.. + +.. date: 2026-09-20-12-00-00 +.. gh-issue: 157856 +.. nonce: wq4xuF +.. section: Library + +Fix :func:`asyncio.as_completed` raising :exc:`RuntimeError` ("no running +event loop") when the iterator is created outside of a running event loop +and driven with :meth:`loop.run_until_complete() +`. + +.. + +.. date: 2026-09-18-00-00-00 +.. gh-issue: 49960 +.. nonce: MDT3jE +.. section: Library + +:mod:`ctypes` callback functions can now return structures and unions by +value. Previously only "simple" types could be returned, and any other +result type raised :exc:`TypeError`. + +.. + +.. date: 2026-09-17-20-36-01 +.. gh-issue: 157290 +.. nonce: NfFmt +.. section: Library + +Add the ``%Nf`` format code (where *N* is from 1 to 6) to +:meth:`datetime.datetime.strftime`, :meth:`datetime.time.strftime`, +:meth:`datetime.date.strftime`, :meth:`datetime.datetime.strptime` and +:meth:`datetime.time.strptime`. + +.. + +.. date: 2026-09-17-10-30-00 +.. gh-issue: 158252 +.. nonce: strptime +.. section: Library + +Speed up :func:`time.strptime`, :meth:`datetime.date.strptime`, +:meth:`datetime.time.strptime`, and :meth:`datetime.datetime.strptime` for +common numeric formats by parsing fields and constructing the result in C. +Other inputs continue to use the Python parser. + +.. + +.. date: 2026-09-05-17-29-50 +.. gh-issue: 160837 +.. nonce: W6kHva +.. section: Library + +:func:`asyncio.print_call_graph` no longer truncates the call stack of a +task suspended inside an asynchronous generator. + +.. + +.. date: 2026-09-01-00-00-00 +.. gh-issue: 156784 +.. nonce: 8gvtt4 +.. section: Library + +:class:`asyncio.ProactorEventLoop` no longer silently ignores +:exc:`ConnectionResetError` on UDP sockets, matching +:class:`asyncio.SelectorEventLoop`. + +.. + +.. date: 2026-08-29-14-28-46 +.. gh-issue: 156568 +.. nonce: mkxLY8 +.. section: Library + +:func:`zipapp.create_archive` now correctly sets the executable bit on the +target archive when copying a zipapp where the target is a path-like object. + +.. + +.. date: 2026-08-29-13-41-56 +.. gh-issue: 154675 +.. nonce: cYvE-Z +.. section: Library + +Improve import time of :mod:`pdb`, :mod:`bdb` and :mod:`code` by lazily +importing several dependencies. + +.. + +.. date: 2026-08-23-16-33-00 +.. gh-issue: 151126 +.. nonce: GUvtG7 +.. section: Library + +Fix a crash caused by failing to set :exc:`MemoryError` on allocation +failure when first using a Chinese, Japanese or Korean codec. + +.. + +.. date: 2026-08-21-06-00-00 +.. gh-issue: 156057 +.. nonce: tarfile-wrap-comp-err +.. section: Library + +Wrap the underlying compression library's exception in +:exc:`tarfile.ReadError` when a member's compressed data is corrupt past its +header, for all of :mod:`tarfile`'s supported compression formats (gzip, +bzip2, lzma, zstd). Previously the raw exception (e.g. :exc:`zlib.error`) +could leak through :meth:`tarfile.TarFile.extractfile`. Patch by Jason Mak. + +.. + +.. date: 2026-08-20-09-56-45 +.. gh-issue: 156078 +.. nonce: -E7gZc +.. section: Library + +:meth:`zipfile.ZipFile.mkdir` now raises :exc:`ValueError` when the archive +is closed or when a writable member handle is open. + +.. + +.. date: 2026-08-15-12-08-33 +.. gh-issue: 155833 +.. nonce: Pi2Yjp +.. section: Library + +Ensure that MD5 and SHA* objects are properly GC-untracked before freeing +their internal HACL* state. Patch by Bénédikt Tran. + +.. + +.. date: 2026-08-15-11-49-30 +.. gh-issue: 155830 +.. nonce: cY5xgK +.. section: Library + +:mod:`!_blake2`: Ensure that BLAKE-2 objects are correctly initialized +before being tracked by the garbage collector. Patch by Bénédikt Tran. + +.. + +.. date: 2026-08-15-11-30-42 +.. gh-issue: 155782 +.. nonce: JUmDP4 +.. section: Library + +:mod:`ssl`: prevent a crash in :meth:`~ssl.SSLSocket.group` for session-less +objects on OpenSSL 3.2 and later. Patch by Bénédikt Tran. + +.. + +.. date: 2026-08-09-14-26-48 +.. gh-issue: 155428 +.. nonce: wi0_fI +.. section: Library + +Ensure that :func:`hmac.digest` and :meth:`hmac.HMAC.digest` output +identical values when using a digest's block size smaller than 16. Patch by +Bénédikt Tran. + +.. + +.. date: 2026-08-09-14-06-27 +.. gh-issue: 155426 +.. nonce: zZVPMd +.. section: Library + +Make sure that the pure Python fallback of :func:`hmac.digest` reject keys +that are neither :class:`bytes` or :class:`bytearray`. Previously, an +:exc:`AttributeError` was raised instead of :exc:`TypeError`. Patch by +Bénédikt Tran. + +.. + +.. date: 2026-08-05-10-13-23 +.. gh-issue: 153711 +.. nonce: 9g9dVz +.. section: Library + +On iOS, add :func:`os.pipe2`, and use the syscalls :manpage:`pipe2 (2)` and +:manpage:`dup3 (2)` internally, when available at both build-time and +run-time. + +.. + +.. date: 2026-08-04-16-38-59 +.. gh-issue: 155152 +.. nonce: qN1EEN +.. section: Library + +Improve performance of some :mod:`zipimport` archives that use Zstandard +compression. + +.. + +.. date: 2026-07-21-00-02-11 +.. gh-issue: 148228 +.. nonce: D3rP8m +.. section: Library + +The :term:`REPL` now displays error messages when editing commands cannot be +performed, such as when tab completion finds no matches or a history search +fails. Patch by Bartosz Sławecki. + +.. + +.. date: 2026-07-16-21-30-00 +.. gh-issue: 74876 +.. nonce: wR3fXk +.. section: Library + +Weak references (:class:`weakref.ref`), :class:`weakref.WeakMethod`, +:class:`weakref.WeakSet`, :class:`weakref.WeakValueDictionary` and +:class:`weakref.WeakKeyDictionary` can now be pickled if the weakly +referenced objects are strongly referenced elsewhere in the same pickle; +otherwise pickling raises :exc:`pickle.PicklingError`. +:class:`weakref.WeakMethod` and :class:`weakref.WeakSet` can now also be +copied. + +.. + +.. date: 2026-07-13-00-10-00 +.. gh-issue: 153679 +.. nonce: RJ2WGB +.. section: Library + +:class:`zipimport.zipimporter` now raises :exc:`zipimport.ZipImportError` +instead of :exc:`UnicodeDecodeError` for a UTF-8-flagged file name that is +not valid UTF-8. Patch by tonghuaroot. + +.. + +.. date: 2026-07-11-16-00-00 +.. gh-issue: 153605 +.. nonce: Rk7Xz3 +.. section: Library + +Fix :class:`gettext.GNUTranslations` raising :exc:`struct.error` instead of +:exc:`OSError` when reading a malformed ``.mo`` file. Patch by tonghuaroot. + +.. + +.. date: 2026-07-04-12-52-22 +.. gh-issue: 149816 +.. nonce: XQOutB +.. section: Library + +:mod:`hashlib`: fix a crash arising from a race condition when looking up an +OpenSSL hash algorithm by name the first time. Patch by Bénédikt Tran. + +.. + +.. date: 2026-06-30-08-39-07 +.. gh-issue: 62222 +.. nonce: Zq7x2P +.. section: Library + +Fix :func:`binascii.a2b_qp` and :mod:`quopri` discarding the character after +a ``=`` that does not start a valid escape: ``b'==41'`` now decodes to +``b'=A'``, as in the :mod:`email` package. Add a keyword-only *strip_ws* +parameter to :func:`binascii.a2b_qp`, :func:`quopri.decode` and +:func:`quopri.decodestring` to strip trailing whitespace from each line, as +required by :rfc:`2045`. + +.. + +.. date: 2026-06-28-14-37-01 +.. gh-issue: 152490 +.. nonce: A8qLbF +.. section: Library + +Fix :exc:`TypeError` when formatting a :exc:`SyntaxError` raised with +:data:`NotImplemented` as its argument, which caused unexpected REPL exit +and IDLE Shell restart. + +.. + +.. date: 2026-06-27-08-31-30 +.. gh-issue: 152373 +.. nonce: 3cd0aa +.. section: Library + +Fix the :mod:`pdb` ``until`` command not stepping over a list comprehension +when a breakpoint is set on it. Patch by tonghuaroot. + +.. + +.. date: 2026-06-18-11-26-00 +.. gh-issue: 151633 +.. nonce: uJzHdc +.. section: Library + +Fix a use-after-free under free-threading when multiple threads update the +same :class:`~collections.Counter` concurrently. + +.. + +.. date: 2026-05-21-16-15-01 +.. gh-issue: 105578 +.. nonce: oq-0pg +.. section: Library + +Deprecate :data:`typing.AnyStr` type variable and raise a warning when it is +imported. + +.. + +.. date: 2026-05-09-12-58-04 +.. gh-issue: 149527 +.. nonce: hX36Yh +.. section: Library + +:mod:`multiprocessing`: fix creation of temporary socket files following +:gh:`137335` (`PR#148578 `__ +and corresponding backports). Patch by Bénédikt Tran. + +.. + +.. date: 2026-05-03-22-52-07 +.. gh-issue: 149309 +.. nonce: gXhk9Y +.. section: Library + +:exc:`bdb.BdbQuit` is now a subclass of :exc:`BaseException`, instead of +:exc:`Exception`, to allow it to be used for cleanly exiting the debugger +without being accidentally caught by user code. + +.. + +.. date: 2026-04-27-20-30-16 +.. gh-issue: 149083 +.. nonce: xcmpSO +.. section: Library + +:data:`functools.Placeholder` is now a :class:`sentinel`. It is no longer an +instance of its own singleton type. + +.. + +.. date: 2026-03-28-14-34-18 +.. gh-issue: 143376 +.. nonce: FvWTwi +.. section: Library + +:mod:`concurrent.interpreters`: fix a crash when internal cross-interpreter +channel ends have incorrect channel IDs. Patch by Bénédikt Tran. + +.. + +.. date: 2026-03-28-10-27-46 +.. gh-issue: 146169 +.. nonce: RBF1xp +.. section: Library + +:mod:`xml.parsers.expat`: raise :exc:`RuntimeError` when an Expat handler +calls :meth:`parser.Parse ` or +:meth:`parser.ParseFile ` on the +parser that called the handler. Patch by Bénédikt Tran. + +.. + +.. date: 2026-03-23-00-04-13 +.. gh-issue: 146065 +.. nonce: FIdn8D +.. section: Library + +Fix a crash in asyncio.Future iterator when send() is called after throw() +or close(). + +.. + +.. date: 2026-01-06-09-13-53 +.. gh-issue: 84644 +.. nonce: V_cYP3 +.. section: Library + +Deprecate using a return annotation to infer the dispatch type for +:func:`functools.singledispatch` and +:class:`functools.singledispatchmethod`. It will raise :exc:`TypeError` in +Python 3.21. Annotate the dispatch parameter or pass the dispatch type +explicitly instead. Patch by Bartosz Sławecki. + +.. + +.. date: 2025-10-20-13-08-04 +.. gh-issue: 84027 +.. nonce: HjBO0B +.. section: Library + +:mod:`shutil` now can unpack wheel packages using the ``whl`` format. + +.. + +.. date: 2025-10-13-15-43-09 +.. gh-issue: 140036 +.. nonce: b_59uN +.. section: Library + +Avoid hanging in floor division of pure Python :class:`decimal.Decimal` +instances when the context precision is very large. Patch by Bénédikt Tran. + +.. + +.. date: 2025-09-18-18-03-32 +.. gh-issue: 139105 +.. nonce: 1QQ_W4 +.. section: Library + +Correct the EOF key shown in the :mod:`sqlite3` CLI ``.help`` text on +Windows. + +.. + +.. date: 2025-09-18-14-13-00 +.. gh-issue: 139122 +.. nonce: m3lp66 +.. section: Library + +:mod:`uuid`: Reimplement :class:`~uuid.UUID` objects, :func:`~uuid.uuid4`, +and :func:`~uuid.uuid7` in C. + +.. + +.. date: 2025-06-12-15-39-48 +.. gh-issue: 89730 +.. nonce: Lu35Fu +.. section: Library + +Add support for Encrypted Client Hello (ECH) to the :mod:`ssl` module with +OpenSSL 4.0 or later. + +.. + +.. date: 2025-03-13-20-21-00 +.. gh-issue: 115810 +.. nonce: qwrb231 +.. section: Library + +Add :attr:`datetime.timezone.name`, the *name* passed to the constructor, or +``None`` if no name was passed. + +.. + +.. date: 2025-02-04-09-01-06 +.. gh-issue: 129605 +.. nonce: wKGNXQ +.. section: Library + +Improve exception handling when computing suggestions in traceback.py. This +fixes a bug that could cause PyREPL to exit unexpectedly. + +.. + +.. date: 2024-12-27-15-41-55 +.. gh-issue: 128289 +.. nonce: -hCzEc +.. section: Library + +Add *eager_tasks* parameter to :func:`asyncio.run` function and +:class:`asyncio.Runner` class constructor. + +.. + +.. date: 2023-01-26-09-36-24 +.. gh-issue: 61448 +.. nonce: SOAkvt +.. section: Library + +Fix :func:`inspect.formatargvalues` raising :exc:`KeyError` for deleted +arguments, including ``*args`` and ``**kwargs``, by displaying +````. Patch by Ezio Melotti and Furkan Onder. + +.. + +.. bpo: 19094 +.. date: 2021-06-11-20-00-16 +.. nonce: rMRoIL +.. section: Library + +The :mod:`urllib.parse` URL parsing functions now raise :exc:`TypeError` +instead of :exc:`AttributeError` when passed an object which is not a +string, bytes, or ``None``. Accepting objects with false values (like ``0`` +and ``[]``) except empty strings, byte-like objects and ``None`` is now +deprecated, extending the deprecation made in Python 3.14 for +:func:`~urllib.parse.parse_qsl` and :func:`~urllib.parse.parse_qs`. + +.. + +.. bpo: 44170 +.. date: 2021-05-24-14-41-29 +.. nonce: _v28mv +.. section: Library + +Fix UnicodeDecodeError with multibyte utf8 characters in ShareableList. + +.. + +.. date: 2025-08-31-02-28-21 +.. gh-issue: 138277 +.. nonce: kkORph +.. section: Documentation + +Rearranged documentation search results to emphasize built-in types and +functions. Patch by Adam Hartz. + +.. + +.. date: 2023-09-04-16-01-20 +.. gh-issue: 107689 +.. nonce: LFLFtG +.. section: Documentation + +Added docstrings to abstract ctypes. + +.. + +.. date: 2026-11-07-01-45-00 +.. gh-issue: 160334 +.. nonce: F2n8qA +.. section: Tests + +Fix the sampling profiler integration test for special frames without file +and line information. + +.. + +.. date: 2026-11-06-23-15-23 +.. gh-issue: 161517 +.. nonce: LkAlDt +.. section: Tests + +Fix test_gdb when Python is built out-of-tree and Python is run from a +virtual environment. Previously, test_gdb was just skipped. Patch by Victor +Stinner. + +.. + +.. date: 2026-11-05-16-20-23 +.. gh-issue: 161430 +.. nonce: M7b8N6 +.. section: Tests + +No longer list tests expected to be skipped in the final report. Patch by +Victor Stinner. + +.. + +.. date: 2026-11-03-13-12-50 +.. gh-issue: 161263 +.. nonce: Voe8VM +.. section: Tests + +Skip tests which use MD5 algorithm for WWW-Authenticate challenges when +libssl is in FIPS mode. + +.. + +.. date: 2026-10-28-20-40-00 +.. gh-issue: 158646 +.. nonce: k2Xw7q +.. section: Tests + +Fix a race in ``test_asyncio.test_sslproto`` where the server side of +``test_shutdown_corrupted_ssl_sends_close_notify`` could fail with a +connection reset on Windows. + +.. + +.. date: 2026-10-19-17-05-00 +.. gh-issue: 107862 +.. nonce: qH3sTa +.. section: Tests + +Add ``hypothesis.stateful`` and the ``timezones()`` and ``ip_addresses()`` +strategies to the Hypothesis stubs used when Hypothesis is not installed. + +.. + +.. date: 2026-10-13-13-34-00 +.. gh-issue: 159293 +.. nonce: Lr8q2N +.. section: Tests + +Restore the recursion limit after the free-threading recursion-limit race +test to avoid failures in subsequent tests run in the same process. + +.. + +.. date: 2026-10-07-12-00-58 +.. gh-issue: 158975 +.. nonce: yR8q2L +.. section: Tests + +Replace fixed sleeps used for synchronization in multiprocessing tests with +bounded waits to avoid failures on slow or overloaded systems. Ensure pool +cleanup runs even when assertions fail in the imap buffer tests. + +.. + +.. date: 2026-10-05-22-36-06 +.. gh-issue: 158895 +.. nonce: 3Dmc4J +.. section: Tests + +When run in GitHub Actions, :mod:`test.regrtest` now annotates each test +failure in the job log and writes a summary of the failures to the job +summary. + +.. + +.. date: 2026-11-06-09-16-30 +.. gh-issue: 161467 +.. nonce: oSuzx_ +.. section: Build + +Enable the use of ``__attribute__((hot))`` when building CPython with Clang +and other compilers that support it. + +.. + +.. date: 2026-11-04-15-00-00 +.. gh-issue: 160924 +.. nonce: WQgVVh +.. section: Build + +Fix cross-compilation failures with ``--enable-shared`` caused by the build +Python loading the target's ``libpython`` through the shared-library search +path (such as musl from glibc). + +.. + +.. date: 2026-11-04-14-37-13 +.. gh-issue: 75929 +.. nonce: nELdwE +.. section: Build + +Fix a ``configure`` probe that could omit functions such as +:func:`os.fchdir` from builds using ``-Wall -Werror``. + +.. + +.. date: 2026-10-26-21-00-00 +.. gh-issue: 160704 +.. nonce: ZRYLKF +.. section: Build + +Fix C11-C17 builds with old C library headers that do not define +``static_assert``, including glibc versions older than 2.16. + +.. + +.. date: 2026-10-25-15-30-00 +.. gh-issue: 160689 +.. nonce: bootsp +.. section: Build + +The build helper programs ``Programs/_freeze_module`` and +``_bootstrap_python`` are now linked only with the modules of +:file:`Modules/Setup.bootstrap`, instead of with every static module. +Builtin modules added via :file:`Modules/Setup.local` or +``MODULE_BUILDTYPE=static`` can now depend on frozen modules or on +``getpath``. + +.. + +.. date: 2026-10-22-18-57-02 +.. gh-issue: 128884 +.. nonce: 3zR5Yp +.. section: Build + +Report a configuration error when ``--enable-bolt`` is used with build flags +that explicitly request the Cortex-A53 erratum 843419 workaround. Document +how to disable the workaround for builds that will not run on affected +processors. + +.. + +.. date: 2026-10-21-18-00-00 +.. gh-issue: 128883 +.. nonce: perf-trampoline +.. section: Build + +Fix crashes with ``-X perf`` and ``-X perf_jit`` in BOLT builds. The ELF +perf trampoline templates now use read-only data sections. + +.. + +.. date: 2026-10-21-14-52-56 +.. gh-issue: 128884 +.. nonce: Xs5jK- +.. section: Build + +Fix ``--enable-bolt`` build failures on AArch64 with recent LLVM: pass +``-frame-opt=hot`` only on x86. Patch by Donghee Na. + +.. + +.. date: 2026-10-20-23-30-00 +.. gh-issue: 160004 +.. nonce: CfgPth +.. section: Build + +Fix the paths in the :pep:`739` ``build-details.json`` file generated by +:file:`Tools/build/generate-build-details.py` with both ``--relative-paths`` +and ``--config-file-path``. Previously, every path except ``base_prefix`` +was wrong and depended on the directory the script was run from. + +.. + +.. date: 2026-10-20-23-00-00 +.. gh-issue: 159998 +.. nonce: FwDyn1 +.. section: Build + +Fix ``libpython.dynamic`` in the :pep:`739` ``build-details.json`` file for +macOS and iOS framework builds. It now points at the framework's library +instead of a nonexistent path under :file:`lib/`. + +.. + +.. date: 2026-10-20-20-00-00 +.. gh-issue: 144942 +.. nonce: MdLibs +.. section: Build + +Fix the macOS shared library and framework builds not linking the libraries +required by built-in modules, such as the HACL* objects needed by +``_blake2`` when it is built in via :file:`Modules/Setup.local`. + +.. + +.. date: 2026-10-20-17-50-00 +.. gh-issue: 143632 +.. nonce: PrCtlM +.. section: Build + +Fix the check that disables ``PR_SET_VMA_ANON_NAME`` on musl libc: it tested +an unset variable, so it never had any effect and the build could fail with +a redefinition of ``struct prctl_mm_map``. + +.. + +.. date: 2026-10-20-12-06-22 +.. gh-issue: 131999 +.. nonce: OWoYGM +.. section: Build + +Platform support for Apple's tvOS, watchOS and visionOS was added. + +.. + +.. date: 2026-10-20-00-56-59 +.. gh-issue: 153195 +.. nonce: 35cRE- +.. section: Build + +The PEG parser generator now supports splitting a grammar into several files +with the ``@include`` meta, and generates a separate C file for the rules of +each included file. The rules for specialized syntax errors moved from +:file:`Grammar/python.gram` to :file:`Grammar/invalid.gram`, which generates +the new :file:`Parser/parser_invalid.c`. + +.. + +.. date: 2026-10-19-17-05-00 +.. gh-issue: 159819 +.. nonce: pyCfgSp +.. section: Build + +Fix the shell version of :program:`python3-config` (used on all POSIX +platforms except macOS) when the installation prefix contains spaces or +other characters special to the shell or :program:`sed`: it printed an empty +``--prefix`` and wrong ``--includes``/``--ldflags`` paths while exiting +successfully. The script now also exits with status 1 if it cannot determine +its installation prefix. + +.. + +.. date: 2026-10-19-13-49-39 +.. gh-issue: 54767 +.. nonce: IdrGm6 +.. section: Build + +The ``--enable-loadable-sqlite-extensions=no`` and +``--disable-loadable-sqlite-extensions`` configure options now disable +loadable SQLite extensions instead of enabling them. + +.. + +.. date: 2026-10-18-12-00-00 +.. gh-issue: 159759 +.. nonce: LibStA +.. section: Build + +Fix the ``libpython.static`` path in :pep:`739` ``build-details.json``, +which pointed to a file that is not installed when building with +:option:`--enable-shared`, and no longer list a static library for framework +builds, which do not install one. + +.. + +.. date: 2026-10-15-19-09-31 +.. gh-issue: 75382 +.. nonce: DSrcra +.. section: Build + +Make :program:`configure` fail early with a clear error when a +``--with-*-sanitizer`` option is used but a program cannot be linked with +the corresponding ``-fsanitize`` flag, for example because the sanitizer +runtime library is not installed. + +.. + +.. date: 2026-10-15-17-19-41 +.. gh-issue: 159452 +.. nonce: oJ1saO +.. section: Build + +``Tools/build/regen-configure.sh`` no longer leaves root-owned files in the +source tree. + +.. + +.. date: 2026-10-15-11-20-48 +.. gh-issue: 159440 +.. nonce: uIz6ms +.. section: Build + +The version string reported by ``sys.version`` no longer carries a spurious +``-dirty`` suffix when CPython is built out-of-tree from a clean git +checkout: the build stamp now checks the source tree instead of the build +directory. + +.. + +.. date: 2026-09-22-09-13-06 +.. gh-issue: 157949 +.. nonce: EZ8avp +.. section: Build + +Remove dead build and preprocessor code for SCO UnixWare, OpenUNIX, SCO +OpenServer and ReliantUNIX. + +.. + +.. date: 2026-09-12-15-33-26 +.. gh-issue: 157354 +.. nonce: 2hw6fe +.. section: Build + +Fix the :samp:`--with-{name}-sanitizer=no` and +:samp:`--without-{name}-sanitizer` :program:`configure` options enabling the +sanitizer instead of disabling it. + +.. + +.. date: 2026-09-01-23-32-22 +.. gh-issue: 156780 +.. nonce: Qw3nRt +.. section: Build + +Emscripten ``libpython.a`` can now be linked into a program statically. + +.. + +.. date: 2026-08-27-23-24-29 +.. gh-issue: 155813 +.. nonce: LxRQu9 +.. section: Build + +On macOS, :option:`LIBFFI_CFLAGS` and :option:`LIBFFI_LIBS` are no longer +ignored when the SDK provides ``libffi``, so :mod:`ctypes` can again be +built against a different ``libffi``. Patch by Advit Arora. + +.. + +.. date: 2026-07-11-01-53-58 +.. gh-issue: 153285 +.. nonce: YmSox4 +.. section: Build + +Fix incorrect executable linking on macOS with ``--with-lto`` caused by +premature expansion of Make's ``$@`` target variable. + +.. + +.. date: 2026-10-22-14-04-17 +.. gh-issue: 160239 +.. nonce: A1b2C3 +.. section: Windows + +Remove dead and broken ``_repr_info()`` methods from +``asyncio.windows_events``; they called ``Future._repr_info()``, which no +longer exists. + +.. + +.. date: 2026-10-20-21-37-34 +.. gh-issue: 159880 +.. nonce: eKBiLr +.. section: Windows + +Fix a key handle leak in :func:`winreg.CreateKey`, +:func:`winreg.CreateKeyEx` and :func:`winreg.OpenKey` when the +``winreg.OpenKey/result`` audit hook fails. + +.. + +.. date: 2026-10-15-18-45-00 +.. gh-issue: 159118 +.. nonce: wmiMTA +.. section: Windows + +Fix a crash (``RPC_NT_INTERNAL_ERROR``) and intermittent window class +failures in :mod:`!_wmi` under high concurrency and load by initializing COM +as multi-threaded (MTA) instead of apartment-threaded (STA). + +.. + +.. date: 2026-09-14-16-49-44 +.. gh-issue: 157418 +.. nonce: r2IggA +.. section: Windows + +Correct the third parameter name of ``IocpProactor.recvfrom_into()`` from +*flags* to *nbytes* to reflect that it specifies the number of bytes to +receive. + +.. + +.. date: 2026-10-19-19-33-35 +.. gh-issue: 159739 +.. nonce: aaf575 +.. section: macOS + +Propagate errors that occur while converting macOS system proxy settings. + +.. + +.. date: 2026-11-04-16-34-48 +.. gh-issue: 161367 +.. nonce: bO5MGy +.. section: WASI + +Add a ``test`` command to :file:`Platforms/WASI` with ``--fast-ci`` and +``--slow-ci`` to select fast CI or slow Buildbot tests and ``--target`` to +test the build, gathered distribution, or release archive. + +.. + +.. date: 2026-10-21-15-26-12 +.. gh-issue: 160135 +.. nonce: UP-DlO +.. section: WASI + +Support wasm32-wasip3. + +.. + +.. date: 2026-11-06-17-12-40 +.. gh-issue: 161477 +.. nonce: smXIKC +.. section: IDLE + +Fix ``repr()`` of ``idlelib.redirector.WidgetRedirector`` and +``idlelib.redirector.OriginalCommand``, which displayed a spurious +one-element tuple. + +.. + +.. date: 2026-10-16-15-12-36 +.. gh-issue: 159517 +.. nonce: uzRtAd +.. section: IDLE + +Fix the completion list and the call tip grabbing the focus on macOS with +Tcl/Tk 9.1. + +.. + +.. date: 2026-10-21-11-53-40 +.. gh-issue: 87613 +.. nonce: tmKBlg +.. section: Tools/Demos + +Extend Argument Clinic :ref:`vectorcall` to support :ref:`heap-types` with +zero argument construction. + +.. + +.. date: 2026-10-20-12-50-00 +.. gh-issue: 114258 +.. nonce: slotNx +.. section: Tools/Demos + +Argument Clinic now supports the ``__next__`` type slot (``tp_iternext``), +including ``@critical_section``. + +.. + +.. date: 2026-10-14-09-48-26 +.. gh-issue: 159385 +.. nonce: 0aWOA9 +.. section: Tools/Demos + +iOS builds can now be configured to generate free-threading or debug output. + +.. + +.. date: 2025-03-25-18-00-00 +.. gh-issue: 131725 +.. nonce: qwfh321 +.. section: Tools/Demos + +``Tools/i18n/msgfmt.py`` now writes a hash table to the generated ``.mo`` +file, as GNU :program:`msgfmt` does. + +.. + +.. date: 2026-11-05-16-56-57 +.. gh-issue: 160109 +.. nonce: Fvs4m2 +.. section: C API + +Remove the unused ``FVS_MASK`` and ``FVS_HAVE_SPEC`` macros. They were used +by the ``FORMAT_VALUE`` opcode, which was removed in Python 3.13. + +.. + +.. date: 2026-11-05-10-51-17 +.. gh-issue: 161407 +.. nonce: rVoqaQ +.. section: C API + +Fix a crash at exit when an audit hook was added with +:c:func:`PySys_AddAuditHook` before :c:func:`Py_Initialize` and the raw +memory allocator changed during startup, for example with +``PYTHONMALLOC=mimalloc`` or in the :ref:`Python Development Mode +`. + +.. + +.. date: 2026-11-03-18-27-42 +.. gh-issue: 160962 +.. nonce: 06816I +.. section: C API + +Fix :c:func:`PyInitConfig_SetStr` when setting an optional string option to +``NULL``. Previously, the function crashed. Patch by Victor Stinner. + +.. + +.. date: 2026-11-03-01-24-01 +.. gh-issue: 161226 +.. nonce: MPrJKp +.. section: C API + +:c:func:`_PyTuple_Resize` now fails with :exc:`SystemError` if the hash +value was already computed. Patch by Victor Stinner. + +.. + +.. date: 2026-11-02-15-17-50 +.. gh-issue: 161185 +.. nonce: 4bpyDC +.. section: C API + +Fix a strict aliasing issue in the :c:func:`!memcpy` implementation of +:c:macro:`Py_SETREF`, :c:macro:`Py_XSETREF` and :c:macro:`Py_CLEAR` macros. +Patch by Nathan Goldbaum and Victor Stinner. + +.. + +.. date: 2026-11-02-13-15-22 +.. gh-issue: 161172 +.. nonce: U6kpuN +.. section: C API + +Add the :ref:`PyUnicodeWriter API ` to the limited C API. +Patch by Victor Stinner. + +.. + +.. date: 2026-10-21-19-55-00 +.. gh-issue: 159739 +.. nonce: ctxt01 +.. section: C API + +Avoid a crash if a context watcher is cleared while other context watchers +are being notified. + +.. + +.. date: 2026-10-19-21-05-12 +.. gh-issue: 159739 +.. nonce: Rk3fTq +.. section: C API + +Fix a crash in :c:func:`_PyTuple_Resize` when resizing a non-empty tuple to +a negative or too large size. It now raises :exc:`SystemError` or +:exc:`MemoryError` respectively. + +.. + +.. date: 2026-10-19-20-38-17 +.. gh-issue: 159739 +.. nonce: eb9cdc +.. section: C API + +:c:func:`PyInitConfig_SetStr` now releases a previously configured value and +preserves it if conversion of the replacement fails. + +.. + +.. date: 2026-10-19-19-33-35 +.. gh-issue: 159739 +.. nonce: dee9a0 +.. section: C API + +Fix a reference leak when :c:func:`_PyTuple_Resize` fails. + +.. + +.. date: 2026-09-12-18-37-22 +.. gh-issue: 157384 +.. nonce: uFbdle +.. section: C API + +:c:func:`PyImport_CreateModuleFromInitfunc` now accepts non-ASCII module +names for multi-phase init modules, instead of raising +:exc:`UnicodeEncodeError`. + +.. + +.. date: 2026-08-20-12-00-00 +.. gh-issue: 156133 +.. nonce: GetLoc +.. section: C API + +Add :c:func:`PyUnstable_InterpreterFrame_GetLocal` to read a local variable +of an internal interpreter frame by its localsplus index, and +:c:func:`PyUnstable_Code_GetLocalPlusNames` to get the matching variable +names. + +.. + +.. date: 2026-07-09-13-52-17 +.. gh-issue: 153410 +.. nonce: neaDgY +.. section: C API + +Add :c:func:`PyDict_AsFrozenDictAndClear` C-API function to create +:class:`frozendict` from existing :class:`dict` object and clear the input +dict instance. diff --git a/Misc/NEWS.d/next/Android/README.rst b/Misc/NEWS.d/next/Android/README.rst new file mode 100644 index 000000000000000..719c2aa8ce916e6 --- /dev/null +++ b/Misc/NEWS.d/next/Android/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *Android* section in this directory. diff --git a/Misc/NEWS.d/next/Build/2025-05-13-12-38-26.gh-issue-115119.7n0nx3.rst b/Misc/NEWS.d/next/Build/2025-05-13-12-38-26.gh-issue-115119.7n0nx3.rst deleted file mode 100644 index 0c6804ebf9c890d..000000000000000 --- a/Misc/NEWS.d/next/Build/2025-05-13-12-38-26.gh-issue-115119.7n0nx3.rst +++ /dev/null @@ -1,2 +0,0 @@ -Removed bundled copy of the libmpdec, use system library if it's available. -Patch by Sergey B Kirpichev. diff --git a/Misc/NEWS.d/next/Build/2026-04-21-17-27-52.gh-issue-148832.Kx9aQ1.rst b/Misc/NEWS.d/next/Build/2026-04-21-17-27-52.gh-issue-148832.Kx9aQ1.rst deleted file mode 100644 index 867cfcc5ab62ca2..000000000000000 --- a/Misc/NEWS.d/next/Build/2026-04-21-17-27-52.gh-issue-148832.Kx9aQ1.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix :option:`--enable-bolt` build by switching the default BOLT flag from -``-icf=1`` to ``-icf=0``. ``-icf=1`` folds address-taken functions and -breaks type-slot dispatch, crashing on :mod:`list` and :mod:`tuple` -concatenation. Patched by Shamil Abdulaev. diff --git a/Misc/NEWS.d/next/Build/2026-05-18-16-00-41.gh-issue-148260.UwFiIX.rst b/Misc/NEWS.d/next/Build/2026-05-18-16-00-41.gh-issue-148260.UwFiIX.rst deleted file mode 100644 index 8248c24cbd511ac..000000000000000 --- a/Misc/NEWS.d/next/Build/2026-05-18-16-00-41.gh-issue-148260.UwFiIX.rst +++ /dev/null @@ -1,3 +0,0 @@ -On Linux when Python is linked to the musl C library, use a thread stack -size of at least 1 MiB instead of musl default which is 128 kiB. Patch by -Victor Stinner. diff --git a/Misc/NEWS.d/next/Build/2026-05-19-12-45-23.gh-issue-131372.oJykeB.rst b/Misc/NEWS.d/next/Build/2026-05-19-12-45-23.gh-issue-131372.oJykeB.rst deleted file mode 100644 index 912f4131af27dae..000000000000000 --- a/Misc/NEWS.d/next/Build/2026-05-19-12-45-23.gh-issue-131372.oJykeB.rst +++ /dev/null @@ -1,3 +0,0 @@ -Add a :option:`--with-build-details-suffix` configure flag to allow Linux -distributions that co-install multiple versions of Python in the same tree -to avoid ``build-details.json`` clashes. diff --git a/Misc/NEWS.d/next/Build/2026-05-21-15-14-59.gh-issue-148294.VtFaW4.rst b/Misc/NEWS.d/next/Build/2026-05-21-15-14-59.gh-issue-148294.VtFaW4.rst deleted file mode 100644 index 861261dd97269f9..000000000000000 --- a/Misc/NEWS.d/next/Build/2026-05-21-15-14-59.gh-issue-148294.VtFaW4.rst +++ /dev/null @@ -1,2 +0,0 @@ -Corrected the use of ``AC_PATH_TOOL`` in ``configure.ac`` to allow a C++ -compiler to be found on :envvar:`!PATH`. diff --git a/Misc/NEWS.d/next/Build/2026-05-27-14-28-36.gh-issue-115119.wotFWh.rst b/Misc/NEWS.d/next/Build/2026-05-27-14-28-36.gh-issue-115119.wotFWh.rst deleted file mode 100644 index 04fdf3617f0cdef..000000000000000 --- a/Misc/NEWS.d/next/Build/2026-05-27-14-28-36.gh-issue-115119.wotFWh.rst +++ /dev/null @@ -1 +0,0 @@ -Fix the detection of libmpdec header when no .pc files are available. diff --git a/Misc/NEWS.d/next/Build/2026-06-09-11-54-13.gh-issue-151163.vFAtjv.rst b/Misc/NEWS.d/next/Build/2026-06-09-11-54-13.gh-issue-151163.vFAtjv.rst deleted file mode 100644 index e4f3a044c81c6f5..000000000000000 --- a/Misc/NEWS.d/next/Build/2026-06-09-11-54-13.gh-issue-151163.vFAtjv.rst +++ /dev/null @@ -1 +0,0 @@ -Updated Android build to include SQLite version 3.53.2. diff --git a/Misc/NEWS.d/next/Build/2026-06-26-16-30-00.gh-issue-152240.loongarch.rst b/Misc/NEWS.d/next/Build/2026-06-26-16-30-00.gh-issue-152240.loongarch.rst deleted file mode 100644 index ce9274a5c108377..000000000000000 --- a/Misc/NEWS.d/next/Build/2026-06-26-16-30-00.gh-issue-152240.loongarch.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix C stack unwinding tests on Linux LoongArch builds by teaching the manual -frame pointer unwinder to recognize the LoongArch frame layout. diff --git a/Misc/NEWS.d/next/Build/2026-06-28-16-17-55.gh-issue-152502.6SNqMg.rst b/Misc/NEWS.d/next/Build/2026-06-28-16-17-55.gh-issue-152502.6SNqMg.rst deleted file mode 100644 index 6c7e62a59a34412..000000000000000 --- a/Misc/NEWS.d/next/Build/2026-06-28-16-17-55.gh-issue-152502.6SNqMg.rst +++ /dev/null @@ -1,4 +0,0 @@ -The :mod:`curses` module now detects its optional functions with -:program:`configure` capability probes instead of assuming ncurses, so it -builds against narrow (non-wide) ncurses and other curses implementations such -as NetBSD curses, exposing exactly the functions they provide. diff --git a/Misc/NEWS.d/next/Build/2026-07-01-17-53-00.gh-issue-152769.Kp7mQ2.rst b/Misc/NEWS.d/next/Build/2026-07-01-17-53-00.gh-issue-152769.Kp7mQ2.rst deleted file mode 100644 index 04a6ef4f5e0a7f8..000000000000000 --- a/Misc/NEWS.d/next/Build/2026-07-01-17-53-00.gh-issue-152769.Kp7mQ2.rst +++ /dev/null @@ -1,4 +0,0 @@ -Enable the :ref:`perf profiler ` trampoline on Alpine Linux with the -musl C library on ``x86_64`` and ``aarch64``. The -trampoline is architecture-specific and does not depend on the C library, so -the same assembly trampoline used for glibc is reused for musl. diff --git a/Misc/NEWS.d/next/Build/2026-07-02-16-25-13.gh-issue-152870.oh9eD1.rst b/Misc/NEWS.d/next/Build/2026-07-02-16-25-13.gh-issue-152870.oh9eD1.rst deleted file mode 100644 index eaddd22a60fc09b..000000000000000 --- a/Misc/NEWS.d/next/Build/2026-07-02-16-25-13.gh-issue-152870.oh9eD1.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix a compilation error in the :mod:`decimal` C extension (``_decimal``) when -it is built with ``EXTRA_FUNCTIONALITY``. ``Context.apply()`` called the -internal ``_apply`` helper using its pre-Argument-Clinic signature; the call is -now made through the generated ``_impl`` function. diff --git a/Misc/NEWS.d/next/Build/2026-07-09-22-45-00.gh-issue-153438.Qr7N2p.rst b/Misc/NEWS.d/next/Build/2026-07-09-22-45-00.gh-issue-153438.Qr7N2p.rst deleted file mode 100644 index edab8e6ba7b2595..000000000000000 --- a/Misc/NEWS.d/next/Build/2026-07-09-22-45-00.gh-issue-153438.Qr7N2p.rst +++ /dev/null @@ -1,2 +0,0 @@ -Update Windows build and installer tooling and documentation to use the -current download URL for ``nuget.exe``. diff --git a/Misc/NEWS.d/next/Build/2026-07-11-07-26-16.gh-issue-126877.Zt7Kq2.rst b/Misc/NEWS.d/next/Build/2026-07-11-07-26-16.gh-issue-126877.Zt7Kq2.rst deleted file mode 100644 index 1d7d4fad886c56f..000000000000000 --- a/Misc/NEWS.d/next/Build/2026-07-11-07-26-16.gh-issue-126877.Zt7Kq2.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix the :program:`configure` check for Tcl/Tk which could wrongly succeed -with optimizing compilers when the libraries are missing. diff --git a/Misc/NEWS.d/next/Build/2026-11-06-12-00-00.gh-issue-140266.K3hP9z.rst b/Misc/NEWS.d/next/Build/2026-11-06-12-00-00.gh-issue-140266.K3hP9z.rst new file mode 100644 index 000000000000000..399aca8a9bcff6c --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-11-06-12-00-00.gh-issue-140266.K3hP9z.rst @@ -0,0 +1,3 @@ +Fix ``"platform": ""`` in ``build-details.json`` for native builds configured +with :option:`--with-build-python`: :envvar:`!_PYTHON_HOST_PLATFORM` is now +only passed to the build interpreter when cross compiling. diff --git a/Misc/NEWS.d/next/Build/2026-11-06-12-00-01.gh-issue-136267.Qv7mRs.rst b/Misc/NEWS.d/next/Build/2026-11-06-12-00-01.gh-issue-136267.Qv7mRs.rst new file mode 100644 index 000000000000000..43cc054a04ac7a2 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-11-06-12-00-01.gh-issue-136267.Qv7mRs.rst @@ -0,0 +1,8 @@ +``build-details.json`` now describes the interpreter being built rather than +the interpreter running :program:`generate-build-details.py`: ``abi.flags``, +``suffixes.extensions``, ``abi.stable_abi_suffix`` and +``implementation.supports_isolated_interpreters`` are derived from the +target's configuration, which fixes cross builds and builds that use +:option:`--with-build-python`. ``abi.extension_suffix`` and +``abi.stable_abi_suffix`` are now also present when libpython is only built +as a static library. diff --git a/Misc/NEWS.d/next/Build/2026-11-06-12-00-02.gh-issue-136267.Vt4pLm.rst b/Misc/NEWS.d/next/Build/2026-11-06-12-00-02.gh-issue-136267.Vt4pLm.rst new file mode 100644 index 000000000000000..d99ae1c42133402 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-11-06-12-00-02.gh-issue-136267.Vt4pLm.rst @@ -0,0 +1,4 @@ +``build-details.json`` now takes ``language.version_info``, +``implementation.version`` and ``implementation.hexversion`` from +:file:`Include/patchlevel.h` instead of the interpreter running the generator, +which can be a different patch release under :option:`--with-build-python`. diff --git a/Misc/NEWS.d/next/Build/2026-11-11-11-36-01.gh-issue-161821.9wjElMQP.rst b/Misc/NEWS.d/next/Build/2026-11-11-11-36-01.gh-issue-161821.9wjElMQP.rst new file mode 100644 index 000000000000000..2cfece1209c6e94 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-11-11-11-36-01.gh-issue-161821.9wjElMQP.rst @@ -0,0 +1,4 @@ +When building with ``--with-lto`` and Clang, :program:`configure` now checks +that the linker can link LTO objects and falls back to ``lld`` +(``-fuse-ld=lld``) if it cannot. This fixes LTO builds on systems where the +default GNU linker lacks the ``LLVMgold.so`` plugin, such as Debian 13. diff --git a/Misc/NEWS.d/next/Build/2026-11-17-20-12-03.gh-issue-162170.0SpcRZ.rst b/Misc/NEWS.d/next/Build/2026-11-17-20-12-03.gh-issue-162170.0SpcRZ.rst new file mode 100644 index 000000000000000..caa4b13ce303395 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-11-17-20-12-03.gh-issue-162170.0SpcRZ.rst @@ -0,0 +1,3 @@ +``make install`` now depends on the ``all`` target, so running it directly +after ``./configure --enable-optimizations`` installs the PGO-optimized +interpreter rather than an unoptimized build. diff --git a/Misc/NEWS.d/next/Build/2026-11-19-17-34-03.gh-issue-153668.A7mK2q.rst b/Misc/NEWS.d/next/Build/2026-11-19-17-34-03.gh-issue-153668.A7mK2q.rst new file mode 100644 index 000000000000000..95de6504bdbd074 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-11-19-17-34-03.gh-issue-153668.A7mK2q.rst @@ -0,0 +1,2 @@ +Disable ``unicodectype.c`` optimization in regular Windows ARM64 Release +builds due to a compiler bug in MSVC 14.50, 14.51, and 14.52. PGO builds are not affected. diff --git a/Misc/NEWS.d/next/Build/2026-11-20-16-30-00.gh-issue-162308.Mk7pQ2.rst b/Misc/NEWS.d/next/Build/2026-11-20-16-30-00.gh-issue-162308.Mk7pQ2.rst new file mode 100644 index 000000000000000..90a734551591f83 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-11-20-16-30-00.gh-issue-162308.Mk7pQ2.rst @@ -0,0 +1,4 @@ +Use the newly built interpreter to check extension modules in native builds +configured with :option:`--with-build-python`. This also applies when +generating missing standard library module information. Cross builds continue +to use the build interpreter without importing target extension modules. diff --git a/Misc/NEWS.d/next/Build/README.rst b/Misc/NEWS.d/next/Build/README.rst index d43e989e18051aa..0d2d2c1fc38be93 100644 --- a/Misc/NEWS.d/next/Build/README.rst +++ b/Misc/NEWS.d/next/Build/README.rst @@ -1,3 +1 @@ -Put news entry `blurb`_ files for the *Build* section in this directory. - -.. _blurb: https://pypi.org/project/blurb/ +Put news entry ``blurb`` files for the *Build* section in this directory. diff --git a/Misc/NEWS.d/next/C_API/2026-02-25-13-37-10.gh-issue-145235.-1ySNR.rst b/Misc/NEWS.d/next/C_API/2026-02-25-13-37-10.gh-issue-145235.-1ySNR.rst deleted file mode 100644 index 98a8c2687357265..000000000000000 --- a/Misc/NEWS.d/next/C_API/2026-02-25-13-37-10.gh-issue-145235.-1ySNR.rst +++ /dev/null @@ -1,3 +0,0 @@ -Made :c:func:`PyDict_AddWatcher`, :c:func:`PyDict_ClearWatcher`, -:c:func:`PyDict_Watch`, and :c:func:`PyDict_Unwatch` thread-safe on the -:term:`free threaded ` build. diff --git a/Misc/NEWS.d/next/C_API/2026-05-12-16-47-21.gh-issue-149725.HZLBTZ.rst b/Misc/NEWS.d/next/C_API/2026-05-12-16-47-21.gh-issue-149725.HZLBTZ.rst deleted file mode 100644 index 97721430edbd69d..000000000000000 --- a/Misc/NEWS.d/next/C_API/2026-05-12-16-47-21.gh-issue-149725.HZLBTZ.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add :c:func:`PySentinel_CheckExact` for exact :class:`sentinel` type tests -to accompany the existing :c:func:`PySentinel_Check`. diff --git a/Misc/NEWS.d/next/C_API/2026-05-31-15-39-58.gh-issue-150671.bTkDVC.rst b/Misc/NEWS.d/next/C_API/2026-05-31-15-39-58.gh-issue-150671.bTkDVC.rst deleted file mode 100644 index a67a0f85db1a506..000000000000000 --- a/Misc/NEWS.d/next/C_API/2026-05-31-15-39-58.gh-issue-150671.bTkDVC.rst +++ /dev/null @@ -1,4 +0,0 @@ -Deprecate these C-API functions: :c:func:`PyGen_New`, -:c:func:`PyGen_NewWithQualName`, :c:func:`PyCoro_New`, and -:c:func:`PyAsyncGen_New`. -Schedule them for removal in 3.18 diff --git a/Misc/NEWS.d/next/C_API/2026-06-04-14-26-17.gh-issue-150907.CA91_B.rst b/Misc/NEWS.d/next/C_API/2026-06-04-14-26-17.gh-issue-150907.CA91_B.rst deleted file mode 100644 index f58b248f3a0b986..000000000000000 --- a/Misc/NEWS.d/next/C_API/2026-06-04-14-26-17.gh-issue-150907.CA91_B.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix ``dynamic_annotations.h`` header file when built with C++ and Valgrind: -add ``extern "C++" scope`` for the C++ template. Patch by Victor Stinner. diff --git a/Misc/NEWS.d/next/C_API/2026-06-09-14-50-35.gh-issue-80384.UEGyvB.rst b/Misc/NEWS.d/next/C_API/2026-06-09-14-50-35.gh-issue-80384.UEGyvB.rst deleted file mode 100644 index c4f5e8f3f9bbc2d..000000000000000 --- a/Misc/NEWS.d/next/C_API/2026-06-09-14-50-35.gh-issue-80384.UEGyvB.rst +++ /dev/null @@ -1,3 +0,0 @@ -:c:func:`PyWeakref_NewRef` and :c:func:`PyWeakref_NewProxy` now raise -:exc:`TypeError` if the *callback* argument is not callable, ``None``, or -``NULL``. diff --git a/Misc/NEWS.d/next/C_API/2026-06-10-15-22-44.gh-issue-149044.O7KEcs.rst b/Misc/NEWS.d/next/C_API/2026-06-10-15-22-44.gh-issue-149044.O7KEcs.rst deleted file mode 100644 index fe0730b1bf87c4d..000000000000000 --- a/Misc/NEWS.d/next/C_API/2026-06-10-15-22-44.gh-issue-149044.O7KEcs.rst +++ /dev/null @@ -1,3 +0,0 @@ -Improved error message when specifying non-type base classes in -:c:macro:`Py_tp_bases`, :c:macro:`Py_tp_base`, and *bases* argument to -:c:func:`PyType_FromMetaclass` and other ``PyType_From*`` functions. diff --git a/Misc/NEWS.d/next/C_API/2026-06-10-16-43-37.gh-issue-123619.dV82r6.rst b/Misc/NEWS.d/next/C_API/2026-06-10-16-43-37.gh-issue-123619.dV82r6.rst deleted file mode 100644 index 4d4c94563330c06..000000000000000 --- a/Misc/NEWS.d/next/C_API/2026-06-10-16-43-37.gh-issue-123619.dV82r6.rst +++ /dev/null @@ -1,3 +0,0 @@ -:c:func:`PyUnstable_Object_EnableDeferredRefcount` now returns ``0`` if the -object is not tracked by the garbage collector: if :func:`gc.is_tracked` is -false. Patch by Victor Stinner. diff --git a/Misc/NEWS.d/next/C_API/2026-06-18-18-24-11.gh-issue-141510.-EOHJ1.rst b/Misc/NEWS.d/next/C_API/2026-06-18-18-24-11.gh-issue-141510.-EOHJ1.rst deleted file mode 100644 index c77b462e97bdd1d..000000000000000 --- a/Misc/NEWS.d/next/C_API/2026-06-18-18-24-11.gh-issue-141510.-EOHJ1.rst +++ /dev/null @@ -1 +0,0 @@ -Add :class:`frozendict` to the fast paths of :c:func:`PyMapping_GetOptionalItem`, :c:func:`PyMapping_Keys`, :c:func:`PyMapping_Values`, and :c:func:`PyMapping_Items`. diff --git a/Misc/NEWS.d/next/C_API/2026-07-08-00-38-32.gh-issue-153300.lVoWyR.rst b/Misc/NEWS.d/next/C_API/2026-07-08-00-38-32.gh-issue-153300.lVoWyR.rst deleted file mode 100644 index 3c19c0e15d2bc65..000000000000000 --- a/Misc/NEWS.d/next/C_API/2026-07-08-00-38-32.gh-issue-153300.lVoWyR.rst +++ /dev/null @@ -1,3 +0,0 @@ -:c:func:`PyConfig_Set()` now also set global configuration variables. For -example, ``PyConfig_Set("inspect", value)`` now also sets -:c:var:`Py_InspectFlag`. Patch by Victor Stinner. diff --git a/Misc/NEWS.d/next/C_API/2026-07-09-16-46-30.gh-issue-145633.jyNwAs.rst b/Misc/NEWS.d/next/C_API/2026-07-09-16-46-30.gh-issue-145633.jyNwAs.rst deleted file mode 100644 index cdb68372b6ba7d9..000000000000000 --- a/Misc/NEWS.d/next/C_API/2026-07-09-16-46-30.gh-issue-145633.jyNwAs.rst +++ /dev/null @@ -1,2 +0,0 @@ -:c:func:`PyFloat_Pack8` and ``PyFloat_Unpack*`` functions are no longer -guaranteed to always succeed on CPython. diff --git a/Misc/NEWS.d/next/C_API/2026-07-09-17-33-29.gh-issue-152132.Ma8MJZ.rst b/Misc/NEWS.d/next/C_API/2026-07-09-17-33-29.gh-issue-152132.Ma8MJZ.rst deleted file mode 100644 index 633c41e40bf2696..000000000000000 --- a/Misc/NEWS.d/next/C_API/2026-07-09-17-33-29.gh-issue-152132.Ma8MJZ.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix :c:func:`Py_RunMain` to return an exit code, rather than calling -:c:func:`Py_Exit`, when running a script, a command, or the REPL. Patch by -Victor Stinner. diff --git a/Misc/NEWS.d/next/C_API/2026-07-24-22-30-40.gh-issue-154643.z-ZutK.rst b/Misc/NEWS.d/next/C_API/2026-07-24-22-30-40.gh-issue-154643.z-ZutK.rst new file mode 100644 index 000000000000000..17c2a58555e7ae9 --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2026-07-24-22-30-40.gh-issue-154643.z-ZutK.rst @@ -0,0 +1,2 @@ +In ``pyport.h`` and ``pyatomic.h`` don't use ``_Py_STDC_VERSION`` when it is +not defined, fixing build errors for C or C++ code built with ``-Werror=undef``. diff --git a/Misc/NEWS.d/next/C_API/2026-11-04-14-24-36.gh-issue-160436.WmZEYT.rst b/Misc/NEWS.d/next/C_API/2026-11-04-14-24-36.gh-issue-160436.WmZEYT.rst new file mode 100644 index 000000000000000..4cef63faaa4cdf2 --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2026-11-04-14-24-36.gh-issue-160436.WmZEYT.rst @@ -0,0 +1,4 @@ +Fix a spurious ``-Wdeprecated-declarations`` warning when a +:c:type:`PyStatus` is copied in C++ with clang 21 and older: +:c:member:`PyStatus.exitcode` is no longer marked as deprecated for C++ on +those compilers. diff --git a/Misc/NEWS.d/next/C_API/2026-11-12-21-34-55.gh-issue-161694.71tZlp.rst b/Misc/NEWS.d/next/C_API/2026-11-12-21-34-55.gh-issue-161694.71tZlp.rst new file mode 100644 index 000000000000000..e82a0a267cfe499 --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2026-11-12-21-34-55.gh-issue-161694.71tZlp.rst @@ -0,0 +1,2 @@ +:c:func:`!_PyObject_VAR_SIZE` now returns ``SIZE_MAX`` on integer overflow (if +the result would be greater than ``PY_SSIZE_T_MAX``). Patch by Victor Stinner. diff --git a/Misc/NEWS.d/next/C_API/2026-11-16-17-25-12.gh-issue-158401.ADBBRG.rst b/Misc/NEWS.d/next/C_API/2026-11-16-17-25-12.gh-issue-158401.ADBBRG.rst new file mode 100644 index 000000000000000..f1b59a75095b2a0 --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2026-11-16-17-25-12.gh-issue-158401.ADBBRG.rst @@ -0,0 +1,4 @@ +:c:func:`Py_INCREF`, :c:func:`Py_XINCREF`, :c:func:`Py_DECREF` and +:c:func:`Py_XDECREF` are now implemented as function calls on all limited C +API versions. Previously, they were only implemented as function calls on +the limited C API version 3.12 or newer. Patch by Victor Stinner: diff --git a/Misc/NEWS.d/next/C_API/README.rst b/Misc/NEWS.d/next/C_API/README.rst index a4eb261579f2097..5a04f76f47b67eb 100644 --- a/Misc/NEWS.d/next/C_API/README.rst +++ b/Misc/NEWS.d/next/C_API/README.rst @@ -1,3 +1 @@ -Put news entry `blurb`_ files for the *C API* section in this directory. - -.. _blurb: https://pypi.org/project/blurb/ +Put news entry ``blurb`` files for the *C API* section in this directory. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2019-12-27-19-20-33.bpo-38131.J5fv54.rst b/Misc/NEWS.d/next/Core_and_Builtins/2019-12-27-19-20-33.bpo-38131.J5fv54.rst deleted file mode 100644 index 8b606c4335e033a..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2019-12-27-19-20-33.bpo-38131.J5fv54.rst +++ /dev/null @@ -1,2 +0,0 @@ -Produce more meaningful messages when compiling AST objects with wrong field -values. Patch by Batuhan Taskaya. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2023-01-02-14-54-12.gh-issue-100687.yenIag.rst b/Misc/NEWS.d/next/Core_and_Builtins/2023-01-02-14-54-12.gh-issue-100687.yenIag.rst new file mode 100644 index 000000000000000..f4f63584b1659ea --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2023-01-02-14-54-12.gh-issue-100687.yenIag.rst @@ -0,0 +1,2 @@ +Reduce the memory used by the result of adding two large :class:`int` +values. Such additions are also slightly faster for most sizes. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-03-16-02-23-48.gh-issue-145854.rRexF3.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-03-16-02-23-48.gh-issue-145854.rRexF3.rst deleted file mode 100644 index a4944615369edf5..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-03-16-02-23-48.gh-issue-145854.rRexF3.rst +++ /dev/null @@ -1 +0,0 @@ -The ``DELETE_NAME`` opcode is now replaced with ``PUSH_NULL; STORE_NAME``. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-03-20-16-27-15.gh-issue-145855.3yaHO4.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-03-20-16-27-15.gh-issue-145855.3yaHO4.rst deleted file mode 100644 index e34e51601fe5994..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-03-20-16-27-15.gh-issue-145855.3yaHO4.rst +++ /dev/null @@ -1 +0,0 @@ -The ``DELETE_ATTR`` opcode is now replaced with ``PUSH_NULL; STORE_ATTR``. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-03-23-00-45-44.gh-issue-145857.dB66WV.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-03-23-00-45-44.gh-issue-145857.dB66WV.rst deleted file mode 100644 index 8fd4f078817d404..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-03-23-00-45-44.gh-issue-145857.dB66WV.rst +++ /dev/null @@ -1 +0,0 @@ -The ``DELETE_GLOBAL`` opcode is now replaced with ``PUSH_NULL; STORE_GLOBAL``. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-03-31-16-15-15.gh-issue-75723.BZ4Rsn.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-03-31-16-15-15.gh-issue-75723.BZ4Rsn.rst deleted file mode 100644 index 596ca89958c9ed4..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-03-31-16-15-15.gh-issue-75723.BZ4Rsn.rst +++ /dev/null @@ -1 +0,0 @@ -Avoid re-executing ``.pth`` files when :func:`site.addsitedir` is called for a known directory. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-04-15-15-48-04.gh-issue-148450.2MEVqH.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-04-15-15-48-04.gh-issue-148450.2MEVqH.rst deleted file mode 100644 index 2a7d0d9bb3a7f7e..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-04-15-15-48-04.gh-issue-148450.2MEVqH.rst +++ /dev/null @@ -1 +0,0 @@ -Fix ``abc.register()`` so it invalidates type version tags for registered classes. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-04-21-15-07-03.gh-issue-148825.AbJzmZ.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-04-21-15-07-03.gh-issue-148825.AbJzmZ.rst deleted file mode 100644 index 5cf727b5d91fad1..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-04-21-15-07-03.gh-issue-148825.AbJzmZ.rst +++ /dev/null @@ -1 +0,0 @@ -Fix build error if specialization is disabled. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-04-29-15-10-59.gh-issue-149162.BPPyrq.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-04-29-15-10-59.gh-issue-149162.BPPyrq.rst deleted file mode 100644 index b4c443ecee07adf..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-04-29-15-10-59.gh-issue-149162.BPPyrq.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a potential deadlock in :c:func:`PyUnicode_InternFromString` and other -interning functions in the :term:`free-threaded build` when called from C++ -static local initializers. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-05-12-00-00.gh-issue-149321.remove-lazy-imports-none.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-05-12-00-00.gh-issue-149321.remove-lazy-imports-none.rst deleted file mode 100644 index 44e96ce7be0bfb4..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-05-12-00-00.gh-issue-149321.remove-lazy-imports-none.rst +++ /dev/null @@ -1 +0,0 @@ -Do not support ``none`` as a lazy imports mode. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-07-03-18-59.gh-issue-149459.5fhAqP.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-07-03-18-59.gh-issue-149459.5fhAqP.rst deleted file mode 100644 index 4cd0a148df3c704..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-07-03-18-59.gh-issue-149459.5fhAqP.rst +++ /dev/null @@ -1 +0,0 @@ -Fix a crash in the JIT optimizer when a specialized ``LOAD_SPECIAL`` guard deoptimized after inserting the synthetic ``NULL`` stack entry. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-09-15-22-32.gh-issue-144957.u1F2aQ.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-09-15-22-32.gh-issue-144957.u1F2aQ.rst deleted file mode 100644 index 3063f1a3c0e6d3e..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-09-15-22-32.gh-issue-144957.u1F2aQ.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix lazy ``from`` imports of module attributes provided by module-level -``__getattr__``. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-10-07-42-36.gh-issue-149642.6ZksML.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-10-07-42-36.gh-issue-149642.6ZksML.rst deleted file mode 100644 index 815a084db69d8d8..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-10-07-42-36.gh-issue-149642.6ZksML.rst +++ /dev/null @@ -1,2 +0,0 @@ -Allow imports inside ``exec()`` calls within functions under -``PYTHON_LAZY_IMPORTS=all``. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-10-16-43-50.gh-issue-148829.gscS14.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-10-16-43-50.gh-issue-148829.gscS14.rst deleted file mode 100644 index 3f9b1ccb518787d..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-10-16-43-50.gh-issue-148829.gscS14.rst +++ /dev/null @@ -1,2 +0,0 @@ -:class:`sentinel` objects now support a ``repr=`` argument and their -:attr:`~sentinel.__module__` attribute is writable. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-11-14-48-56.gh-issue-149676.6aTrw1.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-11-14-48-56.gh-issue-149676.6aTrw1.rst deleted file mode 100644 index 96f407cf5ad25a1..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-11-14-48-56.gh-issue-149676.6aTrw1.rst +++ /dev/null @@ -1 +0,0 @@ -Fix ``frozendict | frozendict`` hash. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-11-15-58-23.gh-issue-149689.9Ht49z.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-11-15-58-23.gh-issue-149689.9Ht49z.rst deleted file mode 100644 index aa672760730bd43..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-11-15-58-23.gh-issue-149689.9Ht49z.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix missing error propagation in parser action helpers when memory allocation -fails. Patch by Thomas Kowalski. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-11-18-20-41.gh-issue-148871.AeCbq7.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-11-18-20-41.gh-issue-148871.AeCbq7.rst deleted file mode 100644 index 506e369f553e506..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-11-18-20-41.gh-issue-148871.AeCbq7.rst +++ /dev/null @@ -1,3 +0,0 @@ -The empty tuple ``()`` is now loaded via :opcode:`LOAD_COMMON_CONSTANT` -instead of :opcode:`LOAD_CONST`, removing it from per-code-object -:attr:`~codeobject.co_consts` tuples. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-12-12-49-30.gh-issue-127727.hNmj9G.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-12-12-49-30.gh-issue-127727.hNmj9G.rst deleted file mode 100644 index 474ae434f6885ea..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-12-12-49-30.gh-issue-127727.hNmj9G.rst +++ /dev/null @@ -1,3 +0,0 @@ -Warn when running a virtual environment created for a different minor Python -version than the current interpreter, and suggest using ``python -m venv ---upgrade``. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-12-16-47-23.gh-issue-139808.iIs7_E.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-12-16-47-23.gh-issue-139808.iIs7_E.rst deleted file mode 100644 index 3e9d930bf1de894..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-12-16-47-23.gh-issue-139808.iIs7_E.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add branch protections for AArch64 (BTI/PAC) in assembly code used by -:option:`-X perf_jit <-X>` (Linux perf profiler integration). diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-13-06-54-41.gh-issue-149738.4BLFoH.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-13-06-54-41.gh-issue-149738.4BLFoH.rst deleted file mode 100644 index e62b681d716650b..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-13-06-54-41.gh-issue-149738.4BLFoH.rst +++ /dev/null @@ -1,2 +0,0 @@ -:mod:`sqlite3`: Disallow removing ``row_factory`` and ``text_factory`` attributes -of a connection to prevent a crash on a query. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-13-21-26-26.gh-issue-149805.IG6cza.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-13-21-26-26.gh-issue-149805.IG6cza.rst deleted file mode 100644 index 02d050840ee1f9b..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-13-21-26-26.gh-issue-149805.IG6cza.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a :exc:`SystemError` when compiling a compiling ``__classdict__`` class -annotation. Found by OSS-Fuzz in :oss-fuzz:`512907042`. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-14-19-41-03.gh-issue-149807.IwGaCo.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-14-19-41-03.gh-issue-149807.IwGaCo.rst deleted file mode 100644 index a94c737e73619d8..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-14-19-41-03.gh-issue-149807.IwGaCo.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix ``hash(frozendict)``: compute the hash of each ``(key, value)`` pair -correctly. Patch by Victor Stinner. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-15-11-31-57.gh-issue-149816.ugN2rx.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-15-11-31-57.gh-issue-149816.ugN2rx.rst deleted file mode 100644 index 016c17dd66b19ea..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-15-11-31-57.gh-issue-149816.ugN2rx.rst +++ /dev/null @@ -1 +0,0 @@ -Fix a race condition in :class:`memoryview` with free-threading. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-16-11-03-54.gh-issue-149816.X_gqMT.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-16-11-03-54.gh-issue-149816.X_gqMT.rst deleted file mode 100644 index d35f0857a1aefe8..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-16-11-03-54.gh-issue-149816.X_gqMT.rst +++ /dev/null @@ -1 +0,0 @@ -Fix a race condition in ``_PyBytes_FromList`` in free-threading mode. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-17-12-00-00.gh-issue-138325.h2XSfe.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-17-12-00-00.gh-issue-138325.h2XSfe.rst deleted file mode 100644 index 0eb528c68d8d6f0..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-17-12-00-00.gh-issue-138325.h2XSfe.rst +++ /dev/null @@ -1,3 +0,0 @@ -Speed up converting a list to a tuple in the ``tuple(genexpr)`` fast path -and in starred tuple displays (e.g. ``(*a, *b)``) by stealing the list's -items into the tuple instead of copying them. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-13-47-17.gh-issue-149590.IPBeQx.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-13-47-17.gh-issue-149590.IPBeQx.rst deleted file mode 100644 index 8d3b29d69cc8578..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-13-47-17.gh-issue-149590.IPBeQx.rst +++ /dev/null @@ -1 +0,0 @@ -Fix crash when faulthandler is imported more than once. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-16-54-54.gh-issue-150042.LSr5W8.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-16-54-54.gh-issue-150042.LSr5W8.rst deleted file mode 100644 index 18a4fbd9dadd60f..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-16-54-54.gh-issue-150042.LSr5W8.rst +++ /dev/null @@ -1 +0,0 @@ -Fix refleak in queue.SimpleQueue.put if memory allocation fails. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-17-16-51.gh-issue-150027.sJgLvd.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-17-16-51.gh-issue-150027.sJgLvd.rst deleted file mode 100644 index 66446105da3fba2..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-17-16-51.gh-issue-150027.sJgLvd.rst +++ /dev/null @@ -1,2 +0,0 @@ -Improve performance of :class:`frozenset` objects by avoiding copies during -construction. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-18-36-28.gh-issue-148587.-RD3z5.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-18-36-28.gh-issue-148587.-RD3z5.rst deleted file mode 100644 index d623dbdd75f0c8e..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-18-18-36-28.gh-issue-148587.-RD3z5.rst +++ /dev/null @@ -1 +0,0 @@ -:py:attr:`sys.lazy_modules` is now a set instead of a dict as initially spelled out in PEP 810. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-20-13-06-17.gh-issue-150146.i5m_SL.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-20-13-06-17.gh-issue-150146.i5m_SL.rst deleted file mode 100644 index f373f0bee7023ef..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-20-13-06-17.gh-issue-150146.i5m_SL.rst +++ /dev/null @@ -1,5 +0,0 @@ -Fix a crash on a complex type variable substitution. - -``from typing import TypeVar; memoryview[TypeVar("")][*typing.Mapping[..., -...]]`` used to fail due to missing ``NULL`` check on ``_unpack_args`` C -function call. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-21-21-04-43.gh-issue-150208.VOkxRG.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-21-21-04-43.gh-issue-150208.VOkxRG.rst deleted file mode 100644 index e9bc1d9e976523b..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-21-21-04-43.gh-issue-150208.VOkxRG.rst +++ /dev/null @@ -1,2 +0,0 @@ -Avoid double-quoting string values from ``pyconfig.h`` in ``sysconfigdata`` -variables. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-22-17-09-28.gh-issue-150107.GD72-D.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-22-17-09-28.gh-issue-150107.GD72-D.rst deleted file mode 100644 index a13f249e48cc021..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-22-17-09-28.gh-issue-150107.GD72-D.rst +++ /dev/null @@ -1,3 +0,0 @@ -:mod:`asyncio`: ``sendfile()`` and ``sock_sendfile()`` event loop methods -now call ``file.seek(offset)`` if *file* has a ``seek()`` method, -even if *offset* is ``0`` (default value). diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-22-21-52-38.gh-issue-150207.l2BUtI.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-22-21-52-38.gh-issue-150207.l2BUtI.rst deleted file mode 100644 index 12fbffcd170684c..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-22-21-52-38.gh-issue-150207.l2BUtI.rst +++ /dev/null @@ -1 +0,0 @@ -Fix a crash when a memory allocation fails during tokenizer initialization. A proper :exc:`MemoryError` is now raised instead. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-23-22-08-01.gh-issue-149449.2lhQFF.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-23-22-08-01.gh-issue-149449.2lhQFF.rst deleted file mode 100644 index 7d11442468d2077..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-23-22-08-01.gh-issue-149449.2lhQFF.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a use-after-free crash when the :mod:`unicodedata` module was removed -from :data:`sys.modules` and garbage-collected between calls that decode -``\N{...}`` escapes or use the ``namereplace`` codec error handler. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-24-14-45-00.gh-issue-149156.NP73rB.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-24-14-45-00.gh-issue-149156.NP73rB.rst deleted file mode 100644 index 2cb091e2b162f6a..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-24-14-45-00.gh-issue-149156.NP73rB.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix an intermittent crash after :func:`os.fork` when perf trampoline -profiling is enabled and the child returns through trampoline frames -inherited from the parent process. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-24-22-46-49.gh-issue-148613.PLpmyd.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-24-22-46-49.gh-issue-148613.PLpmyd.rst deleted file mode 100644 index 71a701bf3eb3551..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-24-22-46-49.gh-issue-148613.PLpmyd.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a data race in the free-threaded build between :func:`gc.set_threshold` -and garbage collection scheduling during object allocation. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-25-16-00-22.gh-issue-150374.Emu6d8.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-25-16-00-22.gh-issue-150374.Emu6d8.rst deleted file mode 100644 index 7189ca186d2b7e0..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-25-16-00-22.gh-issue-150374.Emu6d8.rst +++ /dev/null @@ -1 +0,0 @@ -Fix double release of the import lock on lazy import reification errors. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-26-00-06-30.gh-issue-150411.u-d-_5.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-26-00-06-30.gh-issue-150411.u-d-_5.rst deleted file mode 100644 index 5b19a4fff5ddc73..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-26-00-06-30.gh-issue-150411.u-d-_5.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a data race in the free-threaded build when :func:`gc.get_count` reads -the young generation allocation count while another thread updates it. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-29-17-51-11.gh-issue-144774.jPcixe.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-29-17-51-11.gh-issue-144774.jPcixe.rst deleted file mode 100644 index 3dd117e7d3c3502..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-29-17-51-11.gh-issue-144774.jPcixe.rst +++ /dev/null @@ -1 +0,0 @@ -Fix data race in :class:`BaseException` when an exception is copied while being mutated. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-30-20-19-35.gh-issue-150633.XkNul0.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-05-30-20-19-35.gh-issue-150633.XkNul0.rst deleted file mode 100644 index c397ad61f086c1b..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-05-30-20-19-35.gh-issue-150633.XkNul0.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix the frozen importer accepting module names with embedded null bytes, which -caused it to bypass the :data:`sys.modules` cache and create duplicate module -objects. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-01-19-00-00.gh-issue-150700.W8CzVR.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-01-19-00-00.gh-issue-150700.W8CzVR.rst deleted file mode 100644 index e7734034ff5c814..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-01-19-00-00.gh-issue-150700.W8CzVR.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a :exc:`SystemError` when compiling a class-scope comprehension containing -a ``lambda`` that references ``__class__``, ``__classdict__``, or -``__conditional_annotations__``. Patch by Bartosz Sławecki. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-01-19-21-01.gh-issue-150723.Hb3JDG.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-01-19-21-01.gh-issue-150723.Hb3JDG.rst deleted file mode 100644 index 1920c8cdfce4f4c..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-01-19-21-01.gh-issue-150723.Hb3JDG.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix malformed perf jitdump thread ids on macOS. The ``thread_id`` field of the -``JR_CODE_LOAD`` record was written as a 64-bit value instead of the 32-bit -value required by the jitdump format, which shifted every following field and -prevented profilers from resolving Python frames. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-01-19-24-12.gh-issue-150723.WlcL_-.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-01-19-24-12.gh-issue-150723.WlcL_-.rst deleted file mode 100644 index 78c896b669c2393..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-01-19-24-12.gh-issue-150723.WlcL_-.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix perf jitdump timestamps on macOS. Events were stamped using -``CLOCK_MONOTONIC``, but macOS profilers timestamp their samples with -``mach_absolute_time()``. The mismatch prevented the JIT code mappings from -lining up with the samples, so no Python frame could be resolved. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-03-16-27-00.gh-issue-150858.j2dSkD.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-03-16-27-00.gh-issue-150858.j2dSkD.rst deleted file mode 100644 index dcb932bf320629a..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-03-16-27-00.gh-issue-150858.j2dSkD.rst +++ /dev/null @@ -1 +0,0 @@ -Fix a data race while changing ``__qualname__`` of a type concurrently on free-threaded builds. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-03-21-14-28.gh-issue-150459.qpsCEl.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-03-21-14-28.gh-issue-150459.qpsCEl.rst deleted file mode 100644 index a3e3e38ddcd1f43..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-03-21-14-28.gh-issue-150459.qpsCEl.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix :exc:`SyntaxError` error message for ``from x lazy import y``. -Raise :exc:`SyntaxWarning` on ``from . lazy import x`` -(with whitespace between the dots and a module named ``lazy``). diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-04-12-53-10.gh-issue-148874.r121cG.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-04-12-53-10.gh-issue-148874.r121cG.rst deleted file mode 100644 index 95f93338beb9129..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-04-12-53-10.gh-issue-148874.r121cG.rst +++ /dev/null @@ -1,3 +0,0 @@ -Ignore interrupts immediately after calling the ``__enter__`` method of a -context menager in a ``with`` statement. This ensures that the ``__exit__`` -method is always called in a ``with`` statement. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-04-15-02-35.gh-issue-146495.wWRRvx.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-04-15-02-35.gh-issue-146495.wWRRvx.rst deleted file mode 100644 index 1d86bf5307ba99d..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-04-15-02-35.gh-issue-146495.wWRRvx.rst +++ /dev/null @@ -1 +0,0 @@ -Improve :exc:`SyntaxError` message for ``&&`` and ``||`` operators, suggesting ``and``/``&`` and ``or``/``|`` respectively. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-05-22-52-41.gh-issue-150988.fDKfMJ.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-05-22-52-41.gh-issue-150988.fDKfMJ.rst deleted file mode 100644 index 6fb70a1ce2685c8..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-05-22-52-41.gh-issue-150988.fDKfMJ.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a reference leak in :exc:`OSError` when attributes are set before -``super().__init__()``. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-06-08-20-00.gh-issue-150942.Jk9pQr.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-06-08-20-00.gh-issue-150942.Jk9pQr.rst deleted file mode 100644 index 9777b8932271404..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-06-08-20-00.gh-issue-150942.Jk9pQr.rst +++ /dev/null @@ -1,3 +0,0 @@ -Speed up frame local variable item collection by appending result pairs to the -output list without an extra reference-count round-trip (using the internal -reference-stealing list append helper). Patch by Omkar Kabde. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-06-20-15-08.gh-issue-151029.A33CKK.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-06-20-15-08.gh-issue-151029.A33CKK.rst deleted file mode 100644 index cbfe5952627ad8a..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-06-20-15-08.gh-issue-151029.A33CKK.rst +++ /dev/null @@ -1,2 +0,0 @@ -On Linux, fix :func:`sys.remote_exec` unable to find remote writable memory -when ``libpython`` replaced on disk. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-08-05-31-22.gh-issue-151065._o_31F.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-08-05-31-22.gh-issue-151065._o_31F.rst deleted file mode 100644 index e46c96ef784cc9e..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-08-05-31-22.gh-issue-151065._o_31F.rst +++ /dev/null @@ -1 +0,0 @@ -Fix memory leak when using the :ref:`mimalloc memory allocator `. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-08-13-14-42.gh-issue-150902.-CWZ66.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-08-13-14-42.gh-issue-150902.-CWZ66.rst deleted file mode 100644 index e3b7cd387b439fe..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-08-13-14-42.gh-issue-150902.-CWZ66.rst +++ /dev/null @@ -1 +0,0 @@ -Apply an existing optimization of PyCriticalSection (single mutex) to PyCriticalSection2: avoid acquiring the same locks that the current CS has already acquired. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst deleted file mode 100644 index 67e2ce4044431f9..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst +++ /dev/null @@ -1,5 +0,0 @@ -Fix a crash, when there's no memory left on a device, -which happened in: code compilation, :mod:`!_interpchannels` module, -:func:`!_winapi.CreateProcess` function. - -Now these places raise proper :exc:`MemoryError` errors. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-12-24-35.gh-issue-151112.4RKCkD.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-12-24-35.gh-issue-151112.4RKCkD.rst deleted file mode 100644 index 93ee5c8cf1914b4..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-12-24-35.gh-issue-151112.4RKCkD.rst +++ /dev/null @@ -1 +0,0 @@ -Fix a crash in the compiler that could occur when running out of memory. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-10-15-19-58.gh-issue-151238.C9Wu4x.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-10-15-19-58.gh-issue-151238.C9Wu4x.rst deleted file mode 100644 index fe7519fb4878952..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-10-15-19-58.gh-issue-151238.C9Wu4x.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a crash when compiling a concatenated f-string or t-string if an error -occurs when processing one of it's parts. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-10-15-42-46.gh-issue-151253.7MMQ8P.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-10-15-42-46.gh-issue-151253.7MMQ8P.rst deleted file mode 100644 index 56d2f3b2633bb01..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-10-15-42-46.gh-issue-151253.7MMQ8P.rst +++ /dev/null @@ -1,3 +0,0 @@ -If ``import encodings`` (first import) fails at Python startup, dump the -Python path configuration to help users debugging their configuration. Patch -by Victor Stinner. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-11-16-03-23.gh-issue-151297.NGPkUM.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-11-16-03-23.gh-issue-151297.NGPkUM.rst deleted file mode 100644 index 288d726e0f1004d..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-11-16-03-23.gh-issue-151297.NGPkUM.rst +++ /dev/null @@ -1 +0,0 @@ -Fix an invalid pointer dereference that could occur when calling :c:func:`PyObject_Realloc` with a NULL pointer in :term:`free-threaded builds ` or with :envvar:`PYTHONMALLOC` set to ``mimalloc``. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-12-15-30-25.gh-issue-151218.5M_nv8.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-12-15-30-25.gh-issue-151218.5M_nv8.rst deleted file mode 100644 index 46539efc373eb0d..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-12-15-30-25.gh-issue-151218.5M_nv8.rst +++ /dev/null @@ -1,3 +0,0 @@ -:c:func:`PyConfig_Set` and :func:`sys.set_int_max_str_digits` now replace -:data:`sys.flags` (create a new object), instead of modifying :data:`sys.flags` -in-place. Patch by Victor Stinner. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-14-05-05-15.gh-issue-151461.5q0s88.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-14-05-05-15.gh-issue-151461.5q0s88.rst deleted file mode 100644 index d76a9bc95278bcb..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-14-05-05-15.gh-issue-151461.5q0s88.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix direct execution of files with invalid source encodings to report the -underlying codec lookup or decoding error instead of the generic -``SyntaxError: encoding problem`` message. Patch by Bartosz Sławecki. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-16-00-45-42.gh-issue-151510.HJ-kGn.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-16-00-45-42.gh-issue-151510.HJ-kGn.rst deleted file mode 100644 index cfa5ee8d3839c1b..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-16-00-45-42.gh-issue-151510.HJ-kGn.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a crash in :func:`!__lazy_import__` when called without an explicit -``globals`` argument and without a current Python frame. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-16-17-23-37.gh-issue-151546.LhiaZz.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-16-17-23-37.gh-issue-151546.LhiaZz.rst deleted file mode 100644 index af1c23bd50355f2..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-16-17-23-37.gh-issue-151546.LhiaZz.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix the stack limit check if Python is linked to musl (ex: Alpine Linux). -Use the stack size set by the linker to compute the stack limits. Patch by -Victor Stinner. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-17-16-26-45.gh-issue-151126.Yc_6wC.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-17-16-26-45.gh-issue-151126.Yc_6wC.rst deleted file mode 100644 index 29bb03d2d408598..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-17-16-26-45.gh-issue-151126.Yc_6wC.rst +++ /dev/null @@ -1,2 +0,0 @@ -Avoid possible crash in ``getpath.c`` where a device has no memory left. Now -it properly raises a :exc:`MemoryError`. Patch by Ivy Xu. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-17-16-46-07.gh-issue-151126.vhTL0T.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-17-16-46-07.gh-issue-151126.vhTL0T.rst deleted file mode 100644 index 6f2d230b1dcfc00..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-17-16-46-07.gh-issue-151126.vhTL0T.rst +++ /dev/null @@ -1,2 +0,0 @@ -Avoid possible crash in ``_winapi.c`` where a device has no memory left. Now -it properly raises a :exc:`MemoryError`. Patch by Ivy Xu. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-18-00-00-00.gh-issue-151644.5cFffN.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-18-00-00-00.gh-issue-151644.5cFffN.rst deleted file mode 100644 index ff5058e14b42f15..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-18-00-00-00.gh-issue-151644.5cFffN.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix a data race in :func:`sys.setdlopenflags` and :func:`sys.getdlopenflags` -when called concurrently in the free-threaded build. The underlying -``_PyImport_GetDLOpenFlags`` and ``_PyImport_SetDLOpenFlags`` functions now -use atomic load/store operations. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-18-16-00-10.gh-issue-151126.tBqn6I.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-18-16-00-10.gh-issue-151126.tBqn6I.rst deleted file mode 100644 index d495df43ede932c..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-18-16-00-10.gh-issue-151126.tBqn6I.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a crash when sharing :class:`memoryview` objects between interpreters -fails due to running out of memory. It now raises a proper -:exc:`MemoryError`. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-19-12-00-00.gh-issue-151646.Gc5tAt.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-19-12-00-00.gh-issue-151646.Gc5tAt.rst deleted file mode 100644 index fde428c8a2839bb..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-19-12-00-00.gh-issue-151646.Gc5tAt.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a data race in free-threading builds between :func:`gc.get_stats` and a -concurrent garbage collection cycle. Access to the per-generation statistics -is now serialized with a mutex so the reader observes a consistent snapshot. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-19-16-40-01.gh-issue-151619.35yyJW.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-19-16-40-01.gh-issue-151619.35yyJW.rst deleted file mode 100644 index 28ba2038e876fa7..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-19-16-40-01.gh-issue-151619.35yyJW.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix an issue where using non-module global or builtin namespaces (such as -dictionaries passed to :func:`exec`) could cause cached global loads to -produce unresolved :ref:`lazy imports `. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-20-00-30-47.gh-issue-151722.RPMPIY.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-20-00-30-47.gh-issue-151722.RPMPIY.rst deleted file mode 100644 index 57b5dee7458ede5..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-20-00-30-47.gh-issue-151722.RPMPIY.rst +++ /dev/null @@ -1,2 +0,0 @@ -Defer GC tracking of :class:`frozendict` to end of construction. Patch by -Donghee Na. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-20-10-01-26.gh-issue-151672.K-w7j0.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-20-10-01-26.gh-issue-151672.K-w7j0.rst deleted file mode 100644 index 4f4823df0b21015..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-20-10-01-26.gh-issue-151672.K-w7j0.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix an inconsistency where calling ``__lazy_import__`` with a string -``fromlist`` would return a :class:`types.LazyImportType` that resolves to -the named member, rather than the module being imported. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-21-12-55-18.gh-issue-151665.82fmzx.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-21-12-55-18.gh-issue-151665.82fmzx.rst deleted file mode 100644 index d08a1220cbe5efc..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-21-12-55-18.gh-issue-151665.82fmzx.rst +++ /dev/null @@ -1,2 +0,0 @@ -:func:`inspect.signature` now works on the lazy evaluators of type aliases -and type parameters instead of raising :exc:`ValueError`. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-21-16-00-00.gh-issue-151773.mN4kRt.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-21-16-00-00.gh-issue-151773.mN4kRt.rst deleted file mode 100644 index b4193c5e15ffef8..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-21-16-00-00.gh-issue-151773.mN4kRt.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a crash in :func:`contextvars.ContextVar.set` when memory allocation -fails. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-02-42-38.gh-issue-151907.6Tol_J.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-02-42-38.gh-issue-151907.6Tol_J.rst deleted file mode 100644 index cca300f6d0e2f42..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-02-42-38.gh-issue-151907.6Tol_J.rst +++ /dev/null @@ -1,2 +0,0 @@ -Avoid creating :class:`list` objects in comprehensions when the comprehension -is not used as a value. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-06-26-34.gh-issue-151905.FOLMYg.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-06-26-34.gh-issue-151905.FOLMYg.rst deleted file mode 100644 index c71122df6b8580f..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-06-26-34.gh-issue-151905.FOLMYg.rst +++ /dev/null @@ -1 +0,0 @@ -Fix OOM error handling in :c:func:`PyFrame_GetBack` to propagate exceptions instead of masking them as None. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-14-48-22.gh-issue-151912.YcxfnU.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-14-48-22.gh-issue-151912.YcxfnU.rst deleted file mode 100644 index 07b73949b438a33..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-14-48-22.gh-issue-151912.YcxfnU.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed a crash in ``type()`` when selecting a metaclass whose ``tp_new`` slot is ``NULL``. Such metaclasses are now rejected with ``TypeError`` instead of causing a NULL pointer dereference. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-23-12-03-55.gh-issue-151763.K7QfWG.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-23-12-03-55.gh-issue-151763.K7QfWG.rst deleted file mode 100644 index 64d0146cb091016..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-23-12-03-55.gh-issue-151763.K7QfWG.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a potential crash in :func:`compile`, :func:`exec`, :func:`eval` and -:func:`ast.parse` when an allocation fails: the parser or compiler could -return without setting an exception. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-23-19-50-22.gh-issue-152020.DTKXjR.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-23-19-50-22.gh-issue-152020.DTKXjR.rst deleted file mode 100644 index 93c716f7a6a1c86..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-23-19-50-22.gh-issue-152020.DTKXjR.rst +++ /dev/null @@ -1,3 +0,0 @@ -On the free-threaded build, :func:`asyncio.all_tasks` no longer loses -eager-started tasks when called from a thread other than the one running the -event loop. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-23-23-48-54.gh-issue-151763.Eu8pYQ.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-23-23-48-54.gh-issue-151763.Eu8pYQ.rst deleted file mode 100644 index d4746e992f8779d..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-23-23-48-54.gh-issue-151763.Eu8pYQ.rst +++ /dev/null @@ -1 +0,0 @@ -Fixes possible crash on :class:`types.CodeType` deallocation. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-24-13-36-31.gh-issue-151722.lWKfE1.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-24-13-36-31.gh-issue-151722.lWKfE1.rst deleted file mode 100644 index db50b0058bdbdda..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-24-13-36-31.gh-issue-151722.lWKfE1.rst +++ /dev/null @@ -1,3 +0,0 @@ -:meth:`!frozendict.fromkeys` now only tracks the :class:`frozendict` in the -garbage collector once the dictionary is fully initialized. Patch by Donghee Na -and Victor Stinner. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-25-21-34-15.gh-issue-152228.a6K14K.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-25-21-34-15.gh-issue-152228.a6K14K.rst deleted file mode 100644 index 8af7ae0d1739130..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-25-21-34-15.gh-issue-152228.a6K14K.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix an assertion failure when python is built in a debug mode -that happened in :meth:`str.replace` under a limited memory situation. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-05-49-13.gh-issue-152235.YU20T9.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-05-49-13.gh-issue-152235.YU20T9.rst deleted file mode 100644 index 8d386ad458dfff1..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-05-49-13.gh-issue-152235.YU20T9.rst +++ /dev/null @@ -1,2 +0,0 @@ -Defer GC tracking of a :class:`set` or :class:`frozenset` to the end of its -construction from iterable. Patch by Donghee Na. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-11-34-50.gh-issue-152254.yK6TGp.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-11-34-50.gh-issue-152254.yK6TGp.rst new file mode 100644 index 000000000000000..206b88a2affb2b2 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-11-34-50.gh-issue-152254.yK6TGp.rst @@ -0,0 +1,2 @@ +Fix a crash during the clean up of managed dict objects under a memory +pressure in :c:func:`PyObject_ClearManagedDict`. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-22-03-16.gh-issue-152235.ZKWiWk.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-22-03-16.gh-issue-152235.ZKWiWk.rst deleted file mode 100644 index ff89a2445cb4fe8..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-22-03-16.gh-issue-152235.ZKWiWk.rst +++ /dev/null @@ -1,3 +0,0 @@ -Defer GC tracking of :meth:`set.intersection`, :meth:`set.difference`, -:meth:`set.symmetric_difference`, :meth:`set.union` and ``set.__sub__``. -Patch by Donghee Na. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-22-38-21.gh-issue-152192.lX2jIM.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-22-38-21.gh-issue-152192.lX2jIM.rst deleted file mode 100644 index 153cbeb317a2452..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-22-38-21.gh-issue-152192.lX2jIM.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a truncated ``oparg`` being passed to JIT trace initialization for a -``JUMP_BACKWARD`` with an ``EXTENDED_ARG``. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-27-10-05-12.gh-issue-152375.L-ZBk6.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-27-10-05-12.gh-issue-152375.L-ZBk6.rst deleted file mode 100644 index db6ae3060d8328f..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-27-10-05-12.gh-issue-152375.L-ZBk6.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix undefined behaviour when a :mod:`sys.monitoring` callback raised an -exception while the program was following a branch or loop. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-28-14-31-03.gh-issue-152492._09Zee.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-28-14-31-03.gh-issue-152492._09Zee.rst deleted file mode 100644 index 16cb5a205c908a8..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-28-14-31-03.gh-issue-152492._09Zee.rst +++ /dev/null @@ -1 +0,0 @@ -:type:`collections.OrderedDict` ``update`` method can now accept :type:`frozendict` as an argument. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-28-14-39-05.gh-issue-152405.-_3YRo.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-28-14-39-05.gh-issue-152405.-_3YRo.rst deleted file mode 100644 index d7c473ce171d4b7..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-28-14-39-05.gh-issue-152405.-_3YRo.rst +++ /dev/null @@ -1,5 +0,0 @@ -Do not expose the internal mapping of :class:`types.MappingProxyType` -when performing rich-compare operations with non-stdlib types. -Previously, it was possible to mutate the internal mapping of a proxy there. -Now we pass not the original :class:`dict` instance, but its copy, -when dealing with custom types. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-29-23-29-14.gh-issue-152635.O21J0O.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-29-23-29-14.gh-issue-152635.O21J0O.rst deleted file mode 100644 index dadb25fc7c44771..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-29-23-29-14.gh-issue-152635.O21J0O.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a crash caused when running out of memory creating a -:mod:`!_interpchannels` channel. Now a :exc:`MemoryError` is correctly raised. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-30-14-00-00.gh-issue-152682.yId7e5.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-30-14-00-00.gh-issue-152682.yId7e5.rst deleted file mode 100644 index aba0b594382bcf8..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-30-14-00-00.gh-issue-152682.yId7e5.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix NULL pointer dereference in :func:`compile` when a reserved name (e.g. -``__classdict__``) is used as a type parameter name and memory allocation -fails while formatting the error message. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-01-12-00-00.gh-issue-102960.fR8kJa.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-01-12-00-00.gh-issue-102960.fR8kJa.rst deleted file mode 100644 index fec1eeb242c1ed6..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-01-12-00-00.gh-issue-102960.fR8kJa.rst +++ /dev/null @@ -1,2 +0,0 @@ -:ref:`Frame objects ` now support :mod:`weak references -`. Patch by Łukasz Langa. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-06-18-00-00.gh-issue-153171.errloc1.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-06-18-00-00.gh-issue-153171.errloc1.rst deleted file mode 100644 index aa3171b701894d7..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-06-18-00-00.gh-issue-153171.errloc1.rst +++ /dev/null @@ -1,3 +0,0 @@ -Improve syntax error messages for misplaced ``not`` after an operator -in contexts where a generic "invalid syntax" error was previously reported, -such as ``1 << 2 + not x`` and ``1 * + not x``. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-07-04-16-48.gh-issue-153205.5fE8QZ.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-07-04-16-48.gh-issue-153205.5fE8QZ.rst deleted file mode 100644 index 9ccfbff7ee69778..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-07-04-16-48.gh-issue-153205.5fE8QZ.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a potential :exc:`SystemError` during vector calls when memory allocation fails. -A :exc:`MemoryError` is now raised instead. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-08-13-23-11.gh-issue-153298.wvcXxN.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-08-13-23-11.gh-issue-153298.wvcXxN.rst deleted file mode 100644 index 38d548834d5e02e..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-08-13-23-11.gh-issue-153298.wvcXxN.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fixes a data race in :class:`types.GenericAlias` ``__parameters__`` -initialization on free-threading builds. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-18-22-56-27.gh-issue-152125.sEPvJf.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-18-22-56-27.gh-issue-152125.sEPvJf.rst new file mode 100644 index 000000000000000..ae66f69f206217f --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-18-22-56-27.gh-issue-152125.sEPvJf.rst @@ -0,0 +1,3 @@ +Fix a crash in the :term:`free-threaded build` where :c:func:`PyList_New` could leave +a newly allocated list's item buffer pointer uninitialized when the backing +array allocation failed under low memory, leading to an invalid free. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-08-05-01-10-20.gh-issue-155181.jj8jhk.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-08-05-01-10-20.gh-issue-155181.jj8jhk.rst new file mode 100644 index 000000000000000..1acf8fda95e4652 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-08-05-01-10-20.gh-issue-155181.jj8jhk.rst @@ -0,0 +1,3 @@ +:class:`frozenset` objects created from a set literal or a set comprehension +are now untracked by the garbage collector when none of their elements can +be tracked. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-08-05-19-10-00.gh-issue-155247.extKey.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-08-05-19-10-00.gh-issue-155247.extKey.rst new file mode 100644 index 000000000000000..1e08323008d5b7a --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-08-05-19-10-00.gh-issue-155247.extKey.rst @@ -0,0 +1,4 @@ +Fix importing an extension module whose path contains characters unencodable +in UTF-8, e.g. undecodable bytes of a file name. Previously it failed with +:exc:`UnicodeEncodeError`, which made it impossible to build or run Python in +a directory with such name. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-08-23-16-31-00.gh-issue-151126.phAWIG.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-08-23-16-31-00.gh-issue-151126.phAWIG.rst new file mode 100644 index 000000000000000..b1459de1c1596d8 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-08-23-16-31-00.gh-issue-151126.phAWIG.rst @@ -0,0 +1 @@ +Fix a crash when allocation failure occurs during :ref:`interp-object-sharing`. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-08-28-10-15-00.gh-issue-144446.pQ7wXn.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-08-28-10-15-00.gh-issue-144446.pQ7wXn.rst new file mode 100644 index 000000000000000..2718a4cc7487f05 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-08-28-10-15-00.gh-issue-144446.pQ7wXn.rst @@ -0,0 +1,2 @@ +Fix thread safety of :attr:`frame.f_locals` and :c:func:`PyFrame_GetVar` on +frames executing on another thread in the free-threaded build. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-10-08-19-03-14.gh-issue-159037.nbQ5wk.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-08-19-03-14.gh-issue-159037.nbQ5wk.rst new file mode 100644 index 000000000000000..a27cc2782d0b7c0 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-08-19-03-14.gh-issue-159037.nbQ5wk.rst @@ -0,0 +1 @@ +Improve performance of :meth:`str.join`. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-10-09-18-27-12.gh-issue-159054.YUCTvG.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-09-18-27-12.gh-issue-159054.YUCTvG.rst new file mode 100644 index 000000000000000..eaa01aa05435a72 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-09-18-27-12.gh-issue-159054.YUCTvG.rst @@ -0,0 +1,2 @@ +Fixed a crash when an allocation failure occurred while compiling code +containing cold blocks. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-10-22-15-40-00.gh-issue-160303.q7Zb2K.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-22-15-40-00.gh-issue-160303.q7Zb2K.rst new file mode 100644 index 000000000000000..ba72afc400bd0ab --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-22-15-40-00.gh-issue-160303.q7Zb2K.rst @@ -0,0 +1,5 @@ +Fix :class:`bytearray` reading and writing memory outside of its buffer +after ``del b[:n]`` or ``b[:n] = shorter`` failed with :exc:`MemoryError`. +The bytes are now removed even if shrinking the memory block fails; +:exc:`MemoryError` is still raised. Also fix the missing null byte after the +data when shrinking fails for a slice which is not at the front. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-10-22-20-18-44.gh-issue-160247.WC8hRU.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-22-20-18-44.gh-issue-160247.WC8hRU.rst new file mode 100644 index 000000000000000..97755e25aac7c26 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-22-20-18-44.gh-issue-160247.WC8hRU.rst @@ -0,0 +1,2 @@ +Reduce padding in the internal instruction sequence structure, saving 8 bytes +per instance on 64-bit platforms. Patch by Shamil Abdulaev. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-10-23-08-01-14.gh-issue-159580.lEl21_.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-23-08-01-14.gh-issue-159580.lEl21_.rst new file mode 100644 index 000000000000000..5acc2d3283d5ad2 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-23-08-01-14.gh-issue-159580.lEl21_.rst @@ -0,0 +1 @@ +Improve performance of :func:`isinstance` when the check fails. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-10-24-19-40-00.gh-issue-160573.sT9kQe.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-24-19-40-00.gh-issue-160573.sT9kQe.rst new file mode 100644 index 000000000000000..7a69a4769204857 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-24-19-40-00.gh-issue-160573.sT9kQe.rst @@ -0,0 +1,4 @@ +Fix a crash when a :class:`set` iterator that is shared between threads reaches +its end in a free-threaded build: every thread that walked off the end of the +table released the iterator's reference to the set, so the set was over-released. +The iterator now keeps its reference to the set until it is deallocated. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-10-25-12-30-00.gh-issue-112564.gcDbgW.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-25-12-30-00.gh-issue-112564.gcDbgW.rst new file mode 100644 index 000000000000000..5ff3cb147e71c0d --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-25-12-30-00.gh-issue-112564.gcDbgW.rst @@ -0,0 +1,5 @@ +Fix a crash in the garbage collector when :data:`gc.DEBUG_COLLECTABLE` or +:data:`gc.DEBUG_UNCOLLECTABLE` is set and writing the debug output to +:data:`sys.stderr` frees one of the objects being reported. Object addresses +in this output now use the same ``0x``-prefixed lowercase format on all +platforms, including Windows. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-10-26-10-18-26.gh-issue-160697.qSbR1f.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-26-10-18-26.gh-issue-160697.qSbR1f.rst new file mode 100644 index 000000000000000..55649732e8f4b23 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-26-10-18-26.gh-issue-160697.qSbR1f.rst @@ -0,0 +1,4 @@ +Fix crashes and hangs in the :term:`free-threaded build` when a destructor +ran in the middle of a :class:`dict` resize, a :class:`list` resize or a type +cache update. The thread's queue of delayed frees is now processed only from +the eval breaker, instead of synchronously when the queue fills up. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-11-01-16-02-42.gh-issue-161145.5vLdrm.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-01-16-02-42.gh-issue-161145.5vLdrm.rst new file mode 100644 index 000000000000000..5d809624e25f420 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-01-16-02-42.gh-issue-161145.5vLdrm.rst @@ -0,0 +1,2 @@ +Speed up UTF-8 decoding of long ASCII runs, such as in :meth:`bytes.decode`, +by up to 1.5x. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-11-09-12-00-00.gh-issue-161693.Sp1tKy.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-09-12-00-00.gh-issue-161693.Sp1tKy.rst new file mode 100644 index 000000000000000..ed820f6d29efe9a --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-09-12-00-00.gh-issue-161693.Sp1tKy.rst @@ -0,0 +1,3 @@ +Fix a crash in :meth:`dict.setdefault` when called on an instance +dictionary with a :class:`str` subclass key equal to an attribute name +that is not set on that instance. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-11-11-04-58-51.gh-issue-161792.42EcBI8x.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-11-04-58-51.gh-issue-161792.42EcBI8x.rst new file mode 100644 index 000000000000000..a4b685d96bc8967 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-11-04-58-51.gh-issue-161792.42EcBI8x.rst @@ -0,0 +1,4 @@ +Fix crashes in the callable iterator returned by :func:`iter` with a +sentinel, when :meth:`!__setstate__` is called while the iterator is in use, +or when the iterator is shared between threads in the :term:`free-threaded +build`. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-11-11-21-52-02.gh-issue-161827.3PD3RK.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-11-21-52-02.gh-issue-161827.3PD3RK.rst new file mode 100644 index 000000000000000..2ae6517db14f157 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-11-21-52-02.gh-issue-161827.3PD3RK.rst @@ -0,0 +1,4 @@ +Keep ``_PyEval_EvalFrameDefault`` as a separate frame in the C call stack +when Python is built with the tail-calling interpreter +(:option:`--with-tail-call-interp`), so that stack unwinders, profilers and +other tools that walk the stack can find the interpreter loop. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-11-12-14-37-21.gh-issue-161875.W-nGSw.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-12-14-37-21.gh-issue-161875.W-nGSw.rst new file mode 100644 index 000000000000000..693f39a2bef9177 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-12-14-37-21.gh-issue-161875.W-nGSw.rst @@ -0,0 +1,3 @@ +The :opcode:`GET_AWAITABLE` instruction now also pushes the ``NULL`` and +``None`` that start the :opcode:`SEND` loop, so ``await`` no longer needs +separate :opcode:`PUSH_NULL` and ``LOAD_CONST None`` instructions. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-11-12-14-46-10.gh-issue-161875.oOjR9w.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-12-14-46-10.gh-issue-161875.oOjR9w.rst new file mode 100644 index 000000000000000..9afa682ea8b6ffb --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-12-14-46-10.gh-issue-161875.oOjR9w.rst @@ -0,0 +1,4 @@ +The :opcode:`GET_ANEXT` instruction now also pushes the ``NULL`` and +``None`` that start the :opcode:`SEND` loop, so each :keyword:`async for` +iteration no longer needs separate :opcode:`PUSH_NULL` and ``LOAD_CONST None`` +instructions. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-11-13-00-00-00.gh-issue-161968.ytuf5z.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-13-00-00-00.gh-issue-161968.ytuf5z.rst new file mode 100644 index 000000000000000..12d61b2eeee74e8 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-13-00-00-00.gh-issue-161968.ytuf5z.rst @@ -0,0 +1,2 @@ +Fix ``x *= seq`` raising :exc:`TypeError` when ``x`` is an instance of an +:class:`int` subclass or of a class defining :meth:`~object.__index__`. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-11-13-08-43-30.gh-issue-161849.m5BmNR.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-13-08-43-30.gh-issue-161849.m5BmNR.rst new file mode 100644 index 000000000000000..744a5abed698f45 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-13-08-43-30.gh-issue-161849.m5BmNR.rst @@ -0,0 +1,4 @@ +Fix a crash and a :exc:`SystemError` when compiling a class whose body binds +``__classdict__`` (for example ``__classdict__ = 1`` or ``global +__classdict__``) and also contains an annotated function, a generic class or +function, or a generic type alias. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-11-14-23-17-18.gh-issue-161751.-silGa.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-14-23-17-18.gh-issue-161751.-silGa.rst new file mode 100644 index 000000000000000..0c39e484386dc58 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-14-23-17-18.gh-issue-161751.-silGa.rst @@ -0,0 +1,2 @@ +Fix race in mimalloc abandoned segment visit in free-threaded GC. Patch by +Donghee Na. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-11-20-12-00-00.gh-issue-152276.bRcImm.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-20-12-00-00.gh-issue-152276.bRcImm.rst new file mode 100644 index 000000000000000..9cc5d98dae0d0f1 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-20-12-00-00.gh-issue-152276.bRcImm.rst @@ -0,0 +1,2 @@ +For the :term:`free-threaded build`, avoid an assertion failure when an object +becomes immortal while queued for biased reference counting (BRC) merging. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-11-21-12-00-00.gh-issue-162227.fMtScl.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-21-12-00-00.gh-issue-162227.fMtScl.rst new file mode 100644 index 000000000000000..06b6570b2cd26c2 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-21-12-00-00.gh-issue-162227.fMtScl.rst @@ -0,0 +1,4 @@ +Improve multi-threaded scaling of :func:`format`, f-strings and +:meth:`str.format` with a format specification on the :term:`free-threaded +build` by avoiding the creation of a temporary bound method and reference +count contention on the shared ``__format__`` method. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-11-23-09-17-41.gh-issue-162477.TEcSpB.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-23-09-17-41.gh-issue-162477.TEcSpB.rst new file mode 100644 index 000000000000000..9bfe0a710fc669b --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-23-09-17-41.gh-issue-162477.TEcSpB.rst @@ -0,0 +1,2 @@ +Speed up :c:func:`PyFloat_AsDouble` for exact :class:`int` arguments. Patch by +Maurycy Pawłowski-Wieroński. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/README.rst b/Misc/NEWS.d/next/Core_and_Builtins/README.rst index 00831936c450841..52b8c3e62631630 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/README.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/README.rst @@ -1,3 +1 @@ -Put news entry `blurb`_ files for the *Core and Builtins* section in this directory. - -.. _blurb: https://pypi.org/project/blurb/ +Put news entry ``blurb`` files for the *Core and Builtins* section in this directory. diff --git a/Misc/NEWS.d/next/Documentation/2023-09-16-23-42-27.gh-issue-109503.mZ-kdU.rst b/Misc/NEWS.d/next/Documentation/2023-09-16-23-42-27.gh-issue-109503.mZ-kdU.rst deleted file mode 100644 index c3c6c57569c2ea5..000000000000000 --- a/Misc/NEWS.d/next/Documentation/2023-09-16-23-42-27.gh-issue-109503.mZ-kdU.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix documentation for :func:`shutil.move` on usage of -:func:`os.rename` since nonatomic move might be used even if the files are -on the same filesystem. Patch by Fang Li diff --git a/Misc/NEWS.d/next/Documentation/2026-05-23-17-27-41.gh-issue-150319.ol9tWK.rst b/Misc/NEWS.d/next/Documentation/2026-05-23-17-27-41.gh-issue-150319.ol9tWK.rst deleted file mode 100644 index d56ccbce2fa325c..000000000000000 --- a/Misc/NEWS.d/next/Documentation/2026-05-23-17-27-41.gh-issue-150319.ol9tWK.rst +++ /dev/null @@ -1,2 +0,0 @@ -Generic builtin and standard library types now document the meaning of their -type parameters. diff --git a/Misc/NEWS.d/next/Documentation/2026-06-17-12-00-00.gh-issue-86726.__bOgH.rst b/Misc/NEWS.d/next/Documentation/2026-06-17-12-00-00.gh-issue-86726.__bOgH.rst deleted file mode 100644 index 787b95dbf236279..000000000000000 --- a/Misc/NEWS.d/next/Documentation/2026-06-17-12-00-00.gh-issue-86726.__bOgH.rst +++ /dev/null @@ -1,4 +0,0 @@ -Greatly expand the :mod:`tkinter` documentation to cover the full public API -of the package and its submodules. The descriptions are oriented towards -Python rather than Tcl/Tk, with corrected return types and -``versionadded``/``versionchanged`` information. diff --git a/Misc/NEWS.d/next/Documentation/README.rst b/Misc/NEWS.d/next/Documentation/README.rst index 245b7d635993de2..405f0ac01a7202e 100644 --- a/Misc/NEWS.d/next/Documentation/README.rst +++ b/Misc/NEWS.d/next/Documentation/README.rst @@ -1,3 +1 @@ -Put news entry `blurb`_ files for the *Documentation* section in this directory. - -.. _blurb: https://pypi.org/project/blurb/ +Put news entry ``blurb`` files for the *Documentation* section in this directory. diff --git a/Misc/NEWS.d/next/Emscripten/README.rst b/Misc/NEWS.d/next/Emscripten/README.rst new file mode 100644 index 000000000000000..521a81eeffb53f7 --- /dev/null +++ b/Misc/NEWS.d/next/Emscripten/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *Emscripten* section in this directory. diff --git a/Misc/NEWS.d/next/FreeBSD/README.rst b/Misc/NEWS.d/next/FreeBSD/README.rst new file mode 100644 index 000000000000000..c2cae7b30e4d5e0 --- /dev/null +++ b/Misc/NEWS.d/next/FreeBSD/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *FreeBSD* section in this directory. diff --git a/Misc/NEWS.d/next/IDLE/2019-12-12-03-18-02.bpo-6699.1CqJFG.rst b/Misc/NEWS.d/next/IDLE/2019-12-12-03-18-02.bpo-6699.1CqJFG.rst deleted file mode 100644 index e7fb9bf1b3bdf6a..000000000000000 --- a/Misc/NEWS.d/next/IDLE/2019-12-12-03-18-02.bpo-6699.1CqJFG.rst +++ /dev/null @@ -1 +0,0 @@ -Warn the user if a file will be overwritten when saving. diff --git a/Misc/NEWS.d/next/IDLE/2026-06-28-06-46-46.gh-issue-85320.Hq2vKn.rst b/Misc/NEWS.d/next/IDLE/2026-06-28-06-46-46.gh-issue-85320.Hq2vKn.rst deleted file mode 100644 index ec34bf8ead9eb9f..000000000000000 --- a/Misc/NEWS.d/next/IDLE/2026-06-28-06-46-46.gh-issue-85320.Hq2vKn.rst +++ /dev/null @@ -1,4 +0,0 @@ -IDLE now reads and writes its configuration files and the breakpoints file -using UTF-8 instead of the locale encoding. This keeps non-ASCII data (such -as non-ASCII paths) from being corrupted and makes the files portable between -environments. diff --git a/Misc/NEWS.d/next/IDLE/2026-07-01-00-00-00.gh-issue-66331.wMcLaS.rst b/Misc/NEWS.d/next/IDLE/2026-07-01-00-00-00.gh-issue-66331.wMcLaS.rst deleted file mode 100644 index e00e7c7d8fdc652..000000000000000 --- a/Misc/NEWS.d/next/IDLE/2026-07-01-00-00-00.gh-issue-66331.wMcLaS.rst +++ /dev/null @@ -1,3 +0,0 @@ -Set the ``WM_CLASS`` window property of IDLE's windows to ``Idle`` on X11, -so that window managers group and label them correctly instead of using the -default ``Toplevel``. diff --git a/Misc/NEWS.d/next/IDLE/2026-07-01-00-15-58.gh-issue-152728.yxIhMN.rst b/Misc/NEWS.d/next/IDLE/2026-07-01-00-15-58.gh-issue-152728.yxIhMN.rst deleted file mode 100644 index d73512a615c1898..000000000000000 --- a/Misc/NEWS.d/next/IDLE/2026-07-01-00-15-58.gh-issue-152728.yxIhMN.rst +++ /dev/null @@ -1,2 +0,0 @@ -Move functions run.fix_scaling, editor.fixwordbreaks (as fix_word_breaks) -and pyshell.fix_x11_paste to idlelib.util. diff --git a/Misc/NEWS.d/next/IDLE/2026-07-01-12-00-00.gh-issue-71956.rPlAlL.rst b/Misc/NEWS.d/next/IDLE/2026-07-01-12-00-00.gh-issue-71956.rPlAlL.rst deleted file mode 100644 index 1a92ed4cd389cf5..000000000000000 --- a/Misc/NEWS.d/next/IDLE/2026-07-01-12-00-00.gh-issue-71956.rPlAlL.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix Replace All in the IDLE editor's Replace dialog when the search -direction is "Up" and "Wrap around" is off: it now replaces all matches -above the current position instead of only the first one. diff --git a/Misc/NEWS.d/next/IDLE/2026-07-01-14-00-00.gh-issue-89360.mUlTiC.rst b/Misc/NEWS.d/next/IDLE/2026-07-01-14-00-00.gh-issue-89360.mUlTiC.rst deleted file mode 100644 index 9e3023f8228233f..000000000000000 --- a/Misc/NEWS.d/next/IDLE/2026-07-01-14-00-00.gh-issue-89360.mUlTiC.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a rare crash in the IDLE editor when the completion window is closed: -deleting a key binding for a sequence that is not bound to the virtual -event is now ignored instead of raising a ``ValueError``. diff --git a/Misc/NEWS.d/next/IDLE/2026-07-01-15-00-00.gh-issue-134300.iDlPaT.rst b/Misc/NEWS.d/next/IDLE/2026-07-01-15-00-00.gh-issue-134300.iDlPaT.rst deleted file mode 100644 index 791acbbed62aaf3..000000000000000 --- a/Misc/NEWS.d/next/IDLE/2026-07-01-15-00-00.gh-issue-134300.iDlPaT.rst +++ /dev/null @@ -1,3 +0,0 @@ -Do not add the ``idlelib`` directory to the path of the IDLE user process. -User code run in IDLE can no longer import ``idlelib`` submodules as -top-level modules, such as ``import help``. diff --git a/Misc/NEWS.d/next/IDLE/2026-07-01-16-00-00.gh-issue-80504.gReP.rst b/Misc/NEWS.d/next/IDLE/2026-07-01-16-00-00.gh-issue-80504.gReP.rst deleted file mode 100644 index 93adb33202a41c1..000000000000000 --- a/Misc/NEWS.d/next/IDLE/2026-07-01-16-00-00.gh-issue-80504.gReP.rst +++ /dev/null @@ -1,3 +0,0 @@ -The "In files:" field of IDLE's Find in Files dialog now always contains a -full directory path, even for an unsaved editor or the Shell. This shows -in the grep output which directory was searched. diff --git a/Misc/NEWS.d/next/IDLE/2026-07-01-17-00-00.gh-issue-65339.oUtTxt.rst b/Misc/NEWS.d/next/IDLE/2026-07-01-17-00-00.gh-issue-65339.oUtTxt.rst deleted file mode 100644 index a8b216e86dc8d7e..000000000000000 --- a/Misc/NEWS.d/next/IDLE/2026-07-01-17-00-00.gh-issue-65339.oUtTxt.rst +++ /dev/null @@ -1,3 +0,0 @@ -Saving the IDLE Shell or an Output window now defaults to a ``.txt`` -extension and lists text files before Python files, since their content is -not Python source. diff --git a/Misc/NEWS.d/next/IDLE/2026-07-01-18-00-00.gh-issue-83653.cFgInt.rst b/Misc/NEWS.d/next/IDLE/2026-07-01-18-00-00.gh-issue-83653.cFgInt.rst deleted file mode 100644 index 5812b2dd977f6a9..000000000000000 --- a/Misc/NEWS.d/next/IDLE/2026-07-01-18-00-00.gh-issue-83653.cFgInt.rst +++ /dev/null @@ -1,3 +0,0 @@ -Blanking an integer entry in IDLE's Settings dialog, such as "Auto squeeze -min lines", no longer saves an empty string as an invalid configuration -value. diff --git a/Misc/NEWS.d/next/IDLE/2026-07-01-19-00-00.gh-issue-82183.rNsTrt.rst b/Misc/NEWS.d/next/IDLE/2026-07-01-19-00-00.gh-issue-82183.rNsTrt.rst deleted file mode 100644 index 2af412f5200d0de..000000000000000 --- a/Misc/NEWS.d/next/IDLE/2026-07-01-19-00-00.gh-issue-82183.rNsTrt.rst +++ /dev/null @@ -1,3 +0,0 @@ -When the shell is busy running code, using "Run... Customized" with "Restart -shell" unchecked now reports that the shell is executing instead of -restarting it anyway. diff --git a/Misc/NEWS.d/next/IDLE/README.rst b/Misc/NEWS.d/next/IDLE/README.rst index 834c5d48b95f608..5475f7b42050cd5 100644 --- a/Misc/NEWS.d/next/IDLE/README.rst +++ b/Misc/NEWS.d/next/IDLE/README.rst @@ -1,3 +1 @@ -Put news entry `blurb`_ files for the *IDLE* section in this directory. - -.. _blurb: https://pypi.org/project/blurb/ +Put news entry ``blurb`` files for the *IDLE* section in this directory. diff --git a/Misc/NEWS.d/next/Library/2021-01-09-18-40-15.bpo-42861.T7Ge9O.rst b/Misc/NEWS.d/next/Library/2021-01-09-18-40-15.bpo-42861.T7Ge9O.rst deleted file mode 100644 index 46ed99d1e1b4992..000000000000000 --- a/Misc/NEWS.d/next/Library/2021-01-09-18-40-15.bpo-42861.T7Ge9O.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add :meth:`~ipaddress.IPv4Network.next_network` and -:meth:`~ipaddress.IPv6Network.next_network`. Patch by Faisal Mahmood. diff --git a/Misc/NEWS.d/next/Library/2021-02-26-13-17-57.bpo-40469.yJHeQg.rst b/Misc/NEWS.d/next/Library/2021-02-26-13-17-57.bpo-40469.yJHeQg.rst deleted file mode 100644 index 239f856bb04c0ae..000000000000000 --- a/Misc/NEWS.d/next/Library/2021-02-26-13-17-57.bpo-40469.yJHeQg.rst +++ /dev/null @@ -1,5 +0,0 @@ -:class:`~logging.handlers.TimedRotatingFileHandler` now uses the creation time -instead of the last modification time of an existing log file as the basis -for the first rotation after handler creation, if supported by the OS and file system. -This allows it to be used in short-running programs that start and end before -the rotation interval expires. diff --git a/Misc/NEWS.d/next/Library/2021-10-18-13-46-55.bpo-45509.Upwb60.rst b/Misc/NEWS.d/next/Library/2021-10-18-13-46-55.bpo-45509.Upwb60.rst deleted file mode 100644 index 80c38c03f8fe787..000000000000000 --- a/Misc/NEWS.d/next/Library/2021-10-18-13-46-55.bpo-45509.Upwb60.rst +++ /dev/null @@ -1 +0,0 @@ -Gzip headers are now checked for corrupted NAME, COMMENT and HCRC fields. diff --git a/Misc/NEWS.d/next/Library/2022-04-04-17-58-05.bpo-47216.gPyPte.rst b/Misc/NEWS.d/next/Library/2022-04-04-17-58-05.bpo-47216.gPyPte.rst deleted file mode 100644 index 066e17c1c6e06aa..000000000000000 --- a/Misc/NEWS.d/next/Library/2022-04-04-17-58-05.bpo-47216.gPyPte.rst +++ /dev/null @@ -1,2 +0,0 @@ -Added *mtime* option to :func:`gzip.open`, which will be passed -to the constructor of :class:`~gzip.GzipFile`. diff --git a/Misc/NEWS.d/next/Library/2022-04-10-20-10-59.bpo-46375.8j1ogZ.rst b/Misc/NEWS.d/next/Library/2022-04-10-20-10-59.bpo-46375.8j1ogZ.rst deleted file mode 100644 index 0d1ebb6bbee1136..000000000000000 --- a/Misc/NEWS.d/next/Library/2022-04-10-20-10-59.bpo-46375.8j1ogZ.rst +++ /dev/null @@ -1 +0,0 @@ -Add :meth:`io.BytesIO.peek` method to read without advancing position. diff --git a/Misc/NEWS.d/next/Library/2023-01-23-21-23-50.gh-issue-101267._f-cFH.rst b/Misc/NEWS.d/next/Library/2023-01-23-21-23-50.gh-issue-101267._f-cFH.rst deleted file mode 100644 index 901a3fb60ab5b9f..000000000000000 --- a/Misc/NEWS.d/next/Library/2023-01-23-21-23-50.gh-issue-101267._f-cFH.rst +++ /dev/null @@ -1,7 +0,0 @@ -When a worker process terminates unexpectedly, -:class:`concurrent.futures.ProcessPoolExecutor` now sets a separate -:exc:`~concurrent.futures.process.BrokenProcessPool` exception on each pending -future instead of sharing a single instance among them all. Sharing one -exception produced malformed tracebacks: each -:meth:`Future.result() ` call re-raised the -same object, appending another copy of the traceback to it. diff --git a/Misc/NEWS.d/next/Library/2023-02-26-14-07-18.gh-issue-91099._QPbEL.rst b/Misc/NEWS.d/next/Library/2023-02-26-14-07-18.gh-issue-91099._QPbEL.rst deleted file mode 100644 index d886e8ac6032a4a..000000000000000 --- a/Misc/NEWS.d/next/Library/2023-02-26-14-07-18.gh-issue-91099._QPbEL.rst +++ /dev/null @@ -1,2 +0,0 @@ -:meth:`imaplib.IMAP4.login` now raises exceptions with :class:`str` instead of -:class:`bytes`. Patch by Florian Best. diff --git a/Misc/NEWS.d/next/Library/2023-04-24-11-12-00.gh-issue-60055.UjP6aX.rst b/Misc/NEWS.d/next/Library/2023-04-24-11-12-00.gh-issue-60055.UjP6aX.rst deleted file mode 100644 index 58fface7caded53..000000000000000 --- a/Misc/NEWS.d/next/Library/2023-04-24-11-12-00.gh-issue-60055.UjP6aX.rst +++ /dev/null @@ -1 +0,0 @@ -Let ``urllib.robotparser.RobotFileParser`` accept a ``urllib.request.Request`` object as well as a url string when setting a robots.txt url. diff --git a/Misc/NEWS.d/next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst b/Misc/NEWS.d/next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst deleted file mode 100644 index 79289c1f0bd4217..000000000000000 --- a/Misc/NEWS.d/next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst +++ /dev/null @@ -1 +0,0 @@ -Accept an uppercase V prefix in IPvFuture addresses in :func:`urllib.parse.urlsplit`. diff --git a/Misc/NEWS.d/next/Library/2023-10-18-13-31-10.gh-issue-110941.UVrYGE.rst b/Misc/NEWS.d/next/Library/2023-10-18-13-31-10.gh-issue-110941.UVrYGE.rst new file mode 100644 index 000000000000000..5824b593460e9be --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-10-18-13-31-10.gh-issue-110941.UVrYGE.rst @@ -0,0 +1,2 @@ +Fix ``json.dump`` and ``json.dumps`` encoding certain dict subclasses as +empty. diff --git a/Misc/NEWS.d/next/Library/2024-03-17-22-16-53.gh-issue-115988.EshSDM.rst b/Misc/NEWS.d/next/Library/2024-03-17-22-16-53.gh-issue-115988.EshSDM.rst deleted file mode 100644 index 4efde6a48c26cc8..000000000000000 --- a/Misc/NEWS.d/next/Library/2024-03-17-22-16-53.gh-issue-115988.EshSDM.rst +++ /dev/null @@ -1 +0,0 @@ -:mod:`lzma` adds constants to support the newer BCJ filters for ARM64 and RISC-V. diff --git a/Misc/NEWS.d/next/Library/2024-06-18-04-08-37.gh-issue-120665.x7T1hV.rst b/Misc/NEWS.d/next/Library/2024-06-18-04-08-37.gh-issue-120665.x7T1hV.rst deleted file mode 100644 index 27e93988ed11efb..000000000000000 --- a/Misc/NEWS.d/next/Library/2024-06-18-04-08-37.gh-issue-120665.x7T1hV.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed an issue where ``unittest`` loaders would load and instantiate :class:`unittest.TestCase`-derived subclasses that are also abstract base classes, which can't be instantiated. diff --git a/Misc/NEWS.d/next/Library/2024-07-02-20-57-43.gh-issue-121109.Tp6R2s.rst b/Misc/NEWS.d/next/Library/2024-07-02-20-57-43.gh-issue-121109.Tp6R2s.rst deleted file mode 100644 index eca6014e4a0aed1..000000000000000 --- a/Misc/NEWS.d/next/Library/2024-07-02-20-57-43.gh-issue-121109.Tp6R2s.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix :mod:`tarfile` performance issue when reading archives in streaming mode -(e.g. ``r|*``). diff --git a/Misc/NEWS.d/next/Library/2024-11-02-02-02-31.gh-issue-107398.uUtA6Q.rst b/Misc/NEWS.d/next/Library/2024-11-02-02-02-31.gh-issue-107398.uUtA6Q.rst deleted file mode 100644 index d5af322d68d309a..000000000000000 --- a/Misc/NEWS.d/next/Library/2024-11-02-02-02-31.gh-issue-107398.uUtA6Q.rst +++ /dev/null @@ -1 +0,0 @@ -Fix :mod:`tarfile` stream mode exception when process the file with the gzip extra field. diff --git a/Misc/NEWS.d/next/Library/2025-03-01-13-36-02.gh-issue-128110.9wx_G0.rst b/Misc/NEWS.d/next/Library/2025-03-01-13-36-02.gh-issue-128110.9wx_G0.rst deleted file mode 100644 index b08b1886cff9cf6..000000000000000 --- a/Misc/NEWS.d/next/Library/2025-03-01-13-36-02.gh-issue-128110.9wx_G0.rst +++ /dev/null @@ -1,5 +0,0 @@ -Fix bug in the parsing of :mod:`email` address headers that could result in -extraneous spaces in the decoded text when using a modern email policy. -Space between pairs of adjacent :rfc:`2047` encoded-words is now ignored, per -section 6.2 (and consistent with existing parsing of unstructured -headers like *Subject*). diff --git a/Misc/NEWS.d/next/Library/2025-05-01-16-44-16.gh-issue-72902.19qwJW.rst b/Misc/NEWS.d/next/Library/2025-05-01-16-44-16.gh-issue-72902.19qwJW.rst deleted file mode 100644 index 2b7d8e448408943..000000000000000 --- a/Misc/NEWS.d/next/Library/2025-05-01-16-44-16.gh-issue-72902.19qwJW.rst +++ /dev/null @@ -1,3 +0,0 @@ -Optimize (~x1.4 speedup) :meth:`fractions.Fraction.from_decimal` and -:meth:`fractions.Fraction.from_float` for :class:`~decimal.Decimal` and -:class:`float` inputs, respectively. Patch by Sergey B Kirpichev. diff --git a/Misc/NEWS.d/next/Library/2025-05-07-18-31-31.gh-issue-46927.sF02gj.rst b/Misc/NEWS.d/next/Library/2025-05-07-18-31-31.gh-issue-46927.sF02gj.rst deleted file mode 100644 index 3ba9757c8acb5de..000000000000000 --- a/Misc/NEWS.d/next/Library/2025-05-07-18-31-31.gh-issue-46927.sF02gj.rst +++ /dev/null @@ -1,2 +0,0 @@ -Prevent :mod:`readline` from overriding the ``COLUMNS`` and ``LINES`` -environment variables, as values are not updated on terminal resize. diff --git a/Misc/NEWS.d/next/Library/2025-05-19-20-29-35.gh-issue-133998.KmElUw.rst b/Misc/NEWS.d/next/Library/2025-05-19-20-29-35.gh-issue-133998.KmElUw.rst deleted file mode 100644 index 77d92628beefacd..000000000000000 --- a/Misc/NEWS.d/next/Library/2025-05-19-20-29-35.gh-issue-133998.KmElUw.rst +++ /dev/null @@ -1,5 +0,0 @@ -Fix :exc:`struct.error` exception when creating a file with -:class:`gzip.GzipFile` or compressing data with :func:`gzip.compress` -if the system time is outside the range 00:00:00 UTC, January 1, 1970 -through 06:28:15 UTC, February 7, 2106, or explicitly passed *mtime* -argument is outside the range ``0`` to ``2**32-1``. diff --git a/Misc/NEWS.d/next/Library/2025-05-19-21-08-25.gh-issue-134261.ravGYm.rst b/Misc/NEWS.d/next/Library/2025-05-19-21-08-25.gh-issue-134261.ravGYm.rst deleted file mode 100644 index bf552fee814acbf..000000000000000 --- a/Misc/NEWS.d/next/Library/2025-05-19-21-08-25.gh-issue-134261.ravGYm.rst +++ /dev/null @@ -1 +0,0 @@ -zip: On reproducible builds, ZipFile uses UTC instead of the local time when writing file datetimes to avoid underflows. diff --git a/Misc/NEWS.d/next/Library/2025-05-24-11-17-34.gh-issue-51067.yHOgfy.rst b/Misc/NEWS.d/next/Library/2025-05-24-11-17-34.gh-issue-51067.yHOgfy.rst deleted file mode 100644 index 204213c74de5dfd..000000000000000 --- a/Misc/NEWS.d/next/Library/2025-05-24-11-17-34.gh-issue-51067.yHOgfy.rst +++ /dev/null @@ -1 +0,0 @@ -Add :meth:`~zipfile.ZipFile.remove` and :meth:`~zipfile.ZipFile.repack` to :class:`~zipfile.ZipFile`. diff --git a/Misc/NEWS.d/next/Library/2025-08-30-07-44-30.gh-issue-86533.pathlib.rst b/Misc/NEWS.d/next/Library/2025-08-30-07-44-30.gh-issue-86533.pathlib.rst deleted file mode 100644 index 9c32671173e0ad2..000000000000000 --- a/Misc/NEWS.d/next/Library/2025-08-30-07-44-30.gh-issue-86533.pathlib.rst +++ /dev/null @@ -1,4 +0,0 @@ -The :func:`os.makedirs` function and :meth:`pathlib.Path.mkdir` method now have -a *parent_mode* parameter to specify the mode for intermediate directories when -creating parent directories. This allows one to match the behavior from Python -3.6 and earlier for :func:`os.makedirs`. diff --git a/Misc/NEWS.d/next/Library/2025-09-05-20-50-35.gh-issue-79638.Y-JfaH.rst b/Misc/NEWS.d/next/Library/2025-09-05-20-50-35.gh-issue-79638.Y-JfaH.rst deleted file mode 100644 index bd9fff0bc2e31b6..000000000000000 --- a/Misc/NEWS.d/next/Library/2025-09-05-20-50-35.gh-issue-79638.Y-JfaH.rst +++ /dev/null @@ -1,2 +0,0 @@ -Disallow all access in :mod:`urllib.robotparser` if the ``robots.txt`` file -is unreachable due to server or network errors. diff --git a/Misc/NEWS.d/next/Library/2025-10-09-12-13-29.gh-issue-139819.YxUDyH.rst b/Misc/NEWS.d/next/Library/2025-10-09-12-13-29.gh-issue-139819.YxUDyH.rst deleted file mode 100644 index ab3a8c6ed16ce4a..000000000000000 --- a/Misc/NEWS.d/next/Library/2025-10-09-12-13-29.gh-issue-139819.YxUDyH.rst +++ /dev/null @@ -1,3 +0,0 @@ -:mod:`rlcompleter`: Avoid suggesting attributes that are not accessible on -instances (e.g., Enum members showing ``__name__``). Patch by Peter -(ttw225). diff --git a/Misc/NEWS.d/next/Library/2025-10-12-08-46-26.gh-issue-139398.hESOMl.rst b/Misc/NEWS.d/next/Library/2025-10-12-08-46-26.gh-issue-139398.hESOMl.rst deleted file mode 100644 index 201b682d177c010..000000000000000 --- a/Misc/NEWS.d/next/Library/2025-10-12-08-46-26.gh-issue-139398.hESOMl.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add supported ``_sunder_`` names to the :func:`dir` method of the :mod:`enum` module -to support them in :term:`REPL` autocompletion. diff --git a/Misc/NEWS.d/next/Library/2025-10-20-09-12-18.gh-issue-140344.WjbYg-.rst b/Misc/NEWS.d/next/Library/2025-10-20-09-12-18.gh-issue-140344.WjbYg-.rst deleted file mode 100644 index ca3046941c6c93f..000000000000000 --- a/Misc/NEWS.d/next/Library/2025-10-20-09-12-18.gh-issue-140344.WjbYg-.rst +++ /dev/null @@ -1,11 +0,0 @@ -The classes ``ast.slice``, ``ast.ExtSlice``, ``ast.Index``, ``ast.Suite``, ``ast.AugLoad``, -``ast.AugStore``, and ``ast.Param``, deprecated since Python 3.9, now issue -deprecation warnings on use. They are now scheduled for removal in Python 3.21. - -The ``dims`` property of ``ast.Tuple`` objects, deprecated since Python 3.9, -now issues a deprecation warning when accessed. The property is scheduled for -removal in Python 3.21. Use the (non-deprecated) ``elts`` property of -``ast.Tuple`` objects instead. - -The deprecated global names are also no longer imported by -``from ast import *``. diff --git a/Misc/NEWS.d/next/Library/2025-11-02-05-28-56.gh-issue-115634.JbcNnF.rst b/Misc/NEWS.d/next/Library/2025-11-02-05-28-56.gh-issue-115634.JbcNnF.rst deleted file mode 100644 index f023ce999c60b7c..000000000000000 --- a/Misc/NEWS.d/next/Library/2025-11-02-05-28-56.gh-issue-115634.JbcNnF.rst +++ /dev/null @@ -1,5 +0,0 @@ -Fix a deadlock in :class:`concurrent.futures.ProcessPoolExecutor` when -using ``max_tasks_per_child``, present since the feature was introduced in -Python 3.11. The executor stopped scheduling queued tasks after a worker -process exited upon reaching its task limit. Based on a fix proposed by -Tabrez Mohammed. diff --git a/Misc/NEWS.d/next/Library/2025-11-02-22-24-13.gh-issue-140924.NQVbR_.rst b/Misc/NEWS.d/next/Library/2025-11-02-22-24-13.gh-issue-140924.NQVbR_.rst deleted file mode 100644 index 91c30c95469f089..000000000000000 --- a/Misc/NEWS.d/next/Library/2025-11-02-22-24-13.gh-issue-140924.NQVbR_.rst +++ /dev/null @@ -1,3 +0,0 @@ -Add :func:`locale.localize`, :func:`locale.delocalize` -and platform-specific locale constants -from the :mod:`!_locale` module to ``locale.__all__``. diff --git a/Misc/NEWS.d/next/Library/2025-11-08-13-22-33.gh-issue-140494.L_cKec.rst b/Misc/NEWS.d/next/Library/2025-11-08-13-22-33.gh-issue-140494.L_cKec.rst new file mode 100644 index 000000000000000..142cdac28f70f87 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-11-08-13-22-33.gh-issue-140494.L_cKec.rst @@ -0,0 +1,2 @@ +Require that Tcl is always built with thread support. +This requirement only affects Tcl 8.x, as Tcl 9.x is always thread-enabled. diff --git a/Misc/NEWS.d/next/Library/2025-12-14-06-44-34.gh-issue-81881.qancdQ.rst b/Misc/NEWS.d/next/Library/2025-12-14-06-44-34.gh-issue-81881.qancdQ.rst deleted file mode 100644 index 6b6ca6a1918bdd1..000000000000000 --- a/Misc/NEWS.d/next/Library/2025-12-14-06-44-34.gh-issue-81881.qancdQ.rst +++ /dev/null @@ -1 +0,0 @@ -:func:`shutil.copyfile` now raises :exc:`~shutil.SpecialFileError` for sockets and device files. diff --git a/Misc/NEWS.d/next/Library/2025-12-21-17-56-37.gh-issue-143008.aakErJ.rst b/Misc/NEWS.d/next/Library/2025-12-21-17-56-37.gh-issue-143008.aakErJ.rst deleted file mode 100644 index 907cdb770ab65f9..000000000000000 --- a/Misc/NEWS.d/next/Library/2025-12-21-17-56-37.gh-issue-143008.aakErJ.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix crash in :class:`io.TextIOWrapper` when reentrant -:meth:`io.TextIOBase.detach` is called reentrantly from the underlying buffer. diff --git a/Misc/NEWS.d/next/Library/2026-01-10-17-39-09.gh-issue-143663.9LEFAf.rst b/Misc/NEWS.d/next/Library/2026-01-10-17-39-09.gh-issue-143663.9LEFAf.rst new file mode 100644 index 000000000000000..8428770d51d734b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-01-10-17-39-09.gh-issue-143663.9LEFAf.rst @@ -0,0 +1,2 @@ +:meth:`tarfile.TarFile.extractall` now uses OS-specific separators to call +lstat. diff --git a/Misc/NEWS.d/next/Library/2026-01-18-06-42-47.gh-issue-143988.MtLtCP.rst b/Misc/NEWS.d/next/Library/2026-01-18-06-42-47.gh-issue-143988.MtLtCP.rst deleted file mode 100644 index fcc0cb54934b90e..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-18-06-42-47.gh-issue-143988.MtLtCP.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fixed crashes in :meth:`socket.socket.sendmsg` and :meth:`socket.socket.recvmsg_into` -that could occur if buffer sequences are concurrently mutated. diff --git a/Misc/NEWS.d/next/Library/2026-02-11-16-47-27.gh-issue-140729.2uTPQp.rst b/Misc/NEWS.d/next/Library/2026-02-11-16-47-27.gh-issue-140729.2uTPQp.rst deleted file mode 100644 index 49c9adc4679abbf..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-02-11-16-47-27.gh-issue-140729.2uTPQp.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a pickling error in the ``cProfile`` module when profiling a script that -uses :class:`multiprocessing.Process` with the ``spawn`` and ``forkserver`` -start methods. diff --git a/Misc/NEWS.d/next/Library/2026-03-26-00-00-00.gh-issue-47005.xxc89c.rst b/Misc/NEWS.d/next/Library/2026-03-26-00-00-00.gh-issue-47005.xxc89c.rst deleted file mode 100644 index 646367f0fa069d3..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-03-26-00-00-00.gh-issue-47005.xxc89c.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix :meth:`!urllib.request.AbstractHTTPHandler.do_open` to give regular -headers set via :meth:`~urllib.request.Request.add_header` priority over -unredirected headers, consistent with :meth:`~urllib.request.Request.get_header` -and :meth:`~urllib.request.Request.header_items`. diff --git a/Misc/NEWS.d/next/Library/2026-03-26-09-30-00.gh-issue-146452.Y2N6qZ8J.rst b/Misc/NEWS.d/next/Library/2026-03-26-09-30-00.gh-issue-146452.Y2N6qZ8J.rst deleted file mode 100644 index 99f3cce33497a12..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-03-26-09-30-00.gh-issue-146452.Y2N6qZ8J.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix segfault in :mod:`pickle` when pickling a dictionary concurrently -mutated by another thread in the free-threaded build. diff --git a/Misc/NEWS.d/next/Library/2026-04-20-01-24-22.gh-issue-92455.vXhmad.rst b/Misc/NEWS.d/next/Library/2026-04-20-01-24-22.gh-issue-92455.vXhmad.rst deleted file mode 100644 index 8d2a11cb7761377..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-04-20-01-24-22.gh-issue-92455.vXhmad.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix :mod:`mimetypes` to prefer case-sensitive matches for suffix mappings and -MIME type suffixes before falling back to case-insensitive matches. -Contributed by Xiao Yuan. diff --git a/Misc/NEWS.d/next/Library/2026-04-21-06-30-59.gh-issue-119670.pMWZfY.rst b/Misc/NEWS.d/next/Library/2026-04-21-06-30-59.gh-issue-119670.pMWZfY.rst deleted file mode 100644 index fc1941be4dc7925..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-04-21-06-30-59.gh-issue-119670.pMWZfY.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add keyword-only parameter *force* to :func:`shlex.quote` to force quoting -a string, even if it is already safe for a shell without being quoted. diff --git a/Misc/NEWS.d/next/Library/2026-04-23-12-50-15.gh-issue-148441.zvpCkR.rst b/Misc/NEWS.d/next/Library/2026-04-23-12-50-15.gh-issue-148441.zvpCkR.rst deleted file mode 100644 index 762815270e4d403..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-04-23-12-50-15.gh-issue-148441.zvpCkR.rst +++ /dev/null @@ -1,4 +0,0 @@ -:mod:`xml.parsers.expat`: prevent a crash in -:meth:`~xml.parsers.expat.xmlparser.CharacterDataHandler` -when the character data size exceeds the parser's -:attr:`buffer size `. diff --git a/Misc/NEWS.d/next/Library/2026-04-24-19-54-00.gh-issue-148954.v1.rst b/Misc/NEWS.d/next/Library/2026-04-24-19-54-00.gh-issue-148954.v1.rst deleted file mode 100644 index 6245af7e362e920..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-04-24-19-54-00.gh-issue-148954.v1.rst +++ /dev/null @@ -1 +0,0 @@ -Fix XML injection vulnerability in :func:`xmlrpc.client.dumps` where the ``methodname`` was not being escaped before interpolation into the XML body. diff --git a/Misc/NEWS.d/next/Library/2026-04-26-11-25-38.gh-issue-118158.xIy05H.rst b/Misc/NEWS.d/next/Library/2026-04-26-11-25-38.gh-issue-118158.xIy05H.rst deleted file mode 100644 index bd22871c1c0c172..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-04-26-11-25-38.gh-issue-118158.xIy05H.rst +++ /dev/null @@ -1 +0,0 @@ -Ensure py_compile CLI error messages end with a newline. Contributed by Xiao Yuan. diff --git a/Misc/NEWS.d/next/Library/2026-04-27-11-12-00.gh-issue-149046.74shDd.rst b/Misc/NEWS.d/next/Library/2026-04-27-11-12-00.gh-issue-149046.74shDd.rst deleted file mode 100644 index b05c4222e30fcd2..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-04-27-11-12-00.gh-issue-149046.74shDd.rst +++ /dev/null @@ -1,2 +0,0 @@ -:mod:`io`: Fix :class:`io.StringIO` serialization: no longer call ``str(obj)`` on :class:`str` -subclasses. Patch by Thomas Kowalski. diff --git a/Misc/NEWS.d/next/Library/2026-04-29-08-10-17.gh-issue-149056.jnaD4W.rst b/Misc/NEWS.d/next/Library/2026-04-29-08-10-17.gh-issue-149056.jnaD4W.rst deleted file mode 100644 index 0026d02c8762570..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-04-29-08-10-17.gh-issue-149056.jnaD4W.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix :func:`json.load` not forwarding the *array_hook* argument to -:func:`json.loads`. Patch by Thomas Kowalski. diff --git a/Misc/NEWS.d/next/Library/2026-05-06-20-10-44.gh-issue-149464.3mPhcr.rst b/Misc/NEWS.d/next/Library/2026-05-06-20-10-44.gh-issue-149464.3mPhcr.rst deleted file mode 100644 index 9f987d2a662d8fb..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-06-20-10-44.gh-issue-149464.3mPhcr.rst +++ /dev/null @@ -1,3 +0,0 @@ -Add :func:`os.pidfd_getfd` for duplicating a file descriptor from another -process via a pidfd. Available on Linux 5.6+. Patch by Maurycy -Pawłowski-Wieroński. diff --git a/Misc/NEWS.d/next/Library/2026-05-07-14-18-47.gh-issue-149489.bX9iHe.rst b/Misc/NEWS.d/next/Library/2026-05-07-14-18-47.gh-issue-149489.bX9iHe.rst deleted file mode 100644 index 1550c893fd7c45b..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-07-14-18-47.gh-issue-149489.bX9iHe.rst +++ /dev/null @@ -1,5 +0,0 @@ -Fix :mod:`~xml.etree.ElementTree` serialization to HTML. The content of -comments, processing instructions and elements "xmp", "iframe", "noembed", -"noframes", and "plaintext" is no longer escaped. The "plaintext" element no -longer have the closing tag. Add support of empty attributes (with value -``None``). diff --git a/Misc/NEWS.d/next/Library/2026-05-07-17-35-47.gh-issue-149499.G2ER-R.rst b/Misc/NEWS.d/next/Library/2026-05-07-17-35-47.gh-issue-149499.G2ER-R.rst deleted file mode 100644 index 796d39f5ba05bf1..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-07-17-35-47.gh-issue-149499.G2ER-R.rst +++ /dev/null @@ -1,3 +0,0 @@ -Removed the :func:`!sysconfig.expand_makefile_vars` function which has been -deprecated since Python 3.14. Use the ``vars`` argument of -:func:`sysconfig.get_paths` instead. diff --git a/Misc/NEWS.d/next/Library/2026-05-07-21-58-17.gh-issue-149388.DDBPeA.rst b/Misc/NEWS.d/next/Library/2026-05-07-21-58-17.gh-issue-149388.DDBPeA.rst deleted file mode 100644 index 4a1c6f3f5b4e579..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-07-21-58-17.gh-issue-149388.DDBPeA.rst +++ /dev/null @@ -1 +0,0 @@ -Make :class:`!asyncio.windows_utils.PipeHandle` closing idempotent. diff --git a/Misc/NEWS.d/next/Library/2026-05-08-06-12-26.gh-issue-149528.AxdDxa.rst b/Misc/NEWS.d/next/Library/2026-05-08-06-12-26.gh-issue-149528.AxdDxa.rst deleted file mode 100644 index b2c6e427a1c592f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-08-06-12-26.gh-issue-149528.AxdDxa.rst +++ /dev/null @@ -1 +0,0 @@ -Remove ``annotationlib.ForwardRef._evaludate`` deprecated method. diff --git a/Misc/NEWS.d/next/Library/2026-05-08-06-56-57.gh-issue-149530.cl2AJ8.rst b/Misc/NEWS.d/next/Library/2026-05-08-06-56-57.gh-issue-149530.cl2AJ8.rst deleted file mode 100644 index 2b74e8cdadd03c3..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-08-06-56-57.gh-issue-149530.cl2AJ8.rst +++ /dev/null @@ -1,2 +0,0 @@ -Removed :meth:`!symtable.Class.get_methods` which has been deprecated since -3.14. diff --git a/Misc/NEWS.d/next/Library/2026-05-08-07-51-54.gh-issue-80480.nnA4p1.rst b/Misc/NEWS.d/next/Library/2026-05-08-07-51-54.gh-issue-80480.nnA4p1.rst deleted file mode 100644 index 2f7f15b169b26b5..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-08-07-51-54.gh-issue-80480.nnA4p1.rst +++ /dev/null @@ -1,2 +0,0 @@ -Remove deprecated ``'u'`` type code (:c:type:`wchar_t`) for the :mod:`array` -module. Use ``'w'`` format code instead (:c:type:`Py_UCS4`, always 4 bytes). diff --git a/Misc/NEWS.d/next/Library/2026-05-08-08-24-01.gh-issue-149537.hVFVnt.rst b/Misc/NEWS.d/next/Library/2026-05-08-08-24-01.gh-issue-149537.hVFVnt.rst deleted file mode 100644 index 2fb0359a2ea8936..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-08-08-24-01.gh-issue-149537.hVFVnt.rst +++ /dev/null @@ -1,2 +0,0 @@ -Remove kw parameters from python version of :func:`functools.reduce` -function. diff --git a/Misc/NEWS.d/next/Library/2026-05-08-09-11-48.gh-issue-149534.Tw7eeY.rst b/Misc/NEWS.d/next/Library/2026-05-08-09-11-48.gh-issue-149534.Tw7eeY.rst deleted file mode 100644 index 0938935a75d8c16..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-08-09-11-48.gh-issue-149534.Tw7eeY.rst +++ /dev/null @@ -1 +0,0 @@ -Fix merging of :class:`collections.defaultdict` and :class:`frozendict`. diff --git a/Misc/NEWS.d/next/Library/2026-05-08-14-24-16.gh-issue-149436.dEV02X.rst b/Misc/NEWS.d/next/Library/2026-05-08-14-24-16.gh-issue-149436.dEV02X.rst deleted file mode 100644 index 401cf044e1514fb..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-08-14-24-16.gh-issue-149436.dEV02X.rst +++ /dev/null @@ -1 +0,0 @@ -Improve performance of :meth:`inspect.getattr_static`. diff --git a/Misc/NEWS.d/next/Library/2026-05-08-15-08-35.gh-issue-112821.t9T1YD.rst b/Misc/NEWS.d/next/Library/2026-05-08-15-08-35.gh-issue-112821.t9T1YD.rst deleted file mode 100644 index cfbcde81493e221..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-08-15-08-35.gh-issue-112821.t9T1YD.rst +++ /dev/null @@ -1,4 +0,0 @@ -In the REPL, autocompletion might run arbitrary code in the getter of a -descriptor. If that getter raised an exception, autocompletion would fail to -present any options for the entire object. Autocompletion now works as -expected for these objects. diff --git a/Misc/NEWS.d/next/Library/2026-05-08-16-44-20.gh-issue-149567.iiZKEj.rst b/Misc/NEWS.d/next/Library/2026-05-08-16-44-20.gh-issue-149567.iiZKEj.rst deleted file mode 100644 index e30563df79b3bcf..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-08-16-44-20.gh-issue-149567.iiZKEj.rst +++ /dev/null @@ -1,2 +0,0 @@ -Remove the :exc:`!shutil.ExecError` exception which has been deprecated -since Python 3.14. diff --git a/Misc/NEWS.d/next/Library/2026-05-09-11-22-29.gh-issue-149595.1nuYXw.rst b/Misc/NEWS.d/next/Library/2026-05-09-11-22-29.gh-issue-149595.1nuYXw.rst deleted file mode 100644 index f3971554de37487..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-09-11-22-29.gh-issue-149595.1nuYXw.rst +++ /dev/null @@ -1,2 +0,0 @@ -Remove the :func:`!sys._enablelegacywindowsfsencoding` function which has -been deprecated since Python 3.13. diff --git a/Misc/NEWS.d/next/Library/2026-05-09-15-17-59.gh-issue-149598.aLrXRw.rst b/Misc/NEWS.d/next/Library/2026-05-09-15-17-59.gh-issue-149598.aLrXRw.rst deleted file mode 100644 index 8c06ba5e7d5e4e6..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-09-15-17-59.gh-issue-149598.aLrXRw.rst +++ /dev/null @@ -1 +0,0 @@ -Remove support of deprecated *strm* argument for :mod:`logging` handlers. diff --git a/Misc/NEWS.d/next/Library/2026-05-09-15-42-54.gh-issue-149600.ZbL-iv.rst b/Misc/NEWS.d/next/Library/2026-05-09-15-42-54.gh-issue-149600.ZbL-iv.rst deleted file mode 100644 index 732787dc92c1090..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-09-15-42-54.gh-issue-149600.ZbL-iv.rst +++ /dev/null @@ -1 +0,0 @@ -Remove deprecated :func:`!asyncio.iscoroutinefunction` function. diff --git a/Misc/NEWS.d/next/Library/2026-05-09-21-02-08.gh-issue-149614.U4snj3.rst b/Misc/NEWS.d/next/Library/2026-05-09-21-02-08.gh-issue-149614.U4snj3.rst deleted file mode 100644 index 5169c6c203fc1b3..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-09-21-02-08.gh-issue-149614.U4snj3.rst +++ /dev/null @@ -1 +0,0 @@ -Fix a regression that broke the ability to deepcopy :class:`argparse.ArgumentParser` instances. diff --git a/Misc/NEWS.d/next/Library/2026-05-10-07-21-51.gh-issue-139489.rS7LTA.rst b/Misc/NEWS.d/next/Library/2026-05-10-07-21-51.gh-issue-139489.rS7LTA.rst deleted file mode 100644 index 40fe7e9fd6a0086..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-10-07-21-51.gh-issue-139489.rS7LTA.rst +++ /dev/null @@ -1 +0,0 @@ -Add :func:`xml.is_valid_text` to ``xml.__all__``. diff --git a/Misc/NEWS.d/next/Library/2026-05-10-14-10-00.gh-issue-149634.iT5cwC.rst b/Misc/NEWS.d/next/Library/2026-05-10-14-10-00.gh-issue-149634.iT5cwC.rst deleted file mode 100644 index 73e8d73c36891ab..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-10-14-10-00.gh-issue-149634.iT5cwC.rst +++ /dev/null @@ -1 +0,0 @@ -Remove deprecated and unused :attr:`!tarfile.TarInfo.tarfile` attribute. diff --git a/Misc/NEWS.d/next/Library/2026-05-10-16-06-27.gh-issue-149609.yLKPXo.rst b/Misc/NEWS.d/next/Library/2026-05-10-16-06-27.gh-issue-149609.yLKPXo.rst deleted file mode 100644 index 3acba7d25021b28..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-10-16-06-27.gh-issue-149609.yLKPXo.rst +++ /dev/null @@ -1,3 +0,0 @@ -Raise :exc:`DeprecationWarning` on using :class:`abc.abstractclassmethod`, -:class:`abc.abstractstaticmethod`, and :class:`abc.abstractproperty`, -schedule its removal for Python 3.21. diff --git a/Misc/NEWS.d/next/Library/2026-05-10-19-26-50.gh-issue-149584.x7Qm9A.rst b/Misc/NEWS.d/next/Library/2026-05-10-19-26-50.gh-issue-149584.x7Qm9A.rst deleted file mode 100644 index 6734250fdd6af3c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-10-19-26-50.gh-issue-149584.x7Qm9A.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix excessive overhead in the Tachyon profiler when inspecting a remote -process by avoiding repeated remote page-cache scans, batching predicted -remote reads, and reusing cached profiler result objects. Patch by Pablo -Galindo and Maurycy Pawłowski-Wieroński. diff --git a/Misc/NEWS.d/next/Library/2026-05-10-23-51-23.gh-issue-149504.pDSCbn.rst b/Misc/NEWS.d/next/Library/2026-05-10-23-51-23.gh-issue-149504.pDSCbn.rst deleted file mode 100644 index 88bf268123bbecc..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-10-23-51-23.gh-issue-149504.pDSCbn.rst +++ /dev/null @@ -1,5 +0,0 @@ -Fix :func:`site.addsitedir` to allow re-entrant calls from within startup -files. Previously, a ``.pth`` file containing an ``import`` line that -called :func:`site.addsitedir` (or a ``.start`` entry point doing the same) -could crash with ``RuntimeError: dictionary changed size during iteration`` -during site initialization, breaking tools such as ``uv run --with``. diff --git a/Misc/NEWS.d/next/Library/2026-05-12-06-24-54.gh-issue-149701.8v9RTm.rst b/Misc/NEWS.d/next/Library/2026-05-12-06-24-54.gh-issue-149701.8v9RTm.rst deleted file mode 100644 index 676d788cbce62a3..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-12-06-24-54.gh-issue-149701.8v9RTm.rst +++ /dev/null @@ -1 +0,0 @@ -Fix bad return code from Lib/venv/bin/activate if hashing is disabled diff --git a/Misc/NEWS.d/next/Library/2026-05-12-13-03-45.gh-issue-149718.SaM1NJ.rst b/Misc/NEWS.d/next/Library/2026-05-12-13-03-45.gh-issue-149718.SaM1NJ.rst deleted file mode 100644 index 25344e5a90f022c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-12-13-03-45.gh-issue-149718.SaM1NJ.rst +++ /dev/null @@ -1,4 +0,0 @@ -Coalesce consecutive identical stack frames in Tachyon, so aggregating -collectors (pstats, collapsed, flamegraph, gecko) receive one collect. -Improves sample rate 3x, error rate and missed rate drop by 70%. Patch by -Maurycy Pawłowski-Wieroński. diff --git a/Misc/NEWS.d/next/Library/2026-05-12-14-44-39.gh-issue-149720.ccsoW-.rst b/Misc/NEWS.d/next/Library/2026-05-12-14-44-39.gh-issue-149720.ccsoW-.rst deleted file mode 100644 index f16d8770d740f49..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-12-14-44-39.gh-issue-149720.ccsoW-.rst +++ /dev/null @@ -1 +0,0 @@ -Remove support for undotted *ext* in :meth:`mimetypes.MimeTypes.add_type`. diff --git a/Misc/NEWS.d/next/Library/2026-05-13-12-16-54.gh-issue-149473.nOQZqn.rst b/Misc/NEWS.d/next/Library/2026-05-13-12-16-54.gh-issue-149473.nOQZqn.rst deleted file mode 100644 index db624aba31a9de0..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-13-12-16-54.gh-issue-149473.nOQZqn.rst +++ /dev/null @@ -1,2 +0,0 @@ -Calling ``os.environ.clear()`` now emits ``os._clearenv`` auditing event. -Patch by Victor Stinner. diff --git a/Misc/NEWS.d/next/Library/2026-05-13-23-18-39.gh-issue-149801.S_FfGr.rst b/Misc/NEWS.d/next/Library/2026-05-13-23-18-39.gh-issue-149801.S_FfGr.rst deleted file mode 100644 index f9e8538527d204e..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-13-23-18-39.gh-issue-149801.S_FfGr.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add IANA registered names and aliases with leading zeros before number (like -IBM00858, CP00858, IBM01140, CP01140) for corresponding codecs. diff --git a/Misc/NEWS.d/next/Library/2026-05-14-15-55-28.gh-issue-149816.ZaXQ0q.rst b/Misc/NEWS.d/next/Library/2026-05-14-15-55-28.gh-issue-149816.ZaXQ0q.rst deleted file mode 100644 index 3ea70071ec3c75d..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-14-15-55-28.gh-issue-149816.ZaXQ0q.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a race condition in ``_random.Random.__init__`` method in free-threading -mode. diff --git a/Misc/NEWS.d/next/Library/2026-05-14-17-01-19.gh-issue-62259.ytlFD5.rst b/Misc/NEWS.d/next/Library/2026-05-14-17-01-19.gh-issue-62259.ytlFD5.rst deleted file mode 100644 index d0af77366378b88..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-14-17-01-19.gh-issue-62259.ytlFD5.rst +++ /dev/null @@ -1,9 +0,0 @@ -Add support for multiple multi-byte encodings in the :mod:`XML parser -`: "cp932", "cp949", "cp950", "Big5","EUC-JP", "GB2312", -"GBK", "johab", and "Shift_JIS". Add partial support (only BMP characters) -for multi-byte encodings "Big5-HKSCS", "EUC_JIS-2004", "EUC_JISX0213", -"Shift_JIS-2004", "Shift_JISX0213", "utf-8-sig" and non-standard aliases -like "UTF8" (without hyphen). The parser now raises :exc:`ValueError` for -known unsupported multi-byte encodings such us "ISO-2022-JP" or -"raw-unicode-escape" instead of failing later, when encounter non-ASCII -data. diff --git a/Misc/NEWS.d/next/Library/2026-05-15-16-28-00.gh-issue-149819.fixpth.rst b/Misc/NEWS.d/next/Library/2026-05-15-16-28-00.gh-issue-149819.fixpth.rst deleted file mode 100644 index 66e6da0ecf0d87c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-15-16-28-00.gh-issue-149819.fixpth.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix regression in :func:`site.addsitedir` where ``.pth`` files were no -longer processed in Python subprocesses. This happened because -:func:`site.main` seeded ``known_paths`` with entries inherited from -the parent process, causing ``addsitedir`` to skip ``.pth`` processing. diff --git a/Misc/NEWS.d/next/Library/2026-05-15-18-44-20.gh-issue-142349.fHK3v1.rst b/Misc/NEWS.d/next/Library/2026-05-15-18-44-20.gh-issue-142349.fHK3v1.rst deleted file mode 100644 index fa667c4110941e9..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-15-18-44-20.gh-issue-142349.fHK3v1.rst +++ /dev/null @@ -1 +0,0 @@ -Add :keyword:`lazy` to the list of support topic by :func:`help`. diff --git a/Misc/NEWS.d/next/Library/2026-05-15-19-52-41.gh-issue-149891.BJUIGB.rst b/Misc/NEWS.d/next/Library/2026-05-15-19-52-41.gh-issue-149891.BJUIGB.rst deleted file mode 100644 index f8bc28659533af8..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-15-19-52-41.gh-issue-149891.BJUIGB.rst +++ /dev/null @@ -1 +0,0 @@ -Add support for more encoding aliases `officially registered in IANA `__. diff --git a/Misc/NEWS.d/next/Library/2026-05-16-21-08-33.gh-issue-149921.I1yNML.rst b/Misc/NEWS.d/next/Library/2026-05-16-21-08-33.gh-issue-149921.I1yNML.rst deleted file mode 100644 index 113bd1a802f7990..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-16-21-08-33.gh-issue-149921.I1yNML.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix reference leaks in error paths of the :mod:`!_interpchannels` and -:mod:`!_interpqueues` extension modules. diff --git a/Misc/NEWS.d/next/Library/2026-05-16-22-00-00.gh-issue-146406.10e0da.rst b/Misc/NEWS.d/next/Library/2026-05-16-22-00-00.gh-issue-146406.10e0da.rst deleted file mode 100644 index 8f65fecd85dbf4c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-16-22-00-00.gh-issue-146406.10e0da.rst +++ /dev/null @@ -1,3 +0,0 @@ -Add cross-language hints for ``.clear()`` on :class:`tuple`, -:class:`frozenset`, and :class:`frozendict`, suggesting the mutable -counterpart. Follow-up to :gh:`146406`. diff --git a/Misc/NEWS.d/next/Library/2026-05-17-02-25-56.gh-issue-149571.LNyuWJ.rst b/Misc/NEWS.d/next/Library/2026-05-17-02-25-56.gh-issue-149571.LNyuWJ.rst deleted file mode 100644 index 2b71d9cf2200be4..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-17-02-25-56.gh-issue-149571.LNyuWJ.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix the C implementation of :meth:`xml.etree.ElementTree.Element.itertext`: -it no longer emits text for comments and processing instructions. diff --git a/Misc/NEWS.d/next/Library/2026-05-17-12-37-59.gh-issue-53144.c5tr1p.rst b/Misc/NEWS.d/next/Library/2026-05-17-12-37-59.gh-issue-53144.c5tr1p.rst deleted file mode 100644 index 283a5ba44d1f19f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-17-12-37-59.gh-issue-53144.c5tr1p.rst +++ /dev/null @@ -1,2 +0,0 @@ -The :mod:`email` package now supports all aliases of Python codecs and uses -MIME/IANA names for all IANA registered charsets. diff --git a/Misc/NEWS.d/next/Library/2026-05-17-22-37-02.gh-issue-88726.BAoL6j.rst b/Misc/NEWS.d/next/Library/2026-05-17-22-37-02.gh-issue-88726.BAoL6j.rst deleted file mode 100644 index ba9058d79c9873a..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-17-22-37-02.gh-issue-88726.BAoL6j.rst +++ /dev/null @@ -1,2 +0,0 @@ -The :mod:`email` package now uses standard MIME charset names "gb2312" and -"big5" instead of non-standard names "eucgb2312_cn" and "big5_tw". diff --git a/Misc/NEWS.d/next/Library/2026-05-18-07-44-46.gh-issue-149995.vvtFHn.rst b/Misc/NEWS.d/next/Library/2026-05-18-07-44-46.gh-issue-149995.vvtFHn.rst deleted file mode 100644 index a8e412b578da378..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-18-07-44-46.gh-issue-149995.vvtFHn.rst +++ /dev/null @@ -1 +0,0 @@ -Update various docstrings in :mod:`typing`. diff --git a/Misc/NEWS.d/next/Library/2026-05-18-12-42-31.gh-issue-149816.F98iME.rst b/Misc/NEWS.d/next/Library/2026-05-18-12-42-31.gh-issue-149816.F98iME.rst deleted file mode 100644 index 21e3ae0df57621c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-18-12-42-31.gh-issue-149816.F98iME.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a potential use after free condition in :func:`pickle.dumps` in free-threaded -mode when serializing lists. diff --git a/Misc/NEWS.d/next/Library/2026-05-18-13-43-06.gh-issue-79413.OpTXbV.rst b/Misc/NEWS.d/next/Library/2026-05-18-13-43-06.gh-issue-79413.OpTXbV.rst deleted file mode 100644 index 8d62fda8b2b67f4..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-18-13-43-06.gh-issue-79413.OpTXbV.rst +++ /dev/null @@ -1,3 +0,0 @@ -Update :func:`dataclasses.make_dataclass` to add a *qualname* parameter. The -*qualname* parameter will be used to set the :attr:`!__qualname__` of the -created ``dataclass``. diff --git a/Misc/NEWS.d/next/Library/2026-05-18-17-17-20.gh-issue-149189.a8IooK.rst b/Misc/NEWS.d/next/Library/2026-05-18-17-17-20.gh-issue-149189.a8IooK.rst deleted file mode 100644 index bad027f2c71c6fd..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-18-17-17-20.gh-issue-149189.a8IooK.rst +++ /dev/null @@ -1 +0,0 @@ -Revert the changes to :mod:`pprint` defaults. Patch by Hugo van Kemenade. diff --git a/Misc/NEWS.d/next/Library/2026-05-18-22-45-54.gh-issue-149816.T68vc_.rst b/Misc/NEWS.d/next/Library/2026-05-18-22-45-54.gh-issue-149816.T68vc_.rst deleted file mode 100644 index 9996cc7ec0e8664..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-18-22-45-54.gh-issue-149816.T68vc_.rst +++ /dev/null @@ -1 +0,0 @@ -Fix race condition in :attr:`ssl.SSLContext.sni_callback` diff --git a/Misc/NEWS.d/next/Library/2026-05-19-11-42-37.gh-issue-127949.Ab3kZq.rst b/Misc/NEWS.d/next/Library/2026-05-19-11-42-37.gh-issue-127949.Ab3kZq.rst deleted file mode 100644 index c295d5fffd82fcf..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-19-11-42-37.gh-issue-127949.Ab3kZq.rst +++ /dev/null @@ -1 +0,0 @@ -Remove the deprecated :mod:`asyncio` event loop policy system. Patch by Kumar Aditya. diff --git a/Misc/NEWS.d/next/Library/2026-05-19-12-00-00.gh-issue-149980.Kx7p2A.rst b/Misc/NEWS.d/next/Library/2026-05-19-12-00-00.gh-issue-149980.Kx7p2A.rst deleted file mode 100644 index b056f6a3cda25d3..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-19-12-00-00.gh-issue-149980.Kx7p2A.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix :mod:`tarfile` so that GNU long-name directory entries have all -trailing slashes stripped from their names, matching the behavior for -short-name entries. Previously, only a single trailing slash was removed. diff --git a/Misc/NEWS.d/next/Library/2026-05-19-18-25-00.gh-issue-150077.zstopen-close.rst b/Misc/NEWS.d/next/Library/2026-05-19-18-25-00.gh-issue-150077.zstopen-close.rst deleted file mode 100644 index 06d20e41e25037a..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-19-18-25-00.gh-issue-150077.zstopen-close.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix ``tarfile.TarFile.zstopen`` to close the underlying zstd file object -when opening the tar archive is interrupted by a :exc:`BaseException` -subclass such as :exc:`KeyboardInterrupt`. diff --git a/Misc/NEWS.d/next/Library/2026-05-19-19-00-49.gh-issue-84353.ZU5zaQ.rst b/Misc/NEWS.d/next/Library/2026-05-19-19-00-49.gh-issue-84353.ZU5zaQ.rst deleted file mode 100644 index 84fb12e2abd81a0..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-19-19-00-49.gh-issue-84353.ZU5zaQ.rst +++ /dev/null @@ -1,5 +0,0 @@ -Preserve non-UTF-8 encoded filenames when appending to a -:class:`zipfile.ZipFile`. Previously, non-ASCII names stored in a legacy -encoding (without the UTF-8 flag bit set) could be corrupted when the -central directory was rewritten: they were decoded as cp437 and then -re-stored as UTF-8. diff --git a/Misc/NEWS.d/next/Library/2026-05-21-11-25-58.gh-issue-150175.8H4Caz.rst b/Misc/NEWS.d/next/Library/2026-05-21-11-25-58.gh-issue-150175.8H4Caz.rst deleted file mode 100644 index 80fc80d4d50a636..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-21-11-25-58.gh-issue-150175.8H4Caz.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix race condition in :class:`unittest.mock.ThreadingMock` where -concurrent calls could lose increments to ``call_count`` and other -attributes due to a missing lock in ``_increment_mock_call``. diff --git a/Misc/NEWS.d/next/Library/2026-05-21-20-47-45.gh-issue-150157.ZvmO-bQZ.rst b/Misc/NEWS.d/next/Library/2026-05-21-20-47-45.gh-issue-150157.ZvmO-bQZ.rst deleted file mode 100644 index 3a12e26cf736f79..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-21-20-47-45.gh-issue-150157.ZvmO-bQZ.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a crash in free-threaded builds that occurs when pickling by name -objects without a ``__module__`` attribute while :data:`sys.modules` -is concurrently being modified. diff --git a/Misc/NEWS.d/next/Library/2026-05-22-15-30-00.gh-issue-132372.YP4a6x.rst b/Misc/NEWS.d/next/Library/2026-05-22-15-30-00.gh-issue-132372.YP4a6x.rst deleted file mode 100644 index bcd96e88eac1bfd..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-22-15-30-00.gh-issue-132372.YP4a6x.rst +++ /dev/null @@ -1,2 +0,0 @@ -Speed up :func:`logging.config.fileConfig` and -:func:`logging.config.dictConfig` when handling many existing loggers. diff --git a/Misc/NEWS.d/next/Library/2026-05-25-07-22-05.gh-issue-150372.9hLqhe.rst b/Misc/NEWS.d/next/Library/2026-05-25-07-22-05.gh-issue-150372.9hLqhe.rst deleted file mode 100644 index 7b83bd8fe73f11d..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-25-07-22-05.gh-issue-150372.9hLqhe.rst +++ /dev/null @@ -1,2 +0,0 @@ -:mod:`readline`: Fix a potential crash during tab completion caused by an -out-of-memory error during module initialization. diff --git a/Misc/NEWS.d/next/Library/2026-05-25-17-00-00.gh-issue-150406.jF3g63.rst b/Misc/NEWS.d/next/Library/2026-05-25-17-00-00.gh-issue-150406.jF3g63.rst deleted file mode 100644 index 230e961abd3f588..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-25-17-00-00.gh-issue-150406.jF3g63.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a possible crash occurring during :mod:`socket` module initialization -when the system is out of memory on platforms without a reentrant -``gethostbyname``. diff --git a/Misc/NEWS.d/next/Library/2026-05-26-19-30-00.gh-issue-150479.Kq7Lm2.rst b/Misc/NEWS.d/next/Library/2026-05-26-19-30-00.gh-issue-150479.Kq7Lm2.rst deleted file mode 100644 index 5a41273f3501e39..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-26-19-30-00.gh-issue-150479.Kq7Lm2.rst +++ /dev/null @@ -1,4 +0,0 @@ -:func:`email.utils.formataddr` now raises :exc:`ValueError` when the name or -address contains a carriage return or line feed, matching -:class:`email.headerregistry.Address`. This check can be disabled by passing -``strict=False``. diff --git a/Misc/NEWS.d/next/Library/2026-05-27-11-18-36.gh-issue-150228.pNPiO-.rst b/Misc/NEWS.d/next/Library/2026-05-27-11-18-36.gh-issue-150228.pNPiO-.rst deleted file mode 100644 index 8c03989e90b2401..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-27-11-18-36.gh-issue-150228.pNPiO-.rst +++ /dev/null @@ -1,11 +0,0 @@ -The new :class:`site.StartupState` class lets callers batch-process -:pep:`829` startup configuration files across multiple site directories -before any startup code runs, with public -:meth:`~site.StartupState.addsitedir`, -:meth:`~site.StartupState.addusersitepackages`, -:meth:`~site.StartupState.addsitepackages`, and -:meth:`~site.StartupState.process` methods. The signature of -:func:`site.addsitedir` is unchanged from Python 3.14. The -:data:`!defer_processing_start_files` argument and the -``process_startup_files()`` function added earlier in the 3.15 cycle have -been removed; use :class:`!site.StartupState` instead. diff --git a/Misc/NEWS.d/next/Library/2026-05-27-15-51-29.gh-issue-150534.3Nan6S.rst b/Misc/NEWS.d/next/Library/2026-05-27-15-51-29.gh-issue-150534.3Nan6S.rst deleted file mode 100644 index 2ead9990513015f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-27-15-51-29.gh-issue-150534.3Nan6S.rst +++ /dev/null @@ -1,6 +0,0 @@ -Added trigonometric functions that work in units of half turns, rather than -radians. The new functions :func:`math.acospi`, :func:`math.asinpi`, -:func:`math.atanpi`, and :func:`math.atan2pi` return half-turn angles. The -new functions :func:`math.cospi`, :func:`math.sinpi`, and :func:`math.tanpi` -take half-turn angle arguments. These functions are recommended by IEEE -754-2019 and standardized in C23. diff --git a/Misc/NEWS.d/next/Library/2026-05-27-23-47-31.gh-issue-148932.Y1xmvA.rst b/Misc/NEWS.d/next/Library/2026-05-27-23-47-31.gh-issue-148932.Y1xmvA.rst deleted file mode 100644 index a0b7a9740cd518d..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-27-23-47-31.gh-issue-148932.Y1xmvA.rst +++ /dev/null @@ -1 +0,0 @@ -Fix ``profiling.sampling`` on Windows virtual environments to resolve the actual Python PID from a virtual environment shim. diff --git a/Misc/NEWS.d/next/Library/2026-05-28-23-38-46.gh-issue-150478.qEr0E-.rst b/Misc/NEWS.d/next/Library/2026-05-28-23-38-46.gh-issue-150478.qEr0E-.rst deleted file mode 100644 index 0ceae5e313977a4..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-28-23-38-46.gh-issue-150478.qEr0E-.rst +++ /dev/null @@ -1,3 +0,0 @@ -Add ``show_jit`` option to ``dis.dis`` to show JIT entry points in the -bytecode. This is useful for visualizing where JIT traces are entered from -the interpreter. diff --git a/Misc/NEWS.d/next/Library/2026-05-31-10-00-00.gh-issue-150942.Tk9aRef.rst b/Misc/NEWS.d/next/Library/2026-05-31-10-00-00.gh-issue-150942.Tk9aRef.rst deleted file mode 100644 index ba0de8fd434d303..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-31-10-00-00.gh-issue-150942.Tk9aRef.rst +++ /dev/null @@ -1,3 +0,0 @@ -Speed up :func:`json.loads` decoding of arrays and objects by storing -parsed values into the result list/dict without an extra reference-count -round-trip (using the internal reference-stealing append/insert helpers). diff --git a/Misc/NEWS.d/next/Library/2026-05-31-12-00-00.gh-issue-150942.Re7Ref.rst b/Misc/NEWS.d/next/Library/2026-05-31-12-00-00.gh-issue-150942.Re7Ref.rst deleted file mode 100644 index 63967108b1e0b3b..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-31-12-00-00.gh-issue-150942.Re7Ref.rst +++ /dev/null @@ -1,3 +0,0 @@ -Speed up :func:`re.findall`, :func:`re.sub` and :func:`re.subn` by appending -result items to the output list without an extra reference-count round-trip -(using the internal reference-stealing list append helper). diff --git a/Misc/NEWS.d/next/Library/2026-05-31-14-39-25.gh-issue-150641.LLIhd1.rst b/Misc/NEWS.d/next/Library/2026-05-31-14-39-25.gh-issue-150641.LLIhd1.rst deleted file mode 100644 index eba899c96fcd26b..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-31-14-39-25.gh-issue-150641.LLIhd1.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix bug where :func:`typing.evaluate_forward_ref` with the ``STRING`` format -could leak internal names used by the annotation machinery. diff --git a/Misc/NEWS.d/next/Library/2026-05-31-17-47-30.gh-issue-150685.EBB2mU.rst b/Misc/NEWS.d/next/Library/2026-05-31-17-47-30.gh-issue-150685.EBB2mU.rst deleted file mode 100644 index eb7f31112d004c8..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-05-31-17-47-30.gh-issue-150685.EBB2mU.rst +++ /dev/null @@ -1 +0,0 @@ -Update bundled pip to 26.1.2 diff --git a/Misc/NEWS.d/next/Library/2026-06-01-08-12-34.gh-issue-150717.LVRJXH.rst b/Misc/NEWS.d/next/Library/2026-06-01-08-12-34.gh-issue-150717.LVRJXH.rst deleted file mode 100644 index da7171fcc72ce41..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-01-08-12-34.gh-issue-150717.LVRJXH.rst +++ /dev/null @@ -1,2 +0,0 @@ -Avoid an unnecessary per-call memory allocation when matching :mod:`re` -patterns that have no capturing groups. Patch by Bernát Gábor. diff --git a/Misc/NEWS.d/next/Library/2026-06-02-14-21-46.gh-issue-150750.SVS2o0.rst b/Misc/NEWS.d/next/Library/2026-06-02-14-21-46.gh-issue-150750.SVS2o0.rst deleted file mode 100644 index bda500383e7cda3..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-02-14-21-46.gh-issue-150750.SVS2o0.rst +++ /dev/null @@ -1 +0,0 @@ -Fix a race condition in :meth:`collections.deque.index` with free-threading. diff --git a/Misc/NEWS.d/next/Library/2026-06-02-15-44-57.gh-issue-150817.lpFCh0.rst b/Misc/NEWS.d/next/Library/2026-06-02-15-44-57.gh-issue-150817.lpFCh0.rst deleted file mode 100644 index 42532bb0222cf4e..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-02-15-44-57.gh-issue-150817.lpFCh0.rst +++ /dev/null @@ -1,2 +0,0 @@ -Speed up the ``|``, ``&`` and ``^`` operations on :class:`enum.Flag` members. -Patch by Bernát Gábor. diff --git a/Misc/NEWS.d/next/Library/2026-06-02-15-44-58.gh-issue-150818.Orcefu.rst b/Misc/NEWS.d/next/Library/2026-06-02-15-44-58.gh-issue-150818.Orcefu.rst deleted file mode 100644 index 3bb16001cc0bb41..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-02-15-44-58.gh-issue-150818.Orcefu.rst +++ /dev/null @@ -1,3 +0,0 @@ -Speed up :func:`logging.getLogger` with a lock-free fast path that returns an -already-registered logger without acquiring the logging lock. Patch by Bernát -Gábor. diff --git a/Misc/NEWS.d/next/Library/2026-06-03-13-51-29.gh-issue-150662.ELT8Vg.rst b/Misc/NEWS.d/next/Library/2026-06-03-13-51-29.gh-issue-150662.ELT8Vg.rst deleted file mode 100644 index 42ed6ad7cd3c65f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-03-13-51-29.gh-issue-150662.ELT8Vg.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix the ``--gecko`` collector in :mod:`profiling.sampling` that kept every -sample in memory. It now writes sample and marker data to temporary files -and reads them back, ultimately building the output file at the end. Patch -by Pablo Galindo and Maurycy Pawłowski-Wieroński. diff --git a/Misc/NEWS.d/next/Library/2026-06-03-19-35-32.gh-issue-150583.dedI24.rst b/Misc/NEWS.d/next/Library/2026-06-03-19-35-32.gh-issue-150583.dedI24.rst deleted file mode 100644 index edb551b3c3c8cbd..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-03-19-35-32.gh-issue-150583.dedI24.rst +++ /dev/null @@ -1,2 +0,0 @@ -Correctly set the default compression level in :mod:`compression.zstd` when passing a digested -dictionary during compression. diff --git a/Misc/NEWS.d/next/Library/2026-06-03-21-59-11.gh-issue-150886.r2c25g.rst b/Misc/NEWS.d/next/Library/2026-06-03-21-59-11.gh-issue-150886.r2c25g.rst deleted file mode 100644 index b220b63cfdb4ab5..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-03-21-59-11.gh-issue-150886.r2c25g.rst +++ /dev/null @@ -1,4 +0,0 @@ -Remove the private, undocumented function -``importlib._bootstrap._object_name()``. It had no caller after -``load_module()`` and its deprecation warnings were removed from -:mod:`importlib`. diff --git a/Misc/NEWS.d/next/Library/2026-06-04-06-50-06.gh-issue-150898.1LkLA3.rst b/Misc/NEWS.d/next/Library/2026-06-04-06-50-06.gh-issue-150898.1LkLA3.rst deleted file mode 100644 index 85328c43368e198..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-04-06-50-06.gh-issue-150898.1LkLA3.rst +++ /dev/null @@ -1 +0,0 @@ -Unconditionally assume :attr:`ssl.SSLContext.keylog_filename` exists. diff --git a/Misc/NEWS.d/next/Library/2026-06-04-10-44-36.gh-issue-150889.UYNLR_.rst b/Misc/NEWS.d/next/Library/2026-06-04-10-44-36.gh-issue-150889.UYNLR_.rst deleted file mode 100644 index a5cc1da758637c5..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-04-10-44-36.gh-issue-150889.UYNLR_.rst +++ /dev/null @@ -1 +0,0 @@ -Speed up :func:`unicodedata.normalize` for the NFC and NFKC forms of non-ASCII text up to a factor 2. diff --git a/Misc/NEWS.d/next/Library/2026-06-04-18-22-56.gh-issue-143008.z5tw-J.rst b/Misc/NEWS.d/next/Library/2026-06-04-18-22-56.gh-issue-143008.z5tw-J.rst deleted file mode 100644 index e99bc39c45f9b8f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-04-18-22-56.gh-issue-143008.z5tw-J.rst +++ /dev/null @@ -1 +0,0 @@ -Fix race conditions when re-initializing a :class:`io.TextIOWrapper` object. diff --git a/Misc/NEWS.d/next/Library/2026-06-04-19-24-13.gh-issue-140006.TD8HKl.rst b/Misc/NEWS.d/next/Library/2026-06-04-19-24-13.gh-issue-140006.TD8HKl.rst deleted file mode 100644 index 6d8d66b29b19902..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-04-19-24-13.gh-issue-140006.TD8HKl.rst +++ /dev/null @@ -1,4 +0,0 @@ -The :mod:`venv` ``activate.fish`` script now calls fish builtins through -``builtin`` so a user function that shadows ``.``/``source``, ``echo``, -``printf``, ``set_color``, or ``functions`` can no longer hijack the virtual -environment prompt or break exit-status reporting. diff --git a/Misc/NEWS.d/next/Library/2026-06-04-21-49-18.gh-issue-150913.EmptyBl.rst b/Misc/NEWS.d/next/Library/2026-06-04-21-49-18.gh-issue-150913.EmptyBl.rst deleted file mode 100644 index f95a6ee6ee15bf7..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-04-21-49-18.gh-issue-150913.EmptyBl.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix :class:`sqlite3.Blob` slice assignment to raise -:exc:`TypeError` and :exc:`IndexError` for type and size mismatches -respectively, even when the target slice is empty. diff --git a/Misc/NEWS.d/next/Library/2026-06-04-23-10-31.gh-issue-62825.BtG_yQ.rst b/Misc/NEWS.d/next/Library/2026-06-04-23-10-31.gh-issue-62825.BtG_yQ.rst deleted file mode 100644 index 95a4fb1c61d4c30..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-04-23-10-31.gh-issue-62825.BtG_yQ.rst +++ /dev/null @@ -1,2 +0,0 @@ -Encodings "KS_C_5601-1987", "KS X 1001", etc are now aliases of "CP949" -instead of "EUC-KR". diff --git a/Misc/NEWS.d/next/Library/2026-06-06-06-29-17.gh-issue-150994.I2119M.rst b/Misc/NEWS.d/next/Library/2026-06-06-06-29-17.gh-issue-150994.I2119M.rst deleted file mode 100644 index c4a610c24806b0a..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-06-06-29-17.gh-issue-150994.I2119M.rst +++ /dev/null @@ -1 +0,0 @@ -Make the type annotations in the private ``_colorize`` module resolvable. diff --git a/Misc/NEWS.d/next/Library/2026-06-06-15-20-54.gh-issue-151021.J4qk2A.rst b/Misc/NEWS.d/next/Library/2026-06-06-15-20-54.gh-issue-151021.J4qk2A.rst deleted file mode 100644 index 0617fa068c844d6..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-06-15-20-54.gh-issue-151021.J4qk2A.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix :meth:`mmap.mmap.find` and :meth:`~mmap.mmap.rfind` to return ``-1`` -when searching for an empty subsequence with a start position past the end -of the mapping. diff --git a/Misc/NEWS.d/next/Library/2026-06-07-13-47-05.gh-issue-151042.NMdzF2.rst b/Misc/NEWS.d/next/Library/2026-06-07-13-47-05.gh-issue-151042.NMdzF2.rst deleted file mode 100644 index a24a15c0cc267f5..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-07-13-47-05.gh-issue-151042.NMdzF2.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed venv exporting mixed path styles to PATH on Windows inside fish (via Cygwin, MinGW or MSYS2) diff --git a/Misc/NEWS.d/next/Library/2026-06-07-17-29-33.gh-issue-151039.AZ0qBn.rst b/Misc/NEWS.d/next/Library/2026-06-07-17-29-33.gh-issue-151039.AZ0qBn.rst deleted file mode 100644 index 1e99567f5550579..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-07-17-29-33.gh-issue-151039.AZ0qBn.rst +++ /dev/null @@ -1 +0,0 @@ -Fix a crash when static :mod:`datetime` types outlive the ``_datetime`` module. diff --git a/Misc/NEWS.d/next/Library/2026-06-08-15-04-35.gh-issue-150285.-Tj94n.rst b/Misc/NEWS.d/next/Library/2026-06-08-15-04-35.gh-issue-150285.-Tj94n.rst deleted file mode 100644 index 60b1f3e0a71f5bb..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-08-15-04-35.gh-issue-150285.-Tj94n.rst +++ /dev/null @@ -1 +0,0 @@ -:mod:`pydoc` now wraps long single-line summary in text output. diff --git a/Misc/NEWS.d/next/Library/2026-06-09-12-00-00.gh-issue-150771.K7mNx2.rst b/Misc/NEWS.d/next/Library/2026-06-09-12-00-00.gh-issue-150771.K7mNx2.rst deleted file mode 100644 index 6535e5c48bf0360..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-09-12-00-00.gh-issue-150771.K7mNx2.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix :mod:`email` messages created with ``shift_jis`` or ``euc-jp`` charsets. -``set_content()`` now stores the payload using the output charset -(``iso-2022-jp``) so printing the message no longer raises -:exc:`UnicodeEncodeError`. diff --git a/Misc/NEWS.d/next/Library/2026-06-09-14-49-17.gh-issue-80384.ttRAja.rst b/Misc/NEWS.d/next/Library/2026-06-09-14-49-17.gh-issue-80384.ttRAja.rst deleted file mode 100644 index 53d4d513ba757de..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-09-14-49-17.gh-issue-80384.ttRAja.rst +++ /dev/null @@ -1,2 +0,0 @@ -:func:`weakref.ref` and :func:`weakref.proxy` now raise :exc:`TypeError` if -the *callback* argument is not callable or ``None``. diff --git a/Misc/NEWS.d/next/Library/2026-06-09-19-43-24.gh-issue-151179.hl_6Z0.rst b/Misc/NEWS.d/next/Library/2026-06-09-19-43-24.gh-issue-151179.hl_6Z0.rst deleted file mode 100644 index 904edf3a8c70908..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-09-19-43-24.gh-issue-151179.hl_6Z0.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a pidfd leak in ``_PidfdChildWatcher`` on Linux: the watcher no -longer leaks the process file descriptor when ``waitpid()`` fails with an -error other than :exc:`ChildProcessError`. diff --git a/Misc/NEWS.d/next/Library/2026-06-10-00-00-02.gh-issue-109940.Cx1099.rst b/Misc/NEWS.d/next/Library/2026-06-10-00-00-02.gh-issue-109940.Cx1099.rst deleted file mode 100644 index 130dc780b612864..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-10-00-00-02.gh-issue-109940.Cx1099.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix Windows :mod:`venv` activation in ``cmd.exe`` to respect -``VIRTUAL_ENV_DISABLE_PROMPT``. diff --git a/Misc/NEWS.d/next/Library/2026-06-11-00-00-00.gh-issue-151295.NQYUzW.rst b/Misc/NEWS.d/next/Library/2026-06-11-00-00-00.gh-issue-151295.NQYUzW.rst deleted file mode 100644 index e9012f023ff7f77..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-11-00-00-00.gh-issue-151295.NQYUzW.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fixed a crash (use-after-free) in :meth:`bytes.join` and -:meth:`bytearray.join` that could occur if an item's -:meth:`~object.__buffer__` concurrently mutates the sequence being joined. -The mutation is now reported as a :exc:`RuntimeError` instead. diff --git a/Misc/NEWS.d/next/Library/2026-06-11-06-56-31.gh-issue-150994.gd1wVw.rst b/Misc/NEWS.d/next/Library/2026-06-11-06-56-31.gh-issue-150994.gd1wVw.rst deleted file mode 100644 index 005a1d99b766dce..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-11-06-56-31.gh-issue-150994.gd1wVw.rst +++ /dev/null @@ -1 +0,0 @@ -Make type annotations in the private ``_colorize`` module resolvable. diff --git a/Misc/NEWS.d/next/Library/2026-06-11-11-52-23.gh-issue-149671.6Rpr5r.rst b/Misc/NEWS.d/next/Library/2026-06-11-11-52-23.gh-issue-149671.6Rpr5r.rst deleted file mode 100644 index 5c08828e5fd77ec..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-11-11-52-23.gh-issue-149671.6Rpr5r.rst +++ /dev/null @@ -1,3 +0,0 @@ -Restore compatibility with setuptools ``-nspkg.pth`` files in the :mod:`site` -module. Inject ``sitedir`` variable in the frame which executes pth code. -Patch by Victor Stinner. diff --git a/Misc/NEWS.d/next/Library/2026-06-11-16-25-38.gh-issue-151126.bh_Usy.rst b/Misc/NEWS.d/next/Library/2026-06-11-16-25-38.gh-issue-151126.bh_Usy.rst deleted file mode 100644 index 25149057aa7d092..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-11-16-25-38.gh-issue-151126.bh_Usy.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a crash when :exc:`MemoryError` in :func:`!os._path_splitroot` -was not set properly. diff --git a/Misc/NEWS.d/next/Library/2026-06-11-19-46-16.gh-issue-150285.wuhAsL.rst b/Misc/NEWS.d/next/Library/2026-06-11-19-46-16.gh-issue-150285.wuhAsL.rst deleted file mode 100644 index 3f19150488f3131..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-11-19-46-16.gh-issue-150285.wuhAsL.rst +++ /dev/null @@ -1,2 +0,0 @@ -:mod:`pydoc` now uses all available space (80 columns) for formatting reprs -of module and class data, but ensure that they do not overflow. diff --git a/Misc/NEWS.d/next/Library/2026-06-11-21-43-24.gh-issue-151337.JSVV18.rst b/Misc/NEWS.d/next/Library/2026-06-11-21-43-24.gh-issue-151337.JSVV18.rst deleted file mode 100644 index 0344eee9471d292..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-11-21-43-24.gh-issue-151337.JSVV18.rst +++ /dev/null @@ -1 +0,0 @@ -Avoid possible memory leak in ``tkinter.c`` on Windows. diff --git a/Misc/NEWS.d/next/Library/2026-06-12-00-00-00.gh-issue-151416.spawnUA.rst b/Misc/NEWS.d/next/Library/2026-06-12-00-00-00.gh-issue-151416.spawnUA.rst deleted file mode 100644 index fd034d9885a8302..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-12-00-00-00.gh-issue-151416.spawnUA.rst +++ /dev/null @@ -1,5 +0,0 @@ -Fix a crash in :func:`os.spawnv` and :func:`os.spawnve` when an *argv* -item's :meth:`~os.PathLike.__fspath__` method mutates the *argv* list -during argument conversion. :func:`!os.spawnv` argument conversion errors -other than :exc:`TypeError`, such as the :exc:`ValueError` for an embedded -null, are no longer replaced with a generic :exc:`TypeError`. diff --git a/Misc/NEWS.d/next/Library/2026-06-12-00-04-34.gh-issue-151126.aHaBYq.rst b/Misc/NEWS.d/next/Library/2026-06-12-00-04-34.gh-issue-151126.aHaBYq.rst deleted file mode 100644 index 20ef69d5de5ac55..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-12-00-04-34.gh-issue-151126.aHaBYq.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix crash on unset :exc:`MemoryError` on allocation failure in -:func:`ctypes.get_errno`. diff --git a/Misc/NEWS.d/next/Library/2026-06-12-00-17-29.gh-issue-151128.-LYO3a.rst b/Misc/NEWS.d/next/Library/2026-06-12-00-17-29.gh-issue-151128.-LYO3a.rst deleted file mode 100644 index 6e760686af2b01f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-12-00-17-29.gh-issue-151128.-LYO3a.rst +++ /dev/null @@ -1,3 +0,0 @@ -Cross-language keyword suggestions are now shown for :exc:`SyntaxError` messages. -For example, ``switch x:`` suggests ``match``, ``delete x`` suggests ``del``, -``function f():`` suggests ``def``. Contributed by Zang Langyan. diff --git a/Misc/NEWS.d/next/Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst b/Misc/NEWS.d/next/Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst deleted file mode 100644 index ff8de30599c6ad5..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst +++ /dev/null @@ -1 +0,0 @@ -Colorize ``match`` in the :term:`REPL` when followed by a unary ``+`` or ``-`` operator. Patch by Bartosz Sławecki. diff --git a/Misc/NEWS.d/next/Library/2026-06-12-22-46-31.gh-issue-151403.DalZWh.rst b/Misc/NEWS.d/next/Library/2026-06-12-22-46-31.gh-issue-151403.DalZWh.rst deleted file mode 100644 index ca779ed684e7616..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-12-22-46-31.gh-issue-151403.DalZWh.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fixed a crash in :class:`subprocess.Popen` (and ``_posixsubprocess.fork_exec``) -when an ``argv`` item's :meth:`~os.PathLike.__fspath__` concurrently mutates the -``args`` sequence being converted. diff --git a/Misc/NEWS.d/next/Library/2026-06-13-04-11-00.gh-issue-151426.f2V67e.rst b/Misc/NEWS.d/next/Library/2026-06-13-04-11-00.gh-issue-151426.f2V67e.rst deleted file mode 100644 index 428302e5f847f36..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-13-04-11-00.gh-issue-151426.f2V67e.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix impossible stack traces (callers and callees cross called, orphans and -incorrect lines) in the Tachyon profiler when caching frames, by snapshotting -the stack chunks before walking the frame chain on a cache miss. Patch by -Maurycy Pawłowski-Wieroński. diff --git a/Misc/NEWS.d/next/Library/2026-06-13-11-57-48.gh-issue-151436.UEDowO.rst b/Misc/NEWS.d/next/Library/2026-06-13-11-57-48.gh-issue-151436.UEDowO.rst deleted file mode 100644 index 6b10b03ba02fdf3..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-13-11-57-48.gh-issue-151436.UEDowO.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix skewed stack traces in the Tachyon profiler when caching is enabled and -when generators and coroutines are profiled, by updating -``tstate->last_profiled_frame`` at every frame-removal site. The issue resulted -in total erasure of some callers. Patch by Maurycy Pawłowski-Wieroński. diff --git a/Misc/NEWS.d/next/Library/2026-06-15-07-42-12.gh-issue-151485.NiYQPZ.rst b/Misc/NEWS.d/next/Library/2026-06-15-07-42-12.gh-issue-151485.NiYQPZ.rst deleted file mode 100644 index 134499107ab2b78..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-15-07-42-12.gh-issue-151485.NiYQPZ.rst +++ /dev/null @@ -1 +0,0 @@ -Fix command quoting in :exc:`subprocess.CalledProcessError`. Contributed by Benjy Wiener. diff --git a/Misc/NEWS.d/next/Library/2026-06-15-15-32-36.gh-issue-151497.1cfmSV.rst b/Misc/NEWS.d/next/Library/2026-06-15-15-32-36.gh-issue-151497.1cfmSV.rst deleted file mode 100644 index a4c03c9d71d7618..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-15-15-32-36.gh-issue-151497.1cfmSV.rst +++ /dev/null @@ -1,4 +0,0 @@ -Opening a :mod:`tarfile` archive no longer attempts to pre-allocate a huge -buffer when a crafted or truncated member claims an oversized extended header -(a GNU long name/link or a pax header). The extended header is now read in -bounded chunks, so its size field can no longer trigger memory exhaustion. diff --git a/Misc/NEWS.d/next/Library/2026-06-17-00-00-00.gh-issue-148660.odcopy.rst b/Misc/NEWS.d/next/Library/2026-06-17-00-00-00.gh-issue-148660.odcopy.rst deleted file mode 100644 index 30c2e366ca2ba07..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-17-00-00-00.gh-issue-148660.odcopy.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a crash in :meth:`!collections.OrderedDict.copy` when a key's -``__eq__`` or a subclass method mutates the dict during the copy. Now -raises :exc:`RuntimeError` instead, as iteration does. diff --git a/Misc/NEWS.d/next/Library/2026-06-17-22-31-57.gh-issue-151613.n0nua1.rst b/Misc/NEWS.d/next/Library/2026-06-17-22-31-57.gh-issue-151613.n0nua1.rst deleted file mode 100644 index fbf3ce47ff2739f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-17-22-31-57.gh-issue-151613.n0nua1.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix another way the Tachyon profiler frame cache could produce impossible -mixed stack traces when ``_PyInterpreterFrame`` addresses are reused, by -validating cached frame anchors with a sequence counter. diff --git a/Misc/NEWS.d/next/Library/2026-06-18-00-39-58.gh-issue-151615.PBsCE1.rst b/Misc/NEWS.d/next/Library/2026-06-18-00-39-58.gh-issue-151615.PBsCE1.rst deleted file mode 100644 index 1d08dbacef1f79b..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-18-00-39-58.gh-issue-151615.PBsCE1.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix :mod:`asyncio` servers repeatedly logging and rescheduling on a single -event loop iteration when ``accept()`` fails with a resource errors. diff --git a/Misc/NEWS.d/next/Library/2026-06-18-12-48-03.gh-issue-151640.R4c3Fx.rst b/Misc/NEWS.d/next/Library/2026-06-18-12-48-03.gh-issue-151640.R4c3Fx.rst deleted file mode 100644 index ef61a7d27dd07dd..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-18-12-48-03.gh-issue-151640.R4c3Fx.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a data race in :class:`io.BytesIO` in free-threaded builds when -whole-buffer reads or peeks, or :meth:`~io.BytesIO.getvalue`, share the -internal buffer with concurrent writes. diff --git a/Misc/NEWS.d/next/Library/2026-06-18-23-59-46.gh-issue-151596.5ma144.rst b/Misc/NEWS.d/next/Library/2026-06-18-23-59-46.gh-issue-151596.5ma144.rst deleted file mode 100644 index 17ec1341142e93d..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-18-23-59-46.gh-issue-151596.5ma144.rst +++ /dev/null @@ -1 +0,0 @@ -Add missing ``size`` positional argument to the pure-Python implementation of :meth:`io.TextIOBase.readline`. diff --git a/Misc/NEWS.d/next/Library/2026-06-19-07-26-20.gh-issue-151695.IBDlkN.rst b/Misc/NEWS.d/next/Library/2026-06-19-07-26-20.gh-issue-151695.IBDlkN.rst deleted file mode 100644 index f44cb6b93071656..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-19-07-26-20.gh-issue-151695.IBDlkN.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix a use-after-free in the :mod:`curses` module. The encoding of the initial -screen, used by :func:`curses.unctrl` and :func:`curses.ungetch` to encode -non-ASCII characters, is now kept as a private copy instead of a borrowed -pointer to a window object that may be deallocated. diff --git a/Misc/NEWS.d/next/Library/2026-06-19-12-00-00.gh-issue-151674.FCYTvs.rst b/Misc/NEWS.d/next/Library/2026-06-19-12-00-00.gh-issue-151674.FCYTvs.rst deleted file mode 100644 index 84e21d4cbc4bd72..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-19-12-00-00.gh-issue-151674.FCYTvs.rst +++ /dev/null @@ -1,3 +0,0 @@ -Add the :meth:`~tkinter.Text.edit_canundo` and :meth:`~tkinter.Text.edit_canredo` -methods of :class:`!tkinter.Text`, wrapping the Tk ``edit canundo`` and -``edit canredo`` subcommands. diff --git a/Misc/NEWS.d/next/Library/2026-06-19-12-00-01.gh-issue-151675.acLD7L.rst b/Misc/NEWS.d/next/Library/2026-06-19-12-00-01.gh-issue-151675.acLD7L.rst deleted file mode 100644 index 92bd69de6bdc0ec..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-19-12-00-01.gh-issue-151675.acLD7L.rst +++ /dev/null @@ -1,3 +0,0 @@ -Add the :meth:`~tkinter.Text.sync` and :meth:`~tkinter.Text.pendingsync` -methods of :class:`!tkinter.Text`, wrapping the Tk ``sync`` and -``pendingsync`` subcommands. diff --git a/Misc/NEWS.d/next/Library/2026-06-19-12-19-30.gh-issue-90092.yBVc0C.rst b/Misc/NEWS.d/next/Library/2026-06-19-12-19-30.gh-issue-90092.yBVc0C.rst deleted file mode 100644 index 41e0ce80ee8a069..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-19-12-19-30.gh-issue-90092.yBVc0C.rst +++ /dev/null @@ -1,4 +0,0 @@ -Add support for multiple terminals to the :mod:`curses` module: the new -functions :func:`curses.newterm`, :func:`curses.set_term` and -:func:`curses.new_prescr`, the corresponding :ref:`screen -` object, and the :meth:`curses.window.use` method. diff --git a/Misc/NEWS.d/next/Library/2026-06-19-18-40-00.gh-issue-151744.Kp7mNq.rst b/Misc/NEWS.d/next/Library/2026-06-19-18-40-00.gh-issue-151744.Kp7mNq.rst deleted file mode 100644 index 24328a8f9f93427..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-19-18-40-00.gh-issue-151744.Kp7mNq.rst +++ /dev/null @@ -1 +0,0 @@ -Add :func:`curses.nofilter`, which undoes the effect of :func:`curses.filter`. diff --git a/Misc/NEWS.d/next/Library/2026-06-20-02-14-55.gh-issue-151757.TP9A2x.rst b/Misc/NEWS.d/next/Library/2026-06-20-02-14-55.gh-issue-151757.TP9A2x.rst deleted file mode 100644 index ee1aa3eff6f0c2f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-20-02-14-55.gh-issue-151757.TP9A2x.rst +++ /dev/null @@ -1,9 +0,0 @@ -The :mod:`curses` character-cell window methods now accept a full character -cell -- a spacing character optionally followed by combining characters -- in -addition to a single integer or byte character. Add the wide-character read -methods :meth:`curses.window.get_wstr` and :meth:`curses.window.in_wstr`, and -the functions :func:`curses.erasewchar`, :func:`curses.killwchar` and -:func:`curses.wunctrl`. On a narrow (non-ncursesw) build the character cell -holds a single character without combining marks, representable as one byte in -the window's encoding, and :meth:`curses.window.in_wstr` returns its decoded -text. diff --git a/Misc/NEWS.d/next/Library/2026-06-20-11-11-22.gh-issue-151774.O6nrvs.rst b/Misc/NEWS.d/next/Library/2026-06-20-11-11-22.gh-issue-151774.O6nrvs.rst deleted file mode 100644 index 668b01ebfb8ad79..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-20-11-11-22.gh-issue-151774.O6nrvs.rst +++ /dev/null @@ -1,5 +0,0 @@ -Add the :mod:`curses` functions :func:`curses.alloc_pair`, -:func:`curses.find_pair`, :func:`curses.free_pair` and -:func:`curses.reset_color_pairs` for dynamic color-pair management. They are -only available when Python is built against a wide-character version of the -underlying curses library with extended-color support. diff --git a/Misc/NEWS.d/next/Library/2026-06-20-12-10-02.gh-issue-151776.BtsXIF.rst b/Misc/NEWS.d/next/Library/2026-06-20-12-10-02.gh-issue-151776.BtsXIF.rst deleted file mode 100644 index 3eabc4a6bea82b5..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-20-12-10-02.gh-issue-151776.BtsXIF.rst +++ /dev/null @@ -1,12 +0,0 @@ -Add :mod:`curses` functions and window methods that report state which could -previously only be set: the window methods :meth:`~curses.window.is_cleared`, -:meth:`~curses.window.is_idcok`, :meth:`~curses.window.is_idlok`, -:meth:`~curses.window.is_immedok`, :meth:`~curses.window.is_keypad`, -:meth:`~curses.window.is_leaveok`, :meth:`~curses.window.is_nodelay`, -:meth:`~curses.window.is_notimeout`, :meth:`~curses.window.is_pad`, -:meth:`~curses.window.is_scrollok`, :meth:`~curses.window.is_subwin`, -:meth:`~curses.window.is_syncok`, :meth:`~curses.window.getdelay`, -:meth:`~curses.window.getparent` and :meth:`~curses.window.getscrreg`, and the -functions :func:`curses.is_cbreak`, :func:`curses.is_echo`, -:func:`curses.is_nl` and :func:`curses.is_raw`. They are only available when -built against an ncurses with ``NCURSES_EXT_FUNCS``. diff --git a/Misc/NEWS.d/next/Library/2026-06-20-15-00-00.gh-issue-151770.dtiso0.rst b/Misc/NEWS.d/next/Library/2026-06-20-15-00-00.gh-issue-151770.dtiso0.rst deleted file mode 100644 index 10b3db8efa42b0f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-20-15-00-00.gh-issue-151770.dtiso0.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix :meth:`datetime.datetime.fromisoformat` raising :exc:`AssertionError` -instead of :exc:`ValueError` for an out-of-range month combined with a -``24:00`` time. diff --git a/Misc/NEWS.d/next/Library/2026-06-20-15-00-00.gh-issue-75666.Kt9xQ2.rst b/Misc/NEWS.d/next/Library/2026-06-20-15-00-00.gh-issue-75666.Kt9xQ2.rst deleted file mode 100644 index d2b2b066837bb1f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-20-15-00-00.gh-issue-75666.Kt9xQ2.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a reference leak in :mod:`tkinter`: the Tcl commands created for event -callbacks are now deleted when a binding is replaced or unbound. diff --git a/Misc/NEWS.d/next/Library/2026-06-20-21-15-13.gh-issue-151814.OIbgsO.rst b/Misc/NEWS.d/next/Library/2026-06-20-21-15-13.gh-issue-151814.OIbgsO.rst deleted file mode 100644 index 1365fb4d8edb1d2..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-20-21-15-13.gh-issue-151814.OIbgsO.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix unbounded memory growth in :class:`io.TextIOWrapper` when repeatedly -writing an empty string. diff --git a/Misc/NEWS.d/next/Library/2026-06-20-22-55-22.gh-issue-59396.kT9wPq.rst b/Misc/NEWS.d/next/Library/2026-06-20-22-55-22.gh-issue-59396.kT9wPq.rst deleted file mode 100644 index 550620a9c8276cb..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-20-22-55-22.gh-issue-59396.kT9wPq.rst +++ /dev/null @@ -1,22 +0,0 @@ -The :mod:`tkinter.simpledialog` dialogs were modernized to match the look and -feel of the native Tk dialogs. -:class:`!tkinter.simpledialog.SimpleDialog` and the -:func:`~tkinter.simpledialog.askinteger`, -:func:`~tkinter.simpledialog.askfloat` and -:func:`~tkinter.simpledialog.askstring` dialogs are now built from -the themed :mod:`tkinter.ttk` widgets instead of the classic :mod:`tkinter` -widgets; the :class:`!tkinter.simpledialog.Dialog` base class still defaults to -the classic widgets for compatibility. Both :class:`!Dialog` and -:class:`!SimpleDialog` gained a *use_ttk* -parameter that selects between the classic Tk widgets and the themed ttk -widgets. :class:`!SimpleDialog` also gained *bitmap* and *detail* parameters, -draws the standard icons with themed images in the ttk version, and accepts -mappings of button options as *buttons* entries, where an ``underline`` option -adds an :kbd:`Alt` key accelerator. -The font and wrap length of the message and the detail message are taken from -the Tk option database and can be overridden by the application. -The dialogs also follow the keyboard conventions of the Tk message box: the -default ring follows the keyboard focus, the Return key activates the focused -button, and the :class:`!Dialog` OK and Cancel buttons gained :kbd:`Alt` key -accelerators. -Several bugs were also fixed. diff --git a/Misc/NEWS.d/next/Library/2026-06-21-15-50-24.gh-issue-86165.dyac1G.rst b/Misc/NEWS.d/next/Library/2026-06-21-15-50-24.gh-issue-86165.dyac1G.rst deleted file mode 100644 index 0b630e9ae346834..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-21-15-50-24.gh-issue-86165.dyac1G.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix :func:`imaplib.Time2Internaldate` to use the local timezone offset for -``time.struct_time`` values with ``tm_gmtoff`` set to ``None``, as returned by -``datetime.datetime.timetuple()``. Contributed by Xiao Yuan. diff --git a/Misc/NEWS.d/next/Library/2026-06-21-23-17-12.gh-issue-59396.Fd9Tk2.rst b/Misc/NEWS.d/next/Library/2026-06-21-23-17-12.gh-issue-59396.Fd9Tk2.rst deleted file mode 100644 index 890a29cb7adf95d..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-21-23-17-12.gh-issue-59396.Fd9Tk2.rst +++ /dev/null @@ -1,14 +0,0 @@ -The :class:`!tkinter.filedialog.FileDialog` dialog and its -:class:`!tkinter.filedialog.LoadFileDialog` and -:class:`!tkinter.filedialog.SaveFileDialog` subclasses, which follow the layout -of the classic Motif file selection dialog, were modernized to match its look -and feel more closely. -They are now built from the themed :mod:`tkinter.ttk` widgets instead of the -classic :mod:`tkinter` widgets, and gained a *use_ttk* parameter that selects -between the classic Tk widgets and the themed ttk widgets. -The buttons and field labels gained :kbd:`Alt` key accelerators, the default -ring follows the keyboard focus, and the :kbd:`Escape` key cancels the dialog. -The directory and file lists gained a horizontal scrollbar and type-ahead -selection. -The dialog is now centered over its parent, and the overwrite confirmation of -:class:`!SaveFileDialog` uses a themed message box. diff --git a/Misc/NEWS.d/next/Library/2026-06-22-00-46-57.gh-issue-151874.8VtTrq.rst b/Misc/NEWS.d/next/Library/2026-06-22-00-46-57.gh-issue-151874.8VtTrq.rst deleted file mode 100644 index 50a33f5be809871..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-22-00-46-57.gh-issue-151874.8VtTrq.rst +++ /dev/null @@ -1,3 +0,0 @@ -Add the :mod:`tkinter` methods :meth:`!Misc.winfo_isdark`, -:meth:`!Wm.wm_iconbadge` and :meth:`!Wm.wm_stackorder`, wrapping the -``winfo isdark``, ``wm iconbadge`` and ``wm stackorder`` Tk commands. diff --git a/Misc/NEWS.d/next/Library/2026-06-22-00-55-07.gh-issue-151876.sVe0xx.rst b/Misc/NEWS.d/next/Library/2026-06-22-00-55-07.gh-issue-151876.sVe0xx.rst deleted file mode 100644 index 9dc5f2327cf4155..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-22-00-55-07.gh-issue-151876.sVe0xx.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add the :class:`tkinter.Canvas` methods :meth:`!rchars` and :meth:`!rotate`, -wrapping the ``rchars`` and ``rotate`` Tk canvas commands. diff --git a/Misc/NEWS.d/next/Library/2026-06-22-01-02-33.gh-issue-151878.IFIA5C.rst b/Misc/NEWS.d/next/Library/2026-06-22-01-02-33.gh-issue-151878.IFIA5C.rst deleted file mode 100644 index af0d2c25136c452..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-22-01-02-33.gh-issue-151878.IFIA5C.rst +++ /dev/null @@ -1,3 +0,0 @@ -Add the :meth:`!validate` method to the :class:`tkinter.Entry` and -:class:`tkinter.Spinbox` widgets, forcing an evaluation of the validation -command. diff --git a/Misc/NEWS.d/next/Library/2026-06-22-01-39-38.gh-issue-151881.ShACSZ.rst b/Misc/NEWS.d/next/Library/2026-06-22-01-39-38.gh-issue-151881.ShACSZ.rst deleted file mode 100644 index 9ae939438e826f6..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-22-01-39-38.gh-issue-151881.ShACSZ.rst +++ /dev/null @@ -1,4 +0,0 @@ -Add the :meth:`tkinter.Menu.postcascade` method and the -:meth:`!tkinter.Misc.tk_scaling` and :meth:`!tkinter.Misc.tk_inactive` -methods, wrapping the ``postcascade``, ``tk scaling`` and ``tk inactive`` -Tk commands. diff --git a/Misc/NEWS.d/next/Library/2026-06-22-01-51-06.gh-issue-151886.MsLlNz.rst b/Misc/NEWS.d/next/Library/2026-06-22-01-51-06.gh-issue-151886.MsLlNz.rst deleted file mode 100644 index 7a454ab95f371f1..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-22-01-51-06.gh-issue-151886.MsLlNz.rst +++ /dev/null @@ -1,4 +0,0 @@ -Add the :meth:`!tkinter.Misc.tk_appname`, -:meth:`!tkinter.Misc.tk_useinputmethods` and :meth:`!tkinter.Misc.tk_caret` -methods, wrapping the ``tk appname``, ``tk useinputmethods`` and ``tk caret`` -Tk commands. diff --git a/Misc/NEWS.d/next/Library/2026-06-22-01-57-55.gh-issue-151888.hO7mxi.rst b/Misc/NEWS.d/next/Library/2026-06-22-01-57-55.gh-issue-151888.hO7mxi.rst deleted file mode 100644 index 8a2d5ed765d234e..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-22-01-57-55.gh-issue-151888.hO7mxi.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add the :meth:`!tkinter.PhotoImage.redither` method, wrapping the photo image -``redither`` Tk command. diff --git a/Misc/NEWS.d/next/Library/2026-06-22-02-29-02.gh-issue-151890.gT6JwI.rst b/Misc/NEWS.d/next/Library/2026-06-22-02-29-02.gh-issue-151890.gT6JwI.rst deleted file mode 100644 index 3e064aeeba8131c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-22-02-29-02.gh-issue-151890.gT6JwI.rst +++ /dev/null @@ -1,6 +0,0 @@ -Add the *format* parameter to the :meth:`tkinter.PhotoImage.put` method, the -*metadata* parameter to the :meth:`~tkinter.PhotoImage.put`, -:meth:`~tkinter.PhotoImage.read`, :meth:`~tkinter.PhotoImage.write` and -:meth:`~tkinter.PhotoImage.data` methods, and the *withalpha* parameter to the -:meth:`~tkinter.PhotoImage.get` method. The *metadata* and *withalpha* -parameters require Tcl/Tk 9.0 or newer. diff --git a/Misc/NEWS.d/next/Library/2026-06-22-10-30-22.gh-issue-151910.ayi8xK.rst b/Misc/NEWS.d/next/Library/2026-06-22-10-30-22.gh-issue-151910.ayi8xK.rst deleted file mode 100644 index 3e5647cbf835490..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-22-10-30-22.gh-issue-151910.ayi8xK.rst +++ /dev/null @@ -1,6 +0,0 @@ -Added :class:`tkinter.ttk.Treeview` methods wrapping the enhanced -``ttk::treeview`` widget commands added in Tk 9.1 (and the ``detached`` query -added in Tk 9.0): item navigation and queries, opening, hiding, sorting and -searching of items, and cell focus, selection and tagging. The -:meth:`~tkinter.ttk.Treeview.expand` and :meth:`~tkinter.ttk.Treeview.collapse` -methods (without recursion) also work on Tk older than 9.1. diff --git a/Misc/NEWS.d/next/Library/2026-06-22-12-00-00.gh-issue-95555.Pr0p18.rst b/Misc/NEWS.d/next/Library/2026-06-22-12-00-00.gh-issue-95555.Pr0p18.rst deleted file mode 100644 index fa792cae5ec0761..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-22-12-00-00.gh-issue-95555.Pr0p18.rst +++ /dev/null @@ -1,4 +0,0 @@ -Regular expressions now support Unicode property escapes ``\p{...}`` and -``\P{...}`` for properties that the engine can resolve without the unicodedata -database: many ``General_Category`` values, a number of binary properties, the -POSIX compatibility classes, and properties derivable from the code point. diff --git a/Misc/NEWS.d/next/Library/2026-06-22-14-30-00.gh-issue-151920.Th3mSt.rst b/Misc/NEWS.d/next/Library/2026-06-22-14-30-00.gh-issue-151920.Th3mSt.rst deleted file mode 100644 index 2c4a069a794b10e..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-22-14-30-00.gh-issue-151920.Th3mSt.rst +++ /dev/null @@ -1,3 +0,0 @@ -Add the :meth:`ttk.Style.theme_styles ` -method, wrapping the Tk ``ttk::style theme styles`` subcommand, which -returns the list of styles defined in a theme. diff --git a/Misc/NEWS.d/next/Library/2026-06-22-18-01-00.gh-issue-151955.6u5iwm.rst b/Misc/NEWS.d/next/Library/2026-06-22-18-01-00.gh-issue-151955.6u5iwm.rst deleted file mode 100644 index 4cb5f04025327c4..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-22-18-01-00.gh-issue-151955.6u5iwm.rst +++ /dev/null @@ -1,2 +0,0 @@ -Allow more types to be used in the ``bound`` argument to -:class:`typing.ParamSpec` and :class:`typing.TypeVarTuple`. diff --git a/Misc/NEWS.d/next/Library/2026-06-23-11-00-03.gh-issue-143070.fV5w7s.rst b/Misc/NEWS.d/next/Library/2026-06-23-11-00-03.gh-issue-143070.fV5w7s.rst deleted file mode 100644 index 51c2dc3d51bc865..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-23-11-00-03.gh-issue-143070.fV5w7s.rst +++ /dev/null @@ -1,3 +0,0 @@ -Automatically generated :mod:`tkinter` widget names now start with ``"+"`` -instead of ``"!"``, so that they can be used as tags in the -:class:`!tkinter.Canvas` and :class:`!tkinter.Text` widgets. diff --git a/Misc/NEWS.d/next/Library/2026-06-23-12-00-00.gh-issue-101284.Ab3Xy9.rst b/Misc/NEWS.d/next/Library/2026-06-23-12-00-00.gh-issue-101284.Ab3Xy9.rst deleted file mode 100644 index 9afcf8dcf545ed5..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-23-12-00-00.gh-issue-101284.Ab3Xy9.rst +++ /dev/null @@ -1,2 +0,0 @@ -:class:`tkinter.OptionMenu` now accepts arbitrary :class:`!tkinter.Menubutton` -options as keyword arguments and uses them to override its default appearance. diff --git a/Misc/NEWS.d/next/Library/2026-06-23-13-27-14.gh-issue-126219.kOfv2g.rst b/Misc/NEWS.d/next/Library/2026-06-23-13-27-14.gh-issue-126219.kOfv2g.rst deleted file mode 100644 index 8cc8c64c719471d..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-23-13-27-14.gh-issue-126219.kOfv2g.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fixed a crash in :class:`tkinter.Tk` when *className* contains a non-BMP -character and tkinter is built against Tcl/Tk 8.x. Such a name is now -rejected with a :exc:`ValueError`. diff --git a/Misc/NEWS.d/next/Library/2026-06-23-17-14-04.gh-issue-127802.nGSxo6.rst b/Misc/NEWS.d/next/Library/2026-06-23-17-14-04.gh-issue-127802.nGSxo6.rst deleted file mode 100644 index 9484c9dbd23b2fa..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-23-17-14-04.gh-issue-127802.nGSxo6.rst +++ /dev/null @@ -1,3 +0,0 @@ -The deprecated :class:`tkinter.Variable` methods :meth:`!trace_variable`, -:meth:`!trace`, :meth:`!trace_vdelete` and :meth:`!trace_vinfo` are now -scheduled for removal in Python 3.17. diff --git a/Misc/NEWS.d/next/Library/2026-06-23-18-42-37.gh-issue-143990.o65v7O.rst b/Misc/NEWS.d/next/Library/2026-06-23-18-42-37.gh-issue-143990.o65v7O.rst deleted file mode 100644 index c464f81a6bb2547..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-23-18-42-37.gh-issue-143990.o65v7O.rst +++ /dev/null @@ -1,6 +0,0 @@ -:class:`tkinter.font.Font` can now wrap a font description without creating a -new named font, by passing it as *font* with ``exists=True`` and no *name*. -This avoids a loss of precision in :meth:`~tkinter.font.Font.actual`, -:meth:`~tkinter.font.Font.measure` and :meth:`~tkinter.font.Font.metrics`. -Keyword options now override the corresponding settings of the given *font* -instead of being ignored. diff --git a/Misc/NEWS.d/next/Library/2026-06-23-22-15-00.gh-issue-152033.Ct1Egy.rst b/Misc/NEWS.d/next/Library/2026-06-23-22-15-00.gh-issue-152033.Ct1Egy.rst deleted file mode 100644 index 7c54a6c16c1a145..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-23-22-15-00.gh-issue-152033.Ct1Egy.rst +++ /dev/null @@ -1,5 +0,0 @@ -Optimize matching of character class escapes (``\d``, ``\D``, ``\s``, -``\S``, ``\w`` and ``\W``) that occur outside a character set: they are now -compiled to a single ``CATEGORY`` opcode instead of being wrapped in an -``IN`` block. This speeds up patterns such as ``\d+`` and reduces the size -of the compiled byte code. diff --git a/Misc/NEWS.d/next/Library/2026-06-24-10-30-00.gh-issue-152056.Qk7mZ2.rst b/Misc/NEWS.d/next/Library/2026-06-24-10-30-00.gh-issue-152056.Qk7mZ2.rst deleted file mode 100644 index 6e71d720cd19be2..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-24-10-30-00.gh-issue-152056.Qk7mZ2.rst +++ /dev/null @@ -1,5 +0,0 @@ -Optimize matching of a character set that contains a single character -category, such as ``[\d]`` or ``[^\s]``: it is now compiled to a single -``CATEGORY`` opcode, the same as the corresponding ``\d`` or ``\S`` escape, -instead of being wrapped in an ``IN`` block. This speeds up matching and -reduces the size of the compiled byte code. Patch by Pieter Eendebak. diff --git a/Misc/NEWS.d/next/Library/2026-06-24-10-46-35.gh-issue-152060.f2asrt.rst b/Misc/NEWS.d/next/Library/2026-06-24-10-46-35.gh-issue-152060.f2asrt.rst deleted file mode 100644 index 6088a6b80829bb4..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-24-10-46-35.gh-issue-152060.f2asrt.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix :meth:`datetime.datetime.fromisoformat` raising :exc:`AssertionError` -instead of :exc:`ValueError` for some malformed strings in the pure-Python -implementation, matching the C implementation. diff --git a/Misc/NEWS.d/next/Library/2026-06-24-12-00-00.gh-issue-152052.yBssDE.rst b/Misc/NEWS.d/next/Library/2026-06-24-12-00-00.gh-issue-152052.yBssDE.rst deleted file mode 100644 index f9ffbbd342fc81a..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-24-12-00-00.gh-issue-152052.yBssDE.rst +++ /dev/null @@ -1,2 +0,0 @@ -The :mod:`json` C accelerator now correctly reports an unterminated string for a -``\uXXXX`` escape at the end of the input. diff --git a/Misc/NEWS.d/next/Library/2026-06-24-12-00-00.gh-issue-152079.f1tzus.rst b/Misc/NEWS.d/next/Library/2026-06-24-12-00-00.gh-issue-152079.f1tzus.rst deleted file mode 100644 index 492d00724f6a46e..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-24-12-00-00.gh-issue-152079.f1tzus.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix :meth:`datetime.datetime.fromisoformat` in the C implementation dropping -the sub-second part of a UTC offset whose whole-second part is zero, matching -the pure-Python implementation. diff --git a/Misc/NEWS.d/next/Library/2026-06-24-12-00-00.gh-issue-152100.Set0ps.rst b/Misc/NEWS.d/next/Library/2026-06-24-12-00-00.gh-issue-152100.Set0ps.rst deleted file mode 100644 index 848740ed7a56d31..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-24-12-00-00.gh-issue-152100.Set0ps.rst +++ /dev/null @@ -1,3 +0,0 @@ -Support set operations and nested sets in regular expression character -classes, as described in Unicode Technical Standard #18: set difference -(``[A--B]``), intersection (``[A&&B]``) and union (``[A||B]``). diff --git a/Misc/NEWS.d/next/Library/2026-06-24-16-08-44.gh-issue-152074.PsbS-I.rst b/Misc/NEWS.d/next/Library/2026-06-24-16-08-44.gh-issue-152074.PsbS-I.rst deleted file mode 100644 index 05e61670582dd8b..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-24-16-08-44.gh-issue-152074.PsbS-I.rst +++ /dev/null @@ -1 +0,0 @@ -Increase the buffer size to 256 KiB in :meth:`asyncio.loop.sendfile` method fallback. diff --git a/Misc/NEWS.d/next/Library/2026-06-24-16-40-15.gh-issue-151378.iYWa_6.rst b/Misc/NEWS.d/next/Library/2026-06-24-16-40-15.gh-issue-151378.iYWa_6.rst deleted file mode 100644 index 0b3eb860ba8d329..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-24-16-40-15.gh-issue-151378.iYWa_6.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a bug in the binary collector in Tachyon that caused unbounded memory -growth while profiling a thread that stayed asleep. Patch by Maurycy -Pawłowski-Wieroński. diff --git a/Misc/NEWS.d/next/Library/2026-06-24-22-16-35.gh-issue-105895.hRkuEw.rst b/Misc/NEWS.d/next/Library/2026-06-24-22-16-35.gh-issue-105895.hRkuEw.rst deleted file mode 100644 index c69e6fa7d14f4dc..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-24-22-16-35.gh-issue-105895.hRkuEw.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add :keyword:`match` and :keyword:`case` to the list of supported topics by -:func:`help`. diff --git a/Misc/NEWS.d/next/Library/2026-06-24-23-28-42.gh-issue-151669.tPUavQ.rst b/Misc/NEWS.d/next/Library/2026-06-24-23-28-42.gh-issue-151669.tPUavQ.rst deleted file mode 100644 index d8e4850ba94e140..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-24-23-28-42.gh-issue-151669.tPUavQ.rst +++ /dev/null @@ -1,3 +0,0 @@ -On Windows, when populating tar archives from filesystem content, to -conform to the tar format standard, backslashes in symlink targets are -be replaced by slashes. diff --git a/Misc/NEWS.d/next/Library/2026-06-25-01-00-43.gh-issue-151763.wWeHBe.rst b/Misc/NEWS.d/next/Library/2026-06-25-01-00-43.gh-issue-151763.wWeHBe.rst deleted file mode 100644 index 2f5e84027ad31bb..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-25-01-00-43.gh-issue-151763.wWeHBe.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix crash in :func:`!_interpqueues.create` whe :exc:`MemoryError` -happens on queue creation. diff --git a/Misc/NEWS.d/next/Library/2026-06-25-07-08-17.gh-issue-152157.dt5Ef0.rst b/Misc/NEWS.d/next/Library/2026-06-25-07-08-17.gh-issue-152157.dt5Ef0.rst deleted file mode 100644 index 00e83b4af6be7a9..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-25-07-08-17.gh-issue-152157.dt5Ef0.rst +++ /dev/null @@ -1,3 +0,0 @@ -The C implementations of :meth:`~datetime.datetime.fromisoformat` and :meth:`~datetime.time.fromisoformat` -now reject a decimal separator that is not followed by any -fractional digit before a timezone designator. diff --git a/Misc/NEWS.d/next/Library/2026-06-25-10-07-54.gh-issue-152156.gscPU9.rst b/Misc/NEWS.d/next/Library/2026-06-25-10-07-54.gh-issue-152156.gscPU9.rst deleted file mode 100644 index 30e561274dc50c2..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-25-10-07-54.gh-issue-152156.gscPU9.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a possible crash in :func:`concurrent.interpreters.create` under limited -memory conditions. diff --git a/Misc/NEWS.d/next/Library/2026-06-25-12-00-00.gh-issue-152212.Zk7Qm2.rst b/Misc/NEWS.d/next/Library/2026-06-25-12-00-00.gh-issue-152212.Zk7Qm2.rst deleted file mode 100644 index 2b1d272638b11ab..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-25-12-00-00.gh-issue-152212.Zk7Qm2.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix the pure-Python :mod:`zoneinfo` parser accepting a POSIX TZ string with a -``std`` abbreviation but no offset. This is invalid per POSIX and now -raises :exc:`ValueError`, matching the C accelerator. Patch by tonghuaroot. diff --git a/Misc/NEWS.d/next/Library/2026-06-25-14-32-42.gh-issue-139145.kT9rmP.rst b/Misc/NEWS.d/next/Library/2026-06-25-14-32-42.gh-issue-139145.kT9rmP.rst deleted file mode 100644 index 3fa639c5f727baa..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-25-14-32-42.gh-issue-139145.kT9rmP.rst +++ /dev/null @@ -1,5 +0,0 @@ -Fix a busy loop in :mod:`tkinter` on interactive Python. When a Tcl command -running its own event loop (such as ``vwait`` or :meth:`!wait_variable`) was -active and input arrived on stdin, the event loop kept spinning at 100% CPU. -The stdin file handler is now removed as soon as input is available. Based on -a patch by Michiel de Hoon. diff --git a/Misc/NEWS.d/next/Library/2026-06-25-14-32-43.gh-issue-139816.Lq2vXa.rst b/Misc/NEWS.d/next/Library/2026-06-25-14-32-43.gh-issue-139816.Lq2vXa.rst deleted file mode 100644 index b180dee686caf8c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-25-14-32-43.gh-issue-139816.Lq2vXa.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix a hang in :mod:`tkinter` on interactive Python built without -:mod:`readline`. An exception raised in a callback no longer causes the -event loop to stop and wait for the user to press Enter; pending callbacks -now keep running until input is actually available on stdin. diff --git a/Misc/NEWS.d/next/Library/2026-06-25-19-44-16.gh-issue-152219.ndj4Ib.rst b/Misc/NEWS.d/next/Library/2026-06-25-19-44-16.gh-issue-152219.ndj4Ib.rst deleted file mode 100644 index e7ea6011cb7b50c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-25-19-44-16.gh-issue-152219.ndj4Ib.rst +++ /dev/null @@ -1,5 +0,0 @@ -Add the :mod:`curses` window methods :meth:`~curses.window.attr_get`, -:meth:`~curses.window.attr_set`, :meth:`~curses.window.attr_on`, -:meth:`~curses.window.attr_off` and :meth:`~curses.window.color_set`, which use -a separate color pair argument instead of packing it into the attribute value, -and the corresponding ``WA_*`` attribute constants. diff --git a/Misc/NEWS.d/next/Library/2026-06-25-20-00-00.gh-issue-151496.kMnT3x.rst b/Misc/NEWS.d/next/Library/2026-06-25-20-00-00.gh-issue-151496.kMnT3x.rst deleted file mode 100644 index 994e5dadcf2e8a0..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-25-20-00-00.gh-issue-151496.kMnT3x.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fixed ``profiling.sampling --gecko`` with ``--async-aware`` by flattening -async task stacks before generating Gecko samples. ``--binary`` now rejects -``--async-aware`` until the binary format supports async task data. diff --git a/Misc/NEWS.d/next/Library/2026-06-25-22-19-04.gh-issue-152099.L7fKq9.rst b/Misc/NEWS.d/next/Library/2026-06-25-22-19-04.gh-issue-152099.L7fKq9.rst deleted file mode 100644 index 05e760bcf6ed6d3..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-25-22-19-04.gh-issue-152099.L7fKq9.rst +++ /dev/null @@ -1,4 +0,0 @@ -``asyncio``'s ``loop.sendfile(..., fallback=False)`` now consistently raises -:exc:`asyncio.SendfileNotAvailableError` for fallback-only transports, such as -SSL/TLS transports, when native sendfile cannot be used. Previously, this case -raised :exc:`RuntimeError`. diff --git a/Misc/NEWS.d/next/Library/2026-06-25-22-41-49.gh-issue-152233.pEhm3q.rst b/Misc/NEWS.d/next/Library/2026-06-25-22-41-49.gh-issue-152233.pEhm3q.rst deleted file mode 100644 index 43895aafe6ce136..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-25-22-41-49.gh-issue-152233.pEhm3q.rst +++ /dev/null @@ -1,9 +0,0 @@ -Add the :class:`curses.complexchar` type, representing a styled character -cell (text, attributes and color pair), and the :mod:`curses` window methods -:meth:`~curses.window.in_wch` and :meth:`~curses.window.getbkgrnd` that return -one. The character-cell methods (:meth:`~curses.window.addch`, -:meth:`~curses.window.bkgd`, :meth:`~curses.window.border`, -:meth:`~curses.window.hline` and others) now also accept a -:class:`~curses.complexchar`. This works whether or not Python was built -against a wide-character-aware curses library; on a narrow build a cell holds a -single character representable as one byte in the window's encoding. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-11-20-00.gh-issue-152233.Kp7mQ2.rst b/Misc/NEWS.d/next/Library/2026-06-26-11-20-00.gh-issue-152233.Kp7mQ2.rst deleted file mode 100644 index b905b512a8a12af..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-11-20-00.gh-issue-152233.Kp7mQ2.rst +++ /dev/null @@ -1,8 +0,0 @@ -Add the :class:`curses.complexstr` type, an immutable string of styled -character cells (the counterpart of :class:`curses.complexchar`), and the -:mod:`curses` window method :meth:`~curses.window.in_wchstr` that returns one. -The string-cell methods :meth:`~curses.window.addstr`, -:meth:`~curses.window.addnstr`, :meth:`~curses.window.insstr` and -:meth:`~curses.window.insnstr` now also accept a :class:`~curses.complexstr`. -Like :class:`curses.complexchar`, it works whether or not Python was built -against a wide-character-aware curses library. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-12-50-26.gh-issue-152246.MfXMd1.rst b/Misc/NEWS.d/next/Library/2026-06-26-12-50-26.gh-issue-152246.MfXMd1.rst deleted file mode 100644 index 0858199a9fa2798..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-12-50-26.gh-issue-152246.MfXMd1.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix the pure-Python :mod:`zoneinfo` parser accepting an invalid POSIX TZ -transition rule with a non-period separator. Patch by tonghuaroot. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-13-10-00.gh-issue-80937.Hq3mNp.rst b/Misc/NEWS.d/next/Library/2026-06-26-13-10-00.gh-issue-80937.Hq3mNp.rst deleted file mode 100644 index 4ea0179c6586d4f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-13-10-00.gh-issue-80937.Hq3mNp.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix a memory leak in :mod:`tkinter` when a Tcl command created with -``createcommand`` was not explicitly removed before the interpreter was -deleted. The command no longer keeps the interpreter alive through a -reference cycle. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-13-39-11.gh-issue-152248.N2Rmaf.rst b/Misc/NEWS.d/next/Library/2026-06-26-13-39-11.gh-issue-152248.N2Rmaf.rst deleted file mode 100644 index 8921ad17349e975..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-13-39-11.gh-issue-152248.N2Rmaf.rst +++ /dev/null @@ -1,3 +0,0 @@ -Make the C and pure-Python :mod:`zoneinfo` parsers validate POSIX TZ -abbreviations consistently, rejecting unquoted abbreviations with non-letter -characters and empty quoted abbreviations. Patch by tonghuaroot. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-13-40-00.gh-issue-152258.Qe7Lm3.rst b/Misc/NEWS.d/next/Library/2026-06-26-13-40-00.gh-issue-152258.Qe7Lm3.rst deleted file mode 100644 index b2a0e776ce9c41c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-13-40-00.gh-issue-152258.Qe7Lm3.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add the :mod:`curses` window method :meth:`~curses.window.dupwin`, which -returns a new window that is an independent duplicate of an existing one. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-14-05-00.gh-issue-116946.Kp7raZ.rst b/Misc/NEWS.d/next/Library/2026-06-26-14-05-00.gh-issue-116946.Kp7raZ.rst deleted file mode 100644 index 95957b7d9d9894e..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-14-05-00.gh-issue-116946.Kp7raZ.rst +++ /dev/null @@ -1,3 +0,0 @@ -The internal :mod:`!_tkinter` ``tkapp`` and ``tktimertoken`` types now -implement the garbage collector protocol, so reference cycles involving a -Tcl interpreter or a timer handler can be collected. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-14-34-28.gh-issue-152263.5PHQP4.rst b/Misc/NEWS.d/next/Library/2026-06-26-14-34-28.gh-issue-152263.5PHQP4.rst deleted file mode 100644 index 7367f84c6f474ce..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-14-34-28.gh-issue-152263.5PHQP4.rst +++ /dev/null @@ -1,9 +0,0 @@ -Add the soft-label-key functions to the :mod:`curses` module: -:func:`~curses.slk_init`, :func:`~curses.slk_set`, :func:`~curses.slk_label`, -:func:`~curses.slk_refresh`, :func:`~curses.slk_noutrefresh`, -:func:`~curses.slk_clear`, :func:`~curses.slk_restore`, -:func:`~curses.slk_touch`, :func:`~curses.slk_attron`, -:func:`~curses.slk_attroff`, :func:`~curses.slk_attrset`, -:func:`~curses.slk_attr`, :func:`~curses.slk_attr_on`, -:func:`~curses.slk_attr_off`, :func:`~curses.slk_attr_set` and -:func:`~curses.slk_color`. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-15-00-00.gh-issue-38464.yDPjKH.rst b/Misc/NEWS.d/next/Library/2026-06-26-15-00-00.gh-issue-38464.yDPjKH.rst deleted file mode 100644 index c1c272b97d4b0a8..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-15-00-00.gh-issue-38464.yDPjKH.rst +++ /dev/null @@ -1,3 +0,0 @@ -:meth:`!tkinter.Misc.nametowidget` now resolves the auto-generated names of -cloned menus (a menu used as a menubar or a cascade) back to the original -widget. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-15-10-00.gh-issue-152260.Rk4nP9.rst b/Misc/NEWS.d/next/Library/2026-06-26-15-10-00.gh-issue-152260.Rk4nP9.rst deleted file mode 100644 index 8c396009815399d..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-15-10-00.gh-issue-152260.Rk4nP9.rst +++ /dev/null @@ -1,3 +0,0 @@ -Add the :mod:`curses` functions :func:`~curses.scr_dump`, -:func:`~curses.scr_restore`, :func:`~curses.scr_init` and -:func:`~curses.scr_set`, which dump the whole screen to a file and restore it. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-15-30-00.gh-issue-88758.Qw7nLp.rst b/Misc/NEWS.d/next/Library/2026-06-26-15-30-00.gh-issue-88758.Qw7nLp.rst deleted file mode 100644 index 31d567194fb9031..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-15-30-00.gh-issue-88758.Qw7nLp.rst +++ /dev/null @@ -1,4 +0,0 @@ -:meth:`!tkinter.Misc.focus_get`, :meth:`!focus_displayof`, -:meth:`!focus_lastfor` and :meth:`!winfo_containing` now return ``None`` -instead of raising :exc:`KeyError` when the widget was not created by -:mod:`tkinter` (for example a torn-off menu). diff --git a/Misc/NEWS.d/next/Library/2026-06-26-15-41-34.gh-issue-152305.WnbbBc.rst b/Misc/NEWS.d/next/Library/2026-06-26-15-41-34.gh-issue-152305.WnbbBc.rst deleted file mode 100644 index 4f27e2ed016d694..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-15-41-34.gh-issue-152305.WnbbBc.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix the pure-Python :meth:`datetime.time.strftime` implementation raising :exc:`AttributeError` for the -year directives. Patch by tonghuaroot. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-16-30-00.gh-issue-83274.Kx9mQv.rst b/Misc/NEWS.d/next/Library/2026-06-26-16-30-00.gh-issue-83274.Kx9mQv.rst deleted file mode 100644 index 3b722d2176be920..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-16-30-00.gh-issue-83274.Kx9mQv.rst +++ /dev/null @@ -1,3 +0,0 @@ -Deallocating a :mod:`tkinter` application from a thread other than the one it -was created in no longer crashes the interpreter. The underlying Tcl -interpreter is leaked instead, and a :exc:`RuntimeWarning` is reported. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-17-18-01.gh-issue-152275.V64zKa.rst b/Misc/NEWS.d/next/Library/2026-06-26-17-18-01.gh-issue-152275.V64zKa.rst deleted file mode 100644 index ec33586df1a7381..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-17-18-01.gh-issue-152275.V64zKa.rst +++ /dev/null @@ -1,7 +0,0 @@ -The :mod:`curses` module now raises :exc:`OverflowError` instead of silently -truncating an out-of-range value: :func:`curses.color_pair` rejects a color -pair number that does not fit in the ``chtype`` color field, and the -``attr`` argument of the character-cell and attribute methods -(:meth:`~curses.window.addch`, :meth:`~curses.window.addstr`, -:meth:`~curses.window.attron`, :meth:`~curses.window.attrset` and others) is -checked against the ``chtype`` range. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-19-01-13.gh-issue-121249.p1SBW0.rst b/Misc/NEWS.d/next/Library/2026-06-26-19-01-13.gh-issue-121249.p1SBW0.rst deleted file mode 100644 index 0e676e7774d1d7a..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-19-01-13.gh-issue-121249.p1SBW0.rst +++ /dev/null @@ -1 +0,0 @@ -Deprecate using ``'F'`` and ``'D'`` type codes in the :mod:`struct` module. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-21-30-00.gh-issue-152325.Km9xQr.rst b/Misc/NEWS.d/next/Library/2026-06-26-21-30-00.gh-issue-152325.Km9xQr.rst deleted file mode 100644 index 655f61cbb530b12..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-21-30-00.gh-issue-152325.Km9xQr.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add the :func:`curses.has_mouse` function and the -:meth:`curses.window.mouse_trafo` method. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-22-06-07.gh-issue-87904.F71C70.rst b/Misc/NEWS.d/next/Library/2026-06-26-22-06-07.gh-issue-87904.F71C70.rst deleted file mode 100644 index 09bd5a06836df7d..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-22-06-07.gh-issue-87904.F71C70.rst +++ /dev/null @@ -1,4 +0,0 @@ -The :mod:`curses` types and exceptions now report their public module in -:attr:`~type.__module__`, :func:`repr` and :func:`help` -- for example -``curses.window`` instead of ``_curses.window`` and ``curses.panel.error`` -instead of ``_curses_panel.error``. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-22-15-00.gh-issue-152332.Lp3WqN.rst b/Misc/NEWS.d/next/Library/2026-06-26-22-15-00.gh-issue-152332.Lp3WqN.rst deleted file mode 100644 index 32875cdac5c9d0c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-22-15-00.gh-issue-152332.Lp3WqN.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add the :func:`curses.term_attrs` function, the counterpart of -:func:`curses.termattrs` for the ``WA_*`` attributes. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-22-50-00.gh-issue-152334.Mt7vQx.rst b/Misc/NEWS.d/next/Library/2026-06-26-22-50-00.gh-issue-152334.Mt7vQx.rst deleted file mode 100644 index 8d24ebfde8f1eca..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-22-50-00.gh-issue-152334.Mt7vQx.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add the :func:`curses.define_key`, :func:`curses.key_defined` and -:func:`curses.keyok` key-management functions. diff --git a/Misc/NEWS.d/next/Library/2026-06-26-23-56-40.gh-issue-71880.782D31.rst b/Misc/NEWS.d/next/Library/2026-06-26-23-56-40.gh-issue-71880.782D31.rst deleted file mode 100644 index 5a12f428f2a8b6c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-26-23-56-40.gh-issue-71880.782D31.rst +++ /dev/null @@ -1,5 +0,0 @@ -:class:`curses.textpad.Textbox` now lets the lower-right cell of the window be -edited. Writing it with :meth:`~curses.window.addch` would move the cursor -past the end of the window, raising an error and scrolling a scrollable window, -so it is now written with :meth:`~curses.window.insch`, which keeps the cursor -in place. diff --git a/Misc/NEWS.d/next/Library/2026-06-27-11-32-37.gh-issue-50409.Pw3Kq9.rst b/Misc/NEWS.d/next/Library/2026-06-27-11-32-37.gh-issue-50409.Pw3Kq9.rst deleted file mode 100644 index 479a2a3a8e12527..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-27-11-32-37.gh-issue-50409.Pw3Kq9.rst +++ /dev/null @@ -1,4 +0,0 @@ -Deprecate the *tagOrId* parameter of -:meth:`!tkinter.PanedWindow.paneconfigure` (and its :meth:`!paneconfig` -alias) in favor of *child*, for consistency with the other pane methods; -it will be removed in Python 3.18. diff --git a/Misc/NEWS.d/next/Library/2026-06-27-12-00-00.gh-issue-43699.Zt46MI.rst b/Misc/NEWS.d/next/Library/2026-06-27-12-00-00.gh-issue-43699.Zt46MI.rst deleted file mode 100644 index 93a9864d2445e94..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-27-12-00-00.gh-issue-43699.Zt46MI.rst +++ /dev/null @@ -1,3 +0,0 @@ -The drag cursor in :mod:`tkinter.dnd` is now changed only once the pointer -starts moving rather than on the initial button press, so that a plain -click no longer flashes it. diff --git a/Misc/NEWS.d/next/Library/2026-06-27-12-30-00.gh-issue-133031.Na8Bit.rst b/Misc/NEWS.d/next/Library/2026-06-27-12-30-00.gh-issue-133031.Na8Bit.rst deleted file mode 100644 index 96e9efe20e42f04..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-27-12-30-00.gh-issue-133031.Na8Bit.rst +++ /dev/null @@ -1,3 +0,0 @@ -:class:`curses.textpad.Textbox` now enters and reads back the non-ASCII -characters of an 8-bit locale encoding, instead of mangling them with a 7-bit -mask. diff --git a/Misc/NEWS.d/next/Library/2026-06-27-12-45-00.gh-issue-133031.Wide00.rst b/Misc/NEWS.d/next/Library/2026-06-27-12-45-00.gh-issue-133031.Wide00.rst deleted file mode 100644 index c33365910ae2896..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-27-12-45-00.gh-issue-133031.Wide00.rst +++ /dev/null @@ -1,3 +0,0 @@ -:class:`curses.textpad.Textbox` now supports entering and reading back the full -Unicode range, including combining characters, when curses is built with -wide-character support. diff --git a/Misc/NEWS.d/next/Library/2026-06-27-17-19-09.gh-issue-151126.huUyOM.rst b/Misc/NEWS.d/next/Library/2026-06-27-17-19-09.gh-issue-151126.huUyOM.rst deleted file mode 100644 index 2e51fd45b595486..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-27-17-19-09.gh-issue-151126.huUyOM.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix two crashes in :mod:`tkinter` and :mod:`socket` modules initialization -under a memory pressure. Sets missing :exc:`MemoryError`. diff --git a/Misc/NEWS.d/next/Library/2026-06-27-19-02-17.gh-issue-103878.216fa7.rst b/Misc/NEWS.d/next/Library/2026-06-27-19-02-17.gh-issue-103878.216fa7.rst deleted file mode 100644 index dd5b8c2545fe653..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-27-19-02-17.gh-issue-103878.216fa7.rst +++ /dev/null @@ -1,8 +0,0 @@ -The :mod:`tkinter.filedialog` functions that return a filename -(:func:`~tkinter.filedialog.askopenfilename`, -:func:`~tkinter.filedialog.asksaveasfilename` and -:func:`~tkinter.filedialog.askdirectory`) now consistently return an empty -string when the dialog is cancelled, instead of an empty tuple or ``b''`` -on some platforms. :func:`~tkinter.filedialog.askopenfilenames` likewise -always returns an empty tuple, and :func:`~tkinter.filedialog.askopenfiles` -an empty list. diff --git a/Misc/NEWS.d/next/Library/2026-06-28-00-00-00.gh-issue-152431.Ja3K9m.rst b/Misc/NEWS.d/next/Library/2026-06-28-00-00-00.gh-issue-152431.Ja3K9m.rst deleted file mode 100644 index bda2dfd7cd9d89b..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-28-00-00-00.gh-issue-152431.Ja3K9m.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix ``asyncio.StreamWriter.start_tls()`` to keep the linked -``StreamReader`` transport in sync with the upgraded transport. diff --git a/Misc/NEWS.d/next/Library/2026-06-28-11-00-40.gh-issue-78335.Kp3mWq.rst b/Misc/NEWS.d/next/Library/2026-06-28-11-00-40.gh-issue-78335.Kp3mWq.rst deleted file mode 100644 index 641889cfa9ef41d..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-28-11-00-40.gh-issue-78335.Kp3mWq.rst +++ /dev/null @@ -1,4 +0,0 @@ -Update the docstrings of :mod:`tkinter` and :mod:`tkinter.ttk` widget classes -to list all supported widget options, including options added in Tk 9.0 and -9.1. ``tkinter.Menubutton`` and ``tkinter.Message`` previously had no option -list at all. diff --git a/Misc/NEWS.d/next/Library/2026-06-28-12-00-00.gh-issue-152470.Wn7Kp3.rst b/Misc/NEWS.d/next/Library/2026-06-28-12-00-00.gh-issue-152470.Wn7Kp3.rst deleted file mode 100644 index 445e0a1b18f7dd7..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-28-12-00-00.gh-issue-152470.Wn7Kp3.rst +++ /dev/null @@ -1,9 +0,0 @@ -The wide-character :mod:`curses` functions and methods -:meth:`curses.window.get_wch`, :meth:`curses.window.get_wstr`, -:func:`curses.unget_wch`, :func:`curses.erasewchar`, :func:`curses.killwchar` -and :func:`curses.wunctrl` now also work when Python is not built against a -wide-character-aware curses library, on an 8-bit locale, where each character -is a single byte in the relevant encoding. :func:`curses.ungetch` now also -accepts a one-character string, like :func:`curses.unget_wch`; on a -wide-character build it can be any character (previously a multibyte character -raised :exc:`OverflowError`). diff --git a/Misc/NEWS.d/next/Library/2026-06-28-12-45-09.gh-issue-152356.Dr4w2Q.rst b/Misc/NEWS.d/next/Library/2026-06-28-12-45-09.gh-issue-152356.Dr4w2Q.rst deleted file mode 100644 index 6a4ceecbe9279e2..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-28-12-45-09.gh-issue-152356.Dr4w2Q.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a hang in ``profiling.sampling run --blocking`` on Windows when the -target process exits. The profiler now finalizes binary profiles instead of -continuing to sample the exited process. diff --git a/Misc/NEWS.d/next/Library/2026-06-28-16-20-07.gh-issue-152503.N55ose.rst b/Misc/NEWS.d/next/Library/2026-06-28-16-20-07.gh-issue-152503.N55ose.rst deleted file mode 100644 index e97c5d74600c67f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-28-16-20-07.gh-issue-152503.N55ose.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix :meth:`curses.window.in_wch`, :meth:`curses.window.in_wchstr` and -:meth:`curses.window.getbkgrnd` returning garbage text when :mod:`curses` is -built against a curses library that does not NUL-terminate the ``cchar_t`` -text array (such as NetBSD curses). diff --git a/Misc/NEWS.d/next/Library/2026-06-29-01-08-53.gh-issue-110357.QGWdZQ.rst b/Misc/NEWS.d/next/Library/2026-06-29-01-08-53.gh-issue-110357.QGWdZQ.rst deleted file mode 100644 index 7c2384ea76fe531..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-29-01-08-53.gh-issue-110357.QGWdZQ.rst +++ /dev/null @@ -1,6 +0,0 @@ -Importing :mod:`hashlib` no longer logs an error to stderr when a normally -guaranteed hash algorithm is unavailable in the current runtime (for example -under an OpenSSL FIPS configuration or a build using -:option:`--without-builtin-hashlib-hashes <--with-builtin-hashlib-hashes>`). -Code that actually uses the missing algorithm still gets a clear -:exc:`ValueError`. diff --git a/Misc/NEWS.d/next/Library/2026-06-29-09-45-00.gh-issue-152569.Kf7Lq2.rst b/Misc/NEWS.d/next/Library/2026-06-29-09-45-00.gh-issue-152569.Kf7Lq2.rst deleted file mode 100644 index fb7e32a5260b39a..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-29-09-45-00.gh-issue-152569.Kf7Lq2.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix :func:`asyncio.wait` leaking waiting tasks via the await-graph when racing a -future that never resolves. The waiting task is now discarded from every future's -``awaited_by`` set once :func:`~asyncio.wait` returns, even for pending futures. diff --git a/Misc/NEWS.d/next/Library/2026-06-29-12-50-28.gh-issue-152587.Lq8wVn.rst b/Misc/NEWS.d/next/Library/2026-06-29-12-50-28.gh-issue-152587.Lq8wVn.rst deleted file mode 100644 index e3a9618c6480bc2..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-29-12-50-28.gh-issue-152587.Lq8wVn.rst +++ /dev/null @@ -1,5 +0,0 @@ -In :mod:`tkinter`, the *name* parameter of the -:meth:`~tkinter.Misc.wait_variable`, :meth:`~tkinter.Misc.setvar` and -:meth:`~tkinter.Misc.getvar` methods and the *value* parameter of -:meth:`!setvar` are now required. Their former default values -(``'PY_VAR'`` and ``'1'``) were not meaningful. diff --git a/Misc/NEWS.d/next/Library/2026-06-29-21-59-08.gh-issue-152638.92dpzo.rst b/Misc/NEWS.d/next/Library/2026-06-29-21-59-08.gh-issue-152638.92dpzo.rst deleted file mode 100644 index 3fbffb03cb38961..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-29-21-59-08.gh-issue-152638.92dpzo.rst +++ /dev/null @@ -1,4 +0,0 @@ -Deprecate :func:`tkinter.filedialog.askopenfiles`. Opening several files at -once is error-prone and the returned list cannot be used in a :keyword:`with` -statement; iterate over the names returned by -:func:`tkinter.filedialog.askopenfilenames` and open them one by one instead. diff --git a/Misc/NEWS.d/next/Library/2026-06-29-22-16-57.gh-issue-50966.Tq5mLp.rst b/Misc/NEWS.d/next/Library/2026-06-29-22-16-57.gh-issue-50966.Tq5mLp.rst deleted file mode 100644 index 96a0938c02d226b..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-29-22-16-57.gh-issue-50966.Tq5mLp.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix unbounded recursion in :mod:`turtle` when a mouse event handler that moves -the turtle is reentered while the screen is being redrawn, for example with -``screen.ondrag(turtle.goto)``. This could previously crash the interpreter. diff --git a/Misc/NEWS.d/next/Library/2026-06-30-12-00-00.gh-issue-40038.qK7mGv.rst b/Misc/NEWS.d/next/Library/2026-06-30-12-00-00.gh-issue-40038.qK7mGv.rst deleted file mode 100644 index 1f393d23266bcef..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-30-12-00-00.gh-issue-40038.qK7mGv.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`imaplib` now again quotes command arguments when necessary, for -example mailbox names containing a space. Such quoting was inadvertently -disabled when the module was ported to Python 3, and the arguments are now -quoted according to the :rfc:`3501` grammar. For backward compatibility, -an argument already enclosed in double quotes is left unchanged, so code -that quotes arguments itself keeps working. diff --git a/Misc/NEWS.d/next/Library/2026-06-30-13-00-00.gh-issue-151842.OOM31g.rst b/Misc/NEWS.d/next/Library/2026-06-30-13-00-00.gh-issue-151842.OOM31g.rst deleted file mode 100644 index 8a2ecf3c40032f5..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-30-13-00-00.gh-issue-151842.OOM31g.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a crash in :func:`!_interpreters.capture_exception` when -:exc:`MemoryError` happens. Patch by Amrutha Modela. diff --git a/Misc/NEWS.d/next/Library/2026-06-30-14-30-00.gh-issue-152502.Mq7Kx2.rst b/Misc/NEWS.d/next/Library/2026-06-30-14-30-00.gh-issue-152502.Mq7Kx2.rst deleted file mode 100644 index 6f343f0ab0c162e..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-06-30-14-30-00.gh-issue-152502.Mq7Kx2.rst +++ /dev/null @@ -1,6 +0,0 @@ -Detect the :mod:`curses` mouse interface (:func:`~curses.getmouse`, -:func:`~curses.has_mouse`, the ``BUTTON*`` constants, and others) and the -window ``is_*`` state-query methods with configure capability probes or library -macros instead of gating them on ncurses-specific macros. They are now also -available with other curses implementations that provide them, such as NetBSD -curses and PDCurses (the latter underpins ``windows-curses``). diff --git a/Misc/NEWS.d/next/Library/2026-07-01-10-00-00.gh-issue-88574.Kz3wQm.rst b/Misc/NEWS.d/next/Library/2026-07-01-10-00-00.gh-issue-88574.Kz3wQm.rst deleted file mode 100644 index 371f4d08bccd2e2..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-01-10-00-00.gh-issue-88574.Kz3wQm.rst +++ /dev/null @@ -1,4 +0,0 @@ -:mod:`imaplib` no longer fails when a server sends a spurious blank line -after the counted data of a literal, including after a literal that -terminates a response (such as a mailbox name returned by ``LIST``). -Such blank lines are now skipped without swallowing the following line. diff --git a/Misc/NEWS.d/next/Library/2026-07-01-10-30-00.gh-issue-63121.Rm4tZp.rst b/Misc/NEWS.d/next/Library/2026-07-01-10-30-00.gh-issue-63121.Rm4tZp.rst deleted file mode 100644 index a63b164ad7a627b..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-01-10-30-00.gh-issue-63121.Rm4tZp.rst +++ /dev/null @@ -1,7 +0,0 @@ -:mod:`imaplib` now refreshes the cached capability list after a successful -:meth:`~imaplib.IMAP4.login` or :meth:`~imaplib.IMAP4.authenticate`, using -the ``CAPABILITY`` response sent by the server or, if none was sent, by -querying it, so that capabilities that become available only after -authentication (such as ``ENABLE`` on Gmail) are recognized. Capabilities -advertised in the server greeting are now also used, avoiding a redundant -``CAPABILITY`` command. diff --git a/Misc/NEWS.d/next/Library/2026-07-01-11-29-13.gh-issue-151126.eElGy5.rst b/Misc/NEWS.d/next/Library/2026-07-01-11-29-13.gh-issue-151126.eElGy5.rst deleted file mode 100644 index d5ec1d254ef056e..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-01-11-29-13.gh-issue-151126.eElGy5.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a crash caused by failing to set :exc:`MemoryError` on allocation failure -when passing :class:`ctypes.Structure` or :class:`ctypes.Union` instances by -value to ctypes foreign functions. diff --git a/Misc/NEWS.d/next/Library/2026-07-01-12-00-00.gh-issue-108280.Nq8vTr.rst b/Misc/NEWS.d/next/Library/2026-07-01-12-00-00.gh-issue-108280.Nq8vTr.rst deleted file mode 100644 index 487c9da67f1832b..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-01-12-00-00.gh-issue-108280.Nq8vTr.rst +++ /dev/null @@ -1,4 +0,0 @@ -Connecting :mod:`imaplib` to a server that does not send a valid IMAP4 -greeting (for example a POP3 server answering on the IMAP port) now raises -an error reporting the server's response instead of -``imaplib.IMAP4.error: None``. diff --git a/Misc/NEWS.d/next/Library/2026-07-01-12-00-00.gh-issue-152718.pr0f1l.rst b/Misc/NEWS.d/next/Library/2026-07-01-12-00-00.gh-issue-152718.pr0f1l.rst deleted file mode 100644 index 63d9d7f878cb07d..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-01-12-00-00.gh-issue-152718.pr0f1l.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix unbounded memory allocation in the :mod:`profiling.sampling` binary profile -reader when a file declares more string or frame entries than it contains. diff --git a/Misc/NEWS.d/next/Library/2026-07-01-14-00-00.gh-issue-49680.Lm5rQv.rst b/Misc/NEWS.d/next/Library/2026-07-01-14-00-00.gh-issue-49680.Lm5rQv.rst deleted file mode 100644 index 6371df69e69077f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-01-14-00-00.gh-issue-49680.Lm5rQv.rst +++ /dev/null @@ -1,4 +0,0 @@ -Add the *translate_line_endings* parameter to :meth:`imaplib.IMAP4.append`. -By default line endings in the message are translated to CRLF, as before; -passing ``False`` sends the message literal exactly as given, preserving -bare CR or LF octets. diff --git a/Misc/NEWS.d/next/Library/2026-07-01-15-30-00.gh-issue-77508.Bn2kXt.rst b/Misc/NEWS.d/next/Library/2026-07-01-15-30-00.gh-issue-77508.Bn2kXt.rst deleted file mode 100644 index d6f1bd23be080a3..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-01-15-30-00.gh-issue-77508.Bn2kXt.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add :meth:`imaplib.IMAP4.move`, a wrapper for the IMAP ``MOVE`` command -(:rfc:`6851`), analogous to :meth:`~imaplib.IMAP4.copy`. diff --git a/Misc/NEWS.d/next/Library/2026-07-01-22-59-25.gh-issue-152586.WuEae6.rst b/Misc/NEWS.d/next/Library/2026-07-01-22-59-25.gh-issue-152586.WuEae6.rst deleted file mode 100644 index 6c800551c906f2e..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-01-22-59-25.gh-issue-152586.WuEae6.rst +++ /dev/null @@ -1 +0,0 @@ -:class:`!tempfile._TemporaryFileWrapper` has been renamed to the public :class:`tempfile.TemporaryFileWrapper`. The old private name is kept as a deprecated alias and will be removed in Python 3.21. diff --git a/Misc/NEWS.d/next/Library/2026-07-01-23-17-27.gh-issue-152905.wLnGqR.rst b/Misc/NEWS.d/next/Library/2026-07-01-23-17-27.gh-issue-152905.wLnGqR.rst deleted file mode 100644 index 99f20e65ad8e08f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-01-23-17-27.gh-issue-152905.wLnGqR.rst +++ /dev/null @@ -1,3 +0,0 @@ -On glibc, :func:`locale.nl_langinfo` now decodes the ``LC_TIME`` items (such -as the month and day names) using the wide locale data, so the result no -longer depends on the ``LC_CTYPE`` encoding. diff --git a/Misc/NEWS.d/next/Library/2026-07-02-12-00-00.gh-issue-152847.PitKqc.rst b/Misc/NEWS.d/next/Library/2026-07-02-12-00-00.gh-issue-152847.PitKqc.rst deleted file mode 100644 index 3f20d78a201e84c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-02-12-00-00.gh-issue-152847.PitKqc.rst +++ /dev/null @@ -1,3 +0,0 @@ -Reject a POSIX TZ transition rule with non-digit characters in the -day-of-year field in the pure-Python :mod:`zoneinfo` parser. Patch by -tonghuaroot. diff --git a/Misc/NEWS.d/next/Library/2026-07-02-13-30-00.gh-issue-152849.K9dRvP.rst b/Misc/NEWS.d/next/Library/2026-07-02-13-30-00.gh-issue-152849.K9dRvP.rst deleted file mode 100644 index 053a5dfea3f3ff4..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-02-13-30-00.gh-issue-152849.K9dRvP.rst +++ /dev/null @@ -1,2 +0,0 @@ -Out-of-range float and integer timestamps now raise :exc:`OverflowError` -with the same message. Patch by tonghuaroot. diff --git a/Misc/NEWS.d/next/Library/2026-07-02-19-21-15.gh-issue-152068.ThsmJU.rst b/Misc/NEWS.d/next/Library/2026-07-02-19-21-15.gh-issue-152068.ThsmJU.rst deleted file mode 100644 index 9ec8413b4ac424c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-02-19-21-15.gh-issue-152068.ThsmJU.rst +++ /dev/null @@ -1 +0,0 @@ -Fixes a bug when a line was split (particularly on macOS Terminal.app) in the middle of a colorized keyword, causing the ANSI Color Reset sequence (ESC0m) to not be properly printed, causing the output to be colored when it shouldn't diff --git a/Misc/NEWS.d/next/Library/2026-07-02-22-19-53.gh-issue-150880.vPZ7jK.rst b/Misc/NEWS.d/next/Library/2026-07-02-22-19-53.gh-issue-150880.vPZ7jK.rst deleted file mode 100644 index a7bf210f8e1ca9c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-02-22-19-53.gh-issue-150880.vPZ7jK.rst +++ /dev/null @@ -1,3 +0,0 @@ -Normalize non-extended Windows paths before appending the wildcard used by -``os.listdir()`` and ``os.scandir()``, making paths with trailing spaces -behave consistently with other filesystem APIs. diff --git a/Misc/NEWS.d/next/Library/2026-07-03-14-54-33.gh-issue-152951.u8tPCI.rst b/Misc/NEWS.d/next/Library/2026-07-03-14-54-33.gh-issue-152951.u8tPCI.rst deleted file mode 100644 index c3d56c6d59c91b3..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-03-14-54-33.gh-issue-152951.u8tPCI.rst +++ /dev/null @@ -1,2 +0,0 @@ -:class:`collections.deque` prevent rare crash when calling ``extend`` under -high memory pressure conditions. diff --git a/Misc/NEWS.d/next/Library/2026-07-03-17-29-34.gh-issue-150579.0tLpQukIU.rst b/Misc/NEWS.d/next/Library/2026-07-03-17-29-34.gh-issue-150579.0tLpQukIU.rst deleted file mode 100644 index 7aff384431edc77..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-03-17-29-34.gh-issue-150579.0tLpQukIU.rst +++ /dev/null @@ -1,2 +0,0 @@ -:mod:`concurrent.futures` now uses lazy imports for its executor submodules -instead of a module ``__getattr__`` hook. diff --git a/Misc/NEWS.d/next/Library/2026-07-03-18-30-00.gh-issue-119592.mQr3Vx.rst b/Misc/NEWS.d/next/Library/2026-07-03-18-30-00.gh-issue-119592.mQr3Vx.rst deleted file mode 100644 index f718c877c8ed22b..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-03-18-30-00.gh-issue-119592.mQr3Vx.rst +++ /dev/null @@ -1,11 +0,0 @@ -Fix :class:`concurrent.futures.ProcessPoolExecutor` stranding submitted -work forever when a worker process exited upon reaching its -*max_tasks_per_child* limit after -:meth:`~concurrent.futures.Executor.shutdown` was called with -``wait=False``: a replacement worker is now spawned and the remaining work -executed as documented. If the executor has instead been garbage collected -without ``shutdown()`` (:gh:`152967`), or a replacement worker cannot be -started, the remaining futures now fail with -:exc:`~concurrent.futures.process.BrokenProcessPool` instead of never -resolving. A worker exit racing ``shutdown(wait=False)`` can also no -longer crash the executor management thread. diff --git a/Misc/NEWS.d/next/Library/2026-07-03-19-51-47.gh-issue-152997.i1ErzB.rst b/Misc/NEWS.d/next/Library/2026-07-03-19-51-47.gh-issue-152997.i1ErzB.rst deleted file mode 100644 index 9983f1b8313f73f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-03-19-51-47.gh-issue-152997.i1ErzB.rst +++ /dev/null @@ -1,6 +0,0 @@ -On platforms providing the C library's :manpage:`iconv(3)` function, -the :mod:`codecs` module now exposes every encoding known to ``iconv`` -for which Python has no built-in codec. -Such an encoding can be used by its name (for example ``"cp1133"``) -or, to force the ``iconv``-based engine even when a built-in codec exists, -with an ``"iconv:"`` prefix (for example ``"iconv:latin1"``). diff --git a/Misc/NEWS.d/next/Library/2026-07-03-21-10-00.gh-issue-54930.hq09Er.rst b/Misc/NEWS.d/next/Library/2026-07-03-21-10-00.gh-issue-54930.hq09Er.rst deleted file mode 100644 index 1cfc0212c609a69..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-03-21-10-00.gh-issue-54930.hq09Er.rst +++ /dev/null @@ -1,5 +0,0 @@ -Error responses of :class:`http.server.BaseHTTPRequestHandler` to malformed -request lines now include a status line and headers instead of being sent in -the bare HTTP/0.9 style. -Only a valid HTTP/0.9 request (a two-word ``GET`` request line) now receives -an HTTP/0.9 style response. diff --git a/Misc/NEWS.d/next/Library/2026-07-04-11-14-06.gh-issue-152851.diYvTf.rst b/Misc/NEWS.d/next/Library/2026-07-04-11-14-06.gh-issue-152851.diYvTf.rst deleted file mode 100644 index aab033ebeed6954..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-04-11-14-06.gh-issue-152851.diYvTf.rst +++ /dev/null @@ -1,2 +0,0 @@ -Prevent a crash when allocation fails while copying a :func:`BLAKE-2s/2b -` object. Patch by Bénédikt Tran. diff --git a/Misc/NEWS.d/next/Library/2026-07-04-11-26-24.gh-issue-153009.KGl-nQ.rst b/Misc/NEWS.d/next/Library/2026-07-04-11-26-24.gh-issue-153009.KGl-nQ.rst deleted file mode 100644 index a8a74caa41042ac..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-04-11-26-24.gh-issue-153009.KGl-nQ.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix compilation of :mod:`curses` on platforms that define the ``stdscr`` -macro. Patch by Bénédikt Tran. diff --git a/Misc/NEWS.d/next/Library/2026-07-04-13-00-00.gh-issue-135661.CIkADG.rst b/Misc/NEWS.d/next/Library/2026-07-04-13-00-00.gh-issue-135661.CIkADG.rst deleted file mode 100644 index 26a912a6f3a1949..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-04-13-00-00.gh-issue-135661.CIkADG.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix :class:`html.parser.HTMLParser`: an abruptly closed empty comment -(```` or ````) no longer extends up to a later ``-->`` in the same -:meth:`~html.parser.HTMLParser.feed` call. diff --git a/Misc/NEWS.d/next/Library/2026-07-04-20-28-51.gh-issue-153037.XUSp_g.rst b/Misc/NEWS.d/next/Library/2026-07-04-20-28-51.gh-issue-153037.XUSp_g.rst deleted file mode 100644 index cbfc62f75184706..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-04-20-28-51.gh-issue-153037.XUSp_g.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix :class:`~compression.zstd.ZstdFile` raising :exc:`AttributeError` -instead of :exc:`io.UnsupportedOperation` when iterating over a file that -is not open for reading. diff --git a/Misc/NEWS.d/next/Library/2026-07-05-10-24-30.gh-issue-143921.wQx3Tn.rst b/Misc/NEWS.d/next/Library/2026-07-05-10-24-30.gh-issue-143921.wQx3Tn.rst deleted file mode 100644 index 04e8bd6d6f9d6cb..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-05-10-24-30.gh-issue-143921.wQx3Tn.rst +++ /dev/null @@ -1,4 +0,0 @@ -Narrow the control character check in :mod:`imaplib` commands: only NUL, CR -and LF are now rejected. Other control characters are valid in quoted -strings and can occur in mailbox names returned by the server, so they are -now accepted and sent quoted. diff --git a/Misc/NEWS.d/next/Library/2026-07-05-11-36-51.gh-issue-59396.Apl7sI.rst b/Misc/NEWS.d/next/Library/2026-07-05-11-36-51.gh-issue-59396.Apl7sI.rst deleted file mode 100644 index d4c0473ef372e81..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-05-11-36-51.gh-issue-59396.Apl7sI.rst +++ /dev/null @@ -1,3 +0,0 @@ -:class:`tkinter.scrolledtext.ScrolledText` gained a *use_ttk* parameter to use -the themed :mod:`tkinter.ttk` frame and scroll bar instead of the classic -:mod:`tkinter` widgets. diff --git a/Misc/NEWS.d/next/Library/2026-07-05-12-00-00.gh-issue-153056.tMpLat.rst b/Misc/NEWS.d/next/Library/2026-07-05-12-00-00.gh-issue-153056.tMpLat.rst deleted file mode 100644 index a2bc89f25a53c19..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-05-12-00-00.gh-issue-153056.tMpLat.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix :class:`string.Template` raising a spurious :exc:`ValueError` when the -*pattern* attribute is a compiled regular expression object, which the -documentation allows. On the free-threaded build this also occurred as a data -race on the first concurrent use. diff --git a/Misc/NEWS.d/next/Library/2026-07-05-14-30-00.gh-issue-153062.teeFT1.rst b/Misc/NEWS.d/next/Library/2026-07-05-14-30-00.gh-issue-153062.teeFT1.rst deleted file mode 100644 index ed1aaa15d37bd9c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-05-14-30-00.gh-issue-153062.teeFT1.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a crash when concurrently iterating an :func:`itertools.tee` iterator on -the free-threaded build. diff --git a/Misc/NEWS.d/next/Library/2026-07-05-16-09-31.gh-issue-153068.huY9Jh.rst b/Misc/NEWS.d/next/Library/2026-07-05-16-09-31.gh-issue-153068.huY9Jh.rst deleted file mode 100644 index accf6e99cd6434d..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-05-16-09-31.gh-issue-153068.huY9Jh.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix :meth:`!cProfile.Profile.enable` to no longer overwrite errors from -:mod:`sys.monitoring`. diff --git a/Misc/NEWS.d/next/Library/2026-07-05-17-39-16.gh-issue-153133.kKSH7g.rst b/Misc/NEWS.d/next/Library/2026-07-05-17-39-16.gh-issue-153133.kKSH7g.rst deleted file mode 100644 index a7a68158ac895e3..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-05-17-39-16.gh-issue-153133.kKSH7g.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a socket leak in :meth:`asyncio.loop.create_connection` when the -transport cannot be created. diff --git a/Misc/NEWS.d/next/Library/2026-07-05-20-15-00.gh-issue-98092.iDcmd1.rst b/Misc/NEWS.d/next/Library/2026-07-05-20-15-00.gh-issue-98092.iDcmd1.rst deleted file mode 100644 index 9854e996a942a53..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-05-20-15-00.gh-issue-98092.iDcmd1.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add :meth:`imaplib.IMAP4.id`, a wrapper for the IMAP ``ID`` command -(:rfc:`2971`). diff --git a/Misc/NEWS.d/next/Library/2026-07-05-21-40-00.gh-issue-89869.XG7aHz.rst b/Misc/NEWS.d/next/Library/2026-07-05-21-40-00.gh-issue-89869.XG7aHz.rst deleted file mode 100644 index 4bf319f7f681525..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-05-21-40-00.gh-issue-89869.XG7aHz.rst +++ /dev/null @@ -1,3 +0,0 @@ -Add :meth:`imaplib.IMAP4.login_plain`, which authenticates using the -``PLAIN`` SASL mechanism (:rfc:`4616`). Unlike :meth:`~imaplib.IMAP4.login`, -it supports non-ASCII user names and passwords. diff --git a/Misc/NEWS.d/next/Library/2026-07-05-22-30-00.gh-issue-66788.tM7pQ2.rst b/Misc/NEWS.d/next/Library/2026-07-05-22-30-00.gh-issue-66788.tM7pQ2.rst deleted file mode 100644 index 29bd36ebd6295fe..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-05-22-30-00.gh-issue-66788.tM7pQ2.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add the ``utf-7-imap`` codec, implementing the modified UTF-7 encoding -used for international IMAP4 mailbox names (:rfc:`3501`, section 5.1.3). diff --git a/Misc/NEWS.d/next/Library/2026-07-06-12-00-00.gh-issue-153200.isqrtLt.rst b/Misc/NEWS.d/next/Library/2026-07-06-12-00-00.gh-issue-153200.isqrtLt.rst deleted file mode 100644 index a27ac73fe31a70a..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-06-12-00-00.gh-issue-153200.isqrtLt.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix :func:`math.isqrt` returning an incorrect result for arguments not -less than 2**64 that are instances of an :class:`int` subclass with an -overridden comparison operator. diff --git a/Misc/NEWS.d/next/Library/2026-07-06-13-42-17.gh-issue-72880.fcXhWr.rst b/Misc/NEWS.d/next/Library/2026-07-06-13-42-17.gh-issue-72880.fcXhWr.rst deleted file mode 100644 index 688464c9435d3a9..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-06-13-42-17.gh-issue-72880.fcXhWr.rst +++ /dev/null @@ -1,3 +0,0 @@ -Added the :mod:`tkinter.fontchooser` module which provides the -:class:`~tkinter.fontchooser.FontChooser` class as an interface to the -native font selection dialog. diff --git a/Misc/NEWS.d/next/Library/2026-07-06-14-05-40.gh-issue-153259.sysTr1.rst b/Misc/NEWS.d/next/Library/2026-07-06-14-05-40.gh-issue-153259.sysTr1.rst deleted file mode 100644 index 2355826ab4b2de2..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-06-14-05-40.gh-issue-153259.sysTr1.rst +++ /dev/null @@ -1,4 +0,0 @@ -Added the :mod:`tkinter.systray` module which provides the -:class:`~tkinter.systray.SysTrayIcon` class as an interface to the system -tray icon and the :func:`~tkinter.systray.notify` function which sends a -desktop notification. They require Tk 8.7/9.0 or newer. diff --git a/Misc/NEWS.d/next/Library/2026-07-06-14-18-33.gh-issue-153256.tkPrnt.rst b/Misc/NEWS.d/next/Library/2026-07-06-14-18-33.gh-issue-153256.tkPrnt.rst deleted file mode 100644 index db61bdb7f7b97d9..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-06-14-18-33.gh-issue-153256.tkPrnt.rst +++ /dev/null @@ -1,3 +0,0 @@ -Added the :meth:`!tk_print` method to :class:`tkinter.Canvas` and -:class:`tkinter.Text` which prints the contents of the widget using the -native print dialog. It requires Tk 8.7/9.0 or newer. diff --git a/Misc/NEWS.d/next/Library/2026-07-06-14-30-00.gh-issue-153521.iMaP47.rst b/Misc/NEWS.d/next/Library/2026-07-06-14-30-00.gh-issue-153521.iMaP47.rst deleted file mode 100644 index 93edb1532d5d41b..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-06-14-30-00.gh-issue-153521.iMaP47.rst +++ /dev/null @@ -1,7 +0,0 @@ -Add support for structured arguments in :mod:`imaplib` command methods. A -*message_set* and lists of flags or other atoms can now be passed as -sequences instead of preformatted strings, and the -:meth:`~imaplib.IMAP4.search`, :meth:`~imaplib.IMAP4.fetch`, -:meth:`~imaplib.IMAP4.sort`, :meth:`~imaplib.IMAP4.thread` and -:meth:`~imaplib.IMAP4.uid` methods accept a *params* keyword argument that -substitutes and quotes ``?`` placeholders. diff --git a/Misc/NEWS.d/next/Library/2026-07-06-14-38-02.gh-issue-145578.aX11yQ.rst b/Misc/NEWS.d/next/Library/2026-07-06-14-38-02.gh-issue-145578.aX11yQ.rst new file mode 100644 index 000000000000000..d32d6a80238fdd3 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-07-06-14-38-02.gh-issue-145578.aX11yQ.rst @@ -0,0 +1,7 @@ +Added :mod:`tkinter` support for the Tk 9.1 accessibility API: the +:attr:`~tkinter.Misc.accessible` property of widgets returns an +:class:`~tkinter.Accessible` object whose attributes are exposed to +assistive technologies such as screen readers and whose methods register +custom widgets with the platform accessibility API, and the +:meth:`~tkinter.Misc.tk_check_screenreader` method reports whether a +screen reader is running. diff --git a/Misc/NEWS.d/next/Library/2026-07-07-02-26-43.gh-issue-153210.LUXIcm.rst b/Misc/NEWS.d/next/Library/2026-07-07-02-26-43.gh-issue-153210.LUXIcm.rst deleted file mode 100644 index d5d4b7c1b8c0ed4..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-07-02-26-43.gh-issue-153210.LUXIcm.rst +++ /dev/null @@ -1 +0,0 @@ -Fix crash on :mod:`array` import under a memory pressure. diff --git a/Misc/NEWS.d/next/Library/2026-07-07-13-31-52.gh-issue-148286.-qu-em.rst b/Misc/NEWS.d/next/Library/2026-07-07-13-31-52.gh-issue-148286.-qu-em.rst deleted file mode 100644 index 60cd49020c954a4..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-07-13-31-52.gh-issue-148286.-qu-em.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix undefined behavior in -:attr:`compression.zstd.ZstdDecompressor.unused_data` when a complete frame -was decompressed in a single call. diff --git a/Misc/NEWS.d/next/Library/2026-07-07-17-50-54.gh-issue-143990.FoNtCf.rst b/Misc/NEWS.d/next/Library/2026-07-07-17-50-54.gh-issue-143990.FoNtCf.rst deleted file mode 100644 index a78dcccf482ab59..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-07-17-50-54.gh-issue-143990.FoNtCf.rst +++ /dev/null @@ -1,4 +0,0 @@ -A :class:`tkinter.font.Font` created from a named font, -including by :meth:`~tkinter.font.Font.copy`, -now copies its configured options rather than the options resolved by Tcl's ``font actual``, -preserving a size specified in pixels (a negative size). diff --git a/Misc/NEWS.d/next/Library/2026-07-07-22-06-52.gh-issue-153293.0DvYdc.rst b/Misc/NEWS.d/next/Library/2026-07-07-22-06-52.gh-issue-153293.0DvYdc.rst deleted file mode 100644 index ac358bb7fc0a507..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-07-22-06-52.gh-issue-153293.0DvYdc.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix the live sampling profiler TUI keeping stale aggregated opcode -statistics after a stats reset. diff --git a/Misc/NEWS.d/next/Library/2026-07-08-01-03-17.gh-issue-153292.oHDt3l.rst b/Misc/NEWS.d/next/Library/2026-07-08-01-03-17.gh-issue-153292.oHDt3l.rst deleted file mode 100644 index dc363e160074302..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-08-01-03-17.gh-issue-153292.oHDt3l.rst +++ /dev/null @@ -1 +0,0 @@ -Fix data race in repr of :class:`threading.RLock` in free-threading build. diff --git a/Misc/NEWS.d/next/Library/2026-07-08-01-47-15.gh-issue-153083.XbKZCp.rst b/Misc/NEWS.d/next/Library/2026-07-08-01-47-15.gh-issue-153083.XbKZCp.rst deleted file mode 100644 index b6d96851e17342f..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-08-01-47-15.gh-issue-153083.XbKZCp.rst +++ /dev/null @@ -1,2 +0,0 @@ -Defer GC tracking of an :class:`array.array` to the end of its construction. -Patch by Donghee Na. diff --git a/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst b/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst new file mode 100644 index 000000000000000..9245c1442b06f87 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-07-08-09-05-01.gh-issue-153309.g94LSO.rst @@ -0,0 +1 @@ +:mod:`http`: Add the HTTP QUERY method (:rfc:`10008`) to :class:`~http.HTTPMethod`. diff --git a/Misc/NEWS.d/next/Library/2026-07-08-21-15-00.gh-issue-153333.Kp3mZq.rst b/Misc/NEWS.d/next/Library/2026-07-08-21-15-00.gh-issue-153333.Kp3mZq.rst deleted file mode 100644 index 6fcbd590d0d9d38..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-08-21-15-00.gh-issue-153333.Kp3mZq.rst +++ /dev/null @@ -1,3 +0,0 @@ -The ``readprofile`` method of :class:`tkinter.Tk` now reads the user's -profile scripts using the encoding declared in the file, instead of the -locale encoding. diff --git a/Misc/NEWS.d/next/Library/2026-07-09-00-00-00.gh-issue-153406.vyMmB6.rst b/Misc/NEWS.d/next/Library/2026-07-09-00-00-00.gh-issue-153406.vyMmB6.rst deleted file mode 100644 index c09575754e33804..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-09-00-00-00.gh-issue-153406.vyMmB6.rst +++ /dev/null @@ -1,3 +0,0 @@ -:func:`email.utils.parsedate_to_datetime` now raises :exc:`ValueError` -instead of :exc:`OverflowError` when the parsed year or timezone offset is -out of range, matching its documented behavior. diff --git a/Misc/NEWS.d/next/Library/2026-07-09-10-14-08.gh-issue-153395.N8FuG3.rst b/Misc/NEWS.d/next/Library/2026-07-09-10-14-08.gh-issue-153395.N8FuG3.rst deleted file mode 100644 index 1c44219f710640d..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-09-10-14-08.gh-issue-153395.N8FuG3.rst +++ /dev/null @@ -1,4 +0,0 @@ -:mod:`curses.ascii` predicates and the :func:`~curses.ascii.ctrl` and -:func:`~curses.ascii.unctrl` functions now accept a :class:`curses.complexchar`. -:func:`~curses.ascii.ctrl` now returns a non-ASCII argument unchanged instead -of masking it to a control character. diff --git a/Misc/NEWS.d/next/Library/2026-07-09-12-00-00.gh-issue-49555.Ka9Lm2.rst b/Misc/NEWS.d/next/Library/2026-07-09-12-00-00.gh-issue-49555.Ka9Lm2.rst deleted file mode 100644 index 56860e53db88627..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-09-12-00-00.gh-issue-49555.Ka9Lm2.rst +++ /dev/null @@ -1,7 +0,0 @@ -:mod:`imaplib` now encodes non-ASCII mailbox names as modified UTF-7 -(:rfc:`3501`, section 5.1.3) in the default mode, so international mailbox -names can be passed as ordinary :class:`str`; under ``UTF8=ACCEPT`` they are -sent as UTF-8 instead. A name that is not valid modified UTF-7, such as one -with a bare ``&``, is now encoded correctly instead of being sent as is. -A ``str`` that is already valid modified UTF-7, or a :class:`bytes` object, -is sent unchanged. diff --git a/Misc/NEWS.d/next/Library/2026-07-09-12-35-19.gh-issue-153422.tKb0Xq.rst b/Misc/NEWS.d/next/Library/2026-07-09-12-35-19.gh-issue-153422.tKb0Xq.rst deleted file mode 100644 index 16bd5c9a22fbdef..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-09-12-35-19.gh-issue-153422.tKb0Xq.rst +++ /dev/null @@ -1,4 +0,0 @@ -:meth:`!winfo_exists`, :meth:`!winfo_ismapped` and :meth:`!winfo_viewable` -methods of :mod:`tkinter` widgets and :meth:`!edit_modified` of -:class:`tkinter.Text` now return a :class:`bool` instead of an integer or, -depending on ``wantobjects``, a string. diff --git a/Misc/NEWS.d/next/Library/2026-07-09-14-00-00.gh-issue-153417.Bw7Rq2.rst b/Misc/NEWS.d/next/Library/2026-07-09-14-00-00.gh-issue-153417.Bw7Rq2.rst deleted file mode 100644 index ebc36fa7c228d08..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-09-14-00-00.gh-issue-153417.Bw7Rq2.rst +++ /dev/null @@ -1,3 +0,0 @@ -Error messages from :meth:`imaplib.IMAP4.select` and :meth:`imaplib.IMAP4.uid` -no longer raise :exc:`BytesWarning` under :option:`!-bb` -when the mailbox or command argument is :class:`bytes`. diff --git a/Misc/NEWS.d/next/Library/2026-07-09-15-18-23.gh-issue-151292.f4NQSW.rst b/Misc/NEWS.d/next/Library/2026-07-09-15-18-23.gh-issue-151292.f4NQSW.rst deleted file mode 100644 index 4165893fc474574..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-09-15-18-23.gh-issue-151292.f4NQSW.rst +++ /dev/null @@ -1,5 +0,0 @@ -Store the sample count in :mod:`profiling.sampling` binary format, as a -64-bit integer, widening from previously used 32-bit integer. This breaks -the existing recordings. Long or thread-heavy profiling sessions will no -longer fail because of :exc:`OverflowError`. Patch by Maurycy -Pawłowski-Wieroński. diff --git a/Misc/NEWS.d/next/Library/2026-07-09-16-35-47.gh-issue-153404.daRkes.rst b/Misc/NEWS.d/next/Library/2026-07-09-16-35-47.gh-issue-153404.daRkes.rst deleted file mode 100644 index 0746d3f12149d52..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-09-16-35-47.gh-issue-153404.daRkes.rst +++ /dev/null @@ -1,4 +0,0 @@ -:class:`urllib.robotparser.RobotFileParser` now silently ignores a -``Crawl-delay`` or ``Request-rate`` value written with non-decimal digits -(such as ``U+00B2 SUPERSCRIPT TWO``) instead of raising :exc:`ValueError` -and aborting the parse of the whole ``robots.txt`` file. diff --git a/Misc/NEWS.d/next/Library/2026-07-10-12-33-30.gh-issue-153513.GxrPuY.rst b/Misc/NEWS.d/next/Library/2026-07-10-12-33-30.gh-issue-153513.GxrPuY.rst deleted file mode 100644 index a374355d2d4c591..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-10-12-33-30.gh-issue-153513.GxrPuY.rst +++ /dev/null @@ -1,5 +0,0 @@ -Values of several Tcl object types returned by :mod:`tkinter` are now -converted to the corresponding Python type instead of being wrapped in a -:class:`!_tkinter.Tcl_Obj`: ``index``, ``window``, ``nsName`` and -``parsedVarName`` objects to :class:`str`, and ``pixel`` screen distances -with no unit suffix to :class:`int` or :class:`float`. diff --git a/Misc/NEWS.d/next/Library/2026-07-10-16-00-00.gh-issue-153494.qCh8rT.rst b/Misc/NEWS.d/next/Library/2026-07-10-16-00-00.gh-issue-153494.qCh8rT.rst deleted file mode 100644 index 6e83940efcc180d..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-10-16-00-00.gh-issue-153494.qCh8rT.rst +++ /dev/null @@ -1,8 +0,0 @@ -:meth:`imaplib.IMAP4.search`, :meth:`~imaplib.IMAP4.sort` -and :meth:`~imaplib.IMAP4.thread` (and the corresponding ``uid`` commands) -now encode :class:`str` search criteria to the declared *charset*, -so international search text can be passed as ordinary :class:`str`. -When *charset* is ``None`` (as it must be under ``UTF8=ACCEPT``), -the criteria are sent using the connection encoding instead. -A criterion passed as :class:`bytes` is sent unchanged, -for use with a charset that Python has no codec for. diff --git a/Misc/NEWS.d/next/Library/2026-07-10-18-30-00.gh-issue-153502.uIdKw0.rst b/Misc/NEWS.d/next/Library/2026-07-10-18-30-00.gh-issue-153502.uIdKw0.rst deleted file mode 100644 index 7717c8487cf6436..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-10-18-30-00.gh-issue-153502.uIdKw0.rst +++ /dev/null @@ -1,6 +0,0 @@ -:meth:`imaplib.IMAP4.copy`, :meth:`~imaplib.IMAP4.move`, -:meth:`~imaplib.IMAP4.fetch`, :meth:`~imaplib.IMAP4.store`, -:meth:`~imaplib.IMAP4.search`, :meth:`~imaplib.IMAP4.sort`, -:meth:`~imaplib.IMAP4.thread` and :meth:`~imaplib.IMAP4.expunge` now accept a -keyword-only *uid* argument that selects the corresponding ``UID`` command, as -a more convenient alternative to :meth:`~imaplib.IMAP4.uid`. diff --git a/Misc/NEWS.d/next/Library/2026-07-12-00-00-00.gh-issue-85943.8f906e.rst b/Misc/NEWS.d/next/Library/2026-07-12-00-00-00.gh-issue-85943.8f906e.rst deleted file mode 100644 index 0a93bf2e7b803e3..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-12-00-00-00.gh-issue-85943.8f906e.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix :mod:`struct` functions raising :exc:`BytesWarning` under the ``-bb`` -command line option when a :class:`str` format is used after an equal -:class:`bytes` format (or vice versa). The internal format cache no longer -mixes :class:`str` and :class:`bytes` keys. diff --git a/Misc/NEWS.d/next/Library/2026-07-12-10-00-00.gh-issue-98078.fA3lRt.rst b/Misc/NEWS.d/next/Library/2026-07-12-10-00-00.gh-issue-98078.fA3lRt.rst deleted file mode 100644 index de710283c17b8e5..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-12-10-00-00.gh-issue-98078.fA3lRt.rst +++ /dev/null @@ -1,6 +0,0 @@ -Fix :mod:`asyncio` SSL transports not sending the fatal TLS alert to the -peer when the TLS handshake fails or when receiving corrupted data, and -not sending the ``close_notify`` alert to the peer when the TLS shutdown -fails. The peer can now tell why the connection was dropped (for example, -certificate verification failure or no TLS version in common) instead of -seeing the connection abruptly closed. diff --git a/Misc/NEWS.d/next/Library/2026-07-13-10-27-08.gh-issue-153658.A6o4n5.rst b/Misc/NEWS.d/next/Library/2026-07-13-10-27-08.gh-issue-153658.A6o4n5.rst deleted file mode 100644 index 06385bb7754b127..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-13-10-27-08.gh-issue-153658.A6o4n5.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix :meth:`sqlite3.Connection.iterdump` raising :exc:`sqlite3.OperationalError` -when a table name contains a single quote. Patch by tonghuaroot. diff --git a/Misc/NEWS.d/next/Library/2026-07-14-19-45-21.gh-issue-153695.UYdZJZ.rst b/Misc/NEWS.d/next/Library/2026-07-14-19-45-21.gh-issue-153695.UYdZJZ.rst deleted file mode 100644 index 43d7feebf97d6f2..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-14-19-45-21.gh-issue-153695.UYdZJZ.rst +++ /dev/null @@ -1,2 +0,0 @@ -Hashing a :class:`sqlite3.Row` that contains an unhashable value now raises -:exc:`TypeError` instead of :exc:`SystemError`. Patch by tonghuaroot. diff --git a/Misc/NEWS.d/next/Library/2026-07-15-14-24-18.gh-issue-153761.8jqs67.rst b/Misc/NEWS.d/next/Library/2026-07-15-14-24-18.gh-issue-153761.8jqs67.rst deleted file mode 100644 index 68e007e66e0396c..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-15-14-24-18.gh-issue-153761.8jqs67.rst +++ /dev/null @@ -1 +0,0 @@ -Fix cancelling :meth:`asyncio.loop.sock_accept` dropping a pending connection. diff --git a/Misc/NEWS.d/next/Library/2026-07-15-15-19-08.gh-issue-104533.pQJxCk.rst b/Misc/NEWS.d/next/Library/2026-07-15-15-19-08.gh-issue-104533.pQJxCk.rst deleted file mode 100644 index adb08a8f79c1092..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-15-15-19-08.gh-issue-104533.pQJxCk.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add :func:`ctypes.util.struct` and :class:`ctypes.util.CFieldInfo` for -generating structure types using annotations. diff --git a/Misc/NEWS.d/next/Library/2026-07-17-14-00-00.gh-issue-153840.FgXs3e.rst b/Misc/NEWS.d/next/Library/2026-07-17-14-00-00.gh-issue-153840.FgXs3e.rst new file mode 100644 index 000000000000000..43316035d9b2c27 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-07-17-14-00-00.gh-issue-153840.FgXs3e.rst @@ -0,0 +1,3 @@ +Escape special characters in ``profiling.sampling`` flamegraph function +names to prevent markup injection in the generated HTML report. Patch by +tonghuaroot. diff --git a/Misc/NEWS.d/next/Library/2026-07-17-14-30-00.gh-issue-153844.pYs7Kq.rst b/Misc/NEWS.d/next/Library/2026-07-17-14-30-00.gh-issue-153844.pYs7Kq.rst deleted file mode 100644 index cf46eec8513f673..000000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-17-14-30-00.gh-issue-153844.pYs7Kq.rst +++ /dev/null @@ -1,2 +0,0 @@ -:func:`symtable.symtable` now accepts an AST object, -like the builtin :func:`compile`. diff --git a/Misc/NEWS.d/next/Library/2026-07-20-09-35-32.gh-issue-153144.0a2AoO.rst b/Misc/NEWS.d/next/Library/2026-07-20-09-35-32.gh-issue-153144.0a2AoO.rst new file mode 100644 index 000000000000000..0d0aac646285e79 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-07-20-09-35-32.gh-issue-153144.0a2AoO.rst @@ -0,0 +1,4 @@ +:func:`math.atan2` and :func:`math.atan2pi` no longer raise :exc:`ValueError`. +:func:`cmath.phase` no longer raises :exc:`OverflowError` or :exc:`ValueError`, +and the values of ``math.atan2(b, a)`` and ``cmath.phase(complex(a, b))`` always +match. Contributed by High Performance Kernels LLC. diff --git a/Misc/NEWS.d/next/Library/2026-07-29-12-20-39.gh-issue-127172.Kf3Xa9.rst b/Misc/NEWS.d/next/Library/2026-07-29-12-20-39.gh-issue-127172.Kf3Xa9.rst new file mode 100644 index 000000000000000..c4bf1f07a2ea577 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-07-29-12-20-39.gh-issue-127172.Kf3Xa9.rst @@ -0,0 +1,4 @@ +Creating a virtual environment with :mod:`venv` now writes the activation +scripts using permissions derived from the process umask (and any default +ACL), consistent with the other files it creates, instead of a fixed mode +copied from the packaged templates. Patch by tonghuaroot. diff --git a/Misc/NEWS.d/next/Library/2026-08-01-10-54-39.gh-issue-155031.sTB_n8.rst b/Misc/NEWS.d/next/Library/2026-08-01-10-54-39.gh-issue-155031.sTB_n8.rst new file mode 100644 index 000000000000000..954e4cc2e54ac04 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-08-01-10-54-39.gh-issue-155031.sTB_n8.rst @@ -0,0 +1,2 @@ +Propagate to user any permission errors from subprocess attach commands in +Tachyon diff --git a/Misc/NEWS.d/next/Library/2026-08-02-08-43-20.gh-issue-155003.VVy9Z_.rst b/Misc/NEWS.d/next/Library/2026-08-02-08-43-20.gh-issue-155003.VVy9Z_.rst new file mode 100644 index 000000000000000..c41ce1879488b78 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-08-02-08-43-20.gh-issue-155003.VVy9Z_.rst @@ -0,0 +1,5 @@ +Fix :class:`multiprocessing.shared_memory.SharedMemory` leaking its file +descriptor and printing an ignored :exc:`BufferError` when garbage collected +while its :attr:`~multiprocessing.shared_memory.SharedMemory.buf` was still in +use, for example by a NumPy array. :attr:`!buf` now also stays usable after +the :class:`!SharedMemory` object is garbage collected. diff --git a/Misc/NEWS.d/next/Library/2026-08-02-19-08-17.gh-issue-155074.Vj8qL2.rst b/Misc/NEWS.d/next/Library/2026-08-02-19-08-17.gh-issue-155074.Vj8qL2.rst new file mode 100644 index 000000000000000..70489c9d62f526b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-08-02-19-08-17.gh-issue-155074.Vj8qL2.rst @@ -0,0 +1,2 @@ +Fix the pure Python implementation of ``BufferedReader.readinto()`` raising +:exc:`ValueError` after partially filling the destination buffer. diff --git a/Misc/NEWS.d/next/Library/2026-08-05-20-30-00.gh-issue-75221.runpyM.rst b/Misc/NEWS.d/next/Library/2026-08-05-20-30-00.gh-issue-75221.runpyM.rst new file mode 100644 index 000000000000000..77326f3f98bf94a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-08-05-20-30-00.gh-issue-75221.runpyM.rst @@ -0,0 +1,4 @@ +:func:`runpy.run_path` and the execution of a directory or a zipfile now +search the ``__main__`` module only in that directory or zipfile. Previously +an existing ``__main__`` module located elsewhere on :data:`sys.path` could be +executed instead. diff --git a/Misc/NEWS.d/next/Library/2026-08-08-23-30-00.gh-issue-85681.ntabs.rst b/Misc/NEWS.d/next/Library/2026-08-08-23-30-00.gh-issue-85681.ntabs.rst new file mode 100644 index 000000000000000..b673a69a70620b9 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-08-08-23-30-00.gh-issue-85681.ntabs.rst @@ -0,0 +1,3 @@ +:func:`!ntpath.abspath` on non-Windows platforms now strips trailing dots and +spaces like the Windows path normalization does. This makes +:func:`!ntpath.relpath` and other functions based on it platform independent. diff --git a/Misc/NEWS.d/next/Library/2026-08-17-06-07-49.gh-issue-155935.lbMPKW.rst b/Misc/NEWS.d/next/Library/2026-08-17-06-07-49.gh-issue-155935.lbMPKW.rst new file mode 100644 index 000000000000000..21d7ba6a4f758c4 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-08-17-06-07-49.gh-issue-155935.lbMPKW.rst @@ -0,0 +1 @@ +Fix :meth:`!importlib.machinery.FileFinder.discover` looping forever when the underlying directory scan keeps failing with :exc:`OSError`. A failing scan now ends the listing instead of being retried. diff --git a/Misc/NEWS.d/next/Library/2026-08-25-09-15-00.gh-issue-154923.tKcr8Q.rst b/Misc/NEWS.d/next/Library/2026-08-25-09-15-00.gh-issue-154923.tKcr8Q.rst new file mode 100644 index 000000000000000..54c04dcc1ecc7b0 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-08-25-09-15-00.gh-issue-154923.tKcr8Q.rst @@ -0,0 +1,2 @@ +Fix a crash when creating Tcl interpreters concurrently in different +threads in the :term:`free-threaded build`. diff --git a/Misc/NEWS.d/next/Library/2026-09-11-12-43-04.gh-issue-157299.HQ3I4F.rst b/Misc/NEWS.d/next/Library/2026-09-11-12-43-04.gh-issue-157299.HQ3I4F.rst new file mode 100644 index 000000000000000..fe9483325829c44 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-09-11-12-43-04.gh-issue-157299.HQ3I4F.rst @@ -0,0 +1,4 @@ +Fix eagerly started :class:`asyncio.Task` objects missing their awaited-by +edge during the first step. During that step, even a plain +:func:`asyncio.create_task` call reports the creating task as an awaiter. +Patch by Timofey Ivankov. diff --git a/Misc/NEWS.d/next/Library/2026-09-15-10-30-00.gh-issue-92810.Kx3abc.rst b/Misc/NEWS.d/next/Library/2026-09-15-10-30-00.gh-issue-92810.Kx3abc.rst new file mode 100644 index 000000000000000..45fc06791f6950f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-09-15-10-30-00.gh-issue-92810.Kx3abc.rst @@ -0,0 +1,4 @@ +Speed up :func:`isinstance` and :func:`issubclass` checks against +:class:`abc.ABCMeta` classes, fix quadratic time and memory usage for large +class hierarchies, and improve their scaling across threads in the +free-threaded build. Patch by Kumar Aditya. diff --git a/Misc/NEWS.d/next/Library/2026-09-23-21-15-00.gh-issue-158032.k4nT9p.rst b/Misc/NEWS.d/next/Library/2026-09-23-21-15-00.gh-issue-158032.k4nT9p.rst new file mode 100644 index 000000000000000..0e0a565519fa8e6 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-09-23-21-15-00.gh-issue-158032.k4nT9p.rst @@ -0,0 +1,2 @@ +Fix a crash in :meth:`xml.etree.ElementTree.Element.iter` when a tag's +equality comparison replaces that tag. diff --git a/Misc/NEWS.d/next/Library/2026-09-26-09-44-59.gh-issue-158166.lVGCsI.rst b/Misc/NEWS.d/next/Library/2026-09-26-09-44-59.gh-issue-158166.lVGCsI.rst new file mode 100644 index 000000000000000..528160a6709369a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-09-26-09-44-59.gh-issue-158166.lVGCsI.rst @@ -0,0 +1 @@ +Fix the type of the ``msg`` attribute of :exc:`xml.etree.ElementTree.ParseError` in the pure Python implementation: it is now a string, as in the C implementation. diff --git a/Misc/NEWS.d/next/Library/2026-09-27-13-04-02.gh-issue-42550.sqYlvB.rst b/Misc/NEWS.d/next/Library/2026-09-27-13-04-02.gh-issue-42550.sqYlvB.rst new file mode 100644 index 000000000000000..af8fe2630ba440f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-09-27-13-04-02.gh-issue-42550.sqYlvB.rst @@ -0,0 +1,3 @@ +:class:`http.client.HTTPConnection` now waits for a ``100 Continue`` +response before sending body content if the ``Expect: 100-Continue`` header +is set. diff --git a/Misc/NEWS.d/next/Library/2026-10-02-22-32-10.gh-issue-156145.9l_tZb.rst b/Misc/NEWS.d/next/Library/2026-10-02-22-32-10.gh-issue-156145.9l_tZb.rst new file mode 100644 index 000000000000000..b29e6b8be6dc882 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-02-22-32-10.gh-issue-156145.9l_tZb.rst @@ -0,0 +1,3 @@ +The following functions no longer set ``errno`` to zero: :func:`cmath.phase`, +:func:`math.atan2`, :func:`math.atan2pi`, and :func:`math.copysign`. +Contributed by High Performance Kernels LLC. diff --git a/Misc/NEWS.d/next/Library/2026-10-07-21-54-29.gh-issue-158955.Ey4Iei.rst b/Misc/NEWS.d/next/Library/2026-10-07-21-54-29.gh-issue-158955.Ey4Iei.rst new file mode 100644 index 000000000000000..e7e613ec77e6945 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-07-21-54-29.gh-issue-158955.Ey4Iei.rst @@ -0,0 +1 @@ +Fixed PyREPL rendering on WSL by avoiding the unnecessary INS terminal sequence when appending a character at the end of a line. INS remains used for true mid-line insertions, with regression coverage added. diff --git a/Misc/NEWS.d/next/Library/2026-10-08-01-33-46.gh-issue-158986.iXoUCo.rst b/Misc/NEWS.d/next/Library/2026-10-08-01-33-46.gh-issue-158986.iXoUCo.rst new file mode 100644 index 000000000000000..f234a601a97103d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-08-01-33-46.gh-issue-158986.iXoUCo.rst @@ -0,0 +1,4 @@ +Fix :mod:`profiling.sampling` reporting modules in a ``site-packages`` +directory located inside the standard library directory as standard library +modules. The heatmap now lists them under "Site Packages" and flamegraph +labels no longer start with ``site-packages.``. diff --git a/Misc/NEWS.d/next/Library/2026-10-10-13-35-08.gh-issue-149584.Yq2bF7.rst b/Misc/NEWS.d/next/Library/2026-10-10-13-35-08.gh-issue-149584.Yq2bF7.rst new file mode 100644 index 000000000000000..7f92a1b19877cd4 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-10-13-35-08.gh-issue-149584.Yq2bF7.rst @@ -0,0 +1,2 @@ +Improve the performance of the Tachyon profiler by avoiding unnecessary remote +reads of the base frame sentinel. Patch by Maurycy Pawłowski-Wieroński. diff --git a/Misc/NEWS.d/next/Library/2026-10-10-18-56-26.gh-issue-159130.3AIHqh.rst b/Misc/NEWS.d/next/Library/2026-10-10-18-56-26.gh-issue-159130.3AIHqh.rst new file mode 100644 index 000000000000000..f4ff555a25e7010 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-10-18-56-26.gh-issue-159130.3AIHqh.rst @@ -0,0 +1,2 @@ +Fix :mod:`!_remote_debugging` returning a different thread when the selected +thread does not match the profiling mode with ``only_active_thread=True``. diff --git a/Misc/NEWS.d/next/Library/2026-10-13-11-54-07.gh-issue-159301.Kq3Vx8.rst b/Misc/NEWS.d/next/Library/2026-10-13-11-54-07.gh-issue-159301.Kq3Vx8.rst new file mode 100644 index 000000000000000..067d1d5eac553cf --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-13-11-54-07.gh-issue-159301.Kq3Vx8.rst @@ -0,0 +1,3 @@ +Add symbolic constants for Tk option values which were missing in +:mod:`!tkinter.constants`, such as ``READONLY``, ``TABULAR``, +``DETERMINATE``, ``MENUBAR`` and the names of the themed widget states. diff --git a/Misc/NEWS.d/next/Library/2026-10-18-19-18-20.gh-issue-159645.IOXcpT.rst b/Misc/NEWS.d/next/Library/2026-10-18-19-18-20.gh-issue-159645.IOXcpT.rst new file mode 100644 index 000000000000000..fde97e6f131cb54 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-18-19-18-20.gh-issue-159645.IOXcpT.rst @@ -0,0 +1,2 @@ +Fix :mod:`profiling.sampling` ``--async-aware`` profiles showing event loop +frames under tasks. Patch by Timofei Ivankov. diff --git a/Misc/NEWS.d/next/Library/2026-10-20-12-00-00.gh-issue-87027.PrEvNw.rst b/Misc/NEWS.d/next/Library/2026-10-20-12-00-00.gh-issue-87027.PrEvNw.rst new file mode 100644 index 000000000000000..504cd054ca464c7 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-20-12-00-00.gh-issue-87027.PrEvNw.rst @@ -0,0 +1,2 @@ +Add :meth:`~ipaddress.IPv4Network.prev_network` and +:meth:`~ipaddress.IPv6Network.prev_network`. Patch by Faisal Mahmood. diff --git a/Misc/NEWS.d/next/Library/2026-10-20-12-49-32.gh-issue-159207.Lccezg.rst b/Misc/NEWS.d/next/Library/2026-10-20-12-49-32.gh-issue-159207.Lccezg.rst new file mode 100644 index 000000000000000..a96098fd211abc6 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-20-12-49-32.gh-issue-159207.Lccezg.rst @@ -0,0 +1,3 @@ +The :mod:`profiling.sampling` binary output format now stores samples in +independent blocks. This is a breaking format change: Python 3.16 does not +support reading profiles written in the previous format. diff --git a/Misc/NEWS.d/next/Library/2026-10-20-23-30-00.gh-issue-159973.Ks9nLm.rst b/Misc/NEWS.d/next/Library/2026-10-20-23-30-00.gh-issue-159973.Ks9nLm.rst new file mode 100644 index 000000000000000..506c71ca82bdbae --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-20-23-30-00.gh-issue-159973.Ks9nLm.rst @@ -0,0 +1,3 @@ +Fix soft keyword highlighting after blank lines, comment-only lines, and +dedents in the :ref:`interactive shell `. Patch by Bartosz +Sławecki. diff --git a/Misc/NEWS.d/next/Library/2026-10-22-05-23-04.gh-issue-161104.rvNPjJ.rst b/Misc/NEWS.d/next/Library/2026-10-22-05-23-04.gh-issue-161104.rvNPjJ.rst new file mode 100644 index 000000000000000..acae526043a2979 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-22-05-23-04.gh-issue-161104.rvNPjJ.rst @@ -0,0 +1,4 @@ +Fix :meth:`http.client.HTTPConnection.set_tunnel` accepting a tunnel host +containing a non-ASCII character that IDNA encoding maps to a space, such as +U+00A0 NO-BREAK SPACE. Connecting now raises :exc:`ValueError`, as it already +does for an ASCII space. diff --git a/Misc/NEWS.d/next/Library/2026-10-22-21-19-51.gh-issue-160397.E-RwgUgm.rst b/Misc/NEWS.d/next/Library/2026-10-22-21-19-51.gh-issue-160397.E-RwgUgm.rst new file mode 100644 index 000000000000000..bd880cfe1eaff32 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-22-21-19-51.gh-issue-160397.E-RwgUgm.rst @@ -0,0 +1,5 @@ +The C implementation of :mod:`warnings` no longer takes the warnings lock +when emitting a warning, so user code such as a custom +:func:`~warnings.showwarning` no longer runs with the lock held. On the +:term:`free-threaded build`, the filter search and the registry updates use +per-object critical sections instead. diff --git a/Misc/NEWS.d/next/Library/2026-10-24-18-00-00.gh-issue-160601.Utf8Bin.rst b/Misc/NEWS.d/next/Library/2026-10-24-18-00-00.gh-issue-160601.Utf8Bin.rst new file mode 100644 index 000000000000000..b0b5264ea341c4c --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-24-18-00-00.gh-issue-160601.Utf8Bin.rst @@ -0,0 +1,3 @@ +Fix a :exc:`UnicodeEncodeError` in :mod:`profiling.sampling` binary mode +when a sampled filename or function name contains surrogate characters. +These characters are now written as backslash escapes in the binary file. diff --git a/Misc/NEWS.d/next/Library/2026-10-26-21-14-17.gh-issue-160735.IIUifI.rst b/Misc/NEWS.d/next/Library/2026-10-26-21-14-17.gh-issue-160735.IIUifI.rst new file mode 100644 index 000000000000000..cf64610a9e62590 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-26-21-14-17.gh-issue-160735.IIUifI.rst @@ -0,0 +1,2 @@ +Fix Tachyon's Gecko export closing open markers too early when replaying a +binary profile whose thread samples arrive out of time order. diff --git a/Misc/NEWS.d/next/Library/2026-10-30-19-04-37.gh-issue-160900.007288.rst b/Misc/NEWS.d/next/Library/2026-10-30-19-04-37.gh-issue-160900.007288.rst new file mode 100644 index 000000000000000..4bc5737ccaf8bd5 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-30-19-04-37.gh-issue-160900.007288.rst @@ -0,0 +1 @@ +Allow :func:`fnmatch.filter` and :func:`fnmatch.filterfalse` to accept :term:`path-like objects `. diff --git a/Misc/NEWS.d/next/Library/2026-10-30-23-05-00.gh-issue-160976.GeCk0P.rst b/Misc/NEWS.d/next/Library/2026-10-30-23-05-00.gh-issue-160976.GeCk0P.rst new file mode 100644 index 000000000000000..142d56140b0ce16 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-30-23-05-00.gh-issue-160976.GeCk0P.rst @@ -0,0 +1,2 @@ +Fix the Gecko reporter (``--gecko``) in :mod:`profiling.sampling` to record +full source file paths. diff --git a/Misc/NEWS.d/next/Library/2026-11-01-05-05-38.gh-issue-161060.YOZsVl.rst b/Misc/NEWS.d/next/Library/2026-11-01-05-05-38.gh-issue-161060.YOZsVl.rst new file mode 100644 index 000000000000000..8d55e0162c452ed --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-01-05-05-38.gh-issue-161060.YOZsVl.rst @@ -0,0 +1,5 @@ +Fix a crash in :mod:`xml.parsers.expat` when a handler raises an exception, +or the :meth:`~xml.parsers.expat.xmlparser.DefaultHandler` or +:meth:`~xml.parsers.expat.xmlparser.DefaultHandlerExpand` handler is unset, +while a token longer than 1024 bytes, such as a comment, is being reported to +the default handler from a document that is not encoded in UTF-8. diff --git a/Misc/NEWS.d/next/Library/2026-11-03-08-21-06.gh-issue-161184.PIhcD9.rst b/Misc/NEWS.d/next/Library/2026-11-03-08-21-06.gh-issue-161184.PIhcD9.rst new file mode 100644 index 000000000000000..3b15925773b99ec --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-03-08-21-06.gh-issue-161184.PIhcD9.rst @@ -0,0 +1,6 @@ +Speed up attribute access on instances of :mod:`io` classes and their +subclasses by storing instance attributes and weak references in the object +pre-header. The ``__dictoffset__`` and ``__weakrefoffset__`` attributes +of these classes now report the managed offsets, and C extension types that +subclass an :mod:`io` class can no longer declare their own ``__dictoffset__`` +or ``__weaklistoffset__`` member. diff --git a/Misc/NEWS.d/next/Library/2026-11-03-17-54-07.gh-issue-159637.0p15UL.rst b/Misc/NEWS.d/next/Library/2026-11-03-17-54-07.gh-issue-159637.0p15UL.rst new file mode 100644 index 000000000000000..cd820a2868f52ec --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-03-17-54-07.gh-issue-159637.0p15UL.rst @@ -0,0 +1,4 @@ +Fix :meth:`Document.renameNode() ` in +:mod:`xml.dom.minidom` rejecting a valid rename of an attribute to a +prefixed name, and removing the attribute from its element when a rename +is rejected. diff --git a/Misc/NEWS.d/next/Library/2026-11-05-22-26-44.gh-issue-161452.YfFfjq.rst b/Misc/NEWS.d/next/Library/2026-11-05-22-26-44.gh-issue-161452.YfFfjq.rst new file mode 100644 index 000000000000000..7ac5f49096c5401 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-05-22-26-44.gh-issue-161452.YfFfjq.rst @@ -0,0 +1,3 @@ +Fix the :mod:`random` :ref:`command-line interface ` +printing a random float for a zero or negative integer input instead of +failing like ``--integer`` does. diff --git a/Misc/NEWS.d/next/Library/2026-11-06-12-00-00.gh-issue-160978.Kx7mQa.rst b/Misc/NEWS.d/next/Library/2026-11-06-12-00-00.gh-issue-160978.Kx7mQa.rst new file mode 100644 index 000000000000000..be5cc945f4eb61d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-06-12-00-00.gh-issue-160978.Kx7mQa.rst @@ -0,0 +1,3 @@ +Fix :mod:`ctypes` handing out distinct array types for the same item type +and length when the array type is created concurrently from several +threads. diff --git a/Misc/NEWS.d/next/Library/2026-11-06-20-12-44.gh-issue-161502.rYZtwK.rst b/Misc/NEWS.d/next/Library/2026-11-06-20-12-44.gh-issue-161502.rYZtwK.rst new file mode 100644 index 000000000000000..f284c37bd738945 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-06-20-12-44.gh-issue-161502.rYZtwK.rst @@ -0,0 +1,3 @@ +Fix missing tasks in ``python -m asyncio pstree`` output when tasks are +connected through an intermediate :class:`asyncio.Future`. Patch by Timofei +Ivankov diff --git a/Misc/NEWS.d/next/Library/2026-11-07-12-00-00.gh-issue-51540.Tunn07.rst b/Misc/NEWS.d/next/Library/2026-11-07-12-00-00.gh-issue-51540.Tunn07.rst new file mode 100644 index 000000000000000..9efd6dd0cca7db7 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-07-12-00-00.gh-issue-51540.Tunn07.rst @@ -0,0 +1,8 @@ +:class:`urllib.request.ProxyBasicAuthHandler` and +:class:`urllib.request.ProxyDigestAuthHandler` now handle a ``407 Proxy +Authentication Required`` response to the CONNECT request for an ``https`` +URL. :mod:`http.client` raises the new :exc:`~http.client.ProxyTunnelError`, +a subclass of :exc:`OSError`, when a proxy rejects a CONNECT request. +For such a proxy, :class:`~urllib.request.ProxyDigestAuthHandler` computes +the digest over the CONNECT request (``CONNECT host:port``) instead of the +request sent to the origin server. diff --git a/Misc/NEWS.d/next/Library/2026-11-07-20-26-52.gh-issue-161571.qQ8OhA.rst b/Misc/NEWS.d/next/Library/2026-11-07-20-26-52.gh-issue-161571.qQ8OhA.rst new file mode 100644 index 000000000000000..804b8a494ca4320 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-07-20-26-52.gh-issue-161571.qQ8OhA.rst @@ -0,0 +1,3 @@ +Fix a crash in :func:`curses.tparm` for capabilities with parameters +that they format as strings, such as ``Ms`` of xterm. +Bytes objects are now accepted for these parameters. diff --git a/Misc/NEWS.d/next/Library/2026-11-08-19-29-54.gh-issue-141998.8vum0w.rst b/Misc/NEWS.d/next/Library/2026-11-08-19-29-54.gh-issue-141998.8vum0w.rst new file mode 100644 index 000000000000000..633c27d55175a3d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-08-19-29-54.gh-issue-141998.8vum0w.rst @@ -0,0 +1,2 @@ +Do not syntax highlight text typed in response to :func:`input` in the +:term:`REPL`. diff --git a/Misc/NEWS.d/next/Library/2026-11-10-13-28-10.gh-issue-161746.HxgY9R.rst b/Misc/NEWS.d/next/Library/2026-11-10-13-28-10.gh-issue-161746.HxgY9R.rst new file mode 100644 index 000000000000000..293bf5fb27a7550 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-10-13-28-10.gh-issue-161746.HxgY9R.rst @@ -0,0 +1,3 @@ +Speed up :meth:`datetime.datetime.fromordinal` by about 15% (30% in the +pure-Python implementation) by using the `Neri–Schneider algorithm +`__. diff --git a/Misc/NEWS.d/next/Library/2026-11-10-23-51-25.gh-issue-161788.J8vQmK.rst b/Misc/NEWS.d/next/Library/2026-11-10-23-51-25.gh-issue-161788.J8vQmK.rst new file mode 100644 index 000000000000000..34d3cff85123c79 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-10-23-51-25.gh-issue-161788.J8vQmK.rst @@ -0,0 +1 @@ +:func:`shutil.which` now accepts path-like objects for the command. diff --git a/Misc/NEWS.d/next/Library/2026-11-11-12-00-00.gh-issue-135893.cTyp3s.rst b/Misc/NEWS.d/next/Library/2026-11-11-12-00-00.gh-issue-135893.cTyp3s.rst new file mode 100644 index 000000000000000..bddd3d817ab1cbf --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-11-12-00-00.gh-issue-135893.cTyp3s.rst @@ -0,0 +1,3 @@ +Fix a regression where importing :mod:`ctypes` could leave an extra file +descriptor open on some Linux systems, or hang in x86-64 macOS applications +signed with the hardened runtime. diff --git a/Misc/NEWS.d/next/Library/2026-11-11-14-29-41.gh-issue-161808.S9dK2p.rst b/Misc/NEWS.d/next/Library/2026-11-11-14-29-41.gh-issue-161808.S9dK2p.rst new file mode 100644 index 000000000000000..76626ca60b5b5a9 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-11-14-29-41.gh-issue-161808.S9dK2p.rst @@ -0,0 +1,2 @@ +Raise :exc:`SyntaxError` instead of :exc:`KeyError` for unsupported XPath +tokens in :mod:`xml.etree.ElementTree` path searches. diff --git a/Misc/NEWS.d/next/Library/2026-11-11-20-50-03.gh-issue-156812.nqPw30.rst b/Misc/NEWS.d/next/Library/2026-11-11-20-50-03.gh-issue-156812.nqPw30.rst new file mode 100644 index 000000000000000..741a2d9d42cf166 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-11-20-50-03.gh-issue-156812.nqPw30.rst @@ -0,0 +1,10 @@ +Serializing a document type declaration, a comment or a processing +instruction in :mod:`xml.dom.minidom` now checks the structural rules of XML. +A system literal is now quoted with the quote which it does not contain, +and :exc:`ValueError` is raised for an invalid public identifier, +for a literal containing both quotes, +for a public identifier without a system identifier, +for a comment ending with ``-``, +and for a processing instruction containing ``?>`` in the data +or using the reserved target ``xml``. +The characters are still not checked. diff --git a/Misc/NEWS.d/next/Library/2026-11-12-08-38-09.gh-issue-161840.YcEVjO.rst b/Misc/NEWS.d/next/Library/2026-11-12-08-38-09.gh-issue-161840.YcEVjO.rst new file mode 100644 index 000000000000000..f1e63af06fef87c --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-12-08-38-09.gh-issue-161840.YcEVjO.rst @@ -0,0 +1,3 @@ +Propagate exceptions raised while getting the length of the assigned value +in :mod:`ctypes` array slice assignment instead of replacing them with a +:exc:`ValueError`. diff --git a/Misc/NEWS.d/next/Library/2026-11-12-17-53-13.gh-issue-161861.Kf7Qm2.rst b/Misc/NEWS.d/next/Library/2026-11-12-17-53-13.gh-issue-161861.Kf7Qm2.rst new file mode 100644 index 000000000000000..febea87b27d5a1b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-12-17-53-13.gh-issue-161861.Kf7Qm2.rst @@ -0,0 +1,2 @@ +Preserve the active request's ``continue_timeout`` when a second +:meth:`~http.client.HTTPConnection.putrequest` call is rejected. diff --git a/Misc/NEWS.d/next/Library/2026-11-13-09-49-13.gh-issue-152845.ZipFlags.rst b/Misc/NEWS.d/next/Library/2026-11-13-09-49-13.gh-issue-152845.ZipFlags.rst new file mode 100644 index 000000000000000..70cf5134d3fe9f9 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-13-09-49-13.gh-issue-152845.ZipFlags.rst @@ -0,0 +1,3 @@ +Fix :mod:`zipfile` dropping the UTF-8 (EFS) flag for existing entries +when rewriting an archive in append mode, and honor an explicitly set +flag on new entries. Patch by Kasra Ghodsi. diff --git a/Misc/NEWS.d/next/Library/2026-11-13-12-01-53.gh-issue-161945.X8oFTq.rst b/Misc/NEWS.d/next/Library/2026-11-13-12-01-53.gh-issue-161945.X8oFTq.rst new file mode 100644 index 000000000000000..95adcdb8c25ba17 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-13-12-01-53.gh-issue-161945.X8oFTq.rst @@ -0,0 +1,3 @@ +:meth:`zipfile.ZipFile.open` now raises :exc:`~zipfile.BadZipFile` when a +member's compression method differs between the central directory and the +local file header. diff --git a/Misc/NEWS.d/next/Library/2026-11-14-21-04-56.gh-issue-161996.35uL2d.rst b/Misc/NEWS.d/next/Library/2026-11-14-21-04-56.gh-issue-161996.35uL2d.rst new file mode 100644 index 000000000000000..561bb62d6537073 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-14-21-04-56.gh-issue-161996.35uL2d.rst @@ -0,0 +1,2 @@ +Fix a crash in :meth:`concurrent.interpreters.Interpreter.exec` when the +uncaught exception's ``__str__`` raises. diff --git a/Misc/NEWS.d/next/Library/2026-11-15-02-06-21.gh-issue-162028.jAnDAg.rst b/Misc/NEWS.d/next/Library/2026-11-15-02-06-21.gh-issue-162028.jAnDAg.rst new file mode 100644 index 000000000000000..a52a970039d3df0 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-15-02-06-21.gh-issue-162028.jAnDAg.rst @@ -0,0 +1,2 @@ +Fix the position reported by the pure Python :mod:`json` decoder for an +invalid escape. It now points to the backslash, like the C decoder. diff --git a/Misc/NEWS.d/next/Library/2026-11-15-03-10-31.gh-issue-162031.2k-3CG.rst b/Misc/NEWS.d/next/Library/2026-11-15-03-10-31.gh-issue-162031.2k-3CG.rst new file mode 100644 index 000000000000000..01f1311c735d9b1 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-15-03-10-31.gh-issue-162031.2k-3CG.rst @@ -0,0 +1,3 @@ +Fix :meth:`io.BufferedIOBase.readinto` and :meth:`~io.BufferedIOBase.readinto1` +raising :exc:`TypeError` instead of returning ``None`` when called on a +non-blocking stream with no data available. diff --git a/Misc/NEWS.d/next/Library/2026-11-15-17-30-00.gh-issue-162016.pNbStd.rst b/Misc/NEWS.d/next/Library/2026-11-15-17-30-00.gh-issue-162016.pNbStd.rst new file mode 100644 index 000000000000000..5fa107c8c64271f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-15-17-30-00.gh-issue-162016.pNbStd.rst @@ -0,0 +1,4 @@ +Fix :meth:`subprocess.Popen.communicate` hanging or blocking past its +*timeout* while writing to the child's stdin on macOS and FreeBSD. This +works around a kernel bug most likely seen on loaded hosts with many pipes +in active use at once. diff --git a/Misc/NEWS.d/next/Library/2026-11-16-16-10-42.gh-issue-157579.6choQ_.rst b/Misc/NEWS.d/next/Library/2026-11-16-16-10-42.gh-issue-157579.6choQ_.rst new file mode 100644 index 000000000000000..1bd89a77b5995c1 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-16-16-10-42.gh-issue-157579.6choQ_.rst @@ -0,0 +1,3 @@ +The error handler :class:`~tempfile.TemporaryDirectory` uses to clean up +unreadable and inaccessible files no longer fails for temporary directories +created using :class:`bytes` paths. diff --git a/Misc/NEWS.d/next/Library/2026-11-18-12-18-53.gh-issue-149584.rDchNk.rst b/Misc/NEWS.d/next/Library/2026-11-18-12-18-53.gh-issue-149584.rDchNk.rst new file mode 100644 index 000000000000000..2d0e9d203cf6b3e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-18-12-18-53.gh-issue-149584.rDchNk.rst @@ -0,0 +1,3 @@ +Read stack chunks directly in :mod:`profiling.sampling`, without the page +cache. This removes a redundant retry on macOS that can read a replacement +chunk after the target process reuses the same address. diff --git a/Misc/NEWS.d/next/Library/2026-11-18-18-28-37.gh-issue-162230.ezR86S.rst b/Misc/NEWS.d/next/Library/2026-11-18-18-28-37.gh-issue-162230.ezR86S.rst new file mode 100644 index 000000000000000..00b96c972ece6f6 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-18-18-28-37.gh-issue-162230.ezR86S.rst @@ -0,0 +1,3 @@ +Speed up :meth:`!io.BufferedRWPair.readline`. If a non-blocking read would +block, return the bytes read so far (possibly ``b''``). Previously, it raised +:exc:`OSError`. diff --git a/Misc/NEWS.d/next/Library/2026-11-19-17-55-31.gh-issue-162282.1WW-xb.rst b/Misc/NEWS.d/next/Library/2026-11-19-17-55-31.gh-issue-162282.1WW-xb.rst new file mode 100644 index 000000000000000..0d72db13e0c2bec --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-19-17-55-31.gh-issue-162282.1WW-xb.rst @@ -0,0 +1 @@ +Fix quadratic-time cost in :meth:`urllib.robotparser.RobotFileParser.parse` when a single group contains many identical ``User-agent:`` lines. diff --git a/Misc/NEWS.d/next/Library/2026-11-19-19-44-33.gh-issue-162285.wnH4aQ.rst b/Misc/NEWS.d/next/Library/2026-11-19-19-44-33.gh-issue-162285.wnH4aQ.rst new file mode 100644 index 000000000000000..ff955a30053d273 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-19-19-44-33.gh-issue-162285.wnH4aQ.rst @@ -0,0 +1,3 @@ +Fix quadratic memory use in :mod:`xmlrpc.client` when decoding malformed +XML-RPC packets containing nested string elements. This can cause ``loads()`` +to raise on malformed packets that were previously silently accepted. diff --git a/Misc/NEWS.d/next/Library/2026-11-19-22-01-29.gh-issue-162246.y3L8nP.rst b/Misc/NEWS.d/next/Library/2026-11-19-22-01-29.gh-issue-162246.y3L8nP.rst new file mode 100644 index 000000000000000..702b38215ed6efb --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-19-22-01-29.gh-issue-162246.y3L8nP.rst @@ -0,0 +1,2 @@ +Fix :class:`io.BufferedRWPair` losing buffered writes on deallocation when the +reader and writer share a raw stream. diff --git a/Misc/NEWS.d/next/Library/2026-11-20-09-30-00.gh-issue-162217.wC7sHd.rst b/Misc/NEWS.d/next/Library/2026-11-20-09-30-00.gh-issue-162217.wC7sHd.rst new file mode 100644 index 000000000000000..be12568cb8f7fec --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-20-09-30-00.gh-issue-162217.wC7sHd.rst @@ -0,0 +1,4 @@ +Fix :exc:`asyncio.InvalidStateError` being logged when the standard input of +an :mod:`asyncio` subprocess is closed after a task waiting in +:meth:`proc.stdin.wait_closed() ` was +cancelled. diff --git a/Misc/NEWS.d/next/Library/2026-11-21-11-11-34.gh-issue-162246.jN-ORE.rst b/Misc/NEWS.d/next/Library/2026-11-21-11-11-34.gh-issue-162246.jN-ORE.rst new file mode 100644 index 000000000000000..d596bd87ad31e95 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-21-11-11-34.gh-issue-162246.jN-ORE.rst @@ -0,0 +1,2 @@ +Fix a reference leak in :class:`io.BufferedRWPair` when :meth:`~object.__init__` +is called more than once: the previous reader and writer are now released. diff --git a/Misc/NEWS.d/next/Library/2026-11-21-13-50-09.gh-issue-162061.UbvZxJ.rst b/Misc/NEWS.d/next/Library/2026-11-21-13-50-09.gh-issue-162061.UbvZxJ.rst new file mode 100644 index 000000000000000..db5b2e79b5b2db0 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-21-13-50-09.gh-issue-162061.UbvZxJ.rst @@ -0,0 +1,2 @@ +Fix the asyncio call graph to show which task awaits :func:`asyncio.gather`. +Patch by Timofei Ivankov. diff --git a/Misc/NEWS.d/next/Library/2026-11-21-20-51-29.gh-issue-162395.l8Vlxo.rst b/Misc/NEWS.d/next/Library/2026-11-21-20-51-29.gh-issue-162395.l8Vlxo.rst new file mode 100644 index 000000000000000..563686f8561aa78 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-21-20-51-29.gh-issue-162395.l8Vlxo.rst @@ -0,0 +1,2 @@ +Fix the asyncio call graph to show which task awaits the future returned by +:func:`asyncio.shield`. Patch by Timofei Ivankov. diff --git a/Misc/NEWS.d/next/Library/2026-11-22-15-53-58.gh-issue-162350.2xG9ZI.rst b/Misc/NEWS.d/next/Library/2026-11-22-15-53-58.gh-issue-162350.2xG9ZI.rst new file mode 100644 index 000000000000000..df101c5386cb45e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-22-15-53-58.gh-issue-162350.2xG9ZI.rst @@ -0,0 +1,3 @@ +Add ``@vectorcall`` for :class:`asyncio.Future` and :class:`asyncio.Task` +constructors. The performance boost is 33% for the future creation and 15% +for the task. diff --git a/Misc/NEWS.d/next/Library/2026-11-22-15-56-36.gh-issue-162282.QjKIag.rst b/Misc/NEWS.d/next/Library/2026-11-22-15-56-36.gh-issue-162282.QjKIag.rst new file mode 100644 index 000000000000000..70f534e8f9215ed --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-22-15-56-36.gh-issue-162282.QjKIag.rst @@ -0,0 +1,3 @@ +Fix quadratic-time cost in :mod:`urllib.robotparser` when many groups share +a ``User-agent:``, and when a group with many user agents is checked for +a user agent that is not listed explicitly. diff --git a/Misc/NEWS.d/next/Library/2026-11-23-02-10-10.gh-issue-162467.6hMRI-.rst b/Misc/NEWS.d/next/Library/2026-11-23-02-10-10.gh-issue-162467.6hMRI-.rst new file mode 100644 index 000000000000000..fccff39902eb5e5 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-23-02-10-10.gh-issue-162467.6hMRI-.rst @@ -0,0 +1,3 @@ +Speed up :meth:`datetime.timedelta.total_seconds` and +:meth:`datetime.datetime.timestamp` on aware datetimes. Patch by Maurycy +Pawłowski-Wieroński. diff --git a/Misc/NEWS.d/next/Library/2026-11-24-12-31-49.gh-issue-159865.aB3eGx.rst b/Misc/NEWS.d/next/Library/2026-11-24-12-31-49.gh-issue-159865.aB3eGx.rst new file mode 100644 index 000000000000000..aea5534e1dffc1a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-24-12-31-49.gh-issue-159865.aB3eGx.rst @@ -0,0 +1,2 @@ +Fix :mod:`profiling.sampling` dropping exception-mode samples when a thread +blocks inside an exception handler. diff --git a/Misc/NEWS.d/next/Library/2026-11-24-15-30-00.gh-issue-84256.Fz7Rk2.rst b/Misc/NEWS.d/next/Library/2026-11-24-15-30-00.gh-issue-84256.Fz7Rk2.rst new file mode 100644 index 000000000000000..85b5245b68f7e50 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-24-15-30-00.gh-issue-84256.Fz7Rk2.rst @@ -0,0 +1,3 @@ +Fix a crash in :mod:`tkinter` on Windows when a Tk event handler, such as +a ```` binding, is called while another event loop is running, +for example when the window is resized while a native dialog is shown. diff --git a/Misc/NEWS.d/next/Library/2026-11-24-17-00-00.gh-issue-140488.Bw4tIq.rst b/Misc/NEWS.d/next/Library/2026-11-24-17-00-00.gh-issue-140488.Bw4tIq.rst new file mode 100644 index 000000000000000..ad13320d20a82d2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-24-17-00-00.gh-issue-140488.Bw4tIq.rst @@ -0,0 +1,3 @@ +The :mod:`tkinter` event loop running at the interactive prompt no longer +polls on Unix if Tcl is threaded. It now waits for events or input, so the +process does not wake up every few milliseconds while idle. diff --git a/Misc/NEWS.d/next/Library/2026-11-24-17-56-46.gh-issue-159207.3PCgei.rst b/Misc/NEWS.d/next/Library/2026-11-24-17-56-46.gh-issue-159207.3PCgei.rst new file mode 100644 index 000000000000000..b80c2f7d2a3e93d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-24-17-56-46.gh-issue-159207.3PCgei.rst @@ -0,0 +1,4 @@ +Reduce the memory used by :mod:`profiling.sampling` when replaying binary +profiles on Linux and Windows. Sample data is now read one block at a time +instead of being loaded into memory in full, so the memory used for samples +stays small even for very long captures. diff --git a/Misc/NEWS.d/next/Library/2026-11-24-19-00-00.gh-issue-153020.Hk2vTs.rst b/Misc/NEWS.d/next/Library/2026-11-24-19-00-00.gh-issue-153020.Hk2vTs.rst new file mode 100644 index 000000000000000..7c2a81de7cf8bb2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-24-19-00-00.gh-issue-153020.Hk2vTs.rst @@ -0,0 +1,6 @@ +Fix a crash in :mod:`tkinter` at the interactive prompt if the first Tcl +interpreter was created in a thread which has since exited. The event hook +which runs Tcl events while waiting for input is also no longer removed when +an interpreter is deleted in other thread while other interpreters still +exist, and its state no longer has data races in the :term:`free-threaded +build`. diff --git a/Misc/NEWS.d/next/Library/2026-11-25-20-49-22.gh-issue-162622.qAs2pK.rst b/Misc/NEWS.d/next/Library/2026-11-25-20-49-22.gh-issue-162622.qAs2pK.rst new file mode 100644 index 000000000000000..1f6c1b8cf6fe3e2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-25-20-49-22.gh-issue-162622.qAs2pK.rst @@ -0,0 +1,2 @@ +Preserve literal braces in f-string and t-string format specifiers when +using :func:`ast.unparse`. diff --git a/Misc/NEWS.d/next/Library/2026-11-25-21-00-00.gh-issue-162647.Qm4Tsx.rst b/Misc/NEWS.d/next/Library/2026-11-25-21-00-00.gh-issue-162647.Qm4Tsx.rst new file mode 100644 index 000000000000000..cf069c8985d8710 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-25-21-00-00.gh-issue-162647.Qm4Tsx.rst @@ -0,0 +1,4 @@ +Fix :mod:`tkinter` when Tcl interpreters run :meth:`!mainloop` in different +threads. :meth:`!quit` no longer stops the main loop of other interpreter, +and stops the main loop even if it waits for events. An exception raised in +a callback is no longer raised by the main loop in other thread. diff --git a/Misc/NEWS.d/next/Library/2026-11-26-12-00-00.gh-issue-162650.Nm8Dsq.rst b/Misc/NEWS.d/next/Library/2026-11-26-12-00-00.gh-issue-162650.Nm8Dsq.rst new file mode 100644 index 000000000000000..0f4108e07b76a51 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-26-12-00-00.gh-issue-162650.Nm8Dsq.rst @@ -0,0 +1,3 @@ +Fix :mod:`tkinter` calls from other threads failing with :exc:`RuntimeError` +after a nested :meth:`!mainloop` exited, for example after +:meth:`!SimpleDialog.go` returned. diff --git a/Misc/NEWS.d/next/Library/2026-11-26-14-05-07.gh-issue-138121.-AVsWv.rst b/Misc/NEWS.d/next/Library/2026-11-26-14-05-07.gh-issue-138121.-AVsWv.rst new file mode 100644 index 000000000000000..7348b5cb23a1943 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-26-14-05-07.gh-issue-138121.-AVsWv.rst @@ -0,0 +1,2 @@ +:meth:`asyncio.Lock.locked` now returns ``True`` when it has active waiters. +Contributed by Emerson Beckwith. diff --git a/Misc/NEWS.d/next/Library/README.rst b/Misc/NEWS.d/next/Library/README.rst index 178ac664cc0be1d..6d2d30eca0fd050 100644 --- a/Misc/NEWS.d/next/Library/README.rst +++ b/Misc/NEWS.d/next/Library/README.rst @@ -1,3 +1 @@ -Put news entry `blurb`_ files for the *Library* section in this directory. - -.. _blurb: https://pypi.org/project/blurb/ +Put news entry ``blurb`` files for the *Library* section in this directory. diff --git a/Misc/NEWS.d/next/Security/2026-01-16-11-58-19.gh-issue-143927.aviFeG.rst b/Misc/NEWS.d/next/Security/2026-01-16-11-58-19.gh-issue-143927.aviFeG.rst deleted file mode 100644 index ca554997e5c3963..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-01-16-11-58-19.gh-issue-143927.aviFeG.rst +++ /dev/null @@ -1,2 +0,0 @@ -Normalize all line endings (CR, CRLF, and LF) to LF+TAB when writing -multi-line configparser values. diff --git a/Misc/NEWS.d/next/Security/2026-04-26-19-30-45.gh-issue-149018.a9SqWb.rst b/Misc/NEWS.d/next/Security/2026-04-26-19-30-45.gh-issue-149018.a9SqWb.rst deleted file mode 100644 index d1b5b368684e6a5..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-04-26-19-30-45.gh-issue-149018.a9SqWb.rst +++ /dev/null @@ -1,3 +0,0 @@ -Improved protection against XML hash-flooding attacks in -:mod:`xml.parsers.expat` and :mod:`xml.etree.ElementTree` when Python is -compiled with libExpat 2.8.0 or later. diff --git a/Misc/NEWS.d/next/Security/2026-04-27-16-36-11.gh-issue-149079.vKl-LM.rst b/Misc/NEWS.d/next/Security/2026-04-27-16-36-11.gh-issue-149079.vKl-LM.rst deleted file mode 100644 index 4ed22b58f7405f5..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-04-27-16-36-11.gh-issue-149079.vKl-LM.rst +++ /dev/null @@ -1,5 +0,0 @@ -Fix a potential denial of service in :func:`unicodedata.normalize`. The -canonical ordering step of Unicode normalization used a quadratic-time insertion -sort for reordering combining characters, which could be exploited with -crafted input containing many combining characters in non-canonical order. -Replaced with a linear-time counting sort for long runs. diff --git a/Misc/NEWS.d/next/Security/2026-05-03-21-00-00.gh-issue-149486.tarflt.rst b/Misc/NEWS.d/next/Security/2026-05-03-21-00-00.gh-issue-149486.tarflt.rst deleted file mode 100644 index 7c69edb683cf80a..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-05-03-21-00-00.gh-issue-149486.tarflt.rst +++ /dev/null @@ -1,5 +0,0 @@ -:func:`tarfile.data_filter` now validates link targets using the same -normalised value that is written to disk, strips trailing separators from -the member name when resolving a symlink's directory, and rejects link -members that would replace the destination directory itself. This closes -several path-traversal bypasses of the ``data`` extraction filter. diff --git a/Misc/NEWS.d/next/Security/2026-05-08-02-18-54.gh-issue-149474.ujQ-mu.rst b/Misc/NEWS.d/next/Security/2026-05-08-02-18-54.gh-issue-149474.ujQ-mu.rst deleted file mode 100644 index 48e718b95ebe3ae..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-05-08-02-18-54.gh-issue-149474.ujQ-mu.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix the binary writer in :mod:`profiling.sampling` not firing the audit -(:pep:`578`) when creating the output file. The writer and the reader now -accept any path-like object. Patch by Maurycy Pawłowski-Wieroński. diff --git a/Misc/NEWS.d/next/Security/2026-05-10-18-05-32.gh-issue-87451.XkKB6M.rst b/Misc/NEWS.d/next/Security/2026-05-10-18-05-32.gh-issue-87451.XkKB6M.rst deleted file mode 100644 index 21a79c3e0e7db74..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-05-10-18-05-32.gh-issue-87451.XkKB6M.rst +++ /dev/null @@ -1,6 +0,0 @@ -The :mod:`ftplib` module's undocumented ``ftpcp`` function no longer trusts -the IPv4 address value returned from the source server in response to the -``PASV`` command by default, completing the fix for CVE-2021-4189. As with -:class:`ftplib.FTP`, the former behavior can be re-enabled by setting the -``trust_server_pasv_ipv4_address`` attribute on the source :class:`ftplib.FTP` -instance to ``True``. Thanks to Qi Deng at Aurascape AI for the report. diff --git a/Misc/NEWS.d/next/Security/2026-05-11-21-15-07.gh-issue-149698.OudOcW.rst b/Misc/NEWS.d/next/Security/2026-05-11-21-15-07.gh-issue-149698.OudOcW.rst deleted file mode 100644 index 3c8671b9a5adc43..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-05-11-21-15-07.gh-issue-149698.OudOcW.rst +++ /dev/null @@ -1,2 +0,0 @@ -Update bundled `libexpat `_ to version 2.8.1 -for the fix for :cve:`2026-45186`. diff --git a/Misc/NEWS.d/next/Security/2026-05-18-17-46-00.gh-issue-149835.EebFlk.rst b/Misc/NEWS.d/next/Security/2026-05-18-17-46-00.gh-issue-149835.EebFlk.rst deleted file mode 100644 index 20cab736552486d..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-05-18-17-46-00.gh-issue-149835.EebFlk.rst +++ /dev/null @@ -1,3 +0,0 @@ -:func:`shutil.move` now resolves symlinks via :func:`os.path.realpath` -when checking whether the destination is inside the source directory, -preventing a symlink-based bypass of that guard. diff --git a/Misc/NEWS.d/next/Security/2026-05-30-00-00-00.gh-issue-150743.httpdos.rst b/Misc/NEWS.d/next/Security/2026-05-30-00-00-00.gh-issue-150743.httpdos.rst deleted file mode 100644 index abc07d91c63fcaf..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-05-30-00-00-00.gh-issue-150743.httpdos.rst +++ /dev/null @@ -1,7 +0,0 @@ -:mod:`http.client` now limits the number of chunked-response trailer lines -it will read to :attr:`~http.client.HTTPConnection.max_response_headers` -(100 by default), and the number of interim (1xx) responses it will skip -to 100. A malicious or broken server could previously stream trailer -lines or ``100 Continue`` responses forever, hanging the client even when -a socket timeout was in use. -Reported by ``@YLChen-007`` via GHSA-w4q2-g22w-6fr4. diff --git a/Misc/NEWS.d/next/Security/2026-05-30-09-36-20.gh-issue-150599.nlHqU-.rst b/Misc/NEWS.d/next/Security/2026-05-30-09-36-20.gh-issue-150599.nlHqU-.rst deleted file mode 100644 index a37d86cf423f820..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-05-30-09-36-20.gh-issue-150599.nlHqU-.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix a possible stack buffer overflow in :mod:`bz2` when a -:class:`bz2.BZ2Decompressor` is reused after a decompression error. -The decompressor now becomes unusable after libbz2 reports an error. diff --git a/Misc/NEWS.d/next/Security/2026-06-09-10-23-57.gh-issue-151159.91GpWQ.rst b/Misc/NEWS.d/next/Security/2026-06-09-10-23-57.gh-issue-151159.91GpWQ.rst deleted file mode 100644 index 735164c1a65ec33..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-06-09-10-23-57.gh-issue-151159.91GpWQ.rst +++ /dev/null @@ -1 +0,0 @@ -Update Android and iOS installers to use OpenSSL 3.5.7. diff --git a/Misc/NEWS.d/next/Security/2026-06-09-23-38-08.gh-issue-151159.ds-9f8.rst b/Misc/NEWS.d/next/Security/2026-06-09-23-38-08.gh-issue-151159.ds-9f8.rst deleted file mode 100644 index d9251a93b40b2cc..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-06-09-23-38-08.gh-issue-151159.ds-9f8.rst +++ /dev/null @@ -1 +0,0 @@ -Update macOS installer to use OpenSSL 3.5.7. diff --git a/Misc/NEWS.d/next/Security/2026-06-10-13-08-19.gh-issue-151558.mL74i2.rst b/Misc/NEWS.d/next/Security/2026-06-10-13-08-19.gh-issue-151558.mL74i2.rst deleted file mode 100644 index 74459d5680e21a3..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-06-10-13-08-19.gh-issue-151558.mL74i2.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fixed an vulnerability in the :mod:`tarfile` ``data`` and ``tar`` extraction -filters where crafted archives could create a symlink pointing outside the -destination directory. This was a bypass of :cve:`2025-4330`. diff --git a/Misc/NEWS.d/next/Security/2026-06-16-14-58-02.gh-issue-151544._bexVy.rst b/Misc/NEWS.d/next/Security/2026-06-16-14-58-02.gh-issue-151544._bexVy.rst deleted file mode 100644 index 418e3b4b9677943..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-06-16-14-58-02.gh-issue-151544._bexVy.rst +++ /dev/null @@ -1,4 +0,0 @@ -:file:`Modules/Setup.local` is no longer used as a landmark to discover -whether Python is running in a source tree, as it could potentially affect -actual installs. The :file:`pybuilddir.txt` file is now the sole indicator -of running in a source tree. diff --git a/Misc/NEWS.d/next/Security/2026-06-23-13-28-16.gh-issue-151981.xBHEcU.rst b/Misc/NEWS.d/next/Security/2026-06-23-13-28-16.gh-issue-151981.xBHEcU.rst deleted file mode 100644 index 2123ab8e081b1d9..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-06-23-13-28-16.gh-issue-151981.xBHEcU.rst +++ /dev/null @@ -1,2 +0,0 @@ -In :mod:`tarfile`, seeking a stream now stops when end of the stream is -reached. diff --git a/Misc/NEWS.d/next/Security/2026-06-23-14-19-30.gh-issue-151987.8mNIMf.rst b/Misc/NEWS.d/next/Security/2026-06-23-14-19-30.gh-issue-151987.8mNIMf.rst deleted file mode 100644 index 9eea7b32c4d2b4f..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-06-23-14-19-30.gh-issue-151987.8mNIMf.rst +++ /dev/null @@ -1,2 +0,0 @@ -The :meth:`tarfile.TarFile.extract` method now applies the given filter when -it extracts a link target from the archive as a fallback. diff --git a/Misc/NEWS.d/next/Security/2026-06-25-20-44-20.gh-issue-152216.VxiK5y.rst b/Misc/NEWS.d/next/Security/2026-06-25-20-44-20.gh-issue-152216.VxiK5y.rst deleted file mode 100644 index 2769048e001d694..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-06-25-20-44-20.gh-issue-152216.VxiK5y.rst +++ /dev/null @@ -1 +0,0 @@ -Update bundled `libexpat `_ to version 2.8.2. diff --git a/Misc/NEWS.d/next/Security/2026-07-04-17-00-00.gh-issue-153030.RovkP6.rst b/Misc/NEWS.d/next/Security/2026-07-04-17-00-00.gh-issue-153030.RovkP6.rst deleted file mode 100644 index d1d60593f4ba7d2..000000000000000 --- a/Misc/NEWS.d/next/Security/2026-07-04-17-00-00.gh-issue-153030.RovkP6.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fixed quadratic complexity in incremental parsing of long unterminated -constructs (such as tags or comments) in :class:`html.parser.HTMLParser`, -which could be exploited for a denial of service. diff --git a/Misc/NEWS.d/next/Security/2026-10-07-13-30-00.gh-issue-158907.k4Qm2p.rst b/Misc/NEWS.d/next/Security/2026-10-07-13-30-00.gh-issue-158907.k4Qm2p.rst new file mode 100644 index 000000000000000..67bbd3da1cbbe8d --- /dev/null +++ b/Misc/NEWS.d/next/Security/2026-10-07-13-30-00.gh-issue-158907.k4Qm2p.rst @@ -0,0 +1,5 @@ +:class:`~urllib.request.ProxyBasicAuthHandler` and +:class:`~urllib.request.ProxyDigestAuthHandler` no longer send credentials +in response to ``407`` from a direct origin. A scheme-less lookup against +the origin host could match passwords stored for an HTTPS URL and retry +the cleartext request with ``Proxy-Authorization``. diff --git a/Misc/NEWS.d/next/Security/2026-11-09-17-19-29.gh-issue-161707.xWzwqQ.rst b/Misc/NEWS.d/next/Security/2026-11-09-17-19-29.gh-issue-161707.xWzwqQ.rst new file mode 100644 index 000000000000000..63731daafff41ef --- /dev/null +++ b/Misc/NEWS.d/next/Security/2026-11-09-17-19-29.gh-issue-161707.xWzwqQ.rst @@ -0,0 +1,5 @@ +.. cve: CVE-2026-16052 + +:mod:`http.cookies` now raises :exc:`~http.cookies.CookieError` on any attempt +to set a value string that contains the reserved separator character ``;`` to +any attribute except :attr:`~http.cookies.Morsel.comment`. diff --git a/Misc/NEWS.d/next/Security/2026-11-23-19-30-04.gh-issue-162493.QeSfGU.rst b/Misc/NEWS.d/next/Security/2026-11-23-19-30-04.gh-issue-162493.QeSfGU.rst new file mode 100644 index 000000000000000..79314ee2650da67 --- /dev/null +++ b/Misc/NEWS.d/next/Security/2026-11-23-19-30-04.gh-issue-162493.QeSfGU.rst @@ -0,0 +1,3 @@ +Update bundled `libexpat `_ to version 2.11.0 +for the fixes to :cve:`2026-124317`, :cve:`2026-128241`, and +:cve:`2026-134703`. diff --git a/Misc/NEWS.d/next/Security/2026-11-24-11-39-37.gh-issue-162577.kgsLAF.rst b/Misc/NEWS.d/next/Security/2026-11-24-11-39-37.gh-issue-162577.kgsLAF.rst new file mode 100644 index 000000000000000..ea55b58ddec910d --- /dev/null +++ b/Misc/NEWS.d/next/Security/2026-11-24-11-39-37.gh-issue-162577.kgsLAF.rst @@ -0,0 +1,2 @@ +Update ``zstd`` to v1.6.0 in Android, iOS, and Windows builds to address +:cve:`2026-124851`. diff --git a/Misc/NEWS.d/next/Security/README.rst b/Misc/NEWS.d/next/Security/README.rst index 9ea371df667a430..84c1a3a6ed7a07c 100644 --- a/Misc/NEWS.d/next/Security/README.rst +++ b/Misc/NEWS.d/next/Security/README.rst @@ -1,3 +1 @@ -Put news entry `blurb`_ files for the *Security* section in this directory. - -.. _blurb: https://pypi.org/project/blurb/ +Put news entry ``blurb`` files for the *Security* section in this directory. diff --git a/Misc/NEWS.d/next/Tests/2023-09-03-12-53-53.gh-issue-108828.zoWIyX.rst b/Misc/NEWS.d/next/Tests/2023-09-03-12-53-53.gh-issue-108828.zoWIyX.rst new file mode 100644 index 000000000000000..2b9fbdd48dd4505 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2023-09-03-12-53-53.gh-issue-108828.zoWIyX.rst @@ -0,0 +1,9 @@ +Add support of labels in tests. The ``@test.support.mark('label')`` +decorator adds a label to a test method or class. +``test.support.mark_module('label')`` adds a label to the whole module. +Many :mod:`test.support` decorators like :func:`~test.support.requires_resource`, +:func:`~test.support.cpython_only` or :func:`~test.support.bigmemtest` add +labels automatically. A label can have a value (``True`` by default). Tests +which have or have not the specified label can be filtered by options +``--label`` and ``--no-label``; ``--label name=value`` matches a specific +value, while ``--label name`` matches any value. diff --git a/Misc/NEWS.d/next/Tests/2026-04-24-01-38-56.gh-issue-148853._uM4_Q.rst b/Misc/NEWS.d/next/Tests/2026-04-24-01-38-56.gh-issue-148853._uM4_Q.rst deleted file mode 100644 index 9d3fbc2590dc7a2..000000000000000 --- a/Misc/NEWS.d/next/Tests/2026-04-24-01-38-56.gh-issue-148853._uM4_Q.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix tests failing on FreeBSD in test.support's -in_systemd_nspawn_sync_suppressed() due to unreadable /run directory. diff --git a/Misc/NEWS.d/next/Tests/2026-05-13-14-53-23.gh-issue-149776.orqgsn.rst b/Misc/NEWS.d/next/Tests/2026-05-13-14-53-23.gh-issue-149776.orqgsn.rst deleted file mode 100644 index e86a9130ff9bfb6..000000000000000 --- a/Misc/NEWS.d/next/Tests/2026-05-13-14-53-23.gh-issue-149776.orqgsn.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix test_socket on Linux kernel 7.1 and newer: skip UDP Lite tests if it's -not supported. Patch by Victor Stinner. diff --git a/Misc/NEWS.d/next/Tests/2026-05-22-16-41-45.gh-issue-150114.UdMikH.rst b/Misc/NEWS.d/next/Tests/2026-05-22-16-41-45.gh-issue-150114.UdMikH.rst deleted file mode 100644 index a140bf921972ed9..000000000000000 --- a/Misc/NEWS.d/next/Tests/2026-05-22-16-41-45.gh-issue-150114.UdMikH.rst +++ /dev/null @@ -1,2 +0,0 @@ -On Linux, regrtest now logs the total memory usage of all Python processes. -Read the private memory in ``/proc/pid/smaps``. Patch by Victor Stinner. diff --git a/Misc/NEWS.d/next/Tests/2026-05-25-15-39-53.gh-issue-150387.yzZ7jq.rst b/Misc/NEWS.d/next/Tests/2026-05-25-15-39-53.gh-issue-150387.yzZ7jq.rst deleted file mode 100644 index 663a357a1792042..000000000000000 --- a/Misc/NEWS.d/next/Tests/2026-05-25-15-39-53.gh-issue-150387.yzZ7jq.rst +++ /dev/null @@ -1,5 +0,0 @@ -Fix hang in -``test.test_profiling.test_sampling_profiler.test_live_collector_ui.TestLiveModeErrors.test_run_failed_script_live`` -on slow buildbots. The test now always queues a final ``q`` keystroke so the -live TUI loop exits even when the profiler collects enough samples to enter -the post-finished input loop. diff --git a/Misc/NEWS.d/next/Tests/2026-06-06-16-22-00.gh-issue-150966.7N9x5Q.rst b/Misc/NEWS.d/next/Tests/2026-06-06-16-22-00.gh-issue-150966.7N9x5Q.rst deleted file mode 100644 index 3bbb471163d64e1..000000000000000 --- a/Misc/NEWS.d/next/Tests/2026-06-06-16-22-00.gh-issue-150966.7N9x5Q.rst +++ /dev/null @@ -1,2 +0,0 @@ -Avoid prematurely terminating failing live sampling profiler test targets, -which made stderr assertions flaky on ASAN buildbots. diff --git a/Misc/NEWS.d/next/Tests/2026-06-09-11-52-52.gh-issue-151130.1vslPH.rst b/Misc/NEWS.d/next/Tests/2026-06-09-11-52-52.gh-issue-151130.1vslPH.rst deleted file mode 100644 index 0333e66446ce161..000000000000000 --- a/Misc/NEWS.d/next/Tests/2026-06-09-11-52-52.gh-issue-151130.1vslPH.rst +++ /dev/null @@ -1 +0,0 @@ -Add more tests for ``PyWeakref_*`` C API. diff --git a/Misc/NEWS.d/next/Tests/2026-06-16-05-11-38.gh-issue-151096.Kq3Lp9.rst b/Misc/NEWS.d/next/Tests/2026-06-16-05-11-38.gh-issue-151096.Kq3Lp9.rst deleted file mode 100644 index 3251c6fb094723b..000000000000000 --- a/Misc/NEWS.d/next/Tests/2026-06-16-05-11-38.gh-issue-151096.Kq3Lp9.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix ``test_embed`` failing when CPython is configured with a split exec prefix -(``--exec-prefix`` differing from ``--prefix``). diff --git a/Misc/NEWS.d/next/Tests/2026-06-22-19-45-00.gh-issue-151626.K9pZ2x.rst b/Misc/NEWS.d/next/Tests/2026-06-22-19-45-00.gh-issue-151626.K9pZ2x.rst deleted file mode 100644 index 9858415018ae1ba..000000000000000 --- a/Misc/NEWS.d/next/Tests/2026-06-22-19-45-00.gh-issue-151626.K9pZ2x.rst +++ /dev/null @@ -1,5 +0,0 @@ -Fix several tests in ``test.test_inspect``, ``test.test_import``, -``test.test_importlib``, ``test.test_py_compile`` and -``test.test_compileall`` that failed when the test suite was run with -:envvar:`PYTHONPYCACHEPREFIX` set. These tests now neutralize the pycache -prefix where they assume the default ``__pycache__`` bytecode layout. diff --git a/Misc/NEWS.d/next/Tests/2026-09-16-14-37-28.gh-issue-126253.9FOKPp.rst b/Misc/NEWS.d/next/Tests/2026-09-16-14-37-28.gh-issue-126253.9FOKPp.rst new file mode 100644 index 000000000000000..370d822f883aa9a --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-09-16-14-37-28.gh-issue-126253.9FOKPp.rst @@ -0,0 +1 @@ +Fix ``test_os.test_attributes()`` on Windows NTFS: ignore unknown file attributes. diff --git a/Misc/NEWS.d/next/Tests/2026-11-10-14-49-01.gh-issue-161739.NZTbYC.rst b/Misc/NEWS.d/next/Tests/2026-11-10-14-49-01.gh-issue-161739.NZTbYC.rst new file mode 100644 index 000000000000000..a480b9788f7574e --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-11-10-14-49-01.gh-issue-161739.NZTbYC.rst @@ -0,0 +1,2 @@ +``test_hashlibtest_pbkdf2_hmac_c`` from ``test_haslib`` no longer fails with +``ValueError: [Provider routines] invalid salt length`` with FIPS enabled. diff --git a/Misc/NEWS.d/next/Tests/2026-11-15-09-43-15.gh-issue-162034.egx5QV.rst b/Misc/NEWS.d/next/Tests/2026-11-15-09-43-15.gh-issue-162034.egx5QV.rst new file mode 100644 index 000000000000000..1b7d2c4ad5f27c6 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-11-15-09-43-15.gh-issue-162034.egx5QV.rst @@ -0,0 +1,2 @@ +The Apple testbed projects now build when the path of the project contains a +space. diff --git a/Misc/NEWS.d/next/Tests/2026-11-17-00-39-51.gh-issue-162034.FmiuNi.rst b/Misc/NEWS.d/next/Tests/2026-11-17-00-39-51.gh-issue-162034.FmiuNi.rst new file mode 100644 index 000000000000000..1764fa2a458e599 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-11-17-00-39-51.gh-issue-162034.FmiuNi.rst @@ -0,0 +1,2 @@ +Fix the Apple testbed's extension module processing for an XCframework or +package path with a space, or a build path with brackets or a backslash. diff --git a/Misc/NEWS.d/next/Tests/2026-11-17-15-57-41.gh-issue-162144.pL5k29.rst b/Misc/NEWS.d/next/Tests/2026-11-17-15-57-41.gh-issue-162144.pL5k29.rst new file mode 100644 index 000000000000000..bbd4a9cf54752e0 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-11-17-15-57-41.gh-issue-162144.pL5k29.rst @@ -0,0 +1,3 @@ +Skip ``@support.nomemtest`` tests when using a thread sanitizer (TSan). +``set_nomemory()`` and ``call_with_nomemory()`` functions of the +:mod:`!_testcapi` extension are not thread safe. Patch by Victor Stinner. diff --git a/Misc/NEWS.d/next/Tests/README.rst b/Misc/NEWS.d/next/Tests/README.rst index 8ea9b4ceb277bf5..d2e50e43d847905 100644 --- a/Misc/NEWS.d/next/Tests/README.rst +++ b/Misc/NEWS.d/next/Tests/README.rst @@ -1,3 +1 @@ -Put news entry `blurb`_ files for the *Tests* section in this directory. - -.. _blurb: https://pypi.org/project/blurb/ +Put news entry ``blurb`` files for the *Tests* section in this directory. diff --git a/Misc/NEWS.d/next/Tools-Demos/2024-06-17-13-52-04.gh-issue-111501.syFLAV.rst b/Misc/NEWS.d/next/Tools-Demos/2024-06-17-13-52-04.gh-issue-111501.syFLAV.rst deleted file mode 100644 index 2989d4b81b1dd39..000000000000000 --- a/Misc/NEWS.d/next/Tools-Demos/2024-06-17-13-52-04.gh-issue-111501.syFLAV.rst +++ /dev/null @@ -1 +0,0 @@ -PS1 is no longer exported by venv activate script diff --git a/Misc/NEWS.d/next/Tools-Demos/2026-05-22-18-51-09.gh-issue-150258.dh8GVK.rst b/Misc/NEWS.d/next/Tools-Demos/2026-05-22-18-51-09.gh-issue-150258.dh8GVK.rst deleted file mode 100644 index 02cad6c4f53d928..000000000000000 --- a/Misc/NEWS.d/next/Tools-Demos/2026-05-22-18-51-09.gh-issue-150258.dh8GVK.rst +++ /dev/null @@ -1 +0,0 @@ -Update the tooltip on the Tachyon flame graph to show both absolute and relative percentages. diff --git a/Misc/NEWS.d/next/Tools-Demos/2026-07-10-14-38-31.gh-issue-152384.uaPADM.rst b/Misc/NEWS.d/next/Tools-Demos/2026-07-10-14-38-31.gh-issue-152384.uaPADM.rst deleted file mode 100644 index 08b94d5486f64d8..000000000000000 --- a/Misc/NEWS.d/next/Tools-Demos/2026-07-10-14-38-31.gh-issue-152384.uaPADM.rst +++ /dev/null @@ -1,8 +0,0 @@ -The CPython Pixi packages are now all accessible at the same -``Tools/pixi-packages`` subdirectory, rather than at -``Tools/pixi-packages/{variant}`` as before. Variants are now selected not -via subdirectory but via ``flags``; see -https://pixi.prefix.dev/latest/concepts/package_specifications/#extras-and-flags -for usage instructions. The ``tsan-freethreading`` variant has been renamed -to ``tsan_freethreading``, while the ``default``, ``asan``, and -``freethreading`` variants retain their previous names. diff --git a/Misc/NEWS.d/next/Tools-Demos/README.rst b/Misc/NEWS.d/next/Tools-Demos/README.rst index 9f03d79b208653a..357f82862cb51a8 100644 --- a/Misc/NEWS.d/next/Tools-Demos/README.rst +++ b/Misc/NEWS.d/next/Tools-Demos/README.rst @@ -1,3 +1 @@ -Put news entry `blurb`_ files for the *Tools/Demos* section in this directory. - -.. _blurb: https://pypi.org/project/blurb/ +Put news entry ``blurb`` files for the *Tools/Demos* section in this directory. diff --git a/Misc/NEWS.d/next/Unsupported_platforms/README.rst b/Misc/NEWS.d/next/Unsupported_platforms/README.rst new file mode 100644 index 000000000000000..348b80cb4c7f111 --- /dev/null +++ b/Misc/NEWS.d/next/Unsupported_platforms/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *Unsupported platforms* section in this directory. diff --git a/Misc/NEWS.d/next/WASI/README.rst b/Misc/NEWS.d/next/WASI/README.rst new file mode 100644 index 000000000000000..ee55e287aed51e6 --- /dev/null +++ b/Misc/NEWS.d/next/WASI/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *WASI* section in this directory. diff --git a/Misc/NEWS.d/next/Windows/2026-04-21-16-07-11.gh-issue-140146.TAcUHA.rst b/Misc/NEWS.d/next/Windows/2026-04-21-16-07-11.gh-issue-140146.TAcUHA.rst deleted file mode 100644 index 2d3e42c86fd521f..000000000000000 --- a/Misc/NEWS.d/next/Windows/2026-04-21-16-07-11.gh-issue-140146.TAcUHA.rst +++ /dev/null @@ -1,3 +0,0 @@ -Prevent :mod:`tkinter` from hanging on Windows if stdin is redirected to a pipe in an -interactive session. This is helpful for testing interactive usage of -tkinter from a script, for example as part of the cpython test suite. diff --git a/Misc/NEWS.d/next/Windows/2026-04-29-14-44-51.gh-issue-138489.234aj6.rst b/Misc/NEWS.d/next/Windows/2026-04-29-14-44-51.gh-issue-138489.234aj6.rst deleted file mode 100644 index 4afb8f737b692e8..000000000000000 --- a/Misc/NEWS.d/next/Windows/2026-04-29-14-44-51.gh-issue-138489.234aj6.rst +++ /dev/null @@ -1,4 +0,0 @@ -Windows distributions now include a :file:`build-details.json` file (see -:pep:`739`). The legacy installer does not install it, but all other -distributions from python.org and all preset configurations in the -``PC\layout`` script will include one. diff --git a/Misc/NEWS.d/next/Windows/2026-05-06-21-36-53.gh-issue-124111.m4OBX8.rst b/Misc/NEWS.d/next/Windows/2026-05-06-21-36-53.gh-issue-124111.m4OBX8.rst deleted file mode 100644 index 9a57536f1dc96b6..000000000000000 --- a/Misc/NEWS.d/next/Windows/2026-05-06-21-36-53.gh-issue-124111.m4OBX8.rst +++ /dev/null @@ -1 +0,0 @@ -Updated Windows builds to use Tcl/Tk 9.0.3. diff --git a/Misc/NEWS.d/next/Windows/2026-05-14-22-09-46.gh-issue-149786.UI-HZM.rst b/Misc/NEWS.d/next/Windows/2026-05-14-22-09-46.gh-issue-149786.UI-HZM.rst deleted file mode 100644 index 64ca91a01f41afc..000000000000000 --- a/Misc/NEWS.d/next/Windows/2026-05-14-22-09-46.gh-issue-149786.UI-HZM.rst +++ /dev/null @@ -1 +0,0 @@ -Fixes virtual environment launchers on Windows free-threaded builds. diff --git a/Misc/NEWS.d/next/Windows/2026-06-04-18-53-18.gh-issue-150836.Wci7bZ.rst b/Misc/NEWS.d/next/Windows/2026-06-04-18-53-18.gh-issue-150836.Wci7bZ.rst deleted file mode 100644 index 6497b7927db7da3..000000000000000 --- a/Misc/NEWS.d/next/Windows/2026-06-04-18-53-18.gh-issue-150836.Wci7bZ.rst +++ /dev/null @@ -1 +0,0 @@ -Make installed tkinter work with Tcl/Tk 9 builds that embed the Tk script library in the Tk DLL on Windows. diff --git a/Misc/NEWS.d/next/Windows/2026-06-09-11-40-48.gh-issue-151159.JKVfme.rst b/Misc/NEWS.d/next/Windows/2026-06-09-11-40-48.gh-issue-151159.JKVfme.rst deleted file mode 100644 index ad1be115db5ce8f..000000000000000 --- a/Misc/NEWS.d/next/Windows/2026-06-09-11-40-48.gh-issue-151159.JKVfme.rst +++ /dev/null @@ -1 +0,0 @@ -Updated bundled version of OpenSSL to 3.5.7. diff --git a/Misc/NEWS.d/next/Windows/2026-06-09-11-55-41.gh-issue-151163.oizZYV.rst b/Misc/NEWS.d/next/Windows/2026-06-09-11-55-41.gh-issue-151163.oizZYV.rst deleted file mode 100644 index 580a87400862c52..000000000000000 --- a/Misc/NEWS.d/next/Windows/2026-06-09-11-55-41.gh-issue-151163.oizZYV.rst +++ /dev/null @@ -1 +0,0 @@ -Updated Windows builds to include SQLite version 3.53.2. diff --git a/Misc/NEWS.d/next/Windows/2026-06-28-13-03-57.gh-issue-152433.jUXFwC.rst b/Misc/NEWS.d/next/Windows/2026-06-28-13-03-57.gh-issue-152433.jUXFwC.rst deleted file mode 100644 index 348bfa4ee9c278c..000000000000000 --- a/Misc/NEWS.d/next/Windows/2026-06-28-13-03-57.gh-issue-152433.jUXFwC.rst +++ /dev/null @@ -1 +0,0 @@ -Use the Windows API ``GetFileSizeEx()`` for memory mapped files, rather than the older ``GetFileSize()``. diff --git a/Misc/NEWS.d/next/Windows/2026-06-29-16-29-50.gh-issue-152433._nhCjt.rst b/Misc/NEWS.d/next/Windows/2026-06-29-16-29-50.gh-issue-152433._nhCjt.rst deleted file mode 100644 index 0c420c124c2981f..000000000000000 --- a/Misc/NEWS.d/next/Windows/2026-06-29-16-29-50.gh-issue-152433._nhCjt.rst +++ /dev/null @@ -1,2 +0,0 @@ -Restores the ``mmap`` module when CPython is built from source for specific -Windows API sets. diff --git a/Misc/NEWS.d/next/Windows/2026-07-01-16-38-24.gh-issue-152433.jvEiHh.rst b/Misc/NEWS.d/next/Windows/2026-07-01-16-38-24.gh-issue-152433.jvEiHh.rst deleted file mode 100644 index d5aead5fbe0b9e2..000000000000000 --- a/Misc/NEWS.d/next/Windows/2026-07-01-16-38-24.gh-issue-152433.jvEiHh.rst +++ /dev/null @@ -1 +0,0 @@ -:mod:`ssl`: improve UWP build compatibility. diff --git a/Misc/NEWS.d/next/Windows/2026-07-29-13-05-00.gh-issue-140774.wA3ttr.rst b/Misc/NEWS.d/next/Windows/2026-07-29-13-05-00.gh-issue-140774.wA3ttr.rst new file mode 100644 index 000000000000000..aaf120efb992e79 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2026-07-29-13-05-00.gh-issue-140774.wA3ttr.rst @@ -0,0 +1,3 @@ +Fix :func:`os.chmod` with ``follow_symlinks=True``, :func:`os.fchmod` and +:meth:`pathlib.Path.chmod` on Windows: clearing the read-only attribute of a +file which has no other attribute set is no longer silently ignored. diff --git a/Misc/NEWS.d/next/Windows/2026-09-30-00-00-00.gh-issue-157917.48oa0L.rst b/Misc/NEWS.d/next/Windows/2026-09-30-00-00-00.gh-issue-157917.48oa0L.rst new file mode 100644 index 000000000000000..2d5e6a14a31d53f --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2026-09-30-00-00-00.gh-issue-157917.48oa0L.rst @@ -0,0 +1,9 @@ +Fix :attr:`sys.prefix`, :attr:`sys.exec_prefix` and :attr:`sys.executable` +retaining the ``\\?\`` extended-length path prefix in a virtual environment +when the interpreter is invoked through such a path on Windows. The venv +launcher reports its own path through ``GetModuleFileNameW``, which preserves +the prefix, and that value was used verbatim. Windows does not resolve +relative path components in extended-length paths, so the leaked prefix made +tools that join ``..`` components onto :mod:`sysconfig` paths fail with +``OSError: [Errno 22]``. The prefix is now stripped again, except for paths +that are still too long to be used without it. diff --git a/Misc/NEWS.d/next/Windows/2026-09-30-01-12-58.gh-issue-158414.738yJa.rst b/Misc/NEWS.d/next/Windows/2026-09-30-01-12-58.gh-issue-158414.738yJa.rst new file mode 100644 index 000000000000000..dba12665deddd93 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2026-09-30-01-12-58.gh-issue-158414.738yJa.rst @@ -0,0 +1 @@ +Fix a hang when writing an incomplete UTF-8 sequence to the Windows console. diff --git a/Misc/NEWS.d/next/Windows/2026-11-11-10-44-20.gh-issue-161735.MZLRnD.rst b/Misc/NEWS.d/next/Windows/2026-11-11-10-44-20.gh-issue-161735.MZLRnD.rst new file mode 100644 index 000000000000000..a824533a8caa9d6 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2026-11-11-10-44-20.gh-issue-161735.MZLRnD.rst @@ -0,0 +1 @@ +Updated bundled version of ``zlib-ng`` to v2.2.5. diff --git a/Misc/NEWS.d/next/Windows/README.rst b/Misc/NEWS.d/next/Windows/README.rst index 7dbc5805e3f99fa..1e65de35f0ad97b 100644 --- a/Misc/NEWS.d/next/Windows/README.rst +++ b/Misc/NEWS.d/next/Windows/README.rst @@ -1,3 +1 @@ -Put news entry `blurb`_ files for the *Windows* section in this directory. - -.. _blurb: https://pypi.org/project/blurb/ +Put news entry ``blurb`` files for the *Windows* section in this directory. diff --git a/Misc/NEWS.d/next/iOS/README.rst b/Misc/NEWS.d/next/iOS/README.rst new file mode 100644 index 000000000000000..c91d954958d32b0 --- /dev/null +++ b/Misc/NEWS.d/next/iOS/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *iOS* section in this directory. diff --git a/Misc/NEWS.d/next/macOS/2026-05-31-10-40-00.gh-issue-150644.zLWyjj.rst b/Misc/NEWS.d/next/macOS/2026-05-31-10-40-00.gh-issue-150644.zLWyjj.rst deleted file mode 100644 index 7452a7c765c0a86..000000000000000 --- a/Misc/NEWS.d/next/macOS/2026-05-31-10-40-00.gh-issue-150644.zLWyjj.rst +++ /dev/null @@ -1,3 +0,0 @@ -When system logging is enabled (with ``config.use_system_logger``, messages -are now tagged as public. This allows the macOS 26 system logger to view -messages without special configuration. diff --git a/Misc/NEWS.d/next/macOS/2026-06-09-11-52-35.gh-issue-151163.RlPXHq.rst b/Misc/NEWS.d/next/macOS/2026-06-09-11-52-35.gh-issue-151163.RlPXHq.rst deleted file mode 100644 index 7e9bf6f4587974e..000000000000000 --- a/Misc/NEWS.d/next/macOS/2026-06-09-11-52-35.gh-issue-151163.RlPXHq.rst +++ /dev/null @@ -1 +0,0 @@ -Updated macOS installer to include SQLite version 3.53.2. diff --git a/Misc/NEWS.d/next/macOS/2026-07-17-23-20-27.gh-issue-152023.QAAgdj.rst b/Misc/NEWS.d/next/macOS/2026-07-17-23-20-27.gh-issue-152023.QAAgdj.rst deleted file mode 100644 index afabb3d52249708..000000000000000 --- a/Misc/NEWS.d/next/macOS/2026-07-17-23-20-27.gh-issue-152023.QAAgdj.rst +++ /dev/null @@ -1,2 +0,0 @@ -Update macOS installer builds to SQLite 3.53.3. Enable median() and -percentile() functions. diff --git a/Misc/NEWS.d/next/macOS/2026-07-17-23-35-36.gh-issue-124111.dmM4lk.rst b/Misc/NEWS.d/next/macOS/2026-07-17-23-35-36.gh-issue-124111.dmM4lk.rst deleted file mode 100644 index 48ab66407831a86..000000000000000 --- a/Misc/NEWS.d/next/macOS/2026-07-17-23-35-36.gh-issue-124111.dmM4lk.rst +++ /dev/null @@ -1 +0,0 @@ -Update macOS installer to use Tcl/Tk 9.0.4. diff --git a/Misc/NEWS.d/next/macOS/README.rst b/Misc/NEWS.d/next/macOS/README.rst index 563766928cf9441..a3adb59b62631e8 100644 --- a/Misc/NEWS.d/next/macOS/README.rst +++ b/Misc/NEWS.d/next/macOS/README.rst @@ -1,3 +1 @@ -Put news entry `blurb`_ files for the *macOS* section in this directory. - -.. _blurb: https://pypi.org/project/blurb/ +Put news entry ``blurb`` files for the *macOS* section in this directory. diff --git a/Misc/externals.spdx.json b/Misc/externals.spdx.json index 523d20259adaaa9..b35ed3720943aba 100644 --- a/Misc/externals.spdx.json +++ b/Misc/externals.spdx.json @@ -70,84 +70,84 @@ "checksums": [ { "algorithm": "SHA256", - "checksumValue": "ca94e7c6c223d9caf77bb51aac5949186379608ea2a0cad3aa8bdf31856912e9" + "checksumValue": "d6cf0d9a651f25fe506f6b3dc133a80b9b79a0bc565f570dcf8fdbd597551485" } ], - "downloadLocation": "https://github.com/python/cpython-source-deps/archive/refs/tags/openssl-3.5.7.tar.gz", + "downloadLocation": "https://github.com/python/cpython-source-deps/archive/refs/tags/openssl-3.5.9.tar.gz", "externalRefs": [ { "referenceCategory": "SECURITY", - "referenceLocator": "cpe:2.3:a:openssl:openssl:3.5.7:*:*:*:*:*:*:*", + "referenceLocator": "cpe:2.3:a:openssl:openssl:3.5.9:*:*:*:*:*:*:*", "referenceType": "cpe23Type" } ], "licenseConcluded": "NOASSERTION", "name": "openssl", "primaryPackagePurpose": "SOURCE", - "versionInfo": "3.5.7" + "versionInfo": "3.5.9" }, { "SPDXID": "SPDXRef-PACKAGE-sqlite", "checksums": [ { "algorithm": "SHA256", - "checksumValue": "53f8711811090cc4d9ffc624c360f81e7b409763b145ab2e948998f1a0d6a612" + "checksumValue": "acc27a72ca7745781bb902269370303e778736a090585cc13acd2ea9ab785666" } ], - "downloadLocation": "https://github.com/python/cpython-source-deps/archive/refs/tags/sqlite-3.53.2.0.tar.gz", + "downloadLocation": "https://github.com/python/cpython-source-deps/archive/refs/tags/sqlite-3.53.4.0.tar.gz", "externalRefs": [ { "referenceCategory": "SECURITY", - "referenceLocator": "cpe:2.3:a:sqlite:sqlite:3.53.2.0:*:*:*:*:*:*:*", + "referenceLocator": "cpe:2.3:a:sqlite:sqlite:3.53.4.0:*:*:*:*:*:*:*", "referenceType": "cpe23Type" } ], "licenseConcluded": "NOASSERTION", "name": "sqlite", "primaryPackagePurpose": "SOURCE", - "versionInfo": "3.53.2.0" + "versionInfo": "3.53.4.0" }, { "SPDXID": "SPDXRef-PACKAGE-tcl", "checksums": [ { "algorithm": "SHA256", - "checksumValue": "7a1d1f3a2b8f4484a9c2a027a157963c18f85a81785e85fcb5d1e3df6b6a4fd4" + "checksumValue": "3ac2acd65ddaaac0b2b8df321b558419d21da20bf67ab39149b8248c85f0d214" } ], - "downloadLocation": "https://github.com/python/cpython-source-deps/archive/refs/tags/tcl-9.0.3.0.tar.gz", + "downloadLocation": "https://github.com/python/cpython-source-deps/archive/refs/tags/tcl-9.0.4.0.tar.gz", "externalRefs": [ { "referenceCategory": "SECURITY", - "referenceLocator": "cpe:2.3:a:tcl_tk:tcl_tk:9.0.3.0:*:*:*:*:*:*:*", + "referenceLocator": "cpe:2.3:a:tcl_tk:tcl_tk:9.0.4.0:*:*:*:*:*:*:*", "referenceType": "cpe23Type" } ], "licenseConcluded": "NOASSERTION", "name": "tcl", "primaryPackagePurpose": "SOURCE", - "versionInfo": "9.0.3.0" + "versionInfo": "9.0.4.0" }, { "SPDXID": "SPDXRef-PACKAGE-tk", "checksums": [ { "algorithm": "SHA256", - "checksumValue": "54fb59df12c489c6264f5b7d3d7444b150d1e3d6561fd59cdb11483440cec000" + "checksumValue": "66048966cfa88989333ff1632f454e10e9248516bb45efda7b4d2ae5a61642cb" } ], - "downloadLocation": "https://github.com/python/cpython-source-deps/archive/refs/tags/tk-9.0.3.1.tar.gz", + "downloadLocation": "https://github.com/python/cpython-source-deps/archive/refs/tags/tk-9.0.4.1.tar.gz", "externalRefs": [ { "referenceCategory": "SECURITY", - "referenceLocator": "cpe:2.3:a:tcl_tk:tcl_tk:9.0.3.1:*:*:*:*:*:*:*", + "referenceLocator": "cpe:2.3:a:tcl_tk:tcl_tk:9.0.4.1:*:*:*:*:*:*:*", "referenceType": "cpe23Type" } ], "licenseConcluded": "NOASSERTION", "name": "tk", "primaryPackagePurpose": "SOURCE", - "versionInfo": "9.0.3.1" + "versionInfo": "9.0.4.1" }, { "SPDXID": "SPDXRef-PACKAGE-xz", @@ -175,42 +175,42 @@ "checksums": [ { "algorithm": "SHA256", - "checksumValue": "00bbd88709bc416cb96160ab61d3e1c8f76e106799af7328d0fe434dc7dd5004" + "checksumValue": "a9734c94080792af0b50d9c51c2cc8845c2f8ecfa4db87f6462a9b260af67f96" } ], - "downloadLocation": "https://github.com/python/cpython-source-deps/archive/refs/tags/zlib-ng-2.2.4.tar.gz", + "downloadLocation": "https://github.com/python/cpython-source-deps/archive/refs/tags/zlib-ng-2.2.5.tar.gz", "externalRefs": [ { "referenceCategory": "SECURITY", - "referenceLocator": "cpe:2.3:a:zlib-ng:zlib-ng:2.2.4:*:*:*:*:*:*:*", + "referenceLocator": "cpe:2.3:a:zlib-ng:zlib-ng:2.2.5:*:*:*:*:*:*:*", "referenceType": "cpe23Type" } ], "licenseConcluded": "NOASSERTION", "name": "zlib-ng", "primaryPackagePurpose": "SOURCE", - "versionInfo": "2.2.4" + "versionInfo": "2.2.5" }, { "SPDXID": "SPDXRef-PACKAGE-zstd", "checksums": [ { "algorithm": "SHA256", - "checksumValue": "f24b52470d12f466e9fa4fcc94e6c530625ada51d7b36de7fdc6ed7e6f499c8e" + "checksumValue": "eb34eed79af88b8dd7c07481d55192520b9545f865416c31c828b96b01d335d3" } ], - "downloadLocation": "https://github.com/python/cpython-source-deps/archive/refs/tags/zstd-1.5.7.tar.gz", + "downloadLocation": "https://github.com/python/cpython-source-deps/archive/refs/tags/zstd-1.6.0.tar.gz", "externalRefs": [ { "referenceCategory": "SECURITY", - "referenceLocator": "cpe:2.3:a:facebook:zstandard:1.5.7:*:*:*:*:*:*:*", + "referenceLocator": "cpe:2.3:a:facebook:zstandard:1.6.0:*:*:*:*:*:*:*", "referenceType": "cpe23Type" } ], "licenseConcluded": "NOASSERTION", "name": "zstd", "primaryPackagePurpose": "SOURCE", - "versionInfo": "1.5.7" + "versionInfo": "1.6.0" } ], "spdxVersion": "SPDX-2.3" diff --git a/Misc/platform_triplet.c b/Misc/platform_triplet.c index f5cd73bdea83335..6c1863c943b3539 100644 --- a/Misc/platform_triplet.c +++ b/Misc/platform_triplet.c @@ -257,6 +257,32 @@ PLATFORM_TRIPLET=arm64-iphonesimulator # else PLATFORM_TRIPLET=arm64-iphoneos # endif +# elif defined(TARGET_OS_TV) && TARGET_OS_TV +# if defined(TARGET_OS_SIMULATOR) && TARGET_OS_SIMULATOR +# if __x86_64__ +PLATFORM_TRIPLET=x86_64-appletvsimulator +# else +PLATFORM_TRIPLET=arm64-appletvsimulator +# endif +# else +PLATFORM_TRIPLET=arm64-appletvos +# endif +# elif defined(TARGET_OS_WATCH) && TARGET_OS_WATCH +# if defined(TARGET_OS_SIMULATOR) && TARGET_OS_SIMULATOR +# if __x86_64__ +PLATFORM_TRIPLET=x86_64-watchsimulator +# else +PLATFORM_TRIPLET=arm64-watchsimulator +# endif +# else +PLATFORM_TRIPLET=arm64_32-watchos +# endif +# elif defined(TARGET_OS_VISION) && TARGET_OS_VISION +# if defined(TARGET_OS_SIMULATOR) && TARGET_OS_SIMULATOR +PLATFORM_TRIPLET=arm64-xrsimulator +# else +PLATFORM_TRIPLET=arm64-xros +# endif // Older macOS SDKs do not define TARGET_OS_OSX # elif !defined(TARGET_OS_OSX) || TARGET_OS_OSX PLATFORM_TRIPLET=darwin diff --git a/Misc/python-config.sh.in b/Misc/python-config.sh.in index 555b0cb6ba2a482..39b0031b58b916b 100644 --- a/Misc/python-config.sh.in +++ b/Misc/python-config.sh.in @@ -7,9 +7,9 @@ exit_with_usage () local usage usage="Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed" if [ "$1" -eq 0 ]; then - echo "$usage" + printf '%s\n' "$usage" else - echo "$usage" >&2 + printf '%s\n' "$usage" >&2 fi exit $1 } @@ -19,29 +19,46 @@ if [ "$1" = "" ] ; then fi # Returns the actual prefix where this script was installed to. +# Fails if the directory containing this script cannot be resolved. installed_prefix () { - RESULT=$(dirname $(cd $(dirname "$1") && pwd -P)) + RESULT=$(cd "$(dirname "$1")" && pwd -P) || return 1 + RESULT=$(dirname "$RESULT") if which readlink >/dev/null 2>&1 ; then if readlink -f "$RESULT" >/dev/null 2>&1; then RESULT=$(readlink -f "$RESULT") fi fi - echo $RESULT + printf '%s\n' "$RESULT" } -prefix_real=$(installed_prefix "$0") +prefix_real=$(installed_prefix "$0") || { + printf '%s\n' "$0: cannot determine the installation prefix" >&2 + exit 1 +} -# Use sed to fix paths from their built-to locations to their installed-to -# locations. Keep prefix & exec_prefix using their original values in case +# Fix paths from their built-to locations to their installed-to locations +# by replacing the first occurrence of the configured prefix with the actual +# one. Keep prefix & exec_prefix using their original values in case # they are referenced in other configure variables, to prevent double # substitution, issue #22140. prefix="@prefix@" exec_prefix="@exec_prefix@" exec_prefix_real=${prefix_real} -includedir=$(echo "@includedir@" | sed "s#$prefix#$prefix_real#") -libdir=$(echo "@libdir@" | sed "s#$prefix#$prefix_real#") -CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix#$prefix_real#") +relocate () +{ + case "$1" in + *"$prefix"*) + printf '%s\n' "${1%%"$prefix"*}${prefix_real}${1#*"$prefix"}" + ;; + *) + printf '%s\n' "$1" + ;; + esac +} +includedir=$(relocate "@includedir@") +libdir=$(relocate "@libdir@") +CFLAGS=$(relocate "@CFLAGS@") VERSION="@VERSION@" LIBM="@LIBM@" LIBC="@LIBC@" @@ -55,7 +72,7 @@ OPT="@OPT@" PY_ENABLE_SHARED="@PY_ENABLE_SHARED@" LDVERSION="@LDVERSION@" LIBDEST=${prefix_real}/lib/python${VERSION} -LIBPL=$(echo "@LIBPL@" | sed "s#$prefix#$prefix_real#") +LIBPL=$(relocate "@LIBPL@") SO="@EXT_SUFFIX@" PYTHONFRAMEWORK="@PYTHONFRAMEWORK@" INCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" @@ -63,9 +80,9 @@ PLATINCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" PY_EMBED=0 # Scan for --help or unknown argument. -for ARG in $* +for ARG in "$@" do - case $ARG in + case "$ARG" in --help) exit_with_usage 0 ;; @@ -88,35 +105,35 @@ for ARG in "$@" do case "$ARG" in --prefix) - echo "$prefix_real" + printf '%s\n' "$prefix_real" ;; --exec-prefix) - echo "$exec_prefix_real" + printf '%s\n' "$exec_prefix_real" ;; --includes) - echo "$INCDIR $PLATINCDIR" + printf '%s\n' "$INCDIR $PLATINCDIR" ;; --cflags) - echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT" + printf '%s\n' "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT" ;; --libs) - echo "$LIBS" + printf '%s\n' "$LIBS" ;; --ldflags) LIBPLUSED= if [ "$PY_ENABLE_SHARED" = "0" ] ; then LIBPLUSED="-L$LIBPL" fi - echo "$LIBPLUSED -L$libdir $LIBS" + printf '%s\n' "$LIBPLUSED -L$libdir $LIBS" ;; --extension-suffix) - echo "$SO" + printf '%s\n' "$SO" ;; --abiflags) - echo "$ABIFLAGS" + printf '%s\n' "$ABIFLAGS" ;; --configdir) - echo "$LIBPL" + printf '%s\n' "$LIBPL" ;; esac done diff --git a/Misc/python.man b/Misc/python.man index 5e4f3c3debe9358..238d32099710173 100644 --- a/Misc/python.man +++ b/Misc/python.man @@ -299,7 +299,7 @@ the remaining fields. The .I message -field must match the whole printed warning message; this match is +field must match the start of the warning message; this match is case-insensitive. The diff --git a/Misc/sbom.spdx.json b/Misc/sbom.spdx.json index fbc7ca631d70e29..225f2a5d1863895 100644 --- a/Misc/sbom.spdx.json +++ b/Misc/sbom.spdx.json @@ -20,11 +20,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "b0235fa3cf845a7d68e8e66dd344d5e32e8951b5" + "checksumValue": "28cdbd89d1956e24045d83e5f50b4adeca1b8c0c" }, { "algorithm": "SHA256", - "checksumValue": "42f8b392c70366743eacbc60ce021389ccaa333598dd49eef6ee5c93698ca205" + "checksumValue": "73dd48d5f41e789d5616e8998e5118ea0f25bde65b87a8f04e3e74d4dd51b1a4" } ], "fileName": "Modules/expat/ascii.h" @@ -34,25 +34,39 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "cbb53d16ca1f35ee9c9e296116efd222ae611ed9" + "checksumValue": "f0c9b25759ccf57fd65eb4356c2762f25c0e9a6f" }, { "algorithm": "SHA256", - "checksumValue": "1cc0ae749019fc0e488cd1cf245f6beaa6d4f7c55a1fc797e5aa40a408bc266b" + "checksumValue": "5792cb56f285c8876b988d875a70d49019bc7e6d5ebcd0f8224b24e695301832" } ], "fileName": "Modules/expat/asciitab.h" }, + { + "SPDXID": "SPDXRef-FILE-Modules-expat-entities.h", + "checksums": [ + { + "algorithm": "SHA1", + "checksumValue": "27c38e2ca1427fe62d9ef6a30ef50f1c2c5bb9b7" + }, + { + "algorithm": "SHA256", + "checksumValue": "ed3546fec0e33f14a99c95753357becfaec7c577965dc442d1cefd437acc5e92" + } + ], + "fileName": "Modules/expat/entities.h" + }, { "SPDXID": "SPDXRef-FILE-Modules-expat-expat.h", "checksums": [ { "algorithm": "SHA1", - "checksumValue": "00c5e72b384f5c305be613729184ad37bb491238" + "checksumValue": "2037910f6aacebac08a376d5c2b88cdba7309864" }, { "algorithm": "SHA256", - "checksumValue": "eb43180fbdca40e36d9558060e6e654ef4c451ca656ad679e9e1269eb45456b3" + "checksumValue": "8dfdb5b7d0392391e74cd9cdb74455fcbebfdcfa75c5d7c6ac59fb5855af31fe" } ], "fileName": "Modules/expat/expat.h" @@ -62,11 +76,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "d8f9211d52ff0384e229e4d4d56adae5db2d7f91" + "checksumValue": "942c816cf73281239728035ca2d2211b5982ed5c" }, { "algorithm": "SHA256", - "checksumValue": "b77f8192baf90aaa41f7023bc68fd1f22ab2552f98758271a1e090544537def5" + "checksumValue": "d4e226932e8fd84afd0e396e71b307b2c8f2bf0556d8ea037f43c2dd449b7a73" } ], "fileName": "Modules/expat/expat_external.h" @@ -76,25 +90,39 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "69db5031480c50a1e35a51190bd64fcb816b6caf" + "checksumValue": "378f1dffca32e580be8fb445677950cd1c4c4ea8" }, { "algorithm": "SHA256", - "checksumValue": "3dac2e4fdec819ede1b081ef776f2421c98ab509f69d5647a21d63d651179df2" + "checksumValue": "5e42477487bca7e7caac6b832ab940f39a1a20b8765c945374e4f6c2670f55b6" } ], "fileName": "Modules/expat/fallthrough.h" }, + { + "SPDXID": "SPDXRef-FILE-Modules-expat-hash-table.h", + "checksums": [ + { + "algorithm": "SHA1", + "checksumValue": "e0ab4fb3f3b06bac642dc525d98107337c3534d0" + }, + { + "algorithm": "SHA256", + "checksumValue": "ad93851f86df1f4e8f85488dbac53cab3539e59d701ad747c7beea354d69e0dc" + } + ], + "fileName": "Modules/expat/hash_table.h" + }, { "SPDXID": "SPDXRef-FILE-Modules-expat-iasciitab.h", "checksums": [ { "algorithm": "SHA1", - "checksumValue": "1b0e9014c0baa4c6254d2b5e6a67c70148309c34" + "checksumValue": "19b25ac4e504efa5e51ce639c83be053da587543" }, { "algorithm": "SHA256", - "checksumValue": "ad8b01e9f323cc4208bcd22241df383d7e8641fe3c8b3415aa513de82531f89f" + "checksumValue": "a9cd6f2cf5199ae3c29d22ee4913736fcd984f62132146a0352c88549700e83f" } ], "fileName": "Modules/expat/iasciitab.h" @@ -104,11 +132,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "2555e70b29c1efc0af40879daafd12f8b36aca2c" + "checksumValue": "df8adcb0ea779b2b720d84a687684a08f3bf72c8" }, { "algorithm": "SHA256", - "checksumValue": "4feb1df53898a48ae0ae04b5d0352c90395c8e693e5c2675f8ced41903d6fa94" + "checksumValue": "959b292f428b4ba899a620ae9c214e5a731396982aa445a997705bd8a420a6c8" } ], "fileName": "Modules/expat/internal.h" @@ -118,11 +146,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "d335ecca380e331a0ea7dc33838a4decd93ec1e4" + "checksumValue": "2e37879c51aec484072d504d89e963bda5b553e5" }, { "algorithm": "SHA256", - "checksumValue": "eab66226da100372e01e42e1cbcd8ac2bbbb5c1b5f95d735289cc85c7a8fc2ba" + "checksumValue": "dfc8d79ebdb977a3fd760591c6a92b7c7ae1eb76cd79003ba386015bb92c2b3d" } ], "fileName": "Modules/expat/latin1tab.h" @@ -132,11 +160,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "abdf1b9e9642176466ecbb77d5f48e502d01d0d8" + "checksumValue": "19ff1e65b76536a4595c38d21a500cbc7b86c408" }, { "algorithm": "SHA256", - "checksumValue": "10c66f1cf9dc28608d57cb19adc8c7c654800e8b5b1b9be176eaed802deca2d9" + "checksumValue": "377ca054fdc531360f42a5cb7c522bcbf88b6c67aebc2e29544c37d14e836bde" } ], "fileName": "Modules/expat/memory_sanitizer.h" @@ -146,11 +174,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "cf2bc9626c945826602ba9170786e9a2a44645e4" + "checksumValue": "737800daf4e21db84a3c4ff2a0578b6fb3c3b3ad" }, { "algorithm": "SHA256", - "checksumValue": "67dcf415d37a4b692a6a8bb46f990c02d83f2ef3d01a65cd61c8594a084246f2" + "checksumValue": "19a2e7c6ed53a66df77bcc1576a21f20e729f74997566347c050b97fd6244c95" } ], "fileName": "Modules/expat/nametab.h" @@ -160,11 +188,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "6648f9c12a8d6f77a6eab5ef5c7caa976e7549aa" + "checksumValue": "bcde3e9100b62b87d2b2d628bdacddf415782bdb" }, { "algorithm": "SHA256", - "checksumValue": "c1be28dd62282e668d4daedfe756edb68b7da165c442202bb06a9e597cd5c289" + "checksumValue": "12ecc9915bccb793ea8bb543cc7d002e226f4e4d6b97ec9839dca41cbe4e2e27" } ], "fileName": "Modules/expat/siphash.h" @@ -174,11 +202,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "b77c8fcfb551553c81d6fbd94c798c8aa04ad021" + "checksumValue": "30276d76d64af27de1d0de06160c5b58c884ee8b" }, { "algorithm": "SHA256", - "checksumValue": "8cd26bd461d334d5e1caedb3af4518d401749f2fc66d56208542b29085159c18" + "checksumValue": "3fa349a3a19143366e80a58d9aa950152ef9cd7903f557f971051410b47f335c" } ], "fileName": "Modules/expat/utf8tab.h" @@ -188,39 +216,53 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "a3a8c44efd55dbf2cfea8fcee009ec63120ec0a3" + "checksumValue": "d296304ae595486ec094e341fed8a8450d4cedbe" }, { "algorithm": "SHA256", - "checksumValue": "e70948500d34dfcba4e9f0b305319dfe2a937c7cbfb687905128b56e1a6f8b33" + "checksumValue": "0ab6446eb98abc492ae341ef7607b535e44dedf52633fdc7c6e1a1361aec3922" } ], "fileName": "Modules/expat/winconfig.h" }, { - "SPDXID": "SPDXRef-FILE-Modules-expat-xcsinc.c", + "SPDXID": "SPDXRef-FILE-Modules-expat-xcs.c", + "checksums": [ + { + "algorithm": "SHA1", + "checksumValue": "4f4a913dc8385799ee56263aed7e60ddb265ed51" + }, + { + "algorithm": "SHA256", + "checksumValue": "ab9228cf9662af965bd2222cae6797c6379ab0408501965294c00ca828f6bcb8" + } + ], + "fileName": "Modules/expat/xcs.c" + }, + { + "SPDXID": "SPDXRef-FILE-Modules-expat-xcs.h", "checksums": [ { "algorithm": "SHA1", - "checksumValue": "69fa7a25f555164f089fdcf290f3af6a1731621f" + "checksumValue": "9ec26ee2958c5e8a00eae16813c3681afee15d56" }, { "algorithm": "SHA256", - "checksumValue": "071345c5ccfbe2e46a02839331ee60ee20048348b4408964bff48c4355473b9e" + "checksumValue": "105e1e3f694821583c6475a8b8bcad23e40c846c98fbe15988aaafbca8f7a8a6" } ], - "fileName": "Modules/expat/xcsinc.c" + "fileName": "Modules/expat/xcs.h" }, { "SPDXID": "SPDXRef-FILE-Modules-expat-xmlparse.c", "checksums": [ { "algorithm": "SHA1", - "checksumValue": "a5a5dd44ee8eeb73f42fa42ca1499cd282ddf6a6" + "checksumValue": "0d49c8bd830acb84dcf87e3c156d980680dadc78" }, { "algorithm": "SHA256", - "checksumValue": "5d2c99b576744edd9545cefe613e0577617f57e16c86387edc13d45710dc97d2" + "checksumValue": "c5b0e430fd8e9e9a6b0fe8a3bf3bfc1ebfbedf50a366f923110dcddaabae4c88" } ], "fileName": "Modules/expat/xmlparse.c" @@ -230,11 +272,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "c8769fcb93f00272a6e6ca560be633649c817ff7" + "checksumValue": "56999d78b6ed247b00b0e3283fd174065b04e40f" }, { "algorithm": "SHA256", - "checksumValue": "5b81f0eb0e144b611dbd1bc9e6037075a16bff94f823d57a81eb2a3e4999e91a" + "checksumValue": "b1ad87cc3c0d4722358a7dfb1642df7f62066d1613a0a56dc9289e7112fb3f0c" } ], "fileName": "Modules/expat/xmlrole.c" @@ -244,11 +286,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "ac2964cca107f62dd133bfd4736a9a17defbc401" + "checksumValue": "08de6d1246312e179918de3533328000c887a95b" }, { "algorithm": "SHA256", - "checksumValue": "92e41f373b67f6e0dcd7735faef3c3f1e2c17fe59e007e6b74beef6a2e70fa88" + "checksumValue": "8a0b61cd6efcd7427acbc86759e9013e7a61755097a1f82cbb2a79c011af5ee5" } ], "fileName": "Modules/expat/xmlrole.h" @@ -258,11 +300,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "08dba893b34338e64b66f1044f542aa6760dbab1" + "checksumValue": "6a5bca82fb56189cc67136d17c9236c16999cdf2" }, { "algorithm": "SHA256", - "checksumValue": "0c842b1876503e699517994317805dd2298d9e11c94dcc87c2ecb6c2b8e00bc0" + "checksumValue": "14cc3ff861c70528c7807a1fccf794c7e0c5c00185462e5066092e61e3e1d23c" } ], "fileName": "Modules/expat/xmltok.c" @@ -272,11 +314,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "d126831eaa5158cff187a8c93f4bc1c8118f3b17" + "checksumValue": "d17abcb8cdf7e91fd2bc57ca692ead71cb81f464" }, { "algorithm": "SHA256", - "checksumValue": "91bf003a725a675761ea8d92cebc299a76fd28c3a950572f41bc7ce5327ee7b5" + "checksumValue": "25c3d829eab7bcd5b64bafca3bdd1cc368bc71c7b8ebdae757671e4f641b5e64" } ], "fileName": "Modules/expat/xmltok.h" @@ -286,11 +328,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "3ccb9335589c3ff60aae50ac79b2cdac57999bee" + "checksumValue": "e7da04f93f0bc0268b881da7b20d5a9ea6f000da" }, { "algorithm": "SHA256", - "checksumValue": "94eeaef9ed46d10f80f748924fbf41f950b4859d6f234f61fdb2c8f1a8e77bd1" + "checksumValue": "2e0e61c0125f165c98b310888c642e36b49068a33b93662e5989a07094cb20bc" } ], "fileName": "Modules/expat/xmltok_impl.c" @@ -300,11 +342,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "788332fe8040bed71172cddedb69abd848cc62f7" + "checksumValue": "f862ff6393d47ac1ad9cd0f5f844b43e7c21a20e" }, { "algorithm": "SHA256", - "checksumValue": "f05ad4fe5e98429a7349ff04f57192cac58c324601f2a2e5e697ab0bc05d36d5" + "checksumValue": "a5053c69219d12788088de9bd670537e1c784302766c331afe6b253460d0417d" } ], "fileName": "Modules/expat/xmltok_impl.h" @@ -314,11 +356,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "41b8c8fc275882c76d4210b7d40a18e506b07147" + "checksumValue": "0fc32be2ca285ea118dfafe1a2534d4dc1ebfc4f" }, { "algorithm": "SHA256", - "checksumValue": "b2188c7e5fa5b33e355cf6cf342dfb8f6e23859f2a6b1ddf79841d7f84f7b196" + "checksumValue": "d2b1a0c17a8113d3323331a8acd980f22c1e8de316dff27d7fce23a6069e1487" } ], "fileName": "Modules/expat/xmltok_ns.c" @@ -1044,14 +1086,14 @@ "checksums": [ { "algorithm": "SHA256", - "checksumValue": "ef7d1994f533c9e7343d6c19f31064fc8ebbcbcaa144be3812b4f43052a05f4c" + "checksumValue": "b3e3fcbb629e4d357a9cc0af5b146b85959bcf1cefe87e529d2c0a9234be737f" } ], - "downloadLocation": "https://github.com/libexpat/libexpat/releases/download/R_2_8_2/expat-2.8.2.tar.gz", + "downloadLocation": "https://github.com/libexpat/libexpat/releases/download/R_2_11_0/expat-2.11.0.tar.gz", "externalRefs": [ { "referenceCategory": "SECURITY", - "referenceLocator": "cpe:2.3:a:libexpat_project:libexpat:2.8.2:*:*:*:*:*:*:*", + "referenceLocator": "cpe:2.3:a:libexpat_project:libexpat:2.11.0:*:*:*:*:*:*:*", "referenceType": "cpe23Type" } ], @@ -1059,7 +1101,7 @@ "name": "expat", "originator": "Organization: Expat development team", "primaryPackagePurpose": "SOURCE", - "versionInfo": "2.8.2" + "versionInfo": "2.11.0" }, { "SPDXID": "SPDXRef-PACKAGE-hacl-star", @@ -1122,6 +1164,11 @@ "relationshipType": "CONTAINS", "spdxElementId": "SPDXRef-PACKAGE-expat" }, + { + "relatedSpdxElement": "SPDXRef-FILE-Modules-expat-entities.h", + "relationshipType": "CONTAINS", + "spdxElementId": "SPDXRef-PACKAGE-expat" + }, { "relatedSpdxElement": "SPDXRef-FILE-Modules-expat-expat.h", "relationshipType": "CONTAINS", @@ -1137,6 +1184,11 @@ "relationshipType": "CONTAINS", "spdxElementId": "SPDXRef-PACKAGE-expat" }, + { + "relatedSpdxElement": "SPDXRef-FILE-Modules-expat-hash-table.h", + "relationshipType": "CONTAINS", + "spdxElementId": "SPDXRef-PACKAGE-expat" + }, { "relatedSpdxElement": "SPDXRef-FILE-Modules-expat-iasciitab.h", "relationshipType": "CONTAINS", @@ -1178,7 +1230,12 @@ "spdxElementId": "SPDXRef-PACKAGE-expat" }, { - "relatedSpdxElement": "SPDXRef-FILE-Modules-expat-xcsinc.c", + "relatedSpdxElement": "SPDXRef-FILE-Modules-expat-xcs.c", + "relationshipType": "CONTAINS", + "spdxElementId": "SPDXRef-PACKAGE-expat" + }, + { + "relatedSpdxElement": "SPDXRef-FILE-Modules-expat-xcs.h", "relationshipType": "CONTAINS", "spdxElementId": "SPDXRef-PACKAGE-expat" }, diff --git a/Misc/stable_abi.toml b/Misc/stable_abi.toml index d59a7c788fa9e02..dc892fc5f737eee 100644 --- a/Misc/stable_abi.toml +++ b/Misc/stable_abi.toml @@ -64,6 +64,8 @@ # on all platforms.) # - abi3t_opaque: In abi3t, this struct is opaque (as if `struct_abi_kind` # was 'opaque' and `members` was missing). +# - is_static_inline_function: for `macro`: actually implemented as a static +# inline function, rather than a macro. # Removing items from this file is generally not allowed, and additions should # be considered with that in mind. See the devguide for exact rules: @@ -95,6 +97,8 @@ windows = 'maybe' +### Python 3.2 (initial version) ############################################ + # Mentioned in PEP 384: [struct.PyObject] @@ -627,8 +631,6 @@ added = '3.2' [function.PyErr_Display] added = '3.2' -[function.PyErr_DisplayException] - added = '3.12' [function.PyErr_ExceptionMatches] added = '3.2' [function.PyErr_Fetch] @@ -715,6 +717,7 @@ added = '3.2' [function.PyEval_InitThreads] added = '3.2' + abi_only = true [function.PyEval_ReleaseLock] added = '3.2' abi_only = true @@ -735,8 +738,6 @@ added = '3.2' [data.PyExc_BaseException] added = '3.2' -[data.PyExc_BaseExceptionGroup] - added = '3.11' [data.PyExc_BufferError] added = '3.2' [data.PyExc_BytesWarning] @@ -1351,8 +1352,10 @@ abi_only = true [function.PySys_SetArgv] added = '3.2' + abi_only = true [function.PySys_SetArgvEx] added = '3.2' + abi_only = true [function.PySys_SetObject] added = '3.2' [function.PySys_SetPath] @@ -1642,6 +1645,7 @@ added = '3.2' [data.Py_FileSystemDefaultEncoding] added = '3.2' + abi_only = true [function.Py_Finalize] added = '3.2' [function.Py_GetBuildInfo] @@ -1676,6 +1680,7 @@ added = '3.2' [data.Py_HasFileSystemDefaultEncoding] added = '3.2' + abi_only = true [function.Py_IncRef] added = '3.2' [function.Py_Initialize] @@ -1696,8 +1701,10 @@ added = '3.2' [function.Py_SetProgramName] added = '3.2' + abi_only = true [function.Py_SetPythonHome] added = '3.2' + abi_only = true [function.Py_SetRecursionLimit] added = '3.2' [function.Py_VaBuildValue] @@ -1867,6 +1874,25 @@ [function.PyThread_start_new_thread] added = '3.2' +# Python 3.2 macros + +[macro.Py_CLEAR] + added = '3.2' +[macro.Py_DECREF] + added = '3.2' +[macro.Py_INCREF] + added = '3.2' + is_static_inline_function = true +[macro.Py_XDECREF] + added = '3.2' + is_static_inline_function = true +[macro.Py_XINCREF] + added = '3.2' + is_static_inline_function = true + + +### Python 3.3 ############################################################## + # The following were added in PC/python3.def in Python 3.3: # 7800f75827b1be557be16f3b18f5170fbf9fae08 # 9c56409d3353b8cd4cfc19e0467bbe23fd34fc92 @@ -1896,6 +1922,9 @@ [function.PyThread_GetInfo] added = '3.3' + +### Python 3.4 ############################################################## + # The following were added in PC/python3.def in Python 3.4: # 3ba3a3ee56c142e93d6bbe20ff6bf939212a30f0 @@ -1904,6 +1933,9 @@ [function.PyType_GetSlot] added = '3.4' + +### Python 3.5 ############################################################## + # The following were added in PC/python3.def in Python 3.5: # 11d7b1423fc44d764eba7065ea5eba58ed748b21 # f3b73ad51da3097d7915796fdc62608b1ab90c0a @@ -1942,6 +1974,9 @@ [const.Py_tp_finalize] added = '3.5' + +### Python 3.6 ############################################################## + # The following were added in PC/python3.def in Python 3.6: [function.Py_FinalizeEx] @@ -1956,6 +1991,9 @@ [data.PyExc_ModuleNotFoundError] added = '3.6' + +### Python 3.7 ############################################################## + # The following were added in PC/python3.def in Python 3.6.1 and 3.5.3/3.5.4: [function.PyCodec_NameReplaceErrors] @@ -2151,12 +2189,16 @@ [const.METH_METHOD] added = '3.7' + +### Python 3.8 ############################################################## + # The following were added in PC/python3.def in Python 3.8: [function.PyImport_GetModule] added = '3.8' [data.Py_UTF8Mode] added = '3.8' + abi_only = true [function.PyExceptionClass_Name] added = '3.8' [function.PyIndex_Check] @@ -2174,11 +2216,14 @@ [function.Py_BytesMain] added = '3.8' -# New type flag (PEP 590): +# New type flag in Python 3.8 (PEP 590): [const.Py_TPFLAGS_METHOD_DESCRIPTOR] added = '3.8' + +### Python 3.9 ############################################################## + # The following were added in PC/python3.def in Python 3.9: [function.Py_EnterRecursiveCall] @@ -2198,6 +2243,18 @@ [function.PyObject_GC_IsTracked] added = '3.9' +# Python 3.9 macros + +[macro.Py_SET_REFCNT] + added = '3.9' + is_static_inline_function = true +[macro.Py_SET_TYPE] + added = '3.9' + is_static_inline_function = true + + +### Python 3.10 ############################################################# + # The following were added in PC/python3.def in Python 3.10: [function.Py_GetArgcArgv] @@ -2237,6 +2294,7 @@ added = '3.10' [data.Py_FileSystemDefaultEncodeErrors] added = '3.10' + abi_only = true [function.PyCodec_Unregister] added = '3.10' [function.PyErr_SetInterruptEx] @@ -2262,7 +2320,11 @@ [data.PyExc_EncodingWarning] added = '3.10' -# Support for Stable ABI in debug builds +# Added in 3.7 but in the Stable ABI from 3.10 +[const.METH_FASTCALL] + added = '3.10' + +# Support for Stable ABI in debug builds (Python 3.10) [data._Py_RefTotal] added = '3.10' @@ -2273,13 +2335,13 @@ ifdef = 'Py_REF_DEBUG' abi_only = true -# New slots in 3.10: +# New slots in Python 3.10: [const.Py_am_send] added = '3.10' -# New GC control functions in Py3.10 (https://bugs.python.org/issue28254) +# New GC control functions in Python 3.10 (https://github.com/python/cpython/issues/72441) [function.PyGC_Disable] added = '3.10' @@ -2288,8 +2350,11 @@ [function.PyGC_IsEnabled] added = '3.10' -# Add new C API in Python 3.11 +### Python 3.11 ############################################################# + +[data.PyExc_BaseExceptionGroup] + added = '3.11' [function.PyType_GetName] added = '3.11' [function.PyType_GetQualName] @@ -2297,10 +2362,6 @@ [data.PyStructSequence_UnnamedField] added = '3.11' -# Added in 3.7 but in the Stable ABI from 3.10 -[const.METH_FASTCALL] - added = '3.10' - # Add stable Py_buffer API in Python 3.11 (https://bugs.python.org/issue45459) [struct.Py_buffer] added = '3.11' @@ -2379,7 +2440,6 @@ [const.PyBUF_WRITE] added = '3.11' - # (Detailed comments aren't really needed for further entries: from here on # we can use version control logs.) @@ -2390,6 +2450,11 @@ [function.PyErr_SetHandledException] added = '3.11' + +### Python 3.12 ############################################################# + +[function.PyErr_DisplayException] + added = '3.12' [function.PyType_FromMetaclass] added = '3.12' [const.Py_TPFLAGS_HAVE_VECTORCALL] @@ -2413,7 +2478,7 @@ added = '3.12' [function.PyObject_VectorcallMethod] added = '3.12' -[macro.PY_VECTORCALL_ARGUMENTS_OFFSET] +[const.PY_VECTORCALL_ARGUMENTS_OFFSET] added = '3.12' [typedef.getbufferproc] added = '3.12' @@ -2473,6 +2538,9 @@ # Note: value changed in 3.15 (old value is still accepted) added = '3.12' + +### Python 3.13 ############################################################# + [function.PyImport_AddModuleRef] added = '3.13' [function.PyWeakref_GetRef] @@ -2555,6 +2623,9 @@ # Note: value changed in 3.15 (old value is still accepted) added = '3.13' + +### Python 3.14 ############################################################# + [function.Py_TYPE] # Before 3.14, this was a macro that accessed the PyObject member added = '3.14' @@ -2616,6 +2687,9 @@ [function.Py_PACK_VERSION] added = '3.14' + +### Python 3.15 ############################################################# + [function.PySys_GetAttr] added = '3.15' [function.PySys_GetAttrString] @@ -2773,8 +2847,10 @@ added = '3.15' [const.Py_tp_module] added = '3.15' +[function.PyObject_CallFinalizerFromDealloc] + added = '3.15' -# PEP 757 import/export API. +# Python 3.15 PEP 757 import/export API. [function.PyLong_GetNativeLayout] added = '3.15' @@ -2800,7 +2876,7 @@ # (The definition of 'full-abi' was clarified when this entry was added.) struct_abi_kind = 'full-abi' -# PEP 788 finalization protection +# Python 3.15 PEP 788 finalization protection [struct.PyInterpreterGuard] added = '3.15' @@ -2830,5 +2906,38 @@ added = '3.15' struct_abi_kind = 'opaque' -[function.PyObject_CallFinalizerFromDealloc] - added = '3.15' + +### Python 3.16 ############################################################# + +[function.Py_HashBuffer] + added = '3.16' +[macro.Py_SETREF] + added = '3.16' +[macro.Py_XSETREF] + added = '3.16' +[function.PyUnicodeWriter_Create] + added = '3.16' +[function.PyUnicodeWriter_Discard] + added = '3.16' +[function.PyUnicodeWriter_Finish] + added = '3.16' +[function.PyUnicodeWriter_WriteChar] + added = '3.16' +[function.PyUnicodeWriter_WriteUTF8] + added = '3.16' +[function.PyUnicodeWriter_WriteASCII] + added = '3.16' +[function.PyUnicodeWriter_WriteWideChar] + added = '3.16' +[function.PyUnicodeWriter_WriteUCS4] + added = '3.16' +[function.PyUnicodeWriter_WriteStr] + added = '3.16' +[function.PyUnicodeWriter_WriteRepr] + added = '3.16' +[function.PyUnicodeWriter_WriteSubstring] + added = '3.16' +[function.PyUnicodeWriter_Format] + added = '3.16' +[function.PyUnicodeWriter_DecodeUTF8Stateful] + added = '3.16' diff --git a/Modules/Setup b/Modules/Setup index e97a78e628693dc..0a183ae30f8f0ae 100644 --- a/Modules/Setup +++ b/Modules/Setup @@ -202,7 +202,7 @@ PYTHONPATH=$(COREPYTHONPATH) #_gdbm _gdbmmodule.c -lgdbm #_lzma _lzmamodule.c -llzma #_uuid _uuidmodule.c -luuid -#_zstd _zstd/_zstdmodule.c -lzstd -I$(srcdir)/Modules/_zstd +#_zstd _zstd/_zstdmodule.c _zstd/zstddict.c _zstd/compressor.c _zstd/decompressor.c -lzstd -I$(srcdir)/Modules/_zstd #zlib zlibmodule.c -lz # The readline module also supports libeditline (-leditline). diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in index 65a1fefe72e92ec..1d1de43fd8f05b4 100644 --- a/Modules/Setup.bootstrap.in +++ b/Modules/Setup.bootstrap.in @@ -1,5 +1,9 @@ # -*- makefile -*- +# Mark bootstrap modules explicitly so older Makefile recipes work +# without passing -b to makesetup (gh-161364). +*bootstrap* + # --- # Built-in modules required to get a functioning interpreter; # cannot be built as shared! diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index 524f1466b191f64..d8cd8de10dfe084 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -172,9 +172,9 @@ @MODULE_XXSUBTYPE_TRUE@xxsubtype xxsubtype.c @MODULE__XXTESTFUZZ_TRUE@_xxtestfuzz _xxtestfuzz/_xxtestfuzz.c _xxtestfuzz/fuzzer.c @MODULE__TESTBUFFER_TRUE@_testbuffer _testbuffer.c -@MODULE__TESTINTERNALCAPI_TRUE@_testinternalcapi _testinternalcapi.c _testinternalcapi/test_lock.c _testinternalcapi/pytime.c _testinternalcapi/set.c _testinternalcapi/test_critical_sections.c _testinternalcapi/complex.c _testinternalcapi/interpreter.c _testinternalcapi/tuple.c -@MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c _testcapi/vectorcall.c _testcapi/heaptype.c _testcapi/abstract.c _testcapi/unicode.c _testcapi/dict.c _testcapi/set.c _testcapi/list.c _testcapi/tuple.c _testcapi/getargs.c _testcapi/datetime.c _testcapi/docstring.c _testcapi/mem.c _testcapi/watchers.c _testcapi/long.c _testcapi/float.c _testcapi/complex.c _testcapi/numbers.c _testcapi/structmember.c _testcapi/exceptions.c _testcapi/code.c _testcapi/buffer.c _testcapi/pyatomic.c _testcapi/run.c _testcapi/file.c _testcapi/codec.c _testcapi/immortal.c _testcapi/gc.c _testcapi/hash.c _testcapi/time.c _testcapi/bytes.c _testcapi/object.c _testcapi/modsupport.c _testcapi/monitoring.c _testcapi/config.c _testcapi/import.c _testcapi/frame.c _testcapi/type.c _testcapi/function.c _testcapi/module.c _testcapi/weakref.c -@MODULE__TESTLIMITEDCAPI_TRUE@_testlimitedcapi _testlimitedcapi.c _testlimitedcapi/abstract.c _testlimitedcapi/bytearray.c _testlimitedcapi/bytes.c _testlimitedcapi/codec.c _testlimitedcapi/complex.c _testlimitedcapi/dict.c _testlimitedcapi/eval.c _testlimitedcapi/float.c _testlimitedcapi/heaptype_relative.c _testlimitedcapi/import.c _testlimitedcapi/list.c _testlimitedcapi/long.c _testlimitedcapi/object.c _testlimitedcapi/pyos.c _testlimitedcapi/set.c _testlimitedcapi/slots.c _testlimitedcapi/sys.c _testlimitedcapi/threadstate.c _testlimitedcapi/tuple.c _testlimitedcapi/unicode.c _testlimitedcapi/vectorcall_limited.c _testlimitedcapi/version.c _testlimitedcapi/file.c _testlimitedcapi/weakref.c _testlimitedcapi/run.c +@MODULE__TESTINTERNALCAPI_TRUE@_testinternalcapi _testinternalcapi.c _testinternalcapi/test_lock.c _testinternalcapi/pytime.c _testinternalcapi/set.c _testinternalcapi/test_critical_sections.c _testinternalcapi/complex.c _testinternalcapi/interpreter.c _testinternalcapi/tokenizer.c _testinternalcapi/tuple.c _testinternalcapi/typecache.c +@MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c _testcapi/vectorcall.c _testcapi/heaptype.c _testcapi/abstract.c _testcapi/unicode.c _testcapi/dict.c _testcapi/set.c _testcapi/list.c _testcapi/tuple.c _testcapi/getargs.c _testcapi/datetime.c _testcapi/docstring.c _testcapi/mem.c _testcapi/watchers.c _testcapi/long.c _testcapi/float.c _testcapi/complex.c _testcapi/numbers.c _testcapi/structmember.c _testcapi/exceptions.c _testcapi/code.c _testcapi/buffer.c _testcapi/pyatomic.c _testcapi/run.c _testcapi/file.c _testcapi/codec.c _testcapi/immortal.c _testcapi/gc.c _testcapi/hash.c _testcapi/time.c _testcapi/bytes.c _testcapi/object.c _testcapi/modsupport.c _testcapi/monitoring.c _testcapi/config.c _testcapi/import.c _testcapi/frame.c _testcapi/type.c _testcapi/function.c _testcapi/module.c _testcapi/weakref.c _testcapi/marshal.c _testcapi/fpcast.c +@MODULE__TESTLIMITEDCAPI_TRUE@_testlimitedcapi _testlimitedcapi.c _testlimitedcapi/abstract.c _testlimitedcapi/bytearray.c _testlimitedcapi/bytes.c _testlimitedcapi/capsule.c _testlimitedcapi/codec.c _testlimitedcapi/complex.c _testlimitedcapi/dict.c _testlimitedcapi/eval.c _testlimitedcapi/float.c _testlimitedcapi/heaptype_relative.c _testlimitedcapi/import.c _testlimitedcapi/list.c _testlimitedcapi/long.c _testlimitedcapi/object.c _testlimitedcapi/pyos.c _testlimitedcapi/set.c _testlimitedcapi/slice.c _testlimitedcapi/slots.c _testlimitedcapi/sys.c _testlimitedcapi/threadstate.c _testlimitedcapi/tuple.c _testlimitedcapi/unicode.c _testlimitedcapi/vectorcall_limited.c _testlimitedcapi/version.c _testlimitedcapi/file.c _testlimitedcapi/weakref.c _testlimitedcapi/run.c _testlimitedcapi/type.c _testlimitedcapi/hash.c _testlimitedcapi/build.c @MODULE__TESTCLINIC_TRUE@_testclinic _testclinic.c @MODULE__TESTCLINIC_LIMITED_TRUE@_testclinic_limited _testclinic_limited.c diff --git a/Modules/_abc.c b/Modules/_abc.c index 5826efbfecb6901..79904513c49b643 100644 --- a/Modules/_abc.c +++ b/Modules/_abc.c @@ -4,11 +4,17 @@ #endif #include "Python.h" -#include "pycore_moduleobject.h" // _PyModule_GetState() -#include "pycore_object.h" // _PyType_GetSubclasses() -#include "pycore_runtime.h" // _Py_ID() -#include "pycore_setobject.h" // _PySet_NextEntry() -#include "pycore_weakref.h" // _PyWeakref_GET_REF() +#include "pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION() +#include "pycore_moduleobject.h" // _PyModule_GetState() +#include "pycore_object.h" // _PyType_LookupStackRefAndVersion() +#include "pycore_object_deferred.h" // _PyObject_SetDeferredRefcount() +#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_PTR_ACQUIRE() +#include "pycore_pymem.h" // _PyMem_FreeDelayed() +#include "pycore_pystate.h" // _PyThreadState_GET() +#include "pycore_runtime.h" // _Py_ID() +#include "pycore_stackref.h" // _PyStackRef +#include "pycore_typeobject.h" // _PyType_GetSubclasses() +#include "pycore_pyhash.h" #include "clinic/_abc.c.h" /*[clinic input] @@ -22,6 +28,14 @@ PyDoc_STRVAR(_abc__doc__, typedef struct { PyTypeObject *_abc_data_type; uint64_t abc_invalidation_counter; + // Default implementations, compared by identity to skip the call + // when a class doesn't override them. + PyObject *object_class_descr; + PyObject *object_subclasshook; + PyObject *type_subclasses; + // ABCMeta.__subclasscheck__, set by abc.py on import. Classes using it + // are checked directly instead of going through issubclass(). + PyObject *subclasscheck_func; } _abcmodule_state; static inline _abcmodule_state* @@ -35,57 +49,288 @@ get_abc_state(PyObject *module) static inline uint64_t get_invalidation_counter(_abcmodule_state *state) { -#ifdef Py_GIL_DISABLED - return _Py_atomic_load_uint64(&state->abc_invalidation_counter); -#else - return state->abc_invalidation_counter; -#endif + return FT_ATOMIC_LOAD_UINT64_RELAXED(state->abc_invalidation_counter); } static inline void increment_invalidation_counter(_abcmodule_state *state) { -#ifdef Py_GIL_DISABLED - _Py_atomic_add_uint64(&state->abc_invalidation_counter, 1); -#else - state->abc_invalidation_counter++; -#endif + FT_ATOMIC_ADD_UINT64(state->abc_invalidation_counter, 1); +} + + +// The registry and the caches of an ABC are sets of classes, stored as +// open addressed hash tables keyed by the address of the class. +// +// Each entry also holds a weakref to the class. It is only used to check +// that the class is still alive, as the address of a dead class can be +// reused by a new one. The weakrefs have no callback, so the same weakref +// is shared by all the tables a class is in, and dead entries are only +// removed when the table is rebuilt. +typedef struct { + PyObject *key; /* borrowed ref of a class */ + PyObject *ref; /* weakref to key */ +} abc_entry; + +typedef struct { + size_t mask; /* number of entries - 1 */ + size_t used; /* entries with a key, live or dead */ + abc_entry entries[]; +} abc_table; + +#define TABLE_MIN_SIZE 8 +#define PERTURB_SHIFT 5 + +// Shared empty table, so that lookups don't need a NULL check. +// It is never modified or freed. +static const abc_table empty_table_struct = { + 0, /* mask */ + 0, /* used */ + {{NULL, NULL}}, /* entries */ +}; + +#define EMPTY_TABLE ((abc_table *)&empty_table_struct) + +static inline size_t +abc_table_nbytes(size_t size) +{ + return offsetof(abc_table, entries) + size * sizeof(abc_entry); +} + +static abc_table * +abc_table_new(size_t size) +{ + assert((size & (size - 1)) == 0 && size >= TABLE_MIN_SIZE); + abc_table *table = PyMem_Calloc(1, abc_table_nbytes(size)); + if (table == NULL) { + PyErr_NoMemory(); + return NULL; + } + table->mask = size - 1; + table->used = 0; + return table; +} + +// Free a table and its weakrefs. Use delayed if other threads +// can still be reading the table. +static void +abc_table_release(abc_table *table, int delayed) +{ + if (table == EMPTY_TABLE) { + return; + } + for (size_t i = 0; i <= table->mask; i++) { + PyObject *ref = table->entries[i].ref; + if (delayed) { + _PyObject_XDecRefDelayed(ref); + } + else { + Py_XDECREF(ref); + } + } + if (delayed) { + _PyMem_FreeDelayed(table, abc_table_nbytes(table->mask + 1)); + } + else { + PyMem_Free(table); + } +} + +static inline size_t +abc_hash(PyObject *key) +{ + return (size_t)_Py_HashPointerRaw(key); +} + +static inline int +abc_entry_is_live(PyObject *ref, PyObject *key) +{ + // The caller holds a strong reference to key, so a weakref pointing + // to key cannot be of a dead class which was at the same address. + // wr_object only changes when key dies, so a relaxed load is enough. + assert(ref != NULL); + PyWeakReference *wr = (PyWeakReference *)ref; + return FT_ATOMIC_LOAD_PTR_RELAXED(wr->wr_object) == key; +} + +static abc_entry * +abc_table_find(abc_table *table, PyObject *key, PyObject **found) +{ + size_t mask = table->mask; + size_t perturb = abc_hash(key); + size_t i = perturb & mask; + for (;;) { + abc_entry *entry = &table->entries[i]; + PyObject *k = FT_ATOMIC_LOAD_PTR_ACQUIRE(entry->key); + if (k == NULL || k == key) { + *found = k; + return entry; + } + perturb >>= PERTURB_SHIFT; + i = (i * 5 + perturb + 1) & mask; + } +} + +// Lock-free, the caller must hold a strong reference to key. +static int +abc_table_contains(abc_table *table, PyObject *key) +{ + PyObject *found; + abc_entry *entry = abc_table_find(table, key, &found); + if (found == NULL) { + return 0; + } + PyObject *ref = FT_ATOMIC_LOAD_PTR_ACQUIRE(entry->ref); + return abc_entry_is_live(ref, key); +} + +static abc_table * +abc_table_rebuild(abc_table *old, size_t extra) +{ + size_t live = 0; + for (size_t i = 0; i <= old->mask; i++) { + abc_entry *entry = &old->entries[i]; + if (entry->key != NULL && abc_entry_is_live(entry->ref, entry->key)) { + live++; + } + } + size_t size = TABLE_MIN_SIZE; + while (size < (live + extra) * 2) { + size <<= 1; + } + abc_table *table = abc_table_new(size); + if (table == NULL) { + return NULL; + } + for (size_t i = 0; i <= old->mask; i++) { + abc_entry *entry = &old->entries[i]; + if (entry->key == NULL) { + continue; + } + if (abc_entry_is_live(entry->ref, entry->key)) { + PyObject *found; + abc_entry *dst = abc_table_find(table, entry->key, &found); + assert(found == NULL); + dst->key = entry->key; + dst->ref = entry->ref; + table->used++; + } + else { + _PyObject_XDecRefDelayed(entry->ref); + } + } + return table; +} + +static int +abc_table_add(abc_table **ptable, PyObject *key, PyObject *ref) +{ + abc_table *table = *ptable; + PyObject *found; + abc_entry *entry = abc_table_find(table, key, &found); + if (found == key) { + // The existing weakref can be of a dead class at the same address. + PyObject *old = entry->ref; + if (old == ref) { + Py_DECREF(ref); + } + else { + FT_ATOMIC_STORE_PTR_RELEASE(entry->ref, ref); + _PyObject_XDecRefDelayed(old); + } + return 0; + } + // Always true for EMPTY_TABLE. + if ((table->used + 1) * 3 > (table->mask + 1) * 2) { + abc_table *newtable = abc_table_rebuild(table, 1); + if (newtable == NULL) { + Py_DECREF(ref); + return -1; + } + FT_ATOMIC_STORE_PTR_RELEASE(*ptable, newtable); + if (table != EMPTY_TABLE) { + // The weakrefs were moved to newtable. + _PyMem_FreeDelayed(table, abc_table_nbytes(table->mask + 1)); + } + table = newtable; + entry = abc_table_find(table, key, &found); + } + assert(found == NULL); + FT_ATOMIC_STORE_PTR_RELAXED(entry->ref, ref); + FT_ATOMIC_STORE_PTR_RELEASE(entry->key, key); + table->used++; + return 0; +} + +static void +abc_table_clear(abc_table **ptable) +{ + abc_table *table = *ptable; + if (table != EMPTY_TABLE) { + FT_ATOMIC_STORE_PTR_RELAXED(*ptable, EMPTY_TABLE); + abc_table_release(table, 1); + } +} + +static PyObject * +abc_table_snapshot(abc_table *table) +{ + PyObject *list = PyList_New(0); + if (list == NULL) { + return NULL; + } + for (size_t i = 0; i <= table->mask; i++) { + abc_entry *entry = &table->entries[i]; + if (entry->key == NULL) { + continue; + } + PyObject *obj; + if (PyWeakref_GetRef(entry->ref, &obj) < 0) { + Py_DECREF(list); + return NULL; + } + if (obj == NULL) { + continue; + } + int rc = PyList_Append(list, obj); + Py_DECREF(obj); + if (rc < 0) { + Py_DECREF(list); + return NULL; + } + } + return list; } -/* This object stores internal state for ABCs. - Note that we can use normal sets for caches, - since they are never iterated over. */ + +// Internal state of an ABC, stored in its _abc_impl attribute. + typedef struct { PyObject_HEAD - /* These sets of weak references are lazily created. Once created, they - will point to the same sets until the ABCMeta object is destroyed or - cleared, both of which will only happen while the object is visible to a - single thread. */ - PyObject *_abc_registry; - PyObject *_abc_cache; - PyObject *_abc_negative_cache; - uint64_t _abc_negative_cache_version; + abc_table *registry; + abc_table *cache; + abc_table *negative_cache; + uint64_t negative_cache_version; } _abc_data; #define _abc_data_CAST(op) ((_abc_data *)(op)) +// The version is updated after the negative cache is cleared and read +// before the negative cache is, so a reader which sees the new version +// never sees the old entries. static inline uint64_t get_cache_version(_abc_data *impl) { -#ifdef Py_GIL_DISABLED - return _Py_atomic_load_uint64(&impl->_abc_negative_cache_version); -#else - return impl->_abc_negative_cache_version; -#endif + return FT_ATOMIC_LOAD_UINT64_ACQUIRE(impl->negative_cache_version); } static inline void set_cache_version(_abc_data *impl, uint64_t version) { #ifdef Py_GIL_DISABLED - _Py_atomic_store_uint64(&impl->_abc_negative_cache_version, version); + _Py_atomic_store_uint64_release(&impl->negative_cache_version, version); #else - impl->_abc_negative_cache_version = version; + impl->negative_cache_version = version; #endif } @@ -93,10 +338,9 @@ static int abc_data_traverse(PyObject *op, visitproc visit, void *arg) { _abc_data *self = _abc_data_CAST(op); + // The tables only hold weakrefs without callbacks which cannot + // be part of a reference cycle. Py_VISIT(Py_TYPE(self)); - Py_VISIT(self->_abc_registry); - Py_VISIT(self->_abc_cache); - Py_VISIT(self->_abc_negative_cache); return 0; } @@ -104,9 +348,15 @@ static int abc_data_clear(PyObject *op) { _abc_data *self = _abc_data_CAST(op); - Py_CLEAR(self->_abc_registry); - Py_CLEAR(self->_abc_cache); - Py_CLEAR(self->_abc_negative_cache); + abc_table *registry = self->registry; + abc_table *cache = self->cache; + abc_table *negative_cache = self->negative_cache; + self->registry = EMPTY_TABLE; + self->cache = EMPTY_TABLE; + self->negative_cache = EMPTY_TABLE; + abc_table_release(registry, 0); + abc_table_release(cache, 0); + abc_table_release(negative_cache, 0); return 0; } @@ -135,10 +385,12 @@ abc_data_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; } - self->_abc_registry = NULL; - self->_abc_cache = NULL; - self->_abc_negative_cache = NULL; - self->_abc_negative_cache_version = get_invalidation_counter(state); + self->registry = EMPTY_TABLE; + self->cache = EMPTY_TABLE; + self->negative_cache = EMPTY_TABLE; + self->negative_cache_version = get_invalidation_counter(state); + // Avoid refcount contention between threads. + _PyObject_SetDeferredRefcount((PyObject *)self); return (PyObject *) self; } @@ -162,100 +414,135 @@ static PyType_Spec _abc_data_type_spec = { }; static _abc_data * -_get_impl(PyObject *module, PyObject *self) +lookup_impl(_abcmodule_state *state, PyObject *self, _PyCStackRef *cref) { - _abcmodule_state *state = get_abc_state(module); - PyObject *impl = PyObject_GetAttr(self, &_Py_ID(_abc_impl)); - if (impl == NULL) { + if (!PyType_Check(self)) { return NULL; } + _PyType_LookupStackRefAndVersion((PyTypeObject *)self, &_Py_ID(_abc_impl), + &cref->ref); + if (PyStackRef_IsNull(cref->ref)) { + return NULL; + } + PyObject *impl = PyStackRef_AsPyObjectBorrow(cref->ref); if (!Py_IS_TYPE(impl, state->_abc_data_type)) { - PyErr_SetString(PyExc_TypeError, "_abc_impl is set to a wrong type"); - Py_DECREF(impl); + PyStackRef_CLOSE(cref->ref); + cref->ref = PyStackRef_NULL; return NULL; } return (_abc_data *)impl; } +// Like lookup_impl() but falls back to a full attribute lookup, +// and sets an exception on failure. +static _abc_data * +get_impl(_abcmodule_state *state, PyObject *self, _PyCStackRef *cref) +{ + _abc_data *impl = lookup_impl(state, self, cref); + if (impl != NULL) { + return impl; + } + cref->ref = _PyObject_GetAttrStackRef(self, &_Py_ID(_abc_impl)); + if (PyStackRef_IsNull(cref->ref)) { + return NULL; + } + impl = (_abc_data *)PyStackRef_AsPyObjectBorrow(cref->ref); + if (!Py_IS_TYPE(impl, state->_abc_data_type)) { + PyErr_SetString(PyExc_TypeError, "_abc_impl is set to a wrong type"); + PyStackRef_CLOSE(cref->ref); + cref->ref = PyStackRef_NULL; + return NULL; + } + return impl; +} + static int -_in_weak_set(_abc_data *impl, PyObject **pset, PyObject *obj) +type_lookup_is(PyTypeObject *type, PyObject *name, PyObject *expected) { - PyObject *set; - Py_BEGIN_CRITICAL_SECTION(impl); - set = *pset; - Py_END_CRITICAL_SECTION(); - if (set == NULL || PySet_GET_SIZE(set) == 0) { - return 0; + _PyStackRef ref; + _PyType_LookupStackRefAndVersion(type, name, &ref); + if (PyStackRef_IsNull(ref)) { + return expected == NULL; } - PyObject *ref = PyWeakref_NewRef(obj, NULL); + int res = (PyStackRef_AsPyObjectBorrow(ref) == expected); + PyStackRef_CLOSE(ref); + return res; +} + +static int +add_to_table(_abc_data *impl, abc_table **ptable, PyObject *cls) +{ + // PyWeakref_NewRef() can lock cls, call it outside the critical section. + PyObject *ref = PyWeakref_NewRef(cls, NULL); if (ref == NULL) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) { - PyErr_Clear(); - return 0; - } return -1; } - int res = PySet_Contains(set, ref); - Py_DECREF(ref); + int res; + Py_BEGIN_CRITICAL_SECTION(impl); + res = abc_table_add(ptable, cls, ref); + Py_END_CRITICAL_SECTION(); return res; } -static PyObject * -_destroy(PyObject *setweakref, PyObject *objweakref) +// Add cls to the negative cache if it is still valid for counter. +static int +add_to_negative_cache(_abc_data *impl, PyObject *cls, uint64_t counter) { - PyObject *set = _PyWeakref_GET_REF(setweakref); - if (set == NULL) { - Py_RETURN_NONE; + PyObject *ref = PyWeakref_NewRef(cls, NULL); + if (ref == NULL) { + return -1; } - if (PySet_Discard(set, objweakref) < 0) { - Py_DECREF(set); - return NULL; + int res = 0; + Py_BEGIN_CRITICAL_SECTION(impl); + if (impl->negative_cache_version == counter) { + res = abc_table_add(&impl->negative_cache, cls, ref); } - Py_DECREF(set); - Py_RETURN_NONE; + else { + Py_DECREF(ref); + } + Py_END_CRITICAL_SECTION(); + return res; } -static PyMethodDef _destroy_def = { - "_destroy", _destroy, METH_O -}; +typedef enum { + CACHE_UNKNOWN = -1, // not cached or stale + CACHE_NEGATIVE = 0, // in the negative cache + CACHE_POSITIVE = 1, // in the positive cache +} cache_result; -static int -_add_to_weak_set(_abc_data *impl, PyObject **pset, PyObject *obj) +static cache_result +lookup_caches(_abcmodule_state *state, _abc_data *impl, PyObject *subclass) { - PyObject *set; - Py_BEGIN_CRITICAL_SECTION(impl); - set = *pset; - if (set == NULL) { - set = *pset = PySet_New(NULL); - } - Py_END_CRITICAL_SECTION(); - if (set == NULL) { - return -1; + abc_table *table = FT_ATOMIC_LOAD_PTR_ACQUIRE(impl->cache); + if (abc_table_contains(table, subclass)) { + return CACHE_POSITIVE; + } + if (get_cache_version(impl) == get_invalidation_counter(state)) { + table = FT_ATOMIC_LOAD_PTR_ACQUIRE(impl->negative_cache); + if (abc_table_contains(table, subclass)) { + return CACHE_NEGATIVE; + } } + return CACHE_UNKNOWN; +} - PyObject *ref, *wr; - PyObject *destroy_cb; - wr = PyWeakref_NewRef(set, NULL); - if (wr == NULL) { - return -1; - } - destroy_cb = PyCFunction_NewEx(&_destroy_def, wr, NULL); - if (destroy_cb == NULL) { - Py_DECREF(wr); - return -1; +// Clear the negative cache if register() was called since it was last +// validated. +static void +validate_negative_cache(_abc_data *impl, uint64_t counter) +{ + if (get_cache_version(impl) >= counter) { + return; } - ref = PyWeakref_NewRef(obj, destroy_cb); - Py_DECREF(destroy_cb); - if (ref == NULL) { - Py_DECREF(wr); - return -1; + Py_BEGIN_CRITICAL_SECTION(impl); + if (impl->negative_cache_version < counter) { + abc_table_clear(&impl->negative_cache); + set_cache_version(impl, counter); } - int ret = PySet_Add(set, ref); - Py_DECREF(wr); - Py_DECREF(ref); - return ret; + Py_END_CRITICAL_SECTION(); } + /*[clinic input] _abc._reset_registry @@ -271,19 +558,22 @@ static PyObject * _abc__reset_registry(PyObject *module, PyObject *self) /*[clinic end generated code: output=92d591a43566cc10 input=12a0b7eb339ac35c]*/ { - _abc_data *impl = _get_impl(module, self); - if (impl == NULL) { - return NULL; + PyThreadState *tstate = _PyThreadState_GET(); + _PyCStackRef cref; + _PyThreadState_PushCStackRef(tstate, &cref); + _abc_data *impl = get_impl(get_abc_state(module), self, &cref); + if (impl != NULL) { + Py_BEGIN_CRITICAL_SECTION(impl); + abc_table_clear(&impl->registry); + // Registered classes are also in the cache, and register() + // does nothing for a class which is cached as a subclass. + abc_table_clear(&impl->cache); + Py_END_CRITICAL_SECTION(); } - PyObject *registry; - Py_BEGIN_CRITICAL_SECTION(impl); - registry = impl->_abc_registry; - Py_END_CRITICAL_SECTION(); - if (registry != NULL && PySet_Clear(registry) < 0) { - Py_DECREF(impl); + _PyThreadState_PopCStackRef(tstate, &cref); + if (impl == NULL) { return NULL; } - Py_DECREF(impl); Py_RETURN_NONE; } @@ -302,26 +592,44 @@ static PyObject * _abc__reset_caches(PyObject *module, PyObject *self) /*[clinic end generated code: output=f296f0d5c513f80c input=c0ac616fd8acfb6f]*/ { - _abc_data *impl = _get_impl(module, self); + PyThreadState *tstate = _PyThreadState_GET(); + _PyCStackRef cref; + _PyThreadState_PushCStackRef(tstate, &cref); + _abc_data *impl = get_impl(get_abc_state(module), self, &cref); + if (impl != NULL) { + Py_BEGIN_CRITICAL_SECTION(impl); + abc_table_clear(&impl->cache); + abc_table_clear(&impl->negative_cache); + Py_END_CRITICAL_SECTION(); + } + _PyThreadState_PopCStackRef(tstate, &cref); if (impl == NULL) { return NULL; } - PyObject *cache, *negative_cache; - Py_BEGIN_CRITICAL_SECTION(impl); - cache = impl->_abc_cache; - negative_cache = impl->_abc_negative_cache; - Py_END_CRITICAL_SECTION(); - if (cache != NULL && PySet_Clear(cache) < 0) { - Py_DECREF(impl); + Py_RETURN_NONE; +} + +static PyObject * +weakref_set_from_list(PyObject *list) +{ + PyObject *set = PySet_New(NULL); + if (set == NULL) { return NULL; } - /* also the second cache */ - if (negative_cache != NULL && PySet_Clear(negative_cache) < 0) { - Py_DECREF(impl); - return NULL; + for (Py_ssize_t i = 0; i < PyList_GET_SIZE(list); i++) { + PyObject *ref = PyWeakref_NewRef(PyList_GET_ITEM(list, i), NULL); + if (ref == NULL) { + Py_DECREF(set); + return NULL; + } + int rc = PySet_Add(set, ref); + Py_DECREF(ref); + if (rc < 0) { + Py_DECREF(set); + return NULL; + } } - Py_DECREF(impl); - Py_RETURN_NONE; + return set; } /*[clinic input] @@ -341,19 +649,41 @@ static PyObject * _abc__get_dump(PyObject *module, PyObject *self) /*[clinic end generated code: output=9d9569a8e2c1c443 input=2c5deb1bfe9e3c79]*/ { - _abc_data *impl = _get_impl(module, self); + PyThreadState *tstate = _PyThreadState_GET(); + _PyCStackRef cref; + _PyThreadState_PushCStackRef(tstate, &cref); + _abc_data *impl = get_impl(get_abc_state(module), self, &cref); if (impl == NULL) { + _PyThreadState_PopCStackRef(tstate, &cref); return NULL; } - PyObject *res; + PyObject *lists[3] = {NULL, NULL, NULL}; + PyObject *sets[3] = {NULL, NULL, NULL}; + PyObject *res = NULL; + uint64_t version; Py_BEGIN_CRITICAL_SECTION(impl); - res = Py_BuildValue("NNNK", - PySet_New(impl->_abc_registry), - PySet_New(impl->_abc_cache), - PySet_New(impl->_abc_negative_cache), - get_cache_version(impl)); + lists[0] = abc_table_snapshot(impl->registry); + lists[1] = abc_table_snapshot(impl->cache); + lists[2] = abc_table_snapshot(impl->negative_cache); + version = get_cache_version(impl); Py_END_CRITICAL_SECTION(); - Py_DECREF(impl); + _PyThreadState_PopCStackRef(tstate, &cref); + for (int i = 0; i < 3; i++) { + if (lists[i] == NULL) { + goto done; + } + sets[i] = weakref_set_from_list(lists[i]); + if (sets[i] == NULL) { + goto done; + } + } + res = Py_BuildValue("OOOK", sets[0], sets[1], sets[2], + (unsigned long long)version); +done: + for (int i = 0; i < 3; i++) { + Py_XDECREF(lists[i]); + Py_XDECREF(sets[i]); + } return res; } @@ -580,18 +910,20 @@ _abc__abc_register_impl(PyObject *module, PyObject *self, PyObject *subclass) if (result < 0) { return NULL; } - _abc_data *impl = _get_impl(module, self); - if (impl == NULL) { - return NULL; - } - if (_add_to_weak_set(impl, &impl->_abc_registry, subclass) < 0) { - Py_DECREF(impl); + _abcmodule_state *state = get_abc_state(module); + PyThreadState *tstate = _PyThreadState_GET(); + _PyCStackRef cref; + _PyThreadState_PushCStackRef(tstate, &cref); + _abc_data *impl = get_impl(state, self, &cref); + int err = (impl == NULL + || add_to_table(impl, &impl->registry, subclass) < 0); + _PyThreadState_PopCStackRef(tstate, &cref); + if (err) { return NULL; } - Py_DECREF(impl); /* Invalidate negative cache */ - increment_invalidation_counter(get_abc_state(module)); + increment_invalidation_counter(state); /* Set Py_TPFLAGS_SEQUENCE or Py_TPFLAGS_MAPPING flag */ if (PyType_Check(self)) { @@ -607,6 +939,16 @@ _abc__abc_register_impl(PyObject *module, PyObject *self, PyObject *subclass) } +// True if instance.__class__ is type(instance) and the lookup +// doesn't run any Python code. +static inline int +has_default_class_attr(_abcmodule_state *state, PyObject *instance) +{ + PyTypeObject *tp = Py_TYPE(instance); + return tp->tp_getattro == PyObject_GenericGetAttr + && type_lookup_is(tp, &_Py_ID(__class__), state->object_class_descr); +} + /*[clinic input] @permit_long_summary _abc._abc_instancecheck @@ -623,46 +965,53 @@ _abc__abc_instancecheck_impl(PyObject *module, PyObject *self, PyObject *instance) /*[clinic end generated code: output=b8b5148f63b6b56f input=0bbc8da0ea346719]*/ { - PyObject *subtype, *result = NULL, *subclass = NULL; - _abc_data *impl = _get_impl(module, self); - if (impl == NULL) { - return NULL; - } + _abcmodule_state *state = get_abc_state(module); + PyObject *subclass_owned = NULL; + PyObject *result = NULL; - subclass = PyObject_GetAttr(instance, &_Py_ID(__class__)); - if (subclass == NULL) { - Py_DECREF(impl); - return NULL; - } - /* Inline the cache checking. */ - int incache = _in_weak_set(impl, &impl->_abc_cache, subclass); - if (incache < 0) { - goto end; + if (!has_default_class_attr(state, instance)) { + if (PyObject_GetOptionalAttr(instance, &_Py_ID(__class__), + &subclass_owned) < 0) { + return NULL; + } } - if (incache > 0) { - result = Py_NewRef(Py_True); - goto end; + // The __class__ lookup can change the type of the instance. + PyObject *subtype = (PyObject *)Py_TYPE(instance); + // subclass is either subtype, which is kept alive by instance, or + // subclass_owned. The fast path doesn't incref subtype to avoid + // refcount contention between threads. + /* Fall back to the type when the instance has no __class__, + matching the behaviour of the built-in isinstance() + (gh-153772). */ + PyObject *subclass = subclass_owned != NULL ? subclass_owned : subtype; + + // Fast path: cache hits don't need any locking. + PyThreadState *tstate = _PyThreadState_GET(); + _PyCStackRef cref; + _PyThreadState_PushCStackRef(tstate, &cref); + _abc_data *impl = get_impl(state, self, &cref); + cache_result incache = CACHE_UNKNOWN; + if (impl != NULL) { + incache = lookup_caches(state, impl, subclass); + } + _PyThreadState_PopCStackRef(tstate, &cref); + if (impl == NULL) { + Py_XDECREF(subclass_owned); + return NULL; } - subtype = (PyObject *)Py_TYPE(instance); - if (subtype == subclass) { - if (get_cache_version(impl) == get_invalidation_counter(get_abc_state(module))) { - incache = _in_weak_set(impl, &impl->_abc_negative_cache, subclass); - if (incache < 0) { - goto end; - } - if (incache > 0) { - result = Py_NewRef(Py_False); - goto end; - } - } - /* Fall back to the subclass check. */ - result = PyObject_CallMethodOneArg(self, &_Py_ID(__subclasscheck__), - subclass); - goto end; + if (incache == CACHE_POSITIVE + || (incache == CACHE_NEGATIVE && subtype == subclass)) + { + Py_XDECREF(subclass_owned); + return PyBool_FromLong(incache); } + + /* A subclass check can change the instance's actual type. */ + Py_INCREF(subtype); result = PyObject_CallMethodOneArg(self, &_Py_ID(__subclasscheck__), subclass); - if (result == NULL) { + if (result == NULL || subtype == subclass) { + Py_DECREF(subtype); goto end; } @@ -680,234 +1029,265 @@ _abc__abc_instancecheck_impl(PyObject *module, PyObject *self, default: Py_UNREACHABLE(); } + Py_DECREF(subtype); end: - Py_XDECREF(impl); - Py_XDECREF(subclass); + Py_XDECREF(subclass_owned); return result; } -// Return -1 when exception occurred. -// Return 1 when result is set. -// Return 0 otherwise. -static int subclasscheck_check_registry(_abc_data *impl, PyObject *subclass, - PyObject **result); - -/*[clinic input] -@permit_long_summary -_abc._abc_subclasscheck +static int subclasscheck(_abcmodule_state *state, _abc_data *impl, + PyObject *self, PyObject *subclass, int nested); - self: object - subclass: object - / - -Internal ABC helper for subclasss checks. Should be never used outside abc module. -[clinic start generated code]*/ - -static PyObject * -_abc__abc_subclasscheck_impl(PyObject *module, PyObject *self, - PyObject *subclass) -/*[clinic end generated code: output=b56c9e4a530e3894 input=5bf1ef712f5d3610]*/ +// Like PyObject_IsSubclass(subclass, cls), but doesn't add subclass to the +// negative cache of cls if cls uses the default ABCMeta.__subclasscheck__. +static int +issubclass_nested(_abcmodule_state *state, PyObject *subclass, PyObject *cls) { - if (!PyType_Check(subclass)) { - PyErr_SetString(PyExc_TypeError, "issubclass() arg 1 must be a class"); - return NULL; + assert(PyType_Check(cls)); + if (type_lookup_is(Py_TYPE(cls), &_Py_ID(__subclasscheck__), + state->subclasscheck_func)) + { + PyThreadState *tstate = _PyThreadState_GET(); + _PyCStackRef cref; + _PyThreadState_PushCStackRef(tstate, &cref); + _abc_data *impl = lookup_impl(state, cls, &cref); + int res = -1; + if (impl != NULL) { + if (!Py_EnterRecursiveCall(" in __subclasscheck__")) { + res = subclasscheck(state, impl, cls, subclass, 1); + Py_LeaveRecursiveCall(); + } + } + _PyThreadState_PopCStackRef(tstate, &cref); + if (impl != NULL) { + return res; + } } + return PyObject_IsSubclass(subclass, cls); +} - PyObject *ok, *subclasses = NULL, *result = NULL; - _abcmodule_state *state = NULL; - Py_ssize_t pos; - int incache; - _abc_data *impl = _get_impl(module, self); - if (impl == NULL) { - return NULL; +// Check if subclass is a subclass of a registered class. +// Returns -1 on error. +static int +check_registry(_abcmodule_state *state, _abc_data *impl, PyObject *subclass) +{ + abc_table *registry = FT_ATOMIC_LOAD_PTR_ACQUIRE(impl->registry); + // Fast path: subclass is registered directly. + if (abc_table_contains(registry, subclass)) { + return 1; } - - /* 1. Check cache. */ - incache = _in_weak_set(impl, &impl->_abc_cache, subclass); - if (incache < 0) { - goto end; + // The registry can be modified by the checks, iterate over a copy. + PyObject *classes; + Py_BEGIN_CRITICAL_SECTION(impl); + classes = abc_table_snapshot(impl->registry); + Py_END_CRITICAL_SECTION(); + if (classes == NULL) { + return -1; } - if (incache > 0) { - result = Py_True; - goto end; + int res = 0; + for (Py_ssize_t i = 0; i < PyList_GET_SIZE(classes); i++) { + res = PyObject_IsSubclass(subclass, PyList_GET_ITEM(classes, i)); + if (res != 0) { + break; + } } + Py_DECREF(classes); + return res; +} - state = get_abc_state(module); - /* 2. Check negative cache; may have to invalidate. */ - uint64_t invalidation_counter = get_invalidation_counter(state); - if (get_cache_version(impl) < invalidation_counter) { - /* Invalidate the negative cache. */ - PyObject *negative_cache; - Py_BEGIN_CRITICAL_SECTION(impl); - negative_cache = impl->_abc_negative_cache; - Py_END_CRITICAL_SECTION(); - if (negative_cache != NULL && PySet_Clear(negative_cache) < 0) { - goto end; - } - set_cache_version(impl, invalidation_counter); +// Check if subclass is a subclass of a subclass of self. +// Returns -1 on error. +static int +check_subclasses(_abcmodule_state *state, PyObject *self, PyObject *subclass) +{ + PyObject *subclasses; + int native = 0; + if (PyType_Check(self) + && type_lookup_is((PyTypeObject *)self, &_Py_ID(__subclasses__), NULL) + && type_lookup_is(Py_TYPE(self), &_Py_ID(__subclasses__), + state->type_subclasses)) + { + // __subclasses__() is not overridden, get the subclasses directly. + subclasses = _PyType_GetSubclasses((PyTypeObject *)self); + native = 1; } else { - incache = _in_weak_set(impl, &impl->_abc_negative_cache, subclass); - if (incache < 0) { - goto end; + subclasses = PyObject_CallMethodNoArgs(self, &_Py_ID(__subclasses__)); + if (subclasses != NULL && !PyList_Check(subclasses)) { + PyErr_SetString(PyExc_TypeError, "__subclasses__() must return a list"); + Py_DECREF(subclasses); + return -1; + } + } + if (subclasses == NULL) { + return -1; + } + int res = 0; + for (Py_ssize_t i = 0; i < PyList_GET_SIZE(subclasses); i++) { + PyObject *scls = PyList_GetItemRef(subclasses, i); + if (scls == NULL) { + res = -1; + break; + } + if (native) { + res = issubclass_nested(state, subclass, scls); } - if (incache > 0) { - result = Py_False; - goto end; + else { + res = PyObject_IsSubclass(subclass, scls); + } + Py_DECREF(scls); + if (res != 0) { + break; } } + Py_DECREF(subclasses); + return res; +} - /* 3. Check the subclass hook. */ - ok = PyObject_CallMethodOneArg( - (PyObject *)self, &_Py_ID(__subclasshook__), subclass); - if (ok == NULL) { - goto end; +// Implementation of ABCMeta.__subclasscheck__. Returns -1 on error. +// +// nested is set when checking the subclasses of another ABC. Negative +// results are not cached then, otherwise every class in the hierarchy +// would cache them which is quadratic in the number of classes. +static int +subclasscheck(_abcmodule_state *state, _abc_data *impl, + PyObject *self, PyObject *subclass, int nested) +{ + uint64_t counter = get_invalidation_counter(state); + + /* 1. Check cache. 2. Check negative cache; may have to invalidate. */ + validate_negative_cache(impl, counter); + cache_result incache = lookup_caches(state, impl, subclass); + if (incache != CACHE_UNKNOWN) { + return incache; } - if (ok == Py_True) { - Py_DECREF(ok); - if (_add_to_weak_set(impl, &impl->_abc_cache, subclass) < 0) { - goto end; + + /* 3. Check the subclass hook. */ + // The default hook always returns NotImplemented, skip the call. + if (!(PyType_Check(self) + && type_lookup_is((PyTypeObject *)self, &_Py_ID(__subclasshook__), + state->object_subclasshook) + && type_lookup_is(Py_TYPE(self), &_Py_ID(__subclasshook__), + state->object_subclasshook))) + { + PyObject *ok = PyObject_CallMethodOneArg( + self, &_Py_ID(__subclasshook__), subclass); + if (ok == NULL) { + return -1; } - result = Py_True; - goto end; - } - if (ok == Py_False) { - Py_DECREF(ok); - if (_add_to_weak_set(impl, &impl->_abc_negative_cache, subclass) < 0) { - goto end; + if (ok == Py_True) { + goto positive; + } + if (ok == Py_False) { + goto negative; + } + if (ok != Py_NotImplemented) { + Py_DECREF(ok); + PyErr_SetString(PyExc_AssertionError, "__subclasshook__ must return either" + " False, True, or NotImplemented"); + return -1; } - result = Py_False; - goto end; - } - if (ok != Py_NotImplemented) { - Py_DECREF(ok); - PyErr_SetString(PyExc_AssertionError, "__subclasshook__ must return either" - " False, True, or NotImplemented"); - goto end; } - Py_DECREF(ok); /* 4. Check if it's a direct subclass. */ if (PyType_IsSubtype((PyTypeObject *)subclass, (PyTypeObject *)self)) { - if (_add_to_weak_set(impl, &impl->_abc_cache, subclass) < 0) { - goto end; - } - result = Py_True; - goto end; + goto positive; } /* 5. Check if it's a subclass of a registered class (recursive). */ - if (subclasscheck_check_registry(impl, subclass, &result)) { - // Exception occurred or result is set. - goto end; + int res = check_registry(state, impl, subclass); + if (res < 0) { + return -1; + } + if (res > 0) { + goto positive; } /* 6. Check if it's a subclass of a subclass (recursive). */ - subclasses = PyObject_CallMethod(self, "__subclasses__", NULL); - if (subclasses == NULL) { - goto end; - } - if (!PyList_Check(subclasses)) { - PyErr_SetString(PyExc_TypeError, "__subclasses__() must return a list"); - goto end; + res = check_subclasses(state, self, subclass); + if (res < 0) { + return -1; } - for (pos = 0; pos < PyList_GET_SIZE(subclasses); pos++) { - PyObject *scls = PyList_GetItemRef(subclasses, pos); - if (scls == NULL) { - goto end; - } - int r = PyObject_IsSubclass(subclass, scls); - Py_DECREF(scls); - if (r > 0) { - if (_add_to_weak_set(impl, &impl->_abc_cache, subclass) < 0) { - goto end; - } - result = Py_True; - goto end; - } - if (r < 0) { - goto end; - } + if (res > 0) { + goto positive; } +negative: /* No dice; update negative cache. */ - if (_add_to_weak_set(impl, &impl->_abc_negative_cache, subclass) < 0) { - goto end; + if (!nested && add_to_negative_cache(impl, subclass, counter) < 0) { + return -1; } - result = Py_False; + return 0; -end: - Py_DECREF(impl); - Py_XDECREF(subclasses); - return Py_XNewRef(result); +positive: + if (add_to_table(impl, &impl->cache, subclass) < 0) { + return -1; + } + return 1; } +/*[clinic input] +@permit_long_summary +_abc._abc_subclasscheck -static int -subclasscheck_check_registry(_abc_data *impl, PyObject *subclass, - PyObject **result) + self: object + subclass: object + / + +Internal ABC helper for subclasss checks. Should be never used outside abc module. +[clinic start generated code]*/ + +static PyObject * +_abc__abc_subclasscheck_impl(PyObject *module, PyObject *self, + PyObject *subclass) +/*[clinic end generated code: output=b56c9e4a530e3894 input=5bf1ef712f5d3610]*/ { - // Fast path: check subclass is in weakref directly. - int ret = _in_weak_set(impl, &impl->_abc_registry, subclass); - if (ret < 0) { - *result = NULL; - return -1; - } - if (ret > 0) { - *result = Py_True; - return 1; + if (!PyType_Check(subclass)) { + PyErr_SetString(PyExc_TypeError, "issubclass() arg 1 must be a class"); + return NULL; } - PyObject *registry_shared; - Py_BEGIN_CRITICAL_SECTION(impl); - registry_shared = impl->_abc_registry; - Py_END_CRITICAL_SECTION(); - if (registry_shared == NULL) { - return 0; + _abcmodule_state *state = get_abc_state(module); + PyThreadState *tstate = _PyThreadState_GET(); + _PyCStackRef cref; + _PyThreadState_PushCStackRef(tstate, &cref); + _abc_data *impl = get_impl(state, self, &cref); + int res = -1; + if (impl != NULL) { + res = lookup_caches(state, impl, subclass); + if (res == CACHE_UNKNOWN) { + res = subclasscheck(state, impl, self, subclass, 0); + } } - - // Make a local copy of the registry to protect against concurrent - // modifications of _abc_registry. - PyObject *registry = PyFrozenSet_New(registry_shared); - if (registry == NULL) { - return -1; + _PyThreadState_PopCStackRef(tstate, &cref); + if (res < 0) { + return NULL; } - PyObject *key; - Py_ssize_t pos = 0; - Py_hash_t hash; + return PyBool_FromLong(res); +} - while (_PySet_NextEntry(registry, &pos, &key, &hash)) { - PyObject *rkey; - if (PyWeakref_GetRef(key, &rkey) < 0) { - // Someone inject non-weakref type in the registry. - ret = -1; - break; - } +/*[clinic input] +_abc._set_subclasscheck - if (rkey == NULL) { - continue; - } - int r = PyObject_IsSubclass(subclass, rkey); - Py_DECREF(rkey); - if (r < 0) { - ret = -1; - break; - } - if (r > 0) { - if (_add_to_weak_set(impl, &impl->_abc_cache, subclass) < 0) { - ret = -1; - break; - } - *result = Py_True; - ret = 1; - break; - } - } + func: object + / - Py_DECREF(registry); - return ret; +Internal ABC helper to register ABCMeta.__subclasscheck__. + +Classes whose metaclass resolves __subclasscheck__ to func are checked +natively when walking the subclass tree of an ABC. +[clinic start generated code]*/ + +static PyObject * +_abc__set_subclasscheck(PyObject *module, PyObject *func) +/*[clinic end generated code: output=1dc657738311dea5 input=c2e47dd519524e44]*/ +{ + _abcmodule_state *state = get_abc_state(module); + // abc can be reloaded. + Py_XSETREF(state->subclasscheck_func, Py_NewRef(func)); + Py_RETURN_NONE; } /*[clinic input] @@ -937,9 +1317,23 @@ static struct PyMethodDef _abcmodule_methods[] = { _ABC__ABC_REGISTER_METHODDEF _ABC__ABC_INSTANCECHECK_METHODDEF _ABC__ABC_SUBCLASSCHECK_METHODDEF + _ABC__SET_SUBCLASSCHECK_METHODDEF {NULL, NULL} /* sentinel */ }; +static int +get_type_dict_item(PyTypeObject *type, PyObject *name, PyObject **result) +{ + if (PyDict_GetItemRef(_PyType_GetDict(type), name, result) < 0) { + return -1; + } + if (*result == NULL) { + PyErr_Format(PyExc_SystemError, "%s has no %U", type->tp_name, name); + return -1; + } + return 0; +} + static int _abcmodule_exec(PyObject *module) { @@ -949,7 +1343,15 @@ _abcmodule_exec(PyObject *module) if (state->_abc_data_type == NULL) { return -1; } - + if (get_type_dict_item(&PyBaseObject_Type, &_Py_ID(__class__), + &state->object_class_descr) < 0 + || get_type_dict_item(&PyBaseObject_Type, &_Py_ID(__subclasshook__), + &state->object_subclasshook) < 0 + || get_type_dict_item(&PyType_Type, &_Py_ID(__subclasses__), + &state->type_subclasses) < 0) + { + return -1; + } return 0; } @@ -958,6 +1360,10 @@ _abcmodule_traverse(PyObject *module, visitproc visit, void *arg) { _abcmodule_state *state = get_abc_state(module); Py_VISIT(state->_abc_data_type); + Py_VISIT(state->object_class_descr); + Py_VISIT(state->object_subclasshook); + Py_VISIT(state->type_subclasses); + Py_VISIT(state->subclasscheck_func); return 0; } @@ -966,6 +1372,10 @@ _abcmodule_clear(PyObject *module) { _abcmodule_state *state = get_abc_state(module); Py_CLEAR(state->_abc_data_type); + Py_CLEAR(state->object_class_descr); + Py_CLEAR(state->object_subclasshook); + Py_CLEAR(state->type_subclasses); + Py_CLEAR(state->subclasscheck_func); return 0; } diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index bc0f7f3901e0eda..0ab7682a5404230 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -68,8 +68,8 @@ typedef struct TaskObj { PyObject *task_context; struct llist_node task_node; #ifdef Py_GIL_DISABLED - // thread id of the thread where this task was created - uintptr_t task_tid; + // unique id of the thread state where the task was registered + uint64_t task_tstate_id; #endif } TaskObj; @@ -769,7 +769,6 @@ future_get_result(asyncio_state *state, FutureObj *fut, PyObject **result) return -1; } *result = Py_NewRef(fut->fut_exception); - Py_CLEAR(fut->fut_exception_tb); return 1; } @@ -873,6 +872,7 @@ future_cancel(asyncio_state *state, FutureObj *fut, PyObject *msg) } /*[clinic input] +@vectorcall _asyncio.Future.__init__ * @@ -894,7 +894,7 @@ This class is *almost* compatible with concurrent.futures.Future. static int _asyncio_Future___init___impl(FutureObj *self, PyObject *loop) -/*[clinic end generated code: output=9ed75799eaccb5d6 input=89af317082bc0bf8]*/ +/*[clinic end generated code: output=9ed75799eaccb5d6 input=28ff6d3b6c3aa828]*/ { return future_init(self, loop); @@ -1355,93 +1355,67 @@ _asyncio_Future__asyncio_awaited_by_get_impl(FutureObj *self) /*[clinic input] @critical_section @getter -_asyncio.Future._asyncio_future_blocking +_asyncio.Future._asyncio_future_blocking -> bool [clinic start generated code]*/ -static PyObject * +static int _asyncio_Future__asyncio_future_blocking_get_impl(FutureObj *self) -/*[clinic end generated code: output=a558a2c51e38823b input=58da92efc03b617d]*/ +/*[clinic end generated code: output=32944de3df031979 input=2a51a0cf31a96826]*/ { - if (future_is_alive(self) && self->fut_blocking) { - Py_RETURN_TRUE; - } - else { - Py_RETURN_FALSE; - } + return future_is_alive(self) && self->fut_blocking; } /*[clinic input] @critical_section @setter _asyncio.Future._asyncio_future_blocking + value: bool [clinic start generated code]*/ static int -_asyncio_Future__asyncio_future_blocking_set_impl(FutureObj *self, - PyObject *value) -/*[clinic end generated code: output=0686d1cb024a7453 input=3fd4a5f95df788b7]*/ - +_asyncio_Future__asyncio_future_blocking_set_impl(FutureObj *self, int value) +/*[clinic end generated code: output=be2d5cb1cad6dd30 input=81780cb7b89f28e1]*/ { if (future_ensure_alive(self)) { return -1; } - if (value == NULL) { - PyErr_SetString(PyExc_AttributeError, "cannot delete attribute"); - return -1; - } - - int is_true = PyObject_IsTrue(value); - if (is_true < 0) { - return -1; - } - self->fut_blocking = is_true; + self->fut_blocking = value; return 0; } /*[clinic input] @critical_section @getter -_asyncio.Future._log_traceback +_asyncio.Future._log_traceback -> bool [clinic start generated code]*/ -static PyObject * +static int _asyncio_Future__log_traceback_get_impl(FutureObj *self) -/*[clinic end generated code: output=2724433b238593c7 input=91e5144ea4117d8e]*/ +/*[clinic end generated code: output=ba1356634182ac25 input=50f4db8eca9d1fb4]*/ { - asyncio_state *state = get_asyncio_state_by_def((PyObject *)self); - ENSURE_FUTURE_ALIVE(state, self) - if (self->fut_log_tb) { - Py_RETURN_TRUE; - } - else { - Py_RETURN_FALSE; + if (future_ensure_alive(self)) { + return -1; } + return self->fut_log_tb; } /*[clinic input] @critical_section @setter _asyncio.Future._log_traceback + value: bool [clinic start generated code]*/ static int -_asyncio_Future__log_traceback_set_impl(FutureObj *self, PyObject *value) -/*[clinic end generated code: output=9ce8e19504f42f54 input=30ac8217754b08c2]*/ +_asyncio_Future__log_traceback_set_impl(FutureObj *self, int value) +/*[clinic end generated code: output=ad84ae67ef80e3ad input=30c0f841c945c73f]*/ { - if (value == NULL) { - PyErr_SetString(PyExc_AttributeError, "cannot delete attribute"); - return -1; - } - int is_true = PyObject_IsTrue(value); - if (is_true < 0) { - return -1; - } - if (is_true) { + if (value) { PyErr_SetString(PyExc_ValueError, "_log_traceback can only be set to False"); return -1; } - self->fut_log_tb = is_true; + self->fut_log_tb = value; return 0; } /*[clinic input] @@ -1593,10 +1567,6 @@ static int _asyncio_Future__cancel_message_set_impl(FutureObj *self, PyObject *value) /*[clinic end generated code: output=0854b2f77bff2209 input=f461d17f2d891fad]*/ { - if (value == NULL) { - PyErr_SetString(PyExc_AttributeError, "cannot delete attribute"); - return -1; - } Py_INCREF(value); Py_XSETREF(self->fut_cancel_msg, value); return 0; @@ -1765,6 +1735,7 @@ static PyType_Slot Future_slots[] = { {Py_tp_methods, FutureType_methods}, {Py_tp_getset, FutureType_getsetlist}, {Py_tp_init, _asyncio_Future___init__}, + {Py_tp_vectorcall, _asyncio_Future_vectorcall}, {Py_tp_new, PyType_GenericNew}, {Py_tp_finalize, FutureObj_finalize}, @@ -1826,10 +1797,9 @@ FutureIter_dealloc(PyObject *it) } static PySendResult -FutureIter_am_send_lock_held(futureiterobject *it, PyObject **result) +FutureIter_am_send_lock_held(FutureObj *fut, PyObject **result) { PyObject *res; - FutureObj *fut = it->future; _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(fut); *result = NULL; @@ -1860,11 +1830,24 @@ FutureIter_am_send(PyObject *op, PyObject **result) { futureiterobject *it = (futureiterobject*)op; + + FutureObj *fut; + Py_BEGIN_CRITICAL_SECTION(op); + fut = (FutureObj*)Py_XNewRef(it->future); + Py_END_CRITICAL_SECTION(); + + if (fut == NULL) { + PyErr_SetNone(PyExc_StopIteration); + *result = NULL; + return PYGEN_ERROR; + } + /* arg is unused, see the comment on FutureIter_send for clarification */ PySendResult res; - Py_BEGIN_CRITICAL_SECTION(it->future); - res = FutureIter_am_send_lock_held(it, result); + Py_BEGIN_CRITICAL_SECTION(fut); + res = FutureIter_am_send_lock_held(fut, result); Py_END_CRITICAL_SECTION(); + Py_DECREF(fut); return res; } @@ -1958,7 +1941,9 @@ FutureIter_throw(PyObject *op, PyObject *const *args, Py_ssize_t nargs) goto fail; } + Py_BEGIN_CRITICAL_SECTION(self); Py_CLEAR(self->future); + Py_END_CRITICAL_SECTION(); PyErr_Restore(type, val, tb); @@ -1971,6 +1956,16 @@ FutureIter_throw(PyObject *op, PyObject *const *args, Py_ssize_t nargs) return NULL; } +static PyObject * +FutureIter_close(PyObject *self, PyObject *arg) +{ + futureiterobject *it = (futureiterobject*)self; + Py_BEGIN_CRITICAL_SECTION(self); + Py_CLEAR(it->future); + Py_END_CRITICAL_SECTION(); + Py_RETURN_NONE; +} + static int FutureIter_clear(PyObject *op) { @@ -1979,13 +1974,6 @@ FutureIter_clear(PyObject *op) return 0; } -static PyObject * -FutureIter_close(PyObject *self, PyObject *arg) -{ - (void)FutureIter_clear(self); - Py_RETURN_NONE; -} - static int FutureIter_traverse(PyObject *op, visitproc visit, void *arg) { @@ -2002,6 +1990,22 @@ static PyMethodDef FutureIter_methods[] = { {NULL, NULL} /* Sentinel */ }; +static PyObject * +FutureIter_get_fi_future(PyObject *op, void *Py_UNUSED(closure)) +{ + futureiterobject *it = (futureiterobject*)op; + PyObject *fut; + Py_BEGIN_CRITICAL_SECTION(op); + fut = it->future ? Py_NewRef(it->future) : Py_None; + Py_END_CRITICAL_SECTION(); + return fut; +} + +static PyGetSetDef FutureIter_getsetlist[] = { + {"fi_future", FutureIter_get_fi_future, NULL, NULL}, + {NULL} /* Sentinel */ +}; + static PyType_Slot FutureIter_slots[] = { {Py_tp_dealloc, FutureIter_dealloc}, {Py_tp_getattro, PyObject_GenericGetAttr}, @@ -2010,6 +2014,7 @@ static PyType_Slot FutureIter_slots[] = { {Py_tp_iter, PyObject_SelfIter}, {Py_tp_iternext, FutureIter_iternext}, {Py_tp_methods, FutureIter_methods}, + {Py_tp_getset, FutureIter_getsetlist}, // async methods {Py_am_send, FutureIter_am_send}, @@ -2182,6 +2187,9 @@ register_task(_PyThreadStateImpl *ts, TaskObj *task) assert(task->task_node.prev != NULL); return; } +#ifdef Py_GIL_DISABLED + task->task_tstate_id = ts->base.id; +#endif struct llist_node *head = &ts->asyncio_tasks_head; llist_insert_tail(head, &task->task_node); } @@ -2201,15 +2209,15 @@ static void unregister_task(TaskObj *task) { #ifdef Py_GIL_DISABLED - // check if we are in the same thread - // if so, we can avoid locking - if (task->task_tid == _Py_ThreadId()) { + PyThreadState *tstate = _PyThreadState_GET(); + // The task can only be on this thread's list if this thread state + // registered it, in which case no locking is needed. + if (task->task_tstate_id == tstate->id) { unregister_task_safe(task); } else { - // we are in a different thread - // stop the world then check and remove the task - PyThreadState *tstate = _PyThreadState_GET(); + // The task is on another thread's list or on the interpreter's + // list of lingering tasks: stop the world to remove it. _PyEval_StopTheWorld(tstate->interp); unregister_task_safe(task); _PyEval_StartTheWorld(tstate->interp); @@ -2284,6 +2292,7 @@ swap_current_task(_PyThreadStateImpl *ts, PyObject *loop, PyObject *task) /* ----- Task */ /*[clinic input] +@vectorcall _asyncio.Task.__init__ coro: object @@ -2300,7 +2309,7 @@ static int _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop, PyObject *name, PyObject *context, int eager_start) -/*[clinic end generated code: output=7aced2d27836f1a1 input=18e3f113a51b829d]*/ +/*[clinic end generated code: output=7aced2d27836f1a1 input=de87c52b0800ab4b]*/ { if (future_init((FutureObj*)self, loop)) { return -1; @@ -2325,14 +2334,18 @@ _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop, if (self->task_context == NULL) { return -1; } + } else if (!PyContext_CheckExact(context)) { + // gh-157301: the passed value must be a contextvars.Context + self->task_log_destroy_pending = 0; + PyErr_Format(PyExc_TypeError, + "a contextvars.Context was expected, got %T", + context); + return -1; } else { Py_XSETREF(self->task_context, Py_NewRef(context)); } Py_CLEAR(self->task_fut_waiter); -#ifdef Py_GIL_DISABLED - self->task_tid = _Py_ThreadId(); -#endif self->task_must_cancel = 0; self->task_log_destroy_pending = 1; self->task_num_cancels_requested = 0; @@ -2364,7 +2377,9 @@ _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop, _PyObject_SetMaybeWeakref((PyObject *)self); #endif if (eager_start) { - PyObject *res = PyObject_CallMethodNoArgs(loop, &_Py_ID(is_running)); + // gh-154695: loop may be None here, future_init() resolved it into task_loop. + PyObject *res = PyObject_CallMethodNoArgs(self->task_loop, + &_Py_ID(is_running)); if (res == NULL) { return -1; } @@ -2424,40 +2439,28 @@ TaskObj_traverse(PyObject *op, visitproc visit, void *arg) /*[clinic input] @critical_section @getter -_asyncio.Task._log_destroy_pending +_asyncio.Task._log_destroy_pending -> bool [clinic start generated code]*/ -static PyObject * +static int _asyncio_Task__log_destroy_pending_get_impl(TaskObj *self) -/*[clinic end generated code: output=e6c2a47d029ac93b input=17127298cd4c720b]*/ +/*[clinic end generated code: output=98b5f7bad24a2381 input=a87002bdf72e380b]*/ { - if (self->task_log_destroy_pending) { - Py_RETURN_TRUE; - } - else { - Py_RETURN_FALSE; - } + return self->task_log_destroy_pending; } /*[clinic input] @critical_section @setter _asyncio.Task._log_destroy_pending + value: bool [clinic start generated code]*/ static int -_asyncio_Task__log_destroy_pending_set_impl(TaskObj *self, PyObject *value) -/*[clinic end generated code: output=7ebc030bb92ec5ce input=49b759c97d1216a4]*/ +_asyncio_Task__log_destroy_pending_set_impl(TaskObj *self, int value) +/*[clinic end generated code: output=132bbf2b4c627777 input=533fea7776daa075]*/ { - if (value == NULL) { - PyErr_SetString(PyExc_AttributeError, "cannot delete attribute"); - return -1; - } - int is_true = PyObject_IsTrue(value); - if (is_true < 0) { - return -1; - } - self->task_log_destroy_pending = is_true; + self->task_log_destroy_pending = value; return 0; } @@ -2785,7 +2788,11 @@ static PyObject * _asyncio_Task_get_context_impl(TaskObj *self) /*[clinic end generated code: output=6996f53d3dc01aef input=87c0b209b8fceeeb]*/ { - return Py_NewRef(self->task_context); + if (self->task_context) { + return Py_NewRef(self->task_context); + } + + Py_RETURN_NONE; } /*[clinic input] @@ -2799,7 +2806,12 @@ _asyncio_Task_get_name_impl(TaskObj *self) { if (self->task_name) { if (PyLong_CheckExact(self->task_name)) { - PyObject *name = PyUnicode_FromFormat("Task-%S", self->task_name); + // Formatting can run arbitrary code (e.g. a GC finalizer that logs + // and re-enters get_name()), which may replace self->task_name. + // Hold a strong reference to the counter while formatting it. + PyObject *counter = Py_NewRef(self->task_name); + PyObject *name = PyUnicode_FromFormat("Task-%S", counter); + Py_DECREF(counter); if (name == NULL) { return NULL; } @@ -2943,6 +2955,7 @@ static PyType_Slot Task_slots[] = { {Py_tp_methods, TaskType_methods}, {Py_tp_getset, TaskType_getsetlist}, {Py_tp_init, _asyncio_Task___init__}, + {Py_tp_vectorcall, _asyncio_Task_vectorcall}, {Py_tp_new, PyType_GenericNew}, {Py_tp_finalize, TaskObj_finalize}, @@ -2966,13 +2979,17 @@ TaskObj_dealloc(PyObject *self) if (PyObject_CallFinalizerFromDealloc(self) < 0) { return; // resurrected } + // Untrack the object before unregistering the task, since the + // latter can cause a stop-the-world pause, after which another + // thread might call the GC and reach the object while it is + // semi-deallocated but still tracked + PyObject_GC_UnTrack(self); + // unregister the task after finalization so that // if the task gets resurrected, it remains registered unregister_task((TaskObj *)self); PyTypeObject *tp = Py_TYPE(self); - PyObject_GC_UnTrack(self); - PyObject_ClearWeakRefs(self); (void)TaskObj_clear(self); @@ -3058,8 +3075,13 @@ task_step_impl(asyncio_state *state, TaskObj *task, PyObject *exc) if (task->task_must_cancel) { assert(exc != Py_None); - if (!exc || !PyErr_GivenExceptionMatches(exc, state->asyncio_CancelledError)) { - /* exc was not a CancelledError */ + /* Replace exc with a CancelledError unless it already is one, or + it is SystemExit/KeyboardInterrupt, which must propagate + unchanged (gh-108549). */ + if (!exc || + (!PyErr_GivenExceptionMatches(exc, state->asyncio_CancelledError) && + !PyErr_GivenExceptionMatches(exc, PyExc_KeyboardInterrupt) && + !PyErr_GivenExceptionMatches(exc, PyExc_SystemExit))) { exc = create_cancelled_error(state, (FutureObj*)task); if (!exc) { @@ -3460,24 +3482,49 @@ task_eager_start(_PyThreadStateImpl *ts, asyncio_state *state, TaskObj *task) // it will continue as a regular (non-eager) asyncio task register_task(ts, task); + assert(PyContext_CheckExact(task->task_context)); if (_PyContext_Enter(&ts->base, task->task_context) == -1) { + // gh-157301: a failed enter must not leave the task current and registered + task->task_log_destroy_pending = 0; + PyObject *curtask = swap_current_task(ts, task->task_loop, prevtask); + Py_XDECREF(curtask); + unregister_task(task); Py_DECREF(prevtask); return -1; } int retval = 0; + // gh-157299: the eager step must record the awaited_by edge + int eager_edge = TaskOrFuture_Check(state, prevtask); PyObject *stepres; Py_BEGIN_CRITICAL_SECTION(task); - stepres = task_step_impl(state, task, NULL); - Py_END_CRITICAL_SECTION(); + if (eager_edge && + future_awaited_by_add(state, (FutureObj *)task, prevtask) < 0) + { + eager_edge = 0; + task->task_log_destroy_pending = 0; + unregister_task(task); + stepres = NULL; + } + else { + stepres = task_step_impl(state, task, NULL); + } + + PyObject *exc = stepres == NULL ? PyErr_GetRaisedException() : NULL; + if (eager_edge) { + int res = future_awaited_by_discard(state, (FutureObj *)task, prevtask); + if (res) { + retval = -1; + } + } if (stepres == NULL) { - PyObject *exc = PyErr_GetRaisedException(); _PyErr_ChainExceptions1(exc); retval = -1; } else { Py_DECREF(stepres); } + Py_END_CRITICAL_SECTION(); PyObject *curtask = swap_current_task(ts, task->task_loop, prevtask); Py_DECREF(prevtask); @@ -3963,7 +4010,6 @@ add_tasks_llist(struct llist_node *head, PyListObject *tasks) struct llist_node *node; llist_for_each_safe(node, head) { TaskObj *task = llist_data(node, TaskObj, task_node); - assert(task->task_state == STATE_PENDING); // The linked list holds borrowed references to task // as such it is possible that the task is concurrently // deallocated while added to this list. @@ -4172,6 +4218,23 @@ _asyncio_future_discard_from_awaited_by_impl(PyObject *module, PyObject *fut, Py_RETURN_NONE; } +/*[clinic input] +_asyncio._clear_caches + +Clear internal caches. Used for internal tests. +[clinic start generated code]*/ + +static PyObject * +_asyncio__clear_caches_impl(PyObject *module) +/*[clinic end generated code: output=9691a293f83d4303 input=6e1ae31e51dc906c]*/ +{ + asyncio_state *state = get_asyncio_state(module); + if (PySet_Clear(state->iscoroutine_typecache) < 0) { + return NULL; + } + Py_RETURN_NONE; +} + static int module_traverse(PyObject *mod, visitproc visit, void *arg) { @@ -4343,6 +4406,7 @@ static PyMethodDef asyncio_methods[] = { _ASYNCIO_ALL_TASKS_METHODDEF _ASYNCIO_FUTURE_ADD_TO_AWAITED_BY_METHODDEF _ASYNCIO_FUTURE_DISCARD_FROM_AWAITED_BY_METHODDEF + _ASYNCIO__CLEAR_CACHES_METHODDEF {NULL, NULL} }; diff --git a/Modules/_bz2module.c b/Modules/_bz2module.c index 9db3ac39da52099..e0d85b78741a91e 100644 --- a/Modules/_bz2module.c +++ b/Modules/_bz2module.c @@ -747,6 +747,61 @@ static PyType_Spec bz2_decompressor_type_spec = { .slots = bz2_decompressor_type_slots, }; + +PyDoc_STRVAR(bzlib_version_info__doc__, +"_bz2.bzlib_version_info\n\ +\n\ +Bzlib version information as a named tuple."); + +static PyStructSequence_Field bzlib_version_info_fields[] = { + {"major", "Major release number"}, + {"minor", "Minor release number"}, + {"patch", "Patch release number"}, + {0} +}; + +static PyStructSequence_Desc bzlib_version_info_desc = { + "_bz2.bzlib_version_info", /* name */ + bzlib_version_info__doc__, /* doc */ + bzlib_version_info_fields, /* fields */ + 3 +}; + +/* BZ2_bzlibVersion() returns a string with a trailing suffix, for example + "1.0.8, 13-Jul-2019" for bzip2 or "1.1.0-libbz2-rs-sys-0.2.5" for + libbz2-rs. sscanf() stops at the suffix; components which were not + parsed are left zero. This is deliberate -- a zero is more useful + here than a hard error. */ +static PyObject * +make_bzlib_version_info(PyTypeObject *type, const char *string) +{ + PyObject *version; + int pos = 0; + unsigned int major = 0, minor = 0, patch = 0; + + sscanf(string, "%u.%u.%u", &major, &minor, &patch); + + version = PyStructSequence_New(type); + if (version == NULL) { + return NULL; + } + +#define SetIntItem(VALUE) \ + PyStructSequence_SET_ITEM(version, pos++, PyLong_FromUnsignedLong(VALUE)); \ + if (PyErr_Occurred()) { \ + Py_DECREF(version); \ + return NULL; \ + } + + SetIntItem(major) + SetIntItem(minor) + SetIntItem(patch) +#undef SetIntItem + + return version; +} + + /* Module initialization. */ static int @@ -771,6 +826,24 @@ _bz2_exec(PyObject *module) return -1; } + /* bzlib_version */ + if (PyModule_Add(module, "bzlib_version", + PyUnicode_FromString(BZ2_bzlibVersion())) < 0) + { + return -1; + } + PyTypeObject *version_type; + version_type = PyStructSequence_NewType(&bzlib_version_info_desc); + if (version_type == NULL) { + return -1; + } + if (PyModule_Add(module, "bzlib_version_info", + make_bzlib_version_info(version_type, BZ2_bzlibVersion())) < 0) + { + Py_DECREF(version_type); + return -1; + } + Py_DECREF(version_type); return 0; } diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c index 7cba234fc80b591..dd0ace58cf42fdb 100644 --- a/Modules/_codecsmodule.c +++ b/Modules/_codecsmodule.c @@ -642,7 +642,7 @@ _codecs_code_page_decode_impl(PyObject *module, int codepage, #endif /* MS_WINDOWS */ -#ifdef HAVE_ICONV +#ifdef _Py_HAVE_ICONV /*[clinic input] _codecs.iconv_decode @@ -665,7 +665,7 @@ _codecs_iconv_decode_impl(PyObject *module, const char *encoding, return codec_tuple(decoded, consumed); } -#endif /* HAVE_ICONV */ +#endif /* _Py_HAVE_ICONV */ /* --- Encoder ------------------------------------------------------------ */ @@ -977,7 +977,7 @@ _codecs_code_page_encode_impl(PyObject *module, int code_page, PyObject *str, #endif /* MS_WINDOWS */ -#ifdef HAVE_ICONV +#ifdef _Py_HAVE_ICONV /*[clinic input] _codecs.iconv_encode @@ -996,7 +996,7 @@ _codecs_iconv_encode_impl(PyObject *module, const char *encoding, PyUnicode_GET_LENGTH(str)); } -#endif /* HAVE_ICONV */ +#endif /* _Py_HAVE_ICONV */ /* --- Error handler registry --------------------------------------------- */ diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 62d1dad5735ec8e..c63dc0661bd69e7 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1,6 +1,7 @@ #include "Python.h" #include "pycore_call.h" // _PyObject_CallNoArgs() -#include "pycore_dict.h" // _PyDict_GetItem_KnownHash() +#include "pycore_critical_section.h" // _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED() +#include "pycore_dict.h" // _PyDict_GetItemRef_KnownHash_LockHeld() #include "pycore_long.h" // _PyLong_GetZero() #include "pycore_moduleobject.h" // _PyModule_GetState() #include "pycore_pyatomic_ft_wrappers.h" @@ -648,7 +649,7 @@ deque_copy_impl(dequeobject *deque) result = PyObject_CallOneArg((PyObject *)(Py_TYPE(deque)), (PyObject *)deque); else - result = PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi", + result = PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "On", deque, old_deque->maxlen, NULL); if (result != NULL && !PyObject_TypeCheck(result, state->deque_type)) { PyErr_Format(PyExc_TypeError, @@ -674,8 +675,18 @@ deque___copy___impl(dequeobject *deque) return deque_copy_impl(deque); } +/*[clinic input] +@critical_section +_collections.deque.__add__ as deque_concat + + deque: dequeobject + other: object + / +[clinic start generated code]*/ + static PyObject * -deque_concat_lock_held(dequeobject *deque, PyObject *other) +deque_concat_impl(dequeobject *deque, PyObject *other) +/*[clinic end generated code: output=fa6c28f7752f0b28 input=1816c51a4c6c4f05]*/ { PyObject *new_deque, *result; int rv; @@ -706,17 +717,6 @@ deque_concat_lock_held(dequeobject *deque, PyObject *other) return new_deque; } -static PyObject * -deque_concat(PyObject *self, PyObject *other) -{ - dequeobject *deque = dequeobject_CAST(self); - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(deque); - result = deque_concat_lock_held(deque, other); - Py_END_CRITICAL_SECTION(); - return result; -} - static int deque_clear(PyObject *self) { @@ -819,8 +819,18 @@ deque_clearmethod_impl(dequeobject *deque) Py_RETURN_NONE; } +/*[clinic input] +@critical_section +_collections.deque.__imul__ as deque_inplace_repeat + + deque: dequeobject + n: Py_ssize_t + / +[clinic start generated code]*/ + static PyObject * -deque_inplace_repeat_lock_held(dequeobject *deque, Py_ssize_t n) +deque_inplace_repeat_impl(dequeobject *deque, Py_ssize_t n) +/*[clinic end generated code: output=e9052495a8eb46f9 input=0ebbaedad03b8abf]*/ { Py_ssize_t i, m, size; PyObject *seq; @@ -896,17 +906,6 @@ deque_inplace_repeat_lock_held(dequeobject *deque, Py_ssize_t n) return (PyObject *)deque; } -static PyObject * -deque_inplace_repeat(PyObject *self, Py_ssize_t n) -{ - dequeobject *deque = dequeobject_CAST(self); - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(deque); - result = deque_inplace_repeat_lock_held(deque, n); - Py_END_CRITICAL_SECTION(); - return result; -} - static PyObject * deque_repeat(PyObject *self, Py_ssize_t n) { @@ -921,7 +920,7 @@ deque_repeat(PyObject *self, Py_ssize_t n) return NULL; // It's safe to not acquire the per-object lock for new_deque; it's // invisible to other threads. - rv = deque_inplace_repeat_lock_held(new_deque, n); + rv = deque_inplace_repeat_impl(new_deque, n); Py_DECREF(new_deque); return rv; } @@ -1192,8 +1191,17 @@ deque_count_impl(dequeobject *deque, PyObject *v) return PyLong_FromSsize_t(count); } +/*[clinic input] +@critical_section +_collections.deque.__contains__ as deque_contains + deque: dequeobject + v: object + / +[clinic start generated code]*/ + static int -deque_contains_lock_held(dequeobject *deque, PyObject *v) +deque_contains_impl(dequeobject *deque, PyObject *v) +/*[clinic end generated code: output=5e7718757d3063bf input=8dd115a2cdaf0f23]*/ { block *b = deque->leftblock; Py_ssize_t index = deque->leftindex; @@ -1224,17 +1232,6 @@ deque_contains_lock_held(dequeobject *deque, PyObject *v) return 0; } -static int -deque_contains(PyObject *self, PyObject *v) -{ - dequeobject *deque = dequeobject_CAST(self); - int result; - Py_BEGIN_CRITICAL_SECTION(deque); - result = deque_contains_lock_held(deque, v); - Py_END_CRITICAL_SECTION(); - return result; -} - static Py_ssize_t deque_len(PyObject *self) { @@ -1380,8 +1377,17 @@ valid_index(Py_ssize_t i, Py_ssize_t limit) return (size_t) i < (size_t) limit; } +/*[clinic input] +@critical_section +_collections.deque.__getitem__ as deque_item + deque: dequeobject + i: Py_ssize_t + / +[clinic start generated code]*/ + static PyObject * -deque_item_lock_held(dequeobject *deque, Py_ssize_t i) +deque_item_impl(dequeobject *deque, Py_ssize_t i) +/*[clinic end generated code: output=52e62af1427d61ef input=89f14f06b29122a1]*/ { block *b; PyObject *item; @@ -1419,17 +1425,6 @@ deque_item_lock_held(dequeobject *deque, Py_ssize_t i) return Py_NewRef(item); } -static PyObject * -deque_item(PyObject *self, Py_ssize_t i) -{ - dequeobject *deque = dequeobject_CAST(self); - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(deque); - result = deque_item_lock_held(deque, i); - Py_END_CRITICAL_SECTION(); - return result; -} - static int deque_del_item(dequeobject *deque, Py_ssize_t i) { @@ -1499,8 +1494,19 @@ deque_remove_impl(dequeobject *deque, PyObject *value) Py_RETURN_NONE; } +/*[clinic input] +@critical_section +_collections.deque.__setitem__ as deque_ass_item + + deque: dequeobject + i: Py_ssize_t + v: object + / +[clinic start generated code]*/ + static int -deque_ass_item_lock_held(dequeobject *deque, Py_ssize_t i, PyObject *v) +deque_ass_item_impl(dequeobject *deque, Py_ssize_t i, PyObject *v) +/*[clinic end generated code: output=28739a830dc69ab1 input=b767e1a4972fa537]*/ { block *b; Py_ssize_t n, len=Py_SIZE(deque), halflen=(len+1)>>1, index=i; @@ -1531,17 +1537,6 @@ deque_ass_item_lock_held(dequeobject *deque, Py_ssize_t i, PyObject *v) return 0; } -static int -deque_ass_item(PyObject *self, Py_ssize_t i, PyObject *v) -{ - dequeobject *deque = dequeobject_CAST(self); - int result; - Py_BEGIN_CRITICAL_SECTION(deque); - result = deque_ass_item_lock_held(deque, i, v); - Py_END_CRITICAL_SECTION(); - return result; -} - static void deque_dealloc(PyObject *self) { @@ -2531,6 +2526,66 @@ static PyType_Spec defdict_spec = { /* helper function for Counter *********************************************/ +/* Fast path advantages: + 1. Eliminate double hashing + (by re-using the same hash for both the get and set) + 2. Avoid argument overhead of PyObject_CallFunctionObjArgs + (argument tuple creation and parsing) + 3. Avoid indirection through a bound method object + (creates another argument tuple) + 4. Avoid initial increment from zero + (reuse an existing one-object instead) +*/ +static int +_count_elements_dict_lock_held(PyDictObject *mapping, PyObject *it) +{ + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(mapping); + PyObject *one = _PyLong_GetOne(); // borrowed reference + + while (1) { + Py_hash_t hash; + PyObject *oldval; + int status; + + PyObject *key = PyIter_Next(it); + if (key == NULL) { + return PyErr_Occurred() ? -1 : 0; + } + + hash = _PyObject_HashDictKey(key); + if (hash == -1) { + Py_DECREF(key); + return -1; + } + + int found = _PyDict_GetItemRef_KnownHash_LockHeld(mapping, key, hash, + &oldval); + if (found < 0) { + Py_DECREF(key); + return -1; + } + if (found == 0) { + status = _PyDict_SetItem_KnownHash_LockHeld(mapping, key, one, + hash); + } + else { + PyObject *newval = PyNumber_Add(oldval, one); + Py_DECREF(oldval); + if (newval == NULL) { + Py_DECREF(key); + return -1; + } + status = _PyDict_SetItem_KnownHash_LockHeld(mapping, key, newval, + hash); + Py_DECREF(newval); + } + Py_DECREF(key); + if (status < 0) { + return -1; + } + } +} + /*[clinic input] _collections._count_elements @@ -2547,7 +2602,6 @@ _collections__count_elements_impl(PyObject *module, PyObject *mapping, /*[clinic end generated code: output=7e0c1789636b3d8f input=e79fad04534a0b45]*/ { PyObject *it, *oldval; - PyObject *newval = NULL; PyObject *key = NULL; PyObject *bound_get = NULL; PyObject *mapping_get; @@ -2572,48 +2626,12 @@ _collections__count_elements_impl(PyObject *module, PyObject *mapping, mapping_setitem != NULL && mapping_setitem == dict_setitem && PyDict_Check(mapping)) { - while (1) { - /* Fast path advantages: - 1. Eliminate double hashing - (by re-using the same hash for both the get and set) - 2. Avoid argument overhead of PyObject_CallFunctionObjArgs - (argument tuple creation and parsing) - 3. Avoid indirection through a bound method object - (creates another argument tuple) - 4. Avoid initial increment from zero - (reuse an existing one-object instead) - */ - Py_hash_t hash; - - key = PyIter_Next(it); - if (key == NULL) - break; - - hash = _PyObject_HashDictKey(key); - if (hash == -1) { - goto done; - } - - oldval = _PyDict_GetItem_KnownHash(mapping, key, hash); - if (oldval == NULL) { - if (PyErr_Occurred()) - goto done; - if (_PyDict_SetItem_KnownHash(mapping, key, one, hash) < 0) - goto done; - } else { - /* oldval is a borrowed reference. Keep it alive across - PyNumber_Add(), which can execute arbitrary user code and - mutate (or even clear) the underlying dict. */ - Py_INCREF(oldval); - newval = PyNumber_Add(oldval, one); - Py_DECREF(oldval); - if (newval == NULL) - goto done; - if (_PyDict_SetItem_KnownHash(mapping, key, newval, hash) < 0) - goto done; - Py_CLEAR(newval); - } - Py_DECREF(key); + int status; + Py_BEGIN_CRITICAL_SECTION(mapping); + status = _count_elements_dict_lock_held((PyDictObject *)mapping, it); + Py_END_CRITICAL_SECTION(); + if (status < 0) { + goto done; } } else { @@ -2629,6 +2647,7 @@ _collections__count_elements_impl(PyObject *module, PyObject *mapping, oldval = PyObject_CallFunctionObjArgs(bound_get, key, zero, NULL); if (oldval == NULL) break; + PyObject *newval; if (oldval == zero) { newval = Py_NewRef(one); } else { @@ -2637,9 +2656,10 @@ _collections__count_elements_impl(PyObject *module, PyObject *mapping, Py_DECREF(oldval); if (newval == NULL) break; - if (PyObject_SetItem(mapping, key, newval) < 0) + int status = PyObject_SetItem(mapping, key, newval); + Py_DECREF(newval); + if (status < 0) break; - Py_CLEAR(newval); Py_DECREF(key); } } @@ -2649,7 +2669,6 @@ _collections__count_elements_impl(PyObject *module, PyObject *mapping, Py_XDECREF(mapping_setitem); Py_DECREF(it); Py_XDECREF(key); - Py_XDECREF(newval); Py_XDECREF(bound_get); if (PyErr_Occurred()) return NULL; diff --git a/Modules/_csv.c b/Modules/_csv.c index a7fcc78e058f058..484f7bc0f9d2d49 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -21,10 +21,10 @@ module instead. /*[clinic input] module _csv +class _csv.Dialect "DialectObj *" "clinic_state()->dialect_type" +class _csv.Reader "ReaderObj *" "clinic_state()->reader_type" [clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=385118b71aa43706]*/ - -#include "clinic/_csv.c.h" +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=7bdf66dc7d68ed90]*/ #define NOT_SET ((Py_UCS4)-1) #define EOL ((Py_UCS4)-2) @@ -117,7 +117,12 @@ typedef struct { Py_UCS4 quotechar; /* quote character */ Py_UCS4 escapechar; /* escape character */ PyObject *lineterminator; /* string to write between records */ - + /* Cache for the writer: bit c is set if the ASCII character c needs + quoting or escaping (delimiter, quotechar, escapechar, '\r', '\n' + and the characters of lineterminator). */ + uint64_t special_chars[2]; + /* Whether any of the special characters is non-ASCII. */ + bool nonascii_special; } DialectObj; typedef struct { @@ -155,6 +160,8 @@ typedef struct { #define _ReaderObj_CAST(op) ((ReaderObj *)(op)) #define _WriterObj_CAST(op) ((WriterObj *)(op)) +#include "clinic/_csv.c.h" + /* * DIALECT class */ @@ -332,6 +339,54 @@ _set_str(const char *name, PyObject **target, PyObject *src, const char *dflt) return 0; } +static void +dialect_add_special_char(DialectObj *self, Py_UCS4 c) +{ + if (c == NOT_SET) { + return; + } + if (c < 128) { + self->special_chars[c / 64] |= (uint64_t)1 << (c % 64); + } + else { + self->nonascii_special = true; + } +} + +static void +dialect_init_special_chars_cache(DialectObj *self) +{ + self->special_chars[0] = self->special_chars[1] = 0; + self->nonascii_special = false; + dialect_add_special_char(self, self->delimiter); + dialect_add_special_char(self, self->quotechar); + dialect_add_special_char(self, self->escapechar); + dialect_add_special_char(self, '\r'); + dialect_add_special_char(self, '\n'); + PyObject *lt = self->lineterminator; + for (Py_ssize_t i = 0; i < PyUnicode_GET_LENGTH(lt); i++) { + dialect_add_special_char(self, PyUnicode_READ_CHAR(lt, i)); + } +} + +/* Whether the character needs quoting or escaping by the writer. */ +static inline bool +dialect_is_special_char(DialectObj *self, Py_UCS4 c) +{ + if (c < 128) { + return (self->special_chars[c / 64] >> (c % 64)) & 1; + } + if (!self->nonascii_special) { + return false; + } + return (c == self->delimiter || + c == self->quotechar || + c == self->escapechar || + PyUnicode_FindChar(self->lineterminator, c, 0, + PyUnicode_GET_LENGTH(self->lineterminator), + 1) >= 0); +} + static int dialect_check_quoting(int quoting) { @@ -558,6 +613,7 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { goto err; } + dialect_init_special_chars_cache(self); ret = Py_NewRef(self); err: @@ -577,18 +633,62 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) /* Since dialect is now a heap type, it inherits pickling method for * protocol 0 and 1 from object, therefore it needs to be overridden */ -PyDoc_STRVAR(dialect_reduce_doc, "raises an exception to avoid pickling"); +/*[clinic input] +_csv.Dialect.__reduce__ + +Raise an exception to avoid pickling. +[clinic start generated code]*/ static PyObject * -Dialect_reduce(PyObject *self, PyObject *args) { +_csv_Dialect___reduce___impl(DialectObj *self) +/*[clinic end generated code: output=f728b34af509ed69 input=e46419b46279e480]*/ +{ PyErr_Format(PyExc_TypeError, "cannot pickle '%.100s' instances", _PyType_Name(Py_TYPE(self))); return NULL; } +/*[clinic input] +_csv.Dialect.__reduce_ex__ + + protocol: object + / + +Raise an exception to avoid pickling. +[clinic start generated code]*/ + +static PyObject * +_csv_Dialect___reduce_ex___impl(DialectObj *self, PyObject *protocol) +/*[clinic end generated code: output=d45dec397da6575a input=c6ebd579e8959040]*/ +{ + return _csv_Dialect___reduce___impl(self); +} + +/*[clinic input] +_csv.Dialect.__replace__ + + **changes: dict + +Return a copy of the dialect with the specified options replaced. +[clinic start generated code]*/ + +static PyObject * +_csv_Dialect___replace___impl(DialectObj *self, PyObject *changes) +/*[clinic end generated code: output=8f692c2c63a61b50 input=154beb565fbabd4c]*/ +{ + PyObject *newargs = PyTuple_Pack(1, self); + if (newargs == NULL) { + return NULL; + } + PyObject *result = dialect_new(Py_TYPE(self), newargs, changes); + Py_DECREF(newargs); + return result; +} + static struct PyMethodDef dialect_methods[] = { - {"__reduce__", Dialect_reduce, METH_VARARGS, dialect_reduce_doc}, - {"__reduce_ex__", Dialect_reduce, METH_VARARGS, dialect_reduce_doc}, + _CSV_DIALECT___REDUCE___METHODDEF + _CSV_DIALECT___REDUCE_EX___METHODDEF + _CSV_DIALECT___REPLACE___METHODDEF {NULL, NULL} }; @@ -921,11 +1021,15 @@ parse_reset(ReaderObj *self) return 0; } +/*[clinic input] +@critical_section +_csv.Reader.__next__ as Reader_iternext +[clinic start generated code]*/ + static PyObject * -Reader_iternext_lock_held(PyObject *op) +Reader_iternext_impl(ReaderObj *self) +/*[clinic end generated code: output=3a02b0254a76e1fc input=97c70a4e2fe621e4]*/ { - ReaderObj *self = _ReaderObj_CAST(op); - PyObject *fields = NULL; Py_UCS4 c; Py_ssize_t pos, linelen; @@ -995,16 +1099,6 @@ Reader_iternext_lock_held(PyObject *op) return fields; } -static PyObject * -Reader_iternext(PyObject *op) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(op); - result = Reader_iternext_lock_held(op); - Py_END_CRITICAL_SECTION(); - return result; -} - static void Reader_dealloc(PyObject *op) { @@ -1083,10 +1177,31 @@ PyType_Spec Reader_Type_spec = { }; +/*[clinic input] +_csv.reader + + iterable: object + dialect: object(c_default='NULL') = 'excel' + / + **fmtparams: dict + +Return a reader object that will process lines from the given iterable. + +The "iterable" argument can be any object that returns a line +of input for each iteration, such as a file object or a list. The +optional "dialect" argument defines a CSV dialect. The function +also accepts optional keyword arguments which override settings +provided by the dialect. + +The returned object is an iterator. Each iteration returns a row +of the CSV file (which can span multiple input lines). +[clinic start generated code]*/ + static PyObject * -csv_reader(PyObject *module, PyObject *args, PyObject *keyword_args) +_csv_reader_impl(PyObject *module, PyObject *iterable, PyObject *dialect, + PyObject *fmtparams) +/*[clinic end generated code: output=c7033323f4e82fae input=330c6d58878e33b7]*/ { - PyObject * iterator, * dialect = NULL; _csvstate *module_state = get_csv_state(module); ReaderObj * self = PyObject_GC_New( ReaderObj, @@ -1107,17 +1222,13 @@ csv_reader(PyObject *module, PyObject *args, PyObject *keyword_args) return NULL; } - if (!PyArg_UnpackTuple(args, "reader", 1, 2, &iterator, &dialect)) { - Py_DECREF(self); - return NULL; - } - self->input_iter = PyObject_GetIter(iterator); + self->input_iter = PyObject_GetIter(iterable); if (self->input_iter == NULL) { Py_DECREF(self); return NULL; } self->dialect = (DialectObj *)_call_dialect(module_state, dialect, - keyword_args); + fmtparams); if (self->dialect == NULL) { Py_DECREF(self); return NULL; @@ -1183,14 +1294,7 @@ join_append_data(WriterObj *self, int field_kind, const void *field_data, Py_UCS4 c = PyUnicode_READ(field_kind, field_data, i); int want_escape = 0; - if (c == dialect->delimiter || - c == dialect->escapechar || - c == dialect->quotechar || - c == '\n' || - c == '\r' || - PyUnicode_FindChar( - dialect->lineterminator, c, 0, - PyUnicode_GET_LENGTH(dialect->lineterminator), 1) >= 0) { + if (dialect_is_special_char(dialect, c)) { if (dialect->quoting == QUOTE_NONE) want_escape = 1; else { @@ -1552,10 +1656,27 @@ PyType_Spec Writer_Type_spec = { }; +/*[clinic input] +_csv.writer + + fileobj as output_file: object + dialect: object(c_default='NULL') = 'excel' + / + **fmtparams: dict + +Return a writer object writing user data to the given file object. + +The "fileobj" argument can be any object that supports the file API. +The optional "dialect" argument defines a CSV dialect. The function +also accepts optional keyword arguments which override settings +provided by the dialect. +[clinic start generated code]*/ + static PyObject * -csv_writer(PyObject *module, PyObject *args, PyObject *keyword_args) +_csv_writer_impl(PyObject *module, PyObject *output_file, PyObject *dialect, + PyObject *fmtparams) +/*[clinic end generated code: output=3f57919e03cca475 input=18d396d2aa8138f0]*/ { - PyObject * output_file, * dialect = NULL; _csvstate *module_state = get_csv_state(module); WriterObj * self = PyObject_GC_New(WriterObj, module_state->writer_type); @@ -1572,10 +1693,6 @@ csv_writer(PyObject *module, PyObject *args, PyObject *keyword_args) self->error_obj = Py_NewRef(module_state->error_obj); - if (!PyArg_UnpackTuple(args, "writer", 1, 2, &output_file, &dialect)) { - Py_DECREF(self); - return NULL; - } if (PyObject_GetOptionalAttr(output_file, module_state->str_write, &self->write) < 0) { @@ -1589,7 +1706,7 @@ csv_writer(PyObject *module, PyObject *args, PyObject *keyword_args) return NULL; } self->dialect = (DialectObj *)_call_dialect(module_state, dialect, - keyword_args); + fmtparams); if (self->dialect == NULL) { Py_DECREF(self); return NULL; @@ -1615,21 +1732,36 @@ _csv_list_dialects_impl(PyObject *module) return PyDict_Keys(get_csv_state(module)->dialects); } +/*[clinic input] +_csv.register_dialect + + name as name_obj: object + dialect as dialect_obj: object(c_default='NULL') = 'excel' + / + **fmtparams: dict + +Create a mapping from a string name to a CVS dialect. + +The optional "dialect" argument specifies the base dialect instance +or the name of the registered dialect. The function also accepts +optional keyword arguments which override settings provided by the +dialect. +[clinic start generated code]*/ + static PyObject * -csv_register_dialect(PyObject *module, PyObject *args, PyObject *kwargs) +_csv_register_dialect_impl(PyObject *module, PyObject *name_obj, + PyObject *dialect_obj, PyObject *fmtparams) +/*[clinic end generated code: output=b00b54de5b950472 input=64e9180e18d88a97]*/ { - PyObject *name_obj, *dialect_obj = NULL; _csvstate *module_state = get_csv_state(module); PyObject *dialect; - if (!PyArg_UnpackTuple(args, "register_dialect", 1, 2, &name_obj, &dialect_obj)) - return NULL; if (!PyUnicode_Check(name_obj)) { PyErr_SetString(PyExc_TypeError, "dialect name must be a string"); return NULL; } - dialect = _call_dialect(module_state, dialect_obj, kwargs); + dialect = _call_dialect(module_state, dialect_obj, fmtparams); if (dialect == NULL) return NULL; if (PyDict_SetItem(module_state->dialects, name_obj, dialect) < 0) { @@ -1728,47 +1860,10 @@ PyType_Spec error_spec = { PyDoc_STRVAR(csv_module_doc, "CSV parsing and writing.\n"); -PyDoc_STRVAR(csv_reader_doc, -"reader($module, iterable, /, dialect='excel', **fmtparams)\n" -"--\n\n" -"Return a reader object that will process lines from the given iterable.\n" -"\n" -"The \"iterable\" argument can be any object that returns a line\n" -"of input for each iteration, such as a file object or a list. The\n" -"optional \"dialect\" argument defines a CSV dialect. The function\n" -"also accepts optional keyword arguments which override settings\n" -"provided by the dialect.\n" -"\n" -"The returned object is an iterator. Each iteration returns a row\n" -"of the CSV file (which can span multiple input lines).\n"); - -PyDoc_STRVAR(csv_writer_doc, -"writer($module, fileobj, /, dialect='excel', **fmtparams)\n" -"--\n\n" -"Return a writer object that will write user data on the given file object.\n" -"\n" -"The \"fileobj\" argument can be any object that supports the file API.\n" -"The optional \"dialect\" argument defines a CSV dialect. The function\n" -"also accepts optional keyword arguments which override settings\n" -"provided by the dialect.\n"); - -PyDoc_STRVAR(csv_register_dialect_doc, -"register_dialect($module, name, /, dialect='excel', **fmtparams)\n" -"--\n\n" -"Create a mapping from a string name to a CVS dialect.\n" -"\n" -"The optional \"dialect\" argument specifies the base dialect instance\n" -"or the name of the registered dialect. The function also accepts\n" -"optional keyword arguments which override settings provided by the\n" -"dialect.\n"); - static struct PyMethodDef csv_methods[] = { - { "reader", _PyCFunction_CAST(csv_reader), - METH_VARARGS | METH_KEYWORDS, csv_reader_doc}, - { "writer", _PyCFunction_CAST(csv_writer), - METH_VARARGS | METH_KEYWORDS, csv_writer_doc}, - { "register_dialect", _PyCFunction_CAST(csv_register_dialect), - METH_VARARGS | METH_KEYWORDS, csv_register_dialect_doc}, + _CSV_READER_METHODDEF + _CSV_WRITER_METHODDEF + _CSV_REGISTER_DIALECT_METHODDEF _CSV_LIST_DIALECTS_METHODDEF _CSV_UNREGISTER_DIALECT_METHODDEF _CSV_GET_DIALECT_METHODDEF diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index adfdf44e53604e3..301c28d2eb21154 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -186,7 +186,23 @@ _DictRemover_call(PyObject *myself, PyObject *args, PyObject *kw) { DictRemoverObject *self = _DictRemoverObject_CAST(myself); if (self->key && self->dict) { - if (-1 == PyDict_DelItem(self->dict, self->key)) { + /* Only remove the entry if it is still the proxy that died: the + key may have been reused for a new object in the meantime. */ + PyObject *proxy = PyTuple_GET_SIZE(args) == 1 + ? PyTuple_GET_ITEM(args, 0) : NULL; + PyObject *current; + int rc; + Py_BEGIN_CRITICAL_SECTION(self->dict); + rc = PyDict_GetItemRef(self->dict, self->key, ¤t); + if (rc == 1) { + rc = 0; + if (current == proxy) { + rc = PyDict_DelItem(self->dict, self->key); + } + Py_DECREF(current); + } + Py_END_CRITICAL_SECTION(); + if (rc < 0) { PyErr_FormatUnraisable("Exception ignored while " "calling _ctypes.DictRemover"); } @@ -215,32 +231,72 @@ static PyType_Spec dictremover_spec = { .slots = dictremover_slots, }; -int -PyDict_SetItemProxy(ctypes_state *st, PyObject *dict, PyObject *key, PyObject *item) +/* Cache `item` in `dict` under `key` through a weakref proxy, unless a live + entry already exists. On success *presult is a new reference to whatever + is cached for `key` afterwards: `item` itself, or the object another + thread cached first. + Returns 0 on success, -1 with an exception set on failure. */ +static int +_PyDict_SetDefaultItemProxy(ctypes_state *st, PyObject *dict, PyObject *key, + PyObject *item, PyObject **presult) { - PyObject *obj; - DictRemoverObject *remover; - PyObject *proxy; - int result; - - obj = _PyObject_CallNoArgs((PyObject *)st->DictRemover_Type); - if (obj == NULL) + PyObject *obj = _PyObject_CallNoArgs((PyObject *)st->DictRemover_Type); + if (obj == NULL) { return -1; + } - remover = (DictRemoverObject *)obj; + DictRemoverObject *remover = (DictRemoverObject *)obj; assert(remover->key == NULL); assert(remover->dict == NULL); remover->key = Py_NewRef(key); remover->dict = Py_NewRef(dict); - proxy = PyWeakref_NewProxy(item, obj); + PyObject *proxy = PyWeakref_NewProxy(item, obj); Py_DECREF(obj); - if (proxy == NULL) + if (proxy == NULL) { + return -1; + } + + PyObject *stored; + int present = PyDict_SetDefaultRef(dict, key, proxy, &stored); + if (present < 0) { + Py_DECREF(proxy); return -1; + } + if (present == 0) { + /* Our proxy was inserted; `item` is the canonical object. */ + Py_DECREF(stored); + Py_DECREF(proxy); + *presult = Py_NewRef(item); + return 0; + } - result = PyDict_SetItem(dict, key, proxy); + /* Another thread cached an object for this key first. Prefer it, so that + every caller gets the same object. */ + PyObject *existing = NULL; + int rc = 0; + if (PyWeakref_CheckProxy(stored)) { + rc = PyWeakref_GetRef(stored, &existing); + } + Py_DECREF(stored); + if (rc < 0) { + Py_DECREF(proxy); + return -1; + } + if (existing != NULL) { + Py_DECREF(proxy); + *presult = existing; + return 0; + } + + /* The cached entry had already been cleared; install ours instead. */ + rc = PyDict_SetItem(dict, key, proxy); Py_DECREF(proxy); - return result; + if (rc < 0) { + return -1; + } + *presult = Py_NewRef(item); + return 0; } static int @@ -598,13 +654,13 @@ _ctypes_CType_Type___pointer_type___get_impl(PyObject *self) /*[clinic input] @setter +@deleter _ctypes.CType_Type.__pointer_type__ - [clinic start generated code]*/ static int _ctypes_CType_Type___pointer_type___set_impl(PyObject *self, PyObject *value) -/*[clinic end generated code: output=6259be8ea21693fa input=a05055fc7f4714b6]*/ +/*[clinic end generated code: output=6259be8ea21693fa input=07e8b7a8fcc1efc1]*/ { ctypes_state *st = get_module_state_by_def(Py_TYPE(self)); StgInfo *info; @@ -1436,6 +1492,21 @@ PyCPointerType_from_param_impl(PyObject *type, PyTypeObject *cls, return Py_NewRef(value); } } + + PyObject *as_parameter; + if (PyObject_GetOptionalAttr(value, &_Py_ID(_as_parameter_), &as_parameter) < 0) { + return NULL; + } + if (as_parameter) { + if (_Py_EnterRecursiveCall(" while processing _as_parameter_")) { + Py_DECREF(as_parameter); + return NULL; + } + value = PyCPointerType_from_param_impl(type, cls, as_parameter); + Py_DECREF(as_parameter); + _Py_LeaveRecursiveCall(); + return value; + } return CDataType_from_param_impl(type, cls, value); } @@ -1481,37 +1552,20 @@ class _ctypes.PyCArrayType_Type "CDataObject *" "clinic_state()->PyCArrayType_Ty @critical_section @setter _ctypes.PyCArrayType_Type.raw + value: Py_buffer [clinic start generated code]*/ static int -_ctypes_PyCArrayType_Type_raw_set_impl(CDataObject *self, PyObject *value) -/*[clinic end generated code: output=cf9b2a9fd92e9ecb input=a3717561efc45efd]*/ +_ctypes_PyCArrayType_Type_raw_set_impl(CDataObject *self, Py_buffer *value) +/*[clinic end generated code: output=273e537dc31f4bbd input=90775c9408b1bb59]*/ { - char *ptr; - Py_ssize_t size; - Py_buffer view; - - if (value == NULL) { - PyErr_SetString(PyExc_AttributeError, "cannot delete attribute"); - return -1; - } - if (PyObject_GetBuffer(value, &view, PyBUF_SIMPLE) < 0) - return -1; - size = view.len; - ptr = view.buf; - if (size > self->b_size) { + if (value->len > self->b_size) { PyErr_SetString(PyExc_ValueError, "byte string too long"); - goto fail; + return -1; } - - memcpy(self->b_ptr, ptr, size); - - PyBuffer_Release(&view); + memcpy(self->b_ptr, value->buf, value->len); return 0; - fail: - PyBuffer_Release(&view); - return -1; } /*[clinic input] @@ -1551,42 +1605,24 @@ _ctypes_PyCArrayType_Type_value_get_impl(CDataObject *self) @critical_section @setter _ctypes.PyCArrayType_Type.value + value: object(subclass_of='&PyBytes_Type', type='PyBytesObject *') [clinic start generated code]*/ static int -_ctypes_PyCArrayType_Type_value_set_impl(CDataObject *self, PyObject *value) -/*[clinic end generated code: output=39ad655636a28dd5 input=e2e6385fc6ab1a29]*/ +_ctypes_PyCArrayType_Type_value_set_impl(CDataObject *self, + PyBytesObject *value) +/*[clinic end generated code: output=21cbd436230dc33e input=47d40501c4ecae23]*/ { - const char *ptr; - Py_ssize_t size; - - if (value == NULL) { - PyErr_SetString(PyExc_TypeError, - "can't delete attribute"); - return -1; - } - - if (!PyBytes_Check(value)) { - PyErr_Format(PyExc_TypeError, - "bytes expected instead of %s instance", - Py_TYPE(value)->tp_name); - return -1; - } else - Py_INCREF(value); - size = PyBytes_GET_SIZE(value); + Py_ssize_t size = PyBytes_GET_SIZE(value); if (size > self->b_size) { PyErr_SetString(PyExc_ValueError, "byte string too long"); - Py_DECREF(value); return -1; } - ptr = PyBytes_AS_STRING(value); - memcpy(self->b_ptr, ptr, size); + memcpy(self->b_ptr, PyBytes_AS_STRING(value), size); if (size < self->b_size) self->b_ptr[size] = '\0'; - Py_DECREF(value); - return 0; } @@ -2337,7 +2373,7 @@ PyCSimpleType_paramfunc(ctypes_state *st, CDataObject *self) parg->tag = fd->code; parg->pffi_type = fd->pffi_type; parg->obj = Py_NewRef(self); - memcpy(&parg->value, self->b_ptr, self->b_size); + memcpy(&parg->value, self->b_ptr, info->size); return parg; } @@ -2499,22 +2535,30 @@ PyCSimpleType_init(PyObject *self, PyObject *args, PyObject *kwds) } assert(sw_info); #ifdef WORDS_BIGENDIAN - PyObject_SetAttrString(self, "__ctype_le__", swapped); - PyObject_SetAttrString(self, "__ctype_be__", self); - PyObject_SetAttrString(swapped, "__ctype_be__", self); - PyObject_SetAttrString(swapped, "__ctype_le__", swapped); + if (PyObject_SetAttrString(self, "__ctype_le__", swapped) < 0 || + PyObject_SetAttrString(self, "__ctype_be__", self) < 0 || + PyObject_SetAttrString(swapped, "__ctype_be__", self) < 0 || + PyObject_SetAttrString(swapped, "__ctype_le__", swapped) < 0) + { + Py_DECREF(swapped); + return -1; + } /* We are creating the type for the OTHER endian */ sw_info->format = _ctypes_alloc_format_string("<", stginfo->format+1); #else - PyObject_SetAttrString(self, "__ctype_be__", swapped); - PyObject_SetAttrString(self, "__ctype_le__", self); - PyObject_SetAttrString(swapped, "__ctype_le__", self); - PyObject_SetAttrString(swapped, "__ctype_be__", swapped); + if (PyObject_SetAttrString(self, "__ctype_be__", swapped) < 0 || + PyObject_SetAttrString(self, "__ctype_le__", self) < 0 || + PyObject_SetAttrString(swapped, "__ctype_le__", self) < 0 || + PyObject_SetAttrString(swapped, "__ctype_be__", swapped) < 0) + { + Py_DECREF(swapped); + return -1; + } /* We are creating the type for the OTHER endian */ sw_info->format = _ctypes_alloc_format_string(">", stginfo->format+1); #endif Py_DECREF(swapped); - if (PyErr_Occurred()) { + if (sw_info->format == NULL) { return -1; } }; @@ -2900,28 +2944,33 @@ static PyType_Spec pycfuncptr_type_spec = { * Code to keep needed objects alive */ +static CDataObject * +PyCData_GetContainer_lock_held(CDataObject *root) +{ + assert(root->b_base == NULL); + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(root); + if (root->b_objects == NULL) { + if (root->b_length) { + root->b_objects = PyDict_New(); + if (root->b_objects == NULL) { + return NULL; + } + } else { + root->b_objects = Py_NewRef(Py_None); + } + } + return root; +} + static CDataObject * PyCData_GetContainer(CDataObject *self) { while (self->b_base) { self = self->b_base; } - CDataObject *res = self; + CDataObject *res; Py_BEGIN_CRITICAL_SECTION(self); - // avoid using return directly in this block because critical section - // needs to be released before returning - if (self->b_objects == NULL) { - if (self->b_length) { - self->b_objects = PyDict_New(); - if (self->b_objects == NULL) { - res = NULL; - goto exit; - } - } else { - self->b_objects = Py_NewRef(Py_None); - } - } -exit:; + res = PyCData_GetContainer_lock_held(self); Py_END_CRITICAL_SECTION(); return res; } @@ -2936,6 +2985,22 @@ GetKeepedObjects(CDataObject *target) return container->b_objects; } +/* Like GetKeepedObjects(), for a caller that already holds target's lock. */ +static PyObject * +GetKeepedObjects_lock_held(CDataObject *target) +{ + CDataObject *container; + if (target->b_base == NULL) { + container = PyCData_GetContainer_lock_held(target); + } + else { + container = PyCData_GetContainer(target); + } + if (container == NULL) + return NULL; + return container->b_objects; +} + static PyObject * unique_key(CDataObject *target, Py_ssize_t index) { @@ -2972,7 +3037,15 @@ KeepRef_lock_held(CDataObject *target, Py_ssize_t index, PyObject *keep) Py_DECREF(Py_None); return 0; } - ob = PyCData_GetContainer(target); + if (target->b_base == NULL) { + // target is its own root and the caller already holds its lock: + // re-entering the critical section would be a nested same-object + // lock (failed CAS + slow path) on every field assignment. + ob = PyCData_GetContainer_lock_held(target); + } + else { + ob = PyCData_GetContainer(target); + } if (ob == NULL) { Py_DECREF(keep); return -1; @@ -3140,16 +3213,6 @@ PyCData_NewGetBuffer(PyObject *myself, Py_buffer *view, int flags) return 0; } -/* - * CData objects are mutable, so they cannot be hashable! - */ -static Py_hash_t -PyCData_nohash(PyObject *self) -{ - PyErr_SetString(PyExc_TypeError, "unhashable type"); - return -1; -} - /*[clinic input] @critical_section _ctypes.PyCData.__reduce__ @@ -3246,25 +3309,42 @@ static PyMethodDef PyCData_methods[] = { { NULL, NULL }, }; -static PyType_Slot pycdata_slots[] = { - {Py_tp_dealloc, PyCData_dealloc}, - {Py_tp_hash, PyCData_nohash}, - {Py_tp_doc, PyDoc_STR("XXX to be provided")}, - {Py_tp_traverse, PyCData_traverse}, - {Py_tp_clear, PyCData_clear}, - {Py_tp_methods, PyCData_methods}, - {Py_tp_members, PyCData_members}, - {Py_bf_getbuffer, PyCData_NewGetBuffer}, - {0, NULL}, -}; - -static PyType_Spec pycdata_spec = { - .name = "_ctypes._CData", - .basicsize = sizeof(CDataObject), - .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION), - .slots = pycdata_slots, -}; +/* + * CData objects are mutable, so they cannot be hashable. Setting tp_hash to + * PyObject_HashNotImplemented() makes type_ready() set __hash__ to None. + * + * Unfortunately, on Windows, PyObject_HashNotImplemented is imported from + * the Python DLL. MSVC resolves imported functions in static initializers to + * local thunks, and Clang does the same even for local aggregate initializers. + * Assign the hash slot explicitly at runtime to load the real address from + * the import table. + */ +static PyObject * +PyCData_create_type(PyObject *mod) +{ + PyType_Slot slots[] = { + {Py_tp_dealloc, PyCData_dealloc}, + {Py_tp_hash, NULL}, + {Py_tp_doc, PyDoc_STR("The common base class of all ctypes " + "data types.")}, + {Py_tp_traverse, PyCData_traverse}, + {Py_tp_clear, PyCData_clear}, + {Py_tp_methods, PyCData_methods}, + {Py_tp_members, PyCData_members}, + {Py_bf_getbuffer, PyCData_NewGetBuffer}, + {0, NULL}, + }; + slots[1].pfunc = PyObject_HashNotImplemented; + PyType_Spec spec = { + .name = "_ctypes._CData", + .basicsize = sizeof(CDataObject), + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE | + Py_TPFLAGS_DISALLOW_INSTANTIATION), + .slots = slots, + }; + return PyType_FromMetaclass(NULL, mod, &spec, NULL); +} static int PyCData_MallocBuffer(CDataObject *obj, StgInfo *info) @@ -3569,7 +3649,7 @@ PyCData_set(ctypes_state *st, /* KeepRef steals a refcount from it's last argument */ /* If KeepRef fails, we are stumped. The dst memory block has already been changed */ - return KeepRef(mem, index, result); + return KeepRef_lock_held(mem, index, result); } @@ -3664,12 +3744,13 @@ _validate_paramflags(ctypes_state *st, PyTypeObject *type, PyObject *paramflags, /*[clinic input] @critical_section @setter +@deleter _ctypes.CFuncPtr.errcheck [clinic start generated code]*/ static int _ctypes_CFuncPtr_errcheck_set_impl(PyCFuncPtrObject *self, PyObject *value) -/*[clinic end generated code: output=6580cf1ffdf3b9fb input=84930bb16c490b33]*/ +/*[clinic end generated code: output=6580cf1ffdf3b9fb input=bcd5d3ed1a0c36e9]*/ { if (value && !PyCallable_Check(value)) { PyErr_SetString(PyExc_TypeError, @@ -3701,13 +3782,14 @@ _ctypes_CFuncPtr_errcheck_get_impl(PyCFuncPtrObject *self) /*[clinic input] @setter +@deleter @critical_section _ctypes.CFuncPtr.restype [clinic start generated code]*/ static int _ctypes_CFuncPtr_restype_set_impl(PyCFuncPtrObject *self, PyObject *value) -/*[clinic end generated code: output=0be0a086abbabf18 input=683c3bef4562ccc6]*/ +/*[clinic end generated code: output=0be0a086abbabf18 input=ffc941a26dbb31f3]*/ { PyObject *checker; if (value == NULL) { @@ -3764,13 +3846,14 @@ _ctypes_CFuncPtr_restype_get_impl(PyCFuncPtrObject *self) /*[clinic input] @setter +@deleter @critical_section _ctypes.CFuncPtr.argtypes [clinic start generated code]*/ static int _ctypes_CFuncPtr_argtypes_set_impl(PyCFuncPtrObject *self, PyObject *value) -/*[clinic end generated code: output=596a36e2ae89d7d1 input=c4627573e980aa8b]*/ +/*[clinic end generated code: output=596a36e2ae89d7d1 input=fd012f1fd7cc35be]*/ { if (value == NULL || value == Py_None) { atomic_xsetref(&self->argtypes, NULL); @@ -4993,6 +5076,12 @@ static PyType_Spec pycunion_spec = { /* PyCArray_Type */ + +/*[clinic input] +class _ctypes.Array "PyObject *" "clinic_state()->PyCArray_Type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b2d780e2e2dc6e8a]*/ + static int Array_init(PyObject *self, PyObject *args, PyObject *kw) { @@ -5005,6 +5094,22 @@ Array_init(PyObject *self, PyObject *args, PyObject *kw) return -1; } n = PyTuple_GET_SIZE(args); + + /* Optimization: If the type doesn't override __setitem__, we can store the + * items directly (see gh-72113). */ + PyMappingMethods *mp = Py_TYPE(self)->tp_as_mapping; + if (mp != NULL && mp->mp_ass_subscript == Array_ass_subscript) { + int result = 0; + Py_BEGIN_CRITICAL_SECTION(self); + for (i = 0; result >= 0 && i < n; ++i) { + PyObject *v = PyTuple_GET_ITEM(args, i); + assert(v != NULL); + result = Array_ass_item_impl(self, i, v); + } + Py_END_CRITICAL_SECTION(); + return result; + } + for (i = 0; i < n; ++i) { PyObject *v; v = PyTuple_GET_ITEM(args, i); @@ -5014,8 +5119,17 @@ Array_init(PyObject *self, PyObject *args, PyObject *kw) return 0; } +/*[clinic input] +@critical_section +_ctypes.Array.__getitem__ as Array_item + myself: self + index: Py_ssize_t + / +[clinic start generated code]*/ + static PyObject * -Array_item_lock_held(PyObject *myself, Py_ssize_t index) +Array_item_impl(PyObject *myself, Py_ssize_t index) +/*[clinic end generated code: output=d038162d727d7d9b input=68fa9889c77bb8c9]*/ { _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(myself); @@ -5044,18 +5158,17 @@ Array_item_lock_held(PyObject *myself, Py_ssize_t index) index, size, self->b_ptr + offset); } -static PyObject * -Array_item(PyObject *myself, Py_ssize_t index) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(myself); - result = Array_item_lock_held(myself, index); - Py_END_CRITICAL_SECTION(); - return result; -} +/*[clinic input] +@critical_section +_ctypes.Array.__getitem__ as Array_subscript + myself: self + item: object + / +[clinic start generated code]*/ static PyObject * -Array_subscript_lock_held(PyObject *myself, PyObject *item) +Array_subscript_impl(PyObject *myself, PyObject *item) +/*[clinic end generated code: output=5c88d612ad5c8a1a input=510935495a857cac]*/ { _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(myself); @@ -5068,7 +5181,7 @@ Array_subscript_lock_held(PyObject *myself, PyObject *item) return NULL; if (i < 0) i += self->b_length; - return Array_item_lock_held(myself, i); + return Array_item_impl(myself, i); } else if (PySlice_Check(item)) { PyObject *proto; @@ -5097,7 +5210,6 @@ Array_subscript_lock_held(PyObject *myself, PyObject *item) if (iteminfo->getfunc == _ctypes_get_fielddesc("c")->getfunc) { char *ptr = (char *)self->b_ptr; - char *dest; if (slicelen <= 0) return Py_GetConstant(Py_CONSTANT_EMPTY_BYTES); @@ -5107,19 +5219,17 @@ Array_subscript_lock_held(PyObject *myself, PyObject *item) slicelen); return res; } - dest = (char *)PyMem_Malloc(slicelen); - - if (dest == NULL) - return PyErr_NoMemory(); - + PyBytesWriter *writer = PyBytesWriter_Create(slicelen); + if (writer == NULL) { + return NULL; + } + char *dest = PyBytesWriter_GetData(writer); for (cur = start, i = 0; i < slicelen; cur += step, i++) { dest[i] = ptr[cur]; } - np = PyBytes_FromStringAndSize(dest, slicelen); - PyMem_Free(dest); - return np; + return PyBytesWriter_Finish(writer); } if (iteminfo->getfunc == _ctypes_get_fielddesc("u")->getfunc) { wchar_t *ptr = (wchar_t *)self->b_ptr; @@ -5156,7 +5266,7 @@ Array_subscript_lock_held(PyObject *myself, PyObject *item) for (cur = start, i = 0; i < slicelen; cur += step, i++) { - PyObject *v = Array_item_lock_held(myself, cur); + PyObject *v = Array_item_impl(myself, cur); if (v == NULL) { Py_DECREF(np); return NULL; @@ -5173,18 +5283,19 @@ Array_subscript_lock_held(PyObject *myself, PyObject *item) } -static PyObject * -Array_subscript(PyObject *myself, PyObject *item) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(myself); - result = Array_subscript_lock_held(myself, item); - Py_END_CRITICAL_SECTION(); - return result; -} +/*[clinic input] +@critical_section +_ctypes.Array.__setitem__ as Array_ass_item + + myself: self + index: Py_ssize_t + value: object + / +[clinic start generated code]*/ static int -Array_ass_item_lock_held(PyObject *myself, Py_ssize_t index, PyObject *value) +Array_ass_item_impl(PyObject *myself, Py_ssize_t index, PyObject *value) +/*[clinic end generated code: output=8fb1fd51b5b45da8 input=8b6ddb53d6377b96]*/ { _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(myself); @@ -5218,19 +5329,19 @@ Array_ass_item_lock_held(PyObject *myself, Py_ssize_t index, PyObject *value) index, size, ptr); } -static int -Array_ass_item(PyObject *myself, Py_ssize_t index, PyObject *value) -{ - int result; - Py_BEGIN_CRITICAL_SECTION(myself); - result = Array_ass_item_lock_held(myself, index, value); - Py_END_CRITICAL_SECTION(); - return result; -} +/*[clinic input] +@critical_section +_ctypes.Array.__setitem__ as Array_ass_subscript + myself: self + item: object + value: object + / +[clinic start generated code]*/ static int -Array_ass_subscript_lock_held(PyObject *myself, PyObject *item, PyObject *value) +Array_ass_subscript_impl(PyObject *myself, PyObject *item, PyObject *value) +/*[clinic end generated code: output=cb9a138e4e40c5ac input=4b7aedebbb357853]*/ { CDataObject *self = _CDataObject_CAST(myself); @@ -5247,7 +5358,7 @@ Array_ass_subscript_lock_held(PyObject *myself, PyObject *item, PyObject *value) return -1; if (i < 0) i += self->b_length; - return Array_ass_item_lock_held(myself, i, value); + return Array_ass_item_impl(myself, i, value); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelen, otherlen, i; @@ -5262,6 +5373,9 @@ Array_ass_subscript_lock_held(PyObject *myself, PyObject *item, PyObject *value) stop = start; otherlen = PySequence_Length(value); + if (otherlen < 0) { + return -1; + } if (otherlen != slicelen) { PyErr_SetString(PyExc_ValueError, "Can only assign sequence of same size"); @@ -5272,7 +5386,7 @@ Array_ass_subscript_lock_held(PyObject *myself, PyObject *item, PyObject *value) int result; if (item == NULL) return -1; - result = Array_ass_item_lock_held(myself, cur, item); + result = Array_ass_item_impl(myself, cur, item); Py_DECREF(item); if (result == -1) return -1; @@ -5286,17 +5400,6 @@ Array_ass_subscript_lock_held(PyObject *myself, PyObject *item, PyObject *value) } } -static int -Array_ass_subscript(PyObject *myself, PyObject *item, PyObject *value) -{ - int result; - Py_BEGIN_CRITICAL_SECTION(myself); - result = Array_ass_subscript_lock_held(myself, item, value); - Py_END_CRITICAL_SECTION(); - return result; -} - - static Py_ssize_t Array_length(PyObject *myself) { @@ -5390,13 +5493,20 @@ PyCArrayType_from_ctype(ctypes_state *st, PyObject *itemtype, Py_ssize_t length) Py_DECREF(key); return NULL; } - if (PyDict_SetItemProxy(st, st->array_cache, key, result) < 0) { + PyObject *cached; + int rc; + Py_BEGIN_CRITICAL_SECTION(st->array_cache); + rc = _PyDict_SetDefaultItemProxy(st, st->array_cache, key, result, + &cached); + Py_END_CRITICAL_SECTION(); + if (rc < 0) { Py_DECREF(key); Py_DECREF(result); return NULL; } Py_DECREF(key); - return result; + Py_DECREF(result); + return cached; } @@ -5422,12 +5532,6 @@ _ctypes_Simple_value_set_impl(CDataObject *self, PyObject *value) { PyObject *result; - if (value == NULL) { - PyErr_SetString(PyExc_TypeError, - "can't delete attribute"); - return -1; - } - ctypes_state *st = get_module_state_by_def(Py_TYPE(Py_TYPE(self))); StgInfo *info; if (PyStgInfo_FromObject(st, (PyObject *)self, &info) < 0) { @@ -5440,8 +5544,9 @@ _ctypes_Simple_value_set_impl(CDataObject *self, PyObject *value) if (!result) return -1; - /* consumes the refcount the setfunc returns */ - return KeepRef(self, 0, result); + /* consumes the refcount the setfunc returns; self is already locked + by the critical section taken by the Argument Clinic wrapper */ + return KeepRef_lock_held(self, 0, result); } @@ -5475,7 +5580,7 @@ _ctypes_Simple_value_get_impl(CDataObject *self) assert(info); /* Cannot be NULL for CDataObject instances */ assert(info->getfunc); PyObject *res; - res = info->getfunc(self->b_ptr, self->b_size); + res = info->getfunc(self->b_ptr, info->size); return res; } @@ -5509,15 +5614,29 @@ static PyMethodDef Simple_methods[] = { { NULL, NULL }, }; +/*[clinic input] +@critical_section +_ctypes.Simple.__bool__ as Simple_bool +[clinic start generated code]*/ + static int -Simple_bool(PyObject *op) +Simple_bool_impl(CDataObject *self) +/*[clinic end generated code: output=c4466ece6a99fe8b input=326a1c8b24d8918e]*/ { - int cmp; - CDataObject *self = _CDataObject_CAST(op); - Py_BEGIN_CRITICAL_SECTION(self); - cmp = memcmp(self->b_ptr, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", self->b_size); - Py_END_CRITICAL_SECTION(); - return cmp; + ctypes_state *st = get_module_state_by_def(Py_TYPE(Py_TYPE(self))); + StgInfo *info; + if (PyStgInfo_FromObject(st, (PyObject *)self, &info) < 0) { + return -1; + } + assert(info != NULL); + + assert(info->size <= self->b_size); + for (Py_ssize_t i = 0; i < info->size; i++) { + if (self->b_ptr[i]) { + return 1; + } + } + return 0; } /* "%s(%s)" % (self.__class__.__name__, self.value) */ @@ -5544,7 +5663,12 @@ Simple_repr(PyObject *self) static PyType_Slot pycsimple_slots[] = { {Py_tp_repr, &Simple_repr}, - {Py_tp_doc, PyDoc_STR("XXX to be provided")}, + {Py_tp_doc, PyDoc_STR("This non-public class is the base class of all " + "fundamental ctypes data types.\n" + "It contains the common attributes of the fundamental " + "ctypes data types.\n" + "_SimpleCData is a subclass of _CData, so it inherits " + "their methods and attributes.")}, {Py_tp_methods, Simple_methods}, {Py_tp_getset, Simple_getsets}, {Py_tp_init, Simple_init}, @@ -5566,8 +5690,22 @@ static PyType_Spec pycsimple_spec = { /* PyCPointer_Type */ +/*[clinic input] +class _ctypes._Pointer "PyObject *" "clinic_state()->PyCPointer_Type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=452695db70aa7c3e]*/ + +/*[clinic input] +@critical_section +_ctypes._Pointer.__getitem__ as Pointer_item + myself: self + index: Py_ssize_t + / +[clinic start generated code]*/ + static PyObject * -Pointer_item_lock_held(PyObject *myself, Py_ssize_t index) +Pointer_item_impl(PyObject *myself, Py_ssize_t index) +/*[clinic end generated code: output=4ae9d566e8038853 input=17943427cd04ed08]*/ { CDataObject *self = _CDataObject_CAST(myself); _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self); @@ -5606,18 +5744,19 @@ Pointer_item_lock_held(PyObject *myself, Py_ssize_t index) index, size, (char *)((char *)deref + offset)); } -static PyObject * -Pointer_item(PyObject *self, Py_ssize_t index) -{ - PyObject *res; - Py_BEGIN_CRITICAL_SECTION(self); - res = Pointer_item_lock_held(self, index); - Py_END_CRITICAL_SECTION(); - return res; -} +/*[clinic input] +@critical_section +_ctypes._Pointer.__setitem__ as Pointer_ass_item + + myself: self + index: Py_ssize_t + value: object + / +[clinic start generated code]*/ static int -Pointer_ass_item_lock_held(PyObject *myself, Py_ssize_t index, PyObject *value) +Pointer_ass_item_impl(PyObject *myself, Py_ssize_t index, PyObject *value) +/*[clinic end generated code: output=4503430bd55b6c69 input=344ad19b3094558c]*/ { CDataObject *self = _CDataObject_CAST(myself); _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self); @@ -5662,16 +5801,6 @@ Pointer_ass_item_lock_held(PyObject *myself, Py_ssize_t index, PyObject *value) index, size, ((char *)deref + offset)); } -static int -Pointer_ass_item(PyObject *self, Py_ssize_t index, PyObject *value) -{ - int res; - Py_BEGIN_CRITICAL_SECTION(self); - res = Pointer_ass_item_lock_held(self, index, value); - Py_END_CRITICAL_SECTION(); - return res; -} - static PyObject * Pointer_get_contents_lock_held(PyObject *self, void *closure) { @@ -5711,11 +5840,6 @@ Pointer_set_contents_lock_held(PyObject *op, PyObject *value, void *closure) PyObject *keep; CDataObject *self = _CDataObject_CAST(op); - if (value == NULL) { - PyErr_SetString(PyExc_TypeError, - "Pointer does not support item deletion"); - return -1; - } ctypes_state *st = get_module_state_by_def(Py_TYPE(Py_TYPE(self))); StgInfo *stginfo; if (PyStgInfo_FromObject(st, op, &stginfo) < 0) { @@ -5745,20 +5869,25 @@ Pointer_set_contents_lock_held(PyObject *op, PyObject *value, void *closure) 'value' itself as the second item of the b_objects list, additionally. */ Py_INCREF(value); - if (-1 == KeepRef(self, 1, value)) + if (-1 == KeepRef_lock_held(self, 1, value)) return -1; - keep = GetKeepedObjects(dst); + keep = GetKeepedObjects_lock_held(dst); if (keep == NULL) return -1; Py_INCREF(keep); - return KeepRef(self, 0, keep); + return KeepRef_lock_held(self, 0, keep); } static int Pointer_set_contents(PyObject *op, PyObject *value, void *closure) { + if (value == NULL) { + PyErr_SetString(PyExc_TypeError, + "Pointer does not support item deletion"); + return -1; + } int res; Py_BEGIN_CRITICAL_SECTION2(op, value); res = Pointer_set_contents_lock_held(op, value, closure); @@ -5807,7 +5936,7 @@ copy_pointer_to_list_lock_held(PyObject *myself, PyObject *np, Py_ssize_t len, Py_ssize_t i; size_t cur; for (cur = start, i = 0; i < len; cur += step, i++) { - PyObject *v = Pointer_item_lock_held(myself, cur); + PyObject *v = Pointer_item_impl(myself, cur); if (!v) { return -1; } @@ -5898,8 +6027,6 @@ Pointer_subscript(PyObject *myself, PyObject *item) } assert(iteminfo); if (iteminfo->getfunc == _ctypes_get_fielddesc("c")->getfunc) { - char *dest; - if (len <= 0) return Py_GetConstant(Py_CONSTANT_EMPTY_BYTES); if (step == 1) { @@ -5911,18 +6038,18 @@ Pointer_subscript(PyObject *myself, PyObject *item) Py_END_CRITICAL_SECTION(); return res; } - dest = (char *)PyMem_Malloc(len); - if (dest == NULL) - return PyErr_NoMemory(); + PyBytesWriter *writer = PyBytesWriter_Create(len); + if (writer == NULL) { + return NULL; + } + char *dest = PyBytesWriter_GetData(writer); Py_BEGIN_CRITICAL_SECTION(self); char *ptr = *(void **)self->b_ptr; for (cur = start, i = 0; i < len; cur += step, i++) { dest[i] = ptr[cur]; } Py_END_CRITICAL_SECTION(); - np = PyBytes_FromStringAndSize(dest, len); - PyMem_Free(dest); - return np; + return PyBytesWriter_Finish(writer); } if (iteminfo->getfunc == _ctypes_get_fielddesc("u")->getfunc) { wchar_t *dest; @@ -5974,18 +6101,32 @@ Pointer_subscript(PyObject *myself, PyObject *item) } } +/*[clinic input] +@critical_section +_ctypes._Pointer.__bool__ as Pointer_bool +[clinic start generated code]*/ + static int -Pointer_bool(PyObject *self) +Pointer_bool_impl(PyObject *self) +/*[clinic end generated code: output=0139acaf4d395a69 input=672b8d35e7e0752d]*/ { - int res; - Py_BEGIN_CRITICAL_SECTION(self); - res = *(void **)_CDataObject_CAST(self)->b_ptr != NULL; - Py_END_CRITICAL_SECTION(); - return res; + return *(void **)_CDataObject_CAST(self)->b_ptr != NULL; } static PyType_Slot pycpointer_slots[] = { - {Py_tp_doc, (void *)PyDoc_STR("XXX to be provided")}, + {Py_tp_doc, (void *)PyDoc_STR( + "Private, abstract base class for pointers.\n" + "\n" + "Concrete pointer types are created by calling POINTER() " + "with the type that will be pointed to; this is done " + "automatically by pointer().\n" + "\n" + "If a pointer points to an array, its elements can be read " + "and written using standard subscript and slice accesses. " + "Pointer objects have no size, so len() will raise " + "TypeError. Negative subscripts will read from the memory " + "before the pointer (as in C), and out-of-range subscripts " + "will probably crash with an access violation (if you’re lucky).")}, {Py_tp_getset, Pointer_getsets}, {Py_tp_init, Pointer_init}, {Py_tp_new, Pointer_new}, @@ -6268,7 +6409,10 @@ _ctypes_add_types(PyObject *mod) */ CREATE_TYPE(st->PyCArg_Type, &carg_spec, NULL, NULL); CREATE_TYPE(st->PyCThunk_Type, &cthunk_spec, NULL, NULL); - CREATE_TYPE(st->PyCData_Type, &pycdata_spec, NULL, NULL); + st->PyCData_Type = (PyTypeObject *)PyCData_create_type(mod); + if (st->PyCData_Type == NULL) { + return -1; + } // Common Metaclass CREATE_TYPE(st->PyCType_Type, &pyctype_type_spec, @@ -6384,21 +6528,92 @@ _ctypes_add_objects(PyObject *mod) } +#ifdef FFI_VERSION_NUMBER +PyDoc_STRVAR(libffi_version_info__doc__, +"ctypes.libffi_version_info\n\ +\n\ +libffi version information as a named tuple."); + +static PyStructSequence_Field libffi_version_info_fields[] = { + {"major", "Major release number"}, + {"minor", "Minor release number"}, + {"patch", "Patch release number"}, + {0} +}; + +static PyStructSequence_Desc libffi_version_info_desc = { + "ctypes.libffi_version_info", /* name */ + libffi_version_info__doc__, /* doc */ + libffi_version_info_fields, /* fields */ + 3 +}; + +static PyObject * +make_libffi_version_info(PyTypeObject *type, unsigned long number) +{ + PyObject *version; + int pos = 0; + unsigned long major = number / 10000; + unsigned long minor = (number % 10000) / 100; + unsigned long patch = number % 100; + + version = PyStructSequence_New(type); + if (version == NULL) { + return NULL; + } + +#define SetItem(VALUE) \ + PyStructSequence_SET_ITEM(version, pos++, VALUE); \ + if (PyErr_Occurred()) { \ + Py_DECREF(version); \ + return NULL; \ + } + + SetItem(PyLong_FromUnsignedLong(major)) + SetItem(PyLong_FromUnsignedLong(minor)) + SetItem(PyLong_FromUnsignedLong(patch)) +#undef SetItem + + return version; +} + static int -_ctypes_mod_exec(PyObject *mod) +_ctypes_add_version_constants(PyObject *mod) { - // See https://github.com/python/cpython/issues/128485 - // This allocates some memory and then frees it to ensure that the - // the dlmalloc allocator initializes itself to avoid data races - // in free-threading. - void *codeloc = NULL; - void *ptr = Py_ffi_closure_alloc(sizeof(void *), &codeloc); - if (ptr == NULL) { - PyErr_NoMemory(); + if (PyModule_AddStringConstant(mod, "LIBFFI_VERSION", + FFI_VERSION_STRING) < 0) { return -1; } - Py_ffi_closure_free(ptr); + if (PyModule_AddStringConstant(mod, "libffi_version", + ffi_get_version()) < 0) { + return -1; + } + PyTypeObject *version_type; + version_type = PyStructSequence_NewType(&libffi_version_info_desc); + if (version_type == NULL) { + return -1; + } + if (PyModule_Add(mod, "LIBFFI_VERSION_INFO", + make_libffi_version_info(version_type, FFI_VERSION_NUMBER)) < 0) + { + Py_DECREF(version_type); + return -1; + } + if (PyModule_Add(mod, "libffi_version_info", + make_libffi_version_info(version_type, + ffi_get_version_number())) < 0) + { + Py_DECREF(version_type); + return -1; + } + Py_DECREF(version_type); + return 0; +} +#endif +static int +_ctypes_mod_exec(PyObject *mod) +{ _ctypes_init_fielddesc(); ctypes_state *st = get_module_state(mod); @@ -6438,6 +6653,11 @@ _ctypes_mod_exec(PyObject *mod) if (_ctypes_add_objects(mod) < 0) { return -1; } +#ifdef FFI_VERSION_NUMBER + if (_ctypes_add_version_constants(mod) < 0) { + return -1; + } +#endif return 0; } diff --git a/Modules/_ctypes/_ctypes_test.c b/Modules/_ctypes/_ctypes_test.c index 991ff0d675c2f1c..900dba34fc72967 100644 --- a/Modules/_ctypes/_ctypes_test.c +++ b/Modules/_ctypes/_ctypes_test.c @@ -13,16 +13,6 @@ #include -#ifdef thread_local -# define _Py_thread_local thread_local -#elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__) -# define _Py_thread_local _Thread_local -#elif defined(_MSC_VER) /* AKA NT_THREADS */ -# define _Py_thread_local __declspec(thread) -#elif defined(__GNUC__) /* includes clang */ -# define _Py_thread_local __thread -#endif - #if defined(_Py_FFI_SUPPORT_C_COMPLEX) # include // csqrt() # undef I // for _ctypes_test_generated.c.h @@ -72,6 +62,79 @@ _testfunc_cbk_large_struct(Test in, void (*func)(Test)) func(in); } +/* + * gh-49960: callbacks returning structs and unions by value. + * + * Each of these exercises a different ABI return class, since struct + * return conventions are highly platform-specific: + * - SmallRet: small integer struct, returned in registers + * - Test: >8 bytes (reused from above), returned via hidden pointer + * - FloatRet: all-float struct, SSE class on x86-64 / HFA on AArch64 + * - UnionRet: union + * - PtrRet: struct containing a pointer + */ + +typedef struct { + int a; + int b; +} SmallRet; + +EXPORT(SmallRet) +_testfunc_cbk_ret_small_struct(SmallRet (*func)(void)) +{ + return func(); +} + +/* Returns a scalar derived from the struct, so a test can prove the bytes + actually reached the C caller rather than only round-tripping in Python. */ +EXPORT(long) +_testfunc_cbk_ret_small_struct_sum(SmallRet (*func)(void)) +{ + SmallRet s = func(); + return (long)s.a + (long)s.b; +} + +EXPORT(Test) +_testfunc_cbk_ret_large_struct(Test (*func)(void)) +{ + return func(); +} + +typedef struct { + double x; + double y; +} FloatRet; + +EXPORT(FloatRet) +_testfunc_cbk_ret_float_struct(FloatRet (*func)(void)) +{ + return func(); +} + +typedef union { + int i; + float f; +} UnionRet; + +EXPORT(UnionRet) +_testfunc_cbk_ret_union(UnionRet (*func)(void)) +{ + return func(); +} + +/* Struct containing a pointer, for the documented pointer-lifetime contract: + the struct is copied by value, so the pointed-to memory must outlive the + callback. */ +typedef struct { + const char *s; +} PtrRet; + +EXPORT(PtrRet) +_testfunc_cbk_ret_ptr_struct(PtrRet (*func)(void)) +{ + return func(); +} + /* * See issue 29565. Update a structure passed by value; * the caller should not see any change. @@ -638,6 +701,11 @@ EXPORT(long long) _testfunc_callback_q_qf(long long value, return sum; } +EXPORT(long long) _testfunc_callback_int_to_longlong(int (*func)(void)) +{ + return func(); +} + typedef struct { char *name; char *value; diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c index fd508ae61f2e040..e54111b8a4fab44 100644 --- a/Modules/_ctypes/callbacks.c +++ b/Modules/_ctypes/callbacks.c @@ -9,6 +9,7 @@ #endif #include "pycore_call.h" // _PyObject_CallNoArgs() +#include "pycore_lock.h" // _PyOnceFlag_CallOnce() #include "pycore_runtime.h" // _Py_ID() #include @@ -101,6 +102,22 @@ TryAddRef(PyObject *cnv, CDataObject *obj) } #endif +static int +is_narrow_int_ffi_type(int type) +{ + switch (type) { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + return 1; + default: + return 0; + } +} + /****************************************************************************** * * Call the python object with all arguments @@ -111,6 +128,7 @@ TryAddRef(PyObject *cnv, CDataObject *obj) static void _CallPythonObject(ctypes_state *st, void *mem, ffi_type *restype, + PyObject *restype_obj, SETFUNC setfunc, PyObject *callable, PyObject *converters, @@ -220,47 +238,113 @@ static void _CallPythonObject(ctypes_state *st, Py_XDECREF(error_object); if (restype != &ffi_type_void && result) { - assert(setfunc); - -#ifdef WORDS_BIGENDIAN - /* See the corresponding code in _ctypes_callproc(): - in callproc.c, around line 1219. */ - if (restype->type != FFI_TYPE_FLOAT && restype->size < sizeof(ffi_arg)) { - mem = (char *)mem + sizeof(ffi_arg) - restype->size; - } -#endif - /* keep is an object we have to keep alive so that the result - stays valid. If there is no such object, the setfunc will - have returned Py_None. - - If there is such an object, we have no choice than to keep - it alive forever - but a refcount and/or memory leak will - be the result. EXCEPT when restype is py_object - Python - itself knows how to manage the refcount of these objects. - */ - PyObject *keep = setfunc(mem, result, restype->size); - - if (keep == NULL) { - /* Could not convert callback result. */ - PyErr_FormatUnraisable( - "Exception ignored while converting result " - "of ctypes callback function %R", - callable); + /* libffi's closure contract requires integral results narrower + than ffi_arg to fill a whole register, sign-extended if signed; + setfunc() only writes restype->size bytes. Structs and unions + are never narrow integers, so they always write to mem directly. */ + union { + ffi_arg arg; + int8_t s8; + uint8_t u8; + int16_t s16; + uint16_t u16; + int32_t s32; + uint32_t u32; + } narrow_res = {0}; + int narrow = restype->size < sizeof(ffi_arg) && + is_narrow_int_ffi_type(restype->type); + void *resmem = narrow ? (void *)&narrow_res : mem; + + if (setfunc == NULL) { + /* gh-49960: struct/union return. There is no setfunc for these + types, so copy the bytes out of the CData object directly. + The struct is copied by value and no object is kept alive, so + any pointer it contains must reference memory the caller keeps + alive - the same contract C imposes. */ + assert(!narrow); + /* Use a real subtype check rather than PyObject_IsInstance(): + a metaclass __instancecheck__ could otherwise accept an object + whose buffer is smaller than restype->size. */ + if (PyObject_TypeCheck(result, (PyTypeObject *)restype_obj)) { + /* restype_obj is a struct or union type (enforced in + _ctypes_alloc_callback), so its instances are CData. */ + assert(CDataObject_Check(st, result)); + CDataObject *cd = (CDataObject *)result; + Py_BEGIN_CRITICAL_SECTION(cd); + memcpy(mem, cd->b_ptr, restype->size); + Py_END_CRITICAL_SECTION(); + } + else { + PyErr_Format(PyExc_TypeError, + "ctypes callback function returned unexpected " + "type %T", result); + PyErr_FormatUnraisable( + "Exception ignored while converting result " + "of ctypes callback function %R", + callable); + } } - else if (setfunc != _ctypes_get_fielddesc("O")->setfunc) { - if (keep == Py_None) { - /* Nothing to keep */ - Py_DECREF(keep); + else { + /* keep is an object we have to keep alive so that the result + stays valid. If there is no such object, the setfunc will + have returned Py_None. + + If there is such an object, we have no choice than to keep + it alive forever - but a refcount and/or memory leak will + be the result. EXCEPT when restype is py_object - Python + itself knows how to manage the refcount of these objects. + */ + PyObject *keep = setfunc(resmem, result, restype->size); + + if (narrow && keep != NULL) { + ffi_arg widened; + switch (restype->type) { + case FFI_TYPE_SINT8: + widened = (ffi_arg)(ffi_sarg)narrow_res.s8; + break; + case FFI_TYPE_SINT16: + widened = (ffi_arg)(ffi_sarg)narrow_res.s16; + break; + case FFI_TYPE_SINT32: + widened = (ffi_arg)(ffi_sarg)narrow_res.s32; + break; + case FFI_TYPE_UINT8: + widened = narrow_res.u8; + break; + case FFI_TYPE_UINT16: + widened = narrow_res.u16; + break; + case FFI_TYPE_UINT32: + widened = narrow_res.u32; + break; + default: + Py_UNREACHABLE(); + } + memcpy(mem, &widened, sizeof(ffi_arg)); } - else if (PyErr_WarnEx(PyExc_RuntimeWarning, - "memory leak in callback function.", - 1) == -1) { + + if (keep == NULL) { + /* Could not convert callback result. */ PyErr_FormatUnraisable( "Exception ignored while converting result " "of ctypes callback function %R", callable); } + else if (setfunc != _ctypes_get_fielddesc("O")->setfunc) { + if (keep == Py_None) { + /* Nothing to keep */ + Py_DECREF(keep); + } + else if (PyErr_WarnEx(PyExc_RuntimeWarning, + "memory leak in callback function.", + 1) == -1) { + PyErr_FormatUnraisable( + "Exception ignored while converting result " + "of ctypes callback function %R", + callable); + } + } } } @@ -293,6 +377,7 @@ static void closure_fcn(ffi_cif *cif, _CallPythonObject(st, resp, p->ffi_restype, + p->restype, p->setfunc, p->callable, p->converters, @@ -328,6 +413,27 @@ static CThunkObject* CThunkObject_new(ctypes_state *st, Py_ssize_t nargs) return p; } +static _PyOnceFlag closure_alloc_init_once = {0}; + +// This is done lazily with a once flag rather than in the module exec function, +// because allocating a closure can have some side effects that affect the whole +// process (gh-135893). +static int +closure_alloc_init(void *Py_UNUSED(arg)) +{ + // See https://github.com/python/cpython/issues/128485 + // This allocates some memory and then frees it to ensure that libffi's + // dlmalloc allocator initializes itself exactly once, avoiding data races + // between threads that don't share a GIL. + void *codeloc = NULL; + void *ptr = Py_ffi_closure_alloc(sizeof(void *), &codeloc); + if (ptr == NULL) { + return -1; + } + Py_ffi_closure_free(ptr); + return 0; +} + CThunkObject *_ctypes_alloc_callback(ctypes_state *st, PyObject *callable, PyObject *converters, @@ -347,6 +453,12 @@ CThunkObject *_ctypes_alloc_callback(ctypes_state *st, assert(CThunk_CheckExact(st, (PyObject *)p)); + if (_PyOnceFlag_CallOnce(&closure_alloc_init_once, + closure_alloc_init, NULL) < 0) { + PyErr_NoMemory(); + goto error; + } + p->pcl_write = Py_ffi_closure_alloc(sizeof(ffi_closure), &p->pcl_exec); if (p->pcl_write == NULL) { PyErr_NoMemory(); @@ -371,10 +483,25 @@ CThunkObject *_ctypes_alloc_callback(ctypes_state *st, goto error; } - if (info == NULL || info->setfunc == NULL) { - PyErr_SetString(PyExc_TypeError, - "invalid result type for callback function"); - goto error; + /* gh-49960: structs and unions have no setfunc (that is reserved for + "simple" types), but can still be returned by value. Leaving + p->setfunc as NULL signals the struct-return path in + _CallPythonObject. */ + if (info == NULL + || ( + info->setfunc == NULL + && !PyCStructTypeObject_Check(st, restype) + && !PyObject_TypeCheck(restype, st->UnionType_Type) + ) + ) { + PyErr_SetString(PyExc_TypeError, + "invalid result type for callback function"); + goto error; + } + if (info->setfunc == NULL) { + /* The cif built below depends on the struct/union layout, so + _fields_ must not be (re)assigned after this point. */ + stginfo_set_dict_final(info); } p->setfunc = info->setfunc; p->ffi_restype = &info->ffi_type_pointer; diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index ccc57e347b07acf..c8a54b0cec83a77 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -91,10 +91,30 @@ module _ctypes #define DONT_USE_SEH #endif +#include "pycore_ceval.h" // _Py_EnterRecursiveCall() #include "pycore_runtime.h" // _PyRuntime #include "pycore_global_objects.h"// _Py_ID() #include "pycore_traceback.h" // _PyTraceback_Add() +#ifndef MS_WIN32 +# if HAVE_DECL_RTLD_LOCAL +# define DLOPEN_DEFAULT_MODE (RTLD_NOW | RTLD_LOCAL) +# else + /* cygwin doesn't define RTLD_LOCAL */ +# define DLOPEN_DEFAULT_MODE RTLD_NOW +# endif +#endif + +static int _parse_voidp(PyObject *obj, void *arg); +static int _parse_voidp_object(PyObject *obj, void *arg); + +/*[python input] +class voidp_converter(CConverter): + type = 'void *' + converter = '_parse_voidp' +[python start generated code]*/ +/*[python end generated code: output=da39a3ee5e6b4b0d input=c230831f53ec0946]*/ + #define clinic_state() (get_module_state(module)) #include "clinic/callproc.c.h" #undef clinic_state @@ -186,10 +206,10 @@ _ctypes_get_errobj(ctypes_state *st, int **pspace) } static PyObject * -get_error_internal(PyObject *self, PyObject *args, int index) +get_error_internal(PyObject *module, int index) { int *space; - ctypes_state *st = get_module_state(self); + ctypes_state *st = get_module_state(module); PyObject *errobj = _ctypes_get_errobj(st, &space); PyObject *result; @@ -201,16 +221,13 @@ get_error_internal(PyObject *self, PyObject *args, int index) } static PyObject * -set_error_internal(PyObject *self, PyObject *args, int index) +set_error_internal(PyObject *module, int new_errno, int index) { - int new_errno, old_errno; + int old_errno; PyObject *errobj; int *space; - if (!PyArg_ParseTuple(args, "i", &new_errno)) { - return NULL; - } - ctypes_state *st = get_module_state(self); + ctypes_state *st = get_module_state(module); errobj = _ctypes_get_errobj(st, &space); if (errobj == NULL) return NULL; @@ -220,42 +237,72 @@ set_error_internal(PyObject *self, PyObject *args, int index) return PyLong_FromLong(old_errno); } +/*[clinic input] +_ctypes.get_errno + +Return the current value of the ctypes-private copy of errno. +[clinic start generated code]*/ + static PyObject * -get_errno(PyObject *self, PyObject *args) +_ctypes_get_errno_impl(PyObject *module) +/*[clinic end generated code: output=82992e823984b48e input=bf578c7a7608b0f4]*/ { if (PySys_Audit("ctypes.get_errno", NULL) < 0) { return NULL; } - return get_error_internal(self, args, 0); + return get_error_internal(module, 0); } +/*[clinic input] +_ctypes.set_errno + + value: int + / +[clinic start generated code]*/ + static PyObject * -set_errno(PyObject *self, PyObject *args) +_ctypes_set_errno_impl(PyObject *module, int value) +/*[clinic end generated code: output=0c85e07ccf0749c2 input=b2550d9d2cdfab20]*/ { - if (PySys_Audit("ctypes.set_errno", "O", args) < 0) { + if (PySys_Audit("ctypes.set_errno", "i", value) < 0) { return NULL; } - return set_error_internal(self, args, 0); + return set_error_internal(module, value, 0); } #ifdef MS_WIN32 +/*[clinic input] +_ctypes.get_last_error + +Return the current value of the ctypes-private copy of the last error. +[clinic start generated code]*/ + static PyObject * -get_last_error(PyObject *self, PyObject *args) +_ctypes_get_last_error_impl(PyObject *module) +/*[clinic end generated code: output=e237c4d3b75eb1eb input=d25599a79c030bb4]*/ { if (PySys_Audit("ctypes.get_last_error", NULL) < 0) { return NULL; } - return get_error_internal(self, args, 1); + return get_error_internal(module, 1); } +/*[clinic input] +_ctypes.set_last_error + + value: int + / +[clinic start generated code]*/ + static PyObject * -set_last_error(PyObject *self, PyObject *args) +_ctypes_set_last_error_impl(PyObject *module, int value) +/*[clinic end generated code: output=dce5b4be6255bcb5 input=1a3f4ba970902db7]*/ { - if (PySys_Audit("ctypes.set_last_error", "O", args) < 0) { + if (PySys_Audit("ctypes.set_last_error", "i", value) < 0) { return NULL; } - return set_error_internal(self, args, 1); + return set_error_internal(module, value, 1); } static WCHAR *FormatError(DWORD code) @@ -446,12 +493,17 @@ static DWORD HandleException(EXCEPTION_POINTERS *ptrs, } #endif +/*[clinic input] +_ctypes._check_HRESULT + + hresult as hr: int + / +[clinic start generated code]*/ + static PyObject * -check_hresult(PyObject *self, PyObject *args) +_ctypes__check_HRESULT_impl(PyObject *module, int hr) +/*[clinic end generated code: output=ba872ad9e32b2d1f input=75e2334791d6cf29]*/ { - HRESULT hr; - if (!PyArg_ParseTuple(args, "i", &hr)) - return NULL; if (FAILED(hr)) return PyErr_SetFromWindowsErr(hr); return PyLong_FromLong(hr); @@ -744,8 +796,12 @@ static int ConvParam(ctypes_state *st, attribute) */ if (arg) { - int result; - result = ConvParam(st, arg, index, pa); + if (_Py_EnterRecursiveCall(" while processing _as_parameter_")) { + Py_DECREF(arg); + return -1; + } + int result = ConvParam(st, arg, index, pa); + _Py_LeaveRecursiveCall(); Py_DECREF(arg); return result; } @@ -1082,8 +1138,7 @@ void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...) } -#ifdef MS_WIN32 - +#ifdef MS_WINDOWS_DESKTOP static PyObject * GetComError(ctypes_state *st, HRESULT errcode, GUID *riid, IUnknown *pIunk) { @@ -1337,9 +1392,11 @@ PyObject *_ctypes_callproc(ctypes_state *st, #ifdef MS_WIN32 if (iid && pIunk) { +#ifdef MS_WINDOWS_DESKTOP if (*(int *)resbuf & 0x80000000) retval = GetComError(st, *(HRESULT *)resbuf, iid, pIunk); else +#endif retval = PyLong_FromLong(*(int *)resbuf); } else if (flags & FUNCFLAG_HRESULT) { if (*(int *)resbuf & 0x80000000) @@ -1367,18 +1424,25 @@ _parse_voidp(PyObject *obj, void *arg) #ifdef MS_WIN32 -PyDoc_STRVAR(format_error_doc, -"FormatError([integer]) -> string\n\ -\n\ -Convert a win32 error code into a string. If the error code is not\n\ -given, the return value of a call to GetLastError() is used.\n"); -static PyObject *format_error(PyObject *self, PyObject *args) +/*[clinic input] +_ctypes.FormatError + + code: int = 0 + / + +Convert a win32 error code into a string. + +If the error code is not given, the return value of a call to +GetLastError() is used. +[clinic start generated code]*/ + +static PyObject * +_ctypes_FormatError_impl(PyObject *module, int code) +/*[clinic end generated code: output=ccc560dddfd0b3d7 input=e0c98f1c644e5153]*/ { PyObject *result; wchar_t *lpMsgBuf; - DWORD code = 0; - if (!PyArg_ParseTuple(args, "|i:FormatError", &code)) - return NULL; + if (code == 0) code = GetLastError(); lpMsgBuf = FormatError(code); @@ -1391,23 +1455,26 @@ static PyObject *format_error(PyObject *self, PyObject *args) return result; } -PyDoc_STRVAR(load_library_doc, -"LoadLibrary(name, load_flags) -> handle\n\ -\n\ -Load an executable (usually a DLL), and return a handle to it.\n\ -The handle may be used to locate exported functions in this\n\ -module. load_flags are as defined for LoadLibraryEx in the\n\ -Windows API.\n"); -static PyObject *load_library(PyObject *self, PyObject *args) +/*[clinic input] +_ctypes.LoadLibrary + + name as nameobj: unicode + load_flags: int = 0 + / + +Load an executable (usually a DLL), and return a handle to it. + +The handle may be used to locate exported functions in this module. +load_flags are as defined for LoadLibraryEx in the Windows API. +[clinic start generated code]*/ + +static PyObject * +_ctypes_LoadLibrary_impl(PyObject *module, PyObject *nameobj, int load_flags) +/*[clinic end generated code: output=4e33b2cda4b12af6 input=69e4b6512653825e]*/ { - PyObject *nameobj; - int load_flags = 0; HMODULE hMod; DWORD err; - if (!PyArg_ParseTuple(args, "U|i:LoadLibrary", &nameobj, &load_flags)) - return NULL; - if (PySys_Audit("ctypes.dlopen", "O", nameobj) < 0) { return NULL; } @@ -1442,17 +1509,21 @@ static PyObject *load_library(PyObject *self, PyObject *args) #endif } -PyDoc_STRVAR(free_library_doc, -"FreeLibrary(handle) -> void\n\ -\n\ -Free the handle of an executable previously loaded by LoadLibrary.\n"); -static PyObject *free_library(PyObject *self, PyObject *args) +/*[clinic input] +_ctypes.FreeLibrary + + handle as hMod: voidp + / + +Free the handle of an executable previously loaded by LoadLibrary. +[clinic start generated code]*/ + +static PyObject * +_ctypes_FreeLibrary_impl(PyObject *module, void *hMod) +/*[clinic end generated code: output=2424a8daf3fe93df input=e722e432560e849a]*/ { - void *hMod; BOOL result; DWORD err; - if (!PyArg_ParseTuple(args, "O&:FreeLibrary", &_parse_voidp, &hMod)) - return NULL; Py_BEGIN_ALLOW_THREADS result = FreeLibrary((HMODULE)hMod); @@ -1465,20 +1536,27 @@ static PyObject *free_library(PyObject *self, PyObject *args) Py_RETURN_NONE; } -PyDoc_STRVAR(copy_com_pointer_doc, -"CopyComPointer(src, dst) -> HRESULT value\n"); +/*[clinic input] +_ctypes.CopyComPointer + + src as p1: object + dst as p2: object + / + +Copy a COM pointer and return the HRESULT value. +[clinic start generated code]*/ static PyObject * -copy_com_pointer(PyObject *self, PyObject *args) +_ctypes_CopyComPointer_impl(PyObject *module, PyObject *p1, PyObject *p2) +/*[clinic end generated code: output=bbe731fea856eba2 input=296c1f3e026bbf27]*/ { - PyObject *p1, *p2, *r = NULL; + PyObject *r = NULL; struct argument a, b; IUnknown *src, **pdst; - if (!PyArg_ParseTuple(args, "OO:CopyComPointer", &p1, &p2)) - return NULL; + a.keep = b.keep = NULL; - ctypes_state *st = get_module_state(self); + ctypes_state *st = get_module_state(module); if (ConvParam(st, p1, 0, &a) < 0 || ConvParam(st, p2, 1, &b) < 0) { goto done; } @@ -1529,17 +1607,25 @@ __attribute__((destructor)) void unload_dyld_shared_cache_contains_path(void) { _dyld_shared_cache_contains_path != NULL #endif -static PyObject *py_dyld_shared_cache_contains_path(PyObject *self, PyObject *args) +/*[clinic input] +_ctypes._dyld_shared_cache_contains_path + + path as name: object + / + +Check whether a path is in the shared cache. +[clinic start generated code]*/ + +static PyObject * +_ctypes__dyld_shared_cache_contains_path(PyObject *module, PyObject *name) +/*[clinic end generated code: output=1d3fed04c0490294 input=bb910a42599d991f]*/ { - PyObject *name, *name2; + PyObject *name2; char *name_str; if (HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH_RUNTIME) { int r; - if (!PyArg_ParseTuple(args, "O", &name)) - return NULL; - if (name == Py_None) Py_RETURN_FALSE; @@ -1564,19 +1650,24 @@ static PyObject *py_dyld_shared_cache_contains_path(PyObject *self, PyObject *ar } #endif -static PyObject *py_dl_open(PyObject *self, PyObject *args) +/*[clinic input] +_ctypes.dlopen + + name: object + mode: int(c_default="DLOPEN_DEFAULT_MODE") = RTLD_NOW | RTLD_LOCAL + / + +Open a shared library. +[clinic start generated code]*/ + +static PyObject * +_ctypes_dlopen_impl(PyObject *module, PyObject *name, int mode) +/*[clinic end generated code: output=d68f1775017199b8 input=df6aa38a12f91cfe]*/ { - PyObject *name, *name2; + PyObject *name2; const char *name_str; void * handle; -#if HAVE_DECL_RTLD_LOCAL - int mode = RTLD_NOW | RTLD_LOCAL; -#else - /* cygwin doesn't define RTLD_LOCAL */ - int mode = RTLD_NOW; -#endif - if (!PyArg_ParseTuple(args, "O|i:dlopen", &name, &mode)) - return NULL; + mode |= RTLD_NOW; if (name != Py_None) { if (PyUnicode_FSConverter(name, &name2) == 0) @@ -1603,12 +1694,19 @@ static PyObject *py_dl_open(PyObject *self, PyObject *args) return PyLong_FromVoidPtr(handle); } -static PyObject *py_dl_close(PyObject *self, PyObject *args) -{ - void *handle; +/*[clinic input] +_ctypes.dlclose - if (!PyArg_ParseTuple(args, "O&:dlclose", &_parse_voidp, &handle)) - return NULL; + handle: voidp + / + +Close a shared library. +[clinic start generated code]*/ + +static PyObject * +_ctypes_dlclose_impl(PyObject *module, void *handle) +/*[clinic end generated code: output=80a4d433a7c81348 input=b8a3d95439746deb]*/ +{ if (dlclose(handle)) { const char *errmsg = dlerror(); if (errmsg) { @@ -1621,16 +1719,24 @@ static PyObject *py_dl_close(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject *py_dl_sym(PyObject *self, PyObject *args) +/*[clinic input] +_ctypes.dlsym + + handle: voidp + name: str + / + +Find a symbol in a shared library. +[clinic start generated code]*/ + +static PyObject * +_ctypes_dlsym_impl(PyObject *module, void *handle, const char *name) +/*[clinic end generated code: output=fada3d0f0447614c input=ee37a4935a19550c]*/ { - char *name; - void *handle; void *ptr; - if (!PyArg_ParseTuple(args, "O&s:dlsym", - &_parse_voidp, &handle, &name)) - return NULL; - if (PySys_Audit("ctypes.dlsym/handle", "O", args) < 0) { + if (PySys_Audit("ctypes.dlsym/handle", "ns", (Py_ssize_t)handle, + name) < 0) { return NULL; } #undef USE_DLERROR @@ -1660,6 +1766,49 @@ static PyObject *py_dl_sym(PyObject *self, PyObject *args) PyErr_Format(PyExc_OSError, "symbol '%s' not found", name); return NULL; } + +// Apple platforms use the dyld API in ctypes.util instead. +#if defined(HAVE_DL_ITERATE_PHDR) && !defined(__APPLE__) +#include + +static int +_dllist_callback(struct dl_phdr_info *info, size_t size, void *data) +{ + PyObject *list = (PyObject *)data; + PyObject *name = PyUnicode_DecodeFSDefault(info->dlpi_name); + if (name == NULL) { + return -1; + } + int res = PyList_Append(list, name); + Py_DECREF(name); + return res; +} + +/*[clinic input] +_ctypes.dllist + +Return a list of loaded shared libraries. +[clinic start generated code]*/ + +static PyObject * +_ctypes_dllist_impl(PyObject *module) +/*[clinic end generated code: output=7b4eaaecc7abf21a input=5bfb4e345425f59f]*/ +{ + // On NetBSD dl_iterate_phdr() only reports the link-map group of the + // caller, so it cannot be called via a libffi trampoline. + PyObject *list = PyList_New(0); + if (list == NULL) { + return NULL; + } + // The return value only echoes the callback result. + dl_iterate_phdr(_dllist_callback, list); + if (PyErr_Occurred()) { + Py_DECREF(list); + return NULL; + } + return list; +} +#endif #endif /* @@ -1667,20 +1816,21 @@ static PyObject *py_dl_sym(PyObject *self, PyObject *args) * * XXX Needs to accept more arguments: flags, argtypes, restype */ +/*[clinic input] +_ctypes.call_function + + func: voidp + arguments: object(subclass_of='&PyTuple_Type') + / +[clinic start generated code]*/ + static PyObject * -call_function(PyObject *self, PyObject *args) +_ctypes_call_function_impl(PyObject *module, void *func, PyObject *arguments) +/*[clinic end generated code: output=e90059bba8e0f0de input=2f2a7a5ea1b4031f]*/ { - void *func; - PyObject *arguments; PyObject *result; - if (!PyArg_ParseTuple(args, - "O&O!", - &_parse_voidp, &func, - &PyTuple_Type, &arguments)) - return NULL; - - ctypes_state *st = get_module_state(self); + ctypes_state *st = get_module_state(module); result = _ctypes_callproc(st, (PPROC)func, arguments, @@ -1700,20 +1850,22 @@ call_function(PyObject *self, PyObject *args) * * XXX Needs to accept more arguments: flags, argtypes, restype */ +/*[clinic input] +_ctypes.call_cdeclfunction + + func: voidp + arguments: object(subclass_of='&PyTuple_Type') + / +[clinic start generated code]*/ + static PyObject * -call_cdeclfunction(PyObject *self, PyObject *args) +_ctypes_call_cdeclfunction_impl(PyObject *module, void *func, + PyObject *arguments) +/*[clinic end generated code: output=697e21ce2e298acd input=bc3260e856aa7416]*/ { - void *func; - PyObject *arguments; PyObject *result; - if (!PyArg_ParseTuple(args, - "O&O!", - &_parse_voidp, &func, - &PyTuple_Type, &arguments)) - return NULL; - - ctypes_state *st = get_module_state(self); + ctypes_state *st = get_module_state(module); result = _ctypes_callproc(st, (PPROC)func, arguments, @@ -1766,15 +1918,22 @@ _ctypes_sizeof(PyObject *module, PyObject *obj) return NULL; } -PyDoc_STRVAR(alignment_doc, -"alignment(C type) -> integer\n" -"alignment(C instance) -> integer\n" -"Return the alignment requirements of a C instance"); +/*[clinic input] +_ctypes.alignment + + obj: object + / + +Return the alignment requirements of a C instance. + +The argument is a C type or a C instance. +[clinic start generated code]*/ static PyObject * -align_func(PyObject *self, PyObject *obj) +_ctypes_alignment(PyObject *module, PyObject *obj) +/*[clinic end generated code: output=a7abe04d98641d93 input=3c78c5425bc83928]*/ { - ctypes_state *st = get_module_state(self); + ctypes_state *st = get_module_state(module); StgInfo *info; if (PyStgInfo_FromAny(st, obj, &info) < 0) { return NULL; @@ -1836,36 +1995,60 @@ _ctypes_addressof_impl(PyObject *module, PyObject *obj) } static int -converter(PyObject *obj, void *arg) +_parse_voidp_object(PyObject *obj, void *arg) { - void **address = (void **)arg; + PyObject **address = (PyObject **)arg; *address = PyLong_AsVoidPtr(obj); return *address != NULL; } +/*[clinic input] +_ctypes.PyObj_FromPtr + + address as ob: object(converter="_parse_voidp_object") + / +[clinic start generated code]*/ + static PyObject * -My_PyObj_FromPtr(PyObject *self, PyObject *args) +_ctypes_PyObj_FromPtr_impl(PyObject *module, PyObject *ob) +/*[clinic end generated code: output=225d11c8e84c2926 input=1baea4849458fe7c]*/ { - PyObject *ob; - if (!PyArg_ParseTuple(args, "O&:PyObj_FromPtr", converter, &ob)) { - return NULL; - } if (PySys_Audit("ctypes.PyObj_FromPtr", "(O)", ob) < 0) { return NULL; } return Py_NewRef(ob); } +/*[clinic input] +_ctypes.Py_INCREF + + obj as arg: object + / + +Increment the reference count of the object and return it. +[clinic start generated code]*/ + static PyObject * -My_Py_INCREF(PyObject *self, PyObject *arg) +_ctypes_Py_INCREF(PyObject *module, PyObject *arg) +/*[clinic end generated code: output=ebf05a7f9ba69657 input=04fcd9c30fee39ea]*/ { Py_INCREF(arg); /* that's what this function is for */ Py_INCREF(arg); /* that for returning it */ return arg; } +/*[clinic input] +_ctypes.Py_DECREF + + obj as arg: object + / + +Decrement the reference count of the object and return it. +[clinic start generated code]*/ + static PyObject * -My_Py_DECREF(PyObject *self, PyObject *arg) +_ctypes_Py_DECREF(PyObject *module, PyObject *arg) +/*[clinic end generated code: output=d7933cd7be22ccde input=108543079a732003]*/ { Py_DECREF(arg); /* that's what this function is for */ Py_INCREF(arg); /* that's for returning it */ @@ -1932,13 +2115,20 @@ _ctypes_resize_impl(PyObject *module, CDataObject *obj, Py_ssize_t size) Py_RETURN_NONE; } +/*[clinic input] +_ctypes._unpickle + + cls as typ: object + state: object(subclass_of='&PyTuple_Type') + / +[clinic start generated code]*/ + static PyObject * -unpickle(PyObject *self, PyObject *args) +_ctypes__unpickle_impl(PyObject *module, PyObject *typ, PyObject *state) +/*[clinic end generated code: output=358df408ddcf5145 input=1cdb32990e0ef9b8]*/ { - PyObject *typ, *state, *meth, *obj, *result; + PyObject *meth, *obj, *result; - if (!PyArg_ParseTuple(args, "OO!", &typ, &PyTuple_Type, &state)) - return NULL; obj = PyObject_CallMethodOneArg(typ, &_Py_ID(__new__), typ); if (obj == NULL) return NULL; @@ -1962,13 +2152,23 @@ unpickle(PyObject *self, PyObject *args) return NULL; } +/*[clinic input] +_ctypes.buffer_info + + obj as arg: object + / + +Return buffer interface information. +[clinic start generated code]*/ + static PyObject * -buffer_info(PyObject *self, PyObject *arg) +_ctypes_buffer_info(PyObject *module, PyObject *arg) +/*[clinic end generated code: output=31f942a6fce6d671 input=cb023e7f9c959f72]*/ { PyObject *shape; Py_ssize_t i; - ctypes_state *st = get_module_state(self); + ctypes_state *st = get_module_state(module); StgInfo *info; if (PyStgInfo_FromAny(st, arg, &info) < 0) { return NULL; @@ -1993,13 +2193,8 @@ buffer_info(PyObject *self, PyObject *arg) static PyObject * -_ctypes_getattr(PyObject *Py_UNUSED(self), PyObject *args) +_ctypes_getattr(PyObject *Py_UNUSED(module), PyObject *name) { - PyObject *name; - if (!PyArg_UnpackTuple(args, "__getattr__", 1, 1, &name)) { - return NULL; - } - if (PyUnicode_Check(name) && PyUnicode_EqualToUTF8(name, "__version__")) { if (PyErr_WarnEx(PyExc_DeprecationWarning, "'__version__' is deprecated and slated for " @@ -2017,37 +2212,39 @@ _ctypes_getattr(PyObject *Py_UNUSED(self), PyObject *args) PyMethodDef _ctypes_module_methods[] = { - {"__getattr__", _ctypes_getattr, METH_VARARGS}, - {"get_errno", get_errno, METH_NOARGS}, - {"set_errno", set_errno, METH_VARARGS}, - {"_unpickle", unpickle, METH_VARARGS }, - {"buffer_info", buffer_info, METH_O, "Return buffer interface information"}, + {"__getattr__", _ctypes_getattr, METH_O}, + _CTYPES_GET_ERRNO_METHODDEF + _CTYPES_SET_ERRNO_METHODDEF + _CTYPES__UNPICKLE_METHODDEF + _CTYPES_BUFFER_INFO_METHODDEF _CTYPES_RESIZE_METHODDEF #ifdef MS_WIN32 - {"get_last_error", get_last_error, METH_NOARGS}, - {"set_last_error", set_last_error, METH_VARARGS}, - {"CopyComPointer", copy_com_pointer, METH_VARARGS, copy_com_pointer_doc}, - {"FormatError", format_error, METH_VARARGS, format_error_doc}, - {"LoadLibrary", load_library, METH_VARARGS, load_library_doc}, - {"FreeLibrary", free_library, METH_VARARGS, free_library_doc}, - {"_check_HRESULT", check_hresult, METH_VARARGS}, + _CTYPES_GET_LAST_ERROR_METHODDEF + _CTYPES_SET_LAST_ERROR_METHODDEF + _CTYPES_COPYCOMPOINTER_METHODDEF + _CTYPES_FORMATERROR_METHODDEF + _CTYPES_LOADLIBRARY_METHODDEF + _CTYPES_FREELIBRARY_METHODDEF + _CTYPES__CHECK_HRESULT_METHODDEF #else - {"dlopen", py_dl_open, METH_VARARGS, - "dlopen(name, flag={RTLD_GLOBAL|RTLD_LOCAL}) open a shared library"}, - {"dlclose", py_dl_close, METH_VARARGS, "dlclose a library"}, - {"dlsym", py_dl_sym, METH_VARARGS, "find symbol in shared library"}, + _CTYPES_DLOPEN_METHODDEF + _CTYPES_DLCLOSE_METHODDEF + _CTYPES_DLSYM_METHODDEF +#if defined(HAVE_DL_ITERATE_PHDR) && !defined(__APPLE__) + _CTYPES_DLLIST_METHODDEF +#endif #endif #ifdef __APPLE__ - {"_dyld_shared_cache_contains_path", py_dyld_shared_cache_contains_path, METH_VARARGS, "check if path is in the shared cache"}, + _CTYPES__DYLD_SHARED_CACHE_CONTAINS_PATH_METHODDEF #endif - {"alignment", align_func, METH_O, alignment_doc}, + _CTYPES_ALIGNMENT_METHODDEF _CTYPES_SIZEOF_METHODDEF _CTYPES_BYREF_METHODDEF _CTYPES_ADDRESSOF_METHODDEF - {"call_function", call_function, METH_VARARGS }, - {"call_cdeclfunction", call_cdeclfunction, METH_VARARGS }, - {"PyObj_FromPtr", My_PyObj_FromPtr, METH_VARARGS }, - {"Py_INCREF", My_Py_INCREF, METH_O }, - {"Py_DECREF", My_Py_DECREF, METH_O }, + _CTYPES_CALL_FUNCTION_METHODDEF + _CTYPES_CALL_CDECLFUNCTION_METHODDEF + _CTYPES_PYOBJ_FROMPTR_METHODDEF + _CTYPES_PY_INCREF_METHODDEF + _CTYPES_PY_DECREF_METHODDEF {NULL, NULL} /* Sentinel */ }; diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index 00b075bccff6647..193c60a1afee85c 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -865,14 +865,14 @@ Zf_set_sw(void *ptr, PyObject *value, Py_ssize_t size) return NULL; } #ifdef WORDS_BIGENDIAN - if (PyFloat_Pack4(c.real, ptr, 1) - || PyFloat_Pack4(c.imag, ptr + sizeof(float), 1)) + if (PyFloat_Pack4((float)c.real, ptr, 1) + || PyFloat_Pack4((float)c.imag, ptr + sizeof(float), 1)) { return NULL; } #else - if (PyFloat_Pack4(c.real, ptr, 0) - || PyFloat_Pack4(c.imag, ptr + sizeof(float), 0)) + if (PyFloat_Pack4((float)c.real, ptr, 0) + || PyFloat_Pack4((float)c.imag, ptr + sizeof(float), 0)) { return NULL; } diff --git a/Modules/_ctypes/clinic/_ctypes.c.h b/Modules/_ctypes/clinic/_ctypes.c.h index 529872f0f17ebe9..7a3c4bba9fc2090 100644 --- a/Modules/_ctypes/clinic/_ctypes.c.h +++ b/Modules/_ctypes/clinic/_ctypes.c.h @@ -2,12 +2,10 @@ preserve [clinic start generated code]*/ -#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) -# include "pycore_runtime.h" // _Py_SINGLETON() -#endif #include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() -#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(_ctypes_CType_Type___sizeof____doc__, "__sizeof__($self, /)\n" @@ -31,16 +29,6 @@ _ctypes_CType_Type___sizeof__(PyObject *self, PyTypeObject *cls, PyObject *const return _ctypes_CType_Type___sizeof___impl(self, cls); } -#if !defined(_ctypes_CType_Type___pointer_type___DOCSTR) -# define _ctypes_CType_Type___pointer_type___DOCSTR NULL -#endif -#if defined(_CTYPES_CTYPE_TYPE___POINTER_TYPE___GETSETDEF) -# undef _CTYPES_CTYPE_TYPE___POINTER_TYPE___GETSETDEF -# define _CTYPES_CTYPE_TYPE___POINTER_TYPE___GETSETDEF {"__pointer_type__", (getter)_ctypes_CType_Type___pointer_type___get, (setter)_ctypes_CType_Type___pointer_type___set, _ctypes_CType_Type___pointer_type___DOCSTR}, -#else -# define _CTYPES_CTYPE_TYPE___POINTER_TYPE___GETSETDEF {"__pointer_type__", (getter)_ctypes_CType_Type___pointer_type___get, NULL, _ctypes_CType_Type___pointer_type___DOCSTR}, -#endif - static PyObject * _ctypes_CType_Type___pointer_type___get_impl(PyObject *self); @@ -50,24 +38,18 @@ _ctypes_CType_Type___pointer_type___get(PyObject *self, void *Py_UNUSED(context) return _ctypes_CType_Type___pointer_type___get_impl(self); } -#if !defined(_ctypes_CType_Type___pointer_type___DOCSTR) -# define _ctypes_CType_Type___pointer_type___DOCSTR NULL -#endif -#if defined(_CTYPES_CTYPE_TYPE___POINTER_TYPE___GETSETDEF) -# undef _CTYPES_CTYPE_TYPE___POINTER_TYPE___GETSETDEF -# define _CTYPES_CTYPE_TYPE___POINTER_TYPE___GETSETDEF {"__pointer_type__", (getter)_ctypes_CType_Type___pointer_type___get, (setter)_ctypes_CType_Type___pointer_type___set, _ctypes_CType_Type___pointer_type___DOCSTR}, -#else -# define _CTYPES_CTYPE_TYPE___POINTER_TYPE___GETSETDEF {"__pointer_type__", NULL, (setter)_ctypes_CType_Type___pointer_type___set, NULL}, -#endif - static int _ctypes_CType_Type___pointer_type___set_impl(PyObject *self, PyObject *value); static int -_ctypes_CType_Type___pointer_type___set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ctypes_CType_Type___pointer_type___set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + PyObject *value = NULL; + if (arg != NULL) { + value = arg; + } return_value = _ctypes_CType_Type___pointer_type___set_impl(self, value); return return_value; @@ -92,25 +74,12 @@ static PyObject * CDataType_from_address(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "from_address", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("from_address", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("from_address", nargs, 1, 1)) { goto exit; } value = args[0]; @@ -139,31 +108,18 @@ static PyObject * CDataType_from_buffer(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "from_buffer", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *obj; Py_ssize_t offset = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("from_buffer", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("from_buffer", nargs, 1, 2)) { goto exit; } obj = args[0]; if (nargs < 2) { - goto skip_optional_posonly; + goto skip_optional; } { Py_ssize_t ival = -1; @@ -182,7 +138,7 @@ CDataType_from_buffer(PyObject *type, PyTypeObject *cls, PyObject *const *args, goto exit; } } -skip_optional_posonly: +skip_optional: return_value = CDataType_from_buffer_impl(type, cls, obj, offset); exit: @@ -208,33 +164,20 @@ static PyObject * CDataType_from_buffer_copy(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "from_buffer_copy", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; Py_buffer buffer = {NULL, NULL}; Py_ssize_t offset = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("from_buffer_copy", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("from_buffer_copy", nargs, 1, 2)) { goto exit; } if (PyObject_GetBuffer(args[0], &buffer, PyBUF_SIMPLE) != 0) { goto exit; } if (nargs < 2) { - goto skip_optional_posonly; + goto skip_optional; } { Py_ssize_t ival = -1; @@ -253,7 +196,7 @@ CDataType_from_buffer_copy(PyObject *type, PyTypeObject *cls, PyObject *const *a goto exit; } } -skip_optional_posonly: +skip_optional: return_value = CDataType_from_buffer_copy_impl(type, cls, &buffer, offset); exit: @@ -284,26 +227,13 @@ static PyObject * CDataType_in_dll(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "in_dll", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *dll; const char *name; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("in_dll", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("in_dll", nargs, 2, 2)) { goto exit; } dll = args[0]; @@ -311,15 +241,10 @@ CDataType_in_dll(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ss _PyArg_BadArgument("in_dll", "argument 2", "str", args[1]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(args[1], &name_length); + name = _PyUnicode_AsUTF8NoNUL(args[1]); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = CDataType_in_dll_impl(type, cls, dll, name); exit: @@ -342,25 +267,12 @@ static PyObject * CDataType_from_param(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "from_param", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("from_param", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("from_param", nargs, 1, 1)) { goto exit; } value = args[0]; @@ -386,25 +298,12 @@ static PyObject * PyCPointerType_set_type(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "set_type", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *type; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("set_type", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("set_type", nargs, 1, 1)) { goto exit; } type = args[0]; @@ -431,25 +330,12 @@ static PyObject * PyCPointerType_from_param(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "from_param", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("from_param", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("from_param", nargs, 1, 1)) { goto exit; } value = args[0]; @@ -459,41 +345,37 @@ PyCPointerType_from_param(PyObject *type, PyTypeObject *cls, PyObject *const *ar return return_value; } -#if !defined(_ctypes_PyCArrayType_Type_raw_DOCSTR) -# define _ctypes_PyCArrayType_Type_raw_DOCSTR NULL -#endif -#if defined(_CTYPES_PYCARRAYTYPE_TYPE_RAW_GETSETDEF) -# undef _CTYPES_PYCARRAYTYPE_TYPE_RAW_GETSETDEF -# define _CTYPES_PYCARRAYTYPE_TYPE_RAW_GETSETDEF {"raw", (getter)_ctypes_PyCArrayType_Type_raw_get, (setter)_ctypes_PyCArrayType_Type_raw_set, _ctypes_PyCArrayType_Type_raw_DOCSTR}, -#else -# define _CTYPES_PYCARRAYTYPE_TYPE_RAW_GETSETDEF {"raw", NULL, (setter)_ctypes_PyCArrayType_Type_raw_set, NULL}, -#endif - static int -_ctypes_PyCArrayType_Type_raw_set_impl(CDataObject *self, PyObject *value); +_ctypes_PyCArrayType_Type_raw_set_impl(CDataObject *self, Py_buffer *value); static int -_ctypes_PyCArrayType_Type_raw_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ctypes_PyCArrayType_Type_raw_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; - + int return_value = -1; + Py_buffer value = {NULL, NULL}; + + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'raw' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + if (PyObject_GetBuffer(arg, &value, PyBUF_SIMPLE) != 0) { + goto exit; + } Py_BEGIN_CRITICAL_SECTION(self); - return_value = _ctypes_PyCArrayType_Type_raw_set_impl((CDataObject *)self, value); + return_value = _ctypes_PyCArrayType_Type_raw_set_impl((CDataObject *)self, &value); Py_END_CRITICAL_SECTION(); +exit: + /* Cleanup for value */ + if (value.obj) { + PyBuffer_Release(&value); + } + return return_value; } -#if !defined(_ctypes_PyCArrayType_Type_raw_DOCSTR) -# define _ctypes_PyCArrayType_Type_raw_DOCSTR NULL -#endif -#if defined(_CTYPES_PYCARRAYTYPE_TYPE_RAW_GETSETDEF) -# undef _CTYPES_PYCARRAYTYPE_TYPE_RAW_GETSETDEF -# define _CTYPES_PYCARRAYTYPE_TYPE_RAW_GETSETDEF {"raw", (getter)_ctypes_PyCArrayType_Type_raw_get, (setter)_ctypes_PyCArrayType_Type_raw_set, _ctypes_PyCArrayType_Type_raw_DOCSTR}, -#else -# define _CTYPES_PYCARRAYTYPE_TYPE_RAW_GETSETDEF {"raw", (getter)_ctypes_PyCArrayType_Type_raw_get, NULL, _ctypes_PyCArrayType_Type_raw_DOCSTR}, -#endif - static PyObject * _ctypes_PyCArrayType_Type_raw_get_impl(CDataObject *self); @@ -509,16 +391,6 @@ _ctypes_PyCArrayType_Type_raw_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_ctypes_PyCArrayType_Type_value_DOCSTR) -# define _ctypes_PyCArrayType_Type_value_DOCSTR NULL -#endif -#if defined(_CTYPES_PYCARRAYTYPE_TYPE_VALUE_GETSETDEF) -# undef _CTYPES_PYCARRAYTYPE_TYPE_VALUE_GETSETDEF -# define _CTYPES_PYCARRAYTYPE_TYPE_VALUE_GETSETDEF {"value", (getter)_ctypes_PyCArrayType_Type_value_get, (setter)_ctypes_PyCArrayType_Type_value_set, _ctypes_PyCArrayType_Type_value_DOCSTR}, -#else -# define _CTYPES_PYCARRAYTYPE_TYPE_VALUE_GETSETDEF {"value", (getter)_ctypes_PyCArrayType_Type_value_get, NULL, _ctypes_PyCArrayType_Type_value_DOCSTR}, -#endif - static PyObject * _ctypes_PyCArrayType_Type_value_get_impl(CDataObject *self); @@ -534,28 +406,32 @@ _ctypes_PyCArrayType_Type_value_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_ctypes_PyCArrayType_Type_value_DOCSTR) -# define _ctypes_PyCArrayType_Type_value_DOCSTR NULL -#endif -#if defined(_CTYPES_PYCARRAYTYPE_TYPE_VALUE_GETSETDEF) -# undef _CTYPES_PYCARRAYTYPE_TYPE_VALUE_GETSETDEF -# define _CTYPES_PYCARRAYTYPE_TYPE_VALUE_GETSETDEF {"value", (getter)_ctypes_PyCArrayType_Type_value_get, (setter)_ctypes_PyCArrayType_Type_value_set, _ctypes_PyCArrayType_Type_value_DOCSTR}, -#else -# define _CTYPES_PYCARRAYTYPE_TYPE_VALUE_GETSETDEF {"value", NULL, (setter)_ctypes_PyCArrayType_Type_value_set, NULL}, -#endif - static int -_ctypes_PyCArrayType_Type_value_set_impl(CDataObject *self, PyObject *value); +_ctypes_PyCArrayType_Type_value_set_impl(CDataObject *self, + PyBytesObject *value); static int -_ctypes_PyCArrayType_Type_value_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ctypes_PyCArrayType_Type_value_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; - + int return_value = -1; + PyBytesObject *value; + + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'value' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + if (!PyBytes_Check(arg)) { + PyErr_Format(PyExc_TypeError, "attribute 'value' must be bytes, not %T", arg); + goto exit; + } + value = (PyBytesObject *)arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = _ctypes_PyCArrayType_Type_value_set_impl((CDataObject *)self, value); Py_END_CRITICAL_SECTION(); +exit: return return_value; } @@ -574,25 +450,12 @@ static PyObject * c_wchar_p_from_param(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "from_param", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("from_param", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("from_param", nargs, 1, 1)) { goto exit; } value = args[0]; @@ -617,25 +480,12 @@ static PyObject * c_char_p_from_param(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "from_param", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("from_param", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("from_param", nargs, 1, 1)) { goto exit; } value = args[0]; @@ -660,25 +510,12 @@ static PyObject * c_void_p_from_param(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "from_param", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("from_param", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("from_param", nargs, 1, 1)) { goto exit; } value = args[0]; @@ -705,25 +542,12 @@ static PyObject * PyCSimpleType_from_param(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "from_param", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("from_param", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("from_param", nargs, 1, 1)) { goto exit; } value = args[0]; @@ -781,7 +605,7 @@ _ctypes_PyCData___setstate__(PyObject *myself, PyObject *const *args, Py_ssize_t const char *data; Py_ssize_t data_length; - if (!_PyArg_ParseStack(args, nargs, "O!s#:__setstate__", + if (!PyArg_ParseArray(args, nargs, "O!s#:__setstate__", &PyDict_Type, &dict, &data, &data_length)) { goto exit; } @@ -811,24 +635,18 @@ _ctypes_PyCData___ctypes_from_outparam__(PyObject *self, PyObject *Py_UNUSED(ign return _ctypes_PyCData___ctypes_from_outparam___impl(self); } -#if !defined(_ctypes_CFuncPtr_errcheck_DOCSTR) -# define _ctypes_CFuncPtr_errcheck_DOCSTR NULL -#endif -#if defined(_CTYPES_CFUNCPTR_ERRCHECK_GETSETDEF) -# undef _CTYPES_CFUNCPTR_ERRCHECK_GETSETDEF -# define _CTYPES_CFUNCPTR_ERRCHECK_GETSETDEF {"errcheck", (getter)_ctypes_CFuncPtr_errcheck_get, (setter)_ctypes_CFuncPtr_errcheck_set, _ctypes_CFuncPtr_errcheck_DOCSTR}, -#else -# define _CTYPES_CFUNCPTR_ERRCHECK_GETSETDEF {"errcheck", NULL, (setter)_ctypes_CFuncPtr_errcheck_set, NULL}, -#endif - static int _ctypes_CFuncPtr_errcheck_set_impl(PyCFuncPtrObject *self, PyObject *value); static int -_ctypes_CFuncPtr_errcheck_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ctypes_CFuncPtr_errcheck_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + PyObject *value = NULL; + if (arg != NULL) { + value = arg; + } Py_BEGIN_CRITICAL_SECTION(self); return_value = _ctypes_CFuncPtr_errcheck_set_impl((PyCFuncPtrObject *)self, value); Py_END_CRITICAL_SECTION(); @@ -838,20 +656,6 @@ _ctypes_CFuncPtr_errcheck_set(PyObject *self, PyObject *value, void *Py_UNUSED(c PyDoc_STRVAR(_ctypes_CFuncPtr_errcheck__doc__, "a function to check for errors"); -#if defined(_ctypes_CFuncPtr_errcheck_DOCSTR) -# undef _ctypes_CFuncPtr_errcheck_DOCSTR -#endif -#define _ctypes_CFuncPtr_errcheck_DOCSTR _ctypes_CFuncPtr_errcheck__doc__ - -#if !defined(_ctypes_CFuncPtr_errcheck_DOCSTR) -# define _ctypes_CFuncPtr_errcheck_DOCSTR NULL -#endif -#if defined(_CTYPES_CFUNCPTR_ERRCHECK_GETSETDEF) -# undef _CTYPES_CFUNCPTR_ERRCHECK_GETSETDEF -# define _CTYPES_CFUNCPTR_ERRCHECK_GETSETDEF {"errcheck", (getter)_ctypes_CFuncPtr_errcheck_get, (setter)_ctypes_CFuncPtr_errcheck_set, _ctypes_CFuncPtr_errcheck_DOCSTR}, -#else -# define _CTYPES_CFUNCPTR_ERRCHECK_GETSETDEF {"errcheck", (getter)_ctypes_CFuncPtr_errcheck_get, NULL, _ctypes_CFuncPtr_errcheck_DOCSTR}, -#endif static PyObject * _ctypes_CFuncPtr_errcheck_get_impl(PyCFuncPtrObject *self); @@ -868,24 +672,18 @@ _ctypes_CFuncPtr_errcheck_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_ctypes_CFuncPtr_restype_DOCSTR) -# define _ctypes_CFuncPtr_restype_DOCSTR NULL -#endif -#if defined(_CTYPES_CFUNCPTR_RESTYPE_GETSETDEF) -# undef _CTYPES_CFUNCPTR_RESTYPE_GETSETDEF -# define _CTYPES_CFUNCPTR_RESTYPE_GETSETDEF {"restype", (getter)_ctypes_CFuncPtr_restype_get, (setter)_ctypes_CFuncPtr_restype_set, _ctypes_CFuncPtr_restype_DOCSTR}, -#else -# define _CTYPES_CFUNCPTR_RESTYPE_GETSETDEF {"restype", NULL, (setter)_ctypes_CFuncPtr_restype_set, NULL}, -#endif - static int _ctypes_CFuncPtr_restype_set_impl(PyCFuncPtrObject *self, PyObject *value); static int -_ctypes_CFuncPtr_restype_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ctypes_CFuncPtr_restype_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + PyObject *value = NULL; + if (arg != NULL) { + value = arg; + } Py_BEGIN_CRITICAL_SECTION(self); return_value = _ctypes_CFuncPtr_restype_set_impl((PyCFuncPtrObject *)self, value); Py_END_CRITICAL_SECTION(); @@ -895,20 +693,6 @@ _ctypes_CFuncPtr_restype_set(PyObject *self, PyObject *value, void *Py_UNUSED(co PyDoc_STRVAR(_ctypes_CFuncPtr_restype__doc__, "specify the result type"); -#if defined(_ctypes_CFuncPtr_restype_DOCSTR) -# undef _ctypes_CFuncPtr_restype_DOCSTR -#endif -#define _ctypes_CFuncPtr_restype_DOCSTR _ctypes_CFuncPtr_restype__doc__ - -#if !defined(_ctypes_CFuncPtr_restype_DOCSTR) -# define _ctypes_CFuncPtr_restype_DOCSTR NULL -#endif -#if defined(_CTYPES_CFUNCPTR_RESTYPE_GETSETDEF) -# undef _CTYPES_CFUNCPTR_RESTYPE_GETSETDEF -# define _CTYPES_CFUNCPTR_RESTYPE_GETSETDEF {"restype", (getter)_ctypes_CFuncPtr_restype_get, (setter)_ctypes_CFuncPtr_restype_set, _ctypes_CFuncPtr_restype_DOCSTR}, -#else -# define _CTYPES_CFUNCPTR_RESTYPE_GETSETDEF {"restype", (getter)_ctypes_CFuncPtr_restype_get, NULL, _ctypes_CFuncPtr_restype_DOCSTR}, -#endif static PyObject * _ctypes_CFuncPtr_restype_get_impl(PyCFuncPtrObject *self); @@ -925,24 +709,18 @@ _ctypes_CFuncPtr_restype_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_ctypes_CFuncPtr_argtypes_DOCSTR) -# define _ctypes_CFuncPtr_argtypes_DOCSTR NULL -#endif -#if defined(_CTYPES_CFUNCPTR_ARGTYPES_GETSETDEF) -# undef _CTYPES_CFUNCPTR_ARGTYPES_GETSETDEF -# define _CTYPES_CFUNCPTR_ARGTYPES_GETSETDEF {"argtypes", (getter)_ctypes_CFuncPtr_argtypes_get, (setter)_ctypes_CFuncPtr_argtypes_set, _ctypes_CFuncPtr_argtypes_DOCSTR}, -#else -# define _CTYPES_CFUNCPTR_ARGTYPES_GETSETDEF {"argtypes", NULL, (setter)_ctypes_CFuncPtr_argtypes_set, NULL}, -#endif - static int _ctypes_CFuncPtr_argtypes_set_impl(PyCFuncPtrObject *self, PyObject *value); static int -_ctypes_CFuncPtr_argtypes_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ctypes_CFuncPtr_argtypes_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + PyObject *value = NULL; + if (arg != NULL) { + value = arg; + } Py_BEGIN_CRITICAL_SECTION(self); return_value = _ctypes_CFuncPtr_argtypes_set_impl((PyCFuncPtrObject *)self, value); Py_END_CRITICAL_SECTION(); @@ -952,20 +730,6 @@ _ctypes_CFuncPtr_argtypes_set(PyObject *self, PyObject *value, void *Py_UNUSED(c PyDoc_STRVAR(_ctypes_CFuncPtr_argtypes__doc__, "specify the argument types"); -#if defined(_ctypes_CFuncPtr_argtypes_DOCSTR) -# undef _ctypes_CFuncPtr_argtypes_DOCSTR -#endif -#define _ctypes_CFuncPtr_argtypes_DOCSTR _ctypes_CFuncPtr_argtypes__doc__ - -#if !defined(_ctypes_CFuncPtr_argtypes_DOCSTR) -# define _ctypes_CFuncPtr_argtypes_DOCSTR NULL -#endif -#if defined(_CTYPES_CFUNCPTR_ARGTYPES_GETSETDEF) -# undef _CTYPES_CFUNCPTR_ARGTYPES_GETSETDEF -# define _CTYPES_CFUNCPTR_ARGTYPES_GETSETDEF {"argtypes", (getter)_ctypes_CFuncPtr_argtypes_get, (setter)_ctypes_CFuncPtr_argtypes_set, _ctypes_CFuncPtr_argtypes_DOCSTR}, -#else -# define _CTYPES_CFUNCPTR_ARGTYPES_GETSETDEF {"argtypes", (getter)_ctypes_CFuncPtr_argtypes_get, NULL, _ctypes_CFuncPtr_argtypes_DOCSTR}, -#endif static PyObject * _ctypes_CFuncPtr_argtypes_get_impl(PyCFuncPtrObject *self); @@ -982,24 +746,82 @@ _ctypes_CFuncPtr_argtypes_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_ctypes_Simple_value_DOCSTR) -# define _ctypes_Simple_value_DOCSTR NULL -#endif -#if defined(_CTYPES_SIMPLE_VALUE_GETSETDEF) -# undef _CTYPES_SIMPLE_VALUE_GETSETDEF -# define _CTYPES_SIMPLE_VALUE_GETSETDEF {"value", (getter)_ctypes_Simple_value_get, (setter)_ctypes_Simple_value_set, _ctypes_Simple_value_DOCSTR}, -#else -# define _CTYPES_SIMPLE_VALUE_GETSETDEF {"value", NULL, (setter)_ctypes_Simple_value_set, NULL}, -#endif +static PyObject * +Array_item_impl(PyObject *myself, Py_ssize_t index); + +static PyObject * +Array_item(PyObject *myself, Py_ssize_t index) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(myself); + return_value = Array_item_impl(myself, index); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static PyObject * +Array_subscript_impl(PyObject *myself, PyObject *item); + +static PyObject * +Array_subscript(PyObject *myself, PyObject *item) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(myself); + return_value = Array_subscript_impl(myself, item); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static int +Array_ass_item_impl(PyObject *myself, Py_ssize_t index, PyObject *value); + +static int +Array_ass_item(PyObject *myself, Py_ssize_t index, PyObject *value) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(myself); + return_value = Array_ass_item_impl(myself, index, value); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static int +Array_ass_subscript_impl(PyObject *myself, PyObject *item, PyObject *value); + +static int +Array_ass_subscript(PyObject *myself, PyObject *item, PyObject *value) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(myself); + return_value = Array_ass_subscript_impl(myself, item, value); + Py_END_CRITICAL_SECTION(); + + return return_value; +} static int _ctypes_Simple_value_set_impl(CDataObject *self, PyObject *value); static int -_ctypes_Simple_value_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ctypes_Simple_value_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + PyObject *value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'value' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = _ctypes_Simple_value_set_impl((CDataObject *)self, value); Py_END_CRITICAL_SECTION(); @@ -1007,16 +829,6 @@ _ctypes_Simple_value_set(PyObject *self, PyObject *value, void *Py_UNUSED(contex return return_value; } -#if !defined(_ctypes_Simple_value_DOCSTR) -# define _ctypes_Simple_value_DOCSTR NULL -#endif -#if defined(_CTYPES_SIMPLE_VALUE_GETSETDEF) -# undef _CTYPES_SIMPLE_VALUE_GETSETDEF -# define _CTYPES_SIMPLE_VALUE_GETSETDEF {"value", (getter)_ctypes_Simple_value_get, (setter)_ctypes_Simple_value_set, _ctypes_Simple_value_DOCSTR}, -#else -# define _CTYPES_SIMPLE_VALUE_GETSETDEF {"value", (getter)_ctypes_Simple_value_get, NULL, _ctypes_Simple_value_DOCSTR}, -#endif - static PyObject * _ctypes_Simple_value_get_impl(CDataObject *self); @@ -1052,4 +864,78 @@ Simple_from_outparm(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py } return Simple_from_outparm_impl(self, cls); } -/*[clinic end generated code: output=22105663d71237ca input=a9049054013a1b77]*/ + +static int +Simple_bool_impl(CDataObject *self); + +static int +Simple_bool(PyObject *self) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = Simple_bool_impl((CDataObject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static PyObject * +Pointer_item_impl(PyObject *myself, Py_ssize_t index); + +static PyObject * +Pointer_item(PyObject *myself, Py_ssize_t index) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(myself); + return_value = Pointer_item_impl(myself, index); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static int +Pointer_ass_item_impl(PyObject *myself, Py_ssize_t index, PyObject *value); + +static int +Pointer_ass_item(PyObject *myself, Py_ssize_t index, PyObject *value) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(myself); + return_value = Pointer_ass_item_impl(myself, index, value); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static int +Pointer_bool_impl(PyObject *self); + +static int +Pointer_bool(PyObject *self) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = Pointer_bool_impl(self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} +#define _CTYPES_CTYPE_TYPE___POINTER_TYPE___GETSETDEF {"__pointer_type__", (getter)_ctypes_CType_Type___pointer_type___get, (setter)_ctypes_CType_Type___pointer_type___set, NULL}, + +#define _CTYPES_PYCARRAYTYPE_TYPE_RAW_GETSETDEF {"raw", (getter)_ctypes_PyCArrayType_Type_raw_get, (setter)_ctypes_PyCArrayType_Type_raw_set, NULL}, + +#define _CTYPES_PYCARRAYTYPE_TYPE_VALUE_GETSETDEF {"value", (getter)_ctypes_PyCArrayType_Type_value_get, (setter)_ctypes_PyCArrayType_Type_value_set, NULL}, + +#define _CTYPES_CFUNCPTR_ERRCHECK_GETSETDEF {"errcheck", (getter)_ctypes_CFuncPtr_errcheck_get, (setter)_ctypes_CFuncPtr_errcheck_set, _ctypes_CFuncPtr_errcheck__doc__}, + +#define _CTYPES_CFUNCPTR_RESTYPE_GETSETDEF {"restype", (getter)_ctypes_CFuncPtr_restype_get, (setter)_ctypes_CFuncPtr_restype_set, _ctypes_CFuncPtr_restype__doc__}, + +#define _CTYPES_CFUNCPTR_ARGTYPES_GETSETDEF {"argtypes", (getter)_ctypes_CFuncPtr_argtypes_get, (setter)_ctypes_CFuncPtr_argtypes_set, _ctypes_CFuncPtr_argtypes__doc__}, + +#define _CTYPES_SIMPLE_VALUE_GETSETDEF {"value", (getter)_ctypes_Simple_value_get, (setter)_ctypes_Simple_value_set, NULL}, + +/*[clinic end generated code: output=5d9dd4bbae13cfca input=a9049054013a1b77]*/ diff --git a/Modules/_ctypes/clinic/callproc.c.h b/Modules/_ctypes/clinic/callproc.c.h index e0cfcc6f38def7e..82cb08ff00dfb03 100644 --- a/Modules/_ctypes/clinic/callproc.c.h +++ b/Modules/_ctypes/clinic/callproc.c.h @@ -5,6 +5,512 @@ preserve #include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() + +PyDoc_STRVAR(_ctypes_get_errno__doc__, +"get_errno($module, /)\n" +"--\n" +"\n" +"Return the current value of the ctypes-private copy of errno."); + +#define _CTYPES_GET_ERRNO_METHODDEF \ + {"get_errno", (PyCFunction)_ctypes_get_errno, METH_NOARGS, _ctypes_get_errno__doc__}, + +static PyObject * +_ctypes_get_errno_impl(PyObject *module); + +static PyObject * +_ctypes_get_errno(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _ctypes_get_errno_impl(module); +} + +PyDoc_STRVAR(_ctypes_set_errno__doc__, +"set_errno($module, value, /)\n" +"--\n" +"\n"); + +#define _CTYPES_SET_ERRNO_METHODDEF \ + {"set_errno", (PyCFunction)_ctypes_set_errno, METH_O, _ctypes_set_errno__doc__}, + +static PyObject * +_ctypes_set_errno_impl(PyObject *module, int value); + +static PyObject * +_ctypes_set_errno(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int value; + + value = PyLong_AsInt(arg); + if (value == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _ctypes_set_errno_impl(module, value); + +exit: + return return_value; +} + +#if defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_get_last_error__doc__, +"get_last_error($module, /)\n" +"--\n" +"\n" +"Return the current value of the ctypes-private copy of the last error."); + +#define _CTYPES_GET_LAST_ERROR_METHODDEF \ + {"get_last_error", (PyCFunction)_ctypes_get_last_error, METH_NOARGS, _ctypes_get_last_error__doc__}, + +static PyObject * +_ctypes_get_last_error_impl(PyObject *module); + +static PyObject * +_ctypes_get_last_error(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _ctypes_get_last_error_impl(module); +} + +#endif /* defined(MS_WIN32) */ + +#if defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_set_last_error__doc__, +"set_last_error($module, value, /)\n" +"--\n" +"\n"); + +#define _CTYPES_SET_LAST_ERROR_METHODDEF \ + {"set_last_error", (PyCFunction)_ctypes_set_last_error, METH_O, _ctypes_set_last_error__doc__}, + +static PyObject * +_ctypes_set_last_error_impl(PyObject *module, int value); + +static PyObject * +_ctypes_set_last_error(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int value; + + value = PyLong_AsInt(arg); + if (value == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _ctypes_set_last_error_impl(module, value); + +exit: + return return_value; +} + +#endif /* defined(MS_WIN32) */ + +#if defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes__check_HRESULT__doc__, +"_check_HRESULT($module, hresult, /)\n" +"--\n" +"\n"); + +#define _CTYPES__CHECK_HRESULT_METHODDEF \ + {"_check_HRESULT", (PyCFunction)_ctypes__check_HRESULT, METH_O, _ctypes__check_HRESULT__doc__}, + +static PyObject * +_ctypes__check_HRESULT_impl(PyObject *module, int hr); + +static PyObject * +_ctypes__check_HRESULT(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int hr; + + hr = PyLong_AsInt(arg); + if (hr == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _ctypes__check_HRESULT_impl(module, hr); + +exit: + return return_value; +} + +#endif /* defined(MS_WIN32) */ + +#if defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_FormatError__doc__, +"FormatError($module, code=0, /)\n" +"--\n" +"\n" +"Convert a win32 error code into a string.\n" +"\n" +"If the error code is not given, the return value of a call to\n" +"GetLastError() is used."); + +#define _CTYPES_FORMATERROR_METHODDEF \ + {"FormatError", _PyCFunction_CAST(_ctypes_FormatError), METH_FASTCALL, _ctypes_FormatError__doc__}, + +static PyObject * +_ctypes_FormatError_impl(PyObject *module, int code); + +static PyObject * +_ctypes_FormatError(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int code = 0; + + if (!_PyArg_CheckPositional("FormatError", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + code = PyLong_AsInt(args[0]); + if (code == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _ctypes_FormatError_impl(module, code); + +exit: + return return_value; +} + +#endif /* defined(MS_WIN32) */ + +#if defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_LoadLibrary__doc__, +"LoadLibrary($module, name, load_flags=0, /)\n" +"--\n" +"\n" +"Load an executable (usually a DLL), and return a handle to it.\n" +"\n" +"The handle may be used to locate exported functions in this module.\n" +"load_flags are as defined for LoadLibraryEx in the Windows API."); + +#define _CTYPES_LOADLIBRARY_METHODDEF \ + {"LoadLibrary", _PyCFunction_CAST(_ctypes_LoadLibrary), METH_FASTCALL, _ctypes_LoadLibrary__doc__}, + +static PyObject * +_ctypes_LoadLibrary_impl(PyObject *module, PyObject *nameobj, int load_flags); + +static PyObject * +_ctypes_LoadLibrary(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *nameobj; + int load_flags = 0; + + if (!_PyArg_CheckPositional("LoadLibrary", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("LoadLibrary", "argument 1", "str", args[0]); + goto exit; + } + nameobj = args[0]; + if (nargs < 2) { + goto skip_optional; + } + load_flags = PyLong_AsInt(args[1]); + if (load_flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _ctypes_LoadLibrary_impl(module, nameobj, load_flags); + +exit: + return return_value; +} + +#endif /* defined(MS_WIN32) */ + +#if defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_FreeLibrary__doc__, +"FreeLibrary($module, handle, /)\n" +"--\n" +"\n" +"Free the handle of an executable previously loaded by LoadLibrary."); + +#define _CTYPES_FREELIBRARY_METHODDEF \ + {"FreeLibrary", (PyCFunction)_ctypes_FreeLibrary, METH_O, _ctypes_FreeLibrary__doc__}, + +static PyObject * +_ctypes_FreeLibrary_impl(PyObject *module, void *hMod); + +static PyObject * +_ctypes_FreeLibrary(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + void *hMod; + + if (!_parse_voidp(arg, &hMod)) { + goto exit; + } + return_value = _ctypes_FreeLibrary_impl(module, hMod); + +exit: + return return_value; +} + +#endif /* defined(MS_WIN32) */ + +#if defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_CopyComPointer__doc__, +"CopyComPointer($module, src, dst, /)\n" +"--\n" +"\n" +"Copy a COM pointer and return the HRESULT value."); + +#define _CTYPES_COPYCOMPOINTER_METHODDEF \ + {"CopyComPointer", _PyCFunction_CAST(_ctypes_CopyComPointer), METH_FASTCALL, _ctypes_CopyComPointer__doc__}, + +static PyObject * +_ctypes_CopyComPointer_impl(PyObject *module, PyObject *p1, PyObject *p2); + +static PyObject * +_ctypes_CopyComPointer(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *p1; + PyObject *p2; + + if (!_PyArg_CheckPositional("CopyComPointer", nargs, 2, 2)) { + goto exit; + } + p1 = args[0]; + p2 = args[1]; + return_value = _ctypes_CopyComPointer_impl(module, p1, p2); + +exit: + return return_value; +} + +#endif /* defined(MS_WIN32) */ + +#if !defined(MS_WIN32) && defined(__APPLE__) + +PyDoc_STRVAR(_ctypes__dyld_shared_cache_contains_path__doc__, +"_dyld_shared_cache_contains_path($module, path, /)\n" +"--\n" +"\n" +"Check whether a path is in the shared cache."); + +#define _CTYPES__DYLD_SHARED_CACHE_CONTAINS_PATH_METHODDEF \ + {"_dyld_shared_cache_contains_path", (PyCFunction)_ctypes__dyld_shared_cache_contains_path, METH_O, _ctypes__dyld_shared_cache_contains_path__doc__}, + +#endif /* !defined(MS_WIN32) && defined(__APPLE__) */ + +#if !defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_dlopen__doc__, +"dlopen($module, name, mode=RTLD_NOW | RTLD_LOCAL, /)\n" +"--\n" +"\n" +"Open a shared library."); + +#define _CTYPES_DLOPEN_METHODDEF \ + {"dlopen", _PyCFunction_CAST(_ctypes_dlopen), METH_FASTCALL, _ctypes_dlopen__doc__}, + +static PyObject * +_ctypes_dlopen_impl(PyObject *module, PyObject *name, int mode); + +static PyObject * +_ctypes_dlopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *name; + int mode = DLOPEN_DEFAULT_MODE; + + if (!_PyArg_CheckPositional("dlopen", nargs, 1, 2)) { + goto exit; + } + name = args[0]; + if (nargs < 2) { + goto skip_optional; + } + mode = PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _ctypes_dlopen_impl(module, name, mode); + +exit: + return return_value; +} + +#endif /* !defined(MS_WIN32) */ + +#if !defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_dlclose__doc__, +"dlclose($module, handle, /)\n" +"--\n" +"\n" +"Close a shared library."); + +#define _CTYPES_DLCLOSE_METHODDEF \ + {"dlclose", (PyCFunction)_ctypes_dlclose, METH_O, _ctypes_dlclose__doc__}, + +static PyObject * +_ctypes_dlclose_impl(PyObject *module, void *handle); + +static PyObject * +_ctypes_dlclose(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + void *handle; + + if (!_parse_voidp(arg, &handle)) { + goto exit; + } + return_value = _ctypes_dlclose_impl(module, handle); + +exit: + return return_value; +} + +#endif /* !defined(MS_WIN32) */ + +#if !defined(MS_WIN32) + +PyDoc_STRVAR(_ctypes_dlsym__doc__, +"dlsym($module, handle, name, /)\n" +"--\n" +"\n" +"Find a symbol in a shared library."); + +#define _CTYPES_DLSYM_METHODDEF \ + {"dlsym", _PyCFunction_CAST(_ctypes_dlsym), METH_FASTCALL, _ctypes_dlsym__doc__}, + +static PyObject * +_ctypes_dlsym_impl(PyObject *module, void *handle, const char *name); + +static PyObject * +_ctypes_dlsym(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + void *handle; + const char *name; + + if (!_PyArg_CheckPositional("dlsym", nargs, 2, 2)) { + goto exit; + } + if (!_parse_voidp(args[0], &handle)) { + goto exit; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("dlsym", "argument 2", "str", args[1]); + goto exit; + } + name = _PyUnicode_AsUTF8NoNUL(args[1]); + if (name == NULL) { + goto exit; + } + return_value = _ctypes_dlsym_impl(module, handle, name); + +exit: + return return_value; +} + +#endif /* !defined(MS_WIN32) */ + +#if !defined(MS_WIN32) && (defined(HAVE_DL_ITERATE_PHDR) && !defined(__APPLE__)) + +PyDoc_STRVAR(_ctypes_dllist__doc__, +"dllist($module, /)\n" +"--\n" +"\n" +"Return a list of loaded shared libraries."); + +#define _CTYPES_DLLIST_METHODDEF \ + {"dllist", (PyCFunction)_ctypes_dllist, METH_NOARGS, _ctypes_dllist__doc__}, + +static PyObject * +_ctypes_dllist_impl(PyObject *module); + +static PyObject * +_ctypes_dllist(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _ctypes_dllist_impl(module); +} + +#endif /* !defined(MS_WIN32) && (defined(HAVE_DL_ITERATE_PHDR) && !defined(__APPLE__)) */ + +PyDoc_STRVAR(_ctypes_call_function__doc__, +"call_function($module, func, arguments, /)\n" +"--\n" +"\n"); + +#define _CTYPES_CALL_FUNCTION_METHODDEF \ + {"call_function", _PyCFunction_CAST(_ctypes_call_function), METH_FASTCALL, _ctypes_call_function__doc__}, + +static PyObject * +_ctypes_call_function_impl(PyObject *module, void *func, PyObject *arguments); + +static PyObject * +_ctypes_call_function(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + void *func; + PyObject *arguments; + + if (!_PyArg_CheckPositional("call_function", nargs, 2, 2)) { + goto exit; + } + if (!_parse_voidp(args[0], &func)) { + goto exit; + } + if (!PyTuple_Check(args[1])) { + _PyArg_BadArgument("call_function", "argument 2", "tuple", args[1]); + goto exit; + } + arguments = args[1]; + return_value = _ctypes_call_function_impl(module, func, arguments); + +exit: + return return_value; +} + +PyDoc_STRVAR(_ctypes_call_cdeclfunction__doc__, +"call_cdeclfunction($module, func, arguments, /)\n" +"--\n" +"\n"); + +#define _CTYPES_CALL_CDECLFUNCTION_METHODDEF \ + {"call_cdeclfunction", _PyCFunction_CAST(_ctypes_call_cdeclfunction), METH_FASTCALL, _ctypes_call_cdeclfunction__doc__}, + +static PyObject * +_ctypes_call_cdeclfunction_impl(PyObject *module, void *func, + PyObject *arguments); + +static PyObject * +_ctypes_call_cdeclfunction(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + void *func; + PyObject *arguments; + + if (!_PyArg_CheckPositional("call_cdeclfunction", nargs, 2, 2)) { + goto exit; + } + if (!_parse_voidp(args[0], &func)) { + goto exit; + } + if (!PyTuple_Check(args[1])) { + _PyArg_BadArgument("call_cdeclfunction", "argument 2", "tuple", args[1]); + goto exit; + } + arguments = args[1]; + return_value = _ctypes_call_cdeclfunction_impl(module, func, arguments); + +exit: + return return_value; +} PyDoc_STRVAR(_ctypes_sizeof__doc__, "sizeof($module, obj, /)\n" @@ -15,6 +521,17 @@ PyDoc_STRVAR(_ctypes_sizeof__doc__, #define _CTYPES_SIZEOF_METHODDEF \ {"sizeof", (PyCFunction)_ctypes_sizeof, METH_O, _ctypes_sizeof__doc__}, +PyDoc_STRVAR(_ctypes_alignment__doc__, +"alignment($module, obj, /)\n" +"--\n" +"\n" +"Return the alignment requirements of a C instance.\n" +"\n" +"The argument is a C type or a C instance."); + +#define _CTYPES_ALIGNMENT_METHODDEF \ + {"alignment", (PyCFunction)_ctypes_alignment, METH_O, _ctypes_alignment__doc__}, + PyDoc_STRVAR(_ctypes_byref__doc__, "byref($module, obj, offset=0, /)\n" "--\n" @@ -97,6 +614,50 @@ _ctypes_addressof(PyObject *module, PyObject *arg) return return_value; } +PyDoc_STRVAR(_ctypes_PyObj_FromPtr__doc__, +"PyObj_FromPtr($module, address, /)\n" +"--\n" +"\n"); + +#define _CTYPES_PYOBJ_FROMPTR_METHODDEF \ + {"PyObj_FromPtr", (PyCFunction)_ctypes_PyObj_FromPtr, METH_O, _ctypes_PyObj_FromPtr__doc__}, + +static PyObject * +_ctypes_PyObj_FromPtr_impl(PyObject *module, PyObject *ob); + +static PyObject * +_ctypes_PyObj_FromPtr(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + PyObject *ob; + + if (!_parse_voidp_object(arg, &ob)) { + goto exit; + } + return_value = _ctypes_PyObj_FromPtr_impl(module, ob); + +exit: + return return_value; +} + +PyDoc_STRVAR(_ctypes_Py_INCREF__doc__, +"Py_INCREF($module, obj, /)\n" +"--\n" +"\n" +"Increment the reference count of the object and return it."); + +#define _CTYPES_PY_INCREF_METHODDEF \ + {"Py_INCREF", (PyCFunction)_ctypes_Py_INCREF, METH_O, _ctypes_Py_INCREF__doc__}, + +PyDoc_STRVAR(_ctypes_Py_DECREF__doc__, +"Py_DECREF($module, obj, /)\n" +"--\n" +"\n" +"Decrement the reference count of the object and return it."); + +#define _CTYPES_PY_DECREF_METHODDEF \ + {"Py_DECREF", (PyCFunction)_ctypes_Py_DECREF, METH_O, _ctypes_Py_DECREF__doc__}, + PyDoc_STRVAR(_ctypes_resize__doc__, "resize($module, obj, size, /)\n" "--\n" @@ -142,4 +703,94 @@ _ctypes_resize(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=23c74aced603977d input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_ctypes__unpickle__doc__, +"_unpickle($module, cls, state, /)\n" +"--\n" +"\n"); + +#define _CTYPES__UNPICKLE_METHODDEF \ + {"_unpickle", _PyCFunction_CAST(_ctypes__unpickle), METH_FASTCALL, _ctypes__unpickle__doc__}, + +static PyObject * +_ctypes__unpickle_impl(PyObject *module, PyObject *typ, PyObject *state); + +static PyObject * +_ctypes__unpickle(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *typ; + PyObject *state; + + if (!_PyArg_CheckPositional("_unpickle", nargs, 2, 2)) { + goto exit; + } + typ = args[0]; + if (!PyTuple_Check(args[1])) { + _PyArg_BadArgument("_unpickle", "argument 2", "tuple", args[1]); + goto exit; + } + state = args[1]; + return_value = _ctypes__unpickle_impl(module, typ, state); + +exit: + return return_value; +} + +PyDoc_STRVAR(_ctypes_buffer_info__doc__, +"buffer_info($module, obj, /)\n" +"--\n" +"\n" +"Return buffer interface information."); + +#define _CTYPES_BUFFER_INFO_METHODDEF \ + {"buffer_info", (PyCFunction)_ctypes_buffer_info, METH_O, _ctypes_buffer_info__doc__}, + +#ifndef _CTYPES_GET_LAST_ERROR_METHODDEF + #define _CTYPES_GET_LAST_ERROR_METHODDEF +#endif /* !defined(_CTYPES_GET_LAST_ERROR_METHODDEF) */ + +#ifndef _CTYPES_SET_LAST_ERROR_METHODDEF + #define _CTYPES_SET_LAST_ERROR_METHODDEF +#endif /* !defined(_CTYPES_SET_LAST_ERROR_METHODDEF) */ + +#ifndef _CTYPES__CHECK_HRESULT_METHODDEF + #define _CTYPES__CHECK_HRESULT_METHODDEF +#endif /* !defined(_CTYPES__CHECK_HRESULT_METHODDEF) */ + +#ifndef _CTYPES_FORMATERROR_METHODDEF + #define _CTYPES_FORMATERROR_METHODDEF +#endif /* !defined(_CTYPES_FORMATERROR_METHODDEF) */ + +#ifndef _CTYPES_LOADLIBRARY_METHODDEF + #define _CTYPES_LOADLIBRARY_METHODDEF +#endif /* !defined(_CTYPES_LOADLIBRARY_METHODDEF) */ + +#ifndef _CTYPES_FREELIBRARY_METHODDEF + #define _CTYPES_FREELIBRARY_METHODDEF +#endif /* !defined(_CTYPES_FREELIBRARY_METHODDEF) */ + +#ifndef _CTYPES_COPYCOMPOINTER_METHODDEF + #define _CTYPES_COPYCOMPOINTER_METHODDEF +#endif /* !defined(_CTYPES_COPYCOMPOINTER_METHODDEF) */ + +#ifndef _CTYPES__DYLD_SHARED_CACHE_CONTAINS_PATH_METHODDEF + #define _CTYPES__DYLD_SHARED_CACHE_CONTAINS_PATH_METHODDEF +#endif /* !defined(_CTYPES__DYLD_SHARED_CACHE_CONTAINS_PATH_METHODDEF) */ + +#ifndef _CTYPES_DLOPEN_METHODDEF + #define _CTYPES_DLOPEN_METHODDEF +#endif /* !defined(_CTYPES_DLOPEN_METHODDEF) */ + +#ifndef _CTYPES_DLCLOSE_METHODDEF + #define _CTYPES_DLCLOSE_METHODDEF +#endif /* !defined(_CTYPES_DLCLOSE_METHODDEF) */ + +#ifndef _CTYPES_DLSYM_METHODDEF + #define _CTYPES_DLSYM_METHODDEF +#endif /* !defined(_CTYPES_DLSYM_METHODDEF) */ + +#ifndef _CTYPES_DLLIST_METHODDEF + #define _CTYPES_DLLIST_METHODDEF +#endif /* !defined(_CTYPES_DLLIST_METHODDEF) */ +/*[clinic end generated code: output=615c411ddc01d0a4 input=a9049054013a1b77]*/ diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h index 248559aa364a198..98d8b660850b0d9 100644 --- a/Modules/_ctypes/ctypes.h +++ b/Modules/_ctypes/ctypes.h @@ -24,7 +24,7 @@ // Do we support C99 complex types in ffi? // For Apple's libffi, this must be determined at runtime (see gh-128156). #if defined(_Py_FFI_SUPPORT_C_COMPLEX) -# if USING_APPLE_OS_LIBFFI && defined(__has_builtin) +# if defined(USING_APPLE_OS_LIBFFI) && defined(__has_builtin) # if __has_builtin(__builtin_available) # define Py_FFI_COMPLEX_AVAILABLE __builtin_available(macOS 10.15, *) # else diff --git a/Modules/_ctypes/malloc_closure.c b/Modules/_ctypes/malloc_closure.c index 62c7aa5d6affbfb..3abab8873acbd01 100644 --- a/Modules/_ctypes/malloc_closure.c +++ b/Modules/_ctypes/malloc_closure.c @@ -68,10 +68,25 @@ static void more_core(void) /* allocate a memory block */ #ifdef MS_WIN32 +#ifdef MS_WINDOWS_DESKTOP item = (ITEM *)VirtualAlloc(NULL, count * sizeof(ITEM), MEM_COMMIT, PAGE_EXECUTE_READWRITE); +#else // UWP + /* Due security restrictions, UWP not allows request Read-Write-Execute permissions at once. + The correct flow in UWP for execute dynamic code in memmory is: + 1. Alloate as Read-Write (PAGE_READWRITE) and write dynamic code to memmory. + 2. Change to Executable (PAGE_EXECUTE_READ) with 'VirtualProtectFromApp'. + 3. Flush cache with 'FlushInstructionCache' to ensure CPU instruction cache coherency + before executing the generated code. + TODO: Implement 2 and 3 in the appropriate places. For now, this defers + the error from import time to time of use (or never, if an app avoids it). */ + item = (ITEM*)VirtualAllocFromApp(NULL, + count * sizeof(ITEM), + MEM_COMMIT | MEM_RESERVE, + PAGE_READWRITE); +#endif // !MS_WINDOWS_DESKTOP if (item == NULL) return; #else diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index ab955a0b824a2f3..7920c87ebe3cef3 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -28,6 +28,10 @@ PyCStgInfo_clone(StgInfo *dst_info, StgInfo *src_info) ctype_free_stginfo_members(dst_info); memcpy(dst_info, src_info, sizeof(StgInfo)); + /* Owned buffers must not be shared if a subsequent allocation fails. */ + dst_info->format = NULL; + dst_info->shape = NULL; + dst_info->ffi_type_pointer.elements = NULL; #ifdef Py_GIL_DISABLED dst_info->mutex = (PyMutex){0}; #endif @@ -679,10 +683,22 @@ _replace_array_elements(ctypes_state *st, PyObject *layout_fields, structs[struct_index].type = FFI_TYPE_STRUCT; structs[struct_index].elements = &dummy_types[dummy_index]; ++struct_index; + ffi_type *etype = &einfo->ffi_type_pointer; +#if defined(__sparc__) && defined(__arch64__) && !defined(__sun) + /* On Linux, GCC and clang pass arrays of floating-point type + in a structure in integer registers; only Solaris follows + the vendor ABI here (GCC PR target/114416). */ + if (etype->type == FFI_TYPE_FLOAT) { + etype = &ffi_type_uint32; + } + else if (etype->type == FFI_TYPE_DOUBLE) { + etype = &ffi_type_uint64; + } +#endif /* Copy over the element's type, length times. */ while (length > 0) { assert(dummy_index < (num_ffi_type_pointers)); - dummy_types[dummy_index++] = &einfo->ffi_type_pointer; + dummy_types[dummy_index++] = etype; length--; } assert(dummy_index < (num_ffi_type_pointers)); diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 742a3310bc3528a..40d407742b1621d 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -437,11 +437,11 @@ PyCursesPanel_Clear(PyObject *op) PyCursesPanelObject *self = _PyCursesPanelObject_CAST(op); PyObject *extra = (PyObject *)panel_userptr(self->pan); if (extra != NULL) { - Py_DECREF(extra); if (set_panel_userptr(self->pan, NULL) == ERR) { curses_panel_panel_set_error(self, "set_panel_userptr", NULL); return -1; } + Py_DECREF(extra); } // self->wo should not be cleared because an associated WINDOW may exist return 0; @@ -454,20 +454,21 @@ PyCursesPanel_Dealloc(PyObject *self) PyObject_GC_UnTrack(self); PyCursesPanelObject *po = _PyCursesPanelObject_CAST(self); - if (PyCursesPanel_Clear(self) < 0) { + PyObject *extra = (PyObject *)panel_userptr(po->pan); + if (extra != NULL && set_panel_userptr(po->pan, NULL) == ERR) { + curses_panel_panel_set_error(po, "set_panel_userptr", "__del__"); + PyErr_FormatUnraisable("Exception ignored in PyCursesPanel_Dealloc()"); + } + if (po->wo != NULL && remove_lop(po) < 0) { + PyErr_SetString(PyExc_RuntimeError, "__del__: no panel object to delete"); PyErr_FormatUnraisable("Exception ignored in PyCursesPanel_Dealloc()"); } if (del_panel(po->pan) == ERR && !PyErr_Occurred()) { curses_panel_panel_set_error(po, "del_panel", "__del__"); PyErr_FormatUnraisable("Exception ignored in PyCursesPanel_Dealloc()"); } - if (po->wo != NULL) { - Py_DECREF(po->wo); - if (remove_lop(po) < 0) { - PyErr_SetString(PyExc_RuntimeError, "__del__: no panel object to delete"); - PyErr_FormatUnraisable("Exception ignored in PyCursesPanel_Dealloc()"); - } - } + Py_XDECREF(extra); + Py_XDECREF(po->wo); tp->tp_free(po); Py_DECREF(tp); } @@ -594,6 +595,12 @@ _curses_panel_panel_replace_impl(PyCursesPanelObject *self, return NULL; } + if (win->win == NULL) { + _curses_panel_state *state = get_curses_panel_state_by_panel(self); + PyErr_SetString(state->error, "the window has been detached"); + return NULL; + } + int rtn = replace_panel(self->pan, win->win); if (rtn == ERR) { curses_panel_panel_set_error(self, "replace_panel", "replace"); diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index cc68a51f0bed935..94cad7f02e31bb8 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -107,7 +107,7 @@ static const char PyCursesVersion[] = "2.2"; #define CURSES_MODULE #include "py_curses.h" -#if defined(HAVE_TERM_H) || defined(__sgi) +#ifdef HAVE_TERM_H /* For termname, longname, putp, tigetflag, tigetnum, tigetstr, tparm which are not declared in SysV curses and for setupterm. */ #include @@ -120,7 +120,7 @@ static const char PyCursesVersion[] = "2.2"; #include #endif -#if !defined(NCURSES_VERSION) && (defined(sgi) || defined(__sun) || defined(SCO5)) +#if !defined(NCURSES_VERSION) && defined(__sun) #define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ typedef chtype attr_t; /* No attr_t type is available */ #endif @@ -159,6 +159,8 @@ typedef struct { PyTypeObject *complexstr_type; // _curses.complexstr PyObject *topscreen; // owned ref to the current screen object, // or NULL for the initscr() screen + PyObject *prescreen; // owned ref to the pending new_prescr() screen, + // or NULL if there is no pending pre-screen } cursesmodule_state; static inline cursesmodule_state * @@ -207,6 +209,8 @@ static int curses_initscr_called = FALSE; /* Tells whether start_color() has been called to initialise color usage. */ static int curses_start_color_called = FALSE; +static int update_lines_cols(PyObject *private_module); + /* Encoding of the initial screen, used by module-level functions that have no window object to take it from (e.g. unctrl(), ungetch()). This is a private copy: the window object that initscr() returns may be deallocated @@ -309,6 +313,14 @@ curses_window_set_null_error(PyCursesWindowObject *win, _curses_set_null_error(state, curses_funcname, python_funcname); } +/* ncurses and PDCurses store n characters and add a terminator; NetBSD + curses counts the terminator in n. Ask an unknown library for one more. */ +#if defined(NCURSES_VERSION) || defined(PDCURSES) +# define CURSES_STR_EXTRA 0 +#else +# define CURSES_STR_EXTRA 1 +#endif + /* Utility Checking Procedures */ /* @@ -356,6 +368,35 @@ _PyCursesStatefulCheckFunction(PyObject *module, return 0; } +/* + * Function to check that the current screen has a terminal, by testing + * stdscr, which a screen made by new_prescr() does not have. If an error + * occurs, a PyCursesError is set and this returns 0. Otherwise this + * returns 1. + */ +static int +_PyCursesStatefulCheckTerminal(PyObject *module) +{ + if (stdscr != NULL) { + return 1; + } + cursesmodule_state *state = get_cursesmodule_state(module); + PyErr_SetString(state->error, "the current screen has no terminal"); + return 0; +} + +/* Same as _PyCursesStatefulCheckTerminal() for a Window object. */ +static int +curses_window_check_terminal(PyCursesWindowObject *win) +{ + if (stdscr != NULL) { + return 1; + } + cursesmodule_state *state = get_cursesmodule_state_by_win(win); + PyErr_SetString(state->error, "the current screen has no terminal"); + return 0; +} + #define PyCursesStatefulSetupTermCalled(MODULE) \ do { \ if (!_PyCursesStatefulCheckFunction(MODULE, \ @@ -370,7 +411,8 @@ _PyCursesStatefulCheckFunction(PyObject *module, do { \ if (!_PyCursesStatefulCheckFunction(MODULE, \ curses_initscr_called, \ - "initscr")) \ + "initscr") \ + || !_PyCursesStatefulCheckTerminal(MODULE)) \ { \ return 0; \ } \ @@ -433,7 +475,7 @@ curses_window_check_err(PyCursesWindowObject *win, int code, static int PyCurses_ConvertToChtype(PyCursesWindowObject *win, PyObject *obj, chtype *ch) { - long value; + unsigned long long value; if (PyBytes_Check(obj)) { if (PyBytes_GET_SIZE(obj) != 1) { PyErr_Format(PyExc_TypeError, @@ -463,20 +505,18 @@ PyCurses_ConvertToChtype(PyCursesWindowObject *win, PyObject *obj, chtype *ch) bytes = PyUnicode_AsEncodedString(obj, encoding, NULL); if (bytes == NULL) return 0; - if (PyBytes_GET_SIZE(bytes) == 1) - value = (unsigned char)PyBytes_AS_STRING(bytes)[0]; - else - value = -1; - Py_DECREF(bytes); - if (value < 0) + if (PyBytes_GET_SIZE(bytes) != 1) { + Py_DECREF(bytes); goto overflow; + } + value = (unsigned char)PyBytes_AS_STRING(bytes)[0]; + Py_DECREF(bytes); } } else if (PyLong_CheckExact(obj)) { - int long_overflow; - value = PyLong_AsLongAndOverflow(obj, &long_overflow); - if (long_overflow) - goto overflow; + value = PyLong_AsUnsignedLongLong(obj); + if (value == (unsigned long long)-1 && PyErr_Occurred()) + return 0; } else { PyErr_Format(PyExc_TypeError, @@ -485,7 +525,7 @@ PyCurses_ConvertToChtype(PyCursesWindowObject *win, PyObject *obj, chtype *ch) return 0; } *ch = (chtype)value; - if ((long)*ch != value) + if ((unsigned long long)*ch != value) goto overflow; return 1; @@ -533,6 +573,10 @@ PyCurses_ConvertToWideCell(PyObject *obj, wchar_t *wch) setcchar() would silently drop a trailing spacing character, or fail with a generic error for a control-character base. */ if (nch > 1) { + if (wmemchr(wch, L'\0', nch) != NULL) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + return -1; + } int bad = wcwidth(wch[0]) < 0; for (Py_ssize_t i = 1; !bad && i < nch; i++) { bad = wcwidth(wch[i]) != 0; @@ -557,7 +601,7 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj, #endif ) { - long value; + unsigned long long value; if (PyUnicode_Check(obj)) { #ifdef HAVE_NCURSESW @@ -580,11 +624,8 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj, value = (unsigned char)PyBytes_AsString(obj)[0]; } else if (PyLong_CheckExact(obj)) { - int overflow; - value = PyLong_AsLongAndOverflow(obj, &overflow); - if (overflow) { - PyErr_SetString(PyExc_OverflowError, - "int doesn't fit in long"); + value = PyLong_AsUnsignedLongLong(obj); + if (value == (unsigned long long)-1 && PyErr_Occurred()) { return 0; } } @@ -596,7 +637,7 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj, } *ch = (chtype)value; - if ((long)*ch != value) { + if ((unsigned long long)*ch != value) { PyErr_Format(PyExc_OverflowError, "byte doesn't fit in chtype"); return 0; @@ -763,7 +804,9 @@ curses_getcchar(const cchar_t *wcval, wchar_t *wstr, attr_t *attrs, int *pair) /* getcchar() is not guaranteed to write the text of an empty cell, so make the output an empty string by default. */ wstr[0] = L'\0'; -#if _NCURSES_EXTENDED_COLOR_FUNCS + /* getcchar()'s opts slot returns the extended color pair, but ncurses + returned ERR for a non-NULL opts until 6.3 (patch 20210116). */ +#if _NCURSES_EXTENDED_COLOR_FUNCS && NCURSES_VERSION_PATCH+0 >= 20210116 int rtn = getcchar(wcval, wstr, attrs, &spair, pair); #else int rtn = getcchar(wcval, wstr, attrs, &spair, NULL); @@ -771,6 +814,9 @@ curses_getcchar(const cchar_t *wcval, wchar_t *wstr, attr_t *attrs, int *pair) *pair = spair; } #endif + if (rtn != ERR) { + *attrs &= ~(attr_t)A_COLOR; + } return rtn; } @@ -878,7 +924,9 @@ curses_cell_text(cursesmodule_state *state, const curses_cell_t *cell) PyErr_SetString(state->error, "getcchar() returned ERR"); return NULL; } - return PyUnicode_FromWideChar(wstr, -1); + /* setcchar() stores no text for a NUL (it takes a NUL-terminated string), + so an empty cell holds a NUL character, as on a narrow build. */ + return PyUnicode_FromWideChar(wstr, wstr[0] == L'\0' ? 1 : -1); #else char ch = (char)(*cell & A_CHARTEXT); return PyUnicode_Decode(&ch, 1, curses_screen_encoding, NULL); @@ -1050,14 +1098,14 @@ attr_converter(PyObject *arg, void *ptr) { /* attr_t is unsigned and at least as wide as chtype, so an attribute value must be a non-negative integer that fits in attr_t. */ - unsigned long attr = PyLong_AsUnsignedLong(arg); - if (attr == (unsigned long)-1 && PyErr_Occurred()) { + unsigned long long attr = PyLong_AsUnsignedLongLong(arg); + if (attr == (unsigned long long)-1 && PyErr_Occurred()) { return 0; } - if (attr > (unsigned long)(attr_t)-1) { + if (attr > (unsigned long long)(attr_t)-1) { PyErr_Format(PyExc_OverflowError, - "attribute value is greater than maximum (%lu)", - (unsigned long)(attr_t)-1); + "attribute value is greater than maximum (%llu)", + (unsigned long long)(attr_t)-1); return 0; } *(attr_t *)ptr = (attr_t)attr; @@ -1192,7 +1240,7 @@ complexchar_get_attr(PyObject *self, void *Py_UNUSED(closure)) &_PyCursesComplexCharObject_CAST(self)->cval, &attrs, &pair) < 0) { return NULL; } - return PyLong_FromUnsignedLong((unsigned long)attrs); + return PyLong_FromUnsignedLongLong((unsigned long long)attrs); } static PyObject * @@ -1288,6 +1336,16 @@ static PyObject * complexstr_from_string(cursesmodule_state *state, PyObject *str, attr_t attr, int pair) { + /* A NUL cell ends a batch write and a cell array read (add_wchnstr(3X)), + so a string of cells cannot hold one, as addstr() cannot either. */ + Py_ssize_t nul = PyUnicode_FindChar(str, 0, 0, PyUnicode_GET_LENGTH(str), 1); + if (nul < -1) { + return NULL; + } + if (nul >= 0) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + return NULL; + } #ifdef HAVE_NCURSESW Py_ssize_t n; wchar_t *wbuf = PyUnicode_AsWideCharString(str, &n); @@ -1536,7 +1594,10 @@ complexstr_concat(PyObject *a, PyObject *b) { cursesmodule_state *state = get_cursesmodule_state_by_cls(Py_TYPE(a)); if (!Py_IS_TYPE(b, state->complexstr_type)) { - Py_RETURN_NOTIMPLEMENTED; + PyErr_Format(PyExc_TypeError, + "can only concatenate complexstr to complexstr, not %T", + b); + return NULL; } PyCursesComplexStrObject *sa = _PyCursesComplexStrObject_CAST(a); PyCursesComplexStrObject *sb = _PyCursesComplexStrObject_CAST(b); @@ -1791,6 +1852,42 @@ curses_window_put_cells(PyCursesWindowObject *self, PyObject *obj, Py_RETURN_NONE; \ } +/* Same as Window_OneArgNoReturnVoidFunction() for a function that needs + a terminal. */ +#define Window_OneArgNoReturnVoidTerminalFunction(X, TYPE, PARSESTR) \ + static PyObject * PyCursesWindow_ ## X \ + (PyObject *op, PyObject *args) \ + { \ + TYPE arg1; \ + if (!PyArg_ParseTuple(args, PARSESTR, &arg1)) { \ + return NULL; \ + } \ + PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op); \ + if (!curses_window_check_terminal(self)) { \ + return NULL; \ + } \ + X(self->win, arg1); \ + Py_RETURN_NONE; \ + } + +/* Same as Window_OneArgNoReturnFunction() for a function that needs + a terminal. */ +#define Window_OneArgNoReturnTerminalFunction(X, TYPE, PARSESTR) \ + static PyObject * PyCursesWindow_ ## X \ + (PyObject *op, PyObject *args) \ + { \ + TYPE arg1; \ + if (!PyArg_ParseTuple(args, PARSESTR, &arg1)) { \ + return NULL; \ + } \ + PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op); \ + if (!curses_window_check_terminal(self)) { \ + return NULL; \ + } \ + int code = X(self->win, arg1); \ + return curses_window_check_err(self, code, # X, NULL); \ + } + #define Window_OneArgNoReturnFunction(X, TYPE, PARSESTR) \ static PyObject * PyCursesWindow_ ## X \ (PyObject *op, PyObject *args) \ @@ -1839,10 +1936,10 @@ Window_NoArgTrueFalseFunction(is_scrollok) Window_NoArgTrueFalseFunction(is_subwin) Window_NoArgTrueFalseFunction(is_syncok) #endif -#if defined(HAVE_CURSES_IS_KEYPAD) || defined(PDCURSES) +#if defined(_Py__Py_HAVE_CURSES_IS_KEYPAD) || defined(PDCURSES) Window_NoArgTrueFalseFunction(is_keypad) #endif -#if defined(HAVE_CURSES_IS_LEAVEOK) || defined(PDCURSES) +#if defined(_Py_HAVE_CURSES_IS_LEAVEOK) || defined(PDCURSES) Window_NoArgTrueFalseFunction(is_leaveok) #endif #if defined(HAVE_CURSES_IS_PAD) || defined(PDCURSES) @@ -1868,6 +1965,7 @@ PyCursesWindow_getscrreg(PyObject *op, PyObject *Py_UNUSED(ignored)) } return Py_BuildValue("(ii)", top, bottom); } +#endif /* NCURSES_EXT_FUNCS >= 20110404 || PDCURSES */ static PyObject * PyCursesWindow_getparent(PyObject *op, PyObject *Py_UNUSED(ignored)) @@ -1880,7 +1978,6 @@ PyCursesWindow_getparent(PyObject *op, PyObject *Py_UNUSED(ignored)) } return Py_NewRef((PyObject *)self->orig); } -#endif /* NCURSES_EXT_FUNCS >= 20110404 || PDCURSES */ Window_NoArgNoReturnVoidFunction(wsyncup) Window_NoArgNoReturnVoidFunction(wsyncdown) @@ -1891,7 +1988,7 @@ Window_NoArgNoReturnVoidFunction(wclrtoeol) Window_NoArgNoReturnVoidFunction(wclrtobot) Window_NoArgNoReturnVoidFunction(wclear) -Window_OneArgNoReturnVoidFunction(idcok, int, "i;True(1) or False(0)") +Window_OneArgNoReturnVoidTerminalFunction(idcok, int, "i;True(1) or False(0)") #ifdef HAVE_CURSES_IMMEDOK Window_OneArgNoReturnVoidFunction(immedok, int, "i;True(1) or False(0)") #endif @@ -1903,8 +2000,8 @@ Window_NoArg2TupleReturnFunction(getmaxyx, int, "ii") Window_NoArg2TupleReturnFunction(getparyx, int, "ii") Window_OneArgNoReturnFunction(clearok, int, "i;True(1) or False(0)") -Window_OneArgNoReturnFunction(idlok, int, "i;True(1) or False(0)") -Window_OneArgNoReturnFunction(keypad, int, "i;True(1) or False(0)") +Window_OneArgNoReturnTerminalFunction(idlok, int, "i;True(1) or False(0)") +Window_OneArgNoReturnTerminalFunction(keypad, int, "i;True(1) or False(0)") Window_OneArgNoReturnFunction(leaveok, int, "i;True(1) or False(0)") Window_OneArgNoReturnFunction(nodelay, int, "i;True(1) or False(0)") Window_OneArgNoReturnFunction(notimeout, int, "i;True(1) or False(0)") @@ -1930,7 +2027,7 @@ PyCursesWindow_New(cursesmodule_state *state, { if (encoding == NULL) { #if defined(MS_WINDOWS) - char *buffer[100]; + char buffer[100]; UINT cp; cp = GetConsoleOutputCP(); if (cp != 0) { @@ -2095,6 +2192,56 @@ curses_wattrset(PyCursesWindowObject *self, attr_t attr, const char *funcname) return 0; } +/* Read the rendition a write with an *attr* argument has to put back. The + color pair is read apart from the attributes because the A_COLOR field of a + chtype holds only pairs 0 to 255, while a window can use a larger one. */ +static int +curses_wattr_save(PyCursesWindowObject *self, attr_t *attrs, int *pair, + const char *funcname) +{ +#if defined(_Py_HAVE_CURSES_WATTR_GET) && defined(_Py_HAVE_CURSES_WATTR_SET) + int rtn; +#if _NCURSES_EXTENDED_COLOR_FUNCS + short legacy_pair; + rtn = wattr_get(self->win, attrs, &legacy_pair, pair); +#else + short spair; + rtn = wattr_get(self->win, attrs, &spair, NULL); + *pair = spair; +#endif + if (rtn == ERR) { + curses_window_set_error(self, "wattr_get", funcname); + return -1; + } +#else + *attrs = getattrs(self->win); + *pair = 0; +#endif + return 0; +} + +/* Put the rendition back. The name of the curses function used is + _CURSES_WATTR_RESTORE_FUNC, for the caller to name it in an error. */ +#if defined(_Py_HAVE_CURSES_WATTR_GET) && defined(_Py_HAVE_CURSES_WATTR_SET) +#define _CURSES_WATTR_RESTORE_FUNC "wattr_set" +#else +#define _CURSES_WATTR_RESTORE_FUNC "wattrset" +#endif + +static int +curses_wattr_restore(PyCursesWindowObject *self, attr_t attrs, int pair) +{ +#if defined(_Py_HAVE_CURSES_WATTR_GET) && defined(_Py_HAVE_CURSES_WATTR_SET) +#if _NCURSES_EXTENDED_COLOR_FUNCS + return wattr_set(self->win, attrs, 0, &pair); +#else + return wattr_set(self->win, attrs, (short)pair, NULL); +#endif +#else + return wattrset(self->win, attrs); +#endif +} + /*[clinic input] _curses.window.addstr @@ -2135,6 +2282,7 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1, wchar_t *wstr = NULL; #endif attr_t attr_old = A_NORMAL; + int pair_old = 0; int use_xy = group_left_1, use_attr = group_right_1; const char *funcname; @@ -2159,8 +2307,9 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1, return NULL; } if (use_attr) { - attr_old = getattrs(self->win); - if (curses_wattrset(self, attr, "addstr") < 0) { + if (curses_wattr_save(self, &attr_old, &pair_old, "addstr") < 0 || + curses_wattrset(self, attr, "addstr") < 0) + { curses_release_wstr(strtype, wstr); Py_XDECREF(bytesobj); return NULL; @@ -2196,15 +2345,14 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1, } Py_DECREF(bytesobj); } - if (rtn == ERR) { - curses_window_set_error(self, funcname, "addstr"); - return NULL; - } if (use_attr) { - rtn = wattrset(self->win, attr_old); - return curses_window_check_err(self, rtn, "wattrset", "addstr"); + int attr_rtn = curses_wattr_restore(self, attr_old, pair_old); + if (rtn != ERR) { + rtn = attr_rtn; + funcname = _CURSES_WATTR_RESTORE_FUNC; + } } - Py_RETURN_NONE; + return curses_window_check_err(self, rtn, funcname, "addstr"); } /*[clinic input] @@ -2250,6 +2398,7 @@ _curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1, wchar_t *wstr = NULL; #endif attr_t attr_old = A_NORMAL; + int pair_old = 0; int use_xy = group_left_1, use_attr = group_right_1; const char *funcname; @@ -2274,8 +2423,9 @@ _curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1, return NULL; if (use_attr) { - attr_old = getattrs(self->win); - if (curses_wattrset(self, attr, "addnstr") < 0) { + if (curses_wattr_save(self, &attr_old, &pair_old, "addnstr") < 0 || + curses_wattrset(self, attr, "addnstr") < 0) + { curses_release_wstr(strtype, wstr); Py_XDECREF(bytesobj); return NULL; @@ -2307,15 +2457,14 @@ _curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1, } Py_DECREF(bytesobj); } - if (rtn == ERR) { - curses_window_set_error(self, funcname, "addnstr"); - return NULL; - } if (use_attr) { - rtn = wattrset(self->win, attr_old); - return curses_window_check_err(self, rtn, "wattrset", "addnstr"); + int attr_rtn = curses_wattr_restore(self, attr_old, pair_old); + if (rtn != ERR) { + rtn = attr_rtn; + funcname = _CURSES_WATTR_RESTORE_FUNC; + } } - Py_RETURN_NONE; + return curses_window_check_err(self, rtn, funcname, "addnstr"); } /*[clinic input] @@ -2409,6 +2558,7 @@ _curses_window_attrset_impl(PyCursesWindowObject *self, attr_t attr) return curses_window_check_err(self, rtn, "wattrset", "attrset"); } +#ifdef _Py_HAVE_CURSES_WATTR_GET /*[clinic input] _curses.window.attr_get @@ -2434,7 +2584,9 @@ _curses_window_attr_get_impl(PyCursesWindowObject *self) } return Py_BuildValue("(ki)", (unsigned long)attrs, (int)pair); } +#endif /* _Py_HAVE_CURSES_WATTR_GET */ +#ifdef _Py_HAVE_CURSES_WATTR_SET /*[clinic input] _curses.window.attr_set @@ -2458,7 +2610,9 @@ _curses_window_attr_set_impl(PyCursesWindowObject *self, attr_t attr, #endif return curses_window_check_err(self, rtn, "wattr_set", "attr_set"); } +#endif /* _Py_HAVE_CURSES_WATTR_SET */ +#ifdef _Py_HAVE_CURSES_WATTR_ON /*[clinic input] _curses.window.attr_on @@ -2475,7 +2629,9 @@ _curses_window_attr_on_impl(PyCursesWindowObject *self, attr_t attr) int rtn = wattr_on(self->win, attr, NULL); return curses_window_check_err(self, rtn, "wattr_on", "attr_on"); } +#endif /* _Py_HAVE_CURSES_WATTR_ON */ +#ifdef _Py_HAVE_CURSES_WATTR_OFF /*[clinic input] _curses.window.attr_off @@ -2492,7 +2648,9 @@ _curses_window_attr_off_impl(PyCursesWindowObject *self, attr_t attr) int rtn = wattr_off(self->win, attr, NULL); return curses_window_check_err(self, rtn, "wattr_off", "attr_off"); } +#endif /* _Py_HAVE_CURSES_WATTR_OFF */ +#ifdef _Py_HAVE_CURSES_WCOLOR_SET /*[clinic input] _curses.window.color_set @@ -2514,6 +2672,7 @@ _curses_window_color_set_impl(PyCursesWindowObject *self, int pair) #endif return curses_window_check_err(self, rtn, "wcolor_set", "color_set"); } +#endif /* _Py_HAVE_CURSES_WCOLOR_SET */ /*[clinic input] _curses.window.getattrs @@ -2525,7 +2684,7 @@ static PyObject * _curses_window_getattrs_impl(PyCursesWindowObject *self) /*[clinic end generated code: output=835f499205204ec4 input=bf56a0af5b730bd1]*/ { - return PyLong_FromUnsignedLong((unsigned long)(attr_t)getattrs(self->win)); + return PyLong_FromUnsignedLongLong((unsigned long long)(attr_t)getattrs(self->win)); } /*[clinic input] @@ -2571,21 +2730,21 @@ _curses_window_bkgdset_impl(PyCursesWindowObject *self, PyObject *ch, /*[clinic input] _curses.window.border - ls: object(c_default="NULL") = _curses.ACS_VLINE + ls: object(c_default="NULL") = 0 Left side. - rs: object(c_default="NULL") = _curses.ACS_VLINE + rs: object(c_default="NULL") = 0 Right side. - ts: object(c_default="NULL") = _curses.ACS_HLINE + ts: object(c_default="NULL") = 0 Top side. - bs: object(c_default="NULL") = _curses.ACS_HLINE + bs: object(c_default="NULL") = 0 Bottom side. - tl: object(c_default="NULL") = _curses.ACS_ULCORNER + tl: object(c_default="NULL") = 0 Upper-left corner. - tr: object(c_default="NULL") = _curses.ACS_URCORNER + tr: object(c_default="NULL") = 0 Upper-right corner. - bl: object(c_default="NULL") = _curses.ACS_LLCORNER + bl: object(c_default="NULL") = 0 Bottom-left corner. - br: object(c_default="NULL") = _curses.ACS_LRCORNER + br: object(c_default="NULL") = 0 Bottom-right corner. / @@ -2602,7 +2761,7 @@ _curses_window_border_impl(PyCursesWindowObject *self, PyObject *ls, PyObject *rs, PyObject *ts, PyObject *bs, PyObject *tl, PyObject *tr, PyObject *bl, PyObject *br) -/*[clinic end generated code: output=670ef38d3d7c2aa3 input=42568c1458221d24]*/ +/*[clinic end generated code: output=670ef38d3d7c2aa3 input=d826ce9d6335479a]*/ { chtype ch[8]; int i, rtn; @@ -2615,36 +2774,49 @@ _curses_window_border_impl(PyCursesWindowObject *self, PyObject *ls, #ifdef HAVE_NCURSESW cchar_t wch[8]; const cchar_t *wch_p[8]; - int use_wide = 0; - int types[8]; + /* Only wborder_set() draws a complexchar and only wborder() an integer + or bytes character; a string character suits both, and so does the + integer 0, which asks for the default character. */ + int has_narrow = 0, has_str = 0, has_cchar = 0; for (i = 0; i < 8; i++) { - types[i] = 0; + wch_p[i] = NULL; /* use the default character */ if (objs[i] != NULL) { - types[i] = PyCurses_ConvertToCell(self, objs[i], A_NORMAL, 0, + int type = PyCurses_ConvertToCell(self, objs[i], A_NORMAL, 0, "border", &ch[i], &wch[i]); - if (types[i] == 0) { + if (type == 0) { return NULL; } - if (types[i] == 2) { - use_wide = 1; + if (type == 2) { + wch_p[i] = &wch[i]; + if (PyUnicode_Check(objs[i])) { + has_str = 1; + } + else { + has_cchar = 1; + } + } + else if (!PyLong_CheckExact(objs[i]) || ch[i] != 0) { + has_narrow = 1; /* b'\0' is a byte character, not the 0 */ } } } - if (use_wide) { + if (has_narrow) { + if (has_cchar) { + PyErr_SetString(PyExc_TypeError, + "border() cannot mix complexchar characters " + "with integer or bytes characters"); + return NULL; + } + /* Narrow the string characters. */ for (i = 0; i < 8; i++) { - if (objs[i] == NULL) { - wch_p[i] = NULL; /* use the default character */ - } - else if (types[i] == 2) { - wch_p[i] = &wch[i]; - } - else { - PyErr_SetString(PyExc_TypeError, - "border() cannot mix integer or bytes " - "characters with wide string characters"); + if (objs[i] != NULL && PyUnicode_Check(objs[i]) && + !PyCurses_ConvertToChtype(self, objs[i], &ch[i])) + { return NULL; } } + } + else if (has_str || has_cchar) { rtn = wborder_set(self->win, wch_p[0], wch_p[1], wch_p[2], wch_p[3], wch_p[4], wch_p[5], wch_p[6], wch_p[7]); @@ -2687,42 +2859,67 @@ _curses_window_box_impl(PyCursesWindowObject *self, int group_right_1, PyObject *verch, PyObject *horch) /*[clinic end generated code: output=f3fcb038bb287192 input=e11acb7dbf6790b6]*/ { - chtype ch1 = 0, ch2 = 0; + chtype ch[2] = {0, 0}; + PyObject *objs[2] = {verch, horch}; + int i; #ifdef HAVE_NCURSESW - cchar_t wch1, wch2; - int t1 = 0, t2 = 0; + cchar_t wch[2]; + const cchar_t *wch_p[2] = {NULL, NULL}; + int has_narrow = 0, has_str = 0, has_cchar = 0; if (group_right_1) { - t1 = PyCurses_ConvertToCell(self, verch, A_NORMAL, 0, "box", &ch1, &wch1); - if (t1 == 0) { - return NULL; - } - t2 = PyCurses_ConvertToCell(self, horch, A_NORMAL, 0, "box", &ch2, &wch2); - if (t2 == 0) { - return NULL; + for (i = 0; i < 2; i++) { + int type = PyCurses_ConvertToCell(self, objs[i], A_NORMAL, 0, + "box", &ch[i], &wch[i]); + if (type == 0) { + return NULL; + } + if (type == 2) { + wch_p[i] = &wch[i]; + if (PyUnicode_Check(objs[i])) { + has_str = 1; + } + else { + has_cchar = 1; + } + } + else if (!PyLong_CheckExact(objs[i]) || ch[i] != 0) { + has_narrow = 1; /* b'\0' is a byte character, not the 0 */ + } } } - if (t1 == 2 || t2 == 2) { - if (t1 != 2 || t2 != 2) { + if (has_narrow) { + if (has_cchar) { PyErr_SetString(PyExc_TypeError, - "box() cannot mix integer or bytes characters " - "with wide string characters"); + "box() cannot mix complexchar characters " + "with integer or bytes characters"); return NULL; } - int rtn = wborder_set(self->win, &wch1, &wch1, &wch2, &wch2, - NULL, NULL, NULL, NULL); - return curses_window_check_err(self, rtn, "wborder_set", "box"); + /* Narrow the string characters. */ + for (i = 0; i < 2; i++) { + if (PyUnicode_Check(objs[i]) && + !PyCurses_ConvertToChtype(self, objs[i], &ch[i])) + { + return NULL; + } + } + } + else if (has_str || has_cchar) { + int rtn = box_set(self->win, wch_p[0], wch_p[1]); + return curses_window_check_err(self, rtn, "box_set", "box"); } #else if (group_right_1) { - if (!PyCurses_ConvertToCell(self, verch, A_NORMAL, 0, "box", &ch1)) { - return NULL; - } - if (!PyCurses_ConvertToCell(self, horch, A_NORMAL, 0, "box", &ch2)) { - return NULL; + for (i = 0; i < 2; i++) { + if (!PyCurses_ConvertToCell(self, objs[i], A_NORMAL, 0, "box", + &ch[i])) + { + return NULL; + } } } #endif - return curses_window_check_err(self, box(self->win, ch1, ch2), "box", NULL); + return curses_window_check_err(self, box(self->win, ch[0], ch[1]), + "box", NULL); } #if defined(HAVE_NCURSES_H) || defined(MVWDELCH_IS_EXPRESSION) @@ -2748,73 +2945,50 @@ int py_mvwdelch(WINDOW *w, int y, int x) /* chgat, added by Fabian Kreutz */ #ifdef HAVE_CURSES_WCHGAT -PyDoc_STRVAR(_curses_window_chgat__doc__, -"chgat([y, x,] [n=-1,] attr)\n" -"Set the attributes of characters.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -" n\n" -" Number of characters.\n" -" attr\n" -" Attributes for characters.\n" -"\n" -"Set the attributes of num characters at the current cursor position, or at\n" -"position (y, x) if supplied. If no value of num is given or num = -1, the\n" -"attribute will be set on all the characters to the end of the line. This\n" -"function does not move the cursor. The changed line will be touched using\n" -"the touchline() method so that the contents will be redisplayed by the next\n" -"window refresh."); +/*[clinic input] +_curses.window.chgat + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + [ + n: int = -1 + Number of characters. + ] + attr: attr + Attributes for characters. + / + +Set the attributes of characters. + +Set the attributes of n characters at the current cursor position, +or at position (y, x) if supplied. If no value of n is given or +n = -1, the attribute will be set on all the characters to the end +of the line. This function does not move the cursor. The changed +line will be touched using the touchline() method so that the +contents will be redisplayed by the next window refresh. +[clinic start generated code]*/ static PyObject * -PyCursesWindow_ChgAt(PyObject *op, PyObject *args) +_curses_window_chgat_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, int group_left_2, int n, attr_t attr) +/*[clinic end generated code: output=b990d21c13383874 input=e5ad3c2716927e44]*/ { - PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op); - int rtn; const char *funcname; - int x, y; - int num = -1; - short color; - attr_t attr = A_NORMAL; - int use_xy = FALSE; - - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args,"O&;attr", attr_converter, &attr)) - return NULL; - break; - case 2: - if (!PyArg_ParseTuple(args,"iO&;n,attr", &num, attr_converter, &attr)) - return NULL; - break; - case 3: - if (!PyArg_ParseTuple(args,"iiO&;y,x,attr", &y, &x, attr_converter, &attr)) - return NULL; - use_xy = TRUE; - break; - case 4: - if (!PyArg_ParseTuple(args,"iiiO&;y,x,n,attr", &y, &x, &num, attr_converter, &attr)) - return NULL; - use_xy = TRUE; - break; - default: - PyErr_SetString(PyExc_TypeError, - "_curses.window.chgat requires 1 to 4 arguments"); - return NULL; - } + short color = (short) PAIR_NUMBER(attr); - color = (short) PAIR_NUMBER(attr); attr = attr & A_ATTRIBUTES; - if (use_xy) { - rtn = mvwchgat(self->win,y,x,num,attr,color,NULL); + if (group_left_1) { + rtn = mvwchgat(self->win,y,x,n,attr,color,NULL); funcname = "mvwchgat"; } else { getyx(self->win,y,x); - rtn = wchgat(self->win,num,attr,color,NULL); + rtn = wchgat(self->win,n,attr,color,NULL); funcname = "wchgat"; } if (rtn == ERR) { @@ -2948,6 +3122,10 @@ _curses_window_echochar_impl(PyCursesWindowObject *self, PyObject *ch, int group_right_1, attr_t attr) /*[clinic end generated code: output=ab03afa580aa6a2a input=cd74c42aadcc7e30]*/ { + if (!curses_window_check_terminal(self)) { + return NULL; + } + chtype ch_; #ifdef HAVE_NCURSESW cchar_t wch; @@ -3060,7 +3238,7 @@ _curses_window_getbkgd_impl(PyCursesWindowObject *self) curses_window_set_error(self, "getbkgd", NULL); return NULL; } - return PyLong_FromLong(rtn); + return PyLong_FromUnsignedLongLong(rtn); } /*[clinic input] @@ -3179,21 +3357,32 @@ _curses.window.getch ] / -Get a character code from terminal keyboard. +Read a key press and return it as an integer. -The integer returned does not have to be in ASCII range: function -keys, keypad keys and so on return numbers higher than 256. In -no-delay mode, -1 is returned if there is no input, else getch() -waits until a key is pressed. +Wait until a key is pressed, or return -1 if the read is +non-blocking or times out. + +An ordinary key is returned as the code of a single byte of its +encoding in the current locale, so a character encoded with several +bytes takes several calls. Use get_wch() to read it as a single +character. + +In keypad mode function keys and other special keys are returned as +one of the KEY_* constants, which cannot be mistaken for an ordinary +key. Otherwise their bytes are returned one at a time. [clinic start generated code]*/ static PyObject * _curses_window_getch_impl(PyCursesWindowObject *self, int group_right_1, int y, int x) -/*[clinic end generated code: output=e1639e87d545e676 input=0dc5ff40e079787a]*/ +/*[clinic end generated code: output=e1639e87d545e676 input=882ddab9b41afbbd]*/ { int rtn; + if (!curses_window_check_terminal(self)) { + return NULL; + } + Py_BEGIN_ALLOW_THREADS if (!group_right_1) { rtn = wgetch(self->win); @@ -3227,21 +3416,25 @@ _curses.window.getkey ] / -Get a character (string) from terminal keyboard. +Read a key press and return it as a str. -Returning a string instead of an integer, as getch() does. Function -keys, keypad keys and other special keys return a multibyte string -containing the key name. In no-delay mode, an exception is raised -if there is no input. +Read as getch() does, but return an ordinary key as a one-character +string, the byte decoded as Latin-1, and a special key as its name, +such as 'KEY_UP'. Raise curses.error instead of returning -1 if +there is no input. [clinic start generated code]*/ static PyObject * _curses_window_getkey_impl(PyCursesWindowObject *self, int group_right_1, int y, int x) -/*[clinic end generated code: output=8490a182db46b10f input=bd24a7da1ed9c73b]*/ +/*[clinic end generated code: output=8490a182db46b10f input=f054cf034c69e879]*/ { int rtn; + if (!curses_window_check_terminal(self)) { + return NULL; + } + Py_BEGIN_ALLOW_THREADS if (!group_right_1) { rtn = wgetch(self->win); @@ -3282,17 +3475,25 @@ _curses.window.get_wch ] / -Get a wide character from terminal keyboard. +Read a key press and return it as a one-character str. -Return a character for most keys, or an integer for function keys, -keypad keys, and other special keys. +Wait until a key is pressed, or raise curses.error if the read is +non-blocking or times out. + +In keypad mode function keys and other special keys are returned as +one of the KEY_* constants, an integer. Otherwise their characters +are returned one at a time. [clinic start generated code]*/ static PyObject * _curses_window_get_wch_impl(PyCursesWindowObject *self, int group_right_1, int y, int x) -/*[clinic end generated code: output=9f4f86e91fe50ef3 input=dd7e5367fb49dc48]*/ +/*[clinic end generated code: output=9f4f86e91fe50ef3 input=77eb2da426ebe71f]*/ { + if (!curses_window_check_terminal(self)) { + return NULL; + } + #ifdef HAVE_NCURSESW int ct; wint_t rtn; @@ -3341,71 +3542,37 @@ _curses_window_get_wch_impl(PyCursesWindowObject *self, int group_right_1, #endif } -/* - * Helper function for parsing parameters from getstr() and instr(). - * This function is necessary because Argument Clinic does not know - * how to handle nested optional groups with default values inside. - * - * Return 1 on success and 0 on failure, similar to PyArg_ParseTuple(). - */ -static int -curses_clinic_parse_optional_xy_n(PyObject *args, - int *y, int *x, unsigned int *n, int *use_xy, - const char *qualname) -{ - switch (PyTuple_GET_SIZE(args)) { - case 0: { - *use_xy = 0; - return 1; - } - case 1: { - *use_xy = 0; - return PyArg_ParseTuple(args, "O&;n", - _PyLong_UnsignedInt_Converter, n); - } - case 2: { - *use_xy = 1; - return PyArg_ParseTuple(args, "ii;y,x", y, x); - } - case 3: { - *use_xy = 1; - return PyArg_ParseTuple(args, "iiO&;y,x,n", y, x, - _PyLong_UnsignedInt_Converter, n); - } - default: { - *use_xy = 0; - PyErr_Format(PyExc_TypeError, "%s requires 0 to 3 arguments", - qualname); - return 0; - } +/* Characters one cell can hold. */ +#ifdef HAVE_NCURSESW +#define CURSES_CELL_CHARS CCHARW_MAX +#else +#define CURSES_CELL_CHARS 1 +#endif + +/* The columns left on the line, in the unit the caller counts. */ +static unsigned int +curses_window_read_limit(PyCursesWindowObject *self, int use_xy, int x, + unsigned int per_cell) +{ + int col = use_xy ? x : getcurx(self->win); + int maxx = getmaxx(self->win); + if (col < 0) { + col = 0; } + if (col > maxx) { + return 0; + } + return ((unsigned int)(maxx - col) + 1) * per_cell; } -PyDoc_STRVAR(_curses_window_getstr__doc__, -"getstr([[y, x,] n=2047])\n" -"Read a string from the user, with primitive line editing capacity.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -" n\n" -" Maximal number of characters."); - /* Read user input into a new bytes object (empty on ERR), with primitive line editing. Shared by getstr() and, without the wide library, by get_wstr(). */ static PyObject * -curses_window_getstr_bytes(PyCursesWindowObject *self, PyObject *args, - const char *funcname) +curses_window_getstr_bytes(PyCursesWindowObject *self, int use_xy, + int y, int x, unsigned int n) { - int rtn, use_xy = 0, y = 0, x = 0; + int rtn; unsigned int max_buf_size = 2048; - unsigned int n = max_buf_size - 1; - - if (!curses_clinic_parse_optional_xy_n(args, &y, &x, &n, &use_xy, funcname)) - { - return NULL; - } n = Py_MIN(n, max_buf_size - 1); PyBytesWriter *writer = PyBytesWriter_Create(n + 1); @@ -3438,11 +3605,35 @@ curses_window_getstr_bytes(PyCursesWindowObject *self, PyObject *args, return PyBytesWriter_FinishWithSize(writer, strlen(buf)); } +/*[clinic input] +_curses.window.getstr + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + n: unsigned_int = 2047 + Maximal number of bytes. + / + +Read a line of input and return it as a bytes object. + +The input is read with primitive line editing capacity, encoded in +the current locale, and does not include the terminating newline. +At most n bytes are read. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_getstr(PyObject *op, PyObject *args) +_curses_window_getstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, unsigned int n) +/*[clinic end generated code: output=bea9b0ab7e8f34d9 input=0335501e45f55caf]*/ { - PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op); - return curses_window_getstr_bytes(self, args, "_curses.window.getstr"); + if (!curses_window_check_terminal(self)) { + return NULL; + } + return curses_window_getstr_bytes(self, group_left_1, y, x, n); } /*[clinic input] @@ -3544,6 +3735,24 @@ _curses_window_insch_impl(PyCursesWindowObject *self, int group_left_1, if (type == 0) { return NULL; } + if (type == 1) { + /* winsch() does not locale-decode a byte above 127 on a wide build, + unlike waddch(), so decode it here and insert it as a wide + character. (gh-153864) */ + chtype cch = ch_ & A_CHARTEXT; + if (cch > 127) { + wint_t wc = btowc((int)cch); + if (wc != WEOF) { + wchar_t wstr[2] = { (wchar_t)wc, L'\0' }; + attr_t cattr = (attr_t)((ch_ | attr) & ~(chtype)A_CHARTEXT); + if (curses_setcchar(&wch, wstr, cattr, PAIR_NUMBER(cattr)) == ERR) { + curses_window_set_error(self, "setcchar", "insch"); + return NULL; + } + type = 2; + } + } + } if (type == 2) { if (!group_left_1) { rtn = wins_wch(self->win, &wch); @@ -3596,7 +3805,39 @@ _curses_window_inch_impl(PyCursesWindowObject *self, int group_right_1, { chtype rtn; const char *funcname; - +#ifdef HAVE_NCURSESW + /* ncursesw's winch() returns the whole code point, which overflows the + chtype's 8-bit character field into the color and attribute bits. */ + cchar_t cell = {0}; + int rc; + if (!group_right_1) { + rc = win_wch(self->win, &cell); + funcname = "win_wch"; + } + else { + rc = mvwin_wch(self->win, y, x, &cell); + funcname = "mvwin_wch"; + } + if (rc == ERR) { + curses_window_set_error(self, funcname, "inch"); + return NULL; + } + wchar_t wstr[CCHARW_MAX + 1]; + attr_t attrs; + int pair; + if (curses_getcchar(&cell, wstr, &attrs, &pair) == ERR) { + curses_window_set_error(self, "getcchar", "inch"); + return NULL; + } + int byte = 0; + if (wstr[0] != L'\0' && wstr[1] == L'\0') { + byte = wctob(wstr[0]); + if (byte == EOF) { + byte = 0; + } + } + rtn = (chtype)byte | attrs | COLOR_PAIR(pair); +#else if (!group_right_1) { rtn = winch(self->win); funcname = "winch"; @@ -3609,98 +3850,112 @@ _curses_window_inch_impl(PyCursesWindowObject *self, int group_right_1, curses_window_set_error(self, funcname, "inch"); return NULL; } - return PyLong_FromUnsignedLong(rtn); +#endif + return PyLong_FromUnsignedLongLong(rtn); } -PyDoc_STRVAR(_curses_window_instr__doc__, -"instr([y, x,] n=2047)\n" -"Return a string of characters, extracted from the window.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -" n\n" -" Maximal number of characters.\n" -"\n" -"Return a string of characters, extracted from the window starting\n" -"at the current cursor position, or at y, x if specified, and\n" -"stopping at the end of the line. Attributes and color\n" -"information are stripped from the characters. If n is specified,\n" -"instr() returns a string at most n characters long (exclusive of\n" -"the trailing NUL)."); - /* Extract characters from the window into a new bytes object (empty on ERR), with attributes and color stripped. Shared by instr() and, without the wide library, by in_wstr(). */ static PyObject * -curses_window_instr_bytes(PyCursesWindowObject *self, PyObject *args, - const char *funcname) +curses_window_instr_bytes(PyCursesWindowObject *self, int use_xy, int use_n, + int y, int x, unsigned int n) { - int rtn, use_xy = 0, y = 0, x = 0; - unsigned int max_buf_size = 2048; - unsigned int n = max_buf_size - 1; - - if (!curses_clinic_parse_optional_xy_n(args, &y, &x, &n, &use_xy, funcname)) - { - return NULL; - } - - n = Py_MIN(n, max_buf_size - 1); - PyBytesWriter *writer = PyBytesWriter_Create(n + 1); + int rtn; + unsigned int limit = curses_window_read_limit(self, use_xy, x, + CURSES_CELL_CHARS + * (unsigned int)MB_CUR_MAX); + unsigned int nread = use_n ? Py_MIN(n, limit) : limit; + PyBytesWriter *writer = PyBytesWriter_Create(nread + CURSES_STR_EXTRA + 1); if (writer == NULL) { return NULL; } char *buf = PyBytesWriter_GetData(writer); - if (use_xy) { - rtn = mvwinnstr(self->win, y, x, buf, n); - } - else { - rtn = winnstr(self->win, buf, n); + /* Read again if the library stored more than asked: truncating could + split a multibyte character. */ + for (unsigned int ask = nread + CURSES_STR_EXTRA; ; ask = nread) { + if (use_xy) { + rtn = mvwinnstr(self->win, y, x, buf, ask); + } + else { + rtn = winnstr(self->win, buf, ask); + } + if (rtn == ERR || (unsigned int)rtn <= nread) { + break; + } } if (rtn == ERR) { PyBytesWriter_Discard(writer); return Py_GetConstant(Py_CONSTANT_EMPTY_BYTES); } - return PyBytesWriter_FinishWithSize(writer, strlen(buf)); + return PyBytesWriter_FinishWithSize(writer, rtn); } +/*[clinic input] +_curses.window.instr + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + [ + n: unsigned_int + Maximal number of bytes. The rest of the line by default. + ] + / + +Return the text of the window as a bytes object. + +Read from the current cursor position, or from y, x if specified, to +the end of the line or at most n bytes if n is specified, and return +the text in the encoding of the current locale, with attributes and +color pairs stripped. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_instr(PyObject *op, PyObject *args) +_curses_window_instr_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x, int group_right_2, unsigned int n) +/*[clinic end generated code: output=2428948b44ad10c7 input=9307eca4bd576899]*/ { - PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op); - return curses_window_instr_bytes(self, args, "_curses.window.instr"); + return curses_window_instr_bytes(self, group_right_1, group_right_2, + y, x, n); } -PyDoc_STRVAR(_curses_window_get_wstr__doc__, -"get_wstr([[y, x,] n=2047])\n" -"Read a string from the user, with primitive line editing capacity.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -" n\n" -" Maximal number of characters.\n" -"\n" -"This is the wide-character variant of getstr(); it returns a str."); +/*[clinic input] +_curses.window.get_wstr + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + n: unsigned_int = 2047 + Maximal number of characters. + / + +Read a line of input and return it as a str. + +This is the wide-character variant of getstr(). The input is read +with primitive line editing capacity and does not include the +terminating newline. At most n characters are read. +[clinic start generated code]*/ static PyObject * -PyCursesWindow_get_wstr(PyObject *op, PyObject *args) +_curses_window_get_wstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, unsigned int n) +/*[clinic end generated code: output=e0a6670551cbe79f input=8920c99e9134670b]*/ { - PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op); -#ifdef HAVE_NCURSESW - int rtn, use_xy = 0, y = 0, x = 0; - unsigned int max_buf_size = 2048; - unsigned int n = max_buf_size - 1; - - if (!curses_clinic_parse_optional_xy_n(args, &y, &x, &n, &use_xy, - "_curses.window.get_wstr")) - { + if (!curses_window_check_terminal(self)) { return NULL; } +#ifdef HAVE_NCURSESW + int rtn; + unsigned int max_buf_size = 2048; n = Py_MIN(n, max_buf_size - 1); wint_t *buf = PyMem_New(wint_t, n + 1); @@ -3708,7 +3963,7 @@ PyCursesWindow_get_wstr(PyObject *op, PyObject *args) return PyErr_NoMemory(); } - if (use_xy) { + if (group_left_1) { Py_BEGIN_ALLOW_THREADS rtn = mvwgetn_wstr(self->win, y, x, buf, n); Py_END_ALLOW_THREADS @@ -3744,8 +3999,7 @@ PyCursesWindow_get_wstr(PyObject *op, PyObject *args) #else /* Without the wide library, read the bytes as getstr() does and decode them with the window's encoding. */ - PyObject *bytes = curses_window_getstr_bytes(self, args, - "_curses.window.get_wstr"); + PyObject *bytes = curses_window_getstr_bytes(self, group_left_1, y, x, n); if (bytes == NULL) { return NULL; } @@ -3757,59 +4011,70 @@ PyCursesWindow_get_wstr(PyObject *op, PyObject *args) #endif /* HAVE_NCURSESW */ } -PyDoc_STRVAR(_curses_window_in_wstr__doc__, -"in_wstr([y, x,] n=2047)\n" -"Return a string of characters, extracted from the window.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -" n\n" -" Maximal number of characters.\n" -"\n" -"This is the wide-character variant of instr(); it returns a str."); +/*[clinic input] +_curses.window.in_wstr + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + [ + n: unsigned_int + Maximal number of characters. The rest of the line by default. + ] + / + +Return the text of the window as a str. + +This is the wide-character variant of instr(). Read from the +current cursor position, or from y, x if specified, to the end of +the line or at most n characters if n is specified, with attributes +and color pairs stripped. +[clinic start generated code]*/ static PyObject * -PyCursesWindow_in_wstr(PyObject *op, PyObject *args) +_curses_window_in_wstr_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x, int group_right_2, unsigned int n) +/*[clinic end generated code: output=d8c8bcfe8a26f519 input=5ba908338a94bfc8]*/ { - PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op); #ifdef HAVE_NCURSESW - int rtn, use_xy = 0, y = 0, x = 0; - unsigned int max_buf_size = 2048; - unsigned int n = max_buf_size - 1; - - if (!curses_clinic_parse_optional_xy_n(args, &y, &x, &n, &use_xy, - "_curses.window.in_wstr")) - { - return NULL; - } - - n = Py_MIN(n, max_buf_size - 1); - wchar_t *buf = PyMem_New(wchar_t, n + 1); + int rtn; + unsigned int limit = curses_window_read_limit(self, group_right_1, x, + CURSES_CELL_CHARS); + unsigned int nread = group_right_2 ? Py_MIN(n, limit) : limit; + wchar_t *buf = PyMem_New(wchar_t, nread + CURSES_STR_EXTRA + 1); if (buf == NULL) { return PyErr_NoMemory(); } - - if (use_xy) { - rtn = mvwinnwstr(self->win, y, x, buf, n); - } - else { - rtn = winnwstr(self->win, buf, n); + + /* Read again if the library stored more than asked: truncating could + separate a combining character from its base. */ + for (unsigned int ask = nread + CURSES_STR_EXTRA; ; ask = nread) { + if (group_right_1) { + rtn = mvwinnwstr(self->win, y, x, buf, ask); + } + else { + rtn = winnwstr(self->win, buf, ask); + } + if (rtn == ERR || (unsigned int)rtn <= nread) { + break; + } } if (rtn == ERR) { PyMem_Free(buf); return Py_GetConstant(Py_CONSTANT_EMPTY_STR); } - PyObject *res = PyUnicode_FromWideChar(buf, -1); + PyObject *res = PyUnicode_FromWideChar(buf, rtn); PyMem_Free(buf); return res; #else /* Without the wide library, read the bytes as instr() does and decode them with the window's encoding. */ - PyObject *bytes = curses_window_instr_bytes(self, args, - "_curses.window.in_wstr"); + PyObject *bytes = curses_window_instr_bytes(self, group_right_1, + group_right_2, y, x, n); if (bytes == NULL) { return NULL; } @@ -3821,50 +4086,55 @@ PyCursesWindow_in_wstr(PyObject *op, PyObject *args) #endif } -PyDoc_STRVAR(_curses_window_in_wchstr__doc__, -"in_wchstr([y, x,] n=2047)\n" -"Return a complexstr of the styled cells extracted from the window.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -" n\n" -" Maximal number of cells.\n" -"\n" -"This is the wide-character variant of instr() and in_wstr() that keeps\n" -"each cell's attributes and color pair; it returns a complexstr."); +/*[clinic input] +_curses.window.in_wchstr -static PyObject * -PyCursesWindow_in_wchstr(PyObject *op, PyObject *args) -{ - PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op); - int rtn, use_xy = 0, y = 0, x = 0; - unsigned int max_buf_size = 2048; - unsigned int n = max_buf_size - 1; + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + [ + n: unsigned_int + Maximal number of cells. The rest of the line by default. + ] + / - if (!curses_clinic_parse_optional_xy_n(args, &y, &x, &n, &use_xy, - "_curses.window.in_wchstr")) - { - return NULL; - } +Return the styled cells of the window as a complexstr. - n = Py_MIN(n, max_buf_size - 1); +Read from the current cursor position, or from y, x if specified, +to the end of the line or at most n cells if n is specified. +Unlike instr() and in_wstr(), each cell keeps its attributes and +color pair, so the result can be written back unchanged with +addstr(). +[clinic start generated code]*/ + +static PyObject * +_curses_window_in_wchstr_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x, int group_right_2, + unsigned int n) +/*[clinic end generated code: output=3807a62d51efd44f input=50400321de1db1da]*/ +{ + int rtn; + unsigned int limit = curses_window_read_limit(self, group_right_1, x, 1); + unsigned int nread = group_right_2 ? Py_MIN(n, limit) : limit; + unsigned int ask = nread + CURSES_STR_EXTRA; cursesmodule_state *state = get_cursesmodule_state_by_win(self); /* Zero the cells: reading a cell back through getcchar() relies on the cchar_t text array being NUL-terminated, which some curses libraries only guarantee for the characters they actually write. */ - curses_cell_t *buf = PyMem_Calloc(n + 1, sizeof(curses_cell_t)); + curses_cell_t *buf = PyMem_Calloc(ask + 1, sizeof(curses_cell_t)); if (buf == NULL) { return PyErr_NoMemory(); } #ifdef HAVE_NCURSESW - if (use_xy) { - rtn = mvwin_wchnstr(self->win, y, x, buf, n); + if (group_right_1) { + rtn = mvwin_wchnstr(self->win, y, x, buf, ask); } else { - rtn = win_wchnstr(self->win, buf, n); + rtn = win_wchnstr(self->win, buf, ask); } if (rtn == ERR) { @@ -3872,11 +4142,11 @@ PyCursesWindow_in_wchstr(PyObject *op, PyObject *args) return PyCursesComplexStr_New(state, NULL, 0); } - /* win_wchnstr() stores at most n cells and zero-terminates the array at - the actual count; every real cell holds at least a space, so the first + /* win_wchnstr() stores at most nread cells and zero-terminates the array + at the actual count; every real cell holds at least a space, so the first empty cell marks the end of the run. */ Py_ssize_t count = 0; - while (count < (Py_ssize_t)n) { + while (count < (Py_ssize_t)nread) { wchar_t wstr[CCHARW_MAX + 1]; attr_t attrs; int pair; @@ -3891,12 +4161,12 @@ PyCursesWindow_in_wchstr(PyObject *op, PyObject *args) /* winchnstr() is not guaranteed (SVr4) to terminate the array, so pre-zero it and stop at the first empty cell; a painted cell always holds at least a space, never 0. */ - memset(buf, 0, ((size_t)n + 1) * sizeof(curses_cell_t)); - if (use_xy) { - rtn = mvwinchnstr(self->win, y, x, buf, n); + memset(buf, 0, ((size_t)ask + 1) * sizeof(curses_cell_t)); + if (group_right_1) { + rtn = mvwinchnstr(self->win, y, x, buf, ask); } else { - rtn = winchnstr(self->win, buf, n); + rtn = winchnstr(self->win, buf, ask); } if (rtn == ERR) { @@ -3905,7 +4175,7 @@ PyCursesWindow_in_wchstr(PyObject *op, PyObject *args) } Py_ssize_t count = 0; - while (count < (Py_ssize_t)n && buf[count] != 0) { + while (count < (Py_ssize_t)nread && buf[count] != 0) { count++; } #endif @@ -3955,6 +4225,7 @@ _curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1, wchar_t *wstr = NULL; #endif attr_t attr_old = A_NORMAL; + int pair_old = 0; int use_xy = group_left_1, use_attr = group_right_1; const char *funcname; @@ -3979,8 +4250,9 @@ _curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1, return NULL; if (use_attr) { - attr_old = getattrs(self->win); - if (curses_wattrset(self, attr, "insstr") < 0) { + if (curses_wattr_save(self, &attr_old, &pair_old, "insstr") < 0 || + curses_wattrset(self, attr, "insstr") < 0) + { curses_release_wstr(strtype, wstr); Py_XDECREF(bytesobj); return NULL; @@ -3988,7 +4260,7 @@ _curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1, } #ifdef HAVE_NCURSESW if (strtype == 2) { - if (use_xy) { + if (group_left_1) { rtn = mvwins_wstr(self->win,y,x,wstr); funcname = "mvwins_wstr"; } @@ -4002,7 +4274,7 @@ _curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1, #endif { const char *str = PyBytes_AS_STRING(bytesobj); - if (use_xy) { + if (group_left_1) { rtn = mvwinsstr(self->win,y,x,str); funcname = "mvwinsstr"; } @@ -4012,15 +4284,14 @@ _curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1, } Py_DECREF(bytesobj); } - if (rtn == ERR) { - curses_window_set_error(self, funcname, "insstr"); - return NULL; - } if (use_attr) { - rtn = wattrset(self->win, attr_old); - return curses_window_check_err(self, rtn, "wattrset", "insstr"); + int attr_rtn = curses_wattr_restore(self, attr_old, pair_old); + if (rtn != ERR) { + rtn = attr_rtn; + funcname = _CURSES_WATTR_RESTORE_FUNC; + } } - Py_RETURN_NONE; + return curses_window_check_err(self, rtn, funcname, "insstr"); } /*[clinic input] @@ -4068,6 +4339,7 @@ _curses_window_insnstr_impl(PyCursesWindowObject *self, int group_left_1, wchar_t *wstr = NULL; #endif attr_t attr_old = A_NORMAL; + int pair_old = 0; int use_xy = group_left_1, use_attr = group_right_1; const char *funcname; @@ -4092,15 +4364,17 @@ _curses_window_insnstr_impl(PyCursesWindowObject *self, int group_left_1, return NULL; if (use_attr) { - attr_old = getattrs(self->win); - if (curses_wattrset(self, attr, "insnstr") < 0) { + if (curses_wattr_save(self, &attr_old, &pair_old, "insnstr") < 0 || + curses_wattrset(self, attr, "insnstr") < 0) + { curses_release_wstr(strtype, wstr); + Py_XDECREF(bytesobj); return NULL; } } #ifdef HAVE_NCURSESW if (strtype == 2) { - if (use_xy) { + if (group_left_1) { rtn = mvwins_nwstr(self->win,y,x,wstr,n); funcname = "mvwins_nwstr"; } @@ -4114,7 +4388,7 @@ _curses_window_insnstr_impl(PyCursesWindowObject *self, int group_left_1, #endif { const char *str = PyBytes_AS_STRING(bytesobj); - if (use_xy) { + if (group_left_1) { rtn = mvwinsnstr(self->win,y,x,str,n); funcname = "mvwinsnstr"; } @@ -4124,15 +4398,14 @@ _curses_window_insnstr_impl(PyCursesWindowObject *self, int group_left_1, } Py_DECREF(bytesobj); } - if (rtn == ERR) { - curses_window_set_error(self, funcname, "insnstr"); - return NULL; - } if (use_attr) { - rtn = wattrset(self->win, attr_old); - return curses_window_check_err(self, rtn, "wattrset", "insnstr"); + int attr_rtn = curses_wattr_restore(self, attr_old, pair_old); + if (rtn != ERR) { + rtn = attr_rtn; + funcname = _CURSES_WATTR_RESTORE_FUNC; + } } - Py_RETURN_NONE; + return curses_window_check_err(self, rtn, funcname, "insnstr"); } /*[clinic input] @@ -4207,6 +4480,10 @@ _curses_window_noutrefresh_impl(PyCursesWindowObject *self) { int rtn; + if (!curses_window_check_terminal(self)) { + return NULL; + } + #ifdef py_is_pad if (py_is_pad(self->win)) { if (!group_right_1) { @@ -4437,6 +4714,10 @@ _curses_window_refresh_impl(PyCursesWindowObject *self, int group_right_1, { int rtn; + if (!curses_window_check_terminal(self)) { + return NULL; + } + #ifdef py_is_pad if (py_is_pad(self->win)) { if (!group_right_1) { @@ -4754,7 +5035,7 @@ static PyType_Spec PyCursesComplexStr_Type_spec = { }; #undef clinic_state -#if defined(HAVE_CURSES_USE_SCREEN) || defined(HAVE_CURSES_USE_WINDOW) +#if defined(_Py_HAVE_CURSES_USE_SCREEN) || defined(_Py_HAVE_CURSES_USE_WINDOW) /* Shared trampoline for window.use()/screen.use(): call func(obj, *extra, **kwargs) and store the result (NULL on exception) in data->result. */ @@ -4804,7 +5085,7 @@ curses_use_parse(PyObject *args, PyObject **func, PyObject **extra) } #endif -#ifdef HAVE_CURSES_USE_WINDOW +#ifdef _Py_HAVE_CURSES_USE_WINDOW static int curses_use_window_cb(WINDOW *Py_UNUSED(win), void *data) { @@ -4830,7 +5111,7 @@ PyCursesWindow_use(PyObject *self, PyObject *args, PyObject *kwargs) Py_DECREF(extra); return data.result; } -#endif /* HAVE_CURSES_USE_WINDOW */ +#endif /* _Py_HAVE_CURSES_USE_WINDOW */ static PyMethodDef PyCursesWindow_methods[] = { _CURSES_WINDOW_ADDCH_METHODDEF @@ -4846,12 +5127,7 @@ static PyMethodDef PyCursesWindow_methods[] = { _CURSES_WINDOW_COLOR_SET_METHODDEF _CURSES_WINDOW_GETATTRS_METHODDEF _CURSES_WINDOW_BKGD_METHODDEF -#ifdef HAVE_CURSES_WCHGAT - { - "chgat", PyCursesWindow_ChgAt, METH_VARARGS, - _curses_window_chgat__doc__ - }, -#endif + _CURSES_WINDOW_CHGAT_METHODDEF _CURSES_WINDOW_BKGDSET_METHODDEF _CURSES_WINDOW_BORDER_METHODDEF _CURSES_WINDOW_BOX_METHODDEF @@ -4899,11 +5175,9 @@ static PyMethodDef PyCursesWindow_methods[] = { {"getmaxyx", PyCursesWindow_getmaxyx, METH_NOARGS, "getmaxyx($self, /)\n--\n\n" "Return a tuple (y, x) of the window height and width."}, -#if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20110404) || defined(PDCURSES) {"getparent", PyCursesWindow_getparent, METH_NOARGS, "getparent($self, /)\n--\n\n" "Return the parent window, or None if this is not a subwindow."}, -#endif {"getparyx", PyCursesWindow_getparyx, METH_NOARGS, "getparyx($self, /)\n--\n\n" "Return (y, x) relative to the parent window, or (-1, -1) if none."}, @@ -4912,14 +5186,8 @@ static PyMethodDef PyCursesWindow_methods[] = { "getscrreg($self, /)\n--\n\n" "Return a tuple (top, bottom) of the current scrolling region."}, #endif - { - "getstr", PyCursesWindow_getstr, METH_VARARGS, - _curses_window_getstr__doc__ - }, - { - "get_wstr", PyCursesWindow_get_wstr, METH_VARARGS, - _curses_window_get_wstr__doc__ - }, + _CURSES_WINDOW_GETSTR_METHODDEF + _CURSES_WINDOW_GET_WSTR_METHODDEF {"getyx", PyCursesWindow_getyx, METH_NOARGS, "getyx($self, /)\n--\n\n" "Return a tuple (y, x) of the current cursor position."}, @@ -4946,18 +5214,9 @@ static PyMethodDef PyCursesWindow_methods[] = { "Insert a blank line under the cursor; move following lines down."}, _CURSES_WINDOW_INSNSTR_METHODDEF _CURSES_WINDOW_INSSTR_METHODDEF - { - "instr", PyCursesWindow_instr, METH_VARARGS, - _curses_window_instr__doc__ - }, - { - "in_wstr", PyCursesWindow_in_wstr, METH_VARARGS, - _curses_window_in_wstr__doc__ - }, - { - "in_wchstr", PyCursesWindow_in_wchstr, METH_VARARGS, - _curses_window_in_wchstr__doc__ - }, + _CURSES_WINDOW_INSTR_METHODDEF + _CURSES_WINDOW_IN_WSTR_METHODDEF + _CURSES_WINDOW_IN_WCHSTR_METHODDEF _CURSES_WINDOW_IS_LINETOUCHED_METHODDEF {"is_wintouched", PyCursesWindow_is_wintouched, METH_NOARGS, "is_wintouched($self, /)\n--\n\n" @@ -4991,12 +5250,12 @@ static PyMethodDef PyCursesWindow_methods[] = { "is_syncok($self, /)\n--\n\n" "Return the current value set by syncok()."}, #endif -#if defined(HAVE_CURSES_IS_KEYPAD) || defined(PDCURSES) +#if defined(_Py__Py_HAVE_CURSES_IS_KEYPAD) || defined(PDCURSES) {"is_keypad", PyCursesWindow_is_keypad, METH_NOARGS, "is_keypad($self, /)\n--\n\n" "Return the current value set by keypad()."}, #endif -#if defined(HAVE_CURSES_IS_LEAVEOK) || defined(PDCURSES) +#if defined(_Py_HAVE_CURSES_IS_LEAVEOK) || defined(PDCURSES) {"is_leaveok", PyCursesWindow_is_leaveok, METH_NOARGS, "is_leaveok($self, /)\n--\n\n" "Return the current value set by leaveok()."}, @@ -5052,7 +5311,8 @@ static PyMethodDef PyCursesWindow_methods[] = { {"standout", PyCursesWindow_wstandout, METH_NOARGS, "standout($self, /)\n--\n\n" "Turn on the A_STANDOUT attribute."}, - {"subpad", _curses_window_subwin, METH_VARARGS, _curses_window_subwin__doc__}, + {"subpad", _PyCFunction_CAST(_curses_window_subwin), METH_FASTCALL, + _curses_window_subwin__doc__}, _CURSES_WINDOW_SUBWIN_METHODDEF {"syncdown", PyCursesWindow_wsyncdown, METH_NOARGS, "syncdown($self, /)\n--\n\n" @@ -5076,7 +5336,7 @@ static PyMethodDef PyCursesWindow_methods[] = { "untouchwin($self, /)\n--\n\n" "Mark all lines in the window as unchanged since last refresh()."}, _CURSES_WINDOW_VLINE_METHODDEF -#ifdef HAVE_CURSES_USE_WINDOW +#ifdef _Py_HAVE_CURSES_USE_WINDOW {"use", _PyCFunction_CAST(PyCursesWindow_use), METH_VARARGS | METH_KEYWORDS, PyCursesWindow_use__doc__}, #endif @@ -5218,11 +5478,17 @@ static PyGetSetDef PyCursesScreen_getsets[] = { {NULL, NULL, NULL, NULL, NULL} /* sentinel */ }; -#ifdef HAVE_CURSES_USE_SCREEN +#ifdef _Py_HAVE_CURSES_USE_SCREEN static int curses_use_screen_cb(SCREEN *Py_UNUSED(sp), void *data) { - curses_use_call((curses_use_data *)data); + curses_use_data *u = (curses_use_data *)data; + PyObject *module = PyType_GetModule(Py_TYPE(u->obj)); + if (module == NULL || !update_lines_cols(module)) { + u->result = NULL; + return 0; + } + curses_use_call(u); return 0; } @@ -5235,8 +5501,8 @@ static PyObject * PyCursesScreen_use(PyObject *self, PyObject *args, PyObject *kwargs) { PyCursesScreenObject *so = _PyCursesScreenObject_CAST(self); + cursesmodule_state *state = get_cursesmodule_state_by_cls(Py_TYPE(self)); if (so->screen == NULL) { - cursesmodule_state *state = get_cursesmodule_state_by_cls(Py_TYPE(self)); PyErr_SetString(state->error, "the screen has been deleted"); return NULL; } @@ -5244,12 +5510,30 @@ PyCursesScreen_use(PyObject *self, PyObject *args, PyObject *kwargs) if (curses_use_parse(args, &func, &extra) < 0) { return NULL; } + PyObject *module = PyType_GetModule(Py_TYPE(self)); + if (module == NULL) { + Py_DECREF(extra); + return NULL; + } curses_use_data data = {self, func, extra, kwargs, NULL}; + PyObject *prev = state->topscreen; + state->topscreen = Py_NewRef(self); use_screen(so->screen, curses_use_screen_cb, &data); + Py_SETREF(state->topscreen, prev); Py_DECREF(extra); + if (data.result == NULL) { + PyObject *exc = PyErr_GetRaisedException(); + (void)update_lines_cols(module); + _PyErr_ChainExceptions1(exc); + } + else { + if (!update_lines_cols(module)) { + Py_CLEAR(data.result); + } + } return data.result; } -#endif /* HAVE_CURSES_USE_SCREEN */ +#endif /* _Py_HAVE_CURSES_USE_SCREEN */ PyDoc_STRVAR(PyCursesScreen_close__doc__, "close($self, /)\n--\n\n" @@ -5268,14 +5552,21 @@ PyCursesScreen_close(PyObject *self, PyObject *Py_UNUSED(ignored)) static PyMethodDef PyCursesScreen_methods[] = { {"close", PyCursesScreen_close, METH_NOARGS, PyCursesScreen_close__doc__}, -#ifdef HAVE_CURSES_USE_SCREEN +#ifdef _Py_HAVE_CURSES_USE_SCREEN {"use", _PyCFunction_CAST(PyCursesScreen_use), METH_VARARGS | METH_KEYWORDS, PyCursesScreen_use__doc__}, #endif {NULL, NULL} /* sentinel */ }; +PyDoc_STRVAR(PyCursesScreen_Type_doc, +"A curses screen.\n" +"\n" +"Screen objects are returned by newterm() and new_prescr(), and represent\n" +"a terminal together with its standard window, stdscr."); + static PyType_Slot PyCursesScreen_Type_slots[] = { + {Py_tp_doc, (void *)PyCursesScreen_Type_doc}, {Py_tp_methods, PyCursesScreen_methods}, {Py_tp_getset, PyCursesScreen_getsets}, {Py_tp_dealloc, PyCursesScreen_dealloc}, @@ -5413,7 +5704,7 @@ _curses_filter_impl(PyObject *module) } #endif -#ifdef HAVE_CURSES_NOFILTER +#ifdef _Py_HAVE_CURSES_NOFILTER /*[clinic input] _curses.nofilter @@ -5616,7 +5907,7 @@ _curses_color_pair_impl(PyObject *module, int pair_number) pair_number, (int)PAIR_NUMBER(A_COLOR)); return NULL; } - return PyLong_FromLong(attr); + return PyLong_FromUnsignedLongLong(attr); } /*[clinic input] @@ -5978,7 +6269,7 @@ _curses_getwin(PyObject *module, PyObject *file) return res; } -#ifdef HAVE_CURSES_SCR_DUMP +#ifdef _Py_HAVE_CURSES_SCR_DUMP /*[clinic input] _curses.scr_dump @@ -6033,6 +6324,7 @@ _curses_scr_init(PyObject *module, PyObject *filename) /*[clinic end generated code: output=2e861d381d710419 input=81c45e4702124ef6]*/ ScreenDumpFunctionBody(scr_init) +#ifdef _Py_HAVE_CURSES_SCR_SET /*[clinic input] _curses.scr_set @@ -6049,7 +6341,8 @@ static PyObject * _curses_scr_set(PyObject *module, PyObject *filename) /*[clinic end generated code: output=6056fdec12c5935f input=d248c20543cc289b]*/ ScreenDumpFunctionBody(scr_set) -#endif /* HAVE_CURSES_SCR_DUMP */ +#endif /* _Py_HAVE_CURSES_SCR_SET */ +#endif /* _Py_HAVE_CURSES_SCR_DUMP */ /*[clinic input] _curses.halfdelay @@ -6128,7 +6421,7 @@ _curses_has_key_impl(PyObject *module, int key) } #endif -#ifdef HAVE_CURSES_DEFINE_KEY +#ifdef _Py_HAVE_CURSES_DEFINE_KEY /*[clinic input] _curses.define_key @@ -6154,9 +6447,9 @@ _curses_define_key_impl(PyObject *module, const char *definition, return curses_check_err(module, define_key(definition, keycode), "define_key", NULL); } -#endif /* HAVE_CURSES_DEFINE_KEY */ +#endif /* _Py_HAVE_CURSES_DEFINE_KEY */ -#ifdef HAVE_CURSES_KEY_DEFINED +#ifdef _Py_HAVE_CURSES_KEY_DEFINED /*[clinic input] _curses.key_defined @@ -6178,9 +6471,9 @@ _curses_key_defined_impl(PyObject *module, const char *definition) return PyLong_FromLong(key_defined(definition)); } -#endif /* HAVE_CURSES_KEY_DEFINED */ +#endif /* _Py_HAVE_CURSES_KEY_DEFINED */ -#ifdef HAVE_CURSES_KEYOK +#ifdef _Py_HAVE_CURSES_KEYOK /*[clinic input] _curses.keyok @@ -6201,7 +6494,7 @@ _curses_keyok_impl(PyObject *module, int keycode, int enable) return curses_check_err(module, keyok(keycode, enable), "keyok", NULL); } -#endif /* HAVE_CURSES_KEYOK */ +#endif /* _Py_HAVE_CURSES_KEYOK */ /*[clinic input] _curses.init_color @@ -6400,9 +6693,13 @@ curses_init_dict(PyObject *module) } /* This was moved from initcurses() because it core dumped on SGI, where they're not defined until you've called initscr() */ + /* Use unsigned long long, not long: a chtype constant (the A_* attributes, + ACS_* and key codes) can set bits beyond a 32-bit long, which is what + long is on LLP64 platforms such as Windows -- A_DIM (0x80000000) would + otherwise be sign-extended to a negative number. */ #define SetDictInt(NAME, VALUE) \ do { \ - PyObject *value = PyLong_FromLong((long)(VALUE)); \ + PyObject *value = PyLong_FromUnsignedLongLong((unsigned long long)(VALUE)); \ if (value == NULL) { \ return -1; \ } \ @@ -6480,6 +6777,179 @@ curses_init_dict(PyObject *module) SetDictInt("ACS_STERLING", (ACS_STERLING)); #endif +#ifdef HAVE_NCURSESW + /* The same graphic symbols as character cells, for the methods that take + a complexchar. Unlike the ACS_* codes, these are not restricted to the + 8-bit alternate character set. */ + cursesmodule_state *state = get_cursesmodule_state(module); +#define SetDictWACS(NAME, VALUE) \ + do { \ + PyObject *value = PyCursesComplexChar_New(state, (VALUE)); \ + if (value == NULL) { \ + return -1; \ + } \ + int rc = PyDict_SetItemString(module_dict, (NAME), value); \ + Py_DECREF(value); \ + if (rc < 0) { \ + return -1; \ + } \ + } while (0) + + SetDictWACS("WACS_ULCORNER", WACS_ULCORNER); + SetDictWACS("WACS_LLCORNER", WACS_LLCORNER); + SetDictWACS("WACS_URCORNER", WACS_URCORNER); + SetDictWACS("WACS_LRCORNER", WACS_LRCORNER); + SetDictWACS("WACS_LTEE", WACS_LTEE); + SetDictWACS("WACS_RTEE", WACS_RTEE); + SetDictWACS("WACS_BTEE", WACS_BTEE); + SetDictWACS("WACS_TTEE", WACS_TTEE); + SetDictWACS("WACS_HLINE", WACS_HLINE); + SetDictWACS("WACS_VLINE", WACS_VLINE); + SetDictWACS("WACS_PLUS", WACS_PLUS); + SetDictWACS("WACS_S1", WACS_S1); + SetDictWACS("WACS_S9", WACS_S9); + SetDictWACS("WACS_DIAMOND", WACS_DIAMOND); + SetDictWACS("WACS_CKBOARD", WACS_CKBOARD); + SetDictWACS("WACS_DEGREE", WACS_DEGREE); + SetDictWACS("WACS_PLMINUS", WACS_PLMINUS); + SetDictWACS("WACS_BULLET", WACS_BULLET); + SetDictWACS("WACS_LARROW", WACS_LARROW); + SetDictWACS("WACS_RARROW", WACS_RARROW); + SetDictWACS("WACS_DARROW", WACS_DARROW); + SetDictWACS("WACS_UARROW", WACS_UARROW); + SetDictWACS("WACS_BOARD", WACS_BOARD); + SetDictWACS("WACS_LANTERN", WACS_LANTERN); + SetDictWACS("WACS_BLOCK", WACS_BLOCK); + + SetDictWACS("WACS_BSSB", WACS_ULCORNER); + SetDictWACS("WACS_SSBB", WACS_LLCORNER); + SetDictWACS("WACS_BBSS", WACS_URCORNER); + SetDictWACS("WACS_SBBS", WACS_LRCORNER); + SetDictWACS("WACS_SBSS", WACS_RTEE); + SetDictWACS("WACS_SSSB", WACS_LTEE); + SetDictWACS("WACS_SSBS", WACS_BTEE); + SetDictWACS("WACS_BSSS", WACS_TTEE); + SetDictWACS("WACS_BSBS", WACS_HLINE); + SetDictWACS("WACS_SBSB", WACS_VLINE); + SetDictWACS("WACS_SSSS", WACS_PLUS); + + /* The following are never available with strict SYSV curses */ +#ifdef WACS_S3 + SetDictWACS("WACS_S3", WACS_S3); +#endif +#ifdef WACS_S7 + SetDictWACS("WACS_S7", WACS_S7); +#endif +#ifdef WACS_LEQUAL + SetDictWACS("WACS_LEQUAL", WACS_LEQUAL); +#endif +#ifdef WACS_GEQUAL + SetDictWACS("WACS_GEQUAL", WACS_GEQUAL); +#endif +#ifdef WACS_PI + SetDictWACS("WACS_PI", WACS_PI); +#endif +#ifdef WACS_NEQUAL + SetDictWACS("WACS_NEQUAL", WACS_NEQUAL); +#endif +#ifdef WACS_STERLING + SetDictWACS("WACS_STERLING", WACS_STERLING); +#endif + + /* Double-line and thick-line symbols have no ACS_* counterpart, and are + only provided by some implementations. */ +#ifdef WACS_D_ULCORNER + SetDictWACS("WACS_D_ULCORNER", WACS_D_ULCORNER); + SetDictWACS("WACS_BDDB", WACS_D_ULCORNER); +#endif +#ifdef WACS_D_LLCORNER + SetDictWACS("WACS_D_LLCORNER", WACS_D_LLCORNER); + SetDictWACS("WACS_DDBB", WACS_D_LLCORNER); +#endif +#ifdef WACS_D_URCORNER + SetDictWACS("WACS_D_URCORNER", WACS_D_URCORNER); + SetDictWACS("WACS_BBDD", WACS_D_URCORNER); +#endif +#ifdef WACS_D_LRCORNER + SetDictWACS("WACS_D_LRCORNER", WACS_D_LRCORNER); + SetDictWACS("WACS_DBBD", WACS_D_LRCORNER); +#endif +#ifdef WACS_D_LTEE + SetDictWACS("WACS_D_LTEE", WACS_D_LTEE); + SetDictWACS("WACS_DDDB", WACS_D_LTEE); +#endif +#ifdef WACS_D_RTEE + SetDictWACS("WACS_D_RTEE", WACS_D_RTEE); + SetDictWACS("WACS_DBDD", WACS_D_RTEE); +#endif +#ifdef WACS_D_BTEE + SetDictWACS("WACS_D_BTEE", WACS_D_BTEE); + SetDictWACS("WACS_DDBD", WACS_D_BTEE); +#endif +#ifdef WACS_D_TTEE + SetDictWACS("WACS_D_TTEE", WACS_D_TTEE); + SetDictWACS("WACS_BDDD", WACS_D_TTEE); +#endif +#ifdef WACS_D_HLINE + SetDictWACS("WACS_D_HLINE", WACS_D_HLINE); + SetDictWACS("WACS_BDBD", WACS_D_HLINE); +#endif +#ifdef WACS_D_VLINE + SetDictWACS("WACS_D_VLINE", WACS_D_VLINE); + SetDictWACS("WACS_DBDB", WACS_D_VLINE); +#endif +#ifdef WACS_D_PLUS + SetDictWACS("WACS_D_PLUS", WACS_D_PLUS); + SetDictWACS("WACS_DDDD", WACS_D_PLUS); +#endif + +#ifdef WACS_T_ULCORNER + SetDictWACS("WACS_T_ULCORNER", WACS_T_ULCORNER); + SetDictWACS("WACS_BTTB", WACS_T_ULCORNER); +#endif +#ifdef WACS_T_LLCORNER + SetDictWACS("WACS_T_LLCORNER", WACS_T_LLCORNER); + SetDictWACS("WACS_TTBB", WACS_T_LLCORNER); +#endif +#ifdef WACS_T_URCORNER + SetDictWACS("WACS_T_URCORNER", WACS_T_URCORNER); + SetDictWACS("WACS_BBTT", WACS_T_URCORNER); +#endif +#ifdef WACS_T_LRCORNER + SetDictWACS("WACS_T_LRCORNER", WACS_T_LRCORNER); + SetDictWACS("WACS_TBBT", WACS_T_LRCORNER); +#endif +#ifdef WACS_T_LTEE + SetDictWACS("WACS_T_LTEE", WACS_T_LTEE); + SetDictWACS("WACS_TTTB", WACS_T_LTEE); +#endif +#ifdef WACS_T_RTEE + SetDictWACS("WACS_T_RTEE", WACS_T_RTEE); + SetDictWACS("WACS_TBTT", WACS_T_RTEE); +#endif +#ifdef WACS_T_BTEE + SetDictWACS("WACS_T_BTEE", WACS_T_BTEE); + SetDictWACS("WACS_TTBT", WACS_T_BTEE); +#endif +#ifdef WACS_T_TTEE + SetDictWACS("WACS_T_TTEE", WACS_T_TTEE); + SetDictWACS("WACS_BTTT", WACS_T_TTEE); +#endif +#ifdef WACS_T_HLINE + SetDictWACS("WACS_T_HLINE", WACS_T_HLINE); + SetDictWACS("WACS_BTBT", WACS_T_HLINE); +#endif +#ifdef WACS_T_VLINE + SetDictWACS("WACS_T_VLINE", WACS_T_VLINE); + SetDictWACS("WACS_TBTB", WACS_T_VLINE); +#endif +#ifdef WACS_T_PLUS + SetDictWACS("WACS_T_PLUS", WACS_T_PLUS); + SetDictWACS("WACS_TTTT", WACS_T_PLUS); +#endif +#undef SetDictWACS +#endif /* HAVE_NCURSESW */ + SetDictInt("LINES", LINES); SetDictInt("COLS", COLS); #undef SetDictInt @@ -6491,12 +6961,12 @@ _curses.initscr Initialize the library. -Return a WindowObject which represents the whole screen. +Return a window object which represents the whole screen. [clinic start generated code]*/ static PyObject * _curses_initscr_impl(PyObject *module) -/*[clinic end generated code: output=619fb68443810b7b input=514f4bce1821f6b5]*/ +/*[clinic end generated code: output=619fb68443810b7b input=e2bf3a061b7d948a]*/ { WINDOW *win; @@ -6507,7 +6977,23 @@ _curses_initscr_impl(PyObject *module) _curses_set_null_error(state, "wrefresh", "initscr"); return NULL; } - PyObject *winobj = PyCursesWindow_New(state, stdscr, NULL, NULL, NULL); + if (state->topscreen != NULL) { + /* The current screen is one made by newterm(); return its own + standard window instead of a second wrapper over the same + WINDOW, which would delwin() it on its own. */ + PyCursesScreenObject *so = (PyCursesScreenObject *)state->topscreen; + if (so->stdscr_win != NULL) { + if (curses_update_screen_encoding(so->stdscr_win) < 0) { + return NULL; + } + return Py_NewRef(so->stdscr_win); + } + } + /* Attach the current screen, like newwin(), newpad() and getwin() do, + so that the window keeps its screen alive. It is NULL for the + screen created by initscr(), which has no screen object. */ + PyObject *winobj = PyCursesWindow_New(state, stdscr, NULL, NULL, + state->topscreen); if (winobj == NULL) { return NULL; } @@ -6525,13 +7011,21 @@ _curses_initscr_impl(PyObject *module) return NULL; } + cursesmodule_state *state = get_cursesmodule_state(module); + if (state->prescreen != NULL) { + PyCursesScreenObject *prescreen = + _PyCursesScreenObject_CAST(state->prescreen); + assert(prescreen->screen != NULL); + prescreen->screen = NULL; + Py_CLEAR(state->prescreen); + } + curses_initscr_called = curses_setupterm_called = TRUE; if (curses_init_dict(module) < 0) { return NULL; } - cursesmodule_state *state = get_cursesmodule_state(module); PyObject *winobj = PyCursesWindow_New(state, win, NULL, NULL, NULL); if (winobj == NULL) { return NULL; @@ -6602,8 +7096,6 @@ _curses_setupterm_impl(PyObject *module, const char *term, int fd) Py_RETURN_NONE; } -static int update_lines_cols(PyObject *private_module); /* defined below */ - /* Return a file descriptor for obj, or, if obj is NULL or None, for the sys. stream. Returns -1 with an exception set on error. */ static int @@ -6707,6 +7199,13 @@ _curses_newterm_impl(PyObject *module, const char *type, PyObject *fd, cursesmodule_state *state = get_cursesmodule_state(module); /* The screen object owns the SCREEN and the streams; deleting it (when it is no longer referenced) calls delscreen() and closes the streams. */ + if (state->prescreen != NULL) { + PyCursesScreenObject *prescreen = + _PyCursesScreenObject_CAST(state->prescreen); + assert(prescreen->screen == screen); + prescreen->screen = NULL; + Py_CLEAR(state->prescreen); + } PyObject *screenobj = PyCursesScreen_New(state, screen, outfp, infp, NULL); if (screenobj == NULL) { delscreen(screen); @@ -6768,17 +7267,23 @@ _curses_set_term(PyObject *module, PyObject *screen) if (so == NULL) { return NULL; } + cursesmodule_state *state = get_cursesmodule_state(module); + if (so->stdscr_win == NULL) { + /* A screen from new_prescr() has no terminal, so it cannot become the + current one: a later refresh would dereference NULL in curses. */ + PyErr_SetString(state->error, "the screen has no terminal"); + return NULL; + } set_term(so->screen); if (!update_lines_cols(module)) { return NULL; } - cursesmodule_state *state = get_cursesmodule_state(module); PyObject *prev = state->topscreen; /* steal the owned reference */ state->topscreen = Py_NewRef(screen); return prev != NULL ? prev : Py_NewRef(Py_None); } -#ifdef HAVE_CURSES_NEW_PRESCR +#ifdef _Py_HAVE_CURSES_NEW_PRESCR /*[clinic input] _curses.new_prescr @@ -6792,15 +7297,27 @@ static PyObject * _curses_new_prescr_impl(PyObject *module) /*[clinic end generated code: output=e7de5031da7511e2 input=1a3a89d630b641c3]*/ { + cursesmodule_state *state = get_cursesmodule_state(module); + if (state->prescreen != NULL) { + return Py_NewRef(state->prescreen); + } + SCREEN *screen = new_prescr(); if (screen == NULL) { curses_set_null_error(module, "new_prescr", NULL); return NULL; } - cursesmodule_state *state = get_cursesmodule_state(module); - return PyCursesScreen_New(state, screen, NULL, NULL, NULL); + + PyObject *screenobj = PyCursesScreen_New(state, screen, NULL, NULL, NULL); + if (screenobj == NULL) { + delscreen(screen); + return NULL; + } + + state->prescreen = Py_NewRef(screenobj); + return screenobj; } -#endif /* HAVE_CURSES_NEW_PRESCR */ +#endif /* _Py_HAVE_CURSES_NEW_PRESCR */ #ifdef HAVE_CURSES_ESCDELAY /*[clinic input] @@ -7056,7 +7573,7 @@ _curses_meta_impl(PyObject *module, int yes) } #if defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES) -#if defined(HAVE_CURSES_HAS_MOUSE) || defined(PDCURSES) +#if defined(_Py_HAVE_CURSES_HAS_MOUSE) || defined(PDCURSES) /*[clinic input] _curses.has_mouse @@ -7071,7 +7588,7 @@ _curses_has_mouse_impl(PyObject *module) return PyBool_FromLong(has_mouse()); } -#endif /* HAVE_CURSES_HAS_MOUSE || PDCURSES */ +#endif /* _Py_HAVE_CURSES_HAS_MOUSE || PDCURSES */ /*[clinic input] _curses.mouseinterval @@ -7347,7 +7864,7 @@ _curses_pair_content_impl(PyObject *module, int pair_number) @permit_long_summary _curses.pair_number - attr: int + attr: attr / Return the number of the color-pair set by the specified attribute value. @@ -7356,8 +7873,8 @@ color_pair() is the counterpart to this function. [clinic start generated code]*/ static PyObject * -_curses_pair_number_impl(PyObject *module, int attr) -/*[clinic end generated code: output=85bce7d65c0aa3f4 input=b11152a78c2f9abf]*/ +_curses_pair_number_impl(PyObject *module, attr_t attr) +/*[clinic end generated code: output=04cafc9083329197 input=562273b1a12a06d2]*/ { PyCursesStatefulInitialised(module); PyCursesStatefulInitialisedColor(module); @@ -7412,9 +7929,10 @@ _curses_qiflush_impl(PyObject *module, int flag) Py_RETURN_NONE; } -#if defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM) /* Internal helper used for updating curses.LINES, curses.COLS, _curses.LINES - * and _curses.COLS. Returns 1 on success and 0 on failure. */ + * and _curses.COLS. Returns 1 on success and 0 on failure. Used + * unconditionally (e.g. by set_term()), so it must not be gated on resizeterm(). + */ static int update_lines_cols(PyObject *private_module) { @@ -7433,7 +7951,11 @@ update_lines_cols(PyObject *private_module) goto error; } - o = PyLong_FromLong(LINES); + int lines = LINES; + if (stdscr != NULL) { + lines = getmaxy(stdscr); + } + o = PyLong_FromLong(lines); if (o == NULL) { goto error; } @@ -7445,7 +7967,11 @@ update_lines_cols(PyObject *private_module) } Py_DECREF(o); - o = PyLong_FromLong(COLS); + int cols = COLS; + if (stdscr != NULL) { + cols = getmaxx(stdscr); + } + o = PyLong_FromLong(cols); if (o == NULL) { goto error; } @@ -7456,6 +7982,32 @@ update_lines_cols(PyObject *private_module) goto error; } Py_DECREF(o); + + if (curses_start_color_called) { + o = PyLong_FromUnsignedLongLong((unsigned long long)COLORS); + if (o == NULL) { + goto error; + } + if (PyDict_SetItemString(exposed_module_dict, "COLORS", o) < 0) { + goto error; + } + if (PyDict_SetItemString(private_module_dict, "COLORS", o) < 0) { + goto error; + } + Py_DECREF(o); + + o = PyLong_FromUnsignedLongLong((unsigned long long)COLOR_PAIRS); + if (o == NULL) { + goto error; + } + if (PyDict_SetItemString(exposed_module_dict, "COLOR_PAIRS", o) < 0) { + goto error; + } + if (PyDict_SetItemString(private_module_dict, "COLOR_PAIRS", o) < 0) { + goto error; + } + Py_DECREF(o); + } Py_DECREF(exposed_module); return 1; @@ -7483,8 +8035,6 @@ _curses_update_lines_cols_impl(PyObject *module) Py_RETURN_NONE; } -#endif - /*[clinic input] _curses.raw @@ -7689,7 +8239,7 @@ _curses_start_color_impl(PyObject *module) } #define DICT_ADD_INT_VALUE(NAME, VALUE) \ do { \ - PyObject *value = PyLong_FromLong((long)(VALUE)); \ + PyObject *value = PyLong_FromUnsignedLongLong((unsigned long long)(VALUE)); \ if (value == NULL) { \ return NULL; \ } \ @@ -7716,9 +8266,13 @@ Return a logical OR of all video attributes supported by the terminal. static PyObject * _curses_termattrs_impl(PyObject *module) /*[clinic end generated code: output=b06f437fce1b6fc4 input=0559882a04f84d1d]*/ -NoArgReturnIntFunctionBody(termattrs) +{ + PyCursesStatefulInitialised(module); -#ifdef HAVE_CURSES_TERM_ATTRS + return PyLong_FromUnsignedLong((unsigned long)(chtype)termattrs()); +} + +#ifdef _Py_HAVE_CURSES_TERM_ATTRS /*[clinic input] _curses.term_attrs @@ -7734,9 +8288,9 @@ _curses_term_attrs_impl(PyObject *module) { PyCursesStatefulInitialised(module); - return PyLong_FromUnsignedLong(term_attrs()); + return PyLong_FromUnsignedLongLong(term_attrs()); } -#endif /* HAVE_CURSES_TERM_ATTRS */ +#endif /* _Py_HAVE_CURSES_TERM_ATTRS */ /*[clinic input] @permit_long_summary @@ -7820,35 +8374,155 @@ _curses_tigetstr_impl(PyObject *module, const char *capname) return PyBytes_FromString( capname ); } +#ifndef NCURSES_TPARM_ARG +# define NCURSES_TPARM_ARG long +#endif + +/* Return a bit mask of the parameters of a terminfo string that curses takes + as strings: those that %s or %l follows directly after %p, as in ncurses' + _nc_tparm_analyze(). The others are numbers. */ +static unsigned int +curses_tparm_string_params(const char *str) +{ + unsigned int mask = 0; + int last = 0; /* the parameter pushed last, or 0 */ + + while (*str) { + if (*str++ != '%') { + continue; + } + /* Skip the flags, width and precision of a conversion. */ + int allowminus = 0; + while (*str) { + if (*str == ':') { + allowminus = 1; + } + else if (!(*str == '#' || *str == ' ' || *str == '.' + || Py_ISDIGIT(*str) || (*str == '-' && allowminus))) + { + break; + } + str++; + } + switch (*str) { + case 'p': + if (str[1] >= '1' && str[1] <= '9') { + last = str[1] - '0'; + } + str++; + break; + case 's': + case 'l': + if (last > 0) { + mask |= 1u << (last - 1); + } + break; + case 'd': case 'o': case 'x': case 'X': case 'c': + case '+': case '-': case '*': case '/': case 'm': + case '&': case '|': case '^': case '=': case '<': case '>': + case 'A': case 'O': case '!': case '~': + last = 0; + break; + case '\'': + str += 2; + last = 0; + break; + case '\0': + return mask; + default: + /* %P, %g, %{, %i, %?, %t, %e, %; and %% keep it. */ + break; + } + str++; + } + return mask; +} + +/* Convert a tparm() parameter: a string for those that the terminfo string + takes as strings (passing a number there would crash curses), otherwise a + number. An omitted one is 0, or NULL, which curses takes as "". */ +static int +curses_tparm_param(PyObject *arg, int argnum, int is_string, + NCURSES_TPARM_ARG *result) +{ + if (arg == NULL) { + *result = 0; + return 0; + } + if (is_string) { + if (!PyBytes_Check(arg)) { + PyErr_Format(PyExc_TypeError, + "tparm() argument %d must be bytes, not %T", + argnum, arg); + return -1; + } + const char *value = PyBytes_AS_STRING(arg); + if (strlen(value) != (size_t)PyBytes_GET_SIZE(arg)) { + PyErr_SetString(PyExc_ValueError, "embedded null byte"); + return -1; + } + *result = (NCURSES_TPARM_ARG)(intptr_t)value; + return 0; + } + if (PyBytes_Check(arg)) { + PyErr_Format(PyExc_TypeError, + "tparm() argument %d must be int, not bytes", argnum); + return -1; + } + int value = PyLong_AsInt(arg); + if (value == -1 && PyErr_Occurred()) { + return -1; + } + *result = value; + return 0; +} + /*[clinic input] _curses.tparm - str: str(accept={robuffer}) + str as string: object Parameterized byte string obtained from the terminfo database. - i1: int = 0 - i2: int = 0 - i3: int = 0 - i4: int = 0 - i5: int = 0 - i6: int = 0 - i7: int = 0 - i8: int = 0 - i9: int = 0 / + *params: tuple + Up to nine parameters. Instantiate the specified byte string with the supplied parameters. + +The parameters are integers, except in a few cases where they must be +bytes objects. [clinic start generated code]*/ static PyObject * -_curses_tparm_impl(PyObject *module, const char *str, int i1, int i2, int i3, - int i4, int i5, int i6, int i7, int i8, int i9) -/*[clinic end generated code: output=599f62b615c667ff input=5e30b15786f032aa]*/ +_curses_tparm_impl(PyObject *module, PyObject *string, PyObject *params) +/*[clinic end generated code: output=3439bb1b37a13d5b input=4889c0e3a5eab5b5]*/ { char* result = NULL; + NCURSES_TPARM_ARG values[9]; + Py_ssize_t count = PyTuple_GET_SIZE(params); + const char *str; + + if (!PyArg_Parse(string, "y:tparm", &str)) { + return NULL; + } + if (count > 9) { + PyErr_Format(PyExc_TypeError, + "tparm() takes at most 9 parameters (%zd given)", count); + return NULL; + } PyCursesStatefulSetupTermCalled(module); - result = tparm((char *)str,i1,i2,i3,i4,i5,i6,i7,i8,i9); + unsigned int strings = curses_tparm_string_params(str); + for (int i = 0; i < 9; i++) { + PyObject *arg = i < count ? PyTuple_GET_ITEM(params, i) : NULL; + if (curses_tparm_param(arg, i + 2, strings & (1u << i), + &values[i]) < 0) + { + return NULL; + } + } + result = tparm((char *)str, values[0], values[1], values[2], values[3], + values[4], values[5], values[6], values[7], values[8]); if (!result) { curses_set_null_error(module, "tparm", NULL); return NULL; @@ -7886,15 +8560,17 @@ _curses.unctrl ch: object / -Return a string which is a printable representation of the character ch. +Return a bytes object which is a printable representation of ch. -Control characters are displayed as a caret followed by the character, -for example as ^C. Printing characters are left as they are. +Control characters are displayed as a caret followed by the +character, for example as ^C. Printing characters are left as they +are. Any attributes and color pair are ignored. ch must fit in a +single byte; use wunctrl() for other characters. [clinic start generated code]*/ static PyObject * _curses_unctrl(PyObject *module, PyObject *ch) -/*[clinic end generated code: output=8e07fafc430c9434 input=cd1e35e16cd1ace4]*/ +/*[clinic end generated code: output=8e07fafc430c9434 input=eed6686669f5ca21]*/ { chtype ch_; @@ -8254,15 +8930,15 @@ NoArgNoReturnFunctionBody(slk_touch) /*[clinic input] _curses.slk_attron - attr: long + attr: attr / Add the given chtype attributes to the soft labels. [clinic start generated code]*/ static PyObject * -_curses_slk_attron_impl(PyObject *module, long attr) -/*[clinic end generated code: output=01aa29848a58ab50 input=fa198a604e3eec04]*/ +_curses_slk_attron_impl(PyObject *module, attr_t attr) +/*[clinic end generated code: output=c2a4bfac8ddbbf20 input=c2cfffeb7ce6a86e]*/ { PyCursesStatefulInitialised(module); return curses_check_err(module, slk_attron((chtype)attr), @@ -8272,15 +8948,15 @@ _curses_slk_attron_impl(PyObject *module, long attr) /*[clinic input] _curses.slk_attroff - attr: long + attr: attr / Remove the given chtype attributes from the soft labels. [clinic start generated code]*/ static PyObject * -_curses_slk_attroff_impl(PyObject *module, long attr) -/*[clinic end generated code: output=7b172cc37a17811f input=21dab55d43d30b8f]*/ +_curses_slk_attroff_impl(PyObject *module, attr_t attr) +/*[clinic end generated code: output=321a3b4dc61119bb input=2593027e03cbd302]*/ { PyCursesStatefulInitialised(module); return curses_check_err(module, slk_attroff((chtype)attr), @@ -8290,15 +8966,15 @@ _curses_slk_attroff_impl(PyObject *module, long attr) /*[clinic input] _curses.slk_attrset - attr: long + attr: attr / Set the chtype attributes of the soft labels. [clinic start generated code]*/ static PyObject * -_curses_slk_attrset_impl(PyObject *module, long attr) -/*[clinic end generated code: output=1139e2b0f757edfd input=d5c798956a5f046a]*/ +_curses_slk_attrset_impl(PyObject *module, attr_t attr) +/*[clinic end generated code: output=f396b745cb23fc01 input=5faafda445b2b158]*/ { PyCursesStatefulInitialised(module); return curses_check_err(module, slk_attrset((chtype)attr), @@ -8317,10 +8993,11 @@ _curses_slk_attr_impl(PyObject *module) /*[clinic end generated code: output=6d47752f82bdc29f input=be38805fdec52149]*/ { PyCursesStatefulInitialised(module); - return PyLong_FromUnsignedLong((unsigned long)slk_attr()); + return PyLong_FromUnsignedLongLong((unsigned long long)slk_attr()); } #endif +#ifdef _Py_HAVE_CURSES_SLK_ATTR_ON /*[clinic input] _curses.slk_attr_on @@ -8338,7 +9015,9 @@ _curses_slk_attr_on_impl(PyObject *module, attr_t attr) return curses_check_err(module, slk_attr_on(attr, NULL), "slk_attr_on", NULL); } +#endif /* _Py_HAVE_CURSES_SLK_ATTR_ON */ +#ifdef _Py_HAVE_CURSES_SLK_ATTR_OFF /*[clinic input] _curses.slk_attr_off @@ -8356,7 +9035,9 @@ _curses_slk_attr_off_impl(PyObject *module, attr_t attr) return curses_check_err(module, slk_attr_off(attr, NULL), "slk_attr_off", NULL); } +#endif /* _Py_HAVE_CURSES_SLK_ATTR_OFF */ +#ifdef _Py_HAVE_CURSES_SLK_ATTR_SET /*[clinic input] _curses.slk_attr_set @@ -8380,7 +9061,9 @@ _curses_slk_attr_set_impl(PyObject *module, attr_t attr, int pair) #endif return curses_check_err(module, rtn, "slk_attr_set", NULL); } +#endif /* _Py_HAVE_CURSES_SLK_ATTR_SET */ +#ifdef _Py_HAVE_CURSES_SLK_COLOR /*[clinic input] _curses.slk_color @@ -8395,8 +9078,15 @@ _curses_slk_color_impl(PyObject *module, int pair) /*[clinic end generated code: output=ffe4de805f9c65f5 input=b1e691a9cc6177ee]*/ { PyCursesStatefulInitialised(module); - return curses_check_err(module, slk_color((short)pair), "slk_color", NULL); + int rtn; +#if _NCURSES_EXTENDED_COLOR_FUNCS + rtn = extended_slk_color(pair); +#else + rtn = slk_color((short)pair); +#endif + return curses_check_err(module, rtn, "slk_color", NULL); } +#endif /* _Py_HAVE_CURSES_SLK_COLOR */ #ifdef HAVE_CURSES_USE_ENV /*[clinic input] @@ -8608,7 +9298,7 @@ static PyMethodDef cursesmodule_methods[] = { _CURSES_NEWPAD_METHODDEF _CURSES_NEWTERM_METHODDEF _CURSES_NEWWIN_METHODDEF -#ifdef HAVE_CURSES_NEW_PRESCR +#ifdef _Py_HAVE_CURSES_NEW_PRESCR _CURSES_NEW_PRESCR_METHODDEF #endif _CURSES_NL_METHODDEF @@ -8783,6 +9473,7 @@ cursesmodule_traverse(PyObject *mod, visitproc visit, void *arg) Py_VISIT(state->complexchar_type); Py_VISIT(state->complexstr_type); Py_VISIT(state->topscreen); + Py_VISIT(state->prescreen); return 0; } @@ -8796,6 +9487,7 @@ cursesmodule_clear(PyObject *mod) Py_CLEAR(state->complexchar_type); Py_CLEAR(state->complexstr_type); Py_CLEAR(state->topscreen); + Py_CLEAR(state->prescreen); return 0; } @@ -8889,6 +9581,17 @@ cursesmodule_exec(PyObject *module) return -1; } + /* Whether a cell holds a character or a single byte of the locale + encoding, decided when the module is built. */ +#ifdef HAVE_NCURSESW + rc = PyDict_SetItemString(module_dict, "_wide_character_support", Py_True); +#else + rc = PyDict_SetItemString(module_dict, "_wide_character_support", Py_False); +#endif + if (rc < 0) { + return -1; + } + /* Make the version available */ PyObject *curses_version = PyBytes_FromString(PyCursesVersion); if (curses_version == NULL) { @@ -8927,7 +9630,22 @@ cursesmodule_exec(PyObject *module) #define SetDictInt(NAME, VALUE) \ do { \ - PyObject *value = PyLong_FromLong((long)(VALUE)); \ + PyObject *value = PyLong_FromUnsignedLongLong((unsigned long long)(VALUE)); \ + if (value == NULL) { \ + return -1; \ + } \ + int rc = PyDict_SetItemString(module_dict, (NAME), value); \ + Py_DECREF(value); \ + if (rc < 0) { \ + return -1; \ + } \ + } while (0) + + /* ERR is -1, so it needs a signed conversion, unlike the chtype + constants below. */ +#define SetDictSignedInt(NAME, VALUE) \ + do { \ + PyObject *value = PyLong_FromLongLong((long long)(VALUE)); \ if (value == NULL) { \ return -1; \ } \ @@ -8938,8 +9656,9 @@ cursesmodule_exec(PyObject *module) } \ } while (0) - SetDictInt("ERR", ERR); - SetDictInt("OK", OK); + SetDictSignedInt("ERR", ERR); + SetDictSignedInt("OK", OK); +#undef SetDictSignedInt /* Here are some attributes you can add to chars to print */ diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index cd02b298b406e6a..a06b867049097ee 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -52,6 +52,9 @@ typedef struct { /* The interned Unix epoch datetime instance */ PyObject *epoch; + + PyObject *time_struct_time; + PyObject *time_strftime; } datetime_state; /* The module has a fixed number of static objects, due to being exposed @@ -460,124 +463,57 @@ days_before_month(int year, int month) return days; } -/* year -> number of days before January 1st of year. Remember that we - * start with year 1, so days_before_year(1) == 0. - */ -static int -days_before_year(int year) -{ - int y = year - 1; - /* This is incorrect if year <= 0; we really want the floor - * here. But so long as MINYEAR is 1, the smallest year this - * can see is 1. - */ - assert (year >= 1); - return y*365 + y/4 - y/100 + y/400; -} /* Number of days in 4, 100, and 400 year cycles. That these have * the correct values is asserted in the module init function. */ -#define DI4Y 1461 /* days_before_year(5); days in 4 years */ -#define DI100Y 36524 /* days_before_year(101); days in 100 years */ -#define DI400Y 146097 /* days_before_year(401); days in 400 years */ +#define DI4Y 1461 /* _PyTime_DaysBeforeYear(5); days in 4 years */ +#define DI100Y 36524 /* _PyTime_DaysBeforeYear(101); days in 100 years */ +#define DI400Y 146097 /* _PyTime_DaysBeforeYear(401); days in 400 years */ -/* ordinal -> year, month, day, considering 01-Jan-0001 as day 1. */ +/* ordinal -> year, month, day, considering 01-Jan-0001 as day 1. + * + * Neri and Schneider's algorithm, https://doi.org/10.1002/spe.3172; see + * _ord2ymd() in Lib/_pydatetime.py for an explanation of the steps. + * + * The intermediate values only fit in 32 bits for small ordinals; + * iso_to_ymd() passes the largest, MAXORDINAL + 2 (10000-01-02). + */ static void ord_to_ymd(int ordinal, int *year, int *month, int *day) { - int n, n1, n4, n100, n400, leapyear, preceding; - - /* ordinal is a 1-based index, starting at 1-Jan-1. The pattern of - * leap years repeats exactly every 400 years. The basic strategy is - * to find the closest 400-year boundary at or before ordinal, then - * work with the offset from that boundary to ordinal. Life is much - * clearer if we subtract 1 from ordinal first -- then the values - * of ordinal at 400-year boundaries are exactly those divisible - * by DI400Y: - * - * D M Y n n-1 - * -- --- ---- ---------- ---------------- - * 31 Dec -400 -DI400Y -DI400Y -1 - * 1 Jan -399 -DI400Y +1 -DI400Y 400-year boundary - * ... - * 30 Dec 000 -1 -2 - * 31 Dec 000 0 -1 - * 1 Jan 001 1 0 400-year boundary - * 2 Jan 001 2 1 - * 3 Jan 001 3 2 - * ... - * 31 Dec 400 DI400Y DI400Y -1 - * 1 Jan 401 DI400Y +1 DI400Y 400-year boundary - */ - assert(ordinal >= 1); - --ordinal; - n400 = ordinal / DI400Y; - n = ordinal % DI400Y; - *year = n400 * 400 + 1; - - /* Now n is the (non-negative) offset, in days, from January 1 of - * year, to the desired date. Now compute how many 100-year cycles - * precede n. - * Note that it's possible for n100 to equal 4! In that case 4 full - * 100-year cycles precede the desired day, which implies the - * desired day is December 31 at the end of a 400-year cycle. - */ - n100 = n / DI100Y; - n = n % DI100Y; - - /* Now compute how many 4-year cycles precede it. */ - n4 = n / DI4Y; - n = n % DI4Y; - - /* And now how many single years. Again n1 can be 4, and again - * meaning that the desired day is December 31 at the end of the - * 4-year cycle. - */ - n1 = n / 365; - n = n % 365; - - *year += n100 * 100 + n4 * 4 + n1; - if (n1 == 4 || n100 == 4) { - assert(n == 0); - *year -= 1; - *month = 12; - *day = 31; - return; + assert(1 <= ordinal && ordinal <= MAXORDINAL + 2); + const uint32_t days = (uint32_t)ordinal + 305; + const uint32_t century = (4 * days + 3) / DI400Y; + const uint32_t day_of_century = (4 * days + 3) % DI400Y / 4; + const uint32_t year_of_century = (4 * day_of_century + 3) / DI4Y; + const uint32_t day_of_year = (4 * day_of_century + 3) % DI4Y / 4; + const uint32_t m = (5 * day_of_year + 461) / 153; + const uint32_t d = (5 * day_of_year + 461) % 153 / 5 + 1; + const uint32_t y = 100 * century + year_of_century; + if (m > 12) { /* January or February */ + *year = (int)(y + 1); + *month = (int)(m - 12); } - - /* Now the year is correct, and n is the offset from January 1. We - * find the month via an estimate that's either exact or one too - * large. - */ - leapyear = n1 == 3 && (n4 != 24 || n100 == 3); - assert(leapyear == is_leap(*year)); - *month = (n + 50) >> 5; - preceding = (_days_before_month[*month] + (*month > 2 && leapyear)); - if (preceding > n) { - /* estimate is too large */ - *month -= 1; - preceding -= days_in_month(*year, *month); + else { + *year = (int)y; + *month = (int)m; } - n -= preceding; - assert(0 <= n); - assert(n < days_in_month(*year, *month)); - - *day = n + 1; + *day = (int)d; } /* year, month, day -> ordinal, considering 01-Jan-0001 as day 1. */ static int ymd_to_ord(int year, int month, int day) { - return days_before_year(year) + days_before_month(year, month) + day; + return _PyTime_DaysBeforeYear(year) + days_before_month(year, month) + day; } /* Day of week, where Monday==0, ..., Sunday==6. 1/1/1 was a Monday. */ static int weekday(int year, int month, int day) { - return (ymd_to_ord(year, month, day) + 6) % 7; + return _PyTime_Weekday(year, days_before_month(year, month) + day); } /* Ordinal of the Monday starting week 1 of the ISO year. Week 1 is the @@ -679,6 +615,18 @@ check_date_args(int year, int month, int day) return 0; } +static int +year_from_tm(const struct tm *tm, int *year) +{ + if (tm->tm_year > INT_MAX - 1900) { + PyErr_Format(PyExc_ValueError, "year must be in %d..%d, not %lld", + MINYEAR, MAXYEAR, (long long)tm->tm_year + 1900); + return -1; + } + *year = tm->tm_year + 1900; + return 0; +} + /* Check that time arguments are in range. Return 0 if they are. If they * aren't, raise ValueError and return -1. */ @@ -988,6 +936,10 @@ parse_isoformat_date(const char *dtstr, const size_t len, int *year, int *month, iso_day = 1; } + if ((size_t)(p - dtstr) != len) { + return -1; + } + int rv = iso_to_ymd(*year, iso_week, iso_day, year, month, day); if (rv) { return -3 + rv; @@ -1008,6 +960,9 @@ parse_isoformat_date(const char *dtstr, const size_t len, int *year, int *month, if (p == NULL) { return -1; } + if ((size_t)(p - dtstr) != len) { + return -1; + } return 0; } @@ -1043,8 +998,11 @@ parse_hh_mm_ss_ff(const char *tstr, const char *tstr_end, int *hour, } break; } - else if (p >= p_end) { - return c != '\0'; + else if (p > p_end) { + return 0; // Stopped at p_end: an offset designator or NUL + } + else if (p == p_end) { + return 1; // Stray character just before p_end } else if (has_separator && (c == ':')) { if (i == 2) { @@ -1084,8 +1042,8 @@ parse_hh_mm_ss_ff(const char *tstr, const char *tstr_end, int *hour, ++p; // skip truncated digits } - // Return 1 if it's not the end of the string - return *p != '\0'; + // Return 1 if there is unparsed text before p_end + return p != p_end; } static int @@ -1119,15 +1077,11 @@ parse_isoformat_time(const char *dtstr, size_t dtlen, int *hour, int *minute, if (rv < 0) { return rv; } + else if (rv == 1) { + return -5; // Unparsed text after the time + } else if (tzinfo_pos == p_end) { - // We know that there's no time zone, so if there's stuff at the - // end of the string it's an error. - if (rv == 1) { - return -5; - } - else { - return 0; - } + return 0; } // Special case UTC / Zulu time. @@ -1780,17 +1734,19 @@ inline static int normalize_century(void) { static int cache = -1; - if (cache < 0) { + int res = FT_ATOMIC_LOAD_INT_RELAXED(cache); + if (res < 0) { char year[5]; struct tm date = { .tm_year = -1801, .tm_mon = 0, .tm_mday = 1 }; - cache = (strftime(year, sizeof(year), "%Y", &date) && - strcmp(year, "0099") != 0); + res = (strftime(year, sizeof(year), "%Y", &date) && + strcmp(year, "0099") != 0); + FT_ATOMIC_STORE_INT_RELAXED(cache, res); } - return cache; + return res; } static PyObject * @@ -1861,12 +1817,17 @@ static PyObject * make_freplacement(PyObject *object) { char freplacement[64]; - if (PyTime_Check(object)) - sprintf(freplacement, "%06d", TIME_GET_MICROSECOND(object)); - else if (PyDateTime_Check(object)) - sprintf(freplacement, "%06d", DATE_GET_MICROSECOND(object)); - else - sprintf(freplacement, "%06d", 0); + if (PyTime_Check(object)) { + PyOS_snprintf(freplacement, sizeof(freplacement), + "%06d", TIME_GET_MICROSECOND(object)); + } + else if (PyDateTime_Check(object)) { + PyOS_snprintf(freplacement, sizeof(freplacement), + "%06d", DATE_GET_MICROSECOND(object)); + } + else { + PyOS_snprintf(freplacement, sizeof(freplacement), "%06d", 0); + } return PyUnicode_FromString(freplacement); } @@ -1892,10 +1853,12 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple, assert(object && format && timetuple); assert(PyUnicode_Check(format)); - PyObject *strftime = PyImport_ImportModuleAttrString("time", "strftime"); - if (strftime == NULL) { + PyObject *current_mod = NULL; + datetime_state *st = GET_CURRENT_STATE(current_mod); + if (st == NULL) { return NULL; } + PyObject *strftime = st->time_strftime; /* Scan the input format, looking for %z/%Z/%f escapes, building * a new format. Since computing the replacements for those codes @@ -1964,6 +1927,29 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple, } replacement = freplacement; } + else if (ch >= '1' && ch <= '6' + && i < flen && PyUnicode_READ_CHAR(format, i) == 'f') + { + /* %Nf -> first N digits of microseconds */ + i++; + if (freplacement == NULL) { + freplacement = make_freplacement(object); + if (freplacement == NULL) { + goto Error; + } + } + if (PyUnicodeWriter_WriteSubstring(writer, format, start, end) < 0) { + goto Error; + } + start = i; + Py_ssize_t precision = ch - '0'; + if (PyUnicodeWriter_WriteSubstring(writer, freplacement, + 0, precision) < 0) + { + goto Error; + } + continue; + } else if (normalize_century() && (ch == 'Y' || ch == 'G' || ch == 'F' || ch == 'C')) { @@ -2055,7 +2041,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple, Py_XDECREF(zreplacement); Py_XDECREF(colonzreplacement); Py_XDECREF(Zreplacement); - Py_XDECREF(strftime); + RELEASE_CURRENT_STATE(st, current_mod); return result; Error: @@ -2068,41 +2054,26 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple, * from C. Perhaps they should be. */ -/* Call time.time() and return its result (a Python float). */ -static PyObject * -time_time(void) -{ - PyObject *result = NULL; - PyObject *time = PyImport_ImportModuleAttrString("time", "time"); - - if (time != NULL) { - result = PyObject_CallNoArgs(time); - Py_DECREF(time); - } - return result; -} - /* Build a time.struct_time. The weekday and day number are automatically * computed from the y,m,d args. */ static PyObject * build_struct_time(int y, int m, int d, int hh, int mm, int ss, int dstflag) { - PyObject *struct_time; - PyObject *result; - - struct_time = PyImport_ImportModuleAttrString("time", "struct_time"); - if (struct_time == NULL) { + PyObject *current_mod = NULL; + datetime_state *st = GET_CURRENT_STATE(current_mod); + if (st == NULL) { return NULL; } - result = PyObject_CallFunction(struct_time, "((iiiiiiiii))", + PyObject *result = PyObject_CallFunction(st->time_struct_time, + "((iiiiiiiii))", y, m, d, hh, mm, ss, weekday(y, m, d), days_before_month(y, m) + d, dstflag); - Py_DECREF(struct_time); + RELEASE_CURRENT_STATE(st, current_mod); return result; } @@ -2130,15 +2101,25 @@ diff_to_bool(int diff, int op) /* Convert a timedelta to a number of us, * (24*3600*self.days + self.seconds)*1000000 + self.microseconds * as a Python int. - * Doing mixed-radix arithmetic by hand instead is excruciating in C, - * due to ubiquitous overflow possibilities. + * The number of whole seconds always fits in int64_t, and so does the + * number of microseconds unless the delta is very large, so compute it + * in C when possible and fall back to Python int arithmetic otherwise. + * One second is reserved at the limit so that adding the microseconds + * field cannot overflow. */ static PyObject * delta_to_microseconds(PyDateTime_Delta *self) { + const int64_t max_seconds = INT64_MAX / 1000000 - 1; + int64_t seconds = (int64_t)GET_TD_DAYS(self) * (24 * 3600) + + GET_TD_SECONDS(self); + if (-max_seconds <= seconds && seconds <= max_seconds) { + return PyLong_FromInt64(seconds * 1000000 + + GET_TD_MICROSECONDS(self)); + } + PyObject *x1 = NULL; PyObject *x2 = NULL; - PyObject *x3 = NULL; PyObject *result = NULL; PyObject *current_mod; @@ -2147,42 +2128,23 @@ delta_to_microseconds(PyDateTime_Delta *self) return NULL; } - x1 = PyLong_FromLong(GET_TD_DAYS(self)); + x1 = PyLong_FromInt64(seconds); /* days and seconds in seconds */ if (x1 == NULL) goto Done; - x2 = PyNumber_Multiply(x1, CONST_SEC_PER_DAY(st)); /* days in seconds */ + x2 = PyNumber_Multiply(x1, CONST_US_PER_SECOND(st)); /* us */ if (x2 == NULL) goto Done; - Py_SETREF(x1, NULL); - - /* x2 has days in seconds */ - x1 = PyLong_FromLong(GET_TD_SECONDS(self)); /* seconds */ - if (x1 == NULL) - goto Done; - x3 = PyNumber_Add(x1, x2); /* days and seconds in seconds */ - if (x3 == NULL) - goto Done; - Py_DECREF(x1); - Py_DECREF(x2); - /* x1 = */ x2 = NULL; - /* x3 has days+seconds in seconds */ - x1 = PyNumber_Multiply(x3, CONST_US_PER_SECOND(st)); /* us */ + /* x2 has days+seconds in us */ + Py_SETREF(x1, PyLong_FromLong(GET_TD_MICROSECONDS(self))); if (x1 == NULL) goto Done; - Py_SETREF(x3, NULL); - - /* x1 has days+seconds in us */ - x2 = PyLong_FromLong(GET_TD_MICROSECONDS(self)); - if (x2 == NULL) - goto Done; - result = PyNumber_Add(x1, x2); + result = PyNumber_Add(x2, x1); assert(result == NULL || PyLong_CheckExact(result)); Done: Py_XDECREF(x1); Py_XDECREF(x2); - Py_XDECREF(x3); RELEASE_CURRENT_STATE(st, current_mod); return result; } @@ -3290,14 +3252,18 @@ date_fromtimestamp(PyTypeObject *cls, PyObject *obj) { struct tm tm; time_t t; + int year; if (_PyTime_ObjectToTime_t(obj, &t, _PyTime_ROUND_FLOOR) == -1) return NULL; if (_PyTime_localtime(t, &tm) != 0) return NULL; + if (year_from_tm(&tm, &year) < 0) { + return NULL; + } - return new_date_subclass_ex(tm.tm_year + 1900, + return new_date_subclass_ex(year, tm.tm_mon + 1, tm.tm_mday, cls); @@ -3337,7 +3303,11 @@ datetime_date_today_impl(PyTypeObject *type) type); } - PyObject *time = time_time(); + PyTime_t ts; + if (PyTime_Time(&ts) < 0) { + return NULL; + } + PyObject *time = PyFloat_FromDouble(PyTime_AsSecondsDouble(ts)); if (time == NULL) { return NULL; } @@ -3412,7 +3382,16 @@ datetime_date_fromordinal_impl(PyTypeObject *type, int ordinal) PyErr_SetString(PyExc_ValueError, "ordinal must be >= 1"); return NULL; } - ord_to_ymd(ordinal, &year, &month, &day); + if (ordinal <= MAXORDINAL) { + ord_to_ymd(ordinal, &year, &month, &day); + } + else { + /* Out of range, but compute the year for the error message. + * The calendar repeats every 400 years (DI400Y days). */ + int cycles = (ordinal - 1) / DI400Y; + ord_to_ymd(ordinal - cycles * DI400Y, &year, &month, &day); + year += 400 * cycles; + } return new_date_subclass_ex(year, month, day, type); } @@ -3520,6 +3499,11 @@ datetime_date_strptime_impl(PyTypeObject *type, PyObject *string, PyObject *format) /*[clinic end generated code: output=454d473bee2d5161 input=2db8f0b2b5242deb]*/ { + _PyTime_StrptimeFields fields; + if (type == DATE_TYPE(NO_STATE) && + _PyTime_Strptime(string, format, &fields)) { + return new_date_ex(fields.year, fields.month, fields.day, type); + } PyObject *result; PyObject *module = PyImport_Import(&_Py_ID(_strptime)); @@ -4549,6 +4533,22 @@ static PyMethodDef timezone_methods[] = { {NULL, NULL} }; +static PyObject * +timezone_name(PyObject *op, void *Py_UNUSED(closure)) +{ + PyDateTime_TimeZone *self = PyTimeZone_CAST(op); + if (self->name == NULL) { + Py_RETURN_NONE; + } + return Py_NewRef(self->name); +} + +static PyGetSetDef timezone_getset[] = { + {"name", timezone_name, NULL, + PyDoc_STR("Name given when the timezone was created.")}, + {NULL} +}; + static PyTypeObject PyDateTime_TimeZoneType = { PyVarObject_HEAD_INIT(NULL, 0) "datetime.timezone", /* tp_name */ @@ -4579,7 +4579,7 @@ static PyTypeObject PyDateTime_TimeZoneType = { 0, /* tp_iternext */ timezone_methods, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + timezone_getset, /* tp_getset */ &PyDateTime_TZInfoType, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ @@ -4792,6 +4792,20 @@ datetime_time_strptime_impl(PyTypeObject *type, PyObject *string, PyObject *format) /*[clinic end generated code: output=ae05a9bc0241d3bf input=f01d0b9eb5383da5]*/ { + _PyTime_StrptimeFields fields; + if (type == TIME_TYPE(NO_STATE) && + _PyTime_Strptime(string, format, &fields)) { + PyObject *tzinfo = tzinfo_from_isoformat_results( + fields.gmtoff != INT_MIN, fields.gmtoff, 0); + if (tzinfo == NULL) { + return NULL; + } + PyObject *result = new_time_ex( + fields.hour, fields.minute, fields.second, fields.fraction, + tzinfo, type); + Py_DECREF(tzinfo); + return result; + } PyObject *result; PyObject *module = PyImport_Import(&_Py_ID(_strptime)); @@ -5057,22 +5071,33 @@ time_richcompare(PyObject *self, PyObject *other, int op) } /* The hard case: both aware with different UTC offsets */ else if (offset1 != Py_None && offset2 != Py_None) { - int offsecs1, offsecs2; + long long norm_us1, norm_us2; assert(offset1 != offset2); /* else last "if" handled it */ - offsecs1 = TIME_GET_HOUR(self) * 3600 + - TIME_GET_MINUTE(self) * 60 + - TIME_GET_SECOND(self) - - GET_TD_DAYS(offset1) * 86400 - - GET_TD_SECONDS(offset1); - offsecs2 = TIME_GET_HOUR(other) * 3600 + - TIME_GET_MINUTE(other) * 60 + - TIME_GET_SECOND(other) - - GET_TD_DAYS(offset2) * 86400 - - GET_TD_SECONDS(offset2); - diff = offsecs1 - offsecs2; - if (diff == 0) - diff = TIME_GET_MICROSECOND(self) - - TIME_GET_MICROSECOND(other); + norm_us1 = + ((TIME_GET_HOUR(self) * 3600 + + TIME_GET_MINUTE(self) * 60 + + TIME_GET_SECOND(self)) * 1000000LL + + TIME_GET_MICROSECOND(self)) - + ((GET_TD_DAYS(offset1) * 86400LL + + GET_TD_SECONDS(offset1)) * 1000000LL + + GET_TD_MICROSECONDS(offset1)); + norm_us2 = + ((TIME_GET_HOUR(other) * 3600 + + TIME_GET_MINUTE(other) * 60 + + TIME_GET_SECOND(other)) * 1000000LL + + TIME_GET_MICROSECOND(other)) - + ((GET_TD_DAYS(offset2) * 86400LL + + GET_TD_SECONDS(offset2)) * 1000000LL + + GET_TD_MICROSECONDS(offset2)); + if (norm_us1 < norm_us2) { + diff = -1; + } + else if (norm_us1 > norm_us2) { + diff = 1; + } + else { + diff = 0; + } result = diff_to_bool(diff, op); } else if (op == Py_EQ) { @@ -5618,7 +5643,9 @@ datetime_from_timet_and_us(PyTypeObject *cls, TM_FUNC f, time_t timet, int us, if (f(timet, &tm) != 0) return NULL; - year = tm.tm_year + 1900; + if (year_from_tm(&tm, &year) < 0) { + return NULL; + } month = tm.tm_mon + 1; day = tm.tm_mday; hour = tm.tm_hour; @@ -5861,6 +5888,22 @@ datetime_datetime_strptime_impl(PyTypeObject *type, PyObject *string, PyObject *format) /*[clinic end generated code: output=af2c2d024f3203f5 input=ef7807589f1d50e7]*/ { + /* Subclasses retain the Python parser's constructor arguments. */ + _PyTime_StrptimeFields fields; + if (type == DATETIME_TYPE(NO_STATE) && + _PyTime_Strptime(string, format, &fields)) { + PyObject *tzinfo = tzinfo_from_isoformat_results( + fields.gmtoff != INT_MIN, fields.gmtoff, 0); + if (tzinfo == NULL) { + return NULL; + } + PyObject *result = new_datetime_ex( + fields.year, fields.month, fields.day, + fields.hour, fields.minute, fields.second, fields.fraction, + tzinfo, type); + Py_DECREF(tzinfo); + return result; + } PyObject *result; PyObject *module = PyImport_Import(&_Py_ID(_strptime)); @@ -6767,6 +6810,9 @@ local_timezone_from_timestamp(time_t timestamp) struct tm local_time_tm; PyObject *nameo = NULL; const char *zone = NULL; +#ifndef HAVE_STRUCT_TM_TM_ZONE + char buf[100]; // for zone, which is used after the block below +#endif if (_PyTime_localtime(timestamp, &local_time_tm) != 0) return NULL; @@ -6777,9 +6823,9 @@ local_timezone_from_timestamp(time_t timestamp) { PyObject *local_time, *utc_time; struct tm utc_time_tm; - char buf[100]; - strftime(buf, sizeof(buf), "%Z", &local_time_tm); - zone = buf; + if (strftime(buf, sizeof(buf), "%Z", &local_time_tm) != 0) { + zone = buf; + } local_time = new_datetime(local_time_tm.tm_year + 1900, local_time_tm.tm_mon + 1, local_time_tm.tm_mday, @@ -6789,8 +6835,10 @@ local_timezone_from_timestamp(time_t timestamp) if (local_time == NULL) { return NULL; } - if (_PyTime_gmtime(timestamp, &utc_time_tm) != 0) + if (_PyTime_gmtime(timestamp, &utc_time_tm) != 0) { + Py_DECREF(local_time); return NULL; + } utc_time = new_datetime(utc_time_tm.tm_year + 1900, utc_time_tm.tm_mon + 1, utc_time_tm.tm_mday, @@ -7449,6 +7497,8 @@ init_state(datetime_state *st, PyObject *module, PyObject *old_module) .us_per_week = Py_NewRef(st_old->us_per_week), .seconds_per_day = Py_NewRef(st_old->seconds_per_day), .epoch = Py_NewRef(st_old->epoch), + .time_struct_time = Py_NewRef(st_old->time_struct_time), + .time_strftime = Py_NewRef(st_old->time_strftime), }; return 0; } @@ -7493,6 +7543,15 @@ init_state(datetime_state *st, PyObject *module, PyObject *old_module) return -1; } + st->time_struct_time = PyImport_ImportModuleAttrString("time", "struct_time"); + if (st->time_struct_time == NULL) { + return -1; + } + st->time_strftime = PyImport_ImportModuleAttrString("time", "strftime"); + if (st->time_strftime == NULL) { + return -1; + } + return 0; } @@ -7502,6 +7561,9 @@ traverse_state(datetime_state *st, visitproc visit, void *arg) /* heap types */ Py_VISIT(st->isocalendar_date_type); + Py_VISIT(st->time_struct_time); + Py_VISIT(st->time_strftime); + return 0; } @@ -7517,6 +7579,8 @@ clear_state(datetime_state *st) Py_CLEAR(st->us_per_week); Py_CLEAR(st->seconds_per_day); Py_CLEAR(st->epoch); + Py_CLEAR(st->time_struct_time); + Py_CLEAR(st->time_strftime); return 0; } @@ -7661,19 +7725,19 @@ _datetime_exec(PyObject *module) * pasting together 4 single years. */ static_assert(DI4Y == 4 * 365 + 1, "DI4Y"); - assert(DI4Y == days_before_year(4+1)); + assert(DI4Y == _PyTime_DaysBeforeYear(4+1)); /* Similarly, a 400-year cycle has an extra leap day over what we'd * get from pasting together 4 100-year cycles. */ static_assert(DI400Y == 4 * DI100Y + 1, "DI400Y"); - assert(DI400Y == days_before_year(400+1)); + assert(DI400Y == _PyTime_DaysBeforeYear(400+1)); /* OTOH, a 100-year cycle has one fewer leap day than we'd get from * pasting together 25 4-year cycles. */ static_assert(DI100Y == 25 * DI4Y - 1, "DI100Y"); - assert(DI100Y == days_before_year(100+1)); + assert(DI100Y == _PyTime_DaysBeforeYear(100+1)); if (set_current_module(interp, module) < 0) { goto error; diff --git a/Modules/_dbmmodule.c b/Modules/_dbmmodule.c index a9f4f27d9eb742e..fe2d34a53b57113 100644 --- a/Modules/_dbmmodule.c +++ b/Modules/_dbmmodule.c @@ -28,7 +28,12 @@ static const char which_dbm[] = "GNU gdbm"; #elif defined(USE_NDBM) #include + #ifdef _GDBM_H_ + /* ndbm.h is the GDBM compatibility interface. */ static const char which_dbm[] = "GNU gdbm"; + #else + static const char which_dbm[] = "ndbm"; + #endif #elif defined(USE_BERKDB) #ifndef DB_DBM_HSEARCH #define DB_DBM_HSEARCH 1 @@ -111,10 +116,16 @@ dbm_dealloc(PyObject *self) Py_DECREF(tp); } +/*[clinic input] +@critical_section +_dbm.dbm.__len__ as dbm_length +[clinic start generated code]*/ + static Py_ssize_t -dbm_length_lock_held(PyObject *self) +dbm_length_impl(dbmobject *self) +/*[clinic end generated code: output=d7ea9510562e5f86 input=f912d65e9b06fef5]*/ { - dbmobject *dp = dbmobject_CAST(self); + dbmobject *dp = self; _dbm_state *state = PyType_GetModuleState(Py_TYPE(dp)); assert(state != NULL); if (dp->di_dbm == NULL) { @@ -134,20 +145,16 @@ dbm_length_lock_held(PyObject *self) return dp->di_size; } -static Py_ssize_t -dbm_length(PyObject *self) -{ - Py_ssize_t result; - Py_BEGIN_CRITICAL_SECTION(self); - result = dbm_length_lock_held(self); - Py_END_CRITICAL_SECTION(); - return result; -} +/*[clinic input] +@critical_section +_dbm.dbm.__bool__ as dbm_bool +[clinic start generated code]*/ static int -dbm_bool_lock_held(PyObject *self) +dbm_bool_impl(dbmobject *self) +/*[clinic end generated code: output=b550ce1ae52d6ad1 input=212af765b6e60719]*/ { - dbmobject *dp = dbmobject_CAST(self); + dbmobject *dp = self; _dbm_state *state = PyType_GetModuleState(Py_TYPE(dp)); assert(state != NULL); @@ -176,22 +183,20 @@ dbm_bool_lock_held(PyObject *self) return 1; } -static int -dbm_bool(PyObject *self) -{ - int result; - Py_BEGIN_CRITICAL_SECTION(self); - result = dbm_bool_lock_held(self); - Py_END_CRITICAL_SECTION(); - return result; -} +/*[clinic input] +@critical_section +_dbm.dbm.__getitem__ as dbm_subscript + key: object + / +[clinic start generated code]*/ static PyObject * -dbm_subscript_lock_held(PyObject *self, PyObject *key) +dbm_subscript_impl(dbmobject *self, PyObject *key) +/*[clinic end generated code: output=6278465f3ff37eaa input=e748b684a0870527]*/ { datum drec, krec; Py_ssize_t tmp_size; - dbmobject *dp = dbmobject_CAST(self); + dbmobject *dp = self; _dbm_state *state = PyType_GetModuleState(Py_TYPE(dp)); assert(state != NULL); if (!PyArg_Parse(key, "s#", &krec.dptr, &tmp_size)) { @@ -213,22 +218,22 @@ dbm_subscript_lock_held(PyObject *self, PyObject *key) return PyBytes_FromStringAndSize(drec.dptr, drec.dsize); } -static PyObject * -dbm_subscript(PyObject *self, PyObject *key) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(self); - result = dbm_subscript_lock_held(self, key); - Py_END_CRITICAL_SECTION(); - return result; -} +/*[clinic input] +@critical_section +_dbm.dbm.__setitem__ as dbm_ass_sub + + v: object + w: object + / +[clinic start generated code]*/ static int -dbm_ass_sub_lock_held(PyObject *self, PyObject *v, PyObject *w) +dbm_ass_sub_impl(dbmobject *self, PyObject *v, PyObject *w) +/*[clinic end generated code: output=33e861810d1fd44a input=4f10cc93a02142ee]*/ { datum krec, drec; Py_ssize_t tmp_size; - dbmobject *dp = dbmobject_CAST(self); + dbmobject *dp = self; if ( !PyArg_Parse(v, "s#", &krec.dptr, &tmp_size) ) { PyErr_SetString(PyExc_TypeError, @@ -278,16 +283,6 @@ dbm_ass_sub_lock_held(PyObject *self, PyObject *v, PyObject *w) return 0; } -static int -dbm_ass_sub(PyObject *self, PyObject *v, PyObject *w) -{ - int result; - Py_BEGIN_CRITICAL_SECTION(self); - result = dbm_ass_sub_lock_held(self, v, w); - Py_END_CRITICAL_SECTION(); - return result; -} - /*[clinic input] @critical_section _dbm.dbm.close @@ -347,10 +342,18 @@ _dbm_dbm_keys_impl(dbmobject *self, PyTypeObject *cls) return v; } +/*[clinic input] +@critical_section +_dbm.dbm.__contains__ as dbm_contains + arg: object + / +[clinic start generated code]*/ + static int -dbm_contains_lock_held(PyObject *self, PyObject *arg) +dbm_contains_impl(dbmobject *self, PyObject *arg) +/*[clinic end generated code: output=6c42b797ada528bc input=94134e7abf3eeb6e]*/ { - dbmobject *dp = dbmobject_CAST(self); + dbmobject *dp = self; datum key, val; Py_ssize_t size; @@ -381,16 +384,6 @@ dbm_contains_lock_held(PyObject *self, PyObject *arg) return val.dptr != NULL; } -static int -dbm_contains(PyObject *self, PyObject *arg) -{ - int result; - Py_BEGIN_CRITICAL_SECTION(self); - result = dbm_contains_lock_held(self, arg); - Py_END_CRITICAL_SECTION(); - return result; -} - /*[clinic input] @critical_section _dbm.dbm.get @@ -513,15 +506,21 @@ dbm__enter__(PyObject *self, PyObject *Py_UNUSED(dummy)) return Py_NewRef(self); } +/*[clinic input] +@critical_section +_dbm.dbm.__exit__ + + *exc_info: array + +Close the database. +[clinic start generated code]*/ + static PyObject * -dbm__exit__(PyObject *self, PyObject *Py_UNUSED(args)) +_dbm_dbm___exit___impl(dbmobject *self, PyObject * const *exc_info, + Py_ssize_t exc_info_length) +/*[clinic end generated code: output=f9549bf513b3285d input=340d8190b6fb0f15]*/ { - PyObject *result; - dbmobject *dp = dbmobject_CAST(self); - Py_BEGIN_CRITICAL_SECTION(self); - result = _dbm_dbm_close_impl(dp); - Py_END_CRITICAL_SECTION(); - return result; + return _dbm_dbm_close_impl(self); } static PyMethodDef dbm_methods[] = { @@ -531,7 +530,7 @@ static PyMethodDef dbm_methods[] = { _DBM_DBM_SETDEFAULT_METHODDEF _DBM_DBM_CLEAR_METHODDEF {"__enter__", dbm__enter__, METH_NOARGS, NULL}, - {"__exit__", dbm__exit__, METH_VARARGS, NULL}, + _DBM_DBM___EXIT___METHODDEF {NULL, NULL} /* sentinel */ }; @@ -628,6 +627,136 @@ static PyMethodDef dbmmodule_methods[] = { { 0, 0 }, }; +#if defined(GDBM_VERSION_MAJOR) || defined(DB_VERSION_MAJOR) +static PyStructSequence_Field version_info_fields[] = { + {"major", "Major release number"}, + {"minor", "Minor release number"}, + {"patch", "Patch release number"}, + {0} +}; + +static PyObject * +make_version_info(PyTypeObject *type, int major, int minor, int patch) +{ + PyObject *version; + int pos = 0; + + version = PyStructSequence_New(type); + if (version == NULL) { + return NULL; + } + +#define SetItem(VALUE) \ + PyStructSequence_SET_ITEM(version, pos++, VALUE); \ + if (PyErr_Occurred()) { \ + Py_DECREF(version); \ + return NULL; \ + } + + SetItem(PyLong_FromLong(major)) + SetItem(PyLong_FromLong(minor)) + SetItem(PyLong_FromLong(patch)) +#undef SetItem + + return version; +} +#endif + +#if defined(GDBM_VERSION_MAJOR) +PyDoc_STRVAR(gdbm_version_info__doc__, +"_dbm.gdbm_version_info\n\ +\n\ +GDBM version information as a named tuple."); + +static PyStructSequence_Desc gdbm_version_info_desc = { + "_dbm.gdbm_version_info", /* name */ + gdbm_version_info__doc__, /* doc */ + version_info_fields, /* fields */ + 3 +}; + +static int +add_version_constants(PyObject *module) +{ + if (PyModule_AddStringConstant(module, "gdbm_version", gdbm_version) < 0) { + return -1; + } + PyTypeObject *version_type; + version_type = PyStructSequence_NewType(&gdbm_version_info_desc); + if (version_type == NULL) { + return -1; + } + if (PyModule_Add(module, "GDBM_VERSION_INFO", + make_version_info(version_type, GDBM_VERSION_MAJOR, + GDBM_VERSION_MINOR, GDBM_VERSION_PATCH)) < 0) + { + Py_DECREF(version_type); + return -1; + } + if (PyModule_Add(module, "gdbm_version_info", + make_version_info(version_type, gdbm_version_number[0], + gdbm_version_number[1], + gdbm_version_number[2])) < 0) + { + Py_DECREF(version_type); + return -1; + } + Py_DECREF(version_type); + return 0; +} +#elif defined(DB_VERSION_MAJOR) +PyDoc_STRVAR(bdb_version_info__doc__, +"_dbm.bdb_version_info\n\ +\n\ +Berkeley DB version information as a named tuple."); + +static PyStructSequence_Desc bdb_version_info_desc = { + "_dbm.bdb_version_info", /* name */ + bdb_version_info__doc__, /* doc */ + version_info_fields, /* fields */ + 3 +}; + +static int +add_version_constants(PyObject *module) +{ + int major, minor, patch; + const char *version = db_version(&major, &minor, &patch); + if (PyModule_AddStringConstant(module, "BDB_VERSION", DB_VERSION_STRING) < 0) { + return -1; + } + if (PyModule_AddStringConstant(module, "bdb_version", version) < 0) { + return -1; + } + PyTypeObject *version_type; + version_type = PyStructSequence_NewType(&bdb_version_info_desc); + if (version_type == NULL) { + return -1; + } + if (PyModule_Add(module, "BDB_VERSION_INFO", + make_version_info(version_type, DB_VERSION_MAJOR, + DB_VERSION_MINOR, DB_VERSION_PATCH)) < 0) + { + Py_DECREF(version_type); + return -1; + } + if (PyModule_Add(module, "bdb_version_info", + make_version_info(version_type, major, minor, patch)) < 0) + { + Py_DECREF(version_type); + return -1; + } + Py_DECREF(version_type); + return 0; +} +#else +static int +add_version_constants(PyObject *module) +{ + return 0; +} +#endif + static int _dbm_exec(PyObject *module) { @@ -644,6 +773,9 @@ _dbm_exec(PyObject *module) if (PyModule_AddStringConstant(module, "library", which_dbm) < 0) { return -1; } + if (add_version_constants(module) < 0) { + return -1; + } if (PyModule_AddType(module, (PyTypeObject *)state->dbm_error) < 0) { return -1; } diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index dc1b3c06bed9521..3a128a13222f9b5 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -57,7 +57,6 @@ #define _PY_DEC_ROUND_GUARD (MPD_ROUND_GUARD-1) #endif -#include "clinic/_decimal.c.h" #define MPD_SPEC_VERSION "1.70" // Highest version of the spec this complies with // See https://speleotrove.com/decimal/decarith.html @@ -66,8 +65,9 @@ module _decimal class _decimal.Decimal "PyObject *" "&dec_spec" class _decimal.Context "PyObject *" "&context_spec" +class _decimal.ContextManager "PyDecContextManagerObject *" "&ctxmanager_spec" [clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=a6a6c0bdf4e576ef]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=52b8c97cabc5bf05]*/ struct PyDecContextObject; struct DecCondMap; @@ -234,6 +234,8 @@ typedef struct { PyObject *global; } PyDecContextManagerObject; +#include "clinic/_decimal.c.h" + #define _PyDecContextManagerObject_CAST(op) ((PyDecContextManagerObject *)(op)) #undef MPD @@ -346,30 +348,6 @@ static const char *dec_signal_string[MPD_NUM_FLAGS] = { "Underflow", }; -static const char *invalid_rounding_err = -"valid values for rounding are:\n\ - [ROUND_CEILING, ROUND_FLOOR, ROUND_UP, ROUND_DOWN,\n\ - ROUND_HALF_UP, ROUND_HALF_DOWN, ROUND_HALF_EVEN,\n\ - ROUND_05UP]"; - -static const char *invalid_signals_err = -"valid values for signals are:\n\ - [InvalidOperation, FloatOperation, DivisionByZero,\n\ - Overflow, Underflow, Subnormal, Inexact, Rounded,\n\ - Clamped]"; - -#ifdef EXTRA_FUNCTIONALITY -static const char *invalid_flags_err = -"valid values for _flags or _traps are:\n\ - signals:\n\ - [DecIEEEInvalidOperation, DecFloatOperation, DecDivisionByZero,\n\ - DecOverflow, DecUnderflow, DecSubnormal, DecInexact, DecRounded,\n\ - DecClamped]\n\ - conditions which trigger DecIEEEInvalidOperation:\n\ - [DecInvalidOperation, DecConversionSyntax, DecDivisionImpossible,\n\ - DecDivisionUndefined, DecFpuError, DecInvalidContext, DecMallocError]"; -#endif - static int value_error_int(const char *mesg) { @@ -440,7 +418,11 @@ exception_as_flag(decimal_state *state, PyObject *ex) } } - PyErr_SetString(PyExc_KeyError, invalid_signals_err); + PyErr_SetString(PyExc_KeyError, + "valid values for signals are:\n" + " [InvalidOperation, FloatOperation, DivisionByZero,\n" + " Overflow, Underflow, Subnormal, Inexact, Rounded,\n" + " Clamped]"); return DEC_INVALID_SIGNALS; } @@ -599,7 +581,15 @@ long_as_flags(PyObject *v) return DEC_ERR_OCCURRED; } if (x < 0 || x > (long)MPD_Max_status) { - PyErr_SetString(PyExc_TypeError, invalid_flags_err); + PyErr_SetString(PyExc_TypeError, + "valid values for _flags or _traps are:\n" + " signals:\n" + " [DecIEEEInvalidOperation, DecFloatOperation, DecDivisionByZero,\n" + " DecOverflow, DecUnderflow, DecSubnormal, DecInexact, DecRounded,\n" + " DecClamped]\n" + " conditions which trigger DecIEEEInvalidOperation:\n" + " [DecInvalidOperation, DecConversionSyntax, DecDivisionImpossible,\n" + " DecDivisionUndefined, DecFpuError, DecInvalidContext, DecMallocError]"); return DEC_INVALID_SIGNALS; } @@ -655,7 +645,11 @@ getround(decimal_state *state, PyObject *v) } } - return type_error_int(invalid_rounding_err); + return type_error_int( + "valid values for rounding are:\n" + " [ROUND_CEILING, ROUND_FLOOR, ROUND_UP, ROUND_DOWN,\n" + " ROUND_HALF_UP, ROUND_HALF_DOWN, ROUND_HALF_EVEN,\n" + " ROUND_05UP]"); } @@ -669,7 +663,7 @@ getround(decimal_state *state, PyObject *v) initialized to new SignalDicts. Once a SignalDict is tied to a context, it cannot be deleted. */ -static const char *INVALID_SIGNALDICT_ERROR_MSG = "invalid signal dict"; +static const char *const INVALID_SIGNALDICT_ERROR_MSG = "invalid signal dict"; static int signaldict_init(PyObject *self, @@ -1168,6 +1162,9 @@ context_settraps_dict(PyObject *self, PyObject *value) decimal_state *state = get_module_state_from_ctx(self); if (PyDecSignalDict_Check(state, value)) { + if (SdFlagAddr(value) == NULL) { + return value_error_int(INVALID_SIGNALDICT_ERROR_MSG); + } flags = SdFlags(value); } else { @@ -1234,6 +1231,9 @@ context_setstatus_dict(PyObject *self, PyObject *value) decimal_state *state = get_module_state_from_ctx(self); if (PyDecSignalDict_Check(state, value)) { + if (SdFlagAddr(value) == NULL) { + return value_error_int(INVALID_SIGNALDICT_ERROR_MSG); + } flags = SdFlags(value); } else { @@ -1333,32 +1333,37 @@ context_setattr(PyObject *self, PyObject *name, PyObject *value) return PyObject_GenericSetAttr(self, name, value); } +/* In the constructor None means "not specified". */ +#define NONE_TO_NULL(x) ((x) == Py_None ? NULL : (x)) + +/* Set the given attributes. An attribute is left unchanged if the + corresponding argument is NULL. */ static int context_setattrs(PyObject *self, PyObject *prec, PyObject *rounding, PyObject *emin, PyObject *emax, PyObject *capitals, PyObject *clamp, PyObject *status, PyObject *traps) { int ret; - if (prec != Py_None && context_setprec(self, prec, NULL) < 0) { + if (prec != NULL && context_setprec(self, prec, NULL) < 0) { return -1; } - if (rounding != Py_None && context_setround(self, rounding, NULL) < 0) { + if (rounding != NULL && context_setround(self, rounding, NULL) < 0) { return -1; } - if (emin != Py_None && context_setemin(self, emin, NULL) < 0) { + if (emin != NULL && context_setemin(self, emin, NULL) < 0) { return -1; } - if (emax != Py_None && context_setemax(self, emax, NULL) < 0) { + if (emax != NULL && context_setemax(self, emax, NULL) < 0) { return -1; } - if (capitals != Py_None && context_setcapitals(self, capitals, NULL) < 0) { + if (capitals != NULL && context_setcapitals(self, capitals, NULL) < 0) { return -1; } - if (clamp != Py_None && context_setclamp(self, clamp, NULL) < 0) { + if (clamp != NULL && context_setclamp(self, clamp, NULL) < 0) { return -1; } - if (traps != Py_None) { + if (traps != NULL) { if (PyList_Check(traps)) { ret = context_settraps_list(self, traps); } @@ -1374,7 +1379,7 @@ context_setattrs(PyObject *self, PyObject *prec, PyObject *rounding, return ret; } } - if (status != Py_None) { + if (status != NULL) { if (PyList_Check(status)) { ret = context_setstatus_list(self, status); } @@ -1499,6 +1504,20 @@ static int context_clear(PyObject *op) { PyDecContextObject *self = _PyDecContextObject_CAST(op); + /* Since traps and flags hold a borrowed reference to the + flags stored in the context object, these references need + to be cleared when the context object is deallocated + because traps and flags can survive. See gh-146011. */ + PyDecSignalDictObject *traps = _PyDecSignalDictObject_CAST(self->traps); + PyDecSignalDictObject *flags = _PyDecSignalDictObject_CAST(self->flags); + + if (traps != NULL) { + traps->flags = NULL; + } + if (flags != NULL) { + flags->flags = NULL; + } + Py_CLEAR(self->traps); Py_CLEAR(self->flags); return 0; @@ -1545,10 +1564,11 @@ context_init_impl(PyObject *self, PyObject *prec, PyObject *rounding, PyObject *clamp, PyObject *status, PyObject *traps) /*[clinic end generated code: output=8bfdc59fbe862f44 input=45c704b93cd02959]*/ { + /* The context has already been initialized with the default values. */ return context_setattrs( - self, prec, rounding, - emin, emax, capitals, - clamp, status, traps + self, NONE_TO_NULL(prec), NONE_TO_NULL(rounding), + NONE_TO_NULL(emin), NONE_TO_NULL(emax), NONE_TO_NULL(capitals), + NONE_TO_NULL(clamp), NONE_TO_NULL(status), NONE_TO_NULL(traps) ); } @@ -1676,12 +1696,12 @@ _decimal.Context.copy cls: defining_class -Return a duplicate of the context with all flags cleared. +Return a duplicate of the context. [clinic start generated code]*/ static PyObject * _decimal_Context_copy_impl(PyObject *self, PyTypeObject *cls) -/*[clinic end generated code: output=31c9c8eeb0c0cf77 input=aef1c0bddabdf8f0]*/ +/*[clinic end generated code: output=31c9c8eeb0c0cf77 input=87f8b92b1c7462a5]*/ { decimal_state *state = PyType_GetModuleState(cls); @@ -1702,6 +1722,47 @@ _decimal_Context___copy___impl(PyObject *self, PyTypeObject *cls) return context_copy(state, self); } +/*[clinic input] +@text_signature "($self, /, **changes)" +_decimal.Context.__replace__ + + cls: defining_class + * + prec: object = NULL + rounding: object = NULL + Emin as emin: object = NULL + Emax as emax: object = NULL + capitals: object = NULL + clamp: object = NULL + flags as status: object = NULL + traps: object = NULL + +Return a copy of the context with the specified attributes replaced. +[clinic start generated code]*/ + +static PyObject * +_decimal_Context___replace___impl(PyObject *self, PyTypeObject *cls, + PyObject *prec, PyObject *rounding, + PyObject *emin, PyObject *emax, + PyObject *capitals, PyObject *clamp, + PyObject *status, PyObject *traps) +/*[clinic end generated code: output=375ef0392df682ec input=414d9d00b25af6f3]*/ +{ + decimal_state *state = PyType_GetModuleState(cls); + + PyObject *result = context_copy(state, self); + if (result == NULL) { + return NULL; + } + if (context_setattrs(result, prec, rounding, emin, emax, capitals, + clamp, status, traps) < 0) + { + Py_DECREF(result); + return NULL; + } + return result; +} + /*[clinic input] _decimal.Context.__reduce__ = _decimal.Context.copy @@ -1942,6 +2003,13 @@ current_context(decimal_state *state) } if (tl_context != NULL) { + if (!PyDecContext_Check(state, tl_context)) { + PyErr_Format(PyExc_TypeError, + "current decimal context must be a Context " + "instance, got %T", tl_context); + Py_DECREF(tl_context); + return NULL; + } return tl_context; } @@ -2038,14 +2106,14 @@ _decimal.localcontext ctx as local: object = None * - prec: object = None - rounding: object = None - Emin: object = None - Emax: object = None - capitals: object = None - clamp: object = None - flags: object = None - traps: object = None + prec: object = NULL + rounding: object = NULL + Emin: object = NULL + Emax: object = NULL + capitals: object = NULL + clamp: object = NULL + flags: object = NULL + traps: object = NULL Return a context manager for a copy of the supplied context. @@ -2060,7 +2128,7 @@ _decimal_localcontext_impl(PyObject *module, PyObject *local, PyObject *prec, PyObject *rounding, PyObject *Emin, PyObject *Emax, PyObject *capitals, PyObject *clamp, PyObject *flags, PyObject *traps) -/*[clinic end generated code: output=9bf4e47742a809b0 input=490307b9689c3856]*/ +/*[clinic end generated code: output=9bf4e47742a809b0 input=616abb6ee1654373]*/ { PyObject *global; @@ -2148,11 +2216,21 @@ ctxmanager_set_local(PyObject *op, PyObject *Py_UNUSED(dummy)) return Py_NewRef(self->local); } +/*[clinic input] +_decimal.ContextManager.__exit__ + + *exc_info: array + +Restore the global context. +[clinic start generated code]*/ + static PyObject * -ctxmanager_restore_global(PyObject *op, PyObject *Py_UNUSED(args)) +_decimal_ContextManager___exit___impl(PyDecContextManagerObject *self, + PyObject * const *exc_info, + Py_ssize_t exc_info_length) +/*[clinic end generated code: output=744a645b0145842d input=a86ec9080e28dff3]*/ { PyObject *ret; - PyDecContextManagerObject *self = _PyDecContextManagerObject_CAST(op); ret = PyDec_SetCurrentContext(PyType_GetModule(Py_TYPE(self)), self->global); if (ret == NULL) { return NULL; @@ -2165,7 +2243,7 @@ ctxmanager_restore_global(PyObject *op, PyObject *Py_UNUSED(args)) static PyMethodDef ctxmanager_methods[] = { {"__enter__", ctxmanager_set_local, METH_NOARGS, NULL}, - {"__exit__", ctxmanager_restore_global, METH_VARARGS, NULL}, + _DECIMAL_CONTEXTMANAGER___EXIT___METHODDEF {NULL, NULL} }; @@ -3248,6 +3326,7 @@ PyDec_FromObject(PyObject *v, PyObject *context) } /*[clinic input] +@vectorcall @classmethod _decimal.Decimal.__new__ as dec_new @@ -3264,7 +3343,7 @@ trap is active. static PyObject * dec_new_impl(PyTypeObject *type, PyObject *value, PyObject *context) -/*[clinic end generated code: output=35f48a40c65625ba input=5f8a0892d3fcef80]*/ +/*[clinic end generated code: output=35f48a40c65625ba input=0e5ca99183562cd9]*/ { decimal_state *state = get_module_state_by_def(type); CONTEXT_CHECK_VA(state, context); @@ -5921,11 +6000,13 @@ static Py_hash_t dec_hash(PyObject *op) { PyDecObject *self = _PyDecObject_CAST(op); - if (self->hash == -1) { - self->hash = _dec_hash(self); - } + Py_hash_t hash = FT_ATOMIC_LOAD_SSIZE_RELAXED(self->hash); - return self->hash; + if (hash == -1) { + hash = _dec_hash(self); + FT_ATOMIC_STORE_SSIZE_RELAXED(self->hash, hash); + } + return hash; } /*[clinic input] @@ -6123,6 +6204,7 @@ static PyType_Slot dec_slots[] = { {Py_tp_methods, dec_methods}, {Py_tp_getset, dec_getsets}, {Py_tp_new, dec_new}, + {Py_tp_vectorcall, dec_vectorcall}, // Number protocol {Py_nb_add, nm_mpd_qadd}, @@ -6722,7 +6804,7 @@ _decimal.Context.power Compute a**b. If 'a' is negative, then 'b' must be integral. The result will be -inexact unless 'a' is integral and the result is finite and can be +inexact unless 'b' is integral and the result is finite and can be expressed exactly in 'precision' digits. In the Python version the result is always correctly rounded, in the C version the result is almost always correctly rounded. @@ -6740,7 +6822,7 @@ restrictions hold: static PyObject * _decimal_Context_power_impl(PyObject *context, PyTypeObject *cls, PyObject *base, PyObject *exp, PyObject *mod) -/*[clinic end generated code: output=d06d40c37cdd69dc input=178a254468ec189b]*/ +/*[clinic end generated code: output=d06d40c37cdd69dc input=660210a6607ca4b0]*/ { PyObject *a, *b, *c = NULL; PyObject *result; @@ -7000,13 +7082,19 @@ _decimal_Context_apply_impl(PyObject *context, PyTypeObject *cls, /*[clinic input] _decimal.Context.canonical = _decimal.Context.is_normal -Return a new instance of x. +Returns the same Decimal object. + +As we do not have different encodings for the same number, the +received object already is in its canonical form. + +>>> ExtendedContext.canonical(Decimal('2.50')) +Decimal('2.50') [clinic start generated code]*/ static PyObject * _decimal_Context_canonical_impl(PyObject *context, PyTypeObject *cls, PyObject *x) -/*[clinic end generated code: output=f213e433e2032e5e input=025ecb106ac15bff]*/ +/*[clinic end generated code: output=f213e433e2032e5e input=d9f19ee3e7ed9433]*/ { decimal_state *state = PyType_GetModuleState(cls); if (!PyDec_Check(state, x)) { @@ -7541,6 +7629,7 @@ static PyMethodDef context_methods [] = /* Miscellaneous */ _DECIMAL_CONTEXT___COPY___METHODDEF + _DECIMAL_CONTEXT___REPLACE___METHODDEF _DECIMAL_CONTEXT___REDUCE___METHODDEF _DECIMAL_CONTEXT_COPY_METHODDEF _DECIMAL_CONTEXT_CREATE_DECIMAL_METHODDEF @@ -7680,6 +7769,104 @@ cfunc_noargs(PyTypeObject *t, const char *name) return NULL; } +PyDoc_STRVAR(libmpdec_version_info__doc__, +"decimal.libmpdec_version_info\n\ +\n\ +libmpdec version information as a named tuple."); + +static PyStructSequence_Field libmpdec_version_info_fields[] = { + {"major", "Major release number"}, + {"minor", "Minor release number"}, + {"micro", "Micro release number"}, + {0} +}; + +static PyStructSequence_Desc libmpdec_version_info_desc = { + "decimal.libmpdec_version_info", /* name */ + libmpdec_version_info__doc__, /* doc */ + libmpdec_version_info_fields, /* fields */ + 3 +}; + +static PyObject * +make_libmpdec_version_info(PyTypeObject *type, int major, int minor, int micro) +{ + PyObject *version; + int pos = 0; + + version = PyStructSequence_New(type); + if (version == NULL) { + return NULL; + } + +#define SetItem(VALUE) \ + PyStructSequence_SET_ITEM(version, pos++, VALUE); \ + if (PyErr_Occurred()) { \ + Py_DECREF(version); \ + return NULL; \ + } + + SetItem(PyLong_FromLong(major)) + SetItem(PyLong_FromLong(minor)) + SetItem(PyLong_FromLong(micro)) +#undef SetItem + + return version; +} + +static PyObject * +parse_libmpdec_version_info(PyTypeObject *type, const char *version) +{ + int major, minor, micro; + if (sscanf(version, "%d.%d.%d", &major, &minor, µ) != 3) { + PyErr_Format(PyExc_RuntimeError, + "unexpected libmpdec version string %s", version); + return NULL; + } + return make_libmpdec_version_info(type, major, minor, micro); +} + +static int +add_version_constants(PyObject *m) +{ + const char *version = mpd_version(); + if (PyModule_AddStringConstant(m, "LIBMPDEC_VERSION", MPD_VERSION) < 0) { + return -1; + } + PyObject *obj = PyUnicode_FromString(version); + if (obj == NULL) { + return -1; + } + if (PyModule_AddObjectRef(m, "libmpdec_version", obj) < 0 || + PyModule_AddObjectRef(m, "__libmpdec_version__", obj) < 0) + { + Py_DECREF(obj); + return -1; + } + Py_DECREF(obj); + PyTypeObject *version_type; + version_type = PyStructSequence_NewType(&libmpdec_version_info_desc); + if (version_type == NULL) { + return -1; + } + if (PyModule_Add(m, "LIBMPDEC_VERSION_INFO", + make_libmpdec_version_info(version_type, MPD_MAJOR_VERSION, + MPD_MINOR_VERSION, + MPD_MICRO_VERSION)) < 0) + { + Py_DECREF(version_type); + return -1; + } + if (PyModule_Add(m, "libmpdec_version_info", + parse_libmpdec_version_info(version_type, version)) < 0) + { + Py_DECREF(version_type); + return -1; + } + Py_DECREF(version_type); + return 0; +} + static int minalloc_is_set = 0; static int @@ -7928,7 +8115,7 @@ _decimal_exec(PyObject *m) /* Add specification version number */ CHECK_INT(PyModule_AddStringConstant(m, "SPEC_VERSION", MPD_SPEC_VERSION)); - CHECK_INT(PyModule_AddStringConstant(m, "__libmpdec_version__", mpd_version())); + CHECK_INT(add_version_constants(m)); return 0; diff --git a/Modules/_decimal/clinic/_decimal.c.h b/Modules/_decimal/clinic/_decimal.c.h index c803006ad443825..8aa362b5258d7df 100644 --- a/Modules/_decimal/clinic/_decimal.c.h +++ b/Modules/_decimal/clinic/_decimal.c.h @@ -371,7 +371,7 @@ PyDoc_STRVAR(_decimal_Context_copy__doc__, "copy($self, /)\n" "--\n" "\n" -"Return a duplicate of the context with all flags cleared."); +"Return a duplicate of the context."); #define _DECIMAL_CONTEXT_COPY_METHODDEF \ {"copy", _PyCFunction_CAST(_decimal_Context_copy), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Context_copy__doc__}, @@ -410,6 +410,122 @@ _decimal_Context___copy__(PyObject *self, PyTypeObject *cls, PyObject *const *ar return _decimal_Context___copy___impl(self, cls); } +PyDoc_STRVAR(_decimal_Context___replace____doc__, +"__replace__($self, /, **changes)\n" +"--\n" +"\n" +"Return a copy of the context with the specified attributes replaced."); + +#define _DECIMAL_CONTEXT___REPLACE___METHODDEF \ + {"__replace__", _PyCFunction_CAST(_decimal_Context___replace__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Context___replace____doc__}, + +static PyObject * +_decimal_Context___replace___impl(PyObject *self, PyTypeObject *cls, + PyObject *prec, PyObject *rounding, + PyObject *emin, PyObject *emax, + PyObject *capitals, PyObject *clamp, + PyObject *status, PyObject *traps); + +static PyObject * +_decimal_Context___replace__(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 8 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(prec), &_Py_ID(rounding), &_Py_ID(Emin), &_Py_ID(Emax), &_Py_ID(capitals), &_Py_ID(clamp), &_Py_ID(flags), &_Py_ID(traps), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"prec", "rounding", "Emin", "Emax", "capitals", "clamp", "flags", "traps", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "__replace__", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[8]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *prec = NULL; + PyObject *rounding = NULL; + PyObject *emin = NULL; + PyObject *emax = NULL; + PyObject *capitals = NULL; + PyObject *clamp = NULL; + PyObject *status = NULL; + PyObject *traps = NULL; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[0]) { + prec = args[0]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[1]) { + rounding = args[1]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[2]) { + emin = args[2]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[3]) { + emax = args[3]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[4]) { + capitals = args[4]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[5]) { + clamp = args[5]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[6]) { + status = args[6]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + traps = args[7]; +skip_optional_kwonly: + return_value = _decimal_Context___replace___impl(self, cls, prec, rounding, emin, emax, capitals, clamp, status, traps); + +exit: + return return_value; +} + PyDoc_STRVAR(_decimal_Context___reduce____doc__, "__reduce__($self, /)\n" "--\n" @@ -512,14 +628,14 @@ _decimal_localcontext(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *argsbuf[9]; Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *local = Py_None; - PyObject *prec = Py_None; - PyObject *rounding = Py_None; - PyObject *Emin = Py_None; - PyObject *Emax = Py_None; - PyObject *capitals = Py_None; - PyObject *clamp = Py_None; - PyObject *flags = Py_None; - PyObject *traps = Py_None; + PyObject *prec = NULL; + PyObject *rounding = NULL; + PyObject *Emin = NULL; + PyObject *Emax = NULL; + PyObject *capitals = NULL; + PyObject *clamp = NULL; + PyObject *flags = NULL; + PyObject *traps = NULL; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); @@ -589,6 +705,34 @@ _decimal_localcontext(PyObject *module, PyObject *const *args, Py_ssize_t nargs, return return_value; } +PyDoc_STRVAR(_decimal_ContextManager___exit____doc__, +"__exit__($self, /, *exc_info)\n" +"--\n" +"\n" +"Restore the global context."); + +#define _DECIMAL_CONTEXTMANAGER___EXIT___METHODDEF \ + {"__exit__", _PyCFunction_CAST(_decimal_ContextManager___exit__), METH_FASTCALL, _decimal_ContextManager___exit____doc__}, + +static PyObject * +_decimal_ContextManager___exit___impl(PyDecContextManagerObject *self, + PyObject * const *exc_info, + Py_ssize_t exc_info_length); + +static PyObject * +_decimal_ContextManager___exit__(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject * const *exc_info; + Py_ssize_t exc_info_length; + + exc_info = args; + exc_info_length = nargs; + return_value = _decimal_ContextManager___exit___impl((PyDecContextManagerObject *)self, exc_info, exc_info_length); + + return return_value; +} + PyDoc_STRVAR(_decimal_Decimal_from_float__doc__, "from_float($type, f, /)\n" "--\n" @@ -618,25 +762,12 @@ static PyObject * _decimal_Decimal_from_float(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "from_float", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *pyfloat; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("from_float", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("from_float", nargs, 1, 1)) { goto exit; } pyfloat = args[0]; @@ -670,25 +801,12 @@ static PyObject * _decimal_Decimal_from_number(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "from_number", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *number; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("from_number", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("from_number", nargs, 1, 1)) { goto exit; } number = args[0]; @@ -719,25 +837,12 @@ static PyObject * _decimal_Context_create_decimal_from_float(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "create_decimal_from_float", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *f; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("create_decimal_from_float", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("create_decimal_from_float", nargs, 1, 1)) { goto exit; } f = args[0]; @@ -762,7 +867,8 @@ static PyObject * dec_new_impl(PyTypeObject *type, PyObject *value, PyObject *context); static PyObject * -dec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +dec_new_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -794,12 +900,11 @@ dec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[2]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; + Py_ssize_t noptargs = nargs + nkw - 0; PyObject *value = NULL; PyObject *context = Py_None; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 0, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -821,6 +926,47 @@ dec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +dec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return dec_new_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +dec_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *value = NULL; + PyObject *context = Py_None; + + assert(_PyType_CAST(type)->tp_new == dec_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs > 2) { + return dec_new_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + if (nargs < 1) { + goto skip_optional; + } + value = args[0]; + if (nargs < 2) { + goto skip_optional; + } + context = args[1]; +skip_optional: + return_value = dec_new_impl(_PyType_CAST(type), value, context); + + return return_value; +} + PyDoc_STRVAR(_decimal_Context_create_decimal__doc__, "create_decimal($self, num=\'0\', /)\n" "--\n" @@ -873,26 +1019,13 @@ static PyObject * _decimal_Decimal___format__(PyObject *dec, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "__format__", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *fmtarg; PyObject *override = NULL; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("__format__", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("__format__", nargs, 1, 2)) { goto exit; } if (!PyUnicode_Check(args[0])) { @@ -901,10 +1034,10 @@ _decimal_Decimal___format__(PyObject *dec, PyTypeObject *cls, PyObject *const *a } fmtarg = args[0]; if (nargs < 2) { - goto skip_optional_posonly; + goto skip_optional; } override = args[1]; -skip_optional_posonly: +skip_optional: return_value = _decimal_Decimal___format___impl(dec, cls, fmtarg, override); exit: @@ -1180,32 +1313,19 @@ static PyObject * _decimal_Decimal___round__(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "__round__", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *ndigits = NULL; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("__round__", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("__round__", nargs, 0, 1)) { goto exit; } if (nargs < 1) { - goto skip_optional_posonly; + goto skip_optional; } ndigits = args[0]; -skip_optional_posonly: +skip_optional: return_value = _decimal_Decimal___round___impl(self, cls, ndigits); exit: @@ -4012,25 +4132,12 @@ static PyObject * _decimal_Context_abs(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "abs", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("abs", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("abs", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -4056,25 +4163,12 @@ static PyObject * _decimal_Context_exp(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "exp", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("exp", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("exp", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -4100,25 +4194,12 @@ static PyObject * _decimal_Context_ln(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "ln", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("ln", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("ln", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -4145,25 +4226,12 @@ static PyObject * _decimal_Context_log10(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "log10", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("log10", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("log10", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -4192,25 +4260,12 @@ static PyObject * _decimal_Context_minus(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "minus", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("minus", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("minus", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -4237,25 +4292,12 @@ static PyObject * _decimal_Context_next_minus(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "next_minus", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("next_minus", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("next_minus", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -4282,25 +4324,12 @@ static PyObject * _decimal_Context_next_plus(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "next_plus", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("next_plus", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("next_plus", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -4327,25 +4356,12 @@ static PyObject * _decimal_Context_normalize(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "normalize", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("normalize", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("normalize", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -4373,25 +4389,12 @@ static PyObject * _decimal_Context_plus(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "plus", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("plus", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("plus", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -4418,25 +4421,12 @@ static PyObject * _decimal_Context_to_integral_value(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "to_integral_value", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("to_integral_value", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("to_integral_value", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -4463,25 +4453,12 @@ static PyObject * _decimal_Context_to_integral_exact(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "to_integral_exact", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("to_integral_exact", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("to_integral_exact", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -4508,25 +4485,12 @@ static PyObject * _decimal_Context_to_integral(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "to_integral", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("to_integral", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("to_integral", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -4552,25 +4516,12 @@ static PyObject * _decimal_Context_sqrt(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "sqrt", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("sqrt", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("sqrt", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -4597,26 +4548,13 @@ static PyObject * _decimal_Context_add(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "add", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("add", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("add", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -4644,26 +4582,13 @@ static PyObject * _decimal_Context_compare(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "compare", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("compare", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("compare", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -4691,26 +4616,13 @@ static PyObject * _decimal_Context_compare_signal(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "compare_signal", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("compare_signal", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("compare_signal", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -4738,26 +4650,13 @@ static PyObject * _decimal_Context_divide(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "divide", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("divide", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("divide", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -4785,26 +4684,13 @@ static PyObject * _decimal_Context_divide_int(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "divide_int", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("divide_int", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("divide_int", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -4832,26 +4718,13 @@ static PyObject * _decimal_Context_max(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "max", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("max", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("max", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -4879,26 +4752,13 @@ static PyObject * _decimal_Context_max_mag(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "max_mag", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("max_mag", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("max_mag", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -4926,26 +4786,13 @@ static PyObject * _decimal_Context_min(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "min", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("min", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("min", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -4973,26 +4820,13 @@ static PyObject * _decimal_Context_min_mag(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "min_mag", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("min_mag", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("min_mag", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -5020,26 +4854,13 @@ static PyObject * _decimal_Context_multiply(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "multiply", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("multiply", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("multiply", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -5067,26 +4888,13 @@ static PyObject * _decimal_Context_next_toward(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "next_toward", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("next_toward", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("next_toward", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -5114,26 +4922,13 @@ static PyObject * _decimal_Context_quantize(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "quantize", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("quantize", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("quantize", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -5164,26 +4959,13 @@ static PyObject * _decimal_Context_remainder(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "remainder", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("remainder", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("remainder", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -5214,26 +4996,13 @@ static PyObject * _decimal_Context_remainder_near(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "remainder_near", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("remainder_near", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("remainder_near", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -5261,26 +5030,13 @@ static PyObject * _decimal_Context_subtract(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "subtract", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("subtract", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("subtract", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -5328,7 +5084,7 @@ PyDoc_STRVAR(_decimal_Context_power__doc__, "Compute a**b.\n" "\n" "If \'a\' is negative, then \'b\' must be integral. The result will be\n" -"inexact unless \'a\' is integral and the result is finite and can be\n" +"inexact unless \'b\' is integral and the result is finite and can be\n" "expressed exactly in \'precision\' digits. In the Python version the\n" "result is always correctly rounded, in the C version the result is\n" "almost always correctly rounded.\n" @@ -5421,27 +5177,14 @@ static PyObject * _decimal_Context_fma(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "fma", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[3]; PyObject *x; PyObject *y; PyObject *z; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("fma", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("fma", nargs, 3, 3)) { goto exit; } x = args[0]; @@ -5492,25 +5235,12 @@ static PyObject * _decimal_Context_is_normal(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "is_normal", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("is_normal", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("is_normal", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -5537,25 +5267,12 @@ static PyObject * _decimal_Context_is_subnormal(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "is_subnormal", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("is_subnormal", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("is_subnormal", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -5582,25 +5299,12 @@ static PyObject * _decimal_Context_is_finite(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "is_finite", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("is_finite", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("is_finite", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -5627,25 +5331,12 @@ static PyObject * _decimal_Context_is_infinite(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "is_infinite", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("is_infinite", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("is_infinite", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -5672,25 +5363,12 @@ static PyObject * _decimal_Context_is_nan(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "is_nan", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("is_nan", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("is_nan", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -5717,25 +5395,12 @@ static PyObject * _decimal_Context_is_qnan(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "is_qnan", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("is_qnan", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("is_qnan", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -5762,25 +5427,12 @@ static PyObject * _decimal_Context_is_snan(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "is_snan", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("is_snan", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("is_snan", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -5807,25 +5459,12 @@ static PyObject * _decimal_Context_is_signed(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "is_signed", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("is_signed", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("is_signed", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -5852,25 +5491,12 @@ static PyObject * _decimal_Context_is_zero(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "is_zero", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("is_zero", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("is_zero", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -5897,25 +5523,12 @@ static PyObject * _decimal_Context_is_canonical(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "is_canonical", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("is_canonical", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("is_canonical", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -5942,25 +5555,12 @@ static PyObject * _decimal_Context__apply(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "_apply", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("_apply", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("_apply", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -5989,25 +5589,12 @@ static PyObject * _decimal_Context_apply(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "apply", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("apply", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("apply", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -6023,7 +5610,13 @@ PyDoc_STRVAR(_decimal_Context_canonical__doc__, "canonical($self, x, /)\n" "--\n" "\n" -"Return a new instance of x."); +"Returns the same Decimal object.\n" +"\n" +"As we do not have different encodings for the same number, the\n" +"received object already is in its canonical form.\n" +"\n" +">>> ExtendedContext.canonical(Decimal(\'2.50\'))\n" +"Decimal(\'2.50\')"); #define _DECIMAL_CONTEXT_CANONICAL_METHODDEF \ {"canonical", _PyCFunction_CAST(_decimal_Context_canonical), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _decimal_Context_canonical__doc__}, @@ -6032,29 +5625,16 @@ static PyObject * _decimal_Context_canonical_impl(PyObject *context, PyTypeObject *cls, PyObject *x); -static PyObject * -_decimal_Context_canonical(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "canonical", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; +static PyObject * +_decimal_Context_canonical(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("canonical", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("canonical", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -6081,25 +5661,12 @@ static PyObject * _decimal_Context_copy_abs(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "copy_abs", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("copy_abs", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("copy_abs", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -6126,25 +5693,12 @@ static PyObject * _decimal_Context_copy_decimal(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "copy_decimal", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("copy_decimal", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("copy_decimal", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -6171,25 +5725,12 @@ static PyObject * _decimal_Context_copy_negate(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "copy_negate", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("copy_negate", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("copy_negate", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -6215,25 +5756,12 @@ static PyObject * _decimal_Context_logb(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "logb", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("logb", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("logb", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -6273,25 +5801,12 @@ static PyObject * _decimal_Context_logical_invert(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "logical_invert", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("logical_invert", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("logical_invert", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -6318,25 +5833,12 @@ static PyObject * _decimal_Context_number_class(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "number_class", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("number_class", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("number_class", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -6363,25 +5865,12 @@ static PyObject * _decimal_Context_to_sci_string(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "to_sci_string", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("to_sci_string", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("to_sci_string", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -6408,25 +5897,12 @@ static PyObject * _decimal_Context_to_eng_string(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "to_eng_string", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *x; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("to_eng_string", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("to_eng_string", nargs, 1, 1)) { goto exit; } x = args[0]; @@ -6453,26 +5929,13 @@ static PyObject * _decimal_Context_compare_total(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "compare_total", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("compare_total", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("compare_total", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -6500,26 +5963,13 @@ static PyObject * _decimal_Context_compare_total_mag(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "compare_total_mag", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("compare_total_mag", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("compare_total_mag", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -6547,26 +5997,13 @@ static PyObject * _decimal_Context_copy_sign(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "copy_sign", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("copy_sign", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("copy_sign", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -6615,26 +6052,13 @@ static PyObject * _decimal_Context_logical_and(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "logical_and", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("logical_and", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("logical_and", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -6683,26 +6107,13 @@ static PyObject * _decimal_Context_logical_or(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "logical_or", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("logical_or", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("logical_or", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -6751,26 +6162,13 @@ static PyObject * _decimal_Context_logical_xor(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "logical_xor", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("logical_xor", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("logical_xor", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -6798,26 +6196,13 @@ static PyObject * _decimal_Context_rotate(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "rotate", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("rotate", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("rotate", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -6845,26 +6230,13 @@ static PyObject * _decimal_Context_scaleb(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "scaleb", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("scaleb", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("scaleb", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -6892,26 +6264,13 @@ static PyObject * _decimal_Context_shift(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "shift", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("shift", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("shift", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -6939,26 +6298,13 @@ static PyObject * _decimal_Context_same_quantum(PyObject *context, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "same_quantum", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *x; PyObject *y; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("same_quantum", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("same_quantum", nargs, 2, 2)) { goto exit; } x = args[0]; @@ -6984,4 +6330,4 @@ _decimal_Context_same_quantum(PyObject *context, PyTypeObject *cls, PyObject *co #ifndef _DECIMAL_CONTEXT_APPLY_METHODDEF #define _DECIMAL_CONTEXT_APPLY_METHODDEF #endif /* !defined(_DECIMAL_CONTEXT_APPLY_METHODDEF) */ -/*[clinic end generated code: output=0eb835634388294e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f9ddc00f5a7335c4 input=a9049054013a1b77]*/ diff --git a/Modules/_decimal/tests/README.txt b/Modules/_decimal/tests/README.txt index 97b6ff68a56fb7a..9ea9ef8c802ac2f 100644 --- a/Modules/_decimal/tests/README.txt +++ b/Modules/_decimal/tests/README.txt @@ -1,9 +1,4 @@ - - -This directory contains extended tests and a benchmark against decimal.py: - - bench.py -> Benchmark for small and large precisions. - Usage: ../../../python bench.py +This directory contains extended tests against decimal.py: formathelper.py -> randdec.py -> Generate test cases for deccheck.py. @@ -11,5 +6,3 @@ This directory contains extended tests and a benchmark against decimal.py: deccheck.py -> Run extended tests. Usage: ../../../python deccheck.py [--short|--medium|--long|--all] - - diff --git a/Modules/_decimal/tests/bench.py b/Modules/_decimal/tests/bench.py deleted file mode 100644 index 6605e9a92e2dde4..000000000000000 --- a/Modules/_decimal/tests/bench.py +++ /dev/null @@ -1,150 +0,0 @@ -# -# Copyright (C) 2001 Python Software Foundation. All Rights Reserved. -# Modified and extended by Stefan Krah. -# - -# Usage: ../../../python bench.py - - -import time -import sys -from functools import wraps -from test.support.import_helper import import_fresh_module - -C = import_fresh_module('decimal', fresh=['_decimal']) -P = import_fresh_module('decimal', blocked=['_decimal']) - -# -# NOTE: This is the pi function from the decimal documentation, modified -# for benchmarking purposes. Since floats do not have a context, the higher -# intermediate precision from the original is NOT used, so the modified -# algorithm only gives an approximation to the correctly rounded result. -# For serious use, refer to the documentation or the appropriate literature. -# -def pi_float(): - """native float""" - lasts, t, s, n, na, d, da = 0, 3.0, 3, 1, 0, 0, 24 - while s != lasts: - lasts = s - n, na = n+na, na+8 - d, da = d+da, da+32 - t = (t * n) / d - s += t - return s - -def pi_cdecimal(): - """cdecimal""" - D = C.Decimal - lasts, t, s, n, na, d, da = D(0), D(3), D(3), D(1), D(0), D(0), D(24) - while s != lasts: - lasts = s - n, na = n+na, na+8 - d, da = d+da, da+32 - t = (t * n) / d - s += t - return s - -def pi_decimal(): - """decimal""" - D = P.Decimal - lasts, t, s, n, na, d, da = D(0), D(3), D(3), D(1), D(0), D(0), D(24) - while s != lasts: - lasts = s - n, na = n+na, na+8 - d, da = d+da, da+32 - t = (t * n) / d - s += t - return s - -def factorial(n, m): - if (n > m): - return factorial(m, n) - elif m == 0: - return 1 - elif n == m: - return n - else: - return factorial(n, (n+m)//2) * factorial((n+m)//2 + 1, m) - -# Fix failed test cases caused by CVE-2020-10735 patch. -# See gh-95778 for details. -def increase_int_max_str_digits(maxdigits): - def _increase_int_max_str_digits(func, maxdigits=maxdigits): - @wraps(func) - def wrapper(*args, **kwargs): - previous_int_limit = sys.get_int_max_str_digits() - sys.set_int_max_str_digits(maxdigits) - ans = func(*args, **kwargs) - sys.set_int_max_str_digits(previous_int_limit) - return ans - return wrapper - return _increase_int_max_str_digits - -def test_calc_pi(): - print("\n# ======================================================================") - print("# Calculating pi, 10000 iterations") - print("# ======================================================================\n") - - to_benchmark = [pi_float, pi_decimal] - if C is not None: - to_benchmark.insert(1, pi_cdecimal) - - for prec in [9, 19]: - print("\nPrecision: %d decimal digits\n" % prec) - for func in to_benchmark: - start = time.time() - if C is not None: - C.getcontext().prec = prec - P.getcontext().prec = prec - for i in range(10000): - x = func() - print("%s:" % func.__name__.replace("pi_", "")) - print("result: %s" % str(x)) - print("time: %fs\n" % (time.time()-start)) - -@increase_int_max_str_digits(maxdigits=10000000) -def test_factorial(): - print("\n# ======================================================================") - print("# Factorial") - print("# ======================================================================\n") - - if C is not None: - c = C.getcontext() - c.prec = C.MAX_PREC - c.Emax = C.MAX_EMAX - c.Emin = C.MIN_EMIN - - for n in [100000, 1000000]: - - print("n = %d\n" % n) - - if C is not None: - # C version of decimal - start_calc = time.time() - x = factorial(C.Decimal(n), 0) - end_calc = time.time() - start_conv = time.time() - sx = str(x) - end_conv = time.time() - print("cdecimal:") - print("calculation time: %fs" % (end_calc-start_calc)) - print("conversion time: %fs\n" % (end_conv-start_conv)) - - # Python integers - start_calc = time.time() - y = factorial(n, 0) - end_calc = time.time() - start_conv = time.time() - sy = str(y) - end_conv = time.time() - - print("int:") - print("calculation time: %fs" % (end_calc-start_calc)) - print("conversion time: %fs\n\n" % (end_conv-start_conv)) - - if C is not None: - assert(sx == sy) - -if __name__ == "__main__": - test_calc_pi() - test_factorial() diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index f827274eeffba83..2195010261678f7 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -612,33 +612,41 @@ element_get_tail(ElementObject* self) return Py_NewRef(res); } -static PyObject* -subelement(PyObject *self, PyObject *args, PyObject *kwds) +/*[clinic input] +_elementtree.SubElement + + parent: object(subclass_of='get_elementtree_state(module)->Element_Type') + tag: object + attrib: object(subclass_of='&PyDict_Type', c_default='NULL') = {} + / + **extra: dict + +Create a new subelement of the parent element. +[clinic start generated code]*/ + +static PyObject * +_elementtree_SubElement_impl(PyObject *module, PyObject *parent, + PyObject *tag, PyObject *attrib, + PyObject *extra) +/*[clinic end generated code: output=42e8a4ebc5db08aa input=8588fc68283cdaa0]*/ { PyObject* elem; - elementtreestate *st = get_elementtree_state(self); - ElementObject* parent; - PyObject* tag; - PyObject* attrib = NULL; - if (!PyArg_ParseTuple(args, "O!O|O!:SubElement", - st->Element_Type, &parent, &tag, - &PyDict_Type, &attrib)) { - return NULL; - } + elementtreestate *st = get_elementtree_state(module); + ElementObject* parent_elem = (ElementObject *)parent; if (attrib) { /* attrib passed as positional arg */ attrib = PyDict_Copy(attrib); if (!attrib) return NULL; - if (kwds != NULL && PyDict_Update(attrib, kwds) < 0) { + if (extra && PyDict_Update(attrib, extra) < 0) { Py_DECREF(attrib); return NULL; } - } else if (kwds) { + } else if (extra && PyDict_GET_SIZE(extra)) { /* have keyword args */ - attrib = get_attrib_from_keywords(kwds); + attrib = get_attrib_from_keywords(extra); if (!attrib) return NULL; } else { @@ -650,7 +658,7 @@ subelement(PyObject *self, PyObject *args, PyObject *kwds) if (elem == NULL) return NULL; - if (element_add_subelement(st, parent, elem) < 0) { + if (element_add_subelement(st, parent_elem, elem) < 0) { Py_DECREF(elem); return NULL; } @@ -720,12 +728,17 @@ _elementtree.Element.append subelement: object(subclass_of='clinic_state()->Element_Type') / +Add *subelement* to the end of this element. + +The new element will appear in document order after the last +existing subelement (or directly after the text, if it's the first +subelement), but before the end tag for this element. [clinic start generated code]*/ static PyObject * _elementtree_Element_append_impl(ElementObject *self, PyTypeObject *cls, PyObject *subelement) -/*[clinic end generated code: output=d00923711ea317fc input=8baf92679f9717b8]*/ +/*[clinic end generated code: output=d00923711ea317fc input=a59ebce98937a372]*/ { elementtreestate *st = get_elementtree_state_by_cls(cls); if (element_add_subelement(st, self, subelement) < 0) @@ -737,11 +750,15 @@ _elementtree_Element_append_impl(ElementObject *self, PyTypeObject *cls, /*[clinic input] _elementtree.Element.clear +Reset element. + +This function removes all subelements, clears all attributes, and +sets the text and tail attributes to None. [clinic start generated code]*/ static PyObject * _elementtree_Element_clear_impl(ElementObject *self) -/*[clinic end generated code: output=8bcd7a51f94cfff6 input=3c719ff94bf45dd6]*/ +/*[clinic end generated code: output=8bcd7a51f94cfff6 input=135c2ab634d0fdf5]*/ { clear_extra(self); @@ -1221,24 +1238,6 @@ checkpath(PyObject* tag) } return 0; } - if (PyBytes_Check(tag)) { - const char *p = PyBytes_AS_STRING(tag); - const Py_ssize_t len = PyBytes_GET_SIZE(tag); - if (len >= 3 && p[0] == '{' && ( - p[1] == '}' || (p[1] == '*' && p[2] == '}'))) { - /* wildcard: '{}tag' or '{*}tag' */ - return 1; - } - for (i = 0; i < len; i++) { - if (p[i] == '{') - check = 0; - else if (p[i] == '}') - check = 1; - else if (check && PATHCHAR(p[i])) - return 1; - } - return 0; - } return 1; /* unknown type; might be path expression */ } @@ -1250,12 +1249,15 @@ _elementtree.Element.extend elements: object / +Append subelements from a sequence. + +*elements* is a sequence with zero or more elements. [clinic start generated code]*/ static PyObject * _elementtree_Element_extend_impl(ElementObject *self, PyTypeObject *cls, PyObject *elements) -/*[clinic end generated code: output=3e86d37fac542216 input=6479b1b5379d09ae]*/ +/*[clinic end generated code: output=3e86d37fac542216 input=401ac1d07e13282b]*/ { PyObject* seq; Py_ssize_t i; @@ -1289,12 +1291,19 @@ _elementtree.Element.find path: object namespaces: object = None +Find first matching element by tag name or path. + +*path* is a string having either an element tag or an XPath, +*namespaces* is an optional mapping from namespace prefix to full +name. + +Return the first matching element, or None if no element was found. [clinic start generated code]*/ static PyObject * _elementtree_Element_find_impl(ElementObject *self, PyTypeObject *cls, PyObject *path, PyObject *namespaces) -/*[clinic end generated code: output=18f77d393c9fef1b input=94df8a83f956acc6]*/ +/*[clinic end generated code: output=18f77d393c9fef1b input=3aec422879a342e1]*/ { elementtreestate *st = get_elementtree_state_by_cls(cls); @@ -1332,13 +1341,23 @@ _elementtree.Element.findtext default: object = None namespaces: object = None +Find text for first matching element by tag name or path. + +*path* is a string having either an element tag or an XPath, +*default* is the value to return if the element was not found, +*namespaces* is an optional mapping from namespace prefix to full +name. + +Return text content of first matching element, or default value if +none was found. Note that if an element is found having no text +content, the empty string is returned. [clinic start generated code]*/ static PyObject * _elementtree_Element_findtext_impl(ElementObject *self, PyTypeObject *cls, PyObject *path, PyObject *default_value, PyObject *namespaces) -/*[clinic end generated code: output=6af7a2d96aac32cb input=32f252099f62a3d2]*/ +/*[clinic end generated code: output=6af7a2d96aac32cb input=64610701f762c4f5]*/ { elementtreestate *st = get_elementtree_state_by_cls(cls); @@ -1381,12 +1400,19 @@ _elementtree.Element.findall path: object namespaces: object = None +Find all matching subelements by tag name or path. + +*path* is a string having either an element tag or an XPath, +*namespaces* is an optional mapping from namespace prefix to full +name. + +Returns list containing all matching elements in document order. [clinic start generated code]*/ static PyObject * _elementtree_Element_findall_impl(ElementObject *self, PyTypeObject *cls, PyObject *path, PyObject *namespaces) -/*[clinic end generated code: output=65e39a1208f3b59e input=7aa0db45673fc9a5]*/ +/*[clinic end generated code: output=65e39a1208f3b59e input=2208ddeb5f1cc7c3]*/ { elementtreestate *st = get_elementtree_state_by_cls(cls); @@ -1427,12 +1453,19 @@ _elementtree.Element.iterfind path: object namespaces: object = None +Find all matching subelements by tag name or path. + +*path* is a string having either an element tag or an XPath, +*namespaces* is an optional mapping from namespace prefix to full +name. + +Return an iterable yielding all matching elements in document order. [clinic start generated code]*/ static PyObject * _elementtree_Element_iterfind_impl(ElementObject *self, PyTypeObject *cls, PyObject *path, PyObject *namespaces) -/*[clinic end generated code: output=be5c3f697a14e676 input=88766875a5c9a88b]*/ +/*[clinic end generated code: output=be5c3f697a14e676 input=00bea06334260582]*/ { PyObject* tag = path; elementtreestate *st = get_elementtree_state_by_cls(cls); @@ -1447,20 +1480,30 @@ _elementtree.Element.get key: object default: object = None +Get element attribute. + +Equivalent to attrib.get, but some implementations may handle this a +bit more efficiently. *key* is what attribute to look for, and +*default* is what to return if the attribute was not found. + +Returns a string containing the attribute value, or the default if +attribute was not found. [clinic start generated code]*/ static PyObject * _elementtree_Element_get_impl(ElementObject *self, PyObject *key, PyObject *default_value) -/*[clinic end generated code: output=523c614142595d75 input=ee153bbf8cdb246e]*/ +/*[clinic end generated code: output=523c614142595d75 input=332624526ef81a70]*/ { if (self->extra && self->extra->attrib) { PyObject *attrib = Py_NewRef(self->extra->attrib); - PyObject *value = Py_XNewRef(PyDict_GetItemWithError(attrib, key)); - Py_DECREF(attrib); - if (value != NULL || PyErr_Occurred()) { + PyObject *value; + if (PyDict_GetItemRef(attrib, key, &value) != 0) { + Py_DECREF(attrib); + // The key exists or an error occurred return value; } + Py_DECREF(attrib); } return Py_NewRef(default_value); @@ -1478,21 +1521,29 @@ _elementtree.Element.iter / tag: object = None +Create tree iterator. + +The iterator loops over the element and all subelements in document +order, returning all elements with a matching tag. + +If the tree structure is modified during iteration, new or removed +elements may or may not be included. To get a stable set, use the +list() function on the iterator, and loop over the resulting list. + +*tag* is what tags to look for (default is to return all elements) + +Return an iterator containing all the matching elements. [clinic start generated code]*/ static PyObject * _elementtree_Element_iter_impl(ElementObject *self, PyTypeObject *cls, PyObject *tag) -/*[clinic end generated code: output=bff29dc5d4566c68 input=f6944c48d3f84c58]*/ +/*[clinic end generated code: output=bff29dc5d4566c68 input=e4c542a12e6f9199]*/ { if (PyUnicode_Check(tag)) { if (PyUnicode_GET_LENGTH(tag) == 1 && PyUnicode_READ_CHAR(tag, 0) == '*') tag = Py_None; } - else if (PyBytes_Check(tag)) { - if (PyBytes_GET_SIZE(tag) == 1 && *PyBytes_AS_STRING(tag) == '*') - tag = Py_None; - } elementtreestate *st = get_elementtree_state_by_cls(cls); return create_elementiter(st, self, tag, 0); @@ -1505,11 +1556,15 @@ _elementtree.Element.itertext cls: defining_class / +Create text iterator. + +The iterator loops over the element and all subelements in document +order, returning all inner text. [clinic start generated code]*/ static PyObject * _elementtree_Element_itertext_impl(ElementObject *self, PyTypeObject *cls) -/*[clinic end generated code: output=fdeb2a3bca0ae063 input=a1ef1f0fc872a586]*/ +/*[clinic end generated code: output=fdeb2a3bca0ae063 input=eaffe70224da7f02]*/ { elementtreestate *st = get_elementtree_state_by_cls(cls); return create_elementiter(st, self, Py_None, 1); @@ -1556,12 +1611,13 @@ _elementtree.Element.insert subelement: object(subclass_of='clinic_state()->Element_Type') / +Insert *subelement* at position *index*. [clinic start generated code]*/ static PyObject * _elementtree_Element_insert_impl(ElementObject *self, Py_ssize_t index, PyObject *subelement) -/*[clinic end generated code: output=990adfef4d424c0b input=9530f4905aa401ca]*/ +/*[clinic end generated code: output=990adfef4d424c0b input=2886a2266de15ed7]*/ { Py_ssize_t i; @@ -1594,11 +1650,14 @@ _elementtree_Element_insert_impl(ElementObject *self, Py_ssize_t index, /*[clinic input] _elementtree.Element.items +Get element attributes as (name, value) pairs. + +Equivalent to attrib.items(). [clinic start generated code]*/ static PyObject * _elementtree_Element_items_impl(ElementObject *self) -/*[clinic end generated code: output=6db2c778ce3f5a4d input=adbe09aaea474447]*/ +/*[clinic end generated code: output=6db2c778ce3f5a4d input=7b5adcd8f774d4e0]*/ { if (!self->extra || !self->extra->attrib) return PyList_New(0); @@ -1609,11 +1668,14 @@ _elementtree_Element_items_impl(ElementObject *self) /*[clinic input] _elementtree.Element.keys +Get attribute names. + +Equivalent to attrib.keys() [clinic start generated code]*/ static PyObject * _elementtree_Element_keys_impl(ElementObject *self) -/*[clinic end generated code: output=bc5bfabbf20eeb3c input=f02caf5b496b5b0b]*/ +/*[clinic end generated code: output=bc5bfabbf20eeb3c input=6d860fbdb565115d]*/ { if (!self->extra || !self->extra->attrib) return PyList_New(0); @@ -1639,12 +1701,19 @@ _elementtree.Element.makeelement attrib: object(subclass_of='&PyDict_Type') / +Create a new element with the same type. + +*tag* is a string containing the element name. *attrib* is a +dictionary containing the element attributes. + +Do not call this method, use the SubElement factory function +instead. [clinic start generated code]*/ static PyObject * _elementtree_Element_makeelement_impl(ElementObject *self, PyTypeObject *cls, PyObject *tag, PyObject *attrib) -/*[clinic end generated code: output=d50bb17a47077d47 input=589829dab92f26e8]*/ +/*[clinic end generated code: output=d50bb17a47077d47 input=02b62a503fa25ae7]*/ { PyObject* elem; @@ -1666,11 +1735,20 @@ _elementtree.Element.remove subelement: object(subclass_of='clinic_state()->Element_Type') / +Remove matching subelement. + +Unlike the find methods, this method compares elements based on +identity, NOT ON tag value or contents. To remove subelements by +other means, the easiest way is to use a list comprehension to +select what elements to keep, and then use slice assignment to +update the parent element. + +ValueError is raised if a matching element could not be found. [clinic start generated code]*/ static PyObject * _elementtree_Element_remove_impl(ElementObject *self, PyObject *subelement) -/*[clinic end generated code: output=38fe6c07d6d87d1f input=6133e1d05597d5ee]*/ +/*[clinic end generated code: output=38fe6c07d6d87d1f input=e035af9d920f785b]*/ { Py_ssize_t i; // When iterating over the list of children, we need to check that the @@ -1748,12 +1826,17 @@ _elementtree.Element.set value: object / +Set element attribute. + +Equivalent to attrib[key] = value, but some implementations may +handle this a bit more efficiently. *key* is what attribute to set, +and *value* is the attribute value to set it to. [clinic start generated code]*/ static PyObject * _elementtree_Element_set_impl(ElementObject *self, PyObject *key, PyObject *value) -/*[clinic end generated code: output=fb938806be3c5656 input=1efe90f7d82b3fe9]*/ +/*[clinic end generated code: output=fb938806be3c5656 input=bbaadd68b86636d7]*/ { PyObject* attrib; @@ -2308,7 +2391,9 @@ elementiter_next(PyObject *op) if (it->sought_tag == Py_None) return (PyObject *)elem; - rc = PyObject_RichCompareBool(elem->tag, it->sought_tag, Py_EQ); + PyObject *tag = Py_NewRef(elem->tag); + rc = PyObject_RichCompareBool(tag, it->sought_tag, Py_EQ); + Py_DECREF(tag); if (rc > 0) return (PyObject *)elem; @@ -2409,14 +2494,6 @@ typedef struct { PyObject *pi_factory; /* element tracing */ - PyObject *events_append; /* the append method of the list of events, or NULL */ - PyObject *start_event_obj; /* event objects (NULL to ignore) */ - PyObject *end_event_obj; - PyObject *start_ns_event_obj; - PyObject *end_ns_event_obj; - PyObject *comment_event_obj; - PyObject *pi_event_obj; - char insert_comments; char insert_pis; elementtreestate *state; @@ -2450,10 +2527,6 @@ treebuilder_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } t->index = 0; - t->events_append = NULL; - t->start_event_obj = t->end_event_obj = NULL; - t->start_ns_event_obj = t->end_ns_event_obj = NULL; - t->comment_event_obj = t->pi_event_obj = NULL; t->insert_comments = t->insert_pis = 0; t->state = get_elementtree_state_by_type(type); } @@ -2470,6 +2543,24 @@ _elementtree.TreeBuilder.__init__ insert_comments: bool = False insert_pis: bool = False +Generic element structure builder. + +This builder converts a sequence of start, data, and end method +calls to a well-formed element structure. + +You can use this class to build an element structure using a custom +XML parser, or a parser for some other XML-like format. + +*element_factory* is an optional element factory which is called +to create new Element instances, as necessary. + +*comment_factory* is a factory to create comments to be used instead +of the standard factory. If *insert_comments* is false (the +default), comments will not be inserted into the tree. + +*pi_factory* is a factory to create processing instructions to be +used instead of the standard factory. If *insert_pis* is false (the +default), processing instructions will not be inserted into the tree. [clinic start generated code]*/ static int @@ -2478,7 +2569,7 @@ _elementtree_TreeBuilder___init___impl(TreeBuilderObject *self, PyObject *comment_factory, PyObject *pi_factory, int insert_comments, int insert_pis) -/*[clinic end generated code: output=8571d4dcadfdf952 input=ae98a94df20b5cc3]*/ +/*[clinic end generated code: output=8571d4dcadfdf952 input=24fb5a482d93f8e4]*/ { if (element_factory != Py_None) { Py_XSETREF(self->element_factory, Py_NewRef(element_factory)); @@ -2518,13 +2609,6 @@ treebuilder_gc_traverse(PyObject *op, visitproc visit, void *arg) { TreeBuilderObject *self = _TreeBuilder_CAST(op); Py_VISIT(Py_TYPE(self)); - Py_VISIT(self->pi_event_obj); - Py_VISIT(self->comment_event_obj); - Py_VISIT(self->end_ns_event_obj); - Py_VISIT(self->start_ns_event_obj); - Py_VISIT(self->end_event_obj); - Py_VISIT(self->start_event_obj); - Py_VISIT(self->events_append); Py_VISIT(self->root); Py_VISIT(self->this); Py_VISIT(self->last); @@ -2541,13 +2625,6 @@ static int treebuilder_gc_clear(PyObject *op) { TreeBuilderObject *self = _TreeBuilder_CAST(op); - Py_CLEAR(self->pi_event_obj); - Py_CLEAR(self->comment_event_obj); - Py_CLEAR(self->end_ns_event_obj); - Py_CLEAR(self->start_ns_event_obj); - Py_CLEAR(self->end_event_obj); - Py_CLEAR(self->start_event_obj); - Py_CLEAR(self->events_append); Py_CLEAR(self->stack); Py_CLEAR(self->data); Py_CLEAR(self->last); @@ -2717,24 +2794,6 @@ treebuilder_add_subelement(elementtreestate *st, PyObject *element, } } -LOCAL(int) -treebuilder_append_event(TreeBuilderObject *self, PyObject *action, - PyObject *node) -{ - if (action != NULL) { - PyObject *res; - PyObject *event = _PyTuple_FromPair(action, node); - if (event == NULL) - return -1; - res = PyObject_CallOneArg(self->events_append, event); - Py_DECREF(event); - if (res == NULL) - return -1; - Py_DECREF(res); - } - return 0; -} - /* -------------------------------------------------------------------- */ /* handlers */ @@ -2800,9 +2859,6 @@ treebuilder_handle_start(TreeBuilderObject* self, PyObject* tag, Py_SETREF(self->this, Py_NewRef(node)); Py_SETREF(self->last, Py_NewRef(node)); - if (treebuilder_append_event(self, self->start_event_obj, node) < 0) - goto error; - return node; error: @@ -2822,17 +2878,7 @@ treebuilder_handle_data(TreeBuilderObject* self, PyObject* data) self->data = Py_NewRef(data); } else { /* more than one item; use a list to collect items */ - if (PyBytes_CheckExact(self->data) - && _PyObject_IsUniquelyReferenced(self->data) - && PyBytes_CheckExact(data) && PyBytes_GET_SIZE(data) == 1) { - /* XXX this code path unused in Python 3? */ - /* expat often generates single character data sections; handle - the most common case by resizing the existing string... */ - Py_ssize_t size = PyBytes_GET_SIZE(self->data); - if (_PyBytes_Resize(&self->data, size + 1) < 0) - return NULL; - PyBytes_AS_STRING(self->data)[size] = PyBytes_AS_STRING(data)[0]; - } else if (PyList_CheckExact(self->data)) { + if (PyList_CheckExact(self->data)) { if (PyList_Append(self->data, data) < 0) return NULL; } else { @@ -2873,11 +2919,6 @@ treebuilder_handle_end(TreeBuilderObject* self, PyObject* tag) Py_DECREF(last); Py_XDECREF(last_for_tail); - if (treebuilder_append_event(self, self->end_event_obj, self->last) < 0) { - Py_DECREF(this); - return NULL; - } - return this; } @@ -2907,11 +2948,6 @@ treebuilder_handle_comment(TreeBuilderObject* self, PyObject* text) comment = Py_NewRef(text); } - if (self->events_append && self->comment_event_obj) { - if (treebuilder_append_event(self, self->comment_event_obj, comment) < 0) - goto error; - } - return comment; error: @@ -2950,11 +2986,6 @@ treebuilder_handle_pi(TreeBuilderObject* self, PyObject* target, PyObject* text) } } - if (self->events_append && self->pi_event_obj) { - if (treebuilder_append_event(self, self->pi_event_obj, pi) < 0) - goto error; - } - return pi; error: @@ -2962,39 +2993,6 @@ treebuilder_handle_pi(TreeBuilderObject* self, PyObject* target, PyObject* text) return NULL; } -LOCAL(PyObject*) -treebuilder_handle_start_ns(TreeBuilderObject* self, PyObject* prefix, PyObject* uri) -{ - PyObject* parcel; - - if (self->events_append && self->start_ns_event_obj) { - parcel = _PyTuple_FromPair(prefix, uri); - if (!parcel) { - return NULL; - } - - if (treebuilder_append_event(self, self->start_ns_event_obj, parcel) < 0) { - Py_DECREF(parcel); - return NULL; - } - Py_DECREF(parcel); - } - - Py_RETURN_NONE; -} - -LOCAL(PyObject*) -treebuilder_handle_end_ns(TreeBuilderObject* self, PyObject* prefix) -{ - if (self->events_append && self->end_ns_event_obj) { - if (treebuilder_append_event(self, self->end_ns_event_obj, prefix) < 0) { - return NULL; - } - } - - Py_RETURN_NONE; -} - /* -------------------------------------------------------------------- */ /* methods (in alphabetical order) */ @@ -3004,11 +3002,12 @@ _elementtree.TreeBuilder.data data: object / +Add text to current element. [clinic start generated code]*/ static PyObject * _elementtree_TreeBuilder_data_impl(TreeBuilderObject *self, PyObject *data) -/*[clinic end generated code: output=dfa02b68f732b8c0 input=a0540c532b284d29]*/ +/*[clinic end generated code: output=dfa02b68f732b8c0 input=679b26864cecbde8]*/ { return treebuilder_handle_data(self, data); } @@ -3019,11 +3018,14 @@ _elementtree.TreeBuilder.end tag: object / +Close and return current Element. + +*tag* is the element name. [clinic start generated code]*/ static PyObject * _elementtree_TreeBuilder_end_impl(TreeBuilderObject *self, PyObject *tag) -/*[clinic end generated code: output=84cb6ca9008ec740 input=22dc3674236f5745]*/ +/*[clinic end generated code: output=84cb6ca9008ec740 input=9d161338282e5fac]*/ { return treebuilder_handle_end(self, tag); } @@ -3034,12 +3036,15 @@ _elementtree.TreeBuilder.comment text: object / +Create a comment using the comment_factory. + +*text* is the text of the comment. [clinic start generated code]*/ static PyObject * _elementtree_TreeBuilder_comment_impl(TreeBuilderObject *self, PyObject *text) -/*[clinic end generated code: output=a555ef39027c3823 input=47e7ebc48ed01dfa]*/ +/*[clinic end generated code: output=a555ef39027c3823 input=b1579b62bb9277e4]*/ { return treebuilder_handle_comment(self, text); } @@ -3051,12 +3056,16 @@ _elementtree.TreeBuilder.pi text: object = None / +Create a processing instruction using the pi_factory. + +*target* is the target name of the processing instruction. *text* is +the data of the processing instruction, or ''. [clinic start generated code]*/ static PyObject * _elementtree_TreeBuilder_pi_impl(TreeBuilderObject *self, PyObject *target, PyObject *text) -/*[clinic end generated code: output=21eb95ec9d04d1d9 input=349342bd79c35570]*/ +/*[clinic end generated code: output=21eb95ec9d04d1d9 input=160b939cc17e4121]*/ { return treebuilder_handle_pi(self, target, text); } @@ -3079,11 +3088,12 @@ treebuilder_done(TreeBuilderObject* self) /*[clinic input] _elementtree.TreeBuilder.close +Flush builder buffers and return toplevel document Element. [clinic start generated code]*/ static PyObject * _elementtree_TreeBuilder_close_impl(TreeBuilderObject *self) -/*[clinic end generated code: output=b441fee3202f61ee input=f7c9c65dc718de14]*/ +/*[clinic end generated code: output=b441fee3202f61ee input=461e8391c6b73c5f]*/ { return treebuilder_done(self); } @@ -3095,12 +3105,16 @@ _elementtree.TreeBuilder.start attrs: object(subclass_of='&PyDict_Type') / +Open new element and return it. + +*tag* is the element name, *attrs* is a dict containing element +attributes. [clinic start generated code]*/ static PyObject * _elementtree_TreeBuilder_start_impl(TreeBuilderObject *self, PyObject *tag, PyObject *attrs) -/*[clinic end generated code: output=e7e9dc2861349411 input=7288e9e38e63b2b6]*/ +/*[clinic end generated code: output=e7e9dc2861349411 input=26cccb49c3b8b12f]*/ { return treebuilder_handle_start(self, tag, attrs); } @@ -3125,6 +3139,15 @@ typedef struct { PyObject *handle_start_ns; PyObject *handle_end_ns; + + /* event reporting for the pull API */ + PyObject *events_append; /* the append method of the list of events */ + PyObject *start_event_obj; /* event objects (NULL to ignore) */ + PyObject *end_event_obj; + PyObject *start_ns_event_obj; + PyObject *end_ns_event_obj; + PyObject *comment_event_obj; + PyObject *pi_event_obj; PyObject *handle_start; PyObject *handle_data; PyObject *handle_end; @@ -3158,51 +3181,58 @@ makeuniversal(XMLParserObject* self, const char* string) if (!key) return NULL; - value = Py_XNewRef(PyDict_GetItemWithError(self->names, key)); - - if (value == NULL && !PyErr_Occurred()) { - /* new name. convert to universal name, and decode as - necessary */ + if (PyDict_GetItemRef(self->names, key, &value) != 0) { + // The key exists or an error occurred + Py_DECREF(key); + return value; + } - PyObject* tag; - char* p; - Py_ssize_t i; + /* new name. convert to universal name, and decode as + necessary */ - /* look for namespace separator */ - for (i = 0; i < size; i++) - if (string[i] == '}') - break; - if (i != size) { - /* convert to universal name */ - tag = PyBytes_FromStringAndSize(NULL, size+1); - if (tag == NULL) { - Py_DECREF(key); - return NULL; - } - p = PyBytes_AS_STRING(tag); - p[0] = '{'; - memcpy(p+1, string, size); - size++; - } else { - /* plain name; use key as tag */ - tag = Py_NewRef(key); - } + PyObject* tag; + Py_ssize_t i; - /* decode universal name */ - p = PyBytes_AS_STRING(tag); - value = PyUnicode_DecodeUTF8(p, size, "strict"); - Py_DECREF(tag); - if (!value) { + /* look for namespace separator */ + for (i = 0; i < size; i++) + if (string[i] == '}') + break; + if (i != size) { + /* convert to universal name */ + PyBytesWriter *writer = PyBytesWriter_Create(1 + size); + if (writer == NULL) { Py_DECREF(key); return NULL; } + char *p = PyBytesWriter_GetData(writer); + p[0] = '{'; + memcpy(p+1, string, size); + size++; - /* add to names dictionary */ - if (PyDict_SetItem(self->names, key, value) < 0) { + tag = PyBytesWriter_Finish(writer); + if (tag == NULL) { Py_DECREF(key); - Py_DECREF(value); return NULL; } + } else { + /* plain name; use key as tag */ + tag = Py_NewRef(key); + } + + /* decode universal name */ + const char *p = PyBytes_AS_STRING(tag); + value = PyUnicode_DecodeUTF8(p, size, "strict"); + Py_DECREF(tag); + if (!value) { + Py_DECREF(key); + return NULL; + } + + /* add to names dictionary */ + if (PyDict_SetItem(self->names, key, value) < 0) { + Py_DECREF(key); + Py_DECREF(value); + return NULL; } Py_DECREF(key); @@ -3280,7 +3310,11 @@ expat_default_handler(void *op, const XML_Char *data_in, int data_len) if (!key) return; - value = PyDict_GetItemWithError(self->entity, key); + if (PyDict_GetItemRef(self->entity, key, &value) < 0) { + Py_DECREF(key); + return; + } + Py_DECREF(key); elementtreestate *st = self->state; if (value) { @@ -3292,8 +3326,10 @@ expat_default_handler(void *op, const XML_Char *data_in, int data_len) res = PyObject_CallOneArg(self->handle_data, value); else res = NULL; + Py_DECREF(value); Py_XDECREF(res); - } else if (!PyErr_Occurred()) { + } + else { /* Report the first error, not the last */ char message[128] = "undefined entity "; strncat(message, data_in, data_len < 100?data_len:100); @@ -3305,8 +3341,26 @@ expat_default_handler(void *op, const XML_Char *data_in, int data_len) message ); } +} - Py_DECREF(key); +/* Append (action, node) to the list of events of the pull parser. */ +LOCAL(int) +xmlparser_append_event(XMLParserObject *self, PyObject *action, PyObject *node) +{ + if (self->events_append == NULL || action == NULL || node == NULL) { + return 0; + } + PyObject *event = _PyTuple_FromPair(action, node); + if (event == NULL) { + return -1; + } + PyObject *res = PyObject_CallOneArg(self->events_append, event); + Py_DECREF(event); + if (res == NULL) { + return -1; + } + Py_DECREF(res); + return 0; } static void @@ -3384,7 +3438,10 @@ expat_start_handler(void *op, const XML_Char *tag_in, Py_DECREF(tag); Py_XDECREF(attrib); - Py_XDECREF(res); + if (res != NULL) { + (void)xmlparser_append_event(self, self->start_event_obj, res); + Py_DECREF(res); + } } static void @@ -3441,7 +3498,10 @@ expat_end_handler(void *op, const XML_Char *tag_in) } } - Py_XDECREF(res); + if (res != NULL) { + (void)xmlparser_append_event(self, self->end_event_obj, res); + Py_DECREF(res); + } } static void @@ -3461,42 +3521,34 @@ expat_start_ns_handler(void *op, const XML_Char *prefix_in, if (!prefix_in) prefix_in = ""; - elementtreestate *st = self->state; - if (TreeBuilder_CheckExact(st, self->target)) { - /* shortcut - TreeBuilder does not actually implement .start_ns() */ - TreeBuilderObject *target = (TreeBuilderObject*) self->target; - - if (target->events_append && target->start_ns_event_obj) { - prefix = PyUnicode_DecodeUTF8(prefix_in, strlen(prefix_in), "strict"); - if (!prefix) - return; - uri = PyUnicode_DecodeUTF8(uri_in, strlen(uri_in), "strict"); - if (!uri) { - Py_DECREF(prefix); - return; - } + if (self->handle_start_ns == NULL && self->start_ns_event_obj == NULL) { + return; + } - res = treebuilder_handle_start_ns(target, prefix, uri); - Py_DECREF(uri); - Py_DECREF(prefix); - } - } else if (self->handle_start_ns) { - prefix = PyUnicode_DecodeUTF8(prefix_in, strlen(prefix_in), "strict"); - if (!prefix) - return; - uri = PyUnicode_DecodeUTF8(uri_in, strlen(uri_in), "strict"); - if (!uri) { - Py_DECREF(prefix); - return; - } + prefix = PyUnicode_DecodeUTF8(prefix_in, strlen(prefix_in), "strict"); + if (!prefix) + return; + uri = PyUnicode_DecodeUTF8(uri_in, strlen(uri_in), "strict"); + if (!uri) { + Py_DECREF(prefix); + return; + } + if (self->handle_start_ns) { PyObject *args[2] = {prefix, uri}; res = PyObject_Vectorcall(self->handle_start_ns, args, 2, NULL); - Py_DECREF(uri); - Py_DECREF(prefix); } + else { + /* the target does not implement .start_ns(), report the pair */ + res = _PyTuple_FromPair(prefix, uri); + } + Py_DECREF(uri); + Py_DECREF(prefix); - Py_XDECREF(res); + if (res != NULL) { + (void)xmlparser_append_event(self, self->start_ns_event_obj, res); + Py_DECREF(res); + } } static void @@ -3512,15 +3564,7 @@ expat_end_ns_handler(void *op, const XML_Char *prefix_in) if (!prefix_in) prefix_in = ""; - elementtreestate *st = self->state; - if (TreeBuilder_CheckExact(st, self->target)) { - /* shortcut - TreeBuilder does not actually implement .end_ns() */ - TreeBuilderObject *target = (TreeBuilderObject*) self->target; - - if (target->events_append && target->end_ns_event_obj) { - res = treebuilder_handle_end_ns(target, Py_None); - } - } else if (self->handle_end_ns) { + if (self->handle_end_ns) { prefix = PyUnicode_DecodeUTF8(prefix_in, strlen(prefix_in), "strict"); if (!prefix) return; @@ -3528,8 +3572,15 @@ expat_end_ns_handler(void *op, const XML_Char *prefix_in) res = PyObject_CallOneArg(self->handle_end_ns, prefix); Py_DECREF(prefix); } + else if (self->end_ns_event_obj) { + /* the target does not implement .end_ns() */ + res = Py_NewRef(Py_None); + } - Py_XDECREF(res); + if (res != NULL) { + (void)xmlparser_append_event(self, self->end_ns_event_obj, res); + Py_DECREF(res); + } } static void @@ -3552,16 +3603,22 @@ expat_comment_handler(void *op, const XML_Char *comment_in) return; /* parser will look for errors */ res = treebuilder_handle_comment(target, comment); - Py_XDECREF(res); Py_DECREF(comment); + if (res != NULL) { + (void)xmlparser_append_event(self, self->comment_event_obj, res); + Py_DECREF(res); + } } else if (self->handle_comment) { comment = PyUnicode_DecodeUTF8(comment_in, strlen(comment_in), "strict"); if (!comment) return; res = PyObject_CallOneArg(self->handle_comment, comment); - Py_XDECREF(res); Py_DECREF(comment); + if (res != NULL) { + (void)xmlparser_append_event(self, self->comment_event_obj, res); + Py_DECREF(res); + } } } @@ -3641,7 +3698,7 @@ expat_pi_handler(void *op, const XML_Char *target_in, /* shortcut */ TreeBuilderObject *target = (TreeBuilderObject*) self->target; - if ((target->events_append && target->pi_event_obj) || target->insert_pis) { + if (self->pi_event_obj || target->insert_pis) { pi_target = PyUnicode_DecodeUTF8(target_in, strlen(target_in), "strict"); if (!pi_target) goto error; @@ -3649,9 +3706,12 @@ expat_pi_handler(void *op, const XML_Char *target_in, if (!data) goto error; res = treebuilder_handle_pi(target, pi_target, data); - Py_XDECREF(res); Py_DECREF(data); Py_DECREF(pi_target); + if (res != NULL) { + (void)xmlparser_append_event(self, self->pi_event_obj, res); + Py_DECREF(res); + } } } else if (self->handle_pi) { pi_target = PyUnicode_DecodeUTF8(target_in, strlen(target_in), "strict"); @@ -3663,9 +3723,12 @@ expat_pi_handler(void *op, const XML_Char *target_in, PyObject *args[2] = {pi_target, data}; res = PyObject_Vectorcall(self->handle_pi, args, 2, NULL); - Py_XDECREF(res); Py_DECREF(data); Py_DECREF(pi_target); + if (res != NULL) { + (void)xmlparser_append_event(self, self->pi_event_obj, res); + Py_DECREF(res); + } } return; @@ -3688,6 +3751,10 @@ xmlparser_new(PyTypeObject *type, PyObject *args, PyObject *kwds) self->handle_start = self->handle_data = self->handle_end = NULL; self->handle_comment = self->handle_pi = self->handle_close = NULL; self->handle_doctype = NULL; + self->events_append = NULL; + self->start_event_obj = self->end_event_obj = NULL; + self->start_ns_event_obj = self->end_ns_event_obj = NULL; + self->comment_event_obj = self->pi_event_obj = NULL; self->elementtree_module = PyType_GetModuleByDef(type, &elementtreemodule); assert(self->elementtree_module != NULL); Py_INCREF(self->elementtree_module); @@ -3716,12 +3783,18 @@ _elementtree.XMLParser.__init__ target: object = None encoding: str(accept={str, NoneType}) = None +Element structure builder for XML source data based on the expat parser. + +*target* is an optional target object which defaults to an instance +of the standard TreeBuilder class, *encoding* is an optional encoding +string which if given, overrides the encoding specified in the XML +file: http://www.iana.org/assignments/character-sets [clinic start generated code]*/ static int _elementtree_XMLParser___init___impl(XMLParserObject *self, PyObject *target, const char *encoding) -/*[clinic end generated code: output=3ae45ec6cdf344e4 input=7e716dd6e4f3e439]*/ +/*[clinic end generated code: output=3ae45ec6cdf344e4 input=a77eb075d276d487]*/ { self->entity = PyDict_New(); if (!self->entity) @@ -3856,6 +3929,13 @@ xmlparser_gc_traverse(PyObject *op, visitproc visit, void *arg) Py_VISIT(self->handle_start_ns); Py_VISIT(self->handle_end_ns); Py_VISIT(self->handle_doctype); + Py_VISIT(self->events_append); + Py_VISIT(self->start_event_obj); + Py_VISIT(self->end_event_obj); + Py_VISIT(self->start_ns_event_obj); + Py_VISIT(self->end_ns_event_obj); + Py_VISIT(self->comment_event_obj); + Py_VISIT(self->pi_event_obj); Py_VISIT(self->target); Py_VISIT(self->entity); @@ -3885,6 +3965,13 @@ xmlparser_gc_clear(PyObject *op) Py_CLEAR(self->handle_start_ns); Py_CLEAR(self->handle_end_ns); Py_CLEAR(self->handle_doctype); + Py_CLEAR(self->events_append); + Py_CLEAR(self->start_event_obj); + Py_CLEAR(self->end_event_obj); + Py_CLEAR(self->start_ns_event_obj); + Py_CLEAR(self->end_ns_event_obj); + Py_CLEAR(self->comment_event_obj); + Py_CLEAR(self->pi_event_obj); Py_CLEAR(self->target); Py_CLEAR(self->entity); @@ -3940,14 +4027,36 @@ expat_parse(elementtreestate *st, XMLParserObject *self, const char *data, Py_RETURN_NONE; } +/* Expat takes the length as an int, feed larger data in chunks. */ +#define MAX_CHUNK_SIZE (1 << 20) + +LOCAL(PyObject*) +expat_parse_large(elementtreestate *st, XMLParserObject *self, + const char *data, Py_ssize_t data_len, int final) +{ + static_assert(MAX_CHUNK_SIZE <= INT_MAX, + "MAX_CHUNK_SIZE is larger than INT_MAX"); + while (data_len > MAX_CHUNK_SIZE) { + PyObject *res = expat_parse(st, self, data, MAX_CHUNK_SIZE, 0); + if (res == NULL) { + return NULL; + } + Py_DECREF(res); + data += MAX_CHUNK_SIZE; + data_len -= MAX_CHUNK_SIZE; + } + return expat_parse(st, self, data, (int)data_len, final); +} + /*[clinic input] _elementtree.XMLParser.close +Finish feeding data to parser and return element structure. [clinic start generated code]*/ static PyObject * _elementtree_XMLParser_close_impl(XMLParserObject *self) -/*[clinic end generated code: output=d68d375dd23bc7fb input=ca7909ca78c3abfe]*/ +/*[clinic end generated code: output=d68d375dd23bc7fb input=177603f3353e644f]*/ { /* end feeding data to parser */ @@ -4014,11 +4123,12 @@ _elementtree.XMLParser.feed data: object / +Feed encoded data to parser. [clinic start generated code]*/ static PyObject * _elementtree_XMLParser_feed_impl(XMLParserObject *self, PyObject *data) -/*[clinic end generated code: output=503e6fbf1adf17ab input=fe231b6b8de3ce1f]*/ +/*[clinic end generated code: output=503e6fbf1adf17ab input=9432a189100bc488]*/ { /* feed data to parser */ @@ -4031,26 +4141,17 @@ _elementtree_XMLParser_feed_impl(XMLParserObject *self, PyObject *data) const char *data_ptr = PyUnicode_AsUTF8AndSize(data, &data_len); if (data_ptr == NULL) return NULL; - if (data_len > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, "size does not fit in an int"); - return NULL; - } /* Explicitly set UTF-8 encoding. Return code ignored. */ (void)EXPAT(st, SetEncoding)(self->parser, "utf-8"); - return expat_parse(st, self, data_ptr, (int)data_len, 0); + return expat_parse_large(st, self, data_ptr, data_len, 0); } else { Py_buffer view; PyObject *res; if (PyObject_GetBuffer(data, &view, PyBUF_SIMPLE) < 0) return NULL; - if (view.len > INT_MAX) { - PyBuffer_Release(&view); - PyErr_SetString(PyExc_OverflowError, "size does not fit in an int"); - return NULL; - } - res = expat_parse(st, self, view.buf, (int)view.len, 0); + res = expat_parse_large(st, self, view.buf, view.len, 0); PyBuffer_Release(&view); return res; } @@ -4084,6 +4185,7 @@ _elementtree_XMLParser__parse_whole_impl(XMLParserObject *self, /* read from open file object */ elementtreestate *st = self->state; + int first = 1; for (;;) { buffer = PyObject_CallFunction(reader, "i", 64*1024); @@ -4100,6 +4202,11 @@ _elementtree_XMLParser__parse_whole_impl(XMLParserObject *self, Py_DECREF(buffer); break; } + if (first) { + /* The text is already decoded, the encoding declared in the + document does not apply to it. Return code ignored. */ + (void)EXPAT(st, SetEncoding)(self->parser, "utf-8"); + } temp = PyUnicode_AsEncodedString(buffer, "utf-8", "surrogatepass"); Py_DECREF(buffer); if (!temp) { @@ -4114,15 +4221,10 @@ _elementtree_XMLParser__parse_whole_impl(XMLParserObject *self, break; } - if (PyBytes_GET_SIZE(buffer) > INT_MAX) { - Py_DECREF(buffer); - Py_DECREF(reader); - PyErr_SetString(PyExc_OverflowError, "size does not fit in an int"); - return NULL; - } - res = expat_parse( - st, self, PyBytes_AS_STRING(buffer), (int)PyBytes_GET_SIZE(buffer), + res = expat_parse_large( + st, self, PyBytes_AS_STRING(buffer), PyBytes_GET_SIZE(buffer), 0); + first = 0; Py_DECREF(buffer); @@ -4163,40 +4265,31 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self, { /* activate element event reporting */ Py_ssize_t i; - TreeBuilderObject *target; PyObject *events_append, *events_seq; if (!_check_xmlparser(self)) { return NULL; } elementtreestate *st = self->state; - if (!TreeBuilder_CheckExact(st, self->target)) { - PyErr_SetString( - PyExc_TypeError, - "event handling only supported for ElementTree.TreeBuilder " - "targets" - ); - return NULL; - } - - target = (TreeBuilderObject*) self->target; - events_append = PyObject_GetAttrString(events_queue, "append"); if (events_append == NULL) return NULL; - Py_XSETREF(target->events_append, events_append); + Py_XSETREF(self->events_append, events_append); /* clear out existing events */ - Py_CLEAR(target->start_event_obj); - Py_CLEAR(target->end_event_obj); - Py_CLEAR(target->start_ns_event_obj); - Py_CLEAR(target->end_ns_event_obj); - Py_CLEAR(target->comment_event_obj); - Py_CLEAR(target->pi_event_obj); + Py_CLEAR(self->start_event_obj); + Py_CLEAR(self->end_event_obj); + Py_CLEAR(self->start_ns_event_obj); + Py_CLEAR(self->end_ns_event_obj); + Py_CLEAR(self->comment_event_obj); + Py_CLEAR(self->pi_event_obj); if (events_to_report == Py_None) { /* default is "end" only */ - target->end_event_obj = PyUnicode_FromString("end"); + self->end_event_obj = PyUnicode_FromString("end"); + if (self->end_event_obj == NULL) { + return NULL; + } Py_RETURN_NONE; } @@ -4207,50 +4300,68 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self, for (i = 0; i < PySequence_Fast_GET_SIZE(events_seq); ++i) { PyObject *event_name_obj = PySequence_Fast_GET_ITEM(events_seq, i); - const char *event_name = NULL; - if (PyUnicode_Check(event_name_obj)) { - event_name = PyUnicode_AsUTF8(event_name_obj); - } else if (PyBytes_Check(event_name_obj)) { - event_name = PyBytes_AS_STRING(event_name_obj); + if (!PyUnicode_Check(event_name_obj)) { + goto unknown_event; } + const char *event_name = PyUnicode_AsUTF8(event_name_obj); if (event_name == NULL) { Py_DECREF(events_seq); - PyErr_Format(PyExc_ValueError, "invalid events sequence"); return NULL; } + /* the target must implement the method of the event, + except for the namespace events */ + PyObject *handler = Py_None; if (strcmp(event_name, "start") == 0) { - Py_XSETREF(target->start_event_obj, Py_NewRef(event_name_obj)); + handler = self->handle_start; } else if (strcmp(event_name, "end") == 0) { - Py_XSETREF(target->end_event_obj, Py_NewRef(event_name_obj)); + handler = self->handle_end; + } else if (strcmp(event_name, "comment") == 0) { + handler = self->handle_comment; + } else if (strcmp(event_name, "pi") == 0) { + handler = self->handle_pi; + } + if (handler == NULL) { + PyErr_Format(PyExc_TypeError, + "the target does not support %R events", + event_name_obj); + Py_DECREF(events_seq); + return NULL; + } + + if (strcmp(event_name, "start") == 0) { + Py_XSETREF(self->start_event_obj, Py_NewRef(event_name_obj)); + } else if (strcmp(event_name, "end") == 0) { + Py_XSETREF(self->end_event_obj, Py_NewRef(event_name_obj)); } else if (strcmp(event_name, "start-ns") == 0) { - Py_XSETREF(target->start_ns_event_obj, Py_NewRef(event_name_obj)); + Py_XSETREF(self->start_ns_event_obj, Py_NewRef(event_name_obj)); EXPAT(st, SetNamespaceDeclHandler)( self->parser, (XML_StartNamespaceDeclHandler) expat_start_ns_handler, (XML_EndNamespaceDeclHandler) expat_end_ns_handler ); } else if (strcmp(event_name, "end-ns") == 0) { - Py_XSETREF(target->end_ns_event_obj, Py_NewRef(event_name_obj)); + Py_XSETREF(self->end_ns_event_obj, Py_NewRef(event_name_obj)); EXPAT(st, SetNamespaceDeclHandler)( self->parser, (XML_StartNamespaceDeclHandler) expat_start_ns_handler, (XML_EndNamespaceDeclHandler) expat_end_ns_handler ); } else if (strcmp(event_name, "comment") == 0) { - Py_XSETREF(target->comment_event_obj, Py_NewRef(event_name_obj)); + Py_XSETREF(self->comment_event_obj, Py_NewRef(event_name_obj)); EXPAT(st, SetCommentHandler)( self->parser, (XML_CommentHandler) expat_comment_handler ); } else if (strcmp(event_name, "pi") == 0) { - Py_XSETREF(target->pi_event_obj, Py_NewRef(event_name_obj)); + Py_XSETREF(self->pi_event_obj, Py_NewRef(event_name_obj)); EXPAT(st, SetProcessingInstructionHandler)( self->parser, (XML_ProcessingInstructionHandler) expat_pi_handler ); } else { - PyErr_Format(PyExc_ValueError, "unknown event '%s'", event_name); +unknown_event: + PyErr_Format(PyExc_ValueError, "unknown event %R", event_name_obj); Py_DECREF(events_seq); return NULL; } @@ -4342,7 +4453,27 @@ static PyGetSetDef element_getsetlist[] = { {NULL}, }; +PyDoc_STRVAR(element_doc, +"Element(tag, attrib={}, **extra)\n" +"--\n" +"\n" +"An XML element.\n" +"\n" +"This class is the reference implementation of the Element interface.\n" +"\n" +"An element's length is its number of subelements. That means if you\n" +"want to check if an element is truly empty, you should check BOTH\n" +"its length AND its text attribute.\n" +"\n" +"*tag* is the element name. *attrib* is an optional dictionary\n" +"containing element attributes. *extra* are additional element\n" +"attributes given as keyword arguments.\n" +"\n" +"Example form:\n" +" text...tail"); + static PyType_Slot element_slots[] = { + {Py_tp_doc, (void *)element_doc}, {Py_tp_dealloc, element_dealloc}, {Py_tp_repr, element_repr}, {Py_tp_getattro, PyObject_GenericGetAttr}, @@ -4383,6 +4514,7 @@ static PyMethodDef treebuilder_methods[] = { }; static PyType_Slot treebuilder_slots[] = { + {Py_tp_doc, (void *)_elementtree_TreeBuilder___init____doc__}, {Py_tp_dealloc, treebuilder_dealloc}, {Py_tp_traverse, treebuilder_gc_traverse}, {Py_tp_clear, treebuilder_gc_clear}, @@ -4410,6 +4542,7 @@ static PyMethodDef xmlparser_methods[] = { }; static PyType_Slot xmlparser_slots[] = { + {Py_tp_doc, (void *)_elementtree_XMLParser___init____doc__}, {Py_tp_dealloc, xmlparser_dealloc}, {Py_tp_traverse, xmlparser_gc_traverse}, {Py_tp_clear, xmlparser_gc_clear}, @@ -4434,7 +4567,7 @@ static PyType_Spec xmlparser_spec = { /* python module interface */ static PyMethodDef _functions[] = { - {"SubElement", _PyCFunction_CAST(subelement), METH_VARARGS | METH_KEYWORDS}, + _ELEMENTTREE_SUBELEMENT_METHODDEF _ELEMENTTREE__SET_FACTORIES_METHODDEF {NULL, NULL} }; diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index b4595c55d519b93..75b93d87e90a999 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -27,7 +27,6 @@ class _functools._lru_cache_wrapper "PyObject *" "&lru_cache_type_spec" typedef struct _functools_state { /* this object is used delimit args and keywords in the cache keys */ PyObject *kwd_mark; - PyTypeObject *placeholder_type; PyObject *placeholder; // strong reference (singleton) PyTypeObject *partial_type; PyTypeObject *keyobject_type; @@ -55,77 +54,6 @@ typedef struct { static inline _functools_state * get_functools_state_by_type(PyTypeObject *type); -PyDoc_STRVAR(placeholder_doc, -"The type of the Placeholder singleton.\n\n" -"Used as a placeholder for partial arguments."); - -static PyObject * -placeholder_repr(PyObject *op) -{ - return PyUnicode_FromString("Placeholder"); -} - -static PyObject * -placeholder_reduce(PyObject *op, PyObject *Py_UNUSED(ignored)) -{ - return PyUnicode_FromString("Placeholder"); -} - -static PyMethodDef placeholder_methods[] = { - {"__reduce__", placeholder_reduce, METH_NOARGS, NULL}, - {NULL, NULL} -}; - -static void -placeholder_dealloc(PyObject* self) -{ - PyObject_GC_UnTrack(self); - PyTypeObject *tp = Py_TYPE(self); - tp->tp_free((PyObject*)self); - Py_DECREF(tp); -} - -static PyObject * -placeholder_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - if (PyTuple_GET_SIZE(args) || (kwargs && PyDict_GET_SIZE(kwargs))) { - PyErr_SetString(PyExc_TypeError, "PlaceholderType takes no arguments"); - return NULL; - } - _functools_state *state = get_functools_state_by_type(type); - if (state->placeholder != NULL) { - return Py_NewRef(state->placeholder); - } - - PyObject *placeholder = PyType_GenericNew(type, NULL, NULL); - if (placeholder == NULL) { - return NULL; - } - - if (state->placeholder == NULL) { - state->placeholder = Py_NewRef(placeholder); - } - return placeholder; -} - -static PyType_Slot placeholder_type_slots[] = { - {Py_tp_dealloc, placeholder_dealloc}, - {Py_tp_repr, placeholder_repr}, - {Py_tp_doc, (void *)placeholder_doc}, - {Py_tp_methods, placeholder_methods}, - {Py_tp_new, placeholder_new}, - {Py_tp_traverse, _PyObject_VisitType}, - {0, 0} -}; - -static PyType_Spec placeholder_type_spec = { - .name = "functools._PlaceholderType", - .basicsize = sizeof(placeholderobject), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_HAVE_GC, - .slots = placeholder_type_slots -}; - - typedef struct { PyObject_HEAD PyObject *fn; @@ -382,9 +310,14 @@ partial_vectorcall(PyObject *self, PyObject *const *args, return NULL; } - PyObject **pto_args = _PyTuple_ITEMS(pto->args); - Py_ssize_t pto_nargs = PyTuple_GET_SIZE(pto->args); - Py_ssize_t pto_nkwds = PyDict_GET_SIZE(pto->kw); + PyObject *result = NULL; + PyObject *partial_function = Py_NewRef(pto->fn); + PyObject *partial_args = Py_NewRef(pto->args); + PyObject *partial_keywords = Py_NewRef(pto->kw); + + PyObject **pto_args = _PyTuple_ITEMS(partial_args); + Py_ssize_t pto_nargs = PyTuple_GET_SIZE(partial_args); + Py_ssize_t pto_nkwds = PyDict_GET_SIZE(partial_keywords); Py_ssize_t nkwds = kwnames == NULL ? 0 : PyTuple_GET_SIZE(kwnames); Py_ssize_t nargskw = nargs + nkwds; @@ -392,8 +325,9 @@ partial_vectorcall(PyObject *self, PyObject *const *args, if (!pto_nkwds) { /* Fast path if we're called without arguments */ if (nargskw == 0) { - return _PyObject_VectorcallTstate(tstate, pto->fn, pto_args, - pto_nargs, NULL); + result = _PyObject_VectorcallTstate(tstate, partial_function, pto_args, + pto_nargs, NULL); + goto done; } /* Use PY_VECTORCALL_ARGUMENTS_OFFSET to prepend a single @@ -402,10 +336,10 @@ partial_vectorcall(PyObject *self, PyObject *const *args, PyObject **newargs = (PyObject **)args - 1; PyObject *tmp = newargs[0]; newargs[0] = pto_args[0]; - PyObject *ret = _PyObject_VectorcallTstate(tstate, pto->fn, newargs, - nargs + 1, kwnames); + result = _PyObject_VectorcallTstate(tstate, partial_function, newargs, + nargs + 1, kwnames); newargs[0] = tmp; - return ret; + goto done; } } @@ -435,7 +369,8 @@ partial_vectorcall(PyObject *self, PyObject *const *args, else { stack = PyMem_Malloc(init_stack_size * sizeof(PyObject *)); if (stack == NULL) { - return PyErr_NoMemory(); + PyErr_NoMemory(); + goto done; } } @@ -457,20 +392,20 @@ partial_vectorcall(PyObject *self, PyObject *const *args, for (Py_ssize_t i = 0; i < nkwds; ++i) { key = PyTuple_GET_ITEM(kwnames, i); val = args[nargs + i]; - int contains = PyDict_Contains(pto->kw, key); + int contains = PyDict_Contains(partial_keywords, key); if (contains < 0) { - goto error; + goto clean_stack; } else if (contains == 1) { if (pto_kw_merged == NULL) { - pto_kw_merged = PyDict_Copy(pto->kw); + pto_kw_merged = PyDict_Copy(partial_keywords); if (pto_kw_merged == NULL) { - goto error; + goto clean_stack; } } if (PyDict_SetItem(pto_kw_merged, key, val) < 0) { Py_DECREF(pto_kw_merged); - goto error; + goto clean_stack; } } else { @@ -486,7 +421,7 @@ partial_vectorcall(PyObject *self, PyObject *const *args, tot_kwnames = PyTuple_New(tot_nkwds - n_merges); if (tot_kwnames == NULL) { Py_XDECREF(pto_kw_merged); - goto error; + goto clean_stack; } for (Py_ssize_t i = 0; i < n_tail; ++i) { key = Py_NewRef(stack[tot_nargskw + i]); @@ -496,7 +431,7 @@ partial_vectorcall(PyObject *self, PyObject *const *args, /* Copy pto_keywords with overlapping call keywords merged * Note, tail is already coppied. */ Py_ssize_t pos = 0, i = 0; - PyObject *keyword_dict = n_merges ? pto_kw_merged : pto->kw; + PyObject *keyword_dict = n_merges ? pto_kw_merged : partial_keywords; Py_BEGIN_CRITICAL_SECTION(keyword_dict); while (PyDict_Next(keyword_dict, &pos, &key, &val)) { assert(i < pto_nkwds); @@ -515,10 +450,8 @@ partial_vectorcall(PyObject *self, PyObject *const *args, tmp_stack = PyMem_Realloc(stack, (tot_nargskw - n_merges) * sizeof(PyObject *)); if (tmp_stack == NULL) { Py_DECREF(tot_kwnames); - if (stack != small_stack) { - PyMem_Free(stack); - } - return PyErr_NoMemory(); + PyErr_NoMemory(); + goto clean_stack; } stack = tmp_stack; } @@ -547,21 +480,22 @@ partial_vectorcall(PyObject *self, PyObject *const *args, memcpy(stack + pto_nargs, args, nargs * sizeof(PyObject*)); } - PyObject *ret = _PyObject_VectorcallTstate(tstate, pto->fn, stack, - tot_nargs, tot_kwnames); - if (stack != small_stack) { - PyMem_Free(stack); - } + result = _PyObject_VectorcallTstate(tstate, partial_function, stack, + tot_nargs, tot_kwnames); if (pto_nkwds) { Py_DECREF(tot_kwnames); } - return ret; - error: + clean_stack: if (stack != small_stack) { PyMem_Free(stack); } - return NULL; + + done: + Py_DECREF(partial_function); + Py_DECREF(partial_args); + Py_DECREF(partial_keywords); + return result; } /* Set pto->vectorcall depending on the parameters of the partial object */ @@ -1811,14 +1745,31 @@ lru_cache_reduce(PyObject *self, PyObject *Py_UNUSED(dummy)) return PyObject_GetAttrString(self, "__qualname__"); } +/*[clinic input] +_functools._lru_cache_wrapper.__copy__ + +Return a copy of the wrapper, which is the wrapper itself. +[clinic start generated code]*/ + static PyObject * -lru_cache_copy(PyObject *self, PyObject *Py_UNUSED(args)) +_functools__lru_cache_wrapper___copy___impl(PyObject *self) +/*[clinic end generated code: output=d681851615d57391 input=41d000bde05efb2b]*/ { return Py_NewRef(self); } +/*[clinic input] +_functools._lru_cache_wrapper.__deepcopy__ + + memo: object + / + +Return a deep copy of the wrapper, which is the wrapper itself. +[clinic start generated code]*/ + static PyObject * -lru_cache_deepcopy(PyObject *self, PyObject *Py_UNUSED(args)) +_functools__lru_cache_wrapper___deepcopy__(PyObject *self, PyObject *memo) +/*[clinic end generated code: output=3445cd9d96273c9e input=84f706565f55ce46]*/ { return Py_NewRef(self); } @@ -1866,8 +1817,8 @@ static PyMethodDef lru_cache_methods[] = { _FUNCTOOLS__LRU_CACHE_WRAPPER_CACHE_INFO_METHODDEF _FUNCTOOLS__LRU_CACHE_WRAPPER_CACHE_CLEAR_METHODDEF {"__reduce__", lru_cache_reduce, METH_NOARGS}, - {"__copy__", lru_cache_copy, METH_VARARGS}, - {"__deepcopy__", lru_cache_deepcopy, METH_VARARGS}, + _FUNCTOOLS__LRU_CACHE_WRAPPER___COPY___METHODDEF + _FUNCTOOLS__LRU_CACHE_WRAPPER___DEEPCOPY___METHODDEF {NULL} }; @@ -1927,16 +1878,7 @@ _functools_exec(PyObject *module) return -1; } - state->placeholder_type = (PyTypeObject *)PyType_FromModuleAndSpec(module, - &placeholder_type_spec, NULL); - if (state->placeholder_type == NULL) { - return -1; - } - if (PyModule_AddType(module, state->placeholder_type) < 0) { - return -1; - } - - PyObject *placeholder = PyObject_CallNoArgs((PyObject *)state->placeholder_type); + PyObject *placeholder = PySentinel_New("Placeholder", "functools", NULL); if (placeholder == NULL) { return -1; } @@ -1944,7 +1886,7 @@ _functools_exec(PyObject *module) Py_DECREF(placeholder); return -1; } - Py_DECREF(placeholder); + state->placeholder = placeholder; state->partial_type = (PyTypeObject *)PyType_FromModuleAndSpec(module, &partial_type_spec, NULL); @@ -1990,7 +1932,6 @@ _functools_traverse(PyObject *module, visitproc visit, void *arg) { _functools_state *state = get_functools_state(module); Py_VISIT(state->kwd_mark); - Py_VISIT(state->placeholder_type); Py_VISIT(state->placeholder); Py_VISIT(state->partial_type); Py_VISIT(state->keyobject_type); @@ -2003,7 +1944,6 @@ _functools_clear(PyObject *module) { _functools_state *state = get_functools_state(module); Py_CLEAR(state->kwd_mark); - Py_CLEAR(state->placeholder_type); Py_CLEAR(state->placeholder); Py_CLEAR(state->partial_type); Py_CLEAR(state->keyobject_type); diff --git a/Modules/_gdbmmodule.c b/Modules/_gdbmmodule.c index 20d482021656a50..2cec6e0a0bafbbc 100644 --- a/Modules/_gdbmmodule.c +++ b/Modules/_gdbmmodule.c @@ -136,10 +136,16 @@ gdbm_dealloc(PyObject *op) Py_DECREF(tp); } +/*[clinic input] +@critical_section +_gdbm.gdbm.__len__ as gdbm_length +[clinic start generated code]*/ + static Py_ssize_t -gdbm_length_lock_held(PyObject *op) +gdbm_length_impl(gdbmobject *self) +/*[clinic end generated code: output=3ccb956974ed73b5 input=57878f60d264ed98]*/ { - gdbmobject *dp = _gdbmobject_CAST(op); + gdbmobject *dp = self; _gdbm_state *state = PyType_GetModuleState(Py_TYPE(dp)); if (dp->di_dbm == NULL) { PyErr_SetString(state->gdbm_error, "GDBM object has already been closed"); @@ -183,20 +189,16 @@ gdbm_length_lock_held(PyObject *op) return dp->di_size; } -static Py_ssize_t -gdbm_length(PyObject *op) -{ - Py_ssize_t result; - Py_BEGIN_CRITICAL_SECTION(op); - result = gdbm_length_lock_held(op); - Py_END_CRITICAL_SECTION(); - return result; -} +/*[clinic input] +@critical_section +_gdbm.gdbm.__bool__ as gdbm_bool +[clinic start generated code]*/ static int -gdbm_bool_lock_held(PyObject *op) +gdbm_bool_impl(gdbmobject *self) +/*[clinic end generated code: output=91316ca18acb945c input=bf2878ff5e311848]*/ { - gdbmobject *dp = _gdbmobject_CAST(op); + gdbmobject *dp = self; _gdbm_state *state = PyType_GetModuleState(Py_TYPE(dp)); if (dp->di_dbm == NULL) { PyErr_SetString(state->gdbm_error, "GDBM object has already been closed"); @@ -223,16 +225,6 @@ gdbm_bool_lock_held(PyObject *op) return 1; } -static int -gdbm_bool(PyObject *op) -{ - int result; - Py_BEGIN_CRITICAL_SECTION(op); - result = gdbm_bool_lock_held(op); - Py_END_CRITICAL_SECTION(); - return result; -} - // Wrapper function for PyArg_Parse(o, "s#", &d.dptr, &d.size). // This function is needed to support PY_SSIZE_T_CLEAN. // Return 1 on success, same to PyArg_Parse(). @@ -254,12 +246,20 @@ parse_datum(PyObject *o, datum *d, const char *failmsg) return 1; } +/*[clinic input] +@critical_section +_gdbm.gdbm.__getitem__ as gdbm_subscript + key: object + / +[clinic start generated code]*/ + static PyObject * -gdbm_subscript_lock_held(PyObject *op, PyObject *key) +gdbm_subscript_impl(gdbmobject *self, PyObject *key) +/*[clinic end generated code: output=e96388d53678e967 input=8324d90d97ae98f0]*/ { PyObject *v; datum drec, krec; - gdbmobject *dp = _gdbmobject_CAST(op); + gdbmobject *dp = self; _gdbm_state *state = PyType_GetModuleState(Py_TYPE(dp)); if (!parse_datum(key, &krec, NULL)) { @@ -280,16 +280,6 @@ gdbm_subscript_lock_held(PyObject *op, PyObject *key) return v; } -static PyObject * -gdbm_subscript(PyObject *op, PyObject *key) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(op); - result = gdbm_subscript_lock_held(op, key); - Py_END_CRITICAL_SECTION(); - return result; -} - /*[clinic input] _gdbm.gdbm.get @@ -314,12 +304,22 @@ _gdbm_gdbm_get_impl(gdbmobject *self, PyObject *key, PyObject *default_value) return res; } +/*[clinic input] +@critical_section +_gdbm.gdbm.__setitem__ as gdbm_ass_sub + + v: object + w: object + / +[clinic start generated code]*/ + static int -gdbm_ass_sub_lock_held(PyObject *op, PyObject *v, PyObject *w) +gdbm_ass_sub_impl(gdbmobject *self, PyObject *v, PyObject *w) +/*[clinic end generated code: output=b46cce6ffa309dab input=fbd980f3b49e2f91]*/ { datum krec, drec; const char *failmsg = "gdbm mappings have bytes or string indices only"; - gdbmobject *dp = _gdbmobject_CAST(op); + gdbmobject *dp = self; _gdbm_state *state = PyType_GetModuleState(Py_TYPE(dp)); if (!parse_datum(v, &krec, failmsg)) { @@ -360,16 +360,6 @@ gdbm_ass_sub_lock_held(PyObject *op, PyObject *v, PyObject *w) return 0; } -static int -gdbm_ass_sub(PyObject *op, PyObject *v, PyObject *w) -{ - int result; - Py_BEGIN_CRITICAL_SECTION(op); - result = gdbm_ass_sub_lock_held(op, v, w); - Py_END_CRITICAL_SECTION(); - return result; -} - /*[clinic input] @permit_long_summary @critical_section @@ -470,10 +460,18 @@ _gdbm_gdbm_keys_impl(gdbmobject *self, PyTypeObject *cls) return v; } +/*[clinic input] +@critical_section +_gdbm.gdbm.__contains__ as gdbm_contains + arg: object + / +[clinic start generated code]*/ + static int -gdbm_contains_lock_held(PyObject *self, PyObject *arg) +gdbm_contains_impl(gdbmobject *self, PyObject *arg) +/*[clinic end generated code: output=ad951f5a9f4194df input=411dc2039fdd7277]*/ { - gdbmobject *dp = (gdbmobject *)self; + gdbmobject *dp = self; datum key; Py_ssize_t size; _gdbm_state *state = PyType_GetModuleState(Py_TYPE(dp)); @@ -502,16 +500,6 @@ gdbm_contains_lock_held(PyObject *self, PyObject *arg) return gdbm_exists(dp->di_dbm, key); } -static int -gdbm_contains(PyObject *self, PyObject *arg) -{ - int result; - Py_BEGIN_CRITICAL_SECTION(self); - result = gdbm_contains_lock_held(self, arg); - Py_END_CRITICAL_SECTION(); - return result; -} - /*[clinic input] @critical_section _gdbm.gdbm.firstkey @@ -687,14 +675,21 @@ gdbm__enter__(PyObject *self, PyObject *args) return Py_NewRef(self); } +/*[clinic input] +@critical_section +_gdbm.gdbm.__exit__ + + *exc_info: array + +Close the database. +[clinic start generated code]*/ + static PyObject * -gdbm__exit__(PyObject *self, PyObject *args) +_gdbm_gdbm___exit___impl(gdbmobject *self, PyObject * const *exc_info, + Py_ssize_t exc_info_length) +/*[clinic end generated code: output=4bb425e091228932 input=b22b90a00b22cf18]*/ { - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(self); - result = _gdbm_gdbm_close_impl((gdbmobject *)self); - Py_END_CRITICAL_SECTION(); - return result; + return _gdbm_gdbm_close_impl(self); } static PyMethodDef gdbm_methods[] = { @@ -708,7 +703,7 @@ static PyMethodDef gdbm_methods[] = { _GDBM_GDBM_SETDEFAULT_METHODDEF _GDBM_GDBM_CLEAR_METHODDEF {"__enter__", gdbm__enter__, METH_NOARGS, NULL}, - {"__exit__", gdbm__exit__, METH_VARARGS, NULL}, + _GDBM_GDBM___EXIT___METHODDEF {NULL, NULL} /* sentinel */ }; @@ -855,6 +850,85 @@ static PyMethodDef _gdbm_module_methods[] = { { 0, 0 }, }; +PyDoc_STRVAR(gdbm_version_info__doc__, +"_gdbm.gdbm_version_info\n\ +\n\ +GDBM version information as a named tuple."); + +static PyStructSequence_Field gdbm_version_info_fields[] = { + {"major", "Major release number"}, + {"minor", "Minor release number"}, + {"patch", "Patch release number"}, + {0} +}; + +static PyStructSequence_Desc gdbm_version_info_desc = { + "_gdbm.gdbm_version_info", /* name */ + gdbm_version_info__doc__, /* doc */ + gdbm_version_info_fields, /* fields */ + 3 +}; + +static PyObject * +make_gdbm_version_info(PyTypeObject *type, int major, int minor, int patch) +{ + PyObject *version; + int pos = 0; + + version = PyStructSequence_New(type); + if (version == NULL) { + return NULL; + } + +#define SetItem(VALUE) \ + PyStructSequence_SET_ITEM(version, pos++, VALUE); \ + if (PyErr_Occurred()) { \ + Py_DECREF(version); \ + return NULL; \ + } + + SetItem(PyLong_FromLong(major)) + SetItem(PyLong_FromLong(minor)) + SetItem(PyLong_FromLong(patch)) +#undef SetItem + + return version; +} + +static int +add_version_constants(PyObject *module) +{ + if (PyModule_AddStringConstant(module, "gdbm_version", gdbm_version) < 0) { + return -1; + } +#if defined(GDBM_VERSION_MAJOR) && defined(GDBM_VERSION_MINOR) && \ + defined(GDBM_VERSION_PATCH) + PyTypeObject *version_type; + version_type = PyStructSequence_NewType(&gdbm_version_info_desc); + if (version_type == NULL) { + return -1; + } + if (PyModule_Add(module, "GDBM_VERSION_INFO", + make_gdbm_version_info(version_type, GDBM_VERSION_MAJOR, + GDBM_VERSION_MINOR, + GDBM_VERSION_PATCH)) < 0) + { + Py_DECREF(version_type); + return -1; + } + if (PyModule_Add(module, "gdbm_version_info", + make_gdbm_version_info(version_type, gdbm_version_number[0], + gdbm_version_number[1], + gdbm_version_number[2])) < 0) + { + Py_DECREF(version_type); + return -1; + } + Py_DECREF(version_type); +#endif + return 0; +} + static int _gdbm_exec(PyObject *module) { @@ -876,14 +950,9 @@ _gdbm_exec(PyObject *module) return -1; } -#if defined(GDBM_VERSION_MAJOR) && defined(GDBM_VERSION_MINOR) && \ - defined(GDBM_VERSION_PATCH) - PyObject *obj = Py_BuildValue("iii", GDBM_VERSION_MAJOR, - GDBM_VERSION_MINOR, GDBM_VERSION_PATCH); - if (PyModule_Add(module, "_GDBM_VERSION", obj) < 0) { + if (add_version_constants(module) < 0) { return -1; } -#endif return 0; } diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c index f895c9037485c43..9d7602b39d7b938 100644 --- a/Modules/_hashopenssl.c +++ b/Modules/_hashopenssl.c @@ -27,6 +27,7 @@ #include "pycore_strhex.h" // _Py_strhex() #include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_PTR_RELAXED #include "hashlib.h" +#include "_openssl_mem.h" /* EVP is the preferred interface to hashing in OpenSSL */ #include @@ -692,43 +693,46 @@ static PY_EVP_MD * get_openssl_evp_md_by_utf8name(_hashlibstate *state, const char *name, Py_hash_type py_ht) { - PY_EVP_MD *digest = NULL, *other_digest = NULL; + PY_EVP_MD *digest = NULL, *fresh = NULL; py_hashentry_t *entry = _Py_hashtable_get(state->hashtable, name); + int fips = !disable_fips_property(py_ht); if (entry != NULL) { - if (!disable_fips_property(py_ht)) { - digest = FT_ATOMIC_LOAD_PTR_RELAXED(entry->evp); - if (digest == NULL) { - digest = PY_EVP_MD_fetch(entry->ossl_name, NULL); -#ifdef Py_GIL_DISABLED - // exchange just in case another thread did same thing at same time - other_digest = _Py_atomic_exchange_ptr(&entry->evp, (void *)digest); -#else - entry->evp = digest; -#endif - } - } - else { - digest = FT_ATOMIC_LOAD_PTR_RELAXED(entry->evp_nosecurity); - if (digest == NULL) { - digest = PY_EVP_MD_fetch(entry->ossl_name, "-fips"); -#ifdef Py_GIL_DISABLED - // exchange just in case another thread did same thing at same time - other_digest = _Py_atomic_exchange_ptr(&entry->evp_nosecurity, (void *)digest); -#else - entry->evp_nosecurity = digest; -#endif + PY_EVP_MD **cached = fips ? &entry->evp : &entry->evp_nosecurity; + digest = FT_ATOMIC_LOAD_PTR_RELAXED(*cached); + if (digest == NULL) { + fresh = PY_EVP_MD_fetch(entry->ossl_name, fips ? NULL : "-fips"); + if (fresh != NULL) { + /* + * Publish a freshly fetched digest into the cache exactly once. + * + * On the first publication, 'cached' adopts the 'fresh' ref. + * If another thread wins the race, 'fresh' is released and + * the cached digest is used instead. + * + * See https://github.com/python/cpython/issues/128657 + * and https://github.com/python/cpython/issues/149816. + */ + PY_EVP_MD *expected = NULL; + if (_Py_atomic_compare_exchange_ptr(cached, &expected, (void *)fresh)) { + digest = fresh; // we won: 'cached' now owns the fresh digest + } + else { + PY_EVP_MD_free(fresh); // we lost: discard the fresh digest + digest = expected; // reuse the winner's digest + } } } - // if another thread same thing at same time make sure we got same ptr - assert(other_digest == NULL || other_digest == digest); - if (digest != NULL && other_digest == NULL) { + /* Hand the caller its own reference; the cache keeps its own. Valid + * whether `digest` was already cached, freshly published by this + * thread, or published by a thread that won the race. */ + if (digest != NULL) { PY_EVP_MD_up_ref(digest); } } else { // Fall back for looking up an unindexed OpenSSL specific name. - const char *props = disable_fips_property(py_ht) ? "-fips" : NULL; + const char *props = fips ? NULL : "-fips"; (void)props; // will only be used in OpenSSL 3.0 and later digest = PY_EVP_MD_fetch(name, props); } @@ -846,6 +850,12 @@ new_hash_object(PyTypeObject *type) return retval; } +/* + * Update the digest context of 'self' with 'len' bytes from 'vp'. + * + * Return 0 on success and -1 if EVP_DigestUpdate() failed. No exception + * is set, so that this can be called without an attached thread state. + */ static int _hashlib_HASH_hash(HASHobject *self, const void *vp, Py_ssize_t len) { @@ -857,7 +867,6 @@ _hashlib_HASH_hash(HASHobject *self, const void *vp, Py_ssize_t len) else process = Py_SAFE_DOWNCAST(len, Py_ssize_t, unsigned int); if (!EVP_DigestUpdate(self->ctx, (const void*)cp, process)) { - notify_ssl_error_occurred_in(Py_STRINGIFY(EVP_DigestUpdate)); return -1; } len -= process; @@ -990,7 +999,11 @@ _hashlib_HASH_update_impl(HASHobject *self, PyObject *obj) result = _hashlib_HASH_hash(self, view.buf, view.len) ); PyBuffer_Release(&view); - return result < 0 ? NULL : Py_None; + if (result < 0) { + notify_ssl_error_occurred_in(Py_STRINGIFY(EVP_DigestUpdate)); + return NULL; + } + Py_RETURN_NONE; } static PyMethodDef HASH_methods[] = { @@ -1304,7 +1317,7 @@ _hashlib_HASH(_hashlibstate *state, const char *digestname, PyObject *data_obj, result = _hashlib_HASH_hash(self, view.buf, view.len) ); if (result == -1) { - assert(PyErr_Occurred()); + notify_ssl_error_occurred_in(Py_STRINGIFY(EVP_DigestUpdate)); Py_CLEAR(self); goto exit; } @@ -1975,16 +1988,6 @@ hashlib_HMAC_get_hashlib_digest_name(HMACobject *self) #endif } -static int -hashlib_openssl_HMAC_update_once(PY_HMAC_CTX_TYPE *ctx, const Py_buffer *v) -{ - if (!PY_HMAC_update(ctx, (const unsigned char *)v->buf, (size_t)v->len)) { - notify_smart_ssl_error_occurred_in(Py_STRINGIFY(PY_HMAC_update)); - return -1; - } - return 0; -} - /* Thin wrapper around PY_HMAC_CTX_free that allows to pass a NULL 'ctx'. */ static inline void hashlib_openssl_HMAC_CTX_free(PY_HMAC_CTX_TYPE *ctx) @@ -2239,10 +2242,15 @@ _hmac_update(HMACobject *self, PyObject *obj) GET_BUFFER_VIEW_OR_ERROR(obj, &view, return -1); HASHLIB_EXTERNAL_INSTRUCTIONS_LOCKED( self, view.len, - r = hashlib_openssl_HMAC_update_once(self->ctx, &view) + r = PY_HMAC_update(self->ctx, (const unsigned char *)view.buf, + (size_t)view.len) ); PyBuffer_Release(&view); - return r; + if (r == 0) { + notify_smart_ssl_error_occurred_in(Py_STRINGIFY(PY_HMAC_update)); + return -1; + } + return 0; } /*[clinic input] @@ -2933,5 +2941,6 @@ static struct PyModuleDef _hashlibmodule = { PyMODINIT_FUNC PyInit__hashlib(void) { + _PyOpenSSL_SetupMemFunctions(); return PyModuleDef_Init(&_hashlibmodule); } diff --git a/Modules/_interpchannelsmodule.c b/Modules/_interpchannelsmodule.c index 7b31b1f0c85d264..930d7276a3ed45e 100644 --- a/Modules/_interpchannelsmodule.c +++ b/Modules/_interpchannelsmodule.c @@ -2634,6 +2634,17 @@ _channelid_from_xid(_PyXIData_t *data) static int _channelid_shared(PyThreadState *tstate, PyObject *obj, _PyXIData_t *data) { + module_state *st = _get_current_module_state(); + if (st == NULL) { + return -1; + } + if (!PyObject_TypeCheck(obj, st->ChannelIDType)) { + PyErr_Format(PyExc_TypeError, + "'_id' attribute must be an %N object, not %T", + st->ChannelIDType, obj); + return -1; + } + if (_PyXIData_InitWithSize( data, tstate->interp, sizeof(struct _channelid_xid), obj, _channelid_from_xid diff --git a/Modules/_interpretersmodule.c b/Modules/_interpretersmodule.c index 15bfd35a80806ce..454db063d18b6a0 100644 --- a/Modules/_interpretersmodule.c +++ b/Modules/_interpretersmodule.c @@ -802,17 +802,27 @@ get_summary(PyInterpreterState *interp) } -// Not converted to Argument Clinic because the function uses ``**kwargs``. +/*[clinic input] +_interpreters.new_config + + name: str(c_default="NULL") = 'isolated' + / + **overrides: dict + +Return a representation of a new PyInterpreterConfig. + +The name determines the initial values of the config. Supported named +configs are: default, isolated, legacy, and empty. + +Any keyword arguments are set on the corresponding config fields, +overriding the initial values. +[clinic start generated code]*/ + static PyObject * -interp_new_config(PyObject *self, PyObject *args, PyObject *kwds) +_interpreters_new_config_impl(PyObject *module, const char *name, + PyObject *overrides) +/*[clinic end generated code: output=90ca53e5c8f66e31 input=67a5a2832894a72b]*/ { - const char *name = NULL; - if (!PyArg_ParseTuple(args, "|s:" MODULE_NAME_STR ".new_config", &name)) - { - return NULL; - } - PyObject *overrides = kwds; - PyInterpreterConfig config; if (init_named_config(&config, name) < 0) { return NULL; @@ -834,18 +844,6 @@ interp_new_config(PyObject *self, PyObject *args, PyObject *kwds) return configobj; } -PyDoc_STRVAR(new_config_doc, -"new_config($module, name='isolated', /, **overrides)\n\ ---\n\ -\n\ -Return a representation of a new PyInterpreterConfig.\n\ -\n\ -The name determines the initial values of the config. Supported named\n\ -configs are: default, isolated, legacy, and empty.\n\ -\n\ -Any keyword arguments are set on the corresponding config fields,\n\ -overriding the initial values."); - /*[clinic input] _interpreters.create @@ -1558,8 +1556,7 @@ _interpreters_capture_exception_impl(PyObject *module, PyObject *exc_arg) static PyMethodDef module_functions[] = { - {"new_config", _PyCFunction_CAST(interp_new_config), - METH_VARARGS | METH_KEYWORDS, new_config_doc}, + _INTERPRETERS_NEW_CONFIG_METHODDEF _INTERPRETERS_CREATE_METHODDEF _INTERPRETERS_DESTROY_METHODDEF diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index 03e6fbe08889d47..0d28fe24fa0b3a7 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -94,10 +94,7 @@ mode. Other common values are 'w' for writing (truncating the file if it already exists), 'x' for creating and writing to a new file, and 'a' for appending (which on some Unix systems, means that all writes append to the end of the file regardless of the current seek position). -In text mode, if encoding is not specified the encoding used is platform -dependent: locale.getencoding() is called to get the current locale -encoding. (For reading and writing raw bytes use binary mode and leave -encoding unspecified.) The available modes are: +The available modes are: ========= ========================================================== Character Meaning @@ -122,8 +119,7 @@ even when the underlying operating system doesn't. Files opened in binary mode (appending 'b' to the mode argument) return contents as bytes objects without any decoding. In text mode (the default, or when 't' is appended to the mode argument), the contents of the file are -returned as strings, the bytes having been first decoded using a -platform-dependent encoding or using the specified encoding if given. +decoded using the encoding described below and returned as strings. buffering is an optional integer used to set the buffering policy. Pass 0 to switch buffering off (only allowed in binary mode), 1 to @@ -140,10 +136,11 @@ argument is given, the default buffering policy works as follows: use line buffering. Other text files use the policy described above for binary files. -encoding is the name of the encoding used to decode or encode the -file. This should only be used in text mode. The default encoding is -platform dependent, but any encoding supported by Python can be -passed. See the codecs module for the list of supported encodings. +encoding is the name of the encoding used to decode or encode the file. +This should only be used in text mode. The default encoding is UTF-8; +if UTF-8 Mode is disabled, the encoding returned by +locale.getencoding() is used instead. See the codecs module for the +list of supported encodings. errors is an optional string that specifies how encoding errors are to be handled---this argument should not be used in binary mode. Pass @@ -200,7 +197,7 @@ static PyObject * _io_open_impl(PyObject *module, PyObject *file, const char *mode, int buffering, const char *encoding, const char *errors, const char *newline, int closefd, PyObject *opener) -/*[clinic end generated code: output=aefafc4ce2b46dc0 input=b3cefa70bef404b3]*/ +/*[clinic end generated code: output=aefafc4ce2b46dc0 input=5a005681afa02242]*/ { size_t i; diff --git a/Modules/_io/_iomodule.h b/Modules/_io/_iomodule.h index 4ae487c8e2adf72..c9bbbf24bd466d7 100644 --- a/Modules/_io/_iomodule.h +++ b/Modules/_io/_iomodule.h @@ -4,6 +4,7 @@ #include "exports.h" +#include "pycore_fileutils.h" // Py_off_t #include "pycore_moduleobject.h" // _PyModule_GetState() #include "pycore_typeobject.h" // _PyType_GetModuleState() #include "structmember.h" @@ -94,8 +95,6 @@ extern int _PyIO_trap_eintr(void); #ifdef MS_WINDOWS -/* Windows uses long long for offsets */ -typedef long long Py_off_t; # define PyLong_AsOff_t PyLong_AsLongLong # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX LLONG_MAX @@ -106,7 +105,6 @@ typedef long long Py_off_t; #else /* Other platforms use off_t */ -typedef off_t Py_off_t; #if (SIZEOF_OFF_T == SIZEOF_SIZE_T) # define PyLong_AsOff_t PyLong_AsSsize_t # define PyLong_FromOff_t PyLong_FromSsize_t diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 5537947f6a51c11..9e5a7216ee013b6 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -9,11 +9,11 @@ #include "Python.h" #include "pycore_call.h" // _PyObject_CallNoArgs() +#include "pycore_critical_section.h" // _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED() #include "pycore_fileutils.h" // _PyFile_Flush #include "pycore_object.h" // _PyObject_GC_UNTRACK() #include "pycore_pyerrors.h" // _Py_FatalErrorFormat() #include "pycore_pylifecycle.h" // _Py_IsInterpreterFinalizing() -#include "pycore_weakref.h" // FT_CLEAR_WEAKREFS() #include "_iomodule.h" @@ -60,6 +60,11 @@ _bufferediobase_readinto_generic(PyObject *self, Py_buffer *buffer, char readint if (data == NULL) return NULL; + /* Non-blocking stream with no data available */ + if (data == Py_None) { + return data; + } + if (!PyBytes_Check(data)) { Py_DECREF(data); PyErr_SetString(PyExc_TypeError, "read() should return bytes"); @@ -260,8 +265,6 @@ typedef struct { Py_ssize_t buffer_size; Py_ssize_t buffer_mask; - PyObject *dict; - PyObject *weakreflist; } buffered; #define buffered_CAST(op) ((buffered *)(op)) @@ -417,7 +420,7 @@ buffered_clear(PyObject *op) buffered *self = buffered_CAST(op); self->ok = 0; Py_CLEAR(self->raw); - Py_CLEAR(self->dict); + PyObject_ClearManagedDict(op); return 0; } @@ -431,7 +434,7 @@ buffered_dealloc(PyObject *op) return; _PyObject_GC_UNTRACK(self); self->ok = 0; - FT_CLEAR_WEAKREFS(op, self->weakreflist); + PyObject_ClearWeakRefs(op); if (self->buffer) { PyMem_Free(self->buffer); self->buffer = NULL; @@ -467,8 +470,7 @@ buffered_traverse(PyObject *op, visitproc visit, void *arg) buffered *self = buffered_CAST(op); Py_VISIT(Py_TYPE(self)); Py_VISIT(self->raw); - Py_VISIT(self->dict); - return 0; + return PyObject_VisitManagedDict(op, visit, arg); } /* Because this can call arbitrary code, it shouldn't be called when @@ -1205,109 +1207,113 @@ _io__Buffered_readinto1_impl(buffered *self, Py_buffer *buffer) static PyObject * _buffered_readline(buffered *self, Py_ssize_t limit) { - PyObject *res = NULL; - PyObject *chunks = NULL; - Py_ssize_t n; - const char *start, *s, *end; + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self); CHECK_CLOSED(self, "readline of closed file") /* First, try to find a line in the buffer. This can run unlocked because the calls to the C API are simple enough that they can't trigger any thread switch. */ - n = Py_SAFE_DOWNCAST(READAHEAD(self), Py_off_t, Py_ssize_t); - if (limit >= 0 && n > limit) + Py_ssize_t n = Py_SAFE_DOWNCAST(READAHEAD(self), Py_off_t, Py_ssize_t); + if (limit >= 0 && n > limit) { n = limit; - start = self->buffer + self->pos; - s = memchr(start, '\n', n); + } + const char *start = self->buffer + self->pos; + const char *s = memchr(start, '\n', n); if (s != NULL) { - res = PyBytes_FromStringAndSize(start, s - start + 1); - if (res != NULL) - self->pos += s - start + 1; - goto end_unlocked; + n = s - start + 1; + PyObject *res = PyBytes_FromStringAndSize(start, n); + if (res == NULL) { + return NULL; + } + self->pos += n; + return res; } + if (n == limit) { - res = PyBytes_FromStringAndSize(start, n); - if (res != NULL) - self->pos += n; - goto end_unlocked; + PyObject *res = PyBytes_FromStringAndSize(start, n); + if (res == NULL) { + return NULL; + } + self->pos += n; + return res; } - if (!ENTER_BUFFERED(self)) - goto end_unlocked; + PyBytesWriter *writer = NULL; + int locked = 0; + if (!ENTER_BUFFERED(self)) { + goto error; + } + locked = 1; /* Now we try to get some more from the raw stream */ - chunks = PyList_New(0); - if (chunks == NULL) - goto end; + writer = PyBytesWriter_Create(0); + if (writer == NULL) { + goto error; + } + if (n > 0) { - res = PyBytes_FromStringAndSize(start, n); - if (res == NULL) - goto end; - if (PyList_Append(chunks, res) < 0) { - Py_CLEAR(res); - goto end; + if (PyBytesWriter_WriteBytes(writer, start, n) < 0) { + goto error; } - Py_CLEAR(res); self->pos += n; - if (limit >= 0) + if (limit >= 0) { limit -= n; + } } if (self->writable) { - PyObject *r = buffered_flush_and_rewind_unlocked(self); - if (r == NULL) - goto end; - Py_DECREF(r); + PyObject *res = buffered_flush_and_rewind_unlocked(self); + if (res == NULL) { + goto error; + } + Py_DECREF(res); } for (;;) { _bufferedreader_reset_buf(self); n = _bufferedreader_fill_buffer(self); - if (n == -1) - goto end; - if (n <= 0) + if (n == -1) { + goto error; + } + if (n <= 0) { break; - if (limit >= 0 && n > limit) + } + if (limit >= 0 && n > limit) { n = limit; + } start = self->buffer; - end = start + n; - s = start; - while (s < end) { - if (*s++ == '\n') { - res = PyBytes_FromStringAndSize(start, s - start); - if (res == NULL) - goto end; - self->pos = s - start; - goto found; + const char *newline = memchr(start, '\n', n); + if (newline != NULL) { + n = newline - start + 1; + if (PyBytesWriter_WriteBytes(writer, start, n) < 0) { + goto error; } + self->pos = n; + goto found; + } + + if (PyBytesWriter_WriteBytes(writer, start, n) < 0) { + goto error; } - res = PyBytes_FromStringAndSize(start, n); - if (res == NULL) - goto end; if (n == limit) { self->pos = n; break; } - if (PyList_Append(chunks, res) < 0) { - Py_CLEAR(res); - goto end; - } - Py_CLEAR(res); - if (limit >= 0) + if (limit >= 0) { limit -= n; + } } -found: - if (res != NULL && PyList_Append(chunks, res) < 0) { - Py_CLEAR(res); - goto end; - } - Py_XSETREF(res, PyBytes_Join((PyObject *)&_Py_SINGLETON(bytes_empty), chunks)); -end: +found: LEAVE_BUFFERED(self) -end_unlocked: - Py_XDECREF(chunks); - return res; + return PyBytesWriter_Finish(writer); + +error: + PyBytesWriter_Discard(writer); + if (locked) { + LEAVE_BUFFERED(self) + } + return NULL; } /*[clinic input] @@ -2246,8 +2252,6 @@ typedef struct { PyObject_HEAD buffered *reader; buffered *writer; - PyObject *dict; - PyObject *weakreflist; } rwpair; #define rwpair_CAST(op) ((rwpair *)(op)) @@ -2283,20 +2287,25 @@ _io_BufferedRWPair___init___impl(rwpair *self, PyObject *reader, return -1; } - self->reader = (buffered *) PyObject_CallFunction( + buffered *new_reader = (buffered *) PyObject_CallFunction( (PyObject *)state->PyBufferedReader_Type, "On", reader, buffer_size); - if (self->reader == NULL) + if (new_reader == NULL) { return -1; + } - self->writer = (buffered *) PyObject_CallFunction( + buffered *new_writer = (buffered *) PyObject_CallFunction( (PyObject *)state->PyBufferedWriter_Type, "On", writer, buffer_size); - if (self->writer == NULL) { - Py_CLEAR(self->reader); + if (new_writer == NULL) { + Py_DECREF(new_reader); return -1; } + /* Release a previous writer before a previous reader, see + bufferedrwpair_clear(). */ + Py_XSETREF(self->writer, new_writer); + Py_XSETREF(self->reader, new_reader); return 0; } @@ -2305,19 +2314,19 @@ bufferedrwpair_traverse(PyObject *op, visitproc visit, void *arg) { rwpair *self = rwpair_CAST(op); Py_VISIT(Py_TYPE(self)); - Py_VISIT(self->dict); Py_VISIT(self->reader); Py_VISIT(self->writer); - return 0; + return PyObject_VisitManagedDict(op, visit, arg); } static int bufferedrwpair_clear(PyObject *op) { rwpair *self = rwpair_CAST(op); - Py_CLEAR(self->reader); + /* Let the writer flush before the reader closes a shared raw stream. */ Py_CLEAR(self->writer); - Py_CLEAR(self->dict); + Py_CLEAR(self->reader); + PyObject_ClearManagedDict(op); return 0; } @@ -2327,100 +2336,168 @@ bufferedrwpair_dealloc(PyObject *op) rwpair *self = rwpair_CAST(op); PyTypeObject *tp = Py_TYPE(self); _PyObject_GC_UNTRACK(self); - FT_CLEAR_WEAKREFS(op, self->weakreflist); + PyObject_ClearWeakRefs(op); (void)bufferedrwpair_clear(op); tp->tp_free(self); Py_DECREF(tp); } +/* Call the method of the underlying reader or writer. The argument is + only passed if it is not NULL, so that the default of that method is + used otherwise. */ static PyObject * -_forward_call(buffered *self, PyObject *name, PyObject *args) +_forward_call(buffered *self, PyObject *name, PyObject *arg) { - PyObject *func, *ret; if (self == NULL) { PyErr_SetString(PyExc_ValueError, "I/O operation on uninitialized object"); return NULL; } - func = PyObject_GetAttr((PyObject *)self, name); - if (func == NULL) { - PyErr_SetObject(PyExc_AttributeError, name); - return NULL; + if (arg == NULL) { + return PyObject_CallMethodNoArgs((PyObject *)self, name); } + return PyObject_CallMethodOneArg((PyObject *)self, name, arg); +} - ret = PyObject_CallObject(func, args); - Py_DECREF(func); - return ret; +/*[clinic input] +_io.BufferedRWPair.read + size: object(c_default="NULL") = -1 + / +[clinic start generated code]*/ + +static PyObject * +_io_BufferedRWPair_read_impl(rwpair *self, PyObject *size) +/*[clinic end generated code: output=0668e3c5dbd3e93d input=eddb5e52aba9ebe5]*/ +{ + return _forward_call(self->reader, &_Py_ID(read), size); } +/*[clinic input] +_io.BufferedRWPair.peek + size: object(c_default="NULL") = 0 + / +[clinic start generated code]*/ + static PyObject * -bufferedrwpair_read(PyObject *op, PyObject *args) +_io_BufferedRWPair_peek_impl(rwpair *self, PyObject *size) +/*[clinic end generated code: output=190a267bd694efa0 input=36af95964bebe355]*/ { - rwpair *self = rwpair_CAST(op); - return _forward_call(self->reader, &_Py_ID(read), args); + return _forward_call(self->reader, &_Py_ID(peek), size); } +/*[clinic input] +_io.BufferedRWPair.read1 + size: object(c_default="NULL") = -1 + / +[clinic start generated code]*/ + static PyObject * -bufferedrwpair_peek(PyObject *op, PyObject *args) +_io_BufferedRWPair_read1_impl(rwpair *self, PyObject *size) +/*[clinic end generated code: output=17ec19608f2bb825 input=9e94db423e490b58]*/ { - rwpair *self = rwpair_CAST(op); - return _forward_call(self->reader, &_Py_ID(peek), args); + return _forward_call(self->reader, &_Py_ID(read1), size); } +/*[clinic input] +_io.BufferedRWPair.readline + size: object(c_default="NULL") = -1 + / + +Read and return a line from the stream. + +If size is specified, at most size bytes will be read. + +The line terminator is always b'\n'. +[clinic start generated code]*/ + static PyObject * -bufferedrwpair_read1(PyObject *op, PyObject *args) +_io_BufferedRWPair_readline_impl(rwpair *self, PyObject *size) +/*[clinic end generated code: output=ee5bb2364231e6e1 input=1c552272a69db1ad]*/ { - rwpair *self = rwpair_CAST(op); - return _forward_call(self->reader, &_Py_ID(read1), args); + return _forward_call(self->reader, &_Py_ID(readline), size); } +/*[clinic input] +_io.BufferedRWPair.readinto + buffer: object + / +[clinic start generated code]*/ + static PyObject * -bufferedrwpair_readinto(PyObject *op, PyObject *args) +_io_BufferedRWPair_readinto_impl(rwpair *self, PyObject *buffer) +/*[clinic end generated code: output=16c86b071015f7a4 input=ccd86ce2666261f7]*/ { - rwpair *self = rwpair_CAST(op); - return _forward_call(self->reader, &_Py_ID(readinto), args); + return _forward_call(self->reader, &_Py_ID(readinto), buffer); } +/*[clinic input] +_io.BufferedRWPair.readinto1 + buffer: object + / +[clinic start generated code]*/ + static PyObject * -bufferedrwpair_readinto1(PyObject *op, PyObject *args) +_io_BufferedRWPair_readinto1_impl(rwpair *self, PyObject *buffer) +/*[clinic end generated code: output=f1577b6f54c2b02a input=613d9bf127f88a4a]*/ { - rwpair *self = rwpair_CAST(op); - return _forward_call(self->reader, &_Py_ID(readinto1), args); + return _forward_call(self->reader, &_Py_ID(readinto1), buffer); } +/*[clinic input] +_io.BufferedRWPair.write + buffer: object + / +[clinic start generated code]*/ + static PyObject * -bufferedrwpair_write(PyObject *op, PyObject *args) +_io_BufferedRWPair_write_impl(rwpair *self, PyObject *buffer) +/*[clinic end generated code: output=6f7509a747410c68 input=66c602422e3ec36f]*/ { - rwpair *self = rwpair_CAST(op); - return _forward_call(self->writer, &_Py_ID(write), args); + return _forward_call(self->writer, &_Py_ID(write), buffer); } +/*[clinic input] +_io.BufferedRWPair.flush +[clinic start generated code]*/ + static PyObject * -bufferedrwpair_flush(PyObject *op, PyObject *Py_UNUSED(dummy)) +_io_BufferedRWPair_flush_impl(rwpair *self) +/*[clinic end generated code: output=0b2dcbe828718d6b input=e853da796ee61df1]*/ { - rwpair *self = rwpair_CAST(op); return _forward_call(self->writer, &_Py_ID(flush), NULL); } +/*[clinic input] +_io.BufferedRWPair.readable +[clinic start generated code]*/ + static PyObject * -bufferedrwpair_readable(PyObject *op, PyObject *Py_UNUSED(dummy)) +_io_BufferedRWPair_readable_impl(rwpair *self) +/*[clinic end generated code: output=615967d4aa58f122 input=0475ed73d0a3167f]*/ { - rwpair *self = rwpair_CAST(op); return _forward_call(self->reader, &_Py_ID(readable), NULL); } +/*[clinic input] +_io.BufferedRWPair.writable +[clinic start generated code]*/ + static PyObject * -bufferedrwpair_writable(PyObject *op, PyObject *Py_UNUSED(dummy)) +_io_BufferedRWPair_writable_impl(rwpair *self) +/*[clinic end generated code: output=c5a43c84e0195c11 input=3cfd44fb4757082f]*/ { - rwpair *self = rwpair_CAST(op); return _forward_call(self->writer, &_Py_ID(writable), NULL); } +/*[clinic input] +_io.BufferedRWPair.close +[clinic start generated code]*/ + static PyObject * -bufferedrwpair_close(PyObject *op, PyObject *Py_UNUSED(dummy)) +_io_BufferedRWPair_close_impl(rwpair *self) +/*[clinic end generated code: output=5924ba5ecc78752a input=4087d69f2d8fc368]*/ { - rwpair *self = rwpair_CAST(op); PyObject *exc = NULL; PyObject *ret = _forward_call(self->writer, &_Py_ID(close), NULL); if (ret == NULL) { @@ -2437,10 +2514,14 @@ bufferedrwpair_close(PyObject *op, PyObject *Py_UNUSED(dummy)) return ret; } +/*[clinic input] +_io.BufferedRWPair.isatty +[clinic start generated code]*/ + static PyObject * -bufferedrwpair_isatty(PyObject *op, PyObject *Py_UNUSED(dummy)) +_io_BufferedRWPair_isatty_impl(rwpair *self) +/*[clinic end generated code: output=d017c621ed879cb7 input=92833e3d60586e14]*/ { - rwpair *self = rwpair_CAST(op); PyObject *ret = _forward_call(self->writer, &_Py_ID(isatty), NULL); if (ret != Py_False) { @@ -2452,10 +2533,15 @@ bufferedrwpair_isatty(PyObject *op, PyObject *Py_UNUSED(dummy)) return _forward_call(self->reader, &_Py_ID(isatty), NULL); } +/*[clinic input] +@getter +_io.BufferedRWPair.closed +[clinic start generated code]*/ + static PyObject * -bufferedrwpair_closed_get(PyObject *op, void *Py_UNUSED(dummy)) +_io_BufferedRWPair_closed_get_impl(rwpair *self) +/*[clinic end generated code: output=4117400c74766f21 input=8248430ac54e5b25]*/ { - rwpair *self = rwpair_CAST(op); if (self->writer == NULL) { PyErr_SetString(PyExc_RuntimeError, "the BufferedRWPair object is being garbage-collected"); @@ -2576,8 +2662,6 @@ static PyMethodDef bufferedreader_methods[] = { static PyMemberDef bufferedreader_members[] = { {"raw", _Py_T_OBJECT, offsetof(buffered, raw), Py_READONLY}, {"_finalizing", Py_T_BOOL, offsetof(buffered, finalizing), 0}, - {"__weaklistoffset__", Py_T_PYSSIZET, offsetof(buffered, weakreflist), Py_READONLY}, - {"__dictoffset__", Py_T_PYSSIZET, offsetof(buffered, dict), Py_READONLY}, {NULL} }; @@ -2635,8 +2719,6 @@ static PyMethodDef bufferedwriter_methods[] = { static PyMemberDef bufferedwriter_members[] = { {"raw", _Py_T_OBJECT, offsetof(buffered, raw), Py_READONLY}, {"_finalizing", Py_T_BOOL, offsetof(buffered, finalizing), 0}, - {"__weaklistoffset__", Py_T_PYSSIZET, offsetof(buffered, weakreflist), Py_READONLY}, - {"__dictoffset__", Py_T_PYSSIZET, offsetof(buffered, dict), Py_READONLY}, {NULL} }; @@ -2670,32 +2752,27 @@ PyType_Spec _Py_bufferedwriter_spec = { }; static PyMethodDef bufferedrwpair_methods[] = { - {"read", bufferedrwpair_read, METH_VARARGS}, - {"peek", bufferedrwpair_peek, METH_VARARGS}, - {"read1", bufferedrwpair_read1, METH_VARARGS}, - {"readinto", bufferedrwpair_readinto, METH_VARARGS}, - {"readinto1", bufferedrwpair_readinto1, METH_VARARGS}, + _IO_BUFFEREDRWPAIR_READ_METHODDEF + _IO_BUFFEREDRWPAIR_PEEK_METHODDEF + _IO_BUFFEREDRWPAIR_READ1_METHODDEF + _IO_BUFFEREDRWPAIR_READLINE_METHODDEF + _IO_BUFFEREDRWPAIR_READINTO_METHODDEF + _IO_BUFFEREDRWPAIR_READINTO1_METHODDEF - {"write", bufferedrwpair_write, METH_VARARGS}, - {"flush", bufferedrwpair_flush, METH_NOARGS}, + _IO_BUFFEREDRWPAIR_WRITE_METHODDEF + _IO_BUFFEREDRWPAIR_FLUSH_METHODDEF - {"readable", bufferedrwpair_readable, METH_NOARGS}, - {"writable", bufferedrwpair_writable, METH_NOARGS}, + _IO_BUFFEREDRWPAIR_READABLE_METHODDEF + _IO_BUFFEREDRWPAIR_WRITABLE_METHODDEF - {"close", bufferedrwpair_close, METH_NOARGS}, - {"isatty", bufferedrwpair_isatty, METH_NOARGS}, + _IO_BUFFEREDRWPAIR_CLOSE_METHODDEF + _IO_BUFFEREDRWPAIR_ISATTY_METHODDEF {NULL, NULL} }; -static PyMemberDef bufferedrwpair_members[] = { - {"__weaklistoffset__", Py_T_PYSSIZET, offsetof(rwpair, weakreflist), Py_READONLY}, - {"__dictoffset__", Py_T_PYSSIZET, offsetof(rwpair, dict), Py_READONLY}, - {NULL} -}; - static PyGetSetDef bufferedrwpair_getset[] = { - {"closed", bufferedrwpair_closed_get, NULL, NULL}, + _IO_BUFFEREDRWPAIR_CLOSED_GETSETDEF {NULL} }; @@ -2705,7 +2782,6 @@ static PyType_Slot bufferedrwpair_slots[] = { {Py_tp_traverse, bufferedrwpair_traverse}, {Py_tp_clear, bufferedrwpair_clear}, {Py_tp_methods, bufferedrwpair_methods}, - {Py_tp_members, bufferedrwpair_members}, {Py_tp_getset, bufferedrwpair_getset}, {Py_tp_init, _io_BufferedRWPair___init__}, {0, NULL}, @@ -2752,8 +2828,6 @@ static PyMethodDef bufferedrandom_methods[] = { static PyMemberDef bufferedrandom_members[] = { {"raw", _Py_T_OBJECT, offsetof(buffered, raw), Py_READONLY}, {"_finalizing", Py_T_BOOL, offsetof(buffered, finalizing), 0}, - {"__weaklistoffset__", Py_T_PYSSIZET, offsetof(buffered, weakreflist), Py_READONLY}, - {"__dictoffset__", Py_T_PYSSIZET, offsetof(buffered, dict), Py_READONLY}, {NULL} }; diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c index 3d14ec3f8f94a92..fa828f218928990 100644 --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@ -1,9 +1,10 @@ #include "Python.h" +#include "pycore_bytesobject.h" // _PyBytes_ResizeKeepOnError() #include "pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION() +#include "pycore_list.h" // _PyList_AppendTakeRef() #include "pycore_object.h" #include "pycore_pyatomic_ft_wrappers.h" #include "pycore_sysmodule.h" // _PySys_GetSizeOf() -#include "pycore_weakref.h" // FT_CLEAR_WEAKREFS() #include // offsetof() #include "_iomodule.h" @@ -19,8 +20,6 @@ typedef struct { PyObject *buf; Py_ssize_t pos; Py_ssize_t string_size; - PyObject *dict; - PyObject *weakreflist; Py_ssize_t exports; #ifdef Py_GIL_DISABLED int buf_shared; @@ -37,10 +36,11 @@ typedef struct { #define bytesiobuf_CAST(op) ((bytesiobuf *)(op)) /* The bytesio object can be in three states: - * Py_REFCNT(buf) == 1, exports == 0. - * Py_REFCNT(buf) > 1. exports == 0, + * Py_REFCNT(buf) == 1, the hash of buf is not cached, exports == 0. + * Py_REFCNT(buf) > 1 or the hash of buf is cached. exports == 0, first modification or export causes the internal buffer copying. - * exports > 0. Py_REFCNT(buf) == 1, any modifications are forbidden. + * exports > 0. Any modifications are forbidden. Every exported buffer + keeps a reference to buf, so it outlives closing of the bytesio object. */ static int @@ -74,10 +74,19 @@ check_exports(bytesio *self) return NULL; \ } +/* If the hash value is cached, the internal bytes object was already used in + Python somehow (ex: as a dictionary key). Modifying it in place would leave + the hash of the old contents, even if nothing else references it anymore. */ +#define HASHED_BUF(self) \ + (_PyBytes_GET_CACHED_HASH((PyBytesObject *)(self)->buf) != -1) + #ifdef Py_GIL_DISABLED -#define SHARED_BUF(self) ((self)->buf_shared || !_PyObject_IsUniquelyReferenced((self)->buf)) +#define SHARED_BUF(self) \ + ((self)->buf_shared || !_PyObject_IsUniquelyReferenced((self)->buf) \ + || HASHED_BUF(self)) #else -#define SHARED_BUF(self) (!_PyObject_IsUniquelyReferenced((self)->buf)) +#define SHARED_BUF(self) \ + (!_PyObject_IsUniquelyReferenced((self)->buf) || HASHED_BUF(self)) #endif static inline void @@ -107,7 +116,7 @@ resize_unshared_buffer_lock_held(bytesio *self, Py_ssize_t size) Callers must detach first. */ assert(!self->buf_shared); #endif - int ret = _PyBytes_Resize(&self->buf, size); + int ret = _PyBytes_ResizeKeepOnError(&self->buf, size); if (ret == 0) { clear_shared_buf(self); } @@ -209,6 +218,9 @@ resize_buffer_lock_held(bytesio *self, size_t size) /* Major upsize; resize up to exact size */ alloc = size + 1; } + if (alloc > PY_SSIZE_T_MAX) { + goto overflow; + } if (SHARED_BUF(self)) { if (unshare_buffer_lock_held(self, alloc) < 0) @@ -266,6 +278,7 @@ write_bytes_lock_held(bytesio *self, PyObject *b) goto done; } } + assert(_PyBytes_IsMutable(self->buf)); if (self->pos > self->string_size) { /* In case of overseek, pad with null bytes the buffer region between @@ -295,20 +308,19 @@ write_bytes_lock_held(bytesio *self, PyObject *b) return len; } -static PyObject * -bytesio_get_closed(PyObject *op, void *Py_UNUSED(closure)) +/*[clinic input] +@critical_section +@getter +_io.BytesIO.closed -> bool + +True if the file is closed. +[clinic start generated code]*/ + +static int +_io_BytesIO_closed_get_impl(bytesio *self) +/*[clinic end generated code: output=7cdc647cc7a71683 input=0687f923344225ee]*/ { - PyObject *ret; - bytesio *self = bytesio_CAST(op); - Py_BEGIN_CRITICAL_SECTION(self); - if (self->buf == NULL) { - ret = Py_True; - } - else { - ret = Py_False; - } - Py_END_CRITICAL_SECTION(); - return ret; + return self->buf == NULL; } /*[clinic input] @@ -484,7 +496,7 @@ peek_bytes_lock_held(bytesio *self, Py_ssize_t size) is beyond the size of self->buf. Assert above validates size is always in bounds. When self->pos is out of bounds calling code sets size to 0. */ if (size == 0) { - return PyBytes_FromStringAndSize(NULL, 0); + return Py_GetConstant(Py_CONSTANT_EMPTY_BYTES); } output = PyBytes_AS_STRING(self->buf) + self->pos; @@ -663,11 +675,9 @@ _io_BytesIO_readlines_impl(bytesio *self, PyObject *arg) line = PyBytes_FromStringAndSize(output, n); if (!line) goto on_error; - if (PyList_Append(result, line) == -1) { - Py_DECREF(line); + if (_PyList_AppendTakeRef((PyListObject *)result, line) < 0) { goto on_error; } - Py_DECREF(line); size += n; if (maxsize > 0 && size >= maxsize) break; @@ -714,7 +724,7 @@ _io_BytesIO_readinto_impl(bytesio *self, Py_buffer *buffer) assert(self->pos + len <= PY_SSIZE_T_MAX); assert(len >= 0); - memcpy(buffer->buf, PyBytes_AS_STRING(self->buf) + self->pos, len); + memmove(buffer->buf, PyBytes_AS_STRING(self->buf) + self->pos, len); self->pos += len; return PyLong_FromSsize_t(len); @@ -745,7 +755,7 @@ _io_BytesIO_truncate_impl(bytesio *self, PyObject *size) new_size = self->pos; } else { - new_size = PyLong_AsLong(size); + new_size = PyNumber_AsSsize_t(size, PyExc_OverflowError); if (new_size == -1 && PyErr_Occurred()) { return NULL; } @@ -754,24 +764,34 @@ _io_BytesIO_truncate_impl(bytesio *self, PyObject *size) "negative size value %zd", new_size); return NULL; } + CHECK_CLOSED(self); + CHECK_EXPORTS(self); } if (new_size < self->string_size) { + Py_ssize_t old_string_size = self->string_size; self->string_size = new_size; - if (resize_buffer_lock_held(self, new_size) < 0) + if (resize_buffer_lock_held(self, new_size) < 0) { + self->string_size = old_string_size; return NULL; + } } return PyLong_FromSsize_t(new_size); } +/*[clinic input] +@critical_section +_io.BytesIO.__next__ as bytesio_iternext +[clinic start generated code]*/ + static PyObject * -bytesio_iternext_lock_held(PyObject *op) +bytesio_iternext_impl(bytesio *self) +/*[clinic end generated code: output=f530bdee3a720d48 input=7fb3a763efe11a21]*/ { - _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op); + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self); Py_ssize_t n; - bytesio *self = bytesio_CAST(op); CHECK_CLOSED(self); @@ -783,16 +803,6 @@ bytesio_iternext_lock_held(PyObject *op) return read_bytes_lock_held(self, n); } -static PyObject * -bytesio_iternext(PyObject *op) -{ - PyObject *ret; - Py_BEGIN_CRITICAL_SECTION(op); - ret = bytesio_iternext_lock_held(op); - Py_END_CRITICAL_SECTION(); - return ret; -} - /*[clinic input] @critical_section _io.BytesIO.seek @@ -925,7 +935,7 @@ static PyObject * _io_BytesIO_close_impl(bytesio *self) /*[clinic end generated code: output=1471bb9411af84a0 input=34ce76d8bd17a23b]*/ { - CHECK_EXPORTS(self); + /* The exported buffers keep the internal buffer alive. */ Py_CLEAR(self->buf); Py_RETURN_NONE; } @@ -945,54 +955,60 @@ _io_BytesIO_close_impl(bytesio *self) function to use the efficient instance representation of PEP 307. */ - static PyObject * - bytesio_getstate_lock_held(PyObject *op) - { - _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op); - - bytesio *self = bytesio_CAST(op); - PyObject *initvalue = _io_BytesIO_getvalue_impl(self); - PyObject *dict; - PyObject *state; - - if (initvalue == NULL) - return NULL; - if (self->dict == NULL) { - dict = Py_NewRef(Py_None); - } - else { - dict = PyDict_Copy(self->dict); - if (dict == NULL) { - Py_DECREF(initvalue); - return NULL; - } - } - - state = Py_BuildValue("(OnN)", initvalue, self->pos, dict); - Py_DECREF(initvalue); - return state; -} + +/*[clinic input] +@critical_section +_io.BytesIO.__getstate__ +[clinic start generated code]*/ static PyObject * -bytesio_getstate(PyObject *op, PyObject *Py_UNUSED(dummy)) +_io_BytesIO___getstate___impl(bytesio *self) +/*[clinic end generated code: output=4a776270c8443b85 input=f41e5bc9731475c4]*/ { - PyObject *ret; - Py_BEGIN_CRITICAL_SECTION(op); - ret = bytesio_getstate_lock_held(op); - Py_END_CRITICAL_SECTION(); - return ret; + PyObject *initvalue = _io_BytesIO_getvalue_impl(self); + PyObject *dict; + PyObject *state; + + if (initvalue == NULL) + return NULL; + if (_PyObject_IsInstanceDictEmpty((PyObject *)self)) { + dict = Py_NewRef(Py_None); + } + else { + dict = PyObject_GenericGetDict((PyObject *)self, NULL); + if (dict == NULL) { + Py_DECREF(initvalue); + return NULL; + } + Py_SETREF(dict, PyDict_Copy(dict)); + if (dict == NULL) { + Py_DECREF(initvalue); + return NULL; + } + } + + state = Py_BuildValue("(OnN)", initvalue, self->pos, dict); + Py_DECREF(initvalue); + return state; } + +/*[clinic input] +@critical_section +_io.BytesIO.__setstate__ + + state: object + / +[clinic start generated code]*/ + static PyObject * -bytesio_setstate_lock_held(PyObject *op, PyObject *state) +_io_BytesIO___setstate___impl(bytesio *self, PyObject *state) +/*[clinic end generated code: output=3605abdec171bb98 input=82a189599ba75083]*/ { - _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op); - PyObject *result; PyObject *position_obj; PyObject *dict; Py_ssize_t pos; - bytesio *self = bytesio_CAST(op); assert(state != NULL); @@ -1047,30 +1063,22 @@ bytesio_setstate_lock_held(PyObject *op, PyObject *state) Py_TYPE(dict)->tp_name); return NULL; } - if (self->dict) { - /* Alternatively, we could replace the internal dictionary - completely. However, it seems more practical to just update it. */ - if (PyDict_Update(self->dict, dict) < 0) - return NULL; + /* Alternatively, we could replace the internal dictionary + completely. However, it seems more practical to just update it. */ + PyObject *self_dict = PyObject_GenericGetDict((PyObject *)self, NULL); + if (self_dict == NULL) { + return NULL; } - else { - self->dict = Py_NewRef(dict); + int rc = PyDict_Update(self_dict, dict); + Py_DECREF(self_dict); + if (rc < 0) { + return NULL; } } Py_RETURN_NONE; } -static PyObject * -bytesio_setstate(PyObject *op, PyObject *state) -{ - PyObject *ret; - Py_BEGIN_CRITICAL_SECTION(op); - ret = bytesio_setstate_lock_held(op, state); - Py_END_CRITICAL_SECTION(); - return ret; -} - static void bytesio_dealloc(PyObject *op) { @@ -1083,8 +1091,8 @@ bytesio_dealloc(PyObject *op) PyErr_Print(); } Py_CLEAR(self->buf); - Py_CLEAR(self->dict); - FT_CLEAR_WEAKREFS(op, self->weakreflist); + PyObject_ClearManagedDict(op); + PyObject_ClearWeakRefs(op); tp->tp_free(self); Py_DECREF(tp); } @@ -1102,7 +1110,7 @@ bytesio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) /* tp_alloc initializes all the fields to zero. So we don't have to initialize them here. */ - self->buf = PyBytes_FromStringAndSize(NULL, 0); + self->buf = Py_GetConstant(Py_CONSTANT_EMPTY_BYTES); if (self->buf == NULL) { Py_DECREF(self); return PyErr_NoMemory(); @@ -1112,6 +1120,7 @@ bytesio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } /*[clinic input] +@vectorcall @critical_section _io.BytesIO.__init__ initial_bytes as initvalue: object(c_default="NULL") = b'' @@ -1121,17 +1130,18 @@ Buffered I/O implementation using an in-memory bytes buffer. static int _io_BytesIO___init___impl(bytesio *self, PyObject *initvalue) -/*[clinic end generated code: output=65c0c51e24c5b621 input=3da5a74ee4c4f1ac]*/ +/*[clinic end generated code: output=65c0c51e24c5b621 input=a6dc38082204df28]*/ { - /* In case, __init__ is called multiple times. */ - self->string_size = 0; - self->pos = 0; - if (FT_ATOMIC_LOAD_SSIZE_RELAXED(self->exports) > 0) { PyErr_SetString(PyExc_BufferError, "Existing exports of data: object cannot be re-sized"); return -1; } + + /* In case, __init__ is called multiple times. */ + self->string_size = 0; + self->pos = 0; + if (initvalue && initvalue != Py_None) { if (PyBytes_CheckExact(initvalue)) { Py_XSETREF(self->buf, Py_NewRef(initvalue)); @@ -1151,12 +1161,18 @@ _io_BytesIO___init___impl(bytesio *self, PyObject *initvalue) return 0; } + +/*[clinic input] +@critical_section +_io.BytesIO.__sizeof__ + +Size of object in memory, in bytes. +[clinic start generated code]*/ + static PyObject * -bytesio_sizeof_lock_held(PyObject *op) +_io_BytesIO___sizeof___impl(bytesio *self) +/*[clinic end generated code: output=f61b601bd055c4de input=6f01c36e6ff64c17]*/ { - _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op); - - bytesio *self = bytesio_CAST(op); size_t res = _PyObject_SIZE(Py_TYPE(self)); if (self->buf && !SHARED_BUF(self)) { size_t s = _PySys_GetSizeOf(self->buf); @@ -1168,31 +1184,20 @@ bytesio_sizeof_lock_held(PyObject *op) return PyLong_FromSize_t(res); } -static PyObject * -bytesio_sizeof(PyObject *op, PyObject *Py_UNUSED(dummy)) -{ - PyObject *ret; - Py_BEGIN_CRITICAL_SECTION(op); - ret = bytesio_sizeof_lock_held(op); - Py_END_CRITICAL_SECTION(); - return ret; -} - static int bytesio_traverse(PyObject *op, visitproc visit, void *arg) { bytesio *self = bytesio_CAST(op); Py_VISIT(Py_TYPE(self)); - Py_VISIT(self->dict); Py_VISIT(self->buf); - return 0; + return PyObject_VisitManagedDict(op, visit, arg); } static int bytesio_clear(PyObject *op) { bytesio *self = bytesio_CAST(op); - Py_CLEAR(self->dict); + PyObject_ClearManagedDict(op); if (FT_ATOMIC_LOAD_SSIZE_RELAXED(self->exports) == 0) { Py_CLEAR(self->buf); } @@ -1205,8 +1210,7 @@ bytesio_clear(PyObject *op) #undef clinic_state static PyGetSetDef bytesio_getsetlist[] = { - {"closed", bytesio_get_closed, NULL, - "True if the file is closed."}, + _IO_BYTESIO_CLOSED_GETSETDEF {NULL}, /* sentinel */ }; @@ -1230,18 +1234,12 @@ static struct PyMethodDef bytesio_methods[] = { _IO_BYTESIO_GETVALUE_METHODDEF _IO_BYTESIO_SEEK_METHODDEF _IO_BYTESIO_TRUNCATE_METHODDEF - {"__getstate__", bytesio_getstate, METH_NOARGS, NULL}, - {"__setstate__", bytesio_setstate, METH_O, NULL}, - {"__sizeof__", bytesio_sizeof, METH_NOARGS, NULL}, + _IO_BYTESIO___GETSTATE___METHODDEF + _IO_BYTESIO___SETSTATE___METHODDEF + _IO_BYTESIO___SIZEOF___METHODDEF {NULL, NULL} /* sentinel */ }; -static PyMemberDef bytesio_members[] = { - {"__weaklistoffset__", Py_T_PYSSIZET, offsetof(bytesio, weakreflist), Py_READONLY}, - {"__dictoffset__", Py_T_PYSSIZET, offsetof(bytesio, dict), Py_READONLY}, - {NULL} -}; - static PyType_Slot bytesio_slots[] = { {Py_tp_dealloc, bytesio_dealloc}, {Py_tp_doc, (void *)_io_BytesIO___init____doc__}, @@ -1250,10 +1248,10 @@ static PyType_Slot bytesio_slots[] = { {Py_tp_iter, PyObject_SelfIter}, {Py_tp_iternext, bytesio_iternext}, {Py_tp_methods, bytesio_methods}, - {Py_tp_members, bytesio_members}, {Py_tp_getset, bytesio_getsetlist}, {Py_tp_init, _io_BytesIO___init__}, {Py_tp_new, bytesio_new}, + {Py_tp_vectorcall, _io_BytesIO_vectorcall}, {0, NULL}, }; @@ -1279,6 +1277,9 @@ bytesiobuf_getbuffer_lock_held(PyObject *op, Py_buffer *view, int flags) _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(b); + if (check_closed(b)) { + return -1; + } if (FT_ATOMIC_LOAD_SSIZE_RELAXED(b->exports) == 0 && SHARED_BUF(b)) { if (unshare_buffer_lock_held(b, b->string_size) < 0) return -1; @@ -1288,6 +1289,9 @@ bytesiobuf_getbuffer_lock_held(PyObject *op, Py_buffer *view, int flags) (void)PyBuffer_FillInfo(view, op, PyBytes_AS_STRING(b->buf), b->string_size, 0, flags); + /* Keep the internal buffer alive: the bytesio object can be closed + while the buffer is exported. */ + view->internal = Py_NewRef(b->buf); FT_ATOMIC_ADD_SSIZE(b->exports, 1); return 0; } @@ -1309,11 +1313,12 @@ bytesiobuf_getbuffer(PyObject *op, Py_buffer *view, int flags) } static void -bytesiobuf_releasebuffer(PyObject *op, Py_buffer *Py_UNUSED(view)) +bytesiobuf_releasebuffer(PyObject *op, Py_buffer *view) { bytesiobuf *obj = bytesiobuf_CAST(op); bytesio *b = bytesio_CAST(obj->source); FT_ATOMIC_ADD_SSIZE(b->exports, -1); + Py_CLEAR(view->internal); } static int diff --git a/Modules/_io/clinic/_iomodule.c.h b/Modules/_io/clinic/_iomodule.c.h index f03638064385e28..462597078b77d9c 100644 --- a/Modules/_io/clinic/_iomodule.c.h +++ b/Modules/_io/clinic/_iomodule.c.h @@ -7,6 +7,7 @@ preserve # include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(_io_open__doc__, "open($module, /, file, mode=\'r\', buffering=-1, encoding=None,\n" @@ -27,10 +28,7 @@ PyDoc_STRVAR(_io_open__doc__, "it already exists), \'x\' for creating and writing to a new file, and\n" "\'a\' for appending (which on some Unix systems, means that all writes\n" "append to the end of the file regardless of the current seek position).\n" -"In text mode, if encoding is not specified the encoding used is platform\n" -"dependent: locale.getencoding() is called to get the current locale\n" -"encoding. (For reading and writing raw bytes use binary mode and leave\n" -"encoding unspecified.) The available modes are:\n" +"The available modes are:\n" "\n" "========= ==========================================================\n" "Character Meaning\n" @@ -55,8 +53,7 @@ PyDoc_STRVAR(_io_open__doc__, "binary mode (appending \'b\' to the mode argument) return contents as\n" "bytes objects without any decoding. In text mode (the default, or when\n" "\'t\' is appended to the mode argument), the contents of the file are\n" -"returned as strings, the bytes having been first decoded using a\n" -"platform-dependent encoding or using the specified encoding if given.\n" +"decoded using the encoding described below and returned as strings.\n" "\n" "buffering is an optional integer used to set the buffering policy.\n" "Pass 0 to switch buffering off (only allowed in binary mode), 1 to\n" @@ -73,10 +70,11 @@ PyDoc_STRVAR(_io_open__doc__, " use line buffering. Other text files use the policy described above\n" " for binary files.\n" "\n" -"encoding is the name of the encoding used to decode or encode the\n" -"file. This should only be used in text mode. The default encoding is\n" -"platform dependent, but any encoding supported by Python can be\n" -"passed. See the codecs module for the list of supported encodings.\n" +"encoding is the name of the encoding used to decode or encode the file.\n" +"This should only be used in text mode. The default encoding is UTF-8;\n" +"if UTF-8 Mode is disabled, the encoding returned by\n" +"locale.getencoding() is used instead. See the codecs module for the\n" +"list of supported encodings.\n" "\n" "errors is an optional string that specifies how encoding errors are to\n" "be handled---this argument should not be used in binary mode. Pass\n" @@ -192,15 +190,10 @@ _io_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw _PyArg_BadArgument("open", "argument 'mode'", "str", args[1]); goto exit; } - Py_ssize_t mode_length; - mode = PyUnicode_AsUTF8AndSize(args[1], &mode_length); + mode = _PyUnicode_AsUTF8NoNUL(args[1]); if (mode == NULL) { goto exit; } - if (strlen(mode) != (size_t)mode_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_pos; } @@ -219,15 +212,10 @@ _io_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw encoding = NULL; } else if (PyUnicode_Check(args[3])) { - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[3], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(args[3]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("open", "argument 'encoding'", "str or None", args[3]); @@ -242,15 +230,10 @@ _io_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw errors = NULL; } else if (PyUnicode_Check(args[4])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[4], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[4]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("open", "argument 'errors'", "str or None", args[4]); @@ -265,15 +248,10 @@ _io_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw newline = NULL; } else if (PyUnicode_Check(args[5])) { - Py_ssize_t newline_length; - newline = PyUnicode_AsUTF8AndSize(args[5], &newline_length); + newline = _PyUnicode_AsUTF8NoNUL(args[5]); if (newline == NULL) { goto exit; } - if (strlen(newline) != (size_t)newline_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("open", "argument 'newline'", "str or None", args[5]); @@ -411,4 +389,4 @@ _io_open_code(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec exit: return return_value; } -/*[clinic end generated code: output=5190d11f0803bfe8 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=517d977e17d38fce input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/bufferedio.c.h b/Modules/_io/clinic/bufferedio.c.h index b7c0ca2c4b919b6..0cedf4a9948e9da 100644 --- a/Modules/_io/clinic/bufferedio.c.h +++ b/Modules/_io/clinic/bufferedio.c.h @@ -4,7 +4,7 @@ preserve #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) # include "pycore_gc.h" // PyGC_Head -# include "pycore_runtime.h" // _Py_SINGLETON() +# include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() @@ -135,35 +135,22 @@ static PyObject * _io__BufferedIOBase_read(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "read", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; int size = -1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("read", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { goto exit; } if (nargs < 1) { - goto skip_optional_posonly; + goto skip_optional; } size = PyLong_AsInt(args[0]); if (size == -1 && PyErr_Occurred()) { goto exit; } -skip_optional_posonly: +skip_optional: return_value = _io__BufferedIOBase_read_impl(self, cls, size); exit: @@ -190,35 +177,22 @@ static PyObject * _io__BufferedIOBase_read1(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "read1", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; int size = -1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("read1", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("read1", nargs, 0, 1)) { goto exit; } if (nargs < 1) { - goto skip_optional_posonly; + goto skip_optional; } size = PyLong_AsInt(args[0]); if (size == -1 && PyErr_Occurred()) { goto exit; } -skip_optional_posonly: +skip_optional: return_value = _io__BufferedIOBase_read1_impl(self, cls, size); exit: @@ -248,25 +222,12 @@ static PyObject * _io__BufferedIOBase_write(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "write", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *b; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("write", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("write", nargs, 1, 1)) { goto exit; } b = args[0]; @@ -343,16 +304,6 @@ _io__Buffered_simple_flush(PyObject *self, PyObject *Py_UNUSED(ignored)) return return_value; } -#if !defined(_io__Buffered_closed_DOCSTR) -# define _io__Buffered_closed_DOCSTR NULL -#endif -#if defined(_IO__BUFFERED_CLOSED_GETSETDEF) -# undef _IO__BUFFERED_CLOSED_GETSETDEF -# define _IO__BUFFERED_CLOSED_GETSETDEF {"closed", (getter)_io__Buffered_closed_get, (setter)_io__Buffered_closed_set, _io__Buffered_closed_DOCSTR}, -#else -# define _IO__BUFFERED_CLOSED_GETSETDEF {"closed", (getter)_io__Buffered_closed_get, NULL, _io__Buffered_closed_DOCSTR}, -#endif - static PyObject * _io__Buffered_closed_get_impl(buffered *self); @@ -483,16 +434,6 @@ _io__Buffered_writable(PyObject *self, PyObject *Py_UNUSED(ignored)) return return_value; } -#if !defined(_io__Buffered_name_DOCSTR) -# define _io__Buffered_name_DOCSTR NULL -#endif -#if defined(_IO__BUFFERED_NAME_GETSETDEF) -# undef _IO__BUFFERED_NAME_GETSETDEF -# define _IO__BUFFERED_NAME_GETSETDEF {"name", (getter)_io__Buffered_name_get, (setter)_io__Buffered_name_set, _io__Buffered_name_DOCSTR}, -#else -# define _IO__BUFFERED_NAME_GETSETDEF {"name", (getter)_io__Buffered_name_get, NULL, _io__Buffered_name_DOCSTR}, -#endif - static PyObject * _io__Buffered_name_get_impl(buffered *self); @@ -508,16 +449,6 @@ _io__Buffered_name_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_io__Buffered_mode_DOCSTR) -# define _io__Buffered_mode_DOCSTR NULL -#endif -#if defined(_IO__BUFFERED_MODE_GETSETDEF) -# undef _IO__BUFFERED_MODE_GETSETDEF -# define _IO__BUFFERED_MODE_GETSETDEF {"mode", (getter)_io__Buffered_mode_get, (setter)_io__Buffered_mode_set, _io__Buffered_mode_DOCSTR}, -#else -# define _IO__BUFFERED_MODE_GETSETDEF {"mode", (getter)_io__Buffered_mode_get, NULL, _io__Buffered_mode_DOCSTR}, -#endif - static PyObject * _io__Buffered_mode_get_impl(buffered *self); @@ -904,32 +835,19 @@ static PyObject * _io__Buffered_truncate(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "truncate", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *pos = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("truncate", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { goto exit; } if (nargs < 1) { - goto skip_optional_posonly; + goto skip_optional; } pos = args[0]; -skip_optional_posonly: +skip_optional: Py_BEGIN_CRITICAL_SECTION(self); return_value = _io__Buffered_truncate_impl((buffered *)self, cls, pos); Py_END_CRITICAL_SECTION(); @@ -1186,6 +1104,292 @@ _io_BufferedRWPair___init__(PyObject *self, PyObject *args, PyObject *kwargs) return return_value; } +PyDoc_STRVAR(_io_BufferedRWPair_read__doc__, +"read($self, size=-1, /)\n" +"--\n" +"\n"); + +#define _IO_BUFFEREDRWPAIR_READ_METHODDEF \ + {"read", _PyCFunction_CAST(_io_BufferedRWPair_read), METH_FASTCALL, _io_BufferedRWPair_read__doc__}, + +static PyObject * +_io_BufferedRWPair_read_impl(rwpair *self, PyObject *size); + +static PyObject * +_io_BufferedRWPair_read(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *size = NULL; + + if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + size = args[0]; +skip_optional: + return_value = _io_BufferedRWPair_read_impl((rwpair *)self, size); + +exit: + return return_value; +} + +PyDoc_STRVAR(_io_BufferedRWPair_peek__doc__, +"peek($self, size=0, /)\n" +"--\n" +"\n"); + +#define _IO_BUFFEREDRWPAIR_PEEK_METHODDEF \ + {"peek", _PyCFunction_CAST(_io_BufferedRWPair_peek), METH_FASTCALL, _io_BufferedRWPair_peek__doc__}, + +static PyObject * +_io_BufferedRWPair_peek_impl(rwpair *self, PyObject *size); + +static PyObject * +_io_BufferedRWPair_peek(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *size = NULL; + + if (!_PyArg_CheckPositional("peek", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + size = args[0]; +skip_optional: + return_value = _io_BufferedRWPair_peek_impl((rwpair *)self, size); + +exit: + return return_value; +} + +PyDoc_STRVAR(_io_BufferedRWPair_read1__doc__, +"read1($self, size=-1, /)\n" +"--\n" +"\n"); + +#define _IO_BUFFEREDRWPAIR_READ1_METHODDEF \ + {"read1", _PyCFunction_CAST(_io_BufferedRWPair_read1), METH_FASTCALL, _io_BufferedRWPair_read1__doc__}, + +static PyObject * +_io_BufferedRWPair_read1_impl(rwpair *self, PyObject *size); + +static PyObject * +_io_BufferedRWPair_read1(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *size = NULL; + + if (!_PyArg_CheckPositional("read1", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + size = args[0]; +skip_optional: + return_value = _io_BufferedRWPair_read1_impl((rwpair *)self, size); + +exit: + return return_value; +} + +PyDoc_STRVAR(_io_BufferedRWPair_readline__doc__, +"readline($self, size=-1, /)\n" +"--\n" +"\n" +"Read and return a line from the stream.\n" +"\n" +"If size is specified, at most size bytes will be read.\n" +"\n" +"The line terminator is always b\'\\n\'."); + +#define _IO_BUFFEREDRWPAIR_READLINE_METHODDEF \ + {"readline", _PyCFunction_CAST(_io_BufferedRWPair_readline), METH_FASTCALL, _io_BufferedRWPair_readline__doc__}, + +static PyObject * +_io_BufferedRWPair_readline_impl(rwpair *self, PyObject *size); + +static PyObject * +_io_BufferedRWPair_readline(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *size = NULL; + + if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + size = args[0]; +skip_optional: + return_value = _io_BufferedRWPair_readline_impl((rwpair *)self, size); + +exit: + return return_value; +} + +PyDoc_STRVAR(_io_BufferedRWPair_readinto__doc__, +"readinto($self, buffer, /)\n" +"--\n" +"\n"); + +#define _IO_BUFFEREDRWPAIR_READINTO_METHODDEF \ + {"readinto", (PyCFunction)_io_BufferedRWPair_readinto, METH_O, _io_BufferedRWPair_readinto__doc__}, + +static PyObject * +_io_BufferedRWPair_readinto_impl(rwpair *self, PyObject *buffer); + +static PyObject * +_io_BufferedRWPair_readinto(PyObject *self, PyObject *buffer) +{ + PyObject *return_value = NULL; + + return_value = _io_BufferedRWPair_readinto_impl((rwpair *)self, buffer); + + return return_value; +} + +PyDoc_STRVAR(_io_BufferedRWPair_readinto1__doc__, +"readinto1($self, buffer, /)\n" +"--\n" +"\n"); + +#define _IO_BUFFEREDRWPAIR_READINTO1_METHODDEF \ + {"readinto1", (PyCFunction)_io_BufferedRWPair_readinto1, METH_O, _io_BufferedRWPair_readinto1__doc__}, + +static PyObject * +_io_BufferedRWPair_readinto1_impl(rwpair *self, PyObject *buffer); + +static PyObject * +_io_BufferedRWPair_readinto1(PyObject *self, PyObject *buffer) +{ + PyObject *return_value = NULL; + + return_value = _io_BufferedRWPair_readinto1_impl((rwpair *)self, buffer); + + return return_value; +} + +PyDoc_STRVAR(_io_BufferedRWPair_write__doc__, +"write($self, buffer, /)\n" +"--\n" +"\n"); + +#define _IO_BUFFEREDRWPAIR_WRITE_METHODDEF \ + {"write", (PyCFunction)_io_BufferedRWPair_write, METH_O, _io_BufferedRWPair_write__doc__}, + +static PyObject * +_io_BufferedRWPair_write_impl(rwpair *self, PyObject *buffer); + +static PyObject * +_io_BufferedRWPair_write(PyObject *self, PyObject *buffer) +{ + PyObject *return_value = NULL; + + return_value = _io_BufferedRWPair_write_impl((rwpair *)self, buffer); + + return return_value; +} + +PyDoc_STRVAR(_io_BufferedRWPair_flush__doc__, +"flush($self, /)\n" +"--\n" +"\n"); + +#define _IO_BUFFEREDRWPAIR_FLUSH_METHODDEF \ + {"flush", (PyCFunction)_io_BufferedRWPair_flush, METH_NOARGS, _io_BufferedRWPair_flush__doc__}, + +static PyObject * +_io_BufferedRWPair_flush_impl(rwpair *self); + +static PyObject * +_io_BufferedRWPair_flush(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _io_BufferedRWPair_flush_impl((rwpair *)self); +} + +PyDoc_STRVAR(_io_BufferedRWPair_readable__doc__, +"readable($self, /)\n" +"--\n" +"\n"); + +#define _IO_BUFFEREDRWPAIR_READABLE_METHODDEF \ + {"readable", (PyCFunction)_io_BufferedRWPair_readable, METH_NOARGS, _io_BufferedRWPair_readable__doc__}, + +static PyObject * +_io_BufferedRWPair_readable_impl(rwpair *self); + +static PyObject * +_io_BufferedRWPair_readable(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _io_BufferedRWPair_readable_impl((rwpair *)self); +} + +PyDoc_STRVAR(_io_BufferedRWPair_writable__doc__, +"writable($self, /)\n" +"--\n" +"\n"); + +#define _IO_BUFFEREDRWPAIR_WRITABLE_METHODDEF \ + {"writable", (PyCFunction)_io_BufferedRWPair_writable, METH_NOARGS, _io_BufferedRWPair_writable__doc__}, + +static PyObject * +_io_BufferedRWPair_writable_impl(rwpair *self); + +static PyObject * +_io_BufferedRWPair_writable(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _io_BufferedRWPair_writable_impl((rwpair *)self); +} + +PyDoc_STRVAR(_io_BufferedRWPair_close__doc__, +"close($self, /)\n" +"--\n" +"\n"); + +#define _IO_BUFFEREDRWPAIR_CLOSE_METHODDEF \ + {"close", (PyCFunction)_io_BufferedRWPair_close, METH_NOARGS, _io_BufferedRWPair_close__doc__}, + +static PyObject * +_io_BufferedRWPair_close_impl(rwpair *self); + +static PyObject * +_io_BufferedRWPair_close(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _io_BufferedRWPair_close_impl((rwpair *)self); +} + +PyDoc_STRVAR(_io_BufferedRWPair_isatty__doc__, +"isatty($self, /)\n" +"--\n" +"\n"); + +#define _IO_BUFFEREDRWPAIR_ISATTY_METHODDEF \ + {"isatty", (PyCFunction)_io_BufferedRWPair_isatty, METH_NOARGS, _io_BufferedRWPair_isatty__doc__}, + +static PyObject * +_io_BufferedRWPair_isatty_impl(rwpair *self); + +static PyObject * +_io_BufferedRWPair_isatty(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _io_BufferedRWPair_isatty_impl((rwpair *)self); +} + +static PyObject * +_io_BufferedRWPair_closed_get_impl(rwpair *self); + +static PyObject * +_io_BufferedRWPair_closed_get(PyObject *self, void *Py_UNUSED(context)) +{ + return _io_BufferedRWPair_closed_get_impl((rwpair *)self); +} + PyDoc_STRVAR(_io_BufferedRandom___init____doc__, "BufferedRandom(raw, buffer_size=DEFAULT_BUFFER_SIZE)\n" "--\n" @@ -1265,4 +1469,12 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=3ee17211d2010462 input=a9049054013a1b77]*/ +#define _IO__BUFFERED_CLOSED_GETSETDEF {"closed", (getter)_io__Buffered_closed_get, (setter)NULL, NULL}, + +#define _IO__BUFFERED_NAME_GETSETDEF {"name", (getter)_io__Buffered_name_get, (setter)NULL, NULL}, + +#define _IO__BUFFERED_MODE_GETSETDEF {"mode", (getter)_io__Buffered_mode_get, (setter)NULL, NULL}, + +#define _IO_BUFFEREDRWPAIR_CLOSED_GETSETDEF {"closed", (getter)_io_BufferedRWPair_closed_get, (setter)NULL, NULL}, + +/*[clinic end generated code: output=1596bb353f00a1ea input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h index a0159c063b58591..e48d71397367daf 100644 --- a/Modules/_io/clinic/bytesio.c.h +++ b/Modules/_io/clinic/bytesio.c.h @@ -4,11 +4,35 @@ preserve #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) # include "pycore_gc.h" // PyGC_Head -# include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t() #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_runtime.h" // _Py_SINGLETON() + +PyDoc_STRVAR(_io_BytesIO_closed__doc__, +"True if the file is closed."); + +static int +_io_BytesIO_closed_get_impl(bytesio *self); + +static PyObject * +_io_BytesIO_closed_get(PyObject *self, void *Py_UNUSED(context)) +{ + PyObject *return_value = NULL; + int _return_value; + + Py_BEGIN_CRITICAL_SECTION(self); + _return_value = _io_BytesIO_closed_get_impl((bytesio *)self); + Py_END_CRITICAL_SECTION(); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} PyDoc_STRVAR(_io_BytesIO_readable__doc__, "readable($self, /)\n" @@ -487,6 +511,21 @@ _io_BytesIO_truncate(PyObject *self, PyObject *const *args, Py_ssize_t nargs) return return_value; } +static PyObject * +bytesio_iternext_impl(bytesio *self); + +static PyObject * +bytesio_iternext(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = bytesio_iternext_impl((bytesio *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(_io_BytesIO_seek__doc__, "seek($self, pos, whence=0, /)\n" "--\n" @@ -621,6 +660,52 @@ _io_BytesIO_close(PyObject *self, PyObject *Py_UNUSED(ignored)) return return_value; } +PyDoc_STRVAR(_io_BytesIO___getstate____doc__, +"__getstate__($self, /)\n" +"--\n" +"\n"); + +#define _IO_BYTESIO___GETSTATE___METHODDEF \ + {"__getstate__", (PyCFunction)_io_BytesIO___getstate__, METH_NOARGS, _io_BytesIO___getstate____doc__}, + +static PyObject * +_io_BytesIO___getstate___impl(bytesio *self); + +static PyObject * +_io_BytesIO___getstate__(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _io_BytesIO___getstate___impl((bytesio *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +PyDoc_STRVAR(_io_BytesIO___setstate____doc__, +"__setstate__($self, state, /)\n" +"--\n" +"\n"); + +#define _IO_BYTESIO___SETSTATE___METHODDEF \ + {"__setstate__", (PyCFunction)_io_BytesIO___setstate__, METH_O, _io_BytesIO___setstate____doc__}, + +static PyObject * +_io_BytesIO___setstate___impl(bytesio *self, PyObject *state); + +static PyObject * +_io_BytesIO___setstate__(PyObject *self, PyObject *state) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _io_BytesIO___setstate___impl((bytesio *)self, state); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(_io_BytesIO___init____doc__, "BytesIO(initial_bytes=b\'\')\n" "--\n" @@ -631,7 +716,8 @@ static int _io_BytesIO___init___impl(bytesio *self, PyObject *initvalue); static int -_io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) +_io_BytesIO___init___helper(PyObject *self, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { int return_value = -1; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -663,11 +749,10 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[1]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; + Py_ssize_t noptargs = nargs + nkw - 0; PyObject *initvalue = NULL; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -684,4 +769,91 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=b5e625e31b2a82f0 input=a9049054013a1b77]*/ + +static int +_io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) +{ + return _io_BytesIO___init___helper(self, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +_io_BytesIO_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *self; + int _result; + PyObject *initvalue = NULL; + + assert(_PyType_CAST(type)->tp_init == _io_BytesIO___init__); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs > 1) { + self = _PyType_CAST(type)->tp_new(_PyType_CAST(type), + (PyObject *)&_Py_SINGLETON(tuple_empty), NULL); + if (self == NULL) { + return NULL; + } + _result = _io_BytesIO___init___helper(self, args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + if (_result != 0) { + Py_DECREF(self); + return NULL; + } + return self; + } + if (nargs < 1) { + goto skip_optional; + } + initvalue = args[0]; +skip_optional: + self = _PyType_CAST(type)->tp_new(_PyType_CAST(type), + (PyObject *)&_Py_SINGLETON(tuple_empty), NULL); + if (self == NULL) { + goto exit; + } + Py_BEGIN_CRITICAL_SECTION(self); + _result = _io_BytesIO___init___impl((bytesio *)self, initvalue); + Py_END_CRITICAL_SECTION(); + if (_result != 0) { + Py_DECREF(self); + goto exit; + } + return_value = self; + +exit: + return return_value; +} + +PyDoc_STRVAR(_io_BytesIO___sizeof____doc__, +"__sizeof__($self, /)\n" +"--\n" +"\n" +"Size of object in memory, in bytes."); + +#define _IO_BYTESIO___SIZEOF___METHODDEF \ + {"__sizeof__", (PyCFunction)_io_BytesIO___sizeof__, METH_NOARGS, _io_BytesIO___sizeof____doc__}, + +static PyObject * +_io_BytesIO___sizeof___impl(bytesio *self); + +static PyObject * +_io_BytesIO___sizeof__(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _io_BytesIO___sizeof___impl((bytesio *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} +#define _IO_BYTESIO_CLOSED_GETSETDEF {"closed", (getter)_io_BytesIO_closed_get, (setter)NULL, _io_BytesIO_closed__doc__}, + +/*[clinic end generated code: output=b9d367ad8e0b44d2 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/fileio.c.h b/Modules/_io/clinic/fileio.c.h index 890b6bc3fac9d55..9db31938f3334f3 100644 --- a/Modules/_io/clinic/fileio.c.h +++ b/Modules/_io/clinic/fileio.c.h @@ -8,6 +8,28 @@ preserve #endif #include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() + +PyDoc_STRVAR(_io_FileIO__dealloc_warn__doc__, +"_dealloc_warn($self, source, /)\n" +"--\n" +"\n"); + +#define _IO_FILEIO__DEALLOC_WARN_METHODDEF \ + {"_dealloc_warn", (PyCFunction)_io_FileIO__dealloc_warn, METH_O, _io_FileIO__dealloc_warn__doc__}, + +static PyObject * +_io_FileIO__dealloc_warn_impl(fileio *self, PyObject *source); + +static PyObject * +_io_FileIO__dealloc_warn(PyObject *self, PyObject *source) +{ + PyObject *return_value = NULL; + + return_value = _io_FileIO__dealloc_warn_impl((fileio *)self, source); + + return return_value; +} PyDoc_STRVAR(_io_FileIO_close__doc__, "close($self, /)\n" @@ -113,15 +135,10 @@ _io_FileIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("FileIO", "argument 'mode'", "str", fastargs[1]); goto exit; } - Py_ssize_t mode_length; - mode = PyUnicode_AsUTF8AndSize(fastargs[1], &mode_length); + mode = _PyUnicode_AsUTF8NoNUL(fastargs[1]); if (mode == NULL) { goto exit; } - if (strlen(mode) != (size_t)mode_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_pos; } @@ -231,25 +248,12 @@ static PyObject * _io_FileIO_readinto(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "readinto", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; Py_buffer buffer = {NULL, NULL}; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("readinto", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("readinto", nargs, 1, 1)) { goto exit; } if (PyObject_GetBuffer(args[0], &buffer, PyBUF_WRITABLE) < 0) { @@ -322,34 +326,21 @@ static PyObject * _io_FileIO_read(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "read", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; Py_ssize_t size = -1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("read", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { goto exit; } if (nargs < 1) { - goto skip_optional_posonly; + goto skip_optional; } if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { goto exit; } -skip_optional_posonly: +skip_optional: return_value = _io_FileIO_read_impl((fileio *)self, cls, size); exit: @@ -376,25 +367,12 @@ static PyObject * _io_FileIO_write(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "write", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; Py_buffer b = {NULL, NULL}; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("write", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("write", nargs, 1, 1)) { goto exit; } if (PyObject_GetBuffer(args[0], &b, PyBUF_SIMPLE) != 0) { @@ -498,32 +476,19 @@ static PyObject * _io_FileIO_truncate(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "truncate", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *posobj = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("truncate", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { goto exit; } if (nargs < 1) { - goto skip_optional_posonly; + goto skip_optional; } posobj = args[0]; -skip_optional_posonly: +skip_optional: return_value = _io_FileIO_truncate_impl((fileio *)self, cls, posobj); exit: @@ -550,7 +515,110 @@ _io_FileIO_isatty(PyObject *self, PyObject *Py_UNUSED(ignored)) return _io_FileIO_isatty_impl((fileio *)self); } +PyDoc_STRVAR(_io_FileIO__isatty_open_only__doc__, +"_isatty_open_only($self, /)\n" +"--\n" +"\n"); + +#define _IO_FILEIO__ISATTY_OPEN_ONLY_METHODDEF \ + {"_isatty_open_only", (PyCFunction)_io_FileIO__isatty_open_only, METH_NOARGS, _io_FileIO__isatty_open_only__doc__}, + +static PyObject * +_io_FileIO__isatty_open_only_impl(fileio *self); + +static PyObject * +_io_FileIO__isatty_open_only(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _io_FileIO__isatty_open_only_impl((fileio *)self); +} + +PyDoc_STRVAR(_io_FileIO_closed__doc__, +"True if the file is closed."); + +static int +_io_FileIO_closed_get_impl(fileio *self); + +static PyObject * +_io_FileIO_closed_get(PyObject *self, void *Py_UNUSED(context)) +{ + PyObject *return_value = NULL; + int _return_value; + + _return_value = _io_FileIO_closed_get_impl((fileio *)self); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(_io_FileIO_closefd__doc__, +"True if the file descriptor will be closed by close()."); + +static int +_io_FileIO_closefd_get_impl(fileio *self); + +static PyObject * +_io_FileIO_closefd_get(PyObject *self, void *Py_UNUSED(context)) +{ + PyObject *return_value = NULL; + int _return_value; + + _return_value = _io_FileIO_closefd_get_impl((fileio *)self); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(_io_FileIO_mode__doc__, +"String giving the file mode."); + +static PyObject * +_io_FileIO_mode_get_impl(fileio *self); + +static PyObject * +_io_FileIO_mode_get(PyObject *self, void *Py_UNUSED(context)) +{ + return _io_FileIO_mode_get_impl((fileio *)self); +} + +PyDoc_STRVAR(_io_FileIO__blksize__doc__, +"Stat st_blksize if available."); + +static long +_io_FileIO__blksize_get_impl(fileio *self); + +static PyObject * +_io_FileIO__blksize_get(PyObject *self, void *Py_UNUSED(context)) +{ + PyObject *return_value = NULL; + long _return_value; + + _return_value = _io_FileIO__blksize_get_impl((fileio *)self); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyLong_FromLong(_return_value); + +exit: + return return_value; +} + #ifndef _IO_FILEIO_TRUNCATE_METHODDEF #define _IO_FILEIO_TRUNCATE_METHODDEF #endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */ -/*[clinic end generated code: output=453d584e2e72f986 input=a9049054013a1b77]*/ +#define _IO_FILEIO_CLOSED_GETSETDEF {"closed", (getter)_io_FileIO_closed_get, (setter)NULL, _io_FileIO_closed__doc__}, + +#define _IO_FILEIO_CLOSEFD_GETSETDEF {"closefd", (getter)_io_FileIO_closefd_get, (setter)NULL, _io_FileIO_closefd__doc__}, + +#define _IO_FILEIO_MODE_GETSETDEF {"mode", (getter)_io_FileIO_mode_get, (setter)NULL, _io_FileIO_mode__doc__}, + +#define _IO_FILEIO__BLKSIZE_GETSETDEF {"_blksize", (getter)_io_FileIO__blksize_get, (setter)NULL, _io_FileIO__blksize__doc__}, + +/*[clinic end generated code: output=b8d6d338bfd0a58f input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/iobase.c.h b/Modules/_io/clinic/iobase.c.h index e4438c26431aa8e..c7adafe1580ea9a 100644 --- a/Modules/_io/clinic/iobase.c.h +++ b/Modules/_io/clinic/iobase.c.h @@ -2,11 +2,8 @@ preserve [clinic start generated code]*/ -#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) -# include "pycore_runtime.h" // _Py_SINGLETON() -#endif #include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t() -#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_modsupport.h" // _PyArg_CheckPositional() PyDoc_STRVAR(_io__IOBase_seek__doc__, "seek($self, offset, whence=os.SEEK_SET, /)\n" @@ -41,26 +38,13 @@ static PyObject * _io__IOBase_seek(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "seek", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; int offset; int whence = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("seek", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) { goto exit; } offset = PyLong_AsInt(args[0]); @@ -68,13 +52,13 @@ _io__IOBase_seek(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ss goto exit; } if (nargs < 2) { - goto skip_optional_posonly; + goto skip_optional; } whence = PyLong_AsInt(args[1]); if (whence == -1 && PyErr_Occurred()) { goto exit; } -skip_optional_posonly: +skip_optional: return_value = _io__IOBase_seek_impl(self, cls, offset, whence); exit: @@ -119,32 +103,19 @@ static PyObject * _io__IOBase_truncate(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "truncate", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *size = Py_None; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("truncate", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { goto exit; } if (nargs < 1) { - goto skip_optional_posonly; + goto skip_optional; } size = args[0]; -skip_optional_posonly: +skip_optional: return_value = _io__IOBase_truncate_impl(self, cls, size); exit: @@ -171,6 +142,96 @@ _io__IOBase_flush(PyObject *self, PyObject *Py_UNUSED(ignored)) return _io__IOBase_flush_impl(self); } +PyDoc_STRVAR(_io__IOBase_closed__doc__, +"True if the file is closed."); + +static int +_io__IOBase_closed_get_impl(PyObject *self); + +static PyObject * +_io__IOBase_closed_get(PyObject *self, void *Py_UNUSED(context)) +{ + PyObject *return_value = NULL; + int _return_value; + + _return_value = _io__IOBase_closed_get_impl(self); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(_io__IOBase__checkClosed__doc__, +"_checkClosed($self, /)\n" +"--\n" +"\n"); + +#define _IO__IOBASE__CHECKCLOSED_METHODDEF \ + {"_checkClosed", (PyCFunction)_io__IOBase__checkClosed, METH_NOARGS, _io__IOBase__checkClosed__doc__}, + +static PyObject * +_io__IOBase__checkClosed_impl(PyObject *self); + +static PyObject * +_io__IOBase__checkClosed(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _io__IOBase__checkClosed_impl(self); +} + +PyDoc_STRVAR(_io__IOBase__checkSeekable__doc__, +"_checkSeekable($self, /)\n" +"--\n" +"\n"); + +#define _IO__IOBASE__CHECKSEEKABLE_METHODDEF \ + {"_checkSeekable", (PyCFunction)_io__IOBase__checkSeekable, METH_NOARGS, _io__IOBase__checkSeekable__doc__}, + +static PyObject * +_io__IOBase__checkSeekable_impl(PyObject *self); + +static PyObject * +_io__IOBase__checkSeekable(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _io__IOBase__checkSeekable_impl(self); +} + +PyDoc_STRVAR(_io__IOBase__checkReadable__doc__, +"_checkReadable($self, /)\n" +"--\n" +"\n"); + +#define _IO__IOBASE__CHECKREADABLE_METHODDEF \ + {"_checkReadable", (PyCFunction)_io__IOBase__checkReadable, METH_NOARGS, _io__IOBase__checkReadable__doc__}, + +static PyObject * +_io__IOBase__checkReadable_impl(PyObject *self); + +static PyObject * +_io__IOBase__checkReadable(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _io__IOBase__checkReadable_impl(self); +} + +PyDoc_STRVAR(_io__IOBase__checkWritable__doc__, +"_checkWritable($self, /)\n" +"--\n" +"\n"); + +#define _IO__IOBASE__CHECKWRITABLE_METHODDEF \ + {"_checkWritable", (PyCFunction)_io__IOBase__checkWritable, METH_NOARGS, _io__IOBase__checkWritable__doc__}, + +static PyObject * +_io__IOBase__checkWritable_impl(PyObject *self); + +static PyObject * +_io__IOBase__checkWritable(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _io__IOBase__checkWritable_impl(self); +} + PyDoc_STRVAR(_io__IOBase_close__doc__, "close($self, /)\n" "--\n" @@ -252,6 +313,55 @@ _io__IOBase_writable(PyObject *self, PyObject *Py_UNUSED(ignored)) return _io__IOBase_writable_impl(self); } +PyDoc_STRVAR(_io__IOBase___enter____doc__, +"__enter__($self, /)\n" +"--\n" +"\n" +"Context management protocol. Returns the stream itself."); + +#define _IO__IOBASE___ENTER___METHODDEF \ + {"__enter__", (PyCFunction)_io__IOBase___enter__, METH_NOARGS, _io__IOBase___enter____doc__}, + +static PyObject * +_io__IOBase___enter___impl(PyObject *self); + +static PyObject * +_io__IOBase___enter__(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _io__IOBase___enter___impl(self); +} + +PyDoc_STRVAR(_io__IOBase___exit____doc__, +"__exit__($self, /, *args)\n" +"--\n" +"\n" +"Context management protocol. Calls close()."); + +#define _IO__IOBASE___EXIT___METHODDEF \ + {"__exit__", _PyCFunction_CAST(_io__IOBase___exit__), METH_FASTCALL, _io__IOBase___exit____doc__}, + +static PyObject * +_io__IOBase___exit___impl(PyObject *self, PyObject *args); + +static PyObject * +_io__IOBase___exit__(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *__clinic_args = NULL; + + __clinic_args = PyTuple_FromArray(args, nargs); + if (__clinic_args == NULL) { + goto exit; + } + return_value = _io__IOBase___exit___impl(self, __clinic_args); + +exit: + /* Cleanup for args */ + Py_XDECREF(__clinic_args); + + return return_value; +} + PyDoc_STRVAR(_io__IOBase_fileno__doc__, "fileno($self, /)\n" "--\n" @@ -445,4 +555,22 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored)) { return _io__RawIOBase_readall_impl(self); } -/*[clinic end generated code: output=28c06bb6db32c096 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_io__RawIOBase_readinto__doc__, +"readinto($self, buffer, /)\n" +"--\n" +"\n"); + +#define _IO__RAWIOBASE_READINTO_METHODDEF \ + {"readinto", (PyCFunction)_io__RawIOBase_readinto, METH_O, _io__RawIOBase_readinto__doc__}, + +PyDoc_STRVAR(_io__RawIOBase_write__doc__, +"write($self, buffer, /)\n" +"--\n" +"\n"); + +#define _IO__RAWIOBASE_WRITE_METHODDEF \ + {"write", (PyCFunction)_io__RawIOBase_write, METH_O, _io__RawIOBase_write__doc__}, +#define _IO__IOBASE_CLOSED_GETSETDEF {"closed", (getter)_io__IOBase_closed_get, (setter)NULL, _io__IOBase_closed__doc__}, + +/*[clinic end generated code: output=fd729b0ef2ad52b8 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/stringio.c.h b/Modules/_io/clinic/stringio.c.h index d6d4afb9b63c624..bda87205e6bb718 100644 --- a/Modules/_io/clinic/stringio.c.h +++ b/Modules/_io/clinic/stringio.c.h @@ -135,6 +135,21 @@ _io_StringIO_readline(PyObject *self, PyObject *const *args, Py_ssize_t nargs) return return_value; } +static PyObject * +stringio_iternext_impl(stringio *self); + +static PyObject * +stringio_iternext(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = stringio_iternext_impl((stringio *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(_io_StringIO_truncate__doc__, "truncate($self, pos=None, /)\n" "--\n" @@ -477,66 +492,48 @@ _io_StringIO___setstate__(PyObject *self, PyObject *state) return return_value; } -#if !defined(_io_StringIO_closed_DOCSTR) -# define _io_StringIO_closed_DOCSTR NULL -#endif -#if defined(_IO_STRINGIO_CLOSED_GETSETDEF) -# undef _IO_STRINGIO_CLOSED_GETSETDEF -# define _IO_STRINGIO_CLOSED_GETSETDEF {"closed", (getter)_io_StringIO_closed_get, (setter)_io_StringIO_closed_set, _io_StringIO_closed_DOCSTR}, -#else -# define _IO_STRINGIO_CLOSED_GETSETDEF {"closed", (getter)_io_StringIO_closed_get, NULL, _io_StringIO_closed_DOCSTR}, -#endif - -static PyObject * +static int _io_StringIO_closed_get_impl(stringio *self); static PyObject * _io_StringIO_closed_get(PyObject *self, void *Py_UNUSED(context)) { PyObject *return_value = NULL; + int _return_value; Py_BEGIN_CRITICAL_SECTION(self); - return_value = _io_StringIO_closed_get_impl((stringio *)self); + _return_value = _io_StringIO_closed_get_impl((stringio *)self); Py_END_CRITICAL_SECTION(); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); +exit: return return_value; } -#if !defined(_io_StringIO_line_buffering_DOCSTR) -# define _io_StringIO_line_buffering_DOCSTR NULL -#endif -#if defined(_IO_STRINGIO_LINE_BUFFERING_GETSETDEF) -# undef _IO_STRINGIO_LINE_BUFFERING_GETSETDEF -# define _IO_STRINGIO_LINE_BUFFERING_GETSETDEF {"line_buffering", (getter)_io_StringIO_line_buffering_get, (setter)_io_StringIO_line_buffering_set, _io_StringIO_line_buffering_DOCSTR}, -#else -# define _IO_STRINGIO_LINE_BUFFERING_GETSETDEF {"line_buffering", (getter)_io_StringIO_line_buffering_get, NULL, _io_StringIO_line_buffering_DOCSTR}, -#endif - -static PyObject * +static int _io_StringIO_line_buffering_get_impl(stringio *self); static PyObject * _io_StringIO_line_buffering_get(PyObject *self, void *Py_UNUSED(context)) { PyObject *return_value = NULL; + int _return_value; Py_BEGIN_CRITICAL_SECTION(self); - return_value = _io_StringIO_line_buffering_get_impl((stringio *)self); + _return_value = _io_StringIO_line_buffering_get_impl((stringio *)self); Py_END_CRITICAL_SECTION(); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); +exit: return return_value; } -#if !defined(_io_StringIO_newlines_DOCSTR) -# define _io_StringIO_newlines_DOCSTR NULL -#endif -#if defined(_IO_STRINGIO_NEWLINES_GETSETDEF) -# undef _IO_STRINGIO_NEWLINES_GETSETDEF -# define _IO_STRINGIO_NEWLINES_GETSETDEF {"newlines", (getter)_io_StringIO_newlines_get, (setter)_io_StringIO_newlines_set, _io_StringIO_newlines_DOCSTR}, -#else -# define _IO_STRINGIO_NEWLINES_GETSETDEF {"newlines", (getter)_io_StringIO_newlines_get, NULL, _io_StringIO_newlines_DOCSTR}, -#endif - static PyObject * _io_StringIO_newlines_get_impl(stringio *self); @@ -551,4 +548,10 @@ _io_StringIO_newlines_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -/*[clinic end generated code: output=730c34b2a6c0500b input=a9049054013a1b77]*/ +#define _IO_STRINGIO_CLOSED_GETSETDEF {"closed", (getter)_io_StringIO_closed_get, (setter)NULL, NULL}, + +#define _IO_STRINGIO_LINE_BUFFERING_GETSETDEF {"line_buffering", (getter)_io_StringIO_line_buffering_get, (setter)NULL, NULL}, + +#define _IO_STRINGIO_NEWLINES_GETSETDEF {"newlines", (getter)_io_StringIO_newlines_get, (setter)NULL, NULL}, + +/*[clinic end generated code: output=38a0385529d9cbef input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/textio.c.h b/Modules/_io/clinic/textio.c.h index 8d59bda5f74b386..954fee5cd2d4bfb 100644 --- a/Modules/_io/clinic/textio.c.h +++ b/Modules/_io/clinic/textio.c.h @@ -4,11 +4,12 @@ preserve #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) # include "pycore_gc.h" // PyGC_Head -# include "pycore_runtime.h" // _Py_SINGLETON() #endif #include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t() #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() -#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_runtime.h" // _Py_SINGLETON() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(_io__TextIOBase_detach__doc__, "detach($self, /)\n" @@ -55,35 +56,22 @@ static PyObject * _io__TextIOBase_read(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "read", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; int size = -1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("read", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { goto exit; } if (nargs < 1) { - goto skip_optional_posonly; + goto skip_optional; } size = PyLong_AsInt(args[0]); if (size == -1 && PyErr_Occurred()) { goto exit; } -skip_optional_posonly: +skip_optional: return_value = _io__TextIOBase_read_impl(self, cls, size); exit: @@ -110,35 +98,22 @@ static PyObject * _io__TextIOBase_readline(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "readline", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; int size = -1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("readline", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) { goto exit; } if (nargs < 1) { - goto skip_optional_posonly; + goto skip_optional; } size = PyLong_AsInt(args[0]); if (size == -1 && PyErr_Occurred()) { goto exit; } -skip_optional_posonly: +skip_optional: return_value = _io__TextIOBase_readline_impl(self, cls, size); exit: @@ -165,40 +140,22 @@ static PyObject * _io__TextIOBase_write(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "write", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; const char *s; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("write", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("write", nargs, 1, 1)) { goto exit; } if (!PyUnicode_Check(args[0])) { _PyArg_BadArgument("write", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t s_length; - s = PyUnicode_AsUTF8AndSize(args[0], &s_length); + s = _PyUnicode_AsUTF8NoNUL(args[0]); if (s == NULL) { goto exit; } - if (strlen(s) != (size_t)s_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _io__TextIOBase_write_impl(self, cls, s); exit: @@ -209,20 +166,6 @@ PyDoc_STRVAR(_io__TextIOBase_encoding__doc__, "Encoding of the text stream.\n" "\n" "Subclasses should override."); -#if defined(_io__TextIOBase_encoding_DOCSTR) -# undef _io__TextIOBase_encoding_DOCSTR -#endif -#define _io__TextIOBase_encoding_DOCSTR _io__TextIOBase_encoding__doc__ - -#if !defined(_io__TextIOBase_encoding_DOCSTR) -# define _io__TextIOBase_encoding_DOCSTR NULL -#endif -#if defined(_IO__TEXTIOBASE_ENCODING_GETSETDEF) -# undef _IO__TEXTIOBASE_ENCODING_GETSETDEF -# define _IO__TEXTIOBASE_ENCODING_GETSETDEF {"encoding", (getter)_io__TextIOBase_encoding_get, (setter)_io__TextIOBase_encoding_set, _io__TextIOBase_encoding_DOCSTR}, -#else -# define _IO__TEXTIOBASE_ENCODING_GETSETDEF {"encoding", (getter)_io__TextIOBase_encoding_get, NULL, _io__TextIOBase_encoding_DOCSTR}, -#endif static PyObject * _io__TextIOBase_encoding_get_impl(PyObject *self); @@ -239,20 +182,6 @@ PyDoc_STRVAR(_io__TextIOBase_newlines__doc__, "Only line endings translated during reading are considered.\n" "\n" "Subclasses should override."); -#if defined(_io__TextIOBase_newlines_DOCSTR) -# undef _io__TextIOBase_newlines_DOCSTR -#endif -#define _io__TextIOBase_newlines_DOCSTR _io__TextIOBase_newlines__doc__ - -#if !defined(_io__TextIOBase_newlines_DOCSTR) -# define _io__TextIOBase_newlines_DOCSTR NULL -#endif -#if defined(_IO__TEXTIOBASE_NEWLINES_GETSETDEF) -# undef _IO__TEXTIOBASE_NEWLINES_GETSETDEF -# define _IO__TEXTIOBASE_NEWLINES_GETSETDEF {"newlines", (getter)_io__TextIOBase_newlines_get, (setter)_io__TextIOBase_newlines_set, _io__TextIOBase_newlines_DOCSTR}, -#else -# define _IO__TEXTIOBASE_NEWLINES_GETSETDEF {"newlines", (getter)_io__TextIOBase_newlines_get, NULL, _io__TextIOBase_newlines_DOCSTR}, -#endif static PyObject * _io__TextIOBase_newlines_get_impl(PyObject *self); @@ -267,20 +196,6 @@ PyDoc_STRVAR(_io__TextIOBase_errors__doc__, "The error setting of the decoder or encoder.\n" "\n" "Subclasses should override."); -#if defined(_io__TextIOBase_errors_DOCSTR) -# undef _io__TextIOBase_errors_DOCSTR -#endif -#define _io__TextIOBase_errors_DOCSTR _io__TextIOBase_errors__doc__ - -#if !defined(_io__TextIOBase_errors_DOCSTR) -# define _io__TextIOBase_errors_DOCSTR NULL -#endif -#if defined(_IO__TEXTIOBASE_ERRORS_GETSETDEF) -# undef _IO__TEXTIOBASE_ERRORS_GETSETDEF -# define _IO__TEXTIOBASE_ERRORS_GETSETDEF {"errors", (getter)_io__TextIOBase_errors_get, (setter)_io__TextIOBase_errors_set, _io__TextIOBase_errors_DOCSTR}, -#else -# define _IO__TEXTIOBASE_ERRORS_GETSETDEF {"errors", (getter)_io__TextIOBase_errors_get, NULL, _io__TextIOBase_errors_DOCSTR}, -#endif static PyObject * _io__TextIOBase_errors_get_impl(PyObject *self); @@ -310,7 +225,8 @@ _io_IncrementalNewlineDecoder___init___impl(nldecoder_object *self, PyObject *errors); static int -_io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject *kwargs) +_io_IncrementalNewlineDecoder___init___helper(PyObject *self, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { int return_value = -1; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -342,13 +258,12 @@ _io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject #undef KWTUPLE PyObject *argsbuf[3]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2; + Py_ssize_t noptargs = nargs + nkw - 2; PyObject *decoder; int translate; PyObject *errors = NULL; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 2, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -369,6 +284,72 @@ _io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject return return_value; } +static int +_io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject *kwargs) +{ + return _io_IncrementalNewlineDecoder___init___helper(self, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +_io_IncrementalNewlineDecoder_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *self; + int _result; + PyObject *decoder; + int translate; + PyObject *errors = NULL; + + assert(_PyType_CAST(type)->tp_init == _io_IncrementalNewlineDecoder___init__); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs < 2 || nargs > 3) { + self = _PyType_CAST(type)->tp_new(_PyType_CAST(type), + (PyObject *)&_Py_SINGLETON(tuple_empty), NULL); + if (self == NULL) { + return NULL; + } + _result = _io_IncrementalNewlineDecoder___init___helper(self, args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + if (_result != 0) { + Py_DECREF(self); + return NULL; + } + return self; + } + decoder = args[0]; + translate = PyObject_IsTrue(args[1]); + if (translate < 0) { + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + errors = args[2]; +skip_optional: + self = _PyType_CAST(type)->tp_new(_PyType_CAST(type), + (PyObject *)&_Py_SINGLETON(tuple_empty), NULL); + if (self == NULL) { + goto exit; + } + _result = _io_IncrementalNewlineDecoder___init___impl((nldecoder_object *)self, decoder, translate, errors); + if (_result != 0) { + Py_DECREF(self); + goto exit; + } + return_value = self; + +exit: + return return_value; +} + PyDoc_STRVAR(_io_IncrementalNewlineDecoder_decode__doc__, "decode($self, /, input, final=False)\n" "--\n" @@ -509,6 +490,15 @@ _io_IncrementalNewlineDecoder_reset(PyObject *self, PyObject *Py_UNUSED(ignored) return return_value; } +static PyObject * +_io_IncrementalNewlineDecoder_newlines_get_impl(nldecoder_object *self); + +static PyObject * +_io_IncrementalNewlineDecoder_newlines_get(PyObject *self, void *Py_UNUSED(context)) +{ + return _io_IncrementalNewlineDecoder_newlines_get_impl((nldecoder_object *)self); +} + PyDoc_STRVAR(_io_TextIOWrapper___init____doc__, "TextIOWrapper(buffer, encoding=None, errors=None, newline=None,\n" " line_buffering=False, write_through=False)\n" @@ -517,7 +507,10 @@ PyDoc_STRVAR(_io_TextIOWrapper___init____doc__, "Character and line based layer over a BufferedIOBase object, buffer.\n" "\n" "encoding gives the name of the encoding that the stream will be\n" -"decoded or encoded with. It defaults to locale.getencoding().\n" +"decoded or encoded with. It defaults to UTF-8; if UTF-8 Mode is\n" +"disabled, the encoding returned by locale.getencoding() is used\n" +"instead. See the codecs module for the list of supported\n" +"encodings.\n" "\n" "errors determines the strictness of encoding and decoding (see\n" "help(codecs.Codec) or the documentation for codecs.register) and\n" @@ -605,15 +598,10 @@ _io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs) encoding = NULL; } else if (PyUnicode_Check(fastargs[1])) { - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(fastargs[1]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("TextIOWrapper", "argument 'encoding'", "str or None", fastargs[1]); @@ -634,15 +622,10 @@ _io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs) newline = NULL; } else if (PyUnicode_Check(fastargs[3])) { - Py_ssize_t newline_length; - newline = PyUnicode_AsUTF8AndSize(fastargs[3], &newline_length); + newline = _PyUnicode_AsUTF8NoNUL(fastargs[3]); if (newline == NULL) { goto exit; } - if (strlen(newline) != (size_t)newline_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("TextIOWrapper", "argument 'newline'", "str or None", fastargs[3]); @@ -1182,15 +1165,20 @@ _io_TextIOWrapper_close(PyObject *self, PyObject *Py_UNUSED(ignored)) return return_value; } -#if !defined(_io_TextIOWrapper_name_DOCSTR) -# define _io_TextIOWrapper_name_DOCSTR NULL -#endif -#if defined(_IO_TEXTIOWRAPPER_NAME_GETSETDEF) -# undef _IO_TEXTIOWRAPPER_NAME_GETSETDEF -# define _IO_TEXTIOWRAPPER_NAME_GETSETDEF {"name", (getter)_io_TextIOWrapper_name_get, (setter)_io_TextIOWrapper_name_set, _io_TextIOWrapper_name_DOCSTR}, -#else -# define _IO_TEXTIOWRAPPER_NAME_GETSETDEF {"name", (getter)_io_TextIOWrapper_name_get, NULL, _io_TextIOWrapper_name_DOCSTR}, -#endif +static PyObject * +textiowrapper_iternext_impl(textio *self); + +static PyObject * +textiowrapper_iternext(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = textiowrapper_iternext_impl((textio *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} static PyObject * _io_TextIOWrapper_name_get_impl(textio *self); @@ -1207,16 +1195,6 @@ _io_TextIOWrapper_name_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_io_TextIOWrapper_closed_DOCSTR) -# define _io_TextIOWrapper_closed_DOCSTR NULL -#endif -#if defined(_IO_TEXTIOWRAPPER_CLOSED_GETSETDEF) -# undef _IO_TEXTIOWRAPPER_CLOSED_GETSETDEF -# define _IO_TEXTIOWRAPPER_CLOSED_GETSETDEF {"closed", (getter)_io_TextIOWrapper_closed_get, (setter)_io_TextIOWrapper_closed_set, _io_TextIOWrapper_closed_DOCSTR}, -#else -# define _IO_TEXTIOWRAPPER_CLOSED_GETSETDEF {"closed", (getter)_io_TextIOWrapper_closed_get, NULL, _io_TextIOWrapper_closed_DOCSTR}, -#endif - static PyObject * _io_TextIOWrapper_closed_get_impl(textio *self); @@ -1232,16 +1210,6 @@ _io_TextIOWrapper_closed_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_io_TextIOWrapper_newlines_DOCSTR) -# define _io_TextIOWrapper_newlines_DOCSTR NULL -#endif -#if defined(_IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF) -# undef _IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF -# define _IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF {"newlines", (getter)_io_TextIOWrapper_newlines_get, (setter)_io_TextIOWrapper_newlines_set, _io_TextIOWrapper_newlines_DOCSTR}, -#else -# define _IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF {"newlines", (getter)_io_TextIOWrapper_newlines_get, NULL, _io_TextIOWrapper_newlines_DOCSTR}, -#endif - static PyObject * _io_TextIOWrapper_newlines_get_impl(textio *self); @@ -1257,16 +1225,6 @@ _io_TextIOWrapper_newlines_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_io_TextIOWrapper_errors_DOCSTR) -# define _io_TextIOWrapper_errors_DOCSTR NULL -#endif -#if defined(_IO_TEXTIOWRAPPER_ERRORS_GETSETDEF) -# undef _IO_TEXTIOWRAPPER_ERRORS_GETSETDEF -# define _IO_TEXTIOWRAPPER_ERRORS_GETSETDEF {"errors", (getter)_io_TextIOWrapper_errors_get, (setter)_io_TextIOWrapper_errors_set, _io_TextIOWrapper_errors_DOCSTR}, -#else -# define _IO_TEXTIOWRAPPER_ERRORS_GETSETDEF {"errors", (getter)_io_TextIOWrapper_errors_get, NULL, _io_TextIOWrapper_errors_DOCSTR}, -#endif - static PyObject * _io_TextIOWrapper_errors_get_impl(textio *self); @@ -1282,53 +1240,94 @@ _io_TextIOWrapper_errors_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_io_TextIOWrapper__CHUNK_SIZE_DOCSTR) -# define _io_TextIOWrapper__CHUNK_SIZE_DOCSTR NULL -#endif -#if defined(_IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF) -# undef _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF -# define _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF {"_CHUNK_SIZE", (getter)_io_TextIOWrapper__CHUNK_SIZE_get, (setter)_io_TextIOWrapper__CHUNK_SIZE_set, _io_TextIOWrapper__CHUNK_SIZE_DOCSTR}, -#else -# define _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF {"_CHUNK_SIZE", (getter)_io_TextIOWrapper__CHUNK_SIZE_get, NULL, _io_TextIOWrapper__CHUNK_SIZE_DOCSTR}, -#endif - -static PyObject * +static Py_ssize_t _io_TextIOWrapper__CHUNK_SIZE_get_impl(textio *self); static PyObject * _io_TextIOWrapper__CHUNK_SIZE_get(PyObject *self, void *Py_UNUSED(context)) { PyObject *return_value = NULL; + Py_ssize_t _return_value; Py_BEGIN_CRITICAL_SECTION(self); - return_value = _io_TextIOWrapper__CHUNK_SIZE_get_impl((textio *)self); + _return_value = _io_TextIOWrapper__CHUNK_SIZE_get_impl((textio *)self); Py_END_CRITICAL_SECTION(); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyLong_FromSsize_t(_return_value); +exit: return return_value; } -#if !defined(_io_TextIOWrapper__CHUNK_SIZE_DOCSTR) -# define _io_TextIOWrapper__CHUNK_SIZE_DOCSTR NULL -#endif -#if defined(_IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF) -# undef _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF -# define _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF {"_CHUNK_SIZE", (getter)_io_TextIOWrapper__CHUNK_SIZE_get, (setter)_io_TextIOWrapper__CHUNK_SIZE_set, _io_TextIOWrapper__CHUNK_SIZE_DOCSTR}, -#else -# define _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF {"_CHUNK_SIZE", NULL, (setter)_io_TextIOWrapper__CHUNK_SIZE_set, NULL}, -#endif - static int -_io_TextIOWrapper__CHUNK_SIZE_set_impl(textio *self, PyObject *value); +_io_TextIOWrapper__CHUNK_SIZE_set_impl(textio *self, Py_ssize_t value); static int -_io_TextIOWrapper__CHUNK_SIZE_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_io_TextIOWrapper__CHUNK_SIZE_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + Py_ssize_t value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute '_CHUNK_SIZE' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(arg); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + value = ival; + } Py_BEGIN_CRITICAL_SECTION(self); return_value = _io_TextIOWrapper__CHUNK_SIZE_set_impl((textio *)self, value); Py_END_CRITICAL_SECTION(); +exit: return return_value; } -/*[clinic end generated code: output=8c571c9dba87d2b1 input=a9049054013a1b77]*/ + +static PyObject * +_io_TextIOWrapper_buffer_get_impl(textio *self); + +static PyObject * +_io_TextIOWrapper_buffer_get(PyObject *self, void *Py_UNUSED(context)) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _io_TextIOWrapper_buffer_get_impl((textio *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} +#define _IO__TEXTIOBASE_ENCODING_GETSETDEF {"encoding", (getter)_io__TextIOBase_encoding_get, (setter)NULL, _io__TextIOBase_encoding__doc__}, + +#define _IO__TEXTIOBASE_NEWLINES_GETSETDEF {"newlines", (getter)_io__TextIOBase_newlines_get, (setter)NULL, _io__TextIOBase_newlines__doc__}, + +#define _IO__TEXTIOBASE_ERRORS_GETSETDEF {"errors", (getter)_io__TextIOBase_errors_get, (setter)NULL, _io__TextIOBase_errors__doc__}, + +#define _IO_INCREMENTALNEWLINEDECODER_NEWLINES_GETSETDEF {"newlines", (getter)_io_IncrementalNewlineDecoder_newlines_get, (setter)NULL, NULL}, + +#define _IO_TEXTIOWRAPPER_NAME_GETSETDEF {"name", (getter)_io_TextIOWrapper_name_get, (setter)NULL, NULL}, + +#define _IO_TEXTIOWRAPPER_CLOSED_GETSETDEF {"closed", (getter)_io_TextIOWrapper_closed_get, (setter)NULL, NULL}, + +#define _IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF {"newlines", (getter)_io_TextIOWrapper_newlines_get, (setter)NULL, NULL}, + +#define _IO_TEXTIOWRAPPER_ERRORS_GETSETDEF {"errors", (getter)_io_TextIOWrapper_errors_get, (setter)NULL, NULL}, + +#define _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF {"_CHUNK_SIZE", (getter)_io_TextIOWrapper__CHUNK_SIZE_get, (setter)_io_TextIOWrapper__CHUNK_SIZE_set, NULL}, + +#define _IO_TEXTIOWRAPPER_BUFFER_GETSETDEF {"buffer", (getter)_io_TextIOWrapper_buffer_get, (setter)NULL, NULL}, + +/*[clinic end generated code: output=d96cd0f7c06f36f5 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/winconsoleio.c.h b/Modules/_io/clinic/winconsoleio.c.h index bd8073cd0af3f64..76baeb79e68cd0b 100644 --- a/Modules/_io/clinic/winconsoleio.c.h +++ b/Modules/_io/clinic/winconsoleio.c.h @@ -8,6 +8,7 @@ preserve #endif #include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() #if defined(HAVE_WINDOWS_CONSOLE_IO) @@ -109,15 +110,10 @@ _io__WindowsConsoleIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("_WindowsConsoleIO", "argument 'mode'", "str", fastargs[1]); goto exit; } - Py_ssize_t mode_length; - mode = PyUnicode_AsUTF8AndSize(fastargs[1], &mode_length); + mode = _PyUnicode_AsUTF8NoNUL(fastargs[1]); if (mode == NULL) { goto exit; } - if (strlen(mode) != (size_t)mode_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_pos; } @@ -226,25 +222,12 @@ static PyObject * _io__WindowsConsoleIO_readinto(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "readinto", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; Py_buffer buffer = {NULL, NULL}; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("readinto", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("readinto", nargs, 1, 1)) { goto exit; } if (PyObject_GetBuffer(args[0], &buffer, PyBUF_WRITABLE) < 0) { @@ -311,34 +294,21 @@ static PyObject * _io__WindowsConsoleIO_read(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "read", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; Py_ssize_t size = -1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("read", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("read", nargs, 0, 1)) { goto exit; } if (nargs < 1) { - goto skip_optional_posonly; + goto skip_optional; } if (!_Py_convert_optional_to_ssize_t(args[0], &size)) { goto exit; } -skip_optional_posonly: +skip_optional: return_value = _io__WindowsConsoleIO_read_impl((winconsoleio *)self, cls, size); exit: @@ -369,25 +339,12 @@ static PyObject * _io__WindowsConsoleIO_write(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "write", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; Py_buffer b = {NULL, NULL}; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("write", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("write", nargs, 1, 1)) { goto exit; } if (PyObject_GetBuffer(args[0], &b, PyBUF_SIMPLE) != 0) { @@ -428,6 +385,92 @@ _io__WindowsConsoleIO_isatty(PyObject *self, PyObject *Py_UNUSED(ignored)) #endif /* defined(HAVE_WINDOWS_CONSOLE_IO) */ +#if defined(HAVE_WINDOWS_CONSOLE_IO) + +PyDoc_STRVAR(_io__WindowsConsoleIO_closed__doc__, +"True if the file is closed."); +#if defined(_IO__WINDOWSCONSOLEIO_CLOSED_DOCSTR) +# undef _IO__WINDOWSCONSOLEIO_CLOSED_DOCSTR +#endif +#define _IO__WINDOWSCONSOLEIO_CLOSED_DOCSTR _io__WindowsConsoleIO_closed__doc__ + +#define _IO__WINDOWSCONSOLEIO_CLOSED_GETTER _io__WindowsConsoleIO_closed_get + +static int +_io__WindowsConsoleIO_closed_get_impl(winconsoleio *self); + +static PyObject * +_io__WindowsConsoleIO_closed_get(PyObject *self, void *Py_UNUSED(context)) +{ + PyObject *return_value = NULL; + int _return_value; + + _return_value = _io__WindowsConsoleIO_closed_get_impl((winconsoleio *)self); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_WINDOWS_CONSOLE_IO) */ + +#if defined(HAVE_WINDOWS_CONSOLE_IO) + +PyDoc_STRVAR(_io__WindowsConsoleIO_closefd__doc__, +"True if the file descriptor will be closed by close()."); +#if defined(_IO__WINDOWSCONSOLEIO_CLOSEFD_DOCSTR) +# undef _IO__WINDOWSCONSOLEIO_CLOSEFD_DOCSTR +#endif +#define _IO__WINDOWSCONSOLEIO_CLOSEFD_DOCSTR _io__WindowsConsoleIO_closefd__doc__ + +#define _IO__WINDOWSCONSOLEIO_CLOSEFD_GETTER _io__WindowsConsoleIO_closefd_get + +static int +_io__WindowsConsoleIO_closefd_get_impl(winconsoleio *self); + +static PyObject * +_io__WindowsConsoleIO_closefd_get(PyObject *self, void *Py_UNUSED(context)) +{ + PyObject *return_value = NULL; + int _return_value; + + _return_value = _io__WindowsConsoleIO_closefd_get_impl((winconsoleio *)self); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_WINDOWS_CONSOLE_IO) */ + +#if defined(HAVE_WINDOWS_CONSOLE_IO) + +PyDoc_STRVAR(_io__WindowsConsoleIO_mode__doc__, +"String giving the file mode."); +#if defined(_IO__WINDOWSCONSOLEIO_MODE_DOCSTR) +# undef _IO__WINDOWSCONSOLEIO_MODE_DOCSTR +#endif +#define _IO__WINDOWSCONSOLEIO_MODE_DOCSTR _io__WindowsConsoleIO_mode__doc__ + +#define _IO__WINDOWSCONSOLEIO_MODE_GETTER _io__WindowsConsoleIO_mode_get + +static PyObject * +_io__WindowsConsoleIO_mode_get_impl(winconsoleio *self); + +static PyObject * +_io__WindowsConsoleIO_mode_get(PyObject *self, void *Py_UNUSED(context)) +{ + return _io__WindowsConsoleIO_mode_get_impl((winconsoleio *)self); +} + +#endif /* defined(HAVE_WINDOWS_CONSOLE_IO) */ + #ifndef _IO__WINDOWSCONSOLEIO_CLOSE_METHODDEF #define _IO__WINDOWSCONSOLEIO_CLOSE_METHODDEF #endif /* !defined(_IO__WINDOWSCONSOLEIO_CLOSE_METHODDEF) */ @@ -463,4 +506,49 @@ _io__WindowsConsoleIO_isatty(PyObject *self, PyObject *Py_UNUSED(ignored)) #ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF #define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF #endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */ -/*[clinic end generated code: output=dfe49dd71f4f4b1d input=a9049054013a1b77]*/ +#if defined(_IO__WINDOWSCONSOLEIO_CLOSED_GETTER) || defined(_IO__WINDOWSCONSOLEIO_CLOSED_SETTER) +# if !defined(_IO__WINDOWSCONSOLEIO_CLOSED_GETTER) +# define _IO__WINDOWSCONSOLEIO_CLOSED_GETTER NULL +# endif +# if !defined(_IO__WINDOWSCONSOLEIO_CLOSED_SETTER) +# define _IO__WINDOWSCONSOLEIO_CLOSED_SETTER NULL +# endif +# if !defined(_IO__WINDOWSCONSOLEIO_CLOSED_DOCSTR) +# define _IO__WINDOWSCONSOLEIO_CLOSED_DOCSTR NULL +# endif +# define _IO__WINDOWSCONSOLEIO_CLOSED_GETSETDEF {"closed", (getter)_IO__WINDOWSCONSOLEIO_CLOSED_GETTER, (setter)_IO__WINDOWSCONSOLEIO_CLOSED_SETTER, _IO__WINDOWSCONSOLEIO_CLOSED_DOCSTR}, +#else +# define _IO__WINDOWSCONSOLEIO_CLOSED_GETSETDEF +#endif + +#if defined(_IO__WINDOWSCONSOLEIO_CLOSEFD_GETTER) || defined(_IO__WINDOWSCONSOLEIO_CLOSEFD_SETTER) +# if !defined(_IO__WINDOWSCONSOLEIO_CLOSEFD_GETTER) +# define _IO__WINDOWSCONSOLEIO_CLOSEFD_GETTER NULL +# endif +# if !defined(_IO__WINDOWSCONSOLEIO_CLOSEFD_SETTER) +# define _IO__WINDOWSCONSOLEIO_CLOSEFD_SETTER NULL +# endif +# if !defined(_IO__WINDOWSCONSOLEIO_CLOSEFD_DOCSTR) +# define _IO__WINDOWSCONSOLEIO_CLOSEFD_DOCSTR NULL +# endif +# define _IO__WINDOWSCONSOLEIO_CLOSEFD_GETSETDEF {"closefd", (getter)_IO__WINDOWSCONSOLEIO_CLOSEFD_GETTER, (setter)_IO__WINDOWSCONSOLEIO_CLOSEFD_SETTER, _IO__WINDOWSCONSOLEIO_CLOSEFD_DOCSTR}, +#else +# define _IO__WINDOWSCONSOLEIO_CLOSEFD_GETSETDEF +#endif + +#if defined(_IO__WINDOWSCONSOLEIO_MODE_GETTER) || defined(_IO__WINDOWSCONSOLEIO_MODE_SETTER) +# if !defined(_IO__WINDOWSCONSOLEIO_MODE_GETTER) +# define _IO__WINDOWSCONSOLEIO_MODE_GETTER NULL +# endif +# if !defined(_IO__WINDOWSCONSOLEIO_MODE_SETTER) +# define _IO__WINDOWSCONSOLEIO_MODE_SETTER NULL +# endif +# if !defined(_IO__WINDOWSCONSOLEIO_MODE_DOCSTR) +# define _IO__WINDOWSCONSOLEIO_MODE_DOCSTR NULL +# endif +# define _IO__WINDOWSCONSOLEIO_MODE_GETSETDEF {"mode", (getter)_IO__WINDOWSCONSOLEIO_MODE_GETTER, (setter)_IO__WINDOWSCONSOLEIO_MODE_SETTER, _IO__WINDOWSCONSOLEIO_MODE_DOCSTR}, +#else +# define _IO__WINDOWSCONSOLEIO_MODE_GETSETDEF +#endif + +/*[clinic end generated code: output=7c7499116eefd498 input=a9049054013a1b77]*/ diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index 3aeb30dfe24a357..a954bc5cd407d27 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -1,10 +1,10 @@ /* Author: Daniel Stutzbach */ #include "Python.h" +#include "pycore_abstract.h" // _PyIndex_Check() #include "pycore_fileutils.h" // _Py_BEGIN_SUPPRESS_IPH #include "pycore_object.h" // _PyObject_GC_UNTRACK() #include "pycore_pyerrors.h" // _PyErr_ChainExceptions1() -#include "pycore_weakref.h" // FT_CLEAR_WEAKREFS() #include // bool #ifdef HAVE_UNISTD_H @@ -80,8 +80,6 @@ typedef struct { modified outside of the fileio object / Python (ex. gh-90102, GH-121941, gh-109523). */ struct _Py_stat_struct *stat_atopen; - PyObject *weakreflist; - PyObject *dict; } fileio; #define PyFileIO_Check(state, op) (PyObject_TypeCheck((op), state->PyFileIO_Type)) @@ -99,10 +97,17 @@ _PyFileIO_closed(PyObject *self) /* Because this can call arbitrary code, it shouldn't be called when the refcount is 0 (that is, not directly from tp_dealloc unless the refcount has been temporarily re-incremented). */ +/*[clinic input] +_io.FileIO._dealloc_warn + + source: object + / +[clinic start generated code]*/ + static PyObject * -fileio_dealloc_warn(PyObject *op, PyObject *source) +_io_FileIO__dealloc_warn_impl(fileio *self, PyObject *source) +/*[clinic end generated code: output=c7b7d122decd6575 input=3ea7e1cc0685edc2]*/ { - fileio *self = PyFileIO_CAST(op); if (self->fd >= 0 && self->closefd) { PyObject *exc = PyErr_GetRaisedException(); if (PyErr_ResourceWarning(source, 1, "unclosed file %R", source)) { @@ -176,7 +181,7 @@ _io_FileIO_close_impl(fileio *self, PyTypeObject *cls) exc = PyErr_GetRaisedException(); } if (self->finalizing) { - PyObject *r = fileio_dealloc_warn((PyObject*)self, (PyObject *) self); + PyObject *r = _io_FileIO__dealloc_warn_impl(self, (PyObject *)self); if (r) { Py_DECREF(r); } @@ -213,7 +218,6 @@ fileio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) self->truncate = 0; self->stat_atopen = NULL; self->closefd = 1; - self->weakreflist = NULL; return (PyObject *) self; } @@ -293,14 +297,17 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode, return -1; } } - fd = PyLong_AsInt(nameobj); - if (fd < 0) { - if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ValueError, - "negative file descriptor"); - return -1; + if (_PyIndex_Check(nameobj)) { + fd = PyLong_AsInt(nameobj); + if (fd < 0) { + if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ValueError, + "negative file descriptor"); + return -1; + } + /* Failed to convert; try other paths. */ + PyErr_Clear(); } - PyErr_Clear(); } if (fd < 0) { @@ -551,15 +558,13 @@ fileio_traverse(PyObject *op, visitproc visit, void *arg) { fileio *self = PyFileIO_CAST(op); Py_VISIT(Py_TYPE(self)); - Py_VISIT(self->dict); - return 0; + return PyObject_VisitManagedDict(op, visit, arg); } static int fileio_clear(PyObject *op) { - fileio *self = PyFileIO_CAST(op); - Py_CLEAR(self->dict); + PyObject_ClearManagedDict(op); return 0; } @@ -577,7 +582,7 @@ fileio_dealloc(PyObject *op) PyMem_Free(self->stat_atopen); self->stat_atopen = NULL; } - FT_CLEAR_WEAKREFS(op, self->weakreflist); + PyObject_ClearWeakRefs(op); (void)fileio_clear(op); PyTypeObject *tp = Py_TYPE(op); @@ -992,7 +997,14 @@ portable_lseek(fileio *self, PyObject *posobj, int whence, bool suppress_pipe_er Py_BEGIN_ALLOW_THREADS _Py_BEGIN_SUPPRESS_IPH #ifdef MS_WINDOWS - res = _lseeki64(fd, pos, whence); + HANDLE h = (HANDLE)_get_osfhandle(fd); + if (h != INVALID_HANDLE_VALUE && GetFileType(h) == FILE_TYPE_PIPE) { + res = -1; + errno = ESPIPE; + } + else { + res = _lseeki64(fd, pos, whence); + } #else res = lseek(fd, pos, whence); #endif @@ -1243,10 +1255,14 @@ _io_FileIO_isatty_impl(fileio *self) information. Use the stat result to skip a system call. Outside of that context TOCTOU issues (the fd could be arbitrarily modified by surrounding code). */ +/*[clinic input] +_io.FileIO._isatty_open_only +[clinic start generated code]*/ + static PyObject * -_io_FileIO_isatty_open_only(PyObject *op, PyObject *Py_UNUSED(dummy)) +_io_FileIO__isatty_open_only_impl(fileio *self) +/*[clinic end generated code: output=2b4689154d4b8b84 input=228767ff567cdfb6]*/ { - fileio *self = PyFileIO_CAST(op); if (self->stat_atopen != NULL && !S_ISCHR(self->stat_atopen->st_mode)) { Py_RETURN_FALSE; } @@ -1269,60 +1285,85 @@ static PyMethodDef fileio_methods[] = { _IO_FILEIO_WRITABLE_METHODDEF _IO_FILEIO_FILENO_METHODDEF _IO_FILEIO_ISATTY_METHODDEF - {"_isatty_open_only", _io_FileIO_isatty_open_only, METH_NOARGS}, - {"_dealloc_warn", fileio_dealloc_warn, METH_O, NULL}, + _IO_FILEIO__ISATTY_OPEN_ONLY_METHODDEF + _IO_FILEIO__DEALLOC_WARN_METHODDEF {"__getstate__", _PyIOBase_cannot_pickle, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; /* 'closed' and 'mode' are attributes for backwards compatibility reasons. */ -static PyObject * -fileio_get_closed(PyObject *op, void *closure) +/*[clinic input] +@getter +_io.FileIO.closed -> bool + +True if the file is closed. +[clinic start generated code]*/ + +static int +_io_FileIO_closed_get_impl(fileio *self) +/*[clinic end generated code: output=5052fd0688b475f2 input=6024cca6d484d9a2]*/ { - fileio *self = PyFileIO_CAST(op); - return PyBool_FromLong((long)(self->fd < 0)); + return self->fd < 0; } -static PyObject * -fileio_get_closefd(PyObject *op, void *closure) +/*[clinic input] +@getter +_io.FileIO.closefd -> bool + +True if the file descriptor will be closed by close(). +[clinic start generated code]*/ + +static int +_io_FileIO_closefd_get_impl(fileio *self) +/*[clinic end generated code: output=11963fca763399cc input=ed3d108a6f07ad5c]*/ { - fileio *self = PyFileIO_CAST(op); - return PyBool_FromLong((long)(self->closefd)); + return self->closefd; } +/*[clinic input] +@getter +_io.FileIO.mode + +String giving the file mode. +[clinic start generated code]*/ + static PyObject * -fileio_get_mode(PyObject *op, void *closure) +_io_FileIO_mode_get_impl(fileio *self) +/*[clinic end generated code: output=d5178215493e2e7e input=300a448fc9b2fea4]*/ { - fileio *self = PyFileIO_CAST(op); return PyUnicode_FromString(mode_string(self)); } -static PyObject * -fileio_get_blksize(PyObject *op, void *closure) +/*[clinic input] +@getter +_io.FileIO._blksize -> long + +Stat st_blksize if available. +[clinic start generated code]*/ + +static long +_io_FileIO__blksize_get_impl(fileio *self) +/*[clinic end generated code: output=e47eaf8cd6c0079f input=699d87d750798ccb]*/ { #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE - fileio *self = PyFileIO_CAST(op); if (self->stat_atopen != NULL && self->stat_atopen->st_blksize > 1) { - return PyLong_FromLong(self->stat_atopen->st_blksize); + return self->stat_atopen->st_blksize; } #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */ - return PyLong_FromLong(DEFAULT_BUFFER_SIZE); + return DEFAULT_BUFFER_SIZE; } static PyGetSetDef fileio_getsetlist[] = { - {"closed", fileio_get_closed, NULL, "True if the file is closed"}, - {"closefd", fileio_get_closefd, NULL, - "True if the file descriptor will be closed by close()."}, - {"mode", fileio_get_mode, NULL, "String giving the file mode"}, - {"_blksize", fileio_get_blksize, NULL, "Stat st_blksize if available"}, + _IO_FILEIO_CLOSED_GETSETDEF + _IO_FILEIO_CLOSEFD_GETSETDEF + _IO_FILEIO_MODE_GETSETDEF + _IO_FILEIO__BLKSIZE_GETSETDEF {NULL}, }; static PyMemberDef fileio_members[] = { {"_finalizing", Py_T_BOOL, offsetof(fileio, finalizing), 0}, - {"__weaklistoffset__", Py_T_PYSSIZET, offsetof(fileio, weakreflist), Py_READONLY}, - {"__dictoffset__", Py_T_PYSSIZET, offsetof(fileio, dict), Py_READONLY}, {NULL} }; diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c index 1253f124108bdbf..13de04d3b9ce772 100644 --- a/Modules/_io/iobase.c +++ b/Modules/_io/iobase.c @@ -14,7 +14,6 @@ #include "pycore_long.h" // _PyLong_GetOne() #include "pycore_object.h" // _PyType_HasFeature() #include "pycore_pyerrors.h" // _PyErr_ChainExceptions1() -#include "pycore_weakref.h" // FT_CLEAR_WEAKREFS() #include // offsetof() #include "_iomodule.h" @@ -33,8 +32,6 @@ class _io._RawIOBase "PyObject *" "clinic_state()->PyRawIOBase_Type" typedef struct { PyObject_HEAD - PyObject *dict; - PyObject *weakreflist; } iobase; #define iobase_CAST(op) ((iobase *)(op)) @@ -184,14 +181,18 @@ _io__IOBase_flush_impl(PyObject *self) return NULL; } -static PyObject * -iobase_closed_get(PyObject *self, void *context) +/*[clinic input] +@getter +_io._IOBase.closed -> bool + +True if the file is closed. +[clinic start generated code]*/ + +static int +_io__IOBase_closed_get_impl(PyObject *self) +/*[clinic end generated code: output=561af4ea236d16d9 input=e730fe4ccc4c096c]*/ { - int closed = iobase_is_closed(self); - if (closed < 0) { - return NULL; - } - return PyBool_FromLong(closed); + return iobase_is_closed(self); } static int @@ -225,25 +226,51 @@ _PyIOBase_check_closed(PyObject *self, PyObject *args) Py_RETURN_NONE; } +/*[clinic input] +_io._IOBase._checkClosed +[clinic start generated code]*/ + +static PyObject * +_io__IOBase__checkClosed_impl(PyObject *self) +/*[clinic end generated code: output=8fb8412185623f1a input=8d18d2e67b2270bb]*/ +{ + return _PyIOBase_check_closed(self, NULL); +} + +/*[clinic input] +_io._IOBase._checkSeekable +[clinic start generated code]*/ + static PyObject * -iobase_check_seekable(PyObject *self, PyObject *args) +_io__IOBase__checkSeekable_impl(PyObject *self) +/*[clinic end generated code: output=10f09b515a9f4c4f input=479853eded776b0e]*/ { _PyIO_State *state = find_io_state_by_def(Py_TYPE(self)); - return _PyIOBase_check_seekable(state, self, args); + return _PyIOBase_check_seekable(state, self, NULL); } +/*[clinic input] +_io._IOBase._checkReadable +[clinic start generated code]*/ + static PyObject * -iobase_check_readable(PyObject *self, PyObject *args) +_io__IOBase__checkReadable_impl(PyObject *self) +/*[clinic end generated code: output=33ccab8a7c4550fb input=63fbf50b36772323]*/ { _PyIO_State *state = find_io_state_by_def(Py_TYPE(self)); - return _PyIOBase_check_readable(state, self, args); + return _PyIOBase_check_readable(state, self, NULL); } +/*[clinic input] +_io._IOBase._checkWritable +[clinic start generated code]*/ + static PyObject * -iobase_check_writable(PyObject *self, PyObject *args) +_io__IOBase__checkWritable_impl(PyObject *self) +/*[clinic end generated code: output=8cfc6b4b2469d2a3 input=2758c7291cf5911e]*/ { _PyIO_State *state = find_io_state_by_def(Py_TYPE(self)); - return _PyIOBase_check_writable(state, self, args); + return _PyIOBase_check_writable(state, self, NULL); } PyObject * @@ -353,15 +380,13 @@ iobase_traverse(PyObject *op, visitproc visit, void *arg) { iobase *self = iobase_CAST(op); Py_VISIT(Py_TYPE(self)); - Py_VISIT(self->dict); - return 0; + return PyObject_VisitManagedDict(op, visit, arg); } static int iobase_clear(PyObject *op) { - iobase *self = iobase_CAST(op); - Py_CLEAR(self->dict); + PyObject_ClearManagedDict(op); return 0; } @@ -370,8 +395,8 @@ iobase_clear(PyObject *op) static void iobase_dealloc(PyObject *op) { - /* NOTE: since IOBaseObject has its own dict, Python-defined attributes - are still available here for close() to use. + /* NOTE: since the managed dict is only cleared below, Python-defined + attributes are still available here for close() to use. However, if the derived class declares a __slots__, those slots are already gone. */ @@ -386,8 +411,8 @@ iobase_dealloc(PyObject *op) } PyTypeObject *tp = Py_TYPE(self); _PyObject_GC_UNTRACK(self); - FT_CLEAR_WEAKREFS(op, self->weakreflist); - Py_CLEAR(self->dict); + PyObject_ClearWeakRefs(op); + PyObject_ClearManagedDict(op); tp->tp_free(self); Py_DECREF(tp); } @@ -495,8 +520,15 @@ _PyIOBase_check_writable(_PyIO_State *state, PyObject *self, PyObject *args) /* Context manager */ +/*[clinic input] +_io._IOBase.__enter__ + +Context management protocol. Returns the stream itself. +[clinic start generated code]*/ + static PyObject * -iobase_enter(PyObject *self, PyObject *args) +_io__IOBase___enter___impl(PyObject *self) +/*[clinic end generated code: output=d1e8e5b58bde3680 input=92e2d5e34ee714e5]*/ { if (iobase_check_closed(self)) return NULL; @@ -504,8 +536,16 @@ iobase_enter(PyObject *self, PyObject *args) return Py_NewRef(self); } +/*[clinic input] +_io._IOBase.__exit__ + *args: tuple + +Context management protocol. Calls close(). +[clinic start generated code]*/ + static PyObject * -iobase_exit(PyObject *self, PyObject *args) +_io__IOBase___exit___impl(PyObject *self, PyObject *args) +/*[clinic end generated code: output=452f3e33a34e2c5c input=fd3f46a32773a170]*/ { return PyObject_CallMethodNoArgs(self, &_Py_ID(close)); } @@ -571,20 +611,19 @@ _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit) { /* For backwards compatibility, a (slowish) readline(). */ - PyObject *peek, *buffer, *result; - Py_ssize_t old_size = -1; + PyObject *peek; if (PyObject_GetOptionalAttr(self, &_Py_ID(peek), &peek) < 0) { return NULL; } - buffer = PyByteArray_FromStringAndSize(NULL, 0); - if (buffer == NULL) { + PyBytesWriter *writer = PyBytesWriter_Create(0); + if (writer == NULL) { Py_XDECREF(peek); return NULL; } - while (limit < 0 || PyByteArray_GET_SIZE(buffer) < limit) { + while (limit < 0 || PyBytesWriter_GetSize(writer) < limit) { Py_ssize_t nreadahead = 1; PyObject *b; @@ -609,8 +648,9 @@ _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit) Py_ssize_t n = 0; const char *buf = PyBytes_AS_STRING(readahead); if (limit >= 0) { + Py_ssize_t remaining = limit - PyBytesWriter_GetSize(writer); do { - if (n >= PyBytes_GET_SIZE(readahead) || n >= limit) + if (n >= PyBytes_GET_SIZE(readahead) || n >= remaining) break; if (buf[n++] == '\n') break; @@ -650,28 +690,25 @@ _io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit) break; } - old_size = PyByteArray_GET_SIZE(buffer); - if (PyByteArray_Resize(buffer, old_size + PyBytes_GET_SIZE(b)) < 0) { + if (PyBytesWriter_WriteBytes(writer, + PyBytes_AS_STRING(b), + PyBytes_GET_SIZE(b)) < 0) { Py_DECREF(b); goto fail; } - memcpy(PyByteArray_AS_STRING(buffer) + old_size, - PyBytes_AS_STRING(b), PyBytes_GET_SIZE(b)); Py_DECREF(b); - if (PyByteArray_AS_STRING(buffer)[PyByteArray_GET_SIZE(buffer) - 1] == '\n') + char *data = PyBytesWriter_GetData(writer); + if (data[PyBytesWriter_GetSize(writer) - 1] == '\n') break; } - result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(buffer), - PyByteArray_GET_SIZE(buffer)); Py_XDECREF(peek); - Py_DECREF(buffer); - return result; + return PyBytesWriter_Finish(writer); fail: Py_XDECREF(peek); - Py_DECREF(buffer); + PyBytesWriter_Discard(writer); return NULL; } @@ -841,16 +878,16 @@ static PyMethodDef iobase_methods[] = { _IO__IOBASE_READABLE_METHODDEF _IO__IOBASE_WRITABLE_METHODDEF - {"_checkClosed", _PyIOBase_check_closed, METH_NOARGS}, - {"_checkSeekable", iobase_check_seekable, METH_NOARGS}, - {"_checkReadable", iobase_check_readable, METH_NOARGS}, - {"_checkWritable", iobase_check_writable, METH_NOARGS}, + _IO__IOBASE__CHECKCLOSED_METHODDEF + _IO__IOBASE__CHECKSEEKABLE_METHODDEF + _IO__IOBASE__CHECKREADABLE_METHODDEF + _IO__IOBASE__CHECKWRITABLE_METHODDEF _IO__IOBASE_FILENO_METHODDEF _IO__IOBASE_ISATTY_METHODDEF - {"__enter__", iobase_enter, METH_NOARGS}, - {"__exit__", iobase_exit, METH_VARARGS}, + _IO__IOBASE___ENTER___METHODDEF + _IO__IOBASE___EXIT___METHODDEF _IO__IOBASE_READLINE_METHODDEF _IO__IOBASE_READLINES_METHODDEF @@ -861,16 +898,10 @@ static PyMethodDef iobase_methods[] = { static PyGetSetDef iobase_getset[] = { {"__dict__", PyObject_GenericGetDict, NULL, NULL}, - {"closed", iobase_closed_get, NULL, NULL}, + _IO__IOBASE_CLOSED_GETSETDEF {NULL} }; -static struct PyMemberDef iobase_members[] = { - {"__weaklistoffset__", Py_T_PYSSIZET, offsetof(iobase, weakreflist), Py_READONLY}, - {"__dictoffset__", Py_T_PYSSIZET, offsetof(iobase, dict), Py_READONLY}, - {NULL}, -}; - static PyType_Slot iobase_slots[] = { {Py_tp_dealloc, iobase_dealloc}, @@ -880,7 +911,6 @@ static PyType_Slot iobase_slots[] = { {Py_tp_iter, iobase_iter}, {Py_tp_iternext, iobase_iternext}, {Py_tp_methods, iobase_methods}, - {Py_tp_members, iobase_members}, {Py_tp_getset, iobase_getset}, {Py_tp_finalize, iobase_finalize}, {0, NULL}, @@ -890,7 +920,8 @@ PyType_Spec _Py_iobase_spec = { .name = "_io._IOBase", .basicsize = sizeof(iobase), .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_IMMUTABLETYPE), + Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_MANAGED_DICT | + Py_TPFLAGS_MANAGED_WEAKREF), .slots = iobase_slots, }; @@ -1018,15 +1049,29 @@ _io__RawIOBase_readall_impl(PyObject *self) return PyBytesWriter_Finish(writer); } +/*[clinic input] +_io._RawIOBase.readinto + buffer: object + / +[clinic start generated code]*/ + static PyObject * -rawiobase_readinto(PyObject *self, PyObject *args) +_io__RawIOBase_readinto(PyObject *self, PyObject *buffer) +/*[clinic end generated code: output=081b8cdfaf3a40ff input=99d4bea2acd659c8]*/ { PyErr_SetNone(PyExc_NotImplementedError); return NULL; } +/*[clinic input] +_io._RawIOBase.write + buffer: object + / +[clinic start generated code]*/ + static PyObject * -rawiobase_write(PyObject *self, PyObject *args) +_io__RawIOBase_write(PyObject *self, PyObject *buffer) +/*[clinic end generated code: output=7add3f2c8715c3a8 input=e6a1534adb876fe2]*/ { PyErr_SetNone(PyExc_NotImplementedError); return NULL; @@ -1035,8 +1080,8 @@ rawiobase_write(PyObject *self, PyObject *args) static PyMethodDef rawiobase_methods[] = { _IO__RAWIOBASE_READ_METHODDEF _IO__RAWIOBASE_READALL_METHODDEF - {"readinto", rawiobase_readinto, METH_VARARGS}, - {"write", rawiobase_write, METH_VARARGS}, + _IO__RAWIOBASE_READINTO_METHODDEF + _IO__RAWIOBASE_WRITE_METHODDEF {NULL, NULL} }; diff --git a/Modules/_io/stringio.c b/Modules/_io/stringio.c index b8601383ad0a26f..a5687207d65e089 100644 --- a/Modules/_io/stringio.c +++ b/Modules/_io/stringio.c @@ -1,7 +1,8 @@ #include "Python.h" #include // offsetof() +#include "pycore_critical_section.h" // _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED() #include "pycore_object.h" -#include "pycore_weakref.h" // FT_CLEAR_WEAKREFS() +#include "pycore_unicodeobject.h" // _PyUnicode_ResizeCompact() #include "_iomodule.h" /* Implementation note: the buffer is always at least one character longer @@ -41,8 +42,6 @@ typedef struct { PyObject *readnl; PyObject *writenl; - PyObject *dict; - PyObject *weakreflist; _PyIO_State *module_state; } stringio; @@ -68,6 +67,20 @@ static int _io_StringIO___init__(PyObject *self, PyObject *args, PyObject *kwarg return NULL; \ } +#define CHECK_INITIALIZED_INT(self) \ + if (self->ok <= 0) { \ + PyErr_SetString(PyExc_ValueError, \ + "I/O operation on uninitialized object"); \ + return -1; \ + } + +#define CHECK_CLOSED_INT(self) \ + if (self->closed) { \ + PyErr_SetString(PyExc_ValueError, \ + "I/O operation on closed file"); \ + return -1; \ + } + #define ENSURE_REALIZED(self) \ if (realize(self) < 0) { \ return NULL; \ @@ -129,25 +142,52 @@ resize_buffer(stringio *self, size_t size) return -1; } +/* Shrink the buffer of the writer to its contents, so that the following + PyUnicodeWriter_Finish() has nothing to allocate and cannot fail. + If this fails, the writer is unchanged. */ +static int +shrink_writer(stringio *self) +{ + _PyUnicodeWriter *writer = (_PyUnicodeWriter *)self->writer; + if (writer->readonly || writer->buffer == NULL + || writer->pos == 0 || writer->pos == writer->size) + { + return 0; + } + PyObject *buffer = _PyUnicode_ResizeCompact(writer->buffer, writer->pos); + if (buffer == NULL) { + return -1; + } + writer->buffer = NULL; + _PyUnicodeWriter_SetBuffer(writer, buffer); + return 0; +} + static PyObject * make_intermediate(stringio *self) { - PyObject *intermediate = PyUnicodeWriter_Finish(self->writer); - self->writer = NULL; - self->state = STATE_REALIZED; - if (intermediate == NULL) + /* Create the new writer and shrink the old one first: if this fails, + the object keeps its contents. */ + PyUnicodeWriter *writer = PyUnicodeWriter_Create(0); + if (writer == NULL) return NULL; + if (shrink_writer(self) < 0) { + PyUnicodeWriter_Discard(writer); + return NULL; + } - self->writer = PyUnicodeWriter_Create(0); - if (self->writer == NULL) { - Py_DECREF(intermediate); + PyObject *intermediate = PyUnicodeWriter_Finish(self->writer); + self->writer = writer; + if (intermediate == NULL) { + /* The contents are lost, the new writer is empty. */ + self->string_size = 0; return NULL; } if (PyUnicodeWriter_WriteStr(self->writer, intermediate)) { Py_DECREF(intermediate); + self->string_size = 0; return NULL; } - self->state = STATE_ACCUMULATING; return intermediate; } @@ -160,23 +200,30 @@ realize(stringio *self) if (self->state == STATE_REALIZED) return 0; assert(self->state == STATE_ACCUMULATING); + + /* Allocate the internal buffer and shrink the writer first: if this + fails, the object stays in the accumulating state and keeps its + contents. */ + if (resize_buffer(self, self->string_size) < 0) + return -1; + if (shrink_writer(self) < 0) + return -1; self->state = STATE_REALIZED; intermediate = PyUnicodeWriter_Finish(self->writer); self->writer = NULL; - if (intermediate == NULL) + if (intermediate == NULL) { + /* The contents are lost, the internal buffer contains nothing. */ + self->string_size = 0; return -1; + } - /* Append the intermediate string to the internal buffer. - The length should be equal to the current cursor position. - */ + /* Copy the intermediate string to the internal buffer. */ len = PyUnicode_GET_LENGTH(intermediate); - if (resize_buffer(self, len) < 0) { - Py_DECREF(intermediate); - return -1; - } + assert(len == self->string_size); if (!PyUnicode_AsUCS4(intermediate, self->buf, len, 0)) { Py_DECREF(intermediate); + self->string_size = 0; return -1; } @@ -344,7 +391,9 @@ _io_StringIO_read_impl(stringio *self, Py_ssize_t size) /* Optimization for seek(0); read() */ if (self->state == STATE_ACCUMULATING && self->pos == 0 && size == n) { PyObject *result = make_intermediate(self); - self->pos = self->string_size; + if (result != NULL) { + self->pos = self->string_size; + } return result; } @@ -406,11 +455,18 @@ _io_StringIO_readline_impl(stringio *self, Py_ssize_t size) return _stringio_readline(self, size); } +/*[clinic input] +@critical_section +_io.StringIO.__next__ as stringio_iternext +[clinic start generated code]*/ + static PyObject * -stringio_iternext(PyObject *op) +stringio_iternext_impl(stringio *self) +/*[clinic end generated code: output=51eb3991b1c79c41 input=b6cf3e73fab6b42e]*/ { + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self); + PyObject *line; - stringio *self = stringio_CAST(op); CHECK_INITIALIZED(self); CHECK_CLOSED(self); @@ -422,7 +478,7 @@ stringio_iternext(PyObject *op) } else { /* XXX is subclassing StringIO really supported? */ - line = PyObject_CallMethodNoArgs(op, &_Py_ID(readline)); + line = PyObject_CallMethodNoArgs((PyObject *)self, &_Py_ID(readline)); if (line && !PyUnicode_Check(line)) { PyErr_Format(PyExc_OSError, "readline() should have returned a str object, " @@ -469,7 +525,7 @@ _io_StringIO_truncate_impl(stringio *self, PyObject *pos) size = self->pos; } else { - size = PyLong_AsLong(pos); + size = PyNumber_AsSsize_t(pos, PyExc_OverflowError); if (size == -1 && PyErr_Occurred()) { return NULL; } @@ -478,6 +534,9 @@ _io_StringIO_truncate_impl(stringio *self, PyObject *pos) "negative pos value %zd", size); return NULL; } + /* __index__ may have closed or reinitialized the stream. */ + CHECK_INITIALIZED(self); + CHECK_CLOSED(self); } if (size < self->string_size) { @@ -614,8 +673,7 @@ stringio_traverse(PyObject *op, visitproc visit, void *arg) Py_VISIT(self->readnl); Py_VISIT(self->writenl); Py_VISIT(self->decoder); - Py_VISIT(self->dict); - return 0; + return PyObject_VisitManagedDict(op, visit, arg); } static int @@ -625,7 +683,7 @@ stringio_clear(PyObject *op) Py_CLEAR(self->readnl); Py_CLEAR(self->writenl); Py_CLEAR(self->decoder); - Py_CLEAR(self->dict); + PyObject_ClearManagedDict(op); return 0; } @@ -642,7 +700,7 @@ stringio_dealloc(PyObject *op) } PyUnicodeWriter_Discard(self->writer); (void)stringio_clear(op); - FT_CLEAR_WEAKREFS(op, self->weakreflist); + PyObject_ClearWeakRefs(op); tp->tp_free(self); Py_DECREF(tp); } @@ -869,11 +927,16 @@ _io_StringIO___getstate___impl(stringio *self) if (initvalue == NULL) return NULL; - if (self->dict == NULL) { + if (_PyObject_IsInstanceDictEmpty((PyObject *)self)) { dict = Py_NewRef(Py_None); } else { - dict = PyDict_Copy(self->dict); + dict = PyObject_GenericGetDict((PyObject *)self, NULL); + if (dict == NULL) { + Py_DECREF(initvalue); + return NULL; + } + Py_SETREF(dict, PyDict_Copy(dict)); if (dict == NULL) { Py_DECREF(initvalue); return NULL; @@ -984,14 +1047,16 @@ _io_StringIO___setstate___impl(stringio *self, PyObject *state) Py_TYPE(dict)->tp_name); return NULL; } - if (self->dict) { - /* Alternatively, we could replace the internal dictionary - completely. However, it seems more practical to just update it. */ - if (PyDict_Update(self->dict, dict) < 0) - return NULL; + /* Alternatively, we could replace the internal dictionary + completely. However, it seems more practical to just update it. */ + PyObject *self_dict = PyObject_GenericGetDict((PyObject *)self, NULL); + if (self_dict == NULL) { + return NULL; } - else { - self->dict = Py_NewRef(dict); + int rc = PyDict_Update(self_dict, dict); + Py_DECREF(self_dict); + if (rc < 0) { + return NULL; } } @@ -1001,30 +1066,30 @@ _io_StringIO___setstate___impl(stringio *self, PyObject *state) /*[clinic input] @critical_section @getter -_io.StringIO.closed +_io.StringIO.closed -> bool [clinic start generated code]*/ -static PyObject * +static int _io_StringIO_closed_get_impl(stringio *self) -/*[clinic end generated code: output=531ddca7954331d6 input=178d2ef24395fd49]*/ +/*[clinic end generated code: output=754068c44422cafa input=ea05e89b945e721c]*/ { - CHECK_INITIALIZED(self); - return PyBool_FromLong(self->closed); + CHECK_INITIALIZED_INT(self); + return self->closed; } /*[clinic input] @critical_section @getter -_io.StringIO.line_buffering +_io.StringIO.line_buffering -> bool [clinic start generated code]*/ -static PyObject * +static int _io_StringIO_line_buffering_get_impl(stringio *self) -/*[clinic end generated code: output=360710e0112966ae input=6a7634e7f890745e]*/ +/*[clinic end generated code: output=56c0edde9001fb37 input=326f8b3bd1feb699]*/ { - CHECK_INITIALIZED(self); - CHECK_CLOSED(self); - Py_RETURN_FALSE; + CHECK_INITIALIZED_INT(self); + CHECK_CLOSED_INT(self); + return 0; } /*[clinic input] @@ -1077,12 +1142,6 @@ static PyGetSetDef stringio_getset[] = { {NULL} }; -static struct PyMemberDef stringio_members[] = { - {"__weaklistoffset__", Py_T_PYSSIZET, offsetof(stringio, weakreflist), Py_READONLY}, - {"__dictoffset__", Py_T_PYSSIZET, offsetof(stringio, dict), Py_READONLY}, - {NULL}, -}; - static PyType_Slot stringio_slots[] = { {Py_tp_dealloc, stringio_dealloc}, {Py_tp_doc, (void *)_io_StringIO___init____doc__}, @@ -1090,7 +1149,6 @@ static PyType_Slot stringio_slots[] = { {Py_tp_clear, stringio_clear}, {Py_tp_iternext, stringio_iternext}, {Py_tp_methods, stringio_methods}, - {Py_tp_members, stringio_members}, {Py_tp_getset, stringio_getset}, {Py_tp_init, _io_StringIO___init__}, {Py_tp_new, stringio_new}, diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 5b2a20a30c28cb2..049f999349f0d58 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -16,7 +16,6 @@ #include "pycore_pyerrors.h" // _PyErr_ChainExceptions1() #include "pycore_pystate.h" // _PyInterpreterState_GET() #include "pycore_unicodeobject.h" // _PyUnicode_AsASCIIString() -#include "pycore_weakref.h" // FT_CLEAR_WEAKREFS() #include "_iomodule.h" @@ -229,6 +228,7 @@ struct nldecoder_object { #define nldecoder_object_CAST(op) ((nldecoder_object *)(op)) /*[clinic input] +@vectorcall _io.IncrementalNewlineDecoder.__init__ decoder: object translate: bool @@ -248,7 +248,7 @@ static int _io_IncrementalNewlineDecoder___init___impl(nldecoder_object *self, PyObject *decoder, int translate, PyObject *errors) -/*[clinic end generated code: output=fbd04d443e764ec2 input=ed547aa257616b0e]*/ +/*[clinic end generated code: output=fbd04d443e764ec2 input=7fd0efad15bc0b69]*/ { if (errors == NULL) { @@ -336,8 +336,11 @@ _PyIncrementalNewlineDecoder_decode(PyObject *myself, /* decode input (with the eventual \r from a previous pass) */ if (self->decoder != Py_None) { - output = PyObject_CallMethodObjArgs(self->decoder, + /* The wrapper can be reinitialized by a decoding callback. */ + PyObject *decoder = Py_NewRef(self->decoder); + output = PyObject_CallMethodObjArgs(decoder, &_Py_ID(decode), input, final ? Py_True : Py_False, NULL); + Py_DECREF(decoder); } else { output = Py_NewRef(input); @@ -635,10 +638,15 @@ _io_IncrementalNewlineDecoder_reset_impl(nldecoder_object *self) Py_RETURN_NONE; } +/*[clinic input] +@getter +_io.IncrementalNewlineDecoder.newlines +[clinic start generated code]*/ + static PyObject * -incrementalnewlinedecoder_newlines_get(PyObject *op, void *Py_UNUSED(context)) +_io_IncrementalNewlineDecoder_newlines_get_impl(nldecoder_object *self) +/*[clinic end generated code: output=4370cf5202a83d08 input=040f9a26aef317a8]*/ { - nldecoder_object *self = nldecoder_object_CAST(op); CHECK_INITIALIZED_DECODER(self); switch (self->seennl) { @@ -723,8 +731,6 @@ struct textio /* Cache raw object if it's a FileIO object */ PyObject *raw; - PyObject *weakreflist; - PyObject *dict; _PyIO_State *state; }; @@ -753,10 +759,8 @@ buffer_access_safe(textio *self) return NULL; } - /* Returning a borrowed reference is safe since TextIOWrapper methods are - protected by critical sections. */ _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self); - return self->buffer; + return Py_NewRef(self->buffer); } static PyObject * @@ -767,7 +771,9 @@ buffer_getattr(textio *self, PyObject *attr_name) return NULL; } - return PyObject_GetAttr(buffer, attr_name); + PyObject *res = PyObject_GetAttr(buffer, attr_name); + Py_DECREF(buffer); + return res; } static PyObject * @@ -778,7 +784,9 @@ buffer_callmethod_noargs(textio *self, PyObject *name) return NULL; } - return PyObject_CallMethodNoArgs(buffer, name); + PyObject *res = PyObject_CallMethodNoArgs(buffer, name); + Py_DECREF(buffer); + return res; } static PyObject * @@ -789,7 +797,9 @@ buffer_callmethod_onearg(textio *self, PyObject *name, PyObject *arg) return NULL; } - return PyObject_CallMethodOneArg(buffer, name, arg); + PyObject *res = PyObject_CallMethodOneArg(buffer, name, arg); + Py_DECREF(buffer); + return res; } static void @@ -997,11 +1007,17 @@ _textiowrapper_decode(_PyIO_State *state, PyObject *decoder, PyObject *bytes, { PyObject *chars; + if (decoder == NULL) { + return _unsupported(state, "not readable"); + } + /* A codec callback may replace the wrapper's decoder. */ + Py_INCREF(decoder); if (Py_IS_TYPE(decoder, state->PyIncrementalNewlineDecoder_Type)) chars = _PyIncrementalNewlineDecoder_decode(decoder, bytes, eof); else chars = PyObject_CallMethodObjArgs(decoder, &_Py_ID(decode), bytes, eof ? Py_True : Py_False, NULL); + Py_DECREF(decoder); if (check_decoded(chars) < 0) // check_decoded already decreases refcount @@ -1135,7 +1151,10 @@ _io.TextIOWrapper.__init__ Character and line based layer over a BufferedIOBase object, buffer. encoding gives the name of the encoding that the stream will be -decoded or encoded with. It defaults to locale.getencoding(). +decoded or encoded with. It defaults to UTF-8; if UTF-8 Mode is +disabled, the encoding returned by locale.getencoding() is used +instead. See the codecs module for the list of supported +encodings. errors determines the strictness of encoding and decoding (see help(codecs.Codec) or the documentation for codecs.register) and @@ -1167,7 +1186,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer, const char *encoding, PyObject *errors, const char *newline, int line_buffering, int write_through) -/*[clinic end generated code: output=72267c0c01032ed2 input=0f077220214c40a4]*/ +/*[clinic end generated code: output=72267c0c01032ed2 input=4f0bee5a0b2302fd]*/ { PyObject *raw, *codec_info = NULL; PyObject *res; @@ -1524,7 +1543,7 @@ textiowrapper_clear(PyObject *op) Py_CLEAR(self->errors); Py_CLEAR(self->raw); - Py_CLEAR(self->dict); + PyObject_ClearManagedDict(op); return 0; } @@ -1538,7 +1557,7 @@ textiowrapper_dealloc(PyObject *op) return; self->ok = 0; _PyObject_GC_UNTRACK(self); - FT_CLEAR_WEAKREFS(op, self->weakreflist); + PyObject_ClearWeakRefs(op); (void)textiowrapper_clear(op); tp->tp_free(self); Py_DECREF(tp); @@ -1560,8 +1579,7 @@ textiowrapper_traverse(PyObject *op, visitproc visit, void *arg) Py_VISIT(self->errors); Py_VISIT(self->raw); - Py_VISIT(self->dict); - return 0; + return PyObject_VisitManagedDict(op, visit, arg); } static PyObject * @@ -1639,7 +1657,7 @@ _io_TextIOWrapper_detach_impl(textio *self) if (buffer == NULL) { return NULL; } - self->buffer = NULL; + Py_CLEAR(self->buffer); self->detached = 1; return buffer; } @@ -1671,17 +1689,17 @@ _textiowrapper_writeflush(textio *self) } else { assert(PyList_Check(pending)); - b = PyBytes_FromStringAndSize(NULL, self->pending_bytes_count); - if (b == NULL) { + PyBytesWriter *writer = PyBytesWriter_Create(self->pending_bytes_count); + if (writer == NULL) { return -1; } - char *buf = PyBytes_AsString(b); + char *buf = PyBytesWriter_GetData(writer); Py_ssize_t pos = 0; for (Py_ssize_t i = 0; i < PyList_GET_SIZE(pending); i++) { PyObject *obj = PyList_GET_ITEM(pending, i); - char *src; + const char *src; Py_ssize_t len; if (PyUnicode_Check(obj)) { assert(PyUnicode_IS_ASCII(obj)); @@ -1690,15 +1708,18 @@ _textiowrapper_writeflush(textio *self) } else { assert(PyBytes_Check(obj)); - if (PyBytes_AsStringAndSize(obj, &src, &len) < 0) { - Py_DECREF(b); - return -1; - } + src = PyBytes_AS_STRING(obj); + len = PyBytes_GET_SIZE(obj); } memcpy(buf + pos, src, len); pos += len; } assert(pos == self->pending_bytes_count); + + b = PyBytesWriter_Finish(writer); + if (b == NULL) { + return -1; + } } self->pending_bytes_count = 0; @@ -1718,84 +1739,27 @@ _textiowrapper_writeflush(textio *self) return 0; } -/*[clinic input] -@critical_section -_io.TextIOWrapper.write - text: unicode - / -[clinic start generated code]*/ - +/* Return borrowed Py_None on success, or NULL on error. */ static PyObject * -_io_TextIOWrapper_write_impl(textio *self, PyObject *text) -/*[clinic end generated code: output=d2deb0d50771fcec input=73ec95c5c4a3489c]*/ +textiowrapper_check_write(textio *self) { - PyObject *ret; - PyObject *b; - Py_ssize_t textlen; - int haslf = 0; - int needflush = 0, text_needflush = 0; - CHECK_ATTACHED(self); CHECK_CLOSED(self); if (self->encoder == NULL) { return _unsupported(self->state, "not writable"); } + return Py_None; +} - Py_INCREF(text); - - textlen = PyUnicode_GET_LENGTH(text); - - if ((self->writetranslate && self->writenl != NULL) || self->line_buffering) - if (PyUnicode_FindChar(text, '\n', 0, PyUnicode_GET_LENGTH(text), 1) != -1) - haslf = 1; - - if (haslf && self->writetranslate && self->writenl != NULL) { - PyObject *newtext = _PyObject_CallMethod(text, &_Py_ID(replace), - "ss", "\n", self->writenl); - Py_DECREF(text); - if (newtext == NULL) - return NULL; - text = newtext; - } - - if (self->write_through) - text_needflush = 1; - if (self->line_buffering && - (haslf || - PyUnicode_FindChar(text, '\r', 0, PyUnicode_GET_LENGTH(text), 1) != -1)) - needflush = 1; - - /* XXX What if we were just reading? */ - if (self->encodefunc != NULL) { - if (PyUnicode_IS_ASCII(text) && - // See bpo-43260 - PyUnicode_GET_LENGTH(text) <= self->chunk_size && - is_asciicompat_encoding(self->encodefunc)) { - b = Py_NewRef(text); - } - else { - b = (*self->encodefunc)((PyObject *) self, text); - } - self->encoding_start_of_stream = 0; - } - else { - b = PyObject_CallMethodOneArg(self->encoder, &_Py_ID(encode), text); - } - - Py_DECREF(text); - if (b == NULL) - return NULL; - if (b != text && !PyBytes_Check(b)) { - PyErr_Format(PyExc_TypeError, - "encoder should return a bytes object, not '%.200s'", - Py_TYPE(b)->tp_name); - Py_DECREF(b); - return NULL; - } - +/* Consume b, which is either bytes or an ASCII string. */ +static int +textiowrapper_write_bytes(textio *self, PyObject *b, + int needflush, int text_needflush) +{ Py_ssize_t bytes_len; - if (b == text) { + if (PyUnicode_Check(b)) { + assert(PyUnicode_IS_ASCII(b)); bytes_len = PyUnicode_GET_LENGTH(b); } else { @@ -1815,7 +1779,7 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text) while (self->pending_bytes != NULL) { if (_textiowrapper_writeflush(self) < 0) { Py_DECREF(b); - return NULL; + return -1; } } } @@ -1829,7 +1793,7 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text) PyObject *list = PyList_New(2); if (list == NULL) { Py_DECREF(b); - return NULL; + return -1; } // Since Python 3.12, allocating GC object won't trigger GC and release // GIL. See https://github.com/python/cpython/issues/97922 @@ -1841,7 +1805,7 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text) else { if (PyList_Append(self->pending_bytes, b) < 0) { Py_DECREF(b); - return NULL; + return -1; } Py_DECREF(b); } @@ -1855,13 +1819,18 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text) if (self->pending_bytes_count >= self->chunk_size || needflush || text_needflush) { if (_textiowrapper_writeflush(self) < 0) - return NULL; + return -1; } if (needflush) { PyObject *buffer = buffer_access_safe(self); - if (buffer == NULL || _PyFile_Flush(buffer) < 0) { - return NULL; + if (buffer == NULL) { + return -1; + } + int res = _PyFile_Flush(buffer); + Py_DECREF(buffer); + if (res < 0) { + return -1; } } @@ -1871,15 +1840,112 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text) } if (self->decoder) { - ret = PyObject_CallMethodNoArgs(self->decoder, &_Py_ID(reset)); + PyObject *ret = PyObject_CallMethodNoArgs(self->decoder, &_Py_ID(reset)); if (ret == NULL) - return NULL; + return -1; Py_DECREF(ret); } + return 0; +} + +static PyObject * +textiowrapper_write_text(textio *self, PyObject *text) +{ + PyObject *b; + Py_ssize_t textlen; + int haslf = 0; + int needflush = 0, text_needflush = 0; + + Py_INCREF(text); + + textlen = PyUnicode_GET_LENGTH(text); + + if ((self->writetranslate && self->writenl != NULL) || self->line_buffering) + if (PyUnicode_FindChar(text, '\n', 0, PyUnicode_GET_LENGTH(text), 1) != -1) + haslf = 1; + + if (haslf && self->writetranslate && self->writenl != NULL) { + PyObject *newtext = _PyObject_CallMethod(text, &_Py_ID(replace), + "ss", "\n", self->writenl); + Py_DECREF(text); + if (newtext == NULL) + return NULL; + if (!PyUnicode_Check(newtext)) { + PyErr_Format(PyExc_TypeError, + "replace() should return a str, not %T", newtext); + Py_DECREF(newtext); + return NULL; + } + /* replace() may have closed, detached or reinitialized the stream. */ + if (textiowrapper_check_write(self) == NULL) { + Py_DECREF(newtext); + return NULL; + } + text = newtext; + } + + if (self->write_through) + text_needflush = 1; + if (self->line_buffering && + (haslf || + PyUnicode_FindChar(text, '\r', 0, PyUnicode_GET_LENGTH(text), 1) != -1)) + needflush = 1; + + /* XXX What if we were just reading? */ + if (self->encodefunc != NULL) { + if (PyUnicode_IS_ASCII(text) && + // See bpo-43260 + PyUnicode_GET_LENGTH(text) <= self->chunk_size && + is_asciicompat_encoding(self->encodefunc)) { + b = Py_NewRef(text); + } + else { + b = (*self->encodefunc)((PyObject *) self, text); + } + self->encoding_start_of_stream = 0; + } + else { + /* A codec callback may reconfigure the stream. */ + PyObject *encoder = Py_NewRef(self->encoder); + b = PyObject_CallMethodOneArg(encoder, &_Py_ID(encode), text); + Py_DECREF(encoder); + } + + Py_DECREF(text); + if (b == NULL) + return NULL; + if (b != text && !PyBytes_Check(b)) { + PyErr_Format(PyExc_TypeError, + "encoder should return a bytes object, not '%.200s'", + Py_TYPE(b)->tp_name); + Py_DECREF(b); + return NULL; + } + + if (textiowrapper_write_bytes(self, b, needflush, text_needflush) < 0) { + return NULL; + } return PyLong_FromSsize_t(textlen); } +/*[clinic input] +@critical_section +_io.TextIOWrapper.write + text: unicode + / +[clinic start generated code]*/ + +static PyObject * +_io_TextIOWrapper_write_impl(textio *self, PyObject *text) +/*[clinic end generated code: output=d2deb0d50771fcec input=73ec95c5c4a3489c]*/ +{ + if (textiowrapper_check_write(self) == NULL) { + return NULL; + } + return textiowrapper_write_text(self, text); +} + /* Steal a reference to chars and store it in the decoded_char buffer; */ static void @@ -2015,8 +2081,9 @@ textiowrapper_read_chunk(textio *self, Py_ssize_t size_hint) if (decoded_chars == NULL) goto fail; - textiowrapper_set_decoded_chars(self, decoded_chars); + /* The old chunk's finalizer can clear the new chunk. */ nchars = PyUnicode_GET_LENGTH(decoded_chars); + textiowrapper_set_decoded_chars(self, decoded_chars); if (nchars > 0) self->b2cratio = (double) nbytes / nchars; else @@ -2088,15 +2155,9 @@ _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n) return NULL; } - _PyIO_State *state = self->state; - if (Py_IS_TYPE(self->decoder, state->PyIncrementalNewlineDecoder_Type)) - decoded = _PyIncrementalNewlineDecoder_decode(self->decoder, - bytes, 1); - else - decoded = PyObject_CallMethodObjArgs( - self->decoder, &_Py_ID(decode), bytes, Py_True, NULL); + decoded = _textiowrapper_decode(self->state, self->decoder, bytes, 1); Py_DECREF(bytes); - if (check_decoded(decoded) < 0) + if (decoded == NULL) goto fail; result = textiowrapper_get_decoded_chars(self, -1); @@ -2679,6 +2740,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence) goto fail; } res = _PyObject_CallMethod(buf, &_Py_ID(seek), "ii", 0, 2); + Py_DECREF(buf); Py_CLEAR(cookieObj); if (res == NULL) goto fail; @@ -2823,7 +2885,7 @@ _io_TextIOWrapper_tell_impl(textio *self) PyObject *res; PyObject *posobj = NULL; cookie_type cookie = {0,0,0,0,0}; - PyObject *next_input; + PyObject *next_input = NULL; Py_ssize_t chars_to_skip, chars_decoded; Py_ssize_t skip_bytes, skip_back; PyObject *saved_state = NULL; @@ -2875,11 +2937,15 @@ _io_TextIOWrapper_tell_impl(textio *self) assert (PyBytes_Check(next_input)); + /* Own next_input: a reentrant or concurrent seek can drop the snapshot. */ + Py_INCREF(next_input); + cookie.start_pos -= PyBytes_GET_SIZE(next_input); /* How many decoded characters have been used up since the snapshot? */ if (self->decoded_chars_used == 0) { /* We haven't moved from the snapshot point. */ + Py_DECREF(next_input); return textiowrapper_build_cookie(&cookie); } @@ -2932,9 +2998,16 @@ _io_TextIOWrapper_tell_impl(textio *self) /* Fast search for an acceptable start point, close to our current pos */ - skip_bytes = (Py_ssize_t) (self->b2cratio * chars_to_skip); + double skip_estimate = self->b2cratio * chars_to_skip; + if (skip_estimate >= 0 && + skip_estimate <= PyBytes_GET_SIZE(next_input)) + { + skip_bytes = (Py_ssize_t)skip_estimate; + } + else { + skip_bytes = 0; + } skip_back = 1; - assert(skip_bytes <= PyBytes_GET_SIZE(next_input)); input = PyBytes_AS_STRING(next_input); while (skip_bytes > 0) { /* Decode up to temptative start point */ @@ -3020,6 +3093,7 @@ _io_TextIOWrapper_tell_impl(textio *self) } finally: + Py_XDECREF(next_input); res = PyObject_CallMethodOneArg( self->decoder, &_Py_ID(setstate), saved_state); Py_DECREF(saved_state); @@ -3032,6 +3106,7 @@ _io_TextIOWrapper_tell_impl(textio *self) return textiowrapper_build_cookie(&cookie); fail: + Py_XDECREF(next_input); if (saved_state) { PyObject *exc = PyErr_GetRaisedException(); res = PyObject_CallMethodOneArg( @@ -3263,12 +3338,17 @@ _io_TextIOWrapper_close_impl(textio *self) } } +/*[clinic input] +@critical_section +_io.TextIOWrapper.__next__ as textiowrapper_iternext +[clinic start generated code]*/ + static PyObject * -textiowrapper_iternext_lock_held(PyObject *op) +textiowrapper_iternext_impl(textio *self) +/*[clinic end generated code: output=f365c4287cd43a1f input=c5b4c79faf0c98cb]*/ { - _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op); + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self); PyObject *line; - textio *self = textio_CAST(op); CHECK_ATTACHED(self); @@ -3278,7 +3358,7 @@ textiowrapper_iternext_lock_held(PyObject *op) line = _textiowrapper_readline(self, -1); } else { - line = PyObject_CallMethodNoArgs(op, &_Py_ID(readline)); + line = PyObject_CallMethodNoArgs((PyObject *)self, &_Py_ID(readline)); if (line && !PyUnicode_Check(line)) { PyErr_Format(PyExc_OSError, "readline() should have returned a str object, " @@ -3302,16 +3382,6 @@ textiowrapper_iternext_lock_held(PyObject *op) return line; } -static PyObject * -textiowrapper_iternext(PyObject *op) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(op); - result = textiowrapper_iternext_lock_held(op); - Py_END_CRITICAL_SECTION(); - return result; -} - /*[clinic input] @critical_section @getter @@ -3385,45 +3455,55 @@ _io_TextIOWrapper_errors_get_impl(textio *self) /*[clinic input] @critical_section @getter -_io.TextIOWrapper._CHUNK_SIZE +_io.TextIOWrapper._CHUNK_SIZE -> Py_ssize_t [clinic start generated code]*/ -static PyObject * +static Py_ssize_t _io_TextIOWrapper__CHUNK_SIZE_get_impl(textio *self) -/*[clinic end generated code: output=039925cd2df375bc input=e9715b0e06ff0fa6]*/ +/*[clinic end generated code: output=3fe34b873b6b2c8c input=cae767b74b6b46bd]*/ { - CHECK_ATTACHED(self); - return PyLong_FromSsize_t(self->chunk_size); + CHECK_ATTACHED_INT(self); + return self->chunk_size; } /*[clinic input] @critical_section @setter _io.TextIOWrapper._CHUNK_SIZE + value: Py_ssize_t [clinic start generated code]*/ static int -_io_TextIOWrapper__CHUNK_SIZE_set_impl(textio *self, PyObject *value) -/*[clinic end generated code: output=edb86d2db660a5ab input=32fc99861db02a0a]*/ +_io_TextIOWrapper__CHUNK_SIZE_set_impl(textio *self, Py_ssize_t value) +/*[clinic end generated code: output=5170a93dd4d74917 input=ede7bae6145f941b]*/ { - Py_ssize_t n; CHECK_ATTACHED_INT(self); - if (value == NULL) { - PyErr_SetString(PyExc_AttributeError, "cannot delete attribute"); - return -1; - } - n = PyNumber_AsSsize_t(value, PyExc_ValueError); - if (n == -1 && PyErr_Occurred()) - return -1; - if (n <= 0) { + if (value <= 0) { PyErr_SetString(PyExc_ValueError, "a strictly positive integer is required"); return -1; } - self->chunk_size = n; + self->chunk_size = value; return 0; } +/*[clinic input] +@critical_section +@getter +_io.TextIOWrapper.buffer +[clinic start generated code]*/ + +static PyObject * +_io_TextIOWrapper_buffer_get_impl(textio *self) +/*[clinic end generated code: output=d265a34555aa5d4b input=5951cfa148f7350a]*/ +{ + /* gh-160427: None once detached, matching the former member descriptor. */ + if (self->buffer == NULL) { + Py_RETURN_NONE; + } + return Py_NewRef(self->buffer); +} + static PyMethodDef incrementalnewlinedecoder_methods[] = { _IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF _IO_INCREMENTALNEWLINEDECODER_GETSTATE_METHODDEF @@ -3433,7 +3513,7 @@ static PyMethodDef incrementalnewlinedecoder_methods[] = { }; static PyGetSetDef incrementalnewlinedecoder_getset[] = { - {"newlines", incrementalnewlinedecoder_newlines_get, NULL, NULL}, + _IO_INCREMENTALNEWLINEDECODER_NEWLINES_GETSETDEF {NULL} }; @@ -3445,6 +3525,7 @@ static PyType_Slot nldecoder_slots[] = { {Py_tp_traverse, incrementalnewlinedecoder_traverse}, {Py_tp_clear, incrementalnewlinedecoder_clear}, {Py_tp_init, _io_IncrementalNewlineDecoder___init__}, + {Py_tp_vectorcall, _io_IncrementalNewlineDecoder_vectorcall}, {0, NULL}, }; @@ -3482,12 +3563,9 @@ static PyMethodDef textiowrapper_methods[] = { static PyMemberDef textiowrapper_members[] = { {"encoding", _Py_T_OBJECT, offsetof(textio, encoding), Py_READONLY}, - {"buffer", _Py_T_OBJECT, offsetof(textio, buffer), Py_READONLY}, {"line_buffering", Py_T_BOOL, offsetof(textio, line_buffering), Py_READONLY}, {"write_through", Py_T_BOOL, offsetof(textio, write_through), Py_READONLY}, {"_finalizing", Py_T_BOOL, offsetof(textio, finalizing), 0}, - {"__weaklistoffset__", Py_T_PYSSIZET, offsetof(textio, weakreflist), Py_READONLY}, - {"__dictoffset__", Py_T_PYSSIZET, offsetof(textio, dict), Py_READONLY}, {NULL} }; @@ -3497,6 +3575,7 @@ static PyGetSetDef textiowrapper_getset[] = { _IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF _IO_TEXTIOWRAPPER_ERRORS_GETSETDEF _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF + _IO_TEXTIOWRAPPER_BUFFER_GETSETDEF {NULL} }; diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c index 4cd71094e8f459e..a6e884fb9c5fc82 100644 --- a/Modules/_io/winconsoleio.c +++ b/Modules/_io/winconsoleio.c @@ -10,7 +10,6 @@ #include "pycore_fileutils.h" // _Py_BEGIN_SUPPRESS_IPH #include "pycore_object.h" // _PyObject_GC_UNTRACK() #include "pycore_pyerrors.h" // _PyErr_ChainExceptions1() -#include "pycore_weakref.h" // FT_CLEAR_WEAKREFS() #ifdef HAVE_WINDOWS_CONSOLE_IO @@ -216,8 +215,6 @@ typedef struct { unsigned int closefd : 1; char finalizing; unsigned int blksize; - PyObject *weakreflist; - PyObject *dict; char buf[SMALLBUF]; wchar_t wbuf; } winconsoleio; @@ -300,7 +297,6 @@ winconsoleio_new(PyTypeObject *type, PyObject *args, PyObject *kwds) self->writable = 0; self->closefd = 0; self->blksize = 0; - self->weakreflist = NULL; } return (PyObject *) self; @@ -498,15 +494,13 @@ winconsoleio_traverse(PyObject *op, visitproc visit, void *arg) { winconsoleio *self = winconsoleio_CAST(op); Py_VISIT(Py_TYPE(self)); - Py_VISIT(self->dict); - return 0; + return PyObject_VisitManagedDict(op, visit, arg); } static int winconsoleio_clear(PyObject *op) { - winconsoleio *self = winconsoleio_CAST(op); - Py_CLEAR(self->dict); + PyObject_ClearManagedDict(op); return 0; } @@ -519,8 +513,8 @@ winconsoleio_dealloc(PyObject *op) if (_PyIOBase_finalize(op) < 0) return; _PyObject_GC_UNTRACK(self); - FT_CLEAR_WEAKREFS(op, self->weakreflist); - Py_CLEAR(self->dict); + PyObject_ClearWeakRefs(op); + PyObject_ClearManagedDict(op); tp->tp_free(self); Py_DECREF(tp); } @@ -644,8 +638,8 @@ read_console_w(HANDLE handle, DWORD maxlen, DWORD *readlen) { break; err = 0; HANDLE hInterruptEvent = _PyOS_SigintEvent(); - if (WaitForSingleObjectEx(hInterruptEvent, 100, FALSE) - == WAIT_OBJECT_0) { + DWORD state = WaitForSingleObjectEx(hInterruptEvent, 100, FALSE); + if (state == WAIT_OBJECT_0) { ResetEvent(hInterruptEvent); Py_BLOCK_THREADS sig = PyErr_CheckSignals(); @@ -653,6 +647,13 @@ read_console_w(HANDLE handle, DWORD maxlen, DWORD *readlen) { if (sig < 0) break; } + else if (state != WAIT_TIMEOUT) { + err = GetLastError(); + break; + } + /* The console cancelled the read and flushed its input buffer, + but no exception was raised. Start the read over. */ + continue; } *readlen += n; @@ -935,7 +936,7 @@ _io__WindowsConsoleIO_readall_impl(winconsoleio *self) if (len == 0 && _buflen(self) == 0) { /* when the result starts with ^Z we return an empty buffer */ PyMem_Free(buf); - return PyBytes_FromStringAndSize(NULL, 0); + return Py_GetConstant(Py_CONSTANT_EMPTY_BYTES); } if (len) { @@ -955,6 +956,10 @@ _io__WindowsConsoleIO_readall_impl(winconsoleio *self) bytes_size += _buflen(self); bytes = PyBytes_FromStringAndSize(NULL, bytes_size); + if (bytes == NULL) { + PyMem_Free(buf); + return NULL; + } rn = _copyfrombuf(self, PyBytes_AS_STRING(bytes), bytes_size); if (len) { @@ -1002,7 +1007,6 @@ _io__WindowsConsoleIO_read_impl(winconsoleio *self, PyTypeObject *cls, Py_ssize_t size) /*[clinic end generated code: output=7e569a586537c0ae input=a14570a5da273365]*/ { - PyObject *bytes; Py_ssize_t bytes_size; if (self->fd == -1) @@ -1019,26 +1023,20 @@ _io__WindowsConsoleIO_read_impl(winconsoleio *self, PyTypeObject *cls, return NULL; } - bytes = PyBytes_FromStringAndSize(NULL, size); - if (bytes == NULL) + PyBytesWriter *writer = PyBytesWriter_Create(size); + if (writer == NULL) { return NULL; + } _PyIO_State *state = get_io_state_by_cls(cls); - bytes_size = readinto(state, self, PyBytes_AS_STRING(bytes), - PyBytes_GET_SIZE(bytes)); + bytes_size = readinto(state, self, PyBytesWriter_GetData(writer), + PyBytesWriter_GetSize(writer)); if (bytes_size < 0) { - Py_CLEAR(bytes); + PyBytesWriter_Discard(writer); return NULL; } - if (bytes_size < PyBytes_GET_SIZE(bytes)) { - if (_PyBytes_Resize(&bytes, bytes_size) < 0) { - Py_CLEAR(bytes); - return NULL; - } - } - - return bytes; + return PyBytesWriter_FinishWithSize(writer, bytes_size); } /*[clinic input] @@ -1093,7 +1091,10 @@ _io__WindowsConsoleIO_write_impl(winconsoleio *self, PyTypeObject *cls, len = Py_MIN(len, max_wlen * 3); while (1) { /* Fix for github issues gh-110913 and gh-82052. */ - len = _find_last_utf8_boundary(b->buf, len); + DWORD boundary = _find_last_utf8_boundary(b->buf, len); + if (boundary != 0) { + len = boundary; + } wlen = MultiByteToWideChar(CP_UTF8, 0, b->buf, len, NULL, 0); if (wlen <= max_wlen) { break; @@ -1202,40 +1203,58 @@ static PyMethodDef winconsoleio_methods[] = { /* 'closed' and 'mode' are attributes for compatibility with FileIO. */ -static PyObject * -get_closed(PyObject *op, void *Py_UNUSED(closure)) +/*[clinic input] +@getter +_io._WindowsConsoleIO.closed -> bool + +True if the file is closed. +[clinic start generated code]*/ + +static int +_io__WindowsConsoleIO_closed_get_impl(winconsoleio *self) +/*[clinic end generated code: output=a3f8b93c6ddcf660 input=65b6d1bed0aadbb8]*/ { - winconsoleio *self = winconsoleio_CAST(op); - return PyBool_FromLong((long)(self->fd == -1)); + return self->fd == -1; } -static PyObject * -get_closefd(PyObject *op, void *Py_UNUSED(closure)) +/*[clinic input] +@getter +_io._WindowsConsoleIO.closefd -> bool + +True if the file descriptor will be closed by close(). +[clinic start generated code]*/ + +static int +_io__WindowsConsoleIO_closefd_get_impl(winconsoleio *self) +/*[clinic end generated code: output=ec221c2f949530a3 input=5839d3a815edecee]*/ { - winconsoleio *self = winconsoleio_CAST(op); - return PyBool_FromLong((long)(self->closefd)); + return self->closefd; } +/*[clinic input] +@getter +_io._WindowsConsoleIO.mode + +String giving the file mode. +[clinic start generated code]*/ + static PyObject * -get_mode(PyObject *op, void *Py_UNUSED(closure)) +_io__WindowsConsoleIO_mode_get_impl(winconsoleio *self) +/*[clinic end generated code: output=2d7c4cabf96e5281 input=e1fa9cd881117c0f]*/ { - winconsoleio *self = winconsoleio_CAST(op); return PyUnicode_FromString(self->readable ? "rb" : "wb"); } static PyGetSetDef winconsoleio_getsetlist[] = { - {"closed", get_closed, NULL, "True if the file is closed"}, - {"closefd", get_closefd, NULL, - "True if the file descriptor will be closed by close()."}, - {"mode", get_mode, NULL, "String giving the file mode"}, + _IO__WINDOWSCONSOLEIO_CLOSED_GETSETDEF + _IO__WINDOWSCONSOLEIO_CLOSEFD_GETSETDEF + _IO__WINDOWSCONSOLEIO_MODE_GETSETDEF {NULL}, }; static PyMemberDef winconsoleio_members[] = { {"_blksize", Py_T_UINT, offsetof(winconsoleio, blksize), 0}, {"_finalizing", Py_T_BOOL, offsetof(winconsoleio, finalizing), 0}, - {"__weaklistoffset__", Py_T_PYSSIZET, offsetof(winconsoleio, weakreflist), Py_READONLY}, - {"__dictoffset__", Py_T_PYSSIZET, offsetof(winconsoleio, dict), Py_READONLY}, {NULL} }; diff --git a/Modules/_json.c b/Modules/_json.c index 3a724a3e72b185b..e79b697f06c994c 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -1802,7 +1802,10 @@ encoder_listencode_dict(PyEncoderObject *s, PyUnicodeWriter *writer, PyObject *ident = NULL; bool first = true; - if (PyDict_GET_SIZE(dct) == 0) { + // Only take the fast path for exact dicts: a subclass may keep its + // contents outside the dict storage, so PyDict_GET_SIZE could be 0 while + // the mapping is non-empty (gh-110941). + if (PyAnyDict_CheckExact(dct) && PyDict_GET_SIZE(dct) == 0) { /* Fast path */ return PyUnicodeWriter_WriteASCII(writer, "{}", 2); } diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c index 0f71358a180dd29..ba8b421c25a47cc 100644 --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -126,7 +126,7 @@ check_locale_name_all(const char *locale) _locale.setlocale category: int - locale: str(accept={str, NoneType}) = NULL + locale: str(accept={str, NoneType}) = None / Activates/queries locale processing. @@ -134,7 +134,7 @@ Activates/queries locale processing. static PyObject * _locale_setlocale_impl(PyObject *module, int category, const char *locale) -/*[clinic end generated code: output=a0e777ae5d2ff117 input=dbe18f1d66c57a6a]*/ +/*[clinic end generated code: output=a0e777ae5d2ff117 input=b53449b63407179b]*/ { char *result; PyObject *result_object; @@ -443,6 +443,7 @@ _locale_strxfrm_impl(PyObject *module, PyObject *str) { Py_ssize_t n1; wchar_t *s = NULL, *buf = NULL; + wchar_t dummy[1]; size_t n2; PyObject *result = NULL; @@ -456,7 +457,9 @@ _locale_strxfrm_impl(PyObject *module, PyObject *str) } errno = 0; - n2 = wcsxfrm(NULL, s, 0); + /* Query the size with a real one-element buffer: DragonFly BSD's + wcsxfrm() crashes when the destination is NULL or the size is 0. */ + n2 = wcsxfrm(dummy, s, 1); if (errno && errno != ERANGE) { PyErr_SetFromErrno(PyExc_OSError); goto exit; diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index 4e50ca64f59af22..c11973d3ed1ff0f 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -52,6 +52,7 @@ typedef struct { ProfilerContext *currentProfilerContext; ProfilerContext *freelistProfilerContext; int flags; + unsigned int activeTimers; /* may overlap if the profiler lock is released */ PyObject *externalTimer; double externalTimerUnit; int tool_id; @@ -63,7 +64,6 @@ typedef struct { #define POF_ENABLED 0x001 #define POF_SUBCALLS 0x002 #define POF_BUILTINS 0x004 -#define POF_EXT_TIMER 0x008 #define POF_NOMEMORY 0x100 /*[clinic input] @@ -92,13 +92,8 @@ _lsprof_get_state(PyObject *module) static PyTime_t CallExternalTimer(ProfilerObject *pObj) { - PyObject *o = NULL; - - // External timer can do arbitrary things so we need a flag to prevent - // horrible things to happen - pObj->flags |= POF_EXT_TIMER; - o = _PyObject_CallNoArgs(pObj->externalTimer); - pObj->flags &= ~POF_EXT_TIMER; + assert(pObj->externalTimer != NULL && pObj->externalTimer != Py_None); + PyObject *o = _PyObject_CallNoArgs(pObj->externalTimer); if (o == NULL) { PyErr_FormatUnraisable("Exception ignored while calling " @@ -132,7 +127,12 @@ static inline PyTime_t call_timer(ProfilerObject *pObj) { if (pObj->externalTimer != NULL) { - return CallExternalTimer(pObj); + /* Converting or releasing the result and reporting an unraisable + exception can all run Python code. */ + pObj->activeTimers++; + PyTime_t result = CallExternalTimer(pObj); + pObj->activeTimers--; + return result; } else { PyTime_t t; @@ -363,6 +363,12 @@ ptrace_enter_call(PyObject *self, void *key, PyObject *userObj) ProfilerEntry *profEntry; ProfilerContext *pContext; + /* Events raised by the external timer must be ignored: it can run + arbitrary code while a context is still being unwound. */ + if (pObj->activeTimers) { + return; + } + /* In the case of entering a generator expression frame via a * throw (gen_send_ex(.., 1)), we may already have an * Exception set here. We must not mess around with this @@ -405,6 +411,10 @@ ptrace_leave_call(PyObject *self, void *key) ProfilerEntry *profEntry; ProfilerContext *pContext; + if (pObj->activeTimers) { + return; + } + pContext = pObj->currentProfilerContext; if (pContext == NULL) return; @@ -887,7 +897,7 @@ static PyObject * _lsprof_Profiler_disable_impl(ProfilerObject *self) /*[clinic end generated code: output=838cffef7f651870 input=f7e4787cae20f7f6]*/ { - if (self->flags & POF_EXT_TIMER) { + if (self->activeTimers) { PyErr_SetString(PyExc_RuntimeError, "cannot disable profiler in external timer"); return NULL; @@ -947,7 +957,7 @@ static PyObject * _lsprof_Profiler_clear_impl(ProfilerObject *self) /*[clinic end generated code: output=dd1c668fb84b1335 input=4aab219d5d7a9bec]*/ { - if (self->flags & POF_EXT_TIMER) { + if (self->activeTimers) { PyErr_SetString(PyExc_RuntimeError, "cannot clear profiler in external timer"); return NULL; @@ -980,16 +990,20 @@ profiler_dealloc(PyObject *op) } } + /* Drop the external timer before flushing: it is Python code, and the + profiler can be deallocated by the garbage collector. */ + Py_CLEAR(self->externalTimer); + flush_unmatched(self); clearEntries(self); Py_XDECREF(self->missing); - Py_XDECREF(self->externalTimer); PyTypeObject *tp = Py_TYPE(self); tp->tp_free(self); Py_DECREF(tp); } /*[clinic input] +@critical_section _lsprof.Profiler.__init__ as profiler_init timer: object(c_default='NULL') = None @@ -1008,11 +1022,19 @@ is, in seconds). static int profiler_init_impl(ProfilerObject *self, PyObject *timer, double timeunit, int subcalls, int builtins) -/*[clinic end generated code: output=ac523803ec9f9df2 input=8285ca746f96a414]*/ +/*[clinic end generated code: output=ac523803ec9f9df2 input=5add5fc72beb63ba]*/ { + if (self->activeTimers) { + PyErr_SetString(PyExc_RuntimeError, + "cannot initialize profiler in external timer"); + return -1; + } if (setSubcalls(self, subcalls) < 0 || setBuiltins(self, builtins) < 0) { return -1; } + if (timer == Py_None) { + timer = NULL; + } self->externalTimerUnit = timeunit; Py_XSETREF(self->externalTimer, Py_XNewRef(timer)); self->tool_id = PY_MONITORING_PROFILER_ID; diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c index 4335a8bb162414d..92784904f3c9930 100644 --- a/Modules/_lzmamodule.c +++ b/Modules/_lzmamodule.c @@ -1509,6 +1509,62 @@ _lzma__decode_filter_properties_impl(PyObject *module, lzma_vli filter_id, return result; } + +PyDoc_STRVAR(lzma_version_info__doc__, +"_lzma.lzma_version_info\n\ +\n\ +Lzma version information as a named tuple."); + +static PyStructSequence_Field lzma_version_info_fields[] = { + {"major", "Major release number"}, + {"minor", "Minor release number"}, + {"patch", "Patch release number"}, + {"stability", "'alpha', 'beta', or 'stable'"}, + {0} +}; + +static PyStructSequence_Desc lzma_version_info_desc = { + "_lzma.lzma_version_info", /* name */ + lzma_version_info__doc__, /* doc */ + lzma_version_info_fields, /* fields */ + 4 +}; + +static PyObject * +make_lzma_version_info(PyTypeObject *type, unsigned int number) +{ + PyObject *version; + int pos = 0; + unsigned int major = number / 10000000u; + unsigned int minor = (number % 10000000u) / 10000u; + unsigned int patch = (number % 10000u) / 10u; + unsigned int stability = number % 10u; + const char *stability_string = (stability == 0) ? "alpha" + : (stability == 1) ? "beta" + : "stable"; + + version = PyStructSequence_New(type); + if (version == NULL) { + return NULL; + } + +#define SetItem(VALUE) \ + PyStructSequence_SET_ITEM(version, pos++, VALUE); \ + if (PyErr_Occurred()) { \ + Py_DECREF(version); \ + return NULL; \ + } + + SetItem(PyLong_FromUnsignedLong(major)) + SetItem(PyLong_FromUnsignedLong(minor)) + SetItem(PyLong_FromUnsignedLong(patch)) + SetItem(PyUnicode_FromString(stability_string)) +#undef SetItem + + return version; +} + + /* Some of our constants are more than 32 bits wide, so PyModule_AddIntConstant would not work correctly on platforms with 32-bit longs. */ static int @@ -1603,6 +1659,33 @@ lzma_exec(PyObject *module) return -1; } + /* lzma_version */ + if (PyModule_Add(module, "LZMA_VERSION", + PyUnicode_FromString(LZMA_VERSION_STRING)) < 0) { + return -1; + } + if (PyModule_Add(module, "lzma_version", + PyUnicode_FromString(lzma_version_string())) < 0) { + return -1; + } + PyTypeObject *version_type; + version_type = PyStructSequence_NewType(&lzma_version_info_desc); + if (version_type == NULL) { + return -1; + } + if (PyModule_Add(module, "LZMA_VERSION_INFO", + make_lzma_version_info(version_type, LZMA_VERSION)) < 0) + { + Py_DECREF(version_type); + return -1; + } + if (PyModule_Add(module, "lzma_version_info", + make_lzma_version_info(version_type, lzma_version_number())) < 0) + { + Py_DECREF(version_type); + return -1; + } + Py_DECREF(version_type); return 0; } diff --git a/Modules/_multiprocessing/clinic/multiprocessing.c.h b/Modules/_multiprocessing/clinic/multiprocessing.c.h index 6d4f5c2afcfd398..ea6fffc428919b4 100644 --- a/Modules/_multiprocessing/clinic/multiprocessing.c.h +++ b/Modules/_multiprocessing/clinic/multiprocessing.c.h @@ -3,6 +3,7 @@ preserve [clinic start generated code]*/ #include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() #if defined(MS_WINDOWS) @@ -138,15 +139,10 @@ _multiprocessing_sem_unlink(PyObject *module, PyObject *arg) _PyArg_BadArgument("sem_unlink", "argument", "str", arg); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(arg, &name_length); + name = _PyUnicode_AsUTF8NoNUL(arg); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _multiprocessing_sem_unlink_impl(module, name); exit: @@ -164,4 +160,4 @@ _multiprocessing_sem_unlink(PyObject *module, PyObject *arg) #ifndef _MULTIPROCESSING_SEND_METHODDEF #define _MULTIPROCESSING_SEND_METHODDEF #endif /* !defined(_MULTIPROCESSING_SEND_METHODDEF) */ -/*[clinic end generated code: output=73b4cb8428d816da input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f5147f6a6e2cbd17 input=a9049054013a1b77]*/ diff --git a/Modules/_multiprocessing/clinic/semaphore.c.h b/Modules/_multiprocessing/clinic/semaphore.c.h index 6b1c0092ce48160..962f0c88a3914fd 100644 --- a/Modules/_multiprocessing/clinic/semaphore.c.h +++ b/Modules/_multiprocessing/clinic/semaphore.c.h @@ -8,6 +8,7 @@ preserve #endif #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() #if defined(HAVE_MP_SEMAPHORE) && defined(MS_WINDOWS) @@ -292,15 +293,10 @@ _multiprocessing_SemLock(PyTypeObject *type, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("SemLock", "argument 'name'", "str", fastargs[3]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(fastargs[3], &name_length); + name = _PyUnicode_AsUTF8NoNUL(fastargs[3]); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } unlink = PyObject_IsTrue(fastargs[4]); if (unlink < 0) { goto exit; @@ -337,7 +333,7 @@ _multiprocessing_SemLock__rebuild(PyObject *type, PyObject *const *args, Py_ssiz int maxvalue; const char *name; - if (!_PyArg_ParseStack(args, nargs, ""F_SEM_HANDLE"iiz:_rebuild", + if (!PyArg_ParseArray(args, nargs, ""F_SEM_HANDLE"iiz:_rebuild", &handle, &kind, &maxvalue, &name)) { goto exit; } @@ -582,4 +578,4 @@ _multiprocessing_SemLock___exit__(PyObject *self, PyObject *const *args, Py_ssiz #ifndef _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF #define _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF #endif /* !defined(_MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF) */ -/*[clinic end generated code: output=d1e349d4ee3d4bbf input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7a35732855b11781 input=a9049054013a1b77]*/ diff --git a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c index 201cedbb59818f2..6ca1bbe30f20c77 100644 --- a/Modules/_multiprocessing/multiprocessing.c +++ b/Modules/_multiprocessing/multiprocessing.c @@ -9,22 +9,6 @@ #include "multiprocessing.h" -/*[python input] -class HANDLE_converter(CConverter): - type = "HANDLE" - format_unit = '"F_HANDLE"' - - def parse_arg(self, argname, displayname, *, limited_capi): - return self.format_code(""" - {paramname} = PyLong_AsVoidPtr({argname}); - if (!{paramname} && PyErr_Occurred()) {{{{ - goto exit; - }}}} - """, - argname=argname) - -[python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=3cf0318efc6a8772]*/ /*[clinic input] module _multiprocessing diff --git a/Modules/_openssl_mem.h b/Modules/_openssl_mem.h new file mode 100644 index 000000000000000..5284d9b5e63361a --- /dev/null +++ b/Modules/_openssl_mem.h @@ -0,0 +1,56 @@ +// Route OpenSSL allocations through the raw memory allocators. +// Shared by the _ssl and _hashlib modules. + +#ifndef Py_OPENSSL_MEM_H +#define Py_OPENSSL_MEM_H + +#include "Python.h" + +#include // CRYPTO_set_mem_functions() + +// LibreSSL stubs out CRYPTO_set_mem_functions() and BoringSSL lacks it. +// AWS-LC has it, but unlike OpenSSL it does not refuse to install hooks +// after the first allocation, so earlier size-prefixed allocations would +// be freed with the wrong allocator. +#if !defined(LIBRESSL_VERSION_NUMBER) && !defined(OPENSSL_IS_BORINGSSL) \ + && !defined(OPENSSL_IS_AWSLC) +# define _Py_OPENSSL_CAN_SET_MEM_FUNCTIONS +#endif + +#ifdef _Py_OPENSSL_CAN_SET_MEM_FUNCTIONS + +static void * +_PyOpenSSL_Malloc(size_t size, const char *Py_UNUSED(file), + int Py_UNUSED(line)) +{ + return PyMem_RawMalloc(size); +} + +static void * +_PyOpenSSL_Realloc(void *ptr, size_t size, const char *Py_UNUSED(file), + int Py_UNUSED(line)) +{ + return PyMem_RawRealloc(ptr, size); +} + +static void +_PyOpenSSL_Free(void *ptr, const char *Py_UNUSED(file), + int Py_UNUSED(line)) +{ + PyMem_RawFree(ptr); +} + +#endif // _Py_OPENSSL_CAN_SET_MEM_FUNCTIONS + +static void +_PyOpenSSL_SetupMemFunctions(void) +{ +#ifdef _Py_OPENSSL_CAN_SET_MEM_FUNCTIONS + // Fails if OpenSSL has already allocated memory (e.g. another + // libcrypto user in the process); it then keeps its current allocator. + (void)CRYPTO_set_mem_functions(_PyOpenSSL_Malloc, _PyOpenSSL_Realloc, + _PyOpenSSL_Free); +#endif +} + +#endif // !Py_OPENSSL_MEM_H diff --git a/Modules/_operator.c b/Modules/_operator.c index 417403dc4c10c11..a0843971efe13e6 100644 --- a/Modules/_operator.c +++ b/Modules/_operator.c @@ -1740,7 +1740,7 @@ methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return (PyObject *)mc; } -static void +static int methodcaller_clear(PyObject *op) { methodcallerobject *mc = methodcallerobject_CAST(op); @@ -1749,6 +1749,7 @@ methodcaller_clear(PyObject *op) Py_CLEAR(mc->kwds); Py_CLEAR(mc->vectorcall_args); Py_CLEAR(mc->vectorcall_kwnames); + return 0; } static void diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 034dd06b6ab4609..b8f9b1c92f20723 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -603,6 +603,13 @@ typedef struct { Py_ssize_t me_value; } PyMemoEntry; +/* The top bit of me_value flags an object reached so far only through a weak + reference (memo indices are small non-negative ints, so it is free); + MEMO_INDEX() masks it out. Bit math in size_t; the store back into the + signed field relies on two's complement. */ +#define MEMO_WEAK_ONLY ((size_t)1 << (sizeof(size_t) * 8 - 1)) +#define MEMO_INDEX(v) ((Py_ssize_t)((size_t)(v) & ~MEMO_WEAK_ONLY)) + typedef struct { size_t mt_mask; size_t mt_used; @@ -647,6 +654,10 @@ typedef struct PicklerObject { int running; /* True when a method of Pickler is executing. */ PyObject *fast_memo; PyObject *buffer_callback; /* Callback for out-of-band buffers, or NULL */ + + Py_ssize_t weak_only_count; /* Number of memo entries flagged weak-only; + any left at the end of dump() are pickling + errors. */ } PicklerObject; typedef struct UnpicklerObject { @@ -669,6 +680,10 @@ typedef struct UnpicklerObject { Py_ssize_t input_len; Py_ssize_t next_read_idx; Py_ssize_t prefetched_idx; /* index of first prefetched byte */ + Py_ssize_t frame_end; /* End of the current frame, or -1 if not in a + frame. While in a frame, input_len is capped + here so reads can't cross it (PEP 3154). */ + Py_ssize_t saved_input_len; /* input_len to restore when the frame ends. */ PyObject *read; /* read() method of the input stream. */ PyObject *readinto; /* readinto() method of the input stream. */ @@ -736,6 +751,8 @@ typedef struct { /* Forward declarations */ static int save(PickleState *state, PicklerObject *, PyObject *, int); +static int save_object(PickleState *state, PicklerObject *, PyObject *, + int pers_save, int weak); static int save_reduce(PickleState *, PicklerObject *, PyObject *, PyObject *); #include "clinic/_pickle.c.h" @@ -1166,6 +1183,7 @@ _Pickler_New(PickleState *st) self->running = 0; self->fast_memo = NULL; self->buffer_callback = NULL; + self->weak_only_count = 0; PyObject_GC_Track(self); return self; @@ -1250,6 +1268,7 @@ _Unpickler_SetStringInput(UnpicklerObject *self, PyObject *input) self->input_len = self->buffer.len; self->next_read_idx = 0; self->prefetched_idx = self->input_len; + self->frame_end = -1; return self->input_len; } @@ -1260,6 +1279,30 @@ bad_readline(PickleState *st) return -1; } +/* End the current frame, uncapping input_len. The frame must be fully read. */ +static void +_Unpickler_EndFrame(UnpicklerObject *self) +{ + assert(self->frame_end >= 0); + assert(self->next_read_idx == self->frame_end); + self->input_len = self->saved_input_len; + self->frame_end = -1; +} + +/* Reached the end of the current frame. If straddle, the read crosses the + frame boundary (PEP 3154) and fails; otherwise end the frame. */ +static int +_Unpickler_LeaveFrame(PickleState *st, UnpicklerObject *self, int straddle) +{ + if (straddle) { + PyErr_SetString(st->UnpicklingError, + "pickle exhausted before end of frame"); + return -1; + } + _Unpickler_EndFrame(self); + return 0; +} + /* Skip any consumed data that was only prefetched using peek() */ static int _Unpickler_SkipConsumed(UnpicklerObject *self) @@ -1444,6 +1487,19 @@ _Unpickler_ReadImpl(UnpicklerObject *self, PickleState *st, char **s, Py_ssize_t return -1; } + if (self->frame_end >= 0) { + if (_Unpickler_LeaveFrame(st, self, + self->next_read_idx < self->frame_end) < 0) { + return -1; + } + /* Frame ended; the read may now be satisfied from the buffer. */ + if (n <= self->input_len - self->next_read_idx) { + *s = self->input_buffer + self->next_read_idx; + self->next_read_idx += n; + return n; + } + } + /* This case is handled by the _Unpickler_Read() macro for efficiency */ assert(self->next_read_idx + n > self->input_len); @@ -1489,6 +1545,25 @@ _Unpickler_ReadInto(PickleState *state, UnpicklerObject *self, char *buf, } } + if (self->frame_end >= 0) { + /* in_buffer > 0 is next_read_idx < frame_end on entry: frame data was + consumed above, so the read crosses the frame boundary. */ + if (_Unpickler_LeaveFrame(state, self, in_buffer > 0) < 0) { + return -1; + } + in_buffer = self->input_len - self->next_read_idx; + if (in_buffer > 0) { + Py_ssize_t to_read = Py_MIN(in_buffer, n); + memcpy(buf, self->input_buffer + self->next_read_idx, to_read); + self->next_read_idx += to_read; + buf += to_read; + n -= to_read; + if (n == 0) { + return n; + } + } + } + /* Read from file */ if (!self->read) { /* We're unpickling memory, this means the input is truncated */ @@ -1547,6 +1622,7 @@ _Unpickler_Readline(PickleState *state, UnpicklerObject *self, char **result) { Py_ssize_t i, num_read; +rescan: for (i = self->next_read_idx; i < self->input_len; i++) { if (self->input_buffer[i] == '\n') { char *line_start = self->input_buffer + self->next_read_idx; @@ -1555,6 +1631,14 @@ _Unpickler_Readline(PickleState *state, UnpicklerObject *self, char **result) return _Unpickler_CopyLine(self, line_start, num_read, result); } } + if (self->frame_end >= 0) { + if (_Unpickler_LeaveFrame(state, self, + self->next_read_idx < self->frame_end) < 0) { + return -1; + } + /* Frame ended; continue the line past its end. */ + goto rescan; + } if (!self->read) return bad_readline(state); @@ -1678,16 +1762,16 @@ _Unpickler_NewMemo(Py_ssize_t new_size) return memo; } -/* Free the unpickler's memo, taking care to decref any items left in it. */ +/* Replace the unpickler's memo and release the old entries. */ static void -_Unpickler_MemoCleanup(UnpicklerObject *self) +_Unpickler_MemoCleanup(UnpicklerObject *self, PyObject **replacement) { Py_ssize_t i; PyObject **memo = self->memo; - if (self->memo == NULL) + self->memo = replacement; + if (memo == NULL) return; - self->memo = NULL; i = self->memo_size; while (--i >= 0) { Py_XDECREF(memo[i]); @@ -1729,6 +1813,8 @@ _Unpickler_New(PyObject *module) self->input_len = 0; self->next_read_idx = 0; self->prefetched_idx = 0; + self->frame_end = -1; + self->saved_input_len = 0; self->read = NULL; self->readinto = NULL; self->readline = NULL; @@ -1836,25 +1922,26 @@ memo_get(PickleState *st, PicklerObject *self, PyObject *key) PyErr_SetObject(PyExc_KeyError, key); return -1; } + Py_ssize_t idx = MEMO_INDEX(*value); /* mask off the weak-only flag bit */ if (!self->bin) { pdata[0] = GET; PyOS_snprintf(pdata + 1, sizeof(pdata) - 1, - "%zd\n", *value); + "%zd\n", idx); len = strlen(pdata); } else { - if (*value < 256) { + if (idx < 256) { pdata[0] = BINGET; - pdata[1] = (unsigned char)(*value & 0xff); + pdata[1] = (unsigned char)(idx & 0xff); len = 2; } - else if ((size_t)*value <= 0xffffffffUL) { + else if ((size_t)idx <= 0xffffffffUL) { pdata[0] = LONG_BINGET; - pdata[1] = (unsigned char)(*value & 0xff); - pdata[2] = (unsigned char)((*value >> 8) & 0xff); - pdata[3] = (unsigned char)((*value >> 16) & 0xff); - pdata[4] = (unsigned char)((*value >> 24) & 0xff); + pdata[1] = (unsigned char)(idx & 0xff); + pdata[2] = (unsigned char)((idx >> 8) & 0xff); + pdata[3] = (unsigned char)((idx >> 16) & 0xff); + pdata[4] = (unsigned char)((idx >> 24) & 0xff); len = 5; } else { /* unlikely */ @@ -4548,8 +4635,154 @@ save_reduce(PickleState *st, PicklerObject *self, PyObject *args, return 0; } +/* Weak-only objects are flagged in place in the memo (the MEMO_WEAK_ONLY bit + of the value, see PyMemoEntry); self->weak_only_count tracks how many. The + value pointer comes from PyMemoTable_Get() and must not be held across an + insertion into the table (it may rehash). */ + +static void +memo_set_weak_only(PicklerObject *self, Py_ssize_t *value) +{ + if (*value >= 0) { /* not already flagged */ + *value = (Py_ssize_t)((size_t)*value | MEMO_WEAK_ONLY); + self->weak_only_count++; + } +} + +static void +memo_clear_weak_only(PicklerObject *self, Py_ssize_t *value) +{ + if (*value < 0) { /* flagged */ + *value = MEMO_INDEX(*value); + self->weak_only_count--; + } +} + +/* Pickle a weakref.ref as weakref.ref(referent). The referent is pickled + *weakly* (no anchoring) and tagged weak-only only after its whole subtree, + so a strong cycle inside it cannot anchor it. See Lib/pickle.py. */ static int -save(PickleState *st, PicklerObject *self, PyObject *obj, int pers_save) +save_weakref(PickleState *st, PicklerObject *self, PyObject *obj) +{ + const char tuple1_op = TUPLE1; + const char tuple_op = TUPLE; + const char mark_op = MARK; + const char reduce_op = REDUCE; + const char pop_op = POP; + int status = -1; + + PyObject *referent; + if (PyWeakref_GetRef(obj, &referent) < 0) + return -1; + if (referent == NULL) { + /* All dead references are interchangeable: pickle by name as the + weakref._dead_ref singleton. */ + const char global_op = GLOBAL; + const char dead_ref_name[] = "weakref\n_dead_ref\n"; + if (_Pickler_Write(self, &global_op, 1) < 0 || + _Pickler_Write(self, dead_ref_name, sizeof(dead_ref_name) - 1) < 0) + { + return -1; + } + return 0; + } + + /* Py_TYPE(obj) is exactly weakref.ref, the reconstructor. */ + if (save(st, self, (PyObject *)Py_TYPE(obj), 0) < 0) + goto done; + + /* A referent already in the memo is anchored or already tracked; + otherwise it is tagged below, until a strong save of it. */ + int anchored = PyMemoTable_Get(self->memo, referent) != NULL; + + /* Build the 1-tuple (referent,); TUPLE1 needs protocol 2. */ + if (self->proto < 2 && _Pickler_Write(self, &mark_op, 1) < 0) + goto done; + + if (save_object(st, self, referent, 0, 1) < 0) + goto done; + + if (!anchored) { + Py_ssize_t *value = PyMemoTable_Get(self->memo, referent); + if (value != NULL) + memo_set_weak_only(self, value); + } + + if (_Pickler_Write(self, self->proto >= 2 ? &tuple1_op : &tuple_op, 1) < 0 || + _Pickler_Write(self, &reduce_op, 1) < 0) + goto done; + + /* The referent's subtree may have pickled this very (cached) weakref + already; reuse the memoized one. */ + if (PyMemoTable_Get(self->memo, obj)) { + if (_Pickler_Write(self, &pop_op, 1) < 0) + goto done; + if (memo_get(st, self, obj) < 0) + goto done; + } + else if (memo_put(st, self, obj) < 0) { + goto done; + } + status = 0; + + done: + Py_DECREF(referent); + return status; +} + +/* Build a sorted ", "-joined string of the distinct type names of the memo + objects still flagged weak-only, for the dump() error. */ +static PyObject * +weak_only_type_names(PicklerObject *self) +{ + PyObject *names = PySet_New(NULL); + if (names == NULL) + return NULL; + + PyMemoTable *memo = self->memo; + if (memo && memo->mt_table) { + for (size_t i = 0; i < memo->mt_allocated; i++) { + PyObject *key = memo->mt_table[i].me_key; + if (key == NULL || memo->mt_table[i].me_value >= 0) + continue; /* absent or not flagged weak-only */ + PyObject *tname = PyType_GetFullyQualifiedName(Py_TYPE(key)); + if (tname == NULL) + goto error; + int r = PySet_Add(names, tname); + Py_DECREF(tname); + if (r < 0) + goto error; + } + } + + PyObject *lst = PySequence_List(names); + Py_CLEAR(names); + if (lst == NULL) + return NULL; + if (PyList_Sort(lst) < 0) { + Py_DECREF(lst); + return NULL; + } + PyObject *sep = PyUnicode_FromString(", "); + if (sep == NULL) { + Py_DECREF(lst); + return NULL; + } + PyObject *joined = PyUnicode_Join(sep, lst); + Py_DECREF(sep); + Py_DECREF(lst); + return joined; + + error: + Py_DECREF(names); + return NULL; +} + +/* `weak` is true only for save_weakref's immediate save of its referent; it + does not propagate to nested saves. All other callers go through save(). */ +static int +save_object(PickleState *st, PicklerObject *self, PyObject *obj, int pers_save, + int weak) { PyTypeObject *type; PyObject *reduce_func = NULL; @@ -4596,7 +4829,11 @@ save(PickleState *st, PicklerObject *self, PyObject *obj, int pers_save) /* Check the memo to see if it has the object. If so, generate a GET (or BINGET) opcode, instead of pickling the object once again. */ - if (PyMemoTable_Get(self->memo, obj)) { + Py_ssize_t *memo_value = PyMemoTable_Get(self->memo, obj); + if (memo_value != NULL) { + /* A strong reference anchors the object: no longer weak-only. */ + if (!weak) + memo_clear_weak_only(self, memo_value); return memo_get(st, self, obj); } @@ -4613,6 +4850,11 @@ save(PickleState *st, PicklerObject *self, PyObject *obj, int pers_save) return -1; } + if (PyWeakref_CheckRefExact(obj)) { + status = save_weakref(st, self, obj); + goto done; + } + if (type == &PyDict_Type) { status = save_dict(st, self, obj); goto done; @@ -4673,17 +4915,9 @@ save(PickleState *st, PicklerObject *self, PyObject *obj, int pers_save) * __reduce_ex__ method, or the object's __reduce__ method. */ if (self->dispatch_table == NULL) { - reduce_func = PyDict_GetItemWithError(st->dispatch_table, - (PyObject *)type); - if (reduce_func == NULL) { - if (PyErr_Occurred()) { - goto error; - } - } else { - /* PyDict_GetItemWithError() returns a borrowed reference. - Increase the reference count to be consistent with - PyObject_GetItem and _PyObject_GetAttrId used below. */ - Py_INCREF(reduce_func); + if (PyDict_GetItemRef(st->dispatch_table, (PyObject *)type, + &reduce_func) < 0) { + goto error; } } else if (PyMapping_GetOptionalItem(self->dispatch_table, (PyObject *)type, @@ -4755,6 +4989,14 @@ save(PickleState *st, PicklerObject *self, PyObject *obj, int pers_save) if (status < 0) { _PyErr_FormatNote("when serializing %T object", obj); } + else if (!weak) { + /* A completed non-weak save anchors obj. Only save_reduce() + memoizes an object after its arguments, so only here can a weak + reference to a still-in-progress obj have tagged it. */ + Py_ssize_t *value = PyMemoTable_Get(self->memo, obj); + if (value != NULL) + memo_clear_weak_only(self, value); + } if (0) { error: @@ -4769,12 +5011,37 @@ save(PickleState *st, PicklerObject *self, PyObject *obj, int pers_save) return status; } +static int +save(PickleState *st, PicklerObject *self, PyObject *obj, int pers_save) +{ + return save_object(st, self, obj, pers_save, 0); +} + static PyObject * persistent_id(PyObject *self, PyObject *obj) { Py_RETURN_NONE; } +static PyObject *Pickler_getattr(PyObject *self, PyObject *name); + +/* Like PyObject_GetOptionalAttr(), but avoids creating an AttributeError + for a missing attribute. Must not be used for "persistent_id". */ +static int +pickler_get_optional_attr(PicklerObject *self, PyObject *name, + PyObject **result) +{ + if (Py_TYPE(self)->tp_getattro == Pickler_getattr) { + *result = _PyObject_GenericGetAttrWithDict((PyObject *)self, name, + NULL, 1); + if (*result != NULL) { + return 1; + } + return PyErr_Occurred() ? -1 : 0; + } + return PyObject_GetOptionalAttr((PyObject *)self, name, result); +} + static int dump(PickleState *state, PicklerObject *self, PyObject *obj) { @@ -4796,8 +5063,8 @@ dump(PickleState *state, PicklerObject *self, PyObject *obj) Py_XSETREF(self->persistent_id, tmp); /* Cache the reducer_override method, if it exists. */ - if (PyObject_GetOptionalAttr((PyObject *)self, &_Py_ID(reducer_override), - &tmp) < 0) { + if (pickler_get_optional_attr(self, &_Py_ID(reducer_override), + &tmp) < 0) { goto error; } Py_XSETREF(self->reducer_override, tmp); @@ -4814,8 +5081,22 @@ dump(PickleState *state, PicklerObject *self, PyObject *obj) self->framing = 1; } - if (save(state, self, obj, 0) < 0 || - _Pickler_Write(self, &stop_op, 1) < 0 || + if (save(state, self, obj, 0) < 0) + goto error; + + if (self->weak_only_count > 0) { + /* These referents would be collected right after loading. */ + PyObject *names = weak_only_type_names(self); + if (names == NULL) + goto error; + PyErr_Format(state->PicklingError, + "cannot pickle weak reference(s) whose referent(s) have " + "no strong reference in the pickle: %U", names); + Py_DECREF(names); + goto error; + } + + if (_Pickler_Write(self, &stop_op, 1) < 0 || _Pickler_CommitFrame(self) < 0) goto error; @@ -4854,6 +5135,7 @@ _pickle_Pickler_clear_memo_impl(PicklerObject *self) { if (self->memo) PyMemoTable_Clear(self->memo); + self->weak_only_count = 0; Py_RETURN_NONE; } @@ -4956,6 +5238,8 @@ Pickler_clear(PyObject *op) self->memo = NULL; PyMemoTable_Del(memo); } + /* The weak-only flags lived in the memo entries just freed. */ + self->weak_only_count = 0; return 0; } @@ -5077,8 +5361,8 @@ _pickle_Pickler___init___impl(PicklerObject *self, PyObject *file, self->fast_memo = NULL; if (self->dispatch_table == NULL) { - if (PyObject_GetOptionalAttr((PyObject *)self, &_Py_ID(dispatch_table), - &self->dispatch_table) < 0) { + if (pickler_get_optional_attr(self, &_Py_ID(dispatch_table), + &self->dispatch_table) < 0) { goto error; } } @@ -5143,7 +5427,7 @@ _pickle_PicklerMemoProxy_copy_impl(PicklerMemoProxyObject *self) if (key == NULL) { goto error; } - value = Py_BuildValue("nO", entry.me_value, entry.me_key); + value = Py_BuildValue("nO", MEMO_INDEX(entry.me_value), entry.me_key); if (value == NULL) { Py_DECREF(key); goto error; @@ -7078,6 +7362,17 @@ load_frame(PickleState *state, UnpicklerObject *self) if (_Unpickler_Read(self, state, &s, 8) < 0) return -1; + /* A new frame must not begin before the current one ends (PEP 3154). Its + header may lie at the tail of the current frame if it drains it. */ + if (self->frame_end >= 0) { + if (self->next_read_idx < self->frame_end) { + PyErr_SetString(state->UnpicklingError, + "beginning of a new frame before end of current frame"); + return -1; + } + _Unpickler_EndFrame(self); + } + frame_len = calc_binsize(s, 8); if (frame_len < 0) { PyErr_Format(PyExc_OverflowError, @@ -7091,6 +7386,12 @@ load_frame(PickleState *state, UnpicklerObject *self) /* Rewind to start of frame */ self->next_read_idx -= frame_len; + + /* Cap input_len at the frame end so reads can't cross it (PEP 3154); + _Unpickler_EndFrame() restores it when the frame is fully read. */ + self->frame_end = self->next_read_idx + frame_len; + self->saved_input_len = self->input_len; + self->input_len = self->frame_end; return 0; } @@ -7468,7 +7769,7 @@ Unpickler_clear(PyObject *op) } Py_CLEAR(self->memo_dict); - _Unpickler_MemoCleanup(self); + _Unpickler_MemoCleanup(self, NULL); PyMem_Free(self->marks); self->marks = NULL; PyMem_Free(self->input_line); @@ -7615,10 +7916,16 @@ static PyObject * _pickle_UnpicklerMemoProxy_clear_impl(UnpicklerMemoProxyObject *self) /*[clinic end generated code: output=d20cd43f4ba1fb1f input=b1df7c52e7afd9bd]*/ { - _Unpickler_MemoCleanup(self->unpickler); - self->unpickler->memo = _Unpickler_NewMemo(self->unpickler->memo_size); - if (self->unpickler->memo == NULL) + UnpicklerObject *unpickler = self->unpickler; + PyObject **memo = _Unpickler_NewMemo(unpickler->memo_size); + if (memo == NULL) { return NULL; + } + PyObject *memo_dict = unpickler->memo_dict; + unpickler->memo_dict = NULL; + unpickler->memo_len = 0; + _Unpickler_MemoCleanup(unpickler, memo); + Py_XDECREF(memo_dict); Py_RETURN_NONE; } @@ -7823,7 +8130,7 @@ Unpickler_set_memo(PyObject *op, PyObject *obj, void *Py_UNUSED(closure)) return -1; } - _Unpickler_MemoCleanup(self); + _Unpickler_MemoCleanup(self, NULL); self->memo_size = new_memo_size; self->memo = new_memo; diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index 2aa3923f68e66ad..8ad01414ad80755 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -84,22 +84,6 @@ module _posixsubprocess [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=c62211df27cf7334]*/ -/*[python input] -class pid_t_converter(CConverter): - type = 'pid_t' - format_unit = '" _Py_PARSE_PID "' - - def parse_arg(self, argname, displayname, *, limited_capi): - return self.format_code(""" - {paramname} = PyLong_AsPid({argname}); - if ({paramname} == -1 && PyErr_Occurred()) {{{{ - goto exit; - }}}} - """, - argname=argname) -[python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=c94349aa1aad151d]*/ - #include "clinic/_posixsubprocess.c.h" /* Convert ASCII to a positive int, no libc call. no overflow. -1 on error. */ @@ -368,7 +352,8 @@ _close_range_except(int start_fd, int (*closer)(int, int)) { if (end_fd == -1) { - end_fd = Py_MIN(safe_get_max_fd(), INT_MAX); + end_fd = safe_get_max_fd(); + end_fd = Py_MIN(end_fd, INT_MAX); } Py_ssize_t keep_seq_idx; /* As fds_to_keep is sorted we can loop through the list closing @@ -388,20 +373,26 @@ _close_range_except(int start_fd, return 0; } -#if defined(__linux__) && defined(HAVE_SYS_SYSCALL_H) +#if defined(_Py_HAVE_GETDENTS64) \ + || (defined(__linux__) && defined(HAVE_SYS_SYSCALL_H)) + +#ifdef _Py_HAVE_GETDENTS64 +# define py_dirent64 dirent64 +#else /* It doesn't matter if d_name has room for NAME_MAX chars; we're using this * only to read a directory of short file descriptor number names. The kernel * will return an error if we didn't give it enough space. Highly Unlikely. * This structure is very old and stable: It will not change unless the kernel * chooses to break compatibility with all existing binaries. Highly Unlikely. */ -struct linux_dirent64 { +struct py_dirent64 { unsigned long long d_ino; long long d_off; unsigned short d_reclen; /* Length of this linux_dirent */ unsigned char d_type; char d_name[256]; /* Filename (null-terminated) */ }; +#endif // !_Py_HAVE_GETDENTS64 static int _brute_force_closer(int first, int last) @@ -441,19 +432,31 @@ _close_open_fds_safe(int start_fd, int *fds_to_keep, Py_ssize_t fds_to_keep_len) _brute_force_closer); return; } else { - char buffer[sizeof(struct linux_dirent64)]; - int bytes; - while ((bytes = syscall(SYS_getdents64, fd_dir_fd, - (struct linux_dirent64 *)buffer, - sizeof(buffer))) > 0) { - struct linux_dirent64 *entry; + char buffer[sizeof(struct py_dirent64)]; + Py_ssize_t bytes; + while (1) { +#ifdef _Py_HAVE_GETDENTS64 + /* musl <1.2.4 headers expose `getdents64` as an alias for `getdents`, whose buffer parameter + * is `struct dirent *`. We use `void *` to support both that interface and the glibc declaration + * without an incompatible-pointer diagnostic. + */ + bytes = getdents64(fd_dir_fd, (void *)buffer, sizeof(buffer)); +#else + bytes = syscall(SYS_getdents64, fd_dir_fd, + (struct py_dirent64 *)buffer, sizeof(buffer)); +#endif + if (bytes <= 0) { + break; + } + + struct py_dirent64 *entry; int offset; #ifdef _Py_MEMORY_SANITIZER __msan_unpoison(buffer, bytes); #endif for (offset = 0; offset < bytes; offset += entry->d_reclen) { int fd; - entry = (struct linux_dirent64 *)(buffer + offset); + entry = (struct py_dirent64 *)(buffer + offset); if ((fd = _pos_int_from_ascii(entry->d_name)) < 0) continue; /* Not a number. */ if (fd != fd_dir_fd && fd >= start_fd && diff --git a/Modules/_queuemodule.c b/Modules/_queuemodule.c index af54e42a6af584c..8ab5c7d5f2b88bc 100644 --- a/Modules/_queuemodule.c +++ b/Modules/_queuemodule.c @@ -51,13 +51,14 @@ RingBuf_Init(RingBuf *buf) { buf->put_idx = 0; buf->get_idx = 0; - buf->items_cap = INITIAL_RING_BUF_CAPACITY; + buf->items_cap = 0; buf->num_items = 0; - buf->items = PyMem_Calloc(buf->items_cap, sizeof(PyObject *)); + buf->items = PyMem_Calloc(INITIAL_RING_BUF_CAPACITY, sizeof(PyObject *)); if (buf->items == NULL) { PyErr_NoMemory(); return -1; } + buf->items_cap = INITIAL_RING_BUF_CAPACITY; return 0; } @@ -238,6 +239,7 @@ simplequeue_traverse(PyObject *op, visitproc visit, void *arg) } /*[clinic input] +@vectorcall @classmethod _queue.SimpleQueue.__new__ as simplequeue_new @@ -246,7 +248,7 @@ Simple, unbounded, reentrant FIFO queue. static PyObject * simplequeue_new_impl(PyTypeObject *type) -/*[clinic end generated code: output=ba97740608ba31cd input=a0674a1643e3e2fb]*/ +/*[clinic end generated code: output=ba97740608ba31cd input=9113a69fd48c8e74]*/ { simplequeueobject *self; @@ -567,6 +569,7 @@ static PyType_Slot simplequeue_slots[] = { {Py_tp_members, simplequeue_members}, {Py_tp_methods, simplequeue_methods}, {Py_tp_new, simplequeue_new}, + {Py_tp_vectorcall, simplequeue_vectorcall}, {0, NULL}, }; diff --git a/Modules/_remote_debugging/_remote_debugging.h b/Modules/_remote_debugging/_remote_debugging.h index fa37fb7b2167ecf..532fed28741738b 100644 --- a/Modules/_remote_debugging/_remote_debugging.h +++ b/Modules/_remote_debugging/_remote_debugging.h @@ -56,7 +56,6 @@ extern "C" { # if TARGET_OS_OSX # include # include -# define MAX_NATIVE_THREADS 4096 # endif #endif @@ -104,17 +103,7 @@ typedef struct { #ifdef MS_WINDOWS #define STATUS_SUCCESS ((NTSTATUS)0x00000000L) -#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L) -typedef enum _WIN32_THREADSTATE { - WIN32_THREADSTATE_INITIALIZED = 0, - WIN32_THREADSTATE_READY = 1, - WIN32_THREADSTATE_RUNNING = 2, - WIN32_THREADSTATE_STANDBY = 3, - WIN32_THREADSTATE_TERMINATED = 4, - WIN32_THREADSTATE_WAITING = 5, - WIN32_THREADSTATE_TRANSITION = 6, - WIN32_THREADSTATE_UNKNOWN = 7 -} WIN32_THREADSTATE; +#define STATUS_NO_MORE_ENTRIES ((NTSTATUS)0x8000001AL) #endif /* ============================================================================ @@ -132,7 +121,6 @@ typedef enum _WIN32_THREADSTATE { #define SIZEOF_GEN_OBJ sizeof(PyGenObject) #define SIZEOF_INTERP_FRAME sizeof(_PyInterpreterFrame) #define SIZEOF_LLIST_NODE sizeof(struct llist_node) -#define SIZEOF_PAGE_CACHE_ENTRY sizeof(page_cache_entry_t) #define SIZEOF_PYOBJECT sizeof(PyObject) #define SIZEOF_SET_OBJ sizeof(PySetObject) #define SIZEOF_TASK_OBJ 4096 @@ -147,6 +135,8 @@ typedef enum _WIN32_THREADSTATE { #define MAX_STACK_CHUNK_SIZE (16 * 1024 * 1024) /* 16 MB max for stack chunks */ #define MAX_LONG_DIGITS 64 /* Allows values up to ~2^1920 */ #define MAX_SET_TABLE_SIZE (1 << 20) /* 1 million entries max for set iteration */ +#define MAX_FRAME_CHAIN_DEPTH (1024 + 512) /* Iteration bound for frame chain walks */ +#define MAX_TASK_WAITER_WALK_TASKS (1 << 14) /* Total-task bound for waiter walks */ #ifndef MAX #define MAX(a, b) ((a) > (b) ? (a) : (b)) @@ -180,7 +170,7 @@ typedef enum _WIN32_THREADSTATE { #define set_exception_cause(unwinder, exc_type, message) \ do { \ assert(PyErr_Occurred() && "function returned -1 without setting exception"); \ - if (unwinder->debug && !_Py_RemoteDebug_HasPermissionError()) { \ + if (unwinder->debug && !_Py_RemoteDebug_IsFatalReadError()) { \ _set_debug_exception_cause(exc_type, message); \ } \ } while (0) @@ -384,14 +374,6 @@ typedef struct { #ifdef Py_GIL_DISABLED uint32_t tlbc_generation; _Py_hashtable_t *tlbc_cache; -#endif -#ifdef __APPLE__ - uint64_t thread_id_offset; - int thread_id_offset_initialized; -#endif -#ifdef MS_WINDOWS - PVOID win_process_buffer; - ULONG win_process_buffer_size; #endif // Thread stopping state (only on platforms that support it) #ifdef Py_REMOTE_DEBUG_SUPPORTS_BLOCKING @@ -478,12 +460,6 @@ typedef int (*thread_processor_func)( void *context ); -typedef int (*set_entry_processor_func)( - RemoteUnwinderObject *unwinder, - uintptr_t key_addr, - void *context -); - typedef int (*interpreter_processor_func)( RuntimeOffsets *offsets, uintptr_t interpreter_state_addr, @@ -528,7 +504,6 @@ extern int validate_debug_offsets(struct _Py_DebugOffsets *debug_offsets); * ============================================================================ */ extern int read_ptr(RemoteUnwinderObject *unwinder, uintptr_t address, uintptr_t *result); -extern int read_Py_ssize_t(RemoteUnwinderObject *unwinder, uintptr_t address, Py_ssize_t *result); extern int read_char(RemoteUnwinderObject *unwinder, uintptr_t address, char *result); extern int read_py_ptr(RemoteUnwinderObject *unwinder, uintptr_t address, uintptr_t *ptr_addr); @@ -599,7 +574,6 @@ extern int parse_frame_object( RemoteUnwinderObject *unwinder, PyObject** result, uintptr_t address, - uintptr_t* address_of_code_object, uintptr_t* previous_frame ); @@ -608,7 +582,6 @@ extern int parse_frame_from_chunks( PyObject **result, uintptr_t address, uintptr_t *previous_frame, - uintptr_t *stackpointer, StackChunkList *chunks ); @@ -685,8 +658,6 @@ extern int find_running_frame( uintptr_t *frame ); -extern int get_thread_status(RemoteUnwinderObject *unwinder, uint64_t tid, uint64_t pthread_id); - extern PyObject* unwind_stack_for_thread( RemoteUnwinderObject *unwinder, uintptr_t *current_tstate, @@ -729,33 +700,11 @@ extern int parse_task( PyObject *render_to ); -extern int parse_coro_chain( - RemoteUnwinderObject *unwinder, - uintptr_t coro_address, - PyObject *render_to -); - extern int parse_async_frame_chain( RemoteUnwinderObject *unwinder, PyObject *calls, uintptr_t address_of_thread, - uintptr_t running_task_code_obj -); - -/* Set iteration */ -extern int iterate_set_entries( - RemoteUnwinderObject *unwinder, - uintptr_t set_addr, - set_entry_processor_func processor, - void *context -); - -/* Task awaited_by processing */ -extern int process_task_awaited_by( - RemoteUnwinderObject *unwinder, - uintptr_t task_address, - set_entry_processor_func processor, - void *context + uintptr_t running_task_frame ); extern int process_single_task_node( @@ -765,22 +714,16 @@ extern int process_single_task_node( PyObject *result ); -extern int process_task_and_waiters( - RemoteUnwinderObject *unwinder, - uintptr_t task_addr, - PyObject *result -); - extern int find_running_task_in_thread( RemoteUnwinderObject *unwinder, uintptr_t thread_state_addr, uintptr_t *running_task_addr ); -extern int get_task_code_object( +extern int get_task_frame( RemoteUnwinderObject *unwinder, uintptr_t task_addr, - uintptr_t *code_obj_addr + uintptr_t *frame_addr ); extern int append_awaited_by( diff --git a/Modules/_remote_debugging/asyncio.c b/Modules/_remote_debugging/asyncio.c index 44a9a3cbce0061a..165d32ad31308bb 100644 --- a/Modules/_remote_debugging/asyncio.c +++ b/Modules/_remote_debugging/asyncio.c @@ -22,7 +22,7 @@ _Py_RemoteDebug_GetAsyncioDebugAddress(proc_handle_t* handle) address = search_windows_map_for_section(handle, "AsyncioD", L"_asyncio", NULL); if (address == 0) { - if (!_Py_RemoteDebug_HasPermissionError()) { + if (!_Py_RemoteDebug_IsFatalReadError()) { PyObject *exc = PyErr_GetRaisedException(); PyErr_SetString(PyExc_RuntimeError, "Failed to find the AsyncioDebug section in the process."); _PyErr_ChainExceptions1(exc); @@ -33,23 +33,16 @@ _Py_RemoteDebug_GetAsyncioDebugAddress(proc_handle_t* handle) address = search_linux_map_for_section(handle, "AsyncioDebug", "python", NULL); if (address == 0) { - if (!_Py_RemoteDebug_HasPermissionError()) { + if (!_Py_RemoteDebug_IsFatalReadError()) { PyObject *exc = PyErr_GetRaisedException(); PyErr_SetString(PyExc_RuntimeError, "Failed to find the AsyncioDebug section in the process."); _PyErr_ChainExceptions1(exc); } } #elif defined(__APPLE__) && TARGET_OS_OSX - // On macOS, try libpython first, then fall back to python - address = search_map_for_section(handle, "AsyncioDebug", "libpython", - NULL); - if (address == 0 && !_Py_RemoteDebug_HasPermissionError()) { - PyErr_Clear(); - address = search_map_for_section(handle, "AsyncioDebug", "python", - NULL); - } + address = search_loaded_images_for_section(handle, "AsyncioDebug", NULL); if (address == 0) { - if (!_Py_RemoteDebug_HasPermissionError()) { + if (!_Py_RemoteDebug_IsFatalReadError()) { PyObject *exc = PyErr_GetRaisedException(); PyErr_SetString(PyExc_RuntimeError, "Failed to find the AsyncioDebug section in the process."); _PyErr_ChainExceptions1(exc); @@ -99,12 +92,22 @@ ensure_async_debug_offsets(RemoteUnwinderObject *unwinder) return -1; } if (result < 0) { - if (!_Py_RemoteDebug_HasPermissionError()) { - PyErr_Clear(); - PyErr_SetString(PyExc_RuntimeError, "AsyncioDebug section not available"); - set_exception_cause(unwinder, PyExc_RuntimeError, - "AsyncioDebug section unavailable - asyncio module may not be loaded in target process"); + if (_Py_RemoteDebug_IsFatalReadError()) { + return -1; + } + PyErr_Clear(); + /* Image discovery can fail without reporting that the target exited. + Read a known runtime address before reporting unavailable asyncio. */ + char runtime_byte; + if (_Py_RemoteDebug_ReadRemoteMemory(&unwinder->handle, + unwinder->runtime_start_address, sizeof(runtime_byte), + &runtime_byte) < 0) + { + return -1; } + PyErr_SetString(PyExc_RuntimeError, "AsyncioDebug section not available"); + set_exception_cause(unwinder, PyExc_RuntimeError, + "AsyncioDebug section unavailable - asyncio module may not be loaded in target process"); return -1; } @@ -116,12 +119,11 @@ ensure_async_debug_offsets(RemoteUnwinderObject *unwinder) * SET ITERATION FUNCTIONS * ============================================================================ */ -int +static int iterate_set_entries( RemoteUnwinderObject *unwinder, uintptr_t set_addr, - set_entry_processor_func processor, - void *context + PyObject *awaited_by ) { char set_object[SIZEOF_SET_OBJ]; if (_Py_RemoteDebug_PagedReadRemoteMemory(&unwinder->handle, set_addr, @@ -146,28 +148,22 @@ iterate_set_entries( Py_ssize_t i = 0; Py_ssize_t els = 0; while (i < set_len && els < num_els) { - uintptr_t key_addr; - if (read_py_ptr(unwinder, table_ptr, &key_addr) < 0) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read set entry key"); + setentry entry; + if (_Py_RemoteDebug_PagedReadRemoteMemory( + &unwinder->handle, table_ptr, sizeof(entry), &entry) < 0) + { + set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read set entry"); return -1; } - if ((void*)key_addr != NULL) { - Py_ssize_t ref_cnt; - if (read_Py_ssize_t(unwinder, table_ptr, &ref_cnt) < 0) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read set entry ref count"); + uintptr_t key_addr = (uintptr_t)entry.key; + if (key_addr != 0 && entry.hash != -1) { + if (parse_task(unwinder, key_addr, awaited_by) < 0) { return -1; } - - if (ref_cnt) { - // Process this valid set entry - if (processor(unwinder, key_addr, context) < 0) { - return -1; - } - els++; - } + els++; } - table_ptr += sizeof(void*) * 2; + table_ptr += sizeof(entry); i++; } @@ -247,13 +243,67 @@ parse_task_name( * COROUTINE CHAIN PARSING * ============================================================================ */ +// gh-159620 +/* Return in *coro_addr the coroutine, generator or async generator to walk + for the awaitable at addr, or 0 if it is none (for example, a future). */ +static int +get_coro_like_address( + RemoteUnwinderObject *unwinder, + uintptr_t addr, + uintptr_t *coro_addr +) { + *coro_addr = 0; + + // Skip user classes that share a name with the generator types below + uintptr_t type_addr; + unsigned long tp_flags; + if (read_ptr(unwinder, addr + (uintptr_t)unwinder->debug_offsets.pyobject.ob_type, + &type_addr) < 0 + || _Py_RemoteDebug_PagedReadRemoteMemory(&unwinder->handle, + type_addr + (uintptr_t)unwinder->debug_offsets.type_object.tp_flags, + sizeof(tp_flags), &tp_flags) < 0) + { + set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read awaitable type"); + return -1; + } + + if (tp_flags & Py_TPFLAGS_HEAPTYPE) { + return 0; + } + + uintptr_t name_addr; + char name[32] = {0}; + if (read_ptr(unwinder, type_addr + (uintptr_t)unwinder->debug_offsets.type_object.tp_name, + &name_addr) < 0 + || _Py_RemoteDebug_PagedReadRemoteMemory(&unwinder->handle, name_addr, + sizeof(name) - 1, name) < 0) + { + set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read awaitable type name"); + return -1; + } + + if (strcmp(name, "coroutine") == 0 || strcmp(name, "generator") == 0) { + *coro_addr = addr; + } + else if (strcmp(name, "async_generator_asend") == 0 + || strcmp(name, "async_generator_athrow") == 0) + { + // asend and athrow are separate wrapper objects: read the pointer + // to their parent async generator, stored right after PyObject_HEAD + return read_ptr(unwinder, addr + (uintptr_t)unwinder->debug_offsets.pyobject.size, + coro_addr); + } + return 0; +} + static int -handle_yield_from_frame( +get_awaited_coro_address( RemoteUnwinderObject *unwinder, uintptr_t gi_iframe_addr, - uintptr_t gen_type_addr, - PyObject *render_to + uintptr_t *next_coro ) { + *next_coro = 0; + // Read the entire interpreter frame at once char iframe[SIZEOF_INTERP_FRAME]; int err = _Py_RemoteDebug_PagedReadRemoteMemory( @@ -277,51 +327,20 @@ handle_yield_from_frame( uintptr_t stackpointer_addr = GET_MEMBER_NO_TAG(uintptr_t, iframe, unwinder->debug_offsets.interpreter_frame.stackpointer); if ((void*)stackpointer_addr != NULL) { - uintptr_t gi_await_addr; err = read_py_ptr( unwinder, stackpointer_addr - sizeof(void*) * 2, - &gi_await_addr); + next_coro); if (err) { set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read gi_await address"); return -1; } - - if ((void*)gi_await_addr != NULL) { - uintptr_t gi_await_addr_type_addr; - err = read_ptr( - unwinder, - gi_await_addr + (uintptr_t)unwinder->debug_offsets.pyobject.ob_type, - &gi_await_addr_type_addr); - if (err) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read gi_await type address"); - return -1; - } - - if (gen_type_addr == gi_await_addr_type_addr) { - /* This needs an explanation. We always start with parsing - native coroutine / generator frames. Ultimately they - are awaiting on something. That something can be - a native coroutine frame or... an iterator. - If it's the latter -- we can't continue building - our chain. So the condition to bail out of this is - to do that when the type of the current coroutine - doesn't match the type of whatever it points to - in its cr_await. - */ - err = parse_coro_chain(unwinder, gi_await_addr, render_to); - if (err) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to parse coroutine chain in yield_from"); - return -1; - } - } - } } return 0; } -int +static int parse_coro_chain( RemoteUnwinderObject *unwinder, uintptr_t coro_address, @@ -329,49 +348,67 @@ parse_coro_chain( ) { assert((void*)coro_address != NULL); - // Read the entire generator object at once - char gen_object[SIZEOF_GEN_OBJ]; - int err = _Py_RemoteDebug_PagedReadRemoteMemory( - &unwinder->handle, - coro_address, - SIZEOF_GEN_OBJ, - gen_object); - if (err < 0) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read generator object in coro chain"); - return -1; - } + for (size_t depth = 0; (void*)coro_address != NULL; depth++) { + if (depth >= MAX_FRAME_CHAIN_DEPTH) { + PyErr_SetString(PyExc_RuntimeError, + "Too many coroutine frames (possible infinite loop)"); + set_exception_cause(unwinder, PyExc_RuntimeError, + "Coroutine chain depth limit exceeded"); + return -1; + } - int8_t frame_state = GET_MEMBER(int8_t, gen_object, unwinder->debug_offsets.gen_object.gi_frame_state); - if (frame_state == FRAME_CLEARED) { - return 0; - } + if (get_coro_like_address(unwinder, coro_address, &coro_address) < 0) { + return -1; + } + if ((void*)coro_address == NULL) { + return 0; + } - uintptr_t gen_type_addr = GET_MEMBER(uintptr_t, gen_object, unwinder->debug_offsets.pyobject.ob_type); + // Read the entire generator object at once + char gen_object[SIZEOF_GEN_OBJ]; + int err = _Py_RemoteDebug_PagedReadRemoteMemory( + &unwinder->handle, + coro_address, + SIZEOF_GEN_OBJ, + gen_object); + if (err < 0) { + set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read generator object in coro chain"); + return -1; + } - PyObject* name = NULL; + int8_t frame_state = GET_MEMBER(int8_t, gen_object, unwinder->debug_offsets.gen_object.gi_frame_state); + if (frame_state == FRAME_CLEARED) { + return 0; + } - // Parse the previous frame using the gi_iframe from local copy - uintptr_t prev_frame; - uintptr_t gi_iframe_addr = coro_address + (uintptr_t)unwinder->debug_offsets.gen_object.gi_iframe; - uintptr_t address_of_code_object = 0; - if (parse_frame_object(unwinder, &name, gi_iframe_addr, &address_of_code_object, &prev_frame) < 0) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to parse frame object in coro chain"); - return -1; - } + PyObject* name = NULL; - if (!name) { - return 0; - } + // Parse the previous frame using the gi_iframe from local copy + uintptr_t prev_frame; + uintptr_t gi_iframe_addr = coro_address + (uintptr_t)unwinder->debug_offsets.gen_object.gi_iframe; + if (parse_frame_object(unwinder, &name, gi_iframe_addr, &prev_frame) < 0) { + set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to parse frame object in coro chain"); + return -1; + } + + if (!name) { + return 0; + } - if (PyList_Append(render_to, name)) { + if (PyList_Append(render_to, name)) { + Py_DECREF(name); + set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to append frame to coro chain"); + return -1; + } Py_DECREF(name); - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to append frame to coro chain"); - return -1; - } - Py_DECREF(name); - if (frame_state == FRAME_SUSPENDED_YIELD_FROM) { - return handle_yield_from_frame(unwinder, gi_iframe_addr, gen_type_addr, render_to); + if (frame_state != FRAME_SUSPENDED_YIELD_FROM) { + return 0; + } + + if (get_awaited_coro_address(unwinder, gi_iframe_addr, &coro_address) < 0) { + return -1; + } } return 0; @@ -384,13 +421,12 @@ parse_coro_chain( static PyObject* create_task_result( RemoteUnwinderObject *unwinder, - uintptr_t task_address + uintptr_t task_address, + char is_task ) { PyObject* result = NULL; PyObject *call_stack = NULL; PyObject *tn = NULL; - char task_obj[SIZEOF_TASK_OBJ]; - uintptr_t coro_addr; // Create call_stack first since it's the first tuple element call_stack = PyList_New(0); @@ -406,25 +442,27 @@ create_task_result( goto error; } - // Parse coroutine chain - if (_Py_RemoteDebug_PagedReadRemoteMemory(&unwinder->handle, task_address, - (size_t)unwinder->async_debug_offsets.asyncio_task_object.size, - task_obj) < 0) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read task object for coro chain"); - goto error; - } - - coro_addr = GET_MEMBER_NO_TAG(uintptr_t, task_obj, unwinder->async_debug_offsets.asyncio_task_object.task_coro); - - if ((void*)coro_addr != NULL) { - if (parse_coro_chain(unwinder, coro_addr, call_stack) < 0) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to parse coroutine chain"); + if (is_task) { + char task_obj[SIZEOF_TASK_OBJ]; + if (_Py_RemoteDebug_PagedReadRemoteMemory(&unwinder->handle, task_address, + (size_t)unwinder->async_debug_offsets.asyncio_task_object.size, + task_obj) < 0) { + set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read task object for coro chain"); goto error; } - if (PyList_Reverse(call_stack)) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to reverse call stack"); - goto error; + uintptr_t coro_addr = GET_MEMBER_NO_TAG(uintptr_t, task_obj, unwinder->async_debug_offsets.asyncio_task_object.task_coro); + + if ((void*)coro_addr != NULL) { + if (parse_coro_chain(unwinder, coro_addr, call_stack) < 0) { + set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to parse coroutine chain"); + goto error; + } + + if (PyList_Reverse(call_stack)) { + set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to reverse call stack"); + goto error; + } } } @@ -468,33 +506,10 @@ parse_task( goto error; } - if (is_task) { - result = create_task_result(unwinder, task_address); - if (!result) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to create task result"); - goto error; - } - } else { - // Create an empty CoroInfo for non-task objects - RemoteDebuggingState *state = RemoteDebugging_GetStateFromObject((PyObject*)unwinder); - result = PyStructSequence_New(state->CoroInfo_Type); - if (result == NULL) { - set_exception_cause(unwinder, PyExc_MemoryError, "Failed to create empty CoroInfo"); - goto error; - } - PyObject *empty_list = PyList_New(0); - if (empty_list == NULL) { - set_exception_cause(unwinder, PyExc_MemoryError, "Failed to create empty list"); - goto error; - } - PyObject *task_name = PyLong_FromUnsignedLongLong(task_address); - if (task_name == NULL) { - Py_DECREF(empty_list); - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to create task name"); - goto error; - } - PyStructSequence_SetItem(result, 0, empty_list); // This steals the reference - PyStructSequence_SetItem(result, 1, task_name); // This steals the reference + result = create_task_result(unwinder, task_address, is_task); + if (result == NULL) { + set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to create task result"); + goto error; } if (PyList_Append(render_to, result)) { set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to append task result to render list"); @@ -513,40 +528,17 @@ parse_task( * TASK AWAITED_BY PROCESSING * ============================================================================ */ -// Forward declaration for mutual recursion -static int process_waiter_task(RemoteUnwinderObject *unwinder, uintptr_t key_addr, void *context); - -// Processor function for parsing tasks in sets -static int -process_task_parser( - RemoteUnwinderObject *unwinder, - uintptr_t key_addr, - void *context -) { - PyObject *awaited_by = (PyObject *)context; - return parse_task(unwinder, key_addr, awaited_by); -} - static int parse_task_awaited_by( RemoteUnwinderObject *unwinder, uintptr_t task_address, PyObject *awaited_by ) { - return process_task_awaited_by(unwinder, task_address, process_task_parser, awaited_by); -} - -int -process_task_awaited_by( - RemoteUnwinderObject *unwinder, - uintptr_t task_address, - set_entry_processor_func processor, - void *context -) { - // Read the entire TaskObj at once char task_obj[SIZEOF_TASK_OBJ]; + size_t size = unwinder->async_debug_offsets.asyncio_task_object.task_awaited_by_is_set + + sizeof(char); if (_Py_RemoteDebug_PagedReadRemoteMemory(&unwinder->handle, task_address, - (size_t)unwinder->async_debug_offsets.asyncio_task_object.size, + size, task_obj) < 0) { set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read task object"); return -1; @@ -560,10 +552,10 @@ process_task_awaited_by( char awaited_by_is_a_set = GET_MEMBER(char, task_obj, unwinder->async_debug_offsets.asyncio_task_object.task_awaited_by_is_set); if (awaited_by_is_a_set) { - return iterate_set_entries(unwinder, task_ab_addr, processor, context); + return iterate_set_entries(unwinder, task_ab_addr, awaited_by); } else { // Single task waiting - return processor(unwinder, task_ab_addr, context); + return parse_task(unwinder, task_ab_addr, awaited_by); } } @@ -580,7 +572,16 @@ process_single_task_node( PyObject *result_item = NULL; PyObject *coroutine_stack = NULL; - tn = parse_task_name(unwinder, task_addr); + char is_task; + // task_is_task = 1 => task + // task_is_task = 0 => future + if (read_char(unwinder, + task_addr + unwinder->async_debug_offsets.asyncio_task_object.task_is_task, + &is_task) < 0) { + goto error; + } + tn = is_task ? parse_task_name(unwinder, task_addr) + : PyUnicode_FromFormat("Future-%p", (void *)task_addr); if (tn == NULL) { set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to parse task name in single task node"); goto error; @@ -621,6 +622,7 @@ process_single_task_node( PyStructSequence_SetItem(result_item, 1, tn); // steals ref PyStructSequence_SetItem(result_item, 2, coroutine_stack); // steals ref PyStructSequence_SetItem(result_item, 3, current_awaited_by); // steals ref + PyStructSequence_SetItem(result_item, 4, PyBool_FromLong(!is_task)); // References transferred to tuple task_id = NULL; @@ -658,30 +660,71 @@ process_single_task_node( return -1; } -int -process_task_and_waiters( +static int +process_task_waiters( RemoteUnwinderObject *unwinder, - uintptr_t task_addr, - PyObject *result + PyObject *result, + bool futures_only ) { - // First, add this task to the result - if (process_single_task_node(unwinder, task_addr, NULL, result) < 0) { + Py_ssize_t initial_count = futures_only ? PyList_GET_SIZE(result) : 0; + PyObject *visited = PySet_New(NULL); + if (visited == NULL) { return -1; } + for (Py_ssize_t i = 0; i < PyList_GET_SIZE(result); i++) { + PyObject *task_info = PyList_GET_ITEM(result, i); + if (PySet_Add(visited, PyStructSequence_GET_ITEM(task_info, 0)) < 0) { + goto error; + } + PyObject *waiters = PyStructSequence_GET_ITEM(task_info, 3); + for (Py_ssize_t j = 0; j < PyList_GET_SIZE(waiters); j++) { + PyObject *waiter = PyList_GET_ITEM(waiters, j); + PyObject *task_id = PyStructSequence_GET_ITEM(waiter, 1); + int seen = PySet_Contains(visited, task_id); + if (seen > 0) { + continue; + } + if (seen < 0 || PySet_Add(visited, task_id) < 0) { + goto error; + } + void *task_ptr = PyLong_AsVoidPtr(task_id); + if (task_ptr == NULL && PyErr_Occurred()) { + set_exception_cause(unwinder, PyExc_RuntimeError, + "Failed to parse waiter task ID"); + goto error; + } + if (futures_only) { + char is_task; + if (read_char(unwinder, + (uintptr_t)task_ptr + unwinder->async_debug_offsets.asyncio_task_object.task_is_task, + &is_task) < 0) { + goto error; + } + if (is_task) { + continue; + } + } + if (PyList_GET_SIZE(result) - initial_count >= MAX_TASK_WAITER_WALK_TASKS) { + PyErr_SetString(PyExc_RuntimeError, + "Too many task waiters (possible infinite loop)"); + set_exception_cause(unwinder, PyExc_RuntimeError, + "Task waiter walk size limit exceeded"); + goto error; + } + if (process_single_task_node( + unwinder, (uintptr_t)task_ptr, NULL, result) < 0) + { + goto error; + } + } + } - // Now find all tasks that are waiting for this task and process them - return process_task_awaited_by(unwinder, task_addr, process_waiter_task, result); -} + Py_DECREF(visited); + return 0; -// Processor function for task waiters -static int -process_waiter_task( - RemoteUnwinderObject *unwinder, - uintptr_t key_addr, - void *context -) { - PyObject *result = (PyObject *)context; - return process_task_and_waiters(unwinder, key_addr, result); +error: + Py_DECREF(visited); + return -1; } /* ============================================================================ @@ -724,7 +767,7 @@ find_running_task_in_thread( } int -get_task_code_object(RemoteUnwinderObject *unwinder, uintptr_t task_addr, uintptr_t *code_obj_addr) { +get_task_frame(RemoteUnwinderObject *unwinder, uintptr_t task_addr, uintptr_t *frame_addr) { uintptr_t running_coro_addr = 0; if(read_py_ptr( @@ -741,21 +784,15 @@ get_task_code_object(RemoteUnwinderObject *unwinder, uintptr_t task_addr, uintpt return -1; } - // note: genobject's gi_iframe is an embedded struct so the address to - // the offset leads directly to its first field: f_executable - if (read_py_ptr( - unwinder, - running_coro_addr + (uintptr_t)unwinder->debug_offsets.gen_object.gi_iframe, code_obj_addr) < 0) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read running task code object"); + if (get_coro_like_address(unwinder, running_coro_addr, &running_coro_addr) < 0) { return -1; } - - if (*code_obj_addr == 0) { - PyErr_SetString(PyExc_RuntimeError, "Running task code object is NULL"); - set_exception_cause(unwinder, PyExc_RuntimeError, "Running task code object address is NULL"); - return -1; + if (running_coro_addr == 0) { + *frame_addr = 0; + return 0; } + *frame_addr = running_coro_addr + (uintptr_t)unwinder->debug_offsets.gen_object.gi_iframe; return 0; } @@ -768,22 +805,29 @@ parse_async_frame_chain( RemoteUnwinderObject *unwinder, PyObject *calls, uintptr_t address_of_thread, - uintptr_t running_task_code_obj + uintptr_t running_task_frame ) { + Py_ssize_t coro_chain_size = PyList_GET_SIZE(calls); uintptr_t address_of_current_frame; if (find_running_frame(unwinder, address_of_thread, &address_of_current_frame) < 0) { set_exception_cause(unwinder, PyExc_RuntimeError, "Running frame search failed in async chain"); return -1; } + size_t frame_count = 0; while ((void*)address_of_current_frame != NULL) { + if (++frame_count > MAX_FRAME_CHAIN_DEPTH) { + PyErr_SetString(PyExc_RuntimeError, "Too many async stack frames (possible infinite loop)"); + set_exception_cause(unwinder, PyExc_RuntimeError, "Async frame chain iteration limit exceeded"); + return -1; + } PyObject* frame_info = NULL; - uintptr_t address_of_code_object; + + uintptr_t this_frame = address_of_current_frame; int res = parse_frame_object( unwinder, &frame_info, address_of_current_frame, - &address_of_code_object, &address_of_current_frame ); @@ -804,12 +848,15 @@ parse_async_frame_chain( Py_DECREF(frame_info); - if (address_of_code_object == running_task_code_obj) { - break; + // Stop at the task's own frame. Code objects are shared by + // recursive calls, so they cannot identify it. + if (this_frame == running_task_frame) { + return PyList_SetSlice(calls, 0, coro_chain_size, NULL); } } - return 0; + // gh-159645: keep the coroutine chain if the task's frame was not found. + return PyList_SetSlice(calls, coro_chain_size, PY_SSIZE_T_MAX, NULL); } /* ============================================================================ @@ -870,11 +917,11 @@ append_awaited_by_for_thread( return 0; } -int -append_awaited_by( +static int +append_awaited_info( RemoteUnwinderObject *unwinder, unsigned long tid, - uintptr_t head_addr, + PyObject *task_list, PyObject *result) { PyObject *tid_py = PyLong_FromUnsignedLong(tid); @@ -883,24 +930,16 @@ append_awaited_by( return -1; } - PyObject* awaited_by_for_thread = PyList_New(0); - if (awaited_by_for_thread == NULL) { - Py_DECREF(tid_py); - set_exception_cause(unwinder, PyExc_MemoryError, "Failed to create awaited_by thread list"); - return -1; - } - RemoteDebuggingState *state = RemoteDebugging_GetStateFromObject((PyObject*)unwinder); PyObject *result_item = PyStructSequence_New(state->AwaitedInfo_Type); if (result_item == NULL) { Py_DECREF(tid_py); - Py_DECREF(awaited_by_for_thread); set_exception_cause(unwinder, PyExc_MemoryError, "Failed to create AwaitedInfo"); return -1; } - PyStructSequence_SetItem(result_item, 0, tid_py); // steals ref - PyStructSequence_SetItem(result_item, 1, awaited_by_for_thread); // steals ref + PyStructSequence_SetItem(result_item, 0, tid_py); + PyStructSequence_SetItem(result_item, 1, Py_NewRef(task_list)); if (PyList_Append(result, result_item)) { Py_DECREF(result_item); set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to append awaited_by result item"); @@ -908,13 +947,35 @@ append_awaited_by( } Py_DECREF(result_item); - if (append_awaited_by_for_thread(unwinder, head_addr, awaited_by_for_thread)) - { + return 0; +} + +int +append_awaited_by( + RemoteUnwinderObject *unwinder, + unsigned long tid, + uintptr_t head_addr, + PyObject *result) +{ + PyObject *task_list = PyList_New(0); + if (task_list == NULL) { + set_exception_cause(unwinder, PyExc_MemoryError, "Failed to create awaited_by thread list"); + return -1; + } + + if (append_awaited_info(unwinder, tid, task_list, result) < 0) { + Py_DECREF(task_list); + return -1; + } + + int err = append_awaited_by_for_thread(unwinder, head_addr, task_list); + Py_DECREF(task_list); + if (err < 0) { set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to append awaited_by for thread"); return -1; } - return 0; + return process_task_waiters(unwinder, task_list, true); } /* ============================================================================ @@ -940,8 +1001,8 @@ process_running_task_chain( uintptr_t thread_state_addr, PyObject *result ) { - uintptr_t running_task_code_obj = 0; - if(get_task_code_object(unwinder, running_task_addr, &running_task_code_obj) < 0) { + uintptr_t running_task_frame = 0; + if(get_task_frame(unwinder, running_task_addr, &running_task_frame) < 0) { return -1; } @@ -951,6 +1012,11 @@ process_running_task_chain( return -1; } + // gh-159645: non-native coroutines have no frame to look for. + if (running_task_frame == 0) { + return process_task_waiters(unwinder, result, false); + } + // Get the chain from the current frame to this task PyObject *coro_chain = PyStructSequence_GET_ITEM(task_info, 2); assert(coro_chain != NULL); @@ -966,19 +1032,13 @@ process_running_task_chain( PyObject *frame_chain = PyStructSequence_GET_ITEM(coro_info, 0); assert(frame_chain != NULL); - // Clear the coro_chain - if (PyList_Clear(frame_chain) < 0) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to clear coroutine chain"); - return -1; - } - // Add the chain from the current frame to this task - if (parse_async_frame_chain(unwinder, frame_chain, thread_state_addr, running_task_code_obj) < 0) { + if (parse_async_frame_chain(unwinder, frame_chain, thread_state_addr, running_task_frame) < 0) { return -1; } // Now find all tasks that are waiting for this task and process them - if (process_task_awaited_by(unwinder, running_task_addr, process_waiter_task, result) < 0) { + if (process_task_waiters(unwinder, result, false) < 0) { return -1; } @@ -1014,32 +1074,9 @@ process_thread_for_async_stack_trace( return -1; } - // Create AwaitedInfo structure for this thread - PyObject *tid_py = PyLong_FromUnsignedLong(tid); - if (tid_py == NULL) { - Py_DECREF(task_list); - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to create thread ID"); - return -1; - } - - RemoteDebuggingState *state = RemoteDebugging_GetStateFromObject((PyObject*)unwinder); - PyObject *awaited_info = PyStructSequence_New(state->AwaitedInfo_Type); - if (awaited_info == NULL) { - Py_DECREF(tid_py); - Py_DECREF(task_list); - set_exception_cause(unwinder, PyExc_MemoryError, "Failed to create AwaitedInfo"); - return -1; - } - - PyStructSequence_SetItem(awaited_info, 0, tid_py); // steals ref - PyStructSequence_SetItem(awaited_info, 1, task_list); // steals ref - - if (PyList_Append(result, awaited_info)) { - Py_DECREF(awaited_info); - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to append AwaitedInfo to result"); - return -1; - } - Py_DECREF(awaited_info); + int err = append_awaited_info(unwinder, tid, task_list, result); + Py_DECREF(task_list); + return err; } return 0; diff --git a/Modules/_remote_debugging/binary_io.h b/Modules/_remote_debugging/binary_io.h index 8c34668ab15ae7e..b89bb9bbedf67d2 100644 --- a/Modules/_remote_debugging/binary_io.h +++ b/Modules/_remote_debugging/binary_io.h @@ -2,7 +2,7 @@ * Python Remote Debugging Module - Binary I/O Header * * This header provides declarations for high-performance binary file I/O - * for profiling data with optional zstd streaming compression. + * for profiling data with optional zstd compression. ******************************************************************************/ #ifndef Py_BINARY_IO_H @@ -23,7 +23,7 @@ extern "C" { #define BINARY_FORMAT_MAGIC 0x54414348 /* "TACH" (Tachyon) in native byte order */ #define BINARY_FORMAT_MAGIC_SWAPPED 0x48434154 /* Byte-swapped magic for endianness detection */ -#define BINARY_FORMAT_VERSION 1 +#define BINARY_FORMAT_VERSION 2 /* Sentinel values for optional frame fields */ #define OPCODE_NONE 255 /* No opcode captured (u8 sentinel) */ @@ -59,23 +59,40 @@ extern "C" { #define HDR_SIZE_FRAME_TABLE 8 #define HDR_OFF_COMPRESSION (HDR_OFF_FRAME_TABLE + HDR_SIZE_FRAME_TABLE) #define HDR_SIZE_COMPRESSION 4 -#define FILE_HEADER_SIZE (HDR_OFF_COMPRESSION + HDR_SIZE_COMPRESSION) +#define HDR_OFF_CONFIG (HDR_OFF_COMPRESSION + HDR_SIZE_COMPRESSION) +#define HDR_SIZE_CONFIG 4 +#define FILE_HEADER_SIZE (HDR_OFF_CONFIG + HDR_SIZE_CONFIG) #define FILE_HEADER_PLACEHOLDER_SIZE 64 static_assert(FILE_HEADER_SIZE <= FILE_HEADER_PLACEHOLDER_SIZE, "FILE_HEADER_SIZE exceeds FILE_HEADER_PLACEHOLDER_SIZE"); -/* Sample header field offsets and sizes */ -#define SMP_OFF_THREAD_ID 0 -#define SMP_SIZE_THREAD_ID sizeof(uint64_t) -#define SMP_OFF_INTERPRETER_ID (SMP_OFF_THREAD_ID + SMP_SIZE_THREAD_ID) -#define SMP_SIZE_INTERPRETER_ID sizeof(uint32_t) -#define SMP_OFF_ENCODING (SMP_OFF_INTERPRETER_ID + SMP_SIZE_INTERPRETER_ID) -#define SMP_SIZE_ENCODING sizeof(uint8_t) -#define SAMPLE_HEADER_FIXED_SIZE (SMP_OFF_ENCODING + SMP_SIZE_ENCODING) - -static_assert(SAMPLE_HEADER_FIXED_SIZE == 13, - "SAMPLE_HEADER_FIXED_SIZE must remain 13"); +/* Sample blocks */ +#define BLOCK_MAGIC "TBLK" +#define BLOCK_MAGIC_SIZE (sizeof(BLOCK_MAGIC) - 1) +#define MAX_BLOCK_SIZE (1024 * 1024) +#define MAX_BLOCK_STREAMS 4096 + +/* Block columns */ +enum { + COLUMN_STREAM_TABLE, + COLUMN_SAMPLE_STREAM_IDS, + COLUMN_TIMESTAMP_RESIDUALS, + COLUMN_STATUS_BITMAPS, + COLUMN_STACK_INSTRUCTIONS, + COLUMN_FRAME_IDS, + COLUMN_COUNT +}; + +/* Stream table entry offsets and sizes */ +#define STM_OFF_THREAD_ID 0 +#define STM_SIZE_THREAD_ID sizeof(uint64_t) +#define STM_OFF_INTERPRETER_ID (STM_OFF_THREAD_ID + STM_SIZE_THREAD_ID) +#define STM_SIZE_INTERPRETER_ID sizeof(uint32_t) +#define STREAM_ENTRY_SIZE (STM_OFF_INTERPRETER_ID + STM_SIZE_INTERPRETER_ID) + +static_assert(STREAM_ENTRY_SIZE == 12, + "STREAM_ENTRY_SIZE must remain 12"); /* Footer field offsets and sizes */ #define FTR_OFF_STRINGS 0 @@ -91,32 +108,79 @@ static_assert(SAMPLE_HEADER_FIXED_SIZE == 13, static_assert(FILE_FOOTER_SIZE == 32, "FILE_FOOTER_SIZE must remain 32"); +/* Optional profiling statistics immediately precede the footer. The + * signature and size live at the end so readers can discover extensions + * without changing the fixed header or moving streamed sample data. */ +#define PROFILE_STATS_MAGIC "TACHSTAT" +#define PROFILE_STATS_MAGIC_SIZE 8 +#define PROFILE_STATS_VERSION 1 +#define PST_OFF_DURATION 0 +#define PST_SIZE_DURATION 8 +#define PST_OFF_SAMPLE_RATE (PST_OFF_DURATION + PST_SIZE_DURATION) +#define PST_SIZE_SAMPLE_RATE 8 +#define PST_OFF_ERROR_RATE (PST_OFF_SAMPLE_RATE + PST_SIZE_SAMPLE_RATE) +#define PST_SIZE_ERROR_RATE 8 +#define PST_OFF_MISSED_SAMPLES (PST_OFF_ERROR_RATE + PST_SIZE_ERROR_RATE) +#define PST_SIZE_MISSED_SAMPLES 8 +#define PST_OFF_PRESENT (PST_OFF_MISSED_SAMPLES + PST_SIZE_MISSED_SAMPLES) +#define PST_SIZE_PRESENT 4 +#define PST_OFF_RESERVED (PST_OFF_PRESENT + PST_SIZE_PRESENT) +#define PST_SIZE_RESERVED 4 +#define PST_OFF_MAGIC (PST_OFF_RESERVED + PST_SIZE_RESERVED) +#define PST_OFF_VERSION (PST_OFF_MAGIC + PROFILE_STATS_MAGIC_SIZE) +#define PST_SIZE_VERSION 4 +#define PST_OFF_SIZE (PST_OFF_VERSION + PST_SIZE_VERSION) +#define PST_SIZE_SIZE 4 +#define PROFILE_STATS_SIZE (PST_OFF_SIZE + PST_SIZE_SIZE) +#define PROFILE_STATS_V1_SIZE 32 +#define PROFILE_STATS_ERROR_RATE 0x01 +#define PROFILE_STATS_MISSED 0x02 + +static_assert(PROFILE_STATS_SIZE == 56, + "PROFILE_STATS_SIZE must remain 56"); + /* Minimum on-disk bytes of a string (1) and frame (7) table entry. */ #define MIN_STRING_ENTRY_SIZE 1 #define MIN_FRAME_ENTRY_SIZE 7 -/* Buffer sizes: 512KB balances syscall amortization against memory use, - * and aligns well with filesystem block sizes and zstd dictionary windows */ -#define WRITE_BUFFER_SIZE (512 * 1024) -#define COMPRESSED_BUFFER_SIZE (512 * 1024) - /* Compression types */ #define COMPRESSION_NONE 0 #define COMPRESSION_ZSTD 1 +#define COLUMN_CONSTANT 2 /* Column stored as one repeated byte */ + +/* Profiling configuration. The mode occupies the low three bits and is + * stored plus one so zero remains compatible with files written before this + * field was defined. Capture features are valid when bit 3 is set. */ +#define PROFILING_CONFIG_MODE_MASK 0x7U +#define PROFILING_CONFIG_FEATURES_KNOWN (1U << 3) +#define PROFILING_CONFIG_FEATURES_SHIFT 4 +#define PROFILING_FEATURE_ALL_THREADS (1U << 0) +#define PROFILING_FEATURE_NATIVE (1U << 1) +#define PROFILING_FEATURE_GC (1U << 2) +#define PROFILING_FEATURE_OPCODES (1U << 3) +#define PROFILING_FEATURE_BLOCKING (1U << 4) +#define PROFILING_FEATURE_MASK 0x1FU /* Stack encoding types for delta compression */ #define STACK_REPEAT 0x00 /* RLE: identical to previous, with count */ -#define STACK_FULL 0x01 /* Full stack (first sample or no match) */ -#define STACK_SUFFIX 0x02 /* Shares N frames from bottom */ -#define STACK_POP_PUSH 0x03 /* Remove M frames, add N frames */ +#define STACK_REPLACE_SUFFIX 0x01 /* Keep outer frames, append new ones */ +#define STACK_REUSE 0x02 /* Stack stored earlier in the block */ /* Maximum stack depth we'll buffer for delta encoding */ #define MAX_STACK_DEPTH 256 +/* Writer's stack cache size per block */ +#define STACK_CACHE_SIZE 4096 +#define STACK_CACHE_BUCKET_SIZE 2 +#define STACK_CACHE_BUCKET_COUNT \ + (STACK_CACHE_SIZE / STACK_CACHE_BUCKET_SIZE) + /* Initial capacities for dynamic arrays - sized to reduce reallocations */ #define INITIAL_STRING_CAPACITY 4096 #define INITIAL_FRAME_CAPACITY 4096 #define INITIAL_THREAD_CAPACITY 256 +#define INITIAL_BLOCK_CAPACITY 256 +#define INITIAL_BLOCK_STREAM_CAPACITY 16 /* ============================================================================ * STATISTICS STRUCTURES @@ -128,7 +192,7 @@ typedef struct { uint64_t repeat_samples; /* Total samples encoded via RLE */ uint64_t full_records; /* Number of full stack records */ uint64_t suffix_records; /* Number of suffix match records */ - uint64_t pop_push_records; /* Number of pop-push records */ + uint64_t reuse_records; /* Number of stack reuse records */ uint64_t total_frames_written;/* Total frame indices written */ uint64_t frames_saved; /* Frames avoided due to delta encoding */ uint64_t bytes_written; /* Total bytes written (before compression) */ @@ -140,7 +204,7 @@ typedef struct { uint64_t repeat_samples; /* Samples decoded from RLE */ uint64_t full_records; /* Full stack records decoded */ uint64_t suffix_records; /* Suffix match records decoded */ - uint64_t pop_push_records; /* Pop-push records decoded */ + uint64_t reuse_records; /* Stack reuse records decoded */ uint64_t total_samples; /* Total samples reconstructed */ uint64_t stack_reconstructions; /* Number of stack array reconstructions */ } BinaryReaderStats; @@ -199,8 +263,6 @@ typedef struct { #else void *cctx; /* Placeholder */ #endif - uint8_t *compressed_buffer; - size_t compressed_buffer_size; } ZstdCompressor; /* Frame entry - combines all frame data for better cache locality. @@ -227,31 +289,93 @@ typedef struct { uint8_t opcode; } FrameKey; -/* Thread entry - tracks per-thread state for delta encoding */ +/* One entry per (thread, interpreter) pair seen in the file */ typedef struct { uint64_t thread_id; - uint64_t prev_timestamp; uint32_t interpreter_id; + /* Stream index in the current block, or UINT32_MAX */ + uint32_t block_stream_index; +} ThreadEntry; + +/* Delta encoding state of a stream, reset with each block */ +typedef struct { + uint64_t prev_timestamp; + size_t thread_index; + uint32_t current_repeat; + /* Previous stack for delta encoding (frame indices, innermost first) */ - uint32_t *prev_stack; size_t prev_stack_depth; - size_t prev_stack_capacity; + uint32_t prev_stack[MAX_STACK_DEPTH]; +} BlockStream; + +/* Limit errors occur before emitting an incomplete sample. Other write + * failures may leave partial records and must prevent finalization. */ +typedef enum { + BINARY_WRITER_OPEN, + BINARY_WRITER_LIMIT_REACHED, + BINARY_WRITER_BROKEN, +} BinaryWriterState; + +/* Byte buffer for block data */ +typedef struct { + uint8_t *data; + size_t size; + size_t capacity; +} ByteBuffer; - /* RLE pending buffer - samples waiting to be written as a repeat group */ - uint8_t *pending_rle; - size_t pending_rle_bytes; - size_t pending_rle_samples; -} ThreadEntry; +/* Column size and encoding */ +typedef struct { + uint32_t decoded_size; + uint32_t stored_size; + uint8_t encoding; +} ColumnDescriptor; + +/* Block header as stored in the file */ +typedef struct { + uint32_t sample_count; + uint64_t base_timestamp; + uint8_t frame_width; + uint8_t common_status_flags; + uint8_t status_bitmap_flags; + ColumnDescriptor columns[COLUMN_COUNT]; +} BlockHeader; + +/* Complete stack that later samples can REUSE */ +typedef struct { + Py_uhash_t hash; + uint32_t offset; + uint32_t depth; +} StackCacheEntry; + +/* REPEAT instruction position and count */ +typedef struct { + uint32_t offset; + uint32_t count; +} Repeat; + +/* Samples buffered until the next flush */ +typedef struct { + ByteBuffer columns[COLUMN_COUNT]; + ByteBuffer repeats; + ByteBuffer transformed; + ByteBuffer compressed; + ByteBuffer output; + StackCacheEntry cache[STACK_CACHE_BUCKET_COUNT][STACK_CACHE_BUCKET_SIZE]; + BlockStream *streams; + size_t stream_capacity; + uint64_t base_timestamp; + uint32_t sample_count; + uint32_t stream_count; + uint32_t max_frame; + size_t size; +} SampleBlock; /* Main binary writer structure */ typedef struct { FILE *fp; - - /* Write buffer for batched I/O */ - uint8_t *write_buffer; - size_t buffer_pos; - size_t buffer_size; + BinaryWriterState state; + SampleBlock *block; /* Compression */ int compression_type; @@ -261,6 +385,14 @@ typedef struct { uint64_t start_time_us; uint64_t sample_interval_us; uint64_t total_samples; + double duration_sec; + double sample_rate; + double error_rate; + double missed_samples; + uint32_t profile_stats_present; + int has_profile_stats; + int profiling_mode; + int capture_features; /* String hash table: PyObject* -> uint32_t index */ _Py_hashtable_t *string_hash; @@ -290,34 +422,57 @@ typedef struct { * BINARY READER STRUCTURES * ============================================================================ */ -/* Per-thread state for stack reconstruction during replay */ +typedef struct { + uint32_t frame_index; + PyObject *frame_info; +} ReaderFrameCacheEntry; + +/* Decoded sample block */ +typedef struct { + BlockHeader header; + uint32_t stream_count; + uint32_t frame_count; + ByteBuffer columns[COLUMN_COUNT]; + const uint32_t *stream_ids; + const uint64_t *timestamps; + const uint8_t *statuses; + const uint32_t *frames; + size_t instruction_offset; + uint32_t frame_offset; +} DecodedBlock; + +/* Per-stream replay state */ typedef struct { uint64_t thread_id; uint32_t interpreter_id; uint64_t prev_timestamp; - - /* Reconstructed stack buffer (frame indices, innermost first) */ - uint32_t *current_stack; + uint32_t current_stack[MAX_STACK_DEPTH]; size_t current_stack_depth; - size_t current_stack_capacity; -} ReaderThreadState; + uint32_t pending_repeats; + int has_stack; + PyObject *batch; + uint8_t batch_status; +} ReaderBlockStream; /* Main binary reader structure */ typedef struct { #if USE_MMAP uint8_t *mapped_data; size_t mapped_size; + size_t page_size; #else FILE *fp; - uint8_t *file_data; size_t file_size; + uint8_t *table_data; + ByteBuffer sample_window; + size_t sample_window_start; #endif /* Decompression state */ int compression_type; - /* Note: ZSTD_DCtx is not stored - created/freed during decompression */ - uint8_t *decompressed_data; - size_t decompressed_size; +#ifdef HAVE_ZSTD + ZSTD_DCtx *dctx; +#endif /* Header metadata */ uint8_t py_major; @@ -328,8 +483,16 @@ typedef struct { uint64_t sample_interval_us; uint64_t sample_count; uint32_t thread_count; + double duration_sec; + double sample_rate; + double error_rate; + double missed_samples; + uint32_t profile_stats_present; + int has_profile_stats; uint64_t string_table_offset; uint64_t frame_table_offset; + int profiling_mode; + int capture_features; /* Parsed string table: array of Python string objects */ PyObject **strings; @@ -338,13 +501,24 @@ typedef struct { /* Parsed frame table: array of FrameEntry structures */ FrameEntry *frames; uint32_t frames_count; + ReaderFrameCacheEntry *frame_info_cache; + size_t frame_info_cache_size; /* Sample data region */ uint8_t *sample_data; size_t sample_data_size; - /* Per-thread state for stack reconstruction (used during replay) */ - ReaderThreadState *thread_states; + ByteBuffer block_data; + ByteBuffer block_stream_ids; + ByteBuffer block_timestamps; + ByteBuffer block_statuses; + ByteBuffer block_frames; + ReaderBlockStream *block_streams; + size_t block_stream_capacity; + int replaying; + + /* Threads seen during replay */ + ThreadEntry *thread_states; size_t thread_state_count; size_t thread_state_capacity; @@ -391,6 +565,14 @@ encode_varint_i32(uint8_t *buf, int32_t value) return encode_varint_u32(buf, zigzag); } +/* Encode signed 64-bit varint (zigzag encoding). Returns bytes written. */ +static inline size_t +encode_varint_i64(uint8_t *buf, int64_t value) +{ + uint64_t zigzag = ((uint64_t)value << 1) ^ (uint64_t)(value >> 63); + return encode_varint_u64(buf, zigzag); +} + /* Decode unsigned 64-bit varint (LEB128). Updates offset only on success. * On error (overflow or incomplete), offset is NOT updated, allowing callers * to detect errors via (offset == prev_offset) check. Sets PyErr on error. */ @@ -454,10 +636,64 @@ decode_varint_i32(const uint8_t *data, size_t *offset, size_t max_size) return (int32_t)((zigzag >> 1) ^ -(int32_t)(zigzag & 1)); } +/* Decode signed 64-bit varint (zigzag encoding). */ +static inline int64_t +decode_varint_i64(const uint8_t *data, size_t *offset, size_t max_size) +{ + size_t saved_offset = *offset; + uint64_t zigzag = decode_varint_u64(data, offset, max_size); + if (*offset == saved_offset) { + return 0; /* decode_varint_u64 already set PyErr */ + } + return (int64_t)((zigzag >> 1) ^ (0 - (zigzag & 1))); +} + /* ============================================================================ * SHARED UTILITY FUNCTIONS * ============================================================================ */ +/* Grow a byte buffer to hold at least size bytes */ +static inline int +buffer_reserve(ByteBuffer *buffer, size_t size) +{ + if (size <= buffer->capacity) { + return 0; + } + size_t capacity = buffer->capacity ? buffer->capacity + : INITIAL_BLOCK_CAPACITY; + while (capacity < size) { + if (capacity > SIZE_MAX / 2) { + PyErr_NoMemory(); + return -1; + } + capacity *= 2; + } + uint8_t *data = PyMem_Realloc(buffer->data, capacity); + if (data == NULL) { + PyErr_NoMemory(); + return -1; + } + buffer->data = data; + buffer->capacity = capacity; + return 0; +} + +static inline void +buffer_clear(ByteBuffer *buffer) +{ + PyMem_Free(buffer->data); + buffer->data = NULL; + buffer->size = 0; + buffer->capacity = 0; +} + +/* Bytes in one status bitmap */ +static inline size_t +status_bitmap_size(uint32_t sample_count) +{ + return ((size_t)sample_count + CHAR_BIT - 1) / CHAR_BIT; +} + /* Generic array growth - returns new pointer or NULL (sets PyErr_NoMemory) * Includes overflow checking for capacity doubling and allocation size. */ static inline void * @@ -516,6 +752,8 @@ grow_array_inplace(void **ptr_addr, size_t count, size_t *capacity, size_t elem_ * sample_interval_us: Sampling interval in microseconds * compression_type: COMPRESSION_NONE or COMPRESSION_ZSTD * start_time_us: Start timestamp in microseconds (from time.monotonic() * 1e6) + * profiling_mode: PROFILING_MODE_* value, or -1 if unknown + * capture_features: PROFILING_FEATURE_* bit mask, or -1 if unknown * * Returns: * New BinaryWriter* on success, NULL on failure (PyErr set) @@ -524,7 +762,9 @@ BinaryWriter *binary_writer_create( PyObject *path, uint64_t sample_interval_us, int compression_type, - uint64_t start_time_us + uint64_t start_time_us, + int profiling_mode, + int capture_features ); /* @@ -556,6 +796,16 @@ int binary_writer_write_sample( */ int binary_writer_finalize(BinaryWriter *writer); +/* Store measured statistics to write during finalization. */ +int binary_writer_set_stats( + BinaryWriter *writer, + double duration_sec, + double sample_rate, + double error_rate, + double missed_samples, + uint32_t present +); + /* * Destroy a binary writer and free all resources. * Safe to call even if writer is partially initialized. @@ -631,6 +881,12 @@ void binary_reader_close(BinaryReader *reader); */ PyObject *binary_writer_get_stats(BinaryWriter *writer); +/* + * Decoded bytes of the samples buffered in the current block, not yet + * counted in the writer's bytes_written statistic. + */ +size_t binary_writer_buffered_size(BinaryWriter *writer); + /* * Get reader statistics as a Python dict. * diff --git a/Modules/_remote_debugging/binary_io_reader.c b/Modules/_remote_debugging/binary_io_reader.c index 07352f94cc805d7..e627feeb53bd49a 100644 --- a/Modules/_remote_debugging/binary_io_reader.c +++ b/Modules/_remote_debugging/binary_io_reader.c @@ -12,22 +12,36 @@ #include "binary_io.h" #include "_remote_debugging.h" #include "pycore_bitutils.h" /* _Py_bswap32, _Py_bswap64 for cross-endian reading */ +#include #include #ifdef HAVE_ZSTD #include #endif +#ifdef _Py_MEMORY_SANITIZER +# include +#endif + /* ============================================================================ * CONSTANTS FOR BINARY FORMAT SIZES * ============================================================================ */ -/* File structure sizes */ -#define MIN_DECOMPRESS_BUFFER_SIZE (64 * 1024) /* Minimum decompression buffer */ - /* Progress callback frequency */ #define PROGRESS_CALLBACK_INTERVAL 1000 +/* Cap per-batch RLE samples to bound the timestamp list (gh-151378) */ +#define MAX_RLE_BATCH_SAMPLES 8192 + +#define FRAME_INFO_CACHE_SIZE 1024 + +#if !USE_MMAP +/* The block parser limits stored columns to MAX_BLOCK_SIZE */ +#define MAX_STORED_BLOCK_SIZE (MAX_BLOCK_SIZE + 1024) +/* Replay reads samples through a window that fits any block */ +#define SAMPLE_WINDOW_SIZE (2 * MAX_BLOCK_SIZE) +#endif + /* ============================================================================ * BINARY READER IMPLEMENTATION * ============================================================================ */ @@ -84,7 +98,7 @@ reader_parse_header(BinaryReader *reader, const uint8_t *data, size_t file_size) /* Read header fields with byte-swapping if needed */ uint64_t start_time_us, sample_interval_us, string_table_offset, frame_table_offset; uint64_t sample_count; - uint32_t thread_count, compression_type; + uint32_t thread_count, compression_type, profiling_config; memcpy(&start_time_us, &data[HDR_OFF_START_TIME], HDR_SIZE_START_TIME); memcpy(&sample_interval_us, &data[HDR_OFF_INTERVAL], HDR_SIZE_INTERVAL); @@ -93,6 +107,7 @@ reader_parse_header(BinaryReader *reader, const uint8_t *data, size_t file_size) memcpy(&string_table_offset, &data[HDR_OFF_STR_TABLE], HDR_SIZE_STR_TABLE); memcpy(&frame_table_offset, &data[HDR_OFF_FRAME_TABLE], HDR_SIZE_FRAME_TABLE); memcpy(&compression_type, &data[HDR_OFF_COMPRESSION], HDR_SIZE_COMPRESSION); + memcpy(&profiling_config, &data[HDR_OFF_CONFIG], HDR_SIZE_CONFIG); reader->start_time_us = SWAP64_IF(reader->needs_swap, start_time_us); reader->sample_interval_us = SWAP64_IF(reader->needs_swap, sample_interval_us); @@ -101,6 +116,20 @@ reader_parse_header(BinaryReader *reader, const uint8_t *data, size_t file_size) reader->string_table_offset = SWAP64_IF(reader->needs_swap, string_table_offset); reader->frame_table_offset = SWAP64_IF(reader->needs_swap, frame_table_offset); reader->compression_type = (int)SWAP32_IF(reader->needs_swap, compression_type); + profiling_config = SWAP32_IF(reader->needs_swap, profiling_config); + uint32_t profiling_mode = + profiling_config & PROFILING_CONFIG_MODE_MASK; + if (profiling_mode > PROFILING_MODE_EXCEPTION + 1) { + PyErr_Format(PyExc_ValueError, + "Invalid profiling mode in header: %u", profiling_mode); + return -1; + } + reader->profiling_mode = (int)profiling_mode - 1; + reader->capture_features = + profiling_config & PROFILING_CONFIG_FEATURES_KNOWN + ? (int)((profiling_config >> PROFILING_CONFIG_FEATURES_SHIFT) & + PROFILING_FEATURE_MASK) + : -1; return 0; } @@ -125,118 +154,144 @@ reader_parse_footer(BinaryReader *reader, const uint8_t *data, size_t file_size) return 0; } -#ifdef HAVE_ZSTD -/* Maximum decompression buffer size to prevent memory exhaustion (1GB) */ -#define MAX_DECOMPRESS_SIZE (1ULL << 30) - static inline int -reader_decompress_samples(BinaryReader *reader, const uint8_t *data) +reader_parse_profile_stats(BinaryReader *reader, const uint8_t *data, + size_t file_size) { - size_t compressed_size = reader->string_table_offset - FILE_HEADER_PLACEHOLDER_SIZE; - const uint8_t *compressed_data = data + FILE_HEADER_PLACEHOLDER_SIZE; + size_t minimum_size = FILE_FOOTER_SIZE + PROFILE_STATS_V1_SIZE; + if (file_size < minimum_size) { + return 0; + } + + const uint8_t *stats_end = data + file_size - FILE_FOOTER_SIZE; + const uint8_t *stats_tail = stats_end - PROFILE_STATS_MAGIC_SIZE - + PST_SIZE_VERSION - PST_SIZE_SIZE; + if (memcmp(stats_tail, + PROFILE_STATS_MAGIC, PROFILE_STATS_MAGIC_SIZE) != 0) { + return 0; + } + + uint32_t version, size; + memcpy(&version, stats_tail + PROFILE_STATS_MAGIC_SIZE, + PST_SIZE_VERSION); + memcpy(&size, stats_tail + PROFILE_STATS_MAGIC_SIZE + PST_SIZE_VERSION, + PST_SIZE_SIZE); + version = SWAP32_IF(reader->needs_swap, version); + size = SWAP32_IF(reader->needs_swap, size); + + if (size < PROFILE_STATS_V1_SIZE || + size > file_size - FILE_FOOTER_SIZE) { + PyErr_SetString(PyExc_ValueError, + "Invalid profiling statistics size"); + return -1; + } + if (version != PROFILE_STATS_VERSION) { + return 0; + } - /* Validate compressed data region */ - if (reader->string_table_offset < FILE_HEADER_PLACEHOLDER_SIZE) { - PyErr_SetString(PyExc_ValueError, "Invalid string table offset"); + const uint8_t *trailer = stats_end - size; + uint64_t duration_bits, sample_rate_bits; + memcpy(&duration_bits, trailer + PST_OFF_DURATION, PST_SIZE_DURATION); + memcpy(&sample_rate_bits, trailer + PST_OFF_SAMPLE_RATE, + PST_SIZE_SAMPLE_RATE); + duration_bits = SWAP64_IF(reader->needs_swap, duration_bits); + sample_rate_bits = SWAP64_IF(reader->needs_swap, sample_rate_bits); + memcpy(&reader->duration_sec, &duration_bits, sizeof(duration_bits)); + memcpy(&reader->sample_rate, &sample_rate_bits, sizeof(sample_rate_bits)); + + if (!isfinite(reader->duration_sec) || reader->duration_sec < 0.0 || + !isfinite(reader->sample_rate) || reader->sample_rate < 0.0) { + PyErr_SetString(PyExc_ValueError, + "Invalid profiling statistics values"); return -1; } + reader->has_profile_stats = 1; + + if (size >= PROFILE_STATS_SIZE) { + uint64_t error_rate_bits, missed_samples_bits; + uint32_t present; + memcpy(&error_rate_bits, trailer + PST_OFF_ERROR_RATE, + PST_SIZE_ERROR_RATE); + memcpy(&missed_samples_bits, trailer + PST_OFF_MISSED_SAMPLES, + PST_SIZE_MISSED_SAMPLES); + memcpy(&present, trailer + PST_OFF_PRESENT, PST_SIZE_PRESENT); + error_rate_bits = SWAP64_IF(reader->needs_swap, error_rate_bits); + missed_samples_bits = SWAP64_IF(reader->needs_swap, + missed_samples_bits); + present = SWAP32_IF(reader->needs_swap, present); + memcpy(&reader->error_rate, &error_rate_bits, + sizeof(error_rate_bits)); + memcpy(&reader->missed_samples, &missed_samples_bits, + sizeof(missed_samples_bits)); + if (((present & PROFILE_STATS_ERROR_RATE) && + (!isfinite(reader->error_rate) || reader->error_rate < 0.0)) || + ((present & PROFILE_STATS_MISSED) && + !isfinite(reader->missed_samples))) { + PyErr_SetString(PyExc_ValueError, + "Invalid profiling statistics values"); + return -1; + } + reader->profile_stats_present = present; + } + return 0; +} - ZSTD_DCtx *dctx = ZSTD_createDCtx(); - if (!dctx) { - PyErr_SetString(PyExc_MemoryError, "Failed to create zstd decompression context"); +static int +reader_decompress(BinaryReader *reader, const uint8_t *compressed_data, + size_t compressed_size, ByteBuffer *output, + size_t decoded_size) +{ +#ifdef HAVE_ZSTD + /* The data must be exactly one zstd frame */ + size_t frame_size = ZSTD_findFrameCompressedSize(compressed_data, + compressed_size); + if (ZSTD_isError(frame_size) || frame_size != compressed_size) { + PyErr_SetString(PyExc_ValueError, "Corrupted zstd frame header"); return -1; } - /* Try to get exact decompressed size from frame header for optimal allocation */ + /* Check the decompressed size recorded in the frame header before + * allocating for it */ unsigned long long frame_content_size = ZSTD_getFrameContentSize(compressed_data, compressed_size); - size_t alloc_size; - if (frame_content_size == ZSTD_CONTENTSIZE_ERROR) { /* Corrupted frame header - fail early */ - ZSTD_freeDCtx(dctx); PyErr_SetString(PyExc_ValueError, "Corrupted zstd frame header"); return -1; - } else if (frame_content_size != ZSTD_CONTENTSIZE_UNKNOWN && - frame_content_size <= SIZE_MAX && - frame_content_size <= MAX_DECOMPRESS_SIZE) { - alloc_size = (size_t)frame_content_size; - } else { - alloc_size = ZSTD_DStreamOutSize() * 4; - if (alloc_size < MIN_DECOMPRESS_BUFFER_SIZE) { - alloc_size = MIN_DECOMPRESS_BUFFER_SIZE; - } } - - reader->decompressed_data = PyMem_Malloc(alloc_size); - if (!reader->decompressed_data) { - ZSTD_freeDCtx(dctx); - PyErr_NoMemory(); + if (frame_content_size != decoded_size) { + PyErr_SetString(PyExc_ValueError, + "zstd frame size does not match the decoded size"); return -1; } - ZSTD_inBuffer input = { compressed_data, compressed_size, 0 }; - size_t total_output = 0; - size_t last_result = 0; - - while (input.pos < input.size) { - if (total_output >= alloc_size) { - /* Check for overflow before doubling */ - if (alloc_size > SIZE_MAX / 2 || alloc_size * 2 > MAX_DECOMPRESS_SIZE) { - PyMem_Free(reader->decompressed_data); - reader->decompressed_data = NULL; - ZSTD_freeDCtx(dctx); - PyErr_SetString(PyExc_MemoryError, "Decompressed data exceeds maximum size"); - return -1; - } - size_t new_size = alloc_size * 2; - uint8_t *new_buf = PyMem_Realloc(reader->decompressed_data, new_size); - if (!new_buf) { - PyMem_Free(reader->decompressed_data); - reader->decompressed_data = NULL; - ZSTD_freeDCtx(dctx); - PyErr_NoMemory(); - return -1; - } - reader->decompressed_data = new_buf; - alloc_size = new_size; - } - - ZSTD_outBuffer output = { - reader->decompressed_data + total_output, - alloc_size - total_output, - 0 - }; - - last_result = ZSTD_decompressStream(dctx, &output, &input); - if (ZSTD_isError(last_result)) { - PyMem_Free(reader->decompressed_data); - reader->decompressed_data = NULL; - ZSTD_freeDCtx(dctx); - PyErr_Format(PyExc_ValueError, "zstd decompression error: %s", - ZSTD_getErrorName(last_result)); - return -1; - } - - total_output += output.pos; + /* Append the decoded data to the output buffer */ + if (buffer_reserve(output, output->size + decoded_size) < 0) { + return -1; + } + uint8_t *decoded = output->data + output->size; + size_t result = ZSTD_decompressDCtx(reader->dctx, decoded, decoded_size, + compressed_data, compressed_size); + if (ZSTD_isError(result)) { + PyErr_Format(PyExc_ValueError, "zstd decompression error: %s", + ZSTD_getErrorName(result)); + return -1; } - /* Verify decompression is complete (last_result == 0 means frame is complete) */ - if (last_result != 0) { - PyMem_Free(reader->decompressed_data); - reader->decompressed_data = NULL; - ZSTD_freeDCtx(dctx); + /* Verify decompression is complete */ + if (result != decoded_size) { PyErr_SetString(PyExc_ValueError, "Incomplete zstd frame: data may be truncated"); return -1; } - ZSTD_freeDCtx(dctx); - reader->decompressed_size = total_output; - reader->sample_data = reader->decompressed_data; - reader->sample_data_size = reader->decompressed_size; - + _Py_MSAN_UNPOISON(decoded, decoded_size); + output->size += decoded_size; return 0; -} +#else + PyErr_SetString(PyExc_RuntimeError, + "File uses zstd compression but zstd support not compiled in"); + return -1; #endif +} /* Reject a table/run count whose entries cannot fit in the bytes still * available; a malicious file could otherwise drive a huge allocation. @@ -256,10 +311,10 @@ reader_validate_count(const char *what, uint32_t count, } static inline int -reader_parse_string_table(BinaryReader *reader, const uint8_t *data, size_t file_size) +reader_parse_string_table(BinaryReader *reader, const uint8_t *data, + size_t size, size_t offset) { - if (reader_validate_count("string", reader->strings_count, - file_size - reader->string_table_offset, + if (reader_validate_count("string", reader->strings_count, size - offset, MIN_STRING_ENTRY_SIZE) < 0) { return -1; } @@ -270,15 +325,14 @@ reader_parse_string_table(BinaryReader *reader, const uint8_t *data, size_t file return -1; } - size_t offset = reader->string_table_offset; for (uint32_t i = 0; i < reader->strings_count; i++) { size_t prev_offset = offset; - uint32_t str_len = decode_varint_u32(data, &offset, file_size); + uint32_t str_len = decode_varint_u32(data, &offset, size); if (offset == prev_offset) { PyErr_SetString(PyExc_ValueError, "Malformed varint in string table"); return -1; } - if (offset > file_size || str_len > file_size - offset) { + if (offset > size || str_len > size - offset) { PyErr_SetString(PyExc_ValueError, "String table overflow"); return -1; } @@ -294,7 +348,8 @@ reader_parse_string_table(BinaryReader *reader, const uint8_t *data, size_t file } static inline int -reader_parse_frame_table(BinaryReader *reader, const uint8_t *data, size_t file_size) +reader_parse_frame_table(BinaryReader *reader, const uint8_t *data, + size_t size, size_t offset) { /* Check for integer overflow in allocation size calculation. */ #if SIZEOF_SIZE_T < 8 @@ -304,8 +359,7 @@ reader_parse_frame_table(BinaryReader *reader, const uint8_t *data, size_t file_ } #endif - if (reader_validate_count("frame", reader->frames_count, - file_size - reader->frame_table_offset, + if (reader_validate_count("frame", reader->frames_count, size - offset, MIN_FRAME_ENTRY_SIZE) < 0) { return -1; } @@ -317,34 +371,33 @@ reader_parse_frame_table(BinaryReader *reader, const uint8_t *data, size_t file_ return -1; } - size_t offset = reader->frame_table_offset; for (uint32_t i = 0; i < reader->frames_count; i++) { FrameEntry *frame = &reader->frames[i]; size_t prev_offset; prev_offset = offset; - frame->filename_idx = decode_varint_u32(data, &offset, file_size); + frame->filename_idx = decode_varint_u32(data, &offset, size); if (offset == prev_offset) { PyErr_SetString(PyExc_ValueError, "Malformed varint in frame table (filename)"); return -1; } prev_offset = offset; - frame->funcname_idx = decode_varint_u32(data, &offset, file_size); + frame->funcname_idx = decode_varint_u32(data, &offset, size); if (offset == prev_offset) { PyErr_SetString(PyExc_ValueError, "Malformed varint in frame table (funcname)"); return -1; } prev_offset = offset; - frame->lineno = decode_varint_i32(data, &offset, file_size); + frame->lineno = decode_varint_i32(data, &offset, size); if (offset == prev_offset) { PyErr_SetString(PyExc_ValueError, "Malformed varint in frame table (lineno)"); return -1; } prev_offset = offset; - int32_t end_lineno_delta = decode_varint_i32(data, &offset, file_size); + int32_t end_lineno_delta = decode_varint_i32(data, &offset, size); if (offset == prev_offset) { PyErr_SetString(PyExc_ValueError, "Malformed varint in frame table (end_lineno_delta)"); return -1; @@ -357,14 +410,14 @@ reader_parse_frame_table(BinaryReader *reader, const uint8_t *data, size_t file_ } prev_offset = offset; - frame->column = decode_varint_i32(data, &offset, file_size); + frame->column = decode_varint_i32(data, &offset, size); if (offset == prev_offset) { PyErr_SetString(PyExc_ValueError, "Malformed varint in frame table (column)"); return -1; } prev_offset = offset; - int32_t end_column_delta = decode_varint_i32(data, &offset, file_size); + int32_t end_column_delta = decode_varint_i32(data, &offset, size); if (offset == prev_offset) { PyErr_SetString(PyExc_ValueError, "Malformed varint in frame table (end_column_delta)"); return -1; @@ -377,7 +430,7 @@ reader_parse_frame_table(BinaryReader *reader, const uint8_t *data, size_t file_ } /* Read opcode byte */ - if (offset >= file_size) { + if (offset >= size) { PyErr_SetString(PyExc_ValueError, "Unexpected end of frame table (opcode)"); return -1; } @@ -387,6 +440,63 @@ reader_parse_frame_table(BinaryReader *reader, const uint8_t *data, size_t file_ return 0; } +#if USE_MMAP && defined(__linux__) && defined(MADV_DONTNEED) +static size_t +reader_discard_mapped_pages(BinaryReader *reader, size_t start, size_t end) +{ + start = _Py_SIZE_ROUND_UP(start, reader->page_size); + end = _Py_SIZE_ROUND_DOWN(end, reader->page_size); + if (start >= end) { + return start; + } + (void)madvise(reader->mapped_data + start, end - start, MADV_DONTNEED); + return end; +} +#else +static inline size_t +reader_discard_mapped_pages(BinaryReader *reader, size_t start, size_t end) +{ + return end; +} +#endif + +#if !USE_MMAP +/* Checked fread with GIL release - returns 0 on success, -1 on error */ +static int +fread_checked_allow_threads(void *data, size_t size, FILE *fp) +{ + size_t nread; + Py_BEGIN_ALLOW_THREADS + nread = fread(data, 1, size, fp); + Py_END_ALLOW_THREADS + if (nread != size) { + int err = errno; + if (ferror(fp) && err != 0) { + errno = err; + PyErr_SetFromErrno(PyExc_IOError); + } + else { + PyErr_Format(PyExc_ValueError, + "Unexpected end of file: read %zu of %zu bytes", + nread, size); + } + return -1; + } + return 0; +} + +static int +reader_read_at(BinaryReader *reader, size_t offset, uint8_t *buffer, + size_t size) +{ + if (FSEEK64(reader->fp, (file_offset_t)offset, SEEK_SET) != 0) { + PyErr_SetFromErrno(PyExc_IOError); + return -1; + } + return fread_checked_allow_threads(buffer, size, reader->fp); +} +#endif + BinaryReader * binary_reader_open(PyObject *path) { @@ -427,32 +537,19 @@ binary_reader_open(PyObject *path) goto error; } - /* Map the file into memory. - * MAP_POPULATE (Linux-only) pre-faults all pages at mmap time, which: - * - Catches issues (e.g., file truncation) immediately rather than as SIGBUS during reads - * - Eliminates page faults during subsequent reads for better performance - */ -#ifdef __linux__ - reader->mapped_data = mmap(NULL, reader->mapped_size, PROT_READ, - MAP_PRIVATE | MAP_POPULATE, fd, 0); -#else reader->mapped_data = mmap(NULL, reader->mapped_size, PROT_READ, MAP_PRIVATE, fd, 0); -#endif if (reader->mapped_data == MAP_FAILED) { reader->mapped_data = NULL; PyErr_SetFromErrno(PyExc_IOError); Py_fclose(fp); goto error; } + reader->page_size = (size_t)sysconf(_SC_PAGESIZE); /* Hint sequential access pattern - failures are non-fatal */ (void)madvise(reader->mapped_data, reader->mapped_size, MADV_SEQUENTIAL); - /* Pre-fetch pages into memory - failures are non-fatal. - * Complements MAP_POPULATE on Linux, provides benefit on macOS. */ - (void)madvise(reader->mapped_data, reader->mapped_size, MADV_WILLNEED); - /* Use transparent huge pages for large files to reduce TLB misses. * Only beneficial for files >= 32MB where TLB pressure matters. */ #ifdef MADV_HUGEPAGE @@ -464,9 +561,6 @@ binary_reader_open(PyObject *path) /* Add file descriptor-level hints for better kernel I/O scheduling */ #if defined(__linux__) && defined(POSIX_FADV_SEQUENTIAL) (void)posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL); - if (reader->mapped_size > (64 * 1024 * 1024)) { - (void)posix_fadvise(fd, 0, 0, POSIX_FADV_WILLNEED); - } #endif if (Py_fclose(fp) != 0) { @@ -477,7 +571,8 @@ binary_reader_open(PyObject *path) uint8_t *data = reader->mapped_data; size_t file_size = reader->mapped_size; #else - /* Use stdio on Windows */ + /* Use stdio on Windows. Read the header and tables now, samples during + * replay. */ reader->fp = Py_fopen(path, "rb"); if (!reader->fp) { goto error; @@ -501,43 +596,17 @@ binary_reader_open(PyObject *path) PyErr_SetString(PyExc_ValueError, "File too small for header"); goto error; } - if (FSEEK64(reader->fp, 0, SEEK_SET) != 0) { - PyErr_SetFromErrno(PyExc_IOError); - goto error; - } - - reader->file_data = PyMem_Malloc(reader->file_size); - if (!reader->file_data) { - PyErr_NoMemory(); - goto error; - } - - size_t nread = fread(reader->file_data, 1, reader->file_size, reader->fp); - if (nread != reader->file_size) { - int err = errno; - if (ferror(reader->fp) && err != 0) { - errno = err; - PyErr_SetFromErrno(PyExc_IOError); - } - else { - PyErr_Format(PyExc_ValueError, - "Unexpected end of file: read %zu of %zu bytes", - nread, reader->file_size); - } + uint8_t data[FILE_HEADER_PLACEHOLDER_SIZE]; + size_t file_size = reader->file_size; + if (reader_read_at(reader, 0, data, + Py_MIN(file_size, sizeof(data))) < 0) { goto error; } - - uint8_t *data = reader->file_data; - size_t file_size = reader->file_size; #endif - /* Parse header and footer */ if (reader_parse_header(reader, data, file_size) < 0) { goto error; } - if (reader_parse_footer(reader, data, file_size) < 0) { - goto error; - } /* Validate table offsets are within file bounds */ if (reader->string_table_offset > file_size) { @@ -572,10 +641,11 @@ binary_reader_open(PyObject *path) goto error; } - /* Handle compressed data */ if (reader->compression_type == COMPRESSION_ZSTD) { #ifdef HAVE_ZSTD - if (reader_decompress_samples(reader, data) < 0) { + reader->dctx = ZSTD_createDCtx(); + if (!reader->dctx) { + PyErr_SetString(PyExc_MemoryError, "Failed to create zstd decompression context"); goto error; } #else @@ -583,18 +653,46 @@ binary_reader_open(PyObject *path) "File uses zstd compression but zstd support not compiled in"); goto error; #endif - } else { - reader->sample_data = data + FILE_HEADER_PLACEHOLDER_SIZE; - reader->sample_data_size = reader->string_table_offset - FILE_HEADER_PLACEHOLDER_SIZE; } + reader->sample_data_size = + (size_t)reader->string_table_offset - FILE_HEADER_PLACEHOLDER_SIZE; - /* Parse string and frame tables */ - if (reader_parse_string_table(reader, data, file_size) < 0) { + /* Tables, statistics and footer follow the samples. The footer is + * always the last bytes of the file. */ + size_t tail_offset = Py_MIN((size_t)reader->string_table_offset, + file_size - FILE_FOOTER_SIZE); + size_t tail_size = file_size - tail_offset; +#if USE_MMAP + reader->sample_data = data + FILE_HEADER_PLACEHOLDER_SIZE; + const uint8_t *tail = data + tail_offset; +#else + reader->table_data = PyMem_Malloc(tail_size); + if (!reader->table_data) { + PyErr_NoMemory(); + goto error; + } + if (reader_read_at(reader, tail_offset, reader->table_data, + tail_size) < 0) { goto error; } - if (reader_parse_frame_table(reader, data, file_size) < 0) { + const uint8_t *tail = reader->table_data; +#endif + if (reader_parse_footer(reader, tail, tail_size) < 0 || + reader_parse_profile_stats(reader, tail, tail_size) < 0 || + reader_parse_string_table( + reader, tail, tail_size, + (size_t)reader->string_table_offset - tail_offset) < 0 || + reader_parse_frame_table( + reader, tail, tail_size, + (size_t)reader->frame_table_offset - tail_offset) < 0) { goto error; } +#if USE_MMAP + (void)reader_discard_mapped_pages(reader, tail_offset, file_size); +#else + PyMem_Free(reader->table_data); + reader->table_data = NULL; +#endif return reader; @@ -604,7 +702,7 @@ binary_reader_open(PyObject *path) } /* Get or create reader thread state for stack reconstruction */ -static ReaderThreadState * +static ThreadEntry * reader_get_or_create_thread_state(BinaryReader *reader, uint64_t thread_id, uint32_t interpreter_id) { @@ -626,192 +724,104 @@ reader_get_or_create_thread_state(BinaryReader *reader, uint64_t thread_id, if (!reader->thread_states) { reader->thread_state_capacity = 16; - reader->thread_states = PyMem_Calloc(reader->thread_state_capacity, sizeof(ReaderThreadState)); + reader->thread_states = PyMem_Calloc(reader->thread_state_capacity, sizeof(ThreadEntry)); if (!reader->thread_states) { PyErr_NoMemory(); return NULL; } - } else if (reader->thread_state_count >= reader->thread_state_capacity) { - ReaderThreadState *new_states = grow_array(reader->thread_states, - &reader->thread_state_capacity, - sizeof(ReaderThreadState)); - if (!new_states) { - return NULL; - } - reader->thread_states = new_states; + } + else if (GROW_ARRAY(reader->thread_states, reader->thread_state_count, + reader->thread_state_capacity, ThreadEntry) < 0) { + return NULL; } - ReaderThreadState *ts = &reader->thread_states[reader->thread_state_count]; - memset(ts, 0, sizeof(ReaderThreadState)); + ThreadEntry *ts = &reader->thread_states[reader->thread_state_count]; + memset(ts, 0, sizeof(ThreadEntry)); ts->thread_id = thread_id; ts->interpreter_id = interpreter_id; - ts->prev_timestamp = reader->start_time_us; - ts->current_stack_capacity = MAX_STACK_DEPTH; - ts->current_stack = PyMem_Malloc(ts->current_stack_capacity * sizeof(uint32_t)); - if (!ts->current_stack) { - PyErr_NoMemory(); - return NULL; - } - // Increment count only after successful allocation to avoid - // leaving a half-initialized entry visible to future lookups reader->thread_state_count++; return ts; } -/* ============================================================================ - * STACK DECODING HELPERS - * ============================================================================ */ - -/* Validate that final_depth fits in the stack buffer. - * Uses uint64_t to prevent overflow on 32-bit platforms. */ -static inline int -validate_stack_depth(ReaderThreadState *ts, uint64_t final_depth) -{ - if (final_depth > ts->current_stack_capacity) { - PyErr_Format(PyExc_ValueError, - "Final stack depth %llu exceeds capacity %zu", - (unsigned long long)final_depth, ts->current_stack_capacity); - return -1; - } - return 0; -} - -/* Decode a full stack from sample data. - * Updates ts->current_stack and ts->current_stack_depth. - * Returns 0 on success, -1 on error (bounds violation). */ -static inline int -decode_stack_full(ReaderThreadState *ts, const uint8_t *data, - size_t *offset, size_t max_size) +static PyObject * +reader_get_frame_info(RemoteDebuggingState *state, BinaryReader *reader, + uint32_t frame_index) { - size_t prev_offset = *offset; - uint32_t depth = decode_varint_u32(data, offset, max_size); - if (*offset == prev_offset) { - return -1; - } - - /* Validate depth against capacity to prevent buffer overflow */ - if (depth > ts->current_stack_capacity) { - PyErr_Format(PyExc_ValueError, - "Stack depth %u exceeds capacity %zu", depth, ts->current_stack_capacity); - return -1; + if (frame_index >= reader->frames_count) { + PyErr_Format(PyExc_ValueError, "Invalid frame index: %u", frame_index); + return NULL; } - - ts->current_stack_depth = depth; - for (uint32_t i = 0; i < depth; i++) { - size_t prev_offset = *offset; - ts->current_stack[i] = decode_varint_u32(data, offset, max_size); - if (*offset == prev_offset) { - return -1; + if (reader->frame_info_cache == NULL) { + size_t cache_size = Py_MIN(reader->frames_count, + (uint32_t)FRAME_INFO_CACHE_SIZE); + reader->frame_info_cache = PyMem_Calloc( + cache_size, sizeof(*reader->frame_info_cache)); + if (reader->frame_info_cache == NULL) { + PyErr_NoMemory(); + return NULL; } + reader->frame_info_cache_size = cache_size; } - return 0; -} - -/* Decode a suffix-encoded stack from sample data. - * The suffix encoding shares frames from the bottom of the previous stack. - * Returns 0 on success, -1 on error (bounds violation). */ -static inline int -decode_stack_suffix(ReaderThreadState *ts, const uint8_t *data, - size_t *offset, size_t max_size) -{ - size_t prev_offset = *offset; - uint32_t shared = decode_varint_u32(data, offset, max_size); - if (*offset == prev_offset) { - return -1; - } - prev_offset = *offset; - uint32_t new_count = decode_varint_u32(data, offset, max_size); - if (*offset == prev_offset) { - return -1; - } - - /* Validate shared doesn't exceed current stack depth */ - if (shared > ts->current_stack_depth) { - PyErr_Format(PyExc_ValueError, - "Shared count %u exceeds current stack depth %zu", - shared, ts->current_stack_depth); - return -1; + ReaderFrameCacheEntry *entry = &reader->frame_info_cache[ + frame_index % reader->frame_info_cache_size]; + if (entry->frame_info != NULL && entry->frame_index == frame_index) { + return Py_NewRef(entry->frame_info); } - /* Use uint64_t to prevent overflow on 32-bit platforms */ - uint64_t final_depth = (uint64_t)shared + new_count; - if (validate_stack_depth(ts, final_depth) < 0) { - return -1; + FrameEntry *frame = &reader->frames[frame_index]; + if (frame->filename_idx >= reader->strings_count || + frame->funcname_idx >= reader->strings_count) { + PyErr_SetString(PyExc_ValueError, "Invalid string index in frame"); + return NULL; } - /* Move shared frames (from bottom of stack) to make room for new frames at the top */ - if (new_count > 0 && shared > 0) { - /* Defensive check: ensure subtraction won't underflow. - * This should already be guaranteed by the check above, but we add - * this assertion as defense-in-depth against stack corruption. */ - if (ts->current_stack_depth < shared) { - PyErr_SetString(PyExc_ValueError, - "Internal error: stack corruption detected in suffix decoding"); - return -1; - } - size_t prev_shared_start = ts->current_stack_depth - shared; - memmove(&ts->current_stack[new_count], - &ts->current_stack[prev_shared_start], - shared * sizeof(uint32_t)); + PyObject *frame_info = PyStructSequence_New(state->FrameInfo_Type); + if (!frame_info) { + return NULL; } - for (uint32_t i = 0; i < new_count; i++) { - size_t prev_offset = *offset; - ts->current_stack[i] = decode_varint_u32(data, offset, max_size); - if (*offset == prev_offset) { - return -1; + /* Build location tuple with full position info */ + PyObject *location; + if (frame->lineno != LOCATION_NOT_AVAILABLE) { + location = Py_BuildValue("(iiii)", + frame->lineno, + frame->end_lineno, + frame->column, + frame->end_column); + if (!location) { + Py_DECREF(frame_info); + return NULL; } } - ts->current_stack_depth = final_depth; - return 0; -} - -/* Decode a pop-push encoded stack from sample data. - * Pops frames from the top and pushes new frames. - * Returns 0 on success, -1 on error (bounds violation). */ -static inline int -decode_stack_pop_push(ReaderThreadState *ts, const uint8_t *data, - size_t *offset, size_t max_size) -{ - size_t prev_offset = *offset; - uint32_t pop = decode_varint_u32(data, offset, max_size); - if (*offset == prev_offset) { - return -1; - } - prev_offset = *offset; - uint32_t push = decode_varint_u32(data, offset, max_size); - if (*offset == prev_offset) { - return -1; + else { + location = Py_NewRef(Py_None); } - size_t keep = (ts->current_stack_depth > pop) ? ts->current_stack_depth - pop : 0; - /* Use uint64_t to prevent overflow on 32-bit platforms */ - uint64_t final_depth = (uint64_t)keep + push; - if (validate_stack_depth(ts, final_depth) < 0) { - return -1; + /* Build opcode object */ + PyObject *opcode_obj; + if (frame->opcode != OPCODE_NONE) { + opcode_obj = PyLong_FromLong(frame->opcode); + if (!opcode_obj) { + Py_DECREF(location); + Py_DECREF(frame_info); + return NULL; + } } - - /* Move kept frames (from bottom of stack) to make room for new frames at the top. - * Even when push == 0, we need to move kept frames to index 0 if pop > 0. */ - if (keep > 0) { - memmove(&ts->current_stack[push], - &ts->current_stack[pop], - keep * sizeof(uint32_t)); + else { + opcode_obj = Py_NewRef(Py_None); } - for (uint32_t i = 0; i < push; i++) { - size_t prev_offset = *offset; - ts->current_stack[i] = decode_varint_u32(data, offset, max_size); - /* If offset didn't advance, varint decoding failed */ - if (*offset == prev_offset) { - return -1; - } - } - ts->current_stack_depth = final_depth; - return 0; + PyStructSequence_SetItem(frame_info, 0, Py_NewRef(reader->strings[frame->filename_idx])); + PyStructSequence_SetItem(frame_info, 1, location); + PyStructSequence_SetItem(frame_info, 2, Py_NewRef(reader->strings[frame->funcname_idx])); + PyStructSequence_SetItem(frame_info, 3, opcode_obj); + Py_XSETREF(entry->frame_info, Py_NewRef(frame_info)); + entry->frame_index = frame_index; + return frame_info; } -/* Build a Python list of FrameInfo objects from frame indices */ +/* Build a Python list of FrameInfo objects from frame indices. Stacks are + * kept outermost first, but collectors expect innermost first. */ static PyObject * build_frame_list(RemoteDebuggingState *state, BinaryReader *reader, const uint32_t *frame_indices, size_t stack_depth) @@ -822,60 +832,11 @@ build_frame_list(RemoteDebuggingState *state, BinaryReader *reader, } for (size_t k = 0; k < stack_depth; k++) { - uint32_t frame_idx = frame_indices[k]; - if (frame_idx >= reader->frames_count) { - PyErr_Format(PyExc_ValueError, "Invalid frame index: %u", frame_idx); - goto error; - } - - FrameEntry *frame = &reader->frames[frame_idx]; - - if (frame->filename_idx >= reader->strings_count || - frame->funcname_idx >= reader->strings_count) { - PyErr_SetString(PyExc_ValueError, "Invalid string index in frame"); - goto error; - } - - PyObject *frame_info = PyStructSequence_New(state->FrameInfo_Type); - if (!frame_info) { + PyObject *frame_info = reader_get_frame_info( + state, reader, frame_indices[stack_depth - 1 - k]); + if (frame_info == NULL) { goto error; } - - /* Build location tuple with full position info */ - PyObject *location; - if (frame->lineno != LOCATION_NOT_AVAILABLE) { - location = Py_BuildValue("(iiii)", - frame->lineno, - frame->end_lineno, - frame->column, - frame->end_column); - if (!location) { - Py_DECREF(frame_info); - goto error; - } - } - else { - location = Py_NewRef(Py_None); - } - - /* Build opcode object */ - PyObject *opcode_obj; - if (frame->opcode != OPCODE_NONE) { - opcode_obj = PyLong_FromLong(frame->opcode); - if (!opcode_obj) { - Py_DECREF(location); - Py_DECREF(frame_info); - goto error; - } - } - else { - opcode_obj = Py_NewRef(Py_None); - } - - PyStructSequence_SetItem(frame_info, 0, Py_NewRef(reader->strings[frame->filename_idx])); - PyStructSequence_SetItem(frame_info, 1, location); - PyStructSequence_SetItem(frame_info, 2, Py_NewRef(reader->strings[frame->funcname_idx])); - PyStructSequence_SetItem(frame_info, 3, opcode_obj); PyList_SET_ITEM(frame_list, k, frame_info); } @@ -977,21 +938,6 @@ emit_sample(RemoteDebuggingState *state, PyObject *collector, return 0; } -/* Helper to trim timestamp list and emit batch. Returns 0 on success, -1 on error. */ -static int -emit_batch(RemoteDebuggingState *state, PyObject *collector, - uint64_t thread_id, uint32_t interpreter_id, uint8_t status, - const uint32_t *frame_indices, size_t stack_depth, - BinaryReader *reader, PyObject *timestamps_list, Py_ssize_t actual_size) -{ - /* Trim list to actual size */ - if (PyList_SetSlice(timestamps_list, actual_size, PyList_GET_SIZE(timestamps_list), NULL) < 0) { - return -1; - } - return emit_sample(state, collector, thread_id, interpreter_id, status, - frame_indices, stack_depth, reader, timestamps_list); -} - /* Helper to invoke progress callback, returns -1 on error */ static inline int invoke_progress_callback(PyObject *callback, Py_ssize_t current, uint64_t total) @@ -1007,244 +953,820 @@ invoke_progress_callback(PyObject *callback, Py_ssize_t current, uint64_t total) return 0; } -Py_ssize_t -binary_reader_replay(BinaryReader *reader, PyObject *collector, PyObject *progress_callback) +/* ============================================================================ + * SAMPLE BLOCKS + * ============================================================================ */ + +static int +block_error(const char *message) { - PyObject *collect_method; - int has_collect = PyObject_GetOptionalAttrString(collector, "collect", &collect_method); - if (has_collect < 0) { - return -1; + PyErr_Format(PyExc_ValueError, "Invalid sample block: %s", message); + return -1; +} + +static inline int +block_read_varint(const ByteBuffer *column, size_t *offset, uint64_t *value) +{ + size_t prev_offset = *offset; + *value = decode_varint_u64(column->data, offset, column->size); + return *offset == prev_offset ? -1 : 0; +} + +static int +block_read_varint_u32(const ByteBuffer *column, size_t *offset, + uint32_t *value) +{ + size_t prev_offset = *offset; + *value = decode_varint_u32(column->data, offset, column->size); + return *offset == prev_offset ? -1 : 0; +} + +static int +reader_parse_block_header(BinaryReader *reader, const ByteBuffer *section, + size_t *offset, BlockHeader *header) +{ + /* Block magic "TBLK" */ + if (section->size - *offset < BLOCK_MAGIC_SIZE) { + return block_error("truncated header"); } - if (has_collect == 0) { - PyErr_SetString(PyExc_TypeError, "Collector must have a collect() method"); - return -1; + if (memcmp(section->data + *offset, BLOCK_MAGIC, BLOCK_MAGIC_SIZE) != 0) { + return block_error("wrong magic"); } - Py_DECREF(collect_method); + *offset += BLOCK_MAGIC_SIZE; - /* Get module state for struct sequence types */ - PyObject *module = PyImport_ImportModule("_remote_debugging"); - if (!module) { + /* Sample count and base timestamp (varints) */ + if (block_read_varint_u32(section, offset, &header->sample_count) < 0 || + block_read_varint(section, offset, &header->base_timestamp) < 0) { return -1; } - RemoteDebuggingState *state = RemoteDebugging_GetState(module); - Py_DECREF(module); - if (!state) { - PyErr_SetString(PyExc_RuntimeError, "Failed to get module state"); - return -1; + /* Frame ID width and the two status flag masks (1 byte each) */ + if (section->size - *offset < 3) { + return block_error("truncated header"); } - - size_t offset = 0; - Py_ssize_t replayed = 0; - - /* Initial progress callback at 0% */ - if (invoke_progress_callback(progress_callback, 0, reader->sample_count) < 0) { - return -1; + header->frame_width = section->data[(*offset)++]; + header->common_status_flags = section->data[(*offset)++]; + header->status_bitmap_flags = section->data[(*offset)++]; + if (header->sample_count == 0) { + return block_error("no samples"); + } + if (header->frame_width < 1 || header->frame_width > sizeof(uint32_t)) { + return block_error("frame ID width out of range"); + } + if (header->common_status_flags & header->status_bitmap_flags) { + return block_error("common and varying status flags overlap"); } - while (offset < reader->sample_data_size) { - /* Read thread_id (8 bytes) + interpreter_id (4 bytes) + encoding byte */ - if (reader->sample_data_size - offset < SAMPLE_HEADER_FIXED_SIZE) { - PyErr_Format(PyExc_ValueError, - "Truncated sample data: %zu trailing bytes", - reader->sample_data_size - offset); + size_t decoded_total = 0; + size_t stored_total = 0; + for (unsigned column = 0; column < COLUMN_COUNT; column++) { + ColumnDescriptor *descriptor = &header->columns[column]; + /* Decoded size (varint) and encoding (1 byte) */ + if (block_read_varint_u32(section, offset, + &descriptor->decoded_size) < 0) { return -1; } + if (*offset >= section->size) { + return block_error("truncated column descriptor"); + } + descriptor->encoding = section->data[(*offset)++]; - /* Use memcpy to avoid strict aliasing violations, then byte-swap if needed */ - uint64_t thread_id_raw; - uint32_t interpreter_id_raw; - memcpy(&thread_id_raw, &reader->sample_data[offset], SMP_SIZE_THREAD_ID); - offset += SMP_SIZE_THREAD_ID; - - memcpy(&interpreter_id_raw, &reader->sample_data[offset], SMP_SIZE_INTERPRETER_ID); - offset += SMP_SIZE_INTERPRETER_ID; + /* Stored size: implied for raw and constant, a varint for zstd */ + switch (descriptor->encoding) { + case COMPRESSION_NONE: + descriptor->stored_size = descriptor->decoded_size; + break; + case COLUMN_CONSTANT: + descriptor->stored_size = 1; + break; + case COMPRESSION_ZSTD: + if (reader->compression_type != COMPRESSION_ZSTD) { + return block_error("zstd column in an uncompressed file"); + } + if (block_read_varint_u32(section, offset, + &descriptor->stored_size) < 0) { + return -1; + } + break; + default: + return block_error("unknown column encoding"); + } - uint64_t thread_id = SWAP64_IF(reader->needs_swap, thread_id_raw); - uint32_t interpreter_id = SWAP32_IF(reader->needs_swap, interpreter_id_raw); + if (descriptor->encoding != COMPRESSION_NONE && + descriptor->decoded_size == 0) { + return block_error("encoded column is empty"); + } + if (descriptor->decoded_size > MAX_BLOCK_SIZE - decoded_total) { + return block_error("decoded columns exceed the block limit"); + } + if (descriptor->stored_size > MAX_BLOCK_SIZE - stored_total) { + return block_error("stored columns exceed the block limit"); + } + decoded_total += descriptor->decoded_size; + stored_total += descriptor->stored_size; + } - /* Get or create thread state for reconstruction */ - ReaderThreadState *ts = reader_get_or_create_thread_state(reader, thread_id, interpreter_id); - if (!ts) { - return -1; + /* Each sample needs at least one byte of stream index and residual */ + if (header->sample_count > + header->columns[COLUMN_SAMPLE_STREAM_IDS].decoded_size || + header->sample_count > + header->columns[COLUMN_TIMESTAMP_RESIDUALS].decoded_size) { + return block_error("more samples than stored stream indices"); + } + return 0; +} + +/* A constant stream index or residual column that holds the same one-byte + * varint for every sample is read from its stored byte, not expanded. */ +static int +constant_varint_column(const DecodedBlock *block, unsigned column, + uint8_t value) +{ + const ColumnDescriptor *descriptor = &block->header.columns[column]; + return (column == COLUMN_SAMPLE_STREAM_IDS || + column == COLUMN_TIMESTAMP_RESIDUALS) && + descriptor->encoding == COLUMN_CONSTANT && + descriptor->decoded_size == block->header.sample_count && + value < 0x80; +} + +static int +decode_block_columns(BinaryReader *reader, const ByteBuffer *section, + size_t *offset, DecodedBlock *block) +{ + const ColumnDescriptor *descriptors = block->header.columns; + /* Find where each column is stored and how much of the shared buffer + * the expanded and decompressed columns need. The buffer is reused + * across blocks and reserved up front so decoded columns never move. */ + uint8_t *stored[COLUMN_COUNT]; + size_t buffered_total = 0; + for (unsigned column = 0; column < COLUMN_COUNT; column++) { + const ColumnDescriptor *descriptor = &descriptors[column]; + if (descriptor->stored_size > section->size - *offset) { + return block_error("column extends past the sample section"); + } + stored[column] = section->data + *offset; + *offset += descriptor->stored_size; + if (descriptor->encoding == COMPRESSION_ZSTD || + (descriptor->encoding == COLUMN_CONSTANT && + !constant_varint_column(block, column, stored[column][0]))) { + buffered_total += descriptor->decoded_size; } + } + ByteBuffer *buffer = &reader->block_data; + if (buffer_reserve(buffer, buffered_total) < 0) { + return -1; + } - /* Read encoding byte */ - uint8_t encoding = reader->sample_data[offset++]; - - switch (encoding) { - case STACK_REPEAT: { - /* RLE repeat: [count: varint] [delta: varint, status: 1]... */ - size_t prev_offset = offset; - uint32_t count = decode_varint_u32(reader->sample_data, &offset, reader->sample_data_size); - /* Detect varint decode failure */ - if (offset == prev_offset) { - PyErr_SetString(PyExc_ValueError, "Malformed varint for RLE count"); - return -1; + buffer->size = 0; + for (unsigned column = 0; column < COLUMN_COUNT; column++) { + const ColumnDescriptor *descriptor = &descriptors[column]; + uint8_t *stored_data = stored[column]; + ByteBuffer *decoded = &block->columns[column]; + decoded->size = descriptor->decoded_size; + switch (descriptor->encoding) { + case COMPRESSION_NONE: + /* Raw columns point into the file data */ + decoded->data = stored_data; + break; + case COLUMN_CONSTANT: + if (constant_varint_column(block, column, stored_data[0])) { + decoded->data = stored_data; + decoded->size = 1; + break; } - - /* Reject a count larger than the remaining bytes can hold; each - * RLE sample needs at least 2 bytes (1-byte min varint + status). */ - if (reader_validate_count("RLE", count, - reader->sample_data_size - offset, 2) < 0) { + decoded->data = buffer->data + buffer->size; + memset(decoded->data, stored_data[0], decoded->size); + buffer->size += decoded->size; + break; + case COMPRESSION_ZSTD: + decoded->data = buffer->data + buffer->size; + if (reader_decompress(reader, stored_data, + descriptor->stored_size, buffer, + decoded->size) < 0) { return -1; } - if ((uint64_t)count > (uint64_t)PY_SSIZE_T_MAX - (uint64_t)replayed) { - PyErr_SetString(PyExc_OverflowError, - "Sample count exceeds Py_ssize_t maximum"); + break; + default: + return block_error("unknown column encoding"); + } + } + return 0; +} + +static int +validate_block_columns(DecodedBlock *block) +{ + size_t stream_table_size = block->columns[COLUMN_STREAM_TABLE].size; + if (stream_table_size % STREAM_ENTRY_SIZE != 0) { + return block_error("stream table has a partial entry"); + } + size_t stream_count = stream_table_size / STREAM_ENTRY_SIZE; + if (stream_count == 0 || stream_count > MAX_BLOCK_STREAMS) { + return block_error("stream count out of range"); + } + block->stream_count = (uint32_t)stream_count; + + size_t frame_ids_size = block->columns[COLUMN_FRAME_IDS].size; + if (frame_ids_size % block->header.frame_width != 0) { + return block_error("frame ID column has a partial value"); + } + block->frame_count = + (uint32_t)(frame_ids_size / block->header.frame_width); + + size_t plane_size = status_bitmap_size(block->header.sample_count); + size_t plane_count = + (size_t)_Py_popcount32(block->header.status_bitmap_flags); + const ByteBuffer *statuses = &block->columns[COLUMN_STATUS_BITMAPS]; + if (statuses->size != plane_size * plane_count) { + return block_error("status bitmaps have the wrong size"); + } + unsigned used_bits = block->header.sample_count % CHAR_BIT; + for (size_t plane = 0; used_bits && plane < plane_count; plane++) { + if (statuses->data[(plane + 1) * plane_size - 1] >> used_bits) { + return block_error("status bitmap padding is not zero"); + } + } + return 0; +} + +static int +reserve_block_streams(BinaryReader *reader, uint32_t stream_count) +{ + if (stream_count <= reader->block_stream_capacity) { + return 0; + } + ReaderBlockStream *streams = PyMem_Realloc( + reader->block_streams, stream_count * sizeof(ReaderBlockStream)); + if (streams == NULL) { + PyErr_NoMemory(); + return -1; + } + reader->block_streams = streams; + reader->block_stream_capacity = stream_count; + return 0; +} + +static int +reader_parse_stream_table(BinaryReader *reader, const DecodedBlock *block) +{ + const uint8_t *stream_table = block->columns[COLUMN_STREAM_TABLE].data; + uint64_t initial_prev_timestamp = + block->header.base_timestamp - reader->sample_interval_us; + memset(reader->block_streams, 0, + block->stream_count * sizeof(ReaderBlockStream)); + for (uint32_t i = 0; i < block->stream_count; i++) { + /* Read thread_id (8 bytes) + interpreter_id (4 bytes) */ + const uint8_t *entry = stream_table + (size_t)i * STREAM_ENTRY_SIZE; + uint64_t thread_id; + uint32_t interpreter_id; + memcpy(&thread_id, entry + STM_OFF_THREAD_ID, STM_SIZE_THREAD_ID); + memcpy(&interpreter_id, entry + STM_OFF_INTERPRETER_ID, + STM_SIZE_INTERPRETER_ID); + ThreadEntry *thread = reader_get_or_create_thread_state( + reader, SWAP64_IF(reader->needs_swap, thread_id), + SWAP32_IF(reader->needs_swap, interpreter_id)); + if (thread == NULL) { + return -1; + } + /* Each thread may appear only once in a block. An index left over + * from an earlier block points at a different thread here. */ + uint32_t previous_index = thread->block_stream_index; + if (previous_index < i && + reader->block_streams[previous_index].thread_id == + thread->thread_id && + reader->block_streams[previous_index].interpreter_id == + thread->interpreter_id) { + return block_error("stream table repeats a thread"); + } + thread->block_stream_index = i; + + /* Each stream's first expected timestamp is the base timestamp */ + ReaderBlockStream *stream = &reader->block_streams[i]; + stream->thread_id = thread->thread_id; + stream->interpreter_id = thread->interpreter_id; + stream->prev_timestamp = initial_prev_timestamp; + } + return 0; +} + +static int +decode_samples(BinaryReader *reader, DecodedBlock *block) +{ + size_t sample_count = block->header.sample_count; + if (buffer_reserve(&reader->block_stream_ids, + sample_count * sizeof(uint32_t)) < 0 || + buffer_reserve(&reader->block_timestamps, + sample_count * sizeof(uint64_t)) < 0) { + return -1; + } + uint32_t *stream_ids = (uint32_t *)reader->block_stream_ids.data; + uint64_t *timestamps = (uint64_t *)reader->block_timestamps.data; + const ByteBuffer *stream_id_column = + &block->columns[COLUMN_SAMPLE_STREAM_IDS]; + const ByteBuffer *residual_column = + &block->columns[COLUMN_TIMESTAMP_RESIDUALS]; + int constant_stream_ids = constant_varint_column( + block, COLUMN_SAMPLE_STREAM_IDS, stream_id_column->data[0]); + int constant_residuals = constant_varint_column( + block, COLUMN_TIMESTAMP_RESIDUALS, residual_column->data[0]); + size_t stream_id_offset = 0; + size_t residual_offset = 0; + int64_t constant_residual = 0; + if (constant_residuals) { + constant_residual = decode_varint_i64(residual_column->data, + &residual_offset, 1); + } + for (uint32_t sample = 0; sample < block->header.sample_count; sample++) { + uint64_t stream_id; + if (constant_stream_ids) { + stream_id = stream_id_column->data[0]; + } + else if (block_read_varint(stream_id_column, &stream_id_offset, + &stream_id) < 0) { + return -1; + } + if (stream_id >= block->stream_count) { + return block_error("sample refers to an unknown stream"); + } + int64_t residual = constant_residual; + if (!constant_residuals) { + size_t prev_offset = residual_offset; + residual = decode_varint_i64(residual_column->data, + &residual_offset, + residual_column->size); + if (residual_offset == prev_offset) { return -1; } + } - reader->stats.repeat_records++; - reader->stats.repeat_samples += count; - - /* Process RLE samples, batching by status */ - PyObject *timestamps_list = NULL; - uint8_t batch_status = 0; - Py_ssize_t batch_idx = 0; - - for (uint32_t i = 0; i < count; i++) { - size_t delta_prev_offset = offset; - uint64_t delta = decode_varint_u64(reader->sample_data, &offset, reader->sample_data_size); - if (offset == delta_prev_offset) { - Py_XDECREF(timestamps_list); - PyErr_SetString(PyExc_ValueError, "Malformed varint in RLE sample data"); - return -1; - } - if (offset >= reader->sample_data_size) { - Py_XDECREF(timestamps_list); - PyErr_SetString(PyExc_ValueError, "Unexpected end of sample data in RLE"); - return -1; - } - uint8_t status = reader->sample_data[offset++]; - ts->prev_timestamp += delta; - - /* Start new batch on first sample or status change */ - if (i == 0 || status != batch_status) { - if (timestamps_list) { - int rc = emit_batch(state, collector, thread_id, interpreter_id, - batch_status, ts->current_stack, ts->current_stack_depth, - reader, timestamps_list, batch_idx); - Py_DECREF(timestamps_list); - if (rc < 0) { - return -1; - } - } - timestamps_list = PyList_New(count - i); - if (!timestamps_list) { - return -1; - } - batch_status = status; - batch_idx = 0; - } - - PyObject *ts_obj = PyLong_FromUnsignedLongLong(ts->prev_timestamp); - if (!ts_obj) { - Py_DECREF(timestamps_list); - return -1; - } - PyList_SET_ITEM(timestamps_list, batch_idx++, ts_obj); - } + /* Timestamp is the expected time plus the stored residual */ + ReaderBlockStream *stream = &reader->block_streams[stream_id]; + stream->prev_timestamp += + reader->sample_interval_us + (uint64_t)residual; - /* Emit final batch */ - if (timestamps_list) { - int rc = emit_batch(state, collector, thread_id, interpreter_id, - batch_status, ts->current_stack, ts->current_stack_depth, - reader, timestamps_list, batch_idx); - Py_DECREF(timestamps_list); - if (rc < 0) { - return -1; - } - } + stream_ids[sample] = (uint32_t)stream_id; + timestamps[sample] = stream->prev_timestamp; + } + if (!constant_stream_ids && stream_id_offset != stream_id_column->size) { + return block_error("stream index column has trailing data"); + } + if (residual_offset != residual_column->size) { + return block_error("timestamp column has trailing data"); + } + block->stream_ids = stream_ids; + block->timestamps = timestamps; + return 0; +} - replayed += count; - reader->stats.total_samples += count; +static int +decode_statuses(BinaryReader *reader, DecodedBlock *block) +{ + if (buffer_reserve(&reader->block_statuses, + block->header.sample_count) < 0) { + return -1; + } + /* Start from the common flags, then add each varying flag's bitmap */ + uint8_t *statuses = reader->block_statuses.data; + memset(statuses, block->header.common_status_flags, + block->header.sample_count); + const uint8_t *plane = block->columns[COLUMN_STATUS_BITMAPS].data; + size_t plane_size = status_bitmap_size(block->header.sample_count); + for (unsigned bit = 0; bit < CHAR_BIT; bit++) { + if (!(block->header.status_bitmap_flags & (1U << bit))) { + continue; + } + for (uint32_t i = 0; i < block->header.sample_count; i++) { + statuses[i] |= ((plane[i / CHAR_BIT] >> (i % CHAR_BIT)) & 1U) + << bit; + } + plane += plane_size; + } + block->statuses = statuses; + return 0; +} - /* Progress callback after batch */ - if (replayed % PROGRESS_CALLBACK_INTERVAL < count) { - if (invoke_progress_callback(progress_callback, replayed, reader->sample_count) < 0) { - return -1; - } - } - break; +static int +decode_frame_ids(BinaryReader *reader, DecodedBlock *block) +{ + size_t frame_count = block->frame_count; + size_t frames_size = frame_count * sizeof(uint32_t); + if (buffer_reserve(&reader->block_frames, frames_size) < 0) { + return -1; + } + uint32_t *frames = (uint32_t *)reader->block_frames.data; + block->frames = frames; + if (frame_count == 0) { + return 0; + } + + /* Combine byte b of every frame index from plane b, low byte first */ + memset(frames, 0, frames_size); + const uint8_t *plane = block->columns[COLUMN_FRAME_IDS].data; + for (unsigned byte = 0; byte < block->header.frame_width; byte++) { + for (size_t i = 0; i < frame_count; i++) { + frames[i] |= (uint32_t)plane[i] << (byte * CHAR_BIT); + } + plane += frame_count; + } + for (size_t i = 0; i < frame_count; i++) { + if (frames[i] >= reader->frames_count) { + return block_error("frame index out of range"); } + } + return 0; +} - case STACK_FULL: - case STACK_SUFFIX: - case STACK_POP_PUSH: { - /* All three encodings share: [delta: varint] [status: 1] ... */ - size_t prev_offset = offset; - uint64_t delta = decode_varint_u64(reader->sample_data, &offset, reader->sample_data_size); - /* Detect varint decode failure: offset unchanged means error */ - if (offset == prev_offset) { - PyErr_SetString(PyExc_ValueError, "Malformed varint in sample data"); - return -1; - } - if (offset >= reader->sample_data_size) { - PyErr_SetString(PyExc_ValueError, "Unexpected end of sample data"); - return -1; - } - uint8_t status = reader->sample_data[offset++]; - ts->prev_timestamp += delta; - - if (encoding == STACK_FULL) { - if (decode_stack_full(ts, reader->sample_data, &offset, reader->sample_data_size) < 0) { - return -1; - } - reader->stats.full_records++; - } else if (encoding == STACK_SUFFIX) { - if (decode_stack_suffix(ts, reader->sample_data, &offset, reader->sample_data_size) < 0) { - return -1; - } - reader->stats.suffix_records++; - } else { /* STACK_POP_PUSH */ - if (decode_stack_pop_push(ts, reader->sample_data, &offset, reader->sample_data_size) < 0) { - return -1; - } - reader->stats.pop_push_records++; - } - reader->stats.stack_reconstructions++; +static int +decode_block(BinaryReader *reader, const ByteBuffer *section, + size_t *offset, DecodedBlock *block) +{ + block->instruction_offset = 0; + block->frame_offset = 0; + if (reader_parse_block_header(reader, section, offset, + &block->header) < 0 || + decode_block_columns(reader, section, offset, block) < 0 || + validate_block_columns(block) < 0 || + reserve_block_streams(reader, block->stream_count) < 0 || + reader_parse_stream_table(reader, block) < 0 || + decode_samples(reader, block) < 0 || + decode_statuses(reader, block) < 0 || + decode_frame_ids(reader, block) < 0) { + return -1; + } + return 0; +} - /* Build single-element timestamp list */ - PyObject *ts_obj = PyLong_FromUnsignedLongLong(ts->prev_timestamp); - if (!ts_obj) { - return -1; - } - PyObject *timestamps_list = PyList_New(1); - if (!timestamps_list) { - Py_DECREF(ts_obj); - return -1; - } - PyList_SET_ITEM(timestamps_list, 0, ts_obj); +static int +flush_stream_batch(BinaryReader *reader, RemoteDebuggingState *state, + PyObject *collector, ReaderBlockStream *stream) +{ + if (stream->batch == NULL) { + return 0; + } + int result = emit_sample(state, collector, stream->thread_id, + stream->interpreter_id, stream->batch_status, + stream->current_stack, + stream->current_stack_depth, reader, + stream->batch); + Py_CLEAR(stream->batch); + return result; +} - if (emit_sample(state, collector, thread_id, interpreter_id, status, - ts->current_stack, ts->current_stack_depth, reader, - timestamps_list) < 0) { - Py_DECREF(timestamps_list); - return -1; - } - Py_DECREF(timestamps_list); - if (replayed == PY_SSIZE_T_MAX) { - PyErr_SetString(PyExc_OverflowError, - "Sample count exceeds Py_ssize_t maximum"); - return -1; - } - replayed++; - reader->stats.total_samples++; +static int +decode_stack_repeat(BinaryReader *reader, DecodedBlock *block, + ReaderBlockStream *stream) +{ + const ByteBuffer *instructions = + &block->columns[COLUMN_STACK_INSTRUCTIONS]; + size_t *offset = &block->instruction_offset; + uint64_t count; + if (block_read_varint(instructions, offset, &count) < 0) { + return -1; + } + if (!stream->has_stack) { + return block_error("first stack of a stream cannot repeat"); + } + if (count == 0 || count > block->header.sample_count) { + return block_error("repeat count out of range"); + } + stream->pending_repeats = (uint32_t)(count - 1); + reader->stats.repeat_records++; + reader->stats.repeat_samples++; + return 0; +} + +static int +decode_stack_replace_suffix(BinaryReader *reader, DecodedBlock *block, + ReaderBlockStream *stream) +{ + const ByteBuffer *instructions = + &block->columns[COLUMN_STACK_INSTRUCTIONS]; + size_t *offset = &block->instruction_offset; + uint64_t keep, count; + if (block_read_varint(instructions, offset, &keep) < 0 || + block_read_varint(instructions, offset, &count) < 0) { + return -1; + } + if (keep > stream->current_stack_depth || count > MAX_STACK_DEPTH - keep) { + return block_error("stack prefix out of range"); + } + if (count > block->frame_count - block->frame_offset) { + return block_error("stack uses more frame IDs than stored"); + } + if (count > 0) { + memcpy(&stream->current_stack[keep], + &block->frames[block->frame_offset], count * sizeof(uint32_t)); + } + block->frame_offset += (uint32_t)count; + stream->current_stack_depth = (size_t)(keep + count); + if (keep == 0) { + reader->stats.full_records++; + } + else { + reader->stats.suffix_records++; + } + return 0; +} + +static int +decode_stack_reuse(BinaryReader *reader, DecodedBlock *block, + ReaderBlockStream *stream) +{ + const ByteBuffer *instructions = + &block->columns[COLUMN_STACK_INSTRUCTIONS]; + size_t *offset = &block->instruction_offset; + uint64_t start, count; + if (block_read_varint(instructions, offset, &start) < 0 || + block_read_varint(instructions, offset, &count) < 0) { + return -1; + } + if (count > MAX_STACK_DEPTH) { + return block_error("stack is too deep"); + } + if (start > block->frame_offset || count > block->frame_offset - start) { + return block_error("reused stack is not stored earlier"); + } + if (count > 0) { + memcpy(stream->current_stack, &block->frames[start], + count * sizeof(uint32_t)); + } + stream->current_stack_depth = (size_t)count; + reader->stats.reuse_records++; + return 0; +} + +/* Return 1 if a new stack was decoded, 0 if the stack repeats, -1 on error. */ +static int +decode_stack(BinaryReader *reader, RemoteDebuggingState *state, + PyObject *collector, DecodedBlock *block, + ReaderBlockStream *stream) +{ + /* An earlier REPEAT still covers this sample */ + if (stream->pending_repeats > 0) { + stream->pending_repeats--; + reader->stats.repeat_samples++; + return 0; + } + uint64_t encoding; + if (block_read_varint(&block->columns[COLUMN_STACK_INSTRUCTIONS], + &block->instruction_offset, &encoding) < 0) { + return -1; + } + if (encoding == STACK_REPEAT) { + return decode_stack_repeat(reader, block, stream); + } + + /* The pending batch was collected with the stack being replaced. */ + if (flush_stream_batch(reader, state, collector, stream) < 0) { + return -1; + } + int result; + switch (encoding) { + case STACK_REPLACE_SUFFIX: + result = decode_stack_replace_suffix(reader, block, stream); + break; + case STACK_REUSE: + result = decode_stack_reuse(reader, block, stream); + break; + default: + return block_error("unknown stack instruction"); + } + if (result < 0) { + return -1; + } + stream->has_stack = 1; + reader->stats.stack_reconstructions++; + return 1; +} + +static int +replay_sample(BinaryReader *reader, RemoteDebuggingState *state, + PyObject *collector, DecodedBlock *block, uint32_t sample) +{ + ReaderBlockStream *stream = + &reader->block_streams[block->stream_ids[sample]]; + uint8_t status = block->statuses[sample]; + int new_stack = decode_stack(reader, state, collector, block, stream); + if (new_stack < 0) { + return -1; + } + + /* Start a new batch when the status changes or the batch is full */ + if (stream->batch == NULL || status != stream->batch_status || + PyList_GET_SIZE(stream->batch) >= MAX_RLE_BATCH_SAMPLES) { + if (flush_stream_batch(reader, state, collector, stream) < 0) { + return -1; + } + stream->batch = PyList_New(0); + if (stream->batch == NULL) { + return -1; + } + stream->batch_status = status; + } + PyObject *timestamp = + PyLong_FromUnsignedLongLong(block->timestamps[sample]); + if (timestamp == NULL) { + return -1; + } + int result = PyList_Append(stream->batch, timestamp); + Py_DECREF(timestamp); + if (result < 0) { + return -1; + } + /* Send a new stack's sample immediately so a stream's first sample is + * not held back behind samples from other streams. */ + if (new_stack) { + return flush_stream_batch(reader, state, collector, stream); + } + return 0; +} + +static int +validate_block_consumed(BinaryReader *reader, const DecodedBlock *block) +{ + if (block->instruction_offset != + block->columns[COLUMN_STACK_INSTRUCTIONS].size) { + return block_error("stack instruction column has trailing data"); + } + if (block->frame_offset != block->frame_count) { + return block_error("frame ID column has unused values"); + } + for (uint32_t i = 0; i < block->stream_count; i++) { + if (!reader->block_streams[i].has_stack) { + return block_error("stream table has an unused entry"); + } + if (reader->block_streams[i].pending_repeats != 0) { + return block_error("repeat count extends past the block"); + } + } + return 0; +} + +static int +replay_block(BinaryReader *reader, RemoteDebuggingState *state, + PyObject *collector, PyObject *progress_callback, + DecodedBlock *block, Py_ssize_t *replayed) +{ + if ((uint64_t)block->header.sample_count > + reader->sample_count - (uint64_t)*replayed) { + return block_error("more samples than the file header declares"); + } + int result = 0; + for (uint32_t sample = 0; sample < block->header.sample_count; sample++) { + if (replay_sample(reader, state, collector, block, sample) < 0) { + result = -1; break; } + (*replayed)++; + reader->stats.total_samples++; + if (*replayed % PROGRESS_CALLBACK_INTERVAL == 0 && + invoke_progress_callback(progress_callback, *replayed, + reader->sample_count) < 0) { + result = -1; + break; + } + } + if (result == 0) { + result = validate_block_consumed(reader, block); + } - default: - PyErr_Format(PyExc_ValueError, "Unknown stack encoding: %u", encoding); + /* Send the remaining batches, or drop them after an error. */ + for (uint32_t i = 0; i < block->stream_count; i++) { + ReaderBlockStream *stream = &reader->block_streams[i]; + if (result == 0 && + flush_stream_batch(reader, state, collector, stream) < 0) { + result = -1; + } + Py_CLEAR(stream->batch); + } + + return result; +} + +/* Set section and offset to the block at sample offset pos */ +#if USE_MMAP +static int +reader_load_samples(BinaryReader *reader, size_t pos, ByteBuffer *section, + size_t *offset) +{ + *section = (ByteBuffer){reader->sample_data, reader->sample_data_size, 0}; + *offset = pos; + return 0; +} +#else +static int +reader_load_samples(BinaryReader *reader, size_t pos, ByteBuffer *section, + size_t *offset) +{ + ByteBuffer *window = &reader->sample_window; + if (pos == 0) { + /* A new replay starts at the first block */ + if (buffer_reserve(window, Py_MIN(SAMPLE_WINDOW_SIZE, + reader->sample_data_size)) < 0) { return -1; } + if (FSEEK64(reader->fp, FILE_HEADER_PLACEHOLDER_SIZE, SEEK_SET) != 0) { + PyErr_SetFromErrno(PyExc_IOError); + return -1; + } + window->size = 0; + reader->sample_window_start = 0; + } + + size_t start = reader->sample_window_start; + size_t end = start + window->size; + size_t needed = Py_MIN(MAX_STORED_BLOCK_SIZE, + reader->sample_data_size - pos); + if (end - pos < needed) { + /* Keep the unread bytes and refill the rest */ + size_t kept = end - pos; + memmove(window->data, window->data + (pos - start), kept); + size_t size = Py_MIN(SAMPLE_WINDOW_SIZE - kept, + reader->sample_data_size - end); + if (fread_checked_allow_threads(window->data + kept, size, + reader->fp) < 0) { + return -1; + } + reader->sample_window_start = pos; + window->size = kept + size; + } + *section = (ByteBuffer){window->data, window->size, 0}; + *offset = pos - reader->sample_window_start; + return 0; +} +#endif - /* Progress callback */ - if (replayed % PROGRESS_CALLBACK_INTERVAL == 0) { - if (invoke_progress_callback(progress_callback, replayed, reader->sample_count) < 0) { - return -1; - } +static int +replay_blocks(BinaryReader *reader, RemoteDebuggingState *state, + PyObject *collector, PyObject *progress_callback, + Py_ssize_t *replayed) +{ + size_t pos = 0; + size_t discarded = 0; + while (pos < reader->sample_data_size) { + ByteBuffer section; + size_t offset; + if (reader_load_samples(reader, pos, §ion, &offset) < 0) { + return -1; } + size_t block_start = offset; + DecodedBlock block; + if (decode_block(reader, §ion, &offset, &block) < 0 || + replay_block(reader, state, collector, progress_callback, + &block, replayed) < 0) { + return -1; + } + pos += offset - block_start; + discarded = reader_discard_mapped_pages( + reader, discarded, FILE_HEADER_PLACEHOLDER_SIZE + pos); + } + return 0; +} + +static Py_ssize_t +replay_all_samples(BinaryReader *reader, PyObject *collector, + PyObject *progress_callback) +{ + PyObject *collect_method; + int has_collect = PyObject_GetOptionalAttrString(collector, "collect", &collect_method); + if (has_collect < 0) { + return -1; + } + if (has_collect == 0) { + PyErr_SetString(PyExc_TypeError, "Collector must have a collect() method"); + return -1; + } + Py_DECREF(collect_method); + + /* Get module state for struct sequence types */ + PyObject *module = PyImport_ImportModule("_remote_debugging"); + if (!module) { + return -1; + } + RemoteDebuggingState *state = RemoteDebugging_GetState(module); + Py_DECREF(module); + + if (!state) { + PyErr_SetString(PyExc_RuntimeError, "Failed to get module state"); + return -1; + } + if (reader->sample_count > (uint64_t)PY_SSIZE_T_MAX) { + PyErr_SetString(PyExc_OverflowError, + "Sample count exceeds Py_ssize_t maximum"); + return -1; + } + + /* Initial progress callback at 0% */ + if (invoke_progress_callback(progress_callback, 0, reader->sample_count) < 0) { + return -1; + } + + memset(&reader->stats, 0, sizeof(reader->stats)); + Py_ssize_t replayed = 0; + if (replay_blocks(reader, state, collector, progress_callback, + &replayed) < 0) { + return -1; } if ((uint64_t)replayed != reader->sample_count) { @@ -1253,8 +1775,25 @@ binary_reader_replay(BinaryReader *reader, PyObject *collector, PyObject *progre (unsigned long long)reader->sample_count, replayed); return -1; } + return replayed; +} - /* Final progress callback at 100% */ +Py_ssize_t +binary_reader_replay(BinaryReader *reader, PyObject *collector, PyObject *progress_callback) +{ + if (reader->replaying) { + PyErr_SetString(PyExc_RuntimeError, "Reader is already replaying"); + return -1; + } + reader->replaying = 1; + Py_ssize_t replayed = replay_all_samples(reader, collector, + progress_callback); + reader->replaying = 0; + if (replayed < 0) { + return -1; + } + + /* Final progress callback at 100%; it may close the reader */ if (invoke_progress_callback(progress_callback, replayed, reader->sample_count) < 0) { return -1; } @@ -1270,8 +1809,63 @@ binary_reader_get_info(BinaryReader *reader) if (py_version == NULL) { return NULL; } + PyObject *duration = reader->has_profile_stats + ? PyFloat_FromDouble(reader->duration_sec) : Py_NewRef(Py_None); + if (duration == NULL) { + Py_DECREF(py_version); + return NULL; + } + PyObject *sample_rate = reader->has_profile_stats + ? PyFloat_FromDouble(reader->sample_rate) : Py_NewRef(Py_None); + if (sample_rate == NULL) { + Py_DECREF(py_version); + Py_DECREF(duration); + return NULL; + } + PyObject *error_rate = + reader->profile_stats_present & PROFILE_STATS_ERROR_RATE + ? PyFloat_FromDouble(reader->error_rate) : Py_NewRef(Py_None); + if (error_rate == NULL) { + Py_DECREF(py_version); + Py_DECREF(duration); + Py_DECREF(sample_rate); + return NULL; + } + PyObject *missed_samples = + reader->profile_stats_present & PROFILE_STATS_MISSED + ? PyFloat_FromDouble(reader->missed_samples) : Py_NewRef(Py_None); + if (missed_samples == NULL) { + Py_DECREF(py_version); + Py_DECREF(duration); + Py_DECREF(sample_rate); + Py_DECREF(error_rate); + return NULL; + } + PyObject *profiling_mode = reader->profiling_mode < 0 + ? Py_NewRef(Py_None) + : PyLong_FromLong(reader->profiling_mode); + if (profiling_mode == NULL) { + Py_DECREF(py_version); + Py_DECREF(duration); + Py_DECREF(sample_rate); + Py_DECREF(error_rate); + Py_DECREF(missed_samples); + return NULL; + } + PyObject *capture_features = reader->capture_features < 0 + ? Py_NewRef(Py_None) + : PyLong_FromLong(reader->capture_features); + if (capture_features == NULL) { + Py_DECREF(py_version); + Py_DECREF(profiling_mode); + Py_DECREF(duration); + Py_DECREF(sample_rate); + Py_DECREF(error_rate); + Py_DECREF(missed_samples); + return NULL; + } return Py_BuildValue( - "{s:I, s:N, s:K, s:K, s:K, s:I, s:I, s:I, s:i}", + "{s:I, s:N, s:K, s:K, s:K, s:I, s:I, s:I, s:i, s:N, s:N, s:N, s:N, s:N, s:N}", "version", BINARY_FORMAT_VERSION, "python_version", py_version, "start_time_us", reader->start_time_us, @@ -1280,7 +1874,13 @@ binary_reader_get_info(BinaryReader *reader) "thread_count", reader->thread_count, "string_count", reader->strings_count, "frame_count", reader->frames_count, - "compression_type", reader->compression_type + "compression_type", reader->compression_type, + "duration_sec", duration, + "sample_rate", sample_rate, + "error_rate", error_rate, + "missed_samples", missed_samples, + "mode", profiling_mode, + "capture_features", capture_features ); } @@ -1291,8 +1891,9 @@ binary_writer_get_stats(BinaryWriter *writer) /* Calculate derived stats */ uint64_t total_records = s->repeat_records + s->full_records + - s->suffix_records + s->pop_push_records; + s->suffix_records + s->reuse_records; uint64_t total_samples = writer->total_samples; + uint64_t bytes_written = s->bytes_written + binary_writer_buffered_size(writer); uint64_t potential_frames = s->total_frames_written + s->frames_saved; double compression_ratio = (potential_frames > 0) ? (double)s->frames_saved / potential_frames * 100.0 : 0.0; @@ -1303,12 +1904,12 @@ binary_writer_get_stats(BinaryWriter *writer) "repeat_samples", s->repeat_samples, "full_records", s->full_records, "suffix_records", s->suffix_records, - "pop_push_records", s->pop_push_records, + "reuse_records", s->reuse_records, "total_records", total_records, "total_samples", total_samples, "total_frames_written", s->total_frames_written, "frames_saved", s->frames_saved, - "bytes_written", s->bytes_written, + "bytes_written", bytes_written, "frame_compression_pct", compression_ratio ); } @@ -1319,7 +1920,7 @@ binary_reader_get_stats(BinaryReader *reader) BinaryReaderStats *s = &reader->stats; uint64_t total_records = s->repeat_records + s->full_records + - s->suffix_records + s->pop_push_records; + s->suffix_records + s->reuse_records; return Py_BuildValue( "{s:K, s:K, s:K, s:K, s:K, s:K, s:K, s:K}", @@ -1327,7 +1928,7 @@ binary_reader_get_stats(BinaryReader *reader) "repeat_samples", s->repeat_samples, "full_records", s->full_records, "suffix_records", s->suffix_records, - "pop_push_records", s->pop_push_records, + "reuse_records", s->reuse_records, "total_records", total_records, "total_samples", s->total_samples, "stack_reconstructions", s->stack_reconstructions @@ -1355,14 +1956,28 @@ binary_reader_close(BinaryReader *reader) Py_fclose(reader->fp); reader->fp = NULL; } - if (reader->file_data) { - PyMem_Free(reader->file_data); - reader->file_data = NULL; - reader->file_size = 0; - } + PyMem_Free(reader->table_data); + reader->table_data = NULL; + buffer_clear(&reader->sample_window); + reader->file_size = 0; #endif - PyMem_Free(reader->decompressed_data); +#ifdef HAVE_ZSTD + ZSTD_freeDCtx(reader->dctx); +#endif + buffer_clear(&reader->block_data); + buffer_clear(&reader->block_stream_ids); + buffer_clear(&reader->block_timestamps); + buffer_clear(&reader->block_statuses); + buffer_clear(&reader->block_frames); + PyMem_Free(reader->block_streams); + + if (reader->frame_info_cache != NULL) { + for (size_t i = 0; i < reader->frame_info_cache_size; i++) { + Py_XDECREF(reader->frame_info_cache[i].frame_info); + } + PyMem_Free(reader->frame_info_cache); + } if (reader->strings) { for (uint32_t i = 0; i < reader->strings_count; i++) { @@ -1373,12 +1988,7 @@ binary_reader_close(BinaryReader *reader) PyMem_Free(reader->frames); - if (reader->thread_states) { - for (size_t i = 0; i < reader->thread_state_count; i++) { - PyMem_Free(reader->thread_states[i].current_stack); - } - PyMem_Free(reader->thread_states); - } + PyMem_Free(reader->thread_states); PyMem_Free(reader); } diff --git a/Modules/_remote_debugging/binary_io_writer.c b/Modules/_remote_debugging/binary_io_writer.c index e2ac40d96b39bee..50bbbedd5d5355d 100644 --- a/Modules/_remote_debugging/binary_io_writer.c +++ b/Modules/_remote_debugging/binary_io_writer.c @@ -2,7 +2,7 @@ * Python Remote Debugging Module - Binary Writer Implementation * * High-performance binary file writer for profiling data with optional zstd - * streaming compression. + * compression. ******************************************************************************/ #ifndef Py_BUILD_CORE_MODULE @@ -11,27 +11,86 @@ #include "binary_io.h" #include "_remote_debugging.h" +#include "pycore_bitutils.h" // _Py_bit_length(), _Py_popcount32() #include "pycore_opcode_utils.h" // MAX_REAL_OPCODE +#include #include #ifdef HAVE_ZSTD #include #endif +#ifdef _Py_MEMORY_SANITIZER +# include +#endif + /* ============================================================================ * CONSTANTS FOR BINARY FORMAT SIZES * ============================================================================ */ -/* Sample header sizes */ -#define SAMPLE_HEADER_MAX_SIZE 26 /* fixed + max_varint(10) + status(1) + margin */ #define MAX_VARINT_SIZE 10 /* Maximum bytes for a varint64 */ #define MAX_VARINT_SIZE_U32 5 /* Maximum bytes for a varint32 */ -/* Frame buffer: depth varint (max 2 bytes for 256) + 256 frames * 5 bytes/varint + margin */ -#define MAX_FRAME_BUFFER_SIZE ((MAX_STACK_DEPTH * MAX_VARINT_SIZE_U32) + MAX_VARINT_SIZE_U32 + 16) -/* RLE pending buffer (per thread): one entry is a u64 delta varint + status byte */ -#define MAX_RLE_BUF_SIZE (16 * 1024) -#define MAX_RLE_ENTRY_SIZE (MAX_VARINT_SIZE + sizeof(uint8_t)) +#define MAX_BLOCK_HEADER_SIZE \ + (BLOCK_MAGIC_SIZE + MAX_VARINT_SIZE_U32 + MAX_VARINT_SIZE + \ + 3 * sizeof(uint8_t) + \ + COLUMN_COUNT * (2 * MAX_VARINT_SIZE_U32 + sizeof(uint8_t))) + +#define ZSTD_MIN_SIZE 32 +#define STACK_REUSE_MIN_FRAMES 3 + +#define MAX_SAMPLE_SIZE \ + (STREAM_ENTRY_SIZE + 5 * MAX_VARINT_SIZE + sizeof(uint8_t) + \ + MAX_STACK_DEPTH * sizeof(uint32_t) + sizeof(Repeat)) +#define MAX_BITMAP_PADDING (CHAR_BIT - 1) +#define BLOCK_FLUSH_SIZE \ + (MAX_BLOCK_SIZE - MAX_SAMPLE_SIZE - MAX_BITMAP_PADDING) + +static int +buffer_append(ByteBuffer *buffer, const void *data, size_t size) +{ + if (buffer->size > MAX_BLOCK_SIZE || + size > MAX_BLOCK_SIZE - buffer->size) { + PyErr_SetString(PyExc_RuntimeError, + "sample block buffer exceeds the writer safety limit"); + return -1; + } + if (buffer_reserve(buffer, buffer->size + size) < 0) { + return -1; + } + if (size != 0) { + memcpy(buffer->data + buffer->size, data, size); + } + buffer->size += size; + return 0; +} + +static int +buffer_append_varint(ByteBuffer *buffer, uint64_t value) +{ + uint8_t bytes[MAX_VARINT_SIZE]; + size_t size = encode_varint_u64(bytes, value); + return buffer_append(buffer, bytes, size); +} + +static int +column_write(SampleBlock *block, unsigned column, const void *data, + size_t size) +{ + if (buffer_append(&block->columns[column], data, size) < 0) { + return -1; + } + block->size += size; + return 0; +} + +static int +column_write_varint(SampleBlock *block, unsigned column, uint64_t value) +{ + uint8_t bytes[MAX_VARINT_SIZE]; + size_t size = encode_varint_u64(bytes, value); + return column_write(block, column, bytes, size); +} /* Helper macro: convert PyLong to int32, using default_val if conversion fails */ #define PYLONG_TO_INT32_OR_DEFAULT(obj, var, default_val) \ @@ -126,19 +185,6 @@ fwrite_checked_allow_threads(const void *data, size_t size, FILE *fp) return 0; } -/* Forward declaration for writer_write_bytes */ -static inline int writer_write_bytes(BinaryWriter *writer, const void *data, size_t size); - -/* Encode and write a varint u32 - returns 0 on success, -1 on error */ -static inline int -writer_write_varint_u32(BinaryWriter *writer, uint32_t value) -{ - uint8_t buf[MAX_VARINT_SIZE]; - size_t len = encode_varint_u32(buf, value); - return writer_write_bytes(writer, buf, len); -} - - /* ============================================================================ * UTILITY FUNCTIONS * ============================================================================ */ @@ -177,9 +223,9 @@ writer_init_zstd(BinaryWriter *writer) return -1; } - /* Compression level 5: better ratio for repetitive profiling data */ + /* Compression level 3: good ratio without slowing down each block flush */ size_t result = ZSTD_CCtx_setParameter(writer->zstd.cctx, - ZSTD_c_compressionLevel, 5); + ZSTD_c_compressionLevel, 3); if (ZSTD_isError(result)) { PyErr_Format(PyExc_RuntimeError, "Failed to set zstd compression level: %s", ZSTD_getErrorName(result)); @@ -188,16 +234,6 @@ writer_init_zstd(BinaryWriter *writer) return -1; } - /* Use large buffer (512KB) for fewer I/O syscalls */ - writer->zstd.compressed_buffer = PyMem_Malloc(COMPRESSED_BUFFER_SIZE); - if (!writer->zstd.compressed_buffer) { - ZSTD_freeCCtx(writer->zstd.cctx); - writer->zstd.cctx = NULL; - PyErr_NoMemory(); - return -1; - } - writer->zstd.compressed_buffer_size = COMPRESSED_BUFFER_SIZE; - return 0; #else PyErr_SetString(PyExc_RuntimeError, @@ -206,78 +242,6 @@ writer_init_zstd(BinaryWriter *writer) #endif } -static int -writer_flush_buffer(BinaryWriter *writer) -{ - if (writer->buffer_pos == 0) { - return 0; - } - -#ifdef HAVE_ZSTD - if (writer->compression_type == COMPRESSION_ZSTD) { - ZSTD_inBuffer input = { writer->write_buffer, writer->buffer_pos, 0 }; - - while (input.pos < input.size) { - ZSTD_outBuffer output = { - writer->zstd.compressed_buffer, - writer->zstd.compressed_buffer_size, - 0 - }; - - size_t result = ZSTD_compressStream2( - writer->zstd.cctx, &output, &input, ZSTD_e_continue - ); - - if (ZSTD_isError(result)) { - PyErr_Format(PyExc_IOError, "zstd compression error: %s", - ZSTD_getErrorName(result)); - return -1; - } - - if (output.pos > 0) { - if (fwrite_checked_allow_threads(writer->zstd.compressed_buffer, output.pos, writer->fp) < 0) { - return -1; - } - } - } - } else -#endif - { - if (fwrite_checked_allow_threads(writer->write_buffer, writer->buffer_pos, writer->fp) < 0) { - return -1; - } - } - - writer->buffer_pos = 0; - return 0; -} - -static inline int -writer_write_bytes(BinaryWriter *writer, const void *data, size_t size) -{ - const uint8_t *src = (const uint8_t *)data; - size_t original_size = size; - - while (size > 0) { - size_t space = writer->buffer_size - writer->buffer_pos; - size_t to_copy = (size < space) ? size : space; - - memcpy(writer->write_buffer + writer->buffer_pos, src, to_copy); - writer->buffer_pos += to_copy; - src += to_copy; - size -= to_copy; - - if (writer->buffer_pos == writer->buffer_size) { - if (writer_flush_buffer(writer) < 0) { - return -1; - } - } - } - - writer->stats.bytes_written += original_size; - return 0; -} - /* ============================================================================ * HASH TABLE SUPPORT FUNCTIONS (using _Py_hashtable) * ============================================================================ */ @@ -370,6 +334,7 @@ writer_intern_string(BinaryWriter *writer, PyObject *string, uint32_t *index) } if (writer->string_count >= UINT32_MAX) { + writer->state = BINARY_WRITER_LIMIT_REACHED; PyErr_SetString(PyExc_OverflowError, "too many strings for binary format"); return -1; @@ -379,16 +344,23 @@ writer_intern_string(BinaryWriter *writer, PyObject *string, uint32_t *index) (void **)&writer->string_lengths, &writer->string_capacity, sizeof(char *), sizeof(size_t)) < 0) { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) { + writer->state = BINARY_WRITER_LIMIT_REACHED; + } return -1; } } - Py_ssize_t str_len; - const char *str_data = PyUnicode_AsUTF8AndSize(string, &str_len); - if (!str_data) { + /* Frame names can contain surrogates (e.g. from undecodable filenames). + * Escape them to keep the string table valid UTF-8. */ + PyObject *encoded = PyUnicode_AsEncodedString(string, "utf-8", "backslashreplace"); + if (encoded == NULL) { return -1; } + Py_ssize_t str_len = PyBytes_GET_SIZE(encoded); if ((uintmax_t)str_len > UINT32_MAX) { + Py_DECREF(encoded); + writer->state = BINARY_WRITER_LIMIT_REACHED; PyErr_Format(PyExc_OverflowError, "string length %zd exceeds binary format maximum %u", str_len, UINT32_MAX); @@ -397,10 +369,12 @@ writer_intern_string(BinaryWriter *writer, PyObject *string, uint32_t *index) char *str_copy = PyMem_Malloc(str_len + 1); if (!str_copy) { + Py_DECREF(encoded); PyErr_NoMemory(); return -1; } - memcpy(str_copy, str_data, str_len + 1); + memcpy(str_copy, PyBytes_AS_STRING(encoded), str_len + 1); + Py_DECREF(encoded); *index = (uint32_t)writer->string_count; @@ -437,12 +411,16 @@ writer_intern_frame(BinaryWriter *writer, const FrameEntry *entry, uint32_t *ind } if (writer->frame_count >= UINT32_MAX) { + writer->state = BINARY_WRITER_LIMIT_REACHED; PyErr_SetString(PyExc_OverflowError, "too many frames for binary format"); return -1; } if (GROW_ARRAY(writer->frame_entries, writer->frame_count, writer->frame_capacity, FrameEntry) < 0) { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) { + writer->state = BINARY_WRITER_LIMIT_REACHED; + } return -1; } @@ -466,269 +444,640 @@ writer_intern_frame(BinaryWriter *writer, const FrameEntry *entry, uint32_t *ind return 0; } -/* Get or create a thread entry for the given thread_id. - * Returns pointer to ThreadEntry, or NULL on allocation failure. - * If is_new is non-NULL, sets it to 1 if this is a new thread, 0 otherwise. */ +/* Get or create the entry for a (thread, interpreter) pair. */ static ThreadEntry * writer_get_or_create_thread_entry(BinaryWriter *writer, uint64_t thread_id, - uint32_t interpreter_id, int *is_new) + uint32_t interpreter_id) { /* Linear search is OK for small number of threads. * Key is (thread_id, interpreter_id) since same thread_id can exist in different interpreters. */ for (size_t i = 0; i < writer->thread_count; i++) { if (writer->thread_entries[i].thread_id == thread_id && writer->thread_entries[i].interpreter_id == interpreter_id) { - if (is_new) { - *is_new = 0; - } return &writer->thread_entries[i]; } } if (writer->thread_count >= UINT32_MAX) { + writer->state = BINARY_WRITER_LIMIT_REACHED; PyErr_SetString(PyExc_OverflowError, "too many threads for binary format"); return NULL; } - if (writer->thread_count >= writer->thread_capacity) { - ThreadEntry *new_entries = grow_array(writer->thread_entries, - &writer->thread_capacity, - sizeof(ThreadEntry)); - if (!new_entries) { - return NULL; + if (GROW_ARRAY(writer->thread_entries, writer->thread_count, + writer->thread_capacity, ThreadEntry) < 0) { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) { + writer->state = BINARY_WRITER_LIMIT_REACHED; } - writer->thread_entries = new_entries; + return NULL; } ThreadEntry *entry = &writer->thread_entries[writer->thread_count]; memset(entry, 0, sizeof(ThreadEntry)); entry->thread_id = thread_id; entry->interpreter_id = interpreter_id; - entry->prev_timestamp = writer->start_time_us; - entry->prev_stack_capacity = MAX_STACK_DEPTH; - - entry->prev_stack = PyMem_Calloc(entry->prev_stack_capacity, sizeof(uint32_t)); - if (!entry->prev_stack) { - PyErr_NoMemory(); - return NULL; - } + entry->block_stream_index = UINT32_MAX; writer->thread_count++; - if (is_new) { - *is_new = 1; - } return entry; } -/* Compare two stacks and return the encoding type and parameters. - * Sets: - * - shared_count: number of frames matching from bottom of stack - * - pop_count: frames to remove from prev stack - * - push_count: new frames to add - * - * Returns the best encoding type to use. */ static int -compare_stacks(const uint32_t *prev_stack, size_t prev_depth, - const uint32_t *curr_stack, size_t curr_depth, - size_t *shared_count, size_t *pop_count, size_t *push_count) +encode_column(BinaryWriter *writer, const ByteBuffer *decoded, + ColumnDescriptor *descriptor) { - if (prev_depth == curr_depth) { - int identical = 1; - for (size_t i = 0; i < prev_depth; i++) { - if (prev_stack[i] != curr_stack[i]) { - identical = 0; - break; - } + SampleBlock *block = writer->block; + const uint8_t *data = decoded->data; + size_t size = decoded->size; + uint8_t encoding = COMPRESSION_NONE; + if (size > 1 && memcmp(data, data + 1, size - 1) == 0) { + encoding = COLUMN_CONSTANT; + size = 1; + } +#ifdef HAVE_ZSTD + if (encoding == COMPRESSION_NONE && size >= ZSTD_MIN_SIZE && + writer->compression_type == COMPRESSION_ZSTD) { + size_t compress_bound = ZSTD_compressBound(size); + if (buffer_reserve(&block->compressed, compress_bound) < 0) { + return -1; + } + size_t compressed_size = ZSTD_compress2( + writer->zstd.cctx, block->compressed.data, compress_bound, + data, size); + if (ZSTD_isError(compressed_size)) { + PyErr_Format(PyExc_IOError, "zstd compression error: %s", + ZSTD_getErrorName(compressed_size)); + return -1; } - if (identical) { - *shared_count = prev_depth; - *pop_count = 0; - *push_count = 0; - return STACK_REPEAT; + _Py_MSAN_UNPOISON(block->compressed.data, compressed_size); + uint8_t stored_size[MAX_VARINT_SIZE]; + if (compressed_size + encode_varint_u64(stored_size, compressed_size) + < size) { + data = block->compressed.data; + size = compressed_size; + encoding = COMPRESSION_ZSTD; } } +#endif + descriptor->decoded_size = (uint32_t)decoded->size; + descriptor->stored_size = (uint32_t)size; + descriptor->encoding = encoding; + if (buffer_reserve(&block->output, block->output.size + size) < 0) { + return -1; + } + if (size != 0) { + memcpy(block->output.data + block->output.size, data, size); + } + block->output.size += size; + return 0; +} - /* Find longest common suffix (frames at the bottom/outer part of stack). - * Stacks are stored innermost-first, so suffix is at the end. */ - size_t suffix_len = 0; - size_t min_depth = (prev_depth < curr_depth) ? prev_depth : curr_depth; - - for (size_t i = 0; i < min_depth; i++) { - size_t prev_idx = prev_depth - 1 - i; - size_t curr_idx = curr_depth - 1 - i; - if (prev_stack[prev_idx] == curr_stack[curr_idx]) { - suffix_len++; - } else { - break; +static ByteBuffer * +transform_statuses(SampleBlock *block, uint8_t bitmap_flags) +{ + size_t plane_size = status_bitmap_size(block->sample_count); + unsigned plane_count = (unsigned)_Py_popcount32(bitmap_flags); + if (buffer_reserve(&block->transformed, + plane_size * plane_count) < 0) { + return NULL; + } + const uint8_t *statuses = + block->columns[COLUMN_STATUS_BITMAPS].data; + block->transformed.size = 0; + for (unsigned bit = 0; bit < CHAR_BIT; bit++) { + if (!(bitmap_flags & (1U << bit))) { + continue; + } + uint8_t *plane = block->transformed.data + block->transformed.size; + memset(plane, 0, plane_size); + for (uint32_t sample = 0; sample < block->sample_count; sample++) { + plane[sample / CHAR_BIT] |= ((statuses[sample] >> bit) & 1U) + << (sample % CHAR_BIT); } + block->transformed.size += plane_size; } + return &block->transformed; +} - *shared_count = suffix_len; - *pop_count = prev_depth - suffix_len; - *push_count = curr_depth - suffix_len; - - /* Choose best encoding based on byte cost */ - /* STACK_FULL: 1 (type) + 1-2 (depth) + sum(frame varints) */ - /* STACK_SUFFIX: 1 (type) + 1-2 (shared) + 1-2 (new_count) + sum(new frame varints) */ - /* STACK_POP_PUSH: 1 (type) + 1-2 (pop) + 1-2 (push) + sum(new frame varints) */ - - /* If no common suffix, use full stack */ - if (suffix_len == 0) { - return STACK_FULL; +static ByteBuffer * +transform_frame_ids(SampleBlock *block, unsigned width) +{ + ByteBuffer *frames = &block->columns[COLUMN_FRAME_IDS]; + size_t frame_count = frames->size / sizeof(uint32_t); + if (buffer_reserve(&block->transformed, + frame_count * width) < 0) { + return NULL; } - - /* If only adding frames (suffix == prev_depth), use SUFFIX */ - if (*pop_count == 0 && *push_count > 0) { - return STACK_SUFFIX; + const uint32_t *frame_ids = (const uint32_t *)frames->data; + for (unsigned byte = 0; frame_count && byte < width; byte++) { + uint8_t *plane = + block->transformed.data + (size_t)byte * frame_count; + for (uint32_t frame = 0; frame < frame_count; frame++) { + plane[frame] = + (uint8_t)(frame_ids[frame] >> (byte * CHAR_BIT)); + } } + block->transformed.size = frame_count * width; + return &block->transformed; +} - /* If popping and/or pushing, use POP_PUSH if it saves bytes */ - /* Heuristic: POP_PUSH is better when we're modifying top frames */ - if (*pop_count > 0 || *push_count > 0) { - /* Use full stack if sharing less than half the frames */ - if (suffix_len < curr_depth / 2) { - return STACK_FULL; +static ByteBuffer * +transform_stack_instructions(SampleBlock *block) +{ + ByteBuffer *instructions = + &block->columns[COLUMN_STACK_INSTRUCTIONS]; + size_t repeat_count = block->repeats.size / sizeof(Repeat); + if (repeat_count == 0) { + return instructions; + } + const Repeat *repeats = (const Repeat *)block->repeats.data; + size_t copied_offset = 0; + block->transformed.size = 0; + for (size_t i = 0; i < repeat_count; i++) { + if (buffer_append(&block->transformed, + instructions->data + copied_offset, + repeats[i].offset - copied_offset) < 0 || + buffer_append_varint( + &block->transformed, STACK_REPEAT) < 0 || + buffer_append_varint( + &block->transformed, repeats[i].count) < 0) { + return NULL; } - return STACK_POP_PUSH; + copied_offset = repeats[i].offset; } + if (buffer_append(&block->transformed, + instructions->data + copied_offset, + instructions->size - copied_offset) < 0) { + return NULL; + } + return &block->transformed; +} + +static void +block_reset(BinaryWriter *writer) +{ + SampleBlock *block = writer->block; + /* Only threads with a stream in this block need resetting */ + for (uint32_t i = 0; i < block->stream_count; i++) { + size_t thread = block->streams[i].thread_index; + writer->thread_entries[thread].block_stream_index = UINT32_MAX; + } + for (unsigned column = 0; column < COLUMN_COUNT; column++) { + block->columns[column].size = 0; + } + block->sample_count = 0; + block->stream_count = 0; + block->repeats.size = 0; + block->max_frame = 0; + block->size = 0; + memset(block->cache, 0, sizeof(block->cache)); +} - return STACK_FULL; +static unsigned +block_frame_width(const SampleBlock *block) +{ + if (block->max_frame == 0) { + return 1; + } + return (unsigned)(_Py_bit_length(block->max_frame) + CHAR_BIT - 1) + / CHAR_BIT; } -/* Write common sample header: thread_id(8) + interpreter_id(4) + encoding(1). - * Returns 0 on success, -1 on failure. */ -static inline int -write_sample_header(BinaryWriter *writer, ThreadEntry *entry, uint8_t encoding) +static void +block_status_flags(const SampleBlock *block, uint8_t *common_flags, + uint8_t *bitmap_flags) +{ + uint8_t common_status = UINT8_MAX; + uint8_t any_status = 0; + const uint8_t *statuses = block->columns[COLUMN_STATUS_BITMAPS].data; + for (uint32_t sample = 0; sample < block->sample_count; sample++) { + common_status &= statuses[sample]; + any_status |= statuses[sample]; + } + *common_flags = common_status; + *bitmap_flags = any_status ^ common_status; +} + +static size_t +write_block_header(const BlockHeader *header, uint8_t *bytes) { - uint8_t header[SAMPLE_HEADER_FIXED_SIZE]; - memcpy(header + SMP_OFF_THREAD_ID, &entry->thread_id, SMP_SIZE_THREAD_ID); - memcpy(header + SMP_OFF_INTERPRETER_ID, &entry->interpreter_id, SMP_SIZE_INTERPRETER_ID); - header[SMP_OFF_ENCODING] = encoding; - return writer_write_bytes(writer, header, SAMPLE_HEADER_FIXED_SIZE); + /* Magic "TBLK", sample count and base timestamp (varints), then frame + * ID width and the two status flag masks (1 byte each) */ + size_t size = BLOCK_MAGIC_SIZE; + memcpy(bytes, BLOCK_MAGIC, BLOCK_MAGIC_SIZE); + size += encode_varint_u32(bytes + size, header->sample_count); + size += encode_varint_u64(bytes + size, header->base_timestamp); + bytes[size++] = header->frame_width; + bytes[size++] = header->common_status_flags; + bytes[size++] = header->status_bitmap_flags; + + /* Each column: decoded size (varint), encoding (1 byte), and the stored + * size (varint) for zstd only */ + for (unsigned column = 0; column < COLUMN_COUNT; column++) { + const ColumnDescriptor *descriptor = &header->columns[column]; + size += encode_varint_u32(bytes + size, descriptor->decoded_size); + bytes[size++] = descriptor->encoding; + if (descriptor->encoding == COMPRESSION_ZSTD) { + size += encode_varint_u32(bytes + size, descriptor->stored_size); + } + } + return size; } -/* Flush pending RLE samples for a thread. - * Writes the RLE record to the output buffer. - * Returns 0 on success, -1 on failure. */ static int -flush_pending_rle(BinaryWriter *writer, ThreadEntry *entry) +block_flush(BinaryWriter *writer) { - if (entry->pending_rle_samples == 0) { + SampleBlock *block = writer->block; + if (block->sample_count == 0) { return 0; } + BlockHeader header = {0}; + header.sample_count = block->sample_count; + header.base_timestamp = block->base_timestamp; + header.frame_width = (uint8_t)block_frame_width(block); + block_status_flags(block, &header.common_status_flags, + &header.status_bitmap_flags); - /* Write RLE record: - * [thread_id: 8] [interpreter_id: 4] [STACK_REPEAT: 1] [count: varint] - * [timestamp_delta_1: varint] [status_1: 1] ... [timestamp_delta_N: varint] [status_N: 1] - */ - - if (write_sample_header(writer, entry, STACK_REPEAT) < 0) { + /* Convert each column to its file form, then encode it */ + /* Leave room for the header, which is written once its size is known */ + if (buffer_reserve(&block->output, MAX_BLOCK_HEADER_SIZE) < 0) { return -1; } - - if (writer_write_varint_u32(writer, (uint32_t)entry->pending_rle_samples) < 0) { + block->output.size = MAX_BLOCK_HEADER_SIZE; + size_t decoded_payload_size = 0; + for (unsigned column = 0; column < COLUMN_COUNT; column++) { + ByteBuffer *decoded = &block->columns[column]; + switch (column) { + case COLUMN_STATUS_BITMAPS: + decoded = transform_statuses(block, header.status_bitmap_flags); + break; + case COLUMN_STACK_INSTRUCTIONS: + decoded = transform_stack_instructions(block); + break; + case COLUMN_FRAME_IDS: + decoded = transform_frame_ids(block, header.frame_width); + break; + } + if (decoded == NULL) { + return -1; + } + if (decoded->size > + MAX_BLOCK_SIZE - decoded_payload_size) { + PyErr_SetString(PyExc_RuntimeError, + "sample block exceeds the decoded size limit"); + return -1; + } + decoded_payload_size += decoded->size; + if (encode_column(writer, decoded, &header.columns[column]) < 0) { + return -1; + } + } + /* Put the header right before the columns and write the block */ + uint8_t header_bytes[MAX_BLOCK_HEADER_SIZE]; + size_t header_size = write_block_header(&header, header_bytes); + size_t unused = MAX_BLOCK_HEADER_SIZE - header_size; + uint8_t *header_start = block->output.data + unused; + memcpy(header_start, header_bytes, header_size); + if (fwrite_checked_allow_threads(header_start, + block->output.size - unused, + writer->fp) < 0) { return -1; } + writer->stats.bytes_written += decoded_payload_size; + block_reset(writer); + return 0; +} - if (writer_write_bytes(writer, entry->pending_rle, entry->pending_rle_bytes) < 0) { - return -1; +/* FNV-1a over the frame indices, the same in every process */ +static Py_uhash_t +stack_hash(const uint32_t *stack, size_t depth) +{ + uint64_t hash = 0xcbf29ce484222325; + for (size_t i = 0; i < depth; i++) { + hash = (hash ^ stack[i]) * 0x100000001b3; + } + /* Mix the high bits into the low bits that select the cache bucket */ + hash ^= hash >> 33; + hash *= 0xff51afd7ed558ccd; + hash ^= hash >> 33; + return (Py_uhash_t)hash; +} + +static size_t +common_outer_frames(const BlockStream *stream, const uint32_t *stack, + size_t depth) +{ + size_t shared = 0; + while (shared < depth && shared < stream->prev_stack_depth && + stack[depth - 1 - shared] == + stream->prev_stack[stream->prev_stack_depth - 1 - shared]) { + shared++; + } + return shared; +} + +static int +cached_stack_matches(const StackCacheEntry *cached, + const ByteBuffer *frames, Py_uhash_t hash, + const uint32_t *stack, size_t depth) +{ + if (cached->hash != hash || cached->depth != depth) { + return 0; } + const uint32_t *frame_ids = (const uint32_t *)frames->data; + for (size_t frame = 0; frame < depth; frame++) { + if (stack[frame] != + frame_ids[cached->offset + depth - 1 - frame]) { + return 0; + } + } + return 1; +} - writer->stats.repeat_records++; - writer->stats.repeat_samples += entry->pending_rle_samples; - /* Each RLE sample saves writing the entire stack */ - writer->stats.frames_saved += entry->pending_rle_samples * entry->prev_stack_depth; +static StackCacheEntry * +stack_cache_lookup(StackCacheEntry *bucket, const ByteBuffer *frames, + Py_uhash_t hash, const uint32_t *stack, size_t depth) +{ + for (size_t i = 0; i < STACK_CACHE_BUCKET_SIZE; i++) { + if (cached_stack_matches(&bucket[i], frames, hash, stack, depth)) { + return &bucket[i]; + } + } + return NULL; +} - entry->pending_rle_bytes = 0; - entry->pending_rle_samples = 0; +static void +stack_cache_insert(StackCacheEntry *bucket, StackCacheEntry entry) +{ + memmove(&bucket[1], &bucket[0], + (STACK_CACHE_BUCKET_SIZE - 1) * sizeof(*bucket)); + bucket[0] = entry; +} +static int +write_stack_repeat(BinaryWriter *writer, BlockStream *stream, size_t depth) +{ + SampleBlock *block = writer->block; + if (stream->current_repeat == UINT32_MAX) { + Repeat repeat = { + (uint32_t)block->columns[COLUMN_STACK_INSTRUCTIONS].size, 1}; + if (buffer_append(&block->repeats, + &repeat, sizeof(repeat)) < 0) { + return -1; + } + block->size += sizeof(repeat); + stream->current_repeat = + (uint32_t)(block->repeats.size / sizeof(repeat) - 1); + writer->stats.repeat_records++; + } + else { + Repeat *repeats = (Repeat *)block->repeats.data; + repeats[stream->current_repeat].count++; + } + writer->stats.repeat_samples++; + writer->stats.frames_saved += depth; return 0; } -/* Write a single sample with the specified encoding. - * Returns 0 on success, -1 on failure. */ static int -write_sample_with_encoding(BinaryWriter *writer, ThreadEntry *entry, - uint64_t timestamp_delta, uint8_t status, - int encoding_type, - const uint32_t *frame_indices, size_t stack_depth, - size_t shared_count, size_t pop_count, size_t push_count) +write_stack_reuse(BinaryWriter *writer, + const StackCacheEntry *cached, size_t depth) { - /* Header: thread_id(8) + interpreter_id(4) + encoding(1) + delta(varint) + status(1) */ - uint8_t header_buf[SAMPLE_HEADER_MAX_SIZE]; - memcpy(header_buf + SMP_OFF_THREAD_ID, &entry->thread_id, SMP_SIZE_THREAD_ID); - memcpy(header_buf + SMP_OFF_INTERPRETER_ID, &entry->interpreter_id, SMP_SIZE_INTERPRETER_ID); - header_buf[SMP_OFF_ENCODING] = (uint8_t)encoding_type; - size_t varint_len = encode_varint_u64( - header_buf + SAMPLE_HEADER_FIXED_SIZE, - timestamp_delta); - header_buf[SAMPLE_HEADER_FIXED_SIZE + varint_len] = status; - - if (writer_write_bytes(writer, header_buf, - SAMPLE_HEADER_FIXED_SIZE + varint_len + 1) < 0) { + SampleBlock *block = writer->block; + if (column_write_varint(block, COLUMN_STACK_INSTRUCTIONS, + STACK_REUSE) < 0 || + column_write_varint(block, COLUMN_STACK_INSTRUCTIONS, + cached->offset) < 0 || + column_write_varint(block, COLUMN_STACK_INSTRUCTIONS, depth) < 0) { return -1; } + writer->stats.reuse_records++; + writer->stats.frames_saved += depth; + return 0; +} - uint8_t frame_buf[MAX_FRAME_BUFFER_SIZE]; - size_t frame_buf_pos = 0; - size_t frames_written = 0; +static int +write_stack_replace_suffix(BinaryWriter *writer, StackCacheEntry *bucket, + Py_uhash_t hash, const uint32_t *stack, + size_t depth, size_t shared) +{ + SampleBlock *block = writer->block; + ByteBuffer *frames = &block->columns[COLUMN_FRAME_IDS]; + size_t new_frames = depth - shared; + if (column_write_varint(block, COLUMN_STACK_INSTRUCTIONS, + STACK_REPLACE_SUFFIX) < 0 || + column_write_varint(block, COLUMN_STACK_INSTRUCTIONS, shared) < 0 || + column_write_varint(block, COLUMN_STACK_INSTRUCTIONS, + new_frames) < 0) { + return -1; + } - switch (encoding_type) { - case STACK_FULL: - /* [depth: varint] [frame_idx: varint]... */ - frame_buf_pos += encode_varint_u32(frame_buf, (uint32_t)stack_depth); - for (size_t i = 0; i < stack_depth; i++) { - frame_buf_pos += encode_varint_u32(frame_buf + frame_buf_pos, frame_indices[i]); + /* Append the new inner frames, outermost first */ + size_t stack_offset = frames->size / sizeof(uint32_t); + if (new_frames != 0) { + if (buffer_reserve( + frames, frames->size + new_frames * sizeof(uint32_t)) < 0) { + return -1; } - frames_written = stack_depth; - writer->stats.full_records++; - break; - - case STACK_SUFFIX: - /* [shared_count: varint] [new_count: varint] [new_frame_idx: varint]... */ - frame_buf_pos += encode_varint_u32(frame_buf, (uint32_t)shared_count); - frame_buf_pos += encode_varint_u32(frame_buf + frame_buf_pos, (uint32_t)push_count); - /* New frames are at the top (beginning) of current stack */ - for (size_t i = 0; i < push_count; i++) { - frame_buf_pos += encode_varint_u32(frame_buf + frame_buf_pos, frame_indices[i]); + uint32_t *new_frame_ids = (uint32_t *)(frames->data + frames->size); + for (size_t i = 0; i < new_frames; i++) { + uint32_t frame = stack[new_frames - 1 - i]; + new_frame_ids[i] = frame; + if (frame > block->max_frame) { + block->max_frame = frame; + } } - frames_written = push_count; - writer->stats.suffix_records++; - /* Saved writing shared_count frames */ - writer->stats.frames_saved += shared_count; - break; - - case STACK_POP_PUSH: - /* [pop_count: varint] [push_count: varint] [new_frame_idx: varint]... */ - frame_buf_pos += encode_varint_u32(frame_buf, (uint32_t)pop_count); - frame_buf_pos += encode_varint_u32(frame_buf + frame_buf_pos, (uint32_t)push_count); - /* New frames are at the top (beginning) of current stack */ - for (size_t i = 0; i < push_count; i++) { - frame_buf_pos += encode_varint_u32(frame_buf + frame_buf_pos, frame_indices[i]); + frames->size += new_frames * sizeof(uint32_t); + block->size += new_frames * sizeof(uint32_t); + } + /* Complete stacks are cached so later samples can REUSE them */ + if (shared == 0) { + if (bucket != NULL) { + stack_cache_insert(bucket, (StackCacheEntry){ + hash, (uint32_t)stack_offset, (uint32_t)depth}); } - frames_written = push_count; - writer->stats.pop_push_records++; - /* Saved writing shared_count frames (stack_depth - push_count if we had written full) */ - writer->stats.frames_saved += shared_count; - break; - - default: - PyErr_SetString(PyExc_RuntimeError, "Invalid stack encoding type"); + writer->stats.full_records++; + } + else { + writer->stats.suffix_records++; + } + writer->stats.total_frames_written += new_frames; + writer->stats.frames_saved += shared; + return 0; +} + +static int +write_stack(BinaryWriter *writer, BlockStream *stream, int new_stream, + const uint32_t *stack, size_t depth) +{ + SampleBlock *block = writer->block; + size_t shared = common_outer_frames(stream, stack, depth); + /* Same stack as this stream's previous sample: extend its REPEAT */ + if (!new_stream && shared == depth && + shared == stream->prev_stack_depth) { + return write_stack_repeat(writer, stream, depth); + } + + /* Enough new frames to be worth looking up an earlier complete stack */ + Py_uhash_t hash = 0; + StackCacheEntry *bucket = NULL; + StackCacheEntry *cached = NULL; + if (depth - shared >= STACK_REUSE_MIN_FRAMES) { + hash = stack_hash(stack, depth); + bucket = block->cache[hash % STACK_CACHE_BUCKET_COUNT]; + cached = stack_cache_lookup(bucket, &block->columns[COLUMN_FRAME_IDS], + hash, stack, depth); + } + + int result; + if (cached != NULL) { + /* Stack already stored in this block: point to its frames */ + result = write_stack_reuse(writer, cached, depth); + } + else { + /* Keep the shared outer frames and write only the new inner ones */ + result = write_stack_replace_suffix(writer, bucket, hash, stack, + depth, shared); + } + if (result < 0) { return -1; } + stream->current_repeat = UINT32_MAX; + memcpy(stream->prev_stack, stack, depth * sizeof(uint32_t)); + stream->prev_stack_depth = depth; + return 0; +} + +size_t +binary_writer_buffered_size(BinaryWriter *writer) +{ + SampleBlock *block = writer->block; + if (block == NULL || block->sample_count == 0) { + return 0; + } + size_t size = block->columns[COLUMN_STREAM_TABLE].size + + block->columns[COLUMN_SAMPLE_STREAM_IDS].size + + block->columns[COLUMN_TIMESTAMP_RESIDUALS].size + + block->columns[COLUMN_STACK_INSTRUCTIONS].size; + const Repeat *repeats = (const Repeat *)block->repeats.data; + size_t repeat_count = block->repeats.size / sizeof(Repeat); + uint8_t bytes[MAX_VARINT_SIZE]; + for (size_t i = 0; i < repeat_count; i++) { + size += encode_varint_u64(bytes, STACK_REPEAT) + + encode_varint_u64(bytes, repeats[i].count); + } + uint8_t common_flags, bitmap_flags; + block_status_flags(block, &common_flags, &bitmap_flags); + size += (size_t)_Py_popcount32(bitmap_flags) + * status_bitmap_size(block->sample_count); + size += block->columns[COLUMN_FRAME_IDS].size / sizeof(uint32_t) + * block_frame_width(block); + return size; +} - if (writer_write_bytes(writer, frame_buf, frame_buf_pos) < 0) { +static int +block_add_stream(BinaryWriter *writer, ThreadEntry *entry) +{ + SampleBlock *block = writer->block; + if (GROW_ARRAY(block->streams, block->stream_count, + block->stream_capacity, BlockStream) < 0) { return -1; } + /* Stream table entry: thread_id (8 bytes) + interpreter_id (4 bytes) */ + uint8_t stream_entry[STREAM_ENTRY_SIZE]; + memcpy(stream_entry + STM_OFF_THREAD_ID, + &entry->thread_id, sizeof(entry->thread_id)); + memcpy(stream_entry + STM_OFF_INTERPRETER_ID, + &entry->interpreter_id, sizeof(entry->interpreter_id)); + if (column_write(block, COLUMN_STREAM_TABLE, + stream_entry, sizeof(stream_entry)) < 0) { + return -1; + } + BlockStream *stream = &block->streams[block->stream_count]; + stream->thread_index = (size_t)(entry - writer->thread_entries); + stream->prev_timestamp = block->base_timestamp - writer->sample_interval_us; + stream->current_repeat = UINT32_MAX; + stream->prev_stack_depth = 0; + entry->block_stream_index = block->stream_count++; + return 0; +} - writer->stats.total_frames_written += frames_written; +static int +block_add_sample(BinaryWriter *writer, ThreadEntry *entry, + uint64_t timestamp, uint8_t status, + const uint32_t *stack, size_t depth) +{ + static_assert(BLOCK_FLUSH_SIZE + MAX_SAMPLE_SIZE + MAX_BITMAP_PADDING == + MAX_BLOCK_SIZE, + "block flush size needs headroom for one complete sample"); + + SampleBlock *block = writer->block; + /* Start a new block if this sample might not fit */ + if (block->size >= BLOCK_FLUSH_SIZE || + (entry->block_stream_index == UINT32_MAX && + block->stream_count == MAX_BLOCK_STREAMS)) { + if (block_flush(writer) < 0) { + return -1; + } + } + if (block->sample_count == 0) { + block->base_timestamp = timestamp; + } + int new_stream = entry->block_stream_index == UINT32_MAX; + if (new_stream && block_add_stream(writer, entry) < 0) { + return -1; + } + BlockStream *stream = &block->streams[entry->block_stream_index]; + /* Store the difference from the expected timestamp */ + uint64_t residual = + timestamp - stream->prev_timestamp - writer->sample_interval_us; + uint8_t residual_bytes[MAX_VARINT_SIZE]; + size_t residual_size = + encode_varint_i64(residual_bytes, (int64_t)residual); + if (column_write_varint(block, COLUMN_SAMPLE_STREAM_IDS, + entry->block_stream_index) < 0 || + column_write(block, COLUMN_TIMESTAMP_RESIDUALS, + residual_bytes, residual_size) < 0 || + column_write(block, COLUMN_STATUS_BITMAPS, + &status, sizeof(status)) < 0) { + return -1; + } + if (write_stack(writer, stream, new_stream, stack, depth) < 0) { + return -1; + } + stream->prev_timestamp = timestamp; + block->sample_count++; + writer->total_samples++; return 0; } +static void +block_destroy(SampleBlock *block) +{ + if (block == NULL) { + return; + } + for (unsigned i = 0; i < COLUMN_COUNT; i++) { + buffer_clear(&block->columns[i]); + } + buffer_clear(&block->repeats); + buffer_clear(&block->transformed); + buffer_clear(&block->compressed); + buffer_clear(&block->output); + PyMem_Free(block->streams); + PyMem_Free(block); +} + BinaryWriter * binary_writer_create(PyObject *path, uint64_t sample_interval_us, int compression_type, - uint64_t start_time_us) + uint64_t start_time_us, int profiling_mode, + int capture_features) { + if (compression_type != COMPRESSION_NONE && + compression_type != COMPRESSION_ZSTD) { + PyErr_SetString(PyExc_ValueError, "invalid compression type"); + return NULL; + } BinaryWriter *writer = PyMem_Calloc(1, sizeof(BinaryWriter)); if (!writer) { PyErr_NoMemory(); @@ -738,13 +1087,21 @@ binary_writer_create(PyObject *path, uint64_t sample_interval_us, int compressio writer->start_time_us = start_time_us; writer->sample_interval_us = sample_interval_us; writer->compression_type = compression_type; + writer->profiling_mode = profiling_mode; + writer->capture_features = capture_features; - writer->write_buffer = PyMem_Malloc(WRITE_BUFFER_SIZE); - if (!writer->write_buffer) { + writer->block = PyMem_Calloc(1, sizeof(SampleBlock)); + if (writer->block == NULL) { PyErr_NoMemory(); goto error; } - writer->buffer_size = WRITE_BUFFER_SIZE; + writer->block->streams = PyMem_Malloc( + INITIAL_BLOCK_STREAM_CAPACITY * sizeof(BlockStream)); + if (writer->block->streams == NULL) { + PyErr_NoMemory(); + goto error; + } + writer->block->stream_capacity = INITIAL_BLOCK_STREAM_CAPACITY; writer->string_hash = _Py_hashtable_new_full( string_hash_func, @@ -924,6 +1281,12 @@ static int process_thread_sample(BinaryWriter *writer, PyObject *thread_info, uint32_t interpreter_id, uint64_t timestamp_us) { + if (writer->total_samples == UINT64_MAX) { + writer->state = BINARY_WRITER_LIMIT_REACHED; + PyErr_SetString(PyExc_OverflowError, "too many samples for binary format"); + return -1; + } + PyObject *thread_id_obj = PyStructSequence_GET_ITEM(thread_info, 0); PyObject *status_obj = PyStructSequence_GET_ITEM(thread_info, 1); PyObject *frame_list = PyStructSequence_GET_ITEM(thread_info, 2); @@ -936,74 +1299,29 @@ process_thread_sample(BinaryWriter *writer, PyObject *thread_info, if (status_long == -1 && PyErr_Occurred()) { return -1; } + if (status_long < 0 || status_long > UINT8_MAX) { + writer->state = BINARY_WRITER_LIMIT_REACHED; + PyErr_Format(PyExc_OverflowError, + "thread status %ld exceeds the binary format range", + status_long); + return -1; + } uint8_t status = (uint8_t)status_long; ThreadEntry *entry = writer_get_or_create_thread_entry( - writer, thread_id, interpreter_id, NULL); + writer, thread_id, interpreter_id); if (!entry) { return -1; } - /* Calculate timestamp delta */ - uint64_t delta = timestamp_us - entry->prev_timestamp; - entry->prev_timestamp = timestamp_us; - /* Process frames and build current stack */ uint32_t curr_stack[MAX_STACK_DEPTH]; size_t curr_depth; if (build_frame_stack(writer, frame_list, curr_stack, &curr_depth) < 0) { return -1; } - - /* Compare with previous stack to determine encoding */ - size_t shared_count, pop_count, push_count; - int encoding = compare_stacks( - entry->prev_stack, entry->prev_stack_depth, - curr_stack, curr_depth, - &shared_count, &pop_count, &push_count); - - if (encoding == STACK_REPEAT) { - /* Buffer this sample for RLE. - * - * STACK_REPEAT also covers the "first sample for a fresh thread, - * empty stack" case: a new ThreadEntry has prev_stack_depth == 0 - * and a zero-initialized prev_stack, so compare_stacks() returns - * STACK_REPEAT against an empty curr_stack (depth 0). Buffering - * it here is correct; the RLE flush path emits it as a normal - * STACK_REPEAT record. */ - if (entry->pending_rle == NULL) { - entry->pending_rle = PyMem_Malloc(MAX_RLE_BUF_SIZE); - if (!entry->pending_rle) { - PyErr_NoMemory(); - return -1; - } - } - if (entry->pending_rle_bytes + MAX_RLE_ENTRY_SIZE > MAX_RLE_BUF_SIZE - && flush_pending_rle(writer, entry) < 0) { - return -1; - } - entry->pending_rle_bytes += encode_varint_u64( - entry->pending_rle + entry->pending_rle_bytes, delta); - entry->pending_rle[entry->pending_rle_bytes++] = status; - entry->pending_rle_samples++; - } else { - /* Stack changed - flush any pending RLE first */ - if (flush_pending_rle(writer, entry) < 0) { - return -1; - } - - if (write_sample_with_encoding(writer, entry, delta, status, encoding, - curr_stack, curr_depth, - shared_count, pop_count, push_count) < 0) { - return -1; - } - - memcpy(entry->prev_stack, curr_stack, curr_depth * sizeof(uint32_t)); - entry->prev_stack_depth = curr_depth; - } - - writer->total_samples++; - return 0; + return block_add_sample( + writer, entry, timestamp_us, status, curr_stack, curr_depth); } int @@ -1021,15 +1339,16 @@ binary_writer_write_sample(BinaryWriter *writer, PyObject *stack_frames, uint64_ PyObject *interp_id_obj = PyStructSequence_GET_ITEM(interp_info, 0); PyObject *threads = PyStructSequence_GET_ITEM(interp_info, 1); - unsigned long interp_id_long = PyLong_AsUnsignedLong(interp_id_obj); - if (interp_id_long == (unsigned long)-1 && PyErr_Occurred()) { + unsigned long long interp_id_long = PyLong_AsUnsignedLongLong(interp_id_obj); + if (interp_id_long == (unsigned long long)-1 && PyErr_Occurred()) { return -1; } /* Bounds check: interpreter_id is stored as uint32_t in binary format */ if (interp_id_long > UINT32_MAX) { + writer->state = BINARY_WRITER_LIMIT_REACHED; PyErr_Format(PyExc_OverflowError, - "interpreter_id %lu exceeds maximum value %lu", - interp_id_long, (unsigned long)UINT32_MAX); + "interpreter_id %llu exceeds maximum value %u", + interp_id_long, UINT32_MAX); return -1; } uint32_t interpreter_id = (uint32_t)interp_id_long; @@ -1049,46 +1368,10 @@ binary_writer_write_sample(BinaryWriter *writer, PyObject *stack_frames, uint64_ int binary_writer_finalize(BinaryWriter *writer) { - for (size_t i = 0; i < writer->thread_count; i++) { - if (flush_pending_rle(writer, &writer->thread_entries[i]) < 0) { - return -1; - } - } - - if (writer_flush_buffer(writer) < 0) { + if (block_flush(writer) < 0) { return -1; } -#ifdef HAVE_ZSTD - /* Finalize compression stream */ - if (writer->compression_type == COMPRESSION_ZSTD && writer->zstd.cctx) { - ZSTD_inBuffer input = { NULL, 0, 0 }; - size_t remaining; - - do { - ZSTD_outBuffer output = { - writer->zstd.compressed_buffer, - writer->zstd.compressed_buffer_size, - 0 - }; - - remaining = ZSTD_compressStream2(writer->zstd.cctx, &output, &input, ZSTD_e_end); - - if (ZSTD_isError(remaining)) { - PyErr_Format(PyExc_IOError, "zstd finalization error: %s", - ZSTD_getErrorName(remaining)); - return -1; - } - - if (output.pos > 0) { - if (fwrite_checked_allow_threads(writer->zstd.compressed_buffer, output.pos, writer->fp) < 0) { - return -1; - } - } - } while (remaining > 0); - } -#endif - /* Use 64-bit file position for >2GB files */ file_offset_t string_table_offset = FTELL64(writer->fp); if (string_table_offset < 0) { @@ -1146,6 +1429,30 @@ binary_writer_finalize(BinaryWriter *writer) } } + if (writer->has_profile_stats) { + uint8_t profile_stats[PROFILE_STATS_SIZE] = {0}; + uint32_t version = PROFILE_STATS_VERSION; + uint32_t size = PROFILE_STATS_SIZE; + memcpy(profile_stats + PST_OFF_DURATION, + &writer->duration_sec, PST_SIZE_DURATION); + memcpy(profile_stats + PST_OFF_SAMPLE_RATE, + &writer->sample_rate, PST_SIZE_SAMPLE_RATE); + memcpy(profile_stats + PST_OFF_ERROR_RATE, + &writer->error_rate, PST_SIZE_ERROR_RATE); + memcpy(profile_stats + PST_OFF_MISSED_SAMPLES, + &writer->missed_samples, PST_SIZE_MISSED_SAMPLES); + memcpy(profile_stats + PST_OFF_PRESENT, + &writer->profile_stats_present, PST_SIZE_PRESENT); + memcpy(profile_stats + PST_OFF_MAGIC, + PROFILE_STATS_MAGIC, PROFILE_STATS_MAGIC_SIZE); + memcpy(profile_stats + PST_OFF_VERSION, &version, PST_SIZE_VERSION); + memcpy(profile_stats + PST_OFF_SIZE, &size, PST_SIZE_SIZE); + if (fwrite_checked_allow_threads( + profile_stats, PROFILE_STATS_SIZE, writer->fp) < 0) { + return -1; + } + } + /* Footer: string_count(4) + frame_count(4) + file_size(8) + checksum(16) */ file_offset_t footer_offset = FTELL64(writer->fp); if (footer_offset < 0) { @@ -1177,6 +1484,12 @@ binary_writer_finalize(BinaryWriter *writer) uint64_t frame_table_offset_u64 = (uint64_t)frame_table_offset; uint32_t thread_count_u32 = (uint32_t)writer->thread_count; uint32_t compression_type_u32 = (uint32_t)writer->compression_type; + uint32_t profiling_config_u32 = (uint32_t)(writer->profiling_mode + 1); + if (writer->capture_features >= 0) { + profiling_config_u32 |= PROFILING_CONFIG_FEATURES_KNOWN; + profiling_config_u32 |= (uint32_t)writer->capture_features + << PROFILING_CONFIG_FEATURES_SHIFT; + } uint8_t header[FILE_HEADER_SIZE] = {0}; uint32_t magic = BINARY_FORMAT_MAGIC; @@ -1193,6 +1506,7 @@ binary_writer_finalize(BinaryWriter *writer) memcpy(header + HDR_OFF_STR_TABLE, &string_table_offset_u64, HDR_SIZE_STR_TABLE); memcpy(header + HDR_OFF_FRAME_TABLE, &frame_table_offset_u64, HDR_SIZE_FRAME_TABLE); memcpy(header + HDR_OFF_COMPRESSION, &compression_type_u32, HDR_SIZE_COMPRESSION); + memcpy(header + HDR_OFF_CONFIG, &profiling_config_u32, HDR_SIZE_CONFIG); if (fwrite_checked_allow_threads(header, FILE_HEADER_SIZE, writer->fp) < 0) { return -1; } @@ -1207,6 +1521,41 @@ binary_writer_finalize(BinaryWriter *writer) return 0; } +int +binary_writer_set_stats(BinaryWriter *writer, double duration_sec, + double sample_rate, double error_rate, + double missed_samples, uint32_t present) +{ + if (!isfinite(duration_sec) || duration_sec < 0.0) { + PyErr_SetString(PyExc_ValueError, + "duration must be a finite non-negative value"); + return -1; + } + if (!isfinite(sample_rate) || sample_rate < 0.0) { + PyErr_SetString(PyExc_ValueError, + "sample rate must be a finite non-negative value"); + return -1; + } + if ((present & PROFILE_STATS_ERROR_RATE) && + (!isfinite(error_rate) || error_rate < 0.0)) { + PyErr_SetString(PyExc_ValueError, + "error rate must be a finite non-negative value"); + return -1; + } + if ((present & PROFILE_STATS_MISSED) && !isfinite(missed_samples)) { + PyErr_SetString(PyExc_ValueError, + "missed samples must be a finite value"); + return -1; + } + writer->duration_sec = duration_sec; + writer->sample_rate = sample_rate; + writer->error_rate = error_rate; + writer->missed_samples = missed_samples; + writer->profile_stats_present = present; + writer->has_profile_stats = 1; + return 0; +} + void binary_writer_destroy(BinaryWriter *writer) { @@ -1218,13 +1567,12 @@ binary_writer_destroy(BinaryWriter *writer) Py_fclose(writer->fp); } - PyMem_Free(writer->write_buffer); + block_destroy(writer->block); #ifdef HAVE_ZSTD if (writer->zstd.cctx) { ZSTD_freeCCtx(writer->zstd.cctx); } - PyMem_Free(writer->zstd.compressed_buffer); #endif if (writer->string_hash) { @@ -1243,13 +1591,7 @@ binary_writer_destroy(BinaryWriter *writer) } PyMem_Free(writer->frame_entries); - if (writer->thread_entries) { - for (size_t i = 0; i < writer->thread_count; i++) { - PyMem_Free(writer->thread_entries[i].prev_stack); - PyMem_Free(writer->thread_entries[i].pending_rle); - } - PyMem_Free(writer->thread_entries); - } + PyMem_Free(writer->thread_entries); PyMem_Free(writer); } diff --git a/Modules/_remote_debugging/clinic/module.c.h b/Modules/_remote_debugging/clinic/module.c.h index d01f3d13e85f09f..26e4a3c2c2e84be 100644 --- a/Modules/_remote_debugging/clinic/module.c.h +++ b/Modules/_remote_debugging/clinic/module.c.h @@ -56,7 +56,7 @@ PyDoc_STRVAR(_remote_debugging_RemoteUnwinder___init____doc__, static int _remote_debugging_RemoteUnwinder___init___impl(RemoteUnwinderObject *self, - int pid, int all_threads, + pid_t pid, int all_threads, int only_active_thread, int mode, int debug, int skip_non_matching_threads, @@ -99,7 +99,7 @@ _remote_debugging_RemoteUnwinder___init__(PyObject *self, PyObject *args, PyObje PyObject * const *fastargs; Py_ssize_t nargs = PyTuple_GET_SIZE(args); Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; - int pid; + pid_t pid; int all_threads = 0; int only_active_thread = 0; int mode = 0; @@ -116,8 +116,8 @@ _remote_debugging_RemoteUnwinder___init__(PyObject *self, PyObject *args, PyObje if (!fastargs) { goto exit; } - pid = PyLong_AsInt(fastargs[0]); - if (pid == -1 && PyErr_Occurred()) { + pid = PyLong_AsPid(fastargs[0]); + if (pid == (pid_t)(-1) && PyErr_Occurred()) { goto exit; } if (!noptargs) { @@ -288,23 +288,28 @@ PyDoc_STRVAR(_remote_debugging_RemoteUnwinder_get_all_awaited_by__doc__, "get_all_awaited_by($self, /)\n" "--\n" "\n" -"Get all tasks and their awaited_by relationships from the remote process.\n" +"Get awaited_by relationships for tasks in the remote process.\n" "\n" -"This provides a tree structure showing which tasks are waiting for\n" -"other tasks.\n" -"\n" -"For each task, returns:\n" -"1. The call stack frames leading to where the task is currently\n" -" executing\n" -"2. The name of the task\n" -"3. A list of tasks that this task is waiting for, with their own\n" -" frames/names/etc\n" -"\n" -"Returns a list of [frames, task_name, subtasks] where:\n" -"- frames: List of (func_name, filename, lineno) showing the call\n" -" stack\n" -"- task_name: String identifier for the task\n" -"- subtasks: List of tasks being awaited by this task, in same format\n" +"Returns:\n" +" A list of AwaitedInfo objects, where each object contains:\n" +"\n" +" - thread_id (int): Identifier of the thread, or 0 for tasks in the\n" +" interpreter\'s fallback task list.\n" +" - awaited_by (list[TaskInfo]): Tasks registered with this thread and\n" +" intermediate futures in their awaited_by chains.\n" +"\n" +"Each TaskInfo contains:\n" +" - task_id (int): Identifier of the task.\n" +" - task_name (str): Name of the task, or a generated name for\n" +" a future.\n" +" - coroutine_stack (list[CoroInfo]): Stack of coroutine frames.\n" +" - awaited_by (list[CoroInfo]): Coroutine information for tasks or futures\n" +" awaiting this task.\n" +" - is_future (bool, named-only): True for a plain Future.\n" +"\n" +"Each CoroInfo contains:\n" +" - call_stack (list[FrameInfo]): Call stack frames for the coroutine.\n" +" - task_name (int): Identifier of the task or future.\n" "\n" "Raises:\n" " RuntimeError: If AsyncioDebug section is not available in the\n" @@ -313,20 +318,20 @@ PyDoc_STRVAR(_remote_debugging_RemoteUnwinder_get_all_awaited_by__doc__, " OSError: If reading from the remote process fails\n" "\n" "Example output:\n" -"[\n" +"\n" " [\n" -" [(\"c5\", \"script.py\", 10), (\"c4\", \"script.py\", 14)],\n" -" \"c2_root\",\n" -" [\n" -" [\n" -" [(\"c1\", \"script.py\", 23)],\n" -" \"sub_main_2\",\n" -" [...]\n" -" ],\n" -" [...]\n" -" ]\n" -" ]\n" -"]"); +" AwaitedInfo(\n" +" thread_id=12345,\n" +" awaited_by=[\n" +" TaskInfo(\n" +" task_id=1,\n" +" task_name=\"Task-1\",\n" +" coroutine_stack=[...],\n" +" awaited_by=[]\n" +" )\n" +" ]\n" +" )\n" +" ]"); #define _REMOTE_DEBUGGING_REMOTEUNWINDER_GET_ALL_AWAITED_BY_METHODDEF \ {"get_all_awaited_by", (PyCFunction)_remote_debugging_RemoteUnwinder_get_all_awaited_by, METH_NOARGS, _remote_debugging_RemoteUnwinder_get_all_awaited_by__doc__}, @@ -360,16 +365,37 @@ PyDoc_STRVAR(_remote_debugging_RemoteUnwinder_get_async_stack_trace__doc__, "all tasks that transitively depend on it (tasks waiting for the\n" "running task, tasks waiting for those tasks, etc.).\n" "\n" -"Returns a list of per-thread results, where each thread result\n" -"contains:\n" -"- Thread ID\n" -"- List of task information for the running task and all its waiters\n" -"\n" -"Each task info contains:\n" -"- Task ID (memory address)\n" -"- Task name\n" -"- Call stack frames: List of (func_name, filename, lineno)\n" -"- List of tasks waiting for this task (recursive structure)\n" +"Returns:\n" +" A list of AwaitedInfo objects, where each object contains:\n" +"\n" +" - thread_id (int): Identifier of the thread.\n" +" - awaited_by (list[TaskInfo]): The running task and all its\n" +" transitive waiters, including intermediate futures.\n" +"\n" +"Each TaskInfo contains:\n" +" - task_id (int): Identifier of the task.\n" +" - task_name (str): Name of the task, or a generated name for\n" +" a future.\n" +" - coroutine_stack (list[CoroInfo]): Stack of coroutine frames.\n" +" - awaited_by (list[CoroInfo]): Coroutine information for\n" +" tasks or futures awaiting this task.\n" +" - is_future (bool, named-only): True for a plain Future.\n" +"\n" +"Each CoroInfo contains:\n" +" - call_stack (list[FrameInfo]): Frames for the coroutine.\n" +" - task_name (int): Identifier of the task or future.\n" +"\n" +"Each FrameInfo contains:\n" +" - filename (str): Source code filename.\n" +" - location (LocationInfo | None): Source location, if available.\n" +" - funcname (str): Function name.\n" +" - opcode (int | None): Opcode, if available.\n" +"\n" +"Each LocationInfo contains:\n" +" - lineno (int): Starting line number.\n" +" - end_lineno (int): Ending line number.\n" +" - col_offset (int): Starting column offset.\n" +" - end_col_offset (int): Ending column offset.\n" "\n" "Raises:\n" " RuntimeError: If AsyncioDebug section is not available in the\n" @@ -377,18 +403,30 @@ PyDoc_STRVAR(_remote_debugging_RemoteUnwinder_get_async_stack_trace__doc__, " MemoryError: If memory allocation fails\n" " OSError: If reading from the remote process fails\n" "\n" -"Example output (similar structure to get_all_awaited_by but only for\n" -"running tasks):\n" -"[\n" -" (140234, [\n" -" (4345585712, \'main_task\',\n" -" [(\"run_server\", \"server.py\", 127), (\"main\", \"app.py\", 23)],\n" -" [\n" -" (4345585800, \'worker_1\', [...], [...]),\n" -" (4345585900, \'worker_2\', [...], [...])\n" -" ])\n" -" ])\n" -"]"); +"Example output:\n" +"\n" +" [\n" +" AwaitedInfo(thread_id=140234, awaited_by=[\n" +" TaskInfo(\n" +" task_id=1,\n" +" task_name=\"worker\",\n" +" coroutine_stack=[\n" +" CoroInfo(call_stack=[...], task_name=1)\n" +" ],\n" +" awaited_by=[\n" +" CoroInfo(call_stack=[...], task_name=2)\n" +" ]\n" +" ),\n" +" TaskInfo(\n" +" task_id=2,\n" +" task_name=\"main\",\n" +" coroutine_stack=[\n" +" CoroInfo(call_stack=[...], task_name=2)\n" +" ],\n" +" awaited_by=[]\n" +" )\n" +" ])\n" +" ]"); #define _REMOTE_DEBUGGING_REMOTEUNWINDER_GET_ASYNC_STACK_TRACE_METHODDEF \ {"get_async_stack_trace", (PyCFunction)_remote_debugging_RemoteUnwinder_get_async_stack_trace, METH_NOARGS, _remote_debugging_RemoteUnwinder_get_async_stack_trace__doc__}, @@ -559,7 +597,7 @@ PyDoc_STRVAR(_remote_debugging_GCMonitor___init____doc__, " target process"); static int -_remote_debugging_GCMonitor___init___impl(GCMonitorObject *self, int pid, +_remote_debugging_GCMonitor___init___impl(GCMonitorObject *self, pid_t pid, int debug); static int @@ -597,7 +635,7 @@ _remote_debugging_GCMonitor___init__(PyObject *self, PyObject *args, PyObject *k PyObject * const *fastargs; Py_ssize_t nargs = PyTuple_GET_SIZE(args); Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; - int pid; + pid_t pid; int debug = 0; fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, @@ -605,8 +643,8 @@ _remote_debugging_GCMonitor___init__(PyObject *self, PyObject *args, PyObject *k if (!fastargs) { goto exit; } - pid = PyLong_AsInt(fastargs[0]); - if (pid == -1 && PyErr_Occurred()) { + pid = PyLong_AsPid(fastargs[0]); + if (pid == (pid_t)(-1) && PyErr_Occurred()) { goto exit; } if (!noptargs) { @@ -717,7 +755,7 @@ _remote_debugging_GCMonitor_get_gc_stats(PyObject *self, PyObject *const *args, PyDoc_STRVAR(_remote_debugging_BinaryWriter___init____doc__, "BinaryWriter(filename, sample_interval_us, start_time_us, *,\n" -" compression=0)\n" +" compression=0, mode=-1, capture_features=-1)\n" "--\n" "\n" "High-performance binary writer for profiling data.\n" @@ -728,6 +766,9 @@ PyDoc_STRVAR(_remote_debugging_BinaryWriter___init____doc__, " start_time_us: Start timestamp in microseconds (from\n" " time.monotonic() * 1e6)\n" " compression: 0=none, 1=zstd (default: 0)\n" +" mode: Profiling mode, or -1 if unknown (default: -1)\n" +" capture_features: Capture feature bit mask, or -1 if unknown\n" +" (default: -1)\n" "\n" "Use as a context manager or call finalize() when done."); @@ -736,7 +777,8 @@ _remote_debugging_BinaryWriter___init___impl(BinaryWriterObject *self, PyObject *filename, unsigned long long sample_interval_us, unsigned long long start_time_us, - int compression); + int compression, int mode, + int capture_features); static int _remote_debugging_BinaryWriter___init__(PyObject *self, PyObject *args, PyObject *kwargs) @@ -744,7 +786,7 @@ _remote_debugging_BinaryWriter___init__(PyObject *self, PyObject *args, PyObject int return_value = -1; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - #define NUM_KEYWORDS 4 + #define NUM_KEYWORDS 6 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD @@ -753,7 +795,7 @@ _remote_debugging_BinaryWriter___init__(PyObject *self, PyObject *args, PyObject } _kwtuple = { .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) .ob_hash = -1, - .ob_item = { &_Py_ID(filename), &_Py_ID(sample_interval_us), &_Py_ID(start_time_us), &_Py_ID(compression), }, + .ob_item = { &_Py_ID(filename), &_Py_ID(sample_interval_us), &_Py_ID(start_time_us), &_Py_ID(compression), &_Py_ID(mode), &_Py_ID(capture_features), }, }; #undef NUM_KEYWORDS #define KWTUPLE (&_kwtuple.ob_base.ob_base) @@ -762,14 +804,14 @@ _remote_debugging_BinaryWriter___init__(PyObject *self, PyObject *args, PyObject # define KWTUPLE NULL #endif // !Py_BUILD_CORE - static const char * const _keywords[] = {"filename", "sample_interval_us", "start_time_us", "compression", NULL}; + static const char * const _keywords[] = {"filename", "sample_interval_us", "start_time_us", "compression", "mode", "capture_features", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, .fname = "BinaryWriter", .kwtuple = KWTUPLE, }; #undef KWTUPLE - PyObject *argsbuf[4]; + PyObject *argsbuf[6]; PyObject * const *fastargs; Py_ssize_t nargs = PyTuple_GET_SIZE(args); Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 3; @@ -777,6 +819,8 @@ _remote_debugging_BinaryWriter___init__(PyObject *self, PyObject *args, PyObject unsigned long long sample_interval_us; unsigned long long start_time_us; int compression = 0; + int mode = -1; + int capture_features = -1; fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, /*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); @@ -793,12 +837,30 @@ _remote_debugging_BinaryWriter___init__(PyObject *self, PyObject *args, PyObject if (!noptargs) { goto skip_optional_kwonly; } - compression = PyLong_AsInt(fastargs[3]); - if (compression == -1 && PyErr_Occurred()) { + if (fastargs[3]) { + compression = PyLong_AsInt(fastargs[3]); + if (compression == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[4]) { + mode = PyLong_AsInt(fastargs[4]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + capture_features = PyLong_AsInt(fastargs[5]); + if (capture_features == -1 && PyErr_Occurred()) { goto exit; } skip_optional_kwonly: - return_value = _remote_debugging_BinaryWriter___init___impl((BinaryWriterObject *)self, filename, sample_interval_us, start_time_us, compression); + return_value = _remote_debugging_BinaryWriter___init___impl((BinaryWriterObject *)self, filename, sample_interval_us, start_time_us, compression, mode, capture_features); exit: return return_value; @@ -873,6 +935,103 @@ _remote_debugging_BinaryWriter_write_sample(PyObject *self, PyObject *const *arg return return_value; } +PyDoc_STRVAR(_remote_debugging_BinaryWriter_set_stats__doc__, +"set_stats($self, /, duration_sec, sample_rate, error_rate=None,\n" +" missed_samples=None)\n" +"--\n" +"\n" +"Store measured profile statistics in the binary file."); + +#define _REMOTE_DEBUGGING_BINARYWRITER_SET_STATS_METHODDEF \ + {"set_stats", _PyCFunction_CAST(_remote_debugging_BinaryWriter_set_stats), METH_FASTCALL|METH_KEYWORDS, _remote_debugging_BinaryWriter_set_stats__doc__}, + +static PyObject * +_remote_debugging_BinaryWriter_set_stats_impl(BinaryWriterObject *self, + double duration_sec, + double sample_rate, + PyObject *error_rate, + PyObject *missed_samples); + +static PyObject * +_remote_debugging_BinaryWriter_set_stats(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 4 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(duration_sec), &_Py_ID(sample_rate), &_Py_ID(error_rate), &_Py_ID(missed_samples), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"duration_sec", "sample_rate", "error_rate", "missed_samples", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "set_stats", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + double duration_sec; + double sample_rate; + PyObject *error_rate = Py_None; + PyObject *missed_samples = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 2, /*maxpos*/ 4, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_CheckExact(args[0])) { + duration_sec = PyFloat_AS_DOUBLE(args[0]); + } + else + { + duration_sec = PyFloat_AsDouble(args[0]); + if (duration_sec == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + if (PyFloat_CheckExact(args[1])) { + sample_rate = PyFloat_AS_DOUBLE(args[1]); + } + else + { + sample_rate = PyFloat_AsDouble(args[1]); + if (sample_rate == -1.0 && PyErr_Occurred()) { + goto exit; + } + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + error_rate = args[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + missed_samples = args[3]; +skip_optional_pos: + return_value = _remote_debugging_BinaryWriter_set_stats_impl((BinaryWriterObject *)self, duration_sec, sample_rate, error_rate, missed_samples); + +exit: + return return_value; +} + PyDoc_STRVAR(_remote_debugging_BinaryWriter_finalize__doc__, "finalize($self, /)\n" "--\n" @@ -1016,7 +1175,7 @@ PyDoc_STRVAR(_remote_debugging_BinaryWriter_get_stats__doc__, "Get encoding statistics for the writer.\n" "\n" "Returns a dict with encoding statistics including\n" -"repeat/full/suffix/pop-push record counts, frames written/saved, and\n" +"repeat/full/suffix/reuse record counts, frames written/saved, and\n" "compression ratio."); #define _REMOTE_DEBUGGING_BINARYWRITER_GET_STATS_METHODDEF \ @@ -1374,7 +1533,7 @@ PyDoc_STRVAR(_remote_debugging_get_child_pids__doc__, {"get_child_pids", _PyCFunction_CAST(_remote_debugging_get_child_pids), METH_FASTCALL|METH_KEYWORDS, _remote_debugging_get_child_pids__doc__}, static PyObject * -_remote_debugging_get_child_pids_impl(PyObject *module, int pid, +_remote_debugging_get_child_pids_impl(PyObject *module, pid_t pid, int recursive); static PyObject * @@ -1410,7 +1569,7 @@ _remote_debugging_get_child_pids(PyObject *module, PyObject *const *args, Py_ssi #undef KWTUPLE PyObject *argsbuf[2]; Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; - int pid; + pid_t pid; int recursive = 1; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, @@ -1418,8 +1577,8 @@ _remote_debugging_get_child_pids(PyObject *module, PyObject *const *args, Py_ssi if (!args) { goto exit; } - pid = PyLong_AsInt(args[0]); - if (pid == -1 && PyErr_Occurred()) { + pid = PyLong_AsPid(args[0]); + if (pid == (pid_t)(-1) && PyErr_Occurred()) { goto exit; } if (!noptargs) { @@ -1446,7 +1605,7 @@ PyDoc_STRVAR(_remote_debugging_is_python_process__doc__, {"is_python_process", _PyCFunction_CAST(_remote_debugging_is_python_process), METH_FASTCALL|METH_KEYWORDS, _remote_debugging_is_python_process__doc__}, static PyObject * -_remote_debugging_is_python_process_impl(PyObject *module, int pid); +_remote_debugging_is_python_process_impl(PyObject *module, pid_t pid); static PyObject * _remote_debugging_is_python_process(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) @@ -1480,15 +1639,15 @@ _remote_debugging_is_python_process(PyObject *module, PyObject *const *args, Py_ }; #undef KWTUPLE PyObject *argsbuf[1]; - int pid; + pid_t pid; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!args) { goto exit; } - pid = PyLong_AsInt(args[0]); - if (pid == -1 && PyErr_Occurred()) { + pid = PyLong_AsPid(args[0]); + if (pid == (pid_t)(-1) && PyErr_Occurred()) { goto exit; } return_value = _remote_debugging_is_python_process_impl(module, pid); @@ -1527,7 +1686,7 @@ PyDoc_STRVAR(_remote_debugging_get_gc_stats__doc__, {"get_gc_stats", _PyCFunction_CAST(_remote_debugging_get_gc_stats), METH_FASTCALL|METH_KEYWORDS, _remote_debugging_get_gc_stats__doc__}, static PyObject * -_remote_debugging_get_gc_stats_impl(PyObject *module, int pid, +_remote_debugging_get_gc_stats_impl(PyObject *module, pid_t pid, int all_interpreters); static PyObject * @@ -1563,7 +1722,7 @@ _remote_debugging_get_gc_stats(PyObject *module, PyObject *const *args, Py_ssize #undef KWTUPLE PyObject *argsbuf[2]; Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; - int pid; + pid_t pid; int all_interpreters = 0; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, @@ -1571,8 +1730,8 @@ _remote_debugging_get_gc_stats(PyObject *module, PyObject *const *args, Py_ssize if (!args) { goto exit; } - pid = PyLong_AsInt(args[0]); - if (pid == -1 && PyErr_Occurred()) { + pid = PyLong_AsPid(args[0]); + if (pid == (pid_t)(-1) && PyErr_Occurred()) { goto exit; } if (!noptargs) { @@ -1588,4 +1747,4 @@ _remote_debugging_get_gc_stats(PyObject *module, PyObject *const *args, Py_ssize exit: return return_value; } -/*[clinic end generated code: output=a3df14a6ab7f2998 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2be4cb3f27f6c8d8 input=a9049054013a1b77]*/ diff --git a/Modules/_remote_debugging/code_objects.c b/Modules/_remote_debugging/code_objects.c index ab889a130ee4e7e..081aaa49fb49ffb 100644 --- a/Modules/_remote_debugging/code_objects.c +++ b/Modules/_remote_debugging/code_objects.c @@ -7,6 +7,8 @@ #include "_remote_debugging.h" +#define MAX_LINETABLE_SIZE (64 * 1024) + /* ============================================================================ * TLBC CACHING FUNCTIONS (Py_GIL_DISABLED only) * ============================================================================ */ @@ -30,9 +32,12 @@ get_tlbc_cache_entry(RemoteUnwinderObject *self, uintptr_t code_addr, uint32_t c TLBCCacheEntry *entry = _Py_hashtable_get(self->tlbc_cache, key); if (entry && entry->generation != current_generation) { - // Entry is stale, remove it by setting to NULL - _Py_hashtable_set(self->tlbc_cache, key, NULL); - entry = NULL; + // Entry is stale, remove it from the cache and destroy it + TLBCCacheEntry *old = _Py_hashtable_steal(self->tlbc_cache, key); + if (old != NULL) { + tlbc_cache_entry_destroy(old); + } + return NULL; } return entry; @@ -186,11 +191,7 @@ parse_linetable(const uintptr_t addrq, const char* linetable, Py_ssize_t linetab int computed_line = firstlineno; // Running accumulator, separate from output int val; // Temporary for varint results uint8_t byte; // Temporary for byte reads - const size_t MAX_LINETABLE_ENTRIES = 65536; - size_t entry_count = 0; - - while (ptr < end && *ptr != '\0' && entry_count < MAX_LINETABLE_ENTRIES) { - entry_count++; + while (ptr < end && *ptr != '\0') { uint8_t first_byte = *(ptr++); uint8_t code = (first_byte >> 3) & 15; size_t length = (first_byte & 7) + 1; @@ -340,11 +341,16 @@ parse_code_object(RemoteUnwinderObject *unwinder, PyObject **result, const CodeObjectContext *ctx) { + _Py_DECLARE_STR(unknown_function, ""); + _Py_DECLARE_STR(unknown_file, ""); + _Py_DECLARE_STR(unreadable_frame, ""); + void *key = (void *)ctx->code_addr; CachedCodeMetadata *meta = NULL; PyObject *func = NULL; PyObject *file = NULL; PyObject *linetable = NULL; + int code_metadata_incomplete = 0; #ifdef Py_GIL_DISABLED // In free threading builds, code object addresses might have the low bit set @@ -368,29 +374,50 @@ parse_code_object(RemoteUnwinderObject *unwinder, if (_Py_RemoteDebug_PagedReadRemoteMemory( &unwinder->handle, real_address, SIZEOF_CODE_OBJ, code_object) < 0) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read code object"); - goto error; + if (_Py_RemoteDebug_IsFatalReadError()) { + goto error; + } + PyErr_Clear(); + func = Py_NewRef(&_Py_STR(unreadable_frame)); + file = Py_NewRef(_Py_LATIN1_CHR('~')); + goto degraded; } func = read_py_str(unwinder, GET_MEMBER(uintptr_t, code_object, unwinder->debug_offsets.code_object.qualname), 1024); if (!func) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read function name from code object"); - goto error; + if (_Py_RemoteDebug_IsFatalReadError()) { + goto error; + } + PyErr_Clear(); + func = Py_NewRef(&_Py_STR(unknown_function)); + code_metadata_incomplete = 1; } file = read_py_str(unwinder, GET_MEMBER(uintptr_t, code_object, unwinder->debug_offsets.code_object.filename), 1024); if (!file) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read filename from code object"); - goto error; + if (_Py_RemoteDebug_IsFatalReadError()) { + goto error; + } + PyErr_Clear(); + file = Py_NewRef(&_Py_STR(unknown_file)); + code_metadata_incomplete = 1; + } + + if (code_metadata_incomplete) { + goto degraded; } linetable = read_py_bytes(unwinder, - GET_MEMBER(uintptr_t, code_object, unwinder->debug_offsets.code_object.linetable), 4096); + GET_MEMBER(uintptr_t, code_object, unwinder->debug_offsets.code_object.linetable), + MAX_LINETABLE_SIZE); if (!linetable) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read linetable from code object"); - goto error; + if (_Py_RemoteDebug_IsFatalReadError()) { + goto error; + } + PyErr_Clear(); + goto degraded; } meta = PyMem_RawMalloc(sizeof(CachedCodeMetadata)); @@ -450,6 +477,22 @@ parse_code_object(RemoteUnwinderObject *unwinder, tlbc_entry = get_tlbc_cache_entry(unwinder, real_address, unwinder->tlbc_generation); } + if (tlbc_entry && ctx->tlbc_index >= 0) { + uintptr_t *entries = (uintptr_t *)((char *)tlbc_entry->tlbc_array + sizeof(Py_ssize_t)); + if (ctx->tlbc_index >= tlbc_entry->tlbc_array_size || + entries[ctx->tlbc_index] == 0) { + TLBCCacheEntry *old = _Py_hashtable_steal(unwinder->tlbc_cache, (void *)real_address); + if (old != NULL) { + tlbc_cache_entry_destroy(old); + } + if (!cache_tlbc_array(unwinder, real_address, real_address + unwinder->debug_offsets.code_object.co_tlbc, + unwinder->tlbc_generation)) { + goto error; + } + tlbc_entry = get_tlbc_cache_entry(unwinder, real_address, unwinder->tlbc_generation); + } + } + // Validate tlbc_index and check TLBC cache if (tlbc_entry) { // Validate index bounds (also catches negative values since tlbc_index is signed) @@ -543,6 +586,18 @@ parse_code_object(RemoteUnwinderObject *unwinder, *result = tuple; return 0; +degraded: { + PyObject *degraded_tuple = make_frame_info(unwinder, file, Py_None, + func, Py_None); + Py_CLEAR(func); + Py_CLEAR(file); + if (!degraded_tuple) { + return -1; + } + *result = degraded_tuple; + return 0; +} + error: Py_XDECREF(func); Py_XDECREF(file); diff --git a/Modules/_remote_debugging/debug_offsets_validation.h b/Modules/_remote_debugging/debug_offsets_validation.h index c0c01a0a639e196..66c35e5522a9c7d 100644 --- a/Modules/_remote_debugging/debug_offsets_validation.h +++ b/Modules/_remote_debugging/debug_offsets_validation.h @@ -48,6 +48,15 @@ static_assert( PY_REMOTE_ASYNC_DEBUG_OFFSETS_TOTAL_SIZE, "Update _remote_debugging validation for _Py_AsyncioModuleDebugOffsets"); +/* Derive unexported offsets from adjacent fields to keep the debug-offset + * table compatible across patch releases. */ +static_assert(offsetof(PyThreadState, exc_info) == + offsetof(PyThreadState, current_exception) + sizeof(uintptr_t), + "exc_info must immediately follow current_exception"); +static_assert(offsetof(_PyErr_StackItem, previous_item) == + offsetof(_PyErr_StackItem, exc_value) + sizeof(uintptr_t), + "previous_item must immediately follow exc_value"); + /* * This logic lives in a private header because it is shared by module.c and * asyncio.c. Keep the helpers static inline so they stay local to those users @@ -249,6 +258,7 @@ validate_fixed_field( #define PY_REMOTE_DEBUG_RUNTIME_STATE_FIELDS(APPLY, buffer_size) \ APPLY(runtime_state, interpreters_head, sizeof(uintptr_t), _Alignof(uintptr_t), buffer_size) +/* current_exception also covers the adjacent exc_info pointer. */ #define PY_REMOTE_DEBUG_THREAD_STATE_FIELDS(APPLY, buffer_size) \ APPLY(thread_state, native_thread_id, sizeof(unsigned long), _Alignof(long), buffer_size); \ APPLY(thread_state, interp, sizeof(uintptr_t), _Alignof(uintptr_t), buffer_size); \ @@ -256,7 +266,7 @@ validate_fixed_field( APPLY(thread_state, status, FIELD_SIZE(PyThreadState, _status), _Alignof(unsigned int), buffer_size); \ APPLY(thread_state, holds_gil, sizeof(int), _Alignof(int), buffer_size); \ APPLY(thread_state, gil_requested, sizeof(int), _Alignof(int), buffer_size); \ - APPLY(thread_state, current_exception, sizeof(uintptr_t), _Alignof(uintptr_t), buffer_size); \ + APPLY(thread_state, current_exception, 2 * sizeof(uintptr_t), _Alignof(uintptr_t), buffer_size); \ APPLY(thread_state, thread_id, sizeof(unsigned long), _Alignof(long), buffer_size); \ APPLY(thread_state, next, sizeof(uintptr_t), _Alignof(uintptr_t), buffer_size); \ APPLY(thread_state, current_frame, sizeof(uintptr_t), _Alignof(uintptr_t), buffer_size); \ @@ -351,10 +361,11 @@ _PyRemoteDebug_ValidateDebugOffsetsLayout(struct _Py_DebugOffsets *debug_offsets PY_REMOTE_DEBUG_THREAD_STATE_FIELDS( PY_REMOTE_DEBUG_VALIDATE_FIELD, SIZEOF_THREAD_STATE); + /* exc_value also covers the adjacent previous_item pointer. */ PY_REMOTE_DEBUG_VALIDATE_FIXED_FIELD( err_stackitem, exc_value, - sizeof(uintptr_t), + 2 * sizeof(uintptr_t), _Alignof(uintptr_t), sizeof(_PyErr_StackItem)); PY_REMOTE_DEBUG_VALIDATE_NESTED_FIELD( diff --git a/Modules/_remote_debugging/frame_cache.c b/Modules/_remote_debugging/frame_cache.c index 1b2d9a60f408b91..63d1331015a548d 100644 --- a/Modules/_remote_debugging/frame_cache.c +++ b/Modules/_remote_debugging/frame_cache.c @@ -318,9 +318,8 @@ frame_cache_store( // Validate we have a complete stack before caching. // Only cache if last_frame_visited matches base_frame_addr (the sentinel // at the bottom of the stack). Note: we use last_frame_visited rather than - // addrs[num_addrs-1] because the base frame is visited but not added to the - // addrs array (it returns frame==NULL from is_frame_valid due to - // owner==FRAME_OWNED_BY_INTERPRETER). + // addrs[num_addrs-1] because the base frame's address is not added to the + // addrs array. if (base_frame_addr != 0 && last_frame_visited != base_frame_addr) { // Incomplete stack - don't cache (graceful degradation) return 0; diff --git a/Modules/_remote_debugging/frames.c b/Modules/_remote_debugging/frames.c index 46968acc6ff1feb..3f8d628a6314e6e 100644 --- a/Modules/_remote_debugging/frames.c +++ b/Modules/_remote_debugging/frames.c @@ -36,7 +36,7 @@ process_single_stack_chunk( return -1; } - if (_Py_RemoteDebug_PagedReadRemoteMemory(&unwinder->handle, chunk_addr, current_size, this_chunk) < 0) { + if (_Py_RemoteDebug_ReadRemoteMemory(&unwinder->handle, chunk_addr, current_size, this_chunk) < 0) { PyMem_RawFree(this_chunk); set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read stack chunk"); return -1; @@ -65,7 +65,7 @@ process_single_stack_chunk( } this_chunk = tmp; - if (_Py_RemoteDebug_PagedReadRemoteMemory(&unwinder->handle, chunk_addr, actual_size, this_chunk) < 0) { + if (_Py_RemoteDebug_ReadRemoteMemory(&unwinder->handle, chunk_addr, actual_size, this_chunk) < 0) { PyMem_RawFree(this_chunk); set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to reread stack chunk with correct size"); return -1; @@ -163,6 +163,8 @@ find_frame_in_chunks(StackChunkList *chunks, uintptr_t remote_ptr) * FRAME PARSING FUNCTIONS * ============================================================================ */ +enum { FRAME_PARSE_INTERPRETER = 2 }; + int is_frame_valid( RemoteUnwinderObject *unwinder, @@ -170,14 +172,14 @@ is_frame_valid( uintptr_t code_object_addr ) { if ((void*)code_object_addr == NULL) { - return 0; + return 0; // Frame being cleared } void* frame = (void*)frame_addr; char owner = GET_MEMBER(char, frame, unwinder->debug_offsets.interpreter_frame.owner); if (owner == FRAME_OWNED_BY_INTERPRETER) { - return 0; // C frame or sentinel base frame + return FRAME_PARSE_INTERPRETER; // C frame or sentinel base frame } if (owner != FRAME_OWNED_BY_GENERATOR && owner != FRAME_OWNED_BY_THREAD) { @@ -193,11 +195,8 @@ parse_frame_buffer( RemoteUnwinderObject *unwinder, PyObject** result, const char *frame, - uintptr_t* address_of_code_object, uintptr_t* previous_frame ) { - *address_of_code_object = 0; - *previous_frame = GET_MEMBER(uintptr_t, frame, unwinder->debug_offsets.interpreter_frame.previous); uintptr_t code_object = GET_MEMBER_NO_TAG(uintptr_t, frame, unwinder->debug_offsets.interpreter_frame.executable); int frame_valid = is_frame_valid(unwinder, (uintptr_t)frame, code_object); @@ -215,8 +214,6 @@ parse_frame_buffer( } #endif - *address_of_code_object = code_object; - CodeObjectContext code_ctx = { .code_addr = code_object, .instruction_pointer = instruction_pointer, @@ -230,7 +227,6 @@ parse_frame_object( RemoteUnwinderObject *unwinder, PyObject** result, uintptr_t address, - uintptr_t* address_of_code_object, uintptr_t* previous_frame ) { char frame[SIZEOF_INTERP_FRAME]; @@ -247,7 +243,7 @@ parse_frame_object( STATS_INC(unwinder, memory_reads); STATS_ADD(unwinder, memory_bytes_read, SIZEOF_INTERP_FRAME); - return parse_frame_buffer(unwinder, result, frame, address_of_code_object, previous_frame); + return parse_frame_buffer(unwinder, result, frame, previous_frame); } int @@ -256,41 +252,16 @@ parse_frame_from_chunks( PyObject **result, uintptr_t address, uintptr_t *previous_frame, - uintptr_t *stackpointer, StackChunkList *chunks ) { - void *frame_ptr = find_frame_in_chunks(chunks, address); - if (!frame_ptr) { + const char *frame = find_frame_in_chunks(chunks, address); + if (!frame) { PyErr_Format(PyExc_RuntimeError, "Frame at address 0x%lx not found in stack chunks", address); set_exception_cause(unwinder, PyExc_RuntimeError, "Frame not found in stack chunks"); return -1; } - char *frame = (char *)frame_ptr; - *previous_frame = GET_MEMBER(uintptr_t, frame, unwinder->debug_offsets.interpreter_frame.previous); - *stackpointer = GET_MEMBER(uintptr_t, frame, unwinder->debug_offsets.interpreter_frame.stackpointer); - uintptr_t code_object = GET_MEMBER_NO_TAG(uintptr_t, frame_ptr, unwinder->debug_offsets.interpreter_frame.executable); - int frame_valid = is_frame_valid(unwinder, (uintptr_t)frame, code_object); - if (frame_valid != 1) { - return frame_valid; - } - - uintptr_t instruction_pointer = GET_MEMBER(uintptr_t, frame, unwinder->debug_offsets.interpreter_frame.instr_ptr); - - // Get tlbc_index for free threading builds - int32_t tlbc_index = 0; -#ifdef Py_GIL_DISABLED - if (unwinder->debug_offsets.interpreter_frame.tlbc_index != 0) { - tlbc_index = GET_MEMBER(int32_t, frame, unwinder->debug_offsets.interpreter_frame.tlbc_index); - } -#endif - - CodeObjectContext code_ctx = { - .code_addr = code_object, - .instruction_pointer = instruction_pointer, - .tlbc_index = tlbc_index, - }; - return parse_code_object(unwinder, result, &code_ctx); + return parse_frame_buffer(unwinder, result, frame, previous_frame); } /* ============================================================================ @@ -305,49 +276,51 @@ process_frame_chain( uintptr_t frame_addr = ctx->frame_addr; uintptr_t prev_frame_addr = 0; uintptr_t last_frame_addr = 0; - const size_t MAX_FRAMES = 1024 + 512; size_t frame_count = 0; - assert(MAX_FRAMES > 0 && MAX_FRAMES < 10000); ctx->stopped_at_cached_frame = 0; ctx->last_frame_visited = 0; while ((void*)frame_addr != NULL) { + int parse_result = 0; PyObject *frame = NULL; uintptr_t next_frame_addr = 0; - uintptr_t stackpointer = 0; last_frame_addr = frame_addr; - if (++frame_count > MAX_FRAMES) { + if (++frame_count > MAX_FRAME_CHAIN_DEPTH) { PyErr_SetString(PyExc_RuntimeError, "Too many stack frames (possible infinite loop)"); set_exception_cause(unwinder, PyExc_RuntimeError, "Frame chain iteration limit exceeded"); return -1; } - assert(frame_count <= MAX_FRAMES); + assert(frame_count <= MAX_FRAME_CHAIN_DEPTH); + + // The base frame is a sentinel with previous == NULL: reaching it is + // enough, no need to read it. Still read it when it is the GC frame + // so the marker gets emitted. + if (frame_addr == ctx->base_frame_addr + && !(unwinder->gc && frame_addr == ctx->gc_frame)) { + break; + } if (ctx->chunks && ctx->chunks->count > 0) { - if (parse_frame_from_chunks(unwinder, &frame, frame_addr, &next_frame_addr, &stackpointer, ctx->chunks) == 0) { + parse_result = parse_frame_from_chunks( + unwinder, &frame, frame_addr, &next_frame_addr, ctx->chunks); + if (parse_result == 0) { goto parsed_frame; } PyErr_Clear(); } - { - uintptr_t address_of_code_object = 0; - int parse_result; - if (ctx->prefetch.frame && ctx->prefetch.frame_addr == frame_addr) { - parse_result = parse_frame_buffer( - unwinder, &frame, ctx->prefetch.frame, - &address_of_code_object, &next_frame_addr); - } - else { - parse_result = parse_frame_object( - unwinder, &frame, frame_addr, - &address_of_code_object, &next_frame_addr); - } - if (parse_result < 0) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to parse frame object in chain"); - return -1; - } + if (ctx->prefetch.frame && ctx->prefetch.frame_addr == frame_addr) { + parse_result = parse_frame_buffer( + unwinder, &frame, ctx->prefetch.frame, &next_frame_addr); + } + else { + parse_result = parse_frame_object( + unwinder, &frame, frame_addr, &next_frame_addr); + } + if (parse_result < 0) { + set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to parse frame object in chain"); + return -1; } parsed_frame: @@ -358,19 +331,19 @@ process_frame_chain( continue; } - if (frame == NULL && PyList_GET_SIZE(ctx->frame_info) == 0) { - const char *e = "Failed to parse initial frame in chain"; - PyErr_SetString(PyExc_RuntimeError, e); - return -1; - } PyObject *extra_frame = NULL; if (unwinder->gc && frame_addr == ctx->gc_frame) { _Py_DECLARE_STR(gc, ""); extra_frame = &_Py_STR(gc); } + // A leading frame without Python code marks no transition between + // Python frames: it is a frame being popped or C code the thread is + // returning into. else if (unwinder->native && frame == NULL && + parse_result == FRAME_PARSE_INTERPRETER && next_frame_addr && + PyList_GET_SIZE(ctx->frame_info) > 0 && !(unwinder->gc && next_frame_addr == ctx->gc_frame)) { _Py_DECLARE_STR(native, ""); @@ -463,7 +436,7 @@ clear_last_profiled_frames(RemoteUnwinderObject *unwinder) uintptr_t tstate_addr; if (_Py_RemoteDebug_PagedReadRemoteMemory( &unwinder->handle, - current_interp + unwinder->debug_offsets.interpreter_state.threads_head, + current_interp + (uintptr_t)unwinder->debug_offsets.interpreter_state.threads_head, sizeof(void*), &tstate_addr) < 0) { // Non-fatal: just skip clearing @@ -484,7 +457,7 @@ clear_last_profiled_frames(RemoteUnwinderObject *unwinder) // Move to next thread if (_Py_RemoteDebug_PagedReadRemoteMemory( &unwinder->handle, - tstate_addr + unwinder->debug_offsets.thread_state.next, + tstate_addr + (uintptr_t)unwinder->debug_offsets.thread_state.next, sizeof(void*), &tstate_addr) < 0) { PyErr_Clear(); @@ -495,7 +468,7 @@ clear_last_profiled_frames(RemoteUnwinderObject *unwinder) // Move to next interpreter if (_Py_RemoteDebug_PagedReadRemoteMemory( &unwinder->handle, - current_interp + unwinder->debug_offsets.interpreter_state.next, + current_interp + (uintptr_t)unwinder->debug_offsets.interpreter_state.next, sizeof(void*), ¤t_interp) < 0) { PyErr_Clear(); @@ -541,17 +514,16 @@ try_full_cache_hit( } PyObject *current_frame = NULL; - uintptr_t code_object_addr = 0; uintptr_t previous_frame = 0; int parse_result; if (ctx->prefetch.frame && ctx->prefetch.frame_addr == ctx->frame_addr) { parse_result = parse_frame_buffer(unwinder, ¤t_frame, ctx->prefetch.frame, - &code_object_addr, &previous_frame); + &previous_frame); } else { parse_result = parse_frame_object(unwinder, ¤t_frame, ctx->frame_addr, - &code_object_addr, &previous_frame); + &previous_frame); } if (parse_result < 0) { return -1; diff --git a/Modules/_remote_debugging/gc_stats.c b/Modules/_remote_debugging/gc_stats.c index d5d05edb8ecf5ee..4dc77803a0a9f3c 100644 --- a/Modules/_remote_debugging/gc_stats.c +++ b/Modules/_remote_debugging/gc_stats.c @@ -88,8 +88,8 @@ get_gc_stats_from_interpreter_state(RuntimeOffsets *offsets, uintptr_t gc_stats_addr = 0; uintptr_t gc_stats_pointer_address = interpreter_state_addr - + offsets->debug_offsets.interpreter_state.gc - + offsets->debug_offsets.gc.generation_stats; + + (uintptr_t)offsets->debug_offsets.interpreter_state.gc + + (uintptr_t)offsets->debug_offsets.gc.generation_stats; if (_Py_RemoteDebug_ReadRemoteMemory(&offsets->handle, gc_stats_pointer_address, sizeof(gc_stats_addr), @@ -103,12 +103,42 @@ get_gc_stats_from_interpreter_state(RuntimeOffsets *offsets, } struct gc_stats stats; - if (_Py_RemoteDebug_ReadRemoteMemory(&offsets->handle, - gc_stats_addr, - sizeof(stats), - &stats) < 0) { - set_exception_cause(offsets, PyExc_RuntimeError, "Failed to read GC state"); - return -1; + uintptr_t sequence_address = gc_stats_addr + + offsetof(struct gc_stats, update_seq); + /* A short GC update may finish before a second attempt. */ + for (int attempt = 0; attempt < 2; attempt++) { + uint32_t before; + if (_Py_RemoteDebug_ReadRemoteMemory(&offsets->handle, + sequence_address, + sizeof(before), &before) < 0) { + set_exception_cause(offsets, PyExc_RuntimeError, + "Failed to read GC update sequence"); + return -1; + } + if (_Py_RemoteDebug_ReadRemoteMemory(&offsets->handle, + gc_stats_addr, + sizeof(stats), + &stats) < 0) { + set_exception_cause(offsets, PyExc_RuntimeError, "Failed to read GC state"); + return -1; + } + + uint32_t after; + if (_Py_RemoteDebug_ReadRemoteMemory(&offsets->handle, + sequence_address, + sizeof(after), &after) < 0) { + set_exception_cause(offsets, PyExc_RuntimeError, + "Failed to read GC update sequence"); + return -1; + } + if (before == after && before == stats.update_seq && !(after & 1)) { + break; + } + if (attempt == 1) { + PyErr_SetString(PyExc_RuntimeError, + "GC stats changed while being read; retry later"); + return -1; + } } if (read_gc_stats(&stats, iid, ctx->result, diff --git a/Modules/_remote_debugging/module.c b/Modules/_remote_debugging/module.c index adafee97a94ada7..d9d7b61633a106c 100644 --- a/Modules/_remote_debugging/module.c +++ b/Modules/_remote_debugging/module.c @@ -34,12 +34,13 @@ static PyStructSequence_Field TaskInfo_fields[] = { {"task_name", "Task name"}, {"coroutine_stack", "Coroutine call stack"}, {"awaited_by", "Tasks awaiting this task"}, + {"is_future", "Whether this node is a plain Future rather than a Task"}, {NULL} }; PyStructSequence_Desc TaskInfo_desc = { "_remote_debugging.TaskInfo", - "Information about an asyncio task", + "Information about an asyncio task or future", TaskInfo_fields, 4 }; @@ -281,7 +282,7 @@ class _remote_debugging.RemoteUnwinder "RemoteUnwinderObject *" "&RemoteUnwinder /*[clinic input] @permit_long_summary _remote_debugging.RemoteUnwinder.__init__ - pid: int + pid: pid_t * all_threads: bool = False only_active_thread: bool = False @@ -334,14 +335,14 @@ other runtime data. static int _remote_debugging_RemoteUnwinder___init___impl(RemoteUnwinderObject *self, - int pid, int all_threads, + pid_t pid, int all_threads, int only_active_thread, int mode, int debug, int skip_non_matching_threads, int native, int gc, int opcodes, int cache_frames, int stats) -/*[clinic end generated code: output=0031f743f4b9ad52 input=9d25ae328d62626d]*/ +/*[clinic end generated code: output=acfe554c8a92cf6b input=3b5a5ad153709125]*/ { // Validate that all_threads and only_active_thread are not both True if (all_threads && only_active_thread) { @@ -384,12 +385,6 @@ _remote_debugging_RemoteUnwinder___init___impl(RemoteUnwinderObject *self, return -1; } - self->runtime_start_address = _Py_RemoteDebug_GetPyRuntimeAddress(&self->handle); - if (self->runtime_start_address == 0) { - set_exception_cause(self, PyExc_RuntimeError, "Failed to get Python runtime address"); - return -1; - } - if (_Py_RemoteDebug_ReadDebugOffsets(&self->handle, &self->runtime_start_address, &self->debug_offsets) < 0) @@ -404,20 +399,8 @@ _remote_debugging_RemoteUnwinder___init___impl(RemoteUnwinderObject *self, return -1; } - // Try to read async debug offsets, but don't fail if they're not available - self->async_debug_offsets_available = 1; - int async_debug_result = read_async_debug(self); - if (async_debug_result == PY_REMOTE_DEBUG_INVALID_ASYNC_DEBUG_OFFSETS) { - return -1; - } - if (async_debug_result < 0) { - if (_Py_RemoteDebug_HasPermissionError()) { - return -1; - } - PyErr_Clear(); - memset(&self->async_debug_offsets, 0, sizeof(self->async_debug_offsets)); - self->async_debug_offsets_available = 0; - } + self->async_debug_offsets_available = 0; + memset(&self->async_debug_offsets, 0, sizeof(self->async_debug_offsets)); if (populate_initial_state_data(all_threads, self, self->runtime_start_address, &self->interpreter_addr ,&self->tstate_addr) < 0) @@ -450,22 +433,12 @@ _remote_debugging_RemoteUnwinder___init___impl(RemoteUnwinderObject *self, NULL ); if (self->tlbc_cache == NULL) { - _Py_hashtable_destroy(self->code_object_cache); PyErr_NoMemory(); set_exception_cause(self, PyExc_MemoryError, "Failed to create TLBC cache"); return -1; } #endif -#if defined(__APPLE__) - self->thread_id_offset = 0; - self->thread_id_offset_initialized = 0; -#endif - -#ifdef MS_WINDOWS - self->win_process_buffer = NULL; - self->win_process_buffer_size = 0; -#endif #ifdef __linux__ self->thread_tids = NULL; self->thread_tids_capacity = 0; @@ -823,6 +796,9 @@ _remote_debugging_RemoteUnwinder_get_stack_trace_impl(RemoteUnwinderObject *self goto exit; } // Thread was skipped due to mode filtering, continue to next thread + if (self->tstate_addr || self->only_active_thread) { + break; + } continue; } // This was an actual error @@ -904,27 +880,32 @@ _remote_debugging_RemoteUnwinder_get_stack_trace_impl(RemoteUnwinderObject *self } /*[clinic input] -@permit_long_summary +@permit_long_docstring_body @critical_section _remote_debugging.RemoteUnwinder.get_all_awaited_by -Get all tasks and their awaited_by relationships from the remote process. +Get awaited_by relationships for tasks in the remote process. -This provides a tree structure showing which tasks are waiting for -other tasks. - -For each task, returns: -1. The call stack frames leading to where the task is currently - executing -2. The name of the task -3. A list of tasks that this task is waiting for, with their own - frames/names/etc - -Returns a list of [frames, task_name, subtasks] where: -- frames: List of (func_name, filename, lineno) showing the call - stack -- task_name: String identifier for the task -- subtasks: List of tasks being awaited by this task, in same format +Returns: + A list of AwaitedInfo objects, where each object contains: + + - thread_id (int): Identifier of the thread, or 0 for tasks in the + interpreter's fallback task list. + - awaited_by (list[TaskInfo]): Tasks registered with this thread and + intermediate futures in their awaited_by chains. + +Each TaskInfo contains: + - task_id (int): Identifier of the task. + - task_name (str): Name of the task, or a generated name for + a future. + - coroutine_stack (list[CoroInfo]): Stack of coroutine frames. + - awaited_by (list[CoroInfo]): Coroutine information for tasks or futures + awaiting this task. + - is_future (bool, named-only): True for a plain Future. + +Each CoroInfo contains: + - call_stack (list[FrameInfo]): Call stack frames for the coroutine. + - task_name (int): Identifier of the task or future. Raises: RuntimeError: If AsyncioDebug section is not available in the @@ -933,29 +914,25 @@ Returns a list of [frames, task_name, subtasks] where: OSError: If reading from the remote process fails Example output: -[ - # Task c2_root waiting for two subtasks + [ - # Call stack of c2_root - [("c5", "script.py", 10), ("c4", "script.py", 14)], - "c2_root", - [ - # First subtask (sub_main_2) and what it's waiting for - [ - [("c1", "script.py", 23)], - "sub_main_2", - [...] - ], - # Second subtask and its waiters - [...] - ] + AwaitedInfo( + thread_id=12345, + awaited_by=[ + TaskInfo( + task_id=1, + task_name="Task-1", + coroutine_stack=[...], + awaited_by=[] + ) + ] + ) ] -] [clinic start generated code]*/ static PyObject * _remote_debugging_RemoteUnwinder_get_all_awaited_by_impl(RemoteUnwinderObject *self) -/*[clinic end generated code: output=6a49cd345e8aec53 input=c22bfee0612e0b69]*/ +/*[clinic end generated code: output=6a49cd345e8aec53 input=17fcd3d7bb835624]*/ { if (ensure_async_debug_offsets(self) < 0) { return NULL; @@ -1013,16 +990,37 @@ For each thread with a running task, returns the running task plus all tasks that transitively depend on it (tasks waiting for the running task, tasks waiting for those tasks, etc.). -Returns a list of per-thread results, where each thread result -contains: -- Thread ID -- List of task information for the running task and all its waiters - -Each task info contains: -- Task ID (memory address) -- Task name -- Call stack frames: List of (func_name, filename, lineno) -- List of tasks waiting for this task (recursive structure) +Returns: + A list of AwaitedInfo objects, where each object contains: + + - thread_id (int): Identifier of the thread. + - awaited_by (list[TaskInfo]): The running task and all its + transitive waiters, including intermediate futures. + +Each TaskInfo contains: + - task_id (int): Identifier of the task. + - task_name (str): Name of the task, or a generated name for + a future. + - coroutine_stack (list[CoroInfo]): Stack of coroutine frames. + - awaited_by (list[CoroInfo]): Coroutine information for + tasks or futures awaiting this task. + - is_future (bool, named-only): True for a plain Future. + +Each CoroInfo contains: + - call_stack (list[FrameInfo]): Frames for the coroutine. + - task_name (int): Identifier of the task or future. + +Each FrameInfo contains: + - filename (str): Source code filename. + - location (LocationInfo | None): Source location, if available. + - funcname (str): Function name. + - opcode (int | None): Opcode, if available. + +Each LocationInfo contains: + - lineno (int): Starting line number. + - end_lineno (int): Ending line number. + - col_offset (int): Starting column offset. + - end_col_offset (int): Ending column offset. Raises: RuntimeError: If AsyncioDebug section is not available in the @@ -1030,27 +1028,36 @@ Each task info contains: MemoryError: If memory allocation fails OSError: If reading from the remote process fails -Example output (similar structure to get_all_awaited_by but only for -running tasks): -[ - # Thread 140234 results - (140234, [ - # Running task and its complete waiter dependency graph - (4345585712, 'main_task', - [("run_server", "server.py", 127), ("main", "app.py", 23)], - [ - # Tasks waiting for main_task - (4345585800, 'worker_1', [...], [...]), - (4345585900, 'worker_2', [...], [...]) - ]) - ]) -] +Example output: + + [ + AwaitedInfo(thread_id=140234, awaited_by=[ + TaskInfo( + task_id=1, + task_name="worker", + coroutine_stack=[ + CoroInfo(call_stack=[...], task_name=1) + ], + awaited_by=[ + CoroInfo(call_stack=[...], task_name=2) + ] + ), + TaskInfo( + task_id=2, + task_name="main", + coroutine_stack=[ + CoroInfo(call_stack=[...], task_name=2) + ], + awaited_by=[] + ) + ]) + ] [clinic start generated code]*/ static PyObject * _remote_debugging_RemoteUnwinder_get_async_stack_trace_impl(RemoteUnwinderObject *self) -/*[clinic end generated code: output=6433d52b55e87bbe input=bc802e4221c99399]*/ +/*[clinic end generated code: output=6433d52b55e87bbe input=a95958816358476a]*/ { if (ensure_async_debug_offsets(self) < 0) { return NULL; @@ -1324,11 +1331,6 @@ RemoteUnwinder_dealloc(PyObject *op) if (self->code_object_cache) { _Py_hashtable_destroy(self->code_object_cache); } -#ifdef MS_WINDOWS - if (self->win_process_buffer != NULL) { - PyMem_Free(self->win_process_buffer); - } -#endif #ifdef Py_GIL_DISABLED if (self->tlbc_cache) { @@ -1376,18 +1378,13 @@ cleanup_runtime_offsets(RuntimeOffsets *offsets) } static int -init_runtime_offsets(RuntimeOffsets *offsets, int pid, int debug) +init_runtime_offsets(RuntimeOffsets *offsets, pid_t pid, int debug) { offsets->debug = debug; if (_Py_RemoteDebug_InitProcHandle(&offsets->handle, pid) < 0) { set_exception_cause(offsets, PyExc_RuntimeError, "Failed to initialize process handle"); return -1; } - offsets->runtime_start_address = _Py_RemoteDebug_GetPyRuntimeAddress(&offsets->handle); - if (offsets->runtime_start_address == 0) { - set_exception_cause(offsets, PyExc_RuntimeError, "Failed to get Python runtime address"); - goto error; - } if (_Py_RemoteDebug_ReadDebugOffsets(&offsets->handle, &offsets->runtime_start_address, &offsets->debug_offsets) < 0) @@ -1414,7 +1411,7 @@ class _remote_debugging.GCMonitor "GCMonitorObject *" "&GCMonitor_Type" /*[clinic input] @permit_long_summary _remote_debugging.GCMonitor.__init__ - pid: int + pid: pid_t * debug: bool = False @@ -1437,9 +1434,9 @@ a running Python process. [clinic start generated code]*/ static int -_remote_debugging_GCMonitor___init___impl(GCMonitorObject *self, int pid, +_remote_debugging_GCMonitor___init___impl(GCMonitorObject *self, pid_t pid, int debug) -/*[clinic end generated code: output=2cdf351c2f6335db input=03da0b2d3282ae1b]*/ +/*[clinic end generated code: output=03b4c92bef0673ad input=dcc6ee2ec5a16fa1]*/ { return init_runtime_offsets(&self->offsets, pid, debug); } @@ -1717,6 +1714,8 @@ _remote_debugging.BinaryWriter.__init__ start_time_us: unsigned_long_long * compression: int = 0 + mode: int = -1 + capture_features: int = -1 High-performance binary writer for profiling data. @@ -1726,6 +1725,9 @@ High-performance binary writer for profiling data. start_time_us: Start timestamp in microseconds (from time.monotonic() * 1e6) compression: 0=none, 1=zstd (default: 0) + mode: Profiling mode, or -1 if unknown (default: -1) + capture_features: Capture feature bit mask, or -1 if unknown + (default: -1) Use as a context manager or call finalize() when done. [clinic start generated code]*/ @@ -1735,14 +1737,26 @@ _remote_debugging_BinaryWriter___init___impl(BinaryWriterObject *self, PyObject *filename, unsigned long long sample_interval_us, unsigned long long start_time_us, - int compression) -/*[clinic end generated code: output=00446656ea2e5986 input=2e3f298c69fc7666]*/ + int compression, int mode, + int capture_features) +/*[clinic end generated code: output=3c1c9576795658ce input=98add735b20403ad]*/ { + if (mode < -1 || mode > PROFILING_MODE_EXCEPTION) { + PyErr_SetString(PyExc_ValueError, "invalid profiling mode"); + return -1; + } + if (capture_features < -1 || + capture_features > (int)PROFILING_FEATURE_MASK) { + PyErr_SetString(PyExc_ValueError, "invalid capture features"); + return -1; + } if (self->writer) { binary_writer_destroy(self->writer); } - self->writer = binary_writer_create(filename, sample_interval_us, compression, start_time_us); + self->writer = binary_writer_create( + filename, sample_interval_us, compression, start_time_us, mode, + capture_features); if (!self->writer) { return -1; } @@ -1774,23 +1788,83 @@ _remote_debugging_BinaryWriter_write_sample_impl(BinaryWriterObject *self, return NULL; } + if (self->writer->state == BINARY_WRITER_BROKEN) { + PyErr_SetString(PyExc_ValueError, "Writer is broken"); + return NULL; + } + self->writer->state = BINARY_WRITER_OPEN; if (binary_writer_write_sample(self->writer, stack_frames, timestamp_us) < 0) { + if (self->writer->state != BINARY_WRITER_LIMIT_REACHED) { + self->writer->state = BINARY_WRITER_BROKEN; + } return NULL; } Py_RETURN_NONE; } +/*[clinic input] +_remote_debugging.BinaryWriter.set_stats + duration_sec: double + sample_rate: double + error_rate: object = None + missed_samples: object = None + +Store measured profile statistics in the binary file. +[clinic start generated code]*/ + +static PyObject * +_remote_debugging_BinaryWriter_set_stats_impl(BinaryWriterObject *self, + double duration_sec, + double sample_rate, + PyObject *error_rate, + PyObject *missed_samples) +/*[clinic end generated code: output=28ab1bdd7c631a97 input=1646e7182f4c2259]*/ +{ + if (!self->writer) { + PyErr_SetString(PyExc_ValueError, "Writer is closed"); + return NULL; + } + uint32_t present = 0; + double error_rate_value = 0.0; + double missed_samples_value = 0.0; + if (error_rate != Py_None) { + error_rate_value = PyFloat_AsDouble(error_rate); + if (error_rate_value == -1.0 && PyErr_Occurred()) { + return NULL; + } + present |= PROFILE_STATS_ERROR_RATE; + } + if (missed_samples != Py_None) { + missed_samples_value = PyFloat_AsDouble(missed_samples); + if (missed_samples_value == -1.0 && PyErr_Occurred()) { + return NULL; + } + present |= PROFILE_STATS_MISSED; + } + if (binary_writer_set_stats(self->writer, duration_sec, sample_rate, + error_rate_value, missed_samples_value, + present) < 0) { + return NULL; + } + Py_RETURN_NONE; +} + /* Finalize the writer, cache total_samples, and destroy it. * * The cache assignment must happen AFTER binary_writer_finalize(): finalize - * flushes pending RLE records and updates the file header before the writer is - * destroyed. Caching before finalize would preserve a count for a file that + * flushes the open sample block and updates the file header before the writer + * is destroyed. Caching before finalize would preserve a count for a file that * might still fail to finish. */ static int binary_writer_finalize_and_cache(BinaryWriterObject *self) { + if (self->writer->state == BINARY_WRITER_BROKEN) { + PyErr_SetString(PyExc_ValueError, "Writer is broken"); + return -1; + } if (binary_writer_finalize(self->writer) < 0) { + self->writer->state = BINARY_WRITER_BROKEN; return -1; } self->cached_total_samples = self->writer->total_samples; @@ -1871,8 +1945,7 @@ _remote_debugging_BinaryWriter___exit___impl(BinaryWriterObject *self, /*[clinic end generated code: output=61831f47c72a53c6 input=12334ce1009af37f]*/ { if (self->writer) { - /* Only finalize on normal exit (no exception) */ - if (exc_type == Py_None) { + if (self->writer->state != BINARY_WRITER_BROKEN) { if (binary_writer_finalize_and_cache(self) < 0) { if (self->writer) { binary_writer_destroy(self->writer); @@ -1895,13 +1968,13 @@ _remote_debugging.BinaryWriter.get_stats Get encoding statistics for the writer. Returns a dict with encoding statistics including -repeat/full/suffix/pop-push record counts, frames written/saved, and +repeat/full/suffix/reuse record counts, frames written/saved, and compression ratio. [clinic start generated code]*/ static PyObject * _remote_debugging_BinaryWriter_get_stats_impl(BinaryWriterObject *self) -/*[clinic end generated code: output=06522cd52544df89 input=a8bb8c8682ccd34b]*/ +/*[clinic end generated code: output=06522cd52544df89 input=09c317b6289ae311]*/ { if (!self->writer) { PyErr_SetString(PyExc_ValueError, "Writer is closed"); @@ -1921,13 +1994,23 @@ BinaryWriter_get_total_samples(PyObject *op, void *closure) return PyLong_FromUnsignedLongLong(self->writer->total_samples); } +static PyObject * +BinaryWriter_get_limit_reached(PyObject *op, void *closure) +{ + BinaryWriter *writer = BinaryWriter_CAST(op)->writer; + return PyBool_FromLong(writer && writer->state == BINARY_WRITER_LIMIT_REACHED); +} + static PyGetSetDef BinaryWriter_getset[] = { {"total_samples", BinaryWriter_get_total_samples, NULL, "Total samples written", NULL}, + {"limit_reached", BinaryWriter_get_limit_reached, NULL, + "A format limit was reached; the collected samples can still be finalized", NULL}, {NULL} }; static PyMethodDef BinaryWriter_methods[] = { _REMOTE_DEBUGGING_BINARYWRITER_WRITE_SAMPLE_METHODDEF + _REMOTE_DEBUGGING_BINARYWRITER_SET_STATS_METHODDEF _REMOTE_DEBUGGING_BINARYWRITER_FINALIZE_METHODDEF _REMOTE_DEBUGGING_BINARYWRITER_CLOSE_METHODDEF _REMOTE_DEBUGGING_BINARYWRITER___ENTER___METHODDEF @@ -1972,6 +2055,22 @@ static PyType_Spec BinaryWriter_spec = { #define BinaryReader_CAST(op) ((BinaryReaderObject *)(op)) +static int +binary_reader_close_checked(BinaryReaderObject *self) +{ + if (self->reader && self->reader->replaying) { + PyErr_SetString(PyExc_RuntimeError, + "Cannot close or reinitialize the reader " + "while it is replaying"); + return -1; + } + if (self->reader) { + binary_reader_close(self->reader); + self->reader = NULL; + } + return 0; +} + /*[clinic input] class _remote_debugging.BinaryReader "BinaryReaderObject *" "&PyBinaryReader_Type" [clinic start generated code]*/ @@ -1994,10 +2093,9 @@ _remote_debugging_BinaryReader___init___impl(BinaryReaderObject *self, PyObject *filename) /*[clinic end generated code: output=f04b33ee5c5e6dbf input=9d7cbe8b4f1a97c9]*/ { - if (self->reader) { - binary_reader_close(self->reader); + if (binary_reader_close_checked(self) < 0) { + return -1; } - self->reader = binary_reader_open(filename); if (!self->reader) { return -1; @@ -2091,9 +2189,8 @@ static PyObject * _remote_debugging_BinaryReader_close_impl(BinaryReaderObject *self) /*[clinic end generated code: output=ad0238cf5240b4f8 input=b919a66c737712d5]*/ { - if (self->reader) { - binary_reader_close(self->reader); - self->reader = NULL; + if (binary_reader_close_checked(self) < 0) { + return NULL; } Py_RETURN_NONE; } @@ -2128,9 +2225,8 @@ _remote_debugging_BinaryReader___exit___impl(BinaryReaderObject *self, PyObject *exc_tb) /*[clinic end generated code: output=2acdd36cfdc14e4a input=87284243d7935835]*/ { - if (self->reader) { - binary_reader_close(self->reader); - self->reader = NULL; + if (binary_reader_close_checked(self) < 0) { + return NULL; } Py_RETURN_FALSE; } @@ -2226,7 +2322,7 @@ _remote_debugging_zstd_available_impl(PyObject *module) /*[clinic input] _remote_debugging.get_child_pids - pid: int + pid: pid_t Process ID of the parent process * recursive: bool = True @@ -2248,24 +2344,24 @@ list is returned. [clinic start generated code]*/ static PyObject * -_remote_debugging_get_child_pids_impl(PyObject *module, int pid, +_remote_debugging_get_child_pids_impl(PyObject *module, pid_t pid, int recursive) -/*[clinic end generated code: output=1ae2289c6b953e4b input=c6437b52e2fdd880]*/ +/*[clinic end generated code: output=fa3dfd1b02eed29b input=3325d95e9f39d75d]*/ { - return enumerate_child_pids((pid_t)pid, recursive); + return enumerate_child_pids(pid, recursive); } /*[clinic input] _remote_debugging.is_python_process - pid: int + pid: pid_t Check if a process is a Python process. [clinic start generated code]*/ static PyObject * -_remote_debugging_is_python_process_impl(PyObject *module, int pid) -/*[clinic end generated code: output=22947dc8afcac362 input=13488e28c7295d84]*/ +_remote_debugging_is_python_process_impl(PyObject *module, pid_t pid) +/*[clinic end generated code: output=63541478c889e536 input=ff998fef4aeef433]*/ { proc_handle_t handle; @@ -2288,7 +2384,7 @@ _remote_debugging_is_python_process_impl(PyObject *module, int pid) /*[clinic input] _remote_debugging.get_gc_stats - pid: int + pid: pid_t * all_interpreters: bool = False If True, return GC statistics from all interpreters. @@ -2314,9 +2410,9 @@ Get garbage collector statistics from external Python process. [clinic start generated code]*/ static PyObject * -_remote_debugging_get_gc_stats_impl(PyObject *module, int pid, +_remote_debugging_get_gc_stats_impl(PyObject *module, pid_t pid, int all_interpreters) -/*[clinic end generated code: output=d9dce5f7add149bb input=a2a08a45a8f0b119]*/ +/*[clinic end generated code: output=dd33199ccb6a56e9 input=41399e77788aa369]*/ { RuntimeOffsets offsets; if (init_runtime_offsets(&offsets, pid, /*debug=*/1) < 0) { diff --git a/Modules/_remote_debugging/object_reading.c b/Modules/_remote_debugging/object_reading.c index 1cea96a2151fcc6..ed1f07c9143e0fc 100644 --- a/Modules/_remote_debugging/object_reading.c +++ b/Modules/_remote_debugging/object_reading.c @@ -6,6 +6,7 @@ ******************************************************************************/ #include "_remote_debugging.h" +#include "internal/pycore_unicodeobject.h" // _Py_MAX_UNICODE #include /* ============================================================================ @@ -25,7 +26,6 @@ read_##type_name(RemoteUnwinderObject *unwinder, uintptr_t address, c_type *resu } DEFINE_MEMORY_READER(ptr, uintptr_t, "Failed to read pointer from remote memory") -DEFINE_MEMORY_READER(Py_ssize_t, Py_ssize_t, "Failed to read Py_ssize_t from remote memory") DEFINE_MEMORY_READER(char, char, "Failed to read char from remote memory") int @@ -64,12 +64,16 @@ read_py_str( } Py_ssize_t len = GET_MEMBER(Py_ssize_t, unicode_obj, unwinder->debug_offsets.unicode_object.length); - if (len < 0 || len > max_len) { + if (len < 0) { PyErr_Format(PyExc_RuntimeError, "Invalid string length (%zd) at 0x%lx", len, address); set_exception_cause(unwinder, PyExc_RuntimeError, "Invalid string length in remote Unicode object"); return NULL; } + if (len > max_len) { + // gh-157788: a long name must not fail the whole read + len = max_len; + } // Inspect state to pick the right data offset and character width. // We rely on the remote process sharing this Python version's @@ -88,23 +92,15 @@ read_py_str( } int kind = (int)state.kind; - Py_UCS4 max_char; - switch (kind) { - case PyUnicode_1BYTE_KIND: - max_char = state.ascii ? 0x7F : 0xFF; - break; - case PyUnicode_2BYTE_KIND: - max_char = 0xFFFF; - break; - case PyUnicode_4BYTE_KIND: - max_char = 0x10FFFF; - break; - default: - PyErr_Format(PyExc_RuntimeError, - "Invalid Unicode kind %d at 0x%lx", kind, address); - set_exception_cause(unwinder, PyExc_RuntimeError, - "Invalid kind in remote Unicode object"); - return NULL; + if (kind != PyUnicode_1BYTE_KIND + && kind != PyUnicode_2BYTE_KIND + && kind != PyUnicode_4BYTE_KIND) + { + PyErr_Format(PyExc_RuntimeError, + "Invalid Unicode kind %d at 0x%lx", kind, address); + set_exception_cause(unwinder, PyExc_RuntimeError, + "Invalid kind in remote Unicode object"); + return NULL; } size_t header_size = state.ascii @@ -124,16 +120,16 @@ read_py_str( return NULL; } - PyObject *result = PyUnicode_New(len, max_char); - if (result == NULL) { - set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to allocate PyUnicode for remote string"); - return NULL; - } if (nbytes == 0) { - return result; + return Py_GetConstant(Py_CONSTANT_EMPTY_STR); } - void *data = PyUnicode_DATA(result); + char *data = PyMem_Malloc(nbytes); + if (data == NULL) { + PyErr_NoMemory(); + set_exception_cause(unwinder, PyExc_MemoryError, "Failed to allocate buffer for remote string"); + return NULL; + } // Reuse data already present in the header read; only round-trip for // whatever spills past it. @@ -150,14 +146,36 @@ read_py_str( &unwinder->handle, address + header_size + inline_bytes, nbytes - inline_bytes, - (char *)data + inline_bytes); + data + inline_bytes); if (res < 0) { - Py_DECREF(result); + PyMem_Free(data); set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read string data from remote memory"); return NULL; } } + if (kind == PyUnicode_4BYTE_KIND) { + Py_UCS4 *ucs4 = (Py_UCS4 *)data; + for (Py_ssize_t i = 0; i < len; i++) { + Py_UCS4 ch = ucs4[i]; + if (ch > _Py_MAX_UNICODE) { + PyMem_Free(data); + PyErr_Format(PyExc_RuntimeError, + "character U+%x is not in range [U+0000; U+%x]", + ch, _Py_MAX_UNICODE); + set_exception_cause(unwinder, PyExc_RuntimeError, + "Unicode string contains invalid character"); + return NULL; + } + } + } + + PyObject *result = PyUnicode_FromKindAndData(kind, data, len); + PyMem_Free(data); + if (result == NULL) { + set_exception_cause(unwinder, PyExc_RuntimeError, "Invalid character data in remote Unicode object"); + return NULL; + } return result; } @@ -167,9 +185,6 @@ read_py_bytes( uintptr_t address, Py_ssize_t max_len ) { - PyObject *result = NULL; - char *buf = NULL; - // Read the entire PyBytesObject at once char bytes_obj[SIZEOF_BYTES_OBJ]; int res = _Py_RemoteDebug_PagedReadRemoteMemory( @@ -180,7 +195,7 @@ read_py_bytes( ); if (res < 0) { set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read PyBytesObject"); - goto err; + return NULL; } Py_ssize_t len = GET_MEMBER(Py_ssize_t, bytes_obj, unwinder->debug_offsets.bytes_object.ob_size); @@ -191,36 +206,26 @@ read_py_bytes( return NULL; } - buf = (char *)PyMem_RawMalloc(len+1); - if (buf == NULL) { - PyErr_NoMemory(); + PyBytesWriter *writer = PyBytesWriter_Create(len); + if (writer == NULL) { set_exception_cause(unwinder, PyExc_MemoryError, "Failed to allocate buffer for bytes reading"); return NULL; } size_t offset = (size_t)unwinder->debug_offsets.bytes_object.ob_sval; - res = _Py_RemoteDebug_PagedReadRemoteMemory(&unwinder->handle, address + offset, len, buf); + res = _Py_RemoteDebug_PagedReadRemoteMemory(&unwinder->handle, address + offset, + len, PyBytesWriter_GetData(writer)); if (res < 0) { + PyBytesWriter_Discard(writer); set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read bytes data from remote memory"); - goto err; + return NULL; } - buf[len] = '\0'; - result = PyBytes_FromStringAndSize(buf, len); + PyObject *result = PyBytesWriter_Finish(writer); if (result == NULL) { set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to create PyBytes from remote bytes data"); - goto err; } - - PyMem_RawFree(buf); - assert(result != NULL); return result; - -err: - if (buf != NULL) { - PyMem_RawFree(buf); - } - return NULL; } long @@ -261,7 +266,7 @@ read_py_long( } // Calculate how many digits fit inline in our local buffer - Py_ssize_t ob_digit_offset = unwinder->debug_offsets.long_object.ob_digit; + Py_ssize_t ob_digit_offset = (Py_ssize_t)unwinder->debug_offsets.long_object.ob_digit; Py_ssize_t inline_digits_space = SIZEOF_LONG_OBJ - ob_digit_offset; Py_ssize_t max_inline_digits = inline_digits_space / (Py_ssize_t)sizeof(digit); diff --git a/Modules/_remote_debugging/subprocess.c b/Modules/_remote_debugging/subprocess.c index cdad75e318be914..eeb9693cef9222e 100644 --- a/Modules/_remote_debugging/subprocess.c +++ b/Modules/_remote_debugging/subprocess.c @@ -6,6 +6,7 @@ ******************************************************************************/ #include "_remote_debugging.h" +#include "pycore_fileutils.h" // _Py_strerror() #ifndef MS_WINDOWS #include @@ -96,7 +97,7 @@ pid_array_contains(pid_array_t *arr, pid_t pid) /* Find child PIDs using BFS traversal of the pid->ppid mapping. * all_pids and ppids must have the same count (parallel arrays). * Returns 0 on success, -1 on error. */ -static int +UNUSED static int find_children_bfs(pid_t target_pid, int recursive, pid_t *all_pids, pid_t *ppids, size_t pid_count, pid_array_t *result) @@ -229,9 +230,13 @@ get_child_pids_platform(pid_t target_pid, int recursive, pid_array_t *result) if (entry == NULL) { if (errno != 0) { int err = errno; - _set_debug_oserror_from_errno_with_filename(err, "/proc", - "Failed to read process directory '/proc': %s", - strerror(err)); + PyObject *message = _Py_strerror(err); + if (message != NULL) { + _set_debug_oserror_from_errno_with_filename(err, "/proc", + "Failed to read process directory '/proc': %S", + message); + Py_DECREF(message); + } goto done; } break; @@ -259,9 +264,13 @@ get_child_pids_platform(pid_t target_pid, int recursive, pid_array_t *result) if (closedir(proc_dir) != 0) { int err = errno; proc_dir = NULL; - _set_debug_oserror_from_errno_with_filename(err, "/proc", - "Failed to close process directory '/proc': %s", - strerror(err)); + PyObject *message = _Py_strerror(err); + if (message != NULL) { + _set_debug_oserror_from_errno_with_filename(err, "/proc", + "Failed to close process directory '/proc': %S", + message); + Py_DECREF(message); + } goto done; } proc_dir = NULL; @@ -307,6 +316,7 @@ get_child_pids_platform(pid_t target_pid, int recursive, pid_array_t *result) PyErr_SetString(PyExc_OSError, "Failed to get process count"); goto done; } + n_pids /= sizeof(pid_t); /* Allocate buffer for PIDs (add some slack for new processes) */ int buffer_size = n_pids + 64; @@ -322,6 +332,7 @@ get_child_pids_platform(pid_t target_pid, int recursive, pid_array_t *result) PyErr_SetString(PyExc_OSError, "Failed to list PIDs"); goto done; } + actual /= sizeof(pid_t); /* Build pid -> ppid mapping */ ppids = (pid_t *)PyMem_Malloc(actual * sizeof(pid_t)); diff --git a/Modules/_remote_debugging/threads.c b/Modules/_remote_debugging/threads.c index 04c70cc96d6bd1e..66c40d875ab3b31 100644 --- a/Modules/_remote_debugging/threads.c +++ b/Modules/_remote_debugging/threads.c @@ -6,6 +6,7 @@ ******************************************************************************/ #include "_remote_debugging.h" +#include "pycore_fileutils.h" // _Py_strerror() #ifndef MS_WINDOWS #include @@ -17,6 +18,17 @@ #include #endif +#ifdef MS_WINDOWS +enum { + /* ThreadSystemThreadInformation is not named in the Windows SDK. */ + WIN32_THREAD_SYSTEM_INFORMATION = 40, + WIN32_THREAD_RUNNING = 2, +}; +#endif + +/* Bound traversal of corrupted remote exception chains. */ +#define MAX_EXCEPTION_CHAIN_DEPTH (2 << 15) + /* ============================================================================ * THREAD ITERATION FUNCTIONS * ============================================================================ */ @@ -154,45 +166,22 @@ find_running_frame( * THREAD STATUS FUNCTIONS * ============================================================================ */ -int -get_thread_status(RemoteUnwinderObject *unwinder, uint64_t tid, uint64_t pthread_id) { +static int +get_thread_status(RemoteUnwinderObject *unwinder, unsigned long tid) { #if defined(__APPLE__) && TARGET_OS_OSX - if (!unwinder->thread_id_offset_initialized) { - uint64_t *tids = (uint64_t *)PyMem_Malloc(MAX_NATIVE_THREADS * sizeof(uint64_t)); - if (!tids) { - // Non-fatal: thread status is best-effort - return THREAD_STATE_UNKNOWN; - } - int n = proc_pidinfo(unwinder->handle.pid, PROC_PIDLISTTHREADS, 0, tids, MAX_NATIVE_THREADS * sizeof(uint64_t)) / sizeof(uint64_t); - if (n <= 0) { - PyMem_Free(tids); - return THREAD_STATE_UNKNOWN; - } - uint64_t min_offset = UINT64_MAX; - for (int i = 0; i < n; i++) { - uint64_t offset = tids[i] - pthread_id; - if (offset < min_offset) { - min_offset = offset; - } - } - unwinder->thread_id_offset = min_offset; - unwinder->thread_id_offset_initialized = 1; - PyMem_Free(tids); - } - struct proc_threadinfo ti; - uint64_t tid_with_offset = pthread_id + unwinder->thread_id_offset; - if (proc_pidinfo(unwinder->handle.pid, PROC_PIDTHREADINFO, tid_with_offset, &ti, sizeof(ti)) != sizeof(ti)) { + struct proc_threadinfo thread; + int size = proc_pidinfo(unwinder->handle.pid, PROC_PIDTHREADID64INFO, + tid, &thread, sizeof(thread)); + if (size != sizeof(thread)) { return THREAD_STATE_UNKNOWN; } - if (ti.pth_run_state == TH_STATE_RUNNING) { - return THREAD_STATE_RUNNING; - } - return THREAD_STATE_IDLE; + return thread.pth_run_state == TH_STATE_RUNNING + ? THREAD_STATE_RUNNING : THREAD_STATE_IDLE; #elif defined(__linux__) char stat_path[256]; char buffer[2048] = ""; - snprintf(stat_path, sizeof(stat_path), "/proc/%d/task/%" PRIu64 "/stat", unwinder->handle.pid, tid); + snprintf(stat_path, sizeof(stat_path), "/proc/%d/task/%lu/stat", unwinder->handle.pid, tid); int fd = open(stat_path, O_RDONLY); if (fd == -1) { @@ -228,46 +217,24 @@ get_thread_status(RemoteUnwinderObject *unwinder, uint64_t tid, uint64_t pthread return THREAD_STATE_UNKNOWN; } #elif defined(MS_WINDOWS) - ULONG n; - NTSTATUS status = NtQuerySystemInformation( - SystemProcessInformation, - unwinder->win_process_buffer, - unwinder->win_process_buffer_size, - &n - ); - if (status == STATUS_INFO_LENGTH_MISMATCH) { - // Buffer was too small so we reallocate a larger one and try again. - unwinder->win_process_buffer_size = n; - PVOID new_buffer = PyMem_Realloc(unwinder->win_process_buffer, n); - if (!new_buffer) { - // Match Linux/macOS: degrade gracefully on alloc failure - return THREAD_STATE_UNKNOWN; - } - unwinder->win_process_buffer = new_buffer; - return get_thread_status(unwinder, tid, pthread_id); - } - if (status != STATUS_SUCCESS) { + HANDLE thread = OpenThread(THREAD_QUERY_LIMITED_INFORMATION, FALSE, (DWORD)tid); + if (thread == NULL) { return THREAD_STATE_UNKNOWN; } - - SYSTEM_PROCESS_INFORMATION *pi = (SYSTEM_PROCESS_INFORMATION *)unwinder->win_process_buffer; - while ((ULONG)(ULONG_PTR)pi->UniqueProcessId != unwinder->handle.pid) { - if (pi->NextEntryOffset == 0) { - // Process not found (may have exited) - return THREAD_STATE_UNKNOWN; - } - pi = (SYSTEM_PROCESS_INFORMATION *)(((BYTE *)pi) + pi->NextEntryOffset); - } - - SYSTEM_THREAD_INFORMATION *ti = (SYSTEM_THREAD_INFORMATION *)((char *)pi + sizeof(SYSTEM_PROCESS_INFORMATION)); - for (size_t i = 0; i < pi->NumberOfThreads; i++, ti++) { - if (ti->ClientId.UniqueThread == (HANDLE)tid) { - return ti->ThreadState != WIN32_THREADSTATE_RUNNING ? THREAD_STATE_IDLE : THREAD_STATE_RUNNING; - } + SYSTEM_THREAD_INFORMATION info; + ULONG size = 0; + NTSTATUS result = NtQueryInformationThread( + thread, (THREADINFOCLASS)WIN32_THREAD_SYSTEM_INFORMATION, + &info, sizeof(info), &size); + CloseHandle(thread); + if (result != STATUS_SUCCESS || size != sizeof(info) || + (ULONG_PTR)info.ClientId.UniqueProcess != (ULONG_PTR)unwinder->handle.pid || + (ULONG_PTR)info.ClientId.UniqueThread != tid) + { + return THREAD_STATE_UNKNOWN; } - - // Thread not found (may have exited) - return THREAD_STATE_UNKNOWN; + return info.ThreadState == WIN32_THREAD_RUNNING + ? THREAD_STATE_RUNNING : THREAD_STATE_IDLE; #else return THREAD_STATE_UNKNOWN; #endif @@ -394,7 +361,8 @@ unwind_stack_for_thread( STATS_ADD(unwinder, memory_bytes_read, SIZEOF_INTERP_FRAME); } - long tid = GET_MEMBER(long, ts, unwinder->debug_offsets.thread_state.native_thread_id); + unsigned long tid = GET_MEMBER(unsigned long, ts, + unwinder->debug_offsets.thread_state.native_thread_id); // Calculate thread status using flags (always) int status_flags = 0; @@ -436,16 +404,49 @@ unwind_stack_for_thread( has_exception = 1; } - // Check exc_state.exc_value (exception being handled in except block) - // exc_state is embedded in PyThreadState, so we read it directly from - // the thread state buffer. This catches most cases; nested exception - // handlers where exc_info points elsewhere are rare. + // Generators and coroutines use their own exception stack items. + // Follow exc_info to find the innermost handler, as sys.exception() does. if (!has_exception) { - uintptr_t exc_value = GET_MEMBER(uintptr_t, ts, - unwinder->debug_offsets.thread_state.exc_state + - unwinder->debug_offsets.err_stackitem.exc_value); - if (exc_value != 0) { - has_exception = 1; + uintptr_t exc_info = GET_MEMBER(uintptr_t, ts, + unwinder->debug_offsets.thread_state.current_exception + + sizeof(uintptr_t)); + uintptr_t exc_state_addr = + *current_tstate + (uintptr_t)unwinder->debug_offsets.thread_state.exc_state; + uintptr_t exc_value_offset = + (uintptr_t)unwinder->debug_offsets.err_stackitem.exc_value; + uintptr_t previous_item_offset = + exc_value_offset + sizeof(uintptr_t); + + for (int depth = 0; exc_info != 0 && depth < MAX_EXCEPTION_CHAIN_DEPTH; + depth++) + { + if (exc_info == exc_state_addr) { + // Bottom of the chain: the stack item embedded in the thread + // state, which is already in the local thread state buffer. + uintptr_t exc_value = GET_MEMBER(uintptr_t, ts, + unwinder->debug_offsets.thread_state.exc_state + + exc_value_offset); + if (exc_value != 0) { + has_exception = 1; + } + break; + } + uintptr_t exc_value = 0; + if (read_ptr(unwinder, exc_info + exc_value_offset, &exc_value) < 0) { + PyErr_Clear(); // Best effort: treat as no active exception + break; + } + if (exc_value != 0) { + has_exception = 1; + break; + } + uintptr_t previous_item = 0; + if (read_ptr(unwinder, exc_info + previous_item_offset, + &previous_item) < 0) { + PyErr_Clear(); + break; + } + exc_info = previous_item; } } @@ -453,13 +454,9 @@ unwind_stack_for_thread( status_flags |= THREAD_STATUS_HAS_EXCEPTION; } - // Check CPU status - long pthread_id = GET_MEMBER(long, ts, unwinder->debug_offsets.thread_state.thread_id); - - // Optimization: only check CPU status if needed by mode because it's expensive int cpu_status = THREAD_STATE_UNKNOWN; if (unwinder->mode == PROFILING_MODE_CPU || unwinder->mode == PROFILING_MODE_ALL) { - cpu_status = get_thread_status(unwinder, tid, pthread_id); + cpu_status = get_thread_status(unwinder, tid); } if (cpu_status == THREAD_STATE_UNKNOWN) { @@ -560,7 +557,7 @@ unwind_stack_for_thread( } } if (thread_id == NULL) { - thread_id = PyLong_FromLongLong(tid); + thread_id = PyLong_FromUnsignedLong(tid); if (thread_id == NULL) { set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to create thread ID"); goto error; @@ -680,9 +677,13 @@ read_thread_ids(RemoteUnwinderObject *unwinder, _Py_RemoteDebug_ThreadsState *st int err = errno; closedir(dir); _Py_RemoteDebug_InitThreadsState(unwinder, st); - _set_debug_oserror_from_errno_with_filename(err, task_path, - "Failed to read process task directory '%s': %s", - task_path, strerror(err)); + PyObject *message = _Py_strerror(err); + if (message != NULL) { + _set_debug_oserror_from_errno_with_filename(err, task_path, + "Failed to read process task directory '%s': %S", + task_path, message); + Py_DECREF(message); + } return -1; } break; @@ -713,9 +714,13 @@ read_thread_ids(RemoteUnwinderObject *unwinder, _Py_RemoteDebug_ThreadsState *st if (closedir(dir) != 0) { int err = errno; _Py_RemoteDebug_InitThreadsState(unwinder, st); - _set_debug_oserror_from_errno_with_filename(err, task_path, - "Failed to close process task directory '%s': %s", - task_path, strerror(err)); + PyObject *message = _Py_strerror(err); + if (message != NULL) { + _set_debug_oserror_from_errno_with_filename(err, task_path, + "Failed to close process task directory '%s': %S", + task_path, message); + Py_DECREF(message); + } return -1; } st->tids = unwinder->thread_tids; @@ -780,8 +785,12 @@ _Py_RemoteDebug_StopAllThreads(RemoteUnwinderObject *unwinder, _Py_RemoteDebug_T } if (ret < 0) { detach_threads(st, seized); - _set_debug_oserror_from_errno(err, - "Failed to seize thread %d: %s", tid, strerror(err)); + PyObject *message = _Py_strerror(err); + if (message != NULL) { + _set_debug_oserror_from_errno(err, + "Failed to seize thread %d: %S", tid, message); + Py_DECREF(message); + } _Py_RemoteDebug_InitThreadsState(unwinder, st); return -1; } @@ -791,8 +800,12 @@ _Py_RemoteDebug_StopAllThreads(RemoteUnwinderObject *unwinder, _Py_RemoteDebug_T err = errno; if (err != ESRCH) { detach_threads(st, seized); - _set_debug_oserror_from_errno(err, - "Failed to interrupt thread %d: %s", tid, strerror(err)); + PyObject *message = _Py_strerror(err); + if (message != NULL) { + _set_debug_oserror_from_errno(err, + "Failed to interrupt thread %d: %S", tid, message); + Py_DECREF(message); + } _Py_RemoteDebug_InitThreadsState(unwinder, st); return -1; } @@ -803,8 +816,12 @@ _Py_RemoteDebug_StopAllThreads(RemoteUnwinderObject *unwinder, _Py_RemoteDebug_T err = errno; if (err != ECHILD && err != ESRCH) { detach_threads(st, seized); - _set_debug_oserror_from_errno(err, - "waitpid failed for thread %d: %s", tid, strerror(err)); + PyObject *message = _Py_strerror(err); + if (message != NULL) { + _set_debug_oserror_from_errno(err, + "waitpid failed for thread %d: %S", tid, message); + Py_DECREF(message); + } _Py_RemoteDebug_InitThreadsState(unwinder, st); return -1; } @@ -828,6 +845,89 @@ _Py_RemoteDebug_ResumeAllThreads(RemoteUnwinderObject *unwinder, _Py_RemoteDebug #elif defined(MS_WINDOWS) +static int +wait_for_threads_to_stop(RemoteUnwinderObject *unwinder) +{ + typedef NTSTATUS (NTAPI *NtGetNextThreadFunc)( + HANDLE, HANDLE, ACCESS_MASK, ULONG, ULONG, PHANDLE); + static NtGetNextThreadFunc pNtGetNextThread = NULL; + static int tried_load = 0; + + if (!tried_load) { + HMODULE hNtdll = GetModuleHandleW(L"ntdll.dll"); + if (hNtdll) { + pNtGetNextThread = (NtGetNextThreadFunc)GetProcAddress( + hNtdll, "NtGetNextThread"); + } + tried_load = 1; + } + if (pNtGetNextThread == NULL) { + PyErr_SetString(PyExc_RuntimeError, "NtGetNextThread not available"); + return -1; + } + + HANDLE previous = NULL; + int result = -1; + for (;;) { + HANDLE next = NULL; + // Enumerate with the available access, then obtain context access + // separately so threads that deny it are not silently skipped. + NTSTATUS status = pNtGetNextThread(unwinder->handle.hProcess, + previous, MAXIMUM_ALLOWED, 0, 0, &next); + if (previous != NULL) { + CloseHandle(previous); + } + previous = next; + if (status == STATUS_NO_MORE_ENTRIES) { + break; + } + if (status < 0) { + if (!is_process_alive(unwinder->handle.hProcess)) { + PyErr_Format(PyExc_ProcessLookupError, + "Process %d has terminated", unwinder->handle.pid); + } + else { + PyErr_Format(PyExc_RuntimeError, + "NtGetNextThread failed: 0x%lx", status); + } + goto done; + } + HANDLE thread; + if (!DuplicateHandle(GetCurrentProcess(), next, GetCurrentProcess(), + &thread, THREAD_GET_CONTEXT | SYNCHRONIZE, + FALSE, 0)) { + PyErr_SetFromWindowsErr(GetLastError()); + goto done; + } + // Suspension is asynchronous. Reading the context waits for the + // thread to stop before we start reading the target's memory. + CONTEXT context = {.ContextFlags = CONTEXT_CONTROL}; + if (!GetThreadContext(thread, &context)) { + DWORD error = GetLastError(); + int exited = WaitForSingleObject(thread, 0) == WAIT_OBJECT_0; + CloseHandle(thread); + if (exited) { + continue; + } + PyErr_SetFromWindowsErr(error); + goto done; + } + CloseHandle(thread); + } + if (!is_process_alive(unwinder->handle.hProcess)) { + PyErr_Format(PyExc_ProcessLookupError, + "Process %d has terminated", unwinder->handle.pid); + goto done; + } + result = 0; + +done: + if (previous != NULL) { + CloseHandle(previous); + } + return result; +} + void _Py_RemoteDebug_InitThreadsState(RemoteUnwinderObject *unwinder, _Py_RemoteDebug_ThreadsState *st) { @@ -858,6 +958,12 @@ _Py_RemoteDebug_StopAllThreads(RemoteUnwinderObject *unwinder, _Py_RemoteDebug_T if (status >= 0) { st->hProcess = unwinder->handle.hProcess; st->suspended = 1; + if (wait_for_threads_to_stop(unwinder) < 0) { + // pause_threads() has not yet set threads_stopped, so its caller + // will not resume the process when we return an error. + _Py_RemoteDebug_ResumeAllThreads(unwinder, st); + return -1; + } _Py_RemoteDebug_ClearCache(&unwinder->handle); return 0; } diff --git a/Modules/_scproxy.c b/Modules/_scproxy.c index e9170f2ce1ae872..94163197a3a2e3a 100644 --- a/Modules/_scproxy.c +++ b/Modules/_scproxy.c @@ -113,6 +113,7 @@ get_proxy_settings(PyObject* Py_UNUSED(mod), PyObject *Py_UNUSED(ignored)) } else { PyObject* t = cfstring_to_pystring(aString); if (!t) { + if (PyErr_Occurred()) goto error; PyTuple_SetItem(v, i, Py_NewRef(Py_None)); } else { PyTuple_SetItem(v, i, t); @@ -161,6 +162,7 @@ set_proxy(PyObject* proxies, const char* proto, CFDictionaryRef proxyDict, Py_DECREF(v); return r; } + if (PyErr_Occurred()) return -1; } } diff --git a/Modules/_sqlite/blob.c b/Modules/_sqlite/blob.c index d81784409e5d91a..ae318ca19fa0b8a 100644 --- a/Modules/_sqlite/blob.c +++ b/Modules/_sqlite/blob.c @@ -139,26 +139,35 @@ read_single(pysqlite_Blob *self, Py_ssize_t offset) return PyLong_FromUnsignedLong((unsigned long)buf); } -static PyObject * -read_multiple(pysqlite_Blob *self, Py_ssize_t length, Py_ssize_t offset) +static int +inner_read(pysqlite_Blob *self, char *buf, Py_ssize_t length, + Py_ssize_t offset) { assert(length <= sqlite3_blob_bytes(self->blob)); assert(offset < sqlite3_blob_bytes(self->blob)); - PyBytesWriter *writer = PyBytesWriter_Create(length); - if (writer == NULL) { - return NULL; - } - char *raw_buffer = PyBytesWriter_GetData(writer); - int rc; Py_BEGIN_ALLOW_THREADS - rc = sqlite3_blob_read(self->blob, raw_buffer, (int)length, (int)offset); + rc = sqlite3_blob_read(self->blob, buf, (int)length, (int)offset); Py_END_ALLOW_THREADS if (rc != SQLITE_OK) { - PyBytesWriter_Discard(writer); blob_seterror(self, rc); + return -1; + } + return 0; +} + +static PyObject * +read_multiple(pysqlite_Blob *self, Py_ssize_t length, Py_ssize_t offset) +{ + PyBytesWriter *writer = PyBytesWriter_Create(length); + if (writer == NULL) { + return NULL; + } + + if (inner_read(self, PyBytesWriter_GetData(writer), length, offset) < 0) { + PyBytesWriter_Discard(writer); return NULL; } return PyBytesWriter_Finish(writer); @@ -438,14 +447,21 @@ subscript_slice(pysqlite_Blob *self, PyObject *item) } if (len == 0) { - return PyBytes_FromStringAndSize(NULL, 0); + return Py_GetConstant(Py_CONSTANT_EMPTY_BYTES); } if (step == 1) { return read_multiple(self, len, start); } - PyObject *blob = read_multiple(self, stop - start, start); + // Compute the contiguous blob region covering all slice elements, then + // copy each element using the standard size_t-cursor pattern that handles + // both positive and negative steps via unsigned arithmetic. + Py_ssize_t last = start + (len - 1) * step; + Py_ssize_t read_offset = Py_MIN(start, last); + Py_ssize_t read_length = Py_ABS(start - last) + 1; + + PyObject *blob = read_multiple(self, read_length, read_offset); if (blob == NULL) { return NULL; } @@ -456,10 +472,12 @@ subscript_slice(pysqlite_Blob *self, PyObject *item) return NULL; } char *res_buf = PyBytesWriter_GetData(writer); + const char *blob_buf = PyBytes_AS_STRING(blob); - char *blob_buf = PyBytes_AS_STRING(blob); - for (Py_ssize_t i = 0, j = 0; i < len; i++, j += step) { - res_buf[i] = blob_buf[j]; + size_t cur; + Py_ssize_t i; + for (cur = (size_t)start, i = 0; i < len; cur += (size_t)step, i++) { + res_buf[i] = blob_buf[(Py_ssize_t)cur - read_offset]; } Py_DECREF(blob); return PyBytesWriter_Finish(writer); @@ -553,14 +571,31 @@ ass_subscript_slice(pysqlite_Blob *self, PyObject *item, PyObject *value) rc = inner_write(self, vbuf.buf, len, start); } else { - PyObject *blob_bytes = read_multiple(self, stop - start, start); - if (blob_bytes != NULL) { - char *blob_buf = PyBytes_AS_STRING(blob_bytes); - for (Py_ssize_t i = 0, j = 0; i < len; i++, j += step) { - blob_buf[j] = ((char *)vbuf.buf)[i]; + /* Compute the contiguous blob region covering all slice elements, + read it, patch each element and write it back. The object + returned by read_multiple() cannot be used as the buffer, because + for a single byte it is an immortal singleton. */ + Py_ssize_t last = start + (len - 1) * step; + Py_ssize_t write_offset = Py_MIN(start, last); + Py_ssize_t write_length = Py_ABS(start - last) + 1; + char *buf = PyMem_Malloc(write_length); + if (buf == NULL) { + PyErr_NoMemory(); + } + else { + if (inner_read(self, buf, write_length, write_offset) == 0) { + /* The size_t cursor handles both positive and negative steps + via unsigned arithmetic. */ + size_t cur; + Py_ssize_t i; + for (cur = (size_t)start, i = 0; i < len; + cur += (size_t)step, i++) { + buf[(Py_ssize_t)cur - write_offset] = + ((char *)vbuf.buf)[i]; + } + rc = inner_write(self, buf, write_length, write_offset); } - rc = inner_write(self, blob_buf, stop - start, start); - Py_DECREF(blob_bytes); + PyMem_Free(buf); } } PyBuffer_Release(&vbuf); diff --git a/Modules/_sqlite/clinic/_sqlite3.connect.c.h b/Modules/_sqlite/clinic/_sqlite3.connect.c.h index e9d560666c14913..ce8c795ed2d5a02 100644 --- a/Modules/_sqlite/clinic/_sqlite3.connect.c.h +++ b/Modules/_sqlite/clinic/_sqlite3.connect.c.h @@ -7,6 +7,7 @@ preserve # include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(pysqlite_connect__doc__, "connect($module, /, database, *, timeout=5.0, detect_types=0,\n" @@ -22,4 +23,4 @@ PyDoc_STRVAR(pysqlite_connect__doc__, #define PYSQLITE_CONNECT_METHODDEF \ {"connect", _PyCFunction_CAST(pysqlite_connect), METH_FASTCALL|METH_KEYWORDS, pysqlite_connect__doc__}, -/*[clinic end generated code: output=3d83139ba65e0bb5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=07d5692e22b0fdf2 input=a9049054013a1b77]*/ diff --git a/Modules/_sqlite/clinic/connection.c.h b/Modules/_sqlite/clinic/connection.c.h index b645bf3464bcea1..69ef85e4ee5408f 100644 --- a/Modules/_sqlite/clinic/connection.c.h +++ b/Modules/_sqlite/clinic/connection.c.h @@ -7,6 +7,7 @@ preserve # include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() static int pysqlite_connection_init_impl(pysqlite_Connection *self, PyObject *database, @@ -280,28 +281,18 @@ blobopen(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwna _PyArg_BadArgument("blobopen", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t table_length; - table = PyUnicode_AsUTF8AndSize(args[0], &table_length); + table = _PyUnicode_AsUTF8NoNUL(args[0]); if (table == NULL) { goto exit; } - if (strlen(table) != (size_t)table_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!PyUnicode_Check(args[1])) { _PyArg_BadArgument("blobopen", "argument 2", "str", args[1]); goto exit; } - Py_ssize_t col_length; - col = PyUnicode_AsUTF8AndSize(args[1], &col_length); + col = _PyUnicode_AsUTF8NoNUL(args[1]); if (col == NULL) { goto exit; } - if (strlen(col) != (size_t)col_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!sqlite3_int64_converter(args[2], &row)) { goto exit; } @@ -321,15 +312,10 @@ blobopen(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwna _PyArg_BadArgument("blobopen", "argument 'name'", "str", args[4]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(args[4], &name_length); + name = _PyUnicode_AsUTF8NoNUL(args[4]); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } skip_optional_kwonly: return_value = blobopen_impl((pysqlite_Connection *)self, table, col, row, readonly, name); @@ -459,15 +445,10 @@ pysqlite_connection_create_function(PyObject *self, PyTypeObject *cls, PyObject _PyArg_BadArgument("create_function", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(args[0], &name_length); + name = _PyUnicode_AsUTF8NoNUL(args[0]); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } narg = PyLong_AsInt(args[1]); if (narg == -1 && PyErr_Occurred()) { goto exit; @@ -516,42 +497,24 @@ static PyObject * create_window_function(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "create_window_function", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[3]; const char *name; int num_params; PyObject *aggregate_class; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("create_window_function", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("create_window_function", nargs, 3, 3)) { goto exit; } if (!PyUnicode_Check(args[0])) { _PyArg_BadArgument("create_window_function", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(args[0], &name_length); + name = _PyUnicode_AsUTF8NoNUL(args[0]); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } num_params = PyLong_AsInt(args[1]); if (num_params == -1 && PyErr_Occurred()) { goto exit; @@ -584,42 +547,24 @@ static PyObject * pysqlite_connection_create_aggregate(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "create_aggregate", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[3]; const char *name; int n_arg; PyObject *aggregate_class; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("create_aggregate", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("create_aggregate", nargs, 3, 3)) { goto exit; } if (!PyUnicode_Check(args[0])) { _PyArg_BadArgument("create_aggregate", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(args[0], &name_length); + name = _PyUnicode_AsUTF8NoNUL(args[0]); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } n_arg = PyLong_AsInt(args[1]); if (n_arg == -1 && PyErr_Occurred()) { goto exit; @@ -649,25 +594,12 @@ static PyObject * pysqlite_connection_set_authorizer(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "set_authorizer", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *callable; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("set_authorizer", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("set_authorizer", nargs, 1, 1)) { goto exit; } callable = args[0]; @@ -771,25 +703,12 @@ static PyObject * pysqlite_connection_set_trace_callback(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "set_trace_callback", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *callable; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("set_trace_callback", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("set_trace_callback", nargs, 1, 1)) { goto exit; } callable = args[0]; @@ -893,15 +812,10 @@ pysqlite_connection_load_extension(PyObject *self, PyObject *const *args, Py_ssi _PyArg_BadArgument("load_extension", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t extension_name_length; - extension_name = PyUnicode_AsUTF8AndSize(args[0], &extension_name_length); + extension_name = _PyUnicode_AsUTF8NoNUL(args[0]); if (extension_name == NULL) { goto exit; } - if (strlen(extension_name) != (size_t)extension_name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!noptargs) { goto skip_optional_kwonly; } @@ -909,15 +823,10 @@ pysqlite_connection_load_extension(PyObject *self, PyObject *const *args, Py_ssi entrypoint = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t entrypoint_length; - entrypoint = PyUnicode_AsUTF8AndSize(args[1], &entrypoint_length); + entrypoint = _PyUnicode_AsUTF8NoNUL(args[1]); if (entrypoint == NULL) { goto exit; } - if (strlen(entrypoint) != (size_t)entrypoint_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("load_extension", "argument 'entrypoint'", "str or None", args[1]); @@ -933,7 +842,7 @@ pysqlite_connection_load_extension(PyObject *self, PyObject *const *args, Py_ssi #endif /* defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) */ PyDoc_STRVAR(pysqlite_connection_execute__doc__, -"execute($self, sql, parameters=, /)\n" +"execute($self, sql, parameters=(), /)\n" "--\n" "\n" "Executes an SQL statement."); @@ -1202,15 +1111,10 @@ pysqlite_connection_backup(PyObject *self, PyObject *const *args, Py_ssize_t nar _PyArg_BadArgument("backup", "argument 'name'", "str", args[3]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(args[3], &name_length); + name = _PyUnicode_AsUTF8NoNUL(args[3]); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_kwonly; } @@ -1251,41 +1155,23 @@ static PyObject * pysqlite_connection_create_collation(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "create_collation", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; const char *name; PyObject *callable; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("create_collation", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("create_collation", nargs, 2, 2)) { goto exit; } if (!PyUnicode_Check(args[0])) { _PyArg_BadArgument("create_collation", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(args[0], &name_length); + name = _PyUnicode_AsUTF8NoNUL(args[0]); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } callable = args[1]; return_value = pysqlite_connection_create_collation_impl((pysqlite_Connection *)self, cls, name, callable); @@ -1362,15 +1248,10 @@ serialize(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwn _PyArg_BadArgument("serialize", "argument 'name'", "str", args[0]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(args[0], &name_length); + name = _PyUnicode_AsUTF8NoNUL(args[0]); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } skip_optional_kwonly: return_value = serialize_impl((pysqlite_Connection *)self, name); @@ -1471,15 +1352,10 @@ deserialize(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *k _PyArg_BadArgument("deserialize", "argument 'name'", "str", args[1]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(args[1], &name_length); + name = _PyUnicode_AsUTF8NoNUL(args[1]); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } skip_optional_kwonly: return_value = deserialize_impl((pysqlite_Connection *)self, &data, name); @@ -1725,4 +1601,4 @@ getconfig(PyObject *self, PyObject *arg) #ifndef DESERIALIZE_METHODDEF #define DESERIALIZE_METHODDEF #endif /* !defined(DESERIALIZE_METHODDEF) */ -/*[clinic end generated code: output=1418b72751ef68fc input=a9049054013a1b77]*/ +/*[clinic end generated code: output=faee86c7feaa0937 input=a9049054013a1b77]*/ diff --git a/Modules/_sqlite/clinic/cursor.c.h b/Modules/_sqlite/clinic/cursor.c.h index 3cad9f3aef5ecd5..45780bd63530073 100644 --- a/Modules/_sqlite/clinic/cursor.c.h +++ b/Modules/_sqlite/clinic/cursor.c.h @@ -8,6 +8,7 @@ preserve #endif #include "pycore_long.h" // _PyLong_UInt32_Converter() #include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() static int pysqlite_cursor_init_impl(pysqlite_Cursor *self, @@ -136,15 +137,10 @@ pysqlite_cursor_executescript(PyObject *self, PyObject *arg) _PyArg_BadArgument("executescript", "argument", "str", arg); goto exit; } - Py_ssize_t sql_script_length; - sql_script = PyUnicode_AsUTF8AndSize(arg, &sql_script_length); + sql_script = _PyUnicode_AsUTF8NoNUL(arg); if (sql_script == NULL) { goto exit; } - if (strlen(sql_script) != (size_t)sql_script_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = pysqlite_cursor_executescript_impl((pysqlite_Cursor *)self, sql_script); exit: @@ -330,16 +326,6 @@ pysqlite_cursor_close(PyObject *self, PyObject *Py_UNUSED(ignored)) return pysqlite_cursor_close_impl((pysqlite_Cursor *)self); } -#if !defined(_sqlite3_Cursor_arraysize_DOCSTR) -# define _sqlite3_Cursor_arraysize_DOCSTR NULL -#endif -#if defined(_SQLITE3_CURSOR_ARRAYSIZE_GETSETDEF) -# undef _SQLITE3_CURSOR_ARRAYSIZE_GETSETDEF -# define _SQLITE3_CURSOR_ARRAYSIZE_GETSETDEF {"arraysize", (getter)_sqlite3_Cursor_arraysize_get, (setter)_sqlite3_Cursor_arraysize_set, _sqlite3_Cursor_arraysize_DOCSTR}, -#else -# define _SQLITE3_CURSOR_ARRAYSIZE_GETSETDEF {"arraysize", (getter)_sqlite3_Cursor_arraysize_get, NULL, _sqlite3_Cursor_arraysize_DOCSTR}, -#endif - static PyObject * _sqlite3_Cursor_arraysize_get_impl(pysqlite_Cursor *self); @@ -349,26 +335,29 @@ _sqlite3_Cursor_arraysize_get(PyObject *self, void *Py_UNUSED(context)) return _sqlite3_Cursor_arraysize_get_impl((pysqlite_Cursor *)self); } -#if !defined(_sqlite3_Cursor_arraysize_DOCSTR) -# define _sqlite3_Cursor_arraysize_DOCSTR NULL -#endif -#if defined(_SQLITE3_CURSOR_ARRAYSIZE_GETSETDEF) -# undef _SQLITE3_CURSOR_ARRAYSIZE_GETSETDEF -# define _SQLITE3_CURSOR_ARRAYSIZE_GETSETDEF {"arraysize", (getter)_sqlite3_Cursor_arraysize_get, (setter)_sqlite3_Cursor_arraysize_set, _sqlite3_Cursor_arraysize_DOCSTR}, -#else -# define _SQLITE3_CURSOR_ARRAYSIZE_GETSETDEF {"arraysize", NULL, (setter)_sqlite3_Cursor_arraysize_set, NULL}, -#endif - static int -_sqlite3_Cursor_arraysize_set_impl(pysqlite_Cursor *self, PyObject *value); +_sqlite3_Cursor_arraysize_set_impl(pysqlite_Cursor *self, uint32_t value); static int -_sqlite3_Cursor_arraysize_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_sqlite3_Cursor_arraysize_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + uint32_t value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'arraysize' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + if (!_PyLong_UInt32_Converter(arg, &value)) { + goto exit; + } return_value = _sqlite3_Cursor_arraysize_set_impl((pysqlite_Cursor *)self, value); +exit: return return_value; } -/*[clinic end generated code: output=a0e3ebba9e4d0ece input=a9049054013a1b77]*/ +#define _SQLITE3_CURSOR_ARRAYSIZE_GETSETDEF {"arraysize", (getter)_sqlite3_Cursor_arraysize_get, (setter)_sqlite3_Cursor_arraysize_set, NULL}, + +/*[clinic end generated code: output=c24b4d93900ed908 input=a9049054013a1b77]*/ diff --git a/Modules/_sqlite/clinic/module.c.h b/Modules/_sqlite/clinic/module.c.h index 82ecd3eea1b39b4..79d1043cd729df7 100644 --- a/Modules/_sqlite/clinic/module.c.h +++ b/Modules/_sqlite/clinic/module.c.h @@ -7,6 +7,7 @@ preserve # include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(pysqlite_complete_statement__doc__, "complete_statement($module, /, statement)\n" @@ -63,15 +64,10 @@ pysqlite_complete_statement(PyObject *module, PyObject *const *args, Py_ssize_t _PyArg_BadArgument("complete_statement", "argument 'statement'", "str", args[0]); goto exit; } - Py_ssize_t statement_length; - statement = PyUnicode_AsUTF8AndSize(args[0], &statement_length); + statement = _PyUnicode_AsUTF8NoNUL(args[0]); if (statement == NULL) { goto exit; } - if (strlen(statement) != (size_t)statement_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = pysqlite_complete_statement_impl(module, statement); exit: @@ -211,4 +207,4 @@ pysqlite_adapt(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=17c4e031680a5168 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=02aee45b7f9f14f0 input=a9049054013a1b77]*/ diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 892740b05e55c98..f8bd3a8df35b668 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -104,11 +104,16 @@ autocommit_converter(PyObject *val, enum autocommit_mode *result) *result = AUTOCOMMIT_DISABLED; return 1; } - if (PyLong_Check(val) && - PyLong_AsLong(val) == LEGACY_TRANSACTION_CONTROL) - { - *result = AUTOCOMMIT_LEGACY; - return 1; + if (PyLong_Check(val)) { + int overflow; + long value = PyLong_AsLongAndOverflow(val, &overflow); + if (value == -1 && PyErr_Occurred()) { + return 0; + } + if (!overflow && value == LEGACY_TRANSACTION_CONTROL) { + *result = AUTOCOMMIT_LEGACY; + return 1; + } } PyErr_SetString(PyExc_ValueError, @@ -300,8 +305,9 @@ pysqlite_connection_init_impl(pysqlite_Connection *self, PyObject *database, self->thread_ident = PyThread_get_thread_ident(); self->statement_cache = statement_cache; self->blobs = blobs; - self->row_factory = Py_NewRef(Py_None); - self->text_factory = Py_NewRef(&PyUnicode_Type); + pysqlite_set_ref((PyObject *)self, &self->row_factory, Py_NewRef(Py_None)); + pysqlite_set_ref((PyObject *)self, &self->text_factory, + Py_NewRef(&PyUnicode_Type)); self->trace_ctx = NULL; self->progress_ctx = NULL; self->authorizer_ctx = NULL; @@ -406,8 +412,8 @@ connection_clear(PyObject *op) pysqlite_Connection *self = _pysqlite_Connection_CAST(op); Py_CLEAR(self->statement_cache); Py_CLEAR(self->blobs); - Py_CLEAR(self->row_factory); - Py_CLEAR(self->text_factory); + pysqlite_set_ref(op, &self->row_factory, NULL); + pysqlite_set_ref(op, &self->text_factory, NULL); clear_callback_context(self->trace_ctx); clear_callback_context(self->progress_ctx); clear_callback_context(self->authorizer_ctx); @@ -549,9 +555,14 @@ pysqlite_connection_cursor_impl(pysqlite_Connection *self, PyObject *factory) return NULL; } - if (cursor && self->row_factory != Py_None) { - Py_INCREF(self->row_factory); - Py_XSETREF(((pysqlite_Cursor *)cursor)->row_factory, self->row_factory); + PyObject *row_factory = pysqlite_get_ref((PyObject *)self, + &self->row_factory, Py_None); + if (row_factory != Py_None) { + pysqlite_Cursor *cur = (pysqlite_Cursor *)cursor; + pysqlite_set_ref(cursor, &cur->row_factory, row_factory); + } + else { + Py_DECREF(row_factory); } return cursor; @@ -561,7 +572,7 @@ static PyObject * connection_get_row_factory(PyObject *op, void *closure) { pysqlite_Connection *self = (pysqlite_Connection *)op; - return Py_NewRef(self->row_factory); + return pysqlite_get_ref(op, &self->row_factory, Py_None); } static int @@ -573,7 +584,7 @@ connection_set_row_factory(PyObject *op, PyObject *value, void *closure) "cannot delete row_factory attribute"); return -1; } - Py_XSETREF(self->row_factory, Py_NewRef(value)); + pysqlite_set_ref(op, &self->row_factory, Py_NewRef(value)); return 0; } @@ -581,7 +592,8 @@ static PyObject * connection_get_text_factory(PyObject *op, void *closure) { pysqlite_Connection *self = (pysqlite_Connection *)op; - return Py_NewRef(self->text_factory); + return pysqlite_get_ref(op, &self->text_factory, + (PyObject *)&PyUnicode_Type); } static int @@ -593,7 +605,7 @@ connection_set_text_factory(PyObject *op, PyObject *value, void *closure) "cannot delete text_factory attribute"); return -1; } - Py_XSETREF(self->text_factory, Py_NewRef(value)); + pysqlite_set_ref(op, &self->text_factory, Py_NewRef(value)); return 0; } @@ -1872,7 +1884,7 @@ pysqlite_connection_call(PyObject *op, PyObject *args, PyObject *kwargs) _sqlite3.Connection.execute as pysqlite_connection_execute sql: unicode - parameters: object = NULL + parameters: object(c_default = 'NULL') = () / Executes an SQL statement. @@ -1881,7 +1893,7 @@ Executes an SQL statement. static PyObject * pysqlite_connection_execute_impl(pysqlite_Connection *self, PyObject *sql, PyObject *parameters) -/*[clinic end generated code: output=5be05ae01ee17ee4 input=27aa7792681ddba2]*/ +/*[clinic end generated code: output=5be05ae01ee17ee4 input=847390a17de45cc7]*/ { PyObject* result = 0; @@ -2621,6 +2633,11 @@ static int set_autocommit(PyObject *op, PyObject *val, void *Py_UNUSED(closure)) { pysqlite_Connection *self = _pysqlite_Connection_CAST(op); + if (val == NULL) { + PyErr_SetString(PyExc_AttributeError, + "cannot delete autocommit attribute"); + return -1; + } if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) { return -1; } diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 5a61e43617984d9..ad8c434c1b2fb8f 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -121,18 +121,15 @@ pysqlite_cursor_init_impl(pysqlite_Cursor *self, Py_CLEAR(self->statement); Py_CLEAR(self->row_cast_map); - Py_INCREF(Py_None); - Py_XSETREF(self->description, Py_None); + pysqlite_set_ref((PyObject *)self, &self->description, Py_NewRef(Py_None)); - Py_INCREF(Py_None); - Py_XSETREF(self->lastrowid, Py_None); + pysqlite_set_ref((PyObject *)self, &self->lastrowid, Py_NewRef(Py_None)); self->arraysize = 1; self->closed = 0; self->rowcount = -1L; - Py_INCREF(Py_None); - Py_XSETREF(self->row_factory, Py_None); + pysqlite_set_ref((PyObject *)self, &self->row_factory, Py_NewRef(Py_None)); if (!pysqlite_check_thread(self->connection)) { return -1; @@ -176,10 +173,10 @@ cursor_clear(PyObject *op) { pysqlite_Cursor *self = _pysqlite_Cursor_CAST(op); Py_CLEAR(self->connection); - Py_CLEAR(self->description); + pysqlite_set_ref(op, &self->description, NULL); Py_CLEAR(self->row_cast_map); - Py_CLEAR(self->lastrowid); - Py_CLEAR(self->row_factory); + pysqlite_set_ref(op, &self->lastrowid, NULL); + pysqlite_set_ref(op, &self->row_factory, NULL); if (self->statement) { /* Reset the statement if the user has not closed the cursor */ int rc = stmt_reset(self->statement); @@ -223,8 +220,11 @@ _pysqlite_get_converter(pysqlite_state *state, const char *keystr, return NULL; } - retval = PyDict_GetItemWithError(state->converters, upcase_key); + int rc = PyDict_GetItemRef(state->converters, upcase_key, &retval); Py_DECREF(upcase_key); + if (rc < 0) { + return NULL; + } return retval; } @@ -296,11 +296,10 @@ pysqlite_build_row_cast_map(pysqlite_Cursor* self) } } - if (!converter) { - converter = Py_None; - } - - if (PyList_Append(self->row_cast_map, converter) != 0) { + int rc = PyList_Append(self->row_cast_map, + converter ? converter : Py_None); + Py_XDECREF(converter); + if (rc != 0) { Py_CLEAR(self->row_cast_map); return -1; } @@ -413,12 +412,17 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self) } nbytes = sqlite3_column_bytes(self->statement->st, i); - if (self->connection->text_factory == (PyObject*)&PyUnicode_Type) { + PyObject *factory = pysqlite_get_ref( + (PyObject *)self->connection, + &self->connection->text_factory, + (PyObject *)&PyUnicode_Type); + if (factory == (PyObject*)&PyUnicode_Type) { converted = PyUnicode_FromStringAndSize(text, nbytes); if (!converted && PyErr_ExceptionMatches(PyExc_UnicodeDecodeError)) { PyErr_Clear(); colname = sqlite3_column_name(self->statement->st, i); if (colname == NULL) { + Py_DECREF(factory); PyErr_NoMemory(); goto error; } @@ -434,13 +438,14 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self) Py_DECREF(error_msg); } } - } else if (self->connection->text_factory == (PyObject*)&PyBytes_Type) { + } else if (factory == (PyObject*)&PyBytes_Type) { converted = PyBytes_FromStringAndSize(text, nbytes); - } else if (self->connection->text_factory == (PyObject*)&PyByteArray_Type) { + } else if (factory == (PyObject*)&PyByteArray_Type) { converted = PyByteArray_FromStringAndSize(text, nbytes); } else { - converted = PyObject_CallFunction(self->connection->text_factory, "y#", text, nbytes); + converted = PyObject_CallFunction(factory, "y#", text, nbytes); } + Py_DECREF(factory); } else { /* coltype == SQLITE_BLOB */ const void *blob = sqlite3_column_blob(self->statement->st, i); @@ -699,8 +704,7 @@ bind_parameters(pysqlite_state *state, pysqlite_Statement *self, PyObject *item = PyTuple_GET_ITEM(parameters, i); current_param = Py_NewRef(item); } else if (PyList_CheckExact(parameters)) { - PyObject *item = PyList_GetItem(parameters, i); - current_param = Py_XNewRef(item); + current_param = PyList_GetItemRef(parameters, i); } else { current_param = PySequence_GetItem(parameters, i); } @@ -796,6 +800,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation PyObject* parameters_list = NULL; PyObject* parameters_iter = NULL; PyObject* parameters = NULL; + PyObject* description = NULL; int i; int rc; int numcols; @@ -845,8 +850,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation } /* reset description */ - Py_INCREF(Py_None); - Py_SETREF(self->description, Py_None); + pysqlite_set_ref((PyObject *)self, &self->description, Py_NewRef(Py_None)); if (self->statement) { // Reset pending statements on this cursor. @@ -930,8 +934,8 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation numcols = sqlite3_column_count(self->statement->st); Py_END_ALLOW_THREADS if (self->description == Py_None && numcols > 0) { - Py_SETREF(self->description, PyTuple_New(numcols)); - if (!self->description) { + description = PyTuple_New(numcols); + if (description == NULL) { goto error; } for (i = 0; i < numcols; i++) { @@ -952,8 +956,10 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation if (descriptor == NULL) { goto error; } - PyTuple_SET_ITEM(self->description, i, descriptor); + PyTuple_SET_ITEM(description, i, descriptor); } + pysqlite_set_ref((PyObject *)self, &self->description, description); + description = NULL; } if (rc == SQLITE_DONE) { @@ -974,11 +980,15 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation lastrowid = sqlite3_last_insert_rowid(self->connection->db); Py_END_ALLOW_THREADS - Py_SETREF(self->lastrowid, PyLong_FromLongLong(lastrowid)); - // Fall through on error. + PyObject *lastrowid_obj = PyLong_FromLongLong(lastrowid); + if (lastrowid_obj == NULL) { + goto error; + } + pysqlite_set_ref((PyObject *)self, &self->lastrowid, lastrowid_obj); } error: + Py_XDECREF(description); Py_XDECREF(parameters); Py_XDECREF(parameters_iter); Py_XDECREF(parameters_list); @@ -1176,12 +1186,13 @@ pysqlite_cursor_iternext(PyObject *op) } return NULL; } - if (!Py_IsNone(self->row_factory)) { - PyObject *factory = self->row_factory; + PyObject *factory = pysqlite_get_ref(op, &self->row_factory, Py_None); + if (!Py_IsNone(factory)) { PyObject *args[] = { op, row, }; PyObject *new_row = PyObject_Vectorcall(factory, args, 2, NULL); Py_SETREF(row, new_row); } + Py_DECREF(factory); return row; reset_failure: @@ -1372,13 +1383,15 @@ _sqlite3_Cursor_arraysize_get_impl(pysqlite_Cursor *self) /*[clinic input] @setter _sqlite3.Cursor.arraysize + value: uint32 [clinic start generated code]*/ static int -_sqlite3_Cursor_arraysize_set_impl(pysqlite_Cursor *self, PyObject *value) -/*[clinic end generated code: output=af59a6b09f8cce6e input=ace48cb114e26060]*/ +_sqlite3_Cursor_arraysize_set_impl(pysqlite_Cursor *self, uint32_t value) +/*[clinic end generated code: output=465c2db6df904802 input=80234ca4ec5cfb7c]*/ { - return PyLong_AsUInt32(value, &self->arraysize); + self->arraysize = value; + return 0; } static PyMethodDef cursor_methods[] = { @@ -1400,13 +1413,33 @@ static struct PyMemberDef cursor_members[] = {"description", _Py_T_OBJECT, offsetof(pysqlite_Cursor, description), Py_READONLY}, {"lastrowid", _Py_T_OBJECT, offsetof(pysqlite_Cursor, lastrowid), Py_READONLY}, {"rowcount", Py_T_LONG, offsetof(pysqlite_Cursor, rowcount), Py_READONLY}, - {"row_factory", _Py_T_OBJECT, offsetof(pysqlite_Cursor, row_factory), 0}, {"__weaklistoffset__", Py_T_PYSSIZET, offsetof(pysqlite_Cursor, in_weakreflist), Py_READONLY}, {NULL} }; +static PyObject * +cursor_get_row_factory(PyObject *op, void *Py_UNUSED(closure)) +{ + pysqlite_Cursor *self = _pysqlite_Cursor_CAST(op); + return pysqlite_get_ref(op, &self->row_factory, Py_None); +} + +static int +cursor_set_row_factory(PyObject *op, PyObject *value, void *Py_UNUSED(closure)) +{ + pysqlite_Cursor *self = _pysqlite_Cursor_CAST(op); + if (value == NULL) { + PyErr_SetString(PyExc_AttributeError, + "cannot delete row_factory attribute"); + return -1; + } + pysqlite_set_ref(op, &self->row_factory, Py_NewRef(value)); + return 0; +} + static struct PyGetSetDef cursor_getsets[] = { _SQLITE3_CURSOR_ARRAYSIZE_GETSETDEF + {"row_factory", cursor_get_row_factory, cursor_set_row_factory}, {NULL}, }; diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c index 512d9744d57416e..5eebacaa79d4e60 100644 --- a/Modules/_sqlite/module.c +++ b/Modules/_sqlite/module.c @@ -439,6 +439,87 @@ add_keyword_tuple(PyObject *module) #endif } +PyDoc_STRVAR(sqlite_version_info__doc__, +"_sqlite3.sqlite_version_info\n\ +\n\ +SQLite version information as a named tuple."); + +static PyStructSequence_Field sqlite_version_info_fields[] = { + {"major", "Major release number"}, + {"minor", "Minor release number"}, + {"patch", "Patch release number"}, + {0} +}; + +static PyStructSequence_Desc sqlite_version_info_desc = { + "_sqlite3.sqlite_version_info", /* name */ + sqlite_version_info__doc__, /* doc */ + sqlite_version_info_fields, /* fields */ + 3 +}; + +static PyObject * +make_sqlite_version_info(PyTypeObject *type, int number) +{ + PyObject *version; + int pos = 0; + int major = number / 1000000; + int minor = (number % 1000000) / 1000; + int patch = number % 1000; + + version = PyStructSequence_New(type); + if (version == NULL) { + return NULL; + } + +#define SetItem(VALUE) \ + PyStructSequence_SET_ITEM(version, pos++, VALUE); \ + if (PyErr_Occurred()) { \ + Py_DECREF(version); \ + return NULL; \ + } + + SetItem(PyLong_FromLong(major)) + SetItem(PyLong_FromLong(minor)) + SetItem(PyLong_FromLong(patch)) +#undef SetItem + + return version; +} + +static int +add_version_constants(PyObject *module) +{ + if (PyModule_AddStringMacro(module, SQLITE_VERSION) < 0) { + return -1; + } + if (PyModule_AddStringConstant(module, "sqlite_version", + sqlite3_libversion()) < 0) + { + return -1; + } + PyTypeObject *version_type; + version_type = PyStructSequence_NewType(&sqlite_version_info_desc); + if (version_type == NULL) { + return -1; + } + if (PyModule_Add(module, "SQLITE_VERSION_INFO", + make_sqlite_version_info(version_type, SQLITE_VERSION_NUMBER)) < 0) + { + Py_DECREF(version_type); + return -1; + } + if (PyModule_Add(module, "sqlite_version_info", + make_sqlite_version_info(version_type, + sqlite3_libversion_number())) < 0) + { + Py_DECREF(version_type); + return -1; + } + Py_DECREF(version_type); + return 0; +} + static int add_integer_constants(PyObject *module) { #define ADD_INT(ival) \ @@ -741,7 +822,7 @@ module_exec(PyObject *module) goto error; } - if (PyModule_AddStringConstant(module, "sqlite_version", sqlite3_libversion())) { + if (add_version_constants(module) < 0) { goto error; } diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c index 8646f591ef5169f..7e39db9d6bcd4ee 100644 --- a/Modules/_sqlite/row.c +++ b/Modules/_sqlite/row.c @@ -27,6 +27,7 @@ #include "row.h" #include "cursor.h" +#include "util.h" #define clinic_state() (pysqlite_get_state_by_type(type)) #include "clinic/row.c.h" @@ -93,7 +94,8 @@ pysqlite_row_new_impl(PyTypeObject *type, pysqlite_Cursor *cursor, return NULL; self->data = Py_NewRef(data); - self->description = Py_NewRef(cursor->description); + self->description = pysqlite_get_ref((PyObject *)cursor, + &cursor->description, Py_None); return (PyObject *) self; } diff --git a/Modules/_sqlite/util.h b/Modules/_sqlite/util.h index c00369496f99687..d53aedd66b615fb 100644 --- a/Modules/_sqlite/util.h +++ b/Modules/_sqlite/util.h @@ -24,6 +24,7 @@ #ifndef PYSQLITE_UTIL_H #define PYSQLITE_UTIL_H #include "Python.h" +#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_STORE_PTR_RELEASE() #include "pythread.h" #include "sqlite3.h" #include "connection.h" @@ -36,4 +37,28 @@ void set_error_from_code(pysqlite_state *state, int code); sqlite_int64 _pysqlite_long_as_int64(PyObject * value); +/* Take a strong reference while the owning object's lock is held. */ +static inline PyObject * +pysqlite_get_ref(PyObject *owner, PyObject *const *field, PyObject *fallback) +{ + PyObject *value; + Py_BEGIN_CRITICAL_SECTION(owner); + value = Py_NewRef(*field != NULL ? *field : fallback); + Py_END_CRITICAL_SECTION(); + return value; +} + +/* Steal value. Use the same store as PyMember_SetOne() since a readonly + * member descriptor may load the field without taking the object's lock. */ +static inline void +pysqlite_set_ref(PyObject *owner, PyObject **field, PyObject *value) +{ + PyObject *old; + Py_BEGIN_CRITICAL_SECTION(owner); + old = *field; + FT_ATOMIC_STORE_PTR_RELEASE(*field, value); + Py_END_CRITICAL_SECTION(); + Py_XDECREF(old); +} + #endif diff --git a/Modules/_sre/clinic/sre.c.h b/Modules/_sre/clinic/sre.c.h index b49bf4e058b69b6..9e6c91d09f59a41 100644 --- a/Modules/_sre/clinic/sre.c.h +++ b/Modules/_sre/clinic/sre.c.h @@ -1247,6 +1247,35 @@ _sre_SRE_Match_expand(PyObject *self, PyObject *const *args, Py_ssize_t nargs, P return return_value; } +PyDoc_STRVAR(_sre_SRE_Match_group__doc__, +"group($self, /, *args)\n" +"--\n" +"\n" +"Return subgroup(s) of the match by indices or names.\n" +"\n" +"For 0 returns the entire match."); + +#define _SRE_SRE_MATCH_GROUP_METHODDEF \ + {"group", _PyCFunction_CAST(_sre_SRE_Match_group), METH_FASTCALL, _sre_SRE_Match_group__doc__}, + +static PyObject * +_sre_SRE_Match_group_impl(MatchObject *self, PyObject * const *args, + Py_ssize_t args_length); + +static PyObject * +_sre_SRE_Match_group(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject * const *__clinic_args; + Py_ssize_t args_length; + + __clinic_args = args; + args_length = nargs; + return_value = _sre_SRE_Match_group_impl((MatchObject *)self, __clinic_args, args_length); + + return return_value; +} + PyDoc_STRVAR(_sre_SRE_Match_groups__doc__, "groups($self, /, default=None)\n" "--\n" @@ -1568,4 +1597,4 @@ _sre_SRE_Scanner_search(PyObject *self, PyTypeObject *cls, PyObject *const *args #ifndef _SRE_SRE_PATTERN__FAIL_AFTER_METHODDEF #define _SRE_SRE_PATTERN__FAIL_AFTER_METHODDEF #endif /* !defined(_SRE_SRE_PATTERN__FAIL_AFTER_METHODDEF) */ -/*[clinic end generated code: output=0c867efb64e020aa input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2e6c222a2eb0875e input=a9049054013a1b77]*/ diff --git a/Modules/_sre/sre.c b/Modules/_sre/sre.c index e742a25e4891fce..588d48e84cb629c 100644 --- a/Modules/_sre/sre.c +++ b/Modules/_sre/sre.c @@ -899,6 +899,10 @@ pattern_dealloc(PyObject *self) LOCAL(Py_ssize_t) sre_match(SRE_STATE* state, SRE_CODE* pattern) { + /* No match if pos > endpos. */ + if (state->ptr > state->end) { + return 0; + } if (state->charsize == 1) return sre_ucs1_match(state, pattern, 1); if (state->charsize == 2) @@ -1273,8 +1277,7 @@ _sre_SRE_Pattern_split_impl(PatternObject *self, PyObject *string, ); if (!item) goto error; - status = PyList_Append(list, item); - Py_DECREF(item); + status = _PyList_AppendTakeRef((PyListObject *)list, item); if (status < 0) goto error; @@ -1283,8 +1286,7 @@ _sre_SRE_Pattern_split_impl(PatternObject *self, PyObject *string, item = state_getslice(&state, i+1, string, 0); if (!item) goto error; - status = PyList_Append(list, item); - Py_DECREF(item); + status = _PyList_AppendTakeRef((PyListObject *)list, item); if (status < 0) goto error; } @@ -1301,8 +1303,7 @@ _sre_SRE_Pattern_split_impl(PatternObject *self, PyObject *string, ); if (!item) goto error; - status = PyList_Append(list, item); - Py_DECREF(item); + status = _PyList_AppendTakeRef((PyListObject *)list, item); if (status < 0) goto error; @@ -2613,31 +2614,38 @@ _sre_SRE_Match_expand_impl(MatchObject *self, PyObject *template) return result; } -static PyObject* -match_group(PyObject *op, PyObject* args) +/*[clinic input] +_sre.SRE_Match.group + + *args: array + +Return subgroup(s) of the match by indices or names. + +For 0 returns the entire match. +[clinic start generated code]*/ + +static PyObject * +_sre_SRE_Match_group_impl(MatchObject *self, PyObject * const *args, + Py_ssize_t args_length) +/*[clinic end generated code: output=240cddd2cf62ee2a input=f6d9bfa0d01f3cda]*/ { - MatchObject *self = _MatchObject_CAST(op); PyObject* result; - Py_ssize_t i, size; - - size = PyTuple_GET_SIZE(args); + Py_ssize_t i; - switch (size) { + switch (args_length) { case 0: result = match_getslice(self, _PyLong_GetZero(), Py_None); break; case 1: - result = match_getslice(self, PyTuple_GET_ITEM(args, 0), Py_None); + result = match_getslice(self, args[0], Py_None); break; default: /* fetch multiple items */ - result = PyTuple_New(size); + result = PyTuple_New(args_length); if (!result) return NULL; - for (i = 0; i < size; i++) { - PyObject* item = match_getslice( - self, PyTuple_GET_ITEM(args, i), Py_None - ); + for (i = 0; i < args_length; i++) { + PyObject* item = match_getslice(self, args[i], Py_None); if (!item) { Py_DECREF(result); return NULL; @@ -2879,11 +2887,6 @@ PyDoc_STRVAR(match_doc, "The result of re.search(), re.prefixmatch(), and re.fullmatch().\n\ Match objects always have a boolean value of True."); -PyDoc_STRVAR(match_group_doc, -"group([group1, ...]) -> str or tuple.\n\ - Return subgroup(s) of the match by indices or names.\n\ - For 0 returns the entire match."); - static PyObject * match_lastindex_get(PyObject *op, void *Py_UNUSED(ignored)) { @@ -3020,6 +3023,8 @@ scanner_traverse(PyObject *op, visitproc visit, void *arg) ScannerObject *self = _ScannerObject_CAST(op); Py_VISIT(Py_TYPE(self)); Py_VISIT(self->pattern); + Py_VISIT(self->state.string); + Py_VISIT(self->state.buffer.obj); return 0; } @@ -3027,7 +3032,10 @@ static int scanner_clear(PyObject *op) { ScannerObject *self = _ScannerObject_CAST(op); + self->state.start = NULL; Py_CLEAR(self->pattern); + Py_CLEAR(self->state.string); + PyBuffer_Release(&self->state.buffer); return 0; } @@ -3037,8 +3045,8 @@ scanner_dealloc(PyObject *self) PyTypeObject *tp = Py_TYPE(self); PyObject_GC_UnTrack(self); ScannerObject *scanner = _ScannerObject_CAST(self); - state_fini(&scanner->state); (void)scanner_clear(self); + state_fini(&scanner->state); tp->tp_free(self); Py_DECREF(tp); } @@ -3439,7 +3447,7 @@ static PyType_Spec pattern_spec = { }; static PyMethodDef match_methods[] = { - {"group", match_group, METH_VARARGS, match_group_doc}, + _SRE_SRE_MATCH_GROUP_METHODDEF _SRE_SRE_MATCH_START_METHODDEF _SRE_SRE_MATCH_END_METHODDEF _SRE_SRE_MATCH_SPAN_METHODDEF diff --git a/Modules/_sre/sre_lib.h b/Modules/_sre/sre_lib.h index 444cd39d2fed288..fbdbaefb399193d 100644 --- a/Modules/_sre/sre_lib.h +++ b/Modules/_sre/sre_lib.h @@ -175,16 +175,71 @@ SRE(charset)(SRE_STATE* state, const SRE_CODE* set, SRE_CODE ch) } } +/* Like SRE(charset), but matches both locale cases of ch against every set + member. Testing the whole set once per case would complement it before + closing it under case instead of after, so that [^bc] matched b'B'. + BIGCHARSET and RANGE_UNI_IGNORE are not handled: they never occur in a + set of a bytes pattern. */ LOCAL(int) SRE(charset_loc_ignore)(SRE_STATE* state, const SRE_CODE* set, SRE_CODE ch) { SRE_CODE lo, up; - lo = sre_lower_locale(ch); - if (SRE(charset)(state, set, lo)) - return 1; + int ok = 1; + lo = sre_lower_locale(ch); up = sre_upper_locale(ch); - return up != lo && SRE(charset)(state, set, up); + if (up == lo) + return SRE(charset)(state, set, lo); + + for (;;) { + switch (*set++) { + + case SRE_OP_FAILURE: + return !ok; + + case SRE_OP_LITERAL: + /* */ + if (lo == set[0] || up == set[0]) + return ok; + set++; + break; + + case SRE_OP_CATEGORY: + /* */ + if (sre_category(set[0], (int) lo) || + sre_category(set[0], (int) up)) + return ok; + set++; + break; + + case SRE_OP_CHARSET: + /* */ + if ((lo < 256 && (set[lo/SRE_CODE_BITS] + & (1u << (lo & (SRE_CODE_BITS-1))))) || + (up < 256 && (set[up/SRE_CODE_BITS] + & (1u << (up & (SRE_CODE_BITS-1)))))) + return ok; + set += 256/SRE_CODE_BITS; + break; + + case SRE_OP_RANGE: + /* */ + if ((set[0] <= lo && lo <= set[1]) || + (set[0] <= up && up <= set[1])) + return ok; + set += 2; + break; + + case SRE_OP_NEGATE: + ok = !ok; + break; + + default: + /* internal error -- there's not much we can do about it + here, so let's just pretend it didn't match... */ + return 0; + } + } } LOCAL(Py_ssize_t) SRE(match)(SRE_STATE* state, const SRE_CODE* pattern, int toplevel); diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 20564e1ba4165a6..2e4c67b4058bc3e 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -41,6 +41,7 @@ #endif #include "_ssl.h" +#include "_openssl_mem.h" /* Redefined below for Windows debug builds after important #includes */ #define _PySSL_FIX_ERRNO @@ -66,6 +67,7 @@ /* Include OpenSSL header files */ #include "openssl/rsa.h" #include "openssl/crypto.h" +#include "openssl/evp.h" #include "openssl/x509.h" #include "openssl/x509v3.h" #include "openssl/pem.h" @@ -75,38 +77,15 @@ #include "openssl/bio.h" #include "openssl/dh.h" -#ifndef OPENSSL_THREADS -# error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL" +#if OPENSSL_VERSION_NUMBER >= 0x40000000L && !defined(OPENSSL_NO_ECH) +# define HAVE_OPENSSL_ECH 1 +# include "openssl/ech.h" #endif - -#ifdef BIO_get_ktls_send -# ifdef MS_WINDOWS -typedef long long Py_off_t; -# else -typedef off_t Py_off_t; -# endif - -static int -Py_off_t_converter(PyObject *arg, void *addr) -{ -#ifdef HAVE_LARGEFILE_SUPPORT - *((Py_off_t *)addr) = PyLong_AsLongLong(arg); -#else - *((Py_off_t *)addr) = PyLong_AsLong(arg); +#ifndef OPENSSL_THREADS +# error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL" #endif - return PyErr_Occurred() ? 0 : 1; -} -/*[python input] - -class Py_off_t_converter(CConverter): - type = 'Py_off_t' - converter = 'Py_off_t_converter' - -[python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=3fd9ca8ca6f0cbb8]*/ -#endif /* BIO_get_ktls_send */ struct py_ssl_error_code { const char *mnemonic; @@ -169,10 +148,9 @@ static void _PySSLFixErrno(void) { #endif #if (OPENSSL_VERSION_NUMBER >= 0x40000000L) +/* OpenSSL 4.0 removed SSLv3 and the version-specific methods, + * but TLS 1.0, 1.1 and 1.2 are still available via TLS_method(). */ # define OPENSSL_NO_SSL3 -# define OPENSSL_NO_TLS1 -# define OPENSSL_NO_TLS1_1 -# define OPENSSL_NO_TLS1_2 # define OPENSSL_NO_SSL3_METHOD # define OPENSSL_NO_TLS1_METHOD # define OPENSSL_NO_TLS1_1_METHOD @@ -339,6 +317,10 @@ typedef struct { SSL_CTX *ctx; unsigned char *alpn_protocols; unsigned int alpn_protocols_len; +#ifdef HAVE_OPENSSL_ECH + unsigned char *outer_alpn_protocols; + unsigned int outer_alpn_protocols_len; +#endif PyObject *set_sni_cb; int check_hostname; int protocol; @@ -478,6 +460,9 @@ PyDoc_STRVAR(SSLWantWriteError_doc, PyDoc_STRVAR(SSLSyscallError_doc, "System error when attempting SSL operation."); +PyDoc_STRVAR(SSLECHRejectedError_doc, +"SSL/TLS handshake failed because the server rejected Encrypted Client Hello."); + PyDoc_STRVAR(SSLEOFError_doc, "SSL/TLS connection terminated abruptly."); @@ -512,6 +497,7 @@ fill_and_set_sslerror(_sslmodulestate *state, { PyObject *err_value = NULL, *reason_obj = NULL, *lib_obj = NULL; PyObject *verify_obj = NULL, *verify_code_obj = NULL; + PyObject *retry_obj = NULL; PyObject *init_value, *msg, *key; PyUnicodeWriter *writer = NULL; @@ -656,11 +642,32 @@ fill_and_set_sslerror(_sslmodulestate *state, goto fail; } +#ifdef HAVE_OPENSSL_ECH + if ((sslsock != NULL) && (type == state->PySSLECHRejectedErrorObject)) { + unsigned char *config = NULL; + size_t config_len = 0; + + /* OpenSSL only releases retry configurations once the outer + * handshake has authenticated the server; otherwise report none. */ + if (SSL_ech_get1_retry_config(sslsock->ssl, &config, &config_len) != 1) { + config = NULL; + config_len = 0; + } + retry_obj = PyBytes_FromStringAndSize((const char *)config, config_len); + OPENSSL_free(config); + if (retry_obj == NULL) + goto fail; + if (PyObject_SetAttr(err_value, state->str_retry_config, retry_obj)) + goto fail; + } +#endif + PyErr_SetObject(type, err_value); fail: Py_XDECREF(err_value); Py_XDECREF(verify_code_obj); Py_XDECREF(verify_obj); + Py_XDECREF(retry_obj); PyUnicodeWriter_Discard(writer); } @@ -765,6 +772,12 @@ PySSL_SetError(PySSLSocket *sslsock, _PySSLError err, PyObject *exc, ERR_GET_REASON(e) == SSL_R_CERTIFICATE_VERIFY_FAILED) { type = state->PySSLCertVerificationErrorObject; } +#ifdef HAVE_OPENSSL_ECH + if (ERR_GET_LIB(e) == ERR_LIB_SSL && + ERR_GET_REASON(e) == SSL_R_ECH_REQUIRED) { + type = state->PySSLECHRejectedErrorObject; + } +#endif #if defined(SSL_R_UNEXPECTED_EOF_WHILE_READING) /* OpenSSL 3.0 changed transport EOF from SSL_ERROR_SYSCALL with * zero return value to SSL_ERROR_SSL with a special error code. */ @@ -964,6 +977,23 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock, return NULL; } +#ifdef HAVE_OPENSSL_ECH + if (socket_type == PY_SSL_CLIENT) { + char *inner_sni = NULL, *outer_sni = NULL; + int status = SSL_ech_get1_status(self->ssl, &inner_sni, &outer_sni); + OPENSSL_free(inner_sni); + OPENSSL_free(outer_sni); + /* OpenSSL also applies outer ALPN to ordinary and GREASE handshakes. */ + if ((status == SSL_ECH_STATUS_NOT_CONFIGURED + || status == SSL_ECH_STATUS_GREASE) + && SSL_ech_set1_outer_alpn_protos(self->ssl, NULL, 0) != 1) { + _setSSLError(get_state_ctx(sslctx), NULL, 0, __FILE__, __LINE__); + Py_DECREF(self); + return NULL; + } + } +#endif + if (socket_type == PY_SSL_SERVER) { #define SID_CTX "Python" /* Set the session id context (server-side only) */ @@ -1003,7 +1033,9 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock, int mode = SSL_get_verify_mode(self->ssl); if (mode & SSL_VERIFY_PEER) { mode |= SSL_VERIFY_POST_HANDSHAKE; - SSL_set_verify(self->ssl, mode, NULL); + /* Keep ctx verify callback (distrusted SPKI check) */ + SSL_set_verify(self->ssl, mode, + SSL_get_verify_callback(self->ssl)); } } else { /* client socket */ @@ -1576,6 +1608,7 @@ _get_peer_alt_names (_sslmodulestate *state, X509 *certificate) { fail: + sk_GENERAL_NAME_pop_free(names, GENERAL_NAME_free); if (biobuf != NULL) BIO_free(biobuf); @@ -2017,31 +2050,37 @@ _ssl__SSLSocket_get_unverified_chain_impl(PySSLSocket *self) /*[clinic end generated code: output=5acdae414e13f913 input=079f8ff5c205cb3b]*/ { PyObject *retval; + X509 *peer = NULL; /* borrowed reference */ - /* TODO: include SSL_get_peer_certificate() for server-side sockets */ STACK_OF(X509) *chain = SSL_get_peer_cert_chain(self->ssl); - if (chain == NULL) { + /* OpenSSL does not include the peer cert in the chain for server side + * connections, so the chain alone does not tell whether the client sent + * a certificate: the chain is empty when it did not, and NULL when the + * session was resumed from a ticket (which stores the peer cert only). */ + if (self->socket_type == PY_SSL_SERVER) { + peer = SSL_get_peer_certificate(self->ssl); + if (peer == NULL) { + Py_RETURN_NONE; + } + } + else if (chain == NULL) { Py_RETURN_NONE; } - retval = _PySSL_CertificateFromX509Stack(self->ctx->state, chain, 1); + retval = chain == NULL + ? PyList_New(0) + : _PySSL_CertificateFromX509Stack(self->ctx->state, chain, 1); if (retval == NULL) { + X509_free(peer); return NULL; } - /* OpenSSL does not include peer cert for server side connections */ - if (self->socket_type == PY_SSL_SERVER) { - PyObject *peerobj = NULL; - X509 *peer = SSL_get_peer_certificate(self->ssl); - - if (peer == NULL) { - peerobj = Py_NewRef(Py_None); - } else { - /* consume X509 reference on success */ - peerobj = _PySSL_CertificateFromX509(self->ctx->state, peer, 0); - if (peerobj == NULL) { - X509_free(peer); - Py_DECREF(retval); - return NULL; - } + if (peer != NULL) { + /* consume X509 reference on success */ + PyObject *peerobj = _PySSL_CertificateFromX509(self->ctx->state, + peer, 0); + if (peerobj == NULL) { + X509_free(peer); + Py_DECREF(retval); + return NULL; } int res = PyList_Insert(retval, 0, peerobj); Py_DECREF(peerobj); @@ -2143,6 +2182,112 @@ cipher_to_dict(const SSL_CIPHER *cipher) ); } +#ifdef HAVE_OPENSSL_ECH +/*[clinic input] +@critical_section +_ssl._SSLSocket.get_ech_status +[clinic start generated code]*/ + +static PyObject * +_ssl__SSLSocket_get_ech_status_impl(PySSLSocket *self) +/*[clinic end generated code: output=263bf7fc7888e2d6 input=71320052d6f2a10f]*/ +{ + char *inner_sni = NULL, *outer_sni = NULL; + if (self->ssl == NULL) { + Py_RETURN_NONE; + } + int status = SSL_ech_get1_status(self->ssl, &inner_sni, &outer_sni); + PyObject *result = Py_BuildValue("(izz)", status, inner_sni, outer_sni); + OPENSSL_free(inner_sni); + OPENSSL_free(outer_sni); + return result; +} + +/*[clinic input] +@critical_section +_ssl._SSLSocket.get_ech_retry_config +[clinic start generated code]*/ + +static PyObject * +_ssl__SSLSocket_get_ech_retry_config_impl(PySSLSocket *self) +/*[clinic end generated code: output=967da2032df9a37a input=0e51b545e93f43ba]*/ +{ + if (self->ssl == NULL) { + Py_RETURN_NONE; + } + unsigned char *config = NULL; + size_t config_len = 0; + if (SSL_ech_get1_retry_config(self->ssl, &config, &config_len) != 1) { + // OpenSSL does not release unauthenticated retry configurations. + ERR_clear_error(); + config_len = 0; + } + PyObject *result = PyBytes_FromStringAndSize((char *)config, config_len); + OPENSSL_free(config); + return result; +} + +static OSSL_ECHSTORE *ech_store_from_config(_sslmodulestate *state, + Py_buffer *ech_config); + +/*[clinic input] +@critical_section +_ssl._SSLSocket.set_ech_config + + ech_config: Py_buffer + / + +Set the ECH configuration for this connection. + +This replaces any configuration inherited from the context and +must be called before the handshake starts. +[clinic start generated code]*/ + +static PyObject * +_ssl__SSLSocket_set_ech_config_impl(PySSLSocket *self, Py_buffer *ech_config) +/*[clinic end generated code: output=c9d2639cc222eae9 input=c331e306213d39d9]*/ +{ + if (self->socket_type != PY_SSL_CLIENT) { + PyErr_SetString(PyExc_ValueError, + "Cannot set ECH configuration for server-side SSLSocket."); + return NULL; + } + if (!SSL_in_before(self->ssl)) { + PyErr_SetString(PyExc_ValueError, + "Cannot set ECH configuration after handshake."); + return NULL; + } + _sslmodulestate *state = get_state_sock(self); + OSSL_ECHSTORE *store = ech_store_from_config(state, ech_config); + if (store == NULL) { + return NULL; + } + int result = SSL_set1_echstore(self->ssl, store); + OSSL_ECHSTORE_free(store); + if (result != 1) { + _setSSLError(state, NULL, 0, __FILE__, __LINE__); + return NULL; + } + /* Restore the outer ALPN cleared when this socket was created without + * an ECH configuration. */ + PySSLContext *ctx = (PySSLContext *)Py_NewRef(self->ctx); + Py_BEGIN_CRITICAL_SECTION2(self, ctx); + if (ctx->outer_alpn_protocols != NULL) { + result = SSL_ech_set1_outer_alpn_protos(self->ssl, + ctx->outer_alpn_protocols, + ctx->outer_alpn_protocols_len); + } + Py_END_CRITICAL_SECTION2(); + Py_DECREF(ctx); + if (result != 1) { + _setSSLError(state, NULL, 0, __FILE__, __LINE__); + return NULL; + } + Py_RETURN_NONE; +} + +#endif /* HAVE_OPENSSL_ECH */ + /*[clinic input] @critical_section _ssl._SSLSocket.shared_ciphers @@ -2224,7 +2369,9 @@ _ssl__SSLSocket_group_impl(PySSLSocket *self) #if OPENSSL_VERSION_NUMBER >= 0x30200000L const char *group_name; - if (self->ssl == NULL) { + // OpenSSL issue: SSL_get0_group_name(...) crashes if no session exists. + // See https://github.com/openssl/openssl/issues/32379. + if (self->ssl == NULL || SSL_get_session(self->ssl) == NULL) { Py_RETURN_NONE; } group_name = SSL_get0_group_name(self->ssl); @@ -3368,6 +3515,9 @@ static PyMethodDef PySSLMethods[] = { _SSL__SSLSOCKET_COMPRESSION_METHODDEF _SSL__SSLSOCKET_SHUTDOWN_METHODDEF _SSL__SSLSOCKET_VERIFY_CLIENT_POST_HANDSHAKE_METHODDEF + _SSL__SSLSOCKET_GET_ECH_STATUS_METHODDEF + _SSL__SSLSOCKET_SET_ECH_CONFIG_METHODDEF + _SSL__SSLSOCKET_GET_ECH_RETRY_CONFIG_METHODDEF _SSL__SSLSOCKET_GET_UNVERIFIED_CHAIN_METHODDEF _SSL__SSLSOCKET_GET_VERIFIED_CHAIN_METHODDEF {NULL, NULL} @@ -3393,6 +3543,66 @@ static PyType_Spec PySSLSocket_spec = { * _SSLContext objects */ +#include "_ssl/distrusted_spki.h" + +/* Returns 1 if the SHA-256 of the cert's SPKI is on the distrusted list, + 0 if not (okay), -1 on an internal error. */ +static int +_cert_has_distrusted_spki(X509 *cert) +{ + unsigned char *spki = NULL; + int spki_len = i2d_X509_PUBKEY(X509_get_X509_PUBKEY(cert), &spki); + if (spki_len <= 0 || spki == NULL) { + return -1; + } + + unsigned char digest[EVP_MAX_MD_SIZE]; + unsigned int digest_len = 0; + int ok = EVP_Digest(spki, (size_t)spki_len, digest, &digest_len, + EVP_sha256(), NULL); + OPENSSL_free(spki); + assert(sizeof(_distrusted_spki[0]) == SHA256_DIGEST_LENGTH); + if (!ok + || digest_len != SHA256_DIGEST_LENGTH + || sizeof(_distrusted_spki[0]) != SHA256_DIGEST_LENGTH) { + return -1; + } + + for (size_t i = 0; i < Py_ARRAY_LENGTH(_distrusted_spki); i++) { + if (memcmp(digest, _distrusted_spki[i], SHA256_DIGEST_LENGTH) == 0) { + return 1; + } + } + return 0; +} + +/* Verify callback, called once per cert. Reject distrusted SPKIs. */ +static int +_ssl_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx) +{ + /* Don't override an error OpenSSL already reported for this certificate. */ + if (!preverify_ok) { + return preverify_ok; + } + X509 *cert = X509_STORE_CTX_get_current_cert(x509_ctx); + if (cert == NULL) { + return preverify_ok; + } + switch (_cert_has_distrusted_spki(cert)) { + case 0: + /* okay: not on the distrusted list */ + return preverify_ok; + case 1: + /* rejected: public key is on the distrusted list */ + X509_STORE_CTX_set_error(x509_ctx, X509_V_ERR_CERT_REJECTED); + return 0; + default: + /* internal error */ + X509_STORE_CTX_set_error(x509_ctx, X509_V_ERR_UNSPECIFIED); + return 0; + } +} + static int _set_verify_mode(PySSLContext *self, enum py_ssl_cert_requirements n) { @@ -3417,7 +3627,7 @@ _set_verify_mode(PySSLContext *self, enum py_ssl_cert_requirements n) /* bpo-37428: newPySSLSocket() sets SSL_VERIFY_POST_HANDSHAKE flag for * server sockets and SSL_set_post_handshake_auth() for client. */ - SSL_CTX_set_verify(self->ctx, mode, NULL); + SSL_CTX_set_verify(self->ctx, mode, _ssl_verify_callback); return 0; } @@ -3527,6 +3737,10 @@ _ssl__SSLContext_impl(PyTypeObject *type, int proto_version) self->keylog_filename = NULL; self->keylog_bio = NULL; self->alpn_protocols = NULL; +#ifdef HAVE_OPENSSL_ECH + self->outer_alpn_protocols = NULL; + self->outer_alpn_protocols_len = 0; +#endif self->set_sni_cb = NULL; self->state = get_ssl_state(module); #ifndef OPENSSL_NO_PSK @@ -3674,8 +3888,14 @@ context_dealloc(PyObject *op) /* bpo-31095: UnTrack is needed before calling any callbacks */ PyObject_GC_UnTrack(self); (void)context_clear(op); + /* The SSL_CTX may outlive this object as the session_ctx of sockets that + were switched to another context; leave no Python callback behind. */ + SSL_CTX_set_tlsext_servername_callback(self->ctx, NULL); SSL_CTX_free(self->ctx); PyMem_FREE(self->alpn_protocols); +#ifdef HAVE_OPENSSL_ECH + PyMem_Free(self->outer_alpn_protocols); +#endif tp->tp_free(self); Py_DECREF(tp); } @@ -3863,6 +4083,10 @@ _ssl__SSLContext_set_client_sigalgs_impl(PySSLContext *self, #ifdef OPENSSL_IS_AWSLC _setSSLError(get_state_ctx(self), "can't set client sigalgs on AWS-LC", 0, __FILE__, __LINE__); return NULL; +#elif defined(LIBRESSL_VERSION_NUMBER) + PyErr_SetString(PyExc_NotImplementedError, + "setting client sigalgs is not supported by LibreSSL"); + return NULL; #else if (!SSL_CTX_set1_client_sigalgs_list(self->ctx, sigalgslist)) { _setSSLError(get_state_ctx(self), "unrecognized signature algorithm", 0, __FILE__, __LINE__); @@ -3884,11 +4108,17 @@ _ssl__SSLContext_set_server_sigalgs_impl(PySSLContext *self, const char *sigalgslist) /*[clinic end generated code: output=31ecb1d310285644 input=653b752e4f8d801b]*/ { +#ifdef LIBRESSL_VERSION_NUMBER + PyErr_SetString(PyExc_NotImplementedError, + "setting server sigalgs is not supported by LibreSSL"); + return NULL; +#else if (!SSL_CTX_set1_sigalgs_list(self->ctx, sigalgslist)) { _setSSLError(get_state_ctx(self), "unrecognized signature algorithm", 0, __FILE__, __LINE__); return NULL; } Py_RETURN_NONE; +#endif } static int @@ -3960,15 +4190,54 @@ _ssl__SSLContext__set_alpn_protocols_impl(PySSLContext *self, Py_RETURN_NONE; } +#ifdef HAVE_OPENSSL_ECH /*[clinic input] @critical_section -@getter -_ssl._SSLContext.verify_mode +_ssl._SSLContext._set_outer_alpn_protocols + protos: Py_buffer + / [clinic start generated code]*/ static PyObject * +_ssl__SSLContext__set_outer_alpn_protocols_impl(PySSLContext *self, + Py_buffer *protos) +/*[clinic end generated code: output=823aea95e8dea835 input=b6ddf7d0791afd0e]*/ +{ + if ((size_t)protos->len > UINT_MAX) { + PyErr_Format(PyExc_OverflowError, + "protocols longer than %u bytes", UINT_MAX); + return NULL; + } + PyMem_Free(self->outer_alpn_protocols); + self->outer_alpn_protocols = NULL; + self->outer_alpn_protocols_len = 0; + if (protos->len) { + self->outer_alpn_protocols = PyMem_Malloc(protos->len); + if (!self->outer_alpn_protocols) { + return PyErr_NoMemory(); + } + memcpy(self->outer_alpn_protocols, protos->buf, protos->len); + self->outer_alpn_protocols_len = (unsigned int)protos->len; + } + if (SSL_CTX_ech_set1_outer_alpn_protos(self->ctx, + self->outer_alpn_protocols, + self->outer_alpn_protocols_len) != 1) { + _setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__); + return NULL; + } + Py_RETURN_NONE; +} +#endif /* HAVE_OPENSSL_ECH */ + +/*[clinic input] +@critical_section +@getter +_ssl._SSLContext.verify_mode -> int +[clinic start generated code]*/ + +static int _ssl__SSLContext_verify_mode_get_impl(PySSLContext *self) -/*[clinic end generated code: output=3e788736cc7229bc input=7e3c7f4454121d0a]*/ +/*[clinic end generated code: output=f588c0dc5c0bc414 input=9f74370037133ac3]*/ { /* ignore SSL_VERIFY_CLIENT_ONCE and SSL_VERIFY_POST_HANDSHAKE */ int mask = (SSL_VERIFY_NONE | SSL_VERIFY_PEER | @@ -3976,72 +4245,69 @@ _ssl__SSLContext_verify_mode_get_impl(PySSLContext *self) int verify_mode = SSL_CTX_get_verify_mode(self->ctx); switch (verify_mode & mask) { case SSL_VERIFY_NONE: - return PyLong_FromLong(PY_SSL_CERT_NONE); + return PY_SSL_CERT_NONE; case SSL_VERIFY_PEER: - return PyLong_FromLong(PY_SSL_CERT_OPTIONAL); + return PY_SSL_CERT_OPTIONAL; case SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT: - return PyLong_FromLong(PY_SSL_CERT_REQUIRED); + return PY_SSL_CERT_REQUIRED; } PyErr_SetString(get_state_ctx(self)->PySSLErrorObject, "invalid return value from SSL_CTX_get_verify_mode"); - return NULL; + return -1; } /*[clinic input] @critical_section @setter _ssl._SSLContext.verify_mode + value: int [clinic start generated code]*/ static int -_ssl__SSLContext_verify_mode_set_impl(PySSLContext *self, PyObject *value) -/*[clinic end generated code: output=d698e16c58db3118 input=3ee60057c3a22378]*/ +_ssl__SSLContext_verify_mode_set_impl(PySSLContext *self, int value) +/*[clinic end generated code: output=5ca6ec88aa4faed0 input=cb53415e79047735]*/ { - int n; - if (!PyArg_Parse(value, "i", &n)) - return -1; - if (n == PY_SSL_CERT_NONE && self->check_hostname) { + if (value == PY_SSL_CERT_NONE && self->check_hostname) { PyErr_SetString(PyExc_ValueError, "Cannot set verify_mode to CERT_NONE when " "check_hostname is enabled."); return -1; } - return _set_verify_mode(self, n); + return _set_verify_mode(self, value); } /*[clinic input] @critical_section @getter -_ssl._SSLContext.verify_flags +_ssl._SSLContext.verify_flags -> unsigned_long [clinic start generated code]*/ -static PyObject * +static unsigned long _ssl__SSLContext_verify_flags_get_impl(PySSLContext *self) -/*[clinic end generated code: output=fbbf8ba28ad6e56e input=c1ec36d610b3f391]*/ +/*[clinic end generated code: output=65df79ad8808f85d input=8a60274c619c3d29]*/ { X509_VERIFY_PARAM *ssl_verification_params; - unsigned long flags; ssl_verification_params = SSL_CTX_get0_param(self->ctx); - flags = X509_VERIFY_PARAM_get_flags(ssl_verification_params); - return PyLong_FromUnsignedLong(flags); + return X509_VERIFY_PARAM_get_flags(ssl_verification_params); } /*[clinic input] @critical_section @setter _ssl._SSLContext.verify_flags + value: unsigned_long(bitwise=True) [clinic start generated code]*/ static int -_ssl__SSLContext_verify_flags_set_impl(PySSLContext *self, PyObject *value) -/*[clinic end generated code: output=a3e3b2a0ce6c2e99 input=b2a0c42583d4f34e]*/ +_ssl__SSLContext_verify_flags_set_impl(PySSLContext *self, + unsigned long value) +/*[clinic end generated code: output=3a0dc3da11d16fc0 input=45ca63f1bfe14386]*/ { X509_VERIFY_PARAM *ssl_verification_params; - unsigned long new_flags, flags, set, clear; + unsigned long new_flags = value; + unsigned long flags, set, clear; - if (!PyArg_Parse(value, "k", &new_flags)) - return -1; ssl_verification_params = SSL_CTX_get0_param(self->ctx); flags = X509_VERIFY_PARAM_get_flags(ssl_verification_params); clear = flags & ~new_flags; @@ -4231,15 +4497,14 @@ _ssl__SSLContext_num_tickets_get_impl(PySSLContext *self) @critical_section @setter _ssl._SSLContext.num_tickets + value: long [clinic start generated code]*/ static int -_ssl__SSLContext_num_tickets_set_impl(PySSLContext *self, PyObject *value) -/*[clinic end generated code: output=ced81b46f3beab09 input=6ef8067ac55607e7]*/ +_ssl__SSLContext_num_tickets_set_impl(PySSLContext *self, long value) +/*[clinic end generated code: output=c2c97071a729b0ff input=6f7531a9d9cd4570]*/ { - long num; - if (!PyArg_Parse(value, "l", &num)) - return -1; + long num = value; if (num < 0) { PyErr_SetString(PyExc_ValueError, "value must be non-negative"); return -1; @@ -4291,11 +4556,13 @@ _ssl__SSLContext_options_get_impl(PySSLContext *self) @critical_section @setter _ssl._SSLContext.options + value: unsigned_long_long [clinic start generated code]*/ static int -_ssl__SSLContext_options_set_impl(PySSLContext *self, PyObject *value) -/*[clinic end generated code: output=92ca34731ece5dbb input=2b94bf789e9ae5dd]*/ +_ssl__SSLContext_options_set_impl(PySSLContext *self, + unsigned long long value) +/*[clinic end generated code: output=9bf1e7bf9ab9c49b input=143105581d4dfc86]*/ { unsigned long long new_opts_arg; uint64_t new_opts, opts, clear, set; @@ -4304,9 +4571,7 @@ _ssl__SSLContext_options_set_impl(PySSLContext *self, PyObject *value) SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2 | SSL_OP_NO_TLSv1_3 ); - if (!PyArg_Parse(value, "O&", _PyLong_UnsignedLongLong_Converter, &new_opts_arg)) { - return -1; - } + new_opts_arg = value; Py_BUILD_ASSERT(sizeof(new_opts) >= sizeof(new_opts_arg)); new_opts = (uint64_t)new_opts_arg; @@ -4332,36 +4597,32 @@ _ssl__SSLContext_options_set_impl(PySSLContext *self, PyObject *value) /*[clinic input] @critical_section @getter -_ssl._SSLContext._host_flags +_ssl._SSLContext._host_flags -> unsigned_int [clinic start generated code]*/ -static PyObject * +static unsigned int _ssl__SSLContext__host_flags_get_impl(PySSLContext *self) -/*[clinic end generated code: output=0f9db6654ce32582 input=8e3c49499eefd0e5]*/ +/*[clinic end generated code: output=86ddaf5eeea5f355 input=1ccf5ae9b37de139]*/ { X509_VERIFY_PARAM *ssl_verification_params; - unsigned int host_flags; ssl_verification_params = SSL_CTX_get0_param(self->ctx); - host_flags = X509_VERIFY_PARAM_get_hostflags(ssl_verification_params); - return PyLong_FromUnsignedLong(host_flags); + return X509_VERIFY_PARAM_get_hostflags(ssl_verification_params); } /*[clinic input] @critical_section @setter _ssl._SSLContext._host_flags + value: unsigned_int(bitwise=True) [clinic start generated code]*/ static int -_ssl__SSLContext__host_flags_set_impl(PySSLContext *self, PyObject *value) -/*[clinic end generated code: output=1ed6f4027aaf2e3e input=28caf1fb9c32f6cb]*/ +_ssl__SSLContext__host_flags_set_impl(PySSLContext *self, unsigned int value) +/*[clinic end generated code: output=9986c48e63e6ba3e input=36d1b89df2884d81]*/ { X509_VERIFY_PARAM *ssl_verification_params; - unsigned int new_flags = 0; - - if (!PyArg_Parse(value, "I", &new_flags)) - return -1; + unsigned int new_flags = value; ssl_verification_params = SSL_CTX_get0_param(self->ctx); X509_VERIFY_PARAM_set_hostflags(ssl_verification_params, new_flags); @@ -4371,29 +4632,28 @@ _ssl__SSLContext__host_flags_set_impl(PySSLContext *self, PyObject *value) /*[clinic input] @critical_section @getter -_ssl._SSLContext.check_hostname +_ssl._SSLContext.check_hostname -> bool [clinic start generated code]*/ -static PyObject * +static int _ssl__SSLContext_check_hostname_get_impl(PySSLContext *self) -/*[clinic end generated code: output=e046d6eeefc76063 input=1b8341e705f9ecf5]*/ +/*[clinic end generated code: output=a5772c7e90e32c1d input=d5ae97abc5e0fb0b]*/ { - return PyBool_FromLong(self->check_hostname); + return self->check_hostname; } /*[clinic input] @critical_section @setter _ssl._SSLContext.check_hostname + value: bool [clinic start generated code]*/ static int -_ssl__SSLContext_check_hostname_set_impl(PySSLContext *self, PyObject *value) -/*[clinic end generated code: output=0e767b4784e7dc3f input=e6a771cb5919f74d]*/ +_ssl__SSLContext_check_hostname_set_impl(PySSLContext *self, int value) +/*[clinic end generated code: output=323bb94d7b54d471 input=9134aa868194a6c3]*/ { - int check_hostname; - if (!PyArg_Parse(value, "p", &check_hostname)) - return -1; + int check_hostname = value; int verify_mode = check_hostname ? SSL_CTX_get_verify_mode(self->ctx) : 0; if (check_hostname && verify_mode == SSL_VERIFY_NONE) { @@ -5103,6 +5363,212 @@ _ssl__SSLContext_set_default_verify_paths_impl(PySSLContext *self) Py_RETURN_NONE; } +#ifdef HAVE_OPENSSL_ECH +static OSSL_ECHSTORE * +ech_store_from_config(_sslmodulestate *state, Py_buffer *ech_config) +{ + if (ech_config->len > INT_MAX) { + PyErr_Format(PyExc_OverflowError, + "ECH configuration longer than %d bytes", INT_MAX); + return NULL; + } + OSSL_ECHSTORE *store = NULL; + BIO *config_bio = BIO_new(BIO_s_mem()); + if (config_bio == NULL) { + goto fail; + } + store = OSSL_ECHSTORE_new(NULL, NULL); + if (store == NULL) { + goto fail; + } + const unsigned char *config = ech_config->buf; + int config_len = (int)ech_config->len; + if (BIO_write(config_bio, config, config_len) != config_len + || OSSL_ECHSTORE_read_echconfiglist(store, config_bio) != 1) { + goto fail; + } + int num_entries; + if (OSSL_ECHSTORE_num_entries(store, &num_entries) != 1) { + goto fail; + } + if (num_entries == 0) { + ERR_raise(ERR_LIB_SSL, ERR_R_PASSED_INVALID_ARGUMENT); + goto fail; + } + BIO_free(config_bio); + return store; + +fail: + _setSSLError(state, NULL, 0, __FILE__, __LINE__); + OSSL_ECHSTORE_free(store); + BIO_free(config_bio); + return NULL; +} + +/*[clinic input] +@critical_section +_ssl._SSLContext.set_ech_config + + ech_config: Py_buffer + / + +Set the ECH configuration on the SSL context. + +ech_config must be a bytes-like object containing an ECHConfigList +in binary or Base64 encoding. +[clinic start generated code]*/ + +static PyObject * +_ssl__SSLContext_set_ech_config_impl(PySSLContext *self, + Py_buffer *ech_config) +/*[clinic end generated code: output=cea53188b338cf80 input=69016efcb2cd1ed2]*/ +{ + if (self->protocol == PY_SSL_VERSION_TLS_SERVER) { + _setSSLError(get_state_ctx(self), + "Cannot set ECH configuration on a " + "PROTOCOL_TLS_SERVER context", 0, __FILE__, __LINE__); + return NULL; + } + OSSL_ECHSTORE *store = ech_store_from_config(get_state_ctx(self), + ech_config); + if (store == NULL) { + return NULL; + } + PyMutex_Lock(&self->tstate_mutex); + int result = SSL_CTX_set1_echstore(self->ctx, store); + PyMutex_Unlock(&self->tstate_mutex); + OSSL_ECHSTORE_free(store); + if (result != 1) { + _setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__); + return NULL; + } + Py_RETURN_NONE; +} + +static int +load_ech_keys(SSL_CTX *ctx, BIO *bio, int for_retry, + _PySSLPasswordInfo *pw_info) +{ + int result = 0; + int old_keys, new_keys; + OSSL_ECHSTORE *store = NULL; + EVP_PKEY *key = PEM_read_bio_PrivateKey(bio, NULL, + _password_callback, pw_info); + if (key == NULL) { + goto end; + } + store = SSL_CTX_get1_echstore(ctx); + if (store == NULL) { + if (ERR_peek_error() != 0) { + goto end; + } + store = OSSL_ECHSTORE_new(NULL, NULL); + if (store == NULL) { + goto end; + } + } + if (OSSL_ECHSTORE_num_keys(store, &old_keys) != 1 + || OSSL_ECHSTORE_set1_key_and_read_pem(store, key, bio, for_retry) != 1 + || OSSL_ECHSTORE_num_keys(store, &new_keys) != 1) { + goto end; + } + // OpenSSL may match a key already in the store. We want to require a new match. + if (new_keys <= old_keys) { + ERR_raise(ERR_LIB_SSL, SSL_R_PRIVATE_KEY_MISMATCH); + goto end; + } + result = SSL_CTX_set1_echstore(ctx, store); + +end: + EVP_PKEY_free(key); + OSSL_ECHSTORE_free(store); + return result; +} + +/*[clinic input] +_ssl._SSLContext.load_ech_keys + + keyfile: object + password: object = None + * + for_retry: bool = True + +Load server ECH keys and configurations from a PEM file. + +The file must contain a private key followed by its ECHConfigList. +The password argument may be a string, bytes, bytearray, or a +callable returning one of those types. It is only needed for +encrypted keys. +If for_retry is true, advertise the configurations in ECH retry +responses. +[clinic start generated code]*/ + +static PyObject * +_ssl__SSLContext_load_ech_keys_impl(PySSLContext *self, PyObject *keyfile, + PyObject *password, int for_retry) +/*[clinic end generated code: output=73b9b4832b89f40d input=016a625a1505de4a]*/ +{ + if (self->protocol == PY_SSL_VERSION_TLS_CLIENT) { + _setSSLError(get_state_ctx(self), + "Cannot load ECH keys into a " + "PROTOCOL_TLS_CLIENT context", 0, __FILE__, __LINE__); + return NULL; + } + PyObject *keyfile_bytes; + PyObject *ret = NULL; + _PySSLPasswordInfo pw_info = { NULL, NULL, NULL, 0, 0 }; + if (!PyUnicode_FSConverter(keyfile, &keyfile_bytes)) { + return NULL; + } + if (password != Py_None) { + if (PyCallable_Check(password)) { + pw_info.callable = password; + } else if (!_pwinfo_set(&pw_info, password, + "password should be a string or callable")) { + goto done; + } + } + const char *filename = PyBytes_AS_STRING(keyfile_bytes); + int result = 0; + int open_failed = 0; + + ERR_clear_error(); + PyMutex_Lock(&self->tstate_mutex); + PySSL_BEGIN_ALLOW_THREADS_S(pw_info.thread_state); + errno = 0; + BIO *bio = BIO_new_file(filename, "rb"); + if (bio == NULL) { + open_failed = 1; + } + else { + result = load_ech_keys(self->ctx, bio, for_retry, &pw_info); + BIO_free(bio); + } + PySSL_END_ALLOW_THREADS_S(pw_info.thread_state); + PyMutex_Unlock(&self->tstate_mutex); + + if (result != 1) { + if (pw_info.error) { + /* The password callback has already set the exception. */ + ERR_clear_error(); + } + else if (open_failed && errno != 0) { + PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError, keyfile); + ERR_clear_error(); + } + else { + _setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__); + } + goto done; + } + ret = Py_NewRef(Py_None); +done: + PyMem_Free(pw_info.password); + Py_DECREF(keyfile_bytes); + return ret; +} +#endif /* HAVE_OPENSSL_ECH */ + /*[clinic input] @critical_section _ssl._SSLContext.set_ecdh_curve @@ -5145,10 +5611,10 @@ _ssl__SSLContext_set_ecdh_curve_impl(PySSLContext *self, PyObject *name) } static int -_servername_callback(SSL *s, int *al, void *args) +_servername_callback(SSL *s, int *al, void *Py_UNUSED(args)) { int ret; - PySSLContext *sslctx = (PySSLContext *) args; + PySSLContext *sslctx; PySSLSocket *ssl; PyObject *result; /* The high-level ssl.SSLSocket object */ @@ -5157,18 +5623,30 @@ _servername_callback(SSL *s, int *al, void *args) const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name); PyGILState_STATE gstate = PyGILState_Ensure(); + /* Do not use the SSL_CTX's servername arg to find the context: it is a + borrowed pointer to whichever _SSLContext installed the callback, and + that object may already be gone while OpenSSL still reaches this + callback through the connection's session_ctx (e.g. on the second + ClientHello after a HelloRetryRequest, once sni_callback has switched + the socket to another context). The socket's current context is + always alive. */ + ssl = SSL_get_app_data(s); + assert(ssl != NULL); + Py_BEGIN_CRITICAL_SECTION(ssl); + sslctx = (PySSLContext *)Py_NewRef(ssl->ctx); + Py_END_CRITICAL_SECTION(); + assert(Py_IS_TYPE(ssl, get_state_ctx(sslctx)->PySSLSocket_Type)); + Py_BEGIN_CRITICAL_SECTION(sslctx); sni_cb = Py_XNewRef(sslctx->set_sni_cb); Py_END_CRITICAL_SECTION(); if (sni_cb == NULL) { + Py_DECREF(sslctx); PyGILState_Release(gstate); return SSL_TLSEXT_ERR_OK; } - ssl = SSL_get_app_data(s); - assert(Py_IS_TYPE(ssl, get_state_ctx(sslctx)->PySSLSocket_Type)); - /* The servername callback expects an argument that represents the current * SSL connection and that has a .context attribute that can be changed to * identify the requested hostname. Since the official API is the Python @@ -5251,12 +5729,14 @@ _servername_callback(SSL *s, int *al, void *args) } Py_DECREF(sni_cb); + Py_DECREF(sslctx); PyGILState_Release(gstate); return ret; error: Py_XDECREF(ssl_socket); Py_XDECREF(sni_cb); + Py_DECREF(sslctx); *al = SSL_AD_INTERNAL_ERROR; ret = SSL_TLSEXT_ERR_ALERT_FATAL; PyGILState_Release(gstate); @@ -5315,7 +5795,6 @@ _ssl__SSLContext_sni_callback_set_impl(PySSLContext *self, PyObject *value) } else { Py_XSETREF(self->set_sni_cb, Py_NewRef(value)); - SSL_CTX_set_tlsext_servername_arg(self->ctx, self); SSL_CTX_set_tlsext_servername_callback(self->ctx, _servername_callback); } return 0; @@ -5769,6 +6248,9 @@ static struct PyMethodDef context_methods[] = { _SSL__SSLCONTEXT_SESSION_STATS_METHODDEF _SSL__SSLCONTEXT_SET_DEFAULT_VERIFY_PATHS_METHODDEF _SSL__SSLCONTEXT_SET_ECDH_CURVE_METHODDEF + _SSL__SSLCONTEXT_SET_ECH_CONFIG_METHODDEF + _SSL__SSLCONTEXT_LOAD_ECH_KEYS_METHODDEF + _SSL__SSLCONTEXT__SET_OUTER_ALPN_PROTOCOLS_METHODDEF _SSL__SSLCONTEXT_CERT_STORE_STATS_METHODDEF _SSL__SSLCONTEXT_GET_CA_CERTS_METHODDEF _SSL__SSLCONTEXT_GET_CIPHERS_METHODDEF @@ -5900,7 +6382,8 @@ _ssl_MemoryBIO_read_impl(PySSLMemoryBIO *self, int len) { int avail, nbytes; - avail = (int)Py_MIN(BIO_ctrl_pending(self->bio), INT_MAX); + size_t pending = BIO_ctrl_pending(self->bio); + avail = (int)Py_MIN(pending, (size_t)INT_MAX); if ((len < 0) || (len > avail)) len = avail; @@ -6259,10 +6742,9 @@ _ssl_RAND_add_impl(PyObject *module, Py_buffer *view, double entropy) } static PyObject * -PySSL_RAND(PyObject *module, int len, int pseudo) +PySSL_RAND(PyObject *module, int len) { int ok; - PyObject *bytes; unsigned long err; const char *errstr; PyObject *v; @@ -6272,20 +6754,16 @@ PySSL_RAND(PyObject *module, int len, int pseudo) return NULL; } - bytes = PyBytes_FromStringAndSize(NULL, len); - if (bytes == NULL) + PyBytesWriter *writer = PyBytesWriter_Create(len); + if (writer == NULL) { return NULL; - if (pseudo) { - ok = RAND_bytes((unsigned char*)PyBytes_AS_STRING(bytes), len); - if (ok == 0 || ok == 1) - return Py_BuildValue("NO", bytes, ok == 1 ? Py_True : Py_False); } - else { - ok = RAND_bytes((unsigned char*)PyBytes_AS_STRING(bytes), len); - if (ok == 1) - return bytes; + + ok = RAND_bytes(PyBytesWriter_GetData(writer), len); + if (ok == 1) { + return PyBytesWriter_Finish(writer); } - Py_DECREF(bytes); + PyBytesWriter_Discard(writer); err = ERR_get_error(); errstr = ERR_reason_error_string(err); @@ -6310,7 +6788,7 @@ static PyObject * _ssl_RAND_bytes_impl(PyObject *module, int n) /*[clinic end generated code: output=977da635e4838bc7 input=2e78ce1e86336776]*/ { - return PySSL_RAND(module, n, 0); + return PySSL_RAND(module, n); } @@ -6894,6 +7372,13 @@ do { \ SSLEOFError_doc, state->PySSLErrorObject ); + + add_exception( + state->PySSLECHRejectedErrorObject, + "SSLECHRejectedError", + SSLECHRejectedError_doc, + state->PySSLErrorObject + ); #undef add_exception return 0; @@ -6967,6 +7452,20 @@ sslmodule_init_constants(PyObject *m) ADD_INT_CONST("VERIFY_X509_PARTIAL_CHAIN", X509_V_FLAG_PARTIAL_CHAIN); #endif +#ifdef HAVE_OPENSSL_ECH + ADD_INT_CONST("ECH_STATUS_BACKEND", SSL_ECH_STATUS_BACKEND); + ADD_INT_CONST("ECH_STATUS_GREASE_ECH", SSL_ECH_STATUS_GREASE_ECH); + ADD_INT_CONST("ECH_STATUS_GREASE", SSL_ECH_STATUS_GREASE); + ADD_INT_CONST("ECH_STATUS_SUCCESS", SSL_ECH_STATUS_SUCCESS); + ADD_INT_CONST("ECH_STATUS_FAILED", SSL_ECH_STATUS_FAILED); + ADD_INT_CONST("ECH_STATUS_BAD_CALL", SSL_ECH_STATUS_BAD_CALL); + ADD_INT_CONST("ECH_STATUS_NOT_TRIED", SSL_ECH_STATUS_NOT_TRIED); + ADD_INT_CONST("ECH_STATUS_BAD_NAME", SSL_ECH_STATUS_BAD_NAME); + ADD_INT_CONST("ECH_STATUS_NOT_CONFIGURED", SSL_ECH_STATUS_NOT_CONFIGURED); + ADD_INT_CONST("ECH_STATUS_FAILED_ECH", SSL_ECH_STATUS_FAILED_ECH); + ADD_INT_CONST("ECH_STATUS_FAILED_ECH_BAD_NAME", SSL_ECH_STATUS_FAILED_ECH_BAD_NAME); +#endif + /* Alert Descriptions from ssl.h */ /* note RESERVED constants no longer intended for use have been removed */ /* http://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-6 */ @@ -7026,13 +7525,13 @@ sslmodule_init_constants(PyObject *m) ADD_INT_CONST("PROTOCOL_TLS", PY_SSL_VERSION_TLS); ADD_INT_CONST("PROTOCOL_TLS_CLIENT", PY_SSL_VERSION_TLS_CLIENT); ADD_INT_CONST("PROTOCOL_TLS_SERVER", PY_SSL_VERSION_TLS_SERVER); -#ifndef OPENSSL_NO_TLS1 +#if !defined(OPENSSL_NO_TLS1) && !defined(OPENSSL_NO_TLS1_METHOD) ADD_INT_CONST("PROTOCOL_TLSv1", PY_SSL_VERSION_TLS1); #endif -#ifndef OPENSSL_NO_TLS1_1 +#if !defined(OPENSSL_NO_TLS1_1) && !defined(OPENSSL_NO_TLS1_1_METHOD) ADD_INT_CONST("PROTOCOL_TLSv1_1", PY_SSL_VERSION_TLS1_1); #endif -#ifndef OPENSSL_NO_TLS1_2 +#if !defined(OPENSSL_NO_TLS1_2) && !defined(OPENSSL_NO_TLS1_2_METHOD) ADD_INT_CONST("PROTOCOL_TLSv1_2", PY_SSL_VERSION_TLS1_2); #endif @@ -7056,6 +7555,12 @@ sslmodule_init_constants(PyObject *m) ADD_OPTION("OP_NO_TICKET", SSL_OP_NO_TICKET); ADD_OPTION("OP_LEGACY_SERVER_CONNECT", SSL_OP_LEGACY_SERVER_CONNECT); +#ifdef HAVE_OPENSSL_ECH + ADD_OPTION("OP_ECH_GREASE", SSL_OP_ECH_GREASE); + ADD_OPTION("OP_ECH_TRIALDECRYPT", SSL_OP_ECH_TRIALDECRYPT); + ADD_OPTION("OP_ECH_IGNORE_CID", SSL_OP_ECH_IGNORE_CID); + ADD_OPTION("OP_ECH_GREASE_RETRY_CONFIG", SSL_OP_ECH_GREASE_RETRY_CONFIG); +#endif #ifdef SSL_OP_SINGLE_ECDH_USE ADD_OPTION("OP_SINGLE_ECDH_USE", SSL_OP_SINGLE_ECDH_USE); #endif @@ -7183,6 +7688,12 @@ sslmodule_init_constants(PyObject *m) addbool(m, "HAS_PHA", 0); #endif +#ifdef HAVE_OPENSSL_ECH + addbool(m, "HAS_ECH", 1); +#else + addbool(m, "HAS_ECH", 0); +#endif + #undef addbool #undef ADD_INT_CONST @@ -7259,12 +7770,62 @@ parse_openssl_version(unsigned long libver, *major = libver & 0xFF; } +PyDoc_STRVAR(openssl_version_info__doc__, +"ssl.OPENSSL_VERSION_INFO\n\ +\n\ +OpenSSL version information as a named tuple."); + +static PyStructSequence_Field openssl_version_info_fields[] = { + {"major", "Major release number"}, + {"minor", "Minor release number"}, + {"fix", "Fix release number"}, + {"patch", "Patch release number"}, + {"status", "Release status"}, + {0} +}; + +static PyStructSequence_Desc openssl_version_info_desc = { + "ssl.OPENSSL_VERSION_INFO", /* name */ + openssl_version_info__doc__, /* doc */ + openssl_version_info_fields, /* fields */ + 5 +}; + +static PyObject * +make_openssl_version_info(PyTypeObject *type, unsigned long libver) +{ + PyObject *version; + int pos = 0; + unsigned int major, minor, fix, patch, status; + + parse_openssl_version(libver, &major, &minor, &fix, &patch, &status); + version = PyStructSequence_New(type); + if (version == NULL) { + return NULL; + } + +#define SetItem(VALUE) \ + PyStructSequence_SET_ITEM(version, pos++, VALUE); \ + if (PyErr_Occurred()) { \ + Py_DECREF(version); \ + return NULL; \ + } + + SetItem(PyLong_FromUnsignedLong(major)) + SetItem(PyLong_FromUnsignedLong(minor)) + SetItem(PyLong_FromUnsignedLong(fix)) + SetItem(PyLong_FromUnsignedLong(patch)) + SetItem(PyLong_FromUnsignedLong(status)) +#undef SetItem + + return version; +} + static int sslmodule_init_versioninfo(PyObject *m) { PyObject *r; unsigned long libver; - unsigned int major, minor, fix, patch, status; /* OpenSSL version */ /* SSLeay() gives us the version of the library linked against, @@ -7275,20 +7836,33 @@ sslmodule_init_versioninfo(PyObject *m) if (PyModule_Add(m, "OPENSSL_VERSION_NUMBER", r) < 0) return -1; - parse_openssl_version(libver, &major, &minor, &fix, &patch, &status); - r = Py_BuildValue("IIIII", major, minor, fix, patch, status); - if (PyModule_Add(m, "OPENSSL_VERSION_INFO", r) < 0) - return -1; - r = PyUnicode_FromString(OpenSSL_version(OPENSSL_VERSION)); if (PyModule_Add(m, "OPENSSL_VERSION", r) < 0) return -1; - libver = OPENSSL_VERSION_NUMBER; - parse_openssl_version(libver, &major, &minor, &fix, &patch, &status); - r = Py_BuildValue("IIIII", major, minor, fix, patch, status); - if (PyModule_Add(m, "_OPENSSL_API_VERSION", r) < 0) + PyTypeObject *version_type; + version_type = PyStructSequence_NewType(&openssl_version_info_desc); + if (version_type == NULL) { return -1; + } + if (PyModule_Add(m, "OPENSSL_VERSION_INFO", + make_openssl_version_info(version_type, libver)) < 0) + { + Py_DECREF(version_type); + return -1; + } + r = make_openssl_version_info(version_type, OPENSSL_VERSION_NUMBER); + Py_DECREF(version_type); + if (r == NULL) { + return -1; + } + if (PyModule_AddObjectRef(m, "OPENSSL_API_VERSION_INFO", r) < 0 || + PyModule_AddObjectRef(m, "_OPENSSL_API_VERSION", r) < 0) + { + Py_DECREF(r); + return -1; + } + Py_DECREF(r); return 0; } @@ -7361,6 +7935,10 @@ sslmodule_init_strings(PyObject *module) if (state->str_verify_code == NULL) { return -1; } + state->str_retry_config = PyUnicode_InternFromString("retry_config"); + if (state->str_retry_config == NULL) { + return -1; + } return 0; } @@ -7408,6 +7986,7 @@ sslmodule_traverse(PyObject *m, visitproc visit, void *arg) Py_VISIT(state->PySSLWantWriteErrorObject); Py_VISIT(state->PySSLSyscallErrorObject); Py_VISIT(state->PySSLEOFErrorObject); + Py_VISIT(state->PySSLECHRejectedErrorObject); Py_VISIT(state->err_codes_to_names); Py_VISIT(state->lib_codes_to_names); Py_VISIT(state->Sock_Type); @@ -7432,6 +8011,7 @@ sslmodule_clear(PyObject *m) Py_CLEAR(state->PySSLWantWriteErrorObject); Py_CLEAR(state->PySSLSyscallErrorObject); Py_CLEAR(state->PySSLEOFErrorObject); + Py_CLEAR(state->PySSLECHRejectedErrorObject); Py_CLEAR(state->err_codes_to_names); Py_CLEAR(state->lib_codes_to_names); Py_CLEAR(state->Sock_Type); @@ -7439,6 +8019,7 @@ sslmodule_clear(PyObject *m) Py_CLEAR(state->str_reason); Py_CLEAR(state->str_verify_code); Py_CLEAR(state->str_verify_message); + Py_CLEAR(state->str_retry_config); return 0; } @@ -7465,5 +8046,6 @@ static struct PyModuleDef _sslmodule_def = { PyMODINIT_FUNC PyInit__ssl(void) { + _PyOpenSSL_SetupMemFunctions(); return PyModuleDef_Init(&_sslmodule_def); } diff --git a/Modules/_ssl.h b/Modules/_ssl.h index 22d93ddcc6d6ebb..f0a9ac09ed3cb7a 100644 --- a/Modules/_ssl.h +++ b/Modules/_ssl.h @@ -23,6 +23,7 @@ typedef struct { PyObject *PySSLWantWriteErrorObject; PyObject *PySSLSyscallErrorObject; PyObject *PySSLEOFErrorObject; + PyObject *PySSLECHRejectedErrorObject; /* Error mappings */ PyObject *err_codes_to_names; PyObject *lib_codes_to_names; @@ -33,6 +34,7 @@ typedef struct { PyObject *str_reason; PyObject *str_verify_code; PyObject *str_verify_message; + PyObject *str_retry_config; /* keylog lock */ PyThread_type_lock keylog_lock; } _sslmodulestate; diff --git a/Modules/_ssl/debughelpers.c b/Modules/_ssl/debughelpers.c index fb9043994f08f9e..0e5422b73a89d4f 100644 --- a/Modules/_ssl/debughelpers.c +++ b/Modules/_ssl/debughelpers.c @@ -102,20 +102,28 @@ _PySSLContext_set_msg_callback(PyObject *op, PyObject *arg, void *Py_UNUSED(closure)) { PySSLContext *self = PySSLContext_CAST(op); - Py_CLEAR(self->msg_cb); + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute '_msg_callback' of '%.100s' objects " + "cannot be deleted", Py_TYPE(op)->tp_name); + return -1; + } + if (arg != Py_None && !PyCallable_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "not a callable object"); + return -1; + } + /* Releasing the old callback can run arbitrary code. */ + PyObject *old_cb = self->msg_cb; if (arg == Py_None) { + self->msg_cb = NULL; SSL_CTX_set_msg_callback(self->ctx, NULL); } else { - if (!PyCallable_Check(arg)) { - SSL_CTX_set_msg_callback(self->ctx, NULL); - PyErr_SetString(PyExc_TypeError, - "not a callable object"); - return -1; - } self->msg_cb = Py_NewRef(arg); SSL_CTX_set_msg_callback(self->ctx, _PySSL_msg_callback); } + Py_XDECREF(old_cb); return 0; } @@ -182,6 +190,12 @@ static int _PySSLContext_set_keylog_filename(PyObject *op, PyObject *arg, void *Py_UNUSED(closure)) { + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'keylog_filename' of '%.100s' objects " + "cannot be deleted", Py_TYPE(op)->tp_name); + return -1; + } #if defined(MS_WINDOWS_APP) && !defined(MS_WINDOWS_DESKTOP) PyErr_SetString(PyExc_NotImplementedError, "set_keylog_filename: unavailable on UWP build"); @@ -218,6 +232,7 @@ _PySSLContext_set_keylog_filename(PyObject *op, PyObject *arg, self->keylog_bio = BIO_new_fp(fp, BIO_CLOSE | BIO_FP_TEXT); if (self->keylog_bio == NULL) { + fclose(fp); PyErr_SetString(get_state_ctx(self)->PySSLErrorObject, "Can't malloc memory for keylog file"); return -1; diff --git a/Modules/_ssl/distrusted_spki.h b/Modules/_ssl/distrusted_spki.h new file mode 100644 index 000000000000000..bbdb56dcfe671ed --- /dev/null +++ b/Modules/_ssl/distrusted_spki.h @@ -0,0 +1,75 @@ +/* Denylist of distrusted SubjectPublicKeyInfo (SPKI). + * + * Verification rejects any chain with a cert whose SPKI SHA-256 digest is in + * the _distrusted_spki table. We match the key, not a cert fingerprint, so + * cross-signs that reuse the key are blocked too. + * + * This is an extraordinary measure and last line of defense. Removing trust is + * primarily the job of the platform root store. This list only blocks keys while + * that update is still propagating to the OS, container images, or root CAs + * bundled in Python packages. The threshold for adding an entry is very high. + * + * See https://github.com/python/cpython/issues/160040 for the eMudhra discussion. + * + * To block another key, add the SHA-256 digest bytes of its SPKI: + * + * $ openssl x509 -in cert.pem -noout -pubkey | openssl pkey -pubin -outform DER | openssl dgst -sha256 -binary | xxd -i + */ +#ifndef Py_SSL_DISTRUSTED_SPKI_H +#define Py_SSL_DISTRUSTED_SPKI_H + +#include "openssl/sha.h" + +static const unsigned char _distrusted_spki[][SHA256_DIGEST_LENGTH] = { + /* Compromised eMudhra intermediates, https://emudhra.we-have-a-problem.com/ */ + /* CN=EM OV TLS CA - G3B,O=eMudhra BV,C=NL */ + { + 0x43, 0xbf, 0xfa, 0x19, 0xd6, 0xef, 0x65, 0x14, 0x51, 0xf6, 0x84, 0x1e, + 0x01, 0x99, 0x31, 0xe9, 0x6f, 0x6f, 0x2e, 0xae, 0xff, 0x28, 0xab, 0x4b, + 0x6f, 0x1c, 0xe4, 0x57, 0x6d, 0xe2, 0x71, 0x7b, + }, + /* CN=EM DV TLS CA - G3C,O=eMudhra Inc,C=US */ + { + 0x49, 0xdd, 0x35, 0x3d, 0xc2, 0xb9, 0x19, 0xa3, 0x77, 0x06, 0x45, 0x11, + 0x7d, 0x0e, 0x60, 0xc1, 0x61, 0x15, 0xe7, 0xd1, 0xbc, 0x25, 0x9e, 0xef, + 0xe7, 0x34, 0xb0, 0x0e, 0xa4, 0x34, 0xfe, 0x5f, + }, + /* CN=EM EV TLS CA - G3C,O=eMudhra Inc,C=US */ + { + 0x5c, 0x06, 0x60, 0xa2, 0xb1, 0x64, 0x91, 0x0d, 0x8f, 0xf5, 0x89, 0xc1, + 0x8e, 0x14, 0x55, 0x2e, 0x9e, 0x0e, 0xc2, 0x37, 0xdc, 0xef, 0xe2, 0xcb, + 0x73, 0x6d, 0x41, 0xa4, 0x81, 0x1f, 0x81, 0xa0, + }, + /* CN=EM OV TLS CA - G3C,O=eMudhra Inc,C=US */ + { + 0x63, 0xec, 0xef, 0xee, 0x43, 0x1d, 0x49, 0x52, 0x3b, 0xc1, 0x13, 0x6c, + 0x4e, 0x72, 0xd0, 0x20, 0x6a, 0x47, 0x70, 0x86, 0xca, 0xf6, 0x06, 0xcd, + 0x5c, 0xf0, 0x25, 0x68, 0x6c, 0x10, 0x9c, 0xf8, + }, + /* CN=EM OV CS CA - G3C,O=eMudhra Inc,C=US */ + { + 0x92, 0xc0, 0x63, 0xd6, 0x7e, 0x8f, 0x14, 0xdb, 0x71, 0xd2, 0x88, 0xe1, + 0x12, 0x66, 0xff, 0xda, 0xf6, 0x9c, 0xbf, 0x11, 0x5f, 0x7b, 0xab, 0x14, + 0xf3, 0xbc, 0x2f, 0x68, 0xd2, 0x5e, 0x0e, 0x30, + }, + /* CN=EM EV TLS CA - G3B,O=eMudhra BV,C=NL */ + { + 0xe0, 0x25, 0x4c, 0x7f, 0xcd, 0xc2, 0x65, 0xe2, 0xf0, 0xf8, 0xa4, 0x28, + 0xda, 0xbb, 0x75, 0xab, 0x4a, 0xe0, 0x39, 0xb4, 0x87, 0x2d, 0x62, 0xf5, + 0xee, 0x57, 0xf0, 0x87, 0x7d, 0x5a, 0x8a, 0x41, + }, + /* CN=EM DV TLS CA - G3B,O=eMudhra BV,C=NL */ + { + 0xeb, 0xed, 0x64, 0x75, 0xc2, 0xc2, 0xd8, 0x0f, 0xcb, 0x19, 0x9f, 0x3f, + 0xe8, 0xdd, 0x6e, 0x6b, 0x3c, 0xe6, 0x0b, 0x77, 0xeb, 0x15, 0xd4, 0xe4, + 0x2c, 0x3d, 0xec, 0x0c, 0x6f, 0x5b, 0x51, 0x05, + }, + /* CN=EM OV CS CA - G3B,O=eMudhra BV,C=NL */ + { + 0xec, 0x4f, 0xfa, 0x1a, 0xd0, 0xac, 0x88, 0x08, 0x13, 0x14, 0xb7, 0xaa, + 0xff, 0xef, 0x6a, 0x91, 0xf9, 0x7c, 0xd5, 0x72, 0x91, 0xbb, 0x5b, 0xa6, + 0x86, 0xc5, 0x41, 0x5f, 0x5e, 0xb4, 0xf6, 0xb6, + }, +}; + +#endif /* !Py_SSL_DISTRUSTED_SPKI_H */ diff --git a/Modules/_ssl_data_300.h b/Modules/_ssl_data_300.h index b687ce43c77d669..39b637a8f6a2ca4 100644 --- a/Modules/_ssl_data_300.h +++ b/Modules/_ssl_data_300.h @@ -1,7 +1,9 @@ /* File generated by Tools/ssl/make_ssl_data.py */ -/* Generated on 2023-06-01T03:03:52.163218 */ -/* Manually edited to add definitions from 1.1.1 (GH-105174) */ +/* Generated on 2026-08-25T19:28:21.667000+00:00 */ +/* Generated from Git commit openssl-3.0.22-0-ga279090b9 */ +/* Manually edited to retain definitions from 1.1.1 (GH-105174) */ +/* generated from args.lib2errnum */ static struct py_ssl_library_code library_codes[] = { #ifdef ERR_LIB_ASN1 {"ASN1", ERR_LIB_ASN1}, @@ -168,10 +170,10 @@ static struct py_ssl_library_code library_codes[] = { #ifdef ERR_LIB_X509V3 {"X509V3", ERR_LIB_X509V3}, #endif - { NULL } + {NULL, 0} /* sentinel */ }; - +/* generated from args.reasons */ static struct py_ssl_error_code error_codes[] = { #ifdef ASN1_R_ADDING_OBJECT {"ADDING_OBJECT", ERR_LIB_ASN1, ASN1_R_ADDING_OBJECT}, @@ -1538,6 +1540,11 @@ static struct py_ssl_error_code error_codes[] = { #else {"CERTIFICATE_VERIFY_ERROR", 46, 100}, #endif + #ifdef CMS_R_CIPHER_AEAD_IN_ENVELOPED_DATA + {"CIPHER_AEAD_IN_ENVELOPED_DATA", ERR_LIB_CMS, CMS_R_CIPHER_AEAD_IN_ENVELOPED_DATA}, + #else + {"CIPHER_AEAD_IN_ENVELOPED_DATA", 46, 182}, + #endif #ifdef CMS_R_CIPHER_AEAD_SET_TAG_ERROR {"CIPHER_AEAD_SET_TAG_ERROR", ERR_LIB_CMS, CMS_R_CIPHER_AEAD_SET_TAG_ERROR}, #else @@ -1643,6 +1650,11 @@ static struct py_ssl_error_code error_codes[] = { #else {"ERROR_SETTING_RECIPIENTINFO", 46, 116}, #endif + #ifdef CMS_R_ERROR_UNSUPPORTED_STATIC_KEY_AGREEMENT + {"ERROR_UNSUPPORTED_STATIC_KEY_AGREEMENT", ERR_LIB_CMS, CMS_R_ERROR_UNSUPPORTED_STATIC_KEY_AGREEMENT}, + #else + {"ERROR_UNSUPPORTED_STATIC_KEY_AGREEMENT", 46, 196}, + #endif #ifdef CMS_R_ESS_SIGNING_CERTID_MISMATCH_ERROR {"ESS_SIGNING_CERTID_MISMATCH_ERROR", ERR_LIB_CMS, CMS_R_ESS_SIGNING_CERTID_MISMATCH_ERROR}, #else @@ -1963,6 +1975,11 @@ static struct py_ssl_error_code error_codes[] = { #else {"UNSUPPORTED_RECIPIENT_TYPE", 46, 154}, #endif + #ifdef CMS_R_UNSUPPORTED_SIGNATURE_ALGORITHM + {"UNSUPPORTED_SIGNATURE_ALGORITHM", ERR_LIB_CMS, CMS_R_UNSUPPORTED_SIGNATURE_ALGORITHM}, + #else + {"UNSUPPORTED_SIGNATURE_ALGORITHM", 46, 195}, + #endif #ifdef CMS_R_UNSUPPORTED_TYPE {"UNSUPPORTED_TYPE", ERR_LIB_CMS, CMS_R_UNSUPPORTED_TYPE}, #else @@ -2088,6 +2105,11 @@ static struct py_ssl_error_code error_codes[] = { #else {"RECURSIVE_DIRECTORY_INCLUDE", 14, 111}, #endif + #ifdef CONF_R_RECURSIVE_SECTION_REFERENCE + {"RECURSIVE_SECTION_REFERENCE", ERR_LIB_CONF, CONF_R_RECURSIVE_SECTION_REFERENCE}, + #else + {"RECURSIVE_SECTION_REFERENCE", 14, 126}, + #endif #ifdef CONF_R_RELATIVE_PATH {"RELATIVE_PATH", ERR_LIB_CONF, CONF_R_RELATIVE_PATH}, #else @@ -2573,6 +2595,11 @@ static struct py_ssl_error_code error_codes[] = { #else {"PEER_KEY_ERROR", 5, 111}, #endif + #ifdef DH_R_Q_TOO_LARGE + {"Q_TOO_LARGE", ERR_LIB_DH, DH_R_Q_TOO_LARGE}, + #else + {"Q_TOO_LARGE", 5, 130}, + #endif #ifdef DH_R_SHARED_INFO_ERROR {"SHARED_INFO_ERROR", ERR_LIB_DH, DH_R_SHARED_INFO_ERROR}, #else @@ -7483,6 +7510,11 @@ static struct py_ssl_error_code error_codes[] = { #else {"TLSV1_ALERT_INTERNAL_ERROR", 20, 1080}, #endif + #ifdef SSL_R_TLSV1_ALERT_NO_APPLICATION_PROTOCOL + {"TLSV1_ALERT_NO_APPLICATION_PROTOCOL", ERR_LIB_SSL, SSL_R_TLSV1_ALERT_NO_APPLICATION_PROTOCOL}, + #else + {"TLSV1_ALERT_NO_APPLICATION_PROTOCOL", 20, 1120}, + #endif #ifdef SSL_R_TLSV1_ALERT_NO_RENEGOTIATION {"TLSV1_ALERT_NO_RENEGOTIATION", ERR_LIB_SSL, SSL_R_TLSV1_ALERT_NO_RENEGOTIATION}, #else @@ -7503,6 +7535,11 @@ static struct py_ssl_error_code error_codes[] = { #else {"TLSV1_ALERT_UNKNOWN_CA", 20, 1048}, #endif + #ifdef SSL_R_TLSV1_ALERT_UNKNOWN_PSK_IDENTITY + {"TLSV1_ALERT_UNKNOWN_PSK_IDENTITY", ERR_LIB_SSL, SSL_R_TLSV1_ALERT_UNKNOWN_PSK_IDENTITY}, + #else + {"TLSV1_ALERT_UNKNOWN_PSK_IDENTITY", 20, 1115}, + #endif #ifdef SSL_R_TLSV1_ALERT_USER_CANCELLED {"TLSV1_ALERT_USER_CANCELLED", ERR_LIB_SSL, SSL_R_TLSV1_ALERT_USER_CANCELLED}, #else @@ -8408,11 +8445,21 @@ static struct py_ssl_error_code error_codes[] = { #else {"CRL_ALREADY_DELTA", 11, 127}, #endif + #ifdef X509_R_CRL_SIGNATURE_ALGORITHM_MISMATCH + {"CRL_SIGNATURE_ALGORITHM_MISMATCH", ERR_LIB_X509, X509_R_CRL_SIGNATURE_ALGORITHM_MISMATCH}, + #else + {"CRL_SIGNATURE_ALGORITHM_MISMATCH", 11, 147}, + #endif #ifdef X509_R_CRL_VERIFY_FAILURE {"CRL_VERIFY_FAILURE", ERR_LIB_X509, X509_R_CRL_VERIFY_FAILURE}, #else {"CRL_VERIFY_FAILURE", 11, 131}, #endif + #ifdef X509_R_DUPLICATE_ATTRIBUTE + {"DUPLICATE_ATTRIBUTE", ERR_LIB_X509, X509_R_DUPLICATE_ATTRIBUTE}, + #else + {"DUPLICATE_ATTRIBUTE", 11, 140}, + #endif #ifdef X509_R_ERROR_GETTING_MD_BY_NID {"ERROR_GETTING_MD_BY_NID", ERR_LIB_X509, X509_R_ERROR_GETTING_MD_BY_NID}, #else @@ -8583,6 +8630,5 @@ static struct py_ssl_error_code error_codes[] = { #else {"WRONG_TYPE", 11, 122}, #endif - { NULL } + {NULL, 0, 0} /* sentinel */ }; - diff --git a/Modules/_ssl_data_36.h b/Modules/_ssl_data_36.h index e1c1eb30ff6a7b7..fd323e6ee5a2c07 100644 --- a/Modules/_ssl_data_36.h +++ b/Modules/_ssl_data_36.h @@ -1,6 +1,6 @@ /* File generated by Tools/ssl/make_ssl_data.py */ -/* Generated on 2026-05-03T19:50:43.034653+00:00 */ -/* Generated from Git commit openssl-3.6.2-0-gfe686e15d */ +/* Generated on 2026-08-25T19:23:56.859950+00:00 */ +/* Generated from Git commit openssl-3.6.4-0-gd3c1b1169 */ /* generated from args.lib2errnum */ static struct py_ssl_library_code library_codes[] = { @@ -9268,6 +9268,11 @@ static struct py_ssl_error_code error_codes[] = { #else {"CRL_ALREADY_DELTA", 11, 127}, #endif + #ifdef X509_R_CRL_SIGNATURE_ALGORITHM_MISMATCH + {"CRL_SIGNATURE_ALGORITHM_MISMATCH", ERR_LIB_X509, X509_R_CRL_SIGNATURE_ALGORITHM_MISMATCH}, + #else + {"CRL_SIGNATURE_ALGORITHM_MISMATCH", 11, 147}, + #endif #ifdef X509_R_CRL_VERIFY_FAILURE {"CRL_VERIFY_FAILURE", ERR_LIB_X509, X509_R_CRL_VERIFY_FAILURE}, #else diff --git a/Modules/_ssl_data_40.h b/Modules/_ssl_data_40.h index ea615f655bb5953..6d8631df0a2ec27 100644 --- a/Modules/_ssl_data_40.h +++ b/Modules/_ssl_data_40.h @@ -1,6 +1,6 @@ /* File generated by Tools/ssl/make_ssl_data.py */ -/* Generated on 2026-04-15T09:18:34.696139+00:00 */ -/* Generated from Git commit v3.15.0a8-132-gd14e31ed683 */ +/* Generated on 2026-08-25T19:25:20.590415+00:00 */ +/* Generated from Git commit openssl-4.0.2-0-gf089acdf4 */ /* generated from args.lib2errnum */ static struct py_ssl_library_code library_codes[] = { @@ -9163,6 +9163,11 @@ static struct py_ssl_error_code error_codes[] = { #else {"CRL_ALREADY_DELTA", 11, 127}, #endif + #ifdef X509_R_CRL_SIGNATURE_ALGORITHM_MISMATCH + {"CRL_SIGNATURE_ALGORITHM_MISMATCH", ERR_LIB_X509, X509_R_CRL_SIGNATURE_ALGORITHM_MISMATCH}, + #else + {"CRL_SIGNATURE_ALGORITHM_MISMATCH", 11, 147}, + #endif #ifdef X509_R_CRL_VERIFY_FAILURE {"CRL_VERIFY_FAILURE", ERR_LIB_X509, X509_R_CRL_VERIFY_FAILURE}, #else diff --git a/Modules/_struct.c b/Modules/_struct.c index 352312fb0b4c19b..fad026ac8a4652e 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -790,14 +790,19 @@ np_float_complex(_structmodulestate *state, char *p, PyObject *v, const formatdef *f) { Py_complex c = PyComplex_AsCComplex(v); - float x[2] = {(float)c.real, (float)c.imag}; + char tmp[8]; if (c.real == -1 && PyErr_Occurred()) { PyErr_SetString(state->StructError, "required argument is not a complex"); return -1; } - memcpy(p, &x, sizeof(x)); + if (PyFloat_Pack4(c.real, tmp, PY_LITTLE_ENDIAN) + || PyFloat_Pack4(c.imag, tmp + 4, PY_LITTLE_ENDIAN)) + { + return -1; + } + memcpy(p, tmp, 8); return 0; } @@ -1132,15 +1137,20 @@ static int bp_float_complex(_structmodulestate *state, char *p, PyObject *v, const formatdef *f) { Py_complex x = PyComplex_AsCComplex(v); + char tmp[8]; + if (x.real == -1 && PyErr_Occurred()) { PyErr_SetString(state->StructError, "required argument is not a complex"); return -1; } - if (PyFloat_Pack4(x.real, p, 0)) { + if (PyFloat_Pack4(x.real, tmp, 0) + || PyFloat_Pack4(x.imag, tmp + 4, 0)) + { return -1; } - return PyFloat_Pack4(x.imag, p + 4, 0); + memcpy(p, tmp, 8); + return 0; } static int @@ -1458,16 +1468,20 @@ static int lp_float_complex(_structmodulestate *state, char *p, PyObject *v, const formatdef *f) { Py_complex x = PyComplex_AsCComplex(v); + char tmp[8]; + if (x.real == -1 && PyErr_Occurred()) { PyErr_SetString(state->StructError, "required argument is not a complex"); return -1; } - if (PyFloat_Pack4(x.real, p, 1)) { + if (PyFloat_Pack4(x.real, tmp, 1) + || PyFloat_Pack4(x.imag, tmp + 4, 1)) + { return -1; } - return PyFloat_Pack4(x.imag, p + 4, 1); - + memcpy(p, tmp, 8); + return 0; } static int @@ -2395,7 +2409,7 @@ s_pack_internal(PyStructObject *soself, PyObject *const *args, if (n > code->size) n = code->size; if (n > 0) - memcpy(res, p, n); + memmove(res, p, n); } else if (strcmp(e->format, "p") == 0) { Py_ssize_t n; int isstring; @@ -2421,10 +2435,12 @@ s_pack_internal(PyStructObject *soself, PyObject *const *args, n = code->size - 1; } if (n > 0) - memcpy(res + 1, p, n); + memmove(res + 1, p, n); if (n > 255) n = 255; - *res = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char); + if (n > 0) { + *res = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char); + } } else { if (e->pack(state, res, v, e) < 0) { if (PyLong_Check(v) && PyErr_ExceptionMatches(PyExc_OverflowError)) @@ -2482,7 +2498,8 @@ Struct_pack_impl(PyStructObject *self, PyObject * const *values, return NULL; } - return PyBytesWriter_FinishWithSize(writer, self->s_size); + assert(PyBytesWriter_GetSize(writer) == self->s_size); + return PyBytesWriter_Finish(writer); } /*[clinic input] diff --git a/Modules/_testbuffer.c b/Modules/_testbuffer.c index 8b6b617aafa427d..8b37dc7bb34bed9 100644 --- a/Modules/_testbuffer.c +++ b/Modules/_testbuffer.c @@ -2171,7 +2171,6 @@ ndarray_tobytes(PyObject *self, PyObject *dummy) Py_buffer *src = &ndbuf->base; Py_buffer dest; PyObject *ret = NULL; - char *mem; if (ND_C_CONTIGUOUS(ndbuf->flags)) return PyBytes_FromStringAndSize(src->buf, src->len); @@ -2180,14 +2179,13 @@ ndarray_tobytes(PyObject *self, PyObject *dummy) assert(src->strides != NULL); assert(src->ndim > 0); - mem = PyMem_Malloc(src->len); - if (mem == NULL) { - PyErr_NoMemory(); + PyBytesWriter *writer = PyBytesWriter_Create(src->len); + if (writer == NULL) { return NULL; } dest = *src; - dest.buf = mem; + dest.buf = PyBytesWriter_GetData(writer); dest.suboffsets = NULL; dest.strides = strides_from_shape(ndbuf, 0); if (dest.strides == NULL) @@ -2195,11 +2193,12 @@ ndarray_tobytes(PyObject *self, PyObject *dummy) if (copy_buffer(&dest, src) < 0) goto out; - ret = PyBytes_FromStringAndSize(mem, src->len); + ret = PyBytesWriter_Finish(writer); + writer = NULL; out: PyMem_XFree(dest.strides); - PyMem_Free(mem); + PyBytesWriter_Discard(writer); return ret; } @@ -2445,7 +2444,7 @@ py_buffer_to_contiguous(PyObject *self, PyObject *args) int flags; char ord; Py_buffer view; - char *buf = NULL; + PyBytesWriter *writer = NULL; if (!PyArg_ParseTuple(args, "OOi", &obj, &order, &flags)) { return NULL; @@ -2460,21 +2459,21 @@ py_buffer_to_contiguous(PyObject *self, PyObject *args) goto out; } - buf = PyMem_Malloc(view.len); - if (buf == NULL) { - PyErr_NoMemory(); + writer = PyBytesWriter_Create(view.len); + if (writer == NULL) { goto out; } - if (PyBuffer_ToContiguous(buf, &view, view.len, ord) < 0) { + if (PyBuffer_ToContiguous(PyBytesWriter_GetData(writer), &view, view.len, ord) < 0) { goto out; } - ret = PyBytes_FromStringAndSize(buf, view.len); + ret = PyBytesWriter_Finish(writer); + writer = NULL; out: PyBuffer_Release(&view); - PyMem_XFree(buf); + PyBytesWriter_Discard(writer); return ret; } diff --git a/Modules/_testcapi/buffer.c b/Modules/_testcapi/buffer.c index 48393a3dd530c65..c086d7250f67745 100644 --- a/Modules/_testcapi/buffer.c +++ b/Modules/_testcapi/buffer.c @@ -114,8 +114,22 @@ buffer_pointer_as_int(PyObject *Py_UNUSED(module), PyObject *obj) return out; } +static PyObject * +clear_memoryview(PyObject *Py_UNUSED(module), PyObject *obj) +{ + if (!PyMemoryView_Check(obj)) { + PyErr_SetString(PyExc_TypeError, "memoryview expected"); + return NULL; + } + if (Py_TYPE(obj)->tp_clear(obj) < 0) { + return NULL; + } + Py_RETURN_NONE; +} + static PyMethodDef test_methods[] = { {"buffer_pointer_as_int", buffer_pointer_as_int, METH_O}, + {"clear_memoryview", clear_memoryview, METH_O}, {NULL}, }; diff --git a/Modules/_testcapi/bytes.c b/Modules/_testcapi/bytes.c index f12fc7f5f3a2a86..605df203d6fc9a4 100644 --- a/Modules/_testcapi/bytes.c +++ b/Modules/_testcapi/bytes.c @@ -4,19 +4,26 @@ #include "parts.h" #include "util.h" +#include // offsetof() + #include "pycore_bytesobject.h" // _PyBytesWriter_CreateByteArray() /* Test _PyBytes_Resize() */ static PyObject * -bytes_resize(PyObject *Py_UNUSED(module), PyObject *args) +bytes_resize(PyObject *Py_UNUSED(module), PyObject *args, PyObject *kwargs) { + static char *kwlist[] = {"obj", "newsize", "new", "compute_hash", NULL}; PyObject *obj; Py_ssize_t newsize; int new; + int compute_hash = 0; - if (!PyArg_ParseTuple(args, "Onp", &obj, &newsize, &new)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "Onp|p", kwlist, + &obj, &newsize, &new, &compute_hash)) { return NULL; + } NULLABLE(obj); if (new) { @@ -32,13 +39,25 @@ bytes_resize(PyObject *Py_UNUSED(module), PyObject *args) else { Py_XINCREF(obj); } + + if (compute_hash) { + if (PyObject_Hash(obj) == -1) { + Py_DECREF(obj); + return NULL; + } + } + + PyObject *old_obj = obj; if (_PyBytes_Resize(&obj, newsize) < 0) { assert(obj == NULL); + return NULL; } else { assert(obj != NULL); } - return obj; + + Py_ssize_t refcnt = Py_REFCNT(obj); + return Py_BuildValue("Nnp", obj, refcnt, obj != old_obj); } @@ -85,34 +104,25 @@ writer_init(PyObject *self_raw, PyObject *args, PyObject *kwargs) return -1; } - Py_ssize_t alloc; - char *str; - Py_ssize_t str_size; - int use_bytearray; - if (!PyArg_ParseTuple(args, "ny#i", - &alloc, &str, &str_size, &use_bytearray)) { + Py_ssize_t size; + int use_bytearray = 0; + if (!PyArg_ParseTuple(args, "n|i", &size, &use_bytearray)) { return -1; } WriterObject *self = (WriterObject *)self_raw; - if (self->writer) { - PyBytesWriter_Discard(self->writer); - } + PyBytesWriter_Discard(self->writer); + if (use_bytearray) { - self->writer = _PyBytesWriter_CreateByteArray(alloc); + self->writer = _PyBytesWriter_CreateByteArray(size); } else { - self->writer = PyBytesWriter_Create(alloc); + self->writer = PyBytesWriter_Create(size); } if (self->writer == NULL) { return -1; } - if (str_size) { - char *buf = PyBytesWriter_GetData(self->writer); - memcpy(buf, str, str_size); - } - return 0; } @@ -141,6 +151,39 @@ writer_check(WriterObject *self) } +static PyObject* +writer_write(PyObject *self_raw, PyObject *args, PyObject *kwargs) +{ + WriterObject *self = (WriterObject *)self_raw; + if (writer_check(self) < 0) { + return NULL; + } + + static char *kwlist[] = {"pos", "str", "check", NULL}; + Py_ssize_t pos, size; + char *str; + int check = 1; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "ny#|i", kwlist, + &pos, &str, &size, &check)) { + return NULL; + } + + // Use check=0 to trigger a buffer overflow for example + if (check) { + if (pos < 0 || (pos + size) > PyBytesWriter_GetSize(self->writer)) { + PyErr_SetString(PyExc_ValueError, "invalid position or size"); + return NULL; + } + } + + char *data = PyBytesWriter_GetData(self->writer); + memcpy(data + pos, str, size); + + Py_RETURN_NONE; +} + + static PyObject* writer_write_bytes(PyObject *self_raw, PyObject *args) { @@ -149,9 +192,9 @@ writer_write_bytes(PyObject *self_raw, PyObject *args) return NULL; } - char *bytes; - Py_ssize_t size; - if (!PyArg_ParseTuple(args, "yn", &bytes, &size)) { + const char *bytes; + Py_ssize_t unused_size, size; + if (!PyArg_ParseTuple(args, "y#n", &bytes, &unused_size, &size)) { return NULL; } @@ -183,6 +226,27 @@ writer_format_i(PyObject *self_raw, PyObject *args) } +static PyObject* +writer_format_s(PyObject *self_raw, PyObject *args) +{ + WriterObject *self = (WriterObject *)self_raw; + if (writer_check(self) < 0) { + return NULL; + } + + char *format, *str; + if (!PyArg_ParseTuple(args, "yy", &format, &str)) { + return NULL; + } + + if (PyBytesWriter_Format(self->writer, format, str) < 0) { + return NULL; + } + Py_RETURN_NONE; +} + + +// PyBytesWriter_Resize static PyObject* writer_resize(PyObject *self_raw, PyObject *args) { @@ -192,27 +256,56 @@ writer_resize(PyObject *self_raw, PyObject *args) } Py_ssize_t size; - char *str; - Py_ssize_t str_size; - if (!PyArg_ParseTuple(args, - "ny#", - &size, &str, &str_size)) { + if (!PyArg_ParseTuple(args, "n", &size)) { return NULL; } - assert(size >= str_size); - Py_ssize_t pos = PyBytesWriter_GetSize(self->writer); if (PyBytesWriter_Resize(self->writer, size) < 0) { return NULL; } + Py_RETURN_NONE; +} - char *buf = PyBytesWriter_GetData(self->writer); - memcpy(buf + pos, str, str_size); +// Test PyBytesWriter_Grow() +static PyObject* +writer_grow(PyObject *self_raw, PyObject *args) +{ + WriterObject *self = (WriterObject *)self_raw; + if (writer_check(self) < 0) { + return NULL; + } + + Py_ssize_t size; + if (!PyArg_ParseTuple(args, "n", &size)) { + return NULL; + } + + if (PyBytesWriter_Grow(self->writer, size) < 0) { + return NULL; + } Py_RETURN_NONE; } +static PyObject* +writer_get_data(PyObject *self_raw, PyObject *args) +{ + WriterObject *self = (WriterObject *)self_raw; + if (writer_check(self) < 0) { + return NULL; + } + + Py_ssize_t size = PyBytesWriter_GetSize(self->writer); + if (!PyArg_ParseTuple(args, "|n", &size)) { + return NULL; + } + + const char *data = PyBytesWriter_GetData(self->writer); + return PyBytes_FromStringAndSize(data, size); +} + + static PyObject* writer_get_size(PyObject *self_raw, PyObject *Py_UNUSED(args)) { @@ -221,8 +314,8 @@ writer_get_size(PyObject *self_raw, PyObject *Py_UNUSED(args)) return NULL; } - Py_ssize_t alloc = PyBytesWriter_GetSize(self->writer); - return PyLong_FromSsize_t(alloc); + Py_ssize_t size = PyBytesWriter_GetSize(self->writer); + return PyLong_FromSsize_t(size); } @@ -259,13 +352,32 @@ writer_finish_with_size(PyObject *self_raw, PyObject *args) } +static PyObject* +writer_discard(PyObject *self_raw, PyObject *Py_UNUSED(args)) +{ + WriterObject *self = (WriterObject *)self_raw; + if (writer_check(self) < 0) { + return NULL; + } + + PyBytesWriter_Discard(self->writer); + self->writer = NULL; + Py_RETURN_NONE; +} + + static PyMethodDef writer_methods[] = { + {"write", _PyCFunction_CAST(writer_write), METH_VARARGS | METH_KEYWORDS}, {"write_bytes", _PyCFunction_CAST(writer_write_bytes), METH_VARARGS}, {"format_i", _PyCFunction_CAST(writer_format_i), METH_VARARGS}, + {"format_s", _PyCFunction_CAST(writer_format_s), METH_VARARGS}, {"resize", _PyCFunction_CAST(writer_resize), METH_VARARGS}, + {"grow", _PyCFunction_CAST(writer_grow), METH_VARARGS}, + {"get_data", _PyCFunction_CAST(writer_get_data), METH_VARARGS}, {"get_size", _PyCFunction_CAST(writer_get_size), METH_NOARGS}, {"finish", _PyCFunction_CAST(writer_finish), METH_NOARGS}, {"finish_with_size", _PyCFunction_CAST(writer_finish_with_size), METH_VARARGS}, + {"discard", _PyCFunction_CAST(writer_discard), METH_NOARGS}, {NULL, NULL} /* sentinel */ }; @@ -311,8 +423,9 @@ byteswriter_resize(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) char *buf = PyBytesWriter_GetData(writer); // Write some bytes - memcpy(buf, "Hello ", strlen("Hello ")); - buf += strlen("Hello "); + const char *hello = "Hello "; + memcpy(buf, hello, strlen(hello)); + buf += strlen(hello); // Allocate 10 more bytes buf = PyBytesWriter_GrowAndUpdatePointer(writer, 10, buf); @@ -322,8 +435,9 @@ byteswriter_resize(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) } // Write more bytes - memcpy(buf, "World", strlen("World")); - buf += strlen("World"); + const char *world = "World"; + memcpy(buf, world, strlen(world)); + buf += strlen(world); // Truncate to the exact size and create a bytes object return PyBytesWriter_FinishWithPointer(writer, buf); @@ -351,12 +465,171 @@ byteswriter_highlevel(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) } +static size_t +pybyteswriter_small_buffer_size(void) +{ + return offsetof(PyBytesWriter, obj); +} + + +// Test the "Pointer" API of PyBytesWriter +static PyObject * +test_byteswriter_ptr(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) +{ + // Test PyBytesWriter_FinishWithPointer(): create the string "abc" + PyBytesWriter *writer = PyBytesWriter_Create(3); + if (writer == NULL) { + return NULL; + } + char *str = PyBytesWriter_GetData(writer); + memcpy(str, "abc", 3); + str += 3; + PyObject *result = PyBytesWriter_FinishWithPointer(writer, str); + if (result == NULL) { + return NULL; + } + assert(PyBytes_GET_SIZE(result) == 3); + assert(memcmp(PyBytes_AS_STRING(result), "abc", 3) == 0); + Py_DECREF(result); + + // Test PyBytesWriter_GrowAndUpdatePointer(). + // Start by using the small buffer, and then resize to use a bytes object. + writer = PyBytesWriter_Create(0); + if (writer == NULL) { + return NULL; + } + str = PyBytesWriter_GetData(writer); + + str = PyBytesWriter_GrowAndUpdatePointer(writer, 100, str); + if (str == NULL) { + PyBytesWriter_Discard(writer); + return NULL; + } + memset(str, 'x', 100); + str += 100; + + // make sure that the test switches to a bytes object + assert((100 + 200) > pybyteswriter_small_buffer_size()); + char *old_str = str; + str = PyBytesWriter_GrowAndUpdatePointer(writer, 200, str); + if (str == NULL) { + PyBytesWriter_Discard(writer); + return NULL; + } + // make sure that we moved from the small buffer to a bytes object + assert(str != old_str); + memset(str, 'y', 200); + str += 200; + + result = PyBytesWriter_FinishWithPointer(writer, str); + if (result == NULL) { + return NULL; + } + assert(PyBytes_GET_SIZE(result) == 300); + str = PyBytes_AS_STRING(result); + for (Py_ssize_t i = 0; i < 100; i++) { + assert(str[i] == 'x'); + } + for (Py_ssize_t i = 0; i < 200; i++) { + assert(str[100 + i] == 'y'); + } + Py_DECREF(result); + + // Check that PyBytesWriter_FinishWithPointer() rejects pointer + // after the buffer end (create a string larger than the allocated size) + writer = PyBytesWriter_Create(3); + if (writer == NULL) { + return NULL; + } + str = PyBytesWriter_GetData(writer); + memcpy(str, "abc", 3); + str += 4; // off-by-one bug on purpose + result = PyBytesWriter_FinishWithPointer(writer, str); + assert(result == NULL); + assert(PyErr_ExceptionMatches(PyExc_ValueError)); + PyErr_Clear(); + + // Check that PyBytesWriter_FinishWithPointer() rejects pointer + // before the buffer start (negative size) + writer = PyBytesWriter_Create(3); + if (writer == NULL) { + return NULL; + } + str = PyBytesWriter_GetData(writer); + str--; // bug on purpose: go before the buffer start + result = PyBytesWriter_FinishWithPointer(writer, str); + assert(result == NULL); + assert(PyErr_ExceptionMatches(PyExc_ValueError)); + PyErr_Clear(); + + Py_RETURN_NONE; +} + + +static PyObject * +bytes_overflow(PyObject *Py_UNUSED(module), PyObject *args) +{ + Py_ssize_t alloc, overflow = 1; + if (!PyArg_ParseTuple(args, "n|n", &alloc, &overflow)) + return NULL; + + PyObject *bytes = PyObject_CallFunction((PyObject*)&PyBytes_Type, "n", alloc); + if (bytes == NULL) { + return NULL; + } + + char *data = PyBytes_AS_STRING(bytes); + Py_ssize_t size = PyBytes_GET_SIZE(bytes); + memset(data, 'x', size); + memset(data + size, '#', overflow); // Buffer overflow! + return bytes; +} + + +static PyObject * +bytearray_overflow(PyObject *Py_UNUSED(module), PyObject *args) +{ + Py_ssize_t alloc, overflow = 1; + if (!PyArg_ParseTuple(args, "n|n", &alloc, &overflow)) + return NULL; + + PyObject *bytearray = PyObject_CallFunction((PyObject*)&PyByteArray_Type, "n", alloc); + if (bytearray == NULL) { + return NULL; + } + + char *data = PyByteArray_AS_STRING(bytearray); + Py_ssize_t size = PyByteArray_GET_SIZE(bytearray); + memset(data + size, '#', overflow); // Buffer overflow! + return bytearray; +} + + +// Write into an immutable bytes object to test _PyStaticObjects_CheckAll() +static PyObject * +corrupt_bytes(PyObject *Py_UNUSED(module), PyObject *args) +{ + char *bytes, *override; + Py_ssize_t size; + if (!PyArg_ParseTuple(args, "yy#", &bytes, &override, &size)) { + return NULL; + } + + memcpy(bytes, override, size); + Py_RETURN_NONE; +} + + static PyMethodDef test_methods[] = { - {"bytes_resize", bytes_resize, METH_VARARGS}, + {"bytes_resize", _PyCFunction_CAST(bytes_resize), METH_VARARGS | METH_KEYWORDS}, {"bytes_join", bytes_join, METH_VARARGS}, {"byteswriter_abc", byteswriter_abc, METH_NOARGS}, {"byteswriter_resize", byteswriter_resize, METH_NOARGS}, {"byteswriter_highlevel", byteswriter_highlevel, METH_NOARGS}, + {"test_byteswriter_ptr", test_byteswriter_ptr, METH_NOARGS}, + {"bytes_overflow", bytes_overflow, METH_VARARGS}, + {"bytearray_overflow", bytearray_overflow, METH_VARARGS}, + {"corrupt_bytes", corrupt_bytes, METH_VARARGS}, {NULL}, }; @@ -377,5 +650,11 @@ _PyTestCapi_Init_Bytes(PyObject *m) } Py_DECREF(writer_type); + // PyBytesWriter.obj is the second member, small_buffer is the first member + long size = (long)pybyteswriter_small_buffer_size(); + if (PyModule_AddIntConstant(m, "PyBytesWriter_small_buffer", size) < 0) { + return -1; + } + return 0; } diff --git a/Modules/_testcapi/clinic/exceptions.c.h b/Modules/_testcapi/clinic/exceptions.c.h index cac5d288f437b72..21eee65cbde8a50 100644 --- a/Modules/_testcapi/clinic/exceptions.c.h +++ b/Modules/_testcapi/clinic/exceptions.c.h @@ -7,6 +7,7 @@ preserve # include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(_testcapi_err_set_raised__doc__, "err_set_raised($module, exception, /)\n" @@ -16,6 +17,37 @@ PyDoc_STRVAR(_testcapi_err_set_raised__doc__, #define _TESTCAPI_ERR_SET_RAISED_METHODDEF \ {"err_set_raised", (PyCFunction)_testcapi_err_set_raised, METH_O, _testcapi_err_set_raised__doc__}, +PyDoc_STRVAR(_testcapi_err_givenexceptionmatches__doc__, +"err_givenexceptionmatches($module, err, exc, /)\n" +"--\n" +"\n" +"Test PyErr_GivenExceptionMatches()."); + +#define _TESTCAPI_ERR_GIVENEXCEPTIONMATCHES_METHODDEF \ + {"err_givenexceptionmatches", _PyCFunction_CAST(_testcapi_err_givenexceptionmatches), METH_FASTCALL, _testcapi_err_givenexceptionmatches__doc__}, + +static PyObject * +_testcapi_err_givenexceptionmatches_impl(PyObject *module, PyObject *err, + PyObject *exc); + +static PyObject * +_testcapi_err_givenexceptionmatches(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *err; + PyObject *exc; + + if (!_PyArg_CheckPositional("err_givenexceptionmatches", nargs, 2, 2)) { + goto exit; + } + err = args[0]; + exc = args[1]; + return_value = _testcapi_err_givenexceptionmatches_impl(module, err, exc); + +exit: + return return_value; +} + PyDoc_STRVAR(_testcapi_exception_print__doc__, "exception_print($module, exception, legacy=False, /)\n" "--\n" @@ -115,15 +147,10 @@ _testcapi_make_exception_with_doc(PyObject *module, PyObject *const *args, Py_ss _PyArg_BadArgument("make_exception_with_doc", "argument 'name'", "str", args[0]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(args[0], &name_length); + name = _PyUnicode_AsUTF8NoNUL(args[0]); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!noptargs) { goto skip_optional_pos; } @@ -132,15 +159,10 @@ _testcapi_make_exception_with_doc(PyObject *module, PyObject *const *args, Py_ss _PyArg_BadArgument("make_exception_with_doc", "argument 'doc'", "str", args[1]); goto exit; } - Py_ssize_t doc_length; - doc = PyUnicode_AsUTF8AndSize(args[1], &doc_length); + doc = _PyUnicode_AsUTF8NoNUL(args[1]); if (doc == NULL) { goto exit; } - if (strlen(doc) != (size_t)doc_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_pos; } @@ -238,7 +260,7 @@ _testcapi_err_setstring(PyObject *module, PyObject *const *args, Py_ssize_t narg const char *value; Py_ssize_t value_length; - if (!_PyArg_ParseStack(args, nargs, "Oz#:err_setstring", + if (!PyArg_ParseArray(args, nargs, "Oz#:err_setstring", &exc, &value, &value_length)) { goto exit; } @@ -270,7 +292,7 @@ _testcapi_err_setfromerrnowithfilename(PyObject *module, PyObject *const *args, const char *value; Py_ssize_t value_length; - if (!_PyArg_ParseStack(args, nargs, "iOz#:err_setfromerrnowithfilename", + if (!PyArg_ParseArray(args, nargs, "iOz#:err_setfromerrnowithfilename", &error, &exc, &value, &value_length)) { goto exit; } @@ -348,7 +370,7 @@ _testcapi_fatal_error(PyObject *module, PyObject *const *args, Py_ssize_t nargs) const char *message; int release_gil = 0; - if (!_PyArg_ParseStack(args, nargs, "y|p:fatal_error", + if (!PyArg_ParseArray(args, nargs, "y|p:fatal_error", &message, &release_gil)) { goto exit; } @@ -459,4 +481,4 @@ _testcapi_unstable_exc_prep_reraise_star(PyObject *module, PyObject *const *args exit: return return_value; } -/*[clinic end generated code: output=357caea020348789 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=93dfd0e1ca2253b6 input=a9049054013a1b77]*/ diff --git a/Modules/_testcapi/clinic/file.c.h b/Modules/_testcapi/clinic/file.c.h index 08df729cb977386..5e8b8562ac6e533 100644 --- a/Modules/_testcapi/clinic/file.c.h +++ b/Modules/_testcapi/clinic/file.c.h @@ -52,7 +52,7 @@ _testcapi_py_fopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs) const char *mode; Py_ssize_t mode_length; - if (!_PyArg_ParseStack(args, nargs, "Oz#:py_fopen", + if (!PyArg_ParseArray(args, nargs, "Oz#:py_fopen", &path, &mode, &mode_length)) { goto exit; } @@ -95,4 +95,4 @@ _testcapi_py_universalnewlinefgets(PyObject *module, PyObject *const *args, Py_s exit: return return_value; } -/*[clinic end generated code: output=a5ed111054e3a0bc input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8079c9d50d559d71 input=a9049054013a1b77]*/ diff --git a/Modules/_testcapi/clinic/float.c.h b/Modules/_testcapi/clinic/float.c.h index d5a00c8072da1ef..b56b74a3536f931 100644 --- a/Modules/_testcapi/clinic/float.c.h +++ b/Modules/_testcapi/clinic/float.c.h @@ -72,7 +72,7 @@ _testcapi_float_unpack(PyObject *module, PyObject *const *args, Py_ssize_t nargs Py_ssize_t data_length; int le; - if (!_PyArg_ParseStack(args, nargs, "y#i:float_unpack", + if (!PyArg_ParseArray(args, nargs, "y#i:float_unpack", &data, &data_length, &le)) { goto exit; } @@ -81,4 +81,4 @@ _testcapi_float_unpack(PyObject *module, PyObject *const *args, Py_ssize_t nargs exit: return return_value; } -/*[clinic end generated code: output=b43dfd3a77fe04ba input=a9049054013a1b77]*/ +/*[clinic end generated code: output=397689b93b97e397 input=a9049054013a1b77]*/ diff --git a/Modules/_testcapi/complex.c b/Modules/_testcapi/complex.c index fb5234d03cf0676..f1bbeb4804a1918 100644 --- a/Modules/_testcapi/complex.c +++ b/Modules/_testcapi/complex.c @@ -76,7 +76,6 @@ _py_c_abs(PyObject *Py_UNUSED(module), PyObject* obj) return NULL; } - errno = 0; res = _Py_c_abs(complex); return Py_BuildValue("di", res, errno); } diff --git a/Modules/_testcapi/dict.c b/Modules/_testcapi/dict.c index 172591b03182abf..5e169d99c179d57 100644 --- a/Modules/_testcapi/dict.c +++ b/Modules/_testcapi/dict.c @@ -257,6 +257,13 @@ test_dict_iteration(PyObject* self, PyObject *Py_UNUSED(ignored)) Py_RETURN_NONE; } +static PyObject * +dict_as_frozendict_and_clear(PyObject *self, PyObject *obj) +{ + NULLABLE(obj); + return PyDict_AsFrozenDictAndClear(obj); +} + static PyObject * frozendict_check(PyObject *self, PyObject *obj) @@ -306,6 +313,7 @@ static PyMethodDef test_methods[] = { {"dict_popstring", dict_popstring, METH_VARARGS}, {"dict_popstring_null", dict_popstring_null, METH_VARARGS}, {"test_dict_iteration", test_dict_iteration, METH_NOARGS}, + {"dict_as_frozendict_and_clear", dict_as_frozendict_and_clear, METH_O}, {"frozendict_check", frozendict_check, METH_O}, {"frozendict_checkexact", frozendict_checkexact, METH_O}, {"anydict_check", anydict_check, METH_O}, diff --git a/Modules/_testcapi/exceptions.c b/Modules/_testcapi/exceptions.c index c0254e044bc2d5f..cc62b47c99414a0 100644 --- a/Modules/_testcapi/exceptions.c +++ b/Modules/_testcapi/exceptions.c @@ -54,6 +54,26 @@ err_restore(PyObject *self, PyObject *args) { return NULL; } +/*[clinic input] +_testcapi.err_givenexceptionmatches + err: object + exc: object + / + +Test PyErr_GivenExceptionMatches(). +[clinic start generated code]*/ + +static PyObject * +_testcapi_err_givenexceptionmatches_impl(PyObject *module, PyObject *err, + PyObject *exc) +/*[clinic end generated code: output=e40994ab6dd75001 input=7b8ef542df07575b]*/ +{ + assert(!PyErr_Occurred()); + int res = PyErr_GivenExceptionMatches(err, exc); + assert(!PyErr_Occurred()); + return PyBool_FromLong(res); +} + /*[clinic input] _testcapi.exception_print exception as exc: object @@ -552,6 +572,7 @@ static PyMethodDef test_methods[] = { _TESTCAPI_MAKE_EXCEPTION_WITH_DOC_METHODDEF _TESTCAPI_EXC_SET_OBJECT_METHODDEF _TESTCAPI_EXC_SET_OBJECT_FETCH_METHODDEF + _TESTCAPI_ERR_GIVENEXCEPTIONMATCHES_METHODDEF _TESTCAPI_ERR_SETSTRING_METHODDEF _TESTCAPI_ERR_SETFROMERRNOWITHFILENAME_METHODDEF _TESTCAPI_RAISE_EXCEPTION_METHODDEF diff --git a/Modules/_testcapi/fpcast.c b/Modules/_testcapi/fpcast.c new file mode 100644 index 000000000000000..ed6e2d3c5c5e6d9 --- /dev/null +++ b/Modules/_testcapi/fpcast.c @@ -0,0 +1,164 @@ +/* + * Tests for Python/wasm_trampoline.c + * + * Third party extensions frequently cast functions with the "wrong" number of + * arguments to PyCFunction, getter, setter or ternaryfunc. On native targets + * this works by accident. On WebAssembly, call_indirect checks the signature + * and traps, so CPython routes these calls through a trampoline that detects + * the real signature. + */ + +#include "parts.h" + +static PyObject * +zero(void) +{ + Py_RETURN_NONE; +} + +static PyObject * +one(PyObject *self) +{ + Py_RETURN_NONE; +} + +static PyObject * +two(PyObject *self, PyObject *args) +{ + Py_RETURN_NONE; +} + +static PyObject * +three(PyObject *self, PyObject *args, PyObject *kwargs) +{ + Py_RETURN_NONE; +} + +// Using this as a handler should raise a SystemError. +static PyObject * +four(PyObject *self, PyObject *a, PyObject *b, PyObject *c) +{ + Py_RETURN_NONE; +} + +static int +set_two(PyObject *self, PyObject *value) +{ + return 0; +} + +static PyObject *last_set_value = NULL; + +static int +set_three(PyObject *self, PyObject *value, void *closure) +{ + Py_XSETREF(last_set_value, Py_XNewRef(value)); + return 0; +} + +static PyObject * +get_last_set_value(PyObject *self, PyObject *Py_UNUSED(args)) +{ + if (last_set_value == NULL) { + Py_RETURN_NONE; + } + return Py_NewRef(last_set_value); +} + +#define FPCAST_METHODS(prefix) \ + {prefix "noargs0", _PyCFunction_CAST(zero), METH_NOARGS}, \ + {prefix "noargs1", _PyCFunction_CAST(one), METH_NOARGS}, \ + {prefix "noargs2", _PyCFunction_CAST(two), METH_NOARGS}, \ + {prefix "noargs3", _PyCFunction_CAST(three), METH_NOARGS}, \ + {prefix "noargs4", _PyCFunction_CAST(four), METH_NOARGS}, \ + \ + {prefix "o0", _PyCFunction_CAST(zero), METH_O}, \ + {prefix "o1", _PyCFunction_CAST(one), METH_O}, \ + {prefix "o2", _PyCFunction_CAST(two), METH_O}, \ + {prefix "o3", _PyCFunction_CAST(three), METH_O}, \ + \ + {prefix "varargs0", _PyCFunction_CAST(zero), METH_VARARGS}, \ + {prefix "varargs1", _PyCFunction_CAST(one), METH_VARARGS}, \ + {prefix "varargs2", _PyCFunction_CAST(two), METH_VARARGS}, \ + {prefix "varargs3", _PyCFunction_CAST(three), METH_VARARGS}, \ + \ + {prefix "kwargs0", _PyCFunction_CAST(zero), \ + METH_VARARGS | METH_KEYWORDS}, \ + {prefix "kwargs1", _PyCFunction_CAST(one), \ + METH_VARARGS | METH_KEYWORDS}, \ + {prefix "kwargs2", _PyCFunction_CAST(two), \ + METH_VARARGS | METH_KEYWORDS}, \ + {prefix "kwargs3", _PyCFunction_CAST(three), \ + METH_VARARGS | METH_KEYWORDS} + +static PyMethodDef test_methods[] = { + FPCAST_METHODS("fpcast_"), + {"fpcast_last_set_value", get_last_set_value, METH_NOARGS}, + {NULL}, +}; + +static PyMethodDef type_methods[] = { + FPCAST_METHODS(""), + {NULL}, +}; + +static PyGetSetDef type_getset[] = { + {"getset0", .get = _Py_FUNC_CAST(getter, zero)}, + {"getset1", .get = _Py_FUNC_CAST(getter, one), + .set = _Py_FUNC_CAST(setter, set_two)}, + {"getset2", .get = _Py_FUNC_CAST(getter, two), + .set = _Py_FUNC_CAST(setter, set_three)}, + {"getset4", .get = _Py_FUNC_CAST(getter, four), + .set = _Py_FUNC_CAST(setter, four)}, + {NULL}, +}; + +static PyTypeObject FpcastTestType = { + PyVarObject_HEAD_INIT(NULL, 0) + .tp_name = "_testcapi.FpcastTestType", + .tp_basicsize = sizeof(PyObject), + .tp_flags = Py_TPFLAGS_DEFAULT, + .tp_methods = type_methods, + .tp_getset = type_getset, + .tp_new = PyType_GenericNew, +}; + +#define CALLABLE_TYPE(N, FUNC) \ + static PyTypeObject FpcastCallable##N = { \ + PyVarObject_HEAD_INIT(NULL, 0) \ + .tp_name = "_testcapi.FpcastCallable" #N, \ + .tp_basicsize = sizeof(PyObject), \ + .tp_flags = Py_TPFLAGS_DEFAULT, \ + .tp_call = _Py_FUNC_CAST(ternaryfunc, FUNC), \ + .tp_new = PyType_GenericNew, \ + }; + +CALLABLE_TYPE(0, zero) +CALLABLE_TYPE(1, one) +CALLABLE_TYPE(2, two) +CALLABLE_TYPE(3, three) +CALLABLE_TYPE(4, four) + +#undef CALLABLE_TYPE + +int +_PyTestCapi_Init_Fpcast(PyObject *mod) +{ + if (PyModule_AddFunctions(mod, test_methods) < 0) { + return -1; + } + PyTypeObject *types[] = { + &FpcastTestType, + &FpcastCallable0, + &FpcastCallable1, + &FpcastCallable2, + &FpcastCallable3, + &FpcastCallable4, + }; + for (size_t i = 0; i < Py_ARRAY_LENGTH(types); i++) { + if (PyModule_AddType(mod, types[i]) < 0) { + return -1; + } + } + return 0; +} diff --git a/Modules/_testcapi/function.c b/Modules/_testcapi/function.c index 40767adbd3f14a7..28420ce19f112e9 100644 --- a/Modules/_testcapi/function.c +++ b/Modules/_testcapi/function.c @@ -38,6 +38,13 @@ function_get_module(PyObject *self, PyObject *func) } +static PyObject * +function_get_module_macro(PyObject *self, PyObject *func) +{ + return Py_XNewRef(PyFunction_GET_MODULE(func)); +} + + static PyObject * function_get_defaults(PyObject *self, PyObject *func) { @@ -134,6 +141,7 @@ static PyMethodDef test_methods[] = { {"function_get_code", function_get_code, METH_O, NULL}, {"function_get_globals", function_get_globals, METH_O, NULL}, {"function_get_module", function_get_module, METH_O, NULL}, + {"function_get_module_macro", function_get_module_macro, METH_O, NULL}, {"function_get_defaults", function_get_defaults, METH_O, NULL}, {"function_set_defaults", function_set_defaults, METH_VARARGS, NULL}, {"function_get_kw_defaults", function_get_kw_defaults, METH_O, NULL}, diff --git a/Modules/_testcapi/gc.c b/Modules/_testcapi/gc.c index 863cb52980f9425..dac7066565f7ffc 100644 --- a/Modules/_testcapi/gc.c +++ b/Modules/_testcapi/gc.c @@ -195,6 +195,57 @@ test_gc_visit_objects_basic(PyObject *Py_UNUSED(self), Py_RETURN_NONE; } +static int +gc_call_no_args(const char *method) +{ + PyObject *gc = PyImport_ImportModule("gc"); + if (gc == NULL) { + return -1; + } + PyObject *res = PyObject_CallMethod(gc, method, NULL); + Py_DECREF(gc); + if (res == NULL) { + return -1; + } + Py_DECREF(res); + return 0; +} + +// gh-131740: frozen objects must be visited too. +static PyObject * +test_gc_visit_objects_frozen(PyObject *Py_UNUSED(self), + PyObject *Py_UNUSED(ignored)) +{ + PyObject *obj; + struct gc_visit_state_basic state; + + obj = PyList_New(0); + if (obj == NULL) { + return NULL; + } + if (gc_call_no_args("freeze") < 0) { + Py_DECREF(obj); + return NULL; + } + state.target = obj; + state.found = 0; + + PyUnstable_GC_VisitObjects(gc_visit_callback_basic, &state); + + int err = gc_call_no_args("unfreeze"); + Py_DECREF(obj); + if (err < 0) { + return NULL; + } + if (!state.found) { + PyErr_SetString( + PyExc_AssertionError, + "test_gc_visit_objects_frozen: Didn't find frozen list"); + return NULL; + } + Py_RETURN_NONE; +} + static int gc_visit_callback_exit_early(PyObject *obj, void *arg) { @@ -316,6 +367,7 @@ static PyType_Spec ObjExtraData_TypeSpec = { static PyMethodDef test_methods[] = { {"test_gc_control", test_gc_control, METH_NOARGS}, {"test_gc_visit_objects_basic", test_gc_visit_objects_basic, METH_NOARGS, NULL}, + {"test_gc_visit_objects_frozen", test_gc_visit_objects_frozen, METH_NOARGS, NULL}, {"test_gc_visit_objects_exit_early", test_gc_visit_objects_exit_early, METH_NOARGS, NULL}, {"without_gc", without_gc, METH_O, NULL}, {"with_tp_del", with_tp_del, METH_VARARGS, NULL}, diff --git a/Modules/_testcapi/hash.c b/Modules/_testcapi/hash.c index 1525344a93fbcf0..87d535c585cc27a 100644 --- a/Modules/_testcapi/hash.c +++ b/Modules/_testcapi/hash.c @@ -66,20 +66,6 @@ hash_pointer(PyObject *Py_UNUSED(module), PyObject *arg) } -static PyObject * -hash_buffer(PyObject *Py_UNUSED(module), PyObject *args) -{ - char *ptr; - Py_ssize_t len; - if (!PyArg_ParseTuple(args, "y#", &ptr, &len)) { - return NULL; - } - - Py_hash_t hash = Py_HashBuffer(ptr, len); - return long_from_hash(hash); -} - - static PyObject * object_generichash(PyObject *Py_UNUSED(module), PyObject *arg) { @@ -92,7 +78,6 @@ object_generichash(PyObject *Py_UNUSED(module), PyObject *arg) static PyMethodDef test_methods[] = { {"hash_getfuncdef", hash_getfuncdef, METH_NOARGS}, {"hash_pointer", hash_pointer, METH_O}, - {"hash_buffer", hash_buffer, METH_VARARGS}, {"object_generichash", object_generichash, METH_O}, {NULL}, }; diff --git a/Modules/_testcapi/long.c b/Modules/_testcapi/long.c index 008a7d37726869b..65daa249acdd0a2 100644 --- a/Modules/_testcapi/long.c +++ b/Modules/_testcapi/long.c @@ -281,6 +281,21 @@ get_pylong_layout(PyObject *module, PyObject *Py_UNUSED(args)) } +// Write into an immutable int object to test _PyStaticObjects_CheckAll() +static PyObject * +corrupt_long(PyObject *Py_UNUSED(module), PyObject *args) +{ + PyObject *obj; + int value; + if (!PyArg_ParseTuple(args, "Oi", &obj, &value)) { + return NULL; + } + + ((PyLongObject*)obj)->long_value.ob_digit[0] = value; + Py_RETURN_NONE; +} + + static PyMethodDef test_methods[] = { _TESTCAPI_CALL_LONG_COMPACT_API_METHODDEF {"pylong_fromunicodeobject", pylong_fromunicodeobject, METH_VARARGS}, @@ -295,6 +310,7 @@ static PyMethodDef test_methods[] = { {"pylong_ispositive", pylong_ispositive, METH_O}, {"pylong_isnegative", pylong_isnegative, METH_O}, {"pylong_iszero", pylong_iszero, METH_O}, + {"corrupt_long", corrupt_long, METH_VARARGS}, {NULL}, }; diff --git a/Modules/_testcapi/marshal.c b/Modules/_testcapi/marshal.c new file mode 100644 index 000000000000000..cf5c2250dfe6097 --- /dev/null +++ b/Modules/_testcapi/marshal.c @@ -0,0 +1,228 @@ +// Test PyMarshal C API + +#include "parts.h" +#include "util.h" +#include "marshal.h" // PyMarshal_WriteLongToFile() + + +// Test PyMarshal_WriteLongToFile() +static PyObject* +pymarshal_write_long_to_file(PyObject* self, PyObject *args) +{ + long value; + PyObject *filename; + int version; + + if (!PyArg_ParseTuple(args, "lOi:pymarshal_write_long_to_file", + &value, &filename, &version)) + return NULL; + + FILE *fp = Py_fopen(filename, "wb"); + if (fp == NULL) { + return NULL; + } + + assert(!PyErr_Occurred()); + PyMarshal_WriteLongToFile(value, fp, version); + + fclose(fp); + if (PyErr_Occurred()) { + return NULL; + } + Py_RETURN_NONE; +} + + +// Test PyMarshal_WriteObjectToFile() +static PyObject* +pymarshal_write_object_to_file(PyObject* self, PyObject *args) +{ + PyObject *obj; + PyObject *filename; + int version; + + if (!PyArg_ParseTuple(args, "OOi:pymarshal_write_object_to_file", + &obj, &filename, &version)) { + return NULL; + } + NULLABLE(obj); + + FILE *fp = Py_fopen(filename, "wb"); + if (fp == NULL) { + return NULL; + } + + assert(!PyErr_Occurred()); + PyMarshal_WriteObjectToFile(obj, fp, version); + fclose(fp); + if (PyErr_Occurred()) { + return NULL; + } + + Py_RETURN_NONE; +} + + +// Test PyMarshal_ReadShortFromFile() +static PyObject* +pymarshal_read_short_from_file(PyObject* self, PyObject *args) +{ + int value; + long pos; + PyObject *filename; + if (!PyArg_ParseTuple(args, "O:pymarshal_read_short_from_file", &filename)) + return NULL; + + FILE *fp = Py_fopen(filename, "rb"); + if (fp == NULL) { + return NULL; + } + + assert(!PyErr_Occurred()); + value = PyMarshal_ReadShortFromFile(fp); + pos = ftell(fp); + + fclose(fp); + if (PyErr_Occurred()) { + assert(value == -1); + return NULL; + } + + assert(pos == 2); + return PyLong_FromLong(value); +} + + +// Test PyMarshal_ReadLongFromFile() +static PyObject* +pymarshal_read_long_from_file(PyObject* self, PyObject *args) +{ + long pos; + PyObject *filename; + if (!PyArg_ParseTuple(args, "O:pymarshal_read_long_from_file", &filename)) + return NULL; + + FILE *fp = Py_fopen(filename, "rb"); + if (fp == NULL) { + return NULL; + } + + assert(!PyErr_Occurred()); + long value = PyMarshal_ReadLongFromFile(fp); + pos = ftell(fp); + + fclose(fp); + if (PyErr_Occurred()) { + assert(value == -1); + return NULL; + } + + assert(pos == 4); + return PyLong_FromLong(value); +} + + +// Test PyMarshal_ReadLastObjectFromFile() +static PyObject* +pymarshal_read_last_object_from_file(PyObject* self, PyObject *args) +{ + PyObject *filename; + if (!PyArg_ParseTuple(args, "O:pymarshal_read_last_object_from_file", &filename)) + return NULL; + + FILE *fp = Py_fopen(filename, "rb"); + if (fp == NULL) { + return NULL; + } + + assert(!PyErr_Occurred()); + PyObject *obj = PyMarshal_ReadLastObjectFromFile(fp); + long pos = ftell(fp); + + fclose(fp); + if (obj == NULL) { + return NULL; + } + return Py_BuildValue("Nl", obj, pos); +} + + +// Test PyMarshal_ReadObjectFromFile() +static PyObject* +pymarshal_read_object_from_file(PyObject* self, PyObject *args) +{ + PyObject *filename; + if (!PyArg_ParseTuple(args, "O:pymarshal_read_object_from_file", &filename)) + return NULL; + + FILE *fp = Py_fopen(filename, "rb"); + if (fp == NULL) { + return NULL; + } + + assert(!PyErr_Occurred()); + PyObject *obj = PyMarshal_ReadObjectFromFile(fp); + long pos = ftell(fp); + + fclose(fp); + if (obj == NULL) { + return NULL; + } + return Py_BuildValue("Nl", obj, pos); +} + + +// Test PyMarshal_ReadObjectFromString() +static PyObject* +pymarshal_readobjectfromstring(PyObject* self, PyObject *args) +{ + const char *str; + Py_ssize_t size; + if (!PyArg_ParseTuple(args, "s#", &str, &size)) { + return NULL; + } + + return PyMarshal_ReadObjectFromString(str, size); +} + + +// Test PyMarshal_WriteObjectToString() +static PyObject* +pymarshal_writeobjecttostring(PyObject* self, PyObject *args) +{ + PyObject *obj; + int version; + if (!PyArg_ParseTuple(args, "Oi", &obj, &version)) { + return NULL; + } + NULLABLE(obj); + + return PyMarshal_WriteObjectToString(obj, version); +} + + +static PyMethodDef test_methods[] = { + {"pymarshal_write_long_to_file", + pymarshal_write_long_to_file, METH_VARARGS}, + {"pymarshal_write_object_to_file", + pymarshal_write_object_to_file, METH_VARARGS}, + {"pymarshal_read_short_from_file", + pymarshal_read_short_from_file, METH_VARARGS}, + {"pymarshal_read_long_from_file", + pymarshal_read_long_from_file, METH_VARARGS}, + {"pymarshal_read_last_object_from_file", + pymarshal_read_last_object_from_file, METH_VARARGS}, + {"pymarshal_read_object_from_file", + pymarshal_read_object_from_file, METH_VARARGS}, + {"pymarshal_readobjectfromstring", + pymarshal_readobjectfromstring, METH_VARARGS}, + {"pymarshal_writeobjecttostring", + pymarshal_writeobjecttostring, METH_VARARGS}, + {NULL}, +}; + +int +_PyTestCapi_Init_Marshal(PyObject *mod) +{ + return PyModule_AddFunctions(mod, test_methods); +} diff --git a/Modules/_testcapi/mem.c b/Modules/_testcapi/mem.c index 28e89275d61705e..822ae661944a24b 100644 --- a/Modules/_testcapi/mem.c +++ b/Modules/_testcapi/mem.c @@ -13,6 +13,8 @@ # include // proc_pidinfo(), PROC_PIDTASKINFO # include // struct proc_taskinfo # endif +#else +# define TARGET_OS_OSX 0 #endif #ifdef __FreeBSD__ @@ -177,18 +179,29 @@ fm_remove_hooks(void) } } +static void +fm_set_nomemory(int start, int stop) +{ + /* Memory allocation fails after 'start' allocation requests, and until + * 'stop' allocation requests except when 'stop' is negative or equal + * to 0 (default) in which case allocation failures never stop. */ + FmData.start = start; + FmData.stop = stop; + FmData.count = 0; + fm_setup_hooks(); +} + static PyObject * set_nomemory(PyObject *self, PyObject *args) { /* Memory allocation fails after 'start' allocation requests, and until * 'stop' allocation requests except when 'stop' is negative or equal * to 0 (default) in which case allocation failures never stop. */ - FmData.count = 0; - FmData.stop = 0; - if (!PyArg_ParseTuple(args, "i|i", &FmData.start, &FmData.stop)) { + int start, stop = 0; + if (!PyArg_ParseTuple(args, "i|i", &start, &stop)) { return NULL; } - fm_setup_hooks(); + fm_set_nomemory(start, stop); Py_RETURN_NONE; } @@ -199,6 +212,39 @@ remove_mem_hooks(PyObject *self, PyObject *Py_UNUSED(ignored)) Py_RETURN_NONE; } +static PyObject * +call_with_nomemory(PyObject *self, PyObject *args) +{ + /* Call func(*args) with memory allocation failing as in set_nomemory(). + * No bytecode is executed between arming the failure and the call. */ + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + if (nargs < 3) { + PyErr_SetString(PyExc_TypeError, + "call_with_nomemory() requires at least 3 arguments"); + return NULL; + } + int start = PyLong_AsInt(PyTuple_GET_ITEM(args, 0)); + if (start == -1 && PyErr_Occurred()) { + return NULL; + } + int stop = PyLong_AsInt(PyTuple_GET_ITEM(args, 1)); + if (stop == -1 && PyErr_Occurred()) { + return NULL; + } + PyObject *func = PyTuple_GET_ITEM(args, 2); + /* PyObject_Call() with a prebuilt tuple does not allocate, + * unlike PyObject_Vectorcall() for a callee without vectorcall. */ + PyObject *callargs = PyTuple_GetSlice(args, 3, nargs); + if (callargs == NULL) { + return NULL; + } + fm_set_nomemory(start, stop); + PyObject *res = PyObject_Call(func, callargs, NULL); + fm_remove_hooks(); + Py_DECREF(callargs); + return res; +} + static PyObject * test_setallocators(PyMemAllocatorDomain domain) { @@ -437,6 +483,7 @@ test_pyobject_new(PyObject *self, PyObject *Py_UNUSED(ignored)) if (obj == NULL) { goto alloc_failed; } + memset(PyBytes_AS_STRING(obj), 0, 3 + 1); // +1 for the null byte Py_DECREF(obj); // PyObject_NEW_VAR() @@ -444,6 +491,7 @@ test_pyobject_new(PyObject *self, PyObject *Py_UNUSED(ignored)) if (obj == NULL) { goto alloc_failed; } + memset(PyBytes_AS_STRING(obj), 0, 3 + 1); // +1 for the null byte Py_DECREF(obj); Py_RETURN_NONE; @@ -821,6 +869,129 @@ get_process_memory_usage(PyObject *self, PyObject *args) #endif +struct bytes_resize_tracer { + PyObject *create; + PyObject *destroy; +}; + + +static int +bytes_resize_tracer(PyObject *obj, PyRefTracerEvent event, void* data) +{ + if (event != PyRefTracer_CREATE && event != PyRefTracer_DESTROY) { + return 0; + } + + struct bytes_resize_tracer *tracer = (struct bytes_resize_tracer*)data; + if (!PyBytes_Check(obj)) { + return 0; + } + + switch (event) { + case PyRefTracer_CREATE: + tracer->create = obj; + break; + case PyRefTracer_DESTROY: + tracer->destroy = obj; + break; + default: + break; + } + return 0; +} + + +// When _PyBytes_Resize() resizes a bytes object in-place, check that +// PyRefTracer_DESTROY and PyRefTracer_CREATE events are emitted. +// If no_memory is non-zero, inject MemoryError. +static int +check_bytes_resize_tracer(int no_memory) +{ + PyObject *bytes = NULL; + PyRefTracer old_tracer = NULL; + void *old_tracer_data = NULL; + int restore_tracer = 0; + + bytes = PyBytes_FromString("hello"); + if (bytes == NULL) { + goto error; + } + assert(PyUnstable_Object_IsUniquelyReferenced(bytes)); + + old_tracer = PyRefTracer_GetTracer(&old_tracer_data); + restore_tracer = 1; + + struct bytes_resize_tracer tracer = {0}; + if (PyRefTracer_SetTracer(bytes_resize_tracer, &tracer) != 0) { + goto error; + } + + PyObject *old_bytes = bytes; // borrowed reference + if (no_memory) { + fm_set_nomemory(0, 0); + int res = _PyBytes_Resize(&bytes, 100); + assert(res < 0); + assert(bytes == NULL); + fm_remove_hooks(); + + assert(PyErr_ExceptionMatches(PyExc_MemoryError)); + PyErr_Clear(); + } + else { + if (_PyBytes_Resize(&bytes, 100) < 0) { + assert(bytes == NULL); + goto error; + } + } + + if (tracer.destroy != old_bytes) { + PyErr_SetString(PyExc_AssertionError, "PyRefTracer_DESTROY not seen"); + goto error; + } + + int seen_create; + if (no_memory) { + seen_create = (tracer.create == old_bytes); + } + else { + seen_create = (tracer.create == bytes); + } + if (!seen_create) { + PyErr_SetString(PyExc_AssertionError, "PyRefTracer_CREATE not seen"); + goto error; + } + + Py_CLEAR(bytes); + if (PyRefTracer_SetTracer(old_tracer, old_tracer_data) != 0) { + restore_tracer = 0; + goto error; + } + return 0; + +error: + Py_XDECREF(bytes); + if (restore_tracer) { + if (PyRefTracer_SetTracer(old_tracer, old_tracer_data) != 0) { + return -1; + } + } + return -1; +} + + +static PyObject* +test_bytes_resize_tracer(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + if (check_bytes_resize_tracer(0) < 0) { + return NULL; + } + if (check_bytes_resize_tracer(1) < 0) { + return NULL; + } + Py_RETURN_NONE; +} + + static PyMethodDef test_methods[] = { {"pymem_api_misuse", pymem_api_misuse, METH_NOARGS}, {"pymem_buffer_overflow", pymem_buffer_overflow, METH_NOARGS}, @@ -830,6 +1001,8 @@ static PyMethodDef test_methods[] = { PyDoc_STR("Remove memory hooks.")}, {"set_nomemory", set_nomemory, METH_VARARGS, PyDoc_STR("set_nomemory(start:int, stop:int = 0)")}, + {"call_with_nomemory", call_with_nomemory, METH_VARARGS, + PyDoc_STR("call_with_nomemory(start:int, stop:int, func, /, *args)")}, {"test_pymem_alloc0", test_pymem_alloc0, METH_NOARGS}, {"test_pymem_setallocators", test_pymem_setallocators, METH_NOARGS}, {"test_pymem_setrawallocators", test_pymem_setrawallocators, METH_NOARGS}, @@ -838,6 +1011,7 @@ static PyMethodDef test_methods[] = { #if TARGET_OS_OSX || defined(__FreeBSD__) {"get_process_memory_usage", get_process_memory_usage, METH_VARARGS}, #endif + {"test_bytes_resize_tracer", test_bytes_resize_tracer, METH_NOARGS}, // Tracemalloc tests {"tracemalloc_track", tracemalloc_track, METH_VARARGS}, diff --git a/Modules/_testcapi/object.c b/Modules/_testcapi/object.c index 09a548fd2e24489..1bb038aea654a17 100644 --- a/Modules/_testcapi/object.c +++ b/Modules/_testcapi/object.c @@ -16,6 +16,9 @@ call_pyobject_print(PyObject *self, PyObject * args) } fp = Py_fopen(filename, "w+"); + if (fp == NULL) { + return NULL; + } if (Py_IsTrue(print_raw)) { flags = Py_PRINT_RAW; @@ -32,17 +35,15 @@ call_pyobject_print(PyObject *self, PyObject * args) } static PyObject * -pyobject_print_null(PyObject *self, PyObject *args) +pyobject_print_null(PyObject *self, PyObject *filename) { - PyObject *filename; FILE *fp; - if (!PyArg_UnpackTuple(args, "call_pyobject_print", 1, 1, &filename)) { + fp = Py_fopen(filename, "w+"); + if (fp == NULL) { return NULL; } - fp = Py_fopen(filename, "w+"); - if (PyObject_Print(NULL, fp, 0) < 0) { fclose(fp); return NULL; @@ -54,26 +55,29 @@ pyobject_print_null(PyObject *self, PyObject *args) } static PyObject * -pyobject_print_noref_object(PyObject *self, PyObject *args) +pyobject_print_noref_object(PyObject *self, PyObject *filename) { PyObject *test_string; - PyObject *filename; FILE *fp; char correct_string[100]; test_string = PyUnicode_FromString("Spam spam spam"); + if (test_string == NULL) { + return NULL; + } Py_SET_REFCNT(test_string, 0); PyOS_snprintf(correct_string, 100, "", Py_REFCNT(test_string), (void *)test_string); - if (!PyArg_UnpackTuple(args, "call_pyobject_print", 1, 1, &filename)) { + fp = Py_fopen(filename, "w+"); + if (fp == NULL) { + Py_SET_REFCNT(test_string, 1); + Py_DECREF(test_string); return NULL; } - fp = Py_fopen(filename, "w+"); - if (PyObject_Print(test_string, fp, 0) < 0){ fclose(fp); Py_SET_REFCNT(test_string, 1); @@ -90,20 +94,22 @@ pyobject_print_noref_object(PyObject *self, PyObject *args) } static PyObject * -pyobject_print_os_error(PyObject *self, PyObject *args) +pyobject_print_os_error(PyObject *self, PyObject *filename) { PyObject *test_string; - PyObject *filename; FILE *fp; test_string = PyUnicode_FromString("Spam spam spam"); - - if (!PyArg_UnpackTuple(args, "call_pyobject_print", 1, 1, &filename)) { + if (test_string == NULL) { return NULL; } // open file in read mode to induce OSError fp = Py_fopen(filename, "r"); + if (fp == NULL) { + Py_DECREF(test_string); + return NULL; + } if (PyObject_Print(test_string, fp, 0) < 0) { fclose(fp); @@ -147,6 +153,13 @@ pyobject_is_unique_temporary_new_object(PyObject *self, PyObject *unused) return PyLong_FromLong(result); } +static PyObject * +pyobject_clear_managed_dict(PyObject *self, PyObject *obj) +{ + PyObject_ClearManagedDict(obj); + Py_RETURN_NONE; +} + static int MyObject_dealloc_called = 0; static void @@ -240,63 +253,6 @@ test_py_set_immortal(PyObject *self, PyObject *unused) Py_RETURN_NONE; } -static PyObject * -_test_incref(PyObject *ob) -{ - return Py_NewRef(ob); -} - -static PyObject * -test_xincref_doesnt_leak(PyObject *ob, PyObject *Py_UNUSED(ignored)) -{ - PyObject *obj = PyLong_FromLong(0); - Py_XINCREF(_test_incref(obj)); - Py_DECREF(obj); - Py_DECREF(obj); - Py_DECREF(obj); - Py_RETURN_NONE; -} - - -static PyObject * -test_incref_doesnt_leak(PyObject *ob, PyObject *Py_UNUSED(ignored)) -{ - PyObject *obj = PyLong_FromLong(0); - Py_INCREF(_test_incref(obj)); - Py_DECREF(obj); - Py_DECREF(obj); - Py_DECREF(obj); - Py_RETURN_NONE; -} - - -static PyObject * -test_xdecref_doesnt_leak(PyObject *ob, PyObject *Py_UNUSED(ignored)) -{ - Py_XDECREF(PyLong_FromLong(0)); - Py_RETURN_NONE; -} - - -static PyObject * -test_decref_doesnt_leak(PyObject *ob, PyObject *Py_UNUSED(ignored)) -{ - Py_DECREF(PyLong_FromLong(0)); - Py_RETURN_NONE; -} - - -static PyObject * -test_incref_decref_API(PyObject *ob, PyObject *Py_UNUSED(ignored)) -{ - PyObject *obj = PyLong_FromLong(0); - Py_IncRef(obj); - Py_DecRef(obj); - Py_DecRef(obj); - Py_RETURN_NONE; -} - - #ifdef Py_REF_DEBUG static PyObject * negative_refcount(PyObject *self, PyObject *Py_UNUSED(args)) @@ -337,186 +293,6 @@ decref_freed_object(PyObject *self, PyObject *Py_UNUSED(args)) #endif -// Test Py_CLEAR() macro -static PyObject* -test_py_clear(PyObject *self, PyObject *Py_UNUSED(ignored)) -{ - // simple case with a variable - PyObject *obj = PyList_New(0); - if (obj == NULL) { - return NULL; - } - Py_CLEAR(obj); - assert(obj == NULL); - - // gh-98724: complex case, Py_CLEAR() argument has a side effect - PyObject* array[1]; - array[0] = PyList_New(0); - if (array[0] == NULL) { - return NULL; - } - - PyObject **p = array; - Py_CLEAR(*p++); - assert(array[0] == NULL); - assert(p == array + 1); - - Py_RETURN_NONE; -} - - -// Test Py_SETREF() and Py_XSETREF() macros, similar to test_py_clear() -static PyObject* -test_py_setref(PyObject *self, PyObject *Py_UNUSED(ignored)) -{ - // Py_SETREF() simple case with a variable - PyObject *obj = PyList_New(0); - if (obj == NULL) { - return NULL; - } - Py_SETREF(obj, NULL); - assert(obj == NULL); - - // Py_XSETREF() simple case with a variable - PyObject *obj2 = PyList_New(0); - if (obj2 == NULL) { - return NULL; - } - Py_XSETREF(obj2, NULL); - assert(obj2 == NULL); - // test Py_XSETREF() when the argument is NULL - Py_XSETREF(obj2, NULL); - assert(obj2 == NULL); - - // gh-98724: complex case, Py_SETREF() argument has a side effect - PyObject* array[1]; - array[0] = PyList_New(0); - if (array[0] == NULL) { - return NULL; - } - - PyObject **p = array; - Py_SETREF(*p++, NULL); - assert(array[0] == NULL); - assert(p == array + 1); - - // gh-98724: complex case, Py_XSETREF() argument has a side effect - PyObject* array2[1]; - array2[0] = PyList_New(0); - if (array2[0] == NULL) { - return NULL; - } - - PyObject **p2 = array2; - Py_XSETREF(*p2++, NULL); - assert(array2[0] == NULL); - assert(p2 == array2 + 1); - - // test Py_XSETREF() when the argument is NULL - p2 = array2; - Py_XSETREF(*p2++, NULL); - assert(array2[0] == NULL); - assert(p2 == array2 + 1); - - Py_RETURN_NONE; -} - - -#define TEST_REFCOUNT() \ - do { \ - PyObject *obj = PyList_New(0); \ - if (obj == NULL) { \ - return NULL; \ - } \ - assert(Py_REFCNT(obj) == 1); \ - \ - /* test Py_NewRef() */ \ - PyObject *ref = Py_NewRef(obj); \ - assert(ref == obj); \ - assert(Py_REFCNT(obj) == 2); \ - Py_DECREF(ref); \ - \ - /* test Py_XNewRef() */ \ - PyObject *xref = Py_XNewRef(obj); \ - assert(xref == obj); \ - assert(Py_REFCNT(obj) == 2); \ - Py_DECREF(xref); \ - \ - assert(Py_XNewRef(NULL) == NULL); \ - \ - Py_DECREF(obj); \ - Py_RETURN_NONE; \ - } while (0) - - -// Test Py_NewRef() and Py_XNewRef() macros -static PyObject* -test_refcount_macros(PyObject *self, PyObject *Py_UNUSED(ignored)) -{ - TEST_REFCOUNT(); -} - -#undef Py_NewRef -#undef Py_XNewRef - -// Test Py_NewRef() and Py_XNewRef() functions, after undefining macros. -static PyObject* -test_refcount_funcs(PyObject *self, PyObject *Py_UNUSED(ignored)) -{ - TEST_REFCOUNT(); -} - - -// Test Py_Is() function -#define TEST_PY_IS() \ - do { \ - PyObject *o_none = Py_None; \ - PyObject *o_true = Py_True; \ - PyObject *o_false = Py_False; \ - PyObject *obj = PyList_New(0); \ - if (obj == NULL) { \ - return NULL; \ - } \ - \ - /* test Py_Is() */ \ - assert(Py_Is(obj, obj)); \ - assert(!Py_Is(obj, o_none)); \ - \ - /* test Py_None */ \ - assert(Py_Is(o_none, o_none)); \ - assert(!Py_Is(obj, o_none)); \ - \ - /* test Py_True */ \ - assert(Py_Is(o_true, o_true)); \ - assert(!Py_Is(o_false, o_true)); \ - assert(!Py_Is(obj, o_true)); \ - \ - /* test Py_False */ \ - assert(Py_Is(o_false, o_false)); \ - assert(!Py_Is(o_true, o_false)); \ - assert(!Py_Is(obj, o_false)); \ - \ - Py_DECREF(obj); \ - Py_RETURN_NONE; \ - } while (0) - -// Test Py_Is() macro -static PyObject* -test_py_is_macros(PyObject *self, PyObject *Py_UNUSED(ignored)) -{ - TEST_PY_IS(); -} - -#undef Py_Is - -// Test Py_Is() function, after undefining its macro. -static PyObject* -test_py_is_funcs(PyObject *self, PyObject *Py_UNUSED(ignored)) -{ - TEST_PY_IS(); -} - - static PyObject * clear_managed_dict(PyObject *self, PyObject *obj) { @@ -582,30 +358,20 @@ pysentinel_checkexact(PyObject *self, PyObject *obj) static PyMethodDef test_methods[] = { {"call_pyobject_print", call_pyobject_print, METH_VARARGS}, - {"pyobject_print_null", pyobject_print_null, METH_VARARGS}, - {"pyobject_print_noref_object", pyobject_print_noref_object, METH_VARARGS}, - {"pyobject_print_os_error", pyobject_print_os_error, METH_VARARGS}, + {"pyobject_print_null", pyobject_print_null, METH_O}, + {"pyobject_print_noref_object", pyobject_print_noref_object, METH_O}, + {"pyobject_print_os_error", pyobject_print_os_error, METH_O}, {"pyobject_clear_weakrefs_no_callbacks", pyobject_clear_weakrefs_no_callbacks, METH_O}, {"pyobject_enable_deferred_refcount", pyobject_enable_deferred_refcount, METH_O}, {"pyobject_is_unique_temporary", pyobject_is_unique_temporary, METH_O}, {"pyobject_is_unique_temporary_new_object", pyobject_is_unique_temporary_new_object, METH_NOARGS}, + {"pyobject_clear_managed_dict", pyobject_clear_managed_dict, METH_O}, {"test_py_try_inc_ref", test_py_try_inc_ref, METH_NOARGS}, {"test_py_set_immortal", test_py_set_immortal, METH_NOARGS}, - {"test_xincref_doesnt_leak",test_xincref_doesnt_leak, METH_NOARGS}, - {"test_incref_doesnt_leak", test_incref_doesnt_leak, METH_NOARGS}, - {"test_xdecref_doesnt_leak",test_xdecref_doesnt_leak, METH_NOARGS}, - {"test_decref_doesnt_leak", test_decref_doesnt_leak, METH_NOARGS}, - {"test_incref_decref_API", test_incref_decref_API, METH_NOARGS}, #ifdef Py_REF_DEBUG {"negative_refcount", negative_refcount, METH_NOARGS}, {"decref_freed_object", decref_freed_object, METH_NOARGS}, #endif - {"test_py_clear", test_py_clear, METH_NOARGS}, - {"test_py_setref", test_py_setref, METH_NOARGS}, - {"test_refcount_macros", test_refcount_macros, METH_NOARGS}, - {"test_refcount_funcs", test_refcount_funcs, METH_NOARGS}, - {"test_py_is_macros", test_py_is_macros, METH_NOARGS}, - {"test_py_is_funcs", test_py_is_funcs, METH_NOARGS}, {"clear_managed_dict", clear_managed_dict, METH_O, NULL}, {"is_uniquely_referenced", is_uniquely_referenced, METH_O}, {"pyobject_dump", pyobject_dump, METH_VARARGS}, diff --git a/Modules/_testcapi/parts.h b/Modules/_testcapi/parts.h index 98b5dd47accde35..e2787e7c93aef88 100644 --- a/Modules/_testcapi/parts.h +++ b/Modules/_testcapi/parts.h @@ -68,5 +68,7 @@ int _PyTestCapi_Init_Type(PyObject *mod); int _PyTestCapi_Init_Function(PyObject *mod); int _PyTestCapi_Init_Module(PyObject *mod); int _PyTestCapi_Init_Weakref(PyObject *mod); +int _PyTestCapi_Init_Marshal(PyObject *mod); +int _PyTestCapi_Init_Fpcast(PyObject *mod); #endif // Py_TESTCAPI_PARTS_H diff --git a/Modules/_testcapi/tuple.c b/Modules/_testcapi/tuple.c index 5de1c494c0a8c00..c3a1218d7916e9e 100644 --- a/Modules/_testcapi/tuple.c +++ b/Modules/_testcapi/tuple.c @@ -66,12 +66,17 @@ tuple_set_item(PyObject *Py_UNUSED(module), PyObject *args) } static PyObject * -_tuple_resize(PyObject *Py_UNUSED(module), PyObject *args) +_tuple_resize(PyObject *Py_UNUSED(module), PyObject *args, PyObject *kwargs) { + static char *kwlist[] = {"obj", "newsize", "new", "compute_hash", NULL}; PyObject *tup; Py_ssize_t newsize; int new = 1; - if (!PyArg_ParseTuple(args, "On|p", &tup, &newsize, &new)) { + int compute_hash = 0; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "On|pi", kwlist, + &tup, &newsize, &new, &compute_hash)) { return NULL; } if (new) { @@ -84,12 +89,24 @@ _tuple_resize(PyObject *Py_UNUSED(module), PyObject *args) NULLABLE(tup); Py_XINCREF(tup); } + + if (compute_hash) { + if (PyObject_Hash(tup) == -1) { + Py_DECREF(tup); + return NULL; + } + } + + PyObject *old_tup = tup; int r = _PyTuple_Resize(&tup, newsize); if (r == -1) { assert(tup == NULL); return NULL; } - return tup; + assert(tup != NULL); + + Py_ssize_t refcnt = Py_REFCNT(tup); + return Py_BuildValue("Nnp", tup, refcnt, tup != old_tup); } static PyObject * @@ -135,7 +152,7 @@ static PyMethodDef test_methods[] = { {"tuple_get_size", tuple_get_size, METH_O}, {"tuple_get_item", tuple_get_item, METH_VARARGS}, {"tuple_set_item", tuple_set_item, METH_VARARGS}, - {"_tuple_resize", _tuple_resize, METH_VARARGS}, + {"_tuple_resize", _PyCFunction_CAST(_tuple_resize), METH_VARARGS | METH_KEYWORDS}, {"_check_tuple_item_is_NULL", _check_tuple_item_is_NULL, METH_VARARGS}, {"tuple_fromarray", tuple_fromarray, METH_VARARGS}, {NULL}, diff --git a/Modules/_testcapi/type.c b/Modules/_testcapi/type.c index f566efa0ca15ae6..91203c7bf0f678a 100644 --- a/Modules/_testcapi/type.c +++ b/Modules/_testcapi/type.c @@ -1,3 +1,7 @@ +// Thin wrappers to PyType functions. +// Do no check PyType_Check() so Python tests can pass arbitrary objects, +// even if it's likely to crash. + #include "parts.h" #include "util.h" @@ -13,50 +17,11 @@ static PyType_Spec HeapTypeNameType_Spec = { .slots = HeapTypeNameType_slots, }; -static PyObject * -get_heaptype_for_name(PyObject *self, PyObject *Py_UNUSED(ignored)) -{ - return PyType_FromSpec(&HeapTypeNameType_Spec); -} - - -static PyObject * -get_type_name(PyObject *self, PyObject *type) -{ - assert(PyType_Check(type)); - return PyType_GetName((PyTypeObject *)type); -} - - -static PyObject * -get_type_qualname(PyObject *self, PyObject *type) -{ - assert(PyType_Check(type)); - return PyType_GetQualName((PyTypeObject *)type); -} - - -static PyObject * -get_type_fullyqualname(PyObject *self, PyObject *type) -{ - assert(PyType_Check(type)); - return PyType_GetFullyQualifiedName((PyTypeObject *)type); -} - - -static PyObject * -get_type_module_name(PyObject *self, PyObject *type) -{ - assert(PyType_Check(type)); - return PyType_GetModuleName((PyTypeObject *)type); -} - +// Test for PyType_GetDict() static PyObject * test_get_type_dict(PyObject *self, PyObject *Py_UNUSED(ignored)) { - /* Test for PyType_GetDict */ - // Assert ints have a `to_bytes` method PyObject *long_dict = PyType_GetDict(&PyLong_Type); assert(long_dict); @@ -77,6 +42,7 @@ test_get_type_dict(PyObject *self, PyObject *Py_UNUSED(ignored)) } +// Test PyType_GetSlot() static PyObject * test_get_statictype_slots(PyObject *self, PyObject *Py_UNUSED(ignored)) { @@ -135,14 +101,12 @@ test_get_statictype_slots(PyObject *self, PyObject *Py_UNUSED(ignored)) // Get type->tp_version_tag static PyObject * -type_get_version(PyObject *self, PyObject *type) +type_get_version(PyObject *self, PyObject *arg) { - if (!PyType_Check(type)) { - PyErr_SetString(PyExc_TypeError, "argument must be a type"); - return NULL; - } - PyObject *res = PyLong_FromUnsignedLong( - ((PyTypeObject *)type)->tp_version_tag); + NULLABLE(arg); + PyTypeObject *type = (PyTypeObject*)arg; + + PyObject *res = PyLong_FromUnsignedLong(type->tp_version_tag); if (res == NULL) { assert(PyErr_Occurred()); return NULL; @@ -150,27 +114,12 @@ type_get_version(PyObject *self, PyObject *type) return res; } -static PyObject * -type_modified(PyObject *self, PyObject *arg) -{ - if (!PyType_Check(arg)) { - PyErr_SetString(PyExc_TypeError, "argument must be a type"); - return NULL; - } - PyTypeObject *type = (PyTypeObject*)arg; - - PyType_Modified(type); - Py_RETURN_NONE; -} - +// Test PyUnstable_Type_AssignVersionTag() static PyObject * type_assign_version(PyObject *self, PyObject *arg) { - if (!PyType_Check(arg)) { - PyErr_SetString(PyExc_TypeError, "argument must be a type"); - return NULL; - } + NULLABLE(arg); PyTypeObject *type = (PyTypeObject*)arg; int res = PyUnstable_Type_AssignVersionTag(type); @@ -178,13 +127,11 @@ type_assign_version(PyObject *self, PyObject *arg) } +// Get PyTypeObject.tp_bases static PyObject * type_get_tp_bases(PyObject *self, PyObject *arg) { - if (!PyType_Check(arg)) { - PyErr_SetString(PyExc_TypeError, "argument must be a type"); - return NULL; - } + NULLABLE(arg); PyTypeObject *type = (PyTypeObject*)arg; PyObject *bases = type->tp_bases; @@ -194,16 +141,15 @@ type_get_tp_bases(PyObject *self, PyObject *arg) return Py_NewRef(bases); } + +// Get PyTypeObject.tp_mro static PyObject * type_get_tp_mro(PyObject *self, PyObject *arg) { - if (!PyType_Check(arg)) { - PyErr_SetString(PyExc_TypeError, "argument must be a type"); - return NULL; - } + NULLABLE(arg); PyTypeObject *type = (PyTypeObject*)arg; - PyObject *mro = ((PyTypeObject *)type)->tp_mro; + PyObject *mro = type->tp_mro; if (mro == NULL) { Py_RETURN_NONE; } @@ -211,41 +157,38 @@ type_get_tp_mro(PyObject *self, PyObject *arg) } -static PyObject * -type_freeze(PyObject *module, PyObject *arg) -{ - if (!PyType_Check(arg)) { - PyErr_SetString(PyExc_TypeError, "argument must be a type"); - return NULL; - } - PyTypeObject *type = (PyTypeObject*)arg; - - if (PyType_Freeze(type) < 0) { - return NULL; - } - Py_RETURN_NONE; -} - - static PyMethodDef test_methods[] = { - {"get_heaptype_for_name", get_heaptype_for_name, METH_NOARGS}, - {"get_type_name", get_type_name, METH_O}, - {"get_type_qualname", get_type_qualname, METH_O}, - {"get_type_fullyqualname", get_type_fullyqualname, METH_O}, - {"get_type_module_name", get_type_module_name, METH_O}, {"test_get_type_dict", test_get_type_dict, METH_NOARGS}, {"test_get_statictype_slots", test_get_statictype_slots, METH_NOARGS}, {"type_get_version", type_get_version, METH_O, PyDoc_STR("type->tp_version_tag")}, - {"type_modified", type_modified, METH_O, PyDoc_STR("PyType_Modified")}, {"type_assign_version", type_assign_version, METH_O, PyDoc_STR("PyUnstable_Type_AssignVersionTag")}, {"type_get_tp_bases", type_get_tp_bases, METH_O}, {"type_get_tp_mro", type_get_tp_mro, METH_O}, - {"type_freeze", type_freeze, METH_O}, {NULL}, }; int _PyTestCapi_Init_Type(PyObject *m) { - return PyModule_AddFunctions(m, test_methods); + if (PyModule_AddFunctions(m, test_methods) < 0) { + return -1; + } + +#define ADD_INT(macro) \ + do { \ + if (PyModule_AddIntConstant(m, #macro, macro) < 0) { \ + return -1; \ + } \ + } while (0) + + // Flags excluded from the limited C API + ADD_INT(_Py_TPFLAGS_STATIC_BUILTIN); + ADD_INT(Py_TPFLAGS_INLINE_VALUES); + ADD_INT(Py_TPFLAGS_MANAGED_WEAKREF); + ADD_INT(Py_TPFLAGS_MANAGED_DICT); + ADD_INT(Py_TPFLAGS_SEQUENCE); + ADD_INT(Py_TPFLAGS_MAPPING); + +#undef ADD_INT + return 0; } diff --git a/Modules/_testcapi/unicode.c b/Modules/_testcapi/unicode.c index 915c9230f66b52e..19178b2977e62ed 100644 --- a/Modules/_testcapi/unicode.c +++ b/Modules/_testcapi/unicode.c @@ -59,13 +59,20 @@ unicode_copy(PyObject *unicode) /* Test PyUnicode_Fill() */ static PyObject * -unicode_fill(PyObject *self, PyObject *args) +unicode_fill(PyObject *self, PyObject *args, PyObject *kwargs) { + static char *kwlist[] = {"to", "start", "length", "fill_char", + "incref", NULL}; PyObject *to, *to_copy; Py_ssize_t start, length, filled; unsigned int fill_char; + int incref = 0; - if (!PyArg_ParseTuple(args, "OnnI", &to, &start, &length, &fill_char)) { + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "OnnI|p", kwlist, + &to, &start, &length, + &fill_char, &incref)) + { return NULL; } @@ -74,7 +81,14 @@ unicode_fill(PyObject *self, PyObject *args) return NULL; } + if (incref) { + Py_INCREF(to_copy); + } filled = PyUnicode_Fill(to_copy, start, length, (Py_UCS4)fill_char); + if (incref) { + Py_DECREF(to_copy); + } + if (filled == -1 && PyErr_Occurred()) { Py_DECREF(to_copy); return NULL; @@ -190,13 +204,18 @@ unicode_asutf8(PyObject *self, PyObject *args) /* Test PyUnicode_CopyCharacters() */ static PyObject * -unicode_copycharacters(PyObject *self, PyObject *args) +unicode_copycharacters(PyObject *self, PyObject *args, PyObject *kwargs) { + static char *kwlist[] = {"to", "to_start", "from", "from_start", + "howmany", "incref", NULL}; PyObject *from, *to, *to_copy; Py_ssize_t from_start, to_start, how_many, copied; + int incref = 0; - if (!PyArg_ParseTuple(args, "UnOnn", &to, &to_start, - &from, &from_start, &how_many)) { + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "UnOnn|p", kwlist, + &to, &to_start, &from, &from_start, + &how_many, &incref)) { return NULL; } @@ -210,8 +229,15 @@ unicode_copycharacters(PyObject *self, PyObject *args) return NULL; } + if (incref) { + Py_INCREF(to_copy); + } copied = PyUnicode_CopyCharacters(to_copy, to_start, from, from_start, how_many); + if (incref) { + Py_DECREF(to_copy); + } + if (copied == -1 && PyErr_Occurred()) { Py_DECREF(to_copy); return NULL; @@ -220,6 +246,8 @@ unicode_copycharacters(PyObject *self, PyObject *args) return Py_BuildValue("(Nn)", to_copy, copied); } + +// Test PyUnstable_Unicode_GET_CACHED_HASH() static PyObject* unicode_GET_CACHED_HASH(PyObject *self, PyObject *arg) { @@ -227,6 +255,216 @@ unicode_GET_CACHED_HASH(PyObject *self, PyObject *arg) } +// Test the deprecated _Py_Identifier C API: +// - _Py_IDENTIFIER() +// - _Py_static_string() +// - _Py_static_string_init() +// - _PyObject_CallMethodId() +// - _PyObject_GetAttrId() +// - _PyUnicode_FromId() +// +// _testembed also has tests on _PyUnicode_FromId(). +static PyObject* +test_py_identifier(PyObject *self, PyObject *Py_UNUSED(args)) +{ +// Ignore deprecation warnings +_Py_COMP_DIAG_PUSH +_Py_COMP_DIAG_IGNORE_DEPR_DECLS + + _Py_IDENTIFIER(hello); + PyObject *str = _PyUnicode_FromId(&PyId_hello); // borrowed ref + if (str == NULL) { + return NULL; + } + assert(PyUnicode_EqualToUTF8(str, "hello") == 1); + + // Calling twice return the same object + PyObject *str2 = _PyUnicode_FromId(&PyId_hello); // borrowed ref + assert(str2 == str); + + PyObject *number = Py_GetConstant(Py_CONSTANT_ONE); // immortal + _Py_static_string(to_bytes_id, "to_bytes"); + PyObject *res = _PyObject_CallMethodId(number, &to_bytes_id, NULL); + if (res == NULL) { + return NULL; + } + Py_DECREF(res); + + static _Py_Identifier real_id = _Py_static_string_init("real"); + res = _PyObject_GetAttrId(number, &real_id); + if (res == NULL) { + return NULL; + } + assert(res == number); + Py_DECREF(res); + + Py_RETURN_NONE; + +_Py_COMP_DIAG_POP +} + + +// Write into an immutable str object to test _PyStaticObjects_CheckAll() +static PyObject * +corrupt_unicode(PyObject *Py_UNUSED(module), PyObject *args) +{ + PyObject *obj, *override; + if (!PyArg_ParseTuple(args, "OO", &obj, &override)) { + return NULL; + } + assert(PyUnicode_KIND(obj) == PyUnicode_1BYTE_KIND); + assert(PyUnicode_KIND(override) == PyUnicode_1BYTE_KIND); + + Py_UCS1 *dst = PyUnicode_1BYTE_DATA(obj); + Py_UCS1 *src = PyUnicode_1BYTE_DATA(override); + Py_ssize_t size = PyUnicode_GET_LENGTH(override); + memcpy(dst, src, size); + Py_RETURN_NONE; +} + + +/* Test PyUnicode_READ_CHAR() */ +static PyObject * +unicode_read_char(PyObject *self, PyObject *args) +{ + PyObject *unicode; + Py_ssize_t index; + if (!PyArg_ParseTuple(args, "On", &unicode, &index)) { + return NULL; + } + NULLABLE(unicode); + + Py_UCS4 result = PyUnicode_READ_CHAR(unicode, index); + return PyLong_FromUnsignedLong(result); +} + + +/* Test PyUnicode_READ() macro */ +static PyObject * +unicode_read(PyObject *self, PyObject *args) +{ + PyObject *unicode; + Py_ssize_t index; + if (!PyArg_ParseTuple(args, "On", &unicode, &index)) { + return NULL; + } + NULLABLE(unicode); + + int kind = PyUnicode_KIND(unicode); + const void *data = PyUnicode_DATA(unicode); + Py_UCS4 result = PyUnicode_READ(kind, data, index); + return PyLong_FromUnsignedLong(result); +} + + +/* Test PyUnicode_WRITE() macro */ +static PyObject * +unicode_write(PyObject *self, PyObject *args) +{ + PyObject *unicode; + Py_ssize_t index; + unsigned int character; + if (!PyArg_ParseTuple(args, "OnI", &unicode, &index, &character)) { + return NULL; + } + NULLABLE(unicode); + + PyObject *copy = unicode_copy(unicode); + if (copy == NULL) { + return NULL; + } + + int kind = PyUnicode_KIND(copy); + const void *data = PyUnicode_DATA(copy); + PyUnicode_WRITE(kind, data, index, character); + // Same return value than _testlimitedcapi unicode_writechar(): + // always use 0 as the function result + return Py_BuildValue("(Ni)", copy, 0); +} + + +/* Test PyUnicode_KIND() macro */ +static PyObject * +unicode_kind(PyObject *self, PyObject *unicode) +{ + NULLABLE(unicode); + + int kind = PyUnicode_KIND(unicode); + return PyLong_FromLong(kind); +} + + +/* Test PyUnicode_MAX_CHAR_VALUE() macro */ +static PyObject * +unicode_max_char_value(PyObject *self, PyObject *unicode) +{ + NULLABLE(unicode); + + Py_UCS4 maxchar = PyUnicode_MAX_CHAR_VALUE(unicode); + return PyLong_FromUnsignedLong(maxchar); +} + + +/* Test PyUnicode_GET_LENGTH() macro */ +static PyObject * +unicode_getlength_macro(PyObject *self, PyObject *arg) +{ + NULLABLE(arg); + return PyLong_FromSsize_t(PyUnicode_GET_LENGTH(arg)); +} + + +/* Test PyUnicode_Equal() macro */ +static PyObject * +unicode_equal(PyObject *self, PyObject *args) +{ + PyObject *str1, *str2; + if (!PyArg_ParseTuple(args, "OnI", &str1, &str2)) { + return NULL; + } + NULLABLE(str1); + NULLABLE(str2); + + RETURN_INT(PyUnicode_Equal(str1, str2)); +} + + +/* Test PyUnicode_CHECK_INTERNED() macro */ +static PyObject * +unicode_check_interned(PyObject *self, PyObject *arg) +{ + NULLABLE(arg); + RETURN_UINT(PyUnicode_CHECK_INTERNED(arg)); +} + + +/* Test PyUnicode_IS_ASCII() macro */ +static PyObject * +unicode_is_ascii(PyObject *self, PyObject *arg) +{ + NULLABLE(arg); + RETURN_UINT(PyUnicode_IS_ASCII(arg)); +} + + +/* Test PyUnicode_IS_COMPACT() macro */ +static PyObject * +unicode_is_compact(PyObject *self, PyObject *arg) +{ + NULLABLE(arg); + RETURN_UINT(PyUnicode_IS_COMPACT(arg)); +} + + +/* Test PyUnicode_IS_COMPACT_ASCII() macro */ +static PyObject * +unicode_is_compact_ascii(PyObject *self, PyObject *arg) +{ + NULLABLE(arg); + RETURN_INT(PyUnicode_IS_COMPACT_ASCII(arg)); +} + + // --- PyUnicodeWriter type ------------------------------------------------- typedef struct { @@ -451,6 +689,23 @@ writer_write_repr(PyObject *self_raw, PyObject *obj) } +// write_repr(None) calls PyUnicodeWriter_WriteRepr(writer, NULL), so add +// a specialized function calling PyUnicodeWriter_WriteRepr(writer, Py_None). +static PyObject* +writer_write_repr_none(PyObject *self_raw, PyObject *Py_UNUSED(arg)) +{ + WriterObject *self = (WriterObject *)self_raw; + if (writer_check(self) < 0) { + return NULL; + } + + if (PyUnicodeWriter_WriteRepr(self->writer, Py_None) < 0) { + return NULL; + } + Py_RETURN_NONE; +} + + static PyObject* writer_write_substring(PyObject *self_raw, PyObject *args) { @@ -473,6 +728,32 @@ writer_write_substring(PyObject *self_raw, PyObject *args) } +static PyObject* +writer_write_latin1(PyObject *self_raw, PyObject *args) +{ + WriterObject *self = (WriterObject *)self_raw; + if (writer_check(self) < 0) { + return NULL; + } + + const char *str; + Py_ssize_t bsize, size; + if (!PyArg_ParseTuple(args, "z#n", &str, &bsize, &size)) { + return NULL; + } + + _PyUnicodeWriter *writer = (_PyUnicodeWriter*)self->writer; +_Py_COMP_DIAG_PUSH +_Py_COMP_DIAG_IGNORE_DEPR_DECLS + if (_PyUnicodeWriter_WriteLatin1String(writer, str, size) < 0) { + return NULL; + } +_Py_COMP_DIAG_POP + + Py_RETURN_NONE; +} + + static PyObject* writer_decodeutf8stateful(PyObject *self_raw, PyObject *args) { @@ -518,6 +799,31 @@ writer_get_pointer(PyObject *self_raw, PyObject *args) } +static PyObject* +writer_get_buffer(PyObject *self_raw, PyObject *args) +{ + WriterObject *self = (WriterObject *)self_raw; + if (writer_check(self) < 0) { + return NULL; + } + + _PyUnicodeWriter *writer = (_PyUnicodeWriter*)self->writer; + PyObject *allocated; + Py_UCS4 maxchar; + if (writer->buffer) { + allocated = PyLong_FromSsize_t(PyUnicode_GET_LENGTH(writer->buffer)); + maxchar = PyUnicode_MAX_CHAR_VALUE(writer->buffer); + } + else { + allocated = Py_None; + maxchar = writer->min_char; + } + return Py_BuildValue("(NkN)", + allocated, (unsigned long)maxchar, + PyBool_FromLong(writer->readonly)); +} + + static PyObject* writer_finish(PyObject *self_raw, PyObject *Py_UNUSED(args)) { @@ -532,6 +838,31 @@ writer_finish(PyObject *self_raw, PyObject *Py_UNUSED(args)) } +static PyObject* +writer_finish_with_size(PyObject *self_raw, PyObject *args) +{ + PyAPI_FUNC(PyObject*) _PyUnicodeWriter_FinishWithSize( + _PyUnicodeWriter *writer, + Py_ssize_t size); + + WriterObject *self = (WriterObject *)self_raw; + if (writer_check(self) < 0) { + return NULL; + } + + Py_ssize_t size; + if (!PyArg_ParseTuple(args, "n", &size)) { + return NULL; + } + + _PyUnicodeWriter *writer = (_PyUnicodeWriter*)self->writer; + PyObject *str = _PyUnicodeWriter_FinishWithSize(writer, size); + PyUnicodeWriter_Discard(self->writer); + self->writer = NULL; + return str; +} + + static PyMethodDef writer_methods[] = { {"write_char", _PyCFunction_CAST(writer_write_char), METH_VARARGS}, {"write_utf8", _PyCFunction_CAST(writer_write_utf8), METH_VARARGS}, @@ -540,10 +871,14 @@ static PyMethodDef writer_methods[] = { {"write_ucs4", _PyCFunction_CAST(writer_write_ucs4), METH_VARARGS}, {"write_str", _PyCFunction_CAST(writer_write_str), METH_O}, {"write_repr", _PyCFunction_CAST(writer_write_repr), METH_O}, + {"write_repr_none", _PyCFunction_CAST(writer_write_repr_none), METH_NOARGS}, {"write_substring", _PyCFunction_CAST(writer_write_substring), METH_VARARGS}, + {"write_latin1", _PyCFunction_CAST(writer_write_latin1), METH_VARARGS}, {"decodeutf8stateful", _PyCFunction_CAST(writer_decodeutf8stateful), METH_VARARGS}, {"get_pointer", _PyCFunction_CAST(writer_get_pointer), METH_VARARGS}, + {"get_buffer", _PyCFunction_CAST(writer_get_buffer), METH_VARARGS}, {"finish", _PyCFunction_CAST(writer_finish), METH_NOARGS}, + {"finish_with_size", _PyCFunction_CAST(writer_finish_with_size), METH_VARARGS}, {NULL, NULL} /* sentinel */ }; @@ -565,13 +900,26 @@ static PyType_Spec Writer_spec = { static PyMethodDef TestMethods[] = { {"unicode_new", unicode_new, METH_VARARGS}, - {"unicode_fill", unicode_fill, METH_VARARGS}, + {"unicode_fill", _PyCFunction_CAST(unicode_fill), METH_VARARGS | METH_KEYWORDS}, {"unicode_fromkindanddata", unicode_fromkindanddata, METH_VARARGS}, {"unicode_asucs4", unicode_asucs4, METH_VARARGS}, {"unicode_asucs4copy", unicode_asucs4copy, METH_VARARGS}, {"unicode_asutf8", unicode_asutf8, METH_VARARGS}, - {"unicode_copycharacters", unicode_copycharacters, METH_VARARGS}, + {"unicode_copycharacters", _PyCFunction_CAST(unicode_copycharacters), METH_VARARGS | METH_KEYWORDS}, {"unicode_GET_CACHED_HASH", unicode_GET_CACHED_HASH, METH_O}, + {"test_py_identifier", test_py_identifier, METH_NOARGS}, + {"corrupt_unicode", corrupt_unicode, METH_VARARGS}, + {"unicode_read_char", unicode_read_char, METH_VARARGS}, + {"unicode_read", unicode_read, METH_VARARGS}, + {"unicode_write", unicode_write, METH_VARARGS}, + {"unicode_kind", unicode_kind, METH_O}, + {"unicode_max_char_value", unicode_max_char_value, METH_O}, + {"unicode_getlength_macro", unicode_getlength_macro, METH_O}, + {"unicode_equal", unicode_equal, METH_VARARGS}, + {"unicode_check_interned", unicode_check_interned, METH_O}, + {"unicode_is_ascii", unicode_is_ascii, METH_O}, + {"unicode_is_compact", unicode_is_compact, METH_O}, + {"unicode_is_compact_ascii", unicode_is_compact_ascii, METH_O}, {NULL}, }; diff --git a/Modules/_testcapi/util.h b/Modules/_testcapi/util.h index 042e522542eddb6..c20472e24f3d465 100644 --- a/Modules/_testcapi/util.h +++ b/Modules/_testcapi/util.h @@ -14,6 +14,16 @@ return PyLong_FromLong(_ret); \ } while (0) +#define RETURN_UINT(value) do { \ + unsigned int _ret = (value); \ + if (_ret == (unsigned int)-1) { \ + assert(PyErr_Occurred()); \ + return NULL; \ + } \ + assert(!PyErr_Occurred()); \ + return PyLong_FromUnsignedLong(_ret); \ + } while (0) + #define RETURN_SIZE(value) do { \ Py_ssize_t _ret = (value); \ if (_ret == -1) { \ diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 799390c27053287..08dbfabde547478 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -13,7 +13,10 @@ #include "_testcapi/parts.h" #include "frameobject.h" // PyFrame_New() -#include "marshal.h" // PyMarshal_WriteLongToFile() + +#ifdef bool +# error "The public headers should not include , see gh-90904" +#endif #include // FLT_MAX #include @@ -26,10 +29,6 @@ # include // sysctlbyname() #endif -#ifdef bool -# error "The public headers should not include , see gh-48924" -#endif - #include "_testcapi/util.h" @@ -39,6 +38,7 @@ static struct PyModuleDef _testcapimodule; // Module state typedef struct { PyObject *error; // _testcapi.error object + Py_ssize_t list_destroys; } testcapistate_t; static testcapistate_t* @@ -1415,155 +1415,6 @@ join_temporary_c_thread(PyObject *self, PyObject *Py_UNUSED(ignored)) Py_RETURN_NONE; } -/* marshal */ - -static PyObject* -pymarshal_write_long_to_file(PyObject* self, PyObject *args) -{ - long value; - PyObject *filename; - int version; - FILE *fp; - - if (!PyArg_ParseTuple(args, "lOi:pymarshal_write_long_to_file", - &value, &filename, &version)) - return NULL; - - fp = Py_fopen(filename, "wb"); - if (fp == NULL) { - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - - PyMarshal_WriteLongToFile(value, fp, version); - assert(!PyErr_Occurred()); - - fclose(fp); - Py_RETURN_NONE; -} - -static PyObject* -pymarshal_write_object_to_file(PyObject* self, PyObject *args) -{ - PyObject *obj; - PyObject *filename; - int version; - FILE *fp; - - if (!PyArg_ParseTuple(args, "OOi:pymarshal_write_object_to_file", - &obj, &filename, &version)) - return NULL; - - fp = Py_fopen(filename, "wb"); - if (fp == NULL) { - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - - PyMarshal_WriteObjectToFile(obj, fp, version); - assert(!PyErr_Occurred()); - - fclose(fp); - Py_RETURN_NONE; -} - -static PyObject* -pymarshal_read_short_from_file(PyObject* self, PyObject *args) -{ - int value; - long pos; - PyObject *filename; - FILE *fp; - - if (!PyArg_ParseTuple(args, "O:pymarshal_read_short_from_file", &filename)) - return NULL; - - fp = Py_fopen(filename, "rb"); - if (fp == NULL) { - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - - value = PyMarshal_ReadShortFromFile(fp); - pos = ftell(fp); - - fclose(fp); - if (PyErr_Occurred()) - return NULL; - return Py_BuildValue("il", value, pos); -} - -static PyObject* -pymarshal_read_long_from_file(PyObject* self, PyObject *args) -{ - long value, pos; - PyObject *filename; - FILE *fp; - - if (!PyArg_ParseTuple(args, "O:pymarshal_read_long_from_file", &filename)) - return NULL; - - fp = Py_fopen(filename, "rb"); - if (fp == NULL) { - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - - value = PyMarshal_ReadLongFromFile(fp); - pos = ftell(fp); - - fclose(fp); - if (PyErr_Occurred()) - return NULL; - return Py_BuildValue("ll", value, pos); -} - -static PyObject* -pymarshal_read_last_object_from_file(PyObject* self, PyObject *args) -{ - PyObject *filename; - if (!PyArg_ParseTuple(args, "O:pymarshal_read_last_object_from_file", &filename)) - return NULL; - - FILE *fp = Py_fopen(filename, "rb"); - if (fp == NULL) { - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - - PyObject *obj = PyMarshal_ReadLastObjectFromFile(fp); - long pos = ftell(fp); - - fclose(fp); - if (obj == NULL) { - return NULL; - } - return Py_BuildValue("Nl", obj, pos); -} - -static PyObject* -pymarshal_read_object_from_file(PyObject* self, PyObject *args) -{ - PyObject *filename; - if (!PyArg_ParseTuple(args, "O:pymarshal_read_object_from_file", &filename)) - return NULL; - - FILE *fp = Py_fopen(filename, "rb"); - if (fp == NULL) { - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - - PyObject *obj = PyMarshal_ReadObjectFromFile(fp); - long pos = ftell(fp); - - fclose(fp); - if (obj == NULL) { - return NULL; - } - return Py_BuildValue("Nl", obj, pos); -} - static PyObject* return_null_without_error(PyObject *self, PyObject *args) { @@ -1640,6 +1491,30 @@ py_w_stopcode(PyObject *self, PyObject *args) #endif +static PyObject * +sequence_repeat(PyObject* self, PyObject *args) +{ + PyObject *sequence; + Py_ssize_t count; + if (!PyArg_ParseTuple(args, "On", &sequence, &count)) { + return NULL; + } + + return PySequence_Repeat(sequence, count); +} + +static PyObject * +sequence_inplace_repeat(PyObject* self, PyObject *args) +{ + PyObject *sequence; + Py_ssize_t count; + if (!PyArg_ParseTuple(args, "On", &sequence, &count)) { + return NULL; + } + + return PySequence_InPlaceRepeat(sequence, count); +} + static PyObject * test_pythread_tss_key_state(PyObject *self, PyObject *args) { @@ -2194,12 +2069,22 @@ test_macros(PyObject *self, PyObject *Py_UNUSED(args)) static_assert(1 == 1, "bug"); Py_BUILD_ASSERT(1 == 1); - // Py_MIN(), Py_MAX(), Py_ABS() assert(Py_MIN(5, 11) == 5); assert(Py_MAX(5, 11) == 11); assert(Py_ABS(-5) == 5); +#if ((defined(__GNUC__) || defined(__clang__)) \ + && defined(_Py_TYPEOF) && !defined(__cplusplus)) + // When _Py_TYPEOF() is available, arguments are only evaluated once + int x = 5, y = 11; + assert(Py_MIN(++x, ++y) == 6); + x = 5; y = 11; + assert(Py_MAX(++x, ++y) == 12); + x = -5; + assert(Py_ABS(--x) == 6); +#endif + // Py_STRINGIFY() assert(strcmp(Py_STRINGIFY(123), "123") == 0); @@ -2418,6 +2303,36 @@ test_reftracer(PyObject *ob, PyObject *Py_UNUSED(ignored)) return NULL; } +static int +_listdestroytracer(PyObject *obj, PyRefTracerEvent event, void *data) +{ + if (event == PyRefTracer_DESTROY && PyList_CheckExact(obj)) { + _Py_atomic_add_ssize((Py_ssize_t *)data, 1); + } + return 0; +} + +static PyObject * +start_counting_list_destroys(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + testcapistate_t *state = get_testcapi_state(self); + _Py_atomic_store_ssize(&state->list_destroys, 0); + if (PyRefTracer_SetTracer(_listdestroytracer, &state->list_destroys) != 0) { + return NULL; + } + Py_RETURN_NONE; +} + +static PyObject * +stop_counting_list_destroys(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + if (PyRefTracer_SetTracer(NULL, NULL) != 0) { + return NULL; + } + return PyLong_FromSsize_t( + _Py_atomic_load_ssize(&get_testcapi_state(self)->list_destroys)); +} + static PyObject * function_set_warning(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) { @@ -3022,6 +2937,8 @@ static PyMethodDef TestMethods[] = { {"test_buildvalue_N", test_buildvalue_N, METH_NOARGS}, {"test_buildvalue_p", test_buildvalue_p, METH_NOARGS}, {"test_reftracer", test_reftracer, METH_NOARGS}, + {"start_counting_list_destroys", start_counting_list_destroys, METH_NOARGS}, + {"stop_counting_list_destroys", stop_counting_list_destroys, METH_NOARGS}, {"_test_thread_state", test_thread_state, METH_VARARGS}, {"gilstate_ensure_release", gilstate_ensure_release, METH_NOARGS}, #ifndef MS_WINDOWS @@ -3046,18 +2963,6 @@ static PyMethodDef TestMethods[] = { {"call_in_temporary_c_thread", call_in_temporary_c_thread, METH_VARARGS, PyDoc_STR("set_error_class(error_class) -> None")}, {"join_temporary_c_thread", join_temporary_c_thread, METH_NOARGS}, - {"pymarshal_write_long_to_file", - pymarshal_write_long_to_file, METH_VARARGS}, - {"pymarshal_write_object_to_file", - pymarshal_write_object_to_file, METH_VARARGS}, - {"pymarshal_read_short_from_file", - pymarshal_read_short_from_file, METH_VARARGS}, - {"pymarshal_read_long_from_file", - pymarshal_read_long_from_file, METH_VARARGS}, - {"pymarshal_read_last_object_from_file", - pymarshal_read_last_object_from_file, METH_VARARGS}, - {"pymarshal_read_object_from_file", - pymarshal_read_object_from_file, METH_VARARGS}, {"return_null_without_error", return_null_without_error, METH_NOARGS}, {"return_result_with_error", return_result_with_error, METH_NOARGS}, {"getitem_with_error", getitem_with_error, METH_VARARGS}, @@ -3068,6 +2973,8 @@ static PyMethodDef TestMethods[] = { #ifdef W_STOPCODE {"W_STOPCODE", py_w_stopcode, METH_VARARGS}, #endif + {"sequence_repeat", sequence_repeat, METH_VARARGS}, + {"sequence_inplace_repeat", sequence_inplace_repeat, METH_VARARGS}, {"test_pythread_tss_key_state", test_pythread_tss_key_state, METH_VARARGS}, {"bad_get", bad_get, METH_VARARGS}, {"meth_varargs", meth_varargs, METH_VARARGS}, @@ -3400,6 +3307,17 @@ static PyTypeObject MyList_Type = { MyList_new, /* tp_new */ }; +/* Like MyList, but tp_dict is initialized with a dict subclass before + PyType_Ready(), as extension modules may do (e.g. ctypes before 3.13). */ +static PyTypeObject MyListDictSubclass_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "MyListDictSubclass", + sizeof(MyListObject), + .tp_dealloc = MyList_dealloc, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + .tp_new = MyList_new, +}; + /* Test PEP 560 */ typedef struct { @@ -3479,6 +3397,11 @@ static PyMethodDef meth_instance_methods[] = { {"meth_noargs", meth_noargs, METH_NOARGS}, {"meth_fastcall", _PyCFunction_CAST(meth_fastcall), METH_FASTCALL}, {"meth_fastcall_keywords", _PyCFunction_CAST(meth_fastcall_keywords), METH_FASTCALL|METH_KEYWORDS}, + {"meth_fastcall_coexist", _PyCFunction_CAST(meth_fastcall), + METH_FASTCALL|METH_COEXIST}, + {"meth_fastcall_keywords_coexist", + _PyCFunction_CAST(meth_fastcall_keywords), + METH_FASTCALL|METH_KEYWORDS|METH_COEXIST}, {NULL, NULL} /* sentinel */ }; @@ -3711,6 +3634,28 @@ _testcapi_exec(PyObject *m) Py_INCREF(&MyList_Type); PyModule_AddObject(m, "MyList", (PyObject *)&MyList_Type); + MyListDictSubclass_Type.tp_base = &PyList_Type; + if (MyListDictSubclass_Type.tp_dict == NULL) { + PyObject *cls = PyObject_CallFunction((PyObject *)&PyType_Type, + "s(O){}", "DictSubclass", + &PyDict_Type); + if (cls == NULL) { + return -1; + } + MyListDictSubclass_Type.tp_dict = PyObject_CallNoArgs(cls); + Py_DECREF(cls); + if (MyListDictSubclass_Type.tp_dict == NULL) { + return -1; + } + } + /* PyModule_AddType() would skip PyType_Ready() as tp_dict is set. */ + if (PyType_Ready(&MyListDictSubclass_Type) < 0) { + return -1; + } + if (PyModule_AddType(m, &MyListDictSubclass_Type) < 0) { + return -1; + } + if (PyType_Ready(&GenericAlias_Type) < 0) return -1; Py_INCREF(&GenericAlias_Type); @@ -3943,7 +3888,12 @@ _testcapi_exec(PyObject *m) if (_PyTestCapi_Init_Weakref(m) < 0) { return -1; } - + if (_PyTestCapi_Init_Marshal(m) < 0) { + return -1; + } + if (_PyTestCapi_Init_Fpcast(m) < 0) { + return -1; + } return 0; } diff --git a/Modules/_testclinic.c b/Modules/_testclinic.c index 66a375589ba38e5..fc87f521e4999b2 100644 --- a/Modules/_testclinic.c +++ b/Modules/_testclinic.c @@ -21,6 +21,11 @@ custom_converter(PyObject *obj, custom_t *val) } +/* Forward declarations for vectorcall types, needed because + * clinic/_testclinic.c.h is included before the type definitions. */ +static PyTypeObject VcNew_Type; +static PyTypeObject VcNewBase_Type; +static PyTypeObject VcKwOnly_Type; #include "clinic/_testclinic.c.h" @@ -1237,6 +1242,122 @@ posonly_poskw_varpos_array_impl(PyObject *module, PyObject *a, PyObject *b, } +/*[clinic input] +only_group + + [ + a: object + ] + / + +[clinic start generated code]*/ + +static PyObject * +only_group_impl(PyObject *module, int group_right_1, PyObject *a) +/*[clinic end generated code: output=e92d6c85b72a5897 input=7aca574206712a42]*/ +{ + return pack_arguments_newref(2, group_right_1 ? Py_True : Py_False, a); +} + + +/*[clinic input] +group_and_opt + + [ + a: object + b: object + ] + c: object = None + / + +[clinic start generated code]*/ + +static PyObject * +group_and_opt_impl(PyObject *module, int group_left_1, PyObject *a, + PyObject *b, PyObject *c) +/*[clinic end generated code: output=23413ec545526111 input=8a84d8f44bc8bd0b]*/ +{ + return pack_arguments_newref(4, group_left_1 ? Py_True : Py_False, + a, b, c); +} + + +/*[clinic input] +two_groups_on_left + + [ + a: object + b: object + ] + [ + c: object + ] + d: object + / + +[clinic start generated code]*/ + +static PyObject * +two_groups_on_left_impl(PyObject *module, int group_left_1, PyObject *a, + PyObject *b, int group_left_2, PyObject *c, + PyObject *d) +/*[clinic end generated code: output=3a43d6542864e3d8 input=79fc792669696ac7]*/ +{ + return pack_arguments_newref(6, group_left_1 ? Py_True : Py_False, a, b, + group_left_2 ? Py_True : Py_False, c, d); +} + + +/*[clinic input] +two_groups_on_right + + a: object + [ + b: object + ] + [ + c: object + d: object + ] + / + +[clinic start generated code]*/ + +static PyObject * +two_groups_on_right_impl(PyObject *module, PyObject *a, int group_right_1, + PyObject *b, int group_right_2, PyObject *c, + PyObject *d) +/*[clinic end generated code: output=045f60f127c6e448 input=96895285f29bb501]*/ +{ + return pack_arguments_newref(6, a, group_right_1 ? Py_True : Py_False, b, + group_right_2 ? Py_True : Py_False, c, d); +} + + +/*[clinic input] +group_and_two_opt + + [ + a: object + b: object + c: object + ] + d: object = None + e: object = None + / + +[clinic start generated code]*/ + +static PyObject * +group_and_two_opt_impl(PyObject *module, int group_left_1, PyObject *a, + PyObject *b, PyObject *c, PyObject *d, PyObject *e) +/*[clinic end generated code: output=1427c4b3c35f24ff input=cdda98eec1e365ea]*/ +{ + return pack_arguments_newref(6, group_left_1 ? Py_True : Py_False, + a, b, c, d, e); +} + + /*[clinic input] gh_32092_oob @@ -1401,6 +1522,40 @@ clone_with_conv_f2_impl(PyObject *module, custom_t path) } +/*[clinic input] +alias_pos + + a: object = None + * + b as a: object = None + +[clinic start generated code]*/ + +static PyObject * +alias_pos_impl(PyObject *module, PyObject *a) +/*[clinic end generated code: output=f6cd3c7f098a894d input=8018ee6c26e3f435]*/ +{ + return Py_NewRef(a); +} + + +/*[clinic input] +alias_kwonly + + * + a: object = None + b as a: object = None + +[clinic start generated code]*/ + +static PyObject * +alias_kwonly_impl(PyObject *module, PyObject *a) +/*[clinic end generated code: output=9a6d4202ba972f46 input=8ad2d6c0f326571d]*/ +{ + return Py_NewRef(a); +} + + /*[clinic input] class _testclinic.TestClass "PyObject *" "&PyBaseObject_Type" [clinic start generated code]*/ @@ -1714,6 +1869,20 @@ static PyTypeObject TestClass = { .tp_methods = test_class_methods, }; +/* Heap type sharing TestClass's methods, to test defining_class on both. */ +static PyType_Slot HeapTestClass_slots[] = { + {Py_tp_new, PyType_GenericNew}, + {Py_tp_methods, test_class_methods}, + {0, NULL}, +}; + +static PyType_Spec HeapTestClass_spec = { + .name = "_testclinic.HeapTestClass", + .basicsize = sizeof(PyObject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE, + .slots = HeapTestClass_slots, +}; + /*[clinic input] output push @@ -1768,13 +1937,17 @@ static struct PyMethodDef depr_star_new_methods[] = { {NULL, NULL} }; -static PyTypeObject DeprStarNew = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "_testclinic.DeprStarNew", - .tp_basicsize = sizeof(PyObject), - .tp_new = depr_star_new, - .tp_flags = Py_TPFLAGS_DEFAULT, - .tp_methods = depr_star_new_methods, +static PyType_Slot DeprStarNew_slots[] = { + {Py_tp_new, depr_star_new}, + {Py_tp_methods, depr_star_new_methods}, + {0, NULL}, +}; + +static PyType_Spec DeprStarNew_spec = { + .name = "_testclinic.DeprStarNew", + .basicsize = sizeof(PyObject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE, + .slots = DeprStarNew_slots, }; @@ -1809,14 +1982,18 @@ static struct PyMethodDef depr_star_init_methods[] = { {NULL, NULL} }; -static PyTypeObject DeprStarInit = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "_testclinic.DeprStarInit", - .tp_basicsize = sizeof(PyObject), - .tp_new = PyType_GenericNew, - .tp_init = depr_star_init, - .tp_flags = Py_TPFLAGS_DEFAULT, - .tp_methods = depr_star_init_methods, +static PyType_Slot DeprStarInit_slots[] = { + {Py_tp_new, PyType_GenericNew}, + {Py_tp_init, depr_star_init}, + {Py_tp_methods, depr_star_init_methods}, + {0, NULL}, +}; + +static PyType_Spec DeprStarInit_spec = { + .name = "_testclinic.DeprStarInit", + .basicsize = sizeof(PyObject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE, + .slots = DeprStarInit_slots, }; @@ -1840,13 +2017,17 @@ depr_star_init_noinline_impl(PyObject *self, PyObject *a, PyObject *b, return 0; } -static PyTypeObject DeprStarInitNoInline = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "_testclinic.DeprStarInitNoInline", - .tp_basicsize = sizeof(PyObject), - .tp_new = PyType_GenericNew, - .tp_init = depr_star_init_noinline, - .tp_flags = Py_TPFLAGS_DEFAULT, +static PyType_Slot DeprStarInitNoInline_slots[] = { + {Py_tp_new, PyType_GenericNew}, + {Py_tp_init, depr_star_init_noinline}, + {0, NULL}, +}; + +static PyType_Spec DeprStarInitNoInline_spec = { + .name = "_testclinic.DeprStarInitNoInline", + .basicsize = sizeof(PyObject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE, + .slots = DeprStarInitNoInline_slots, }; @@ -1866,12 +2047,16 @@ depr_kwd_new_impl(PyTypeObject *type, PyObject *a) return type->tp_alloc(type, 0); } -static PyTypeObject DeprKwdNew = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "_testclinic.DeprKwdNew", - .tp_basicsize = sizeof(PyObject), - .tp_new = depr_kwd_new, - .tp_flags = Py_TPFLAGS_DEFAULT, +static PyType_Slot DeprKwdNew_slots[] = { + {Py_tp_new, depr_kwd_new}, + {0, NULL}, +}; + +static PyType_Spec DeprKwdNew_spec = { + .name = "_testclinic.DeprKwdNew", + .basicsize = sizeof(PyObject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE, + .slots = DeprKwdNew_slots, }; @@ -1890,13 +2075,17 @@ depr_kwd_init_impl(PyObject *self, PyObject *a) return 0; } -static PyTypeObject DeprKwdInit = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "_testclinic.DeprKwdInit", - .tp_basicsize = sizeof(PyObject), - .tp_new = PyType_GenericNew, - .tp_init = depr_kwd_init, - .tp_flags = Py_TPFLAGS_DEFAULT, +static PyType_Slot DeprKwdInit_slots[] = { + {Py_tp_new, PyType_GenericNew}, + {Py_tp_init, depr_kwd_init}, + {0, NULL}, +}; + +static PyType_Spec DeprKwdInit_spec = { + .name = "_testclinic.DeprKwdInit", + .basicsize = sizeof(PyObject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE, + .slots = DeprKwdInit_slots, }; @@ -1920,13 +2109,17 @@ depr_kwd_init_noinline_impl(PyObject *self, PyObject *a, PyObject *b, return 0; } -static PyTypeObject DeprKwdInitNoInline = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "_testclinic.DeprKwdInitNoInline", - .tp_basicsize = sizeof(PyObject), - .tp_new = PyType_GenericNew, - .tp_init = depr_kwd_init_noinline, - .tp_flags = Py_TPFLAGS_DEFAULT, +static PyType_Slot DeprKwdInitNoInline_slots[] = { + {Py_tp_new, PyType_GenericNew}, + {Py_tp_init, depr_kwd_init_noinline}, + {0, NULL}, +}; + +static PyType_Spec DeprKwdInitNoInline_spec = { + .name = "_testclinic.DeprKwdInitNoInline", + .basicsize = sizeof(PyObject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE, + .slots = DeprKwdInitNoInline_slots, }; @@ -2277,6 +2470,40 @@ depr_kwd_multi_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, } +/*[clinic input] +depr_alias + a: object = None + * + [until 3.14] b as a: object = None +[clinic start generated code]*/ + +static PyObject * +depr_alias_impl(PyObject *module, PyObject *a) +/*[clinic end generated code: output=85e89838716d9423 input=92efd3f244c2ec3f]*/ +{ + return Py_NewRef(a); +} + + +/*[clinic input] +depr_param + a: object = None + [until 3.14] b: object = None + [until 3.14] c: object = None + / + * + [until 3.14] d: object = None +[clinic start generated code]*/ + +static PyObject * +depr_param_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, + PyObject *d) +/*[clinic end generated code: output=5a42b461851c467b input=f689a85166408359]*/ +{ + return pack_arguments_newref(4, a, b, c, d); +} + + /*[clinic input] depr_multi a: object @@ -2315,6 +2542,170 @@ output pop /*[clinic end generated code: output=da39a3ee5e6b4b0d input=e7c7c42daced52b0]*/ +/* @vectorcall test types. Multiple types as tp_vectorcall is a single slot. */ + +/* VcNew: __new__ with one optional positional-or-keyword arg */ + +/*[clinic input] +class _testclinic.VcNew "PyObject *" "&VcNew_Type" +@classmethod +@vectorcall +_testclinic.VcNew.__new__ as vc_plain_new + a: object = None +[clinic start generated code]*/ + +static PyObject * +vc_plain_new_impl(PyTypeObject *type, PyObject *a) +/*[clinic end generated code: output=55b273e9797a3013 input=e15d88606280badc]*/ +{ + return type->tp_alloc(type, 0); +} + +static PyTypeObject VcNew_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + .tp_name = "_testclinic.VcNew", + .tp_basicsize = sizeof(PyObject), + .tp_flags = Py_TPFLAGS_DEFAULT, + .tp_new = vc_plain_new, + .tp_vectorcall = vc_plain_vectorcall, +}; + + +/* VcInit: __init__ with one required positional-only and one optional keyword + * arg. Uses @critical_section to exercise the {lock}/impl/{unlock} placement + * in both the helper body and the vectorcall fast-path inner block. */ + +/*[clinic input] +class _testclinic.VcInit "PyObject *" "" +@vectorcall +@critical_section +_testclinic.VcInit.__init__ as vc_posorkw_init + a: object + / + b: object = None +[clinic start generated code]*/ + +static int +vc_posorkw_init_impl(PyObject *self, PyObject *a, PyObject *b) +/*[clinic end generated code: output=6018424ba9fb0744 input=f0c7a84428d5b33d]*/ +{ + return 0; +} + +/* Heap type: the generated vectorcall can't name the type object. */ +static PyType_Slot VcInit_slots[] = { + {Py_tp_new, PyType_GenericNew}, + {Py_tp_init, vc_posorkw_init}, + {Py_tp_vectorcall, vc_posorkw_vectorcall}, + {0, NULL}, +}; + +static PyType_Spec VcInit_spec = { + .name = "_testclinic.VcInit", + .basicsize = sizeof(PyObject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE, + .slots = VcInit_slots, +}; + + +/* VcNewBase: __new__ with a required positional-only argument, and the one + * subclassable vectorcall type. tp_vectorcall is not inherited, so a subclass + * is constructed through tp_new, never reaching vc_base_vectorcall. */ + +/*[clinic input] +class _testclinic.VcNewBase "PyObject *" "&VcNewBase_Type" +@classmethod +@vectorcall +_testclinic.VcNewBase.__new__ as vc_base_new + a: object + / + b: object = None +[clinic start generated code]*/ + +static PyObject * +vc_base_new_impl(PyTypeObject *type, PyObject *a, PyObject *b) +/*[clinic end generated code: output=e4ca5a11e7fb1148 input=c204ca773dc608bf]*/ +{ + return type->tp_alloc(type, 0); +} + +static PyTypeObject VcNewBase_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + .tp_name = "_testclinic.VcNewBase", + .tp_basicsize = sizeof(PyObject), + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + .tp_new = vc_base_new, + .tp_vectorcall = vc_base_vectorcall, +}; + + +/* VcKwOnly: @vectorcall + keyword-only arg. + * Exercises the no-kwnames==NULL-fast-path branch of the vectorcall codegen: + * the vectorcall function delegates unconditionally to the helper because the + * keyword-only parameter rules out the positional-only fast path. */ + +/*[clinic input] +class _testclinic.VcKwOnly "PyObject *" "&VcKwOnly_Type" +@classmethod +@vectorcall +_testclinic.VcKwOnly.__new__ as vc_kwonly_new + a: object + * + b: object = None +[clinic start generated code]*/ + +static PyObject * +vc_kwonly_new_impl(PyTypeObject *type, PyObject *a, PyObject *b) +/*[clinic end generated code: output=00417079caa234dc input=68c863b55575a9e1]*/ +{ + return type->tp_alloc(type, 0); +} + +static PyTypeObject VcKwOnly_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + .tp_name = "_testclinic.VcKwOnly", + .tp_basicsize = sizeof(PyObject), + .tp_flags = Py_TPFLAGS_DEFAULT, + .tp_new = vc_kwonly_new, + .tp_vectorcall = vc_kwonly_vectorcall, +}; + + +/* VcKwds: @vectorcall + **kwargs. __new__ returns the parsed arguments. */ + +/*[clinic input] +class _testclinic.VcKwds "PyObject *" "" +@classmethod +@vectorcall +_testclinic.VcKwds.__new__ as vc_kwds_new + a: object + b: object = None + / + **kwds: dict +[clinic start generated code]*/ + +static PyObject * +vc_kwds_new_impl(PyTypeObject *type, PyObject *a, PyObject *b, + PyObject *kwds) +/*[clinic end generated code: output=481e680d2e76fdbd input=3d8e5218fd593383]*/ +{ + return pack_arguments_newref(3, a, b, kwds); +} + +static PyType_Slot VcKwds_slots[] = { + {Py_tp_new, vc_kwds_new}, + {Py_tp_vectorcall, vc_kwds_vectorcall}, + {0, NULL}, +}; +static PyType_Spec VcKwds_spec = { + .name = "_testclinic.VcKwds", + .basicsize = sizeof(PyObject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE, + .slots = VcKwds_slots, +}; + + + /*[clinic input] output push destination kwarg new file '{dirname}/clinic/_testclinic_kwds.c.h' @@ -2358,6 +2749,23 @@ kwds_with_pos_only_impl(PyObject *module, PyObject *a, PyObject *b, } +/*[clinic input] +kwds_with_optional_pos_only + a: object + b: object = None + / + **kwds: dict +[clinic start generated code]*/ + +static PyObject * +kwds_with_optional_pos_only_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *kwds) +/*[clinic end generated code: output=25a8458f5acc1a07 input=0b18b9e1670904ec]*/ +{ + return pack_arguments_newref(3, a, b, kwds); +} + + /*[clinic input] kwds_with_stararg *args: tuple @@ -2455,6 +2863,11 @@ static PyMethodDef tester_methods[] = { POSONLY_VARPOS_ARRAY_METHODDEF POSONLY_REQ_OPT_VARPOS_ARRAY_METHODDEF POSONLY_POSKW_VARPOS_ARRAY_METHODDEF + ONLY_GROUP_METHODDEF + GROUP_AND_OPT_METHODDEF + GROUP_AND_TWO_OPT_METHODDEF + TWO_GROUPS_ON_LEFT_METHODDEF + TWO_GROUPS_ON_RIGHT_METHODDEF GH_32092_OOB_METHODDEF GH_32092_KW_PASS_METHODDEF @@ -2467,6 +2880,9 @@ static PyMethodDef tester_methods[] = { CLONE_WITH_CONV_F1_METHODDEF CLONE_WITH_CONV_F2_METHODDEF + ALIAS_POS_METHODDEF + ALIAS_KWONLY_METHODDEF + DEPR_STAR_POS0_LEN1_METHODDEF DEPR_STAR_POS0_LEN2_METHODDEF DEPR_STAR_POS0_LEN3_WITH_KWD_METHODDEF @@ -2487,58 +2903,68 @@ static PyMethodDef tester_methods[] = { DEPR_KWD_NOINLINE_METHODDEF DEPR_KWD_MULTI_METHODDEF DEPR_MULTI_METHODDEF + DEPR_ALIAS_METHODDEF + DEPR_PARAM_METHODDEF LONE_KWDS_METHODDEF KWDS_WITH_POS_ONLY_METHODDEF + KWDS_WITH_OPTIONAL_POS_ONLY_METHODDEF KWDS_WITH_STARARG_METHODDEF KWDS_WITH_POS_ONLY_AND_STARARG_METHODDEF {NULL, NULL} }; +static int +_testclinic_exec(PyObject *m) +{ + PyTypeObject *static_types[] = { + &TestClass, &VcNew_Type, &VcNewBase_Type, &VcKwOnly_Type, + }; + for (size_t i = 0; i < Py_ARRAY_LENGTH(static_types); i++) { + if (PyModule_AddType(m, static_types[i]) < 0) { + return -1; + } + } + + PyType_Spec *heap_specs[] = { + &HeapTestClass_spec, + &DeprStarNew_spec, &DeprStarInit_spec, &DeprStarInitNoInline_spec, + &DeprKwdNew_spec, &DeprKwdInit_spec, &DeprKwdInitNoInline_spec, + &VcInit_spec, &VcKwds_spec, + }; + for (size_t i = 0; i < Py_ARRAY_LENGTH(heap_specs); i++) { + PyObject *type = PyType_FromModuleAndSpec(m, heap_specs[i], NULL); + if (type == NULL) { + return -1; + } + int rc = PyModule_AddType(m, (PyTypeObject *)type); + Py_DECREF(type); + if (rc < 0) { + return -1; + } + } + return 0; +} + +static PyModuleDef_Slot _testclinic_slots[] = { + {Py_mod_exec, _testclinic_exec}, + {Py_mod_gil, Py_MOD_GIL_NOT_USED}, + {0, NULL}, +}; + static struct PyModuleDef _testclinic_module = { PyModuleDef_HEAD_INIT, .m_name = "_testclinic", .m_size = 0, .m_methods = tester_methods, + .m_slots = _testclinic_slots, }; PyMODINIT_FUNC PyInit__testclinic(void) { - PyObject *m = PyModule_Create(&_testclinic_module); - if (m == NULL) { - return NULL; - } -#ifdef Py_GIL_DISABLED - PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED); -#endif - if (PyModule_AddType(m, &TestClass) < 0) { - goto error; - } - if (PyModule_AddType(m, &DeprStarNew) < 0) { - goto error; - } - if (PyModule_AddType(m, &DeprStarInit) < 0) { - goto error; - } - if (PyModule_AddType(m, &DeprStarInitNoInline) < 0) { - goto error; - } - if (PyModule_AddType(m, &DeprKwdNew) < 0) { - goto error; - } - if (PyModule_AddType(m, &DeprKwdInit) < 0) { - goto error; - } - if (PyModule_AddType(m, &DeprKwdInitNoInline) < 0) { - goto error; - } - return m; - -error: - Py_DECREF(m); - return NULL; + return PyModuleDef_Init(&_testclinic_module); } #undef RETURN_PACKED_ARGS diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c index ea3ad2b81c28668..586b687f233ce02 100644 --- a/Modules/_testinternalcapi.c +++ b/Modules/_testinternalcapi.c @@ -30,6 +30,7 @@ #include "pycore_instruction_sequence.h" // _PyInstructionSequence_New() #include "pycore_interpframe.h" // _PyFrame_GetFunction() #include "pycore_jit.h" // _PyJIT_AddressInJitCode() +#include "pycore_lock.h" // PyEvent_WaitTimed() #include "pycore_object.h" // _PyObject_IsFreed() #include "pycore_optimizer.h" // _Py_Executor_DependsOn #include "pycore_pathconfig.h" // _PyPathConfig_ClearGlobal() @@ -37,6 +38,7 @@ #include "pycore_pylifecycle.h" // _PyInterpreterConfig_InitFromDict() #include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_runtime_structs.h" // _PY_NSMALLPOSINTS +#include "pycore_time.h" // _PyTime_FromSecondsObject() #include "pycore_unicodeobject.h" // _PyUnicode_TransformDecimalAndSpaceToASCII() #include "clinic/_testinternalcapi.c.h" @@ -109,10 +111,20 @@ static const uintptr_t min_frame_pointer_addr = 0x1000; // address is stored at fp[-1]. # define FRAME_POINTER_NEXT_OFFSET -2 # define FRAME_POINTER_RETURN_OFFSET -1 +#elif defined(__sparc__) && defined(__arch64__) +// SPARC V9 has no frame record: fp points to the register window save area, +// where the caller's %fp is saved at fp[14] and its return address (%i7) at +// fp[15]. The saved %fp is biased by 2047. +# define FRAME_POINTER_NEXT_OFFSET 14 +# define FRAME_POINTER_RETURN_OFFSET 15 +# define FRAME_POINTER_BIAS 2047 #else # define FRAME_POINTER_NEXT_OFFSET 0 # define FRAME_POINTER_RETURN_OFFSET 1 #endif +#ifndef FRAME_POINTER_BIAS +# define FRAME_POINTER_BIAS 0 +#endif static PyObject * @@ -208,6 +220,59 @@ get_stack_margin(PyObject *self, PyObject *Py_UNUSED(args)) return PyLong_FromSize_t(_PyOS_STACK_MARGIN_BYTES); } +static PyObject * +stop_the_world(PyObject *self, PyObject *args) +{ + PyObject *duration_obj = NULL; + PyTime_t duration = 0; + if (!PyArg_ParseTuple(args, "|O:stop_the_world", &duration_obj)) { + return NULL; + } + if (duration_obj != NULL && + _PyTime_FromSecondsObject(&duration, duration_obj, + _PyTime_ROUND_TIMEOUT) < 0) { + return NULL; + } + if (duration < 0) { + PyErr_SetString(PyExc_ValueError, "duration must be non-negative"); + return NULL; + } +#ifdef Py_GIL_DISABLED + PyInterpreterState *interp = _PyInterpreterState_GET(); + _PyEval_StopTheWorld(interp); + if (duration != 0) { + PyEvent event = {0}; + PyEvent_WaitTimed(&event, duration, /*detach=*/0); + } + _PyEval_StartTheWorld(interp); +#endif + Py_RETURN_NONE; +} + +PyDoc_STRVAR(stop_the_world_doc, +"stop_the_world($module, duration=0, /)\n" +"--\n" +"\n" +"Stop the world, wait for duration seconds, then restart it.\n" +"Does nothing in GIL-enabled builds."); + +static PyObject * +test_stop_the_world(PyObject *self, PyObject *Py_UNUSED(args)) +{ +#ifdef Py_GIL_DISABLED + PyInterpreterState *interp = _PyInterpreterState_GET(); + // Request consecutive pauses without running Python code between them. + for (int i = 0; i < 100; i++) { + _PyEval_StopTheWorld(interp); + // Give detached threads time to try to reattach during the pause. + PyEvent event = {0}; + PyEvent_WaitTimed(&event, 10 * 1000 * 1000, /*detach=*/0); + _PyEval_StartTheWorld(interp); + } +#endif + Py_RETURN_NONE; +} + #ifdef MS_WINDOWS static const char * classify_address(uintptr_t addr, int jit_enabled, PyInterpreterState *interp) @@ -451,7 +516,7 @@ next_frame_pointer_is_valid(uintptr_t *frame_pointer, uintptr_t *next_fp, #endif } -static PyObject * +static PyObject * _Py_NO_SANITIZE_MEMORY manual_unwind_from_fp(uintptr_t *frame_pointer) { uintptr_t stack_min = 0; @@ -509,7 +574,8 @@ manual_unwind_from_fp(uintptr_t *frame_pointer) stack_min, stack_max)) { break; } - uintptr_t *next_fp = (uintptr_t *)frame_pointer[FRAME_POINTER_NEXT_OFFSET]; + uintptr_t *next_fp = (uintptr_t *)(frame_pointer[FRAME_POINTER_NEXT_OFFSET] + + FRAME_POINTER_BIAS); uintptr_t return_addr = frame_pointer[FRAME_POINTER_RETURN_OFFSET]; PyObject *addr_obj = PyLong_FromUnsignedLongLong(return_addr); @@ -581,6 +647,10 @@ gnu_backtrace_unwind(PyObject *self, PyObject *Py_UNUSED(args)) static PyObject * manual_frame_pointer_unwind(PyObject *self, PyObject *args) { +#if defined(__sparc__) && defined(__arch64__) + // The callers' register windows are only in their save areas once spilled. + __asm__ volatile ("flushw" ::: "memory"); +#endif uintptr_t *frame_pointer = (uintptr_t *)__builtin_frame_address(0); return manual_unwind_from_fp(frame_pointer); } @@ -1028,92 +1098,119 @@ get_getpath_codeobject(PyObject *self, PyObject *Py_UNUSED(args)) { } +// Test _Py_EncodeLocale() static PyObject * -encode_locale_ex(PyObject *self, PyObject *args) +encode_locale(PyObject *self, PyObject *args) { PyObject *unicode; int current_locale = 0; - wchar_t *wstr; PyObject *res = NULL; const char *errors = NULL; if (!PyArg_ParseTuple(args, "U|is", &unicode, ¤t_locale, &errors)) { return NULL; } - wstr = PyUnicode_AsWideCharString(unicode, NULL); + + // Accept embedded null characters + Py_ssize_t unused_wlen; + wchar_t *wstr = PyUnicode_AsWideCharString(unicode, &unused_wlen); if (wstr == NULL) { return NULL; } _Py_error_handler error_handler = _Py_GetErrorHandler(errors); - char *str = NULL; - size_t error_pos; - const char *reason = NULL; - int ret = _Py_EncodeLocaleEx(wstr, - &str, &error_pos, &reason, - current_locale, error_handler); + const char *str_canary = (const char*)0x1234; + char *str = (char*)str_canary; + size_t error_pos_canary = (size_t)-123; + size_t error_pos = error_pos_canary; + const size_t output_length_canary = (size_t)-456; + size_t output_length = output_length_canary; + int ret = _Py_EncodeLocale(wstr, + &str, &output_length, &error_pos, + current_locale, error_handler); PyMem_Free(wstr); switch(ret) { case 0: - res = PyBytes_FromString(str); + assert(str != NULL && str != str_canary); + assert(output_length != output_length_canary); + assert(error_pos == error_pos_canary); + res = PyBytes_FromStringAndSize(str, output_length); PyMem_RawFree(str); break; - case -1: + case _Py_CODEC_MEMORY_ERROR: + assert(str == NULL); + assert(output_length == 0); + assert(error_pos == 0); PyErr_NoMemory(); break; - case -2: - PyErr_Format(PyExc_RuntimeError, "encode error: pos=%zu, reason=%s", - error_pos, reason); + case _Py_CODEC_ENCODE_ERROR: + assert(str == NULL); + assert(output_length == 0); + assert(error_pos != error_pos_canary); + PyErr_Format(PyExc_RuntimeError, "encode error: pos=%zu", error_pos); break; - case -3: + case _Py_CODEC_UNSUPPORTED_ERROR_HANDLER: + assert(str == NULL); + assert(output_length == 0); + assert(error_pos == 0); PyErr_SetString(PyExc_ValueError, "unsupported error handler"); break; default: - PyErr_SetString(PyExc_ValueError, "unknown error code"); + PyErr_SetString(PyExc_SystemError, "unknown error code"); break; } return res; } +// Test _Py_DecodeLocale() static PyObject * -decode_locale_ex(PyObject *self, PyObject *args) +decode_locale(PyObject *self, PyObject *args) { char *str; + Py_ssize_t unused_len; int current_locale = 0; PyObject *res = NULL; const char *errors = NULL; - - if (!PyArg_ParseTuple(args, "y|is", &str, ¤t_locale, &errors)) { + // Accept embedded null bytes in str + if (!PyArg_ParseTuple(args, "y#|is", + &str, &unused_len, ¤t_locale, &errors)) { return NULL; } _Py_error_handler error_handler = _Py_GetErrorHandler(errors); - wchar_t *wstr = NULL; - size_t wlen = 0; - const char *reason = NULL; - int ret = _Py_DecodeLocaleEx(str, - &wstr, &wlen, &reason, - current_locale, error_handler); + const wchar_t *wstr_canary = (const wchar_t*)0x12345; + wchar_t *wstr = (wchar_t*)wstr_canary; + const size_t wlen_canary = (size_t)-123; + size_t wlen = wlen_canary; + int ret = _Py_DecodeLocale(str, &wstr, &wlen, + current_locale, error_handler); switch(ret) { case 0: + assert(wstr != NULL && wstr != wstr_canary); + assert(wlen != wlen_canary); res = PyUnicode_FromWideChar(wstr, wlen); PyMem_RawFree(wstr); break; - case -1: + case _Py_CODEC_MEMORY_ERROR: + assert(wstr == NULL); + assert(wlen == 0); PyErr_NoMemory(); break; - case -2: - PyErr_Format(PyExc_RuntimeError, "decode error: pos=%zu, reason=%s", - wlen, reason); + case _Py_CODEC_DECODE_ERROR: + assert(wstr == NULL); + assert(wlen != wlen_canary); + PyErr_Format(PyExc_RuntimeError, "decode error: pos=%zu", wlen); break; - case -3: + case _Py_CODEC_UNSUPPORTED_ERROR_HANDLER: + assert(wstr == NULL); + assert(wlen == 0); PyErr_SetString(PyExc_ValueError, "unsupported error handler"); break; default: - PyErr_SetString(PyExc_ValueError, "unknown error code"); + PyErr_SetString(PyExc_SystemError, "unknown error code"); break; } return res; @@ -1137,7 +1234,9 @@ record_eval(PyThreadState *tstate, struct _PyInterpreterFrame *f, int exc) assert(module != NULL); module_state *state = get_module_state(module); Py_DECREF(module); - int res = PyList_Append(state->record_list, func->func_name); + PyObject *name = Py_NewRef(FT_ATOMIC_LOAD_PTR_ACQUIRE(func->func_name)); + int res = PyList_Append(state->record_list, name); + Py_DECREF(name); if (res < 0) { return NULL; } @@ -1198,7 +1297,9 @@ record_eval_interp(PyThreadState *tstate, struct _PyInterpreterFrame *f, int exc assert(module != NULL); module_state *state = get_module_state(module); Py_DECREF(module); - int res = PyList_Append(state->record_list, func->func_name); + PyObject *name = Py_NewRef(FT_ATOMIC_LOAD_PTR_ACQUIRE(func->func_name)); + int res = PyList_Append(state->record_list, name); + Py_DECREF(name); if (res < 0) { return NULL; } @@ -1357,13 +1458,16 @@ _testinternalcapi_assemble_code_object_impl(PyObject *module, umd.u_cellvars = PyDict_GetItemString(metadata, "cellvars"); umd.u_freevars = PyDict_GetItemString(metadata, "freevars"); umd.u_fasthidden = PyDict_GetItemString(metadata, "fasthidden"); + if (umd.u_fasthidden == Py_None) { + umd.u_fasthidden = NULL; + } assert(PyDict_Check(umd.u_consts)); assert(PyDict_Check(umd.u_names)); assert(PyDict_Check(umd.u_varnames)); assert(PyDict_Check(umd.u_cellvars)); assert(PyDict_Check(umd.u_freevars)); - assert(PyDict_Check(umd.u_fasthidden)); + assert(umd.u_fasthidden == NULL || PySet_Check(umd.u_fasthidden)); umd.u_argcount = get_nonnegative_int_from_dict(metadata, "argcount"); umd.u_posonlyargcount = get_nonnegative_int_from_dict(metadata, "posonlyargcount"); @@ -1514,6 +1618,80 @@ iframe_getlasti(PyObject *self, PyObject *frame) return PyLong_FromLong(PyUnstable_InterpreterFrame_GetLasti(f)); } +// Reads the locals of the Python frame that called this C function using +// PyUnstable_InterpreterFrame_GetLocal and returns them as a name -> value +// dict, skipping NULL (unset or hidden) slots. +static PyObject * +get_frame_locals(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + PyThreadState *tstate = _PyThreadState_GET(); + _PyInterpreterFrame *frame = _PyThreadState_GetFrame(tstate); + assert(frame != NULL); // there must be a caller frame + PyCodeObject *co = _PyFrame_GetCode(frame); + Py_ssize_t n = co->co_nlocalsplus; + PyObject *dict = PyDict_New(); + if (dict == NULL) { + return NULL; + } + PyObject *names = PyUnstable_Code_GetLocalPlusNames(co); + for (Py_ssize_t i = 0; i < n; i++) { + PyObject *value; + int rc = PyUnstable_InterpreterFrame_GetLocal(frame, i, &value); + if (rc < 0) { + Py_DECREF(names); + Py_DECREF(dict); + assert(value == NULL); + return NULL; + } + if (rc == 0) { + assert(value == NULL); + continue; // unset or hidden slot + } + PyObject *name = PyTuple_GET_ITEM(names, i); + int err = PyDict_SetItem(dict, name, value); + Py_DECREF(value); + if (err < 0) { + Py_DECREF(names); + Py_DECREF(dict); + return NULL; + } + } + Py_DECREF(names); + return dict; +} + +// Calls PyUnstable_InterpreterFrame_GetLocal on the caller's frame for a single +// index and returns (rc, value), or raises if rc is -1. +static PyObject * +get_frame_local(PyObject *self, PyObject *arg) +{ + Py_ssize_t index = PyLong_AsSsize_t(arg); + if (index == -1 && PyErr_Occurred()) { + return NULL; + } + PyThreadState *tstate = _PyThreadState_GET(); + _PyInterpreterFrame *frame = _PyThreadState_GetFrame(tstate); + assert(frame != NULL); // there must be a caller frame + PyObject *value; + int rc = PyUnstable_InterpreterFrame_GetLocal(frame, index, &value); + if (rc < 0) { + assert(value == NULL); + return NULL; + } + if (rc == 0) { + assert(value == NULL); + return Py_BuildValue("iO", rc, Py_None); + } + return Py_BuildValue("iN", rc, value); +} + +static PyObject * +code_get_localsplus_names(PyObject *self, PyObject *arg) +{ + assert(PyCode_Check(arg)); + return PyUnstable_Code_GetLocalPlusNames((PyCodeObject *)arg); +} + static PyObject * code_returns_only_none(PyObject *self, PyObject *arg) { @@ -2008,6 +2186,19 @@ unicode_transformdecimalandspacetoascii(PyObject *self, PyObject *arg) return _PyUnicode_TransformDecimalAndSpaceToASCII(arg); } +/* Return a str holding code points above U+10FFFF. */ +static PyObject * +new_invalid_str(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + PyObject *str = PyUnicode_New(2, _Py_MAX_UNICODE); + if (str == NULL) { + return NULL; + } + PyUnicode_4BYTE_DATA(str)[0] = _Py_MAX_UNICODE + 1; + PyUnicode_4BYTE_DATA(str)[1] = _Py_MAX_UNICODE + 2; + return str; +} + static PyObject * test_pyobject_is_freed(const char *test_name, PyObject *op) { @@ -2062,8 +2253,8 @@ check_pyobject_forbidden_bytes_is_freed(PyObject *self, static PyObject * check_pyobject_freed_is_freed(PyObject *self, PyObject *Py_UNUSED(args)) { - /* ASan or TSan would report an use-after-free error */ -#if defined(_Py_ADDRESS_SANITIZER) || defined(_Py_THREAD_SANITIZER) + /* ASan, MSan or TSan would report an error. */ +#if defined(_Py_ADDRESS_SANITIZER) || defined(_Py_THREAD_SANITIZER) || defined(_Py_MEMORY_SANITIZER) Py_RETURN_NONE; #else PyObject *op = PyObject_CallNoArgs((PyObject *)&PyBaseObject_Type); @@ -2312,8 +2503,7 @@ destroy_interpreter(PyObject *self, PyObject *args, PyObject *kwargs) } t2 = PyThreadState_New(interp); prev = PyThreadState_Swap(t2); - PyThreadState_Clear(t1); - PyThreadState_Delete(t1); + // t1 is deliberately left alive; Py_EndInterpreter() must clean it up. Py_EndInterpreter(t2); PyThreadState_Swap(prev); } @@ -2576,6 +2766,9 @@ get_crossinterp_data(PyObject *self, PyObject *args, PyObject *kwargs) } else { mode = PyUnicode_AsUTF8(modeobj); + if (mode == NULL) { + return NULL; + } if (strlen(mode) == 0) { mode = "xidata"; } @@ -2962,7 +3155,7 @@ EM_JS(int, emscripten_set_up_async_input_device_js, (void), { await sleep(5); return bufs[(idx ++) % 3]; }); - return !!WebAssembly.promising; + return !!Module._Py_EmscriptenStackSwitching; }); static PyObject * @@ -3207,6 +3400,28 @@ test_thread_state_ensure_from_view_interp_switch(PyObject *self, PyObject *unuse Py_RETURN_NONE; } +static PyObject * +unicodewriter_overflow(PyObject *self, PyObject *unused) +{ + PyUnicodeWriter *writer = PyUnicodeWriter_Create(0); + if (writer == NULL) { + return NULL; + } + if (PyUnicodeWriter_WriteASCII(writer, "hello", -1) < 0) { + PyUnicodeWriter_Discard(writer); + return NULL; + } + + _PyUnicodeWriter *impl = (_PyUnicodeWriter*)writer; + PyObject *buffer = impl->buffer; + Py_ssize_t index = PyUnicode_GET_LENGTH(buffer); + PyUnicode_WRITE(impl->kind, impl->data, index, '#'); // overflow! + + // Spoiler: the function doesn't return if an overflow is detected + // in debug mode + return PyUnicodeWriter_Finish(writer); +} + /* Self interrupting context manager */ typedef struct { @@ -3274,6 +3489,8 @@ static PyMethodDef module_functions[] = { {"get_c_recursion_remaining", get_c_recursion_remaining, METH_NOARGS}, {"get_stack_pointer", get_stack_pointer, METH_NOARGS}, {"get_stack_margin", get_stack_margin, METH_NOARGS}, + {"stop_the_world", stop_the_world, METH_VARARGS, stop_the_world_doc}, + {"test_stop_the_world", test_stop_the_world, METH_NOARGS}, {"classify_stack_addresses", classify_stack_addresses, METH_VARARGS}, {"get_jit_code_ranges", get_jit_code_ranges, METH_NOARGS}, {"get_jit_backend", get_jit_backend, METH_NOARGS}, @@ -3288,8 +3505,8 @@ static PyMethodDef module_functions[] = { {"test_bytes_find", test_bytes_find, METH_NOARGS}, {"normalize_path", normalize_path, METH_O, NULL}, {"get_getpath_codeobject", get_getpath_codeobject, METH_NOARGS, NULL}, - {"EncodeLocaleEx", encode_locale_ex, METH_VARARGS}, - {"DecodeLocaleEx", decode_locale_ex, METH_VARARGS}, + {"encode_locale", encode_locale, METH_VARARGS}, + {"decode_locale", decode_locale, METH_VARARGS}, {"set_eval_frame_default", set_eval_frame_default, METH_NOARGS, NULL}, {"set_eval_frame_interp", set_eval_frame_interp, METH_VARARGS, NULL}, {"set_eval_frame_record", set_eval_frame_record, METH_O, NULL}, @@ -3306,6 +3523,9 @@ static PyMethodDef module_functions[] = { {"iframe_getcode", iframe_getcode, METH_O, NULL}, {"iframe_getline", iframe_getline, METH_O, NULL}, {"iframe_getlasti", iframe_getlasti, METH_O, NULL}, + {"get_frame_locals", get_frame_locals, METH_NOARGS, NULL}, + {"get_frame_local", get_frame_local, METH_O, NULL}, + {"code_get_localsplus_names", code_get_localsplus_names, METH_O, NULL}, {"code_returns_only_none", code_returns_only_none, METH_O, NULL}, {"get_co_framesize", get_co_framesize, METH_O, NULL}, {"get_co_localskinds", get_co_localskinds, METH_O, NULL}, @@ -3325,6 +3545,7 @@ static PyMethodDef module_functions[] = { {"_PyTraceMalloc_GetTraceback", tracemalloc_get_traceback, METH_VARARGS}, {"test_tstate_capi", test_tstate_capi, METH_NOARGS, NULL}, {"_PyUnicode_TransformDecimalAndSpaceToASCII", unicode_transformdecimalandspacetoascii, METH_O}, + {"new_invalid_str", new_invalid_str, METH_NOARGS}, {"check_pyobject_forbidden_bytes_is_freed", check_pyobject_forbidden_bytes_is_freed, METH_NOARGS}, {"check_pyobject_freed_is_freed", check_pyobject_freed_is_freed, METH_NOARGS}, @@ -3394,6 +3615,7 @@ static PyMethodDef module_functions[] = { {"test_interp_guard_countdown", test_interp_guard_countdown, METH_NOARGS}, {"test_interp_view_countdown", test_interp_view_countdown, METH_NOARGS}, {"test_thread_state_ensure_from_view_interp_switch", test_thread_state_ensure_from_view_interp_switch, METH_NOARGS}, + {"unicodewriter_overflow", unicodewriter_overflow, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; @@ -3420,9 +3642,15 @@ module_exec(PyObject *module) if (_PyTestInternalCapi_Init_CriticalSection(module) < 0) { return 1; } + if (_PyTestInternalCapi_Init_Tokenizer(module) < 0) { + return 1; + } if (_PyTestInternalCapi_Init_Tuple(module) < 0) { return 1; } + if (_PyTestInternalCapi_Init_TypeCache(module) < 0) { + return 1; + } Py_ssize_t sizeof_gc_head = 0; #ifndef Py_GIL_DISABLED @@ -3494,6 +3722,10 @@ module_exec(PyObject *module) } PyModule_AddObject(module, "SelfInterruptingContextManager", (PyObject *)&SelfInterruptingContextManager_Type); + if (PyModule_AddIntMacro(module, _Py_MAX_UNICODE) < 0) { + return 1; + } + return 0; } diff --git a/Modules/_testinternalcapi/interpreter.c b/Modules/_testinternalcapi/interpreter.c index 237635c5f2bcdba..a67ecdc211bb343 100644 --- a/Modules/_testinternalcapi/interpreter.c +++ b/Modules/_testinternalcapi/interpreter.c @@ -29,8 +29,6 @@ stop_tracing_and_jit(PyThreadState *tstate, _PyInterpreterFrame *frame) } #endif -_PyJitEntryFuncPtr _Py_jit_entry; - #if _Py_TAIL_CALL_INTERP #include "test_targets.h" #include "test_cases.c.h" diff --git a/Modules/_testinternalcapi/parts.h b/Modules/_testinternalcapi/parts.h index 81f536c3babb18c..9b06eec3bce9e65 100644 --- a/Modules/_testinternalcapi/parts.h +++ b/Modules/_testinternalcapi/parts.h @@ -15,6 +15,8 @@ int _PyTestInternalCapi_Init_PyTime(PyObject *module); int _PyTestInternalCapi_Init_Set(PyObject *module); int _PyTestInternalCapi_Init_Complex(PyObject *module); int _PyTestInternalCapi_Init_CriticalSection(PyObject *module); +int _PyTestInternalCapi_Init_Tokenizer(PyObject *module); int _PyTestInternalCapi_Init_Tuple(PyObject *module); +int _PyTestInternalCapi_Init_TypeCache(PyObject *module); #endif // Py_TESTINTERNALCAPI_PARTS_H diff --git a/Modules/_testinternalcapi/test_cases.c.h b/Modules/_testinternalcapi/test_cases.c.h index a17648a33d4fe4a..8bb3f857437792a 100644 --- a/Modules/_testinternalcapi/test_cases.c.h +++ b/Modules/_testinternalcapi/test_cases.c.h @@ -2488,7 +2488,8 @@ assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); } - if (PyCFunction_GET_FLAGS(callable_o) != METH_FASTCALL) { + if ((PyCFunction_GET_FLAGS(callable_o) & + _Py_METH_CALL_FLAGS) != METH_FASTCALL) { UPDATE_MISS_STATS(CALL); assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); @@ -2581,7 +2582,8 @@ assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); } - if (PyCFunction_GET_FLAGS(callable_o) != (METH_FASTCALL | METH_KEYWORDS)) { + if ((PyCFunction_GET_FLAGS(callable_o) & + _Py_METH_CALL_FLAGS) != (METH_FASTCALL | METH_KEYWORDS)) { UPDATE_MISS_STATS(CALL); assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); @@ -2674,7 +2676,8 @@ assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); } - if (PyCFunction_GET_FLAGS(callable_o) != METH_O) { + if ((PyCFunction_GET_FLAGS(callable_o) & + _Py_METH_CALL_FLAGS) != METH_O) { UPDATE_MISS_STATS(CALL); assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); @@ -3981,6 +3984,22 @@ int err = _PyList_AppendTakeRef((PyListObject *)self_o, PyStackRef_AsPyObjectSteal(arg)); UNLOCK_OBJECT(self_o); if (err) { + _PyFrame_SetStackPointer(frame, stack_pointer); + _PyFrame_StackPointerValidate(frame); + _PyStackRef tmp = self; + self = PyStackRef_NULL; + stack_pointer[-2] = self; + PyStackRef_CLOSE(tmp); + _PyFrame_StackPointerInvalidate(frame); + assert(stack_pointer == _PyFrame_GetStackPointer(frame)); + _PyFrame_StackPointerValidate(frame); + tmp = callable; + callable = PyStackRef_NULL; + stack_pointer[-3] = callable; + PyStackRef_CLOSE(tmp); + _PyFrame_StackPointerInvalidate(frame); + stack_pointer += -3; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); JUMP_TO_LABEL(error); } c = callable; @@ -4041,7 +4060,8 @@ assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); } - if (method->d_method->ml_flags != METH_FASTCALL) { + if ((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + METH_FASTCALL) { UPDATE_MISS_STATS(CALL); assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); @@ -4160,7 +4180,8 @@ assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); } - if (method->d_method->ml_flags != (METH_FASTCALL|METH_KEYWORDS)) { + if ((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + (METH_FASTCALL | METH_KEYWORDS)) { UPDATE_MISS_STATS(CALL); assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); @@ -4283,7 +4304,8 @@ assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); } - if (method->d_method->ml_flags != METH_NOARGS) { + if ((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + METH_NOARGS) { UPDATE_MISS_STATS(CALL); assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); @@ -4406,7 +4428,8 @@ assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); } - if (method->d_method->ml_flags != METH_O) { + if ((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + METH_O) { UPDATE_MISS_STATS(CALL); assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); @@ -6776,6 +6799,8 @@ INSTRUCTION_STATS(GET_ANEXT); _PyStackRef aiter; _PyStackRef awaitable; + _PyStackRef null; + _PyStackRef none; aiter = stack_pointer[-1]; _PyFrame_SetStackPointer(frame, stack_pointer); _PyFrame_StackPointerValidate(frame); @@ -6785,8 +6810,12 @@ JUMP_TO_LABEL(error); } awaitable = PyStackRef_FromPyObjectSteal(awaitable_o); + null = PyStackRef_NULL; + none = PyStackRef_None; stack_pointer[0] = awaitable; - stack_pointer += 1; + stack_pointer[1] = null; + stack_pointer[2] = none; + stack_pointer += 3; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); DISPATCH(); } @@ -6801,6 +6830,8 @@ INSTRUCTION_STATS(GET_AWAITABLE); _PyStackRef iterable; _PyStackRef iter; + _PyStackRef null; + _PyStackRef none; iterable = stack_pointer[-1]; _PyFrame_SetStackPointer(frame, stack_pointer); _PyFrame_StackPointerValidate(frame); @@ -6816,8 +6847,12 @@ JUMP_TO_LABEL(error); } iter = PyStackRef_FromPyObjectSteal(iter_o); + null = PyStackRef_NULL; + none = PyStackRef_None; stack_pointer[0] = iter; - stack_pointer += 1; + stack_pointer[1] = null; + stack_pointer[2] = none; + stack_pointer += 3; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); DISPATCH(); } @@ -9207,7 +9242,7 @@ uint32_t dict_version = read_u32(&this_instr[2].cache); uint16_t index = read_u16(&this_instr[4].cache); PyObject *owner_o = PyStackRef_AsPyObjectBorrow(owner); - if (Py_TYPE(owner_o)->tp_getattro != PyModule_Type.tp_getattro) { + if (!PyModule_CheckExact(owner_o)) { UPDATE_MISS_STATS(LOAD_ATTR); assert(_PyOpcode_Deopt[opcode] == (LOAD_ATTR)); JUMP_TO_PREDICTED(LOAD_ATTR); @@ -9907,6 +9942,16 @@ JUMP_TO_LABEL(error); } } + else if (PyLazyImport_CheckExact(value_o)) { + assert(stack_pointer == _PyFrame_GetStackPointer(frame)); + _PyFrame_StackPointerValidate(frame); + Py_SETREF(value_o, _PyLazyImport_Reify( + tstate, value_o, name, class_dict)); + _PyFrame_StackPointerInvalidate(frame); + if (value_o == NULL) { + JUMP_TO_LABEL(error); + } + } stack_pointer += -1; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); @@ -9932,11 +9977,21 @@ _PyStackRef v; mod_or_class_dict = stack_pointer[-1]; PyObject *name = GETITEM(FRAME_CO_NAMES, oparg); + PyObject *namespace = PyStackRef_AsPyObjectBorrow(mod_or_class_dict); int err; _PyFrame_SetStackPointer(frame, stack_pointer); _PyFrame_StackPointerValidate(frame); - PyObject *v_o = _PyMapping_GetOptionalItem2(PyStackRef_AsPyObjectBorrow(mod_or_class_dict), name, &err); + PyObject *v_o = _PyMapping_GetOptionalItem2(namespace, name, &err); _PyFrame_StackPointerInvalidate(frame); + if (v_o != NULL && PyLazyImport_CheckExact(v_o)) { + assert(stack_pointer == _PyFrame_GetStackPointer(frame)); + _PyFrame_StackPointerValidate(frame); + Py_SETREF(v_o, _PyLazyImport_Reify(tstate, v_o, name, namespace)); + _PyFrame_StackPointerInvalidate(frame); + if (v_o == NULL) { + err = -1; + } + } stack_pointer += -1; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); @@ -9947,81 +10002,17 @@ JUMP_TO_LABEL(error); } if (v_o == NULL) { - if (PyDict_CheckExact(GLOBALS()) - && PyDict_CheckExact(BUILTINS())) - { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - v_o = _PyDict_LoadGlobal((PyDictObject *)GLOBALS(), - (PyDictObject *)BUILTINS(), - name); - _PyFrame_StackPointerInvalidate(frame); - if (v_o == NULL) { - if (!_PyErr_Occurred(tstate)) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - _PyEval_FormatExcCheckArg(tstate, PyExc_NameError, - NAME_ERROR_MSG, name); - _PyFrame_StackPointerInvalidate(frame); - } - JUMP_TO_LABEL(error); - } - if (PyLazyImport_CheckExact(v_o)) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - PyObject *l_v = _PyImport_LoadLazyImportTstate(tstate, v_o); - _PyFrame_StackPointerInvalidate(frame); - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_SETREF(v_o, l_v); - _PyFrame_StackPointerInvalidate(frame); - if (v_o == NULL) { - JUMP_TO_LABEL(error); - } - } - } - else { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - v_o = _PyMapping_GetOptionalItem2(GLOBALS(), name, &err); - _PyFrame_StackPointerInvalidate(frame); - if (err < 0) { - JUMP_TO_LABEL(error); - } - if (v_o == NULL) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - v_o = _PyMapping_GetOptionalItem2(BUILTINS(), name, &err); - _PyFrame_StackPointerInvalidate(frame); - if (err < 0) { - JUMP_TO_LABEL(error); - } - if (v_o == NULL) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - _PyEval_FormatExcCheckArg( - tstate, PyExc_NameError, - NAME_ERROR_MSG, name); - _PyFrame_StackPointerInvalidate(frame); - JUMP_TO_LABEL(error); - } - } - if (PyLazyImport_CheckExact(v_o)) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - PyObject *l_v = _PyImport_LoadLazyImportTstate(tstate, v_o); - _PyFrame_StackPointerInvalidate(frame); - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_SETREF(v_o, l_v); - _PyFrame_StackPointerInvalidate(frame); - if (v_o == NULL) { - JUMP_TO_LABEL(error); - } - } + assert(stack_pointer == _PyFrame_GetStackPointer(frame)); + _PyFrame_StackPointerValidate(frame); + _PyEval_LoadGlobalStackRef(GLOBALS(), BUILTINS(), name, &v); + _PyFrame_StackPointerInvalidate(frame); + if (PyStackRef_IsNull(v)) { + JUMP_TO_LABEL(error); } } - v = PyStackRef_FromPyObjectSteal(v_o); + else { + v = PyStackRef_FromPyObjectSteal(v_o); + } stack_pointer[0] = v; stack_pointer += 1; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); @@ -10141,7 +10132,7 @@ assert(_PyOpcode_Deopt[opcode] == (LOAD_GLOBAL)); JUMP_TO_PREDICTED(LOAD_GLOBAL); } - #if Py_GIL_DISABLED + #ifdef Py_GIL_DISABLED int increfed = _Py_TryIncrefCompareStackRef(&entries[index].me_value, res_o, &res); if (!increfed) { UPDATE_MISS_STATS(LOAD_GLOBAL); @@ -10208,7 +10199,7 @@ assert(_PyOpcode_Deopt[opcode] == (LOAD_GLOBAL)); JUMP_TO_PREDICTED(LOAD_GLOBAL); } - #if Py_GIL_DISABLED + #ifdef Py_GIL_DISABLED int increfed = _Py_TryIncrefCompareStackRef(&entries[index].me_value, res_o, &res); if (!increfed) { UPDATE_MISS_STATS(LOAD_GLOBAL); @@ -10275,38 +10266,6 @@ if (v_o == NULL) { JUMP_TO_LABEL(error); } - if (PyLazyImport_CheckExact(v_o)) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - PyObject *l_v = _PyImport_LoadLazyImportTstate(tstate, v_o); - _PyFrame_StackPointerInvalidate(frame); - if (l_v == NULL) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_DECREF(v_o); - _PyFrame_StackPointerInvalidate(frame); - JUMP_TO_LABEL(error); - } - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - int err = PyDict_SetItem(GLOBALS(), name, l_v); - _PyFrame_StackPointerInvalidate(frame); - if (err < 0) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_DECREF(v_o); - _PyFrame_StackPointerInvalidate(frame); - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_DECREF(l_v); - _PyFrame_StackPointerInvalidate(frame); - JUMP_TO_LABEL(error); - } - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_SETREF(v_o, l_v); - _PyFrame_StackPointerInvalidate(frame); - } v = PyStackRef_FromPyObjectSteal(v_o); stack_pointer[0] = v; stack_pointer += 1; @@ -10357,7 +10316,8 @@ ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); _PyFrame_StackPointerValidate(frame); - int err = _PyObject_LookupSpecialMethod(name, method_and_self); + int err = _PyObject_LookupSpecialMethod(name, &method_and_self[0], + &method_and_self[1]); _PyFrame_StackPointerInvalidate(frame); if (err <= 0) { if (err == 0) { @@ -12996,11 +12956,11 @@ _PyStackRef value; _PyStackRef res; _PyStackRef v; - // _GUARD_TOS_INT + // _GUARD_TOS_EXACT_INT { value = stack_pointer[-1]; PyObject *value_o = PyStackRef_AsPyObjectBorrow(value); - if (!_PyLong_CheckExactAndCompact(value_o)) { + if (!PyLong_CheckExact(value_o)) { UPDATE_MISS_STATS(TO_BOOL); assert(_PyOpcode_Deopt[opcode] == (TO_BOOL)); JUMP_TO_PREDICTED(TO_BOOL); diff --git a/Modules/_testinternalcapi/tokenizer.c b/Modules/_testinternalcapi/tokenizer.c new file mode 100644 index 000000000000000..f41a517deefcefd --- /dev/null +++ b/Modules/_testinternalcapi/tokenizer.c @@ -0,0 +1,220 @@ +#include "parts.h" + +#include "../../Parser/tokenizer/source.h" + +static int +check(int condition, const char *message) +{ + if (condition) { + return 0; + } + PyErr_SetString(PyExc_AssertionError, message); + return -1; +} + +static int +check_system_error(int failed, const char *message) +{ + if (!failed || !PyErr_ExceptionMatches(PyExc_SystemError)) { + PyErr_SetString(PyExc_AssertionError, message); + return -1; + } + PyErr_Clear(); + return 0; +} + +static int +check_line_view(const _PyTok_SourceText *source, Py_ssize_t lineno, + const char *expected) +{ + Py_ssize_t len; + const char *line = _PyTok_SourceLineView(source, lineno, &len); + return check(len == (Py_ssize_t)strlen(expected) && + memcmp(line, expected, len) == 0, + "wrong source line view"); +} + +static PyObject * +test_tokenizer_source(PyObject *Py_UNUSED(module), + PyObject *Py_UNUSED(args)) +{ + const char multiple_lines[] = "a\nb\n"; + const char first_line[] = "alpha\n"; + const char second_line[] = "\xce\xb2\n"; + const char expected[] = "alpha\n\xce\xb2\n"; + const char tail[] = "tail"; + const char terminated_line[] = "x\n"; + _PyTok_SourceText source; + _PyTok_SourceInit(&source); + + if (check_line_view(&source, 1, "") < 0) { + goto error; + } + + if (check_system_error( + _PyTok_SourceAppendLine(&source, "", 0) < 0, + "accepted empty source line") < 0 || + check_system_error( + _PyTok_SourceAppendLine( + &source, multiple_lines, sizeof(multiple_lines) - 1) < 0, + "accepted multiple source lines") < 0 || + check(_PyTok_SourceAppendLine( + &source, first_line, sizeof(first_line) - 1) == 0, + "wrong first source offset") < 0 || + check(_PyTok_SourceAppendLine( + &source, second_line, sizeof(second_line) - 1) == + (Py_ssize_t)sizeof(first_line) - 1, + "wrong second source offset") < 0) { + goto error; + } + + if (check_line_view(&source, PY_SSIZE_T_MIN, "alpha") < 0 || + check_line_view(&source, 1, "alpha") < 0 || + check_line_view(&source, 2, "\xce\xb2") < 0 || + check_line_view(&source, 3, "") < 0 || + check_line_view(&source, PY_SSIZE_T_MAX, "") < 0) { + goto error; + } + + if (check(source.len == (Py_ssize_t)sizeof(expected) - 1 && + memcmp(source.bytes, expected, sizeof(expected)) == 0, + "wrong source contents") < 0) { + goto error; + } + + _PyTok_SourceClear(&source); + if (_PyTok_SourceAppendLine(&source, tail, sizeof(tail) - 1) < 0 || + check_system_error( + _PyTok_SourceAppendLine( + &source, terminated_line, sizeof(terminated_line) - 1) < 0, + "appended after unterminated source line") < 0) { + goto error; + } + if (check_line_view(&source, 1, "tail") < 0 || + check_line_view(&source, PY_SSIZE_T_MAX, "tail") < 0) { + goto error; + } + + _PyTok_SourceClear(&source); + if (check(_PyTok_SourceAppendLineWithNewline(&source, "", 0) == 0, + "cannot append empty terminated line") < 0 || + check(_PyTok_SourceAppendLineWithNewline(&source, tail, 4) == 1, + "wrong terminated line offset") < 0 || + check(source.len == 6 && source.nlines == 2 && + memcmp(source.bytes, "\ntail\n", 7) == 0, + "wrong terminated source contents") < 0 || + check_system_error(_PyTok_SourceAppendLineWithNewline( + &source, terminated_line, 2) < 0, + "accepted newline in line payload") < 0) { + goto error; + } + source.base_offset = PY_SSIZE_T_MAX - source.len; + if (check(_PyTok_SourceAppendLineWithNewline(&source, "", 0) < 0 && + PyErr_ExceptionMatches(PyExc_MemoryError), + "accepted overflowing appended newline") < 0) { + goto error; + } + PyErr_Clear(); + source.base_offset = 0; + source.nlines = INT_MAX - 1; + if (check(_PyTok_SourceAppendLineWithNewline(&source, "", 0) < 0 && + PyErr_ExceptionMatches(PyExc_OverflowError), + "accepted overflowing newline count") < 0) { + goto error; + } + PyErr_Clear(); + + _PyTok_SourceClear(&source); + Py_RETURN_NONE; + +error: + _PyTok_SourceClear(&source); + return NULL; +} + +static PyObject * +test_tokenizer_source_discard(PyObject *Py_UNUSED(module), + PyObject *Py_UNUSED(args)) +{ + enum { LINE_COUNT = 2 }; + const char first_line[] = "x\n"; + const char second_line[] = "y\n"; + const char tail[] = "tail"; + const char final_line[] = "z\n"; + const _PyTok_Off first_batch_len = LINE_COUNT * (sizeof(first_line) - 1); + const _PyTok_Off second_batch_len = LINE_COUNT * (sizeof(second_line) - 1); + const _PyTok_Off discarded_len = first_batch_len + second_batch_len; + _PyTok_SourceText source; + _PyTok_SourceInit(&source); + for (int i = 0; i < LINE_COUNT; i++) { + if (_PyTok_SourceAppendLine(&source, first_line, sizeof(first_line) - 1) < 0) { + goto error; + } + } + char *bytes = source.bytes; + _PyTok_Off capacity = source.cap; + _PyTok_SourceDiscard(&source); + if (check(source.base_offset == first_batch_len && source.len == 0 && + source.nlines == 0 && source.bytes == bytes && + source.cap == capacity && source.bytes[0] == '\0', + "discard did not preserve source allocation") < 0) { + goto error; + } + for (int i = 0; i < LINE_COUNT; i++) { + if (check(_PyTok_SourceAppendLine( + &source, second_line, sizeof(second_line) - 1) == + first_batch_len + ((Py_ssize_t)sizeof(second_line) - 1) * i, + "wrong source offset after discard") < 0) { + goto error; + } + } + if (check(source.bytes == bytes && source.cap == capacity, + "discarded allocation was not reused") < 0) { + goto error; + } + _PyTok_SourceDiscard(&source); + if (check(_PyTok_SourceAppendLine( + &source, tail, sizeof(tail) - 1) == discarded_len, + "wrong source offset after repeated discard") < 0) { + goto error; + } + _PyTok_SourceDiscard(&source); + if (check(_PyTok_SourceAppendLine( + &source, final_line, sizeof(final_line) - 1) == + discarded_len + (Py_ssize_t)sizeof(tail) - 1, + "cannot append after discarding unterminated line") < 0) { + goto error; + } + _PyTok_SourceDiscard(&source); + source.base_offset = PY_SSIZE_T_MAX - 1; + if (check(_PyTok_SourceAppendLine( + &source, final_line, sizeof(final_line) - 1) < 0 && + PyErr_ExceptionMatches(PyExc_MemoryError), + "accepted overflowing logical source offset") < 0) { + goto error; + } + PyErr_Clear(); + if (check(source.len == 0 && source.nlines == 0 && + source.base_offset == PY_SSIZE_T_MAX - 1, + "overflow changed retained source") < 0) { + goto error; + } + _PyTok_SourceClear(&source); + Py_RETURN_NONE; + +error: + _PyTok_SourceClear(&source); + return NULL; +} + +static PyMethodDef test_methods[] = { + {"test_tokenizer_source", test_tokenizer_source, METH_NOARGS}, + {"test_tokenizer_source_discard", test_tokenizer_source_discard, METH_NOARGS}, + {NULL}, +}; + +int +_PyTestInternalCapi_Init_Tokenizer(PyObject *module) +{ + return PyModule_AddFunctions(module, test_methods); +} diff --git a/Modules/_testinternalcapi/typecache.c b/Modules/_testinternalcapi/typecache.c new file mode 100644 index 000000000000000..b5fe0cae353801b --- /dev/null +++ b/Modules/_testinternalcapi/typecache.c @@ -0,0 +1,95 @@ +// Test wrappers for the per-type lookup cache (pycore_typecache.h). +// +// Insertion is exercised indirectly through normal attribute access (which +// calls _PyType_Lookup); only Lookup and Invalidate need direct wrappers. + +#include "parts.h" + +#include "pycore_critical_section.h" +#include "pycore_pystate.h" // _PyInterpreterState_GET() +#include "pycore_stackref.h" // PyStackRef_AsPyObjectSteal() +#include "pycore_typecache.h" // _PyTypeCache_Lookup() + + +static int +require_type(PyObject *obj) +{ + if (!PyType_Check(obj)) { + PyErr_SetString(PyExc_TypeError, "expected a type"); + return -1; + } + return 0; +} + +static PyObject * +intern_name(PyObject *name) +{ + if (!PyUnicode_CheckExact(name)) { + PyErr_SetString(PyExc_TypeError, "name must be a str"); + return NULL; + } + Py_INCREF(name); + PyUnicode_InternInPlace(&name); + return name; +} + +// type_cache_lookup(type, name) -> (cache_hit, value_or_None, version_tag) +static PyObject * +type_cache_lookup(PyObject *Py_UNUSED(self), PyObject *args) +{ + PyObject *type_obj, *name; + if (!PyArg_ParseTuple(args, "OU", &type_obj, &name)) { + return NULL; + } + if (require_type(type_obj) < 0) { + return NULL; + } + name = intern_name(name); + if (name == NULL) { + return NULL; + } + struct _PyTypeCacheLookupResult r = + _PyTypeCache_Lookup((PyTypeObject *)type_obj, name); + Py_DECREF(name); + PyObject *value; + if (PyStackRef_IsNull(r.value)) { + value = Py_NewRef(Py_None); + } + else { + value = PyStackRef_AsPyObjectSteal(r.value); + } + return Py_BuildValue("(iNk)", + r.cache_hit, value, + (unsigned long)r.version_tag); +} + +static PyObject * +type_cache_invalidate(PyObject *Py_UNUSED(self), PyObject *type_obj) +{ + if (require_type(type_obj) < 0) { + return NULL; + } + Py_BEGIN_CRITICAL_SECTION_MUTEX(&_PyInterpreterState_GET()->types.mutex); + _PyTypeCache_Invalidate((PyTypeObject *)type_obj); + Py_END_CRITICAL_SECTION(); + Py_RETURN_NONE; +} + + +static PyMethodDef test_methods[] = { + {"type_cache_lookup", type_cache_lookup, METH_VARARGS}, + {"type_cache_invalidate", type_cache_invalidate, METH_O}, + {NULL}, +}; + +int +_PyTestInternalCapi_Init_TypeCache(PyObject *m) +{ + if (PyModule_AddFunctions(m, test_methods) < 0) { + return -1; + } + if (PyModule_AddIntMacro(m, _Py_TYPECACHE_MINSIZE) < 0) { + return -1; + } + return 0; +} diff --git a/Modules/_testlimitedcapi.c b/Modules/_testlimitedcapi.c index 8ce704502af0104..1aee3bc9bf3c1df 100644 --- a/Modules/_testlimitedcapi.c +++ b/Modules/_testlimitedcapi.c @@ -2,107 +2,122 @@ * Test the limited C API. * * The 'test_*' functions exported by this module are run as part of the - * standard Python regression test, via Lib/test/test_capi.py. + * standard Python regression test, via Lib/test/test_capi/test_misc.py. */ #include "_testlimitedcapi/parts.h" -static PyMethodDef TestMethods[] = { - {NULL, NULL} /* sentinel */ -}; - -static struct PyModuleDef _testlimitedcapimodule = { - PyModuleDef_HEAD_INIT, - .m_name = "_testlimitedcapi", - .m_size = 0, - .m_methods = TestMethods, -}; - -PyMODINIT_FUNC -PyInit__testlimitedcapi(void) +static int +module_exec(PyObject *mod) { - PyObject *mod = PyModule_Create(&_testlimitedcapimodule); - if (mod == NULL) { - return NULL; - } -#ifdef Py_GIL_DISABLED - PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED); -#endif - if (_PyTestLimitedCAPI_Init_Abstract(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_ByteArray(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_Bytes(mod) < 0) { - return NULL; + return -1; + } + if (_PyTestLimitedCAPI_Init_Capsule(mod) < 0) { + return -1; } if (_PyTestLimitedCAPI_Init_Codec(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_Complex(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_Dict(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_Eval(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_Float(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_HeaptypeRelative(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_Import(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_List(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_Long(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_Object(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_PyOS(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_Set(mod) < 0) { - return NULL; + return -1; + } + if (_PyTestLimitedCAPI_Init_Slice(mod) < 0) { + return -1; } if (_PyTestLimitedCAPI_Init_Slots(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_Sys(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_ThreadState(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_Tuple(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_Unicode(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_VectorcallLimited(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_Version(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_File(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_Weakref(mod) < 0) { - return NULL; + return -1; } if (_PyTestLimitedCAPI_Init_Run(mod) < 0) { - return NULL; + return -1; + } + if (_PyTestLimitedCAPI_Init_Type(mod) < 0) { + return -1; } - return mod; + if (_PyTestLimitedCAPI_Init_Hash(mod) < 0) { + return -1; + } + if (_PyTestLimitedCAPI_Init_Build(mod) < 0) { + return -1; + } + return 0; +} + +static struct PyModuleDef _testlimitedcapimodule_def = { + PyModuleDef_HEAD_INIT, + .m_name = "_testlimitedcapi", + .m_size = 0, + .m_slots = (PyModuleDef_Slot[]){ + {Py_mod_exec, module_exec}, +#ifdef Py_GIL_DISABLED + {Py_mod_gil, Py_MOD_GIL_NOT_USED}, +#endif + {0} + } +}; + +PyMODINIT_FUNC +PyInit__testlimitedcapi(void) +{ + return PyModuleDef_Init(&_testlimitedcapimodule_def); } diff --git a/Modules/_testlimitedcapi/build.c b/Modules/_testlimitedcapi/build.c new file mode 100644 index 000000000000000..ae26fdc07fe9089 --- /dev/null +++ b/Modules/_testlimitedcapi/build.c @@ -0,0 +1,78 @@ +#include "parts.h" +#include "util.h" + + +static PyObject* +return_string(const char *str) +{ + assert(str != NULL); + return PyUnicode_FromString(str); +} + + +/* Test Py_GetVersion() */ +static PyObject* +py_getversion(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) +{ + return return_string(Py_GetVersion()); +} + + +/* Test Py_GetPlatform() */ +static PyObject* +py_getplatform(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) +{ + return return_string(Py_GetPlatform()); +} + + +/* Test Py_GetCopyright() */ +static PyObject* +py_getcopyright(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) +{ + return return_string(Py_GetCopyright()); +} + + +/* Test Py_GetCompiler() */ +static PyObject* +py_getcompiler(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) +{ + return return_string(Py_GetCompiler()); +} + + +/* Test Py_GetBuildInfo() */ +static PyObject* +py_getbuildinfo(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) +{ + return return_string(Py_GetBuildInfo()); +} + + +/* Test _Py_GetBuiltWithAssert() */ +static PyObject* +_py_getbuiltwithassert(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) +{ + // Function only exported for _testlimitedcapi + PyAPI_FUNC(int) _Py_GetBuiltWithAssert(void); + + return PyLong_FromLong(_Py_GetBuiltWithAssert()); +} + + +static PyMethodDef test_methods[] = { + {"py_getversion", py_getversion, METH_NOARGS}, + {"py_getplatform", py_getplatform, METH_NOARGS}, + {"py_getcopyright", py_getcopyright, METH_NOARGS}, + {"py_getcompiler", py_getcompiler, METH_NOARGS}, + {"py_getbuildinfo", py_getbuildinfo, METH_NOARGS}, + {"_py_getbuiltwithassert", _py_getbuiltwithassert, METH_NOARGS}, + {NULL}, +}; + +int +_PyTestLimitedCAPI_Init_Build(PyObject *m) +{ + return PyModule_AddFunctions(m, test_methods); +} diff --git a/Modules/_testlimitedcapi/capsule.c b/Modules/_testlimitedcapi/capsule.c new file mode 100644 index 000000000000000..8dd870034023a35 --- /dev/null +++ b/Modules/_testlimitedcapi/capsule.c @@ -0,0 +1,66 @@ +#include "parts.h" + +#include // free() + + +static void +capsule_destructor(PyObject *op) +{ + /* If non-NULL, the name and the pointer are the same allocation. */ + free((char *)PyCapsule_GetName(op)); +} + +static PyObject * +capsule_new(PyObject *self, PyObject *arg) +{ + const char *name; + Py_ssize_t size; + if (!PyArg_Parse(arg, "z#", &name, &size)) { + return NULL; + } + char *name_copy = NULL; + if (name != NULL) { + name_copy = strdup(name); + if (name_copy == NULL) { + return PyErr_NoMemory(); + } + } + static const char dummy = 0; + void *pointer = name_copy != NULL ? (void *)name_copy : (void *)&dummy; + PyObject *capsule = PyCapsule_New(pointer, name_copy, capsule_destructor); + if (capsule == NULL) { + free(name_copy); + } + return capsule; +} + +static PyObject * +pycapsule_import(PyObject *self, PyObject *args) +{ + const char *name; + Py_ssize_t size; + int no_block = 0; + if (!PyArg_ParseTuple(args, "z#|i", &name, &size, &no_block)) { + return NULL; + } + void *pointer = PyCapsule_Import(name, no_block); + if (pointer == NULL) { + return NULL; + } + /* Capsules created by capsule_new() store a copy of their name as the + pointer, so a successful import round-trips the name. Only use this + function with such capsules. */ + return PyUnicode_FromString((const char *)pointer); +} + +static PyMethodDef test_methods[] = { + {"capsule_new", capsule_new, METH_O}, + {"PyCapsule_Import", pycapsule_import, METH_VARARGS}, + {NULL}, +}; + +int +_PyTestLimitedCAPI_Init_Capsule(PyObject *m) +{ + return PyModule_AddFunctions(m, test_methods); +} diff --git a/Modules/_testlimitedcapi/codec.c b/Modules/_testlimitedcapi/codec.c index fdc18eedc2d2886..e9c8fed198ebfe4 100644 --- a/Modules/_testlimitedcapi/codec.c +++ b/Modules/_testlimitedcapi/codec.c @@ -1,8 +1,9 @@ #include "pyconfig.h" // Py_GIL_DISABLED - -// Need limited C API version 3.5 for PyCodec_NameReplaceErrors() -#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API) -# define Py_LIMITED_API 0x03050000 +#ifdef Py_GIL_DISABLED +# define Py_TARGET_ABI3T 0x030f0000 +#else + // Need limited C API version 3.13 for PyMem_RawFree() +# define Py_LIMITED_API 0x030d0000 #endif #include "parts.h" @@ -14,16 +15,93 @@ codec_namereplace_errors(PyObject *Py_UNUSED(module), PyObject *exc) return PyCodec_NameReplaceErrors(exc); } + +// Test Py_DecodeLocale() +static PyObject * +decode_locale(PyObject *Py_UNUSED(module), PyObject *arg) +{ + const char *str; + Py_ssize_t unused_len; + // Accept embedded null bytes + if (PyArg_Parse(arg, "y#", &str, &unused_len) < 0) { + return NULL; + } + + const size_t size_canary = (size_t)-123; + size_t size = size_canary; + wchar_t *wstr = Py_DecodeLocale(str, &size); + + if (wstr == NULL) { + if (size == (size_t)-1) { + PyErr_NoMemory(); + } + else if (size == (size_t)-2) { + PyErr_SetString(PyExc_RuntimeError, "decode error"); + } + else { + PyErr_Format(PyExc_SystemError, + "unknown Py_DecodeLocale() return value: %zd", + (Py_ssize_t)size); + } + return NULL; + } + assert(wstr != NULL); + assert(size != size_canary); + + PyObject *result = PyUnicode_FromWideChar(wstr, size); + PyMem_RawFree(wstr); + return result; +} + + +// Test Py_EncodeLocale() +static PyObject * +encode_locale(PyObject *Py_UNUSED(module), PyObject *arg) +{ + PyObject *unicode; + if (PyArg_Parse(arg, "U", &unicode) < 0) { + return NULL; + } + + // Accept embedded null characters + Py_ssize_t unused_wlen; + wchar_t *wstr = PyUnicode_AsWideCharString(unicode, &unused_wlen); + if (wstr == NULL) { + return NULL; + } + + const size_t error_pos_canary = (size_t)-123; + size_t error_pos = error_pos_canary; + char *str = Py_EncodeLocale(wstr, &error_pos); + PyMem_Free(wstr); + + if (str == NULL) { + if (error_pos == (size_t)-1) { + return PyErr_NoMemory(); + } + else { + assert(error_pos != error_pos_canary); + return PyErr_Format(PyExc_RuntimeError, + "encode error: pos=%zd", error_pos); + } + } + assert(error_pos == error_pos_canary); + + PyObject *result = PyBytes_FromString(str); + PyMem_Free(str); + return result; +} + + static PyMethodDef test_methods[] = { {"codec_namereplace_errors", codec_namereplace_errors, METH_O}, + {"decode_locale", decode_locale, METH_O}, + {"encode_locale", encode_locale, METH_O}, {NULL}, }; int _PyTestLimitedCAPI_Init_Codec(PyObject *module) { - if (PyModule_AddFunctions(module, test_methods) < 0) { - return -1; - } - return 0; + return PyModule_AddFunctions(module, test_methods); } diff --git a/Modules/_testlimitedcapi/file.c b/Modules/_testlimitedcapi/file.c index e082e3c6700ee71..c627c6ceaa201ef 100644 --- a/Modules/_testlimitedcapi/file.c +++ b/Modules/_testlimitedcapi/file.c @@ -1,5 +1,7 @@ #include "pyconfig.h" // Py_GIL_DISABLED -#ifndef Py_GIL_DISABLED +#ifdef Py_GIL_DISABLED +# define Py_TARGET_ABI3T 0x030f0000 +#else // Need limited C API 3.13 for PyLong_AsInt() # define Py_LIMITED_API 0x030d0000 #endif diff --git a/Modules/_testlimitedcapi/hash.c b/Modules/_testlimitedcapi/hash.c new file mode 100644 index 000000000000000..a17359d5aa45fe5 --- /dev/null +++ b/Modules/_testlimitedcapi/hash.c @@ -0,0 +1,40 @@ +// Need limited C API version 3.16 for Py_HashBuffer() +#define Py_LIMITED_API 0x03100000 + +#include "parts.h" +#include "util.h" + + +static PyObject* +long_from_hash(Py_hash_t hash) +{ + Py_BUILD_ASSERT(sizeof(long long) >= sizeof(hash)); + return PyLong_FromLongLong(hash); +} + + +// Test Py_HashBuffer() +static PyObject* +hash_buffer(PyObject *Py_UNUSED(module), PyObject *args) +{ + char *ptr; + Py_ssize_t len; + if (!PyArg_ParseTuple(args, "y#", &ptr, &len)) { + return NULL; + } + + Py_hash_t hash = Py_HashBuffer(ptr, len); + return long_from_hash(hash); +} + + +static PyMethodDef test_methods[] = { + {"hash_buffer", hash_buffer, METH_VARARGS}, + {NULL}, +}; + +int +_PyTestLimitedCAPI_Init_Hash(PyObject *m) +{ + return PyModule_AddFunctions(m, test_methods); +} diff --git a/Modules/_testlimitedcapi/heaptype_relative.c b/Modules/_testlimitedcapi/heaptype_relative.c index c02a52368b5324c..f21ca9250ed2666 100644 --- a/Modules/_testlimitedcapi/heaptype_relative.c +++ b/Modules/_testlimitedcapi/heaptype_relative.c @@ -1,6 +1,8 @@ -// Need limited C API version 3.15 for _DuringGC functions #include "pyconfig.h" // Py_GIL_DISABLED -#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API) +#ifdef Py_GIL_DISABLED + // Cannot test the limited C API +#else + // Need limited C API version 3.15 for _DuringGC functions # define Py_LIMITED_API 0x030f0000 #endif @@ -66,7 +68,7 @@ make_sized_heaptypes(PyObject *module, PyObject *args) } result = Py_BuildValue("OOOKnn", base, sub, instance, - (unsigned long long)data_ptr, + (unsigned long long)(uintptr_t)data_ptr, (Py_ssize_t)(data_ptr - (char*)instance), data_size); finally: diff --git a/Modules/_testlimitedcapi/import.c b/Modules/_testlimitedcapi/import.c index f572212ba88b76e..48c477bf3ccc489 100644 --- a/Modules/_testlimitedcapi/import.c +++ b/Modules/_testlimitedcapi/import.c @@ -1,6 +1,8 @@ -// Need limited C API version 3.13 for PyImport_AddModuleRef() #include "pyconfig.h" // Py_GIL_DISABLED -#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API) +#ifdef Py_GIL_DISABLED +# define Py_TARGET_ABI3T 0x030f0000 +#else + // Need limited C API version 3.13 for PyImport_AddModuleRef() # define Py_LIMITED_API 0x030d0000 #endif diff --git a/Modules/_testlimitedcapi/list.c b/Modules/_testlimitedcapi/list.c index ed492c3e719727a..91c8ad60e3b990d 100644 --- a/Modules/_testlimitedcapi/list.c +++ b/Modules/_testlimitedcapi/list.c @@ -1,6 +1,8 @@ -// Need limited C API version 3.13 for PyList_GetItemRef() #include "pyconfig.h" // Py_GIL_DISABLED -#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API) +#ifdef Py_GIL_DISABLED +# define Py_TARGET_ABI3T 0x030f0000 +#else + // Need limited C API version 3.13 for PyList_GetItemRef() # define Py_LIMITED_API 0x030d0000 #endif diff --git a/Modules/_testlimitedcapi/long.c b/Modules/_testlimitedcapi/long.c index 99b9e96760d50df..1654f9210e1d0ba 100644 --- a/Modules/_testlimitedcapi/long.c +++ b/Modules/_testlimitedcapi/long.c @@ -1,5 +1,7 @@ #include "pyconfig.h" // Py_GIL_DISABLED -#ifndef Py_GIL_DISABLED +#ifdef Py_GIL_DISABLED +# define Py_TARGET_ABI3T 0x030f0000 +#else // Need limited C API 3.14 to test PyLong_AsInt64() # define Py_LIMITED_API 0x030e0000 #endif @@ -762,8 +764,9 @@ static PyObject * pylong_asint32(PyObject *module, PyObject *arg) { NULLABLE(arg); - int32_t value; + int32_t value = UNINITIALIZED_INT; if (PyLong_AsInt32(arg, &value) < 0) { + assert(value == UNINITIALIZED_INT); return NULL; } return PyLong_FromInt32(value); @@ -773,8 +776,9 @@ static PyObject * pylong_asuint32(PyObject *module, PyObject *arg) { NULLABLE(arg); - uint32_t value; + uint32_t value = UNINITIALIZED_INT; if (PyLong_AsUInt32(arg, &value) < 0) { + assert(value == UNINITIALIZED_INT); return NULL; } return PyLong_FromUInt32(value); @@ -785,8 +789,9 @@ static PyObject * pylong_asint64(PyObject *module, PyObject *arg) { NULLABLE(arg); - int64_t value; + int64_t value = UNINITIALIZED_INT; if (PyLong_AsInt64(arg, &value) < 0) { + assert(value == UNINITIALIZED_INT); return NULL; } return PyLong_FromInt64(value); @@ -796,8 +801,9 @@ static PyObject * pylong_asuint64(PyObject *module, PyObject *arg) { NULLABLE(arg); - uint64_t value; + uint64_t value = UNINITIALIZED_INT; if (PyLong_AsUInt64(arg, &value) < 0) { + assert(value == UNINITIALIZED_INT); return NULL; } return PyLong_FromUInt64(value); diff --git a/Modules/_testlimitedcapi/object.c b/Modules/_testlimitedcapi/object.c index da6fe3e4efa34c2..5eee2a9a5210e71 100644 --- a/Modules/_testlimitedcapi/object.c +++ b/Modules/_testlimitedcapi/object.c @@ -1,6 +1,8 @@ -// Need limited C API version 3.13 for Py_GetConstant() #include "pyconfig.h" // Py_GIL_DISABLED -#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API) +#ifdef Py_GIL_DISABLED +# define Py_TARGET_ABI3T 0x030f0000 +#else + // Need limited C API version 3.13 for Py_GetConstant() # define Py_LIMITED_API 0x030d0000 #endif @@ -62,10 +64,317 @@ test_constants(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) Py_RETURN_NONE; } + +static PyObject * +_test_incref(PyObject *ob) +{ + return Py_NewRef(ob); +} + +static PyObject * +test_xincref_doesnt_leak(PyObject *ob, PyObject *Py_UNUSED(ignored)) +{ + PyObject *obj = PyLong_FromLong(0); + Py_XINCREF(_test_incref(obj)); + Py_DECREF(obj); + Py_DECREF(obj); + Py_DECREF(obj); + Py_RETURN_NONE; +} + + +static PyObject * +test_incref_doesnt_leak(PyObject *ob, PyObject *Py_UNUSED(ignored)) +{ + PyObject *obj = PyLong_FromLong(0); + Py_INCREF(_test_incref(obj)); + Py_DECREF(obj); + Py_DECREF(obj); + Py_DECREF(obj); + Py_RETURN_NONE; +} + + +static PyObject * +test_xdecref_doesnt_leak(PyObject *ob, PyObject *Py_UNUSED(ignored)) +{ + Py_XDECREF(PyLong_FromLong(0)); + Py_RETURN_NONE; +} + + +static PyObject * +test_decref_doesnt_leak(PyObject *ob, PyObject *Py_UNUSED(ignored)) +{ + Py_DECREF(PyLong_FromLong(0)); + Py_RETURN_NONE; +} + + +static PyObject * +test_incref_decref_API(PyObject *ob, PyObject *Py_UNUSED(ignored)) +{ + PyObject *obj = PyLong_FromLong(0); + Py_IncRef(obj); + Py_DecRef(obj); + Py_DecRef(obj); + Py_RETURN_NONE; +} + + +// Test Py_CLEAR() macro +static PyObject* +test_py_clear(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + // simple case with a variable + PyObject *obj = PyList_New(0); + if (obj == NULL) { + return NULL; + } + Py_CLEAR(obj); + assert(obj == NULL); + + // gh-98724: complex case, Py_CLEAR() argument has a side effect + PyObject* array[1]; + array[0] = PyList_New(0); + if (array[0] == NULL) { + return NULL; + } + + PyObject **p = array; + Py_CLEAR(*p++); + assert(array[0] == NULL); + assert(p == array + 1); + + Py_RETURN_NONE; +} + + +// Test Py_SETREF() and Py_XSETREF() macros, similar to test_py_clear() +static PyObject* +test_py_setref(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + // Py_SETREF() simple case with a variable + PyObject *obj = PyList_New(0); + if (obj == NULL) { + return NULL; + } + Py_SETREF(obj, NULL); + assert(obj == NULL); + + // Py_XSETREF() simple case with a variable + PyObject *obj2 = PyList_New(0); + if (obj2 == NULL) { + return NULL; + } + Py_XSETREF(obj2, NULL); + assert(obj2 == NULL); + // test Py_XSETREF() when the argument is NULL + Py_XSETREF(obj2, NULL); + assert(obj2 == NULL); + + // gh-98724: complex case, Py_SETREF() argument has a side effect + PyObject* array[1]; + array[0] = PyList_New(0); + if (array[0] == NULL) { + return NULL; + } + + PyObject **p = array; + Py_SETREF(*p++, NULL); + assert(array[0] == NULL); + assert(p == array + 1); + + // gh-98724: complex case, Py_XSETREF() argument has a side effect + PyObject* array2[1]; + array2[0] = PyList_New(0); + if (array2[0] == NULL) { + return NULL; + } + + PyObject **p2 = array2; + Py_XSETREF(*p2++, NULL); + assert(array2[0] == NULL); + assert(p2 == array2 + 1); + + // test Py_XSETREF() when the argument is NULL + p2 = array2; + Py_XSETREF(*p2++, NULL); + assert(array2[0] == NULL); + assert(p2 == array2 + 1); + + Py_RETURN_NONE; +} + + +#define TEST_REFCOUNT() \ + do { \ + PyObject *obj = PyList_New(0); \ + if (obj == NULL) { \ + return NULL; \ + } \ + assert(Py_REFCNT(obj) == 1); \ + \ + /* test Py_NewRef() */ \ + PyObject *ref = Py_NewRef(obj); \ + assert(ref == obj); \ + assert(Py_REFCNT(obj) == 2); \ + Py_DECREF(ref); \ + \ + /* test Py_XNewRef() */ \ + PyObject *xref = Py_XNewRef(obj); \ + assert(xref == obj); \ + assert(Py_REFCNT(obj) == 2); \ + Py_DECREF(xref); \ + \ + assert(Py_XNewRef(NULL) == NULL); \ + \ + Py_DECREF(obj); \ + Py_RETURN_NONE; \ + } while (0) + + +// Test Py_NewRef() and Py_XNewRef() macros +static PyObject* +test_refcount_macros(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + TEST_REFCOUNT(); +} + + +// Test Py_MIN(), Py_MAX() and Py_ABS() macros. +// On GCC/clang, they are implemented as a statement expression to only +// evaluate each argument only once. +static PyObject* +test_min_max_abs_macros(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + int x = 5, y = 7, z = -11; + + // Simple usage + assert(Py_MIN(x, y) == 5); + assert(Py_MAX(x, y) == 7); + assert(Py_ABS(z) == 11); + + // Combined macros + assert(Py_MIN(x, Py_MIN(y, z)) == -11); + assert(Py_MAX(x, Py_MAX(y, z)) == 7); + assert(Py_MIN(x, Py_MAX(y, z)) == 5); + assert(Py_MAX(x, Py_MIN(y, z)) == 5); + assert(Py_ABS(Py_ABS(z)) == 11); + + // A few more tests + assert(Py_MIN(2, Py_MIN(6, 12)) == 2); + assert(Py_MAX(2, Py_MAX(6, 12)) == 12); + assert(Py_MIN(2, Py_MAX(6, 12)) == 2); + assert(Py_MAX(2, Py_MIN(6, 12)) == 6); + assert(Py_MIN(Py_MIN(2, 6), 12) == 2); + assert(Py_MAX(Py_MAX(2, 6), 12) == 12); + assert(Py_MIN(Py_MAX(2, 6), 12) == 6); + assert(Py_MAX(Py_MIN(2, 6), 12) == 12); + assert(Py_ABS(Py_ABS(12)) == 12); + assert(Py_ABS(Py_ABS(12)) == 12); + + // Integer limits + assert(Py_MIN(123, INT_MIN) == INT_MIN); + assert(Py_MAX(123, INT_MAX) == INT_MAX); + assert(Py_ABS(INT_MAX) == INT_MAX); + // Do not tests Py_ABS(INT_MIN), since the behavior is documented. + // This limitation is documented in Py_ABS() documentation. + +#if ((defined(__GNUC__) || defined(__clang__)) \ + && defined(_Py_TYPEOF) && !defined(__cplusplus)) + // Check that arguments are only evaluated once + int a = 5, b = 7, c = -11; + assert(Py_MIN(++a, ++b) == 6); + assert(a == 6); + assert(b == 8); + assert(Py_MAX(++a, ++b) == 9); + assert(a == 7); + assert(b == 9); + assert(Py_ABS(--c) == 12); + assert(c == -12); +#endif + + Py_RETURN_NONE; +} + +#undef Py_NewRef +#undef Py_XNewRef + +// Test Py_NewRef() and Py_XNewRef() functions, after undefining macros. +static PyObject* +test_refcount_funcs(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + TEST_REFCOUNT(); +} + + +// Test Py_Is() function +#define TEST_PY_IS() \ + do { \ + PyObject *o_none = Py_None; \ + PyObject *o_true = Py_True; \ + PyObject *o_false = Py_False; \ + PyObject *obj = PyList_New(0); \ + if (obj == NULL) { \ + return NULL; \ + } \ + \ + /* test Py_Is() */ \ + assert(Py_Is(obj, obj)); \ + assert(!Py_Is(obj, o_none)); \ + \ + /* test Py_None */ \ + assert(Py_Is(o_none, o_none)); \ + assert(!Py_Is(obj, o_none)); \ + \ + /* test Py_True */ \ + assert(Py_Is(o_true, o_true)); \ + assert(!Py_Is(o_false, o_true)); \ + assert(!Py_Is(obj, o_true)); \ + \ + /* test Py_False */ \ + assert(Py_Is(o_false, o_false)); \ + assert(!Py_Is(o_true, o_false)); \ + assert(!Py_Is(obj, o_false)); \ + \ + Py_DECREF(obj); \ + Py_RETURN_NONE; \ + } while (0) + +// Test Py_Is() macro +static PyObject* +test_py_is_macros(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + TEST_PY_IS(); +} + +#undef Py_Is + +// Test Py_Is() function, after undefining its macro. +static PyObject* +test_py_is_funcs(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + TEST_PY_IS(); +} + + static PyMethodDef test_methods[] = { {"get_constant", get_constant, METH_VARARGS}, {"get_constant_borrowed", get_constant_borrowed, METH_VARARGS}, {"test_constants", test_constants, METH_NOARGS}, + {"test_xincref_doesnt_leak",test_xincref_doesnt_leak, METH_NOARGS}, + {"test_incref_doesnt_leak", test_incref_doesnt_leak, METH_NOARGS}, + {"test_xdecref_doesnt_leak",test_xdecref_doesnt_leak, METH_NOARGS}, + {"test_decref_doesnt_leak", test_decref_doesnt_leak, METH_NOARGS}, + {"test_incref_decref_API", test_incref_decref_API, METH_NOARGS}, + {"test_py_clear", test_py_clear, METH_NOARGS}, + {"test_py_setref", test_py_setref, METH_NOARGS}, + {"test_refcount_macros", test_refcount_macros, METH_NOARGS}, + {"test_refcount_funcs", test_refcount_funcs, METH_NOARGS}, + {"test_min_max_abs_macros", test_min_max_abs_macros, METH_NOARGS}, + {"test_py_is_macros", test_py_is_macros, METH_NOARGS}, + {"test_py_is_funcs", test_py_is_funcs, METH_NOARGS}, {NULL}, }; diff --git a/Modules/_testlimitedcapi/parts.h b/Modules/_testlimitedcapi/parts.h index a11e0edb8311e31..1e9d140899cecfd 100644 --- a/Modules/_testlimitedcapi/parts.h +++ b/Modules/_testlimitedcapi/parts.h @@ -7,8 +7,10 @@ #include "pyconfig.h" // Py_GIL_DISABLED // Use the limited C API -#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API) - // need limited C API version 3.5 for PyModule_AddFunctions() +#ifdef Py_GIL_DISABLED + // Cannot test the limited C API +#elif !defined(Py_LIMITED_API) + // Need limited C API version 3.5 for PyModule_AddFunctions() # define Py_LIMITED_API 0x03050000 #endif @@ -25,6 +27,7 @@ int _PyTestLimitedCAPI_Init_Abstract(PyObject *module); int _PyTestLimitedCAPI_Init_ByteArray(PyObject *module); int _PyTestLimitedCAPI_Init_Bytes(PyObject *module); +int _PyTestLimitedCAPI_Init_Capsule(PyObject *module); int _PyTestLimitedCAPI_Init_Codec(PyObject *module); int _PyTestLimitedCAPI_Init_Complex(PyObject *module); int _PyTestLimitedCAPI_Init_Dict(PyObject *module); @@ -37,6 +40,7 @@ int _PyTestLimitedCAPI_Init_List(PyObject *module); int _PyTestLimitedCAPI_Init_Long(PyObject *module); int _PyTestLimitedCAPI_Init_PyOS(PyObject *module); int _PyTestLimitedCAPI_Init_Set(PyObject *module); +int _PyTestLimitedCAPI_Init_Slice(PyObject *module); int _PyTestLimitedCAPI_Init_Slots(PyObject *module); int _PyTestLimitedCAPI_Init_Sys(PyObject *module); int _PyTestLimitedCAPI_Init_ThreadState(PyObject *module); @@ -47,5 +51,8 @@ int _PyTestLimitedCAPI_Init_Version(PyObject *module); int _PyTestLimitedCAPI_Init_File(PyObject *module); int _PyTestLimitedCAPI_Init_Weakref(PyObject *module); int _PyTestLimitedCAPI_Init_Run(PyObject *module); +int _PyTestLimitedCAPI_Init_Type(PyObject *module); +int _PyTestLimitedCAPI_Init_Hash(PyObject *module); +int _PyTestLimitedCAPI_Init_Build(PyObject *module); #endif // Py_TESTLIMITEDCAPI_PARTS_H diff --git a/Modules/_testlimitedcapi/slice.c b/Modules/_testlimitedcapi/slice.c new file mode 100644 index 000000000000000..febb3d0de3cfa6c --- /dev/null +++ b/Modules/_testlimitedcapi/slice.c @@ -0,0 +1,240 @@ +#include "pyconfig.h" // Py_GIL_DISABLED +#ifdef Py_GIL_DISABLED +# define Py_TARGET_ABI3T 0x030f0000 +#else + // Need limited C API 3.6.1 for PySlice_Unpack() and PySlice_AdjustIndices() + // and for PySlice_GetIndicesEx() implemented as a macro. +# define Py_LIMITED_API 0x03060100 +#endif + +#include "parts.h" +#include "util.h" + + +static PyObject * +slice_check(PyObject *Py_UNUSED(module), PyObject *obj) +{ + NULLABLE(obj); + return PyLong_FromLong(PySlice_Check(obj)); +} + +static PyObject * +slice_new(PyObject *Py_UNUSED(module), PyObject *args) +{ + PyObject *start, *stop, *step; + + if (!PyArg_ParseTuple(args, "OOO", &start, &stop, &step)) { + return NULL; + } + NULLABLE(start); + NULLABLE(stop); + NULLABLE(step); + return PySlice_New(start, stop, step); +} + +/* Returns the (start, stop, step) triple on success. If PySlice_GetIndices() + * fails without setting an exception, returns None. */ +static PyObject * +slice_getindices(PyObject *Py_UNUSED(module), PyObject *args) +{ + PyObject *slice; + Py_ssize_t length; + Py_ssize_t start = UNINITIALIZED_SIZE; + Py_ssize_t stop = UNINITIALIZED_SIZE; + Py_ssize_t step = UNINITIALIZED_SIZE; + + if (!PyArg_ParseTuple(args, "On", &slice, &length)) { + return NULL; + } + NULLABLE(slice); + if (PySlice_GetIndices(slice, length, &start, &stop, &step) < 0) { + if (PyErr_Occurred()) { + return NULL; + } + Py_RETURN_NONE; + } + assert(!PyErr_Occurred()); + assert(start != UNINITIALIZED_SIZE); + assert(stop != UNINITIALIZED_SIZE); + assert(step != UNINITIALIZED_SIZE); + return Py_BuildValue("nnn", start, stop, step); +} + +/* Test PySlice_GetIndicesEx() implemented as a macro using PySlice_Unpack() + * and PySlice_AdjustIndices(). */ +static PyObject * +slice_getindicesex_macro(PyObject *Py_UNUSED(module), PyObject *args) +{ + PyObject *slice; + Py_ssize_t length = UNINITIALIZED_SIZE; + Py_ssize_t start = UNINITIALIZED_SIZE; + Py_ssize_t stop = UNINITIALIZED_SIZE; + Py_ssize_t step = UNINITIALIZED_SIZE; + Py_ssize_t slicelength = UNINITIALIZED_SIZE; + + if (!PyArg_ParseTuple(args, "On", &slice, &length)) { + return NULL; + } + NULLABLE(slice); + if (PySlice_GetIndicesEx(slice, length, + &start, &stop, &step, &slicelength) < 0) { + assert(PyErr_Occurred()); + /* The macro sets the slice length to 0 on error. */ + assert(slicelength == 0); + return NULL; + } + assert(!PyErr_Occurred()); + assert(start != UNINITIALIZED_SIZE); + assert(stop != UNINITIALIZED_SIZE); + assert(step != UNINITIALIZED_SIZE); + assert(slicelength != UNINITIALIZED_SIZE); + return Py_BuildValue("nnnn", start, stop, step, slicelength); +} + +/* Same as slice_getindicesex_macro(), but the length is the size of a sequence. + * The macro evaluates it after calling PySlice_Unpack(), which can execute + * arbitrary Python code and resize the sequence. */ +static PyObject * +slice_getindicesex_seq_macro(PyObject *Py_UNUSED(module), PyObject *args) +{ + PyObject *slice, *seq; + Py_ssize_t start = UNINITIALIZED_SIZE; + Py_ssize_t stop = UNINITIALIZED_SIZE; + Py_ssize_t step = UNINITIALIZED_SIZE; + Py_ssize_t slicelength = UNINITIALIZED_SIZE; + + if (!PyArg_ParseTuple(args, "OO", &slice, &seq)) { + return NULL; + } + NULLABLE(slice); + NULLABLE(seq); + if (PySlice_GetIndicesEx(slice, Py_SIZE(seq), + &start, &stop, &step, &slicelength) < 0) { + assert(PyErr_Occurred()); + assert(slicelength == 0); + return NULL; + } + assert(!PyErr_Occurred()); + return Py_BuildValue("nnnn", start, stop, step, slicelength); +} + +static PyObject * +slice_unpack(PyObject *Py_UNUSED(module), PyObject *slice) +{ + Py_ssize_t start = UNINITIALIZED_SIZE; + Py_ssize_t stop = UNINITIALIZED_SIZE; + Py_ssize_t step = UNINITIALIZED_SIZE; + + NULLABLE(slice); + if (PySlice_Unpack(slice, &start, &stop, &step) < 0) { + assert(PyErr_Occurred()); + return NULL; + } + assert(!PyErr_Occurred()); + assert(start != UNINITIALIZED_SIZE); + assert(stop != UNINITIALIZED_SIZE); + assert(step != UNINITIALIZED_SIZE); + return Py_BuildValue("nnn", start, stop, step); +} + +static PyObject * +slice_adjustindices(PyObject *Py_UNUSED(module), PyObject *args) +{ + Py_ssize_t length, start, stop, step; + + if (!PyArg_ParseTuple(args, "nnnn", &length, &start, &stop, &step)) { + return NULL; + } + Py_ssize_t slicelength = PySlice_AdjustIndices(length, &start, &stop, step); + assert(!PyErr_Occurred()); + return Py_BuildValue("nnn", slicelength, start, stop); +} + +#undef PySlice_GetIndicesEx + +/* Test the deprecated PySlice_GetIndicesEx() function. It is still exported + * for the stable ABI and used if Py_LIMITED_API is older than 3.5.4. */ +static PyObject * +slice_getindicesex_func(PyObject *Py_UNUSED(module), PyObject *args) +{ + PyObject *slice; + Py_ssize_t length; + Py_ssize_t start = UNINITIALIZED_SIZE; + Py_ssize_t stop = UNINITIALIZED_SIZE; + Py_ssize_t step = UNINITIALIZED_SIZE; + Py_ssize_t slicelength = UNINITIALIZED_SIZE; + + if (!PyArg_ParseTuple(args, "On", &slice, &length)) { + return NULL; + } + NULLABLE(slice); +// Ignore deprecation warnings +_Py_COMP_DIAG_PUSH +_Py_COMP_DIAG_IGNORE_DEPR_DECLS + int res = PySlice_GetIndicesEx(slice, length, + &start, &stop, &step, &slicelength); +_Py_COMP_DIAG_POP + if (res < 0) { + assert(PyErr_Occurred()); + return NULL; + } + assert(!PyErr_Occurred()); + assert(start != UNINITIALIZED_SIZE); + assert(stop != UNINITIALIZED_SIZE); + assert(step != UNINITIALIZED_SIZE); + assert(slicelength != UNINITIALIZED_SIZE); + return Py_BuildValue("nnnn", start, stop, step, slicelength); +} + + +/* Same as slice_getindicesex_seq_macro(), but using the deprecated function. + * The length is evaluated before the call. */ +static PyObject * +slice_getindicesex_seq_func(PyObject *Py_UNUSED(module), PyObject *args) +{ + PyObject *slice, *seq; + Py_ssize_t start = UNINITIALIZED_SIZE; + Py_ssize_t stop = UNINITIALIZED_SIZE; + Py_ssize_t step = UNINITIALIZED_SIZE; + Py_ssize_t slicelength = UNINITIALIZED_SIZE; + + if (!PyArg_ParseTuple(args, "OO", &slice, &seq)) { + return NULL; + } + NULLABLE(slice); + NULLABLE(seq); +// Ignore deprecation warnings +_Py_COMP_DIAG_PUSH +_Py_COMP_DIAG_IGNORE_DEPR_DECLS + int res = PySlice_GetIndicesEx(slice, Py_SIZE(seq), + &start, &stop, &step, &slicelength); +_Py_COMP_DIAG_POP + if (res < 0) { + assert(PyErr_Occurred()); + return NULL; + } + assert(!PyErr_Occurred()); + return Py_BuildValue("nnnn", start, stop, step, slicelength); +} + + +static PyMethodDef test_methods[] = { + {"slice_check", slice_check, METH_O}, + {"slice_new", slice_new, METH_VARARGS}, + {"slice_getindices", slice_getindices, METH_VARARGS}, + {"slice_getindicesex_macro", slice_getindicesex_macro, METH_VARARGS}, + {"slice_getindicesex_seq_macro", slice_getindicesex_seq_macro, METH_VARARGS}, + {"slice_getindicesex_func", slice_getindicesex_func, + METH_VARARGS}, + {"slice_getindicesex_seq_func", slice_getindicesex_seq_func, + METH_VARARGS}, + {"slice_unpack", slice_unpack, METH_O}, + {"slice_adjustindices", slice_adjustindices, METH_VARARGS}, + {NULL}, +}; + +int +_PyTestLimitedCAPI_Init_Slice(PyObject *m) +{ + return PyModule_AddFunctions(m, test_methods); +} diff --git a/Modules/_testlimitedcapi/slots.c b/Modules/_testlimitedcapi/slots.c index 9abe53d21154645..2a887cd49f4c4b7 100644 --- a/Modules/_testlimitedcapi/slots.c +++ b/Modules/_testlimitedcapi/slots.c @@ -1,3 +1,4 @@ +// Need limited C API version 3.15 for PyType_FromSlots() #define Py_LIMITED_API 0x030f0000 #include "parts.h" diff --git a/Modules/_testlimitedcapi/sys.c b/Modules/_testlimitedcapi/sys.c index cec7f8ab6120198..618f4847c7ac6e5 100644 --- a/Modules/_testlimitedcapi/sys.c +++ b/Modules/_testlimitedcapi/sys.c @@ -1,8 +1,6 @@ -#include "pyconfig.h" // Py_GIL_DISABLED // Need limited C API version 3.15 for PySys_GetAttr() etc -#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API) -# define Py_LIMITED_API 0x030f0000 -#endif +#define Py_LIMITED_API 0x030f0000 + #include "parts.h" #include "util.h" diff --git a/Modules/_testlimitedcapi/type.c b/Modules/_testlimitedcapi/type.c new file mode 100644 index 000000000000000..640468ae08dcbb6 --- /dev/null +++ b/Modules/_testlimitedcapi/type.c @@ -0,0 +1,222 @@ +// Thin wrappers to PyType functions. +// Do no check PyType_Check() so Python tests can pass arbitrary objects, +// even if it's likely to crash. + +// Need limited C API version 3.14 for PyType_Freeze() +#include "pyconfig.h" // Py_GIL_DISABLED +#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API) +# define Py_LIMITED_API 0x030e0000 +#endif + +#include "parts.h" +#include "util.h" + + +static PyType_Slot HeapTypeNameType_slots[] = { + {0}, +}; + +static PyType_Spec HeapTypeNameType_Spec = { + .name = "_testcapi.HeapTypeNameType", + .basicsize = sizeof(PyObject), + .flags = Py_TPFLAGS_DEFAULT, + .slots = HeapTypeNameType_slots, +}; + + +// Test PyType_FromSpec() with a minimum PyType_Spec +static PyObject* +get_heaptype_for_name(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return PyType_FromSpec(&HeapTypeNameType_Spec); +} + + +// Test PyType_GetName() +static PyObject* +get_type_name(PyObject *self, PyObject *arg) +{ + NULLABLE(arg); + PyTypeObject *type = (PyTypeObject*)arg; + + return PyType_GetName(type); +} + + +// Test PyType_GetQualName() +static PyObject* +get_type_qualname(PyObject *self, PyObject *arg) +{ + NULLABLE(arg); + PyTypeObject *type = (PyTypeObject*)arg; + + return PyType_GetQualName(type); +} + + +// Test PyType_GetFullyQualifiedName() +static PyObject* +get_type_fullyqualname(PyObject *self, PyObject *arg) +{ + NULLABLE(arg); + PyTypeObject *type = (PyTypeObject*)arg; + + return PyType_GetFullyQualifiedName(type); +} + + +// Test PyType_GetModuleName() +static PyObject* +get_type_module_name(PyObject *self, PyObject *arg) +{ + NULLABLE(arg); + PyTypeObject *type = (PyTypeObject*)arg; + + return PyType_GetModuleName(type); +} + + +// Test PyType_Modified() +static PyObject* +type_modified(PyObject *self, PyObject *arg) +{ + NULLABLE(arg); + PyTypeObject *type = (PyTypeObject*)arg; + + PyType_Modified(type); + Py_RETURN_NONE; +} + + +// Test PyType_Ready() +static PyObject* +type_ready(PyObject *self, PyObject *arg) +{ + assert(!PyErr_Occurred()); + NULLABLE(arg); + PyTypeObject *type = (PyTypeObject*)arg; + + if (PyType_Ready(type) < 0) { + assert(PyErr_Occurred()); + return NULL; + } + assert(!PyErr_Occurred()); + Py_RETURN_NONE; +} + + +// Test PyType_Freeze() +static PyObject * +type_freeze(PyObject *module, PyObject *arg) +{ + NULLABLE(arg); + PyTypeObject *type = (PyTypeObject*)arg; + + if (PyType_Freeze(type) < 0) { + return NULL; + } + Py_RETURN_NONE; +} + + +// Test PyType_ClearCache() +static PyObject * +type_clearcache(PyObject *module, PyObject *Py_UNUSED(arg)) +{ + // Since Python 3.16, PyType_ClearCache() is a no-op as the type cache is + // now implemented per-type. It still returns the current version tag. + unsigned int version_tag = PyType_ClearCache(); + assert(!PyErr_Occurred()); + return PyLong_FromUnsignedLong(version_tag); +} + + +// Test PyType_GetFlags() +static PyObject * +type_getflags(PyObject *module, PyObject *arg) +{ + NULLABLE(arg); + PyTypeObject *type = (PyTypeObject*)arg; + + unsigned long flags = PyType_GetFlags(type); + assert(!PyErr_Occurred()); + return PyLong_FromUnsignedLong(flags); +} + + +// Test PyType_IsSubtype() +static PyObject * +type_issubtype(PyObject *module, PyObject *args) +{ + PyTypeObject *type1, *type2; + if (!PyArg_ParseTuple(args, "O!O!", + &PyType_Type, &type1, + &PyType_Type, &type2)) { + return NULL; + } + + int is_subtype = PyType_IsSubtype(type1, type2); + return PyLong_FromLong(is_subtype); +} + + +static PyMethodDef test_methods[] = { + {"get_heaptype_for_name", get_heaptype_for_name, METH_NOARGS}, + {"get_type_name", get_type_name, METH_O}, + {"get_type_qualname", get_type_qualname, METH_O}, + {"get_type_fullyqualname", get_type_fullyqualname, METH_O}, + {"get_type_module_name", get_type_module_name, METH_O}, + {"type_ready", type_ready, METH_O}, + {"type_modified", type_modified, METH_O}, + {"type_freeze", type_freeze, METH_O}, + {"type_clearcache", type_clearcache, METH_NOARGS}, + {"type_getflags", type_getflags, METH_O}, + {"type_issubtype", type_issubtype, METH_VARARGS}, + {NULL}, +}; + +int +_PyTestLimitedCAPI_Init_Type(PyObject *m) +{ + if (PyModule_AddFunctions(m, test_methods) < 0) { + return -1; + } + +#define ADD_INT(macro) \ + do { \ + if (PyModule_AddIntConstant(m, #macro, macro) < 0) { \ + return -1; \ + } \ + } while (0) + + ADD_INT(Py_TPFLAGS_DEFAULT); + + ADD_INT(Py_TPFLAGS_HAVE_FINALIZE); + ADD_INT(Py_TPFLAGS_HAVE_GC); + ADD_INT(Py_TPFLAGS_HAVE_VERSION_TAG); + ADD_INT(Py_TPFLAGS_HAVE_VECTORCALL); + + ADD_INT(Py_TPFLAGS_DISALLOW_INSTANTIATION ); + ADD_INT(Py_TPFLAGS_IMMUTABLETYPE); + ADD_INT(Py_TPFLAGS_HEAPTYPE); + ADD_INT(Py_TPFLAGS_BASETYPE); + ADD_INT(Py_TPFLAGS_READY); + ADD_INT(Py_TPFLAGS_READYING); + ADD_INT(Py_TPFLAGS_METHOD_DESCRIPTOR); + ADD_INT(Py_TPFLAGS_VALID_VERSION_TAG); + ADD_INT(Py_TPFLAGS_IS_ABSTRACT); + ADD_INT(_Py_TPFLAGS_MATCH_SELF); + ADD_INT(Py_TPFLAGS_ITEMS_AT_END); + + ADD_INT(Py_TPFLAGS_LONG_SUBCLASS); + ADD_INT(Py_TPFLAGS_LIST_SUBCLASS); + ADD_INT(Py_TPFLAGS_TUPLE_SUBCLASS); + ADD_INT(Py_TPFLAGS_BYTES_SUBCLASS); + ADD_INT(Py_TPFLAGS_UNICODE_SUBCLASS); + ADD_INT(Py_TPFLAGS_DICT_SUBCLASS); + ADD_INT(Py_TPFLAGS_BASE_EXC_SUBCLASS); + ADD_INT(Py_TPFLAGS_TYPE_SUBCLASS); + +#undef ADD_INT + return 0; +} diff --git a/Modules/_testlimitedcapi/unicode.c b/Modules/_testlimitedcapi/unicode.c index c7a23d5d1cbd71a..6e3b15ef76aaa23 100644 --- a/Modules/_testlimitedcapi/unicode.c +++ b/Modules/_testlimitedcapi/unicode.c @@ -1,5 +1,7 @@ #include "pyconfig.h" // Py_GIL_DISABLED -#ifndef Py_GIL_DISABLED +#ifdef Py_GIL_DISABLED +# define Py_TARGET_ABI3T 0x030f0000 +#else // Need limited C API 3.14 to test PyUnicode_Equal() # define Py_LIMITED_API 0x030e0000 #endif @@ -138,14 +140,19 @@ unicode_copy(PyObject *unicode) /* Test PyUnicode_WriteChar() */ static PyObject * -unicode_writechar(PyObject *self, PyObject *args) +unicode_writechar(PyObject *self, PyObject *args, PyObject *kwargs) { + static char *kwlist[] = {"to", "index", "character", "incref", NULL}; PyObject *to, *to_copy; Py_ssize_t index; unsigned int character; int result; + int incref = 0; - if (!PyArg_ParseTuple(args, "OnI", &to, &index, &character)) { + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "OnI|p", kwlist, + &to, &index, &character, &incref)) + { return NULL; } @@ -154,7 +161,14 @@ unicode_writechar(PyObject *self, PyObject *args) return NULL; } + if (incref) { + Py_INCREF(to_copy); + } result = PyUnicode_WriteChar(to_copy, index, (Py_UCS4)character); + if (incref) { + Py_DECREF(to_copy); + } + if (result == -1 && PyErr_Occurred()) { Py_DECREF(to_copy); return NULL; @@ -181,24 +195,59 @@ unicode_resize(PyObject *self, PyObject *args) PyObject *obj, *copy; Py_ssize_t length; int result; + int new = 1; + int compute_hash = 0; - if (!PyArg_ParseTuple(args, "On", &obj, &length)) { + if (!PyArg_ParseTuple(args, "On|pp", &obj, &length, &new, &compute_hash)) { return NULL; } NULLABLE(obj); - if (!(copy = unicode_copy(obj)) && obj) { - return NULL; + Py_ssize_t old_len = obj ? PyUnicode_GetLength(obj) : 0; + if (obj != NULL && new) { + copy = unicode_copy(obj); + if (!copy) { + return NULL; + } + obj = copy; + } + else { + Py_XINCREF(obj); + } + + if (compute_hash && obj != NULL) { + if (PyObject_Hash(obj) == -1) { + Py_DECREF(obj); + return NULL; + } } - result = PyUnicode_Resize(©, length); + + PyObject *old_obj = obj; + result = PyUnicode_Resize(&obj, length); if (result == -1 && PyErr_Occurred()) { - Py_XDECREF(copy); + Py_XDECREF(obj); return NULL; } - if (obj && PyUnicode_Check(obj) && length > PyUnicode_GetLength(obj)) { - unicode_fill(copy, PyUnicode_GetLength(obj), length, 0U); + if (obj && PyUnicode_Check(obj) && length > old_len) { + unicode_fill(obj, old_len, length, 0U); } - return Py_BuildValue("(Ni)", copy, result); + Py_ssize_t refcnt = Py_REFCNT(obj); + return Py_BuildValue("(Ninp)", obj, result, refcnt, obj != old_obj); +} + +// Test PyUnicode_Resize(NULL, length) +static PyObject * +unicode_resize_null(PyObject *self, PyObject *args) +{ + Py_ssize_t length; + if (!PyArg_ParseTuple(args, "n", &length)) { + return NULL; + } + + if (PyUnicode_Resize(NULL, length)) { + return NULL; + } + Py_RETURN_NONE; } /* Test PyUnicode_Append() */ @@ -944,7 +993,7 @@ unicode_encodecodepage(PyObject *self, PyObject *args) { int code_page; PyObject *unicode; - const char *errors; + const char *errors = NULL; if (!PyArg_ParseTuple(args, "iO|z", &code_page, &unicode, &errors)) return NULL; @@ -961,7 +1010,7 @@ unicode_decodelocaleandsize(PyObject *self, PyObject *args) { const char *data; Py_ssize_t size; - const char *errors; + const char *errors = NULL; if (!PyArg_ParseTuple(args, "y#|z", &data, &size, &errors)) return NULL; @@ -975,7 +1024,7 @@ unicode_decodelocale(PyObject *self, PyObject *args) { const char *data; Py_ssize_t size; - const char *errors; + const char *errors = NULL; if (!PyArg_ParseTuple(args, "y#|z", &data, &size, &errors)) return NULL; @@ -988,7 +1037,7 @@ static PyObject * unicode_encodelocale(PyObject *self, PyObject *args) { PyObject *unicode; - const char *errors; + const char *errors = NULL; if (!PyArg_ParseTuple(args, "O|z", &unicode, &errors)) return NULL; @@ -1282,7 +1331,7 @@ unicode_comparewithasciistring(PyObject *self, PyObject *args) { PyObject *left; const char *right = NULL; - Py_ssize_t right_len; + Py_ssize_t right_len = 0; int result; if (!PyArg_ParseTuple(args, "O|y#", &left, &right, &right_len)) @@ -1321,7 +1370,7 @@ unicode_equaltoutf8andsize(PyObject *self, PyObject *args) { PyObject *left; const char *right = NULL; - Py_ssize_t right_len; + Py_ssize_t right_len = 0; Py_ssize_t size = -100; int result; @@ -1853,6 +1902,23 @@ unicode_equal(PyObject *module, PyObject *args) } +/* Test PyUnicode_Check() */ +static PyObject * +unicode_check(PyObject *module, PyObject *obj) +{ + NULLABLE(obj); + return PyLong_FromLong(PyUnicode_Check(obj)); +} + + +/* Test PyUnicode_CheckExact() */ +static PyObject * +unicode_checkexact(PyObject *module, PyObject *obj) +{ + NULLABLE(obj); + return PyLong_FromLong(PyUnicode_CheckExact(obj)); +} + static PyMethodDef TestMethods[] = { {"codec_incrementalencoder", codec_incrementalencoder, METH_VARARGS}, @@ -1861,8 +1927,9 @@ static PyMethodDef TestMethods[] = { test_unicode_compare_with_ascii, METH_NOARGS}, {"test_string_from_format", test_string_from_format, METH_NOARGS}, {"test_widechar", test_widechar, METH_NOARGS}, - {"unicode_writechar", unicode_writechar, METH_VARARGS}, + {"unicode_writechar", _PyCFunction_CAST(unicode_writechar), METH_VARARGS | METH_KEYWORDS}, {"unicode_resize", unicode_resize, METH_VARARGS}, + {"unicode_resize_null", unicode_resize_null, METH_VARARGS}, {"unicode_append", unicode_append, METH_VARARGS}, {"unicode_appendanddel", unicode_appendanddel, METH_VARARGS}, {"unicode_fromstringandsize",unicode_fromstringandsize, METH_VARARGS}, @@ -1942,6 +2009,8 @@ static PyMethodDef TestMethods[] = { {"unicode_contains", unicode_contains, METH_VARARGS}, {"unicode_isidentifier", unicode_isidentifier, METH_O}, {"unicode_equal", unicode_equal, METH_VARARGS}, + {"unicode_check", unicode_check, METH_O}, + {"unicode_checkexact", unicode_checkexact, METH_O}, {NULL}, }; diff --git a/Modules/_testlimitedcapi/vectorcall_limited.c b/Modules/_testlimitedcapi/vectorcall_limited.c index 84362d523f49633..443c4aca28e3ae7 100644 --- a/Modules/_testlimitedcapi/vectorcall_limited.c +++ b/Modules/_testlimitedcapi/vectorcall_limited.c @@ -1,8 +1,10 @@ /* Test Vectorcall in the limited API */ -// Need limited C API version 3.12 for PyObject_Vectorcall() #include "pyconfig.h" // Py_GIL_DISABLED -#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API) +#ifdef Py_GIL_DISABLED + // Cannot test the limited C API +#else + // Need limited C API version 3.12 for PyObject_Vectorcall() # define Py_LIMITED_API 0x030c0000 #endif diff --git a/Modules/_testlimitedcapi/version.c b/Modules/_testlimitedcapi/version.c index 57cd6e4e928ea3f..d2a4551159165c0 100644 --- a/Modules/_testlimitedcapi/version.c +++ b/Modules/_testlimitedcapi/version.c @@ -1,8 +1,11 @@ /* Test version macros in the limited API */ #include "pyconfig.h" // Py_GIL_DISABLED -#ifndef Py_GIL_DISABLED -# define Py_LIMITED_API 0x030e0000 // Added in 3.14 +#ifdef Py_GIL_DISABLED +# define Py_TARGET_ABI3T 0x030f0000 +#else + // Need limited C API version 3.14 for Py_PACK_VERSION() +# define Py_LIMITED_API 0x030e0000 #endif #include "parts.h" diff --git a/Modules/_testlimitedcapi/weakref.c b/Modules/_testlimitedcapi/weakref.c index e7f9d54d1a0d59e..a25e39e21af3748 100644 --- a/Modules/_testlimitedcapi/weakref.c +++ b/Modules/_testlimitedcapi/weakref.c @@ -1,5 +1,7 @@ #include "pyconfig.h" // Py_GIL_DISABLED -#ifndef Py_GIL_DISABLED +#ifdef Py_GIL_DISABLED +# define Py_TARGET_ABI3T 0x030f0000 +#else // Need limited C API 3.5 for PyModule_AddFunctions() # define Py_LIMITED_API 0x03050000 #endif diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index e999fe20287e2d6..2b227a4eec37214 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -85,8 +85,9 @@ static PF_SET_THREAD_DESCRIPTION pSetThreadDescription = NULL; module _thread class _thread.lock "lockobject *" "clinic_state()->lock_type" class _thread.RLock "rlockobject *" "clinic_state()->rlock_type" +class _thread._ThreadHandle "PyObject *" "clinic_state()->thread_handle_type" [clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=c5a0f8c492a0c263]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=bd4eae07ae18bc2c]*/ #define clinic_state() get_thread_state_by_cls(type) #include "clinic/_threadmodule.c.h" @@ -571,7 +572,8 @@ ThreadHandle_join(ThreadHandle *self, PyTime_t timeout_ns) if (deadline) { // _PyDeadline_Get will return a negative value if the deadline has // been exceeded. - timeout_ns = Py_MAX(_PyDeadline_Get(deadline), 0); + timeout_ns = _PyDeadline_Get(deadline); + timeout_ns = Py_MAX(timeout_ns, 0); } if (timeout_ns) { @@ -677,43 +679,57 @@ PyThreadHandleObject_repr(PyObject *op) Py_TYPE(self)->tp_name, ident); } +/*[clinic input] +@getter +_thread._ThreadHandle.ident +[clinic start generated code]*/ + static PyObject * -PyThreadHandleObject_get_ident(PyObject *op, void *Py_UNUSED(closure)) +_thread__ThreadHandle_ident_get_impl(PyObject *self) +/*[clinic end generated code: output=66d40aa1a624ac23 input=2b3361e34a6ca79d]*/ { - PyThreadHandleObject *self = PyThreadHandleObject_CAST(op); - return PyLong_FromUnsignedLongLong(ThreadHandle_ident(self->handle)); + PyThreadHandleObject *handle = PyThreadHandleObject_CAST(self); + return PyLong_FromUnsignedLongLong(ThreadHandle_ident(handle->handle)); } +/*[clinic input] +_thread._ThreadHandle.join + timeout as timeout_obj: object = None + / +[clinic start generated code]*/ + static PyObject * -PyThreadHandleObject_join(PyObject *op, PyObject *args) +_thread__ThreadHandle_join_impl(PyObject *self, PyObject *timeout_obj) +/*[clinic end generated code: output=d3a4f0b20c21442e input=b66d17a0f77d6e9c]*/ { - PyThreadHandleObject *self = PyThreadHandleObject_CAST(op); - - PyObject *timeout_obj = NULL; - if (!PyArg_ParseTuple(args, "|O:join", &timeout_obj)) { - return NULL; - } + PyThreadHandleObject *handle = PyThreadHandleObject_CAST(self); PyTime_t timeout_ns = -1; - if (timeout_obj != NULL && timeout_obj != Py_None) { + if (timeout_obj != Py_None) { if (_PyTime_FromSecondsObject(&timeout_ns, timeout_obj, _PyTime_ROUND_TIMEOUT) < 0) { return NULL; } } - if (ThreadHandle_join(self->handle, timeout_ns) < 0) { + if (ThreadHandle_join(handle->handle, timeout_ns) < 0) { return NULL; } Py_RETURN_NONE; } +/*[clinic input] +_thread._ThreadHandle.is_done +[clinic start generated code]*/ + static PyObject * -PyThreadHandleObject_is_done(PyObject *op, PyObject *Py_UNUSED(dummy)) +_thread__ThreadHandle_is_done_impl(PyObject *self) +/*[clinic end generated code: output=f5c00923fb61967b input=dd905a1ac7fc2e7c]*/ { - PyThreadHandleObject *self = PyThreadHandleObject_CAST(op); - if (_PyEvent_IsSet(&self->handle->thread_is_exiting)) { - if (_PyOnceFlag_CallOnce(&self->handle->once, join_thread, self->handle) == -1) { + PyThreadHandleObject *handle = PyThreadHandleObject_CAST(self); + if (_PyEvent_IsSet(&handle->handle->thread_is_exiting)) { + if (_PyOnceFlag_CallOnce(&handle->handle->once, join_thread, + handle->handle) == -1) { return NULL; } Py_RETURN_TRUE; @@ -723,25 +739,30 @@ PyThreadHandleObject_is_done(PyObject *op, PyObject *Py_UNUSED(dummy)) } } +/*[clinic input] +_thread._ThreadHandle._set_done +[clinic start generated code]*/ + static PyObject * -PyThreadHandleObject_set_done(PyObject *op, PyObject *Py_UNUSED(dummy)) +_thread__ThreadHandle__set_done_impl(PyObject *self) +/*[clinic end generated code: output=709b4d7ca318bb6d input=9f0115db8d84806b]*/ { - PyThreadHandleObject *self = PyThreadHandleObject_CAST(op); - if (ThreadHandle_set_done(self->handle) < 0) { + PyThreadHandleObject *handle = PyThreadHandleObject_CAST(self); + if (ThreadHandle_set_done(handle->handle) < 0) { return NULL; } Py_RETURN_NONE; } static PyGetSetDef ThreadHandle_getsetlist[] = { - {"ident", PyThreadHandleObject_get_ident, NULL, NULL}, + _THREAD__THREADHANDLE_IDENT_GETSETDEF {0}, }; static PyMethodDef ThreadHandle_methods[] = { - {"join", PyThreadHandleObject_join, METH_VARARGS, NULL}, - {"_set_done", PyThreadHandleObject_set_done, METH_NOARGS, NULL}, - {"is_done", PyThreadHandleObject_is_done, METH_NOARGS, NULL}, + _THREAD__THREADHANDLE_JOIN_METHODDEF + _THREAD__THREADHANDLE__SET_DONE_METHODDEF + _THREAD__THREADHANDLE_IS_DONE_METHODDEF {0, 0} }; @@ -1521,10 +1542,25 @@ local_new(PyTypeObject *type, PyObject *args, PyObject *kw) assert(module != NULL); thread_module_state *state = get_thread_state(module); + // A subclass finalizer may access attributes if construction fails. + PyObject *localdicts = PyDict_New(); + if (localdicts == NULL) { + return NULL; + } + PyObject *thread_watchdogs = PySet_New(NULL); + if (thread_watchdogs == NULL) { + Py_DECREF(localdicts); + return NULL; + } + localobject *self = (localobject *)type->tp_alloc(type, 0); if (self == NULL) { + Py_DECREF(localdicts); + Py_DECREF(thread_watchdogs); return NULL; } + self->localdicts = localdicts; + self->thread_watchdogs = thread_watchdogs; // gh-128691: Use deferred reference counting for thread-locals to avoid // contention on the shared object. @@ -1533,16 +1569,6 @@ local_new(PyTypeObject *type, PyObject *args, PyObject *kw) self->args = Py_XNewRef(args); self->kw = Py_XNewRef(kw); - self->localdicts = PyDict_New(); - if (self->localdicts == NULL) { - goto err; - } - - self->thread_watchdogs = PySet_New(NULL); - if (self->thread_watchdogs == NULL) { - goto err; - } - PyObject *localsdict = NULL; PyObject *sentinel_wr = NULL; if (create_localsdict(self, state, &localsdict, &sentinel_wr) < 0) { @@ -1874,8 +1900,17 @@ clear_locals(PyObject *locals_and_key, PyObject *dummyweakref) /* Module functions */ +/*[clinic input] +_thread.daemon_threads_allowed + +Return True if daemon threads are allowed in the current interpreter. + +Return False otherwise. +[clinic start generated code]*/ + static PyObject * -thread_daemon_threads_allowed(PyObject *module, PyObject *Py_UNUSED(ignored)) +_thread_daemon_threads_allowed_impl(PyObject *module) +/*[clinic end generated code: output=c82b3b9490c7e11e input=f94150f9e14b7d0c]*/ { PyInterpreterState *interp = _PyInterpreterState_GET(); if (interp->feature_flags & Py_RTFLAGS_DAEMON_THREADS) { @@ -1886,13 +1921,6 @@ thread_daemon_threads_allowed(PyObject *module, PyObject *Py_UNUSED(ignored)) } } -PyDoc_STRVAR(daemon_threads_allowed_doc, -"daemon_threads_allowed($module, /)\n\ ---\n\ -\n\ -Return True if daemon threads are allowed in the current interpreter,\n\ -and False otherwise.\n"); - static int do_start_new_thread(thread_module_state *state, PyObject *func, PyObject *args, PyObject *kwargs, ThreadHandle *handle, int daemon) @@ -1926,31 +1954,36 @@ do_start_new_thread(thread_module_state *state, PyObject *func, PyObject *args, return 0; } +/*[clinic input] +_thread.start_new_thread + + function as func: object + args: object(subclass_of='&PyTuple_Type') + kwargs: object(subclass_of='&PyDict_Type', c_default="NULL") = {} + / + +Start a new thread and return its identifier. + +The thread will call the function with positional arguments from the +tuple args and keyword arguments taken from the optional dictionary +kwargs. The thread exits when the function returns; the return value +is ignored. The thread will also exit when the function raises an +unhandled exception; a stack trace will be printed unless the exception +is SystemExit. +[clinic start generated code]*/ + static PyObject * -thread_PyThread_start_new_thread(PyObject *module, PyObject *fargs) +_thread_start_new_thread_impl(PyObject *module, PyObject *func, + PyObject *args, PyObject *kwargs) +/*[clinic end generated code: output=0c27eb61b7a7152b input=b85f6b3301d30719]*/ { - PyObject *func, *args, *kwargs = NULL; thread_module_state *state = get_thread_state(module); - if (!PyArg_UnpackTuple(fargs, "start_new_thread", 2, 3, - &func, &args, &kwargs)) - return NULL; if (!PyCallable_Check(func)) { PyErr_SetString(PyExc_TypeError, "first arg must be callable"); return NULL; } - if (!PyTuple_Check(args)) { - PyErr_SetString(PyExc_TypeError, - "2nd arg must be a tuple"); - return NULL; - } - if (kwargs != NULL && !PyDict_Check(kwargs)) { - PyErr_SetString(PyExc_TypeError, - "optional 3rd arg must be a dictionary"); - return NULL; - } - if (PySys_Audit("_thread.start_new_thread", "OOO", func, args, kwargs ? kwargs : Py_None) < 0) { return NULL; @@ -1972,39 +2005,36 @@ thread_PyThread_start_new_thread(PyObject *module, PyObject *fargs) return PyLong_FromUnsignedLongLong(ident); } -PyDoc_STRVAR(start_new_thread_doc, -"start_new_thread($module, function, args, kwargs={}, /)\n\ ---\n\ -\n\ -Start a new thread and return its identifier.\n\ -\n\ -The thread will call the function with positional arguments from the\n\ -tuple args and keyword arguments taken from the optional dictionary\n\ -kwargs. The thread exits when the function returns; the return value\n\ -is ignored. The thread will also exit when the function raises an\n\ -unhandled exception; a stack trace will be printed unless the exception\n\ -is SystemExit."); - PyDoc_STRVAR(start_new_doc, "start_new($module, function, args, kwargs={}, /)\n\ --\n\ \n\ An obsolete synonym of start_new_thread()."); +/*[clinic input] +_thread.start_joinable_thread + + function as func: object + handle as hobj: object = None + daemon: bool = True + +*For internal use only*: start a new thread. + +Like start_new_thread(), this starts a new thread calling the given +function. Unlike start_new_thread(), this returns a handle object with +methods to join or detach the given thread. +This function is not for third-party code, please use the `threading` +module instead. During finalization the runtime will not wait for the +thread to exit if daemon is True. If handle is provided it must be a +newly created thread._ThreadHandle instance. +[clinic start generated code]*/ + static PyObject * -thread_PyThread_start_joinable_thread(PyObject *module, PyObject *fargs, - PyObject *fkwargs) +_thread_start_joinable_thread_impl(PyObject *module, PyObject *func, + PyObject *hobj, int daemon) +/*[clinic end generated code: output=58691769e60620cf input=e17b3aebc087952a]*/ { - static char *keywords[] = {"function", "handle", "daemon", NULL}; - PyObject *func = NULL; - int daemon = 1; thread_module_state *state = get_thread_state(module); - PyObject *hobj = NULL; - if (!PyArg_ParseTupleAndKeywords(fargs, fkwargs, - "O|Op:start_joinable_thread", keywords, - &func, &hobj, &daemon)) { - return NULL; - } if (!PyCallable_Check(func)) { PyErr_SetString(PyExc_TypeError, @@ -2012,10 +2042,7 @@ thread_PyThread_start_joinable_thread(PyObject *module, PyObject *fargs, return NULL; } - if (hobj == NULL) { - hobj = Py_None; - } - else if (hobj != Py_None && !Py_IS_TYPE(hobj, state->thread_handle_type)) { + if (hobj != Py_None && !Py_IS_TYPE(hobj, state->thread_handle_type)) { PyErr_SetString(PyExc_TypeError, "'handle' must be a _ThreadHandle"); return NULL; } @@ -2049,48 +2076,49 @@ thread_PyThread_start_joinable_thread(PyObject *module, PyObject *fargs, return (PyObject *) hobj; } -PyDoc_STRVAR(start_joinable_doc, -"start_joinable_thread($module, /, function, handle=None, daemon=True)\n\ ---\n\ -\n\ -*For internal use only*: start a new thread.\n\ -\n\ -Like start_new_thread(), this starts a new thread calling the given function.\n\ -Unlike start_new_thread(), this returns a handle object with methods to join\n\ -or detach the given thread.\n\ -This function is not for third-party code, please use the\n\ -`threading` module instead. During finalization the runtime will not wait for\n\ -the thread to exit if daemon is True. If handle is provided it must be a\n\ -newly created thread._ThreadHandle instance."); +/*[clinic input] +_thread.exit + +Raise SystemExit. + +It will cause the current thread to exit silently unless the exception +is caught. +[clinic start generated code]*/ static PyObject * -thread_PyThread_exit_thread(PyObject *self, PyObject *Py_UNUSED(ignored)) +_thread_exit_impl(PyObject *module) +/*[clinic end generated code: output=b03924346e743f4c input=1f3dc5da8ad48c70]*/ { PyErr_SetNone(PyExc_SystemExit); return NULL; } -PyDoc_STRVAR(exit_doc, -"exit($module, /)\n\ ---\n\ -\n\ -This is synonymous to ``raise SystemExit''. It will cause the current\n\ -thread to exit silently unless the exception is caught."); - PyDoc_STRVAR(exit_thread_doc, "exit_thread($module, /)\n\ --\n\ \n\ An obsolete synonym of exit()."); +/*[clinic input] +_thread.interrupt_main + + signum: int(c_default="SIGINT") = signal.SIGINT + / + +Simulate the arrival of the given signal in the main thread. + +The corresponding signal handler will be executed. +If *signum* is omitted, SIGINT is assumed. +A subthread can use this function to interrupt the main thread. + +Note: the default signal handler for SIGINT raises +``KeyboardInterrupt``. +[clinic start generated code]*/ + static PyObject * -thread_PyThread_interrupt_main(PyObject *self, PyObject *args) +_thread_interrupt_main_impl(PyObject *module, int signum) +/*[clinic end generated code: output=fdafa7261ceb26e9 input=a8cf392f3a7f2a84]*/ { - int signum = SIGINT; - if (!PyArg_ParseTuple(args, "|i:signum", &signum)) { - return NULL; - } - if (PyErr_SetInterruptEx(signum)) { PyErr_SetString(PyExc_ValueError, "signal number out of range"); return NULL; @@ -2098,40 +2126,44 @@ thread_PyThread_interrupt_main(PyObject *self, PyObject *args) Py_RETURN_NONE; } -PyDoc_STRVAR(interrupt_doc, -"interrupt_main($module, signum=signal.SIGINT, /)\n\ ---\n\ -\n\ -Simulate the arrival of the given signal in the main thread,\n\ -where the corresponding signal handler will be executed.\n\ -If *signum* is omitted, SIGINT is assumed.\n\ -A subthread can use this function to interrupt the main thread.\n\ -\n\ -Note: the default signal handler for SIGINT raises ``KeyboardInterrupt``." -); +/*[clinic input] +_thread.allocate_lock + +Create a new lock object. + +See help(type(threading.Lock())) for information about locks. +[clinic start generated code]*/ static PyObject * -thread_PyThread_allocate_lock(PyObject *module, PyObject *Py_UNUSED(ignored)) +_thread_allocate_lock_impl(PyObject *module) +/*[clinic end generated code: output=884a4be6cb9ca731 input=49f5b1f966361bb6]*/ { thread_module_state *state = get_thread_state(module); return lock_new_impl(state->lock_type); } -PyDoc_STRVAR(allocate_lock_doc, -"allocate_lock($module, /)\n\ ---\n\ -\n\ -Create a new lock object. See help(type(threading.Lock())) for\n\ -information about locks."); - PyDoc_STRVAR(allocate_doc, "allocate($module, /)\n\ --\n\ \n\ An obsolete synonym of allocate_lock()."); +/*[clinic input] +_thread.get_ident + +Return a non-zero integer that uniquely identifies the current thread. + +It is unique amongst other threads that exist simultaneously. +This may be used to identify per-thread resources. +Even though on some platforms threads identities may appear to be +allocated consecutive numbers starting at 1, this behavior should not +be relied upon, and the number should be seen purely as a magic cookie. +A thread's identity may be reused for another thread after it exits. +[clinic start generated code]*/ + static PyObject * -thread_get_ident(PyObject *self, PyObject *Py_UNUSED(ignored)) +_thread_get_ident_impl(PyObject *module) +/*[clinic end generated code: output=8c3f9d8aa938b332 input=08faef37d1fd9e67]*/ { PyThread_ident_t ident = PyThread_get_thread_ident_ex(); if (ident == PYTHREAD_INVALID_THREAD_ID) { @@ -2141,64 +2173,79 @@ thread_get_ident(PyObject *self, PyObject *Py_UNUSED(ignored)) return PyLong_FromUnsignedLongLong(ident); } -PyDoc_STRVAR(get_ident_doc, -"get_ident($module, /)\n\ ---\n\ -\n\ -Return a non-zero integer that uniquely identifies the current thread\n\ -amongst other threads that exist simultaneously.\n\ -This may be used to identify per-thread resources.\n\ -Even though on some platforms threads identities may appear to be\n\ -allocated consecutive numbers starting at 1, this behavior should not\n\ -be relied upon, and the number should be seen purely as a magic cookie.\n\ -A thread's identity may be reused for another thread after it exits."); - #ifdef PY_HAVE_THREAD_NATIVE_ID +/*[clinic input] +_thread.get_native_id + +Return a non-negative integer identifying the thread. + +It is reported by the OS (kernel). This may be used to uniquely +identify a particular thread within a system. +[clinic start generated code]*/ + static PyObject * -thread_get_native_id(PyObject *self, PyObject *Py_UNUSED(ignored)) +_thread_get_native_id_impl(PyObject *module) +/*[clinic end generated code: output=d69767224b4ba922 input=454af91013e4f747]*/ { unsigned long native_id = PyThread_get_thread_native_id(); return PyLong_FromUnsignedLong(native_id); } -PyDoc_STRVAR(get_native_id_doc, -"get_native_id($module, /)\n\ ---\n\ -\n\ -Return a non-negative integer identifying the thread as reported\n\ -by the OS (kernel). This may be used to uniquely identify a\n\ -particular thread within a system."); #endif +/*[clinic input] +_thread._count + +Return the number of currently running Python threads. + +The main thread is excluded. The returned number comprises all threads +created through `start_new_thread()` as well as `threading.Thread`, and +not yet finished. + +This function is meant for internal and specialized purposes only. +In most applications `threading.enumerate()` should be used instead. +[clinic start generated code]*/ + static PyObject * -thread__count(PyObject *self, PyObject *Py_UNUSED(ignored)) +_thread__count_impl(PyObject *module) +/*[clinic end generated code: output=4cd03377c3e8521d input=bbd340043d174d48]*/ { PyInterpreterState *interp = _PyInterpreterState_GET(); return PyLong_FromSsize_t(_Py_atomic_load_ssize(&interp->threads.count)); } -PyDoc_STRVAR(_count_doc, -"_count($module, /)\n\ ---\n\ -\n\ -Return the number of currently running Python threads, excluding\n\ -the main thread. The returned number comprises all threads created\n\ -through `start_new_thread()` as well as `threading.Thread`, and not\n\ -yet finished.\n\ -\n\ -This function is meant for internal and specialized purposes only.\n\ -In most applications `threading.enumerate()` should be used instead."); +/*[clinic input] +_thread.stack_size + + size as new_size: Py_ssize_t = 0 + / + +Return the thread stack size used when creating new threads. + +The optional size argument specifies the stack size (in bytes) to be +used for subsequently created threads, and must be 0 (use platform or +configured default) or a positive integer value of at least 32,768 (32 +KiB). If changing the thread stack size is unsupported, a ThreadError +exception is raised. If the specified size is invalid, a ValueError +exception is raised, and the stack size is unmodified. 32 KiB +currently is the minimum supported stack size value to guarantee +sufficient stack space for the interpreter itself. + +Note that some systems may have particular restrictions on values for +the stack size, such as requiring a minimum stack size larger than 32 +KiB or requiring allocation in multiples of the system memory page size +- platform documentation should be referred to for more information +(4 KiB pages are common; using multiples of 4096 for the stack size is +the suggested approach in the absence of more specific information). +[clinic start generated code]*/ static PyObject * -thread_stack_size(PyObject *self, PyObject *args) +_thread_stack_size_impl(PyObject *module, Py_ssize_t new_size) +/*[clinic end generated code: output=cc7ba71bd35afc30 input=3249feb8ed2350f8]*/ { size_t old_size; - Py_ssize_t new_size = 0; int rc; - if (!PyArg_ParseTuple(args, "|n:stack_size", &new_size)) - return NULL; - Py_ssize_t min_size = _PyOS_MIN_STACK_SIZE + SYSTEM_PAGE_SIZE; if (new_size != 0 && new_size < min_size) { PyErr_Format(PyExc_ValueError, @@ -2224,27 +2271,6 @@ thread_stack_size(PyObject *self, PyObject *args) return PyLong_FromSsize_t((Py_ssize_t) old_size); } -PyDoc_STRVAR(stack_size_doc, -"stack_size($module, size=0, /)\n\ ---\n\ -\n\ -Return the thread stack size used when creating new threads. The\n\ -optional size argument specifies the stack size (in bytes) to be used\n\ -for subsequently created threads, and must be 0 (use platform or\n\ -configured default) or a positive integer value of at least 32,768 (32k).\n\ -If changing the thread stack size is unsupported, a ThreadError\n\ -exception is raised. If the specified size is invalid, a ValueError\n\ -exception is raised, and the stack size is unmodified. 32k bytes\n\ - currently the minimum supported stack size value to guarantee\n\ -sufficient stack space for the interpreter itself.\n\ -\n\ -Note that some platforms may have particular restrictions on values for\n\ -the stack size, such as requiring a minimum stack size larger than 32 KiB or\n\ -requiring allocation in multiples of the system memory page size\n\ -- platform documentation should be referred to for more information\n\ -(4 KiB pages are common; using multiples of 4096 for the stack size is\n\ -the suggested approach in the absence of more specific information)."); - static int thread_excepthook_file(PyObject *file, PyObject *exc_type, PyObject *exc_value, PyObject *exc_traceback, PyObject *thread) @@ -2323,8 +2349,18 @@ static PyStructSequence_Desc ExceptHookArgs_desc = { }; +/*[clinic input] +_thread._excepthook + + args: object + / + +Handle uncaught Thread.run() exception. +[clinic start generated code]*/ + static PyObject * -thread_excepthook(PyObject *module, PyObject *args) +_thread__excepthook(PyObject *module, PyObject *args) +/*[clinic end generated code: output=cadc54a3be0e6007 input=5ae2316c400a3497]*/ { thread_module_state *state = get_thread_state(module); @@ -2380,30 +2416,32 @@ thread_excepthook(PyObject *module, PyObject *args) Py_RETURN_NONE; } -PyDoc_STRVAR(excepthook_doc, -"_excepthook($module, args, /)\n\ ---\n\ -\n\ -Handle uncaught Thread.run() exception."); +/*[clinic input] +_thread._is_main_interpreter + +Return True if the current interpreter is the main Python interpreter. +[clinic start generated code]*/ static PyObject * -thread__is_main_interpreter(PyObject *module, PyObject *Py_UNUSED(ignored)) +_thread__is_main_interpreter_impl(PyObject *module) +/*[clinic end generated code: output=7dd82e1728339adc input=cc1eb00fd4598915]*/ { PyInterpreterState *interp = _PyInterpreterState_GET(); return PyBool_FromLong(_Py_IsMainInterpreter(interp)); } -PyDoc_STRVAR(thread__is_main_interpreter_doc, -"_is_main_interpreter($module, /)\n\ ---\n\ -\n\ -Return True if the current interpreter is the main Python interpreter."); +/*[clinic input] +_thread._shutdown + +Wait for all non-daemon threads (other than the calling thread) to stop. +[clinic start generated code]*/ static PyObject * -thread_shutdown(PyObject *self, PyObject *args) +_thread__shutdown_impl(PyObject *module) +/*[clinic end generated code: output=a19afe92bddc1824 input=bcaeaceb3a6fa590]*/ { PyThread_ident_t ident = PyThread_get_thread_ident_ex(); - thread_module_state *state = get_thread_state(self); + thread_module_state *state = get_thread_state(module); for (;;) { ThreadHandle *handle = NULL; @@ -2413,7 +2451,7 @@ thread_shutdown(PyObject *self, PyObject *args) struct llist_node *node; llist_for_each_safe(node, &state->shutdown_handles) { ThreadHandle *cur = llist_data(node, ThreadHandle, shutdown_node); - if (cur->ident != ident) { + if (ThreadHandle_ident(cur) != ident) { ThreadHandle_incref(cur); handle = cur; break; @@ -2439,14 +2477,21 @@ thread_shutdown(PyObject *self, PyObject *args) Py_RETURN_NONE; } -PyDoc_STRVAR(shutdown_doc, -"_shutdown($module, /)\n\ ---\n\ -\n\ -Wait for all non-daemon threads (other than the calling thread) to stop."); +/*[clinic input] +_thread._make_thread_handle + + ident as identobj: object + / + +Internal only. + +Make a thread handle for threads not spawned by the _thread or +threading module. +[clinic start generated code]*/ static PyObject * -thread__make_thread_handle(PyObject *module, PyObject *identobj) +_thread__make_thread_handle(PyObject *module, PyObject *identobj) +/*[clinic end generated code: output=afa56c40a7e1c394 input=57bb20ebf5825dd1]*/ { thread_module_state *state = get_thread_state(module); if (!PyLong_Check(identobj)) { @@ -2469,26 +2514,22 @@ thread__make_thread_handle(PyObject *module, PyObject *identobj) return (PyObject*) hobj; } -PyDoc_STRVAR(thread__make_thread_handle_doc, -"_make_thread_handle($module, ident, /)\n\ ---\n\ -\n\ -Internal only. Make a thread handle for threads not spawned\n\ -by the _thread or threading module."); +/*[clinic input] +_thread._get_main_thread_ident + +Internal only. + +Return a non-zero integer that uniquely identifies the main thread of +the main interpreter. +[clinic start generated code]*/ static PyObject * -thread__get_main_thread_ident(PyObject *module, PyObject *Py_UNUSED(ignored)) +_thread__get_main_thread_ident_impl(PyObject *module) +/*[clinic end generated code: output=01aa07c5553458bf input=feea25c7039ba4b5]*/ { return PyLong_FromUnsignedLongLong(_PyRuntime.main_thread); } -PyDoc_STRVAR(thread__get_main_thread_ident_doc, -"_get_main_thread_ident($module, /)\n\ ---\n\ -\n\ -Internal only. Return a non-zero integer that uniquely identifies the main thread\n\ -of the main interpreter."); - #if defined(__OpenBSD__) /* pthread_*_np functions, especially pthread_{get,set}_name_np(). pthread_np.h exists on both OpenBSD and FreeBSD but the latter declares @@ -2648,44 +2689,29 @@ _thread_set_name_impl(PyObject *module, PyObject *name_obj) static PyMethodDef thread_methods[] = { - {"start_new_thread", thread_PyThread_start_new_thread, - METH_VARARGS, start_new_thread_doc}, - {"start_new", thread_PyThread_start_new_thread, - METH_VARARGS, start_new_doc}, - {"start_joinable_thread", _PyCFunction_CAST(thread_PyThread_start_joinable_thread), - METH_VARARGS | METH_KEYWORDS, start_joinable_doc}, - {"daemon_threads_allowed", thread_daemon_threads_allowed, - METH_NOARGS, daemon_threads_allowed_doc}, - {"allocate_lock", thread_PyThread_allocate_lock, - METH_NOARGS, allocate_lock_doc}, - {"allocate", thread_PyThread_allocate_lock, + _THREAD_START_NEW_THREAD_METHODDEF + {"start_new", _PyCFunction_CAST(_thread_start_new_thread), + METH_FASTCALL, start_new_doc}, + _THREAD_START_JOINABLE_THREAD_METHODDEF + _THREAD_DAEMON_THREADS_ALLOWED_METHODDEF + _THREAD_ALLOCATE_LOCK_METHODDEF + {"allocate", _thread_allocate_lock, METH_NOARGS, allocate_doc}, - {"exit_thread", thread_PyThread_exit_thread, + {"exit_thread", _thread_exit, METH_NOARGS, exit_thread_doc}, - {"exit", thread_PyThread_exit_thread, - METH_NOARGS, exit_doc}, - {"interrupt_main", thread_PyThread_interrupt_main, - METH_VARARGS, interrupt_doc}, - {"get_ident", thread_get_ident, - METH_NOARGS, get_ident_doc}, + _THREAD_EXIT_METHODDEF + _THREAD_INTERRUPT_MAIN_METHODDEF + _THREAD_GET_IDENT_METHODDEF #ifdef PY_HAVE_THREAD_NATIVE_ID - {"get_native_id", thread_get_native_id, - METH_NOARGS, get_native_id_doc}, + _THREAD_GET_NATIVE_ID_METHODDEF #endif - {"_count", thread__count, - METH_NOARGS, _count_doc}, - {"stack_size", thread_stack_size, - METH_VARARGS, stack_size_doc}, - {"_excepthook", thread_excepthook, - METH_O, excepthook_doc}, - {"_is_main_interpreter", thread__is_main_interpreter, - METH_NOARGS, thread__is_main_interpreter_doc}, - {"_shutdown", thread_shutdown, - METH_NOARGS, shutdown_doc}, - {"_make_thread_handle", thread__make_thread_handle, - METH_O, thread__make_thread_handle_doc}, - {"_get_main_thread_ident", thread__get_main_thread_ident, - METH_NOARGS, thread__get_main_thread_ident_doc}, + _THREAD__COUNT_METHODDEF + _THREAD_STACK_SIZE_METHODDEF + _THREAD__EXCEPTHOOK_METHODDEF + _THREAD__IS_MAIN_INTERPRETER_METHODDEF + _THREAD__SHUTDOWN_METHODDEF + _THREAD__MAKE_THREAD_HANDLE_METHODDEF + _THREAD__GET_MAIN_THREAD_IDENT_METHODDEF _THREAD_SET_NAME_METHODDEF _THREAD__GET_NAME_METHODDEF {NULL, NULL} /* sentinel */ diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index f5fb1841f0d5940..5eadf6b235e1d7a 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -31,8 +31,11 @@ Copyright (C) 1994 Steen Lumholt. #endif #include "pycore_long.h" // _PyLong_IsNegative() +#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_INT_RELAXED() #include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8String +#include // SIGINT + #ifdef MS_WINDOWS # include #endif @@ -40,9 +43,10 @@ Copyright (C) 1994 Steen Lumholt. #define CHECK_SIZE(size, elemsize) \ ((size_t)(size) <= Py_MIN((size_t)INT_MAX, UINT_MAX / (size_t)(elemsize))) -/* If Tcl is compiled for threads, we must also define TCL_THREAD. We define - it always; if Tcl is not threaded, the thread functions in - Tcl are empty. */ +/* Tcl 8 headers make the Tcl mutex and condition variable functions + no-ops unless TCL_THREADS is defined. Tcl is required to be built + with thread support (this is checked when creating a tkapp), so + always define it. */ #define TCL_THREADS #ifdef TK_FRAMEWORK @@ -227,105 +231,115 @@ Tkinter_TkInit(Tcl_Interp *interp) does not search. Mount the DLL using Zipfs if possible. */ mount_tk_dll_zip(); #endif - return Tk_Init(interp); +#ifdef __APPLE__ + /* Tk on macOS replaces the handlers of these signals with its own, + which exits the process. Keep the handlers installed by Python + (gh-157672). */ + static const int signals[] = {SIGINT, SIGHUP, SIGTERM}; + PyOS_sighandler_t handlers[Py_ARRAY_LENGTH(signals)]; + for (size_t i = 0; i < Py_ARRAY_LENGTH(signals); i++) { + handlers[i] = PyOS_getsig(signals[i]); + } +#endif + int result = Tk_Init(interp); +#ifdef __APPLE__ + for (size_t i = 0; i < Py_ARRAY_LENGTH(signals); i++) { + if (handlers[i] != SIG_DFL) { + PyOS_setsig(signals[i], handlers[i]); + } + } +#endif + return result; } -/* The threading situation is complicated. Tcl is not thread-safe, except - when configured with --enable-threads. - - So we need to use a lock around all uses of Tcl. Previously, the - Python interpreter lock was used for this. However, this causes - problems when other Python threads need to run while Tcl is blocked - waiting for events. +/* Tcl is required to be built with thread support. A Tcl interpreter is + only valid in the thread that created it, and all Tk activity must + happen in this thread. That means that the mainloop must be invoked in + the thread that created the interpreter. Invoking commands from other + threads is possible: _tkinter queues an event for the interpreter + thread, which executes the command and passes back the result. If the + interpreter thread is not in the mainloop, invoking a command raises an + exception; if the mainloop is running but not processing events, the + invocation blocks. - To solve this problem, a separate lock for Tcl is introduced. - Holding it is incompatible with holding Python's interpreter lock. - The following four macros manipulate both locks together. + The Python interpreter lock is released while Tcl runs, so that other + Python threads can run while Tcl is blocked waiting for events. The + thread state saved for that is kept in tcl_tstate, which is + thread-local, since several Tcl interpreters may run in different + threads at the same time. The following macros manage this. ENTER_TCL and LEAVE_TCL are brackets, just like Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS. They should be used whenever a call into Tcl is made that could call an event handler, or otherwise affect the state of a Tcl interpreter. These assume that the surrounding code has the Python interpreter lock; - inside the brackets, the Python interpreter lock has been released - and the lock for Tcl has been acquired. + inside the brackets, the Python interpreter lock has been released. - Sometimes, it is necessary to have both the Python lock and the Tcl - lock. (For example, when transferring data from the Tcl - interpreter result to a Python string object.) This can be done by - using different macros to close the ENTER_TCL block: ENTER_OVERLAP - reacquires the Python lock (and restores the thread state) but - doesn't release the Tcl lock; LEAVE_OVERLAP_TCL releases the Tcl - lock. + Sometimes, it is necessary to use Python inside the ENTER_TCL block, + for example when transferring data from the Tcl interpreter result to + a Python object. This can be done by using different macros to close + the ENTER_TCL block: ENTER_OVERLAP reacquires the Python interpreter + lock (and restores the thread state); LEAVE_OVERLAP_TCL then closes + the block. By contrast, ENTER_PYTHON and LEAVE_PYTHON are used in Tcl event handlers when the handler needs to use Python. Such event handlers - are entered while the lock for Tcl is held; the event handler - presumably needs to use Python. ENTER_PYTHON releases the lock for - Tcl and acquires the Python interpreter lock, restoring the - appropriate thread state, and LEAVE_PYTHON releases the Python - interpreter lock and re-acquires the lock for Tcl. It is okay for - ENTER_TCL/LEAVE_TCL pairs to be contained inside the code between - ENTER_PYTHON and LEAVE_PYTHON. - - These locks expand to several statements and brackets; they should + are called inside an ENTER_TCL block. ENTER_PYTHON acquires the + Python interpreter lock, restoring the saved thread state, and + LEAVE_PYTHON releases it again. It is okay for ENTER_TCL/LEAVE_TCL + pairs to be contained inside the code between ENTER_PYTHON and + LEAVE_PYTHON. + + An event handler can also be called when Tcl is not entered with + ENTER_TCL, for example from a foreign event loop on Windows, which + dispatches a window message to Tk while the Python interpreter lock + is released. Then there is no saved thread state, so ENTER_PYTHON + acquires the Python interpreter lock with PyGILState_Ensure() and + LEAVE_PYTHON releases it with PyGILState_Release(). + + These macros expand to several statements and brackets; they should not be used in branches of if statements and the like. - - If Tcl is threaded, this approach won't work anymore. The Tcl - interpreter is only valid in the thread that created it, and all Tk - activity must happen in this thread, also. That means that the - mainloop must be invoked in the thread that created the - interpreter. Invoking commands from other threads is possible; - _tkinter will queue an event for the interpreter thread, which will - then execute the command and pass back the result. If the main - thread is not in the mainloop, and invoking commands causes an - exception; if the main loop is running but not processing events, - the command invocation will block. - - In addition, for a threaded Tcl, a single global tcl_tstate won't - be sufficient anymore, since multiple Tcl interpreters may - simultaneously dispatch in different threads. So we use the Tcl TLS - API. - */ -static PyThread_type_lock tcl_lock = 0; - -#ifdef TCL_THREADS static Tcl_ThreadDataKey state_key; #define tcl_tstate \ (*(PyThreadState**)Tcl_GetThreadData(&state_key, sizeof(PyThreadState*))) -#else -static PyThreadState *tcl_tstate = NULL; -#endif #define ENTER_TCL \ { PyThreadState *tstate = PyThreadState_Get(); \ Py_BEGIN_ALLOW_THREADS \ - if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); \ tcl_tstate = tstate; #define LEAVE_TCL \ tcl_tstate = NULL; \ - if(tcl_lock)PyThread_release_lock(tcl_lock); \ Py_END_ALLOW_THREADS} #define ENTER_OVERLAP \ Py_END_ALLOW_THREADS #define LEAVE_OVERLAP_TCL \ - tcl_tstate = NULL; if(tcl_lock)PyThread_release_lock(tcl_lock); } + tcl_tstate = NULL; } #define ENTER_PYTHON \ - { PyThreadState *tstate = tcl_tstate; tcl_tstate = NULL; \ - if(tcl_lock) \ - PyThread_release_lock(tcl_lock); \ - PyEval_RestoreThread((tstate)); } + { PyThreadState *tstate = tcl_tstate; \ + PyGILState_STATE gilstate = PyGILState_UNLOCKED; \ + if (tstate == NULL) { \ + gilstate = PyGILState_Ensure(); \ + } \ + else { \ + tcl_tstate = NULL; \ + PyEval_RestoreThread(tstate); \ + } #define LEAVE_PYTHON \ - { PyThreadState *tstate = PyEval_SaveThread(); \ - if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); \ - tcl_tstate = tstate; } + if (tstate == NULL) { \ + PyGILState_Release(gilstate); \ + } \ + else { \ + tstate = PyEval_SaveThread(); \ + tcl_tstate = tstate; \ + } \ + } #ifndef FREECAST #define FREECAST (char *) @@ -339,9 +353,10 @@ typedef struct { PyObject_HEAD Tcl_Interp *interp; int wantobjects; - int threaded; /* True if tcl_platform[threaded] */ Tcl_ThreadId thread_id; int dispatching; + int quitting; /* Set by quit() to stop mainloop() */ + int event_hook; /* True if counted by EnableEventHook() */ PyObject *trace; /* We cannot include tclInt.h, as this is internal. So we cache interesting types here. */ @@ -373,7 +388,7 @@ typedef struct { static inline int check_tcl_appartment(TkappObject *app) { - if (app->threaded && app->thread_id != Tcl_GetCurrentThread()) { + if (app->thread_id != Tcl_GetCurrentThread()) { PyErr_SetString(PyExc_RuntimeError, "Calling Tcl from different apartment"); return -1; @@ -392,9 +407,14 @@ check_tcl_appartment(TkappObject *app) /**** Error Handling ****/ static PyObject *Tkinter_TclError; -static int quitMainLoop = 0; -static int errorInCmd = 0; -static PyObject *excInCmd; + +/* An exception raised in a Python callback, which should be raised by the + event loop (mainloop() or the event hook) that called the callback. + Callbacks are only called in the thread of their Tcl interpreter, so it + is thread-local. */ +static Tcl_ThreadDataKey excInCmd_key; +#define excInCmd \ + (*(PyObject **)Tcl_GetThreadData(&excInCmd_key, sizeof(PyObject *))) static PyObject *Tkapp_UnicodeResult(TkappObject *); @@ -624,8 +644,8 @@ Tcl_AppInit(Tcl_Interp *interp) * `tkMain.c'. */ -static void EnableEventHook(void); /* Forward */ -static void DisableEventHook(void); /* Forward */ +static void EnableEventHook(TkappObject *); /* Forward */ +static void DisableEventHook(TkappObject *); /* Forward */ static TkappObject * Tkapp_New(const char *screenName, const char *className, @@ -634,37 +654,37 @@ Tkapp_New(const char *screenName, const char *className, { TkappObject *v; char *argv0; +#if TCL_MAJOR_VERSION < 9 /* Tcl 9.x is always threaded */ + Tcl_Obj* threaded; +#endif PyTypeObject *tp = (PyTypeObject *)Tkapp_Type; v = (TkappObject *)tp->tp_alloc(tp, 0); if (v == NULL) return NULL; + /* Without the GIL, the first-time initialization in Tcl_CreateInterp() + is not thread-safe. Serialize it. */ + static PyMutex tcl_create_mutex; + PyMutex_Lock(&tcl_create_mutex); v->interp = Tcl_CreateInterp(); - v->wantobjects = wantobjects; -#if TCL_MAJOR_VERSION >= 9 - v->threaded = 1; -#else - v->threaded = Tcl_GetVar2Ex(v->interp, "tcl_platform", "threaded", - TCL_GLOBAL_ONLY) != NULL; -#endif + PyMutex_Unlock(&tcl_create_mutex); v->thread_id = Tcl_GetCurrentThread(); - v->dispatching = 0; - v->trace = NULL; - -#ifndef TCL_THREADS - if (v->threaded) { +#if TCL_MAJOR_VERSION < 9 /* Tcl 9.x is always threaded */ + threaded = Tcl_GetVar2Ex(v->interp, + "tcl_platform", + "threaded", + TCL_GLOBAL_ONLY); + if (threaded == NULL) { PyErr_SetString(PyExc_RuntimeError, - "Tcl is threaded but _tkinter is not"); + "Tcl must be compiled with thread support"); Py_DECREF(v); - return 0; + return NULL; } #endif - if (v->threaded && tcl_lock) { - /* If Tcl is threaded, we don't need the lock. */ - PyThread_free_lock(tcl_lock); - tcl_lock = NULL; - } + v->wantobjects = wantobjects; + v->dispatching = 0; + v->trace = NULL; v->OldBooleanType = Tcl_GetObjType("boolean"); { @@ -811,7 +831,7 @@ Tkapp_New(const char *screenName, const char *className, return (TkappObject *)result; } - EnableEventHook(); + EnableEventHook(v); return v; } @@ -1027,13 +1047,21 @@ asBignumObj(PyObject *value) return result; } -static Tcl_Obj* AsObj(PyObject *value); +static Tcl_Obj* AsObjNested(PyObject *value, int depth); static Tcl_Obj* -TupleAsObj(PyObject *value, int wrapped) +TupleAsObj(PyObject *value, int wrapped, int depth) { Tcl_Obj *result = NULL; Py_ssize_t size = PyTuple_GET_SIZE(value); + /* The same limit as in _flatten1(). It bounds not only the recursion + here, but also the recursion in Tcl when it generates the string + representation of the nested list, so a C stack check is not enough. */ + if (depth > 1000) { + PyErr_SetString(PyExc_ValueError, + "nesting too deep in conversion to Tcl object"); + return NULL; + } if (size == 0) { return Tcl_NewListObj(0, NULL); } @@ -1048,8 +1076,15 @@ TupleAsObj(PyObject *value, int wrapped) return NULL; } for (Py_ssize_t i = 0; i < size; i++) { - Tcl_Obj *item = AsObj(PyTuple_GET_ITEM(value, i)); + Tcl_Obj *item = AsObjNested(PyTuple_GET_ITEM(value, i), depth + 1); if (item == NULL) { + /* Free the already converted items. A new Tcl object has a + zero reference count, so it must be acquired before it can + be released. */ + while (--i >= 0) { + Tcl_IncrRefCount(argv[i]); + Tcl_DecrRefCount(argv[i]); + } goto exit; } argv[i] = item; @@ -1062,7 +1097,7 @@ TupleAsObj(PyObject *value, int wrapped) } static Tcl_Obj* -AsObj(PyObject *value) +AsObjNested(PyObject *value, int depth) { Tcl_Obj *result; @@ -1108,7 +1143,7 @@ AsObj(PyObject *value) return Tcl_NewDoubleObj(PyFloat_AS_DOUBLE(value)); if (PyTuple_Check(value)) { - return TupleAsObj(value, false); + return TupleAsObj(value, false, depth); } if (PyList_Check(value)) { @@ -1116,7 +1151,7 @@ AsObj(PyObject *value) if (value_as_tuple == NULL) { return NULL; } - result = TupleAsObj(value_as_tuple, true); + result = TupleAsObj(value_as_tuple, true, depth); Py_DECREF(value_as_tuple); return result; } @@ -1199,14 +1234,21 @@ AsObj(PyObject *value) { PyObject *v = PyObject_Str(value); - if (!v) - return 0; - result = AsObj(v); + if (!v) { + return NULL; + } + result = AsObjNested(v, depth); Py_DECREF(v); return result; } } +static Tcl_Obj* +AsObj(PyObject *value) +{ + return AsObjNested(value, 0); +} + static PyObject * fromBoolean(TkappObject *tkapp, Tcl_Obj *value) { @@ -1364,19 +1406,25 @@ FromObj(TkappObject *tkapp, Tcl_Obj *value) result = PyTuple_New(size); if (!result) return NULL; + if (Py_EnterRecursiveCall(" while converting a Tcl list")) { + Py_DECREF(result); + return NULL; + } for (i = 0; i < size; i++) { status = Tcl_ListObjIndex(interp, value, i, &tcl_elem); if (status == TCL_ERROR) { - Py_DECREF(result); - return Tkinter_Error(tkapp); + Tkinter_Error(tkapp); + Py_CLEAR(result); + break; } elem = FromObj(tkapp, tcl_elem); if (!elem) { - Py_DECREF(result); - return NULL; + Py_CLEAR(result); + break; } PyTuple_SET_ITEM(result, i, elem); } + Py_LeaveRecursiveCall(); return result; } @@ -1610,8 +1658,7 @@ Tkapp_Trace(TkappObject *self, PyObject *args) } while (0) /* Tkapp_CallProc is the event procedure that is executed in the context of - the Tcl interpreter thread. Initially, it holds the Tcl lock, and doesn't - hold the Python lock. */ + the Tcl interpreter thread. Initially, it doesn't hold the Python lock. */ static int Tkapp_CallProc(Tcl_Event *evPtr, int flags) @@ -1659,25 +1706,29 @@ Tkapp_CallProc(Tcl_Event *evPtr, int flags) /* This is the main entry point for calling a Tcl command. - It supports three cases, with regard to threading: - 1. Tcl is not threaded: Must have the Tcl lock, then can invoke command in - the context of the calling thread. - 2. Tcl is threaded, caller of the command is in the interpreter thread: - Execute the command in the calling thread. Since the Tcl lock will - not be used, we can merge that with case 1. - 3. Tcl is threaded, caller is in a different thread: Must queue an event to + It supports two cases, with regard to threading: + 1. Caller of the command is in the interpreter thread: + Execute the command in the calling thread. + 2. Caller is in a different thread: Must queue an event to the interpreter thread. Allocation of Tcl objects needs to occur in the interpreter thread, so we ship the PyObject* args to the target thread, and perform processing there. */ +/*[clinic input] +_tkinter.tkapp.call + + *args: tuple + +[clinic start generated code]*/ + static PyObject * -Tkapp_Call(PyObject *selfptr, PyObject *args) +_tkinter_tkapp_call_impl(TkappObject *self, PyObject *args) +/*[clinic end generated code: output=2af3af48d1927065 input=60052dc395d80297]*/ { Tcl_Obj *objStore[ARGSZ]; Tcl_Obj **objv = NULL; Tcl_Size objc; PyObject *res = NULL; - TkappObject *self = TkappObject_CAST(selfptr); int flags = TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL; /* If args is a single tuple, replace with contents of tuple */ @@ -1686,7 +1737,7 @@ Tkapp_Call(PyObject *selfptr, PyObject *args) if (PyTuple_Check(item)) args = item; } - if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) { + if (self->thread_id != Tcl_GetCurrentThread()) { /* We cannot call the command directly. Instead, we must marshal the parameters to the interpreter thread. */ Tkapp_CallEvent *ev; @@ -1963,7 +2014,7 @@ static PyObject* var_invoke(EventFunc func, PyObject *selfptr, PyObject *args, int flags) { TkappObject *self = TkappObject_CAST(selfptr); - if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) { + if (self->thread_id != Tcl_GetCurrentThread()) { VarEvent *ev; // init 'res' and 'exc' to make static analyzers happy PyObject *res = NULL, *exc = NULL; @@ -1997,7 +2048,7 @@ var_invoke(EventFunc func, PyObject *selfptr, PyObject *args, int flags) } return res; } - /* Tcl is not threaded, or this is the interpreter thread. */ + /* This is the interpreter thread. */ return func(self, args, flags); } @@ -2014,7 +2065,6 @@ SetVar(TkappObject *self, PyObject *args, int flags) if (!PyArg_ParseTuple(args, "O&O:setvar", varname_converter, &name1, &newValue)) return NULL; - /* XXX Acquire tcl lock??? */ newval = AsObj(newValue); if (newval == NULL) return NULL; @@ -2045,8 +2095,10 @@ SetVar(TkappObject *self, PyObject *args, int flags) CHECK_STRING_LENGTH(name1); CHECK_STRING_LENGTH(name2); - /* XXX must hold tcl lock already??? */ newval = AsObj(newValue); + if (newval == NULL) { + return NULL; + } if (self->trace) { if (flags & TCL_GLOBAL_ONLY) { TRACE(self, ("((sssNO))", "uplevel", "#0", "set", @@ -2531,15 +2583,6 @@ typedef struct { PyObject *func; } PythonCmd_ClientData; -static int -PythonCmd_Error(Tcl_Interp *interp) -{ - errorInCmd = 1; - excInCmd = PyErr_GetRaisedException(); - LEAVE_PYTHON - return TCL_ERROR; -} - /* This is the Tcl command that acts as a wrapper for Python * function or method. */ @@ -2552,19 +2595,20 @@ PythonCmd(ClientData clientData, Tcl_Interp *interp, int i; Tcl_Obj *obj_res; int objargs = data->self->wantobjects >= 2; + int result = TCL_ERROR; ENTER_PYTHON /* Create argument tuple (objv1, ..., objvN) */ if (!(args = PyTuple_New(objc - 1))) - return PythonCmd_Error(interp); + goto error; for (i = 0; i < (objc - 1); i++) { PyObject *s = objargs ? FromObj(data->self, objv[i + 1]) : unicodeFromTclObj(data->self, objv[i + 1]); if (!s) { Py_DECREF(args); - return PythonCmd_Error(interp); + goto error; } PyTuple_SET_ITEM(args, i, s); } @@ -2573,19 +2617,24 @@ PythonCmd(ClientData clientData, Tcl_Interp *interp, Py_DECREF(args); if (res == NULL) - return PythonCmd_Error(interp); + goto error; obj_res = AsObj(res); if (obj_res == NULL) { Py_DECREF(res); - return PythonCmd_Error(interp); + goto error; } Tcl_SetObjResult(interp, obj_res); Py_DECREF(res); + result = TCL_OK; + goto done; +error: + Py_XSETREF(excInCmd, PyErr_GetRaisedException()); +done: LEAVE_PYTHON - return TCL_OK; + return result; } @@ -2655,7 +2704,7 @@ _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name, return NULL; } - if (self->threaded && self->thread_id != Tcl_GetCurrentThread() && + if (self->thread_id != Tcl_GetCurrentThread() && !WaitForMainloop(self)) return NULL; @@ -2669,7 +2718,7 @@ _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name, (gh-80937). The command cannot outlive the interpreter. */ data->self = self; data->func = Py_NewRef(func); - if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) { + if (self->thread_id != Tcl_GetCurrentThread()) { err = 0; // init to make static analyzers happy Tcl_Condition cond = NULL; @@ -2727,7 +2776,7 @@ _tkinter_tkapp_deletecommand_impl(TkappObject *self, const char *name) TRACE(self, ("((sss))", "rename", name, "")); - if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) { + if (self->thread_id != Tcl_GetCurrentThread()) { err = 0; // init to make static analyzers happy Tcl_Condition cond = NULL; @@ -2819,8 +2868,7 @@ FileHandler(ClientData clientData, int mask) res = PyObject_CallFunction(func, "Oi", file, mask); if (res == NULL) { - errorInCmd = 1; - excInCmd = PyErr_GetRaisedException(); + Py_XSETREF(excInCmd, PyErr_GetRaisedException()); } Py_XDECREF(res); LEAVE_PYTHON @@ -3024,8 +3072,7 @@ TimerHandler(ClientData clientData) Py_DECREF(v); /* See Tktt_New() */ if (res == NULL) { - errorInCmd = 1; - excInCmd = PyErr_GetRaisedException(); + Py_XSETREF(excInCmd, PyErr_GetRaisedException()); } else Py_DECREF(res); @@ -3082,50 +3129,38 @@ static PyObject * _tkinter_tkapp_mainloop_impl(TkappObject *self, int threshold) /*[clinic end generated code: output=0ba8eabbe57841b0 input=036bcdcf03d5eca0]*/ { - PyThreadState *tstate = PyThreadState_Get(); - CHECK_TCL_APPARTMENT(self); + /* mainloop() can be nested, the outer mainloop() still dispatches + events after the inner one exits. */ + int dispatching = self->dispatching; self->dispatching = 1; - quitMainLoop = 0; + FT_ATOMIC_STORE_INT_RELAXED(self->quitting, 0); while (Tk_GetNumMainWindows() > threshold && - !quitMainLoop && - !errorInCmd) + !FT_ATOMIC_LOAD_INT_RELAXED(self->quitting) && + excInCmd == NULL) { int result; - if (self->threaded) { - /* Allow other Python threads to run. */ - ENTER_TCL - result = Tcl_DoOneEvent(0); - LEAVE_TCL - } - else { - Py_BEGIN_ALLOW_THREADS - if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); - tcl_tstate = tstate; - result = Tcl_DoOneEvent(TCL_DONT_WAIT); - tcl_tstate = NULL; - if(tcl_lock)PyThread_release_lock(tcl_lock); - if (result == 0) - Sleep(Tkinter_busywaitinterval); - Py_END_ALLOW_THREADS - } + /* Allow other Python threads to run. */ + ENTER_TCL + result = Tcl_DoOneEvent(0); + LEAVE_TCL if (PyErr_CheckSignals() != 0) { - self->dispatching = 0; + self->dispatching = dispatching; return NULL; } if (result < 0) break; } - self->dispatching = 0; - quitMainLoop = 0; + self->dispatching = dispatching; + FT_ATOMIC_STORE_INT_RELAXED(self->quitting, 0); - if (errorInCmd) { - errorInCmd = 0; - PyErr_SetRaisedException(excInCmd); + PyObject *exc = excInCmd; + if (exc != NULL) { excInCmd = NULL; + PyErr_SetRaisedException(exc); return NULL; } Py_RETURN_NONE; @@ -3151,6 +3186,13 @@ _tkinter_tkapp_dooneevent_impl(TkappObject *self, int flags) return PyLong_FromLong(rv); } +static int +QuitEventProc(Tcl_Event *evPtr, int flags) +{ + /* Nothing to do: the event only wakes up the event loop. */ + return 1; +} + /*[clinic input] _tkinter.tkapp.quit [clinic start generated code]*/ @@ -3159,7 +3201,19 @@ static PyObject * _tkinter_tkapp_quit_impl(TkappObject *self) /*[clinic end generated code: output=7f21eeff481f754f input=e03020dc38aff23c]*/ { - quitMainLoop = 1; + FT_ATOMIC_STORE_INT_RELAXED(self->quitting, 1); + if (self->dispatching && self->thread_id != Tcl_GetCurrentThread()) { + /* mainloop() is running in other thread and can wait for an event. + Send it an event, so that it checks the flag. */ + Tcl_Event *ev = (Tcl_Event *)attemptckalloc(sizeof(Tcl_Event)); + if (ev == NULL) { + return PyErr_NoMemory(); + } + memset(ev, 0, sizeof(Tcl_Event)); + ev->proc = QuitEventProc; + Tcl_ThreadQueueEvent(self->thread_id, ev, TCL_QUEUE_TAIL); + Tcl_ThreadAlert(self->thread_id); + } Py_RETURN_NONE; } @@ -3211,18 +3265,23 @@ _tkinter_tkapp_loadtk_impl(TkappObject *self) Py_RETURN_NONE; } +/*[clinic input] +_tkinter.tkapp.wantobjects + + value: int = -1 + / + +Return the current setting, or set it if the argument is not -1. +[clinic start generated code]*/ + static PyObject * -Tkapp_WantObjects(PyObject *op, PyObject *args) +_tkinter_tkapp_wantobjects_impl(TkappObject *self, int value) +/*[clinic end generated code: output=10ce2bffa4adb3a4 input=69a4045e2c202385]*/ { - TkappObject *self = TkappObject_CAST(op); - int wantobjects = -1; - if (!PyArg_ParseTuple(args, "|i:wantobjects", &wantobjects)) { - return NULL; - } - if (wantobjects == -1) { + if (value == -1) { return PyLong_FromLong(self->wantobjects); } - self->wantobjects = wantobjects; + self->wantobjects = value; Py_RETURN_NONE; } @@ -3309,7 +3368,7 @@ Tkapp_Dealloc(PyObject *op) TkappObject *self = (TkappObject *)op; PyTypeObject *tp = Py_TYPE(op); PyObject_GC_UnTrack(op); - if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) { + if (self->thread_id != Tcl_GetCurrentThread()) { /* Deleting the interpreter from another thread aborts the process ("Tcl_AsyncDelete: async handler deleted by the wrong thread"). Leak it instead (gh-83274). */ @@ -3327,10 +3386,10 @@ Tkapp_Dealloc(PyObject *op) Tcl_DeleteInterp(Tkapp_Interp(self)); LEAVE_TCL } + DisableEventHook(self); (void)Tkapp_Clear(op); tp->tp_free(op); Py_DECREF(tp); - DisableEventHook(); } @@ -3486,21 +3545,21 @@ _tkinter_create_impl(PyObject *module, const char *screenName, } /*[clinic input] -@permit_long_summary _tkinter.setbusywaitinterval new_val: int / -Set the busy-wait interval in milliseconds between successive calls to Tcl_DoOneEvent in a threaded Python interpreter. +Set the busy-wait interval in milliseconds. -It should be set to a divisor of the maximum time between frames in -an animation. +It is the interval between successive calls to Tcl_DoOneEvent when +waiting for input at the interactive prompt on Windows. It should be +set to a divisor of the maximum time between frames in an animation. [clinic start generated code]*/ static PyObject * _tkinter_setbusywaitinterval_impl(PyObject *module, int new_val) -/*[clinic end generated code: output=42bf7757dc2d0ab6 input=0360dd95c8bd8619]*/ +/*[clinic end generated code: output=42bf7757dc2d0ab6 input=05733d51be719869]*/ { if (new_val < 0) { PyErr_SetString(PyExc_ValueError, @@ -3512,19 +3571,32 @@ _tkinter_setbusywaitinterval_impl(PyObject *module, int new_val) } /*[clinic input] -@permit_long_summary _tkinter.getbusywaitinterval -> int -Return the current busy-wait interval between successive calls to Tcl_DoOneEvent in a threaded Python interpreter. +Return the current busy-wait interval in milliseconds. [clinic start generated code]*/ static int _tkinter_getbusywaitinterval_impl(PyObject *module) -/*[clinic end generated code: output=23b72d552001f5c7 input=62d5b36ddab3976b]*/ +/*[clinic end generated code: output=23b72d552001f5c7 input=cd3d96a258e75ade]*/ { return Tkinter_busywaitinterval; } +/*[clinic input] +_tkinter._finalize_thread + +Clean up per-thread state. +[clinic start generated code]*/ + +static PyObject * +_tkinter__finalize_thread_impl(PyObject *module) +/*[clinic end generated code: output=4ed0d3be4d1f8de8 input=ea68096ee9b83d23]*/ +{ + Tcl_FinalizeThread(); + Py_RETURN_NONE; +} + #include "clinic/_tkinter.c.h" static PyMethodDef Tktt_methods[] = @@ -3560,10 +3632,10 @@ static PyType_Spec Tktt_Type_spec = { static PyMethodDef Tkapp_methods[] = { _TKINTER_TKAPP_WILLDISPATCH_METHODDEF - {"wantobjects", Tkapp_WantObjects, METH_VARARGS}, + _TKINTER_TKAPP_WANTOBJECTS_METHODDEF _TKINTER_TKAPP_SETTRACE_METHODDEF _TKINTER_TKAPP_GETTRACE_METHODDEF - {"call", Tkapp_Call, METH_VARARGS}, + _TKINTER_TKAPP_CALL_METHODDEF _TKINTER_TKAPP_EVAL_METHODDEF _TKINTER_TKAPP_EVALFILE_METHODDEF _TKINTER_TKAPP_RECORD_METHODDEF @@ -3622,10 +3694,15 @@ static PyMethodDef moduleMethods[] = _TKINTER_CREATE_METHODDEF _TKINTER_SETBUSYWAITINTERVAL_METHODDEF _TKINTER_GETBUSYWAITINTERVAL_METHODDEF + _TKINTER__FINALIZE_THREAD_METHODDEF {NULL, NULL} }; #ifdef WAIT_FOR_STDIN +/* The number of Tcl interpreters which use the event hook. */ +static Py_ssize_t event_hook_users = 0; +static PyMutex event_hook_mutex = {0}; + #ifndef MS_WINDOWS static int stdin_ready = 0; @@ -3643,8 +3720,6 @@ MyFileProc(void *clientData, int mask) } #endif -static PyThreadState *event_tstate = NULL; - static int EventHook(void) { @@ -3653,10 +3728,18 @@ EventHook(void) DWORD type; #else int tfile; +#endif + /* The hook is called with the GIL released, usually by PyOS_Readline() + in the thread which reads the input. Use the thread state of that + thread, not of the thread which created the Tcl interpreter. */ + PyThreadState *tstate = PyGILState_GetThisThreadState(); + if (tstate == NULL) { + return 0; + } +#ifndef MS_WINDOWS stdin_ready = 0; #endif - PyEval_RestoreThread(event_tstate); - errorInCmd = 0; + PyEval_RestoreThread(tstate); #ifdef MS_WINDOWS hStdin = GetStdHandle(STD_INPUT_HANDLE); type = GetFileType(hStdin); @@ -3684,27 +3767,32 @@ EventHook(void) else if (type == FILE_TYPE_DISK) { break; } -#endif + /* stdin is not a Tcl event source on Windows, so poll. */ Py_BEGIN_ALLOW_THREADS - if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); - tcl_tstate = event_tstate; - + tcl_tstate = tstate; result = Tcl_DoOneEvent(TCL_DONT_WAIT); - tcl_tstate = NULL; - if(tcl_lock)PyThread_release_lock(tcl_lock); if (result == 0) Sleep(Tkinter_busywaitinterval); Py_END_ALLOW_THREADS +#else + /* stdin is watched by MyFileProc, so we can wait for an event or + input instead of polling. */ + Py_BEGIN_ALLOW_THREADS + tcl_tstate = tstate; + result = Tcl_DoOneEvent(0); + tcl_tstate = NULL; + Py_END_ALLOW_THREADS +#endif /* Report an exception raised in a callback, but keep pumping events instead of returning to the prompt: without readline there is no input waiting on stdin yet, so returning here would block in fgets until the user hits enter, freezing later callbacks. */ - if (errorInCmd) { - errorInCmd = 0; - PyErr_SetRaisedException(excInCmd); + PyObject *exc = excInCmd; + if (exc != NULL) { excInCmd = NULL; + PyErr_SetRaisedException(exc); PyErr_Print(); } if (result < 0) @@ -3721,23 +3809,32 @@ EventHook(void) #endif static void -EnableEventHook(void) +EnableEventHook(TkappObject *self) { #ifdef WAIT_FOR_STDIN + PyMutex_Lock(&event_hook_mutex); + event_hook_users++; if (PyOS_InputHook == NULL) { - event_tstate = PyThreadState_Get(); PyOS_InputHook = EventHook; } + self->event_hook = 1; + PyMutex_Unlock(&event_hook_mutex); #endif } static void -DisableEventHook(void) +DisableEventHook(TkappObject *self) { #ifdef WAIT_FOR_STDIN - if (Tk_GetNumMainWindows() == 0 && PyOS_InputHook == EventHook) { + if (!self->event_hook) { + return; + } + PyMutex_Lock(&event_hook_mutex); + self->event_hook = 0; + if (--event_hook_users == 0 && PyOS_InputHook == EventHook) { PyOS_InputHook = NULL; } + PyMutex_Unlock(&event_hook_mutex); #endif } @@ -3787,10 +3884,6 @@ PyInit__tkinter(void) PyObject *m, *uexe, *cexe; - tcl_lock = PyThread_allocate_lock(); - if (tcl_lock == NULL) - return PyErr_NoMemory(); - m = PyModule_Create(&_tkintermodule); if (m == NULL) return NULL; @@ -3848,6 +3941,14 @@ PyInit__tkinter(void) Py_DECREF(m); return NULL; } + if (PyModule_AddStringConstant(m, "TK_PATCH_LEVEL", TK_PATCH_LEVEL)) { + Py_DECREF(m); + return NULL; + } + if (PyModule_AddStringConstant(m, "TCL_PATCH_LEVEL", TCL_PATCH_LEVEL)) { + Py_DECREF(m); + return NULL; + } Tkapp_Type = PyType_FromSpec(&Tkapp_Type_spec); if (PyModule_AddObjectRef(m, "TkappType", Tkapp_Type)) { diff --git a/Modules/_uuidmodule.c b/Modules/_uuidmodule.c index c31a7e8fea56084..04bce1bd18901b8 100644 --- a/Modules/_uuidmodule.c +++ b/Modules/_uuidmodule.c @@ -1,15 +1,26 @@ /* - * Python UUID module that wraps libuuid or Windows rpcrt4.dll. + * Python UUID module: + * - wraps libuuid or Windows rpcrt4.dll. + * - implements fast version of the uuid.py:UUID class. + * - re-implements uuid4() and uuid7() functions with improved performance + * by virtue of them being implemented in C and better entropy fetching + * strategy. + * * DCE compatible Universally Unique Identifier library. */ -// Need limited C API version 3.13 for Py_mod_gil -#include "pyconfig.h" // Py_GIL_DISABLED -#ifndef Py_GIL_DISABLED -# define Py_LIMITED_API 0x030d0000 +#ifndef Py_BUILD_CORE_BUILTIN +# define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" + +#include "pycore_critical_section.h" // _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED() +#include "pycore_long.h" // _PyLong_AsByteArray(), _PyLong_GetOne() +#include "pycore_pylifecycle.h" // _PyOS_URandom() +#include "pycore_runtime_init.h" // _Py_ID() +#include "pycore_strhex.h" // _Py_strhex() + #if defined(HAVE_UUID_H) // AIX, FreeBSD, libuuid with pkgconf #include @@ -18,12 +29,34 @@ #include #endif +#ifdef HAVE_UNISTD_H +# include // getpid() +#endif +#ifdef HAVE_PROCESS_H +# include // getpid() +#endif +#ifdef MS_WINDOWS +# include // GetCurrentProcessId() +#endif + #ifdef MS_WINDOWS #include +#ifndef RPC_S_OK +#define RPC_S_OK 0L +#endif #endif +#include // memcpy(), memset(), strncmp() + #ifndef MS_WINDOWS + +/*[clinic input] +module _uuid +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=7cbed123a45a3859]*/ + + static PyObject * py_uuid_generate_time_safe(PyObject *Py_UNUSED(context), PyObject *Py_UNUSED(ignored)) @@ -91,45 +124,1762 @@ py_windows_has_stable_node(void) #endif /* MS_WINDOWS */ +#define UUID_SIZE 16 + +typedef struct uuidobject { + PyObject_HEAD + uint8_t bytes[UUID_SIZE]; + Py_hash_t cached_hash; + PyObject *is_safe; + PyObject *weakreflist; +} uuidobject; + +#define uuidobject_CAST(OP) ((uuidobject *)(OP)) + + +// UUID Structure per RFC 9562: +// +// A UUID is 128 bits (16 bytes) represented as: +// +// String: xx xx xx xx - xx xx - Mx xx - Nx xx - xx xx xx xx xx xx +// Byte pos: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +// +// Time-based layouts in big-endian order (field widths in bits): +// +// v1: time_low(32) | time_mid(16) | version(4) | time_high(12) | +// variant(2) | clock_seq(14) | node(48) +// v6: time_high(32) | time_mid(16) | version(4) | time_low(12) | +// variant(2) | clock_seq(14) | node(48) +// v7: unix_ts_ms(48) | version(4) | rand_a(12) | variant(2) | rand_b(62) +// +// v1 and v6 encode the same 60-bit timestamp in 100-nanosecond intervals +// since 1582-10-15, with different field ordering. v7 uses milliseconds +// since the Unix epoch. Its rand_a and rand_b fields hold random/counter +// bits, with no clock sequence or node field. +// +// M is the version field: the most significant 4 bits of byte 6. +// +// N contains the variant: the most significant variable bits of byte 8. +// 0xxx: Reserved for NCS compatibility +// 10xx: RFC 4122/9562 (standard) +// 110x: Reserved for Microsoft compatibility +// 111x: Reserved for future definition + +#define RANDOM_BUF_SIZE 256 +#define MAX_FREE_LIST_SIZE 32 + +/* State of the _uuid module */ +typedef struct { + PyTypeObject *uuid_type; + + PyObject *safe_uuid; + + PyObject *uint128_max; + + PyObject *random_func; + PyObject *random_size_int; + PyObject *time_func; + + // A freelist for uuid objects -- 15-20% performance boost. + uuidobject *freelist; + size_t freelist_size; + + // We overfetch entropy to speed up successive uuid generations; + // this enables 10x peformance boost. + uint8_t random_buf[RANDOM_BUF_SIZE]; + Py_ssize_t random_idx; + uint64_t random_last_pid; + + // UUID v7 state + uint64_t last_timestamp_v7; + uint64_t last_counter_v7; + uint8_t last_timestamp_v7_init; +} uuid_state; + +#include "clinic/_uuidmodule.c.h" + +/*[clinic input] +class _uuid.UUID "uuidobject *" "&uuid_type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b62c7d736c192881]*/ + +// Forward declarations +static int from_hex(uuidobject *self, PyObject *hex); +static int from_bytes_le(uuidobject *self, PyObject *bytes_le); +static int from_int(uuidobject *self, PyObject *int_value, int validate); +static int from_fields(uuidobject *self, PyObject *fields); +static PyObject *get_SafeUUID(uuid_state *state); + +static uint64_t +uuid_getpid(void) +{ +#if !defined(MS_WINDOWS) || defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) + return (uint64_t)getpid(); +#else + return (uint64_t)GetCurrentProcessId(); +#endif +} + +static struct PyModuleDef uuidmodule; + +static inline uuid_state * +get_uuid_state(PyObject *mod) +{ + uuid_state *state = PyModule_GetState(mod); + assert(state != NULL); + return state; +} + +static inline uuid_state * +get_uuid_state_by_cls(PyTypeObject *cls) +{ + PyObject *module = PyType_GetModuleByDef(cls, &uuidmodule); + assert(module != NULL); + uuid_state *state = get_uuid_state(module); + assert(state != NULL); + return state; +} + +// Forward declaration +static PyObject *uuid_from_bytes_array(PyTypeObject *type, uint8_t bytes[UUID_SIZE]); + static int -uuid_exec(PyObject *module) +gen_time(uuid_state *state, PyTime_t *time) { -#define ADD_INT(NAME, VALUE) \ - do { \ - if (PyModule_AddIntConstant(module, (NAME), (VALUE)) < 0) { \ - return -1; \ - } \ + if (state->time_func == NULL) { + return PyTime_Time(time); + } + + PyObject *time_func = Py_NewRef(state->time_func); + PyObject *ret = PyObject_CallNoArgs(time_func); + Py_DECREF(time_func); + if (ret == NULL) { + return -1; + } + + if (!PyLong_CheckExact(ret)) { + PyErr_SetString(PyExc_ValueError, "time_func must return int"); + Py_DECREF(ret); + return -1; + } + + int res = PyLong_AsInt64(ret, time); + Py_DECREF(ret); + return res; +} + +static int +gen_random_lock_held(PyObject *module, uuid_state *state, uint8_t *bytes, + Py_ssize_t size) +{ + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(module); + + // Overfetching & caching entropy improves the performance 10x. + // There's a precedent with NodeJS doing exact same thing for + // improving performance of their UUID implementation. + + uint64_t pid = uuid_getpid(); + if (pid != state->random_last_pid) { + // The main concern to take core of with caching entropy is handling + // fork -- we don't want the child process to share any entropy with + // us. Luckily getpid() is fast. + state->random_last_pid = pid; + state->random_idx = RANDOM_BUF_SIZE; + } + + if (state->random_idx + size <= RANDOM_BUF_SIZE) { + memcpy(bytes, state->random_buf + state->random_idx, size); + state->random_idx += size; + } + else { + if (state->random_idx < RANDOM_BUF_SIZE) { + // We exhaustively consume cached entropy. We do that + // because we have tests that compare Python and C + // implementations and it's important that they see incoming + // entropy as a continuous stream. + // The overhead here must be negligible, but we want the same + // code to be run in production and in tests. + Py_ssize_t partial = RANDOM_BUF_SIZE - state->random_idx; + memcpy(bytes, state->random_buf + state->random_idx, partial); + bytes += partial; + size -= partial; + } + + // Reserve the cached bytes before a refill can release the module's + // critical section. Another call must not consume the same bytes. + state->random_idx = RANDOM_BUF_SIZE; + uint8_t random_buf[RANDOM_BUF_SIZE]; + + if (state->random_func != NULL) { + PyObject *random_func = Py_NewRef(state->random_func); + PyObject *buf = PyObject_CallOneArg( + random_func, state->random_size_int); + Py_DECREF(random_func); + if (buf == NULL) { + return -1; + } + + if (!PyBytes_CheckExact(buf)) { + PyErr_SetString(PyExc_ValueError, "random_func must return bytes"); + Py_DECREF(buf); + return -1; + } + + if (PyBytes_Size(buf) != (Py_ssize_t)RANDOM_BUF_SIZE) { + PyErr_Format( + PyExc_ValueError, + "random_func must return bytes of length %zd exactly", + (Py_ssize_t)RANDOM_BUF_SIZE + ); + Py_DECREF(buf); + return -1; + } + + memcpy(random_buf, PyBytes_AsString(buf), sizeof(random_buf)); + Py_DECREF(buf); + } + else { + // _PyOS_URandom() releases the thread state. Fill a private buffer + // so concurrent refills cannot write into the same memory. + if (_PyOS_URandom(random_buf, sizeof(random_buf)) < 0) { + return -1; + } + } + + // We hold the caller's module lock again after fetching entropy. + // Replace the cache, discarding any unused bytes from a concurrent refill. + memcpy(state->random_buf, random_buf, sizeof(random_buf)); + memcpy(bytes, state->random_buf, size); + state->random_idx = size; + } + + return 0; +} + +/*[clinic input] +@critical_section +_uuid.uuid4 + +Generate a random UUID (version 4). +[clinic start generated code]*/ + +static PyObject * +_uuid_uuid4_impl(PyObject *module) +/*[clinic end generated code: output=b835af30d9d6efc5 input=9cfb3a3b71c25cdf]*/ +{ + uuid_state *state = get_uuid_state(module); + uint8_t bytes[UUID_SIZE]; + + if (gen_random_lock_held(module, state, bytes, sizeof(bytes)) < 0) { + return NULL; + } + + // Set version (4) and variant + bytes[6] = (uint8_t)((bytes[6] & 0x0f) | 0x40); + bytes[8] = (uint8_t)((bytes[8] & 0x3f) | 0x80); + + return uuid_from_bytes_array(state->uuid_type, bytes); +} + +static inline int +uuid7_get_counter_and_tail(PyObject *module, uuid_state *state, + uint64_t *counter, uint8_t *tail) +{ + uint8_t rand_bytes[10]; + if (gen_random_lock_held(module, state, rand_bytes, sizeof(rand_bytes)) < 0) { + return -1; + } + + *counter = (((uint64_t)rand_bytes[0] & 0x01) << 40) | + ((uint64_t)rand_bytes[1] << 32) | + ((uint64_t)rand_bytes[2] << 24) | + ((uint64_t)rand_bytes[3] << 16) | + ((uint64_t)rand_bytes[4] << 8) | + ((uint64_t)rand_bytes[5]); + + memcpy(tail, rand_bytes + 6, 4); + return 0; +} + + +// The module's critical section protects the cached entropy and UUIDv7 state. +// It may be suspended during entropy fetching or a Python testing hook. +/*[clinic input] +@critical_section +_uuid.uuid7 + +Generate a UUID from a Unix timestamp in milliseconds and random bits. + +UUIDv7 objects feature monotonicity within a millisecond. +[clinic start generated code]*/ + +static PyObject * +_uuid_uuid7_impl(PyObject *module) +/*[clinic end generated code: output=f301accc11162c91 input=88514d61dc785108]*/ +{ + uuid_state *state = get_uuid_state(module); + uint8_t bytes[UUID_SIZE]; + uint64_t timestamp_ms, counter; + + PyTime_t pytime; + if (gen_time(state, &pytime) < 0) { + return NULL; + } + uint64_t last_timestamp, last_counter; + uint8_t last_timestamp_init; + do { + last_timestamp = state->last_timestamp_v7; + last_counter = state->last_counter_v7; + last_timestamp_init = state->last_timestamp_v7_init; + timestamp_ms = (uint64_t)(pytime / 1000000); + + if (!last_timestamp_init || timestamp_ms > last_timestamp) { + if (uuid7_get_counter_and_tail(module, state, &counter, bytes + 12) < 0) { + return NULL; + } + } + else { + if (timestamp_ms < last_timestamp) { + timestamp_ms = last_timestamp + 1; + } + // advance the 42-bit counter + counter = last_counter + 1; + if (counter > 0x3FFFFFFFFFF) { + // advance the 48-bit timestamp + timestamp_ms += 1; + if (uuid7_get_counter_and_tail(module, state, &counter, bytes + 12) < 0) { + return NULL; + } + } + else { + // This is the common fast path, we only need 4 bytes of entropy + // 32-bit random data + if (gen_random_lock_held(module, state, bytes + 12, 4) < 0) { + return NULL; + } + } + } + // A refill can suspend the critical section and let another call + // advance the state. Recompute instead of committing a stale counter. + } while (last_timestamp != state->last_timestamp_v7 || + last_counter != state->last_counter_v7 || + last_timestamp_init != state->last_timestamp_v7_init); + + timestamp_ms &= 0xFFFFFFFFFFFF; + bytes[0] = (uint8_t)(timestamp_ms >> 40); + bytes[1] = (uint8_t)(timestamp_ms >> 32); + bytes[2] = (uint8_t)(timestamp_ms >> 24); + bytes[3] = (uint8_t)(timestamp_ms >> 16); + bytes[4] = (uint8_t)(timestamp_ms >> 8); + bytes[5] = (uint8_t)timestamp_ms; + + uint16_t counter_hi = (uint16_t)((counter >> 30) & 0x0FFF); + bytes[6] = (uint8_t)(0x70 | (counter_hi >> 8)); // Version 7 = 0111 + bytes[7] = (uint8_t)counter_hi; + + uint16_t counter_mid = (uint16_t)((counter >> 16) & 0x3FFF); + bytes[8] = (uint8_t)(0x80 | (counter_mid >> 8)); // Variant = 10 + bytes[9] = (uint8_t)counter_mid; + + uint16_t counter_lo = (uint16_t)(counter & 0xFFFF); + bytes[10] = (uint8_t)(counter_lo >> 8); + bytes[11] = (uint8_t)counter_lo; + + state->last_timestamp_v7_init = 1; + state->last_timestamp_v7 = timestamp_ms; + state->last_counter_v7 = counter; + + return uuid_from_bytes_array(state->uuid_type, bytes); +} + +/*[clinic input] +@critical_section +_uuid._install_c_hooks + + * + random_func: object + time_func: object + +[clinic start generated code]*/ + +static PyObject * +_uuid__install_c_hooks_impl(PyObject *module, PyObject *random_func, + PyObject *time_func) +/*[clinic end generated code: output=884aa6e91b2ea832 input=6c5017297067e2ea]*/ +{ + uuid_state *state = get_uuid_state(module); + + // Reset bufferred entropy -- tests need to always start fresh + // when the random function is changed. Reset last_timestamp_v7 -- + // important for repeatable tests + state->random_idx = RANDOM_BUF_SIZE; + state->last_timestamp_v7_init = 0; + + if (random_func == Py_None) { + Py_CLEAR(state->random_func); + } + else { + Py_XSETREF(state->random_func, Py_NewRef(random_func)); + } + + if (time_func == Py_None) { + Py_CLEAR(state->time_func); + } + else { + Py_XSETREF(state->time_func, Py_NewRef(time_func)); + } + + Py_RETURN_NONE; +} + +/*[clinic input] +_uuid.UUID.__init__ + + hex: object = None + bytes: object = None + bytes_le: object = None + fields: object = None + int: object = None + version: object = None + * + is_safe: object = NULL + +UUID is a fast base implementation type for uuid.UUID. +[clinic start generated code]*/ + +static int +_uuid_UUID___init___impl(uuidobject *self, PyObject *hex, PyObject *bytes, + PyObject *bytes_le, PyObject *fields, + PyObject *int_value, PyObject *version, + PyObject *is_safe) +/*[clinic end generated code: output=6d100803f5ecd751 input=23c754454cc11724]*/ + +{ + // Explicit None values do not select a UUID input form. + int passed = 0; + if (hex != Py_None) passed++; + if (bytes != Py_None) passed++; + if (bytes_le != Py_None) passed++; + if (fields != Py_None) passed++; + if (int_value != Py_None) passed++; + if (passed != 1) { + PyErr_SetString( + PyExc_TypeError, + "one of the hex, bytes, bytes_le, fields, or int arguments must be given" + ); + return -1; + } + + if (hex != Py_None) { + if (from_hex(self, hex) < 0) { + return -1; + } + } + else if (bytes != Py_None) { + if (!PyBytes_Check(bytes)) { + PyErr_SetString(PyExc_TypeError, "bytes must be a bytes object"); + return -1; + } + if (PyBytes_GET_SIZE(bytes) != UUID_SIZE) { + PyErr_SetString( + PyExc_ValueError, + "bytes is not a 16-char string" + ); + return -1; + } + memcpy(self->bytes, PyBytes_AS_STRING(bytes), sizeof(self->bytes)); + } + else if (bytes_le != Py_None) { + if (from_bytes_le(self, bytes_le) < 0) { + return -1; + } + } + else if (fields != Py_None) { + if (from_fields(self, fields) < 0) { + return -1; + } + } + else if (int_value != Py_None) { + if (from_int(self, int_value, 1) < 0) { + return -1; + } + } + else { + Py_UNREACHABLE(); + } + + if (version != Py_None) { + long version_num = PyLong_AsLong(version); + if (version_num == -1 && PyErr_Occurred()) { + return -1; + } + if (version_num < 1 || version_num > 8) { + PyErr_SetString(PyExc_ValueError, "illegal version number"); + return -1; + } + + // Clear variant bits (keep only lower 6 bits of byte 8) + self->bytes[8] &= 0x3f; // 0011 1111 + // Clear version bits (keep only lower 4 bits of byte 6) + self->bytes[6] &= 0x0f; // 0000 1111 + // Set the variant to RFC 4122/9562 (binary 10xx xxxx) + self->bytes[8] |= 0x80; // 1000 0000 + // Set the version number (upper 4 bits of byte 6) + self->bytes[6] |= (uint8_t)(version_num << 4); + } + + Py_XSETREF(self->is_safe, Py_XNewRef(is_safe)); + + return 0; +} + + +static const uint8_t INT_TO_HEX[] = "0123456789abcdef"; + +// Lookup table for hex character to value conversion +// -1 for invalid characters +static const int8_t HEX_TO_INT[256] = { + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1, 0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 +}; + +static inline void +byte_to_hex(uint8_t byte, char *hex) +{ + hex[0] = INT_TO_HEX[(byte >> 4) & 0xf]; + hex[1] = INT_TO_HEX[byte & 0xf]; +} + +static int +from_hex(uuidobject *self, PyObject *hex) +{ + Py_ssize_t size; + const char *start = PyUnicode_AsUTF8AndSize(hex, &size); + if (start == NULL) { + return -1; + } + + uint8_t ch; + uint8_t acc, acc_set; + int8_t part; + int i, j; + + // Reimplement `hex = hex.replace('urn:', '').replace('uuid:', '')` + if (size > 0 && start[0] == 'u') { + if (size >= 9 && (strncmp(start, "urn:uuid:", 9) == 0 || + strncmp(start, "uuid:urn:", 9) == 0)) { + start += 9; + size -= 9; + } + else if (size >= 4 && strncmp(start, "urn:", 4) == 0) { + start += 4; + size -= 4; + } + else if (size >= 5 && strncmp(start, "uuid:", 5) == 0) { + start += 5; + size -= 5; + } + } + + // Reimplement `hex = hex.strip('{}')` + while (size >= 1 && (start[0] == '{' || start[0] == '}')) { + start++; + size -= 1; + } + while (size >= 1 && (start[size - 1] == '{' || start[size - 1] == '}')) { + size -= 1; + } + + if (size < 32) { + PyErr_SetString( + PyExc_ValueError, + "badly formed hexadecimal UUID string" + ); + return -1; + } + + acc_set = 0; + j = 0; + + for (i = 0; i < size; i++) { + ch = (uint8_t)start[i]; + + if (ch == '-') { + continue; + } + + part = HEX_TO_INT[ch]; + if (part == -1) { + PyErr_SetString( + PyExc_ValueError, + "badly formed hexadecimal UUID string" + ); + return -1; + } + + if (acc_set) { + acc |= (uint8_t)part; + self->bytes[j] = acc; + acc_set = 0; + j++; + } + else { + acc = (uint8_t)(part << 4); + acc_set = 1; + } + + if (j > UUID_SIZE || (j == UUID_SIZE && acc_set)) { + PyErr_Format(PyExc_ValueError, + "invalid UUID '%s': decodes to more than 16 bytes", + hex); + return -1; + } + } + + if (j != UUID_SIZE) { + PyErr_Format(PyExc_ValueError, + "invalid UUID '%s': decodes to less than 16 bytes", + hex); + return -1; + } + + return 0; +} + +static int +from_bytes_le(uuidobject *self, PyObject *bytes_le) +{ + if (!PyBytes_Check(bytes_le)) { + PyErr_SetString(PyExc_TypeError, "bytes_le must be a bytes object"); + return -1; + } + if (PyBytes_GET_SIZE(bytes_le) != UUID_SIZE) { + PyErr_SetString(PyExc_ValueError, + "bytes_le is not a 16-char string"); + return -1; + } + + // Convert from little-endian to big-endian UUID format + // UUID fields in little-endian order need to be byte-swapped: + // - time_low (4 bytes) + // - time_mid (2 bytes) + // - time_hi_version (2 bytes) + // - clock_seq_hi_variant (1 byte) - no swap needed + // - clock_seq_low (1 byte) - no swap needed + // - node (6 bytes) - no swap needed + + const unsigned char *src = (const unsigned char *)PyBytes_AS_STRING(bytes_le); + unsigned char *dst = (unsigned char *)self->bytes; + + // Swap time_low (bytes 0-3) + dst[0] = src[3]; + dst[1] = src[2]; + dst[2] = src[1]; + dst[3] = src[0]; + + // Swap time_mid (bytes 4-5) + dst[4] = src[5]; + dst[5] = src[4]; + + // Swap time_hi_version (bytes 6-7) + dst[6] = src[7]; + dst[7] = src[6]; + + // Copy clock_seq and node as-is (bytes 8-15) + memcpy(dst + 8, src + 8, 8); + + return 0; +} + +static int +validate_int(uuid_state *state, PyObject *int_value) +{ + if (!PyLong_Check(int_value)) { + PyErr_SetString(PyExc_TypeError, "value must be an integer"); + return -1; + } + + int cmp = PyLong_IsNegative(int_value); + if (cmp < 0) { + return -1; + } + if (cmp == 1) { + PyErr_SetString(PyExc_ValueError, + "int is out of range (need a 128-bit value)"); + return -1; + } + + // Check if it's greater than max (2^128 - 1) + cmp = PyObject_RichCompareBool(int_value, state->uint128_max, Py_GT); + if (cmp < 0) { + return -1; + } + if (cmp == 1) { + PyErr_SetString(PyExc_ValueError, + "int is out of range (need a 128-bit value)"); + return -1; + } + + return 0; +} + +static int +from_int(uuidobject *self, PyObject *int_value, int validate) +{ + // Convert a 128-bit integer to UUID bytes (big-endian) + + uuid_state *state = get_uuid_state_by_cls(Py_TYPE(self)); + + if (validate && validate_int(state, int_value) < 0) { + return -1; + } + + return _PyLong_AsByteArray( + (PyLongObject *)int_value, + (unsigned char *)self->bytes, + sizeof(self->bytes), + 0, // big-endian + 0, // unsigned + 1 // with_exceptions + ); +} + +static int +extract_field( + PyObject *fields, + int field_num, + uint64_t max_value, + const char *error_msg, + uint64_t *result +) { + PyObject *field = PySequence_GetItem(fields, field_num); + if (field == NULL) { + return -1; + } + + if (!PyLong_Check(field)) { + PyErr_Format(PyExc_TypeError, "field %d must be an integer", field_num); + goto fail; + } + + uint64_t value; + if (PyLong_AsUInt64(field, &value) < 0) { + goto fail; + } + + if (value > max_value) { + PyErr_SetString(PyExc_ValueError, error_msg); + goto fail; + } + + *result = value; + Py_DECREF(field); + return 0; + +fail: + Py_DECREF(field); + return -1; +} + +static int +from_fields(uuidobject *self, PyObject *fields) +{ + // Validate the length without replacing errors raised by __len__. + Py_ssize_t len = PySequence_Size(fields); + if (len < 0) { + return -1; + } + if (len != 6) { + PyErr_SetString(PyExc_ValueError, "fields is not a 6-tuple"); + return -1; + } + +#define EXTRACT_FIELD(FIELD_NUM, MAX_VALUE, ERROR_MSG, TYPE, NAME) \ + TYPE NAME; \ + do { \ + uint64_t NAME##_extracted; \ + if (extract_field(fields, FIELD_NUM, MAX_VALUE, ERROR_MSG, \ + &NAME##_extracted) < 0) \ + { \ + return -1; \ + } \ + NAME = (TYPE)NAME##_extracted; \ } while (0) - assert(sizeof(uuid_t) == 16); -#if defined(MS_WINDOWS) - ADD_INT("has_uuid_generate_time_safe", 0); -#elif defined(HAVE_UUID_GENERATE_TIME_SAFE) - ADD_INT("has_uuid_generate_time_safe", 1); -#else - ADD_INT("has_uuid_generate_time_safe", 0); -#endif + EXTRACT_FIELD( + 0, (1ULL << 32) - 1, "field 1 out of range (need a 32-bit value)", + uint32_t, time_low + ); + EXTRACT_FIELD( + 1, (1ULL << 16) - 1, "field 2 out of range (need a 16-bit value)", + uint16_t, time_mid + ); + EXTRACT_FIELD( + 2, (1ULL << 16) - 1, "field 3 out of range (need a 16-bit value)", + uint16_t, time_hi_version + ); + EXTRACT_FIELD( + 3, (1ULL << 8) - 1, "field 4 out of range (need an 8-bit value)", + uint8_t, clock_seq_hi_variant + ); + EXTRACT_FIELD( + 4, (1ULL << 8) - 1, "field 5 out of range (need an 8-bit value)", + uint8_t, clock_seq_low + ); + EXTRACT_FIELD( + 5, (1ULL << 48) - 1, "field 6 out of range (need a 48-bit value)", + uint64_t, node + ); -#if defined(MS_WINDOWS) - ADD_INT("has_stable_extractable_node", py_windows_has_stable_node()); -#elif defined(HAVE_UUID_GENERATE_TIME_SAFE_STABLE_MAC) - ADD_INT("has_stable_extractable_node", 1); -#else - ADD_INT("has_stable_extractable_node", 0); -#endif +#undef EXTRACT_FIELD + + self->bytes[0] = (uint8_t)(time_low >> 24); + self->bytes[1] = (uint8_t)(time_low >> 16); + self->bytes[2] = (uint8_t)(time_low >> 8); + self->bytes[3] = (uint8_t)time_low; + + self->bytes[4] = (uint8_t)(time_mid >> 8); + self->bytes[5] = (uint8_t)time_mid; + + self->bytes[6] = (uint8_t)(time_hi_version >> 8); + self->bytes[7] = (uint8_t)time_hi_version; + + self->bytes[8] = clock_seq_hi_variant; + + self->bytes[9] = clock_seq_low; + + self->bytes[10] = (uint8_t)(node >> 40); + self->bytes[11] = (uint8_t)(node >> 32); + self->bytes[12] = (uint8_t)(node >> 24); + self->bytes[13] = (uint8_t)(node >> 16); + self->bytes[14] = (uint8_t)(node >> 8); + self->bytes[15] = (uint8_t)node; + + return 0; +} + +static PyObject * +get_int(uuidobject *self) +{ + return _PyLong_FromByteArray( + (unsigned char *)self->bytes, sizeof(self->bytes), 0, 0); +} + +static PyObject * +get_uuidmod_attr(const char *name) +{ + return PyImport_ImportModuleAttrString("uuid", name); +} + +static PyObject * +get_SafeUUID(uuid_state *state) +{ + if (state->safe_uuid != NULL) { + return Py_NewRef(state->safe_uuid); + } + + state->safe_uuid = get_uuidmod_attr("SafeUUID"); + return Py_XNewRef(state->safe_uuid); +} + +static uuidobject * +make_uuid(PyTypeObject *type) +{ + uuidobject *self = NULL; + uuid_state *state = get_uuid_state_by_cls(type); + + if (type != state->uuid_type) { + // Allocate the subclass's full instance size and enable GC tracking. + self = uuidobject_CAST(PyType_GenericAlloc(type, 0)); + if (self == NULL) { + return NULL; + } + goto init; + } + + Py_BEGIN_CRITICAL_SECTION(type); + if (state->freelist_size > 0) { + self = state->freelist; + state->freelist = uuidobject_CAST(self->weakreflist); + state->freelist_size--; + } + Py_END_CRITICAL_SECTION(); + + if (self != NULL) { + // Deallocation releases the type reference even when caching the object, + // so the freelist does not keep the type and its module alive. Restore + // that reference and reinitialize the object before returning it. + PyObject_Init((PyObject *)self, type); + } + else { + self = PyObject_New(uuidobject, type); + if (self == NULL) { + return NULL; + } + } + +init: + self->is_safe = NULL; + + self->weakreflist = NULL; + self->cached_hash = -1; + + return self; +} + +static PyObject * +Uuid_alloc(PyTypeObject *type, Py_ssize_t Py_UNUSED(nitems)) +{ + uuidobject *self = make_uuid(type); + if (self == NULL) { + return NULL; + } + memset(self->bytes, 0, sizeof(self->bytes)); + return (PyObject *)self; +} + +static void +Uuid_dealloc(PyObject *obj) +{ + PyTypeObject *type = Py_TYPE(obj); + + uuidobject *uuid = uuidobject_CAST(obj); + if (uuid->weakreflist != NULL) { + PyObject_ClearWeakRefs(obj); + } + Py_CLEAR(uuid->is_safe); + + int skip_dealloc = 0; + // Only the base UUID type uses the freelist. Do not search a subclass's + // MRO: GC may already have cleared its base type's module reference. + PyObject *module = PyType_GetModule_DuringGC(type); + if (module == NULL) { + goto dealloc; + } + assert(PyModule_Check(module)); + if (PyModule_GetDef(module) != &uuidmodule) { + goto dealloc; + } + uuid_state *state = get_uuid_state(module); + if (type != state->uuid_type) { + goto dealloc; + } + + Py_BEGIN_CRITICAL_SECTION(type); + if (state->freelist_size < MAX_FREE_LIST_SIZE) { + uuidobject *head = state->freelist; + state->freelist = uuid; + uuid->weakreflist = (PyObject *)head; + state->freelist_size++; + skip_dealloc = 1; + } + Py_END_CRITICAL_SECTION(); + +dealloc: + if (!skip_dealloc) { + type->tp_free(uuid); + } + // Only live instances own a reference to the heap type. Keeping that + // reference in the freelist would prevent the module from being collected. + Py_DECREF(type); +} + + +static PyObject * +Uuid_get_int(PyObject *op, void *Py_UNUSED(closure)) +{ + return get_int(uuidobject_CAST(op)); +} + +static PyObject * +Uuid_get_is_safe(PyObject *op, void *Py_UNUSED(closure)) +{ + uuidobject *self = uuidobject_CAST(op); + uuid_state *state = get_uuid_state_by_cls(Py_TYPE(self)); + if (self->is_safe == NULL) { + PyObject *SafeUUID = get_SafeUUID(state); + if (SafeUUID == NULL) { + return NULL; + } + PyObject *ret = PyObject_GetAttrString(SafeUUID, "unknown"); + Py_DECREF(SafeUUID); + return ret; + } + return Py_NewRef(self->is_safe); +} + +static PyObject * +Uuid_get_hex(PyObject *op, void *Py_UNUSED(closure)) +{ + uuidobject *self = uuidobject_CAST(op); + return _Py_strhex((const char *)self->bytes, sizeof(self->bytes)); +} + +static PyObject * +Uuid_get_variant(PyObject *op, void *Py_UNUSED(closure)) +{ + uuidobject *self = uuidobject_CAST(op); + uint8_t variant_byte = self->bytes[8]; + + // xxx - three high bits of variant_byte are unknown + if (!(variant_byte & 0x80)) { // & 0b1000_0000 + // 0xx - RESERVED_NCS + return get_uuidmod_attr("RESERVED_NCS"); + } + + // 1xx -- we know that high bit must be 1 + if (!(variant_byte & 0x40)) { // & 0b0100_0000 + // 10x - RFC_4122 + return get_uuidmod_attr("RFC_4122"); + } + + // 11x -- we know that two high bits are 1 + if (!(variant_byte & 0x20)) { // & 0b0010_0000 + // 110 - RESERVED_MICROSOFT + return get_uuidmod_attr("RESERVED_MICROSOFT"); + } + + // 111 -- we know that all three high bits are 1 - RESERVED_FUTURE + return get_uuidmod_attr("RESERVED_FUTURE"); +} + +static int +is_rfc_4122(uuidobject *self) +{ + return (self->bytes[8] & 0xc0) == 0x80; +} + +static long +get_version(uuidobject *self) +{ + // RFC_4122 is when bit 7 is set (0x80) and bit 6 is not set (0x40) + // 0xc0 = 0b11000000 + // 0x80 = 0b10000000 + if (!is_rfc_4122(self)) { + return 0; + } + return (self->bytes[6] >> 4) & 0xf; +} + +static PyObject * +Uuid_get_version(PyObject *op, void *Py_UNUSED(closure)) +{ + uuidobject *self = uuidobject_CAST(op); + if (!is_rfc_4122(self)) { + Py_RETURN_NONE; + } + return PyLong_FromLong(get_version(self)); +} + +static inline uint32_t +get_time_low(uuidobject *self) +{ + return ((uint32_t)self->bytes[0] << 24) | + ((uint32_t)self->bytes[1] << 16) | + ((uint32_t)self->bytes[2] << 8) | + ((uint32_t)self->bytes[3]); +} + +static inline uint16_t +get_time_mid(uuidobject *self) +{ + return (uint16_t)((self->bytes[4] << 8) | self->bytes[5]); +} + +static inline uint16_t +get_time_hi_version(uuidobject *self) +{ + return (uint16_t)((self->bytes[6] << 8) | self->bytes[7]); +} + +static inline uint8_t +get_clock_seq_hi_variant(uuidobject *self) +{ + return self->bytes[8]; +} + +static inline uint8_t +get_clock_seq_low(uuidobject *self) +{ + return self->bytes[9]; +} + +static inline uint64_t +get_node(uuidobject *self) +{ + return ((uint64_t)self->bytes[10] << 40) | + ((uint64_t)self->bytes[11] << 32) | + ((uint64_t)self->bytes[12] << 24) | + ((uint64_t)self->bytes[13] << 16) | + ((uint64_t)self->bytes[14] << 8) | + ((uint64_t)self->bytes[15]); +} + +static PyObject * +Uuid_get_time_low(PyObject *op, void *Py_UNUSED(closure)) +{ + uuidobject *self = uuidobject_CAST(op); + return PyLong_FromUnsignedLong(get_time_low(self)); +} + +static PyObject * +Uuid_get_time_mid(PyObject *op, void *Py_UNUSED(closure)) +{ + uuidobject *self = uuidobject_CAST(op); + return PyLong_FromUnsignedLong(get_time_mid(self)); +} + +static PyObject * +Uuid_get_time_hi_version(PyObject *op, void *Py_UNUSED(closure)) +{ + uuidobject *self = uuidobject_CAST(op); + return PyLong_FromUnsignedLong(get_time_hi_version(self)); +} + +static PyObject * +Uuid_get_clock_seq_hi_variant(PyObject *op, void *Py_UNUSED(closure)) +{ + uuidobject *self = uuidobject_CAST(op); + return PyLong_FromUnsignedLong(get_clock_seq_hi_variant(self)); +} + +static PyObject * +Uuid_get_clock_seq_low(PyObject *op, void *Py_UNUSED(closure)) +{ + uuidobject *self = uuidobject_CAST(op); + return PyLong_FromUnsignedLong(get_clock_seq_low(self)); +} + +static PyObject * +Uuid_get_time(PyObject *op, void *Py_UNUSED(closure)) +{ + uuidobject *self = uuidobject_CAST(op); + + long version = get_version(self); + + if (version == 6) { + // UUID v6: time_hi (32) | time_mid (16) | ver (4) | time_lo (12) | ... (64) + uint32_t time_hi = get_time_low(self); + uint16_t time_mid = get_time_mid(self); + uint16_t time_lo = (uint16_t)(((self->bytes[6] & 0x0f) << 8) | + self->bytes[7]); + + uint64_t time = ((uint64_t)time_hi << 28) | + ((uint64_t)time_mid << 12) | + (uint64_t)time_lo; + return PyLong_FromUnsignedLongLong(time); + } + else if (version == 7) { + // UUID v7: unix_ts_ms (48) | ... (80) + // First 6 bytes are the 48-bit timestamp + uint64_t unix_ts_ms = ((uint64_t)self->bytes[0] << 40) | + ((uint64_t)self->bytes[1] << 32) | + ((uint64_t)self->bytes[2] << 24) | + ((uint64_t)self->bytes[3] << 16) | + ((uint64_t)self->bytes[4] << 8) | + ((uint64_t)self->bytes[5]); + return PyLong_FromUnsignedLongLong(unix_ts_ms); + } + else { + // UUID v1 and others: time_lo (32) | time_mid (16) | ver (4) + // | time_hi (12) | ... (64) + uint32_t time_lo = get_time_low(self); + uint16_t time_mid = get_time_mid(self); + uint16_t time_hi = (uint16_t)(((self->bytes[6] & 0x0f) << 8) | + self->bytes[7]); + + uint64_t time = ((uint64_t)time_hi << 48) | + ((uint64_t)time_mid << 32) | + (uint64_t)time_lo; + return PyLong_FromUnsignedLongLong(time); + } +} + +static PyObject * +Uuid_get_clock_seq(PyObject *op, void *Py_UNUSED(closure)) +{ + uuidobject *self = uuidobject_CAST(op); + // clock_seq_hi_variant (byte 8) & 0x3f, then clock_seq_low (byte 9) + uint16_t clock_seq = (uint16_t)(((get_clock_seq_hi_variant(self) & 0x3f) << 8) | + get_clock_seq_low(self)); + return PyLong_FromUnsignedLong(clock_seq); +} + +static PyObject * +Uuid_get_node(PyObject *op, void *Py_UNUSED(closure)) +{ + uuidobject *self = uuidobject_CAST(op); + return PyLong_FromUnsignedLongLong(get_node(self)); +} + +static PyObject * +Uuid_get_bytes(PyObject *op, void *Py_UNUSED(closure)) +{ + uuidobject *self = uuidobject_CAST(op); + return PyBytes_FromStringAndSize((const char *)self->bytes, sizeof(self->bytes)); +} + +static PyObject * +Uuid_get_bytes_le(PyObject *op, void *Py_UNUSED(closure)) +{ + uuidobject *self = uuidobject_CAST(op); + // UUID fields in little-endian order need to be byte-swapped: + // - time_low (4 bytes) - reversed + // - time_mid (2 bytes) - reversed + // - time_hi_version (2 bytes) - reversed + // - clock_seq and node (8 bytes) - unchanged + + unsigned char bytes_le[UUID_SIZE]; + + // Reverse time_low (bytes 0-3) + bytes_le[0] = self->bytes[3]; + bytes_le[1] = self->bytes[2]; + bytes_le[2] = self->bytes[1]; + bytes_le[3] = self->bytes[0]; + + // Reverse time_mid (bytes 4-5) + bytes_le[4] = self->bytes[5]; + bytes_le[5] = self->bytes[4]; + + // Reverse time_hi_version (bytes 6-7) + bytes_le[6] = self->bytes[7]; + bytes_le[7] = self->bytes[6]; + + // Copy clock_seq and node as-is (bytes 8-15) + memcpy(bytes_le + 8, self->bytes + 8, 8); + + return PyBytes_FromStringAndSize((const char *)bytes_le, sizeof(bytes_le)); +} + +static PyObject * +Uuid_get_fields(PyObject *op, void *Py_UNUSED(closure)) +{ + uuidobject *self = uuidobject_CAST(op); + uint32_t time_low = get_time_low(self); + uint16_t time_mid = get_time_mid(self); + uint16_t time_hi_version = get_time_hi_version(self); + uint8_t clock_seq_hi_variant = get_clock_seq_hi_variant(self); + uint8_t clock_seq_low = get_clock_seq_low(self); + uint64_t node = get_node(self); + + // Build and return the tuple + return Py_BuildValue( + "(kHHBBK)", + (unsigned long)time_low, + (unsigned short)time_mid, + (unsigned short)time_hi_version, + (unsigned char)clock_seq_hi_variant, + (unsigned char)clock_seq_low, + (unsigned long long)node + ); +} + +static PyObject * +uuid_from_bytes_array(PyTypeObject *type, uint8_t bytes[UUID_SIZE]) +{ + uuidobject *self = make_uuid(type); + if (self == NULL) { + return NULL; + } + memcpy(self->bytes, bytes, sizeof(self->bytes)); + return (PyObject *)self; +} + +static PyObject * +Uuid_nb_int(PyObject *self) +{ + return get_int(uuidobject_CAST(self)); +} + +static PyObject * +Uuid_richcompare(PyObject *self, PyObject *other, int op) +{ + uuid_state *state = get_uuid_state_by_cls(Py_TYPE(self)); + + if (!PyObject_TypeCheck(other, state->uuid_type)) { + Py_RETURN_NOTIMPLEMENTED; + } + + uuidobject *uuid_self = uuidobject_CAST(self); + uuidobject *uuid_other = uuidobject_CAST(other); + + int cmp = memcmp(uuid_self->bytes, uuid_other->bytes, sizeof(uuid_self->bytes)); + + int result; + switch (op) { + case Py_EQ: + result = (cmp == 0); + break; + case Py_NE: + result = (cmp != 0); + break; + case Py_LT: + result = (cmp < 0); + break; + case Py_LE: + result = (cmp <= 0); + break; + case Py_GT: + result = (cmp > 0); + break; + case Py_GE: + result = (cmp >= 0); + break; + default: + Py_RETURN_NOTIMPLEMENTED; + } + + if (result) { + Py_RETURN_TRUE; + } + else { + Py_RETURN_FALSE; + } +} + +static PyObject * +Uuid_str(PyObject *self) +{ + uuidobject *uuid = uuidobject_CAST(self); + + // UUID string format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (36 chars) + PyObject *result = PyUnicode_New(36, 127); + if (result == NULL) { + return NULL; + } + char *str = (char *)PyUnicode_1BYTE_DATA(result); + + for (int i = 0; i < 4; i++) { + byte_to_hex(uuid->bytes[i], &str[i * 2]); + } + str[8] = '-'; + + for (int i = 4; i < 6; i++) { + byte_to_hex(uuid->bytes[i], &str[9 + (i - 4) * 2]); + } + str[13] = '-'; + + for (int i = 6; i < 8; i++) { + byte_to_hex(uuid->bytes[i], &str[14 + (i - 6) * 2]); + } + str[18] = '-'; + + for (int i = 8; i < 10; i++) { + byte_to_hex(uuid->bytes[i], &str[19 + (i - 8) * 2]); + } + str[23] = '-'; + + for (int i = 10; i < UUID_SIZE; i++) { + byte_to_hex(uuid->bytes[i], &str[24 + (i - 10) * 2]); + } + + return result; +} + +static PyObject * +Uuid_repr(PyObject *self) +{ + // Get the class name (sadly can't use tp_name -- we don't need the full name) + PyObject *cls_name = PyObject_GetAttrString((PyObject *)Py_TYPE(self), "__name__"); + if (cls_name == NULL) { + return NULL; + } + + PyObject *repr = PyUnicode_FromFormat("%U('%S')", cls_name, self); + Py_DECREF(cls_name); + return repr; +} + +static int +Uuid_setattr(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(name), + PyObject *Py_UNUSED(value)) +{ + PyErr_SetString(PyExc_TypeError, "UUID objects are immutable"); + return -1; +} + +static PyObject * +Uuid_get_urn(PyObject *op, void *Py_UNUSED(closure)) +{ + PyObject *str_obj = Uuid_str(op); + if (str_obj == NULL) { + return NULL; + } + + PyObject *urn = PyUnicode_FromFormat("urn:uuid:%U", str_obj); + Py_DECREF(str_obj); + return urn; +} + +static Py_hash_t +Uuid_hash(PyObject *op) +{ + uuidobject *uuid = uuidobject_CAST(op); + // UUIDs are very often used in dicts/sets, so it makes + // sense to cache the computed hash (like we do for str). + if (uuid->cached_hash == -1) { + uuid->cached_hash = Py_HashBuffer(uuid->bytes, sizeof(uuid->bytes)); + } + return uuid->cached_hash; +} + + +/*[clinic input] +@classmethod +_uuid.UUID._from_int + + value: object + / + +Create a UUID from an integer value. Internal use only. +[clinic start generated code]*/ + +static PyObject * +_uuid_UUID__from_int_impl(PyTypeObject *type, PyObject *value) +/*[clinic end generated code: output=05af0cfa4805fcae input=3f472ebfd07bbf50]*/ +{ + uuid_state *state = get_uuid_state_by_cls(type); + + if (validate_int(state, value) < 0) { + return NULL; + } + + uuidobject *self = make_uuid(type); + if (self == NULL) { + return NULL; + } + + if (from_int(self, value, 0) < 0) { + // We validated before creating an instance, so now we don't need to + // validate again + return NULL; + } + + return (PyObject *)self; +} + +static PyGetSetDef Uuid_getset[] = { + {"int", Uuid_get_int, NULL, "UUID as a 128-bit integer", NULL}, + {"is_safe", Uuid_get_is_safe, NULL, "UUID safety status", NULL}, + {"fields", Uuid_get_fields, NULL, "UUID as a 6-tuple", NULL}, + {"hex", Uuid_get_hex, NULL, "UUID as a 32-character hex string", NULL}, + {"urn", Uuid_get_urn, NULL, "UUID as a URN", NULL}, + {"variant", Uuid_get_variant, NULL, "UUID variant", NULL}, + {"version", Uuid_get_version, NULL, "UUID version", NULL}, + {"time_low", Uuid_get_time_low, NULL, "Time low field (32 bits)", NULL}, + {"time_mid", Uuid_get_time_mid, NULL, "Time mid field (16 bits)", NULL}, + {"bytes", Uuid_get_bytes, NULL, "UUID as a 16-byte string", NULL}, + {"bytes_le", Uuid_get_bytes_le, NULL, + "UUID as a 16-byte string in little-endian byte order", NULL}, + {"time_hi_version", Uuid_get_time_hi_version, NULL, + "Time high and version field (16 bits)", NULL}, + {"clock_seq_hi_variant", Uuid_get_clock_seq_hi_variant, NULL, + "Clock sequence high and variant field (8 bits)", NULL}, + {"clock_seq_low", Uuid_get_clock_seq_low, NULL, + "Clock sequence low field (8 bits)", NULL}, + {"time", Uuid_get_time, NULL, + "Time field (60 bits for v1/v6, 48 bits for v7)", NULL}, + {"clock_seq", Uuid_get_clock_seq, NULL, "Clock sequence field (14 bits)", NULL}, + {"node", Uuid_get_node, NULL, "Node field (48 bits)", NULL}, + {NULL} +}; + +/*[clinic input] +_uuid.UUID.__getstate__ + +Return the UUID's state for pickling. +[clinic start generated code]*/ + +static PyObject * +_uuid_UUID___getstate___impl(uuidobject *self) +/*[clinic end generated code: output=f9278a4d28ccac91 input=4b471ae24b705e8e]*/ +{ + PyObject *dict = PyDict_New(); + if (dict == NULL) { + return NULL; + } + + // Always add 'int' key + PyObject *int_value = get_int(self); + if (int_value == NULL) { + Py_DECREF(dict); + return NULL; + } + if (PyDict_SetItem(dict, &_Py_ID(int), int_value) < 0) { + Py_DECREF(int_value); + Py_DECREF(dict); + return NULL; + } + Py_DECREF(int_value); + + if (PyDict_SetItem(dict, &_Py_ID(is_safe), self->is_safe) < 0) { + Py_DECREF(dict); + return NULL; + } + + return dict; +} + +/*[clinic input] +_uuid.UUID.__setstate__ + + state: object + / + +Restore the UUID's state from pickling. + +Expects a mapping with 'int' and optionally 'is_safe' keys. +[clinic start generated code]*/ + +static PyObject * +_uuid_UUID___setstate___impl(uuidobject *self, PyObject *state) +/*[clinic end generated code: output=cdf6bd4a2a680b3f input=fc65bdad0a8d6211]*/ +{ + // Get and set the 'int' value + PyObject *int_value = PyObject_GetItem(state, &_Py_ID(int)); + if (int_value == NULL) { + return NULL; + } + + int result = from_int(self, int_value, 1); + Py_DECREF(int_value); + if (result < 0) { + return NULL; + } + + int has_is_safe = PySequence_Contains(state, &_Py_ID(is_safe)); + if (has_is_safe < 0) { + return NULL; + } + PyObject *is_safe = has_is_safe + ? PyObject_GetItem(state, &_Py_ID(is_safe)) + : Py_NewRef(Py_None); + if (is_safe == NULL) { + return NULL; + } + + uuid_state *module_state = get_uuid_state_by_cls(Py_TYPE(self)); + PyObject *SafeUUID = get_SafeUUID(module_state); + if (SafeUUID == NULL) { + Py_DECREF(is_safe); + return NULL; + } + PyObject *safety = PyObject_CallOneArg(SafeUUID, is_safe); + Py_DECREF(SafeUUID); + Py_DECREF(is_safe); + if (safety == NULL) { + return NULL; + } + Py_XSETREF(self->is_safe, safety); + + Py_RETURN_NONE; +} + +static PyObject * +compute_uuid_max(void) +{ + // Compute `(1 << 128) - 1` + + PyObject *shift = PyLong_FromLong(128); + if (shift == NULL) { + return NULL; + } + + PyObject *shifted = PyNumber_Lshift(_PyLong_GetOne(), shift); + Py_DECREF(shift); + if (shifted == NULL) { + return NULL; + } + + PyObject *result = PyNumber_Subtract(shifted, _PyLong_GetOne()); + Py_DECREF(shifted); + return result; +} + +static PyMethodDef Uuid_methods[] = { + _UUID_UUID__FROM_INT_METHODDEF + _UUID_UUID___GETSTATE___METHODDEF + _UUID_UUID___SETSTATE___METHODDEF + {NULL, NULL} +}; + +static PyMemberDef Uuid_members[] = { + {"__weaklistoffset__", Py_T_PYSSIZET, offsetof(uuidobject, weakreflist), Py_READONLY}, + {NULL} +}; + +static PyType_Slot Uuid_slots[] = { + {Py_tp_alloc, Uuid_alloc}, + {Py_tp_dealloc, Uuid_dealloc}, + {Py_tp_getattro, PyObject_GenericGetAttr}, + {Py_tp_setattro, Uuid_setattr}, + {Py_tp_getset, Uuid_getset}, + {Py_tp_members, Uuid_members}, + {Py_tp_init, _uuid_UUID___init__}, + {Py_tp_doc, (void *)_uuid_UUID___init____doc__}, + {Py_tp_str, Uuid_str}, + {Py_tp_repr, Uuid_repr}, + {Py_tp_hash, Uuid_hash}, + {Py_tp_richcompare, Uuid_richcompare}, + {Py_nb_int, Uuid_nb_int}, + {Py_tp_methods, Uuid_methods}, + {0, NULL}, +}; + + +static PyType_Spec Uuid_spec = { + // We use "uuid.UUID" here and not "_uuid.UUID" to have full + // compatibility with old pickled UUIDs. There's no workaround + // if we want both to produce compatible pickles that can be read + // by older Pythons (using ancient pickle protocol verions) and + // restore from pickles produced by old Python versions. + .name = "uuid.UUID", + + .basicsize = sizeof(uuidobject), + .flags = ( + Py_TPFLAGS_DEFAULT + | Py_TPFLAGS_BASETYPE + | Py_TPFLAGS_HEAPTYPE + | Py_TPFLAGS_IMMUTABLETYPE + ), + .slots = Uuid_slots, +}; + + +static int +module_traverse(PyObject *mod, visitproc visit, void *arg) +{ + uuid_state *state = get_uuid_state(mod); + Py_VISIT(state->uuid_type); + Py_VISIT(state->safe_uuid); + Py_VISIT(state->uint128_max); + Py_VISIT(state->random_func); + Py_VISIT(state->time_func); + Py_VISIT(state->random_size_int); + return 0; +} + +static int +module_clear(PyObject *mod) +{ + uuid_state *state = get_uuid_state(mod); + + Py_CLEAR(state->uuid_type); + Py_CLEAR(state->safe_uuid); + Py_CLEAR(state->uint128_max); + Py_CLEAR(state->random_func); + Py_CLEAR(state->time_func); + Py_CLEAR(state->random_size_int); + + if (state->freelist != NULL) { + while (state->freelist != NULL) { + uuidobject *cur = state->freelist; + state->freelist = uuidobject_CAST(cur->weakreflist); + PyObject_Free(cur); + } + state->freelist = NULL; + state->freelist_size = 0; + } + + return 0; +} + +static void +module_free(void *mod) +{ + (void)module_clear((PyObject *)mod); +} + + +static int +uuid_exec(PyObject *module) +{ + uuid_state *state = get_uuid_state(module); + +#define ADD_INT(NAME, VALUE) \ + do { \ + if (PyModule_AddIntConstant(module, (NAME), (VALUE)) < 0) { \ + return -1; \ + } \ + } while (0) + + assert(sizeof(uuid_t) == UUID_SIZE); +#if defined(MS_WINDOWS) + ADD_INT("has_uuid_generate_time_safe", 0); +#elif defined(HAVE_UUID_GENERATE_TIME_SAFE) + ADD_INT("has_uuid_generate_time_safe", 1); +#else + ADD_INT("has_uuid_generate_time_safe", 0); +#endif + +#if defined(MS_WINDOWS) + ADD_INT("has_stable_extractable_node", py_windows_has_stable_node()); +#elif defined(HAVE_UUID_GENERATE_TIME_SAFE_STABLE_MAC) + ADD_INT("has_stable_extractable_node", 1); +#else + ADD_INT("has_stable_extractable_node", 0); +#endif + +#undef ADD_INT + + state->uuid_type = (PyTypeObject *)PyType_FromModuleAndSpec( + module, + &Uuid_spec, + NULL + ); + if (state->uuid_type == NULL) { + return -1; + } + if (PyModule_AddType(module, state->uuid_type) < 0) { + return -1; + } + + state->safe_uuid = NULL; + + state->uint128_max = compute_uuid_max(); + if (state->uint128_max == NULL) { + return -1; + } + + state->last_timestamp_v7 = 0; + state->last_timestamp_v7_init = 0; + state->last_counter_v7 = 0; + state->random_last_pid = uuid_getpid(); + + state->time_func = NULL; + state->random_func = NULL; + state->random_size_int = PyLong_FromSize_t((Py_ssize_t)RANDOM_BUF_SIZE); + if (state->random_size_int == NULL) { + return -1; + } + state->random_idx = RANDOM_BUF_SIZE; + + state->freelist = NULL; + state->freelist_size = 0; -#undef ADD_INT return 0; } static PyMethodDef uuid_methods[] = { + _UUID_UUID4_METHODDEF + _UUID_UUID7_METHODDEF + _UUID__INSTALL_C_HOOKS_METHODDEF #if defined(HAVE_UUID_UUID_H) || defined(HAVE_UUID_H) {"generate_time_safe", py_uuid_generate_time_safe, METH_NOARGS, NULL}, #endif #if defined(MS_WINDOWS) {"UuidCreate", py_UuidCreate, METH_NOARGS, NULL}, #endif - {NULL, NULL, 0, NULL} /* sentinel */ + {NULL, NULL, 0, NULL} }; static PyModuleDef_Slot uuid_slots[] = { @@ -142,9 +1892,12 @@ static PyModuleDef_Slot uuid_slots[] = { static struct PyModuleDef uuidmodule = { PyModuleDef_HEAD_INIT, .m_name = "_uuid", - .m_size = 0, + .m_size = sizeof(uuid_state), .m_methods = uuid_methods, + .m_traverse = module_traverse, + .m_clear = module_clear, .m_slots = uuid_slots, + .m_free = module_free, }; PyMODINIT_FUNC diff --git a/Modules/_winapi.c b/Modules/_winapi.c index 535784adedb24d8..51e7523b4bf9e29 100644 --- a/Modules/_winapi.c +++ b/Modules/_winapi.c @@ -227,13 +227,10 @@ def create_converter(type_, format_unit): type(name, (CConverter,), {'type': type_, 'format_unit': format_unit}) # format unit differs between platforms for these -create_converter('HANDLE', '" F_HANDLE "') create_converter('HMODULE', '" F_HANDLE "') create_converter('LPSECURITY_ATTRIBUTES', '" F_POINTER "') create_converter('LPCVOID', '" F_POINTER "') -create_converter('BOOL', 'i') # F_BOOL used previously (always 'i') -create_converter('DWORD', 'k') # F_DWORD is always "k" (which is much shorter) create_converter('UINT', 'I') # F_UINT used previously (always 'I') class LPCWSTR_converter(Py_UNICODE_converter): @@ -268,7 +265,7 @@ class LPVOID_return_converter(CReturnConverter): data.return_conversion.append( 'return_value = HANDLE_TO_PYNUM(_return_value);\n') [python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=da0a4db751936ee7]*/ +/*[python end generated code: output=da39a3ee5e6b4b0d input=59b6c67bbb5411d5]*/ #include "clinic/_winapi.c.h" @@ -520,11 +517,11 @@ _winapi_CreateEventW_impl(PyObject *module, _winapi.CreateFile -> HANDLE file_name: LPCWSTR - desired_access: DWORD - share_mode: DWORD + desired_access: DWORD(bitwise=True) + share_mode: DWORD(bitwise=True) security_attributes: LPSECURITY_ATTRIBUTES - creation_disposition: DWORD - flags_and_attributes: DWORD + creation_disposition: DWORD(bitwise=True) + flags_and_attributes: DWORD(bitwise=True) template_file: HANDLE / [clinic start generated code]*/ @@ -535,7 +532,7 @@ _winapi_CreateFile_impl(PyObject *module, LPCWSTR file_name, LPSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD flags_and_attributes, HANDLE template_file) -/*[clinic end generated code: output=818c811e5e04d550 input=1fa870ed1c2e3d69]*/ +/*[clinic end generated code: output=818c811e5e04d550 input=de198846d329724e]*/ { HANDLE handle; @@ -564,9 +561,9 @@ _winapi.CreateFileMapping -> HANDLE file_handle: HANDLE security_attributes: LPSECURITY_ATTRIBUTES - protect: DWORD - max_size_high: DWORD - max_size_low: DWORD + protect: DWORD(bitwise=True) + max_size_high: DWORD(bitwise=True) + max_size_low: DWORD(bitwise=True) name: LPCWSTR / [clinic start generated code]*/ @@ -576,7 +573,7 @@ _winapi_CreateFileMapping_impl(PyObject *module, HANDLE file_handle, LPSECURITY_ATTRIBUTES security_attributes, DWORD protect, DWORD max_size_high, DWORD max_size_low, LPCWSTR name) -/*[clinic end generated code: output=6c0a4d5cf7f6fcc6 input=3dc5cf762a74dee8]*/ +/*[clinic end generated code: output=6c0a4d5cf7f6fcc6 input=06507c1bc186b047]*/ { HANDLE handle; @@ -787,12 +784,12 @@ _winapi_CreateMutexW_impl(PyObject *module, _winapi.CreateNamedPipe -> HANDLE name: LPCWSTR - open_mode: DWORD - pipe_mode: DWORD - max_instances: DWORD - out_buffer_size: DWORD - in_buffer_size: DWORD - default_timeout: DWORD + open_mode: DWORD(bitwise=True) + pipe_mode: DWORD(bitwise=True) + max_instances: DWORD(bitwise=True) + out_buffer_size: DWORD(bitwise=True) + in_buffer_size: DWORD(bitwise=True) + default_timeout: DWORD(bitwise=True) security_attributes: LPSECURITY_ATTRIBUTES / [clinic start generated code]*/ @@ -803,7 +800,7 @@ _winapi_CreateNamedPipe_impl(PyObject *module, LPCWSTR name, DWORD open_mode, DWORD out_buffer_size, DWORD in_buffer_size, DWORD default_timeout, LPSECURITY_ATTRIBUTES security_attributes) -/*[clinic end generated code: output=7d6fde93227680ba input=5bd4e4a55639ee02]*/ +/*[clinic end generated code: output=7d6fde93227680ba input=83dfbf822975724b]*/ { HANDLE handle; @@ -830,7 +827,7 @@ _winapi.CreatePipe pipe_attrs: object Ignored internally, can be None. - size: DWORD + size: DWORD(bitwise=True) / Create an anonymous pipe. @@ -840,7 +837,7 @@ Returns a 2-tuple of handles, to the read and write ends of the pipe. static PyObject * _winapi_CreatePipe_impl(PyObject *module, PyObject *pipe_attrs, DWORD size) -/*[clinic end generated code: output=1c4411d8699f0925 input=c4f2cfa56ef68d90]*/ +/*[clinic end generated code: output=1c4411d8699f0925 input=ccfdf00b218dfe06]*/ { HANDLE read_pipe; HANDLE write_pipe; @@ -1214,6 +1211,7 @@ gethandlelist(PyObject *mapping, const char *name, Py_ssize_t *size) return ret; } +#ifdef MS_WINDOWS_DESKTOP typedef struct { LPPROC_THREAD_ATTRIBUTE_LIST attribute_list; LPHANDLE handle_list; @@ -1325,6 +1323,7 @@ getattributelist(PyObject *obj, const char *name, AttributeList *attribute_list) return ret; } +#endif /*[clinic input] _winapi.CreateProcess @@ -1337,7 +1336,7 @@ _winapi.CreateProcess thread_attrs: object Ignored internally, can be None. inherit_handles: BOOL - creation_flags: DWORD + creation_flags: DWORD(bitwise=True) env_mapping: object current_directory: Py_UNICODE(accept={str, NoneType}) startup_info: object @@ -1356,8 +1355,11 @@ _winapi_CreateProcess_impl(PyObject *module, const wchar_t *application_name, DWORD creation_flags, PyObject *env_mapping, const wchar_t *current_directory, PyObject *startup_info) -/*[clinic end generated code: output=a25c8e49ea1d6427 input=42ac293eaea03fc4]*/ +/*[clinic end generated code: output=a25c8e49ea1d6427 input=84e2175279a3f5c2]*/ { +#ifndef MS_WINDOWS_DESKTOP + return NULL; +#else PyObject *ret = NULL; BOOL result; PROCESS_INFORMATION pi; @@ -1439,6 +1441,7 @@ _winapi_CreateProcess_impl(PyObject *module, const wchar_t *application_name, freeattributelist(&attribute_list); return ret; +#endif } /*[clinic input] @@ -1447,9 +1450,9 @@ _winapi.DuplicateHandle -> HANDLE source_process_handle: HANDLE source_handle: HANDLE target_process_handle: HANDLE - desired_access: DWORD + desired_access: DWORD(bitwise=True) inherit_handle: BOOL - options: DWORD = 0 + options: DWORD(bitwise=True) = 0 / Return a duplicate handle object. @@ -1465,7 +1468,7 @@ _winapi_DuplicateHandle_impl(PyObject *module, HANDLE source_process_handle, HANDLE target_process_handle, DWORD desired_access, BOOL inherit_handle, DWORD options) -/*[clinic end generated code: output=ad9711397b5dcd4e input=b933e3f2356a8c12]*/ +/*[clinic end generated code: output=ad9711397b5dcd4e input=f4965c09aa01993a]*/ { HANDLE target_handle; BOOL result; @@ -1698,7 +1701,7 @@ _winapi_GetShortPathName_impl(PyObject *module, LPCWSTR path) /*[clinic input] _winapi.GetStdHandle -> HANDLE - std_handle: DWORD + std_handle: DWORD(bitwise=True) One of STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, or STD_ERROR_HANDLE. / @@ -1709,7 +1712,7 @@ The integer associated with the handle object is returned. static HANDLE _winapi_GetStdHandle_impl(PyObject *module, DWORD std_handle) -/*[clinic end generated code: output=0e613001e73ab614 input=07016b06a2fc8826]*/ +/*[clinic end generated code: output=0e613001e73ab614 input=377191071925fe8d]*/ { HANDLE handle; @@ -1739,7 +1742,19 @@ _winapi_GetVersion_impl(PyObject *module) #pragma warning(disable:4996) { +#ifdef MS_WINDOWS_DESKTOP return GetVersion(); +#else + OSVERSIONINFOW version_info; + ZeroMemory(&version_info, sizeof(version_info)); + version_info.dwOSVersionInfoSize = sizeof(version_info); + if (GetVersionExW(&version_info)) { + return version_info.dwMinorVersion | + (version_info.dwMajorVersion << 8) | + (version_info.dwBuildNumber << 16); + } + return 0; +#endif } #pragma warning(pop) @@ -1748,9 +1763,9 @@ _winapi_GetVersion_impl(PyObject *module) _winapi.MapViewOfFile -> LPVOID file_map: HANDLE - desired_access: DWORD - file_offset_high: DWORD - file_offset_low: DWORD + desired_access: DWORD(bitwise=True) + file_offset_high: DWORD(bitwise=True) + file_offset_low: DWORD(bitwise=True) number_bytes: size_t / [clinic start generated code]*/ @@ -1759,7 +1774,7 @@ static LPVOID _winapi_MapViewOfFile_impl(PyObject *module, HANDLE file_map, DWORD desired_access, DWORD file_offset_high, DWORD file_offset_low, size_t number_bytes) -/*[clinic end generated code: output=f23b1ee4823663e3 input=177471073be1a103]*/ +/*[clinic end generated code: output=f23b1ee4823663e3 input=cc9e7e33663d3b8e]*/ { LPVOID address; @@ -1801,7 +1816,7 @@ _winapi_UnmapViewOfFile_impl(PyObject *module, LPCVOID address) /*[clinic input] _winapi.OpenEventW -> HANDLE - desired_access: DWORD + desired_access: DWORD(bitwise=True) inherit_handle: BOOL name: LPCWSTR [clinic start generated code]*/ @@ -1809,7 +1824,7 @@ _winapi.OpenEventW -> HANDLE static HANDLE _winapi_OpenEventW_impl(PyObject *module, DWORD desired_access, BOOL inherit_handle, LPCWSTR name) -/*[clinic end generated code: output=c4a45e95545a4bd2 input=dec26598748d35aa]*/ +/*[clinic end generated code: output=c4a45e95545a4bd2 input=ca388b35dcd10b1e]*/ { HANDLE handle; @@ -1832,7 +1847,7 @@ _winapi_OpenEventW_impl(PyObject *module, DWORD desired_access, /*[clinic input] _winapi.OpenMutexW -> HANDLE - desired_access: DWORD + desired_access: DWORD(bitwise=True) inherit_handle: BOOL name: LPCWSTR [clinic start generated code]*/ @@ -1840,7 +1855,7 @@ _winapi.OpenMutexW -> HANDLE static HANDLE _winapi_OpenMutexW_impl(PyObject *module, DWORD desired_access, BOOL inherit_handle, LPCWSTR name) -/*[clinic end generated code: output=dda39d7844397bf0 input=f3a7b466c5307712]*/ +/*[clinic end generated code: output=dda39d7844397bf0 input=c1a077777c7f88f6]*/ { HANDLE handle; @@ -1862,7 +1877,7 @@ _winapi_OpenMutexW_impl(PyObject *module, DWORD desired_access, /*[clinic input] _winapi.OpenFileMapping -> HANDLE - desired_access: DWORD + desired_access: DWORD(bitwise=True) inherit_handle: BOOL name: LPCWSTR / @@ -1871,7 +1886,7 @@ _winapi.OpenFileMapping -> HANDLE static HANDLE _winapi_OpenFileMapping_impl(PyObject *module, DWORD desired_access, BOOL inherit_handle, LPCWSTR name) -/*[clinic end generated code: output=08cc44def1cb11f1 input=131f2a405359de7f]*/ +/*[clinic end generated code: output=08cc44def1cb11f1 input=1f82471d4cdc232f]*/ { HANDLE handle; @@ -1892,16 +1907,16 @@ _winapi_OpenFileMapping_impl(PyObject *module, DWORD desired_access, /*[clinic input] _winapi.OpenProcess -> HANDLE - desired_access: DWORD + desired_access: DWORD(bitwise=True) inherit_handle: BOOL - process_id: DWORD + process_id: DWORD(bitwise=True) / [clinic start generated code]*/ static HANDLE _winapi_OpenProcess_impl(PyObject *module, DWORD desired_access, BOOL inherit_handle, DWORD process_id) -/*[clinic end generated code: output=b42b6b81ea5a0fc3 input=ec98c4cf4ea2ec36]*/ +/*[clinic end generated code: output=b42b6b81ea5a0fc3 input=13af8d7640f1313f]*/ { HANDLE handle; @@ -1978,7 +1993,7 @@ _winapi_PeekNamedPipe_impl(PyObject *module, HANDLE handle, int size) _winapi.LCMapStringEx locale: LPCWSTR - flags: DWORD + flags: DWORD(bitwise=True) src: unicode [clinic start generated code]*/ @@ -1986,7 +2001,7 @@ _winapi.LCMapStringEx static PyObject * _winapi_LCMapStringEx_impl(PyObject *module, LPCWSTR locale, DWORD flags, PyObject *src) -/*[clinic end generated code: output=b90e6b26e028ff0a input=3e3dcd9b8164012f]*/ +/*[clinic end generated code: output=b90e6b26e028ff0a input=247d3967a9c480ba]*/ { if (flags & (LCMAP_SORTHANDLE | LCMAP_HASH | LCMAP_BYTEREV | LCMAP_SORTKEY)) { @@ -2038,14 +2053,14 @@ _winapi_LCMapStringEx_impl(PyObject *module, LPCWSTR locale, DWORD flags, _winapi.ReadFile handle: HANDLE - size: DWORD + size: DWORD(bitwise=True) overlapped as use_overlapped: bool = False [clinic start generated code]*/ static PyObject * _winapi_ReadFile_impl(PyObject *module, HANDLE handle, DWORD size, int use_overlapped) -/*[clinic end generated code: output=d3d5b44a8201b944 input=4f82f8e909ad91ad]*/ +/*[clinic end generated code: output=d3d5b44a8201b944 input=aa266e0df79fe16a]*/ { DWORD nread; PyObject *buf; @@ -2265,13 +2280,13 @@ _winapi_VirtualQuerySize_impl(PyObject *module, LPCVOID address) _winapi.WaitNamedPipe name: LPCWSTR - timeout: DWORD + timeout: DWORD(bitwise=True) / [clinic start generated code]*/ static PyObject * _winapi_WaitNamedPipe_impl(PyObject *module, LPCWSTR name, DWORD timeout) -/*[clinic end generated code: output=e161e2e630b3e9c2 input=099a4746544488fa]*/ +/*[clinic end generated code: output=e161e2e630b3e9c2 input=e35bf1f712f3193d]*/ { BOOL success; @@ -2322,7 +2337,7 @@ _winapi.BatchedWaitForMultipleObjects handle_seq: object wait_all: BOOL - milliseconds: DWORD(c_default='INFINITE') = _winapi.INFINITE + milliseconds: DWORD(bitwise=True, c_default='INFINITE') = _winapi.INFINITE Supports a larger number of handles than WaitForMultipleObjects @@ -2344,7 +2359,7 @@ static PyObject * _winapi_BatchedWaitForMultipleObjects_impl(PyObject *module, PyObject *handle_seq, BOOL wait_all, DWORD milliseconds) -/*[clinic end generated code: output=d21c1a4ad0a252fd input=7e196f29005dc77b]*/ +/*[clinic end generated code: output=d21c1a4ad0a252fd input=c93e93b7fce1da4f]*/ { Py_ssize_t thread_count = 0, handle_count = 0, i; Py_ssize_t nhandles; @@ -2582,7 +2597,9 @@ _winapi_BatchedWaitForMultipleObjects_impl(PyObject *module, while (--thread_count >= 0) { HANDLE t = thread_data[thread_count]->thread; if (t) { +#ifdef MS_WINDOWS_DESKTOP TerminateThread(t, WAIT_ABANDONED_0); +#endif CloseHandle(t); } PyMem_Free((void *)thread_data[thread_count]); @@ -2595,14 +2612,14 @@ _winapi.WaitForMultipleObjects handle_seq: object wait_flag: BOOL - milliseconds: DWORD(c_default='INFINITE') = _winapi.INFINITE + milliseconds: DWORD(bitwise=True, c_default='INFINITE') = _winapi.INFINITE / [clinic start generated code]*/ static PyObject * _winapi_WaitForMultipleObjects_impl(PyObject *module, PyObject *handle_seq, BOOL wait_flag, DWORD milliseconds) -/*[clinic end generated code: output=295e3f00b8e45899 input=36f76ca057cd28a0]*/ +/*[clinic end generated code: output=295e3f00b8e45899 input=8ea1dd762d873559]*/ { DWORD result; HANDLE handles[MAXIMUM_WAIT_OBJECTS]; @@ -2665,7 +2682,7 @@ _winapi_WaitForMultipleObjects_impl(PyObject *module, PyObject *handle_seq, _winapi.WaitForSingleObject -> long handle: HANDLE - milliseconds: DWORD + milliseconds: DWORD(bitwise=True) / Wait for a single object. @@ -2678,7 +2695,7 @@ in milliseconds. static long _winapi_WaitForSingleObject_impl(PyObject *module, HANDLE handle, DWORD milliseconds) -/*[clinic end generated code: output=3c4715d8f1b39859 input=443d1ab076edc7b1]*/ +/*[clinic end generated code: output=3c4715d8f1b39859 input=1f74a3422daef05c]*/ { DWORD result; @@ -2776,7 +2793,11 @@ static PyObject * _winapi_GetOEMCP_impl(PyObject *module) /*[clinic end generated code: output=4def5b07a8be1b3b input=e8caf4353a28e28e]*/ { +#ifndef MS_WINDOWS_DESKTOP + return NULL; +#else return PyLong_FromUnsignedLong(GetOEMCP()); +#endif } /*[clinic input] @@ -2803,6 +2824,95 @@ _winapi_GetFileType_impl(PyObject *module, HANDLE handle) return result; } +/*[clinic input] +_winapi.GetConsoleMode -> DWORD + + handle: HANDLE + / + +Return the current mode of a console buffer. + +The handle may refer to a console input buffer or a console screen +buffer. +[clinic start generated code]*/ + +static DWORD +_winapi_GetConsoleMode_impl(PyObject *module, HANDLE handle) +/*[clinic end generated code: output=4c0155d4357673ac input=4768c2370a960135]*/ +{ + DWORD mode; + BOOL ret; + + Py_BEGIN_ALLOW_THREADS + ret = GetConsoleMode(handle, &mode); + Py_END_ALLOW_THREADS + + if (!ret) { + PyErr_SetFromWindowsErr(0); + return PY_DWORD_MAX; + } + + return mode; +} + +/*[clinic input] +_winapi.SetConsoleMode + + handle: HANDLE + mode: DWORD(bitwise=True) + / + +Set the mode of a console buffer. + +The handle may refer to a console input buffer or a console screen +buffer. +[clinic start generated code]*/ + +static PyObject * +_winapi_SetConsoleMode_impl(PyObject *module, HANDLE handle, DWORD mode) +/*[clinic end generated code: output=3351f12c46a8938f input=41ffc3f65998d7e1]*/ +{ + BOOL ret; + + Py_BEGIN_ALLOW_THREADS + ret = SetConsoleMode(handle, mode); + Py_END_ALLOW_THREADS + + if (!ret) { + return PyErr_SetFromWindowsErr(0); + } + + Py_RETURN_NONE; +} + +/*[clinic input] +_winapi.FlushConsoleInputBuffer + + handle: HANDLE + / + +Flush the console input buffer. + +All input records currently in the input buffer are discarded. +[clinic start generated code]*/ + +static PyObject * +_winapi_FlushConsoleInputBuffer_impl(PyObject *module, HANDLE handle) +/*[clinic end generated code: output=2edaf920d25233ab input=9684cbfada20c237]*/ +{ + BOOL ret; + + Py_BEGIN_ALLOW_THREADS + ret = FlushConsoleInputBuffer(handle); + Py_END_ALLOW_THREADS + + if (!ret) { + return PyErr_SetFromWindowsErr(0); + } + + Py_RETURN_NONE; +} + /*[clinic input] _winapi._mimetypes_read_windows_registry @@ -2942,7 +3052,7 @@ _winapi.CopyFile2 existing_file_name: LPCWSTR new_file_name: LPCWSTR - flags: DWORD + flags: DWORD(bitwise=True) progress_routine: object = None Copies a file from one name to a new name. @@ -2958,7 +3068,7 @@ static PyObject * _winapi_CopyFile2_impl(PyObject *module, LPCWSTR existing_file_name, LPCWSTR new_file_name, DWORD flags, PyObject *progress_routine) -/*[clinic end generated code: output=43d960d9df73d984 input=fb976b8d1492d130]*/ +/*[clinic end generated code: output=43d960d9df73d984 input=16394ddb6b3bd276]*/ { HRESULT hr; COPYFILE2_EXTENDED_PARAMETERS params = { sizeof(COPYFILE2_EXTENDED_PARAMETERS) }; @@ -3211,6 +3321,9 @@ static PyMethodDef winapi_functions[] = { _WINAPI_GETACP_METHODDEF _WINAPI_GETOEMCP_METHODDEF _WINAPI_GETFILETYPE_METHODDEF + _WINAPI_GETCONSOLEMODE_METHODDEF + _WINAPI_SETCONSOLEMODE_METHODDEF + _WINAPI_FLUSHCONSOLEINPUTBUFFER_METHODDEF _WINAPI__MIMETYPES_READ_WINDOWS_REGISTRY_METHODDEF _WINAPI_NEEDCURRENTDIRECTORYFOREXEPATH_METHODDEF _WINAPI_COPYFILE2_METHODDEF diff --git a/Modules/_xxtestfuzz/fuzzer.c b/Modules/_xxtestfuzz/fuzzer.c index 02afb01d3731fbc..8c2d0e93cd72d44 100644 --- a/Modules/_xxtestfuzz/fuzzer.c +++ b/Modules/_xxtestfuzz/fuzzer.c @@ -325,6 +325,10 @@ static int fuzz_sre_match(const char* data, size_t size) { PyObject* pattern = compiled_patterns[idx]; PyObject* match_callable = PyObject_GetAttrString(pattern, "match"); + if (match_callable == NULL) { + Py_DECREF(to_match); + return 0; + } PyObject* matches = PyObject_CallOneArg(match_callable, to_match); diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c index 2a7ac4498261e08..d17b3df4dfbbb14 100644 --- a/Modules/_zoneinfo.c +++ b/Modules/_zoneinfo.c @@ -302,6 +302,7 @@ get_weak_cache(zoneinfo_state *state, PyTypeObject *type) } /*[clinic input] +@vectorcall @critical_section @classmethod zoneinfo.ZoneInfo.__new__ @@ -313,7 +314,7 @@ Create a new ZoneInfo instance. static PyObject * zoneinfo_ZoneInfo_impl(PyTypeObject *type, PyObject *key) -/*[clinic end generated code: output=95e61dab86bb95c3 input=ef73d7a83bf8790e]*/ +/*[clinic end generated code: output=95e61dab86bb95c3 input=8cb93934e6a8d11b]*/ { zoneinfo_state *state = zoneinfo_get_state_by_self(type); PyObject *instance = zone_from_strong_cache(state, type, key); @@ -1070,7 +1071,7 @@ load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj) } Py_ssize_t cur_trans_idx = PyLong_AsSsize_t(num); - if (cur_trans_idx == -1) { + if (cur_trans_idx == -1 && PyErr_Occurred()) { goto error; } @@ -1181,7 +1182,12 @@ load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj) self->ttinfo_before = &(self->_ttinfos[0]); } - if (tz_str != Py_None && PyObject_IsTrue(tz_str)) { + int has_tz_str = PyObject_IsTrue(tz_str); + if (has_tz_str < 0) { + goto error; + } + + if (has_tz_str) { if (parse_tz_str(state, tz_str, &(self->tzrule_after))) { goto error; } @@ -1431,7 +1437,7 @@ dayrule_year_to_timestamp(TransitionRuleType *base_self, int year) // you would use a Julian day, e.g. J91 always refers to April 1st and J365 // always refers to December 31st. uint16_t day = self->day; - if (self->julian && day >= 59 && is_leap_year(year)) { + if (self->julian && day >= 60 && is_leap_year(year)) { day += 1; } @@ -2311,7 +2317,7 @@ get_local_timestamp(PyObject *dt, int64_t *local_ts) } hour = PyLong_AsLong(num); Py_DECREF(num); - if (hour == -1) { + if (hour == -1 && PyErr_Occurred()) { return -1; } @@ -2321,7 +2327,7 @@ get_local_timestamp(PyObject *dt, int64_t *local_ts) } minute = PyLong_AsLong(num); Py_DECREF(num); - if (minute == -1) { + if (minute == -1 && PyErr_Occurred()) { return -1; } @@ -2331,7 +2337,7 @@ get_local_timestamp(PyObject *dt, int64_t *local_ts) } second = PyLong_AsLong(num); Py_DECREF(num); - if (second == -1) { + if (second == -1 && PyErr_Occurred()) { return -1; } } @@ -2433,11 +2439,9 @@ find_in_strong_cache(const StrongCacheNode *const root, PyObject *const key) { const StrongCacheNode *node = root; while (node != NULL) { - int rv = PyObject_RichCompareBool(key, node->key, Py_EQ); - if (rv < 0) { - return NULL; - } - if (rv) { + if (key == node->key || + (PyUnicode_Check(key) && PyUnicode_Check(node->key) && + PyUnicode_Equal(key, node->key))) { return (StrongCacheNode *)node; } @@ -2614,9 +2618,21 @@ initialize_caches(zoneinfo_state *state) return 0; } +/*[clinic input] +@classmethod +zoneinfo.ZoneInfo.__init_subclass__ + + **kwargs: dict + +Function to initialize subclasses. +[clinic start generated code]*/ + static PyObject * -zoneinfo_init_subclass(PyObject *cls, PyObject *args, PyObject *kwargs) +zoneinfo_ZoneInfo___init_subclass___impl(PyTypeObject *type, + PyObject *kwargs) +/*[clinic end generated code: output=05b20743d42252f1 input=fd2e4b35d6ab1397]*/ { + PyObject *cls = (PyObject *)type; PyObject *weak_cache = new_weak_cache(); if (weak_cache == NULL) { return NULL; @@ -2646,9 +2662,7 @@ static PyMethodDef zoneinfo_methods[] = { {"__reduce__", zoneinfo_reduce, METH_NOARGS, PyDoc_STR("Function for serialization with the pickle protocol.")}, ZONEINFO_ZONEINFO__UNPICKLE_METHODDEF - {"__init_subclass__", _PyCFunction_CAST(zoneinfo_init_subclass), - METH_VARARGS | METH_KEYWORDS | METH_CLASS, - PyDoc_STR("Function to initialize subclasses.")}, + ZONEINFO_ZONEINFO___INIT_SUBCLASS___METHODDEF {NULL} /* Sentinel */ }; @@ -2672,6 +2686,7 @@ static PyType_Slot zoneinfo_slots[] = { {Py_tp_methods, zoneinfo_methods}, {Py_tp_members, zoneinfo_members}, {Py_tp_new, zoneinfo_ZoneInfo}, + {Py_tp_vectorcall, zoneinfo_ZoneInfo_vectorcall}, {Py_tp_dealloc, zoneinfo_dealloc}, {Py_tp_traverse, zoneinfo_traverse}, {Py_tp_clear, zoneinfo_clear}, diff --git a/Modules/_zstd/_zstdmodule.c b/Modules/_zstd/_zstdmodule.c index 94246dd93b17de1..0c7db1ccaaee23b 100644 --- a/Modules/_zstd/_zstdmodule.c +++ b/Modules/_zstd/_zstdmodule.c @@ -274,7 +274,7 @@ _zstd_train_dict_impl(PyObject *module, PyBytesObject *samples_bytes, PyObject *samples_sizes, Py_ssize_t dict_size) /*[clinic end generated code: output=8e87fe43935e8f77 input=d20dedb21c72cb62]*/ { - PyObject *dst_dict_bytes = NULL; + PyBytesWriter *dst_dict_bytes = NULL; size_t *chunk_sizes = NULL; Py_ssize_t chunks_number; size_t zstd_ret; @@ -294,13 +294,13 @@ _zstd_train_dict_impl(PyObject *module, PyBytesObject *samples_bytes, } /* Allocate dict buffer */ - dst_dict_bytes = PyBytes_FromStringAndSize(NULL, dict_size); + dst_dict_bytes = PyBytesWriter_Create(dict_size); if (dst_dict_bytes == NULL) { goto error; } /* Train the dictionary */ - char *dst_dict_buffer = PyBytes_AS_STRING(dst_dict_bytes); + char *dst_dict_buffer = PyBytesWriter_GetData(dst_dict_bytes); const char *samples_buffer = PyBytes_AS_STRING(samples_bytes); Py_BEGIN_ALLOW_THREADS zstd_ret = ZDICT_trainFromBuffer(dst_dict_buffer, dict_size, @@ -315,19 +315,15 @@ _zstd_train_dict_impl(PyObject *module, PyBytesObject *samples_bytes, goto error; } - /* Resize dict_buffer */ - if (_PyBytes_Resize(&dst_dict_bytes, zstd_ret) < 0) { - goto error; - } + PyMem_Free(chunk_sizes); - goto success; + /* Resize dict_buffer */ + return PyBytesWriter_FinishWithSize(dst_dict_bytes, zstd_ret); error: - Py_CLEAR(dst_dict_bytes); - -success: + PyBytesWriter_Discard(dst_dict_bytes); PyMem_Free(chunk_sizes); - return dst_dict_bytes; + return NULL; } /*[clinic input] @@ -357,7 +353,8 @@ _zstd_finalize_dict_impl(PyObject *module, PyBytesObject *custom_dict_bytes, { Py_ssize_t chunks_number; size_t *chunk_sizes = NULL; - PyObject *dst_dict_bytes = NULL; + PyBytesWriter *dst_dict_bytes = NULL; + PyObject *result = NULL; size_t zstd_ret; ZDICT_params_t params; @@ -376,7 +373,7 @@ _zstd_finalize_dict_impl(PyObject *module, PyBytesObject *custom_dict_bytes, } /* Allocate dict buffer */ - dst_dict_bytes = PyBytes_FromStringAndSize(NULL, dict_size); + dst_dict_bytes = PyBytesWriter_Create(dict_size); if (dst_dict_bytes == NULL) { goto error; } @@ -393,7 +390,8 @@ _zstd_finalize_dict_impl(PyObject *module, PyBytesObject *custom_dict_bytes, /* Finalize the dictionary */ Py_BEGIN_ALLOW_THREADS zstd_ret = ZDICT_finalizeDictionary( - PyBytes_AS_STRING(dst_dict_bytes), dict_size, + PyBytesWriter_GetData(dst_dict_bytes), + PyBytesWriter_GetSize(dst_dict_bytes), PyBytes_AS_STRING(custom_dict_bytes), Py_SIZE(custom_dict_bytes), PyBytes_AS_STRING(samples_bytes), chunk_sizes, @@ -408,18 +406,15 @@ _zstd_finalize_dict_impl(PyObject *module, PyBytesObject *custom_dict_bytes, } /* Resize dict_buffer */ - if (_PyBytes_Resize(&dst_dict_bytes, zstd_ret) < 0) { - goto error; - } - - goto success; + result = PyBytesWriter_FinishWithSize(dst_dict_bytes, zstd_ret); + goto done; error: - Py_CLEAR(dst_dict_bytes); + PyBytesWriter_Discard(dst_dict_bytes); -success: +done: PyMem_Free(chunk_sizes); - return dst_dict_bytes; + return result; } @@ -498,12 +493,12 @@ _zstd.get_frame_info frame_buffer: Py_buffer A bytes-like object, containing the header of a Zstandard frame. -Get Zstandard frame infomation from a frame header. +Get Zstandard frame information from a frame header. [clinic start generated code]*/ static PyObject * _zstd_get_frame_info_impl(PyObject *module, Py_buffer *frame_buffer) -/*[clinic end generated code: output=56e033cf48001929 input=94b240583ae22ca5]*/ +/*[clinic end generated code: output=56e033cf48001929 input=6b350490b0f58ede]*/ { uint64_t decompressed_size; uint32_t dict_id; @@ -571,6 +566,55 @@ static PyMethodDef _zstd_methods[] = { {NULL, NULL} }; +PyDoc_STRVAR(zstd_version_info__doc__, +"_zstd.zstd_version_info\n\ +\n\ +Zstd version information as a named tuple."); + +static PyStructSequence_Field zstd_version_info_fields[] = { + {"major", "Major release number"}, + {"minor", "Minor release number"}, + {"patch", "Patch release number"}, + {0} +}; + +static PyStructSequence_Desc zstd_version_info_desc = { + "_zstd.zstd_version_info", /* name */ + zstd_version_info__doc__, /* doc */ + zstd_version_info_fields, /* fields */ + 3 +}; + +static PyObject * +make_zstd_version_info(PyTypeObject *type, unsigned int number) +{ + PyObject *version; + int pos = 0; + unsigned int major = number / 10000u; + unsigned int minor = (number % 10000u) / 100u; + unsigned int patch = number % 100u; + + version = PyStructSequence_New(type); + if (version == NULL) { + return NULL; + } + +#define SetIntItem(VALUE) \ + PyStructSequence_SET_ITEM(version, pos++, PyLong_FromUnsignedLong(VALUE)); \ + if (PyErr_Occurred()) { \ + Py_DECREF(version); \ + return NULL; \ + } + + SetIntItem(major) + SetIntItem(minor) + SetIntItem(patch) +#undef SetIntItem + + return version; +} + + static int _zstd_exec(PyObject *m) { @@ -623,15 +667,32 @@ do { \ } /* Add constants */ - if (PyModule_AddIntConstant(m, "zstd_version_number", - ZSTD_versionNumber()) < 0) { + if (PyModule_AddStringConstant(m, "ZSTD_VERSION", + ZSTD_VERSION_STRING) < 0) { return -1; } - if (PyModule_AddStringConstant(m, "zstd_version", ZSTD_versionString()) < 0) { return -1; } + PyTypeObject *version_type; + version_type = PyStructSequence_NewType(&zstd_version_info_desc); + if (version_type == NULL) { + return -1; + } + if (PyModule_Add(m, "ZSTD_VERSION_INFO", + make_zstd_version_info(version_type, ZSTD_VERSION_NUMBER)) < 0) + { + Py_DECREF(version_type); + return -1; + } + if (PyModule_Add(m, "zstd_version_info", + make_zstd_version_info(version_type, ZSTD_versionNumber())) < 0) + { + Py_DECREF(version_type); + return -1; + } + Py_DECREF(version_type); #if ZSTD_VERSION_NUMBER >= 10500 if (PyModule_AddIntConstant(m, "ZSTD_CLEVEL_DEFAULT", diff --git a/Modules/_zstd/clinic/_zstdmodule.c.h b/Modules/_zstd/clinic/_zstdmodule.c.h index 766e1cfa776767b..feb0563b3228381 100644 --- a/Modules/_zstd/clinic/_zstdmodule.c.h +++ b/Modules/_zstd/clinic/_zstdmodule.c.h @@ -289,7 +289,7 @@ PyDoc_STRVAR(_zstd_get_frame_info__doc__, "get_frame_info($module, /, frame_buffer)\n" "--\n" "\n" -"Get Zstandard frame infomation from a frame header.\n" +"Get Zstandard frame information from a frame header.\n" "\n" " frame_buffer\n" " A bytes-like object, containing the header of a Zstandard frame."); @@ -426,4 +426,4 @@ _zstd_set_parameter_types(PyObject *module, PyObject *const *args, Py_ssize_t na exit: return return_value; } -/*[clinic end generated code: output=437b084f149e68e5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a6ad0ab41c507911 input=a9049054013a1b77]*/ diff --git a/Modules/_zstd/clinic/decompressor.c.h b/Modules/_zstd/clinic/decompressor.c.h index fe3b76b8bb369df..83431363621ad64 100644 --- a/Modules/_zstd/clinic/decompressor.c.h +++ b/Modules/_zstd/clinic/decompressor.c.h @@ -93,20 +93,6 @@ PyDoc_STRVAR(_zstd_ZstdDecompressor_unused_data__doc__, "When ZstdDecompressor object stops after a frame is\n" "decompressed, unused input data after the frame. Otherwise this\n" "will be b\'\'."); -#if defined(_zstd_ZstdDecompressor_unused_data_DOCSTR) -# undef _zstd_ZstdDecompressor_unused_data_DOCSTR -#endif -#define _zstd_ZstdDecompressor_unused_data_DOCSTR _zstd_ZstdDecompressor_unused_data__doc__ - -#if !defined(_zstd_ZstdDecompressor_unused_data_DOCSTR) -# define _zstd_ZstdDecompressor_unused_data_DOCSTR NULL -#endif -#if defined(_ZSTD_ZSTDDECOMPRESSOR_UNUSED_DATA_GETSETDEF) -# undef _ZSTD_ZSTDDECOMPRESSOR_UNUSED_DATA_GETSETDEF -# define _ZSTD_ZSTDDECOMPRESSOR_UNUSED_DATA_GETSETDEF {"unused_data", (getter)_zstd_ZstdDecompressor_unused_data_get, (setter)_zstd_ZstdDecompressor_unused_data_set, _zstd_ZstdDecompressor_unused_data_DOCSTR}, -#else -# define _ZSTD_ZSTDDECOMPRESSOR_UNUSED_DATA_GETSETDEF {"unused_data", (getter)_zstd_ZstdDecompressor_unused_data_get, NULL, _zstd_ZstdDecompressor_unused_data_DOCSTR}, -#endif static PyObject * _zstd_ZstdDecompressor_unused_data_get_impl(ZstdDecompressor *self); @@ -222,4 +208,6 @@ _zstd_ZstdDecompressor_decompress(PyObject *self, PyObject *const *args, Py_ssiz return return_value; } -/*[clinic end generated code: output=70bc308e86463751 input=a9049054013a1b77]*/ +#define _ZSTD_ZSTDDECOMPRESSOR_UNUSED_DATA_GETSETDEF {"unused_data", (getter)_zstd_ZstdDecompressor_unused_data_get, (setter)NULL, _zstd_ZstdDecompressor_unused_data__doc__}, + +/*[clinic end generated code: output=91b84afb07b1188c input=a9049054013a1b77]*/ diff --git a/Modules/_zstd/clinic/zstddict.c.h b/Modules/_zstd/clinic/zstddict.c.h index 18b049e3cbe37ef..30a1ed8ea9bfa8a 100644 --- a/Modules/_zstd/clinic/zstddict.c.h +++ b/Modules/_zstd/clinic/zstddict.c.h @@ -95,20 +95,6 @@ _zstd_ZstdDict_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyDoc_STRVAR(_zstd_ZstdDict_dict_content__doc__, "The content of a Zstandard dictionary, as a bytes object."); -#if defined(_zstd_ZstdDict_dict_content_DOCSTR) -# undef _zstd_ZstdDict_dict_content_DOCSTR -#endif -#define _zstd_ZstdDict_dict_content_DOCSTR _zstd_ZstdDict_dict_content__doc__ - -#if !defined(_zstd_ZstdDict_dict_content_DOCSTR) -# define _zstd_ZstdDict_dict_content_DOCSTR NULL -#endif -#if defined(_ZSTD_ZSTDDICT_DICT_CONTENT_GETSETDEF) -# undef _ZSTD_ZSTDDICT_DICT_CONTENT_GETSETDEF -# define _ZSTD_ZSTDDICT_DICT_CONTENT_GETSETDEF {"dict_content", (getter)_zstd_ZstdDict_dict_content_get, (setter)_zstd_ZstdDict_dict_content_set, _zstd_ZstdDict_dict_content_DOCSTR}, -#else -# define _ZSTD_ZSTDDICT_DICT_CONTENT_GETSETDEF {"dict_content", (getter)_zstd_ZstdDict_dict_content_get, NULL, _zstd_ZstdDict_dict_content_DOCSTR}, -#endif static PyObject * _zstd_ZstdDict_dict_content_get_impl(ZstdDict *self); @@ -131,20 +117,6 @@ PyDoc_STRVAR(_zstd_ZstdDict_as_digested_dict__doc__, " level. It\'s faster when loading again a digested dictionary with\n" " the same compression level.\n" "3. No need to use this for decompression."); -#if defined(_zstd_ZstdDict_as_digested_dict_DOCSTR) -# undef _zstd_ZstdDict_as_digested_dict_DOCSTR -#endif -#define _zstd_ZstdDict_as_digested_dict_DOCSTR _zstd_ZstdDict_as_digested_dict__doc__ - -#if !defined(_zstd_ZstdDict_as_digested_dict_DOCSTR) -# define _zstd_ZstdDict_as_digested_dict_DOCSTR NULL -#endif -#if defined(_ZSTD_ZSTDDICT_AS_DIGESTED_DICT_GETSETDEF) -# undef _ZSTD_ZSTDDICT_AS_DIGESTED_DICT_GETSETDEF -# define _ZSTD_ZSTDDICT_AS_DIGESTED_DICT_GETSETDEF {"as_digested_dict", (getter)_zstd_ZstdDict_as_digested_dict_get, (setter)_zstd_ZstdDict_as_digested_dict_set, _zstd_ZstdDict_as_digested_dict_DOCSTR}, -#else -# define _ZSTD_ZSTDDICT_AS_DIGESTED_DICT_GETSETDEF {"as_digested_dict", (getter)_zstd_ZstdDict_as_digested_dict_get, NULL, _zstd_ZstdDict_as_digested_dict_DOCSTR}, -#endif static PyObject * _zstd_ZstdDict_as_digested_dict_get_impl(ZstdDict *self); @@ -166,20 +138,6 @@ PyDoc_STRVAR(_zstd_ZstdDict_as_undigested_dict__doc__, "2. Loading an undigested dictionary is costly. If load an undigested\n" " dictionary multiple times, consider reusing a compressor object.\n" "3. No need to use this for decompression."); -#if defined(_zstd_ZstdDict_as_undigested_dict_DOCSTR) -# undef _zstd_ZstdDict_as_undigested_dict_DOCSTR -#endif -#define _zstd_ZstdDict_as_undigested_dict_DOCSTR _zstd_ZstdDict_as_undigested_dict__doc__ - -#if !defined(_zstd_ZstdDict_as_undigested_dict_DOCSTR) -# define _zstd_ZstdDict_as_undigested_dict_DOCSTR NULL -#endif -#if defined(_ZSTD_ZSTDDICT_AS_UNDIGESTED_DICT_GETSETDEF) -# undef _ZSTD_ZSTDDICT_AS_UNDIGESTED_DICT_GETSETDEF -# define _ZSTD_ZSTDDICT_AS_UNDIGESTED_DICT_GETSETDEF {"as_undigested_dict", (getter)_zstd_ZstdDict_as_undigested_dict_get, (setter)_zstd_ZstdDict_as_undigested_dict_set, _zstd_ZstdDict_as_undigested_dict_DOCSTR}, -#else -# define _ZSTD_ZSTDDICT_AS_UNDIGESTED_DICT_GETSETDEF {"as_undigested_dict", (getter)_zstd_ZstdDict_as_undigested_dict_get, NULL, _zstd_ZstdDict_as_undigested_dict_DOCSTR}, -#endif static PyObject * _zstd_ZstdDict_as_undigested_dict_get_impl(ZstdDict *self); @@ -201,20 +159,6 @@ PyDoc_STRVAR(_zstd_ZstdDict_as_prefix__doc__, "2. It only works for the first frame, then the\n" " compressor/decompressor will return to no prefix state.\n" "3. When decompressing, must use the same prefix as when compressing."); -#if defined(_zstd_ZstdDict_as_prefix_DOCSTR) -# undef _zstd_ZstdDict_as_prefix_DOCSTR -#endif -#define _zstd_ZstdDict_as_prefix_DOCSTR _zstd_ZstdDict_as_prefix__doc__ - -#if !defined(_zstd_ZstdDict_as_prefix_DOCSTR) -# define _zstd_ZstdDict_as_prefix_DOCSTR NULL -#endif -#if defined(_ZSTD_ZSTDDICT_AS_PREFIX_GETSETDEF) -# undef _ZSTD_ZSTDDICT_AS_PREFIX_GETSETDEF -# define _ZSTD_ZSTDDICT_AS_PREFIX_GETSETDEF {"as_prefix", (getter)_zstd_ZstdDict_as_prefix_get, (setter)_zstd_ZstdDict_as_prefix_set, _zstd_ZstdDict_as_prefix_DOCSTR}, -#else -# define _ZSTD_ZSTDDICT_AS_PREFIX_GETSETDEF {"as_prefix", (getter)_zstd_ZstdDict_as_prefix_get, NULL, _zstd_ZstdDict_as_prefix_DOCSTR}, -#endif static PyObject * _zstd_ZstdDict_as_prefix_get_impl(ZstdDict *self); @@ -224,4 +168,12 @@ _zstd_ZstdDict_as_prefix_get(PyObject *self, void *Py_UNUSED(context)) { return _zstd_ZstdDict_as_prefix_get_impl((ZstdDict *)self); } -/*[clinic end generated code: output=49b66061b4fcdb5f input=a9049054013a1b77]*/ +#define _ZSTD_ZSTDDICT_DICT_CONTENT_GETSETDEF {"dict_content", (getter)_zstd_ZstdDict_dict_content_get, (setter)NULL, _zstd_ZstdDict_dict_content__doc__}, + +#define _ZSTD_ZSTDDICT_AS_DIGESTED_DICT_GETSETDEF {"as_digested_dict", (getter)_zstd_ZstdDict_as_digested_dict_get, (setter)NULL, _zstd_ZstdDict_as_digested_dict__doc__}, + +#define _ZSTD_ZSTDDICT_AS_UNDIGESTED_DICT_GETSETDEF {"as_undigested_dict", (getter)_zstd_ZstdDict_as_undigested_dict_get, (setter)NULL, _zstd_ZstdDict_as_undigested_dict__doc__}, + +#define _ZSTD_ZSTDDICT_AS_PREFIX_GETSETDEF {"as_prefix", (getter)_zstd_ZstdDict_as_prefix_get, (setter)NULL, _zstd_ZstdDict_as_prefix__doc__}, + +/*[clinic end generated code: output=aa4d4b8fd985ae08 input=a9049054013a1b77]*/ diff --git a/Modules/_zstd/compressor.c b/Modules/_zstd/compressor.c index 894568fce28d0d5..0e3d81bd32c58b2 100644 --- a/Modules/_zstd/compressor.c +++ b/Modules/_zstd/compressor.c @@ -36,6 +36,10 @@ typedef struct { /* (nbWorker >= 1) ? 1 : 0 */ int use_multithread; + /* Nonzero if worker threads may still be compressing submitted data: + set by any call that did not complete a frame, including a failed one */ + int mt_maybe_busy; + /* Compression level */ int compression_level; @@ -347,6 +351,7 @@ _zstd_ZstdCompressor_new_impl(PyTypeObject *type, PyObject *level, } self->use_multithread = 0; + self->mt_maybe_busy = 0; self->compression_level = ZSTD_CLEVEL_DEFAULT; self->dict = NULL; self->lock = (PyMutex){0}; @@ -427,6 +432,18 @@ ZstdCompressor_dealloc(PyObject *ob) /* Free compression context */ if (self->cctx) { + if (self->mt_maybe_busy) { + /* ZSTD_freeCCtx() (as of libzstd 1.5.7) frees the context's own + copy of a dictionary loaded with ZSTD_CCtx_loadDictionary() + before it stops the worker threads, which may still be + reading it. Starting a new frame makes libzstd wait for the + jobs of the previous one, and with no input it starts none. */ + ZSTD_inBuffer in = {NULL, 0, 0}; + ZSTD_outBuffer out = {NULL, 0, 0}; + (void)ZSTD_CCtx_reset(self->cctx, ZSTD_reset_session_only); + (void)ZSTD_compressStream2(self->cctx, &out, &in, + ZSTD_e_continue); + } ZSTD_freeCCtx(self->cctx); } @@ -637,6 +654,8 @@ _zstd_ZstdCompressor_compress_impl(ZstdCompressor *self, Py_buffer *data, /* Resetting cctx's session never fail */ ZSTD_CCtx_reset(self->cctx, ZSTD_reset_session_only); } + self->mt_maybe_busy = (self->use_multithread + && (ret == NULL || mode != ZSTD_e_end)); PyMutex_Unlock(&self->lock); return ret; @@ -685,6 +704,8 @@ _zstd_ZstdCompressor_flush_impl(ZstdCompressor *self, int mode) /* Resetting cctx's session never fail */ ZSTD_CCtx_reset(self->cctx, ZSTD_reset_session_only); } + self->mt_maybe_busy = (self->use_multithread + && (ret == NULL || mode != ZSTD_e_end)); PyMutex_Unlock(&self->lock); return ret; @@ -766,17 +787,13 @@ static int ZstdCompressor_traverse(PyObject *ob, visitproc visit, void *arg) { ZstdCompressor *self = ZstdCompressor_CAST(ob); + Py_VISIT(Py_TYPE(ob)); Py_VISIT(self->dict); return 0; } -static int -ZstdCompressor_clear(PyObject *ob) -{ - ZstdCompressor *self = ZstdCompressor_CAST(ob); - Py_CLEAR(self->dict); - return 0; -} +/* No tp_clear: the compression context (and its worker threads) uses the + dictionary until ZstdCompressor_dealloc() has freed the context. */ static PyType_Slot zstdcompressor_slots[] = { {Py_tp_new, _zstd_ZstdCompressor_new}, @@ -785,7 +802,6 @@ static PyType_Slot zstdcompressor_slots[] = { {Py_tp_members, ZstdCompressor_members}, {Py_tp_doc, (void *)_zstd_ZstdCompressor_new__doc__}, {Py_tp_traverse, ZstdCompressor_traverse}, - {Py_tp_clear, ZstdCompressor_clear}, {0, 0} }; diff --git a/Modules/_zstd/decompressor.c b/Modules/_zstd/decompressor.c index ca9ea7e3b8f99bb..454736d687a4305 100644 --- a/Modules/_zstd/decompressor.c +++ b/Modules/_zstd/decompressor.c @@ -689,18 +689,13 @@ static int ZstdDecompressor_traverse(PyObject *ob, visitproc visit, void *arg) { ZstdDecompressor *self = ZstdDecompressor_CAST(ob); + Py_VISIT(Py_TYPE(ob)); Py_VISIT(self->dict); return 0; } -static int -ZstdDecompressor_clear(PyObject *ob) -{ - ZstdDecompressor *self = ZstdDecompressor_CAST(ob); - Py_CLEAR(self->dict); - Py_CLEAR(self->unused_data); - return 0; -} +/* No tp_clear: the decompression context references the dictionary until + ZstdDecompressor_dealloc() has freed the context. */ static PyType_Slot ZstdDecompressor_slots[] = { {Py_tp_new, _zstd_ZstdDecompressor_new}, @@ -710,7 +705,6 @@ static PyType_Slot ZstdDecompressor_slots[] = { {Py_tp_getset, ZstdDecompressor_getset}, {Py_tp_doc, (void *)_zstd_ZstdDecompressor_new__doc__}, {Py_tp_traverse, ZstdDecompressor_traverse}, - {Py_tp_clear, ZstdDecompressor_clear}, {0, 0} }; diff --git a/Modules/_zstd/zstddict.c b/Modules/_zstd/zstddict.c index e1b9d998e697fb8..11ea7619976bf92 100644 --- a/Modules/_zstd/zstddict.c +++ b/Modules/_zstd/zstddict.c @@ -240,16 +240,11 @@ ZstdDict_length(PyObject *ob) static int ZstdDict_traverse(PyObject *ob, visitproc visit, void *arg) { - ZstdDict *self = ZstdDict_CAST(ob); - Py_VISIT(self->c_dicts); - return 0; -} - -static int -ZstdDict_clear(PyObject *ob) -{ - ZstdDict *self = ZstdDict_CAST(ob); - Py_CLEAR(self->c_dicts); + /* c_dicts is not visited and there is no tp_clear: it only maps ints + to capsules, and the ZSTD_CDict instances they own must stay alive + until ZstdDict_dealloc() as a compression context being collected + together with this object may still use them. */ + Py_VISIT(Py_TYPE(ob)); return 0; } @@ -262,7 +257,6 @@ static PyType_Slot zstddict_slots[] = { {Py_tp_doc, (void *)_zstd_ZstdDict_new__doc__}, {Py_sq_length, ZstdDict_length}, {Py_tp_traverse, ZstdDict_traverse}, - {Py_tp_clear, ZstdDict_clear}, {0, 0} }; diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 68486c66575933a..64dacd1b8f1f616 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -584,8 +584,8 @@ e_getitem(arrayobject *ap, Py_ssize_t i) static int e_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v) { - float x; - if (!PyArg_Parse(v, "f;array item must be float", &x)) { + double x; + if (!PyArg_Parse(v, "d;array item must be float", &x)) { return -1; } @@ -607,14 +607,16 @@ f_getitem(arrayobject *ap, Py_ssize_t i) static int f_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v) { - float x; - if (!PyArg_Parse(v, "f;array item must be float", &x)) + double x; + if (!PyArg_Parse(v, "d;array item must be float", &x)) return -1; CHECK_ARRAY_BOUNDS(ap, i); - if (i >= 0) - ((float *)ap->ob_item)[i] = x; + if (i >= 0) { + return PyFloat_Pack4(x, ap->ob_item + sizeof(float)*i, + PY_LITTLE_ENDIAN); + } return 0; } @@ -651,7 +653,6 @@ static int cf_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v) { Py_complex x; - float f[2]; if (!PyArg_Parse(v, "D;array item must be complex", &x)) { return -1; @@ -659,10 +660,18 @@ cf_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v) CHECK_ARRAY_BOUNDS(ap, i); - f[0] = (float)x.real; - f[1] = (float)x.imag; if (i >= 0) { - memcpy(ap->ob_item + i*sizeof(f), &f, sizeof(f)); + char f[8]; + int ret = PyFloat_Pack4(x.real, f, PY_LITTLE_ENDIAN); + + if (ret) { + return ret; + } + ret = PyFloat_Pack4(x.imag, f + sizeof(float), PY_LITTLE_ENDIAN); + if (!ret) { + memcpy(ap->ob_item + i*sizeof(f), &f, sizeof(f)); + } + return ret; } return 0; } @@ -1617,7 +1626,7 @@ array_array_byteswap_impl(arrayobject *self) break; case 16: assert(strcmp(self->ob_descr->typecode, "Zd") == 0); - for (p = self->ob_item, i = Py_SIZE(self); --i >= 0; p += 8) { + for (p = self->ob_item, i = Py_SIZE(self); --i >= 0; p += 16) { char t0 = p[0]; char t1 = p[1]; char t2 = p[2]; @@ -2281,7 +2290,7 @@ array__array_reconstructor_impl(PyObject *module, PyTypeObject *arraytype, case IEEE_754_FLOAT16_LE: case IEEE_754_FLOAT16_BE: { Py_ssize_t i; - int le = (mformat_code == IEEE_754_FLOAT_LE) ? 1 : 0; + int le = (mformat_code == IEEE_754_FLOAT16_LE) ? 1 : 0; Py_ssize_t itemcount = Py_SIZE(items) / 2; const char *memstr = PyBytes_AS_STRING(items); @@ -3100,6 +3109,7 @@ The following type codes are defined:\n\ Type code C Type Minimum size in bytes\n\ 'b' signed integer 1\n\ 'B' unsigned integer 1\n\ + 'w' Py_UCS4 4\n\ 'h' signed integer 2\n\ 'H' unsigned integer 2\n\ 'i' signed integer 2\n\ diff --git a/Modules/atexitmodule.c b/Modules/atexitmodule.c index 177b09d3dafbd93..d572351e80f6586 100644 --- a/Modules/atexitmodule.c +++ b/Modules/atexitmodule.c @@ -12,6 +12,13 @@ #include "pycore_interp.h" // PyInterpreterState.atexit #include "pycore_pystate.h" // _PyInterpreterState_GET +/*[clinic input] +module atexit +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=ac8fd67d15bf23fc]*/ + +#include "clinic/atexitmodule.c.h" + /* ===================================================================== */ /* Callback machinery. */ @@ -157,45 +164,35 @@ _PyAtExit_Call(PyInterpreterState *interp) /* Module methods. */ -PyDoc_STRVAR(atexit_register__doc__, -"register($module, func, /, *args, **kwargs)\n\ ---\n\ -\n\ -Register a function to be executed upon normal program termination\n\ -\n\ - func - function to be called at exit\n\ - args - optional arguments to pass to func\n\ - kwargs - optional keyword arguments to pass to func\n\ -\n\ - func is returned to facilitate usage as a decorator."); +/*[clinic input] +atexit.register + + func: object + / + *args: tuple + **kwargs: dict + +Register a function to be executed upon normal program termination + + func - function to be called at exit + args - optional arguments to pass to func + kwargs - optional keyword arguments to pass to func + + func is returned to facilitate usage as a decorator. +[clinic start generated code]*/ static PyObject * -atexit_register(PyObject *module, PyObject *args, PyObject *kwargs) +atexit_register_impl(PyObject *module, PyObject *func, PyObject *args, + PyObject *kwargs) +/*[clinic end generated code: output=c921286994bd8612 input=a682b5a343a82e4a]*/ { - if (PyTuple_GET_SIZE(args) == 0) { - PyErr_SetString(PyExc_TypeError, - "register() takes at least 1 argument (0 given)"); - return NULL; - } - - PyObject *func = PyTuple_GET_ITEM(args, 0); if (!PyCallable_Check(func)) { PyErr_SetString(PyExc_TypeError, "the first argument must be callable"); return NULL; } - PyObject *func_args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args)); - if (func_args == NULL) { - return NULL; - } - PyObject *func_kwargs = kwargs; - - if (func_kwargs == NULL) - { - func_kwargs = Py_None; - } - PyObject *callback = PyTuple_Pack(3, func, func_args, func_kwargs); - Py_DECREF(func_args); + PyObject *callback = PyTuple_Pack(3, func, args, + kwargs ? kwargs : Py_None); if (callback == NULL) { return NULL; @@ -318,8 +315,7 @@ atexit_unregister(PyObject *module, PyObject *func) static PyMethodDef atexit_methods[] = { - {"register", _PyCFunction_CAST(atexit_register), METH_VARARGS|METH_KEYWORDS, - atexit_register__doc__}, + ATEXIT_REGISTER_METHODDEF {"_clear", atexit_clear, METH_NOARGS, atexit_clear__doc__}, {"unregister", atexit_unregister, METH_O, atexit_unregister__doc__}, {"_run_exitfuncs", atexit_run_exitfuncs, METH_NOARGS, diff --git a/Modules/binascii.c b/Modules/binascii.c index 0e7af135a6f6ce4..406234cac1ed238 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -2373,31 +2373,80 @@ binascii.a2b_qp data: ascii_buffer header: bool = False + * + strip_ws: bool = False Decode a string of qp-encoded data. + +If strip_ws is true, whitespace at the end of a line is stripped, as +required by RFC 2045 when decoding a quoted-printable body. [clinic start generated code]*/ static PyObject * -binascii_a2b_qp_impl(PyObject *module, Py_buffer *data, int header) -/*[clinic end generated code: output=e99f7846cfb9bc53 input=bdfb31598d4e47b9]*/ +binascii_a2b_qp_impl(PyObject *module, Py_buffer *data, int header, + int strip_ws) +/*[clinic end generated code: output=7e9431376a28709d input=679b714f08932dd1]*/ { Py_ssize_t in, out; char ch; const unsigned char *ascii_data; - unsigned char *odata; + unsigned char *stripped = NULL; Py_ssize_t datalen = 0; - PyObject *rv; ascii_data = data->buf; datalen = data->len; - /* We allocate the output same size as input, this is overkill. + /* Strip trailing space and tab before each line break and at the end of + * the data (RFC 2045). Done before decoding, so that a "=" left at the + * end of a line becomes a soft line break and a "=20" is preserved. */ - odata = (unsigned char *) PyMem_Calloc(1, datalen); - if (odata == NULL) { - PyErr_NoMemory(); + if (strip_ws) { + Py_ssize_t i = 0, j = 0, start = 0; + while (i < datalen) { + if (ascii_data[i] != ' ' && ascii_data[i] != '\t') { + i++; + continue; + } + /* Find the run of space and tab. */ + Py_ssize_t k = i; + while (k < datalen && + (ascii_data[k] == ' ' || ascii_data[k] == '\t')) { + k++; + } + /* Drop it if it ends a line: before "\n", "\r\n" or the end of the + * data, but not a bare "\r" (RFC 2045: CR occurs only in CRLF). + */ + if (k == datalen || ascii_data[k] == '\n' || + (ascii_data[k] == '\r' && k + 1 < datalen && + ascii_data[k+1] == '\n')) { + if (stripped == NULL) { + /* Allocate only once something is actually stripped. */ + stripped = (unsigned char *) PyMem_Malloc(datalen); + if (stripped == NULL) { + PyErr_NoMemory(); + return NULL; + } + } + memcpy(stripped + j, ascii_data + start, i - start); + j += i - start; + start = k; + } + i = k; + } + if (stripped != NULL) { + memcpy(stripped + j, ascii_data + start, datalen - start); + j += datalen - start; + ascii_data = stripped; + datalen = j; + } + } + + PyBytesWriter *writer = PyBytesWriter_Create(datalen); + if (writer == NULL) { + PyMem_Free(stripped); return NULL; } + unsigned char *odata = PyBytesWriter_GetData(writer); in = out = 0; while (in < datalen) { @@ -2411,11 +2460,6 @@ binascii_a2b_qp_impl(PyObject *module, Py_buffer *data, int header) } if (in < datalen) in++; } - else if (ascii_data[in] == '=') { - /* broken case from broken python qp */ - odata[out++] = '='; - in++; - } else if ((in + 1 < datalen) && ((ascii_data[in] >= 'A' && ascii_data[in] <= 'F') || (ascii_data[in] >= 'a' && ascii_data[in] <= 'f') || @@ -2444,9 +2488,8 @@ binascii_a2b_qp_impl(PyObject *module, Py_buffer *data, int header) out++; } } - rv = PyBytes_FromStringAndSize((char *)odata, out); - PyMem_Free(odata); - return rv; + PyMem_Free(stripped); + return PyBytesWriter_FinishWithSize(writer, out); } static int @@ -2486,9 +2529,7 @@ binascii_b2a_qp_impl(PyObject *module, Py_buffer *data, int quotetabs, { Py_ssize_t in, out; const unsigned char *databuf; - unsigned char *odata; Py_ssize_t datalen = 0, odatalen = 0; - PyObject *rv; unsigned int linelen = 0; unsigned char ch; int crlf = 0; @@ -2573,13 +2614,11 @@ binascii_b2a_qp_impl(PyObject *module, Py_buffer *data, int quotetabs, odatalen += delta; } - /* We allocate the output same size as input, this is overkill. - */ - odata = (unsigned char *) PyMem_Calloc(1, odatalen); - if (odata == NULL) { - PyErr_NoMemory(); + PyBytesWriter *writer = PyBytesWriter_Create(odatalen); + if (writer == NULL) { return NULL; } + unsigned char *odata = PyBytesWriter_GetData(writer); in = out = linelen = 0; while (in < datalen) { @@ -2649,9 +2688,7 @@ binascii_b2a_qp_impl(PyObject *module, Py_buffer *data, int quotetabs, } } } - rv = PyBytes_FromStringAndSize((char *)odata, out); - PyMem_Free(odata); - return rv; + return PyBytesWriter_FinishWithSize(writer, out); } /* List of functions defined in the module */ diff --git a/Modules/blake2module.c b/Modules/blake2module.c index ac7265bb9d6836c..551ebd7cd052af9 100644 --- a/Modules/blake2module.c +++ b/Modules/blake2module.c @@ -392,6 +392,29 @@ new_Blake2Object(PyTypeObject *type) return NULL; } HASHLIB_INIT_MUTEX(self); + self->impl = type_to_impl(type); + // Ensure that the states are NULL-initialized in case of an error. + // See: py_blake2_clear() for more details. + switch (self->impl) { +#if _Py_HACL_CAN_COMPILE_VEC256 + case Blake2b_256: + self->blake2b_256_state = NULL; + break; +#endif +#if _Py_HACL_CAN_COMPILE_VEC128 + case Blake2s_128: + self->blake2s_128_state = NULL; + break; +#endif + case Blake2b: + self->blake2b_state = NULL; + break; + case Blake2s: + self->blake2s_state = NULL; + break; + default: + Py_UNREACHABLE(); + } PyObject_GC_Track(self); return self; @@ -553,30 +576,6 @@ py_blake2_new(PyTypeObject *type, PyObject *data, int digest_size, goto error; } - self->impl = type_to_impl(type); - // Ensure that the states are NULL-initialized in case of an error. - // See: py_blake2_clear() for more details. - switch (self->impl) { -#if _Py_HACL_CAN_COMPILE_VEC256 - case Blake2b_256: - self->blake2b_256_state = NULL; - break; -#endif -#if _Py_HACL_CAN_COMPILE_VEC128 - case Blake2s_128: - self->blake2s_128_state = NULL; - break; -#endif - case Blake2b: - self->blake2b_state = NULL; - break; - case Blake2s: - self->blake2s_state = NULL; - break; - default: - Py_UNREACHABLE(); - } - // Unlike the state types, the parameters share a single (client-friendly) // structure. if (py_blake2_validate_params(self, @@ -950,7 +949,9 @@ static PyObject * py_blake2b_get_digest_size(PyObject *op, void *Py_UNUSED(closure)) { Blake2Object *self = _Blake2Object_CAST(op); + HASHLIB_ACQUIRE_LOCK(self); Hacl_Hash_Blake2b_index info = hacl_get_blake2_info(self); + HASHLIB_RELEASE_LOCK(self); return PyLong_FromLong(info.digest_length); } diff --git a/Modules/cjkcodecs/_codecs_cn.c b/Modules/cjkcodecs/_codecs_cn.c index e2c7908c9bb2753..ede54d09f2875e1 100644 --- a/Modules/cjkcodecs/_codecs_cn.c +++ b/Modules/cjkcodecs/_codecs_cn.c @@ -361,11 +361,13 @@ ENCODER(hz) NEXT_OUT(2); state->c[CN_STATE_OFFSET] = 0; } - WRITEBYTE1((unsigned char)c); - NEXT(1, 1); if (c == '~') { - WRITEBYTE1('~'); - NEXT_OUT(1); + WRITEBYTE2('~', '~'); + NEXT(1, 2); + } + else { + WRITEBYTE1((unsigned char)c); + NEXT(1, 1); } continue; } @@ -414,9 +416,9 @@ DECODER(hz) Py_UCS4 decoded; if (c == '~') { + REQUIRE_INBUF(2); unsigned char c2 = INBYTE2; - REQUIRE_INBUF(2); if (c2 == '~' && state->c[CN_STATE_OFFSET] == 0) OUTCHAR('~'); else if (c2 == '{' && state->c[CN_STATE_OFFSET] == 0) diff --git a/Modules/cjkcodecs/_codecs_hk.c b/Modules/cjkcodecs/_codecs_hk.c index e7273bf18e34941..0e0c5670238555b 100644 --- a/Modules/cjkcodecs/_codecs_hk.c +++ b/Modules/cjkcodecs/_codecs_hk.c @@ -62,7 +62,7 @@ ENCODER(big5hkscs) else c2 = 0; - if (inlen - *inpos >= 2 && + if (inlen - *inpos >= 2 && c2 <= 0xffff && ((c & 0xffdf) == 0x00ca) && ((c2 & 0xfff7) == 0x0304)) { code = big5hkscs_pairenc_table[ diff --git a/Modules/cjkcodecs/_codecs_iso2022.c b/Modules/cjkcodecs/_codecs_iso2022.c index b1984df2695b172..f0cba62e8773877 100644 --- a/Modules/cjkcodecs/_codecs_iso2022.c +++ b/Modules/cjkcodecs/_codecs_iso2022.c @@ -174,9 +174,8 @@ ENCODER_RESET(iso2022) if (STATE_G0 != CHARSET_ASCII) { WRITEBYTE3(ESC, '(', 'B'); NEXT_OUT(3); - STATE_SETG0(CHARSET_ASCII); } - return 0; + return iso2022_encode_init(state, codec); } ENCODER(iso2022) @@ -311,9 +310,7 @@ DECODER_INIT(iso2022) DECODER_RESET(iso2022) { - STATE_SETG0(CHARSET_ASCII); - STATE_CLEARFLAG(F_SHIFTED); - return 0; + return iso2022_decode_init(state, codec); } static Py_ssize_t @@ -382,17 +379,22 @@ iso2022processesc(const MultibyteCodec *codec, MultibyteCodec_State *state, return esclen; } - /* raise error when the charset is not designated for this encoding */ + /* raise error when the charset is not designated to this plane for + * this encoding (ASCII is only ever designated to G0) */ if (charset != CHARSET_ASCII) { const struct iso2022_designation *dsg; for (dsg = CONFIG_DESIGNATIONS; dsg->mark; dsg++) { - if (dsg->mark == charset) + if (dsg->mark == charset && dsg->plane == designation) { break; + } } if (!dsg->mark) return esclen; } + else if (designation != 0) { + return esclen; + } STATE_SETG(designation, charset); *inleft -= esclen; @@ -533,15 +535,16 @@ DECODER(iso2022) dsg = dsgcache; else { for (dsg = CONFIG_DESIGNATIONS; - dsg->mark != charset -#ifdef Py_DEBUG - && dsg->mark != '\0' -#endif - ; dsg++) + dsg->mark != charset && dsg->mark != '\0'; + dsg++) { /* noop */ } - assert(dsg->mark != '\0'); + if (dsg->mark == '\0') { + /* Unknown charset designation from a corrupt + setstate(); no width to trust, report one byte. */ + return 1; + } dsgcache = dsg; } @@ -803,7 +806,7 @@ jisx0213_encoder(const MultibyteCodec *codec, const Py_UCS4 *data, case 2: /* second character of unicode pair */ if (data[1] != 0) { /* Don't consume null char as part of pair */ - coded = find_pairencmap((ucs2_t)data[0], (ucs2_t)data[1], + coded = find_pairencmap((ucs2_t)data[0], data[1], jisx0213_pair_encmap, JISX0213_ENCPAIRS); if (coded != DBCINV) { return coded; diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h index 9d86396f73b2b55..759ebfc08bd4fcd 100644 --- a/Modules/cjkcodecs/cjkcodecs.h +++ b/Modules/cjkcodecs/cjkcodecs.h @@ -155,15 +155,15 @@ get_module_state(PyObject *mod) #define OUTCHAR(c) \ do { \ - if (_PyUnicodeWriter_WriteChar(writer, (c)) < 0) \ - return MBERR_EXCEPTION; \ + if (_PyUnicodeWriter_WriteCharInline(writer, (c)) < 0) \ + return MBERR_EXCEPTION; \ } while (0) #define OUTCHAR2(c1, c2) \ do { \ Py_UCS4 _c1 = (c1); \ Py_UCS4 _c2 = (c2); \ - if (_PyUnicodeWriter_Prepare(writer, 2, Py_MAX(_c1, c2)) < 0) \ + if (_PyUnicodeWriter_Prepare(writer, 2, Py_MAX(_c1, _c2)) < 0) \ return MBERR_EXCEPTION; \ PyUnicode_WRITE(writer->kind, writer->data, writer->pos, _c1); \ PyUnicode_WRITE(writer->kind, writer->data, writer->pos + 1, _c2); \ @@ -237,6 +237,7 @@ add_mappings(cjkcodecs_module_state *st) \ st->num_mappings = NUM; \ st->mapping_list = PyMem_Calloc(NUM, sizeof(struct dbcs_map)); \ if (st->mapping_list == NULL) { \ + PyErr_NoMemory(); \ return -1; \ } @@ -261,6 +262,7 @@ add_codecs(cjkcodecs_module_state *st) \ st->num_codecs = NUM; \ st->codec_list = PyMem_Calloc(NUM, sizeof(MultibyteCodec)); \ if (st->codec_list == NULL) { \ + PyErr_NoMemory(); \ return -1; \ } @@ -406,10 +408,13 @@ register_maps(PyObject *module) #ifdef USING_BINARY_PAIR_SEARCH static DBCHAR -find_pairencmap(ucs2_t body, ucs2_t modifier, +find_pairencmap(ucs2_t body, Py_UCS4 modifier, const struct pair_encodemap *haystack, int haystacksize) { int pos, min, max; + if (modifier > 0xffff) { + return DBCINV; + } Py_UCS4 value = body << 16 | modifier; min = 0; diff --git a/Modules/cjkcodecs/clinic/multibytecodec.c.h b/Modules/cjkcodecs/clinic/multibytecodec.c.h index 32588b0561e1acc..1229a0fb48fe95b 100644 --- a/Modules/cjkcodecs/clinic/multibytecodec.c.h +++ b/Modules/cjkcodecs/clinic/multibytecodec.c.h @@ -7,6 +7,7 @@ preserve # include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(_multibytecodec_MultibyteCodec_encode__doc__, "encode($self, /, input, errors=None)\n" @@ -77,15 +78,10 @@ _multibytecodec_MultibyteCodec_encode(PyObject *self, PyObject *const *args, Py_ errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("encode", "argument 'errors'", "str or None", args[1]); @@ -169,15 +165,10 @@ _multibytecodec_MultibyteCodec_decode(PyObject *self, PyObject *const *args, Py_ errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("decode", "argument 'errors'", "str or None", args[1]); @@ -596,25 +587,12 @@ static PyObject * _multibytecodec_MultibyteStreamWriter_write(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "write", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *strobj; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("write", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("write", nargs, 1, 1)) { goto exit; } strobj = args[0]; @@ -641,25 +619,12 @@ static PyObject * _multibytecodec_MultibyteStreamWriter_writelines(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "writelines", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *lines; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("writelines", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("writelines", nargs, 1, 1)) { goto exit; } lines = args[0]; @@ -698,4 +663,4 @@ PyDoc_STRVAR(_multibytecodec___create_codec__doc__, #define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \ {"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__}, -/*[clinic end generated code: output=a84b1544d7d01abb input=a9049054013a1b77]*/ +/*[clinic end generated code: output=20fec21d79e87a15 input=a9049054013a1b77]*/ diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index 32c96c9d2cb3cde..ba3c70c998f6a93 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -82,7 +82,8 @@ typedef struct { PyObject *inobj; Py_ssize_t inpos, inlen; unsigned char *outbuf, *outbuf_end; - PyObject *excobj, *outobj; + PyObject *excobj; + PyBytesWriter *writer; } MultibyteEncodeBuffer; typedef struct { @@ -209,8 +210,8 @@ expand_encodebuffer(MultibyteEncodeBuffer *buf, Py_ssize_t esize) Py_ssize_t orgpos, orgsize, incsize; orgpos = (Py_ssize_t)((char *)buf->outbuf - - PyBytes_AS_STRING(buf->outobj)); - orgsize = PyBytes_GET_SIZE(buf->outobj); + (char *)PyBytesWriter_GetData(buf->writer)); + orgsize = PyBytesWriter_GetSize(buf->writer); incsize = (esize < (orgsize >> 1) ? (orgsize >> 1) | 1 : esize); if (orgsize > PY_SSIZE_T_MAX - incsize) { @@ -218,12 +219,12 @@ expand_encodebuffer(MultibyteEncodeBuffer *buf, Py_ssize_t esize) return -1; } - if (_PyBytes_Resize(&buf->outobj, orgsize + incsize) == -1) + if (PyBytesWriter_Resize(buf->writer, orgsize + incsize) == -1) return -1; - buf->outbuf = (unsigned char *)PyBytes_AS_STRING(buf->outobj) +orgpos; - buf->outbuf_end = (unsigned char *)PyBytes_AS_STRING(buf->outobj) - + PyBytes_GET_SIZE(buf->outobj); + unsigned char *data = PyBytesWriter_GetData(buf->writer); + buf->outbuf = data + orgpos; + buf->outbuf_end = data + PyBytesWriter_GetSize(buf->writer); return 0; } @@ -429,8 +430,8 @@ multibytecodec_decerror(const MultibyteCodec *codec, } if (errors == ERROR_REPLACE) { - if (_PyUnicodeWriter_WriteChar(&buf->writer, - Py_UNICODE_REPLACEMENT_CHARACTER) < 0) + if (_PyUnicodeWriter_WriteCharInline( + &buf->writer, Py_UNICODE_REPLACEMENT_CHARACTER) < 0) goto errorexit; } if (errors == ERROR_IGNORE || errors == ERROR_REPLACE) { @@ -503,7 +504,7 @@ multibytecodec_encode(const MultibyteCodec *codec, PyObject *errors, int flags) { MultibyteEncodeBuffer buf; - Py_ssize_t finalsize, r = 0; + Py_ssize_t r = 0; Py_ssize_t datalen; int kind; const void *data; @@ -511,10 +512,15 @@ multibytecodec_encode(const MultibyteCodec *codec, datalen = PyUnicode_GET_LENGTH(text); if (datalen == 0 && !(flags & MBENC_RESET)) - return PyBytes_FromStringAndSize(NULL, 0); + return Py_GetConstant(Py_CONSTANT_EMPTY_BYTES); + + /* A callback may change a stateful encoder's errors attribute. */ + if (ERROR_ISCUSTOM(errors)) { + Py_INCREF(errors); + } buf.excobj = NULL; - buf.outobj = NULL; + buf.writer = NULL; buf.inobj = text; /* borrowed reference */ buf.inpos = 0; buf.inlen = datalen; @@ -526,11 +532,11 @@ multibytecodec_encode(const MultibyteCodec *codec, goto errorexit; } - buf.outobj = PyBytes_FromStringAndSize(NULL, datalen * 2 + 16); - if (buf.outobj == NULL) + buf.writer = PyBytesWriter_Create(datalen * 2 + 16); + if (buf.writer == NULL) goto errorexit; - buf.outbuf = (unsigned char *)PyBytes_AS_STRING(buf.outobj); - buf.outbuf_end = buf.outbuf + PyBytes_GET_SIZE(buf.outobj); + buf.outbuf = (unsigned char *)PyBytesWriter_GetData(buf.writer); + buf.outbuf_end = buf.outbuf + PyBytesWriter_GetSize(buf.writer); while (buf.inpos < buf.inlen) { /* we don't reuse inleft and outleft here. @@ -563,21 +569,16 @@ multibytecodec_encode(const MultibyteCodec *codec, goto errorexit; } - finalsize = (Py_ssize_t)((char *)buf.outbuf - - PyBytes_AS_STRING(buf.outobj)); - - if (finalsize != PyBytes_GET_SIZE(buf.outobj)) - if (_PyBytes_Resize(&buf.outobj, finalsize) == -1) - goto errorexit; - if (inpos_t) *inpos_t = buf.inpos; Py_XDECREF(buf.excobj); - return buf.outobj; + ERROR_DECREF(errors); + return PyBytesWriter_FinishWithPointer(buf.writer, buf.outbuf); errorexit: Py_XDECREF(buf.excobj); - Py_XDECREF(buf.outobj); + ERROR_DECREF(errors); + PyBytesWriter_Discard(buf.writer); return NULL; } @@ -793,6 +794,7 @@ encoder_encode_stateful(MultibyteStatefulEncoderContext *ctx, PyObject *inbuf = NULL; Py_ssize_t inpos, datalen; PyObject *origpending = NULL; + MultibyteCodec_State origstate; if (PyUnicode_Check(unistr)) ucvt = NULL; @@ -808,6 +810,7 @@ encoder_encode_stateful(MultibyteStatefulEncoderContext *ctx, } } + origstate = ctx->state; if (ctx->pending) { PyObject *inbuf_tmp; @@ -865,6 +868,9 @@ encoder_encode_stateful(MultibyteStatefulEncoderContext *ctx, return r; errorexit: + /* recover the original codec state: the discarded output may have + * included an escape sequence for a state change */ + ctx->state = origstate; Py_XDECREF(r); Py_XDECREF(ucvt); Py_XDECREF(origpending); @@ -1107,7 +1113,7 @@ mbiencoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds) self->codec->encinit(&self->state, self->codec) != 0) goto errorexit; - Py_DECREF(codec); + self->codec_owner = codec; return (PyObject *)self; errorexit: @@ -1128,6 +1134,7 @@ mbiencoder_traverse(PyObject *op, visitproc visit, void *arg) MultibyteIncrementalEncoderObject *self = _MultibyteIncrementalEncoderObject_CAST(op); if (ERROR_ISCUSTOM(self->errors)) Py_VISIT(self->errors); + Py_VISIT(self->codec_owner); return 0; } @@ -1139,6 +1146,7 @@ mbiencoder_dealloc(PyObject *op) PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); Py_CLEAR(self->pending); + Py_XDECREF(self->codec_owner); tp->tp_free(self); Py_DECREF(tp); } @@ -1390,7 +1398,7 @@ mbidecoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds) self->codec->decinit(&self->state, self->codec) != 0) goto errorexit; - Py_DECREF(codec); + self->codec_owner = codec; return (PyObject *)self; errorexit: @@ -1411,6 +1419,7 @@ mbidecoder_traverse(PyObject *op, visitproc visit, void *arg) MultibyteIncrementalDecoderObject *self = _MultibyteIncrementalDecoderObject_CAST(op); if (ERROR_ISCUSTOM(self->errors)) Py_VISIT(self->errors); + Py_VISIT(self->codec_owner); return 0; } @@ -1421,6 +1430,7 @@ mbidecoder_dealloc(PyObject *op) PyTypeObject *tp = Py_TYPE(self); PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); + Py_XDECREF(self->codec_owner); tp->tp_free(self); Py_DECREF(tp); } @@ -1482,23 +1492,25 @@ mbstreamreader_iread(MultibyteStreamReaderObject *self, endoffile = (PyBytes_GET_SIZE(cres) == 0); if (self->pendingsize > 0) { - PyObject *ctr; - char *ctrdata; - if (PyBytes_GET_SIZE(cres) > PY_SSIZE_T_MAX - self->pendingsize) { PyErr_NoMemory(); goto errorexit; } rsize = PyBytes_GET_SIZE(cres) + self->pendingsize; - ctr = PyBytes_FromStringAndSize(NULL, rsize); - if (ctr == NULL) + + PyBytesWriter *writer = PyBytesWriter_Create(rsize); + if (writer == NULL) { goto errorexit; - ctrdata = PyBytes_AS_STRING(ctr); + } + char *ctrdata = PyBytesWriter_GetData(writer); memcpy(ctrdata, self->pending, self->pendingsize); memcpy(ctrdata + self->pendingsize, PyBytes_AS_STRING(cres), PyBytes_GET_SIZE(cres)); - Py_SETREF(cres, ctr); + Py_SETREF(cres, PyBytesWriter_Finish(writer)); + if (cres == NULL) { + goto errorexit; + } self->pendingsize = 0; } @@ -1707,7 +1719,7 @@ mbstreamreader_new(PyTypeObject *type, PyObject *args, PyObject *kwds) self->codec->decinit(&self->state, self->codec) != 0) goto errorexit; - Py_DECREF(codec); + self->codec_owner = codec; return (PyObject *)self; errorexit: @@ -1729,6 +1741,7 @@ mbstreamreader_traverse(PyObject *op, visitproc visit, void *arg) if (ERROR_ISCUSTOM(self->errors)) Py_VISIT(self->errors); Py_VISIT(self->stream); + Py_VISIT(self->codec_owner); return 0; } @@ -1740,6 +1753,7 @@ mbstreamreader_dealloc(PyObject *op) PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); Py_XDECREF(self->stream); + Py_XDECREF(self->codec_owner); tp->tp_free(self); Py_DECREF(tp); } @@ -1861,13 +1875,17 @@ _multibytecodec_MultibyteStreamWriter_reset_impl(MultibyteStreamWriterObject *se PyTypeObject *cls) /*[clinic end generated code: output=32ef224c2a38aa3d input=28af6a9cd38d1979]*/ { - PyObject *pwrt; + PyObject *pwrt, *pending; - if (!self->pending) - Py_RETURN_NONE; + /* even without pending characters, a stateful codec may have to + * write a sequence that returns the output to its initial state */ + pending = self->pending; + if (pending == NULL) { + pending = Py_GetConstantBorrowed(Py_CONSTANT_EMPTY_STR); + } pwrt = multibytecodec_encode(self->codec, &self->state, - self->pending, NULL, self->errors, + pending, NULL, self->errors, MBENC_FLUSH | MBENC_RESET); /* some pending buffer can be truncated when UnicodeEncodeError is * raised on 'strict' mode. but, 'reset' method is designed to @@ -1890,6 +1908,7 @@ _multibytecodec_MultibyteStreamWriter_reset_impl(MultibyteStreamWriterObject *se Py_DECREF(pwrt); return NULL; } + Py_DECREF(wr); } Py_DECREF(pwrt); @@ -1931,7 +1950,7 @@ mbstreamwriter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) self->codec->encinit(&self->state, self->codec) != 0) goto errorexit; - Py_DECREF(codec); + self->codec_owner = codec; return (PyObject *)self; errorexit: @@ -1953,6 +1972,7 @@ mbstreamwriter_traverse(PyObject *op, visitproc visit, void *arg) if (ERROR_ISCUSTOM(self->errors)) Py_VISIT(self->errors); Py_VISIT(self->stream); + Py_VISIT(self->codec_owner); return 0; } @@ -1964,6 +1984,7 @@ mbstreamwriter_dealloc(PyObject *op) PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); Py_XDECREF(self->stream); + Py_XDECREF(self->codec_owner); tp->tp_free(self); Py_DECREF(tp); } diff --git a/Modules/cjkcodecs/multibytecodec.h b/Modules/cjkcodecs/multibytecodec.h index 5b85e2e3de316dc..bacd6e1078b6857 100644 --- a/Modules/cjkcodecs/multibytecodec.h +++ b/Modules/cjkcodecs/multibytecodec.h @@ -77,6 +77,7 @@ typedef struct { #define _MultibyteStatefulCodec_HEAD \ PyObject_HEAD \ const MultibyteCodec *codec; \ + PyObject *codec_owner; \ MultibyteCodec_State state; \ PyObject *errors; typedef struct { @@ -91,7 +92,8 @@ typedef struct { _MultibyteStatefulEncoder_HEAD } MultibyteStatefulEncoderContext; -#define MAXDECPENDING 8 +/* ISO-2022 may retain an incomplete escape sequence up to 15 bytes. */ +#define MAXDECPENDING 16 #define _MultibyteStatefulDecoder_HEAD \ _MultibyteStatefulCodec_HEAD \ unsigned char pending[MAXDECPENDING]; \ diff --git a/Modules/clinic/_abc.c.h b/Modules/clinic/_abc.c.h index fa1c57dc26bf853..8fdce59468e5304 100644 --- a/Modules/clinic/_abc.c.h +++ b/Modules/clinic/_abc.c.h @@ -140,6 +140,18 @@ _abc__abc_subclasscheck(PyObject *module, PyObject *const *args, Py_ssize_t narg return return_value; } +PyDoc_STRVAR(_abc__set_subclasscheck__doc__, +"_set_subclasscheck($module, func, /)\n" +"--\n" +"\n" +"Internal ABC helper to register ABCMeta.__subclasscheck__.\n" +"\n" +"Classes whose metaclass resolves __subclasscheck__ to func are checked\n" +"natively when walking the subclass tree of an ABC."); + +#define _ABC__SET_SUBCLASSCHECK_METHODDEF \ + {"_set_subclasscheck", (PyCFunction)_abc__set_subclasscheck, METH_O, _abc__set_subclasscheck__doc__}, + PyDoc_STRVAR(_abc_get_cache_token__doc__, "get_cache_token($module, /)\n" "--\n" @@ -161,4 +173,4 @@ _abc_get_cache_token(PyObject *module, PyObject *Py_UNUSED(ignored)) { return _abc_get_cache_token_impl(module); } -/*[clinic end generated code: output=b05d599656aeb1e1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=5d71c05c399149c5 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_asynciomodule.c.h b/Modules/clinic/_asynciomodule.c.h index 8bbef6b50231250..c44e9f01bfcbc67 100644 --- a/Modules/clinic/_asynciomodule.c.h +++ b/Modules/clinic/_asynciomodule.c.h @@ -4,10 +4,10 @@ preserve #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) # include "pycore_gc.h" // PyGC_Head -# include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_runtime.h" // _Py_SINGLETON() PyDoc_STRVAR(_asyncio_Future___init____doc__, "Future(*, loop=None)\n" @@ -30,7 +30,8 @@ static int _asyncio_Future___init___impl(FutureObj *self, PyObject *loop); static int -_asyncio_Future___init__(PyObject *self, PyObject *args, PyObject *kwargs) +_asyncio_Future___init___helper(PyObject *self, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { int return_value = -1; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -62,11 +63,10 @@ _asyncio_Future___init__(PyObject *self, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[1]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; + Py_ssize_t noptargs = nargs + nkw - 0; PyObject *loop = Py_None; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -82,6 +82,42 @@ _asyncio_Future___init__(PyObject *self, PyObject *args, PyObject *kwargs) return return_value; } +static int +_asyncio_Future___init__(PyObject *self, PyObject *args, PyObject *kwargs) +{ + return _asyncio_Future___init___helper(self, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +_asyncio_Future_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *self; + int _result; + + assert(_PyType_CAST(type)->tp_init == _asyncio_Future___init__); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + self = _PyType_CAST(type)->tp_new(_PyType_CAST(type), + (PyObject *)&_Py_SINGLETON(tuple_empty), NULL); + if (self == NULL) { + return NULL; + } + _result = _asyncio_Future___init___helper(self, args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + if (_result != 0) { + Py_DECREF(self); + return NULL; + } + return self; +} + PyDoc_STRVAR(_asyncio_Future_result__doc__, "result($self, /)\n" "--\n" @@ -165,25 +201,12 @@ static PyObject * _asyncio_Future_set_result(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "set_result", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *result; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("set_result", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("set_result", nargs, 1, 1)) { goto exit; } result = args[0]; @@ -215,25 +238,12 @@ static PyObject * _asyncio_Future_set_exception(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "set_exception", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *exception; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("set_exception", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("set_exception", nargs, 1, 1)) { goto exit; } exception = args[0]; @@ -336,25 +346,12 @@ static PyObject * _asyncio_Future_remove_done_callback(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "remove_done_callback", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *fn; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("remove_done_callback", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("remove_done_callback", nargs, 1, 1)) { goto exit; } fn = args[0]; @@ -516,16 +513,6 @@ _asyncio_Future_get_loop(PyObject *self, PyTypeObject *cls, PyObject *const *arg return return_value; } -#if !defined(_asyncio_Future__asyncio_awaited_by_DOCSTR) -# define _asyncio_Future__asyncio_awaited_by_DOCSTR NULL -#endif -#if defined(_ASYNCIO_FUTURE__ASYNCIO_AWAITED_BY_GETSETDEF) -# undef _ASYNCIO_FUTURE__ASYNCIO_AWAITED_BY_GETSETDEF -# define _ASYNCIO_FUTURE__ASYNCIO_AWAITED_BY_GETSETDEF {"_asyncio_awaited_by", (getter)_asyncio_Future__asyncio_awaited_by_get, (setter)_asyncio_Future__asyncio_awaited_by_set, _asyncio_Future__asyncio_awaited_by_DOCSTR}, -#else -# define _ASYNCIO_FUTURE__ASYNCIO_AWAITED_BY_GETSETDEF {"_asyncio_awaited_by", (getter)_asyncio_Future__asyncio_awaited_by_get, NULL, _asyncio_Future__asyncio_awaited_by_DOCSTR}, -#endif - static PyObject * _asyncio_Future__asyncio_awaited_by_get_impl(FutureObj *self); @@ -541,117 +528,102 @@ _asyncio_Future__asyncio_awaited_by_get(PyObject *self, void *Py_UNUSED(context) return return_value; } -#if !defined(_asyncio_Future__asyncio_future_blocking_DOCSTR) -# define _asyncio_Future__asyncio_future_blocking_DOCSTR NULL -#endif -#if defined(_ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF) -# undef _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF -# define _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF {"_asyncio_future_blocking", (getter)_asyncio_Future__asyncio_future_blocking_get, (setter)_asyncio_Future__asyncio_future_blocking_set, _asyncio_Future__asyncio_future_blocking_DOCSTR}, -#else -# define _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF {"_asyncio_future_blocking", (getter)_asyncio_Future__asyncio_future_blocking_get, NULL, _asyncio_Future__asyncio_future_blocking_DOCSTR}, -#endif - -static PyObject * +static int _asyncio_Future__asyncio_future_blocking_get_impl(FutureObj *self); static PyObject * _asyncio_Future__asyncio_future_blocking_get(PyObject *self, void *Py_UNUSED(context)) { PyObject *return_value = NULL; + int _return_value; Py_BEGIN_CRITICAL_SECTION(self); - return_value = _asyncio_Future__asyncio_future_blocking_get_impl((FutureObj *)self); + _return_value = _asyncio_Future__asyncio_future_blocking_get_impl((FutureObj *)self); Py_END_CRITICAL_SECTION(); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); +exit: return return_value; } -#if !defined(_asyncio_Future__asyncio_future_blocking_DOCSTR) -# define _asyncio_Future__asyncio_future_blocking_DOCSTR NULL -#endif -#if defined(_ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF) -# undef _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF -# define _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF {"_asyncio_future_blocking", (getter)_asyncio_Future__asyncio_future_blocking_get, (setter)_asyncio_Future__asyncio_future_blocking_set, _asyncio_Future__asyncio_future_blocking_DOCSTR}, -#else -# define _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF {"_asyncio_future_blocking", NULL, (setter)_asyncio_Future__asyncio_future_blocking_set, NULL}, -#endif - static int -_asyncio_Future__asyncio_future_blocking_set_impl(FutureObj *self, - PyObject *value); +_asyncio_Future__asyncio_future_blocking_set_impl(FutureObj *self, int value); static int -_asyncio_Future__asyncio_future_blocking_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_asyncio_Future__asyncio_future_blocking_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + int value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute '_asyncio_future_blocking' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = PyObject_IsTrue(arg); + if (value < 0) { + goto exit; + } Py_BEGIN_CRITICAL_SECTION(self); return_value = _asyncio_Future__asyncio_future_blocking_set_impl((FutureObj *)self, value); Py_END_CRITICAL_SECTION(); +exit: return return_value; } -#if !defined(_asyncio_Future__log_traceback_DOCSTR) -# define _asyncio_Future__log_traceback_DOCSTR NULL -#endif -#if defined(_ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF) -# undef _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF -# define _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF {"_log_traceback", (getter)_asyncio_Future__log_traceback_get, (setter)_asyncio_Future__log_traceback_set, _asyncio_Future__log_traceback_DOCSTR}, -#else -# define _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF {"_log_traceback", (getter)_asyncio_Future__log_traceback_get, NULL, _asyncio_Future__log_traceback_DOCSTR}, -#endif - -static PyObject * +static int _asyncio_Future__log_traceback_get_impl(FutureObj *self); static PyObject * _asyncio_Future__log_traceback_get(PyObject *self, void *Py_UNUSED(context)) { PyObject *return_value = NULL; + int _return_value; Py_BEGIN_CRITICAL_SECTION(self); - return_value = _asyncio_Future__log_traceback_get_impl((FutureObj *)self); + _return_value = _asyncio_Future__log_traceback_get_impl((FutureObj *)self); Py_END_CRITICAL_SECTION(); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); +exit: return return_value; } -#if !defined(_asyncio_Future__log_traceback_DOCSTR) -# define _asyncio_Future__log_traceback_DOCSTR NULL -#endif -#if defined(_ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF) -# undef _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF -# define _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF {"_log_traceback", (getter)_asyncio_Future__log_traceback_get, (setter)_asyncio_Future__log_traceback_set, _asyncio_Future__log_traceback_DOCSTR}, -#else -# define _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF {"_log_traceback", NULL, (setter)_asyncio_Future__log_traceback_set, NULL}, -#endif - static int -_asyncio_Future__log_traceback_set_impl(FutureObj *self, PyObject *value); +_asyncio_Future__log_traceback_set_impl(FutureObj *self, int value); static int -_asyncio_Future__log_traceback_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_asyncio_Future__log_traceback_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + int value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute '_log_traceback' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = PyObject_IsTrue(arg); + if (value < 0) { + goto exit; + } Py_BEGIN_CRITICAL_SECTION(self); return_value = _asyncio_Future__log_traceback_set_impl((FutureObj *)self, value); Py_END_CRITICAL_SECTION(); +exit: return return_value; } -#if !defined(_asyncio_Future__loop_DOCSTR) -# define _asyncio_Future__loop_DOCSTR NULL -#endif -#if defined(_ASYNCIO_FUTURE__LOOP_GETSETDEF) -# undef _ASYNCIO_FUTURE__LOOP_GETSETDEF -# define _ASYNCIO_FUTURE__LOOP_GETSETDEF {"_loop", (getter)_asyncio_Future__loop_get, (setter)_asyncio_Future__loop_set, _asyncio_Future__loop_DOCSTR}, -#else -# define _ASYNCIO_FUTURE__LOOP_GETSETDEF {"_loop", (getter)_asyncio_Future__loop_get, NULL, _asyncio_Future__loop_DOCSTR}, -#endif - static PyObject * _asyncio_Future__loop_get_impl(FutureObj *self); @@ -667,16 +639,6 @@ _asyncio_Future__loop_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_asyncio_Future__callbacks_DOCSTR) -# define _asyncio_Future__callbacks_DOCSTR NULL -#endif -#if defined(_ASYNCIO_FUTURE__CALLBACKS_GETSETDEF) -# undef _ASYNCIO_FUTURE__CALLBACKS_GETSETDEF -# define _ASYNCIO_FUTURE__CALLBACKS_GETSETDEF {"_callbacks", (getter)_asyncio_Future__callbacks_get, (setter)_asyncio_Future__callbacks_set, _asyncio_Future__callbacks_DOCSTR}, -#else -# define _ASYNCIO_FUTURE__CALLBACKS_GETSETDEF {"_callbacks", (getter)_asyncio_Future__callbacks_get, NULL, _asyncio_Future__callbacks_DOCSTR}, -#endif - static PyObject * _asyncio_Future__callbacks_get_impl(FutureObj *self); @@ -692,16 +654,6 @@ _asyncio_Future__callbacks_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_asyncio_Future__result_DOCSTR) -# define _asyncio_Future__result_DOCSTR NULL -#endif -#if defined(_ASYNCIO_FUTURE__RESULT_GETSETDEF) -# undef _ASYNCIO_FUTURE__RESULT_GETSETDEF -# define _ASYNCIO_FUTURE__RESULT_GETSETDEF {"_result", (getter)_asyncio_Future__result_get, (setter)_asyncio_Future__result_set, _asyncio_Future__result_DOCSTR}, -#else -# define _ASYNCIO_FUTURE__RESULT_GETSETDEF {"_result", (getter)_asyncio_Future__result_get, NULL, _asyncio_Future__result_DOCSTR}, -#endif - static PyObject * _asyncio_Future__result_get_impl(FutureObj *self); @@ -717,16 +669,6 @@ _asyncio_Future__result_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_asyncio_Future__exception_DOCSTR) -# define _asyncio_Future__exception_DOCSTR NULL -#endif -#if defined(_ASYNCIO_FUTURE__EXCEPTION_GETSETDEF) -# undef _ASYNCIO_FUTURE__EXCEPTION_GETSETDEF -# define _ASYNCIO_FUTURE__EXCEPTION_GETSETDEF {"_exception", (getter)_asyncio_Future__exception_get, (setter)_asyncio_Future__exception_set, _asyncio_Future__exception_DOCSTR}, -#else -# define _ASYNCIO_FUTURE__EXCEPTION_GETSETDEF {"_exception", (getter)_asyncio_Future__exception_get, NULL, _asyncio_Future__exception_DOCSTR}, -#endif - static PyObject * _asyncio_Future__exception_get_impl(FutureObj *self); @@ -742,16 +684,6 @@ _asyncio_Future__exception_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_asyncio_Future__source_traceback_DOCSTR) -# define _asyncio_Future__source_traceback_DOCSTR NULL -#endif -#if defined(_ASYNCIO_FUTURE__SOURCE_TRACEBACK_GETSETDEF) -# undef _ASYNCIO_FUTURE__SOURCE_TRACEBACK_GETSETDEF -# define _ASYNCIO_FUTURE__SOURCE_TRACEBACK_GETSETDEF {"_source_traceback", (getter)_asyncio_Future__source_traceback_get, (setter)_asyncio_Future__source_traceback_set, _asyncio_Future__source_traceback_DOCSTR}, -#else -# define _ASYNCIO_FUTURE__SOURCE_TRACEBACK_GETSETDEF {"_source_traceback", (getter)_asyncio_Future__source_traceback_get, NULL, _asyncio_Future__source_traceback_DOCSTR}, -#endif - static PyObject * _asyncio_Future__source_traceback_get_impl(FutureObj *self); @@ -767,16 +699,6 @@ _asyncio_Future__source_traceback_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_asyncio_Future__cancel_message_DOCSTR) -# define _asyncio_Future__cancel_message_DOCSTR NULL -#endif -#if defined(_ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF) -# undef _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF -# define _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF {"_cancel_message", (getter)_asyncio_Future__cancel_message_get, (setter)_asyncio_Future__cancel_message_set, _asyncio_Future__cancel_message_DOCSTR}, -#else -# define _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF {"_cancel_message", (getter)_asyncio_Future__cancel_message_get, NULL, _asyncio_Future__cancel_message_DOCSTR}, -#endif - static PyObject * _asyncio_Future__cancel_message_get_impl(FutureObj *self); @@ -792,24 +714,22 @@ _asyncio_Future__cancel_message_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_asyncio_Future__cancel_message_DOCSTR) -# define _asyncio_Future__cancel_message_DOCSTR NULL -#endif -#if defined(_ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF) -# undef _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF -# define _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF {"_cancel_message", (getter)_asyncio_Future__cancel_message_get, (setter)_asyncio_Future__cancel_message_set, _asyncio_Future__cancel_message_DOCSTR}, -#else -# define _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF {"_cancel_message", NULL, (setter)_asyncio_Future__cancel_message_set, NULL}, -#endif - static int _asyncio_Future__cancel_message_set_impl(FutureObj *self, PyObject *value); static int -_asyncio_Future__cancel_message_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_asyncio_Future__cancel_message_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + PyObject *value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute '_cancel_message' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = _asyncio_Future__cancel_message_set_impl((FutureObj *)self, value); Py_END_CRITICAL_SECTION(); @@ -817,16 +737,6 @@ _asyncio_Future__cancel_message_set(PyObject *self, PyObject *value, void *Py_UN return return_value; } -#if !defined(_asyncio_Future__state_DOCSTR) -# define _asyncio_Future__state_DOCSTR NULL -#endif -#if defined(_ASYNCIO_FUTURE__STATE_GETSETDEF) -# undef _ASYNCIO_FUTURE__STATE_GETSETDEF -# define _ASYNCIO_FUTURE__STATE_GETSETDEF {"_state", (getter)_asyncio_Future__state_get, (setter)_asyncio_Future__state_set, _asyncio_Future__state_DOCSTR}, -#else -# define _ASYNCIO_FUTURE__STATE_GETSETDEF {"_state", (getter)_asyncio_Future__state_get, NULL, _asyncio_Future__state_DOCSTR}, -#endif - static PyObject * _asyncio_Future__state_get_impl(FutureObj *self); @@ -881,7 +791,8 @@ _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop, int eager_start); static int -_asyncio_Task___init__(PyObject *self, PyObject *args, PyObject *kwargs) +_asyncio_Task___init___helper(PyObject *self, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { int return_value = -1; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -913,15 +824,14 @@ _asyncio_Task___init__(PyObject *self, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[5]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + Py_ssize_t noptargs = nargs + nkw - 1; PyObject *coro; PyObject *loop = Py_None; PyObject *name = Py_None; PyObject *context = Py_None; int eager_start = 0; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -959,66 +869,90 @@ _asyncio_Task___init__(PyObject *self, PyObject *args, PyObject *kwargs) return return_value; } -#if !defined(_asyncio_Task__log_destroy_pending_DOCSTR) -# define _asyncio_Task__log_destroy_pending_DOCSTR NULL -#endif -#if defined(_ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF) -# undef _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF -# define _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF {"_log_destroy_pending", (getter)_asyncio_Task__log_destroy_pending_get, (setter)_asyncio_Task__log_destroy_pending_set, _asyncio_Task__log_destroy_pending_DOCSTR}, -#else -# define _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF {"_log_destroy_pending", (getter)_asyncio_Task__log_destroy_pending_get, NULL, _asyncio_Task__log_destroy_pending_DOCSTR}, -#endif +static int +_asyncio_Task___init__(PyObject *self, PyObject *args, PyObject *kwargs) +{ + return _asyncio_Task___init___helper(self, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} static PyObject * +_asyncio_Task_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *self; + int _result; + + assert(_PyType_CAST(type)->tp_init == _asyncio_Task___init__); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + self = _PyType_CAST(type)->tp_new(_PyType_CAST(type), + (PyObject *)&_Py_SINGLETON(tuple_empty), NULL); + if (self == NULL) { + return NULL; + } + _result = _asyncio_Task___init___helper(self, args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + if (_result != 0) { + Py_DECREF(self); + return NULL; + } + return self; +} + +static int _asyncio_Task__log_destroy_pending_get_impl(TaskObj *self); static PyObject * _asyncio_Task__log_destroy_pending_get(PyObject *self, void *Py_UNUSED(context)) { PyObject *return_value = NULL; + int _return_value; Py_BEGIN_CRITICAL_SECTION(self); - return_value = _asyncio_Task__log_destroy_pending_get_impl((TaskObj *)self); + _return_value = _asyncio_Task__log_destroy_pending_get_impl((TaskObj *)self); Py_END_CRITICAL_SECTION(); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); +exit: return return_value; } -#if !defined(_asyncio_Task__log_destroy_pending_DOCSTR) -# define _asyncio_Task__log_destroy_pending_DOCSTR NULL -#endif -#if defined(_ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF) -# undef _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF -# define _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF {"_log_destroy_pending", (getter)_asyncio_Task__log_destroy_pending_get, (setter)_asyncio_Task__log_destroy_pending_set, _asyncio_Task__log_destroy_pending_DOCSTR}, -#else -# define _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF {"_log_destroy_pending", NULL, (setter)_asyncio_Task__log_destroy_pending_set, NULL}, -#endif - static int -_asyncio_Task__log_destroy_pending_set_impl(TaskObj *self, PyObject *value); +_asyncio_Task__log_destroy_pending_set_impl(TaskObj *self, int value); static int -_asyncio_Task__log_destroy_pending_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_asyncio_Task__log_destroy_pending_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + int value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute '_log_destroy_pending' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = PyObject_IsTrue(arg); + if (value < 0) { + goto exit; + } Py_BEGIN_CRITICAL_SECTION(self); return_value = _asyncio_Task__log_destroy_pending_set_impl((TaskObj *)self, value); Py_END_CRITICAL_SECTION(); +exit: return return_value; } -#if !defined(_asyncio_Task__must_cancel_DOCSTR) -# define _asyncio_Task__must_cancel_DOCSTR NULL -#endif -#if defined(_ASYNCIO_TASK__MUST_CANCEL_GETSETDEF) -# undef _ASYNCIO_TASK__MUST_CANCEL_GETSETDEF -# define _ASYNCIO_TASK__MUST_CANCEL_GETSETDEF {"_must_cancel", (getter)_asyncio_Task__must_cancel_get, (setter)_asyncio_Task__must_cancel_set, _asyncio_Task__must_cancel_DOCSTR}, -#else -# define _ASYNCIO_TASK__MUST_CANCEL_GETSETDEF {"_must_cancel", (getter)_asyncio_Task__must_cancel_get, NULL, _asyncio_Task__must_cancel_DOCSTR}, -#endif - static PyObject * _asyncio_Task__must_cancel_get_impl(TaskObj *self); @@ -1034,16 +968,6 @@ _asyncio_Task__must_cancel_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_asyncio_Task__coro_DOCSTR) -# define _asyncio_Task__coro_DOCSTR NULL -#endif -#if defined(_ASYNCIO_TASK__CORO_GETSETDEF) -# undef _ASYNCIO_TASK__CORO_GETSETDEF -# define _ASYNCIO_TASK__CORO_GETSETDEF {"_coro", (getter)_asyncio_Task__coro_get, (setter)_asyncio_Task__coro_set, _asyncio_Task__coro_DOCSTR}, -#else -# define _ASYNCIO_TASK__CORO_GETSETDEF {"_coro", (getter)_asyncio_Task__coro_get, NULL, _asyncio_Task__coro_DOCSTR}, -#endif - static PyObject * _asyncio_Task__coro_get_impl(TaskObj *self); @@ -1059,16 +983,6 @@ _asyncio_Task__coro_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_asyncio_Task__fut_waiter_DOCSTR) -# define _asyncio_Task__fut_waiter_DOCSTR NULL -#endif -#if defined(_ASYNCIO_TASK__FUT_WAITER_GETSETDEF) -# undef _ASYNCIO_TASK__FUT_WAITER_GETSETDEF -# define _ASYNCIO_TASK__FUT_WAITER_GETSETDEF {"_fut_waiter", (getter)_asyncio_Task__fut_waiter_get, (setter)_asyncio_Task__fut_waiter_set, _asyncio_Task__fut_waiter_DOCSTR}, -#else -# define _ASYNCIO_TASK__FUT_WAITER_GETSETDEF {"_fut_waiter", (getter)_asyncio_Task__fut_waiter_get, NULL, _asyncio_Task__fut_waiter_DOCSTR}, -#endif - static PyObject * _asyncio_Task__fut_waiter_get_impl(TaskObj *self); @@ -2234,4 +2148,50 @@ _asyncio_future_discard_from_awaited_by(PyObject *module, PyObject *const *args, exit: return return_value; } -/*[clinic end generated code: output=22e74568ff49f81f input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_asyncio__clear_caches__doc__, +"_clear_caches($module, /)\n" +"--\n" +"\n" +"Clear internal caches. Used for internal tests."); + +#define _ASYNCIO__CLEAR_CACHES_METHODDEF \ + {"_clear_caches", (PyCFunction)_asyncio__clear_caches, METH_NOARGS, _asyncio__clear_caches__doc__}, + +static PyObject * +_asyncio__clear_caches_impl(PyObject *module); + +static PyObject * +_asyncio__clear_caches(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _asyncio__clear_caches_impl(module); +} +#define _ASYNCIO_FUTURE__ASYNCIO_AWAITED_BY_GETSETDEF {"_asyncio_awaited_by", (getter)_asyncio_Future__asyncio_awaited_by_get, (setter)NULL, NULL}, + +#define _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF {"_asyncio_future_blocking", (getter)_asyncio_Future__asyncio_future_blocking_get, (setter)_asyncio_Future__asyncio_future_blocking_set, NULL}, + +#define _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF {"_log_traceback", (getter)_asyncio_Future__log_traceback_get, (setter)_asyncio_Future__log_traceback_set, NULL}, + +#define _ASYNCIO_FUTURE__LOOP_GETSETDEF {"_loop", (getter)_asyncio_Future__loop_get, (setter)NULL, NULL}, + +#define _ASYNCIO_FUTURE__CALLBACKS_GETSETDEF {"_callbacks", (getter)_asyncio_Future__callbacks_get, (setter)NULL, NULL}, + +#define _ASYNCIO_FUTURE__RESULT_GETSETDEF {"_result", (getter)_asyncio_Future__result_get, (setter)NULL, NULL}, + +#define _ASYNCIO_FUTURE__EXCEPTION_GETSETDEF {"_exception", (getter)_asyncio_Future__exception_get, (setter)NULL, NULL}, + +#define _ASYNCIO_FUTURE__SOURCE_TRACEBACK_GETSETDEF {"_source_traceback", (getter)_asyncio_Future__source_traceback_get, (setter)NULL, NULL}, + +#define _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF {"_cancel_message", (getter)_asyncio_Future__cancel_message_get, (setter)_asyncio_Future__cancel_message_set, NULL}, + +#define _ASYNCIO_FUTURE__STATE_GETSETDEF {"_state", (getter)_asyncio_Future__state_get, (setter)NULL, NULL}, + +#define _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF {"_log_destroy_pending", (getter)_asyncio_Task__log_destroy_pending_get, (setter)_asyncio_Task__log_destroy_pending_set, NULL}, + +#define _ASYNCIO_TASK__MUST_CANCEL_GETSETDEF {"_must_cancel", (getter)_asyncio_Task__must_cancel_get, (setter)NULL, NULL}, + +#define _ASYNCIO_TASK__CORO_GETSETDEF {"_coro", (getter)_asyncio_Task__coro_get, (setter)NULL, NULL}, + +#define _ASYNCIO_TASK__FUT_WAITER_GETSETDEF {"_fut_waiter", (getter)_asyncio_Task__fut_waiter_get, (setter)NULL, NULL}, + +/*[clinic end generated code: output=32aeff4f33bb2087 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_codecsmodule.c.h b/Modules/clinic/_codecsmodule.c.h index 788b9b706c8fbb8..0b4ec169a2da149 100644 --- a/Modules/clinic/_codecsmodule.c.h +++ b/Modules/clinic/_codecsmodule.c.h @@ -7,6 +7,7 @@ preserve # include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_modsupport.h" // _PyArg_BadArgument() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(_codecs_register__doc__, "register($module, search_function, /)\n" @@ -55,15 +56,10 @@ _codecs_lookup(PyObject *module, PyObject *arg) _PyArg_BadArgument("lookup", "argument", "str", arg); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(arg, &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(arg); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _codecs_lookup_impl(module, encoding); exit: @@ -140,15 +136,10 @@ _codecs_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje _PyArg_BadArgument("encode", "argument 'encoding'", "str", args[1]); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(args[1]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_pos; } @@ -157,15 +148,10 @@ _codecs_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje _PyArg_BadArgument("encode", "argument 'errors'", "str", args[2]); goto exit; } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[2]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } skip_optional_pos: return_value = _codecs_encode_impl(module, obj, encoding, errors); @@ -243,15 +229,10 @@ _codecs_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje _PyArg_BadArgument("decode", "argument 'encoding'", "str", args[1]); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(args[1]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_pos; } @@ -260,15 +241,10 @@ _codecs_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje _PyArg_BadArgument("decode", "argument 'errors'", "str", args[2]); goto exit; } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[2]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } skip_optional_pos: return_value = _codecs_decode_impl(module, obj, encoding, errors); @@ -320,15 +296,10 @@ _codecs_escape_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("escape_decode", "argument 2", "str or None", args[1]); @@ -380,15 +351,10 @@ _codecs_escape_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("escape_encode", "argument 2", "str or None", args[1]); @@ -434,15 +400,10 @@ _codecs_utf_7_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_7_decode", "argument 2", "str or None", args[1]); @@ -500,15 +461,10 @@ _codecs_utf_8_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_8_decode", "argument 2", "str or None", args[1]); @@ -566,15 +522,10 @@ _codecs_utf_16_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_16_decode", "argument 2", "str or None", args[1]); @@ -632,15 +583,10 @@ _codecs_utf_16_le_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_16_le_decode", "argument 2", "str or None", args[1]); @@ -698,15 +644,10 @@ _codecs_utf_16_be_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_16_be_decode", "argument 2", "str or None", args[1]); @@ -766,15 +707,10 @@ _codecs_utf_16_ex_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_16_ex_decode", "argument 2", "str or None", args[1]); @@ -839,15 +775,10 @@ _codecs_utf_32_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_32_decode", "argument 2", "str or None", args[1]); @@ -905,15 +836,10 @@ _codecs_utf_32_le_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_32_le_decode", "argument 2", "str or None", args[1]); @@ -971,15 +897,10 @@ _codecs_utf_32_be_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_32_be_decode", "argument 2", "str or None", args[1]); @@ -1039,15 +960,10 @@ _codecs_utf_32_ex_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_32_ex_decode", "argument 2", "str or None", args[1]); @@ -1124,15 +1040,10 @@ _codecs_unicode_escape_decode(PyObject *module, PyObject *const *args, Py_ssize_ errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("unicode_escape_decode", "argument 2", "str or None", args[1]); @@ -1202,15 +1113,10 @@ _codecs_raw_unicode_escape_decode(PyObject *module, PyObject *const *args, Py_ss errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("raw_unicode_escape_decode", "argument 2", "str or None", args[1]); @@ -1267,15 +1173,10 @@ _codecs_latin_1_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("latin_1_decode", "argument 2", "str or None", args[1]); @@ -1325,15 +1226,10 @@ _codecs_ascii_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("ascii_decode", "argument 2", "str or None", args[1]); @@ -1384,15 +1280,10 @@ _codecs_charmap_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("charmap_decode", "argument 2", "str or None", args[1]); @@ -1449,15 +1340,10 @@ _codecs_mbcs_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("mbcs_decode", "argument 2", "str or None", args[1]); @@ -1519,15 +1405,10 @@ _codecs_oem_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("oem_decode", "argument 2", "str or None", args[1]); @@ -1594,15 +1475,10 @@ _codecs_code_page_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar errors = NULL; } else if (PyUnicode_Check(args[2])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[2]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("code_page_decode", "argument 3", "str or None", args[2]); @@ -1629,7 +1505,7 @@ _codecs_code_page_decode(PyObject *module, PyObject *const *args, Py_ssize_t nar #endif /* defined(MS_WINDOWS) */ -#if defined(HAVE_ICONV) +#if defined(_Py_HAVE_ICONV) PyDoc_STRVAR(_codecs_iconv_decode__doc__, "iconv_decode($module, encoding, data, errors=None, final=False, /)\n" @@ -1659,15 +1535,10 @@ _codecs_iconv_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) _PyArg_BadArgument("iconv_decode", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(args[0]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (PyObject_GetBuffer(args[1], &data, PyBUF_SIMPLE) != 0) { goto exit; } @@ -1678,15 +1549,10 @@ _codecs_iconv_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[2])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[2]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("iconv_decode", "argument 3", "str or None", args[2]); @@ -1711,7 +1577,7 @@ _codecs_iconv_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) return return_value; } -#endif /* defined(HAVE_ICONV) */ +#endif /* defined(_Py_HAVE_ICONV) */ PyDoc_STRVAR(_codecs_readbuffer_encode__doc__, "readbuffer_encode($module, data, errors=None, /)\n" @@ -1757,15 +1623,10 @@ _codecs_readbuffer_encode(PyObject *module, PyObject *const *args, Py_ssize_t na errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("readbuffer_encode", "argument 2", "str or None", args[1]); @@ -1817,15 +1678,10 @@ _codecs_utf_7_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_7_encode", "argument 2", "str or None", args[1]); @@ -1872,15 +1728,10 @@ _codecs_utf_8_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_8_encode", "argument 2", "str or None", args[1]); @@ -1928,15 +1779,10 @@ _codecs_utf_16_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_16_encode", "argument 2", "str or None", args[1]); @@ -1990,15 +1836,10 @@ _codecs_utf_16_le_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_16_le_encode", "argument 2", "str or None", args[1]); @@ -2045,15 +1886,10 @@ _codecs_utf_16_be_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_16_be_encode", "argument 2", "str or None", args[1]); @@ -2101,15 +1937,10 @@ _codecs_utf_32_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_32_encode", "argument 2", "str or None", args[1]); @@ -2163,15 +1994,10 @@ _codecs_utf_32_le_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_32_le_encode", "argument 2", "str or None", args[1]); @@ -2218,15 +2044,10 @@ _codecs_utf_32_be_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("utf_32_be_encode", "argument 2", "str or None", args[1]); @@ -2273,15 +2094,10 @@ _codecs_unicode_escape_encode(PyObject *module, PyObject *const *args, Py_ssize_ errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("unicode_escape_encode", "argument 2", "str or None", args[1]); @@ -2328,15 +2144,10 @@ _codecs_raw_unicode_escape_encode(PyObject *module, PyObject *const *args, Py_ss errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("raw_unicode_escape_encode", "argument 2", "str or None", args[1]); @@ -2383,15 +2194,10 @@ _codecs_latin_1_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("latin_1_encode", "argument 2", "str or None", args[1]); @@ -2438,15 +2244,10 @@ _codecs_ascii_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("ascii_encode", "argument 2", "str or None", args[1]); @@ -2494,15 +2295,10 @@ _codecs_charmap_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("charmap_encode", "argument 2", "str or None", args[1]); @@ -2582,15 +2378,10 @@ _codecs_mbcs_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("mbcs_encode", "argument 2", "str or None", args[1]); @@ -2640,15 +2431,10 @@ _codecs_oem_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("oem_encode", "argument 2", "str or None", args[1]); @@ -2704,15 +2490,10 @@ _codecs_code_page_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar errors = NULL; } else if (PyUnicode_Check(args[2])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[2]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("code_page_encode", "argument 3", "str or None", args[2]); @@ -2727,7 +2508,7 @@ _codecs_code_page_encode(PyObject *module, PyObject *const *args, Py_ssize_t nar #endif /* defined(MS_WINDOWS) */ -#if defined(HAVE_ICONV) +#if defined(_Py_HAVE_ICONV) PyDoc_STRVAR(_codecs_iconv_encode__doc__, "iconv_encode($module, encoding, str, errors=None, /)\n" @@ -2756,15 +2537,10 @@ _codecs_iconv_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) _PyArg_BadArgument("iconv_encode", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(args[0]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!PyUnicode_Check(args[1])) { _PyArg_BadArgument("iconv_encode", "argument 2", "str", args[1]); goto exit; @@ -2777,15 +2553,10 @@ _codecs_iconv_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) errors = NULL; } else if (PyUnicode_Check(args[2])) { - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[2]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("iconv_encode", "argument 3", "str or None", args[2]); @@ -2798,7 +2569,7 @@ _codecs_iconv_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) return return_value; } -#endif /* defined(HAVE_ICONV) */ +#endif /* defined(_Py_HAVE_ICONV) */ PyDoc_STRVAR(_codecs_register_error__doc__, "register_error($module, errors, handler, /)\n" @@ -2832,15 +2603,10 @@ _codecs_register_error(PyObject *module, PyObject *const *args, Py_ssize_t nargs _PyArg_BadArgument("register_error", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[0], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[0]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } handler = args[1]; return_value = _codecs_register_error_impl(module, errors, handler); @@ -2879,15 +2645,10 @@ _codecs__unregister_error(PyObject *module, PyObject *arg) _PyArg_BadArgument("_unregister_error", "argument", "str", arg); goto exit; } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(arg, &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(arg); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } _return_value = _codecs__unregister_error_impl(module, errors); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -2923,15 +2684,10 @@ _codecs_lookup_error(PyObject *module, PyObject *arg) _PyArg_BadArgument("lookup_error", "argument", "str", arg); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(arg, &name_length); + name = _PyUnicode_AsUTF8NoNUL(arg); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _codecs_lookup_error_impl(module, name); exit: @@ -3033,4 +2789,4 @@ _codecs__normalize_encoding(PyObject *module, PyObject *const *args, Py_ssize_t #ifndef _CODECS_ICONV_ENCODE_METHODDEF #define _CODECS_ICONV_ENCODE_METHODDEF #endif /* !defined(_CODECS_ICONV_ENCODE_METHODDEF) */ -/*[clinic end generated code: output=912e04020d6a6144 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2bf386d7e284e6f3 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_collectionsmodule.c.h b/Modules/clinic/_collectionsmodule.c.h index 6c60678a6fbd51a..2966d68aa3813b5 100644 --- a/Modules/clinic/_collectionsmodule.c.h +++ b/Modules/clinic/_collectionsmodule.c.h @@ -202,6 +202,21 @@ deque___copy__(PyObject *deque, PyObject *Py_UNUSED(ignored)) return return_value; } +static PyObject * +deque_concat_impl(dequeobject *deque, PyObject *other); + +static PyObject * +deque_concat(PyObject *deque, PyObject *other) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(deque); + return_value = deque_concat_impl((dequeobject *)deque, other); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(deque_clearmethod__doc__, "clear($self, /)\n" "--\n" @@ -226,6 +241,21 @@ deque_clearmethod(PyObject *deque, PyObject *Py_UNUSED(ignored)) return return_value; } +static PyObject * +deque_inplace_repeat_impl(dequeobject *deque, Py_ssize_t n); + +static PyObject * +deque_inplace_repeat(PyObject *deque, Py_ssize_t n) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(deque); + return_value = deque_inplace_repeat_impl((dequeobject *)deque, n); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(deque_rotate__doc__, "rotate($self, n=1, /)\n" "--\n" @@ -319,6 +349,21 @@ deque_count(PyObject *deque, PyObject *v) return return_value; } +static int +deque_contains_impl(dequeobject *deque, PyObject *v); + +static int +deque_contains(PyObject *deque, PyObject *v) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(deque); + return_value = deque_contains_impl((dequeobject *)deque, v); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(deque_index__doc__, "index($self, value, [start, [stop]])\n" "--\n" @@ -410,6 +455,21 @@ deque_insert(PyObject *deque, PyObject *const *args, Py_ssize_t nargs) return return_value; } +static PyObject * +deque_item_impl(dequeobject *deque, Py_ssize_t i); + +static PyObject * +deque_item(PyObject *deque, Py_ssize_t i) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(deque); + return_value = deque_item_impl((dequeobject *)deque, i); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(deque_remove__doc__, "remove($self, value, /)\n" "--\n" @@ -434,6 +494,21 @@ deque_remove(PyObject *deque, PyObject *value) return return_value; } +static int +deque_ass_item_impl(dequeobject *deque, Py_ssize_t i, PyObject *v); + +static int +deque_ass_item(PyObject *deque, Py_ssize_t i, PyObject *v) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(deque); + return_value = deque_ass_item_impl((dequeobject *)deque, i, v); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(deque___reduce____doc__, "__reduce__($self, /)\n" "--\n" @@ -632,4 +707,4 @@ tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=f5a388add99d3d15 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=de400069cf6f11a4 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_csv.c.h b/Modules/clinic/_csv.c.h index b8dd8ac35fac599..09dbcbea7e057b1 100644 --- a/Modules/clinic/_csv.c.h +++ b/Modules/clinic/_csv.c.h @@ -6,7 +6,188 @@ preserve # include "pycore_gc.h" // PyGC_Head # include "pycore_runtime.h" // _Py_ID() #endif -#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() +#include "pycore_modsupport.h" // _PyArg_NoPositional() + +PyDoc_STRVAR(_csv_Dialect___reduce____doc__, +"__reduce__($self, /)\n" +"--\n" +"\n" +"Raise an exception to avoid pickling."); + +#define _CSV_DIALECT___REDUCE___METHODDEF \ + {"__reduce__", (PyCFunction)_csv_Dialect___reduce__, METH_NOARGS, _csv_Dialect___reduce____doc__}, + +static PyObject * +_csv_Dialect___reduce___impl(DialectObj *self); + +static PyObject * +_csv_Dialect___reduce__(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _csv_Dialect___reduce___impl((DialectObj *)self); +} + +PyDoc_STRVAR(_csv_Dialect___reduce_ex____doc__, +"__reduce_ex__($self, protocol, /)\n" +"--\n" +"\n" +"Raise an exception to avoid pickling."); + +#define _CSV_DIALECT___REDUCE_EX___METHODDEF \ + {"__reduce_ex__", (PyCFunction)_csv_Dialect___reduce_ex__, METH_O, _csv_Dialect___reduce_ex____doc__}, + +static PyObject * +_csv_Dialect___reduce_ex___impl(DialectObj *self, PyObject *protocol); + +static PyObject * +_csv_Dialect___reduce_ex__(PyObject *self, PyObject *protocol) +{ + PyObject *return_value = NULL; + + return_value = _csv_Dialect___reduce_ex___impl((DialectObj *)self, protocol); + + return return_value; +} + +PyDoc_STRVAR(_csv_Dialect___replace____doc__, +"__replace__($self, /, **changes)\n" +"--\n" +"\n" +"Return a copy of the dialect with the specified options replaced."); + +#define _CSV_DIALECT___REPLACE___METHODDEF \ + {"__replace__", _PyCFunction_CAST(_csv_Dialect___replace__), METH_VARARGS|METH_KEYWORDS, _csv_Dialect___replace____doc__}, + +static PyObject * +_csv_Dialect___replace___impl(DialectObj *self, PyObject *changes); + +static PyObject * +_csv_Dialect___replace__(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *changes = NULL; + + if (!_PyArg_NoPositional("__replace__", args)) { + goto exit; + } + changes = Py_XNewRef(kwargs); + return_value = _csv_Dialect___replace___impl((DialectObj *)self, changes); + +exit: + /* Cleanup for changes */ + Py_XDECREF(changes); + + return return_value; +} + +static PyObject * +Reader_iternext_impl(ReaderObj *self); + +static PyObject * +Reader_iternext(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = Reader_iternext_impl((ReaderObj *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +PyDoc_STRVAR(_csv_reader__doc__, +"reader($module, iterable, dialect=\'excel\', /, **fmtparams)\n" +"--\n" +"\n" +"Return a reader object that will process lines from the given iterable.\n" +"\n" +"The \"iterable\" argument can be any object that returns a line\n" +"of input for each iteration, such as a file object or a list. The\n" +"optional \"dialect\" argument defines a CSV dialect. The function\n" +"also accepts optional keyword arguments which override settings\n" +"provided by the dialect.\n" +"\n" +"The returned object is an iterator. Each iteration returns a row\n" +"of the CSV file (which can span multiple input lines)."); + +#define _CSV_READER_METHODDEF \ + {"reader", _PyCFunction_CAST(_csv_reader), METH_VARARGS|METH_KEYWORDS, _csv_reader__doc__}, + +static PyObject * +_csv_reader_impl(PyObject *module, PyObject *iterable, PyObject *dialect, + PyObject *fmtparams); + +static PyObject * +_csv_reader(PyObject *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *iterable; + PyObject *dialect = NULL; + PyObject *fmtparams = NULL; + + if (!_PyArg_CheckPositional("reader", PyTuple_GET_SIZE(args), 1, 2)) { + goto exit; + } + iterable = PyTuple_GET_ITEM(args, 0); + if (PyTuple_GET_SIZE(args) < 2) { + goto skip_optional; + } + dialect = PyTuple_GET_ITEM(args, 1); +skip_optional: + fmtparams = Py_XNewRef(kwargs); + return_value = _csv_reader_impl(module, iterable, dialect, fmtparams); + +exit: + /* Cleanup for fmtparams */ + Py_XDECREF(fmtparams); + + return return_value; +} + +PyDoc_STRVAR(_csv_writer__doc__, +"writer($module, fileobj, dialect=\'excel\', /, **fmtparams)\n" +"--\n" +"\n" +"Return a writer object writing user data to the given file object.\n" +"\n" +"The \"fileobj\" argument can be any object that supports the file API.\n" +"The optional \"dialect\" argument defines a CSV dialect. The function\n" +"also accepts optional keyword arguments which override settings\n" +"provided by the dialect."); + +#define _CSV_WRITER_METHODDEF \ + {"writer", _PyCFunction_CAST(_csv_writer), METH_VARARGS|METH_KEYWORDS, _csv_writer__doc__}, + +static PyObject * +_csv_writer_impl(PyObject *module, PyObject *output_file, PyObject *dialect, + PyObject *fmtparams); + +static PyObject * +_csv_writer(PyObject *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *output_file; + PyObject *dialect = NULL; + PyObject *fmtparams = NULL; + + if (!_PyArg_CheckPositional("writer", PyTuple_GET_SIZE(args), 1, 2)) { + goto exit; + } + output_file = PyTuple_GET_ITEM(args, 0); + if (PyTuple_GET_SIZE(args) < 2) { + goto skip_optional; + } + dialect = PyTuple_GET_ITEM(args, 1); +skip_optional: + fmtparams = Py_XNewRef(kwargs); + return_value = _csv_writer_impl(module, output_file, dialect, fmtparams); + +exit: + /* Cleanup for fmtparams */ + Py_XDECREF(fmtparams); + + return return_value; +} PyDoc_STRVAR(_csv_list_dialects__doc__, "list_dialects($module, /)\n" @@ -26,6 +207,51 @@ _csv_list_dialects(PyObject *module, PyObject *Py_UNUSED(ignored)) return _csv_list_dialects_impl(module); } +PyDoc_STRVAR(_csv_register_dialect__doc__, +"register_dialect($module, name, dialect=\'excel\', /, **fmtparams)\n" +"--\n" +"\n" +"Create a mapping from a string name to a CVS dialect.\n" +"\n" +"The optional \"dialect\" argument specifies the base dialect instance\n" +"or the name of the registered dialect. The function also accepts\n" +"optional keyword arguments which override settings provided by the\n" +"dialect."); + +#define _CSV_REGISTER_DIALECT_METHODDEF \ + {"register_dialect", _PyCFunction_CAST(_csv_register_dialect), METH_VARARGS|METH_KEYWORDS, _csv_register_dialect__doc__}, + +static PyObject * +_csv_register_dialect_impl(PyObject *module, PyObject *name_obj, + PyObject *dialect_obj, PyObject *fmtparams); + +static PyObject * +_csv_register_dialect(PyObject *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *name_obj; + PyObject *dialect_obj = NULL; + PyObject *fmtparams = NULL; + + if (!_PyArg_CheckPositional("register_dialect", PyTuple_GET_SIZE(args), 1, 2)) { + goto exit; + } + name_obj = PyTuple_GET_ITEM(args, 0); + if (PyTuple_GET_SIZE(args) < 2) { + goto skip_optional; + } + dialect_obj = PyTuple_GET_ITEM(args, 1); +skip_optional: + fmtparams = Py_XNewRef(kwargs); + return_value = _csv_register_dialect_impl(module, name_obj, dialect_obj, fmtparams); + +exit: + /* Cleanup for fmtparams */ + Py_XDECREF(fmtparams); + + return return_value; +} + PyDoc_STRVAR(_csv_unregister_dialect__doc__, "unregister_dialect($module, /, name)\n" "--\n" @@ -207,4 +433,4 @@ _csv_field_size_limit(PyObject *module, PyObject *const *args, Py_ssize_t nargs, exit: return return_value; } -/*[clinic end generated code: output=ed77cb69fad9f3b4 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=30eac1c04ff9d38a input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_cursesmodule.c.h b/Modules/clinic/_cursesmodule.c.h index da1b97c0ea5ad8b..ac9a4de4c960c8f 100644 --- a/Modules/clinic/_cursesmodule.c.h +++ b/Modules/clinic/_cursesmodule.c.h @@ -6,7 +6,9 @@ preserve # include "pycore_gc.h" // PyGC_Head # include "pycore_runtime.h" // _Py_ID() #endif +#include "pycore_long.h" // _PyLong_UnsignedInt_Converter() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(complexchar_new__doc__, "complexchar(text, /, attr=0, pair=0)\n" @@ -207,7 +209,7 @@ PyDoc_STRVAR(_curses_window_addch__doc__, "current settings for the window object."); #define _CURSES_WINDOW_ADDCH_METHODDEF \ - {"addch", (PyCFunction)_curses_window_addch, METH_VARARGS, _curses_window_addch__doc__}, + {"addch", _PyCFunction_CAST(_curses_window_addch), METH_FASTCALL, _curses_window_addch__doc__}, static PyObject * _curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, @@ -215,7 +217,7 @@ _curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, attr_t attr); static PyObject * -_curses_window_addch(PyObject *self, PyObject *args) +_curses_window_addch(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_left_1 = 0; @@ -225,34 +227,29 @@ _curses_window_addch(PyObject *self, PyObject *args) int group_right_1 = 0; attr_t attr = 0; - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O:addch", &ch)) { - goto exit; - } - break; - case 2: - if (!PyArg_ParseTuple(args, "OO&:addch", &ch, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - case 3: - if (!PyArg_ParseTuple(args, "iiO:addch", &y, &x, &ch)) { - goto exit; - } - group_left_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOO&:addch", &y, &x, &ch, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.addch requires 1 to 4 arguments"); + Py_ssize_t offset = 0; + if (nargs < 1 || nargs > 4) { + PyErr_SetString(PyExc_TypeError, "_curses.window.addch requires 1 to 4 arguments"); + goto exit; + } + if (nargs >= 3) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + offset += 2; + group_left_1 = 1; + } + ch = args[offset]; + if (nargs == 2 || nargs == 4) { + if (!attr_converter(args[nargs - 1], &attr)) { goto exit; + } + group_right_1 = 1; } return_value = _curses_window_addch_impl((PyCursesWindowObject *)self, group_left_1, y, x, ch, group_right_1, attr); @@ -279,7 +276,7 @@ PyDoc_STRVAR(_curses_window_addstr__doc__, "current settings for the window object."); #define _CURSES_WINDOW_ADDSTR_METHODDEF \ - {"addstr", (PyCFunction)_curses_window_addstr, METH_VARARGS, _curses_window_addstr__doc__}, + {"addstr", _PyCFunction_CAST(_curses_window_addstr), METH_FASTCALL, _curses_window_addstr__doc__}, static PyObject * _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1, @@ -287,7 +284,7 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1, attr_t attr); static PyObject * -_curses_window_addstr(PyObject *self, PyObject *args) +_curses_window_addstr(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_left_1 = 0; @@ -297,34 +294,29 @@ _curses_window_addstr(PyObject *self, PyObject *args) int group_right_1 = 0; attr_t attr = 0; - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O:addstr", &str)) { - goto exit; - } - break; - case 2: - if (!PyArg_ParseTuple(args, "OO&:addstr", &str, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - case 3: - if (!PyArg_ParseTuple(args, "iiO:addstr", &y, &x, &str)) { - goto exit; - } - group_left_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOO&:addstr", &y, &x, &str, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.addstr requires 1 to 4 arguments"); + Py_ssize_t offset = 0; + if (nargs < 1 || nargs > 4) { + PyErr_SetString(PyExc_TypeError, "_curses.window.addstr requires 1 to 4 arguments"); + goto exit; + } + if (nargs >= 3) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + offset += 2; + group_left_1 = 1; + } + str = args[offset]; + if (nargs == 2 || nargs == 4) { + if (!attr_converter(args[nargs - 1], &attr)) { + goto exit; + } + group_right_1 = 1; } return_value = _curses_window_addstr_impl((PyCursesWindowObject *)self, group_left_1, y, x, str, group_right_1, attr); @@ -353,7 +345,7 @@ PyDoc_STRVAR(_curses_window_addnstr__doc__, "current settings for the window object."); #define _CURSES_WINDOW_ADDNSTR_METHODDEF \ - {"addnstr", (PyCFunction)_curses_window_addnstr, METH_VARARGS, _curses_window_addnstr__doc__}, + {"addnstr", _PyCFunction_CAST(_curses_window_addnstr), METH_FASTCALL, _curses_window_addnstr__doc__}, static PyObject * _curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1, @@ -361,7 +353,7 @@ _curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1, int group_right_1, attr_t attr); static PyObject * -_curses_window_addnstr(PyObject *self, PyObject *args) +_curses_window_addnstr(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_left_1 = 0; @@ -372,34 +364,33 @@ _curses_window_addnstr(PyObject *self, PyObject *args) int group_right_1 = 0; attr_t attr = 0; - switch (PyTuple_GET_SIZE(args)) { - case 2: - if (!PyArg_ParseTuple(args, "Oi:addnstr", &str, &n)) { - goto exit; - } - break; - case 3: - if (!PyArg_ParseTuple(args, "OiO&:addnstr", &str, &n, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOi:addnstr", &y, &x, &str, &n)) { - goto exit; - } - group_left_1 = 1; - break; - case 5: - if (!PyArg_ParseTuple(args, "iiOiO&:addnstr", &y, &x, &str, &n, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.addnstr requires 2 to 5 arguments"); + Py_ssize_t offset = 0; + if (nargs < 2 || nargs > 5) { + PyErr_SetString(PyExc_TypeError, "_curses.window.addnstr requires 2 to 5 arguments"); + goto exit; + } + if (nargs >= 4) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + offset += 2; + group_left_1 = 1; + } + str = args[offset]; + n = PyLong_AsInt(args[offset + 1]); + if (n == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs == 3 || nargs == 5) { + if (!attr_converter(args[nargs - 1], &attr)) { goto exit; + } + group_right_1 = 1; } return_value = _curses_window_addnstr_impl((PyCursesWindowObject *)self, group_left_1, y, x, str, n, group_right_1, attr); @@ -417,35 +408,30 @@ PyDoc_STRVAR(_curses_window_bkgd__doc__, " Background attributes."); #define _CURSES_WINDOW_BKGD_METHODDEF \ - {"bkgd", (PyCFunction)_curses_window_bkgd, METH_VARARGS, _curses_window_bkgd__doc__}, + {"bkgd", _PyCFunction_CAST(_curses_window_bkgd), METH_FASTCALL, _curses_window_bkgd__doc__}, static PyObject * _curses_window_bkgd_impl(PyCursesWindowObject *self, PyObject *ch, int group_right_1, attr_t attr); static PyObject * -_curses_window_bkgd(PyObject *self, PyObject *args) +_curses_window_bkgd(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; PyObject *ch; int group_right_1 = 0; attr_t attr = 0; - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O:bkgd", &ch)) { - goto exit; - } - break; - case 2: - if (!PyArg_ParseTuple(args, "OO&:bkgd", &ch, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.bkgd requires 1 to 2 arguments"); + if (nargs < 1 || nargs > 2) { + PyErr_SetString(PyExc_TypeError, "_curses.window.bkgd requires 1 to 2 arguments"); + goto exit; + } + ch = args[0]; + if (nargs >= 2) { + if (!attr_converter(args[1], &attr)) { goto exit; + } + group_right_1 = 1; } return_value = _curses_window_bkgd_impl((PyCursesWindowObject *)self, ch, group_right_1, attr); @@ -534,6 +520,8 @@ _curses_window_attrset(PyObject *self, PyObject *arg) return return_value; } +#if defined(_Py_HAVE_CURSES_WATTR_GET) + PyDoc_STRVAR(_curses_window_attr_get__doc__, "attr_get($self, /)\n" "--\n" @@ -552,6 +540,10 @@ _curses_window_attr_get(PyObject *self, PyObject *Py_UNUSED(ignored)) return _curses_window_attr_get_impl((PyCursesWindowObject *)self); } +#endif /* defined(_Py_HAVE_CURSES_WATTR_GET) */ + +#if defined(_Py_HAVE_CURSES_WATTR_SET) + PyDoc_STRVAR(_curses_window_attr_set__doc__, "attr_set($self, attr, pair=0, /)\n" "--\n" @@ -591,6 +583,10 @@ _curses_window_attr_set(PyObject *self, PyObject *const *args, Py_ssize_t nargs) return return_value; } +#endif /* defined(_Py_HAVE_CURSES_WATTR_SET) */ + +#if defined(_Py_HAVE_CURSES_WATTR_ON) + PyDoc_STRVAR(_curses_window_attr_on__doc__, "attr_on($self, attr, /)\n" "--\n" @@ -618,6 +614,10 @@ _curses_window_attr_on(PyObject *self, PyObject *arg) return return_value; } +#endif /* defined(_Py_HAVE_CURSES_WATTR_ON) */ + +#if defined(_Py_HAVE_CURSES_WATTR_OFF) + PyDoc_STRVAR(_curses_window_attr_off__doc__, "attr_off($self, attr, /)\n" "--\n" @@ -645,6 +645,10 @@ _curses_window_attr_off(PyObject *self, PyObject *arg) return return_value; } +#endif /* defined(_Py_HAVE_CURSES_WATTR_OFF) */ + +#if defined(_Py_HAVE_CURSES_WCOLOR_SET) + PyDoc_STRVAR(_curses_window_color_set__doc__, "color_set($self, pair, /)\n" "--\n" @@ -672,6 +676,8 @@ _curses_window_color_set(PyObject *self, PyObject *arg) return return_value; } +#endif /* defined(_Py_HAVE_CURSES_WCOLOR_SET) */ + PyDoc_STRVAR(_curses_window_getattrs__doc__, "getattrs($self, /)\n" "--\n" @@ -700,35 +706,30 @@ PyDoc_STRVAR(_curses_window_bkgdset__doc__, " Background attributes."); #define _CURSES_WINDOW_BKGDSET_METHODDEF \ - {"bkgdset", (PyCFunction)_curses_window_bkgdset, METH_VARARGS, _curses_window_bkgdset__doc__}, + {"bkgdset", _PyCFunction_CAST(_curses_window_bkgdset), METH_FASTCALL, _curses_window_bkgdset__doc__}, static PyObject * _curses_window_bkgdset_impl(PyCursesWindowObject *self, PyObject *ch, int group_right_1, attr_t attr); static PyObject * -_curses_window_bkgdset(PyObject *self, PyObject *args) +_curses_window_bkgdset(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; PyObject *ch; int group_right_1 = 0; attr_t attr = 0; - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O:bkgdset", &ch)) { - goto exit; - } - break; - case 2: - if (!PyArg_ParseTuple(args, "OO&:bkgdset", &ch, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.bkgdset requires 1 to 2 arguments"); + if (nargs < 1 || nargs > 2) { + PyErr_SetString(PyExc_TypeError, "_curses.window.bkgdset requires 1 to 2 arguments"); + goto exit; + } + ch = args[0]; + if (nargs >= 2) { + if (!attr_converter(args[1], &attr)) { goto exit; + } + group_right_1 = 1; } return_value = _curses_window_bkgdset_impl((PyCursesWindowObject *)self, ch, group_right_1, attr); @@ -737,10 +738,7 @@ _curses_window_bkgdset(PyObject *self, PyObject *args) } PyDoc_STRVAR(_curses_window_border__doc__, -"border($self, ls=_curses.ACS_VLINE, rs=_curses.ACS_VLINE,\n" -" ts=_curses.ACS_HLINE, bs=_curses.ACS_HLINE,\n" -" tl=_curses.ACS_ULCORNER, tr=_curses.ACS_URCORNER,\n" -" bl=_curses.ACS_LLCORNER, br=_curses.ACS_LRCORNER, /)\n" +"border($self, ls=0, rs=0, ts=0, bs=0, tl=0, tr=0, bl=0, br=0, /)\n" "--\n" "\n" "Draw a border around the edges of the window.\n" @@ -845,39 +843,112 @@ PyDoc_STRVAR(_curses_window_box__doc__, "function."); #define _CURSES_WINDOW_BOX_METHODDEF \ - {"box", (PyCFunction)_curses_window_box, METH_VARARGS, _curses_window_box__doc__}, + {"box", _PyCFunction_CAST(_curses_window_box), METH_FASTCALL, _curses_window_box__doc__}, static PyObject * _curses_window_box_impl(PyCursesWindowObject *self, int group_right_1, PyObject *verch, PyObject *horch); static PyObject * -_curses_window_box(PyObject *self, PyObject *args) +_curses_window_box(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_right_1 = 0; PyObject *verch = _PyLong_GetZero(); PyObject *horch = _PyLong_GetZero(); - switch (PyTuple_GET_SIZE(args)) { + switch (nargs) { case 0: - break; case 2: - if (!PyArg_ParseTuple(args, "OO:box", &verch, &horch)) { - goto exit; - } - group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.box requires 0 to 2 arguments"); goto exit; } + if (nargs >= 2) { + verch = args[0]; + horch = args[1]; + group_right_1 = 1; + } return_value = _curses_window_box_impl((PyCursesWindowObject *)self, group_right_1, verch, horch); exit: return return_value; } +#if defined(HAVE_CURSES_WCHGAT) + +PyDoc_STRVAR(_curses_window_chgat__doc__, +"chgat([y, x,] [n=-1,] attr)\n" +"Set the attributes of characters.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" n\n" +" Number of characters.\n" +" attr\n" +" Attributes for characters.\n" +"\n" +"Set the attributes of n characters at the current cursor position,\n" +"or at position (y, x) if supplied. If no value of n is given or\n" +"n = -1, the attribute will be set on all the characters to the end\n" +"of the line. This function does not move the cursor. The changed\n" +"line will be touched using the touchline() method so that the\n" +"contents will be redisplayed by the next window refresh."); + +#define _CURSES_WINDOW_CHGAT_METHODDEF \ + {"chgat", _PyCFunction_CAST(_curses_window_chgat), METH_FASTCALL, _curses_window_chgat__doc__}, + +static PyObject * +_curses_window_chgat_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, int group_left_2, int n, attr_t attr); + +static PyObject * +_curses_window_chgat(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + int group_left_2 = 0; + int n = -1; + attr_t attr; + + if (nargs < 1 || nargs > 4) { + PyErr_SetString(PyExc_TypeError, "_curses.window.chgat requires 1 to 4 arguments"); + goto exit; + } + if (nargs >= 3) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + group_left_1 = 1; + } + if (nargs == 2 || nargs == 4) { + n = PyLong_AsInt(args[nargs - 2]); + if (n == -1 && PyErr_Occurred()) { + goto exit; + } + group_left_2 = 1; + } + if (!attr_converter(args[nargs - 1], &attr)) { + goto exit; + } + return_value = _curses_window_chgat_impl((PyCursesWindowObject *)self, group_left_1, y, x, group_left_2, n, attr); + +exit: + return return_value; +} + +#endif /* defined(HAVE_CURSES_WCHGAT) */ + PyDoc_STRVAR(_curses_window_delch__doc__, "delch([y, x])\n" "Delete the character under the cursor, or at (y, x) if specified.\n" @@ -891,33 +962,39 @@ PyDoc_STRVAR(_curses_window_delch__doc__, "position left."); #define _CURSES_WINDOW_DELCH_METHODDEF \ - {"delch", (PyCFunction)_curses_window_delch, METH_VARARGS, _curses_window_delch__doc__}, + {"delch", _PyCFunction_CAST(_curses_window_delch), METH_FASTCALL, _curses_window_delch__doc__}, static PyObject * _curses_window_delch_impl(PyCursesWindowObject *self, int group_right_1, int y, int x); static PyObject * -_curses_window_delch(PyObject *self, PyObject *args) +_curses_window_delch(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_right_1 = 0; int y = 0; int x = 0; - switch (PyTuple_GET_SIZE(args)) { + switch (nargs) { case 0: - break; case 2: - if (!PyArg_ParseTuple(args, "ii:delch", &y, &x)) { - goto exit; - } - group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.delch requires 0 to 2 arguments"); goto exit; } + if (nargs >= 2) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + group_right_1 = 1; + } return_value = _curses_window_delch_impl((PyCursesWindowObject *)self, group_right_1, y, x); exit: @@ -942,14 +1019,14 @@ PyDoc_STRVAR(_curses_window_derwin__doc__, "relative to the entire screen."); #define _CURSES_WINDOW_DERWIN_METHODDEF \ - {"derwin", (PyCFunction)_curses_window_derwin, METH_VARARGS, _curses_window_derwin__doc__}, + {"derwin", _PyCFunction_CAST(_curses_window_derwin), METH_FASTCALL, _curses_window_derwin__doc__}, static PyObject * _curses_window_derwin_impl(PyCursesWindowObject *self, int group_left_1, int nlines, int ncols, int begin_y, int begin_x); static PyObject * -_curses_window_derwin(PyObject *self, PyObject *args) +_curses_window_derwin(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_left_1 = 0; @@ -958,22 +1035,33 @@ _curses_window_derwin(PyObject *self, PyObject *args) int begin_y; int begin_x; - switch (PyTuple_GET_SIZE(args)) { + switch (nargs) { case 2: - if (!PyArg_ParseTuple(args, "ii:derwin", &begin_y, &begin_x)) { - goto exit; - } - break; case 4: - if (!PyArg_ParseTuple(args, "iiii:derwin", &nlines, &ncols, &begin_y, &begin_x)) { - goto exit; - } - group_left_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.derwin requires 2 to 4 arguments"); goto exit; } + if (nargs >= 4) { + nlines = PyLong_AsInt(args[0]); + if (nlines == -1 && PyErr_Occurred()) { + goto exit; + } + ncols = PyLong_AsInt(args[1]); + if (ncols == -1 && PyErr_Occurred()) { + goto exit; + } + group_left_1 = 1; + } + begin_y = PyLong_AsInt(args[nargs - 2]); + if (begin_y == -1 && PyErr_Occurred()) { + goto exit; + } + begin_x = PyLong_AsInt(args[nargs - 1]); + if (begin_x == -1 && PyErr_Occurred()) { + goto exit; + } return_value = _curses_window_derwin_impl((PyCursesWindowObject *)self, group_left_1, nlines, ncols, begin_y, begin_x); exit: @@ -1012,35 +1100,30 @@ PyDoc_STRVAR(_curses_window_echochar__doc__, " Attributes for the character."); #define _CURSES_WINDOW_ECHOCHAR_METHODDEF \ - {"echochar", (PyCFunction)_curses_window_echochar, METH_VARARGS, _curses_window_echochar__doc__}, + {"echochar", _PyCFunction_CAST(_curses_window_echochar), METH_FASTCALL, _curses_window_echochar__doc__}, static PyObject * _curses_window_echochar_impl(PyCursesWindowObject *self, PyObject *ch, int group_right_1, attr_t attr); static PyObject * -_curses_window_echochar(PyObject *self, PyObject *args) +_curses_window_echochar(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; PyObject *ch; int group_right_1 = 0; attr_t attr = 0; - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O:echochar", &ch)) { - goto exit; - } - break; - case 2: - if (!PyArg_ParseTuple(args, "OO&:echochar", &ch, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.echochar requires 1 to 2 arguments"); + if (nargs < 1 || nargs > 2) { + PyErr_SetString(PyExc_TypeError, "_curses.window.echochar requires 1 to 2 arguments"); + goto exit; + } + ch = args[0]; + if (nargs >= 2) { + if (!attr_converter(args[1], &attr)) { goto exit; + } + group_right_1 = 1; } return_value = _curses_window_echochar_impl((PyCursesWindowObject *)self, ch, group_right_1, attr); @@ -1181,33 +1264,39 @@ PyDoc_STRVAR(_curses_window_in_wch__doc__, "attributes and color pair."); #define _CURSES_WINDOW_IN_WCH_METHODDEF \ - {"in_wch", (PyCFunction)_curses_window_in_wch, METH_VARARGS, _curses_window_in_wch__doc__}, + {"in_wch", _PyCFunction_CAST(_curses_window_in_wch), METH_FASTCALL, _curses_window_in_wch__doc__}, static PyObject * _curses_window_in_wch_impl(PyCursesWindowObject *self, int group_right_1, int y, int x); static PyObject * -_curses_window_in_wch(PyObject *self, PyObject *args) +_curses_window_in_wch(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_right_1 = 0; int y = 0; int x = 0; - switch (PyTuple_GET_SIZE(args)) { + switch (nargs) { case 0: - break; case 2: - if (!PyArg_ParseTuple(args, "ii:in_wch", &y, &x)) { - goto exit; - } - group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.in_wch requires 0 to 2 arguments"); goto exit; } + if (nargs >= 2) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + group_right_1 = 1; + } return_value = _curses_window_in_wch_impl((PyCursesWindowObject *)self, group_right_1, y, x); exit: @@ -1234,46 +1323,59 @@ _curses_window_getbkgrnd(PyObject *self, PyObject *Py_UNUSED(ignored)) PyDoc_STRVAR(_curses_window_getch__doc__, "getch([y, x])\n" -"Get a character code from terminal keyboard.\n" +"Read a key press and return it as an integer.\n" "\n" " y\n" " Y-coordinate.\n" " x\n" " X-coordinate.\n" "\n" -"The integer returned does not have to be in ASCII range: function\n" -"keys, keypad keys and so on return numbers higher than 256. In\n" -"no-delay mode, -1 is returned if there is no input, else getch()\n" -"waits until a key is pressed."); +"Wait until a key is pressed, or return -1 if the read is\n" +"non-blocking or times out.\n" +"\n" +"An ordinary key is returned as the code of a single byte of its\n" +"encoding in the current locale, so a character encoded with several\n" +"bytes takes several calls. Use get_wch() to read it as a single\n" +"character.\n" +"\n" +"In keypad mode function keys and other special keys are returned as\n" +"one of the KEY_* constants, which cannot be mistaken for an ordinary\n" +"key. Otherwise their bytes are returned one at a time."); #define _CURSES_WINDOW_GETCH_METHODDEF \ - {"getch", (PyCFunction)_curses_window_getch, METH_VARARGS, _curses_window_getch__doc__}, + {"getch", _PyCFunction_CAST(_curses_window_getch), METH_FASTCALL, _curses_window_getch__doc__}, static PyObject * _curses_window_getch_impl(PyCursesWindowObject *self, int group_right_1, int y, int x); static PyObject * -_curses_window_getch(PyObject *self, PyObject *args) +_curses_window_getch(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_right_1 = 0; int y = 0; int x = 0; - switch (PyTuple_GET_SIZE(args)) { + switch (nargs) { case 0: - break; case 2: - if (!PyArg_ParseTuple(args, "ii:getch", &y, &x)) { - goto exit; - } - group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.getch requires 0 to 2 arguments"); goto exit; } + if (nargs >= 2) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + group_right_1 = 1; + } return_value = _curses_window_getch_impl((PyCursesWindowObject *)self, group_right_1, y, x); exit: @@ -1282,46 +1384,52 @@ _curses_window_getch(PyObject *self, PyObject *args) PyDoc_STRVAR(_curses_window_getkey__doc__, "getkey([y, x])\n" -"Get a character (string) from terminal keyboard.\n" +"Read a key press and return it as a str.\n" "\n" " y\n" " Y-coordinate.\n" " x\n" " X-coordinate.\n" "\n" -"Returning a string instead of an integer, as getch() does. Function\n" -"keys, keypad keys and other special keys return a multibyte string\n" -"containing the key name. In no-delay mode, an exception is raised\n" -"if there is no input."); +"Read as getch() does, but return an ordinary key as a one-character\n" +"string, the byte decoded as Latin-1, and a special key as its name,\n" +"such as \'KEY_UP\'. Raise curses.error instead of returning -1 if\n" +"there is no input."); #define _CURSES_WINDOW_GETKEY_METHODDEF \ - {"getkey", (PyCFunction)_curses_window_getkey, METH_VARARGS, _curses_window_getkey__doc__}, + {"getkey", _PyCFunction_CAST(_curses_window_getkey), METH_FASTCALL, _curses_window_getkey__doc__}, static PyObject * _curses_window_getkey_impl(PyCursesWindowObject *self, int group_right_1, int y, int x); static PyObject * -_curses_window_getkey(PyObject *self, PyObject *args) +_curses_window_getkey(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_right_1 = 0; int y = 0; int x = 0; - switch (PyTuple_GET_SIZE(args)) { + switch (nargs) { case 0: - break; case 2: - if (!PyArg_ParseTuple(args, "ii:getkey", &y, &x)) { - goto exit; - } - group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.getkey requires 0 to 2 arguments"); goto exit; } + if (nargs >= 2) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + group_right_1 = 1; + } return_value = _curses_window_getkey_impl((PyCursesWindowObject *)self, group_right_1, y, x); exit: @@ -1330,50 +1438,121 @@ _curses_window_getkey(PyObject *self, PyObject *args) PyDoc_STRVAR(_curses_window_get_wch__doc__, "get_wch([y, x])\n" -"Get a wide character from terminal keyboard.\n" +"Read a key press and return it as a one-character str.\n" "\n" " y\n" " Y-coordinate.\n" " x\n" " X-coordinate.\n" "\n" -"Return a character for most keys, or an integer for function keys,\n" -"keypad keys, and other special keys."); +"Wait until a key is pressed, or raise curses.error if the read is\n" +"non-blocking or times out.\n" +"\n" +"In keypad mode function keys and other special keys are returned as\n" +"one of the KEY_* constants, an integer. Otherwise their characters\n" +"are returned one at a time."); #define _CURSES_WINDOW_GET_WCH_METHODDEF \ - {"get_wch", (PyCFunction)_curses_window_get_wch, METH_VARARGS, _curses_window_get_wch__doc__}, + {"get_wch", _PyCFunction_CAST(_curses_window_get_wch), METH_FASTCALL, _curses_window_get_wch__doc__}, static PyObject * _curses_window_get_wch_impl(PyCursesWindowObject *self, int group_right_1, int y, int x); static PyObject * -_curses_window_get_wch(PyObject *self, PyObject *args) +_curses_window_get_wch(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_right_1 = 0; int y = 0; int x = 0; - switch (PyTuple_GET_SIZE(args)) { + switch (nargs) { case 0: - break; case 2: - if (!PyArg_ParseTuple(args, "ii:get_wch", &y, &x)) { - goto exit; - } - group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.get_wch requires 0 to 2 arguments"); goto exit; } + if (nargs >= 2) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + group_right_1 = 1; + } return_value = _curses_window_get_wch_impl((PyCursesWindowObject *)self, group_right_1, y, x); exit: return return_value; } +PyDoc_STRVAR(_curses_window_getstr__doc__, +"getstr([y, x,] n=2047)\n" +"Read a line of input and return it as a bytes object.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" n\n" +" Maximal number of bytes.\n" +"\n" +"The input is read with primitive line editing capacity, encoded in\n" +"the current locale, and does not include the terminating newline.\n" +"At most n bytes are read."); + +#define _CURSES_WINDOW_GETSTR_METHODDEF \ + {"getstr", _PyCFunction_CAST(_curses_window_getstr), METH_FASTCALL, _curses_window_getstr__doc__}, + +static PyObject * +_curses_window_getstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, unsigned int n); + +static PyObject * +_curses_window_getstr(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + unsigned int n = 2047; + + Py_ssize_t offset = 0; + if (nargs > 3) { + PyErr_SetString(PyExc_TypeError, "_curses.window.getstr requires 0 to 3 arguments"); + goto exit; + } + if (nargs >= 2) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + offset += 2; + group_left_1 = 1; + } + if (nargs <= offset) { + goto skip_optional; + } + if (!_PyLong_UnsignedInt_Converter(args[offset], &n)) { + goto exit; + } +skip_optional: + return_value = _curses_window_getstr_impl((PyCursesWindowObject *)self, group_left_1, y, x, n); + +exit: + return return_value; +} + PyDoc_STRVAR(_curses_window_hline__doc__, "hline([y, x,] ch, n, [attr])\n" "Display a horizontal line.\n" @@ -1390,7 +1569,7 @@ PyDoc_STRVAR(_curses_window_hline__doc__, " Attributes for the characters."); #define _CURSES_WINDOW_HLINE_METHODDEF \ - {"hline", (PyCFunction)_curses_window_hline, METH_VARARGS, _curses_window_hline__doc__}, + {"hline", _PyCFunction_CAST(_curses_window_hline), METH_FASTCALL, _curses_window_hline__doc__}, static PyObject * _curses_window_hline_impl(PyCursesWindowObject *self, int group_left_1, @@ -1398,7 +1577,7 @@ _curses_window_hline_impl(PyCursesWindowObject *self, int group_left_1, int group_right_1, attr_t attr); static PyObject * -_curses_window_hline(PyObject *self, PyObject *args) +_curses_window_hline(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_left_1 = 0; @@ -1409,34 +1588,33 @@ _curses_window_hline(PyObject *self, PyObject *args) int group_right_1 = 0; attr_t attr = 0; - switch (PyTuple_GET_SIZE(args)) { - case 2: - if (!PyArg_ParseTuple(args, "Oi:hline", &ch, &n)) { - goto exit; - } - break; - case 3: - if (!PyArg_ParseTuple(args, "OiO&:hline", &ch, &n, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOi:hline", &y, &x, &ch, &n)) { - goto exit; - } - group_left_1 = 1; - break; - case 5: - if (!PyArg_ParseTuple(args, "iiOiO&:hline", &y, &x, &ch, &n, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.hline requires 2 to 5 arguments"); + Py_ssize_t offset = 0; + if (nargs < 2 || nargs > 5) { + PyErr_SetString(PyExc_TypeError, "_curses.window.hline requires 2 to 5 arguments"); + goto exit; + } + if (nargs >= 4) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + offset += 2; + group_left_1 = 1; + } + ch = args[offset]; + n = PyLong_AsInt(args[offset + 1]); + if (n == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs == 3 || nargs == 5) { + if (!attr_converter(args[nargs - 1], &attr)) { + goto exit; + } + group_right_1 = 1; } return_value = _curses_window_hline_impl((PyCursesWindowObject *)self, group_left_1, y, x, ch, n, group_right_1, attr); @@ -1461,7 +1639,7 @@ PyDoc_STRVAR(_curses_window_insch__doc__, "right, with the rightmost characters on the line being lost."); #define _CURSES_WINDOW_INSCH_METHODDEF \ - {"insch", (PyCFunction)_curses_window_insch, METH_VARARGS, _curses_window_insch__doc__}, + {"insch", _PyCFunction_CAST(_curses_window_insch), METH_FASTCALL, _curses_window_insch__doc__}, static PyObject * _curses_window_insch_impl(PyCursesWindowObject *self, int group_left_1, @@ -1469,7 +1647,7 @@ _curses_window_insch_impl(PyCursesWindowObject *self, int group_left_1, attr_t attr); static PyObject * -_curses_window_insch(PyObject *self, PyObject *args) +_curses_window_insch(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_left_1 = 0; @@ -1479,34 +1657,29 @@ _curses_window_insch(PyObject *self, PyObject *args) int group_right_1 = 0; attr_t attr = 0; - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O:insch", &ch)) { - goto exit; - } - break; - case 2: - if (!PyArg_ParseTuple(args, "OO&:insch", &ch, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - case 3: - if (!PyArg_ParseTuple(args, "iiO:insch", &y, &x, &ch)) { - goto exit; - } - group_left_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOO&:insch", &y, &x, &ch, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.insch requires 1 to 4 arguments"); + Py_ssize_t offset = 0; + if (nargs < 1 || nargs > 4) { + PyErr_SetString(PyExc_TypeError, "_curses.window.insch requires 1 to 4 arguments"); + goto exit; + } + if (nargs >= 3) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { goto exit; + } + offset += 2; + group_left_1 = 1; + } + ch = args[offset]; + if (nargs == 2 || nargs == 4) { + if (!attr_converter(args[nargs - 1], &attr)) { + goto exit; + } + group_right_1 = 1; } return_value = _curses_window_insch_impl((PyCursesWindowObject *)self, group_left_1, y, x, ch, group_right_1, attr); @@ -1527,34 +1700,283 @@ PyDoc_STRVAR(_curses_window_inch__doc__, "attributes."); #define _CURSES_WINDOW_INCH_METHODDEF \ - {"inch", (PyCFunction)_curses_window_inch, METH_VARARGS, _curses_window_inch__doc__}, + {"inch", _PyCFunction_CAST(_curses_window_inch), METH_FASTCALL, _curses_window_inch__doc__}, static PyObject * _curses_window_inch_impl(PyCursesWindowObject *self, int group_right_1, int y, int x); static PyObject * -_curses_window_inch(PyObject *self, PyObject *args) +_curses_window_inch(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_right_1 = 0; int y = 0; int x = 0; - switch (PyTuple_GET_SIZE(args)) { + switch (nargs) { case 0: - break; case 2: - if (!PyArg_ParseTuple(args, "ii:inch", &y, &x)) { - goto exit; - } - group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.inch requires 0 to 2 arguments"); goto exit; } - return_value = _curses_window_inch_impl((PyCursesWindowObject *)self, group_right_1, y, x); + if (nargs >= 2) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + group_right_1 = 1; + } + return_value = _curses_window_inch_impl((PyCursesWindowObject *)self, group_right_1, y, x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_instr__doc__, +"instr([y, x,] [n])\n" +"Return the text of the window as a bytes object.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" n\n" +" Maximal number of bytes. The rest of the line by default.\n" +"\n" +"Read from the current cursor position, or from y, x if specified, to\n" +"the end of the line or at most n bytes if n is specified, and return\n" +"the text in the encoding of the current locale, with attributes and\n" +"color pairs stripped."); + +#define _CURSES_WINDOW_INSTR_METHODDEF \ + {"instr", _PyCFunction_CAST(_curses_window_instr), METH_FASTCALL, _curses_window_instr__doc__}, + +static PyObject * +_curses_window_instr_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x, int group_right_2, unsigned int n); + +static PyObject * +_curses_window_instr(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int y = 0; + int x = 0; + int group_right_2 = 0; + unsigned int n = 0; + + if (nargs > 3) { + PyErr_SetString(PyExc_TypeError, "_curses.window.instr requires 0 to 3 arguments"); + goto exit; + } + if (nargs >= 2) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + group_right_1 = 1; + } + if (nargs == 1 || nargs == 3) { + if (!_PyLong_UnsignedInt_Converter(args[nargs - 1], &n)) { + goto exit; + } + group_right_2 = 1; + } + return_value = _curses_window_instr_impl((PyCursesWindowObject *)self, group_right_1, y, x, group_right_2, n); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_get_wstr__doc__, +"get_wstr([y, x,] n=2047)\n" +"Read a line of input and return it as a str.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" n\n" +" Maximal number of characters.\n" +"\n" +"This is the wide-character variant of getstr(). The input is read\n" +"with primitive line editing capacity and does not include the\n" +"terminating newline. At most n characters are read."); + +#define _CURSES_WINDOW_GET_WSTR_METHODDEF \ + {"get_wstr", _PyCFunction_CAST(_curses_window_get_wstr), METH_FASTCALL, _curses_window_get_wstr__doc__}, + +static PyObject * +_curses_window_get_wstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, unsigned int n); + +static PyObject * +_curses_window_get_wstr(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + unsigned int n = 2047; + + Py_ssize_t offset = 0; + if (nargs > 3) { + PyErr_SetString(PyExc_TypeError, "_curses.window.get_wstr requires 0 to 3 arguments"); + goto exit; + } + if (nargs >= 2) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + offset += 2; + group_left_1 = 1; + } + if (nargs <= offset) { + goto skip_optional; + } + if (!_PyLong_UnsignedInt_Converter(args[offset], &n)) { + goto exit; + } +skip_optional: + return_value = _curses_window_get_wstr_impl((PyCursesWindowObject *)self, group_left_1, y, x, n); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_in_wstr__doc__, +"in_wstr([y, x,] [n])\n" +"Return the text of the window as a str.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" n\n" +" Maximal number of characters. The rest of the line by default.\n" +"\n" +"This is the wide-character variant of instr(). Read from the\n" +"current cursor position, or from y, x if specified, to the end of\n" +"the line or at most n characters if n is specified, with attributes\n" +"and color pairs stripped."); + +#define _CURSES_WINDOW_IN_WSTR_METHODDEF \ + {"in_wstr", _PyCFunction_CAST(_curses_window_in_wstr), METH_FASTCALL, _curses_window_in_wstr__doc__}, + +static PyObject * +_curses_window_in_wstr_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x, int group_right_2, unsigned int n); + +static PyObject * +_curses_window_in_wstr(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int y = 0; + int x = 0; + int group_right_2 = 0; + unsigned int n = 0; + + if (nargs > 3) { + PyErr_SetString(PyExc_TypeError, "_curses.window.in_wstr requires 0 to 3 arguments"); + goto exit; + } + if (nargs >= 2) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + group_right_1 = 1; + } + if (nargs == 1 || nargs == 3) { + if (!_PyLong_UnsignedInt_Converter(args[nargs - 1], &n)) { + goto exit; + } + group_right_2 = 1; + } + return_value = _curses_window_in_wstr_impl((PyCursesWindowObject *)self, group_right_1, y, x, group_right_2, n); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_in_wchstr__doc__, +"in_wchstr([y, x,] [n])\n" +"Return the styled cells of the window as a complexstr.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" n\n" +" Maximal number of cells. The rest of the line by default.\n" +"\n" +"Read from the current cursor position, or from y, x if specified,\n" +"to the end of the line or at most n cells if n is specified.\n" +"Unlike instr() and in_wstr(), each cell keeps its attributes and\n" +"color pair, so the result can be written back unchanged with\n" +"addstr()."); + +#define _CURSES_WINDOW_IN_WCHSTR_METHODDEF \ + {"in_wchstr", _PyCFunction_CAST(_curses_window_in_wchstr), METH_FASTCALL, _curses_window_in_wchstr__doc__}, + +static PyObject * +_curses_window_in_wchstr_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x, int group_right_2, + unsigned int n); + +static PyObject * +_curses_window_in_wchstr(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int y = 0; + int x = 0; + int group_right_2 = 0; + unsigned int n = 0; + + if (nargs > 3) { + PyErr_SetString(PyExc_TypeError, "_curses.window.in_wchstr requires 0 to 3 arguments"); + goto exit; + } + if (nargs >= 2) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + group_right_1 = 1; + } + if (nargs == 1 || nargs == 3) { + if (!_PyLong_UnsignedInt_Converter(args[nargs - 1], &n)) { + goto exit; + } + group_right_2 = 1; + } + return_value = _curses_window_in_wchstr_impl((PyCursesWindowObject *)self, group_right_1, y, x, group_right_2, n); exit: return return_value; @@ -1580,7 +2002,7 @@ PyDoc_STRVAR(_curses_window_insstr__doc__, "moving to y, x, if specified)."); #define _CURSES_WINDOW_INSSTR_METHODDEF \ - {"insstr", (PyCFunction)_curses_window_insstr, METH_VARARGS, _curses_window_insstr__doc__}, + {"insstr", _PyCFunction_CAST(_curses_window_insstr), METH_FASTCALL, _curses_window_insstr__doc__}, static PyObject * _curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1, @@ -1588,7 +2010,7 @@ _curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1, attr_t attr); static PyObject * -_curses_window_insstr(PyObject *self, PyObject *args) +_curses_window_insstr(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_left_1 = 0; @@ -1598,34 +2020,29 @@ _curses_window_insstr(PyObject *self, PyObject *args) int group_right_1 = 0; attr_t attr = 0; - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O:insstr", &str)) { - goto exit; - } - break; - case 2: - if (!PyArg_ParseTuple(args, "OO&:insstr", &str, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - case 3: - if (!PyArg_ParseTuple(args, "iiO:insstr", &y, &x, &str)) { - goto exit; - } - group_left_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOO&:insstr", &y, &x, &str, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.insstr requires 1 to 4 arguments"); + Py_ssize_t offset = 0; + if (nargs < 1 || nargs > 4) { + PyErr_SetString(PyExc_TypeError, "_curses.window.insstr requires 1 to 4 arguments"); + goto exit; + } + if (nargs >= 3) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { goto exit; + } + offset += 2; + group_left_1 = 1; + } + str = args[offset]; + if (nargs == 2 || nargs == 4) { + if (!attr_converter(args[nargs - 1], &attr)) { + goto exit; + } + group_right_1 = 1; } return_value = _curses_window_insstr_impl((PyCursesWindowObject *)self, group_left_1, y, x, str, group_right_1, attr); @@ -1656,7 +2073,7 @@ PyDoc_STRVAR(_curses_window_insnstr__doc__, "does not change (after moving to y, x, if specified)."); #define _CURSES_WINDOW_INSNSTR_METHODDEF \ - {"insnstr", (PyCFunction)_curses_window_insnstr, METH_VARARGS, _curses_window_insnstr__doc__}, + {"insnstr", _PyCFunction_CAST(_curses_window_insnstr), METH_FASTCALL, _curses_window_insnstr__doc__}, static PyObject * _curses_window_insnstr_impl(PyCursesWindowObject *self, int group_left_1, @@ -1664,7 +2081,7 @@ _curses_window_insnstr_impl(PyCursesWindowObject *self, int group_left_1, int group_right_1, attr_t attr); static PyObject * -_curses_window_insnstr(PyObject *self, PyObject *args) +_curses_window_insnstr(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_left_1 = 0; @@ -1675,34 +2092,33 @@ _curses_window_insnstr(PyObject *self, PyObject *args) int group_right_1 = 0; attr_t attr = 0; - switch (PyTuple_GET_SIZE(args)) { - case 2: - if (!PyArg_ParseTuple(args, "Oi:insnstr", &str, &n)) { - goto exit; - } - break; - case 3: - if (!PyArg_ParseTuple(args, "OiO&:insnstr", &str, &n, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOi:insnstr", &y, &x, &str, &n)) { - goto exit; - } - group_left_1 = 1; - break; - case 5: - if (!PyArg_ParseTuple(args, "iiOiO&:insnstr", &y, &x, &str, &n, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.insnstr requires 2 to 5 arguments"); + Py_ssize_t offset = 0; + if (nargs < 2 || nargs > 5) { + PyErr_SetString(PyExc_TypeError, "_curses.window.insnstr requires 2 to 5 arguments"); + goto exit; + } + if (nargs >= 4) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + offset += 2; + group_left_1 = 1; + } + str = args[offset]; + n = PyLong_AsInt(args[offset + 1]); + if (n == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs == 3 || nargs == 5) { + if (!attr_converter(args[nargs - 1], &attr)) { goto exit; + } + group_right_1 = 1; } return_value = _curses_window_insnstr_impl((PyCursesWindowObject *)self, group_left_1, y, x, str, n, group_right_1, attr); @@ -1755,7 +2171,7 @@ PyDoc_STRVAR(_curses_window_noutrefresh__doc__, "screen. To accomplish that, call doupdate()."); #define _CURSES_WINDOW_NOUTREFRESH_METHODDEF \ - {"noutrefresh", (PyCFunction)_curses_window_noutrefresh, METH_VARARGS, _curses_window_noutrefresh__doc__}, + {"noutrefresh", _PyCFunction_CAST(_curses_window_noutrefresh), METH_FASTCALL, _curses_window_noutrefresh__doc__}, static PyObject * _curses_window_noutrefresh_impl(PyCursesWindowObject *self, @@ -1764,7 +2180,7 @@ _curses_window_noutrefresh_impl(PyCursesWindowObject *self, int smaxcol); static PyObject * -_curses_window_noutrefresh(PyObject *self, PyObject *args) +_curses_window_noutrefresh(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_right_1 = 0; @@ -1775,19 +2191,41 @@ _curses_window_noutrefresh(PyObject *self, PyObject *args) int smaxrow = 0; int smaxcol = 0; - switch (PyTuple_GET_SIZE(args)) { + switch (nargs) { case 0: - break; case 6: - if (!PyArg_ParseTuple(args, "iiiiii:noutrefresh", &pminrow, &pmincol, &sminrow, &smincol, &smaxrow, &smaxcol)) { - goto exit; - } - group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.noutrefresh requires 0 to 6 arguments"); goto exit; } + if (nargs >= 6) { + pminrow = PyLong_AsInt(args[0]); + if (pminrow == -1 && PyErr_Occurred()) { + goto exit; + } + pmincol = PyLong_AsInt(args[1]); + if (pmincol == -1 && PyErr_Occurred()) { + goto exit; + } + sminrow = PyLong_AsInt(args[2]); + if (sminrow == -1 && PyErr_Occurred()) { + goto exit; + } + smincol = PyLong_AsInt(args[3]); + if (smincol == -1 && PyErr_Occurred()) { + goto exit; + } + smaxrow = PyLong_AsInt(args[4]); + if (smaxrow == -1 && PyErr_Occurred()) { + goto exit; + } + smaxcol = PyLong_AsInt(args[5]); + if (smaxcol == -1 && PyErr_Occurred()) { + goto exit; + } + group_right_1 = 1; + } return_value = _curses_window_noutrefresh_impl((PyCursesWindowObject *)self, group_right_1, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol); exit: @@ -1837,7 +2275,7 @@ PyDoc_STRVAR(_curses_window_overlay__doc__, "a rectangle in the destination window."); #define _CURSES_WINDOW_OVERLAY_METHODDEF \ - {"overlay", (PyCFunction)_curses_window_overlay, METH_VARARGS, _curses_window_overlay__doc__}, + {"overlay", _PyCFunction_CAST(_curses_window_overlay), METH_FASTCALL, _curses_window_overlay__doc__}, static PyObject * _curses_window_overlay_impl(PyCursesWindowObject *self, @@ -1846,7 +2284,7 @@ _curses_window_overlay_impl(PyCursesWindowObject *self, int dmincol, int dmaxrow, int dmaxcol); static PyObject * -_curses_window_overlay(PyObject *self, PyObject *args) +_curses_window_overlay(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; PyCursesWindowObject *destwin; @@ -1858,22 +2296,46 @@ _curses_window_overlay(PyObject *self, PyObject *args) int dmaxrow = 0; int dmaxcol = 0; - switch (PyTuple_GET_SIZE(args)) { + switch (nargs) { case 1: - if (!PyArg_ParseTuple(args, "O!:overlay", clinic_state()->window_type, &destwin)) { - goto exit; - } - break; case 7: - if (!PyArg_ParseTuple(args, "O!iiiiii:overlay", clinic_state()->window_type, &destwin, &sminrow, &smincol, &dminrow, &dmincol, &dmaxrow, &dmaxcol)) { - goto exit; - } - group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.overlay requires 1 to 7 arguments"); goto exit; } + if (!PyObject_TypeCheck(args[0], clinic_state()->window_type)) { + _PyArg_BadArgument("overlay", "argument 1", (clinic_state()->window_type)->tp_name, args[0]); + goto exit; + } + destwin = (PyCursesWindowObject *)args[0]; + if (nargs >= 7) { + sminrow = PyLong_AsInt(args[1]); + if (sminrow == -1 && PyErr_Occurred()) { + goto exit; + } + smincol = PyLong_AsInt(args[2]); + if (smincol == -1 && PyErr_Occurred()) { + goto exit; + } + dminrow = PyLong_AsInt(args[3]); + if (dminrow == -1 && PyErr_Occurred()) { + goto exit; + } + dmincol = PyLong_AsInt(args[4]); + if (dmincol == -1 && PyErr_Occurred()) { + goto exit; + } + dmaxrow = PyLong_AsInt(args[5]); + if (dmaxrow == -1 && PyErr_Occurred()) { + goto exit; + } + dmaxcol = PyLong_AsInt(args[6]); + if (dmaxcol == -1 && PyErr_Occurred()) { + goto exit; + } + group_right_1 = 1; + } return_value = _curses_window_overlay_impl((PyCursesWindowObject *)self, destwin, group_right_1, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol); exit: @@ -1896,7 +2358,7 @@ PyDoc_STRVAR(_curses_window_overwrite__doc__, "a rectangle in the destination window."); #define _CURSES_WINDOW_OVERWRITE_METHODDEF \ - {"overwrite", (PyCFunction)_curses_window_overwrite, METH_VARARGS, _curses_window_overwrite__doc__}, + {"overwrite", _PyCFunction_CAST(_curses_window_overwrite), METH_FASTCALL, _curses_window_overwrite__doc__}, static PyObject * _curses_window_overwrite_impl(PyCursesWindowObject *self, @@ -1906,7 +2368,7 @@ _curses_window_overwrite_impl(PyCursesWindowObject *self, int dmaxcol); static PyObject * -_curses_window_overwrite(PyObject *self, PyObject *args) +_curses_window_overwrite(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; PyCursesWindowObject *destwin; @@ -1918,22 +2380,46 @@ _curses_window_overwrite(PyObject *self, PyObject *args) int dmaxrow = 0; int dmaxcol = 0; - switch (PyTuple_GET_SIZE(args)) { + switch (nargs) { case 1: - if (!PyArg_ParseTuple(args, "O!:overwrite", clinic_state()->window_type, &destwin)) { - goto exit; - } - break; case 7: - if (!PyArg_ParseTuple(args, "O!iiiiii:overwrite", clinic_state()->window_type, &destwin, &sminrow, &smincol, &dminrow, &dmincol, &dmaxrow, &dmaxcol)) { - goto exit; - } - group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.overwrite requires 1 to 7 arguments"); goto exit; } + if (!PyObject_TypeCheck(args[0], clinic_state()->window_type)) { + _PyArg_BadArgument("overwrite", "argument 1", (clinic_state()->window_type)->tp_name, args[0]); + goto exit; + } + destwin = (PyCursesWindowObject *)args[0]; + if (nargs >= 7) { + sminrow = PyLong_AsInt(args[1]); + if (sminrow == -1 && PyErr_Occurred()) { + goto exit; + } + smincol = PyLong_AsInt(args[2]); + if (smincol == -1 && PyErr_Occurred()) { + goto exit; + } + dminrow = PyLong_AsInt(args[3]); + if (dminrow == -1 && PyErr_Occurred()) { + goto exit; + } + dmincol = PyLong_AsInt(args[4]); + if (dmincol == -1 && PyErr_Occurred()) { + goto exit; + } + dmaxrow = PyLong_AsInt(args[5]); + if (dmaxrow == -1 && PyErr_Occurred()) { + goto exit; + } + dmaxcol = PyLong_AsInt(args[6]); + if (dmaxcol == -1 && PyErr_Occurred()) { + goto exit; + } + group_right_1 = 1; + } return_value = _curses_window_overwrite_impl((PyCursesWindowObject *)self, destwin, group_right_1, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol); exit: @@ -2025,7 +2511,7 @@ PyDoc_STRVAR(_curses_window_refresh__doc__, "pmincol, sminrow, or smincol are treated as if they were zero."); #define _CURSES_WINDOW_REFRESH_METHODDEF \ - {"refresh", (PyCFunction)_curses_window_refresh, METH_VARARGS, _curses_window_refresh__doc__}, + {"refresh", _PyCFunction_CAST(_curses_window_refresh), METH_FASTCALL, _curses_window_refresh__doc__}, static PyObject * _curses_window_refresh_impl(PyCursesWindowObject *self, int group_right_1, @@ -2033,7 +2519,7 @@ _curses_window_refresh_impl(PyCursesWindowObject *self, int group_right_1, int smincol, int smaxrow, int smaxcol); static PyObject * -_curses_window_refresh(PyObject *self, PyObject *args) +_curses_window_refresh(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_right_1 = 0; @@ -2044,19 +2530,41 @@ _curses_window_refresh(PyObject *self, PyObject *args) int smaxrow = 0; int smaxcol = 0; - switch (PyTuple_GET_SIZE(args)) { + switch (nargs) { case 0: - break; case 6: - if (!PyArg_ParseTuple(args, "iiiiii:refresh", &pminrow, &pmincol, &sminrow, &smincol, &smaxrow, &smaxcol)) { - goto exit; - } - group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.refresh requires 0 to 6 arguments"); goto exit; } + if (nargs >= 6) { + pminrow = PyLong_AsInt(args[0]); + if (pminrow == -1 && PyErr_Occurred()) { + goto exit; + } + pmincol = PyLong_AsInt(args[1]); + if (pmincol == -1 && PyErr_Occurred()) { + goto exit; + } + sminrow = PyLong_AsInt(args[2]); + if (sminrow == -1 && PyErr_Occurred()) { + goto exit; + } + smincol = PyLong_AsInt(args[3]); + if (smincol == -1 && PyErr_Occurred()) { + goto exit; + } + smaxrow = PyLong_AsInt(args[4]); + if (smaxrow == -1 && PyErr_Occurred()) { + goto exit; + } + smaxcol = PyLong_AsInt(args[5]); + if (smaxcol == -1 && PyErr_Occurred()) { + goto exit; + } + group_right_1 = 1; + } return_value = _curses_window_refresh_impl((PyCursesWindowObject *)self, group_right_1, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol); exit: @@ -2124,14 +2632,14 @@ PyDoc_STRVAR(_curses_window_subwin__doc__, "to the lower right corner of the window."); #define _CURSES_WINDOW_SUBWIN_METHODDEF \ - {"subwin", (PyCFunction)_curses_window_subwin, METH_VARARGS, _curses_window_subwin__doc__}, + {"subwin", _PyCFunction_CAST(_curses_window_subwin), METH_FASTCALL, _curses_window_subwin__doc__}, static PyObject * _curses_window_subwin_impl(PyCursesWindowObject *self, int group_left_1, int nlines, int ncols, int begin_y, int begin_x); static PyObject * -_curses_window_subwin(PyObject *self, PyObject *args) +_curses_window_subwin(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_left_1 = 0; @@ -2140,22 +2648,33 @@ _curses_window_subwin(PyObject *self, PyObject *args) int begin_y; int begin_x; - switch (PyTuple_GET_SIZE(args)) { + switch (nargs) { case 2: - if (!PyArg_ParseTuple(args, "ii:subwin", &begin_y, &begin_x)) { - goto exit; - } - break; case 4: - if (!PyArg_ParseTuple(args, "iiii:subwin", &nlines, &ncols, &begin_y, &begin_x)) { - goto exit; - } - group_left_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.window.subwin requires 2 to 4 arguments"); goto exit; } + if (nargs >= 4) { + nlines = PyLong_AsInt(args[0]); + if (nlines == -1 && PyErr_Occurred()) { + goto exit; + } + ncols = PyLong_AsInt(args[1]); + if (ncols == -1 && PyErr_Occurred()) { + goto exit; + } + group_left_1 = 1; + } + begin_y = PyLong_AsInt(args[nargs - 2]); + if (begin_y == -1 && PyErr_Occurred()) { + goto exit; + } + begin_x = PyLong_AsInt(args[nargs - 1]); + if (begin_x == -1 && PyErr_Occurred()) { + goto exit; + } return_value = _curses_window_subwin_impl((PyCursesWindowObject *)self, group_left_1, nlines, ncols, begin_y, begin_x); exit: @@ -2173,31 +2692,29 @@ PyDoc_STRVAR(_curses_window_scroll__doc__, "negative."); #define _CURSES_WINDOW_SCROLL_METHODDEF \ - {"scroll", (PyCFunction)_curses_window_scroll, METH_VARARGS, _curses_window_scroll__doc__}, + {"scroll", _PyCFunction_CAST(_curses_window_scroll), METH_FASTCALL, _curses_window_scroll__doc__}, static PyObject * _curses_window_scroll_impl(PyCursesWindowObject *self, int group_right_1, int lines); static PyObject * -_curses_window_scroll(PyObject *self, PyObject *args) +_curses_window_scroll(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_right_1 = 0; int lines = 1; - switch (PyTuple_GET_SIZE(args)) { - case 0: - break; - case 1: - if (!PyArg_ParseTuple(args, "i:scroll", &lines)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.scroll requires 0 to 1 arguments"); + if (nargs > 1) { + PyErr_SetString(PyExc_TypeError, "_curses.window.scroll requires 0 to 1 arguments"); + goto exit; + } + if (nargs >= 1) { + lines = PyLong_AsInt(args[0]); + if (lines == -1 && PyErr_Occurred()) { goto exit; + } + group_right_1 = 1; } return_value = _curses_window_scroll_impl((PyCursesWindowObject *)self, group_right_1, lines); @@ -2214,14 +2731,14 @@ PyDoc_STRVAR(_curses_window_touchline__doc__, "(changed=False)."); #define _CURSES_WINDOW_TOUCHLINE_METHODDEF \ - {"touchline", (PyCFunction)_curses_window_touchline, METH_VARARGS, _curses_window_touchline__doc__}, + {"touchline", _PyCFunction_CAST(_curses_window_touchline), METH_FASTCALL, _curses_window_touchline__doc__}, static PyObject * _curses_window_touchline_impl(PyCursesWindowObject *self, int start, int count, int group_right_1, int changed); static PyObject * -_curses_window_touchline(PyObject *self, PyObject *args) +_curses_window_touchline(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int start; @@ -2229,21 +2746,24 @@ _curses_window_touchline(PyObject *self, PyObject *args) int group_right_1 = 0; int changed = 1; - switch (PyTuple_GET_SIZE(args)) { - case 2: - if (!PyArg_ParseTuple(args, "ii:touchline", &start, &count)) { - goto exit; - } - break; - case 3: - if (!PyArg_ParseTuple(args, "iip:touchline", &start, &count, &changed)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.touchline requires 2 to 3 arguments"); + if (nargs < 2 || nargs > 3) { + PyErr_SetString(PyExc_TypeError, "_curses.window.touchline requires 2 to 3 arguments"); + goto exit; + } + start = PyLong_AsInt(args[0]); + if (start == -1 && PyErr_Occurred()) { + goto exit; + } + count = PyLong_AsInt(args[1]); + if (count == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs >= 3) { + changed = PyObject_IsTrue(args[2]); + if (changed < 0) { goto exit; + } + group_right_1 = 1; } return_value = _curses_window_touchline_impl((PyCursesWindowObject *)self, start, count, group_right_1, changed); @@ -2267,7 +2787,7 @@ PyDoc_STRVAR(_curses_window_vline__doc__, " Attributes for the character."); #define _CURSES_WINDOW_VLINE_METHODDEF \ - {"vline", (PyCFunction)_curses_window_vline, METH_VARARGS, _curses_window_vline__doc__}, + {"vline", _PyCFunction_CAST(_curses_window_vline), METH_FASTCALL, _curses_window_vline__doc__}, static PyObject * _curses_window_vline_impl(PyCursesWindowObject *self, int group_left_1, @@ -2275,7 +2795,7 @@ _curses_window_vline_impl(PyCursesWindowObject *self, int group_left_1, int group_right_1, attr_t attr); static PyObject * -_curses_window_vline(PyObject *self, PyObject *args) +_curses_window_vline(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_left_1 = 0; @@ -2286,34 +2806,33 @@ _curses_window_vline(PyObject *self, PyObject *args) int group_right_1 = 0; attr_t attr = 0; - switch (PyTuple_GET_SIZE(args)) { - case 2: - if (!PyArg_ParseTuple(args, "Oi:vline", &ch, &n)) { - goto exit; - } - break; - case 3: - if (!PyArg_ParseTuple(args, "OiO&:vline", &ch, &n, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOi:vline", &y, &x, &ch, &n)) { - goto exit; - } - group_left_1 = 1; - break; - case 5: - if (!PyArg_ParseTuple(args, "iiOiO&:vline", &y, &x, &ch, &n, attr_converter, &attr)) { - goto exit; - } - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_curses.window.vline requires 2 to 5 arguments"); + Py_ssize_t offset = 0; + if (nargs < 2 || nargs > 5) { + PyErr_SetString(PyExc_TypeError, "_curses.window.vline requires 2 to 5 arguments"); + goto exit; + } + if (nargs >= 4) { + y = PyLong_AsInt(args[0]); + if (y == -1 && PyErr_Occurred()) { + goto exit; + } + x = PyLong_AsInt(args[1]); + if (x == -1 && PyErr_Occurred()) { + goto exit; + } + offset += 2; + group_left_1 = 1; + } + ch = args[offset]; + n = PyLong_AsInt(args[offset + 1]); + if (n == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs == 3 || nargs == 5) { + if (!attr_converter(args[nargs - 1], &attr)) { goto exit; + } + group_right_1 = 1; } return_value = _curses_window_vline_impl((PyCursesWindowObject *)self, group_left_1, y, x, ch, n, group_right_1, attr); @@ -2348,7 +2867,7 @@ _curses_filter(PyObject *module, PyObject *Py_UNUSED(ignored)) #endif /* defined(HAVE_CURSES_FILTER) */ -#if defined(HAVE_CURSES_NOFILTER) +#if defined(_Py_HAVE_CURSES_NOFILTER) PyDoc_STRVAR(_curses_nofilter__doc__, "nofilter($module, /)\n" @@ -2372,7 +2891,7 @@ _curses_nofilter(PyObject *module, PyObject *Py_UNUSED(ignored)) return _curses_nofilter_impl(module); } -#endif /* defined(HAVE_CURSES_NOFILTER) */ +#endif /* defined(_Py_HAVE_CURSES_NOFILTER) */ PyDoc_STRVAR(_curses_baudrate__doc__, "baudrate($module, /)\n" @@ -3047,7 +3566,7 @@ PyDoc_STRVAR(_curses_getwin__doc__, #define _CURSES_GETWIN_METHODDEF \ {"getwin", (PyCFunction)_curses_getwin, METH_O, _curses_getwin__doc__}, -#if defined(HAVE_CURSES_SCR_DUMP) +#if defined(_Py_HAVE_CURSES_SCR_DUMP) PyDoc_STRVAR(_curses_scr_dump__doc__, "scr_dump($module, filename, /)\n" @@ -3064,9 +3583,9 @@ PyDoc_STRVAR(_curses_scr_dump__doc__, #define _CURSES_SCR_DUMP_METHODDEF \ {"scr_dump", (PyCFunction)_curses_scr_dump, METH_O, _curses_scr_dump__doc__}, -#endif /* defined(HAVE_CURSES_SCR_DUMP) */ +#endif /* defined(_Py_HAVE_CURSES_SCR_DUMP) */ -#if defined(HAVE_CURSES_SCR_DUMP) +#if defined(_Py_HAVE_CURSES_SCR_DUMP) PyDoc_STRVAR(_curses_scr_restore__doc__, "scr_restore($module, filename, /)\n" @@ -3083,9 +3602,9 @@ PyDoc_STRVAR(_curses_scr_restore__doc__, #define _CURSES_SCR_RESTORE_METHODDEF \ {"scr_restore", (PyCFunction)_curses_scr_restore, METH_O, _curses_scr_restore__doc__}, -#endif /* defined(HAVE_CURSES_SCR_DUMP) */ +#endif /* defined(_Py_HAVE_CURSES_SCR_DUMP) */ -#if defined(HAVE_CURSES_SCR_DUMP) +#if defined(_Py_HAVE_CURSES_SCR_DUMP) PyDoc_STRVAR(_curses_scr_init__doc__, "scr_init($module, filename, /)\n" @@ -3102,9 +3621,9 @@ PyDoc_STRVAR(_curses_scr_init__doc__, #define _CURSES_SCR_INIT_METHODDEF \ {"scr_init", (PyCFunction)_curses_scr_init, METH_O, _curses_scr_init__doc__}, -#endif /* defined(HAVE_CURSES_SCR_DUMP) */ +#endif /* defined(_Py_HAVE_CURSES_SCR_DUMP) */ -#if defined(HAVE_CURSES_SCR_DUMP) +#if defined(_Py_HAVE_CURSES_SCR_DUMP) && defined(_Py_HAVE_CURSES_SCR_SET) PyDoc_STRVAR(_curses_scr_set__doc__, "scr_set($module, filename, /)\n" @@ -3120,7 +3639,7 @@ PyDoc_STRVAR(_curses_scr_set__doc__, #define _CURSES_SCR_SET_METHODDEF \ {"scr_set", (PyCFunction)_curses_scr_set, METH_O, _curses_scr_set__doc__}, -#endif /* defined(HAVE_CURSES_SCR_DUMP) */ +#endif /* defined(_Py_HAVE_CURSES_SCR_DUMP) && defined(_Py_HAVE_CURSES_SCR_SET) */ PyDoc_STRVAR(_curses_halfdelay__doc__, "halfdelay($module, tenths, /)\n" @@ -3259,7 +3778,7 @@ _curses_has_key(PyObject *module, PyObject *arg) #endif /* defined(HAVE_CURSES_HAS_KEY) */ -#if defined(HAVE_CURSES_DEFINE_KEY) +#if defined(_Py_HAVE_CURSES_DEFINE_KEY) PyDoc_STRVAR(_curses_define_key__doc__, "define_key($module, definition, keycode, /)\n" @@ -3296,15 +3815,10 @@ _curses_define_key(PyObject *module, PyObject *const *args, Py_ssize_t nargs) definition = NULL; } else if (PyUnicode_Check(args[0])) { - Py_ssize_t definition_length; - definition = PyUnicode_AsUTF8AndSize(args[0], &definition_length); + definition = _PyUnicode_AsUTF8NoNUL(args[0]); if (definition == NULL) { goto exit; } - if (strlen(definition) != (size_t)definition_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("define_key", "argument 1", "str or None", args[0]); @@ -3320,9 +3834,9 @@ _curses_define_key(PyObject *module, PyObject *const *args, Py_ssize_t nargs) return return_value; } -#endif /* defined(HAVE_CURSES_DEFINE_KEY) */ +#endif /* defined(_Py_HAVE_CURSES_DEFINE_KEY) */ -#if defined(HAVE_CURSES_KEY_DEFINED) +#if defined(_Py_HAVE_CURSES_KEY_DEFINED) PyDoc_STRVAR(_curses_key_defined__doc__, "key_defined($module, definition, /)\n" @@ -3352,24 +3866,19 @@ _curses_key_defined(PyObject *module, PyObject *arg) _PyArg_BadArgument("key_defined", "argument", "str", arg); goto exit; } - Py_ssize_t definition_length; - definition = PyUnicode_AsUTF8AndSize(arg, &definition_length); + definition = _PyUnicode_AsUTF8NoNUL(arg); if (definition == NULL) { goto exit; } - if (strlen(definition) != (size_t)definition_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _curses_key_defined_impl(module, definition); exit: return return_value; } -#endif /* defined(HAVE_CURSES_KEY_DEFINED) */ +#endif /* defined(_Py_HAVE_CURSES_KEY_DEFINED) */ -#if defined(HAVE_CURSES_KEYOK) +#if defined(_Py_HAVE_CURSES_KEYOK) PyDoc_STRVAR(_curses_keyok__doc__, "keyok($module, keycode, enable, /)\n" @@ -3412,7 +3921,7 @@ _curses_keyok(PyObject *module, PyObject *const *args, Py_ssize_t nargs) return return_value; } -#endif /* defined(HAVE_CURSES_KEYOK) */ +#endif /* defined(_Py_HAVE_CURSES_KEYOK) */ PyDoc_STRVAR(_curses_init_color__doc__, "init_color($module, color_number, r, g, b, /)\n" @@ -3673,7 +4182,7 @@ PyDoc_STRVAR(_curses_initscr__doc__, "\n" "Initialize the library.\n" "\n" -"Return a WindowObject which represents the whole screen."); +"Return a window object which represents the whole screen."); #define _CURSES_INITSCR_METHODDEF \ {"initscr", (PyCFunction)_curses_initscr, METH_NOARGS, _curses_initscr__doc__}, @@ -3755,15 +4264,10 @@ _curses_setupterm(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyO term = NULL; } else if (PyUnicode_Check(args[0])) { - Py_ssize_t term_length; - term = PyUnicode_AsUTF8AndSize(args[0], &term_length); + term = _PyUnicode_AsUTF8NoNUL(args[0]); if (term == NULL) { goto exit; } - if (strlen(term) != (size_t)term_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("setupterm", "argument 'term'", "str or None", args[0]); @@ -3825,15 +4329,10 @@ _curses_newterm(PyObject *module, PyObject *const *args, Py_ssize_t nargs) type = NULL; } else if (PyUnicode_Check(args[0])) { - Py_ssize_t type_length; - type = PyUnicode_AsUTF8AndSize(args[0], &type_length); + type = _PyUnicode_AsUTF8NoNUL(args[0]); if (type == NULL) { goto exit; } - if (strlen(type) != (size_t)type_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("newterm", "argument 1", "str or None", args[0]); @@ -3865,7 +4364,7 @@ PyDoc_STRVAR(_curses_set_term__doc__, #define _CURSES_SET_TERM_METHODDEF \ {"set_term", (PyCFunction)_curses_set_term, METH_O, _curses_set_term__doc__}, -#if defined(HAVE_CURSES_NEW_PRESCR) +#if defined(_Py_HAVE_CURSES_NEW_PRESCR) PyDoc_STRVAR(_curses_new_prescr__doc__, "new_prescr($module, /)\n" @@ -3888,7 +4387,7 @@ _curses_new_prescr(PyObject *module, PyObject *Py_UNUSED(ignored)) return _curses_new_prescr_impl(module); } -#endif /* defined(HAVE_CURSES_NEW_PRESCR) */ +#endif /* defined(_Py_HAVE_CURSES_NEW_PRESCR) */ #if defined(HAVE_CURSES_ESCDELAY) @@ -4232,7 +4731,7 @@ _curses_meta(PyObject *module, PyObject *arg) return return_value; } -#if (defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)) && (defined(HAVE_CURSES_HAS_MOUSE) || defined(PDCURSES)) +#if (defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)) && (defined(_Py_HAVE_CURSES_HAS_MOUSE) || defined(PDCURSES)) PyDoc_STRVAR(_curses_has_mouse__doc__, "has_mouse($module, /)\n" @@ -4252,7 +4751,7 @@ _curses_has_mouse(PyObject *module, PyObject *Py_UNUSED(ignored)) return _curses_has_mouse_impl(module); } -#endif /* (defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)) && (defined(HAVE_CURSES_HAS_MOUSE) || defined(PDCURSES)) */ +#endif /* (defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)) && (defined(_Py_HAVE_CURSES_HAS_MOUSE) || defined(PDCURSES)) */ #if (defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)) @@ -4440,14 +4939,14 @@ PyDoc_STRVAR(_curses_newwin__doc__, "lower right corner of the screen."); #define _CURSES_NEWWIN_METHODDEF \ - {"newwin", (PyCFunction)_curses_newwin, METH_VARARGS, _curses_newwin__doc__}, + {"newwin", _PyCFunction_CAST(_curses_newwin), METH_FASTCALL, _curses_newwin__doc__}, static PyObject * _curses_newwin_impl(PyObject *module, int nlines, int ncols, int group_right_1, int begin_y, int begin_x); static PyObject * -_curses_newwin(PyObject *module, PyObject *args) +_curses_newwin(PyObject *module, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int nlines; @@ -4456,22 +4955,33 @@ _curses_newwin(PyObject *module, PyObject *args) int begin_y = 0; int begin_x = 0; - switch (PyTuple_GET_SIZE(args)) { + switch (nargs) { case 2: - if (!PyArg_ParseTuple(args, "ii:newwin", &nlines, &ncols)) { - goto exit; - } - break; case 4: - if (!PyArg_ParseTuple(args, "iiii:newwin", &nlines, &ncols, &begin_y, &begin_x)) { - goto exit; - } - group_right_1 = 1; break; default: PyErr_SetString(PyExc_TypeError, "_curses.newwin requires 2 to 4 arguments"); goto exit; } + nlines = PyLong_AsInt(args[0]); + if (nlines == -1 && PyErr_Occurred()) { + goto exit; + } + ncols = PyLong_AsInt(args[1]); + if (ncols == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs >= 4) { + begin_y = PyLong_AsInt(args[2]); + if (begin_y == -1 && PyErr_Occurred()) { + goto exit; + } + begin_x = PyLong_AsInt(args[3]); + if (begin_x == -1 && PyErr_Occurred()) { + goto exit; + } + group_right_1 = 1; + } return_value = _curses_newwin_impl(module, nlines, ncols, group_right_1, begin_y, begin_x); exit: @@ -4664,16 +5174,15 @@ PyDoc_STRVAR(_curses_pair_number__doc__, {"pair_number", (PyCFunction)_curses_pair_number, METH_O, _curses_pair_number__doc__}, static PyObject * -_curses_pair_number_impl(PyObject *module, int attr); +_curses_pair_number_impl(PyObject *module, attr_t attr); static PyObject * _curses_pair_number(PyObject *module, PyObject *arg) { PyObject *return_value = NULL; - int attr; + attr_t attr; - attr = PyLong_AsInt(arg); - if (attr == -1 && PyErr_Occurred()) { + if (!attr_converter(arg, &attr)) { goto exit; } return_value = _curses_pair_number_impl(module, attr); @@ -4752,8 +5261,6 @@ _curses_qiflush(PyObject *module, PyObject *const *args, Py_ssize_t nargs) return return_value; } -#if (defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM)) - PyDoc_STRVAR(_curses_update_lines_cols__doc__, "update_lines_cols($module, /)\n" "--\n" @@ -4774,8 +5281,6 @@ _curses_update_lines_cols(PyObject *module, PyObject *Py_UNUSED(ignored)) return _curses_update_lines_cols_impl(module); } -#endif /* (defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM)) */ - PyDoc_STRVAR(_curses_raw__doc__, "raw($module, flag=True, /)\n" "--\n" @@ -5140,7 +5645,7 @@ _curses_termattrs(PyObject *module, PyObject *Py_UNUSED(ignored)) return _curses_termattrs_impl(module); } -#if defined(HAVE_CURSES_TERM_ATTRS) +#if defined(_Py_HAVE_CURSES_TERM_ATTRS) PyDoc_STRVAR(_curses_term_attrs__doc__, "term_attrs($module, /)\n" @@ -5163,7 +5668,7 @@ _curses_term_attrs(PyObject *module, PyObject *Py_UNUSED(ignored)) return _curses_term_attrs_impl(module); } -#endif /* defined(HAVE_CURSES_TERM_ATTRS) */ +#endif /* defined(_Py_HAVE_CURSES_TERM_ATTRS) */ PyDoc_STRVAR(_curses_termname__doc__, "termname($module, /)\n" @@ -5211,15 +5716,10 @@ _curses_tigetflag(PyObject *module, PyObject *arg) _PyArg_BadArgument("tigetflag", "argument", "str", arg); goto exit; } - Py_ssize_t capname_length; - capname = PyUnicode_AsUTF8AndSize(arg, &capname_length); + capname = _PyUnicode_AsUTF8NoNUL(arg); if (capname == NULL) { goto exit; } - if (strlen(capname) != (size_t)capname_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _curses_tigetflag_impl(module, capname); exit: @@ -5254,15 +5754,10 @@ _curses_tigetnum(PyObject *module, PyObject *arg) _PyArg_BadArgument("tigetnum", "argument", "str", arg); goto exit; } - Py_ssize_t capname_length; - capname = PyUnicode_AsUTF8AndSize(arg, &capname_length); + capname = _PyUnicode_AsUTF8NoNUL(arg); if (capname == NULL) { goto exit; } - if (strlen(capname) != (size_t)capname_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _curses_tigetnum_impl(module, capname); exit: @@ -5297,15 +5792,10 @@ _curses_tigetstr(PyObject *module, PyObject *arg) _PyArg_BadArgument("tigetstr", "argument", "str", arg); goto exit; } - Py_ssize_t capname_length; - capname = PyUnicode_AsUTF8AndSize(arg, &capname_length); + capname = _PyUnicode_AsUTF8NoNUL(arg); if (capname == NULL) { goto exit; } - if (strlen(capname) != (size_t)capname_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _curses_tigetstr_impl(module, capname); exit: @@ -5313,44 +5803,46 @@ _curses_tigetstr(PyObject *module, PyObject *arg) } PyDoc_STRVAR(_curses_tparm__doc__, -"tparm($module, str, i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0, i8=0,\n" -" i9=0, /)\n" +"tparm($module, str, /, *params)\n" "--\n" "\n" "Instantiate the specified byte string with the supplied parameters.\n" "\n" " str\n" -" Parameterized byte string obtained from the terminfo database."); +" Parameterized byte string obtained from the terminfo database.\n" +" params\n" +" Up to nine parameters.\n" +"\n" +"The parameters are integers, except in a few cases where they must be\n" +"bytes objects."); #define _CURSES_TPARM_METHODDEF \ {"tparm", _PyCFunction_CAST(_curses_tparm), METH_FASTCALL, _curses_tparm__doc__}, static PyObject * -_curses_tparm_impl(PyObject *module, const char *str, int i1, int i2, int i3, - int i4, int i5, int i6, int i7, int i8, int i9); +_curses_tparm_impl(PyObject *module, PyObject *string, PyObject *params); static PyObject * _curses_tparm(PyObject *module, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; - const char *str; - int i1 = 0; - int i2 = 0; - int i3 = 0; - int i4 = 0; - int i5 = 0; - int i6 = 0; - int i7 = 0; - int i8 = 0; - int i9 = 0; + PyObject *string; + PyObject *params = NULL; - if (!_PyArg_ParseStack(args, nargs, "y|iiiiiiiii:tparm", - &str, &i1, &i2, &i3, &i4, &i5, &i6, &i7, &i8, &i9)) { + if (!_PyArg_CheckPositional("tparm", nargs, 1, PY_SSIZE_T_MAX)) { + goto exit; + } + string = args[0]; + params = PyTuple_FromArray(args + 1, nargs - 1); + if (params == NULL) { goto exit; } - return_value = _curses_tparm_impl(module, str, i1, i2, i3, i4, i5, i6, i7, i8, i9); + return_value = _curses_tparm_impl(module, string, params); exit: + /* Cleanup for params */ + Py_XDECREF(params); + return return_value; } @@ -5395,10 +5887,12 @@ PyDoc_STRVAR(_curses_unctrl__doc__, "unctrl($module, ch, /)\n" "--\n" "\n" -"Return a string which is a printable representation of the character ch.\n" +"Return a bytes object which is a printable representation of ch.\n" "\n" -"Control characters are displayed as a caret followed by the character,\n" -"for example as ^C. Printing characters are left as they are."); +"Control characters are displayed as a caret followed by the\n" +"character, for example as ^C. Printing characters are left as they\n" +"are. Any attributes and color pair are ignored. ch must fit in a\n" +"single byte; use wunctrl() for other characters."); #define _CURSES_UNCTRL_METHODDEF \ {"unctrl", (PyCFunction)_curses_unctrl, METH_O, _curses_unctrl__doc__}, @@ -5659,16 +6153,15 @@ PyDoc_STRVAR(_curses_slk_attron__doc__, {"slk_attron", (PyCFunction)_curses_slk_attron, METH_O, _curses_slk_attron__doc__}, static PyObject * -_curses_slk_attron_impl(PyObject *module, long attr); +_curses_slk_attron_impl(PyObject *module, attr_t attr); static PyObject * _curses_slk_attron(PyObject *module, PyObject *arg) { PyObject *return_value = NULL; - long attr; + attr_t attr; - attr = PyLong_AsLong(arg); - if (attr == -1 && PyErr_Occurred()) { + if (!attr_converter(arg, &attr)) { goto exit; } return_value = _curses_slk_attron_impl(module, attr); @@ -5687,16 +6180,15 @@ PyDoc_STRVAR(_curses_slk_attroff__doc__, {"slk_attroff", (PyCFunction)_curses_slk_attroff, METH_O, _curses_slk_attroff__doc__}, static PyObject * -_curses_slk_attroff_impl(PyObject *module, long attr); +_curses_slk_attroff_impl(PyObject *module, attr_t attr); static PyObject * _curses_slk_attroff(PyObject *module, PyObject *arg) { PyObject *return_value = NULL; - long attr; + attr_t attr; - attr = PyLong_AsLong(arg); - if (attr == -1 && PyErr_Occurred()) { + if (!attr_converter(arg, &attr)) { goto exit; } return_value = _curses_slk_attroff_impl(module, attr); @@ -5715,16 +6207,15 @@ PyDoc_STRVAR(_curses_slk_attrset__doc__, {"slk_attrset", (PyCFunction)_curses_slk_attrset, METH_O, _curses_slk_attrset__doc__}, static PyObject * -_curses_slk_attrset_impl(PyObject *module, long attr); +_curses_slk_attrset_impl(PyObject *module, attr_t attr); static PyObject * _curses_slk_attrset(PyObject *module, PyObject *arg) { PyObject *return_value = NULL; - long attr; + attr_t attr; - attr = PyLong_AsLong(arg); - if (attr == -1 && PyErr_Occurred()) { + if (!attr_converter(arg, &attr)) { goto exit; } return_value = _curses_slk_attrset_impl(module, attr); @@ -5755,6 +6246,8 @@ _curses_slk_attr(PyObject *module, PyObject *Py_UNUSED(ignored)) #endif /* (defined(NCURSES_EXT_FUNCS) || defined(PDCURSES)) */ +#if defined(_Py_HAVE_CURSES_SLK_ATTR_ON) + PyDoc_STRVAR(_curses_slk_attr_on__doc__, "slk_attr_on($module, attr, /)\n" "--\n" @@ -5782,6 +6275,10 @@ _curses_slk_attr_on(PyObject *module, PyObject *arg) return return_value; } +#endif /* defined(_Py_HAVE_CURSES_SLK_ATTR_ON) */ + +#if defined(_Py_HAVE_CURSES_SLK_ATTR_OFF) + PyDoc_STRVAR(_curses_slk_attr_off__doc__, "slk_attr_off($module, attr, /)\n" "--\n" @@ -5809,6 +6306,10 @@ _curses_slk_attr_off(PyObject *module, PyObject *arg) return return_value; } +#endif /* defined(_Py_HAVE_CURSES_SLK_ATTR_OFF) */ + +#if defined(_Py_HAVE_CURSES_SLK_ATTR_SET) + PyDoc_STRVAR(_curses_slk_attr_set__doc__, "slk_attr_set($module, attr, pair=0, /)\n" "--\n" @@ -5847,6 +6348,10 @@ _curses_slk_attr_set(PyObject *module, PyObject *const *args, Py_ssize_t nargs) return return_value; } +#endif /* defined(_Py_HAVE_CURSES_SLK_ATTR_SET) */ + +#if defined(_Py_HAVE_CURSES_SLK_COLOR) + PyDoc_STRVAR(_curses_slk_color__doc__, "slk_color($module, pair, /)\n" "--\n" @@ -5874,6 +6379,8 @@ _curses_slk_color(PyObject *module, PyObject *arg) return return_value; } +#endif /* defined(_Py_HAVE_CURSES_SLK_COLOR) */ + #if defined(HAVE_CURSES_USE_ENV) PyDoc_STRVAR(_curses_use_env__doc__, @@ -6003,6 +6510,30 @@ _curses_has_extended_color_support(PyObject *module, PyObject *Py_UNUSED(ignored return _curses_has_extended_color_support_impl(module); } +#ifndef _CURSES_WINDOW_ATTR_GET_METHODDEF + #define _CURSES_WINDOW_ATTR_GET_METHODDEF +#endif /* !defined(_CURSES_WINDOW_ATTR_GET_METHODDEF) */ + +#ifndef _CURSES_WINDOW_ATTR_SET_METHODDEF + #define _CURSES_WINDOW_ATTR_SET_METHODDEF +#endif /* !defined(_CURSES_WINDOW_ATTR_SET_METHODDEF) */ + +#ifndef _CURSES_WINDOW_ATTR_ON_METHODDEF + #define _CURSES_WINDOW_ATTR_ON_METHODDEF +#endif /* !defined(_CURSES_WINDOW_ATTR_ON_METHODDEF) */ + +#ifndef _CURSES_WINDOW_ATTR_OFF_METHODDEF + #define _CURSES_WINDOW_ATTR_OFF_METHODDEF +#endif /* !defined(_CURSES_WINDOW_ATTR_OFF_METHODDEF) */ + +#ifndef _CURSES_WINDOW_COLOR_SET_METHODDEF + #define _CURSES_WINDOW_COLOR_SET_METHODDEF +#endif /* !defined(_CURSES_WINDOW_COLOR_SET_METHODDEF) */ + +#ifndef _CURSES_WINDOW_CHGAT_METHODDEF + #define _CURSES_WINDOW_CHGAT_METHODDEF +#endif /* !defined(_CURSES_WINDOW_CHGAT_METHODDEF) */ + #ifndef _CURSES_WINDOW_ENCLOSE_METHODDEF #define _CURSES_WINDOW_ENCLOSE_METHODDEF #endif /* !defined(_CURSES_WINDOW_ENCLOSE_METHODDEF) */ @@ -6135,10 +6666,6 @@ _curses_has_extended_color_support(PyObject *module, PyObject *Py_UNUSED(ignored #define _CURSES_MOUSEMASK_METHODDEF #endif /* !defined(_CURSES_MOUSEMASK_METHODDEF) */ -#ifndef _CURSES_UPDATE_LINES_COLS_METHODDEF - #define _CURSES_UPDATE_LINES_COLS_METHODDEF -#endif /* !defined(_CURSES_UPDATE_LINES_COLS_METHODDEF) */ - #ifndef _CURSES_RESIZETERM_METHODDEF #define _CURSES_RESIZETERM_METHODDEF #endif /* !defined(_CURSES_RESIZETERM_METHODDEF) */ @@ -6163,6 +6690,22 @@ _curses_has_extended_color_support(PyObject *module, PyObject *Py_UNUSED(ignored #define _CURSES_SLK_ATTR_METHODDEF #endif /* !defined(_CURSES_SLK_ATTR_METHODDEF) */ +#ifndef _CURSES_SLK_ATTR_ON_METHODDEF + #define _CURSES_SLK_ATTR_ON_METHODDEF +#endif /* !defined(_CURSES_SLK_ATTR_ON_METHODDEF) */ + +#ifndef _CURSES_SLK_ATTR_OFF_METHODDEF + #define _CURSES_SLK_ATTR_OFF_METHODDEF +#endif /* !defined(_CURSES_SLK_ATTR_OFF_METHODDEF) */ + +#ifndef _CURSES_SLK_ATTR_SET_METHODDEF + #define _CURSES_SLK_ATTR_SET_METHODDEF +#endif /* !defined(_CURSES_SLK_ATTR_SET_METHODDEF) */ + +#ifndef _CURSES_SLK_COLOR_METHODDEF + #define _CURSES_SLK_COLOR_METHODDEF +#endif /* !defined(_CURSES_SLK_COLOR_METHODDEF) */ + #ifndef _CURSES_USE_ENV_METHODDEF #define _CURSES_USE_ENV_METHODDEF #endif /* !defined(_CURSES_USE_ENV_METHODDEF) */ @@ -6174,4 +6717,4 @@ _curses_has_extended_color_support(PyObject *module, PyObject *Py_UNUSED(ignored #ifndef _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF #define _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF #endif /* !defined(_CURSES_ASSUME_DEFAULT_COLORS_METHODDEF) */ -/*[clinic end generated code: output=36fcacafc5044720 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2e47ca767f378409 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_datetimemodule.c.h b/Modules/clinic/_datetimemodule.c.h index fac41e7aefc7f4f..392a9da93ddbb41 100644 --- a/Modules/clinic/_datetimemodule.c.h +++ b/Modules/clinic/_datetimemodule.c.h @@ -7,6 +7,7 @@ preserve # include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(delta_new__doc__, "timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0,\n" @@ -957,15 +958,10 @@ datetime_time_isoformat(PyObject *self, PyObject *const *args, Py_ssize_t nargs, _PyArg_BadArgument("isoformat", "argument 'timespec'", "str", args[0]); goto exit; } - Py_ssize_t timespec_length; - timespec = PyUnicode_AsUTF8AndSize(args[0], ×pec_length); + timespec = _PyUnicode_AsUTF8NoNUL(args[0]); if (timespec == NULL) { goto exit; } - if (strlen(timespec) != (size_t)timespec_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } skip_optional_pos: return_value = datetime_time_isoformat_impl((PyDateTime_Time *)self, timespec); @@ -1816,15 +1812,10 @@ datetime_datetime_isoformat(PyObject *self, PyObject *const *args, Py_ssize_t na _PyArg_BadArgument("isoformat", "argument 'timespec'", "str", args[1]); goto exit; } - Py_ssize_t timespec_length; - timespec = PyUnicode_AsUTF8AndSize(args[1], ×pec_length); + timespec = _PyUnicode_AsUTF8NoNUL(args[1]); if (timespec == NULL) { goto exit; } - if (strlen(timespec) != (size_t)timespec_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } skip_optional_pos: return_value = datetime_datetime_isoformat_impl((PyDateTime_DateTime *)self, sep, timespec); @@ -2091,4 +2082,4 @@ datetime_datetime___reduce__(PyObject *self, PyObject *Py_UNUSED(ignored)) { return datetime_datetime___reduce___impl((PyDateTime_DateTime *)self); } -/*[clinic end generated code: output=8f63509398651723 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7bdfdfbd568c63ed input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_dbmmodule.c.h b/Modules/clinic/_dbmmodule.c.h index 6c979a4b0081df3..ad3a5b149299a2c 100644 --- a/Modules/clinic/_dbmmodule.c.h +++ b/Modules/clinic/_dbmmodule.c.h @@ -2,11 +2,69 @@ preserve [clinic start generated code]*/ -#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) -# include "pycore_runtime.h" // _Py_SINGLETON() -#endif #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() -#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() + +static Py_ssize_t +dbm_length_impl(dbmobject *self); + +static Py_ssize_t +dbm_length(PyObject *self) +{ + Py_ssize_t return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = dbm_length_impl((dbmobject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static int +dbm_bool_impl(dbmobject *self); + +static int +dbm_bool(PyObject *self) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = dbm_bool_impl((dbmobject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static PyObject * +dbm_subscript_impl(dbmobject *self, PyObject *key); + +static PyObject * +dbm_subscript(PyObject *self, PyObject *key) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = dbm_subscript_impl((dbmobject *)self, key); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static int +dbm_ass_sub_impl(dbmobject *self, PyObject *v, PyObject *w); + +static int +dbm_ass_sub(PyObject *self, PyObject *v, PyObject *w) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = dbm_ass_sub_impl((dbmobject *)self, v, w); + Py_END_CRITICAL_SECTION(); + + return return_value; +} PyDoc_STRVAR(_dbm_dbm_close__doc__, "close($self, /)\n" @@ -61,6 +119,21 @@ _dbm_dbm_keys(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize return return_value; } +static int +dbm_contains_impl(dbmobject *self, PyObject *arg); + +static int +dbm_contains(PyObject *self, PyObject *arg) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = dbm_contains_impl((dbmobject *)self, arg); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(_dbm_dbm_get__doc__, "get($self, key, default=None, /)\n" "--\n" @@ -78,24 +151,14 @@ static PyObject * _dbm_dbm_get(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .format = "s#|O:get", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE const char *key; Py_ssize_t key_length; PyObject *default_value = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + if (!_PyArg_NoKwnames("get", kwnames)) { + goto exit; + } + if (!PyArg_ParseArray(args, nargs, "s#|O:get", &key, &key_length, &default_value)) { goto exit; } @@ -127,24 +190,14 @@ static PyObject * _dbm_dbm_setdefault(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .format = "s#|O:setdefault", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE const char *key; Py_ssize_t key_length; PyObject *default_value = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + if (!_PyArg_NoKwnames("setdefault", kwnames)) { + goto exit; + } + if (!PyArg_ParseArray(args, nargs, "s#|O:setdefault", &key, &key_length, &default_value)) { goto exit; } @@ -185,6 +238,35 @@ _dbm_dbm_clear(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssiz return return_value; } +PyDoc_STRVAR(_dbm_dbm___exit____doc__, +"__exit__($self, /, *exc_info)\n" +"--\n" +"\n" +"Close the database."); + +#define _DBM_DBM___EXIT___METHODDEF \ + {"__exit__", _PyCFunction_CAST(_dbm_dbm___exit__), METH_FASTCALL, _dbm_dbm___exit____doc__}, + +static PyObject * +_dbm_dbm___exit___impl(dbmobject *self, PyObject * const *exc_info, + Py_ssize_t exc_info_length); + +static PyObject * +_dbm_dbm___exit__(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject * const *exc_info; + Py_ssize_t exc_info_length; + + exc_info = args; + exc_info_length = nargs; + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _dbm_dbm___exit___impl((dbmobject *)self, exc_info, exc_info_length); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(dbmopen__doc__, "open($module, filename, flags=\'r\', mode=0o666, /)\n" "--\n" @@ -225,15 +307,10 @@ dbmopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs) _PyArg_BadArgument("open", "argument 2", "str", args[1]); goto exit; } - Py_ssize_t flags_length; - flags = PyUnicode_AsUTF8AndSize(args[1], &flags_length); + flags = _PyUnicode_AsUTF8NoNUL(args[1]); if (flags == NULL) { goto exit; } - if (strlen(flags) != (size_t)flags_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (nargs < 3) { goto skip_optional; } @@ -247,4 +324,4 @@ dbmopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=677deecf525167a5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=4fa1cc840de2abd3 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_elementtree.c.h b/Modules/clinic/_elementtree.c.h index c9e77a4c2b92d8b..afc9daa5288f2c5 100644 --- a/Modules/clinic/_elementtree.c.h +++ b/Modules/clinic/_elementtree.c.h @@ -4,15 +4,72 @@ preserve #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) # include "pycore_gc.h" // PyGC_Head -# include "pycore_runtime.h" // _Py_SINGLETON() +# include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_abstract.h" // _PyNumber_Index() -#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() + +PyDoc_STRVAR(_elementtree_SubElement__doc__, +"SubElement($module, parent, tag, attrib={}, /, **extra)\n" +"--\n" +"\n" +"Create a new subelement of the parent element."); + +#define _ELEMENTTREE_SUBELEMENT_METHODDEF \ + {"SubElement", _PyCFunction_CAST(_elementtree_SubElement), METH_VARARGS|METH_KEYWORDS, _elementtree_SubElement__doc__}, + +static PyObject * +_elementtree_SubElement_impl(PyObject *module, PyObject *parent, + PyObject *tag, PyObject *attrib, + PyObject *extra); + +static PyObject * +_elementtree_SubElement(PyObject *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *parent; + PyObject *tag; + PyObject *attrib = NULL; + PyObject *extra = NULL; + + if (!_PyArg_CheckPositional("SubElement", PyTuple_GET_SIZE(args), 2, 3)) { + goto exit; + } + if (!PyObject_TypeCheck(PyTuple_GET_ITEM(args, 0), get_elementtree_state(module)->Element_Type)) { + _PyArg_BadArgument("SubElement", "argument 1", (get_elementtree_state(module)->Element_Type)->tp_name, PyTuple_GET_ITEM(args, 0)); + goto exit; + } + parent = PyTuple_GET_ITEM(args, 0); + tag = PyTuple_GET_ITEM(args, 1); + if (PyTuple_GET_SIZE(args) < 3) { + goto skip_optional; + } + if (!PyDict_Check(PyTuple_GET_ITEM(args, 2))) { + _PyArg_BadArgument("SubElement", "argument 3", "dict", PyTuple_GET_ITEM(args, 2)); + goto exit; + } + attrib = PyTuple_GET_ITEM(args, 2); +skip_optional: + extra = Py_XNewRef(kwargs); + return_value = _elementtree_SubElement_impl(module, parent, tag, attrib, extra); + +exit: + /* Cleanup for extra */ + Py_XDECREF(extra); + + return return_value; +} PyDoc_STRVAR(_elementtree_Element_append__doc__, "append($self, subelement, /)\n" "--\n" -"\n"); +"\n" +"Add *subelement* to the end of this element.\n" +"\n" +"The new element will appear in document order after the last\n" +"existing subelement (or directly after the text, if it\'s the first\n" +"subelement), but before the end tag for this element."); #define _ELEMENTTREE_ELEMENT_APPEND_METHODDEF \ {"append", _PyCFunction_CAST(_elementtree_Element_append), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_append__doc__}, @@ -25,25 +82,12 @@ static PyObject * _elementtree_Element_append(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "append", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *subelement; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("append", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("append", nargs, 1, 1)) { goto exit; } if (!PyObject_TypeCheck(args[0], clinic_state()->Element_Type)) { @@ -60,7 +104,11 @@ _elementtree_Element_append(PyObject *self, PyTypeObject *cls, PyObject *const * PyDoc_STRVAR(_elementtree_Element_clear__doc__, "clear($self, /)\n" "--\n" -"\n"); +"\n" +"Reset element.\n" +"\n" +"This function removes all subelements, clears all attributes, and\n" +"sets the text and tail attributes to None."); #define _ELEMENTTREE_ELEMENT_CLEAR_METHODDEF \ {"clear", (PyCFunction)_elementtree_Element_clear, METH_NOARGS, _elementtree_Element_clear__doc__}, @@ -183,25 +231,12 @@ static PyObject * _elementtree_Element___setstate__(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "__setstate__", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *state; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("__setstate__", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("__setstate__", nargs, 1, 1)) { goto exit; } state = args[0]; @@ -214,7 +249,10 @@ _elementtree_Element___setstate__(PyObject *self, PyTypeObject *cls, PyObject *c PyDoc_STRVAR(_elementtree_Element_extend__doc__, "extend($self, elements, /)\n" "--\n" -"\n"); +"\n" +"Append subelements from a sequence.\n" +"\n" +"*elements* is a sequence with zero or more elements."); #define _ELEMENTTREE_ELEMENT_EXTEND_METHODDEF \ {"extend", _PyCFunction_CAST(_elementtree_Element_extend), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_extend__doc__}, @@ -227,25 +265,12 @@ static PyObject * _elementtree_Element_extend(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "extend", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *elements; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("extend", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("extend", nargs, 1, 1)) { goto exit; } elements = args[0]; @@ -258,7 +283,14 @@ _elementtree_Element_extend(PyObject *self, PyTypeObject *cls, PyObject *const * PyDoc_STRVAR(_elementtree_Element_find__doc__, "find($self, /, path, namespaces=None)\n" "--\n" -"\n"); +"\n" +"Find first matching element by tag name or path.\n" +"\n" +"*path* is a string having either an element tag or an XPath,\n" +"*namespaces* is an optional mapping from namespace prefix to full\n" +"name.\n" +"\n" +"Return the first matching element, or None if no element was found."); #define _ELEMENTTREE_ELEMENT_FIND_METHODDEF \ {"find", _PyCFunction_CAST(_elementtree_Element_find), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_find__doc__}, @@ -323,7 +355,17 @@ _elementtree_Element_find(PyObject *self, PyTypeObject *cls, PyObject *const *ar PyDoc_STRVAR(_elementtree_Element_findtext__doc__, "findtext($self, /, path, default=None, namespaces=None)\n" "--\n" -"\n"); +"\n" +"Find text for first matching element by tag name or path.\n" +"\n" +"*path* is a string having either an element tag or an XPath,\n" +"*default* is the value to return if the element was not found,\n" +"*namespaces* is an optional mapping from namespace prefix to full\n" +"name.\n" +"\n" +"Return text content of first matching element, or default value if\n" +"none was found. Note that if an element is found having no text\n" +"content, the empty string is returned."); #define _ELEMENTTREE_ELEMENT_FINDTEXT_METHODDEF \ {"findtext", _PyCFunction_CAST(_elementtree_Element_findtext), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findtext__doc__}, @@ -396,7 +438,14 @@ _elementtree_Element_findtext(PyObject *self, PyTypeObject *cls, PyObject *const PyDoc_STRVAR(_elementtree_Element_findall__doc__, "findall($self, /, path, namespaces=None)\n" "--\n" -"\n"); +"\n" +"Find all matching subelements by tag name or path.\n" +"\n" +"*path* is a string having either an element tag or an XPath,\n" +"*namespaces* is an optional mapping from namespace prefix to full\n" +"name.\n" +"\n" +"Returns list containing all matching elements in document order."); #define _ELEMENTTREE_ELEMENT_FINDALL_METHODDEF \ {"findall", _PyCFunction_CAST(_elementtree_Element_findall), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findall__doc__}, @@ -461,7 +510,14 @@ _elementtree_Element_findall(PyObject *self, PyTypeObject *cls, PyObject *const PyDoc_STRVAR(_elementtree_Element_iterfind__doc__, "iterfind($self, /, path, namespaces=None)\n" "--\n" -"\n"); +"\n" +"Find all matching subelements by tag name or path.\n" +"\n" +"*path* is a string having either an element tag or an XPath,\n" +"*namespaces* is an optional mapping from namespace prefix to full\n" +"name.\n" +"\n" +"Return an iterable yielding all matching elements in document order."); #define _ELEMENTTREE_ELEMENT_ITERFIND_METHODDEF \ {"iterfind", _PyCFunction_CAST(_elementtree_Element_iterfind), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iterfind__doc__}, @@ -526,7 +582,15 @@ _elementtree_Element_iterfind(PyObject *self, PyTypeObject *cls, PyObject *const PyDoc_STRVAR(_elementtree_Element_get__doc__, "get($self, /, key, default=None)\n" "--\n" -"\n"); +"\n" +"Get element attribute.\n" +"\n" +"Equivalent to attrib.get, but some implementations may handle this a\n" +"bit more efficiently. *key* is what attribute to look for, and\n" +"*default* is what to return if the attribute was not found.\n" +"\n" +"Returns a string containing the attribute value, or the default if\n" +"attribute was not found."); #define _ELEMENTTREE_ELEMENT_GET_METHODDEF \ {"get", _PyCFunction_CAST(_elementtree_Element_get), METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_get__doc__}, @@ -591,7 +655,19 @@ _elementtree_Element_get(PyObject *self, PyObject *const *args, Py_ssize_t nargs PyDoc_STRVAR(_elementtree_Element_iter__doc__, "iter($self, /, tag=None)\n" "--\n" -"\n"); +"\n" +"Create tree iterator.\n" +"\n" +"The iterator loops over the element and all subelements in document\n" +"order, returning all elements with a matching tag.\n" +"\n" +"If the tree structure is modified during iteration, new or removed\n" +"elements may or may not be included. To get a stable set, use the\n" +"list() function on the iterator, and loop over the resulting list.\n" +"\n" +"*tag* is what tags to look for (default is to return all elements)\n" +"\n" +"Return an iterator containing all the matching elements."); #define _ELEMENTTREE_ELEMENT_ITER_METHODDEF \ {"iter", _PyCFunction_CAST(_elementtree_Element_iter), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iter__doc__}, @@ -654,7 +730,11 @@ _elementtree_Element_iter(PyObject *self, PyTypeObject *cls, PyObject *const *ar PyDoc_STRVAR(_elementtree_Element_itertext__doc__, "itertext($self, /)\n" "--\n" -"\n"); +"\n" +"Create text iterator.\n" +"\n" +"The iterator loops over the element and all subelements in document\n" +"order, returning all inner text."); #define _ELEMENTTREE_ELEMENT_ITERTEXT_METHODDEF \ {"itertext", _PyCFunction_CAST(_elementtree_Element_itertext), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_itertext__doc__}, @@ -675,7 +755,8 @@ _elementtree_Element_itertext(PyObject *self, PyTypeObject *cls, PyObject *const PyDoc_STRVAR(_elementtree_Element_insert__doc__, "insert($self, index, subelement, /)\n" "--\n" -"\n"); +"\n" +"Insert *subelement* at position *index*."); #define _ELEMENTTREE_ELEMENT_INSERT_METHODDEF \ {"insert", _PyCFunction_CAST(_elementtree_Element_insert), METH_FASTCALL, _elementtree_Element_insert__doc__}, @@ -720,7 +801,10 @@ _elementtree_Element_insert(PyObject *self, PyObject *const *args, Py_ssize_t na PyDoc_STRVAR(_elementtree_Element_items__doc__, "items($self, /)\n" "--\n" -"\n"); +"\n" +"Get element attributes as (name, value) pairs.\n" +"\n" +"Equivalent to attrib.items()."); #define _ELEMENTTREE_ELEMENT_ITEMS_METHODDEF \ {"items", (PyCFunction)_elementtree_Element_items, METH_NOARGS, _elementtree_Element_items__doc__}, @@ -737,7 +821,10 @@ _elementtree_Element_items(PyObject *self, PyObject *Py_UNUSED(ignored)) PyDoc_STRVAR(_elementtree_Element_keys__doc__, "keys($self, /)\n" "--\n" -"\n"); +"\n" +"Get attribute names.\n" +"\n" +"Equivalent to attrib.keys()"); #define _ELEMENTTREE_ELEMENT_KEYS_METHODDEF \ {"keys", (PyCFunction)_elementtree_Element_keys, METH_NOARGS, _elementtree_Element_keys__doc__}, @@ -754,7 +841,14 @@ _elementtree_Element_keys(PyObject *self, PyObject *Py_UNUSED(ignored)) PyDoc_STRVAR(_elementtree_Element_makeelement__doc__, "makeelement($self, tag, attrib, /)\n" "--\n" -"\n"); +"\n" +"Create a new element with the same type.\n" +"\n" +"*tag* is a string containing the element name. *attrib* is a\n" +"dictionary containing the element attributes.\n" +"\n" +"Do not call this method, use the SubElement factory function\n" +"instead."); #define _ELEMENTTREE_ELEMENT_MAKEELEMENT_METHODDEF \ {"makeelement", _PyCFunction_CAST(_elementtree_Element_makeelement), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_makeelement__doc__}, @@ -767,26 +861,13 @@ static PyObject * _elementtree_Element_makeelement(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "makeelement", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *tag; PyObject *attrib; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("makeelement", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("makeelement", nargs, 2, 2)) { goto exit; } tag = args[0]; @@ -804,7 +885,16 @@ _elementtree_Element_makeelement(PyObject *self, PyTypeObject *cls, PyObject *co PyDoc_STRVAR(_elementtree_Element_remove__doc__, "remove($self, subelement, /)\n" "--\n" -"\n"); +"\n" +"Remove matching subelement.\n" +"\n" +"Unlike the find methods, this method compares elements based on\n" +"identity, NOT ON tag value or contents. To remove subelements by\n" +"other means, the easiest way is to use a list comprehension to\n" +"select what elements to keep, and then use slice assignment to\n" +"update the parent element.\n" +"\n" +"ValueError is raised if a matching element could not be found."); #define _ELEMENTTREE_ELEMENT_REMOVE_METHODDEF \ {"remove", (PyCFunction)_elementtree_Element_remove, METH_O, _elementtree_Element_remove__doc__}, @@ -832,7 +922,12 @@ _elementtree_Element_remove(PyObject *self, PyObject *arg) PyDoc_STRVAR(_elementtree_Element_set__doc__, "set($self, key, value, /)\n" "--\n" -"\n"); +"\n" +"Set element attribute.\n" +"\n" +"Equivalent to attrib[key] = value, but some implementations may\n" +"handle this a bit more efficiently. *key* is what attribute to set,\n" +"and *value* is the attribute value to set it to."); #define _ELEMENTTREE_ELEMENT_SET_METHODDEF \ {"set", _PyCFunction_CAST(_elementtree_Element_set), METH_FASTCALL, _elementtree_Element_set__doc__}, @@ -859,6 +954,30 @@ _elementtree_Element_set(PyObject *self, PyObject *const *args, Py_ssize_t nargs return return_value; } +PyDoc_STRVAR(_elementtree_TreeBuilder___init____doc__, +"TreeBuilder(element_factory=None, *, comment_factory=None,\n" +" pi_factory=None, insert_comments=False, insert_pis=False)\n" +"--\n" +"\n" +"Generic element structure builder.\n" +"\n" +"This builder converts a sequence of start, data, and end method\n" +"calls to a well-formed element structure.\n" +"\n" +"You can use this class to build an element structure using a custom\n" +"XML parser, or a parser for some other XML-like format.\n" +"\n" +"*element_factory* is an optional element factory which is called\n" +"to create new Element instances, as necessary.\n" +"\n" +"*comment_factory* is a factory to create comments to be used instead\n" +"of the standard factory. If *insert_comments* is false (the\n" +"default), comments will not be inserted into the tree.\n" +"\n" +"*pi_factory* is a factory to create processing instructions to be\n" +"used instead of the standard factory. If *insert_pis* is false (the\n" +"default), processing instructions will not be inserted into the tree."); + static int _elementtree_TreeBuilder___init___impl(TreeBuilderObject *self, PyObject *element_factory, @@ -993,7 +1112,8 @@ _elementtree__set_factories(PyObject *module, PyObject *const *args, Py_ssize_t PyDoc_STRVAR(_elementtree_TreeBuilder_data__doc__, "data($self, data, /)\n" "--\n" -"\n"); +"\n" +"Add text to current element."); #define _ELEMENTTREE_TREEBUILDER_DATA_METHODDEF \ {"data", (PyCFunction)_elementtree_TreeBuilder_data, METH_O, _elementtree_TreeBuilder_data__doc__}, @@ -1014,7 +1134,10 @@ _elementtree_TreeBuilder_data(PyObject *self, PyObject *data) PyDoc_STRVAR(_elementtree_TreeBuilder_end__doc__, "end($self, tag, /)\n" "--\n" -"\n"); +"\n" +"Close and return current Element.\n" +"\n" +"*tag* is the element name."); #define _ELEMENTTREE_TREEBUILDER_END_METHODDEF \ {"end", (PyCFunction)_elementtree_TreeBuilder_end, METH_O, _elementtree_TreeBuilder_end__doc__}, @@ -1035,7 +1158,10 @@ _elementtree_TreeBuilder_end(PyObject *self, PyObject *tag) PyDoc_STRVAR(_elementtree_TreeBuilder_comment__doc__, "comment($self, text, /)\n" "--\n" -"\n"); +"\n" +"Create a comment using the comment_factory.\n" +"\n" +"*text* is the text of the comment."); #define _ELEMENTTREE_TREEBUILDER_COMMENT_METHODDEF \ {"comment", (PyCFunction)_elementtree_TreeBuilder_comment, METH_O, _elementtree_TreeBuilder_comment__doc__}, @@ -1057,7 +1183,11 @@ _elementtree_TreeBuilder_comment(PyObject *self, PyObject *text) PyDoc_STRVAR(_elementtree_TreeBuilder_pi__doc__, "pi($self, target, text=None, /)\n" "--\n" -"\n"); +"\n" +"Create a processing instruction using the pi_factory.\n" +"\n" +"*target* is the target name of the processing instruction. *text* is\n" +"the data of the processing instruction, or \'\'."); #define _ELEMENTTREE_TREEBUILDER_PI_METHODDEF \ {"pi", _PyCFunction_CAST(_elementtree_TreeBuilder_pi), METH_FASTCALL, _elementtree_TreeBuilder_pi__doc__}, @@ -1091,7 +1221,8 @@ _elementtree_TreeBuilder_pi(PyObject *self, PyObject *const *args, Py_ssize_t na PyDoc_STRVAR(_elementtree_TreeBuilder_close__doc__, "close($self, /)\n" "--\n" -"\n"); +"\n" +"Flush builder buffers and return toplevel document Element."); #define _ELEMENTTREE_TREEBUILDER_CLOSE_METHODDEF \ {"close", (PyCFunction)_elementtree_TreeBuilder_close, METH_NOARGS, _elementtree_TreeBuilder_close__doc__}, @@ -1108,7 +1239,11 @@ _elementtree_TreeBuilder_close(PyObject *self, PyObject *Py_UNUSED(ignored)) PyDoc_STRVAR(_elementtree_TreeBuilder_start__doc__, "start($self, tag, attrs, /)\n" "--\n" -"\n"); +"\n" +"Open new element and return it.\n" +"\n" +"*tag* is the element name, *attrs* is a dict containing element\n" +"attributes."); #define _ELEMENTTREE_TREEBUILDER_START_METHODDEF \ {"start", _PyCFunction_CAST(_elementtree_TreeBuilder_start), METH_FASTCALL, _elementtree_TreeBuilder_start__doc__}, @@ -1139,6 +1274,17 @@ _elementtree_TreeBuilder_start(PyObject *self, PyObject *const *args, Py_ssize_t return return_value; } +PyDoc_STRVAR(_elementtree_XMLParser___init____doc__, +"XMLParser(*, target=None, encoding=None)\n" +"--\n" +"\n" +"Element structure builder for XML source data based on the expat parser.\n" +"\n" +"*target* is an optional target object which defaults to an instance\n" +"of the standard TreeBuilder class, *encoding* is an optional encoding\n" +"string which if given, overrides the encoding specified in the XML\n" +"file: http://www.iana.org/assignments/character-sets"); + static int _elementtree_XMLParser___init___impl(XMLParserObject *self, PyObject *target, const char *encoding); @@ -1199,15 +1345,10 @@ _elementtree_XMLParser___init__(PyObject *self, PyObject *args, PyObject *kwargs encoding = NULL; } else if (PyUnicode_Check(fastargs[1])) { - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(fastargs[1]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("XMLParser", "argument 'encoding'", "str or None", fastargs[1]); @@ -1223,7 +1364,8 @@ _elementtree_XMLParser___init__(PyObject *self, PyObject *args, PyObject *kwargs PyDoc_STRVAR(_elementtree_XMLParser_close__doc__, "close($self, /)\n" "--\n" -"\n"); +"\n" +"Finish feeding data to parser and return element structure."); #define _ELEMENTTREE_XMLPARSER_CLOSE_METHODDEF \ {"close", (PyCFunction)_elementtree_XMLParser_close, METH_NOARGS, _elementtree_XMLParser_close__doc__}, @@ -1257,7 +1399,8 @@ _elementtree_XMLParser_flush(PyObject *self, PyObject *Py_UNUSED(ignored)) PyDoc_STRVAR(_elementtree_XMLParser_feed__doc__, "feed($self, data, /)\n" "--\n" -"\n"); +"\n" +"Feed encoded data to parser."); #define _ELEMENTTREE_XMLPARSER_FEED_METHODDEF \ {"feed", (PyCFunction)_elementtree_XMLParser_feed, METH_O, _elementtree_XMLParser_feed__doc__}, @@ -1331,4 +1474,4 @@ _elementtree_XMLParser__setevents(PyObject *self, PyObject *const *args, Py_ssiz exit: return return_value; } -/*[clinic end generated code: output=c863ce16d8566291 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d454d27e90eb399e input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_functoolsmodule.c.h b/Modules/clinic/_functoolsmodule.c.h index 5f350c864f057b0..b09653fe5d4ef86 100644 --- a/Modules/clinic/_functoolsmodule.c.h +++ b/Modules/clinic/_functoolsmodule.c.h @@ -193,4 +193,31 @@ _functools__lru_cache_wrapper_cache_clear(PyObject *self, PyObject *Py_UNUSED(ig return return_value; } -/*[clinic end generated code: output=6d8fdaeba4b520fa input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_functools__lru_cache_wrapper___copy____doc__, +"__copy__($self, /)\n" +"--\n" +"\n" +"Return a copy of the wrapper, which is the wrapper itself."); + +#define _FUNCTOOLS__LRU_CACHE_WRAPPER___COPY___METHODDEF \ + {"__copy__", (PyCFunction)_functools__lru_cache_wrapper___copy__, METH_NOARGS, _functools__lru_cache_wrapper___copy____doc__}, + +static PyObject * +_functools__lru_cache_wrapper___copy___impl(PyObject *self); + +static PyObject * +_functools__lru_cache_wrapper___copy__(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _functools__lru_cache_wrapper___copy___impl(self); +} + +PyDoc_STRVAR(_functools__lru_cache_wrapper___deepcopy____doc__, +"__deepcopy__($self, memo, /)\n" +"--\n" +"\n" +"Return a deep copy of the wrapper, which is the wrapper itself."); + +#define _FUNCTOOLS__LRU_CACHE_WRAPPER___DEEPCOPY___METHODDEF \ + {"__deepcopy__", (PyCFunction)_functools__lru_cache_wrapper___deepcopy__, METH_O, _functools__lru_cache_wrapper___deepcopy____doc__}, +/*[clinic end generated code: output=9af090694f03b4f2 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_gdbmmodule.c.h b/Modules/clinic/_gdbmmodule.c.h index fe993cc328fbd2f..010e1369fbdc9bf 100644 --- a/Modules/clinic/_gdbmmodule.c.h +++ b/Modules/clinic/_gdbmmodule.c.h @@ -2,11 +2,54 @@ preserve [clinic start generated code]*/ -#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) -# include "pycore_runtime.h" // _Py_SINGLETON() -#endif #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() + +static Py_ssize_t +gdbm_length_impl(gdbmobject *self); + +static Py_ssize_t +gdbm_length(PyObject *self) +{ + Py_ssize_t return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = gdbm_length_impl((gdbmobject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static int +gdbm_bool_impl(gdbmobject *self); + +static int +gdbm_bool(PyObject *self) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = gdbm_bool_impl((gdbmobject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static PyObject * +gdbm_subscript_impl(gdbmobject *self, PyObject *key); + +static PyObject * +gdbm_subscript(PyObject *self, PyObject *key) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = gdbm_subscript_impl((gdbmobject *)self, key); + Py_END_CRITICAL_SECTION(); + + return return_value; +} PyDoc_STRVAR(_gdbm_gdbm_get__doc__, "get($self, key, default=None, /)\n" @@ -42,6 +85,21 @@ _gdbm_gdbm_get(PyObject *self, PyObject *const *args, Py_ssize_t nargs) return return_value; } +static int +gdbm_ass_sub_impl(gdbmobject *self, PyObject *v, PyObject *w); + +static int +gdbm_ass_sub(PyObject *self, PyObject *v, PyObject *w) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = gdbm_ass_sub_impl((gdbmobject *)self, v, w); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(_gdbm_gdbm_setdefault__doc__, "setdefault($self, key, default=None, /)\n" "--\n" @@ -132,6 +190,21 @@ _gdbm_gdbm_keys(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssi return return_value; } +static int +gdbm_contains_impl(gdbmobject *self, PyObject *arg); + +static int +gdbm_contains(PyObject *self, PyObject *arg) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = gdbm_contains_impl((gdbmobject *)self, arg); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(_gdbm_gdbm_firstkey__doc__, "firstkey($self, /)\n" "--\n" @@ -190,23 +263,13 @@ static PyObject * _gdbm_gdbm_nextkey(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .format = "s#:nextkey", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE const char *key; Py_ssize_t key_length; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + if (!_PyArg_NoKwnames("nextkey", kwnames)) { + goto exit; + } + if (!PyArg_ParseArray(args, nargs, "s#:nextkey", &key, &key_length)) { goto exit; } @@ -314,6 +377,35 @@ _gdbm_gdbm_clear(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ss return return_value; } +PyDoc_STRVAR(_gdbm_gdbm___exit____doc__, +"__exit__($self, /, *exc_info)\n" +"--\n" +"\n" +"Close the database."); + +#define _GDBM_GDBM___EXIT___METHODDEF \ + {"__exit__", _PyCFunction_CAST(_gdbm_gdbm___exit__), METH_FASTCALL, _gdbm_gdbm___exit____doc__}, + +static PyObject * +_gdbm_gdbm___exit___impl(gdbmobject *self, PyObject * const *exc_info, + Py_ssize_t exc_info_length); + +static PyObject * +_gdbm_gdbm___exit__(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject * const *exc_info; + Py_ssize_t exc_info_length; + + exc_info = args; + exc_info_length = nargs; + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _gdbm_gdbm___exit___impl((gdbmobject *)self, exc_info, exc_info_length); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(dbmopen__doc__, "open($module, filename, flags=\'r\', mode=0o666, /)\n" "--\n" @@ -367,15 +459,10 @@ dbmopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs) _PyArg_BadArgument("open", "argument 2", "str", args[1]); goto exit; } - Py_ssize_t flags_length; - flags = PyUnicode_AsUTF8AndSize(args[1], &flags_length); + flags = _PyUnicode_AsUTF8NoNUL(args[1]); if (flags == NULL) { goto exit; } - if (strlen(flags) != (size_t)flags_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (nargs < 3) { goto skip_optional; } @@ -389,4 +476,4 @@ dbmopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=429b5db24568292e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f4c81f6e2181a474 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_hashopenssl.c.h b/Modules/clinic/_hashopenssl.c.h index 17ed37bbd3b6191..b99545b0eb33471 100644 --- a/Modules/clinic/_hashopenssl.c.h +++ b/Modules/clinic/_hashopenssl.c.h @@ -9,6 +9,7 @@ preserve #include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_long.h" // _PyLong_UnsignedLong_Converter() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(_hashlib_HASH_copy__doc__, "copy($self, /)\n" @@ -307,15 +308,10 @@ _hashlib_HASH_new(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyO _PyArg_BadArgument("new", "argument 'name'", "str", args[0]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(args[0], &name_length); + name = _PyUnicode_AsUTF8NoNUL(args[0]); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!noptargs) { goto skip_optional_pos; } @@ -1463,15 +1459,10 @@ pbkdf2_hmac(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject _PyArg_BadArgument("pbkdf2_hmac", "argument 'hash_name'", "str", args[0]); goto exit; } - Py_ssize_t hash_name_length; - hash_name = PyUnicode_AsUTF8AndSize(args[0], &hash_name_length); + hash_name = _PyUnicode_AsUTF8NoNUL(args[0]); if (hash_name == NULL) { goto exit; } - if (strlen(hash_name) != (size_t)hash_name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (PyObject_GetBuffer(args[1], &password, PyBUF_SIMPLE) != 0) { goto exit; } @@ -1986,4 +1977,4 @@ _hashlib_compare_digest(PyObject *module, PyObject *const *args, Py_ssize_t narg #ifndef _HASHLIB_OPENSSL_SHAKE_256_METHODDEF #define _HASHLIB_OPENSSL_SHAKE_256_METHODDEF #endif /* !defined(_HASHLIB_OPENSSL_SHAKE_256_METHODDEF) */ -/*[clinic end generated code: output=cf405e652a340bb2 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=608e8ac9483c9173 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_interpretersmodule.c.h b/Modules/clinic/_interpretersmodule.c.h index 72792f9b583a66c..4d087b152d2b7f7 100644 --- a/Modules/clinic/_interpretersmodule.c.h +++ b/Modules/clinic/_interpretersmodule.c.h @@ -6,7 +6,59 @@ preserve # include "pycore_gc.h" // PyGC_Head # include "pycore_runtime.h" // _Py_ID() #endif -#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() + +PyDoc_STRVAR(_interpreters_new_config__doc__, +"new_config($module, name=\'isolated\', /, **overrides)\n" +"--\n" +"\n" +"Return a representation of a new PyInterpreterConfig.\n" +"\n" +"The name determines the initial values of the config. Supported named\n" +"configs are: default, isolated, legacy, and empty.\n" +"\n" +"Any keyword arguments are set on the corresponding config fields,\n" +"overriding the initial values."); + +#define _INTERPRETERS_NEW_CONFIG_METHODDEF \ + {"new_config", _PyCFunction_CAST(_interpreters_new_config), METH_VARARGS|METH_KEYWORDS, _interpreters_new_config__doc__}, + +static PyObject * +_interpreters_new_config_impl(PyObject *module, const char *name, + PyObject *overrides); + +static PyObject * +_interpreters_new_config(PyObject *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + const char *name = NULL; + PyObject *overrides = NULL; + + if (!_PyArg_CheckPositional("new_config", PyTuple_GET_SIZE(args), 0, 1)) { + goto exit; + } + if (PyTuple_GET_SIZE(args) < 1) { + goto skip_optional; + } + if (!PyUnicode_Check(PyTuple_GET_ITEM(args, 0))) { + _PyArg_BadArgument("new_config", "argument 1", "str", PyTuple_GET_ITEM(args, 0)); + goto exit; + } + name = _PyUnicode_AsUTF8NoNUL(PyTuple_GET_ITEM(args, 0)); + if (name == NULL) { + goto exit; + } +skip_optional: + overrides = Py_XNewRef(kwargs); + return_value = _interpreters_new_config_impl(module, name, overrides); + +exit: + /* Cleanup for overrides */ + Py_XDECREF(overrides); + + return return_value; +} PyDoc_STRVAR(_interpreters_create__doc__, "create($module, /, config=\'isolated\', *, reqrefs=False)\n" @@ -1200,4 +1252,4 @@ _interpreters_capture_exception(PyObject *module, PyObject *const *args, Py_ssiz exit: return return_value; } -/*[clinic end generated code: output=8c3ca09c304378ad input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ad79d44c2b139a83 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_localemodule.c.h b/Modules/clinic/_localemodule.c.h index 5e0880b0d0bb4c0..902673894774562 100644 --- a/Modules/clinic/_localemodule.c.h +++ b/Modules/clinic/_localemodule.c.h @@ -3,9 +3,10 @@ preserve [clinic start generated code]*/ #include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(_locale_setlocale__doc__, -"setlocale($module, category, locale=, /)\n" +"setlocale($module, category, locale=None, /)\n" "--\n" "\n" "Activates/queries locale processing."); @@ -37,15 +38,10 @@ _locale_setlocale(PyObject *module, PyObject *const *args, Py_ssize_t nargs) locale = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t locale_length; - locale = PyUnicode_AsUTF8AndSize(args[1], &locale_length); + locale = _PyUnicode_AsUTF8NoNUL(args[1]); if (locale == NULL) { goto exit; } - if (strlen(locale) != (size_t)locale_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("setlocale", "argument 2", "str or None", args[1]); @@ -230,15 +226,10 @@ _locale_gettext(PyObject *module, PyObject *arg) _PyArg_BadArgument("gettext", "argument", "str", arg); goto exit; } - Py_ssize_t in_length; - in = PyUnicode_AsUTF8AndSize(arg, &in_length); + in = _PyUnicode_AsUTF8NoNUL(arg); if (in == NULL) { goto exit; } - if (strlen(in) != (size_t)in_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _locale_gettext_impl(module, in); exit: @@ -277,15 +268,10 @@ _locale_dgettext(PyObject *module, PyObject *const *args, Py_ssize_t nargs) domain = NULL; } else if (PyUnicode_Check(args[0])) { - Py_ssize_t domain_length; - domain = PyUnicode_AsUTF8AndSize(args[0], &domain_length); + domain = _PyUnicode_AsUTF8NoNUL(args[0]); if (domain == NULL) { goto exit; } - if (strlen(domain) != (size_t)domain_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("dgettext", "argument 1", "str or None", args[0]); @@ -295,15 +281,10 @@ _locale_dgettext(PyObject *module, PyObject *const *args, Py_ssize_t nargs) _PyArg_BadArgument("dgettext", "argument 2", "str", args[1]); goto exit; } - Py_ssize_t in_length; - in = PyUnicode_AsUTF8AndSize(args[1], &in_length); + in = _PyUnicode_AsUTF8NoNUL(args[1]); if (in == NULL) { goto exit; } - if (strlen(in) != (size_t)in_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _locale_dgettext_impl(module, domain, in); exit: @@ -342,15 +323,10 @@ _locale_dcgettext(PyObject *module, PyObject *const *args, Py_ssize_t nargs) domain = NULL; } else if (PyUnicode_Check(args[0])) { - Py_ssize_t domain_length; - domain = PyUnicode_AsUTF8AndSize(args[0], &domain_length); + domain = _PyUnicode_AsUTF8NoNUL(args[0]); if (domain == NULL) { goto exit; } - if (strlen(domain) != (size_t)domain_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("dcgettext", "argument 1", "str or None", args[0]); @@ -360,15 +336,10 @@ _locale_dcgettext(PyObject *module, PyObject *const *args, Py_ssize_t nargs) _PyArg_BadArgument("dcgettext", "argument 2", "str", args[1]); goto exit; } - Py_ssize_t msgid_length; - msgid = PyUnicode_AsUTF8AndSize(args[1], &msgid_length); + msgid = _PyUnicode_AsUTF8NoNUL(args[1]); if (msgid == NULL) { goto exit; } - if (strlen(msgid) != (size_t)msgid_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } category = PyLong_AsInt(args[2]); if (category == -1 && PyErr_Occurred()) { goto exit; @@ -405,15 +376,10 @@ _locale_textdomain(PyObject *module, PyObject *arg) domain = NULL; } else if (PyUnicode_Check(arg)) { - Py_ssize_t domain_length; - domain = PyUnicode_AsUTF8AndSize(arg, &domain_length); + domain = _PyUnicode_AsUTF8NoNUL(arg); if (domain == NULL) { goto exit; } - if (strlen(domain) != (size_t)domain_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("textdomain", "argument", "str or None", arg); @@ -456,15 +422,10 @@ _locale_bindtextdomain(PyObject *module, PyObject *const *args, Py_ssize_t nargs _PyArg_BadArgument("bindtextdomain", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t domain_length; - domain = PyUnicode_AsUTF8AndSize(args[0], &domain_length); + domain = _PyUnicode_AsUTF8NoNUL(args[0]); if (domain == NULL) { goto exit; } - if (strlen(domain) != (size_t)domain_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } dirname_obj = args[1]; return_value = _locale_bindtextdomain_impl(module, domain, dirname_obj); @@ -503,28 +464,18 @@ _locale_bind_textdomain_codeset(PyObject *module, PyObject *const *args, Py_ssiz _PyArg_BadArgument("bind_textdomain_codeset", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t domain_length; - domain = PyUnicode_AsUTF8AndSize(args[0], &domain_length); + domain = _PyUnicode_AsUTF8NoNUL(args[0]); if (domain == NULL) { goto exit; } - if (strlen(domain) != (size_t)domain_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (args[1] == Py_None) { codeset = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t codeset_length; - codeset = PyUnicode_AsUTF8AndSize(args[1], &codeset_length); + codeset = _PyUnicode_AsUTF8NoNUL(args[1]); if (codeset == NULL) { goto exit; } - if (strlen(codeset) != (size_t)codeset_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("bind_textdomain_codeset", "argument 2", "str or None", args[1]); @@ -595,4 +546,4 @@ _locale_getencoding(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef _LOCALE_BIND_TEXTDOMAIN_CODESET_METHODDEF #define _LOCALE_BIND_TEXTDOMAIN_CODESET_METHODDEF #endif /* !defined(_LOCALE_BIND_TEXTDOMAIN_CODESET_METHODDEF) */ -/*[clinic end generated code: output=034a3c219466d207 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b995b35bd3085d5b input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_lsprof.c.h b/Modules/clinic/_lsprof.c.h index acb4aaf27e377f2..0b1913a729ae895 100644 --- a/Modules/clinic/_lsprof.c.h +++ b/Modules/clinic/_lsprof.c.h @@ -471,9 +471,11 @@ profiler_init(PyObject *self, PyObject *args, PyObject *kwargs) goto exit; } skip_optional_pos: + Py_BEGIN_CRITICAL_SECTION(self); return_value = profiler_init_impl((ProfilerObject *)self, timer, timeunit, subcalls, builtins); + Py_END_CRITICAL_SECTION(); exit: return return_value; } -/*[clinic end generated code: output=af26a0b0ddcc3351 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=82541e3b3fe9819c input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_pickle.c.h b/Modules/clinic/_pickle.c.h index 213e817a50a287f..ae94e4c1d252ae3 100644 --- a/Modules/clinic/_pickle.c.h +++ b/Modules/clinic/_pickle.c.h @@ -4,9 +4,10 @@ preserve #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) # include "pycore_gc.h" // PyGC_Head -# include "pycore_runtime.h" // _Py_SINGLETON() +# include "pycore_runtime.h" // _Py_ID() #endif -#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(_pickle_Pickler_clear_memo__doc__, "clear_memo($self, /)\n" @@ -48,25 +49,12 @@ static PyObject * _pickle_Pickler_dump(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "dump", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *obj; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("dump", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("dump", nargs, 1, 1)) { goto exit; } obj = args[0]; @@ -286,25 +274,12 @@ static PyObject * _pickle_Unpickler_persistent_load(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "persistent_load", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *pid; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("persistent_load", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("persistent_load", nargs, 1, 1)) { goto exit; } pid = args[0]; @@ -365,26 +340,13 @@ static PyObject * _pickle_Unpickler_find_class(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "find_class", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *module_name; PyObject *global_name; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("find_class", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("find_class", nargs, 2, 2)) { goto exit; } module_name = args[0]; @@ -518,15 +480,10 @@ _pickle_Unpickler___init__(PyObject *self, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("Unpickler", "argument 'encoding'", "str", fastargs[2]); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(fastargs[2], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(fastargs[2]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_kwonly; } @@ -536,15 +493,10 @@ _pickle_Unpickler___init__(PyObject *self, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("Unpickler", "argument 'errors'", "str", fastargs[3]); goto exit; } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(fastargs[3], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(fastargs[3]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_kwonly; } @@ -931,15 +883,10 @@ _pickle_load(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject _PyArg_BadArgument("load", "argument 'encoding'", "str", args[2]); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[2], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(args[2]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_kwonly; } @@ -949,15 +896,10 @@ _pickle_load(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject _PyArg_BadArgument("load", "argument 'errors'", "str", args[3]); goto exit; } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[3], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[3]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_kwonly; } @@ -1060,15 +1002,10 @@ _pickle_loads(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec _PyArg_BadArgument("loads", "argument 'encoding'", "str", args[2]); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[2], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(args[2]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_kwonly; } @@ -1078,15 +1015,10 @@ _pickle_loads(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec _PyArg_BadArgument("loads", "argument 'errors'", "str", args[3]); goto exit; } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[3], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[3]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_kwonly; } @@ -1098,4 +1030,4 @@ _pickle_loads(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec exit: return return_value; } -/*[clinic end generated code: output=6331c72b3c427f63 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=df810fb55415996f input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_posixsubprocess.c.h b/Modules/clinic/_posixsubprocess.c.h index e7e9707f182a2ed..3414dc5fa261df0 100644 --- a/Modules/clinic/_posixsubprocess.c.h +++ b/Modules/clinic/_posixsubprocess.c.h @@ -134,7 +134,7 @@ subprocess_fork_exec(PyObject *module, PyObject *const *args, Py_ssize_t nargs) goto exit; } pgid_to_set = PyLong_AsPid(args[16]); - if (pgid_to_set == -1 && PyErr_Occurred()) { + if (pgid_to_set == (pid_t)(-1) && PyErr_Occurred()) { goto exit; } gid_object = args[17]; @@ -150,4 +150,4 @@ subprocess_fork_exec(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=138941c284792aa1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=59df66f994e6251d input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_queuemodule.c.h b/Modules/clinic/_queuemodule.c.h index b67dd23f260c9e2..2ec21ce72d4c5aa 100644 --- a/Modules/clinic/_queuemodule.c.h +++ b/Modules/clinic/_queuemodule.c.h @@ -38,6 +38,27 @@ simplequeue_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +simplequeue_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + + assert(_PyType_CAST(type)->tp_new == simplequeue_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoPositionalStack("SimpleQueue", nargs) || + !_PyArg_NoKwnames("SimpleQueue", kwnames)) { + goto exit; + } + return_value = simplequeue_new_impl(_PyType_CAST(type)); + +exit: + return return_value; +} + PyDoc_STRVAR(_queue_SimpleQueue_put__doc__, "put($self, /, item, block=True, timeout=None)\n" "--\n" @@ -390,4 +411,4 @@ _queue_SimpleQueue___sizeof__(PyObject *self, PyObject *Py_UNUSED(ignored)) exit: return return_value; } -/*[clinic end generated code: output=8219fe2f2ed5f068 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ab7862d3ec0c03c4 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_ssl.c.h b/Modules/clinic/_ssl.c.h index e337ed2390a1fc4..98a929b33def825 100644 --- a/Modules/clinic/_ssl.c.h +++ b/Modules/clinic/_ssl.c.h @@ -6,9 +6,12 @@ preserve # include "pycore_gc.h" // PyGC_Head # include "pycore_runtime.h" // _Py_ID() #endif +#include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() +#include "pycore_fileutils.h" // _Py_Off_t_Converter() #include "pycore_long.h" // _PyLong_Size_t_Converter() #include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(_ssl__SSLSocket_do_handshake__doc__, "do_handshake($self, /)\n" @@ -153,6 +156,101 @@ _ssl__SSLSocket_get_unverified_chain(PyObject *self, PyObject *Py_UNUSED(ignored return return_value; } +#if defined(HAVE_OPENSSL_ECH) + +PyDoc_STRVAR(_ssl__SSLSocket_get_ech_status__doc__, +"get_ech_status($self, /)\n" +"--\n" +"\n"); + +#define _SSL__SSLSOCKET_GET_ECH_STATUS_METHODDEF \ + {"get_ech_status", (PyCFunction)_ssl__SSLSocket_get_ech_status, METH_NOARGS, _ssl__SSLSocket_get_ech_status__doc__}, + +static PyObject * +_ssl__SSLSocket_get_ech_status_impl(PySSLSocket *self); + +static PyObject * +_ssl__SSLSocket_get_ech_status(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _ssl__SSLSocket_get_ech_status_impl((PySSLSocket *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +#endif /* defined(HAVE_OPENSSL_ECH) */ + +#if defined(HAVE_OPENSSL_ECH) + +PyDoc_STRVAR(_ssl__SSLSocket_get_ech_retry_config__doc__, +"get_ech_retry_config($self, /)\n" +"--\n" +"\n"); + +#define _SSL__SSLSOCKET_GET_ECH_RETRY_CONFIG_METHODDEF \ + {"get_ech_retry_config", (PyCFunction)_ssl__SSLSocket_get_ech_retry_config, METH_NOARGS, _ssl__SSLSocket_get_ech_retry_config__doc__}, + +static PyObject * +_ssl__SSLSocket_get_ech_retry_config_impl(PySSLSocket *self); + +static PyObject * +_ssl__SSLSocket_get_ech_retry_config(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _ssl__SSLSocket_get_ech_retry_config_impl((PySSLSocket *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +#endif /* defined(HAVE_OPENSSL_ECH) */ + +#if defined(HAVE_OPENSSL_ECH) + +PyDoc_STRVAR(_ssl__SSLSocket_set_ech_config__doc__, +"set_ech_config($self, ech_config, /)\n" +"--\n" +"\n" +"Set the ECH configuration for this connection.\n" +"\n" +"This replaces any configuration inherited from the context and\n" +"must be called before the handshake starts."); + +#define _SSL__SSLSOCKET_SET_ECH_CONFIG_METHODDEF \ + {"set_ech_config", (PyCFunction)_ssl__SSLSocket_set_ech_config, METH_O, _ssl__SSLSocket_set_ech_config__doc__}, + +static PyObject * +_ssl__SSLSocket_set_ech_config_impl(PySSLSocket *self, Py_buffer *ech_config); + +static PyObject * +_ssl__SSLSocket_set_ech_config(PyObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + Py_buffer ech_config = {NULL, NULL}; + + if (PyObject_GetBuffer(arg, &ech_config, PyBUF_SIMPLE) != 0) { + goto exit; + } + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _ssl__SSLSocket_set_ech_config_impl((PySSLSocket *)self, &ech_config); + Py_END_CRITICAL_SECTION(); + +exit: + /* Cleanup for ech_config */ + if (ech_config.obj) { + PyBuffer_Release(&ech_config); + } + + return return_value; +} + +#endif /* defined(HAVE_OPENSSL_ECH) */ + PyDoc_STRVAR(_ssl__SSLSocket_shared_ciphers__doc__, "shared_ciphers($self, /)\n" "--\n" @@ -338,20 +436,6 @@ PyDoc_STRVAR(_ssl__SSLSocket_context__doc__, "sni_callback on the SSLContext to change the certificate information\n" "associated with the SSLSocket before the cryptographic exchange\n" "handshake messages."); -#if defined(_ssl__SSLSocket_context_DOCSTR) -# undef _ssl__SSLSocket_context_DOCSTR -#endif -#define _ssl__SSLSocket_context_DOCSTR _ssl__SSLSocket_context__doc__ - -#if !defined(_ssl__SSLSocket_context_DOCSTR) -# define _ssl__SSLSocket_context_DOCSTR NULL -#endif -#if defined(_SSL__SSLSOCKET_CONTEXT_GETSETDEF) -# undef _SSL__SSLSOCKET_CONTEXT_GETSETDEF -# define _SSL__SSLSOCKET_CONTEXT_GETSETDEF {"context", (getter)_ssl__SSLSocket_context_get, (setter)_ssl__SSLSocket_context_set, _ssl__SSLSocket_context_DOCSTR}, -#else -# define _SSL__SSLSOCKET_CONTEXT_GETSETDEF {"context", (getter)_ssl__SSLSocket_context_get, NULL, _ssl__SSLSocket_context_DOCSTR}, -#endif static PyObject * _ssl__SSLSocket_context_get_impl(PySSLSocket *self); @@ -368,24 +452,22 @@ _ssl__SSLSocket_context_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_ssl__SSLSocket_context_DOCSTR) -# define _ssl__SSLSocket_context_DOCSTR NULL -#endif -#if defined(_SSL__SSLSOCKET_CONTEXT_GETSETDEF) -# undef _SSL__SSLSOCKET_CONTEXT_GETSETDEF -# define _SSL__SSLSOCKET_CONTEXT_GETSETDEF {"context", (getter)_ssl__SSLSocket_context_get, (setter)_ssl__SSLSocket_context_set, _ssl__SSLSocket_context_DOCSTR}, -#else -# define _SSL__SSLSOCKET_CONTEXT_GETSETDEF {"context", NULL, (setter)_ssl__SSLSocket_context_set, NULL}, -#endif - static int _ssl__SSLSocket_context_set_impl(PySSLSocket *self, PyObject *value); static int -_ssl__SSLSocket_context_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ssl__SSLSocket_context_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + PyObject *value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'context' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLSocket_context_set_impl((PySSLSocket *)self, value); Py_END_CRITICAL_SECTION(); @@ -395,20 +477,6 @@ _ssl__SSLSocket_context_set(PyObject *self, PyObject *value, void *Py_UNUSED(con PyDoc_STRVAR(_ssl__SSLSocket_server_side__doc__, "Whether this is a server-side socket."); -#if defined(_ssl__SSLSocket_server_side_DOCSTR) -# undef _ssl__SSLSocket_server_side_DOCSTR -#endif -#define _ssl__SSLSocket_server_side_DOCSTR _ssl__SSLSocket_server_side__doc__ - -#if !defined(_ssl__SSLSocket_server_side_DOCSTR) -# define _ssl__SSLSocket_server_side_DOCSTR NULL -#endif -#if defined(_SSL__SSLSOCKET_SERVER_SIDE_GETSETDEF) -# undef _SSL__SSLSOCKET_SERVER_SIDE_GETSETDEF -# define _SSL__SSLSOCKET_SERVER_SIDE_GETSETDEF {"server_side", (getter)_ssl__SSLSocket_server_side_get, (setter)_ssl__SSLSocket_server_side_set, _ssl__SSLSocket_server_side_DOCSTR}, -#else -# define _SSL__SSLSOCKET_SERVER_SIDE_GETSETDEF {"server_side", (getter)_ssl__SSLSocket_server_side_get, NULL, _ssl__SSLSocket_server_side_DOCSTR}, -#endif static PyObject * _ssl__SSLSocket_server_side_get_impl(PySSLSocket *self); @@ -427,20 +495,6 @@ _ssl__SSLSocket_server_side_get(PyObject *self, void *Py_UNUSED(context)) PyDoc_STRVAR(_ssl__SSLSocket_server_hostname__doc__, "The currently set server hostname (for SNI)."); -#if defined(_ssl__SSLSocket_server_hostname_DOCSTR) -# undef _ssl__SSLSocket_server_hostname_DOCSTR -#endif -#define _ssl__SSLSocket_server_hostname_DOCSTR _ssl__SSLSocket_server_hostname__doc__ - -#if !defined(_ssl__SSLSocket_server_hostname_DOCSTR) -# define _ssl__SSLSocket_server_hostname_DOCSTR NULL -#endif -#if defined(_SSL__SSLSOCKET_SERVER_HOSTNAME_GETSETDEF) -# undef _SSL__SSLSOCKET_SERVER_HOSTNAME_GETSETDEF -# define _SSL__SSLSOCKET_SERVER_HOSTNAME_GETSETDEF {"server_hostname", (getter)_ssl__SSLSocket_server_hostname_get, (setter)_ssl__SSLSocket_server_hostname_set, _ssl__SSLSocket_server_hostname_DOCSTR}, -#else -# define _SSL__SSLSOCKET_SERVER_HOSTNAME_GETSETDEF {"server_hostname", (getter)_ssl__SSLSocket_server_hostname_get, NULL, _ssl__SSLSocket_server_hostname_DOCSTR}, -#endif static PyObject * _ssl__SSLSocket_server_hostname_get_impl(PySSLSocket *self); @@ -461,20 +515,6 @@ PyDoc_STRVAR(_ssl__SSLSocket_owner__doc__, "The Python-level owner of this object.\n" "\n" "Passed as \"self\" in servername callback."); -#if defined(_ssl__SSLSocket_owner_DOCSTR) -# undef _ssl__SSLSocket_owner_DOCSTR -#endif -#define _ssl__SSLSocket_owner_DOCSTR _ssl__SSLSocket_owner__doc__ - -#if !defined(_ssl__SSLSocket_owner_DOCSTR) -# define _ssl__SSLSocket_owner_DOCSTR NULL -#endif -#if defined(_SSL__SSLSOCKET_OWNER_GETSETDEF) -# undef _SSL__SSLSOCKET_OWNER_GETSETDEF -# define _SSL__SSLSOCKET_OWNER_GETSETDEF {"owner", (getter)_ssl__SSLSocket_owner_get, (setter)_ssl__SSLSocket_owner_set, _ssl__SSLSocket_owner_DOCSTR}, -#else -# define _SSL__SSLSOCKET_OWNER_GETSETDEF {"owner", (getter)_ssl__SSLSocket_owner_get, NULL, _ssl__SSLSocket_owner_DOCSTR}, -#endif static PyObject * _ssl__SSLSocket_owner_get_impl(PySSLSocket *self); @@ -491,24 +531,22 @@ _ssl__SSLSocket_owner_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_ssl__SSLSocket_owner_DOCSTR) -# define _ssl__SSLSocket_owner_DOCSTR NULL -#endif -#if defined(_SSL__SSLSOCKET_OWNER_GETSETDEF) -# undef _SSL__SSLSOCKET_OWNER_GETSETDEF -# define _SSL__SSLSOCKET_OWNER_GETSETDEF {"owner", (getter)_ssl__SSLSocket_owner_get, (setter)_ssl__SSLSocket_owner_set, _ssl__SSLSocket_owner_DOCSTR}, -#else -# define _SSL__SSLSOCKET_OWNER_GETSETDEF {"owner", NULL, (setter)_ssl__SSLSocket_owner_set, NULL}, -#endif - static int _ssl__SSLSocket_owner_set_impl(PySSLSocket *self, PyObject *value); static int -_ssl__SSLSocket_owner_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ssl__SSLSocket_owner_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + PyObject *value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'owner' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLSocket_owner_set_impl((PySSLSocket *)self, value); Py_END_CRITICAL_SECTION(); @@ -601,7 +639,7 @@ _ssl__SSLSocket_sendfile(PyObject *self, PyObject *const *args, Py_ssize_t nargs if (fd == -1 && PyErr_Occurred()) { goto exit; } - if (!Py_off_t_converter(args[1], &offset)) { + if (!_Py_Off_t_Converter(args[1], &offset)) { goto exit; } if (!_PyLong_Size_t_Converter(args[2], &size)) { @@ -690,35 +728,42 @@ PyDoc_STRVAR(_ssl__SSLSocket_read__doc__, "Read up to size bytes from the SSL socket."); #define _SSL__SSLSOCKET_READ_METHODDEF \ - {"read", (PyCFunction)_ssl__SSLSocket_read, METH_VARARGS, _ssl__SSLSocket_read__doc__}, + {"read", _PyCFunction_CAST(_ssl__SSLSocket_read), METH_FASTCALL, _ssl__SSLSocket_read__doc__}, static PyObject * _ssl__SSLSocket_read_impl(PySSLSocket *self, Py_ssize_t len, int group_right_1, Py_buffer *buffer); static PyObject * -_ssl__SSLSocket_read(PyObject *self, PyObject *args) +_ssl__SSLSocket_read(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; Py_ssize_t len; int group_right_1 = 0; Py_buffer buffer = {NULL, NULL}; - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "n:read", &len)) { - goto exit; - } - break; - case 2: - if (!PyArg_ParseTuple(args, "nw*:read", &len, &buffer)) { - goto exit; - } - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "_ssl._SSLSocket.read requires 1 to 2 arguments"); + if (nargs < 1 || nargs > 2) { + PyErr_SetString(PyExc_TypeError, "_ssl._SSLSocket.read requires 1 to 2 arguments"); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { goto exit; + } + len = ival; + } + if (nargs >= 2) { + if (PyObject_GetBuffer(args[1], &buffer, PyBUF_WRITABLE) < 0) { + _PyArg_BadArgument("read", "argument 2", "read-write bytes-like object", args[1]); + goto exit; + } + group_right_1 = 1; } Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLSocket_read_impl((PySSLSocket *)self, len, group_right_1, &buffer); @@ -822,15 +867,10 @@ _ssl__SSLSocket_get_channel_binding(PyObject *self, PyObject *const *args, Py_ss _PyArg_BadArgument("get_channel_binding", "argument 'cb_type'", "str", args[0]); goto exit; } - Py_ssize_t cb_type_length; - cb_type = PyUnicode_AsUTF8AndSize(args[0], &cb_type_length); + cb_type = _PyUnicode_AsUTF8NoNUL(args[0]); if (cb_type == NULL) { goto exit; } - if (strlen(cb_type) != (size_t)cb_type_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } skip_optional_pos: Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLSocket_get_channel_binding_impl((PySSLSocket *)self, cb_type); @@ -866,20 +906,6 @@ _ssl__SSLSocket_verify_client_post_handshake(PyObject *self, PyObject *Py_UNUSED PyDoc_STRVAR(_ssl__SSLSocket_session__doc__, "The underlying SSLSession object."); -#if defined(_ssl__SSLSocket_session_DOCSTR) -# undef _ssl__SSLSocket_session_DOCSTR -#endif -#define _ssl__SSLSocket_session_DOCSTR _ssl__SSLSocket_session__doc__ - -#if !defined(_ssl__SSLSocket_session_DOCSTR) -# define _ssl__SSLSocket_session_DOCSTR NULL -#endif -#if defined(_SSL__SSLSOCKET_SESSION_GETSETDEF) -# undef _SSL__SSLSOCKET_SESSION_GETSETDEF -# define _SSL__SSLSOCKET_SESSION_GETSETDEF {"session", (getter)_ssl__SSLSocket_session_get, (setter)_ssl__SSLSocket_session_set, _ssl__SSLSocket_session_DOCSTR}, -#else -# define _SSL__SSLSOCKET_SESSION_GETSETDEF {"session", (getter)_ssl__SSLSocket_session_get, NULL, _ssl__SSLSocket_session_DOCSTR}, -#endif static PyObject * _ssl__SSLSocket_session_get_impl(PySSLSocket *self); @@ -896,24 +922,22 @@ _ssl__SSLSocket_session_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_ssl__SSLSocket_session_DOCSTR) -# define _ssl__SSLSocket_session_DOCSTR NULL -#endif -#if defined(_SSL__SSLSOCKET_SESSION_GETSETDEF) -# undef _SSL__SSLSOCKET_SESSION_GETSETDEF -# define _SSL__SSLSOCKET_SESSION_GETSETDEF {"session", (getter)_ssl__SSLSocket_session_get, (setter)_ssl__SSLSocket_session_set, _ssl__SSLSocket_session_DOCSTR}, -#else -# define _SSL__SSLSOCKET_SESSION_GETSETDEF {"session", NULL, (setter)_ssl__SSLSocket_session_set, NULL}, -#endif - static int _ssl__SSLSocket_session_set_impl(PySSLSocket *self, PyObject *value); static int -_ssl__SSLSocket_session_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ssl__SSLSocket_session_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + PyObject *value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'session' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLSocket_session_set_impl((PySSLSocket *)self, value); Py_END_CRITICAL_SECTION(); @@ -923,20 +947,6 @@ _ssl__SSLSocket_session_set(PyObject *self, PyObject *value, void *Py_UNUSED(con PyDoc_STRVAR(_ssl__SSLSocket_session_reused__doc__, "Was the client session reused during handshake?"); -#if defined(_ssl__SSLSocket_session_reused_DOCSTR) -# undef _ssl__SSLSocket_session_reused_DOCSTR -#endif -#define _ssl__SSLSocket_session_reused_DOCSTR _ssl__SSLSocket_session_reused__doc__ - -#if !defined(_ssl__SSLSocket_session_reused_DOCSTR) -# define _ssl__SSLSocket_session_reused_DOCSTR NULL -#endif -#if defined(_SSL__SSLSOCKET_SESSION_REUSED_GETSETDEF) -# undef _SSL__SSLSOCKET_SESSION_REUSED_GETSETDEF -# define _SSL__SSLSOCKET_SESSION_REUSED_GETSETDEF {"session_reused", (getter)_ssl__SSLSocket_session_reused_get, (setter)_ssl__SSLSocket_session_reused_set, _ssl__SSLSocket_session_reused_DOCSTR}, -#else -# define _SSL__SSLSOCKET_SESSION_REUSED_GETSETDEF {"session_reused", (getter)_ssl__SSLSocket_session_reused_get, NULL, _ssl__SSLSocket_session_reused_DOCSTR}, -#endif static PyObject * _ssl__SSLSocket_session_reused_get_impl(PySSLSocket *self); @@ -1003,15 +1013,10 @@ _ssl__SSLContext_set_ciphers(PyObject *self, PyObject *arg) _PyArg_BadArgument("set_ciphers", "argument", "str", arg); goto exit; } - Py_ssize_t cipherlist_length; - cipherlist = PyUnicode_AsUTF8AndSize(arg, &cipherlist_length); + cipherlist = _PyUnicode_AsUTF8NoNUL(arg); if (cipherlist == NULL) { goto exit; } - if (strlen(cipherlist) != (size_t)cipherlist_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLContext_set_ciphers_impl((PySSLContext *)self, cipherlist); Py_END_CRITICAL_SECTION(); @@ -1042,15 +1047,10 @@ _ssl__SSLContext_set_ciphersuites(PyObject *self, PyObject *arg) _PyArg_BadArgument("set_ciphersuites", "argument", "str", arg); goto exit; } - Py_ssize_t ciphersuites_length; - ciphersuites = PyUnicode_AsUTF8AndSize(arg, &ciphersuites_length); + ciphersuites = _PyUnicode_AsUTF8NoNUL(arg); if (ciphersuites == NULL) { goto exit; } - if (strlen(ciphersuites) != (size_t)ciphersuites_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLContext_set_ciphersuites_impl((PySSLContext *)self, ciphersuites); Py_END_CRITICAL_SECTION(); @@ -1103,15 +1103,10 @@ _ssl__SSLContext_set_groups(PyObject *self, PyObject *arg) _PyArg_BadArgument("set_groups", "argument", "str", arg); goto exit; } - Py_ssize_t grouplist_length; - grouplist = PyUnicode_AsUTF8AndSize(arg, &grouplist_length); + grouplist = _PyUnicode_AsUTF8NoNUL(arg); if (grouplist == NULL) { goto exit; } - if (strlen(grouplist) != (size_t)grouplist_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLContext_set_groups_impl((PySSLContext *)self, grouplist); Py_END_CRITICAL_SECTION(); @@ -1209,15 +1204,10 @@ _ssl__SSLContext_set_client_sigalgs(PyObject *self, PyObject *arg) _PyArg_BadArgument("set_client_sigalgs", "argument", "str", arg); goto exit; } - Py_ssize_t sigalgslist_length; - sigalgslist = PyUnicode_AsUTF8AndSize(arg, &sigalgslist_length); + sigalgslist = _PyUnicode_AsUTF8NoNUL(arg); if (sigalgslist == NULL) { goto exit; } - if (strlen(sigalgslist) != (size_t)sigalgslist_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLContext_set_client_sigalgs_impl((PySSLContext *)self, sigalgslist); Py_END_CRITICAL_SECTION(); @@ -1248,15 +1238,10 @@ _ssl__SSLContext_set_server_sigalgs(PyObject *self, PyObject *arg) _PyArg_BadArgument("set_server_sigalgs", "argument", "str", arg); goto exit; } - Py_ssize_t sigalgslist_length; - sigalgslist = PyUnicode_AsUTF8AndSize(arg, &sigalgslist_length); + sigalgslist = _PyUnicode_AsUTF8NoNUL(arg); if (sigalgslist == NULL) { goto exit; } - if (strlen(sigalgslist) != (size_t)sigalgslist_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLContext_set_server_sigalgs_impl((PySSLContext *)self, sigalgslist); Py_END_CRITICAL_SECTION(); @@ -1299,116 +1284,157 @@ _ssl__SSLContext__set_alpn_protocols(PyObject *self, PyObject *arg) return return_value; } -#if !defined(_ssl__SSLContext_verify_mode_DOCSTR) -# define _ssl__SSLContext_verify_mode_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_VERIFY_MODE_GETSETDEF) -# undef _SSL__SSLCONTEXT_VERIFY_MODE_GETSETDEF -# define _SSL__SSLCONTEXT_VERIFY_MODE_GETSETDEF {"verify_mode", (getter)_ssl__SSLContext_verify_mode_get, (setter)_ssl__SSLContext_verify_mode_set, _ssl__SSLContext_verify_mode_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_VERIFY_MODE_GETSETDEF {"verify_mode", (getter)_ssl__SSLContext_verify_mode_get, NULL, _ssl__SSLContext_verify_mode_DOCSTR}, -#endif +#if defined(HAVE_OPENSSL_ECH) + +PyDoc_STRVAR(_ssl__SSLContext__set_outer_alpn_protocols__doc__, +"_set_outer_alpn_protocols($self, protos, /)\n" +"--\n" +"\n"); + +#define _SSL__SSLCONTEXT__SET_OUTER_ALPN_PROTOCOLS_METHODDEF \ + {"_set_outer_alpn_protocols", (PyCFunction)_ssl__SSLContext__set_outer_alpn_protocols, METH_O, _ssl__SSLContext__set_outer_alpn_protocols__doc__}, static PyObject * +_ssl__SSLContext__set_outer_alpn_protocols_impl(PySSLContext *self, + Py_buffer *protos); + +static PyObject * +_ssl__SSLContext__set_outer_alpn_protocols(PyObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + Py_buffer protos = {NULL, NULL}; + + if (PyObject_GetBuffer(arg, &protos, PyBUF_SIMPLE) != 0) { + goto exit; + } + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _ssl__SSLContext__set_outer_alpn_protocols_impl((PySSLContext *)self, &protos); + Py_END_CRITICAL_SECTION(); + +exit: + /* Cleanup for protos */ + if (protos.obj) { + PyBuffer_Release(&protos); + } + + return return_value; +} + +#endif /* defined(HAVE_OPENSSL_ECH) */ + +static int _ssl__SSLContext_verify_mode_get_impl(PySSLContext *self); static PyObject * _ssl__SSLContext_verify_mode_get(PyObject *self, void *Py_UNUSED(context)) { PyObject *return_value = NULL; + int _return_value; Py_BEGIN_CRITICAL_SECTION(self); - return_value = _ssl__SSLContext_verify_mode_get_impl((PySSLContext *)self); + _return_value = _ssl__SSLContext_verify_mode_get_impl((PySSLContext *)self); Py_END_CRITICAL_SECTION(); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyLong_FromLong((long)_return_value); +exit: return return_value; } -#if !defined(_ssl__SSLContext_verify_mode_DOCSTR) -# define _ssl__SSLContext_verify_mode_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_VERIFY_MODE_GETSETDEF) -# undef _SSL__SSLCONTEXT_VERIFY_MODE_GETSETDEF -# define _SSL__SSLCONTEXT_VERIFY_MODE_GETSETDEF {"verify_mode", (getter)_ssl__SSLContext_verify_mode_get, (setter)_ssl__SSLContext_verify_mode_set, _ssl__SSLContext_verify_mode_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_VERIFY_MODE_GETSETDEF {"verify_mode", NULL, (setter)_ssl__SSLContext_verify_mode_set, NULL}, -#endif - static int -_ssl__SSLContext_verify_mode_set_impl(PySSLContext *self, PyObject *value); +_ssl__SSLContext_verify_mode_set_impl(PySSLContext *self, int value); static int -_ssl__SSLContext_verify_mode_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ssl__SSLContext_verify_mode_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + int value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'verify_mode' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = PyLong_AsInt(arg); + if (value == -1 && PyErr_Occurred()) { + goto exit; + } Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLContext_verify_mode_set_impl((PySSLContext *)self, value); Py_END_CRITICAL_SECTION(); +exit: return return_value; } -#if !defined(_ssl__SSLContext_verify_flags_DOCSTR) -# define _ssl__SSLContext_verify_flags_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_VERIFY_FLAGS_GETSETDEF) -# undef _SSL__SSLCONTEXT_VERIFY_FLAGS_GETSETDEF -# define _SSL__SSLCONTEXT_VERIFY_FLAGS_GETSETDEF {"verify_flags", (getter)_ssl__SSLContext_verify_flags_get, (setter)_ssl__SSLContext_verify_flags_set, _ssl__SSLContext_verify_flags_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_VERIFY_FLAGS_GETSETDEF {"verify_flags", (getter)_ssl__SSLContext_verify_flags_get, NULL, _ssl__SSLContext_verify_flags_DOCSTR}, -#endif - -static PyObject * +static unsigned long _ssl__SSLContext_verify_flags_get_impl(PySSLContext *self); static PyObject * _ssl__SSLContext_verify_flags_get(PyObject *self, void *Py_UNUSED(context)) { PyObject *return_value = NULL; + unsigned long _return_value; Py_BEGIN_CRITICAL_SECTION(self); - return_value = _ssl__SSLContext_verify_flags_get_impl((PySSLContext *)self); + _return_value = _ssl__SSLContext_verify_flags_get_impl((PySSLContext *)self); Py_END_CRITICAL_SECTION(); + if ((_return_value == (unsigned long)-1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyLong_FromUnsignedLong(_return_value); +exit: return return_value; } -#if !defined(_ssl__SSLContext_verify_flags_DOCSTR) -# define _ssl__SSLContext_verify_flags_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_VERIFY_FLAGS_GETSETDEF) -# undef _SSL__SSLCONTEXT_VERIFY_FLAGS_GETSETDEF -# define _SSL__SSLCONTEXT_VERIFY_FLAGS_GETSETDEF {"verify_flags", (getter)_ssl__SSLContext_verify_flags_get, (setter)_ssl__SSLContext_verify_flags_set, _ssl__SSLContext_verify_flags_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_VERIFY_FLAGS_GETSETDEF {"verify_flags", NULL, (setter)_ssl__SSLContext_verify_flags_set, NULL}, -#endif - static int -_ssl__SSLContext_verify_flags_set_impl(PySSLContext *self, PyObject *value); +_ssl__SSLContext_verify_flags_set_impl(PySSLContext *self, + unsigned long value); static int -_ssl__SSLContext_verify_flags_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ssl__SSLContext_verify_flags_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + unsigned long value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'verify_flags' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + if (!PyIndex_Check(arg)) { + PyErr_Format(PyExc_TypeError, "attribute 'verify_flags' must be int, not %T", arg); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(arg, &value, sizeof(unsigned long), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(unsigned long)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLContext_verify_flags_set_impl((PySSLContext *)self, value); Py_END_CRITICAL_SECTION(); +exit: return return_value; } -#if !defined(_ssl__SSLContext_minimum_version_DOCSTR) -# define _ssl__SSLContext_minimum_version_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_MINIMUM_VERSION_GETSETDEF) -# undef _SSL__SSLCONTEXT_MINIMUM_VERSION_GETSETDEF -# define _SSL__SSLCONTEXT_MINIMUM_VERSION_GETSETDEF {"minimum_version", (getter)_ssl__SSLContext_minimum_version_get, (setter)_ssl__SSLContext_minimum_version_set, _ssl__SSLContext_minimum_version_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_MINIMUM_VERSION_GETSETDEF {"minimum_version", (getter)_ssl__SSLContext_minimum_version_get, NULL, _ssl__SSLContext_minimum_version_DOCSTR}, -#endif - static PyObject * _ssl__SSLContext_minimum_version_get_impl(PySSLContext *self); @@ -1424,25 +1450,23 @@ _ssl__SSLContext_minimum_version_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_ssl__SSLContext_minimum_version_DOCSTR) -# define _ssl__SSLContext_minimum_version_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_MINIMUM_VERSION_GETSETDEF) -# undef _SSL__SSLCONTEXT_MINIMUM_VERSION_GETSETDEF -# define _SSL__SSLCONTEXT_MINIMUM_VERSION_GETSETDEF {"minimum_version", (getter)_ssl__SSLContext_minimum_version_get, (setter)_ssl__SSLContext_minimum_version_set, _ssl__SSLContext_minimum_version_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_MINIMUM_VERSION_GETSETDEF {"minimum_version", NULL, (setter)_ssl__SSLContext_minimum_version_set, NULL}, -#endif - static int _ssl__SSLContext_minimum_version_set_impl(PySSLContext *self, PyObject *value); static int -_ssl__SSLContext_minimum_version_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ssl__SSLContext_minimum_version_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + PyObject *value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'minimum_version' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLContext_minimum_version_set_impl((PySSLContext *)self, value); Py_END_CRITICAL_SECTION(); @@ -1450,16 +1474,6 @@ _ssl__SSLContext_minimum_version_set(PyObject *self, PyObject *value, void *Py_U return return_value; } -#if !defined(_ssl__SSLContext_maximum_version_DOCSTR) -# define _ssl__SSLContext_maximum_version_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_MAXIMUM_VERSION_GETSETDEF) -# undef _SSL__SSLCONTEXT_MAXIMUM_VERSION_GETSETDEF -# define _SSL__SSLCONTEXT_MAXIMUM_VERSION_GETSETDEF {"maximum_version", (getter)_ssl__SSLContext_maximum_version_get, (setter)_ssl__SSLContext_maximum_version_set, _ssl__SSLContext_maximum_version_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_MAXIMUM_VERSION_GETSETDEF {"maximum_version", (getter)_ssl__SSLContext_maximum_version_get, NULL, _ssl__SSLContext_maximum_version_DOCSTR}, -#endif - static PyObject * _ssl__SSLContext_maximum_version_get_impl(PySSLContext *self); @@ -1475,25 +1489,23 @@ _ssl__SSLContext_maximum_version_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_ssl__SSLContext_maximum_version_DOCSTR) -# define _ssl__SSLContext_maximum_version_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_MAXIMUM_VERSION_GETSETDEF) -# undef _SSL__SSLCONTEXT_MAXIMUM_VERSION_GETSETDEF -# define _SSL__SSLCONTEXT_MAXIMUM_VERSION_GETSETDEF {"maximum_version", (getter)_ssl__SSLContext_maximum_version_get, (setter)_ssl__SSLContext_maximum_version_set, _ssl__SSLContext_maximum_version_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_MAXIMUM_VERSION_GETSETDEF {"maximum_version", NULL, (setter)_ssl__SSLContext_maximum_version_set, NULL}, -#endif - static int _ssl__SSLContext_maximum_version_set_impl(PySSLContext *self, PyObject *value); static int -_ssl__SSLContext_maximum_version_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ssl__SSLContext_maximum_version_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + PyObject *value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'maximum_version' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLContext_maximum_version_set_impl((PySSLContext *)self, value); Py_END_CRITICAL_SECTION(); @@ -1503,20 +1515,6 @@ _ssl__SSLContext_maximum_version_set(PyObject *self, PyObject *value, void *Py_U PyDoc_STRVAR(_ssl__SSLContext_num_tickets__doc__, "Control the number of TLSv1.3 session tickets."); -#if defined(_ssl__SSLContext_num_tickets_DOCSTR) -# undef _ssl__SSLContext_num_tickets_DOCSTR -#endif -#define _ssl__SSLContext_num_tickets_DOCSTR _ssl__SSLContext_num_tickets__doc__ - -#if !defined(_ssl__SSLContext_num_tickets_DOCSTR) -# define _ssl__SSLContext_num_tickets_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_NUM_TICKETS_GETSETDEF) -# undef _SSL__SSLCONTEXT_NUM_TICKETS_GETSETDEF -# define _SSL__SSLCONTEXT_NUM_TICKETS_GETSETDEF {"num_tickets", (getter)_ssl__SSLContext_num_tickets_get, (setter)_ssl__SSLContext_num_tickets_set, _ssl__SSLContext_num_tickets_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_NUM_TICKETS_GETSETDEF {"num_tickets", (getter)_ssl__SSLContext_num_tickets_get, NULL, _ssl__SSLContext_num_tickets_DOCSTR}, -#endif static PyObject * _ssl__SSLContext_num_tickets_get_impl(PySSLContext *self); @@ -1533,47 +1531,35 @@ _ssl__SSLContext_num_tickets_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_ssl__SSLContext_num_tickets_DOCSTR) -# define _ssl__SSLContext_num_tickets_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_NUM_TICKETS_GETSETDEF) -# undef _SSL__SSLCONTEXT_NUM_TICKETS_GETSETDEF -# define _SSL__SSLCONTEXT_NUM_TICKETS_GETSETDEF {"num_tickets", (getter)_ssl__SSLContext_num_tickets_get, (setter)_ssl__SSLContext_num_tickets_set, _ssl__SSLContext_num_tickets_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_NUM_TICKETS_GETSETDEF {"num_tickets", NULL, (setter)_ssl__SSLContext_num_tickets_set, NULL}, -#endif - static int -_ssl__SSLContext_num_tickets_set_impl(PySSLContext *self, PyObject *value); +_ssl__SSLContext_num_tickets_set_impl(PySSLContext *self, long value); static int -_ssl__SSLContext_num_tickets_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ssl__SSLContext_num_tickets_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + long value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'num_tickets' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = PyLong_AsLong(arg); + if (value == -1 && PyErr_Occurred()) { + goto exit; + } Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLContext_num_tickets_set_impl((PySSLContext *)self, value); Py_END_CRITICAL_SECTION(); +exit: return return_value; } PyDoc_STRVAR(_ssl__SSLContext_security_level__doc__, "The current security level."); -#if defined(_ssl__SSLContext_security_level_DOCSTR) -# undef _ssl__SSLContext_security_level_DOCSTR -#endif -#define _ssl__SSLContext_security_level_DOCSTR _ssl__SSLContext_security_level__doc__ - -#if !defined(_ssl__SSLContext_security_level_DOCSTR) -# define _ssl__SSLContext_security_level_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_SECURITY_LEVEL_GETSETDEF) -# undef _SSL__SSLCONTEXT_SECURITY_LEVEL_GETSETDEF -# define _SSL__SSLCONTEXT_SECURITY_LEVEL_GETSETDEF {"security_level", (getter)_ssl__SSLContext_security_level_get, (setter)_ssl__SSLContext_security_level_set, _ssl__SSLContext_security_level_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_SECURITY_LEVEL_GETSETDEF {"security_level", (getter)_ssl__SSLContext_security_level_get, NULL, _ssl__SSLContext_security_level_DOCSTR}, -#endif static PyObject * _ssl__SSLContext_security_level_get_impl(PySSLContext *self); @@ -1590,16 +1576,6 @@ _ssl__SSLContext_security_level_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_ssl__SSLContext_options_DOCSTR) -# define _ssl__SSLContext_options_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_OPTIONS_GETSETDEF) -# undef _SSL__SSLCONTEXT_OPTIONS_GETSETDEF -# define _SSL__SSLCONTEXT_OPTIONS_GETSETDEF {"options", (getter)_ssl__SSLContext_options_get, (setter)_ssl__SSLContext_options_set, _ssl__SSLContext_options_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_OPTIONS_GETSETDEF {"options", (getter)_ssl__SSLContext_options_get, NULL, _ssl__SSLContext_options_DOCSTR}, -#endif - static PyObject * _ssl__SSLContext_options_get_impl(PySSLContext *self); @@ -1615,141 +1591,141 @@ _ssl__SSLContext_options_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_ssl__SSLContext_options_DOCSTR) -# define _ssl__SSLContext_options_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_OPTIONS_GETSETDEF) -# undef _SSL__SSLCONTEXT_OPTIONS_GETSETDEF -# define _SSL__SSLCONTEXT_OPTIONS_GETSETDEF {"options", (getter)_ssl__SSLContext_options_get, (setter)_ssl__SSLContext_options_set, _ssl__SSLContext_options_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_OPTIONS_GETSETDEF {"options", NULL, (setter)_ssl__SSLContext_options_set, NULL}, -#endif - static int -_ssl__SSLContext_options_set_impl(PySSLContext *self, PyObject *value); +_ssl__SSLContext_options_set_impl(PySSLContext *self, + unsigned long long value); static int -_ssl__SSLContext_options_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ssl__SSLContext_options_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + unsigned long long value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'options' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + if (!_PyLong_UnsignedLongLong_Converter(arg, &value)) { + goto exit; + } Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLContext_options_set_impl((PySSLContext *)self, value); Py_END_CRITICAL_SECTION(); +exit: return return_value; } -#if !defined(_ssl__SSLContext__host_flags_DOCSTR) -# define _ssl__SSLContext__host_flags_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT__HOST_FLAGS_GETSETDEF) -# undef _SSL__SSLCONTEXT__HOST_FLAGS_GETSETDEF -# define _SSL__SSLCONTEXT__HOST_FLAGS_GETSETDEF {"_host_flags", (getter)_ssl__SSLContext__host_flags_get, (setter)_ssl__SSLContext__host_flags_set, _ssl__SSLContext__host_flags_DOCSTR}, -#else -# define _SSL__SSLCONTEXT__HOST_FLAGS_GETSETDEF {"_host_flags", (getter)_ssl__SSLContext__host_flags_get, NULL, _ssl__SSLContext__host_flags_DOCSTR}, -#endif - -static PyObject * +static unsigned int _ssl__SSLContext__host_flags_get_impl(PySSLContext *self); static PyObject * _ssl__SSLContext__host_flags_get(PyObject *self, void *Py_UNUSED(context)) { PyObject *return_value = NULL; + unsigned int _return_value; Py_BEGIN_CRITICAL_SECTION(self); - return_value = _ssl__SSLContext__host_flags_get_impl((PySSLContext *)self); + _return_value = _ssl__SSLContext__host_flags_get_impl((PySSLContext *)self); Py_END_CRITICAL_SECTION(); + if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyLong_FromUnsignedLong((unsigned long)_return_value); +exit: return return_value; } -#if !defined(_ssl__SSLContext__host_flags_DOCSTR) -# define _ssl__SSLContext__host_flags_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT__HOST_FLAGS_GETSETDEF) -# undef _SSL__SSLCONTEXT__HOST_FLAGS_GETSETDEF -# define _SSL__SSLCONTEXT__HOST_FLAGS_GETSETDEF {"_host_flags", (getter)_ssl__SSLContext__host_flags_get, (setter)_ssl__SSLContext__host_flags_set, _ssl__SSLContext__host_flags_DOCSTR}, -#else -# define _SSL__SSLCONTEXT__HOST_FLAGS_GETSETDEF {"_host_flags", NULL, (setter)_ssl__SSLContext__host_flags_set, NULL}, -#endif - static int -_ssl__SSLContext__host_flags_set_impl(PySSLContext *self, PyObject *value); +_ssl__SSLContext__host_flags_set_impl(PySSLContext *self, unsigned int value); static int -_ssl__SSLContext__host_flags_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ssl__SSLContext__host_flags_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + unsigned int value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute '_host_flags' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(arg, &value, sizeof(unsigned int), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(unsigned int)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLContext__host_flags_set_impl((PySSLContext *)self, value); Py_END_CRITICAL_SECTION(); +exit: return return_value; } -#if !defined(_ssl__SSLContext_check_hostname_DOCSTR) -# define _ssl__SSLContext_check_hostname_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_CHECK_HOSTNAME_GETSETDEF) -# undef _SSL__SSLCONTEXT_CHECK_HOSTNAME_GETSETDEF -# define _SSL__SSLCONTEXT_CHECK_HOSTNAME_GETSETDEF {"check_hostname", (getter)_ssl__SSLContext_check_hostname_get, (setter)_ssl__SSLContext_check_hostname_set, _ssl__SSLContext_check_hostname_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_CHECK_HOSTNAME_GETSETDEF {"check_hostname", (getter)_ssl__SSLContext_check_hostname_get, NULL, _ssl__SSLContext_check_hostname_DOCSTR}, -#endif - -static PyObject * +static int _ssl__SSLContext_check_hostname_get_impl(PySSLContext *self); static PyObject * _ssl__SSLContext_check_hostname_get(PyObject *self, void *Py_UNUSED(context)) { PyObject *return_value = NULL; + int _return_value; Py_BEGIN_CRITICAL_SECTION(self); - return_value = _ssl__SSLContext_check_hostname_get_impl((PySSLContext *)self); + _return_value = _ssl__SSLContext_check_hostname_get_impl((PySSLContext *)self); Py_END_CRITICAL_SECTION(); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); +exit: return return_value; } -#if !defined(_ssl__SSLContext_check_hostname_DOCSTR) -# define _ssl__SSLContext_check_hostname_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_CHECK_HOSTNAME_GETSETDEF) -# undef _SSL__SSLCONTEXT_CHECK_HOSTNAME_GETSETDEF -# define _SSL__SSLCONTEXT_CHECK_HOSTNAME_GETSETDEF {"check_hostname", (getter)_ssl__SSLContext_check_hostname_get, (setter)_ssl__SSLContext_check_hostname_set, _ssl__SSLContext_check_hostname_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_CHECK_HOSTNAME_GETSETDEF {"check_hostname", NULL, (setter)_ssl__SSLContext_check_hostname_set, NULL}, -#endif - static int -_ssl__SSLContext_check_hostname_set_impl(PySSLContext *self, PyObject *value); +_ssl__SSLContext_check_hostname_set_impl(PySSLContext *self, int value); static int -_ssl__SSLContext_check_hostname_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ssl__SSLContext_check_hostname_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + int value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'check_hostname' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = PyObject_IsTrue(arg); + if (value < 0) { + goto exit; + } Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLContext_check_hostname_set_impl((PySSLContext *)self, value); Py_END_CRITICAL_SECTION(); +exit: return return_value; } -#if !defined(_ssl__SSLContext_protocol_DOCSTR) -# define _ssl__SSLContext_protocol_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_PROTOCOL_GETSETDEF) -# undef _SSL__SSLCONTEXT_PROTOCOL_GETSETDEF -# define _SSL__SSLCONTEXT_PROTOCOL_GETSETDEF {"protocol", (getter)_ssl__SSLContext_protocol_get, (setter)_ssl__SSLContext_protocol_set, _ssl__SSLContext_protocol_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_PROTOCOL_GETSETDEF {"protocol", (getter)_ssl__SSLContext_protocol_get, NULL, _ssl__SSLContext_protocol_DOCSTR}, -#endif - static PyObject * _ssl__SSLContext_protocol_get_impl(PySSLContext *self); @@ -2186,6 +2162,139 @@ _ssl__SSLContext_set_default_verify_paths(PyObject *self, PyObject *Py_UNUSED(ig return return_value; } +#if defined(HAVE_OPENSSL_ECH) + +PyDoc_STRVAR(_ssl__SSLContext_set_ech_config__doc__, +"set_ech_config($self, ech_config, /)\n" +"--\n" +"\n" +"Set the ECH configuration on the SSL context.\n" +"\n" +"ech_config must be a bytes-like object containing an ECHConfigList\n" +"in binary or Base64 encoding."); + +#define _SSL__SSLCONTEXT_SET_ECH_CONFIG_METHODDEF \ + {"set_ech_config", (PyCFunction)_ssl__SSLContext_set_ech_config, METH_O, _ssl__SSLContext_set_ech_config__doc__}, + +static PyObject * +_ssl__SSLContext_set_ech_config_impl(PySSLContext *self, + Py_buffer *ech_config); + +static PyObject * +_ssl__SSLContext_set_ech_config(PyObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + Py_buffer ech_config = {NULL, NULL}; + + if (PyObject_GetBuffer(arg, &ech_config, PyBUF_SIMPLE) != 0) { + goto exit; + } + Py_BEGIN_CRITICAL_SECTION(self); + return_value = _ssl__SSLContext_set_ech_config_impl((PySSLContext *)self, &ech_config); + Py_END_CRITICAL_SECTION(); + +exit: + /* Cleanup for ech_config */ + if (ech_config.obj) { + PyBuffer_Release(&ech_config); + } + + return return_value; +} + +#endif /* defined(HAVE_OPENSSL_ECH) */ + +#if defined(HAVE_OPENSSL_ECH) + +PyDoc_STRVAR(_ssl__SSLContext_load_ech_keys__doc__, +"load_ech_keys($self, /, keyfile, password=None, *, for_retry=True)\n" +"--\n" +"\n" +"Load server ECH keys and configurations from a PEM file.\n" +"\n" +"The file must contain a private key followed by its ECHConfigList.\n" +"The password argument may be a string, bytes, bytearray, or a\n" +"callable returning one of those types. It is only needed for\n" +"encrypted keys.\n" +"If for_retry is true, advertise the configurations in ECH retry\n" +"responses."); + +#define _SSL__SSLCONTEXT_LOAD_ECH_KEYS_METHODDEF \ + {"load_ech_keys", _PyCFunction_CAST(_ssl__SSLContext_load_ech_keys), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_load_ech_keys__doc__}, + +static PyObject * +_ssl__SSLContext_load_ech_keys_impl(PySSLContext *self, PyObject *keyfile, + PyObject *password, int for_retry); + +static PyObject * +_ssl__SSLContext_load_ech_keys(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 3 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(keyfile), &_Py_ID(password), &_Py_ID(for_retry), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"keyfile", "password", "for_retry", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "load_ech_keys", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *keyfile; + PyObject *password = Py_None; + int for_retry = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + keyfile = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + password = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + for_retry = PyObject_IsTrue(args[2]); + if (for_retry < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = _ssl__SSLContext_load_ech_keys_impl((PySSLContext *)self, keyfile, password, for_retry); + +exit: + return return_value; +} + +#endif /* defined(HAVE_OPENSSL_ECH) */ + PyDoc_STRVAR(_ssl__SSLContext_set_ecdh_curve__doc__, "set_ecdh_curve($self, name, /)\n" "--\n" @@ -2217,20 +2326,6 @@ PyDoc_STRVAR(_ssl__SSLContext_sni_callback__doc__, "SSLContext object.\n" "\n" "See RFC 6066 for details of the SNI extension."); -#if defined(_ssl__SSLContext_sni_callback_DOCSTR) -# undef _ssl__SSLContext_sni_callback_DOCSTR -#endif -#define _ssl__SSLContext_sni_callback_DOCSTR _ssl__SSLContext_sni_callback__doc__ - -#if !defined(_ssl__SSLContext_sni_callback_DOCSTR) -# define _ssl__SSLContext_sni_callback_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_SNI_CALLBACK_GETSETDEF) -# undef _SSL__SSLCONTEXT_SNI_CALLBACK_GETSETDEF -# define _SSL__SSLCONTEXT_SNI_CALLBACK_GETSETDEF {"sni_callback", (getter)_ssl__SSLContext_sni_callback_get, (setter)_ssl__SSLContext_sni_callback_set, _ssl__SSLContext_sni_callback_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_SNI_CALLBACK_GETSETDEF {"sni_callback", (getter)_ssl__SSLContext_sni_callback_get, NULL, _ssl__SSLContext_sni_callback_DOCSTR}, -#endif static PyObject * _ssl__SSLContext_sni_callback_get_impl(PySSLContext *self); @@ -2247,24 +2342,22 @@ _ssl__SSLContext_sni_callback_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(_ssl__SSLContext_sni_callback_DOCSTR) -# define _ssl__SSLContext_sni_callback_DOCSTR NULL -#endif -#if defined(_SSL__SSLCONTEXT_SNI_CALLBACK_GETSETDEF) -# undef _SSL__SSLCONTEXT_SNI_CALLBACK_GETSETDEF -# define _SSL__SSLCONTEXT_SNI_CALLBACK_GETSETDEF {"sni_callback", (getter)_ssl__SSLContext_sni_callback_get, (setter)_ssl__SSLContext_sni_callback_set, _ssl__SSLContext_sni_callback_DOCSTR}, -#else -# define _SSL__SSLCONTEXT_SNI_CALLBACK_GETSETDEF {"sni_callback", NULL, (setter)_ssl__SSLContext_sni_callback_set, NULL}, -#endif - static int _ssl__SSLContext_sni_callback_set_impl(PySSLContext *self, PyObject *value); static int -_ssl__SSLContext_sni_callback_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +_ssl__SSLContext_sni_callback_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + PyObject *value; + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'sni_callback' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = _ssl__SSLContext_sni_callback_set_impl((PySSLContext *)self, value); Py_END_CRITICAL_SECTION(); @@ -2498,15 +2591,10 @@ _ssl__SSLContext_set_psk_server_callback(PyObject *self, PyObject *const *args, identity_hint = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t identity_hint_length; - identity_hint = PyUnicode_AsUTF8AndSize(args[1], &identity_hint_length); + identity_hint = _PyUnicode_AsUTF8NoNUL(args[1]); if (identity_hint == NULL) { goto exit; } - if (strlen(identity_hint) != (size_t)identity_hint_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("set_psk_server_callback", "argument 'identity_hint'", "str or None", args[1]); @@ -2548,20 +2636,6 @@ _ssl_MemoryBIO(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyDoc_STRVAR(_ssl_MemoryBIO_pending__doc__, "The number of bytes pending in the memory BIO."); -#if defined(_ssl_MemoryBIO_pending_DOCSTR) -# undef _ssl_MemoryBIO_pending_DOCSTR -#endif -#define _ssl_MemoryBIO_pending_DOCSTR _ssl_MemoryBIO_pending__doc__ - -#if !defined(_ssl_MemoryBIO_pending_DOCSTR) -# define _ssl_MemoryBIO_pending_DOCSTR NULL -#endif -#if defined(_SSL_MEMORYBIO_PENDING_GETSETDEF) -# undef _SSL_MEMORYBIO_PENDING_GETSETDEF -# define _SSL_MEMORYBIO_PENDING_GETSETDEF {"pending", (getter)_ssl_MemoryBIO_pending_get, (setter)_ssl_MemoryBIO_pending_set, _ssl_MemoryBIO_pending_DOCSTR}, -#else -# define _SSL_MEMORYBIO_PENDING_GETSETDEF {"pending", (getter)_ssl_MemoryBIO_pending_get, NULL, _ssl_MemoryBIO_pending_DOCSTR}, -#endif static PyObject * _ssl_MemoryBIO_pending_get_impl(PySSLMemoryBIO *self); @@ -2580,20 +2654,6 @@ _ssl_MemoryBIO_pending_get(PyObject *self, void *Py_UNUSED(context)) PyDoc_STRVAR(_ssl_MemoryBIO_eof__doc__, "Whether the memory BIO is at EOF."); -#if defined(_ssl_MemoryBIO_eof_DOCSTR) -# undef _ssl_MemoryBIO_eof_DOCSTR -#endif -#define _ssl_MemoryBIO_eof_DOCSTR _ssl_MemoryBIO_eof__doc__ - -#if !defined(_ssl_MemoryBIO_eof_DOCSTR) -# define _ssl_MemoryBIO_eof_DOCSTR NULL -#endif -#if defined(_SSL_MEMORYBIO_EOF_GETSETDEF) -# undef _SSL_MEMORYBIO_EOF_GETSETDEF -# define _SSL_MEMORYBIO_EOF_GETSETDEF {"eof", (getter)_ssl_MemoryBIO_eof_get, (setter)_ssl_MemoryBIO_eof_set, _ssl_MemoryBIO_eof_DOCSTR}, -#else -# define _SSL_MEMORYBIO_EOF_GETSETDEF {"eof", (getter)_ssl_MemoryBIO_eof_get, NULL, _ssl_MemoryBIO_eof_DOCSTR}, -#endif static PyObject * _ssl_MemoryBIO_eof_get_impl(PySSLMemoryBIO *self); @@ -2716,20 +2776,6 @@ _ssl_MemoryBIO_write_eof(PyObject *self, PyObject *Py_UNUSED(ignored)) PyDoc_STRVAR(_ssl_SSLSession_time__doc__, "Session creation time (seconds since epoch)."); -#if defined(_ssl_SSLSession_time_DOCSTR) -# undef _ssl_SSLSession_time_DOCSTR -#endif -#define _ssl_SSLSession_time_DOCSTR _ssl_SSLSession_time__doc__ - -#if !defined(_ssl_SSLSession_time_DOCSTR) -# define _ssl_SSLSession_time_DOCSTR NULL -#endif -#if defined(_SSL_SSLSESSION_TIME_GETSETDEF) -# undef _SSL_SSLSESSION_TIME_GETSETDEF -# define _SSL_SSLSESSION_TIME_GETSETDEF {"time", (getter)_ssl_SSLSession_time_get, (setter)_ssl_SSLSession_time_set, _ssl_SSLSession_time_DOCSTR}, -#else -# define _SSL_SSLSESSION_TIME_GETSETDEF {"time", (getter)_ssl_SSLSession_time_get, NULL, _ssl_SSLSession_time_DOCSTR}, -#endif static PyObject * _ssl_SSLSession_time_get_impl(PySSLSession *self); @@ -2748,20 +2794,6 @@ _ssl_SSLSession_time_get(PyObject *self, void *Py_UNUSED(context)) PyDoc_STRVAR(_ssl_SSLSession_timeout__doc__, "Session timeout (delta in seconds)."); -#if defined(_ssl_SSLSession_timeout_DOCSTR) -# undef _ssl_SSLSession_timeout_DOCSTR -#endif -#define _ssl_SSLSession_timeout_DOCSTR _ssl_SSLSession_timeout__doc__ - -#if !defined(_ssl_SSLSession_timeout_DOCSTR) -# define _ssl_SSLSession_timeout_DOCSTR NULL -#endif -#if defined(_SSL_SSLSESSION_TIMEOUT_GETSETDEF) -# undef _SSL_SSLSESSION_TIMEOUT_GETSETDEF -# define _SSL_SSLSESSION_TIMEOUT_GETSETDEF {"timeout", (getter)_ssl_SSLSession_timeout_get, (setter)_ssl_SSLSession_timeout_set, _ssl_SSLSession_timeout_DOCSTR}, -#else -# define _SSL_SSLSESSION_TIMEOUT_GETSETDEF {"timeout", (getter)_ssl_SSLSession_timeout_get, NULL, _ssl_SSLSession_timeout_DOCSTR}, -#endif static PyObject * _ssl_SSLSession_timeout_get_impl(PySSLSession *self); @@ -2780,20 +2812,6 @@ _ssl_SSLSession_timeout_get(PyObject *self, void *Py_UNUSED(context)) PyDoc_STRVAR(_ssl_SSLSession_ticket_lifetime_hint__doc__, "Ticket life time hint."); -#if defined(_ssl_SSLSession_ticket_lifetime_hint_DOCSTR) -# undef _ssl_SSLSession_ticket_lifetime_hint_DOCSTR -#endif -#define _ssl_SSLSession_ticket_lifetime_hint_DOCSTR _ssl_SSLSession_ticket_lifetime_hint__doc__ - -#if !defined(_ssl_SSLSession_ticket_lifetime_hint_DOCSTR) -# define _ssl_SSLSession_ticket_lifetime_hint_DOCSTR NULL -#endif -#if defined(_SSL_SSLSESSION_TICKET_LIFETIME_HINT_GETSETDEF) -# undef _SSL_SSLSESSION_TICKET_LIFETIME_HINT_GETSETDEF -# define _SSL_SSLSESSION_TICKET_LIFETIME_HINT_GETSETDEF {"ticket_lifetime_hint", (getter)_ssl_SSLSession_ticket_lifetime_hint_get, (setter)_ssl_SSLSession_ticket_lifetime_hint_set, _ssl_SSLSession_ticket_lifetime_hint_DOCSTR}, -#else -# define _SSL_SSLSESSION_TICKET_LIFETIME_HINT_GETSETDEF {"ticket_lifetime_hint", (getter)_ssl_SSLSession_ticket_lifetime_hint_get, NULL, _ssl_SSLSession_ticket_lifetime_hint_DOCSTR}, -#endif static PyObject * _ssl_SSLSession_ticket_lifetime_hint_get_impl(PySSLSession *self); @@ -2812,20 +2830,6 @@ _ssl_SSLSession_ticket_lifetime_hint_get(PyObject *self, void *Py_UNUSED(context PyDoc_STRVAR(_ssl_SSLSession_id__doc__, "Session ID."); -#if defined(_ssl_SSLSession_id_DOCSTR) -# undef _ssl_SSLSession_id_DOCSTR -#endif -#define _ssl_SSLSession_id_DOCSTR _ssl_SSLSession_id__doc__ - -#if !defined(_ssl_SSLSession_id_DOCSTR) -# define _ssl_SSLSession_id_DOCSTR NULL -#endif -#if defined(_SSL_SSLSESSION_ID_GETSETDEF) -# undef _SSL_SSLSESSION_ID_GETSETDEF -# define _SSL_SSLSESSION_ID_GETSETDEF {"id", (getter)_ssl_SSLSession_id_get, (setter)_ssl_SSLSession_id_set, _ssl_SSLSession_id_DOCSTR}, -#else -# define _SSL_SSLSESSION_ID_GETSETDEF {"id", (getter)_ssl_SSLSession_id_get, NULL, _ssl_SSLSession_id_DOCSTR}, -#endif static PyObject * _ssl_SSLSession_id_get_impl(PySSLSession *self); @@ -2844,20 +2848,6 @@ _ssl_SSLSession_id_get(PyObject *self, void *Py_UNUSED(context)) PyDoc_STRVAR(_ssl_SSLSession_has_ticket__doc__, "Does the session contain a ticket?"); -#if defined(_ssl_SSLSession_has_ticket_DOCSTR) -# undef _ssl_SSLSession_has_ticket_DOCSTR -#endif -#define _ssl_SSLSession_has_ticket_DOCSTR _ssl_SSLSession_has_ticket__doc__ - -#if !defined(_ssl_SSLSession_has_ticket_DOCSTR) -# define _ssl_SSLSession_has_ticket_DOCSTR NULL -#endif -#if defined(_SSL_SSLSESSION_HAS_TICKET_GETSETDEF) -# undef _SSL_SSLSESSION_HAS_TICKET_GETSETDEF -# define _SSL_SSLSESSION_HAS_TICKET_GETSETDEF {"has_ticket", (getter)_ssl_SSLSession_has_ticket_get, (setter)_ssl_SSLSession_has_ticket_set, _ssl_SSLSession_has_ticket_DOCSTR}, -#else -# define _SSL_SSLSESSION_HAS_TICKET_GETSETDEF {"has_ticket", (getter)_ssl_SSLSession_has_ticket_get, NULL, _ssl_SSLSession_has_ticket_DOCSTR}, -#endif static PyObject * _ssl_SSLSession_has_ticket_get_impl(PySSLSession *self); @@ -3097,15 +3087,10 @@ _ssl_txt2obj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject _PyArg_BadArgument("txt2obj", "argument 'txt'", "str", args[0]); goto exit; } - Py_ssize_t txt_length; - txt = PyUnicode_AsUTF8AndSize(args[0], &txt_length); + txt = _PyUnicode_AsUTF8NoNUL(args[0]); if (txt == NULL) { goto exit; } - if (strlen(txt) != (size_t)txt_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!noptargs) { goto skip_optional_pos; } @@ -3215,15 +3200,10 @@ _ssl_enum_certificates(PyObject *module, PyObject *const *args, Py_ssize_t nargs _PyArg_BadArgument("enum_certificates", "argument 'store_name'", "str", args[0]); goto exit; } - Py_ssize_t store_name_length; - store_name = PyUnicode_AsUTF8AndSize(args[0], &store_name_length); + store_name = _PyUnicode_AsUTF8NoNUL(args[0]); if (store_name == NULL) { goto exit; } - if (strlen(store_name) != (size_t)store_name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } Py_BEGIN_CRITICAL_SECTION(module); return_value = _ssl_enum_certificates_impl(module, store_name); Py_END_CRITICAL_SECTION(); @@ -3296,15 +3276,10 @@ _ssl_enum_crls(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje _PyArg_BadArgument("enum_crls", "argument 'store_name'", "str", args[0]); goto exit; } - Py_ssize_t store_name_length; - store_name = PyUnicode_AsUTF8AndSize(args[0], &store_name_length); + store_name = _PyUnicode_AsUTF8NoNUL(args[0]); if (store_name == NULL) { goto exit; } - if (strlen(store_name) != (size_t)store_name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } Py_BEGIN_CRITICAL_SECTION(module); return_value = _ssl_enum_crls_impl(module, store_name); Py_END_CRITICAL_SECTION(); @@ -3315,10 +3290,34 @@ _ssl_enum_crls(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje #endif /* defined(_MSC_VER) */ +#ifndef _SSL__SSLSOCKET_GET_ECH_STATUS_METHODDEF + #define _SSL__SSLSOCKET_GET_ECH_STATUS_METHODDEF +#endif /* !defined(_SSL__SSLSOCKET_GET_ECH_STATUS_METHODDEF) */ + +#ifndef _SSL__SSLSOCKET_GET_ECH_RETRY_CONFIG_METHODDEF + #define _SSL__SSLSOCKET_GET_ECH_RETRY_CONFIG_METHODDEF +#endif /* !defined(_SSL__SSLSOCKET_GET_ECH_RETRY_CONFIG_METHODDEF) */ + +#ifndef _SSL__SSLSOCKET_SET_ECH_CONFIG_METHODDEF + #define _SSL__SSLSOCKET_SET_ECH_CONFIG_METHODDEF +#endif /* !defined(_SSL__SSLSOCKET_SET_ECH_CONFIG_METHODDEF) */ + #ifndef _SSL__SSLSOCKET_SENDFILE_METHODDEF #define _SSL__SSLSOCKET_SENDFILE_METHODDEF #endif /* !defined(_SSL__SSLSOCKET_SENDFILE_METHODDEF) */ +#ifndef _SSL__SSLCONTEXT__SET_OUTER_ALPN_PROTOCOLS_METHODDEF + #define _SSL__SSLCONTEXT__SET_OUTER_ALPN_PROTOCOLS_METHODDEF +#endif /* !defined(_SSL__SSLCONTEXT__SET_OUTER_ALPN_PROTOCOLS_METHODDEF) */ + +#ifndef _SSL__SSLCONTEXT_SET_ECH_CONFIG_METHODDEF + #define _SSL__SSLCONTEXT_SET_ECH_CONFIG_METHODDEF +#endif /* !defined(_SSL__SSLCONTEXT_SET_ECH_CONFIG_METHODDEF) */ + +#ifndef _SSL__SSLCONTEXT_LOAD_ECH_KEYS_METHODDEF + #define _SSL__SSLCONTEXT_LOAD_ECH_KEYS_METHODDEF +#endif /* !defined(_SSL__SSLCONTEXT_LOAD_ECH_KEYS_METHODDEF) */ + #ifndef _SSL_ENUM_CERTIFICATES_METHODDEF #define _SSL_ENUM_CERTIFICATES_METHODDEF #endif /* !defined(_SSL_ENUM_CERTIFICATES_METHODDEF) */ @@ -3326,4 +3325,52 @@ _ssl_enum_crls(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje #ifndef _SSL_ENUM_CRLS_METHODDEF #define _SSL_ENUM_CRLS_METHODDEF #endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */ -/*[clinic end generated code: output=aef2e74b706c6106 input=a9049054013a1b77]*/ +#define _SSL__SSLSOCKET_CONTEXT_GETSETDEF {"context", (getter)_ssl__SSLSocket_context_get, (setter)_ssl__SSLSocket_context_set, _ssl__SSLSocket_context__doc__}, + +#define _SSL__SSLSOCKET_SERVER_SIDE_GETSETDEF {"server_side", (getter)_ssl__SSLSocket_server_side_get, (setter)NULL, _ssl__SSLSocket_server_side__doc__}, + +#define _SSL__SSLSOCKET_SERVER_HOSTNAME_GETSETDEF {"server_hostname", (getter)_ssl__SSLSocket_server_hostname_get, (setter)NULL, _ssl__SSLSocket_server_hostname__doc__}, + +#define _SSL__SSLSOCKET_OWNER_GETSETDEF {"owner", (getter)_ssl__SSLSocket_owner_get, (setter)_ssl__SSLSocket_owner_set, _ssl__SSLSocket_owner__doc__}, + +#define _SSL__SSLSOCKET_SESSION_GETSETDEF {"session", (getter)_ssl__SSLSocket_session_get, (setter)_ssl__SSLSocket_session_set, _ssl__SSLSocket_session__doc__}, + +#define _SSL__SSLSOCKET_SESSION_REUSED_GETSETDEF {"session_reused", (getter)_ssl__SSLSocket_session_reused_get, (setter)NULL, _ssl__SSLSocket_session_reused__doc__}, + +#define _SSL__SSLCONTEXT_VERIFY_MODE_GETSETDEF {"verify_mode", (getter)_ssl__SSLContext_verify_mode_get, (setter)_ssl__SSLContext_verify_mode_set, NULL}, + +#define _SSL__SSLCONTEXT_VERIFY_FLAGS_GETSETDEF {"verify_flags", (getter)_ssl__SSLContext_verify_flags_get, (setter)_ssl__SSLContext_verify_flags_set, NULL}, + +#define _SSL__SSLCONTEXT_MINIMUM_VERSION_GETSETDEF {"minimum_version", (getter)_ssl__SSLContext_minimum_version_get, (setter)_ssl__SSLContext_minimum_version_set, NULL}, + +#define _SSL__SSLCONTEXT_MAXIMUM_VERSION_GETSETDEF {"maximum_version", (getter)_ssl__SSLContext_maximum_version_get, (setter)_ssl__SSLContext_maximum_version_set, NULL}, + +#define _SSL__SSLCONTEXT_NUM_TICKETS_GETSETDEF {"num_tickets", (getter)_ssl__SSLContext_num_tickets_get, (setter)_ssl__SSLContext_num_tickets_set, _ssl__SSLContext_num_tickets__doc__}, + +#define _SSL__SSLCONTEXT_SECURITY_LEVEL_GETSETDEF {"security_level", (getter)_ssl__SSLContext_security_level_get, (setter)NULL, _ssl__SSLContext_security_level__doc__}, + +#define _SSL__SSLCONTEXT_OPTIONS_GETSETDEF {"options", (getter)_ssl__SSLContext_options_get, (setter)_ssl__SSLContext_options_set, NULL}, + +#define _SSL__SSLCONTEXT__HOST_FLAGS_GETSETDEF {"_host_flags", (getter)_ssl__SSLContext__host_flags_get, (setter)_ssl__SSLContext__host_flags_set, NULL}, + +#define _SSL__SSLCONTEXT_CHECK_HOSTNAME_GETSETDEF {"check_hostname", (getter)_ssl__SSLContext_check_hostname_get, (setter)_ssl__SSLContext_check_hostname_set, NULL}, + +#define _SSL__SSLCONTEXT_PROTOCOL_GETSETDEF {"protocol", (getter)_ssl__SSLContext_protocol_get, (setter)NULL, NULL}, + +#define _SSL__SSLCONTEXT_SNI_CALLBACK_GETSETDEF {"sni_callback", (getter)_ssl__SSLContext_sni_callback_get, (setter)_ssl__SSLContext_sni_callback_set, _ssl__SSLContext_sni_callback__doc__}, + +#define _SSL_MEMORYBIO_PENDING_GETSETDEF {"pending", (getter)_ssl_MemoryBIO_pending_get, (setter)NULL, _ssl_MemoryBIO_pending__doc__}, + +#define _SSL_MEMORYBIO_EOF_GETSETDEF {"eof", (getter)_ssl_MemoryBIO_eof_get, (setter)NULL, _ssl_MemoryBIO_eof__doc__}, + +#define _SSL_SSLSESSION_TIME_GETSETDEF {"time", (getter)_ssl_SSLSession_time_get, (setter)NULL, _ssl_SSLSession_time__doc__}, + +#define _SSL_SSLSESSION_TIMEOUT_GETSETDEF {"timeout", (getter)_ssl_SSLSession_timeout_get, (setter)NULL, _ssl_SSLSession_timeout__doc__}, + +#define _SSL_SSLSESSION_TICKET_LIFETIME_HINT_GETSETDEF {"ticket_lifetime_hint", (getter)_ssl_SSLSession_ticket_lifetime_hint_get, (setter)NULL, _ssl_SSLSession_ticket_lifetime_hint__doc__}, + +#define _SSL_SSLSESSION_ID_GETSETDEF {"id", (getter)_ssl_SSLSession_id_get, (setter)NULL, _ssl_SSLSession_id__doc__}, + +#define _SSL_SSLSESSION_HAS_TICKET_GETSETDEF {"has_ticket", (getter)_ssl_SSLSession_has_ticket_get, (setter)NULL, _ssl_SSLSession_has_ticket__doc__}, + +/*[clinic end generated code: output=fb3476aa2f825376 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_testclinic.c.h b/Modules/clinic/_testclinic.c.h index 05615c1fdd81b9c..4527ae213f021e3 100644 --- a/Modules/clinic/_testclinic.c.h +++ b/Modules/clinic/_testclinic.c.h @@ -6,10 +6,12 @@ preserve # include "pycore_gc.h" // PyGC_Head #endif #include "pycore_abstract.h" // _PyNumber_Index() +#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_long.h" // _PyLong_UnsignedShort_Converter() #include "pycore_modsupport.h" // _PyArg_CheckPositional() #include "pycore_runtime.h" // _Py_ID() #include "pycore_tuple.h" // _PyTuple_ITEMS() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(test_empty_function__doc__, "test_empty_function($module, /)\n" @@ -1528,7 +1530,7 @@ str_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs) const char *c = "c"; Py_ssize_t c_length; - if (!_PyArg_ParseStack(args, nargs, "|sys#:str_converter", + if (!PyArg_ParseArray(args, nargs, "|sys#:str_converter", &a, &b, &c, &c_length)) { goto exit; } @@ -1559,7 +1561,7 @@ str_converter_encoding(PyObject *module, PyObject *const *args, Py_ssize_t nargs char *c = NULL; Py_ssize_t c_length; - if (!_PyArg_ParseStack(args, nargs, "esetet#:str_converter_encoding", + if (!PyArg_ParseArray(args, nargs, "esetet#:str_converter_encoding", "idna", &a, "idna", &b, "idna", &c, &c_length)) { goto exit; } @@ -1593,7 +1595,7 @@ py_buffer_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs) Py_buffer a = {NULL, NULL}; Py_buffer b = {NULL, NULL}; - if (!_PyArg_ParseStack(args, nargs, "z*w*:py_buffer_converter", + if (!PyArg_ParseArray(args, nargs, "z*w*:py_buffer_converter", &a, &b)) { goto exit; } @@ -3477,6 +3479,209 @@ posonly_poskw_varpos_array(PyObject *module, PyObject *const *args, Py_ssize_t n return return_value; } +PyDoc_STRVAR(only_group__doc__, +"only_group([a])"); + +#define ONLY_GROUP_METHODDEF \ + {"only_group", _PyCFunction_CAST(only_group), METH_FASTCALL, only_group__doc__}, + +static PyObject * +only_group_impl(PyObject *module, int group_right_1, PyObject *a); + +static PyObject * +only_group(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + PyObject *a = NULL; + + if (nargs > 1) { + PyErr_SetString(PyExc_TypeError, "only_group requires 0 to 1 arguments"); + goto exit; + } + if (nargs >= 1) { + a = args[0]; + group_right_1 = 1; + } + return_value = only_group_impl(module, group_right_1, a); + +exit: + return return_value; +} + +PyDoc_STRVAR(group_and_opt__doc__, +"group_and_opt([a, b,] c=None)"); + +#define GROUP_AND_OPT_METHODDEF \ + {"group_and_opt", _PyCFunction_CAST(group_and_opt), METH_FASTCALL, group_and_opt__doc__}, + +static PyObject * +group_and_opt_impl(PyObject *module, int group_left_1, PyObject *a, + PyObject *b, PyObject *c); + +static PyObject * +group_and_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + PyObject *a = NULL; + PyObject *b = NULL; + PyObject *c = Py_None; + + Py_ssize_t offset = 0; + if (nargs > 3) { + PyErr_SetString(PyExc_TypeError, "group_and_opt requires 0 to 3 arguments"); + goto exit; + } + if (nargs >= 2) { + a = args[0]; + b = args[1]; + offset += 2; + group_left_1 = 1; + } + if (nargs <= offset) { + goto skip_optional; + } + c = args[offset]; +skip_optional: + return_value = group_and_opt_impl(module, group_left_1, a, b, c); + +exit: + return return_value; +} + +PyDoc_STRVAR(two_groups_on_left__doc__, +"two_groups_on_left([a, b,] [c,] d)"); + +#define TWO_GROUPS_ON_LEFT_METHODDEF \ + {"two_groups_on_left", _PyCFunction_CAST(two_groups_on_left), METH_FASTCALL, two_groups_on_left__doc__}, + +static PyObject * +two_groups_on_left_impl(PyObject *module, int group_left_1, PyObject *a, + PyObject *b, int group_left_2, PyObject *c, + PyObject *d); + +static PyObject * +two_groups_on_left(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + PyObject *a = NULL; + PyObject *b = NULL; + int group_left_2 = 0; + PyObject *c = NULL; + PyObject *d; + + if (nargs < 1 || nargs > 4) { + PyErr_SetString(PyExc_TypeError, "two_groups_on_left requires 1 to 4 arguments"); + goto exit; + } + if (nargs >= 3) { + a = args[0]; + b = args[1]; + group_left_1 = 1; + } + if (nargs == 2 || nargs == 4) { + c = args[nargs - 2]; + group_left_2 = 1; + } + d = args[nargs - 1]; + return_value = two_groups_on_left_impl(module, group_left_1, a, b, group_left_2, c, d); + +exit: + return return_value; +} + +PyDoc_STRVAR(two_groups_on_right__doc__, +"two_groups_on_right(a, [b,] [c, d])"); + +#define TWO_GROUPS_ON_RIGHT_METHODDEF \ + {"two_groups_on_right", _PyCFunction_CAST(two_groups_on_right), METH_FASTCALL, two_groups_on_right__doc__}, + +static PyObject * +two_groups_on_right_impl(PyObject *module, PyObject *a, int group_right_1, + PyObject *b, int group_right_2, PyObject *c, + PyObject *d); + +static PyObject * +two_groups_on_right(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *a; + int group_right_1 = 0; + PyObject *b = NULL; + int group_right_2 = 0; + PyObject *c = NULL; + PyObject *d = NULL; + + if (nargs < 1 || nargs > 4) { + PyErr_SetString(PyExc_TypeError, "two_groups_on_right requires 1 to 4 arguments"); + goto exit; + } + a = args[0]; + if (nargs == 2 || nargs == 4) { + b = args[1]; + group_right_1 = 1; + } + if (nargs >= 3) { + c = args[nargs - 2]; + d = args[nargs - 1]; + group_right_2 = 1; + } + return_value = two_groups_on_right_impl(module, a, group_right_1, b, group_right_2, c, d); + +exit: + return return_value; +} + +PyDoc_STRVAR(group_and_two_opt__doc__, +"group_and_two_opt([a, b, c,] d=None, e=None)"); + +#define GROUP_AND_TWO_OPT_METHODDEF \ + {"group_and_two_opt", _PyCFunction_CAST(group_and_two_opt), METH_FASTCALL, group_and_two_opt__doc__}, + +static PyObject * +group_and_two_opt_impl(PyObject *module, int group_left_1, PyObject *a, + PyObject *b, PyObject *c, PyObject *d, PyObject *e); + +static PyObject * +group_and_two_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + PyObject *a = NULL; + PyObject *b = NULL; + PyObject *c = NULL; + PyObject *d = Py_None; + PyObject *e = Py_None; + + Py_ssize_t offset = 0; + if (nargs > 5) { + PyErr_SetString(PyExc_TypeError, "group_and_two_opt requires 0 to 5 arguments"); + goto exit; + } + if (nargs >= 3) { + a = args[0]; + b = args[1]; + c = args[2]; + offset += 3; + group_left_1 = 1; + } + if (nargs <= offset) { + goto skip_optional; + } + d = args[offset]; + if (nargs <= offset + 1) { + goto skip_optional; + } + e = args[offset + 1]; +skip_optional: + return_value = group_and_two_opt_impl(module, group_left_1, a, b, c, d, e); + +exit: + return return_value; +} + PyDoc_STRVAR(gh_32092_oob__doc__, "gh_32092_oob($module, /, pos1, pos2, *varargs, kw1=None, kw2=None)\n" "--\n" @@ -3690,7 +3895,7 @@ gh_99240_double_free(PyObject *module, PyObject *const *args, Py_ssize_t nargs) char *a = NULL; char *b = NULL; - if (!_PyArg_ParseStack(args, nargs, "eses:gh_99240_double_free", + if (!PyArg_ParseArray(args, nargs, "eses:gh_99240_double_free", "idna", &a, "idna", &b)) { goto exit; } @@ -3839,15 +4044,10 @@ clone_f1(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw _PyArg_BadArgument("clone_f1", "argument 'path'", "str", args[0]); goto exit; } - Py_ssize_t path_length; - path = PyUnicode_AsUTF8AndSize(args[0], &path_length); + path = _PyUnicode_AsUTF8NoNUL(args[0]); if (path == NULL) { goto exit; } - if (strlen(path) != (size_t)path_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = clone_f1_impl(module, path); exit: @@ -3908,15 +4108,10 @@ clone_f2(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw _PyArg_BadArgument("clone_f2", "argument 'path'", "str", args[0]); goto exit; } - Py_ssize_t path_length; - path = PyUnicode_AsUTF8AndSize(args[0], &path_length); + path = _PyUnicode_AsUTF8NoNUL(args[0]); if (path == NULL) { goto exit; } - if (strlen(path) != (size_t)path_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = clone_f2_impl(module, path); exit: @@ -4055,6 +4250,158 @@ clone_with_conv_f2(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py return return_value; } +PyDoc_STRVAR(alias_pos__doc__, +"alias_pos($module, /, a=None)\n" +"--\n" +"\n"); + +#define ALIAS_POS_METHODDEF \ + {"alias_pos", _PyCFunction_CAST(alias_pos), METH_FASTCALL|METH_KEYWORDS, alias_pos__doc__}, + +static PyObject * +alias_pos_impl(PyObject *module, PyObject *a); + +static PyObject * +alias_pos(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 2 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { _Py_LATIN1_CHR('a'), _Py_LATIN1_CHR('b'), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"a", "b", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "alias_pos", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *a = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + a = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[0]) { + PyErr_Format(PyExc_TypeError, + "argument for alias_pos() given by " + "name ('b') and %s", 0 < nargs ? "position (1)" : "name ('a')"); + goto exit; + } + a = args[1]; +skip_optional_kwonly: + return_value = alias_pos_impl(module, a); + +exit: + return return_value; +} + +PyDoc_STRVAR(alias_kwonly__doc__, +"alias_kwonly($module, /, *, a=None)\n" +"--\n" +"\n"); + +#define ALIAS_KWONLY_METHODDEF \ + {"alias_kwonly", _PyCFunction_CAST(alias_kwonly), METH_FASTCALL|METH_KEYWORDS, alias_kwonly__doc__}, + +static PyObject * +alias_kwonly_impl(PyObject *module, PyObject *a); + +static PyObject * +alias_kwonly(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 2 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { _Py_LATIN1_CHR('a'), _Py_LATIN1_CHR('b'), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"a", "b", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "alias_kwonly", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *a = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[0]) { + a = args[0]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[0]) { + PyErr_Format(PyExc_TypeError, + "argument for alias_kwonly() given by " + "name ('b') and name ('a')"); + goto exit; + } + a = args[1]; +skip_optional_kwonly: + return_value = alias_kwonly_impl(module, a); + +exit: + return return_value; +} + PyDoc_STRVAR(_testclinic_TestClass_get_defining_class__doc__, "get_defining_class($self, /)\n" "--\n" @@ -4152,26 +4499,9 @@ static PyObject * _testclinic_TestClass_defclass_varpos(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "defclass_varpos", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; - PyObject * const *fastargs; PyObject *__clinic_args = NULL; - fastargs = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 1, argsbuf); - if (!fastargs) { + if (!_PyArg_NoKwnames("defclass_varpos", kwnames)) { goto exit; } __clinic_args = PyTuple_FromArray(args, nargs); @@ -4205,32 +4535,18 @@ static PyObject * _testclinic_TestClass_defclass_posonly_varpos(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "defclass_posonly_varpos", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; - PyObject * const *fastargs; PyObject *a; PyObject *b; PyObject *__clinic_args = NULL; - fastargs = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 1, argsbuf); - if (!fastargs) { + if (!_PyArg_NoKwnames("defclass_posonly_varpos", kwnames)) { goto exit; } - a = fastargs[0]; - b = fastargs[1]; + if (!_PyArg_CheckPositional("defclass_posonly_varpos", nargs, 2, PY_SSIZE_T_MAX)) { + goto exit; + } + a = args[0]; + b = args[1]; __clinic_args = PyTuple_FromArray(args + 2, nargs - 2); if (__clinic_args == NULL) { goto exit; @@ -4600,4 +4916,466 @@ _testclinic_TestClass_posonly_poskw_varpos_array_no_fastcall(PyObject *type, PyO exit: return return_value; } -/*[clinic end generated code: output=9971dbbc5f62b8d2 input=a9049054013a1b77]*/ + +static PyObject * +vc_plain_new_impl(PyTypeObject *type, PyObject *a); + +static PyObject * +vc_plain_new_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { _Py_LATIN1_CHR('a'), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"a", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "VcNew", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t noptargs = nargs + nkw - 0; + PyObject *a = Py_None; + + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, + /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!fastargs) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + a = fastargs[0]; +skip_optional_pos: + return_value = vc_plain_new_impl(type, a); + +exit: + return return_value; +} + +static PyObject * +vc_plain_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return vc_plain_new_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +vc_plain_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *a = Py_None; + + assert(_PyType_CAST(type)->tp_new == vc_plain_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs > 1) { + return vc_plain_new_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + if (nargs < 1) { + goto skip_optional; + } + a = args[0]; +skip_optional: + return_value = vc_plain_new_impl(_PyType_CAST(type), a); + + return return_value; +} + +static int +vc_posorkw_init_impl(PyObject *self, PyObject *a, PyObject *b); + +static int +vc_posorkw_init_helper(PyObject *self, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) +{ + int return_value = -1; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { _Py_LATIN1_CHR('b'), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"", "b", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "VcInit", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t noptargs = nargs + nkw - 1; + PyObject *a; + PyObject *b = Py_None; + + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!fastargs) { + goto exit; + } + a = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + b = fastargs[1]; +skip_optional_pos: + Py_BEGIN_CRITICAL_SECTION(self); + return_value = vc_posorkw_init_impl(self, a, b); + Py_END_CRITICAL_SECTION(); + +exit: + return return_value; +} + +static int +vc_posorkw_init(PyObject *self, PyObject *args, PyObject *kwargs) +{ + return vc_posorkw_init_helper(self, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +vc_posorkw_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *self; + int _result; + PyObject *a; + PyObject *b = Py_None; + + assert(_PyType_CAST(type)->tp_init == vc_posorkw_init); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs < 1 || nargs > 2) { + self = _PyType_CAST(type)->tp_new(_PyType_CAST(type), + (PyObject *)&_Py_SINGLETON(tuple_empty), NULL); + if (self == NULL) { + return NULL; + } + _result = vc_posorkw_init_helper(self, args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + if (_result != 0) { + Py_DECREF(self); + return NULL; + } + return self; + } + a = args[0]; + if (nargs < 2) { + goto skip_optional; + } + b = args[1]; +skip_optional: + self = _PyType_CAST(type)->tp_new(_PyType_CAST(type), + (PyObject *)&_Py_SINGLETON(tuple_empty), NULL); + if (self == NULL) { + goto exit; + } + Py_BEGIN_CRITICAL_SECTION(self); + _result = vc_posorkw_init_impl((PyObject *)self, a, b); + Py_END_CRITICAL_SECTION(); + if (_result != 0) { + Py_DECREF(self); + goto exit; + } + return_value = self; + +exit: + return return_value; +} + +static PyObject * +vc_base_new_impl(PyTypeObject *type, PyObject *a, PyObject *b); + +static PyObject * +vc_base_new_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { _Py_LATIN1_CHR('b'), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"", "b", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "VcNewBase", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t noptargs = nargs + nkw - 1; + PyObject *a; + PyObject *b = Py_None; + + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!fastargs) { + goto exit; + } + a = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + b = fastargs[1]; +skip_optional_pos: + return_value = vc_base_new_impl(type, a, b); + +exit: + return return_value; +} + +static PyObject * +vc_base_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return vc_base_new_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +vc_base_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *a; + PyObject *b = Py_None; + + assert(_PyType_CAST(type)->tp_new == vc_base_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs < 1 || nargs > 2) { + return vc_base_new_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + a = args[0]; + if (nargs < 2) { + goto skip_optional; + } + b = args[1]; +skip_optional: + return_value = vc_base_new_impl(_PyType_CAST(type), a, b); + + return return_value; +} + +static PyObject * +vc_kwonly_new_impl(PyTypeObject *type, PyObject *a, PyObject *b); + +static PyObject * +vc_kwonly_new_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 2 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { _Py_LATIN1_CHR('a'), _Py_LATIN1_CHR('b'), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"a", "b", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "VcKwOnly", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t noptargs = nargs + nkw - 1; + PyObject *a; + PyObject *b = Py_None; + + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!fastargs) { + goto exit; + } + a = fastargs[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + b = fastargs[1]; +skip_optional_kwonly: + return_value = vc_kwonly_new_impl(type, a, b); + +exit: + return return_value; +} + +static PyObject * +vc_kwonly_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return vc_kwonly_new_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +vc_kwonly_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + + assert(_PyType_CAST(type)->tp_new == vc_kwonly_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + return vc_kwonly_new_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); +} + +static PyObject * +vc_kwds_new_impl(PyTypeObject *type, PyObject *a, PyObject *b, + PyObject *kwds); + +static PyObject * +vc_kwds_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *a; + PyObject *b = Py_None; + PyObject *__clinic_kwds = NULL; + + if (!_PyArg_CheckPositional("VcKwds", PyTuple_GET_SIZE(args), 1, 2)) { + goto exit; + } + a = PyTuple_GET_ITEM(args, 0); + if (PyTuple_GET_SIZE(args) < 2) { + goto skip_optional; + } + b = PyTuple_GET_ITEM(args, 1); +skip_optional: + __clinic_kwds = Py_XNewRef(kwargs); + return_value = vc_kwds_new_impl(type, a, b, __clinic_kwds); + +exit: + /* Cleanup for kwds */ + Py_XDECREF(__clinic_kwds); + + return return_value; +} + +static PyObject * +vc_kwds_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *a; + PyObject *b = Py_None; + PyObject *__clinic_kwds = NULL; + + assert(_PyType_CAST(type)->tp_new == vc_kwds_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_CheckPositional("VcKwds", nargs, 1, 2)) { + goto exit; + } + a = args[0]; + if (nargs < 2) { + goto skip_optional; + } + b = args[1]; +skip_optional: + if (kwnames != NULL) { + __clinic_kwds = _PyStack_AsDict(args + nargs, kwnames); + if (__clinic_kwds == NULL) { + goto exit; + } + } + return_value = vc_kwds_new_impl(_PyType_CAST(type), a, b, __clinic_kwds); + +exit: + /* Cleanup for kwds */ + Py_XDECREF(__clinic_kwds); + + return return_value; +} +/*[clinic end generated code: output=2e36c6f796a4ca09 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_testclinic_depr.c.h b/Modules/clinic/_testclinic_depr.c.h index e2db4fd87ed26b7..1652e9223e54f94 100644 --- a/Modules/clinic/_testclinic_depr.c.h +++ b/Modules/clinic/_testclinic_depr.c.h @@ -6,10 +6,12 @@ preserve # include "pycore_gc.h" // PyGC_Head #endif #include "pycore_abstract.h" // _PyNumber_Index() +#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_long.h" // _PyLong_UnsignedShort_Converter() #include "pycore_modsupport.h" // _PyArg_CheckPositional() #include "pycore_runtime.h" // _Py_ID() #include "pycore_tuple.h" // _PyTuple_ITEMS() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(depr_star_new__doc__, "DeprStarNew(a=None)\n" @@ -2365,6 +2367,212 @@ depr_kwd_multi(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje return return_value; } +PyDoc_STRVAR(depr_alias__doc__, +"depr_alias($module, /, a=None)\n" +"--\n" +"\n"); + +#define DEPR_ALIAS_METHODDEF \ + {"depr_alias", _PyCFunction_CAST(depr_alias), METH_FASTCALL|METH_KEYWORDS, depr_alias__doc__}, + +static PyObject * +depr_alias_impl(PyObject *module, PyObject *a); + +// Emit compiler warnings when we get to Python 3.14. +#if PY_VERSION_HEX >= 0x030e00C0 +# error "Update the clinic input of 'depr_alias'." +#elif PY_VERSION_HEX >= 0x030e00A0 +# ifdef _MSC_VER +# pragma message ("Update the clinic input of 'depr_alias'.") +# else +# warning "Update the clinic input of 'depr_alias'." +# endif +#endif + +static PyObject * +depr_alias(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 2 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { _Py_LATIN1_CHR('a'), _Py_LATIN1_CHR('b'), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"a", "b", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "depr_alias", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *a = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + a = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[0]) { + PyErr_Format(PyExc_TypeError, + "argument for depr_alias() given by " + "name ('b') and %s", 0 < nargs ? "position (1)" : "name ('a')"); + goto exit; + } + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'b' to depr_alias() is deprecated. Use 'a' " + "instead. It will be removed in Python 3.14.", 1)) + { + goto exit; + } + a = args[1]; +skip_optional_kwonly: + return_value = depr_alias_impl(module, a); + +exit: + return return_value; +} + +PyDoc_STRVAR(depr_param__doc__, +"depr_param($module, a=None, b=None, c=None, /, *, d=None)\n" +"--\n" +"\n"); + +#define DEPR_PARAM_METHODDEF \ + {"depr_param", _PyCFunction_CAST(depr_param), METH_FASTCALL|METH_KEYWORDS, depr_param__doc__}, + +static PyObject * +depr_param_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, + PyObject *d); + +// Emit compiler warnings when we get to Python 3.14. +#if PY_VERSION_HEX >= 0x030e00C0 +# error "Update the clinic input of 'depr_param'." +#elif PY_VERSION_HEX >= 0x030e00A0 +# ifdef _MSC_VER +# pragma message ("Update the clinic input of 'depr_param'.") +# else +# warning "Update the clinic input of 'depr_param'." +# endif +#endif + +static PyObject * +depr_param(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { _Py_LATIN1_CHR('d'), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"", "", "", "d", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "depr_param", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *a = Py_None; + PyObject *b = Py_None; + PyObject *c = Py_None; + PyObject *d = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 0, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (nargs < 1) { + goto skip_optional_posonly; + } + noptargs--; + a = args[0]; + if (nargs < 2) { + goto skip_optional_posonly; + } + noptargs--; + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'b' to depr_param() is deprecated. It will " + "be removed in Python 3.14.", 1)) + { + goto exit; + } + b = args[1]; + if (nargs < 3) { + goto skip_optional_posonly; + } + noptargs--; + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'c' to depr_param() is deprecated. It will " + "be removed in Python 3.14.", 1)) + { + goto exit; + } + c = args[2]; +skip_optional_posonly: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Passing the argument 'd' to depr_param() is deprecated. It will " + "be removed in Python 3.14.", 1)) + { + goto exit; + } + d = args[3]; +skip_optional_kwonly: + return_value = depr_param_impl(module, a, b, c, d); + +exit: + return return_value; +} + PyDoc_STRVAR(depr_multi__doc__, "depr_multi($module, a, /, b, c, d, e, f, *, g)\n" "--\n" @@ -2474,4 +2682,4 @@ depr_multi(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * exit: return return_value; } -/*[clinic end generated code: output=2231bec0ed196830 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=abe0af8d8c637c36 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_testclinic_kwds.c.h b/Modules/clinic/_testclinic_kwds.c.h index 86cad50c56cf55e..729ba1b6fa7c3da 100644 --- a/Modules/clinic/_testclinic_kwds.c.h +++ b/Modules/clinic/_testclinic_kwds.c.h @@ -6,10 +6,12 @@ preserve # include "pycore_gc.h" // PyGC_Head #endif #include "pycore_abstract.h" // _PyNumber_Index() +#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_long.h" // _PyLong_UnsignedShort_Converter() #include "pycore_modsupport.h" // _PyArg_CheckPositional() #include "pycore_runtime.h" // _Py_ID() #include "pycore_tuple.h" // _PyTuple_ITEMS() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(lone_kwds__doc__, "lone_kwds($module, /, **kwds)\n" @@ -31,15 +33,7 @@ lone_kwds(PyObject *module, PyObject *args, PyObject *kwargs) if (!_PyArg_NoPositional("lone_kwds", args)) { goto exit; } - if (kwargs == NULL) { - __clinic_kwds = PyDict_New(); - if (__clinic_kwds == NULL) { - goto exit; - } - } - else { - __clinic_kwds = Py_NewRef(kwargs); - } + __clinic_kwds = Py_XNewRef(kwargs); return_value = lone_kwds_impl(module, __clinic_kwds); exit: @@ -74,16 +68,47 @@ kwds_with_pos_only(PyObject *module, PyObject *args, PyObject *kwargs) } a = PyTuple_GET_ITEM(args, 0); b = PyTuple_GET_ITEM(args, 1); - if (kwargs == NULL) { - __clinic_kwds = PyDict_New(); - if (__clinic_kwds == NULL) { - goto exit; - } + __clinic_kwds = Py_XNewRef(kwargs); + return_value = kwds_with_pos_only_impl(module, a, b, __clinic_kwds); + +exit: + /* Cleanup for kwds */ + Py_XDECREF(__clinic_kwds); + + return return_value; +} + +PyDoc_STRVAR(kwds_with_optional_pos_only__doc__, +"kwds_with_optional_pos_only($module, a, b=None, /, **kwds)\n" +"--\n" +"\n"); + +#define KWDS_WITH_OPTIONAL_POS_ONLY_METHODDEF \ + {"kwds_with_optional_pos_only", _PyCFunction_CAST(kwds_with_optional_pos_only), METH_VARARGS|METH_KEYWORDS, kwds_with_optional_pos_only__doc__}, + +static PyObject * +kwds_with_optional_pos_only_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *kwds); + +static PyObject * +kwds_with_optional_pos_only(PyObject *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *a; + PyObject *b = Py_None; + PyObject *__clinic_kwds = NULL; + + if (!_PyArg_CheckPositional("kwds_with_optional_pos_only", PyTuple_GET_SIZE(args), 1, 2)) { + goto exit; } - else { - __clinic_kwds = Py_NewRef(kwargs); + a = PyTuple_GET_ITEM(args, 0); + if (PyTuple_GET_SIZE(args) < 2) { + goto skip_optional; } - return_value = kwds_with_pos_only_impl(module, a, b, __clinic_kwds); + b = PyTuple_GET_ITEM(args, 1); +skip_optional: + __clinic_kwds = Py_XNewRef(kwargs); + return_value = kwds_with_optional_pos_only_impl(module, a, b, __clinic_kwds); exit: /* Cleanup for kwds */ @@ -111,18 +136,9 @@ kwds_with_stararg(PyObject *module, PyObject *args, PyObject *kwargs) PyObject *__clinic_kwds = NULL; __clinic_args = Py_NewRef(args); - if (kwargs == NULL) { - __clinic_kwds = PyDict_New(); - if (__clinic_kwds == NULL) { - goto exit; - } - } - else { - __clinic_kwds = Py_NewRef(kwargs); - } + __clinic_kwds = Py_XNewRef(kwargs); return_value = kwds_with_stararg_impl(module, __clinic_args, __clinic_kwds); -exit: /* Cleanup for args */ Py_XDECREF(__clinic_args); /* Cleanup for kwds */ @@ -162,15 +178,7 @@ kwds_with_pos_only_and_stararg(PyObject *module, PyObject *args, PyObject *kwarg if (!__clinic_args) { goto exit; } - if (kwargs == NULL) { - __clinic_kwds = PyDict_New(); - if (__clinic_kwds == NULL) { - goto exit; - } - } - else { - __clinic_kwds = Py_NewRef(kwargs); - } + __clinic_kwds = Py_XNewRef(kwargs); return_value = kwds_with_pos_only_and_stararg_impl(module, a, b, __clinic_args, __clinic_kwds); exit: @@ -181,4 +189,4 @@ kwds_with_pos_only_and_stararg(PyObject *module, PyObject *args, PyObject *kwarg return return_value; } -/*[clinic end generated code: output=3e5251b10aa44382 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ad46500147228faf input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_threadmodule.c.h b/Modules/clinic/_threadmodule.c.h index 926bea8e1e419a4..090fdee8f6593e3 100644 --- a/Modules/clinic/_threadmodule.c.h +++ b/Modules/clinic/_threadmodule.c.h @@ -6,7 +6,82 @@ preserve # include "pycore_gc.h" // PyGC_Head # include "pycore_runtime.h" // _Py_ID() #endif -#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_abstract.h" // _PyNumber_Index() +#include "pycore_modsupport.h" // _PyArg_CheckPositional() + +static PyObject * +_thread__ThreadHandle_ident_get_impl(PyObject *self); + +static PyObject * +_thread__ThreadHandle_ident_get(PyObject *self, void *Py_UNUSED(context)) +{ + return _thread__ThreadHandle_ident_get_impl(self); +} + +PyDoc_STRVAR(_thread__ThreadHandle_join__doc__, +"join($self, timeout=None, /)\n" +"--\n" +"\n"); + +#define _THREAD__THREADHANDLE_JOIN_METHODDEF \ + {"join", _PyCFunction_CAST(_thread__ThreadHandle_join), METH_FASTCALL, _thread__ThreadHandle_join__doc__}, + +static PyObject * +_thread__ThreadHandle_join_impl(PyObject *self, PyObject *timeout_obj); + +static PyObject * +_thread__ThreadHandle_join(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *timeout_obj = Py_None; + + if (!_PyArg_CheckPositional("join", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + timeout_obj = args[0]; +skip_optional: + return_value = _thread__ThreadHandle_join_impl(self, timeout_obj); + +exit: + return return_value; +} + +PyDoc_STRVAR(_thread__ThreadHandle_is_done__doc__, +"is_done($self, /)\n" +"--\n" +"\n"); + +#define _THREAD__THREADHANDLE_IS_DONE_METHODDEF \ + {"is_done", (PyCFunction)_thread__ThreadHandle_is_done, METH_NOARGS, _thread__ThreadHandle_is_done__doc__}, + +static PyObject * +_thread__ThreadHandle_is_done_impl(PyObject *self); + +static PyObject * +_thread__ThreadHandle_is_done(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _thread__ThreadHandle_is_done_impl(self); +} + +PyDoc_STRVAR(_thread__ThreadHandle__set_done__doc__, +"_set_done($self, /)\n" +"--\n" +"\n"); + +#define _THREAD__THREADHANDLE__SET_DONE_METHODDEF \ + {"_set_done", (PyCFunction)_thread__ThreadHandle__set_done, METH_NOARGS, _thread__ThreadHandle__set_done__doc__}, + +static PyObject * +_thread__ThreadHandle__set_done_impl(PyObject *self); + +static PyObject * +_thread__ThreadHandle__set_done(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _thread__ThreadHandle__set_done_impl(self); +} PyDoc_STRVAR(_thread_lock_acquire__doc__, "acquire($self, /, blocking=True, timeout=-1)\n" @@ -637,6 +712,457 @@ _thread_RLock__at_fork_reinit(PyObject *self, PyObject *Py_UNUSED(ignored)) #endif /* defined(HAVE_FORK) */ +PyDoc_STRVAR(_thread_daemon_threads_allowed__doc__, +"daemon_threads_allowed($module, /)\n" +"--\n" +"\n" +"Return True if daemon threads are allowed in the current interpreter.\n" +"\n" +"Return False otherwise."); + +#define _THREAD_DAEMON_THREADS_ALLOWED_METHODDEF \ + {"daemon_threads_allowed", (PyCFunction)_thread_daemon_threads_allowed, METH_NOARGS, _thread_daemon_threads_allowed__doc__}, + +static PyObject * +_thread_daemon_threads_allowed_impl(PyObject *module); + +static PyObject * +_thread_daemon_threads_allowed(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _thread_daemon_threads_allowed_impl(module); +} + +PyDoc_STRVAR(_thread_start_new_thread__doc__, +"start_new_thread($module, function, args, kwargs={}, /)\n" +"--\n" +"\n" +"Start a new thread and return its identifier.\n" +"\n" +"The thread will call the function with positional arguments from the\n" +"tuple args and keyword arguments taken from the optional dictionary\n" +"kwargs. The thread exits when the function returns; the return value\n" +"is ignored. The thread will also exit when the function raises an\n" +"unhandled exception; a stack trace will be printed unless the exception\n" +"is SystemExit."); + +#define _THREAD_START_NEW_THREAD_METHODDEF \ + {"start_new_thread", _PyCFunction_CAST(_thread_start_new_thread), METH_FASTCALL, _thread_start_new_thread__doc__}, + +static PyObject * +_thread_start_new_thread_impl(PyObject *module, PyObject *func, + PyObject *args, PyObject *kwargs); + +static PyObject * +_thread_start_new_thread(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *func; + PyObject *__clinic_args; + PyObject *__clinic_kwargs = NULL; + + if (!_PyArg_CheckPositional("start_new_thread", nargs, 2, 3)) { + goto exit; + } + func = args[0]; + if (!PyTuple_Check(args[1])) { + _PyArg_BadArgument("start_new_thread", "argument 2", "tuple", args[1]); + goto exit; + } + __clinic_args = args[1]; + if (nargs < 3) { + goto skip_optional; + } + if (!PyDict_Check(args[2])) { + _PyArg_BadArgument("start_new_thread", "argument 3", "dict", args[2]); + goto exit; + } + __clinic_kwargs = args[2]; +skip_optional: + return_value = _thread_start_new_thread_impl(module, func, __clinic_args, __clinic_kwargs); + +exit: + return return_value; +} + +PyDoc_STRVAR(_thread_start_joinable_thread__doc__, +"start_joinable_thread($module, /, function, handle=None, daemon=True)\n" +"--\n" +"\n" +"*For internal use only*: start a new thread.\n" +"\n" +"Like start_new_thread(), this starts a new thread calling the given\n" +"function. Unlike start_new_thread(), this returns a handle object with\n" +"methods to join or detach the given thread.\n" +"This function is not for third-party code, please use the `threading`\n" +"module instead. During finalization the runtime will not wait for the\n" +"thread to exit if daemon is True. If handle is provided it must be a\n" +"newly created thread._ThreadHandle instance."); + +#define _THREAD_START_JOINABLE_THREAD_METHODDEF \ + {"start_joinable_thread", _PyCFunction_CAST(_thread_start_joinable_thread), METH_FASTCALL|METH_KEYWORDS, _thread_start_joinable_thread__doc__}, + +static PyObject * +_thread_start_joinable_thread_impl(PyObject *module, PyObject *func, + PyObject *hobj, int daemon); + +static PyObject * +_thread_start_joinable_thread(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 3 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(function), &_Py_ID(handle), &_Py_ID(daemon), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"function", "handle", "daemon", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "start_joinable_thread", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *func; + PyObject *hobj = Py_None; + int daemon = 1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + func = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + hobj = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + daemon = PyObject_IsTrue(args[2]); + if (daemon < 0) { + goto exit; + } +skip_optional_pos: + return_value = _thread_start_joinable_thread_impl(module, func, hobj, daemon); + +exit: + return return_value; +} + +PyDoc_STRVAR(_thread_exit__doc__, +"exit($module, /)\n" +"--\n" +"\n" +"Raise SystemExit.\n" +"\n" +"It will cause the current thread to exit silently unless the exception\n" +"is caught."); + +#define _THREAD_EXIT_METHODDEF \ + {"exit", (PyCFunction)_thread_exit, METH_NOARGS, _thread_exit__doc__}, + +static PyObject * +_thread_exit_impl(PyObject *module); + +static PyObject * +_thread_exit(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _thread_exit_impl(module); +} + +PyDoc_STRVAR(_thread_interrupt_main__doc__, +"interrupt_main($module, signum=signal.SIGINT, /)\n" +"--\n" +"\n" +"Simulate the arrival of the given signal in the main thread.\n" +"\n" +"The corresponding signal handler will be executed.\n" +"If *signum* is omitted, SIGINT is assumed.\n" +"A subthread can use this function to interrupt the main thread.\n" +"\n" +"Note: the default signal handler for SIGINT raises\n" +"``KeyboardInterrupt``."); + +#define _THREAD_INTERRUPT_MAIN_METHODDEF \ + {"interrupt_main", _PyCFunction_CAST(_thread_interrupt_main), METH_FASTCALL, _thread_interrupt_main__doc__}, + +static PyObject * +_thread_interrupt_main_impl(PyObject *module, int signum); + +static PyObject * +_thread_interrupt_main(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int signum = SIGINT; + + if (!_PyArg_CheckPositional("interrupt_main", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + signum = PyLong_AsInt(args[0]); + if (signum == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _thread_interrupt_main_impl(module, signum); + +exit: + return return_value; +} + +PyDoc_STRVAR(_thread_allocate_lock__doc__, +"allocate_lock($module, /)\n" +"--\n" +"\n" +"Create a new lock object.\n" +"\n" +"See help(type(threading.Lock())) for information about locks."); + +#define _THREAD_ALLOCATE_LOCK_METHODDEF \ + {"allocate_lock", (PyCFunction)_thread_allocate_lock, METH_NOARGS, _thread_allocate_lock__doc__}, + +static PyObject * +_thread_allocate_lock_impl(PyObject *module); + +static PyObject * +_thread_allocate_lock(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _thread_allocate_lock_impl(module); +} + +PyDoc_STRVAR(_thread_get_ident__doc__, +"get_ident($module, /)\n" +"--\n" +"\n" +"Return a non-zero integer that uniquely identifies the current thread.\n" +"\n" +"It is unique amongst other threads that exist simultaneously.\n" +"This may be used to identify per-thread resources.\n" +"Even though on some platforms threads identities may appear to be\n" +"allocated consecutive numbers starting at 1, this behavior should not\n" +"be relied upon, and the number should be seen purely as a magic cookie.\n" +"A thread\'s identity may be reused for another thread after it exits."); + +#define _THREAD_GET_IDENT_METHODDEF \ + {"get_ident", (PyCFunction)_thread_get_ident, METH_NOARGS, _thread_get_ident__doc__}, + +static PyObject * +_thread_get_ident_impl(PyObject *module); + +static PyObject * +_thread_get_ident(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _thread_get_ident_impl(module); +} + +#if defined(PY_HAVE_THREAD_NATIVE_ID) + +PyDoc_STRVAR(_thread_get_native_id__doc__, +"get_native_id($module, /)\n" +"--\n" +"\n" +"Return a non-negative integer identifying the thread.\n" +"\n" +"It is reported by the OS (kernel). This may be used to uniquely\n" +"identify a particular thread within a system."); + +#define _THREAD_GET_NATIVE_ID_METHODDEF \ + {"get_native_id", (PyCFunction)_thread_get_native_id, METH_NOARGS, _thread_get_native_id__doc__}, + +static PyObject * +_thread_get_native_id_impl(PyObject *module); + +static PyObject * +_thread_get_native_id(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _thread_get_native_id_impl(module); +} + +#endif /* defined(PY_HAVE_THREAD_NATIVE_ID) */ + +PyDoc_STRVAR(_thread__count__doc__, +"_count($module, /)\n" +"--\n" +"\n" +"Return the number of currently running Python threads.\n" +"\n" +"The main thread is excluded. The returned number comprises all threads\n" +"created through `start_new_thread()` as well as `threading.Thread`, and\n" +"not yet finished.\n" +"\n" +"This function is meant for internal and specialized purposes only.\n" +"In most applications `threading.enumerate()` should be used instead."); + +#define _THREAD__COUNT_METHODDEF \ + {"_count", (PyCFunction)_thread__count, METH_NOARGS, _thread__count__doc__}, + +static PyObject * +_thread__count_impl(PyObject *module); + +static PyObject * +_thread__count(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _thread__count_impl(module); +} + +PyDoc_STRVAR(_thread_stack_size__doc__, +"stack_size($module, size=0, /)\n" +"--\n" +"\n" +"Return the thread stack size used when creating new threads.\n" +"\n" +"The optional size argument specifies the stack size (in bytes) to be\n" +"used for subsequently created threads, and must be 0 (use platform or\n" +"configured default) or a positive integer value of at least 32,768 (32\n" +"KiB). If changing the thread stack size is unsupported, a ThreadError\n" +"exception is raised. If the specified size is invalid, a ValueError\n" +"exception is raised, and the stack size is unmodified. 32 KiB\n" +"currently is the minimum supported stack size value to guarantee\n" +"sufficient stack space for the interpreter itself.\n" +"\n" +"Note that some systems may have particular restrictions on values for\n" +"the stack size, such as requiring a minimum stack size larger than 32\n" +"KiB or requiring allocation in multiples of the system memory page size\n" +"- platform documentation should be referred to for more information\n" +"(4 KiB pages are common; using multiples of 4096 for the stack size is\n" +"the suggested approach in the absence of more specific information)."); + +#define _THREAD_STACK_SIZE_METHODDEF \ + {"stack_size", _PyCFunction_CAST(_thread_stack_size), METH_FASTCALL, _thread_stack_size__doc__}, + +static PyObject * +_thread_stack_size_impl(PyObject *module, Py_ssize_t new_size); + +static PyObject * +_thread_stack_size(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + Py_ssize_t new_size = 0; + + if (!_PyArg_CheckPositional("stack_size", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + new_size = ival; + } +skip_optional: + return_value = _thread_stack_size_impl(module, new_size); + +exit: + return return_value; +} + +PyDoc_STRVAR(_thread__excepthook__doc__, +"_excepthook($module, args, /)\n" +"--\n" +"\n" +"Handle uncaught Thread.run() exception."); + +#define _THREAD__EXCEPTHOOK_METHODDEF \ + {"_excepthook", (PyCFunction)_thread__excepthook, METH_O, _thread__excepthook__doc__}, + +PyDoc_STRVAR(_thread__is_main_interpreter__doc__, +"_is_main_interpreter($module, /)\n" +"--\n" +"\n" +"Return True if the current interpreter is the main Python interpreter."); + +#define _THREAD__IS_MAIN_INTERPRETER_METHODDEF \ + {"_is_main_interpreter", (PyCFunction)_thread__is_main_interpreter, METH_NOARGS, _thread__is_main_interpreter__doc__}, + +static PyObject * +_thread__is_main_interpreter_impl(PyObject *module); + +static PyObject * +_thread__is_main_interpreter(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _thread__is_main_interpreter_impl(module); +} + +PyDoc_STRVAR(_thread__shutdown__doc__, +"_shutdown($module, /)\n" +"--\n" +"\n" +"Wait for all non-daemon threads (other than the calling thread) to stop."); + +#define _THREAD__SHUTDOWN_METHODDEF \ + {"_shutdown", (PyCFunction)_thread__shutdown, METH_NOARGS, _thread__shutdown__doc__}, + +static PyObject * +_thread__shutdown_impl(PyObject *module); + +static PyObject * +_thread__shutdown(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _thread__shutdown_impl(module); +} + +PyDoc_STRVAR(_thread__make_thread_handle__doc__, +"_make_thread_handle($module, ident, /)\n" +"--\n" +"\n" +"Internal only.\n" +"\n" +"Make a thread handle for threads not spawned by the _thread or\n" +"threading module."); + +#define _THREAD__MAKE_THREAD_HANDLE_METHODDEF \ + {"_make_thread_handle", (PyCFunction)_thread__make_thread_handle, METH_O, _thread__make_thread_handle__doc__}, + +PyDoc_STRVAR(_thread__get_main_thread_ident__doc__, +"_get_main_thread_ident($module, /)\n" +"--\n" +"\n" +"Internal only.\n" +"\n" +"Return a non-zero integer that uniquely identifies the main thread of\n" +"the main interpreter."); + +#define _THREAD__GET_MAIN_THREAD_IDENT_METHODDEF \ + {"_get_main_thread_ident", (PyCFunction)_thread__get_main_thread_ident, METH_NOARGS, _thread__get_main_thread_ident__doc__}, + +static PyObject * +_thread__get_main_thread_ident_impl(PyObject *module); + +static PyObject * +_thread__get_main_thread_ident(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _thread__get_main_thread_ident_impl(module); +} + #if (defined(HAVE_PTHREAD_GETNAME_NP) || defined(HAVE_PTHREAD_GET_NAME_NP) || defined(MS_WINDOWS)) PyDoc_STRVAR(_thread__get_name__doc__, @@ -733,6 +1259,10 @@ _thread_set_name(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb #define _THREAD_RLOCK__AT_FORK_REINIT_METHODDEF #endif /* !defined(_THREAD_RLOCK__AT_FORK_REINIT_METHODDEF) */ +#ifndef _THREAD_GET_NATIVE_ID_METHODDEF + #define _THREAD_GET_NATIVE_ID_METHODDEF +#endif /* !defined(_THREAD_GET_NATIVE_ID_METHODDEF) */ + #ifndef _THREAD__GET_NAME_METHODDEF #define _THREAD__GET_NAME_METHODDEF #endif /* !defined(_THREAD__GET_NAME_METHODDEF) */ @@ -740,4 +1270,6 @@ _thread_set_name(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb #ifndef _THREAD_SET_NAME_METHODDEF #define _THREAD_SET_NAME_METHODDEF #endif /* !defined(_THREAD_SET_NAME_METHODDEF) */ -/*[clinic end generated code: output=0f1707cbafc0e8f2 input=a9049054013a1b77]*/ +#define _THREAD__THREADHANDLE_IDENT_GETSETDEF {"ident", (getter)_thread__ThreadHandle_ident_get, (setter)NULL, NULL}, + +/*[clinic end generated code: output=3bfc76a318c6579d input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_tkinter.c.h b/Modules/clinic/_tkinter.c.h index 3147cf7f9d2cff3..6994ebdebaf480c 100644 --- a/Modules/clinic/_tkinter.c.h +++ b/Modules/clinic/_tkinter.c.h @@ -3,6 +3,37 @@ preserve [clinic start generated code]*/ #include "pycore_modsupport.h" // _PyArg_BadArgument() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() + +PyDoc_STRVAR(_tkinter_tkapp_call__doc__, +"call($self, /, *args)\n" +"--\n" +"\n"); + +#define _TKINTER_TKAPP_CALL_METHODDEF \ + {"call", _PyCFunction_CAST(_tkinter_tkapp_call), METH_FASTCALL, _tkinter_tkapp_call__doc__}, + +static PyObject * +_tkinter_tkapp_call_impl(TkappObject *self, PyObject *args); + +static PyObject * +_tkinter_tkapp_call(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *__clinic_args = NULL; + + __clinic_args = PyTuple_FromArray(args, nargs); + if (__clinic_args == NULL) { + goto exit; + } + return_value = _tkinter_tkapp_call_impl((TkappObject *)self, __clinic_args); + +exit: + /* Cleanup for args */ + Py_XDECREF(__clinic_args); + + return return_value; +} PyDoc_STRVAR(_tkinter_tkapp_eval__doc__, "eval($self, script, /)\n" @@ -25,15 +56,10 @@ _tkinter_tkapp_eval(PyObject *self, PyObject *arg) _PyArg_BadArgument("eval", "argument", "str", arg); goto exit; } - Py_ssize_t script_length; - script = PyUnicode_AsUTF8AndSize(arg, &script_length); + script = _PyUnicode_AsUTF8NoNUL(arg); if (script == NULL) { goto exit; } - if (strlen(script) != (size_t)script_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _tkinter_tkapp_eval_impl((TkappObject *)self, script); exit: @@ -61,15 +87,10 @@ _tkinter_tkapp_evalfile(PyObject *self, PyObject *arg) _PyArg_BadArgument("evalfile", "argument", "str", arg); goto exit; } - Py_ssize_t fileName_length; - fileName = PyUnicode_AsUTF8AndSize(arg, &fileName_length); + fileName = _PyUnicode_AsUTF8NoNUL(arg); if (fileName == NULL) { goto exit; } - if (strlen(fileName) != (size_t)fileName_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _tkinter_tkapp_evalfile_impl((TkappObject *)self, fileName); exit: @@ -97,15 +118,10 @@ _tkinter_tkapp_record(PyObject *self, PyObject *arg) _PyArg_BadArgument("record", "argument", "str", arg); goto exit; } - Py_ssize_t script_length; - script = PyUnicode_AsUTF8AndSize(arg, &script_length); + script = _PyUnicode_AsUTF8NoNUL(arg); if (script == NULL) { goto exit; } - if (strlen(script) != (size_t)script_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _tkinter_tkapp_record_impl((TkappObject *)self, script); exit: @@ -133,15 +149,10 @@ _tkinter_tkapp_adderrorinfo(PyObject *self, PyObject *arg) _PyArg_BadArgument("adderrorinfo", "argument", "str", arg); goto exit; } - Py_ssize_t msg_length; - msg = PyUnicode_AsUTF8AndSize(arg, &msg_length); + msg = _PyUnicode_AsUTF8NoNUL(arg); if (msg == NULL) { goto exit; } - if (strlen(msg) != (size_t)msg_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _tkinter_tkapp_adderrorinfo_impl((TkappObject *)self, msg); exit: @@ -232,15 +243,10 @@ _tkinter_tkapp_exprstring(PyObject *self, PyObject *arg) _PyArg_BadArgument("exprstring", "argument", "str", arg); goto exit; } - Py_ssize_t s_length; - s = PyUnicode_AsUTF8AndSize(arg, &s_length); + s = _PyUnicode_AsUTF8NoNUL(arg); if (s == NULL) { goto exit; } - if (strlen(s) != (size_t)s_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _tkinter_tkapp_exprstring_impl((TkappObject *)self, s); exit: @@ -268,15 +274,10 @@ _tkinter_tkapp_exprlong(PyObject *self, PyObject *arg) _PyArg_BadArgument("exprlong", "argument", "str", arg); goto exit; } - Py_ssize_t s_length; - s = PyUnicode_AsUTF8AndSize(arg, &s_length); + s = _PyUnicode_AsUTF8NoNUL(arg); if (s == NULL) { goto exit; } - if (strlen(s) != (size_t)s_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _tkinter_tkapp_exprlong_impl((TkappObject *)self, s); exit: @@ -304,15 +305,10 @@ _tkinter_tkapp_exprdouble(PyObject *self, PyObject *arg) _PyArg_BadArgument("exprdouble", "argument", "str", arg); goto exit; } - Py_ssize_t s_length; - s = PyUnicode_AsUTF8AndSize(arg, &s_length); + s = _PyUnicode_AsUTF8NoNUL(arg); if (s == NULL) { goto exit; } - if (strlen(s) != (size_t)s_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _tkinter_tkapp_exprdouble_impl((TkappObject *)self, s); exit: @@ -340,15 +336,10 @@ _tkinter_tkapp_exprboolean(PyObject *self, PyObject *arg) _PyArg_BadArgument("exprboolean", "argument", "str", arg); goto exit; } - Py_ssize_t s_length; - s = PyUnicode_AsUTF8AndSize(arg, &s_length); + s = _PyUnicode_AsUTF8NoNUL(arg); if (s == NULL) { goto exit; } - if (strlen(s) != (size_t)s_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _tkinter_tkapp_exprboolean_impl((TkappObject *)self, s); exit: @@ -402,15 +393,10 @@ _tkinter_tkapp_createcommand(PyObject *self, PyObject *const *args, Py_ssize_t n _PyArg_BadArgument("createcommand", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(args[0], &name_length); + name = _PyUnicode_AsUTF8NoNUL(args[0]); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } func = args[1]; return_value = _tkinter_tkapp_createcommand_impl((TkappObject *)self, name, func); @@ -439,15 +425,10 @@ _tkinter_tkapp_deletecommand(PyObject *self, PyObject *arg) _PyArg_BadArgument("deletecommand", "argument", "str", arg); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(arg, &name_length); + name = _PyUnicode_AsUTF8NoNUL(arg); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _tkinter_tkapp_deletecommand_impl((TkappObject *)self, name); exit: @@ -687,6 +668,41 @@ _tkinter_tkapp_loadtk(PyObject *self, PyObject *Py_UNUSED(ignored)) return _tkinter_tkapp_loadtk_impl((TkappObject *)self); } +PyDoc_STRVAR(_tkinter_tkapp_wantobjects__doc__, +"wantobjects($self, value=-1, /)\n" +"--\n" +"\n" +"Return the current setting, or set it if the argument is not -1."); + +#define _TKINTER_TKAPP_WANTOBJECTS_METHODDEF \ + {"wantobjects", _PyCFunction_CAST(_tkinter_tkapp_wantobjects), METH_FASTCALL, _tkinter_tkapp_wantobjects__doc__}, + +static PyObject * +_tkinter_tkapp_wantobjects_impl(TkappObject *self, int value); + +static PyObject * +_tkinter_tkapp_wantobjects(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int value = -1; + + if (!_PyArg_CheckPositional("wantobjects", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + value = PyLong_AsInt(args[0]); + if (value == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _tkinter_tkapp_wantobjects_impl((TkappObject *)self, value); + +exit: + return return_value; +} + PyDoc_STRVAR(_tkinter_tkapp_settrace__doc__, "settrace($self, func, /)\n" "--\n" @@ -799,15 +815,10 @@ _tkinter_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs) screenName = NULL; } else if (PyUnicode_Check(args[0])) { - Py_ssize_t screenName_length; - screenName = PyUnicode_AsUTF8AndSize(args[0], &screenName_length); + screenName = _PyUnicode_AsUTF8NoNUL(args[0]); if (screenName == NULL) { goto exit; } - if (strlen(screenName) != (size_t)screenName_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("create", "argument 1", "str or None", args[0]); @@ -820,15 +831,10 @@ _tkinter_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs) _PyArg_BadArgument("create", "argument 2", "str", args[1]); goto exit; } - Py_ssize_t baseName_length; - baseName = PyUnicode_AsUTF8AndSize(args[1], &baseName_length); + baseName = _PyUnicode_AsUTF8NoNUL(args[1]); if (baseName == NULL) { goto exit; } - if (strlen(baseName) != (size_t)baseName_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (nargs < 3) { goto skip_optional; } @@ -836,15 +842,10 @@ _tkinter_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs) _PyArg_BadArgument("create", "argument 3", "str", args[2]); goto exit; } - Py_ssize_t className_length; - className = PyUnicode_AsUTF8AndSize(args[2], &className_length); + className = _PyUnicode_AsUTF8NoNUL(args[2]); if (className == NULL) { goto exit; } - if (strlen(className) != (size_t)className_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (nargs < 4) { goto skip_optional; } @@ -880,15 +881,10 @@ _tkinter_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs) use = NULL; } else if (PyUnicode_Check(args[7])) { - Py_ssize_t use_length; - use = PyUnicode_AsUTF8AndSize(args[7], &use_length); + use = _PyUnicode_AsUTF8NoNUL(args[7]); if (use == NULL) { goto exit; } - if (strlen(use) != (size_t)use_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("create", "argument 8", "str or None", args[7]); @@ -905,10 +901,11 @@ PyDoc_STRVAR(_tkinter_setbusywaitinterval__doc__, "setbusywaitinterval($module, new_val, /)\n" "--\n" "\n" -"Set the busy-wait interval in milliseconds between successive calls to Tcl_DoOneEvent in a threaded Python interpreter.\n" +"Set the busy-wait interval in milliseconds.\n" "\n" -"It should be set to a divisor of the maximum time between frames in\n" -"an animation."); +"It is the interval between successive calls to Tcl_DoOneEvent when\n" +"waiting for input at the interactive prompt on Windows. It should be\n" +"set to a divisor of the maximum time between frames in an animation."); #define _TKINTER_SETBUSYWAITINTERVAL_METHODDEF \ {"setbusywaitinterval", (PyCFunction)_tkinter_setbusywaitinterval, METH_O, _tkinter_setbusywaitinterval__doc__}, @@ -936,7 +933,7 @@ PyDoc_STRVAR(_tkinter_getbusywaitinterval__doc__, "getbusywaitinterval($module, /)\n" "--\n" "\n" -"Return the current busy-wait interval between successive calls to Tcl_DoOneEvent in a threaded Python interpreter."); +"Return the current busy-wait interval in milliseconds."); #define _TKINTER_GETBUSYWAITINTERVAL_METHODDEF \ {"getbusywaitinterval", (PyCFunction)_tkinter_getbusywaitinterval, METH_NOARGS, _tkinter_getbusywaitinterval__doc__}, @@ -960,6 +957,24 @@ _tkinter_getbusywaitinterval(PyObject *module, PyObject *Py_UNUSED(ignored)) return return_value; } +PyDoc_STRVAR(_tkinter__finalize_thread__doc__, +"_finalize_thread($module, /)\n" +"--\n" +"\n" +"Clean up per-thread state."); + +#define _TKINTER__FINALIZE_THREAD_METHODDEF \ + {"_finalize_thread", (PyCFunction)_tkinter__finalize_thread, METH_NOARGS, _tkinter__finalize_thread__doc__}, + +static PyObject * +_tkinter__finalize_thread_impl(PyObject *module); + +static PyObject * +_tkinter__finalize_thread(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _tkinter__finalize_thread_impl(module); +} + #ifndef _TKINTER_TKAPP_CREATEFILEHANDLER_METHODDEF #define _TKINTER_TKAPP_CREATEFILEHANDLER_METHODDEF #endif /* !defined(_TKINTER_TKAPP_CREATEFILEHANDLER_METHODDEF) */ @@ -967,4 +982,4 @@ _tkinter_getbusywaitinterval(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF #define _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF #endif /* !defined(_TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF) */ -/*[clinic end generated code: output=c807adb73e305725 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=af52d6870d8c6065 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_uuidmodule.c.h b/Modules/clinic/_uuidmodule.c.h new file mode 100644 index 000000000000000..cd7643846ca91af --- /dev/null +++ b/Modules/clinic/_uuidmodule.c.h @@ -0,0 +1,299 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) +# include "pycore_gc.h" // PyGC_Head +# include "pycore_runtime.h" // _Py_ID() +#endif +#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() +#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() + +PyDoc_STRVAR(_uuid_uuid4__doc__, +"uuid4($module, /)\n" +"--\n" +"\n" +"Generate a random UUID (version 4)."); + +#define _UUID_UUID4_METHODDEF \ + {"uuid4", (PyCFunction)_uuid_uuid4, METH_NOARGS, _uuid_uuid4__doc__}, + +static PyObject * +_uuid_uuid4_impl(PyObject *module); + +static PyObject * +_uuid_uuid4(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(module); + return_value = _uuid_uuid4_impl(module); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +PyDoc_STRVAR(_uuid_uuid7__doc__, +"uuid7($module, /)\n" +"--\n" +"\n" +"Generate a UUID from a Unix timestamp in milliseconds and random bits.\n" +"\n" +"UUIDv7 objects feature monotonicity within a millisecond."); + +#define _UUID_UUID7_METHODDEF \ + {"uuid7", (PyCFunction)_uuid_uuid7, METH_NOARGS, _uuid_uuid7__doc__}, + +static PyObject * +_uuid_uuid7_impl(PyObject *module); + +static PyObject * +_uuid_uuid7(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(module); + return_value = _uuid_uuid7_impl(module); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +PyDoc_STRVAR(_uuid__install_c_hooks__doc__, +"_install_c_hooks($module, /, *, random_func, time_func)\n" +"--\n" +"\n"); + +#define _UUID__INSTALL_C_HOOKS_METHODDEF \ + {"_install_c_hooks", _PyCFunction_CAST(_uuid__install_c_hooks), METH_FASTCALL|METH_KEYWORDS, _uuid__install_c_hooks__doc__}, + +static PyObject * +_uuid__install_c_hooks_impl(PyObject *module, PyObject *random_func, + PyObject *time_func); + +static PyObject * +_uuid__install_c_hooks(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 2 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(random_func), &_Py_ID(time_func), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"random_func", "time_func", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "_install_c_hooks", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[2]; + PyObject *random_func; + PyObject *time_func; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 2, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + random_func = args[0]; + time_func = args[1]; + Py_BEGIN_CRITICAL_SECTION(module); + return_value = _uuid__install_c_hooks_impl(module, random_func, time_func); + Py_END_CRITICAL_SECTION(); + +exit: + return return_value; +} + +PyDoc_STRVAR(_uuid_UUID___init____doc__, +"UUID(hex=None, bytes=None, bytes_le=None, fields=None, int=None,\n" +" version=None, *, is_safe=)\n" +"--\n" +"\n" +"UUID is a fast base implementation type for uuid.UUID."); + +static int +_uuid_UUID___init___impl(uuidobject *self, PyObject *hex, PyObject *bytes, + PyObject *bytes_le, PyObject *fields, + PyObject *int_value, PyObject *version, + PyObject *is_safe); + +static int +_uuid_UUID___init__(PyObject *self, PyObject *args, PyObject *kwargs) +{ + int return_value = -1; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 7 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(hex), &_Py_ID(bytes), &_Py_ID(bytes_le), &_Py_ID(fields), &_Py_ID(int), &_Py_ID(version), &_Py_ID(is_safe), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"hex", "bytes", "bytes_le", "fields", "int", "version", "is_safe", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "UUID", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[7]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; + PyObject *hex = Py_None; + PyObject *bytes = Py_None; + PyObject *bytes_le = Py_None; + PyObject *fields = Py_None; + PyObject *int_value = Py_None; + PyObject *version = Py_None; + PyObject *is_safe = NULL; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + /*minpos*/ 0, /*maxpos*/ 6, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!fastargs) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[0]) { + hex = fastargs[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[1]) { + bytes = fastargs[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[2]) { + bytes_le = fastargs[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[3]) { + fields = fastargs[3]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[4]) { + int_value = fastargs[4]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[5]) { + version = fastargs[5]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + is_safe = fastargs[6]; +skip_optional_kwonly: + return_value = _uuid_UUID___init___impl((uuidobject *)self, hex, bytes, bytes_le, fields, int_value, version, is_safe); + +exit: + return return_value; +} + +PyDoc_STRVAR(_uuid_UUID__from_int__doc__, +"_from_int($type, value, /)\n" +"--\n" +"\n" +"Create a UUID from an integer value. Internal use only."); + +#define _UUID_UUID__FROM_INT_METHODDEF \ + {"_from_int", (PyCFunction)_uuid_UUID__from_int, METH_O|METH_CLASS, _uuid_UUID__from_int__doc__}, + +static PyObject * +_uuid_UUID__from_int_impl(PyTypeObject *type, PyObject *value); + +static PyObject * +_uuid_UUID__from_int(PyObject *type, PyObject *value) +{ + PyObject *return_value = NULL; + + return_value = _uuid_UUID__from_int_impl((PyTypeObject *)type, value); + + return return_value; +} + +PyDoc_STRVAR(_uuid_UUID___getstate____doc__, +"__getstate__($self, /)\n" +"--\n" +"\n" +"Return the UUID\'s state for pickling."); + +#define _UUID_UUID___GETSTATE___METHODDEF \ + {"__getstate__", (PyCFunction)_uuid_UUID___getstate__, METH_NOARGS, _uuid_UUID___getstate____doc__}, + +static PyObject * +_uuid_UUID___getstate___impl(uuidobject *self); + +static PyObject * +_uuid_UUID___getstate__(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _uuid_UUID___getstate___impl((uuidobject *)self); +} + +PyDoc_STRVAR(_uuid_UUID___setstate____doc__, +"__setstate__($self, state, /)\n" +"--\n" +"\n" +"Restore the UUID\'s state from pickling.\n" +"\n" +"Expects a mapping with \'int\' and optionally \'is_safe\' keys."); + +#define _UUID_UUID___SETSTATE___METHODDEF \ + {"__setstate__", (PyCFunction)_uuid_UUID___setstate__, METH_O, _uuid_UUID___setstate____doc__}, + +static PyObject * +_uuid_UUID___setstate___impl(uuidobject *self, PyObject *state); + +static PyObject * +_uuid_UUID___setstate__(PyObject *self, PyObject *state) +{ + PyObject *return_value = NULL; + + return_value = _uuid_UUID___setstate___impl((uuidobject *)self, state); + + return return_value; +} +/*[clinic end generated code: output=929e54bf30e649aa input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_winapi.c.h b/Modules/clinic/_winapi.c.h index 031a0783aef60bb..d53902b48e2afe2 100644 --- a/Modules/clinic/_winapi.c.h +++ b/Modules/clinic/_winapi.c.h @@ -88,7 +88,8 @@ _winapi_CloseHandle(PyObject *module, PyObject *arg) PyObject *return_value = NULL; HANDLE handle; - if (!PyArg_Parse(arg, "" F_HANDLE ":CloseHandle", &handle)) { + handle = PyLong_AsVoidPtr(arg); + if (!handle && PyErr_Occurred()) { goto exit; } return_value = _winapi_CloseHandle_impl(module, handle); @@ -136,17 +137,32 @@ _winapi_ConnectNamedPipe(PyObject *module, PyObject *const *args, Py_ssize_t nar static const char * const _keywords[] = {"handle", "overlapped", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, - .format = "" F_HANDLE "|p:ConnectNamedPipe", + .fname = "ConnectNamedPipe", .kwtuple = KWTUPLE, }; #undef KWTUPLE + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; HANDLE handle; int use_overlapped = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &handle, &use_overlapped)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + handle = PyLong_AsVoidPtr(args[0]); + if (!handle && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + use_overlapped = PyObject_IsTrue(args[1]); + if (use_overlapped < 0) { goto exit; } +skip_optional_pos: return_value = _winapi_ConnectNamedPipe_impl(module, handle, use_overlapped); exit: @@ -255,7 +271,7 @@ _winapi_CreateFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs) HANDLE template_file; HANDLE _return_value; - if (!_PyArg_ParseStack(args, nargs, "O&kk" F_POINTER "kk" F_HANDLE ":CreateFile", + if (!PyArg_ParseArray(args, nargs, "O&kk" F_POINTER "kk"_Py_PARSE_UINTPTR":CreateFile", _PyUnicode_WideCharString_Converter, &file_name, &desired_access, &share_mode, &security_attributes, &creation_disposition, &flags_and_attributes, &template_file)) { goto exit; } @@ -302,7 +318,7 @@ _winapi_CreateFileMapping(PyObject *module, PyObject *const *args, Py_ssize_t na LPCWSTR name = NULL; HANDLE _return_value; - if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "" F_POINTER "kkkO&:CreateFileMapping", + if (!PyArg_ParseArray(args, nargs, ""_Py_PARSE_UINTPTR"" F_POINTER "kkkO&:CreateFileMapping", &file_handle, &security_attributes, &protect, &max_size_high, &max_size_low, _PyUnicode_WideCharString_Converter, &name)) { goto exit; } @@ -471,7 +487,7 @@ _winapi_CreateNamedPipe(PyObject *module, PyObject *const *args, Py_ssize_t narg LPSECURITY_ATTRIBUTES security_attributes; HANDLE _return_value; - if (!_PyArg_ParseStack(args, nargs, "O&kkkkkk" F_POINTER ":CreateNamedPipe", + if (!PyArg_ParseArray(args, nargs, "O&kkkkkk" F_POINTER ":CreateNamedPipe", _PyUnicode_WideCharString_Converter, &name, &open_mode, &pipe_mode, &max_instances, &out_buffer_size, &in_buffer_size, &default_timeout, &security_attributes)) { goto exit; } @@ -515,10 +531,30 @@ _winapi_CreatePipe(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *pipe_attrs; DWORD size; - if (!_PyArg_ParseStack(args, nargs, "Ok:CreatePipe", - &pipe_attrs, &size)) { + if (!_PyArg_CheckPositional("CreatePipe", nargs, 2, 2)) { + goto exit; + } + pipe_attrs = args[0]; + if (!PyIndex_Check(args[1])) { + _PyArg_BadArgument("CreatePipe", "argument 2", "int", args[1]); goto exit; } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[1], &size, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } return_value = _winapi_CreatePipe_impl(module, pipe_attrs, size); exit: @@ -568,10 +604,64 @@ _winapi_CreateProcess(PyObject *module, PyObject *const *args, Py_ssize_t nargs) const wchar_t *current_directory = NULL; PyObject *startup_info; - if (!_PyArg_ParseStack(args, nargs, "O&OOOikOO&O:CreateProcess", - _PyUnicode_WideCharString_Opt_Converter, &application_name, &command_line, &proc_attrs, &thread_attrs, &inherit_handles, &creation_flags, &env_mapping, _PyUnicode_WideCharString_Opt_Converter, ¤t_directory, &startup_info)) { + if (!_PyArg_CheckPositional("CreateProcess", nargs, 9, 9)) { + goto exit; + } + if (args[0] == Py_None) { + application_name = NULL; + } + else if (PyUnicode_Check(args[0])) { + application_name = PyUnicode_AsWideCharString(args[0], NULL); + if (application_name == NULL) { + goto exit; + } + } + else { + _PyArg_BadArgument("CreateProcess", "argument 1", "str or None", args[0]); goto exit; } + command_line = args[1]; + proc_attrs = args[2]; + thread_attrs = args[3]; + inherit_handles = PyLong_AsInt(args[4]); + if (inherit_handles == -1 && PyErr_Occurred()) { + goto exit; + } + if (!PyIndex_Check(args[5])) { + _PyArg_BadArgument("CreateProcess", "argument 6", "int", args[5]); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[5], &creation_flags, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } + env_mapping = args[6]; + if (args[7] == Py_None) { + current_directory = NULL; + } + else if (PyUnicode_Check(args[7])) { + current_directory = PyUnicode_AsWideCharString(args[7], NULL); + if (current_directory == NULL) { + goto exit; + } + } + else { + _PyArg_BadArgument("CreateProcess", "argument 8", "str or None", args[7]); + goto exit; + } + startup_info = args[8]; return_value = _winapi_CreateProcess_impl(module, application_name, command_line, proc_attrs, thread_attrs, inherit_handles, creation_flags, env_mapping, current_directory, startup_info); exit: @@ -617,10 +707,69 @@ _winapi_DuplicateHandle(PyObject *module, PyObject *const *args, Py_ssize_t narg DWORD options = 0; HANDLE _return_value; - if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "" F_HANDLE "" F_HANDLE "ki|k:DuplicateHandle", - &source_process_handle, &source_handle, &target_process_handle, &desired_access, &inherit_handle, &options)) { + if (!_PyArg_CheckPositional("DuplicateHandle", nargs, 5, 6)) { + goto exit; + } + source_process_handle = PyLong_AsVoidPtr(args[0]); + if (!source_process_handle && PyErr_Occurred()) { goto exit; } + source_handle = PyLong_AsVoidPtr(args[1]); + if (!source_handle && PyErr_Occurred()) { + goto exit; + } + target_process_handle = PyLong_AsVoidPtr(args[2]); + if (!target_process_handle && PyErr_Occurred()) { + goto exit; + } + if (!PyIndex_Check(args[3])) { + _PyArg_BadArgument("DuplicateHandle", "argument 4", "int", args[3]); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[3], &desired_access, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } + inherit_handle = PyLong_AsInt(args[4]); + if (inherit_handle == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 6) { + goto skip_optional; + } + if (!PyIndex_Check(args[5])) { + _PyArg_BadArgument("DuplicateHandle", "argument 6", "int", args[5]); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[5], &options, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } +skip_optional: _return_value = _winapi_DuplicateHandle_impl(module, source_process_handle, source_handle, target_process_handle, desired_access, inherit_handle, options); if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { goto exit; @@ -710,7 +859,8 @@ _winapi_GetExitCodeProcess(PyObject *module, PyObject *arg) HANDLE process; DWORD _return_value; - if (!PyArg_Parse(arg, "" F_HANDLE ":GetExitCodeProcess", &process)) { + process = PyLong_AsVoidPtr(arg); + if (!process && PyErr_Occurred()) { goto exit; } _return_value = _winapi_GetExitCodeProcess_impl(module, process); @@ -958,9 +1108,26 @@ _winapi_GetStdHandle(PyObject *module, PyObject *arg) DWORD std_handle; HANDLE _return_value; - if (!PyArg_Parse(arg, "k:GetStdHandle", &std_handle)) { + if (!PyIndex_Check(arg)) { + _PyArg_BadArgument("GetStdHandle", "argument", "int", arg); goto exit; } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(arg, &std_handle, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } _return_value = _winapi_GetStdHandle_impl(module, std_handle); if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { goto exit; @@ -1027,8 +1194,74 @@ _winapi_MapViewOfFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs) size_t number_bytes; LPVOID _return_value; - if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "kkkO&:MapViewOfFile", - &file_map, &desired_access, &file_offset_high, &file_offset_low, _PyLong_Size_t_Converter, &number_bytes)) { + if (!_PyArg_CheckPositional("MapViewOfFile", nargs, 5, 5)) { + goto exit; + } + file_map = PyLong_AsVoidPtr(args[0]); + if (!file_map && PyErr_Occurred()) { + goto exit; + } + if (!PyIndex_Check(args[1])) { + _PyArg_BadArgument("MapViewOfFile", "argument 2", "int", args[1]); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[1], &desired_access, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } + if (!PyIndex_Check(args[2])) { + _PyArg_BadArgument("MapViewOfFile", "argument 3", "int", args[2]); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[2], &file_offset_high, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } + if (!PyIndex_Check(args[3])) { + _PyArg_BadArgument("MapViewOfFile", "argument 4", "int", args[3]); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[3], &file_offset_low, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } + if (!_PyLong_Size_t_Converter(args[4], &number_bytes)) { goto exit; } _return_value = _winapi_MapViewOfFile_impl(module, file_map, desired_access, file_offset_high, file_offset_low, number_bytes); @@ -1106,17 +1339,51 @@ _winapi_OpenEventW(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py static const char * const _keywords[] = {"desired_access", "inherit_handle", "name", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, - .format = "kiO&:OpenEventW", + .fname = "OpenEventW", .kwtuple = KWTUPLE, }; #undef KWTUPLE + PyObject *argsbuf[3]; DWORD desired_access; BOOL inherit_handle; LPCWSTR name = NULL; HANDLE _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &desired_access, &inherit_handle, _PyUnicode_WideCharString_Converter, &name)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyIndex_Check(args[0])) { + _PyArg_BadArgument("OpenEventW", "argument 'desired_access'", "int", args[0]); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[0], &desired_access, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } + inherit_handle = PyLong_AsInt(args[1]); + if (inherit_handle == -1 && PyErr_Occurred()) { + goto exit; + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("OpenEventW", "argument 'name'", "str", args[2]); + goto exit; + } + name = PyUnicode_AsWideCharString(args[2], NULL); + if (name == NULL) { goto exit; } _return_value = _winapi_OpenEventW_impl(module, desired_access, inherit_handle, name); @@ -1174,17 +1441,51 @@ _winapi_OpenMutexW(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py static const char * const _keywords[] = {"desired_access", "inherit_handle", "name", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, - .format = "kiO&:OpenMutexW", + .fname = "OpenMutexW", .kwtuple = KWTUPLE, }; #undef KWTUPLE + PyObject *argsbuf[3]; DWORD desired_access; BOOL inherit_handle; LPCWSTR name = NULL; HANDLE _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &desired_access, &inherit_handle, _PyUnicode_WideCharString_Converter, &name)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyIndex_Check(args[0])) { + _PyArg_BadArgument("OpenMutexW", "argument 'desired_access'", "int", args[0]); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[0], &desired_access, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } + inherit_handle = PyLong_AsInt(args[1]); + if (inherit_handle == -1 && PyErr_Occurred()) { + goto exit; + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("OpenMutexW", "argument 'name'", "str", args[2]); + goto exit; + } + name = PyUnicode_AsWideCharString(args[2], NULL); + if (name == NULL) { goto exit; } _return_value = _winapi_OpenMutexW_impl(module, desired_access, inherit_handle, name); @@ -1224,8 +1525,39 @@ _winapi_OpenFileMapping(PyObject *module, PyObject *const *args, Py_ssize_t narg LPCWSTR name = NULL; HANDLE _return_value; - if (!_PyArg_ParseStack(args, nargs, "kiO&:OpenFileMapping", - &desired_access, &inherit_handle, _PyUnicode_WideCharString_Converter, &name)) { + if (!_PyArg_CheckPositional("OpenFileMapping", nargs, 3, 3)) { + goto exit; + } + if (!PyIndex_Check(args[0])) { + _PyArg_BadArgument("OpenFileMapping", "argument 1", "int", args[0]); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[0], &desired_access, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } + inherit_handle = PyLong_AsInt(args[1]); + if (inherit_handle == -1 && PyErr_Occurred()) { + goto exit; + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("OpenFileMapping", "argument 3", "str", args[2]); + goto exit; + } + name = PyUnicode_AsWideCharString(args[2], NULL); + if (name == NULL) { goto exit; } _return_value = _winapi_OpenFileMapping_impl(module, desired_access, inherit_handle, name); @@ -1265,10 +1597,53 @@ _winapi_OpenProcess(PyObject *module, PyObject *const *args, Py_ssize_t nargs) DWORD process_id; HANDLE _return_value; - if (!_PyArg_ParseStack(args, nargs, "kik:OpenProcess", - &desired_access, &inherit_handle, &process_id)) { + if (!_PyArg_CheckPositional("OpenProcess", nargs, 3, 3)) { + goto exit; + } + if (!PyIndex_Check(args[0])) { + _PyArg_BadArgument("OpenProcess", "argument 1", "int", args[0]); goto exit; } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[0], &desired_access, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } + inherit_handle = PyLong_AsInt(args[1]); + if (inherit_handle == -1 && PyErr_Occurred()) { + goto exit; + } + if (!PyIndex_Check(args[2])) { + _PyArg_BadArgument("OpenProcess", "argument 3", "int", args[2]); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[2], &process_id, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } _return_value = _winapi_OpenProcess_impl(module, desired_access, inherit_handle, process_id); if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { goto exit; @@ -1300,10 +1675,21 @@ _winapi_PeekNamedPipe(PyObject *module, PyObject *const *args, Py_ssize_t nargs) HANDLE handle; int size = 0; - if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "|i:PeekNamedPipe", - &handle, &size)) { + if (!_PyArg_CheckPositional("PeekNamedPipe", nargs, 1, 2)) { + goto exit; + } + handle = PyLong_AsVoidPtr(args[0]); + if (!handle && PyErr_Occurred()) { + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + size = PyLong_AsInt(args[1]); + if (size == -1 && PyErr_Occurred()) { goto exit; } +skip_optional: return_value = _winapi_PeekNamedPipe_impl(module, handle, size); exit: @@ -1349,18 +1735,53 @@ _winapi_LCMapStringEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, static const char * const _keywords[] = {"locale", "flags", "src", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, - .format = "O&kU:LCMapStringEx", + .fname = "LCMapStringEx", .kwtuple = KWTUPLE, }; #undef KWTUPLE + PyObject *argsbuf[3]; LPCWSTR locale = NULL; DWORD flags; PyObject *src; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - _PyUnicode_WideCharString_Converter, &locale, &flags, &src)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("LCMapStringEx", "argument 'locale'", "str", args[0]); + goto exit; + } + locale = PyUnicode_AsWideCharString(args[0], NULL); + if (locale == NULL) { + goto exit; + } + if (!PyIndex_Check(args[1])) { + _PyArg_BadArgument("LCMapStringEx", "argument 'flags'", "int", args[1]); goto exit; } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[1], &flags, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("LCMapStringEx", "argument 'src'", "str", args[2]); + goto exit; + } + src = args[2]; return_value = _winapi_LCMapStringEx_impl(module, locale, flags, src); exit: @@ -1409,18 +1830,53 @@ _winapi_ReadFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb static const char * const _keywords[] = {"handle", "size", "overlapped", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, - .format = "" F_HANDLE "k|p:ReadFile", + .fname = "ReadFile", .kwtuple = KWTUPLE, }; #undef KWTUPLE + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; HANDLE handle; DWORD size; int use_overlapped = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &handle, &size, &use_overlapped)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 2, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + handle = PyLong_AsVoidPtr(args[0]); + if (!handle && PyErr_Occurred()) { goto exit; } + if (!PyIndex_Check(args[1])) { + _PyArg_BadArgument("ReadFile", "argument 'size'", "int", args[1]); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[1], &size, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } + if (!noptargs) { + goto skip_optional_pos; + } + use_overlapped = PyObject_IsTrue(args[2]); + if (use_overlapped < 0) { + goto exit; + } +skip_optional_pos: return_value = _winapi_ReadFile_impl(module, handle, size, use_overlapped); exit: @@ -1465,14 +1921,20 @@ _winapi_ReleaseMutex(PyObject *module, PyObject *const *args, Py_ssize_t nargs, static const char * const _keywords[] = {"mutex", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, - .format = "" F_HANDLE ":ReleaseMutex", + .fname = "ReleaseMutex", .kwtuple = KWTUPLE, }; #undef KWTUPLE + PyObject *argsbuf[1]; HANDLE mutex; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &mutex)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + mutex = PyLong_AsVoidPtr(args[0]); + if (!mutex && PyErr_Occurred()) { goto exit; } return_value = _winapi_ReleaseMutex_impl(module, mutex); @@ -1519,14 +1981,20 @@ _winapi_ResetEvent(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py static const char * const _keywords[] = {"event", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, - .format = "" F_HANDLE ":ResetEvent", + .fname = "ResetEvent", .kwtuple = KWTUPLE, }; #undef KWTUPLE + PyObject *argsbuf[1]; HANDLE event; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &event)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + event = PyLong_AsVoidPtr(args[0]); + if (!event && PyErr_Occurred()) { goto exit; } return_value = _winapi_ResetEvent_impl(module, event); @@ -1573,14 +2041,20 @@ _winapi_SetEvent(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb static const char * const _keywords[] = {"event", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, - .format = "" F_HANDLE ":SetEvent", + .fname = "SetEvent", .kwtuple = KWTUPLE, }; #undef KWTUPLE + PyObject *argsbuf[1]; HANDLE event; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &event)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + event = PyLong_AsVoidPtr(args[0]); + if (!event && PyErr_Occurred()) { goto exit; } return_value = _winapi_SetEvent_impl(module, event); @@ -1613,10 +2087,16 @@ _winapi_SetNamedPipeHandleState(PyObject *module, PyObject *const *args, Py_ssiz PyObject *max_collection_count; PyObject *collect_data_timeout; - if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "OOO:SetNamedPipeHandleState", - &named_pipe, &mode, &max_collection_count, &collect_data_timeout)) { + if (!_PyArg_CheckPositional("SetNamedPipeHandleState", nargs, 4, 4)) { + goto exit; + } + named_pipe = PyLong_AsVoidPtr(args[0]); + if (!named_pipe && PyErr_Occurred()) { goto exit; } + mode = args[1]; + max_collection_count = args[2]; + collect_data_timeout = args[3]; return_value = _winapi_SetNamedPipeHandleState_impl(module, named_pipe, mode, max_collection_count, collect_data_timeout); exit: @@ -1643,7 +2123,7 @@ _winapi_TerminateProcess(PyObject *module, PyObject *const *args, Py_ssize_t nar HANDLE handle; UINT exit_code; - if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "I:TerminateProcess", + if (!PyArg_ParseArray(args, nargs, ""_Py_PARSE_UINTPTR"I:TerminateProcess", &handle, &exit_code)) { goto exit; } @@ -1702,10 +2182,37 @@ _winapi_WaitNamedPipe(PyObject *module, PyObject *const *args, Py_ssize_t nargs) LPCWSTR name = NULL; DWORD timeout; - if (!_PyArg_ParseStack(args, nargs, "O&k:WaitNamedPipe", - _PyUnicode_WideCharString_Converter, &name, &timeout)) { + if (!_PyArg_CheckPositional("WaitNamedPipe", nargs, 2, 2)) { goto exit; } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("WaitNamedPipe", "argument 1", "str", args[0]); + goto exit; + } + name = PyUnicode_AsWideCharString(args[0], NULL); + if (name == NULL) { + goto exit; + } + if (!PyIndex_Check(args[1])) { + _PyArg_BadArgument("WaitNamedPipe", "argument 2", "int", args[1]); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[1], &timeout, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } return_value = _winapi_WaitNamedPipe_impl(module, name, timeout); exit: @@ -1770,18 +2277,50 @@ _winapi_BatchedWaitForMultipleObjects(PyObject *module, PyObject *const *args, P static const char * const _keywords[] = {"handle_seq", "wait_all", "milliseconds", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, - .format = "Oi|k:BatchedWaitForMultipleObjects", + .fname = "BatchedWaitForMultipleObjects", .kwtuple = KWTUPLE, }; #undef KWTUPLE + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyObject *handle_seq; BOOL wait_all; DWORD milliseconds = INFINITE; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &handle_seq, &wait_all, &milliseconds)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 2, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + handle_seq = args[0]; + wait_all = PyLong_AsInt(args[1]); + if (wait_all == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (!PyIndex_Check(args[2])) { + _PyArg_BadArgument("BatchedWaitForMultipleObjects", "argument 'milliseconds'", "int", args[2]); goto exit; } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[2], &milliseconds, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } +skip_optional_pos: return_value = _winapi_BatchedWaitForMultipleObjects_impl(module, handle_seq, wait_all, milliseconds); exit: @@ -1809,10 +2348,38 @@ _winapi_WaitForMultipleObjects(PyObject *module, PyObject *const *args, Py_ssize BOOL wait_flag; DWORD milliseconds = INFINITE; - if (!_PyArg_ParseStack(args, nargs, "Oi|k:WaitForMultipleObjects", - &handle_seq, &wait_flag, &milliseconds)) { + if (!_PyArg_CheckPositional("WaitForMultipleObjects", nargs, 2, 3)) { goto exit; } + handle_seq = args[0]; + wait_flag = PyLong_AsInt(args[1]); + if (wait_flag == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (!PyIndex_Check(args[2])) { + _PyArg_BadArgument("WaitForMultipleObjects", "argument 3", "int", args[2]); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[2], &milliseconds, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } +skip_optional: return_value = _winapi_WaitForMultipleObjects_impl(module, handle_seq, wait_flag, milliseconds); exit: @@ -1844,10 +2411,33 @@ _winapi_WaitForSingleObject(PyObject *module, PyObject *const *args, Py_ssize_t DWORD milliseconds; long _return_value; - if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "k:WaitForSingleObject", - &handle, &milliseconds)) { + if (!_PyArg_CheckPositional("WaitForSingleObject", nargs, 2, 2)) { + goto exit; + } + handle = PyLong_AsVoidPtr(args[0]); + if (!handle && PyErr_Occurred()) { + goto exit; + } + if (!PyIndex_Check(args[1])) { + _PyArg_BadArgument("WaitForSingleObject", "argument 2", "int", args[1]); goto exit; } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[1], &milliseconds, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } _return_value = _winapi_WaitForSingleObject_impl(module, handle, milliseconds); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -1897,18 +2487,34 @@ _winapi_WriteFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyO static const char * const _keywords[] = {"handle", "buffer", "overlapped", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, - .format = "" F_HANDLE "O|p:WriteFile", + .fname = "WriteFile", .kwtuple = KWTUPLE, }; #undef KWTUPLE + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; HANDLE handle; PyObject *buffer; int use_overlapped = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &handle, &buffer, &use_overlapped)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 2, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + handle = PyLong_AsVoidPtr(args[0]); + if (!handle && PyErr_Occurred()) { + goto exit; + } + buffer = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + use_overlapped = PyObject_IsTrue(args[2]); + if (use_overlapped < 0) { goto exit; } +skip_optional_pos: return_value = _winapi_WriteFile_impl(module, handle, buffer, use_overlapped); exit: @@ -1989,15 +2595,21 @@ _winapi_GetFileType(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P static const char * const _keywords[] = {"handle", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, - .format = "" F_HANDLE ":GetFileType", + .fname = "GetFileType", .kwtuple = KWTUPLE, }; #undef KWTUPLE + PyObject *argsbuf[1]; HANDLE handle; DWORD _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &handle)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + handle = PyLong_AsVoidPtr(args[0]); + if (!handle && PyErr_Occurred()) { goto exit; } _return_value = _winapi_GetFileType_impl(module, handle); @@ -2010,6 +2622,127 @@ _winapi_GetFileType(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P return return_value; } +PyDoc_STRVAR(_winapi_GetConsoleMode__doc__, +"GetConsoleMode($module, handle, /)\n" +"--\n" +"\n" +"Return the current mode of a console buffer.\n" +"\n" +"The handle may refer to a console input buffer or a console screen\n" +"buffer."); + +#define _WINAPI_GETCONSOLEMODE_METHODDEF \ + {"GetConsoleMode", (PyCFunction)_winapi_GetConsoleMode, METH_O, _winapi_GetConsoleMode__doc__}, + +static DWORD +_winapi_GetConsoleMode_impl(PyObject *module, HANDLE handle); + +static PyObject * +_winapi_GetConsoleMode(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + HANDLE handle; + DWORD _return_value; + + handle = PyLong_AsVoidPtr(arg); + if (!handle && PyErr_Occurred()) { + goto exit; + } + _return_value = _winapi_GetConsoleMode_impl(module, handle); + if ((_return_value == PY_DWORD_MAX) && PyErr_Occurred()) { + goto exit; + } + return_value = PyLong_FromUnsignedLong(_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(_winapi_SetConsoleMode__doc__, +"SetConsoleMode($module, handle, mode, /)\n" +"--\n" +"\n" +"Set the mode of a console buffer.\n" +"\n" +"The handle may refer to a console input buffer or a console screen\n" +"buffer."); + +#define _WINAPI_SETCONSOLEMODE_METHODDEF \ + {"SetConsoleMode", _PyCFunction_CAST(_winapi_SetConsoleMode), METH_FASTCALL, _winapi_SetConsoleMode__doc__}, + +static PyObject * +_winapi_SetConsoleMode_impl(PyObject *module, HANDLE handle, DWORD mode); + +static PyObject * +_winapi_SetConsoleMode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + HANDLE handle; + DWORD mode; + + if (!_PyArg_CheckPositional("SetConsoleMode", nargs, 2, 2)) { + goto exit; + } + handle = PyLong_AsVoidPtr(args[0]); + if (!handle && PyErr_Occurred()) { + goto exit; + } + if (!PyIndex_Check(args[1])) { + _PyArg_BadArgument("SetConsoleMode", "argument 2", "int", args[1]); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[1], &mode, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } + return_value = _winapi_SetConsoleMode_impl(module, handle, mode); + +exit: + return return_value; +} + +PyDoc_STRVAR(_winapi_FlushConsoleInputBuffer__doc__, +"FlushConsoleInputBuffer($module, handle, /)\n" +"--\n" +"\n" +"Flush the console input buffer.\n" +"\n" +"All input records currently in the input buffer are discarded."); + +#define _WINAPI_FLUSHCONSOLEINPUTBUFFER_METHODDEF \ + {"FlushConsoleInputBuffer", (PyCFunction)_winapi_FlushConsoleInputBuffer, METH_O, _winapi_FlushConsoleInputBuffer__doc__}, + +static PyObject * +_winapi_FlushConsoleInputBuffer_impl(PyObject *module, HANDLE handle); + +static PyObject * +_winapi_FlushConsoleInputBuffer(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + HANDLE handle; + + handle = PyLong_AsVoidPtr(arg); + if (!handle && PyErr_Occurred()) { + goto exit; + } + return_value = _winapi_FlushConsoleInputBuffer_impl(module, handle); + +exit: + return return_value; +} + PyDoc_STRVAR(_winapi__mimetypes_read_windows_registry__doc__, "_mimetypes_read_windows_registry($module, /, on_type_read)\n" "--\n" @@ -2160,19 +2893,63 @@ _winapi_CopyFile2(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyO static const char * const _keywords[] = {"existing_file_name", "new_file_name", "flags", "progress_routine", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, - .format = "O&O&k|O:CopyFile2", + .fname = "CopyFile2", .kwtuple = KWTUPLE, }; #undef KWTUPLE + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; LPCWSTR existing_file_name = NULL; LPCWSTR new_file_name = NULL; DWORD flags; PyObject *progress_routine = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - _PyUnicode_WideCharString_Converter, &existing_file_name, _PyUnicode_WideCharString_Converter, &new_file_name, &flags, &progress_routine)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 3, /*maxpos*/ 4, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("CopyFile2", "argument 'existing_file_name'", "str", args[0]); + goto exit; + } + existing_file_name = PyUnicode_AsWideCharString(args[0], NULL); + if (existing_file_name == NULL) { + goto exit; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("CopyFile2", "argument 'new_file_name'", "str", args[1]); + goto exit; + } + new_file_name = PyUnicode_AsWideCharString(args[1], NULL); + if (new_file_name == NULL) { goto exit; } + if (!PyIndex_Check(args[2])) { + _PyArg_BadArgument("CopyFile2", "argument 'flags'", "int", args[2]); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[2], &flags, sizeof(DWORD), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(DWORD)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } + if (!noptargs) { + goto skip_optional_pos; + } + progress_routine = args[3]; +skip_optional_pos: return_value = _winapi_CopyFile2_impl(module, existing_file_name, new_file_name, flags, progress_routine); exit: @@ -2274,7 +3051,8 @@ _winapi_DeregisterEventSource(PyObject *module, PyObject *arg) PyObject *return_value = NULL; HANDLE handle; - if (!PyArg_Parse(arg, "" F_HANDLE ":DeregisterEventSource", &handle)) { + handle = PyLong_AsVoidPtr(arg); + if (!handle && PyErr_Occurred()) { goto exit; } return_value = _winapi_DeregisterEventSource_impl(module, handle); @@ -2318,8 +3096,28 @@ _winapi_ReportEvent(PyObject *module, PyObject *const *args, Py_ssize_t nargs) unsigned int event_id; LPCWSTR string = NULL; - if (!_PyArg_ParseStack(args, nargs, "" F_HANDLE "O&O&O&O&:ReportEvent", - &handle, _PyLong_UnsignedShort_Converter, &type, _PyLong_UnsignedShort_Converter, &category, _PyLong_UnsignedInt_Converter, &event_id, _PyUnicode_WideCharString_Converter, &string)) { + if (!_PyArg_CheckPositional("ReportEvent", nargs, 5, 5)) { + goto exit; + } + handle = PyLong_AsVoidPtr(args[0]); + if (!handle && PyErr_Occurred()) { + goto exit; + } + if (!_PyLong_UnsignedShort_Converter(args[1], &type)) { + goto exit; + } + if (!_PyLong_UnsignedShort_Converter(args[2], &category)) { + goto exit; + } + if (!_PyLong_UnsignedInt_Converter(args[3], &event_id)) { + goto exit; + } + if (!PyUnicode_Check(args[4])) { + _PyArg_BadArgument("ReportEvent", "argument 5", "str", args[4]); + goto exit; + } + string = PyUnicode_AsWideCharString(args[4], NULL); + if (string == NULL) { goto exit; } return_value = _winapi_ReportEvent_impl(module, handle, type, category, event_id, string); @@ -2349,7 +3147,8 @@ _winapi_GetProcessMemoryInfo(PyObject *module, PyObject *arg) PyObject *return_value = NULL; HANDLE handle; - if (!PyArg_Parse(arg, "" F_HANDLE ":GetProcessMemoryInfo", &handle)) { + handle = PyLong_AsVoidPtr(arg); + if (!handle && PyErr_Occurred()) { goto exit; } return_value = _winapi_GetProcessMemoryInfo_impl(module, handle); @@ -2379,4 +3178,4 @@ _winapi_GetTickCount64(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef _WINAPI_GETSHORTPATHNAME_METHODDEF #define _WINAPI_GETSHORTPATHNAME_METHODDEF #endif /* !defined(_WINAPI_GETSHORTPATHNAME_METHODDEF) */ -/*[clinic end generated code: output=713a8ce97185b017 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=0242bed9703b56a7 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_zoneinfo.c.h b/Modules/clinic/_zoneinfo.c.h index 19564a6c13f246a..4ec36c2209a7743 100644 --- a/Modules/clinic/_zoneinfo.c.h +++ b/Modules/clinic/_zoneinfo.c.h @@ -19,7 +19,8 @@ static PyObject * zoneinfo_ZoneInfo_impl(PyTypeObject *type, PyObject *key); static PyObject * -zoneinfo_ZoneInfo(PyTypeObject *type, PyObject *args, PyObject *kwargs) +zoneinfo_ZoneInfo_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -51,10 +52,9 @@ zoneinfo_ZoneInfo(PyTypeObject *type, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[1]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *key; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -68,6 +68,40 @@ zoneinfo_ZoneInfo(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +zoneinfo_ZoneInfo(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return zoneinfo_ZoneInfo_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +zoneinfo_ZoneInfo_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *key; + + assert(_PyType_CAST(type)->tp_new == zoneinfo_ZoneInfo); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs < 1 || nargs > 1) { + return zoneinfo_ZoneInfo_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + key = args[0]; + Py_BEGIN_CRITICAL_SECTION(type); + return_value = zoneinfo_ZoneInfo_impl(_PyType_CAST(type), key); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(zoneinfo_ZoneInfo_from_file__doc__, "from_file($type, file_obj, /, key=None)\n" "--\n" @@ -276,25 +310,12 @@ static PyObject * zoneinfo_ZoneInfo_utcoffset(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "utcoffset", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *dt; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("utcoffset", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("utcoffset", nargs, 1, 1)) { goto exit; } dt = args[0]; @@ -320,25 +341,12 @@ static PyObject * zoneinfo_ZoneInfo_dst(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "dst", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *dt; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("dst", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("dst", nargs, 1, 1)) { goto exit; } dt = args[0]; @@ -365,25 +373,12 @@ static PyObject * zoneinfo_ZoneInfo_tzname(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "tzname", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *dt; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("tzname", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("tzname", nargs, 1, 1)) { goto exit; } dt = args[0]; @@ -410,26 +405,13 @@ static PyObject * zoneinfo_ZoneInfo__unpickle(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "_unpickle", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *key; unsigned char from_cache; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("_unpickle", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("_unpickle", nargs, 2, 2)) { goto exit; } key = args[0]; @@ -454,4 +436,36 @@ zoneinfo_ZoneInfo__unpickle(PyObject *type, PyTypeObject *cls, PyObject *const * exit: return return_value; } -/*[clinic end generated code: output=c6df04d7b400bd7f input=a9049054013a1b77]*/ + +PyDoc_STRVAR(zoneinfo_ZoneInfo___init_subclass____doc__, +"__init_subclass__($type, /, **kwargs)\n" +"--\n" +"\n" +"Function to initialize subclasses."); + +#define ZONEINFO_ZONEINFO___INIT_SUBCLASS___METHODDEF \ + {"__init_subclass__", _PyCFunction_CAST(zoneinfo_ZoneInfo___init_subclass__), METH_VARARGS|METH_KEYWORDS|METH_CLASS, zoneinfo_ZoneInfo___init_subclass____doc__}, + +static PyObject * +zoneinfo_ZoneInfo___init_subclass___impl(PyTypeObject *type, + PyObject *kwargs); + +static PyObject * +zoneinfo_ZoneInfo___init_subclass__(PyObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *__clinic_kwargs = NULL; + + if (!_PyArg_NoPositional("__init_subclass__", args)) { + goto exit; + } + __clinic_kwargs = Py_XNewRef(kwargs); + return_value = zoneinfo_ZoneInfo___init_subclass___impl((PyTypeObject *)type, __clinic_kwargs); + +exit: + /* Cleanup for kwargs */ + Py_XDECREF(__clinic_kwargs); + + return return_value; +} +/*[clinic end generated code: output=e64d1d5b38e0c6e5 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/arraymodule.c.h b/Modules/clinic/arraymodule.c.h index 1e9f317853d6c2e..41798e098389c2a 100644 --- a/Modules/clinic/arraymodule.c.h +++ b/Modules/clinic/arraymodule.c.h @@ -2,11 +2,9 @@ preserve [clinic start generated code]*/ -#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) -# include "pycore_runtime.h" // _Py_SINGLETON() -#endif #include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(array_array_clear__doc__, "clear($self, /)\n" @@ -217,25 +215,12 @@ static PyObject * array_array_extend(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "extend", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *bb; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("extend", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("extend", nargs, 1, 1)) { goto exit; } bb = args[0]; @@ -386,26 +371,13 @@ static PyObject * array_array_fromfile(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "fromfile", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *f; Py_ssize_t n; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("fromfile", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("fromfile", nargs, 2, 2)) { goto exit; } f = args[0]; @@ -448,25 +420,12 @@ static PyObject * array_array_tofile(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "tofile", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *f; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("tofile", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("tofile", nargs, 1, 1)) { goto exit; } f = args[0]; @@ -673,15 +632,10 @@ array__array_reconstructor(PyObject *module, PyObject *const *args, Py_ssize_t n _PyArg_BadArgument("_array_reconstructor", "argument 2", "str", args[1]); goto exit; } - Py_ssize_t typecode_length; - typecode = PyUnicode_AsUTF8AndSize(args[1], &typecode_length); + typecode = _PyUnicode_AsUTF8NoNUL(args[1]); if (typecode == NULL) { goto exit; } - if (strlen(typecode) != (size_t)typecode_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } mformat_code = PyLong_AsInt(args[2]); if (mformat_code == -1 && PyErr_Occurred()) { goto exit; @@ -710,25 +664,12 @@ static PyObject * array_array___reduce_ex__(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "__reduce_ex__", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *value; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("__reduce_ex__", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("__reduce_ex__", nargs, 1, 1)) { goto exit; } value = args[0]; @@ -781,4 +722,4 @@ array_arrayiterator___setstate__(PyObject *self, PyObject *state) return return_value; } -/*[clinic end generated code: output=32784678e77ac658 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=172a9af0316afc14 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/atexitmodule.c.h b/Modules/clinic/atexitmodule.c.h new file mode 100644 index 000000000000000..8297f03c0276b59 --- /dev/null +++ b/Modules/clinic/atexitmodule.c.h @@ -0,0 +1,53 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#include "pycore_modsupport.h" // _PyArg_CheckPositional() + +PyDoc_STRVAR(atexit_register__doc__, +"register($module, func, /, *args, **kwargs)\n" +"--\n" +"\n" +"Register a function to be executed upon normal program termination\n" +"\n" +" func - function to be called at exit\n" +" args - optional arguments to pass to func\n" +" kwargs - optional keyword arguments to pass to func\n" +"\n" +" func is returned to facilitate usage as a decorator."); + +#define ATEXIT_REGISTER_METHODDEF \ + {"register", _PyCFunction_CAST(atexit_register), METH_VARARGS|METH_KEYWORDS, atexit_register__doc__}, + +static PyObject * +atexit_register_impl(PyObject *module, PyObject *func, PyObject *args, + PyObject *kwargs); + +static PyObject * +atexit_register(PyObject *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *func; + PyObject *__clinic_args = NULL; + PyObject *__clinic_kwargs = NULL; + + if (!_PyArg_CheckPositional("register", PyTuple_GET_SIZE(args), 1, PY_SSIZE_T_MAX)) { + goto exit; + } + func = PyTuple_GET_ITEM(args, 0); + __clinic_args = PyTuple_GetSlice(args, 1, PY_SSIZE_T_MAX); + if (!__clinic_args) { + goto exit; + } + __clinic_kwargs = Py_XNewRef(kwargs); + return_value = atexit_register_impl(module, func, __clinic_args, __clinic_kwargs); + +exit: + /* Cleanup for args */ + Py_XDECREF(__clinic_args); + /* Cleanup for kwargs */ + Py_XDECREF(__clinic_kwargs); + + return return_value; +} +/*[clinic end generated code: output=ab4b375d516aa59b input=a9049054013a1b77]*/ diff --git a/Modules/clinic/binascii.c.h b/Modules/clinic/binascii.c.h index 29fa9e87de87c7a..0c5e35b1516da21 100644 --- a/Modules/clinic/binascii.c.h +++ b/Modules/clinic/binascii.c.h @@ -1513,16 +1513,20 @@ binascii_unhexlify(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py } PyDoc_STRVAR(binascii_a2b_qp__doc__, -"a2b_qp($module, /, data, header=False)\n" +"a2b_qp($module, /, data, header=False, *, strip_ws=False)\n" "--\n" "\n" -"Decode a string of qp-encoded data."); +"Decode a string of qp-encoded data.\n" +"\n" +"If strip_ws is true, whitespace at the end of a line is stripped, as\n" +"required by RFC 2045 when decoding a quoted-printable body."); #define BINASCII_A2B_QP_METHODDEF \ {"a2b_qp", _PyCFunction_CAST(binascii_a2b_qp), METH_FASTCALL|METH_KEYWORDS, binascii_a2b_qp__doc__}, static PyObject * -binascii_a2b_qp_impl(PyObject *module, Py_buffer *data, int header); +binascii_a2b_qp_impl(PyObject *module, Py_buffer *data, int header, + int strip_ws); static PyObject * binascii_a2b_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) @@ -1530,7 +1534,7 @@ binascii_a2b_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - #define NUM_KEYWORDS 2 + #define NUM_KEYWORDS 3 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD @@ -1539,7 +1543,7 @@ binascii_a2b_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj } _kwtuple = { .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) .ob_hash = -1, - .ob_item = { &_Py_ID(data), &_Py_ID(header), }, + .ob_item = { &_Py_ID(data), &_Py_ID(header), &_Py_ID(strip_ws), }, }; #undef NUM_KEYWORDS #define KWTUPLE (&_kwtuple.ob_base.ob_base) @@ -1548,17 +1552,18 @@ binascii_a2b_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj # define KWTUPLE NULL #endif // !Py_BUILD_CORE - static const char * const _keywords[] = {"data", "header", NULL}; + static const char * const _keywords[] = {"data", "header", "strip_ws", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, .fname = "a2b_qp", .kwtuple = KWTUPLE, }; #undef KWTUPLE - PyObject *argsbuf[2]; + PyObject *argsbuf[3]; Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; int header = 0; + int strip_ws = 0; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); @@ -1571,12 +1576,25 @@ binascii_a2b_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj if (!noptargs) { goto skip_optional_pos; } - header = PyObject_IsTrue(args[1]); - if (header < 0) { - goto exit; + if (args[1]) { + header = PyObject_IsTrue(args[1]); + if (header < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } } skip_optional_pos: - return_value = binascii_a2b_qp_impl(module, &data, header); + if (!noptargs) { + goto skip_optional_kwonly; + } + strip_ws = PyObject_IsTrue(args[2]); + if (strip_ws < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = binascii_a2b_qp_impl(module, &data, header, strip_ws); exit: /* Cleanup for data */ @@ -1685,4 +1703,4 @@ binascii_b2a_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj return return_value; } -/*[clinic end generated code: output=42dd48f323cbb118 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ec23792754b04657 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/cmathmodule.c.h b/Modules/clinic/cmathmodule.c.h index ecb5257cf6b2408..fe40ece030116bf 100644 --- a/Modules/clinic/cmathmodule.c.h +++ b/Modules/clinic/cmathmodule.c.h @@ -745,7 +745,7 @@ PyDoc_STRVAR(cmath_rect__doc__, #define CMATH_RECT_METHODDEF \ {"rect", _PyCFunction_CAST(cmath_rect), METH_FASTCALL, cmath_rect__doc__}, -static PyObject * +static Py_complex cmath_rect_impl(PyObject *module, double r, double phi); static PyObject * @@ -754,6 +754,7 @@ cmath_rect(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; double r; double phi; + Py_complex _return_value; if (!_PyArg_CheckPositional("rect", nargs, 2, 2)) { goto exit; @@ -778,7 +779,18 @@ cmath_rect(PyObject *module, PyObject *const *args, Py_ssize_t nargs) goto exit; } } - return_value = cmath_rect_impl(module, r, phi); + _return_value = cmath_rect_impl(module, r, phi); + if (errno == EDOM) { + PyErr_SetString(PyExc_ValueError, "math domain error"); + goto exit; + } + else if (errno == ERANGE) { + PyErr_SetString(PyExc_OverflowError, "math range error"); + goto exit; + } + else { + return_value = PyComplex_FromCComplex(_return_value); + } exit: return return_value; @@ -987,4 +999,4 @@ cmath_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec exit: return return_value; } -/*[clinic end generated code: output=7d5ad4cf258526cd input=a9049054013a1b77]*/ +/*[clinic end generated code: output=89513888cb105a65 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/gcmodule.c.h b/Modules/clinic/gcmodule.c.h index aa743c8f40a565f..0ec615c61cbb2f6 100644 --- a/Modules/clinic/gcmodule.c.h +++ b/Modules/clinic/gcmodule.c.h @@ -224,14 +224,14 @@ PyDoc_STRVAR(gc_set_threshold__doc__, "Setting \'threshold0\' to zero disables collection."); #define GC_SET_THRESHOLD_METHODDEF \ - {"set_threshold", (PyCFunction)gc_set_threshold, METH_VARARGS, gc_set_threshold__doc__}, + {"set_threshold", _PyCFunction_CAST(gc_set_threshold), METH_FASTCALL, gc_set_threshold__doc__}, static PyObject * gc_set_threshold_impl(PyObject *module, int threshold0, int group_right_1, int threshold1, int group_right_2, int threshold2); static PyObject * -gc_set_threshold(PyObject *module, PyObject *args) +gc_set_threshold(PyObject *module, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int threshold0; @@ -240,28 +240,27 @@ gc_set_threshold(PyObject *module, PyObject *args) int group_right_2 = 0; int threshold2 = 0; - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "i:set_threshold", &threshold0)) { - goto exit; - } - break; - case 2: - if (!PyArg_ParseTuple(args, "ii:set_threshold", &threshold0, &threshold1)) { - goto exit; - } - group_right_1 = 1; - break; - case 3: - if (!PyArg_ParseTuple(args, "iii:set_threshold", &threshold0, &threshold1, &threshold2)) { - goto exit; - } - group_right_1 = 1; - group_right_2 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "gc.set_threshold requires 1 to 3 arguments"); + if (nargs < 1 || nargs > 3) { + PyErr_SetString(PyExc_TypeError, "gc.set_threshold requires 1 to 3 arguments"); + goto exit; + } + threshold0 = PyLong_AsInt(args[0]); + if (threshold0 == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs >= 2) { + threshold1 = PyLong_AsInt(args[1]); + if (threshold1 == -1 && PyErr_Occurred()) { + goto exit; + } + group_right_1 = 1; + } + if (nargs >= 3) { + threshold2 = PyLong_AsInt(args[2]); + if (threshold2 == -1 && PyErr_Occurred()) { goto exit; + } + group_right_2 = 1; } return_value = gc_set_threshold_impl(module, threshold0, group_right_1, threshold1, group_right_2, threshold2); @@ -584,4 +583,4 @@ gc_get_freeze_count(PyObject *module, PyObject *Py_UNUSED(ignored)) exit: return return_value; } -/*[clinic end generated code: output=756c0e7719b76971 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d0cb000f41ffe433 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/getpath.c.h b/Modules/clinic/getpath.c.h new file mode 100644 index 000000000000000..54ab0240e4482c5 --- /dev/null +++ b/Modules/clinic/getpath.c.h @@ -0,0 +1,380 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#include "pycore_modsupport.h" // _PyArg_BadArgument() + +PyDoc_STRVAR(getpath_abspath__doc__, +"abspath($module, path, /)\n" +"--\n" +"\n" +"Return the absolute path."); + +#define GETPATH_ABSPATH_METHODDEF \ + {"abspath", (PyCFunction)getpath_abspath, METH_O, getpath_abspath__doc__}, + +static PyObject * +getpath_abspath_impl(PyObject *module, const wchar_t *path); + +static PyObject * +getpath_abspath(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + const wchar_t *path = NULL; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("abspath", "argument", "str", arg); + goto exit; + } + path = PyUnicode_AsWideCharString(arg, NULL); + if (path == NULL) { + goto exit; + } + return_value = getpath_abspath_impl(module, path); + +exit: + /* Cleanup for path */ + PyMem_Free((void *)path); + + return return_value; +} + +PyDoc_STRVAR(getpath_basename__doc__, +"basename($module, path, /)\n" +"--\n" +"\n" +"Return the final component of the path."); + +#define GETPATH_BASENAME_METHODDEF \ + {"basename", (PyCFunction)getpath_basename, METH_O, getpath_basename__doc__}, + +static PyObject * +getpath_basename_impl(PyObject *module, PyObject *path); + +static PyObject * +getpath_basename(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + PyObject *path; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("basename", "argument", "str", arg); + goto exit; + } + path = arg; + return_value = getpath_basename_impl(module, path); + +exit: + return return_value; +} + +PyDoc_STRVAR(getpath_dirname__doc__, +"dirname($module, path, /)\n" +"--\n" +"\n" +"Return the directory component of the path."); + +#define GETPATH_DIRNAME_METHODDEF \ + {"dirname", (PyCFunction)getpath_dirname, METH_O, getpath_dirname__doc__}, + +static PyObject * +getpath_dirname_impl(PyObject *module, PyObject *path); + +static PyObject * +getpath_dirname(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + PyObject *path; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("dirname", "argument", "str", arg); + goto exit; + } + path = arg; + return_value = getpath_dirname_impl(module, path); + +exit: + return return_value; +} + +PyDoc_STRVAR(getpath_isabs__doc__, +"isabs($module, path, /)\n" +"--\n" +"\n" +"Return True if the path is absolute."); + +#define GETPATH_ISABS_METHODDEF \ + {"isabs", (PyCFunction)getpath_isabs, METH_O, getpath_isabs__doc__}, + +static int +getpath_isabs_impl(PyObject *module, const wchar_t *path); + +static PyObject * +getpath_isabs(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + const wchar_t *path = NULL; + int _return_value; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("isabs", "argument", "str", arg); + goto exit; + } + path = PyUnicode_AsWideCharString(arg, NULL); + if (path == NULL) { + goto exit; + } + _return_value = getpath_isabs_impl(module, path); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); + +exit: + /* Cleanup for path */ + PyMem_Free((void *)path); + + return return_value; +} + +PyDoc_STRVAR(getpath_hassuffix__doc__, +"hassuffix($module, path, suffix, /)\n" +"--\n" +"\n" +"Return True if the path ends with the suffix, ignoring the case."); + +#define GETPATH_HASSUFFIX_METHODDEF \ + {"hassuffix", _PyCFunction_CAST(getpath_hassuffix), METH_FASTCALL, getpath_hassuffix__doc__}, + +static int +getpath_hassuffix_impl(PyObject *module, PyObject *pathobj, + PyObject *suffixobj); + +static PyObject * +getpath_hassuffix(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *pathobj; + PyObject *suffixobj; + int _return_value; + + if (!_PyArg_CheckPositional("hassuffix", nargs, 2, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("hassuffix", "argument 1", "str", args[0]); + goto exit; + } + pathobj = args[0]; + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("hassuffix", "argument 2", "str", args[1]); + goto exit; + } + suffixobj = args[1]; + _return_value = getpath_hassuffix_impl(module, pathobj, suffixobj); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(getpath_isdir__doc__, +"isdir($module, path, /)\n" +"--\n" +"\n" +"Return True if the path is a directory."); + +#define GETPATH_ISDIR_METHODDEF \ + {"isdir", (PyCFunction)getpath_isdir, METH_O, getpath_isdir__doc__}, + +static int +getpath_isdir_impl(PyObject *module, const wchar_t *path); + +static PyObject * +getpath_isdir(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + const wchar_t *path = NULL; + int _return_value; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("isdir", "argument", "str", arg); + goto exit; + } + path = PyUnicode_AsWideCharString(arg, NULL); + if (path == NULL) { + goto exit; + } + _return_value = getpath_isdir_impl(module, path); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); + +exit: + /* Cleanup for path */ + PyMem_Free((void *)path); + + return return_value; +} + +PyDoc_STRVAR(getpath_isfile__doc__, +"isfile($module, path, /)\n" +"--\n" +"\n" +"Return True if the path is a regular file."); + +#define GETPATH_ISFILE_METHODDEF \ + {"isfile", (PyCFunction)getpath_isfile, METH_O, getpath_isfile__doc__}, + +static int +getpath_isfile_impl(PyObject *module, PyObject *pathobj); + +static PyObject * +getpath_isfile(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + PyObject *pathobj; + int _return_value; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("isfile", "argument", "str", arg); + goto exit; + } + pathobj = arg; + _return_value = getpath_isfile_impl(module, pathobj); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(getpath_isxfile__doc__, +"isxfile($module, path, /)\n" +"--\n" +"\n" +"Return True if the path is an executable file."); + +#define GETPATH_ISXFILE_METHODDEF \ + {"isxfile", (PyCFunction)getpath_isxfile, METH_O, getpath_isxfile__doc__}, + +static int +getpath_isxfile_impl(PyObject *module, PyObject *pathobj); + +static PyObject * +getpath_isxfile(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + PyObject *pathobj; + int _return_value; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("isxfile", "argument", "str", arg); + goto exit; + } + pathobj = arg; + _return_value = getpath_isxfile_impl(module, pathobj); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(getpath_joinpath__doc__, +"joinpath($module, /, *args)\n" +"--\n" +"\n" +"Join the path components."); + +#define GETPATH_JOINPATH_METHODDEF \ + {"joinpath", _PyCFunction_CAST(getpath_joinpath), METH_FASTCALL, getpath_joinpath__doc__}, + +static PyObject * +getpath_joinpath_impl(PyObject *module, PyObject *args); + +static PyObject * +getpath_joinpath(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *__clinic_args = NULL; + + __clinic_args = PyTuple_FromArray(args, nargs); + if (__clinic_args == NULL) { + goto exit; + } + return_value = getpath_joinpath_impl(module, __clinic_args); + +exit: + /* Cleanup for args */ + Py_XDECREF(__clinic_args); + + return return_value; +} + +PyDoc_STRVAR(getpath_readlines__doc__, +"readlines($module, path, /)\n" +"--\n" +"\n" +"Return the lines of the file."); + +#define GETPATH_READLINES_METHODDEF \ + {"readlines", (PyCFunction)getpath_readlines, METH_O, getpath_readlines__doc__}, + +static PyObject * +getpath_readlines_impl(PyObject *module, PyObject *pathobj); + +static PyObject * +getpath_readlines(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + PyObject *pathobj; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("readlines", "argument", "str", arg); + goto exit; + } + pathobj = arg; + return_value = getpath_readlines_impl(module, pathobj); + +exit: + return return_value; +} + +PyDoc_STRVAR(getpath_realpath__doc__, +"realpath($module, path, /)\n" +"--\n" +"\n" +"Resolve a symlinked file."); + +#define GETPATH_REALPATH_METHODDEF \ + {"realpath", (PyCFunction)getpath_realpath, METH_O, getpath_realpath__doc__}, + +static PyObject * +getpath_realpath_impl(PyObject *module, PyObject *pathobj); + +static PyObject * +getpath_realpath(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + PyObject *pathobj; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("realpath", "argument", "str", arg); + goto exit; + } + pathobj = arg; + return_value = getpath_realpath_impl(module, pathobj); + +exit: + return return_value; +} +/*[clinic end generated code: output=74266cdd2d87e28d input=a9049054013a1b77]*/ diff --git a/Modules/clinic/grpmodule.c.h b/Modules/clinic/grpmodule.c.h index 665c2f2dfdac148..9f1ea181d9bc4ca 100644 --- a/Modules/clinic/grpmodule.c.h +++ b/Modules/clinic/grpmodule.c.h @@ -20,7 +20,7 @@ PyDoc_STRVAR(grp_getgrgid__doc__, {"getgrgid", _PyCFunction_CAST(grp_getgrgid), METH_FASTCALL|METH_KEYWORDS, grp_getgrgid__doc__}, static PyObject * -grp_getgrgid_impl(PyObject *module, PyObject *id); +grp_getgrgid_impl(PyObject *module, gid_t gid); static PyObject * grp_getgrgid(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) @@ -54,15 +54,17 @@ grp_getgrgid(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject }; #undef KWTUPLE PyObject *argsbuf[1]; - PyObject *id; + gid_t gid; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!args) { goto exit; } - id = args[0]; - return_value = grp_getgrgid_impl(module, id); + if (!_Py_Gid_Converter(args[0], &gid)) { + goto exit; + } + return_value = grp_getgrgid_impl(module, gid); exit: return return_value; @@ -152,4 +154,4 @@ grp_getgrall(PyObject *module, PyObject *Py_UNUSED(ignored)) { return grp_getgrall_impl(module); } -/*[clinic end generated code: output=35aa81c00dbd3229 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=9052db62d986262c input=a9049054013a1b77]*/ diff --git a/Modules/clinic/hmacmodule.c.h b/Modules/clinic/hmacmodule.c.h index a31d2ab7f04463c..bdff9c4bf8c1df6 100644 --- a/Modules/clinic/hmacmodule.c.h +++ b/Modules/clinic/hmacmodule.c.h @@ -204,16 +204,6 @@ _hmac_HMAC_hexdigest(PyObject *self, PyObject *Py_UNUSED(ignored)) return _hmac_HMAC_hexdigest_impl((HMACObject *)self); } -#if !defined(_hmac_HMAC_name_DOCSTR) -# define _hmac_HMAC_name_DOCSTR NULL -#endif -#if defined(_HMAC_HMAC_NAME_GETSETDEF) -# undef _HMAC_HMAC_NAME_GETSETDEF -# define _HMAC_HMAC_NAME_GETSETDEF {"name", (getter)_hmac_HMAC_name_get, (setter)_hmac_HMAC_name_set, _hmac_HMAC_name_DOCSTR}, -#else -# define _HMAC_HMAC_NAME_GETSETDEF {"name", (getter)_hmac_HMAC_name_get, NULL, _hmac_HMAC_name_DOCSTR}, -#endif - static PyObject * _hmac_HMAC_name_get_impl(HMACObject *self); @@ -223,16 +213,6 @@ _hmac_HMAC_name_get(PyObject *self, void *Py_UNUSED(context)) return _hmac_HMAC_name_get_impl((HMACObject *)self); } -#if !defined(_hmac_HMAC_block_size_DOCSTR) -# define _hmac_HMAC_block_size_DOCSTR NULL -#endif -#if defined(_HMAC_HMAC_BLOCK_SIZE_GETSETDEF) -# undef _HMAC_HMAC_BLOCK_SIZE_GETSETDEF -# define _HMAC_HMAC_BLOCK_SIZE_GETSETDEF {"block_size", (getter)_hmac_HMAC_block_size_get, (setter)_hmac_HMAC_block_size_set, _hmac_HMAC_block_size_DOCSTR}, -#else -# define _HMAC_HMAC_BLOCK_SIZE_GETSETDEF {"block_size", (getter)_hmac_HMAC_block_size_get, NULL, _hmac_HMAC_block_size_DOCSTR}, -#endif - static PyObject * _hmac_HMAC_block_size_get_impl(HMACObject *self); @@ -242,16 +222,6 @@ _hmac_HMAC_block_size_get(PyObject *self, void *Py_UNUSED(context)) return _hmac_HMAC_block_size_get_impl((HMACObject *)self); } -#if !defined(_hmac_HMAC_digest_size_DOCSTR) -# define _hmac_HMAC_digest_size_DOCSTR NULL -#endif -#if defined(_HMAC_HMAC_DIGEST_SIZE_GETSETDEF) -# undef _HMAC_HMAC_DIGEST_SIZE_GETSETDEF -# define _HMAC_HMAC_DIGEST_SIZE_GETSETDEF {"digest_size", (getter)_hmac_HMAC_digest_size_get, (setter)_hmac_HMAC_digest_size_set, _hmac_HMAC_digest_size_DOCSTR}, -#else -# define _HMAC_HMAC_DIGEST_SIZE_GETSETDEF {"digest_size", (getter)_hmac_HMAC_digest_size_get, NULL, _hmac_HMAC_digest_size_DOCSTR}, -#endif - static PyObject * _hmac_HMAC_digest_size_get_impl(HMACObject *self); @@ -670,4 +640,10 @@ _hmac_compute_blake2b_32(PyObject *module, PyObject *const *args, Py_ssize_t nar exit: return return_value; } -/*[clinic end generated code: output=6ec5948df1c5569a input=a9049054013a1b77]*/ +#define _HMAC_HMAC_NAME_GETSETDEF {"name", (getter)_hmac_HMAC_name_get, (setter)NULL, NULL}, + +#define _HMAC_HMAC_BLOCK_SIZE_GETSETDEF {"block_size", (getter)_hmac_HMAC_block_size_get, (setter)NULL, NULL}, + +#define _HMAC_HMAC_DIGEST_SIZE_GETSETDEF {"digest_size", (getter)_hmac_HMAC_digest_size_get, (setter)NULL, NULL}, + +/*[clinic end generated code: output=f63101faf6ff6bac input=a9049054013a1b77]*/ diff --git a/Modules/clinic/itertoolsmodule.c.h b/Modules/clinic/itertoolsmodule.c.h index d9917b47dc90376..3fd1b7a2fc7b907 100644 --- a/Modules/clinic/itertoolsmodule.c.h +++ b/Modules/clinic/itertoolsmodule.c.h @@ -7,6 +7,7 @@ preserve # include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_abstract.h" // _PyNumber_Index() +#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() PyDoc_STRVAR(batched_new__doc__, @@ -35,7 +36,8 @@ batched_new_impl(PyTypeObject *type, PyObject *iterable, Py_ssize_t n, int strict); static PyObject * -batched_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +batched_new_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -67,13 +69,12 @@ batched_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[3]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2; + Py_ssize_t noptargs = nargs + nkw - 2; PyObject *iterable; Py_ssize_t n; int strict = 0; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -105,6 +106,30 @@ batched_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +batched_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return batched_new_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +batched_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + + assert(_PyType_CAST(type)->tp_new == batched_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + return batched_new_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); +} + PyDoc_STRVAR(pairwise_new__doc__, "pairwise(iterable, /)\n" "--\n" @@ -137,6 +162,31 @@ pairwise_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +pairwise_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *iterable; + + assert(_PyType_CAST(type)->tp_new == pairwise_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("pairwise", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("pairwise", nargs, 1, 1)) { + goto exit; + } + iterable = args[0]; + return_value = pairwise_new_impl(_PyType_CAST(type), iterable); + +exit: + return return_value; +} + PyDoc_STRVAR(itertools_groupby__doc__, "groupby(iterable, key=None)\n" "--\n" @@ -154,7 +204,8 @@ static PyObject * itertools_groupby_impl(PyTypeObject *type, PyObject *it, PyObject *keyfunc); static PyObject * -itertools_groupby(PyTypeObject *type, PyObject *args, PyObject *kwargs) +itertools_groupby_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -186,12 +237,11 @@ itertools_groupby(PyTypeObject *type, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[2]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + Py_ssize_t noptargs = nargs + nkw - 1; PyObject *it; PyObject *keyfunc = Py_None; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -208,6 +258,44 @@ itertools_groupby(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +itertools_groupby(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return itertools_groupby_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +itertools_groupby_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *it; + PyObject *keyfunc = Py_None; + + assert(_PyType_CAST(type)->tp_new == itertools_groupby); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs < 1 || nargs > 2) { + return itertools_groupby_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + it = args[0]; + if (nargs < 2) { + goto skip_optional; + } + keyfunc = args[1]; +skip_optional: + return_value = itertools_groupby_impl(_PyType_CAST(type), it, keyfunc); + + return return_value; +} + static PyObject * itertools__grouper_impl(PyTypeObject *type, PyObject *parent, PyObject *tgtkey); @@ -278,6 +366,39 @@ itertools_teedataobject(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +itertools_teedataobject_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *it; + PyObject *values; + PyObject *next; + + assert(_PyType_CAST(type)->tp_new == itertools_teedataobject); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("teedataobject", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("teedataobject", nargs, 3, 3)) { + goto exit; + } + it = args[0]; + if (!PyList_Check(args[1])) { + _PyArg_BadArgument("teedataobject", "argument 2", "list", args[1]); + goto exit; + } + values = args[1]; + next = args[2]; + return_value = itertools_teedataobject_impl(_PyType_CAST(type), it, values, next); + +exit: + return return_value; +} + PyDoc_STRVAR(itertools__tee__doc__, "_tee(iterable, /)\n" "--\n" @@ -388,6 +509,31 @@ itertools_cycle(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +itertools_cycle_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *iterable; + + assert(_PyType_CAST(type)->tp_new == itertools_cycle); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("cycle", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("cycle", nargs, 1, 1)) { + goto exit; + } + iterable = args[0]; + return_value = itertools_cycle_impl(_PyType_CAST(type), iterable); + +exit: + return return_value; +} + PyDoc_STRVAR(itertools_dropwhile__doc__, "dropwhile(predicate, iterable, /)\n" "--\n" @@ -422,6 +568,33 @@ itertools_dropwhile(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +itertools_dropwhile_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *func; + PyObject *seq; + + assert(_PyType_CAST(type)->tp_new == itertools_dropwhile); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("dropwhile", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("dropwhile", nargs, 2, 2)) { + goto exit; + } + func = args[0]; + seq = args[1]; + return_value = itertools_dropwhile_impl(_PyType_CAST(type), func, seq); + +exit: + return return_value; +} + PyDoc_STRVAR(itertools_takewhile__doc__, "takewhile(predicate, iterable, /)\n" "--\n" @@ -454,6 +627,33 @@ itertools_takewhile(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +itertools_takewhile_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *func; + PyObject *seq; + + assert(_PyType_CAST(type)->tp_new == itertools_takewhile); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("takewhile", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("takewhile", nargs, 2, 2)) { + goto exit; + } + func = args[0]; + seq = args[1]; + return_value = itertools_takewhile_impl(_PyType_CAST(type), func, seq); + +exit: + return return_value; +} + PyDoc_STRVAR(itertools_starmap__doc__, "starmap(function, iterable, /)\n" "--\n" @@ -486,6 +686,33 @@ itertools_starmap(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +itertools_starmap_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *func; + PyObject *seq; + + assert(_PyType_CAST(type)->tp_new == itertools_starmap); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("starmap", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("starmap", nargs, 2, 2)) { + goto exit; + } + func = args[0]; + seq = args[1]; + return_value = itertools_starmap_impl(_PyType_CAST(type), func, seq); + +exit: + return return_value; +} + PyDoc_STRVAR(itertools_chain_from_iterable__doc__, "from_iterable($type, iterable, /)\n" "--\n" @@ -508,6 +735,36 @@ itertools_chain_from_iterable(PyObject *type, PyObject *arg) return return_value; } +static PyObject * +chain_next_impl(chainobject *self); + +static PyObject * +chain_next(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = chain_next_impl((chainobject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static PyObject * +product_next_impl(productobject *self); + +static PyObject * +product_next(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = product_next_impl((productobject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(itertools_combinations__doc__, "combinations(iterable, r)\n" "--\n" @@ -521,7 +778,8 @@ itertools_combinations_impl(PyTypeObject *type, PyObject *iterable, Py_ssize_t r); static PyObject * -itertools_combinations(PyTypeObject *type, PyObject *args, PyObject *kwargs) +itertools_combinations_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -553,11 +811,10 @@ itertools_combinations(PyTypeObject *type, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[2]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *iterable; Py_ssize_t r; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -586,6 +843,72 @@ itertools_combinations(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +itertools_combinations(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return itertools_combinations_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +itertools_combinations_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *iterable; + Py_ssize_t r; + + assert(_PyType_CAST(type)->tp_new == itertools_combinations); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs < 2 || nargs > 2) { + return itertools_combinations_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + iterable = args[0]; + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + r = ival; + if (r < 0) { + PyErr_SetString(PyExc_ValueError, + "r cannot be negative"); + goto exit; + } + } + return_value = itertools_combinations_impl(_PyType_CAST(type), iterable, r); + +exit: + return return_value; +} + +static PyObject * +combinations_next_impl(combinationsobject *self); + +static PyObject * +combinations_next(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = combinations_next_impl((combinationsobject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(itertools_combinations_with_replacement__doc__, "combinations_with_replacement(iterable, r)\n" "--\n" @@ -600,7 +923,8 @@ itertools_combinations_with_replacement_impl(PyTypeObject *type, Py_ssize_t r); static PyObject * -itertools_combinations_with_replacement(PyTypeObject *type, PyObject *args, PyObject *kwargs) +itertools_combinations_with_replacement_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -632,11 +956,10 @@ itertools_combinations_with_replacement(PyTypeObject *type, PyObject *args, PyOb #undef KWTUPLE PyObject *argsbuf[2]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *iterable; Py_ssize_t r; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -665,6 +988,72 @@ itertools_combinations_with_replacement(PyTypeObject *type, PyObject *args, PyOb return return_value; } +static PyObject * +itertools_combinations_with_replacement(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return itertools_combinations_with_replacement_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +itertools_combinations_with_replacement_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *iterable; + Py_ssize_t r; + + assert(_PyType_CAST(type)->tp_new == itertools_combinations_with_replacement); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs < 2 || nargs > 2) { + return itertools_combinations_with_replacement_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + iterable = args[0]; + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + r = ival; + if (r < 0) { + PyErr_SetString(PyExc_ValueError, + "r cannot be negative"); + goto exit; + } + } + return_value = itertools_combinations_with_replacement_impl(_PyType_CAST(type), iterable, r); + +exit: + return return_value; +} + +static PyObject * +cwr_next_impl(cwrobject *self); + +static PyObject * +cwr_next(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = cwr_next_impl((cwrobject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(itertools_permutations__doc__, "permutations(iterable, r=None)\n" "--\n" @@ -678,7 +1067,8 @@ itertools_permutations_impl(PyTypeObject *type, PyObject *iterable, PyObject *robj); static PyObject * -itertools_permutations(PyTypeObject *type, PyObject *args, PyObject *kwargs) +itertools_permutations_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -710,12 +1100,11 @@ itertools_permutations(PyTypeObject *type, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[2]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + Py_ssize_t noptargs = nargs + nkw - 1; PyObject *iterable; PyObject *robj = Py_None; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -732,6 +1121,59 @@ itertools_permutations(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +itertools_permutations(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return itertools_permutations_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +itertools_permutations_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *iterable; + PyObject *robj = Py_None; + + assert(_PyType_CAST(type)->tp_new == itertools_permutations); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs < 1 || nargs > 2) { + return itertools_permutations_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + iterable = args[0]; + if (nargs < 2) { + goto skip_optional; + } + robj = args[1]; +skip_optional: + return_value = itertools_permutations_impl(_PyType_CAST(type), iterable, robj); + + return return_value; +} + +static PyObject * +permutations_next_impl(permutationsobject *self); + +static PyObject * +permutations_next(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = permutations_next_impl((permutationsobject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(itertools_accumulate__doc__, "accumulate(iterable, func=None, *, initial=None)\n" "--\n" @@ -743,7 +1185,8 @@ itertools_accumulate_impl(PyTypeObject *type, PyObject *iterable, PyObject *binop, PyObject *initial); static PyObject * -itertools_accumulate(PyTypeObject *type, PyObject *args, PyObject *kwargs) +itertools_accumulate_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -775,13 +1218,12 @@ itertools_accumulate(PyTypeObject *type, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[3]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + Py_ssize_t noptargs = nargs + nkw - 1; PyObject *iterable; PyObject *binop = Py_None; PyObject *initial = Py_None; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -808,6 +1250,45 @@ itertools_accumulate(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +itertools_accumulate(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return itertools_accumulate_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +itertools_accumulate_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + + assert(_PyType_CAST(type)->tp_new == itertools_accumulate); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + return itertools_accumulate_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); +} + +static PyObject * +accumulate_next_impl(accumulateobject *self); + +static PyObject * +accumulate_next(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = accumulate_next_impl((accumulateobject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(itertools_compress__doc__, "compress(data, selectors)\n" "--\n" @@ -821,7 +1302,8 @@ static PyObject * itertools_compress_impl(PyTypeObject *type, PyObject *seq1, PyObject *seq2); static PyObject * -itertools_compress(PyTypeObject *type, PyObject *args, PyObject *kwargs) +itertools_compress_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -853,11 +1335,10 @@ itertools_compress(PyTypeObject *type, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[2]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *seq1; PyObject *seq2; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -870,6 +1351,40 @@ itertools_compress(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +itertools_compress(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return itertools_compress_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +itertools_compress_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *seq1; + PyObject *seq2; + + assert(_PyType_CAST(type)->tp_new == itertools_compress); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs < 2 || nargs > 2) { + return itertools_compress_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + seq1 = args[0]; + seq2 = args[1]; + return_value = itertools_compress_impl(_PyType_CAST(type), seq1, seq2); + + return return_value; +} + PyDoc_STRVAR(itertools_filterfalse__doc__, "filterfalse(function, iterable, /)\n" "--\n" @@ -904,6 +1419,33 @@ itertools_filterfalse(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +itertools_filterfalse_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *func; + PyObject *seq; + + assert(_PyType_CAST(type)->tp_new == itertools_filterfalse); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("filterfalse", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("filterfalse", nargs, 2, 2)) { + goto exit; + } + func = args[0]; + seq = args[1]; + return_value = itertools_filterfalse_impl(_PyType_CAST(type), func, seq); + +exit: + return return_value; +} + PyDoc_STRVAR(itertools_count__doc__, "count(start=0, step=1)\n" "--\n" @@ -922,7 +1464,8 @@ itertools_count_impl(PyTypeObject *type, PyObject *long_cnt, PyObject *long_step); static PyObject * -itertools_count(PyTypeObject *type, PyObject *args, PyObject *kwargs) +itertools_count_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -954,12 +1497,11 @@ itertools_count(PyTypeObject *type, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[2]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; + Py_ssize_t noptargs = nargs + nkw - 0; PyObject *long_cnt = NULL; PyObject *long_step = NULL; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 0, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -980,4 +1522,60 @@ itertools_count(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=a34a31f60100e0ff input=a9049054013a1b77]*/ + +static PyObject * +itertools_count(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return itertools_count_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +itertools_count_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *long_cnt = NULL; + PyObject *long_step = NULL; + + assert(_PyType_CAST(type)->tp_new == itertools_count); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs > 2) { + return itertools_count_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + if (nargs < 1) { + goto skip_optional; + } + long_cnt = args[0]; + if (nargs < 2) { + goto skip_optional; + } + long_step = args[1]; +skip_optional: + return_value = itertools_count_impl(_PyType_CAST(type), long_cnt, long_step); + + return return_value; +} + +static PyObject * +zip_longest_next_impl(ziplongestobject *self); + +static PyObject * +zip_longest_next(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = zip_longest_next_impl((ziplongestobject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} +/*[clinic end generated code: output=60939958c9c9348b input=a9049054013a1b77]*/ diff --git a/Modules/clinic/mmapmodule.c.h b/Modules/clinic/mmapmodule.c.h index 98c5bf6a2fb1462..ece08c0fb6007c0 100644 --- a/Modules/clinic/mmapmodule.c.h +++ b/Modules/clinic/mmapmodule.c.h @@ -9,6 +9,7 @@ preserve #include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(mmap_mmap_close__doc__, "close($self, /)\n" @@ -547,15 +548,10 @@ mmap_mmap_set_name(PyObject *self, PyObject *arg) _PyArg_BadArgument("set_name", "argument", "str", arg); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(arg, &name_length); + name = _PyUnicode_AsUTF8NoNUL(arg); if (name == NULL) { goto exit; } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } Py_BEGIN_CRITICAL_SECTION(self); return_value = mmap_mmap_set_name_impl((mmap_object *)self, name); Py_END_CRITICAL_SECTION(); @@ -705,6 +701,21 @@ mmap_mmap___exit__(PyObject *self, PyObject *const *args, Py_ssize_t nargs) return return_value; } +static PyObject * +mmap__repr__method_impl(PyObject *op); + +static PyObject * +mmap__repr__method(PyObject *op) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(op); + return_value = mmap__repr__method_impl(op); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + #if defined(MS_WINDOWS) PyDoc_STRVAR(mmap_mmap___sizeof____doc__, @@ -866,6 +877,81 @@ mmap_mmap_madvise(PyObject *self, PyObject *const *args, Py_ssize_t nargs) #endif /* defined(HAVE_MADVISE) */ +static Py_ssize_t +mmap_length_impl(mmap_object *self); + +static Py_ssize_t +mmap_length(PyObject *self) +{ + Py_ssize_t return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = mmap_length_impl((mmap_object *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static PyObject * +mmap_item_impl(mmap_object *self, Py_ssize_t i); + +static PyObject * +mmap_item(PyObject *self, Py_ssize_t i) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = mmap_item_impl((mmap_object *)self, i); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static PyObject * +mmap_subscript_impl(mmap_object *self, PyObject *item); + +static PyObject * +mmap_subscript(PyObject *self, PyObject *item) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = mmap_subscript_impl((mmap_object *)self, item); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static int +mmap_ass_item_impl(mmap_object *self, Py_ssize_t i, PyObject *v); + +static int +mmap_ass_item(PyObject *self, Py_ssize_t i, PyObject *v) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = mmap_ass_item_impl((mmap_object *)self, i, v); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static int +mmap_ass_subscript_impl(mmap_object *self, PyObject *item, PyObject *value); + +static int +mmap_ass_subscript(PyObject *self, PyObject *item, PyObject *value) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = mmap_ass_subscript_impl((mmap_object *)self, item, value); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + #ifndef MMAP_MMAP_RESIZE_METHODDEF #define MMAP_MMAP_RESIZE_METHODDEF #endif /* !defined(MMAP_MMAP_RESIZE_METHODDEF) */ @@ -881,4 +967,4 @@ mmap_mmap_madvise(PyObject *self, PyObject *const *args, Py_ssize_t nargs) #ifndef MMAP_MMAP_MADVISE_METHODDEF #define MMAP_MMAP_MADVISE_METHODDEF #endif /* !defined(MMAP_MMAP_MADVISE_METHODDEF) */ -/*[clinic end generated code: output=1122b93314aebc5c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=90a906cde591ab92 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h index 1f7e414b2dfe48f..c2f183f70378367 100644 --- a/Modules/clinic/posixmodule.c.h +++ b/Modules/clinic/posixmodule.c.h @@ -7,8 +7,10 @@ preserve # include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_abstract.h" // _PyNumber_Index() +#include "pycore_fileutils.h" // _Py_Off_t_Converter() #include "pycore_long.h" // _PyLong_UnsignedInt_Converter() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(os_stat__doc__, "stat($module, /, path, *, dir_fd=None, follow_symlinks=True)\n" @@ -5320,15 +5322,10 @@ os_getgrouplist(PyObject *module, PyObject *const *args, Py_ssize_t nargs) _PyArg_BadArgument("getgrouplist", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t user_length; - user = PyUnicode_AsUTF8AndSize(args[0], &user_length); + user = _PyUnicode_AsUTF8NoNUL(args[0]); if (user == NULL) { goto exit; } - if (strlen(user) != (size_t)user_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } basegid = PyLong_AsInt(args[1]); if (basegid == -1 && PyErr_Occurred()) { goto exit; @@ -5374,15 +5371,10 @@ os_getgrouplist(PyObject *module, PyObject *const *args, Py_ssize_t nargs) _PyArg_BadArgument("getgrouplist", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t user_length; - user = PyUnicode_AsUTF8AndSize(args[0], &user_length); + user = _PyUnicode_AsUTF8NoNUL(args[0]); if (user == NULL) { goto exit; } - if (strlen(user) != (size_t)user_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!_Py_Gid_Converter(args[1], &basegid)) { goto exit; } @@ -5625,7 +5617,7 @@ PyDoc_STRVAR(os_getppid__doc__, "Return the parent\'s process id.\n" "\n" "If the parent process has already exited, Windows machines will still\n" -"return its id; others systems will return the id of the \'init\' proces\n" +"return its id; other systems will return the id of the \'init\' process\n" "(1)."); #define OS_GETPPID_METHODDEF \ @@ -6330,7 +6322,7 @@ os_wait(PyObject *module, PyObject *Py_UNUSED(ignored)) #endif /* defined(HAVE_WAIT) */ -#if (defined(__linux__) && defined(__NR_pidfd_open) && !(defined(__ANDROID__) && __ANDROID_API__ < 31)) +#if (defined(_Py_HAVE_PIDFD_OPEN) || (defined(__linux__) && defined(__NR_pidfd_open) && !(defined(__ANDROID__) && __ANDROID_API__ < 31))) PyDoc_STRVAR(os_pidfd_open__doc__, "pidfd_open($module, /, pid, flags=0)\n" @@ -6405,9 +6397,9 @@ os_pidfd_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec return return_value; } -#endif /* (defined(__linux__) && defined(__NR_pidfd_open) && !(defined(__ANDROID__) && __ANDROID_API__ < 31)) */ +#endif /* (defined(_Py_HAVE_PIDFD_OPEN) || (defined(__linux__) && defined(__NR_pidfd_open) && !(defined(__ANDROID__) && __ANDROID_API__ < 31))) */ -#if (defined(__linux__) && defined(__NR_pidfd_getfd) && !(defined(__ANDROID__) && __ANDROID_API__ < 31)) +#if (defined(_Py_HAVE_PIDFD_GETFD) || (defined(__linux__) && defined(__NR_pidfd_getfd) && !(defined(__ANDROID__) && __ANDROID_API__ < 31))) PyDoc_STRVAR(os_pidfd_getfd__doc__, "pidfd_getfd($module, /, pidfd, targetfd, *, flags=0)\n" @@ -6492,7 +6484,7 @@ os_pidfd_getfd(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje return return_value; } -#endif /* (defined(__linux__) && defined(__NR_pidfd_getfd) && !(defined(__ANDROID__) && __ANDROID_API__ < 31)) */ +#endif /* (defined(_Py_HAVE_PIDFD_GETFD) || (defined(__linux__) && defined(__NR_pidfd_getfd) && !(defined(__ANDROID__) && __ANDROID_API__ < 31))) */ #if defined(HAVE_SETNS) @@ -6655,7 +6647,10 @@ PyDoc_STRVAR(os_readlink__doc__, "that directory.\n" "\n" "dir_fd may not be implemented on your platform. If it is unavailable,\n" -"using it will raise a NotImplementedError."); +"using it will raise a NotImplementedError.\n" +"\n" +"On Linux, Android, macOS and iOS, path may be a file descriptor\n" +"referring to a symlink. If it is, dir_fd must be None."); #define OS_READLINK_METHODDEF \ {"readlink", _PyCFunction_CAST(os_readlink), METH_FASTCALL|METH_KEYWORDS, os_readlink__doc__}, @@ -6696,7 +6691,7 @@ os_readlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject #undef KWTUPLE PyObject *argsbuf[2]; Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; - path_t path = PATH_T_INITIALIZE_P("readlink", "path", 0, 0, 0, 0); + path_t path = PATH_T_INITIALIZE_P("readlink", "path", 0, 0, 0, 1); int dir_fd = DEFAULT_DIR_FD; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, @@ -7076,9 +7071,9 @@ PyDoc_STRVAR(os_timerfd_settime_ns__doc__, " flags\n" " 0 or a bit mask of TFD_TIMER_ABSTIME or TFD_TIMER_CANCEL_ON_SET.\n" " initial\n" -" initial expiration timing in seconds.\n" +" initial expiration timing in nanoseconds.\n" " interval\n" -" interval for the timer in seconds."); +" interval for the timer in nanoseconds."); #define OS_TIMERFD_SETTIME_NS_METHODDEF \ {"timerfd_settime_ns", _PyCFunction_CAST(os_timerfd_settime_ns), METH_FASTCALL|METH_KEYWORDS, os_timerfd_settime_ns__doc__}, @@ -7174,7 +7169,7 @@ PyDoc_STRVAR(os_timerfd_gettime__doc__, "timerfd_gettime($module, fd, /)\n" "--\n" "\n" -"Return a tuple of a timer file descriptor\'s (interval, next expiration) in float seconds.\n" +"Return a tuple of a timer file descriptor\'s (next expiration, interval) in float seconds.\n" "\n" " fd\n" " A timer file descriptor."); @@ -7209,7 +7204,7 @@ PyDoc_STRVAR(os_timerfd_gettime_ns__doc__, "timerfd_gettime_ns($module, fd, /)\n" "--\n" "\n" -"Return a tuple of a timer file descriptor\'s (interval, next expiration) in nanoseconds.\n" +"Return a tuple of a timer file descriptor\'s (next expiration, interval) in nanoseconds.\n" "\n" " fd\n" " A timer file descriptor."); @@ -7761,7 +7756,7 @@ os_lockf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (command == -1 && PyErr_Occurred()) { goto exit; } - if (!Py_off_t_converter(args[2], &length)) { + if (!_Py_Off_t_Converter(args[2], &length)) { goto exit; } return_value = os_lockf_impl(module, fd, command, length); @@ -7813,7 +7808,7 @@ os_lseek(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (fd == -1 && PyErr_Occurred()) { goto exit; } - if (!Py_off_t_converter(args[1], &position)) { + if (!_Py_Off_t_Converter(args[1], &position)) { goto exit; } how = PyLong_AsInt(args[2]); @@ -8024,7 +8019,7 @@ os_pread(PyObject *module, PyObject *const *args, Py_ssize_t nargs) } length = ival; } - if (!Py_off_t_converter(args[2], &offset)) { + if (!_Py_Off_t_Converter(args[2], &offset)) { goto exit; } return_value = os_pread_impl(module, fd, length, offset); @@ -8084,7 +8079,7 @@ os_preadv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) goto exit; } buffers = args[1]; - if (!Py_off_t_converter(args[2], &offset)) { + if (!_Py_Off_t_Converter(args[2], &offset)) { goto exit; } if (nargs < 4) { @@ -8223,10 +8218,10 @@ os_sendfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject if (in_fd == -1 && PyErr_Occurred()) { goto exit; } - if (!Py_off_t_converter(args[2], &offset)) { + if (!_Py_Off_t_Converter(args[2], &offset)) { goto exit; } - if (!Py_off_t_converter(args[3], &sbytes)) { + if (!_Py_Off_t_Converter(args[3], &sbytes)) { goto exit; } if (!noptargs) { @@ -8328,7 +8323,7 @@ os_sendfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject if (in_fd == -1 && PyErr_Occurred()) { goto exit; } - if (!Py_off_t_converter(args[2], &offset)) { + if (!_Py_Off_t_Converter(args[2], &offset)) { goto exit; } { @@ -8757,7 +8752,7 @@ os_pwrite(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) { goto exit; } - if (!Py_off_t_converter(args[2], &offset)) { + if (!_Py_Off_t_Converter(args[2], &offset)) { goto exit; } _return_value = os_pwrite_impl(module, fd, &buffer, offset); @@ -8801,6 +8796,7 @@ PyDoc_STRVAR(os_pwritev__doc__, "- RWF_APPEND\n" "- RWF_DONTCACHE\n" "- RWF_ATOMIC\n" +"- RWF_NOSIGNAL\n" "\n" "Using non-zero flags requires Linux 4.7 or newer."); @@ -8829,7 +8825,7 @@ os_pwritev(PyObject *module, PyObject *const *args, Py_ssize_t nargs) goto exit; } buffers = args[1]; - if (!Py_off_t_converter(args[2], &offset)) { + if (!_Py_Off_t_Converter(args[2], &offset)) { goto exit; } if (nargs < 4) { @@ -8852,7 +8848,7 @@ os_pwritev(PyObject *module, PyObject *const *args, Py_ssize_t nargs) #endif /* (defined(HAVE_PWRITEV) || defined (HAVE_PWRITEV2)) */ -#if defined(HAVE_COPY_FILE_RANGE) +#if defined(_Py_HAVE_COPY_FILE_RANGE) PyDoc_STRVAR(os_copy_file_range__doc__, "copy_file_range($module, /, src, dst, count, offset_src=None,\n" @@ -8968,7 +8964,7 @@ os_copy_file_range(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py return return_value; } -#endif /* defined(HAVE_COPY_FILE_RANGE) */ +#endif /* defined(_Py_HAVE_COPY_FILE_RANGE) */ #if ((defined(HAVE_SPLICE) && !defined(_AIX))) @@ -9443,7 +9439,7 @@ os_ftruncate(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (fd == -1 && PyErr_Occurred()) { goto exit; } - if (!Py_off_t_converter(args[1], &length)) { + if (!_Py_Off_t_Converter(args[1], &length)) { goto exit; } return_value = os_ftruncate_impl(module, fd, length); @@ -9515,7 +9511,7 @@ os_truncate(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject if (!path_converter(args[0], &path)) { goto exit; } - if (!Py_off_t_converter(args[1], &length)) { + if (!_Py_Off_t_Converter(args[1], &length)) { goto exit; } return_value = os_truncate_impl(module, &path, length); @@ -9563,10 +9559,10 @@ os_posix_fallocate(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (fd == -1 && PyErr_Occurred()) { goto exit; } - if (!Py_off_t_converter(args[1], &offset)) { + if (!_Py_Off_t_Converter(args[1], &offset)) { goto exit; } - if (!Py_off_t_converter(args[2], &length)) { + if (!_Py_Off_t_Converter(args[2], &length)) { goto exit; } return_value = os_posix_fallocate_impl(module, fd, offset, length); @@ -9616,10 +9612,10 @@ os_posix_fadvise(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (fd == -1 && PyErr_Occurred()) { goto exit; } - if (!Py_off_t_converter(args[1], &offset)) { + if (!_Py_Off_t_Converter(args[1], &offset)) { goto exit; } - if (!Py_off_t_converter(args[2], &length)) { + if (!_Py_Off_t_Converter(args[2], &length)) { goto exit; } advice = PyLong_AsInt(args[3]); @@ -11546,7 +11542,7 @@ os_urandom(PyObject *module, PyObject *arg) return return_value; } -#if defined(HAVE_MEMFD_CREATE) +#if defined(_Py_HAVE_MEMFD_CREATE) PyDoc_STRVAR(os_memfd_create__doc__, "memfd_create($module, /, name, flags=MFD_CLOEXEC)\n" @@ -11632,7 +11628,7 @@ os_memfd_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj return return_value; } -#endif /* defined(HAVE_MEMFD_CREATE) */ +#endif /* defined(_Py_HAVE_MEMFD_CREATE) */ #if (defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC)) @@ -12441,6 +12437,33 @@ os_DirEntry___fspath__(PyObject *self, PyObject *Py_UNUSED(ignored)) return os_DirEntry___fspath___impl((DirEntry *)self); } +PyDoc_STRVAR(os_ScandirIterator___exit____doc__, +"__exit__($self, /, *exc_info)\n" +"--\n" +"\n" +"Close the scandir iterator."); + +#define OS_SCANDIRITERATOR___EXIT___METHODDEF \ + {"__exit__", _PyCFunction_CAST(os_ScandirIterator___exit__), METH_FASTCALL, os_ScandirIterator___exit____doc__}, + +static PyObject * +os_ScandirIterator___exit___impl(PyObject *self, PyObject * const *exc_info, + Py_ssize_t exc_info_length); + +static PyObject * +os_ScandirIterator___exit__(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject * const *exc_info; + Py_ssize_t exc_info_length; + + exc_info = args; + exc_info_length = nargs; + return_value = os_ScandirIterator___exit___impl(self, exc_info, exc_info_length); + + return return_value; +} + PyDoc_STRVAR(os_scandir__doc__, "scandir($module, /, path=None)\n" "--\n" @@ -12577,7 +12600,7 @@ os_fspath(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k return return_value; } -#if defined(HAVE_GETRANDOM_SYSCALL) +#if (defined(HAVE_GETRANDOM) || defined(HAVE_GETRANDOM_SYSCALL)) PyDoc_STRVAR(os_getrandom__doc__, "getrandom($module, /, size, flags=0)\n" @@ -12589,7 +12612,7 @@ PyDoc_STRVAR(os_getrandom__doc__, {"getrandom", _PyCFunction_CAST(os_getrandom), METH_FASTCALL|METH_KEYWORDS, os_getrandom__doc__}, static PyObject * -os_getrandom_impl(PyObject *module, Py_ssize_t size, int flags); +os_getrandom_impl(PyObject *module, Py_ssize_t size, unsigned int flags); static PyObject * os_getrandom(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) @@ -12625,7 +12648,7 @@ os_getrandom(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject PyObject *argsbuf[2]; Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_ssize_t size; - int flags = 0; + unsigned int flags = 0; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); @@ -12647,9 +12670,21 @@ os_getrandom(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject if (!noptargs) { goto skip_optional_pos; } - flags = PyLong_AsInt(args[1]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[1], &flags, sizeof(unsigned int), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(unsigned int)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } } skip_optional_pos: return_value = os_getrandom_impl(module, size, flags); @@ -12658,7 +12693,7 @@ os_getrandom(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject return return_value; } -#endif /* defined(HAVE_GETRANDOM_SYSCALL) */ +#endif /* (defined(HAVE_GETRANDOM) || defined(HAVE_GETRANDOM_SYSCALL)) */ #if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)) @@ -13029,15 +13064,10 @@ os__emscripten_log(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py _PyArg_BadArgument("_emscripten_log", "argument 'arg'", "str", args[0]); goto exit; } - Py_ssize_t arg_length; - arg = PyUnicode_AsUTF8AndSize(args[0], &arg_length); + arg = _PyUnicode_AsUTF8NoNUL(args[0]); if (arg == NULL) { goto exit; } - if (strlen(arg) != (size_t)arg_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = os__emscripten_log_impl(module, arg); exit: @@ -13733,4 +13763,4 @@ os__emscripten_log(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py #ifndef OS__EMSCRIPTEN_LOG_METHODDEF #define OS__EMSCRIPTEN_LOG_METHODDEF #endif /* !defined(OS__EMSCRIPTEN_LOG_METHODDEF) */ -/*[clinic end generated code: output=d81494ceb6ce44ed input=a9049054013a1b77]*/ +/*[clinic end generated code: output=077c57e5f93bd790 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/pwdmodule.c.h b/Modules/clinic/pwdmodule.c.h index 43d4825031c7e61..64127ff8e494db8 100644 --- a/Modules/clinic/pwdmodule.c.h +++ b/Modules/clinic/pwdmodule.c.h @@ -15,6 +15,24 @@ PyDoc_STRVAR(pwd_getpwuid__doc__, #define PWD_GETPWUID_METHODDEF \ {"getpwuid", (PyCFunction)pwd_getpwuid, METH_O, pwd_getpwuid__doc__}, +static PyObject * +pwd_getpwuid_impl(PyObject *module, uid_t uid); + +static PyObject * +pwd_getpwuid(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + uid_t uid; + + if (!_Py_Uid_Converter(arg, &uid)) { + goto exit; + } + return_value = pwd_getpwuid_impl(module, uid); + +exit: + return return_value; +} + PyDoc_STRVAR(pwd_getpwnam__doc__, "getpwnam($module, name, /)\n" "--\n" @@ -73,4 +91,4 @@ pwd_getpwall(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef PWD_GETPWALL_METHODDEF #define PWD_GETPWALL_METHODDEF #endif /* !defined(PWD_GETPWALL_METHODDEF) */ -/*[clinic end generated code: output=5a8fb12939ff4ea3 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=5bca0b2c2f4c5e89 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/pyexpat.c.h b/Modules/clinic/pyexpat.c.h index 1a07726d303ecad..0ce841c83feb204 100644 --- a/Modules/clinic/pyexpat.c.h +++ b/Modules/clinic/pyexpat.c.h @@ -4,10 +4,11 @@ preserve #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) # include "pycore_gc.h" // PyGC_Head -# include "pycore_runtime.h" // _Py_SINGLETON() +# include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_long.h" // _PyLong_UnsignedLongLong_Converter() -#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(pyexpat_xmlparser_SetReparseDeferralEnabled__doc__, "SetReparseDeferralEnabled($self, enabled, /)\n" @@ -62,6 +63,8 @@ PyDoc_STRVAR(pyexpat_xmlparser_Parse__doc__, "\n" "Parse XML data.\n" "\n" +"\'data\' can be a bytes-like object or a string. If it is a string,\n" +"the encoding declaration in the XML data is ignored.\n" "\'isfinal\' should be true at end of input."); #define PYEXPAT_XMLPARSER_PARSE_METHODDEF \ @@ -75,37 +78,24 @@ static PyObject * pyexpat_xmlparser_Parse(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "Parse", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; PyObject *data; int isfinal = 0; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("Parse", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("Parse", nargs, 1, 2)) { goto exit; } data = args[0]; if (nargs < 2) { - goto skip_optional_posonly; + goto skip_optional; } isfinal = PyObject_IsTrue(args[1]); if (isfinal < 0) { goto exit; } -skip_optional_posonly: +skip_optional: return_value = pyexpat_xmlparser_Parse_impl((xmlparseobject *)self, cls, data, isfinal); exit: @@ -116,7 +106,9 @@ PyDoc_STRVAR(pyexpat_xmlparser_ParseFile__doc__, "ParseFile($self, file, /)\n" "--\n" "\n" -"Parse XML data from file-like object."); +"Parse XML data from a binary file-like object.\n" +"\n" +"Its read() method should return bytes."); #define PYEXPAT_XMLPARSER_PARSEFILE_METHODDEF \ {"ParseFile", _PyCFunction_CAST(pyexpat_xmlparser_ParseFile), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_ParseFile__doc__}, @@ -129,25 +121,12 @@ static PyObject * pyexpat_xmlparser_ParseFile(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "ParseFile", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *file; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("ParseFile", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("ParseFile", nargs, 1, 1)) { goto exit; } file = args[0]; @@ -179,15 +158,10 @@ pyexpat_xmlparser_SetBase(PyObject *self, PyObject *arg) _PyArg_BadArgument("SetBase", "argument", "str", arg); goto exit; } - Py_ssize_t base_length; - base = PyUnicode_AsUTF8AndSize(arg, &base_length); + base = _PyUnicode_AsUTF8NoNUL(arg); if (base == NULL) { goto exit; } - if (strlen(base) != (size_t)base_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = pyexpat_xmlparser_SetBase_impl((xmlparseobject *)self, base); exit: @@ -212,15 +186,42 @@ pyexpat_xmlparser_GetBase(PyObject *self, PyObject *Py_UNUSED(ignored)) return pyexpat_xmlparser_GetBase_impl((xmlparseobject *)self); } +PyDoc_STRVAR(pyexpat_xmlparser_GetSpecifiedAttributeCount__doc__, +"GetSpecifiedAttributeCount($self, /)\n" +"--\n" +"\n" +"Return the index just past the attributes given in the start tag.\n" +"\n" +"Attributes defaulted from the DTD follow the specified ones, so\n" +"attributes at lower indices in the list passed to\n" +"StartElementHandler were given in the start tag. Each attribute\n" +"takes two items in that list, its name and its value. Only\n" +"meaningful inside a StartElementHandler call, and only if\n" +"ordered_attributes is true."); + +#define PYEXPAT_XMLPARSER_GETSPECIFIEDATTRIBUTECOUNT_METHODDEF \ + {"GetSpecifiedAttributeCount", (PyCFunction)pyexpat_xmlparser_GetSpecifiedAttributeCount, METH_NOARGS, pyexpat_xmlparser_GetSpecifiedAttributeCount__doc__}, + +static PyObject * +pyexpat_xmlparser_GetSpecifiedAttributeCount_impl(xmlparseobject *self); + +static PyObject * +pyexpat_xmlparser_GetSpecifiedAttributeCount(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return pyexpat_xmlparser_GetSpecifiedAttributeCount_impl((xmlparseobject *)self); +} + PyDoc_STRVAR(pyexpat_xmlparser_GetInputContext__doc__, "GetInputContext($self, /)\n" "--\n" "\n" -"Return the untranslated text of the input that caused the current event.\n" +"Return the input which generated the current event as bytes.\n" "\n" -"If the event was generated by a large amount of text (such as\n" -"a start tag for an element with many attributes), not all of the\n" -"text may be available."); +"The data is in the encoding of the entity which contains the text.\n" +"It extends to the end of the currently buffered input, therefore it\n" +"can contain also the data of the following events, and if the event\n" +"was generated by a large amount of text, not all of it may be\n" +"available."); #define PYEXPAT_XMLPARSER_GETINPUTCONTEXT_METHODDEF \ {"GetInputContext", (PyCFunction)pyexpat_xmlparser_GetInputContext, METH_NOARGS, pyexpat_xmlparser_GetInputContext__doc__}, @@ -254,63 +255,40 @@ static PyObject * pyexpat_xmlparser_ExternalEntityParserCreate(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "ExternalEntityParserCreate", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[2]; const char *context; const char *encoding = NULL; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("ExternalEntityParserCreate", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("ExternalEntityParserCreate", nargs, 1, 2)) { goto exit; } if (args[0] == Py_None) { context = NULL; } else if (PyUnicode_Check(args[0])) { - Py_ssize_t context_length; - context = PyUnicode_AsUTF8AndSize(args[0], &context_length); + context = _PyUnicode_AsUTF8NoNUL(args[0]); if (context == NULL) { goto exit; } - if (strlen(context) != (size_t)context_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("ExternalEntityParserCreate", "argument 1", "str or None", args[0]); goto exit; } if (nargs < 2) { - goto skip_optional_posonly; + goto skip_optional; } if (!PyUnicode_Check(args[1])) { _PyArg_BadArgument("ExternalEntityParserCreate", "argument 2", "str", args[1]); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(args[1]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } -skip_optional_posonly: +skip_optional: return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl((xmlparseobject *)self, cls, context, encoding); exit: @@ -374,35 +352,22 @@ static PyObject * pyexpat_xmlparser_UseForeignDTD(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "UseForeignDTD", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; int flag = 1; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("UseForeignDTD", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("UseForeignDTD", nargs, 0, 1)) { goto exit; } if (nargs < 1) { - goto skip_optional_posonly; + goto skip_optional; } flag = PyObject_IsTrue(args[0]); if (flag < 0) { goto exit; } -skip_optional_posonly: +skip_optional: return_value = pyexpat_xmlparser_UseForeignDTD_impl((xmlparseobject *)self, cls, flag); exit: @@ -441,25 +406,12 @@ static PyObject * pyexpat_xmlparser_SetBillionLaughsAttackProtectionActivationThreshold(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "SetBillionLaughsAttackProtectionActivationThreshold", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; unsigned long long threshold; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("SetBillionLaughsAttackProtectionActivationThreshold", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("SetBillionLaughsAttackProtectionActivationThreshold", nargs, 1, 1)) { goto exit; } if (!_PyLong_UnsignedLongLong_Converter(args[0], &threshold)) { @@ -510,25 +462,12 @@ static PyObject * pyexpat_xmlparser_SetBillionLaughsAttackProtectionMaximumAmplification(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "SetBillionLaughsAttackProtectionMaximumAmplification", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; float max_factor; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("SetBillionLaughsAttackProtectionMaximumAmplification", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("SetBillionLaughsAttackProtectionMaximumAmplification", nargs, 1, 1)) { goto exit; } if (PyFloat_CheckExact(args[0])) { @@ -573,25 +512,12 @@ static PyObject * pyexpat_xmlparser_SetAllocTrackerActivationThreshold(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "SetAllocTrackerActivationThreshold", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; unsigned long long threshold; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("SetAllocTrackerActivationThreshold", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("SetAllocTrackerActivationThreshold", nargs, 1, 1)) { goto exit; } if (!_PyLong_UnsignedLongLong_Converter(args[0], &threshold)) { @@ -640,25 +566,12 @@ static PyObject * pyexpat_xmlparser_SetAllocTrackerMaximumAmplification(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "SetAllocTrackerMaximumAmplification", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; float max_factor; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("SetAllocTrackerMaximumAmplification", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("SetAllocTrackerMaximumAmplification", nargs, 1, 1)) { goto exit; } if (PyFloat_CheckExact(args[0])) { @@ -743,15 +656,10 @@ pyexpat_ParserCreate(PyObject *module, PyObject *const *args, Py_ssize_t nargs, encoding = NULL; } else if (PyUnicode_Check(args[0])) { - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(args[0]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("ParserCreate", "argument 'encoding'", "str or None", args[0]); @@ -766,15 +674,10 @@ pyexpat_ParserCreate(PyObject *module, PyObject *const *args, Py_ssize_t nargs, namespace_separator = NULL; } else if (PyUnicode_Check(args[1])) { - Py_ssize_t namespace_separator_length; - namespace_separator = PyUnicode_AsUTF8AndSize(args[1], &namespace_separator_length); + namespace_separator = _PyUnicode_AsUTF8NoNUL(args[1]); if (namespace_separator == NULL) { goto exit; } - if (strlen(namespace_separator) != (size_t)namespace_separator_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("ParserCreate", "argument 'namespace_separator'", "str or None", args[1]); @@ -839,4 +742,4 @@ pyexpat_ErrorString(PyObject *module, PyObject *arg) #ifndef PYEXPAT_XMLPARSER_SETALLOCTRACKERMAXIMUMAMPLIFICATION_METHODDEF #define PYEXPAT_XMLPARSER_SETALLOCTRACKERMAXIMUMAMPLIFICATION_METHODDEF #endif /* !defined(PYEXPAT_XMLPARSER_SETALLOCTRACKERMAXIMUMAMPLIFICATION_METHODDEF) */ -/*[clinic end generated code: output=270a0bfe3300e8a1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f1652fd212bce55f input=a9049054013a1b77]*/ diff --git a/Modules/clinic/readline.c.h b/Modules/clinic/readline.c.h index dc9381e4b976acd..a7df757f3f6c85c 100644 --- a/Modules/clinic/readline.c.h +++ b/Modules/clinic/readline.c.h @@ -366,7 +366,13 @@ readline_get_pre_input_hook_impl(PyObject *module); static PyObject * readline_get_pre_input_hook(PyObject *module, PyObject *Py_UNUSED(ignored)) { - return readline_get_pre_input_hook_impl(module); + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(module); + return_value = readline_get_pre_input_hook_impl(module); + Py_END_CRITICAL_SECTION(); + + return return_value; } #endif /* defined(HAVE_RL_PRE_INPUT_HOOK) */ @@ -651,7 +657,13 @@ readline_get_completer_impl(PyObject *module); static PyObject * readline_get_completer(PyObject *module, PyObject *Py_UNUSED(ignored)) { - return readline_get_completer_impl(module); + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(module); + return_value = readline_get_completer_impl(module); + Py_END_CRITICAL_SECTION(); + + return return_value; } PyDoc_STRVAR(readline_get_history_item__doc__, @@ -823,4 +835,4 @@ readline_redisplay(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef READLINE_CLEAR_HISTORY_METHODDEF #define READLINE_CLEAR_HISTORY_METHODDEF #endif /* !defined(READLINE_CLEAR_HISTORY_METHODDEF) */ -/*[clinic end generated code: output=4bd95070973cd0e2 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=acf4e4c35191cf09 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/resource.c.h b/Modules/clinic/resource.c.h index e4ef93900d17978..173e3f977721c27 100644 --- a/Modules/clinic/resource.c.h +++ b/Modules/clinic/resource.c.h @@ -120,7 +120,7 @@ resource_prlimit(PyObject *module, PyObject *const *args, Py_ssize_t nargs) goto exit; } pid = PyLong_AsPid(args[0]); - if (pid == -1 && PyErr_Occurred()) { + if (pid == (pid_t)(-1) && PyErr_Occurred()) { goto exit; } resource = PyLong_AsInt(args[1]); @@ -174,4 +174,4 @@ resource_getpagesize(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef RESOURCE_PRLIMIT_METHODDEF #define RESOURCE_PRLIMIT_METHODDEF #endif /* !defined(RESOURCE_PRLIMIT_METHODDEF) */ -/*[clinic end generated code: output=8e905b2f5c35170e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=4044ef9ffbf7278b input=a9049054013a1b77]*/ diff --git a/Modules/clinic/signalmodule.c.h b/Modules/clinic/signalmodule.c.h index ca47033446074cd..26139ff0fc0cd39 100644 --- a/Modules/clinic/signalmodule.c.h +++ b/Modules/clinic/signalmodule.c.h @@ -689,7 +689,7 @@ signal_pthread_kill(PyObject *module, PyObject *const *args, Py_ssize_t nargs) #endif /* defined(HAVE_PTHREAD_KILL) */ -#if (defined(__linux__) && defined(__NR_pidfd_send_signal) && !(defined(__ANDROID__) && __ANDROID_API__ < 31)) +#if (defined(_Py_HAVE_PIDFD_SEND_SIGNAL) || (defined(__linux__) && defined(__NR_pidfd_send_signal) && !(defined(__ANDROID__) && __ANDROID_API__ < 31))) PyDoc_STRVAR(signal_pidfd_send_signal__doc__, "pidfd_send_signal($module, pidfd, signalnum, siginfo=None, flags=0, /)\n" @@ -702,7 +702,7 @@ PyDoc_STRVAR(signal_pidfd_send_signal__doc__, static PyObject * signal_pidfd_send_signal_impl(PyObject *module, int pidfd, int signalnum, - PyObject *siginfo, int flags); + PyObject *siginfo, unsigned int flags); static PyObject * signal_pidfd_send_signal(PyObject *module, PyObject *const *args, Py_ssize_t nargs) @@ -711,7 +711,7 @@ signal_pidfd_send_signal(PyObject *module, PyObject *const *args, Py_ssize_t nar int pidfd; int signalnum; PyObject *siginfo = Py_None; - int flags = 0; + unsigned int flags = 0; if (!_PyArg_CheckPositional("pidfd_send_signal", nargs, 2, 4)) { goto exit; @@ -731,9 +731,21 @@ signal_pidfd_send_signal(PyObject *module, PyObject *const *args, Py_ssize_t nar if (nargs < 4) { goto skip_optional; } - flags = PyLong_AsInt(args[3]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[3], &flags, sizeof(unsigned int), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(unsigned int)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } } skip_optional: return_value = signal_pidfd_send_signal_impl(module, pidfd, signalnum, siginfo, flags); @@ -742,7 +754,7 @@ signal_pidfd_send_signal(PyObject *module, PyObject *const *args, Py_ssize_t nar return return_value; } -#endif /* (defined(__linux__) && defined(__NR_pidfd_send_signal) && !(defined(__ANDROID__) && __ANDROID_API__ < 31)) */ +#endif /* (defined(_Py_HAVE_PIDFD_SEND_SIGNAL) || (defined(__linux__) && defined(__NR_pidfd_send_signal) && !(defined(__ANDROID__) && __ANDROID_API__ < 31))) */ #ifndef SIGNAL_ALARM_METHODDEF #define SIGNAL_ALARM_METHODDEF @@ -795,4 +807,4 @@ signal_pidfd_send_signal(PyObject *module, PyObject *const *args, Py_ssize_t nar #ifndef SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF #define SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF #endif /* !defined(SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF) */ -/*[clinic end generated code: output=0731d6f05c42c09a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=48d30418971f312a input=a9049054013a1b77]*/ diff --git a/Modules/clinic/socketmodule.c.h b/Modules/clinic/socketmodule.c.h index b565e7516d50f33..5a1a128b304f028 100644 --- a/Modules/clinic/socketmodule.c.h +++ b/Modules/clinic/socketmodule.c.h @@ -6,29 +6,918 @@ preserve # include "pycore_gc.h" // PyGC_Head # include "pycore_runtime.h" // _Py_ID() #endif +#include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_long.h" // _PyLong_UInt16_Converter() #include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() + +#if (defined(HAVE_ACCEPT) || defined(HAVE_ACCEPT4)) + +PyDoc_STRVAR(_socket_socket__accept__doc__, +"_accept($self, /)\n" +"--\n" +"\n" +"Wait for an incoming connection.\n" +"\n" +"Return a new socket file descriptor representing the connection, and\n" +"the address of the client. For IP sockets, the address info is a\n" +"pair (hostaddr, port)."); + +#define _SOCKET_SOCKET__ACCEPT_METHODDEF \ + {"_accept", (PyCFunction)_socket_socket__accept, METH_NOARGS, _socket_socket__accept__doc__}, + +static PyObject * +_socket_socket__accept_impl(PySocketSockObject *s); + +static PyObject * +_socket_socket__accept(PyObject *s, PyObject *Py_UNUSED(ignored)) +{ + return _socket_socket__accept_impl((PySocketSockObject *)s); +} + +#endif /* (defined(HAVE_ACCEPT) || defined(HAVE_ACCEPT4)) */ + +PyDoc_STRVAR(_socket_socket_setblocking__doc__, +"setblocking($self, flag, /)\n" +"--\n" +"\n" +"Set the socket to blocking (flag is true) or non-blocking (false).\n" +"\n" +"setblocking(True) is equivalent to settimeout(None);\n" +"setblocking(False) is equivalent to settimeout(0.0)."); + +#define _SOCKET_SOCKET_SETBLOCKING_METHODDEF \ + {"setblocking", (PyCFunction)_socket_socket_setblocking, METH_O, _socket_socket_setblocking__doc__}, + +static PyObject * +_socket_socket_setblocking_impl(PySocketSockObject *s, int flag); + +static PyObject * +_socket_socket_setblocking(PyObject *s, PyObject *arg) +{ + PyObject *return_value = NULL; + int flag; + + flag = PyObject_IsTrue(arg); + if (flag < 0) { + goto exit; + } + return_value = _socket_socket_setblocking_impl((PySocketSockObject *)s, flag); + +exit: + return return_value; +} + +PyDoc_STRVAR(_socket_socket_getblocking__doc__, +"getblocking($self, /)\n" +"--\n" +"\n" +"Return True if socket is in blocking mode, False if in non-blocking."); + +#define _SOCKET_SOCKET_GETBLOCKING_METHODDEF \ + {"getblocking", (PyCFunction)_socket_socket_getblocking, METH_NOARGS, _socket_socket_getblocking__doc__}, + +static PyObject * +_socket_socket_getblocking_impl(PySocketSockObject *s); + +static PyObject * +_socket_socket_getblocking(PyObject *s, PyObject *Py_UNUSED(ignored)) +{ + return _socket_socket_getblocking_impl((PySocketSockObject *)s); +} + +PyDoc_STRVAR(_socket_socket_settimeout__doc__, +"settimeout($self, timeout, /)\n" +"--\n" +"\n" +"Set a timeout on socket operations.\n" +"\n" +"\'timeout\' can be a float, giving in seconds, or None. Setting a\n" +"timeout of None disables the timeout feature and is equivalent to\n" +"setblocking(1). Setting a timeout of zero is the same as\n" +"setblocking(0)."); + +#define _SOCKET_SOCKET_SETTIMEOUT_METHODDEF \ + {"settimeout", (PyCFunction)_socket_socket_settimeout, METH_O, _socket_socket_settimeout__doc__}, + +static PyObject * +_socket_socket_settimeout_impl(PySocketSockObject *s, PyObject *arg); + +static PyObject * +_socket_socket_settimeout(PyObject *s, PyObject *arg) +{ + PyObject *return_value = NULL; + + return_value = _socket_socket_settimeout_impl((PySocketSockObject *)s, arg); + + return return_value; +} + +PyDoc_STRVAR(_socket_socket_gettimeout__doc__, +"gettimeout($self, /)\n" +"--\n" +"\n" +"Return the timeout in seconds (float) of socket operations.\n" +"\n" +"A timeout of None indicates that timeouts on socket operations are\n" +"disabled."); + +#define _SOCKET_SOCKET_GETTIMEOUT_METHODDEF \ + {"gettimeout", (PyCFunction)_socket_socket_gettimeout, METH_NOARGS, _socket_socket_gettimeout__doc__}, + +static PyObject * +_socket_socket_gettimeout_impl(PySocketSockObject *self); + +static PyObject * +_socket_socket_gettimeout(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _socket_socket_gettimeout_impl((PySocketSockObject *)self); +} + +PyDoc_STRVAR(_socket_socket_getsockopt__doc__, +"getsockopt($self, level, option, buffersize=0, /)\n" +"--\n" +"\n" +"Get a socket option.\n" +"\n" +"See the Unix manual for level and option. If a nonzero buffersize\n" +"argument is given, the return value is a bytes object of that\n" +"length; otherwise it is an integer."); + +#define _SOCKET_SOCKET_GETSOCKOPT_METHODDEF \ + {"getsockopt", _PyCFunction_CAST(_socket_socket_getsockopt), METH_FASTCALL, _socket_socket_getsockopt__doc__}, + +static PyObject * +_socket_socket_getsockopt_impl(PySocketSockObject *s, int level, int optname, + int buflen); + +static PyObject * +_socket_socket_getsockopt(PyObject *s, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int level; + int optname; + int buflen = 0; + + if (!_PyArg_CheckPositional("getsockopt", nargs, 2, 3)) { + goto exit; + } + level = PyLong_AsInt(args[0]); + if (level == -1 && PyErr_Occurred()) { + goto exit; + } + optname = PyLong_AsInt(args[1]); + if (optname == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + buflen = PyLong_AsInt(args[2]); + if (buflen == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _socket_socket_getsockopt_impl((PySocketSockObject *)s, level, optname, buflen); + +exit: + return return_value; +} + +#if defined(HAVE_BIND) + +PyDoc_STRVAR(_socket_socket_bind__doc__, +"bind($self, address, /)\n" +"--\n" +"\n" +"Bind the socket to a local address.\n" +"\n" +"For IP sockets, the address is a pair (host, port); the host must\n" +"refer to the local host. For raw packet sockets the address is a\n" +"tuple (ifname, proto [,pkttype [,hatype [,addr]]])."); + +#define _SOCKET_SOCKET_BIND_METHODDEF \ + {"bind", (PyCFunction)_socket_socket_bind, METH_O, _socket_socket_bind__doc__}, + +static PyObject * +_socket_socket_bind_impl(PySocketSockObject *s, PyObject *addro); + +static PyObject * +_socket_socket_bind(PyObject *s, PyObject *addro) +{ + PyObject *return_value = NULL; + + return_value = _socket_socket_bind_impl((PySocketSockObject *)s, addro); + + return return_value; +} + +#endif /* defined(HAVE_BIND) */ PyDoc_STRVAR(_socket_socket_close__doc__, "close($self, /)\n" "--\n" "\n" -"close()\n" +"close()\n" +"\n" +"Close the socket. It cannot be used after this call."); + +#define _SOCKET_SOCKET_CLOSE_METHODDEF \ + {"close", (PyCFunction)_socket_socket_close, METH_NOARGS, _socket_socket_close__doc__}, + +static PyObject * +_socket_socket_close_impl(PySocketSockObject *s); + +static PyObject * +_socket_socket_close(PyObject *s, PyObject *Py_UNUSED(ignored)) +{ + return _socket_socket_close_impl((PySocketSockObject *)s); +} + +PyDoc_STRVAR(_socket_socket_detach__doc__, +"detach($self, /)\n" +"--\n" +"\n" +"Close the socket object without closing the file descriptor.\n" +"\n" +"The object cannot be used after this call, but the file descriptor\n" +"can be reused for other purposes. The file descriptor is returned."); + +#define _SOCKET_SOCKET_DETACH_METHODDEF \ + {"detach", (PyCFunction)_socket_socket_detach, METH_NOARGS, _socket_socket_detach__doc__}, + +static PyObject * +_socket_socket_detach_impl(PySocketSockObject *s); + +static PyObject * +_socket_socket_detach(PyObject *s, PyObject *Py_UNUSED(ignored)) +{ + return _socket_socket_detach_impl((PySocketSockObject *)s); +} + +#if defined(HAVE_CONNECT) + +PyDoc_STRVAR(_socket_socket_connect__doc__, +"connect($self, address, /)\n" +"--\n" +"\n" +"Connect the socket to a remote address.\n" +"\n" +"For IP sockets, the address is a pair (host, port)."); + +#define _SOCKET_SOCKET_CONNECT_METHODDEF \ + {"connect", (PyCFunction)_socket_socket_connect, METH_O, _socket_socket_connect__doc__}, + +static PyObject * +_socket_socket_connect_impl(PySocketSockObject *s, PyObject *addro); + +static PyObject * +_socket_socket_connect(PyObject *s, PyObject *addro) +{ + PyObject *return_value = NULL; + + return_value = _socket_socket_connect_impl((PySocketSockObject *)s, addro); + + return return_value; +} + +#endif /* defined(HAVE_CONNECT) */ + +#if defined(HAVE_CONNECT) + +PyDoc_STRVAR(_socket_socket_connect_ex__doc__, +"connect_ex($self, address, /)\n" +"--\n" +"\n" +"Connect the socket to a remote address.\n" +"\n" +"This is like connect(address), but returns an error code (the errno\n" +"value) instead of raising an exception when an error occurs."); + +#define _SOCKET_SOCKET_CONNECT_EX_METHODDEF \ + {"connect_ex", (PyCFunction)_socket_socket_connect_ex, METH_O, _socket_socket_connect_ex__doc__}, + +static PyObject * +_socket_socket_connect_ex_impl(PySocketSockObject *s, PyObject *addro); + +static PyObject * +_socket_socket_connect_ex(PyObject *s, PyObject *addro) +{ + PyObject *return_value = NULL; + + return_value = _socket_socket_connect_ex_impl((PySocketSockObject *)s, addro); + + return return_value; +} + +#endif /* defined(HAVE_CONNECT) */ + +PyDoc_STRVAR(_socket_socket_fileno__doc__, +"fileno($self, /)\n" +"--\n" +"\n" +"Return the integer file descriptor of the socket."); + +#define _SOCKET_SOCKET_FILENO_METHODDEF \ + {"fileno", (PyCFunction)_socket_socket_fileno, METH_NOARGS, _socket_socket_fileno__doc__}, + +static PyObject * +_socket_socket_fileno_impl(PySocketSockObject *s); + +static PyObject * +_socket_socket_fileno(PyObject *s, PyObject *Py_UNUSED(ignored)) +{ + return _socket_socket_fileno_impl((PySocketSockObject *)s); +} + +#if defined(HAVE_GETSOCKNAME) + +PyDoc_STRVAR(_socket_socket_getsockname__doc__, +"getsockname($self, /)\n" +"--\n" +"\n" +"Return the address of the local endpoint.\n" +"\n" +"The format depends on the address family. For IPv4 sockets, the\n" +"address info is a pair (hostaddr, port). For IPv6 sockets, the\n" +"address info is a 4-tuple (hostaddr, port, flowinfo, scope_id)."); + +#define _SOCKET_SOCKET_GETSOCKNAME_METHODDEF \ + {"getsockname", (PyCFunction)_socket_socket_getsockname, METH_NOARGS, _socket_socket_getsockname__doc__}, + +static PyObject * +_socket_socket_getsockname_impl(PySocketSockObject *s); + +static PyObject * +_socket_socket_getsockname(PyObject *s, PyObject *Py_UNUSED(ignored)) +{ + return _socket_socket_getsockname_impl((PySocketSockObject *)s); +} + +#endif /* defined(HAVE_GETSOCKNAME) */ + +#if defined(HAVE_GETPEERNAME) + +PyDoc_STRVAR(_socket_socket_getpeername__doc__, +"getpeername($self, /)\n" +"--\n" +"\n" +"Return the address of the remote endpoint.\n" +"\n" +"For IP sockets, the address info is a pair (hostaddr, port)."); + +#define _SOCKET_SOCKET_GETPEERNAME_METHODDEF \ + {"getpeername", (PyCFunction)_socket_socket_getpeername, METH_NOARGS, _socket_socket_getpeername__doc__}, + +static PyObject * +_socket_socket_getpeername_impl(PySocketSockObject *s); + +static PyObject * +_socket_socket_getpeername(PyObject *s, PyObject *Py_UNUSED(ignored)) +{ + return _socket_socket_getpeername_impl((PySocketSockObject *)s); +} + +#endif /* defined(HAVE_GETPEERNAME) */ + +#if defined(HAVE_LISTEN) + +PyDoc_STRVAR(_socket_socket_listen__doc__, +"listen($self, backlog=min(SOMAXCONN, 128), /)\n" +"--\n" +"\n" +"Enable a server to accept connections.\n" +"\n" +"If backlog is specified, it must be at least 0 (if it is lower, it\n" +"is set to 0); it specifies the number of unaccepted connections that\n" +"the system will allow before refusing new connections. If not\n" +"specified, a default reasonable value is chosen."); + +#define _SOCKET_SOCKET_LISTEN_METHODDEF \ + {"listen", _PyCFunction_CAST(_socket_socket_listen), METH_FASTCALL, _socket_socket_listen__doc__}, + +static PyObject * +_socket_socket_listen_impl(PySocketSockObject *s, int backlog); + +static PyObject * +_socket_socket_listen(PyObject *s, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int backlog = Py_MIN(SOMAXCONN, 128); + + if (!_PyArg_CheckPositional("listen", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + backlog = PyLong_AsInt(args[0]); + if (backlog == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _socket_socket_listen_impl((PySocketSockObject *)s, backlog); + +exit: + return return_value; +} + +#endif /* defined(HAVE_LISTEN) */ + +PyDoc_STRVAR(_socket_socket_recv__doc__, +"recv($self, buffersize, flags=0, /)\n" +"--\n" +"\n" +"Receive up to buffersize bytes from the socket.\n" +"\n" +"For the optional flags argument, see the Unix manual. When no data\n" +"is available, block until at least one byte is available or until\n" +"the remote end is closed. When the remote end is closed and all data\n" +"is read, return the empty string."); + +#define _SOCKET_SOCKET_RECV_METHODDEF \ + {"recv", _PyCFunction_CAST(_socket_socket_recv), METH_FASTCALL, _socket_socket_recv__doc__}, + +static PyObject * +_socket_socket_recv_impl(PySocketSockObject *s, Py_ssize_t recvlen, + int flags); + +static PyObject * +_socket_socket_recv(PyObject *s, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + Py_ssize_t recvlen; + int flags = 0; + + if (!_PyArg_CheckPositional("recv", nargs, 1, 2)) { + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + recvlen = ival; + } + if (nargs < 2) { + goto skip_optional; + } + flags = PyLong_AsInt(args[1]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _socket_socket_recv_impl((PySocketSockObject *)s, recvlen, flags); + +exit: + return return_value; +} + +PyDoc_STRVAR(_socket_socket_recv_into__doc__, +"recv_into($self, /, buffer, nbytes=0, flags=0)\n" +"--\n" +"\n" +"Receive up to nbytes bytes from the socket, storing into a buffer.\n" +"\n" +"A version of recv() that stores its data into a buffer rather than\n" +"creating a new bytes object. If nbytes is not specified (or 0),\n" +"receive up to the size available in the given buffer.\n" +"\n" +"See recv() for documentation about the flags."); + +#define _SOCKET_SOCKET_RECV_INTO_METHODDEF \ + {"recv_into", _PyCFunction_CAST(_socket_socket_recv_into), METH_FASTCALL|METH_KEYWORDS, _socket_socket_recv_into__doc__}, + +static PyObject * +_socket_socket_recv_into_impl(PySocketSockObject *s, Py_buffer *pbuf, + Py_ssize_t recvlen, int flags); + +static PyObject * +_socket_socket_recv_into(PyObject *s, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 3 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(buffer), &_Py_ID(nbytes), &_Py_ID(flags), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"buffer", "nbytes", "flags", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "recv_into", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + Py_buffer pbuf = {NULL, NULL}; + Py_ssize_t recvlen = 0; + int flags = 0; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &pbuf, PyBUF_WRITABLE) < 0) { + _PyArg_BadArgument("recv_into", "argument 'buffer'", "read-write bytes-like object", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + recvlen = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + flags = PyLong_AsInt(args[2]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: + return_value = _socket_socket_recv_into_impl((PySocketSockObject *)s, &pbuf, recvlen, flags); + +exit: + /* Cleanup for pbuf */ + if (pbuf.obj) { + PyBuffer_Release(&pbuf); + } + + return return_value; +} + +#if defined(HAVE_RECVFROM) + +PyDoc_STRVAR(_socket_socket_recvfrom__doc__, +"recvfrom($self, buffersize, flags=0, /)\n" +"--\n" +"\n" +"Receive up to buffersize bytes and the sender\'s address info.\n" +"\n" +"Like recv(buffersize, flags), but return a (data, address info)\n" +"pair."); + +#define _SOCKET_SOCKET_RECVFROM_METHODDEF \ + {"recvfrom", _PyCFunction_CAST(_socket_socket_recvfrom), METH_FASTCALL, _socket_socket_recvfrom__doc__}, + +static PyObject * +_socket_socket_recvfrom_impl(PySocketSockObject *s, Py_ssize_t recvlen, + int flags); + +static PyObject * +_socket_socket_recvfrom(PyObject *s, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + Py_ssize_t recvlen; + int flags = 0; + + if (!_PyArg_CheckPositional("recvfrom", nargs, 1, 2)) { + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + recvlen = ival; + } + if (nargs < 2) { + goto skip_optional; + } + flags = PyLong_AsInt(args[1]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _socket_socket_recvfrom_impl((PySocketSockObject *)s, recvlen, flags); + +exit: + return return_value; +} + +#endif /* defined(HAVE_RECVFROM) */ + +#if defined(HAVE_RECVFROM) + +PyDoc_STRVAR(_socket_socket_recvfrom_into__doc__, +"recvfrom_into($self, /, buffer, nbytes=0, flags=0)\n" +"--\n" +"\n" +"Receive up to nbytes bytes and the sender\'s address info.\n" +"\n" +"Like recv_into(buffer, nbytes, flags), but return a (nbytes, address\n" +"info) pair."); + +#define _SOCKET_SOCKET_RECVFROM_INTO_METHODDEF \ + {"recvfrom_into", _PyCFunction_CAST(_socket_socket_recvfrom_into), METH_FASTCALL|METH_KEYWORDS, _socket_socket_recvfrom_into__doc__}, + +static PyObject * +_socket_socket_recvfrom_into_impl(PySocketSockObject *s, Py_buffer *pbuf, + Py_ssize_t recvlen, int flags); + +static PyObject * +_socket_socket_recvfrom_into(PyObject *s, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 3 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(buffer), &_Py_ID(nbytes), &_Py_ID(flags), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"buffer", "nbytes", "flags", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "recvfrom_into", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + Py_buffer pbuf = {NULL, NULL}; + Py_ssize_t recvlen = 0; + int flags = 0; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &pbuf, PyBUF_WRITABLE) < 0) { + _PyArg_BadArgument("recvfrom_into", "argument 'buffer'", "read-write bytes-like object", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + recvlen = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + flags = PyLong_AsInt(args[2]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: + return_value = _socket_socket_recvfrom_into_impl((PySocketSockObject *)s, &pbuf, recvlen, flags); + +exit: + /* Cleanup for pbuf */ + if (pbuf.obj) { + PyBuffer_Release(&pbuf); + } + + return return_value; +} + +#endif /* defined(HAVE_RECVFROM) */ + +#if defined(CMSG_LEN) + +PyDoc_STRVAR(_socket_socket_recvmsg__doc__, +"recvmsg($self, bufsize, ancbufsize=0, flags=0, /)\n" +"--\n" +"\n" +"Receive normal data and ancillary data from the socket.\n" +"\n" +"Receive up to bufsize bytes of normal data. The ancbufsize argument\n" +"sets the size in bytes of the internal buffer used to receive the\n" +"ancillary data; it defaults to 0, meaning that no ancillary data\n" +"will be received. Appropriate buffer sizes for ancillary data can\n" +"be calculated using CMSG_SPACE() or CMSG_LEN(), and items which do\n" +"not fit into the buffer might be truncated or discarded. The flags\n" +"argument defaults to 0 and has the same meaning as for recv().\n" +"\n" +"The return value is a 4-tuple: (data, ancdata, msg_flags, address).\n" +"The data item is a bytes object holding the non-ancillary data\n" +"received. The ancdata item is a list of zero or more tuples\n" +"(cmsg_level, cmsg_type, cmsg_data) representing the ancillary data\n" +"(control messages) received: cmsg_level and cmsg_type are integers\n" +"specifying the protocol level and protocol-specific type\n" +"respectively, and cmsg_data is a bytes object holding the associated\n" +"data. The msg_flags item is the bitwise OR of various flags\n" +"indicating conditions on the received message; see your system\n" +"documentation for details. If the receiving socket is unconnected,\n" +"address is the address of the sending socket, if available;\n" +"otherwise, its value is unspecified.\n" +"\n" +"If recvmsg() raises an exception after the system call returns, it\n" +"will first attempt to close any file descriptors received via the\n" +"SCM_RIGHTS mechanism."); + +#define _SOCKET_SOCKET_RECVMSG_METHODDEF \ + {"recvmsg", _PyCFunction_CAST(_socket_socket_recvmsg), METH_FASTCALL, _socket_socket_recvmsg__doc__}, + +static PyObject * +_socket_socket_recvmsg_impl(PySocketSockObject *s, Py_ssize_t bufsize, + Py_ssize_t ancbufsize, int flags); + +static PyObject * +_socket_socket_recvmsg(PyObject *s, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + Py_ssize_t bufsize; + Py_ssize_t ancbufsize = 0; + int flags = 0; + + if (!_PyArg_CheckPositional("recvmsg", nargs, 1, 3)) { + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + bufsize = ival; + } + if (nargs < 2) { + goto skip_optional; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + ancbufsize = ival; + } + if (nargs < 3) { + goto skip_optional; + } + flags = PyLong_AsInt(args[2]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _socket_socket_recvmsg_impl((PySocketSockObject *)s, bufsize, ancbufsize, flags); + +exit: + return return_value; +} + +#endif /* defined(CMSG_LEN) */ + +#if defined(CMSG_LEN) + +PyDoc_STRVAR(_socket_socket_recvmsg_into__doc__, +"recvmsg_into($self, buffers, ancbufsize=0, flags=0, /)\n" +"--\n" +"\n" +"Receive normal and ancillary data, scattering the normal data.\n" "\n" -"Close the socket. It cannot be used after this call."); +"The buffers argument must be an iterable of objects that export\n" +"writable buffers (e.g. bytearray objects); these will be filled\n" +"with successive chunks of the non-ancillary data until it has all\n" +"been written or there are no more buffers. The ancbufsize argument\n" +"sets the size in bytes of the internal buffer used to receive the\n" +"ancillary data; it defaults to 0, meaning that no ancillary data\n" +"will be received. Appropriate buffer sizes for ancillary data can\n" +"be calculated using CMSG_SPACE() or CMSG_LEN(), and items which do\n" +"not fit into the buffer might be truncated or discarded. The flags\n" +"argument defaults to 0 and has the same meaning as for recv().\n" +"\n" +"The return value is a 4-tuple: (nbytes, ancdata, msg_flags,\n" +"address). The nbytes item is the total number of bytes of\n" +"non-ancillary data written into the buffers. The ancdata item is a\n" +"list of zero or more tuples (cmsg_level, cmsg_type, cmsg_data)\n" +"representing the ancillary data (control messages) received:\n" +"cmsg_level and cmsg_type are integers specifying the protocol level\n" +"and protocol-specific type respectively, and cmsg_data is a bytes\n" +"object holding the associated data. The msg_flags item is the\n" +"bitwise OR of various flags indicating conditions on the received\n" +"message; see your system documentation for details. If the\n" +"receiving socket is unconnected, address is the address of the\n" +"sending socket, if available; otherwise, its value is unspecified.\n" +"\n" +"If recvmsg_into() raises an exception after the system call returns,\n" +"it will first attempt to close any file descriptors received via the\n" +"SCM_RIGHTS mechanism."); -#define _SOCKET_SOCKET_CLOSE_METHODDEF \ - {"close", (PyCFunction)_socket_socket_close, METH_NOARGS, _socket_socket_close__doc__}, +#define _SOCKET_SOCKET_RECVMSG_INTO_METHODDEF \ + {"recvmsg_into", _PyCFunction_CAST(_socket_socket_recvmsg_into), METH_FASTCALL, _socket_socket_recvmsg_into__doc__}, static PyObject * -_socket_socket_close_impl(PySocketSockObject *s); +_socket_socket_recvmsg_into_impl(PySocketSockObject *s, + PyObject *buffers_arg, + Py_ssize_t ancbufsize, int flags); static PyObject * -_socket_socket_close(PyObject *s, PyObject *Py_UNUSED(ignored)) +_socket_socket_recvmsg_into(PyObject *s, PyObject *const *args, Py_ssize_t nargs) { - return _socket_socket_close_impl((PySocketSockObject *)s); + PyObject *return_value = NULL; + PyObject *buffers_arg; + Py_ssize_t ancbufsize = 0; + int flags = 0; + + if (!_PyArg_CheckPositional("recvmsg_into", nargs, 1, 3)) { + goto exit; + } + buffers_arg = args[0]; + if (nargs < 2) { + goto skip_optional; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + ancbufsize = ival; + } + if (nargs < 3) { + goto skip_optional; + } + flags = PyLong_AsInt(args[2]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _socket_socket_recvmsg_into_impl((PySocketSockObject *)s, buffers_arg, ancbufsize, flags); + +exit: + return return_value; } +#endif /* defined(CMSG_LEN) */ + PyDoc_STRVAR(_socket_socket_send__doc__, "send($self, data, flags=0, /)\n" "--\n" @@ -77,123 +966,323 @@ _socket_socket_send(PyObject *s, PyObject *const *args, Py_ssize_t nargs) return return_value; } -PyDoc_STRVAR(_socket_socket_sendall__doc__, -"sendall($self, data, flags=0, /)\n" +PyDoc_STRVAR(_socket_socket_sendall__doc__, +"sendall($self, data, flags=0, /)\n" +"--\n" +"\n" +"Send a data string to the socket.\n" +"\n" +"For the optional flags argument, see the Unix manual.\n" +"This calls send() repeatedly until all data is sent.\n" +"If an error occurs, it\'s impossible to tell how much data has been\n" +"sent."); + +#define _SOCKET_SOCKET_SENDALL_METHODDEF \ + {"sendall", _PyCFunction_CAST(_socket_socket_sendall), METH_FASTCALL, _socket_socket_sendall__doc__}, + +static PyObject * +_socket_socket_sendall_impl(PySocketSockObject *s, Py_buffer *pbuf, + int flags); + +static PyObject * +_socket_socket_sendall(PyObject *s, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + Py_buffer pbuf = {NULL, NULL}; + int flags = 0; + + if (!_PyArg_CheckPositional("sendall", nargs, 1, 2)) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &pbuf, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + flags = PyLong_AsInt(args[1]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _socket_socket_sendall_impl((PySocketSockObject *)s, &pbuf, flags); + +exit: + /* Cleanup for pbuf */ + if (pbuf.obj) { + PyBuffer_Release(&pbuf); + } + + return return_value; +} + +#if defined(CMSG_LEN) + +PyDoc_STRVAR(_socket_socket_sendmsg__doc__, +"sendmsg($self, buffers, ancdata=(), flags=0, address=None, /)\n" +"--\n" +"\n" +"Send normal and ancillary data to the socket.\n" +"\n" +"It gathering the non-ancillary data from a series of buffers\n" +"and concatenating it into a single message.\n" +"The buffers argument specifies the non-ancillary\n" +"data as an iterable of bytes-like objects (e.g. bytes objects).\n" +"The ancdata argument specifies the ancillary data (control messages)\n" +"as an iterable of zero or more tuples (cmsg_level, cmsg_type,\n" +"cmsg_data), where cmsg_level and cmsg_type are integers specifying\n" +"the protocol level and protocol-specific type respectively, and\n" +"cmsg_data is a bytes-like object holding the associated data. The\n" +"flags argument defaults to 0 and has the same meaning as for send().\n" +"If address is supplied and not None, it sets a destination address\n" +"for the message. The return value is the number of bytes of\n" +"non-ancillary data sent."); + +#define _SOCKET_SOCKET_SENDMSG_METHODDEF \ + {"sendmsg", _PyCFunction_CAST(_socket_socket_sendmsg), METH_FASTCALL, _socket_socket_sendmsg__doc__}, + +static PyObject * +_socket_socket_sendmsg_impl(PySocketSockObject *s, PyObject *data_arg, + PyObject *cmsg_arg, int flags, + PyObject *addr_arg); + +static PyObject * +_socket_socket_sendmsg(PyObject *s, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *data_arg; + PyObject *cmsg_arg = NULL; + int flags = 0; + PyObject *addr_arg = NULL; + + if (!_PyArg_CheckPositional("sendmsg", nargs, 1, 4)) { + goto exit; + } + data_arg = args[0]; + if (nargs < 2) { + goto skip_optional; + } + cmsg_arg = args[1]; + if (nargs < 3) { + goto skip_optional; + } + flags = PyLong_AsInt(args[2]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 4) { + goto skip_optional; + } + addr_arg = args[3]; +skip_optional: + return_value = _socket_socket_sendmsg_impl((PySocketSockObject *)s, data_arg, cmsg_arg, flags, addr_arg); + +exit: + return return_value; +} + +#endif /* defined(CMSG_LEN) */ + +#if defined(HAVE_SOCKADDR_ALG) + +PyDoc_STRVAR(_socket_socket_sendmsg_afalg__doc__, +"sendmsg_afalg($self, /, msg=, *, op=,\n" +" iv=, assoclen=, flags=0)\n" +"--\n" +"\n" +"Set operation mode, IV and associated data length.\n" +"\n" +"For an AF_ALG operation socket."); + +#define _SOCKET_SOCKET_SENDMSG_AFALG_METHODDEF \ + {"sendmsg_afalg", _PyCFunction_CAST(_socket_socket_sendmsg_afalg), METH_FASTCALL|METH_KEYWORDS, _socket_socket_sendmsg_afalg__doc__}, + +static PyObject * +_socket_socket_sendmsg_afalg_impl(PySocketSockObject *self, + PyObject *data_arg, PyObject *opobj, + Py_buffer *iv, PyObject *assoclenobj, + int flags); + +static PyObject * +_socket_socket_sendmsg_afalg(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 5 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(msg), &_Py_ID(op), &_Py_ID(iv), &_Py_ID(assoclen), &_Py_ID(flags), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"msg", "op", "iv", "assoclen", "flags", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "sendmsg_afalg", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *data_arg = NULL; + PyObject *opobj = NULL; + Py_buffer iv = {NULL, NULL}; + PyObject *assoclenobj = NULL; + int flags = 0; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + data_arg = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[1]) { + if (!PyLong_Check(args[1])) { + _PyArg_BadArgument("sendmsg_afalg", "argument 'op'", "int", args[1]); + goto exit; + } + opobj = args[1]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[2]) { + if (PyObject_GetBuffer(args[2], &iv, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[3]) { + if (!PyLong_Check(args[3])) { + _PyArg_BadArgument("sendmsg_afalg", "argument 'assoclen'", "int", args[3]); + goto exit; + } + assoclenobj = args[3]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + flags = PyLong_AsInt(args[4]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_kwonly: + return_value = _socket_socket_sendmsg_afalg_impl((PySocketSockObject *)self, data_arg, opobj, &iv, assoclenobj, flags); + +exit: + /* Cleanup for iv */ + if (iv.obj) { + PyBuffer_Release(&iv); + } + + return return_value; +} + +#endif /* defined(HAVE_SOCKADDR_ALG) */ + +#if defined(HAVE_SHUTDOWN) + +PyDoc_STRVAR(_socket_socket_shutdown__doc__, +"shutdown($self, flag, /)\n" "--\n" "\n" -"Send a data string to the socket.\n" +"Shut down one or both halves of the connection.\n" "\n" -"For the optional flags argument, see the Unix manual.\n" -"This calls send() repeatedly until all data is sent.\n" -"If an error occurs, it\'s impossible to tell how much data has been\n" -"sent."); +"Shut down the reading side of the socket (flag == SHUT_RD), the\n" +"writing side of the socket (flag == SHUT_WR), or both ends (flag ==\n" +"SHUT_RDWR)."); -#define _SOCKET_SOCKET_SENDALL_METHODDEF \ - {"sendall", _PyCFunction_CAST(_socket_socket_sendall), METH_FASTCALL, _socket_socket_sendall__doc__}, +#define _SOCKET_SOCKET_SHUTDOWN_METHODDEF \ + {"shutdown", (PyCFunction)_socket_socket_shutdown, METH_O, _socket_socket_shutdown__doc__}, static PyObject * -_socket_socket_sendall_impl(PySocketSockObject *s, Py_buffer *pbuf, - int flags); +_socket_socket_shutdown_impl(PySocketSockObject *s, PyObject *arg); static PyObject * -_socket_socket_sendall(PyObject *s, PyObject *const *args, Py_ssize_t nargs) +_socket_socket_shutdown(PyObject *s, PyObject *arg) { PyObject *return_value = NULL; - Py_buffer pbuf = {NULL, NULL}; - int flags = 0; - - if (!_PyArg_CheckPositional("sendall", nargs, 1, 2)) { - goto exit; - } - if (PyObject_GetBuffer(args[0], &pbuf, PyBUF_SIMPLE) != 0) { - goto exit; - } - if (nargs < 2) { - goto skip_optional; - } - flags = PyLong_AsInt(args[1]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional: - return_value = _socket_socket_sendall_impl((PySocketSockObject *)s, &pbuf, flags); -exit: - /* Cleanup for pbuf */ - if (pbuf.obj) { - PyBuffer_Release(&pbuf); - } + return_value = _socket_socket_shutdown_impl((PySocketSockObject *)s, arg); return return_value; } -#if defined(CMSG_LEN) +#endif /* defined(HAVE_SHUTDOWN) */ -PyDoc_STRVAR(_socket_socket_sendmsg__doc__, -"sendmsg($self, buffers, ancdata=, flags=0,\n" -" address=, /)\n" +#if defined(MS_WINDOWS) + +PyDoc_STRVAR(_socket_socket_share__doc__, +"share($self, process_id, /)\n" "--\n" "\n" -"Send normal and ancillary data to the socket.\n" +"Share the socket with another process.\n" "\n" -"It gathering the non-ancillary data from a series of buffers\n" -"and concatenating it into a single message.\n" -"The buffers argument specifies the non-ancillary\n" -"data as an iterable of bytes-like objects (e.g. bytes objects).\n" -"The ancdata argument specifies the ancillary data (control messages)\n" -"as an iterable of zero or more tuples (cmsg_level, cmsg_type,\n" -"cmsg_data), where cmsg_level and cmsg_type are integers specifying\n" -"the protocol level and protocol-specific type respectively, and\n" -"cmsg_data is a bytes-like object holding the associated data. The\n" -"flags argument defaults to 0 and has the same meaning as for send().\n" -"If address is supplied and not None, it sets a destination address\n" -"for the message. The return value is the number of bytes of\n" -"non-ancillary data sent."); +"The target process id must be provided and the resulting bytes\n" +"object passed to the target process. There the shared socket can be\n" +"instantiated by calling socket.fromshare()."); -#define _SOCKET_SOCKET_SENDMSG_METHODDEF \ - {"sendmsg", _PyCFunction_CAST(_socket_socket_sendmsg), METH_FASTCALL, _socket_socket_sendmsg__doc__}, +#define _SOCKET_SOCKET_SHARE_METHODDEF \ + {"share", (PyCFunction)_socket_socket_share, METH_O, _socket_socket_share__doc__}, static PyObject * -_socket_socket_sendmsg_impl(PySocketSockObject *s, PyObject *data_arg, - PyObject *cmsg_arg, int flags, - PyObject *addr_arg); +_socket_socket_share_impl(PySocketSockObject *s, unsigned int processId); static PyObject * -_socket_socket_sendmsg(PyObject *s, PyObject *const *args, Py_ssize_t nargs) +_socket_socket_share(PyObject *s, PyObject *arg) { PyObject *return_value = NULL; - PyObject *data_arg; - PyObject *cmsg_arg = NULL; - int flags = 0; - PyObject *addr_arg = NULL; - - if (!_PyArg_CheckPositional("sendmsg", nargs, 1, 4)) { - goto exit; - } - data_arg = args[0]; - if (nargs < 2) { - goto skip_optional; - } - cmsg_arg = args[1]; - if (nargs < 3) { - goto skip_optional; - } - flags = PyLong_AsInt(args[2]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } - if (nargs < 4) { - goto skip_optional; + unsigned int processId; + + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(arg, &processId, sizeof(unsigned int), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(unsigned int)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } } - addr_arg = args[3]; -skip_optional: - return_value = _socket_socket_sendmsg_impl((PySocketSockObject *)s, data_arg, cmsg_arg, flags, addr_arg); + return_value = _socket_socket_share_impl((PySocketSockObject *)s, processId); exit: return return_value; } -#endif /* defined(CMSG_LEN) */ +#endif /* defined(MS_WINDOWS) */ static int sock_initobj_impl(PySocketSockObject *self, int family, int type, int proto, @@ -282,6 +1371,321 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwargs) return return_value; } +#if defined(HAVE_GETHOSTNAME) + +PyDoc_STRVAR(_socket_gethostname__doc__, +"gethostname($module, /)\n" +"--\n" +"\n" +"Return the current host name."); + +#define _SOCKET_GETHOSTNAME_METHODDEF \ + {"gethostname", (PyCFunction)_socket_gethostname, METH_NOARGS, _socket_gethostname__doc__}, + +static PyObject * +_socket_gethostname_impl(PyObject *module); + +static PyObject * +_socket_gethostname(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _socket_gethostname_impl(module); +} + +#endif /* defined(HAVE_GETHOSTNAME) */ + +#if defined(HAVE_SETHOSTNAME) + +PyDoc_STRVAR(_socket_sethostname__doc__, +"sethostname($module, name, /)\n" +"--\n" +"\n" +"Set the hostname to name."); + +#define _SOCKET_SETHOSTNAME_METHODDEF \ + {"sethostname", (PyCFunction)_socket_sethostname, METH_O, _socket_sethostname__doc__}, + +#endif /* defined(HAVE_SETHOSTNAME) */ + +#if defined(HAVE_GETADDRINFO) + +PyDoc_STRVAR(_socket_gethostbyname__doc__, +"gethostbyname($module, host, /)\n" +"--\n" +"\n" +"Return the IP address for a host.\n" +"\n" +"The address is a string of the form \'255.255.255.255\'."); + +#define _SOCKET_GETHOSTBYNAME_METHODDEF \ + {"gethostbyname", (PyCFunction)_socket_gethostbyname, METH_O, _socket_gethostbyname__doc__}, + +#endif /* defined(HAVE_GETADDRINFO) */ + +#if (defined(HAVE_GETHOSTBYNAME_R) || defined (HAVE_GETHOSTBYNAME)) + +PyDoc_STRVAR(_socket_gethostbyname_ex__doc__, +"gethostbyname_ex($module, host, /)\n" +"--\n" +"\n" +"Map a host name to its IP number.\n" +"\n" +"Return the true host name, a list of aliases, and a list of IP\n" +"addresses, which are strings of the form \'255.255.255.255\'."); + +#define _SOCKET_GETHOSTBYNAME_EX_METHODDEF \ + {"gethostbyname_ex", (PyCFunction)_socket_gethostbyname_ex, METH_O, _socket_gethostbyname_ex__doc__}, + +#endif /* (defined(HAVE_GETHOSTBYNAME_R) || defined (HAVE_GETHOSTBYNAME)) */ + +#if (defined(HAVE_GETHOSTBYNAME_R) || defined (HAVE_GETHOSTBYADDR)) + +PyDoc_STRVAR(_socket_gethostbyaddr__doc__, +"gethostbyaddr($module, host, /)\n" +"--\n" +"\n" +"Map an IP number or host name to the true host name and addresses.\n" +"\n" +"Return the true host name, a list of aliases, and a list of IP\n" +"addresses. The host argument is a string giving a host name or IP\n" +"number."); + +#define _SOCKET_GETHOSTBYADDR_METHODDEF \ + {"gethostbyaddr", (PyCFunction)_socket_gethostbyaddr, METH_O, _socket_gethostbyaddr__doc__}, + +#endif /* (defined(HAVE_GETHOSTBYNAME_R) || defined (HAVE_GETHOSTBYADDR)) */ + +#if defined(HAVE_GETSERVBYNAME) + +PyDoc_STRVAR(_socket_getservbyname__doc__, +"getservbyname($module, servicename, protocolname=, /)\n" +"--\n" +"\n" +"Return a port number from a service name and protocol name.\n" +"\n" +"The optional protocol name, if given, should be \'tcp\' or \'udp\',\n" +"otherwise any protocol will match."); + +#define _SOCKET_GETSERVBYNAME_METHODDEF \ + {"getservbyname", _PyCFunction_CAST(_socket_getservbyname), METH_FASTCALL, _socket_getservbyname__doc__}, + +static PyObject * +_socket_getservbyname_impl(PyObject *module, const char *name, + const char *proto); + +static PyObject * +_socket_getservbyname(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + const char *name; + const char *proto = NULL; + + if (!_PyArg_CheckPositional("getservbyname", nargs, 1, 2)) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("getservbyname", "argument 1", "str", args[0]); + goto exit; + } + name = _PyUnicode_AsUTF8NoNUL(args[0]); + if (name == NULL) { + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("getservbyname", "argument 2", "str", args[1]); + goto exit; + } + proto = _PyUnicode_AsUTF8NoNUL(args[1]); + if (proto == NULL) { + goto exit; + } +skip_optional: + return_value = _socket_getservbyname_impl(module, name, proto); + +exit: + return return_value; +} + +#endif /* defined(HAVE_GETSERVBYNAME) */ + +#if defined(HAVE_GETSERVBYPORT) + +PyDoc_STRVAR(_socket_getservbyport__doc__, +"getservbyport($module, port, protocolname=, /)\n" +"--\n" +"\n" +"Return the service name from a port number and protocol name.\n" +"\n" +"The optional protocol name, if given, should be \'tcp\' or \'udp\',\n" +"otherwise any protocol will match."); + +#define _SOCKET_GETSERVBYPORT_METHODDEF \ + {"getservbyport", _PyCFunction_CAST(_socket_getservbyport), METH_FASTCALL, _socket_getservbyport__doc__}, + +static PyObject * +_socket_getservbyport_impl(PyObject *module, int port, const char *proto); + +static PyObject * +_socket_getservbyport(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int port; + const char *proto = NULL; + + if (!_PyArg_CheckPositional("getservbyport", nargs, 1, 2)) { + goto exit; + } + port = PyLong_AsInt(args[0]); + if (port == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("getservbyport", "argument 2", "str", args[1]); + goto exit; + } + proto = _PyUnicode_AsUTF8NoNUL(args[1]); + if (proto == NULL) { + goto exit; + } +skip_optional: + return_value = _socket_getservbyport_impl(module, port, proto); + +exit: + return return_value; +} + +#endif /* defined(HAVE_GETSERVBYPORT) */ + +#if defined(HAVE_GETPROTOBYNAME) + +PyDoc_STRVAR(_socket_getprotobyname__doc__, +"getprotobyname($module, name, /)\n" +"--\n" +"\n" +"Return the protocol number for the named protocol."); + +#define _SOCKET_GETPROTOBYNAME_METHODDEF \ + {"getprotobyname", (PyCFunction)_socket_getprotobyname, METH_O, _socket_getprotobyname__doc__}, + +static PyObject * +_socket_getprotobyname_impl(PyObject *module, const char *name); + +static PyObject * +_socket_getprotobyname(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + const char *name; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("getprotobyname", "argument", "str", arg); + goto exit; + } + name = _PyUnicode_AsUTF8NoNUL(arg); + if (name == NULL) { + goto exit; + } + return_value = _socket_getprotobyname_impl(module, name); + +exit: + return return_value; +} + +#endif /* defined(HAVE_GETPROTOBYNAME) */ + +PyDoc_STRVAR(_socket_close__doc__, +"close($module, fd, /)\n" +"--\n" +"\n" +"Close a socket fd.\n" +"\n" +"This is like os.close(), but for sockets; on some platforms os.close()\n" +"won\'t work for socket file descriptors."); + +#define _SOCKET_CLOSE_METHODDEF \ + {"close", (PyCFunction)_socket_close, METH_O, _socket_close__doc__}, + +#if !defined(NO_DUP) + +PyDoc_STRVAR(_socket_dup__doc__, +"dup($module, fd, /)\n" +"--\n" +"\n" +"Duplicate a socket descriptor.\n" +"\n" +"The new descriptor is non-inheritable. This is like os.dup(), but for\n" +"sockets; on some platforms os.dup() won\'t work for socket file\n" +"descriptors."); + +#define _SOCKET_DUP_METHODDEF \ + {"dup", (PyCFunction)_socket_dup, METH_O, _socket_dup__doc__}, + +#endif /* !defined(NO_DUP) */ + +#if defined(HAVE_SOCKETPAIR) + +PyDoc_STRVAR(_socket_socketpair__doc__, +"socketpair($module, family=AF_UNIX, type=SOCK_STREAM, proto=0, /)\n" +"--\n" +"\n" +"Create a pair of connected socket objects.\n" +"\n" +"The sockets are returned by the platform socketpair() function. The\n" +"arguments are the same as for socket(), except that the default\n" +"family is AF_UNIX if defined on the platform; otherwise, the default\n" +"is AF_INET."); + +#define _SOCKET_SOCKETPAIR_METHODDEF \ + {"socketpair", _PyCFunction_CAST(_socket_socketpair), METH_FASTCALL, _socket_socketpair__doc__}, + +static PyObject * +_socket_socketpair_impl(PyObject *module, int family, int type, int proto); + +static PyObject * +_socket_socketpair(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int family = SOCKETPAIR_DEFAULT_FAMILY; + int type = SOCK_STREAM; + int proto = 0; + + if (!_PyArg_CheckPositional("socketpair", nargs, 0, 3)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + family = PyLong_AsInt(args[0]); + if (family == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 2) { + goto skip_optional; + } + type = PyLong_AsInt(args[1]); + if (type == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + proto = PyLong_AsInt(args[2]); + if (proto == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional: + return_value = _socket_socketpair_impl(module, family, type, proto); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SOCKETPAIR) */ + PyDoc_STRVAR(_socket_ntohs__doc__, "ntohs($module, integer, /)\n" "--\n" @@ -412,15 +1816,10 @@ _socket_inet_aton(PyObject *module, PyObject *arg) _PyArg_BadArgument("inet_aton", "argument", "str", arg); goto exit; } - Py_ssize_t ip_addr_length; - ip_addr = PyUnicode_AsUTF8AndSize(arg, &ip_addr_length); + ip_addr = _PyUnicode_AsUTF8NoNUL(arg); if (ip_addr == NULL) { goto exit; } - if (strlen(ip_addr) != (size_t)ip_addr_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = _socket_inet_aton_impl(module, ip_addr); exit: @@ -463,7 +1862,297 @@ _socket_inet_ntoa(PyObject *module, PyObject *arg) #endif /* defined(HAVE_INET_NTOA) */ -#if (defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS)) +#if defined(HAVE_INET_PTON) + +PyDoc_STRVAR(_socket_inet_pton__doc__, +"inet_pton($module, af, ip, /)\n" +"--\n" +"\n" +"Convert an IP address from string format to a packed string.\n" +"\n" +"The string is suitable for use with low-level network functions."); + +#define _SOCKET_INET_PTON_METHODDEF \ + {"inet_pton", _PyCFunction_CAST(_socket_inet_pton), METH_FASTCALL, _socket_inet_pton__doc__}, + +static PyObject * +_socket_inet_pton_impl(PyObject *module, int af, const char *ip); + +static PyObject * +_socket_inet_pton(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int af; + const char *ip; + + if (!_PyArg_CheckPositional("inet_pton", nargs, 2, 2)) { + goto exit; + } + af = PyLong_AsInt(args[0]); + if (af == -1 && PyErr_Occurred()) { + goto exit; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("inet_pton", "argument 2", "str", args[1]); + goto exit; + } + ip = _PyUnicode_AsUTF8NoNUL(args[1]); + if (ip == NULL) { + goto exit; + } + return_value = _socket_inet_pton_impl(module, af, ip); + +exit: + return return_value; +} + +#endif /* defined(HAVE_INET_PTON) */ + +#if defined(HAVE_INET_PTON) + +PyDoc_STRVAR(_socket_inet_ntop__doc__, +"inet_ntop($module, af, packed_ip, /)\n" +"--\n" +"\n" +"Convert a packed IP address of the given family to string format."); + +#define _SOCKET_INET_NTOP_METHODDEF \ + {"inet_ntop", _PyCFunction_CAST(_socket_inet_ntop), METH_FASTCALL, _socket_inet_ntop__doc__}, + +static PyObject * +_socket_inet_ntop_impl(PyObject *module, int af, Py_buffer *packed_ip); + +static PyObject * +_socket_inet_ntop(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int af; + Py_buffer packed_ip = {NULL, NULL}; + + if (!_PyArg_CheckPositional("inet_ntop", nargs, 2, 2)) { + goto exit; + } + af = PyLong_AsInt(args[0]); + if (af == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyObject_GetBuffer(args[1], &packed_ip, PyBUF_SIMPLE) != 0) { + goto exit; + } + return_value = _socket_inet_ntop_impl(module, af, &packed_ip); + +exit: + /* Cleanup for packed_ip */ + if (packed_ip.obj) { + PyBuffer_Release(&packed_ip); + } + + return return_value; +} + +#endif /* defined(HAVE_INET_PTON) */ + +#if defined(HAVE_GETADDRINFO) + +PyDoc_STRVAR(_socket_getaddrinfo__doc__, +"getaddrinfo($module, /, host, port, family=AF_UNSPEC, type=0, proto=0,\n" +" flags=0)\n" +"--\n" +"\n" +"Resolve host and port into a list of 5-tuples.\n" +"\n" +"Each tuple is (family, type, proto, canonname, sockaddr)."); + +#define _SOCKET_GETADDRINFO_METHODDEF \ + {"getaddrinfo", _PyCFunction_CAST(_socket_getaddrinfo), METH_FASTCALL|METH_KEYWORDS, _socket_getaddrinfo__doc__}, + +static PyObject * +_socket_getaddrinfo_impl(PyObject *module, PyObject *hobj, PyObject *pobj, + int family, int socktype, int protocol, int flags); + +static PyObject * +_socket_getaddrinfo(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 6 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(host), &_Py_ID(port), &_Py_ID(family), &_Py_ID(type), &_Py_ID(proto), &_Py_ID(flags), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"host", "port", "family", "type", "proto", "flags", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "getaddrinfo", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[6]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + PyObject *hobj; + PyObject *pobj; + int family = AF_UNSPEC; + int socktype = 0; + int protocol = 0; + int flags = 0; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 2, /*maxpos*/ 6, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + hobj = args[0]; + pobj = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + family = PyLong_AsInt(args[2]); + if (family == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[3]) { + socktype = PyLong_AsInt(args[3]); + if (socktype == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[4]) { + protocol = PyLong_AsInt(args[4]); + if (protocol == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + flags = PyLong_AsInt(args[5]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: + return_value = _socket_getaddrinfo_impl(module, hobj, pobj, family, socktype, protocol, flags); + +exit: + return return_value; +} + +#endif /* defined(HAVE_GETADDRINFO) */ + +#if defined(HAVE_GETNAMEINFO) + +PyDoc_STRVAR(_socket_getnameinfo__doc__, +"getnameinfo($module, sockaddr, flags, /)\n" +"--\n" +"\n" +"Get host and port for a sockaddr."); + +#define _SOCKET_GETNAMEINFO_METHODDEF \ + {"getnameinfo", _PyCFunction_CAST(_socket_getnameinfo), METH_FASTCALL, _socket_getnameinfo__doc__}, + +static PyObject * +_socket_getnameinfo_impl(PyObject *module, PyObject *sa, int flags); + +static PyObject * +_socket_getnameinfo(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *sa; + int flags; + + if (!_PyArg_CheckPositional("getnameinfo", nargs, 2, 2)) { + goto exit; + } + sa = args[0]; + flags = PyLong_AsInt(args[1]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = _socket_getnameinfo_impl(module, sa, flags); + +exit: + return return_value; +} + +#endif /* defined(HAVE_GETNAMEINFO) */ + +PyDoc_STRVAR(_socket_getdefaulttimeout__doc__, +"getdefaulttimeout($module, /)\n" +"--\n" +"\n" +"Return the default timeout in seconds for new socket objects.\n" +"\n" +"A value of None indicates that new socket objects have no timeout.\n" +"When the socket module is first imported, the default is None."); + +#define _SOCKET_GETDEFAULTTIMEOUT_METHODDEF \ + {"getdefaulttimeout", (PyCFunction)_socket_getdefaulttimeout, METH_NOARGS, _socket_getdefaulttimeout__doc__}, + +static PyObject * +_socket_getdefaulttimeout_impl(PyObject *module); + +static PyObject * +_socket_getdefaulttimeout(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _socket_getdefaulttimeout_impl(module); +} + +PyDoc_STRVAR(_socket_setdefaulttimeout__doc__, +"setdefaulttimeout($module, timeout, /)\n" +"--\n" +"\n" +"Set the default timeout in seconds for new socket objects.\n" +"\n" +"A value of None indicates that new socket objects have no timeout.\n" +"When the socket module is first imported, the default is None."); + +#define _SOCKET_SETDEFAULTTIMEOUT_METHODDEF \ + {"setdefaulttimeout", (PyCFunction)_socket_setdefaulttimeout, METH_O, _socket_setdefaulttimeout__doc__}, + +#if (defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS_DESKTOP)) + +PyDoc_STRVAR(_socket_if_nameindex__doc__, +"if_nameindex($module, /)\n" +"--\n" +"\n" +"Return a list of network interface information (index, name) tuples."); + +#define _SOCKET_IF_NAMEINDEX_METHODDEF \ + {"if_nameindex", (PyCFunction)_socket_if_nameindex, METH_NOARGS, _socket_if_nameindex__doc__}, + +static PyObject * +_socket_if_nameindex_impl(PyObject *module); + +static PyObject * +_socket_if_nameindex(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _socket_if_nameindex_impl(module); +} + +#endif /* (defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS_DESKTOP)) */ + +#if (defined(_Py_HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS_DESKTOP)) PyDoc_STRVAR(_socket_if_nametoindex__doc__, "if_nametoindex($module, oname, /)\n" @@ -495,9 +2184,9 @@ _socket_if_nametoindex(PyObject *module, PyObject *arg) return return_value; } -#endif /* (defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS)) */ +#endif /* (defined(_Py_HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS_DESKTOP)) */ -#if (defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS)) +#if (defined(_Py_HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)) PyDoc_STRVAR(_socket_if_indextoname__doc__, "if_indextoname($module, if_index, /)\n" @@ -526,16 +2215,225 @@ _socket_if_indextoname(PyObject *module, PyObject *arg) return return_value; } -#endif /* (defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS)) */ +#endif /* (defined(_Py_HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)) */ + +#if defined(CMSG_LEN) + +PyDoc_STRVAR(_socket_CMSG_LEN__doc__, +"CMSG_LEN($module, length, /)\n" +"--\n" +"\n" +"Return the total length of an ancillary data item with associated data.\n" +"\n" +"The associated data has the given length. This value can often be\n" +"used as the buffer size for recvmsg() to receive a single item of\n" +"ancillary data, but RFC 3542 requires portable applications to use\n" +"CMSG_SPACE() and thus include space for padding, even when the item\n" +"will be the last in the buffer. Raises OverflowError if length is\n" +"outside the permissible range of values."); + +#define _SOCKET_CMSG_LEN_METHODDEF \ + {"CMSG_LEN", (PyCFunction)_socket_CMSG_LEN, METH_O, _socket_CMSG_LEN__doc__}, + +static PyObject * +_socket_CMSG_LEN_impl(PyObject *module, Py_ssize_t length); + +static PyObject * +_socket_CMSG_LEN(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + Py_ssize_t length; + + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(arg); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + length = ival; + } + return_value = _socket_CMSG_LEN_impl(module, length); + +exit: + return return_value; +} + +#endif /* defined(CMSG_LEN) */ + +#if defined(CMSG_LEN) && defined(CMSG_SPACE) + +PyDoc_STRVAR(_socket_CMSG_SPACE__doc__, +"CMSG_SPACE($module, length, /)\n" +"--\n" +"\n" +"Return the buffer size needed to receive an ancillary data item.\n" +"\n" +"The item has associated data of the given length, and the size\n" +"includes any trailing padding. The buffer space needed to receive\n" +"multiple items is the sum of the CMSG_SPACE() values for their\n" +"associated data lengths. Raises OverflowError if length is outside\n" +"the permissible range of values."); + +#define _SOCKET_CMSG_SPACE_METHODDEF \ + {"CMSG_SPACE", (PyCFunction)_socket_CMSG_SPACE, METH_O, _socket_CMSG_SPACE__doc__}, + +static PyObject * +_socket_CMSG_SPACE_impl(PyObject *module, Py_ssize_t length); + +static PyObject * +_socket_CMSG_SPACE(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + Py_ssize_t length; + + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(arg); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + length = ival; + } + return_value = _socket_CMSG_SPACE_impl(module, length); + +exit: + return return_value; +} + +#endif /* defined(CMSG_LEN) && defined(CMSG_SPACE) */ + +#ifndef _SOCKET_SOCKET__ACCEPT_METHODDEF + #define _SOCKET_SOCKET__ACCEPT_METHODDEF +#endif /* !defined(_SOCKET_SOCKET__ACCEPT_METHODDEF) */ + +#ifndef _SOCKET_SOCKET_BIND_METHODDEF + #define _SOCKET_SOCKET_BIND_METHODDEF +#endif /* !defined(_SOCKET_SOCKET_BIND_METHODDEF) */ + +#ifndef _SOCKET_SOCKET_CONNECT_METHODDEF + #define _SOCKET_SOCKET_CONNECT_METHODDEF +#endif /* !defined(_SOCKET_SOCKET_CONNECT_METHODDEF) */ + +#ifndef _SOCKET_SOCKET_CONNECT_EX_METHODDEF + #define _SOCKET_SOCKET_CONNECT_EX_METHODDEF +#endif /* !defined(_SOCKET_SOCKET_CONNECT_EX_METHODDEF) */ + +#ifndef _SOCKET_SOCKET_GETSOCKNAME_METHODDEF + #define _SOCKET_SOCKET_GETSOCKNAME_METHODDEF +#endif /* !defined(_SOCKET_SOCKET_GETSOCKNAME_METHODDEF) */ + +#ifndef _SOCKET_SOCKET_GETPEERNAME_METHODDEF + #define _SOCKET_SOCKET_GETPEERNAME_METHODDEF +#endif /* !defined(_SOCKET_SOCKET_GETPEERNAME_METHODDEF) */ + +#ifndef _SOCKET_SOCKET_LISTEN_METHODDEF + #define _SOCKET_SOCKET_LISTEN_METHODDEF +#endif /* !defined(_SOCKET_SOCKET_LISTEN_METHODDEF) */ + +#ifndef _SOCKET_SOCKET_RECVFROM_METHODDEF + #define _SOCKET_SOCKET_RECVFROM_METHODDEF +#endif /* !defined(_SOCKET_SOCKET_RECVFROM_METHODDEF) */ + +#ifndef _SOCKET_SOCKET_RECVFROM_INTO_METHODDEF + #define _SOCKET_SOCKET_RECVFROM_INTO_METHODDEF +#endif /* !defined(_SOCKET_SOCKET_RECVFROM_INTO_METHODDEF) */ + +#ifndef _SOCKET_SOCKET_RECVMSG_METHODDEF + #define _SOCKET_SOCKET_RECVMSG_METHODDEF +#endif /* !defined(_SOCKET_SOCKET_RECVMSG_METHODDEF) */ + +#ifndef _SOCKET_SOCKET_RECVMSG_INTO_METHODDEF + #define _SOCKET_SOCKET_RECVMSG_INTO_METHODDEF +#endif /* !defined(_SOCKET_SOCKET_RECVMSG_INTO_METHODDEF) */ #ifndef _SOCKET_SOCKET_SENDMSG_METHODDEF #define _SOCKET_SOCKET_SENDMSG_METHODDEF #endif /* !defined(_SOCKET_SOCKET_SENDMSG_METHODDEF) */ +#ifndef _SOCKET_SOCKET_SENDMSG_AFALG_METHODDEF + #define _SOCKET_SOCKET_SENDMSG_AFALG_METHODDEF +#endif /* !defined(_SOCKET_SOCKET_SENDMSG_AFALG_METHODDEF) */ + +#ifndef _SOCKET_SOCKET_SHUTDOWN_METHODDEF + #define _SOCKET_SOCKET_SHUTDOWN_METHODDEF +#endif /* !defined(_SOCKET_SOCKET_SHUTDOWN_METHODDEF) */ + +#ifndef _SOCKET_SOCKET_SHARE_METHODDEF + #define _SOCKET_SOCKET_SHARE_METHODDEF +#endif /* !defined(_SOCKET_SOCKET_SHARE_METHODDEF) */ + +#ifndef _SOCKET_GETHOSTNAME_METHODDEF + #define _SOCKET_GETHOSTNAME_METHODDEF +#endif /* !defined(_SOCKET_GETHOSTNAME_METHODDEF) */ + +#ifndef _SOCKET_SETHOSTNAME_METHODDEF + #define _SOCKET_SETHOSTNAME_METHODDEF +#endif /* !defined(_SOCKET_SETHOSTNAME_METHODDEF) */ + +#ifndef _SOCKET_GETHOSTBYNAME_METHODDEF + #define _SOCKET_GETHOSTBYNAME_METHODDEF +#endif /* !defined(_SOCKET_GETHOSTBYNAME_METHODDEF) */ + +#ifndef _SOCKET_GETHOSTBYNAME_EX_METHODDEF + #define _SOCKET_GETHOSTBYNAME_EX_METHODDEF +#endif /* !defined(_SOCKET_GETHOSTBYNAME_EX_METHODDEF) */ + +#ifndef _SOCKET_GETHOSTBYADDR_METHODDEF + #define _SOCKET_GETHOSTBYADDR_METHODDEF +#endif /* !defined(_SOCKET_GETHOSTBYADDR_METHODDEF) */ + +#ifndef _SOCKET_GETSERVBYNAME_METHODDEF + #define _SOCKET_GETSERVBYNAME_METHODDEF +#endif /* !defined(_SOCKET_GETSERVBYNAME_METHODDEF) */ + +#ifndef _SOCKET_GETSERVBYPORT_METHODDEF + #define _SOCKET_GETSERVBYPORT_METHODDEF +#endif /* !defined(_SOCKET_GETSERVBYPORT_METHODDEF) */ + +#ifndef _SOCKET_GETPROTOBYNAME_METHODDEF + #define _SOCKET_GETPROTOBYNAME_METHODDEF +#endif /* !defined(_SOCKET_GETPROTOBYNAME_METHODDEF) */ + +#ifndef _SOCKET_DUP_METHODDEF + #define _SOCKET_DUP_METHODDEF +#endif /* !defined(_SOCKET_DUP_METHODDEF) */ + +#ifndef _SOCKET_SOCKETPAIR_METHODDEF + #define _SOCKET_SOCKETPAIR_METHODDEF +#endif /* !defined(_SOCKET_SOCKETPAIR_METHODDEF) */ + #ifndef _SOCKET_INET_NTOA_METHODDEF #define _SOCKET_INET_NTOA_METHODDEF #endif /* !defined(_SOCKET_INET_NTOA_METHODDEF) */ +#ifndef _SOCKET_INET_PTON_METHODDEF + #define _SOCKET_INET_PTON_METHODDEF +#endif /* !defined(_SOCKET_INET_PTON_METHODDEF) */ + +#ifndef _SOCKET_INET_NTOP_METHODDEF + #define _SOCKET_INET_NTOP_METHODDEF +#endif /* !defined(_SOCKET_INET_NTOP_METHODDEF) */ + +#ifndef _SOCKET_GETADDRINFO_METHODDEF + #define _SOCKET_GETADDRINFO_METHODDEF +#endif /* !defined(_SOCKET_GETADDRINFO_METHODDEF) */ + +#ifndef _SOCKET_GETNAMEINFO_METHODDEF + #define _SOCKET_GETNAMEINFO_METHODDEF +#endif /* !defined(_SOCKET_GETNAMEINFO_METHODDEF) */ + +#ifndef _SOCKET_IF_NAMEINDEX_METHODDEF + #define _SOCKET_IF_NAMEINDEX_METHODDEF +#endif /* !defined(_SOCKET_IF_NAMEINDEX_METHODDEF) */ + #ifndef _SOCKET_IF_NAMETOINDEX_METHODDEF #define _SOCKET_IF_NAMETOINDEX_METHODDEF #endif /* !defined(_SOCKET_IF_NAMETOINDEX_METHODDEF) */ @@ -543,4 +2441,12 @@ _socket_if_indextoname(PyObject *module, PyObject *arg) #ifndef _SOCKET_IF_INDEXTONAME_METHODDEF #define _SOCKET_IF_INDEXTONAME_METHODDEF #endif /* !defined(_SOCKET_IF_INDEXTONAME_METHODDEF) */ -/*[clinic end generated code: output=0b1fa78ac6589353 input=a9049054013a1b77]*/ + +#ifndef _SOCKET_CMSG_LEN_METHODDEF + #define _SOCKET_CMSG_LEN_METHODDEF +#endif /* !defined(_SOCKET_CMSG_LEN_METHODDEF) */ + +#ifndef _SOCKET_CMSG_SPACE_METHODDEF + #define _SOCKET_CMSG_SPACE_METHODDEF +#endif /* !defined(_SOCKET_CMSG_SPACE_METHODDEF) */ +/*[clinic end generated code: output=e6e677d3de0c63e4 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/symtablemodule.c.h b/Modules/clinic/symtablemodule.c.h index 00ee4315846b603..2df590875955f36 100644 --- a/Modules/clinic/symtablemodule.c.h +++ b/Modules/clinic/symtablemodule.c.h @@ -7,6 +7,7 @@ preserve # include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(_symtable_symtable__doc__, "symtable($module, source, filename, startstr, /, *, module=None)\n" @@ -75,15 +76,10 @@ _symtable_symtable(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py _PyArg_BadArgument("symtable", "argument 3", "str", args[2]); goto exit; } - Py_ssize_t startstr_length; - startstr = PyUnicode_AsUTF8AndSize(args[2], &startstr_length); + startstr = _PyUnicode_AsUTF8NoNUL(args[2]); if (startstr == NULL) { goto exit; } - if (strlen(startstr) != (size_t)startstr_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!noptargs) { goto skip_optional_kwonly; } @@ -97,4 +93,4 @@ _symtable_symtable(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py return return_value; } -/*[clinic end generated code: output=23523cada784726e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=910e4f6ce98ae0a1 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/syslogmodule.c.h b/Modules/clinic/syslogmodule.c.h index f9034982f3b2c7f..6f878d675045e45 100644 --- a/Modules/clinic/syslogmodule.c.h +++ b/Modules/clinic/syslogmodule.c.h @@ -8,6 +8,7 @@ preserve #endif #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(syslog_openlog__doc__, "openlog($module, /, ident=, logoption=0,\n" @@ -105,35 +106,38 @@ PyDoc_STRVAR(syslog_syslog__doc__, "Send the string message to the system logger."); #define SYSLOG_SYSLOG_METHODDEF \ - {"syslog", (PyCFunction)syslog_syslog, METH_VARARGS, syslog_syslog__doc__}, + {"syslog", _PyCFunction_CAST(syslog_syslog), METH_FASTCALL, syslog_syslog__doc__}, static PyObject * syslog_syslog_impl(PyObject *module, int group_left_1, int priority, const char *message); static PyObject * -syslog_syslog(PyObject *module, PyObject *args) +syslog_syslog(PyObject *module, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int group_left_1 = 0; int priority = LOG_INFO; const char *message; - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "s:syslog", &message)) { - goto exit; - } - break; - case 2: - if (!PyArg_ParseTuple(args, "is:syslog", &priority, &message)) { - goto exit; - } - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "syslog.syslog requires 1 to 2 arguments"); + if (nargs < 1 || nargs > 2) { + PyErr_SetString(PyExc_TypeError, "syslog.syslog requires 1 to 2 arguments"); + goto exit; + } + if (nargs >= 2) { + priority = PyLong_AsInt(args[0]); + if (priority == -1 && PyErr_Occurred()) { goto exit; + } + group_left_1 = 1; + } + if (!PyUnicode_Check(args[nargs - 1])) { + _PyArg_BadArgument("syslog", "argument", "str", args[nargs - 1]); + goto exit; + } + message = _PyUnicode_AsUTF8NoNUL(args[nargs - 1]); + if (message == NULL) { + goto exit; } Py_BEGIN_CRITICAL_SECTION(module); return_value = syslog_syslog_impl(module, group_left_1, priority, message); @@ -265,4 +269,4 @@ syslog_LOG_UPTO(PyObject *module, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=f92ac9948fa6131e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=0c9607f279107505 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/timemodule.c.h b/Modules/clinic/timemodule.c.h index bbc0748f9a9c0dd..a42c1d7905e811d 100644 --- a/Modules/clinic/timemodule.c.h +++ b/Modules/clinic/timemodule.c.h @@ -2,6 +2,58 @@ preserve [clinic start generated code]*/ +#include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() + +PyDoc_STRVAR(time_time__doc__, +"time($module, /)\n" +"--\n" +"\n" +"Return the current time in seconds since the Epoch.\n" +"\n" +"Fractions of a second may be present if the system clock provides\n" +"them."); + +#define TIME_TIME_METHODDEF \ + {"time", (PyCFunction)time_time, METH_NOARGS, time_time__doc__}, + +static double +time_time_impl(PyObject *module); + +static PyObject * +time_time(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + double _return_value; + + _return_value = time_time_impl(module); + if ((_return_value == -1.0) && PyErr_Occurred()) { + goto exit; + } + return_value = PyFloat_FromDouble(_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(time_time_ns__doc__, +"time_ns($module, /)\n" +"--\n" +"\n" +"Return the current time in nanoseconds since the Epoch."); + +#define TIME_TIME_NS_METHODDEF \ + {"time_ns", (PyCFunction)time_time_ns, METH_NOARGS, time_time_ns__doc__}, + +static PyObject * +time_time_ns_impl(PyObject *module); + +static PyObject * +time_time_ns(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return time_time_ns_impl(module); +} + #if defined(HAVE_CLOCK_GETTIME) PyDoc_STRVAR(time_clock_gettime__doc__, @@ -64,6 +116,598 @@ time_clock_gettime_ns(PyObject *module, PyObject *arg) #endif /* defined(HAVE_CLOCK_GETTIME) */ +#if defined(HAVE_CLOCK_SETTIME) + +PyDoc_STRVAR(time_clock_settime__doc__, +"clock_settime($module, clk_id, time, /)\n" +"--\n" +"\n" +"Set the time of the specified clock clk_id."); + +#define TIME_CLOCK_SETTIME_METHODDEF \ + {"clock_settime", _PyCFunction_CAST(time_clock_settime), METH_FASTCALL, time_clock_settime__doc__}, + +static PyObject * +time_clock_settime_impl(PyObject *module, int clk_id, PyObject *obj); + +static PyObject * +time_clock_settime(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int clk_id; + PyObject *obj; + + if (!_PyArg_CheckPositional("clock_settime", nargs, 2, 2)) { + goto exit; + } + clk_id = PyLong_AsInt(args[0]); + if (clk_id == -1 && PyErr_Occurred()) { + goto exit; + } + obj = args[1]; + return_value = time_clock_settime_impl(module, clk_id, obj); + +exit: + return return_value; +} + +#endif /* defined(HAVE_CLOCK_SETTIME) */ + +#if defined(HAVE_CLOCK_SETTIME) + +PyDoc_STRVAR(time_clock_settime_ns__doc__, +"clock_settime_ns($module, clk_id, time, /)\n" +"--\n" +"\n" +"Set the time of the specified clock clk_id with nanoseconds."); + +#define TIME_CLOCK_SETTIME_NS_METHODDEF \ + {"clock_settime_ns", _PyCFunction_CAST(time_clock_settime_ns), METH_FASTCALL, time_clock_settime_ns__doc__}, + +static PyObject * +time_clock_settime_ns_impl(PyObject *module, int clk_id, PyObject *obj); + +static PyObject * +time_clock_settime_ns(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int clk_id; + PyObject *obj; + + if (!_PyArg_CheckPositional("clock_settime_ns", nargs, 2, 2)) { + goto exit; + } + clk_id = PyLong_AsInt(args[0]); + if (clk_id == -1 && PyErr_Occurred()) { + goto exit; + } + obj = args[1]; + return_value = time_clock_settime_ns_impl(module, clk_id, obj); + +exit: + return return_value; +} + +#endif /* defined(HAVE_CLOCK_SETTIME) */ + +#if defined(HAVE_CLOCK_GETRES) + +PyDoc_STRVAR(time_clock_getres__doc__, +"clock_getres($module, clk_id, /)\n" +"--\n" +"\n" +"Return the resolution (precision) of the specified clock clk_id."); + +#define TIME_CLOCK_GETRES_METHODDEF \ + {"clock_getres", (PyCFunction)time_clock_getres, METH_O, time_clock_getres__doc__}, + +static double +time_clock_getres_impl(PyObject *module, int clk_id); + +static PyObject * +time_clock_getres(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int clk_id; + double _return_value; + + clk_id = PyLong_AsInt(arg); + if (clk_id == -1 && PyErr_Occurred()) { + goto exit; + } + _return_value = time_clock_getres_impl(module, clk_id); + if ((_return_value == -1.0) && PyErr_Occurred()) { + goto exit; + } + return_value = PyFloat_FromDouble(_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_CLOCK_GETRES) */ + +#if defined(HAVE_PTHREAD_GETCPUCLOCKID) + +PyDoc_STRVAR(time_pthread_getcpuclockid__doc__, +"pthread_getcpuclockid($module, thread_id, /)\n" +"--\n" +"\n" +"Return the clk_id of a thread\'s CPU time clock."); + +#define TIME_PTHREAD_GETCPUCLOCKID_METHODDEF \ + {"pthread_getcpuclockid", (PyCFunction)time_pthread_getcpuclockid, METH_O, time_pthread_getcpuclockid__doc__}, + +static PyObject * +time_pthread_getcpuclockid_impl(PyObject *module, unsigned long thread_id); + +static PyObject * +time_pthread_getcpuclockid(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + unsigned long thread_id; + + if (!PyIndex_Check(arg)) { + _PyArg_BadArgument("pthread_getcpuclockid", "argument", "int", arg); + goto exit; + } + { + Py_ssize_t _bytes = PyLong_AsNativeBytes(arg, &thread_id, sizeof(unsigned long), + Py_ASNATIVEBYTES_NATIVE_ENDIAN | + Py_ASNATIVEBYTES_ALLOW_INDEX | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); + if (_bytes < 0) { + goto exit; + } + if ((size_t)_bytes > sizeof(unsigned long)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "integer value out of range", 1) < 0) + { + goto exit; + } + } + } + return_value = time_pthread_getcpuclockid_impl(module, thread_id); + +exit: + return return_value; +} + +#endif /* defined(HAVE_PTHREAD_GETCPUCLOCKID) */ + +PyDoc_STRVAR(time_sleep__doc__, +"sleep($module, seconds, /)\n" +"--\n" +"\n" +"Delay execution for a given number of seconds.\n" +"\n" +"The argument may be a floating-point number for subsecond precision."); + +#define TIME_SLEEP_METHODDEF \ + {"sleep", (PyCFunction)time_sleep, METH_O, time_sleep__doc__}, + +PyDoc_STRVAR(time_gmtime__doc__, +"gmtime($module, seconds=None, /)\n" +"--\n" +"\n" +"Convert seconds since the Epoch to a time tuple expressing UTC.\n" +"\n" +"That is, Greenwich Mean Time. When \'seconds\' is not passed in, convert\n" +"the current time instead.\n" +"\n" +"If the platform supports the tm_gmtoff and tm_zone, they are available\n" +"as attributes only."); + +#define TIME_GMTIME_METHODDEF \ + {"gmtime", _PyCFunction_CAST(time_gmtime), METH_FASTCALL, time_gmtime__doc__}, + +static PyObject * +time_gmtime_impl(PyObject *module, PyObject *ot); + +static PyObject * +time_gmtime(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *ot = Py_None; + + if (!_PyArg_CheckPositional("gmtime", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + ot = args[0]; +skip_optional: + return_value = time_gmtime_impl(module, ot); + +exit: + return return_value; +} + +PyDoc_STRVAR(time_localtime__doc__, +"localtime($module, seconds=None, /)\n" +"--\n" +"\n" +"Convert seconds since the Epoch to a time tuple expressing local time.\n" +"\n" +"When \'seconds\' is not passed in, convert the current time instead."); + +#define TIME_LOCALTIME_METHODDEF \ + {"localtime", _PyCFunction_CAST(time_localtime), METH_FASTCALL, time_localtime__doc__}, + +static PyObject * +time_localtime_impl(PyObject *module, PyObject *ot); + +static PyObject * +time_localtime(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *ot = Py_None; + + if (!_PyArg_CheckPositional("localtime", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + ot = args[0]; +skip_optional: + return_value = time_localtime_impl(module, ot); + +exit: + return return_value; +} + +PyDoc_STRVAR(time_asctime__doc__, +"asctime($module, time_tuple=, /)\n" +"--\n" +"\n" +"Convert a time tuple to a string, e.g. \'Sat Jun 06 16:26:11 1998\'.\n" +"\n" +"When the time tuple is not present, current time as returned by\n" +"localtime() is used."); + +#define TIME_ASCTIME_METHODDEF \ + {"asctime", _PyCFunction_CAST(time_asctime), METH_FASTCALL, time_asctime__doc__}, + +static PyObject * +time_asctime_impl(PyObject *module, PyObject *tup); + +static PyObject * +time_asctime(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *tup = NULL; + + if (!_PyArg_CheckPositional("asctime", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + tup = args[0]; +skip_optional: + return_value = time_asctime_impl(module, tup); + +exit: + return return_value; +} + +PyDoc_STRVAR(time_ctime__doc__, +"ctime($module, seconds=None, /)\n" +"--\n" +"\n" +"Convert a time in seconds since the Epoch to a string in local time.\n" +"\n" +"This is equivalent to asctime(localtime(seconds)). When \'seconds\' is\n" +"not passed in, convert the current time instead."); + +#define TIME_CTIME_METHODDEF \ + {"ctime", _PyCFunction_CAST(time_ctime), METH_FASTCALL, time_ctime__doc__}, + +static PyObject * +time_ctime_impl(PyObject *module, PyObject *ot); + +static PyObject * +time_ctime(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *ot = Py_None; + + if (!_PyArg_CheckPositional("ctime", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + ot = args[0]; +skip_optional: + return_value = time_ctime_impl(module, ot); + +exit: + return return_value; +} + +#if defined(HAVE_MKTIME) + +PyDoc_STRVAR(time_mktime__doc__, +"mktime($module, time_tuple, /)\n" +"--\n" +"\n" +"Convert a time tuple in local time to seconds since the Epoch.\n" +"\n" +"Note that mktime(gmtime(0)) will not generally return zero for most\n" +"time zones; instead the returned value will either be equal to that of\n" +"the timezone or altzone attributes on the time module."); + +#define TIME_MKTIME_METHODDEF \ + {"mktime", (PyCFunction)time_mktime, METH_O, time_mktime__doc__}, + +#endif /* defined(HAVE_MKTIME) */ + +#if defined(HAVE_WORKING_TZSET) + +PyDoc_STRVAR(time_tzset__doc__, +"tzset($module, /)\n" +"--\n" +"\n" +"Initialize, or reinitialize, the local timezone.\n" +"\n" +"The local timezone is set to the value stored in os.environ[\'TZ\']. The\n" +"TZ environment variable should be specified in standard Unix timezone\n" +"format as documented in the tzset man page (eg. \'US/Eastern\',\n" +"\'Europe/Amsterdam\'). Unknown timezones will silently fall back to UTC.\n" +"If the TZ environment variable is not set, the local timezone is set to\n" +"the systems best guess of wallclock time. Changing the TZ environment\n" +"variable without calling tzset *may* change the local timezone used by\n" +"methods such as localtime, but this behaviour should not be relied on."); + +#define TIME_TZSET_METHODDEF \ + {"tzset", (PyCFunction)time_tzset, METH_NOARGS, time_tzset__doc__}, + +static PyObject * +time_tzset_impl(PyObject *module); + +static PyObject * +time_tzset(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return time_tzset_impl(module); +} + +#endif /* defined(HAVE_WORKING_TZSET) */ + +PyDoc_STRVAR(time_monotonic__doc__, +"monotonic($module, /)\n" +"--\n" +"\n" +"Monotonic clock, cannot go backward."); + +#define TIME_MONOTONIC_METHODDEF \ + {"monotonic", (PyCFunction)time_monotonic, METH_NOARGS, time_monotonic__doc__}, + +static double +time_monotonic_impl(PyObject *module); + +static PyObject * +time_monotonic(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + double _return_value; + + _return_value = time_monotonic_impl(module); + if ((_return_value == -1.0) && PyErr_Occurred()) { + goto exit; + } + return_value = PyFloat_FromDouble(_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(time_monotonic_ns__doc__, +"monotonic_ns($module, /)\n" +"--\n" +"\n" +"Monotonic clock, cannot go backward, as nanoseconds."); + +#define TIME_MONOTONIC_NS_METHODDEF \ + {"monotonic_ns", (PyCFunction)time_monotonic_ns, METH_NOARGS, time_monotonic_ns__doc__}, + +static PyObject * +time_monotonic_ns_impl(PyObject *module); + +static PyObject * +time_monotonic_ns(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return time_monotonic_ns_impl(module); +} + +PyDoc_STRVAR(time_perf_counter__doc__, +"perf_counter($module, /)\n" +"--\n" +"\n" +"Performance counter for benchmarking."); + +#define TIME_PERF_COUNTER_METHODDEF \ + {"perf_counter", (PyCFunction)time_perf_counter, METH_NOARGS, time_perf_counter__doc__}, + +static double +time_perf_counter_impl(PyObject *module); + +static PyObject * +time_perf_counter(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + double _return_value; + + _return_value = time_perf_counter_impl(module); + if ((_return_value == -1.0) && PyErr_Occurred()) { + goto exit; + } + return_value = PyFloat_FromDouble(_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(time_perf_counter_ns__doc__, +"perf_counter_ns($module, /)\n" +"--\n" +"\n" +"Performance counter for benchmarking as nanoseconds."); + +#define TIME_PERF_COUNTER_NS_METHODDEF \ + {"perf_counter_ns", (PyCFunction)time_perf_counter_ns, METH_NOARGS, time_perf_counter_ns__doc__}, + +static PyObject * +time_perf_counter_ns_impl(PyObject *module); + +static PyObject * +time_perf_counter_ns(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return time_perf_counter_ns_impl(module); +} + +PyDoc_STRVAR(time_process_time__doc__, +"process_time($module, /)\n" +"--\n" +"\n" +"Process time for profiling.\n" +"\n" +"That is the sum of the kernel and user-space CPU time."); + +#define TIME_PROCESS_TIME_METHODDEF \ + {"process_time", (PyCFunction)time_process_time, METH_NOARGS, time_process_time__doc__}, + +static double +time_process_time_impl(PyObject *module); + +static PyObject * +time_process_time(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + double _return_value; + + _return_value = time_process_time_impl(module); + if ((_return_value == -1.0) && PyErr_Occurred()) { + goto exit; + } + return_value = PyFloat_FromDouble(_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(time_process_time_ns__doc__, +"process_time_ns($module, /)\n" +"--\n" +"\n" +"Process time for profiling as nanoseconds.\n" +"\n" +"That is the sum of the kernel and user-space CPU time."); + +#define TIME_PROCESS_TIME_NS_METHODDEF \ + {"process_time_ns", (PyCFunction)time_process_time_ns, METH_NOARGS, time_process_time_ns__doc__}, + +static PyObject * +time_process_time_ns_impl(PyObject *module); + +static PyObject * +time_process_time_ns(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return time_process_time_ns_impl(module); +} + +#if defined(HAVE_THREAD_TIME) + +PyDoc_STRVAR(time_thread_time__doc__, +"thread_time($module, /)\n" +"--\n" +"\n" +"Thread time for profiling.\n" +"\n" +"That is the sum of the kernel and user-space CPU time."); + +#define TIME_THREAD_TIME_METHODDEF \ + {"thread_time", (PyCFunction)time_thread_time, METH_NOARGS, time_thread_time__doc__}, + +static double +time_thread_time_impl(PyObject *module); + +static PyObject * +time_thread_time(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + double _return_value; + + _return_value = time_thread_time_impl(module); + if ((_return_value == -1.0) && PyErr_Occurred()) { + goto exit; + } + return_value = PyFloat_FromDouble(_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_THREAD_TIME) */ + +#if defined(HAVE_THREAD_TIME) + +PyDoc_STRVAR(time_thread_time_ns__doc__, +"thread_time_ns($module, /)\n" +"--\n" +"\n" +"Thread time for profiling as nanoseconds.\n" +"\n" +"That is the sum of the kernel and user-space CPU time."); + +#define TIME_THREAD_TIME_NS_METHODDEF \ + {"thread_time_ns", (PyCFunction)time_thread_time_ns, METH_NOARGS, time_thread_time_ns__doc__}, + +static PyObject * +time_thread_time_ns_impl(PyObject *module); + +static PyObject * +time_thread_time_ns(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return time_thread_time_ns_impl(module); +} + +#endif /* defined(HAVE_THREAD_TIME) */ + +PyDoc_STRVAR(time_get_clock_info__doc__, +"get_clock_info($module, name, /)\n" +"--\n" +"\n" +"Get information of the specified clock."); + +#define TIME_GET_CLOCK_INFO_METHODDEF \ + {"get_clock_info", (PyCFunction)time_get_clock_info, METH_O, time_get_clock_info__doc__}, + +static PyObject * +time_get_clock_info_impl(PyObject *module, const char *name); + +static PyObject * +time_get_clock_info(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + const char *name; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("get_clock_info", "argument", "str", arg); + goto exit; + } + name = _PyUnicode_AsUTF8NoNUL(arg); + if (name == NULL) { + goto exit; + } + return_value = time_get_clock_info_impl(module, name); + +exit: + return return_value; +} + #ifndef TIME_CLOCK_GETTIME_METHODDEF #define TIME_CLOCK_GETTIME_METHODDEF #endif /* !defined(TIME_CLOCK_GETTIME_METHODDEF) */ @@ -71,4 +715,36 @@ time_clock_gettime_ns(PyObject *module, PyObject *arg) #ifndef TIME_CLOCK_GETTIME_NS_METHODDEF #define TIME_CLOCK_GETTIME_NS_METHODDEF #endif /* !defined(TIME_CLOCK_GETTIME_NS_METHODDEF) */ -/*[clinic end generated code: output=b589a2132aa9df47 input=a9049054013a1b77]*/ + +#ifndef TIME_CLOCK_SETTIME_METHODDEF + #define TIME_CLOCK_SETTIME_METHODDEF +#endif /* !defined(TIME_CLOCK_SETTIME_METHODDEF) */ + +#ifndef TIME_CLOCK_SETTIME_NS_METHODDEF + #define TIME_CLOCK_SETTIME_NS_METHODDEF +#endif /* !defined(TIME_CLOCK_SETTIME_NS_METHODDEF) */ + +#ifndef TIME_CLOCK_GETRES_METHODDEF + #define TIME_CLOCK_GETRES_METHODDEF +#endif /* !defined(TIME_CLOCK_GETRES_METHODDEF) */ + +#ifndef TIME_PTHREAD_GETCPUCLOCKID_METHODDEF + #define TIME_PTHREAD_GETCPUCLOCKID_METHODDEF +#endif /* !defined(TIME_PTHREAD_GETCPUCLOCKID_METHODDEF) */ + +#ifndef TIME_MKTIME_METHODDEF + #define TIME_MKTIME_METHODDEF +#endif /* !defined(TIME_MKTIME_METHODDEF) */ + +#ifndef TIME_TZSET_METHODDEF + #define TIME_TZSET_METHODDEF +#endif /* !defined(TIME_TZSET_METHODDEF) */ + +#ifndef TIME_THREAD_TIME_METHODDEF + #define TIME_THREAD_TIME_METHODDEF +#endif /* !defined(TIME_THREAD_TIME_METHODDEF) */ + +#ifndef TIME_THREAD_TIME_NS_METHODDEF + #define TIME_THREAD_TIME_NS_METHODDEF +#endif /* !defined(TIME_THREAD_TIME_NS_METHODDEF) */ +/*[clinic end generated code: output=d89be8cc2b2a7b05 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/zlibmodule.c.h b/Modules/clinic/zlibmodule.c.h index 620e483d5a759a7..023b178dc58fb5b 100644 --- a/Modules/clinic/zlibmodule.c.h +++ b/Modules/clinic/zlibmodule.c.h @@ -455,25 +455,12 @@ static PyObject * zlib_Compress_compress(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "compress", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; Py_buffer data = {NULL, NULL}; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("compress", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("compress", nargs, 1, 1)) { goto exit; } if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { @@ -612,35 +599,22 @@ static PyObject * zlib_Compress_flush(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "flush", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; int mode = Z_FINISH; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("flush", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("flush", nargs, 0, 1)) { goto exit; } if (nargs < 1) { - goto skip_optional_posonly; + goto skip_optional; } mode = PyLong_AsInt(args[0]); if (mode == -1 && PyErr_Occurred()) { goto exit; } -skip_optional_posonly: +skip_optional: return_value = zlib_Compress_flush_impl((compobject *)self, cls, mode); exit: @@ -716,25 +690,12 @@ static PyObject * zlib_Compress___deepcopy__(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "__deepcopy__", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *memo; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("__deepcopy__", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("__deepcopy__", nargs, 1, 1)) { goto exit; } memo = args[0]; @@ -815,25 +776,12 @@ static PyObject * zlib_Decompress___deepcopy__(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "__deepcopy__", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; PyObject *memo; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("__deepcopy__", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("__deepcopy__", nargs, 1, 1)) { goto exit; } memo = args[0]; @@ -865,29 +813,16 @@ static PyObject * zlib_Decompress_flush(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - #else - # define KWTUPLE NULL - #endif - - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = { - .keywords = _keywords, - .fname = "flush", - .kwtuple = KWTUPLE, - }; - #undef KWTUPLE - PyObject *argsbuf[1]; Py_ssize_t length = DEF_BUF_SIZE; - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, - /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); - if (!args) { + if (!_PyArg_NoKwnames("flush", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("flush", nargs, 0, 1)) { goto exit; } if (nargs < 1) { - goto skip_optional_posonly; + goto skip_optional; } { Py_ssize_t ival = -1; @@ -901,7 +836,7 @@ zlib_Decompress_flush(PyObject *self, PyTypeObject *cls, PyObject *const *args, } length = ival; } -skip_optional_posonly: +skip_optional: return_value = zlib_Decompress_flush_impl((compobject *)self, cls, length); exit: @@ -1403,4 +1338,4 @@ zlib_crc32_combine(PyObject *module, PyObject *const *args, Py_ssize_t nargs) #ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF #define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF #endif /* !defined(ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF) */ -/*[clinic end generated code: output=c9a60fe6600a2e4d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f4c3b5abac20df9b input=a9049054013a1b77]*/ diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c index 7c736f4610bb988..6e2d8e60c99e97d 100644 --- a/Modules/cmathmodule.c +++ b/Modules/cmathmodule.c @@ -1004,12 +1004,11 @@ cmath_phase_impl(PyObject *module, Py_complex z) { double phi; - errno = 0; - phi = atan2(z.imag, z.real); /* should not cause any exception */ - if (errno != 0) - return math_error(); - else - return PyFloat_FromDouble(phi); + phi = atan2(z.imag, z.real); + /* gh-153144: Ignore atan2() errno on purpose since it can optionally be + EDOM, which we should ignore, or ERANGE if phi underflows, + which is silent on Python. Overflow is not possible. */ + return PyFloat_FromDouble(phi); } /*[clinic input] @@ -1029,8 +1028,8 @@ cmath_polar_impl(PyObject *module, Py_complex z) { double r, phi; - errno = 0; phi = atan2(z.imag, z.real); /* should not cause any exception */ + errno = 0; r = _Py_c_abs(z); /* sets errno to ERANGE on overflow */ if (errno != 0) return math_error(); @@ -1060,7 +1059,7 @@ static Py_complex rect_special_values[7][7] = { }; /*[clinic input] -cmath.rect +cmath.rect -> Py_complex_protected r: double phi: double @@ -1069,9 +1068,9 @@ cmath.rect Convert from polar coordinates to rectangular coordinates. [clinic start generated code]*/ -static PyObject * +static Py_complex cmath_rect_impl(PyObject *module, double r, double phi) -/*[clinic end generated code: output=385a0690925df2d5 input=24c5646d147efd69]*/ +/*[clinic end generated code: output=74ff3d17585f3388 input=50e60c5d28c834e6]*/ { Py_complex z; errno = 0; @@ -1115,11 +1114,7 @@ cmath_rect_impl(PyObject *module, double r, double phi) z.imag = r * sin(phi); errno = 0; } - - if (errno != 0) - return math_error(); - else - return PyComplex_FromCComplex(z); + return z; } /*[clinic input] diff --git a/Modules/expat/ascii.h b/Modules/expat/ascii.h index 1f594d2e54b4d29..d5d82bf41e82dbd 100644 --- a/Modules/expat/ascii.h +++ b/Modules/expat/ascii.h @@ -10,7 +10,7 @@ Copyright (c) 2000 Clark Cooper Copyright (c) 2002 Fred L. Drake, Jr. Copyright (c) 2007 Karl Waclawek - Copyright (c) 2017 Sebastian Pipping + Copyright (c) 2017-2026 Sebastian Pipping Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining @@ -31,6 +31,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ #define ASCII_A 0x41 @@ -111,6 +113,7 @@ #define ASCII_LT 0x3C #define ASCII_EQUALS 0x3D #define ASCII_GT 0x3E +#define ASCII_QUEST 0x3F #define ASCII_LSQB 0x5B #define ASCII_RSQB 0x5D #define ASCII_UNDERSCORE 0x5F diff --git a/Modules/expat/asciitab.h b/Modules/expat/asciitab.h index af766fb24785ea3..43af0876ccd3f8a 100644 --- a/Modules/expat/asciitab.h +++ b/Modules/expat/asciitab.h @@ -30,6 +30,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ /* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, diff --git a/Modules/expat/entities.h b/Modules/expat/entities.h new file mode 100644 index 000000000000000..51e3ed5c151b546 --- /dev/null +++ b/Modules/expat/entities.h @@ -0,0 +1,99 @@ +/* Internal helpers related to entities + __ __ _ + ___\ \/ /_ __ __ _| |_ + / _ \\ /| '_ \ / _` | __| + | __// \| |_) | (_| | |_ + \___/_/\_\ .__/ \__,_|\__| + |_| XML parser + + Copyright (c) 2026 Sebastian Pipping + Licensed under the MIT license: + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to permit + persons to whom the Software is furnished to do so, subject to the + following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT +*/ + +#if ! defined(EXPAT_ENTITIES_H) +# define EXPAT_ENTITIES_H 1 + +# include "expat_config.h" // for XML_GE +# include "expat_external.h" // for XML_Char +# include "internal.h" // for XML_NONTESTING_STATIC +# include // for size_t +# include // for size_t + +typedef struct { + const XML_Char *name; + const XML_Char *textPtr; + size_t textLen; /* length in XML_Chars */ + size_t processed; /* # of processed bytes - when suspended */ + const XML_Char *systemId; + const XML_Char *base; + const XML_Char *publicId; + const XML_Char *notation; + bool open; + bool hasMore; /* true if entity has not been completely processed */ + /* An entity can be open while being already completely processed (!hasMore). + The reason is the delayed closing of entities until their inner + entities are processed and closed */ + bool is_param; + bool is_internal; /* true if declared in internal subset outside PE */ +# if XML_GE == 1 + /* Indirect accounting bytes charged when this entity is expanded: 1 per text + character, plus each reference's "&name;"/"%name;" token length and its own + expansion. Matches XML_ACCOUNT_ENTITY_EXPANSION, so it is not the + replacement-text size. 0 means "not computed yet" (an empty entity is 0 + too, told apart by textLen == 0). */ + XmlBigCount expandedSize; + bool beingAnalyzed; /* on the resolveEntityClosureExpandedSize depth-first + search stack; used for cycle detection */ + const XML_Char + *scanPtr; /* cursor position into the entity's replacement text; NULL when + `textPtr` is NULL, else a pointer into the entity value, + ranging from `.textPtr` to `.textPtr + .textLen`. */ +# endif /* XML_GE == 1 */ +} ENTITY; + +# if XML_GE == 1 +/* How a scanEntityText call ended. */ +enum EntityScanResult { + ENTITY_SCAN_COMPLETE, /* reached end of text; *expandedSize is final */ + ENTITY_SCAN_BLOCKED, /* stopped at a defined entity whose expanded + size has not been computed yet; *blockerOut + names the entity whose size to compute + first */ + ENTITY_SCAN_OVERFLOW /* the expanded size would exceed XmlBigCount; + callers must abort parsing */ +}; + +XML_NONTESTING_STATIC int isCDataCommentOrPIStart(const XML_Char *pos, + size_t maxLen, + size_t *openTextLen); + +XML_NONTESTING_STATIC int isPredefinedEntityName(const XML_Char *name, + size_t nameLen); + +XML_NONTESTING_STATIC enum EntityScanResult +scanEntityText(XML_Parser parser, ENTITY *entity, const XML_Char **posPtr, + XmlBigCount *expandedSize, ENTITY **blockerOut); +# endif /* XML_GE == 1 */ + +#endif // ! defined(EXPAT_ENTITIES_H) diff --git a/Modules/expat/expat.h b/Modules/expat/expat.h index c493c70441c4184..4a7260d35b369d6 100644 --- a/Modules/expat/expat.h +++ b/Modules/expat/expat.h @@ -20,6 +20,8 @@ Copyright (c) 2023 Sony Corporation / Snild Dolkow Copyright (c) 2024 Taichi Haradaguchi <20001722@ymail.ne.jp> Copyright (c) 2025 Matthew Fernandez + Copyright (c) 2026 Braian Plaku + Copyright (c) 2026 Xisco Fauli Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining @@ -40,12 +42,14 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ #ifndef Expat_INCLUDED # define Expat_INCLUDED 1 -# include // for uint8_t +# include // for int64_t, uint8_t, uint64_t # include # include "expat_external.h" @@ -137,6 +141,26 @@ enum XML_Error { XML_ERROR_NOT_STARTED, }; +/* Added in 2.9.0. */ +enum XML_Prop_Error { + XML_PROP_ERROR_NONE = 0, // i.e. success + + XML_PROP_ERROR_INVALID_KEY = 1, // i.e. the property is not known at all + XML_PROP_ERROR_INVALID_TYPE = 2, // i.e. the property is known but expects a + // different type (so a different + // getter/setter would need to be called) + XML_PROP_ERROR_INVALID_VALUE = 3, // i.e. the value is invalid (with a setter + // function) or a NULL-pointer (with a + // getter function) + + XML_PROP_ERROR_PARSER_NULL = 4, // i.e. the parser argument is NULL + XML_PROP_ERROR_PARSER_NOT_ROOT = 5, // i.e. the parser is not a root parser + // but a subparser (and a root parser is + // needed) + + /* potentially more error codes upcoming here */ +}; + enum XML_Content_Type { XML_CTYPE_EMPTY = 1, XML_CTYPE_ANY, @@ -754,47 +778,31 @@ XML_GetSpecifiedAttributeCount(XML_Parser parser); XMLPARSEAPI(int) XML_GetIdAttributeIndex(XML_Parser parser); -# ifdef XML_ATTR_INFO -/* Source file byte offsets for the start and end of attribute names and values. - The value indices are exclusive of surrounding quotes; thus in a UTF-8 source - file an attribute value of "blah" will yield: - info->valueEnd - info->valueStart = 4 bytes. -*/ -typedef struct { - XML_Index nameStart; /* Offset to beginning of the attribute name. */ - XML_Index nameEnd; /* Offset after the attribute name's last byte. */ - XML_Index valueStart; /* Offset to beginning of the attribute value. */ - XML_Index valueEnd; /* Offset after the attribute value's last byte. */ -} XML_AttrInfo; - -/* Returns an array of XML_AttrInfo structures for the attribute/value pairs - passed in last call to the XML_StartElementHandler that were specified - in the start-tag rather than defaulted. Each attribute/value pair counts - as 1; thus the number of entries in the array is - XML_GetSpecifiedAttributeCount(parser) / 2. -*/ -XMLPARSEAPI(const XML_AttrInfo *) -XML_GetAttributeInfo(XML_Parser parser); -# endif - /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is detected. The last call to XML_Parse must have isFinal true; len may be zero for this call (or any other). - - Though the return values for these functions has always been - described as a Boolean value, the implementation, at least for the - 1.95.x series, has always returned exactly one of the XML_Status - values. */ XMLPARSEAPI(enum XML_Status) XML_Parse(XML_Parser parser, const char *s, int len, int isFinal); +// Added in Expat 2.11.0. +XMLPARSEAPI(enum XML_Status) +XML_Parse64(XML_Parser parser, const char *s, size_t len, XML_Bool isFinal); + XMLPARSEAPI(void *) XML_GetBuffer(XML_Parser parser, int len); +// Added in Expat 2.11.0. +XMLPARSEAPI(void *) +XML_GetBuffer64(XML_Parser parser, size_t len); + XMLPARSEAPI(enum XML_Status) XML_ParseBuffer(XML_Parser parser, int len, int isFinal); +// Added in Expat 2.11.0. +XMLPARSEAPI(enum XML_Status) +XML_ParseBuffer64(XML_Parser parser, size_t len, XML_Bool isFinal); + /* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return. Must be called from within a call-back handler, except when aborting (resumable = 0) an already suspended parser. Some call-backs may @@ -919,7 +927,9 @@ XML_SetParamEntityParsing(XML_Parser parser, Returns 1 if successful, 0 when called after parsing has started. Note: If parser == NULL, the function will do nothing and return 0. DEPRECATED since Expat 2.8.0. + Please use XML_SetHashSalt16Bytes instead. */ +XML_ATTR_DEPRECATED("please use XML_SetHashSalt16Bytes instead") XMLPARSEAPI(int) XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt); @@ -959,15 +969,24 @@ XML_GetErrorCode(XML_Parser parser); return 0 to indicate an error. Note: XML_GetCurrentByteIndex returns -1 to indicate an error. */ +XML_ATTR_DEPRECATED("please use XML_GetCurrentLineNumber64 instead") XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser); +XMLPARSEAPI(uint64_t) XML_GetCurrentLineNumber64(XML_Parser parser); +XML_ATTR_DEPRECATED("please use XML_GetCurrentColumnNumber64 instead") XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser); +XMLPARSEAPI(uint64_t) XML_GetCurrentColumnNumber64(XML_Parser parser); +XML_ATTR_DEPRECATED("please use XML_GetCurrentByteIndex64 instead") XMLPARSEAPI(XML_Index) XML_GetCurrentByteIndex(XML_Parser parser); +XMLPARSEAPI(int64_t) XML_GetCurrentByteIndex64(XML_Parser parser); /* Return the number of bytes in the current event. Returns 0 if the event is in an internal entity. */ +XML_ATTR_DEPRECATED("please use XML_GetCurrentByteCount64 instead") XMLPARSEAPI(int) XML_GetCurrentByteCount(XML_Parser parser); +XMLPARSEAPI(uint64_t) +XML_GetCurrentByteCount64(XML_Parser parser); /* If XML_CONTEXT_BYTES is >=1, returns the input buffer, sets the integer pointed to by offset to the offset within this buffer @@ -979,8 +998,11 @@ XML_GetCurrentByteCount(XML_Parser parser); NOTE: The character pointer returned should not be used outside the handler that makes the call. */ +XML_ATTR_DEPRECATED("please use XML_GetInputContext64 instead") XMLPARSEAPI(const char *) XML_GetInputContext(XML_Parser parser, int *offset, int *size); +XMLPARSEAPI(const char *) +XML_GetInputContext64(XML_Parser parser, int64_t *offset, uint64_t *size); /* For backwards compatibility with previous versions. */ # define XML_GetErrorLineNumber XML_GetCurrentLineNumber @@ -1035,11 +1057,15 @@ enum XML_FeatureEnum { XML_FEATURE_UNICODE_WCHAR_T, XML_FEATURE_DTD, XML_FEATURE_CONTEXT_BYTES, + /* Added in Expat 1.95.5, removed in Expat 2.9.0. */ XML_FEATURE_MIN_SIZE, XML_FEATURE_SIZEOF_XML_CHAR, XML_FEATURE_SIZEOF_XML_LCHAR, + /* Added in Expat 2.0.0. */ XML_FEATURE_NS, + /* Added in Expat 2.0.1. */ XML_FEATURE_LARGE_SIZE, + /* Added in Expat 2.1.0, removed in Expat 2.9.0. */ XML_FEATURE_ATTR_INFO, /* Added in Expat 2.4.0. */ XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT, @@ -1061,6 +1087,41 @@ typedef struct { XMLPARSEAPI(const XML_Feature *) XML_GetFeatureList(void); +/* Added in Expat 2.9.0. */ +enum XML_Parser_Property { +# if defined(XML_TESTING) + XML_PROP_INVALID = 0, +# endif +# if defined(XML_GE) && XML_GE == 1 + XML_PROP_ALLOC_TRACKER_ACTIVATION_THRESHOLD = 1, // of type `uint64_t` + XML_PROP_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION = 2, // of type `double` + XML_PROP_BILLION_LAUGHS_ACTIVATION_THRESHOLD = 3, // of type `uint64_t` + XML_PROP_BILLION_LAUGHS_MAXIMUM_AMPLIFICATION = 4, // of type `double` +# endif + XML_PROP_REPARSE_DEFERRAL_ENABLED = 5, // of type `XML_Bool` + /* more properties upcoming here */ +}; + +/* Added in Expat 2.9.0. */ +XMLPARSEAPI(enum XML_Prop_Error) +XML_GetPropertyBool(XML_Parser parser, enum XML_Parser_Property property, + XML_Bool *value); +XMLPARSEAPI(enum XML_Prop_Error) +XML_GetPropertyDouble(XML_Parser parser, enum XML_Parser_Property property, + double *value); +XMLPARSEAPI(enum XML_Prop_Error) +XML_GetPropertyUInt64(XML_Parser parser, enum XML_Parser_Property property, + uint64_t *value); +XMLPARSEAPI(enum XML_Prop_Error) +XML_SetPropertyBool(XML_Parser parser, enum XML_Parser_Property property, + XML_Bool value); +XMLPARSEAPI(enum XML_Prop_Error) +XML_SetPropertyDouble(XML_Parser parser, enum XML_Parser_Property property, + double value); +XMLPARSEAPI(enum XML_Prop_Error) +XML_SetPropertyUInt64(XML_Parser parser, enum XML_Parser_Property property, + uint64_t value); + # if defined(XML_DTD) || (defined(XML_GE) && XML_GE == 1) /* Added in Expat 2.4.0 for XML_DTD defined and * added in Expat 2.6.0 for XML_GE == 1. */ @@ -1093,8 +1154,8 @@ XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled); See https://semver.org */ # define XML_MAJOR_VERSION 2 -# define XML_MINOR_VERSION 8 -# define XML_MICRO_VERSION 2 +# define XML_MINOR_VERSION 11 +# define XML_MICRO_VERSION 0 # ifdef __cplusplus } diff --git a/Modules/expat/expat_external.h b/Modules/expat/expat_external.h index cc945c424e471f7..b373407b10c4a60 100644 --- a/Modules/expat/expat_external.h +++ b/Modules/expat/expat_external.h @@ -12,10 +12,11 @@ Copyright (c) 2001-2002 Greg Stein Copyright (c) 2002-2006 Karl Waclawek Copyright (c) 2016 Cristian Rodríguez - Copyright (c) 2016-2025 Sebastian Pipping + Copyright (c) 2016-2026 Sebastian Pipping Copyright (c) 2017 Rhodri James Copyright (c) 2018 Yury Gribov Copyright (c) 2026 Matthew Fernandez + Copyright (c) 2026 Braian Plaku Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining @@ -36,6 +37,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ #ifndef Expat_External_INCLUDED @@ -126,6 +129,17 @@ # define XML_ATTR_ALLOC_SIZE(x) # endif +/* Marks a function that Expat still provides but that callers should move off + of. */ +# if defined(__clang__) || defined(__GNUC__) +# define XML_ATTR_DEPRECATED(message) \ + __attribute__((__deprecated__(message))) +# elif defined(_MSC_VER) +# define XML_ATTR_DEPRECATED(message) __declspec(deprecated(message)) +# else +# define XML_ATTR_DEPRECATED(message) // empty i.e. no deprecation +# endif + # define XMLPARSEAPI(type) XMLIMPORT type XMLCALL # ifdef __cplusplus @@ -155,6 +169,9 @@ typedef char XML_LChar; # endif /* XML_UNICODE */ # ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */ +# if defined(__clang__) || defined(__GNUC__) +# warning Macro XML_LARGE_SIZE is deprecated, please use the 64bit location API functions instead. +# endif typedef long long XML_Index; typedef unsigned long long XML_Size; # else diff --git a/Modules/expat/fallthrough.h b/Modules/expat/fallthrough.h index 707dbdd44bfe53d..0152d1bdc5de8ff 100644 --- a/Modules/expat/fallthrough.h +++ b/Modules/expat/fallthrough.h @@ -27,6 +27,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ #ifndef FALLTHROUGH_H diff --git a/Modules/expat/hash_table.h b/Modules/expat/hash_table.h new file mode 100644 index 000000000000000..f290aad18693feb --- /dev/null +++ b/Modules/expat/hash_table.h @@ -0,0 +1,78 @@ +/* Hash table related internal API + __ __ _ + ___\ \/ /_ __ __ _| |_ + / _ \\ /| '_ \ / _` | __| + | __// \| |_) | (_| | |_ + \___/_/\_\ .__/ \__,_|\__| + |_| XML parser + + Copyright (c) 2026 Sebastian Pipping + Licensed under the MIT license: + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to permit + persons to whom the Software is furnished to do so, subject to the + following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT +*/ + +#if ! defined(HASH_TABLE_H) +# define HASH_TABLE_H 1 + +# include "expat.h" // for XML_Bool, XML_Parser +# include "internal.h" // for XML_NONTESTING_STATIC + +# include // for size_t + +typedef const XML_Char *KEY; + +typedef struct { + KEY name; +} NAMED; + +typedef struct { + NAMED **v; + unsigned char power; + size_t size; + size_t used; + XML_Parser parser; +} HASH_TABLE; + +typedef struct { + NAMED **p; + NAMED **end; +} HASH_TABLE_ITER; + +XML_NONTESTING_STATIC NAMED *lookupWithLength(XML_Parser parser, + HASH_TABLE *table, KEY name, + size_t nameLen, + size_t createSize); +XML_NONTESTING_STATIC NAMED *lookup(XML_Parser parser, HASH_TABLE *table, + KEY name, size_t createSize); + +XML_NONTESTING_STATIC void hashTableInit(HASH_TABLE *table, XML_Parser parser); +XML_NONTESTING_STATIC void hashTableClear(HASH_TABLE *table); +XML_NONTESTING_STATIC void hashTableDestroy(HASH_TABLE *table); +XML_NONTESTING_STATIC void hashTableIterInit(HASH_TABLE_ITER *iter, + const HASH_TABLE *table); +XML_NONTESTING_STATIC NAMED *hashTableIterNext(HASH_TABLE_ITER *iter); + +XML_NONTESTING_STATIC XML_Bool keyeq(KEY s1, size_t s1len, KEY s2); +XML_NONTESTING_STATIC size_t keylen(KEY s); + +#endif // ! defined(HASH_TABLE_H) diff --git a/Modules/expat/iasciitab.h b/Modules/expat/iasciitab.h index 5d8646f2a318b8a..1de8d519c8b7bad 100644 --- a/Modules/expat/iasciitab.h +++ b/Modules/expat/iasciitab.h @@ -30,6 +30,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ /* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */ diff --git a/Modules/expat/internal.h b/Modules/expat/internal.h index 420d4217a569b1d..7ab186c0342b3c2 100644 --- a/Modules/expat/internal.h +++ b/Modules/expat/internal.h @@ -6,13 +6,6 @@ The following calling convention macros are defined for frequently called functions: - FASTCALL - Used for those internal functions that have a simple - body and a low number of arguments and local variables. - - PTRCALL - Used for functions called though function pointers. - - PTRFASTCALL - Like PTRCALL, but for low number of arguments. - inline - Used for selected internal functions for which inlining may improve performance on some platforms. @@ -33,6 +26,10 @@ Copyright (c) 2019 David Loffredo Copyright (c) 2023-2024 Sony Corporation / Snild Dolkow Copyright (c) 2024 Taichi Haradaguchi <20001722@ymail.ne.jp> + Copyright (c) 2026 Matthew Wozniczka + Copyright (c) 2026 Braian Plaku + Copyright (c) 2026 Florian Schmaus + Copyright (c) 2026 Brooks Davis Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining @@ -53,143 +50,111 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#if defined(__GNUC__) && defined(__i386__) && ! defined(__MINGW32__) -/* We'll use this version by default only where we know it helps. - - regparm() generates warnings on Solaris boxes. See SF bug #692878. - Instability reported with egcs on a RedHat Linux 7.3. - Let's comment out: - #define FASTCALL __attribute__((stdcall, regparm(3))) - and let's try this: + SPDX-License-Identifier: MIT */ -# define FASTCALL __attribute__((regparm(3))) -# define PTRFASTCALL __attribute__((regparm(3))) -#endif - -/* Using __fastcall seems to have an unexpected negative effect under - MS VC++, especially for function pointers, so we won't use it for - now on that platform. It may be reconsidered for a future release - if it can be made more effective. - Likely reason: __fastcall on Windows is like stdcall, therefore - the compiler cannot perform stack optimizations for call clusters. -*/ - -/* Make sure all of these are defined if they aren't already. */ - -#ifndef FASTCALL -# define FASTCALL -#endif -#ifndef PTRCALL -# define PTRCALL -#endif +#if ! defined(INTERNAL_H) +# define INTERNAL_H 1 -#ifndef PTRFASTCALL -# define PTRFASTCALL -#endif - -#ifndef XML_MIN_SIZE -# if ! defined(__cplusplus) && ! defined(inline) +# if ! defined(inline) # ifdef __GNUC__ # define inline __inline # endif /* __GNUC__ */ # endif -#endif /* XML_MIN_SIZE */ -#ifdef __cplusplus -# define inline inline -#else # ifndef inline # define inline # endif -#endif - -#include // ULONG_MAX -#include // size_t - -#if defined(_WIN32) \ - && (! defined(__USE_MINGW_ANSI_STDIO) \ - || (1 - __USE_MINGW_ANSI_STDIO - 1 == 0)) -# define EXPAT_FMT_LLX(midpart) "%" midpart "I64x" -# define EXPAT_FMT_ULL(midpart) "%" midpart "I64u" -# if defined(_WIN64) // Note: modifiers "td" and "zu" do not work for MinGW -# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "I64d" -# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "I64u" -# else -# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d" -# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u" + +# if ! defined(XML_NONTESTING_STATIC) +# if defined(XML_TESTING) +# define XML_NONTESTING_STATIC // empty i.e. not static +# else +# define XML_NONTESTING_STATIC static +# endif # endif -#else -# define EXPAT_FMT_LLX(midpart) "%" midpart "llx" -# define EXPAT_FMT_ULL(midpart) "%" midpart "llu" -# if ! defined(ULONG_MAX) -# error Compiler did not define ULONG_MAX for us -# elif ULONG_MAX == 18446744073709551615u // 2^64-1 -# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld" -# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu" -# elif defined(__wasm32__) // 32bit mode Emscripten or WASI SDK -# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld" -# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "zu" + +# include // ULONG_MAX +# include // size_t + +# if defined(_WIN32) \ + && (! defined(__USE_MINGW_ANSI_STDIO) \ + || (1 - __USE_MINGW_ANSI_STDIO - 1 == 0)) +# define EXPAT_FMT_LLX(midpart) "%" midpart "I64x" +# define EXPAT_FMT_ULL(midpart) "%" midpart "I64u" +# if defined(_WIN64) // Note: modifiers "td" and "zu" do not work for MinGW +# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "I64d" +# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "I64u" +# else +# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d" +# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u" +# endif # else -# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d" -# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u" +# define EXPAT_FMT_LLX(midpart) "%" midpart "llx" +# define EXPAT_FMT_ULL(midpart) "%" midpart "llu" +# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "td" +# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "zu" # endif -#endif -#ifndef UNUSED_P -# define UNUSED_P(p) (void)p -#endif +# ifndef UNUSED_P +# define UNUSED_P(p) (void)p +# endif /* NOTE BEGIN If you ever patch these defaults to greater values for non-attack XML payload in your environment, please file a bug report with libexpat. Thank you! */ -#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT \ - 100.0f -#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT \ - 8388608 // 8 MiB, 2^23 +# define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT \ + 100.0f +# define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT \ + 8388608 // 8 MiB, 2^23 -#define EXPAT_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION_DEFAULT 100.0f -#define EXPAT_ALLOC_TRACKER_ACTIVATION_THRESHOLD_DEFAULT \ - 67108864 // 64 MiB, 2^26 +# define EXPAT_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION_DEFAULT 100.0f +# define EXPAT_ALLOC_TRACKER_ACTIVATION_THRESHOLD_DEFAULT \ + 67108864 // 64 MiB, 2^26 // NOTE: If function expat_alloc was user facing, EXPAT_MALLOC_ALIGNMENT would // have to take sizeof(long double) into account -#define EXPAT_MALLOC_ALIGNMENT sizeof(long long) // largest parser (sub)member -#define EXPAT_MALLOC_PADDING ((EXPAT_MALLOC_ALIGNMENT) - sizeof(size_t)) +union expat_align { + long long l; + void *p; +}; +# define EXPAT_MALLOC_ALIGNMENT sizeof(union expat_align) +# define EXPAT_MALLOC_PADDING ((EXPAT_MALLOC_ALIGNMENT) - sizeof(size_t)) /* NOTE END */ -#include "expat.h" // so we can use type XML_Parser below +# include "expat.h" // so we can use type XML_Parser below + +typedef unsigned long long XmlBigCount; -#ifdef __cplusplus -extern "C" { -#endif +// NOTE: Type `ssize_t` and macro `SSIZE_MAX` are not guaranteed by C99 +typedef long expat_ssize_t; +# define EXPAT_SSIZE_MAX LONG_MAX void _INTERNAL_trim_to_complete_utf8_characters(const char *from, const char **fromLimRef); -#if defined(XML_GE) && XML_GE == 1 +# if defined(XML_GE) && XML_GE == 1 unsigned long long testingAccountingGetCountBytesDirect(XML_Parser parser); unsigned long long testingAccountingGetCountBytesIndirect(XML_Parser parser); const char *unsignedCharToPrintable(unsigned char c); -#endif +# endif extern -#if ! defined(XML_TESTING) +# if ! defined(XML_TESTING) const -#endif +# endif XML_Bool g_reparseDeferralEnabledDefault; // written ONLY in runtests.c -#if defined(XML_TESTING) +# if defined(XML_TESTING) + +int xmlSetHashSalt(XML_Parser parser, unsigned long hash_salt); + void *expat_malloc(XML_Parser parser, size_t size, int sourceLine); void expat_free(XML_Parser parser, void *ptr, int sourceLine); void *expat_realloc(XML_Parser parser, void *ptr, size_t size, int sourceLine); extern unsigned int g_bytesScanned; // used for testing only -#endif +# endif -#ifdef __cplusplus -} -#endif +#endif // not defined INTERNAL_H diff --git a/Modules/expat/latin1tab.h b/Modules/expat/latin1tab.h index b681d278af6569b..df421f2e7d8719d 100644 --- a/Modules/expat/latin1tab.h +++ b/Modules/expat/latin1tab.h @@ -9,7 +9,7 @@ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd Copyright (c) 2000 Clark Cooper Copyright (c) 2002 Fred L. Drake, Jr. - Copyright (c) 2017 Sebastian Pipping + Copyright (c) 2017-2026 Sebastian Pipping Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining @@ -30,6 +30,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ /* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, @@ -42,11 +44,11 @@ /* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, /* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, /* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, - /* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER, + /* 0xA8 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, /* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, /* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, - /* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME, - /* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER, + /* 0xB4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_NAME, + /* 0xB8 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, /* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, /* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, /* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, diff --git a/Modules/expat/memory_sanitizer.h b/Modules/expat/memory_sanitizer.h index a8a8006ccded12d..f739b88f304871b 100644 --- a/Modules/expat/memory_sanitizer.h +++ b/Modules/expat/memory_sanitizer.h @@ -27,6 +27,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ #if ! defined(MEMORY_SANITIZER_H) diff --git a/Modules/expat/nametab.h b/Modules/expat/nametab.h index 63485446b967272..57407e87b693d4e 100644 --- a/Modules/expat/nametab.h +++ b/Modules/expat/nametab.h @@ -6,8 +6,8 @@ \___/_/\_\ .__/ \__,_|\__| |_| XML parser - Copyright (c) 2000 Clark Cooper - Copyright (c) 2017 Sebastian Pipping + Copyright (c) 2000 Clark Cooper + Copyright (c) 2017-2026 Sebastian Pipping Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining @@ -28,6 +28,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ static const unsigned namingBitmap[] = { @@ -35,102 +37,66 @@ static const unsigned namingBitmap[] = { 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE, 0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF, - 0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, - 0xFFFFE00F, 0xFC31FFFF, 0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, - 0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD, - 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, 0xFFFF0003, 0xFFFFFFFF, - 0xFFFF199F, 0x033FCFFF, 0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE, - 0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF, 0x00000000, 0x07FFFFFE, - 0x000007FE, 0xFFFE0000, 0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060, - 0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003, 0xFFF99FE0, 0x03C5FDFF, - 0xB0000000, 0x00030003, 0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000, - 0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001, 0xFFF99FE0, 0x23CDFDFF, - 0xB0000000, 0x00000003, 0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000, - 0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003, 0xFFFDDFE0, 0x03EFFDFF, - 0x40000000, 0x00000003, 0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFE, 0x000D7FFF, - 0x0000003F, 0x00000000, 0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000, - 0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF, 0x0007DAED, 0x50000000, - 0x82315001, 0x002C62AB, 0x40000000, 0xF580C900, 0x00000007, 0x02010800, - 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0FFFFFFF, 0xFFFFFFFF, - 0xFFFFFFFF, 0x03FFFFFF, 0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF, - 0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF, 0x00000000, 0x00004C40, - 0x00000000, 0x00000000, 0x00000007, 0x00000000, 0x00000000, 0x00000000, - 0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF, 0x001FFFFF, 0xFFFFFFFE, - 0xFFFFFFFF, 0x07FFFFFF, 0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, - 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000, - 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000000F, - 0x00000000, 0x00000000, 0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE, - 0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF, 0x00FFFFFF, 0x00000000, - 0xFFFF0000, 0xFFFFFFFF, 0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000, - 0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003, 0xFFFFD7C0, 0xFFFFFFFB, - 0x547F7FFF, 0x000FFFFD, 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, - 0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF, 0x00000000, 0xFFFE0000, - 0x027FFFFF, 0xFFFFFFFE, 0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF, - 0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF, 0xFFFFFFFF, 0x7CFFFFFF, - 0xFFEF7FFF, 0x03FF3DFF, 0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF, - 0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF, 0xFFF987E4, 0xD36DFDFF, - 0x5E003987, 0x001FFFC0, 0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1, - 0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3, 0xD63DC7EC, 0xC3BFC718, - 0x00803DC7, 0x0000FF80, 0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3, - 0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3, 0xFFFDDFEC, 0xC3FFFDFF, - 0x00803DCF, 0x0000FFC3, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000, 0xFEF02596, 0x3BFF6CAE, - 0x03FF3F5F, 0x00000000, 0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF, - 0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1FFF0000, 0x00000002, - 0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF, 0x661FFFFF, 0xFFFFFFFE, - 0xFFFFFFFF, 0x77FFFFFF, + 0x00000000, 0x00000000, 0x00000000, 0xBFFF0000, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0x00003000, 0x00000000, 0x00000000, 0xFFFF0000, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0x0000FFFF, 0x00000000, 0x00000000, 0x00000000, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0x0000FFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000FFFF, 0xFFFF0000, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0x3FFFFFFF, 0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE, + 0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xBFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0x00003000, 0x80000000, 0x00000001, 0xFFFF0000, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, }; static const unsigned char nmstrtPages[] = { - 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x00, 0x09, 0x0A, 0x0B, - 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x00, 0x14, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x05, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x06, + 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x08, 0x01, 0x09, }; static const unsigned char namePages[] = { - 0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00, 0x00, 0x1F, 0x20, 0x21, - 0x22, 0x23, 0x24, 0x25, 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x26, 0x14, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x0A, 0x01, 0x01, 0x0B, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0C, 0x05, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x06, + 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x08, 0x01, 0x09, }; diff --git a/Modules/expat/pyexpatns.h b/Modules/expat/pyexpatns.h index fc6b482d587e0d6..4c550b7d0131819 100644 --- a/Modules/expat/pyexpatns.h +++ b/Modules/expat/pyexpatns.h @@ -50,14 +50,22 @@ #define XML_GetBase PyExpat_XML_GetBase #define XML_GetBuffer PyExpat_XML_GetBuffer #define XML_GetCurrentByteCount PyExpat_XML_GetCurrentByteCount +#define XML_GetCurrentByteCount64 PyExpat_XML_GetCurrentByteCount64 #define XML_GetCurrentByteIndex PyExpat_XML_GetCurrentByteIndex +#define XML_GetCurrentByteIndex64 PyExpat_XML_GetCurrentByteIndex64 #define XML_GetCurrentColumnNumber PyExpat_XML_GetCurrentColumnNumber +#define XML_GetCurrentColumnNumber64 PyExpat_XML_GetCurrentColumnNumber64 #define XML_GetCurrentLineNumber PyExpat_XML_GetCurrentLineNumber +#define XML_GetCurrentLineNumber64 PyExpat_XML_GetCurrentLineNumber64 #define XML_GetErrorCode PyExpat_XML_GetErrorCode #define XML_GetFeatureList PyExpat_XML_GetFeatureList #define XML_GetIdAttributeIndex PyExpat_XML_GetIdAttributeIndex #define XML_GetInputContext PyExpat_XML_GetInputContext +#define XML_GetInputContext64 PyExpat_XML_GetInputContext64 #define XML_GetParsingStatus PyExpat_XML_GetParsingStatus +#define XML_GetPropertyBool PyExpat_XML_GetPropertyBool +#define XML_GetPropertyDouble PyExpat_XML_GetPropertyDouble +#define XML_GetPropertyUInt64 PyExpat_XML_GetPropertyUInt64 #define XML_GetSpecifiedAttributeCount PyExpat_XML_GetSpecifiedAttributeCount #define XmlGetUtf16InternalEncoding PyExpat_XmlGetUtf16InternalEncoding #define XmlGetUtf16InternalEncodingNS PyExpat_XmlGetUtf16InternalEncodingNS @@ -110,6 +118,9 @@ #define XML_SetNotStandaloneHandler PyExpat_XML_SetNotStandaloneHandler #define XML_SetParamEntityParsing PyExpat_XML_SetParamEntityParsing #define XML_SetProcessingInstructionHandler PyExpat_XML_SetProcessingInstructionHandler +#define XML_SetPropertyBool PyExpat_XML_SetPropertyBool +#define XML_SetPropertyDouble PyExpat_XML_SetPropertyDouble +#define XML_SetPropertyUInt64 PyExpat_XML_SetPropertyUInt64 #define XML_SetReparseDeferralEnabled PyExpat_XML_SetReparseDeferralEnabled #define XML_SetReturnNSTriplet PyExpat_XML_SetReturnNSTriplet #define XML_SetSkippedEntityHandler PyExpat_XML_SetSkippedEntityHandler diff --git a/Modules/expat/refresh.sh b/Modules/expat/refresh.sh index 503f562c1862a48..469fc5a09d4d2d7 100755 --- a/Modules/expat/refresh.sh +++ b/Modules/expat/refresh.sh @@ -12,9 +12,9 @@ fi # Update this when updating to a new version after verifying that the changes # the update brings in are good. These values are used for verifying the SBOM, too. -expected_libexpat_tag="R_2_8_2" -expected_libexpat_version="2.8.2" -expected_libexpat_sha256="ef7d1994f533c9e7343d6c19f31064fc8ebbcbcaa144be3812b4f43052a05f4c" +expected_libexpat_tag="R_2_11_0" +expected_libexpat_version="2.11.0" +expected_libexpat_sha256="b3e3fcbb629e4d357a9cc0af5b146b85959bcf1cefe87e529d2c0a9234be737f" expat_dir="$(realpath "$(dirname -- "${BASH_SOURCE[0]}")")" cd ${expat_dir} @@ -31,9 +31,11 @@ declare -a lib_files lib_files=( ascii.h asciitab.h + entities.h expat.h expat_external.h fallthrough.h + hash_table.h iasciitab.h internal.h latin1tab.h @@ -42,7 +44,8 @@ lib_files=( siphash.h utf8tab.h winconfig.h - xcsinc.c + xcs.c + xcs.h xmlparse.c xmlrole.c xmlrole.h diff --git a/Modules/expat/siphash.h b/Modules/expat/siphash.h index be216b4006dc847..ac1fbfaf0bde81d 100644 --- a/Modules/expat/siphash.h +++ b/Modules/expat/siphash.h @@ -8,6 +8,8 @@ * * 1. https://www.131002.net/siphash/siphash24.c * 2. https://www.131002.net/siphash/ + * + * SPDX-License-Identifier: CC0-1.0 * -------------------------------------------------------------------------- * HISTORY: * diff --git a/Modules/expat/utf8tab.h b/Modules/expat/utf8tab.h index 88efcf91cc16a6c..73732d1527f1420 100644 --- a/Modules/expat/utf8tab.h +++ b/Modules/expat/utf8tab.h @@ -30,6 +30,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ /* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, diff --git a/Modules/expat/winconfig.h b/Modules/expat/winconfig.h index 05805514ec7fa21..9e7e8bdc22ca36c 100644 --- a/Modules/expat/winconfig.h +++ b/Modules/expat/winconfig.h @@ -31,6 +31,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ #ifndef WINCONFIG_H diff --git a/Modules/expat/xcs.c b/Modules/expat/xcs.c new file mode 100644 index 000000000000000..a97647fa9d69e32 --- /dev/null +++ b/Modules/expat/xcs.c @@ -0,0 +1,111 @@ +/* + __ __ _ + ___\ \/ /_ __ __ _| |_ + / _ \\ /| '_ \ / _` | __| + | __// \| |_) | (_| | |_ + \___/_/\_\ .__/ \__,_|\__| + |_| XML parser + + Copyright (c) 2022-2026 Sebastian Pipping + Licensed under the MIT license: + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to permit + persons to whom the Software is furnished to do so, subject to the + following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT +*/ + +#include "xcs.h" + +#if defined(XML_UNICODE) +# if defined(XML_UNICODE_WCHAR_T) +# include // for wcscmp, wcslen, wcsncmp +# endif +#else +# include // for strcmp, strlen, strncmp +#endif + +size_t +xcslen(const XML_Char *s) { +#ifdef XML_UNICODE +# ifdef XML_UNICODE_WCHAR_T + return wcslen(s); +# else + // XML_Char is unsigned short + size_t len = 0; + while (s[len]) { + len++; + } + return len; +# endif +#else + return strlen(s); +#endif +} + +int +xcscmp(const XML_Char *a, const XML_Char *b) { +#if defined(XML_UNICODE) +# if defined(XML_UNICODE_WCHAR_T) + return wcscmp(a, b); +# else + for (; a[0] && b[0] && a[0] == b[0]; a++, b++) + ; + return a[0] - b[0]; +# endif +#else + return strcmp(a, b); +#endif +} + +int +xcsncmp(const XML_Char *a, const XML_Char *b, size_t len) { +#if defined(XML_UNICODE) +# if defined(XML_UNICODE_WCHAR_T) + return wcsncmp(a, b, len); +# else + for (; len > 0 && a[0] && b[0] && a[0] == b[0]; len--, a++, b++) { + } + return (len == 0) ? 0 : (a[0] - b[0]); +# endif +#else + return strncmp(a, b, len); +#endif +} + +// A port of `strnstr(3bsd)` to `XML_Char` +const XML_Char * +xcsnstr(const XML_Char *haystack, const XML_Char *needle, size_t maxLen) { + // NOTE: We are not calling `xcsnlen(haystack, maxLen)` because + // `haystack` could be long and `xcsnlen` could be used in a loop + // and we need to avoid quadratic runtime behavior. + if (! *needle) + return haystack; // i.e. empty needle is always a match + const size_t needleLen = xcslen(needle); + if (needleLen > maxLen) + return NULL; + const size_t maxTries = (maxLen - needleLen) + 1; + for (size_t i = 0; i < maxTries && haystack[i]; i++) { + if (haystack[i] == needle[0] + && xcsncmp(haystack + i, needle, needleLen) == 0) { + return haystack + i; + } + } + return NULL; +} diff --git a/Modules/expat/xcs.h b/Modules/expat/xcs.h new file mode 100644 index 000000000000000..9fbc4fe4c8510f5 --- /dev/null +++ b/Modules/expat/xcs.h @@ -0,0 +1,47 @@ +/* + __ __ _ + ___\ \/ /_ __ __ _| |_ + / _ \\ /| '_ \ / _` | __| + | __// \| |_) | (_| | |_ + \___/_/\_\ .__/ \__,_|\__| + |_| XML parser + + Copyright (c) 2026 Sebastian Pipping + Licensed under the MIT license: + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to permit + persons to whom the Software is furnished to do so, subject to the + following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT +*/ + +#if ! defined(EXPAT_XCS_H) + +# include // size_t +# include "expat_external.h" // for XML_Char + +extern size_t xcslen(const XML_Char *s); + +extern int xcscmp(const XML_Char *a, const XML_Char *b); +extern int xcsncmp(const XML_Char *a, const XML_Char *b, size_t len); + +extern const XML_Char *xcsnstr(const XML_Char *haystack, const XML_Char *needle, + size_t maxLen); + +#endif // ! defined(EXPAT_XCS_H) diff --git a/Modules/expat/xcsinc.c b/Modules/expat/xcsinc.c deleted file mode 100644 index 3597c2480bc9617..000000000000000 --- a/Modules/expat/xcsinc.c +++ /dev/null @@ -1,48 +0,0 @@ -/* This file is included from other .c files! - __ __ _ - ___\ \/ /_ __ __ _| |_ - / _ \\ /| '_ \ / _` | __| - | __// \| |_) | (_| | |_ - \___/_/\_\ .__/ \__,_|\__| - |_| XML parser - - Copyright (c) 2022 Sebastian Pipping - Licensed under the MIT license: - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to permit - persons to whom the Software is furnished to do so, subject to the - following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -static size_t -xcslen(const XML_Char *s) { -#ifdef XML_UNICODE -# ifdef XML_UNICODE_WCHAR_T - return wcslen(s); -# else - // XML_Char is unsigned short - size_t len = 0; - while (s[len]) { - len++; - } - return len; -# endif -#else - return strlen(s); -#endif -} diff --git a/Modules/expat/xmlparse.c b/Modules/expat/xmlparse.c index d961ebf227e7405..40d34923e45246a 100644 --- a/Modules/expat/xmlparse.c +++ b/Modules/expat/xmlparse.c @@ -1,4 +1,4 @@ -/* 5de44e6750c6cc78818f06ed552f522a1241df0299395250e1792cb339389daf (2.8.2+) +/* 643e4d909658296100c7d226d5c26bf60bf9d6377fb83d7b5415d7193809f8f7 (2.11.0+) __ __ _ ___\ \/ /_ __ __ _| |_ / _ \\ /| '_ \ / _` | __| @@ -50,6 +50,16 @@ Copyright (c) 2026 Nick Begg Copyright (c) 2026 Kartik Kenchi Copyright (c) 2026 Haris Hussain + Copyright (c) 2026 Evgeny Kotkov + Copyright (c) 2026 Darren Carreras + Copyright (c) 2026 Alberto Maschietto + Copyright (c) 2026 Zeyou Liu + Copyright (c) 2026 Stan Ulbrych + Copyright (c) 2026 Braian Plaku + Copyright (c) 2026 Filippo Tedeschi + Copyright (c) 2026 Junki Lee + Copyright (c) 2026 Shani Yosef + Copyright (c) 2026 Pu Cheng Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining @@ -70,6 +80,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ #define XML_BUILDING_EXPAT 1 @@ -93,12 +105,13 @@ #include #include /* memset(), memcpy() */ #include -#include /* INT_MAX, LLONG_MAX, LONG_MAX, UINT_MAX */ +#include /* INT_MAX, UINT_MAX */ #include /* fprintf */ #include /* getenv */ -#include /* SIZE_MAX, uintptr_t */ +#include /* SIZE_MAX, UINT64_MAX, uint64_t, uintptr_t */ #include /* isnan */ #include +#include /* wcsncmp */ #ifdef _WIN32 # define getpid GetCurrentProcessId @@ -117,7 +130,7 @@ #include "ascii.h" #include "expat.h" #include "siphash.h" -#include "xcsinc.c" +#include "xcs.h" #if defined(HAVE_ARC4RANDOM) # include "random_arc4random.h" @@ -211,12 +224,6 @@ typedef char ICHAR; #endif -#ifdef XML_LARGE_SIZE -# define XML_INDEX_MAX LLONG_MAX -#else -# define XML_INDEX_MAX LONG_MAX -#endif - /* Round up n to be a multiple of sz, where sz is a power of 2. */ #define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1)) @@ -226,25 +233,11 @@ typedef char ICHAR; #define EXPAT_MIN(a, b) (((a) < (b)) ? (a) : (b)) #include "internal.h" +#include "hash_table.h" +#include "entities.h" #include "xmltok.h" #include "xmlrole.h" -typedef const XML_Char *KEY; - -typedef struct { - KEY name; -} NAMED; - -typedef struct { - NAMED **v; - unsigned char power; - size_t size; - size_t used; - XML_Parser parser; -} HASH_TABLE; - -static size_t keylen(KEY s); - static void copy_salt_to_sipkey(XML_Parser parser, struct sipkey *key); /* For probing (after a collision) we need a step size relative prime @@ -260,11 +253,6 @@ static void copy_salt_to_sipkey(XML_Parser parser, struct sipkey *key); #define PROBE_STEP(hash, mask, power) \ ((unsigned char)((SECOND_HASH(hash, mask, power)) | 1)) -typedef struct { - NAMED **p; - NAMED **end; -} HASH_TABLE_ITER; - #define INIT_TAG_BUF_SIZE 32 /* must be a multiple of sizeof(XML_Char) */ #define INIT_DATA_BUF_SIZE 1024 #define INIT_ATTS_SIZE 16 @@ -314,7 +302,7 @@ typedef struct { typedef struct tag { struct tag *parent; /* parent of this element */ const char *rawName; /* tagName in the original encoding */ - int rawNameLength; + size_t rawNameLength; TAG_NAME name; /* tagName in the API encoding */ union { char *raw; /* for byte-level access (rawName storage) */ @@ -324,39 +312,21 @@ typedef struct tag { BINDING *bindings; } TAG; -typedef struct { - const XML_Char *name; - const XML_Char *textPtr; - int textLen; /* length in XML_Chars */ - int processed; /* # of processed bytes - when suspended */ - const XML_Char *systemId; - const XML_Char *base; - const XML_Char *publicId; - const XML_Char *notation; - XML_Bool open; - XML_Bool hasMore; /* true if entity has not been completely processed */ - /* An entity can be open while being already completely processed (hasMore == - XML_FALSE). The reason is the delayed closing of entities until their inner - entities are processed and closed */ - XML_Bool is_param; - XML_Bool is_internal; /* true if declared in internal subset outside PE */ -} ENTITY; - typedef struct { enum XML_Content_Type type; enum XML_Content_Quant quant; const XML_Char *name; - int firstchild; - int lastchild; - int childcnt; - int nextsib; + size_t firstchild; + size_t lastchild; + size_t childcnt; + size_t nextsib; } CONTENT_SCAFFOLD; #define INIT_SCAFFOLD_ELEMENTS 32 typedef struct block { struct block *next; - int size; + size_t size; XML_Char s[]; } BLOCK; @@ -374,16 +344,32 @@ typedef struct { typedef struct attribute_id { XML_Char *name; PREFIX *prefix; - XML_Bool maybeTokenized; - XML_Bool xmlns; + bool maybeTokenized; + bool xmlns; } ATTRIBUTE_ID; typedef struct { const ATTRIBUTE_ID *id; - XML_Bool isCdata; + bool isCdata; const XML_Char *value; } DEFAULT_ATTRIBUTE; +// This structure allows mapping attribute names to instances of +// `DEFAULT_ATTRIBUTE`. +typedef struct { + // Member `name` goes first to make this structure compatible with structure + // `NAMED` (further up), which is needed to support use of structure + // `NAME_AND_DEFAULT_ATTRIBUTE` in a hash table as implemented by function + // `lookup` (further down). + const XML_Char *name; + // We would store a `DEFAULT_ATTRIBUTE *` here but the backing array + // can be reallocated which would invalidate the pointer. Using an index + // into the array instead, avoids that problem. + size_t attIndex; + // This is set to `false` by function `lookup`. + bool initialized; +} NAME_AND_DEFAULT_ATTRIBUTE; + typedef struct { unsigned long version; unsigned long hash; @@ -397,7 +383,7 @@ typedef struct { size_t nDefaultAtts; size_t allocDefaultAtts; DEFAULT_ATTRIBUTE *defaultAtts; - HASH_TABLE defaultAttsNames; + HASH_TABLE defaultAttForName; } ELEMENT_TYPE; typedef struct { @@ -415,18 +401,18 @@ typedef struct { XML_Bool standalone; #ifdef XML_DTD /* indicates if external PE has been read */ - XML_Bool paramEntityRead; + bool paramEntityRead; HASH_TABLE paramEntities; #endif /* XML_DTD */ PREFIX defaultPrefix; /* === scaffolding for building content model === */ - XML_Bool in_eldecl; + bool in_eldecl; CONTENT_SCAFFOLD *scaffold; - unsigned contentStringLen; - unsigned scaffSize; - unsigned scaffCount; - int scaffLevel; - int *scaffIndex; + size_t contentStringLen; + size_t scaffSize; + size_t scaffCount; + size_t scaffLevel; + size_t *scaffIndex; size_t scaffIndexSize; } DTD; @@ -442,7 +428,7 @@ typedef struct open_internal_entity { struct open_internal_entity *next; ENTITY *entity; int startTagLevel; - XML_Bool betweenDecl; /* WFC: PE Between Declarations */ + bool betweenDecl; /* WFC: PE Between Declarations */ enum EntityType type; } OPEN_INTERNAL_ENTITY; @@ -454,7 +440,6 @@ enum XML_Account { }; #if XML_GE == 1 -typedef unsigned long long XmlBigCount; typedef struct accounting { XmlBigCount countBytesDirect; XmlBigCount countBytesIndirect; @@ -464,8 +449,9 @@ typedef struct accounting { } ACCOUNTING; typedef struct MALLOC_TRACKER { - XmlBigCount bytesAllocated; - XmlBigCount peakBytesAllocated; // updated live only for debug level >=2 + size_t bytesAllocated; + size_t peakBytesAllocated; // updated live only for debug level >=2 + size_t bytesAllocatedWhenLastReset; unsigned long debugLevel; float maximumAmplificationFactor; // >=1.0 XmlBigCount activationThresholdBytes; @@ -477,10 +463,17 @@ typedef struct entity_stats { unsigned int maximumDepthSeen; unsigned long debugLevel; } ENTITY_STATS; + +/* One pending entity-analysis task on the explicit stack used by + resolveEntityClosureExpandedSize's depth-first search over the entity + reference graph. */ +typedef struct { + ENTITY *entity; /* entity currently being scanned */ +} ENTITY_ANALYSIS_TASK; #endif /* XML_GE == 1 */ -typedef enum XML_Error PTRCALL Processor(XML_Parser parser, const char *start, - const char *end, const char **endPtr); +typedef enum XML_Error Processor(XML_Parser parser, const char *start, + const char *end, const char **endPtr); static Processor prologProcessor; static Processor prologInitProcessor; @@ -512,7 +505,7 @@ static enum XML_Error doProlog(XML_Parser parser, const ENCODING *enc, XML_Bool haveMore, XML_Bool allowClosingDoctype, enum XML_Account account); static enum XML_Error processEntity(XML_Parser parser, ENTITY *entity, - XML_Bool betweenDecl, enum EntityType type); + bool betweenDecl, enum EntityType type); static enum XML_Error doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, const char *start, const char *end, const char **endPtr, @@ -536,15 +529,15 @@ static enum XML_Error addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, const XML_Char *uri, BINDING **bindingsPtr); static int defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, - XML_Bool isCdata, XML_Bool isId, - const XML_Char *value, XML_Parser parser); + bool isCdata, bool isId, const XML_Char *value, + XML_Parser parser); static enum XML_Error storeAttributeValue(XML_Parser parser, - const ENCODING *enc, XML_Bool isCdata, + const ENCODING *enc, bool isCdata, const char *ptr, const char *end, STRING_POOL *pool, enum XML_Account account); static enum XML_Error -appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, +appendAttributeValue(XML_Parser parser, const ENCODING *enc, bool isCdata, const char *ptr, const char *end, STRING_POOL *pool, enum XML_Account account, const char **nextPtr); static ATTRIBUTE_ID *getAttributeId(XML_Parser parser, const ENCODING *enc, @@ -559,6 +552,9 @@ static enum XML_Error callStoreEntityValue(XML_Parser parser, const ENCODING *enc, const char *start, const char *end, enum XML_Account account); +static enum XML_Error resolveEntityClosureExpandedSize(XML_Parser parser, + HASH_TABLE *table, + ENTITY *root); #else static enum XML_Error storeSelfEntityValue(XML_Parser parser, ENTITY *entity); #endif @@ -568,11 +564,13 @@ static int reportComment(XML_Parser parser, const ENCODING *enc, const char *start, const char *end); static void reportDefault(XML_Parser parser, const ENCODING *enc, const char *start, const char *end); +static void reportCharacterData(XML_Parser parser, const XML_Char *s, + size_t len); static const XML_Char *getContext(XML_Parser parser); static XML_Bool setContext(XML_Parser parser, const XML_Char *context); -static void FASTCALL normalizePublicId(XML_Char *s); +static void normalizePublicId(XML_Char *s); static DTD *dtdCreate(XML_Parser parser); /* do not call if m_parentParser != NULL */ @@ -582,34 +580,24 @@ static int dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, XML_Parser parser); static int copyEntityTable(XML_Parser oldParser, HASH_TABLE *newTable, STRING_POOL *newPool, const HASH_TABLE *oldTable); -static NAMED *lookup(XML_Parser parser, HASH_TABLE *table, KEY name, - size_t createSize); -static void FASTCALL hashTableInit(HASH_TABLE *table, XML_Parser parser); -static void FASTCALL hashTableClear(HASH_TABLE *table); -static void FASTCALL hashTableDestroy(HASH_TABLE *table); -static void FASTCALL hashTableIterInit(HASH_TABLE_ITER *iter, - const HASH_TABLE *table); -static NAMED *FASTCALL hashTableIterNext(HASH_TABLE_ITER *iter); - -static void FASTCALL poolInit(STRING_POOL *pool, XML_Parser parser); -static void FASTCALL poolClear(STRING_POOL *pool); -static void FASTCALL poolDestroy(STRING_POOL *pool); + +static void poolInit(STRING_POOL *pool, XML_Parser parser); +static void poolClear(STRING_POOL *pool); +static void poolDestroy(STRING_POOL *pool); static XML_Char *poolAppend(STRING_POOL *pool, const ENCODING *enc, const char *ptr, const char *end); static XML_Char *poolStoreString(STRING_POOL *pool, const ENCODING *enc, const char *ptr, const char *end); -static XML_Bool FASTCALL poolGrow(STRING_POOL *pool); -static bool FASTCALL poolGrowUntil(STRING_POOL *pool, size_t needed); -static const XML_Char *FASTCALL poolCopyString(STRING_POOL *pool, - const XML_Char *s); -static const XML_Char *FASTCALL poolCopyStringNoFinish(STRING_POOL *pool, - const XML_Char *s); +static XML_Bool poolGrow(STRING_POOL *pool); +static bool poolGrowUntil(STRING_POOL *pool, size_t needed); +static const XML_Char *poolCopyString(STRING_POOL *pool, const XML_Char *s); +static const XML_Char *poolCopyStringNoFinish(STRING_POOL *pool, + const XML_Char *s); static const XML_Char *poolCopyStringN(STRING_POOL *pool, const XML_Char *s, - int n); -static const XML_Char *FASTCALL poolAppendString(STRING_POOL *pool, - const XML_Char *s); + size_t n); +static const XML_Char *poolAppendString(STRING_POOL *pool, const XML_Char *s); -static int FASTCALL nextScaffoldPart(XML_Parser parser); +static expat_ssize_t nextScaffoldPart(XML_Parser parser); static XML_Content *build_model(XML_Parser parser); static ELEMENT_TYPE *getElementType(XML_Parser parser, const ENCODING *enc, const char *ptr, const char *end); @@ -624,12 +612,19 @@ static XML_Parser parserCreate(const XML_Char *encodingName, const XML_Char *nameSep, DTD *dtd, XML_Parser parentParser); -static void parserInit(XML_Parser parser, const XML_Char *encodingName); +static void parserInit(XML_Parser parser, const XML_Char *encodingName, + bool isReset); + +static void *internalGetBuffer64(XML_Parser parser, size_t len); #if XML_GE == 1 -static float accountingGetCurrentAmplification(XML_Parser rootParser); -static void accountingReportStats(XML_Parser originParser, const char *epilog); -static void accountingOnAbort(XML_Parser originParser); +static float accountingGetCurrentAmplification(XML_Parser rootParser, + XmlBigCount extraIndirectBytes); +static void accountingReportStats(XML_Parser originParser, const char *epilog, + XmlBigCount extraIndirectBytes, + int sourceLine); +static void accountingOnAbort(XML_Parser originParser, + XmlBigCount extraIndirectBytes, int sourceLine); static void accountingReportDiff(XML_Parser rootParser, unsigned int levelsAwayFromRootParser, const char *before, const char *after, @@ -639,6 +634,9 @@ static XML_Bool accountingDiffTolerated(XML_Parser originParser, int tok, const char *before, const char *after, int source_line, enum XML_Account account); +static XML_Bool +accountingCurrentAmplificationTolerated(XML_Parser rootParser, + XmlBigCount extraIndirectBytes); static void entityTrackingReportStats(XML_Parser parser, ENTITY *entity, const char *action, int sourceLine); @@ -646,6 +644,10 @@ static void entityTrackingOnOpen(XML_Parser parser, ENTITY *entity, int sourceLine); static void entityTrackingOnClose(XML_Parser parser, ENTITY *entity, int sourceLine); +static void entityTrackingOnScanStart(XML_Parser parser, ENTITY *entity, + int sourceLine); +static void entityTrackingOnScanStop(XML_Parser parser, ENTITY *entity, + int sourceLine); #endif /* XML_GE == 1 */ static XML_Parser getRootParserOf(XML_Parser parser, @@ -658,6 +660,25 @@ static bool poolAppendChar(STRING_POOL *pool, XML_Char c); static bool poolAppendChars(STRING_POOL *pool, const XML_Char *s, size_t len); +#if XML_GE == 1 +static enum XML_Prop_Error setBillionLaughsAttackProtectionMaximumAmplification( + XML_Parser parser, float maximumAmplificationFactor); + +static enum XML_Prop_Error setBillionLaughsAttackProtectionActivationThreshold( + XML_Parser parser, unsigned long long activationThresholdBytes); + +static enum XML_Prop_Error +setAllocTrackerMaximumAmplification(XML_Parser parser, + float maximumAmplificationFactor); + +static enum XML_Prop_Error +setAllocTrackerActivationThreshold(XML_Parser parser, + unsigned long long activationThresholdBytes); +#endif /* XML_GE == 1 */ + +static enum XML_Prop_Error setReparseDeferralEnabled(XML_Parser parser, + XML_Bool enabled); + #define poolStart(pool) ((pool)->start) #define poolLength(pool) ((pool)->ptr - (pool)->start) #define poolChop(pool) ((void)--(pool->ptr)) @@ -719,11 +740,11 @@ struct XML_ParserStruct { char *m_bufferEnd; // past last character to be parsed const char *m_bufferLim; // allocated end of m_buffer - XML_Index m_parseEndByteIndex; + uint64_t m_parseEndByteIndex; const char *m_parseEndPtr; size_t m_partialTokenBytesBefore; /* used in heuristic to avoid O(n^2) */ XML_Bool m_reparseDeferralEnabled; - int m_lastBufferRequestSize; + size_t m_lastBufferRequestSize; XML_Char *m_dataBuf; XML_Char *m_dataBufEnd; XML_StartElementHandler m_startElementHandler; @@ -758,6 +779,8 @@ struct XML_ParserStruct { void *m_unknownEncodingMem; void *m_unknownEncodingData; void *m_unknownEncodingHandlerData; + // Application callback invoked by callUnknownEncodingConvert. + int(XMLCALL *m_unknownEncodingConvert)(void *, const char *); void(XMLCALL *m_unknownEncodingRelease)(void *); PROLOG_STATE m_prologState; Processor *m_processor; @@ -780,8 +803,8 @@ struct XML_ParserStruct { const XML_Char *m_declNotationPublicId; ELEMENT_TYPE *m_declElementType; ATTRIBUTE_ID *m_declAttributeId; - XML_Bool m_declAttributeIsCdata; - XML_Bool m_declAttributeIsId; + bool m_declAttributeIsCdata; + bool m_declAttributeIsId; DTD *m_dtd; const XML_Char *m_curBase; TAG *m_tagStack; @@ -795,9 +818,6 @@ struct XML_ParserStruct { NS_ATT *m_nsAtts; unsigned long m_nsAttsVersion; unsigned char m_nsAttsPower; -#ifdef XML_ATTR_INFO - XML_AttrInfo *m_attInfo; -#endif POSITION m_position; STRING_POOL m_tempPool; STRING_POOL m_temp2Pool; @@ -834,33 +854,44 @@ struct XML_ParserStruct { #if XML_GE == 1 static void -expat_heap_stat(XML_Parser rootParser, char operator, XmlBigCount absDiff, - XmlBigCount newTotal, XmlBigCount peakTotal, int sourceLine) { +expat_heap_stat(XML_Parser rootParser, char operator, size_t absDiff, + size_t newTotal, size_t peakTotal, int sourceLine) { // NOTE: This can be +infinity or -nan const float amplification = (float)newTotal / (float)rootParser->m_accounting.countBytesDirect; fprintf( stderr, - "expat: Allocations(%p): Direct " EXPAT_FMT_ULL("10") ", allocated %c" EXPAT_FMT_ULL( - "10") " to " EXPAT_FMT_ULL("10") " (" EXPAT_FMT_ULL("10") " peak), amplification %8.2f (xmlparse.c:%d)\n", + "expat: Allocations(%p): Direct " EXPAT_FMT_ULL("10") ", allocated %c" EXPAT_FMT_SIZE_T( + "10") " to " EXPAT_FMT_SIZE_T("10") " (" EXPAT_FMT_SIZE_T("10") " peak), amplification %8.2f (xmlparse.c:%d)\n", (void *)rootParser, rootParser->m_accounting.countBytesDirect, operator, absDiff, newTotal, peakTotal, (double)amplification, sourceLine); } static bool -expat_heap_increase_tolerable(XML_Parser rootParser, XmlBigCount increase, +expat_heap_increase_tolerable(XML_Parser rootParser, size_t increase, int sourceLine) { assert(rootParser != NULL); assert(increase > 0); - XmlBigCount newTotal = 0; + size_t newTotal = 0; bool tolerable = true; + // The idea is to subtract the amount of memory that was already + // allocated the last time that `XML_ParserReset` was called for + // this parser, the memory use of one document could skew the + // memory statso of the next document. + const size_t bytesAllocated + = (rootParser->m_alloc_tracker.bytesAllocatedWhenLastReset + > rootParser->m_alloc_tracker.bytesAllocated) + ? 0 + : (rootParser->m_alloc_tracker.bytesAllocated + - rootParser->m_alloc_tracker.bytesAllocatedWhenLastReset); + // Detect integer overflow - if ((XmlBigCount)-1 - rootParser->m_alloc_tracker.bytesAllocated < increase) { + if (SIZE_MAX - bytesAllocated < increase) { tolerable = false; } else { - newTotal = rootParser->m_alloc_tracker.bytesAllocated + increase; + newTotal = bytesAllocated + increase; if (newTotal >= rootParser->m_alloc_tracker.activationThresholdBytes) { assert(newTotal > 0); @@ -897,8 +928,7 @@ expat_malloc(XML_Parser parser, size_t size, int sourceLine) { const size_t bytesToAllocate = sizeof(size_t) + EXPAT_MALLOC_PADDING + size; - if ((XmlBigCount)-1 - rootParser->m_alloc_tracker.bytesAllocated - < bytesToAllocate) { + if (SIZE_MAX - rootParser->m_alloc_tracker.bytesAllocated < bytesToAllocate) { return NULL; // i.e. signal integer overflow as out-of-memory } @@ -1008,9 +1038,10 @@ expat_realloc(XML_Parser parser, void *ptr, size_t size, int sourceLine) { } } - // NOTE: Integer overflow detection has already been done for us - // by expat_heap_increase_tolerable(..) above - assert(SIZE_MAX - sizeof(size_t) - EXPAT_MALLOC_PADDING >= size); + // Detect and prevent integer overflow + if (size > SIZE_MAX - sizeof(size_t) - EXPAT_MALLOC_PADDING) { + return NULL; + } // Actually allocate mallocedPtr = parser->m_mem.realloc_fcn( @@ -1022,8 +1053,7 @@ expat_realloc(XML_Parser parser, void *ptr, size_t size, int sourceLine) { // Update accounting if (isIncrease) { - assert((XmlBigCount)-1 - rootParser->m_alloc_tracker.bytesAllocated - >= absDiff); + assert(SIZE_MAX - rootParser->m_alloc_tracker.bytesAllocated >= absDiff); rootParser->m_alloc_tracker.bytesAllocated += absDiff; } else { // i.e. decrease assert(rootParser->m_alloc_tracker.bytesAllocated >= absDiff); @@ -1101,7 +1131,7 @@ gather_time_entropy(void) { static struct sipkey ENTROPY_DEBUG(const char *label, struct sipkey entropy_128) { - if (getDebugLevel("EXPAT_ENTROPY_DEBUG", 0) >= 1u) { + if (getDebugLevel("EXPAT_ENTROPY_DEBUG", 0) >= 1) { fprintf(stderr, "expat: Entropy: %s --> [0x" EXPAT_FMT_LLX( "016") ", 0x" EXPAT_FMT_LLX("016") "] (16 bytes)\n", @@ -1180,6 +1210,25 @@ isCalledFromInsideHandler(XML_Parser parser) { return parser->m_handlerCallDepth > 0; } +static void +callUnknownEncodingRelease(XML_Parser parser) { + beforeHandler(parser); + parser->m_unknownEncodingRelease(parser->m_unknownEncodingData); + afterHandler(parser); + parser->m_unknownEncodingRelease = NULL; + parser->m_unknownEncodingData = NULL; +} + +static int XMLCALL +callUnknownEncodingConvert(void *data, const char *p) { + XML_Parser parser = data; + beforeHandler(parser); + const int result + = parser->m_unknownEncodingConvert(parser->m_unknownEncodingData, p); + afterHandler(parser); + return result; +} + static enum XML_Error callProcessor(XML_Parser parser, const char *start, const char *end, const char **endPtr) { @@ -1199,9 +1248,8 @@ callProcessor(XML_Parser parser, const char *start, const char *end, available_buffer += EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_bufferEnd); // m_lastBufferRequestSize is never assigned a value < 0, so the cast is ok - const bool enough - = (have_now >= 2 * had_before) - || ((size_t)parser->m_lastBufferRequestSize > available_buffer); + const bool enough = (have_now >= 2 * had_before) + || (parser->m_lastBufferRequestSize > available_buffer); if (! enough) { *endPtr = start; // callers may expect this to be set @@ -1334,8 +1382,7 @@ parserCreate(const XML_Char *encodingName, // Initialize .m_alloc_tracker memset(&parser->m_alloc_tracker, 0, sizeof(MALLOC_TRACKER)); if (parentParser == NULL) { - parser->m_alloc_tracker.debugLevel - = getDebugLevel("EXPAT_MALLOC_DEBUG", 0u); + parser->m_alloc_tracker.debugLevel = getDebugLevel("EXPAT_MALLOC_DEBUG", 0); parser->m_alloc_tracker.maximumAmplificationFactor = EXPAT_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION_DEFAULT; parser->m_alloc_tracker.activationThresholdBytes @@ -1380,20 +1427,9 @@ parserCreate(const XML_Char *encodingName, FREE(parser, parser); return NULL; } -#ifdef XML_ATTR_INFO - parser->m_attInfo = MALLOC(parser, parser->m_attsSize * sizeof(XML_AttrInfo)); - if (parser->m_attInfo == NULL) { - FREE(parser, parser->m_atts); - FREE(parser, parser); - return NULL; - } -#endif parser->m_dataBuf = MALLOC(parser, INIT_DATA_BUF_SIZE * sizeof(XML_Char)); if (parser->m_dataBuf == NULL) { FREE(parser, parser->m_atts); -#ifdef XML_ATTR_INFO - FREE(parser, parser->m_attInfo); -#endif FREE(parser, parser); return NULL; } @@ -1406,9 +1442,6 @@ parserCreate(const XML_Char *encodingName, if (parser->m_dtd == NULL) { FREE(parser, parser->m_dataBuf); FREE(parser, parser->m_atts); -#ifdef XML_ATTR_INFO - FREE(parser, parser->m_attInfo); -#endif FREE(parser, parser); return NULL; } @@ -1436,7 +1469,7 @@ parserCreate(const XML_Char *encodingName, poolInit(&parser->m_tempPool, parser); poolInit(&parser->m_temp2Pool, parser); - parserInit(parser, encodingName); + parserInit(parser, encodingName, /*isReset=*/false); if (encodingName && ! parser->m_protocolEncodingName) { if (dtd) { @@ -1463,14 +1496,14 @@ parserCreate(const XML_Char *encodingName, } static void -parserInit(XML_Parser parser, const XML_Char *encodingName) { +parserInit(XML_Parser parser, const XML_Char *encodingName, bool isReset) { parser->m_processor = prologInitProcessor; XmlPrologStateInit(&parser->m_prologState); if (encodingName != NULL) { parser->m_protocolEncodingName = copyString(encodingName, parser); } parser->m_curBase = NULL; - XmlInitEncoding(&parser->m_initEncoding, &parser->m_encoding, 0); + XmlInitEncoding(&parser->m_initEncoding, &parser->m_encoding, NULL); parser->m_userData = NULL; parser->m_handlerArg = NULL; parser->m_startElementHandler = NULL; @@ -1511,8 +1544,8 @@ parserInit(XML_Parser parser, const XML_Char *encodingName) { parser->m_declAttributeType = NULL; parser->m_declNotationName = NULL; parser->m_declNotationPublicId = NULL; - parser->m_declAttributeIsCdata = XML_FALSE; - parser->m_declAttributeIsId = XML_FALSE; + parser->m_declAttributeIsCdata = false; + parser->m_declAttributeIsId = false; memset(&parser->m_position, 0, sizeof(POSITION)); parser->m_errorCode = XML_ERROR_NONE; parser->m_eventPtr = NULL; @@ -1526,10 +1559,13 @@ parserInit(XML_Parser parser, const XML_Char *encodingName) { parser->m_tagStack = NULL; parser->m_inheritedBindings = NULL; parser->m_nSpecifiedAtts = 0; + parser->m_idAttIndex = -1; parser->m_unknownEncodingMem = NULL; + parser->m_unknownEncodingConvert = NULL; parser->m_unknownEncodingRelease = NULL; parser->m_unknownEncodingData = NULL; parser->m_parsingStatus.parsing = XML_INITIALIZED; + parser->m_parsingStatus.finalBuffer = XML_FALSE; // Reentry can only be triggered inside m_processor calls parser->m_reenter = XML_FALSE; parser->m_handlerCallDepth = 0; @@ -1543,20 +1579,29 @@ parserInit(XML_Parser parser, const XML_Char *encodingName) { parser->m_hash_secret_salt_set = XML_FALSE; #if XML_GE == 1 - memset(&parser->m_accounting, 0, sizeof(ACCOUNTING)); - parser->m_accounting.debugLevel = getDebugLevel("EXPAT_ACCOUNTING_DEBUG", 0u); - parser->m_accounting.maximumAmplificationFactor - = EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT; - parser->m_accounting.activationThresholdBytes - = EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT; - - memset(&parser->m_entity_stats, 0, sizeof(ENTITY_STATS)); - parser->m_entity_stats.debugLevel = getDebugLevel("EXPAT_ENTITY_DEBUG", 0u); + parser->m_accounting.countBytesDirect = 0; + parser->m_accounting.countBytesIndirect = 0; + if (! isReset) { + parser->m_accounting.debugLevel + = getDebugLevel("EXPAT_ACCOUNTING_DEBUG", 0); + parser->m_accounting.maximumAmplificationFactor + = EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT; + parser->m_accounting.activationThresholdBytes + = EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT; + } + + parser->m_entity_stats.countEverOpened = 0; + parser->m_entity_stats.currentDepth = 0; + parser->m_entity_stats.maximumDepthSeen = 0; + if (! isReset) + parser->m_entity_stats.debugLevel = getDebugLevel("EXPAT_ENTITY_DEBUG", 0); +#else + UNUSED_P(isReset); #endif } /* moves list of bindings to m_freeBindingList */ -static void FASTCALL +static void moveToFreeBindingList(XML_Parser parser, BINDING *bindings) { while (bindings) { BINDING *b = bindings; @@ -1586,6 +1631,10 @@ XML_ParserReset(XML_Parser parser, const XML_Char *encodingName) { if (parser->m_parentParser) return XML_FALSE; + // The application-defined release callback may access the parser, so it + // must run before any parser state is freed. + if (parser->m_unknownEncodingRelease) + callUnknownEncodingRelease(parser); /* move m_tagStack to m_freeTagList */ tStk = parser->m_tagStack; while (tStk) { @@ -1606,14 +1655,24 @@ XML_ParserReset(XML_Parser parser, const XML_Char *encodingName) { moveEntityList(&parser->m_freeEntities, &parser->m_openValueEntities); moveToFreeBindingList(parser, parser->m_inheritedBindings); FREE(parser, parser->m_unknownEncodingMem); - if (parser->m_unknownEncodingRelease) - parser->m_unknownEncodingRelease(parser->m_unknownEncodingData); poolClear(&parser->m_tempPool); poolClear(&parser->m_temp2Pool); FREE(parser, (void *)parser->m_protocolEncodingName); parser->m_protocolEncodingName = NULL; - parserInit(parser, encodingName); + parserInit(parser, encodingName, /*isReset=*/true); dtdReset(parser->m_dtd, parser); + +#if XML_GE == 1 + parser->m_alloc_tracker.bytesAllocatedWhenLastReset + = parser->m_alloc_tracker.bytesAllocated; +#endif + + // NOTE: This effectively checks for `copyString` having failed during the + // call to `parserInit` above + if (encodingName && ! parser->m_protocolEncodingName) { + parser->m_errorCode = XML_ERROR_NO_MEMORY; + return XML_FALSE; + } return XML_TRUE; } @@ -1829,7 +1888,7 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser, const XML_Char *context, return parser; } -static void FASTCALL +static void destroyBindings(BINDING *bindings, XML_Parser parser) { for (;;) { BINDING *b = bindings; @@ -1846,6 +1905,10 @@ XML_ParserFree(XML_Parser parser) { TAG *tagList; if ((parser == NULL) || isCalledFromInsideHandler(parser)) return; + // The application-defined release callback may access the parser, so it + // must run before any parser state is freed. + if (parser->m_unknownEncodingRelease) + callUnknownEncodingRelease(parser); /* free m_tagStack and m_freeTagList */ tagList = parser->m_tagStack; for (;;) { @@ -1906,9 +1969,6 @@ XML_ParserFree(XML_Parser parser) { #endif /* XML_DTD */ dtdDestroy(parser->m_dtd, (XML_Bool)! parser->m_parentParser, parser); FREE(parser, parser->m_atts); -#ifdef XML_ATTR_INFO - FREE(parser, parser->m_attInfo); -#endif FREE(parser, parser->m_groupConnector); // NOTE: We are avoiding FREE(..) here because parser->m_buffer // is not being allocated with MALLOC(..) but with plain @@ -1917,8 +1977,6 @@ XML_ParserFree(XML_Parser parser) { FREE(parser, parser->m_dataBuf); FREE(parser, parser->m_nsAtts); FREE(parser, parser->m_unknownEncodingMem); - if (parser->m_unknownEncodingRelease) - parser->m_unknownEncodingRelease(parser->m_unknownEncodingData); FREE(parser, parser); } @@ -1999,15 +2057,6 @@ XML_GetIdAttributeIndex(XML_Parser parser) { return parser->m_idAttIndex; } -#ifdef XML_ATTR_INFO -const XML_AttrInfo *XMLCALL -XML_GetAttributeInfo(XML_Parser parser) { - if (parser == NULL) - return NULL; - return parser->m_attInfo; -} -#endif - void XMLCALL XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start, XML_EndElementHandler end) { @@ -2228,9 +2277,10 @@ XML_SetParamEntityParsing(XML_Parser parser, #endif } -// DEPRECATED since Expat 2.8.0. -int XMLCALL -XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt) { +/* The body of XML_SetHashSalt, so that Expat's own tests can reach it + without tripping the deprecation of the public function. */ +XML_NONTESTING_STATIC int +xmlSetHashSalt(XML_Parser parser, unsigned long hash_salt) { if (parser == NULL) return 0; @@ -2256,6 +2306,12 @@ XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt) { return 1; } +// DEPRECATED since Expat 2.8.0. +int XMLCALL +XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt) { + return xmlSetHashSalt(parser, hash_salt); +} + XML_Bool XMLCALL XML_SetHashSalt16Bytes(XML_Parser parser, const uint8_t entropy[16]) { if (parser == NULL) @@ -2280,15 +2336,33 @@ XML_SetHashSalt16Bytes(XML_Parser parser, const uint8_t entropy[16]) { return XML_TRUE; } +static bool +isInsideEntity(XML_Parser parser) { + return parser->m_openInternalEntities || parser->m_openAttributeEntities + || parser->m_openValueEntities; +} + enum XML_Status XMLCALL XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) { - if ((parser == NULL) || (len < 0) || ((s == NULL) && (len != 0))) { - if (parser != NULL) - parser->m_errorCode = XML_ERROR_INVALID_ARGUMENT; + if (parser == NULL || isCalledFromInsideHandler(parser)) + return XML_STATUS_ERROR; + if (len < 0) { + parser->m_errorCode = XML_ERROR_INVALID_ARGUMENT; return XML_STATUS_ERROR; } - if (isCalledFromInsideHandler(parser)) + return XML_Parse64(parser, s, (size_t)len, isFinal ? XML_TRUE : XML_FALSE); +} + +enum XML_Status XMLCALL +XML_Parse64(XML_Parser parser, const char *s, size_t len, XML_Bool isFinal) { + if (parser == NULL || isCalledFromInsideHandler(parser)) + return XML_STATUS_ERROR; + + if ((s == NULL) && (len != 0)) { + parser->m_errorCode = XML_ERROR_INVALID_ARGUMENT; return XML_STATUS_ERROR; + } + switch (parser->m_parsingStatus.parsing) { case XML_SUSPENDED: parser->m_errorCode = XML_ERROR_SUSPENDED; @@ -2306,13 +2380,28 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) { parser->m_parsingStatus.parsing = XML_PARSING; } + // NOTE: This checks if we can get away without copying `s` into the buffer + // and allocating the needed space for it. #if XML_CONTEXT_BYTES == 0 + // Is the buffer empty? if (parser->m_bufferPtr == parser->m_bufferEnd) { - const char *end; - int nLeftOver; +#else + // Is this the first parse on the document (that has no chance at any past + // context bytes anyway)? + if (parser->m_parseEndByteIndex == 0) { +#endif + // This null-object trick allows us to stop worrying about case `s == NULL` + // within this branch, e.g. with `s + len - end`. + const char *const empty = ""; + if (s == NULL) { + assert(len == 0); + s = empty; + } + const char *end = s + len; + size_t nLeftOver; enum XML_Status result; /* Detect overflow (a+b > MAX <==> b > MAX-a) */ - if (len > XML_INDEX_MAX - parser->m_parseEndByteIndex) { + if ((uint64_t)len > UINT64_MAX - parser->m_parseEndByteIndex) { parser->m_errorCode = XML_ERROR_NO_MEMORY; parser->m_eventPtr = parser->m_eventEndPtr = NULL; parser->m_processor = errorProcessor; @@ -2323,81 +2412,198 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) { parser->m_lastBufferRequestSize = len; parser->m_parseEndByteIndex += len; parser->m_positionPtr = s; - parser->m_parsingStatus.finalBuffer = (XML_Bool)isFinal; + parser->m_parsingStatus.finalBuffer = isFinal; + +#if XML_CONTEXT_BYTES > 0 + // Fake presence of a buffer to functions like `XML_GetInputContext64` that + // rely on these pointers being set + /*.*/ char *const bufferBackup = parser->m_buffer; + const char *const bufferPtrBackup = parser->m_bufferPtr; + /*.*/ char *const bufferEndBackup = parser->m_bufferEnd; + const char *const bufferLimBackup = parser->m_bufferLim; + parser->m_buffer = (char *)s; + parser->m_bufferPtr = /**/ s; + parser->m_bufferEnd = (char *)end; + parser->m_bufferLim = /*...*/ end; +#endif parser->m_errorCode - = callProcessor(parser, s, parser->m_parseEndPtr = s + len, &end); + = callProcessor(parser, s, parser->m_parseEndPtr = end, &end); + +#if XML_CONTEXT_BYTES > 0 + // Undo fake buffer + parser->m_buffer = bufferBackup; + parser->m_bufferPtr = bufferPtrBackup; + parser->m_bufferEnd = bufferEndBackup; + parser->m_bufferLim = bufferLimBackup; +#endif if (parser->m_errorCode != XML_ERROR_NONE) { - parser->m_eventEndPtr = parser->m_eventPtr; + // Do we need to rescue `parser->m_eventPtr`? + // It cannot continue pointing into `s` after the call because we have + // no guarantee that that that buffer lives on. + // + // Note: The `uintptr_t` casts intend to address `6.5.8 Relational + // operators` of C99 that says that comparison of pointers that do + // not point into the same array object is undefined behavior. + if (parser->m_eventPtr && (uintptr_t)parser->m_eventPtr >= (uintptr_t)s + && (uintptr_t)parser->m_eventPtr <= (uintptr_t)(s + len)) { + const size_t rewindBy = s + len - parser->m_eventPtr; + + XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, + parser->m_eventPtr, &parser->m_position); + parser->m_positionPtr = parser->m_eventPtr; + + // Ensure presence of a buffer so that we can point `parser->m_eventPtr` + // into it to avoid `parser->m_eventPtr == NULL`. + if (! parser->m_buffer) { + const enum XML_Error errorCodeBackup = parser->m_errorCode; + if (! internalGetBuffer64(parser, 1)) { + // NOTE: parser->m_errorCode has already been set by + // XML_GetBuffer(). + parser->m_errorCode = errorCodeBackup; + parser->m_eventPtr = parser->m_eventEndPtr = NULL; + parser->m_processor = errorProcessor; + return XML_STATUS_ERROR; + } + } + assert(parser->m_buffer != NULL); + + parser->m_eventPtr = parser->m_eventEndPtr = parser->m_bufferPtr; + parser->m_positionPtr = parser->m_eventPtr; + parser->m_parseEndPtr = parser->m_eventPtr; + // To make `XML_GetCurrentByteIndex64` work: + parser->m_parseEndByteIndex -= rewindBy; + } else { + parser->m_eventPtr = parser->m_eventEndPtr = NULL; + parser->m_positionPtr = NULL; + } parser->m_processor = errorProcessor; return XML_STATUS_ERROR; - } else { - switch (parser->m_parsingStatus.parsing) { - case XML_SUSPENDED: - result = XML_STATUS_SUSPENDED; - break; - case XML_INITIALIZED: - case XML_PARSING: - if (isFinal) { - parser->m_parsingStatus.parsing = XML_FINISHED; - return XML_STATUS_OK; - } - EXPAT_FALLTHROUGH; - default: - result = XML_STATUS_OK; + } + + // Note: The `uintptr_t` casts intend to address `6.5.8 Relational + // operators` of C99 that says that comparison of pointers that do not + // point into the same array object is undefined behavior. + const bool eventPtrUseful + = isInsideEntity(parser) && parser->m_eventPtr + && (uintptr_t)parser->m_eventPtr >= (uintptr_t)s + && (uintptr_t)parser->m_eventPtr <= (uintptr_t)end; + const size_t eventContextSize + = (eventPtrUseful ? (end - parser->m_eventPtr) : 0); + const size_t eventLen + = (eventPtrUseful + ? EXPAT_SAFE_PTR_DIFF(parser->m_eventEndPtr, parser->m_eventPtr) + : 0); + assert(eventLen <= eventContextSize); + + switch (parser->m_parsingStatus.parsing) { + case XML_SUSPENDED: + result = XML_STATUS_SUSPENDED; + break; + case XML_INITIALIZED: + case XML_PARSING: + if (isFinal) { + parser->m_parsingStatus.parsing = XML_FINISHED; } + EXPAT_FALLTHROUGH; + default: + result = XML_STATUS_OK; } XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, end, &parser->m_position); + parser->m_positionPtr = end; + nLeftOver = s + len - end; - if (nLeftOver) { - // Back up and restore the parsing status to avoid XML_ERROR_SUSPENDED - // (and XML_ERROR_FINISHED) from XML_GetBuffer. - const enum XML_Parsing originalStatus = parser->m_parsingStatus.parsing; - parser->m_parsingStatus.parsing = XML_PARSING; - void *const temp = XML_GetBuffer(parser, nLeftOver); - parser->m_parsingStatus.parsing = originalStatus; - // GetBuffer may have overwritten this, but we want to remember what the - // app requested, not how many bytes were left over after parsing. - parser->m_lastBufferRequestSize = len; + assert(nLeftOver <= len); + + const size_t contextSize = (XML_CONTEXT_BYTES > eventContextSize) + ? XML_CONTEXT_BYTES + : eventContextSize; + + const size_t bytesToCopy + = (contextSize > len - nLeftOver) ? len : (contextSize + nLeftOver); + assert(bytesToCopy <= len); + + if (bytesToCopy) { + void *const temp = internalGetBuffer64(parser, bytesToCopy); if (temp == NULL) { // NOTE: parser->m_errorCode has already been set by XML_GetBuffer(). parser->m_eventPtr = parser->m_eventEndPtr = NULL; parser->m_processor = errorProcessor; return XML_STATUS_ERROR; } - // Since we know that the buffer was empty and XML_CONTEXT_BYTES is 0, we - // don't have any data to preserve, and can copy straight into the start - // of the buffer rather than the GetBuffer return pointer (which may be - // pointing further into the allocated buffer). - memcpy(parser->m_buffer, end, nLeftOver); + + // Since we know that the buffer was empty and either XML_CONTEXT_BYTES + // is 0 or this is the first parse, we don't have any data to preserve, + // and can copy straight into the start of the buffer rather than the + // XML_GetBuffer return pointer (which may be pointing further into the + // allocated buffer). + const char *const copyFrom = s + (len - bytesToCopy); + memcpy(parser->m_buffer, copyFrom, bytesToCopy); + } else { + // Ensure presence of a buffer so that we can point `parser->m_eventPtr` + // into it to avoid `parser->m_eventPtr == NULL`. + if (! parser->m_buffer) { + if (! internalGetBuffer64(parser, 1)) { + // NOTE: parser->m_errorCode has already been set by XML_GetBuffer(). + parser->m_eventPtr = parser->m_eventEndPtr = NULL; + parser->m_processor = errorProcessor; + return XML_STATUS_ERROR; + } + } } - parser->m_bufferPtr = parser->m_buffer; - parser->m_bufferEnd = parser->m_buffer + nLeftOver; + assert(parser->m_buffer != NULL); + + parser->m_bufferPtr = parser->m_buffer + (bytesToCopy - nLeftOver); + parser->m_bufferEnd = parser->m_buffer + bytesToCopy; parser->m_positionPtr = parser->m_bufferPtr; parser->m_parseEndPtr = parser->m_bufferEnd; - parser->m_eventPtr = parser->m_bufferPtr; - parser->m_eventEndPtr = parser->m_bufferPtr; + + assert((size_t)(parser->m_bufferPtr - parser->m_buffer) + >= eventContextSize); + parser->m_eventPtr = parser->m_bufferPtr - eventContextSize; + parser->m_eventEndPtr = parser->m_eventPtr + eventLen; + return result; } -#endif /* XML_CONTEXT_BYTES == 0 */ - void *buff = XML_GetBuffer(parser, len); + + void *buff = XML_GetBuffer64(parser, len); if (buff == NULL) return XML_STATUS_ERROR; if (len > 0) { assert(s != NULL); // make sure s==NULL && len!=0 was rejected above memcpy(buff, s, len); } - return XML_ParseBuffer(parser, len, isFinal); + return XML_ParseBuffer64(parser, len, isFinal); +} + +// Advances or sets `parser->m_eventPtr` if (a) it is `NULL` or (b) it points +// into the parse buffer but behind `parser->m_bufferPtr`. +static void +advanceEventPtr(XML_Parser parser) { + if (! parser->m_bufferPtr) + return; + + if (isInsideEntity(parser)) + return; + + // Note: The `uintptr_t` casts intend to address `6.5.8 Relational operators` + // of C99 that says that comparison of pointers that do not point into + // the same array object is undefined behavior. + if (parser->m_eventPtr == NULL + || ((uintptr_t)parser->m_buffer <= (uintptr_t)parser->m_eventPtr + && (uintptr_t)parser->m_eventPtr < (uintptr_t)parser->m_bufferPtr)) { + parser->m_eventPtr = parser->m_bufferPtr; + if (parser->m_eventEndPtr != NULL + && (uintptr_t)parser->m_eventEndPtr < (uintptr_t)parser->m_eventPtr) + parser->m_eventEndPtr = parser->m_bufferPtr; + } } enum XML_Status XMLCALL XML_ParseBuffer(XML_Parser parser, int len, int isFinal) { - const char *start; - enum XML_Status result = XML_STATUS_OK; - if ((parser == NULL) || isCalledFromInsideHandler(parser)) return XML_STATUS_ERROR; @@ -2406,6 +2612,17 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal) { return XML_STATUS_ERROR; } + return XML_ParseBuffer64(parser, (size_t)len, isFinal ? XML_TRUE : XML_FALSE); +} + +enum XML_Status XMLCALL +XML_ParseBuffer64(XML_Parser parser, size_t len, XML_Bool isFinal) { + if ((parser == NULL) || isCalledFromInsideHandler(parser)) + return XML_STATUS_ERROR; + + const char *start; + enum XML_Status result = XML_STATUS_OK; + switch (parser->m_parsingStatus.parsing) { case XML_SUSPENDED: parser->m_errorCode = XML_ERROR_SUSPENDED; @@ -2429,8 +2646,14 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal) { parser->m_parsingStatus.parsing = XML_PARSING; } + if (len + > (size_t)EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_bufferEnd)) { + parser->m_errorCode = XML_ERROR_INVALID_ARGUMENT; + return XML_STATUS_ERROR; + } + // Detect and avoid integer overflow - if (len > XML_INDEX_MAX - parser->m_parseEndByteIndex) { + if ((uint64_t)len > UINT64_MAX - parser->m_parseEndByteIndex) { parser->m_errorCode = XML_ERROR_NO_MEMORY; parser->m_eventPtr = parser->m_eventEndPtr = NULL; parser->m_processor = errorProcessor; @@ -2442,7 +2665,7 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal) { parser->m_bufferEnd += len; parser->m_parseEndPtr = parser->m_bufferEnd; parser->m_parseEndByteIndex += len; - parser->m_parsingStatus.finalBuffer = (XML_Bool)isFinal; + parser->m_parsingStatus.finalBuffer = isFinal; parser->m_errorCode = callProcessor(parser, start, parser->m_parseEndPtr, &parser->m_bufferPtr); @@ -2451,35 +2674,37 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal) { parser->m_eventEndPtr = parser->m_eventPtr; parser->m_processor = errorProcessor; return XML_STATUS_ERROR; - } else { - switch (parser->m_parsingStatus.parsing) { - case XML_SUSPENDED: - result = XML_STATUS_SUSPENDED; - break; - case XML_INITIALIZED: - case XML_PARSING: - if (isFinal) { - parser->m_parsingStatus.parsing = XML_FINISHED; - return result; - } - break; - default:; /* should not happen */ + } + + switch (parser->m_parsingStatus.parsing) { + case XML_SUSPENDED: + result = XML_STATUS_SUSPENDED; + break; + case XML_INITIALIZED: + case XML_PARSING: + if (isFinal) { + parser->m_parsingStatus.parsing = XML_FINISHED; + return result; } + break; + default:; /* should not happen */ } XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, parser->m_bufferPtr, &parser->m_position); parser->m_positionPtr = parser->m_bufferPtr; + advanceEventPtr(parser); return result; } /* Modifies `parser`’s buffer to be backed by `newBuf`. */ static void -setParserBuffer(XML_Parser parser, char *newBuf, int newBufSize, int keep) { +setParserBuffer(XML_Parser parser, char *newBuf, size_t newBufSize, + size_t keep) { parser->m_bufferLim = newBuf + newBufSize; if (parser->m_bufferPtr) { - const int parsing - = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr); + const size_t parsing + = EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr); memcpy(newBuf, parser->m_bufferPtr - keep, parsing + keep); // NOTE: We are avoiding FREE(..) here because parser->m_buffer // is not being allocated with MALLOC(..) but with plain @@ -2500,10 +2725,20 @@ void *XMLCALL XML_GetBuffer(XML_Parser parser, int len) { if ((parser == NULL) || isCalledFromInsideHandler(parser)) return NULL; + if (len < 0) { parser->m_errorCode = XML_ERROR_NO_MEMORY; return NULL; } + + return XML_GetBuffer64(parser, (size_t)len); +} + +void *XMLCALL +XML_GetBuffer64(XML_Parser parser, size_t len) { + if ((parser == NULL) || isCalledFromInsideHandler(parser)) + return NULL; + switch (parser->m_parsingStatus.parsing) { case XML_SUSPENDED: parser->m_errorCode = XML_ERROR_SUSPENDED; @@ -2517,37 +2752,49 @@ XML_GetBuffer(XML_Parser parser, int len) { // whether or not the request succeeds, `len` seems to be the app's preferred // buffer fill size; remember it. parser->m_lastBufferRequestSize = len; - if (len > EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_bufferEnd) + + return internalGetBuffer64(parser, len); +} + +// Like `XML_GetBuffer*` but: +// - without checking parser status +// - without recording `len` to `parser->m_lastBufferRequestSize` +static void * +internalGetBuffer64(XML_Parser parser, size_t len) { + assert(parser != NULL); + + if (len > (size_t)EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, + parser->m_bufferEnd) || parser->m_buffer == NULL) { /* Do not invoke signed arithmetic overflow: */ - int neededSize = (int)((unsigned)len - + (unsigned)EXPAT_SAFE_PTR_DIFF( - parser->m_bufferEnd, parser->m_bufferPtr)); - if (neededSize < 0) { + const size_t leftUnparsed + = EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr); + if (len > SIZE_MAX - leftUnparsed) { parser->m_errorCode = XML_ERROR_NO_MEMORY; return NULL; } + size_t neededSize = len + leftUnparsed; #if XML_CONTEXT_BYTES > 0 - const int parsed - = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer); - int keep = parsed; + const size_t parsed + = EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer); + size_t keep = parsed; if (keep > XML_CONTEXT_BYTES) keep = XML_CONTEXT_BYTES; /* Detect and prevent integer overflow */ - if (keep > INT_MAX - neededSize) { + if (keep > SIZE_MAX - neededSize) { parser->m_errorCode = XML_ERROR_NO_MEMORY; return NULL; } #else - int keep = 0; + size_t keep = 0; #endif /* XML_CONTEXT_BYTES > 0 */ neededSize += keep; if (parser->m_buffer && parser->m_bufferPtr - && neededSize - <= EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_buffer)) { + && neededSize <= (size_t)EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, + parser->m_buffer)) { #if XML_CONTEXT_BYTES > 0 if (keep < parsed) { - int offset = parsed - keep; + size_t offset = parsed - keep; /* The buffer pointers cannot be NULL here; we have at least some bytes * in the buffer */ memmove(parser->m_buffer, &parser->m_buffer[offset], @@ -2564,15 +2811,13 @@ XML_GetBuffer(XML_Parser parser, int len) { parser->m_bufferPtr = parser->m_buffer; #endif /* XML_CONTEXT_BYTES > 0 */ } else { - int bufferSize - = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_buffer); + size_t bufferSize + = EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_buffer); if (bufferSize == 0) bufferSize = INIT_BUFFER_SIZE; - do { - /* Do not invoke signed arithmetic overflow: */ - bufferSize = (int)(2U * (unsigned)bufferSize); - } while (bufferSize < neededSize && bufferSize > 0); - if (bufferSize <= 0) { + while (bufferSize < neededSize && bufferSize <= SIZE_MAX / 2) + bufferSize *= 2; + if (bufferSize < neededSize) { parser->m_errorCode = XML_ERROR_NO_MEMORY; return NULL; } @@ -2651,25 +2896,26 @@ XML_ResumeParser(XML_Parser parser) { parser->m_eventEndPtr = parser->m_eventPtr; parser->m_processor = errorProcessor; return XML_STATUS_ERROR; - } else { - switch (parser->m_parsingStatus.parsing) { - case XML_SUSPENDED: - result = XML_STATUS_SUSPENDED; - break; - case XML_INITIALIZED: - case XML_PARSING: - if (parser->m_parsingStatus.finalBuffer) { - parser->m_parsingStatus.parsing = XML_FINISHED; - return result; - } - break; - default:; + } + + switch (parser->m_parsingStatus.parsing) { + case XML_SUSPENDED: + result = XML_STATUS_SUSPENDED; + break; + case XML_INITIALIZED: + case XML_PARSING: + if (parser->m_parsingStatus.finalBuffer) { + parser->m_parsingStatus.parsing = XML_FINISHED; + return result; } + break; + default:; } XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, parser->m_bufferPtr, &parser->m_position); parser->m_positionPtr = parser->m_bufferPtr; + advanceEventPtr(parser); return result; } @@ -2688,35 +2934,57 @@ XML_GetErrorCode(XML_Parser parser) { return parser->m_errorCode; } -XML_Index XMLCALL -XML_GetCurrentByteIndex(XML_Parser parser) { +int64_t XMLCALL +XML_GetCurrentByteIndex64(XML_Parser parser) { if (parser == NULL) return -1; - if (parser->m_eventPtr) - return (XML_Index)(parser->m_parseEndByteIndex - - (parser->m_parseEndPtr - parser->m_eventPtr)); + if (parser->m_eventPtr) { + return (int64_t)(parser->m_parseEndByteIndex + - (parser->m_parseEndPtr - parser->m_eventPtr)); + } return -1; } -int XMLCALL -XML_GetCurrentByteCount(XML_Parser parser) { +// DEPRECATED since Expat 2.9.0. +XML_Index XMLCALL +XML_GetCurrentByteIndex(XML_Parser parser) { + // NOTE: XML_Index is known to wrap around for >2 GiB content + // on 32bit machines and 64bit Windows, unless (non-default and + // uncommon) XML_LARGE_SIZE is defined. + // That's a bug and it only lives on because we cannot break + // ABI compatibility of public API. + return (XML_Index)XML_GetCurrentByteIndex64(parser); +} + +uint64_t XMLCALL +XML_GetCurrentByteCount64(XML_Parser parser) { if (parser == NULL) return 0; - if (parser->m_eventEndPtr && parser->m_eventPtr) - return (int)(parser->m_eventEndPtr - parser->m_eventPtr); + if (parser->m_eventEndPtr && parser->m_eventPtr) { + return parser->m_eventEndPtr - parser->m_eventPtr; + } return 0; } +// DEPRECATED since Expat 2.9.0. +int XMLCALL +XML_GetCurrentByteCount(XML_Parser parser) { + // NOTE: int is known to wrap around for >2 GiB content. + // That's a bug and it only lives on because we cannot break + // ABI compatibility of public API. + return (int)XML_GetCurrentByteCount64(parser); +} + const char *XMLCALL -XML_GetInputContext(XML_Parser parser, int *offset, int *size) { +XML_GetInputContext64(XML_Parser parser, int64_t *offset, uint64_t *size) { #if XML_CONTEXT_BYTES > 0 - if (parser == NULL) + if (parser == NULL || ! isCalledFromInsideHandler(parser)) return NULL; if (parser->m_eventPtr && parser->m_buffer) { if (offset != NULL) - *offset = (int)(parser->m_eventPtr - parser->m_buffer); + *offset = parser->m_eventPtr - parser->m_buffer; if (size != NULL) - *size = (int)(parser->m_bufferEnd - parser->m_buffer); + *size = parser->m_bufferEnd - parser->m_buffer; return parser->m_buffer; } #else @@ -2727,8 +2995,41 @@ XML_GetInputContext(XML_Parser parser, int *offset, int *size) { return NULL; } -XML_Size XMLCALL -XML_GetCurrentLineNumber(XML_Parser parser) { +// DEPRECATED since Expat 2.9.0. +const char *XMLCALL +XML_GetInputContext(XML_Parser parser, int *offset, int *size) { +#if XML_CONTEXT_BYTES > 0 + if (parser == NULL || ! isCalledFromInsideHandler(parser)) + return NULL; + + int64_t offset64; + uint64_t size64; + + const char *const buffer = XML_GetInputContext64(parser, &offset64, &size64); + + if (buffer == NULL) + return NULL; + + // NOTE: int is known to wrap around for >2 GiB content. + // That's a bug and it only lives on because we cannot break + // ABI compatibility of public API. + if (offset != NULL) + *offset = (int)offset64; + + if (size != NULL) + *size = (int)size64; + + return buffer; +#else + (void)parser; + (void)offset; + (void)size; +#endif /* XML_CONTEXT_BYTES > 0 */ + return NULL; +} + +uint64_t XMLCALL +XML_GetCurrentLineNumber64(XML_Parser parser) { if (parser == NULL) return 0; if (parser->m_eventPtr && parser->m_eventPtr >= parser->m_positionPtr) { @@ -2739,8 +3040,19 @@ XML_GetCurrentLineNumber(XML_Parser parser) { return parser->m_position.lineNumber + 1; } +// DEPRECATED since Expat 2.9.0. XML_Size XMLCALL -XML_GetCurrentColumnNumber(XML_Parser parser) { +XML_GetCurrentLineNumber(XML_Parser parser) { + // NOTE: XML_Size is known to wrap around for >4 GiB content + // on 32bit machines and 64bit Windows, unless (non-default and + // uncommon) XML_LARGE_SIZE is defined. + // That's a bug and it only lives on because we cannot break + // ABI compatibility of public API. + return (XML_Size)XML_GetCurrentLineNumber64(parser); +} + +uint64_t XMLCALL +XML_GetCurrentColumnNumber64(XML_Parser parser) { if (parser == NULL) return 0; if (parser->m_eventPtr && parser->m_eventPtr >= parser->m_positionPtr) { @@ -2751,6 +3063,17 @@ XML_GetCurrentColumnNumber(XML_Parser parser) { return parser->m_position.columnNumber; } +// DEPRECATED since Expat 2.9.0. +XML_Size XMLCALL +XML_GetCurrentColumnNumber(XML_Parser parser) { + // NOTE: XML_Size is known to wrap around for >4 GiB content + // on 32bit machines and 64bit Windows, unless (non-default and + // uncommon) XML_LARGE_SIZE is defined. + // That's a bug and it only lives on because we cannot break + // ABI compatibility of public API. + return (XML_Size)XML_GetCurrentColumnNumber64(parser); +} + void XMLCALL XML_FreeContentModel(XML_Parser parser, XML_Content *model) { if (parser == NULL) @@ -2794,7 +3117,7 @@ XML_MemFree(XML_Parser parser, void *ptr) { void XMLCALL XML_DefaultCurrent(XML_Parser parser) { - if (parser == NULL) + if (parser == NULL || ! isCalledFromInsideHandler(parser)) return; if (parser->m_defaultHandler) { if (parser->m_openInternalEntities) @@ -2965,18 +3288,12 @@ XML_GetFeatureList(void) { {XML_FEATURE_CONTEXT_BYTES, XML_L("XML_CONTEXT_BYTES"), XML_CONTEXT_BYTES}, #endif -#ifdef XML_MIN_SIZE - {XML_FEATURE_MIN_SIZE, XML_L("XML_MIN_SIZE"), 0}, -#endif #ifdef XML_NS {XML_FEATURE_NS, XML_L("XML_NS"), 0}, #endif #ifdef XML_LARGE_SIZE {XML_FEATURE_LARGE_SIZE, XML_L("XML_LARGE_SIZE"), 0}, #endif -#ifdef XML_ATTR_INFO - {XML_FEATURE_ATTR_INFO, XML_L("XML_ATTR_INFO"), 0}, -#endif #if XML_GE == 1 /* Added in Expat 2.4.0 for XML_DTD defined and * added in Expat 2.6.0 for XML_GE == 1. */ @@ -3003,59 +3320,294 @@ XML_GetFeatureList(void) { } #if XML_GE == 1 +static enum XML_Prop_Error +setBillionLaughsAttackProtectionMaximumAmplification( + XML_Parser parser, float maximumAmplificationFactor) { + if (parser == NULL) + return XML_PROP_ERROR_PARSER_NULL; + + if (parser->m_parentParser != NULL) + return XML_PROP_ERROR_PARSER_NOT_ROOT; + + if (isnan(maximumAmplificationFactor) || (maximumAmplificationFactor < 1.0f)) + return XML_PROP_ERROR_INVALID_VALUE; + + parser->m_accounting.maximumAmplificationFactor = maximumAmplificationFactor; + + return XML_PROP_ERROR_NONE; +} + XML_Bool XMLCALL XML_SetBillionLaughsAttackProtectionMaximumAmplification( XML_Parser parser, float maximumAmplificationFactor) { - if ((parser == NULL) || (parser->m_parentParser != NULL) - || isnan(maximumAmplificationFactor) - || (maximumAmplificationFactor < 1.0f)) { - return XML_FALSE; - } - parser->m_accounting.maximumAmplificationFactor = maximumAmplificationFactor; - return XML_TRUE; + return (setBillionLaughsAttackProtectionMaximumAmplification( + parser, maximumAmplificationFactor) + == XML_PROP_ERROR_NONE) + ? XML_TRUE + : XML_FALSE; +} + +static enum XML_Prop_Error +setBillionLaughsAttackProtectionActivationThreshold( + XML_Parser parser, unsigned long long activationThresholdBytes) { + if (parser == NULL) + return XML_PROP_ERROR_PARSER_NULL; + + if (parser->m_parentParser != NULL) + return XML_PROP_ERROR_PARSER_NOT_ROOT; + + parser->m_accounting.activationThresholdBytes = activationThresholdBytes; + + return XML_PROP_ERROR_NONE; } XML_Bool XMLCALL XML_SetBillionLaughsAttackProtectionActivationThreshold( XML_Parser parser, unsigned long long activationThresholdBytes) { - if ((parser == NULL) || (parser->m_parentParser != NULL)) { - return XML_FALSE; - } - parser->m_accounting.activationThresholdBytes = activationThresholdBytes; - return XML_TRUE; + return (setBillionLaughsAttackProtectionActivationThreshold( + parser, activationThresholdBytes) + == XML_PROP_ERROR_NONE) + ? XML_TRUE + : XML_FALSE; +} + +static enum XML_Prop_Error +setAllocTrackerMaximumAmplification(XML_Parser parser, + float maximumAmplificationFactor) { + if (parser == NULL) + return XML_PROP_ERROR_PARSER_NULL; + + if (parser->m_parentParser != NULL) + return XML_PROP_ERROR_PARSER_NOT_ROOT; + + if (isnan(maximumAmplificationFactor) || (maximumAmplificationFactor < 1.0f)) + return XML_PROP_ERROR_INVALID_VALUE; + + parser->m_alloc_tracker.maximumAmplificationFactor + = maximumAmplificationFactor; + + return XML_PROP_ERROR_NONE; } XML_Bool XMLCALL XML_SetAllocTrackerMaximumAmplification(XML_Parser parser, float maximumAmplificationFactor) { - if ((parser == NULL) || (parser->m_parentParser != NULL) - || isnan(maximumAmplificationFactor) - || (maximumAmplificationFactor < 1.0f)) { - return XML_FALSE; - } - parser->m_alloc_tracker.maximumAmplificationFactor - = maximumAmplificationFactor; - return XML_TRUE; + return (setAllocTrackerMaximumAmplification(parser, + maximumAmplificationFactor) + == XML_PROP_ERROR_NONE) + ? XML_TRUE + : XML_FALSE; +} + +static enum XML_Prop_Error +setAllocTrackerActivationThreshold( + XML_Parser parser, unsigned long long activationThresholdBytes) { + if (parser == NULL) + return XML_PROP_ERROR_PARSER_NULL; + + if (parser->m_parentParser != NULL) + return XML_PROP_ERROR_PARSER_NOT_ROOT; + + parser->m_alloc_tracker.activationThresholdBytes = activationThresholdBytes; + + return XML_PROP_ERROR_NONE; } XML_Bool XMLCALL XML_SetAllocTrackerActivationThreshold( XML_Parser parser, unsigned long long activationThresholdBytes) { - if ((parser == NULL) || (parser->m_parentParser != NULL)) { - return XML_FALSE; - } - parser->m_alloc_tracker.activationThresholdBytes = activationThresholdBytes; - return XML_TRUE; + return (setAllocTrackerActivationThreshold(parser, activationThresholdBytes) + == XML_PROP_ERROR_NONE) + ? XML_TRUE + : XML_FALSE; } #endif /* XML_GE == 1 */ +static enum XML_Prop_Error +setReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled) { + if (parser == NULL) + return XML_PROP_ERROR_PARSER_NULL; + + if (enabled != XML_TRUE && enabled != XML_FALSE) + return XML_PROP_ERROR_INVALID_VALUE; + + parser->m_reparseDeferralEnabled = enabled; + + return XML_PROP_ERROR_NONE; +} + XML_Bool XMLCALL XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled) { - if (parser != NULL && (enabled == XML_TRUE || enabled == XML_FALSE)) { - parser->m_reparseDeferralEnabled = enabled; - return XML_TRUE; + return (setReparseDeferralEnabled(parser, enabled) == XML_PROP_ERROR_NONE) + ? XML_TRUE + : XML_FALSE; +} + +enum XML_Prop_Error XMLCALL +XML_SetPropertyBool(XML_Parser parser, enum XML_Parser_Property property, + XML_Bool value) { + if (parser == NULL) + return XML_PROP_ERROR_PARSER_NULL; + + switch (property) { +#if XML_GE == 1 + case XML_PROP_ALLOC_TRACKER_ACTIVATION_THRESHOLD: + case XML_PROP_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION: + case XML_PROP_BILLION_LAUGHS_ACTIVATION_THRESHOLD: + case XML_PROP_BILLION_LAUGHS_MAXIMUM_AMPLIFICATION: + return XML_PROP_ERROR_INVALID_TYPE; +#endif /* XML_GE == 1 */ + case XML_PROP_REPARSE_DEFERRAL_ENABLED: + return setReparseDeferralEnabled(parser, value); + default: + return XML_PROP_ERROR_INVALID_KEY; + } + + assert(0 && "considered unreachable"); +} + +enum XML_Prop_Error XMLCALL +XML_SetPropertyDouble(XML_Parser parser, enum XML_Parser_Property property, + double value) { + if (parser == NULL) + return XML_PROP_ERROR_PARSER_NULL; + +#if XML_GE == 0 + UNUSED_P(value); +#endif + + switch (property) { +#if XML_GE == 1 + case XML_PROP_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION: + return setAllocTrackerMaximumAmplification(parser, (float)value); + case XML_PROP_BILLION_LAUGHS_MAXIMUM_AMPLIFICATION: + return setBillionLaughsAttackProtectionMaximumAmplification(parser, + (float)value); + case XML_PROP_ALLOC_TRACKER_ACTIVATION_THRESHOLD: + case XML_PROP_BILLION_LAUGHS_ACTIVATION_THRESHOLD: +#endif /* XML_GE == 1 */ + case XML_PROP_REPARSE_DEFERRAL_ENABLED: + return XML_PROP_ERROR_INVALID_TYPE; + default: + return XML_PROP_ERROR_INVALID_KEY; + } + + assert(0 && "considered unreachable"); +} + +enum XML_Prop_Error XMLCALL +XML_SetPropertyUInt64(XML_Parser parser, enum XML_Parser_Property property, + uint64_t value) { + if (parser == NULL) + return XML_PROP_ERROR_PARSER_NULL; + +#if XML_GE == 0 + UNUSED_P(value); +#endif + + switch (property) { +#if XML_GE == 1 + case XML_PROP_ALLOC_TRACKER_ACTIVATION_THRESHOLD: + return setAllocTrackerActivationThreshold(parser, + (unsigned long long)value); + case XML_PROP_BILLION_LAUGHS_ACTIVATION_THRESHOLD: + return setBillionLaughsAttackProtectionActivationThreshold( + parser, (unsigned long long)value); + case XML_PROP_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION: + case XML_PROP_BILLION_LAUGHS_MAXIMUM_AMPLIFICATION: +#endif /* XML_GE == 1 */ + case XML_PROP_REPARSE_DEFERRAL_ENABLED: + return XML_PROP_ERROR_INVALID_TYPE; + default: + return XML_PROP_ERROR_INVALID_KEY; + } + + assert(0 && "considered unreachable"); +} + +enum XML_Prop_Error XMLCALL +XML_GetPropertyBool(XML_Parser parser, enum XML_Parser_Property property, + XML_Bool *value) { + if (parser == NULL) + return XML_PROP_ERROR_PARSER_NULL; + + if (value == NULL) + return XML_PROP_ERROR_INVALID_VALUE; + + switch (property) { +#if XML_GE == 1 + case XML_PROP_ALLOC_TRACKER_ACTIVATION_THRESHOLD: + case XML_PROP_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION: + case XML_PROP_BILLION_LAUGHS_ACTIVATION_THRESHOLD: + case XML_PROP_BILLION_LAUGHS_MAXIMUM_AMPLIFICATION: + return XML_PROP_ERROR_INVALID_TYPE; +#endif /* XML_GE == 1 */ + case XML_PROP_REPARSE_DEFERRAL_ENABLED: + *value = parser->m_reparseDeferralEnabled; + break; + default: + return XML_PROP_ERROR_INVALID_KEY; + } + + return XML_PROP_ERROR_NONE; +} + +enum XML_Prop_Error XMLCALL +XML_GetPropertyDouble(XML_Parser parser, enum XML_Parser_Property property, + double *value) { + if (parser == NULL) + return XML_PROP_ERROR_PARSER_NULL; + + if (value == NULL) + return XML_PROP_ERROR_INVALID_VALUE; + + switch (property) { +#if XML_GE == 1 + case XML_PROP_BILLION_LAUGHS_MAXIMUM_AMPLIFICATION: + *value = (double)parser->m_accounting.maximumAmplificationFactor; + break; + case XML_PROP_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION: + *value = (double)parser->m_alloc_tracker.maximumAmplificationFactor; + break; + case XML_PROP_ALLOC_TRACKER_ACTIVATION_THRESHOLD: + case XML_PROP_BILLION_LAUGHS_ACTIVATION_THRESHOLD: +#endif /* XML_GE == 1 */ + case XML_PROP_REPARSE_DEFERRAL_ENABLED: + return XML_PROP_ERROR_INVALID_TYPE; + default: + return XML_PROP_ERROR_INVALID_KEY; + } + + return XML_PROP_ERROR_NONE; +} + +enum XML_Prop_Error XMLCALL +XML_GetPropertyUInt64(XML_Parser parser, enum XML_Parser_Property property, + uint64_t *value) { + if (parser == NULL) + return XML_PROP_ERROR_PARSER_NULL; + + if (value == NULL) + return XML_PROP_ERROR_INVALID_VALUE; + + switch (property) { +#if XML_GE == 1 + case XML_PROP_BILLION_LAUGHS_ACTIVATION_THRESHOLD: + *value = parser->m_accounting.activationThresholdBytes; + break; + case XML_PROP_ALLOC_TRACKER_ACTIVATION_THRESHOLD: + *value = parser->m_alloc_tracker.activationThresholdBytes; + break; + case XML_PROP_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION: + case XML_PROP_BILLION_LAUGHS_MAXIMUM_AMPLIFICATION: +#endif /* XML_GE == 1 */ + case XML_PROP_REPARSE_DEFERRAL_ENABLED: + return XML_PROP_ERROR_INVALID_TYPE; + default: + return XML_PROP_ERROR_INVALID_KEY; } - return XML_FALSE; + + return XML_PROP_ERROR_NONE; } /* Initially tag->rawName always points into the parse buffer; @@ -3112,7 +3664,7 @@ storeRawNames(XML_Parser parser) { return XML_TRUE; } -static enum XML_Error PTRCALL +static enum XML_Error contentProcessor(XML_Parser parser, const char *start, const char *end, const char **endPtr) { enum XML_Error result = doContent( @@ -3126,7 +3678,7 @@ contentProcessor(XML_Parser parser, const char *start, const char *end, return result; } -static enum XML_Error PTRCALL +static enum XML_Error externalEntityInitProcessor(XML_Parser parser, const char *start, const char *end, const char **endPtr) { enum XML_Error result = initializeEncoding(parser); @@ -3136,7 +3688,7 @@ externalEntityInitProcessor(XML_Parser parser, const char *start, return externalEntityInitProcessor2(parser, start, end, endPtr); } -static enum XML_Error PTRCALL +static enum XML_Error externalEntityInitProcessor2(XML_Parser parser, const char *start, const char *end, const char **endPtr) { const char *next = start; /* XmlContentTok doesn't always set the last arg */ @@ -3146,7 +3698,7 @@ externalEntityInitProcessor2(XML_Parser parser, const char *start, #if XML_GE == 1 if (! accountingDiffTolerated(parser, tok, start, next, __LINE__, XML_ACCOUNT_DIRECT)) { - accountingOnAbort(parser); + accountingOnAbort(parser, 0, __LINE__); return XML_ERROR_AMPLIFICATION_LIMIT_BREACH; } #endif /* XML_GE == 1 */ @@ -3176,12 +3728,17 @@ externalEntityInitProcessor2(XML_Parser parser, const char *start, } parser->m_eventPtr = start; return XML_ERROR_PARTIAL_CHAR; + case XML_TOK_NONE: + if (! parser->m_parsingStatus.finalBuffer) { + *endPtr = start; + } + return XML_ERROR_NONE; } parser->m_processor = externalEntityInitProcessor3; return externalEntityInitProcessor3(parser, start, end, endPtr); } -static enum XML_Error PTRCALL +static enum XML_Error externalEntityInitProcessor3(XML_Parser parser, const char *start, const char *end, const char **endPtr) { int tok; @@ -3233,7 +3790,7 @@ externalEntityInitProcessor3(XML_Parser parser, const char *start, return externalEntityContentProcessor(parser, start, end, endPtr); } -static enum XML_Error PTRCALL +static enum XML_Error externalEntityContentProcessor(XML_Parser parser, const char *start, const char *end, const char **endPtr) { enum XML_Error result @@ -3275,7 +3832,7 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, : next; if (! accountingDiffTolerated(parser, tok, s, accountAfter, __LINE__, account)) { - accountingOnAbort(parser); + accountingOnAbort(parser, 0, __LINE__); return XML_ERROR_AMPLIFICATION_LIMIT_BREACH; } #endif @@ -3289,9 +3846,7 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, *eventEndPP = end; if (parser->m_characterDataHandler) { XML_Char c = 0xA; - beforeHandler(parser); - parser->m_characterDataHandler(parser->m_handlerArg, &c, 1); - afterHandler(parser); + reportCharacterData(parser, &c, 1); } else if (parser->m_defaultHandler) reportDefault(parser, enc, s, end); /* We are at the end of the final buffer, should we check for @@ -3345,9 +3900,7 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, XML_ACCOUNT_ENTITY_EXPANSION); #endif /* XML_GE == 1 */ if (parser->m_characterDataHandler) { - beforeHandler(parser); - parser->m_characterDataHandler(parser->m_handlerArg, &ch, 1); - afterHandler(parser); + reportCharacterData(parser, &ch, 1); } else if (parser->m_defaultHandler) reportDefault(parser, enc, s, next); break; @@ -3397,9 +3950,9 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, return result; } else if (parser->m_externalEntityRefHandler) { const XML_Char *context; - entity->open = XML_TRUE; + entity->open = true; context = getContext(parser); - entity->open = XML_FALSE; + entity->open = false; if (! context) return XML_ERROR_NO_MEMORY; beforeHandler(parser); @@ -3537,7 +4090,7 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, if (parser->m_tagLevel == startTagLevel) return XML_ERROR_ASYNC_ENTITY; else { - int len; + size_t len; const char *rawName; TAG *tag = parser->m_tagStack; rawName = s + enc->minBytesPerChar * 2; @@ -3608,10 +4161,8 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, return XML_ERROR_BAD_CHAR_REF; if (parser->m_characterDataHandler) { XML_Char buf[XML_ENCODE_MAX]; - beforeHandler(parser); - parser->m_characterDataHandler(parser->m_handlerArg, buf, - XmlEncode(n, (ICHAR *)buf)); - afterHandler(parser); + const size_t len = XmlEncode(n, (ICHAR *)buf); + reportCharacterData(parser, buf, len); } else if (parser->m_defaultHandler) reportDefault(parser, enc, s, next); } break; @@ -3620,9 +4171,7 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, case XML_TOK_DATA_NEWLINE: if (parser->m_characterDataHandler) { XML_Char c = 0xA; - beforeHandler(parser); - parser->m_characterDataHandler(parser->m_handlerArg, &c, 1); - afterHandler(parser); + reportCharacterData(parser, &c, 1); } else if (parser->m_defaultHandler) reportDefault(parser, enc, s, next); break; @@ -3646,10 +4195,7 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, easier to let the user deal with this. */ } else if ((0) && parser->m_characterDataHandler) { - beforeHandler(parser); - parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf, - 0); - afterHandler(parser); + reportCharacterData(parser, parser->m_dataBuf, 0); /* END disabled code */ } else if (parser->m_defaultHandler) reportDefault(parser, enc, s, next); @@ -3671,17 +4217,11 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, if (MUST_CONVERT(enc, s)) { ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf; XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)parser->m_dataBufEnd); - beforeHandler(parser); - parser->m_characterDataHandler( - parser->m_handlerArg, parser->m_dataBuf, - (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); - afterHandler(parser); + reportCharacterData(parser, parser->m_dataBuf, + dataPtr - (ICHAR *)parser->m_dataBuf); } else { - beforeHandler(parser); - parser->m_characterDataHandler( - parser->m_handlerArg, (const XML_Char *)s, - (int)((const XML_Char *)end - (const XML_Char *)s)); - afterHandler(parser); + reportCharacterData(parser, (const XML_Char *)s, + (const XML_Char *)end - (const XML_Char *)s); } } else if (parser->m_defaultHandler) reportDefault(parser, enc, s, end); @@ -3699,28 +4239,25 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, *nextPtr = end; return XML_ERROR_NONE; case XML_TOK_DATA_CHARS: { - XML_CharacterDataHandler charDataHandler = parser->m_characterDataHandler; - if (charDataHandler) { + if (parser->m_characterDataHandler) { if (MUST_CONVERT(enc, s)) { for (;;) { ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf; const enum XML_Convert_Result convert_res = XmlConvert( enc, &s, next, &dataPtr, (ICHAR *)parser->m_dataBufEnd); *eventEndPP = s; - beforeHandler(parser); - charDataHandler(parser->m_handlerArg, parser->m_dataBuf, - (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); - afterHandler(parser); + if (parser->m_characterDataHandler) { + reportCharacterData(parser, parser->m_dataBuf, + dataPtr - (ICHAR *)parser->m_dataBuf); + } if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) break; *eventPP = s; } } else { - beforeHandler(parser); - charDataHandler(parser->m_handlerArg, (const XML_Char *)s, - (int)((const XML_Char *)next - (const XML_Char *)s)); - afterHandler(parser); + reportCharacterData(parser, (const XML_Char *)s, + (const XML_Char *)next - (const XML_Char *)s); } } else if (parser->m_defaultHandler) reportDefault(parser, enc, s, next); @@ -3807,9 +4344,9 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr, TAG_NAME *tagNamePtr, BINDING **bindingsPtr, enum XML_Account account) { DTD *const dtd = parser->m_dtd; /* save one level of indirection */ - int attIndex = 0; + size_t attIndex = 0; XML_Char *uri; - int nPrefixes = 0; + size_t nPrefixes = 0; BINDING *binding; const XML_Char *localPart; @@ -3824,20 +4361,15 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr, sizeof(ELEMENT_TYPE)); if (! elementType) return XML_ERROR_NO_MEMORY; - if (! elementType->defaultAttsNames.parser) - hashTableInit(&(elementType->defaultAttsNames), parser); + if (! elementType->defaultAttForName.parser) + hashTableInit(&(elementType->defaultAttForName), parser); if (parser->m_ns && ! setElementTypePrefix(parser, elementType)) return XML_ERROR_NO_MEMORY; } const size_t nDefaultAtts = elementType->nDefaultAtts; - /* Detect and prevent integer overflow. */ - if (parser->m_attsSize > (size_t)INT_MAX) - return XML_ERROR_NO_MEMORY; - /* get the attributes from the tokenizer */ - size_t n = (size_t)XmlGetAttributes(enc, attStr, (int)parser->m_attsSize, - parser->m_atts); + size_t n = XmlGetAttributes(enc, attStr, parser->m_attsSize, parser->m_atts); /* Detect and prevent integer overflow */ if (n > SIZE_MAX - nDefaultAtts) { @@ -3868,52 +4400,32 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr, return XML_ERROR_NO_MEMORY; } parser->m_atts = temp; -#ifdef XML_ATTR_INFO - /* Detect and prevent integer overflow. */ - if (parser->m_attsSize > SIZE_MAX / sizeof(XML_AttrInfo)) { - parser->m_attsSize = oldAttsSize; - return XML_ERROR_NO_MEMORY; - } - - XML_AttrInfo *const temp2 = REALLOC( - parser, parser->m_attInfo, parser->m_attsSize * sizeof(XML_AttrInfo)); - if (temp2 == NULL) { - parser->m_attsSize = oldAttsSize; - return XML_ERROR_NO_MEMORY; - } - parser->m_attInfo = temp2; -#endif if (n > oldAttsSize) { - /* Detect and prevent integer overflow. */ - if (n > (size_t)INT_MAX) - return XML_ERROR_NO_MEMORY; - XmlGetAttributes(enc, attStr, (int)n, parser->m_atts); + XmlGetAttributes(enc, attStr, n, parser->m_atts); } } /* the attribute list for the application */ + // NOTE: `parser->m_atts` is used to read `ATTRIBUTE` elements + // from start to end while at the same time writing `XML_Char *` + // elements from start to end *to the same block of memory*. + // That black magic only works because the first member `.name` in + // `ATTRIBUTE` is no longer being read after `appAtts[attIndex]` + // has been written, which for the first element is the very same + // address in memory. + // And because `attIndex` is increased twice for default attributes + // further down, struct `ATTRIBUTE` must be at least twice the size + // of a pointer, or the allocation size math for `m_attsSize` starts + // to underallocate. const XML_Char **const appAtts = (const XML_Char **)parser->m_atts; for (size_t i = 0; i < n; i++) { ATTRIBUTE *currAtt = &parser->m_atts[i]; -#ifdef XML_ATTR_INFO - XML_AttrInfo *currAttInfo = &parser->m_attInfo[i]; -#endif /* add the name and value to the attribute list */ ATTRIBUTE_ID *attId = getAttributeId(parser, enc, currAtt->name, currAtt->name + XmlNameLength(enc, currAtt->name)); if (! attId) return XML_ERROR_NO_MEMORY; -#ifdef XML_ATTR_INFO - currAttInfo->nameStart - = parser->m_parseEndByteIndex - (parser->m_parseEndPtr - currAtt->name); - currAttInfo->nameEnd - = currAttInfo->nameStart + XmlNameLength(enc, currAtt->name); - currAttInfo->valueStart = parser->m_parseEndByteIndex - - (parser->m_parseEndPtr - currAtt->valuePtr); - currAttInfo->valueEnd = parser->m_parseEndByteIndex - - (parser->m_parseEndPtr - currAtt->valueEnd); -#endif /* Detect duplicate attributes by their QNames. This does not work when namespace processing is turned on and different prefixes for the same namespace are used. For this case we have a check further down. @@ -3924,17 +4436,22 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr, return XML_ERROR_DUPLICATE_ATTRIBUTE; } (attId->name)[-1] = 1; + // NOTE: The next call overwrites `parser->m_atts`, so we cannot use + // e.g. `parser->m_atts[i].name;` after this line! appAtts[attIndex++] = attId->name; if (! parser->m_atts[i].normalized) { - XML_Bool isCdata = XML_TRUE; + bool isCdata = true; /* figure out whether declared as other than CDATA */ if (attId->maybeTokenized) { - for (size_t j = 0; j < nDefaultAtts; j++) { - if (attId == elementType->defaultAtts[j].id) { - isCdata = elementType->defaultAtts[j].isCdata; - break; - } + NAME_AND_DEFAULT_ATTRIBUTE *const nameAndDefaultAttribute + = (NAME_AND_DEFAULT_ATTRIBUTE *)lookup( + parser, &(elementType->defaultAttForName), attId->name, 0); + if (nameAndDefaultAttribute != NULL) { + assert(nameAndDefaultAttribute->attIndex < elementType->nDefaultAtts); + const DEFAULT_ATTRIBUTE *const att + = elementType->defaultAtts + nameAndDefaultAttribute->attIndex; + isCdata = att->isCdata; } } @@ -3975,11 +4492,16 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr, } /* set-up for XML_GetSpecifiedAttributeCount and XML_GetIdAttributeIndex */ - parser->m_nSpecifiedAtts = attIndex; + // Detect and reject integer overflow + if (attIndex > INT_MAX) + return XML_ERROR_NO_MEMORY; + parser->m_nSpecifiedAtts = (int)attIndex; if (elementType->idAtt && (elementType->idAtt->name)[-1]) { - for (int i = 0; i < attIndex; i += 2) + for (size_t i = 0; i < attIndex; i += 2) if (appAtts[i] == elementType->idAtt->name) { - parser->m_idAttIndex = i; + if (i > INT_MAX) + return XML_ERROR_NO_MEMORY; + parser->m_idAttIndex = (int)i; break; } } else @@ -4008,11 +4530,11 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr, } } } - appAtts[attIndex] = 0; + appAtts[attIndex] = NULL; /* expand prefixed attribute names, check for duplicates, and clear flags that say whether attributes were specified */ - int i = 0; + size_t i = 0; if (nPrefixes) { unsigned int j; /* hash table index */ unsigned long version = parser->m_nsAttsVersion; @@ -4025,8 +4547,8 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr, unsigned int nsAttsSize = 1u << parser->m_nsAttsPower; unsigned char oldNsAttsPower = parser->m_nsAttsPower; /* size of hash table must be at least 2 * (# of prefixed attributes) */ - if ((nPrefixes << 1) - >> parser->m_nsAttsPower) { /* true for m_nsAttsPower = 0 */ + if (parser->m_nsAttsPower == 0 + || (nPrefixes >> (parser->m_nsAttsPower - 1))) { /* hash table size must also be a power of 2 and >= 8 */ while (nPrefixes >> parser->m_nsAttsPower++) ; @@ -4484,6 +5006,7 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, /* Detect and prevent integer overflow */ if (len > SIZE_MAX - EXPAND_SPARE || len + EXPAND_SPARE > SIZE_MAX / sizeof(XML_Char)) { + FREE(parser, b); return XML_ERROR_NO_MEMORY; } @@ -4521,7 +5044,7 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, /* The idea here is to avoid using stack for each CDATA section when the whole file is parsed with one call. */ -static enum XML_Error PTRCALL +static enum XML_Error cdataSectionProcessor(XML_Parser parser, const char *start, const char *end, const char **endPtr) { enum XML_Error result = doCdataSection( @@ -4567,7 +5090,7 @@ doCdataSection(XML_Parser parser, const ENCODING *enc, const char **startPtr, int tok = XmlCdataSectionTok(enc, s, end, &next); #if XML_GE == 1 if (! accountingDiffTolerated(parser, tok, s, next, __LINE__, account)) { - accountingOnAbort(parser); + accountingOnAbort(parser, 0, __LINE__); return XML_ERROR_AMPLIFICATION_LIMIT_BREACH; } #else @@ -4584,10 +5107,7 @@ doCdataSection(XML_Parser parser, const ENCODING *enc, const char **startPtr, /* BEGIN disabled code */ /* see comment under XML_TOK_CDATA_SECT_OPEN */ else if ((0) && parser->m_characterDataHandler) { - beforeHandler(parser); - parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf, - 0); - afterHandler(parser); + reportCharacterData(parser, parser->m_dataBuf, 0); /* END disabled code */ } else if (parser->m_defaultHandler) reportDefault(parser, enc, s, next); @@ -4600,35 +5120,30 @@ doCdataSection(XML_Parser parser, const ENCODING *enc, const char **startPtr, case XML_TOK_DATA_NEWLINE: if (parser->m_characterDataHandler) { XML_Char c = 0xA; - beforeHandler(parser); - parser->m_characterDataHandler(parser->m_handlerArg, &c, 1); - afterHandler(parser); + reportCharacterData(parser, &c, 1); } else if (parser->m_defaultHandler) reportDefault(parser, enc, s, next); break; case XML_TOK_DATA_CHARS: { - XML_CharacterDataHandler charDataHandler = parser->m_characterDataHandler; - if (charDataHandler) { + if (parser->m_characterDataHandler) { if (MUST_CONVERT(enc, s)) { for (;;) { ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf; const enum XML_Convert_Result convert_res = XmlConvert( enc, &s, next, &dataPtr, (ICHAR *)parser->m_dataBufEnd); *eventEndPP = next; - beforeHandler(parser); - charDataHandler(parser->m_handlerArg, parser->m_dataBuf, - (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); - afterHandler(parser); + if (parser->m_characterDataHandler) { + reportCharacterData(parser, parser->m_dataBuf, + dataPtr - (ICHAR *)parser->m_dataBuf); + } if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) break; *eventPP = s; } } else { - beforeHandler(parser); - charDataHandler(parser->m_handlerArg, (const XML_Char *)s, - (int)((const XML_Char *)next - (const XML_Char *)s)); - afterHandler(parser); + reportCharacterData(parser, (const XML_Char *)s, + (const XML_Char *)next - (const XML_Char *)s); } } else if (parser->m_defaultHandler) reportDefault(parser, enc, s, next); @@ -4687,7 +5202,7 @@ doCdataSection(XML_Parser parser, const ENCODING *enc, const char **startPtr, /* The idea here is to avoid using stack for each IGNORE section when the whole file is parsed with one call. */ -static enum XML_Error PTRCALL +static enum XML_Error ignoreSectionProcessor(XML_Parser parser, const char *start, const char *end, const char **endPtr) { enum XML_Error result @@ -4739,7 +5254,7 @@ doIgnoreSection(XML_Parser parser, const ENCODING *enc, const char **startPtr, # if XML_GE == 1 if (! accountingDiffTolerated(parser, tok, s, next, __LINE__, XML_ACCOUNT_DIRECT)) { - accountingOnAbort(parser); + accountingOnAbort(parser, 0, __LINE__); return XML_ERROR_AMPLIFICATION_LIMIT_BREACH; } # endif @@ -4831,7 +5346,7 @@ processXmlDecl(XML_Parser parser, int isGeneralTextEntity, const char *s, #if XML_GE == 1 if (! accountingDiffTolerated(parser, XML_TOK_XML_DECL, s, next, __LINE__, XML_ACCOUNT_DIRECT)) { - accountingOnAbort(parser); + accountingOnAbort(parser, 0, __LINE__); return XML_ERROR_AMPLIFICATION_LIMIT_BREACH; } #endif @@ -4925,30 +5440,39 @@ handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) { const int status = parser->m_unknownEncodingHandler( parser->m_unknownEncodingHandlerData, encodingName, &info); afterHandler(parser); + + parser->m_unknownEncodingRelease = info.release; + parser->m_unknownEncodingData = info.data; + if (status) { ENCODING *enc; parser->m_unknownEncodingMem = MALLOC(parser, XmlSizeOfUnknownEncoding()); if (! parser->m_unknownEncodingMem) { - if (info.release) - info.release(info.data); + if (parser->m_unknownEncodingRelease) + callUnknownEncodingRelease(parser); + else + parser->m_unknownEncodingData = NULL; return XML_ERROR_NO_MEMORY; } + parser->m_unknownEncodingConvert = info.convert; enc = (parser->m_ns ? XmlInitUnknownEncodingNS : XmlInitUnknownEncoding)( - parser->m_unknownEncodingMem, info.map, info.convert, info.data); + parser->m_unknownEncodingMem, info.map, + info.convert ? callUnknownEncodingConvert : NULL, parser); if (enc) { - parser->m_unknownEncodingData = info.data; - parser->m_unknownEncodingRelease = info.release; parser->m_encoding = enc; return XML_ERROR_NONE; } + parser->m_unknownEncodingConvert = NULL; } - if (info.release != NULL) - info.release(info.data); + if (parser->m_unknownEncodingRelease != NULL) + callUnknownEncodingRelease(parser); + else + parser->m_unknownEncodingData = NULL; } return XML_ERROR_UNKNOWN_ENCODING; } -static enum XML_Error PTRCALL +static enum XML_Error prologInitProcessor(XML_Parser parser, const char *s, const char *end, const char **nextPtr) { enum XML_Error result = initializeEncoding(parser); @@ -4960,7 +5484,7 @@ prologInitProcessor(XML_Parser parser, const char *s, const char *end, #ifdef XML_DTD -static enum XML_Error PTRCALL +static enum XML_Error externalParEntInitProcessor(XML_Parser parser, const char *s, const char *end, const char **nextPtr) { enum XML_Error result = initializeEncoding(parser); @@ -4969,7 +5493,7 @@ externalParEntInitProcessor(XML_Parser parser, const char *s, const char *end, /* we know now that XML_Parse(Buffer) has been called, so we consider the external parameter entity read */ - parser->m_dtd->paramEntityRead = XML_TRUE; + parser->m_dtd->paramEntityRead = true; if (parser->m_prologState.inEntityValue) { parser->m_processor = entityValueInitProcessor; @@ -4980,7 +5504,7 @@ externalParEntInitProcessor(XML_Parser parser, const char *s, const char *end, } } -static enum XML_Error PTRCALL +static enum XML_Error entityValueInitProcessor(XML_Parser parser, const char *s, const char *end, const char **nextPtr) { int tok; @@ -5043,7 +5567,7 @@ entityValueInitProcessor(XML_Parser parser, const char *s, const char *end, # if XML_GE == 1 if (! accountingDiffTolerated(parser, tok, s, next, __LINE__, XML_ACCOUNT_DIRECT)) { - accountingOnAbort(parser); + accountingOnAbort(parser, 0, __LINE__); return XML_ERROR_AMPLIFICATION_LIMIT_BREACH; } # endif @@ -5064,7 +5588,7 @@ entityValueInitProcessor(XML_Parser parser, const char *s, const char *end, } } -static enum XML_Error PTRCALL +static enum XML_Error externalParEntProcessor(XML_Parser parser, const char *s, const char *end, const char **nextPtr) { const char *next = s; @@ -5096,7 +5620,7 @@ externalParEntProcessor(XML_Parser parser, const char *s, const char *end, else if (tok == XML_TOK_BOM) { if (! accountingDiffTolerated(parser, tok, s, next, __LINE__, XML_ACCOUNT_DIRECT)) { - accountingOnAbort(parser); + accountingOnAbort(parser, 0, __LINE__); return XML_ERROR_AMPLIFICATION_LIMIT_BREACH; } @@ -5110,7 +5634,7 @@ externalParEntProcessor(XML_Parser parser, const char *s, const char *end, XML_ACCOUNT_DIRECT); } -static enum XML_Error PTRCALL +static enum XML_Error entityValueProcessor(XML_Parser parser, const char *s, const char *end, const char **nextPtr) { const char *start = s; @@ -5157,7 +5681,7 @@ entityValueProcessor(XML_Parser parser, const char *s, const char *end, #endif /* XML_DTD */ -static enum XML_Error PTRCALL +static enum XML_Error prologProcessor(XML_Parser parser, const char *s, const char *end, const char **nextPtr) { const char *next = s; @@ -5275,7 +5799,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, break; default: if (! accountingDiffTolerated(parser, tok, s, next, __LINE__, account)) { - accountingOnAbort(parser); + accountingOnAbort(parser, 0, __LINE__); return XML_ERROR_AMPLIFICATION_LIMIT_BREACH; } } @@ -5372,7 +5896,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, return XML_ERROR_INVALID_TOKEN; } - if (parser->m_doctypeName) { + if (parser->m_doctypeName && parser->m_startDoctypeDeclHandler) { beforeHandler(parser); parser->m_startDoctypeDeclHandler( parser->m_handlerArg, parser->m_doctypeName, parser->m_doctypeSysid, @@ -5403,10 +5927,10 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, } if (parser->m_useForeignDTD) entity->base = parser->m_curBase; - dtd->paramEntityRead = XML_FALSE; + dtd->paramEntityRead = false; beforeHandler(parser); const int status = parser->m_externalEntityRefHandler( - parser->m_externalEntityRefHandlerArg, 0, entity->base, + parser->m_externalEntityRefHandlerArg, NULL, entity->base, entity->systemId, entity->publicId); afterHandler(parser); if (! status) @@ -5438,7 +5962,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, handleDefault = XML_FALSE; } break; - case XML_ROLE_INSTANCE_START: + case XML_ROLE_INSTANCE_START: { #ifdef XML_DTD /* if there is no DOCTYPE declaration then now is the last chance to read the foreign DTD @@ -5453,10 +5977,10 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, if (! entity) return XML_ERROR_NO_MEMORY; entity->base = parser->m_curBase; - dtd->paramEntityRead = XML_FALSE; + dtd->paramEntityRead = false; beforeHandler(parser); const int status = parser->m_externalEntityRefHandler( - parser->m_externalEntityRefHandlerArg, 0, entity->base, + parser->m_externalEntityRefHandlerArg, NULL, entity->base, entity->systemId, entity->publicId); afterHandler(parser); if (! status) @@ -5482,6 +6006,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, #endif /* XML_DTD */ parser->m_processor = contentProcessor; return contentProcessor(parser, s, end, nextPtr); + } case XML_ROLE_ATTLIST_ELEMENT_NAME: parser->m_declElementType = getElementType(parser, enc, s, next); if (! parser->m_declElementType) @@ -5491,16 +6016,16 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, parser->m_declAttributeId = getAttributeId(parser, enc, s, next); if (! parser->m_declAttributeId) return XML_ERROR_NO_MEMORY; - parser->m_declAttributeIsCdata = XML_FALSE; + parser->m_declAttributeIsCdata = false; parser->m_declAttributeType = NULL; - parser->m_declAttributeIsId = XML_FALSE; + parser->m_declAttributeIsId = false; goto checkAttListDeclHandler; case XML_ROLE_ATTRIBUTE_TYPE_CDATA: - parser->m_declAttributeIsCdata = XML_TRUE; + parser->m_declAttributeIsCdata = true; parser->m_declAttributeType = atypeCDATA; goto checkAttListDeclHandler; case XML_ROLE_ATTRIBUTE_TYPE_ID: - parser->m_declAttributeIsId = XML_TRUE; + parser->m_declAttributeIsId = true; parser->m_declAttributeType = atypeID; goto checkAttListDeclHandler; case XML_ROLE_ATTRIBUTE_TYPE_IDREF: @@ -5548,7 +6073,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, if (! defineAttribute(parser->m_declElementType, parser->m_declAttributeId, parser->m_declAttributeIsCdata, - parser->m_declAttributeIsId, 0, parser)) + parser->m_declAttributeIsId, NULL, parser)) return XML_ERROR_NO_MEMORY; if (parser->m_attlistDeclHandler && parser->m_declAttributeType) { if (*parser->m_declAttributeType == XML_T(ASCII_LPAREN) @@ -5565,8 +6090,8 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, beforeHandler(parser); parser->m_attlistDeclHandler( parser->m_handlerArg, parser->m_declElementType->name, - parser->m_declAttributeId->name, parser->m_declAttributeType, 0, - role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE); + parser->m_declAttributeId->name, parser->m_declAttributeType, + NULL, role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE); afterHandler(parser); handleDefault = XML_FALSE; } @@ -5588,7 +6113,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, /* ID attributes aren't allowed to have a default */ if (! defineAttribute( parser->m_declElementType, parser->m_declAttributeId, - parser->m_declAttributeIsCdata, XML_FALSE, attVal, parser)) + parser->m_declAttributeIsCdata, false, attVal, parser)) return XML_ERROR_NO_MEMORY; if (parser->m_attlistDeclHandler && parser->m_declAttributeType) { if (*parser->m_declAttributeType == XML_T(ASCII_LPAREN) @@ -5618,32 +6143,35 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, #if XML_GE == 1 // This will store the given replacement text in // parser->m_declEntity->textPtr. - enum XML_Error result = callStoreEntityValue( + const enum XML_Error result = callStoreEntityValue( parser, enc, s + enc->minBytesPerChar, next - enc->minBytesPerChar, XML_ACCOUNT_NONE); + if (result != XML_ERROR_NONE) { + poolDiscard(&dtd->entityValuePool); + return result; + } if (parser->m_declEntity) { - /* Detect and prevent signed integer overflow */ - if ((size_t)poolLength(&dtd->entityValuePool) > (size_t)INT_MAX) { - return XML_ERROR_NO_MEMORY; - } - parser->m_declEntity->textPtr = poolStart(&dtd->entityValuePool); - parser->m_declEntity->textLen - = (int)(poolLength(&dtd->entityValuePool)); + const XML_Char *const valueStart = poolStart(&dtd->entityValuePool); + parser->m_declEntity->textPtr = valueStart; + parser->m_declEntity->textLen = poolLength(&dtd->entityValuePool); + parser->m_declEntity->scanPtr = valueStart; poolFinish(&dtd->entityValuePool); if (parser->m_entityDeclHandler) { *eventEndPP = s; + // Check if follow-up cast to (int) would be truncating + if (parser->m_declEntity->textLen > INT_MAX) + return XML_ERROR_NO_MEMORY; beforeHandler(parser); parser->m_entityDeclHandler( parser->m_handlerArg, parser->m_declEntity->name, parser->m_declEntity->is_param, parser->m_declEntity->textPtr, - parser->m_declEntity->textLen, parser->m_curBase, 0, 0, 0); + (int)parser->m_declEntity->textLen, parser->m_curBase, NULL, + NULL, NULL); afterHandler(parser); handleDefault = XML_FALSE; } } else poolDiscard(&dtd->entityValuePool); - if (result != XML_ERROR_NONE) - return result; #else // This will store "&entity123;" in parser->m_declEntity->textPtr // to end up as "&entity123;" in the handler. @@ -5655,11 +6183,15 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, if (parser->m_entityDeclHandler) { *eventEndPP = s; + // Check if follow-up cast to (int) would be truncating + if (parser->m_declEntity->textLen > INT_MAX) + return XML_ERROR_NO_MEMORY; beforeHandler(parser); parser->m_entityDeclHandler( parser->m_handlerArg, parser->m_declEntity->name, parser->m_declEntity->is_param, parser->m_declEntity->textPtr, - parser->m_declEntity->textLen, parser->m_curBase, 0, 0, 0); + (int)parser->m_declEntity->textLen, parser->m_curBase, NULL, + NULL, NULL); afterHandler(parser); handleDefault = XML_FALSE; } @@ -5743,8 +6275,9 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, beforeHandler(parser); parser->m_entityDeclHandler( parser->m_handlerArg, parser->m_declEntity->name, - parser->m_declEntity->is_param, 0, 0, parser->m_declEntity->base, - parser->m_declEntity->systemId, parser->m_declEntity->publicId, 0); + parser->m_declEntity->is_param, NULL, 0, parser->m_declEntity->base, + parser->m_declEntity->systemId, parser->m_declEntity->publicId, + NULL); afterHandler(parser); handleDefault = XML_FALSE; } @@ -5769,7 +6302,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, *eventEndPP = s; beforeHandler(parser); parser->m_entityDeclHandler( - parser->m_handlerArg, parser->m_declEntity->name, 0, 0, 0, + parser->m_handlerArg, parser->m_declEntity->name, 0, NULL, 0, parser->m_declEntity->base, parser->m_declEntity->systemId, parser->m_declEntity->publicId, parser->m_declEntity->notation); afterHandler(parser); @@ -5778,6 +6311,17 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, } break; case XML_ROLE_GENERAL_ENTITY_NAME: { + // NOTE: XML 1.0 fourth edition demands in section + // "4.6 Predefined Entities" that bad redefinitions of predefined + // general entities must be detected and rejected. Expat has been + // ignoring both conforming and non-conforming redefinitions and + // thus has been failing to reject bad redefinitions, for years. + // As a result, users learned that they can get away with + // `` in practice. We cannot start conforming to + // that part of the spec now, or we risk rejecting many documents + // that parsed fine for years and that may not be fixable now or + // in time. So Expat continues to discard redefinitions of + // predefined entities altogether. if (XmlPredefinedEntityName(enc, s, next)) { parser->m_declEntity = NULL; break; @@ -5796,7 +6340,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, } else { poolFinish(&dtd->pool); parser->m_declEntity->publicId = NULL; - parser->m_declEntity->is_param = XML_FALSE; + parser->m_declEntity->is_param = false; /* if we have a parent parser or are reading an internal parameter entity, then the entity declaration is not considered "internal" */ @@ -5826,7 +6370,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, } else { poolFinish(&dtd->pool); parser->m_declEntity->publicId = NULL; - parser->m_declEntity->is_param = XML_TRUE; + parser->m_declEntity->is_param = true; /* if we have a parent parser or are reading an internal parameter entity, then the entity declaration is not considered "internal" */ @@ -5951,19 +6495,19 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, } parser->m_groupConnector[parser->m_prologState.level] = 0; if (dtd->in_eldecl) { - int myindex = nextScaffoldPart(parser); + expat_ssize_t myindex = nextScaffoldPart(parser); if (myindex < 0) return XML_ERROR_NO_MEMORY; assert(dtd->scaffIndex != NULL); - if ((size_t)dtd->scaffLevel >= dtd->scaffIndexSize) { + if (dtd->scaffLevel >= dtd->scaffIndexSize) { /* Detect and prevent integer overflow */ - if (dtd->scaffIndexSize > SIZE_MAX / 2 / sizeof(int)) { + if (dtd->scaffIndexSize > SIZE_MAX / 2 / sizeof(size_t)) { return XML_ERROR_NO_MEMORY; } assert(dtd->scaffIndexSize > 0); const size_t new_size = dtd->scaffIndexSize * 2; - int *const new_scaff_index - = REALLOC(parser, dtd->scaffIndex, new_size * sizeof(int)); + size_t *const new_scaff_index + = REALLOC(parser, dtd->scaffIndex, new_size * sizeof(size_t)); if (new_scaff_index == NULL) { return XML_ERROR_NO_MEMORY; } @@ -6061,8 +6605,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, return XML_ERROR_RECURSIVE_ENTITY_REF; if (entity->textPtr) { enum XML_Error result; - XML_Bool betweenDecl - = (role == XML_ROLE_PARAM_ENTITY_REF ? XML_TRUE : XML_FALSE); + bool betweenDecl = (role == XML_ROLE_PARAM_ENTITY_REF); result = processEntity(parser, entity, betweenDecl, ENTITY_INTERNAL); if (result != XML_ERROR_NONE) return result; @@ -6070,21 +6613,21 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, break; } if (parser->m_externalEntityRefHandler) { - dtd->paramEntityRead = XML_FALSE; - entity->open = XML_TRUE; + dtd->paramEntityRead = false; + entity->open = true; entityTrackingOnOpen(parser, entity, __LINE__); beforeHandler(parser); const int status = parser->m_externalEntityRefHandler( - parser->m_externalEntityRefHandlerArg, 0, entity->base, + parser->m_externalEntityRefHandlerArg, NULL, entity->base, entity->systemId, entity->publicId); afterHandler(parser); if (! status) { entityTrackingOnClose(parser, entity, __LINE__); - entity->open = XML_FALSE; + entity->open = false; return XML_ERROR_EXTERNAL_ENTITY_HANDLING; } entityTrackingOnClose(parser, entity, __LINE__); - entity->open = XML_FALSE; + entity->open = false; handleDefault = XML_FALSE; if (! dtd->paramEntityRead) { dtd->keepProcessing = dtd->standalone; @@ -6114,7 +6657,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, return XML_ERROR_NO_MEMORY; dtd->scaffLevel = 0; dtd->scaffCount = 0; - dtd->in_eldecl = XML_TRUE; + dtd->in_eldecl = true; handleDefault = XML_FALSE; } break; @@ -6143,7 +6686,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, afterHandler(parser); handleDefault = XML_FALSE; } - dtd->in_eldecl = XML_FALSE; + dtd->in_eldecl = false; } break; @@ -6174,7 +6717,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, size_t nameLen; const char *nxt = (quant == XML_CQUANT_NONE ? next : next - enc->minBytesPerChar); - int myindex = nextScaffoldPart(parser); + expat_ssize_t myindex = nextScaffoldPart(parser); if (myindex < 0) return XML_ERROR_NO_MEMORY; dtd->scaffold[myindex].type = XML_CTYPE_NAME; @@ -6187,11 +6730,11 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, nameLen = xcslen(name) + /*null terminator*/ 1; /* Detect and prevent integer overflow */ - if (nameLen > UINT_MAX - dtd->contentStringLen) { + if (nameLen > SIZE_MAX - dtd->contentStringLen) { return XML_ERROR_NO_MEMORY; } - dtd->contentStringLen += (unsigned)nameLen; + dtd->contentStringLen += nameLen; if (parser->m_elementDeclHandler) handleDefault = XML_FALSE; } @@ -6225,7 +6768,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, parser->m_handlerArg, parser->m_declElementType->name, model); afterHandler(parser); } - dtd->in_eldecl = XML_FALSE; + dtd->in_eldecl = false; dtd->contentStringLen = 0; } } @@ -6294,7 +6837,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, /* not reached */ } -static enum XML_Error PTRCALL +static enum XML_Error epilogProcessor(XML_Parser parser, const char *s, const char *end, const char **nextPtr) { parser->m_processor = epilogProcessor; @@ -6305,7 +6848,7 @@ epilogProcessor(XML_Parser parser, const char *s, const char *end, #if XML_GE == 1 if (! accountingDiffTolerated(parser, tok, s, next, __LINE__, XML_ACCOUNT_DIRECT)) { - accountingOnAbort(parser); + accountingOnAbort(parser, 0, __LINE__); return XML_ERROR_AMPLIFICATION_LIMIT_BREACH; } #endif @@ -6372,8 +6915,417 @@ epilogProcessor(XML_Parser parser, const char *s, const char *end, } } +#if XML_GE == 1 +// Checks `name` for being a predefined entity (i.e. one of "amp", "apos", "gt", +// "lt", "quot"). Similar in implementation to function +// `PREFIX(predefinedEntityName)` but operating on an `XML_Char` string with an +// explicit length, instead. Returns +// ASCII_AMP/ASCII_APOS/ASCII_GT/ASCII_LT/ASCII_QUOT for a match or 0 for no +// match. +XML_NONTESTING_STATIC int +isPredefinedEntityName(const XML_Char *name, size_t nameLen) { + switch (nameLen) { + case 2: + // Wanted: "lt" or "gt" + if (name[1] != XML_T(ASCII_t)) + break; + switch (name[0]) { + case XML_T(ASCII_l): + return ASCII_LT; + case XML_T(ASCII_g): + return ASCII_GT; + } + break; + case 3: + // Wanted: "amp" + if (name[0] == XML_T(ASCII_a) && name[1] == XML_T(ASCII_m) + && name[2] == XML_T(ASCII_p)) + return ASCII_AMP; + break; + case 4: + // Wanted: "apos" or "quot" + switch (name[0]) { + case XML_T(ASCII_a): + if (name[1] == XML_T(ASCII_p) && name[2] == XML_T(ASCII_o) + && name[3] == XML_T(ASCII_s)) + return ASCII_APOS; + break; + case XML_T(ASCII_q): + if (name[1] == XML_T(ASCII_u) && name[2] == XML_T(ASCII_o) + && name[3] == XML_T(ASCII_t)) + return ASCII_QUOT; + break; + } + } + return 0; +} + +static const XML_Char cdataOpen[] + = {ASCII_LT, ASCII_EXCL, ASCII_LSQB, ASCII_C, ASCII_D, + ASCII_A, ASCII_T, ASCII_A, ASCII_LSQB, '\0'}; // i.e. "" +static const XML_Char commentOpen[] + = {ASCII_LT, ASCII_EXCL, ASCII_MINUS, ASCII_MINUS, '\0'}; // i.e. "" +static const XML_Char piClose[] = {ASCII_QUEST, ASCII_GT, '\0'}; // i.e. "?>" + +static const size_t cdataOpenLen = sizeof(cdataOpen) / sizeof(cdataOpen[0]) - 1; +static const size_t cdataCloseLen + = sizeof(cdataClose) / sizeof(cdataClose[0]) - 1; +static const size_t commentOpenLen + = sizeof(commentOpen) / sizeof(commentOpen[0]) - 1; +static const size_t commentCloseLen + = sizeof(commentClose) / sizeof(commentClose[0]) - 1; +static const size_t piCloseLen = sizeof(piClose) / sizeof(piClose[0]) - 1; + +// Checks the string starting at `pos` for starting a CDATA section, a comment +// or processing instructions. Returns +// XML_TOK_CDATA_SECT_OPEN/XML_TOK_COMMENT/XML_TOK_PI for a match or +// XML_TOK_INVALID (=0) for no match. Only in the success case, the length +// of the token is written to `*openTextLen`. +XML_NONTESTING_STATIC int +isCDataCommentOrPIStart(const XML_Char *pos, size_t maxLen, + size_t *openTextLen) { + assert(pos != NULL); + assert(openTextLen != NULL); + + if (maxLen < 2) + return XML_TOK_INVALID; + + if (pos[0] != XML_T(ASCII_LT)) + return XML_TOK_INVALID; + + if (pos[1] == XML_T(ASCII_QUEST)) { + *openTextLen = 2; + return XML_TOK_PI; + } + + if (pos[1] != XML_T(ASCII_EXCL)) + return XML_TOK_INVALID; + + if (maxLen >= cdataOpenLen && xcsncmp(pos, cdataOpen, cdataOpenLen) == 0) { + *openTextLen = cdataOpenLen; + return XML_TOK_CDATA_SECT_OPEN; + } + + if (maxLen >= commentOpenLen + && xcsncmp(pos, commentOpen, commentOpenLen) == 0) { + *openTextLen = commentOpenLen; + return XML_TOK_COMMENT; + } + + return XML_TOK_INVALID; +} + +/* Scan `entity`'s body, starting at `*posPtr`, accumulating the expanded + size into `*expandedSize`. + + Return value: how the scan ended, see enum EntityScanResult. + + *blockerOut (out, set only for ENTITY_SCAN_BLOCKED): + The non-empty entity the scan stopped at because its expanded size + has not been computed yet. The caller computes that size first and + calls again with *posPtr unchanged to resume. + The pointer is borrowed from the entity hash table (via lookup), not + a new allocation, so it must not be freed. + + *posPtr (in/out, scan cursor): + Advanced to end-of-text on a complete scan, or parked at the + offending reference otherwise, so a follow-up call resumes from + the same position. Not meaningful after ENTITY_SCAN_OVERFLOW. + + *expandedSize (in/out, expanded-byte accumulator): + The expanded size of this one `entity` (its text plus the expandedSize + of entities it references), not a total across all entities. Not + meaningful after ENTITY_SCAN_OVERFLOW; the overflowing value is never + stored anywhere. */ +XML_NONTESTING_STATIC enum EntityScanResult +scanEntityText(XML_Parser parser, ENTITY *entity, const XML_Char **posPtr, + XmlBigCount *expandedSize, ENTITY **blockerOut) { + if (blockerOut != NULL) + *blockerOut = NULL; + const XML_Char refChar = entity->is_param ? XML_T('%') : XML_T('&'); + HASH_TABLE *const refTable +# ifdef XML_DTD + = entity->is_param ? &parser->m_dtd->paramEntities + : &parser->m_dtd->generalEntities; +# else + = &parser->m_dtd->generalEntities; +# endif + + const XML_Char *pos = *posPtr; + const XML_Char *const end = entity->textPtr + entity->textLen; + + while (pos < end) { + // Detect and skip CDATA/comment/PI sections + // because entities have no effect in these places + if (*pos == XML_T('<')) { + // Detect CDATA/comment/PI section start + size_t openTextLen = 0; + const int tok = isCDataCommentOrPIStart(pos, end - pos, &openTextLen); + if (tok != XML_TOK_INVALID) { + assert(openTextLen != 0); + + // Detect and avoid integer overflow + if (openTextLen > (XmlBigCount)(-1) - *expandedSize) + return ENTITY_SCAN_OVERFLOW; + + *expandedSize += openTextLen; + pos += openTextLen; + + // Detect CDATA/comment/PI section end + const XML_Char *closeText = NULL; + size_t closeLen = 0; + + switch (tok) { + case XML_TOK_CDATA_SECT_OPEN: + closeText = cdataClose; + closeLen = cdataCloseLen; + break; + case XML_TOK_COMMENT: + closeText = commentClose; + closeLen = commentCloseLen; + break; + case XML_TOK_PI: + closeText = piClose; + closeLen = piCloseLen; + break; + default: + assert(0 && "never gets here"); + break; + } + + const size_t remainderLen = end - pos; + const XML_Char *const closeStart + = xcsnstr(pos, closeText, remainderLen); + if (closeStart == NULL) { + // The CDATA/comment/PI section is NOT terminated + if (remainderLen > (XmlBigCount)(-1) - *expandedSize) + return ENTITY_SCAN_OVERFLOW; + *expandedSize += remainderLen; + *posPtr = end; + return ENTITY_SCAN_COMPLETE; + } + + // The CDATA/comment/PI section is NOT terminated + const size_t skippedLen = closeStart + closeLen - pos; + + // Detect and avoid integer overflow + if (skippedLen > (XmlBigCount)(-1) - *expandedSize) + return ENTITY_SCAN_OVERFLOW; + + *expandedSize += skippedLen; + pos += skippedLen; + + continue; + } + } + + // Detect an entity reference + if (*pos != refChar) { + // Detect and avoid integer overflow + if (*expandedSize == (XmlBigCount)(-1)) + return ENTITY_SCAN_OVERFLOW; + (*expandedSize)++; + pos++; + continue; + } + + const XML_Char *nameStart = pos + 1; + const XML_Char *nameEnd = nameStart; + while (nameEnd < end && *nameEnd != XML_T(';')) + nameEnd++; + + if (nameEnd >= end) { + /* Unterminated reference at end of text: treat the trailing + bytes as literal characters. */ + XmlBigCount addend = (XmlBigCount)(end - pos); + // Detect and avoid integer overflow + if (*expandedSize > (XmlBigCount)(-1) - addend) + return ENTITY_SCAN_OVERFLOW; + *expandedSize += addend; + *posPtr = end; + return ENTITY_SCAN_COMPLETE; + } + + const size_t nameLen = (size_t)(nameEnd - nameStart); + + /* At runtime the whole "&name;"/"%name;" token is re-scanned and charged to + the indirect accounting, then its expansion is charged separately; so + every reference below counts this token length plus its expansion. */ + const XmlBigCount refTokenLen + = (XmlBigCount)(/*sigil*/ 1 + nameLen + /*semicolon*/ 1); + + ENTITY *refEntity + = (ENTITY *)lookupWithLength(parser, refTable, nameStart, nameLen, 0); + + XmlBigCount addend = 0; + if (! refEntity) { + /* Predefined entities (amp/lt/gt/quot/apos) are general-only, hence the + `! entity->is_param` guard, and expand to a single character. */ + if (! entity->is_param && isPredefinedEntityName(nameStart, nameLen)) { + addend = refTokenLen + 1; + } else { + /* Undefined entity: expands to nothing, so only the token. */ + addend = refTokenLen; + } + } else if (refEntity->beingAnalyzed) { + /* Cycle: refEntity is already on the depth-first search stack, so its + expandedSize is not final yet; charge just the token. Do not fail the + parse here: per XML 1.0r4, + "A parsed entity MUST NOT contain a recursive reference to + itself, either directly or indirectly", but also "Only parsed + entities that are referenced directly or indirectly within the + document are required to be well-formed" - so a declared-but- + never-expanded cycle must be accepted; if the cycle is actually + expanded, the runtime recursive-ref check reports + XML_ERROR_RECURSIVE_ENTITY_REF. */ + addend = refTokenLen; + } else if (refEntity->textLen > 0 && refEntity->expandedSize == 0) { + /* Non-empty entity whose expanded size has not been computed yet; + report refEntity as a blocker so the caller can compute its size + first. */ + *posPtr = pos; + if (blockerOut != NULL) + *blockerOut = refEntity; + return ENTITY_SCAN_BLOCKED; + } else if (refEntity->expandedSize > 0) { + /* refEntity is fully resolved: expandedSize holds its final expanded + size (a non-zero value is never a partial here - the only entity that + briefly holds a partial is one currently on the resolve stack, which + is caught by the beingAnalyzed branch above). Add the token plus that + expansion. */ + if (refEntity->expandedSize > (XmlBigCount)(-1) - refTokenLen) + return ENTITY_SCAN_OVERFLOW; + addend = refTokenLen + refEntity->expandedSize; + } else { + /* Empty entity (textLen == 0): expands to nothing, so only the token. */ + addend = refTokenLen; + } + + // Detect and avoid integer overflow + if (*expandedSize > (XmlBigCount)(-1) - addend) + return ENTITY_SCAN_OVERFLOW; + *expandedSize += addend; + pos = nameEnd + 1; + } + + /* Loop only exits here with pos == end (a complete scan). */ + assert(pos == end); + *posPtr = end; + return ENTITY_SCAN_COMPLETE; +} + +/* Resolve expandedSize using an iterative depth-first search over the + reference graph. Each entity is scanned at most twice (once on push, + once after its blocker resolves), so the total work is O(N + T) where + N is the number of entities and T is the sum of all entities' textLen. + `entity->beingAnalyzed` marks the entities currently on the stack for + cycle detection; it is cleared again on pop. + Returns XML_ERROR_NO_MEMORY if the stack cannot be allocated, and + XML_ERROR_AMPLIFICATION_LIMIT_BREACH if an entity's expanded size + overflows XmlBigCount. */ +static enum XML_Error +resolveEntityClosureExpandedSize(XML_Parser parser, HASH_TABLE *table, + ENTITY *root) { + if (root == NULL || root->expandedSize != 0 || root->textPtr == NULL + || root->textLen == 0) + return XML_ERROR_NONE; + + if (table->used == 0) + return XML_ERROR_NONE; + + // Detect and avoid integer overflow + if (table->used > SIZE_MAX / sizeof(ENTITY_ANALYSIS_TASK)) + return XML_ERROR_NO_MEMORY; + + ENTITY_ANALYSIS_TASK *stack + = MALLOC(parser, sizeof(ENTITY_ANALYSIS_TASK) * table->used); + if (stack == NULL) + return XML_ERROR_NO_MEMORY; + + const XML_Parser rootParser = getRootParserOf(parser, NULL); + assert(! rootParser->m_parentParser); + + size_t top = 0; + stack[top].entity = root; + root->beingAnalyzed = XML_TRUE; + top++; + rootParser->m_entity_stats.currentDepth++; + if (rootParser->m_entity_stats.currentDepth + > rootParser->m_entity_stats.maximumDepthSeen) { + rootParser->m_entity_stats.maximumDepthSeen++; + } + + while (top > 0) { + ENTITY_ANALYSIS_TASK *task = &stack[top - 1]; + ENTITY *e = task->entity; + XmlBigCount sizeSoFar = e->expandedSize; + ENTITY *blocker = NULL; + + entityTrackingOnScanStart(parser, e, __LINE__); + + const enum EntityScanResult scanResult + = scanEntityText(parser, e, &e->scanPtr, &sizeSoFar, &blocker); + switch (scanResult) { + case ENTITY_SCAN_COMPLETE: + case ENTITY_SCAN_BLOCKED: + /* Save the size accumulated so far; together with task->pos it is + the state that lets the scan resume once the blocker's size has + been computed. This is the one place where expandedSize briefly + holds neither 0 nor the final size - only while the entity is + on the stack, where the beingAnalyzed check in scanEntityText + keeps every other reader away from the intermediate value. */ + e->expandedSize = sizeSoFar; + break; + default: + break; + } + + entityTrackingOnScanStop(parser, e, __LINE__); + + switch (scanResult) { + case ENTITY_SCAN_OVERFLOW: + /* Abort parsing right away; the beingAnalyzed marks still set on + the stacked entities do not matter once the parse is dead. */ + FREE(parser, stack); + /* expandedSize overflowed; pass SIZE_MAX (unrepresentable size). */ + accountingOnAbort(parser, SIZE_MAX, __LINE__); + return XML_ERROR_AMPLIFICATION_LIMIT_BREACH; + + case ENTITY_SCAN_COMPLETE: + e->beingAnalyzed = XML_FALSE; + top--; + rootParser->m_entity_stats.currentDepth--; + break; + + case ENTITY_SCAN_BLOCKED: + /* Push the blocker. A blocker's expanded size is always still + uncomputed and it is never already on the stack, so each entity + is pushed at most once and top <= table->used. */ + assert(! blocker->beingAnalyzed); + assert(top < table->used); + stack[top].entity = blocker; + blocker->beingAnalyzed = XML_TRUE; + top++; + rootParser->m_entity_stats.currentDepth++; + if (rootParser->m_entity_stats.currentDepth + > rootParser->m_entity_stats.maximumDepthSeen) { + rootParser->m_entity_stats.maximumDepthSeen++; + } + break; + } + } + + FREE(parser, stack); + return XML_ERROR_NONE; +} +#endif /* XML_GE == 1 */ + static enum XML_Error -processEntity(XML_Parser parser, ENTITY *entity, XML_Bool betweenDecl, +processEntity(XML_Parser parser, ENTITY *entity, bool betweenDecl, enum EntityType type) { OPEN_INTERNAL_ENTITY *openEntity, **openEntityList; OPEN_INTERNAL_ENTITY **const freeEntityList = &parser->m_freeEntities; @@ -6400,6 +7352,37 @@ processEntity(XML_Parser parser, ENTITY *entity, XML_Bool betweenDecl, /* LCOV_EXCL_STOP */ } +#if XML_GE == 1 + // Compute entity size assuming immediate access + if (entity->textLen > 0 && entity->expandedSize == 0) { + HASH_TABLE *const table +# ifdef XML_DTD + = entity->is_param ? &parser->m_dtd->paramEntities + : &parser->m_dtd->generalEntities; +# else + = &parser->m_dtd->generalEntities; +# endif + const enum XML_Error result + = resolveEntityClosureExpandedSize(parser, table, entity); + if (result != XML_ERROR_NONE) + return result; + } + + /* Reject an amplification attack before acquiring openEntity, so a rejected + entity leaks nothing and leaves entity state untouched. */ + if (entity->expandedSize > 0) { + const XML_Parser rootParser = getRootParserOf(parser, NULL); + /* Overflow of expandedSize aborts parsing during resolution + (on first expansion), so the stored value here is always exact. */ + const XmlBigCount expandedBytes = entity->expandedSize; + if (accountingCurrentAmplificationTolerated(rootParser, expandedBytes) + != XML_TRUE) { + accountingOnAbort(rootParser, expandedBytes, __LINE__); + return XML_ERROR_AMPLIFICATION_LIMIT_BREACH; + } + } +#endif /* XML_GE == 1 */ + if (*freeEntityList) { openEntity = *freeEntityList; *freeEntityList = openEntity->next; @@ -6408,11 +7391,11 @@ processEntity(XML_Parser parser, ENTITY *entity, XML_Bool betweenDecl, if (! openEntity) return XML_ERROR_NO_MEMORY; } - entity->open = XML_TRUE; - entity->hasMore = XML_TRUE; + entity->open = true; + entity->hasMore = true; #if XML_GE == 1 entityTrackingOnOpen(parser, entity, __LINE__); -#endif +#endif /* XML_GE == 1 */ entity->processed = 0; openEntity->next = *openEntityList; *openEntityList = openEntity; @@ -6431,7 +7414,7 @@ processEntity(XML_Parser parser, ENTITY *entity, XML_Bool betweenDecl, return XML_ERROR_NONE; } -static enum XML_Error PTRCALL +static enum XML_Error internalEntityProcessor(XML_Parser parser, const char *s, const char *end, const char **nextPtr) { UNUSED_P(s); @@ -6474,14 +7457,14 @@ internalEntityProcessor(XML_Parser parser, const char *s, const char *end, && (parser->m_parsingStatus.parsing == XML_SUSPENDED || (parser->m_parsingStatus.parsing == XML_PARSING && parser->m_reenter))) { - entity->processed = (int)(next - (const char *)entity->textPtr); + entity->processed = next - (const char *)entity->textPtr; return result; } // Entity is complete. We cannot close it here since we need to first // process its possible inner entities (which are added to the // m_openInternalEntities during doProlog or doContent calls above) - entity->hasMore = XML_FALSE; + entity->hasMore = false; if (! entity->is_param && (openEntity->startTagLevel != parser->m_tagLevel)) { return XML_ERROR_ASYNC_ENTITY; @@ -6499,7 +7482,7 @@ internalEntityProcessor(XML_Parser parser, const char *s, const char *end, // to false. This means we can directly remove the head of // m_openInternalEntities assert(parser->m_openInternalEntities == openEntity); - entity->open = XML_FALSE; + entity->open = false; parser->m_openInternalEntities = parser->m_openInternalEntities->next; /* put openEntity back in list of free instances */ @@ -6513,7 +7496,7 @@ internalEntityProcessor(XML_Parser parser, const char *s, const char *end, return XML_ERROR_NONE; } -static enum XML_Error PTRCALL +static enum XML_Error errorProcessor(XML_Parser parser, const char *s, const char *end, const char **nextPtr) { UNUSED_P(s); @@ -6523,7 +7506,7 @@ errorProcessor(XML_Parser parser, const char *s, const char *end, } static enum XML_Error -storeAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, +storeAttributeValue(XML_Parser parser, const ENCODING *enc, bool isCdata, const char *ptr, const char *end, STRING_POOL *pool, enum XML_Account account) { const char *next = ptr; @@ -6554,16 +7537,16 @@ storeAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, // Check if entity is complete, if not, mark down how much of it is // processed. A XML_SUSPENDED check here is not required as // appendAttributeValue will never suspend the parser. - if (textEnd != nextInEntity) { - entity->processed - = (int)(nextInEntity - (const char *)entity->textPtr); + if (nextInEntity < textEnd) { + entity->processed = nextInEntity - (const char *)entity->textPtr; continue; } + assert(nextInEntity == textEnd); // Entity is complete. We cannot close it here since we need to first // process its possible inner entities (which are added to the // m_openAttributeEntities during appendAttributeValue) - entity->hasMore = XML_FALSE; + entity->hasMore = false; continue; } // End of entity processing, "if" block skips the rest @@ -6576,7 +7559,7 @@ storeAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, // with hasMore set to false. This means we can directly remove the head // of m_openAttributeEntities assert(parser->m_openAttributeEntities == openEntity); - entity->open = XML_FALSE; + entity->open = false; parser->m_openAttributeEntities = parser->m_openAttributeEntities->next; /* put openEntity back in list of free instances */ @@ -6600,7 +7583,7 @@ storeAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, } static enum XML_Error -appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, +appendAttributeValue(XML_Parser parser, const ENCODING *enc, bool isCdata, const char *ptr, const char *end, STRING_POOL *pool, enum XML_Account account, const char **nextPtr) { DTD *const dtd = parser->m_dtd; /* save one level of indirection */ @@ -6614,7 +7597,7 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, int tok = XmlAttributeValueTok(enc, ptr, end, &next); #if XML_GE == 1 if (! accountingDiffTolerated(parser, tok, ptr, next, __LINE__, account)) { - accountingOnAbort(parser); + accountingOnAbort(parser, 0, __LINE__); return XML_ERROR_AMPLIFICATION_LIMIT_BREACH; } #endif @@ -6830,7 +7813,7 @@ storeEntityValue(XML_Parser parser, const ENCODING *enc, if (! accountingDiffTolerated(parser, tok, entityTextPtr, next, __LINE__, account)) { - accountingOnAbort(parser); + accountingOnAbort(parser, 0, __LINE__); result = XML_ERROR_AMPLIFICATION_LIMIT_BREACH; goto endEntityValue; } @@ -6871,22 +7854,22 @@ storeEntityValue(XML_Parser parser, const ENCODING *enc, } if (entity->systemId) { if (parser->m_externalEntityRefHandler) { - dtd->paramEntityRead = XML_FALSE; - entity->open = XML_TRUE; + dtd->paramEntityRead = false; + entity->open = true; entityTrackingOnOpen(parser, entity, __LINE__); beforeHandler(parser); const int status = parser->m_externalEntityRefHandler( - parser->m_externalEntityRefHandlerArg, 0, entity->base, + parser->m_externalEntityRefHandlerArg, NULL, entity->base, entity->systemId, entity->publicId); afterHandler(parser); if (! status) { entityTrackingOnClose(parser, entity, __LINE__); - entity->open = XML_FALSE; + entity->open = false; result = XML_ERROR_EXTERNAL_ENTITY_HANDLING; goto endEntityValue; } entityTrackingOnClose(parser, entity, __LINE__); - entity->open = XML_FALSE; + entity->open = false; if (! dtd->paramEntityRead) dtd->keepProcessing = dtd->standalone; } else @@ -7015,15 +7998,14 @@ callStoreEntityValue(XML_Parser parser, const ENCODING *enc, // processed. A XML_SUSPENDED check here is not required as // appendAttributeValue will never suspend the parser. if (textEnd != nextInEntity) { - entity->processed - = (int)(nextInEntity - (const char *)entity->textPtr); + entity->processed = nextInEntity - (const char *)entity->textPtr; continue; } // Entity is complete. We cannot close it here since we need to first // process its possible inner entities (which are added to the // m_openValueEntities during storeEntityValue) - entity->hasMore = XML_FALSE; + entity->hasMore = false; continue; } // End of entity processing, "if" block skips the rest @@ -7036,7 +8018,7 @@ callStoreEntityValue(XML_Parser parser, const ENCODING *enc, // with hasMore set to false. This means we can directly remove the head // of m_openValueEntities assert(parser->m_openValueEntities == openEntity); - entity->open = XML_FALSE; + entity->open = false; parser->m_openValueEntities = parser->m_openValueEntities->next; /* put openEntity back in list of free instances */ @@ -7071,13 +8053,9 @@ storeSelfEntityValue(XML_Parser parser, ENTITY *entity) { return XML_ERROR_NO_MEMORY; } - /* Detect and prevent signed integer overflow */ - if ((size_t)poolLength(pool) > (size_t)INT_MAX) { - poolDiscard(pool); - return XML_ERROR_NO_MEMORY; - } - entity->textPtr = poolStart(pool); - entity->textLen = (int)(poolLength(pool)); + const XML_Char *const valueStart = poolStart(pool); + entity->textPtr = valueStart; + entity->textLen = poolLength(pool); poolFinish(pool); return XML_ERROR_NONE; @@ -7085,7 +8063,7 @@ storeSelfEntityValue(XML_Parser parser, ENTITY *entity) { #endif /* XML_GE == 0 */ -static void FASTCALL +static void normalizeLines(XML_Char *s) { XML_Char *p; for (;; s++) { @@ -7157,6 +8135,22 @@ reportComment(XML_Parser parser, const ENCODING *enc, const char *start, return 1; } +static void +callDefaultHandler(XML_Parser parser, const XML_Char *s, size_t len) { + assert(parser->m_defaultHandler != NULL); + beforeHandler(parser); + while (parser->m_defaultHandler && len > INT_MAX) { + parser->m_defaultHandler(parser->m_handlerArg, s, INT_MAX); + s += INT_MAX; + len -= INT_MAX; + } + if (parser->m_defaultHandler) { + assert(len <= INT_MAX); + parser->m_defaultHandler(parser->m_handlerArg, s, (int)len); + } + afterHandler(parser); +} + static void reportDefault(XML_Parser parser, const ENCODING *enc, const char *s, const char *end) { @@ -7193,31 +8187,42 @@ reportDefault(XML_Parser parser, const ENCODING *enc, const char *s, convert_res = XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)parser->m_dataBufEnd); *eventEndPP = s; - beforeHandler(parser); - parser->m_defaultHandler(parser->m_handlerArg, parser->m_dataBuf, - (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); - afterHandler(parser); + callDefaultHandler(parser, parser->m_dataBuf, + dataPtr - (ICHAR *)parser->m_dataBuf); *eventPP = s; - } while ((convert_res != XML_CONVERT_COMPLETED) + } while (parser->m_defaultHandler && (convert_res != XML_CONVERT_COMPLETED) && (convert_res != XML_CONVERT_INPUT_INCOMPLETE)); } else { - beforeHandler(parser); - parser->m_defaultHandler( - parser->m_handlerArg, (const XML_Char *)s, - (int)((const XML_Char *)end - (const XML_Char *)s)); - afterHandler(parser); + callDefaultHandler(parser, (const XML_Char *)s, + (const XML_Char *)end - (const XML_Char *)s); + } +} + +static void +reportCharacterData(XML_Parser parser, const XML_Char *s, size_t len) { + assert(parser->m_characterDataHandler != NULL); + beforeHandler(parser); + while (parser->m_characterDataHandler && len > INT_MAX) { + parser->m_characterDataHandler(parser->m_handlerArg, s, INT_MAX); + s += INT_MAX; + len -= INT_MAX; + } + if (parser->m_characterDataHandler) { + assert(len <= INT_MAX); + parser->m_characterDataHandler(parser->m_handlerArg, s, (int)len); } + afterHandler(parser); } static int -defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata, - XML_Bool isId, const XML_Char *value, XML_Parser parser) { +defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, bool isCdata, + bool isId, const XML_Char *value, XML_Parser parser) { DEFAULT_ATTRIBUTE *att; if (value || isId) { /* The handling of default attributes gets messed up if we have a default which duplicates a non-default. */ NAMED *const nameFound - = lookup(parser, &(type->defaultAttsNames), attId->name, 0); + = lookup(parser, &(type->defaultAttForName), attId->name, 0); if (nameFound) return 1; if (isId && ! type->idAtt && ! attId->xmlns) @@ -7251,13 +8256,26 @@ defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata, att->value = value; att->isCdata = isCdata; if (! isCdata) - attId->maybeTokenized = XML_TRUE; + attId->maybeTokenized = true; - NAMED *const nameAddedOrFound - = lookup(parser, &(type->defaultAttsNames), attId->name, sizeof(NAMED)); - if (! nameAddedOrFound) + NAME_AND_DEFAULT_ATTRIBUTE *const nameAndDefaultAttribute + = (NAME_AND_DEFAULT_ATTRIBUTE *)lookup( + parser, &(type->defaultAttForName), attId->name, + sizeof(NAME_AND_DEFAULT_ATTRIBUTE)); + if (! nameAndDefaultAttribute) return 0; + assert(nameAndDefaultAttribute->name == attId->name); + + // NOTE: The XML 1.0r4 spec says: + // "When more than one definition is provided for the same attribute of a + // given element type, the first declaration is binding and later + // declarations are ignored." + if (! nameAndDefaultAttribute->initialized) { + nameAndDefaultAttribute->attIndex = type->nDefaultAtts; + nameAndDefaultAttribute->initialized = true; + } + type->nDefaultAtts += 1; return 1; } @@ -7323,14 +8341,10 @@ getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start, else id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, name + 6, sizeof(PREFIX)); - id->xmlns = XML_TRUE; + id->xmlns = true; } else { - int i; + size_t i; for (i = 0; name[i]; i++) { - /* Detect and prevent signed integer overflow */ - if (i == INT_MAX) { - return NULL; - } /* attributes without prefix are *not* in the default namespace */ if (name[i] == XML_T(ASCII_COLON)) { if (! poolAppendChars(&dtd->pool, name, i)) @@ -7359,7 +8373,7 @@ static const XML_Char * getContext(XML_Parser parser) { DTD *const dtd = parser->m_dtd; /* save one level of indirection */ HASH_TABLE_ITER iter; - XML_Bool needSep = XML_FALSE; + bool needSep = false; if (dtd->defaultPrefix.binding) { if (! poolAppendChar(&parser->m_tempPool, XML_T(ASCII_EQUALS))) @@ -7390,7 +8404,7 @@ getContext(XML_Parser parser) { */ return NULL; /* LCOV_EXCL_LINE */ } - needSep = XML_TRUE; + needSep = true; } hashTableIterInit(&iter, &(dtd->prefixes)); @@ -7419,7 +8433,7 @@ getContext(XML_Parser parser) { len--; if (! poolAppendChars(&parser->m_tempPool, prefix->binding->uri, len)) return NULL; - needSep = XML_TRUE; + needSep = true; } hashTableIterInit(&iter, &(dtd->generalEntities)); @@ -7433,7 +8447,7 @@ getContext(XML_Parser parser) { return NULL; if (! poolAppendChars(&parser->m_tempPool, e->name, xcslen(e->name))) return NULL; - needSep = XML_TRUE; + needSep = true; } if (! poolAppendChar(&parser->m_tempPool, XML_T('\0'))) @@ -7458,7 +8472,7 @@ setContext(XML_Parser parser, const XML_Char *context) { e = (ENTITY *)lookup(parser, &dtd->generalEntities, poolStart(&parser->m_tempPool), 0); if (e) - e->open = XML_TRUE; + e->open = true; if (*s != XML_T('\0')) s++; context = s; @@ -7513,7 +8527,7 @@ setContext(XML_Parser parser, const XML_Char *context) { return XML_TRUE; } -static void FASTCALL +static void normalizePublicId(XML_Char *publicId) { XML_Char *p = publicId; XML_Char *s; @@ -7546,13 +8560,13 @@ dtdCreate(XML_Parser parser) { hashTableInit(&(p->attributeIds), parser); hashTableInit(&(p->prefixes), parser); #ifdef XML_DTD - p->paramEntityRead = XML_FALSE; + p->paramEntityRead = false; hashTableInit(&(p->paramEntities), parser); #endif /* XML_DTD */ p->defaultPrefix.name = NULL; p->defaultPrefix.binding = NULL; - p->in_eldecl = XML_FALSE; + p->in_eldecl = false; p->scaffIndex = NULL; p->scaffIndexSize = 0; p->scaffold = NULL; @@ -7575,12 +8589,12 @@ dtdReset(DTD *p, XML_Parser parser) { ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); if (! e) break; - hashTableDestroy(&(e->defaultAttsNames)); + hashTableDestroy(&(e->defaultAttForName)); FREE(parser, e->defaultAtts); } hashTableClear(&(p->generalEntities)); #ifdef XML_DTD - p->paramEntityRead = XML_FALSE; + p->paramEntityRead = false; hashTableClear(&(p->paramEntities)); #endif /* XML_DTD */ hashTableClear(&(p->elementTypes)); @@ -7591,7 +8605,7 @@ dtdReset(DTD *p, XML_Parser parser) { p->defaultPrefix.name = NULL; p->defaultPrefix.binding = NULL; - p->in_eldecl = XML_FALSE; + p->in_eldecl = false; FREE(parser, p->scaffIndex); p->scaffIndex = NULL; @@ -7617,7 +8631,7 @@ dtdDestroy(DTD *p, XML_Bool isDocEntity, XML_Parser parser) { ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); if (! e) break; - hashTableDestroy(&(e->defaultAttsNames)); + hashTableDestroy(&(e->defaultAttForName)); FREE(parser, e->defaultAtts); } hashTableDestroy(&(p->generalEntities)); @@ -7710,8 +8724,8 @@ dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, if (! newE) return 0; - if (! newE->defaultAttsNames.parser) - hashTableInit(&(newE->defaultAttsNames), parser); + if (! newE->defaultAttForName.parser) + hashTableInit(&(newE->defaultAttForName), parser); if (oldE->nDefaultAtts) { /* Detect and prevent integer overflow. */ @@ -7744,11 +8758,22 @@ dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, } else newE->defaultAtts[i].value = NULL; - NAMED *const nameAddedOrFound = lookup(parser, &(newE->defaultAttsNames), - attributeName, sizeof(NAMED)); - if (! nameAddedOrFound) { + NAME_AND_DEFAULT_ATTRIBUTE *const nameAndDefaultAttribute + = (NAME_AND_DEFAULT_ATTRIBUTE *)lookup( + parser, &(newE->defaultAttForName), attributeName, + sizeof(NAME_AND_DEFAULT_ATTRIBUTE)); + if (! nameAndDefaultAttribute) { return 0; } + + // NOTE: The XML 1.0r4 spec says: + // "When more than one definition is provided for the same attribute of a + // given element type, the first declaration is binding and later + // declarations are ignored." + if (! nameAndDefaultAttribute->initialized) { + nameAndDefaultAttribute->attIndex = i; + nameAndDefaultAttribute->initialized = true; + } } } @@ -7830,6 +8855,9 @@ copyEntityTable(XML_Parser oldParser, HASH_TABLE *newTable, return 0; newE->textPtr = tem; newE->textLen = oldE->textLen; +#if XML_GE == 1 + newE->scanPtr = tem; +#endif /* XML_GE == 1 */ } if (oldE->notation) { const XML_Char *tem = poolCopyString(newPool, oldE->notation); @@ -7845,23 +8873,27 @@ copyEntityTable(XML_Parser oldParser, HASH_TABLE *newTable, #define INIT_POWER 6 -static XML_Bool FASTCALL -keyeq(KEY s1, KEY s2) { +// Compares two strings `s1` and `s2` whereas: +// - `s2` is zero-terminated but +// - `s1` is made up of exactly (not just up to) `s1len` non-zero characters. +XML_NONTESTING_STATIC XML_Bool +keyeq(KEY s1, size_t s1len, KEY s2) { #ifdef XML_UNICODE # ifdef XML_UNICODE_WCHAR_T - return (wcscmp(s1, s2) == 0) ? XML_TRUE : XML_FALSE; + return (wcsncmp(s1, s2, s1len) == 0 && s2[s1len] == L'\0') ? XML_TRUE + : XML_FALSE; # else - for (; *s1 == *s2; s1++, s2++) - if (*s1 == 0) - return XML_TRUE; - return XML_FALSE; + for (; s1len > 0 && *s1 == *s2; s1len--, s1++, s2++) + ; /* no loop body! */ + return ((s1len == 0) && (*s2 == 0)) ? XML_TRUE : XML_FALSE; # endif #else - return (strcmp(s1, s2) == 0) ? XML_TRUE : XML_FALSE; + return (strncmp(s1, s2, s1len) == 0 && s2[s1len] == '\0') ? XML_TRUE + : XML_FALSE; #endif } -static size_t +XML_NONTESTING_STATIC size_t keylen(KEY s) { return xcslen(s); } @@ -7874,42 +8906,60 @@ copy_salt_to_sipkey(XML_Parser parser, struct sipkey *key) { *key = rootParser->m_hash_secret_salt_128; } -static unsigned long FASTCALL -hash(XML_Parser parser, KEY s) { +static unsigned long +hash(XML_Parser parser, KEY s, size_t keyLen) { struct siphash state; struct sipkey key; (void)sip24_valid; copy_salt_to_sipkey(parser, &key); sip24_init(&state, &key); - sip24_update(&state, s, keylen(s) * sizeof(XML_Char)); + sip24_update(&state, s, keyLen * sizeof(XML_Char)); return (unsigned long)sip24_final(&state); } -static NAMED * -lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize) { +// Function `lookupWithLength` can be used to either… +// +// a) check whether an element with key `name` exists in the given hash table +// (read-only mode where `createSize == 0`) or +// +// b) check whether an element with key `name` exists in the given hash table +// *and* insert it if missing (i.e. read-write mode where `createSize != 0`. +// +// When inserting, a block of `createSize` number of bytes will be allocated +// and set to zero, and the resulting block of memory will be considered +// to start with a `NAMED` structure, and `->name = name;` is performed. +// The fact that all other bytes in the structure are initially zero can +// be used to tell cases "existed and found" and "newly inserted" apart +// with the structure returned. +// +// NOTE: Read-only lookup does not need zero-terminated keys but +// read-write mode does, because keys can be re-hashed later and the +// hash table does not store key length information. +// +XML_NONTESTING_STATIC NAMED * +lookupWithLength(XML_Parser parser, HASH_TABLE *table, KEY name, size_t nameLen, + size_t createSize) { size_t i; if (table->size == 0) { - size_t tsize; if (! createSize) return NULL; table->power = INIT_POWER; /* table->size is a power of 2 */ table->size = (size_t)1 << INIT_POWER; - tsize = table->size * sizeof(NAMED *); + const size_t tsize = table->size * sizeof(NAMED *); table->v = MALLOC(table->parser, tsize); if (! table->v) { table->size = 0; return NULL; } memset(table->v, 0, tsize); - i = hash(parser, name) & ((unsigned long)table->size - 1); + i = hash(parser, name, nameLen) & ((unsigned long)table->size - 1); } else { - unsigned long h = hash(parser, name); + unsigned long h = hash(parser, name, nameLen); unsigned long mask = (unsigned long)table->size - 1; - unsigned char step = 0; i = h & mask; - while (table->v[i]) { - if (keyeq(name, table->v[i]->name)) + for (unsigned char step = 0; table->v[i];) { + if (keyeq(name, nameLen, table->v[i]->name)) return table->v[i]; if (! step) step = PROBE_STEP(h, mask, table->power); @@ -7935,17 +8985,17 @@ lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize) { return NULL; } - size_t tsize = newSize * sizeof(NAMED *); + const size_t tsize = newSize * sizeof(NAMED *); NAMED **newV = MALLOC(table->parser, tsize); if (! newV) return NULL; memset(newV, 0, tsize); for (i = 0; i < table->size; i++) if (table->v[i]) { - unsigned long newHash = hash(parser, table->v[i]->name); + KEY const key = table->v[i]->name; + unsigned long newHash = hash(parser, key, keylen(key)); size_t j = newHash & newMask; - step = 0; - while (newV[j]) { + for (unsigned char step = 0; newV[j];) { if (! step) step = PROBE_STEP(newHash, newMask, newPower); j < step ? (j += newSize - step) : (j -= step); @@ -7957,24 +9007,44 @@ lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize) { table->power = newPower; table->size = newSize; i = h & newMask; - step = 0; - while (table->v[i]) { + for (unsigned char step = 0; table->v[i];) { if (! step) step = PROBE_STEP(h, newMask, newPower); i < step ? (i += newSize - step) : (i -= step); } } } + assert(createSize >= sizeof(NAMED)); table->v[i] = MALLOC(table->parser, createSize); if (! table->v[i]) return NULL; memset(table->v[i], 0, createSize); - table->v[i]->name = name; + table->v[i]->name = name; // NOTE: This requires and assumes zero termination! (table->used)++; return table->v[i]; } -static void FASTCALL +// Function `lookup` can be used to either… +// +// a) check whether an element with key `name` exists in the given hash table +// (read-only mode where `createSize == 0`) or +// +// b) check whether an element with key `name` exists in the given hash table +// *and* insert it if missing (i.e. read-write mode where `createSize != 0`. +// +// When inserting, a block of `createSize` number of bytes will be allocated +// and set to zero, and the resulting block of memory will be considered +// to start with a `NAMED` structure, and `->name = name;` is performed. +// The fact that all other bytes in the structure are initially zero can +// be used to tell cases "existed and found" and "newly inserted" apart +// with the structure returned. +// +XML_NONTESTING_STATIC NAMED * +lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize) { + return lookupWithLength(parser, table, name, keylen(name), createSize); +} + +XML_NONTESTING_STATIC void hashTableClear(HASH_TABLE *table) { size_t i; for (i = 0; i < table->size; i++) { @@ -7984,7 +9054,7 @@ hashTableClear(HASH_TABLE *table) { table->used = 0; } -static void FASTCALL +XML_NONTESTING_STATIC void hashTableDestroy(HASH_TABLE *table) { size_t i; for (i = 0; i < table->size; i++) @@ -7992,7 +9062,7 @@ hashTableDestroy(HASH_TABLE *table) { FREE(table->parser, table->v); } -static void FASTCALL +XML_NONTESTING_STATIC void hashTableInit(HASH_TABLE *p, XML_Parser parser) { p->power = 0; p->size = 0; @@ -8001,13 +9071,13 @@ hashTableInit(HASH_TABLE *p, XML_Parser parser) { p->parser = parser; } -static void FASTCALL +XML_NONTESTING_STATIC void hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table) { iter->p = table->v; iter->end = iter->p ? iter->p + table->size : NULL; } -static NAMED *FASTCALL +XML_NONTESTING_STATIC NAMED * hashTableIterNext(HASH_TABLE_ITER *iter) { while (iter->p != iter->end) { NAMED *tem = *(iter->p)++; @@ -8017,7 +9087,7 @@ hashTableIterNext(HASH_TABLE_ITER *iter) { return NULL; } -static void FASTCALL +static void poolInit(STRING_POOL *pool, XML_Parser parser) { pool->blocks = NULL; pool->freeBlocks = NULL; @@ -8027,7 +9097,7 @@ poolInit(STRING_POOL *pool, XML_Parser parser) { pool->parser = parser; } -static void FASTCALL +static void poolClear(STRING_POOL *pool) { if (! pool->freeBlocks) pool->freeBlocks = pool->blocks; @@ -8046,7 +9116,7 @@ poolClear(STRING_POOL *pool) { pool->end = NULL; } -static void FASTCALL +static void poolDestroy(STRING_POOL *pool) { BLOCK *p = pool->blocks; while (p) { @@ -8079,7 +9149,7 @@ poolAppend(STRING_POOL *pool, const ENCODING *enc, const char *ptr, return pool->start; } -static const XML_Char *FASTCALL +static const XML_Char * poolCopyString(STRING_POOL *pool, const XML_Char *s) { if (! poolAppendChars(pool, s, xcslen(s) + /*null terminator*/ 1)) return NULL; @@ -8090,7 +9160,7 @@ poolCopyString(STRING_POOL *pool, const XML_Char *s) { // A version of `poolCopyString` that does not call `poolFinish` // and reverts any partial advancement upon failure. -static const XML_Char *FASTCALL +static const XML_Char * poolCopyStringNoFinish(STRING_POOL *pool, const XML_Char *s) { const XML_Char *const original = s; do { @@ -8106,7 +9176,7 @@ poolCopyStringNoFinish(STRING_POOL *pool, const XML_Char *s) { } static const XML_Char * -poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) { +poolCopyStringN(STRING_POOL *pool, const XML_Char *s, size_t n) { if (! pool->ptr && ! poolGrow(pool)) { /* The following line is unreachable given the current usage of * poolCopyStringN(). Currently it is called from exactly one @@ -8128,7 +9198,7 @@ poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) { return s; } -static const XML_Char *FASTCALL +static const XML_Char * poolAppendString(STRING_POOL *pool, const XML_Char *s) { if (! poolAppendChars(pool, s, xcslen(s))) return NULL; @@ -8146,7 +9216,7 @@ poolStoreString(STRING_POOL *pool, const ENCODING *enc, const char *ptr, } static size_t -poolBytesToAllocateFor(int blockSize) { +poolBytesToAllocateFor(size_t blockSize) { /* Unprotected math would be: ** return offsetof(BLOCK, s) + blockSize * sizeof(XML_Char); ** @@ -8156,24 +9226,22 @@ poolBytesToAllocateFor(int blockSize) { */ const size_t stretch = sizeof(XML_Char); /* can be 4 bytes */ - if (blockSize <= 0) + // Detect integer overflow + if (blockSize > SIZE_MAX / stretch) return 0; - if (blockSize > (int)(INT_MAX / stretch)) + const size_t stretchedBlockSize = blockSize * stretch; + + // Detect integer overflow + if (offsetof(BLOCK, s) > SIZE_MAX - stretchedBlockSize) return 0; - { - const int stretchedBlockSize = blockSize * (int)stretch; - const int bytesToAllocate - = (int)(offsetof(BLOCK, s) + (unsigned)stretchedBlockSize); - if (bytesToAllocate < 0) - return 0; + const size_t bytesToAllocate = offsetof(BLOCK, s) + stretchedBlockSize; - return (size_t)bytesToAllocate; - } + return bytesToAllocate; } -static XML_Bool FASTCALL +static XML_Bool poolGrow(STRING_POOL *pool) { if (pool->freeBlocks) { if (pool->start == NULL) { @@ -8185,14 +9253,14 @@ poolGrow(STRING_POOL *pool) { pool->ptr = pool->start; return XML_TRUE; } - if (pool->end - pool->start < pool->freeBlocks->size) { + if ((size_t)(pool->end - pool->start) < pool->freeBlocks->size) { BLOCK *tem = pool->freeBlocks->next; pool->freeBlocks->next = pool->blocks; pool->blocks = pool->freeBlocks; pool->freeBlocks = tem; memcpy(pool->blocks->s, pool->start, (pool->end - pool->start) * sizeof(XML_Char)); - pool->ptr = pool->blocks->s + (pool->ptr - pool->start); + pool->ptr = pool->blocks->s + EXPAT_SAFE_PTR_DIFF(pool->ptr, pool->start); pool->start = pool->blocks->s; pool->end = pool->start + pool->blocks->size; return XML_TRUE; @@ -8200,22 +9268,17 @@ poolGrow(STRING_POOL *pool) { } if (pool->blocks && pool->start == pool->blocks->s) { BLOCK *temp; - int blockSize = (int)((unsigned)(pool->end - pool->start) * 2U); + const size_t len = pool->end - pool->start; + // Detect integer overflow + if (len > SIZE_MAX / 2) + return XML_FALSE; /* LCOV_EXCL_LINE */ + const size_t blockSize = len * 2; size_t bytesToAllocate; /* NOTE: Needs to be calculated prior to calling `realloc` to avoid dangling pointers: */ - const ptrdiff_t offsetInsideBlock = pool->ptr - pool->start; - - if (blockSize < 0) { - /* This condition traps a situation where either more than - * INT_MAX/2 bytes have already been allocated. This isn't - * readily testable, since it is unlikely that an average - * machine will have that much memory, so we exclude it from the - * coverage statistics. - */ - return XML_FALSE; /* LCOV_EXCL_LINE */ - } + const ptrdiff_t offsetInsideBlock + = EXPAT_SAFE_PTR_DIFF(pool->ptr, pool->start); bytesToAllocate = poolBytesToAllocateFor(blockSize); if (bytesToAllocate == 0) @@ -8231,29 +9294,15 @@ poolGrow(STRING_POOL *pool) { pool->end = pool->start + blockSize; } else { BLOCK *tem; - int blockSize = (int)(pool->end - pool->start); + size_t blockSize = pool->end - pool->start; size_t bytesToAllocate; - if (blockSize < 0) { - /* This condition traps a situation where either more than - * INT_MAX bytes have already been allocated (which is prevented - * by various pieces of program logic, not least this one, never - * mind the unlikelihood of actually having that much memory) or - * the pool control fields have been corrupted (which could - * conceivably happen in an extremely buggy user handler - * function). Either way it isn't readily testable, so we - * exclude it from the coverage statistics. - */ - return XML_FALSE; /* LCOV_EXCL_LINE */ - } - if (blockSize < INIT_BLOCK_SIZE) blockSize = INIT_BLOCK_SIZE; else { - /* Detect overflow, avoiding _signed_ overflow undefined behavior */ - if ((int)((unsigned)blockSize * 2U) < 0) { - return XML_FALSE; - } + // Detect integer overflow + if (blockSize > SIZE_MAX / 2) + return XML_FALSE; /* LCOV_EXCL_LINE */ blockSize *= 2; } @@ -8268,15 +9317,16 @@ poolGrow(STRING_POOL *pool) { tem->next = pool->blocks; pool->blocks = tem; if (pool->ptr != pool->start) - memcpy(tem->s, pool->start, (pool->ptr - pool->start) * sizeof(XML_Char)); - pool->ptr = tem->s + (pool->ptr - pool->start); + memcpy(tem->s, pool->start, + EXPAT_SAFE_PTR_DIFF(pool->ptr, pool->start) * sizeof(XML_Char)); + pool->ptr = tem->s + EXPAT_SAFE_PTR_DIFF(pool->ptr, pool->start); pool->start = tem->s; pool->end = tem->s + blockSize; } return XML_TRUE; } -static bool FASTCALL +static bool poolGrowUntil(STRING_POOL *pool, size_t needed) { for (;;) { const size_t available = pool->end - pool->ptr; @@ -8289,34 +9339,29 @@ poolGrowUntil(STRING_POOL *pool, size_t needed) { } } -static int FASTCALL +static expat_ssize_t nextScaffoldPart(XML_Parser parser) { DTD *const dtd = parser->m_dtd; /* save one level of indirection */ CONTENT_SCAFFOLD *me; - int next; + expat_ssize_t next; if (! dtd->scaffIndex) { /* Detect and prevent integer overflow. */ - if (parser->m_groupSize > SIZE_MAX / sizeof(int)) { + if (parser->m_groupSize > SIZE_MAX / sizeof(size_t)) { return -1; } - dtd->scaffIndex = MALLOC(parser, parser->m_groupSize * sizeof(int)); + dtd->scaffIndex = MALLOC(parser, parser->m_groupSize * sizeof(size_t)); if (! dtd->scaffIndex) return -1; dtd->scaffIndexSize = parser->m_groupSize; dtd->scaffIndex[0] = 0; } - // Will casting to int be safe further down? - if (dtd->scaffCount > INT_MAX) { - return -1; - } - if (dtd->scaffCount >= dtd->scaffSize) { CONTENT_SCAFFOLD *temp; if (dtd->scaffold) { /* Detect and prevent integer overflow */ - if (dtd->scaffSize > UINT_MAX / 2u) { + if (dtd->scaffSize > SIZE_MAX / 2u) { return -1; } /* Detect and prevent integer overflow. @@ -8342,7 +9387,10 @@ nextScaffoldPart(XML_Parser parser) { } dtd->scaffold = temp; } - next = (int)dtd->scaffCount++; + if (dtd->scaffCount > EXPAT_SSIZE_MAX) { + return -1; + } + next = (expat_ssize_t)dtd->scaffCount++; me = &dtd->scaffold[next]; if (dtd->scaffLevel) { CONTENT_SCAFFOLD *parent @@ -8455,7 +9503,7 @@ build_model(XML_Parser parser) { for (; dest < destLimit; dest++) { /* Retrieve source tree array index from job storage */ - const int src_node = (int)dest->numchildren; + const size_t src_node = dest->numchildren; /* Convert item */ dest->type = dtd->scaffold[src_node].type; @@ -8483,15 +9531,24 @@ build_model(XML_Parser parser) { dest->children = NULL; } else { unsigned int i; - int cn; + size_t cn; + if (dtd->scaffold[src_node].childcnt > UINT_MAX) { + parser->m_mem.free_fcn(ret); + return NULL; + } dest->name = NULL; dest->numchildren = dtd->scaffold[src_node].childcnt; dest->children = jobDest; /* Append scaffold indices of children to array */ for (i = 0, cn = dtd->scaffold[src_node].firstchild; - i < dest->numchildren; i++, cn = dtd->scaffold[cn].nextsib) + i < dest->numchildren; i++, cn = dtd->scaffold[cn].nextsib) { + if (cn > UINT_MAX) { + parser->m_mem.free_fcn(ret); + return NULL; + } (jobDest++)->numchildren = (unsigned int)cn; + } } } @@ -8511,8 +9568,8 @@ getElementType(XML_Parser parser, const ENCODING *enc, const char *ptr, sizeof(ELEMENT_TYPE)); if (! ret) return NULL; - if (! ret->defaultAttsNames.parser) - hashTableInit(&(ret->defaultAttsNames), getRootParserOf(parser, NULL)); + if (! ret->defaultAttForName.parser) + hashTableInit(&(ret->defaultAttForName), getRootParserOf(parser, NULL)); if (ret->name != name) poolDiscard(&dtd->pool); else { @@ -8549,45 +9606,61 @@ copyString(const XML_Char *s, XML_Parser parser) { #if XML_GE == 1 static float -accountingGetCurrentAmplification(XML_Parser rootParser) { +accountingGetCurrentAmplification(XML_Parser rootParser, + XmlBigCount extraIndirectBytes) { // 1.........1.........12 => 22 const size_t lenOfShortestInclude = sizeof("") - 1; - const XmlBigCount countBytesOutput - = rootParser->m_accounting.countBytesDirect - + rootParser->m_accounting.countBytesIndirect; + /* Add as floats: u64 counts (max ~1.8e19) are far below FLT_MAX, so the sum + is always finite and cannot wrap the way an unsigned integer add could. */ + const float indirect = (float)rootParser->m_accounting.countBytesIndirect + + (float)extraIndirectBytes; const float amplificationFactor = rootParser->m_accounting.countBytesDirect - ? ((float)countBytesOutput + ? (((float)rootParser->m_accounting.countBytesDirect + indirect) / (float)(rootParser->m_accounting.countBytesDirect)) - : ((float)(lenOfShortestInclude - + rootParser->m_accounting.countBytesIndirect) + : (((float)lenOfShortestInclude + indirect) / (float)lenOfShortestInclude); assert(! rootParser->m_parentParser); return amplificationFactor; } static void -accountingReportStats(XML_Parser originParser, const char *epilog) { +accountingReportStats(XML_Parser originParser, const char *epilog, + XmlBigCount extraIndirectBytes, int sourceLine) { const XML_Parser rootParser = getRootParserOf(originParser, NULL); assert(! rootParser->m_parentParser); - if (rootParser->m_accounting.debugLevel == 0u) { + if (rootParser->m_accounting.debugLevel == 0) { return; } + /* On an early abort the amplifying bytes have not been charged to the + indirect counter yet; fold extraIndirectBytes in (with overflow detection) + so the reported byte count and amplification reflect what was detected. */ + const XmlBigCount indirect = rootParser->m_accounting.countBytesIndirect; + const XmlBigCount indirectWithExtra + = (extraIndirectBytes > (XmlBigCount)(-1) - indirect) + ? (XmlBigCount)(-1) + : indirect + extraIndirectBytes; const float amplificationFactor - = accountingGetCurrentAmplification(rootParser); + = accountingGetCurrentAmplification(rootParser, extraIndirectBytes); fprintf(stderr, "expat: Accounting(%p): Direct " EXPAT_FMT_ULL( "10") ", indirect " EXPAT_FMT_ULL("10") ", amplification %8.2f%s", (void *)rootParser, rootParser->m_accounting.countBytesDirect, - rootParser->m_accounting.countBytesIndirect, - (double)amplificationFactor, epilog); + indirectWithExtra, (double)amplificationFactor, epilog); + /* An abort has no accountingReportDiff before it, so append the originating + source line here to show which rejection site these stats belong to. */ + if (sourceLine > 0) { + fprintf(stderr, " (xmlparse.c:%d)\n", sourceLine); + } } static void -accountingOnAbort(XML_Parser originParser) { - accountingReportStats(originParser, " ABORTING\n"); +accountingOnAbort(XML_Parser originParser, XmlBigCount extraIndirectBytes, + int sourceLine) { + accountingReportStats(originParser, " ABORTING", extraIndirectBytes, + sourceLine); } static void @@ -8608,7 +9681,7 @@ accountingReportDiff(XML_Parser rootParser, /* Note: Performance is of no concern here */ const char *walker = before; - if ((rootParser->m_accounting.debugLevel >= 3u) + if ((rootParser->m_accounting.debugLevel >= 3) || (after - before) <= (ptrdiff_t)(contextLength + ellipsisLength + contextLength)) { for (; walker < after; walker++) { @@ -8627,6 +9700,32 @@ accountingReportDiff(XML_Parser rootParser, fprintf(stderr, "\"\n"); } +static XML_Bool +accountingCurrentAmplificationTolerated(XML_Parser rootParser, + XmlBigCount extraIndirectBytes) { + assert(! rootParser->m_parentParser); + + const XmlBigCount countBytesOutput + = rootParser->m_accounting.countBytesDirect + + rootParser->m_accounting.countBytesIndirect; + /* Overflow check: extraIndirectBytes can be SIZE_MAX, which would otherwise + wrap the unsigned total around to a small value and wrongly report the + output as tolerated. */ + const XmlBigCount countBytesOutputWithExtra + = (extraIndirectBytes > (XmlBigCount)(-1) - countBytesOutput) + ? (XmlBigCount)(-1) + : countBytesOutput + extraIndirectBytes; + const float amplificationFactor + = accountingGetCurrentAmplification(rootParser, extraIndirectBytes); + const XML_Bool tolerated + = (countBytesOutputWithExtra + < rootParser->m_accounting.activationThresholdBytes) + || (amplificationFactor + <= rootParser->m_accounting.maximumAmplificationFactor); + + return tolerated; +} + static XML_Bool accountingDiffTolerated(XML_Parser originParser, int tok, const char *before, const char *after, int source_line, @@ -8663,18 +9762,11 @@ accountingDiffTolerated(XML_Parser originParser, int tok, const char *before, return XML_FALSE; *additionTarget += bytesMore; - const XmlBigCount countBytesOutput - = rootParser->m_accounting.countBytesDirect - + rootParser->m_accounting.countBytesIndirect; - const float amplificationFactor - = accountingGetCurrentAmplification(rootParser); const XML_Bool tolerated - = (countBytesOutput < rootParser->m_accounting.activationThresholdBytes) - || (amplificationFactor - <= rootParser->m_accounting.maximumAmplificationFactor); + = accountingCurrentAmplificationTolerated(rootParser, 0); - if (rootParser->m_accounting.debugLevel >= 2u) { - accountingReportStats(rootParser, ""); + if (rootParser->m_accounting.debugLevel >= 2) { + accountingReportStats(rootParser, "", 0, 0); accountingReportDiff(rootParser, levelsAwayFromRootParser, before, after, bytesMore, source_line, account); } @@ -8700,7 +9792,7 @@ static void entityTrackingReportStats(XML_Parser rootParser, ENTITY *entity, const char *action, int sourceLine) { assert(! rootParser->m_parentParser); - if (rootParser->m_entity_stats.debugLevel == 0u) + if (rootParser->m_entity_stats.debugLevel == 0) return; # if defined(XML_UNICODE) @@ -8720,14 +9812,21 @@ entityTrackingReportStats(XML_Parser rootParser, ENTITY *entity, = limitingNeeded ? (maxLimitedDepth - /* make space for ellipis */ 2) : candidateIndentDepth; + const ptrdiff_t scannedLength + = EXPAT_SAFE_PTR_DIFF(entity->scanPtr, entity->textPtr); + const char *const confidenceMarker + = ((size_t)scannedLength == entity->textLen) ? "!" : "?"; + fprintf( stderr, - "expat: Entities(%p): Count %9u, depth %2u/%2u %*s%s%s%s; %s length %d (xmlparse.c:%d)\n", + "expat: Entities(%p): Count %9u, depth %2u/%2u %*s%s%s%s; %s scanned " EXPAT_FMT_PTRDIFF_T( + "") "/" EXPAT_FMT_SIZE_T("") ", expanded " EXPAT_FMT_ULL("") "%s (xmlparse.c:%d)\n", (void *)rootParser, rootParser->m_entity_stats.countEverOpened, rootParser->m_entity_stats.currentDepth, rootParser->m_entity_stats.maximumDepthSeen, indentDepth * 2, "", ellipisOrEmpty, entity->is_param ? "%" : "&", entityName, action, - entity->textLen, sourceLine); + scannedLength, entity->textLen, entity->expandedSize, confidenceMarker, + sourceLine); } static void @@ -8742,6 +9841,7 @@ entityTrackingOnOpen(XML_Parser originParser, ENTITY *entity, int sourceLine) { rootParser->m_entity_stats.maximumDepthSeen++; } + // NOTE: The space at the end of "OPEN " is for length alignment with "CLOSE" entityTrackingReportStats(rootParser, entity, "OPEN ", sourceLine); } @@ -8754,6 +9854,25 @@ entityTrackingOnClose(XML_Parser originParser, ENTITY *entity, int sourceLine) { rootParser->m_entity_stats.currentDepth--; } +static void +entityTrackingOnScanStart(XML_Parser originParser, ENTITY *entity, + int sourceLine) { + const XML_Parser rootParser = getRootParserOf(originParser, NULL); + assert(! rootParser->m_parentParser); + + entityTrackingReportStats(rootParser, entity, "START", sourceLine); +} + +static void +entityTrackingOnScanStop(XML_Parser originParser, ENTITY *entity, + int sourceLine) { + const XML_Parser rootParser = getRootParserOf(originParser, NULL); + assert(! rootParser->m_parentParser); + + // NOTE: The space at the end of "STOP " is for length alignment with "START" + entityTrackingReportStats(rootParser, entity, "STOP ", sourceLine); +} + #endif /* XML_GE == 1 */ static XML_Parser diff --git a/Modules/expat/xmlrole.c b/Modules/expat/xmlrole.c index d56bee82dd2d13f..dbf4a2d1b8f7080 100644 --- a/Modules/expat/xmlrole.c +++ b/Modules/expat/xmlrole.c @@ -12,7 +12,7 @@ Copyright (c) 2002-2006 Karl Waclawek Copyright (c) 2002-2003 Fred L. Drake, Jr. Copyright (c) 2005-2009 Steven Solie - Copyright (c) 2016-2023 Sebastian Pipping + Copyright (c) 2016-2026 Sebastian Pipping Copyright (c) 2017 Rhodri James Copyright (c) 2019 David Loffredo Copyright (c) 2021 Donghee Na @@ -37,6 +37,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ #include "expat_config.h" @@ -119,9 +121,8 @@ static const char KW_SYSTEM[] # define setTopLevel(state) ((state)->handler = internalSubset) #endif /* not XML_DTD */ -typedef int PTRCALL PROLOG_HANDLER(PROLOG_STATE *state, int tok, - const char *ptr, const char *end, - const ENCODING *enc); +typedef int PROLOG_HANDLER(PROLOG_STATE *state, int tok, const char *ptr, + const char *end, const ENCODING *enc); static PROLOG_HANDLER prolog0, prolog1, prolog2, doctype0, doctype1, doctype2, doctype3, doctype4, doctype5, internalSubset, entity0, entity1, entity2, @@ -135,9 +136,9 @@ static PROLOG_HANDLER prolog0, prolog1, prolog2, doctype0, doctype1, doctype2, #endif /* XML_DTD */ declClose, error; -static int FASTCALL common(PROLOG_STATE *state, int tok); +static int common(PROLOG_STATE *state, int tok); -static int PTRCALL +static int prolog0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { switch (tok) { @@ -168,7 +169,7 @@ prolog0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int prolog1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { switch (tok) { @@ -200,7 +201,7 @@ prolog1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int prolog2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -220,7 +221,7 @@ prolog2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int doctype0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -237,7 +238,7 @@ doctype0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int doctype1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { switch (tok) { @@ -263,7 +264,7 @@ doctype1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int doctype2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -279,7 +280,7 @@ doctype2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int doctype3(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -295,7 +296,7 @@ doctype3(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int doctype4(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -314,7 +315,7 @@ doctype4(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int doctype5(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -330,7 +331,7 @@ doctype5(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int internalSubset(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { switch (tok) { @@ -375,7 +376,7 @@ internalSubset(PROLOG_STATE *state, int tok, const char *ptr, const char *end, #ifdef XML_DTD -static int PTRCALL +static int externalSubset0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { state->handler = externalSubset1; @@ -384,7 +385,7 @@ externalSubset0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return externalSubset1(state, tok, ptr, end, enc); } -static int PTRCALL +static int externalSubset1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { switch (tok) { @@ -412,7 +413,7 @@ externalSubset1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, #endif /* XML_DTD */ -static int PTRCALL +static int entity0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -431,7 +432,7 @@ entity0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int entity1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -447,7 +448,7 @@ entity1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int entity2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { switch (tok) { @@ -471,7 +472,7 @@ entity2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int entity3(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -487,7 +488,7 @@ entity3(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int entity4(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -503,7 +504,7 @@ entity4(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int entity5(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { switch (tok) { @@ -522,7 +523,7 @@ entity5(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int entity6(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -539,7 +540,7 @@ entity6(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int entity7(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { switch (tok) { @@ -563,7 +564,7 @@ entity7(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int entity8(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -579,7 +580,7 @@ entity8(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int entity9(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -595,7 +596,7 @@ entity9(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int entity10(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -611,7 +612,7 @@ entity10(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int notation0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -627,7 +628,7 @@ notation0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int notation1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { switch (tok) { @@ -647,7 +648,7 @@ notation1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int notation2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -663,7 +664,7 @@ notation2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int notation3(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -680,7 +681,7 @@ notation3(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int notation4(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -700,7 +701,7 @@ notation4(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int attlist0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -717,7 +718,7 @@ attlist0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int attlist1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -737,7 +738,7 @@ attlist1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int attlist2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { switch (tok) { @@ -767,7 +768,7 @@ attlist2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int attlist3(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -785,7 +786,7 @@ attlist3(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int attlist4(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -804,7 +805,7 @@ attlist4(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int attlist5(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -820,7 +821,7 @@ attlist5(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int attlist6(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -836,7 +837,7 @@ attlist6(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int attlist7(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -856,7 +857,7 @@ attlist7(PROLOG_STATE *state, int tok, const char *ptr, const char *end, } /* default value */ -static int PTRCALL +static int attlist8(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { switch (tok) { @@ -886,7 +887,7 @@ attlist8(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int attlist9(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -902,7 +903,7 @@ attlist9(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int element0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -919,7 +920,7 @@ element0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int element1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { switch (tok) { @@ -945,7 +946,7 @@ element1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int element2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { switch (tok) { @@ -979,7 +980,7 @@ element2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int element3(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -1003,7 +1004,7 @@ element3(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int element4(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -1020,7 +1021,7 @@ element4(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int element5(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -1040,7 +1041,7 @@ element5(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int element6(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -1069,7 +1070,7 @@ element6(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int element7(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -1118,7 +1119,7 @@ element7(PROLOG_STATE *state, int tok, const char *ptr, const char *end, #ifdef XML_DTD -static int PTRCALL +static int condSect0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { switch (tok) { @@ -1138,7 +1139,7 @@ condSect0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int condSect1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -1155,7 +1156,7 @@ condSect1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, return common(state, tok); } -static int PTRCALL +static int condSect2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -1173,7 +1174,7 @@ condSect2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, #endif /* XML_DTD */ -static int PTRCALL +static int declClose(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(ptr); @@ -1209,7 +1210,7 @@ declClose(PROLOG_STATE *state, int tok, const char *ptr, const char *end, * * LCOV_EXCL_START */ -static int PTRCALL +static int error(PROLOG_STATE *state, int tok, const char *ptr, const char *end, const ENCODING *enc) { UNUSED_P(state); @@ -1221,7 +1222,7 @@ error(PROLOG_STATE *state, int tok, const char *ptr, const char *end, } /* LCOV_EXCL_STOP */ -static int FASTCALL +static int common(PROLOG_STATE *state, int tok) { #ifdef XML_DTD if (! state->documentEntity && tok == XML_TOK_PARAM_ENTITY_REF) diff --git a/Modules/expat/xmlrole.h b/Modules/expat/xmlrole.h index 9d0d4ff11b7f982..f4aba4079f5cdfa 100644 --- a/Modules/expat/xmlrole.h +++ b/Modules/expat/xmlrole.h @@ -10,7 +10,7 @@ Copyright (c) 2000 Clark Cooper Copyright (c) 2002 Karl Waclawek Copyright (c) 2002 Fred L. Drake, Jr. - Copyright (c) 2017-2025 Sebastian Pipping + Copyright (c) 2017-2026 Sebastian Pipping Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining @@ -31,6 +31,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ #ifndef XmlRole_INCLUDED @@ -38,10 +40,6 @@ # include "xmltok.h" -# ifdef __cplusplus -extern "C" { -# endif - enum { XML_ROLE_ERROR = -1, XML_ROLE_NONE = 0, @@ -110,8 +108,8 @@ enum { }; typedef struct prolog_state { - int(PTRCALL *handler)(struct prolog_state *state, int tok, const char *ptr, - const char *end, const ENCODING *enc); + int (*handler)(struct prolog_state *state, int tok, const char *ptr, + const char *end, const ENCODING *enc); unsigned level; int role_none; # ifdef XML_DTD @@ -129,8 +127,4 @@ void XmlPrologStateInitExternalEntity(PROLOG_STATE *state); # define XmlTokenRole(state, tok, ptr, end, enc) \ (((state)->handler)(state, tok, ptr, end, enc)) -# ifdef __cplusplus -} -# endif - #endif /* not XmlRole_INCLUDED */ diff --git a/Modules/expat/xmltok.c b/Modules/expat/xmltok.c index 387c6e44a25f80c..e2c114a5229bb71 100644 --- a/Modules/expat/xmltok.c +++ b/Modules/expat/xmltok.c @@ -12,7 +12,7 @@ Copyright (c) 2002 Greg Stein Copyright (c) 2002-2016 Karl Waclawek Copyright (c) 2005-2009 Steven Solie - Copyright (c) 2016-2024 Sebastian Pipping + Copyright (c) 2016-2026 Sebastian Pipping Copyright (c) 2016 Pascal Cuoq Copyright (c) 2016 Don Lewis Copyright (c) 2017 Rhodri James @@ -26,6 +26,8 @@ Copyright (c) 2023 Hanno Böck Copyright (c) 2025 Alfonso Gregory Copyright (c) 2026 Nick Begg + Copyright (c) 2026 Kartik Kenchi + Copyright (c) 2026 Afonso Januário Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining @@ -46,10 +48,13 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ #include "expat_config.h" +#include #include #include /* memcpy */ #include @@ -133,54 +138,61 @@ : ((p)[1] & 0x80) == 0 \ || ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0))) -static int PTRFASTCALL -isNever(const ENCODING *enc, const char *p) { - UNUSED_P(enc); - UNUSED_P(p); - return 0; -} +static const uint8_t b_0000_0111 = 0x07; +static const uint8_t b_0011_1111 = 0x3F; -static int PTRFASTCALL +static int utf8_isName2(const ENCODING *enc, const char *p) { UNUSED_P(enc); return UTF8_GET_NAMING2(namePages, (const unsigned char *)p); } -static int PTRFASTCALL +static int utf8_isName3(const ENCODING *enc, const char *p) { UNUSED_P(enc); return UTF8_GET_NAMING3(namePages, (const unsigned char *)p); } -#define utf8_isName4 isNever +#define utf8_isName4 utf8_isNmstrt4 -static int PTRFASTCALL +static int utf8_isNmstrt2(const ENCODING *enc, const char *p) { UNUSED_P(enc); return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p); } -static int PTRFASTCALL +static int utf8_isNmstrt3(const ENCODING *enc, const char *p) { UNUSED_P(enc); return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p); } -#define utf8_isNmstrt4 isNever +static int +utf8_isNmstrt4(const ENCODING *enc, const char *p) { + UNUSED_P(enc); -static int PTRFASTCALL + // This is a four-byte-unit UTF-8 decoder but: + // - We only need the two upper bytes for the check below + // - Malformed continuation bytes have been rejected before + const unsigned codepoint + = ((p[0] & b_0000_0111) << 18) | ((p[1] & b_0011_1111) << 12); + + return ((codepoint >= 0x10000) && (codepoint <= 0xEFFFF)); +} + +static int utf8_isInvalid2(const ENCODING *enc, const char *p) { UNUSED_P(enc); return UTF8_INVALID2((const unsigned char *)p); } -static int PTRFASTCALL +static int utf8_isInvalid3(const ENCODING *enc, const char *p) { UNUSED_P(enc); return UTF8_INVALID3((const unsigned char *)p); } -static int PTRFASTCALL +static int utf8_isInvalid4(const ENCODING *enc, const char *p) { UNUSED_P(enc); return UTF8_INVALID4((const unsigned char *)p); @@ -189,36 +201,20 @@ utf8_isInvalid4(const ENCODING *enc, const char *p) { struct normal_encoding { ENCODING enc; unsigned char type[256]; -#ifdef XML_MIN_SIZE - int(PTRFASTCALL *byteType)(const ENCODING *, const char *); - int(PTRFASTCALL *isNameMin)(const ENCODING *, const char *); - int(PTRFASTCALL *isNmstrtMin)(const ENCODING *, const char *); - int(PTRFASTCALL *byteToAscii)(const ENCODING *, const char *); - int(PTRCALL *charMatches)(const ENCODING *, const char *, int); -#endif /* XML_MIN_SIZE */ - int(PTRFASTCALL *isName2)(const ENCODING *, const char *); - int(PTRFASTCALL *isName3)(const ENCODING *, const char *); - int(PTRFASTCALL *isName4)(const ENCODING *, const char *); - int(PTRFASTCALL *isNmstrt2)(const ENCODING *, const char *); - int(PTRFASTCALL *isNmstrt3)(const ENCODING *, const char *); - int(PTRFASTCALL *isNmstrt4)(const ENCODING *, const char *); - int(PTRFASTCALL *isInvalid2)(const ENCODING *, const char *); - int(PTRFASTCALL *isInvalid3)(const ENCODING *, const char *); - int(PTRFASTCALL *isInvalid4)(const ENCODING *, const char *); + int (*isName2)(const ENCODING *, const char *); + int (*isName3)(const ENCODING *, const char *); + int (*isName4)(const ENCODING *, const char *); + int (*isNmstrt2)(const ENCODING *, const char *); + int (*isNmstrt3)(const ENCODING *, const char *); + int (*isNmstrt4)(const ENCODING *, const char *); + int (*isInvalid2)(const ENCODING *, const char *); + int (*isInvalid3)(const ENCODING *, const char *); + int (*isInvalid4)(const ENCODING *, const char *); }; #define AS_NORMAL_ENCODING(enc) ((const struct normal_encoding *)(enc)) -#ifdef XML_MIN_SIZE - -# define STANDARD_VTABLE(E) \ - E##byteType, E##isNameMin, E##isNmstrtMin, E##byteToAscii, E##charMatches, - -#else - -# define STANDARD_VTABLE(E) /* as nothing */ - -#endif +#define STANDARD_VTABLE(E) /* as nothing */ #define NORMAL_VTABLE(E) \ E##isName2, E##isName3, E##isName4, E##isNmstrt2, E##isNmstrt3, \ @@ -229,80 +225,33 @@ struct normal_encoding { /* isNmstrt2 */ NULL, /* isNmstrt3 */ NULL, /* isNmstrt4 */ NULL, \ /* isInvalid2 */ NULL, /* isInvalid3 */ NULL, /* isInvalid4 */ NULL -static int FASTCALL checkCharRefNumber(int result); +#define UTF16_NULL_VTABLE(E) NULL_VTABLE + +static int checkCharRefNumber(int result); #include "xmltok_impl.h" #include "ascii.h" -#ifdef XML_MIN_SIZE -# define sb_isNameMin isNever -# define sb_isNmstrtMin isNever -#endif - -#ifdef XML_MIN_SIZE -# define MINBPC(enc) ((enc)->minBytesPerChar) -#else /* minimum bytes per character */ -# define MINBPC(enc) 1 -#endif +#define MINBPC(enc) 1 #define SB_BYTE_TYPE(enc, p) \ (((const struct normal_encoding *)(enc))->type[(unsigned char)*(p)]) -#ifdef XML_MIN_SIZE -static int PTRFASTCALL -sb_byteType(const ENCODING *enc, const char *p) { - return SB_BYTE_TYPE(enc, p); -} -# define BYTE_TYPE(enc, p) (AS_NORMAL_ENCODING(enc)->byteType(enc, p)) -#else -# define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p) -#endif +#define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p) -#ifdef XML_MIN_SIZE -# define BYTE_TO_ASCII(enc, p) (AS_NORMAL_ENCODING(enc)->byteToAscii(enc, p)) -static int PTRFASTCALL -sb_byteToAscii(const ENCODING *enc, const char *p) { - UNUSED_P(enc); - return *p; -} -#else -# define BYTE_TO_ASCII(enc, p) (*(p)) -#endif +#define BYTE_TO_ASCII(enc, p) (*(p)) #define IS_NAME_CHAR(enc, p, n) (AS_NORMAL_ENCODING(enc)->isName##n(enc, p)) #define IS_NMSTRT_CHAR(enc, p, n) (AS_NORMAL_ENCODING(enc)->isNmstrt##n(enc, p)) -#ifdef XML_MIN_SIZE -# define IS_INVALID_CHAR(enc, p, n) \ - (AS_NORMAL_ENCODING(enc)->isInvalid##n \ - && AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p)) -#else -# define IS_INVALID_CHAR(enc, p, n) \ - (AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p)) -#endif +#define IS_INVALID_CHAR(enc, p, n) \ + (AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p)) -#ifdef XML_MIN_SIZE -# define IS_NAME_CHAR_MINBPC(enc, p) \ - (AS_NORMAL_ENCODING(enc)->isNameMin(enc, p)) -# define IS_NMSTRT_CHAR_MINBPC(enc, p) \ - (AS_NORMAL_ENCODING(enc)->isNmstrtMin(enc, p)) -#else -# define IS_NAME_CHAR_MINBPC(enc, p) (0) -# define IS_NMSTRT_CHAR_MINBPC(enc, p) (0) -#endif +#define IS_NAME_CHAR_MINBPC(enc, p) (0) +#define IS_NMSTRT_CHAR_MINBPC(enc, p) (0) -#ifdef XML_MIN_SIZE -# define CHAR_MATCHES(enc, p, c) \ - (AS_NORMAL_ENCODING(enc)->charMatches(enc, p, c)) -static int PTRCALL -sb_charMatches(const ENCODING *enc, const char *p, int c) { - UNUSED_P(enc); - return *p == c; -} -#else /* c is an ASCII character */ -# define CHAR_MATCHES(enc, p, c) (*(p) == (c)) -#endif +#define CHAR_MATCHES(enc, p, c) (*(p) == (c)) #define PREFIX(ident) normal_##ident #define XML_TOK_IMPL_C @@ -365,7 +314,7 @@ _INTERNAL_trim_to_complete_utf8_characters(const char *from, *fromLimRef = fromLim; } -static enum XML_Convert_Result PTRCALL +static enum XML_Convert_Result utf8_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim) { bool input_incomplete = false; @@ -404,7 +353,7 @@ utf8_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, return XML_CONVERT_COMPLETED; } -static enum XML_Convert_Result PTRCALL +static enum XML_Convert_Result utf8_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim) { enum XML_Convert_Result res = XML_CONVERT_COMPLETED; @@ -502,7 +451,7 @@ static const struct normal_encoding internal_utf8_encoding }, STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)}; -static enum XML_Convert_Result PTRCALL +static enum XML_Convert_Result latin1_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim) { UNUSED_P(enc); @@ -525,7 +474,7 @@ latin1_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, } } -static enum XML_Convert_Result PTRCALL +static enum XML_Convert_Result latin1_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim) { UNUSED_P(enc); @@ -560,7 +509,7 @@ static const struct normal_encoding latin1_encoding }, STANDARD_VTABLE(sb_) NULL_VTABLE}; -static enum XML_Convert_Result PTRCALL +static enum XML_Convert_Result ascii_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim) { UNUSED_P(enc); @@ -595,7 +544,7 @@ static const struct normal_encoding ascii_encoding }, STANDARD_VTABLE(sb_) NULL_VTABLE}; -static int PTRFASTCALL +static int unicode_byte_type(char hi, char lo) { switch ((unsigned char)hi) { /* 0xD800-0xDBFF first 16-bit code unit or high surrogate (W1) */ @@ -622,7 +571,7 @@ unicode_byte_type(char hi, char lo) { } #define DEFINE_UTF16_TO_UTF8(E) \ - static enum XML_Convert_Result PTRCALL E##toUtf8( \ + static enum XML_Convert_Result E##toUtf8( \ const ENCODING *enc, const char **fromP, const char *fromLim, \ char **toP, const char *toLim) { \ const char *from = *fromP; \ @@ -699,24 +648,36 @@ unicode_byte_type(char hi, char lo) { } #define DEFINE_UTF16_TO_UTF16(E) \ - static enum XML_Convert_Result PTRCALL E##toUtf16( \ + static enum XML_Convert_Result E##toUtf16( \ const ENCODING *enc, const char **fromP, const char *fromLim, \ unsigned short **toP, const unsigned short *toLim) { \ enum XML_Convert_Result res = XML_CONVERT_COMPLETED; \ UNUSED_P(enc); \ - fromLim = *fromP + (((fromLim - *fromP) >> 1) << 1); /* shrink to even */ \ - /* Avoid copying first half only of surrogate */ \ - if (fromLim - *fromP > ((toLim - *toP) << 1) \ - && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) { \ + const size_t maxBytesToCopy = (toLim - *toP) * sizeof(short); \ + \ + if ((size_t)(fromLim - *fromP) > maxBytesToCopy) { \ + /* Shrink to the (even) maximum amount able to copy */ \ + fromLim = *fromP + maxBytesToCopy; \ + res = XML_CONVERT_OUTPUT_EXHAUSTED; \ + } else { \ + /* Shrink to even number of bytes */ \ + fromLim = *fromP + (((fromLim - *fromP) >> 1) << 1); \ + } \ + \ + /* Avoid copying the first half (2 bytes) of surrogate pairs (4 bytes) */ \ + /* Are the last about-to-be-copied two bytes a high surrogate \ + * (0xD800-0xDBFF)? */ \ + if ((fromLim - *fromP) >= 2 && (GET_HI(fromLim - 2) & 0xFC) == 0xD8) { \ fromLim -= 2; \ - res = XML_CONVERT_INPUT_INCOMPLETE; \ + if (res != XML_CONVERT_OUTPUT_EXHAUSTED) \ + res = XML_CONVERT_INPUT_INCOMPLETE; \ } \ + \ + /* Copy bytes respecting endianness */ \ for (; *fromP < fromLim && *toP < toLim; *fromP += 2) \ *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \ - if ((*toP == toLim) && (*fromP < fromLim)) \ - return XML_CONVERT_OUTPUT_EXHAUSTED; \ - else \ - return res; \ + \ + return res; \ } #define GET_LO(ptr) ((unsigned char)(ptr)[0]) @@ -741,74 +702,57 @@ DEFINE_UTF16_TO_UTF16(big2_) ((p)[1] == 0 ? SB_BYTE_TYPE(enc, p) : unicode_byte_type((p)[1], (p)[0])) #define LITTLE2_BYTE_TO_ASCII(p) ((p)[1] == 0 ? (p)[0] : -1) #define LITTLE2_CHAR_MATCHES(p, c) ((p)[1] == 0 && (p)[0] == (c)) +#define LITTLE2_IS_NAME_CHAR(enc, p, n) LITTLE2_IS_NMSTRT_CHAR(enc, p, n) #define LITTLE2_IS_NAME_CHAR_MINBPC(p) \ UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0]) #define LITTLE2_IS_NMSTRT_CHAR_MINBPC(p) \ UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0]) - -#ifdef XML_MIN_SIZE - -static int PTRFASTCALL -little2_byteType(const ENCODING *enc, const char *p) { - return LITTLE2_BYTE_TYPE(enc, p); -} - -static int PTRFASTCALL -little2_byteToAscii(const ENCODING *enc, const char *p) { +/* A 4-byte UTF-16 character is a surrogate pair; byteType only reports BT_LEAD4 + for a high surrogate, so the pair is invalid unless the second unit is a low + surrogate (U+DC00..U+DFFF, i.e. high byte 0xDC..0xDF). */ +#define LITTLE2_IS_INVALID_CHAR(p, n) \ + ((n) == 4 && ((unsigned char)(p)[3] & 0xFC) != 0xDC) + +static bool +LITTLE2_IS_NMSTRT_CHAR(const ENCODING *enc, const char *p, size_t n) { UNUSED_P(enc); - return LITTLE2_BYTE_TO_ASCII(p); -} + assert(n == 4); + const uint8_t *const source = (const uint8_t *)p; -static int PTRCALL -little2_charMatches(const ENCODING *enc, const char *p, int c) { - UNUSED_P(enc); - return LITTLE2_CHAR_MATCHES(p, c); -} + const uint16_t high = (source[1] << 8) | source[0]; + const uint16_t low = (source[3] << 8) | source[2]; -static int PTRFASTCALL -little2_isNameMin(const ENCODING *enc, const char *p) { - UNUSED_P(enc); - return LITTLE2_IS_NAME_CHAR_MINBPC(p); -} + const unsigned codepoint = (high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000; -static int PTRFASTCALL -little2_isNmstrtMin(const ENCODING *enc, const char *p) { - UNUSED_P(enc); - return LITTLE2_IS_NMSTRT_CHAR_MINBPC(p); + return ((codepoint >= 0x10000) && (codepoint <= 0xEFFFF)); } -# undef VTABLE -# define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16 +#undef PREFIX +#define PREFIX(ident) little2_##ident +#define MINBPC(enc) 2 +/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ +#define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p) +#define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(p) +#define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(p, c) +#define IS_NAME_CHAR(enc, p, n) LITTLE2_IS_NAME_CHAR(enc, p, n) +#define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(p) +#define IS_NMSTRT_CHAR(enc, p, n) LITTLE2_IS_NMSTRT_CHAR(enc, p, n) +#define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(p) +#define IS_INVALID_CHAR(enc, p, n) LITTLE2_IS_INVALID_CHAR(p, n) -#else /* not XML_MIN_SIZE */ +#define XML_TOK_IMPL_C +#include "xmltok_impl.c" +#undef XML_TOK_IMPL_C -# undef PREFIX -# define PREFIX(ident) little2_##ident -# define MINBPC(enc) 2 -/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ -# define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p) -# define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(p) -# define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(p, c) -# define IS_NAME_CHAR(enc, p, n) 0 -# define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(p) -# define IS_NMSTRT_CHAR(enc, p, n) (0) -# define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(p) - -# define XML_TOK_IMPL_C -# include "xmltok_impl.c" -# undef XML_TOK_IMPL_C - -# undef MINBPC -# undef BYTE_TYPE -# undef BYTE_TO_ASCII -# undef CHAR_MATCHES -# undef IS_NAME_CHAR -# undef IS_NAME_CHAR_MINBPC -# undef IS_NMSTRT_CHAR -# undef IS_NMSTRT_CHAR_MINBPC -# undef IS_INVALID_CHAR - -#endif /* not XML_MIN_SIZE */ +#undef MINBPC +#undef BYTE_TYPE +#undef BYTE_TO_ASCII +#undef CHAR_MATCHES +#undef IS_NAME_CHAR +#undef IS_NAME_CHAR_MINBPC +#undef IS_NMSTRT_CHAR +#undef IS_NMSTRT_CHAR_MINBPC +#undef IS_INVALID_CHAR #ifdef XML_NS @@ -824,7 +768,7 @@ static const struct normal_encoding little2_encoding_ns # include "asciitab.h" # include "latin1tab.h" }, - STANDARD_VTABLE(little2_) NULL_VTABLE}; + STANDARD_VTABLE(little2_) UTF16_NULL_VTABLE(little2_)}; #endif @@ -842,7 +786,7 @@ static const struct normal_encoding little2_encoding #undef BT_COLON #include "latin1tab.h" }, - STANDARD_VTABLE(little2_) NULL_VTABLE}; + STANDARD_VTABLE(little2_) UTF16_NULL_VTABLE(little2_)}; #if BYTEORDER != 4321 @@ -854,7 +798,7 @@ static const struct normal_encoding internal_little2_encoding_ns # include "iasciitab.h" # include "latin1tab.h" }, - STANDARD_VTABLE(little2_) NULL_VTABLE}; + STANDARD_VTABLE(little2_) UTF16_NULL_VTABLE(little2_)}; # endif @@ -866,7 +810,7 @@ static const struct normal_encoding internal_little2_encoding # undef BT_COLON # include "latin1tab.h" }, - STANDARD_VTABLE(little2_) NULL_VTABLE}; + STANDARD_VTABLE(little2_) UTF16_NULL_VTABLE(little2_)}; #endif @@ -874,74 +818,57 @@ static const struct normal_encoding internal_little2_encoding ((p)[0] == 0 ? SB_BYTE_TYPE(enc, p + 1) : unicode_byte_type((p)[0], (p)[1])) #define BIG2_BYTE_TO_ASCII(p) ((p)[0] == 0 ? (p)[1] : -1) #define BIG2_CHAR_MATCHES(p, c) ((p)[0] == 0 && (p)[1] == (c)) +#define BIG2_IS_NAME_CHAR(enc, p, n) BIG2_IS_NMSTRT_CHAR(enc, p, n) #define BIG2_IS_NAME_CHAR_MINBPC(p) \ UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1]) #define BIG2_IS_NMSTRT_CHAR_MINBPC(p) \ UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1]) - -#ifdef XML_MIN_SIZE - -static int PTRFASTCALL -big2_byteType(const ENCODING *enc, const char *p) { - return BIG2_BYTE_TYPE(enc, p); -} - -static int PTRFASTCALL -big2_byteToAscii(const ENCODING *enc, const char *p) { +/* A 4-byte UTF-16 character is a surrogate pair; byteType only reports BT_LEAD4 + for a high surrogate, so the pair is invalid unless the second unit is a low + surrogate (U+DC00..U+DFFF, i.e. high byte 0xDC..0xDF). */ +#define BIG2_IS_INVALID_CHAR(p, n) \ + ((n) == 4 && ((unsigned char)(p)[2] & 0xFC) != 0xDC) + +static bool +BIG2_IS_NMSTRT_CHAR(const ENCODING *enc, const char *p, size_t n) { UNUSED_P(enc); - return BIG2_BYTE_TO_ASCII(p); -} + assert(n == 4); + const uint8_t *const source = (const uint8_t *)p; -static int PTRCALL -big2_charMatches(const ENCODING *enc, const char *p, int c) { - UNUSED_P(enc); - return BIG2_CHAR_MATCHES(p, c); -} + const uint16_t high = (source[0] << 8) | source[1]; + const uint16_t low = (source[2] << 8) | source[3]; -static int PTRFASTCALL -big2_isNameMin(const ENCODING *enc, const char *p) { - UNUSED_P(enc); - return BIG2_IS_NAME_CHAR_MINBPC(p); -} + const unsigned codepoint = (high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000; -static int PTRFASTCALL -big2_isNmstrtMin(const ENCODING *enc, const char *p) { - UNUSED_P(enc); - return BIG2_IS_NMSTRT_CHAR_MINBPC(p); + return ((codepoint >= 0x10000) && (codepoint <= 0xEFFFF)); } -# undef VTABLE -# define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16 +#undef PREFIX +#define PREFIX(ident) big2_##ident +#define MINBPC(enc) 2 +/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ +#define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p) +#define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(p) +#define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(p, c) +#define IS_NAME_CHAR(enc, p, n) BIG2_IS_NAME_CHAR(enc, p, n) +#define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(p) +#define IS_NMSTRT_CHAR(enc, p, n) BIG2_IS_NMSTRT_CHAR(enc, p, n) +#define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(p) +#define IS_INVALID_CHAR(enc, p, n) BIG2_IS_INVALID_CHAR(p, n) -#else /* not XML_MIN_SIZE */ +#define XML_TOK_IMPL_C +#include "xmltok_impl.c" +#undef XML_TOK_IMPL_C -# undef PREFIX -# define PREFIX(ident) big2_##ident -# define MINBPC(enc) 2 -/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ -# define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p) -# define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(p) -# define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(p, c) -# define IS_NAME_CHAR(enc, p, n) 0 -# define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(p) -# define IS_NMSTRT_CHAR(enc, p, n) (0) -# define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(p) - -# define XML_TOK_IMPL_C -# include "xmltok_impl.c" -# undef XML_TOK_IMPL_C - -# undef MINBPC -# undef BYTE_TYPE -# undef BYTE_TO_ASCII -# undef CHAR_MATCHES -# undef IS_NAME_CHAR -# undef IS_NAME_CHAR_MINBPC -# undef IS_NMSTRT_CHAR -# undef IS_NMSTRT_CHAR_MINBPC -# undef IS_INVALID_CHAR - -#endif /* not XML_MIN_SIZE */ +#undef MINBPC +#undef BYTE_TYPE +#undef BYTE_TO_ASCII +#undef CHAR_MATCHES +#undef IS_NAME_CHAR +#undef IS_NAME_CHAR_MINBPC +#undef IS_NMSTRT_CHAR +#undef IS_NMSTRT_CHAR_MINBPC +#undef IS_INVALID_CHAR #ifdef XML_NS @@ -957,7 +884,7 @@ static const struct normal_encoding big2_encoding_ns # include "asciitab.h" # include "latin1tab.h" }, - STANDARD_VTABLE(big2_) NULL_VTABLE}; + STANDARD_VTABLE(big2_) UTF16_NULL_VTABLE(big2_)}; #endif @@ -975,7 +902,7 @@ static const struct normal_encoding big2_encoding #undef BT_COLON #include "latin1tab.h" }, - STANDARD_VTABLE(big2_) NULL_VTABLE}; + STANDARD_VTABLE(big2_) UTF16_NULL_VTABLE(big2_)}; #if BYTEORDER != 1234 @@ -987,7 +914,7 @@ static const struct normal_encoding internal_big2_encoding_ns # include "iasciitab.h" # include "latin1tab.h" }, - STANDARD_VTABLE(big2_) NULL_VTABLE}; + STANDARD_VTABLE(big2_) UTF16_NULL_VTABLE(big2_)}; # endif @@ -999,13 +926,13 @@ static const struct normal_encoding internal_big2_encoding # undef BT_COLON # include "latin1tab.h" }, - STANDARD_VTABLE(big2_) NULL_VTABLE}; + STANDARD_VTABLE(big2_) UTF16_NULL_VTABLE(big2_)}; #endif #undef PREFIX -static int FASTCALL +static int streqci(const char *s1, const char *s2) { for (;;) { char c1 = *s1++; @@ -1026,7 +953,7 @@ streqci(const char *s1, const char *s2) { return 1; } -static void PTRCALL +static void initUpdatePosition(const ENCODING *enc, const char *ptr, const char *end, POSITION *pos) { UNUSED_P(enc); @@ -1044,7 +971,7 @@ toAscii(const ENCODING *enc, const char *ptr, const char *end) { return buf[0]; } -static int FASTCALL +static int isSpace(int c) { switch (c) { case 0x20: @@ -1150,6 +1077,34 @@ static const char KW_yes[] = {ASCII_y, ASCII_e, ASCII_s, '\0'}; static const char KW_no[] = {ASCII_n, ASCII_o, '\0'}; +static const char KW_1_dot[] = {ASCII_1, ASCII_PERIOD, '\0'}; + +/* Checks a version pseudo-attribute value against the VersionNum production. + XML 1.0 Fourth Edition only allows the literal "1.0", but the Fifth + Edition relaxed this to "1." followed by one or more digits, since Expat + only implements 1.0 itself but plans to track the Fifth Edition's laxer + grammar here so that "1.1" and similar aren't rejected only to have that + rejection reverted later. Returns true for a value matching "1.[0-9]+". + val/valEnd bound the value itself; valEnd is the upper bound used when + decoding the individual characters between them. */ +static bool +checkXmlDeclVersionNum(const ENCODING *enc, const char *val, + const char *valEnd) { + if (valEnd - val < 2 * enc->minBytesPerChar + || ! XmlNameMatchesAscii(enc, val, val + 2 * enc->minBytesPerChar, + KW_1_dot)) + return false; + val += 2 * enc->minBytesPerChar; + if (val == valEnd) + return false; + for (; val != valEnd; val += enc->minBytesPerChar) { + int c = toAscii(enc, val, valEnd); + if (c < ASCII_0 || c > ASCII_9) + return false; + } + return true; +} + static int doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *, const char *, const char *), @@ -1177,6 +1132,22 @@ doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *, const char *, *versionPtr = val; if (versionEndPtr) *versionEndPtr = ptr; + /* The version number must not be empty; VersionNum requires at least + one character. The encoding and standalone pseudo-attributes below + already reject an empty value, so keep version consistent. */ + if (val == ptr - enc->minBytesPerChar) { + *badPtr = val; + return 0; + } + /* Expat implements XML 1.0 only, so any version outside the "1.0"/"1.x" + family is rejected. Following the Fifth Edition's VersionNum + production (rather than the Fourth Edition's exact "1.0") avoids + rejecting "1.1" now only to have to revert that once Expat tracks + the newer edition. */ + if (! checkXmlDeclVersionNum(enc, val, ptr - enc->minBytesPerChar)) { + *badPtr = val; + return 0; + } if (! parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) { *badPtr = ptr; return 0; @@ -1231,7 +1202,7 @@ doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *, const char *, return 1; } -static int FASTCALL +static int checkCharRefNumber(int result) { switch (result >> 8) { case 0xD8: @@ -1255,7 +1226,7 @@ checkCharRefNumber(int result) { return result; } -int FASTCALL +int XmlUtf8Encode(int c, char *buf) { enum { /* minN is minimum legal resulting value for N byte sequence */ @@ -1291,7 +1262,7 @@ XmlUtf8Encode(int c, char *buf) { return 0; /* LCOV_EXCL_LINE: this case too is eliminated before calling */ } -int FASTCALL +int XmlUtf16Encode(int charNum, unsigned short *buf) { if (charNum < 0) return 0; @@ -1323,7 +1294,7 @@ XmlSizeOfUnknownEncoding(void) { return sizeof(struct unknown_encoding); } -static int PTRFASTCALL +static int unknown_isName(const ENCODING *enc, const char *p) { const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); int c = uenc->convert(uenc->userData, p); @@ -1332,7 +1303,7 @@ unknown_isName(const ENCODING *enc, const char *p) { return UCS2_GET_NAMING(namePages, c >> 8, c & 0xFF); } -static int PTRFASTCALL +static int unknown_isNmstrt(const ENCODING *enc, const char *p) { const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); int c = uenc->convert(uenc->userData, p); @@ -1341,14 +1312,14 @@ unknown_isNmstrt(const ENCODING *enc, const char *p) { return UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xFF); } -static int PTRFASTCALL +static int unknown_isInvalid(const ENCODING *enc, const char *p) { const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); int c = uenc->convert(uenc->userData, p); return (c & ~0xFFFF) || checkCharRefNumber(c) < 0; } -static enum XML_Convert_Result PTRCALL +static enum XML_Convert_Result unknown_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim) { const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); @@ -1361,13 +1332,17 @@ unknown_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, utf8 = uenc->utf8[(unsigned char)**fromP]; n = *utf8++; if (n == 0) { + const size_t readLen + = (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP] + - (BT_LEAD2 - 2)); + if (readLen > (size_t)(fromLim - *fromP)) + return XML_CONVERT_INPUT_INCOMPLETE; int c = uenc->convert(uenc->userData, *fromP); n = XmlUtf8Encode(c, buf); if (n > toLim - *toP) return XML_CONVERT_OUTPUT_EXHAUSTED; utf8 = buf; - *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP] - - (BT_LEAD2 - 2)); + *fromP += readLen; } else { if (n > toLim - *toP) return XML_CONVERT_OUTPUT_EXHAUSTED; @@ -1378,16 +1353,20 @@ unknown_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, } } -static enum XML_Convert_Result PTRCALL +static enum XML_Convert_Result unknown_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim) { const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); while (*fromP < fromLim && *toP < toLim) { unsigned short c = uenc->utf16[(unsigned char)**fromP]; if (c == 0) { + const size_t readLen + = (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP] + - (BT_LEAD2 - 2)); + if (readLen > (size_t)(fromLim - *fromP)) + return XML_CONVERT_INPUT_INCOMPLETE; c = (unsigned short)uenc->convert(uenc->userData, *fromP); - *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP] - - (BT_LEAD2 - 2)); + *fromP += readLen; } else (*fromP)++; *(*toP)++ = c; @@ -1395,8 +1374,8 @@ unknown_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim, if ((*toP == toLim) && (*fromP < fromLim)) return XML_CONVERT_OUTPUT_EXHAUSTED; - else - return XML_CONVERT_COMPLETED; + + return XML_CONVERT_COMPLETED; } ENCODING * @@ -1502,7 +1481,7 @@ static const char KW_UTF_16LE[] = {ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_L, ASCII_E, '\0'}; -static int FASTCALL +static int getEncodingIndex(const char *name) { static const char *const encodingNames[] = { KW_ISO_8859_1, KW_US_ASCII, KW_UTF_8, KW_UTF_16, KW_UTF_16BE, KW_UTF_16LE, diff --git a/Modules/expat/xmltok.h b/Modules/expat/xmltok.h index 79a9fb76871f10b..1beac2b09d78ace 100644 --- a/Modules/expat/xmltok.h +++ b/Modules/expat/xmltok.h @@ -10,7 +10,7 @@ Copyright (c) 2000 Clark Cooper Copyright (c) 2002 Fred L. Drake, Jr. Copyright (c) 2002-2005 Karl Waclawek - Copyright (c) 2016-2024 Sebastian Pipping + Copyright (c) 2016-2026 Sebastian Pipping Copyright (c) 2017 Rhodri James Licensed under the MIT license: @@ -32,14 +32,14 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ #ifndef XmlTok_INCLUDED # define XmlTok_INCLUDED 1 -# ifdef __cplusplus -extern "C" { -# endif +# include // uint64_t /* The following token may be returned by XmlContentTok */ # define XML_TOK_TRAILING_RSQB \ @@ -145,8 +145,8 @@ extern "C" { typedef struct position { /* first line and first column are 0 not 1 */ - XML_Size lineNumber; - XML_Size columnNumber; + uint64_t lineNumber; + uint64_t columnNumber; } POSITION; typedef struct { @@ -159,41 +159,40 @@ typedef struct { struct encoding; typedef struct encoding ENCODING; -typedef int(PTRCALL *SCANNER)(const ENCODING *, const char *, const char *, - const char **); +typedef int (*SCANNER)(const ENCODING *, const char *, const char *, + const char **); enum XML_Convert_Result { XML_CONVERT_COMPLETED = 0, XML_CONVERT_INPUT_INCOMPLETE = 1, - XML_CONVERT_OUTPUT_EXHAUSTED - = 2 /* and therefore potentially input remaining as well */ + XML_CONVERT_OUTPUT_EXHAUSTED = 2 /* and therefore potentially input remaining + as well */ }; struct encoding { SCANNER scanners[XML_N_STATES]; SCANNER literalScanners[XML_N_LITERAL_TYPES]; - int(PTRCALL *nameMatchesAscii)(const ENCODING *, const char *, const char *, - const char *); - int(PTRFASTCALL *nameLength)(const ENCODING *, const char *); - const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *); - int(PTRCALL *getAtts)(const ENCODING *enc, const char *ptr, int attsMax, - ATTRIBUTE *atts); - int(PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr); - int(PTRCALL *predefinedEntityName)(const ENCODING *, const char *, - const char *); - void(PTRCALL *updatePosition)(const ENCODING *, const char *ptr, - const char *end, POSITION *); - int(PTRCALL *isPublicId)(const ENCODING *enc, const char *ptr, - const char *end, const char **badPtr); - enum XML_Convert_Result(PTRCALL *utf8Convert)(const ENCODING *enc, - const char **fromP, - const char *fromLim, char **toP, - const char *toLim); - enum XML_Convert_Result(PTRCALL *utf16Convert)(const ENCODING *enc, - const char **fromP, - const char *fromLim, - unsigned short **toP, - const unsigned short *toLim); + int (*nameMatchesAscii)(const ENCODING *, const char *, const char *, + const char *); + size_t (*nameLength)(const ENCODING *, const char *); + const char *(*skipS)(const ENCODING *, const char *); + size_t (*getAtts)(const ENCODING *enc, const char *ptr, size_t attsMax, + ATTRIBUTE *atts); + int (*charRefNumber)(const ENCODING *enc, const char *ptr); + int (*predefinedEntityName)(const ENCODING *, const char *, const char *); + void (*updatePosition)(const ENCODING *, const char *ptr, const char *end, + POSITION *); + int (*isPublicId)(const ENCODING *enc, const char *ptr, const char *end, + const char **badPtr); + enum XML_Convert_Result (*utf8Convert)(const ENCODING *enc, + const char **fromP, + const char *fromLim, char **toP, + const char *toLim); + enum XML_Convert_Result (*utf16Convert)(const ENCODING *enc, + const char **fromP, + const char *fromLim, + unsigned short **toP, + const unsigned short *toLim); int minBytesPerChar; char isUtf8; char isUtf16; @@ -293,8 +292,10 @@ int XmlInitEncoding(INIT_ENCODING *p, const ENCODING **encPtr, const char *name); const ENCODING *XmlGetUtf8InternalEncoding(void); const ENCODING *XmlGetUtf16InternalEncoding(void); -int FASTCALL XmlUtf8Encode(int charNumber, char *buf); -int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf); +const ENCODING *XmlGetUtf16LittleEndianEncoding(void); +const ENCODING *XmlGetUtf16BigEndianEncoding(void); +int XmlUtf8Encode(int charNumber, char *buf); +int XmlUtf16Encode(int charNumber, unsigned short *buf); int XmlSizeOfUnknownEncoding(void); typedef int(XMLCALL *CONVERTER)(void *userData, const char *p); @@ -312,10 +313,9 @@ int XmlInitEncodingNS(INIT_ENCODING *p, const ENCODING **encPtr, const char *name); const ENCODING *XmlGetUtf8InternalEncodingNS(void); const ENCODING *XmlGetUtf16InternalEncodingNS(void); +const ENCODING *XmlGetUtf16LittleEndianEncodingNS(void); +const ENCODING *XmlGetUtf16BigEndianEncodingNS(void); ENCODING *XmlInitUnknownEncodingNS(void *mem, const int *table, CONVERTER convert, void *userData); -# ifdef __cplusplus -} -# endif #endif /* not XmlTok_INCLUDED */ diff --git a/Modules/expat/xmltok_impl.c b/Modules/expat/xmltok_impl.c index eae11bdd968aee4..0e867689633d0fe 100644 --- a/Modules/expat/xmltok_impl.c +++ b/Modules/expat/xmltok_impl.c @@ -1,4 +1,4 @@ -/* This file is included (from xmltok.c, 1-3 times depending on XML_MIN_SIZE)! +/* This file is included (from xmltok.c, 3 times)! __ __ _ ___\ \/ /_ __ __ _| |_ / _ \\ /| '_ \ / _` | __| @@ -10,7 +10,7 @@ Copyright (c) 2000 Clark Cooper Copyright (c) 2002 Fred L. Drake, Jr. Copyright (c) 2002-2016 Karl Waclawek - Copyright (c) 2016-2022 Sebastian Pipping + Copyright (c) 2016-2026 Sebastian Pipping Copyright (c) 2017 Rhodri James Copyright (c) 2018 Benjamin Peterson Copyright (c) 2018 Anton Maklakov @@ -18,6 +18,7 @@ Copyright (c) 2020 Boris Kolpackov Copyright (c) 2022 Martin Ettl Copyright (c) 2026 Nick Begg + Copyright (c) 2026 Kartik Kenchi Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining @@ -38,14 +39,12 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ #ifdef XML_TOK_IMPL_C -# ifndef IS_INVALID_CHAR // i.e. for UTF-16 and XML_MIN_SIZE not defined -# define IS_INVALID_CHAR(enc, ptr, n) (0) -# endif - # define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \ case BT_LEAD##n: \ if (end - ptr < n) \ @@ -142,7 +141,7 @@ /* ptr points to character following "= end) @@ -428,7 +427,7 @@ PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, const char *end, /* ptr points to character following "= end) @@ -920,7 +919,7 @@ PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end, /* ptr points to character following "%" */ -static int PTRCALL +static int PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { REQUIRE_CHAR(enc, ptr, end); @@ -950,7 +949,7 @@ PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end, return XML_TOK_PARTIAL; } -static int PTRCALL +static int PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { REQUIRE_CHAR(enc, ptr, end); @@ -980,7 +979,7 @@ PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end, return -XML_TOK_POUND_NAME; } -static int PTRCALL +static int PREFIX(scanLit)(int open, const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { while (HAS_CHAR(enc, ptr, end)) { @@ -1014,7 +1013,7 @@ PREFIX(scanLit)(int open, const ENCODING *enc, const char *ptr, const char *end, return XML_TOK_PARTIAL; } -static int PTRCALL +static int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { int tok; @@ -1258,7 +1257,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end, return -tok; } -static int PTRCALL +static int PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { const char *start; @@ -1327,7 +1326,7 @@ PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *end, return XML_TOK_DATA_CHARS; } -static int PTRCALL +static int PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { const char *start; @@ -1394,7 +1393,7 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end, # ifdef XML_DTD -static int PTRCALL +static int PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { int level = 0; @@ -1446,7 +1445,7 @@ PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, const char *end, # endif /* XML_DTD */ -static int PTRCALL +static int PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end, const char **badPtr) { ptr += MINBPC(enc); @@ -1506,11 +1505,11 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end, first attsMax attributes are stored in atts. */ -static int PTRCALL -PREFIX(getAtts)(const ENCODING *enc, const char *ptr, int attsMax, +static size_t +PREFIX(getAtts)(const ENCODING *enc, const char *ptr, size_t attsMax, ATTRIBUTE *atts) { enum { other, inName, inValue } state = inName; - int nAtts = 0; + size_t nAtts = 0; int open = 0; /* defined when state == inValue; initialization just to shut up compilers */ @@ -1599,7 +1598,7 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr, int attsMax, /* not reached */ } -static int PTRFASTCALL +static int PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr) { int result = 0; /* skip &# */ @@ -1657,7 +1656,7 @@ PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr) { return checkCharRefNumber(result); } -static int PTRCALL +static int PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr, const char *end) { UNUSED_P(enc); @@ -1711,7 +1710,7 @@ PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr, return 0; } -static int PTRCALL +static int PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1, const char *end1, const char *ptr2) { UNUSED_P(enc); @@ -1730,7 +1729,7 @@ PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1, return ptr1 == end1; } -static int PTRFASTCALL +static size_t PREFIX(nameLength)(const ENCODING *enc, const char *ptr) { const char *start = ptr; for (;;) { @@ -1755,12 +1754,12 @@ PREFIX(nameLength)(const ENCODING *enc, const char *ptr) { ptr += MINBPC(enc); break; default: - return (int)(ptr - start); + return ptr - start; } } } -static const char *PTRFASTCALL +static const char * PREFIX(skipS)(const ENCODING *enc, const char *ptr) { for (;;) { switch (BYTE_TYPE(enc, ptr)) { @@ -1775,7 +1774,7 @@ PREFIX(skipS)(const ENCODING *enc, const char *ptr) { } } -static void PTRCALL +static void PREFIX(updatePosition)(const ENCODING *enc, const char *ptr, const char *end, POSITION *pos) { while (HAS_CHAR(enc, ptr, end)) { diff --git a/Modules/expat/xmltok_impl.h b/Modules/expat/xmltok_impl.h index 3469c4ae138c95a..13a08899da3b1a5 100644 --- a/Modules/expat/xmltok_impl.h +++ b/Modules/expat/xmltok_impl.h @@ -29,6 +29,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ enum { diff --git a/Modules/expat/xmltok_ns.c b/Modules/expat/xmltok_ns.c index 810ca2c6d0485eb..6373641481f75be 100644 --- a/Modules/expat/xmltok_ns.c +++ b/Modules/expat/xmltok_ns.c @@ -11,7 +11,7 @@ Copyright (c) 2002 Greg Stein Copyright (c) 2002 Fred L. Drake, Jr. Copyright (c) 2002-2006 Karl Waclawek - Copyright (c) 2017-2021 Sebastian Pipping + Copyright (c) 2017-2026 Sebastian Pipping Copyright (c) 2025 Alfonso Gregory Licensed under the MIT license: @@ -33,6 +33,8 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + SPDX-License-Identifier: MIT */ #ifdef XML_TOK_NS_C @@ -55,6 +57,16 @@ NS(XmlGetUtf16InternalEncoding)(void) { # endif } +const ENCODING * +NS(XmlGetUtf16LittleEndianEncoding)(void) { + return &ns(little2_encoding).enc; +} + +const ENCODING * +NS(XmlGetUtf16BigEndianEncoding)(void) { + return &ns(big2_encoding).enc; +} + static const ENCODING *const NS(encodings)[] = { &ns(latin1_encoding).enc, &ns(ascii_encoding).enc, &ns(utf8_encoding).enc, &ns(big2_encoding).enc, @@ -62,14 +74,14 @@ static const ENCODING *const NS(encodings)[] = { &ns(utf8_encoding).enc /* NO_ENC */ }; -static int PTRCALL +static int NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE, ptr, end, nextTokPtr); } -static int PTRCALL +static int NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE, diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c index e6a40ffc5a26144..5dd3df9bb408f0c 100644 --- a/Modules/fcntlmodule.c +++ b/Modules/fcntlmodule.c @@ -121,13 +121,14 @@ fcntl_fcntl_impl(PyObject *module, int fd, int code, PyObject *arg) return PyBytes_FromStringAndSize(buf, len); } else { - PyBytesWriter *writer = PyBytesWriter_Create(len); + PyBytesWriter *writer = PyBytesWriter_Create(len + GUARDSZ); if (writer == NULL) { PyBuffer_Release(&view); return NULL; } char *ptr = PyBytesWriter_GetData(writer); memcpy(ptr, view.buf, len); + memcpy(ptr + len, guard, GUARDSZ); PyBuffer_Release(&view); do { @@ -142,7 +143,7 @@ fcntl_fcntl_impl(PyObject *module, int fd, int code, PyObject *arg) PyBytesWriter_Discard(writer); return NULL; } - if (ptr[len] != '\0') { + if (memcmp(ptr + len, guard, GUARDSZ) != 0) { PyErr_SetString(PyExc_SystemError, "Memory corruption in fcntl() due to " "buffer overflow. " @@ -151,7 +152,8 @@ fcntl_fcntl_impl(PyObject *module, int fd, int code, PyObject *arg) PyBytesWriter_Discard(writer); return NULL; } - return PyBytesWriter_Finish(writer); + // Truncate the trailing guard bytes + return PyBytesWriter_FinishWithSize(writer, len); } #undef FCNTL_BUFSZ } @@ -316,13 +318,14 @@ fcntl_ioctl_impl(PyObject *module, int fd, unsigned long code, PyObject *arg, return PyBytes_FromStringAndSize(buf, len); } else { - PyBytesWriter *writer = PyBytesWriter_Create(len); + PyBytesWriter *writer = PyBytesWriter_Create(len + GUARDSZ); if (writer == NULL) { PyBuffer_Release(&view); return NULL; } char *ptr = PyBytesWriter_GetData(writer); memcpy(ptr, view.buf, len); + memcpy(ptr + len, guard, GUARDSZ); PyBuffer_Release(&view); do { @@ -337,7 +340,7 @@ fcntl_ioctl_impl(PyObject *module, int fd, unsigned long code, PyObject *arg, PyBytesWriter_Discard(writer); return NULL; } - if (ptr[len] != '\0') { + if (memcmp(ptr + len, guard, GUARDSZ) != 0) { PyErr_SetString(PyExc_SystemError, "Memory corruption in ioctl() due to " "buffer overflow. " @@ -346,7 +349,8 @@ fcntl_ioctl_impl(PyObject *module, int fd, unsigned long code, PyObject *arg, PyBytesWriter_Discard(writer); return NULL; } - return PyBytesWriter_Finish(writer); + // Truncate the trailing guard bytes + return PyBytesWriter_FinishWithSize(writer, len); } #undef IOCTL_BUFSZ } diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index e2df31556f3c372..af90a56b9121725 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -7,6 +7,7 @@ #include "Python.h" #include "pycore_gc.h" #include "pycore_object.h" // _PyObject_IS_GC() +#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_INT_RELAXED() #include "pycore_pystate.h" // _PyInterpreterState_GET() typedef struct _gc_runtime_state GCState; @@ -116,7 +117,7 @@ gc_set_debug_impl(PyObject *module, int flags) /*[clinic end generated code: output=7c8366575486b228 input=5e5ce15e84fbed15]*/ { GCState *gcstate = get_gc_state(); - gcstate->debug = flags; + FT_ATOMIC_STORE_INT_RELAXED(gcstate->debug, flags); Py_RETURN_NONE; } @@ -131,7 +132,7 @@ gc_get_debug_impl(PyObject *module) /*[clinic end generated code: output=91242f3506cd1e50 input=91a101e1c3b98366]*/ { GCState *gcstate = get_gc_state(); - return gcstate->debug; + return FT_ATOMIC_LOAD_INT_RELAXED(gcstate->debug); } /*[clinic input] @@ -221,9 +222,12 @@ gc_get_count_impl(PyObject *module) _PyThreadStateImpl *tstate = (_PyThreadStateImpl *)_PyThreadState_GET(); struct _gc_thread_state *gc = &tstate->gc; - // Flush the local allocation count to the global count - _Py_atomic_add_int(&gcstate->young.count, (int)gc->alloc_count); - gc->alloc_count = 0; + // Don't flush: record_allocation() checks the threshold only when it fills. + int young = _Py_atomic_load_int_relaxed(&gcstate->young.count); + young += (int)gc->alloc_count; + if (young < 0) { + young = 0; + } #endif #ifndef Py_GIL_DISABLED @@ -233,7 +237,7 @@ gc_get_count_impl(PyObject *module) gcstate->generations[2].count); #else return Py_BuildValue("(iii)", - _Py_atomic_load_int_relaxed(&gcstate->young.count), + young, gcstate->old[0].count, gcstate->old[1].count); #endif diff --git a/Modules/getaddrinfo.c b/Modules/getaddrinfo.c index de6f0bf57b5c314..311632879855a04 100644 --- a/Modules/getaddrinfo.c +++ b/Modules/getaddrinfo.c @@ -171,7 +171,10 @@ if (pai->ai_flags & AI_CANONNAME) {\ char *p;\ if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\ ((gai_afd)->a_socklen)))\ - == NULL) goto free;\ + == NULL) {\ + error = EAI_MEMORY;\ + goto free;\ + }\ memcpy(ai, pai, sizeof(struct addrinfo));\ (ai)->ai_addr = (struct sockaddr *)((ai) + 1);\ memset((ai)->ai_addr, 0, (gai_afd)->a_socklen);\ @@ -186,7 +189,10 @@ if (pai->ai_flags & AI_CANONNAME) {\ char *p;\ if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\ ((gai_afd)->a_socklen)))\ - == NULL) goto free;\ + == NULL) {\ + error = EAI_MEMORY;\ + goto free;\ + }\ memcpy(ai, pai, sizeof(struct addrinfo));\ (ai)->ai_addr = (struct sockaddr *)((ai) + 1);\ memset((ai)->ai_addr, 0, (gai_afd)->a_socklen);\ @@ -413,8 +419,8 @@ getaddrinfo(const char*hostname, const char*servname, */ } cur = cur->ai_next; + top = sentinel.ai_next; } - top = sentinel.ai_next; if (top) goto good; else @@ -463,7 +469,10 @@ getaddrinfo(const char*hostname, const char*servname, * translation function, and it looks strange * that we do addr->name translation here. */ - get_name(pton, &gai_afdl[i], &top, pton, pai, port); + error = get_name(pton, &gai_afdl[i], &top, pton, pai, port); + if (error != SUCCESS) { + goto free; + } goto good; } else ERR(EAI_FAMILY); /*xxx*/ diff --git a/Modules/getbuildinfo.c b/Modules/getbuildinfo.c index b68f0f5cc56a44c..006043d7dc3ba61 100644 --- a/Modules/getbuildinfo.c +++ b/Modules/getbuildinfo.c @@ -77,3 +77,19 @@ _Py_gitidentifier(void) gitid = GITBRANCH; return gitid; } + + +// Check if Python was built with NDEBUG macro defined or not. Implement the +// function in Modules/getbuildinfo.c so it's built with the same compiler +// flags than the Python core C code. +// +// Export the function for '_testlimitedcapi' shared extension. +PyAPI_FUNC(int) +_Py_GetBuiltWithAssert(void) +{ +#ifdef NDEBUG + return 0; +#else + return 1; +#endif +} diff --git a/Modules/getnameinfo.c b/Modules/getnameinfo.c index 2a9034b833eceb9..be8950d10fbba85 100644 --- a/Modules/getnameinfo.c +++ b/Modules/getnameinfo.c @@ -130,13 +130,13 @@ getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, /* what we should do? */ } else if (flags & NI_NUMERICSERV) { sprintf(numserv, "%d", ntohs(port)); - if (strlen(numserv) > servlen) + if (strlen(numserv) >= servlen) return ENI_MEMORY; strcpy(serv, numserv); } else { sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp"); if (sp) { - if (strlen(sp->s_name) > servlen) + if (strlen(sp->s_name) >= servlen) return ENI_MEMORY; strcpy(serv, sp->s_name); } else @@ -166,7 +166,7 @@ getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, if (inet_ntop(gni_afd->a_af, addr, numaddr, sizeof(numaddr)) == NULL) return ENI_SYSTEM; - if (strlen(numaddr) > hostlen) + if (strlen(numaddr) >= hostlen) return ENI_MEMORY; strcpy(host, numaddr); } else { @@ -181,7 +181,7 @@ getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, p = strchr(hp->h_name, '.'); if (p) *p = '\0'; } - if (strlen(hp->h_name) > hostlen) { + if (strlen(hp->h_name) >= hostlen) { #ifdef ENABLE_IPV6 freehostent(hp); #endif @@ -197,7 +197,7 @@ getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, if (inet_ntop(gni_afd->a_af, addr, numaddr, sizeof(numaddr)) == NULL) return ENI_NOHOSTNAME; - if (strlen(numaddr) > hostlen) + if (strlen(numaddr) >= hostlen) return ENI_MEMORY; strcpy(host, numaddr); } diff --git a/Modules/getpath.c b/Modules/getpath.c index ed41536acbcc813..d1b0cf6bf902b96 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -58,40 +58,52 @@ #endif +/*[clinic input] +module getpath +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b425aa3ea7292100]*/ + +#include "clinic/getpath.c.h" + /* HELPER FUNCTIONS for getpath.py */ +/*[clinic input] +getpath.abspath + + path: Py_UNICODE + / + +Return the absolute path. +[clinic start generated code]*/ + static PyObject * -getpath_abspath(PyObject *Py_UNUSED(self), PyObject *args) +getpath_abspath_impl(PyObject *module, const wchar_t *path) +/*[clinic end generated code: output=5009336e32e75b9b input=0fd554ce535744f2]*/ { - PyObject *r = NULL; - PyObject *pathobj; - wchar_t *path; - if (!PyArg_ParseTuple(args, "U", &pathobj)) { + wchar_t *abs; + if (_Py_abspath(_Py_normpath((wchar_t *)path, -1), &abs) < 0 || abs == NULL) { + PyErr_SetString(PyExc_OSError, "failed to make path absolute"); return NULL; } - Py_ssize_t len; - path = PyUnicode_AsWideCharString(pathobj, &len); - if (path) { - wchar_t *abs; - if (_Py_abspath((const wchar_t *)_Py_normpath(path, -1), &abs) == 0 && abs) { - r = PyUnicode_FromWideChar(abs, -1); - PyMem_RawFree((void *)abs); - } else { - PyErr_SetString(PyExc_OSError, "failed to make path absolute"); - } - PyMem_Free((void *)path); - } + PyObject *r = PyUnicode_FromWideChar(abs, -1); + PyMem_RawFree((void *)abs); return r; } +/*[clinic input] +getpath.basename + + path: unicode + / + +Return the final component of the path. +[clinic start generated code]*/ + static PyObject * -getpath_basename(PyObject *Py_UNUSED(self), PyObject *args) +getpath_basename_impl(PyObject *module, PyObject *path) +/*[clinic end generated code: output=d383d3b34842236e input=0de5b71fc78bbad8]*/ { - PyObject *path; - if (!PyArg_ParseTuple(args, "U", &path)) { - return NULL; - } Py_ssize_t end = PyUnicode_GET_LENGTH(path); Py_ssize_t pos = PyUnicode_FindChar(path, SEP, 0, end, -1); if (pos < 0) { @@ -101,13 +113,19 @@ getpath_basename(PyObject *Py_UNUSED(self), PyObject *args) } +/*[clinic input] +getpath.dirname + + path: unicode + / + +Return the directory component of the path. +[clinic start generated code]*/ + static PyObject * -getpath_dirname(PyObject *Py_UNUSED(self), PyObject *args) +getpath_dirname_impl(PyObject *module, PyObject *path) +/*[clinic end generated code: output=6887a025f5f6784c input=0c33269fe28957fb]*/ { - PyObject *path; - if (!PyArg_ParseTuple(args, "U", &path)) { - return NULL; - } Py_ssize_t end = PyUnicode_GET_LENGTH(path); Py_ssize_t pos = PyUnicode_FindChar(path, SEP, 0, end, -1); if (pos < 0) { @@ -117,51 +135,51 @@ getpath_dirname(PyObject *Py_UNUSED(self), PyObject *args) } -static PyObject * -getpath_isabs(PyObject *Py_UNUSED(self), PyObject *args) +/*[clinic input] +getpath.isabs -> bool + + path: Py_UNICODE + / + +Return True if the path is absolute. +[clinic start generated code]*/ + +static int +getpath_isabs_impl(PyObject *module, const wchar_t *path) +/*[clinic end generated code: output=4659b9e6f088c2ca input=04931a206cdd77f6]*/ { - PyObject *r = NULL; - PyObject *pathobj; - const wchar_t *path; - if (!PyArg_ParseTuple(args, "U", &pathobj)) { - return NULL; - } - path = PyUnicode_AsWideCharString(pathobj, NULL); - if (path) { - r = _Py_isabs(path) ? Py_True : Py_False; - PyMem_Free((void *)path); - } - return Py_XNewRef(r); + return _Py_isabs(path); } -static PyObject * -getpath_hassuffix(PyObject *Py_UNUSED(self), PyObject *args) +/*[clinic input] +getpath.hassuffix -> bool + + path as pathobj: unicode + suffix as suffixobj: unicode + / + +Return True if the path ends with the suffix, ignoring the case. +[clinic start generated code]*/ + +static int +getpath_hassuffix_impl(PyObject *module, PyObject *pathobj, + PyObject *suffixobj) +/*[clinic end generated code: output=c4cbd6f2f567f83c input=4b477740575b94d8]*/ { - PyObject *r = NULL; - PyObject *pathobj; - PyObject *suffixobj; - const wchar_t *path; - const wchar_t *suffix; - if (!PyArg_ParseTuple(args, "UU", &pathobj, &suffixobj)) { - return NULL; - } + int r = -1; Py_ssize_t len, suffixLen; - path = PyUnicode_AsWideCharString(pathobj, &len); + const wchar_t *path = PyUnicode_AsWideCharString(pathobj, &len); if (path) { - suffix = PyUnicode_AsWideCharString(suffixobj, &suffixLen); + const wchar_t *suffix = PyUnicode_AsWideCharString(suffixobj, + &suffixLen); if (suffix) { - if (suffixLen > len || + r = suffixLen <= len && #ifdef MS_WINDOWS - wcsicmp(&path[len - suffixLen], suffix) != 0 + wcsicmp(&path[len - suffixLen], suffix) == 0; #else - wcscmp(&path[len - suffixLen], suffix) != 0 + wcscmp(&path[len - suffixLen], suffix) == 0; #endif - ) { - r = Py_NewRef(Py_False); - } else { - r = Py_NewRef(Py_True); - } PyMem_Free((void *)suffix); } PyMem_Free((void *)path); @@ -170,105 +188,114 @@ getpath_hassuffix(PyObject *Py_UNUSED(self), PyObject *args) } -static PyObject * -getpath_isdir(PyObject *Py_UNUSED(self), PyObject *args) +/*[clinic input] +getpath.isdir -> bool + + path: Py_UNICODE + / + +Return True if the path is a directory. +[clinic start generated code]*/ + +static int +getpath_isdir_impl(PyObject *module, const wchar_t *path) +/*[clinic end generated code: output=467820dd83daa7a6 input=0ddd588cd5357a9a]*/ { - PyObject *r = NULL; - PyObject *pathobj; - const wchar_t *path; - if (!PyArg_ParseTuple(args, "U", &pathobj)) { - return NULL; - } - path = PyUnicode_AsWideCharString(pathobj, NULL); - if (path) { #ifdef MS_WINDOWS - DWORD attr = GetFileAttributesW(path); - r = (attr != INVALID_FILE_ATTRIBUTES) && - (attr & FILE_ATTRIBUTE_DIRECTORY) ? Py_True : Py_False; + DWORD attr = GetFileAttributesW(path); + return (attr != INVALID_FILE_ATTRIBUTES) + && (attr & FILE_ATTRIBUTE_DIRECTORY); #else - struct stat st; - r = (_Py_wstat(path, &st) == 0) && S_ISDIR(st.st_mode) ? Py_True : Py_False; + struct stat st; + return (_Py_wstat(path, &st) == 0) && S_ISDIR(st.st_mode); #endif - PyMem_Free((void *)path); - } - return Py_XNewRef(r); } -static PyObject * -getpath_isfile(PyObject *Py_UNUSED(self), PyObject *args) -{ - PyObject *pathobj; - if (!PyArg_ParseTuple(args, "U", &pathobj)) { - return NULL; - } +/*[clinic input] +getpath.isfile -> bool - int isfile; + path as pathobj: unicode + / + +Return True if the path is a regular file. +[clinic start generated code]*/ + +static int +getpath_isfile_impl(PyObject *module, PyObject *pathobj) +/*[clinic end generated code: output=197acb7a5434b9d1 input=ba1c2746ec8f2f47]*/ +{ #ifdef MS_WINDOWS wchar_t *path = PyUnicode_AsWideCharString(pathobj, NULL); if (path == NULL) { - return NULL; + return -1; } DWORD attr = GetFileAttributesW(path); PyMem_Free(path); - isfile = ((attr != INVALID_FILE_ATTRIBUTES) - && !(attr & FILE_ATTRIBUTE_DIRECTORY)); + return (attr != INVALID_FILE_ATTRIBUTES) + && !(attr & FILE_ATTRIBUTE_DIRECTORY); #else struct stat st; int res = _Py_stat(pathobj, &st); if (res == -2) { - return NULL; + return -1; } - isfile = ((res == 0) && S_ISREG(st.st_mode)); + return (res == 0) && S_ISREG(st.st_mode); #endif - return PyBool_FromLong(isfile); } -static PyObject * -getpath_isxfile(PyObject *Py_UNUSED(self), PyObject *args) -{ - PyObject *pathobj; - if (!PyArg_ParseTuple(args, "U", &pathobj)) { - return NULL; - } +/*[clinic input] +getpath.isxfile -> bool + + path as pathobj: unicode + / - int isxfile; +Return True if the path is an executable file. +[clinic start generated code]*/ + +static int +getpath_isxfile_impl(PyObject *module, PyObject *pathobj) +/*[clinic end generated code: output=2f0bc6708d945bc8 input=6d99faa90e262511]*/ +{ #ifdef MS_WINDOWS Py_ssize_t cchPath; wchar_t *path = PyUnicode_AsWideCharString(pathobj, &cchPath); if (path == NULL) { - return NULL; + return -1; } DWORD attr = GetFileAttributesW(path); + int isxfile = (attr != INVALID_FILE_ATTRIBUTES) && + !(attr & FILE_ATTRIBUTE_DIRECTORY) && + (cchPath >= 4) && + (CompareStringOrdinal(path + cchPath - 4, -1, L".exe", -1, 1 /* ignore case */) == CSTR_EQUAL); PyMem_Free(path); - isxfile = (attr != INVALID_FILE_ATTRIBUTES) && - !(attr & FILE_ATTRIBUTE_DIRECTORY) && - (cchPath >= 4) && - (CompareStringOrdinal(path + cchPath - 4, -1, L".exe", -1, 1 /* ignore case */) == CSTR_EQUAL); + return isxfile; #else struct stat st; int res = _Py_stat(pathobj, &st); if (res == -2) { - return NULL; + return -1; } - isxfile = ((res == 0) - && S_ISREG(st.st_mode) - && (st.st_mode & 0111)); + return (res == 0) && S_ISREG(st.st_mode) && (st.st_mode & 0111); #endif - return PyBool_FromLong(isxfile); } +/*[clinic input] +getpath.joinpath + + *args: tuple + +Join the path components. +[clinic start generated code]*/ + static PyObject * -getpath_joinpath(PyObject *Py_UNUSED(self), PyObject *args) +getpath_joinpath_impl(PyObject *module, PyObject *args) +/*[clinic end generated code: output=0044d429b32e5f5a input=5c67eeca4a6d1413]*/ { - if (!PyTuple_Check(args)) { - PyErr_SetString(PyExc_TypeError, "requires tuple of arguments"); - return NULL; - } Py_ssize_t n = PyTuple_GET_SIZE(args); if (n == 0) { return Py_GetConstant(Py_CONSTANT_EMPTY_STR); @@ -347,13 +374,19 @@ getpath_joinpath(PyObject *Py_UNUSED(self), PyObject *args) } +/*[clinic input] +getpath.readlines + + path as pathobj: unicode + / + +Return the lines of the file. +[clinic start generated code]*/ + static PyObject * -getpath_readlines(PyObject *Py_UNUSED(self), PyObject *args) +getpath_readlines_impl(PyObject *module, PyObject *pathobj) +/*[clinic end generated code: output=6a7c1a1d2bb23046 input=6f54150f72789b78]*/ { - PyObject *pathobj; - if (!PyArg_ParseTuple(args, "U", &pathobj)) { - return NULL; - } FILE *fp = Py_fopen(pathobj, "rb"); if (!fp) { return NULL; @@ -376,9 +409,11 @@ getpath_readlines(PyObject *Py_UNUSED(self), PyObject *args) size_t cb = fread(buffer, 1, MAX_FILE, fp); fclose(fp); if (!cb) { + PyMem_Free(buffer); return r; } if (cb >= MAX_FILE) { + PyMem_Free(buffer); Py_DECREF(r); PyErr_SetString(PyExc_MemoryError, "cannot read file larger than 32KB during initialization"); @@ -423,13 +458,19 @@ getpath_readlines(PyObject *Py_UNUSED(self), PyObject *args) } +/*[clinic input] +getpath.realpath + + path as pathobj: unicode + / + +Resolve a symlinked file. +[clinic start generated code]*/ + static PyObject * -getpath_realpath(PyObject *Py_UNUSED(self) , PyObject *args) +getpath_realpath_impl(PyObject *module, PyObject *pathobj) +/*[clinic end generated code: output=8559260e3786874e input=d3c5eee0ddd2c3e2]*/ { - PyObject *pathobj; - if (!PyArg_ParseTuple(args, "U", &pathobj)) { - return NULL; - } #if defined(HAVE_READLINK) /* This readlink calculation only resolves a symlinked file, and does not resolve any path segments. This is consistent with @@ -566,17 +607,17 @@ getpath_realpath(PyObject *Py_UNUSED(self) , PyObject *args) static PyMethodDef getpath_methods[] = { - {"abspath", getpath_abspath, METH_VARARGS, NULL}, - {"basename", getpath_basename, METH_VARARGS, NULL}, - {"dirname", getpath_dirname, METH_VARARGS, NULL}, - {"hassuffix", getpath_hassuffix, METH_VARARGS, NULL}, - {"isabs", getpath_isabs, METH_VARARGS, NULL}, - {"isdir", getpath_isdir, METH_VARARGS, NULL}, - {"isfile", getpath_isfile, METH_VARARGS, NULL}, - {"isxfile", getpath_isxfile, METH_VARARGS, NULL}, - {"joinpath", getpath_joinpath, METH_VARARGS, NULL}, - {"readlines", getpath_readlines, METH_VARARGS, NULL}, - {"realpath", getpath_realpath, METH_VARARGS, NULL}, + GETPATH_ABSPATH_METHODDEF + GETPATH_BASENAME_METHODDEF + GETPATH_DIRNAME_METHODDEF + GETPATH_HASSUFFIX_METHODDEF + GETPATH_ISABS_METHODDEF + GETPATH_ISDIR_METHODDEF + GETPATH_ISFILE_METHODDEF + GETPATH_ISXFILE_METHODDEF + GETPATH_JOINPATH_METHODDEF + GETPATH_READLINES_METHODDEF + GETPATH_REALPATH_METHODDEF {NULL, NULL, 0, NULL} }; @@ -591,7 +632,11 @@ getpath_warn(PyObject *Py_UNUSED(self), PyObject *args) if (!PyArg_ParseTuple(args, "U", &msgobj)) { return NULL; } - fprintf(stderr, "%s\n", PyUnicode_AsUTF8(msgobj)); + const char *msg = PyUnicode_AsUTF8(msgobj); + if (msg == NULL) { + return NULL; + } + fprintf(stderr, "%s\n", msg); Py_RETURN_NONE; } diff --git a/Modules/getpath.py b/Modules/getpath.py index 6199567bd777aa0..6afbe4c68985569 100644 --- a/Modules/getpath.py +++ b/Modules/getpath.py @@ -211,6 +211,28 @@ def search_up(prefix, *landmarks, test=isfile): prefix = dirname(prefix) +# The traditional Windows path length limit, not counting the terminating NUL. +MAX_PATH = 260 + + +def strip_extended_length_prefix(path): + """ + Remove the leading "\\\\?\\" of a Windows extended-length path, and + rewrite the "\\\\?\\UNC\\" form of a UNC path back to a plain "\\\\" one. + Windows does not resolve relative components (such as ".." or "/") in an + extended-length path, so keeping the prefix in a path that we later join + onto is liable to break consumers. A path that is still too long to be + used unprefixed keeps its prefix, as it has no other usable form. + """ + if path.startswith('\\\\?\\UNC\\'): + stripped = '\\\\' + path[8:] + elif path.startswith('\\\\?\\'): + stripped = path[4:] + else: + return path + return stripped if len(stripped) < MAX_PATH else path + + # ****************************************************************************** # READ VARIABLES FROM config # ****************************************************************************** @@ -232,6 +254,7 @@ def search_up(prefix, *landmarks, test=isfile): stdlib_dir_was_set_in_config = bool(stdlib_dir) real_executable_dir = None +base_executable_dir = None platstdlib_dir = None stdlib_zip = None @@ -319,6 +342,13 @@ def search_up(prefix, *landmarks, test=isfile): real_executable = base_executable #real_executable_dir = dirname(real_executable) executable = ENV_PYTHONEXECUTABLE or ENV___PYVENV_LAUNCHER__ + if os_name == 'nt': + # QUIRK: On Windows the venv launcher reports its own path through + # GetModuleFileNameW, which hands back a "\\?\" extended-length path + # whenever that is how the interpreter was invoked. Drop that prefix + # again, so the venv prefix and sys.executable stay usable by tools + # that join relative components onto them (gh-157917). + executable = strip_extended_length_prefix(executable) executable_dir = dirname(executable) @@ -409,6 +439,20 @@ def search_up(prefix, *landmarks, test=isfile): if isfile(candidate): base_executable = candidate break + if base_executable and isfile(base_executable): + # Search relative to the resolved base executable rather + # than the potentially external symlink in pyvenv.cfg. + # If nothing there locates a standard library (e.g. a + # launcher binary stored outside the installation that + # 'home' points into), keep searching from 'home'. + # base_executable_dir is still used to find platform + # dependent libraries (exec_prefix) in that case. + base_executable_dir = dirname(base_executable) + if ( + isfile(joinpath(base_executable_dir, BUILDDIR_TXT)) + or search_up(base_executable_dir, ZIP_LANDMARK, *STDLIB_LANDMARKS) + ): + executable_dir = real_executable_dir = base_executable_dir # home key found; stop iterating over lines break @@ -618,6 +662,11 @@ def search_up(prefix, *landmarks, test=isfile): exec_prefix = prefix if not exec_prefix and prefix and isdir(joinpath(prefix, PLATSTDLIB_LANDMARK)): exec_prefix = prefix + if not exec_prefix and base_executable_dir and base_executable_dir != executable_dir: + # The venv's resolved base executable may live under a separate + # exec_prefix (e.g. ./configure --exec-prefix) even when the + # stdlib was found from 'home'. + exec_prefix = search_up(base_executable_dir, PLATSTDLIB_LANDMARK, test=isdir) if not exec_prefix and executable_dir: exec_prefix = search_up(executable_dir, PLATSTDLIB_LANDMARK, test=isdir) if not exec_prefix and EXEC_PREFIX: @@ -766,10 +815,10 @@ def search_up(prefix, *landmarks, test=isfile): # SANITY CHECKS # ****************************************************************************** -# Warn if the standard library is missing, unless pythonpath_was_set was set, as -# that skips parts of the stdlib directories calculation — assume the provided -# pythonpath is correct. This is how subinterpreters initialize the path for eg. -if not py_setpath and not pythonpath_was_set: +# Warn if we did a search for the standard library and couldn't find it. Never +# show a warning if paths were provided explicitly, since we trust the caller +# knows what they're doing even if the layout doesn't look "normal". +if not (py_setpath or pythonpath_was_set or pth): home_hint = f"The Python 'home' directory was set to {home!r}, is this correct?" if (not stdlib_zip or not isfile(stdlib_zip)) and (not stdlib_dir or not isdir(stdlib_dir)): hint = home_hint if home else f'sys.prefix is set to {prefix}, is this correct?' diff --git a/Modules/getpath_noop.c b/Modules/getpath_noop.c index c10e41d07f27c99..25ca25bd42c2516 100644 --- a/Modules/getpath_noop.c +++ b/Modules/getpath_noop.c @@ -1,10 +1,21 @@ /* Implements the getpath API for compiling with no functionality */ #include "Python.h" -#include "pycore_pathconfig.h" +#include "pycore_initconfig.h" // _Py_Get_Getpath_CodeObject() +#include "pycore_pathconfig.h" // _PyConfig_InitPathConfig() PyStatus _PyConfig_InitPathConfig(PyConfig *config, int compute_path_config) { return PyStatus_Error("path configuration is unsupported"); } + +/* Used by _testinternalcapi, which is linked into Programs/_freeze_module + when extension modules are built in (MODULE_BUILDTYPE=static). */ +PyObject * +_Py_Get_Getpath_CodeObject(void) +{ + PyErr_SetString(PyExc_RuntimeError, + "path configuration is unsupported"); + return NULL; +} diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c index 32ead2598036146..5404250ee7387f4 100644 --- a/Modules/grpmodule.c +++ b/Modules/grpmodule.c @@ -111,13 +111,14 @@ mkgrent(PyObject *module, struct group *p) return NULL; } + PyObject_GC_Track(v); return v; } /*[clinic input] grp.getgrgid - id: object + id as gid: gid_t Return the group database entry for the given numeric group ID. @@ -125,18 +126,14 @@ If id is not valid, raise KeyError. [clinic start generated code]*/ static PyObject * -grp_getgrgid_impl(PyObject *module, PyObject *id) -/*[clinic end generated code: output=30797c289504a1ba input=15fa0e2ccf5cda25]*/ +grp_getgrgid_impl(PyObject *module, gid_t gid) +/*[clinic end generated code: output=a9e7385cd6df08da input=fca15128dd772588]*/ { PyObject *retval = NULL; int nomem = 0; char *buf = NULL, *buf2 = NULL; - gid_t gid; struct group *p; - if (!_Py_Gid_Converter(id, &gid)) { - return NULL; - } #ifdef HAVE_GETGRGID_R int status; Py_ssize_t bufsize; diff --git a/Modules/hmacmodule.c b/Modules/hmacmodule.c index 0f9eca2f73bd0c5..a76a7056e494437 100644 --- a/Modules/hmacmodule.c +++ b/Modules/hmacmodule.c @@ -271,14 +271,6 @@ get_hmacmodule_state(PyObject *module) return (hmacmodule_state *)state; } -static inline hmacmodule_state * -get_hmacmodule_state_by_cls(PyTypeObject *cls) -{ - void *state = PyType_GetModuleState(cls); - assert(state != NULL); - return (hmacmodule_state *)state; -} - // --- HMAC Object ------------------------------------------------------------ typedef Hacl_Streaming_HMAC_agile_state HACL_HMAC_state; @@ -387,16 +379,17 @@ narrow_hmac_hash_kind(hmacmodule_state *state, HMAC_Hash_Kind kind) * * If 'code' represents a successful operation, this returns 0. * Otherwise, this sets an appropriate exception and returns -1. + * + * The caller must have an attached thread state. */ static int _hacl_convert_errno(hacl_errno_t code) { - assert(PyGILState_GetThisThreadState() != NULL); + assert(PyThreadState_GetUnchecked() != NULL); if (code == Hacl_Streaming_Types_Success) { return 0; } - PyGILState_STATE gstate = PyGILState_Ensure(); switch (code) { case Hacl_Streaming_Types_InvalidAlgorithm: { PyErr_SetString(PyExc_ValueError, "invalid HACL* algorithm"); @@ -421,7 +414,6 @@ _hacl_convert_errno(hacl_errno_t code) break; } } - PyGILState_Release(gstate); return -1; } @@ -457,39 +449,33 @@ _hacl_hmac_state_free(HACL_HMAC_state *state) /* * Call the HACL* HMAC-HASH update function on the given data. * - * On DEBUG builds, the update() call is verified. - * - * Return 0 on success; otherwise, set an exception and return -1 on failure. + * Return the HACL* exit code. No exception is set, so that this + * can be called without an attached thread state or with a lock held. */ -static int +static hacl_errno_t _hacl_hmac_state_update_once(HACL_HMAC_state *state, uint8_t *buf, uint32_t len) { -#ifndef NDEBUG - hacl_errno_t code = Hacl_Streaming_HMAC_update(state, buf, len); - return _hacl_convert_errno(code); -#else - (void)Hacl_Streaming_HMAC_update(state, buf, len); - return 0; -#endif + return Hacl_Streaming_HMAC_update(state, buf, len); } /* * Perform the HMAC-HASH update() operation in a streaming fashion. * - * On DEBUG builds, each update() call is verified. - * - * Return 0 on success; otherwise, set an exception and return -1 on failure. + * Return the HACL* exit code. No exception is set, so that this + * can be called without an attached thread state or with a lock held. + * Use _hacl_convert_errno() afterwards to set an appropriate exception. */ -static int +static hacl_errno_t _hacl_hmac_state_update(HACL_HMAC_state *state, uint8_t *buf, Py_ssize_t len) { assert(len >= 0); #ifdef Py_HMAC_SSIZE_LARGER_THAN_UINT32 while (len > UINT32_MAX_AS_SSIZE_T) { - if (_hacl_hmac_state_update_once(state, buf, UINT32_MAX) < 0) { - assert(PyErr_Occurred()); - return -1; + hacl_errno_t code = _hacl_hmac_state_update_once(state, buf, + UINT32_MAX); + if (code != Hacl_Streaming_Types_Success) { + return code; } buf += UINT32_MAX; len -= UINT32_MAX; @@ -676,6 +662,24 @@ has_uint32_t_buffer_length(const Py_buffer *buffer) // --- HMAC object ------------------------------------------------------------ +/* + * Create a zero-initialized untracked HMAC object. + * + * Return NULL on failure with an exception set. + */ +static HMACObject * +hmac_new_object(PyTypeObject *tp) +{ + HMACObject *self = (HMACObject *)tp->tp_alloc(tp, 0); + if (self == NULL) { + return NULL; + } + HASHLIB_INIT_MUTEX(self); + // tp_alloc initializes the memory to zero but the unknown kind is -1 + self->kind = Py_hmac_kind_hash_unknown; + return self; +} + /* * Use the HMAC information 'info' to populate the corresponding fields. * @@ -687,7 +691,7 @@ hmac_set_hinfo(hmacmodule_state *state, HMACObject *self, const py_hmac_hinfo *info) { assert(info->display_name != NULL); - self->name = Py_NewRef(info->display_name); + Py_XSETREF(self->name, Py_NewRef(info->display_name)); assert_is_static_hmac_hash_kind(info->kind); self->kind = narrow_hmac_hash_kind(state, info->kind); assert(info->block_size <= Py_hmac_hash_max_block_size); @@ -756,16 +760,15 @@ _hmac_new_impl(PyObject *module, PyObject *keyobj, PyObject *msgobj, return NULL; } - HMACObject *self = PyObject_New(HMACObject, state->hmac_type); + HMACObject *self = hmac_new_object(state->hmac_type); if (self == NULL) { return NULL; } - HASHLIB_INIT_MUTEX(self); hmac_set_hinfo(state, self, info); int rc; // Create the HACL* internal state with the given key. Py_buffer key; - GET_BUFFER_VIEW_OR_ERROR(keyobj, &key, goto error_on_key); + GET_BUFFER_VIEW_OR_ERROR(keyobj, &key, goto error); rc = hmac_new_initial_state(self, key.buf, key.len); PyBuffer_Release(&key); if (rc < 0) { @@ -777,24 +780,20 @@ _hmac_new_impl(PyObject *module, PyObject *keyobj, PyObject *msgobj, GET_BUFFER_VIEW_OR_ERROR(msgobj, &msg, goto error); /* Do not use self->mutex here as this is the constructor * where it is not yet possible to have concurrent access. */ + hacl_errno_t code; HASHLIB_EXTERNAL_INSTRUCTIONS_UNLOCKED( msg.len, - rc = _hacl_hmac_state_update(self->state, msg.buf, msg.len) + code = _hacl_hmac_state_update(self->state, msg.buf, msg.len) ); PyBuffer_Release(&msg); -#ifndef NDEBUG + rc = _hacl_convert_errno(code); if (rc < 0) { goto error; } -#else - (void)rc; -#endif } assert(rc == 0); return (PyObject *)self; -error_on_key: - self->state = NULL; error: Py_DECREF(self); return NULL; @@ -807,7 +806,7 @@ static void hmac_copy_hinfo(HMACObject *out, const HMACObject *src) { assert(src->name != NULL); - out->name = Py_NewRef(src->name); + Py_XSETREF(out->name, Py_NewRef(src->name)); assert(src->kind != Py_hmac_kind_hash_unknown); out->kind = src->kind; assert(src->block_size <= Py_hmac_hash_max_block_size); @@ -850,8 +849,7 @@ static PyObject * _hmac_HMAC_copy_impl(HMACObject *self, PyTypeObject *cls) /*[clinic end generated code: output=a955bfa55b65b215 input=17b2c0ad0b147e36]*/ { - hmacmodule_state *state = get_hmacmodule_state_by_cls(cls); - HMACObject *copy = PyObject_New(HMACObject, state->hmac_type); + HMACObject *copy = hmac_new_object(cls); if (copy == NULL) { return NULL; } @@ -868,7 +866,6 @@ _hmac_HMAC_copy_impl(HMACObject *self, PyTypeObject *cls) return NULL; } - HASHLIB_INIT_MUTEX(copy); return (PyObject *)copy; } @@ -884,15 +881,15 @@ static PyObject * _hmac_HMAC_update_impl(HMACObject *self, PyObject *msgobj) /*[clinic end generated code: output=962134ada5e55985 input=7c0ea830efb03367]*/ { - int rc = 0; + hacl_errno_t code; Py_buffer msg; GET_BUFFER_VIEW_OR_ERROUT(msgobj, &msg); HASHLIB_EXTERNAL_INSTRUCTIONS_LOCKED( self, msg.len, - rc = _hacl_hmac_state_update(self->state, msg.buf, msg.len) + code = _hacl_hmac_state_update(self->state, msg.buf, msg.len) ); PyBuffer_Release(&msg); - return rc < 0 ? NULL : Py_None; + return _hacl_convert_errno(code) < 0 ? NULL : Py_None; } /* diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 72bfab1abaf9cae..d7daad8c3038588 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -65,6 +65,16 @@ find_state_by_type(PyTypeObject *tp) return get_module_state(mod); } +// The generated code (clinic/itertoolsmodule.c.h) needs the object types +// of the type slots implemented with Argument Clinic. +typedef struct chainobject chainobject; +typedef struct productobject productobject; +typedef struct combinationsobject combinationsobject; +typedef struct cwrobject cwrobject; +typedef struct permutationsobject permutationsobject; +typedef struct accumulateobject accumulateobject; +typedef struct ziplongestobject ziplongestobject; + /*[clinic input] module itertools class itertools.groupby "groupbyobject *" "clinic_state()->groupby_type" @@ -77,16 +87,18 @@ class itertools.dropwhile "dropwhileobject *" "clinic_state()->dropwhile_type" class itertools.takewhile "takewhileobject *" "clinic_state()->takewhile_type" class itertools.starmap "starmapobject *" "clinic_state()->starmap_type" class itertools.chain "chainobject *" "clinic_state()->chain_type" +class itertools.product "productobject *" "clinic_state()->product_type" class itertools.combinations "combinationsobject *" "clinic_state()->combinations_type" -class itertools.combinations_with_replacement "cwr_object *" "clinic_state()->cwr_type" +class itertools.combinations_with_replacement "cwrobject *" "clinic_state()->cwr_type" class itertools.permutations "permutationsobject *" "clinic_state()->permutations_type" class itertools.accumulate "accumulateobject *" "clinic_state()->accumulate_type" +class itertools.zip_longest "ziplongestobject *" "clinic_state()->ziplongest_type" class itertools.compress "compressobject *" "clinic_state()->compress_type" class itertools.filterfalse "filterfalseobject *" "clinic_state()->filterfalse_type" class itertools.count "countobject *" "clinic_state()->count_type" class itertools.pairwise "pairwiseobject *" "clinic_state()->pairwise_type" [clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=aa48fe4de9d4080f]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=1086fb2d308d75d2]*/ #define clinic_state() (find_state_by_type(type)) #define clinic_state_by_cls() (get_module_state_by_cls(base_tp)) @@ -108,6 +120,7 @@ typedef struct { /*[clinic input] @permit_long_summary +@vectorcall @classmethod itertools.batched.__new__ as batched_new iterable: object @@ -137,7 +150,7 @@ than n. static PyObject * batched_new_impl(PyTypeObject *type, PyObject *iterable, Py_ssize_t n, int strict) -/*[clinic end generated code: output=c6de11b061529d3e input=b31d8be8e8577a34]*/ +/*[clinic end generated code: output=c6de11b061529d3e input=e225f892d3eee347]*/ { PyObject *it; batchedobject *bo; @@ -258,6 +271,7 @@ static PyType_Slot batched_slots[] = { {Py_tp_iternext, batched_next}, {Py_tp_alloc, PyType_GenericAlloc}, {Py_tp_new, batched_new}, + {Py_tp_vectorcall, batched_vectorcall}, {Py_tp_free, PyObject_GC_Del}, {0, NULL}, }; @@ -283,6 +297,7 @@ typedef struct { #define pairwiseobject_CAST(op) ((pairwiseobject *)(op)) /*[clinic input] +@vectorcall @classmethod itertools.pairwise.__new__ as pairwise_new iterable: object @@ -295,7 +310,7 @@ Return an iterator of overlapping pairs taken from the input iterator. static PyObject * pairwise_new_impl(PyTypeObject *type, PyObject *iterable) -/*[clinic end generated code: output=9f0267062d384456 input=6e7c3cddb431a8d6]*/ +/*[clinic end generated code: output=9f0267062d384456 input=32624f8712dcf0a3]*/ { PyObject *it; pairwiseobject *po; @@ -407,6 +422,7 @@ static PyType_Slot pairwise_slots[] = { {Py_tp_iternext, pairwise_next}, {Py_tp_alloc, PyType_GenericAlloc}, {Py_tp_new, pairwise_new}, + {Py_tp_vectorcall, pairwise_vectorcall}, {Py_tp_free, PyObject_GC_Del}, {0, NULL}, }; @@ -439,6 +455,7 @@ static PyObject *_grouper_create(groupbyobject *, PyObject *); /*[clinic input] @permit_long_summary +@vectorcall @classmethod itertools.groupby.__new__ @@ -454,7 +471,7 @@ make an iterator that returns consecutive keys and groups from the iterable static PyObject * itertools_groupby_impl(PyTypeObject *type, PyObject *it, PyObject *keyfunc) -/*[clinic end generated code: output=cbb1ae3a90fd4141 input=9f89fe625b20ef1a]*/ +/*[clinic end generated code: output=cbb1ae3a90fd4141 input=83700c6814fea634]*/ { groupbyobject *gbo; @@ -582,6 +599,7 @@ static PyType_Slot groupby_slots[] = { {Py_tp_iter, PyObject_SelfIter}, {Py_tp_iternext, groupby_next}, {Py_tp_new, itertools_groupby}, + {Py_tp_vectorcall, itertools_groupby_vectorcall}, {Py_tp_free, PyObject_GC_Del}, {0, NULL}, }; @@ -872,6 +890,7 @@ teedataobject_dealloc(PyObject *op) } /*[clinic input] +@vectorcall @classmethod itertools.teedataobject.__new__ iterable as it: object @@ -884,7 +903,7 @@ Data container common to multiple tee objects. static PyObject * itertools_teedataobject_impl(PyTypeObject *type, PyObject *it, PyObject *values, PyObject *next) -/*[clinic end generated code: output=3343ceb07e08df5e input=be60f2fabd2b72ba]*/ +/*[clinic end generated code: output=3343ceb07e08df5e input=02647670a03714c0]*/ { teedataobject *tdo; Py_ssize_t i, len; @@ -932,6 +951,7 @@ static PyType_Slot teedataobject_slots[] = { {Py_tp_traverse, teedataobject_traverse}, {Py_tp_clear, teedataobject_clear}, {Py_tp_new, itertools_teedataobject}, + {Py_tp_vectorcall, itertools_teedataobject_vectorcall}, {Py_tp_free, PyObject_GC_Del}, {0, NULL}, }; @@ -1209,6 +1229,7 @@ typedef struct { /*[clinic input] @permit_long_summary +@vectorcall @classmethod itertools.cycle.__new__ iterable: object @@ -1218,7 +1239,7 @@ Return elements from the iterable until it is exhausted. Then repeat the sequenc static PyObject * itertools_cycle_impl(PyTypeObject *type, PyObject *iterable) -/*[clinic end generated code: output=f60e5ec17a45b35c input=ead392f4aac7afd8]*/ +/*[clinic end generated code: output=f60e5ec17a45b35c input=183a6615ee9f1440]*/ { PyObject *it; PyObject *saved; @@ -1317,6 +1338,7 @@ static PyType_Slot cycle_slots[] = { {Py_tp_iter, PyObject_SelfIter}, {Py_tp_iternext, cycle_next}, {Py_tp_new, itertools_cycle}, + {Py_tp_vectorcall, itertools_cycle_vectorcall}, {Py_tp_free, PyObject_GC_Del}, {0, NULL}, }; @@ -1342,6 +1364,7 @@ typedef struct { #define dropwhileobject_CAST(op) ((dropwhileobject *)(op)) /*[clinic input] +@vectorcall @classmethod itertools.dropwhile.__new__ predicate as func: object @@ -1354,7 +1377,7 @@ Afterwards, return every element until the iterable is exhausted. static PyObject * itertools_dropwhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq) -/*[clinic end generated code: output=92f9d0d89af149e4 input=d39737147c9f0a26]*/ +/*[clinic end generated code: output=92f9d0d89af149e4 input=38ed294cc91d3aa8]*/ { PyObject *it; dropwhileobject *lz; @@ -1441,6 +1464,7 @@ static PyType_Slot dropwhile_slots[] = { {Py_tp_iter, PyObject_SelfIter}, {Py_tp_iternext, dropwhile_next}, {Py_tp_new, itertools_dropwhile}, + {Py_tp_vectorcall, itertools_dropwhile_vectorcall}, {Py_tp_free, PyObject_GC_Del}, {0, NULL}, }; @@ -1467,6 +1491,7 @@ typedef struct { /*[clinic input] @permit_long_summary +@vectorcall @classmethod itertools.takewhile.__new__ predicate as func: object @@ -1477,7 +1502,7 @@ Return successive entries from an iterable as long as the predicate evaluates to static PyObject * itertools_takewhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq) -/*[clinic end generated code: output=bb179ea7864e2ef6 input=61e42255dd0a7657]*/ +/*[clinic end generated code: output=bb179ea7864e2ef6 input=168fa0aa716792be]*/ { PyObject *it; takewhileobject *lz; @@ -1560,6 +1585,7 @@ static PyType_Slot takewhile_slots[] = { {Py_tp_iter, PyObject_SelfIter}, {Py_tp_iternext, takewhile_next}, {Py_tp_new, itertools_takewhile}, + {Py_tp_vectorcall, itertools_takewhile_vectorcall}, {Py_tp_free, PyObject_GC_Del}, {0, NULL}, }; @@ -1777,6 +1803,7 @@ typedef struct { /*[clinic input] @permit_long_summary +@vectorcall @classmethod itertools.starmap.__new__ function as func: object @@ -1787,7 +1814,7 @@ Return an iterator whose values are returned from the function evaluated with an static PyObject * itertools_starmap_impl(PyTypeObject *type, PyObject *func, PyObject *seq) -/*[clinic end generated code: output=79eeb81d452c6e8d input=8c9068da0692d6d2]*/ +/*[clinic end generated code: output=79eeb81d452c6e8d input=a7986310dcdb9694]*/ { PyObject *it; starmapobject *lz; @@ -1862,6 +1889,7 @@ static PyType_Slot starmap_slots[] = { {Py_tp_iter, PyObject_SelfIter}, {Py_tp_iternext, starmap_next}, {Py_tp_new, itertools_starmap}, + {Py_tp_vectorcall, itertools_starmap_vectorcall}, {Py_tp_free, PyObject_GC_Del}, {0, NULL}, }; @@ -1877,11 +1905,11 @@ static PyType_Spec starmap_spec = { /* chain object **************************************************************/ -typedef struct { +struct chainobject { PyObject_HEAD PyObject *source; /* Iterator over input iterables */ PyObject *active; /* Currently running input iterator */ -} chainobject; +}; #define chainobject_CAST(op) ((chainobject *)(op)) @@ -1963,10 +1991,16 @@ chain_traverse(PyObject *op, visitproc visit, void *arg) return 0; } -static inline PyObject * -chain_next_lock_held(PyObject *op) +/*[clinic input] +@critical_section +itertools.chain.__next__ as chain_next +[clinic start generated code]*/ + +static PyObject * +chain_next_impl(chainobject *self) +/*[clinic end generated code: output=91e716f45def7fa9 input=e17098e9dc88706b]*/ { - chainobject *lz = chainobject_CAST(op); + chainobject *lz = self; PyObject *item; /* lz->source is the iterator of iterables. If it's NULL, we've already @@ -2002,16 +2036,6 @@ chain_next_lock_held(PyObject *op) return NULL; } -static PyObject * -chain_next(PyObject *op) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(op); - result = chain_next_lock_held(op); - Py_END_CRITICAL_SECTION() - return result; -} - PyDoc_STRVAR(chain_doc, "chain(*iterables)\n\ --\n\ @@ -2055,13 +2079,13 @@ static PyType_Spec chain_spec = { /* product object ************************************************************/ -typedef struct { +struct productobject { PyObject_HEAD PyObject *pools; /* tuple of pool tuples */ Py_ssize_t *indices; /* one index per pool */ PyObject *result; /* most recently returned result tuple */ int stopped; /* set to 1 when the iterator is exhausted */ -} productobject; +}; #define productobject_CAST(op) ((productobject *)(op)) @@ -2182,10 +2206,16 @@ product_traverse(PyObject *op, visitproc visit, void *arg) return 0; } +/*[clinic input] +@critical_section +itertools.product.__next__ as product_next +[clinic start generated code]*/ + static PyObject * -product_next_lock_held(PyObject *op) +product_next_impl(productobject *self) +/*[clinic end generated code: output=d20b8571608c2043 input=54266fe7ed4a857a]*/ { - productobject *lz = productobject_CAST(op); + productobject *lz = self; PyObject *pool; PyObject *elem; PyObject *oldelem; @@ -2269,16 +2299,6 @@ product_next_lock_held(PyObject *op) return NULL; } -static PyObject * -product_next(PyObject *op) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(op); - result = product_next_lock_held(op); - Py_END_CRITICAL_SECTION() - return result; -} - static PyMethodDef product_methods[] = { {"__sizeof__", product_sizeof, METH_NOARGS, sizeof_doc}, {NULL, NULL} /* sentinel */ @@ -2323,18 +2343,19 @@ static PyType_Spec product_spec = { /* combinations object *******************************************************/ -typedef struct { +struct combinationsobject { PyObject_HEAD PyObject *pool; /* input converted to a tuple */ Py_ssize_t *indices; /* one index per result element */ PyObject *result; /* most recently returned result tuple */ Py_ssize_t r; /* size of result tuple */ int stopped; /* set to 1 when the iterator is exhausted */ -} combinationsobject; +}; #define combinationsobject_CAST(op) ((combinationsobject *)(op)) /*[clinic input] +@vectorcall @classmethod itertools.combinations.__new__ iterable: object @@ -2347,7 +2368,7 @@ combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3) static PyObject * itertools_combinations_impl(PyTypeObject *type, PyObject *iterable, Py_ssize_t r) -/*[clinic end generated code: output=87a689b39c40039c input=a32f07a15cfa4676]*/ +/*[clinic end generated code: output=87a689b39c40039c input=119eb0d9196abfe3]*/ { combinationsobject *co; Py_ssize_t n; @@ -2421,10 +2442,16 @@ combinations_traverse(PyObject *op, visitproc visit, void *arg) return 0; } +/*[clinic input] +@critical_section +itertools.combinations.__next__ as combinations_next +[clinic start generated code]*/ + static PyObject * -combinations_next_lock_held(PyObject *op) +combinations_next_impl(combinationsobject *self) +/*[clinic end generated code: output=19965c1a1f4b8f2a input=93000f6ec48380d7]*/ { - combinationsobject *co = combinationsobject_CAST(op); + combinationsobject *co = self; PyObject *elem; PyObject *oldelem; PyObject *pool = co->pool; @@ -2507,16 +2534,6 @@ combinations_next_lock_held(PyObject *op) return NULL; } -static PyObject * -combinations_next(PyObject *op) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(op); - result = combinations_next_lock_held(op); - Py_END_CRITICAL_SECTION() - return result; -} - static PyMethodDef combinations_methods[] = { {"__sizeof__", combinations_sizeof, METH_NOARGS, sizeof_doc}, {NULL, NULL} /* sentinel */ @@ -2531,6 +2548,7 @@ static PyType_Slot combinations_slots[] = { {Py_tp_iternext, combinations_next}, {Py_tp_methods, combinations_methods}, {Py_tp_new, itertools_combinations}, + {Py_tp_vectorcall, itertools_combinations_vectorcall}, {Py_tp_free, PyObject_GC_Del}, {0, NULL}, }; @@ -2572,20 +2590,21 @@ static PyType_Spec combinations_spec = { if sorted(indices) == list(indices): yield tuple(pool[i] for i in indices) */ -typedef struct { +struct cwrobject { PyObject_HEAD PyObject *pool; /* input converted to a tuple */ Py_ssize_t *indices; /* one index per result element */ PyObject *result; /* most recently returned result tuple */ Py_ssize_t r; /* size of result tuple */ int stopped; /* set to 1 when the cwr iterator is exhausted */ -} cwrobject; +}; #define cwrobject_CAST(op) ((cwrobject *)(op)) /*[clinic input] @permit_long_summary @permit_long_docstring_body +@vectorcall @classmethod itertools.combinations_with_replacement.__new__ iterable: object @@ -2599,7 +2618,7 @@ static PyObject * itertools_combinations_with_replacement_impl(PyTypeObject *type, PyObject *iterable, Py_ssize_t r) -/*[clinic end generated code: output=48b26856d4e659ca input=828696750169e84f]*/ +/*[clinic end generated code: output=48b26856d4e659ca input=8bd0382a7253de95]*/ { cwrobject *co; Py_ssize_t n; @@ -2673,10 +2692,16 @@ cwr_traverse(PyObject *op, visitproc visit, void *arg) return 0; } +/*[clinic input] +@critical_section +itertools.combinations_with_replacement.__next__ as cwr_next +[clinic start generated code]*/ + static PyObject * -cwr_next_lock_held(PyObject *op) +cwr_next_impl(cwrobject *self) +/*[clinic end generated code: output=760ddcfbf905ee37 input=d9ed46a28a5bb29a]*/ { - cwrobject *co = cwrobject_CAST(op); + cwrobject *co = self; PyObject *elem; PyObject *oldelem; PyObject *pool = co->pool; @@ -2753,16 +2778,6 @@ cwr_next_lock_held(PyObject *op) return NULL; } -static PyObject * -cwr_next(PyObject *op) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(op); - result = cwr_next_lock_held(op); - Py_END_CRITICAL_SECTION() - return result; -} - static PyMethodDef cwr_methods[] = { {"__sizeof__", cwr_sizeof, METH_NOARGS, sizeof_doc}, {NULL, NULL} /* sentinel */ @@ -2777,6 +2792,7 @@ static PyType_Slot cwr_slots[] = { {Py_tp_iternext, cwr_next}, {Py_tp_methods, cwr_methods}, {Py_tp_new, itertools_combinations_with_replacement}, + {Py_tp_vectorcall, itertools_combinations_with_replacement_vectorcall}, {Py_tp_free, PyObject_GC_Del}, {0, NULL}, }; @@ -2818,7 +2834,7 @@ def permutations(iterable, r=None): return */ -typedef struct { +struct permutationsobject { PyObject_HEAD PyObject *pool; /* input converted to a tuple */ Py_ssize_t *indices; /* one index per element in the pool */ @@ -2826,11 +2842,12 @@ typedef struct { PyObject *result; /* most recently returned result tuple */ Py_ssize_t r; /* size of result tuple */ int stopped; /* set to 1 when the iterator is exhausted */ -} permutationsobject; +}; #define permutationsobject_CAST(op) ((permutationsobject *)(op)) /*[clinic input] +@vectorcall @classmethod itertools.permutations.__new__ iterable: object @@ -2843,7 +2860,7 @@ permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1) static PyObject * itertools_permutations_impl(PyTypeObject *type, PyObject *iterable, PyObject *robj) -/*[clinic end generated code: output=296a72fa76d620ea input=57d0170a4ac0ec7a]*/ +/*[clinic end generated code: output=296a72fa76d620ea input=3679c9c6e757d17d]*/ { permutationsobject *po; Py_ssize_t n; @@ -2942,10 +2959,16 @@ permutations_traverse(PyObject *op, visitproc visit, void *arg) return 0; } +/*[clinic input] +@critical_section +itertools.permutations.__next__ as permutations_next +[clinic start generated code]*/ + static PyObject * -permutations_next_lock_held(PyObject *op) +permutations_next_impl(permutationsobject *self) +/*[clinic end generated code: output=17d8db4465bd3ee5 input=d4c1a1eed76a35e0]*/ { - permutationsobject *po = permutationsobject_CAST(op); + permutationsobject *po = self; PyObject *elem; PyObject *oldelem; PyObject *pool = po->pool; @@ -3033,16 +3056,6 @@ permutations_next_lock_held(PyObject *op) return NULL; } -static PyObject * -permutations_next(PyObject *op) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(op); - result = permutations_next_lock_held(op); - Py_END_CRITICAL_SECTION() - return result; -} - static PyMethodDef permuations_methods[] = { {"__sizeof__", permutations_sizeof, METH_NOARGS, sizeof_doc}, {NULL, NULL} /* sentinel */ @@ -3057,6 +3070,7 @@ static PyType_Slot permutations_slots[] = { {Py_tp_iternext, permutations_next}, {Py_tp_methods, permuations_methods}, {Py_tp_new, itertools_permutations}, + {Py_tp_vectorcall, itertools_permutations_vectorcall}, {Py_tp_free, PyObject_GC_Del}, {0, NULL}, }; @@ -3072,18 +3086,19 @@ static PyType_Spec permutations_spec = { /* accumulate object ********************************************************/ -typedef struct { +struct accumulateobject { PyObject_HEAD PyObject *total; PyObject *it; PyObject *binop; PyObject *initial; itertools_state *state; -} accumulateobject; +}; #define accumulateobject_CAST(op) ((accumulateobject *)(op)) /*[clinic input] +@vectorcall @classmethod itertools.accumulate.__new__ iterable: object @@ -3096,7 +3111,7 @@ Return series of accumulated sums (or other binary function results). static PyObject * itertools_accumulate_impl(PyTypeObject *type, PyObject *iterable, PyObject *binop, PyObject *initial) -/*[clinic end generated code: output=66da2650627128f8 input=c4ce20ac59bf7ffd]*/ +/*[clinic end generated code: output=66da2650627128f8 input=9c7edffb7110edc9]*/ { PyObject *it; accumulateobject *lz; @@ -3149,10 +3164,16 @@ accumulate_traverse(PyObject *op, visitproc visit, void *arg) return 0; } +/*[clinic input] +@critical_section +itertools.accumulate.__next__ as accumulate_next +[clinic start generated code]*/ + static PyObject * -accumulate_next_lock_held(PyObject *op) +accumulate_next_impl(accumulateobject *self) +/*[clinic end generated code: output=30d3f9b40248d8a6 input=758a144b7cfb1ef4]*/ { - accumulateobject *lz = accumulateobject_CAST(op); + accumulateobject *lz = self; PyObject *val, *newtotal; if (lz->initial != Py_None) { @@ -3182,16 +3203,6 @@ accumulate_next_lock_held(PyObject *op) return newtotal; } -static PyObject * -accumulate_next(PyObject *op) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(op); - result = accumulate_next_lock_held(op); - Py_END_CRITICAL_SECTION() - return result; -} - static PyType_Slot accumulate_slots[] = { {Py_tp_dealloc, accumulate_dealloc}, {Py_tp_getattro, PyObject_GenericGetAttr}, @@ -3200,6 +3211,7 @@ static PyType_Slot accumulate_slots[] = { {Py_tp_iter, PyObject_SelfIter}, {Py_tp_iternext, accumulate_next}, {Py_tp_new, itertools_accumulate}, + {Py_tp_vectorcall, itertools_accumulate_vectorcall}, {Py_tp_free, PyObject_GC_Del}, {0, NULL}, }; @@ -3231,6 +3243,7 @@ typedef struct { #define compressobject_CAST(op) ((compressobject *)(op)) /*[clinic input] +@vectorcall @classmethod itertools.compress.__new__ data as seq1: object @@ -3243,7 +3256,7 @@ to choose the data elements. static PyObject * itertools_compress_impl(PyTypeObject *type, PyObject *seq1, PyObject *seq2) -/*[clinic end generated code: output=7e67157212ed09e0 input=32ca4347dbc46749]*/ +/*[clinic end generated code: output=7e67157212ed09e0 input=a886cf13635c9780]*/ { PyObject *data=NULL, *selectors=NULL; compressobject *lz; @@ -3336,6 +3349,7 @@ static PyType_Slot compress_slots[] = { {Py_tp_iter, PyObject_SelfIter}, {Py_tp_iternext, compress_next}, {Py_tp_new, itertools_compress}, + {Py_tp_vectorcall, itertools_compress_vectorcall}, {Py_tp_free, PyObject_GC_Del}, {0, NULL}, }; @@ -3360,6 +3374,7 @@ typedef struct { #define filterfalseobject_CAST(op) ((filterfalseobject *)(op)) /*[clinic input] +@vectorcall @classmethod itertools.filterfalse.__new__ function as func: object @@ -3372,7 +3387,7 @@ If function is None, return the items that are false. static PyObject * itertools_filterfalse_impl(PyTypeObject *type, PyObject *func, PyObject *seq) -/*[clinic end generated code: output=55f87eab9fc0484e input=2d684a2c66f99cde]*/ +/*[clinic end generated code: output=55f87eab9fc0484e input=a80f7d973f6efc81]*/ { PyObject *it; filterfalseobject *lz; @@ -3459,6 +3474,7 @@ static PyType_Slot filterfalse_slots[] = { {Py_tp_iter, PyObject_SelfIter}, {Py_tp_iternext, filterfalse_next}, {Py_tp_new, itertools_filterfalse}, + {Py_tp_vectorcall, itertools_filterfalse_vectorcall}, {Py_tp_free, PyObject_GC_Del}, {0, NULL}, }; @@ -3502,6 +3518,7 @@ slow_mode: when cnt == PY_SSIZE_T_MAX, step is not int(1), or cnt is a float. /*[clinic input] @permit_long_summary +@vectorcall @classmethod itertools.count.__new__ start as long_cnt: object(c_default="NULL") = 0 @@ -3519,7 +3536,7 @@ Equivalent to: static PyObject * itertools_count_impl(PyTypeObject *type, PyObject *long_cnt, PyObject *long_step) -/*[clinic end generated code: output=09a9250aebd00b1c input=91e4b12c0e88b9f4]*/ +/*[clinic end generated code: output=09a9250aebd00b1c input=b8a57119ba1cdd54]*/ { countobject *lz; int fast_mode; @@ -3675,9 +3692,11 @@ static PyObject * count_repr(PyObject *op) { countobject *lz = countobject_CAST(op); - if (lz->long_cnt == NULL) + if (lz->long_cnt == NULL) { + Py_ssize_t cnt = FT_ATOMIC_LOAD_SSIZE_RELAXED(lz->cnt); return PyUnicode_FromFormat("%s(%zd)", - _PyType_Name(Py_TYPE(lz)), lz->cnt); + _PyType_Name(Py_TYPE(lz)), cnt); + } if (PyLong_Check(lz->long_step)) { long step = PyLong_AsLong(lz->long_step); @@ -3705,6 +3724,7 @@ static PyType_Slot count_slots[] = { {Py_tp_iter, PyObject_SelfIter}, {Py_tp_iternext, count_next}, {Py_tp_new, itertools_count}, + {Py_tp_vectorcall, itertools_count_vectorcall}, {Py_tp_free, PyObject_GC_Del}, {0, NULL}, }; @@ -3850,14 +3870,14 @@ static PyType_Spec repeat_spec = { /* ziplongest object *********************************************************/ -typedef struct { +struct ziplongestobject { PyObject_HEAD Py_ssize_t tuplesize; Py_ssize_t numactive; PyObject *ittuple; /* tuple of iterators */ PyObject *result; PyObject *fillvalue; -} ziplongestobject; +}; #define ziplongestobject_CAST(op) ((ziplongestobject *)(op)) @@ -3953,10 +3973,16 @@ zip_longest_traverse(PyObject *op, visitproc visit, void *arg) return 0; } +/*[clinic input] +@critical_section +itertools.zip_longest.__next__ as zip_longest_next +[clinic start generated code]*/ + static PyObject * -zip_longest_next_lock_held(PyObject *op) +zip_longest_next_impl(ziplongestobject *self) +/*[clinic end generated code: output=11bc756cf896c576 input=5b1e3b52098852a9]*/ { - ziplongestobject *lz = ziplongestobject_CAST(op); + ziplongestobject *lz = self; Py_ssize_t i; Py_ssize_t tuplesize = lz->tuplesize; PyObject *result = lz->result; @@ -4025,16 +4051,6 @@ zip_longest_next_lock_held(PyObject *op) return result; } -static PyObject * -zip_longest_next(PyObject *op) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(op); - result = zip_longest_next_lock_held(op); - Py_END_CRITICAL_SECTION() - return result; -} - PyDoc_STRVAR(zip_longest_doc, "zip_longest(*iterables, fillvalue=None)\n\ --\n\ diff --git a/Modules/main.c b/Modules/main.c index ef22331760906ce..d826ed17e0293c1 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -214,6 +214,10 @@ pymain_sys_path_add_path0(PyObject *path0) return -1; } + if (PyDict_SetItemString(sysdict, "_path0", path0) < 0) { + return -1; + } + if (PyList_Insert(sys_path, 0, path0)) { return -1; } @@ -286,6 +290,7 @@ pymain_run_command(wchar_t *command) } if (PySys_Audit("cpython.run_command", "O", unicode) < 0) { + Py_DECREF(unicode); return pymain_exit_err_print(); } @@ -749,13 +754,21 @@ pymain_set_path0(PyObject *main_importer_path) static void pymain_run_python(int *exitcode) { - int set_running_main = 0; - - PyObject *main_importer_path = NULL; PyInterpreterState *interp = _PyInterpreterState_GET(); /* pymain_repl() and pymain_run_stdin() modify the config */ PyConfig *config = (PyConfig*)_PyInterpreterState_GetConfig(interp); + // Process command line options which want to exit Python + int cmdline_exitcode = _PyConfig_ProcessDeferredCmdlineOption(config); + if (cmdline_exitcode >= 0) { + *exitcode = cmdline_exitcode; + return; + } + + int set_running_main = 0; + + PyObject *main_importer_path = NULL; + /* ensure path config is written into global variables */ PyStatus status = _PyPathConfig_UpdateGlobal(config); if (_PyStatus_EXCEPTION(status)) { @@ -910,10 +923,7 @@ static int pymain_main(_PyArgv *args) { PyStatus status = pymain_init(args); - if (_PyStatus_IS_EXIT(status)) { - pymain_free(); - return status.exitcode; - } + assert(!_PyStatus_IS_EXIT(status)); if (_PyStatus_EXCEPTION(status)) { pymain_exit_error(status); } diff --git a/Modules/makesetup b/Modules/makesetup index 104c824b846540e..4b2d4fad02e10b4 100755 --- a/Modules/makesetup +++ b/Modules/makesetup @@ -4,17 +4,23 @@ set -e # Convert templates into Makefile and config.c, based on the module # definitions found in the file Setup. # -# Usage: makesetup [-s dir] [-c file] [-m file] [Setup] ... [-n [Setup] ...] +# Usage: makesetup [-s dir] [-c file] [-m file] [Setup] ... [-b Setup] ... +# [-n [Setup] ...] # # Options: # -s directory: alternative source directory (default .) # -l directory: library source directory (default derived from $0) # -c file: alternative config.c template (default $libdir/config.c.in) -# -c -: don't write config.c +# -c -: don't write config.c (nor config_bootstrap.c) # -m file: alternative Makefile template (default ./Makefile.pre) # -m -: don't write Makefile # # Remaining arguments are one or more Setup files (default ./Setup). +# The Setup file following a -b option holds the *bootstrap* modules: +# the static modules that the build helper programs (_freeze_module, +# _bootstrap_python) are linked with. They are also regular modules of +# the final build. A *bootstrap* line in a Setup file does the same for +# the rest of that file. # Setup files after a -n option are used for their variables, modules # and libraries but not for their .o files. # @@ -28,6 +34,9 @@ set -e # + insert 'extern PyObject* PyInit_(void);' before MARKER 1 # + insert '{"", PyInit_},' before MARKER 2 # +# Copying config.c.in to config_bootstrap.c (only with a -b Setup file): +# - same as config.c, but only for the modules of the -b Setup file +# # Copying Makefile.pre to Makefile: # - insert an identifying comment at the start # - replace _MODBUILT_NAMES_ by the list of *static* and *shared* modules @@ -37,6 +46,8 @@ set -e # - replace _MODOBJS_ by the list of objects from Setup (except for # Setup files after a -n option) # - replace _MODLIBS_ by the list of libraries from Setup +# - replace _BOOTSTRAP_MODOBJS_ and _BOOTSTRAP_MODLIBS_ by the objects and +# libraries of the -b Setup file # - for each object file mentioned in Setup, append a rule # '.o: .c; ' to the end of the Makefile # - for each module mentioned in Setup, append a rule @@ -47,13 +58,14 @@ set -e # Loop over command line options usage=' usage: makesetup [-s srcdir] [-l libdir] [-c config.c.in] [-m Makefile.pre] - [Setup] ... [-n [Setup] ...]' + [Setup] ... [-b Setup] ... [-n [Setup] ...]' srcdir='.' libdir='' config='' makepre='' noobjects='' doconfig=yes +bootstrap= while : do case $1 in @@ -93,7 +105,8 @@ do echo '' # Add a linebreak so we don't choke on files missing EOL. case $i in -n) echo '*noobjects*';; - *) echo '*doconfig*'; cat "$i";; + -b) echo '*bootstrap*';; + *) echo '*doconfig*'; cat "$i"; echo ''; echo '*nobootstrap*';; esac done | sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | @@ -114,6 +127,10 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | LIBS= LOCALLIBS= BASELIBS= + BOOTMODS= + BOOTOBJS= + BOOTLIBS= + havebootstrap= while read line do # to handle backslashes for sh's that don't automatically @@ -136,6 +153,8 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | noobjects=yes; continue;; '*doconfig*') doconfig=yes; continue;; + '*bootstrap*') bootstrap=yes; havebootstrap=yes; continue;; + '*nobootstrap*') bootstrap=; continue;; '*static*') doconfig=yes; continue;; '*noconfig*') doconfig=no; continue;; '*shared*') doconfig=no; continue;; @@ -204,6 +223,18 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | # Detected multiple rules for a module, first rule wins. This # allows users to disable modules in Setup.local. echo 1>&2 "maksetup: '$mod' was handled by previous rule." + case $bootstrap in + yes) + # This module is in the bootstrap Setup file, but an + # earlier Setup file (e.g. Setup.local) already defined + # it, and that definition won. Give the build helpers + # that earlier definition, so they use the same module + # as the final interpreter. + eval "BOOTMODS=\"\$BOOTMODS \${STATICMOD_$mod}\"" + eval "BOOTOBJS=\"\$BOOTOBJS \${STATICOBJS_$mod}\"" + eval "BOOTLIBS=\"\$BOOTLIBS \${STATICLIBS_$mod}\"" + ;; + esac continue 2;; esac CONFIGURED="$CONFIGURED,${mod}," @@ -213,6 +244,12 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | LIBS="$LIBS $libs" MODS="$MODS $mods" BUILT="$BUILT $mods" + case $bootstrap in + yes) + BOOTLIBS="$BOOTLIBS $libs" + BOOTMODS="$BOOTMODS $mods" + ;; + esac ;; no) BUILT="$BUILT $mods" @@ -265,7 +302,21 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | echo "$rule" >>$rulesf done case $doconfig in - yes) OBJS="$OBJS $objs";; + yes) + OBJS="$OBJS $objs" + case $bootstrap in + yes) BOOTOBJS="$BOOTOBJS $objs";; + esac + # Record each static module's objects and libs by name, so + # the bootstrap handling above can find a definition that + # won over a later line in the bootstrap Setup file. + for mod in $mods + do + eval "STATICMOD_$mod='$mod'" + eval "STATICOBJS_$mod='$objs'" + eval "STATICLIBS_$mod='$libs'" + done + ;; esac for mod in $mods do @@ -277,7 +328,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | ;; esac rule="$file: $objs \$(MODULE_${mods_upper}_LDEPS)" - rule="$rule; \$(BLDSHARED) $objs $libs \$(LIBPYTHON) -o $file" + rule="$rule; \$(BLDSHARED) $objs $libs \$(MODULE_LDFLAGS_SHARED) -o $file" echo "$rule" >>$rulesf done done @@ -295,24 +346,31 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | DEFS="BASEMODLIBS=$BASELIBS$NL$DEFS" DEFS="LOCALMODLIBS=$LOCALLIBS$NL$DEFS" - EXTDECLS= - INITBITS= - for mod in $MODS - do - EXTDECLS="${EXTDECLS}extern PyObject* PyInit_$mod(void);$NL" - INITBITS="${INITBITS} {\"$mod\", PyInit_$mod},$NL" - done - - - case $config in - -) ;; - *) sed -e " + # Generate a config.c from the template for the given modules + genconfig() { + out=$1; shift + EXTDECLS= + INITBITS= + for mod + do + EXTDECLS="${EXTDECLS}extern PyObject* PyInit_$mod(void);$NL" + INITBITS="${INITBITS} {\"$mod\", PyInit_$mod},$NL" + done + sed -e " 1i$NL/* Generated automatically from $config by makesetup. */ /MARKER 1/i$NL$EXTDECLS /MARKER 2/i$NL$INITBITS - " $config >config.c + " $config >$out + } + + case $config in + -) ;; + *) genconfig config.c $MODS + case $havebootstrap in + yes) genconfig config_bootstrap.c $BOOTMODS;; + esac ;; esac @@ -331,6 +389,9 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | echo "s%_MODBUILT_NAMES_%$BUILT%" >>$sedf echo "s%_MODSHARED_NAMES_%$BUILT_SHARED%" >>$sedf echo "s%_MODDISABLED_NAMES_%$DISABLED%" >>$sedf + # _BOOTSTRAP_* first: _MODOBJS_ is a substring of _BOOTSTRAP_MODOBJS_ + echo "s%_BOOTSTRAP_MODOBJS_%$BOOTOBJS%" >>$sedf + echo "s%_BOOTSTRAP_MODLIBS_%$BOOTLIBS%" >>$sedf echo "s%_MODOBJS_%$OBJS%" >>$sedf echo "s%_MODLIBS_%$LIBS%" >>$sedf echo "/Definitions added by makesetup/r $sedr" >>$sedf diff --git a/Modules/mathintegermodule.c b/Modules/mathintegermodule.c index 0f660d461e349f8..6d35c825349e451 100644 --- a/Modules/mathintegermodule.c +++ b/Modules/mathintegermodule.c @@ -180,10 +180,9 @@ that the bound `(a - 1)**2 < (n >> s) < (a + 1)**2` is maintained from one iteration to the next. A sketch of the proof of this is given below. In addition to the proof sketch, a formal, computer-verified proof -of correctness (using Lean) of an equivalent recursive algorithm can be found -here: +of correctness (using Lean) of the algorithm can be found here: - https://github.com/mdickinson/snippets/blob/master/proofs/isqrt/src/isqrt.lean + https://github.com/mdickinson/snippets/tree/41ce2d256fef06fb32f24fe7014cfa95173ac5e0/proofs/isqrt Here's Python code equivalent to the C implementation below: diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 64e5372d73d2f29..dd2ac90cf5c7cbb 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -212,7 +212,7 @@ static const double logpi = 1.144729885849400174143427351353058711647; } \ } -#ifndef HAVE_ACOSPI +#ifndef _Py_HAVE_ACOSPI /* acos(x)/pi. It conforms to C23 Annex 'F'. */ @@ -220,6 +220,12 @@ static const double logpi = 1.144729885849400174143427351353058711647; static double m_acospi(double x) { + if (x >= 0.5) { + /* acos(x) = 2*asin(sqrt((1 - x)/2)). 1 - x is exact here. + Some libms (old fdlibm derivatives) lose precision in acos(x) + near x = 1, while asin() is accurate for small arguments. */ + return 2.0*asin(sqrt((1.0 - x)/2.0))/pi; + } double r = acos(x)/pi; if (isgreater(r, 1.0)) { return 1.0; @@ -230,7 +236,7 @@ m_acospi(double x) #define m_acospi acospi #endif -#ifndef HAVE_ASINPI +#ifndef _Py_HAVE_ASINPI /* asin(x)/pi. It conforms to C23 Annex 'F'. */ @@ -248,9 +254,9 @@ m_asinpi(double x) #define m_asinpi asinpi #endif -#ifndef HAVE_ATANPI +#ifndef _Py_HAVE_ATANPI /* - asin(x)/pi. It conforms to C23 Annex 'F'. + atan(x)/pi. It conforms to C23 Annex 'F'. */ static double @@ -266,9 +272,9 @@ m_atanpi(double x) #define m_atanpi atanpi #endif -#ifndef HAVE_ATAN2PI +#ifndef _Py_HAVE_ATAN2PI /* - asin(x)/pi. It conforms to C23 Annex 'F'. + atan2(y, x)/pi. It conforms to C23 Annex 'F'. */ static double @@ -284,7 +290,7 @@ m_atan2pi(double y, double x) #define m_atan2pi atan2pi #endif -#ifndef HAVE_COSPI +#ifndef _Py_HAVE_COSPI /* cos(pi*x), giving accurate results for all finite x (especially x integral or close to an integer). It conforms to C23 Annex 'F'. @@ -312,7 +318,7 @@ m_cospi(double x) #define m_cospi cospi #endif -#ifndef HAVE_SINPI +#ifndef _Py_HAVE_SINPI /* sin(pi*x), giving accurate results for all finite x (especially x integral or close to an integer). It conforms to C23 Annex 'F'. @@ -356,7 +362,7 @@ m_sinpi(double x) #define m_sinpi sinpi #endif -#ifndef HAVE_TANPI +#ifndef _Py_HAVE_TANPI /* tan(pi*x), giving accurate results for all finite x (especially x integral or close to an integer). It conforms to C23 Annex 'F'. @@ -1011,7 +1017,7 @@ math_1a(PyObject *arg, double (*func) (double), const char *err_msg) The last rule is used to catch overflow on platforms which follow C89 but for which HUGE_VAL is not an infinity. - For most two-argument functions (copysign, fmod, hypot, atan2) + For most two-argument functions (fmod, hypot) these rules are enough to ensure that Python's functions behave as specified in 'Annex F' of the C99 standard, with the 'invalid' and 'divide-by-zero' floating-point exceptions mapping to Python's @@ -1024,8 +1030,9 @@ math_2(PyObject *const *args, Py_ssize_t nargs, double (*func) (double, double), const char *funcname) { double x, y, r; - if (!_PyArg_CheckPositional(funcname, nargs, 2, 2)) + if (!_PyArg_CheckPositional(funcname, nargs, 2, 2)) { return NULL; + } x = PyFloat_AsDouble(args[0]); if (x == -1.0 && PyErr_Occurred()) { return NULL; @@ -1054,6 +1061,29 @@ math_2(PyObject *const *args, Py_ssize_t nargs, return PyFloat_FromDouble(r); } +/* variant of math_2, to be used when the function being wrapped is known NOT + to need error checking (i.e., no overflow, invalid, or divide-by-zero). */ + +static PyObject * +math_2ne(PyObject *const *args, Py_ssize_t nargs, + double (*func) (double, double), const char *funcname) +{ + double x, y, r; + if (!_PyArg_CheckPositional(funcname, nargs, 2, 2)) { + return NULL; + } + x = PyFloat_AsDouble(args[0]); + if (x == -1.0 && PyErr_Occurred()) { + return NULL; + } + y = PyFloat_AsDouble(args[1]); + if (y == -1.0 && PyErr_Occurred()) { + return NULL; + } + r = (*func)(x, y); // Ignore errno on purpose. + return PyFloat_FromDouble(r); +} + #define FUNC1(funcname, func, can_overflow, docstring) \ static PyObject * math_##funcname(PyObject *self, PyObject *args) { \ return math_1(args, func, can_overflow, NULL); \ @@ -1084,6 +1114,12 @@ math_2(PyObject *const *args, Py_ssize_t nargs, }\ PyDoc_STRVAR(math_##funcname##_doc, docstring); +#define FUNC2NE(funcname, func, docstring) \ + static PyObject * math_##funcname(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { \ + return math_2ne(args, nargs, func, #funcname); \ + }\ + PyDoc_STRVAR(math_##funcname##_doc, docstring); + FUNC1D(acos, acos, 0, "acos($module, x, /)\n--\n\n" "Return the arc cosine (measured in radians) of x.\n\n" @@ -1115,11 +1151,14 @@ FUNC1(atan, atan, 0, "atan($module, x, /)\n--\n\n" "Return the arc tangent (measured in radians) of x.\n\n" "The result is between -pi/2 and pi/2.") -FUNC2(atan2, atan2, +/* gh-153144: Ignore atan2 and atan2pi errno on purpose since it can optionally + * be EDOM, which we should ignore, or ERANGE on underflow, which is + * silent on Python. Overflow is not possible. */ +FUNC2NE(atan2, atan2, "atan2($module, y, x, /)\n--\n\n" "Return the arc tangent (measured in radians) of y/x.\n\n" "Unlike atan(y/x), the signs of both x and y are considered.") -FUNC2(atan2pi, m_atan2pi, +FUNC2NE(atan2pi, m_atan2pi, "atan2pi($module, y, x, /)\n--\n\n" "Return the arc tangent (measured in half-turns) of y/x.\n\n" "Unlike atanpi(y/x), the signs of both x and y are considered.") @@ -1130,7 +1169,7 @@ FUNC1D(atanh, atanh, 0, FUNC1D(atanpi, m_atanpi, 0, "atanpi($module, x, /)\n--\n\n" "Return the arc tangent (measured in half-turns) of x.\n\n" - "The result is between 0 and 1.", + "The result is between -1/2 and 1/2.", "expected a number in range from -1 up to 1, got %s") FUNC1(cbrt, cbrt, 0, "cbrt($module, x, /)\n--\n\n" @@ -1172,7 +1211,9 @@ math_ceil(PyObject *module, PyObject *number) return PyLong_FromDouble(ceil(x)); } -FUNC2(copysign, copysign, +/* gh-153144: Ignore copysign errno on purpose since IEEE Std 754-2019 requires + * it to operate on bit strings and to signal no exception. */ +FUNC2NE(copysign, copysign, "copysign($module, x, y, /)\n--\n\n" "Return a float with the magnitude (absolute value) of x but the sign of y.\n\n" "On platforms that support signed zeros, copysign(1.0, -0.0)\n" @@ -1337,10 +1378,10 @@ FUNC1D(tan, tan, 0, FUNC1(tanh, tanh, 0, "tanh($module, x, /)\n--\n\n" "Return the hyperbolic tangent of x.") -FUNC1D(tanpi, m_tanpi, 1, +FUNC1D(tanpi, m_tanpi, 0, "tanpi($module, x, /)\n--\n\n" "Return the tangent of x (measured in half-turns).", - "expected a finite input, got %s") + "expected a finite input not equal to a half-integer, got %s") /* Precision summation function as msum() by Raymond Hettinger in , @@ -2688,7 +2729,7 @@ static PyObject * math_issubnormal_impl(PyObject *module, double x) /*[clinic end generated code: output=4e76ac98ddcae761 input=9a20aba7107d0d95]*/ { -#if !defined(_MSC_VER) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +#if !defined(_MSC_VER) && defined(_Py_STDC_VERSION) && _Py_STDC_VERSION >= 202311L return PyBool_FromLong(issubnormal(x)); #else return PyBool_FromLong(isfinite(x) && x && !isnormal(x)); diff --git a/Modules/md5module.c b/Modules/md5module.c index 063be1405dd51f4..537fbc096b31129 100644 --- a/Modules/md5module.c +++ b/Modules/md5module.c @@ -77,6 +77,7 @@ newMD5object(MD5State * st) return NULL; } HASHLIB_INIT_MUTEX(md5); + md5->hash_state = NULL; // PyObject_GC_New() does not zero memory PyObject_GC_Track(md5); return md5; @@ -86,13 +87,13 @@ newMD5object(MD5State * st) static void MD5_dealloc(PyObject *op) { + PyTypeObject *tp = Py_TYPE(op); + PyObject_GC_UnTrack(op); MD5object *ptr = _MD5object_CAST(op); if (ptr->hash_state != NULL) { Hacl_Hash_MD5_free(ptr->hash_state); ptr->hash_state = NULL; } - PyTypeObject *tp = Py_TYPE(op); - PyObject_GC_UnTrack(ptr); PyObject_GC_Del(ptr); Py_DECREF(tp); } diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index d55ab3d4d56edb0..06099a3b8b2e0be 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -969,10 +969,13 @@ mmap_mmap_resize_impl(mmap_object *self, Py_ssize_t new_size) #ifdef UNIX void *newmap; -#ifdef __linux__ +#if defined(__linux__) || defined(__NetBSD__) + // Linux mremap() refuses to grow a shared anonymous mapping, and + // NetBSD mremap() returns a mapping whose grown region is not backed, + // so accessing it crashes. Reject it here in both cases. if (self->fd == -1 && !(self->flags & MAP_PRIVATE) && new_size > self->size) { PyErr_Format(PyExc_ValueError, - "mmap: can't expand a shared anonymous mapping on Linux"); + "mmap: can't expand a shared anonymous mapping"); return NULL; } #endif @@ -1253,8 +1256,16 @@ mmap_mmap___exit___impl(mmap_object *self, PyObject *exc_type, return mmap_mmap_close_impl(self); } +/*[clinic input] +@critical_section +mmap.mmap.__repr__ as mmap__repr__method + + op: self(type="PyObject *") +[clinic start generated code]*/ + static PyObject * -mmap__repr__method_lock_held(PyObject *op) +mmap__repr__method_impl(PyObject *op) +/*[clinic end generated code: output=c896c8c4cd07228c input=a030361fbcfe851a]*/ { mmap_object *mobj = mmap_object_CAST(op); @@ -1298,16 +1309,6 @@ mmap__repr__method_lock_held(PyObject *op) } } -static PyObject * -mmap__repr__method(PyObject *op) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(op); - result = mmap__repr__method_lock_held(op); - Py_END_CRITICAL_SECTION(); - return result; -} - #ifdef MS_WINDOWS /*[clinic input] @critical_section @@ -1484,28 +1485,30 @@ mmap_buffer_releasebuf(PyObject *op, Py_buffer *Py_UNUSED(view)) Py_END_CRITICAL_SECTION(); } +/*[clinic input] +@critical_section +mmap.mmap.__len__ as mmap_length +[clinic start generated code]*/ + static Py_ssize_t -mmap_length_lock_held(PyObject *op) +mmap_length_impl(mmap_object *self) +/*[clinic end generated code: output=a63e62615cdd9960 input=b7bbf695dc9b2b66]*/ { - mmap_object *self = mmap_object_CAST(op); CHECK_VALID(-1); return self->size; } -static Py_ssize_t -mmap_length(PyObject *op) -{ - Py_ssize_t result; - Py_BEGIN_CRITICAL_SECTION(op); - result = mmap_length_lock_held(op); - Py_END_CRITICAL_SECTION(); - return result; -} +/*[clinic input] +@critical_section +mmap.mmap.__getitem__ as mmap_item + i: Py_ssize_t + / +[clinic start generated code]*/ static PyObject * -mmap_item_lock_held(PyObject *op, Py_ssize_t i) +mmap_item_impl(mmap_object *self, Py_ssize_t i) +/*[clinic end generated code: output=70bd231b581a7bc1 input=af6ad504b5fcd499]*/ { - mmap_object *self = mmap_object_CAST(op); CHECK_VALID(NULL); if (i < 0 || i >= self->size) { PyErr_SetString(PyExc_IndexError, "mmap index out of range"); @@ -1519,19 +1522,17 @@ mmap_item_lock_held(PyObject *op, Py_ssize_t i) return PyBytes_FromStringAndSize(&dest, 1); } -static PyObject * -mmap_item(PyObject *op, Py_ssize_t i) { - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(op); - result = mmap_item_lock_held(op, i); - Py_END_CRITICAL_SECTION(); - return result; -} +/*[clinic input] +@critical_section +mmap.mmap.__getitem__ as mmap_subscript + item: object + / +[clinic start generated code]*/ static PyObject * -mmap_subscript_lock_held(PyObject *op, PyObject *item) +mmap_subscript_impl(mmap_object *self, PyObject *item) +/*[clinic end generated code: output=cd6ccc1eb3399f98 input=72f708669823dbba]*/ { - mmap_object *self = mmap_object_CAST(op); CHECK_VALID(NULL); if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); @@ -1566,22 +1567,16 @@ mmap_subscript_lock_held(PyObject *op, PyObject *item) else if (step == 1) return _safe_PyBytes_FromStringAndSize(self->data + start, slicelen); else { - char *result_buf = (char *)PyMem_Malloc(slicelen); - PyObject *result; - - if (result_buf == NULL) - return PyErr_NoMemory(); - - if (safe_copy_to_slice(result_buf, self->data, start, step, - slicelen) < 0) - { - result = NULL; + PyBytesWriter *writer = PyBytesWriter_Create(slicelen); + if (writer == NULL) { + return NULL; } - else { - result = PyBytes_FromStringAndSize(result_buf, slicelen); + if (safe_copy_to_slice(PyBytesWriter_GetData(writer), self->data, + start, step, slicelen) < 0) { + PyBytesWriter_Discard(writer); + return NULL; } - PyMem_Free(result_buf); - return result; + return PyBytesWriter_Finish(writer); } } else { @@ -1591,21 +1586,20 @@ mmap_subscript_lock_held(PyObject *op, PyObject *item) } } -static PyObject * -mmap_subscript(PyObject *op, PyObject *item) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(op); - result = mmap_subscript_lock_held(op, item); - Py_END_CRITICAL_SECTION(); - return result; -} +/*[clinic input] +@critical_section +mmap.mmap.__setitem__ as mmap_ass_item + + i: Py_ssize_t + v: object + / +[clinic start generated code]*/ static int -mmap_ass_item_lock_held(PyObject *op, Py_ssize_t i, PyObject *v) +mmap_ass_item_impl(mmap_object *self, Py_ssize_t i, PyObject *v) +/*[clinic end generated code: output=398d9d502e560f58 input=5fe8a60de3a6c39e]*/ { const char *buf; - mmap_object *self = mmap_object_CAST(op); CHECK_VALID(-1); if (i < 0 || i >= self->size) { @@ -1632,38 +1626,27 @@ mmap_ass_item_lock_held(PyObject *op, Py_ssize_t i, PyObject *v) return 0; } -static int -mmap_ass_item(PyObject *op, Py_ssize_t i, PyObject *v) -{ - int result; - Py_BEGIN_CRITICAL_SECTION(op); - result = mmap_ass_item_lock_held(op, i, v); - Py_END_CRITICAL_SECTION(); - return result; -} +/*[clinic input] +@critical_section +mmap.mmap.__setitem__ as mmap_ass_subscript + + item: object + value: object + / +[clinic start generated code]*/ static int -mmap_ass_subscript_lock_held(PyObject *op, PyObject *item, PyObject *value) +mmap_ass_subscript_impl(mmap_object *self, PyObject *item, PyObject *value) +/*[clinic end generated code: output=e346a1c7f35800d4 input=4827c15e710601f0]*/ { - mmap_object *self = mmap_object_CAST(op); - CHECK_VALID(-1); - if (!is_writable(self)) return -1; if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); - Py_ssize_t v; - if (i == -1 && PyErr_Occurred()) return -1; - if (i < 0) - i += self->size; - if (i < 0 || i >= self->size) { - PyErr_SetString(PyExc_IndexError, - "mmap index out of range"); - return -1; - } + if (value == NULL) { PyErr_SetString(PyExc_TypeError, "mmap doesn't support item deletion"); @@ -1674,7 +1657,7 @@ mmap_ass_subscript_lock_held(PyObject *op, PyObject *item, PyObject *value) "mmap item value must be an int"); return -1; } - v = PyNumber_AsSsize_t(value, PyExc_TypeError); + Py_ssize_t v = PyNumber_AsSsize_t(value, PyExc_TypeError); if (v == -1 && PyErr_Occurred()) return -1; if (v < 0 || v > 255) { @@ -1683,7 +1666,18 @@ mmap_ass_subscript_lock_held(PyObject *op, PyObject *item, PyObject *value) "in range(0, 256)"); return -1; } + + /* Converting item or value above may have run arbitrary code + * (e.g. __index__) that resized or closed the mmap, so bounds + * are only checked now, against the current size. */ CHECK_VALID(-1); + if (i < 0) + i += self->size; + if (i < 0 || i >= self->size) { + PyErr_SetString(PyExc_IndexError, + "mmap index out of range"); + return -1; + } char v_char = (char) v; if (safe_byte_copy(self->data + i, &v_char) < 0) { @@ -1698,7 +1692,6 @@ mmap_ass_subscript_lock_held(PyObject *op, PyObject *item, PyObject *value) if (PySlice_Unpack(item, &start, &stop, &step) < 0) { return -1; } - slicelen = PySlice_AdjustIndices(self->size, &start, &stop, step); if (value == NULL) { PyErr_SetString(PyExc_TypeError, "mmap object doesn't support slice deletion"); @@ -1706,6 +1699,12 @@ mmap_ass_subscript_lock_held(PyObject *op, PyObject *item, PyObject *value) } if (PyObject_GetBuffer(value, &vbuf, PyBUF_SIMPLE) < 0) return -1; + + /* Acquiring the buffer above may have run arbitrary code (e.g. a + * __buffer__ method) that resized or closed this mmap, so the slice bounds + * are only computed now, against the current size. */ + CHECK_VALID_OR_RELEASE(-1, vbuf); + slicelen = PySlice_AdjustIndices(self->size, &start, &stop, step); if (vbuf.len != slicelen) { PyErr_SetString(PyExc_IndexError, "mmap slice assignment is wrong size"); @@ -1713,7 +1712,6 @@ mmap_ass_subscript_lock_held(PyObject *op, PyObject *item, PyObject *value) return -1; } - CHECK_VALID_OR_RELEASE(-1, vbuf); int result = 0; if (slicelen == 0) { } @@ -1739,16 +1737,6 @@ mmap_ass_subscript_lock_held(PyObject *op, PyObject *item, PyObject *value) } } -static int -mmap_ass_subscript(PyObject *op, PyObject *item, PyObject *value) -{ - int result; - Py_BEGIN_CRITICAL_SECTION(op); - result = mmap_ass_subscript_lock_held(op, item, value); - Py_END_CRITICAL_SECTION(); - return result; -} - static PyObject * new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict); @@ -2081,9 +2069,6 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) fh = _Py_get_osfhandle(fileno); if (fh == INVALID_HANDLE_VALUE) return NULL; - - /* Win9x appears to need us seeked to zero */ - lseek(fileno, 0, SEEK_SET); } m_obj = (mmap_object *)type->tp_alloc(type, 0); diff --git a/Modules/overlapped.c b/Modules/overlapped.c index 255576cc057cdd4..f8b654594ebfc66 100644 --- a/Modules/overlapped.c +++ b/Modules/overlapped.c @@ -35,6 +35,10 @@ #define T_HANDLE T_POINTER +#ifndef HasOverlappedIoCompleted +#define HasOverlappedIoCompleted(lpOverlapped) (lpOverlapped)->Internal != STATUS_PENDING +#endif + /*[python input] class pointer_converter(CConverter): format_unit = '"F_POINTER"' @@ -51,9 +55,6 @@ class pointer_converter(CConverter): class OVERLAPPED_converter(pointer_converter): type = 'OVERLAPPED *' -class HANDLE_converter(pointer_converter): - type = 'HANDLE' - class ULONG_PTR_converter(pointer_converter): type = 'ULONG_PTR' @@ -66,13 +67,8 @@ class ULONG_PTR_converter(pointer_converter): """, argname=argname) -class DWORD_converter(unsigned_long_converter): - type = 'DWORD' - -class BOOL_converter(int_converter): - type = 'BOOL' [python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=436f4440630a304c]*/ +/*[python end generated code: output=da39a3ee5e6b4b0d input=e3b1c126cba99725]*/ /*[clinic input] module _overlapped @@ -359,6 +355,9 @@ _overlapped_RegisterWaitWithQueue_impl(PyObject *module, HANDLE Object, DWORD Milliseconds) /*[clinic end generated code: output=c2ace732e447fe45 input=2dd4efee44abe8ee]*/ { +#ifndef MS_WINDOWS_DESKTOP + return NULL; +#else HANDLE NewWaitObject; struct PostCallbackData data = {CompletionPort, Overlapped}, *pdata; @@ -381,6 +380,7 @@ _overlapped_RegisterWaitWithQueue_impl(PyObject *module, HANDLE Object, } return Py_BuildValue(F_HANDLE, NewWaitObject); +#endif } /*[clinic input] @@ -396,6 +396,9 @@ static PyObject * _overlapped_UnregisterWait_impl(PyObject *module, HANDLE WaitHandle) /*[clinic end generated code: output=ec90cd955a9a617d input=a56709544cb2df0f]*/ { +#ifndef MS_WINDOWS_DESKTOP + Py_RETURN_NONE; +#else BOOL ret; Py_BEGIN_ALLOW_THREADS @@ -405,6 +408,7 @@ _overlapped_UnregisterWait_impl(PyObject *module, HANDLE WaitHandle) if (!ret) return SetFromWindowsErr(0); Py_RETURN_NONE; +#endif } /*[clinic input] @@ -422,6 +426,9 @@ _overlapped_UnregisterWaitEx_impl(PyObject *module, HANDLE WaitHandle, HANDLE Event) /*[clinic end generated code: output=2e3d84c1d5f65b92 input=953cddc1de50fab9]*/ { +#ifndef MS_WINDOWS_DESKTOP + Py_RETURN_NONE; +#else BOOL ret; Py_BEGIN_ALLOW_THREADS @@ -431,6 +438,7 @@ _overlapped_UnregisterWaitEx_impl(PyObject *module, HANDLE WaitHandle, if (!ret) return SetFromWindowsErr(0); Py_RETURN_NONE; +#endif } /* diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 36debd6fe7aa153..619154309b40e31 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -21,6 +21,7 @@ #include "pycore_import.h" // _PyImport_AcquireLock() #include "pycore_initconfig.h" // _PyStatus_EXCEPTION() #include "pycore_jit_unwind.h" // _Py_jit_debug_mutex +#include "pycore_lock.h" // PyMutex_LockFast() #include "pycore_long.h" // _PyLong_IsNegative() #include "pycore_moduleobject.h" // _PyModule_GetState() #include "pycore_object.h" // _PyObject_LookupSpecial() @@ -30,6 +31,7 @@ #include "pycore_time.h" // _PyLong_FromTime_t() #include "pycore_tuple.h" // _PyTuple_FromPairSteal #include "pycore_typeobject.h" // _PyType_AddMethod() +#include "pycore_warnings.h" // _PyWarnings_AfterFork() #ifndef MS_WINDOWS # include "posixmodule.h" // _PyLong_FromUid() @@ -68,6 +70,10 @@ # include "emscripten.h" // emscripten_debugger() #endif +#ifdef HAVE_SYS_RANDOM_H +# include // getrandom() +#endif + #ifdef HAVE_SYS_UIO_H # include #endif @@ -153,8 +159,11 @@ #ifdef HAVE_LINUX_RANDOM_H # include // GRND_RANDOM #endif -#ifdef HAVE_GETRANDOM_SYSCALL -# include // syscall() +#ifdef HAVE_SYS_SYSCALL_H +# include // syscall(), __NR_xxx syscall numbers +#endif +#if !defined(SYS_getrandom) && defined(__NR_getrandom) +# define SYS_getrandom __NR_getrandom #endif #ifdef HAVE_POSIX_SPAWN @@ -302,13 +311,6 @@ #endif -#if !defined(_MSC_VER) && defined(__sgi) && _COMPILER_VERSION>=700 -/* declare ctermid_r if compiling with MIPSPro 7.x in ANSI C mode - (default) */ -extern char *ctermid_r(char *); -#endif - - #if defined(__VXWORKS__) # include # include @@ -497,6 +499,7 @@ static const unsigned int _Py_STATX_KNOWN = (STATX_BASIC_STATS | STATX_BTIME # define HAVE_UNLINKAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *) # define HAVE_OPENAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *) # define HAVE_READLINKAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *) +# define HAVE_FREADLINK_RUNTIME __builtin_available(macOS 13.0, iOS 16.0, *) # define HAVE_SYMLINKAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *) # define HAVE_FUTIMENS_RUNTIME __builtin_available(macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4.0, *) # define HAVE_UTIMENSAT_RUNTIME __builtin_available(macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4.0, *) @@ -504,6 +507,8 @@ static const unsigned int _Py_STATX_KNOWN = (STATX_BASIC_STATS | STATX_BTIME # define HAVE_MKFIFOAT_RUNTIME __builtin_available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *) # define HAVE_MKNODAT_RUNTIME __builtin_available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *) # define HAVE_PTSNAME_R_RUNTIME __builtin_available(macOS 10.13.4, iOS 11.3, tvOS 11.3, watchOS 4.3, *) +# define HAVE_DUP3_RUNTIME __builtin_available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, visionOS 27.0, *) +# define HAVE_PIPE2_RUNTIME __builtin_available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, visionOS 27.0, *) # define HAVE_POSIX_SPAWN_SETSID_RUNTIME __builtin_available(macOS 10.15, *) @@ -561,6 +566,10 @@ static const unsigned int _Py_STATX_KNOWN = (STATX_BASIC_STATS | STATX_BTIME # define HAVE_READLINKAT_RUNTIME (readlinkat != NULL) # endif +# ifdef _Py_HAVE_FREADLINK +# define HAVE_FREADLINK_RUNTIME (freadlink != NULL) +# endif + # ifdef HAVE_SYMLINKAT # define HAVE_SYMLINKAT_RUNTIME (symlinkat != NULL) # endif @@ -589,6 +598,14 @@ static const unsigned int _Py_STATX_KNOWN = (STATX_BASIC_STATS | STATX_BTIME # define HAVE_PTSNAME_R_RUNTIME (ptsname_r != NULL) # endif +# ifdef HAVE_DUP3 +# define HAVE_DUP3_RUNTIME (dup3 != NULL) +# endif + +# ifdef HAVE_PIPE2 +# define HAVE_PIPE2_RUNTIME (pipe2 != NULL) +# endif + #endif #ifdef HAVE_FUTIMESAT @@ -619,6 +636,9 @@ static const unsigned int _Py_STATX_KNOWN = (STATX_BASIC_STATS | STATX_BTIME # define HAVE_MKFIFOAT_RUNTIME 1 # define HAVE_MKNODAT_RUNTIME 1 # define HAVE_PTSNAME_R_RUNTIME 1 +# define HAVE_DUP3_RUNTIME 1 +# define HAVE_PIPE2_RUNTIME 1 +# define HAVE_FREADLINK_RUNTIME 1 #endif @@ -696,6 +716,7 @@ PyOS_BeforeFork(void) _PyImport_AcquireLock(interp); _PyEval_StopTheWorldAll(&_PyRuntime); HEAD_LOCK(&_PyRuntime); + _PyWarnings_BeforeFork(interp); } void @@ -766,6 +787,9 @@ PyOS_AfterFork_Child(void) _Py_jit_debug_mutex = (PyMutex){0}; #endif + // Thread-state cleanup can run finalizers that issue warnings. + _PyWarnings_AfterFork(tstate->interp); + reset_remotedebug_data(tstate); reset_asyncio_state((_PyThreadStateImpl *)tstate); @@ -829,9 +853,9 @@ PyOS_AfterFork(void) #ifdef MS_WINDOWS /* defined in fileutils.c */ void _Py_time_t_to_FILE_TIME(time_t, int, FILETIME *); -void _Py_attribute_data_to_stat(BY_HANDLE_FILE_INFORMATION *, ULONG, - FILE_BASIC_INFO *, FILE_ID_INFO *, - struct _Py_stat_struct *); +void _Py_attribute_data_to_stat(FILE_STANDARD_INFO*, ULONG, + FILE_BASIC_INFO*, FILE_ID_INFO*, + struct _Py_stat_struct*); void _Py_stat_basic_info_to_stat(FILE_STAT_BASIC_INFORMATION *, struct _Py_stat_struct *); #endif @@ -1685,25 +1709,6 @@ idtype_t_converter(PyObject *arg, void *addr) } #endif -#ifdef MS_WINDOWS - typedef long long Py_off_t; -#else - typedef off_t Py_off_t; -#endif - -static int -Py_off_t_converter(PyObject *arg, void *addr) -{ -#ifdef HAVE_LARGEFILE_SUPPORT - *((Py_off_t *)addr) = PyLong_AsLongLong(arg); -#else - *((Py_off_t *)addr) = PyLong_AsLong(arg); -#endif - if (PyErr_Occurred()) - return 0; - return 1; -} - static PyObject * PyLong_FromPy_off_t(Py_off_t offset) { @@ -2023,19 +2028,33 @@ win32_wchdir(LPCWSTR path) #define HAVE_STRUCT_STAT_ST_FILE_ATTRIBUTES 1 #define HAVE_STRUCT_STAT_ST_REPARSE_TAG 1 +/* The \\?\ prefix disables the path normalization, in particular + stripping of trailing dots and spaces. */ +static int +is_extended_path(const wchar_t *path) +{ + return wcsncmp(path, L"\\\\?\\", 4) == 0; +} + static void find_data_to_file_info(WIN32_FIND_DATAW *pFileData, - BY_HANDLE_FILE_INFORMATION *info, + FILE_BASIC_INFO* basic_info, + FILE_STANDARD_INFO* standard_info, ULONG *reparse_tag) { - memset(info, 0, sizeof(*info)); - info->dwFileAttributes = pFileData->dwFileAttributes; - info->ftCreationTime = pFileData->ftCreationTime; - info->ftLastAccessTime = pFileData->ftLastAccessTime; - info->ftLastWriteTime = pFileData->ftLastWriteTime; - info->nFileSizeHigh = pFileData->nFileSizeHigh; - info->nFileSizeLow = pFileData->nFileSizeLow; -/* info->nNumberOfLinks = 1; */ + memset(basic_info, 0, sizeof(*basic_info)); + memset(standard_info, 0, sizeof(*standard_info)); + + basic_info->FileAttributes = pFileData->dwFileAttributes; + basic_info->CreationTime.HighPart = pFileData->ftCreationTime.dwHighDateTime; + basic_info->CreationTime.LowPart = pFileData->ftCreationTime.dwLowDateTime; + basic_info->LastAccessTime.HighPart = pFileData->ftLastAccessTime.dwHighDateTime; + basic_info->LastAccessTime.LowPart = pFileData->ftLastAccessTime.dwLowDateTime; + basic_info->LastWriteTime.HighPart = pFileData->ftLastWriteTime.dwHighDateTime; + basic_info->LastWriteTime.LowPart = pFileData->ftLastWriteTime.dwLowDateTime; + standard_info->EndOfFile.HighPart = pFileData->nFileSizeHigh; + standard_info->EndOfFile.LowPart = pFileData->nFileSizeLow; + if (pFileData->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) *reparse_tag = pFileData->dwReserved0; else @@ -2043,7 +2062,7 @@ find_data_to_file_info(WIN32_FIND_DATAW *pFileData, } static BOOL -attributes_from_dir(LPCWSTR pszFile, BY_HANDLE_FILE_INFORMATION *info, ULONG *reparse_tag) +attributes_from_dir(LPCWSTR pszFile, FILE_BASIC_INFO* basic_info, FILE_STANDARD_INFO* standard_info, ULONG* reparse_tag) { HANDLE hFindFile; WIN32_FIND_DATAW FileData; @@ -2074,7 +2093,7 @@ attributes_from_dir(LPCWSTR pszFile, BY_HANDLE_FILE_INFORMATION *info, ULONG *re return FALSE; } FindClose(hFindFile); - find_data_to_file_info(&FileData, info, reparse_tag); + find_data_to_file_info(&FileData, basic_info, standard_info, reparse_tag); return TRUE; } @@ -2090,12 +2109,20 @@ update_st_mode_from_path(const wchar_t *path, DWORD attr, GetSecurityInfo, OpenThreadToken/OpenProcessToken, and AccessCheck to check for generic read, write, and execute access. */ - const wchar_t *fileExtension = wcsrchr(path, '.'); - if (fileExtension) { - if (_wcsicmp(fileExtension, L".exe") == 0 || - _wcsicmp(fileExtension, L".bat") == 0 || - _wcsicmp(fileExtension, L".cmd") == 0 || - _wcsicmp(fileExtension, L".com") == 0) { + size_t len = wcslen(path); + if (!is_extended_path(path)) { + /* Trailing dots and spaces are stripped from the last component + of the path. */ + while (len > 0 && (path[len - 1] == L'.' || path[len - 1] == L' ')) { + len--; + } + } + if (len >= 4) { + const wchar_t *fileExtension = path + len - 4; + if (_wcsnicmp(fileExtension, L".exe", 4) == 0 || + _wcsnicmp(fileExtension, L".bat", 4) == 0 || + _wcsnicmp(fileExtension, L".cmd", 4) == 0 || + _wcsnicmp(fileExtension, L".com", 4) == 0) { result->st_mode |= 0111; } } @@ -2108,10 +2135,9 @@ win32_xstat_slow_impl(const wchar_t *path, struct _Py_stat_struct *result, BOOL traverse) { HANDLE hFile; - BY_HANDLE_FILE_INFORMATION fileInfo; - FILE_BASIC_INFO basicInfo; - FILE_BASIC_INFO *pBasicInfo = NULL; - FILE_ID_INFO idInfo; + FILE_STANDARD_INFO standardInfo = {0}; + FILE_BASIC_INFO basicInfo = {0}; + FILE_ID_INFO idInfo = {0}; FILE_ID_INFO *pIdInfo = NULL; FILE_ATTRIBUTE_TAG_INFO tagInfo = { 0 }; DWORD fileType, error; @@ -2132,7 +2158,7 @@ win32_xstat_slow_impl(const wchar_t *path, struct _Py_stat_struct *result, case ERROR_ACCESS_DENIED: /* Cannot sync or read attributes. */ case ERROR_SHARING_VIOLATION: /* It's a paging file. */ /* Try reading the parent directory. */ - if (!attributes_from_dir(path, &fileInfo, &tagInfo.ReparseTag)) { + if (!attributes_from_dir(path, &basicInfo, &standardInfo, &tagInfo.ReparseTag)) { /* Cannot read the parent directory. */ switch (GetLastError()) { case ERROR_FILE_NOT_FOUND: /* File cannot be found */ @@ -2147,7 +2173,7 @@ win32_xstat_slow_impl(const wchar_t *path, struct _Py_stat_struct *result, return -1; } - if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { + if (basicInfo.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { if (traverse || !IsReparseTagNameSurrogate(tagInfo.ReparseTag)) { /* The stat call has to traverse but cannot, so fail. */ @@ -2247,9 +2273,8 @@ win32_xstat_slow_impl(const wchar_t *path, struct _Py_stat_struct *result, } } - if (!GetFileInformationByHandle(hFile, &fileInfo) || - !GetFileInformationByHandleEx(hFile, FileBasicInfo, - &basicInfo, sizeof(basicInfo))) { + if (!GetFileInformationByHandleEx(hFile, FileStandardInfo, &standardInfo, sizeof(standardInfo)) || + !GetFileInformationByHandleEx(hFile, FileBasicInfo, &basicInfo, sizeof(basicInfo))) { switch (GetLastError()) { case ERROR_INVALID_PARAMETER: case ERROR_INVALID_FUNCTION: @@ -2264,17 +2289,14 @@ win32_xstat_slow_impl(const wchar_t *path, struct _Py_stat_struct *result, goto cleanup; } - /* Successfully got FileBasicInfo, so we'll pass it along */ - pBasicInfo = &basicInfo; - if (GetFileInformationByHandleEx(hFile, FileIdInfo, &idInfo, sizeof(idInfo))) { /* Successfully got FileIdInfo, so pass it along */ pIdInfo = &idInfo; } } - _Py_attribute_data_to_stat(&fileInfo, tagInfo.ReparseTag, pBasicInfo, pIdInfo, result); - update_st_mode_from_path(path, fileInfo.dwFileAttributes, result); + _Py_attribute_data_to_stat(&standardInfo, tagInfo.ReparseTag, &basicInfo, pIdInfo, result); + update_st_mode_from_path(path, basicInfo.FileAttributes, result); cleanup: if (hFile != INVALID_HANDLE_VALUE) { @@ -2539,7 +2561,7 @@ static PyStructSequence_Field waitid_result_fields[] = { }; static PyStructSequence_Desc waitid_result_desc = { - MODNAME ".waitid_result", /* name */ + "os.waitid_result", /* name */ waitid_result__doc__, /* doc */ waitid_result_fields, 5 @@ -3186,14 +3208,6 @@ class dir_fd_converter(CConverter): def c_default_init(self): self.c_default = 'DEFAULT_DIR_FD' -class uid_t_converter(CConverter): - type = "uid_t" - converter = '_Py_Uid_Converter' - -class gid_t_converter(CConverter): - type = "gid_t" - converter = '_Py_Gid_Converter' - class dev_t_converter(CConverter): type = 'dev_t' converter = '_Py_Dev_Converter' @@ -3203,18 +3217,6 @@ class dev_t_return_converter(unsigned_long_return_converter): conversion_fn = '_PyLong_FromDev' unsigned_cast = '(dev_t)' -class pid_t_converter(CConverter): - type = 'pid_t' - format_unit = '" _Py_PARSE_PID "' - - def parse_arg(self, argname, displayname, *, limited_capi): - return self.format_code(""" - {paramname} = PyLong_AsPid({argname}); - if ({paramname} == (pid_t)(-1) && PyErr_Occurred()) {{{{ - goto exit; - }}}} - """, argname=argname) - class idtype_t_converter(CConverter): type = 'idtype_t' converter = 'idtype_t_converter' @@ -3243,10 +3245,6 @@ class intptr_t_converter(CConverter): }}}} """, argname=argname) -class Py_off_t_converter(CConverter): - type = 'Py_off_t' - converter = 'Py_off_t_converter' - class Py_off_t_return_converter(long_return_converter): type = 'Py_off_t' conversion_fn = 'PyLong_FromPy_off_t' @@ -3266,7 +3264,7 @@ class confname_converter(CConverter): """, argname=argname, converter=self.converter, table=self.table) [python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=ddbf3ac90a981122]*/ +/*[python end generated code: output=da39a3ee5e6b4b0d input=7ceccf55bb600f61]*/ /*[clinic input] @@ -3675,6 +3673,9 @@ os_statx_impl(PyObject *module, path_t *path, unsigned int mask, int flags, "use dir_fd kwarg instead of AT_EMPTY_PATH flag"); return NULL; } + if (!follow_symlinks) { + flags |= AT_SYMLINK_NOFOLLOW; + } /* Future bits may refer to members beyond the current size of struct statx, so we need to mask them off to prevent memory corruption. */ @@ -4020,6 +4021,12 @@ win32_hchmod(HANDLE hfile, int mode) } if (mode & _S_IWRITE) { info.FileAttributes &= ~FILE_ATTRIBUTE_READONLY; + if (info.FileAttributes == 0) { + /* SetFileInformationByHandle() interprets FileAttributes == 0 + as "leave the attributes unchanged"; FILE_ATTRIBUTE_NORMAL + is the documented way to clear all attributes. */ + info.FileAttributes = FILE_ATTRIBUTE_NORMAL; + } } else { info.FileAttributes |= FILE_ATTRIBUTE_READONLY; @@ -4400,6 +4407,14 @@ static PyObject * os_chroot_impl(PyObject *module, path_t *path) /*[clinic end generated code: output=de80befc763a4475 input=14822965652c3dc3]*/ { +#ifdef __ANDROID__ + // On Android, calling this function as a non-root user leads to a process crash + // rather than returning a permission error. + if (getuid() != 0) { + errno = EPERM; + return path_error(path); + } +#endif int res; Py_BEGIN_ALLOW_THREADS res = chroot(path->narrow); @@ -5662,8 +5677,9 @@ os__getvolumepathname_impl(PyObject *module, path_t *path) goto exit; } result = PyUnicode_FromWideChar(mountpath, -1); - if (PyBytes_Check(path->object)) + if (result != NULL && PyBytes_Check(path->object)) { Py_SETREF(result, PyUnicode_EncodeFSDefault(result)); + } exit: PyMem_Free(mountpath); @@ -6758,7 +6774,7 @@ or via the attributes sysname, nodename, release, version, and machine.\n\ See os.uname for more information."); static PyStructSequence_Desc uname_result_desc = { - MODNAME ".uname_result", /* name */ + "os.uname_result", /* name */ uname_result__doc__, /* doc */ uname_result_fields, 5 @@ -7507,7 +7523,7 @@ os_execv_impl(PyObject *module, path_t *path, PyObject *argv) /* If we get here it's definitely an error */ - posix_error(); + posix_path_error(path); free_string_array(argvlist, argc); return NULL; } @@ -8359,7 +8375,7 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv, lastarg = i + 1; PyErr_SetString( PyExc_ValueError, - "spawnv() arg 2 first element cannot be empty"); + "spawnve() arg 2 first element cannot be empty"); goto fail_1; } } @@ -8808,7 +8824,7 @@ static PyStructSequence_Field sched_param_fields[] = { }; static PyStructSequence_Desc sched_param_desc = { - MODNAME ".sched_param", /* name */ + "os.sched_param", /* name */ os_sched_param__doc__, /* doc */ sched_param_fields, 1 @@ -9186,7 +9202,9 @@ os_posix_openpt_impl(PyObject *module, int oflag) { int fd; -#if defined(O_CLOEXEC) + // OpenBSD posix_openpt() rejects any flag other than O_RDWR and + // O_NOCTTY; the fd is made non-inheritable below in any case. +#if defined(O_CLOEXEC) && !defined(__OpenBSD__) oflag |= O_CLOEXEC; #endif @@ -9429,11 +9447,30 @@ os_openpty_impl(PyObject *module) goto posix_error; #if defined(HAVE_STROPTS_H) && !defined(HAVE_DEV_PTC) + // Pushing "ptem" makes the slave a terminal, which a session leader + // without a controlling terminal then acquires as one despite O_NOCTTY. + // Note whether we already had one, so a new one can be disowned below. + int had_ctty = 0; +#ifdef TIOCNOTTY + int tty_fd = open("/dev/tty", O_RDONLY | O_NOCTTY); + if (tty_fd >= 0) { + had_ctty = 1; + close(tty_fd); + } +#endif ioctl(slave_fd, I_PUSH, "ptem"); /* push ptem */ ioctl(slave_fd, I_PUSH, "ldterm"); /* push ldterm */ #ifndef __hpux ioctl(slave_fd, I_PUSH, "ttcompat"); /* push ttcompat */ #endif /* __hpux */ +#ifdef TIOCNOTTY + if (!had_ctty && getsid(0) == getpid()) { + // Disown it; TIOCNOTTY sends SIGHUP to the session leader. + PyOS_sighandler_t sig_saved = PyOS_setsig(SIGHUP, SIG_IGN); + ioctl(slave_fd, TIOCNOTTY); + PyOS_setsig(SIGHUP, sig_saved); + } +#endif #endif /* defined(HAVE_STROPTS_H) && !defined(HAVE_DEV_PTC) */ #endif /* HAVE_OPENPTY */ @@ -9855,6 +9892,14 @@ os_initgroups_impl(PyObject *module, PyObject *oname, gid_t gid) /*[clinic end generated code: output=59341244521a9e3f input=7e4514dff4526a95]*/ #endif { +#ifdef __ANDROID__ + // On Android, calling this function as a non-root user leads to a process crash + // rather than returning a permission error. + if (getuid() != 0) { + errno = EPERM; + return posix_error(); + } +#endif const char *username = PyBytes_AS_STRING(oname); if (initgroups(username, gid) == -1) @@ -10052,13 +10097,13 @@ os.getppid Return the parent's process id. If the parent process has already exited, Windows machines will still -return its id; others systems will return the id of the 'init' proces +return its id; other systems will return the id of the 'init' process (1). [clinic start generated code]*/ static PyObject * os_getppid_impl(PyObject *module) -/*[clinic end generated code: output=43b2a946a8c603b4 input=e17c1de18f41316b]*/ +/*[clinic end generated code: output=43b2a946a8c603b4 input=158cc6dd661d54d9]*/ { #ifdef MS_WINDOWS return win32_getppid(); @@ -10107,6 +10152,7 @@ os_getlogin_impl(PyObject *module) errno = old_errno; } else { + _Py_MSAN_UNPOISON(name, sizeof(name)); result = PyUnicode_DecodeFSDefault(name); } #else @@ -10281,6 +10327,14 @@ static PyObject * os_setuid_impl(PyObject *module, uid_t uid) /*[clinic end generated code: output=a0a41fd0d1ec555f input=c921a3285aa22256]*/ { +#ifdef __ANDROID__ + // On Android, calling this function as a non-root user leads to a process crash + // rather than returning a permission error. + if (getuid() != 0) { + errno = EPERM; + return posix_error(); + } +#endif if (setuid(uid) < 0) return posix_error(); Py_RETURN_NONE; @@ -10302,6 +10356,14 @@ static PyObject * os_seteuid_impl(PyObject *module, uid_t euid) /*[clinic end generated code: output=102e3ad98361519a input=ba93d927e4781aa9]*/ { +#ifdef __ANDROID__ + // On Android, calling this function as a non-root user leads to a process crash + // rather than returning a permission error. + if (getuid() != 0) { + errno = EPERM; + return posix_error(); + } +#endif if (seteuid(euid) < 0) return posix_error(); Py_RETURN_NONE; @@ -10323,6 +10385,14 @@ static PyObject * os_setegid_impl(PyObject *module, gid_t egid) /*[clinic end generated code: output=4e4b825a6a10258d input=4080526d0ccd6ce3]*/ { +#ifdef __ANDROID__ + // On Android, calling this function as a non-root user leads to a process crash + // rather than returning a permission error. + if (getuid() != 0) { + errno = EPERM; + return posix_error(); + } +#endif if (setegid(egid) < 0) return posix_error(); Py_RETURN_NONE; @@ -10345,6 +10415,14 @@ static PyObject * os_setreuid_impl(PyObject *module, uid_t ruid, uid_t euid) /*[clinic end generated code: output=62d991210006530a input=0ca8978de663880c]*/ { +#ifdef __ANDROID__ + // On Android, calling this function as a non-root user leads to a process crash + // rather than returning a permission error. + if (getuid() != 0) { + errno = EPERM; + return posix_error(); + } +#endif if (setreuid(ruid, euid) < 0) { return posix_error(); } else { @@ -10369,6 +10447,14 @@ static PyObject * os_setregid_impl(PyObject *module, gid_t rgid, gid_t egid) /*[clinic end generated code: output=aa803835cf5342f3 input=c59499f72846db78]*/ { +#ifdef __ANDROID__ + // On Android, calling this function as a non-root user leads to a process crash + // rather than returning a permission error. + if (getuid() != 0) { + errno = EPERM; + return posix_error(); + } +#endif if (setregid(rgid, egid) < 0) return posix_error(); Py_RETURN_NONE; @@ -10389,6 +10475,14 @@ static PyObject * os_setgid_impl(PyObject *module, gid_t gid) /*[clinic end generated code: output=bdccd7403f6ad8c3 input=27d30c4059045dc6]*/ { +#ifdef __ANDROID__ + // On Android, calling this function as a non-root user leads to a process crash + // rather than returning a permission error. + if (getuid() != 0) { + errno = EPERM; + return posix_error(); + } +#endif if (setgid(gid) < 0) return posix_error(); Py_RETURN_NONE; @@ -10776,8 +10870,9 @@ os_wait_impl(PyObject *module) // This system call always crashes on older Android versions. -#if defined(__linux__) && defined(__NR_pidfd_open) && \ - !(defined(__ANDROID__) && __ANDROID_API__ < 31) +#if defined(_Py_HAVE_PIDFD_OPEN) \ + || (defined(__linux__) && defined(__NR_pidfd_open) \ + && !(defined(__ANDROID__) && __ANDROID_API__ < 31)) /*[clinic input] os.pidfd_open pid: pid_t @@ -10793,7 +10888,11 @@ static PyObject * os_pidfd_open_impl(PyObject *module, pid_t pid, unsigned int flags) /*[clinic end generated code: output=5c7252698947dc41 input=03058b32c389f874]*/ { +#ifdef _Py_HAVE_PIDFD_OPEN + int fd = pidfd_open(pid, flags); +#else int fd = syscall(__NR_pidfd_open, pid, flags); +#endif if (fd < 0) { return posix_error(); } @@ -10802,8 +10901,9 @@ os_pidfd_open_impl(PyObject *module, pid_t pid, unsigned int flags) #endif -#if defined(__linux__) && defined(__NR_pidfd_getfd) && \ - !(defined(__ANDROID__) && __ANDROID_API__ < 31) +#if defined(_Py_HAVE_PIDFD_GETFD) \ + || (defined(__linux__) && defined(__NR_pidfd_getfd) \ + && !(defined(__ANDROID__) && __ANDROID_API__ < 31)) /*[clinic input] os.pidfd_getfd pidfd: int @@ -10822,7 +10922,11 @@ os_pidfd_getfd_impl(PyObject *module, int pidfd, int targetfd, unsigned int flags) /*[clinic end generated code: output=e1a1415a13c7137f input=ef6417fb10deb1cc]*/ { +#ifdef _Py_HAVE_PIDFD_GETFD + int fd = pidfd_getfd(pidfd, targetfd, flags); +#else int fd = syscall(__NR_pidfd_getfd, pidfd, targetfd, flags); +#endif if (fd < 0) { return posix_error(); } @@ -10889,11 +10993,19 @@ os_unshare_impl(PyObject *module, int flags) #endif + #if defined(HAVE_READLINK) || defined(MS_WINDOWS) + +#if (defined(__linux__) || defined(__ANDROID__)) && defined(O_PATH) +// readlinkat(fd, "", ...) reads the symlink that fd refers to. +// supported since Linux 2.6.39 (same version that O_PATH was introduced). +#define _Py_READLINKAT_SUPPORTS_EMPTY_PATH +#endif + /*[clinic input] os.readlink - path: path_t + path: path_t(allow_fd=True) * dir_fd: dir_fd(requires='readlinkat') = None @@ -10905,48 +11017,74 @@ that directory. dir_fd may not be implemented on your platform. If it is unavailable, using it will raise a NotImplementedError. + +On Linux, Android, macOS and iOS, path may be a file descriptor +referring to a symlink. If it is, dir_fd must be None. [clinic start generated code]*/ static PyObject * os_readlink_impl(PyObject *module, path_t *path, int dir_fd) -/*[clinic end generated code: output=d21b732a2e814030 input=03d10130870dbca8]*/ +/*[clinic end generated code: output=d21b732a2e814030 input=d90bddfeee86f673]*/ { #if defined(HAVE_READLINK) char buffer[MAXPATHLEN+1]; ssize_t length; -#ifdef HAVE_READLINKAT - int readlinkat_unavailable = 0; -#endif - Py_BEGIN_ALLOW_THREADS + if (path_and_dir_fd_invalid("readlink", path, dir_fd)) { + return NULL; + } + + if (path->is_fd) { +#if defined(_Py_HAVE_FREADLINK) + if (HAVE_FREADLINK_RUNTIME) { + Py_BEGIN_ALLOW_THREADS + length = freadlink(path->fd, buffer, MAXPATHLEN); + Py_END_ALLOW_THREADS + } else +#elif defined(HAVE_READLINKAT) && defined(_Py_READLINKAT_SUPPORTS_EMPTY_PATH) + // linux/android: + // readlinkat(fd, "", ...) reads the link that fd refers to. + if (HAVE_READLINKAT_RUNTIME) { + Py_BEGIN_ALLOW_THREADS + length = readlinkat(path->fd, "", buffer, MAXPATHLEN); + Py_END_ALLOW_THREADS + } else +#endif + { + PyErr_SetString(PyExc_NotImplementedError, + "readlink cannot read file descriptors on this platform"); + return NULL; + } + } else #ifdef HAVE_READLINKAT if (dir_fd != DEFAULT_DIR_FD) { if (HAVE_READLINKAT_RUNTIME) { + Py_BEGIN_ALLOW_THREADS length = readlinkat(dir_fd, path->narrow, buffer, MAXPATHLEN); + Py_END_ALLOW_THREADS } else { - readlinkat_unavailable = 1; + argument_unavailable_error(NULL, "dir_fd"); + return NULL; } } else #endif + { + Py_BEGIN_ALLOW_THREADS length = readlink(path->narrow, buffer, MAXPATHLEN); - Py_END_ALLOW_THREADS - -#ifdef HAVE_READLINKAT - if (readlinkat_unavailable) { - argument_unavailable_error(NULL, "dir_fd"); - return NULL; + Py_END_ALLOW_THREADS } -#endif if (length < 0) { return path_error(path); } buffer[length] = '\0'; - if (PyUnicode_Check(path->object)) + if (path->is_fd || PyUnicode_Check(path->object)) { return PyUnicode_DecodeFSDefaultAndSize(buffer, length); - else + } + else { return PyBytes_FromStringAndSize(buffer, length); + } #elif defined(MS_WINDOWS) DWORD n_bytes_returned; DWORD io_result = 0; @@ -10955,6 +11093,12 @@ os_readlink_impl(PyObject *module, path_t *path, int dir_fd) _Py_REPARSE_DATA_BUFFER *rdb = (_Py_REPARSE_DATA_BUFFER *)target_buffer; PyObject *result = NULL; + if (path->is_fd) { + PyErr_SetString(PyExc_NotImplementedError, + "readlink cannot read file descriptors on this platform"); + return NULL; + } + /* First get a handle to the reparse point */ Py_BEGIN_ALLOW_THREADS reparse_point_handle = CreateFileW( @@ -11238,7 +11382,7 @@ and elapsed.\n\ See os.times for more information."); static PyStructSequence_Desc times_result_desc = { - MODNAME ".times_result", /* name */ + "os.times_result", /* name */ times_result__doc__, /* doc */ times_result_fields, 5 @@ -11470,9 +11614,9 @@ os.timerfd_settime_ns flags: int = 0 0 or a bit mask of TFD_TIMER_ABSTIME or TFD_TIMER_CANCEL_ON_SET. initial: long_long = 0 - initial expiration timing in seconds. + initial expiration timing in nanoseconds. interval: long_long = 0 - interval for the timer in seconds. + interval for the timer in nanoseconds. Alter a timer file descriptor's internal timer in nanoseconds. [clinic start generated code]*/ @@ -11480,7 +11624,7 @@ Alter a timer file descriptor's internal timer in nanoseconds. static PyObject * os_timerfd_settime_ns_impl(PyObject *module, int fd, int flags, long long initial, long long interval) -/*[clinic end generated code: output=6273ec7d7b4cc0b3 input=261e105d6e42f5bc]*/ +/*[clinic end generated code: output=6273ec7d7b4cc0b3 input=94bdcea7292157eb]*/ { struct itimerspec new_value; struct itimerspec old_value; @@ -11510,12 +11654,12 @@ os.timerfd_gettime A timer file descriptor. / -Return a tuple of a timer file descriptor's (interval, next expiration) in float seconds. +Return a tuple of a timer file descriptor's (next expiration, interval) in float seconds. [clinic start generated code]*/ static PyObject * os_timerfd_gettime_impl(PyObject *module, int fd) -/*[clinic end generated code: output=ec5a94a66cfe6ab4 input=05f7d568a4820dc6]*/ +/*[clinic end generated code: output=ec5a94a66cfe6ab4 input=7b0a7cc61ea9e31a]*/ { struct itimerspec curr_value; int result; @@ -11537,12 +11681,12 @@ os.timerfd_gettime_ns A timer file descriptor. / -Return a tuple of a timer file descriptor's (interval, next expiration) in nanoseconds. +Return a tuple of a timer file descriptor's (next expiration, interval) in nanoseconds. [clinic start generated code]*/ static PyObject * os_timerfd_gettime_ns_impl(PyObject *module, int fd) -/*[clinic end generated code: output=580633a4465f39fe input=d0de95b9782179c5]*/ +/*[clinic end generated code: output=580633a4465f39fe input=89702268455fa93b]*/ { struct itimerspec curr_value; int result; @@ -11844,11 +11988,16 @@ os_dup2_impl(PyObject *module, int fd, int fd2, int inheritable) /*[clinic end generated code: output=bc059d34a73404d1 input=c3cddda8922b038d]*/ { int res = 0; -#if defined(HAVE_DUP3) && \ - !(defined(HAVE_FCNTL_H) && defined(F_DUP2FD_CLOEXEC)) - /* dup3() is available on Linux 2.6.27+ and glibc 2.9 */ - static int dup3_works = -1; -#endif + + /* dup3() is available on Linux 2.6.27+ and glibc 2.9 and macOS 27.0; + * it needs runtime detection for the case of running on older kernels. + * Values: -1: unknown; 0: doesn't work; 1: works + * For thread safety, use a process-global with one read & one store, + * both relaxed. (It's fine if two threads race and do the detection + * simultaneously; they should get the same result.) + */ + static int dup3_works_atomic = -1; + (void) dup3_works_atomic; // unused on some platforms /* dup2() can fail with EINTR if the target FD is already open, because it * then has to be closed. See os_close_impl() for why we don't handle EINTR @@ -11887,18 +12036,27 @@ os_dup2_impl(PyObject *module, int fd, int fd2, int inheritable) #else #ifdef HAVE_DUP3 + int dup3_works = FT_ATOMIC_LOAD_INT_RELAXED(dup3_works_atomic); if (!inheritable && dup3_works != 0) { - Py_BEGIN_ALLOW_THREADS - res = dup3(fd, fd2, O_CLOEXEC); - Py_END_ALLOW_THREADS - if (res < 0) { - if (dup3_works == -1) - dup3_works = (errno != ENOSYS); - if (dup3_works) { - posix_error(); - return -1; + if (HAVE_DUP3_RUNTIME) { + Py_BEGIN_ALLOW_THREADS + res = dup3(fd, fd2, O_CLOEXEC); + Py_END_ALLOW_THREADS + if (res < 0) { + if (dup3_works == -1) { + dup3_works = (errno != ENOSYS); + FT_ATOMIC_STORE_INT_RELAXED(dup3_works_atomic, dup3_works); + } + if (dup3_works) { + posix_error(); + return -1; + } } } + else { + dup3_works = 0; + FT_ATOMIC_STORE_INT_RELAXED(dup3_works_atomic, dup3_works); + } } if (inheritable || dup3_works == 0) @@ -11989,7 +12147,7 @@ static Py_off_t os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how) /*[clinic end generated code: output=971e1efb6b30bd2f input=32ea0788da7cb44b]*/ { - Py_off_t result; + Py_off_t result = -1; #ifdef SEEK_SET /* Turn 0, 1, 2 into SEEK_{SET,CUR,END} */ @@ -12003,14 +12161,21 @@ os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how) Py_BEGIN_ALLOW_THREADS _Py_BEGIN_SUPPRESS_IPH #ifdef MS_WINDOWS - result = _lseeki64(fd, position, how); + HANDLE h = (HANDLE)_get_osfhandle(fd); + if (h != INVALID_HANDLE_VALUE && GetFileType(h) == FILE_TYPE_PIPE) { + errno = ESPIPE; + } + else { + result = _lseeki64(fd, position, how); + } #else result = lseek(fd, position, how); #endif _Py_END_SUPPRESS_IPH Py_END_ALLOW_THREADS - if (result < 0) + if (result < 0) { posix_error(); + } return result; } @@ -12295,7 +12460,7 @@ os_preadv_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset, if (!PySequence_Check(buffers)) { PyErr_SetString(PyExc_TypeError, - "preadv2() arg 2 must be a sequence"); + "preadv() arg 2 must be a sequence"); return -1; } @@ -12572,7 +12737,7 @@ os_sendfile_impl(PyObject *module, int out_fd, int in_fd, PyObject *offobj, } #endif off_t offset; - if (!Py_off_t_converter(offobj, &offset)) + if (!_Py_Off_t_Converter(offobj, &offset)) return NULL; #if defined(__sun) && defined(__SVR4) @@ -12592,27 +12757,35 @@ os_sendfile_impl(PyObject *module, int out_fd, int in_fd, PyObject *offobj, return PyLong_FromLong(0); } - // On illumos specifically sendfile() may perform a partial write but - // return -1/an error (in one confirmed case the destination socket - // had a 5 second timeout set and errno was EAGAIN) and it's on the client - // code to check if the offset parameter was modified by sendfile(). - // - // We need this variable to track said change. - off_t original_offset = offset; -#endif + // sendfile() may perform a partial write and still return -1, so the + // number of transferred bytes must be taken from the out parameter. + // sendfile() reports it by adding it to the offset, but does not + // initialize it when the transfer fails before writing any data, so use + // sendfilev(), which reports it explicitly. + sendfilevec_t vec; + size_t xferred; + + vec.sfv_fd = in_fd; + vec.sfv_flag = 0; + vec.sfv_off = offset; + vec.sfv_len = count; do { Py_BEGIN_ALLOW_THREADS - ret = sendfile(out_fd, in_fd, &offset, count); -#if defined(__sun) && defined(__SVR4) - // This handles illumos-specific sendfile() partial write behavior, - // see a comment above for more details. - if (ret < 0 && offset != original_offset) { - ret = offset - original_offset; + xferred = 0; + ret = sendfilev(out_fd, &vec, 1, &xferred); + if (ret < 0 && xferred != 0) { + ret = (Py_ssize_t)xferred; } -#endif Py_END_ALLOW_THREADS } while (ret < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals())); +#else + do { + Py_BEGIN_ALLOW_THREADS + ret = sendfile(out_fd, in_fd, &offset, count); + Py_END_ALLOW_THREADS + } while (ret < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals())); +#endif if (ret < 0) return (!async_err) ? posix_error() : NULL; return PyLong_FromSsize_t(ret); @@ -12731,7 +12904,13 @@ os_pipe_impl(PyObject *module) SECURITY_ATTRIBUTES attr; BOOL ok; #else - int res; + int res = -1; + + /* pipe2() is available on some newer linux/glibc & macOS; + * use the same runtime detection as for dup3 above. + */ + static int pipe2_works_atomic = -1; + (void) pipe2_works_atomic; // unused on some platforms #endif #ifdef MS_WINDOWS @@ -12757,11 +12936,30 @@ os_pipe_impl(PyObject *module) #else #ifdef HAVE_PIPE2 - Py_BEGIN_ALLOW_THREADS - res = pipe2(fds, O_CLOEXEC); - Py_END_ALLOW_THREADS + int pipe2_works = FT_ATOMIC_LOAD_INT_RELAXED(pipe2_works_atomic); + if (pipe2_works != 0) { + if (HAVE_PIPE2_RUNTIME) { + Py_BEGIN_ALLOW_THREADS + res = pipe2(fds, O_CLOEXEC); + Py_END_ALLOW_THREADS + if (pipe2_works == -1) { + if (res != 0 && errno == ENOSYS) { + pipe2_works = 0; + } + else { + // pipe2 is present but this call failed + pipe2_works = 1; + } + FT_ATOMIC_STORE_INT_RELAXED(pipe2_works_atomic, pipe2_works); + } + } + else { + pipe2_works = 0; + FT_ATOMIC_STORE_INT_RELAXED(pipe2_works_atomic, pipe2_works); + } + } - if (res != 0 && errno == ENOSYS) + if (pipe2_works == 0) { #endif Py_BEGIN_ALLOW_THREADS @@ -12784,8 +12982,9 @@ os_pipe_impl(PyObject *module) } #endif - if (res != 0) + if (res != 0) { return PyErr_SetFromErrno(PyExc_OSError); + } #endif /* !MS_WINDOWS */ return Py_BuildValue("(ii)", fds[0], fds[1]); } @@ -12815,9 +13014,17 @@ os_pipe2_impl(PyObject *module, int flags) int fds[2]; int res; - res = pipe2(fds, flags); - if (res != 0) + if (HAVE_PIPE2_RUNTIME) { + res = pipe2(fds, flags); + } + else { + res = -1; + errno = ENOSYS; + } + if (res != 0) { return posix_error(); + } + return Py_BuildValue("(ii)", fds[0], fds[1]); } #endif /* HAVE_PIPE2 */ @@ -12941,6 +13148,7 @@ following flags: - RWF_APPEND - RWF_DONTCACHE - RWF_ATOMIC +- RWF_NOSIGNAL Using non-zero flags requires Linux 4.7 or newer. [clinic start generated code]*/ @@ -12948,7 +13156,7 @@ Using non-zero flags requires Linux 4.7 or newer. static Py_ssize_t os_pwritev_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset, int flags) -/*[clinic end generated code: output=e3dd3e9d11a6a5c7 input=b2e352a22f030e9a]*/ +/*[clinic end generated code: output=e3dd3e9d11a6a5c7 input=c202f24f01fa66c9]*/ { Py_ssize_t cnt; Py_ssize_t result; @@ -13021,7 +13229,12 @@ os_pwritev_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset, } #endif /* HAVE_PWRITEV */ -#ifdef HAVE_COPY_FILE_RANGE +#if defined(HAVE_COPY_FILE_RANGE) || \ + (defined(__linux__) && defined(__NR_copy_file_range)) +# define _Py_HAVE_COPY_FILE_RANGE +#endif + +#ifdef _Py_HAVE_COPY_FILE_RANGE /*[clinic input] os.copy_file_range @@ -13058,14 +13271,14 @@ os_copy_file_range_impl(PyObject *module, int src, int dst, Py_ssize_t count, if (offset_src != Py_None) { - if (!Py_off_t_converter(offset_src, &offset_src_val)) { + if (!_Py_Off_t_Converter(offset_src, &offset_src_val)) { return NULL; } p_offset_src = &offset_src_val; } if (offset_dst != Py_None) { - if (!Py_off_t_converter(offset_dst, &offset_dst_val)) { + if (!_Py_Off_t_Converter(offset_dst, &offset_dst_val)) { return NULL; } p_offset_dst = &offset_dst_val; @@ -13073,7 +13286,13 @@ os_copy_file_range_impl(PyObject *module, int src, int dst, Py_ssize_t count, do { Py_BEGIN_ALLOW_THREADS +#ifdef HAVE_COPY_FILE_RANGE ret = copy_file_range(src, p_offset_src, dst, p_offset_dst, count, flags); +#else + /* Largefile support makes off_t 64-bit, as the kernel expects. */ + ret = syscall(__NR_copy_file_range, src, p_offset_src, dst, p_offset_dst, + count, flags); +#endif Py_END_ALLOW_THREADS } while (ret < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals())); @@ -13083,7 +13302,7 @@ os_copy_file_range_impl(PyObject *module, int src, int dst, Py_ssize_t count, return PyLong_FromSsize_t(ret); } -#endif /* HAVE_COPY_FILE_RANGE*/ +#endif /* _Py_HAVE_COPY_FILE_RANGE */ #if (defined(HAVE_SPLICE) && !defined(_AIX)) /*[clinic input] @@ -13123,14 +13342,14 @@ os_splice_impl(PyObject *module, int src, int dst, Py_ssize_t count, if (offset_src != Py_None) { - if (!Py_off_t_converter(offset_src, &offset_src_val)) { + if (!_Py_Off_t_Converter(offset_src, &offset_src_val)) { return NULL; } p_offset_src = &offset_src_val; } if (offset_dst != Py_None) { - if (!Py_off_t_converter(offset_dst, &offset_dst_val)) { + if (!_Py_Off_t_Converter(offset_dst, &offset_dst_val)) { return NULL; } p_offset_dst = &offset_dst_val; @@ -13486,6 +13705,10 @@ os_posix_fallocate_impl(PyObject *module, int fd, Py_off_t offset, Py_BEGIN_ALLOW_THREADS result = posix_fallocate(fd, offset, length); Py_END_ALLOW_THREADS + // DragonFly BSD returns -1 and sets errno. + if (result == -1) { + result = errno; + } } while (result == EINTR && !(async_err = PyErr_CheckSignals())); if (result == 0) @@ -13533,6 +13756,10 @@ os_posix_fadvise_impl(PyObject *module, int fd, Py_off_t offset, Py_BEGIN_ALLOW_THREADS result = posix_fadvise(fd, offset, length, advice); Py_END_ALLOW_THREADS + // DragonFly BSD returns -1 and sets errno. + if (result == -1) { + result = errno; + } } while (result == EINTR && !(async_err = PyErr_CheckSignals())); if (result == 0) @@ -13750,13 +13977,7 @@ static PyObject * os_strerror_impl(PyObject *module, int code) /*[clinic end generated code: output=baebf09fa02a78f2 input=75a8673d97915a91]*/ { - char *message = strerror(code); - if (message == NULL) { - PyErr_SetString(PyExc_ValueError, - "strerror() argument out of range"); - return NULL; - } - return PyUnicode_DecodeLocale(message, "surrogateescape"); + return _Py_strerror(code); } @@ -13931,11 +14152,6 @@ os_WSTOPSIG_impl(PyObject *module, int status) #if defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H) -#ifdef _SCO_DS -/* SCO OpenServer 5.0 and later requires _SVID3 before it reveals the - needed definitions in sys/statvfs.h */ -#define _SVID3 -#endif #include #ifdef __APPLE__ @@ -15393,6 +15609,14 @@ static PyObject * os_setresuid_impl(PyObject *module, uid_t ruid, uid_t euid, uid_t suid) /*[clinic end generated code: output=834a641e15373e97 input=9e33cb79a82792f3]*/ { +#ifdef __ANDROID__ + // On Android, calling this function as a non-root user leads to a process crash + // rather than returning a permission error. + if (getuid() != 0) { + errno = EPERM; + return posix_error(); + } +#endif if (setresuid(ruid, euid, suid) < 0) return posix_error(); Py_RETURN_NONE; @@ -15416,6 +15640,14 @@ static PyObject * os_setresgid_impl(PyObject *module, gid_t rgid, gid_t egid, gid_t sgid) /*[clinic end generated code: output=6aa402f3d2e514a9 input=33e9e0785ef426b1]*/ { +#ifdef __ANDROID__ + // On Android, calling this function as a non-root user leads to a process crash + // rather than returning a permission error. + if (getuid() != 0) { + errno = EPERM; + return posix_error(); + } +#endif if (setresgid(rgid, egid, sgid) < 0) return posix_error(); Py_RETURN_NONE; @@ -15777,7 +16009,12 @@ os_urandom_impl(PyObject *module, Py_ssize_t size) return PyBytesWriter_Finish(writer); } -#ifdef HAVE_MEMFD_CREATE +#if defined(HAVE_MEMFD_CREATE) || \ + (defined(__linux__) && defined(__NR_memfd_create) && defined(MFD_CLOEXEC)) +# define _Py_HAVE_MEMFD_CREATE +#endif + +#ifdef _Py_HAVE_MEMFD_CREATE /*[clinic input] os.memfd_create @@ -15793,7 +16030,11 @@ os_memfd_create_impl(PyObject *module, PyObject *name, unsigned int flags) int fd; const char *bytes = PyBytes_AS_STRING(name); Py_BEGIN_ALLOW_THREADS +#ifdef HAVE_MEMFD_CREATE fd = memfd_create(bytes, flags); +#else + fd = syscall(__NR_memfd_create, bytes, flags); +#endif Py_END_ALLOW_THREADS if (fd == -1) { return PyErr_SetFromErrno(PyExc_OSError); @@ -15932,6 +16173,13 @@ os_get_terminal_size_impl(PyObject *module, int fd) #ifdef TERMSIZE_USE_IOCTL { + // On Android, stdout is probably not connected, and calling TIOCGWINSZ + // on an invalid file descriptor causes a log message "avc: denied { + // ioctl }". Some common tools such as pytest call get_terminal_size + // very often, so check it's a TTY first to avoid cluttering the log. + if (!isatty(fd)) + return PyErr_SetFromErrno(PyExc_OSError); + struct winsize w; if (ioctl(fd, TIOCGWINSZ, &w)) return PyErr_SetFromErrno(PyExc_OSError); @@ -16003,7 +16251,9 @@ os_cpu_count_impl(PyObject *module) # ifdef MS_WINDOWS_DESKTOP ncpu = GetActiveProcessorCount(ALL_PROCESSOR_GROUPS); # else - ncpu = 0; + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + ncpu = sysinfo.dwNumberOfProcessors; # endif #elif defined(__hpux) @@ -16182,8 +16432,9 @@ os_set_blocking_impl(PyObject *module, int fd, int blocking) /*[clinic input] class os.DirEntry "DirEntry *" "DirEntryType" +class os.ScandirIterator "PyObject *" "ScandirIteratorType" [clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=3c18c7a448247980]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b845e502eb4a0406]*/ typedef struct { PyObject_HEAD @@ -16590,7 +16841,7 @@ static PyType_Slot DirEntryType_slots[] = { }; static PyType_Spec DirEntryType_spec = { - .name = MODNAME ".DirEntry", + .name = "os.DirEntry", .basicsize = sizeof(DirEntry), .flags = ( Py_TPFLAGS_DEFAULT @@ -16603,12 +16854,6 @@ static PyType_Spec DirEntryType_spec = { #ifdef MS_WINDOWS -static int -is_extended_path(const wchar_t *path) -{ - return wcsncmp(path, L"\\\\?\\", 4) == 0; -} - static wchar_t * join_path_filenameW(const wchar_t *path_wide, const wchar_t *filename, int normalize) @@ -16670,7 +16915,8 @@ static PyObject * DirEntry_from_find_data(PyObject *module, path_t *path, WIN32_FIND_DATAW *dataW) { DirEntry *entry; - BY_HANDLE_FILE_INFORMATION file_info; + FILE_BASIC_INFO basic_info; + FILE_STANDARD_INFO standard_info; ULONG reparse_tag; wchar_t *joined_path; @@ -16708,8 +16954,8 @@ DirEntry_from_find_data(PyObject *module, path_t *path, WIN32_FIND_DATAW *dataW) goto error; } - find_data_to_file_info(dataW, &file_info, &reparse_tag); - _Py_attribute_data_to_stat(&file_info, reparse_tag, NULL, NULL, &entry->win32_lstat); + find_data_to_file_info(dataW, &basic_info, &standard_info, &reparse_tag); + _Py_attribute_data_to_stat(&standard_info, reparse_tag, &basic_info, NULL, &entry->win32_lstat); /* ctime is only deprecated from 3.12, so we copy birthtime across */ entry->win32_lstat.st_ctime = entry->win32_lstat.st_birthtime; @@ -16835,6 +17081,13 @@ typedef struct { #ifdef HAVE_FDOPENDIR int fd; #endif + // Sharing the iterator between threads is subject to race conditions: + // which entries each thread receives is unspecified. It must not + // corrupt the iterator or crash. Since we don't want close() to be + // held up by a blocking directory read, we set the 'closed' flag if + // there are reads in progress. + PyMutex read_mutex; + uint8_t closed; } ScandirIterator; #define ScandirIterator_CAST(op) ((ScandirIterator *)(op)) @@ -16844,62 +17097,84 @@ typedef struct { static int ScandirIterator_is_closed(ScandirIterator *iterator) { - return iterator->handle == INVALID_HANDLE_VALUE; + return _Py_atomic_load_uint8(&iterator->closed); } static void ScandirIterator_closedir(ScandirIterator *iterator) { - HANDLE handle = iterator->handle; + HANDLE handle = INVALID_HANDLE_VALUE; - if (handle == INVALID_HANDLE_VALUE) - return; + _Py_atomic_store_uint8(&iterator->closed, 1); + if (PyMutex_LockFast(&iterator->read_mutex)) { + // no reads in progress, we can close the handle + handle = iterator->handle; + iterator->handle = INVALID_HANDLE_VALUE; + PyMutex_Unlock(&iterator->read_mutex); + } - iterator->handle = INVALID_HANDLE_VALUE; - Py_BEGIN_ALLOW_THREADS - FindClose(handle); - Py_END_ALLOW_THREADS + if (handle != INVALID_HANDLE_VALUE) { + Py_BEGIN_ALLOW_THREADS + FindClose(handle); + Py_END_ALLOW_THREADS + } } static PyObject * ScandirIterator_iternext(PyObject *op) { ScandirIterator *iterator = ScandirIterator_CAST(op); - WIN32_FIND_DATAW *file_data = &iterator->file_data; + WIN32_FIND_DATAW file_data; BOOL success; - PyObject *entry; + DWORD error = ERROR_SUCCESS; + int found = 0; + PyMutex_Lock(&iterator->read_mutex); /* Happens if the iterator is iterated twice, or closed explicitly */ - if (iterator->handle == INVALID_HANDLE_VALUE) - return NULL; - - while (1) { + while (iterator->handle != INVALID_HANDLE_VALUE && + !_Py_atomic_load_uint8_relaxed(&iterator->closed)) + { if (!iterator->first_time) { Py_BEGIN_ALLOW_THREADS - success = FindNextFileW(iterator->handle, file_data); + success = FindNextFileW(iterator->handle, &iterator->file_data); + if (!success) { + error = GetLastError(); + } Py_END_ALLOW_THREADS if (!success) { - /* Error or no more files */ - if (GetLastError() != ERROR_NO_MORE_FILES) - path_error(&iterator->path); break; } } iterator->first_time = 0; /* Skip over . and .. */ - if (wcscmp(file_data->cFileName, L".") != 0 && - wcscmp(file_data->cFileName, L"..") != 0) + if (wcscmp(iterator->file_data.cFileName, L".") != 0 && + wcscmp(iterator->file_data.cFileName, L"..") != 0) { - PyObject *module = PyType_GetModule(Py_TYPE(iterator)); - entry = DirEntry_from_find_data(module, &iterator->path, file_data); - if (!entry) - break; - return entry; + file_data = iterator->file_data; + found = 1; + break; } /* Loop till we get a non-dot directory or finish iterating */ } + PyMutex_Unlock(&iterator->read_mutex); + + if (found && ScandirIterator_is_closed(iterator)) { + ScandirIterator_closedir(iterator); // deferred close + } + + if (found) { + PyObject *module = PyType_GetModule(Py_TYPE(iterator)); + PyObject *entry = DirEntry_from_find_data(module, &iterator->path, &file_data); + if (entry != NULL) { + return entry; + } + } + else if (error != ERROR_SUCCESS && error != ERROR_NO_MORE_FILES) { + SetLastError(error); + path_error(&iterator->path); + } /* Error or no more files */ ScandirIterator_closedir(iterator); @@ -16911,27 +17186,32 @@ ScandirIterator_iternext(PyObject *op) static int ScandirIterator_is_closed(ScandirIterator *iterator) { - return !iterator->dirp; + return _Py_atomic_load_uint8(&iterator->closed); } static void ScandirIterator_closedir(ScandirIterator *iterator) { - DIR *dirp = iterator->dirp; + DIR *dirp = NULL; - if (!dirp) - return; + _Py_atomic_store_uint8(&iterator->closed, 1); + if (PyMutex_LockFast(&iterator->read_mutex)) { + // no reads in progress, we can close dirp + dirp = iterator->dirp; + iterator->dirp = NULL; + PyMutex_Unlock(&iterator->read_mutex); + } - iterator->dirp = NULL; - Py_BEGIN_ALLOW_THREADS + if (dirp != NULL) { + Py_BEGIN_ALLOW_THREADS #ifdef HAVE_FDOPENDIR - if (iterator->path.is_fd) { - rewinddir(dirp); - } + if (iterator->path.is_fd) { + rewinddir(dirp); + } #endif - closedir(dirp); - Py_END_ALLOW_THREADS - return; + closedir(dirp); + Py_END_ALLOW_THREADS + } } static PyObject * @@ -16939,24 +17219,32 @@ ScandirIterator_iternext(PyObject *op) { ScandirIterator *iterator = ScandirIterator_CAST(op); struct dirent *direntp; - Py_ssize_t name_len; + Py_ssize_t name_len = 0; int is_dot; - PyObject *entry; + int found = 0; + int error = 0; + int no_memory = 0; + char namebuf[256]; + char *name = namebuf; + ino_t d_ino = 0; +#ifdef HAVE_DIRENT_D_TYPE + unsigned char d_type = 0; +#endif + PyMutex_Lock(&iterator->read_mutex); /* Happens if the iterator is iterated twice, or closed explicitly */ - if (!iterator->dirp) - return NULL; - - while (1) { - errno = 0; + while (iterator->dirp != NULL && + !_Py_atomic_load_uint8_relaxed(&iterator->closed)) + { Py_BEGIN_ALLOW_THREADS + errno = 0; direntp = readdir(iterator->dirp); + if (direntp == NULL) { + error = errno; + } Py_END_ALLOW_THREADS if (!direntp) { - /* Error or no more files */ - if (errno != 0) - path_error(&iterator->path); break; } @@ -16965,21 +17253,54 @@ ScandirIterator_iternext(PyObject *op) is_dot = direntp->d_name[0] == '.' && (name_len == 1 || (direntp->d_name[1] == '.' && name_len == 2)); if (!is_dot) { - PyObject *module = PyType_GetModule(Py_TYPE(iterator)); - entry = DirEntry_from_posix_info(module, - &iterator->path, direntp->d_name, - name_len, direntp->d_ino + if ((size_t)name_len >= sizeof(namebuf)) { + name = PyMem_RawMalloc(name_len + 1); + if (name == NULL) { + no_memory = 1; + break; + } + } + memcpy(name, direntp->d_name, name_len); + name[name_len] = '\0'; + d_ino = direntp->d_ino; #ifdef HAVE_DIRENT_D_TYPE - , direntp->d_type + d_type = direntp->d_type; #endif - ); - if (!entry) - break; - return entry; + found = 1; + break; } /* Loop till we get a non-dot directory or finish iterating */ } + PyMutex_Unlock(&iterator->read_mutex); + + if (found && ScandirIterator_is_closed(iterator)) { + ScandirIterator_closedir(iterator); // deferred close + } + + if (found) { + PyObject *module = PyType_GetModule(Py_TYPE(iterator)); + PyObject *entry = DirEntry_from_posix_info(module, + &iterator->path, name, + name_len, d_ino +#ifdef HAVE_DIRENT_D_TYPE + , d_type +#endif + ); + if (name != namebuf) { + PyMem_RawFree(name); + } + if (entry != NULL) { + return entry; + } + } + else if (no_memory) { + PyErr_NoMemory(); + } + else if (error != 0) { + errno = error; + path_error(&iterator->path); + } /* Error or no more files */ ScandirIterator_closedir(iterator); @@ -17002,11 +17323,20 @@ ScandirIterator_enter(PyObject *self, PyObject *Py_UNUSED(dummy)) return Py_NewRef(self); } +/*[clinic input] +os.ScandirIterator.__exit__ + + *exc_info: array + +Close the scandir iterator. +[clinic start generated code]*/ + static PyObject * -ScandirIterator_exit(PyObject *op, PyObject *Py_UNUSED(args)) +os_ScandirIterator___exit___impl(PyObject *self, PyObject * const *exc_info, + Py_ssize_t exc_info_length) +/*[clinic end generated code: output=5d3941725a7c97c7 input=ff3ffe83ae605a36]*/ { - ScandirIterator *self = ScandirIterator_CAST(op); - ScandirIterator_closedir(self); + ScandirIterator_closedir(ScandirIterator_CAST(self)); Py_RETURN_NONE; } @@ -17017,9 +17347,11 @@ ScandirIterator_finalize(PyObject *op) /* Save the current exception, if any. */ PyObject *exc = PyErr_GetRaisedException(); - if (!ScandirIterator_is_closed(iterator)) { - ScandirIterator_closedir(iterator); + int was_closed = ScandirIterator_is_closed(iterator); + + ScandirIterator_closedir(iterator); + if (!was_closed) { if (PyErr_ResourceWarning(op, 1, "unclosed scandir iterator %R", iterator)) { @@ -17051,7 +17383,7 @@ ScandirIterator_dealloc(PyObject *op) static PyMethodDef ScandirIterator_methods[] = { {"__enter__", ScandirIterator_enter, METH_NOARGS}, - {"__exit__", ScandirIterator_exit, METH_VARARGS}, + OS_SCANDIRITERATOR___EXIT___METHODDEF {"close", ScandirIterator_close, METH_NOARGS}, {NULL} }; @@ -17066,7 +17398,7 @@ static PyType_Slot ScandirIteratorType_slots[] = { }; static PyType_Spec ScandirIteratorType_spec = { - .name = MODNAME ".ScandirIterator", + .name = "os.ScandirIterator", .basicsize = sizeof(ScandirIterator), // bpo-40549: Py_TPFLAGS_BASETYPE should not be used, since // PyType_GetModule(Py_TYPE(self)) doesn't work on a subclass instance. @@ -17117,6 +17449,8 @@ os_scandir_impl(PyObject *module, path_t *path) if (!iterator) return NULL; + iterator->read_mutex = (PyMutex){0}; + iterator->closed = 1; #ifdef MS_WINDOWS iterator->handle = INVALID_HANDLE_VALUE; #else @@ -17189,6 +17523,7 @@ os_scandir_impl(PyObject *module, path_t *path) } #endif + iterator->closed = 0; return (PyObject *)iterator; error: @@ -17260,19 +17595,19 @@ os_fspath_impl(PyObject *module, PyObject *path) return PyOS_FSPath(path); } -#ifdef HAVE_GETRANDOM_SYSCALL +#if defined(HAVE_GETRANDOM) || defined(HAVE_GETRANDOM_SYSCALL) /*[clinic input] os.getrandom size: Py_ssize_t - flags: int=0 + flags: unsigned_int(bitwise=True) = 0 Obtain a series of random bytes. [clinic start generated code]*/ static PyObject * -os_getrandom_impl(PyObject *module, Py_ssize_t size, int flags) -/*[clinic end generated code: output=b3a618196a61409c input=59bafac39c594947]*/ +os_getrandom_impl(PyObject *module, Py_ssize_t size, unsigned int flags) +/*[clinic end generated code: output=c2163c05f0e1d0a1 input=e0174983f5703f82]*/ { if (size < 0) { errno = EINVAL; @@ -17287,7 +17622,11 @@ os_getrandom_impl(PyObject *module, Py_ssize_t size, int flags) Py_ssize_t n; while (1) { +#ifdef HAVE_GETRANDOM + n = getrandom(data, size, flags); +#else n = syscall(SYS_getrandom, data, size, flags); +#endif if (n < 0 && errno == EINTR) { if (PyErr_CheckSignals() < 0) { goto error; @@ -18244,6 +18583,9 @@ all_ins(PyObject *m) #ifdef RWF_APPEND if (PyModule_AddIntConstant(m, "RWF_APPEND", RWF_APPEND)) return -1; #endif +#ifdef RWF_NOSIGNAL + if (PyModule_AddIntConstant(m, "RWF_NOSIGNAL", RWF_NOSIGNAL)) return -1; +#endif /* constants for splice */ #if defined(HAVE_SPLICE) && defined(__linux__) @@ -18392,11 +18734,11 @@ all_ins(PyObject *m) if (PyModule_AddIntMacro(m, RTLD_MEMBER)) return -1; #endif -#ifdef HAVE_GETRANDOM_SYSCALL +#if defined(HAVE_GETRANDOM) || defined(HAVE_GETRANDOM_SYSCALL) if (PyModule_AddIntMacro(m, GRND_RANDOM)) return -1; if (PyModule_AddIntMacro(m, GRND_NONBLOCK)) return -1; #endif -#ifdef HAVE_MEMFD_CREATE +#ifdef _Py_HAVE_MEMFD_CREATE if (PyModule_AddIntMacro(m, MFD_CLOEXEC)) return -1; if (PyModule_AddIntMacro(m, MFD_ALLOW_SEALING)) return -1; #ifdef MFD_HUGETLB @@ -18444,7 +18786,7 @@ all_ins(PyObject *m) #ifdef MFD_HUGE_16GB if (PyModule_AddIntMacro(m, MFD_HUGE_16GB)) return -1; #endif -#endif /* HAVE_MEMFD_CREATE */ +#endif /* _Py_HAVE_MEMFD_CREATE */ #if defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC) if (PyModule_AddIntMacro(m, EFD_CLOEXEC)) return -1; @@ -18585,6 +18927,10 @@ PROBE(probe_openat, HAVE_OPENAT_RUNTIME) PROBE(probe_readlinkat, HAVE_READLINKAT_RUNTIME) #endif +#ifdef _Py_HAVE_FREADLINK +PROBE(probe_freadlink, HAVE_FREADLINK_RUNTIME) +#endif + #ifdef HAVE_SYMLINKAT PROBE(probe_symlinkat, HAVE_SYMLINKAT_RUNTIME) #endif @@ -18652,6 +18998,10 @@ static const struct have_function { { "HAVE_FPATHCONF", NULL }, #endif +#ifdef _Py_HAVE_FREADLINK + { "HAVE_FREADLINK", probe_freadlink }, +#endif + #ifdef HAVE_FSTATAT { "HAVE_FSTATAT", probe_fstatat }, #endif @@ -18700,7 +19050,7 @@ static const struct have_function { { "HAVE_LUTIMES", NULL }, #endif -#ifdef HAVE_MEMFD_CREATE +#ifdef _Py_HAVE_MEMFD_CREATE { "HAVE_MEMFD_CREATE", NULL }, #endif @@ -18792,6 +19142,22 @@ posixmodule_exec(PyObject *m) } #endif +#if HAVE_PIPE2 + if (HAVE_PIPE2_RUNTIME) { + // Do nothing. (`__builtin_available` doesn't allow `!`; see + // "using negations" in a comment above.) + } + else { + PyObject* dct = PyModule_GetDict(m); + if (dct == NULL) { + return -1; + } + if (PyDict_PopString(dct, "pipe2", NULL) < 0) { + return -1; + } + } +#endif + /* Initialize environ dictionary */ if (PyModule_Add(m, "environ", convertenviron()) != 0) { return -1; diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c index 4a2b33f8700d101..be5e0d4d0c29ae3 100644 --- a/Modules/pwdmodule.c +++ b/Modules/pwdmodule.c @@ -121,7 +121,7 @@ mkpwent(PyObject *module, struct passwd *p) /*[clinic input] pwd.getpwuid - uidobj: object + uidobj as uid: uid_t / Return the password database entry for the given numeric user ID. @@ -130,21 +130,14 @@ See `help(pwd)` for more on password database entries. [clinic start generated code]*/ static PyObject * -pwd_getpwuid(PyObject *module, PyObject *uidobj) -/*[clinic end generated code: output=c4ee1d4d429b86c4 input=ae64d507a1c6d3e8]*/ +pwd_getpwuid_impl(PyObject *module, uid_t uid) +/*[clinic end generated code: output=631bad376fa670c3 input=506d3a592ef19799]*/ { PyObject *retval = NULL; - uid_t uid; int nomem = 0; struct passwd *p; char *buf = NULL, *buf2 = NULL; - if (!_Py_Uid_Converter(uidobj, &uid)) { - if (PyErr_ExceptionMatches(PyExc_OverflowError)) - PyErr_Format(PyExc_KeyError, - "getpwuid(): uid not found"); - return NULL; - } #ifdef HAVE_GETPWUID_R int status; Py_ssize_t bufsize; diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index f9e7e057f7e0f7b..a6063f034463c82 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -25,6 +25,16 @@ module pyexpat #define XML_COMBINED_VERSION (10000*XML_MAJOR_VERSION+100*XML_MINOR_VERSION+XML_MICRO_VERSION) +#if XML_COMBINED_VERSION >= 20900 +# define EXPAT_GetCurrentLineNumber XML_GetCurrentLineNumber64 +# define EXPAT_GetCurrentColumnNumber XML_GetCurrentColumnNumber64 +# define EXPAT_GetCurrentByteIndex XML_GetCurrentByteIndex64 +#else +# define EXPAT_GetCurrentLineNumber XML_GetCurrentLineNumber +# define EXPAT_GetCurrentColumnNumber XML_GetCurrentColumnNumber +# define EXPAT_GetCurrentByteIndex XML_GetCurrentByteIndex +#endif + static XML_Memory_Handling_Suite ExpatMemoryHandler = { PyMem_Malloc, PyMem_Realloc, PyMem_Free}; @@ -148,9 +158,10 @@ set_xml_error_attr_code(PyObject *err, enum XML_Error code) * false on an exception. */ static int -set_xml_error_attr_location(PyObject *err, const char *name, XML_Size value) +set_xml_error_attr_location(PyObject *err, const char *name, + unsigned long long value) { - PyObject *v = PyLong_FromSize_t((size_t)value); + PyObject *v = PyLong_FromUnsignedLongLong(value); int ok = v != NULL && PyObject_SetAttrString(err, name, v) != -1; Py_XDECREF(v); return ok; @@ -159,15 +170,16 @@ set_xml_error_attr_location(PyObject *err, const char *name, XML_Size value) static PyObject * set_xml_error(pyexpat_state *state, - enum XML_Error code, XML_Size lineno, XML_Size column, + enum XML_Error code, + unsigned long long lineno, unsigned long long column, const char *errmsg) { PyObject *arg; if (errmsg == NULL) { arg = PyUnicode_FromFormat( - "%s: line %zu, column %zu", + "%s: line %llu, column %llu", XML_ErrorString(code), - (size_t)lineno, (size_t)column + lineno, column ); } else { @@ -194,8 +206,10 @@ set_xml_error(pyexpat_state *state, do { \ XML_Parser parser = SELF->itself; \ assert(parser != NULL); \ - XML_Size lineno = XML_GetCurrentLineNumber(parser); \ - XML_Size column = XML_GetCurrentColumnNumber(parser); \ + unsigned long long lineno \ + = EXPAT_GetCurrentLineNumber(parser); \ + unsigned long long column \ + = EXPAT_GetCurrentColumnNumber(parser); \ (void)set_xml_error(state, CODE, lineno, column, ERRMSG); \ } while (0) @@ -279,10 +293,13 @@ error_external_entity_ref_handler(XML_Parser parser, /* Dummy character data handler used when an error (exception) has been detected, and the actual parsing can be terminated early. - This is needed since character data handler can't be safely removed - from within the character data handler, but can be replaced. It is - used only from the character data handler trampoline, and must be - used right after `flag_error()` is called. */ + This is needed since the character data and default handlers can't be + safely removed from within a callback, only replaced: Expat may call + them several times for one piece of text (a long comment in a document + that is not UTF-8, for example). The default handler has the same + signature, so this function serves for both. clear_handlers() installs + it after `flag_error()`, and the handler setter installs it when a + handler is set to None from within a callback. */ static void noop_character_data_handler(void *userData, const XML_Char *data, int len) { @@ -303,7 +320,9 @@ call_with_frame(const char *funcname, int lineno, PyObject* func, PyObject* args { PyObject *res; + Py_INCREF(func); res = PyObject_Call(func, args, NULL); + Py_DECREF(func); if (res == NULL) { _PyTraceback_Add(funcname, __FILE__, lineno); XML_StopParser(self->itself, XML_FALSE); @@ -343,44 +362,54 @@ call_character_handler(xmlparseobject *self, const XML_Char *buffer, int len) if (!have_handler(self, CharacterData)) return -1; - args = PyTuple_New(1); - if (args == NULL) - return -1; - temp = (conv_string_len_to_unicode(buffer, len)); + /* Copy the buffer before tuple allocation can trigger a GC callback. */ + temp = conv_string_len_to_unicode(buffer, len); if (temp == NULL) { - Py_DECREF(args); flag_error(self); XML_SetCharacterDataHandler(self->itself, noop_character_data_handler); return -1; } + args = PyTuple_New(1); + if (args == NULL) { + Py_DECREF(temp); + return -1; + } PyTuple_SET_ITEM(args, 0, temp); /* temp is now a borrowed reference; consider it unused. */ + if (!have_handler(self, CharacterData)) { + Py_DECREF(args); + return 0; + } self->in_callback = 1; temp = call_with_frame("CharacterData", __LINE__, self->handlers[CharacterData], args, self); /* temp is an owned reference again, or NULL */ - self->in_callback = 0; Py_DECREF(args); if (temp == NULL) { + self->in_callback = 0; flag_error(self); XML_SetCharacterDataHandler(self->itself, noop_character_data_handler); return -1; } + /* Releasing the result can run arbitrary code, which must still be + treated as being within the callback by the handler setter. */ Py_DECREF(temp); + self->in_callback = 0; return 0; } static int flush_character_buffer(xmlparseobject *self) { - int rc; if (self->buffer == NULL || self->buffer_used == 0) return 0; - rc = call_character_handler(self, self->buffer, self->buffer_used); + int len = self->buffer_used; + /* The callback may change buffering or install a new handler, which + also flushes. Do not expose the same pending data a second time. */ self->buffer_used = 0; - return rc; + return call_character_handler(self, self->buffer, len); } static void @@ -391,27 +420,22 @@ my_CharacterDataHandler(void *userData, const XML_Char *data, int len) if (PyErr_Occurred()) return; - if (self->buffer == NULL) + if (self->buffer != NULL && + len > (self->buffer_size - self->buffer_used)) { + if (flush_character_buffer(self) < 0) + return; + /* The callback may replace the handler or disable buffering. */ + if (!have_handler(self, CharacterData)) + return; + } + if (self->buffer == NULL || + len > (self->buffer_size - self->buffer_used)) { call_character_handler(self, data, len); + } else { - if (len > (self->buffer_size - self->buffer_used)) { - if (flush_character_buffer(self) < 0) - return; - /* handler might have changed; drop the rest on the floor - * if there isn't a handler anymore - */ - if (!have_handler(self, CharacterData)) - return; - } - if (len > self->buffer_size) { - call_character_handler(self, data, len); - self->buffer_used = 0; - } - else { - memcpy(self->buffer + self->buffer_used, - data, len * sizeof(XML_Char)); - self->buffer_used += len; - } + memcpy(self->buffer + self->buffer_used, + data, len * sizeof(XML_Char)); + self->buffer_used += len; } } @@ -442,7 +466,9 @@ my_StartElementHandler(void *userData, max += 2; } /* Build the container. */ - if (self->ordered_attributes) + /* Intern-dictionary comparisons can change the mode mid-loop. */ + int ordered_attributes = self->ordered_attributes; + if (ordered_attributes) container = PyList_New(max); else container = PyDict_New(); @@ -465,7 +491,7 @@ my_StartElementHandler(void *userData, Py_DECREF(n); return; } - if (self->ordered_attributes) { + if (ordered_attributes) { PyList_SET_ITEM(container, i, n); PyList_SET_ITEM(container, i+1, v); } @@ -491,6 +517,10 @@ my_StartElementHandler(void *userData, return; } /* Container is now a borrowed reference; ignore it. */ + if (!have_handler(self, StartElement)) { + Py_DECREF(args); + return; + } self->in_callback = 1; rv = call_with_frame("StartElement", __LINE__, self->handlers[StartElement], args, self); @@ -547,18 +577,26 @@ my_ ## NAME ## Handler PARAMS { \ flag_error(self); \ return RETURN_VARIABLE; \ } \ + if (!have_handler(self, NAME)) { \ + Py_DECREF(args); \ + return RETURN_VARIABLE; \ + } \ self->in_callback = 1; \ PyObject *rv = call_with_frame( \ #NAME, __LINE__, \ self->handlers[NAME], args, self); \ - self->in_callback = 0; \ Py_DECREF(args); \ if (rv == NULL) { \ + self->in_callback = 0; \ flag_error(self); \ return RETURN_VARIABLE; \ } \ CONVERSION \ + /* Releasing the result can run arbitrary code, \ + which must still be treated as being within \ + the callback by the handler setter. */ \ Py_DECREF(rv); \ + self->in_callback = 0; \ if (PyErr_Occurred()) { \ invalid_expat_handler_rv(#NAME); \ } \ @@ -695,6 +733,9 @@ my_ElementDeclHandler(void *userData, flag_error(self); goto finally; } + if (!have_handler(self, ElementDecl)) { + goto finally; + } self->in_callback = 1; rv = call_with_frame("ElementDecl", __LINE__, self->handlers[ElementDecl], args, self); @@ -806,6 +847,18 @@ VOID_HANDLER(StartDoctypeDecl, VOID_HANDLER(EndDoctypeDecl, (void *userData), ("()")) +/* check that the current function is not called from within a handler */ +#define CHECK_NOT_IN_HANDLER(PARSER, FUNCNAME) \ + do { \ + if (PARSER->in_callback) { \ + PyErr_SetString(PyExc_RuntimeError, \ + "cannot call " FUNCNAME "() " \ + "from within a handler"); \ + return NULL; \ + } \ + } while (0) + + /* ---------------------------------------------------------------- */ /*[clinic input] class pyexpat.xmlparser "xmlparseobject *" "&Xmlparsetype" @@ -876,14 +929,19 @@ pyexpat.xmlparser.Parse Parse XML data. +'data' can be a bytes-like object or a string. If it is a string, +the encoding declaration in the XML data is ignored. 'isfinal' should be true at end of input. [clinic start generated code]*/ static PyObject * pyexpat_xmlparser_Parse_impl(xmlparseobject *self, PyTypeObject *cls, PyObject *data, int isfinal) -/*[clinic end generated code: output=8faffe07fe1f862a input=053e0f047e55c05a]*/ +/*[clinic end generated code: output=8faffe07fe1f862a input=f8f3ba4eadf837e5]*/ { + // avoid re-entrant calls to XML_Parse() + CHECK_NOT_IN_HANDLER(self, "Parse"); + const char *s; Py_ssize_t slen; Py_buffer view; @@ -975,14 +1033,19 @@ pyexpat.xmlparser.ParseFile file: object / -Parse XML data from file-like object. +Parse XML data from a binary file-like object. + +Its read() method should return bytes. [clinic start generated code]*/ static PyObject * pyexpat_xmlparser_ParseFile_impl(xmlparseobject *self, PyTypeObject *cls, PyObject *file) -/*[clinic end generated code: output=34780a094c8ca3ae input=ba4bc9c541684793]*/ +/*[clinic end generated code: output=34780a094c8ca3ae input=c96030cf5e4f577e]*/ { + // avoid re-entrant calls to XML_GetBuffer() or XML_ParseBuffer() + CHECK_NOT_IN_HANDLER(self, "ParseFile"); + int rv = 1; PyObject *readmethod = NULL; @@ -1055,28 +1118,56 @@ pyexpat_xmlparser_GetBase_impl(xmlparseobject *self) } /*[clinic input] -@permit_long_summary +pyexpat.xmlparser.GetSpecifiedAttributeCount + +Return the index just past the attributes given in the start tag. + +Attributes defaulted from the DTD follow the specified ones, so +attributes at lower indices in the list passed to +StartElementHandler were given in the start tag. Each attribute +takes two items in that list, its name and its value. Only +meaningful inside a StartElementHandler call, and only if +ordered_attributes is true. +[clinic start generated code]*/ + +static PyObject * +pyexpat_xmlparser_GetSpecifiedAttributeCount_impl(xmlparseobject *self) +/*[clinic end generated code: output=f96b627de9393c0c input=f9f66f840b9dd16b]*/ +{ + return PyLong_FromLong(XML_GetSpecifiedAttributeCount(self->itself)); +} + +/*[clinic input] pyexpat.xmlparser.GetInputContext -Return the untranslated text of the input that caused the current event. +Return the input which generated the current event as bytes. -If the event was generated by a large amount of text (such as -a start tag for an element with many attributes), not all of the -text may be available. +The data is in the encoding of the entity which contains the text. +It extends to the end of the currently buffered input, therefore it +can contain also the data of the following events, and if the event +was generated by a large amount of text, not all of it may be +available. [clinic start generated code]*/ static PyObject * pyexpat_xmlparser_GetInputContext_impl(xmlparseobject *self) -/*[clinic end generated code: output=a88026d683fc22cc input=a672f48f09bb73d2]*/ +/*[clinic end generated code: output=a88026d683fc22cc input=2d605aaa9edbb415]*/ { if (self->in_callback) { +#if XML_COMBINED_VERSION >= 20900 + int64_t offset; + uint64_t size; + const char *buffer + = XML_GetInputContext64(self->itself, &offset, &size); +#else int offset, size; const char *buffer = XML_GetInputContext(self->itself, &offset, &size); +#endif if (buffer != NULL) return PyBytes_FromStringAndSize(buffer + offset, - size - offset); + (Py_ssize_t)(size - offset)); else Py_RETURN_NONE; } @@ -1118,6 +1209,7 @@ pyexpat_xmlparser_ExternalEntityParserCreate_impl(xmlparseobject *self, new_parser->specified_attributes = self->specified_attributes; new_parser->in_callback = 0; new_parser->ns_prefixes = self->ns_prefixes; + new_parser->reparse_deferral_enabled = self->reparse_deferral_enabled; new_parser->itself = XML_ExternalEntityParserCreate(self->itself, context, encoding); // The new subparser will make use of the parent XML_Parser inside of Expat. @@ -1418,6 +1510,7 @@ static struct PyMethodDef xmlparse_methods[] = { PYEXPAT_XMLPARSER_PARSEFILE_METHODDEF PYEXPAT_XMLPARSER_SETBASE_METHODDEF PYEXPAT_XMLPARSER_GETBASE_METHODDEF + PYEXPAT_XMLPARSER_GETSPECIFIEDATTRIBUTECOUNT_METHODDEF PYEXPAT_XMLPARSER_GETINPUTCONTEXT_METHODDEF PYEXPAT_XMLPARSER_EXTERNALENTITYPARSERCREATE_METHODDEF PYEXPAT_XMLPARSER_SETPARAMENTITYPARSING_METHODDEF @@ -1755,8 +1848,14 @@ xmlparse_handler_setter(PyObject *op, PyObject *v, void *closure) active, so Expat does a little more work than it otherwise would, but that's really an odd case. A more elaborate system of handlers and state could remove the - C handler more effectively. */ - if (handlernum == CharacterData && self->in_callback) { + C handler more effectively. The same applies to the + default handler, which Expat can call several times for one + piece of text, such as a long comment in a document that is + not UTF-8. */ + if (self->in_callback + && (handlernum == CharacterData + || handlernum == Default + || handlernum == DefaultHandlerExpand)) { c_handler = (xmlhandler)noop_character_data_handler; } v = NULL; @@ -1770,20 +1869,20 @@ xmlparse_handler_setter(PyObject *op, PyObject *v, void *closure) return 0; } -#define INT_GETTER(name) \ +#define INT_GETTER(name, func) \ static PyObject * \ xmlparse_##name##_getter(PyObject *op, void *Py_UNUSED(closure)) \ { \ xmlparseobject *self = xmlparseobject_CAST(op); \ - return PyLong_FromLong((long)XML_Get##name(self->itself)); \ + return PyLong_FromLongLong((long long)func(self->itself)); \ } -INT_GETTER(ErrorCode) -INT_GETTER(ErrorLineNumber) -INT_GETTER(ErrorColumnNumber) -INT_GETTER(ErrorByteIndex) -INT_GETTER(CurrentLineNumber) -INT_GETTER(CurrentColumnNumber) -INT_GETTER(CurrentByteIndex) +INT_GETTER(ErrorCode, XML_GetErrorCode) +INT_GETTER(ErrorLineNumber, EXPAT_GetCurrentLineNumber) +INT_GETTER(ErrorColumnNumber, EXPAT_GetCurrentColumnNumber) +INT_GETTER(ErrorByteIndex, EXPAT_GetCurrentByteIndex) +INT_GETTER(CurrentLineNumber, EXPAT_GetCurrentLineNumber) +INT_GETTER(CurrentColumnNumber, EXPAT_GetCurrentColumnNumber) +INT_GETTER(CurrentByteIndex, EXPAT_GetCurrentByteIndex) #undef INT_GETTER @@ -2408,6 +2507,78 @@ pyexpat_capsule_destructor(PyObject *capsule) } +PyDoc_STRVAR(version_info__doc__, +"pyexpat.version_info\n\ +\n\ +Expat version information as a named tuple."); + +static PyStructSequence_Field version_info_fields[] = { + {"major", "Major release number"}, + {"minor", "Minor release number"}, + {"micro", "Micro release number"}, + {0} +}; + +static PyStructSequence_Desc version_info_desc = { + "pyexpat.version_info", /* name */ + version_info__doc__, /* doc */ + version_info_fields, /* fields */ + 3 +}; + +static PyObject * +make_version_info(PyTypeObject *type, int major, int minor, int micro) +{ + PyObject *version; + int pos = 0; + + version = PyStructSequence_New(type); + if (version == NULL) { + return NULL; + } + +#define SetItem(VALUE) \ + PyStructSequence_SET_ITEM(version, pos++, VALUE); \ + if (PyErr_Occurred()) { \ + Py_DECREF(version); \ + return NULL; \ + } + + SetItem(PyLong_FromLong(major)) + SetItem(PyLong_FromLong(minor)) + SetItem(PyLong_FromLong(micro)) +#undef SetItem + + return version; +} + +static int +add_version_info(PyObject *mod) +{ + PyTypeObject *version_type; + version_type = PyStructSequence_NewType(&version_info_desc); + if (version_type == NULL) { + return -1; + } + if (PyModule_Add(mod, "VERSION_INFO", + make_version_info(version_type, XML_MAJOR_VERSION, + XML_MINOR_VERSION, XML_MICRO_VERSION)) < 0) + { + Py_DECREF(version_type); + return -1; + } + XML_Expat_Version info = XML_ExpatVersionInfo(); + if (PyModule_Add(mod, "version_info", + make_version_info(version_type, info.major, + info.minor, info.micro)) < 0) + { + Py_DECREF(version_type); + return -1; + } + Py_DECREF(version_type); + return 0; +} + static int pyexpat_exec(PyObject *mod) { @@ -2451,15 +2622,8 @@ pyexpat_exec(PyObject *mod) XML_ExpatVersion()) < 0) { return -1; } - { - XML_Expat_Version info = XML_ExpatVersionInfo(); - PyObject *versionInfo = Py_BuildValue("(iii)", - info.major, - info.minor, - info.micro); - if (PyModule_Add(mod, "version_info", versionInfo) < 0) { - return -1; - } + if (add_version_info(mod) < 0) { + return -1; } /* XXX When Expat supports some way of figuring out how it was compiled, this should check and set native_encoding @@ -2507,8 +2671,11 @@ pyexpat_exec(PyObject *mod) capi->MICRO_VERSION = XML_MICRO_VERSION; capi->ErrorString = XML_ErrorString; capi->GetErrorCode = XML_GetErrorCode; +_Py_COMP_DIAG_PUSH +_Py_COMP_DIAG_IGNORE_DEPR_DECLS capi->GetErrorColumnNumber = XML_GetErrorColumnNumber; capi->GetErrorLineNumber = XML_GetErrorLineNumber; +_Py_COMP_DIAG_POP capi->Parse = XML_Parse; capi->ParserCreate_MM = XML_ParserCreate_MM; capi->ParserFree = XML_ParserFree; @@ -2524,7 +2691,10 @@ pyexpat_exec(PyObject *mod) capi->SetEncoding = XML_SetEncoding; capi->DefaultUnknownEncodingHandler = PyUnknownEncodingHandler; #if XML_COMBINED_VERSION >= 20100 +_Py_COMP_DIAG_PUSH +_Py_COMP_DIAG_IGNORE_DEPR_DECLS capi->SetHashSalt = XML_SetHashSalt; +_Py_COMP_DIAG_POP #else capi->SetHashSalt = NULL; #endif @@ -2632,7 +2802,17 @@ clear_handlers(xmlparseobject *self, int initial) } else { Py_CLEAR(self->handlers[i]); - CALL_XML_HANDLER_SETTER(&handler_info[i], self->itself, NULL); + xmlhandler c_handler = NULL; + if (i == Default || i == DefaultHandlerExpand) { + /* This may be called from within a callback, where the + default handler can't be removed: for a document that is + not UTF-8, Expat passes a long piece of text to it in + several calls and re-reads the handler before each one + (reportDefault() in xmlparse.c). The no-op handler is + harmless otherwise. */ + c_handler = (xmlhandler)noop_character_data_handler; + } + CALL_XML_HANDLER_SETTER(&handler_info[i], self->itself, c_handler); } } } diff --git a/Modules/readline.c b/Modules/readline.c index 4c965e081c9d1a7..fab0d9aeaa80aeb 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -10,16 +10,27 @@ /* Standard definitions */ #include "Python.h" +#include "pycore_fileutils.h" // _Py_open_noraise() #include "pycore_pyatomic_ft_wrappers.h" #include "pycore_pylifecycle.h" // _Py_SetLocaleFromEnv() #include // errno +#include // getpwuid_r() #include // SIGWINCH #include // free() #include // strdup() +#ifdef HAVE_FCNTL_H +# include // O_RDWR +#endif #ifdef HAVE_SYS_SELECT_H # include // select() #endif +#ifdef HAVE_SYS_STAT_H +# include // fstat() +#endif +#ifdef HAVE_UNISTD_H +# include // ftruncate() +#endif #if defined(HAVE_SETLOCALE) /* GNU readline() mistakenly sets the LC_CTYPE locale. @@ -319,6 +330,176 @@ readline_read_history_file_impl(PyObject *module, PyObject *filename_obj) static int _history_length = -1; /* do not truncate history by default */ +#ifndef __APPLE__ +/* macOS libedit carries a patch fixing the bug this works around. */ +/* Return libedit's default history file, "~/.history". This must resolve + * the same file as libedit's private _default_history_file() + * (https://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libedit/readline.c) so that we + * truncate the same file write_history() and append_history() just wrote: the + * home directory comes from the password database, $HOME is not consulted. + * The result must be freed with PyMem_RawFree(). */ +static char * +_py_libedit_default_history_file(void) +{ + struct passwd *pw = NULL; + char *path = NULL; +#ifdef HAVE_GETPWUID_R + struct passwd pwd; + char *buf = NULL; + Py_ssize_t bufsize = sysconf(_SC_GETPW_R_SIZE_MAX); + if (bufsize == -1) { + bufsize = 1024; + } + for (;;) { + char *newbuf = PyMem_RawRealloc(buf, bufsize); + if (newbuf == NULL) { + break; + } + buf = newbuf; + int status = getpwuid_r(getuid(), &pwd, buf, bufsize, &pw); + if (status == 0) { + break; + } + pw = NULL; + if (status != ERANGE || bufsize > (PY_SSIZE_T_MAX >> 1)) { + break; + } + bufsize <<= 1; + } +#else + pw = getpwuid(getuid()); +#endif + if (pw != NULL && pw->pw_dir != NULL) { + size_t len = strlen(pw->pw_dir) + sizeof("/.history"); + path = PyMem_RawMalloc(len); + if (path != NULL) { + PyOS_snprintf(path, len, "%s/.history", pw->pw_dir); + } + } +#ifdef HAVE_GETPWUID_R + PyMem_RawFree(buf); +#endif + return path; +} + +/* libedit's history_truncate_file() keeps the last nlines lines of the + * file, which drops the "_HiStOrY_V2_" header line that its own + * write_history() emits and that its read_history() requires: once + * truncated, the file can no longer be loaded (gh-123018). Truncate the + * file ourselves and keep the header. + * + * Upstream libedit (NetBSD, and the portable releases from thrysoee.dk) + * still has this bug, reported as https://gnats.netbsd.org/60322. Apple's + * libedit fork patches its history_truncate_file() to copy the first line, + * so this workaround is not compiled on macOS. We only keep the header + * when it is actually there, so a file without one (e.g. written by GNU + * readline) is not given a bogus header. + * + * History files are small, so the whole file is read into memory and + * rewritten in place, as libedit does. GNU readline instead writes a + * temporary file and renames it over the original. */ +static int +_py_libedit_history_truncate_file(const char *filename, int nlines) +{ + static const char cookie[] = "_HiStOrY_V2_\n"; + const size_t cookie_len = sizeof(cookie) - 1; + char *default_file = NULL; + char *buf = NULL; + FILE *fp = NULL; + int ret = -1; + + if (filename == NULL) { + default_file = _py_libedit_default_history_file(); + if (default_file == NULL) { + return -1; + } + filename = default_file; + } + int fd = _Py_open_noraise(filename, O_RDWR); + if (fd < 0) { + goto done; + } + fp = fdopen(fd, "r+"); + if (fp == NULL) { + close(fd); + goto done; + } + struct stat st; + if (fstat(fd, &st) != 0) { + goto done; + } + size_t size = (size_t)st.st_size; + buf = PyMem_RawMalloc(size); + if (buf == NULL || fread(buf, 1, size, fp) != size) { + goto done; + } + + size_t header = 0; + if (size >= cookie_len && memcmp(buf, cookie, cookie_len) == 0) { + header = cookie_len; + } + const char *end = buf + size; + + /* Count the lines following the header. */ + size_t total = 0; + for (const char *p = buf + header; + (p = memchr(p, '\n', end - p)) != NULL; + p++) { + total++; + } + if (end > buf + header && end[-1] != '\n') { + total++; /* an unterminated last line */ + } + if (total <= (size_t)nlines) { + ret = 0; /* nothing to drop */ + goto done; + } + + /* Skip the leading lines, keeping the header and the last nlines. */ + const char *tail = buf + header; + for (size_t skip = total - (size_t)nlines; skip > 0; skip--) { + const char *nl = memchr(tail, '\n', end - tail); + if (nl == NULL) { + tail = end; /* the unterminated last line is dropped too */ + break; + } + tail = nl + 1; + } + size_t taillen = end - tail; + if (fseek(fp, 0, SEEK_SET) != 0 + || fwrite(buf, 1, header, fp) != header + || fwrite(tail, 1, taillen, fp) != taillen + || fflush(fp) != 0 + || ftruncate(fd, (off_t)(header + taillen)) != 0) { + goto done; + } + ret = 0; + +done: + if (fp != NULL) { + fclose(fp); + } + PyMem_RawFree(buf); + PyMem_RawFree(default_file); + return ret; +} +#endif /* !__APPLE__ */ + +/* Truncate the history file after write_history() or append_history(). + * Like the history_truncate_file() calls this replaces, failures are + * ignored by the callers: the history was already saved successfully and + * a failed truncation only leaves the file longer than requested. */ +static int +_py_history_truncate_file(const char *filename, int nlines) +{ +#ifndef __APPLE__ + if (using_libedit_emulation) { + return _py_libedit_history_truncate_file(filename, nlines); + } +#endif + return history_truncate_file(filename, nlines); +} + /* Exported function to save a readline history file */ /*[clinic input] @@ -360,7 +541,7 @@ readline_write_history_file_impl(PyObject *module, PyObject *filename_obj) errno = err = write_history(filename); int history_length = FT_ATOMIC_LOAD_INT_RELAXED(_history_length); if (!err && history_length >= 0) - history_truncate_file(filename, history_length); + _py_history_truncate_file(filename, history_length); Py_XDECREF(filename_bytes); errno = err; if (errno) @@ -419,7 +600,7 @@ readline_append_history_file_impl(PyObject *module, int nelements, nelements - libedit_append_replace_history_offset, filename); int history_length = FT_ATOMIC_LOAD_INT_RELAXED(_history_length); if (!err && history_length >= 0) - history_truncate_file(filename, history_length); + _py_history_truncate_file(filename, history_length); Py_XDECREF(filename_bytes); errno = err; if (errno) @@ -578,6 +759,7 @@ readline_set_pre_input_hook_impl(PyObject *module, PyObject *function) /* Get pre-input hook */ /*[clinic input] +@critical_section readline.get_pre_input_hook Get the current pre-input hook function. @@ -585,7 +767,7 @@ Get the current pre-input hook function. static PyObject * readline_get_pre_input_hook_impl(PyObject *module) -/*[clinic end generated code: output=ad56b77a8e8981ca input=fb1e1b1fbd94e4e5]*/ +/*[clinic end generated code: output=ad56b77a8e8981ca input=fbbf0106bd015414]*/ { readlinestate *state = get_readline_state(module); if (state->pre_input_hook == NULL) { @@ -886,6 +1068,7 @@ readline_set_completer_impl(PyObject *module, PyObject *function) } /*[clinic input] +@critical_section readline.get_completer Get the current completer function. @@ -893,7 +1076,7 @@ Get the current completer function. static PyObject * readline_get_completer_impl(PyObject *module) -/*[clinic end generated code: output=6e6bbd8226d14475 input=6457522e56d70d13]*/ +/*[clinic end generated code: output=6e6bbd8226d14475 input=0df9ba4107115c44]*/ { readlinestate *state = get_readline_state(module); if (state->completer == NULL) { @@ -1325,10 +1508,19 @@ flex_complete(const char *text, int start, int end) done: if (state) { - Py_XDECREF(state->begidx); - Py_XDECREF(state->endidx); - state->begidx = PyLong_FromLong((long) start); - state->endidx = PyLong_FromLong((long) end); + PyObject *begidx = PyLong_FromLong((long) start); + PyObject *endidx = PyLong_FromLong((long) end); + if (begidx == NULL || endidx == NULL) { + Py_XDECREF(begidx); + Py_XDECREF(endidx); + PyErr_FormatUnraisable("Exception ignored while preparing " + "readline completion"); + rl_attempted_completion_over = 1; + PyGILState_Release(gilstate); + return NULL; + } + Py_XSETREF(state->begidx, begidx); + Py_XSETREF(state->endidx, endidx); } result = completion_matches((char *)text, *on_completion); PyGILState_Release(gilstate); @@ -1351,7 +1543,7 @@ setup_readline(readlinestate *mod_state) /* The name must be defined before initialization */ rl_readline_name = "python"; -#ifdef HAVE_RL_CHANGE_ENVIRONMENT +#ifdef _Py_HAVE_RL_CHANGE_ENVIRONMENT /* Prevent readline from setting the LINES and COLUMNS environment * variables: ncurses prefers them over an ioctl() query, so a stale value * left after a resize breaks SIGWINCH / KEY_RESIZE handling (gh-46927). */ @@ -1619,6 +1811,96 @@ call_readline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt) } +PyDoc_STRVAR(readline_version_info__doc__, +"readline.readline_version_info\n\ +\n\ +Readline version information as a named tuple."); + +static PyStructSequence_Field readline_version_info_fields[] = { + {"major", "Major release number"}, + {"minor", "Minor release number"}, + {0} +}; + +static PyStructSequence_Desc readline_version_info_desc = { + "readline.readline_version_info", /* name */ + readline_version_info__doc__, /* doc */ + readline_version_info_fields, /* fields */ + 2 +}; + +static PyObject * +make_readline_version_info(PyTypeObject *type, int number) +{ + PyObject *version; + int pos = 0; + int major = (number >> 8) & 0xff; + int minor = number & 0xff; + + version = PyStructSequence_New(type); + if (version == NULL) { + return NULL; + } + +#define SetItem(VALUE) \ + PyStructSequence_SET_ITEM(version, pos++, VALUE); \ + if (PyErr_Occurred()) { \ + Py_DECREF(version); \ + return NULL; \ + } + + SetItem(PyLong_FromLong(major)) + SetItem(PyLong_FromLong(minor)) +#undef SetItem + + return version; +} + +static int +add_version_constants(PyObject *m) +{ + if (PyModule_AddIntConstant(m, "_READLINE_VERSION", + RL_READLINE_VERSION) < 0) { + return -1; + } + if (PyModule_AddIntConstant(m, "_READLINE_RUNTIME_VERSION", + rl_readline_version) < 0) { + return -1; + } + PyObject *obj = PyUnicode_FromString(rl_library_version); + if (obj == NULL) { + return -1; + } + if (PyModule_AddObjectRef(m, "readline_version", obj) < 0 || + PyModule_AddObjectRef(m, "_READLINE_LIBRARY_VERSION", obj) < 0) + { + Py_DECREF(obj); + return -1; + } + Py_DECREF(obj); + PyTypeObject *version_type; + version_type = PyStructSequence_NewType(&readline_version_info_desc); + if (version_type == NULL) { + return -1; + } + if (PyModule_Add(m, "READLINE_VERSION_INFO", + make_readline_version_info(version_type, + RL_READLINE_VERSION)) < 0) + { + Py_DECREF(version_type); + return -1; + } + if (PyModule_Add(m, "readline_version_info", + make_readline_version_info(version_type, + rl_readline_version)) < 0) + { + Py_DECREF(version_type); + return -1; + } + Py_DECREF(version_type); + return 0; +} + /* Initialize the module */ PyDoc_STRVAR(doc_module, @@ -1670,17 +1952,7 @@ PyInit_readline(void) PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED); #endif - if (PyModule_AddIntConstant(m, "_READLINE_VERSION", - RL_READLINE_VERSION) < 0) { - goto error; - } - if (PyModule_AddIntConstant(m, "_READLINE_RUNTIME_VERSION", - rl_readline_version) < 0) { - goto error; - } - if (PyModule_AddStringConstant(m, "_READLINE_LIBRARY_VERSION", - rl_library_version) < 0) - { + if (add_version_constants(m) < 0) { goto error; } diff --git a/Modules/resource.c b/Modules/resource.c index 9bf8d2782766ccb..614b05769869a1e 100644 --- a/Modules/resource.c +++ b/Modules/resource.c @@ -22,22 +22,6 @@ module resource [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=e89d38ed52609d7c]*/ -/*[python input] -class pid_t_converter(CConverter): - type = 'pid_t' - format_unit = '" _Py_PARSE_PID "' - - def parse_arg(self, argname, displayname, *, limited_capi): - return self.format_code(""" - {paramname} = PyLong_AsPid({argname}); - if ({paramname} == -1 && PyErr_Occurred()) {{{{ - goto exit; - }}}} - """, - argname=argname) -[python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=c94349aa1aad151d]*/ - #include "clinic/resource.c.h" PyDoc_STRVAR(struct_rusage__doc__, diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 2c56dbc6a541f7a..63ccd1d0f6cbd08 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -54,11 +54,6 @@ #include #endif -#ifdef __sgi -/* This is missing from unistd.h */ -extern void bzero(void *, int); -#endif - #ifdef HAVE_SYS_TYPES_H #include #endif @@ -2365,9 +2360,11 @@ select_kqueue_control_impl(kqueue_queue_Object *self, PyObject *changelist, else { if (_PyTime_FromSecondsObject(&timeout, otimeout, _PyTime_ROUND_TIMEOUT) < 0) { - PyErr_Format(PyExc_TypeError, - "timeout must be a real number or None, not %T", - otimeout); + if (PyErr_ExceptionMatches(PyExc_TypeError)) { + PyErr_Format(PyExc_TypeError, + "timeout must be a real number or None, not %T", + otimeout); + } return NULL; } diff --git a/Modules/sha1module.c b/Modules/sha1module.c index 5681780b569b6cb..28fb73605f3f511 100644 --- a/Modules/sha1module.c +++ b/Modules/sha1module.c @@ -75,6 +75,7 @@ newSHA1object(SHA1State *st) return NULL; } HASHLIB_INIT_MUTEX(sha); + sha->hash_state = NULL; // PyObject_GC_New() does not zero memory PyObject_GC_Track(sha); return sha; @@ -85,13 +86,13 @@ newSHA1object(SHA1State *st) static void SHA1_dealloc(PyObject *op) { + PyTypeObject *tp = Py_TYPE(op); + PyObject_GC_UnTrack(op); SHA1object *ptr = _SHA1object_CAST(op); if (ptr->hash_state != NULL) { Hacl_Hash_SHA1_free(ptr->hash_state); ptr->hash_state = NULL; } - PyTypeObject *tp = Py_TYPE(ptr); - PyObject_GC_UnTrack(ptr); PyObject_GC_Del(ptr); Py_DECREF(tp); } diff --git a/Modules/sha2module.c b/Modules/sha2module.c index 7613ee54954dd6c..d3801f2b4d232dc 100644 --- a/Modules/sha2module.c +++ b/Modules/sha2module.c @@ -146,6 +146,7 @@ newSHA384object(sha2_state *state) return NULL; } HASHLIB_INIT_MUTEX(sha); + sha->state = NULL; // PyObject_GC_New() does not zero memory PyObject_GC_Track(sha); return sha; @@ -159,6 +160,7 @@ newSHA512object(sha2_state *state) return NULL; } HASHLIB_INIT_MUTEX(sha); + sha->state = NULL; // PyObject_GC_New() does not zero memory PyObject_GC_Track(sha); return sha; @@ -168,13 +170,13 @@ newSHA512object(sha2_state *state) static void SHA256_dealloc(PyObject *op) { + PyTypeObject *tp = Py_TYPE(op); + PyObject_GC_UnTrack(op); SHA256object *ptr = _SHA256object_CAST(op); if (ptr->state != NULL) { Hacl_Hash_SHA2_free_256(ptr->state); ptr->state = NULL; } - PyTypeObject *tp = Py_TYPE(ptr); - PyObject_GC_UnTrack(ptr); PyObject_GC_Del(ptr); Py_DECREF(tp); } @@ -182,13 +184,13 @@ SHA256_dealloc(PyObject *op) static void SHA512_dealloc(PyObject *op) { + PyTypeObject *tp = Py_TYPE(op); + PyObject_GC_UnTrack(op); SHA512object *ptr = _SHA512object_CAST(op); if (ptr->state != NULL) { Hacl_Hash_SHA2_free_512(ptr->state); ptr->state = NULL; } - PyTypeObject *tp = Py_TYPE(ptr); - PyObject_GC_UnTrack(ptr); PyObject_GC_Del(ptr); Py_DECREF(tp); } diff --git a/Modules/sha3module.c b/Modules/sha3module.c index 3ddd0323575b708..f0cb60d04caac7d 100644 --- a/Modules/sha3module.c +++ b/Modules/sha3module.c @@ -67,6 +67,12 @@ sha3_get_state(PyObject *module) typedef struct { HASHLIB_OBJECT_HEAD Hacl_Hash_SHA3_state_t *hash_state; + // HACL* update functions entirely replace the state, which can lead + // to races on the free-threaded build. Since the kind of hash is static, + // we can store its corresponding metadata once. + uint32_t digest_size; + uint32_t block_size; + int is_shake; } SHA3object; #define _SHA3object_CAST(op) ((SHA3object *)(op)) @@ -96,7 +102,8 @@ newSHA3object(PyTypeObject *type) return NULL; } HASHLIB_INIT_MUTEX(newobj); - + newobj->hash_state = NULL; // PyObject_GC_New() does not zero memory + newobj->digest_size = newobj->block_size = 0; PyObject_GC_Track(newobj); return newobj; } @@ -179,6 +186,11 @@ py_sha3_new_impl(PyTypeObject *type, PyObject *data_obj, int usedforsecurity, goto error; } + // set the metadata once we know that the state is valid + int is_shake = Hacl_Hash_SHA3_is_shake(self->hash_state); + self->digest_size = is_shake ? 0 : Hacl_Hash_SHA3_hash_len(self->hash_state); + self->block_size = Hacl_Hash_SHA3_block_len(self->hash_state); + if (data) { GET_BUFFER_VIEW_OR_ERROR(data, &buf, goto error); /* Do not use self->mutex here as this is the constructor @@ -223,7 +235,7 @@ SHA3_dealloc(PyObject *self) PyTypeObject *tp = Py_TYPE(self); PyObject_GC_UnTrack(self); (void)SHA3_clear(self); - tp->tp_free(self); + PyObject_GC_Del(self); Py_DECREF(tp); } @@ -253,6 +265,8 @@ _sha3_sha3_224_copy_impl(SHA3object *self, PyTypeObject *cls) Py_DECREF(newobj); return PyErr_NoMemory(); } + newobj->digest_size = self->digest_size; + newobj->block_size = self->block_size; return (PyObject *)newobj; } @@ -273,8 +287,7 @@ _sha3_sha3_224_digest_impl(SHA3object *self) HASHLIB_ACQUIRE_LOCK(self); (void)Hacl_Hash_SHA3_digest(self->hash_state, digest); HASHLIB_RELEASE_LOCK(self); - return PyBytes_FromStringAndSize((const char *)digest, - Hacl_Hash_SHA3_hash_len(self->hash_state)); + return PyBytes_FromStringAndSize((const char *)digest, self->digest_size); } @@ -292,8 +305,7 @@ _sha3_sha3_224_hexdigest_impl(SHA3object *self) HASHLIB_ACQUIRE_LOCK(self); (void)Hacl_Hash_SHA3_digest(self->hash_state, digest); HASHLIB_RELEASE_LOCK(self); - return _Py_strhex((const char *)digest, - Hacl_Hash_SHA3_hash_len(self->hash_state)); + return _Py_strhex((const char *)digest, self->digest_size); } @@ -334,8 +346,7 @@ static PyObject * SHA3_get_block_size(PyObject *op, void *Py_UNUSED(closure)) { SHA3object *self = _SHA3object_CAST(op); - uint32_t rate = Hacl_Hash_SHA3_block_len(self->hash_state); - return PyLong_FromLong(rate); + return PyLong_FromLong(self->block_size); } @@ -371,10 +382,7 @@ SHA3_get_digest_size(PyObject *op, void *Py_UNUSED(closure)) { // Preserving previous behavior: variable-length algorithms return 0 SHA3object *self = _SHA3object_CAST(op); - if (Hacl_Hash_SHA3_is_shake(self->hash_state)) - return PyLong_FromLong(0); - else - return PyLong_FromLong(Hacl_Hash_SHA3_hash_len(self->hash_state)); + return PyLong_FromLong(self->digest_size); } @@ -382,7 +390,7 @@ static PyObject * SHA3_get_capacity_bits(PyObject *op, void *Py_UNUSED(closure)) { SHA3object *self = _SHA3object_CAST(op); - uint32_t rate = Hacl_Hash_SHA3_block_len(self->hash_state) * 8; + uint32_t rate = self->block_size * 8; assert(rate <= 1600); int capacity = 1600 - rate; return PyLong_FromLong(capacity); @@ -393,8 +401,7 @@ static PyObject * SHA3_get_rate_bits(PyObject *op, void *Py_UNUSED(closure)) { SHA3object *self = _SHA3object_CAST(op); - uint32_t rate = Hacl_Hash_SHA3_block_len(self->hash_state) * 8; - return PyLong_FromLong(rate); + return PyLong_FromLong(self->block_size * 8); } static PyObject * diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index 8456239dee202d3..85ed113a17e5e81 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -53,6 +53,10 @@ # include #endif +#ifdef HAVE_SYS_PIDFD_H +# include // pidfd_send_signal() +#endif + #ifndef SIG_ERR # define SIG_ERR ((PyOS_sighandler_t)(-1)) #endif @@ -1300,15 +1304,16 @@ signal_pthread_kill_impl(PyObject *module, unsigned long thread_id, // This system call always crashes on older Android versions. -#if defined(__linux__) && defined(__NR_pidfd_send_signal) && \ - !(defined(__ANDROID__) && __ANDROID_API__ < 31) +#if defined(_Py_HAVE_PIDFD_SEND_SIGNAL) \ + || (defined(__linux__) && defined(__NR_pidfd_send_signal) \ + && !(defined(__ANDROID__) && __ANDROID_API__ < 31)) /*[clinic input] signal.pidfd_send_signal pidfd: int signalnum: int siginfo: object = None - flags: int = 0 + flags: unsigned_int(bitwise=True) = 0 / Send a signal to a process referred to by a pid file descriptor. @@ -1316,15 +1321,20 @@ Send a signal to a process referred to by a pid file descriptor. static PyObject * signal_pidfd_send_signal_impl(PyObject *module, int pidfd, int signalnum, - PyObject *siginfo, int flags) -/*[clinic end generated code: output=2d59f04a75d9cbdf input=2a6543a1f4ac2000]*/ + PyObject *siginfo, unsigned int flags) +/*[clinic end generated code: output=1804b5a19d269104 input=a6e82a3c264fa19d]*/ { if (siginfo != Py_None) { PyErr_SetString(PyExc_TypeError, "siginfo must be None"); return NULL; } - if (syscall(__NR_pidfd_send_signal, pidfd, signalnum, NULL, flags) < 0) { +#ifdef _Py_HAVE_PIDFD_SEND_SIGNAL + int res = pidfd_send_signal(pidfd, signalnum, NULL, flags); +#else + int res = syscall(__NR_pidfd_send_signal, pidfd, signalnum, NULL, flags); +#endif + if (res < 0) { PyErr_SetFromErrno(PyExc_OSError); return NULL; } @@ -1786,25 +1796,18 @@ PyErr_CheckSignals(void) _PyRunRemoteDebugger(tstate); #endif - if (_Py_ThreadCanHandleSignals(tstate->interp)) { - if (_PyErr_CheckSignalsTstate(tstate) < 0) { - return -1; - } + if (_PyErr_CheckSignalsTstate(tstate) < 0) { + return -1; } return 0; } -/* Declared in cpython/pyerrors.h */ -int -_PyErr_CheckSignalsTstate(PyThreadState *tstate) +// Out of line, to keep the common case of _PyErr_CheckSignalsTstate() cheap. +Py_NO_INLINE static int +run_tripped_handlers(PyThreadState *tstate) { - _Py_CHECK_EMSCRIPTEN_SIGNALS(); - if (!_Py_atomic_load_int(&is_tripped)) { - return 0; - } - /* * The is_tripped variable is meant to speed up the calls to * PyErr_CheckSignals (both directly or via pending calls) when no @@ -1885,6 +1888,20 @@ _PyErr_CheckSignalsTstate(PyThreadState *tstate) } +/* Declared in pycore_pyerrors.h */ +int +_PyErr_CheckSignalsTstate(PyThreadState *tstate) +{ + _Py_CHECK_EMSCRIPTEN_SIGNALS(); + if (!_Py_atomic_load_int(&is_tripped)) { + return 0; + } + if (!_Py_ThreadCanHandleSignals(tstate->interp)) { + return 0; + } + return run_tripped_handlers(tstate); +} + int _PyErr_CheckSignals(void) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 084c2dbcff066e5..7a76882e1633e10 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -190,7 +190,7 @@ shutdown(how) -- shut down traffic in one or both directions\n\ #ifdef HAVE_GETHOSTBYNAME_R # if defined(_AIX) && !defined(_LINUX_SOURCE_COMPAT) # define HAVE_GETHOSTBYNAME_R_3_ARG -# elif defined(__sun) || defined(__sgi) +# elif defined(__sun) # define HAVE_GETHOSTBYNAME_R_5_ARG # elif defined(__linux__) /* Rely on the configure script */ @@ -216,29 +216,6 @@ shutdown(how) -- shut down traffic in one or both directions\n\ # include #endif -#if defined(__sgi) && _COMPILER_VERSION>700 && !_SGIAPI -/* make sure that the reentrant (gethostbyaddr_r etc) - functions are declared correctly if compiling with - MIPSPro 7.x in ANSI C mode (default) */ - -/* XXX Using _SGIAPI is the wrong thing, - but I don't know what the right thing is. */ -#undef _SGIAPI /* to avoid warning */ -#define _SGIAPI 1 - -#undef _XOPEN_SOURCE -#include -#include -#include -#ifdef _SS_ALIGNSIZE -#define HAVE_GETADDRINFO 1 -#define HAVE_GETNAMEINFO 1 -#endif - -#define HAVE_INET_PTON -#include -#endif // __sgi - /* Solaris fails to define this variable at all. */ #if (defined(__sun) && defined(__SVR4)) && !defined(INET_ADDRSTRLEN) #define INET_ADDRSTRLEN 16 @@ -290,6 +267,10 @@ shutdown(how) -- shut down traffic in one or both directions\n\ /* Helpers needed for AF_HYPERV */ # include +#ifndef RPC_S_OK +#define RPC_S_OK 0L +#endif + /* Macros based on the IPPROTO enum, see: https://bugs.python.org/issue29515 */ #define IPPROTO_ICMP IPPROTO_ICMP #define IPPROTO_IGMP IPPROTO_IGMP @@ -414,16 +395,10 @@ remove_unusable_flags(PyObject *m) #endif /* include Python's addrinfo.h unless it causes trouble */ -#if defined(__sgi) && _COMPILER_VERSION>700 && defined(_SS_ALIGNSIZE) - /* Do not include addinfo.h on some newer IRIX versions. - * _SS_ALIGNSIZE is defined in sys/socket.h by 6.5.21, - * for example, but not by 6.5.10. - */ -#elif defined(_MSC_VER) && _MSC_VER>1201 - /* Do not include addrinfo.h for MSVC7 or greater. 'addrinfo' and - * EAI_* constants are defined in (the already included) ws2tcpip.h. - */ -#else +/* Do not include addrinfo.h for MSVC. 'addrinfo' and + * EAI_* constants are defined in (the already included) ws2tcpip.h. + */ +#if !defined(_MSC_VER) # include "addrinfo.h" #endif @@ -631,14 +606,14 @@ _PyLong_##NAME##_Converter(PyObject *obj, void *ptr) \ return 1; \ } -#if defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS) +#if defined(_Py_HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP) # ifdef MS_WINDOWS UNSIGNED_INT_CONVERTER(NetIfindex, NET_IFINDEX) # else # define _PyLong_NetIfindex_Converter _PyLong_UnsignedInt_Converter # define NET_IFINDEX unsigned int # endif -#endif // defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS) +#endif // defined(_Py_HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP) /*[python input] class NET_IFINDEX_converter(CConverter): @@ -692,6 +667,14 @@ class _socket.socket "PySocketSockObject *" "clinic_state()->sock_type" # undef HAVE_SETHOSTNAME #endif +/* The default family of socketpair() is AF_UNIX if defined on the + platform; otherwise, the default is AF_INET. */ +#if defined(AF_UNIX) +# define SOCKETPAIR_DEFAULT_FAMILY AF_UNIX +#else +# define SOCKETPAIR_DEFAULT_FAMILY AF_INET +#endif + #define clinic_state() (find_module_state_by_def(type)) #include "clinic/socketmodule.c.h" #undef clinic_state @@ -745,6 +728,16 @@ set_error(void) } +#if defined(HAVE_HSTRERROR) || defined(HAVE_GAI_STRERROR) +/* Decode a locale-encoded error message from the C library. + It can be localized and use a non-UTF-8 encoding. */ +static PyObject * +decode_error_message(const char *str) +{ + return PyUnicode_DecodeLocale(str, "surrogateescape"); +} +#endif + #if defined(HAVE_GETHOSTBYNAME_R) || defined (HAVE_GETHOSTBYNAME) || defined (HAVE_GETHOSTBYADDR) static PyObject * set_herror(socket_state *state, int h_error) @@ -752,7 +745,9 @@ set_herror(socket_state *state, int h_error) PyObject *v; #ifdef HAVE_HSTRERROR - v = Py_BuildValue("(is)", h_error, hstrerror(h_error)); + const char *errmsg = hstrerror(h_error); + _Py_MSAN_UNPOISON_STRING(errmsg); + v = Py_BuildValue("(iN)", h_error, decode_error_message(errmsg)); #else v = Py_BuildValue("(is)", h_error, "host not found"); #endif @@ -779,7 +774,9 @@ set_gaierror(socket_state *state, int error) #endif #ifdef HAVE_GAI_STRERROR - v = Py_BuildValue("(is)", error, gai_strerror(error)); + const char *errmsg = gai_strerror(error); + _Py_MSAN_UNPOISON_STRING(errmsg); + v = Py_BuildValue("(iN)", error, decode_error_message(errmsg)); #else v = Py_BuildValue("(is)", error, "getaddrinfo failed"); #endif @@ -806,7 +803,6 @@ internal_setblocking(PySocketSockObject *s, int block) int delay_flag, new_delay_flag; #endif - Py_BEGIN_ALLOW_THREADS #ifndef MS_WINDOWS #if (defined(HAVE_SYS_IOCTL_H) && defined(FIONBIO)) block = !block; @@ -833,8 +829,6 @@ internal_setblocking(PySocketSockObject *s, int block) result = 0; done: - Py_END_ALLOW_THREADS - if (result) { #ifndef MS_WINDOWS PyErr_SetFromErrno(PyExc_OSError); @@ -1760,6 +1754,9 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto) PyObject *vmId = PyUnicode_FromWideChar(guidStr, -1); res = RpcStringFreeW(&guidStr); assert(res == RPC_S_OK); + if (vmId == NULL) { + return 0; + } res = UuidToStringW(&a->ServiceId, &guidStr); if (res != RPC_S_OK) { @@ -1793,7 +1790,7 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto) (in particular, numeric IP addresses). */ struct maybe_idna { PyObject *obj; - char *buf; + const char *buf; }; static void @@ -3075,11 +3072,21 @@ sock_accept_impl(PySocketSockObject *s, void *data) /* s._accept() -> (fd, address) */ +/*[clinic input] +_socket.socket._accept + self as s: self(type="PySocketSockObject *") + +Wait for an incoming connection. + +Return a new socket file descriptor representing the connection, and +the address of the client. For IP sockets, the address info is a +pair (hostaddr, port). +[clinic start generated code]*/ + static PyObject * -sock_accept(PyObject *self, PyObject *Py_UNUSED(ignored)) +_socket_socket__accept_impl(PySocketSockObject *s) +/*[clinic end generated code: output=d24eca9a1d4c988e input=07959cdbb2f2a387]*/ { - PySocketSockObject *s = _PySocketSockObject_CAST(self); - sock_addr_t addrbuf; SOCKET_T newfd; socklen_t addrlen; @@ -3145,12 +3152,6 @@ sock_accept(PyObject *self, PyObject *Py_UNUSED(ignored)) return NULL; } -PyDoc_STRVAR(accept_doc, -"_accept() -> (integer, address info)\n\ -\n\ -Wait for an incoming connection. Return a new socket file descriptor\n\ -representing the connection, and the address of the client.\n\ -For IP sockets, the address info is a pair (hostaddr, port)."); #endif // defined(HAVE_ACCEPT) || defined(HAVE_ACCEPT4) @@ -3159,38 +3160,45 @@ For IP sockets, the address info is a pair (hostaddr, port)."); True -- blocking mode; same as settimeout(None) */ -static PyObject * -sock_setblocking(PyObject *self, PyObject *arg) -{ - long block; +/*[clinic input] +_socket.socket.setblocking + self as s: self(type="PySocketSockObject *") + flag: bool + / - block = PyObject_IsTrue(arg); - if (block < 0) - return NULL; +Set the socket to blocking (flag is true) or non-blocking (false). - PySocketSockObject *s = _PySocketSockObject_CAST(self); - s->sock_timeout = _PyTime_FromSeconds(block ? -1 : 0); - if (internal_setblocking(s, block) == -1) { +setblocking(True) is equivalent to settimeout(None); +setblocking(False) is equivalent to settimeout(0.0). +[clinic start generated code]*/ + +static PyObject * +_socket_socket_setblocking_impl(PySocketSockObject *s, int flag) +/*[clinic end generated code: output=0d27b1c391538401 input=bfc2c8564d8b67f6]*/ +{ + s->sock_timeout = _PyTime_FromSeconds(flag ? -1 : 0); + if (internal_setblocking(s, flag) == -1) { return NULL; } Py_RETURN_NONE; } -PyDoc_STRVAR(setblocking_doc, -"setblocking(flag)\n\ -\n\ -Set the socket to blocking (flag is true) or non-blocking (false).\n\ -setblocking(True) is equivalent to settimeout(None);\n\ -setblocking(False) is equivalent to settimeout(0.0)."); /* s.getblocking() method. Returns True if socket is in blocking mode, False if it is in non-blocking mode. */ +/*[clinic input] +_socket.socket.getblocking + self as s: self(type="PySocketSockObject *") + +Return True if socket is in blocking mode, False if in non-blocking. +[clinic start generated code]*/ + static PyObject * -sock_getblocking(PyObject *self, PyObject *Py_UNUSED(ignored)) +_socket_socket_getblocking_impl(PySocketSockObject *s) +/*[clinic end generated code: output=e760d93dae8b6ef7 input=13dfb70bc40c3cf8]*/ { - PySocketSockObject *s = _PySocketSockObject_CAST(self); if (s->sock_timeout) { Py_RETURN_TRUE; } @@ -3199,11 +3207,6 @@ sock_getblocking(PyObject *self, PyObject *Py_UNUSED(ignored)) } } -PyDoc_STRVAR(getblocking_doc, -"getblocking()\n\ -\n\ -Returns True if socket is in blocking mode, or False if it\n\ -is in non-blocking mode."); static int socket_parse_timeout(PyTime_t *timeout, PyObject *timeout_obj) @@ -3252,15 +3255,29 @@ socket_parse_timeout(PyTime_t *timeout, PyObject *timeout_obj) > 0 -- timeout mode; operations time out after timeout seconds < 0 -- illegal; raises an exception */ +/*[clinic input] +_socket.socket.settimeout + self as s: self(type="PySocketSockObject *") + timeout as arg: object + / + +Set a timeout on socket operations. + +'timeout' can be a float, giving in seconds, or None. Setting a +timeout of None disables the timeout feature and is equivalent to +setblocking(1). Setting a timeout of zero is the same as +setblocking(0). +[clinic start generated code]*/ + static PyObject * -sock_settimeout(PyObject *self, PyObject *arg) +_socket_socket_settimeout_impl(PySocketSockObject *s, PyObject *arg) +/*[clinic end generated code: output=5e57e2e1cba1c234 input=08bc8324b9fdb3f9]*/ { PyTime_t timeout; if (socket_parse_timeout(&timeout, arg) < 0) return NULL; - PySocketSockObject *s = _PySocketSockObject_CAST(self); s->sock_timeout = timeout; int block = timeout < 0; @@ -3291,13 +3308,6 @@ sock_settimeout(PyObject *self, PyObject *arg) Py_RETURN_NONE; } -PyDoc_STRVAR(settimeout_doc, -"settimeout(timeout)\n\ -\n\ -Set a timeout on socket operations. 'timeout' can be a float,\n\ -giving in seconds, or None. Setting a timeout of None disables\n\ -the timeout feature and is equivalent to setblocking(1).\n\ -Setting a timeout of zero is the same as setblocking(0)."); /* s.gettimeout() method. Returns the timeout associated with a socket. */ @@ -3314,10 +3324,20 @@ sock_gettimeout_impl(PyObject *self, void *Py_UNUSED(ignored)) } } -static inline PyObject * -sock_gettimeout_method(PyObject *self, PyObject *Py_UNUSED(ignored)) +/*[clinic input] +_socket.socket.gettimeout + +Return the timeout in seconds (float) of socket operations. + +A timeout of None indicates that timeouts on socket operations are +disabled. +[clinic start generated code]*/ + +static PyObject * +_socket_socket_gettimeout_impl(PySocketSockObject *self) +/*[clinic end generated code: output=cd49b7758a504532 input=47e7c5bf80e26eaa]*/ { - return sock_gettimeout_impl(self, NULL); + return sock_gettimeout_impl((PyObject *)self, NULL); } static inline PyObject * @@ -3326,12 +3346,6 @@ sock_gettimeout_getter(PyObject *self, void *Py_UNUSED(closure)) return sock_gettimeout_impl(self, NULL); } -PyDoc_STRVAR(gettimeout_doc, -"gettimeout() -> timeout\n\ -\n\ -Returns the timeout in seconds (float) associated with socket\n\ -operations. A timeout of None indicates that timeouts on socket\n\ -operations are disabled."); #ifdef HAVE_SETSOCKOPT /* s.setsockopt() method. @@ -3377,11 +3391,6 @@ sock_setsockopt(PyObject *self, PyObject *args) #ifdef AF_VSOCK if (s->sock_family == AF_VSOCK) { - if (!PyIndex_Check(optval)) { - PyErr_Format(PyExc_TypeError, - "setsockopt() argument 3 for AF_VSOCK must be an int (got %T)", - optval); - } uint64_t vflag; // Must be set width of 64 bits /* setsockopt(level, opt, flag) */ if (!PyArg_Parse(optval, "K", &vflag)) { @@ -3473,22 +3482,30 @@ None, optlen."); With a third integer argument, retrieves a string buffer of that size; use optional built-in module 'struct' to decode the string. */ +/*[clinic input] +_socket.socket.getsockopt + self as s: self(type="PySocketSockObject *") + level: int + option as optname: int + buffersize as buflen: int = 0 + / + +Get a socket option. + +See the Unix manual for level and option. If a nonzero buffersize +argument is given, the return value is a bytes object of that +length; otherwise it is an integer. +[clinic start generated code]*/ + static PyObject * -sock_getsockopt(PyObject *self, PyObject *args) +_socket_socket_getsockopt_impl(PySocketSockObject *s, int level, int optname, + int buflen) +/*[clinic end generated code: output=0b397d1e2237a512 input=1a586fad20b3c3fa]*/ { - PySocketSockObject *s = _PySocketSockObject_CAST(self); - - int level; - int optname; int res; - socklen_t buflen = 0; int flag = 0; socklen_t flagsize; - if (!PyArg_ParseTuple(args, "ii|i:getsockopt", - &level, &optname, &buflen)) - return NULL; - if (buflen == 0) { #ifdef AF_VSOCK if (s->sock_family == AF_VSOCK) { @@ -3529,31 +3546,38 @@ sock_getsockopt(PyObject *self, PyObject *args) if (writer == NULL) { return NULL; } + socklen_t optlen = buflen; res = getsockopt(get_sock_fd(s), level, optname, - PyBytesWriter_GetData(writer), &buflen); + PyBytesWriter_GetData(writer), &optlen); if (res < 0) { PyBytesWriter_Discard(writer); return s->errorhandler(); } - return PyBytesWriter_FinishWithSize(writer, buflen); + return PyBytesWriter_FinishWithSize(writer, optlen); } -PyDoc_STRVAR(getsockopt_doc, -"getsockopt(level, option[, buffersize]) -> value\n\ -\n\ -Get a socket option. See the Unix manual for level and option.\n\ -If a nonzero buffersize argument is given, the return value is a\n\ -string of that length; otherwise it is an integer."); #ifdef HAVE_BIND /* s.bind(sockaddr) method */ +/*[clinic input] +_socket.socket.bind + self as s: self(type="PySocketSockObject *") + address as addro: object + / + +Bind the socket to a local address. + +For IP sockets, the address is a pair (host, port); the host must +refer to the local host. For raw packet sockets the address is a +tuple (ifname, proto [,pkttype [,hatype [,addr]]]). +[clinic start generated code]*/ + static PyObject * -sock_bind(PyObject *self, PyObject *addro) +_socket_socket_bind_impl(PySocketSockObject *s, PyObject *addro) +/*[clinic end generated code: output=b8d74d0184a9f187 input=ee3f536adbaaa1cb]*/ { - PySocketSockObject *s = _PySocketSockObject_CAST(self); - sock_addr_t addrbuf; int addrlen; int res; @@ -3574,12 +3598,6 @@ sock_bind(PyObject *self, PyObject *addro) Py_RETURN_NONE; } -PyDoc_STRVAR(bind_doc, -"bind(address)\n\ -\n\ -Bind the socket to a local address. For IP sockets, the address is a\n\ -pair (host, port); the host must refer to the local host. For raw packet\n\ -sockets the address is a tuple (ifname, proto [,pkttype [,hatype [,addr]]])"); #endif @@ -3623,21 +3641,25 @@ _socket_socket_close_impl(PySocketSockObject *s) Py_RETURN_NONE; } +/*[clinic input] +_socket.socket.detach + self as s: self(type="PySocketSockObject *") + +Close the socket object without closing the file descriptor. + +The object cannot be used after this call, but the file descriptor +can be reused for other purposes. The file descriptor is returned. +[clinic start generated code]*/ + static PyObject * -sock_detach(PyObject *self, PyObject *Py_UNUSED(ignored)) +_socket_socket_detach_impl(PySocketSockObject *s) +/*[clinic end generated code: output=769cc72d7fdddebd input=ee1305f0594b88cc]*/ { - PySocketSockObject *s = _PySocketSockObject_CAST(self); SOCKET_T fd = get_sock_fd(s); set_sock_fd(s, INVALID_SOCKET); return PyLong_FromSocket_t(fd); } -PyDoc_STRVAR(detach_doc, -"detach()\n\ -\n\ -Close the socket object without closing the underlying file descriptor.\n\ -The object cannot be used after this call, but the file descriptor\n\ -can be reused for other purposes. The file descriptor is returned."); #ifdef HAVE_CONNECT static int @@ -3741,11 +3763,21 @@ internal_connect(PySocketSockObject *s, struct sockaddr *addr, int addrlen, /* s.connect(sockaddr) method */ +/*[clinic input] +_socket.socket.connect + self as s: self(type="PySocketSockObject *") + address as addro: object + / + +Connect the socket to a remote address. + +For IP sockets, the address is a pair (host, port). +[clinic start generated code]*/ + static PyObject * -sock_connect(PyObject *self, PyObject *addro) +_socket_socket_connect_impl(PySocketSockObject *s, PyObject *addro) +/*[clinic end generated code: output=d4f73817eb43ed12 input=1b7c601416490538]*/ { - PySocketSockObject *s = _PySocketSockObject_CAST(self); - sock_addr_t addrbuf; int addrlen; int res; @@ -3767,20 +3799,26 @@ sock_connect(PyObject *self, PyObject *addro) Py_RETURN_NONE; } -PyDoc_STRVAR(connect_doc, -"connect(address)\n\ -\n\ -Connect the socket to a remote address. For IP sockets, the address\n\ -is a pair (host, port)."); /* s.connect_ex(sockaddr) method */ +/*[clinic input] +_socket.socket.connect_ex + self as s: self(type="PySocketSockObject *") + address as addro: object + / + +Connect the socket to a remote address. + +This is like connect(address), but returns an error code (the errno +value) instead of raising an exception when an error occurs. +[clinic start generated code]*/ + static PyObject * -sock_connect_ex(PyObject *self, PyObject *addro) +_socket_socket_connect_ex_impl(PySocketSockObject *s, PyObject *addro) +/*[clinic end generated code: output=bc8b7cdf80e419af input=716f3a78a296d7ca]*/ { - PySocketSockObject *s = _PySocketSockObject_CAST(self); - sock_addr_t addrbuf; int addrlen; int res; @@ -3801,37 +3839,45 @@ sock_connect_ex(PyObject *self, PyObject *addro) return PyLong_FromLong((long) res); } -PyDoc_STRVAR(connect_ex_doc, -"connect_ex(address) -> errno\n\ -\n\ -This is like connect(address), but returns an error code (the errno value)\n\ -instead of raising an exception when an error occurs."); #endif // HAVE_CONNECT /* s.fileno() method */ +/*[clinic input] +_socket.socket.fileno + self as s: self(type="PySocketSockObject *") + +Return the integer file descriptor of the socket. +[clinic start generated code]*/ + static PyObject * -sock_fileno(PyObject *self, PyObject *Py_UNUSED(ignored)) +_socket_socket_fileno_impl(PySocketSockObject *s) +/*[clinic end generated code: output=6d422560f508d2c6 input=7f817a2413c3c37c]*/ { - PySocketSockObject *s = _PySocketSockObject_CAST(self); return PyLong_FromSocket_t(get_sock_fd(s)); } -PyDoc_STRVAR(fileno_doc, -"fileno() -> integer\n\ -\n\ -Return the integer file descriptor of the socket."); #ifdef HAVE_GETSOCKNAME /* s.getsockname() method */ +/*[clinic input] +_socket.socket.getsockname + self as s: self(type="PySocketSockObject *") + +Return the address of the local endpoint. + +The format depends on the address family. For IPv4 sockets, the +address info is a pair (hostaddr, port). For IPv6 sockets, the +address info is a 4-tuple (hostaddr, port, flowinfo, scope_id). +[clinic start generated code]*/ + static PyObject * -sock_getsockname(PyObject *self, PyObject *Py_UNUSED(ignored)) +_socket_socket_getsockname_impl(PySocketSockObject *s) +/*[clinic end generated code: output=b4c94874b6bf20ed input=b6628802847b2eef]*/ { - PySocketSockObject *s = _PySocketSockObject_CAST(self); - sock_addr_t addrbuf; int res; socklen_t addrlen; @@ -3839,33 +3885,32 @@ sock_getsockname(PyObject *self, PyObject *Py_UNUSED(ignored)) if (!getsockaddrlen(s, &addrlen)) return NULL; memset(&addrbuf, 0, addrlen); - Py_BEGIN_ALLOW_THREADS res = getsockname(get_sock_fd(s), SAS2SA(&addrbuf), &addrlen); - Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); return makesockaddr(get_sock_fd(s), SAS2SA(&addrbuf), addrlen, s->sock_proto); } -PyDoc_STRVAR(getsockname_doc, -"getsockname() -> address info\n\ -\n\ -Return the address of the local endpoint. The format depends on the\n\ -address family. For IPv4 sockets, the address info is a pair\n\ -(hostaddr, port). For IPv6 sockets, the address info is a 4-tuple\n\ -(hostaddr, port, flowinfo, scope_id)."); #endif #ifdef HAVE_GETPEERNAME /* Cray APP doesn't have this :-( */ /* s.getpeername() method */ +/*[clinic input] +_socket.socket.getpeername + self as s: self(type="PySocketSockObject *") + +Return the address of the remote endpoint. + +For IP sockets, the address info is a pair (hostaddr, port). +[clinic start generated code]*/ + static PyObject * -sock_getpeername(PyObject *self, PyObject *Py_UNUSED(ignored)) +_socket_socket_getpeername_impl(PySocketSockObject *s) +/*[clinic end generated code: output=3e20211d74c8f60b input=aa6b96e92c7996be]*/ { - PySocketSockObject *s = _PySocketSockObject_CAST(self); - sock_addr_t addrbuf; int res; socklen_t addrlen; @@ -3873,20 +3918,13 @@ sock_getpeername(PyObject *self, PyObject *Py_UNUSED(ignored)) if (!getsockaddrlen(s, &addrlen)) return NULL; memset(&addrbuf, 0, addrlen); - Py_BEGIN_ALLOW_THREADS res = getpeername(get_sock_fd(s), SAS2SA(&addrbuf), &addrlen); - Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); return makesockaddr(get_sock_fd(s), SAS2SA(&addrbuf), addrlen, s->sock_proto); } -PyDoc_STRVAR(getpeername_doc, -"getpeername() -> address info\n\ -\n\ -Return the address of the remote endpoint. For IP sockets, the address\n\ -info is a pair (hostaddr, port)."); #endif /* HAVE_GETPEERNAME */ @@ -3894,18 +3932,26 @@ info is a pair (hostaddr, port)."); #ifdef HAVE_LISTEN /* s.listen(n) method */ +/*[clinic input] +_socket.socket.listen + self as s: self(type="PySocketSockObject *") + backlog: int(c_default="Py_MIN(SOMAXCONN, 128)") = min(SOMAXCONN, 128) + / + +Enable a server to accept connections. + +If backlog is specified, it must be at least 0 (if it is lower, it +is set to 0); it specifies the number of unaccepted connections that +the system will allow before refusing new connections. If not +specified, a default reasonable value is chosen. +[clinic start generated code]*/ + static PyObject * -sock_listen(PyObject *self, PyObject *args) +_socket_socket_listen_impl(PySocketSockObject *s, int backlog) +/*[clinic end generated code: output=245718576af7f07b input=8eb794d108797ad9]*/ { - PySocketSockObject *s = _PySocketSockObject_CAST(self); - /* We try to choose a default backlog high enough to avoid connection drops - * for common workloads, yet not too high to limit resource usage. */ - int backlog = Py_MIN(SOMAXCONN, 128); int res; - if (!PyArg_ParseTuple(args, "|i:listen", &backlog)) - return NULL; - Py_BEGIN_ALLOW_THREADS /* To avoid problems on systems that don't allow a negative backlog * (which doesn't make sense anyway) we force a minimum value of 0. */ @@ -3918,13 +3964,6 @@ sock_listen(PyObject *self, PyObject *args) Py_RETURN_NONE; } -PyDoc_STRVAR(listen_doc, -"listen([backlog])\n\ -\n\ -Enable a server to accept connections. If backlog is specified, it must be\n\ -at least 0 (if it is lower, it is set to 0); it specifies the number of\n\ -unaccepted connections that the system will allow before refusing new\n\ -connections. If not specified, a default reasonable value is chosen."); #endif struct sock_recv { @@ -3985,16 +4024,27 @@ sock_recv_guts(PySocketSockObject *s, char* cbuf, Py_ssize_t len, int flags) /* s.recv(nbytes [,flags]) method */ -static PyObject * -sock_recv(PyObject *self, PyObject *args) -{ - PySocketSockObject *s = _PySocketSockObject_CAST(self); +/*[clinic input] +_socket.socket.recv + self as s: self(type="PySocketSockObject *") + buffersize as recvlen: Py_ssize_t + flags: int = 0 + / - Py_ssize_t recvlen, outlen; - int flags = 0; +Receive up to buffersize bytes from the socket. - if (!PyArg_ParseTuple(args, "n|i:recv", &recvlen, &flags)) - return NULL; +For the optional flags argument, see the Unix manual. When no data +is available, block until at least one byte is available or until +the remote end is closed. When the remote end is closed and all data +is read, return the empty string. +[clinic start generated code]*/ + +static PyObject * +_socket_socket_recv_impl(PySocketSockObject *s, Py_ssize_t recvlen, + int flags) +/*[clinic end generated code: output=412b46af1a68ee75 input=6c8382200e8f85fc]*/ +{ + Py_ssize_t outlen; if (recvlen < 0) { PyErr_SetString(PyExc_ValueError, @@ -4020,37 +4070,34 @@ sock_recv(PyObject *self, PyObject *args) return PyBytesWriter_FinishWithSize(writer, outlen); } -PyDoc_STRVAR(recv_doc, -"recv(buffersize[, flags]) -> data\n\ -\n\ -Receive up to buffersize bytes from the socket. For the optional flags\n\ -argument, see the Unix manual. When no data is available, block until\n\ -at least one byte is available or until the remote end is closed. When\n\ -the remote end is closed and all data is read, return the empty string."); - /* s.recv_into(buffer, [nbytes [,flags]]) method */ -static PyObject* -sock_recv_into(PyObject *self, PyObject *args, PyObject *kwds) -{ - static char *kwlist[] = {"buffer", "nbytes", "flags", 0}; - PySocketSockObject *s = _PySocketSockObject_CAST(self); +/*[clinic input] +_socket.socket.recv_into + self as s: self(type="PySocketSockObject *") + buffer as pbuf: Py_buffer(accept={rwbuffer}) + nbytes as recvlen: Py_ssize_t = 0 + flags: int = 0 - int flags = 0; - Py_buffer pbuf; - char *buf; - Py_ssize_t buflen, readlen, recvlen = 0; +Receive up to nbytes bytes from the socket, storing into a buffer. - /* Get the buffer's memory */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "w*|ni:recv_into", kwlist, - &pbuf, &recvlen, &flags)) - return NULL; - buf = pbuf.buf; - buflen = pbuf.len; +A version of recv() that stores its data into a buffer rather than +creating a new bytes object. If nbytes is not specified (or 0), +receive up to the size available in the given buffer. + +See recv() for documentation about the flags. +[clinic start generated code]*/ + +static PyObject * +_socket_socket_recv_into_impl(PySocketSockObject *s, Py_buffer *pbuf, + Py_ssize_t recvlen, int flags) +/*[clinic end generated code: output=58a1cbe9fadb88d7 input=410e6aff36c416a0]*/ +{ + char *buf = pbuf->buf; + Py_ssize_t buflen = pbuf->len, readlen; if (recvlen < 0) { - PyBuffer_Release(&pbuf); PyErr_SetString(PyExc_ValueError, "negative buffersize in recv_into"); return NULL; @@ -4062,7 +4109,6 @@ sock_recv_into(PyObject *self, PyObject *args, PyObject *kwds) /* Check if the buffer is large enough */ if (buflen < recvlen) { - PyBuffer_Release(&pbuf); PyErr_SetString(PyExc_ValueError, "buffer too small for requested bytes"); return NULL; @@ -4072,24 +4118,14 @@ sock_recv_into(PyObject *self, PyObject *args, PyObject *kwds) readlen = sock_recv_guts(s, buf, recvlen, flags); if (readlen < 0) { /* Return an error. */ - PyBuffer_Release(&pbuf); return NULL; } - PyBuffer_Release(&pbuf); /* Return the number of bytes read. Note that we do not do anything special here in the case that readlen < recvlen. */ return PyLong_FromSsize_t(readlen); } -PyDoc_STRVAR(recv_into_doc, -"recv_into(buffer, [nbytes[, flags]]) -> nbytes_read\n\ -\n\ -A version of recv() that stores its data into a buffer rather than creating\n\ -a new string. Receive up to buffersize bytes from the socket. If buffersize\n\ -is not specified (or 0), receive up to the size available in the given buffer.\n\ -\n\ -See recv() for documentation about the flags."); struct sock_recvfrom { char* cbuf; @@ -4168,17 +4204,26 @@ sock_recvfrom_guts(PySocketSockObject *s, char* cbuf, Py_ssize_t len, int flags, /* s.recvfrom(nbytes [,flags]) method */ +/*[clinic input] +_socket.socket.recvfrom + self as s: self(type="PySocketSockObject *") + buffersize as recvlen: Py_ssize_t + flags: int = 0 + / + +Receive up to buffersize bytes and the sender's address info. + +Like recv(buffersize, flags), but return a (data, address info) +pair. +[clinic start generated code]*/ + static PyObject * -sock_recvfrom(PyObject *self, PyObject *args) +_socket_socket_recvfrom_impl(PySocketSockObject *s, Py_ssize_t recvlen, + int flags) +/*[clinic end generated code: output=52b2ece9ea4251b1 input=d8c8c5dc56c02e86]*/ { - PySocketSockObject *s = _PySocketSockObject_CAST(self); - PyObject *addr = NULL; - int flags = 0; - Py_ssize_t recvlen, outlen; - - if (!PyArg_ParseTuple(args, "n|i:recvfrom", &recvlen, &flags)) - return NULL; + Py_ssize_t outlen; if (recvlen < 0) { PyErr_SetString(PyExc_ValueError, @@ -4210,36 +4255,33 @@ sock_recvfrom(PyObject *self, PyObject *args) return NULL; } -PyDoc_STRVAR(recvfrom_doc, -"recvfrom(buffersize[, flags]) -> (data, address info)\n\ -\n\ -Like recv(buffersize, flags) but also return the sender's address info."); /* s.recvfrom_into(buffer[, nbytes [,flags]]) method */ -static PyObject * -sock_recvfrom_into(PyObject *self, PyObject *args, PyObject* kwds) -{ - static char *kwlist[] = {"buffer", "nbytes", "flags", 0}; - PySocketSockObject *s = _PySocketSockObject_CAST(self); +/*[clinic input] +_socket.socket.recvfrom_into + self as s: self(type="PySocketSockObject *") + buffer as pbuf: Py_buffer(accept={rwbuffer}) + nbytes as recvlen: Py_ssize_t = 0 + flags: int = 0 - int flags = 0; - Py_buffer pbuf; - char *buf; - Py_ssize_t readlen, buflen, recvlen = 0; +Receive up to nbytes bytes and the sender's address info. - PyObject *addr = NULL; +Like recv_into(buffer, nbytes, flags), but return a (nbytes, address +info) pair. +[clinic start generated code]*/ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "w*|ni:recvfrom_into", - kwlist, &pbuf, - &recvlen, &flags)) - return NULL; - buf = pbuf.buf; - buflen = pbuf.len; +static PyObject * +_socket_socket_recvfrom_into_impl(PySocketSockObject *s, Py_buffer *pbuf, + Py_ssize_t recvlen, int flags) +/*[clinic end generated code: output=e60b491a1c9d5bec input=2a15bf437b8b98ba]*/ +{ + char *buf = pbuf->buf; + Py_ssize_t readlen, buflen = pbuf->len; + PyObject *addr = NULL; if (recvlen < 0) { - PyBuffer_Release(&pbuf); PyErr_SetString(PyExc_ValueError, "negative buffersize in recvfrom_into"); return NULL; @@ -4248,7 +4290,6 @@ sock_recvfrom_into(PyObject *self, PyObject *args, PyObject* kwds) /* If nbytes was not specified, use the buffer's length */ recvlen = buflen; } else if (recvlen > buflen) { - PyBuffer_Release(&pbuf); PyErr_SetString(PyExc_ValueError, "nbytes is greater than the length of the buffer"); return NULL; @@ -4256,22 +4297,16 @@ sock_recvfrom_into(PyObject *self, PyObject *args, PyObject* kwds) readlen = sock_recvfrom_guts(s, buf, recvlen, flags, &addr); if (readlen < 0) { - PyBuffer_Release(&pbuf); /* Return an error */ Py_XDECREF(addr); return NULL; } - PyBuffer_Release(&pbuf); /* Return the number of bytes read and the address. Note that we do not do anything special here in the case that readlen < recvlen. */ return Py_BuildValue("nN", readlen, addr); } -PyDoc_STRVAR(recvfrom_into_doc, -"recvfrom_into(buffer[, nbytes[, flags]]) -> (nbytes, address info)\n\ -\n\ -Like recv_into(buffer[, nbytes[, flags]]) but also return the sender's address info."); #endif /* The sendmsg() and recvmsg[_into]() methods require a working @@ -4446,14 +4481,47 @@ makeval_recvmsg(ssize_t received, void *data) /* s.recvmsg(bufsize[, ancbufsize[, flags]]) method */ +/*[clinic input] +_socket.socket.recvmsg + self as s: self(type="PySocketSockObject *") + bufsize: Py_ssize_t + ancbufsize: Py_ssize_t = 0 + flags: int = 0 + / + +Receive normal data and ancillary data from the socket. + +Receive up to bufsize bytes of normal data. The ancbufsize argument +sets the size in bytes of the internal buffer used to receive the +ancillary data; it defaults to 0, meaning that no ancillary data +will be received. Appropriate buffer sizes for ancillary data can +be calculated using CMSG_SPACE() or CMSG_LEN(), and items which do +not fit into the buffer might be truncated or discarded. The flags +argument defaults to 0 and has the same meaning as for recv(). + +The return value is a 4-tuple: (data, ancdata, msg_flags, address). +The data item is a bytes object holding the non-ancillary data +received. The ancdata item is a list of zero or more tuples +(cmsg_level, cmsg_type, cmsg_data) representing the ancillary data +(control messages) received: cmsg_level and cmsg_type are integers +specifying the protocol level and protocol-specific type +respectively, and cmsg_data is a bytes object holding the associated +data. The msg_flags item is the bitwise OR of various flags +indicating conditions on the received message; see your system +documentation for details. If the receiving socket is unconnected, +address is the address of the sending socket, if available; +otherwise, its value is unspecified. + +If recvmsg() raises an exception after the system call returns, it +will first attempt to close any file descriptors received via the +SCM_RIGHTS mechanism. +[clinic start generated code]*/ + static PyObject * -sock_recvmsg(PyObject *self, PyObject *args) +_socket_socket_recvmsg_impl(PySocketSockObject *s, Py_ssize_t bufsize, + Py_ssize_t ancbufsize, int flags) +/*[clinic end generated code: output=1a26c130cf1a898f input=ae53e29436e6c0a3]*/ { - Py_ssize_t bufsize, ancbufsize = 0; - int flags = 0; - if (!PyArg_ParseTuple(args, "n|ni:recvmsg", &bufsize, &ancbufsize, &flags)) - return NULL; - if (bufsize < 0) { PyErr_SetString(PyExc_ValueError, "negative buffer size in recvmsg()"); return NULL; @@ -4471,41 +4539,12 @@ sock_recvmsg(PyObject *self, PyObject *args) writer (&writer); makeval_recvmsg() finish it and set our pointer to NULL. */ PyObject *retval; - PySocketSockObject *s = _PySocketSockObject_CAST(self); retval = sock_recvmsg_guts(s, &iov, 1, flags, ancbufsize, &makeval_recvmsg, &writer); PyBytesWriter_Discard(writer); return retval; } -PyDoc_STRVAR(recvmsg_doc, -"recvmsg(bufsize[, ancbufsize[, flags]]) -> (data, ancdata, msg_flags, address)\n\ -\n\ -Receive normal data (up to bufsize bytes) and ancillary data from the\n\ -socket. The ancbufsize argument sets the size in bytes of the\n\ -internal buffer used to receive the ancillary data; it defaults to 0,\n\ -meaning that no ancillary data will be received. Appropriate buffer\n\ -sizes for ancillary data can be calculated using CMSG_SPACE() or\n\ -CMSG_LEN(), and items which do not fit into the buffer might be\n\ -truncated or discarded. The flags argument defaults to 0 and has the\n\ -same meaning as for recv().\n\ -\n\ -The return value is a 4-tuple: (data, ancdata, msg_flags, address).\n\ -The data item is a bytes object holding the non-ancillary data\n\ -received. The ancdata item is a list of zero or more tuples\n\ -(cmsg_level, cmsg_type, cmsg_data) representing the ancillary data\n\ -(control messages) received: cmsg_level and cmsg_type are integers\n\ -specifying the protocol level and protocol-specific type respectively,\n\ -and cmsg_data is a bytes object holding the associated data. The\n\ -msg_flags item is the bitwise OR of various flags indicating\n\ -conditions on the received message; see your system documentation for\n\ -details. If the receiving socket is unconnected, address is the\n\ -address of the sending socket, if available; otherwise, its value is\n\ -unspecified.\n\ -\n\ -If recvmsg() raises an exception after the system call returns, it\n\ -will first attempt to close any file descriptors received via the\n\ -SCM_RIGHTS mechanism."); static PyObject * @@ -4516,21 +4555,55 @@ makeval_recvmsg_into(ssize_t received, void *data) /* s.recvmsg_into(buffers[, ancbufsize[, flags]]) method */ +/*[clinic input] +_socket.socket.recvmsg_into + self as s: self(type="PySocketSockObject *") + buffers as buffers_arg: object + ancbufsize: Py_ssize_t = 0 + flags: int = 0 + / + +Receive normal and ancillary data, scattering the normal data. + +The buffers argument must be an iterable of objects that export +writable buffers (e.g. bytearray objects); these will be filled +with successive chunks of the non-ancillary data until it has all +been written or there are no more buffers. The ancbufsize argument +sets the size in bytes of the internal buffer used to receive the +ancillary data; it defaults to 0, meaning that no ancillary data +will be received. Appropriate buffer sizes for ancillary data can +be calculated using CMSG_SPACE() or CMSG_LEN(), and items which do +not fit into the buffer might be truncated or discarded. The flags +argument defaults to 0 and has the same meaning as for recv(). + +The return value is a 4-tuple: (nbytes, ancdata, msg_flags, +address). The nbytes item is the total number of bytes of +non-ancillary data written into the buffers. The ancdata item is a +list of zero or more tuples (cmsg_level, cmsg_type, cmsg_data) +representing the ancillary data (control messages) received: +cmsg_level and cmsg_type are integers specifying the protocol level +and protocol-specific type respectively, and cmsg_data is a bytes +object holding the associated data. The msg_flags item is the +bitwise OR of various flags indicating conditions on the received +message; see your system documentation for details. If the +receiving socket is unconnected, address is the address of the +sending socket, if available; otherwise, its value is unspecified. + +If recvmsg_into() raises an exception after the system call returns, +it will first attempt to close any file descriptors received via the +SCM_RIGHTS mechanism. +[clinic start generated code]*/ + static PyObject * -sock_recvmsg_into(PyObject *self, PyObject *args) +_socket_socket_recvmsg_into_impl(PySocketSockObject *s, + PyObject *buffers_arg, + Py_ssize_t ancbufsize, int flags) +/*[clinic end generated code: output=282fd7dd1bdb15f8 input=427536a5043122d2]*/ { - PySocketSockObject *s = _PySocketSockObject_CAST(self); - - Py_ssize_t ancbufsize = 0; - int flags = 0; struct iovec *iovs = NULL; Py_ssize_t i, nitems, nbufs = 0; Py_buffer *bufs = NULL; - PyObject *buffers_arg, *buffers_tuple, *retval = NULL; - - if (!PyArg_ParseTuple(args, "O|ni:recvmsg_into", - &buffers_arg, &ancbufsize, &flags)) - return NULL; + PyObject *buffers_tuple, *retval = NULL; buffers_tuple = PySequence_Tuple(buffers_arg); if (buffers_tuple == NULL) { @@ -4572,38 +4645,6 @@ sock_recvmsg_into(PyObject *self, PyObject *args) return retval; } -PyDoc_STRVAR(recvmsg_into_doc, -"recvmsg_into(buffers[, ancbufsize[, flags]]) -> (nbytes, ancdata, msg_flags, address)\n\ -\n\ -Receive normal data and ancillary data from the socket, scattering the\n\ -non-ancillary data into a series of buffers. The buffers argument\n\ -must be an iterable of objects that export writable buffers\n\ -(e.g. bytearray objects); these will be filled with successive chunks\n\ -of the non-ancillary data until it has all been written or there are\n\ -no more buffers. The ancbufsize argument sets the size in bytes of\n\ -the internal buffer used to receive the ancillary data; it defaults to\n\ -0, meaning that no ancillary data will be received. Appropriate\n\ -buffer sizes for ancillary data can be calculated using CMSG_SPACE()\n\ -or CMSG_LEN(), and items which do not fit into the buffer might be\n\ -truncated or discarded. The flags argument defaults to 0 and has the\n\ -same meaning as for recv().\n\ -\n\ -The return value is a 4-tuple: (nbytes, ancdata, msg_flags, address).\n\ -The nbytes item is the total number of bytes of non-ancillary data\n\ -written into the buffers. The ancdata item is a list of zero or more\n\ -tuples (cmsg_level, cmsg_type, cmsg_data) representing the ancillary\n\ -data (control messages) received: cmsg_level and cmsg_type are\n\ -integers specifying the protocol level and protocol-specific type\n\ -respectively, and cmsg_data is a bytes object holding the associated\n\ -data. The msg_flags item is the bitwise OR of various flags\n\ -indicating conditions on the received message; see your system\n\ -documentation for details. If the receiving socket is unconnected,\n\ -address is the address of the sending socket, if available; otherwise,\n\ -its value is unspecified.\n\ -\n\ -If recvmsg_into() raises an exception after the system call returns,\n\ -it will first attempt to close any file descriptors received via the\n\ -SCM_RIGHTS mechanism."); #endif /* CMSG_LEN */ @@ -4919,9 +4960,9 @@ sock_sendmsg_impl(PySocketSockObject *s, void *data) _socket.socket.sendmsg self as s: self(type="PySocketSockObject *") buffers as data_arg: object - ancdata as cmsg_arg: object = NULL + ancdata as cmsg_arg: object(c_default="NULL") = () flags: int = 0 - address as addr_arg: object = NULL + address as addr_arg: object(c_default="NULL") = None / Send normal and ancillary data to the socket. @@ -4945,7 +4986,7 @@ static PyObject * _socket_socket_sendmsg_impl(PySocketSockObject *s, PyObject *data_arg, PyObject *cmsg_arg, int flags, PyObject *addr_arg) -/*[clinic end generated code: output=3b4cb1110644ce39 input=8ae408971a3aa329]*/ +/*[clinic end generated code: output=3b4cb1110644ce39 input=5fdf9b49bed3848b]*/ { Py_ssize_t i, ndatabufs = 0, ncmsgs, ncmsgbufs = 0; @@ -5130,27 +5171,37 @@ _socket_socket_sendmsg_impl(PySocketSockObject *s, PyObject *data_arg, #endif /* CMSG_LEN */ #ifdef HAVE_SOCKADDR_ALG -static PyObject* -sock_sendmsg_afalg(PyObject *s, PyObject *args, PyObject *kwds) -{ - PySocketSockObject *self = _PySocketSockObject_CAST(s); +/*[clinic input] +_socket.socket.sendmsg_afalg + self: self(type="PySocketSockObject *") + msg as data_arg: object = NULL + * + op as opobj: object(subclass_of='&PyLong_Type') = NULL + iv: Py_buffer = NULL + assoclen as assoclenobj: object(subclass_of='&PyLong_Type') = NULL + flags: int = 0 + +Set operation mode, IV and associated data length. + +For an AF_ALG operation socket. +[clinic start generated code]*/ +static PyObject * +_socket_socket_sendmsg_afalg_impl(PySocketSockObject *self, + PyObject *data_arg, PyObject *opobj, + Py_buffer *iv, PyObject *assoclenobj, + int flags) +/*[clinic end generated code: output=3fd9856d4d9f7c97 input=3ed371da034a1bb3]*/ +{ PyObject *retval = NULL; Py_ssize_t i, ndatabufs = 0; Py_buffer *databufs = NULL; - PyObject *data_arg = NULL; - Py_buffer iv = {NULL, NULL}; - - PyObject *opobj = NULL; int op = -1; - - PyObject *assoclenobj = NULL; int assoclen = -1; unsigned int *uiptr; - int flags = 0; struct msghdr msg; struct cmsghdr *header = NULL; @@ -5158,7 +5209,6 @@ sock_sendmsg_afalg(PyObject *s, PyObject *args, PyObject *kwds) struct sock_sendmsg ctx; Py_ssize_t controllen; void *controlbuf = NULL; - static char *keywords[] = {"msg", "op", "iv", "assoclen", "flags", 0}; if (self->sock_family != AF_ALG) { PyErr_SetString(PyExc_OSError, @@ -5166,14 +5216,6 @@ sock_sendmsg_afalg(PyObject *s, PyObject *args, PyObject *kwds) return NULL; } - if (!PyArg_ParseTupleAndKeywords(args, kwds, - "|O$O!y*O!i:sendmsg_afalg", keywords, - &data_arg, - &PyLong_Type, &opobj, &iv, - &PyLong_Type, &assoclenobj, &flags)) { - return NULL; - } - memset(&msg, 0, sizeof(msg)); /* op is a required, keyword-only argument >= 0 */ @@ -5200,8 +5242,8 @@ sock_sendmsg_afalg(PyObject *s, PyObject *args, PyObject *kwds) } controllen = CMSG_SPACE(4); - if (iv.buf != NULL) { - controllen += CMSG_SPACE(sizeof(*alg_iv) + iv.len); + if (iv->buf != NULL) { + controllen += CMSG_SPACE(sizeof(*alg_iv) + iv->len); } if (assoclen >= 0) { controllen += CMSG_SPACE(4); @@ -5239,7 +5281,7 @@ sock_sendmsg_afalg(PyObject *s, PyObject *args, PyObject *kwds) *uiptr = (unsigned int)op; /* set initialization vector */ - if (iv.buf != NULL) { + if (iv->buf != NULL) { header = CMSG_NXTHDR(&msg, header); if (header == NULL) { PyErr_SetString(PyExc_RuntimeError, @@ -5248,10 +5290,10 @@ sock_sendmsg_afalg(PyObject *s, PyObject *args, PyObject *kwds) } header->cmsg_level = SOL_ALG; header->cmsg_type = ALG_SET_IV; - header->cmsg_len = CMSG_SPACE(sizeof(*alg_iv) + iv.len); + header->cmsg_len = CMSG_SPACE(sizeof(*alg_iv) + iv->len); alg_iv = (void*)CMSG_DATA(header); - alg_iv->ivlen = iv.len; - memcpy(alg_iv->iv, iv.buf, iv.len); + alg_iv->ivlen = iv->len; + memcpy(alg_iv->iv, iv->buf, iv->len); } /* set length of associated data for AEAD */ @@ -5279,9 +5321,6 @@ sock_sendmsg_afalg(PyObject *s, PyObject *args, PyObject *kwds) finally: PyMem_Free(controlbuf); - if (iv.buf != NULL) { - PyBuffer_Release(&iv); - } PyMem_Free(msg.msg_iov); for (i = 0; i < ndatabufs; i++) { PyBuffer_Release(&databufs[i]); @@ -5290,21 +5329,28 @@ sock_sendmsg_afalg(PyObject *s, PyObject *args, PyObject *kwds) return retval; } -PyDoc_STRVAR(sendmsg_afalg_doc, -"sendmsg_afalg([msg], *, op[, iv[, assoclen[, flags=MSG_MORE]]])\n\ -\n\ -Set operation mode, IV and length of associated data for an AF_ALG\n\ -operation socket."); #endif #ifdef HAVE_SHUTDOWN /* s.shutdown(how) method */ +/*[clinic input] +_socket.socket.shutdown + self as s: self(type="PySocketSockObject *") + flag as arg: object + / + +Shut down one or both halves of the connection. + +Shut down the reading side of the socket (flag == SHUT_RD), the +writing side of the socket (flag == SHUT_WR), or both ends (flag == +SHUT_RDWR). +[clinic start generated code]*/ + static PyObject * -sock_shutdown(PyObject *self, PyObject *arg) +_socket_socket_shutdown_impl(PySocketSockObject *s, PyObject *arg) +/*[clinic end generated code: output=84264513a6049ca7 input=a90afb227247ce03]*/ { - PySocketSockObject *s = _PySocketSockObject_CAST(self); - int how; int res; @@ -5319,11 +5365,6 @@ sock_shutdown(PyObject *self, PyObject *arg) Py_RETURN_NONE; } -PyDoc_STRVAR(shutdown_doc, -"shutdown(flag)\n\ -\n\ -Shut down the reading side of the socket (flag == SHUT_RD), the writing side\n\ -of the socket (flag == SHUT_WR), or both ends (flag == SHUT_RDWR)."); #endif #if defined(MS_WINDOWS) && defined(SIO_RCVALL) @@ -5385,18 +5426,26 @@ SIO_LOOPBACK_FAST_PATH: 'option' is a boolean value, and is disabled by default" #endif #if defined(MS_WINDOWS) -static PyObject* -sock_share(PyObject *self, PyObject *arg) -{ - PySocketSockObject *s = _PySocketSockObject_CAST(self); +/*[clinic input] +_socket.socket.share + self as s: self(type="PySocketSockObject *") + process_id as processId: unsigned_int(bitwise=True) + / + +Share the socket with another process. + +The target process id must be provided and the resulting bytes +object passed to the target process. There the shared socket can be +instantiated by calling socket.fromshare(). +[clinic start generated code]*/ +static PyObject * +_socket_socket_share_impl(PySocketSockObject *s, unsigned int processId) +/*[clinic end generated code: output=446bfcc5fe3273c6 input=0a9d7536371bfe2d]*/ +{ WSAPROTOCOL_INFOW info; - DWORD processId; int result; - if (!PyArg_ParseTuple(arg, "I", &processId)) - return NULL; - Py_BEGIN_ALLOW_THREADS result = WSADuplicateSocketW(get_sock_fd(s), processId, &info); Py_END_ALLOW_THREADS @@ -5404,13 +5453,6 @@ sock_share(PyObject *self, PyObject *arg) return set_error(); return PyBytes_FromStringAndSize((const char*)&info, sizeof(info)); } -PyDoc_STRVAR(sock_share_doc, -"share(process_id) -> bytes\n\ -\n\ -Share the socket with another process. The target process id\n\ -must be provided and the resulting bytes object passed to the target\n\ -process. There the shared socket can be instantiated by calling\n\ -socket.fromshare()."); #endif @@ -5418,82 +5460,42 @@ socket.fromshare()."); /* List of methods for socket objects */ static PyMethodDef sock_methods[] = { -#if defined(HAVE_ACCEPT) || defined(HAVE_ACCEPT4) - {"_accept", sock_accept, METH_NOARGS, accept_doc}, -#endif -#ifdef HAVE_BIND - {"bind", sock_bind, METH_O, bind_doc}, -#endif + _SOCKET_SOCKET__ACCEPT_METHODDEF + _SOCKET_SOCKET_BIND_METHODDEF _SOCKET_SOCKET_CLOSE_METHODDEF -#ifdef HAVE_CONNECT - {"connect", sock_connect, METH_O, connect_doc}, - {"connect_ex", sock_connect_ex, METH_O, connect_ex_doc}, -#endif - {"detach", sock_detach, METH_NOARGS, detach_doc}, - {"fileno", sock_fileno, METH_NOARGS, fileno_doc}, -#ifdef HAVE_GETPEERNAME - {"getpeername", sock_getpeername, METH_NOARGS, getpeername_doc}, -#endif -#ifdef HAVE_GETSOCKNAME - {"getsockname", sock_getsockname, METH_NOARGS, getsockname_doc}, -#endif - {"getsockopt", sock_getsockopt, METH_VARARGS, getsockopt_doc}, + _SOCKET_SOCKET_CONNECT_METHODDEF + _SOCKET_SOCKET_CONNECT_EX_METHODDEF + _SOCKET_SOCKET_DETACH_METHODDEF + _SOCKET_SOCKET_FILENO_METHODDEF + _SOCKET_SOCKET_GETPEERNAME_METHODDEF + _SOCKET_SOCKET_GETSOCKNAME_METHODDEF + _SOCKET_SOCKET_GETSOCKOPT_METHODDEF #if defined(MS_WINDOWS) && defined(SIO_RCVALL) {"ioctl", sock_ioctl, METH_VARARGS, sock_ioctl_doc}, #endif -#if defined(MS_WINDOWS) - {"share", sock_share, METH_VARARGS, sock_share_doc}, -#endif -#ifdef HAVE_LISTEN - {"listen", sock_listen, METH_VARARGS, listen_doc}, -#endif - {"recv", sock_recv, METH_VARARGS, recv_doc}, - { - "recv_into", - _PyCFunction_CAST(sock_recv_into), - METH_VARARGS | METH_KEYWORDS, - recv_into_doc - }, -#ifdef HAVE_RECVFROM - {"recvfrom", sock_recvfrom, METH_VARARGS, recvfrom_doc}, - { - "recvfrom_into", - _PyCFunction_CAST(sock_recvfrom_into), - METH_VARARGS | METH_KEYWORDS, - recvfrom_into_doc - }, -#endif + _SOCKET_SOCKET_SHARE_METHODDEF + _SOCKET_SOCKET_LISTEN_METHODDEF + _SOCKET_SOCKET_RECV_METHODDEF + _SOCKET_SOCKET_RECV_INTO_METHODDEF + _SOCKET_SOCKET_RECVFROM_METHODDEF + _SOCKET_SOCKET_RECVFROM_INTO_METHODDEF _SOCKET_SOCKET_SEND_METHODDEF _SOCKET_SOCKET_SENDALL_METHODDEF #ifdef HAVE_SENDTO {"sendto", sock_sendto, METH_VARARGS, sendto_doc}, #endif - {"setblocking", sock_setblocking, METH_O, setblocking_doc}, - {"getblocking", sock_getblocking, METH_NOARGS, getblocking_doc}, - {"settimeout", sock_settimeout, METH_O, settimeout_doc}, - { - "gettimeout", sock_gettimeout_method, METH_NOARGS, - gettimeout_doc - }, + _SOCKET_SOCKET_SETBLOCKING_METHODDEF + _SOCKET_SOCKET_GETBLOCKING_METHODDEF + _SOCKET_SOCKET_SETTIMEOUT_METHODDEF + _SOCKET_SOCKET_GETTIMEOUT_METHODDEF #ifdef HAVE_SETSOCKOPT {"setsockopt", sock_setsockopt, METH_VARARGS, setsockopt_doc}, #endif -#ifdef HAVE_SHUTDOWN - {"shutdown", sock_shutdown, METH_O, shutdown_doc}, -#endif -#ifdef CMSG_LEN - {"recvmsg", sock_recvmsg, METH_VARARGS, recvmsg_doc}, - {"recvmsg_into", sock_recvmsg_into, METH_VARARGS, recvmsg_into_doc}, + _SOCKET_SOCKET_SHUTDOWN_METHODDEF + _SOCKET_SOCKET_RECVMSG_METHODDEF + _SOCKET_SOCKET_RECVMSG_INTO_METHODDEF _SOCKET_SOCKET_SENDMSG_METHODDEF -#endif -#ifdef HAVE_SOCKADDR_ALG - { - "sendmsg_afalg", - _PyCFunction_CAST(sock_sendmsg_afalg), - METH_VARARGS | METH_KEYWORDS, - sendmsg_afalg_doc - }, -#endif + _SOCKET_SOCKET_SENDMSG_AFALG_METHODDEF {NULL, NULL, 0, NULL} /* sentinel */ }; @@ -5872,8 +5874,15 @@ static PyType_Spec sock_spec = { /* Python interface to gethostname(). */ /*ARGSUSED*/ +/*[clinic input] +_socket.gethostname + +Return the current host name. +[clinic start generated code]*/ + static PyObject * -socket_gethostname(PyObject *self, PyObject *unused) +_socket_gethostname_impl(PyObject *module) +/*[clinic end generated code: output=1d9b789d69464c01 input=994028f092f41baf]*/ { if (PySys_Audit("socket.gethostname", NULL) < 0) { return NULL; @@ -5885,10 +5894,12 @@ socket_gethostname(PyObject *self, PyObject *unused) Otherwise, gethostname apparently also returns the DNS name. */ wchar_t buf[MAX_COMPUTERNAME_LENGTH + 1]; DWORD size = Py_ARRAY_LENGTH(buf); - wchar_t *name; - PyObject *result; +#ifdef MS_WINDOWS_DESKTOP if (GetComputerNameExW(ComputerNamePhysicalDnsHostname, buf, &size)) +#else + if (GetComputerNameW(buf, &size)) +#endif return PyUnicode_FromWideChar(buf, size); if (GetLastError() != ERROR_MORE_DATA) @@ -5897,9 +5908,12 @@ socket_gethostname(PyObject *self, PyObject *unused) if (size == 0) return Py_GetConstant(Py_CONSTANT_EMPTY_STR); +#ifndef MS_WINDOWS_DESKTOP + return NULL; +#else /* MSDN says ERROR_MORE_DATA may occur because DNS allows longer names */ - name = PyMem_New(wchar_t, size); + wchar_t* name = PyMem_New(wchar_t, size); if (!name) { PyErr_NoMemory(); return NULL; @@ -5913,15 +5927,14 @@ socket_gethostname(PyObject *self, PyObject *unused) return NULL; } - result = PyUnicode_FromWideChar(name, size); + PyObject* result = PyUnicode_FromWideChar(name, size); PyMem_Free(name); return result; +#endif #else char buf[1024]; int res; - Py_BEGIN_ALLOW_THREADS res = gethostname(buf, (int) sizeof buf - 1); - Py_END_ALLOW_THREADS if (res < 0) return set_error(); buf[sizeof buf - 1] = '\0'; @@ -5929,39 +5942,51 @@ socket_gethostname(PyObject *self, PyObject *unused) #endif } -PyDoc_STRVAR(gethostname_doc, -"gethostname() -> string\n\ -\n\ -Return the current host name."); #endif #ifdef HAVE_SETHOSTNAME -PyDoc_STRVAR(sethostname_doc, -"sethostname(name)\n\n\ -Sets the hostname to name."); + +/*[clinic input] +_socket.sethostname + + name as hnobj: object + / + +Set the hostname to name. +[clinic start generated code]*/ static PyObject * -socket_sethostname(PyObject *self, PyObject *args) +_socket_sethostname(PyObject *module, PyObject *hnobj) +/*[clinic end generated code: output=0b789350cbbc4553 input=89c1a7022cb1082a]*/ { - PyObject *hnobj; Py_buffer buf; int res, flag = 0; +#ifdef __ANDROID__ + // On Android, calling this function as a non-root user leads to a process crash + // rather than returning a permission error. + if (getuid() != 0) { + errno = EPERM; + return set_error(); + } +#endif + #if defined(_AIX) || (defined(__sun) && defined(__SVR4) && Py_SUNOS_VERSION <= 510) /* issue #18259, sethostname is not declared in any useful header file on AIX * the same is true for Solaris 10 */ extern int sethostname(const char *, size_t); #endif - if (!PyArg_ParseTuple(args, "S:sethostname", &hnobj)) { - PyErr_Clear(); - if (!PyArg_ParseTuple(args, "O&:sethostname", - PyUnicode_FSConverter, &hnobj)) + if (!PyBytes_Check(hnobj)) { + if (!PyUnicode_FSConverter(hnobj, &hnobj)) { return NULL; + } flag = 1; } if (PySys_Audit("socket.sethostname", "(O)", hnobj) < 0) { + if (flag) + Py_DECREF(hnobj); return NULL; } @@ -5982,19 +6007,32 @@ extern int sethostname(const char *, size_t); /* Python interface to gethostbyname(name). */ /*ARGSUSED*/ +/*[clinic input] +_socket.gethostbyname + + host as hobj: object + / + +Return the IP address for a host. + +The address is a string of the form '255.255.255.255'. +[clinic start generated code]*/ + static PyObject * -socket_gethostbyname(PyObject *self, PyObject *args) +_socket_gethostbyname(PyObject *module, PyObject *hobj) +/*[clinic end generated code: output=19f571343780c48b input=3c0d3b92e44a1795]*/ { - char *name; struct sockaddr_in addrbuf; + char *name; PyObject *ret = NULL; - if (!PyArg_ParseTuple(args, "et:gethostbyname", "idna", &name)) + if (!PyArg_Parse(hobj, "et:gethostbyname", "idna", &name)) { return NULL; - if (PySys_Audit("socket.gethostbyname", "O", args) < 0) { + } + if (PySys_Audit("socket.gethostbyname", "(O)", hobj) < 0) { goto finally; } - socket_state *state = get_module_state(self); + socket_state *state = get_module_state(module); int rc = setipaddr(state, name, (struct sockaddr *)&addrbuf, sizeof(addrbuf), AF_INET); if (rc < 0) { @@ -6005,11 +6043,6 @@ socket_gethostbyname(PyObject *self, PyObject *args) PyMem_Free(name); return ret; } - -PyDoc_STRVAR(gethostbyname_doc, -"gethostbyname(host) -> address\n\ -\n\ -Return the IP address (a string of the form '255.255.255.255') for a host."); #endif @@ -6031,7 +6064,7 @@ sock_decode_hostname(const char *name) static PyObject * gethost_common(socket_state *state, struct hostent *h, struct sockaddr *addr, - size_t alen, int af) + size_t alen, int af, int h_error) { char **pch; PyObject *rtn_tuple = (PyObject *)NULL; @@ -6042,7 +6075,7 @@ gethost_common(socket_state *state, struct hostent *h, struct sockaddr *addr, if (h == NULL) { /* Let's get real error message to return */ - set_herror(state, h_errno); + set_herror(state, h_error); return NULL; } @@ -6174,10 +6207,24 @@ gethost_common(socket_state *state, struct hostent *h, struct sockaddr *addr, /* Python interface to gethostbyname_ex(name). */ /*ARGSUSED*/ +/*[clinic input] +_socket.gethostbyname_ex + + host as hobj: object + / + +Map a host name to its IP number. + +Return the true host name, a list of aliases, and a list of IP +addresses, which are strings of the form '255.255.255.255'. +[clinic start generated code]*/ + static PyObject * -socket_gethostbyname_ex(PyObject *self, PyObject *args) +_socket_gethostbyname_ex(PyObject *module, PyObject *hobj) +/*[clinic end generated code: output=a1ea4607d257756e input=1ee9eb485339c58b]*/ { char *name; + int h_error; struct hostent *h; sock_addr_t addr; struct sockaddr *sa; @@ -6189,33 +6236,33 @@ socket_gethostbyname_ex(PyObject *self, PyObject *args) #else char buf[16384]; int buf_len = (sizeof buf) - 1; - int errnop; #endif #ifdef HAVE_GETHOSTBYNAME_R_3_ARG int result; #endif #endif /* HAVE_GETHOSTBYNAME_R */ - if (!PyArg_ParseTuple(args, "et:gethostbyname_ex", "idna", &name)) + if (!PyArg_Parse(hobj, "et:gethostbyname_ex", "idna", &name)) { return NULL; - if (PySys_Audit("socket.gethostbyname", "O", args) < 0) { + } + if (PySys_Audit("socket.gethostbyname", "(O)", hobj) < 0) { goto finally; } - socket_state *state = get_module_state(self); + socket_state *state = get_module_state(module); if (setipaddr(state, name, SAS2SA(&addr), sizeof(addr), AF_INET) < 0) { goto finally; } Py_BEGIN_ALLOW_THREADS #ifdef HAVE_GETHOSTBYNAME_R #if defined(HAVE_GETHOSTBYNAME_R_6_ARG) - gethostbyname_r(name, &hp_allocated, buf, buf_len, - &h, &errnop); + gethostbyname_r(name, &hp_allocated, buf, buf_len, &h, &h_error); #elif defined(HAVE_GETHOSTBYNAME_R_5_ARG) - h = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop); + h = gethostbyname_r(name, &hp_allocated, buf, buf_len, &h_error); #else /* HAVE_GETHOSTBYNAME_R_3_ARG */ memset((void *) &data, '\0', sizeof(data)); result = gethostbyname_r(name, &hp_allocated, &data); h = (result != 0) ? NULL : &hp_allocated; + h_error = h_errno; #endif #else /* not HAVE_GETHOSTBYNAME_R */ #ifdef USE_GETHOSTBYNAME_LOCK @@ -6225,6 +6272,7 @@ socket_gethostbyname_ex(PyObject *self, PyObject *args) _Py_COMP_DIAG_IGNORE_DEPR_DECLS h = gethostbyname(name); _Py_COMP_DIAG_POP + h_error = h_errno; #endif /* HAVE_GETHOSTBYNAME_R */ Py_END_ALLOW_THREADS /* Some C libraries would require addr.__ss_family instead of @@ -6233,7 +6281,7 @@ socket_gethostbyname_ex(PyObject *self, PyObject *args) access sa_family. */ sa = SAS2SA(&addr); ret = gethost_common(state, h, SAS2SA(&addr), sizeof(addr), - sa->sa_family); + sa->sa_family, h_error); #ifdef USE_GETHOSTBYNAME_LOCK PyMutex_Unlock(&netdb_lock); #endif @@ -6242,23 +6290,32 @@ socket_gethostbyname_ex(PyObject *self, PyObject *args) return ret; } -PyDoc_STRVAR(ghbn_ex_doc, -"gethostbyname_ex(host) -> (name, aliaslist, addresslist)\n\ -\n\ -Return the true host name, a list of aliases, and a list of IP addresses,\n\ -for a host. The host argument is a string giving a host name or IP number."); #endif #if defined(HAVE_GETHOSTBYNAME_R) || defined (HAVE_GETHOSTBYADDR) /* Python interface to gethostbyaddr(IP). */ /*ARGSUSED*/ +/*[clinic input] +_socket.gethostbyaddr + + host as hobj: object + / + +Map an IP number or host name to the true host name and addresses. + +Return the true host name, a list of aliases, and a list of IP +addresses. The host argument is a string giving a host name or IP +number. +[clinic start generated code]*/ + static PyObject * -socket_gethostbyaddr(PyObject *self, PyObject *args) +_socket_gethostbyaddr(PyObject *module, PyObject *hobj) +/*[clinic end generated code: output=4ba6c4d7a3085ab5 input=c602ba97bf0d395b]*/ { + char *ip_num; sock_addr_t addr; struct sockaddr *sa = SAS2SA(&addr); - char *ip_num; struct hostent *h; PyObject *ret = NULL; #ifdef HAVE_GETHOSTBYNAME_R @@ -6272,7 +6329,6 @@ socket_gethostbyaddr(PyObject *self, PyObject *args) to maintain this alignment. */ _Py_ALIGNED_DEF(8, char) buf[16384]; int buf_len = (sizeof buf) - 1; - int errnop; #endif #ifdef HAVE_GETHOSTBYNAME_R_3_ARG int result; @@ -6281,14 +6337,16 @@ socket_gethostbyaddr(PyObject *self, PyObject *args) const char *ap; int al; int af; + int h_error; - if (!PyArg_ParseTuple(args, "et:gethostbyaddr", "idna", &ip_num)) + if (!PyArg_Parse(hobj, "et:gethostbyaddr", "idna", &ip_num)) { return NULL; - if (PySys_Audit("socket.gethostbyaddr", "O", args) < 0) { + } + if (PySys_Audit("socket.gethostbyaddr", "(O)", hobj) < 0) { goto finally; } af = AF_UNSPEC; - socket_state *state = get_module_state(self); + socket_state *state = get_module_state(module); if (setipaddr(state, ip_num, sa, sizeof(addr), af) < 0) { goto finally; } @@ -6313,16 +6371,14 @@ socket_gethostbyaddr(PyObject *self, PyObject *args) Py_BEGIN_ALLOW_THREADS #ifdef HAVE_GETHOSTBYNAME_R #if defined(HAVE_GETHOSTBYNAME_R_6_ARG) - gethostbyaddr_r(ap, al, af, - &hp_allocated, buf, buf_len, - &h, &errnop); + gethostbyaddr_r(ap, al, af, &hp_allocated, buf, buf_len, &h, &h_error); #elif defined(HAVE_GETHOSTBYNAME_R_5_ARG) - h = gethostbyaddr_r(ap, al, af, - &hp_allocated, buf, buf_len, &errnop); + h = gethostbyaddr_r(ap, al, af, &hp_allocated, buf, buf_len, &h_error); #else /* HAVE_GETHOSTBYNAME_R_3_ARG */ memset((void *) &data, '\0', sizeof(data)); result = gethostbyaddr_r(ap, al, af, &hp_allocated, &data); h = (result != 0) ? NULL : &hp_allocated; + h_error = h_errno; #endif #else /* not HAVE_GETHOSTBYNAME_R */ #ifdef USE_GETHOSTBYNAME_LOCK @@ -6332,9 +6388,10 @@ socket_gethostbyaddr(PyObject *self, PyObject *args) _Py_COMP_DIAG_IGNORE_DEPR_DECLS h = gethostbyaddr(ap, al, af); _Py_COMP_DIAG_POP + h_error = h_errno; #endif /* HAVE_GETHOSTBYNAME_R */ Py_END_ALLOW_THREADS - ret = gethost_common(state, h, SAS2SA(&addr), sizeof(addr), af); + ret = gethost_common(state, h, SAS2SA(&addr), sizeof(addr), af, h_error); #ifdef USE_GETHOSTBYNAME_LOCK PyMutex_Unlock(&netdb_lock); #endif @@ -6342,12 +6399,6 @@ socket_gethostbyaddr(PyObject *self, PyObject *args) PyMem_Free(ip_num); return ret; } - -PyDoc_STRVAR(gethostbyaddr_doc, -"gethostbyaddr(host) -> (name, aliaslist, addresslist)\n\ -\n\ -Return the true host name, a list of aliases, and a list of IP addresses,\n\ -for a host. The host argument is a string giving a host name or IP number."); #endif #ifdef HAVE_GETSERVBYNAME @@ -6356,13 +6407,25 @@ for a host. The host argument is a string giving a host name or IP number."); known or not useful (like the list of aliases). */ /*ARGSUSED*/ +/*[clinic input] +_socket.getservbyname + + servicename as name: str + protocolname as proto: str = NULL + / + +Return a port number from a service name and protocol name. + +The optional protocol name, if given, should be 'tcp' or 'udp', +otherwise any protocol will match. +[clinic start generated code]*/ + static PyObject * -socket_getservbyname(PyObject *self, PyObject *args) +_socket_getservbyname_impl(PyObject *module, const char *name, + const char *proto) +/*[clinic end generated code: output=b0c47287f8ec2b00 input=a8e3ad7ced8c8798]*/ { - const char *name, *proto=NULL; struct servent *sp; - if (!PyArg_ParseTuple(args, "s|s:getservbyname", &name, &proto)) - return NULL; if (PySys_Audit("socket.getservbyname", "ss", name, proto) < 0) { return NULL; @@ -6378,12 +6441,6 @@ socket_getservbyname(PyObject *self, PyObject *args) return PyLong_FromLong((long) ntohs(sp->s_port)); } -PyDoc_STRVAR(getservbyname_doc, -"getservbyname(servicename[, protocolname]) -> integer\n\ -\n\ -Return a port number from a service name and protocol name.\n\ -The optional protocol name, if given, should be 'tcp' or 'udp',\n\ -otherwise any protocol will match."); #endif #ifdef HAVE_GETSERVBYPORT @@ -6392,14 +6449,25 @@ otherwise any protocol will match."); known or not useful (like the list of aliases). */ /*ARGSUSED*/ +/*[clinic input] +_socket.getservbyport + + port: int + protocolname as proto: str = NULL + / + +Return the service name from a port number and protocol name. + +The optional protocol name, if given, should be 'tcp' or 'udp', +otherwise any protocol will match. +[clinic start generated code]*/ + static PyObject * -socket_getservbyport(PyObject *self, PyObject *args) +_socket_getservbyport_impl(PyObject *module, int port, const char *proto) +/*[clinic end generated code: output=42351ab1857aa9e4 input=9a2a3091ea6ff146]*/ { - int port; - const char *proto=NULL; struct servent *sp; - if (!PyArg_ParseTuple(args, "i|s:getservbyport", &port, &proto)) - return NULL; + if (port < 0 || port > 0xffff) { PyErr_SetString( PyExc_OverflowError, @@ -6418,15 +6486,10 @@ socket_getservbyport(PyObject *self, PyObject *args) PyErr_SetString(PyExc_OSError, "port/proto not found"); return NULL; } + _Py_MSAN_UNPOISON_STRING(sp->s_name); return PyUnicode_FromString(sp->s_name); } -PyDoc_STRVAR(getservbyport_doc, -"getservbyport(port[, protocolname]) -> string\n\ -\n\ -Return the service name from a port number and protocol name.\n\ -The optional protocol name, if given, should be 'tcp' or 'udp',\n\ -otherwise any protocol will match."); #endif #ifdef HAVE_GETPROTOBYNAME @@ -6435,13 +6498,20 @@ otherwise any protocol will match."); already known or not useful (like the list of aliases). */ /*ARGSUSED*/ +/*[clinic input] +_socket.getprotobyname + + name: str + / + +Return the protocol number for the named protocol. +[clinic start generated code]*/ + static PyObject * -socket_getprotobyname(PyObject *self, PyObject *args) +_socket_getprotobyname_impl(PyObject *module, const char *name) +/*[clinic end generated code: output=30fb71f0c6ffbaea input=d197d3726c828e38]*/ { - const char *name; struct protoent *sp; - if (!PyArg_ParseTuple(args, "s:getprotobyname", &name)) - return NULL; Py_BEGIN_ALLOW_THREADS sp = getprotobyname(name); Py_END_ALLOW_THREADS @@ -6452,14 +6522,23 @@ socket_getprotobyname(PyObject *self, PyObject *args) return PyLong_FromLong((long) sp->p_proto); } -PyDoc_STRVAR(getprotobyname_doc, -"getprotobyname(name) -> integer\n\ -\n\ -Return the protocol number for the named protocol. (Rarely used.)"); #endif +/*[clinic input] +_socket.close + + fd as fdobj: object + / + +Close a socket fd. + +This is like os.close(), but for sockets; on some platforms os.close() +won't work for socket file descriptors. +[clinic start generated code]*/ + static PyObject * -socket_close(PyObject *self, PyObject *fdobj) +_socket_close(PyObject *module, PyObject *fdobj) +/*[clinic end generated code: output=1d62092e6fc365dc input=b9fc18380117ee4b]*/ { SOCKET_T fd; int res; @@ -6478,17 +6557,26 @@ socket_close(PyObject *self, PyObject *fdobj) Py_RETURN_NONE; } -PyDoc_STRVAR(close_doc, -"close(integer) -> None\n\ -\n\ -Close an integer socket file descriptor. This is like os.close(), but for\n\ -sockets; on some platforms os.close() won't work for socket file descriptors."); #ifndef NO_DUP /* dup() function for socket fds */ +/*[clinic input] +_socket.dup + + fd as fdobj: object + / + +Duplicate a socket descriptor. + +The new descriptor is non-inheritable. This is like os.dup(), but for +sockets; on some platforms os.dup() won't work for socket file +descriptors. +[clinic start generated code]*/ + static PyObject * -socket_dup(PyObject *self, PyObject *fdobj) +_socket_dup(PyObject *module, PyObject *fdobj) +/*[clinic end generated code: output=7e9c4485cf5a76c0 input=d1d74c320feb3d04]*/ { SOCKET_T fd, newfd; PyObject *newfdobj; @@ -6532,11 +6620,6 @@ socket_dup(PyObject *self, PyObject *fdobj) return newfdobj; } -PyDoc_STRVAR(dup_doc, -"dup(integer) -> integer\n\ -\n\ -Duplicate an integer socket file descriptor. This is like os.dup(), but for\n\ -sockets; on some platforms os.dup() won't work for socket file descriptors."); #endif @@ -6546,13 +6629,29 @@ sockets; on some platforms os.dup() won't work for socket file descriptors."); defined on the platform; otherwise, the default is AF_INET. */ /*ARGSUSED*/ +/*[clinic input] +_socket.socketpair + + family: int(c_default="SOCKETPAIR_DEFAULT_FAMILY") = AF_UNIX + type: int(c_default="SOCK_STREAM") = SOCK_STREAM + proto: int = 0 + / + +Create a pair of connected socket objects. + +The sockets are returned by the platform socketpair() function. The +arguments are the same as for socket(), except that the default +family is AF_UNIX if defined on the platform; otherwise, the default +is AF_INET. +[clinic start generated code]*/ + static PyObject * -socket_socketpair(PyObject *self, PyObject *args) +_socket_socketpair_impl(PyObject *module, int family, int type, int proto) +/*[clinic end generated code: output=c012ae1f558bb0ca input=59695511a31a2d52]*/ { PySocketSockObject *s0 = NULL, *s1 = NULL; SOCKET_T sv[2]; - int family, type = SOCK_STREAM, proto = 0; - socket_state *state = get_module_state(self); + socket_state *state = get_module_state(module); #ifdef SOCK_CLOEXEC int *atomic_flag_works = &sock_cloexec_works; #else @@ -6560,15 +6659,6 @@ socket_socketpair(PyObject *self, PyObject *args) #endif int ret; -#if defined(AF_UNIX) - family = AF_UNIX; -#else - family = AF_INET; -#endif - if (!PyArg_ParseTuple(args, "|iii:socketpair", - &family, &type, &proto)) - return NULL; - /* Create a pair of socket fds */ Py_BEGIN_ALLOW_THREADS #ifdef SOCK_CLOEXEC @@ -6618,13 +6708,6 @@ socket_socketpair(PyObject *self, PyObject *args) return NULL; } -PyDoc_STRVAR(socketpair_doc, -"socketpair([family[, type [, proto]]]) -> (socket object, socket object)\n\ -\n\ -Create a pair of socket objects from the sockets returned by the platform\n\ -socketpair() function.\n\ -The arguments are the same as for socket() except the default family is\n\ -AF_UNIX if defined on the platform; otherwise, the default is AF_INET."); #endif /* HAVE_SOCKETPAIR */ @@ -6801,27 +6884,29 @@ _socket_inet_ntoa_impl(PyObject *module, Py_buffer *packed_ip) #ifdef HAVE_INET_PTON -PyDoc_STRVAR(inet_pton_doc, -"inet_pton(af, ip) -> packed IP address string\n\ -\n\ -Convert an IP address from string format to a packed string suitable\n\ -for use with low-level network functions."); + +/*[clinic input] +_socket.inet_pton + + af: int + ip: str + / + +Convert an IP address from string format to a packed string. + +The string is suitable for use with low-level network functions. +[clinic start generated code]*/ static PyObject * -socket_inet_pton(PyObject *self, PyObject *args) +_socket_inet_pton_impl(PyObject *module, int af, const char *ip) +/*[clinic end generated code: output=a1488ddddc478dc2 input=044acc246469c125]*/ { - int af; - const char* ip; int retval; #ifdef ENABLE_IPV6 char packed[Py_MAX(sizeof(struct in_addr), sizeof(struct in6_addr))]; #else char packed[sizeof(struct in_addr)]; #endif - if (!PyArg_ParseTuple(args, "is:inet_pton", &af, &ip)) { - return NULL; - } - #if !defined(ENABLE_IPV6) && defined(AF_INET6) if(af == AF_INET6) { PyErr_SetString(PyExc_OSError, @@ -6852,16 +6937,21 @@ socket_inet_pton(PyObject *self, PyObject *args) } } -PyDoc_STRVAR(inet_ntop_doc, -"inet_ntop(af, packed_ip) -> string formatted IP address\n\ -\n\ -Convert a packed IP address of the given family to string format."); + +/*[clinic input] +_socket.inet_ntop + + af: int + packed_ip: Py_buffer + / + +Convert a packed IP address of the given family to string format. +[clinic start generated code]*/ static PyObject * -socket_inet_ntop(PyObject *self, PyObject *args) +_socket_inet_ntop_impl(PyObject *module, int af, Py_buffer *packed_ip) +/*[clinic end generated code: output=eabff3e56456ede0 input=7027f0a0abdf71d1]*/ { - int af; - Py_buffer packed_ip; const char* retval; #ifdef ENABLE_IPV6 char ip[Py_MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN)]; @@ -6869,43 +6959,33 @@ socket_inet_ntop(PyObject *self, PyObject *args) char ip[INET_ADDRSTRLEN]; #endif - if (!PyArg_ParseTuple(args, "iy*:inet_ntop", &af, &packed_ip)) { - return NULL; - } - if (af == AF_INET) { - if (packed_ip.len != sizeof(struct in_addr)) { + if (packed_ip->len != sizeof(struct in_addr)) { PyErr_SetString(PyExc_ValueError, "invalid length of packed IP address string"); - PyBuffer_Release(&packed_ip); return NULL; } #ifdef ENABLE_IPV6 } else if (af == AF_INET6) { - if (packed_ip.len != sizeof(struct in6_addr)) { + if (packed_ip->len != sizeof(struct in6_addr)) { PyErr_SetString(PyExc_ValueError, "invalid length of packed IP address string"); - PyBuffer_Release(&packed_ip); return NULL; } #endif } else { PyErr_Format(PyExc_ValueError, "unknown address family %d", af); - PyBuffer_Release(&packed_ip); return NULL; } /* inet_ntop guarantee NUL-termination of resulting string. */ - retval = inet_ntop(af, packed_ip.buf, ip, sizeof(ip)); + retval = inet_ntop(af, packed_ip->buf, ip, sizeof(ip)); if (!retval) { PyErr_SetFromErrno(PyExc_OSError); - PyBuffer_Release(&packed_ip); return NULL; - } else { - PyBuffer_Release(&packed_ip); - return PyUnicode_FromString(retval); } + return PyUnicode_FromString(retval); } #endif /* HAVE_INET_PTON */ @@ -6914,29 +6994,35 @@ socket_inet_ntop(PyObject *self, PyObject *args) /* Python interface to getaddrinfo(host, port). */ /*ARGSUSED*/ +/*[clinic input] +_socket.getaddrinfo + + host as hobj: object + port as pobj: object + family: int(c_default="AF_UNSPEC") = AF_UNSPEC + type as socktype: int = 0 + proto as protocol: int = 0 + flags: int = 0 + +Resolve host and port into a list of 5-tuples. + +Each tuple is (family, type, proto, canonname, sockaddr). +[clinic start generated code]*/ + static PyObject * -socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs) +_socket_getaddrinfo_impl(PyObject *module, PyObject *hobj, PyObject *pobj, + int family, int socktype, int protocol, int flags) +/*[clinic end generated code: output=a54f59f33f3da184 input=1fd64ac89aee1d18]*/ { - static char* kwnames[] = {"host", "port", "family", "type", "proto", - "flags", 0}; struct addrinfo hints, *res; struct addrinfo *res0 = NULL; - PyObject *hobj = NULL; - PyObject *pobj = (PyObject *)NULL; PyObject *pstr = NULL; const char *hptr, *pptr; - int family, socktype, protocol, flags; + Py_ssize_t hlen = 0, plen = 0; int error; PyObject *all = (PyObject *)NULL; PyObject *idna = NULL; - socktype = protocol = flags = 0; - family = AF_UNSPEC; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|iiii:getaddrinfo", - kwnames, &hobj, &pobj, &family, &socktype, - &protocol, &flags)) { - return NULL; - } if (hobj == Py_None) { hptr = NULL; } else if (PyUnicode_Check(hobj)) { @@ -6945,13 +7031,20 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs) return NULL; assert(PyBytes_Check(idna)); hptr = PyBytes_AS_STRING(idna); + hlen = PyBytes_GET_SIZE(idna); } else if (PyBytes_Check(hobj)) { - hptr = PyBytes_AsString(hobj); + hptr = PyBytes_AS_STRING(hobj); + hlen = PyBytes_GET_SIZE(hobj); } else { PyErr_SetString(PyExc_TypeError, "getaddrinfo() argument 1 must be string or None"); return NULL; } + if (hptr != NULL && strlen(hptr) != (size_t)hlen) { + PyErr_SetString(PyExc_ValueError, + "getaddrinfo() host must not contain null characters"); + goto err; + } if (PyIndex_Check(pobj)) { pstr = PyNumber_Index(pobj); if (pstr == NULL) @@ -6961,21 +7054,27 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs) if (pstr == NULL) goto err; assert(PyUnicode_Check(pstr)); - pptr = PyUnicode_AsUTF8(pstr); + pptr = PyUnicode_AsUTF8AndSize(pstr, &plen); if (pptr == NULL) goto err; } else if (PyUnicode_Check(pobj)) { - pptr = PyUnicode_AsUTF8(pobj); + pptr = PyUnicode_AsUTF8AndSize(pobj, &plen); if (pptr == NULL) goto err; } else if (PyBytes_Check(pobj)) { pptr = PyBytes_AS_STRING(pobj); + plen = PyBytes_GET_SIZE(pobj); } else if (pobj == Py_None) { pptr = (char *)NULL; } else { PyErr_SetString(PyExc_OSError, "Int or String expected"); goto err; } + if (pptr != NULL && strlen(pptr) != (size_t)plen) { + PyErr_SetString(PyExc_ValueError, + "getaddrinfo() port must not contain null characters"); + goto err; + } #if defined(__APPLE__) && defined(AI_NUMERICSERV) if ((flags & AI_NUMERICSERV) && (pptr == NULL || (pptr[0] == '0' && pptr[1] == 0))) { /* On OSX up to at least OSX 10.8 getaddrinfo crashes @@ -7001,7 +7100,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs) Py_END_ALLOW_THREADS if (error) { res0 = NULL; // gh-100795 - socket_state *state = get_module_state(self); + socket_state *state = get_module_state(module); set_gaierror(state, error); goto err; } @@ -7043,22 +7142,26 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs) return (PyObject *)NULL; } -PyDoc_STRVAR(getaddrinfo_doc, -"getaddrinfo(host, port [, family, type, proto, flags])\n\ - -> list of (family, type, proto, canonname, sockaddr)\n\ -\n\ -Resolve host and port into addrinfo struct."); #endif // HAVE_GETADDRINFO #ifdef HAVE_GETNAMEINFO /* Python interface to getnameinfo(sa, flags). */ /*ARGSUSED*/ +/*[clinic input] +_socket.getnameinfo + + sockaddr as sa: object + flags: int + / + +Get host and port for a sockaddr. +[clinic start generated code]*/ + static PyObject * -socket_getnameinfo(PyObject *self, PyObject *args) +_socket_getnameinfo_impl(PyObject *module, PyObject *sa, int flags) +/*[clinic end generated code: output=2e1d7ef2bd94f698 input=dd0444ac9adae4d3]*/ { - PyObject *sa = (PyObject *)NULL; - int flags; const char *hostp; int port; unsigned int flowinfo, scope_id; @@ -7068,9 +7171,7 @@ socket_getnameinfo(PyObject *self, PyObject *args) PyObject *ret = (PyObject *)NULL; PyObject *name; - flags = flowinfo = scope_id = 0; - if (!PyArg_ParseTuple(args, "Oi:getnameinfo", &sa, &flags)) - return NULL; + flowinfo = scope_id = 0; if (!PyTuple_Check(sa)) { PyErr_SetString(PyExc_TypeError, "getnameinfo() argument 1 must be a tuple"); @@ -7101,7 +7202,7 @@ socket_getnameinfo(PyObject *self, PyObject *args) Py_END_ALLOW_THREADS if (error) { res = NULL; // gh-100795 - socket_state *state = get_module_state(self); + socket_state *state = get_module_state(module); set_gaierror(state, error); goto fail; } @@ -7136,7 +7237,7 @@ socket_getnameinfo(PyObject *self, PyObject *args) hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), flags); Py_END_ALLOW_THREADS if (error) { - socket_state *state = get_module_state(self); + socket_state *state = get_module_state(module); set_gaierror(state, error); goto fail; } @@ -7152,18 +7253,24 @@ socket_getnameinfo(PyObject *self, PyObject *args) return ret; } -PyDoc_STRVAR(getnameinfo_doc, -"getnameinfo(sockaddr, flags) --> (host, port)\n\ -\n\ -Get host and port for a sockaddr."); #endif // HAVE_GETNAMEINFO /* Python API to getting and setting the default timeout value. */ +/*[clinic input] +_socket.getdefaulttimeout + +Return the default timeout in seconds for new socket objects. + +A value of None indicates that new socket objects have no timeout. +When the socket module is first imported, the default is None. +[clinic start generated code]*/ + static PyObject * -socket_getdefaulttimeout(PyObject *self, PyObject *Py_UNUSED(ignored)) +_socket_getdefaulttimeout_impl(PyObject *module) +/*[clinic end generated code: output=7b3e1be56948c44c input=c9fb729acf998a58]*/ { - socket_state *state = get_module_state(self); + socket_state *state = get_module_state(module); PyTime_t timeout = _Py_atomic_load_int64_relaxed(&state->defaulttimeout); if (timeout < 0) { Py_RETURN_NONE; @@ -7174,39 +7281,47 @@ socket_getdefaulttimeout(PyObject *self, PyObject *Py_UNUSED(ignored)) } } -PyDoc_STRVAR(getdefaulttimeout_doc, -"getdefaulttimeout() -> timeout\n\ -\n\ -Returns the default timeout in seconds (float) for new socket objects.\n\ -A value of None indicates that new socket objects have no timeout.\n\ -When the socket module is first imported, the default is None."); + +/*[clinic input] +_socket.setdefaulttimeout + + timeout as arg: object + / + +Set the default timeout in seconds for new socket objects. + +A value of None indicates that new socket objects have no timeout. +When the socket module is first imported, the default is None. +[clinic start generated code]*/ static PyObject * -socket_setdefaulttimeout(PyObject *self, PyObject *arg) +_socket_setdefaulttimeout(PyObject *module, PyObject *arg) +/*[clinic end generated code: output=b5d59296163d66bf input=929785d885173684]*/ { PyTime_t timeout; if (socket_parse_timeout(&timeout, arg) < 0) return NULL; - socket_state *state = get_module_state(self); + socket_state *state = get_module_state(module); _Py_atomic_store_int64_relaxed(&state->defaulttimeout, timeout); Py_RETURN_NONE; } -PyDoc_STRVAR(setdefaulttimeout_doc, -"setdefaulttimeout(timeout)\n\ -\n\ -Set the default timeout in seconds (real number) for new socket objects.\n\ -A value of None indicates that new socket objects have no timeout.\n\ -When the socket module is first imported, the default is None."); -#if defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS) +#if defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS_DESKTOP) /* Python API for getting interface indices and names */ +/*[clinic input] +_socket.if_nameindex + +Return a list of network interface information (index, name) tuples. +[clinic start generated code]*/ + static PyObject * -socket_if_nameindex(PyObject *self, PyObject *arg) +_socket_if_nameindex_impl(PyObject *module) +/*[clinic end generated code: output=93c863a6262059c4 input=d6438bb556de2100]*/ { PyObject *list = PyList_New(0); if (list == NULL) { @@ -7286,10 +7401,9 @@ socket_if_nameindex(PyObject *self, PyObject *arg) #endif } -PyDoc_STRVAR(if_nameindex_doc, -"if_nameindex()\n\ -\n\ -Returns a list of network interface information (index, name) tuples."); +#endif // defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS_DESKTOP) + +#if defined(_Py_HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS_DESKTOP) /*[clinic input] _socket.if_nametoindex @@ -7319,6 +7433,9 @@ _socket_if_nametoindex_impl(PyObject *module, PyObject *oname) return PyLong_FromUnsignedLong(index); } +#endif // defined(_Py_HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS_DESKTOP) + +#if defined(_Py_HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP) /*[clinic input] @permit_long_summary @@ -7343,20 +7460,34 @@ _socket_if_indextoname_impl(PyObject *module, NET_IFINDEX index) return PyUnicode_DecodeFSDefault(name); } -#endif // defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS) +#endif // defined(_Py_HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP) #ifdef CMSG_LEN /* Python interface to CMSG_LEN(length). */ +/*[clinic input] +_socket.CMSG_LEN + + length: Py_ssize_t + / + +Return the total length of an ancillary data item with associated data. + +The associated data has the given length. This value can often be +used as the buffer size for recvmsg() to receive a single item of +ancillary data, but RFC 3542 requires portable applications to use +CMSG_SPACE() and thus include space for padding, even when the item +will be the last in the buffer. Raises OverflowError if length is +outside the permissible range of values. +[clinic start generated code]*/ + static PyObject * -socket_CMSG_LEN(PyObject *self, PyObject *args) +_socket_CMSG_LEN_impl(PyObject *module, Py_ssize_t length) +/*[clinic end generated code: output=e1dd6bb3a3f4a7ff input=b0787fd8c8d9c7be]*/ { - Py_ssize_t length; size_t result; - if (!PyArg_ParseTuple(args, "n:CMSG_LEN", &length)) - return NULL; if (length < 0 || !get_CMSG_LEN(length, &result)) { PyErr_Format(PyExc_OverflowError, "CMSG_LEN() argument out of range"); return NULL; @@ -7364,29 +7495,32 @@ socket_CMSG_LEN(PyObject *self, PyObject *args) return PyLong_FromSize_t(result); } -PyDoc_STRVAR(CMSG_LEN_doc, -"CMSG_LEN(length) -> control message length\n\ -\n\ -Return the total length, without trailing padding, of an ancillary\n\ -data item with associated data of the given length. This value can\n\ -often be used as the buffer size for recvmsg() to receive a single\n\ -item of ancillary data, but RFC 3542 requires portable applications to\n\ -use CMSG_SPACE() and thus include space for padding, even when the\n\ -item will be the last in the buffer. Raises OverflowError if length\n\ -is outside the permissible range of values."); #ifdef CMSG_SPACE /* Python interface to CMSG_SPACE(length). */ +/*[clinic input] +_socket.CMSG_SPACE + + length: Py_ssize_t + / + +Return the buffer size needed to receive an ancillary data item. + +The item has associated data of the given length, and the size +includes any trailing padding. The buffer space needed to receive +multiple items is the sum of the CMSG_SPACE() values for their +associated data lengths. Raises OverflowError if length is outside +the permissible range of values. +[clinic start generated code]*/ + static PyObject * -socket_CMSG_SPACE(PyObject *self, PyObject *args) +_socket_CMSG_SPACE_impl(PyObject *module, Py_ssize_t length) +/*[clinic end generated code: output=857b925dc29c68c3 input=dedf123dcda72642]*/ { - Py_ssize_t length; size_t result; - if (!PyArg_ParseTuple(args, "n:CMSG_SPACE", &length)) - return NULL; if (length < 0 || !get_CMSG_SPACE(length, &result)) { PyErr_SetString(PyExc_OverflowError, "CMSG_SPACE() argument out of range"); @@ -7395,15 +7529,6 @@ socket_CMSG_SPACE(PyObject *self, PyObject *args) return PyLong_FromSize_t(result); } -PyDoc_STRVAR(CMSG_SPACE_doc, -"CMSG_SPACE(length) -> buffer size\n\ -\n\ -Return the buffer size needed for recvmsg() to receive an ancillary\n\ -data item with associated data of the given length, along with any\n\ -trailing padding. The buffer space needed to receive multiple items\n\ -is the sum of the CMSG_SPACE() values for their associated data\n\ -lengths. Raises OverflowError if length is outside the permissible\n\ -range of values."); #endif /* CMSG_SPACE */ #endif /* CMSG_LEN */ @@ -7411,88 +7536,34 @@ range of values."); /* List of functions exported by this module. */ static PyMethodDef socket_methods[] = { -#ifdef HAVE_GETADDRINFO - {"gethostbyname", socket_gethostbyname, - METH_VARARGS, gethostbyname_doc}, -#endif -#if defined(HAVE_GETHOSTBYNAME_R) || defined (HAVE_GETHOSTBYNAME) - {"gethostbyname_ex", socket_gethostbyname_ex, - METH_VARARGS, ghbn_ex_doc}, -#endif -#if defined(HAVE_GETHOSTBYNAME_R) || defined (HAVE_GETHOSTBYADDR) - {"gethostbyaddr", socket_gethostbyaddr, - METH_VARARGS, gethostbyaddr_doc}, -#endif -#ifdef HAVE_GETHOSTNAME - {"gethostname", socket_gethostname, - METH_NOARGS, gethostname_doc}, -#endif -#ifdef HAVE_SETHOSTNAME - {"sethostname", socket_sethostname, - METH_VARARGS, sethostname_doc}, -#endif -#ifdef HAVE_GETSERVBYNAME - {"getservbyname", socket_getservbyname, - METH_VARARGS, getservbyname_doc}, -#endif -#ifdef HAVE_GETSERVBYPORT - {"getservbyport", socket_getservbyport, - METH_VARARGS, getservbyport_doc}, -#endif -#ifdef HAVE_GETPROTOBYNAME - {"getprotobyname", socket_getprotobyname, - METH_VARARGS, getprotobyname_doc}, -#endif - {"close", socket_close, - METH_O, close_doc}, -#ifndef NO_DUP - {"dup", socket_dup, - METH_O, dup_doc}, -#endif -#ifdef HAVE_SOCKETPAIR - {"socketpair", socket_socketpair, - METH_VARARGS, socketpair_doc}, -#endif + _SOCKET_GETHOSTBYNAME_METHODDEF + _SOCKET_GETHOSTBYNAME_EX_METHODDEF + _SOCKET_GETHOSTBYADDR_METHODDEF + _SOCKET_GETHOSTNAME_METHODDEF + _SOCKET_SETHOSTNAME_METHODDEF + _SOCKET_GETSERVBYNAME_METHODDEF + _SOCKET_GETSERVBYPORT_METHODDEF + _SOCKET_GETPROTOBYNAME_METHODDEF + _SOCKET_CLOSE_METHODDEF + _SOCKET_DUP_METHODDEF + _SOCKET_SOCKETPAIR_METHODDEF _SOCKET_NTOHS_METHODDEF _SOCKET_NTOHL_METHODDEF _SOCKET_HTONS_METHODDEF _SOCKET_HTONL_METHODDEF _SOCKET_INET_ATON_METHODDEF -#ifdef HAVE_INET_NTOA _SOCKET_INET_NTOA_METHODDEF -#endif -#ifdef HAVE_INET_PTON - {"inet_pton", socket_inet_pton, - METH_VARARGS, inet_pton_doc}, - {"inet_ntop", socket_inet_ntop, - METH_VARARGS, inet_ntop_doc}, -#endif -#ifdef HAVE_GETADDRINFO - {"getaddrinfo", _PyCFunction_CAST(socket_getaddrinfo), - METH_VARARGS | METH_KEYWORDS, getaddrinfo_doc}, -#endif -#ifdef HAVE_GETNAMEINFO - {"getnameinfo", socket_getnameinfo, - METH_VARARGS, getnameinfo_doc}, -#endif - {"getdefaulttimeout", socket_getdefaulttimeout, - METH_NOARGS, getdefaulttimeout_doc}, - {"setdefaulttimeout", socket_setdefaulttimeout, - METH_O, setdefaulttimeout_doc}, -#if defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS) - {"if_nameindex", socket_if_nameindex, - METH_NOARGS, if_nameindex_doc}, + _SOCKET_INET_PTON_METHODDEF + _SOCKET_INET_NTOP_METHODDEF + _SOCKET_GETADDRINFO_METHODDEF + _SOCKET_GETNAMEINFO_METHODDEF + _SOCKET_GETDEFAULTTIMEOUT_METHODDEF + _SOCKET_SETDEFAULTTIMEOUT_METHODDEF + _SOCKET_IF_NAMEINDEX_METHODDEF _SOCKET_IF_NAMETOINDEX_METHODDEF _SOCKET_IF_INDEXTONAME_METHODDEF -#endif -#ifdef CMSG_LEN - {"CMSG_LEN", socket_CMSG_LEN, - METH_VARARGS, CMSG_LEN_doc}, -#ifdef CMSG_SPACE - {"CMSG_SPACE", socket_CMSG_SPACE, - METH_VARARGS, CMSG_SPACE_doc}, -#endif -#endif + _SOCKET_CMSG_LEN_METHODDEF + _SOCKET_CMSG_SPACE_METHODDEF {NULL, NULL} /* Sentinel */ }; @@ -9292,7 +9363,7 @@ socket_exec(PyObject *m) #endif #endif /* _MSTCPIP_ */ -#ifdef MS_WINDOWS +#ifdef MS_WINDOWS_DESKTOP /* remove some flags on older version Windows during run-time */ if (remove_unusable_flags(m) < 0) { goto error; diff --git a/Modules/symtablemodule.c b/Modules/symtablemodule.c index 7e20b5c7173ae5d..3028158fc917e1d 100644 --- a/Modules/symtablemodule.c +++ b/Modules/symtablemodule.c @@ -128,7 +128,6 @@ symtable_init_constants(PyObject *m) if (PyModule_AddIntMacro(m, DEF_BOUND) < 0) return -1; if (PyModule_AddIntMacro(m, DEF_ANNOT) < 0) return -1; if (PyModule_AddIntMacro(m, DEF_COMP_ITER) < 0) return -1; - if (PyModule_AddIntMacro(m, DEF_COMP_CELL) < 0) return -1; if (PyModule_AddIntConstant(m, "TYPE_FUNCTION", FunctionBlock) < 0) return -1; @@ -144,6 +143,8 @@ symtable_init_constants(PyObject *m) return -1; if (PyModule_AddIntConstant(m, "TYPE_TYPE_VARIABLE", TypeVariableBlock) < 0) return -1; + if (PyModule_AddIntConstant(m, "TYPE_INLINED_COMPREHENSION", InlinedComprehensionBlock) < 0) + return -1; if (PyModule_AddIntMacro(m, LOCAL) < 0) return -1; if (PyModule_AddIntMacro(m, GLOBAL_EXPLICIT) < 0) return -1; diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c index 2d13f9eda758ddc..d7acefa6542a033 100644 --- a/Modules/syslogmodule.c +++ b/Modules/syslogmodule.c @@ -69,7 +69,7 @@ module syslog /* only one instance, only one syslog, so globals should be ok, * these fields are writable from the main interpreter only. */ static PyObject *S_ident_o = NULL; // identifier, held by openlog() -static char S_log_open = 0; +static int S_log_open = 0; static inline int is_main_interpreter(void) @@ -106,8 +106,7 @@ syslog_get_argv(void) return NULL; } - scriptobj = PyList_GetItem(argv, 0); - Py_XINCREF(scriptobj); + scriptobj = PyList_GetItemRef(argv, 0); Py_DECREF(argv); if (scriptobj == NULL) { PyErr_Clear(); @@ -189,7 +188,7 @@ syslog_openlog_impl(PyObject *module, PyObject *ident, long logopt, } openlog(ident_str, logopt, facility); - S_log_open = 1; + _Py_atomic_store_int(&S_log_open, 1); Py_XSETREF(S_ident_o, ident); Py_RETURN_NONE; @@ -222,7 +221,7 @@ syslog_syslog_impl(PyObject *module, int group_left_1, int priority, } /* if log is not opened, open it now */ - if (!S_log_open) { + if (!_Py_atomic_load_int(&S_log_open)) { if (!is_main_interpreter()) { PyErr_SetString(PyExc_RuntimeError, "subinterpreter can't use syslog.syslog() " "until the syslog is opened by the main interpreter"); @@ -235,10 +234,6 @@ syslog_syslog_impl(PyObject *module, int group_left_1, int priority, Py_DECREF(openlog_ret); } - /* Incref ident, because it can be decrefed if syslog.openlog() is - * called when the GIL is released. - */ - PyObject *ident = Py_XNewRef(S_ident_o); #ifdef __APPLE__ // gh-98178: On macOS, libc syslog() is not thread-safe syslog(priority, "%s", message); @@ -247,7 +242,6 @@ syslog_syslog_impl(PyObject *module, int group_left_1, int priority, syslog(priority, "%s", message); Py_END_ALLOW_THREADS; #endif - Py_XDECREF(ident); Py_RETURN_NONE; } @@ -273,10 +267,11 @@ syslog_closelog_impl(PyObject *module) if (PySys_Audit("syslog.closelog", NULL) < 0) { return NULL; } - if (S_log_open) { + + int was_open = _Py_atomic_exchange_int(&S_log_open, 0); + if (was_open) { closelog(); Py_CLEAR(S_ident_o); - S_log_open = 0; } Py_RETURN_NONE; } diff --git a/Modules/termios.c b/Modules/termios.c index 38743e176f0bf6c..cad8b67ddc7feeb 100644 --- a/Modules/termios.c +++ b/Modules/termios.c @@ -21,12 +21,6 @@ # include #endif -// Apparently, on SGI, termios.h won't define CTRL if _XOPEN_SOURCE -// is defined, so we define it here. -#if defined(__sgi) -# define CTRL(c) ((c)&037) -#endif - // We could do better. Check bpo-32660 #if defined(__sun) # include diff --git a/Modules/timemodule.c b/Modules/timemodule.c index d90bf1f2ef90ed9..395d6ec0f92d5f8 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -5,6 +5,7 @@ #include "pycore_moduleobject.h" // _PyModule_GetState() #include "pycore_namespace.h" // _PyNamespace_New() #include "pycore_runtime.h" // _Py_ID() +#include "pycore_structseq.h" // _PyStructSequence_NewType() #include "pycore_time.h" // _PyTimeFraction #include // clock() @@ -96,33 +97,36 @@ get_time_state(PyObject *module) } -static PyObject* -_PyFloat_FromPyTime(PyTime_t t) -{ - double d = PyTime_AsSecondsDouble(t); - return PyFloat_FromDouble(d); -} +/*[clinic input] +time.time -> double +Return the current time in seconds since the Epoch. -static PyObject * -time_time(PyObject *self, PyObject *unused) +Fractions of a second may be present if the system clock provides +them. +[clinic start generated code]*/ + +static double +time_time_impl(PyObject *module) +/*[clinic end generated code: output=4adfc457b48923ca input=eea2e80c63bbcaad]*/ { PyTime_t t; if (PyTime_Time(&t) < 0) { - return NULL; + return -1.0; } - return _PyFloat_FromPyTime(t); + return PyTime_AsSecondsDouble(t); } -PyDoc_STRVAR(time_doc, -"time() -> floating-point number\n\ -\n\ -Return the current time in seconds since the Epoch.\n\ -Fractions of a second may be present if the system clock provides them."); +/*[clinic input] +time.time_ns + +Return the current time in nanoseconds since the Epoch. +[clinic start generated code]*/ static PyObject * -time_time_ns(PyObject *self, PyObject *unused) +time_time_ns_impl(PyObject *module) +/*[clinic end generated code: output=f5f1924ebdcf1cf3 input=3acccd9786731be4]*/ { PyTime_t t; if (PyTime_Time(&t) < 0) { @@ -131,11 +135,6 @@ time_time_ns(PyObject *self, PyObject *unused) return PyLong_FromInt64(t); } -PyDoc_STRVAR(time_ns_doc, -"time_ns() -> int\n\ -\n\ -Return the current time in nanoseconds since the Epoch."); - #ifdef HAVE_CLOCK #ifndef CLOCKS_PER_SEC @@ -266,18 +265,24 @@ time_clock_gettime_ns_impl(PyObject *module, clockid_t clk_id) #endif /* HAVE_CLOCK_GETTIME */ #ifdef HAVE_CLOCK_SETTIME +/*[clinic input] +time.clock_settime + + clk_id: int + time as obj: object + / + +Set the time of the specified clock clk_id. +[clinic start generated code]*/ + static PyObject * -time_clock_settime(PyObject *self, PyObject *args) +time_clock_settime_impl(PyObject *module, int clk_id, PyObject *obj) +/*[clinic end generated code: output=ff2fc2e129f5fdea input=0e71daa237ff6edc]*/ { - int clk_id; - PyObject *obj; PyTime_t t; struct timespec tp; int ret; - if (!PyArg_ParseTuple(args, "iO:clock_settime", &clk_id, &obj)) - return NULL; - if (_PyTime_FromSecondsObject(&t, obj, _PyTime_ROUND_FLOOR) < 0) return NULL; @@ -292,24 +297,24 @@ time_clock_settime(PyObject *self, PyObject *args) Py_RETURN_NONE; } -PyDoc_STRVAR(clock_settime_doc, -"clock_settime(clk_id, time)\n\ -\n\ -Set the time of the specified clock clk_id."); +/*[clinic input] +time.clock_settime_ns + + clk_id: int + time as obj: object + / + +Set the time of the specified clock clk_id with nanoseconds. +[clinic start generated code]*/ static PyObject * -time_clock_settime_ns(PyObject *self, PyObject *args) +time_clock_settime_ns_impl(PyObject *module, int clk_id, PyObject *obj) +/*[clinic end generated code: output=5d40ca0217bfe058 input=f2333aae32a7f441]*/ { - int clk_id; - PyObject *obj; PyTime_t t; struct timespec ts; int ret; - if (!PyArg_ParseTuple(args, "iO:clock_settime", &clk_id, &obj)) { - return NULL; - } - if (PyLong_AsInt64(obj, &t) < 0) { return NULL; } @@ -325,37 +330,34 @@ time_clock_settime_ns(PyObject *self, PyObject *args) Py_RETURN_NONE; } -PyDoc_STRVAR(clock_settime_ns_doc, -"clock_settime_ns(clk_id, time)\n\ -\n\ -Set the time of the specified clock clk_id with nanoseconds."); #endif /* HAVE_CLOCK_SETTIME */ #ifdef HAVE_CLOCK_GETRES -static PyObject * -time_clock_getres(PyObject *self, PyObject *args) +/*[clinic input] +time.clock_getres -> double + + clk_id: int + / + +Return the resolution (precision) of the specified clock clk_id. +[clinic start generated code]*/ + +static double +time_clock_getres_impl(PyObject *module, int clk_id) +/*[clinic end generated code: output=94c4fb7df9f0c2f2 input=d1409a8b5b3be180]*/ { int ret; - int clk_id; struct timespec tp; - if (!PyArg_ParseTuple(args, "i:clock_getres", &clk_id)) - return NULL; - ret = clock_getres((clockid_t)clk_id, &tp); if (ret != 0) { PyErr_SetFromErrno(PyExc_OSError); - return NULL; + return -1.0; } - return PyFloat_FromDouble(tp.tv_sec + tp.tv_nsec * 1e-9); + return tp.tv_sec + tp.tv_nsec * 1e-9; } -PyDoc_STRVAR(clock_getres_doc, -"clock_getres(clk_id) -> floating-point number\n\ -\n\ -Return the resolution (precision) of the specified clock clk_id."); - #ifdef __APPLE__ #pragma clang diagnostic pop #endif @@ -363,15 +365,21 @@ Return the resolution (precision) of the specified clock clk_id."); #endif /* HAVE_CLOCK_GETRES */ #ifdef HAVE_PTHREAD_GETCPUCLOCKID +/*[clinic input] +time.pthread_getcpuclockid + + thread_id: unsigned_long(bitwise=True) + / + +Return the clk_id of a thread's CPU time clock. +[clinic start generated code]*/ + static PyObject * -time_pthread_getcpuclockid(PyObject *self, PyObject *args) +time_pthread_getcpuclockid_impl(PyObject *module, unsigned long thread_id) +/*[clinic end generated code: output=4fc7d4cb73d2e894 input=eb8af7bbcf189270]*/ { - unsigned long thread_id; int err; clockid_t clk_id; - if (!PyArg_ParseTuple(args, "k:pthread_getcpuclockid", &thread_id)) { - return NULL; - } err = pthread_getcpuclockid((pthread_t)thread_id, &clk_id); if (err) { errno = err; @@ -384,14 +392,22 @@ time_pthread_getcpuclockid(PyObject *self, PyObject *args) return PyLong_FromLong(clk_id); } -PyDoc_STRVAR(pthread_getcpuclockid_doc, -"pthread_getcpuclockid(thread_id) -> int\n\ -\n\ -Return the clk_id of a thread's CPU time clock."); #endif /* HAVE_PTHREAD_GETCPUCLOCKID */ +/*[clinic input] +time.sleep + + seconds as timeout_obj: object + / + +Delay execution for a given number of seconds. + +The argument may be a floating-point number for subsecond precision. +[clinic start generated code]*/ + static PyObject * -time_sleep(PyObject *self, PyObject *timeout_obj) +time_sleep(PyObject *module, PyObject *timeout_obj) +/*[clinic end generated code: output=f46e88f5f5756f65 input=3928b1704a2faa12]*/ { if (PySys_Audit("time.sleep", "O", timeout_obj) < 0) { return NULL; @@ -411,12 +427,6 @@ time_sleep(PyObject *self, PyObject *timeout_obj) Py_RETURN_NONE; } -PyDoc_STRVAR(sleep_doc, -"sleep(seconds)\n\ -\n\ -Delay execution for a given number of seconds. The argument may be\n\ -a floating-point number for subsecond precision."); - static PyStructSequence_Field struct_time_type_fields[] = { {"tm_year", "year, for example, 1993"}, {"tm_mon", "month of year, range [1, 12]"}, @@ -477,7 +487,7 @@ tmtotuple(time_module_state *state, struct tm *p #define SET(INDEX, VAL) \ SET_ITEM((INDEX), PyLong_FromLong((long) (VAL))) - SET(0, p->tm_year + 1900); + SET_ITEM(0, PyLong_FromLongLong((long long)p->tm_year + 1900)); SET(1, p->tm_mon + 1); /* Want January == 1 */ SET(2, p->tm_mday); SET(3, p->tm_hour); @@ -500,19 +510,16 @@ tmtotuple(time_module_state *state, struct tm *p return v; } -/* Parse arg tuple that can contain an optional float-or-None value; - format needs to be "|O:name". +/* Convert a number of seconds since the Epoch, or None which means the + current time, to time_t. Returns non-zero on success (parallels PyArg_ParseTuple). */ static int -parse_time_t_args(PyObject *args, const char *format, time_t *pwhen) +parse_time_t_arg(PyObject *ot, time_t *pwhen) { - PyObject *ot = NULL; time_t whent; - if (!PyArg_ParseTuple(args, format, &ot)) - return 0; - if (ot == NULL || ot == Py_None) { + if (ot == Py_None) { whent = time(NULL); } else { @@ -523,13 +530,29 @@ parse_time_t_args(PyObject *args, const char *format, time_t *pwhen) return 1; } +/*[clinic input] +time.gmtime + + seconds as ot: object = None + / + +Convert seconds since the Epoch to a time tuple expressing UTC. + +That is, Greenwich Mean Time. When 'seconds' is not passed in, convert +the current time instead. + +If the platform supports the tm_gmtoff and tm_zone, they are available +as attributes only. +[clinic start generated code]*/ + static PyObject * -time_gmtime(PyObject *module, PyObject *args) +time_gmtime_impl(PyObject *module, PyObject *ot) +/*[clinic end generated code: output=375372dd236a6ed6 input=784de5b57649d4d7]*/ { time_t when; struct tm buf; - if (!parse_time_t_args(args, "|O:gmtime", &when)) + if (!parse_time_t_arg(ot, &when)) return NULL; errno = 0; @@ -557,23 +580,25 @@ timegm(struct tm *p) } #endif -PyDoc_STRVAR(gmtime_doc, -"gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,\n\ - tm_sec, tm_wday, tm_yday, tm_isdst)\n\ -\n\ -Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n\ -GMT). When 'seconds' is not passed in, convert the current time instead.\n\ -\n\ -If the platform supports the tm_gmtoff and tm_zone, they are available as\n\ -attributes only."); +/*[clinic input] +time.localtime + + seconds as ot: object = None + / + +Convert seconds since the Epoch to a time tuple expressing local time. + +When 'seconds' is not passed in, convert the current time instead. +[clinic start generated code]*/ static PyObject * -time_localtime(PyObject *module, PyObject *args) +time_localtime_impl(PyObject *module, PyObject *ot) +/*[clinic end generated code: output=d3c1c6818abd34a1 input=43b4e8bf4914300e]*/ { time_t when; struct tm buf; - if (!parse_time_t_args(args, "|O:localtime", &when)) + if (!parse_time_t_arg(ot, &when)) return NULL; if (_PyTime_localtime(when, &buf) != 0) return NULL; @@ -597,13 +622,6 @@ time_localtime(PyObject *module, PyObject *args) static const char *utc_string = NULL; #endif -PyDoc_STRVAR(localtime_doc, -"localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,\n\ - tm_sec,tm_wday,tm_yday,tm_isdst)\n\ -\n\ -Convert seconds since the Epoch to a time tuple expressing local time.\n\ -When 'seconds' is not passed in, convert the current time instead."); - /* Convert 9-item tuple to tm structure. Return 1 on success, set * an exception and return 0 on error. */ @@ -611,7 +629,7 @@ static int gettmarg(time_module_state *state, PyObject *args, struct tm *p, const char *format) { - int y; + long long y; memset((void *) p, '\0', sizeof(struct tm)); @@ -627,12 +645,12 @@ gettmarg(time_module_state *state, PyObject *args, &p->tm_wday, &p->tm_yday, &p->tm_isdst)) return 0; - if (y < INT_MIN + 1900) { + if (y < (long long)INT_MIN + 1900 || y > (long long)INT_MAX + 1900) { PyErr_SetString(PyExc_OverflowError, "year out of range"); return 0; } - p->tm_year = y - 1900; + p->tm_year = (int)(y - 1900); p->tm_mon--; p->tm_wday = (p->tm_wday + 1) % 7; p->tm_yday--; @@ -763,6 +781,13 @@ Other codes may be available on your platform. See documentation for\n\ the C library strftime function.\n" #ifdef HAVE_STRFTIME +// gh-154460: OpenBSD's wcsftime() computes %V incorrectly: it returns 53 +// whenever the ISO 8601 week belongs to a different year than tm_year. +// strftime() is not affected. +#ifdef __OpenBSD__ +# undef HAVE_WCSFTIME +#endif + #ifdef HAVE_WCSFTIME #define time_char wchar_t #define format_time wcsftime @@ -829,14 +854,14 @@ time_strftime1(time_char **outbuf, size_t *bufsize, return NULL; } *outbuf = tmp; -#if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__) +#if defined _MSC_VER && defined(__STDC_SECURE_LIB__) errno = 0; #endif _Py_BEGIN_SUPPRESS_IPH buflen = format_time(*outbuf, *bufsize, format, tm); _Py_END_SUPPRESS_IPH -#if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__) - /* VisualStudio .NET 2005 does this properly */ +#if defined _MSC_VER && defined(__STDC_SECURE_LIB__) + /* The secure CRT reports invalid format strings with EINVAL. */ if (buflen == 0 && errno == EINVAL) { PyErr_SetString(PyExc_ValueError, "Invalid format string"); return NULL; @@ -881,7 +906,7 @@ time_strftime(PyObject *module, PyObject *args) return NULL; } else if (!gettmarg(state, tup, &buf, - "iiiiiiiii;strftime(): illegal time tuple argument") || + "Liiiiiiii;strftime(): illegal time tuple argument") || !checktm(&buf)) { return NULL; @@ -893,7 +918,7 @@ time_strftime(PyObject *module, PyObject *args) // physical devices (#123017). #if defined(_MSC_VER) || (defined(__sun) && defined(__SVR4)) || defined(_AIX) \ || defined(__VXWORKS__) || defined(__ANDROID__) - if (buf.tm_year + 1900 < 1 || 9999 < buf.tm_year + 1900) { + if (buf.tm_year < 1 - 1900 || buf.tm_year > 9999 - 1900) { PyErr_SetString(PyExc_ValueError, "strftime() requires year in [1; 9999]"); return NULL; @@ -971,7 +996,7 @@ time_strftime(PyObject *module, PyObject *args) #undef time_char #undef format_time PyDoc_STRVAR(strftime_doc, -"strftime(format[, tuple]) -> string\n\ +"strftime(format[, time_tuple]) -> string\n\ \n\ Convert a time tuple to a string according to a format specification.\n\ See the library reference manual for formatting codes. When the time tuple\n\ @@ -982,6 +1007,40 @@ is not present, current time as returned by localtime() is used.\n\ static PyObject * time_strptime(PyObject *self, PyObject *args) { + _PyTime_StrptimeFields fields; + if (PyTuple_GET_SIZE(args) == 2 && + _PyTime_Strptime(PyTuple_GET_ITEM(args, 0), + PyTuple_GET_ITEM(args, 1), &fields)) { + time_module_state *state = get_time_state(self); + PyObject *result = PyStructSequence_New(state->struct_time_type); + if (result == NULL) { + return NULL; + } + const int values[] = { + fields.year, fields.month, fields.day, + fields.hour, fields.minute, fields.second, + _PyTime_Weekday(fields.year, fields.yday), fields.yday, -1 + }; + for (size_t i = 0; i < Py_ARRAY_LENGTH(values); i++) { + PyObject *value = PyLong_FromLong(values[i]); + if (value == NULL) { + Py_DECREF(result); + return NULL; + } + PyStructSequence_SET_ITEM(result, i, value); + } + /* Numeric offsets don't supply a timezone name or DST information. */ + PyStructSequence_SET_ITEM(result, 9, Py_NewRef(Py_None)); + PyObject *offset = fields.gmtoff == INT_MIN + ? Py_NewRef(Py_None) + : PyLong_FromLong(fields.gmtoff); + if (offset == NULL) { + Py_DECREF(result); + return NULL; + } + PyStructSequence_SET_ITEM(result, 10, offset); + return result; + } PyObject *func, *result; func = PyImport_ImportModuleAttrString("_strptime", "_strptime_time"); @@ -996,7 +1055,7 @@ time_strptime(PyObject *self, PyObject *args) PyDoc_STRVAR(strptime_doc, -"strptime(string, format) -> struct_time\n\ +"strptime(string[, format]) -> struct_time\n\ \n\ Parse a string to a time tuple according to a format specification.\n\ See the library reference manual for formatting codes (same as\n\ @@ -1016,23 +1075,32 @@ _asctime(struct tm *timeptr) "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; return PyUnicode_FromFormat( - "%s %s%3d %.2d:%.2d:%.2d %d", + "%s %s%3d %.2d:%.2d:%.2d %lld", wday_name[timeptr->tm_wday], mon_name[timeptr->tm_mon], timeptr->tm_mday, timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec, - 1900 + timeptr->tm_year); + (long long)timeptr->tm_year + 1900); } +/*[clinic input] +time.asctime + + time_tuple as tup: object = NULL + / + +Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'. + +When the time tuple is not present, current time as returned by +localtime() is used. +[clinic start generated code]*/ + static PyObject * -time_asctime(PyObject *module, PyObject *args) +time_asctime_impl(PyObject *module, PyObject *tup) +/*[clinic end generated code: output=a1bc45f84a00fb55 input=083c132f3cb23f1e]*/ { - PyObject *tup = NULL; struct tm buf; - if (!PyArg_UnpackTuple(args, "asctime", 0, 1, &tup)) - return NULL; - time_module_state *state = get_time_state(module); if (tup == NULL) { time_t tt = time(NULL); @@ -1040,7 +1108,7 @@ time_asctime(PyObject *module, PyObject *args) return NULL; } else if (!gettmarg(state, tup, &buf, - "iiiiiiiii;asctime(): illegal time tuple argument") || + "Liiiiiiii;asctime(): illegal time tuple argument") || !checktm(&buf)) { return NULL; @@ -1048,42 +1116,55 @@ time_asctime(PyObject *module, PyObject *args) return _asctime(&buf); } -PyDoc_STRVAR(asctime_doc, -"asctime([tuple]) -> string\n\ -\n\ -Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.\n\ -When the time tuple is not present, current time as returned by localtime()\n\ -is used."); +/*[clinic input] +time.ctime + + seconds as ot: object = None + / + +Convert a time in seconds since the Epoch to a string in local time. + +This is equivalent to asctime(localtime(seconds)). When 'seconds' is +not passed in, convert the current time instead. +[clinic start generated code]*/ static PyObject * -time_ctime(PyObject *self, PyObject *args) +time_ctime_impl(PyObject *module, PyObject *ot) +/*[clinic end generated code: output=c3a028f5c6931cbc input=ee744f25ce87d1ae]*/ { time_t tt; struct tm buf; - if (!parse_time_t_args(args, "|O:ctime", &tt)) + if (!parse_time_t_arg(ot, &tt)) return NULL; if (_PyTime_localtime(tt, &buf) != 0) return NULL; return _asctime(&buf); } -PyDoc_STRVAR(ctime_doc, -"ctime(seconds) -> string\n\ -\n\ -Convert a time in seconds since the Epoch to a string in local time.\n\ -This is equivalent to asctime(localtime(seconds)). When the time tuple is\n\ -not present, current time as returned by localtime() is used."); - #ifdef HAVE_MKTIME +/*[clinic input] +time.mktime + + time_tuple as tm_tuple: object + / + +Convert a time tuple in local time to seconds since the Epoch. + +Note that mktime(gmtime(0)) will not generally return zero for most +time zones; instead the returned value will either be equal to that of +the timezone or altzone attributes on the time module. +[clinic start generated code]*/ + static PyObject * time_mktime(PyObject *module, PyObject *tm_tuple) +/*[clinic end generated code: output=1b2a224cd309deb7 input=70b93e1c2e57e14e]*/ { struct tm tm; time_t tt; time_module_state *state = get_time_state(module); if (!gettmarg(state, tm_tuple, &tm, - "iiiiiiiii;mktime(): illegal time tuple argument")) + "Liiiiiiii;mktime(): illegal time tuple argument")) { return NULL; } @@ -1145,20 +1226,29 @@ time_mktime(PyObject *module, PyObject *tm_tuple) return PyFloat_FromDouble((double)tt); } -PyDoc_STRVAR(mktime_doc, -"mktime(tuple) -> floating-point number\n\ -\n\ -Convert a time tuple in local time to seconds since the Epoch.\n\ -Note that mktime(gmtime(0)) will not generally return zero for most\n\ -time zones; instead the returned value will either be equal to that\n\ -of the timezone or altzone attributes on the time module."); #endif /* HAVE_MKTIME */ #ifdef HAVE_WORKING_TZSET static int init_timezone(PyObject *module); +/*[clinic input] +time.tzset + +Initialize, or reinitialize, the local timezone. + +The local timezone is set to the value stored in os.environ['TZ']. The +TZ environment variable should be specified in standard Unix timezone +format as documented in the tzset man page (eg. 'US/Eastern', +'Europe/Amsterdam'). Unknown timezones will silently fall back to UTC. +If the TZ environment variable is not set, the local timezone is set to +the systems best guess of wallclock time. Changing the TZ environment +variable without calling tzset *may* change the local timezone used by +methods such as localtime, but this behaviour should not be relied on. +[clinic start generated code]*/ + static PyObject * -time_tzset(PyObject *self, PyObject *unused) +time_tzset_impl(PyObject *module) +/*[clinic end generated code: output=d1564ac4d48d320b input=a4d11aab49badf88]*/ { PyObject* m; @@ -1183,38 +1273,35 @@ time_tzset(PyObject *self, PyObject *unused) Py_RETURN_NONE; } -PyDoc_STRVAR(tzset_doc, -"tzset()\n\ -\n\ -Initialize, or reinitialize, the local timezone to the value stored in\n\ -os.environ['TZ']. The TZ environment variable should be specified in\n\ -standard Unix timezone format as documented in the tzset man page\n\ -(eg. 'US/Eastern', 'Europe/Amsterdam'). Unknown timezones will silently\n\ -fall back to UTC. If the TZ environment variable is not set, the local\n\ -timezone is set to the systems best guess of wallclock time.\n\ -Changing the TZ environment variable without calling tzset *may* change\n\ -the local timezone used by methods such as localtime, but this behaviour\n\ -should not be relied on."); #endif /* HAVE_WORKING_TZSET */ -static PyObject * -time_monotonic(PyObject *self, PyObject *unused) +/*[clinic input] +time.monotonic -> double + +Monotonic clock, cannot go backward. +[clinic start generated code]*/ + +static double +time_monotonic_impl(PyObject *module) +/*[clinic end generated code: output=ab51899a17e16542 input=059cb42b2bad6df0]*/ { PyTime_t t; if (PyTime_Monotonic(&t) < 0) { - return NULL; + return -1.0; } - return _PyFloat_FromPyTime(t); + return PyTime_AsSecondsDouble(t); } -PyDoc_STRVAR(monotonic_doc, -"monotonic() -> float\n\ -\n\ -Monotonic clock, cannot go backward."); +/*[clinic input] +time.monotonic_ns + +Monotonic clock, cannot go backward, as nanoseconds. +[clinic start generated code]*/ static PyObject * -time_monotonic_ns(PyObject *self, PyObject *unused) +time_monotonic_ns_impl(PyObject *module) +/*[clinic end generated code: output=57a9261f91740349 input=14032d6b1601a300]*/ { PyTime_t t; if (PyTime_Monotonic(&t) < 0) { @@ -1223,30 +1310,32 @@ time_monotonic_ns(PyObject *self, PyObject *unused) return PyLong_FromInt64(t); } -PyDoc_STRVAR(monotonic_ns_doc, -"monotonic_ns() -> int\n\ -\n\ -Monotonic clock, cannot go backward, as nanoseconds."); +/*[clinic input] +time.perf_counter -> double +Performance counter for benchmarking. +[clinic start generated code]*/ -static PyObject * -time_perf_counter(PyObject *self, PyObject *unused) +static double +time_perf_counter_impl(PyObject *module) +/*[clinic end generated code: output=6eee280ca7b73cb1 input=f786239c5015893b]*/ { PyTime_t t; if (PyTime_PerfCounter(&t) < 0) { - return NULL; + return -1.0; } - return _PyFloat_FromPyTime(t); + return PyTime_AsSecondsDouble(t); } -PyDoc_STRVAR(perf_counter_doc, -"perf_counter() -> float\n\ -\n\ -Performance counter for benchmarking."); +/*[clinic input] +time.perf_counter_ns +Performance counter for benchmarking as nanoseconds. +[clinic start generated code]*/ static PyObject * -time_perf_counter_ns(PyObject *self, PyObject *unused) +time_perf_counter_ns_impl(PyObject *module) +/*[clinic end generated code: output=e11a728338108d42 input=178bf260d7d48a02]*/ { PyTime_t t; if (PyTime_PerfCounter(&t) < 0) { @@ -1255,12 +1344,6 @@ time_perf_counter_ns(PyObject *self, PyObject *unused) return PyLong_FromInt64(t); } -PyDoc_STRVAR(perf_counter_ns_doc, -"perf_counter_ns() -> int\n\ -\n\ -Performance counter for benchmarking as nanoseconds."); - - // gh-115714: Don't use times() on WASI. #if defined(HAVE_TIMES) && !defined(__wasi__) static int @@ -1417,24 +1500,37 @@ py_process_time(time_module_state *state, PyTime_t *tp, #endif } -static PyObject * -time_process_time(PyObject *module, PyObject *unused) +/*[clinic input] +time.process_time -> double + +Process time for profiling. + +That is the sum of the kernel and user-space CPU time. +[clinic start generated code]*/ + +static double +time_process_time_impl(PyObject *module) +/*[clinic end generated code: output=13b593cb16d415a8 input=6d539ae686c37c06]*/ { time_module_state *state = get_time_state(module); PyTime_t t; if (py_process_time(state, &t, NULL) < 0) { - return NULL; + return -1.0; } - return _PyFloat_FromPyTime(t); + return PyTime_AsSecondsDouble(t); } -PyDoc_STRVAR(process_time_doc, -"process_time() -> float\n\ -\n\ -Process time for profiling: sum of the kernel and user-space CPU time."); +/*[clinic input] +time.process_time_ns + +Process time for profiling as nanoseconds. + +That is the sum of the kernel and user-space CPU time. +[clinic start generated code]*/ static PyObject * -time_process_time_ns(PyObject *module, PyObject *unused) +time_process_time_ns_impl(PyObject *module) +/*[clinic end generated code: output=857f0c20105c4d1a input=6d998fd7a213c0cd]*/ { time_module_state *state = get_time_state(module); PyTime_t t; @@ -1444,13 +1540,6 @@ time_process_time_ns(PyObject *module, PyObject *unused) return PyLong_FromInt64(t); } -PyDoc_STRVAR(process_time_ns_doc, -"process_time() -> int\n\ -\n\ -Process time for profiling as nanoseconds:\n\ -sum of the kernel and user-space CPU time."); - - #if defined(MS_WINDOWS) #define HAVE_THREAD_TIME static int @@ -1592,23 +1681,36 @@ _PyTime_GetThreadTimeWithInfo(PyTime_t *tp, _Py_clock_info_t *info) #pragma clang diagnostic ignored "-Wunguarded-availability" #endif -static PyObject * -time_thread_time(PyObject *self, PyObject *unused) +/*[clinic input] +time.thread_time -> double + +Thread time for profiling. + +That is the sum of the kernel and user-space CPU time. +[clinic start generated code]*/ + +static double +time_thread_time_impl(PyObject *module) +/*[clinic end generated code: output=33f6639edb42e8f5 input=cdf4621822b8ed60]*/ { PyTime_t t; if (_PyTime_GetThreadTimeWithInfo(&t, NULL) < 0) { - return NULL; + return -1.0; } - return _PyFloat_FromPyTime(t); + return PyTime_AsSecondsDouble(t); } -PyDoc_STRVAR(thread_time_doc, -"thread_time() -> float\n\ -\n\ -Thread time for profiling: sum of the kernel and user-space CPU time."); +/*[clinic input] +time.thread_time_ns + +Thread time for profiling as nanoseconds. + +That is the sum of the kernel and user-space CPU time. +[clinic start generated code]*/ static PyObject * -time_thread_time_ns(PyObject *self, PyObject *unused) +time_thread_time_ns_impl(PyObject *module) +/*[clinic end generated code: output=2a1ac9cc3e1d4c37 input=a79b2b91f308277d]*/ { PyTime_t t; if (_PyTime_GetThreadTimeWithInfo(&t, NULL) < 0) { @@ -1617,12 +1719,6 @@ time_thread_time_ns(PyObject *self, PyObject *unused) return PyLong_FromInt64(t); } -PyDoc_STRVAR(thread_time_ns_doc, -"thread_time() -> int\n\ -\n\ -Thread time for profiling as nanoseconds:\n\ -sum of the kernel and user-space CPU time."); - #ifdef __APPLE__ #pragma clang diagnostic pop #endif @@ -1630,18 +1726,23 @@ sum of the kernel and user-space CPU time."); #endif +/*[clinic input] +time.get_clock_info + + name: str + / + +Get information of the specified clock. +[clinic start generated code]*/ + static PyObject * -time_get_clock_info(PyObject *module, PyObject *args) +time_get_clock_info_impl(PyObject *module, const char *name) +/*[clinic end generated code: output=a77a07bdf3554bd6 input=6812ae049f1b1031]*/ { - char *name; _Py_clock_info_t info; PyObject *obj = NULL, *dict, *ns; PyTime_t t; - if (!PyArg_ParseTuple(args, "s:get_clock_info", &name)) { - return NULL; - } - #ifdef Py_DEBUG info.implementation = NULL; info.monotonic = -1; @@ -1753,11 +1854,6 @@ time_get_clock_info(PyObject *module, PyObject *args) return NULL; } -PyDoc_STRVAR(get_clock_info_doc, -"get_clock_info(name: str) -> dict\n\ -\n\ -Get information of the specified clock."); - #ifndef HAVE_DECL_TZNAME static void get_zone(char *zone, int n, struct tm *p) @@ -1906,48 +2002,48 @@ init_timezone(PyObject *m) #include "clinic/timemodule.c.h" static PyMethodDef time_methods[] = { - {"time", time_time, METH_NOARGS, time_doc}, - {"time_ns", time_time_ns, METH_NOARGS, time_ns_doc}, + TIME_TIME_METHODDEF + TIME_TIME_NS_METHODDEF #ifdef HAVE_CLOCK_GETTIME TIME_CLOCK_GETTIME_METHODDEF TIME_CLOCK_GETTIME_NS_METHODDEF #endif #ifdef HAVE_CLOCK_SETTIME - {"clock_settime", time_clock_settime, METH_VARARGS, clock_settime_doc}, - {"clock_settime_ns",time_clock_settime_ns, METH_VARARGS, clock_settime_ns_doc}, + TIME_CLOCK_SETTIME_METHODDEF + TIME_CLOCK_SETTIME_NS_METHODDEF #endif #ifdef HAVE_CLOCK_GETRES - {"clock_getres", time_clock_getres, METH_VARARGS, clock_getres_doc}, + TIME_CLOCK_GETRES_METHODDEF #endif #ifdef HAVE_PTHREAD_GETCPUCLOCKID - {"pthread_getcpuclockid", time_pthread_getcpuclockid, METH_VARARGS, pthread_getcpuclockid_doc}, + TIME_PTHREAD_GETCPUCLOCKID_METHODDEF #endif - {"sleep", time_sleep, METH_O, sleep_doc}, - {"gmtime", time_gmtime, METH_VARARGS, gmtime_doc}, - {"localtime", time_localtime, METH_VARARGS, localtime_doc}, - {"asctime", time_asctime, METH_VARARGS, asctime_doc}, - {"ctime", time_ctime, METH_VARARGS, ctime_doc}, + TIME_SLEEP_METHODDEF + TIME_GMTIME_METHODDEF + TIME_LOCALTIME_METHODDEF + TIME_ASCTIME_METHODDEF + TIME_CTIME_METHODDEF #ifdef HAVE_MKTIME - {"mktime", time_mktime, METH_O, mktime_doc}, + TIME_MKTIME_METHODDEF #endif #ifdef HAVE_STRFTIME {"strftime", time_strftime, METH_VARARGS, strftime_doc}, #endif {"strptime", time_strptime, METH_VARARGS, strptime_doc}, #ifdef HAVE_WORKING_TZSET - {"tzset", time_tzset, METH_NOARGS, tzset_doc}, + TIME_TZSET_METHODDEF #endif - {"monotonic", time_monotonic, METH_NOARGS, monotonic_doc}, - {"monotonic_ns", time_monotonic_ns, METH_NOARGS, monotonic_ns_doc}, - {"process_time", time_process_time, METH_NOARGS, process_time_doc}, - {"process_time_ns", time_process_time_ns, METH_NOARGS, process_time_ns_doc}, + TIME_MONOTONIC_METHODDEF + TIME_MONOTONIC_NS_METHODDEF + TIME_PROCESS_TIME_METHODDEF + TIME_PROCESS_TIME_NS_METHODDEF #ifdef HAVE_THREAD_TIME - {"thread_time", time_thread_time, METH_NOARGS, thread_time_doc}, - {"thread_time_ns", time_thread_time_ns, METH_NOARGS, thread_time_ns_doc}, + TIME_THREAD_TIME_METHODDEF + TIME_THREAD_TIME_NS_METHODDEF #endif - {"perf_counter", time_perf_counter, METH_NOARGS, perf_counter_doc}, - {"perf_counter_ns", time_perf_counter_ns, METH_NOARGS, perf_counter_ns_doc}, - {"get_clock_info", time_get_clock_info, METH_VARARGS, get_clock_info_doc}, + TIME_PERF_COUNTER_METHODDEF + TIME_PERF_COUNTER_NS_METHODDEF + TIME_GET_CLOCK_INFO_METHODDEF {NULL, NULL} /* sentinel */ }; @@ -2103,7 +2199,8 @@ time_exec(PyObject *module) } // struct_time type - state->struct_time_type = PyStructSequence_NewType(&struct_time_type_desc); + state->struct_time_type = _PyStructSequence_NewType( + &struct_time_type_desc, Py_TPFLAGS_IMMUTABLETYPE); if (state->struct_time_type == NULL) { return -1; } diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index 5f0e7ab6ec220d6..811d6af7220a73e 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -746,7 +746,8 @@ nfd_nfkd(PyObject *self, PyObject *input, int k) } if (run_length > sortbuflen) { - Py_UCS4 *new_sortbuf = PyMem_Resize(sortbuf, Py_UCS4, run_length); + Py_UCS4 *new_sortbuf = sortbuf; + PyMem_Resize(new_sortbuf, Py_UCS4, run_length); if (new_sortbuf == NULL) { PyErr_NoMemory(); PyMem_Free(sortbuf); @@ -1776,9 +1777,7 @@ enum ExtPictState { enum InCBState { InCBState_Init, - // \p{InCB=Consonant} \p{InCB=Extend}* - InCBState_Started, - // ... \p{InCB=Linker} [ \p{InCB=Extend} \p{InCB=Linker} ]* + // \p{InCB=Linker} \p{InCB=Extend}* InCBState_Linker, // ... \p{InCB=Consonant} InCBState_Matched, @@ -1815,16 +1814,16 @@ update_ext_pict_state(enum ExtPictState state, int gcb, bool ext_pict) static inline enum InCBState update_incb_state(enum InCBState state, int incb) { - if (incb == InCB_Consonant) { - return (state == InCBState_Linker) ? InCBState_Matched : InCBState_Started; + if (incb == InCB_Linker) { + return InCBState_Linker; } - if (state != InCBState_Init) { + if (state == InCBState_Linker) { if (incb == InCB_Extend) { - return (state == InCBState_Linker) ? InCBState_Linker : InCBState_Started; - } - if (incb == InCB_Linker) { return InCBState_Linker; } + if (incb == InCB_Consonant) { + return InCBState_Matched; + } } return InCBState_Init; } @@ -1990,6 +1989,7 @@ Segment_dealloc(PyObject *self) static int Segment_traverse(PyObject *self, visitproc visit, void *arg) { + Py_VISIT(Py_TYPE(self)); Py_VISIT(((SegmentObject *)self)->string); return 0; } @@ -2058,6 +2058,7 @@ GBI_dealloc(PyObject *self) static int GBI_traverse(PyObject *self, visitproc visit, void *arg) { + Py_VISIT(Py_TYPE(self)); Py_VISIT(((GraphemeBreakIterator *)self)->iter.str); return 0; } diff --git a/Modules/unicodedata_db.h b/Modules/unicodedata_db.h index 1c961c5e329341c..c99702765479431 100644 --- a/Modules/unicodedata_db.h +++ b/Modules/unicodedata_db.h @@ -1,6 +1,6 @@ /* this file was generated by Tools/unicode/makeunicodedata.py 3.3 */ -#define UNIDATA_VERSION "17.0.0" +#define UNIDATA_VERSION "18.0.0" /* a list of unique database records */ const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = { {0, 0, 0, 0, 0, 0, 0, 0, 0}, @@ -202,6 +202,7 @@ const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = { {4, 234, 14, 0, 0, 0, 5, 3, 0}, {5, 9, 1, 0, 0, 0, 5, 1, 0}, {4, 1, 14, 0, 0, 0, 5, 3, 0}, + {19, 0, 1, 0, 0, 0, 0, 1, 0}, {4, 214, 14, 0, 0, 0, 5, 3, 0}, {4, 202, 14, 0, 0, 0, 5, 3, 0}, {4, 232, 14, 0, 0, 0, 5, 3, 0}, @@ -1051,6 +1052,7 @@ static const char * const _PyUnicode_BlockNames[] = { "Masaram Gondi", "Gunjala Gondi", "Tolong Siki", + "Bengali Supplement", "Makasar", "Kawi", "Lisu Supplement", @@ -1058,6 +1060,7 @@ static const char * const _PyUnicode_BlockNames[] = { "Cuneiform", "Cuneiform Numbers and Punctuation", "Early Dynastic Cuneiform", + "Archaic Cuneiform Numerals", "Cypro-Minoan", "Egyptian Hieroglyphs", "Egyptian Hieroglyph Format Controls", @@ -1079,6 +1082,8 @@ static const char * const _PyUnicode_BlockNames[] = { "Khitan Small Script", "Tangut Supplement", "Tangut Components Supplement", + "Jurchen", + "Jurchen Radicals", "Kana Extended-B", "Kana Supplement", "Kana Extended-A", @@ -1092,12 +1097,14 @@ static const char * const _PyUnicode_BlockNames[] = { "Byzantine Musical Symbols", "Musical Symbols", "Ancient Greek Musical Notation", + "Musical Symbols Supplement", "Kaktovik Numerals", "Mayan Numerals", "Tai Xuan Jing Symbols", "Counting Rod Numerals", "Mathematical Alphanumeric Symbols", "Sutton SignWriting", + "Miscellaneous Symbols and Arrows Extended", "Latin Extended-G", "Glagolitic Supplement", "Cyrillic Extended-D", @@ -1139,6 +1146,7 @@ static const char * const _PyUnicode_BlockNames[] = { "CJK Unified Ideographs Extension G", "CJK Unified Ideographs Extension H", "CJK Unified Ideographs Extension J", + "Seal", "Tags", "Variation Selectors Supplement", "Supplementary Private Use Area-A", @@ -1404,100 +1412,107 @@ static const _PyUnicode_Block _PyUnicode_Blocks[] = { {0x11D00, 0x11D5F, 251}, {0x11D60, 0x11DAF, 252}, {0x11DB0, 0x11DEF, 253}, - {0x11EE0, 0x11EFF, 254}, - {0x11F00, 0x11F5F, 255}, - {0x11FB0, 0x11FBF, 256}, - {0x11FC0, 0x11FFF, 257}, - {0x12000, 0x123FF, 258}, - {0x12400, 0x1247F, 259}, - {0x12480, 0x1254F, 260}, - {0x12F90, 0x12FFF, 261}, - {0x13000, 0x1342F, 262}, - {0x13430, 0x1345F, 263}, - {0x13460, 0x143FF, 264}, - {0x14400, 0x1467F, 265}, - {0x16100, 0x1613F, 266}, - {0x16800, 0x16A3F, 267}, - {0x16A40, 0x16A6F, 268}, - {0x16A70, 0x16ACF, 269}, - {0x16AD0, 0x16AFF, 270}, - {0x16B00, 0x16B8F, 271}, - {0x16D40, 0x16D7F, 272}, - {0x16E40, 0x16E9F, 273}, - {0x16EA0, 0x16EDF, 274}, - {0x16F00, 0x16F9F, 275}, - {0x16FE0, 0x16FFF, 276}, - {0x17000, 0x187FF, 277}, - {0x18800, 0x18AFF, 278}, - {0x18B00, 0x18CFF, 279}, - {0x18D00, 0x18D7F, 280}, - {0x18D80, 0x18DFF, 281}, - {0x1AFF0, 0x1AFFF, 282}, - {0x1B000, 0x1B0FF, 283}, - {0x1B100, 0x1B12F, 284}, - {0x1B130, 0x1B16F, 285}, - {0x1B170, 0x1B2FF, 286}, - {0x1BC00, 0x1BC9F, 287}, - {0x1BCA0, 0x1BCAF, 288}, - {0x1CC00, 0x1CEBF, 289}, - {0x1CEC0, 0x1CEFF, 290}, - {0x1CF00, 0x1CFCF, 291}, - {0x1D000, 0x1D0FF, 292}, - {0x1D100, 0x1D1FF, 293}, - {0x1D200, 0x1D24F, 294}, - {0x1D2C0, 0x1D2DF, 295}, - {0x1D2E0, 0x1D2FF, 296}, - {0x1D300, 0x1D35F, 297}, - {0x1D360, 0x1D37F, 298}, - {0x1D400, 0x1D7FF, 299}, - {0x1D800, 0x1DAAF, 300}, - {0x1DF00, 0x1DFFF, 301}, - {0x1E000, 0x1E02F, 302}, - {0x1E030, 0x1E08F, 303}, - {0x1E100, 0x1E14F, 304}, - {0x1E290, 0x1E2BF, 305}, - {0x1E2C0, 0x1E2FF, 306}, - {0x1E4D0, 0x1E4FF, 307}, - {0x1E5D0, 0x1E5FF, 308}, - {0x1E6C0, 0x1E6FF, 309}, - {0x1E7E0, 0x1E7FF, 310}, - {0x1E800, 0x1E8DF, 311}, - {0x1E900, 0x1E95F, 312}, - {0x1EC70, 0x1ECBF, 313}, - {0x1ED00, 0x1ED4F, 314}, - {0x1EE00, 0x1EEFF, 315}, - {0x1F000, 0x1F02F, 316}, - {0x1F030, 0x1F09F, 317}, - {0x1F0A0, 0x1F0FF, 318}, - {0x1F100, 0x1F1FF, 319}, - {0x1F200, 0x1F2FF, 320}, - {0x1F300, 0x1F5FF, 321}, - {0x1F600, 0x1F64F, 322}, - {0x1F650, 0x1F67F, 323}, - {0x1F680, 0x1F6FF, 324}, - {0x1F700, 0x1F77F, 325}, - {0x1F780, 0x1F7FF, 326}, - {0x1F800, 0x1F8FF, 327}, - {0x1F900, 0x1F9FF, 328}, - {0x1FA00, 0x1FA6F, 329}, - {0x1FA70, 0x1FAFF, 330}, - {0x1FB00, 0x1FBFF, 331}, - {0x20000, 0x2A6DF, 332}, - {0x2A700, 0x2B73F, 333}, - {0x2B740, 0x2B81F, 334}, - {0x2B820, 0x2CEAF, 335}, - {0x2CEB0, 0x2EBEF, 336}, - {0x2EBF0, 0x2EE5F, 337}, - {0x2F800, 0x2FA1F, 338}, - {0x30000, 0x3134F, 339}, - {0x31350, 0x323AF, 340}, - {0x323B0, 0x3347F, 341}, - {0xE0000, 0xE007F, 342}, - {0xE0100, 0xE01EF, 343}, - {0xF0000, 0xFFFFF, 344}, - {0x100000, 0x10FFFF, 345}, + {0x11DF0, 0x11DFF, 254}, + {0x11EE0, 0x11EFF, 255}, + {0x11F00, 0x11F5F, 256}, + {0x11FB0, 0x11FBF, 257}, + {0x11FC0, 0x11FFF, 258}, + {0x12000, 0x123FF, 259}, + {0x12400, 0x1247F, 260}, + {0x12480, 0x1254F, 261}, + {0x12550, 0x1268F, 262}, + {0x12F90, 0x12FFF, 263}, + {0x13000, 0x1342F, 264}, + {0x13430, 0x1345F, 265}, + {0x13460, 0x143FF, 266}, + {0x14400, 0x1467F, 267}, + {0x16100, 0x1613F, 268}, + {0x16800, 0x16A3F, 269}, + {0x16A40, 0x16A6F, 270}, + {0x16A70, 0x16ACF, 271}, + {0x16AD0, 0x16AFF, 272}, + {0x16B00, 0x16B8F, 273}, + {0x16D40, 0x16D7F, 274}, + {0x16E40, 0x16E9F, 275}, + {0x16EA0, 0x16EDF, 276}, + {0x16F00, 0x16F9F, 277}, + {0x16FE0, 0x16FFF, 278}, + {0x17000, 0x187FF, 279}, + {0x18800, 0x18AFF, 280}, + {0x18B00, 0x18CFF, 281}, + {0x18D00, 0x18D7F, 282}, + {0x18D80, 0x18DFF, 283}, + {0x18E00, 0x1919F, 284}, + {0x191A0, 0x191DF, 285}, + {0x1AFF0, 0x1AFFF, 286}, + {0x1B000, 0x1B0FF, 287}, + {0x1B100, 0x1B12F, 288}, + {0x1B130, 0x1B16F, 289}, + {0x1B170, 0x1B2FF, 290}, + {0x1BC00, 0x1BC9F, 291}, + {0x1BCA0, 0x1BCAF, 292}, + {0x1CC00, 0x1CEBF, 293}, + {0x1CEC0, 0x1CEFF, 294}, + {0x1CF00, 0x1CFCF, 295}, + {0x1D000, 0x1D0FF, 296}, + {0x1D100, 0x1D1FF, 297}, + {0x1D200, 0x1D24F, 298}, + {0x1D250, 0x1D28F, 299}, + {0x1D2C0, 0x1D2DF, 300}, + {0x1D2E0, 0x1D2FF, 301}, + {0x1D300, 0x1D35F, 302}, + {0x1D360, 0x1D37F, 303}, + {0x1D400, 0x1D7FF, 304}, + {0x1D800, 0x1DAAF, 305}, + {0x1DB00, 0x1DBFF, 306}, + {0x1DF00, 0x1DFFF, 307}, + {0x1E000, 0x1E02F, 308}, + {0x1E030, 0x1E08F, 309}, + {0x1E100, 0x1E14F, 310}, + {0x1E290, 0x1E2BF, 311}, + {0x1E2C0, 0x1E2FF, 312}, + {0x1E4D0, 0x1E4FF, 313}, + {0x1E5D0, 0x1E5FF, 314}, + {0x1E6C0, 0x1E6FF, 315}, + {0x1E7E0, 0x1E7FF, 316}, + {0x1E800, 0x1E8DF, 317}, + {0x1E900, 0x1E95F, 318}, + {0x1EC70, 0x1ECBF, 319}, + {0x1ED00, 0x1ED4F, 320}, + {0x1EE00, 0x1EEFF, 321}, + {0x1F000, 0x1F02F, 322}, + {0x1F030, 0x1F09F, 323}, + {0x1F0A0, 0x1F0FF, 324}, + {0x1F100, 0x1F1FF, 325}, + {0x1F200, 0x1F2FF, 326}, + {0x1F300, 0x1F5FF, 327}, + {0x1F600, 0x1F64F, 328}, + {0x1F650, 0x1F67F, 329}, + {0x1F680, 0x1F6FF, 330}, + {0x1F700, 0x1F77F, 331}, + {0x1F780, 0x1F7FF, 332}, + {0x1F800, 0x1F8FF, 333}, + {0x1F900, 0x1F9FF, 334}, + {0x1FA00, 0x1FA6F, 335}, + {0x1FA70, 0x1FAFF, 336}, + {0x1FB00, 0x1FBFF, 337}, + {0x20000, 0x2A6DF, 338}, + {0x2A700, 0x2B73F, 339}, + {0x2B740, 0x2B81F, 340}, + {0x2B820, 0x2CEAF, 341}, + {0x2CEB0, 0x2EBEF, 342}, + {0x2EBF0, 0x2EE5F, 343}, + {0x2F800, 0x2FA1F, 344}, + {0x30000, 0x3134F, 345}, + {0x31350, 0x323AF, 346}, + {0x323B0, 0x3347F, 347}, + {0x3D000, 0x3FC3F, 348}, + {0xE0000, 0xE007F, 349}, + {0xE0100, 0xE01EF, 350}, + {0xF0000, 0xFFFFF, 351}, + {0x100000, 0x10FFFF, 352}, }; -#define BLOCK_COUNT 346 +#define BLOCK_COUNT 353 static const char *decomp_prefix[] = { "", @@ -1561,38 +1576,40 @@ static const unsigned short index1[] = { 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 143, 179, 180, 181, 182, 143, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 143, - 195, 196, 197, 41, 41, 41, 41, 41, 41, 41, 198, 199, 41, 200, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 201, 41, 41, 41, 41, 41, 41, 41, 41, 202, 41, 41, 41, + 195, 196, 197, 41, 41, 41, 41, 41, 41, 41, 198, 199, 41, 200, 201, 201, + 202, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 203, 41, 41, 41, 41, 41, 41, 41, 41, 204, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 140, 41, 41, 41, 41, 203, 143, 143, + 41, 41, 41, 41, 41, 41, 41, 41, 41, 140, 41, 41, 41, 41, 205, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 204, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 41, 41, 41, 41, 205, 206, - 207, 208, 143, 143, 209, 143, 210, 211, 212, 213, 101, 101, 101, 101, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 206, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 41, 41, 41, 41, 207, 208, + 209, 210, 143, 143, 211, 143, 212, 213, 214, 215, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 214, 215, 216, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 216, 217, 218, + 101, 101, 101, 101, 101, 101, 101, 219, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 217, 101, 101, - 218, 101, 101, 219, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 220, 221, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 220, 101, 101, + 221, 101, 101, 222, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 223, 224, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 222, 223, - 222, 222, 222, 224, 225, 226, 78, 227, 228, 229, 230, 231, 232, 143, 233, - 234, 235, 236, 237, 238, 239, 240, 78, 78, 78, 78, 241, 242, 143, 143, - 143, 143, 143, 143, 143, 143, 243, 143, 244, 245, 246, 143, 143, 247, - 143, 143, 143, 248, 143, 249, 143, 250, 143, 251, 252, 253, 254, 255, - 255, 255, 255, 255, 256, 257, 258, 255, 259, 260, 255, 255, 261, 262, - 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 222, 275, - 276, 277, 278, 279, 280, 281, 222, 282, 266, 266, 266, 266, 266, 266, - 266, 283, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 225, 226, + 225, 225, 225, 227, 228, 229, 78, 230, 231, 232, 233, 234, 235, 143, 236, + 237, 238, 239, 240, 241, 242, 243, 78, 78, 78, 78, 244, 245, 246, 143, + 143, 143, 143, 143, 143, 143, 247, 248, 249, 250, 251, 143, 143, 252, + 143, 143, 143, 253, 143, 254, 143, 255, 143, 256, 257, 258, 259, 260, + 260, 260, 260, 260, 261, 262, 263, 260, 264, 265, 260, 260, 266, 267, + 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 225, 280, + 281, 282, 283, 284, 285, 286, 225, 287, 271, 271, 271, 271, 271, 271, + 271, 288, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, + 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, + 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, @@ -1613,59 +1630,57 @@ static const unsigned short index1[] = { 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, + 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 289, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 284, + 101, 101, 101, 101, 101, 101, 290, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 285, 101, 101, 101, 101, 101, 101, 101, + 101, 101, 101, 101, 101, 101, 101, 101, 101, 291, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 286, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, + 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 292, 101, 101, + 101, 101, 293, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 127, 127, 127, 127, 295, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 296, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 287, 101, 101, - 101, 101, 288, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 127, 127, 127, 127, 290, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 291, 101, 101, 101, 101, + 101, 101, 101, 101, 101, 101, 297, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 292, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, + 101, 101, 298, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, + 294, 294, 294, 294, 294, 294, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 293, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, - 289, 289, 289, 291, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, + 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, + 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, + 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 299, 294, 294, 294, + 294, 294, 294, 296, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, @@ -1701,7 +1716,7 @@ static const unsigned short index1[] = { 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 294, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 300, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, @@ -1738,7 +1753,7 @@ static const unsigned short index1[] = { 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 294, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 300, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, @@ -1774,7 +1789,7 @@ static const unsigned short index1[] = { 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 294, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 300, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, @@ -1811,7 +1826,7 @@ static const unsigned short index1[] = { 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 294, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 300, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, @@ -1848,7 +1863,7 @@ static const unsigned short index1[] = { 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 294, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 300, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, @@ -1884,7 +1899,7 @@ static const unsigned short index1[] = { 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 294, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 300, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, @@ -1921,7 +1936,7 @@ static const unsigned short index1[] = { 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 294, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 300, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, @@ -1957,7 +1972,7 @@ static const unsigned short index1[] = { 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 294, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 300, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, @@ -1994,7 +2009,7 @@ static const unsigned short index1[] = { 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 294, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 300, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, @@ -2030,10 +2045,10 @@ static const unsigned short index1[] = { 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 294, - 295, 296, 297, 298, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, - 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, - 296, 296, 296, 296, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 300, + 301, 302, 303, 304, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, + 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, + 302, 302, 302, 302, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, @@ -2067,7 +2082,7 @@ static const unsigned short index1[] = { 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 294, 126, 126, 126, 126, 126, 126, + 143, 143, 143, 143, 143, 143, 143, 300, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, @@ -2104,7 +2119,7 @@ static const unsigned short index1[] = { 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 299, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, + 126, 305, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, @@ -2140,7 +2155,7 @@ static const unsigned short index1[] = { 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 126, 126, 126, 126, 126, 126, 126, 299, + 126, 126, 126, 126, 126, 126, 126, 126, 126, 305, }; static const unsigned short index2[] = { @@ -2218,14 +2233,14 @@ static const unsigned short index2[] = { 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 77, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 77, 77, 55, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 77, 53, 55, 86, 86, 86, 86, 86, 86, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 37, 49, 86, 87, 77, 77, 88, 88, 89, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 37, 49, 86, 87, 53, 53, 88, 88, 89, 90, 91, 84, 84, 84, 84, 91, 84, 84, 84, 92, 91, 84, 84, 84, 84, 84, 84, 91, 91, 91, 91, 91, 91, 84, 84, 91, 84, 84, 92, 93, 84, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 109, 84, 91, 109, 102, 90, 90, 90, 90, 90, 90, 90, 90, 112, 112, 112, + 109, 84, 91, 109, 102, 94, 105, 90, 90, 90, 90, 90, 90, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 90, 90, 90, 90, 112, 112, 112, 112, 109, 109, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 113, @@ -2318,34 +2333,34 @@ static const unsigned short index2[] = { 149, 149, 149, 149, 149, 149, 149, 149, 77, 149, 149, 149, 149, 149, 149, 149, 77, 149, 149, 77, 149, 149, 149, 149, 149, 77, 77, 155, 50, 156, 142, 148, 142, 142, 142, 142, 77, 77, 148, 157, 77, 77, 157, 157, 152, - 77, 77, 77, 77, 77, 77, 77, 142, 161, 156, 77, 77, 77, 77, 153, 153, 77, - 149, 50, 50, 142, 142, 77, 77, 154, 154, 154, 154, 154, 154, 154, 154, - 154, 154, 83, 149, 158, 158, 158, 158, 158, 158, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 142, 50, 77, 50, 50, 50, 50, 50, 50, 77, 77, 77, 50, 50, - 50, 77, 50, 50, 162, 50, 77, 77, 77, 50, 50, 77, 50, 77, 50, 50, 77, 77, - 77, 50, 50, 77, 77, 77, 50, 50, 50, 77, 77, 77, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 156, 148, 142, 148, 148, 77, 77, - 77, 148, 148, 148, 77, 157, 157, 157, 160, 77, 77, 50, 77, 77, 77, 77, - 77, 77, 156, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 154, - 154, 154, 154, 154, 154, 154, 154, 154, 154, 158, 158, 158, 88, 88, 88, - 88, 88, 88, 89, 88, 77, 77, 77, 77, 77, 142, 148, 148, 148, 142, 50, 50, - 50, 50, 50, 50, 50, 50, 77, 50, 50, 50, 77, 50, 50, 50, 149, 149, 149, + 77, 77, 77, 77, 77, 142, 142, 142, 161, 156, 77, 77, 77, 77, 153, 153, + 77, 149, 50, 50, 142, 142, 77, 77, 154, 154, 154, 154, 154, 154, 154, + 154, 154, 154, 83, 149, 158, 158, 158, 158, 158, 158, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 142, 50, 77, 50, 50, 50, 50, 50, 50, 77, 77, 77, 50, + 50, 50, 77, 50, 50, 162, 50, 77, 77, 77, 50, 50, 77, 50, 77, 50, 50, 77, + 77, 77, 50, 50, 77, 77, 77, 50, 50, 50, 77, 77, 77, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 156, 148, 142, 148, 148, 77, + 77, 77, 148, 148, 148, 77, 157, 157, 157, 160, 77, 77, 50, 77, 77, 77, + 77, 77, 77, 156, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 158, 158, 158, 88, 88, + 88, 88, 88, 88, 89, 88, 77, 77, 77, 77, 77, 142, 148, 148, 148, 142, 50, + 50, 50, 50, 50, 50, 50, 50, 77, 50, 50, 50, 77, 50, 50, 50, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 77, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 77, 77, 155, 50, 142, 142, 142, 148, 148, 148, - 148, 77, 142, 142, 163, 77, 142, 142, 142, 152, 77, 77, 77, 77, 77, 77, - 77, 164, 165, 77, 149, 149, 149, 77, 50, 50, 77, 77, 50, 50, 142, 142, - 77, 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, 77, 77, - 77, 77, 77, 86, 166, 166, 166, 166, 166, 166, 166, 83, 50, 142, 148, 148, - 86, 50, 50, 50, 50, 50, 50, 50, 50, 77, 50, 50, 50, 77, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 50, 50, 50, 50, 50, - 77, 77, 155, 50, 148, 167, 168, 148, 156, 148, 148, 77, 167, 168, 168, - 77, 168, 168, 142, 160, 77, 77, 77, 77, 77, 77, 77, 156, 156, 77, 77, 77, - 77, 77, 50, 50, 50, 77, 50, 50, 142, 142, 77, 77, 154, 154, 154, 154, - 154, 154, 154, 154, 154, 154, 77, 50, 50, 148, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 142, 142, 148, 148, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 77, 50, 50, 50, 77, 50, 50, 50, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 77, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 77, 77, 155, 50, 142, 142, 142, 148, 148, + 148, 148, 77, 142, 142, 163, 77, 142, 142, 142, 152, 77, 77, 77, 77, 77, + 77, 77, 164, 165, 77, 149, 149, 149, 77, 50, 50, 77, 77, 50, 50, 142, + 142, 77, 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, + 77, 77, 77, 77, 77, 86, 166, 166, 166, 166, 166, 166, 166, 83, 50, 142, + 148, 148, 86, 50, 50, 50, 50, 50, 50, 50, 50, 77, 50, 50, 50, 77, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 50, 50, 50, + 50, 50, 77, 77, 155, 50, 148, 167, 168, 148, 156, 148, 148, 77, 167, 168, + 168, 77, 168, 168, 142, 160, 77, 77, 77, 77, 77, 77, 77, 156, 156, 77, + 77, 77, 77, 77, 50, 50, 50, 77, 50, 50, 142, 142, 77, 77, 154, 154, 154, + 154, 154, 154, 154, 154, 154, 154, 77, 50, 50, 148, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 142, 142, 148, 148, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 77, 50, 50, 50, 77, 50, 50, 50, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 160, 160, 50, 156, 148, 148, 142, 142, 142, 142, 77, @@ -2541,14 +2556,14 @@ static const unsigned short index2[] = { 154, 77, 77, 77, 77, 77, 77, 86, 86, 86, 86, 86, 86, 86, 55, 86, 86, 86, 86, 86, 86, 77, 77, 84, 84, 84, 84, 84, 91, 91, 91, 91, 91, 91, 84, 84, 91, 85, 91, 91, 84, 84, 91, 91, 84, 84, 84, 84, 84, 91, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 91, 77, 77, 84, - 84, 84, 84, 84, 84, 91, 84, 84, 84, 84, 196, 77, 77, 77, 77, 77, 77, 77, + 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 91, 84, 84, 84, + 84, 84, 84, 84, 84, 91, 84, 84, 84, 84, 196, 84, 84, 91, 91, 84, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 142, 142, 142, 142, 148, 50, 162, 50, 162, 50, 162, 149, 150, 50, 162, 50, 50, 50, 162, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 155, 156, 142, 142, 142, 142, 142, 168, 142, 168, - 148, 148, 157, 157, 142, 168, 197, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 155, 156, 142, 142, 142, 142, 167, 168, 167, 168, + 148, 148, 157, 157, 167, 168, 197, 149, 149, 149, 149, 149, 149, 149, 149, 77, 86, 86, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 86, 86, 86, 86, 86, 86, 86, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 84, 91, 84, 84, 84, 84, 84, 84, 84, 83, 83, 83, 83, 83, 83, 83, 83, 83, 86, 86, @@ -2574,102 +2589,102 @@ static const unsigned short index2[] = { 46, 46, 77, 77, 46, 46, 46, 86, 86, 86, 86, 86, 86, 86, 86, 77, 77, 77, 77, 77, 77, 77, 77, 84, 84, 84, 86, 198, 91, 91, 91, 91, 91, 84, 84, 91, 91, 91, 91, 84, 148, 198, 198, 198, 198, 198, 198, 198, 50, 50, 50, 50, - 91, 50, 50, 50, 50, 50, 50, 84, 50, 50, 148, 84, 84, 50, 77, 77, 77, 77, - 77, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 91, 50, 50, 50, 50, 50, 50, 84, 199, 199, 148, 84, 84, 50, 77, 77, 77, + 77, 77, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 53, 53, 53, 55, 53, 53, 53, 53, 53, - 53, 53, 53, 53, 53, 53, 55, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 53, 53, 53, 55, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 55, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 55, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 53, 49, 49, 49, 49, + 53, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 53, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 53, 53, 53, 53, 53, 53, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, - 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 84, 84, 91, 84, 84, - 84, 84, 84, 84, 84, 91, 84, 84, 196, 199, 91, 200, 84, 84, 84, 84, 84, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 84, 84, 91, 84, + 84, 84, 84, 84, 84, 84, 91, 84, 84, 196, 200, 91, 201, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 201, 93, 93, 91, - 202, 84, 203, 91, 84, 91, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, - 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, - 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, - 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, - 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, - 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, - 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, - 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, - 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 45, 45, 45, 45, 37, 204, - 49, 49, 46, 49, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, - 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, - 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, - 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, - 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, - 40, 45, 40, 45, 46, 49, 46, 49, 46, 49, 45, 45, 45, 45, 45, 45, 45, 45, - 40, 40, 40, 40, 40, 40, 40, 40, 45, 45, 45, 45, 45, 45, 77, 77, 40, 40, - 40, 40, 40, 40, 77, 77, 45, 45, 45, 45, 45, 45, 45, 45, 40, 40, 40, 40, - 40, 40, 40, 40, 45, 45, 45, 45, 45, 45, 45, 45, 40, 40, 40, 40, 40, 40, - 40, 40, 45, 45, 45, 45, 45, 45, 77, 77, 40, 40, 40, 40, 40, 40, 77, 77, - 45, 45, 45, 45, 45, 45, 45, 45, 77, 40, 77, 40, 77, 40, 77, 40, 45, 45, - 45, 45, 45, 45, 45, 45, 40, 40, 40, 40, 40, 40, 40, 40, 45, 205, 45, 205, - 45, 205, 45, 205, 45, 205, 45, 205, 45, 205, 77, 77, 45, 45, 45, 45, 45, - 45, 45, 45, 206, 206, 206, 206, 206, 206, 206, 206, 45, 45, 45, 45, 45, - 45, 45, 45, 206, 206, 206, 206, 206, 206, 206, 206, 45, 45, 45, 45, 45, - 45, 45, 45, 206, 206, 206, 206, 206, 206, 206, 206, 45, 45, 45, 45, 45, - 77, 45, 45, 40, 40, 40, 207, 206, 60, 205, 60, 60, 79, 45, 45, 45, 77, - 45, 45, 40, 207, 40, 207, 206, 79, 79, 79, 45, 45, 45, 205, 77, 77, 45, - 45, 40, 40, 40, 207, 77, 79, 79, 79, 45, 45, 45, 205, 45, 45, 45, 45, 40, - 40, 40, 207, 40, 79, 208, 208, 77, 77, 45, 45, 45, 77, 45, 45, 40, 207, - 40, 207, 206, 208, 60, 77, 209, 209, 210, 210, 210, 210, 210, 210, 210, - 210, 210, 195, 211, 212, 213, 214, 215, 216, 87, 215, 215, 215, 24, 217, - 218, 219, 220, 221, 218, 219, 220, 221, 24, 24, 24, 145, 222, 222, 222, - 24, 223, 224, 225, 226, 227, 228, 229, 23, 230, 115, 230, 231, 232, 24, - 217, 217, 145, 30, 38, 24, 233, 145, 222, 234, 234, 145, 145, 145, 235, - 179, 180, 217, 217, 233, 145, 145, 145, 145, 145, 145, 145, 145, 81, 145, - 234, 145, 145, 217, 145, 145, 145, 145, 145, 145, 145, 210, 195, 195, - 195, 195, 195, 236, 237, 238, 239, 240, 195, 195, 195, 195, 195, 195, - 241, 53, 77, 77, 36, 241, 241, 241, 241, 241, 242, 242, 243, 244, 245, - 246, 241, 36, 36, 36, 36, 241, 241, 241, 241, 241, 242, 242, 243, 244, - 245, 77, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 77, 77, 77, - 89, 89, 89, 89, 89, 89, 89, 89, 247, 248, 89, 89, 25, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 249, 249, - 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 84, 84, 198, - 198, 84, 84, 84, 84, 198, 198, 198, 84, 84, 85, 85, 85, 85, 84, 85, 85, - 85, 198, 198, 84, 91, 84, 198, 198, 91, 91, 91, 91, 84, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 250, 250, 51, 251, 88, 251, - 250, 51, 88, 251, 37, 51, 51, 51, 37, 37, 51, 51, 51, 48, 88, 51, 251, - 88, 81, 51, 51, 51, 51, 51, 88, 88, 250, 251, 252, 88, 51, 88, 253, 88, - 51, 88, 207, 253, 51, 51, 254, 37, 51, 51, 46, 51, 37, 176, 176, 176, - 176, 255, 88, 250, 37, 37, 51, 51, 256, 81, 81, 81, 81, 51, 37, 37, 37, - 37, 88, 81, 88, 88, 49, 83, 257, 257, 257, 39, 39, 257, 257, 257, 257, - 257, 257, 39, 39, 39, 39, 257, 258, 258, 258, 258, 258, 258, 258, 258, - 258, 258, 258, 258, 259, 259, 259, 259, 258, 258, 258, 258, 258, 258, - 258, 258, 258, 258, 259, 259, 259, 259, 259, 259, 193, 193, 193, 46, 49, - 193, 193, 193, 193, 39, 88, 88, 77, 77, 77, 77, 42, 42, 42, 42, 260, 32, - 32, 32, 32, 32, 261, 261, 88, 88, 88, 88, 81, 88, 88, 81, 88, 88, 81, 88, - 88, 28, 28, 88, 88, 88, 261, 88, 88, 88, 88, 88, 88, 88, 88, 88, 262, - 262, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 263, 261, 261, 88, 88, 42, 88, 42, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 262, 88, 88, 88, 88, 88, 88, + 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 202, 93, 93, + 91, 203, 84, 204, 91, 84, 91, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, + 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, + 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, + 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, + 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, + 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, + 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, + 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, + 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 45, 45, 45, 45, 37, + 205, 49, 49, 46, 49, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, + 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, + 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, + 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, + 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, 45, 40, + 45, 40, 45, 40, 45, 46, 49, 46, 49, 46, 49, 45, 45, 45, 45, 45, 45, 45, + 45, 40, 40, 40, 40, 40, 40, 40, 40, 45, 45, 45, 45, 45, 45, 77, 77, 40, + 40, 40, 40, 40, 40, 77, 77, 45, 45, 45, 45, 45, 45, 45, 45, 40, 40, 40, + 40, 40, 40, 40, 40, 45, 45, 45, 45, 45, 45, 45, 45, 40, 40, 40, 40, 40, + 40, 40, 40, 45, 45, 45, 45, 45, 45, 77, 77, 40, 40, 40, 40, 40, 40, 77, + 77, 45, 45, 45, 45, 45, 45, 45, 45, 77, 40, 77, 40, 77, 40, 77, 40, 45, + 45, 45, 45, 45, 45, 45, 45, 40, 40, 40, 40, 40, 40, 40, 40, 45, 206, 45, + 206, 45, 206, 45, 206, 45, 206, 45, 206, 45, 206, 77, 77, 45, 45, 45, 45, + 45, 45, 45, 45, 207, 207, 207, 207, 207, 207, 207, 207, 45, 45, 45, 45, + 45, 45, 45, 45, 207, 207, 207, 207, 207, 207, 207, 207, 45, 45, 45, 45, + 45, 45, 45, 45, 207, 207, 207, 207, 207, 207, 207, 207, 45, 45, 45, 45, + 45, 77, 45, 45, 40, 40, 40, 208, 207, 60, 206, 60, 60, 79, 45, 45, 45, + 77, 45, 45, 40, 208, 40, 208, 207, 79, 79, 79, 45, 45, 45, 206, 77, 77, + 45, 45, 40, 40, 40, 208, 77, 79, 79, 79, 45, 45, 45, 206, 45, 45, 45, 45, + 40, 40, 40, 208, 40, 79, 209, 209, 77, 77, 45, 45, 45, 77, 45, 45, 40, + 208, 40, 208, 207, 209, 60, 77, 210, 210, 211, 211, 211, 211, 211, 211, + 211, 211, 211, 195, 212, 213, 214, 215, 216, 217, 87, 216, 216, 216, 24, + 218, 219, 220, 221, 222, 219, 220, 221, 222, 24, 24, 24, 145, 223, 223, + 223, 24, 224, 225, 226, 227, 228, 229, 230, 23, 231, 115, 231, 232, 233, + 24, 218, 218, 145, 30, 38, 24, 234, 145, 223, 235, 235, 145, 145, 145, + 236, 179, 180, 218, 218, 234, 145, 145, 145, 145, 145, 145, 145, 145, 81, + 145, 235, 145, 145, 218, 145, 145, 145, 145, 145, 145, 145, 211, 195, + 195, 195, 195, 195, 237, 238, 239, 240, 241, 195, 195, 195, 195, 195, + 195, 242, 53, 77, 77, 36, 242, 242, 242, 242, 242, 243, 243, 244, 245, + 246, 247, 242, 36, 36, 36, 36, 242, 242, 242, 242, 242, 243, 243, 244, + 245, 246, 54, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 89, 89, 89, 89, 89, 89, 89, 89, 248, 249, 89, 89, 25, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 84, 84, + 198, 198, 84, 84, 84, 84, 198, 198, 198, 84, 84, 85, 85, 85, 85, 84, 85, + 85, 85, 198, 198, 84, 91, 84, 198, 198, 91, 91, 91, 91, 84, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 251, 251, 51, 252, 88, + 252, 251, 51, 88, 252, 37, 51, 51, 51, 37, 37, 51, 51, 51, 48, 88, 51, + 252, 88, 81, 51, 51, 51, 51, 51, 88, 88, 251, 252, 253, 88, 51, 88, 254, + 88, 51, 88, 208, 254, 51, 51, 255, 37, 51, 51, 46, 51, 37, 176, 176, 176, + 176, 256, 88, 251, 37, 37, 51, 51, 257, 81, 81, 81, 81, 51, 37, 37, 37, + 37, 88, 81, 88, 88, 49, 83, 258, 258, 258, 39, 39, 258, 258, 258, 258, + 258, 258, 39, 39, 39, 39, 258, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 260, 260, 260, 260, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 260, 260, 260, 260, 260, 260, 193, 193, 193, 46, 49, + 193, 193, 193, 193, 39, 88, 88, 77, 77, 77, 77, 42, 42, 42, 42, 261, 32, + 32, 32, 32, 32, 262, 262, 88, 88, 88, 88, 81, 88, 88, 81, 88, 88, 81, 88, + 88, 28, 28, 88, 88, 88, 262, 88, 88, 88, 88, 88, 88, 88, 88, 88, 263, + 263, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 264, 262, 262, 88, 88, 42, 88, 42, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 263, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 42, 264, 265, 265, 266, 81, 81, 42, 265, 266, 264, 265, 266, 264, 81, 42, - 81, 265, 267, 268, 81, 265, 264, 81, 81, 81, 265, 264, 264, 265, 42, 265, - 265, 264, 264, 42, 266, 42, 266, 42, 42, 42, 42, 265, 269, 256, 265, 256, - 256, 264, 264, 264, 42, 42, 42, 42, 81, 264, 81, 264, 265, 265, 264, 264, - 264, 266, 264, 264, 266, 264, 264, 266, 265, 266, 264, 264, 265, 81, 81, - 81, 81, 81, 265, 264, 264, 264, 81, 81, 81, 81, 81, 81, 81, 81, 81, 264, - 270, 42, 266, 81, 265, 265, 265, 265, 264, 264, 265, 265, 81, 266, 270, - 270, 266, 266, 264, 264, 266, 266, 264, 264, 266, 266, 264, 264, 264, - 264, 264, 264, 266, 266, 265, 265, 266, 266, 265, 265, 266, 266, 264, - 264, 264, 81, 81, 264, 264, 264, 264, 81, 81, 42, 81, 81, 264, 42, 81, - 81, 81, 81, 81, 81, 81, 81, 264, 264, 81, 42, 264, 264, 264, 264, 264, - 264, 266, 266, 266, 266, 264, 264, 264, 264, 264, 264, 264, 264, 264, 81, - 81, 81, 81, 81, 264, 265, 81, 81, 81, 81, 81, 81, 81, 81, 81, 264, 264, - 264, 264, 264, 81, 81, 264, 264, 81, 81, 81, 81, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 266, 266, 266, 266, 264, 264, 264, 264, 264, - 264, 266, 266, 266, 266, 81, 81, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264, 264, 88, 88, 88, 88, 88, 88, 88, 88, - 179, 180, 179, 180, 88, 88, 88, 88, 88, 88, 262, 88, 88, 88, 88, 88, 88, - 88, 271, 271, 88, 88, 88, 88, 264, 264, 88, 88, 88, 88, 88, 88, 28, 272, - 273, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 83, 83, 83, 83, 83, 83, + 42, 265, 266, 266, 267, 81, 81, 42, 266, 267, 265, 266, 267, 265, 81, 42, + 81, 266, 268, 269, 81, 266, 265, 81, 81, 81, 266, 265, 265, 266, 42, 266, + 266, 265, 265, 42, 267, 42, 267, 42, 42, 42, 42, 266, 270, 257, 266, 257, + 257, 265, 265, 265, 42, 42, 42, 42, 81, 265, 81, 265, 266, 266, 265, 265, + 265, 267, 265, 265, 267, 265, 265, 267, 266, 267, 265, 265, 266, 81, 81, + 81, 81, 81, 266, 265, 265, 265, 81, 81, 81, 81, 81, 81, 81, 81, 81, 265, + 271, 42, 267, 81, 266, 266, 266, 266, 265, 265, 266, 266, 81, 267, 271, + 271, 267, 267, 265, 265, 267, 267, 265, 265, 267, 267, 265, 265, 265, + 265, 265, 265, 267, 267, 266, 266, 267, 267, 266, 266, 267, 267, 265, + 265, 265, 81, 81, 265, 265, 265, 265, 81, 81, 42, 81, 81, 265, 42, 81, + 81, 81, 81, 81, 81, 81, 81, 265, 265, 81, 42, 265, 265, 265, 265, 265, + 265, 267, 267, 267, 267, 265, 265, 265, 265, 265, 265, 265, 265, 265, 81, + 81, 81, 81, 81, 265, 266, 81, 81, 81, 81, 81, 81, 81, 81, 81, 265, 265, + 265, 265, 265, 81, 81, 265, 265, 81, 81, 81, 81, 265, 265, 265, 265, 265, + 265, 265, 265, 265, 265, 267, 267, 267, 267, 265, 265, 265, 265, 265, + 265, 267, 267, 267, 267, 81, 81, 265, 265, 265, 265, 265, 265, 265, 265, + 265, 265, 265, 265, 265, 265, 265, 265, 88, 88, 88, 88, 88, 88, 88, 88, + 179, 180, 179, 180, 88, 88, 88, 88, 88, 88, 263, 88, 88, 88, 88, 88, 88, + 88, 272, 272, 88, 88, 88, 88, 265, 265, 88, 88, 88, 88, 88, 88, 28, 273, + 274, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, @@ -2679,8 +2694,8 @@ static const unsigned short index2[] = { 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 28, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 81, 81, - 81, 81, 81, 81, 88, 88, 88, 88, 88, 88, 88, 271, 271, 271, 271, 28, 28, - 28, 271, 28, 28, 271, 88, 88, 88, 88, 28, 28, 28, 88, 88, 88, 88, 88, 88, + 81, 81, 81, 81, 88, 88, 88, 88, 88, 88, 88, 272, 272, 272, 272, 28, 28, + 28, 272, 28, 28, 272, 88, 88, 88, 88, 28, 28, 28, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, @@ -2689,60 +2704,60 @@ static const unsigned short index2[] = { 77, 77, 77, 77, 77, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 36, 36, 36, 36, 36, 36, 36, 36, 36, - 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 275, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 257, 276, 276, 276, 276, 276, 276, 276, 276, 276, 276, 276, - 276, 276, 276, 276, 276, 276, 276, 276, 276, 276, 262, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - 262, 262, 88, 88, 88, 88, 262, 262, 262, 262, 262, 262, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 262, 262, 262, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 88, 88, 262, 262, 262, - 262, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 262, 262, 88, 262, 262, 262, - 262, 262, 262, 262, 28, 28, 88, 88, 88, 88, 88, 88, 262, 262, 88, 88, 32, - 42, 88, 88, 88, 88, 262, 262, 88, 88, 32, 42, 88, 88, 88, 88, 262, 262, - 262, 88, 88, 262, 88, 88, 262, 262, 262, 262, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 262, 262, 262, 262, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 262, 88, 88, 88, 88, 88, 88, 88, 88, 81, 81, 81, 277, - 277, 278, 278, 81, 28, 28, 28, 28, 28, 262, 262, 88, 88, 262, 88, 88, 88, - 88, 32, 262, 88, 28, 88, 88, 271, 271, 88, 88, 28, 88, 88, 88, 262, 28, - 262, 88, 28, 88, 28, 28, 88, 88, 28, 88, 88, 88, 28, 88, 88, 88, 28, 28, - 279, 279, 279, 279, 279, 279, 279, 279, 28, 28, 28, 88, 88, 88, 88, 88, - 32, 88, 32, 88, 88, 88, 88, 88, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 28, 32, - 262, 88, 32, 262, 32, 28, 262, 32, 262, 262, 88, 262, 262, 88, 42, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 28, 88, 88, 28, 271, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 279, 279, 279, 279, 279, 279, 88, 88, 28, - 271, 28, 28, 28, 28, 88, 28, 88, 28, 28, 88, 262, 262, 28, 271, 88, 88, - 88, 88, 88, 28, 88, 88, 271, 271, 83, 88, 88, 88, 28, 28, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 271, 271, 262, 88, 88, 88, 88, 271, 271, 262, - 262, 32, 262, 262, 262, 262, 262, 271, 32, 262, 32, 262, 32, 271, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 88, 262, 88, - 88, 88, 88, 262, 32, 271, 262, 262, 262, 262, 262, 32, 32, 271, 271, 32, - 271, 262, 32, 32, 32, 271, 262, 262, 271, 262, 262, 88, 88, 28, 88, 88, - 271, 88, 88, 28, 28, 271, 271, 28, 28, 88, 28, 88, 88, 28, 88, 28, 88, + 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 275, 275, 275, 275, 275, 275, + 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, + 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, + 275, 275, 275, 275, 276, 275, 275, 275, 275, 275, 275, 275, 275, 275, + 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, + 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, + 275, 275, 258, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, + 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 263, 263, 263, 263, + 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, + 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, + 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, + 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, + 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, + 263, 263, 88, 88, 88, 88, 263, 263, 263, 263, 263, 263, 263, 263, 263, + 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, + 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 263, 263, 263, 263, 263, 263, + 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 88, 88, 263, 263, 263, + 263, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 263, 263, 88, 263, 263, 263, + 263, 263, 263, 263, 28, 28, 88, 88, 88, 88, 88, 88, 263, 263, 88, 88, 32, + 42, 88, 88, 88, 88, 263, 263, 88, 88, 32, 42, 88, 88, 88, 88, 263, 263, + 263, 88, 88, 263, 88, 88, 263, 263, 263, 263, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 263, 263, 263, 263, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 263, 88, 88, 88, 88, 88, 88, 88, 88, 81, 81, 81, 278, + 278, 279, 279, 81, 28, 28, 28, 28, 28, 263, 263, 88, 88, 263, 88, 88, 88, + 88, 32, 263, 88, 28, 88, 88, 272, 272, 88, 88, 28, 88, 88, 88, 263, 28, + 263, 88, 28, 88, 28, 28, 88, 88, 28, 88, 88, 88, 28, 88, 88, 88, 28, 28, + 280, 280, 280, 280, 280, 280, 280, 280, 28, 28, 28, 88, 88, 88, 88, 88, + 32, 88, 32, 88, 88, 88, 88, 88, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 28, 32, + 263, 88, 32, 263, 32, 28, 263, 32, 263, 263, 88, 263, 263, 88, 42, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 28, 88, 88, 28, 272, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 280, 280, 280, 280, 280, 280, 88, 88, 28, + 272, 28, 28, 28, 28, 88, 28, 88, 28, 28, 88, 263, 263, 28, 272, 88, 88, + 88, 88, 88, 28, 88, 88, 272, 272, 83, 88, 88, 88, 28, 28, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 272, 272, 263, 88, 88, 88, 88, 272, 272, 263, + 263, 32, 263, 263, 263, 263, 263, 272, 32, 263, 32, 263, 32, 272, 263, + 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 88, 263, 88, + 88, 88, 88, 263, 32, 272, 263, 263, 263, 263, 263, 32, 32, 272, 272, 32, + 272, 263, 32, 32, 32, 272, 263, 263, 272, 263, 263, 88, 88, 28, 88, 88, + 272, 88, 88, 28, 28, 272, 272, 28, 28, 88, 28, 88, 88, 28, 88, 28, 88, 28, 88, 88, 88, 88, 88, 88, 28, 88, 88, 88, 28, 88, 88, 88, 88, 88, 88, - 271, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 28, 28, 88, 88, 88, 88, 88, - 88, 88, 88, 262, 88, 88, 88, 88, 88, 88, 28, 88, 88, 28, 88, 88, 88, 88, - 271, 88, 271, 88, 88, 88, 88, 271, 271, 271, 88, 271, 88, 88, 88, 88, 88, + 272, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 28, 28, 88, 88, 88, 88, 88, + 88, 88, 88, 263, 88, 88, 88, 88, 88, 88, 28, 88, 88, 28, 88, 88, 88, 88, + 272, 88, 272, 88, 88, 88, 88, 272, 272, 272, 88, 272, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 28, 28, 88, 88, 88, 179, 180, 179, 180, 179, 180, - 179, 180, 179, 180, 179, 180, 179, 180, 276, 276, 276, 276, 276, 276, - 276, 276, 276, 276, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, - 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 88, 271, 271, 271, 88, + 179, 180, 179, 180, 179, 180, 179, 180, 277, 277, 277, 277, 277, 277, + 277, 277, 277, 277, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, + 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 88, 272, 272, 272, 88, 88, 88, 88, 88, 88, 88, 88, 88, 28, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 271, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 271, 264, 81, 81, 264, 264, 179, 180, 81, 264, 264, 81, 264, 264, - 264, 81, 81, 81, 81, 81, 264, 264, 264, 264, 81, 81, 81, 81, 81, 264, - 264, 264, 81, 81, 81, 264, 264, 264, 264, 11, 12, 11, 12, 11, 12, 11, 12, + 88, 88, 88, 88, 88, 272, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 272, 265, 81, 81, 265, 265, 179, 180, 81, 265, 265, 81, 265, 265, + 265, 81, 81, 81, 81, 81, 265, 265, 265, 265, 81, 81, 81, 81, 81, 265, + 265, 265, 81, 81, 81, 265, 265, 265, 265, 11, 12, 11, 12, 11, 12, 11, 12, 179, 180, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, @@ -2754,40 +2769,40 @@ static const unsigned short index2[] = { 83, 83, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 277, 277, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 278, 278, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 179, 180, 11, 12, 179, 180, 179, 180, 179, 180, 179, 180, 179, 180, 179, 180, 179, 180, 179, 180, 179, 180, 81, 81, - 264, 264, 264, 264, 264, 264, 81, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 81, 81, 81, 81, 81, 81, 81, 81, 264, 81, - 81, 81, 81, 81, 81, 81, 264, 264, 264, 264, 264, 264, 81, 81, 81, 264, - 81, 81, 81, 81, 264, 264, 264, 264, 264, 81, 264, 264, 81, 81, 179, 180, - 179, 180, 264, 81, 81, 81, 81, 264, 81, 264, 264, 264, 81, 81, 264, 264, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 264, 264, 264, 264, 264, 264, 81, - 81, 179, 180, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 264, 264, - 256, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 81, 264, 264, 264, 264, 81, 81, 264, 81, 264, 81, 81, 264, - 81, 264, 264, 264, 264, 81, 81, 81, 81, 81, 264, 264, 81, 81, 81, 81, 81, - 81, 264, 264, 264, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 264, 264, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 264, 264, 81, 81, 81, 81, 264, 264, 264, 264, 81, - 264, 264, 81, 81, 264, 256, 243, 243, 81, 81, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 81, 81, 264, 264, 264, - 264, 264, 264, 264, 264, 81, 264, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 81, 81, 81, 81, 81, 280, 81, 264, 81, 81, 81, 264, 264, - 264, 264, 264, 81, 81, 81, 81, 81, 264, 264, 264, 81, 81, 81, 81, 264, - 81, 81, 81, 264, 264, 264, 264, 264, 81, 264, 81, 81, 88, 88, 88, 88, 88, + 265, 265, 265, 265, 265, 265, 81, 265, 265, 265, 265, 265, 265, 265, 265, + 265, 265, 265, 265, 265, 265, 81, 81, 81, 81, 81, 81, 81, 81, 265, 81, + 81, 81, 81, 81, 81, 81, 265, 265, 265, 265, 265, 265, 81, 81, 81, 265, + 81, 81, 81, 81, 265, 265, 265, 265, 265, 81, 265, 265, 81, 81, 179, 180, + 179, 180, 265, 81, 81, 81, 81, 265, 81, 265, 265, 265, 81, 81, 265, 265, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 265, 265, 265, 265, 265, 265, 81, + 81, 179, 180, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 265, 265, + 257, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, + 265, 265, 265, 81, 265, 265, 265, 265, 81, 81, 265, 81, 265, 81, 81, 265, + 81, 265, 265, 265, 265, 81, 81, 81, 81, 81, 265, 265, 81, 81, 81, 81, 81, + 81, 265, 265, 265, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 265, 265, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 265, 265, 81, 81, 81, 81, 265, 265, 265, 265, 81, + 265, 265, 81, 81, 265, 257, 244, 244, 81, 81, 265, 265, 265, 265, 265, + 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, + 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, + 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 81, 81, 265, 265, 265, + 265, 265, 265, 265, 265, 81, 265, 265, 265, 265, 265, 265, 265, 265, 265, + 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, + 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, + 265, 265, 265, 81, 81, 81, 81, 81, 281, 81, 265, 81, 81, 81, 265, 265, + 265, 265, 265, 81, 81, 81, 81, 81, 265, 265, 265, 81, 81, 81, 81, 265, + 81, 81, 81, 265, 265, 265, 265, 265, 81, 265, 81, 81, 88, 88, 88, 88, 88, 28, 28, 28, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 271, 271, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 272, 272, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 88, 88, 81, 81, 81, 81, 81, 81, - 88, 88, 88, 271, 88, 88, 88, 88, 271, 262, 262, 262, 262, 88, 88, 88, 88, + 88, 88, 88, 272, 88, 88, 88, 88, 272, 263, 263, 263, 263, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 77, 77, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, @@ -2796,7 +2811,7 @@ static const unsigned short index2[] = { 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 281, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 282, 88, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 49, 49, 49, 49, 49, 49, @@ -2829,318 +2844,309 @@ static const unsigned short index2[] = { 145, 145, 30, 38, 145, 30, 38, 145, 145, 145, 145, 145, 145, 145, 145, 145, 87, 145, 145, 87, 145, 30, 38, 145, 145, 30, 38, 179, 180, 179, 180, 179, 180, 179, 180, 145, 145, 145, 145, 145, 54, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 87, 87, 145, 145, 145, 145, 87, 145, 220, 145, + 145, 145, 145, 145, 145, 87, 87, 145, 145, 145, 145, 87, 145, 221, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 88, 88, 145, - 145, 145, 179, 180, 179, 180, 179, 180, 179, 180, 87, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 77, 279, 279, 279, 279, 282, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 282, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 283, 284, 284, 284, 279, 285, 286, 287, 288, 289, 288, - 289, 288, 289, 288, 289, 288, 289, 279, 279, 288, 289, 288, 289, 288, - 289, 288, 289, 290, 291, 292, 292, 279, 287, 287, 287, 287, 287, 287, - 287, 287, 287, 293, 294, 295, 296, 297, 297, 298, 285, 285, 285, 285, - 285, 282, 279, 299, 299, 299, 285, 286, 300, 279, 88, 77, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 301, 286, 301, 286, 301, 286, - 301, 286, 301, 286, 301, 286, 301, 286, 301, 286, 301, 286, 301, 286, - 301, 286, 301, 286, 286, 301, 286, 301, 286, 301, 286, 286, 286, 286, - 286, 286, 301, 301, 286, 301, 301, 286, 301, 301, 286, 301, 301, 286, - 301, 301, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 301, 286, 286, 77, 77, - 302, 302, 303, 303, 285, 304, 305, 290, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 301, 286, 301, 286, 301, 286, 301, 286, 301, - 286, 301, 286, 301, 286, 301, 286, 301, 286, 301, 286, 301, 286, 301, - 286, 286, 301, 286, 301, 286, 301, 286, 286, 286, 286, 286, 286, 301, - 301, 286, 301, 301, 286, 301, 301, 286, 301, 301, 286, 301, 301, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 301, 286, 286, 301, 301, 301, 301, - 284, 285, 285, 304, 305, 77, 77, 77, 77, 77, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 77, 305, 305, 305, 305, - 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, - 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, - 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, - 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, - 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, - 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, - 305, 305, 305, 305, 305, 305, 77, 306, 306, 307, 307, 307, 307, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 279, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 282, 282, 77, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 309, 309, 309, 309, 309, 309, 309, 309, 282, 310, - 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 282, 282, 282, 306, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 311, - 308, 311, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 310, 310, 310, - 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 282, 282, 282, 282, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 282, - 282, 282, 282, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 282, 282, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 282, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 285, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 77, 77, 77, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 55, 55, 55, - 55, 55, 55, 86, 86, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 55, - 145, 145, 145, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 50, 50, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, - 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, - 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 50, 84, 85, 85, 85, 145, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, 145, 54, 46, 49, 46, 49, 46, 49, 46, 49, - 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, - 46, 49, 53, 53, 84, 84, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 145, 145, 179, 180, 179, 180, 179, 180, 179, 180, 87, 77, 77, 145, 145, + 179, 180, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 77, 280, 280, 280, 280, 283, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 283, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 283, 283, 283, 283, 283, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 284, 285, 285, 285, 280, 286, 287, 288, 289, + 290, 289, 290, 289, 290, 289, 290, 289, 290, 280, 280, 289, 290, 289, + 290, 289, 290, 289, 290, 291, 292, 293, 293, 280, 288, 288, 288, 288, + 288, 288, 288, 288, 288, 294, 295, 296, 297, 298, 298, 299, 286, 286, + 286, 286, 286, 283, 280, 300, 300, 300, 286, 287, 301, 280, 88, 77, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 302, 287, 302, 287, + 302, 287, 302, 287, 302, 287, 302, 287, 302, 287, 302, 287, 302, 287, + 302, 287, 302, 287, 302, 287, 287, 302, 287, 302, 287, 302, 287, 287, + 287, 287, 287, 287, 302, 302, 287, 302, 302, 287, 302, 302, 287, 302, + 302, 287, 302, 302, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 302, 287, + 287, 77, 77, 303, 303, 304, 304, 286, 305, 306, 291, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 302, 287, 302, 287, 302, 287, 302, + 287, 302, 287, 302, 287, 302, 287, 302, 287, 302, 287, 302, 287, 302, + 287, 302, 287, 287, 302, 287, 302, 287, 302, 287, 287, 287, 287, 287, + 287, 302, 302, 287, 302, 302, 287, 302, 302, 287, 302, 302, 287, 302, + 302, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 302, 287, 287, 302, 302, + 302, 302, 285, 286, 286, 305, 306, 77, 77, 77, 77, 77, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 77, 306, 306, + 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, + 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, + 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, + 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, + 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, + 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, + 306, 306, 306, 306, 306, 306, 306, 306, 77, 307, 307, 308, 308, 308, 308, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 280, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 283, 283, 77, 308, 308, 308, 308, 308, 308, + 308, 308, 308, 308, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 310, 310, 310, 310, 310, 310, 310, 310, + 283, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, + 311, 311, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 283, 283, 283, 307, 308, 308, 308, 308, 308, 308, 308, 308, + 308, 308, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 312, 309, 312, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 311, + 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 283, 283, + 283, 283, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 283, 283, 283, 283, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 283, 283, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 283, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 286, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 77, 77, 77, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 55, 55, 55, 55, 55, 55, 86, 86, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 55, 145, 145, 145, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 50, + 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, + 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, + 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 50, 84, 85, 85, 85, + 145, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 145, 54, 46, 49, 46, 49, 46, + 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, + 49, 46, 49, 46, 49, 53, 53, 84, 84, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 84, 84, - 86, 86, 86, 86, 86, 86, 77, 77, 77, 77, 77, 77, 77, 77, 56, 56, 56, 56, + 50, 50, 50, 50, 50, 50, 50, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 84, 84, 86, 86, 86, 86, 86, 86, 77, 77, 77, 77, 77, 77, 77, 77, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 54, 54, 54, 54, 54, 54, 54, 54, 54, 56, 56, 46, 49, 46, 49, 46, 49, - 46, 49, 46, 49, 46, 49, 46, 49, 49, 49, 46, 49, 46, 49, 46, 49, 46, 49, - 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, - 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, - 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, - 53, 49, 49, 49, 49, 49, 49, 49, 49, 46, 49, 46, 49, 46, 46, 49, 46, 49, - 46, 49, 46, 49, 46, 49, 54, 312, 312, 46, 49, 46, 49, 50, 46, 49, 46, 49, - 49, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, - 46, 49, 46, 49, 46, 46, 46, 46, 46, 49, 46, 46, 46, 46, 46, 49, 46, 49, - 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 46, 46, 46, 49, 46, - 49, 46, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, - 46, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 53, 53, 53, 53, 46, 49, 50, 53, 53, 49, 50, 50, 50, 50, 50, - 50, 50, 142, 50, 50, 50, 160, 50, 50, 50, 50, 142, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 148, 148, 142, 142, 148, 88, 88, 88, 88, 160, 77, 77, 77, 158, 158, 158, - 158, 158, 158, 83, 83, 89, 254, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 145, 145, 145, 145, 77, - 77, 77, 77, 77, 77, 77, 77, 148, 148, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, - 148, 148, 148, 148, 148, 148, 160, 142, 77, 77, 77, 77, 77, 77, 77, 77, - 86, 86, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, 77, 77, - 77, 77, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 50, 50, 50, 50, 50, 50, 86, 86, 86, 50, 86, 50, 50, 142, 154, - 154, 154, 154, 154, 154, 154, 154, 154, 154, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 142, 142, 142, 142, 142, 91, 91, 91, 86, 86, 50, 50, 50, 50, + 56, 56, 56, 56, 54, 54, 54, 54, 54, 54, 54, 54, 54, 56, 56, 46, 49, 46, + 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 49, 49, 46, 49, 46, 49, 46, + 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, + 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, + 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, + 49, 46, 49, 53, 49, 49, 49, 49, 49, 49, 49, 49, 46, 49, 46, 49, 46, 46, + 49, 46, 49, 46, 49, 46, 49, 46, 49, 54, 313, 313, 46, 49, 46, 49, 50, 46, + 49, 46, 49, 49, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, + 49, 46, 49, 46, 49, 46, 49, 46, 46, 46, 46, 46, 49, 46, 46, 46, 46, 46, + 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 46, 46, + 46, 49, 46, 49, 46, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, + 49, 46, 49, 46, 46, 77, 77, 77, 77, 46, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 53, 53, 53, 53, 46, 49, 50, 53, 53, 49, 50, 50, + 50, 50, 50, 50, 50, 142, 50, 50, 50, 160, 50, 50, 50, 50, 142, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 148, 148, 142, 142, 148, 88, 88, 88, 88, 160, 77, 77, 77, + 158, 158, 158, 158, 158, 158, 83, 83, 89, 255, 77, 77, 77, 77, 77, 77, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 145, 145, + 145, 145, 77, 77, 77, 77, 77, 77, 77, 77, 148, 148, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 148, 148, 148, 148, 148, 148, 148, + 148, 148, 148, 148, 148, 148, 148, 148, 148, 160, 142, 77, 77, 77, 77, + 77, 77, 77, 77, 86, 86, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 77, 77, 77, 77, 77, 77, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, + 84, 84, 84, 84, 84, 84, 50, 50, 50, 50, 50, 50, 86, 86, 86, 50, 86, 50, + 50, 142, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 142, 142, 142, 142, 142, 91, 91, 91, 86, 86, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 148, 194, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 86, 187, 187, 187, 187, 187, 187, + 50, 50, 50, 50, 50, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, + 142, 148, 194, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 86, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, - 187, 187, 187, 187, 187, 187, 187, 187, 187, 77, 77, 77, 142, 142, 142, - 148, 50, 50, 50, 50, 50, 149, 149, 149, 50, 50, 50, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 77, 77, + 77, 142, 142, 142, 148, 50, 50, 50, 50, 50, 149, 149, 149, 50, 50, 50, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 155, 148, 148, 142, 142, 142, 142, 148, 148, 142, - 142, 148, 148, 197, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, - 77, 55, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, 77, 77, - 86, 86, 149, 149, 149, 149, 149, 142, 55, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 149, - 149, 149, 149, 149, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 142, 142, 142, 142, 142, 142, - 148, 148, 142, 142, 148, 148, 142, 142, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 50, 50, 50, 142, 50, 50, 50, 50, 50, 50, 50, 50, 142, 148, 77, 77, - 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, 86, 86, 86, 86, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 55, 149, 149, 149, 50, 50, 50, 83, 83, 83, 149, 186, 142, 186, - 149, 149, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 84, 50, 84, 84, - 91, 50, 50, 84, 84, 50, 50, 50, 50, 50, 84, 84, 50, 84, 50, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 50, 50, 55, 86, 86, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 148, 142, 142, 148, 148, 86, 86, 50, 55, 55, 148, 152, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 77, 77, 50, - 50, 50, 50, 50, 50, 77, 77, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 77, 50, 50, 50, 50, 50, 50, - 50, 77, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 149, 149, 149, 149, 149, 149, 149, 149, 155, 148, 148, 142, 142, 142, + 142, 148, 148, 142, 142, 148, 148, 197, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 77, 55, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 154, 77, 77, 77, 77, 86, 86, 149, 149, 149, 149, 149, 142, 55, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 154, 154, 154, 154, 154, 154, 154, + 154, 154, 154, 149, 149, 149, 149, 149, 77, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 142, 142, + 142, 142, 142, 142, 148, 148, 142, 142, 148, 148, 142, 142, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 50, 50, 50, 142, 50, 50, 50, 50, 50, 50, 50, 50, + 142, 148, 77, 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, + 77, 86, 86, 86, 86, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 55, 149, 149, 149, 50, 50, 50, 83, 83, 83, + 149, 186, 142, 186, 149, 149, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 84, 50, 84, 84, 91, 50, 50, 84, 84, 50, 50, 50, 50, 50, 84, 84, 50, + 84, 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 55, 86, 86, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 148, 142, 142, 148, 148, 86, 86, 50, + 55, 55, 148, 152, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, + 50, 50, 77, 77, 50, 50, 50, 50, 50, 50, 77, 77, 50, 50, 50, 50, 50, 50, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 77, 50, + 50, 50, 50, 50, 50, 50, 77, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 312, 53, 53, 53, 53, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 53, 56, 56, 77, 77, 77, 77, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 313, 53, 53, 53, + 53, 49, 49, 49, 49, 49, 49, 49, 49, 49, 53, 56, 56, 46, 46, 77, 77, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 50, - 50, 50, 50, 50, 50, 50, 50, 148, 148, 142, 148, 148, 142, 148, 148, 86, - 148, 160, 77, 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, - 77, 77, 77, 77, 77, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 313, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 313, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 188, 188, 188, 188, 188, 188, 188, - 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, - 188, 188, 77, 77, 77, 77, 191, 191, 191, 191, 191, 191, 191, 191, 191, - 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, - 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, - 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 77, 77, 77, - 77, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 49, 49, 49, 49, 49, 49, 49, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 50, 50, 50, 50, 50, 50, 50, 50, 148, 148, 142, 148, + 148, 142, 148, 148, 86, 148, 160, 77, 77, 154, 154, 154, 154, 154, 154, + 154, 154, 154, 154, 77, 77, 77, 77, 77, 77, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - 315, 315, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, + 315, 315, 315, 315, 315, 315, 315, 315, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 314, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 315, 315, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 188, 188, 188, + 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, + 188, 188, 188, 188, 188, 188, 77, 77, 77, 77, 191, 191, 191, 191, 191, + 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, + 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, + 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, + 191, 191, 77, 77, 77, 77, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, @@ -3149,48 +3155,58 @@ static const unsigned short index2[] = { 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, - 316, 316, 316, 316, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 317, 317, 286, 286, 317, 286, 317, 286, 286, 317, - 317, 317, 317, 317, 317, 317, 317, 317, 317, 286, 317, 286, 317, 286, - 286, 317, 317, 286, 286, 286, 317, 317, 317, 317, 317, 317, 317, 317, + 316, 316, 316, 316, 316, 316, 316, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 318, 318, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, + 317, 317, 317, 317, 317, 317, 317, 317, 317, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 287, 287, 318, + 287, 318, 287, 287, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 287, 318, 287, 318, 287, 287, 318, 318, 287, 287, 287, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 319, 319, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 37, 37, 37, 37, 37, 37, - 37, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 37, 37, 37, 37, 37, - 77, 77, 77, 77, 77, 319, 320, 319, 321, 321, 321, 321, 321, 321, 321, - 321, 321, 242, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, - 319, 319, 90, 319, 319, 319, 319, 319, 90, 319, 90, 319, 319, 90, 319, - 319, 90, 319, 319, 319, 319, 319, 319, 319, 319, 319, 321, 136, 136, 136, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 318, 318, 318, 318, 318, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 37, 37, 37, 37, 37, 37, 37, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 37, 37, 37, 37, 37, 77, 77, 77, 77, 77, 320, 321, 320, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 243, 320, 320, 320, 320, 320, 320, + 320, 320, 320, 320, 320, 320, 320, 90, 320, 320, 320, 320, 320, 90, 320, + 90, 320, 320, 90, 320, 320, 90, 320, 320, 320, 320, 320, 320, 320, 320, + 320, 322, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 147, 147, 147, - 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 136, 136, + 136, 136, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, + 147, 147, 147, 147, 147, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, @@ -3207,28 +3223,27 @@ static const unsigned short index2[] = { 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 322, 220, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 136, 136, 136, 136, 136, + 323, 221, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 88, 88, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 88, 88, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 88, 88, 88, 88, 88, 88, 88, 88, 323, 323, 323, 323, 323, 323, - 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, - 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 324, 88, 88, 88, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 325, 325, - 325, 325, 325, 325, 325, 326, 327, 325, 77, 77, 77, 77, 77, 77, 84, 84, - 84, 84, 84, 84, 84, 91, 91, 91, 91, 91, 91, 91, 84, 84, 325, 328, 328, - 329, 329, 326, 327, 326, 327, 326, 327, 326, 327, 326, 327, 326, 327, - 326, 327, 326, 327, 284, 284, 326, 327, 325, 325, 325, 325, 329, 329, - 329, 330, 325, 330, 77, 325, 330, 325, 325, 328, 331, 332, 331, 332, 331, - 332, 333, 325, 325, 334, 335, 336, 336, 337, 77, 325, 338, 333, 325, 77, - 77, 77, 77, 136, 136, 136, 123, 136, 139, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 88, 88, 88, 88, 88, 88, 88, 88, 324, + 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, + 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, + 324, 324, 324, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 325, 88, 88, 88, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 326, 326, 326, 326, 326, 326, 326, 327, 328, 326, 77, 77, 77, + 77, 77, 77, 84, 84, 84, 84, 84, 84, 84, 91, 91, 91, 91, 91, 91, 91, 84, + 84, 326, 329, 329, 330, 330, 327, 328, 327, 328, 327, 328, 327, 328, 327, + 328, 327, 328, 327, 328, 327, 328, 285, 285, 327, 328, 326, 326, 326, + 326, 330, 330, 330, 331, 326, 331, 77, 326, 331, 326, 326, 329, 332, 333, + 332, 333, 332, 333, 334, 326, 326, 335, 336, 337, 337, 338, 77, 326, 339, + 334, 326, 77, 77, 77, 77, 136, 136, 136, 123, 136, 139, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, @@ -3238,221 +3253,221 @@ static const unsigned short index2[] = { 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 139, 139, 195, 77, 339, 339, 340, 341, 340, 339, 339, 342, - 343, 339, 344, 345, 346, 345, 345, 347, 347, 347, 347, 347, 347, 347, - 347, 347, 347, 345, 339, 348, 349, 348, 339, 339, 350, 350, 350, 350, - 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - 350, 350, 350, 350, 350, 350, 350, 350, 342, 339, 343, 351, 352, 351, - 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, - 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 342, 349, - 343, 349, 342, 343, 354, 355, 356, 354, 354, 357, 357, 357, 357, 357, - 357, 357, 357, 357, 357, 358, 357, 357, 357, 357, 357, 357, 357, 357, - 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, - 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, - 357, 357, 357, 357, 357, 357, 357, 357, 357, 359, 359, 357, 357, 357, - 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, - 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 77, - 77, 77, 357, 357, 357, 357, 357, 357, 77, 77, 357, 357, 357, 357, 357, - 357, 77, 77, 357, 357, 357, 357, 357, 357, 77, 77, 357, 357, 357, 77, 77, - 77, 341, 341, 349, 351, 360, 341, 341, 77, 361, 362, 362, 362, 362, 361, - 361, 77, 236, 236, 236, 236, 236, 236, 236, 236, 236, 363, 363, 363, 88, - 262, 323, 323, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 50, 50, 77, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 136, 136, 136, 136, 136, 136, 139, 139, 195, 77, 340, 340, 341, 342, 341, + 340, 340, 343, 344, 340, 345, 346, 347, 346, 346, 348, 348, 348, 348, + 348, 348, 348, 348, 348, 348, 346, 340, 349, 350, 349, 340, 340, 351, + 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 343, 340, 344, + 352, 353, 352, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, + 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, + 354, 343, 350, 344, 350, 343, 344, 355, 356, 357, 355, 355, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 359, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 360, 360, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, + 358, 358, 358, 77, 77, 77, 358, 358, 358, 358, 358, 358, 77, 77, 358, + 358, 358, 358, 358, 358, 77, 77, 358, 358, 358, 358, 358, 358, 77, 77, + 358, 358, 358, 77, 77, 77, 342, 342, 350, 352, 361, 342, 342, 77, 362, + 363, 363, 363, 363, 362, 362, 77, 237, 237, 237, 237, 237, 237, 237, 237, + 237, 364, 364, 364, 88, 263, 324, 324, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 50, 50, + 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 77, 77, 77, 77, 77, 86, 145, 86, 77, 77, 77, 77, 158, 158, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 86, 145, 86, 77, + 77, 77, 77, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, - 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, - 158, 77, 77, 77, 83, 83, 83, 83, 83, 83, 83, 83, 83, 364, 364, 364, 364, - 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, - 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, - 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, - 364, 364, 364, 364, 364, 364, 364, 166, 166, 166, 166, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 166, 166, 88, 83, 83, - 77, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 77, 77, 77, 88, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 158, 158, 158, 158, 158, 77, 77, 77, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, + 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, + 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, + 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 166, 166, 166, + 166, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 166, 166, 88, 83, 83, 77, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 77, 77, 77, 88, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 83, 83, 83, 83, 83, 83, 83, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 91, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 83, 83, 83, 83, 83, 83, 83, 91, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 91, 365, 365, 365, - 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, - 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 158, 158, 158, 158, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 193, 50, 50, 50, 50, 50, 50, 50, - 50, 193, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 91, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, + 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 77, 77, + 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 158, 158, + 158, 158, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 193, 50, 50, 50, 50, + 50, 50, 50, 50, 193, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 84, 84, 84, 84, 84, 77, 77, 77, 77, - 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 86, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 84, 84, 84, 84, 84, 77, + 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 86, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, - 77, 50, 50, 50, 50, 50, 50, 50, 50, 86, 193, 193, 193, 193, 193, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 86, 193, 193, 193, 193, + 193, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 77, 77, 77, 77, 77, 77, 77, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, 50, 50, 50, 50, 50, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 77, 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, 77, 77, - 77, 77, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 50, 50, 77, 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, + 77, 77, 77, 77, 77, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 77, 77, 77, 77, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 46, 46, 46, 46, 46, 77, 77, 77, 77, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, - 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, + 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 86, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 77, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 77, 46, 46, 46, 46, 46, 46, 46, 77, 46, 46, 77, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 77, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 77, 49, 49, 49, 49, 49, 49, 49, 77, 49, - 49, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 162, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 86, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 77, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 77, 46, 46, 46, 46, 46, 46, 46, 77, 46, + 46, 77, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 77, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 77, 49, 49, 49, 49, 49, 49, + 49, 77, 49, 49, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 162, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 162, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 162, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 55, 53, - 53, 53, 53, 53, 77, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 55, 53, 53, 53, 53, 53, 77, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, - 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 77, 53, 53, 53, 53, 53, 53, - 53, 53, 53, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 77, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 112, 112, 112, 112, 112, 112, 90, 90, 112, 90, 112, 112, 112, 112, 112, + 77, 77, 77, 112, 112, 112, 112, 112, 112, 90, 90, 112, 90, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 90, 112, 112, 90, - 90, 90, 112, 90, 90, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 90, 109, - 366, 366, 366, 366, 366, 366, 366, 366, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 90, 112, + 112, 90, 90, 90, 112, 90, 90, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 367, 367, 366, 366, 366, 366, 366, 366, 366, 112, 112, + 112, 90, 109, 367, 367, 367, 367, 367, 367, 367, 367, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 112, 112, 368, 368, 367, 367, 367, 367, 367, 367, 367, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 90, 90, 90, 90, 90, 90, 90, 90, 366, 366, 366, 366, 366, 366, 366, - 366, 366, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 90, 90, 90, 90, 90, 90, 90, 90, 367, 367, 367, 367, 367, + 367, 367, 367, 367, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 112, 112, 112, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 90, 112, 112, 90, 90, 90, 90, 90, 366, 366, 366, 366, 366, 112, + 112, 112, 112, 112, 90, 112, 112, 90, 90, 90, 90, 90, 367, 367, 367, 367, + 367, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 112, 112, 112, 112, 112, 112, 367, 367, 367, 367, 367, + 367, 90, 90, 90, 145, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 366, 366, 366, 366, 366, 366, 90, 90, - 90, 145, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 90, 90, - 90, 90, 90, 109, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 90, 90, 90, 90, 90, 109, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 112, 112, 112, 112, 112, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + 90, 90, 90, 90, 90, 90, 90, 90, 112, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 112, 112, 112, 90, 90, 90, 90, 367, 367, 112, 112, 367, + 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, + 367, 90, 90, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, + 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, + 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, + 367, 367, 367, 367, 367, 367, 369, 142, 142, 142, 90, 142, 142, 90, 90, + 90, 90, 90, 142, 91, 142, 84, 369, 369, 369, 369, 90, 369, 369, 369, 90, + 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, + 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, + 369, 90, 90, 84, 198, 91, 90, 90, 90, 90, 152, 367, 367, 367, 367, 367, + 367, 367, 367, 367, 90, 90, 90, 90, 90, 90, 90, 109, 109, 109, 109, 109, + 109, 109, 109, 109, 90, 90, 90, 90, 90, 90, 90, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 90, 90, 90, 90, 366, 366, 112, 112, 366, 366, 366, 366, 366, - 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 90, 90, 366, 366, - 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, - 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, - 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, - 366, 366, 368, 142, 142, 142, 90, 142, 142, 90, 90, 90, 90, 90, 142, 91, - 142, 84, 368, 368, 368, 368, 90, 368, 368, 368, 90, 368, 368, 368, 368, - 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, - 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 90, 90, 84, 198, - 91, 90, 90, 90, 90, 152, 366, 366, 366, 366, 366, 366, 366, 366, 366, 90, - 90, 90, 90, 90, 90, 90, 109, 109, 109, 109, 109, 109, 109, 109, 109, 90, - 90, 90, 90, 90, 90, 90, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 367, 367, 109, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 366, 366, 109, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, 112, 366, 366, 366, 90, 90, 90, + 367, 367, 367, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 112, 112, 112, 112, 112, 112, - 112, 112, 367, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 112, 112, 112, 112, 112, 368, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 84, 91, 90, 90, 90, 90, 366, 366, 366, 366, 366, 109, 109, - 109, 109, 109, 109, 109, 90, 90, 90, 90, 90, 90, 90, 90, 90, 112, 112, + 112, 112, 112, 112, 112, 112, 112, 112, 112, 84, 91, 90, 90, 90, 90, 367, + 367, 367, 367, 367, 109, 109, 109, 109, 109, 109, 109, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 90, 90, 90, 145, 145, - 145, 145, 145, 145, 145, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 90, 90, - 366, 366, 366, 366, 366, 366, 366, 366, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 90, 90, - 90, 90, 90, 366, 366, 366, 366, 366, 366, 366, 366, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 90, - 90, 90, 90, 90, 90, 90, 109, 109, 109, 109, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 366, 366, 366, 366, 366, 366, 366, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 112, 112, 90, 90, 90, 145, 145, 145, 145, 145, 145, 145, 112, 112, 112, + 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 112, 112, 90, 90, 367, 367, 367, 367, 367, 367, 367, 367, + 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 112, 112, 90, 90, 90, 90, 90, 367, 367, 367, 367, 367, + 367, 367, 367, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 112, 112, 112, 112, 90, 90, 90, 90, 90, 90, 90, 109, 109, + 109, 109, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 367, 367, 367, + 367, 367, 367, 367, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 369, 369, 369, 369, 369, 369, 369, 369, - 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, - 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, - 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, - 369, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 370, 370, 370, - 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - 370, 370, 370, 370, 370, 370, 90, 90, 90, 90, 90, 90, 90, 366, 366, 366, - 366, 366, 366, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, - 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, - 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 84, 84, 84, 84, - 139, 139, 139, 139, 139, 139, 139, 139, 133, 133, 133, 133, 133, 133, - 133, 133, 133, 133, 139, 139, 139, 139, 139, 139, 133, 133, 133, 133, - 133, 133, 133, 133, 133, 133, 112, 112, 112, 112, 144, 112, 369, 369, - 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, - 369, 369, 369, 369, 369, 369, 90, 90, 90, 84, 84, 84, 84, 84, 87, 144, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 90, 90, 90, 90, 90, 90, 90, 90, - 371, 371, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, + 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, + 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, + 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 90, 90, + 90, 90, 90, 90, 90, 367, 367, 367, 367, 367, 367, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 84, 84, 84, 84, 139, 139, 139, 139, 139, 139, 139, + 139, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 139, 139, 139, + 139, 139, 139, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 112, + 112, 112, 112, 144, 112, 370, 370, 370, 370, 370, 370, 370, 370, 370, + 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 90, 90, + 90, 84, 84, 84, 84, 84, 87, 144, 371, 371, 371, 371, 371, 371, 371, 371, + 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 90, + 90, 90, 90, 90, 90, 90, 90, 372, 372, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, @@ -3463,33 +3478,33 @@ static const unsigned short index2[] = { 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 372, 372, 372, 372, 372, - 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, - 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 90, 112, 112, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + 373, 373, 373, 90, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 90, 84, 84, - 107, 90, 90, 112, 112, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 139, 139, 123, 123, 123, 125, 123, 123, 139, 139, 139, 139, 139, - 139, 139, 139, 145, 88, 88, 88, 88, 88, 88, 88, 88, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 91, 91, 142, 91, 91, 91, 112, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 90, 84, 84, 107, 90, 90, 112, 112, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 139, 139, 123, 123, 123, 125, 123, 123, + 139, 147, 147, 84, 91, 91, 84, 84, 145, 88, 88, 88, 88, 88, 88, 88, 88, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 139, 91, 91, 91, 84, 91, 84, 91, + 84, 84, 84, 91, 91, 142, 91, 91, 91, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 366, 366, 366, 366, 366, 366, 366, - 366, 366, 366, 112, 90, 90, 90, 90, 90, 90, 90, 90, 123, 123, 123, 123, + 112, 112, 112, 112, 112, 112, 112, 112, 367, 367, 367, 367, 367, 367, + 367, 367, 367, 367, 112, 90, 90, 90, 90, 90, 90, 90, 90, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, - 123, 123, 123, 123, 91, 91, 84, 84, 84, 91, 84, 91, 91, 91, 91, 373, 373, - 373, 373, 118, 118, 118, 118, 118, 139, 139, 139, 139, 139, 139, 139, + 123, 123, 123, 123, 123, 91, 91, 84, 84, 84, 91, 84, 91, 91, 91, 91, 374, + 374, 374, 374, 118, 118, 118, 118, 118, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 84, 91, 84, 91, 109, 109, 109, 109, 90, 90, 90, + 139, 139, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 112, 112, 112, 84, 91, 84, 91, 109, 109, 109, 109, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 112, - 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 366, 366, 366, 366, 366, 366, 366, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 112, 112, 112, 112, 367, 367, 367, 367, 367, 367, 367, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 90, 90, 90, 90, 90, 90, 90, 90, 90, 148, 142, 148, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, @@ -3502,8 +3517,8 @@ static const unsigned short index2[] = { 142, 142, 148, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 162, 50, 162, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 162, 50, 50, 50, 50, 148, 148, 148, 142, - 142, 142, 142, 148, 148, 160, 151, 86, 86, 374, 86, 86, 86, 86, 142, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 374, 77, 77, 50, 50, 50, 50, 50, 50, + 142, 142, 142, 148, 148, 160, 151, 86, 86, 375, 86, 86, 86, 86, 142, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 375, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 77, 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, 77, 77, 77, 77, 84, 84, 84, 149, 149, 149, 149, 149, @@ -3549,7 +3564,7 @@ static const unsigned short index2[] = { 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 77, 50, 156, 148, 148, 161, 142, 142, 142, 142, 142, 77, - 156, 77, 77, 375, 77, 375, 375, 156, 148, 77, 148, 148, 160, 194, 152, + 156, 77, 77, 376, 77, 376, 376, 156, 148, 77, 148, 148, 160, 194, 152, 169, 142, 50, 86, 86, 77, 86, 86, 77, 77, 77, 77, 77, 77, 77, 77, 142, 142, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, @@ -3631,94 +3646,94 @@ static const unsigned short index2[] = { 142, 142, 142, 142, 167, 167, 142, 142, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 142, 160, 142, 142, 142, 142, 148, 50, 142, - 142, 142, 142, 86, 86, 86, 86, 86, 86, 86, 86, 152, 77, 77, 77, 77, 77, - 77, 77, 77, 149, 142, 142, 142, 142, 142, 142, 148, 148, 142, 142, 142, + 149, 149, 149, 149, 149, 149, 142, 160, 142, 142, 142, 142, 148, 199, + 142, 142, 142, 142, 86, 86, 86, 86, 86, 86, 86, 86, 152, 77, 77, 77, 77, + 77, 77, 77, 77, 149, 142, 142, 142, 142, 142, 142, 148, 148, 142, 142, + 142, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 169, 169, - 169, 169, 169, 169, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, - 142, 142, 142, 148, 142, 152, 86, 86, 86, 50, 86, 86, 86, 86, 86, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 169, + 169, 169, 169, 169, 169, 142, 142, 142, 142, 142, 142, 142, 142, 142, + 142, 142, 142, 142, 148, 142, 152, 86, 86, 86, 50, 86, 86, 86, 86, 86, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 77, - 77, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, + 77, 77, 77, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 149, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 142, 148, 142, 142, 142, 148, 142, 148, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 142, 148, 142, 142, 142, 148, 142, + 148, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 86, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 154, 154, 154, 154, 154, 154, 154, - 154, 154, 154, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 86, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 154, 154, 154, 154, 154, 154, + 154, 154, 154, 154, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 148, 142, 142, 142, 142, 142, 142, 142, 77, 142, 142, 142, - 142, 142, 142, 148, 376, 50, 86, 86, 86, 86, 86, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 158, + 50, 50, 50, 50, 148, 142, 142, 142, 142, 142, 142, 142, 77, 142, 142, + 142, 142, 142, 142, 148, 377, 50, 86, 86, 86, 86, 86, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, - 158, 158, 158, 158, 77, 77, 77, 86, 86, 50, 50, 50, 50, 50, 50, 50, 50, + 158, 158, 158, 158, 158, 77, 77, 77, 86, 86, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 77, 77, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, - 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 77, 148, 142, - 142, 142, 142, 142, 142, 142, 148, 142, 142, 148, 142, 142, 77, 77, 77, + 50, 50, 50, 50, 50, 77, 77, 142, 142, 142, 142, 142, 142, 142, 142, 142, + 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 77, 148, + 142, 142, 142, 142, 142, 142, 142, 148, 142, 142, 148, 142, 142, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, - 50, 50, 50, 50, 50, 77, 50, 50, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, + 50, 50, 50, 50, 50, 50, 77, 50, 50, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 142, 142, 142, 142, 142, 142, - 77, 77, 77, 142, 77, 142, 142, 77, 142, 142, 142, 155, 142, 160, 160, - 169, 142, 77, 77, 77, 77, 77, 77, 77, 77, 154, 154, 154, 154, 154, 154, - 154, 154, 154, 154, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 77, - 50, 50, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 148, - 148, 148, 148, 148, 77, 142, 142, 77, 148, 148, 142, 148, 160, 50, 77, - 77, 77, 77, 77, 77, 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, - 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 142, 142, 142, 142, 142, + 142, 77, 77, 77, 142, 77, 142, 142, 77, 142, 142, 142, 155, 142, 160, + 160, 169, 142, 77, 77, 77, 77, 77, 77, 77, 77, 154, 154, 154, 154, 154, + 154, 154, 154, 154, 154, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, + 77, 50, 50, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 55, 50, 50, 77, 77, 77, 77, - 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 148, 148, 148, 148, 148, 77, 142, 142, 77, 148, 148, 142, 148, 160, 50, + 77, 77, 77, 77, 77, 77, 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 154, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 55, 50, 50, 77, 77, 77, + 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, 77, 77, 77, + 77, 142, 149, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 142, 142, 148, 148, 86, 86, 77, 77, 77, 77, 77, 77, - 77, 142, 142, 169, 148, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 77, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 142, 142, 148, 148, 86, 86, 77, 77, 77, 77, 77, + 77, 77, 142, 142, 169, 148, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 77, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 148, 148, 142, 142, 142, - 142, 142, 77, 77, 77, 148, 148, 142, 194, 152, 86, 86, 86, 86, 86, 86, - 86, 86, 86, 86, 86, 86, 86, 154, 154, 154, 154, 154, 154, 154, 154, 154, - 154, 142, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 148, 148, 142, 142, + 142, 142, 142, 77, 77, 77, 148, 148, 142, 194, 152, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 154, 154, 154, 154, 154, 154, 154, 154, + 154, 154, 142, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 158, 158, 158, 158, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, - 158, 158, 158, 88, 88, 88, 88, 88, 88, 88, 88, 89, 89, 89, 89, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 86, 50, 50, 50, 50, 50, 50, 50, + 158, 158, 158, 158, 158, 88, 88, 88, 88, 88, 88, 88, 88, 89, 89, 89, 89, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 86, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 50, 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 193, 193, 193, 193, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, @@ -3726,67 +3741,85 @@ static const unsigned short index2[] = { 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, - 193, 193, 193, 193, 193, 193, 193, 193, 193, 77, 86, 86, 86, 86, 86, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, + 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 86, 86, 86, + 86, 86, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 193, 193, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 86, - 86, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 86, 86, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 213, 213, 213, 213, 213, 213, 213, 213, - 213, 213, 213, 213, 213, 213, 213, 213, 142, 50, 50, 50, 50, 50, 50, 142, - 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 214, 214, + 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, + 142, 50, 50, 50, 50, 50, 50, 142, 142, 142, 142, 142, 142, 142, 142, 142, + 142, 142, 142, 142, 142, 142, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 161, 161, 161, 377, 377, 377, 377, 377, 377, 377, 377, 161, 148, 148, - 148, 142, 142, 160, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 161, 161, 161, 378, 378, 378, 378, + 378, 378, 378, 378, 161, 148, 148, 148, 142, 142, 160, 154, 154, 154, + 154, 154, 154, 154, 154, 154, 154, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, 77, - 77, 86, 86, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 154, 154, 154, 154, + 154, 154, 154, 154, 154, 154, 77, 77, 77, 77, 86, 86, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 154, 154, 154, 154, 154, 154, - 154, 154, 154, 154, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 77, 77, 198, 198, 198, 198, 198, 86, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, 77, + 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 198, + 198, 198, 198, 198, 86, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 84, 84, 84, 84, 84, 84, 84, 86, 86, 86, 86, 86, 83, 83, 83, 83, 55, 55, - 55, 55, 86, 83, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 154, 154, 154, - 154, 154, 154, 154, 154, 154, 154, 77, 158, 158, 158, 158, 158, 158, 158, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 84, 84, 84, 84, 84, 84, 84, 86, + 86, 86, 86, 86, 83, 83, 83, 83, 55, 55, 55, 55, 86, 83, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 77, 158, 158, 158, 158, 158, 158, 158, 77, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, + 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, @@ -3795,105 +3828,113 @@ static const unsigned short index2[] = { 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 55, 55, 55, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 188, 50, 50, 50, 189, 378, 379, 379, 55, 55, 86, 86, - 86, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 55, 55, + 55, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 188, 50, 50, + 50, 189, 379, 380, 380, 55, 55, 86, 86, 86, 154, 154, 154, 154, 154, 154, + 154, 154, 154, 154, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, - 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 86, 86, 86, 86, - 77, 77, 77, 77, 77, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 77, 77, 49, 49, 49, 49, + 77, 77, 77, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 158, 158, 158, 158, + 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, + 158, 158, 158, 158, 158, 86, 86, 86, 86, 77, 77, 77, 77, 77, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 77, 77, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, - 142, 50, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, + 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 142, 50, 148, 148, 148, 148, 148, + 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, - 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 77, - 77, 77, 77, 77, 77, 77, 142, 142, 142, 142, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 148, 148, 148, 148, 148, 148, 148, 148, 77, 77, 77, 77, 77, 77, 77, 142, + 142, 142, 142, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 286, 286, 285, 286, 381, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 382, 382, 286, 286, 288, 288, 288, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 285, 285, - 284, 285, 380, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 381, 381, 285, - 285, 287, 287, 287, 77, 77, 77, 77, 77, 77, 77, 77, 77, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 286, + 286, 286, 286, 77, 286, 286, 286, 286, 286, 286, 286, 77, 286, 286, 77, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 306, 306, 306, 306, 287, 287, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 287, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 285, 285, - 285, 285, 77, 285, 285, 285, 285, 285, 285, 285, 77, 285, 285, 77, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 286, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 286, 286, - 286, 77, 77, 286, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 286, 286, 286, 286, 77, 77, 77, 77, 77, 77, 77, 77, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 77, 77, 77, 77, 50, 50, + 77, 287, 287, 287, 77, 77, 287, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 287, 287, 287, 287, 287, 77, 77, 77, 77, 77, 77, 77, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 77, 77, + 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, - 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, 77, 77, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 83, 142, 198, 86, 195, 195, 195, - 195, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 50, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 77, 77, 77, + 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, 83, 142, 198, 86, + 195, 195, 195, 195, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 77, 77, 77, 77, 77, 77, 77, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, @@ -3905,215 +3946,230 @@ static const unsigned short index2[] = { 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 382, 382, 382, 382, 382, 382, 382, 382, 382, 382, 382, 382, 382, 382, - 382, 382, 382, 382, 382, 382, 382, 382, 382, 382, 382, 382, 383, 383, - 383, 383, 383, 383, 383, 383, 383, 383, 88, 88, 88, 77, 77, 77, 88, 88, + 88, 88, 88, 88, 88, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, + 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, + 383, 383, 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, 88, 88, 88, + 77, 77, 77, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 77, 77, 77, 77, - 77, 77, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 81, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 88, 77, 77, 77, 77, 77, 77, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 77, 88, 88, 88, 77, 77, + 77, 77, 77, 77, 77, 77, 265, 265, 265, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 77, 77, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, + 142, 142, 142, 142, 142, 142, 142, 142, 77, 77, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, - 142, 142, 142, 142, 77, 77, 142, 142, 142, 142, 142, 142, 142, 142, 142, - 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 142, 142, 142, 142, 77, 77, 77, 77, 77, 77, 77, 77, 77, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, 83, 77, 77, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 91, 91, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 384, 384, 384, 384, 384, 384, - 384, 385, 385, 198, 198, 198, 83, 83, 83, 386, 385, 385, 385, 385, 385, - 195, 195, 195, 195, 195, 195, 195, 195, 91, 91, 91, 91, 91, 91, 91, 91, - 83, 83, 84, 84, 84, 84, 84, 91, 91, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 84, 84, 84, 84, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 384, 384, 384, 384, 384, 384, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 385, 385, + 385, 385, 385, 385, 385, 386, 386, 198, 198, 198, 83, 83, 83, 387, 386, + 386, 386, 386, 386, 195, 195, 195, 195, 195, 195, 195, 195, 91, 91, 91, + 91, 91, 91, 91, 91, 83, 83, 84, 84, 84, 84, 84, 91, 91, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 88, 88, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 83, 83, 83, 83, 83, 83, 83, 83, 84, 84, 84, 84, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 385, 385, 385, 385, 385, 385, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 88, 88, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 84, 84, 84, 88, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 84, + 84, 84, 88, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 386, 386, 386, 83, + 83, 83, 83, 83, 83, 83, 83, 198, 198, 83, 83, 386, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 386, 386, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 158, 158, 158, 158, 158, - 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, - 158, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 158, 158, 158, 158, - 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, - 158, 158, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 387, 387, 387, 387, 387, 387, 387, 387, - 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, - 387, 158, 158, 77, 77, 77, 77, 77, 77, 77, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 37, - 37, 37, 37, 37, 37, 37, 77, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 51, 77, 51, 51, 77, 77, 51, 77, 77, 51, 51, 77, 77, - 51, 51, 51, 51, 77, 51, 51, 51, 51, 51, 51, 51, 51, 37, 37, 37, 37, 77, - 37, 77, 37, 37, 37, 37, 37, 37, 37, 77, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 51, 51, 77, 51, 51, 51, 51, 77, 77, 51, 51, 51, 51, 51, 51, 51, 51, - 77, 51, 51, 51, 51, 51, 51, 51, 77, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 51, - 51, 77, 51, 51, 51, 51, 77, 51, 51, 51, 51, 51, 77, 51, 77, 77, 77, 51, - 51, 51, 51, 51, 51, 51, 77, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 51, 51, 51, + 77, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, + 158, 158, 158, 158, 158, 158, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, + 158, 158, 158, 158, 158, 158, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 77, 77, 77, 77, 77, 77, 77, 77, 77, 388, 388, 388, 388, + 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, + 388, 388, 388, 388, 388, 158, 158, 77, 77, 77, 77, 77, 77, 77, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 37, 37, 37, 37, 37, 37, 37, 77, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 37, + 51, 51, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 51, 77, 51, 51, 77, 77, 51, 77, + 77, 51, 51, 77, 77, 51, 51, 51, 51, 77, 51, 51, 51, 51, 51, 51, 51, 51, + 37, 37, 37, 37, 77, 37, 77, 37, 37, 37, 37, 37, 37, 37, 77, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 51, 51, 77, 51, 51, 51, 51, 77, 77, 51, 51, 51, + 51, 51, 51, 51, 51, 77, 51, 51, 51, 51, 51, 51, 51, 77, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 51, 51, 77, 51, 51, 51, 51, 77, 51, 51, 51, 51, 51, 77, + 51, 77, 77, 77, 51, 51, 51, 51, 51, 51, 51, 77, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 77, 77, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 243, 37, 37, 37, + 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 256, 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 243, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 256, 37, 37, 37, 37, 37, 37, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 243, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 256, 37, 37, 37, 37, 37, - 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 243, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 256, 37, - 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 243, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 256, 37, 37, 37, 37, 37, 37, 51, 37, 77, 77, 383, 383, 383, 383, - 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, - 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, - 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, - 383, 383, 383, 383, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 77, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 244, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 257, 37, 37, 37, 37, 37, 37, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 244, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 257, 37, 37, 37, 37, + 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 244, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 257, + 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 244, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 257, 37, 37, 37, 37, 37, 37, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 244, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 257, 37, 37, 37, 37, 37, 37, 51, 37, 77, 77, + 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, + 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, + 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, 384, + 384, 384, 384, 384, 384, 384, 384, 384, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, - 142, 142, 142, 83, 83, 83, 83, 142, 142, 142, 142, 142, 142, 142, 142, + 142, 142, 142, 142, 142, 142, 142, 83, 83, 83, 83, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, - 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 83, - 83, 83, 83, 83, 83, 83, 83, 142, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 142, 83, 83, 86, 86, 86, 86, 86, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 142, 142, 142, 142, 142, 77, 142, - 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 77, + 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, + 142, 142, 142, 142, 83, 83, 83, 83, 83, 83, 83, 83, 142, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 142, 83, 83, 86, 86, 86, 86, 86, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 142, 142, + 142, 142, 142, 77, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, + 142, 142, 142, 142, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 81, 81, 81, 265, 265, + 265, 265, 265, 265, 265, 81, 81, 81, 81, 81, 81, 265, 81, 81, 81, 81, 81, + 81, 265, 265, 81, 81, 265, 81, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 77, 77, 77, 77, 77, 77, 49, 49, 49, 49, 49, 49, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 46, 49, 49, 49, 49, 49, 49, 49, 46, + 49, 46, 49, 49, 46, 49, 49, 49, 46, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 46, 49, 46, 49, 46, + 49, 46, 49, 49, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, 49, 46, + 49, 50, 50, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 49, + 49, 49, 49, 49, 37, 49, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 84, 84, 84, 84, 84, 84, 84, 77, 84, - 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 77, 77, - 84, 84, 84, 84, 84, 84, 84, 77, 84, 84, 77, 84, 84, 84, 84, 84, 77, 77, - 77, 77, 77, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, - 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 77, 77, 77, 77, 77, 77, 77, + 53, 53, 53, 84, 84, 84, 84, 84, 84, 84, 77, 84, 84, 84, 84, 84, 84, 84, + 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 77, 77, 84, 84, 84, 84, 84, 84, + 84, 77, 84, 84, 77, 84, 84, 84, 84, 84, 77, 77, 77, 77, 77, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 84, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 84, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 77, 77, 77, 84, 84, 84, 84, 84, 84, 84, 55, 55, 55, 55, - 55, 55, 55, 77, 77, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, - 77, 77, 77, 50, 83, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 77, + 77, 84, 84, 84, 84, 84, 84, 84, 55, 55, 55, 55, 55, 55, 55, 77, 77, 154, + 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, 77, 77, 50, 83, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 84, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 84, - 84, 84, 84, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, 77, - 77, 77, 89, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 50, 50, 50, 84, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 84, 84, 84, 84, 154, 154, + 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, 77, 77, 77, 89, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 55, 201, 201, 91, 84, 154, 154, 154, 154, 154, 154, 154, 154, - 154, 154, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 55, 202, 202, + 91, 84, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 84, 91, 50, 154, 154, 154, 154, - 154, 154, 154, 154, 154, 154, 77, 77, 77, 77, 86, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 84, 91, 50, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 154, 77, 77, 77, 77, 86, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, - 50, 50, 50, 84, 50, 50, 84, 50, 50, 50, 50, 50, 50, 50, 84, 84, 50, 50, - 50, 50, 50, 84, 77, 77, 77, 77, 77, 77, 77, 77, 50, 55, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 50, 50, 50, 84, 50, 50, + 84, 50, 50, 50, 50, 50, 50, 50, 84, 84, 50, 50, 50, 50, 50, 84, 77, 77, + 77, 77, 77, 77, 77, 77, 50, 55, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 50, 50, 50, 50, 50, 50, 50, 77, 50, 50, 50, 50, 77, 50, 50, 77, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 112, 112, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 50, 50, 50, 50, + 50, 50, 50, 77, 50, 50, 50, 50, 77, 50, 50, 77, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 77, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, @@ -4127,18 +4183,17 @@ static const unsigned short index2[] = { 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 90, 90, - 366, 366, 366, 366, 366, 366, 366, 366, 366, 91, 91, 91, 91, 91, 91, 91, + 112, 112, 112, 112, 112, 112, 112, 112, 112, 90, 90, 367, 367, 367, 367, + 367, 367, 367, 367, 367, 91, 91, 91, 91, 91, 91, 91, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, - 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, - 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - 370, 370, 84, 84, 84, 84, 84, 84, 155, 144, 90, 90, 90, 90, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 90, 90, 90, 90, 109, 109, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 370, 370, 370, 370, 370, 370, 371, 371, 371, 371, 371, 371, 371, 371, + 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, + 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 84, 84, 84, + 84, 84, 84, 155, 144, 90, 90, 90, 90, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 90, 90, 90, 90, 109, 109, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, @@ -4153,352 +4208,361 @@ static const unsigned short index2[] = { 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 139, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, - 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, - 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, - 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, - 373, 373, 373, 373, 138, 373, 373, 373, 116, 373, 373, 373, 373, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 139, 374, 374, 374, 374, + 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, + 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, + 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, + 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 138, + 374, 374, 374, 116, 374, 374, 374, 374, 139, 139, 139, 139, 139, 139, + 139, 139, 139, 139, 139, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 139, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, - 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, - 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, - 373, 373, 373, 373, 373, 373, 373, 138, 373, 373, 373, 373, 373, 373, - 373, 373, 373, 373, 373, 373, 373, 373, 373, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 90, 90, + 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 139, 374, + 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, + 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, + 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, + 374, 374, 138, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, + 374, 374, 374, 374, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + 139, 139, 139, 139, 139, 139, 139, 139, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 136, 136, 136, 136, 139, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 139, 136, - 136, 139, 136, 139, 139, 136, 139, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 139, 136, 136, 136, 136, 139, 136, 139, 136, 139, 139, - 139, 139, 139, 139, 136, 139, 139, 139, 139, 136, 139, 136, 139, 136, - 139, 136, 136, 136, 139, 136, 136, 139, 136, 139, 139, 136, 139, 136, - 139, 136, 139, 136, 139, 136, 139, 136, 136, 139, 136, 139, 139, 136, - 136, 136, 136, 139, 136, 136, 136, 136, 136, 136, 136, 139, 136, 136, - 136, 136, 139, 136, 136, 136, 136, 139, 136, 139, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 139, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 139, 139, 139, 139, - 139, 136, 136, 136, 139, 136, 136, 136, 136, 136, 139, 136, 136, 136, + 90, 90, 90, 90, 136, 136, 136, 136, 139, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 139, 136, 136, 139, 136, 139, 139, + 136, 139, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 139, 136, + 136, 136, 136, 139, 136, 139, 136, 139, 139, 139, 139, 139, 139, 136, + 139, 139, 139, 139, 136, 139, 136, 139, 136, 139, 136, 136, 136, 139, + 136, 136, 139, 136, 139, 139, 136, 139, 136, 139, 136, 139, 136, 139, + 136, 139, 136, 136, 139, 136, 139, 139, 136, 136, 136, 136, 139, 136, + 136, 136, 136, 136, 136, 136, 139, 136, 136, 136, 136, 139, 136, 136, + 136, 136, 139, 136, 139, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 139, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 139, 139, 139, 139, 139, 136, 136, 136, 139, + 136, 136, 136, 136, 136, 139, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 81, 81, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 88, 88, 88, 88, - 271, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 388, 388, 388, 388, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 139, 139, 139, 139, 139, 81, 81, 139, 139, 139, 139, 139, 139, 139, 139, + 139, 139, 139, 139, 139, 139, 88, 88, 88, 88, 272, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 389, 389, + 389, 389, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 388, 388, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 388, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 271, 388, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 389, 389, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 389, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 272, 389, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 166, - 166, 88, 88, 88, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 382, 88, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, 389, 389, 389, 389, + 88, 88, 88, 88, 88, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 36, + 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 166, 166, 88, 88, 88, 275, 275, + 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, + 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, + 383, 88, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, + 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, + 275, 275, 275, 275, 275, 390, 390, 390, 390, 390, 390, 390, 390, 390, + 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, + 390, 390, 390, 251, 251, 251, 88, 88, 88, 391, 391, 390, 390, 390, 390, + 390, 390, 390, 390, 390, 390, 390, 390, 391, 391, 390, 390, 390, 390, + 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, 392, 390, 275, 392, + 392, 392, 392, 392, 392, 392, 392, 392, 392, 390, 390, 390, 390, 390, + 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, 88, 307, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, - 389, 389, 389, 389, 389, 389, 389, 389, 250, 250, 250, 88, 88, 88, 390, - 390, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 390, - 390, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, - 389, 391, 389, 274, 391, 391, 391, 391, 391, 391, 391, 391, 391, 391, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, - 389, 389, 389, 389, 88, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 392, 392, 392, 392, 392, 392, 392, 392, 392, 392, - 392, 392, 392, 392, 392, 392, 392, 392, 392, 392, 392, 392, 392, 392, - 392, 392, 308, 311, 311, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 311, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 308, 311, 308, 308, 311, 311, 311, 311, - 311, 311, 311, 311, 311, 308, 388, 388, 388, 388, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 388, 388, 388, 388, 388, 388, 388, 311, 311, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 279, 279, 279, 279, 279, 279, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 28, 88, 88, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 28, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 28, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 88, 88, 28, 28, 88, 28, 28, - 28, 88, 88, 28, 28, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 28, 28, 28, 28, 271, 271, 271, 271, 271, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 88, 88, 28, 271, - 28, 88, 28, 271, 271, 271, 393, 393, 393, 393, 393, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 28, 271, 28, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 28, 88, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 28, 28, - 271, 271, 271, 271, 88, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 88, - 88, 88, 88, 88, 88, 88, 28, 28, 88, 88, 28, 28, 28, 28, 28, 28, 28, 271, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 28, 88, 88, 28, 28, 28, - 28, 88, 88, 28, 88, 88, 88, 88, 271, 271, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 271, 28, 88, 88, 28, 88, 88, 88, 88, 88, 88, 88, 88, - 28, 28, 88, 88, 88, 88, 88, 88, 88, 88, 88, 28, 88, 88, 88, 88, 88, 28, - 28, 28, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 28, 28, 28, 88, - 88, 88, 88, 88, 88, 88, 88, 28, 28, 28, 88, 88, 28, 88, 28, 88, 88, 88, - 88, 28, 88, 88, 88, 88, 88, 88, 28, 88, 88, 88, 28, 88, 88, 88, 88, 88, - 88, 28, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 393, + 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, + 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, 309, 312, 312, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 312, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 312, 309, 309, 312, 312, 312, 312, 312, 312, 312, 312, 312, + 309, 389, 389, 389, 389, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 389, 389, 389, 389, 389, 389, 389, 312, 312, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 280, 280, 280, 280, 280, + 280, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 28, 88, 88, 28, 28, 28, 28, 28, 28, 28, 28, + 28, 272, 272, 272, 272, 272, 272, 272, 272, 272, 28, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 28, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 88, 88, 28, 28, 88, 28, 28, 28, 88, 88, 28, 28, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 28, + 28, 28, 28, 272, 272, 272, 272, 272, 28, 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 88, 88, 28, 272, 28, 88, 28, 272, 272, 272, 394, + 394, 394, 394, 394, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 28, 272, 28, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 28, 88, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 28, 28, 272, 272, 272, 272, 88, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 88, 88, 88, 88, 88, 88, 88, 28, + 28, 88, 88, 28, 28, 28, 28, 28, 28, 28, 272, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 28, 88, 88, 28, 28, 28, 28, 88, 88, 28, 88, 88, 88, + 88, 272, 272, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 272, + 28, 88, 88, 28, 88, 88, 88, 88, 88, 88, 88, 88, 28, 28, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 28, 88, 88, 88, 88, 88, 28, 28, 28, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 28, 28, 28, 88, 88, 88, 88, 88, 88, 88, + 88, 28, 28, 28, 88, 88, 28, 88, 28, 88, 88, 88, 88, 28, 88, 88, 88, 88, + 88, 88, 28, 88, 88, 88, 28, 88, 88, 88, 88, 88, 88, 28, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 88, 88, 88, 88, - 88, 28, 271, 28, 28, 28, 271, 271, 271, 88, 88, 271, 271, 271, 271, 388, - 388, 388, 271, 271, 271, 271, 28, 28, 28, 28, 28, 28, 88, 88, 88, 28, 88, - 271, 271, 388, 388, 388, 28, 88, 88, 28, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 388, 388, 388, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 88, 88, 88, 88, 88, 28, 272, 28, 28, + 28, 272, 272, 272, 88, 88, 272, 272, 272, 272, 272, 389, 389, 272, 272, + 272, 272, 28, 28, 28, 28, 28, 28, 88, 88, 88, 28, 88, 272, 272, 389, 389, + 389, 28, 88, 88, 28, 272, 272, 272, 272, 272, 272, 272, 272, 272, 389, + 389, 389, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 388, 388, 388, 388, 388, 388, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 388, 388, 388, 388, 271, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 388, 388, 388, 388, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 307, 88, 389, 389, 389, 389, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 389, 389, 389, 389, 272, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 389, 389, 389, 389, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 388, 388, 388, 388, 388, 388, 388, 388, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 388, 388, 388, 388, 388, 388, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 388, 388, - 388, 388, 388, 388, 388, 388, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 389, 389, 389, 389, 389, 389, + 389, 389, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 389, 389, 389, 389, + 389, 389, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 388, 388, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 388, 388, - 388, 388, 88, 88, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 81, 81, 81, 81, 81, 81, 81, 81, 81, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 88, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 88, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 389, 389, 389, 389, 389, 389, 389, 389, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 389, 389, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 389, 389, 389, 389, 88, 88, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 88, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 88, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 388, 388, 388, 388, 388, 388, 388, 388, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 388, 388, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 388, 388, 388, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 388, 388, 388, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, 388, - 271, 388, 388, 388, 388, 271, 271, 271, 271, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 388, 388, 271, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 388, 388, 388, 388, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 388, 388, 388, 388, 388, 388, 388, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 77, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 389, 389, 389, 389, + 389, 389, 389, 389, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 389, 389, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 389, 389, 389, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 389, 272, 389, 389, 389, 272, 272, 272, 272, + 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 389, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 389, 389, 389, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + 272, 389, 389, 389, 389, 389, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 77, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 383, 383, 383, 383, 383, 383, 383, 383, 383, 383, 88, 77, 77, - 77, 77, 77, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 323, 323, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 318, 318, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 318, 318, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - 317, 317, 317, 317, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 384, 384, 384, 384, 384, 384, + 384, 384, 384, 384, 88, 77, 77, 77, 77, 77, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 324, 324, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 319, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 319, 319, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 323, 323, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 318, 318, 318, - 318, 318, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - 286, 286, 286, 286, 318, 318, 318, 318, 318, 318, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 323, 323, 236, 195, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, - 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, - 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, - 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, - 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, - 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, - 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 324, 324, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 319, 319, 319, 319, 319, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 319, 319, 319, 319, + 319, 319, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, + 319, 319, 319, 319, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 324, 324, 237, 195, 237, 237, 237, 237, 237, 237, + 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 395, 395, 395, 395, + 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, + 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, + 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, + 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, + 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, + 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, + 395, 395, 395, 395, 395, 395, 395, 395, 237, 237, 237, 237, 237, 237, + 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, @@ -4511,17 +4575,18 @@ static const unsigned short index2[] = { 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 236, 236, 236, 236, 236, 236, 236, 236, 236, - 236, 236, 236, 236, 236, 236, 236, 316, 316, 316, 316, 316, 316, 316, - 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, - 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, - 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, - 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, - 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, - 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, - 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, - 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, - 316, 316, 316, 316, 316, 316, 316, 323, 323, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + 237, 237, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, + 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, + 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, + 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, + 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, + 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, + 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, + 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, + 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, + 317, 317, 324, 324, }; /* decomposition data */ @@ -4605,864 +4670,876 @@ static const unsigned int decomp_data[] = { 776, 512, 1256, 776, 512, 1257, 776, 512, 1069, 776, 512, 1101, 776, 512, 1059, 772, 512, 1091, 772, 512, 1059, 776, 512, 1091, 776, 512, 1059, 779, 512, 1091, 779, 512, 1063, 776, 512, 1095, 776, 512, 1067, 776, 512, - 1099, 776, 514, 1381, 1410, 512, 1575, 1619, 512, 1575, 1620, 512, 1608, - 1620, 512, 1575, 1621, 512, 1610, 1620, 514, 1575, 1652, 514, 1608, 1652, - 514, 1735, 1652, 514, 1610, 1652, 512, 1749, 1620, 512, 1729, 1620, 512, - 1746, 1620, 512, 2344, 2364, 512, 2352, 2364, 512, 2355, 2364, 512, 2325, - 2364, 512, 2326, 2364, 512, 2327, 2364, 512, 2332, 2364, 512, 2337, 2364, - 512, 2338, 2364, 512, 2347, 2364, 512, 2351, 2364, 512, 2503, 2494, 512, - 2503, 2519, 512, 2465, 2492, 512, 2466, 2492, 512, 2479, 2492, 512, 2610, - 2620, 512, 2616, 2620, 512, 2582, 2620, 512, 2583, 2620, 512, 2588, 2620, - 512, 2603, 2620, 512, 2887, 2902, 512, 2887, 2878, 512, 2887, 2903, 512, - 2849, 2876, 512, 2850, 2876, 512, 2962, 3031, 512, 3014, 3006, 512, 3015, - 3006, 512, 3014, 3031, 512, 3142, 3158, 512, 3263, 3285, 512, 3270, 3285, - 512, 3270, 3286, 512, 3270, 3266, 512, 3274, 3285, 512, 3398, 3390, 512, - 3399, 3390, 512, 3398, 3415, 512, 3545, 3530, 512, 3545, 3535, 512, 3548, - 3530, 512, 3545, 3551, 514, 3661, 3634, 514, 3789, 3762, 514, 3755, 3737, - 514, 3755, 3745, 257, 3851, 512, 3906, 4023, 512, 3916, 4023, 512, 3921, - 4023, 512, 3926, 4023, 512, 3931, 4023, 512, 3904, 4021, 512, 3953, 3954, - 512, 3953, 3956, 512, 4018, 3968, 514, 4018, 3969, 512, 4019, 3968, 514, - 4019, 3969, 512, 3953, 3968, 512, 3986, 4023, 512, 3996, 4023, 512, 4001, - 4023, 512, 4006, 4023, 512, 4011, 4023, 512, 3984, 4021, 512, 4133, 4142, - 259, 4316, 512, 6917, 6965, 512, 6919, 6965, 512, 6921, 6965, 512, 6923, - 6965, 512, 6925, 6965, 512, 6929, 6965, 512, 6970, 6965, 512, 6972, 6965, - 512, 6974, 6965, 512, 6975, 6965, 512, 6978, 6965, 259, 65, 259, 198, - 259, 66, 259, 68, 259, 69, 259, 398, 259, 71, 259, 72, 259, 73, 259, 74, - 259, 75, 259, 76, 259, 77, 259, 78, 259, 79, 259, 546, 259, 80, 259, 82, - 259, 84, 259, 85, 259, 87, 259, 592, 259, 593, 259, 7426, 259, 98, 259, - 100, 259, 101, 259, 601, 259, 603, 259, 604, 259, 103, 259, 107, 259, - 109, 259, 331, 259, 596, 259, 7446, 259, 7447, 259, 112, 259, 116, 259, - 117, 259, 7453, 259, 623, 259, 118, 259, 7461, 259, 946, 259, 947, 259, - 948, 259, 966, 259, 967, 261, 105, 261, 114, 261, 117, 261, 118, 261, - 946, 261, 947, 261, 961, 261, 966, 261, 967, 259, 1085, 259, 594, 259, - 99, 259, 597, 259, 240, 259, 102, 259, 607, 259, 609, 259, 613, 259, 616, - 259, 617, 259, 618, 259, 7547, 259, 669, 259, 621, 259, 7557, 259, 671, - 259, 625, 259, 624, 259, 626, 259, 627, 259, 628, 259, 629, 259, 632, - 259, 642, 259, 643, 259, 427, 259, 649, 259, 650, 259, 7452, 259, 651, - 259, 652, 259, 122, 259, 656, 259, 657, 259, 658, 259, 952, 512, 65, 805, - 512, 97, 805, 512, 66, 775, 512, 98, 775, 512, 66, 803, 512, 98, 803, - 512, 66, 817, 512, 98, 817, 512, 199, 769, 512, 231, 769, 512, 68, 775, - 512, 100, 775, 512, 68, 803, 512, 100, 803, 512, 68, 817, 512, 100, 817, - 512, 68, 807, 512, 100, 807, 512, 68, 813, 512, 100, 813, 512, 274, 768, - 512, 275, 768, 512, 274, 769, 512, 275, 769, 512, 69, 813, 512, 101, 813, - 512, 69, 816, 512, 101, 816, 512, 552, 774, 512, 553, 774, 512, 70, 775, - 512, 102, 775, 512, 71, 772, 512, 103, 772, 512, 72, 775, 512, 104, 775, - 512, 72, 803, 512, 104, 803, 512, 72, 776, 512, 104, 776, 512, 72, 807, - 512, 104, 807, 512, 72, 814, 512, 104, 814, 512, 73, 816, 512, 105, 816, - 512, 207, 769, 512, 239, 769, 512, 75, 769, 512, 107, 769, 512, 75, 803, - 512, 107, 803, 512, 75, 817, 512, 107, 817, 512, 76, 803, 512, 108, 803, - 512, 7734, 772, 512, 7735, 772, 512, 76, 817, 512, 108, 817, 512, 76, - 813, 512, 108, 813, 512, 77, 769, 512, 109, 769, 512, 77, 775, 512, 109, - 775, 512, 77, 803, 512, 109, 803, 512, 78, 775, 512, 110, 775, 512, 78, - 803, 512, 110, 803, 512, 78, 817, 512, 110, 817, 512, 78, 813, 512, 110, - 813, 512, 213, 769, 512, 245, 769, 512, 213, 776, 512, 245, 776, 512, - 332, 768, 512, 333, 768, 512, 332, 769, 512, 333, 769, 512, 80, 769, 512, - 112, 769, 512, 80, 775, 512, 112, 775, 512, 82, 775, 512, 114, 775, 512, - 82, 803, 512, 114, 803, 512, 7770, 772, 512, 7771, 772, 512, 82, 817, - 512, 114, 817, 512, 83, 775, 512, 115, 775, 512, 83, 803, 512, 115, 803, - 512, 346, 775, 512, 347, 775, 512, 352, 775, 512, 353, 775, 512, 7778, - 775, 512, 7779, 775, 512, 84, 775, 512, 116, 775, 512, 84, 803, 512, 116, - 803, 512, 84, 817, 512, 116, 817, 512, 84, 813, 512, 116, 813, 512, 85, - 804, 512, 117, 804, 512, 85, 816, 512, 117, 816, 512, 85, 813, 512, 117, - 813, 512, 360, 769, 512, 361, 769, 512, 362, 776, 512, 363, 776, 512, 86, - 771, 512, 118, 771, 512, 86, 803, 512, 118, 803, 512, 87, 768, 512, 119, - 768, 512, 87, 769, 512, 119, 769, 512, 87, 776, 512, 119, 776, 512, 87, - 775, 512, 119, 775, 512, 87, 803, 512, 119, 803, 512, 88, 775, 512, 120, - 775, 512, 88, 776, 512, 120, 776, 512, 89, 775, 512, 121, 775, 512, 90, - 770, 512, 122, 770, 512, 90, 803, 512, 122, 803, 512, 90, 817, 512, 122, - 817, 512, 104, 817, 512, 116, 776, 512, 119, 778, 512, 121, 778, 514, 97, - 702, 512, 383, 775, 512, 65, 803, 512, 97, 803, 512, 65, 777, 512, 97, - 777, 512, 194, 769, 512, 226, 769, 512, 194, 768, 512, 226, 768, 512, - 194, 777, 512, 226, 777, 512, 194, 771, 512, 226, 771, 512, 7840, 770, - 512, 7841, 770, 512, 258, 769, 512, 259, 769, 512, 258, 768, 512, 259, - 768, 512, 258, 777, 512, 259, 777, 512, 258, 771, 512, 259, 771, 512, - 7840, 774, 512, 7841, 774, 512, 69, 803, 512, 101, 803, 512, 69, 777, - 512, 101, 777, 512, 69, 771, 512, 101, 771, 512, 202, 769, 512, 234, 769, - 512, 202, 768, 512, 234, 768, 512, 202, 777, 512, 234, 777, 512, 202, - 771, 512, 234, 771, 512, 7864, 770, 512, 7865, 770, 512, 73, 777, 512, - 105, 777, 512, 73, 803, 512, 105, 803, 512, 79, 803, 512, 111, 803, 512, - 79, 777, 512, 111, 777, 512, 212, 769, 512, 244, 769, 512, 212, 768, 512, - 244, 768, 512, 212, 777, 512, 244, 777, 512, 212, 771, 512, 244, 771, - 512, 7884, 770, 512, 7885, 770, 512, 416, 769, 512, 417, 769, 512, 416, - 768, 512, 417, 768, 512, 416, 777, 512, 417, 777, 512, 416, 771, 512, - 417, 771, 512, 416, 803, 512, 417, 803, 512, 85, 803, 512, 117, 803, 512, - 85, 777, 512, 117, 777, 512, 431, 769, 512, 432, 769, 512, 431, 768, 512, - 432, 768, 512, 431, 777, 512, 432, 777, 512, 431, 771, 512, 432, 771, - 512, 431, 803, 512, 432, 803, 512, 89, 768, 512, 121, 768, 512, 89, 803, - 512, 121, 803, 512, 89, 777, 512, 121, 777, 512, 89, 771, 512, 121, 771, - 512, 945, 787, 512, 945, 788, 512, 7936, 768, 512, 7937, 768, 512, 7936, - 769, 512, 7937, 769, 512, 7936, 834, 512, 7937, 834, 512, 913, 787, 512, - 913, 788, 512, 7944, 768, 512, 7945, 768, 512, 7944, 769, 512, 7945, 769, - 512, 7944, 834, 512, 7945, 834, 512, 949, 787, 512, 949, 788, 512, 7952, - 768, 512, 7953, 768, 512, 7952, 769, 512, 7953, 769, 512, 917, 787, 512, - 917, 788, 512, 7960, 768, 512, 7961, 768, 512, 7960, 769, 512, 7961, 769, - 512, 951, 787, 512, 951, 788, 512, 7968, 768, 512, 7969, 768, 512, 7968, - 769, 512, 7969, 769, 512, 7968, 834, 512, 7969, 834, 512, 919, 787, 512, - 919, 788, 512, 7976, 768, 512, 7977, 768, 512, 7976, 769, 512, 7977, 769, - 512, 7976, 834, 512, 7977, 834, 512, 953, 787, 512, 953, 788, 512, 7984, - 768, 512, 7985, 768, 512, 7984, 769, 512, 7985, 769, 512, 7984, 834, 512, - 7985, 834, 512, 921, 787, 512, 921, 788, 512, 7992, 768, 512, 7993, 768, - 512, 7992, 769, 512, 7993, 769, 512, 7992, 834, 512, 7993, 834, 512, 959, - 787, 512, 959, 788, 512, 8000, 768, 512, 8001, 768, 512, 8000, 769, 512, - 8001, 769, 512, 927, 787, 512, 927, 788, 512, 8008, 768, 512, 8009, 768, - 512, 8008, 769, 512, 8009, 769, 512, 965, 787, 512, 965, 788, 512, 8016, - 768, 512, 8017, 768, 512, 8016, 769, 512, 8017, 769, 512, 8016, 834, 512, - 8017, 834, 512, 933, 788, 512, 8025, 768, 512, 8025, 769, 512, 8025, 834, - 512, 969, 787, 512, 969, 788, 512, 8032, 768, 512, 8033, 768, 512, 8032, - 769, 512, 8033, 769, 512, 8032, 834, 512, 8033, 834, 512, 937, 787, 512, - 937, 788, 512, 8040, 768, 512, 8041, 768, 512, 8040, 769, 512, 8041, 769, - 512, 8040, 834, 512, 8041, 834, 512, 945, 768, 256, 940, 512, 949, 768, - 256, 941, 512, 951, 768, 256, 942, 512, 953, 768, 256, 943, 512, 959, - 768, 256, 972, 512, 965, 768, 256, 973, 512, 969, 768, 256, 974, 512, - 7936, 837, 512, 7937, 837, 512, 7938, 837, 512, 7939, 837, 512, 7940, - 837, 512, 7941, 837, 512, 7942, 837, 512, 7943, 837, 512, 7944, 837, 512, - 7945, 837, 512, 7946, 837, 512, 7947, 837, 512, 7948, 837, 512, 7949, - 837, 512, 7950, 837, 512, 7951, 837, 512, 7968, 837, 512, 7969, 837, 512, - 7970, 837, 512, 7971, 837, 512, 7972, 837, 512, 7973, 837, 512, 7974, - 837, 512, 7975, 837, 512, 7976, 837, 512, 7977, 837, 512, 7978, 837, 512, - 7979, 837, 512, 7980, 837, 512, 7981, 837, 512, 7982, 837, 512, 7983, - 837, 512, 8032, 837, 512, 8033, 837, 512, 8034, 837, 512, 8035, 837, 512, - 8036, 837, 512, 8037, 837, 512, 8038, 837, 512, 8039, 837, 512, 8040, - 837, 512, 8041, 837, 512, 8042, 837, 512, 8043, 837, 512, 8044, 837, 512, - 8045, 837, 512, 8046, 837, 512, 8047, 837, 512, 945, 774, 512, 945, 772, - 512, 8048, 837, 512, 945, 837, 512, 940, 837, 512, 945, 834, 512, 8118, - 837, 512, 913, 774, 512, 913, 772, 512, 913, 768, 256, 902, 512, 913, - 837, 514, 32, 787, 256, 953, 514, 32, 834, 512, 168, 834, 512, 8052, 837, - 512, 951, 837, 512, 942, 837, 512, 951, 834, 512, 8134, 837, 512, 917, - 768, 256, 904, 512, 919, 768, 256, 905, 512, 919, 837, 512, 8127, 768, - 512, 8127, 769, 512, 8127, 834, 512, 953, 774, 512, 953, 772, 512, 970, - 768, 256, 912, 512, 953, 834, 512, 970, 834, 512, 921, 774, 512, 921, - 772, 512, 921, 768, 256, 906, 512, 8190, 768, 512, 8190, 769, 512, 8190, - 834, 512, 965, 774, 512, 965, 772, 512, 971, 768, 256, 944, 512, 961, - 787, 512, 961, 788, 512, 965, 834, 512, 971, 834, 512, 933, 774, 512, - 933, 772, 512, 933, 768, 256, 910, 512, 929, 788, 512, 168, 768, 256, - 901, 256, 96, 512, 8060, 837, 512, 969, 837, 512, 974, 837, 512, 969, - 834, 512, 8182, 837, 512, 927, 768, 256, 908, 512, 937, 768, 256, 911, - 512, 937, 837, 256, 180, 514, 32, 788, 256, 8194, 256, 8195, 258, 32, - 257, 8208, 514, 32, 819, 258, 46, 514, 46, 46, 770, 46, 46, 46, 514, - 8242, 8242, 770, 8242, 8242, 8242, 514, 8245, 8245, 770, 8245, 8245, - 8245, 514, 33, 33, 514, 32, 773, 514, 63, 63, 514, 63, 33, 514, 33, 63, - 1026, 8242, 8242, 8242, 8242, 259, 48, 259, 105, 259, 52, 259, 53, 259, - 54, 259, 55, 259, 56, 259, 57, 259, 43, 259, 8722, 259, 61, 259, 40, 259, - 41, 259, 110, 261, 48, 261, 49, 261, 50, 261, 51, 261, 52, 261, 53, 261, - 54, 261, 55, 261, 56, 261, 57, 261, 43, 261, 8722, 261, 61, 261, 40, 261, - 41, 261, 97, 261, 101, 261, 111, 261, 120, 261, 601, 261, 104, 261, 107, - 261, 108, 261, 109, 261, 110, 261, 112, 261, 115, 261, 116, 514, 82, 115, - 770, 97, 47, 99, 770, 97, 47, 115, 262, 67, 514, 176, 67, 770, 99, 47, - 111, 770, 99, 47, 117, 258, 400, 514, 176, 70, 262, 103, 262, 72, 262, - 104, 262, 295, 262, 73, 262, 76, 262, 108, 262, 78, 514, 78, 111, 262, - 80, 262, 81, 262, 82, 515, 83, 77, 770, 84, 69, 76, 515, 84, 77, 262, 90, - 256, 937, 256, 75, 256, 197, 262, 66, 262, 101, 262, 69, 262, 70, 262, - 77, 262, 111, 258, 1488, 258, 1489, 258, 1490, 258, 1491, 262, 105, 770, - 70, 65, 88, 262, 960, 262, 947, 262, 915, 262, 928, 262, 8721, 262, 68, - 262, 100, 262, 106, 772, 49, 8260, 55, 772, 49, 8260, 57, 1028, 49, 8260, - 49, 48, 772, 49, 8260, 51, 772, 50, 8260, 51, 772, 49, 8260, 53, 772, 50, - 8260, 53, 772, 51, 8260, 53, 772, 52, 8260, 53, 772, 49, 8260, 54, 772, - 53, 8260, 54, 772, 49, 8260, 56, 772, 51, 8260, 56, 772, 53, 8260, 56, - 772, 55, 8260, 56, 516, 49, 8260, 258, 73, 514, 73, 73, 770, 73, 73, 73, - 514, 73, 86, 258, 86, 514, 86, 73, 770, 86, 73, 73, 1026, 86, 73, 73, 73, - 514, 73, 88, 258, 88, 514, 88, 73, 770, 88, 73, 73, 258, 76, 258, 67, - 258, 68, 258, 77, 258, 105, 514, 105, 105, 770, 105, 105, 105, 514, 105, - 118, 258, 118, 514, 118, 105, 770, 118, 105, 105, 1026, 118, 105, 105, - 105, 514, 105, 120, 258, 120, 514, 120, 105, 770, 120, 105, 105, 258, - 108, 258, 99, 258, 100, 258, 109, 772, 48, 8260, 51, 512, 8592, 824, 512, - 8594, 824, 512, 8596, 824, 512, 8656, 824, 512, 8660, 824, 512, 8658, - 824, 512, 8707, 824, 512, 8712, 824, 512, 8715, 824, 512, 8739, 824, 512, - 8741, 824, 514, 8747, 8747, 770, 8747, 8747, 8747, 514, 8750, 8750, 770, - 8750, 8750, 8750, 512, 8764, 824, 512, 8771, 824, 512, 8773, 824, 512, - 8776, 824, 512, 61, 824, 512, 8801, 824, 512, 8781, 824, 512, 60, 824, - 512, 62, 824, 512, 8804, 824, 512, 8805, 824, 512, 8818, 824, 512, 8819, - 824, 512, 8822, 824, 512, 8823, 824, 512, 8826, 824, 512, 8827, 824, 512, - 8834, 824, 512, 8835, 824, 512, 8838, 824, 512, 8839, 824, 512, 8866, - 824, 512, 8872, 824, 512, 8873, 824, 512, 8875, 824, 512, 8828, 824, 512, - 8829, 824, 512, 8849, 824, 512, 8850, 824, 512, 8882, 824, 512, 8883, - 824, 512, 8884, 824, 512, 8885, 824, 256, 12296, 256, 12297, 263, 49, - 263, 50, 263, 51, 263, 52, 263, 53, 263, 54, 263, 55, 263, 56, 263, 57, - 519, 49, 48, 519, 49, 49, 519, 49, 50, 519, 49, 51, 519, 49, 52, 519, 49, - 53, 519, 49, 54, 519, 49, 55, 519, 49, 56, 519, 49, 57, 519, 50, 48, 770, - 40, 49, 41, 770, 40, 50, 41, 770, 40, 51, 41, 770, 40, 52, 41, 770, 40, - 53, 41, 770, 40, 54, 41, 770, 40, 55, 41, 770, 40, 56, 41, 770, 40, 57, - 41, 1026, 40, 49, 48, 41, 1026, 40, 49, 49, 41, 1026, 40, 49, 50, 41, - 1026, 40, 49, 51, 41, 1026, 40, 49, 52, 41, 1026, 40, 49, 53, 41, 1026, - 40, 49, 54, 41, 1026, 40, 49, 55, 41, 1026, 40, 49, 56, 41, 1026, 40, 49, - 57, 41, 1026, 40, 50, 48, 41, 514, 49, 46, 514, 50, 46, 514, 51, 46, 514, - 52, 46, 514, 53, 46, 514, 54, 46, 514, 55, 46, 514, 56, 46, 514, 57, 46, - 770, 49, 48, 46, 770, 49, 49, 46, 770, 49, 50, 46, 770, 49, 51, 46, 770, - 49, 52, 46, 770, 49, 53, 46, 770, 49, 54, 46, 770, 49, 55, 46, 770, 49, - 56, 46, 770, 49, 57, 46, 770, 50, 48, 46, 770, 40, 97, 41, 770, 40, 98, - 41, 770, 40, 99, 41, 770, 40, 100, 41, 770, 40, 101, 41, 770, 40, 102, - 41, 770, 40, 103, 41, 770, 40, 104, 41, 770, 40, 105, 41, 770, 40, 106, - 41, 770, 40, 107, 41, 770, 40, 108, 41, 770, 40, 109, 41, 770, 40, 110, - 41, 770, 40, 111, 41, 770, 40, 112, 41, 770, 40, 113, 41, 770, 40, 114, - 41, 770, 40, 115, 41, 770, 40, 116, 41, 770, 40, 117, 41, 770, 40, 118, - 41, 770, 40, 119, 41, 770, 40, 120, 41, 770, 40, 121, 41, 770, 40, 122, - 41, 263, 65, 263, 66, 263, 67, 263, 68, 263, 69, 263, 70, 263, 71, 263, - 72, 263, 73, 263, 74, 263, 75, 263, 76, 263, 77, 263, 78, 263, 79, 263, - 80, 263, 81, 263, 82, 263, 83, 263, 84, 263, 85, 263, 86, 263, 87, 263, - 88, 263, 89, 263, 90, 263, 97, 263, 98, 263, 99, 263, 100, 263, 101, 263, - 102, 263, 103, 263, 104, 263, 105, 263, 106, 263, 107, 263, 108, 263, - 109, 263, 110, 263, 111, 263, 112, 263, 113, 263, 114, 263, 115, 263, - 116, 263, 117, 263, 118, 263, 119, 263, 120, 263, 121, 263, 122, 263, 48, - 1026, 8747, 8747, 8747, 8747, 770, 58, 58, 61, 514, 61, 61, 770, 61, 61, - 61, 512, 10973, 824, 261, 106, 259, 86, 259, 11617, 258, 27597, 258, - 40863, 258, 19968, 258, 20008, 258, 20022, 258, 20031, 258, 20057, 258, - 20101, 258, 20108, 258, 20128, 258, 20154, 258, 20799, 258, 20837, 258, - 20843, 258, 20866, 258, 20886, 258, 20907, 258, 20960, 258, 20981, 258, - 20992, 258, 21147, 258, 21241, 258, 21269, 258, 21274, 258, 21304, 258, - 21313, 258, 21340, 258, 21353, 258, 21378, 258, 21430, 258, 21448, 258, - 21475, 258, 22231, 258, 22303, 258, 22763, 258, 22786, 258, 22794, 258, - 22805, 258, 22823, 258, 22899, 258, 23376, 258, 23424, 258, 23544, 258, - 23567, 258, 23586, 258, 23608, 258, 23662, 258, 23665, 258, 24027, 258, - 24037, 258, 24049, 258, 24062, 258, 24178, 258, 24186, 258, 24191, 258, - 24308, 258, 24318, 258, 24331, 258, 24339, 258, 24400, 258, 24417, 258, - 24435, 258, 24515, 258, 25096, 258, 25142, 258, 25163, 258, 25903, 258, - 25908, 258, 25991, 258, 26007, 258, 26020, 258, 26041, 258, 26080, 258, - 26085, 258, 26352, 258, 26376, 258, 26408, 258, 27424, 258, 27490, 258, - 27513, 258, 27571, 258, 27595, 258, 27604, 258, 27611, 258, 27663, 258, - 27668, 258, 27700, 258, 28779, 258, 29226, 258, 29238, 258, 29243, 258, - 29247, 258, 29255, 258, 29273, 258, 29275, 258, 29356, 258, 29572, 258, - 29577, 258, 29916, 258, 29926, 258, 29976, 258, 29983, 258, 29992, 258, - 30000, 258, 30091, 258, 30098, 258, 30326, 258, 30333, 258, 30382, 258, - 30399, 258, 30446, 258, 30683, 258, 30690, 258, 30707, 258, 31034, 258, - 31160, 258, 31166, 258, 31348, 258, 31435, 258, 31481, 258, 31859, 258, - 31992, 258, 32566, 258, 32593, 258, 32650, 258, 32701, 258, 32769, 258, - 32780, 258, 32786, 258, 32819, 258, 32895, 258, 32905, 258, 33251, 258, - 33258, 258, 33267, 258, 33276, 258, 33292, 258, 33307, 258, 33311, 258, - 33390, 258, 33394, 258, 33400, 258, 34381, 258, 34411, 258, 34880, 258, - 34892, 258, 34915, 258, 35198, 258, 35211, 258, 35282, 258, 35328, 258, - 35895, 258, 35910, 258, 35925, 258, 35960, 258, 35997, 258, 36196, 258, - 36208, 258, 36275, 258, 36523, 258, 36554, 258, 36763, 258, 36784, 258, - 36789, 258, 37009, 258, 37193, 258, 37318, 258, 37324, 258, 37329, 258, - 38263, 258, 38272, 258, 38428, 258, 38582, 258, 38585, 258, 38632, 258, - 38737, 258, 38750, 258, 38754, 258, 38761, 258, 38859, 258, 38893, 258, - 38899, 258, 38913, 258, 39080, 258, 39131, 258, 39135, 258, 39318, 258, - 39321, 258, 39340, 258, 39592, 258, 39640, 258, 39647, 258, 39717, 258, - 39727, 258, 39730, 258, 39740, 258, 39770, 258, 40165, 258, 40565, 258, - 40575, 258, 40613, 258, 40635, 258, 40643, 258, 40653, 258, 40657, 258, - 40697, 258, 40701, 258, 40718, 258, 40723, 258, 40736, 258, 40763, 258, - 40778, 258, 40786, 258, 40845, 258, 40860, 258, 40864, 264, 32, 258, - 12306, 258, 21316, 258, 21317, 512, 12363, 12441, 512, 12365, 12441, 512, - 12367, 12441, 512, 12369, 12441, 512, 12371, 12441, 512, 12373, 12441, - 512, 12375, 12441, 512, 12377, 12441, 512, 12379, 12441, 512, 12381, - 12441, 512, 12383, 12441, 512, 12385, 12441, 512, 12388, 12441, 512, - 12390, 12441, 512, 12392, 12441, 512, 12399, 12441, 512, 12399, 12442, - 512, 12402, 12441, 512, 12402, 12442, 512, 12405, 12441, 512, 12405, - 12442, 512, 12408, 12441, 512, 12408, 12442, 512, 12411, 12441, 512, - 12411, 12442, 512, 12358, 12441, 514, 32, 12441, 514, 32, 12442, 512, - 12445, 12441, 521, 12424, 12426, 512, 12459, 12441, 512, 12461, 12441, - 512, 12463, 12441, 512, 12465, 12441, 512, 12467, 12441, 512, 12469, - 12441, 512, 12471, 12441, 512, 12473, 12441, 512, 12475, 12441, 512, - 12477, 12441, 512, 12479, 12441, 512, 12481, 12441, 512, 12484, 12441, - 512, 12486, 12441, 512, 12488, 12441, 512, 12495, 12441, 512, 12495, - 12442, 512, 12498, 12441, 512, 12498, 12442, 512, 12501, 12441, 512, - 12501, 12442, 512, 12504, 12441, 512, 12504, 12442, 512, 12507, 12441, - 512, 12507, 12442, 512, 12454, 12441, 512, 12527, 12441, 512, 12528, - 12441, 512, 12529, 12441, 512, 12530, 12441, 512, 12541, 12441, 521, - 12467, 12488, 258, 4352, 258, 4353, 258, 4522, 258, 4354, 258, 4524, 258, - 4525, 258, 4355, 258, 4356, 258, 4357, 258, 4528, 258, 4529, 258, 4530, - 258, 4531, 258, 4532, 258, 4533, 258, 4378, 258, 4358, 258, 4359, 258, - 4360, 258, 4385, 258, 4361, 258, 4362, 258, 4363, 258, 4364, 258, 4365, - 258, 4366, 258, 4367, 258, 4368, 258, 4369, 258, 4370, 258, 4449, 258, - 4450, 258, 4451, 258, 4452, 258, 4453, 258, 4454, 258, 4455, 258, 4456, - 258, 4457, 258, 4458, 258, 4459, 258, 4460, 258, 4461, 258, 4462, 258, - 4463, 258, 4464, 258, 4465, 258, 4466, 258, 4467, 258, 4468, 258, 4469, - 258, 4448, 258, 4372, 258, 4373, 258, 4551, 258, 4552, 258, 4556, 258, - 4558, 258, 4563, 258, 4567, 258, 4569, 258, 4380, 258, 4573, 258, 4575, - 258, 4381, 258, 4382, 258, 4384, 258, 4386, 258, 4387, 258, 4391, 258, - 4393, 258, 4395, 258, 4396, 258, 4397, 258, 4398, 258, 4399, 258, 4402, - 258, 4406, 258, 4416, 258, 4423, 258, 4428, 258, 4593, 258, 4594, 258, - 4439, 258, 4440, 258, 4441, 258, 4484, 258, 4485, 258, 4488, 258, 4497, - 258, 4498, 258, 4500, 258, 4510, 258, 4513, 259, 19968, 259, 20108, 259, - 19977, 259, 22235, 259, 19978, 259, 20013, 259, 19979, 259, 30002, 259, - 20057, 259, 19993, 259, 19969, 259, 22825, 259, 22320, 259, 20154, 770, - 40, 4352, 41, 770, 40, 4354, 41, 770, 40, 4355, 41, 770, 40, 4357, 41, - 770, 40, 4358, 41, 770, 40, 4359, 41, 770, 40, 4361, 41, 770, 40, 4363, - 41, 770, 40, 4364, 41, 770, 40, 4366, 41, 770, 40, 4367, 41, 770, 40, - 4368, 41, 770, 40, 4369, 41, 770, 40, 4370, 41, 1026, 40, 4352, 4449, 41, - 1026, 40, 4354, 4449, 41, 1026, 40, 4355, 4449, 41, 1026, 40, 4357, 4449, - 41, 1026, 40, 4358, 4449, 41, 1026, 40, 4359, 4449, 41, 1026, 40, 4361, - 4449, 41, 1026, 40, 4363, 4449, 41, 1026, 40, 4364, 4449, 41, 1026, 40, - 4366, 4449, 41, 1026, 40, 4367, 4449, 41, 1026, 40, 4368, 4449, 41, 1026, - 40, 4369, 4449, 41, 1026, 40, 4370, 4449, 41, 1026, 40, 4364, 4462, 41, - 1794, 40, 4363, 4457, 4364, 4453, 4523, 41, 1538, 40, 4363, 4457, 4370, - 4462, 41, 770, 40, 19968, 41, 770, 40, 20108, 41, 770, 40, 19977, 41, - 770, 40, 22235, 41, 770, 40, 20116, 41, 770, 40, 20845, 41, 770, 40, - 19971, 41, 770, 40, 20843, 41, 770, 40, 20061, 41, 770, 40, 21313, 41, - 770, 40, 26376, 41, 770, 40, 28779, 41, 770, 40, 27700, 41, 770, 40, - 26408, 41, 770, 40, 37329, 41, 770, 40, 22303, 41, 770, 40, 26085, 41, - 770, 40, 26666, 41, 770, 40, 26377, 41, 770, 40, 31038, 41, 770, 40, - 21517, 41, 770, 40, 29305, 41, 770, 40, 36001, 41, 770, 40, 31069, 41, - 770, 40, 21172, 41, 770, 40, 20195, 41, 770, 40, 21628, 41, 770, 40, - 23398, 41, 770, 40, 30435, 41, 770, 40, 20225, 41, 770, 40, 36039, 41, - 770, 40, 21332, 41, 770, 40, 31085, 41, 770, 40, 20241, 41, 770, 40, - 33258, 41, 770, 40, 33267, 41, 263, 21839, 263, 24188, 263, 25991, 263, - 31631, 778, 80, 84, 69, 519, 50, 49, 519, 50, 50, 519, 50, 51, 519, 50, - 52, 519, 50, 53, 519, 50, 54, 519, 50, 55, 519, 50, 56, 519, 50, 57, 519, - 51, 48, 519, 51, 49, 519, 51, 50, 519, 51, 51, 519, 51, 52, 519, 51, 53, - 263, 4352, 263, 4354, 263, 4355, 263, 4357, 263, 4358, 263, 4359, 263, - 4361, 263, 4363, 263, 4364, 263, 4366, 263, 4367, 263, 4368, 263, 4369, - 263, 4370, 519, 4352, 4449, 519, 4354, 4449, 519, 4355, 4449, 519, 4357, - 4449, 519, 4358, 4449, 519, 4359, 4449, 519, 4361, 4449, 519, 4363, 4449, - 519, 4364, 4449, 519, 4366, 4449, 519, 4367, 4449, 519, 4368, 4449, 519, - 4369, 4449, 519, 4370, 4449, 1287, 4366, 4449, 4535, 4352, 4457, 1031, - 4364, 4462, 4363, 4468, 519, 4363, 4462, 263, 19968, 263, 20108, 263, - 19977, 263, 22235, 263, 20116, 263, 20845, 263, 19971, 263, 20843, 263, - 20061, 263, 21313, 263, 26376, 263, 28779, 263, 27700, 263, 26408, 263, - 37329, 263, 22303, 263, 26085, 263, 26666, 263, 26377, 263, 31038, 263, - 21517, 263, 29305, 263, 36001, 263, 31069, 263, 21172, 263, 31192, 263, - 30007, 263, 22899, 263, 36969, 263, 20778, 263, 21360, 263, 27880, 263, - 38917, 263, 20241, 263, 20889, 263, 27491, 263, 19978, 263, 20013, 263, - 19979, 263, 24038, 263, 21491, 263, 21307, 263, 23447, 263, 23398, 263, - 30435, 263, 20225, 263, 36039, 263, 21332, 263, 22812, 519, 51, 54, 519, - 51, 55, 519, 51, 56, 519, 51, 57, 519, 52, 48, 519, 52, 49, 519, 52, 50, - 519, 52, 51, 519, 52, 52, 519, 52, 53, 519, 52, 54, 519, 52, 55, 519, 52, - 56, 519, 52, 57, 519, 53, 48, 514, 49, 26376, 514, 50, 26376, 514, 51, - 26376, 514, 52, 26376, 514, 53, 26376, 514, 54, 26376, 514, 55, 26376, - 514, 56, 26376, 514, 57, 26376, 770, 49, 48, 26376, 770, 49, 49, 26376, - 770, 49, 50, 26376, 522, 72, 103, 778, 101, 114, 103, 522, 101, 86, 778, - 76, 84, 68, 263, 12450, 263, 12452, 263, 12454, 263, 12456, 263, 12458, - 263, 12459, 263, 12461, 263, 12463, 263, 12465, 263, 12467, 263, 12469, - 263, 12471, 263, 12473, 263, 12475, 263, 12477, 263, 12479, 263, 12481, - 263, 12484, 263, 12486, 263, 12488, 263, 12490, 263, 12491, 263, 12492, - 263, 12493, 263, 12494, 263, 12495, 263, 12498, 263, 12501, 263, 12504, - 263, 12507, 263, 12510, 263, 12511, 263, 12512, 263, 12513, 263, 12514, - 263, 12516, 263, 12518, 263, 12520, 263, 12521, 263, 12522, 263, 12523, - 263, 12524, 263, 12525, 263, 12527, 263, 12528, 263, 12529, 263, 12530, - 522, 20196, 21644, 1034, 12450, 12497, 12540, 12488, 1034, 12450, 12523, - 12501, 12449, 1034, 12450, 12531, 12506, 12450, 778, 12450, 12540, 12523, - 1034, 12452, 12491, 12531, 12464, 778, 12452, 12531, 12481, 778, 12454, - 12457, 12531, 1290, 12456, 12473, 12463, 12540, 12489, 1034, 12456, - 12540, 12459, 12540, 778, 12458, 12531, 12473, 778, 12458, 12540, 12512, - 778, 12459, 12452, 12522, 1034, 12459, 12521, 12483, 12488, 1034, 12459, - 12525, 12522, 12540, 778, 12460, 12525, 12531, 778, 12460, 12531, 12510, - 522, 12462, 12460, 778, 12462, 12491, 12540, 1034, 12461, 12517, 12522, - 12540, 1034, 12462, 12523, 12480, 12540, 522, 12461, 12525, 1290, 12461, - 12525, 12464, 12521, 12512, 1546, 12461, 12525, 12513, 12540, 12488, - 12523, 1290, 12461, 12525, 12527, 12483, 12488, 778, 12464, 12521, 12512, - 1290, 12464, 12521, 12512, 12488, 12531, 1290, 12463, 12523, 12476, - 12452, 12525, 1034, 12463, 12525, 12540, 12493, 778, 12465, 12540, 12473, - 778, 12467, 12523, 12490, 778, 12467, 12540, 12509, 1034, 12469, 12452, - 12463, 12523, 1290, 12469, 12531, 12481, 12540, 12512, 1034, 12471, - 12522, 12531, 12464, 778, 12475, 12531, 12481, 778, 12475, 12531, 12488, - 778, 12480, 12540, 12473, 522, 12487, 12471, 522, 12489, 12523, 522, - 12488, 12531, 522, 12490, 12494, 778, 12494, 12483, 12488, 778, 12495, - 12452, 12484, 1290, 12497, 12540, 12475, 12531, 12488, 778, 12497, 12540, - 12484, 1034, 12496, 12540, 12524, 12523, 1290, 12500, 12450, 12473, - 12488, 12523, 778, 12500, 12463, 12523, 522, 12500, 12467, 522, 12499, - 12523, 1290, 12501, 12449, 12521, 12483, 12489, 1034, 12501, 12451, - 12540, 12488, 1290, 12502, 12483, 12471, 12455, 12523, 778, 12501, 12521, - 12531, 1290, 12504, 12463, 12479, 12540, 12523, 522, 12506, 12477, 778, - 12506, 12491, 12498, 778, 12504, 12523, 12484, 778, 12506, 12531, 12473, - 778, 12506, 12540, 12472, 778, 12505, 12540, 12479, 1034, 12509, 12452, - 12531, 12488, 778, 12508, 12523, 12488, 522, 12507, 12531, 778, 12509, - 12531, 12489, 778, 12507, 12540, 12523, 778, 12507, 12540, 12531, 1034, - 12510, 12452, 12463, 12525, 778, 12510, 12452, 12523, 778, 12510, 12483, - 12495, 778, 12510, 12523, 12463, 1290, 12510, 12531, 12471, 12519, 12531, - 1034, 12511, 12463, 12525, 12531, 522, 12511, 12522, 1290, 12511, 12522, - 12496, 12540, 12523, 522, 12513, 12460, 1034, 12513, 12460, 12488, 12531, - 1034, 12513, 12540, 12488, 12523, 778, 12516, 12540, 12489, 778, 12516, - 12540, 12523, 778, 12518, 12450, 12531, 1034, 12522, 12483, 12488, 12523, - 522, 12522, 12521, 778, 12523, 12500, 12540, 1034, 12523, 12540, 12502, - 12523, 522, 12524, 12512, 1290, 12524, 12531, 12488, 12466, 12531, 778, - 12527, 12483, 12488, 514, 48, 28857, 514, 49, 28857, 514, 50, 28857, 514, - 51, 28857, 514, 52, 28857, 514, 53, 28857, 514, 54, 28857, 514, 55, - 28857, 514, 56, 28857, 514, 57, 28857, 770, 49, 48, 28857, 770, 49, 49, - 28857, 770, 49, 50, 28857, 770, 49, 51, 28857, 770, 49, 52, 28857, 770, - 49, 53, 28857, 770, 49, 54, 28857, 770, 49, 55, 28857, 770, 49, 56, - 28857, 770, 49, 57, 28857, 770, 50, 48, 28857, 770, 50, 49, 28857, 770, - 50, 50, 28857, 770, 50, 51, 28857, 770, 50, 52, 28857, 778, 104, 80, 97, - 522, 100, 97, 522, 65, 85, 778, 98, 97, 114, 522, 111, 86, 522, 112, 99, - 522, 100, 109, 778, 100, 109, 178, 778, 100, 109, 179, 522, 73, 85, 522, - 24179, 25104, 522, 26157, 21644, 522, 22823, 27491, 522, 26126, 27835, - 1034, 26666, 24335, 20250, 31038, 522, 112, 65, 522, 110, 65, 522, 956, - 65, 522, 109, 65, 522, 107, 65, 522, 75, 66, 522, 77, 66, 522, 71, 66, - 778, 99, 97, 108, 1034, 107, 99, 97, 108, 522, 112, 70, 522, 110, 70, - 522, 956, 70, 522, 956, 103, 522, 109, 103, 522, 107, 103, 522, 72, 122, - 778, 107, 72, 122, 778, 77, 72, 122, 778, 71, 72, 122, 778, 84, 72, 122, - 522, 956, 8467, 522, 109, 8467, 522, 100, 8467, 522, 107, 8467, 522, 102, - 109, 522, 110, 109, 522, 956, 109, 522, 109, 109, 522, 99, 109, 522, 107, - 109, 778, 109, 109, 178, 778, 99, 109, 178, 522, 109, 178, 778, 107, 109, - 178, 778, 109, 109, 179, 778, 99, 109, 179, 522, 109, 179, 778, 107, 109, - 179, 778, 109, 8725, 115, 1034, 109, 8725, 115, 178, 522, 80, 97, 778, - 107, 80, 97, 778, 77, 80, 97, 778, 71, 80, 97, 778, 114, 97, 100, 1290, - 114, 97, 100, 8725, 115, 1546, 114, 97, 100, 8725, 115, 178, 522, 112, - 115, 522, 110, 115, 522, 956, 115, 522, 109, 115, 522, 112, 86, 522, 110, - 86, 522, 956, 86, 522, 109, 86, 522, 107, 86, 522, 77, 86, 522, 112, 87, - 522, 110, 87, 522, 956, 87, 522, 109, 87, 522, 107, 87, 522, 77, 87, 522, - 107, 937, 522, 77, 937, 1034, 97, 46, 109, 46, 522, 66, 113, 522, 99, 99, - 522, 99, 100, 1034, 67, 8725, 107, 103, 778, 67, 111, 46, 522, 100, 66, - 522, 71, 121, 522, 104, 97, 522, 72, 80, 522, 105, 110, 522, 75, 75, 522, - 75, 77, 522, 107, 116, 522, 108, 109, 522, 108, 110, 778, 108, 111, 103, - 522, 108, 120, 522, 109, 98, 778, 109, 105, 108, 778, 109, 111, 108, 522, - 80, 72, 1034, 112, 46, 109, 46, 778, 80, 80, 77, 522, 80, 82, 522, 115, - 114, 522, 83, 118, 522, 87, 98, 778, 86, 8725, 109, 778, 65, 8725, 109, - 514, 49, 26085, 514, 50, 26085, 514, 51, 26085, 514, 52, 26085, 514, 53, - 26085, 514, 54, 26085, 514, 55, 26085, 514, 56, 26085, 514, 57, 26085, - 770, 49, 48, 26085, 770, 49, 49, 26085, 770, 49, 50, 26085, 770, 49, 51, - 26085, 770, 49, 52, 26085, 770, 49, 53, 26085, 770, 49, 54, 26085, 770, - 49, 55, 26085, 770, 49, 56, 26085, 770, 49, 57, 26085, 770, 50, 48, - 26085, 770, 50, 49, 26085, 770, 50, 50, 26085, 770, 50, 51, 26085, 770, - 50, 52, 26085, 770, 50, 53, 26085, 770, 50, 54, 26085, 770, 50, 55, - 26085, 770, 50, 56, 26085, 770, 50, 57, 26085, 770, 51, 48, 26085, 770, - 51, 49, 26085, 778, 103, 97, 108, 259, 1098, 259, 1100, 259, 42863, 259, - 83, 259, 67, 259, 70, 259, 81, 259, 294, 259, 339, 259, 42791, 259, - 43831, 259, 619, 259, 43858, 259, 653, 256, 35912, 256, 26356, 256, - 36554, 256, 36040, 256, 28369, 256, 20018, 256, 21477, 256, 40860, 256, - 22865, 256, 37329, 256, 21895, 256, 22856, 256, 25078, 256, 30313, 256, - 32645, 256, 34367, 256, 34746, 256, 35064, 256, 37007, 256, 27138, 256, - 27931, 256, 28889, 256, 29662, 256, 33853, 256, 37226, 256, 39409, 256, - 20098, 256, 21365, 256, 27396, 256, 29211, 256, 34349, 256, 40478, 256, - 23888, 256, 28651, 256, 34253, 256, 35172, 256, 25289, 256, 33240, 256, - 34847, 256, 24266, 256, 26391, 256, 28010, 256, 29436, 256, 37070, 256, - 20358, 256, 20919, 256, 21214, 256, 25796, 256, 27347, 256, 29200, 256, - 30439, 256, 32769, 256, 34310, 256, 34396, 256, 36335, 256, 38706, 256, - 39791, 256, 40442, 256, 30860, 256, 31103, 256, 32160, 256, 33737, 256, - 37636, 256, 40575, 256, 35542, 256, 22751, 256, 24324, 256, 31840, 256, - 32894, 256, 29282, 256, 30922, 256, 36034, 256, 38647, 256, 22744, 256, - 23650, 256, 27155, 256, 28122, 256, 28431, 256, 32047, 256, 32311, 256, - 38475, 256, 21202, 256, 32907, 256, 20956, 256, 20940, 256, 31260, 256, - 32190, 256, 33777, 256, 38517, 256, 35712, 256, 25295, 256, 35582, 256, - 20025, 256, 23527, 256, 24594, 256, 29575, 256, 30064, 256, 21271, 256, - 30971, 256, 20415, 256, 24489, 256, 19981, 256, 27852, 256, 25976, 256, - 32034, 256, 21443, 256, 22622, 256, 30465, 256, 33865, 256, 35498, 256, - 27578, 256, 36784, 256, 27784, 256, 25342, 256, 33509, 256, 25504, 256, - 30053, 256, 20142, 256, 20841, 256, 20937, 256, 26753, 256, 31975, 256, - 33391, 256, 35538, 256, 37327, 256, 21237, 256, 21570, 256, 22899, 256, - 24300, 256, 26053, 256, 28670, 256, 31018, 256, 38317, 256, 39530, 256, - 40599, 256, 40654, 256, 21147, 256, 26310, 256, 27511, 256, 36706, 256, - 24180, 256, 24976, 256, 25088, 256, 25754, 256, 28451, 256, 29001, 256, - 29833, 256, 31178, 256, 32244, 256, 32879, 256, 36646, 256, 34030, 256, - 36899, 256, 37706, 256, 21015, 256, 21155, 256, 21693, 256, 28872, 256, - 35010, 256, 24265, 256, 24565, 256, 25467, 256, 27566, 256, 31806, 256, - 29557, 256, 20196, 256, 22265, 256, 23994, 256, 24604, 256, 29618, 256, - 29801, 256, 32666, 256, 32838, 256, 37428, 256, 38646, 256, 38728, 256, - 38936, 256, 20363, 256, 31150, 256, 37300, 256, 38584, 256, 24801, 256, - 20102, 256, 20698, 256, 23534, 256, 23615, 256, 26009, 256, 29134, 256, - 30274, 256, 34044, 256, 36988, 256, 40845, 256, 26248, 256, 38446, 256, - 21129, 256, 26491, 256, 26611, 256, 27969, 256, 28316, 256, 29705, 256, - 30041, 256, 30827, 256, 32016, 256, 39006, 256, 20845, 256, 25134, 256, - 38520, 256, 20523, 256, 23833, 256, 28138, 256, 36650, 256, 24459, 256, - 24900, 256, 26647, 256, 38534, 256, 21033, 256, 21519, 256, 23653, 256, - 26131, 256, 26446, 256, 26792, 256, 27877, 256, 29702, 256, 30178, 256, - 32633, 256, 35023, 256, 35041, 256, 37324, 256, 38626, 256, 21311, 256, - 28346, 256, 21533, 256, 29136, 256, 29848, 256, 34298, 256, 38563, 256, - 40023, 256, 40607, 256, 26519, 256, 28107, 256, 33256, 256, 31435, 256, - 31520, 256, 31890, 256, 29376, 256, 28825, 256, 35672, 256, 20160, 256, - 33590, 256, 21050, 256, 20999, 256, 24230, 256, 25299, 256, 31958, 256, - 23429, 256, 27934, 256, 26292, 256, 36667, 256, 34892, 256, 38477, 256, - 35211, 256, 24275, 256, 20800, 256, 21952, 256, 22618, 256, 26228, 256, - 20958, 256, 29482, 256, 30410, 256, 31036, 256, 31070, 256, 31077, 256, - 31119, 256, 38742, 256, 31934, 256, 32701, 256, 34322, 256, 35576, 256, - 36920, 256, 37117, 256, 39151, 256, 39164, 256, 39208, 256, 40372, 256, - 37086, 256, 38583, 256, 20398, 256, 20711, 256, 20813, 256, 21193, 256, - 21220, 256, 21329, 256, 21917, 256, 22022, 256, 22120, 256, 22592, 256, - 22696, 256, 23652, 256, 23662, 256, 24724, 256, 24936, 256, 24974, 256, - 25074, 256, 25935, 256, 26082, 256, 26257, 256, 26757, 256, 28023, 256, - 28186, 256, 28450, 256, 29038, 256, 29227, 256, 29730, 256, 30865, 256, - 31038, 256, 31049, 256, 31048, 256, 31056, 256, 31062, 256, 31069, 256, - 31117, 256, 31118, 256, 31296, 256, 31361, 256, 31680, 256, 32265, 256, - 32321, 256, 32626, 256, 32773, 256, 33261, 256, 33401, 256, 33879, 256, - 35088, 256, 35222, 256, 35585, 256, 35641, 256, 36051, 256, 36104, 256, - 36790, 256, 38627, 256, 38911, 256, 38971, 256, 24693, 256, 148206, 256, - 33304, 256, 20006, 256, 20917, 256, 20840, 256, 20352, 256, 20805, 256, - 20864, 256, 21191, 256, 21242, 256, 21845, 256, 21913, 256, 21986, 256, - 22707, 256, 22852, 256, 22868, 256, 23138, 256, 23336, 256, 24274, 256, - 24281, 256, 24425, 256, 24493, 256, 24792, 256, 24910, 256, 24840, 256, - 24928, 256, 25140, 256, 25540, 256, 25628, 256, 25682, 256, 25942, 256, - 26395, 256, 26454, 256, 27513, 256, 28379, 256, 28363, 256, 28702, 256, - 30631, 256, 29237, 256, 29359, 256, 29809, 256, 29958, 256, 30011, 256, - 30237, 256, 30239, 256, 30427, 256, 30452, 256, 30538, 256, 30528, 256, - 30924, 256, 31409, 256, 31867, 256, 32091, 256, 32574, 256, 33618, 256, - 33775, 256, 34681, 256, 35137, 256, 35206, 256, 35519, 256, 35531, 256, - 35565, 256, 35722, 256, 36664, 256, 36978, 256, 37273, 256, 37494, 256, - 38524, 256, 38875, 256, 38923, 256, 39698, 256, 141386, 256, 141380, 256, - 144341, 256, 15261, 256, 16408, 256, 16441, 256, 152137, 256, 154832, - 256, 163539, 256, 40771, 256, 40846, 514, 102, 102, 514, 102, 105, 514, - 102, 108, 770, 102, 102, 105, 770, 102, 102, 108, 514, 383, 116, 514, - 115, 116, 514, 1396, 1398, 514, 1396, 1381, 514, 1396, 1387, 514, 1406, - 1398, 514, 1396, 1389, 512, 1497, 1460, 512, 1522, 1463, 262, 1506, 262, - 1488, 262, 1491, 262, 1492, 262, 1499, 262, 1500, 262, 1501, 262, 1512, - 262, 1514, 262, 43, 512, 1513, 1473, 512, 1513, 1474, 512, 64329, 1473, - 512, 64329, 1474, 512, 1488, 1463, 512, 1488, 1464, 512, 1488, 1468, 512, - 1489, 1468, 512, 1490, 1468, 512, 1491, 1468, 512, 1492, 1468, 512, 1493, - 1468, 512, 1494, 1468, 512, 1496, 1468, 512, 1497, 1468, 512, 1498, 1468, - 512, 1499, 1468, 512, 1500, 1468, 512, 1502, 1468, 512, 1504, 1468, 512, - 1505, 1468, 512, 1507, 1468, 512, 1508, 1468, 512, 1510, 1468, 512, 1511, - 1468, 512, 1512, 1468, 512, 1513, 1468, 512, 1514, 1468, 512, 1493, 1465, - 512, 1489, 1471, 512, 1499, 1471, 512, 1508, 1471, 514, 1488, 1500, 267, - 1649, 268, 1649, 267, 1659, 268, 1659, 269, 1659, 270, 1659, 267, 1662, - 268, 1662, 269, 1662, 270, 1662, 267, 1664, 268, 1664, 269, 1664, 270, - 1664, 267, 1658, 268, 1658, 269, 1658, 270, 1658, 267, 1663, 268, 1663, - 269, 1663, 270, 1663, 267, 1657, 268, 1657, 269, 1657, 270, 1657, 267, - 1700, 268, 1700, 269, 1700, 270, 1700, 267, 1702, 268, 1702, 269, 1702, - 270, 1702, 267, 1668, 268, 1668, 269, 1668, 270, 1668, 267, 1667, 268, - 1667, 269, 1667, 270, 1667, 267, 1670, 268, 1670, 269, 1670, 270, 1670, - 267, 1671, 268, 1671, 269, 1671, 270, 1671, 267, 1677, 268, 1677, 267, - 1676, 268, 1676, 267, 1678, 268, 1678, 267, 1672, 268, 1672, 267, 1688, - 268, 1688, 267, 1681, 268, 1681, 267, 1705, 268, 1705, 269, 1705, 270, - 1705, 267, 1711, 268, 1711, 269, 1711, 270, 1711, 267, 1715, 268, 1715, - 269, 1715, 270, 1715, 267, 1713, 268, 1713, 269, 1713, 270, 1713, 267, - 1722, 268, 1722, 267, 1723, 268, 1723, 269, 1723, 270, 1723, 267, 1728, - 268, 1728, 267, 1729, 268, 1729, 269, 1729, 270, 1729, 267, 1726, 268, - 1726, 269, 1726, 270, 1726, 267, 1746, 268, 1746, 267, 1747, 268, 1747, - 267, 1709, 268, 1709, 269, 1709, 270, 1709, 267, 1735, 268, 1735, 267, - 1734, 268, 1734, 267, 1736, 268, 1736, 267, 1655, 267, 1739, 268, 1739, - 267, 1733, 268, 1733, 267, 1737, 268, 1737, 267, 1744, 268, 1744, 269, - 1744, 270, 1744, 269, 1609, 270, 1609, 523, 1574, 1575, 524, 1574, 1575, - 523, 1574, 1749, 524, 1574, 1749, 523, 1574, 1608, 524, 1574, 1608, 523, - 1574, 1735, 524, 1574, 1735, 523, 1574, 1734, 524, 1574, 1734, 523, 1574, - 1736, 524, 1574, 1736, 523, 1574, 1744, 524, 1574, 1744, 525, 1574, 1744, - 523, 1574, 1609, 524, 1574, 1609, 525, 1574, 1609, 267, 1740, 268, 1740, - 269, 1740, 270, 1740, 523, 1574, 1580, 523, 1574, 1581, 523, 1574, 1605, - 523, 1574, 1610, 523, 1576, 1580, 523, 1576, 1581, 523, 1576, 1582, 523, - 1576, 1605, 523, 1576, 1609, 523, 1576, 1610, 523, 1578, 1580, 523, 1578, - 1581, 523, 1578, 1582, 523, 1578, 1605, 523, 1578, 1609, 523, 1578, 1610, - 523, 1579, 1580, 523, 1579, 1605, 523, 1579, 1609, 523, 1579, 1610, 523, - 1580, 1581, 523, 1580, 1605, 523, 1581, 1580, 523, 1581, 1605, 523, 1582, - 1580, 523, 1582, 1581, 523, 1582, 1605, 523, 1587, 1580, 523, 1587, 1581, - 523, 1587, 1582, 523, 1587, 1605, 523, 1589, 1581, 523, 1589, 1605, 523, - 1590, 1580, 523, 1590, 1581, 523, 1590, 1582, 523, 1590, 1605, 523, 1591, - 1581, 523, 1591, 1605, 523, 1592, 1605, 523, 1593, 1580, 523, 1593, 1605, - 523, 1594, 1580, 523, 1594, 1605, 523, 1601, 1580, 523, 1601, 1581, 523, - 1601, 1582, 523, 1601, 1605, 523, 1601, 1609, 523, 1601, 1610, 523, 1602, - 1581, 523, 1602, 1605, 523, 1602, 1609, 523, 1602, 1610, 523, 1603, 1575, - 523, 1603, 1580, 523, 1603, 1581, 523, 1603, 1582, 523, 1603, 1604, 523, - 1603, 1605, 523, 1603, 1609, 523, 1603, 1610, 523, 1604, 1580, 523, 1604, - 1581, 523, 1604, 1582, 523, 1604, 1605, 523, 1604, 1609, 523, 1604, 1610, - 523, 1605, 1580, 523, 1605, 1581, 523, 1605, 1582, 523, 1605, 1605, 523, - 1605, 1609, 523, 1605, 1610, 523, 1606, 1580, 523, 1606, 1581, 523, 1606, - 1582, 523, 1606, 1605, 523, 1606, 1609, 523, 1606, 1610, 523, 1607, 1580, - 523, 1607, 1605, 523, 1607, 1609, 523, 1607, 1610, 523, 1610, 1580, 523, - 1610, 1581, 523, 1610, 1582, 523, 1610, 1605, 523, 1610, 1609, 523, 1610, - 1610, 523, 1584, 1648, 523, 1585, 1648, 523, 1609, 1648, 779, 32, 1612, - 1617, 779, 32, 1613, 1617, 779, 32, 1614, 1617, 779, 32, 1615, 1617, 779, - 32, 1616, 1617, 779, 32, 1617, 1648, 524, 1574, 1585, 524, 1574, 1586, - 524, 1574, 1605, 524, 1574, 1606, 524, 1574, 1610, 524, 1576, 1585, 524, - 1576, 1586, 524, 1576, 1605, 524, 1576, 1606, 524, 1576, 1609, 524, 1576, - 1610, 524, 1578, 1585, 524, 1578, 1586, 524, 1578, 1605, 524, 1578, 1606, - 524, 1578, 1609, 524, 1578, 1610, 524, 1579, 1585, 524, 1579, 1586, 524, - 1579, 1605, 524, 1579, 1606, 524, 1579, 1609, 524, 1579, 1610, 524, 1601, - 1609, 524, 1601, 1610, 524, 1602, 1609, 524, 1602, 1610, 524, 1603, 1575, - 524, 1603, 1604, 524, 1603, 1605, 524, 1603, 1609, 524, 1603, 1610, 524, - 1604, 1605, 524, 1604, 1609, 524, 1604, 1610, 524, 1605, 1575, 524, 1605, - 1605, 524, 1606, 1585, 524, 1606, 1586, 524, 1606, 1605, 524, 1606, 1606, - 524, 1606, 1609, 524, 1606, 1610, 524, 1609, 1648, 524, 1610, 1585, 524, - 1610, 1586, 524, 1610, 1605, 524, 1610, 1606, 524, 1610, 1609, 524, 1610, - 1610, 525, 1574, 1580, 525, 1574, 1581, 525, 1574, 1582, 525, 1574, 1605, - 525, 1574, 1607, 525, 1576, 1580, 525, 1576, 1581, 525, 1576, 1582, 525, - 1576, 1605, 525, 1576, 1607, 525, 1578, 1580, 525, 1578, 1581, 525, 1578, - 1582, 525, 1578, 1605, 525, 1578, 1607, 525, 1579, 1605, 525, 1580, 1581, - 525, 1580, 1605, 525, 1581, 1580, 525, 1581, 1605, 525, 1582, 1580, 525, - 1582, 1605, 525, 1587, 1580, 525, 1587, 1581, 525, 1587, 1582, 525, 1587, - 1605, 525, 1589, 1581, 525, 1589, 1582, 525, 1589, 1605, 525, 1590, 1580, - 525, 1590, 1581, 525, 1590, 1582, 525, 1590, 1605, 525, 1591, 1581, 525, - 1592, 1605, 525, 1593, 1580, 525, 1593, 1605, 525, 1594, 1580, 525, 1594, - 1605, 525, 1601, 1580, 525, 1601, 1581, 525, 1601, 1582, 525, 1601, 1605, - 525, 1602, 1581, 525, 1602, 1605, 525, 1603, 1580, 525, 1603, 1581, 525, - 1603, 1582, 525, 1603, 1604, 525, 1603, 1605, 525, 1604, 1580, 525, 1604, - 1581, 525, 1604, 1582, 525, 1604, 1605, 525, 1604, 1607, 525, 1605, 1580, - 525, 1605, 1581, 525, 1605, 1582, 525, 1605, 1605, 525, 1606, 1580, 525, - 1606, 1581, 525, 1606, 1582, 525, 1606, 1605, 525, 1606, 1607, 525, 1607, - 1580, 525, 1607, 1605, 525, 1607, 1648, 525, 1610, 1580, 525, 1610, 1581, - 525, 1610, 1582, 525, 1610, 1605, 525, 1610, 1607, 526, 1574, 1605, 526, - 1574, 1607, 526, 1576, 1605, 526, 1576, 1607, 526, 1578, 1605, 526, 1578, - 1607, 526, 1579, 1605, 526, 1579, 1607, 526, 1587, 1605, 526, 1587, 1607, - 526, 1588, 1605, 526, 1588, 1607, 526, 1603, 1604, 526, 1603, 1605, 526, - 1604, 1605, 526, 1606, 1605, 526, 1606, 1607, 526, 1610, 1605, 526, 1610, - 1607, 782, 1600, 1614, 1617, 782, 1600, 1615, 1617, 782, 1600, 1616, - 1617, 523, 1591, 1609, 523, 1591, 1610, 523, 1593, 1609, 523, 1593, 1610, - 523, 1594, 1609, 523, 1594, 1610, 523, 1587, 1609, 523, 1587, 1610, 523, - 1588, 1609, 523, 1588, 1610, 523, 1581, 1609, 523, 1581, 1610, 523, 1580, - 1609, 523, 1580, 1610, 523, 1582, 1609, 523, 1582, 1610, 523, 1589, 1609, - 523, 1589, 1610, 523, 1590, 1609, 523, 1590, 1610, 523, 1588, 1580, 523, - 1588, 1581, 523, 1588, 1582, 523, 1588, 1605, 523, 1588, 1585, 523, 1587, - 1585, 523, 1589, 1585, 523, 1590, 1585, 524, 1591, 1609, 524, 1591, 1610, - 524, 1593, 1609, 524, 1593, 1610, 524, 1594, 1609, 524, 1594, 1610, 524, - 1587, 1609, 524, 1587, 1610, 524, 1588, 1609, 524, 1588, 1610, 524, 1581, - 1609, 524, 1581, 1610, 524, 1580, 1609, 524, 1580, 1610, 524, 1582, 1609, - 524, 1582, 1610, 524, 1589, 1609, 524, 1589, 1610, 524, 1590, 1609, 524, - 1590, 1610, 524, 1588, 1580, 524, 1588, 1581, 524, 1588, 1582, 524, 1588, - 1605, 524, 1588, 1585, 524, 1587, 1585, 524, 1589, 1585, 524, 1590, 1585, - 525, 1588, 1580, 525, 1588, 1581, 525, 1588, 1582, 525, 1588, 1605, 525, - 1587, 1607, 525, 1588, 1607, 525, 1591, 1605, 526, 1587, 1580, 526, 1587, - 1581, 526, 1587, 1582, 526, 1588, 1580, 526, 1588, 1581, 526, 1588, 1582, - 526, 1591, 1605, 526, 1592, 1605, 524, 1575, 1611, 523, 1575, 1611, 781, - 1578, 1580, 1605, 780, 1578, 1581, 1580, 781, 1578, 1581, 1580, 781, - 1578, 1581, 1605, 781, 1578, 1582, 1605, 781, 1578, 1605, 1580, 781, - 1578, 1605, 1581, 781, 1578, 1605, 1582, 780, 1580, 1605, 1581, 781, - 1580, 1605, 1581, 780, 1581, 1605, 1610, 780, 1581, 1605, 1609, 781, - 1587, 1581, 1580, 781, 1587, 1580, 1581, 780, 1587, 1580, 1609, 780, - 1587, 1605, 1581, 781, 1587, 1605, 1581, 781, 1587, 1605, 1580, 780, - 1587, 1605, 1605, 781, 1587, 1605, 1605, 780, 1589, 1581, 1581, 781, - 1589, 1581, 1581, 780, 1589, 1605, 1605, 780, 1588, 1581, 1605, 781, - 1588, 1581, 1605, 780, 1588, 1580, 1610, 780, 1588, 1605, 1582, 781, - 1588, 1605, 1582, 780, 1588, 1605, 1605, 781, 1588, 1605, 1605, 780, - 1590, 1581, 1609, 780, 1590, 1582, 1605, 781, 1590, 1582, 1605, 780, - 1591, 1605, 1581, 781, 1591, 1605, 1581, 781, 1591, 1605, 1605, 780, - 1591, 1605, 1610, 780, 1593, 1580, 1605, 780, 1593, 1605, 1605, 781, - 1593, 1605, 1605, 780, 1593, 1605, 1609, 780, 1594, 1605, 1605, 780, - 1594, 1605, 1610, 780, 1594, 1605, 1609, 780, 1601, 1582, 1605, 781, - 1601, 1582, 1605, 780, 1602, 1605, 1581, 780, 1602, 1605, 1605, 780, - 1604, 1581, 1605, 780, 1604, 1581, 1610, 780, 1604, 1581, 1609, 781, - 1604, 1580, 1580, 780, 1604, 1580, 1580, 780, 1604, 1582, 1605, 781, - 1604, 1582, 1605, 780, 1604, 1605, 1581, 781, 1604, 1605, 1581, 781, - 1605, 1581, 1580, 781, 1605, 1581, 1605, 780, 1605, 1581, 1610, 781, - 1605, 1580, 1581, 781, 1605, 1580, 1605, 781, 1605, 1582, 1580, 781, - 1605, 1582, 1605, 781, 1605, 1580, 1582, 781, 1607, 1605, 1580, 781, - 1607, 1605, 1605, 781, 1606, 1581, 1605, 780, 1606, 1581, 1609, 780, - 1606, 1580, 1605, 781, 1606, 1580, 1605, 780, 1606, 1580, 1609, 780, - 1606, 1605, 1610, 780, 1606, 1605, 1609, 780, 1610, 1605, 1605, 781, - 1610, 1605, 1605, 780, 1576, 1582, 1610, 780, 1578, 1580, 1610, 780, - 1578, 1580, 1609, 780, 1578, 1582, 1610, 780, 1578, 1582, 1609, 780, - 1578, 1605, 1610, 780, 1578, 1605, 1609, 780, 1580, 1605, 1610, 780, - 1580, 1581, 1609, 780, 1580, 1605, 1609, 780, 1587, 1582, 1609, 780, - 1589, 1581, 1610, 780, 1588, 1581, 1610, 780, 1590, 1581, 1610, 780, - 1604, 1580, 1610, 780, 1604, 1605, 1610, 780, 1610, 1581, 1610, 780, - 1610, 1580, 1610, 780, 1610, 1605, 1610, 780, 1605, 1605, 1610, 780, - 1602, 1605, 1610, 780, 1606, 1581, 1610, 781, 1602, 1605, 1581, 781, - 1604, 1581, 1605, 780, 1593, 1605, 1610, 780, 1603, 1605, 1610, 781, - 1606, 1580, 1581, 780, 1605, 1582, 1610, 781, 1604, 1580, 1605, 780, - 1603, 1605, 1605, 780, 1604, 1580, 1605, 780, 1606, 1580, 1581, 780, - 1580, 1581, 1610, 780, 1581, 1580, 1610, 780, 1605, 1580, 1610, 780, - 1601, 1605, 1610, 780, 1576, 1581, 1610, 781, 1603, 1605, 1605, 781, - 1593, 1580, 1605, 781, 1589, 1605, 1605, 780, 1587, 1582, 1610, 780, - 1606, 1580, 1610, 779, 1589, 1604, 1746, 779, 1602, 1604, 1746, 1035, - 1575, 1604, 1604, 1607, 1035, 1575, 1603, 1576, 1585, 1035, 1605, 1581, - 1605, 1583, 1035, 1589, 1604, 1593, 1605, 1035, 1585, 1587, 1608, 1604, - 1035, 1593, 1604, 1610, 1607, 1035, 1608, 1587, 1604, 1605, 779, 1589, - 1604, 1609, 4619, 1589, 1604, 1609, 32, 1575, 1604, 1604, 1607, 32, 1593, - 1604, 1610, 1607, 32, 1608, 1587, 1604, 1605, 2059, 1580, 1604, 32, 1580, - 1604, 1575, 1604, 1607, 1035, 1585, 1740, 1575, 1604, 265, 44, 265, - 12289, 265, 12290, 265, 58, 265, 59, 265, 33, 265, 63, 265, 12310, 265, - 12311, 265, 8230, 265, 8229, 265, 8212, 265, 8211, 265, 95, 265, 40, 265, - 41, 265, 123, 265, 125, 265, 12308, 265, 12309, 265, 12304, 265, 12305, - 265, 12298, 265, 12299, 265, 12296, 265, 12297, 265, 12300, 265, 12301, - 265, 12302, 265, 12303, 265, 91, 265, 93, 258, 8254, 258, 95, 271, 44, - 271, 12289, 271, 46, 271, 59, 271, 58, 271, 63, 271, 33, 271, 8212, 271, - 40, 271, 41, 271, 123, 271, 125, 271, 12308, 271, 12309, 271, 35, 271, - 38, 271, 42, 271, 43, 271, 45, 271, 60, 271, 62, 271, 61, 271, 92, 271, - 36, 271, 37, 271, 64, 523, 32, 1611, 526, 1600, 1611, 523, 32, 1612, 523, - 32, 1613, 523, 32, 1614, 526, 1600, 1614, 523, 32, 1615, 526, 1600, 1615, - 523, 32, 1616, 526, 1600, 1616, 523, 32, 1617, 526, 1600, 1617, 523, 32, - 1618, 526, 1600, 1618, 267, 1569, 267, 1570, 268, 1570, 267, 1571, 268, - 1571, 267, 1572, 268, 1572, 267, 1573, 268, 1573, 267, 1574, 268, 1574, - 269, 1574, 270, 1574, 267, 1575, 268, 1575, 267, 1576, 268, 1576, 269, - 1576, 270, 1576, 267, 1577, 268, 1577, 267, 1578, 268, 1578, 269, 1578, - 270, 1578, 267, 1579, 268, 1579, 269, 1579, 270, 1579, 267, 1580, 268, - 1580, 269, 1580, 270, 1580, 267, 1581, 268, 1581, 269, 1581, 270, 1581, - 267, 1582, 268, 1582, 269, 1582, 270, 1582, 267, 1583, 268, 1583, 267, - 1584, 268, 1584, 267, 1585, 268, 1585, 267, 1586, 268, 1586, 267, 1587, - 268, 1587, 269, 1587, 270, 1587, 267, 1588, 268, 1588, 269, 1588, 270, - 1588, 267, 1589, 268, 1589, 269, 1589, 270, 1589, 267, 1590, 268, 1590, - 269, 1590, 270, 1590, 267, 1591, 268, 1591, 269, 1591, 270, 1591, 267, - 1592, 268, 1592, 269, 1592, 270, 1592, 267, 1593, 268, 1593, 269, 1593, - 270, 1593, 267, 1594, 268, 1594, 269, 1594, 270, 1594, 267, 1601, 268, - 1601, 269, 1601, 270, 1601, 267, 1602, 268, 1602, 269, 1602, 270, 1602, - 267, 1603, 268, 1603, 269, 1603, 270, 1603, 267, 1604, 268, 1604, 269, - 1604, 270, 1604, 267, 1605, 268, 1605, 269, 1605, 270, 1605, 267, 1606, - 268, 1606, 269, 1606, 270, 1606, 267, 1607, 268, 1607, 269, 1607, 270, - 1607, 267, 1608, 268, 1608, 267, 1609, 268, 1609, 267, 1610, 268, 1610, - 269, 1610, 270, 1610, 523, 1604, 1570, 524, 1604, 1570, 523, 1604, 1571, - 524, 1604, 1571, 523, 1604, 1573, 524, 1604, 1573, 523, 1604, 1575, 524, - 1604, 1575, 264, 33, 264, 34, 264, 35, 264, 36, 264, 37, 264, 38, 264, - 39, 264, 40, 264, 41, 264, 42, 264, 43, 264, 44, 264, 45, 264, 46, 264, - 47, 264, 48, 264, 49, 264, 50, 264, 51, 264, 52, 264, 53, 264, 54, 264, - 55, 264, 56, 264, 57, 264, 58, 264, 59, 264, 60, 264, 61, 264, 62, 264, - 63, 264, 64, 264, 65, 264, 66, 264, 67, 264, 68, 264, 69, 264, 70, 264, - 71, 264, 72, 264, 73, 264, 74, 264, 75, 264, 76, 264, 77, 264, 78, 264, - 79, 264, 80, 264, 81, 264, 82, 264, 83, 264, 84, 264, 85, 264, 86, 264, - 87, 264, 88, 264, 89, 264, 90, 264, 91, 264, 92, 264, 93, 264, 94, 264, - 95, 264, 96, 264, 97, 264, 98, 264, 99, 264, 100, 264, 101, 264, 102, - 264, 103, 264, 104, 264, 105, 264, 106, 264, 107, 264, 108, 264, 109, - 264, 110, 264, 111, 264, 112, 264, 113, 264, 114, 264, 115, 264, 116, - 264, 117, 264, 118, 264, 119, 264, 120, 264, 121, 264, 122, 264, 123, - 264, 124, 264, 125, 264, 126, 264, 10629, 264, 10630, 272, 12290, 272, - 12300, 272, 12301, 272, 12289, 272, 12539, 272, 12530, 272, 12449, 272, - 12451, 272, 12453, 272, 12455, 272, 12457, 272, 12515, 272, 12517, 272, - 12519, 272, 12483, 272, 12540, 272, 12450, 272, 12452, 272, 12454, 272, - 12456, 272, 12458, 272, 12459, 272, 12461, 272, 12463, 272, 12465, 272, - 12467, 272, 12469, 272, 12471, 272, 12473, 272, 12475, 272, 12477, 272, - 12479, 272, 12481, 272, 12484, 272, 12486, 272, 12488, 272, 12490, 272, - 12491, 272, 12492, 272, 12493, 272, 12494, 272, 12495, 272, 12498, 272, - 12501, 272, 12504, 272, 12507, 272, 12510, 272, 12511, 272, 12512, 272, - 12513, 272, 12514, 272, 12516, 272, 12518, 272, 12520, 272, 12521, 272, - 12522, 272, 12523, 272, 12524, 272, 12525, 272, 12527, 272, 12531, 272, - 12441, 272, 12442, 272, 12644, 272, 12593, 272, 12594, 272, 12595, 272, - 12596, 272, 12597, 272, 12598, 272, 12599, 272, 12600, 272, 12601, 272, - 12602, 272, 12603, 272, 12604, 272, 12605, 272, 12606, 272, 12607, 272, - 12608, 272, 12609, 272, 12610, 272, 12611, 272, 12612, 272, 12613, 272, - 12614, 272, 12615, 272, 12616, 272, 12617, 272, 12618, 272, 12619, 272, - 12620, 272, 12621, 272, 12622, 272, 12623, 272, 12624, 272, 12625, 272, - 12626, 272, 12627, 272, 12628, 272, 12629, 272, 12630, 272, 12631, 272, - 12632, 272, 12633, 272, 12634, 272, 12635, 272, 12636, 272, 12637, 272, - 12638, 272, 12639, 272, 12640, 272, 12641, 272, 12642, 272, 12643, 264, - 162, 264, 163, 264, 172, 264, 175, 264, 166, 264, 165, 264, 8361, 272, - 9474, 272, 8592, 272, 8593, 272, 8594, 272, 8595, 272, 9632, 272, 9675, - 512, 67026, 775, 512, 67034, 775, 259, 720, 259, 721, 259, 230, 259, 665, - 259, 595, 259, 675, 259, 43878, 259, 677, 259, 676, 259, 598, 259, 599, - 259, 7569, 259, 600, 259, 606, 259, 681, 259, 612, 259, 610, 259, 608, - 259, 667, 259, 295, 259, 668, 259, 615, 259, 644, 259, 682, 259, 683, - 259, 620, 259, 122628, 259, 42894, 259, 622, 259, 122629, 259, 654, 259, - 122630, 259, 248, 259, 630, 259, 631, 259, 113, 259, 634, 259, 122632, - 259, 637, 259, 638, 259, 640, 259, 680, 259, 678, 259, 43879, 259, 679, - 259, 648, 259, 11377, 259, 655, 259, 673, 259, 674, 259, 664, 259, 448, - 259, 449, 259, 450, 259, 122634, 259, 122654, 512, 69785, 69818, 512, - 69787, 69818, 512, 69797, 69818, 512, 69937, 69927, 512, 69938, 69927, - 512, 70471, 70462, 512, 70471, 70487, 512, 70530, 70601, 512, 70532, - 70587, 512, 70539, 70594, 512, 70544, 70601, 512, 70594, 70594, 512, - 70594, 70584, 512, 70594, 70601, 512, 70841, 70842, 512, 70841, 70832, - 512, 70841, 70845, 512, 71096, 71087, 512, 71097, 71087, 512, 71989, - 71984, 512, 90398, 90398, 512, 90398, 90409, 512, 90398, 90399, 512, - 90409, 90399, 512, 90398, 90400, 512, 90401, 90399, 512, 90402, 90399, - 512, 90401, 90400, 512, 93543, 93543, 512, 93539, 93543, 512, 93545, - 93543, 262, 65, 262, 71, 262, 74, 262, 75, 262, 79, 262, 83, 262, 84, - 262, 85, 262, 86, 262, 87, 262, 88, 262, 89, 262, 48, 262, 49, 262, 50, - 262, 51, 262, 52, 262, 53, 262, 54, 262, 55, 262, 56, 262, 57, 512, - 119127, 119141, 512, 119128, 119141, 512, 119135, 119150, 512, 119135, - 119151, 512, 119135, 119152, 512, 119135, 119153, 512, 119135, 119154, - 512, 119225, 119141, 512, 119226, 119141, 512, 119227, 119150, 512, - 119228, 119150, 512, 119227, 119151, 512, 119228, 119151, 262, 97, 262, - 98, 262, 99, 262, 102, 262, 107, 262, 109, 262, 110, 262, 112, 262, 113, - 262, 114, 262, 115, 262, 116, 262, 117, 262, 118, 262, 119, 262, 120, - 262, 121, 262, 122, 262, 305, 262, 567, 262, 913, 262, 914, 262, 916, - 262, 917, 262, 918, 262, 919, 262, 920, 262, 921, 262, 922, 262, 923, - 262, 924, 262, 925, 262, 926, 262, 927, 262, 929, 262, 1012, 262, 931, - 262, 932, 262, 933, 262, 934, 262, 935, 262, 936, 262, 937, 262, 8711, - 262, 945, 262, 946, 262, 948, 262, 949, 262, 950, 262, 951, 262, 952, - 262, 953, 262, 954, 262, 955, 262, 956, 262, 957, 262, 958, 262, 959, - 262, 961, 262, 962, 262, 963, 262, 964, 262, 965, 262, 966, 262, 967, - 262, 968, 262, 969, 262, 8706, 262, 1013, 262, 977, 262, 1008, 262, 981, - 262, 1009, 262, 982, 262, 988, 262, 989, 259, 1072, 259, 1073, 259, 1074, - 259, 1075, 259, 1076, 259, 1077, 259, 1078, 259, 1079, 259, 1080, 259, - 1082, 259, 1083, 259, 1084, 259, 1086, 259, 1087, 259, 1088, 259, 1089, - 259, 1090, 259, 1091, 259, 1092, 259, 1093, 259, 1094, 259, 1095, 259, - 1096, 259, 1099, 259, 1101, 259, 1102, 259, 42633, 259, 1241, 259, 1110, - 259, 1112, 259, 1257, 259, 1199, 259, 1231, 261, 1072, 261, 1073, 261, - 1074, 261, 1075, 261, 1076, 261, 1077, 261, 1078, 261, 1079, 261, 1080, - 261, 1082, 261, 1083, 261, 1086, 261, 1087, 261, 1089, 261, 1091, 261, - 1092, 261, 1093, 261, 1094, 261, 1095, 261, 1096, 261, 1098, 261, 1099, - 261, 1169, 261, 1110, 261, 1109, 261, 1119, 259, 1195, 259, 42577, 259, - 1201, 262, 1575, 262, 1576, 262, 1580, 262, 1583, 262, 1608, 262, 1586, - 262, 1581, 262, 1591, 262, 1610, 262, 1603, 262, 1604, 262, 1605, 262, - 1606, 262, 1587, 262, 1593, 262, 1601, 262, 1589, 262, 1602, 262, 1585, - 262, 1588, 262, 1578, 262, 1579, 262, 1582, 262, 1584, 262, 1590, 262, - 1592, 262, 1594, 262, 1646, 262, 1722, 262, 1697, 262, 1647, 262, 1607, - 514, 48, 46, 514, 48, 44, 514, 49, 44, 514, 50, 44, 514, 51, 44, 514, 52, - 44, 514, 53, 44, 514, 54, 44, 514, 55, 44, 514, 56, 44, 514, 57, 44, 770, - 40, 65, 41, 770, 40, 66, 41, 770, 40, 67, 41, 770, 40, 68, 41, 770, 40, - 69, 41, 770, 40, 70, 41, 770, 40, 71, 41, 770, 40, 72, 41, 770, 40, 73, - 41, 770, 40, 74, 41, 770, 40, 75, 41, 770, 40, 76, 41, 770, 40, 77, 41, - 770, 40, 78, 41, 770, 40, 79, 41, 770, 40, 80, 41, 770, 40, 81, 41, 770, - 40, 82, 41, 770, 40, 83, 41, 770, 40, 84, 41, 770, 40, 85, 41, 770, 40, - 86, 41, 770, 40, 87, 41, 770, 40, 88, 41, 770, 40, 89, 41, 770, 40, 90, - 41, 770, 12308, 83, 12309, 519, 67, 68, 519, 87, 90, 266, 65, 266, 66, - 266, 67, 266, 68, 266, 69, 266, 70, 266, 71, 266, 72, 266, 73, 266, 74, - 266, 75, 266, 76, 266, 77, 266, 78, 266, 79, 266, 80, 266, 81, 266, 82, - 266, 83, 266, 84, 266, 85, 266, 86, 266, 87, 266, 88, 266, 89, 266, 90, - 522, 72, 86, 522, 83, 68, 522, 83, 83, 778, 80, 80, 86, 522, 87, 67, 515, - 77, 67, 515, 77, 68, 515, 77, 82, 522, 68, 74, 522, 12411, 12363, 522, - 12467, 12467, 266, 12469, 266, 25163, 266, 23383, 266, 21452, 266, 12487, - 266, 20108, 266, 22810, 266, 35299, 266, 22825, 266, 20132, 266, 26144, - 266, 28961, 266, 26009, 266, 21069, 266, 24460, 266, 20877, 266, 26032, - 266, 21021, 266, 32066, 266, 29983, 266, 36009, 266, 22768, 266, 21561, - 266, 28436, 266, 25237, 266, 25429, 266, 19968, 266, 19977, 266, 36938, - 266, 24038, 266, 20013, 266, 21491, 266, 25351, 266, 36208, 266, 25171, - 266, 31105, 266, 31354, 266, 21512, 266, 28288, 266, 26377, 266, 26376, - 266, 30003, 266, 21106, 266, 21942, 266, 37197, 770, 12308, 26412, 12309, - 770, 12308, 19977, 12309, 770, 12308, 20108, 12309, 770, 12308, 23433, - 12309, 770, 12308, 28857, 12309, 770, 12308, 25171, 12309, 770, 12308, - 30423, 12309, 770, 12308, 21213, 12309, 770, 12308, 25943, 12309, 263, - 24471, 263, 21487, 256, 20029, 256, 20024, 256, 20033, 256, 131362, 256, - 20320, 256, 20411, 256, 20482, 256, 20602, 256, 20633, 256, 20687, 256, - 13470, 256, 132666, 256, 20820, 256, 20836, 256, 20855, 256, 132380, 256, - 13497, 256, 20839, 256, 20877, 256, 132427, 256, 20887, 256, 20900, 256, - 20172, 256, 20908, 256, 168415, 256, 20981, 256, 20995, 256, 13535, 256, - 21051, 256, 21062, 256, 21106, 256, 21111, 256, 13589, 256, 21253, 256, - 21254, 256, 21321, 256, 21338, 256, 21363, 256, 21373, 256, 21375, 256, - 133676, 256, 28784, 256, 21450, 256, 21471, 256, 133987, 256, 21483, 256, - 21489, 256, 21510, 256, 21662, 256, 21560, 256, 21576, 256, 21608, 256, - 21666, 256, 21750, 256, 21776, 256, 21843, 256, 21859, 256, 21892, 256, - 21931, 256, 21939, 256, 21954, 256, 22294, 256, 22295, 256, 22097, 256, - 22132, 256, 22766, 256, 22478, 256, 22516, 256, 22541, 256, 22411, 256, - 22578, 256, 22577, 256, 22700, 256, 136420, 256, 22770, 256, 22775, 256, - 22790, 256, 22810, 256, 22818, 256, 22882, 256, 136872, 256, 136938, 256, - 23020, 256, 23067, 256, 23079, 256, 23000, 256, 23142, 256, 14062, 256, - 14076, 256, 23304, 256, 23358, 256, 137672, 256, 23491, 256, 23512, 256, - 23539, 256, 138008, 256, 23551, 256, 23558, 256, 24403, 256, 23586, 256, - 14209, 256, 23648, 256, 23744, 256, 23693, 256, 138724, 256, 23875, 256, - 138726, 256, 23918, 256, 23915, 256, 23932, 256, 24033, 256, 24034, 256, - 14383, 256, 24061, 256, 24104, 256, 24125, 256, 24169, 256, 14434, 256, - 139651, 256, 14460, 256, 24240, 256, 24243, 256, 24246, 256, 172946, 256, - 24318, 256, 140081, 256, 33281, 256, 24354, 256, 14535, 256, 144056, 256, - 156122, 256, 24418, 256, 24427, 256, 14563, 256, 24474, 256, 24525, 256, - 24535, 256, 24569, 256, 24705, 256, 14650, 256, 14620, 256, 141012, 256, - 24775, 256, 24904, 256, 24908, 256, 24954, 256, 25010, 256, 24996, 256, - 25007, 256, 25054, 256, 25104, 256, 25115, 256, 25181, 256, 25265, 256, - 25300, 256, 25424, 256, 142092, 256, 25405, 256, 25340, 256, 25448, 256, - 25475, 256, 25572, 256, 142321, 256, 25634, 256, 25541, 256, 25513, 256, - 14894, 256, 25705, 256, 25726, 256, 25757, 256, 25719, 256, 14956, 256, - 25964, 256, 143370, 256, 26083, 256, 26360, 256, 26185, 256, 15129, 256, - 15112, 256, 15076, 256, 20882, 256, 20885, 256, 26368, 256, 26268, 256, - 32941, 256, 17369, 256, 26401, 256, 26462, 256, 26451, 256, 144323, 256, - 15177, 256, 26618, 256, 26501, 256, 26706, 256, 144493, 256, 26766, 256, - 26655, 256, 26900, 256, 26946, 256, 27043, 256, 27114, 256, 27304, 256, - 145059, 256, 27355, 256, 15384, 256, 27425, 256, 145575, 256, 27476, 256, - 15438, 256, 27506, 256, 27551, 256, 27579, 256, 146061, 256, 138507, 256, - 146170, 256, 27726, 256, 146620, 256, 27839, 256, 27853, 256, 27751, 256, - 27926, 256, 27966, 256, 28009, 256, 28024, 256, 28037, 256, 146718, 256, - 27956, 256, 28207, 256, 28270, 256, 15667, 256, 28359, 256, 147153, 256, - 28153, 256, 28526, 256, 147294, 256, 147342, 256, 28614, 256, 28729, 256, - 28699, 256, 15766, 256, 28746, 256, 28797, 256, 28791, 256, 28845, 256, - 132389, 256, 28997, 256, 148067, 256, 29084, 256, 148395, 256, 29224, - 256, 29264, 256, 149000, 256, 29312, 256, 29333, 256, 149301, 256, - 149524, 256, 29562, 256, 29579, 256, 16044, 256, 29605, 256, 16056, 256, - 29767, 256, 29788, 256, 29829, 256, 29898, 256, 16155, 256, 29988, 256, - 150582, 256, 30014, 256, 150674, 256, 139679, 256, 30224, 256, 151457, - 256, 151480, 256, 151620, 256, 16380, 256, 16392, 256, 151795, 256, - 151794, 256, 151833, 256, 151859, 256, 30494, 256, 30495, 256, 30603, - 256, 16454, 256, 16534, 256, 152605, 256, 30798, 256, 16611, 256, 153126, - 256, 153242, 256, 153285, 256, 31211, 256, 16687, 256, 31306, 256, 31311, - 256, 153980, 256, 154279, 256, 31470, 256, 16898, 256, 154539, 256, - 31686, 256, 31689, 256, 16935, 256, 154752, 256, 31954, 256, 17056, 256, - 31976, 256, 31971, 256, 32000, 256, 155526, 256, 32099, 256, 17153, 256, - 32199, 256, 32258, 256, 32325, 256, 17204, 256, 156200, 256, 156231, 256, - 17241, 256, 156377, 256, 32634, 256, 156478, 256, 32661, 256, 32762, 256, - 156890, 256, 156963, 256, 32864, 256, 157096, 256, 32880, 256, 144223, - 256, 17365, 256, 32946, 256, 33027, 256, 17419, 256, 33086, 256, 23221, - 256, 157607, 256, 157621, 256, 144275, 256, 144284, 256, 33284, 256, - 36766, 256, 17515, 256, 33425, 256, 33419, 256, 33437, 256, 21171, 256, - 33457, 256, 33459, 256, 33469, 256, 33510, 256, 158524, 256, 33565, 256, - 33635, 256, 33709, 256, 33571, 256, 33725, 256, 33767, 256, 33619, 256, - 33738, 256, 33740, 256, 33756, 256, 158774, 256, 159083, 256, 158933, - 256, 17707, 256, 34033, 256, 34035, 256, 34070, 256, 160714, 256, 34148, - 256, 159532, 256, 17757, 256, 17761, 256, 159665, 256, 159954, 256, - 17771, 256, 34384, 256, 34407, 256, 34409, 256, 34473, 256, 34440, 256, - 34574, 256, 34530, 256, 34600, 256, 34667, 256, 34694, 256, 17879, 256, - 34785, 256, 34817, 256, 17913, 256, 34912, 256, 34915, 256, 161383, 256, - 35031, 256, 35038, 256, 17973, 256, 35066, 256, 13499, 256, 161966, 256, - 162150, 256, 18110, 256, 18119, 256, 35488, 256, 35925, 256, 162984, 256, - 36011, 256, 36033, 256, 36123, 256, 36215, 256, 163631, 256, 133124, 256, - 36299, 256, 36284, 256, 36336, 256, 133342, 256, 36564, 256, 165330, 256, - 165357, 256, 37012, 256, 37105, 256, 37137, 256, 165678, 256, 37147, 256, - 37432, 256, 37591, 256, 37592, 256, 37500, 256, 37881, 256, 37909, 256, - 166906, 256, 38283, 256, 18837, 256, 38327, 256, 167287, 256, 18918, 256, - 38595, 256, 23986, 256, 38691, 256, 168261, 256, 168474, 256, 19054, 256, - 19062, 256, 38880, 256, 168970, 256, 19122, 256, 169110, 256, 38953, 256, - 169398, 256, 39138, 256, 19251, 256, 39209, 256, 39335, 256, 39362, 256, - 39422, 256, 19406, 256, 170800, 256, 40000, 256, 40189, 256, 19662, 256, - 19693, 256, 40295, 256, 172238, 256, 19704, 256, 172293, 256, 172558, - 256, 172689, 256, 40635, 256, 19798, 256, 40697, 256, 40702, 256, 40709, - 256, 40719, 256, 40726, 256, 40763, 256, 173568, + 1099, 776, 259, 1383, 514, 1381, 1410, 259, 1387, 259, 1397, 512, 1575, + 1619, 512, 1575, 1620, 512, 1608, 1620, 512, 1575, 1621, 512, 1610, 1620, + 514, 1575, 1652, 514, 1608, 1652, 514, 1735, 1652, 514, 1610, 1652, 512, + 1749, 1620, 512, 1729, 1620, 512, 1746, 1620, 512, 2344, 2364, 512, 2352, + 2364, 512, 2355, 2364, 512, 2325, 2364, 512, 2326, 2364, 512, 2327, 2364, + 512, 2332, 2364, 512, 2337, 2364, 512, 2338, 2364, 512, 2347, 2364, 512, + 2351, 2364, 512, 2503, 2494, 512, 2503, 2519, 512, 2465, 2492, 512, 2466, + 2492, 512, 2479, 2492, 512, 2610, 2620, 512, 2616, 2620, 512, 2582, 2620, + 512, 2583, 2620, 512, 2588, 2620, 512, 2603, 2620, 512, 2887, 2902, 512, + 2887, 2878, 512, 2887, 2903, 512, 2849, 2876, 512, 2850, 2876, 512, 2962, + 3031, 512, 3014, 3006, 512, 3015, 3006, 512, 3014, 3031, 512, 3142, 3158, + 512, 3263, 3285, 512, 3270, 3285, 512, 3270, 3286, 512, 3270, 3266, 512, + 3274, 3285, 512, 3398, 3390, 512, 3399, 3390, 512, 3398, 3415, 512, 3545, + 3530, 512, 3545, 3535, 512, 3548, 3530, 512, 3545, 3551, 514, 3661, 3634, + 514, 3789, 3762, 514, 3755, 3737, 514, 3755, 3745, 257, 3851, 512, 3906, + 4023, 512, 3916, 4023, 512, 3921, 4023, 512, 3926, 4023, 512, 3931, 4023, + 512, 3904, 4021, 512, 3953, 3954, 512, 3953, 3956, 512, 4018, 3968, 514, + 4018, 3969, 512, 4019, 3968, 514, 4019, 3969, 512, 3953, 3968, 512, 3986, + 4023, 512, 3996, 4023, 512, 4001, 4023, 512, 4006, 4023, 512, 4011, 4023, + 512, 3984, 4021, 512, 4133, 4142, 259, 4316, 512, 6917, 6965, 512, 6919, + 6965, 512, 6921, 6965, 512, 6923, 6965, 512, 6925, 6965, 512, 6929, 6965, + 512, 6970, 6965, 512, 6972, 6965, 512, 6974, 6965, 512, 6975, 6965, 512, + 6978, 6965, 259, 65, 259, 198, 259, 66, 259, 68, 259, 69, 259, 398, 259, + 71, 259, 72, 259, 73, 259, 74, 259, 75, 259, 76, 259, 77, 259, 78, 259, + 79, 259, 546, 259, 80, 259, 82, 259, 84, 259, 85, 259, 87, 259, 592, 259, + 593, 259, 7426, 259, 98, 259, 100, 259, 101, 259, 601, 259, 603, 259, + 604, 259, 103, 259, 107, 259, 109, 259, 331, 259, 596, 259, 7446, 259, + 7447, 259, 112, 259, 116, 259, 117, 259, 7453, 259, 623, 259, 118, 259, + 7461, 259, 946, 259, 947, 259, 948, 259, 966, 259, 967, 261, 105, 261, + 114, 261, 117, 261, 118, 261, 946, 261, 947, 261, 961, 261, 966, 261, + 967, 259, 1085, 259, 594, 259, 99, 259, 597, 259, 240, 259, 102, 259, + 607, 259, 609, 259, 613, 259, 616, 259, 617, 259, 618, 259, 7547, 259, + 669, 259, 621, 259, 7557, 259, 671, 259, 625, 259, 624, 259, 626, 259, + 627, 259, 628, 259, 629, 259, 632, 259, 642, 259, 643, 259, 427, 259, + 649, 259, 650, 259, 7452, 259, 651, 259, 652, 259, 122, 259, 656, 259, + 657, 259, 658, 259, 952, 512, 65, 805, 512, 97, 805, 512, 66, 775, 512, + 98, 775, 512, 66, 803, 512, 98, 803, 512, 66, 817, 512, 98, 817, 512, + 199, 769, 512, 231, 769, 512, 68, 775, 512, 100, 775, 512, 68, 803, 512, + 100, 803, 512, 68, 817, 512, 100, 817, 512, 68, 807, 512, 100, 807, 512, + 68, 813, 512, 100, 813, 512, 274, 768, 512, 275, 768, 512, 274, 769, 512, + 275, 769, 512, 69, 813, 512, 101, 813, 512, 69, 816, 512, 101, 816, 512, + 552, 774, 512, 553, 774, 512, 70, 775, 512, 102, 775, 512, 71, 772, 512, + 103, 772, 512, 72, 775, 512, 104, 775, 512, 72, 803, 512, 104, 803, 512, + 72, 776, 512, 104, 776, 512, 72, 807, 512, 104, 807, 512, 72, 814, 512, + 104, 814, 512, 73, 816, 512, 105, 816, 512, 207, 769, 512, 239, 769, 512, + 75, 769, 512, 107, 769, 512, 75, 803, 512, 107, 803, 512, 75, 817, 512, + 107, 817, 512, 76, 803, 512, 108, 803, 512, 7734, 772, 512, 7735, 772, + 512, 76, 817, 512, 108, 817, 512, 76, 813, 512, 108, 813, 512, 77, 769, + 512, 109, 769, 512, 77, 775, 512, 109, 775, 512, 77, 803, 512, 109, 803, + 512, 78, 775, 512, 110, 775, 512, 78, 803, 512, 110, 803, 512, 78, 817, + 512, 110, 817, 512, 78, 813, 512, 110, 813, 512, 213, 769, 512, 245, 769, + 512, 213, 776, 512, 245, 776, 512, 332, 768, 512, 333, 768, 512, 332, + 769, 512, 333, 769, 512, 80, 769, 512, 112, 769, 512, 80, 775, 512, 112, + 775, 512, 82, 775, 512, 114, 775, 512, 82, 803, 512, 114, 803, 512, 7770, + 772, 512, 7771, 772, 512, 82, 817, 512, 114, 817, 512, 83, 775, 512, 115, + 775, 512, 83, 803, 512, 115, 803, 512, 346, 775, 512, 347, 775, 512, 352, + 775, 512, 353, 775, 512, 7778, 775, 512, 7779, 775, 512, 84, 775, 512, + 116, 775, 512, 84, 803, 512, 116, 803, 512, 84, 817, 512, 116, 817, 512, + 84, 813, 512, 116, 813, 512, 85, 804, 512, 117, 804, 512, 85, 816, 512, + 117, 816, 512, 85, 813, 512, 117, 813, 512, 360, 769, 512, 361, 769, 512, + 362, 776, 512, 363, 776, 512, 86, 771, 512, 118, 771, 512, 86, 803, 512, + 118, 803, 512, 87, 768, 512, 119, 768, 512, 87, 769, 512, 119, 769, 512, + 87, 776, 512, 119, 776, 512, 87, 775, 512, 119, 775, 512, 87, 803, 512, + 119, 803, 512, 88, 775, 512, 120, 775, 512, 88, 776, 512, 120, 776, 512, + 89, 775, 512, 121, 775, 512, 90, 770, 512, 122, 770, 512, 90, 803, 512, + 122, 803, 512, 90, 817, 512, 122, 817, 512, 104, 817, 512, 116, 776, 512, + 119, 778, 512, 121, 778, 514, 97, 702, 512, 383, 775, 512, 65, 803, 512, + 97, 803, 512, 65, 777, 512, 97, 777, 512, 194, 769, 512, 226, 769, 512, + 194, 768, 512, 226, 768, 512, 194, 777, 512, 226, 777, 512, 194, 771, + 512, 226, 771, 512, 7840, 770, 512, 7841, 770, 512, 258, 769, 512, 259, + 769, 512, 258, 768, 512, 259, 768, 512, 258, 777, 512, 259, 777, 512, + 258, 771, 512, 259, 771, 512, 7840, 774, 512, 7841, 774, 512, 69, 803, + 512, 101, 803, 512, 69, 777, 512, 101, 777, 512, 69, 771, 512, 101, 771, + 512, 202, 769, 512, 234, 769, 512, 202, 768, 512, 234, 768, 512, 202, + 777, 512, 234, 777, 512, 202, 771, 512, 234, 771, 512, 7864, 770, 512, + 7865, 770, 512, 73, 777, 512, 105, 777, 512, 73, 803, 512, 105, 803, 512, + 79, 803, 512, 111, 803, 512, 79, 777, 512, 111, 777, 512, 212, 769, 512, + 244, 769, 512, 212, 768, 512, 244, 768, 512, 212, 777, 512, 244, 777, + 512, 212, 771, 512, 244, 771, 512, 7884, 770, 512, 7885, 770, 512, 416, + 769, 512, 417, 769, 512, 416, 768, 512, 417, 768, 512, 416, 777, 512, + 417, 777, 512, 416, 771, 512, 417, 771, 512, 416, 803, 512, 417, 803, + 512, 85, 803, 512, 117, 803, 512, 85, 777, 512, 117, 777, 512, 431, 769, + 512, 432, 769, 512, 431, 768, 512, 432, 768, 512, 431, 777, 512, 432, + 777, 512, 431, 771, 512, 432, 771, 512, 431, 803, 512, 432, 803, 512, 89, + 768, 512, 121, 768, 512, 89, 803, 512, 121, 803, 512, 89, 777, 512, 121, + 777, 512, 89, 771, 512, 121, 771, 512, 945, 787, 512, 945, 788, 512, + 7936, 768, 512, 7937, 768, 512, 7936, 769, 512, 7937, 769, 512, 7936, + 834, 512, 7937, 834, 512, 913, 787, 512, 913, 788, 512, 7944, 768, 512, + 7945, 768, 512, 7944, 769, 512, 7945, 769, 512, 7944, 834, 512, 7945, + 834, 512, 949, 787, 512, 949, 788, 512, 7952, 768, 512, 7953, 768, 512, + 7952, 769, 512, 7953, 769, 512, 917, 787, 512, 917, 788, 512, 7960, 768, + 512, 7961, 768, 512, 7960, 769, 512, 7961, 769, 512, 951, 787, 512, 951, + 788, 512, 7968, 768, 512, 7969, 768, 512, 7968, 769, 512, 7969, 769, 512, + 7968, 834, 512, 7969, 834, 512, 919, 787, 512, 919, 788, 512, 7976, 768, + 512, 7977, 768, 512, 7976, 769, 512, 7977, 769, 512, 7976, 834, 512, + 7977, 834, 512, 953, 787, 512, 953, 788, 512, 7984, 768, 512, 7985, 768, + 512, 7984, 769, 512, 7985, 769, 512, 7984, 834, 512, 7985, 834, 512, 921, + 787, 512, 921, 788, 512, 7992, 768, 512, 7993, 768, 512, 7992, 769, 512, + 7993, 769, 512, 7992, 834, 512, 7993, 834, 512, 959, 787, 512, 959, 788, + 512, 8000, 768, 512, 8001, 768, 512, 8000, 769, 512, 8001, 769, 512, 927, + 787, 512, 927, 788, 512, 8008, 768, 512, 8009, 768, 512, 8008, 769, 512, + 8009, 769, 512, 965, 787, 512, 965, 788, 512, 8016, 768, 512, 8017, 768, + 512, 8016, 769, 512, 8017, 769, 512, 8016, 834, 512, 8017, 834, 512, 933, + 788, 512, 8025, 768, 512, 8025, 769, 512, 8025, 834, 512, 969, 787, 512, + 969, 788, 512, 8032, 768, 512, 8033, 768, 512, 8032, 769, 512, 8033, 769, + 512, 8032, 834, 512, 8033, 834, 512, 937, 787, 512, 937, 788, 512, 8040, + 768, 512, 8041, 768, 512, 8040, 769, 512, 8041, 769, 512, 8040, 834, 512, + 8041, 834, 512, 945, 768, 256, 940, 512, 949, 768, 256, 941, 512, 951, + 768, 256, 942, 512, 953, 768, 256, 943, 512, 959, 768, 256, 972, 512, + 965, 768, 256, 973, 512, 969, 768, 256, 974, 512, 7936, 837, 512, 7937, + 837, 512, 7938, 837, 512, 7939, 837, 512, 7940, 837, 512, 7941, 837, 512, + 7942, 837, 512, 7943, 837, 512, 7944, 837, 512, 7945, 837, 512, 7946, + 837, 512, 7947, 837, 512, 7948, 837, 512, 7949, 837, 512, 7950, 837, 512, + 7951, 837, 512, 7968, 837, 512, 7969, 837, 512, 7970, 837, 512, 7971, + 837, 512, 7972, 837, 512, 7973, 837, 512, 7974, 837, 512, 7975, 837, 512, + 7976, 837, 512, 7977, 837, 512, 7978, 837, 512, 7979, 837, 512, 7980, + 837, 512, 7981, 837, 512, 7982, 837, 512, 7983, 837, 512, 8032, 837, 512, + 8033, 837, 512, 8034, 837, 512, 8035, 837, 512, 8036, 837, 512, 8037, + 837, 512, 8038, 837, 512, 8039, 837, 512, 8040, 837, 512, 8041, 837, 512, + 8042, 837, 512, 8043, 837, 512, 8044, 837, 512, 8045, 837, 512, 8046, + 837, 512, 8047, 837, 512, 945, 774, 512, 945, 772, 512, 8048, 837, 512, + 945, 837, 512, 940, 837, 512, 945, 834, 512, 8118, 837, 512, 913, 774, + 512, 913, 772, 512, 913, 768, 256, 902, 512, 913, 837, 514, 32, 787, 256, + 953, 514, 32, 834, 512, 168, 834, 512, 8052, 837, 512, 951, 837, 512, + 942, 837, 512, 951, 834, 512, 8134, 837, 512, 917, 768, 256, 904, 512, + 919, 768, 256, 905, 512, 919, 837, 512, 8127, 768, 512, 8127, 769, 512, + 8127, 834, 512, 953, 774, 512, 953, 772, 512, 970, 768, 256, 912, 512, + 953, 834, 512, 970, 834, 512, 921, 774, 512, 921, 772, 512, 921, 768, + 256, 906, 512, 8190, 768, 512, 8190, 769, 512, 8190, 834, 512, 965, 774, + 512, 965, 772, 512, 971, 768, 256, 944, 512, 961, 787, 512, 961, 788, + 512, 965, 834, 512, 971, 834, 512, 933, 774, 512, 933, 772, 512, 933, + 768, 256, 910, 512, 929, 788, 512, 168, 768, 256, 901, 256, 96, 512, + 8060, 837, 512, 969, 837, 512, 974, 837, 512, 969, 834, 512, 8182, 837, + 512, 927, 768, 256, 908, 512, 937, 768, 256, 911, 512, 937, 837, 256, + 180, 514, 32, 788, 256, 8194, 256, 8195, 258, 32, 257, 8208, 514, 32, + 819, 258, 46, 514, 46, 46, 770, 46, 46, 46, 514, 8242, 8242, 770, 8242, + 8242, 8242, 514, 8245, 8245, 770, 8245, 8245, 8245, 514, 33, 33, 514, 32, + 773, 514, 63, 63, 514, 63, 33, 514, 33, 63, 1026, 8242, 8242, 8242, 8242, + 259, 48, 259, 105, 259, 52, 259, 53, 259, 54, 259, 55, 259, 56, 259, 57, + 259, 43, 259, 8722, 259, 61, 259, 40, 259, 41, 259, 110, 261, 48, 261, + 49, 261, 50, 261, 51, 261, 52, 261, 53, 261, 54, 261, 55, 261, 56, 261, + 57, 261, 43, 261, 8722, 261, 61, 261, 40, 261, 41, 261, 97, 261, 101, + 261, 111, 261, 120, 261, 601, 261, 104, 261, 107, 261, 108, 261, 109, + 261, 110, 261, 112, 261, 115, 261, 116, 261, 119, 261, 121, 261, 122, + 514, 82, 115, 770, 97, 47, 99, 770, 97, 47, 115, 262, 67, 514, 176, 67, + 770, 99, 47, 111, 770, 99, 47, 117, 258, 400, 514, 176, 70, 262, 103, + 262, 72, 262, 104, 262, 295, 262, 73, 262, 76, 262, 108, 262, 78, 514, + 78, 111, 262, 80, 262, 81, 262, 82, 515, 83, 77, 770, 84, 69, 76, 515, + 84, 77, 262, 90, 256, 937, 256, 75, 256, 197, 262, 66, 262, 101, 262, 69, + 262, 70, 262, 77, 262, 111, 258, 1488, 258, 1489, 258, 1490, 258, 1491, + 262, 105, 770, 70, 65, 88, 262, 960, 262, 947, 262, 915, 262, 928, 262, + 8721, 262, 68, 262, 100, 262, 106, 772, 49, 8260, 55, 772, 49, 8260, 57, + 1028, 49, 8260, 49, 48, 772, 49, 8260, 51, 772, 50, 8260, 51, 772, 49, + 8260, 53, 772, 50, 8260, 53, 772, 51, 8260, 53, 772, 52, 8260, 53, 772, + 49, 8260, 54, 772, 53, 8260, 54, 772, 49, 8260, 56, 772, 51, 8260, 56, + 772, 53, 8260, 56, 772, 55, 8260, 56, 516, 49, 8260, 258, 73, 514, 73, + 73, 770, 73, 73, 73, 514, 73, 86, 258, 86, 514, 86, 73, 770, 86, 73, 73, + 1026, 86, 73, 73, 73, 514, 73, 88, 258, 88, 514, 88, 73, 770, 88, 73, 73, + 258, 76, 258, 67, 258, 68, 258, 77, 258, 105, 514, 105, 105, 770, 105, + 105, 105, 514, 105, 118, 258, 118, 514, 118, 105, 770, 118, 105, 105, + 1026, 118, 105, 105, 105, 514, 105, 120, 258, 120, 514, 120, 105, 770, + 120, 105, 105, 258, 108, 258, 99, 258, 100, 258, 109, 772, 48, 8260, 51, + 512, 8592, 824, 512, 8594, 824, 512, 8596, 824, 512, 8656, 824, 512, + 8660, 824, 512, 8658, 824, 512, 8707, 824, 512, 8712, 824, 512, 8715, + 824, 512, 8739, 824, 512, 8741, 824, 514, 8747, 8747, 770, 8747, 8747, + 8747, 514, 8750, 8750, 770, 8750, 8750, 8750, 512, 8764, 824, 512, 8771, + 824, 512, 8773, 824, 512, 8776, 824, 512, 61, 824, 512, 8801, 824, 512, + 8781, 824, 512, 60, 824, 512, 62, 824, 512, 8804, 824, 512, 8805, 824, + 512, 8818, 824, 512, 8819, 824, 512, 8822, 824, 512, 8823, 824, 512, + 8826, 824, 512, 8827, 824, 512, 8834, 824, 512, 8835, 824, 512, 8838, + 824, 512, 8839, 824, 512, 8866, 824, 512, 8872, 824, 512, 8873, 824, 512, + 8875, 824, 512, 8828, 824, 512, 8829, 824, 512, 8849, 824, 512, 8850, + 824, 512, 8882, 824, 512, 8883, 824, 512, 8884, 824, 512, 8885, 824, 256, + 12296, 256, 12297, 263, 49, 263, 50, 263, 51, 263, 52, 263, 53, 263, 54, + 263, 55, 263, 56, 263, 57, 519, 49, 48, 519, 49, 49, 519, 49, 50, 519, + 49, 51, 519, 49, 52, 519, 49, 53, 519, 49, 54, 519, 49, 55, 519, 49, 56, + 519, 49, 57, 519, 50, 48, 770, 40, 49, 41, 770, 40, 50, 41, 770, 40, 51, + 41, 770, 40, 52, 41, 770, 40, 53, 41, 770, 40, 54, 41, 770, 40, 55, 41, + 770, 40, 56, 41, 770, 40, 57, 41, 1026, 40, 49, 48, 41, 1026, 40, 49, 49, + 41, 1026, 40, 49, 50, 41, 1026, 40, 49, 51, 41, 1026, 40, 49, 52, 41, + 1026, 40, 49, 53, 41, 1026, 40, 49, 54, 41, 1026, 40, 49, 55, 41, 1026, + 40, 49, 56, 41, 1026, 40, 49, 57, 41, 1026, 40, 50, 48, 41, 514, 49, 46, + 514, 50, 46, 514, 51, 46, 514, 52, 46, 514, 53, 46, 514, 54, 46, 514, 55, + 46, 514, 56, 46, 514, 57, 46, 770, 49, 48, 46, 770, 49, 49, 46, 770, 49, + 50, 46, 770, 49, 51, 46, 770, 49, 52, 46, 770, 49, 53, 46, 770, 49, 54, + 46, 770, 49, 55, 46, 770, 49, 56, 46, 770, 49, 57, 46, 770, 50, 48, 46, + 770, 40, 97, 41, 770, 40, 98, 41, 770, 40, 99, 41, 770, 40, 100, 41, 770, + 40, 101, 41, 770, 40, 102, 41, 770, 40, 103, 41, 770, 40, 104, 41, 770, + 40, 105, 41, 770, 40, 106, 41, 770, 40, 107, 41, 770, 40, 108, 41, 770, + 40, 109, 41, 770, 40, 110, 41, 770, 40, 111, 41, 770, 40, 112, 41, 770, + 40, 113, 41, 770, 40, 114, 41, 770, 40, 115, 41, 770, 40, 116, 41, 770, + 40, 117, 41, 770, 40, 118, 41, 770, 40, 119, 41, 770, 40, 120, 41, 770, + 40, 121, 41, 770, 40, 122, 41, 263, 65, 263, 66, 263, 67, 263, 68, 263, + 69, 263, 70, 263, 71, 263, 72, 263, 73, 263, 74, 263, 75, 263, 76, 263, + 77, 263, 78, 263, 79, 263, 80, 263, 81, 263, 82, 263, 83, 263, 84, 263, + 85, 263, 86, 263, 87, 263, 88, 263, 89, 263, 90, 263, 97, 263, 98, 263, + 99, 263, 100, 263, 101, 263, 102, 263, 103, 263, 104, 263, 105, 263, 106, + 263, 107, 263, 108, 263, 109, 263, 110, 263, 111, 263, 112, 263, 113, + 263, 114, 263, 115, 263, 116, 263, 117, 263, 118, 263, 119, 263, 120, + 263, 121, 263, 122, 263, 48, 1026, 8747, 8747, 8747, 8747, 770, 58, 58, + 61, 514, 61, 61, 770, 61, 61, 61, 512, 10973, 824, 261, 106, 259, 86, + 259, 11617, 258, 27597, 258, 40863, 258, 19968, 258, 20008, 258, 20022, + 258, 20031, 258, 20057, 258, 20101, 258, 20108, 258, 20128, 258, 20154, + 258, 20799, 258, 20837, 258, 20843, 258, 20866, 258, 20886, 258, 20907, + 258, 20960, 258, 20981, 258, 20992, 258, 21147, 258, 21241, 258, 21269, + 258, 21274, 258, 21304, 258, 21313, 258, 21340, 258, 21353, 258, 21378, + 258, 21430, 258, 21448, 258, 21475, 258, 22231, 258, 22303, 258, 22763, + 258, 22786, 258, 22794, 258, 22805, 258, 22823, 258, 22899, 258, 23376, + 258, 23424, 258, 23544, 258, 23567, 258, 23586, 258, 23608, 258, 23662, + 258, 23665, 258, 24027, 258, 24037, 258, 24049, 258, 24062, 258, 24178, + 258, 24186, 258, 24191, 258, 24308, 258, 24318, 258, 24331, 258, 24339, + 258, 24400, 258, 24417, 258, 24435, 258, 24515, 258, 25096, 258, 25142, + 258, 25163, 258, 25903, 258, 25908, 258, 25991, 258, 26007, 258, 26020, + 258, 26041, 258, 26080, 258, 26085, 258, 26352, 258, 26376, 258, 26408, + 258, 27424, 258, 27490, 258, 27513, 258, 27571, 258, 27595, 258, 27604, + 258, 27611, 258, 27663, 258, 27668, 258, 27700, 258, 28779, 258, 29226, + 258, 29238, 258, 29243, 258, 29247, 258, 29255, 258, 29273, 258, 29275, + 258, 29356, 258, 29572, 258, 29577, 258, 29916, 258, 29926, 258, 29976, + 258, 29983, 258, 29992, 258, 30000, 258, 30091, 258, 30098, 258, 30326, + 258, 30333, 258, 30382, 258, 30399, 258, 30446, 258, 30683, 258, 30690, + 258, 30707, 258, 31034, 258, 31160, 258, 31166, 258, 31348, 258, 31435, + 258, 31481, 258, 31859, 258, 31992, 258, 32566, 258, 32593, 258, 32650, + 258, 32701, 258, 32769, 258, 32780, 258, 32786, 258, 32819, 258, 32895, + 258, 32905, 258, 33251, 258, 33258, 258, 33267, 258, 33276, 258, 33292, + 258, 33307, 258, 33311, 258, 33390, 258, 33394, 258, 33400, 258, 34381, + 258, 34411, 258, 34880, 258, 34892, 258, 34915, 258, 35198, 258, 35211, + 258, 35282, 258, 35328, 258, 35895, 258, 35910, 258, 35925, 258, 35960, + 258, 35997, 258, 36196, 258, 36208, 258, 36275, 258, 36523, 258, 36554, + 258, 36763, 258, 36784, 258, 36789, 258, 37009, 258, 37193, 258, 37318, + 258, 37324, 258, 37329, 258, 38263, 258, 38272, 258, 38428, 258, 38582, + 258, 38585, 258, 38632, 258, 38737, 258, 38750, 258, 38754, 258, 38761, + 258, 38859, 258, 38893, 258, 38899, 258, 38913, 258, 39080, 258, 39131, + 258, 39135, 258, 39318, 258, 39321, 258, 39340, 258, 39592, 258, 39640, + 258, 39647, 258, 39717, 258, 39727, 258, 39730, 258, 39740, 258, 39770, + 258, 40165, 258, 40565, 258, 40575, 258, 40613, 258, 40635, 258, 40643, + 258, 40653, 258, 40657, 258, 40697, 258, 40701, 258, 40718, 258, 40723, + 258, 40736, 258, 40763, 258, 40778, 258, 40786, 258, 40845, 258, 40860, + 258, 40864, 264, 32, 258, 12306, 258, 21316, 258, 21317, 512, 12363, + 12441, 512, 12365, 12441, 512, 12367, 12441, 512, 12369, 12441, 512, + 12371, 12441, 512, 12373, 12441, 512, 12375, 12441, 512, 12377, 12441, + 512, 12379, 12441, 512, 12381, 12441, 512, 12383, 12441, 512, 12385, + 12441, 512, 12388, 12441, 512, 12390, 12441, 512, 12392, 12441, 512, + 12399, 12441, 512, 12399, 12442, 512, 12402, 12441, 512, 12402, 12442, + 512, 12405, 12441, 512, 12405, 12442, 512, 12408, 12441, 512, 12408, + 12442, 512, 12411, 12441, 512, 12411, 12442, 512, 12358, 12441, 514, 32, + 12441, 514, 32, 12442, 512, 12445, 12441, 521, 12424, 12426, 512, 12459, + 12441, 512, 12461, 12441, 512, 12463, 12441, 512, 12465, 12441, 512, + 12467, 12441, 512, 12469, 12441, 512, 12471, 12441, 512, 12473, 12441, + 512, 12475, 12441, 512, 12477, 12441, 512, 12479, 12441, 512, 12481, + 12441, 512, 12484, 12441, 512, 12486, 12441, 512, 12488, 12441, 512, + 12495, 12441, 512, 12495, 12442, 512, 12498, 12441, 512, 12498, 12442, + 512, 12501, 12441, 512, 12501, 12442, 512, 12504, 12441, 512, 12504, + 12442, 512, 12507, 12441, 512, 12507, 12442, 512, 12454, 12441, 512, + 12527, 12441, 512, 12528, 12441, 512, 12529, 12441, 512, 12530, 12441, + 512, 12541, 12441, 521, 12467, 12488, 258, 4352, 258, 4353, 258, 4522, + 258, 4354, 258, 4524, 258, 4525, 258, 4355, 258, 4356, 258, 4357, 258, + 4528, 258, 4529, 258, 4530, 258, 4531, 258, 4532, 258, 4533, 258, 4378, + 258, 4358, 258, 4359, 258, 4360, 258, 4385, 258, 4361, 258, 4362, 258, + 4363, 258, 4364, 258, 4365, 258, 4366, 258, 4367, 258, 4368, 258, 4369, + 258, 4370, 258, 4449, 258, 4450, 258, 4451, 258, 4452, 258, 4453, 258, + 4454, 258, 4455, 258, 4456, 258, 4457, 258, 4458, 258, 4459, 258, 4460, + 258, 4461, 258, 4462, 258, 4463, 258, 4464, 258, 4465, 258, 4466, 258, + 4467, 258, 4468, 258, 4469, 258, 4448, 258, 4372, 258, 4373, 258, 4551, + 258, 4552, 258, 4556, 258, 4558, 258, 4563, 258, 4567, 258, 4569, 258, + 4380, 258, 4573, 258, 4575, 258, 4381, 258, 4382, 258, 4384, 258, 4386, + 258, 4387, 258, 4391, 258, 4393, 258, 4395, 258, 4396, 258, 4397, 258, + 4398, 258, 4399, 258, 4402, 258, 4406, 258, 4416, 258, 4423, 258, 4428, + 258, 4593, 258, 4594, 258, 4439, 258, 4440, 258, 4441, 258, 4484, 258, + 4485, 258, 4488, 258, 4497, 258, 4498, 258, 4500, 258, 4510, 258, 4513, + 259, 19968, 259, 20108, 259, 19977, 259, 22235, 259, 19978, 259, 20013, + 259, 19979, 259, 30002, 259, 20057, 259, 19993, 259, 19969, 259, 22825, + 259, 22320, 259, 20154, 770, 40, 4352, 41, 770, 40, 4354, 41, 770, 40, + 4355, 41, 770, 40, 4357, 41, 770, 40, 4358, 41, 770, 40, 4359, 41, 770, + 40, 4361, 41, 770, 40, 4363, 41, 770, 40, 4364, 41, 770, 40, 4366, 41, + 770, 40, 4367, 41, 770, 40, 4368, 41, 770, 40, 4369, 41, 770, 40, 4370, + 41, 1026, 40, 4352, 4449, 41, 1026, 40, 4354, 4449, 41, 1026, 40, 4355, + 4449, 41, 1026, 40, 4357, 4449, 41, 1026, 40, 4358, 4449, 41, 1026, 40, + 4359, 4449, 41, 1026, 40, 4361, 4449, 41, 1026, 40, 4363, 4449, 41, 1026, + 40, 4364, 4449, 41, 1026, 40, 4366, 4449, 41, 1026, 40, 4367, 4449, 41, + 1026, 40, 4368, 4449, 41, 1026, 40, 4369, 4449, 41, 1026, 40, 4370, 4449, + 41, 1026, 40, 4364, 4462, 41, 1794, 40, 4363, 4457, 4364, 4453, 4523, 41, + 1538, 40, 4363, 4457, 4370, 4462, 41, 770, 40, 19968, 41, 770, 40, 20108, + 41, 770, 40, 19977, 41, 770, 40, 22235, 41, 770, 40, 20116, 41, 770, 40, + 20845, 41, 770, 40, 19971, 41, 770, 40, 20843, 41, 770, 40, 20061, 41, + 770, 40, 21313, 41, 770, 40, 26376, 41, 770, 40, 28779, 41, 770, 40, + 27700, 41, 770, 40, 26408, 41, 770, 40, 37329, 41, 770, 40, 22303, 41, + 770, 40, 26085, 41, 770, 40, 26666, 41, 770, 40, 26377, 41, 770, 40, + 31038, 41, 770, 40, 21517, 41, 770, 40, 29305, 41, 770, 40, 36001, 41, + 770, 40, 31069, 41, 770, 40, 21172, 41, 770, 40, 20195, 41, 770, 40, + 21628, 41, 770, 40, 23398, 41, 770, 40, 30435, 41, 770, 40, 20225, 41, + 770, 40, 36039, 41, 770, 40, 21332, 41, 770, 40, 31085, 41, 770, 40, + 20241, 41, 770, 40, 33258, 41, 770, 40, 33267, 41, 263, 21839, 263, + 24188, 263, 25991, 263, 31631, 778, 80, 84, 69, 519, 50, 49, 519, 50, 50, + 519, 50, 51, 519, 50, 52, 519, 50, 53, 519, 50, 54, 519, 50, 55, 519, 50, + 56, 519, 50, 57, 519, 51, 48, 519, 51, 49, 519, 51, 50, 519, 51, 51, 519, + 51, 52, 519, 51, 53, 263, 4352, 263, 4354, 263, 4355, 263, 4357, 263, + 4358, 263, 4359, 263, 4361, 263, 4363, 263, 4364, 263, 4366, 263, 4367, + 263, 4368, 263, 4369, 263, 4370, 519, 4352, 4449, 519, 4354, 4449, 519, + 4355, 4449, 519, 4357, 4449, 519, 4358, 4449, 519, 4359, 4449, 519, 4361, + 4449, 519, 4363, 4449, 519, 4364, 4449, 519, 4366, 4449, 519, 4367, 4449, + 519, 4368, 4449, 519, 4369, 4449, 519, 4370, 4449, 1287, 4366, 4449, + 4535, 4352, 4457, 1031, 4364, 4462, 4363, 4468, 519, 4363, 4462, 263, + 19968, 263, 20108, 263, 19977, 263, 22235, 263, 20116, 263, 20845, 263, + 19971, 263, 20843, 263, 20061, 263, 21313, 263, 26376, 263, 28779, 263, + 27700, 263, 26408, 263, 37329, 263, 22303, 263, 26085, 263, 26666, 263, + 26377, 263, 31038, 263, 21517, 263, 29305, 263, 36001, 263, 31069, 263, + 21172, 263, 31192, 263, 30007, 263, 22899, 263, 36969, 263, 20778, 263, + 21360, 263, 27880, 263, 38917, 263, 20241, 263, 20889, 263, 27491, 263, + 19978, 263, 20013, 263, 19979, 263, 24038, 263, 21491, 263, 21307, 263, + 23447, 263, 23398, 263, 30435, 263, 20225, 263, 36039, 263, 21332, 263, + 22812, 519, 51, 54, 519, 51, 55, 519, 51, 56, 519, 51, 57, 519, 52, 48, + 519, 52, 49, 519, 52, 50, 519, 52, 51, 519, 52, 52, 519, 52, 53, 519, 52, + 54, 519, 52, 55, 519, 52, 56, 519, 52, 57, 519, 53, 48, 514, 49, 26376, + 514, 50, 26376, 514, 51, 26376, 514, 52, 26376, 514, 53, 26376, 514, 54, + 26376, 514, 55, 26376, 514, 56, 26376, 514, 57, 26376, 770, 49, 48, + 26376, 770, 49, 49, 26376, 770, 49, 50, 26376, 522, 72, 103, 778, 101, + 114, 103, 522, 101, 86, 778, 76, 84, 68, 263, 12450, 263, 12452, 263, + 12454, 263, 12456, 263, 12458, 263, 12459, 263, 12461, 263, 12463, 263, + 12465, 263, 12467, 263, 12469, 263, 12471, 263, 12473, 263, 12475, 263, + 12477, 263, 12479, 263, 12481, 263, 12484, 263, 12486, 263, 12488, 263, + 12490, 263, 12491, 263, 12492, 263, 12493, 263, 12494, 263, 12495, 263, + 12498, 263, 12501, 263, 12504, 263, 12507, 263, 12510, 263, 12511, 263, + 12512, 263, 12513, 263, 12514, 263, 12516, 263, 12518, 263, 12520, 263, + 12521, 263, 12522, 263, 12523, 263, 12524, 263, 12525, 263, 12527, 263, + 12528, 263, 12529, 263, 12530, 522, 20196, 21644, 1034, 12450, 12497, + 12540, 12488, 1034, 12450, 12523, 12501, 12449, 1034, 12450, 12531, + 12506, 12450, 778, 12450, 12540, 12523, 1034, 12452, 12491, 12531, 12464, + 778, 12452, 12531, 12481, 778, 12454, 12457, 12531, 1290, 12456, 12473, + 12463, 12540, 12489, 1034, 12456, 12540, 12459, 12540, 778, 12458, 12531, + 12473, 778, 12458, 12540, 12512, 778, 12459, 12452, 12522, 1034, 12459, + 12521, 12483, 12488, 1034, 12459, 12525, 12522, 12540, 778, 12460, 12525, + 12531, 778, 12460, 12531, 12510, 522, 12462, 12460, 778, 12462, 12491, + 12540, 1034, 12461, 12517, 12522, 12540, 1034, 12462, 12523, 12480, + 12540, 522, 12461, 12525, 1290, 12461, 12525, 12464, 12521, 12512, 1546, + 12461, 12525, 12513, 12540, 12488, 12523, 1290, 12461, 12525, 12527, + 12483, 12488, 778, 12464, 12521, 12512, 1290, 12464, 12521, 12512, 12488, + 12531, 1290, 12463, 12523, 12476, 12452, 12525, 1034, 12463, 12525, + 12540, 12493, 778, 12465, 12540, 12473, 778, 12467, 12523, 12490, 778, + 12467, 12540, 12509, 1034, 12469, 12452, 12463, 12523, 1290, 12469, + 12531, 12481, 12540, 12512, 1034, 12471, 12522, 12531, 12464, 778, 12475, + 12531, 12481, 778, 12475, 12531, 12488, 778, 12480, 12540, 12473, 522, + 12487, 12471, 522, 12489, 12523, 522, 12488, 12531, 522, 12490, 12494, + 778, 12494, 12483, 12488, 778, 12495, 12452, 12484, 1290, 12497, 12540, + 12475, 12531, 12488, 778, 12497, 12540, 12484, 1034, 12496, 12540, 12524, + 12523, 1290, 12500, 12450, 12473, 12488, 12523, 778, 12500, 12463, 12523, + 522, 12500, 12467, 522, 12499, 12523, 1290, 12501, 12449, 12521, 12483, + 12489, 1034, 12501, 12451, 12540, 12488, 1290, 12502, 12483, 12471, + 12455, 12523, 778, 12501, 12521, 12531, 1290, 12504, 12463, 12479, 12540, + 12523, 522, 12506, 12477, 778, 12506, 12491, 12498, 778, 12504, 12523, + 12484, 778, 12506, 12531, 12473, 778, 12506, 12540, 12472, 778, 12505, + 12540, 12479, 1034, 12509, 12452, 12531, 12488, 778, 12508, 12523, 12488, + 522, 12507, 12531, 778, 12509, 12531, 12489, 778, 12507, 12540, 12523, + 778, 12507, 12540, 12531, 1034, 12510, 12452, 12463, 12525, 778, 12510, + 12452, 12523, 778, 12510, 12483, 12495, 778, 12510, 12523, 12463, 1290, + 12510, 12531, 12471, 12519, 12531, 1034, 12511, 12463, 12525, 12531, 522, + 12511, 12522, 1290, 12511, 12522, 12496, 12540, 12523, 522, 12513, 12460, + 1034, 12513, 12460, 12488, 12531, 1034, 12513, 12540, 12488, 12523, 778, + 12516, 12540, 12489, 778, 12516, 12540, 12523, 778, 12518, 12450, 12531, + 1034, 12522, 12483, 12488, 12523, 522, 12522, 12521, 778, 12523, 12500, + 12540, 1034, 12523, 12540, 12502, 12523, 522, 12524, 12512, 1290, 12524, + 12531, 12488, 12466, 12531, 778, 12527, 12483, 12488, 514, 48, 28857, + 514, 49, 28857, 514, 50, 28857, 514, 51, 28857, 514, 52, 28857, 514, 53, + 28857, 514, 54, 28857, 514, 55, 28857, 514, 56, 28857, 514, 57, 28857, + 770, 49, 48, 28857, 770, 49, 49, 28857, 770, 49, 50, 28857, 770, 49, 51, + 28857, 770, 49, 52, 28857, 770, 49, 53, 28857, 770, 49, 54, 28857, 770, + 49, 55, 28857, 770, 49, 56, 28857, 770, 49, 57, 28857, 770, 50, 48, + 28857, 770, 50, 49, 28857, 770, 50, 50, 28857, 770, 50, 51, 28857, 770, + 50, 52, 28857, 778, 104, 80, 97, 522, 100, 97, 522, 65, 85, 778, 98, 97, + 114, 522, 111, 86, 522, 112, 99, 522, 100, 109, 778, 100, 109, 178, 778, + 100, 109, 179, 522, 73, 85, 522, 24179, 25104, 522, 26157, 21644, 522, + 22823, 27491, 522, 26126, 27835, 1034, 26666, 24335, 20250, 31038, 522, + 112, 65, 522, 110, 65, 522, 956, 65, 522, 109, 65, 522, 107, 65, 522, 75, + 66, 522, 77, 66, 522, 71, 66, 778, 99, 97, 108, 1034, 107, 99, 97, 108, + 522, 112, 70, 522, 110, 70, 522, 956, 70, 522, 956, 103, 522, 109, 103, + 522, 107, 103, 522, 72, 122, 778, 107, 72, 122, 778, 77, 72, 122, 778, + 71, 72, 122, 778, 84, 72, 122, 522, 956, 8467, 522, 109, 8467, 522, 100, + 8467, 522, 107, 8467, 522, 102, 109, 522, 110, 109, 522, 956, 109, 522, + 109, 109, 522, 99, 109, 522, 107, 109, 778, 109, 109, 178, 778, 99, 109, + 178, 522, 109, 178, 778, 107, 109, 178, 778, 109, 109, 179, 778, 99, 109, + 179, 522, 109, 179, 778, 107, 109, 179, 778, 109, 8725, 115, 1034, 109, + 8725, 115, 178, 522, 80, 97, 778, 107, 80, 97, 778, 77, 80, 97, 778, 71, + 80, 97, 778, 114, 97, 100, 1290, 114, 97, 100, 8725, 115, 1546, 114, 97, + 100, 8725, 115, 178, 522, 112, 115, 522, 110, 115, 522, 956, 115, 522, + 109, 115, 522, 112, 86, 522, 110, 86, 522, 956, 86, 522, 109, 86, 522, + 107, 86, 522, 77, 86, 522, 112, 87, 522, 110, 87, 522, 956, 87, 522, 109, + 87, 522, 107, 87, 522, 77, 87, 522, 107, 937, 522, 77, 937, 1034, 97, 46, + 109, 46, 522, 66, 113, 522, 99, 99, 522, 99, 100, 1034, 67, 8725, 107, + 103, 778, 67, 111, 46, 522, 100, 66, 522, 71, 121, 522, 104, 97, 522, 72, + 80, 522, 105, 110, 522, 75, 75, 522, 75, 77, 522, 107, 116, 522, 108, + 109, 522, 108, 110, 778, 108, 111, 103, 522, 108, 120, 522, 109, 98, 778, + 109, 105, 108, 778, 109, 111, 108, 522, 80, 72, 1034, 112, 46, 109, 46, + 778, 80, 80, 77, 522, 80, 82, 522, 115, 114, 522, 83, 118, 522, 87, 98, + 778, 86, 8725, 109, 778, 65, 8725, 109, 514, 49, 26085, 514, 50, 26085, + 514, 51, 26085, 514, 52, 26085, 514, 53, 26085, 514, 54, 26085, 514, 55, + 26085, 514, 56, 26085, 514, 57, 26085, 770, 49, 48, 26085, 770, 49, 49, + 26085, 770, 49, 50, 26085, 770, 49, 51, 26085, 770, 49, 52, 26085, 770, + 49, 53, 26085, 770, 49, 54, 26085, 770, 49, 55, 26085, 770, 49, 56, + 26085, 770, 49, 57, 26085, 770, 50, 48, 26085, 770, 50, 49, 26085, 770, + 50, 50, 26085, 770, 50, 51, 26085, 770, 50, 52, 26085, 770, 50, 53, + 26085, 770, 50, 54, 26085, 770, 50, 55, 26085, 770, 50, 56, 26085, 770, + 50, 57, 26085, 770, 51, 48, 26085, 770, 51, 49, 26085, 778, 103, 97, 108, + 259, 1098, 259, 1100, 259, 42863, 259, 83, 259, 67, 259, 70, 259, 81, + 259, 294, 259, 339, 259, 42791, 259, 43831, 259, 619, 259, 43858, 259, + 653, 256, 35912, 256, 26356, 256, 36554, 256, 36040, 256, 28369, 256, + 20018, 256, 21477, 256, 40860, 256, 22865, 256, 37329, 256, 21895, 256, + 22856, 256, 25078, 256, 30313, 256, 32645, 256, 34367, 256, 34746, 256, + 35064, 256, 37007, 256, 27138, 256, 27931, 256, 28889, 256, 29662, 256, + 33853, 256, 37226, 256, 39409, 256, 20098, 256, 21365, 256, 27396, 256, + 29211, 256, 34349, 256, 40478, 256, 23888, 256, 28651, 256, 34253, 256, + 35172, 256, 25289, 256, 33240, 256, 34847, 256, 24266, 256, 26391, 256, + 28010, 256, 29436, 256, 37070, 256, 20358, 256, 20919, 256, 21214, 256, + 25796, 256, 27347, 256, 29200, 256, 30439, 256, 32769, 256, 34310, 256, + 34396, 256, 36335, 256, 38706, 256, 39791, 256, 40442, 256, 30860, 256, + 31103, 256, 32160, 256, 33737, 256, 37636, 256, 40575, 256, 35542, 256, + 22751, 256, 24324, 256, 31840, 256, 32894, 256, 29282, 256, 30922, 256, + 36034, 256, 38647, 256, 22744, 256, 23650, 256, 27155, 256, 28122, 256, + 28431, 256, 32047, 256, 32311, 256, 38475, 256, 21202, 256, 32907, 256, + 20956, 256, 20940, 256, 31260, 256, 32190, 256, 33777, 256, 38517, 256, + 35712, 256, 25295, 256, 35582, 256, 20025, 256, 23527, 256, 24594, 256, + 29575, 256, 30064, 256, 21271, 256, 30971, 256, 20415, 256, 24489, 256, + 19981, 256, 27852, 256, 25976, 256, 32034, 256, 21443, 256, 22622, 256, + 30465, 256, 33865, 256, 35498, 256, 27578, 256, 36784, 256, 27784, 256, + 25342, 256, 33509, 256, 25504, 256, 30053, 256, 20142, 256, 20841, 256, + 20937, 256, 26753, 256, 31975, 256, 33391, 256, 35538, 256, 37327, 256, + 21237, 256, 21570, 256, 22899, 256, 24300, 256, 26053, 256, 28670, 256, + 31018, 256, 38317, 256, 39530, 256, 40599, 256, 40654, 256, 21147, 256, + 26310, 256, 27511, 256, 36706, 256, 24180, 256, 24976, 256, 25088, 256, + 25754, 256, 28451, 256, 29001, 256, 29833, 256, 31178, 256, 32244, 256, + 32879, 256, 36646, 256, 34030, 256, 36899, 256, 37706, 256, 21015, 256, + 21155, 256, 21693, 256, 28872, 256, 35010, 256, 24265, 256, 24565, 256, + 25467, 256, 27566, 256, 31806, 256, 29557, 256, 20196, 256, 22265, 256, + 23994, 256, 24604, 256, 29618, 256, 29801, 256, 32666, 256, 32838, 256, + 37428, 256, 38646, 256, 38728, 256, 38936, 256, 20363, 256, 31150, 256, + 37300, 256, 38584, 256, 24801, 256, 20102, 256, 20698, 256, 23534, 256, + 23615, 256, 26009, 256, 29134, 256, 30274, 256, 34044, 256, 36988, 256, + 40845, 256, 26248, 256, 38446, 256, 21129, 256, 26491, 256, 26611, 256, + 27969, 256, 28316, 256, 29705, 256, 30041, 256, 30827, 256, 32016, 256, + 39006, 256, 20845, 256, 25134, 256, 38520, 256, 20523, 256, 23833, 256, + 28138, 256, 36650, 256, 24459, 256, 24900, 256, 26647, 256, 38534, 256, + 21033, 256, 21519, 256, 23653, 256, 26131, 256, 26446, 256, 26792, 256, + 27877, 256, 29702, 256, 30178, 256, 32633, 256, 35023, 256, 35041, 256, + 37324, 256, 38626, 256, 21311, 256, 28346, 256, 21533, 256, 29136, 256, + 29848, 256, 34298, 256, 38563, 256, 40023, 256, 40607, 256, 26519, 256, + 28107, 256, 33256, 256, 31435, 256, 31520, 256, 31890, 256, 29376, 256, + 28825, 256, 35672, 256, 20160, 256, 33590, 256, 21050, 256, 20999, 256, + 24230, 256, 25299, 256, 31958, 256, 23429, 256, 27934, 256, 26292, 256, + 36667, 256, 34892, 256, 38477, 256, 35211, 256, 24275, 256, 20800, 256, + 21952, 256, 22618, 256, 26228, 256, 20958, 256, 29482, 256, 30410, 256, + 31036, 256, 31070, 256, 31077, 256, 31119, 256, 38742, 256, 31934, 256, + 32701, 256, 34322, 256, 35576, 256, 36920, 256, 37117, 256, 39151, 256, + 39164, 256, 39208, 256, 40372, 256, 37086, 256, 38583, 256, 20398, 256, + 20711, 256, 20813, 256, 21193, 256, 21220, 256, 21329, 256, 21917, 256, + 22022, 256, 22120, 256, 22592, 256, 22696, 256, 23652, 256, 23662, 256, + 24724, 256, 24936, 256, 24974, 256, 25074, 256, 25935, 256, 26082, 256, + 26257, 256, 26757, 256, 28023, 256, 28186, 256, 28450, 256, 29038, 256, + 29227, 256, 29730, 256, 30865, 256, 31038, 256, 31049, 256, 31048, 256, + 31056, 256, 31062, 256, 31069, 256, 31117, 256, 31118, 256, 31296, 256, + 31361, 256, 31680, 256, 32265, 256, 32321, 256, 32626, 256, 32773, 256, + 33261, 256, 33401, 256, 33879, 256, 35088, 256, 35222, 256, 35585, 256, + 35641, 256, 36051, 256, 36104, 256, 36790, 256, 38627, 256, 38911, 256, + 38971, 256, 24693, 256, 148206, 256, 33304, 256, 20006, 256, 20917, 256, + 20840, 256, 20352, 256, 20805, 256, 20864, 256, 21191, 256, 21242, 256, + 21845, 256, 21913, 256, 21986, 256, 22707, 256, 22852, 256, 22868, 256, + 23138, 256, 23336, 256, 24274, 256, 24281, 256, 24425, 256, 24493, 256, + 24792, 256, 24910, 256, 24840, 256, 24928, 256, 25140, 256, 25540, 256, + 25628, 256, 25682, 256, 25942, 256, 26395, 256, 26454, 256, 27513, 256, + 28379, 256, 28363, 256, 28702, 256, 30631, 256, 29237, 256, 29359, 256, + 29809, 256, 29958, 256, 30011, 256, 30237, 256, 30239, 256, 30427, 256, + 30452, 256, 30538, 256, 30528, 256, 30924, 256, 31409, 256, 31867, 256, + 32091, 256, 32574, 256, 33618, 256, 33775, 256, 34681, 256, 35137, 256, + 35206, 256, 35519, 256, 35531, 256, 35565, 256, 35722, 256, 36664, 256, + 36978, 256, 37273, 256, 37494, 256, 38524, 256, 38875, 256, 38923, 256, + 39698, 256, 141386, 256, 141380, 256, 144341, 256, 15261, 256, 16408, + 256, 16441, 256, 152137, 256, 154832, 256, 163539, 256, 40771, 256, + 40846, 514, 102, 102, 514, 102, 105, 514, 102, 108, 770, 102, 102, 105, + 770, 102, 102, 108, 514, 383, 116, 514, 115, 116, 514, 1396, 1398, 514, + 1396, 1381, 514, 1396, 1387, 514, 1406, 1398, 514, 1396, 1389, 512, 1497, + 1460, 512, 1522, 1463, 262, 1506, 262, 1488, 262, 1491, 262, 1492, 262, + 1499, 262, 1500, 262, 1501, 262, 1512, 262, 1514, 262, 43, 512, 1513, + 1473, 512, 1513, 1474, 512, 64329, 1473, 512, 64329, 1474, 512, 1488, + 1463, 512, 1488, 1464, 512, 1488, 1468, 512, 1489, 1468, 512, 1490, 1468, + 512, 1491, 1468, 512, 1492, 1468, 512, 1493, 1468, 512, 1494, 1468, 512, + 1496, 1468, 512, 1497, 1468, 512, 1498, 1468, 512, 1499, 1468, 512, 1500, + 1468, 512, 1502, 1468, 512, 1504, 1468, 512, 1505, 1468, 512, 1507, 1468, + 512, 1508, 1468, 512, 1510, 1468, 512, 1511, 1468, 512, 1512, 1468, 512, + 1513, 1468, 512, 1514, 1468, 512, 1493, 1465, 512, 1489, 1471, 512, 1499, + 1471, 512, 1508, 1471, 514, 1488, 1500, 267, 1649, 268, 1649, 267, 1659, + 268, 1659, 269, 1659, 270, 1659, 267, 1662, 268, 1662, 269, 1662, 270, + 1662, 267, 1664, 268, 1664, 269, 1664, 270, 1664, 267, 1658, 268, 1658, + 269, 1658, 270, 1658, 267, 1663, 268, 1663, 269, 1663, 270, 1663, 267, + 1657, 268, 1657, 269, 1657, 270, 1657, 267, 1700, 268, 1700, 269, 1700, + 270, 1700, 267, 1702, 268, 1702, 269, 1702, 270, 1702, 267, 1668, 268, + 1668, 269, 1668, 270, 1668, 267, 1667, 268, 1667, 269, 1667, 270, 1667, + 267, 1670, 268, 1670, 269, 1670, 270, 1670, 267, 1671, 268, 1671, 269, + 1671, 270, 1671, 267, 1677, 268, 1677, 267, 1676, 268, 1676, 267, 1678, + 268, 1678, 267, 1672, 268, 1672, 267, 1688, 268, 1688, 267, 1681, 268, + 1681, 267, 1705, 268, 1705, 269, 1705, 270, 1705, 267, 1711, 268, 1711, + 269, 1711, 270, 1711, 267, 1715, 268, 1715, 269, 1715, 270, 1715, 267, + 1713, 268, 1713, 269, 1713, 270, 1713, 267, 1722, 268, 1722, 267, 1723, + 268, 1723, 269, 1723, 270, 1723, 267, 1728, 268, 1728, 267, 1729, 268, + 1729, 269, 1729, 270, 1729, 267, 1726, 268, 1726, 269, 1726, 270, 1726, + 267, 1746, 268, 1746, 267, 1747, 268, 1747, 267, 1709, 268, 1709, 269, + 1709, 270, 1709, 267, 1735, 268, 1735, 267, 1734, 268, 1734, 267, 1736, + 268, 1736, 267, 1655, 267, 1739, 268, 1739, 267, 1733, 268, 1733, 267, + 1737, 268, 1737, 267, 1744, 268, 1744, 269, 1744, 270, 1744, 269, 1609, + 270, 1609, 523, 1574, 1575, 524, 1574, 1575, 523, 1574, 1749, 524, 1574, + 1749, 523, 1574, 1608, 524, 1574, 1608, 523, 1574, 1735, 524, 1574, 1735, + 523, 1574, 1734, 524, 1574, 1734, 523, 1574, 1736, 524, 1574, 1736, 523, + 1574, 1744, 524, 1574, 1744, 525, 1574, 1744, 523, 1574, 1609, 524, 1574, + 1609, 525, 1574, 1609, 267, 1740, 268, 1740, 269, 1740, 270, 1740, 523, + 1574, 1580, 523, 1574, 1581, 523, 1574, 1605, 523, 1574, 1610, 523, 1576, + 1580, 523, 1576, 1581, 523, 1576, 1582, 523, 1576, 1605, 523, 1576, 1609, + 523, 1576, 1610, 523, 1578, 1580, 523, 1578, 1581, 523, 1578, 1582, 523, + 1578, 1605, 523, 1578, 1609, 523, 1578, 1610, 523, 1579, 1580, 523, 1579, + 1605, 523, 1579, 1609, 523, 1579, 1610, 523, 1580, 1581, 523, 1580, 1605, + 523, 1581, 1580, 523, 1581, 1605, 523, 1582, 1580, 523, 1582, 1581, 523, + 1582, 1605, 523, 1587, 1580, 523, 1587, 1581, 523, 1587, 1582, 523, 1587, + 1605, 523, 1589, 1581, 523, 1589, 1605, 523, 1590, 1580, 523, 1590, 1581, + 523, 1590, 1582, 523, 1590, 1605, 523, 1591, 1581, 523, 1591, 1605, 523, + 1592, 1605, 523, 1593, 1580, 523, 1593, 1605, 523, 1594, 1580, 523, 1594, + 1605, 523, 1601, 1580, 523, 1601, 1581, 523, 1601, 1582, 523, 1601, 1605, + 523, 1601, 1609, 523, 1601, 1610, 523, 1602, 1581, 523, 1602, 1605, 523, + 1602, 1609, 523, 1602, 1610, 523, 1603, 1575, 523, 1603, 1580, 523, 1603, + 1581, 523, 1603, 1582, 523, 1603, 1604, 523, 1603, 1605, 523, 1603, 1609, + 523, 1603, 1610, 523, 1604, 1580, 523, 1604, 1581, 523, 1604, 1582, 523, + 1604, 1605, 523, 1604, 1609, 523, 1604, 1610, 523, 1605, 1580, 523, 1605, + 1581, 523, 1605, 1582, 523, 1605, 1605, 523, 1605, 1609, 523, 1605, 1610, + 523, 1606, 1580, 523, 1606, 1581, 523, 1606, 1582, 523, 1606, 1605, 523, + 1606, 1609, 523, 1606, 1610, 523, 1607, 1580, 523, 1607, 1605, 523, 1607, + 1609, 523, 1607, 1610, 523, 1610, 1580, 523, 1610, 1581, 523, 1610, 1582, + 523, 1610, 1605, 523, 1610, 1609, 523, 1610, 1610, 523, 1584, 1648, 523, + 1585, 1648, 523, 1609, 1648, 779, 32, 1612, 1617, 779, 32, 1613, 1617, + 779, 32, 1614, 1617, 779, 32, 1615, 1617, 779, 32, 1616, 1617, 779, 32, + 1617, 1648, 524, 1574, 1585, 524, 1574, 1586, 524, 1574, 1605, 524, 1574, + 1606, 524, 1574, 1610, 524, 1576, 1585, 524, 1576, 1586, 524, 1576, 1605, + 524, 1576, 1606, 524, 1576, 1609, 524, 1576, 1610, 524, 1578, 1585, 524, + 1578, 1586, 524, 1578, 1605, 524, 1578, 1606, 524, 1578, 1609, 524, 1578, + 1610, 524, 1579, 1585, 524, 1579, 1586, 524, 1579, 1605, 524, 1579, 1606, + 524, 1579, 1609, 524, 1579, 1610, 524, 1601, 1609, 524, 1601, 1610, 524, + 1602, 1609, 524, 1602, 1610, 524, 1603, 1575, 524, 1603, 1604, 524, 1603, + 1605, 524, 1603, 1609, 524, 1603, 1610, 524, 1604, 1605, 524, 1604, 1609, + 524, 1604, 1610, 524, 1605, 1575, 524, 1605, 1605, 524, 1606, 1585, 524, + 1606, 1586, 524, 1606, 1605, 524, 1606, 1606, 524, 1606, 1609, 524, 1606, + 1610, 524, 1609, 1648, 524, 1610, 1585, 524, 1610, 1586, 524, 1610, 1605, + 524, 1610, 1606, 524, 1610, 1609, 524, 1610, 1610, 525, 1574, 1580, 525, + 1574, 1581, 525, 1574, 1582, 525, 1574, 1605, 525, 1574, 1607, 525, 1576, + 1580, 525, 1576, 1581, 525, 1576, 1582, 525, 1576, 1605, 525, 1576, 1607, + 525, 1578, 1580, 525, 1578, 1581, 525, 1578, 1582, 525, 1578, 1605, 525, + 1578, 1607, 525, 1579, 1605, 525, 1580, 1581, 525, 1580, 1605, 525, 1581, + 1580, 525, 1581, 1605, 525, 1582, 1580, 525, 1582, 1605, 525, 1587, 1580, + 525, 1587, 1581, 525, 1587, 1582, 525, 1587, 1605, 525, 1589, 1581, 525, + 1589, 1582, 525, 1589, 1605, 525, 1590, 1580, 525, 1590, 1581, 525, 1590, + 1582, 525, 1590, 1605, 525, 1591, 1581, 525, 1592, 1605, 525, 1593, 1580, + 525, 1593, 1605, 525, 1594, 1580, 525, 1594, 1605, 525, 1601, 1580, 525, + 1601, 1581, 525, 1601, 1582, 525, 1601, 1605, 525, 1602, 1581, 525, 1602, + 1605, 525, 1603, 1580, 525, 1603, 1581, 525, 1603, 1582, 525, 1603, 1604, + 525, 1603, 1605, 525, 1604, 1580, 525, 1604, 1581, 525, 1604, 1582, 525, + 1604, 1605, 525, 1604, 1607, 525, 1605, 1580, 525, 1605, 1581, 525, 1605, + 1582, 525, 1605, 1605, 525, 1606, 1580, 525, 1606, 1581, 525, 1606, 1582, + 525, 1606, 1605, 525, 1606, 1607, 525, 1607, 1580, 525, 1607, 1605, 525, + 1607, 1648, 525, 1610, 1580, 525, 1610, 1581, 525, 1610, 1582, 525, 1610, + 1605, 525, 1610, 1607, 526, 1574, 1605, 526, 1574, 1607, 526, 1576, 1605, + 526, 1576, 1607, 526, 1578, 1605, 526, 1578, 1607, 526, 1579, 1605, 526, + 1579, 1607, 526, 1587, 1605, 526, 1587, 1607, 526, 1588, 1605, 526, 1588, + 1607, 526, 1603, 1604, 526, 1603, 1605, 526, 1604, 1605, 526, 1606, 1605, + 526, 1606, 1607, 526, 1610, 1605, 526, 1610, 1607, 782, 1600, 1614, 1617, + 782, 1600, 1615, 1617, 782, 1600, 1616, 1617, 523, 1591, 1609, 523, 1591, + 1610, 523, 1593, 1609, 523, 1593, 1610, 523, 1594, 1609, 523, 1594, 1610, + 523, 1587, 1609, 523, 1587, 1610, 523, 1588, 1609, 523, 1588, 1610, 523, + 1581, 1609, 523, 1581, 1610, 523, 1580, 1609, 523, 1580, 1610, 523, 1582, + 1609, 523, 1582, 1610, 523, 1589, 1609, 523, 1589, 1610, 523, 1590, 1609, + 523, 1590, 1610, 523, 1588, 1580, 523, 1588, 1581, 523, 1588, 1582, 523, + 1588, 1605, 523, 1588, 1585, 523, 1587, 1585, 523, 1589, 1585, 523, 1590, + 1585, 524, 1591, 1609, 524, 1591, 1610, 524, 1593, 1609, 524, 1593, 1610, + 524, 1594, 1609, 524, 1594, 1610, 524, 1587, 1609, 524, 1587, 1610, 524, + 1588, 1609, 524, 1588, 1610, 524, 1581, 1609, 524, 1581, 1610, 524, 1580, + 1609, 524, 1580, 1610, 524, 1582, 1609, 524, 1582, 1610, 524, 1589, 1609, + 524, 1589, 1610, 524, 1590, 1609, 524, 1590, 1610, 524, 1588, 1580, 524, + 1588, 1581, 524, 1588, 1582, 524, 1588, 1605, 524, 1588, 1585, 524, 1587, + 1585, 524, 1589, 1585, 524, 1590, 1585, 525, 1588, 1580, 525, 1588, 1581, + 525, 1588, 1582, 525, 1588, 1605, 525, 1587, 1607, 525, 1588, 1607, 525, + 1591, 1605, 526, 1587, 1580, 526, 1587, 1581, 526, 1587, 1582, 526, 1588, + 1580, 526, 1588, 1581, 526, 1588, 1582, 526, 1591, 1605, 526, 1592, 1605, + 524, 1575, 1611, 523, 1575, 1611, 781, 1578, 1580, 1605, 780, 1578, 1581, + 1580, 781, 1578, 1581, 1580, 781, 1578, 1581, 1605, 781, 1578, 1582, + 1605, 781, 1578, 1605, 1580, 781, 1578, 1605, 1581, 781, 1578, 1605, + 1582, 780, 1580, 1605, 1581, 781, 1580, 1605, 1581, 780, 1581, 1605, + 1610, 780, 1581, 1605, 1609, 781, 1587, 1581, 1580, 781, 1587, 1580, + 1581, 780, 1587, 1580, 1609, 780, 1587, 1605, 1581, 781, 1587, 1605, + 1581, 781, 1587, 1605, 1580, 780, 1587, 1605, 1605, 781, 1587, 1605, + 1605, 780, 1589, 1581, 1581, 781, 1589, 1581, 1581, 780, 1589, 1605, + 1605, 780, 1588, 1581, 1605, 781, 1588, 1581, 1605, 780, 1588, 1580, + 1610, 780, 1588, 1605, 1582, 781, 1588, 1605, 1582, 780, 1588, 1605, + 1605, 781, 1588, 1605, 1605, 780, 1590, 1581, 1609, 780, 1590, 1582, + 1605, 781, 1590, 1582, 1605, 780, 1591, 1605, 1581, 781, 1591, 1605, + 1581, 781, 1591, 1605, 1605, 780, 1591, 1605, 1610, 780, 1593, 1580, + 1605, 780, 1593, 1605, 1605, 781, 1593, 1605, 1605, 780, 1593, 1605, + 1609, 780, 1594, 1605, 1605, 780, 1594, 1605, 1610, 780, 1594, 1605, + 1609, 780, 1601, 1582, 1605, 781, 1601, 1582, 1605, 780, 1602, 1605, + 1581, 780, 1602, 1605, 1605, 780, 1604, 1581, 1605, 780, 1604, 1581, + 1610, 780, 1604, 1581, 1609, 781, 1604, 1580, 1580, 780, 1604, 1580, + 1580, 780, 1604, 1582, 1605, 781, 1604, 1582, 1605, 780, 1604, 1605, + 1581, 781, 1604, 1605, 1581, 781, 1605, 1581, 1580, 781, 1605, 1581, + 1605, 780, 1605, 1581, 1610, 781, 1605, 1580, 1581, 781, 1605, 1580, + 1605, 781, 1605, 1582, 1580, 781, 1605, 1582, 1605, 781, 1605, 1580, + 1582, 781, 1607, 1605, 1580, 781, 1607, 1605, 1605, 781, 1606, 1581, + 1605, 780, 1606, 1581, 1609, 780, 1606, 1580, 1605, 781, 1606, 1580, + 1605, 780, 1606, 1580, 1609, 780, 1606, 1605, 1610, 780, 1606, 1605, + 1609, 780, 1610, 1605, 1605, 781, 1610, 1605, 1605, 780, 1576, 1582, + 1610, 780, 1578, 1580, 1610, 780, 1578, 1580, 1609, 780, 1578, 1582, + 1610, 780, 1578, 1582, 1609, 780, 1578, 1605, 1610, 780, 1578, 1605, + 1609, 780, 1580, 1605, 1610, 780, 1580, 1581, 1609, 780, 1580, 1605, + 1609, 780, 1587, 1582, 1609, 780, 1589, 1581, 1610, 780, 1588, 1581, + 1610, 780, 1590, 1581, 1610, 780, 1604, 1580, 1610, 780, 1604, 1605, + 1610, 780, 1610, 1581, 1610, 780, 1610, 1580, 1610, 780, 1610, 1605, + 1610, 780, 1605, 1605, 1610, 780, 1602, 1605, 1610, 780, 1606, 1581, + 1610, 781, 1602, 1605, 1581, 781, 1604, 1581, 1605, 780, 1593, 1605, + 1610, 780, 1603, 1605, 1610, 781, 1606, 1580, 1581, 780, 1605, 1582, + 1610, 781, 1604, 1580, 1605, 780, 1603, 1605, 1605, 780, 1604, 1580, + 1605, 780, 1606, 1580, 1581, 780, 1580, 1581, 1610, 780, 1581, 1580, + 1610, 780, 1605, 1580, 1610, 780, 1601, 1605, 1610, 780, 1576, 1581, + 1610, 781, 1603, 1605, 1605, 781, 1593, 1580, 1605, 781, 1589, 1605, + 1605, 780, 1587, 1582, 1610, 780, 1606, 1580, 1610, 779, 1589, 1604, + 1746, 779, 1602, 1604, 1746, 1035, 1575, 1604, 1604, 1607, 1035, 1575, + 1603, 1576, 1585, 1035, 1605, 1581, 1605, 1583, 1035, 1589, 1604, 1593, + 1605, 1035, 1585, 1587, 1608, 1604, 1035, 1593, 1604, 1610, 1607, 1035, + 1608, 1587, 1604, 1605, 779, 1589, 1604, 1609, 4619, 1589, 1604, 1609, + 32, 1575, 1604, 1604, 1607, 32, 1593, 1604, 1610, 1607, 32, 1608, 1587, + 1604, 1605, 2059, 1580, 1604, 32, 1580, 1604, 1575, 1604, 1607, 1035, + 1585, 1740, 1575, 1604, 265, 44, 265, 12289, 265, 12290, 265, 58, 265, + 59, 265, 33, 265, 63, 265, 12310, 265, 12311, 265, 8230, 265, 8229, 265, + 8212, 265, 8211, 265, 95, 265, 40, 265, 41, 265, 123, 265, 125, 265, + 12308, 265, 12309, 265, 12304, 265, 12305, 265, 12298, 265, 12299, 265, + 12296, 265, 12297, 265, 12300, 265, 12301, 265, 12302, 265, 12303, 265, + 91, 265, 93, 258, 8254, 258, 95, 271, 44, 271, 12289, 271, 46, 271, 59, + 271, 58, 271, 63, 271, 33, 271, 8212, 271, 40, 271, 41, 271, 123, 271, + 125, 271, 12308, 271, 12309, 271, 35, 271, 38, 271, 42, 271, 43, 271, 45, + 271, 60, 271, 62, 271, 61, 271, 92, 271, 36, 271, 37, 271, 64, 523, 32, + 1611, 526, 1600, 1611, 523, 32, 1612, 523, 32, 1613, 523, 32, 1614, 526, + 1600, 1614, 523, 32, 1615, 526, 1600, 1615, 523, 32, 1616, 526, 1600, + 1616, 523, 32, 1617, 526, 1600, 1617, 523, 32, 1618, 526, 1600, 1618, + 267, 1569, 267, 1570, 268, 1570, 267, 1571, 268, 1571, 267, 1572, 268, + 1572, 267, 1573, 268, 1573, 267, 1574, 268, 1574, 269, 1574, 270, 1574, + 267, 1575, 268, 1575, 267, 1576, 268, 1576, 269, 1576, 270, 1576, 267, + 1577, 268, 1577, 267, 1578, 268, 1578, 269, 1578, 270, 1578, 267, 1579, + 268, 1579, 269, 1579, 270, 1579, 267, 1580, 268, 1580, 269, 1580, 270, + 1580, 267, 1581, 268, 1581, 269, 1581, 270, 1581, 267, 1582, 268, 1582, + 269, 1582, 270, 1582, 267, 1583, 268, 1583, 267, 1584, 268, 1584, 267, + 1585, 268, 1585, 267, 1586, 268, 1586, 267, 1587, 268, 1587, 269, 1587, + 270, 1587, 267, 1588, 268, 1588, 269, 1588, 270, 1588, 267, 1589, 268, + 1589, 269, 1589, 270, 1589, 267, 1590, 268, 1590, 269, 1590, 270, 1590, + 267, 1591, 268, 1591, 269, 1591, 270, 1591, 267, 1592, 268, 1592, 269, + 1592, 270, 1592, 267, 1593, 268, 1593, 269, 1593, 270, 1593, 267, 1594, + 268, 1594, 269, 1594, 270, 1594, 267, 1601, 268, 1601, 269, 1601, 270, + 1601, 267, 1602, 268, 1602, 269, 1602, 270, 1602, 267, 1603, 268, 1603, + 269, 1603, 270, 1603, 267, 1604, 268, 1604, 269, 1604, 270, 1604, 267, + 1605, 268, 1605, 269, 1605, 270, 1605, 267, 1606, 268, 1606, 269, 1606, + 270, 1606, 267, 1607, 268, 1607, 269, 1607, 270, 1607, 267, 1608, 268, + 1608, 267, 1609, 268, 1609, 267, 1610, 268, 1610, 269, 1610, 270, 1610, + 523, 1604, 1570, 524, 1604, 1570, 523, 1604, 1571, 524, 1604, 1571, 523, + 1604, 1573, 524, 1604, 1573, 523, 1604, 1575, 524, 1604, 1575, 264, 33, + 264, 34, 264, 35, 264, 36, 264, 37, 264, 38, 264, 39, 264, 40, 264, 41, + 264, 42, 264, 43, 264, 44, 264, 45, 264, 46, 264, 47, 264, 48, 264, 49, + 264, 50, 264, 51, 264, 52, 264, 53, 264, 54, 264, 55, 264, 56, 264, 57, + 264, 58, 264, 59, 264, 60, 264, 61, 264, 62, 264, 63, 264, 64, 264, 65, + 264, 66, 264, 67, 264, 68, 264, 69, 264, 70, 264, 71, 264, 72, 264, 73, + 264, 74, 264, 75, 264, 76, 264, 77, 264, 78, 264, 79, 264, 80, 264, 81, + 264, 82, 264, 83, 264, 84, 264, 85, 264, 86, 264, 87, 264, 88, 264, 89, + 264, 90, 264, 91, 264, 92, 264, 93, 264, 94, 264, 95, 264, 96, 264, 97, + 264, 98, 264, 99, 264, 100, 264, 101, 264, 102, 264, 103, 264, 104, 264, + 105, 264, 106, 264, 107, 264, 108, 264, 109, 264, 110, 264, 111, 264, + 112, 264, 113, 264, 114, 264, 115, 264, 116, 264, 117, 264, 118, 264, + 119, 264, 120, 264, 121, 264, 122, 264, 123, 264, 124, 264, 125, 264, + 126, 264, 10629, 264, 10630, 272, 12290, 272, 12300, 272, 12301, 272, + 12289, 272, 12539, 272, 12530, 272, 12449, 272, 12451, 272, 12453, 272, + 12455, 272, 12457, 272, 12515, 272, 12517, 272, 12519, 272, 12483, 272, + 12540, 272, 12450, 272, 12452, 272, 12454, 272, 12456, 272, 12458, 272, + 12459, 272, 12461, 272, 12463, 272, 12465, 272, 12467, 272, 12469, 272, + 12471, 272, 12473, 272, 12475, 272, 12477, 272, 12479, 272, 12481, 272, + 12484, 272, 12486, 272, 12488, 272, 12490, 272, 12491, 272, 12492, 272, + 12493, 272, 12494, 272, 12495, 272, 12498, 272, 12501, 272, 12504, 272, + 12507, 272, 12510, 272, 12511, 272, 12512, 272, 12513, 272, 12514, 272, + 12516, 272, 12518, 272, 12520, 272, 12521, 272, 12522, 272, 12523, 272, + 12524, 272, 12525, 272, 12527, 272, 12531, 272, 12441, 272, 12442, 272, + 12644, 272, 12593, 272, 12594, 272, 12595, 272, 12596, 272, 12597, 272, + 12598, 272, 12599, 272, 12600, 272, 12601, 272, 12602, 272, 12603, 272, + 12604, 272, 12605, 272, 12606, 272, 12607, 272, 12608, 272, 12609, 272, + 12610, 272, 12611, 272, 12612, 272, 12613, 272, 12614, 272, 12615, 272, + 12616, 272, 12617, 272, 12618, 272, 12619, 272, 12620, 272, 12621, 272, + 12622, 272, 12623, 272, 12624, 272, 12625, 272, 12626, 272, 12627, 272, + 12628, 272, 12629, 272, 12630, 272, 12631, 272, 12632, 272, 12633, 272, + 12634, 272, 12635, 272, 12636, 272, 12637, 272, 12638, 272, 12639, 272, + 12640, 272, 12641, 272, 12642, 272, 12643, 264, 162, 264, 163, 264, 172, + 264, 175, 264, 166, 264, 165, 264, 8361, 272, 9474, 272, 8592, 272, 8593, + 272, 8594, 272, 8595, 272, 9632, 272, 9675, 512, 67026, 775, 512, 67034, + 775, 259, 720, 259, 721, 259, 230, 259, 665, 259, 595, 259, 675, 259, + 43878, 259, 677, 259, 676, 259, 598, 259, 599, 259, 7569, 259, 600, 259, + 606, 259, 681, 259, 612, 259, 610, 259, 608, 259, 667, 259, 295, 259, + 668, 259, 615, 259, 644, 259, 682, 259, 683, 259, 620, 259, 122628, 259, + 42894, 259, 622, 259, 122629, 259, 654, 259, 122630, 259, 248, 259, 630, + 259, 631, 259, 113, 259, 634, 259, 122632, 259, 637, 259, 638, 259, 640, + 259, 680, 259, 678, 259, 43879, 259, 679, 259, 648, 259, 11377, 259, 655, + 259, 673, 259, 674, 259, 664, 259, 448, 259, 449, 259, 450, 259, 122634, + 259, 122654, 259, 647, 259, 662, 259, 663, 259, 670, 259, 122635, 512, + 69785, 69818, 512, 69787, 69818, 512, 69797, 69818, 512, 69937, 69927, + 512, 69938, 69927, 512, 70471, 70462, 512, 70471, 70487, 512, 70530, + 70601, 512, 70532, 70587, 512, 70539, 70594, 512, 70544, 70601, 512, + 70594, 70594, 512, 70594, 70584, 512, 70594, 70601, 512, 70841, 70842, + 512, 70841, 70832, 512, 70841, 70845, 512, 71096, 71087, 512, 71097, + 71087, 512, 71989, 71984, 512, 90398, 90398, 512, 90398, 90409, 512, + 90398, 90399, 512, 90409, 90399, 512, 90398, 90400, 512, 90401, 90399, + 512, 90402, 90399, 512, 90401, 90400, 512, 93543, 93543, 512, 93539, + 93543, 512, 93545, 93543, 521, 12371, 12392, 521, 12488, 12461, 521, + 12488, 12486, 521, 12520, 12522, 262, 65, 262, 71, 262, 74, 262, 75, 262, + 79, 262, 83, 262, 84, 262, 85, 262, 86, 262, 87, 262, 88, 262, 89, 262, + 48, 262, 49, 262, 50, 262, 51, 262, 52, 262, 53, 262, 54, 262, 55, 262, + 56, 262, 57, 512, 119127, 119141, 512, 119128, 119141, 512, 119135, + 119150, 512, 119135, 119151, 512, 119135, 119152, 512, 119135, 119153, + 512, 119135, 119154, 512, 119225, 119141, 512, 119226, 119141, 512, + 119227, 119150, 512, 119228, 119150, 512, 119227, 119151, 512, 119228, + 119151, 262, 97, 262, 98, 262, 99, 262, 102, 262, 107, 262, 109, 262, + 110, 262, 112, 262, 113, 262, 114, 262, 115, 262, 116, 262, 117, 262, + 118, 262, 119, 262, 120, 262, 121, 262, 122, 262, 305, 262, 567, 262, + 122773, 262, 913, 262, 914, 262, 916, 262, 917, 262, 918, 262, 919, 262, + 920, 262, 921, 262, 922, 262, 923, 262, 924, 262, 925, 262, 926, 262, + 927, 262, 929, 262, 1012, 262, 931, 262, 932, 262, 933, 262, 934, 262, + 935, 262, 936, 262, 937, 262, 8711, 262, 945, 262, 946, 262, 948, 262, + 949, 262, 950, 262, 951, 262, 952, 262, 953, 262, 954, 262, 955, 262, + 956, 262, 957, 262, 958, 262, 959, 262, 961, 262, 962, 262, 963, 262, + 964, 262, 965, 262, 966, 262, 967, 262, 968, 262, 969, 262, 8706, 262, + 1013, 262, 977, 262, 1008, 262, 981, 262, 1009, 262, 982, 262, 988, 262, + 989, 258, 223, 259, 122711, 259, 122712, 259, 122713, 261, 611, 259, + 7448, 259, 384, 259, 273, 259, 485, 259, 322, 259, 410, 259, 122704, 259, + 122686, 259, 585, 259, 7551, 259, 122687, 259, 414, 259, 636, 259, 568, + 259, 569, 259, 122667, 259, 122649, 259, 646, 259, 7576, 259, 122668, + 259, 122652, 259, 659, 259, 7578, 259, 7429, 259, 7424, 259, 7431, 259, + 639, 259, 645, 259, 686, 259, 687, 259, 545, 259, 564, 259, 565, 259, + 566, 259, 968, 259, 969, 259, 7553, 259, 42901, 259, 7559, 259, 7562, + 259, 7566, 259, 392, 259, 409, 259, 421, 259, 672, 259, 429, 259, 122633, + 259, 1072, 259, 1073, 259, 1074, 259, 1075, 259, 1076, 259, 1077, 259, + 1078, 259, 1079, 259, 1080, 259, 1082, 259, 1083, 259, 1084, 259, 1086, + 259, 1087, 259, 1088, 259, 1089, 259, 1090, 259, 1091, 259, 1092, 259, + 1093, 259, 1094, 259, 1095, 259, 1096, 259, 1099, 259, 1101, 259, 1102, + 259, 42633, 259, 1241, 259, 1110, 259, 1112, 259, 1257, 259, 1199, 259, + 1231, 261, 1072, 261, 1073, 261, 1074, 261, 1075, 261, 1076, 261, 1077, + 261, 1078, 261, 1079, 261, 1080, 261, 1082, 261, 1083, 261, 1086, 261, + 1087, 261, 1089, 261, 1091, 261, 1092, 261, 1093, 261, 1094, 261, 1095, + 261, 1096, 261, 1098, 261, 1099, 261, 1169, 261, 1110, 261, 1109, 261, + 1119, 259, 1195, 259, 42577, 259, 1201, 262, 1575, 262, 1576, 262, 1580, + 262, 1583, 262, 1608, 262, 1586, 262, 1581, 262, 1591, 262, 1610, 262, + 1603, 262, 1604, 262, 1605, 262, 1606, 262, 1587, 262, 1593, 262, 1601, + 262, 1589, 262, 1602, 262, 1585, 262, 1588, 262, 1578, 262, 1579, 262, + 1582, 262, 1584, 262, 1590, 262, 1592, 262, 1594, 262, 1646, 262, 1722, + 262, 1697, 262, 1647, 262, 1607, 514, 48, 46, 514, 48, 44, 514, 49, 44, + 514, 50, 44, 514, 51, 44, 514, 52, 44, 514, 53, 44, 514, 54, 44, 514, 55, + 44, 514, 56, 44, 514, 57, 44, 770, 40, 65, 41, 770, 40, 66, 41, 770, 40, + 67, 41, 770, 40, 68, 41, 770, 40, 69, 41, 770, 40, 70, 41, 770, 40, 71, + 41, 770, 40, 72, 41, 770, 40, 73, 41, 770, 40, 74, 41, 770, 40, 75, 41, + 770, 40, 76, 41, 770, 40, 77, 41, 770, 40, 78, 41, 770, 40, 79, 41, 770, + 40, 80, 41, 770, 40, 81, 41, 770, 40, 82, 41, 770, 40, 83, 41, 770, 40, + 84, 41, 770, 40, 85, 41, 770, 40, 86, 41, 770, 40, 87, 41, 770, 40, 88, + 41, 770, 40, 89, 41, 770, 40, 90, 41, 770, 12308, 83, 12309, 519, 67, 68, + 519, 87, 90, 266, 65, 266, 66, 266, 67, 266, 68, 266, 69, 266, 70, 266, + 71, 266, 72, 266, 73, 266, 74, 266, 75, 266, 76, 266, 77, 266, 78, 266, + 79, 266, 80, 266, 81, 266, 82, 266, 83, 266, 84, 266, 85, 266, 86, 266, + 87, 266, 88, 266, 89, 266, 90, 522, 72, 86, 522, 83, 68, 522, 83, 83, + 778, 80, 80, 86, 522, 87, 67, 515, 77, 67, 515, 77, 68, 515, 77, 82, 522, + 68, 74, 522, 12411, 12363, 522, 12467, 12467, 266, 12469, 266, 25163, + 266, 23383, 266, 21452, 266, 12487, 266, 20108, 266, 22810, 266, 35299, + 266, 22825, 266, 20132, 266, 26144, 266, 28961, 266, 26009, 266, 21069, + 266, 24460, 266, 20877, 266, 26032, 266, 21021, 266, 32066, 266, 29983, + 266, 36009, 266, 22768, 266, 21561, 266, 28436, 266, 25237, 266, 25429, + 266, 19968, 266, 19977, 266, 36938, 266, 24038, 266, 20013, 266, 21491, + 266, 25351, 266, 36208, 266, 25171, 266, 31105, 266, 31354, 266, 21512, + 266, 28288, 266, 26377, 266, 26376, 266, 30003, 266, 21106, 266, 21942, + 266, 37197, 770, 12308, 26412, 12309, 770, 12308, 19977, 12309, 770, + 12308, 20108, 12309, 770, 12308, 23433, 12309, 770, 12308, 28857, 12309, + 770, 12308, 25171, 12309, 770, 12308, 30423, 12309, 770, 12308, 21213, + 12309, 770, 12308, 25943, 12309, 263, 24471, 263, 21487, 256, 20029, 256, + 20024, 256, 20033, 256, 131362, 256, 20320, 256, 20411, 256, 20482, 256, + 20602, 256, 20633, 256, 20687, 256, 13470, 256, 132666, 256, 20820, 256, + 20836, 256, 20855, 256, 132380, 256, 13497, 256, 20839, 256, 20877, 256, + 132427, 256, 20887, 256, 20900, 256, 20172, 256, 20908, 256, 168415, 256, + 20981, 256, 20995, 256, 13535, 256, 21051, 256, 21062, 256, 21106, 256, + 21111, 256, 13589, 256, 21253, 256, 21254, 256, 21321, 256, 21338, 256, + 21363, 256, 21373, 256, 21375, 256, 133676, 256, 28784, 256, 21450, 256, + 21471, 256, 133987, 256, 21483, 256, 21489, 256, 21510, 256, 21662, 256, + 21560, 256, 21576, 256, 21608, 256, 21666, 256, 21750, 256, 21776, 256, + 21843, 256, 21859, 256, 21892, 256, 21931, 256, 21939, 256, 21954, 256, + 22294, 256, 22295, 256, 22097, 256, 22132, 256, 22766, 256, 22478, 256, + 22516, 256, 22541, 256, 22411, 256, 22578, 256, 22577, 256, 22700, 256, + 136420, 256, 22770, 256, 22775, 256, 22790, 256, 22810, 256, 22818, 256, + 22882, 256, 136872, 256, 136938, 256, 23020, 256, 23067, 256, 23079, 256, + 23000, 256, 23142, 256, 14062, 256, 14076, 256, 23304, 256, 23358, 256, + 137672, 256, 23491, 256, 23512, 256, 23539, 256, 138008, 256, 23551, 256, + 23558, 256, 24403, 256, 23586, 256, 14209, 256, 23648, 256, 23744, 256, + 23693, 256, 138724, 256, 23875, 256, 138726, 256, 23918, 256, 23915, 256, + 23932, 256, 24033, 256, 24034, 256, 14383, 256, 24061, 256, 24104, 256, + 24125, 256, 24169, 256, 14434, 256, 139651, 256, 14460, 256, 24240, 256, + 24243, 256, 24246, 256, 172946, 256, 24318, 256, 140081, 256, 33281, 256, + 24354, 256, 14535, 256, 144056, 256, 156122, 256, 24418, 256, 24427, 256, + 14563, 256, 24474, 256, 24525, 256, 24535, 256, 24569, 256, 24705, 256, + 14650, 256, 14620, 256, 141012, 256, 24775, 256, 24904, 256, 24908, 256, + 24954, 256, 25010, 256, 24996, 256, 25007, 256, 25054, 256, 25104, 256, + 25115, 256, 25181, 256, 25265, 256, 25300, 256, 25424, 256, 142092, 256, + 25405, 256, 25340, 256, 25448, 256, 25475, 256, 25572, 256, 142321, 256, + 25634, 256, 25541, 256, 25513, 256, 14894, 256, 25705, 256, 25726, 256, + 25757, 256, 25719, 256, 14956, 256, 25964, 256, 143370, 256, 26083, 256, + 26360, 256, 26185, 256, 15129, 256, 15112, 256, 15076, 256, 20882, 256, + 20885, 256, 26368, 256, 26268, 256, 32941, 256, 17369, 256, 26401, 256, + 26462, 256, 26451, 256, 144323, 256, 15177, 256, 26618, 256, 26501, 256, + 26706, 256, 144493, 256, 26766, 256, 26655, 256, 26900, 256, 26946, 256, + 27043, 256, 27114, 256, 27304, 256, 145059, 256, 27355, 256, 15384, 256, + 27425, 256, 145575, 256, 27476, 256, 15438, 256, 27506, 256, 27551, 256, + 27579, 256, 146061, 256, 138507, 256, 146170, 256, 27726, 256, 146620, + 256, 27839, 256, 27853, 256, 27751, 256, 27926, 256, 27966, 256, 28009, + 256, 28024, 256, 28037, 256, 146718, 256, 27956, 256, 28207, 256, 28270, + 256, 15667, 256, 28359, 256, 147153, 256, 28153, 256, 28526, 256, 147294, + 256, 147342, 256, 28614, 256, 28729, 256, 28699, 256, 15766, 256, 28746, + 256, 28797, 256, 28791, 256, 28845, 256, 132389, 256, 28997, 256, 148067, + 256, 29084, 256, 148395, 256, 29224, 256, 29264, 256, 149000, 256, 29312, + 256, 29333, 256, 149301, 256, 149524, 256, 29562, 256, 29579, 256, 16044, + 256, 29605, 256, 16056, 256, 29767, 256, 29788, 256, 29829, 256, 29898, + 256, 16155, 256, 29988, 256, 150582, 256, 30014, 256, 150674, 256, + 139679, 256, 30224, 256, 151457, 256, 151480, 256, 151620, 256, 16380, + 256, 16392, 256, 151795, 256, 151794, 256, 151833, 256, 151859, 256, + 30494, 256, 30495, 256, 30603, 256, 16454, 256, 16534, 256, 152605, 256, + 30798, 256, 16611, 256, 153126, 256, 153242, 256, 153285, 256, 31211, + 256, 16687, 256, 31306, 256, 31311, 256, 153980, 256, 154279, 256, 31470, + 256, 16898, 256, 154539, 256, 31686, 256, 31689, 256, 16935, 256, 154752, + 256, 31954, 256, 17056, 256, 31976, 256, 31971, 256, 32000, 256, 155526, + 256, 32099, 256, 17153, 256, 32199, 256, 32258, 256, 32325, 256, 17204, + 256, 156200, 256, 156231, 256, 17241, 256, 156377, 256, 32634, 256, + 156478, 256, 32661, 256, 32762, 256, 156890, 256, 156963, 256, 32864, + 256, 157096, 256, 32880, 256, 144223, 256, 17365, 256, 32946, 256, 33027, + 256, 17419, 256, 33086, 256, 23221, 256, 157607, 256, 157621, 256, + 144275, 256, 144284, 256, 33284, 256, 36766, 256, 17515, 256, 33425, 256, + 33419, 256, 33437, 256, 21171, 256, 33457, 256, 33459, 256, 33469, 256, + 33510, 256, 158524, 256, 33565, 256, 33635, 256, 33709, 256, 33571, 256, + 33725, 256, 33767, 256, 33619, 256, 33738, 256, 33740, 256, 33756, 256, + 158774, 256, 159083, 256, 158933, 256, 17707, 256, 34033, 256, 34035, + 256, 34070, 256, 160714, 256, 34148, 256, 159532, 256, 17757, 256, 17761, + 256, 159665, 256, 159954, 256, 17771, 256, 34384, 256, 34407, 256, 34409, + 256, 34473, 256, 34440, 256, 34574, 256, 34530, 256, 34600, 256, 34667, + 256, 34694, 256, 17879, 256, 34785, 256, 34817, 256, 17913, 256, 34912, + 256, 34915, 256, 161383, 256, 35031, 256, 35038, 256, 17973, 256, 35066, + 256, 13499, 256, 161966, 256, 162150, 256, 18110, 256, 18119, 256, 35488, + 256, 35925, 256, 162984, 256, 36011, 256, 36033, 256, 36123, 256, 36215, + 256, 163631, 256, 133124, 256, 36299, 256, 36284, 256, 36336, 256, + 133342, 256, 36564, 256, 165330, 256, 165357, 256, 37012, 256, 37105, + 256, 37137, 256, 165678, 256, 37147, 256, 37432, 256, 37591, 256, 37592, + 256, 37500, 256, 37881, 256, 37909, 256, 166906, 256, 38283, 256, 18837, + 256, 38327, 256, 167287, 256, 18918, 256, 38595, 256, 23986, 256, 38691, + 256, 168261, 256, 168474, 256, 19054, 256, 19062, 256, 38880, 256, + 168970, 256, 19122, 256, 169110, 256, 38953, 256, 169398, 256, 39138, + 256, 19251, 256, 39209, 256, 39335, 256, 39362, 256, 39422, 256, 19406, + 256, 170800, 256, 40000, 256, 40189, 256, 19662, 256, 19693, 256, 40295, + 256, 172238, 256, 19704, 256, 172293, 256, 172558, 256, 172689, 256, + 40635, 256, 19798, 256, 40697, 256, 40702, 256, 40709, 256, 40719, 256, + 40726, 256, 40763, 256, 173568, }; /* index tables for the decomposition data */ #define DECOMP_SHIFT 7 static const unsigned char decomp_index1[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 0, 0, 0, 0, 13, 14, 15, 0, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 0, 0, 0, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, - 45, 0, 0, 46, 0, 47, 0, 0, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 0, 14, 15, 16, 0, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 0, 0, 0, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 0, 43, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, + 46, 0, 0, 47, 0, 48, 0, 0, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -5472,36 +5549,37 @@ static const unsigned char decomp_index1[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 59, 60, 61, 0, 0, 0, 0, 0, 0, 62, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 61, 62, 0, 0, 0, 0, 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 75, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 78, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, 80, 0, 0, 0, 81, 82, 0, 83, 0, - 84, 0, 0, 0, 0, 0, 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 78, 0, 0, 0, 79, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 81, 0, 0, 0, 82, 83, 0, 84, 0, + 85, 0, 0, 0, 0, 0, 0, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 90, 0, 0, 0, 0, 0, 0, 0, 0, 91, 92, 0, 0, 0, 0, 93, 94, + 95, 96, 97, 98, 99, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 101, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 103, 104, 0, 0, 0, 0, 105, 106, 107, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 88, 0, 0, 0, 0, 0, 0, 0, 0, 89, 90, 0, 0, 0, 0, 91, 92, - 93, 94, 95, 96, 97, 98, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 100, 101, 0, 0, 0, 0, 102, 103, 104, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -5521,8 +5599,8 @@ static const unsigned char decomp_index1[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 110, 111, 112, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 106, 107, 108, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -5821,7 +5899,6 @@ static const unsigned char decomp_index1[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; static const unsigned short decomp_index2[] = { @@ -5889,807 +5966,827 @@ static const unsigned short decomp_index2[] = { 0, 0, 0, 1063, 1066, 1069, 1072, 0, 0, 1075, 1078, 0, 0, 1081, 1084, 1087, 1090, 1093, 1096, 0, 0, 1099, 1102, 1105, 1108, 1111, 1114, 0, 0, 1117, 1120, 1123, 1126, 1129, 1132, 1135, 1138, 1141, 1144, 1147, 1150, - 0, 0, 1153, 1156, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1159, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1162, 1165, 1168, 1171, 1174, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1177, 1180, 1183, 1186, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1189, 0, 1192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1195, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1153, 1156, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1198, 0, 0, 0, - 0, 0, 0, 0, 1201, 0, 0, 1204, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1207, - 1210, 1213, 1216, 1219, 1222, 1225, 1228, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1159, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1161, 0, 0, 0, 1164, 1166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1231, 1234, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1237, 1240, - 0, 1243, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1246, 0, 0, 1249, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1252, 1255, 1258, 0, 0, 1261, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1168, 1171, 1174, + 1177, 1180, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1183, 1186, 1189, 1192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1264, 0, 0, 1267, 1270, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1273, 1276, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1279, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1195, 0, 1198, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1201, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1282, 1285, 1288, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1204, 0, 0, 0, 0, 0, 0, 0, 1207, 0, 0, 1210, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1213, 1216, 1219, 1222, 1225, 1228, 1231, 1234, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1291, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1237, 1240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1243, 1246, 0, 1249, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1294, 0, 0, 0, 0, 0, 0, 1297, 1300, 0, 1303, 1306, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1252, 0, 0, 1255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1258, 1261, 1264, 0, 0, + 1267, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1309, 1312, 1315, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1270, 0, 0, 1273, 1276, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1279, 1282, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1285, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1288, 1291, 1294, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1318, 0, 1321, 1324, 1327, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1297, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1330, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1300, 0, 0, 0, 0, 0, 0, 1303, + 1306, 0, 1309, 1312, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1336, 1339, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1342, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1344, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1347, 0, 0, 0, 0, 1350, 0, 0, 0, 0, 1353, 0, 0, 0, 0, 1356, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1359, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1362, 0, - 1365, 1368, 1371, 1374, 1377, 0, 0, 0, 0, 0, 0, 0, 1380, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1383, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1386, 0, 0, 0, 0, 1389, 0, 0, 0, 0, 1392, 0, 0, 0, 0, 1395, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1398, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1315, 1318, 1321, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1401, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1324, 0, 1327, 1330, + 1333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1336, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1404, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1406, 0, 1409, 0, 1412, 0, 1415, 0, 1418, 0, 0, - 0, 1421, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1424, 0, 1427, - 0, 0, 1430, 1433, 0, 1436, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1339, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1342, 1345, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1348, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1350, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1353, 0, 0, 0, 0, 1356, 0, + 0, 0, 0, 1359, 0, 0, 0, 0, 1362, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1365, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1368, 0, 1371, 1374, 1377, 1380, 1383, + 0, 0, 0, 0, 0, 0, 0, 1386, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1389, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1392, 0, 0, 0, 0, 1395, 0, 0, 0, + 0, 1398, 0, 0, 0, 0, 1401, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1404, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1407, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1410, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1412, 0, + 1415, 0, 1418, 0, 1421, 0, 1424, 0, 0, 0, 1427, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1430, 0, 1433, 0, 0, 1436, 1439, 0, 1442, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1445, 1447, 1449, 0, 1451, 1453, 1455, 1457, 1459, + 1461, 1463, 1465, 1467, 1469, 1471, 0, 1473, 1475, 1477, 1479, 1481, + 1483, 1485, 6, 1487, 1489, 1491, 1493, 1495, 1497, 1499, 1501, 1503, + 1505, 0, 1507, 1509, 1511, 25, 1513, 1515, 1517, 1519, 1521, 1523, 1525, + 1527, 1529, 1531, 1533, 1535, 1537, 1539, 1541, 1543, 1545, 1547, 1549, + 1551, 1553, 1555, 1557, 1559, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1561, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1563, 1565, 1567, 1569, 1503, 1571, + 1573, 1575, 1577, 1579, 1581, 1583, 1585, 1587, 1589, 1591, 1593, 1595, + 1597, 1599, 1601, 1603, 1605, 1607, 1609, 1611, 1613, 1615, 1617, 1619, + 1621, 1623, 1625, 1627, 1629, 1631, 1633, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1439, 1441, 1443, 0, - 1445, 1447, 1449, 1451, 1453, 1455, 1457, 1459, 1461, 1463, 1465, 0, - 1467, 1469, 1471, 1473, 1475, 1477, 1479, 6, 1481, 1483, 1485, 1487, - 1489, 1491, 1493, 1495, 1497, 1499, 0, 1501, 1503, 1505, 25, 1507, 1509, - 1511, 1513, 1515, 1517, 1519, 1521, 1523, 1525, 1527, 1529, 1531, 1533, - 1535, 1537, 1539, 1541, 1543, 1545, 1547, 1549, 1551, 1553, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1555, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1557, - 1559, 1561, 1563, 1497, 1565, 1567, 1569, 1571, 1573, 1575, 1577, 1579, - 1581, 1583, 1585, 1587, 1589, 1591, 1593, 1595, 1597, 1599, 1601, 1603, - 1605, 1607, 1609, 1611, 1613, 1615, 1617, 1619, 1621, 1623, 1625, 1627, + 0, 0, 0, 0, 0, 0, 1635, 1638, 1641, 1644, 1647, 1650, 1653, 1656, 1659, + 1662, 1665, 1668, 1671, 1674, 1677, 1680, 1683, 1686, 1689, 1692, 1695, + 1698, 1701, 1704, 1707, 1710, 1713, 1716, 1719, 1722, 1725, 1728, 1731, + 1734, 1737, 1740, 1743, 1746, 1749, 1752, 1755, 1758, 1761, 1764, 1767, + 1770, 1773, 1776, 1779, 1782, 1785, 1788, 1791, 1794, 1797, 1800, 1803, + 1806, 1809, 1812, 1815, 1818, 1821, 1824, 1827, 1830, 1833, 1836, 1839, + 1842, 1845, 1848, 1851, 1854, 1857, 1860, 1863, 1866, 1869, 1872, 1875, + 1878, 1881, 1884, 1887, 1890, 1893, 1896, 1899, 1902, 1905, 1908, 1911, + 1914, 1917, 1920, 1923, 1926, 1929, 1932, 1935, 1938, 1941, 1944, 1947, + 1950, 1953, 1956, 1959, 1962, 1965, 1968, 1971, 1974, 1977, 1980, 1983, + 1986, 1989, 1992, 1995, 1998, 2001, 2004, 2007, 2010, 2013, 2016, 2019, + 2022, 2025, 2028, 2031, 2034, 2037, 2040, 2043, 2046, 2049, 2052, 2055, + 2058, 2061, 2064, 2067, 2070, 2073, 2076, 2079, 2082, 2085, 2088, 2091, + 2094, 2097, 2100, 0, 0, 0, 0, 2103, 2106, 2109, 2112, 2115, 2118, 2121, + 2124, 2127, 2130, 2133, 2136, 2139, 2142, 2145, 2148, 2151, 2154, 2157, + 2160, 2163, 2166, 2169, 2172, 2175, 2178, 2181, 2184, 2187, 2190, 2193, + 2196, 2199, 2202, 2205, 2208, 2211, 2214, 2217, 2220, 2223, 2226, 2229, + 2232, 2235, 2238, 2241, 2244, 2247, 2250, 2253, 2256, 2259, 2262, 2265, + 2268, 2271, 2274, 2277, 2280, 2283, 2286, 2289, 2292, 2295, 2298, 2301, + 2304, 2307, 2310, 2313, 2316, 2319, 2322, 2325, 2328, 2331, 2334, 2337, + 2340, 2343, 2346, 2349, 2352, 2355, 2358, 2361, 2364, 2367, 2370, 0, 0, + 0, 0, 0, 0, 2373, 2376, 2379, 2382, 2385, 2388, 2391, 2394, 2397, 2400, + 2403, 2406, 2409, 2412, 2415, 2418, 2421, 2424, 2427, 2430, 2433, 2436, + 0, 0, 2439, 2442, 2445, 2448, 2451, 2454, 0, 0, 2457, 2460, 2463, 2466, + 2469, 2472, 2475, 2478, 2481, 2484, 2487, 2490, 2493, 2496, 2499, 2502, + 2505, 2508, 2511, 2514, 2517, 2520, 2523, 2526, 2529, 2532, 2535, 2538, + 2541, 2544, 2547, 2550, 2553, 2556, 2559, 2562, 2565, 2568, 0, 0, 2571, + 2574, 2577, 2580, 2583, 2586, 0, 0, 2589, 2592, 2595, 2598, 2601, 2604, + 2607, 2610, 0, 2613, 0, 2616, 0, 2619, 0, 2622, 2625, 2628, 2631, 2634, + 2637, 2640, 2643, 2646, 2649, 2652, 2655, 2658, 2661, 2664, 2667, 2670, + 2673, 2676, 2678, 2681, 2683, 2686, 2688, 2691, 2693, 2696, 2698, 2701, + 2703, 2706, 0, 0, 2708, 2711, 2714, 2717, 2720, 2723, 2726, 2729, 2732, + 2735, 2738, 2741, 2744, 2747, 2750, 2753, 2756, 2759, 2762, 2765, 2768, + 2771, 2774, 2777, 2780, 2783, 2786, 2789, 2792, 2795, 2798, 2801, 2804, + 2807, 2810, 2813, 2816, 2819, 2822, 2825, 2828, 2831, 2834, 2837, 2840, + 2843, 2846, 2849, 2852, 2855, 2858, 2861, 2864, 0, 2867, 2870, 2873, + 2876, 2879, 2882, 2884, 2887, 2890, 2887, 2892, 2895, 2898, 2901, 2904, + 0, 2907, 2910, 2913, 2916, 2918, 2921, 2923, 2926, 2929, 2932, 2935, + 2938, 2941, 2944, 0, 0, 2946, 2949, 2952, 2955, 2958, 2961, 0, 2963, + 2966, 2969, 2972, 2975, 2978, 2981, 2983, 2986, 2989, 2992, 2995, 2998, + 3001, 3004, 3006, 3009, 3012, 3014, 0, 0, 3016, 3019, 3022, 0, 3025, + 3028, 3031, 3034, 3036, 3039, 3041, 3044, 3046, 0, 3049, 3051, 3053, + 3053, 3053, 3053, 3053, 1, 3053, 3053, 3053, 0, 0, 0, 0, 0, 0, 3055, 0, + 0, 0, 0, 0, 3057, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3060, 3062, 3065, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3069, 3072, 0, 3076, 3079, 0, 0, 0, + 0, 3083, 0, 3086, 0, 0, 0, 0, 0, 0, 0, 0, 3089, 3092, 3095, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 3098, 0, 0, 0, 0, 0, 0, 0, 3053, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3103, 3105, 0, 0, 3107, 3109, 3111, + 3113, 3115, 3117, 3119, 3121, 3123, 3125, 3127, 3129, 3131, 3133, 3135, + 3137, 3139, 3141, 3143, 3145, 3147, 3149, 3151, 3153, 3155, 3157, 3159, + 0, 3161, 3163, 3165, 3167, 3169, 3171, 3173, 3175, 3177, 3179, 3181, + 3183, 3185, 3187, 3189, 3191, 0, 0, 0, 0, 0, 0, 0, 0, 3193, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1629, 1632, 1635, 1638, - 1641, 1644, 1647, 1650, 1653, 1656, 1659, 1662, 1665, 1668, 1671, 1674, - 1677, 1680, 1683, 1686, 1689, 1692, 1695, 1698, 1701, 1704, 1707, 1710, - 1713, 1716, 1719, 1722, 1725, 1728, 1731, 1734, 1737, 1740, 1743, 1746, - 1749, 1752, 1755, 1758, 1761, 1764, 1767, 1770, 1773, 1776, 1779, 1782, - 1785, 1788, 1791, 1794, 1797, 1800, 1803, 1806, 1809, 1812, 1815, 1818, - 1821, 1824, 1827, 1830, 1833, 1836, 1839, 1842, 1845, 1848, 1851, 1854, - 1857, 1860, 1863, 1866, 1869, 1872, 1875, 1878, 1881, 1884, 1887, 1890, - 1893, 1896, 1899, 1902, 1905, 1908, 1911, 1914, 1917, 1920, 1923, 1926, - 1929, 1932, 1935, 1938, 1941, 1944, 1947, 1950, 1953, 1956, 1959, 1962, - 1965, 1968, 1971, 1974, 1977, 1980, 1983, 1986, 1989, 1992, 1995, 1998, - 2001, 2004, 2007, 2010, 2013, 2016, 2019, 2022, 2025, 2028, 2031, 2034, - 2037, 2040, 2043, 2046, 2049, 2052, 2055, 2058, 2061, 2064, 2067, 2070, - 2073, 2076, 2079, 2082, 2085, 2088, 2091, 2094, 0, 0, 0, 0, 2097, 2100, - 2103, 2106, 2109, 2112, 2115, 2118, 2121, 2124, 2127, 2130, 2133, 2136, - 2139, 2142, 2145, 2148, 2151, 2154, 2157, 2160, 2163, 2166, 2169, 2172, - 2175, 2178, 2181, 2184, 2187, 2190, 2193, 2196, 2199, 2202, 2205, 2208, - 2211, 2214, 2217, 2220, 2223, 2226, 2229, 2232, 2235, 2238, 2241, 2244, - 2247, 2250, 2253, 2256, 2259, 2262, 2265, 2268, 2271, 2274, 2277, 2280, - 2283, 2286, 2289, 2292, 2295, 2298, 2301, 2304, 2307, 2310, 2313, 2316, - 2319, 2322, 2325, 2328, 2331, 2334, 2337, 2340, 2343, 2346, 2349, 2352, - 2355, 2358, 2361, 2364, 0, 0, 0, 0, 0, 0, 2367, 2370, 2373, 2376, 2379, - 2382, 2385, 2388, 2391, 2394, 2397, 2400, 2403, 2406, 2409, 2412, 2415, - 2418, 2421, 2424, 2427, 2430, 0, 0, 2433, 2436, 2439, 2442, 2445, 2448, - 0, 0, 2451, 2454, 2457, 2460, 2463, 2466, 2469, 2472, 2475, 2478, 2481, - 2484, 2487, 2490, 2493, 2496, 2499, 2502, 2505, 2508, 2511, 2514, 2517, - 2520, 2523, 2526, 2529, 2532, 2535, 2538, 2541, 2544, 2547, 2550, 2553, - 2556, 2559, 2562, 0, 0, 2565, 2568, 2571, 2574, 2577, 2580, 0, 0, 2583, - 2586, 2589, 2592, 2595, 2598, 2601, 2604, 0, 2607, 0, 2610, 0, 2613, 0, - 2616, 2619, 2622, 2625, 2628, 2631, 2634, 2637, 2640, 2643, 2646, 2649, - 2652, 2655, 2658, 2661, 2664, 2667, 2670, 2672, 2675, 2677, 2680, 2682, - 2685, 2687, 2690, 2692, 2695, 2697, 2700, 0, 0, 2702, 2705, 2708, 2711, - 2714, 2717, 2720, 2723, 2726, 2729, 2732, 2735, 2738, 2741, 2744, 2747, - 2750, 2753, 2756, 2759, 2762, 2765, 2768, 2771, 2774, 2777, 2780, 2783, - 2786, 2789, 2792, 2795, 2798, 2801, 2804, 2807, 2810, 2813, 2816, 2819, - 2822, 2825, 2828, 2831, 2834, 2837, 2840, 2843, 2846, 2849, 2852, 2855, - 2858, 0, 2861, 2864, 2867, 2870, 2873, 2876, 2878, 2881, 2884, 2881, - 2886, 2889, 2892, 2895, 2898, 0, 2901, 2904, 2907, 2910, 2912, 2915, - 2917, 2920, 2923, 2926, 2929, 2932, 2935, 2938, 0, 0, 2940, 2943, 2946, - 2949, 2952, 2955, 0, 2957, 2960, 2963, 2966, 2969, 2972, 2975, 2977, - 2980, 2983, 2986, 2989, 2992, 2995, 2998, 3000, 3003, 3006, 3008, 0, 0, - 3010, 3013, 3016, 0, 3019, 3022, 3025, 3028, 3030, 3033, 3035, 3038, - 3040, 0, 3043, 3045, 3047, 3047, 3047, 3047, 3047, 1, 3047, 3047, 3047, - 0, 0, 0, 0, 0, 0, 3049, 0, 0, 0, 0, 0, 3051, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 3054, 3056, 3059, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3063, - 3066, 0, 3070, 3073, 0, 0, 0, 0, 3077, 0, 3080, 0, 0, 0, 0, 0, 0, 0, 0, - 3083, 3086, 3089, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3092, 0, 0, 0, - 0, 0, 0, 0, 3047, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3097, - 3099, 0, 0, 3101, 3103, 3105, 3107, 3109, 3111, 3113, 3115, 3117, 3119, - 3121, 3123, 3125, 3127, 3129, 3131, 3133, 3135, 3137, 3139, 3141, 3143, - 3145, 3147, 3149, 3151, 3153, 0, 3155, 3157, 3159, 3161, 3163, 3165, - 3167, 3169, 3171, 3173, 3175, 3177, 3179, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 3181, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3184, 3188, 3192, - 3194, 0, 3197, 3201, 3205, 0, 3207, 3210, 3212, 3212, 3212, 3214, 3216, - 3218, 3218, 3220, 3222, 0, 3224, 3226, 0, 0, 3229, 3231, 3233, 3233, - 3233, 0, 0, 3235, 3238, 3242, 0, 3245, 0, 3247, 0, 3245, 0, 3249, 3251, - 3253, 3192, 0, 3255, 3257, 3259, 0, 3261, 3263, 3265, 3267, 3269, 3271, - 3273, 0, 3275, 3279, 3281, 3283, 3285, 3287, 0, 0, 0, 0, 3289, 3291, - 3255, 3273, 3293, 0, 0, 0, 0, 0, 0, 3295, 3299, 3303, 3308, 3312, 3316, - 3320, 3324, 3328, 3332, 3336, 3340, 3344, 3348, 3352, 3356, 3359, 3361, - 3364, 3368, 3371, 3373, 3376, 3380, 3385, 3388, 3390, 3393, 3397, 3399, - 3401, 3403, 3405, 3407, 3410, 3414, 3417, 3419, 3422, 3426, 3431, 3434, - 3436, 3439, 3443, 3445, 3447, 3449, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3451, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3455, 3458, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3461, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3464, - 3467, 3470, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 3473, 0, 0, 0, 0, 3476, 0, 0, 3479, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3482, 0, 3485, - 0, 0, 0, 0, 0, 3488, 3491, 0, 3495, 3498, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 3502, 0, 0, 3505, 0, 0, 3508, 0, 3511, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3514, 0, 3517, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 3520, 3523, 3526, 3529, 3532, 0, 0, 3535, 3538, - 0, 0, 3541, 3544, 0, 0, 0, 0, 0, 0, 3547, 3550, 0, 0, 3553, 3556, 0, 0, - 3559, 3562, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3565, 3568, 3571, 3574, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3577, - 3580, 3583, 3586, 0, 0, 0, 0, 0, 0, 3589, 3592, 3595, 3598, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 3601, 3603, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 3605, 3607, 3609, 3611, 3613, 3615, 3617, 3619, 3621, 3623, 3626, 3629, - 3632, 3635, 3638, 3641, 3644, 3647, 3650, 3653, 3656, 3660, 3664, 3668, - 3672, 3676, 3680, 3684, 3688, 3692, 3697, 3702, 3707, 3712, 3717, 3722, - 3727, 3732, 3737, 3742, 3747, 3750, 3753, 3756, 3759, 3762, 3765, 3768, - 3771, 3774, 3778, 3782, 3786, 3790, 3794, 3798, 3802, 3806, 3810, 3814, - 3818, 3822, 3826, 3830, 3834, 3838, 3842, 3846, 3850, 3854, 3858, 3862, - 3866, 3870, 3874, 3878, 3882, 3886, 3890, 3894, 3898, 3902, 3906, 3910, - 3914, 3918, 3922, 3924, 3926, 3928, 3930, 3932, 3934, 3936, 3938, 3940, - 3942, 3944, 3946, 3948, 3950, 3952, 3954, 3956, 3958, 3960, 3962, 3964, - 3966, 3968, 3970, 3972, 3974, 3976, 3978, 3980, 3982, 3984, 3986, 3988, - 3990, 3992, 3994, 3996, 3998, 4000, 4002, 4004, 4006, 4008, 4010, 4012, - 4014, 4016, 4018, 4020, 4022, 4024, 4026, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4028, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3196, 3200, 3204, 3206, 0, 3209, 3213, + 3217, 0, 3219, 3222, 3224, 3224, 3224, 3226, 3228, 3230, 3230, 3232, + 3234, 0, 3236, 3238, 0, 0, 3241, 3243, 3245, 3245, 3245, 0, 0, 3247, + 3250, 3254, 0, 3257, 0, 3259, 0, 3257, 0, 3261, 3263, 3265, 3204, 0, + 3267, 3269, 3271, 0, 3273, 3275, 3277, 3279, 3281, 3283, 3285, 0, 3287, + 3291, 3293, 3295, 3297, 3299, 0, 0, 0, 0, 3301, 3303, 3267, 3285, 3305, + 0, 0, 0, 0, 0, 0, 3307, 3311, 3315, 3320, 3324, 3328, 3332, 3336, 3340, + 3344, 3348, 3352, 3356, 3360, 3364, 3368, 3371, 3373, 3376, 3380, 3383, + 3385, 3388, 3392, 3397, 3400, 3402, 3405, 3409, 3411, 3413, 3415, 3417, + 3419, 3422, 3426, 3429, 3431, 3434, 3438, 3443, 3446, 3448, 3451, 3455, + 3457, 3459, 3461, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3463, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 3467, 3470, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3473, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3476, 3479, 3482, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4033, 4037, 4040, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 3485, 0, 0, 0, 0, 3488, 0, 0, 3491, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3494, 0, 3497, 0, 0, 0, 0, 0, 3500, + 3503, 0, 3507, 3510, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 3514, 0, 0, 3517, 0, 0, 3520, 0, 3523, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3526, 0, 3529, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 3532, 3535, 3538, 3541, 3544, 0, 0, 3547, 3550, 0, 0, 3553, 3556, + 0, 0, 0, 0, 0, 0, 3559, 3562, 0, 0, 3565, 3568, 0, 0, 3571, 3574, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 3577, 3580, 3583, 3586, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3589, 3592, 3595, 3598, + 0, 0, 0, 0, 0, 0, 3601, 3604, 3607, 3610, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 3613, 3615, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3617, 3619, 3621, + 3623, 3625, 3627, 3629, 3631, 3633, 3635, 3638, 3641, 3644, 3647, 3650, + 3653, 3656, 3659, 3662, 3665, 3668, 3672, 3676, 3680, 3684, 3688, 3692, + 3696, 3700, 3704, 3709, 3714, 3719, 3724, 3729, 3734, 3739, 3744, 3749, + 3754, 3759, 3762, 3765, 3768, 3771, 3774, 3777, 3780, 3783, 3786, 3790, + 3794, 3798, 3802, 3806, 3810, 3814, 3818, 3822, 3826, 3830, 3834, 3838, + 3842, 3846, 3850, 3854, 3858, 3862, 3866, 3870, 3874, 3878, 3882, 3886, + 3890, 3894, 3898, 3902, 3906, 3910, 3914, 3918, 3922, 3926, 3930, 3934, + 3936, 3938, 3940, 3942, 3944, 3946, 3948, 3950, 3952, 3954, 3956, 3958, + 3960, 3962, 3964, 3966, 3968, 3970, 3972, 3974, 3976, 3978, 3980, 3982, + 3984, 3986, 3988, 3990, 3992, 3994, 3996, 3998, 4000, 4002, 4004, 4006, + 4008, 4010, 4012, 4014, 4016, 4018, 4020, 4022, 4024, 4026, 4028, 4030, + 4032, 4034, 4036, 4038, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4040, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 4045, 4049, 4052, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4056, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 4059, 4061, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 4063, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 4065, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4067, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 4069, 4071, 4073, 4075, 4077, 4079, 4081, 4083, + 4085, 4087, 4089, 4091, 4093, 4095, 4097, 4099, 4101, 4103, 4105, 4107, + 4109, 4111, 4113, 4115, 4117, 4119, 4121, 4123, 4125, 4127, 4129, 4131, + 4133, 4135, 4137, 4139, 4141, 4143, 4145, 4147, 4149, 4151, 4153, 4155, + 4157, 4159, 4161, 4163, 4165, 4167, 4169, 4171, 4173, 4175, 4177, 4179, + 4181, 4183, 4185, 4187, 4189, 4191, 4193, 4195, 4197, 4199, 4201, 4203, + 4205, 4207, 4209, 4211, 4213, 4215, 4217, 4219, 4221, 4223, 4225, 4227, + 4229, 4231, 4233, 4235, 4237, 4239, 4241, 4243, 4245, 4247, 4249, 4251, + 4253, 4255, 4257, 4259, 4261, 4263, 4265, 4267, 4269, 4271, 4273, 4275, + 4277, 4279, 4281, 4283, 4285, 4287, 4289, 4291, 4293, 4295, 4297, 4299, + 4301, 4303, 4305, 4307, 4309, 4311, 4313, 4315, 4317, 4319, 4321, 4323, + 4325, 4327, 4329, 4331, 4333, 4335, 4337, 4339, 4341, 4343, 4345, 4347, + 4349, 4351, 4353, 4355, 4357, 4359, 4361, 4363, 4365, 4367, 4369, 4371, + 4373, 4375, 4377, 4379, 4381, 4383, 4385, 4387, 4389, 4391, 4393, 4395, + 4397, 4399, 4401, 4403, 4405, 4407, 4409, 4411, 4413, 4415, 4417, 4419, + 4421, 4423, 4425, 4427, 4429, 4431, 4433, 4435, 4437, 4439, 4441, 4443, + 4445, 4447, 4449, 4451, 4453, 4455, 4457, 4459, 4461, 4463, 4465, 4467, + 4469, 4471, 4473, 4475, 4477, 4479, 4481, 4483, 4485, 4487, 4489, 4491, + 4493, 4495, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4497, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 4499, 0, 4115, 4501, 4503, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 4505, 0, 4508, 0, 4511, 0, 4514, 0, 4517, 0, 4520, + 0, 4523, 0, 4526, 0, 4529, 0, 4532, 0, 4535, 0, 4538, 0, 0, 4541, 0, + 4544, 0, 4547, 0, 0, 0, 0, 0, 0, 4550, 4553, 0, 4556, 4559, 0, 4562, + 4565, 0, 4568, 4571, 0, 4574, 4577, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4580, 0, 0, 0, 0, 0, 0, 4583, 4586, 0, + 4589, 4592, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4595, 0, 4598, 0, 4601, + 0, 4604, 0, 4607, 0, 4610, 0, 4613, 0, 4616, 0, 4619, 0, 4622, 0, 4625, + 0, 4628, 0, 0, 4631, 0, 4634, 0, 4637, 0, 0, 0, 0, 0, 0, 4640, 4643, 0, + 4646, 4649, 0, 4652, 4655, 0, 4658, 4661, 0, 4664, 4667, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4670, 0, 0, 4673, + 4676, 4679, 4682, 0, 0, 0, 4685, 4688, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4044, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4047, 4049, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4051, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4053, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4691, 4693, 4695, 4697, 4699, + 4701, 4703, 4705, 4707, 4709, 4711, 4713, 4715, 4717, 4719, 4721, 4723, + 4725, 4727, 4729, 4731, 4733, 4735, 4737, 4739, 4741, 4743, 4745, 4747, + 4749, 4751, 4753, 4755, 4757, 4759, 4761, 4763, 4765, 4767, 4769, 4771, + 4773, 4775, 4777, 4779, 4781, 4783, 4785, 4787, 4789, 4791, 4793, 4795, + 4797, 4799, 4801, 4803, 4805, 4807, 4809, 4811, 4813, 4815, 4817, 4819, + 4821, 4823, 4825, 4827, 4829, 4831, 4833, 4835, 4837, 4839, 4841, 4843, + 4845, 4847, 4849, 4851, 4853, 4855, 4857, 4859, 4861, 4863, 4865, 4867, + 4869, 4871, 4873, 4875, 4877, 0, 0, 0, 4879, 4881, 4883, 4885, 4887, + 4889, 4891, 4893, 4895, 4897, 4899, 4901, 4903, 4905, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4055, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4057, 4059, 4061, 4063, 4065, - 4067, 4069, 4071, 4073, 4075, 4077, 4079, 4081, 4083, 4085, 4087, 4089, - 4091, 4093, 4095, 4097, 4099, 4101, 4103, 4105, 4107, 4109, 4111, 4113, - 4115, 4117, 4119, 4121, 4123, 4125, 4127, 4129, 4131, 4133, 4135, 4137, - 4139, 4141, 4143, 4145, 4147, 4149, 4151, 4153, 4155, 4157, 4159, 4161, - 4163, 4165, 4167, 4169, 4171, 4173, 4175, 4177, 4179, 4181, 4183, 4185, - 4187, 4189, 4191, 4193, 4195, 4197, 4199, 4201, 4203, 4205, 4207, 4209, - 4211, 4213, 4215, 4217, 4219, 4221, 4223, 4225, 4227, 4229, 4231, 4233, - 4235, 4237, 4239, 4241, 4243, 4245, 4247, 4249, 4251, 4253, 4255, 4257, - 4259, 4261, 4263, 4265, 4267, 4269, 4271, 4273, 4275, 4277, 4279, 4281, - 4283, 4285, 4287, 4289, 4291, 4293, 4295, 4297, 4299, 4301, 4303, 4305, - 4307, 4309, 4311, 4313, 4315, 4317, 4319, 4321, 4323, 4325, 4327, 4329, - 4331, 4333, 4335, 4337, 4339, 4341, 4343, 4345, 4347, 4349, 4351, 4353, - 4355, 4357, 4359, 4361, 4363, 4365, 4367, 4369, 4371, 4373, 4375, 4377, - 4379, 4381, 4383, 4385, 4387, 4389, 4391, 4393, 4395, 4397, 4399, 4401, - 4403, 4405, 4407, 4409, 4411, 4413, 4415, 4417, 4419, 4421, 4423, 4425, - 4427, 4429, 4431, 4433, 4435, 4437, 4439, 4441, 4443, 4445, 4447, 4449, - 4451, 4453, 4455, 4457, 4459, 4461, 4463, 4465, 4467, 4469, 4471, 4473, - 4475, 4477, 4479, 4481, 4483, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 4485, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4907, 4911, 4915, + 4919, 4923, 4927, 4931, 4935, 4939, 4943, 4947, 4951, 4955, 4959, 4963, + 4968, 4973, 4978, 4983, 4988, 4993, 4998, 5003, 5008, 5013, 5018, 5023, + 5028, 5033, 5038, 5046, 0, 5053, 5057, 5061, 5065, 5069, 5073, 5077, + 5081, 5085, 5089, 5093, 5097, 5101, 5105, 5109, 5113, 5117, 5121, 5125, + 5129, 5133, 5137, 5141, 5145, 5149, 5153, 5157, 5161, 5165, 5169, 5173, + 5177, 5181, 5185, 5189, 5193, 5197, 5199, 5201, 5203, 0, 0, 0, 0, 0, 0, + 0, 0, 5205, 5209, 5212, 5215, 5218, 5221, 5224, 5227, 5230, 5233, 5236, + 5239, 5242, 5245, 5248, 5251, 5254, 5256, 5258, 5260, 5262, 5264, 5266, + 5268, 5270, 5272, 5274, 5276, 5278, 5280, 5282, 5285, 5288, 5291, 5294, + 5297, 5300, 5303, 5306, 5309, 5312, 5315, 5318, 5321, 5324, 5330, 5335, + 0, 5338, 5340, 5342, 5344, 5346, 5348, 5350, 5352, 5354, 5356, 5358, + 5360, 5362, 5364, 5366, 5368, 5370, 5372, 5374, 5376, 5378, 5380, 5382, + 5384, 5386, 5388, 5390, 5392, 5394, 5396, 5398, 5400, 5402, 5404, 5406, + 5408, 5410, 5412, 5414, 5416, 5418, 5420, 5422, 5424, 5426, 5428, 5430, + 5432, 5434, 5436, 5439, 5442, 5445, 5448, 5451, 5454, 5457, 5460, 5463, + 5466, 5469, 5472, 5475, 5478, 5481, 5484, 5487, 5490, 5493, 5496, 5499, + 5502, 5505, 5508, 5512, 5516, 5520, 5523, 5527, 5530, 5534, 5536, 5538, + 5540, 5542, 5544, 5546, 5548, 5550, 5552, 5554, 5556, 5558, 5560, 5562, + 5564, 5566, 5568, 5570, 5572, 5574, 5576, 5578, 5580, 5582, 5584, 5586, + 5588, 5590, 5592, 5594, 5596, 5598, 5600, 5602, 5604, 5606, 5608, 5610, + 5612, 5614, 5616, 5618, 5620, 5622, 5624, 5626, 5628, 5631, 5636, 5641, + 5646, 5650, 5655, 5659, 5663, 5669, 5674, 5678, 5682, 5686, 5691, 5696, + 5700, 5704, 5707, 5711, 5716, 5721, 5724, 5730, 5737, 5743, 5747, 5753, + 5759, 5764, 5768, 5772, 5776, 5781, 5787, 5792, 5796, 5800, 5804, 5807, + 5810, 5813, 5816, 5820, 5824, 5830, 5834, 5839, 5845, 5849, 5852, 5855, + 5861, 5866, 5872, 5876, 5882, 5885, 5889, 5893, 5897, 5901, 5905, 5910, + 5914, 5917, 5921, 5925, 5929, 5934, 5938, 5942, 5946, 5952, 5957, 5960, + 5966, 5969, 5974, 5979, 5983, 5987, 5991, 5996, 5999, 6003, 6008, 6011, + 6017, 6021, 6024, 6027, 6030, 6033, 6036, 6039, 6042, 6045, 6048, 6051, + 6055, 6059, 6063, 6067, 6071, 6075, 6079, 6083, 6087, 6091, 6095, 6099, + 6103, 6107, 6111, 6115, 6118, 6121, 6125, 6128, 6131, 6134, 6138, 6142, + 6145, 6148, 6151, 6154, 6157, 6162, 6165, 6168, 6171, 6174, 6177, 6180, + 6183, 6186, 6190, 6195, 6198, 6201, 6204, 6207, 6210, 6213, 6216, 6220, + 6224, 6228, 6232, 6235, 6238, 6241, 6244, 6247, 6250, 6253, 6256, 6259, + 6262, 6266, 6270, 6273, 6277, 6281, 6285, 6288, 6292, 6296, 6301, 6304, + 6308, 6312, 6316, 6320, 6326, 6333, 6336, 6339, 6342, 6345, 6348, 6351, + 6354, 6357, 6360, 6363, 6366, 6369, 6372, 6375, 6378, 6381, 6384, 6387, + 6392, 6395, 6398, 6401, 6406, 6410, 6413, 6416, 6419, 6422, 6425, 6428, + 6431, 6434, 6437, 6440, 6444, 6447, 6450, 6454, 6458, 6461, 6466, 6470, + 6473, 6476, 6479, 6482, 6486, 6490, 6493, 6496, 6499, 6502, 6505, 6508, + 6511, 6514, 6517, 6521, 6525, 6529, 6533, 6537, 6541, 6545, 6549, 6553, + 6557, 6561, 6565, 6569, 6573, 6577, 6581, 6585, 6589, 6593, 6597, 6601, + 6605, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 6609, 6611, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 6613, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6615, 6617, 6619, 6621, 0, 0, + 0, 6623, 6625, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 6627, 6629, 6631, 6633, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 6635, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 6637, 6639, 6641, 6643, 6645, 6647, 6649, 6651, 6651, 6653, 6655, 6657, + 6659, 6661, 6663, 6665, 6667, 6669, 6671, 6673, 6675, 6677, 6679, 6681, + 6683, 6685, 6687, 6689, 6691, 6693, 6695, 6697, 6699, 6701, 6703, 6705, + 6707, 6709, 6711, 6713, 6715, 6717, 6719, 6721, 6723, 6725, 6727, 6729, + 6731, 6733, 6735, 6737, 6739, 6741, 6743, 6745, 6747, 6749, 6751, 6753, + 6755, 6757, 6759, 6761, 6763, 6765, 6767, 6769, 6771, 6773, 6775, 6777, + 6779, 6781, 6783, 6785, 6787, 6789, 6791, 6793, 6795, 6797, 6799, 6801, + 6803, 6805, 6807, 6809, 6811, 6813, 6815, 6817, 6675, 6819, 6821, 6823, + 6825, 6827, 6829, 6831, 6833, 6835, 6837, 6839, 6841, 6843, 6845, 6847, + 6849, 6851, 6853, 6855, 6857, 6859, 6861, 6863, 6865, 6867, 6869, 6871, + 6873, 6875, 6877, 6879, 6881, 6883, 6885, 6887, 6889, 6891, 6893, 6895, + 6897, 6899, 6901, 6903, 6905, 6907, 6909, 6911, 6913, 6915, 6917, 6919, + 6921, 6923, 6925, 6927, 6929, 6931, 6933, 6935, 6937, 6939, 6941, 6943, + 6945, 6947, 6949, 6951, 6953, 6855, 6955, 6957, 6959, 6961, 6963, 6965, + 6967, 6969, 6823, 6971, 6973, 6975, 6977, 6979, 6981, 6983, 6985, 6987, + 6989, 6991, 6993, 6995, 6997, 6999, 7001, 7003, 7005, 7007, 7009, 6675, + 7011, 7013, 7015, 7017, 7019, 7021, 7023, 7025, 7027, 7029, 7031, 7033, + 7035, 7037, 7039, 7041, 7043, 7045, 7047, 7049, 7051, 7053, 7055, 7057, + 7059, 7061, 7063, 6827, 7065, 7067, 7069, 7071, 7073, 7075, 7077, 7079, + 7081, 7083, 7085, 7087, 7089, 7091, 7093, 7095, 7097, 7099, 7101, 7103, + 7105, 7107, 7109, 7111, 7113, 7115, 7117, 7119, 7121, 7123, 7125, 7127, + 7129, 7131, 7133, 7135, 7137, 7139, 7141, 7143, 7145, 7147, 7149, 7151, + 7153, 7155, 7157, 7159, 7161, 7163, 0, 0, 7165, 0, 7167, 0, 0, 7169, + 7171, 7173, 7175, 7177, 7179, 7181, 7183, 7185, 7187, 0, 7189, 0, 7191, + 0, 0, 7193, 7195, 0, 0, 0, 7197, 7199, 7201, 7203, 7205, 7207, 7209, + 7211, 7213, 7215, 7217, 7219, 7221, 7223, 7225, 7227, 7229, 7231, 7233, + 7235, 7237, 7239, 7241, 7243, 7245, 7247, 7249, 7251, 7253, 7255, 7257, + 7259, 7261, 7263, 7265, 7267, 7269, 7271, 7273, 7275, 7277, 7279, 7281, + 7283, 7285, 6933, 7287, 7289, 7291, 7293, 7295, 7297, 7297, 7299, 7301, + 7303, 7305, 7307, 7309, 7311, 7313, 7193, 7315, 7317, 7319, 7321, 7323, + 7325, 0, 0, 7327, 7329, 7331, 7333, 7335, 7337, 7339, 7341, 7221, 7343, + 7345, 7347, 7165, 7349, 7351, 7353, 7355, 7357, 7359, 7361, 7363, 7365, + 7367, 7369, 7371, 7239, 7373, 7241, 7375, 7377, 7379, 7381, 7383, 7167, + 6717, 7385, 7387, 7389, 6857, 7031, 7391, 7393, 7255, 7395, 7257, 7397, + 7399, 7401, 7171, 7403, 7405, 7407, 7409, 7411, 7173, 7413, 7415, 7417, + 7419, 7421, 7423, 7285, 7425, 7427, 6933, 7429, 7293, 7431, 7433, 7435, + 7437, 7439, 7303, 7441, 7191, 7443, 7305, 6819, 7445, 7307, 7447, 7311, + 7449, 7451, 7453, 7455, 7457, 7315, 7183, 7459, 7317, 7461, 7319, 7463, + 6651, 7465, 7467, 7469, 7471, 7473, 7475, 7477, 7479, 7481, 7483, 7485, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7487, 7490, 7493, 7496, 7500, + 7504, 7507, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7510, 7513, 7516, 7519, + 7522, 0, 0, 0, 0, 0, 7525, 0, 7528, 7531, 7533, 7535, 7537, 7539, 7541, + 7543, 7545, 7547, 7549, 7551, 7554, 7557, 7560, 7563, 7566, 7569, 7572, + 7575, 7578, 7581, 7584, 7587, 0, 7590, 7593, 7596, 7599, 7602, 0, 7605, + 0, 7608, 7611, 0, 7614, 7617, 0, 7620, 7623, 7626, 7629, 7632, 7635, + 7638, 7641, 7644, 7647, 7650, 7652, 7654, 7656, 7658, 7660, 7662, 7664, + 7666, 7668, 7670, 7672, 7674, 7676, 7678, 7680, 7682, 7684, 7686, 7688, + 7690, 7692, 7694, 7696, 7698, 7700, 7702, 7704, 7706, 7708, 7710, 7712, + 7714, 7716, 7718, 7720, 7722, 7724, 7726, 7728, 7730, 7732, 7734, 7736, + 7738, 7740, 7742, 7744, 7746, 7748, 7750, 7752, 7754, 7756, 7758, 7760, + 7762, 7764, 7766, 7768, 7770, 7772, 7774, 7776, 7778, 7780, 7782, 7784, + 7786, 7788, 7790, 7792, 7794, 7796, 7798, 7800, 7802, 7804, 7806, 7808, + 7810, 7812, 7814, 7816, 7818, 7820, 7822, 7824, 7826, 7828, 7830, 7832, + 7834, 7836, 7838, 7840, 7842, 7844, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7846, + 7848, 7850, 7852, 7854, 7856, 7858, 7860, 7862, 7864, 7866, 7868, 7870, + 7872, 7874, 7876, 7878, 7880, 7882, 7884, 7886, 7888, 7890, 7892, 7895, + 7898, 7901, 7904, 7907, 7910, 7913, 7916, 7919, 7922, 7925, 7928, 7931, + 7934, 7937, 7940, 7943, 7946, 7948, 7950, 7952, 7954, 7957, 7960, 7937, + 7963, 7966, 7969, 7972, 7975, 7978, 7981, 7984, 7987, 7990, 7993, 7996, + 7999, 8002, 8005, 8008, 8011, 8014, 8017, 8020, 8023, 8026, 8029, 8032, + 8035, 8038, 8041, 8044, 8047, 8050, 8053, 8056, 8059, 8062, 8065, 8068, + 8071, 8074, 8077, 8080, 8083, 8086, 8089, 8092, 8095, 8098, 8101, 8104, + 8107, 8110, 8113, 8116, 8119, 8122, 8125, 8128, 8131, 8134, 8137, 8140, + 8143, 8146, 8149, 8152, 8155, 8158, 8161, 8164, 8167, 8170, 8173, 8176, + 8179, 8182, 8185, 8188, 8191, 8194, 8197, 8200, 8203, 8206, 8209, 8212, + 8215, 8218, 8221, 8224, 8227, 8230, 8233, 8237, 8241, 8245, 8249, 8253, + 8257, 8260, 8263, 8266, 7940, 8269, 8272, 8275, 8278, 8281, 8284, 8287, + 8290, 8293, 8296, 8299, 8302, 8305, 8308, 8311, 8314, 8317, 8320, 8323, + 8326, 8329, 8332, 8335, 8338, 8341, 8344, 8347, 8350, 8353, 8356, 8359, + 8362, 8365, 8368, 8371, 8374, 8377, 8380, 8383, 8386, 8389, 8392, 8395, + 8398, 8401, 8404, 8407, 8410, 8413, 8416, 8419, 8422, 8425, 8428, 8431, + 8434, 8437, 8440, 8443, 8446, 8449, 8452, 8455, 8458, 8461, 8464, 8467, + 8470, 8473, 8476, 8479, 8482, 8485, 8488, 8491, 8494, 8497, 8500, 8503, + 8506, 8509, 8512, 8515, 8518, 8521, 8524, 8527, 8530, 8533, 8536, 8539, + 8542, 8545, 8548, 8551, 8554, 8557, 8560, 8563, 8566, 8569, 8572, 8575, + 8578, 8581, 8584, 8587, 8590, 8593, 8596, 8599, 8602, 8605, 8608, 8611, + 8614, 8617, 8620, 8623, 8626, 8629, 8632, 8635, 8638, 8641, 8644, 8647, + 8650, 8653, 8656, 8659, 8662, 8665, 8668, 8671, 8674, 8677, 8680, 8684, + 8688, 8692, 8695, 8698, 8701, 8704, 8707, 8710, 8713, 8716, 8719, 8722, + 8725, 8728, 8731, 8734, 8737, 8740, 8743, 8746, 8749, 8752, 8755, 8758, + 8761, 8764, 8767, 8770, 8773, 8776, 8779, 8782, 8785, 8788, 8791, 8794, + 8797, 8800, 8803, 8806, 8809, 8812, 8815, 8818, 8821, 8824, 8827, 8830, + 8833, 8836, 8839, 8842, 8845, 8848, 8851, 8854, 8857, 8860, 8863, 8866, + 8869, 8872, 8875, 8878, 8881, 8884, 8887, 8890, 8893, 8896, 8899, 8902, + 8905, 8908, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8911, + 8915, 8919, 8923, 8927, 8931, 8935, 8939, 8943, 8947, 8951, 8955, 8959, + 8963, 8967, 8971, 8975, 8979, 8983, 8987, 8991, 8995, 8999, 9003, 9007, + 9011, 9015, 9019, 9023, 9027, 9031, 9035, 9039, 9043, 9047, 9051, 9055, + 9059, 9063, 9067, 9071, 9075, 9079, 9083, 9087, 9091, 9095, 9099, 9103, + 9107, 9111, 9115, 9119, 9123, 9127, 9131, 9135, 9139, 9143, 9147, 9151, + 9155, 9159, 9163, 0, 0, 9167, 9171, 9175, 9179, 9183, 9187, 9191, 9195, + 9199, 9203, 9207, 9211, 9215, 9219, 9223, 9227, 9231, 9235, 9239, 9243, + 9247, 9251, 9255, 9259, 9263, 9267, 9271, 9275, 9279, 9283, 9287, 9291, + 9295, 9299, 9303, 9307, 9311, 9315, 9319, 9323, 9327, 9331, 9335, 9339, + 9343, 9347, 9351, 9355, 9359, 9363, 9367, 9371, 9375, 9379, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9383, 9387, 9391, 9396, 9401, 9406, + 9411, 9416, 9421, 9426, 9430, 9449, 9458, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 9463, 9465, 9467, 9469, 9471, 9473, 9475, + 9477, 9479, 9481, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9483, 9485, 9487, 9489, 9489, 9491, 9493, 9495, 9497, 9499, + 9501, 9503, 9505, 9507, 9509, 9511, 9513, 9515, 9517, 9519, 9521, 0, 0, + 9523, 9525, 9527, 9527, 9527, 9527, 9529, 9529, 9529, 9531, 9533, 9535, + 0, 9537, 9539, 9541, 9543, 9545, 9547, 9549, 9551, 9553, 9555, 9557, + 9559, 9561, 9563, 9565, 9567, 9569, 9571, 9573, 0, 9575, 9577, 9579, + 9581, 0, 0, 0, 0, 9583, 9586, 9589, 0, 9592, 0, 9595, 9598, 9601, 9604, + 9607, 9610, 9613, 9616, 9619, 9622, 9625, 9627, 9629, 9631, 9633, 9635, + 9637, 9639, 9641, 9643, 9645, 9647, 9649, 9651, 9653, 9655, 9657, 9659, + 9661, 9663, 9665, 9667, 9669, 9671, 9673, 9675, 9677, 9679, 9681, 9683, + 9685, 9687, 9689, 9691, 9693, 9695, 9697, 9699, 9701, 9703, 9705, 9707, + 9709, 9711, 9713, 9715, 9717, 9719, 9721, 9723, 9725, 9727, 9729, 9731, + 9733, 9735, 9737, 9739, 9741, 9743, 9745, 9747, 9749, 9751, 9753, 9755, + 9757, 9759, 9761, 9763, 9765, 9767, 9769, 9771, 9773, 9775, 9777, 9779, + 9781, 9783, 9785, 9787, 9789, 9791, 9793, 9795, 9797, 9799, 9801, 9803, + 9805, 9807, 9809, 9811, 9813, 9815, 9817, 9819, 9821, 9823, 9825, 9827, + 9829, 9831, 9833, 9835, 9837, 9839, 9841, 9843, 9845, 9847, 9849, 9851, + 9853, 9855, 9857, 9859, 9862, 9865, 9868, 9871, 9874, 9877, 9880, 0, 0, + 0, 0, 9883, 9885, 9887, 9889, 9891, 9893, 9895, 9897, 9899, 9901, 9903, + 9905, 9907, 9909, 9911, 9913, 9915, 9917, 9919, 9921, 9923, 9925, 9927, + 9929, 9931, 9933, 9935, 9937, 9939, 9941, 9943, 9945, 9947, 9949, 9951, + 9953, 9955, 9957, 9959, 9961, 9963, 9965, 9967, 9969, 9971, 9973, 9975, + 9977, 9979, 9981, 9983, 9985, 9987, 9989, 9991, 9993, 9995, 9997, 9999, + 10001, 10003, 10005, 10007, 10009, 10011, 10013, 10015, 10017, 10019, + 10021, 10023, 10025, 10027, 10029, 10031, 10033, 10035, 10037, 10039, + 10041, 10043, 10045, 10047, 10049, 10051, 10053, 10055, 10057, 10059, + 10061, 10063, 10065, 10067, 10069, 10071, 10073, 10075, 10077, 10079, + 10081, 10083, 10085, 10087, 10089, 10091, 10093, 10095, 10097, 10099, + 10101, 10103, 10105, 10107, 10109, 10111, 10113, 10115, 10117, 10119, + 10121, 10123, 10125, 10127, 10129, 10131, 10133, 10135, 10137, 10139, + 10141, 10143, 10145, 10147, 10149, 10151, 10153, 10155, 10157, 10159, + 10161, 10163, 10165, 10167, 10169, 10171, 10173, 10175, 10177, 10179, + 10181, 10183, 10185, 10187, 10189, 10191, 10193, 10195, 10197, 10199, + 10201, 10203, 10205, 10207, 10209, 10211, 10213, 10215, 10217, 10219, + 10221, 10223, 10225, 10227, 10229, 10231, 10233, 10235, 10237, 10239, + 10241, 10243, 10245, 10247, 10249, 10251, 10253, 10255, 10257, 10259, + 10261, 0, 0, 0, 10263, 10265, 10267, 10269, 10271, 10273, 0, 0, 10275, + 10277, 10279, 10281, 10283, 10285, 0, 0, 10287, 10289, 10291, 10293, + 10295, 10297, 0, 0, 10299, 10301, 10303, 0, 0, 0, 10305, 10307, 10309, + 10311, 10313, 10315, 10317, 0, 10319, 10321, 10323, 10325, 10327, 10329, + 10331, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4487, 0, 4103, 4489, 4491, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4493, 0, 4496, 0, 4499, 0, 4502, - 0, 4505, 0, 4508, 0, 4511, 0, 4514, 0, 4517, 0, 4520, 0, 4523, 0, 4526, - 0, 0, 4529, 0, 4532, 0, 4535, 0, 0, 0, 0, 0, 0, 4538, 4541, 0, 4544, - 4547, 0, 4550, 4553, 0, 4556, 4559, 0, 4562, 4565, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4568, 0, 0, 0, 0, 0, 0, - 4571, 4574, 0, 4577, 4580, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4583, 0, - 4586, 0, 4589, 0, 4592, 0, 4595, 0, 4598, 0, 4601, 0, 4604, 0, 4607, 0, - 4610, 0, 4613, 0, 4616, 0, 0, 4619, 0, 4622, 0, 4625, 0, 0, 0, 0, 0, 0, - 4628, 4631, 0, 4634, 4637, 0, 4640, 4643, 0, 4646, 4649, 0, 4652, 4655, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4658, - 0, 0, 4661, 4664, 4667, 4670, 0, 0, 0, 4673, 4676, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4679, 4681, 4683, - 4685, 4687, 4689, 4691, 4693, 4695, 4697, 4699, 4701, 4703, 4705, 4707, - 4709, 4711, 4713, 4715, 4717, 4719, 4721, 4723, 4725, 4727, 4729, 4731, - 4733, 4735, 4737, 4739, 4741, 4743, 4745, 4747, 4749, 4751, 4753, 4755, - 4757, 4759, 4761, 4763, 4765, 4767, 4769, 4771, 4773, 4775, 4777, 4779, - 4781, 4783, 4785, 4787, 4789, 4791, 4793, 4795, 4797, 4799, 4801, 4803, - 4805, 4807, 4809, 4811, 4813, 4815, 4817, 4819, 4821, 4823, 4825, 4827, - 4829, 4831, 4833, 4835, 4837, 4839, 4841, 4843, 4845, 4847, 4849, 4851, - 4853, 4855, 4857, 4859, 4861, 4863, 4865, 0, 0, 0, 4867, 4869, 4871, - 4873, 4875, 4877, 4879, 4881, 4883, 4885, 4887, 4889, 4891, 4893, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4895, - 4899, 4903, 4907, 4911, 4915, 4919, 4923, 4927, 4931, 4935, 4939, 4943, - 4947, 4951, 4956, 4961, 4966, 4971, 4976, 4981, 4986, 4991, 4996, 5001, - 5006, 5011, 5016, 5021, 5026, 5034, 0, 5041, 5045, 5049, 5053, 5057, - 5061, 5065, 5069, 5073, 5077, 5081, 5085, 5089, 5093, 5097, 5101, 5105, - 5109, 5113, 5117, 5121, 5125, 5129, 5133, 5137, 5141, 5145, 5149, 5153, - 5157, 5161, 5165, 5169, 5173, 5177, 5181, 5185, 5187, 5189, 5191, 0, 0, - 0, 0, 0, 0, 0, 0, 5193, 5197, 5200, 5203, 5206, 5209, 5212, 5215, 5218, - 5221, 5224, 5227, 5230, 5233, 5236, 5239, 5242, 5244, 5246, 5248, 5250, - 5252, 5254, 5256, 5258, 5260, 5262, 5264, 5266, 5268, 5270, 5273, 5276, - 5279, 5282, 5285, 5288, 5291, 5294, 5297, 5300, 5303, 5306, 5309, 5312, - 5318, 5323, 0, 5326, 5328, 5330, 5332, 5334, 5336, 5338, 5340, 5342, - 5344, 5346, 5348, 5350, 5352, 5354, 5356, 5358, 5360, 5362, 5364, 5366, - 5368, 5370, 5372, 5374, 5376, 5378, 5380, 5382, 5384, 5386, 5388, 5390, - 5392, 5394, 5396, 5398, 5400, 5402, 5404, 5406, 5408, 5410, 5412, 5414, - 5416, 5418, 5420, 5422, 5424, 5427, 5430, 5433, 5436, 5439, 5442, 5445, - 5448, 5451, 5454, 5457, 5460, 5463, 5466, 5469, 5472, 5475, 5478, 5481, - 5484, 5487, 5490, 5493, 5496, 5500, 5504, 5508, 5511, 5515, 5518, 5522, - 5524, 5526, 5528, 5530, 5532, 5534, 5536, 5538, 5540, 5542, 5544, 5546, - 5548, 5550, 5552, 5554, 5556, 5558, 5560, 5562, 5564, 5566, 5568, 5570, - 5572, 5574, 5576, 5578, 5580, 5582, 5584, 5586, 5588, 5590, 5592, 5594, - 5596, 5598, 5600, 5602, 5604, 5606, 5608, 5610, 5612, 5614, 5616, 5619, - 5624, 5629, 5634, 5638, 5643, 5647, 5651, 5657, 5662, 5666, 5670, 5674, - 5679, 5684, 5688, 5692, 5695, 5699, 5704, 5709, 5712, 5718, 5725, 5731, - 5735, 5741, 5747, 5752, 5756, 5760, 5764, 5769, 5775, 5780, 5784, 5788, - 5792, 5795, 5798, 5801, 5804, 5808, 5812, 5818, 5822, 5827, 5833, 5837, - 5840, 5843, 5849, 5854, 5860, 5864, 5870, 5873, 5877, 5881, 5885, 5889, - 5893, 5898, 5902, 5905, 5909, 5913, 5917, 5922, 5926, 5930, 5934, 5940, - 5945, 5948, 5954, 5957, 5962, 5967, 5971, 5975, 5979, 5984, 5987, 5991, - 5996, 5999, 6005, 6009, 6012, 6015, 6018, 6021, 6024, 6027, 6030, 6033, - 6036, 6039, 6043, 6047, 6051, 6055, 6059, 6063, 6067, 6071, 6075, 6079, - 6083, 6087, 6091, 6095, 6099, 6103, 6106, 6109, 6113, 6116, 6119, 6122, - 6126, 6130, 6133, 6136, 6139, 6142, 6145, 6150, 6153, 6156, 6159, 6162, - 6165, 6168, 6171, 6174, 6178, 6183, 6186, 6189, 6192, 6195, 6198, 6201, - 6204, 6208, 6212, 6216, 6220, 6223, 6226, 6229, 6232, 6235, 6238, 6241, - 6244, 6247, 6250, 6254, 6258, 6261, 6265, 6269, 6273, 6276, 6280, 6284, - 6289, 6292, 6296, 6300, 6304, 6308, 6314, 6321, 6324, 6327, 6330, 6333, - 6336, 6339, 6342, 6345, 6348, 6351, 6354, 6357, 6360, 6363, 6366, 6369, - 6372, 6375, 6380, 6383, 6386, 6389, 6394, 6398, 6401, 6404, 6407, 6410, - 6413, 6416, 6419, 6422, 6425, 6428, 6432, 6435, 6438, 6442, 6446, 6449, - 6454, 6458, 6461, 6464, 6467, 6470, 6474, 6478, 6481, 6484, 6487, 6490, - 6493, 6496, 6499, 6502, 6505, 6509, 6513, 6517, 6521, 6525, 6529, 6533, - 6537, 6541, 6545, 6549, 6553, 6557, 6561, 6565, 6569, 6573, 6577, 6581, - 6585, 6589, 6593, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6597, 6599, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 6601, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6603, 6605, 6607, - 6609, 0, 0, 0, 6611, 6613, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6615, 6617, 6619, 6621, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6623, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6625, 6627, 6629, 6631, 6633, 6635, 6637, 6639, 6639, 6641, - 6643, 6645, 6647, 6649, 6651, 6653, 6655, 6657, 6659, 6661, 6663, 6665, - 6667, 6669, 6671, 6673, 6675, 6677, 6679, 6681, 6683, 6685, 6687, 6689, - 6691, 6693, 6695, 6697, 6699, 6701, 6703, 6705, 6707, 6709, 6711, 6713, - 6715, 6717, 6719, 6721, 6723, 6725, 6727, 6729, 6731, 6733, 6735, 6737, - 6739, 6741, 6743, 6745, 6747, 6749, 6751, 6753, 6755, 6757, 6759, 6761, - 6763, 6765, 6767, 6769, 6771, 6773, 6775, 6777, 6779, 6781, 6783, 6785, - 6787, 6789, 6791, 6793, 6795, 6797, 6799, 6801, 6803, 6805, 6663, 6807, - 6809, 6811, 6813, 6815, 6817, 6819, 6821, 6823, 6825, 6827, 6829, 6831, - 6833, 6835, 6837, 6839, 6841, 6843, 6845, 6847, 6849, 6851, 6853, 6855, - 6857, 6859, 6861, 6863, 6865, 6867, 6869, 6871, 6873, 6875, 6877, 6879, - 6881, 6883, 6885, 6887, 6889, 6891, 6893, 6895, 6897, 6899, 6901, 6903, - 6905, 6907, 6909, 6911, 6913, 6915, 6917, 6919, 6921, 6923, 6925, 6927, - 6929, 6931, 6933, 6935, 6937, 6939, 6941, 6843, 6943, 6945, 6947, 6949, - 6951, 6953, 6955, 6957, 6811, 6959, 6961, 6963, 6965, 6967, 6969, 6971, - 6973, 6975, 6977, 6979, 6981, 6983, 6985, 6987, 6989, 6991, 6993, 6995, - 6997, 6663, 6999, 7001, 7003, 7005, 7007, 7009, 7011, 7013, 7015, 7017, - 7019, 7021, 7023, 7025, 7027, 7029, 7031, 7033, 7035, 7037, 7039, 7041, - 7043, 7045, 7047, 7049, 7051, 6815, 7053, 7055, 7057, 7059, 7061, 7063, - 7065, 7067, 7069, 7071, 7073, 7075, 7077, 7079, 7081, 7083, 7085, 7087, - 7089, 7091, 7093, 7095, 7097, 7099, 7101, 7103, 7105, 7107, 7109, 7111, - 7113, 7115, 7117, 7119, 7121, 7123, 7125, 7127, 7129, 7131, 7133, 7135, - 7137, 7139, 7141, 7143, 7145, 7147, 7149, 7151, 0, 0, 7153, 0, 7155, 0, - 0, 7157, 7159, 7161, 7163, 7165, 7167, 7169, 7171, 7173, 7175, 0, 7177, - 0, 7179, 0, 0, 7181, 7183, 0, 0, 0, 7185, 7187, 7189, 7191, 7193, 7195, - 7197, 7199, 7201, 7203, 7205, 7207, 7209, 7211, 7213, 7215, 7217, 7219, - 7221, 7223, 7225, 7227, 7229, 7231, 7233, 7235, 7237, 7239, 7241, 7243, - 7245, 7247, 7249, 7251, 7253, 7255, 7257, 7259, 7261, 7263, 7265, 7267, - 7269, 7271, 7273, 6921, 7275, 7277, 7279, 7281, 7283, 7285, 7285, 7287, - 7289, 7291, 7293, 7295, 7297, 7299, 7301, 7181, 7303, 7305, 7307, 7309, - 7311, 7313, 0, 0, 7315, 7317, 7319, 7321, 7323, 7325, 7327, 7329, 7209, - 7331, 7333, 7335, 7153, 7337, 7339, 7341, 7343, 7345, 7347, 7349, 7351, - 7353, 7355, 7357, 7359, 7227, 7361, 7229, 7363, 7365, 7367, 7369, 7371, - 7155, 6705, 7373, 7375, 7377, 6845, 7019, 7379, 7381, 7243, 7383, 7245, - 7385, 7387, 7389, 7159, 7391, 7393, 7395, 7397, 7399, 7161, 7401, 7403, - 7405, 7407, 7409, 7411, 7273, 7413, 7415, 6921, 7417, 7281, 7419, 7421, - 7423, 7425, 7427, 7291, 7429, 7179, 7431, 7293, 6807, 7433, 7295, 7435, - 7299, 7437, 7439, 7441, 7443, 7445, 7303, 7171, 7447, 7305, 7449, 7307, - 7451, 6639, 7453, 7455, 7457, 7459, 7461, 7463, 7465, 7467, 7469, 7471, - 7473, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7475, 7478, 7481, 7484, - 7488, 7492, 7495, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7498, 7501, 7504, - 7507, 7510, 0, 0, 0, 0, 0, 7513, 0, 7516, 7519, 7521, 7523, 7525, 7527, - 7529, 7531, 7533, 7535, 7537, 7539, 7542, 7545, 7548, 7551, 7554, 7557, - 7560, 7563, 7566, 7569, 7572, 7575, 0, 7578, 7581, 7584, 7587, 7590, 0, - 7593, 0, 7596, 7599, 0, 7602, 7605, 0, 7608, 7611, 7614, 7617, 7620, - 7623, 7626, 7629, 7632, 7635, 7638, 7640, 7642, 7644, 7646, 7648, 7650, - 7652, 7654, 7656, 7658, 7660, 7662, 7664, 7666, 7668, 7670, 7672, 7674, - 7676, 7678, 7680, 7682, 7684, 7686, 7688, 7690, 7692, 7694, 7696, 7698, - 7700, 7702, 7704, 7706, 7708, 7710, 7712, 7714, 7716, 7718, 7720, 7722, - 7724, 7726, 7728, 7730, 7732, 7734, 7736, 7738, 7740, 7742, 7744, 7746, - 7748, 7750, 7752, 7754, 7756, 7758, 7760, 7762, 7764, 7766, 7768, 7770, - 7772, 7774, 7776, 7778, 7780, 7782, 7784, 7786, 7788, 7790, 7792, 7794, - 7796, 7798, 7800, 7802, 7804, 7806, 7808, 7810, 7812, 7814, 7816, 7818, - 7820, 7822, 7824, 7826, 7828, 7830, 7832, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 7834, 7836, 7838, 7840, 7842, 7844, 7846, 7848, 7850, 7852, 7854, 7856, - 7858, 7860, 7862, 7864, 7866, 7868, 7870, 7872, 7874, 7876, 7878, 7880, - 7883, 7886, 7889, 7892, 7895, 7898, 7901, 7904, 7907, 7910, 7913, 7916, - 7919, 7922, 7925, 7928, 7931, 7934, 7936, 7938, 7940, 7942, 7945, 7948, - 7925, 7951, 7954, 7957, 7960, 7963, 7966, 7969, 7972, 7975, 7978, 7981, - 7984, 7987, 7990, 7993, 7996, 7999, 8002, 8005, 8008, 8011, 8014, 8017, - 8020, 8023, 8026, 8029, 8032, 8035, 8038, 8041, 8044, 8047, 8050, 8053, - 8056, 8059, 8062, 8065, 8068, 8071, 8074, 8077, 8080, 8083, 8086, 8089, - 8092, 8095, 8098, 8101, 8104, 8107, 8110, 8113, 8116, 8119, 8122, 8125, - 8128, 8131, 8134, 8137, 8140, 8143, 8146, 8149, 8152, 8155, 8158, 8161, - 8164, 8167, 8170, 8173, 8176, 8179, 8182, 8185, 8188, 8191, 8194, 8197, - 8200, 8203, 8206, 8209, 8212, 8215, 8218, 8221, 8225, 8229, 8233, 8237, - 8241, 8245, 8248, 8251, 8254, 7928, 8257, 8260, 8263, 8266, 8269, 8272, - 8275, 8278, 8281, 8284, 8287, 8290, 8293, 8296, 8299, 8302, 8305, 8308, - 8311, 8314, 8317, 8320, 8323, 8326, 8329, 8332, 8335, 8338, 8341, 8344, - 8347, 8350, 8353, 8356, 8359, 8362, 8365, 8368, 8371, 8374, 8377, 8380, - 8383, 8386, 8389, 8392, 8395, 8398, 8401, 8404, 8407, 8410, 8413, 8416, - 8419, 8422, 8425, 8428, 8431, 8434, 8437, 8440, 8443, 8446, 8449, 8452, - 8455, 8458, 8461, 8464, 8467, 8470, 8473, 8476, 8479, 8482, 8485, 8488, - 8491, 8494, 8497, 8500, 8503, 8506, 8509, 8512, 8515, 8518, 8521, 8524, - 8527, 8530, 8533, 8536, 8539, 8542, 8545, 8548, 8551, 8554, 8557, 8560, - 8563, 8566, 8569, 8572, 8575, 8578, 8581, 8584, 8587, 8590, 8593, 8596, - 8599, 8602, 8605, 8608, 8611, 8614, 8617, 8620, 8623, 8626, 8629, 8632, - 8635, 8638, 8641, 8644, 8647, 8650, 8653, 8656, 8659, 8662, 8665, 8668, - 8672, 8676, 8680, 8683, 8686, 8689, 8692, 8695, 8698, 8701, 8704, 8707, - 8710, 8713, 8716, 8719, 8722, 8725, 8728, 8731, 8734, 8737, 8740, 8743, - 8746, 8749, 8752, 8755, 8758, 8761, 8764, 8767, 8770, 8773, 8776, 8779, - 8782, 8785, 8788, 8791, 8794, 8797, 8800, 8803, 8806, 8809, 8812, 8815, - 8818, 8821, 8824, 8827, 8830, 8833, 8836, 8839, 8842, 8845, 8848, 8851, - 8854, 8857, 8860, 8863, 8866, 8869, 8872, 8875, 8878, 8881, 8884, 8887, - 8890, 8893, 8896, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8899, 8903, 8907, 8911, 8915, 8919, 8923, 8927, 8931, 8935, 8939, 8943, - 8947, 8951, 8955, 8959, 8963, 8967, 8971, 8975, 8979, 8983, 8987, 8991, - 8995, 8999, 9003, 9007, 9011, 9015, 9019, 9023, 9027, 9031, 9035, 9039, - 9043, 9047, 9051, 9055, 9059, 9063, 9067, 9071, 9075, 9079, 9083, 9087, - 9091, 9095, 9099, 9103, 9107, 9111, 9115, 9119, 9123, 9127, 9131, 9135, - 9139, 9143, 9147, 9151, 0, 0, 9155, 9159, 9163, 9167, 9171, 9175, 9179, - 9183, 9187, 9191, 9195, 9199, 9203, 9207, 9211, 9215, 9219, 9223, 9227, - 9231, 9235, 9239, 9243, 9247, 9251, 9255, 9259, 9263, 9267, 9271, 9275, - 9279, 9283, 9287, 9291, 9295, 9299, 9303, 9307, 9311, 9315, 9319, 9323, - 9327, 9331, 9335, 9339, 9343, 9347, 9351, 9355, 9359, 9363, 9367, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9371, 9375, 9379, 9384, 9389, - 9394, 9399, 9404, 9409, 9414, 9418, 9437, 9446, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9451, 9453, 9455, 9457, 9459, 9461, - 9463, 9465, 9467, 9469, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 9471, 9473, 9475, 9477, 9477, 9479, 9481, 9483, 9485, - 9487, 9489, 9491, 9493, 9495, 9497, 9499, 9501, 9503, 9505, 9507, 9509, - 0, 0, 9511, 9513, 9515, 9515, 9515, 9515, 9517, 9517, 9517, 9519, 9521, - 9523, 0, 9525, 9527, 9529, 9531, 9533, 9535, 9537, 9539, 9541, 9543, - 9545, 9547, 9549, 9551, 9553, 9555, 9557, 9559, 9561, 0, 9563, 9565, - 9567, 9569, 0, 0, 0, 0, 9571, 9574, 9577, 0, 9580, 0, 9583, 9586, 9589, - 9592, 9595, 9598, 9601, 9604, 9607, 9610, 9613, 9615, 9617, 9619, 9621, - 9623, 9625, 9627, 9629, 9631, 9633, 9635, 9637, 9639, 9641, 9643, 9645, - 9647, 9649, 9651, 9653, 9655, 9657, 9659, 9661, 9663, 9665, 9667, 9669, - 9671, 9673, 9675, 9677, 9679, 9681, 9683, 9685, 9687, 9689, 9691, 9693, - 9695, 9697, 9699, 9701, 9703, 9705, 9707, 9709, 9711, 9713, 9715, 9717, - 9719, 9721, 9723, 9725, 9727, 9729, 9731, 9733, 9735, 9737, 9739, 9741, - 9743, 9745, 9747, 9749, 9751, 9753, 9755, 9757, 9759, 9761, 9763, 9765, - 9767, 9769, 9771, 9773, 9775, 9777, 9779, 9781, 9783, 9785, 9787, 9789, - 9791, 9793, 9795, 9797, 9799, 9801, 9803, 9805, 9807, 9809, 9811, 9813, - 9815, 9817, 9819, 9821, 9823, 9825, 9827, 9829, 9831, 9833, 9835, 9837, - 9839, 9841, 9843, 9845, 9847, 9850, 9853, 9856, 9859, 9862, 9865, 9868, - 0, 0, 0, 0, 9871, 9873, 9875, 9877, 9879, 9881, 9883, 9885, 9887, 9889, - 9891, 9893, 9895, 9897, 9899, 9901, 9903, 9905, 9907, 9909, 9911, 9913, - 9915, 9917, 9919, 9921, 9923, 9925, 9927, 9929, 9931, 9933, 9935, 9937, - 9939, 9941, 9943, 9945, 9947, 9949, 9951, 9953, 9955, 9957, 9959, 9961, - 9963, 9965, 9967, 9969, 9971, 9973, 9975, 9977, 9979, 9981, 9983, 9985, - 9987, 9989, 9991, 9993, 9995, 9997, 9999, 10001, 10003, 10005, 10007, - 10009, 10011, 10013, 10015, 10017, 10019, 10021, 10023, 10025, 10027, - 10029, 10031, 10033, 10035, 10037, 10039, 10041, 10043, 10045, 10047, - 10049, 10051, 10053, 10055, 10057, 10059, 10061, 10063, 10065, 10067, - 10069, 10071, 10073, 10075, 10077, 10079, 10081, 10083, 10085, 10087, - 10089, 10091, 10093, 10095, 10097, 10099, 10101, 10103, 10105, 10107, - 10109, 10111, 10113, 10115, 10117, 10119, 10121, 10123, 10125, 10127, - 10129, 10131, 10133, 10135, 10137, 10139, 10141, 10143, 10145, 10147, - 10149, 10151, 10153, 10155, 10157, 10159, 10161, 10163, 10165, 10167, - 10169, 10171, 10173, 10175, 10177, 10179, 10181, 10183, 10185, 10187, - 10189, 10191, 10193, 10195, 10197, 10199, 10201, 10203, 10205, 10207, - 10209, 10211, 10213, 10215, 10217, 10219, 10221, 10223, 10225, 10227, - 10229, 10231, 10233, 10235, 10237, 10239, 10241, 10243, 10245, 10247, - 10249, 0, 0, 0, 10251, 10253, 10255, 10257, 10259, 10261, 0, 0, 10263, - 10265, 10267, 10269, 10271, 10273, 0, 0, 10275, 10277, 10279, 10281, - 10283, 10285, 0, 0, 10287, 10289, 10291, 0, 0, 0, 10293, 10295, 10297, - 10299, 10301, 10303, 10305, 0, 10307, 10309, 10311, 10313, 10315, 10317, - 10319, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 10336, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 10339, 10341, 10343, 10345, 10347, 0, 10349, 10351, + 10353, 10355, 10357, 10359, 10361, 10363, 10365, 10367, 10369, 10371, + 10373, 10375, 10377, 10379, 10381, 10383, 10385, 10387, 10389, 10391, + 10393, 10395, 10397, 10399, 10401, 10403, 10405, 10407, 10409, 10411, + 10413, 10415, 10417, 10419, 10421, 10423, 10425, 10427, 10429, 10431, 0, + 10433, 10435, 10437, 10439, 10441, 10443, 10445, 10447, 10449, 10451, + 10453, 10455, 10457, 10459, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10321, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 10324, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 10327, 10329, 10331, 10333, 10335, 0, 10337, 10339, - 10341, 10343, 10345, 10347, 10349, 10351, 10353, 10355, 10357, 10359, - 10361, 10363, 10365, 10367, 10369, 10371, 10373, 10375, 10377, 10379, - 10381, 10383, 10385, 10387, 10389, 10391, 10393, 10395, 10397, 10399, - 10401, 10403, 10405, 10407, 10409, 10411, 10413, 10415, 10417, 10419, 0, - 10421, 10423, 10425, 10427, 10429, 10431, 10433, 10435, 10437, 0, 0, 0, + 0, 0, 0, 10461, 0, 10464, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 10467, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10439, 0, - 10442, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10445, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10470, 10473, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 10448, 10451, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10476, 10479, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10482, 0, 10485, 0, 0, 0, 0, 0, 0, + 0, 0, 10488, 0, 0, 10491, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10494, 0, 10497, 10500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10454, 10457, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 10460, 0, 10463, 0, 0, 0, 0, 0, 0, 0, 0, 10466, 0, 0, - 10469, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 10472, 0, 10475, 10478, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10503, 10506, 0, 10509, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 10481, 10484, 0, 10487, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 10512, 10515, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10490, 10493, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 10518, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10521, 10524, + 10527, 10530, 10533, 10536, 10539, 10542, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 10496, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10499, 10502, 10505, 10508, 10511, - 10514, 10517, 10520, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10545, 10548, 10551, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 10554, 10557, 10560, 10563, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 10523, 10526, 10529, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 10532, 3253, 3192, 3289, 3257, 3259, 10534, 3212, 3218, 10536, 10538, - 3220, 3261, 3224, 10540, 3229, 3231, 3233, 10542, 10544, 10546, 10548, - 10550, 10552, 10554, 3245, 10556, 10558, 10560, 10562, 10564, 10566, - 10568, 10570, 10572, 10574, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10566, 3265, + 3204, 3301, 3269, 3271, 10568, 3224, 3230, 10570, 10572, 3232, 3273, + 3236, 10574, 3241, 3243, 3245, 10576, 10578, 10580, 10582, 10584, 10586, + 10588, 3257, 10590, 10592, 10594, 10596, 10598, 10600, 10602, 10604, + 10606, 10608, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10576, 10579, 10582, 10585, 10588, - 10591, 10594, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 10610, 10613, 10616, 10619, 10622, 10625, 10628, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10597, 10600, - 10603, 10606, 10609, 10612, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10631, 10634, 10637, 10640, + 10643, 10646, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 10532, 3253, 3192, 3289, 3257, 3259, 10534, 3212, 3218, 10536, 10538, - 3220, 3261, 3224, 10540, 3229, 3231, 3233, 10542, 10544, 10546, 10548, - 10550, 10552, 10554, 3245, 10615, 10617, 10619, 3291, 3255, 10621, 3210, - 3214, 3273, 3293, 10623, 3222, 10625, 10627, 3263, 10629, 10631, 10633, - 10635, 10637, 10639, 10641, 10643, 10645, 10647, 10649, 10532, 3253, - 3192, 3289, 3257, 3259, 10534, 3212, 3218, 10536, 10538, 3220, 3261, - 3224, 10540, 3229, 3231, 3233, 10542, 10544, 10546, 10548, 10550, 10552, - 10554, 3245, 10615, 10617, 10619, 3291, 3255, 10621, 3210, 0, 3273, 3293, - 10623, 3222, 10625, 10627, 3263, 10629, 10631, 10633, 10635, 10637, - 10639, 10641, 10643, 10645, 10647, 10649, 10532, 3253, 3192, 3289, 3257, - 3259, 10534, 3212, 3218, 10536, 10538, 3220, 3261, 3224, 10540, 3229, - 3231, 3233, 10542, 10544, 10546, 10548, 10550, 10552, 10554, 3245, 10615, - 10617, 10619, 3291, 3255, 10621, 3210, 3214, 3273, 3293, 10623, 3222, - 10625, 10627, 3263, 10629, 10631, 10633, 10635, 10637, 10639, 10641, - 10643, 10645, 10647, 10649, 10532, 0, 3192, 3289, 0, 0, 10534, 0, 0, - 10536, 10538, 0, 0, 3224, 10540, 3229, 3231, 0, 10542, 10544, 10546, - 10548, 10550, 10552, 10554, 3245, 10615, 10617, 10619, 3291, 0, 10621, 0, - 3214, 3273, 3293, 10623, 3222, 10625, 10627, 0, 10629, 10631, 10633, - 10635, 10637, 10639, 10641, 10643, 10645, 10647, 10649, 10532, 3253, - 3192, 3289, 3257, 3259, 10534, 3212, 3218, 10536, 10538, 3220, 3261, - 3224, 10540, 3229, 3231, 3233, 10542, 10544, 10546, 10548, 10550, 10552, - 10554, 3245, 10615, 10617, 10619, 3291, 3255, 10621, 3210, 3214, 3273, - 3293, 10623, 3222, 10625, 10627, 3263, 10629, 10631, 10633, 10635, 10637, - 10639, 10641, 10643, 10645, 10647, 10649, 10532, 3253, 0, 3289, 3257, - 3259, 10534, 0, 0, 10536, 10538, 3220, 3261, 3224, 10540, 3229, 3231, 0, - 10542, 10544, 10546, 10548, 10550, 10552, 10554, 0, 10615, 10617, 10619, - 3291, 3255, 10621, 3210, 3214, 3273, 3293, 10623, 3222, 10625, 10627, - 3263, 10629, 10631, 10633, 10635, 10637, 10639, 10641, 10643, 10645, - 10647, 10649, 10532, 3253, 0, 3289, 3257, 3259, 10534, 0, 3218, 10536, - 10538, 3220, 3261, 0, 10540, 0, 0, 0, 10542, 10544, 10546, 10548, 10550, - 10552, 10554, 0, 10615, 10617, 10619, 3291, 3255, 10621, 3210, 3214, - 3273, 3293, 10623, 3222, 10625, 10627, 3263, 10629, 10631, 10633, 10635, - 10637, 10639, 10641, 10643, 10645, 10647, 10649, 10532, 3253, 3192, 3289, - 3257, 3259, 10534, 3212, 3218, 10536, 10538, 3220, 3261, 3224, 10540, - 3229, 3231, 3233, 10542, 10544, 10546, 10548, 10550, 10552, 10554, 3245, - 10615, 10617, 10619, 3291, 3255, 10621, 3210, 3214, 3273, 3293, 10623, - 3222, 10625, 10627, 3263, 10629, 10631, 10633, 10635, 10637, 10639, - 10641, 10643, 10645, 10647, 10649, 10532, 3253, 3192, 3289, 3257, 3259, - 10534, 3212, 3218, 10536, 10538, 3220, 3261, 3224, 10540, 3229, 3231, - 3233, 10542, 10544, 10546, 10548, 10550, 10552, 10554, 3245, 10615, - 10617, 10619, 3291, 3255, 10621, 3210, 3214, 3273, 3293, 10623, 3222, - 10625, 10627, 3263, 10629, 10631, 10633, 10635, 10637, 10639, 10641, - 10643, 10645, 10647, 10649, 10532, 3253, 3192, 3289, 3257, 3259, 10534, - 3212, 3218, 10536, 10538, 3220, 3261, 3224, 10540, 3229, 3231, 3233, - 10542, 10544, 10546, 10548, 10550, 10552, 10554, 3245, 10615, 10617, - 10619, 3291, 3255, 10621, 3210, 3214, 3273, 3293, 10623, 3222, 10625, - 10627, 3263, 10629, 10631, 10633, 10635, 10637, 10639, 10641, 10643, - 10645, 10647, 10649, 10532, 3253, 3192, 3289, 3257, 3259, 10534, 3212, - 3218, 10536, 10538, 3220, 3261, 3224, 10540, 3229, 3231, 3233, 10542, - 10544, 10546, 10548, 10550, 10552, 10554, 3245, 10615, 10617, 10619, - 3291, 3255, 10621, 3210, 3214, 3273, 3293, 10623, 3222, 10625, 10627, - 3263, 10629, 10631, 10633, 10635, 10637, 10639, 10641, 10643, 10645, - 10647, 10649, 10532, 3253, 3192, 3289, 3257, 3259, 10534, 3212, 3218, - 10536, 10538, 3220, 3261, 3224, 10540, 3229, 3231, 3233, 10542, 10544, - 10546, 10548, 10550, 10552, 10554, 3245, 10615, 10617, 10619, 3291, 3255, - 10621, 3210, 3214, 3273, 3293, 10623, 3222, 10625, 10627, 3263, 10629, - 10631, 10633, 10635, 10637, 10639, 10641, 10643, 10645, 10647, 10649, - 10532, 3253, 3192, 3289, 3257, 3259, 10534, 3212, 3218, 10536, 10538, - 3220, 3261, 3224, 10540, 3229, 3231, 3233, 10542, 10544, 10546, 10548, - 10550, 10552, 10554, 3245, 10615, 10617, 10619, 3291, 3255, 10621, 3210, - 3214, 3273, 3293, 10623, 3222, 10625, 10627, 3263, 10629, 10631, 10633, - 10635, 10637, 10639, 10641, 10643, 10645, 10647, 10649, 10651, 10653, 0, - 0, 10655, 10657, 3283, 10659, 10661, 10663, 10665, 10667, 10669, 10671, - 10673, 10675, 10677, 10679, 10681, 3285, 10683, 10685, 10687, 10689, - 10691, 10693, 10695, 10697, 10699, 10701, 10703, 10705, 3281, 10707, - 10709, 10711, 10713, 10715, 10717, 10719, 10721, 10723, 10725, 10727, - 10729, 3279, 10731, 10733, 10735, 10737, 10739, 10741, 10743, 10745, - 10747, 10749, 10751, 10753, 10755, 10757, 10759, 10761, 10655, 10657, - 3283, 10659, 10661, 10663, 10665, 10667, 10669, 10671, 10673, 10675, - 10677, 10679, 10681, 3285, 10683, 10685, 10687, 10689, 10691, 10693, - 10695, 10697, 10699, 10701, 10703, 10705, 3281, 10707, 10709, 10711, - 10713, 10715, 10717, 10719, 10721, 10723, 10725, 10727, 10729, 3279, - 10731, 10733, 10735, 10737, 10739, 10741, 10743, 10745, 10747, 10749, - 10751, 10753, 10755, 10757, 10759, 10761, 10655, 10657, 3283, 10659, - 10661, 10663, 10665, 10667, 10669, 10671, 10673, 10675, 10677, 10679, - 10681, 3285, 10683, 10685, 10687, 10689, 10691, 10693, 10695, 10697, - 10699, 10701, 10703, 10705, 3281, 10707, 10709, 10711, 10713, 10715, - 10717, 10719, 10721, 10723, 10725, 10727, 10729, 3279, 10731, 10733, - 10735, 10737, 10739, 10741, 10743, 10745, 10747, 10749, 10751, 10753, - 10755, 10757, 10759, 10761, 10655, 10657, 3283, 10659, 10661, 10663, - 10665, 10667, 10669, 10671, 10673, 10675, 10677, 10679, 10681, 3285, - 10683, 10685, 10687, 10689, 10691, 10693, 10695, 10697, 10699, 10701, - 10703, 10705, 3281, 10707, 10709, 10711, 10713, 10715, 10717, 10719, - 10721, 10723, 10725, 10727, 10729, 3279, 10731, 10733, 10735, 10737, - 10739, 10741, 10743, 10745, 10747, 10749, 10751, 10753, 10755, 10757, - 10759, 10761, 10655, 10657, 3283, 10659, 10661, 10663, 10665, 10667, - 10669, 10671, 10673, 10675, 10677, 10679, 10681, 3285, 10683, 10685, - 10687, 10689, 10691, 10693, 10695, 10697, 10699, 10701, 10703, 10705, - 3281, 10707, 10709, 10711, 10713, 10715, 10717, 10719, 10721, 10723, - 10725, 10727, 10729, 3279, 10731, 10733, 10735, 10737, 10739, 10741, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10566, 3265, + 3204, 3301, 3269, 3271, 10568, 3224, 3230, 10570, 10572, 3232, 3273, + 3236, 10574, 3241, 3243, 3245, 10576, 10578, 10580, 10582, 10584, 10586, + 10588, 3257, 10649, 10651, 10653, 3303, 3267, 10655, 3222, 3226, 3285, + 3305, 10657, 3234, 10659, 10661, 3275, 10663, 10665, 10667, 10669, 10671, + 10673, 10675, 10677, 10679, 10681, 10683, 10566, 3265, 3204, 3301, 3269, + 3271, 10568, 3224, 3230, 10570, 10572, 3232, 3273, 3236, 10574, 3241, + 3243, 3245, 10576, 10578, 10580, 10582, 10584, 10586, 10588, 3257, 10649, + 10651, 10653, 3303, 3267, 10655, 3222, 0, 3285, 3305, 10657, 3234, 10659, + 10661, 3275, 10663, 10665, 10667, 10669, 10671, 10673, 10675, 10677, + 10679, 10681, 10683, 10566, 3265, 3204, 3301, 3269, 3271, 10568, 3224, + 3230, 10570, 10572, 3232, 3273, 3236, 10574, 3241, 3243, 3245, 10576, + 10578, 10580, 10582, 10584, 10586, 10588, 3257, 10649, 10651, 10653, + 3303, 3267, 10655, 3222, 3226, 3285, 3305, 10657, 3234, 10659, 10661, + 3275, 10663, 10665, 10667, 10669, 10671, 10673, 10675, 10677, 10679, + 10681, 10683, 10566, 0, 3204, 3301, 0, 0, 10568, 0, 0, 10570, 10572, 0, + 0, 3236, 10574, 3241, 3243, 0, 10576, 10578, 10580, 10582, 10584, 10586, + 10588, 3257, 10649, 10651, 10653, 3303, 0, 10655, 0, 3226, 3285, 3305, + 10657, 3234, 10659, 10661, 0, 10663, 10665, 10667, 10669, 10671, 10673, + 10675, 10677, 10679, 10681, 10683, 10566, 3265, 3204, 3301, 3269, 3271, + 10568, 3224, 3230, 10570, 10572, 3232, 3273, 3236, 10574, 3241, 3243, + 3245, 10576, 10578, 10580, 10582, 10584, 10586, 10588, 3257, 10649, + 10651, 10653, 3303, 3267, 10655, 3222, 3226, 3285, 3305, 10657, 3234, + 10659, 10661, 3275, 10663, 10665, 10667, 10669, 10671, 10673, 10675, + 10677, 10679, 10681, 10683, 10566, 3265, 0, 3301, 3269, 3271, 10568, 0, + 0, 10570, 10572, 3232, 3273, 3236, 10574, 3241, 3243, 0, 10576, 10578, + 10580, 10582, 10584, 10586, 10588, 0, 10649, 10651, 10653, 3303, 3267, + 10655, 3222, 3226, 3285, 3305, 10657, 3234, 10659, 10661, 3275, 10663, + 10665, 10667, 10669, 10671, 10673, 10675, 10677, 10679, 10681, 10683, + 10566, 3265, 0, 3301, 3269, 3271, 10568, 0, 3230, 10570, 10572, 3232, + 3273, 0, 10574, 0, 0, 0, 10576, 10578, 10580, 10582, 10584, 10586, 10588, + 0, 10649, 10651, 10653, 3303, 3267, 10655, 3222, 3226, 3285, 3305, 10657, + 3234, 10659, 10661, 3275, 10663, 10665, 10667, 10669, 10671, 10673, + 10675, 10677, 10679, 10681, 10683, 10566, 3265, 3204, 3301, 3269, 3271, + 10568, 3224, 3230, 10570, 10572, 3232, 3273, 3236, 10574, 3241, 3243, + 3245, 10576, 10578, 10580, 10582, 10584, 10586, 10588, 3257, 10649, + 10651, 10653, 3303, 3267, 10655, 3222, 3226, 3285, 3305, 10657, 3234, + 10659, 10661, 3275, 10663, 10665, 10667, 10669, 10671, 10673, 10675, + 10677, 10679, 10681, 10683, 10566, 3265, 3204, 3301, 3269, 3271, 10568, + 3224, 3230, 10570, 10572, 3232, 3273, 3236, 10574, 3241, 3243, 3245, + 10576, 10578, 10580, 10582, 10584, 10586, 10588, 3257, 10649, 10651, + 10653, 3303, 3267, 10655, 3222, 3226, 3285, 3305, 10657, 3234, 10659, + 10661, 3275, 10663, 10665, 10667, 10669, 10671, 10673, 10675, 10677, + 10679, 10681, 10683, 10566, 3265, 3204, 3301, 3269, 3271, 10568, 3224, + 3230, 10570, 10572, 3232, 3273, 3236, 10574, 3241, 3243, 3245, 10576, + 10578, 10580, 10582, 10584, 10586, 10588, 3257, 10649, 10651, 10653, + 3303, 3267, 10655, 3222, 3226, 3285, 3305, 10657, 3234, 10659, 10661, + 3275, 10663, 10665, 10667, 10669, 10671, 10673, 10675, 10677, 10679, + 10681, 10683, 10566, 3265, 3204, 3301, 3269, 3271, 10568, 3224, 3230, + 10570, 10572, 3232, 3273, 3236, 10574, 3241, 3243, 3245, 10576, 10578, + 10580, 10582, 10584, 10586, 10588, 3257, 10649, 10651, 10653, 3303, 3267, + 10655, 3222, 3226, 3285, 3305, 10657, 3234, 10659, 10661, 3275, 10663, + 10665, 10667, 10669, 10671, 10673, 10675, 10677, 10679, 10681, 10683, + 10566, 3265, 3204, 3301, 3269, 3271, 10568, 3224, 3230, 10570, 10572, + 3232, 3273, 3236, 10574, 3241, 3243, 3245, 10576, 10578, 10580, 10582, + 10584, 10586, 10588, 3257, 10649, 10651, 10653, 3303, 3267, 10655, 3222, + 3226, 3285, 3305, 10657, 3234, 10659, 10661, 3275, 10663, 10665, 10667, + 10669, 10671, 10673, 10675, 10677, 10679, 10681, 10683, 10566, 3265, + 3204, 3301, 3269, 3271, 10568, 3224, 3230, 10570, 10572, 3232, 3273, + 3236, 10574, 3241, 3243, 3245, 10576, 10578, 10580, 10582, 10584, 10586, + 10588, 3257, 10649, 10651, 10653, 3303, 3267, 10655, 3222, 3226, 3285, + 3305, 10657, 3234, 10659, 10661, 3275, 10663, 10665, 10667, 10669, 10671, + 10673, 10675, 10677, 10679, 10681, 10683, 10685, 10687, 10689, 0, 10691, + 10693, 3295, 10695, 10697, 10699, 10701, 10703, 10705, 10707, 10709, + 10711, 10713, 10715, 10717, 3297, 10719, 10721, 10723, 10725, 10727, + 10729, 10731, 10733, 10735, 10737, 10739, 10741, 3293, 10743, 10745, + 10747, 10749, 10751, 10753, 10755, 10757, 10759, 10761, 10763, 10765, + 3291, 10767, 10769, 10771, 10773, 10775, 10777, 10779, 10781, 10783, + 10785, 10787, 10789, 10791, 10793, 10795, 10797, 10691, 10693, 3295, + 10695, 10697, 10699, 10701, 10703, 10705, 10707, 10709, 10711, 10713, + 10715, 10717, 3297, 10719, 10721, 10723, 10725, 10727, 10729, 10731, + 10733, 10735, 10737, 10739, 10741, 3293, 10743, 10745, 10747, 10749, + 10751, 10753, 10755, 10757, 10759, 10761, 10763, 10765, 3291, 10767, + 10769, 10771, 10773, 10775, 10777, 10779, 10781, 10783, 10785, 10787, + 10789, 10791, 10793, 10795, 10797, 10691, 10693, 3295, 10695, 10697, + 10699, 10701, 10703, 10705, 10707, 10709, 10711, 10713, 10715, 10717, + 3297, 10719, 10721, 10723, 10725, 10727, 10729, 10731, 10733, 10735, + 10737, 10739, 10741, 3293, 10743, 10745, 10747, 10749, 10751, 10753, + 10755, 10757, 10759, 10761, 10763, 10765, 3291, 10767, 10769, 10771, + 10773, 10775, 10777, 10779, 10781, 10783, 10785, 10787, 10789, 10791, + 10793, 10795, 10797, 10691, 10693, 3295, 10695, 10697, 10699, 10701, + 10703, 10705, 10707, 10709, 10711, 10713, 10715, 10717, 3297, 10719, + 10721, 10723, 10725, 10727, 10729, 10731, 10733, 10735, 10737, 10739, + 10741, 3293, 10743, 10745, 10747, 10749, 10751, 10753, 10755, 10757, + 10759, 10761, 10763, 10765, 3291, 10767, 10769, 10771, 10773, 10775, + 10777, 10779, 10781, 10783, 10785, 10787, 10789, 10791, 10793, 10795, + 10797, 10691, 10693, 3295, 10695, 10697, 10699, 10701, 10703, 10705, + 10707, 10709, 10711, 10713, 10715, 10717, 3297, 10719, 10721, 10723, + 10725, 10727, 10729, 10731, 10733, 10735, 10737, 10739, 10741, 3293, 10743, 10745, 10747, 10749, 10751, 10753, 10755, 10757, 10759, 10761, - 10763, 10765, 0, 0, 10556, 10558, 10560, 10562, 10564, 10566, 10568, - 10570, 10572, 10574, 10556, 10558, 10560, 10562, 10564, 10566, 10568, - 10570, 10572, 10574, 10556, 10558, 10560, 10562, 10564, 10566, 10568, - 10570, 10572, 10574, 10556, 10558, 10560, 10562, 10564, 10566, 10568, - 10570, 10572, 10574, 10556, 10558, 10560, 10562, 10564, 10566, 10568, - 10570, 10572, 10574, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 10767, 10769, 10771, 10773, 10775, 10777, 10779, + 10763, 10765, 3291, 10767, 10769, 10771, 10773, 10775, 10777, 10779, 10781, 10783, 10785, 10787, 10789, 10791, 10793, 10795, 10797, 10799, - 10801, 10803, 10805, 10807, 10809, 10811, 10813, 10815, 10817, 10819, - 10821, 10823, 10825, 10827, 10829, 10831, 10833, 10835, 10837, 10839, - 10841, 10843, 10845, 10847, 10849, 10851, 10853, 10855, 10857, 10859, - 10861, 10863, 10865, 10867, 10869, 10871, 10873, 10875, 10877, 10879, - 10881, 10883, 10885, 10887, 10889, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 10891, 10893, 10895, 10897, 0, 10899, 10901, 10903, 10905, - 10907, 10909, 10911, 10913, 10915, 10917, 10919, 10921, 10923, 10925, - 10927, 10929, 10931, 10933, 10935, 10937, 10939, 10941, 10943, 10945, - 10947, 10949, 10951, 0, 10893, 10895, 0, 10953, 0, 0, 10903, 0, 10907, - 10909, 10911, 10913, 10915, 10917, 10919, 10921, 10923, 10925, 0, 10929, - 10931, 10933, 10935, 0, 10939, 0, 10943, 0, 0, 0, 0, 0, 0, 10895, 0, 0, - 0, 0, 10903, 0, 10907, 0, 10911, 0, 10915, 10917, 10919, 0, 10923, 10925, - 0, 10929, 0, 0, 10935, 0, 10939, 0, 10943, 0, 10947, 0, 10951, 0, 10893, - 10895, 0, 10953, 0, 0, 10903, 10905, 10907, 10909, 0, 10913, 10915, - 10917, 10919, 10921, 10923, 10925, 0, 10929, 10931, 10933, 10935, 0, - 10939, 10941, 10943, 10945, 0, 10949, 0, 10891, 10893, 10895, 10897, - 10953, 10899, 10901, 10903, 10905, 10907, 0, 10911, 10913, 10915, 10917, - 10919, 10921, 10923, 10925, 10927, 10929, 10931, 10933, 10935, 10937, - 10939, 10941, 10943, 0, 0, 0, 0, 0, 10893, 10895, 10897, 0, 10899, 10901, - 10903, 10905, 10907, 0, 10911, 10913, 10915, 10917, 10919, 10921, 10923, - 10925, 10927, 10929, 10931, 10933, 10935, 10937, 10939, 10941, 10943, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10955, 10958, - 10961, 10964, 10967, 10970, 10973, 10976, 10979, 10982, 10985, 0, 0, 0, - 0, 0, 10988, 10992, 10996, 11000, 11004, 11008, 11012, 11016, 11020, - 11024, 11028, 11032, 11036, 11040, 11044, 11048, 11052, 11056, 11060, - 11064, 11068, 11072, 11076, 11080, 11084, 11088, 11092, 3926, 3956, - 11096, 11099, 0, 11102, 11104, 11106, 11108, 11110, 11112, 11114, 11116, - 11118, 11120, 11122, 11124, 11126, 11128, 11130, 11132, 11134, 11136, - 11138, 11140, 11142, 11144, 11146, 11148, 11150, 11152, 11154, 6348, - 11157, 11160, 11163, 11167, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11170, 11173, 11176, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 11179, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11182, - 11185, 11188, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11190, 11192, 11194, - 11196, 11198, 11200, 11202, 11204, 11206, 11208, 11210, 11212, 11214, - 11216, 11218, 11220, 11222, 11224, 11226, 11228, 11230, 11232, 11234, - 11236, 11238, 11240, 11242, 11244, 11246, 11248, 11250, 11252, 11254, - 11256, 11258, 11260, 11262, 11264, 11266, 11268, 11270, 11272, 11274, - 11276, 0, 0, 0, 0, 11278, 11282, 11286, 11290, 11294, 11298, 11302, - 11306, 11310, 0, 0, 0, 0, 0, 0, 0, 11314, 11316, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 10556, 10558, 10560, 10562, 10564, 10566, 10568, 10570, - 10572, 10574, 0, 0, 0, 0, 0, 0, 11318, 11320, 11322, 11324, 11326, 7197, - 11328, 11330, 11332, 11334, 7199, 11336, 11338, 11340, 7201, 11342, - 11344, 11346, 11348, 11350, 11352, 11354, 11356, 11358, 11360, 11362, - 11364, 7317, 11366, 11368, 11370, 11372, 11374, 11376, 11378, 11380, - 11382, 7327, 7203, 7205, 7329, 11384, 11386, 6819, 11388, 7207, 11390, - 11392, 11394, 11396, 11396, 11396, 11398, 11400, 11402, 11404, 11406, - 11408, 11410, 11412, 11414, 11416, 11418, 11420, 11422, 11424, 11426, - 11428, 11430, 11432, 11432, 7333, 11434, 11436, 11438, 11440, 7211, - 11442, 11444, 11446, 7125, 11448, 11450, 11452, 11454, 11456, 11458, - 11460, 11462, 11464, 11466, 11468, 11470, 11472, 11474, 11476, 11478, - 11480, 11482, 11484, 11486, 11488, 11490, 11492, 11494, 11496, 11498, - 11498, 11500, 11502, 11504, 6811, 11506, 11508, 11510, 11512, 11514, - 11516, 11518, 11520, 7221, 11522, 11524, 11526, 11528, 11530, 11532, - 11534, 11536, 11538, 11540, 11542, 11544, 11546, 11548, 11550, 11552, - 11554, 11556, 11558, 11560, 11562, 6703, 11564, 11566, 11568, 11568, - 11570, 11572, 11572, 11574, 11576, 11578, 11580, 11582, 11584, 11586, - 11588, 11590, 11592, 11594, 11596, 11598, 7223, 11600, 11602, 11604, - 11606, 7357, 11606, 11608, 7227, 11610, 11612, 11614, 11616, 7229, 6649, - 11618, 11620, 11622, 11624, 11626, 11628, 11630, 11632, 11634, 11636, - 11638, 11640, 11642, 11644, 11646, 11648, 11650, 11652, 11654, 11656, - 11658, 11660, 7231, 11662, 11664, 11666, 11668, 11670, 11672, 7235, - 11674, 11676, 11678, 11680, 11682, 11684, 11686, 11688, 6705, 7373, - 11690, 11692, 11694, 11696, 11698, 11700, 11702, 11704, 7237, 11706, - 11708, 11710, 11712, 7459, 11714, 11716, 11718, 11720, 11722, 11724, - 11726, 11728, 11730, 11732, 11734, 11736, 11738, 6845, 11740, 11742, - 11744, 11746, 11748, 11750, 11752, 11754, 11756, 11758, 11760, 7239, - 7019, 11762, 11764, 11766, 11768, 11770, 11772, 11774, 11776, 7381, - 11778, 11780, 11782, 11784, 11786, 11788, 11790, 11792, 7383, 11794, - 11796, 11798, 11800, 11802, 11804, 11806, 11808, 11810, 11812, 11814, - 11816, 7387, 11818, 11820, 11822, 11824, 11826, 11828, 11830, 11832, - 11834, 11836, 11838, 11838, 11840, 11842, 7391, 11844, 11846, 11848, - 11850, 11852, 11854, 11856, 6817, 11858, 11860, 11862, 11864, 11866, - 11868, 11870, 7403, 11872, 11874, 11876, 11878, 11880, 11882, 11882, - 7405, 7463, 11884, 11886, 11888, 11890, 11892, 6741, 7409, 11894, 11896, - 7261, 11898, 11900, 7169, 11902, 11904, 7269, 11906, 11908, 11910, 11912, - 11912, 11914, 11916, 11918, 11920, 11922, 11924, 11926, 11928, 11930, - 11932, 11934, 11936, 11938, 11940, 11942, 11944, 11946, 11948, 11950, - 11952, 11954, 11956, 11958, 11960, 11962, 11964, 11966, 7281, 11968, - 11970, 11972, 11974, 11976, 11978, 11980, 11982, 11984, 11986, 11988, - 11990, 11992, 11994, 11996, 11998, 11570, 12000, 12002, 12004, 12006, - 12008, 12010, 12012, 12014, 12016, 12018, 12020, 12022, 6853, 12024, - 12026, 12028, 12030, 12032, 12034, 7287, 12036, 12038, 12040, 12042, - 12044, 12046, 12048, 12050, 12052, 12054, 12056, 12058, 12060, 12062, - 12064, 12066, 12068, 12070, 12072, 12074, 6731, 12076, 12078, 12080, - 12082, 12084, 12086, 7423, 12088, 12090, 12092, 12094, 12096, 12098, - 12100, 12102, 12104, 12106, 12108, 12110, 12112, 12114, 12116, 12118, - 12120, 12122, 12124, 12126, 7433, 7435, 12128, 12130, 12132, 12134, - 12136, 12138, 12140, 12142, 12144, 12146, 12148, 12150, 12152, 7437, - 12154, 12156, 12158, 12160, 12162, 12164, 12166, 12168, 12170, 12172, - 12174, 12176, 12178, 12180, 12182, 12184, 12186, 12188, 12190, 12192, - 12194, 12196, 12198, 12200, 12202, 12204, 12206, 12208, 12210, 12212, - 7449, 7449, 12214, 12216, 12218, 12220, 12222, 12224, 12226, 12228, - 12230, 12232, 7451, 12234, 12236, 12238, 12240, 12242, 12244, 12246, + 10801, 0, 0, 10590, 10592, 10594, 10596, 10598, 10600, 10602, 10604, + 10606, 10608, 10590, 10592, 10594, 10596, 10598, 10600, 10602, 10604, + 10606, 10608, 10590, 10592, 10594, 10596, 10598, 10600, 10602, 10604, + 10606, 10608, 10590, 10592, 10594, 10596, 10598, 10600, 10602, 10604, + 10606, 10608, 10590, 10592, 10594, 10596, 10598, 10600, 10602, 10604, + 10606, 10608, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 10803, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10805, 10807, 10809, 10811, 10813, 10815, + 10817, 10819, 10821, 10823, 10825, 10827, 10829, 10831, 10833, 10835, + 10837, 10839, 10841, 10843, 10845, 10847, 10849, 10851, 10853, 10855, + 10857, 10859, 10861, 10863, 10865, 10867, 10869, 10871, 10873, 10875, + 10877, 10879, 10881, 10883, 10885, 10887, 10889, 10891, 10893, 10895, + 10897, 10899, 10901, 10903, 10905, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10907, 10909, 10911, 10913, 10915, + 10917, 10919, 10921, 10923, 10925, 10927, 10929, 10931, 10933, 10935, + 10937, 10939, 10941, 10943, 10945, 10947, 10949, 10951, 10953, 10955, + 10957, 10959, 10961, 10963, 10965, 10967, 10969, 10971, 10973, 10975, + 10977, 10979, 10981, 10983, 10985, 10987, 10989, 10991, 10993, 10995, + 10997, 10999, 11001, 11003, 11005, 11007, 11009, 11011, 11013, 11015, + 11017, 11019, 11021, 11023, 11025, 11027, 11029, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11031, 11033, 11035, 11037, 0, 11039, + 11041, 11043, 11045, 11047, 11049, 11051, 11053, 11055, 11057, 11059, + 11061, 11063, 11065, 11067, 11069, 11071, 11073, 11075, 11077, 11079, + 11081, 11083, 11085, 11087, 11089, 11091, 0, 11033, 11035, 0, 11093, 0, + 0, 11043, 0, 11047, 11049, 11051, 11053, 11055, 11057, 11059, 11061, + 11063, 11065, 0, 11069, 11071, 11073, 11075, 0, 11079, 0, 11083, 0, 0, 0, + 0, 0, 0, 11035, 0, 0, 0, 0, 11043, 0, 11047, 0, 11051, 0, 11055, 11057, + 11059, 0, 11063, 11065, 0, 11069, 0, 0, 11075, 0, 11079, 0, 11083, 0, + 11087, 0, 11091, 0, 11033, 11035, 0, 11093, 0, 0, 11043, 11045, 11047, + 11049, 0, 11053, 11055, 11057, 11059, 11061, 11063, 11065, 0, 11069, + 11071, 11073, 11075, 0, 11079, 11081, 11083, 11085, 0, 11089, 0, 11031, + 11033, 11035, 11037, 11093, 11039, 11041, 11043, 11045, 11047, 0, 11051, + 11053, 11055, 11057, 11059, 11061, 11063, 11065, 11067, 11069, 11071, + 11073, 11075, 11077, 11079, 11081, 11083, 0, 0, 0, 0, 0, 11033, 11035, + 11037, 0, 11039, 11041, 11043, 11045, 11047, 0, 11051, 11053, 11055, + 11057, 11059, 11061, 11063, 11065, 11067, 11069, 11071, 11073, 11075, + 11077, 11079, 11081, 11083, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 11095, 11098, 11101, 11104, 11107, 11110, 11113, 11116, + 11119, 11122, 11125, 0, 0, 0, 0, 0, 11128, 11132, 11136, 11140, 11144, + 11148, 11152, 11156, 11160, 11164, 11168, 11172, 11176, 11180, 11184, + 11188, 11192, 11196, 11200, 11204, 11208, 11212, 11216, 11220, 11224, + 11228, 11232, 3938, 3968, 11236, 11239, 0, 11242, 11244, 11246, 11248, + 11250, 11252, 11254, 11256, 11258, 11260, 11262, 11264, 11266, 11268, + 11270, 11272, 11274, 11276, 11278, 11280, 11282, 11284, 11286, 11288, + 11290, 11292, 11294, 6360, 11297, 11300, 11303, 11307, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11310, 11313, + 11316, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11319, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 11322, 11325, 11328, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 11330, 11332, 11334, 11336, 11338, 11340, 11342, 11344, 11346, + 11348, 11350, 11352, 11354, 11356, 11358, 11360, 11362, 11364, 11366, + 11368, 11370, 11372, 11374, 11376, 11378, 11380, 11382, 11384, 11386, + 11388, 11390, 11392, 11394, 11396, 11398, 11400, 11402, 11404, 11406, + 11408, 11410, 11412, 11414, 11416, 0, 0, 0, 0, 11418, 11422, 11426, + 11430, 11434, 11438, 11442, 11446, 11450, 0, 0, 0, 0, 0, 0, 0, 11454, + 11456, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10590, 10592, 10594, + 10596, 10598, 10600, 10602, 10604, 10606, 10608, 0, 0, 0, 0, 0, 0, 11458, + 11460, 11462, 11464, 11466, 7209, 11468, 11470, 11472, 11474, 7211, + 11476, 11478, 11480, 7213, 11482, 11484, 11486, 11488, 11490, 11492, + 11494, 11496, 11498, 11500, 11502, 11504, 7329, 11506, 11508, 11510, + 11512, 11514, 11516, 11518, 11520, 11522, 7339, 7215, 7217, 7341, 11524, + 11526, 6831, 11528, 7219, 11530, 11532, 11534, 11536, 11536, 11536, + 11538, 11540, 11542, 11544, 11546, 11548, 11550, 11552, 11554, 11556, + 11558, 11560, 11562, 11564, 11566, 11568, 11570, 11572, 11572, 7345, + 11574, 11576, 11578, 11580, 7223, 11582, 11584, 11586, 7137, 11588, + 11590, 11592, 11594, 11596, 11598, 11600, 11602, 11604, 11606, 11608, + 11610, 11612, 11614, 11616, 11618, 11620, 11622, 11624, 11626, 11628, + 11630, 11632, 11634, 11636, 11638, 11638, 11640, 11642, 11644, 6823, + 11646, 11648, 11650, 11652, 11654, 11656, 11658, 11660, 7233, 11662, + 11664, 11666, 11668, 11670, 11672, 11674, 11676, 11678, 11680, 11682, + 11684, 11686, 11688, 11690, 11692, 11694, 11696, 11698, 11700, 11702, + 6715, 11704, 11706, 11708, 11708, 11710, 11712, 11712, 11714, 11716, + 11718, 11720, 11722, 11724, 11726, 11728, 11730, 11732, 11734, 11736, + 11738, 7235, 11740, 11742, 11744, 11746, 7369, 11746, 11748, 7239, 11750, + 11752, 11754, 11756, 7241, 6661, 11758, 11760, 11762, 11764, 11766, + 11768, 11770, 11772, 11774, 11776, 11778, 11780, 11782, 11784, 11786, + 11788, 11790, 11792, 11794, 11796, 11798, 11800, 7243, 11802, 11804, + 11806, 11808, 11810, 11812, 7247, 11814, 11816, 11818, 11820, 11822, + 11824, 11826, 11828, 6717, 7385, 11830, 11832, 11834, 11836, 11838, + 11840, 11842, 11844, 7249, 11846, 11848, 11850, 11852, 7471, 11854, + 11856, 11858, 11860, 11862, 11864, 11866, 11868, 11870, 11872, 11874, + 11876, 11878, 6857, 11880, 11882, 11884, 11886, 11888, 11890, 11892, + 11894, 11896, 11898, 11900, 7251, 7031, 11902, 11904, 11906, 11908, + 11910, 11912, 11914, 11916, 7393, 11918, 11920, 11922, 11924, 11926, + 11928, 11930, 11932, 7395, 11934, 11936, 11938, 11940, 11942, 11944, + 11946, 11948, 11950, 11952, 11954, 11956, 7399, 11958, 11960, 11962, + 11964, 11966, 11968, 11970, 11972, 11974, 11976, 11978, 11978, 11980, + 11982, 7403, 11984, 11986, 11988, 11990, 11992, 11994, 11996, 6829, + 11998, 12000, 12002, 12004, 12006, 12008, 12010, 7415, 12012, 12014, + 12016, 12018, 12020, 12022, 12022, 7417, 7475, 12024, 12026, 12028, + 12030, 12032, 6753, 7421, 12034, 12036, 7273, 12038, 12040, 7181, 12042, + 12044, 7281, 12046, 12048, 12050, 12052, 12052, 12054, 12056, 12058, + 12060, 12062, 12064, 12066, 12068, 12070, 12072, 12074, 12076, 12078, + 12080, 12082, 12084, 12086, 12088, 12090, 12092, 12094, 12096, 12098, + 12100, 12102, 12104, 12106, 7293, 12108, 12110, 12112, 12114, 12116, + 12118, 12120, 12122, 12124, 12126, 12128, 12130, 12132, 12134, 12136, + 12138, 11710, 12140, 12142, 12144, 12146, 12148, 12150, 12152, 12154, + 12156, 12158, 12160, 12162, 6865, 12164, 12166, 12168, 12170, 12172, + 12174, 7299, 12176, 12178, 12180, 12182, 12184, 12186, 12188, 12190, + 12192, 12194, 12196, 12198, 12200, 12202, 12204, 12206, 12208, 12210, + 12212, 12214, 6743, 12216, 12218, 12220, 12222, 12224, 12226, 7435, + 12228, 12230, 12232, 12234, 12236, 12238, 12240, 12242, 12244, 12246, 12248, 12250, 12252, 12254, 12256, 12258, 12260, 12262, 12264, 12266, - 12268, 12270, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 7445, 7447, 12268, 12270, 12272, 12274, 12276, 12278, 12280, 12282, + 12284, 12286, 12288, 12290, 12292, 7449, 12294, 12296, 12298, 12300, + 12302, 12304, 12306, 12308, 12310, 12312, 12314, 12316, 12318, 12320, + 12322, 12324, 12326, 12328, 12330, 12332, 12334, 12336, 12338, 12340, + 12342, 12344, 12346, 12348, 12350, 12352, 7461, 7461, 12354, 12356, + 12358, 12360, 12362, 12364, 12366, 12368, 12370, 12372, 7463, 12374, + 12376, 12378, 12380, 12382, 12384, 12386, 12388, 12390, 12392, 12394, + 12396, 12398, 12400, 12402, 12404, 12406, 12408, 12410, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; /* NFC pairs */ @@ -7166,6 +7263,7 @@ static const change_record change_records_3_2_0[] = { { 255, 255, 1, 255, 255, 0 }, { 255, 0, 255, 255, 255, 0 }, { 255, 29, 255, 255, 255, 0 }, + { 0, 255, 255, 255, 255, 0 }, { 255, 26, 255, 255, 255, 0 }, { 5, 255, 255, 255, 255, 0 }, { 14, 6, 255, 255, 255, 0 }, @@ -7216,192 +7314,285 @@ static const change_record change_records_3_2_0[] = { }; static const unsigned char changes_3_2_0_index[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 1, 21, 22, 23, 24, 25, 26, 27, 28, 29, 1, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 1, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 1, 1, 1, 50, 1, 1, 51, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 52, 53, 54, 55, 1, 1, - 56, 1, 1, 1, 57, 1, 1, 1, 1, 1, 1, 58, 1, 1, 1, 59, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 60, 1, 55, 1, 1, 1, 1, 1, 1, 61, 1, 1, 62, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 63, 1, 1, 1, 1, 1, 64, 1, 65, 1, 66, 1, - 1, 1, 1, 1, 1, 1, 1, 67, 68, 1, 1, 1, 69, 28, 70, 71, 72, 73, 74, 75, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 76, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 77, 78, 79, 1, 80, 81, 82, 83, 84, 85, 86, 87, 88, 28, 89, - 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 113, 28, 28, 28, 114, 115, 116, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 117, 28, 28, 28, 28, 118, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 119, 28, 28, 120, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 121, 1, 1, 1, 1, 1, - 1, 28, 28, 122, 123, 1, 124, 125, 126, 28, 28, 28, 28, 28, 28, 28, 28, + 1, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 1, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 1, 1, 51, 1, 1, + 52, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 53, 54, 55, 56, 1, + 1, 57, 1, 1, 1, 58, 1, 1, 1, 1, 1, 1, 59, 1, 1, 1, 60, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 61, 1, 56, 1, 1, 1, 1, 1, 1, 62, 1, 1, 63, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 64, 1, 1, 1, 1, 1, 65, 1, 66, 1, 67, + 1, 1, 1, 1, 1, 1, 1, 1, 68, 69, 1, 1, 1, 70, 28, 71, 72, 73, 74, 75, 76, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 77, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 78, 79, 80, 1, 81, 82, 83, 84, 85, 86, 87, 88, 89, 28, 90, + 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, + 107, 108, 109, 110, 111, 112, 113, 114, 28, 28, 28, 115, 28, 116, 117, + 118, 118, 118, 118, 118, 118, 118, 118, 119, 28, 28, 28, 28, 120, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 121, 28, 28, 122, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 123, 118, 118, + 118, 118, 118, 118, 28, 28, 124, 125, 118, 126, 127, 128, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 127, 128, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 129, 28, 130, 131, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 132, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 133, - 28, 134, 135, 1, 136, 137, 138, 139, 1, 140, 141, 28, 28, 142, 1, 1, 1, - 1, 143, 144, 145, 146, 1, 147, 148, 149, 150, 151, 152, 1, 1, 153, 154, - 155, 1, 156, 157, 158, 28, 28, 28, 159, 160, 161, 28, 162, 163, 1, 1, 1, - 1, 164, 66, 1, 1, 1, 1, 1, 1, 1, 165, 166, 167, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 168, 1, 1, 1, 1, 1, 169, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 170, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 171, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 172, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 173, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 174, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 175, - 28, 28, 43, 1, 1, 1, 1, 1, 1, 1, 1, 1, 168, 1, 1, 1, 1, 1, 1, 1, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 176, + 28, 28, 28, 28, 28, 28, 129, 130, 28, 28, 28, 131, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 132, 28, 133, 134, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 135, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 136, 28, 137, 138, + 139, 140, 141, 142, 143, 144, 145, 146, 28, 28, 147, 148, 118, 118, 118, + 149, 150, 151, 152, 118, 153, 154, 155, 156, 157, 158, 118, 118, 159, + 160, 161, 118, 162, 163, 164, 28, 28, 28, 165, 166, 167, 28, 168, 169, + 118, 118, 118, 118, 170, 67, 1, 1, 1, 1, 1, 1, 1, 171, 172, 173, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 174, 1, 1, 1, + 1, 1, 175, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 176, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 177, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 178, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 179, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 180, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 177, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 178, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 28, 28, 28, 181, 28, 28, 182, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 174, 1, 183, 118, 118, 118, 118, 118, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 184, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, 28, 185, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, + 28, 186, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 187, 188, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 189, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 189, }; static const unsigned char changes_3_2_0_data[] = { @@ -7442,140 +7633,146 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, - 10, 0, 9, 9, 0, 0, 0, 9, 9, 9, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 10, 0, 9, 9, 11, 11, 0, 9, 9, 9, 0, 9, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, + 0, 11, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 11, 9, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 0, 0, 9, 9, 9, 9, 9, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, + 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 9, 0, 0, 0, 0, 0, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, - 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 15, 16, 17, 18, 19, 0, 0, 9, 9, 9, 9, 0, 0, 9, 0, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, - 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, - 0, 9, 9, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 9, 9, 0, 20, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, - 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 9, 0, 0, 0, 0, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 0, 0, 9, 0, 0, 9, 0, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 0, 0, - 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 21, 21, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 0, 0, 11, 11, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, + 0, 0, 0, 0, 0, 0, 11, 0, 11, 11, 11, 0, 0, 0, 0, 11, 11, 0, 9, 0, 0, 0, + 0, 0, 0, 0, 11, 11, 0, 0, 11, 11, 0, 0, 0, 9, 11, 11, 11, 11, 11, 11, 11, + 11, 0, 11, 11, 11, 11, 0, 0, 11, 0, 0, 0, 0, 0, 11, 11, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 18, 19, 20, 0, 0, 9, 9, 9, 9, 11, 11, 9, + 0, 9, 11, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 0, 0, 11, 11, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, + 0, 11, 0, 0, 11, 0, 0, 11, 0, 0, 11, 11, 0, 11, 0, 0, 0, 0, 0, 11, 11, + 11, 11, 0, 0, 11, 11, 0, 0, 0, 11, 11, 11, 9, 11, 11, 11, 11, 11, 11, 11, + 0, 0, 0, 0, 11, 0, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, + 11, 0, 0, 0, 0, 0, 0, 0, 9, 0, 11, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 0, + 0, 11, 0, 0, 0, 0, 0, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, + 11, 0, 0, 0, 11, 11, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 0, 9, 9, 9, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 11, + 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 11, 0, 0, 0, 11, 0, 0, 0, 0, + 0, 0, 0, 0, 11, 11, 0, 0, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 11, 9, 0, + 0, 0, 0, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 9, 11, 11, 0, 0, 11, 11, 0, 0, + 0, 11, 11, 11, 11, 11, 9, 9, 9, 0, 0, 11, 11, 11, 11, 0, 0, 11, 0, 0, 0, + 9, 9, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 11, 0, 0, 0, 0, 0, 0, 11, 11, + 11, 0, 0, 0, 11, 0, 0, 0, 0, 11, 11, 11, 0, 0, 11, 0, 11, 0, 0, 11, 11, + 11, 0, 0, 11, 11, 11, 0, 0, 0, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, + 0, 0, 11, 11, 11, 11, 0, 0, 0, 0, 0, 11, 11, 11, 0, 0, 0, 11, 0, 0, 0, 0, + 11, 11, 9, 11, 11, 11, 11, 11, 11, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 11, 11, 11, 11, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 11, + 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 11, 11, 9, + 9, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 11, 0, 0, 0, 0, 11, 11, 11, 11, 11, + 11, 11, 0, 0, 11, 9, 9, 9, 11, 9, 9, 11, 11, 0, 0, 9, 9, 11, 11, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 11, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 11, 11, 9, 9, 0, 21, 0, 0, 0, 0, 0, 11, + 21, 0, 0, 11, 0, 0, 0, 0, 11, 11, 11, 11, 11, 11, 11, 0, 0, 11, 11, 11, + 11, 11, 9, 9, 0, 11, 0, 0, 9, 9, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 11, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 0, 0, + 9, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 11, 0, 0, 0, 11, 0, 0, + 0, 0, 9, 9, 11, 11, 11, 11, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, + 9, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 11, 9, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 11, 11, 0, + 0, 0, 0, 0, 0, 0, 11, 11, 11, 0, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 11, 0, + 11, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 11, 0, 0, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 11, + 0, 11, 9, 0, 0, 9, 0, 11, 9, 0, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 0, 0, 0, + 0, 0, 0, 0, 9, 0, 0, 0, 11, 0, 11, 0, 9, 9, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 11, 11, 0, 0, 0, 0, 0, 11, 0, 11, 0, 0, 0, + 0, 0, 0, 9, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 0, 0, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 22, 22, 22, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 9, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, + 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 11, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 9, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -7584,46 +7781,43 @@ static const unsigned char changes_3_2_0_data[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 9, 0, 0, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 9, 9, 0, 9, - 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 11, 9, 11, 11, 11, 11, 11, 9, 11, 11, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 9, 9, + 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, - 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, + 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, - 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, - 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 0, 0, 0, + 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 11, 0, + 0, 0, 0, 11, 11, 0, 0, 0, 0, 0, 0, 0, 11, 0, 11, 0, 0, 0, 0, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 11, 0, 0, 0, 0, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 9, 0, 11, 0, 0, 0, 0, 11, 11, 0, 0, 0, 0, 0, 0, 0, + 11, 0, 11, 0, 0, 0, 0, 11, 11, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, + 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 11, 0, 0, 0, 0, 11, 11, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 0, 0, 0, 0, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 9, 0, - 0, 9, 9, 9, 9, 9, 9, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 9, 9, 9, 9, 0, 0, 0, 0, + 0, 0, 0, 0, 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 9, 11, 11, 9, 9, 9, 9, 9, 9, 11, 11, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -7635,78 +7829,83 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 22, 22, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 33, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, + 0, 0, 0, 0, 0, 0, 0, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 11, 0, 0, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, + 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, + 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 11, 11, + 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 35, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 0, 0, 0, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, @@ -7716,72 +7915,85 @@ static const unsigned char changes_3_2_0_data[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 0, 0, 0, 9, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 38, 4, 0, 0, 39, 40, - 41, 42, 43, 44, 1, 1, 0, 0, 0, 4, 38, 8, 6, 7, 39, 40, 41, 42, 43, 44, 1, - 1, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, - 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 0, + 0, 0, 0, 0, 0, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 0, + 0, 0, 0, 0, 0, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 11, 0, 11, 0, 11, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, + 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 11, 11, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 38, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 9, + 11, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 39, 4, 11, 11, 40, 41, 42, 43, 44, 45, + 1, 1, 0, 0, 0, 4, 39, 8, 6, 7, 40, 41, 42, 43, 44, 45, 1, 1, 0, 0, 0, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, + 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 46, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, + 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 47, 47, 47, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 50, 11, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 51, + 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, + 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -7791,60 +8003,58 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 48, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, - 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, - 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, 49, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, + 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, - 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, - 9, 0, 0, 0, 0, 9, 9, 9, 0, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, - 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 9, 0, 0, 0, 0, 9, 9, 9, + 0, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, @@ -7859,30 +8069,31 @@ static const unsigned char changes_3_2_0_data[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 9, 0, 0, 0, 0, 0, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, - 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, - 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 11, + 11, 11, 11, 11, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, + 11, 11, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, + 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, + 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, + 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -7891,62 +8102,65 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 33, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 54, 0, 0, 0, 0, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, + 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, + 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, + 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, + 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, + 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -7958,7 +8172,7 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, + 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -7973,20 +8187,20 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, + 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, + 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, + 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -7996,9 +8210,9 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -8011,13 +8225,12 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, - 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -8025,8 +8238,8 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -8035,13 +8248,13 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -8049,11 +8262,11 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -8068,7 +8281,7 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -8082,8 +8295,8 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -8091,11 +8304,11 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -8111,13 +8324,13 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -8133,13 +8346,12 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -8154,22 +8366,23 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, @@ -8178,472 +8391,575 @@ static const unsigned char changes_3_2_0_data[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 11, 11, 11, 11, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, + 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, + 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 0, 0, 9, - 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, - 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, + 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 19, + 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 19, 0, 0, 0, 0, 0, + 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 11, 0, 0, 0, 0, 0, 11, 0, 11, 0, 0, 11, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 50, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 50, 51, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 21, 21, 21, 21, 0, 0, 0, 1, 1, 21, 21, 0, + 0, 0, 11, 0, 0, 0, 0, 0, 22, 22, 22, 22, 22, 22, 0, 0, 0, 1, 1, 22, 22, + 0, 11, 0, 0, 0, 0, 11, 11, 11, 11, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, - 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 14, 14, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 0, 0, 0, 0, 0, 0, 11, 11, + 0, 0, 0, 0, 0, 0, 11, 11, 0, 0, 0, 0, 0, 0, 11, 11, 0, 0, 0, 11, 11, 11, + 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 15, 15, 15, 0, 0, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 11, 11, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, - 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, 0, 0, 0, - 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 0, 0, 9, 0, 0, 0, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, + 20, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, + 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, + 9, 9, 9, 9, 11, 9, 9, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, - 9, 9, 9, 9, 0, 9, 9, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 11, 11, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 11, 11, 11, 9, + 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 0, 0, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 9, 9, 0, 0, 0, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, - 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, + 9, 9, 9, 9, 11, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 11, 11, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 0, 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, - 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, + 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, - 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, - 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 11, 11, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 11, 9, + 11, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 11, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 11, 11, 9, 9, 11, 11, 9, 9, 9, 11, 11, 9, 11, 11, 11, 11, 11, + 11, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, + 9, 11, 11, 11, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 11, 11, 9, 11, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 11, 11, 9, + 11, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 11, 11, 11, + 11, 11, 11, 11, 11, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, + 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, + 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, + 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, + 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 9, 11, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 11, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 11, 9, 9, 11, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 9, 9, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 0, 9, 0, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 0, 0, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, - 9, 9, 9, 0, 9, 9, 0, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, - 0, 9, 9, 0, 0, 9, 9, 9, 0, 0, 9, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 9, - 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 9, 9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 0, 0, - 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 9, 0, 0, 9, 0, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, - 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 0, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 0, 0, 0, 9, 0, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 0, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 0, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 0, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, @@ -8651,160 +8967,149 @@ static const unsigned char changes_3_2_0_data[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, + 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 11, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, + 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, + 11, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 9, - 9, 9, 9, 9, 9, 9, 0, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 11, 11, 9, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, @@ -8819,19 +9124,20 @@ static const unsigned char changes_3_2_0_data[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, @@ -8840,56 +9146,32 @@ static const unsigned char changes_3_2_0_data[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -8899,98 +9181,59 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, - 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, - 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, - 9, 9, 9, 9, 0, 9, 9, 0, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 11, 11, 0, + 11, 11, 0, 0, 11, 11, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 11, 0, 11, 0, 0, 0, 0, 9, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, + 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 11, 0, + 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -8999,188 +9242,326 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, - 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 11, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 0, 0, 0, 0, 0, 0, 9, 9, 11, + 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 0, 9, 9, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 11, 9, + 9, 11, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 11, 11, 11, 11, 11, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 11, + 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, + 11, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, + 11, 9, 11, 11, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 11, + 9, 11, 9, 11, 11, 11, 11, 11, 11, 9, 11, 11, 11, 11, 9, 11, 9, 11, 9, 11, + 9, 9, 9, 11, 9, 9, 11, 9, 11, 11, 9, 11, 9, 11, 9, 11, 9, 11, 9, 11, 9, + 9, 11, 9, 11, 11, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, + 11, 9, 9, 9, 9, 11, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 11, + 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 0, 9, 0, 0, 9, 0, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 0, 9, 0, 9, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, - 0, 9, 0, 9, 0, 9, 0, 9, 9, 9, 0, 9, 9, 0, 9, 0, 0, 9, 0, 9, 0, 9, 0, 9, - 0, 9, 0, 9, 9, 0, 9, 0, 0, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, - 9, 9, 0, 9, 9, 9, 9, 0, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 0, 9, - 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 9, 9, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, + 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 11, 11, 11, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, - 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 0, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, - 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 9, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, - 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 11, 11, 11, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -9192,10 +9573,11 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -9209,8 +9591,8 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -9220,14 +9602,14 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -9240,8 +9622,8 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -9255,10 +9637,11 @@ static const unsigned char changes_3_2_0_data[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, @@ -9275,7 +9658,7 @@ static const unsigned char changes_3_2_0_data[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, @@ -9287,15 +9670,39 @@ static const unsigned char changes_3_2_0_data[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, @@ -9304,13 +9711,44 @@ static const unsigned char changes_3_2_0_data[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, @@ -9320,8 +9758,19 @@ static const unsigned char changes_3_2_0_data[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, }; static const change_record* get_change_3_2_0(Py_UCS4 n) diff --git a/Modules/unicodename_db.h b/Modules/unicodename_db.h index 5ac5ca462bdfabe..21df146a16f2822 100644 --- a/Modules/unicodename_db.h +++ b/Modules/unicodename_db.h @@ -4,9301 +4,9519 @@ /* name->code dictionary */ static const unsigned char packed_name_dawg[] = { - 160, 171, 4, 254, 2, 65, 246, 145, 3, 66, 206, 160, 3, 67, 146, 247, 4, - 68, 250, 135, 1, 69, 178, 153, 1, 70, 174, 55, 71, 214, 169, 1, 72, 138, - 226, 1, 73, 138, 66, 74, 142, 23, 75, 174, 135, 1, 76, 150, 164, 3, 77, - 198, 201, 3, 78, 170, 103, 79, 174, 131, 1, 80, 212, 159, 1, 2, 81, 85, - 226, 7, 82, 158, 180, 1, 83, 210, 197, 4, 84, 146, 236, 2, 85, 246, 104, - 86, 242, 84, 87, 246, 114, 88, 130, 5, 89, 211, 50, 90, 176, 41, 218, 2, + 138, 183, 4, 254, 2, 65, 158, 153, 3, 66, 210, 162, 3, 67, 218, 144, 5, + 68, 162, 137, 1, 69, 202, 153, 1, 70, 194, 55, 71, 146, 169, 1, 72, 190, + 226, 1, 73, 138, 68, 74, 150, 24, 75, 238, 136, 1, 76, 242, 195, 3, 77, + 186, 239, 3, 78, 190, 103, 79, 174, 132, 1, 80, 244, 159, 1, 2, 81, 85, + 222, 7, 82, 186, 181, 1, 83, 134, 201, 4, 84, 146, 237, 2, 85, 198, 105, + 86, 214, 85, 87, 142, 118, 88, 130, 5, 89, 211, 50, 90, 134, 42, 218, 2, 67, 238, 1, 68, 182, 10, 69, 172, 5, 4, 72, 79, 77, 32, 244, 6, 7, 73, - 82, 80, 76, 65, 78, 69, 82, 76, 190, 36, 77, 242, 1, 78, 162, 26, 80, - 162, 20, 82, 186, 150, 2, 83, 162, 3, 84, 70, 85, 214, 1, 86, 252, 197, - 1, 8, 75, 84, 73, 69, 83, 69, 76, 83, 244, 194, 10, 4, 70, 71, 72, 65, - 202, 235, 9, 66, 248, 165, 5, 2, 81, 85, 171, 215, 10, 88, 18, 132, 1, 2, - 67, 79, 46, 75, 20, 5, 85, 84, 69, 32, 65, 236, 179, 17, 6, 84, 73, 86, - 65, 84, 69, 189, 153, 23, 5, 32, 67, 85, 82, 82, 4, 182, 172, 26, 85, - 149, 148, 14, 2, 82, 68, 5, 255, 198, 34, 78, 4, 194, 235, 35, 67, 199, - 254, 3, 78, 188, 1, 232, 1, 4, 76, 65, 77, 32, 242, 7, 77, 200, 199, 13, - 7, 72, 69, 83, 73, 86, 69, 32, 136, 172, 4, 19, 68, 82, 69, 83, 83, 69, - 68, 32, 84, 79, 32, 84, 72, 69, 32, 83, 85, 66, 74, 150, 237, 13, 85, - 233, 185, 1, 6, 73, 32, 83, 72, 65, 75, 176, 1, 218, 1, 67, 44, 4, 83, + 82, 80, 76, 65, 78, 69, 82, 76, 174, 37, 77, 242, 1, 78, 202, 26, 80, + 162, 20, 82, 190, 156, 2, 83, 174, 3, 84, 70, 85, 214, 1, 86, 184, 199, + 1, 8, 75, 84, 73, 69, 83, 69, 76, 83, 148, 222, 10, 4, 70, 71, 72, 65, + 222, 159, 10, 66, 252, 190, 5, 2, 81, 85, 171, 224, 10, 88, 18, 132, 1, + 2, 67, 79, 46, 75, 20, 5, 85, 84, 69, 32, 65, 240, 216, 17, 6, 84, 73, + 86, 65, 84, 69, 213, 238, 23, 5, 32, 67, 85, 82, 82, 4, 154, 155, 27, 85, + 205, 159, 14, 2, 82, 68, 5, 219, 187, 35, 78, 4, 246, 223, 36, 67, 239, + 131, 4, 78, 188, 1, 232, 1, 4, 76, 65, 77, 32, 242, 7, 77, 140, 236, 13, + 7, 72, 69, 83, 73, 86, 69, 32, 132, 175, 4, 19, 68, 82, 69, 83, 83, 69, + 68, 32, 84, 79, 32, 84, 72, 69, 32, 83, 85, 66, 74, 182, 184, 14, 85, + 221, 185, 1, 6, 73, 32, 83, 72, 65, 75, 176, 1, 218, 1, 67, 44, 4, 83, 77, 65, 76, 168, 4, 7, 71, 69, 77, 73, 78, 65, 84, 116, 8, 73, 78, 73, - 84, 73, 65, 76, 32, 38, 78, 146, 228, 2, 72, 192, 208, 23, 4, 65, 76, 73, - 70, 0, 5, 86, 79, 87, 69, 76, 155, 222, 12, 68, 70, 40, 5, 65, 80, 73, + 84, 73, 65, 76, 32, 38, 78, 186, 235, 2, 72, 252, 183, 24, 4, 65, 76, 73, + 70, 0, 5, 86, 79, 87, 69, 76, 187, 230, 12, 68, 70, 40, 5, 65, 80, 73, 84, 65, 215, 4, 79, 68, 45, 9, 76, 32, 76, 69, 84, 84, 69, 82, 32, 68, - 142, 2, 68, 38, 71, 34, 74, 2, 77, 22, 75, 46, 78, 42, 83, 182, 159, 30, - 81, 142, 228, 4, 76, 142, 45, 67, 158, 204, 4, 90, 240, 9, 2, 65, 76, + 142, 2, 68, 38, 71, 34, 74, 2, 77, 22, 75, 46, 78, 42, 83, 210, 144, 31, + 81, 166, 231, 4, 76, 150, 45, 67, 254, 209, 4, 90, 240, 9, 2, 65, 76, 170, 2, 66, 2, 89, 154, 1, 87, 198, 89, 84, 150, 14, 80, 158, 20, 70, 2, - 72, 2, 82, 2, 86, 186, 2, 69, 2, 73, 2, 79, 3, 85, 4, 150, 240, 5, 65, - 163, 151, 35, 72, 4, 246, 242, 40, 66, 215, 22, 65, 2, 219, 134, 40, 73, - 6, 242, 135, 40, 65, 178, 98, 80, 191, 28, 72, 6, 138, 185, 40, 85, 170, - 77, 72, 3, 89, 4, 164, 200, 2, 6, 73, 78, 78, 89, 73, 73, 231, 189, 38, - 72, 4, 40, 4, 69, 32, 67, 79, 207, 158, 40, 73, 2, 197, 252, 39, 13, 78, - 83, 79, 78, 65, 78, 84, 32, 77, 79, 68, 73, 70, 4, 186, 235, 33, 69, 247, - 198, 4, 81, 4, 186, 138, 26, 65, 195, 223, 10, 85, 4, 154, 204, 27, 69, - 245, 177, 12, 12, 73, 83, 83, 73, 79, 78, 32, 84, 73, 67, 75, 69, 116, - 80, 5, 71, 69, 65, 78, 32, 213, 166, 34, 9, 82, 73, 65, 76, 32, 84, 82, + 72, 2, 82, 2, 86, 186, 2, 69, 2, 73, 2, 79, 3, 85, 4, 198, 249, 5, 65, + 143, 136, 36, 72, 4, 146, 237, 41, 66, 215, 22, 65, 2, 247, 128, 41, 73, + 6, 142, 130, 41, 65, 178, 98, 80, 191, 28, 72, 6, 166, 179, 41, 85, 170, + 77, 72, 3, 89, 4, 160, 205, 2, 6, 73, 78, 78, 89, 73, 73, 135, 179, 39, + 72, 4, 40, 4, 69, 32, 67, 79, 235, 152, 41, 73, 2, 225, 246, 40, 13, 78, + 83, 79, 78, 65, 78, 84, 32, 77, 79, 68, 73, 70, 4, 206, 168, 39, 81, 167, + 188, 1, 69, 4, 154, 249, 26, 65, 135, 229, 10, 85, 4, 138, 188, 28, 69, + 161, 188, 12, 12, 73, 83, 83, 73, 79, 78, 32, 84, 73, 67, 75, 69, 116, + 80, 5, 71, 69, 65, 78, 32, 177, 155, 35, 9, 82, 73, 65, 76, 32, 84, 82, 65, 77, 114, 136, 1, 3, 68, 82, 89, 0, 6, 76, 73, 81, 85, 73, 68, 60, 8, - 77, 69, 65, 83, 85, 82, 69, 32, 26, 87, 198, 173, 27, 78, 183, 144, 12, + 77, 69, 65, 83, 85, 82, 69, 32, 26, 87, 170, 157, 28, 78, 247, 151, 12, 67, 2, 153, 2, 11, 32, 77, 69, 65, 83, 85, 82, 69, 32, 70, 73, 4, 246, 1, 83, 31, 84, 14, 100, 6, 69, 73, 71, 72, 84, 32, 241, 1, 14, 79, 82, 68, 32, 83, 69, 80, 65, 82, 65, 84, 79, 82, 32, 10, 54, 70, 66, 83, 30, 84, 65, 5, 66, 65, 83, 69, 32, 4, 38, 73, 89, 5, 79, 85, 82, 84, 72, 2, 85, 3, 82, 83, 84, 2, 49, 4, 69, 67, 79, 78, 2, 21, 3, 72, 73, 82, 2, 11, 68, - 2, 25, 4, 32, 83, 85, 66, 2, 205, 228, 40, 2, 85, 78, 4, 174, 229, 39, + 2, 25, 4, 32, 83, 85, 66, 2, 233, 222, 41, 2, 85, 78, 4, 202, 223, 40, 76, 135, 75, 68, 130, 1, 140, 2, 22, 67, 79, 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, 32, 77, 69, 68, 73, 65, 76, 32, 88, 7, 76, 69, 84, 84, 69, 82, 32, 242, 1, 83, 168, 1, 11, 86, 79, 87, 69, 76, 32, 83, 73, - 71, 78, 32, 248, 242, 32, 8, 78, 85, 77, 66, 69, 82, 32, 84, 203, 147, 6, - 68, 6, 26, 76, 231, 251, 40, 82, 4, 192, 179, 40, 7, 73, 71, 65, 84, 73, - 78, 71, 219, 74, 65, 68, 154, 1, 65, 246, 158, 37, 68, 114, 84, 198, 208, - 1, 76, 226, 195, 1, 78, 126, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 138, + 71, 78, 32, 204, 229, 33, 8, 78, 85, 77, 66, 69, 82, 32, 84, 251, 151, 6, + 68, 6, 26, 76, 131, 246, 41, 82, 4, 220, 173, 41, 7, 73, 71, 65, 84, 73, + 78, 71, 219, 74, 65, 68, 154, 1, 65, 162, 148, 38, 68, 114, 84, 150, 210, + 1, 76, 130, 199, 1, 78, 126, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 138, 69, 72, 2, 77, 2, 82, 3, 83, 9, 45, 9, 76, 84, 69, 82, 78, 65, 84, 69, - 32, 6, 218, 249, 40, 66, 2, 71, 3, 84, 10, 60, 4, 73, 71, 78, 32, 241, - 178, 23, 5, 89, 77, 66, 79, 76, 8, 50, 83, 182, 245, 25, 75, 249, 145, - 10, 2, 82, 85, 4, 212, 248, 37, 4, 77, 65, 76, 76, 203, 177, 2, 69, 22, - 66, 65, 138, 163, 37, 85, 186, 202, 1, 73, 198, 140, 2, 69, 3, 79, 11, - 130, 250, 40, 65, 2, 73, 2, 77, 3, 87, 7, 11, 32, 4, 232, 218, 35, 3, 68, - 69, 80, 221, 205, 4, 5, 65, 82, 82, 73, 86, 152, 2, 212, 1, 4, 65, 82, + 32, 6, 246, 243, 41, 66, 2, 71, 3, 84, 10, 60, 4, 73, 71, 78, 32, 225, + 253, 23, 5, 89, 77, 66, 79, 76, 8, 50, 83, 174, 228, 26, 75, 173, 151, + 10, 2, 82, 85, 4, 244, 238, 38, 4, 77, 65, 76, 76, 199, 181, 2, 69, 22, + 66, 65, 182, 152, 38, 85, 138, 204, 1, 73, 230, 143, 2, 69, 3, 79, 11, + 158, 244, 41, 65, 2, 73, 2, 77, 3, 87, 7, 11, 32, 4, 156, 207, 36, 3, 68, + 69, 80, 197, 211, 4, 5, 65, 82, 82, 73, 86, 158, 2, 212, 1, 4, 65, 82, 77, 32, 48, 20, 67, 72, 69, 77, 73, 67, 65, 76, 32, 83, 89, 77, 66, 79, - 76, 32, 70, 79, 82, 32, 166, 28, 69, 60, 4, 73, 69, 78, 32, 208, 3, 2, - 76, 32, 82, 77, 109, 6, 84, 69, 82, 78, 65, 84, 4, 212, 131, 14, 3, 66, - 69, 76, 203, 129, 24, 67, 232, 1, 158, 2, 65, 246, 2, 66, 210, 1, 67, + 76, 32, 70, 79, 82, 32, 150, 29, 69, 60, 4, 73, 69, 78, 32, 208, 3, 2, + 76, 32, 82, 77, 109, 6, 84, 69, 82, 78, 65, 84, 4, 132, 168, 14, 3, 66, + 69, 76, 187, 211, 24, 67, 238, 1, 166, 2, 65, 246, 2, 66, 210, 1, 67, 138, 3, 68, 98, 71, 38, 72, 132, 1, 4, 73, 82, 79, 78, 82, 76, 74, 77, - 144, 1, 2, 78, 73, 34, 80, 176, 2, 3, 81, 85, 73, 74, 82, 146, 2, 83, - 210, 5, 84, 166, 1, 86, 200, 1, 2, 87, 65, 250, 145, 35, 85, 154, 220, 1, - 69, 194, 212, 1, 70, 219, 56, 79, 30, 194, 1, 76, 72, 3, 81, 85, 65, 204, - 8, 7, 78, 84, 73, 77, 79, 78, 89, 224, 157, 3, 3, 77, 65, 76, 240, 188, - 21, 3, 82, 83, 69, 128, 241, 13, 5, 85, 82, 73, 80, 73, 162, 136, 1, 83, - 183, 93, 73, 8, 224, 24, 2, 69, 77, 240, 196, 26, 4, 75, 65, 76, 73, 235, - 132, 14, 85, 10, 38, 32, 233, 252, 24, 3, 70, 79, 82, 8, 216, 7, 4, 86, - 73, 84, 65, 189, 179, 23, 4, 82, 69, 71, 73, 16, 148, 1, 7, 65, 84, 72, - 32, 79, 70, 32, 204, 6, 6, 73, 83, 77, 85, 84, 72, 144, 1, 4, 79, 82, 65, - 88, 164, 1, 4, 76, 65, 67, 75, 191, 181, 39, 82, 4, 166, 132, 17, 77, - 181, 219, 22, 5, 86, 65, 80, 79, 85, 28, 82, 65, 92, 6, 79, 80, 80, 69, - 82, 32, 34, 82, 253, 202, 39, 4, 73, 78, 78, 65, 6, 216, 143, 6, 2, 68, - 85, 192, 180, 33, 9, 80, 85, 84, 32, 77, 79, 82, 84, 85, 231, 28, 76, 4, - 230, 13, 65, 195, 190, 39, 79, 16, 72, 8, 79, 67, 85, 83, 32, 79, 70, 32, - 53, 6, 85, 67, 73, 66, 76, 69, 6, 228, 16, 5, 67, 79, 80, 80, 69, 223, - 181, 39, 73, 11, 11, 45, 8, 182, 237, 40, 50, 2, 51, 2, 52, 3, 53, 8, 44, - 2, 73, 83, 249, 238, 37, 3, 65, 89, 45, 6, 144, 2, 4, 83, 79, 76, 86, - 247, 238, 37, 84, 4, 222, 188, 30, 79, 247, 158, 10, 85, 8, 32, 4, 65, - 76, 70, 32, 47, 79, 4, 196, 219, 35, 2, 79, 85, 131, 211, 3, 68, 4, 200, - 137, 3, 4, 82, 83, 69, 32, 147, 169, 37, 85, 6, 56, 3, 32, 79, 82, 73, 7, - 45, 67, 79, 80, 80, 69, 82, 4, 135, 213, 26, 69, 4, 48, 3, 69, 65, 68, - 157, 225, 13, 3, 79, 68, 69, 2, 239, 252, 35, 32, 10, 120, 16, 69, 82, - 67, 85, 82, 89, 32, 83, 85, 66, 76, 73, 77, 65, 84, 69, 200, 209, 16, 4, - 65, 82, 67, 65, 167, 146, 22, 79, 7, 251, 231, 40, 45, 4, 158, 198, 39, - 84, 135, 120, 71, 14, 108, 11, 72, 73, 76, 79, 83, 79, 80, 72, 69, 82, - 83, 34, 79, 98, 85, 205, 160, 30, 6, 82, 69, 67, 73, 80, 73, 2, 209, 9, - 4, 32, 83, 85, 76, 6, 52, 4, 87, 68, 69, 82, 185, 172, 36, 3, 84, 32, 65, - 5, 225, 180, 39, 5, 69, 68, 32, 66, 82, 4, 176, 166, 34, 4, 84, 82, 69, - 70, 209, 174, 6, 3, 82, 73, 70, 4, 216, 212, 35, 5, 78, 84, 69, 83, 83, - 181, 247, 3, 4, 67, 75, 32, 76, 24, 58, 69, 201, 207, 26, 8, 79, 67, 75, - 32, 83, 65, 76, 84, 20, 68, 5, 71, 85, 76, 85, 83, 164, 7, 3, 65, 76, 71, - 215, 154, 26, 84, 15, 32, 4, 32, 79, 70, 32, 71, 45, 6, 216, 206, 26, 8, - 65, 78, 84, 73, 77, 79, 78, 89, 143, 238, 12, 73, 6, 214, 227, 40, 50, 2, - 51, 3, 52, 34, 164, 1, 2, 65, 76, 194, 1, 84, 142, 1, 85, 128, 218, 17, - 2, 80, 73, 132, 178, 12, 2, 73, 76, 182, 192, 9, 79, 169, 22, 11, 67, 69, - 80, 84, 69, 82, 32, 79, 70, 32, 74, 8, 58, 84, 193, 183, 39, 8, 45, 65, - 77, 77, 79, 78, 73, 65, 7, 25, 4, 32, 79, 70, 32, 4, 52, 8, 67, 79, 80, - 80, 69, 82, 32, 65, 231, 5, 65, 2, 133, 155, 30, 7, 78, 84, 73, 77, 79, - 78, 73, 6, 236, 3, 8, 65, 82, 82, 69, 68, 32, 84, 82, 157, 199, 26, 19, - 82, 65, 84, 85, 77, 32, 83, 85, 80, 69, 82, 32, 83, 84, 82, 65, 84, 85, - 77, 12, 44, 6, 66, 76, 73, 77, 65, 84, 155, 1, 76, 10, 44, 5, 69, 32, 79, - 70, 32, 247, 142, 40, 73, 8, 68, 8, 83, 65, 76, 84, 32, 79, 70, 32, 130, - 3, 65, 155, 198, 27, 67, 4, 254, 2, 65, 155, 198, 27, 67, 2, 163, 229, - 39, 70, 12, 68, 3, 65, 82, 84, 32, 2, 73, 78, 34, 82, 253, 236, 38, 2, - 85, 84, 4, 11, 65, 4, 207, 199, 26, 82, 4, 178, 190, 35, 67, 187, 49, 32, - 2, 177, 153, 40, 2, 73, 68, 14, 50, 73, 133, 181, 38, 6, 69, 82, 68, 73, - 71, 82, 12, 64, 5, 78, 69, 71, 65, 82, 137, 198, 26, 5, 84, 82, 73, 79, - 76, 9, 44, 5, 32, 79, 70, 32, 65, 167, 218, 40, 45, 2, 141, 174, 24, 3, - 78, 84, 73, 4, 138, 157, 40, 84, 239, 61, 88, 6, 38, 77, 238, 196, 39, - 70, 155, 121, 82, 2, 147, 176, 39, 66, 22, 104, 7, 77, 79, 78, 83, 84, - 69, 82, 138, 1, 83, 129, 241, 35, 10, 67, 82, 65, 66, 32, 83, 84, 69, 80, - 80, 11, 11, 32, 8, 88, 6, 67, 76, 79, 83, 69, 68, 0, 4, 79, 80, 69, 78, - 225, 210, 36, 4, 83, 84, 69, 80, 2, 197, 249, 37, 3, 32, 74, 65, 8, 60, - 6, 80, 73, 68, 69, 82, 32, 57, 5, 81, 85, 73, 68, 32, 4, 248, 178, 29, 5, - 67, 82, 79, 85, 67, 175, 250, 1, 83, 4, 56, 6, 67, 76, 79, 83, 69, 68, 1, - 4, 79, 80, 69, 78, 2, 249, 232, 27, 5, 32, 84, 69, 78, 84, 4, 134, 245, - 33, 69, 253, 184, 4, 11, 65, 82, 79, 85, 78, 68, 45, 80, 82, 79, 70, 9, - 49, 10, 79, 83, 84, 32, 69, 81, 85, 65, 76, 32, 6, 32, 2, 84, 79, 171, - 182, 32, 79, 5, 219, 255, 6, 32, 4, 136, 243, 10, 3, 73, 86, 69, 145, - 183, 28, 5, 69, 32, 79, 78, 69, 12, 162, 1, 80, 180, 191, 29, 6, 69, 82, - 73, 67, 65, 78, 204, 131, 6, 3, 66, 85, 76, 245, 254, 3, 16, 65, 76, 71, - 65, 77, 65, 84, 73, 79, 78, 32, 79, 82, 32, 67, 79, 6, 26, 72, 175, 128, - 37, 69, 4, 204, 242, 24, 3, 73, 84, 82, 255, 155, 15, 79, 194, 9, 92, 3, - 65, 84, 79, 182, 20, 71, 174, 1, 84, 190, 149, 25, 67, 242, 150, 12, 68, - 223, 142, 3, 75, 144, 9, 112, 17, 76, 73, 65, 78, 32, 72, 73, 69, 82, 79, - 71, 76, 89, 80, 72, 32, 65, 197, 201, 39, 5, 77, 73, 67, 65, 76, 142, 9, - 70, 48, 138, 4, 49, 198, 2, 50, 162, 3, 51, 174, 5, 52, 163, 3, 53, 222, - 1, 106, 50, 102, 52, 110, 54, 102, 57, 182, 7, 51, 222, 242, 11, 49, 226, - 146, 23, 48, 130, 2, 53, 2, 55, 3, 56, 22, 210, 189, 36, 54, 242, 145, 4, - 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 55, 2, 56, 3, 57, 28, 170, 187, - 12, 54, 198, 129, 24, 49, 2, 53, 242, 145, 4, 48, 2, 50, 2, 51, 2, 52, 2, - 55, 2, 56, 3, 57, 26, 130, 162, 12, 54, 242, 171, 28, 48, 2, 49, 2, 50, - 2, 51, 2, 52, 2, 53, 2, 55, 2, 56, 3, 57, 24, 158, 187, 36, 55, 2, 56, - 242, 145, 4, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 3, 57, 232, 1, - 98, 48, 114, 49, 174, 166, 12, 50, 2, 51, 138, 230, 22, 52, 2, 53, 2, 54, - 2, 55, 2, 56, 3, 57, 42, 210, 159, 12, 52, 2, 55, 190, 24, 53, 198, 129, - 24, 48, 2, 49, 2, 50, 242, 145, 4, 51, 2, 54, 2, 56, 3, 57, 26, 158, 183, - 12, 48, 198, 129, 24, 53, 242, 145, 4, 49, 2, 50, 2, 51, 2, 52, 2, 54, 2, - 55, 2, 56, 3, 57, 222, 1, 102, 48, 110, 49, 102, 57, 210, 1, 56, 218, - 148, 12, 50, 2, 54, 230, 242, 22, 51, 2, 52, 2, 53, 3, 55, 28, 198, 181, - 12, 50, 198, 129, 24, 55, 2, 57, 242, 145, 4, 48, 2, 49, 2, 51, 2, 52, 2, - 53, 2, 54, 3, 56, 24, 158, 182, 36, 53, 2, 54, 242, 145, 4, 48, 2, 49, 2, - 50, 2, 51, 2, 52, 2, 55, 2, 56, 3, 57, 24, 186, 181, 36, 52, 2, 57, 242, - 145, 4, 48, 2, 49, 2, 50, 2, 51, 2, 53, 2, 54, 2, 55, 3, 56, 228, 1, 102, - 48, 2, 50, 2, 53, 102, 51, 110, 54, 102, 56, 162, 1, 57, 142, 253, 11, - 55, 222, 134, 23, 49, 3, 52, 22, 234, 179, 36, 57, 242, 145, 4, 48, 2, - 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, 56, 30, 134, 153, 12, - 54, 130, 197, 8, 50, 242, 230, 19, 48, 2, 49, 2, 51, 2, 52, 2, 53, 2, 55, - 2, 56, 3, 57, 24, 154, 178, 36, 52, 2, 56, 242, 145, 4, 48, 2, 49, 2, 50, - 2, 51, 2, 53, 2, 54, 2, 55, 3, 57, 26, 98, 51, 214, 176, 36, 49, 2, 54, - 242, 145, 4, 48, 2, 50, 2, 52, 2, 53, 2, 55, 2, 56, 3, 57, 4, 196, 142, - 21, 6, 32, 82, 65, 32, 79, 82, 255, 179, 19, 65, 20, 180, 151, 40, 3, 51, - 32, 69, 210, 42, 48, 2, 49, 2, 50, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, - 57, 202, 1, 102, 49, 210, 1, 53, 178, 229, 20, 57, 146, 155, 14, 48, 2, - 50, 2, 51, 2, 52, 2, 54, 2, 55, 3, 56, 22, 90, 48, 214, 191, 40, 49, 2, - 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 4, 60, 6, 32, 66, - 69, 71, 73, 78, 1, 5, 65, 32, 69, 78, 68, 2, 189, 193, 16, 8, 32, 76, 79, - 71, 79, 71, 82, 65, 24, 238, 172, 36, 48, 2, 55, 242, 145, 4, 49, 2, 50, - 2, 51, 2, 52, 2, 53, 2, 54, 2, 56, 3, 57, 60, 150, 151, 33, 51, 198, 230, - 1, 48, 130, 2, 49, 3, 50, 14, 96, 2, 76, 69, 182, 176, 2, 85, 180, 183, - 32, 2, 83, 84, 130, 239, 3, 69, 217, 168, 1, 2, 82, 89, 7, 33, 6, 32, 87, - 73, 84, 72, 32, 4, 178, 138, 32, 83, 135, 195, 4, 85, 31, 76, 4, 69, 78, - 78, 65, 41, 11, 73, 67, 76, 79, 67, 75, 87, 73, 83, 69, 32, 5, 177, 143, - 37, 5, 32, 87, 73, 84, 72, 24, 90, 84, 162, 139, 7, 67, 58, 68, 122, 71, - 138, 4, 79, 157, 151, 28, 5, 73, 78, 84, 69, 71, 12, 84, 15, 82, 73, 65, - 78, 71, 76, 69, 45, 72, 69, 65, 68, 69, 68, 32, 223, 143, 7, 79, 10, 112, - 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, 12, 6, 66, 79, 84, 84, 79, 77, 0, 3, - 84, 79, 80, 131, 143, 7, 79, 2, 11, 84, 2, 133, 219, 37, 7, 32, 85, 45, + 196, 1, 2, 78, 73, 32, 3, 79, 73, 76, 30, 80, 176, 2, 3, 81, 85, 73, 74, + 82, 142, 2, 83, 238, 5, 84, 166, 1, 86, 200, 1, 2, 87, 65, 186, 133, 36, + 85, 150, 221, 1, 69, 147, 214, 1, 70, 30, 194, 1, 76, 72, 3, 81, 85, 65, + 204, 8, 7, 78, 84, 73, 77, 79, 78, 89, 128, 165, 3, 3, 77, 65, 76, 204, + 142, 22, 3, 82, 83, 69, 248, 142, 14, 5, 85, 82, 73, 80, 73, 194, 139, 1, + 83, 183, 93, 73, 8, 200, 25, 2, 69, 77, 224, 178, 27, 4, 75, 65, 76, 73, + 167, 144, 14, 85, 10, 38, 32, 133, 229, 25, 3, 70, 79, 82, 8, 216, 7, 4, + 86, 73, 84, 65, 165, 254, 23, 4, 82, 69, 71, 73, 16, 148, 1, 7, 65, 84, + 72, 32, 79, 70, 32, 204, 6, 6, 73, 83, 77, 85, 84, 72, 136, 1, 4, 79, 82, + 65, 88, 252, 1, 4, 76, 65, 67, 75, 195, 174, 40, 82, 4, 214, 168, 17, 77, + 153, 177, 23, 5, 86, 65, 80, 79, 85, 28, 82, 65, 92, 6, 79, 80, 80, 69, + 82, 32, 34, 82, 209, 196, 40, 4, 73, 78, 78, 65, 6, 252, 152, 6, 2, 68, + 85, 240, 164, 34, 9, 80, 85, 84, 32, 77, 79, 82, 84, 85, 167, 29, 76, 4, + 206, 14, 65, 175, 183, 40, 79, 16, 72, 8, 79, 67, 85, 83, 32, 79, 70, 32, + 53, 6, 85, 67, 73, 66, 76, 69, 6, 204, 17, 5, 67, 79, 80, 80, 69, 203, + 174, 40, 73, 11, 11, 45, 8, 202, 231, 41, 50, 2, 51, 2, 52, 3, 53, 8, 44, + 2, 73, 83, 145, 229, 38, 3, 65, 89, 45, 6, 144, 2, 4, 83, 79, 76, 86, + 143, 229, 38, 84, 4, 170, 175, 31, 79, 191, 166, 10, 85, 8, 32, 4, 65, + 76, 70, 32, 47, 79, 4, 232, 207, 36, 2, 79, 85, 239, 213, 3, 68, 4, 232, + 144, 3, 4, 82, 83, 69, 32, 135, 156, 38, 85, 6, 56, 3, 32, 79, 82, 73, 7, + 45, 67, 79, 80, 80, 69, 82, 4, 223, 195, 27, 69, 4, 48, 3, 69, 65, 68, + 189, 133, 14, 3, 79, 68, 69, 2, 151, 241, 36, 32, 12, 112, 16, 69, 82, + 67, 85, 82, 89, 32, 83, 85, 66, 76, 73, 77, 65, 84, 69, 22, 79, 189, 245, + 16, 4, 65, 82, 67, 65, 7, 151, 226, 41, 45, 4, 212, 247, 37, 6, 79, 78, + 45, 74, 85, 80, 147, 227, 1, 78, 4, 190, 191, 40, 84, 199, 120, 71, 5, + 193, 153, 21, 2, 32, 73, 14, 108, 11, 72, 73, 76, 79, 83, 79, 80, 72, 69, + 82, 83, 34, 79, 98, 85, 201, 146, 31, 6, 82, 69, 67, 73, 80, 73, 2, 233, + 9, 4, 32, 83, 85, 76, 6, 52, 4, 87, 68, 69, 82, 145, 160, 37, 3, 84, 32, + 65, 5, 229, 173, 40, 5, 69, 68, 32, 66, 82, 4, 180, 154, 35, 4, 84, 82, + 69, 70, 145, 180, 6, 3, 82, 73, 70, 4, 172, 200, 36, 5, 78, 84, 69, 83, + 83, 165, 253, 3, 4, 67, 75, 32, 76, 24, 58, 69, 209, 189, 27, 8, 79, 67, + 75, 32, 83, 65, 76, 84, 20, 68, 5, 71, 85, 76, 85, 83, 188, 7, 3, 65, 76, + 71, 199, 136, 27, 84, 15, 32, 4, 32, 79, 70, 32, 67, 45, 6, 132, 153, 21, + 7, 65, 78, 84, 73, 77, 79, 78, 231, 156, 19, 73, 6, 158, 221, 41, 50, 2, + 51, 3, 52, 36, 164, 1, 2, 65, 76, 222, 1, 84, 142, 1, 85, 208, 128, 18, + 2, 80, 73, 224, 251, 12, 2, 73, 76, 182, 201, 9, 79, 169, 22, 11, 67, 69, + 80, 84, 69, 82, 32, 79, 70, 32, 74, 10, 58, 84, 201, 176, 40, 8, 45, 65, + 77, 77, 79, 78, 73, 65, 9, 25, 4, 32, 79, 70, 32, 6, 80, 8, 67, 79, 80, + 80, 69, 82, 32, 65, 230, 5, 65, 129, 137, 40, 3, 84, 65, 82, 2, 233, 140, + 31, 7, 78, 84, 73, 77, 79, 78, 73, 6, 236, 3, 8, 65, 82, 82, 69, 68, 32, + 84, 82, 141, 181, 27, 19, 82, 65, 84, 85, 77, 32, 83, 85, 80, 69, 82, 32, + 83, 84, 82, 65, 84, 85, 77, 12, 44, 6, 66, 76, 73, 77, 65, 84, 155, 1, + 76, 10, 44, 5, 69, 32, 79, 70, 32, 163, 136, 41, 73, 8, 68, 8, 83, 65, + 76, 84, 32, 79, 70, 32, 130, 3, 65, 155, 181, 28, 67, 4, 254, 2, 65, 155, + 181, 28, 67, 2, 207, 222, 40, 70, 12, 68, 3, 65, 82, 84, 32, 2, 73, 78, + 34, 82, 145, 227, 39, 2, 85, 84, 4, 11, 65, 4, 191, 181, 27, 82, 4, 246, + 177, 36, 67, 183, 49, 32, 2, 221, 146, 41, 2, 73, 68, 14, 50, 73, 253, + 170, 39, 6, 69, 82, 68, 73, 71, 82, 12, 64, 5, 78, 69, 71, 65, 82, 249, + 179, 27, 5, 84, 82, 73, 79, 76, 9, 44, 5, 32, 79, 70, 32, 65, 211, 211, + 41, 45, 2, 145, 132, 25, 3, 78, 84, 73, 4, 182, 150, 41, 84, 239, 61, 88, + 6, 38, 77, 154, 190, 40, 70, 155, 121, 82, 2, 255, 168, 40, 66, 22, 104, + 7, 77, 79, 78, 83, 84, 69, 82, 138, 1, 83, 193, 228, 36, 10, 67, 82, 65, + 66, 32, 83, 84, 69, 80, 80, 11, 11, 32, 8, 88, 6, 67, 76, 79, 83, 69, 68, + 0, 4, 79, 80, 69, 78, 193, 198, 37, 4, 83, 84, 69, 80, 2, 245, 238, 38, + 3, 32, 74, 65, 8, 60, 6, 80, 73, 68, 69, 82, 32, 57, 5, 81, 85, 73, 68, + 32, 4, 132, 163, 30, 5, 67, 82, 79, 85, 67, 147, 252, 1, 83, 4, 56, 6, + 67, 76, 79, 83, 69, 68, 1, 4, 79, 80, 69, 78, 2, 253, 215, 28, 5, 32, 84, + 69, 78, 84, 4, 242, 232, 34, 69, 201, 186, 4, 11, 65, 82, 79, 85, 78, 68, + 45, 80, 82, 79, 70, 9, 49, 10, 79, 83, 84, 32, 69, 81, 85, 65, 76, 32, 6, + 32, 2, 84, 79, 135, 168, 33, 79, 5, 135, 138, 7, 32, 4, 140, 149, 11, 3, + 73, 86, 69, 249, 141, 29, 5, 69, 32, 79, 78, 69, 12, 162, 1, 80, 232, + 175, 30, 6, 69, 82, 73, 67, 65, 78, 212, 134, 6, 3, 66, 85, 76, 229, 132, + 4, 16, 65, 76, 71, 65, 77, 65, 84, 73, 79, 78, 32, 79, 82, 32, 67, 79, 6, + 26, 72, 235, 244, 37, 69, 4, 216, 221, 25, 3, 73, 84, 82, 159, 170, 15, + 79, 196, 9, 92, 3, 65, 84, 79, 182, 20, 71, 214, 1, 84, 246, 130, 26, 67, + 194, 158, 12, 68, 219, 146, 3, 75, 144, 9, 112, 17, 76, 73, 65, 78, 32, + 72, 73, 69, 82, 79, 71, 76, 89, 80, 72, 32, 65, 241, 194, 40, 5, 77, 73, + 67, 65, 76, 142, 9, 70, 48, 138, 4, 49, 198, 2, 50, 162, 3, 51, 174, 5, + 52, 163, 3, 53, 222, 1, 106, 50, 102, 52, 110, 54, 102, 57, 182, 7, 51, + 138, 150, 12, 49, 246, 226, 23, 48, 130, 2, 53, 2, 55, 3, 56, 22, 134, + 177, 37, 54, 234, 151, 4, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 55, + 2, 56, 3, 57, 28, 214, 222, 12, 54, 206, 209, 24, 49, 2, 53, 234, 151, 4, + 48, 2, 50, 2, 51, 2, 52, 2, 55, 2, 56, 3, 57, 26, 174, 197, 12, 54, 242, + 129, 29, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 55, 2, 56, 3, 57, 24, + 210, 174, 37, 55, 2, 56, 234, 151, 4, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, + 53, 2, 54, 3, 57, 232, 1, 98, 48, 114, 49, 218, 201, 12, 50, 2, 51, 158, + 182, 23, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 42, 254, 194, 12, 52, 2, + 55, 190, 24, 53, 206, 209, 24, 48, 2, 49, 2, 50, 234, 151, 4, 51, 2, 54, + 2, 56, 3, 57, 26, 202, 218, 12, 48, 206, 209, 24, 53, 234, 151, 4, 49, 2, + 50, 2, 51, 2, 52, 2, 54, 2, 55, 2, 56, 3, 57, 222, 1, 102, 48, 110, 49, + 102, 57, 210, 1, 56, 134, 184, 12, 50, 2, 54, 250, 194, 23, 51, 2, 52, 2, + 53, 3, 55, 28, 242, 216, 12, 50, 206, 209, 24, 55, 2, 57, 234, 151, 4, + 48, 2, 49, 2, 51, 2, 52, 2, 53, 2, 54, 3, 56, 24, 210, 169, 37, 53, 2, + 54, 234, 151, 4, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 55, 2, 56, 3, 57, 24, + 238, 168, 37, 52, 2, 57, 234, 151, 4, 48, 2, 49, 2, 50, 2, 51, 2, 53, 2, + 54, 2, 55, 3, 56, 228, 1, 102, 48, 2, 50, 2, 53, 102, 51, 110, 54, 102, + 56, 162, 1, 57, 186, 160, 12, 55, 242, 214, 23, 49, 3, 52, 22, 158, 167, + 37, 57, 234, 151, 4, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, + 3, 56, 30, 178, 188, 12, 54, 234, 232, 8, 50, 138, 153, 20, 48, 2, 49, 2, + 51, 2, 52, 2, 53, 2, 55, 2, 56, 3, 57, 24, 206, 165, 37, 52, 2, 56, 234, + 151, 4, 48, 2, 49, 2, 50, 2, 51, 2, 53, 2, 54, 2, 55, 3, 57, 26, 98, 51, + 138, 164, 37, 49, 2, 54, 234, 151, 4, 48, 2, 50, 2, 52, 2, 53, 2, 55, 2, + 56, 3, 57, 4, 216, 213, 21, 6, 32, 82, 65, 32, 79, 82, 151, 230, 19, 65, + 20, 224, 144, 41, 3, 51, 32, 69, 210, 42, 48, 2, 49, 2, 50, 2, 52, 2, 53, + 2, 54, 2, 55, 2, 56, 3, 57, 202, 1, 102, 49, 210, 1, 53, 198, 172, 21, + 57, 190, 199, 14, 48, 2, 50, 2, 51, 2, 52, 2, 54, 2, 55, 3, 56, 22, 90, + 48, 130, 185, 41, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, + 57, 4, 60, 6, 32, 66, 69, 71, 73, 78, 1, 5, 65, 32, 69, 78, 68, 2, 133, + 229, 16, 8, 32, 76, 79, 71, 79, 71, 82, 65, 24, 162, 160, 37, 48, 2, 55, + 234, 151, 4, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 56, 3, 57, 60, + 138, 139, 34, 51, 146, 230, 1, 48, 130, 2, 49, 3, 50, 16, 96, 2, 76, 69, + 238, 182, 2, 85, 200, 164, 33, 2, 83, 84, 202, 241, 3, 69, 241, 171, 1, + 2, 82, 89, 9, 11, 32, 6, 60, 5, 87, 73, 84, 72, 32, 193, 225, 27, 4, 79, + 80, 69, 78, 4, 222, 251, 32, 83, 239, 197, 4, 85, 31, 76, 4, 69, 78, 78, + 65, 41, 11, 73, 67, 76, 79, 67, 75, 87, 73, 83, 69, 32, 5, 173, 132, 38, + 5, 32, 87, 73, 84, 72, 24, 90, 84, 166, 149, 7, 67, 58, 68, 122, 71, 138, + 4, 79, 157, 128, 29, 5, 73, 78, 84, 69, 71, 12, 84, 15, 82, 73, 65, 78, + 71, 76, 69, 45, 72, 69, 65, 68, 69, 68, 32, 227, 153, 7, 79, 10, 112, 3, + 76, 69, 70, 0, 4, 82, 73, 71, 72, 12, 6, 66, 79, 84, 84, 79, 77, 0, 3, + 84, 79, 80, 135, 153, 7, 79, 2, 11, 84, 2, 141, 208, 38, 7, 32, 85, 45, 83, 72, 65, 80, 160, 1, 128, 1, 20, 76, 32, 70, 85, 78, 67, 84, 73, 79, - 78, 65, 76, 32, 83, 89, 77, 66, 79, 76, 32, 206, 15, 79, 38, 80, 199, - 167, 40, 67, 140, 1, 222, 2, 67, 186, 1, 68, 190, 2, 73, 44, 4, 65, 76, + 78, 65, 76, 32, 83, 89, 77, 66, 79, 76, 32, 206, 15, 79, 38, 80, 203, + 160, 41, 67, 140, 1, 222, 2, 67, 186, 1, 68, 190, 2, 73, 44, 4, 65, 76, 80, 72, 0, 4, 79, 77, 69, 71, 32, 4, 74, 79, 84, 32, 36, 4, 76, 69, 70, 84, 68, 2, 81, 85, 218, 3, 82, 54, 83, 92, 4, 69, 80, 83, 73, 32, 6, 66, - 65, 67, 75, 83, 76, 76, 2, 85, 80, 248, 161, 16, 12, 71, 82, 69, 65, 84, - 69, 82, 45, 84, 72, 65, 78, 0, 5, 84, 73, 76, 68, 69, 139, 160, 20, 90, - 14, 64, 6, 73, 82, 67, 76, 69, 32, 185, 144, 39, 4, 79, 77, 77, 65, 12, - 80, 2, 83, 84, 166, 230, 19, 68, 150, 133, 6, 66, 254, 216, 10, 85, 207, - 158, 3, 74, 4, 250, 140, 39, 73, 227, 109, 65, 22, 76, 2, 69, 76, 120, 3, - 79, 87, 78, 253, 145, 32, 6, 73, 65, 77, 79, 78, 68, 10, 30, 32, 53, 3, - 84, 65, 32, 6, 146, 229, 19, 68, 194, 229, 16, 84, 131, 191, 1, 83, 4, - 238, 194, 36, 85, 179, 198, 1, 83, 10, 22, 32, 167, 9, 87, 8, 52, 5, 84, - 65, 67, 75, 32, 182, 1, 83, 227, 6, 67, 4, 250, 193, 36, 85, 207, 158, 3, - 74, 6, 40, 2, 79, 84, 237, 159, 32, 2, 45, 66, 4, 11, 65, 5, 219, 144, - 32, 32, 4, 250, 226, 19, 68, 147, 222, 16, 85, 4, 28, 2, 32, 83, 187, 7, - 87, 2, 233, 134, 38, 4, 72, 79, 69, 32, 46, 44, 2, 65, 68, 133, 3, 4, 79, + 65, 67, 75, 83, 76, 76, 2, 85, 80, 152, 197, 16, 12, 71, 82, 69, 65, 84, + 69, 82, 45, 84, 72, 65, 78, 0, 5, 84, 73, 76, 68, 69, 255, 240, 20, 90, + 14, 64, 6, 73, 82, 67, 76, 69, 32, 253, 136, 40, 4, 79, 77, 77, 65, 12, + 80, 2, 83, 84, 138, 162, 20, 68, 250, 182, 6, 66, 202, 223, 10, 85, 191, + 163, 3, 74, 4, 190, 133, 40, 73, 163, 110, 65, 22, 76, 2, 69, 76, 120, 3, + 79, 87, 78, 177, 131, 33, 6, 73, 65, 77, 79, 78, 68, 10, 30, 32, 53, 3, + 84, 65, 32, 6, 246, 160, 20, 68, 242, 157, 17, 84, 255, 191, 1, 83, 4, + 130, 183, 37, 85, 175, 199, 1, 83, 10, 22, 32, 167, 9, 87, 8, 52, 5, 84, + 65, 67, 75, 32, 182, 1, 83, 227, 6, 67, 4, 142, 182, 37, 85, 191, 163, 3, + 74, 6, 40, 2, 79, 84, 169, 145, 33, 2, 45, 66, 4, 11, 65, 5, 143, 130, + 33, 32, 4, 222, 158, 20, 68, 195, 150, 17, 85, 4, 28, 2, 32, 83, 187, 7, + 87, 2, 249, 251, 38, 4, 72, 79, 69, 32, 46, 44, 2, 65, 68, 133, 3, 4, 79, 84, 69, 32, 43, 11, 32, 40, 178, 1, 67, 38, 68, 92, 2, 85, 80, 36, 2, 76, - 69, 210, 208, 6, 81, 228, 217, 13, 3, 78, 79, 84, 22, 69, 206, 185, 5, - 66, 174, 163, 7, 83, 226, 142, 5, 71, 250, 115, 82, 199, 81, 74, 4, 170, - 217, 38, 73, 151, 132, 1, 79, 12, 54, 73, 36, 3, 79, 87, 78, 149, 240, - 36, 2, 69, 76, 4, 254, 250, 31, 86, 255, 242, 6, 65, 4, 230, 138, 4, 32, - 135, 128, 35, 87, 4, 218, 150, 38, 83, 215, 115, 70, 4, 230, 172, 12, 81, - 139, 144, 24, 85, 4, 184, 3, 5, 73, 71, 72, 84, 87, 163, 137, 40, 72, 10, - 88, 5, 69, 77, 73, 67, 79, 34, 76, 34, 84, 245, 170, 12, 7, 81, 85, 73, - 83, 72, 32, 81, 2, 233, 138, 32, 3, 76, 79, 78, 2, 201, 134, 39, 3, 65, - 83, 72, 4, 160, 162, 16, 2, 65, 82, 227, 169, 7, 73, 12, 22, 32, 171, 1, - 87, 10, 78, 67, 36, 5, 84, 65, 67, 75, 32, 145, 216, 39, 6, 83, 72, 79, - 69, 32, 74, 2, 129, 203, 23, 4, 65, 82, 69, 84, 6, 178, 219, 19, 68, 158, - 155, 17, 79, 195, 225, 2, 74, 2, 145, 135, 37, 6, 65, 82, 68, 83, 32, 86, - 4, 234, 128, 34, 83, 135, 215, 5, 76, 14, 26, 76, 93, 2, 82, 79, 4, 216, - 184, 26, 14, 73, 67, 65, 84, 73, 79, 78, 32, 80, 82, 79, 71, 82, 65, 139, - 217, 12, 69, 10, 112, 9, 88, 73, 77, 65, 84, 69, 76, 89, 32, 161, 137, - 40, 13, 65, 67, 72, 69, 83, 32, 84, 72, 69, 32, 76, 73, 77, 8, 76, 6, 69, - 81, 85, 65, 76, 32, 137, 144, 25, 7, 66, 85, 84, 32, 78, 79, 84, 6, 32, - 2, 84, 79, 235, 133, 32, 79, 5, 161, 185, 26, 13, 32, 79, 82, 32, 84, 72, - 69, 32, 73, 77, 65, 71, 69, 192, 23, 148, 1, 4, 65, 66, 73, 67, 240, 131, - 2, 7, 77, 69, 78, 73, 65, 78, 32, 224, 12, 3, 82, 79, 87, 228, 3, 2, 84, - 73, 202, 248, 36, 73, 135, 150, 1, 67, 238, 21, 54, 32, 173, 130, 2, 7, - 45, 73, 78, 68, 73, 67, 32, 210, 21, 150, 3, 66, 134, 1, 67, 238, 1, 68, - 138, 3, 69, 186, 1, 70, 212, 1, 2, 72, 65, 104, 5, 75, 65, 83, 82, 65, - 86, 76, 212, 180, 1, 2, 77, 65, 204, 18, 7, 78, 85, 77, 66, 69, 82, 32, - 36, 5, 79, 80, 69, 78, 32, 82, 80, 238, 1, 82, 208, 2, 6, 73, 78, 86, 69, - 82, 84, 98, 83, 146, 33, 84, 202, 4, 86, 228, 194, 17, 9, 87, 65, 86, 89, - 32, 72, 65, 77, 90, 154, 138, 18, 81, 197, 198, 1, 6, 90, 87, 65, 82, 65, - 75, 4, 216, 214, 1, 7, 65, 83, 69, 76, 73, 78, 69, 157, 189, 37, 17, 73, - 66, 76, 73, 67, 65, 76, 32, 69, 78, 68, 32, 79, 70, 32, 86, 69, 16, 44, - 2, 79, 77, 81, 5, 85, 82, 76, 89, 32, 4, 192, 181, 19, 11, 66, 73, 78, - 73, 78, 71, 32, 65, 76, 69, 70, 251, 229, 20, 77, 12, 72, 4, 68, 65, 77, - 77, 0, 4, 70, 65, 84, 72, 1, 4, 75, 65, 83, 82, 4, 11, 65, 5, 175, 208, - 38, 84, 26, 158, 1, 65, 108, 5, 79, 85, 66, 76, 69, 216, 234, 23, 5, 69, - 67, 73, 77, 65, 201, 193, 9, 16, 73, 83, 80, 85, 84, 69, 68, 32, 69, 78, - 68, 32, 79, 70, 32, 65, 14, 36, 3, 77, 77, 65, 155, 207, 33, 84, 13, 22, - 32, 219, 5, 84, 6, 242, 238, 1, 73, 54, 77, 175, 133, 37, 87, 8, 22, 32, - 191, 4, 68, 6, 184, 210, 1, 17, 82, 73, 71, 72, 84, 32, 65, 82, 82, 79, - 87, 72, 69, 65, 68, 32, 65, 191, 30, 86, 8, 88, 12, 77, 80, 84, 89, 32, - 67, 69, 78, 84, 82, 69, 32, 57, 6, 78, 68, 32, 79, 70, 32, 4, 192, 195, - 37, 4, 72, 73, 71, 72, 1, 3, 76, 79, 87, 4, 134, 251, 29, 84, 139, 175, - 3, 65, 22, 84, 4, 65, 84, 72, 65, 166, 222, 1, 79, 148, 232, 4, 3, 73, - 86, 69, 195, 251, 30, 85, 17, 22, 32, 139, 2, 84, 10, 52, 5, 87, 73, 84, - 72, 32, 238, 234, 1, 73, 55, 77, 6, 222, 195, 38, 84, 166, 82, 68, 203, - 47, 82, 6, 72, 13, 76, 70, 32, 77, 65, 68, 68, 65, 32, 79, 86, 69, 82, - 235, 16, 77, 2, 221, 226, 17, 2, 32, 77, 13, 18, 32, 43, 84, 6, 166, 72, - 87, 158, 161, 1, 73, 55, 77, 4, 253, 82, 2, 65, 78, 174, 16, 84, 5, 65, - 82, 71, 69, 32, 146, 1, 69, 133, 91, 8, 73, 71, 65, 84, 85, 82, 69, 32, - 8, 64, 10, 82, 79, 85, 78, 68, 32, 68, 79, 84, 32, 179, 139, 11, 67, 6, - 148, 139, 11, 6, 73, 78, 83, 73, 68, 69, 198, 230, 26, 66, 131, 165, 1, - 65, 136, 8, 80, 5, 84, 84, 69, 82, 32, 137, 170, 7, 9, 70, 84, 32, 65, - 82, 82, 79, 87, 72, 132, 8, 210, 2, 65, 240, 10, 2, 66, 69, 150, 4, 68, - 186, 5, 70, 246, 4, 71, 226, 2, 72, 156, 9, 2, 74, 69, 158, 1, 75, 138, - 5, 76, 226, 2, 77, 154, 1, 78, 160, 3, 3, 80, 69, 72, 176, 1, 3, 81, 65, - 70, 214, 1, 82, 234, 3, 83, 162, 9, 84, 214, 8, 85, 148, 2, 2, 86, 69, - 28, 3, 87, 65, 87, 202, 1, 89, 246, 3, 79, 140, 3, 2, 90, 65, 31, 69, - 112, 92, 7, 70, 82, 73, 67, 65, 78, 32, 92, 2, 73, 78, 144, 2, 3, 76, 69, - 70, 131, 140, 40, 69, 8, 52, 3, 81, 65, 70, 218, 152, 33, 70, 183, 203, - 3, 78, 5, 153, 64, 5, 32, 87, 73, 84, 72, 21, 11, 32, 18, 72, 6, 87, 73, - 84, 72, 32, 84, 242, 172, 1, 70, 202, 43, 73, 211, 9, 77, 10, 60, 10, 72, - 82, 69, 69, 32, 68, 79, 84, 83, 32, 187, 54, 87, 6, 168, 146, 15, 17, 80, - 79, 73, 78, 84, 73, 78, 71, 32, 68, 79, 87, 78, 87, 65, 82, 68, 226, 216, - 22, 66, 131, 165, 1, 65, 83, 11, 32, 80, 70, 87, 228, 44, 6, 77, 65, 75, - 83, 85, 82, 130, 126, 70, 231, 52, 73, 70, 48, 4, 73, 84, 72, 32, 177, - 44, 3, 65, 83, 76, 64, 192, 2, 9, 65, 84, 84, 65, 67, 72, 69, 68, 32, - 220, 1, 19, 82, 73, 71, 72, 84, 32, 77, 73, 68, 68, 76, 69, 32, 83, 84, - 82, 79, 75, 69, 188, 1, 6, 72, 65, 77, 90, 65, 32, 44, 8, 87, 65, 86, 89, - 32, 72, 65, 77, 214, 70, 69, 204, 1, 4, 77, 65, 68, 68, 232, 203, 36, 9, - 76, 69, 70, 84, 32, 77, 73, 68, 68, 159, 240, 1, 68, 28, 204, 1, 17, 66, - 79, 84, 84, 79, 77, 32, 82, 73, 71, 72, 84, 32, 75, 65, 83, 82, 0, 14, - 84, 79, 80, 32, 82, 73, 71, 72, 84, 32, 70, 65, 84, 72, 94, 82, 56, 3, - 76, 69, 70, 130, 214, 1, 75, 195, 165, 32, 70, 6, 11, 65, 7, 29, 5, 32, - 65, 78, 68, 32, 4, 196, 193, 19, 3, 76, 69, 70, 167, 196, 19, 68, 8, 52, - 3, 73, 71, 72, 213, 227, 1, 4, 79, 85, 78, 68, 4, 17, 2, 84, 32, 4, 130, - 189, 1, 82, 219, 37, 72, 12, 234, 72, 65, 37, 5, 66, 69, 76, 79, 87, 4, - 223, 207, 37, 90, 50, 22, 72, 179, 64, 69, 41, 22, 32, 155, 64, 69, 28, - 68, 5, 87, 73, 84, 72, 32, 158, 163, 1, 70, 202, 43, 73, 211, 9, 77, 20, - 116, 6, 83, 77, 65, 76, 76, 32, 34, 84, 254, 18, 73, 160, 33, 10, 68, 79, - 84, 32, 66, 69, 76, 79, 87, 32, 135, 21, 72, 6, 150, 39, 77, 231, 212, - 23, 86, 8, 88, 10, 72, 82, 69, 69, 32, 68, 79, 84, 83, 32, 233, 48, 7, - 87, 79, 32, 68, 79, 84, 83, 6, 144, 1, 22, 80, 79, 73, 78, 84, 73, 78, - 71, 32, 85, 80, 87, 65, 82, 68, 83, 32, 66, 69, 76, 79, 87, 201, 54, 8, - 72, 79, 82, 73, 90, 79, 78, 84, 5, 179, 133, 15, 32, 78, 90, 65, 136, 4, - 2, 68, 65, 40, 7, 79, 84, 76, 69, 83, 83, 32, 250, 27, 89, 147, 26, 85, - 44, 34, 76, 254, 3, 72, 147, 46, 68, 27, 11, 32, 24, 56, 5, 87, 73, 84, - 72, 32, 186, 158, 1, 70, 231, 52, 73, 20, 108, 9, 73, 78, 86, 69, 82, 84, - 69, 68, 32, 34, 84, 168, 1, 3, 68, 79, 84, 222, 136, 12, 70, 235, 162, - 27, 82, 4, 238, 14, 83, 163, 239, 39, 86, 8, 132, 1, 10, 72, 82, 69, 69, - 32, 68, 79, 84, 83, 32, 33, 18, 87, 79, 32, 68, 79, 84, 83, 32, 86, 69, - 82, 84, 73, 67, 65, 76, 76, 89, 4, 226, 54, 65, 155, 164, 37, 66, 4, 33, - 6, 32, 66, 69, 76, 79, 87, 5, 217, 178, 15, 11, 32, 65, 78, 68, 32, 83, - 77, 65, 76, 76, 32, 12, 22, 72, 195, 63, 76, 6, 151, 54, 65, 6, 222, 133, - 33, 66, 2, 70, 175, 244, 5, 81, 44, 60, 8, 65, 82, 83, 73, 32, 89, 69, - 72, 169, 2, 2, 69, 72, 23, 11, 32, 20, 68, 5, 87, 73, 84, 72, 32, 182, - 153, 1, 70, 202, 43, 73, 211, 9, 77, 12, 144, 1, 28, 69, 88, 84, 69, 78, - 68, 69, 68, 32, 65, 82, 65, 66, 73, 67, 45, 73, 78, 68, 73, 67, 32, 68, - 73, 71, 73, 84, 32, 30, 84, 247, 39, 73, 6, 250, 8, 70, 207, 50, 84, 4, - 190, 165, 7, 72, 147, 216, 7, 87, 23, 11, 32, 20, 68, 5, 87, 73, 84, 72, - 32, 142, 151, 1, 70, 202, 43, 73, 211, 9, 77, 12, 32, 4, 68, 79, 84, 32, - 51, 84, 6, 214, 40, 66, 145, 215, 15, 4, 77, 79, 86, 69, 6, 64, 10, 72, - 82, 69, 69, 32, 68, 79, 84, 83, 32, 243, 196, 37, 87, 4, 210, 17, 80, - 255, 194, 37, 66, 44, 72, 2, 65, 70, 160, 1, 4, 72, 65, 73, 78, 238, 20, - 85, 151, 222, 38, 82, 19, 11, 32, 16, 68, 5, 87, 73, 84, 72, 32, 182, - 148, 1, 70, 202, 43, 73, 211, 9, 77, 8, 242, 23, 84, 134, 140, 39, 82, - 241, 32, 8, 73, 78, 86, 69, 82, 84, 69, 68, 15, 11, 32, 12, 68, 5, 87, - 73, 84, 72, 32, 150, 147, 1, 70, 202, 43, 73, 211, 9, 77, 4, 214, 37, 84, - 187, 251, 26, 68, 82, 78, 65, 236, 5, 2, 69, 72, 161, 2, 9, 73, 71, 72, - 32, 72, 65, 77, 90, 65, 34, 34, 72, 201, 48, 3, 77, 90, 65, 31, 11, 32, - 28, 68, 5, 87, 73, 84, 72, 32, 174, 145, 1, 70, 202, 43, 73, 211, 9, 77, - 20, 132, 2, 29, 69, 88, 84, 69, 78, 68, 69, 68, 32, 65, 82, 65, 66, 73, - 67, 45, 73, 78, 68, 73, 67, 32, 68, 73, 71, 73, 84, 32, 70, 30, 73, 92, - 24, 83, 77, 65, 76, 76, 32, 65, 82, 65, 66, 73, 67, 32, 76, 69, 84, 84, - 69, 82, 32, 84, 65, 72, 32, 62, 84, 143, 53, 72, 2, 129, 199, 1, 2, 79, - 85, 2, 45, 9, 78, 86, 69, 82, 84, 69, 68, 32, 83, 2, 133, 190, 37, 6, 77, - 65, 76, 76, 32, 86, 6, 26, 65, 239, 204, 37, 66, 4, 134, 31, 78, 243, - 210, 38, 66, 8, 88, 10, 72, 82, 69, 69, 32, 68, 79, 84, 83, 32, 33, 8, - 87, 79, 32, 68, 79, 84, 83, 32, 4, 242, 8, 80, 255, 231, 38, 65, 4, 180, - 240, 38, 8, 86, 69, 82, 84, 73, 67, 65, 76, 27, 65, 41, 11, 32, 38, 144, - 1, 4, 71, 79, 65, 76, 88, 5, 87, 73, 84, 72, 32, 240, 47, 10, 68, 79, 65, - 67, 72, 65, 83, 72, 77, 69, 210, 90, 70, 202, 43, 73, 211, 9, 77, 13, 11, - 32, 10, 164, 50, 6, 87, 73, 84, 72, 32, 72, 230, 88, 70, 202, 43, 73, - 211, 9, 77, 8, 174, 26, 73, 149, 20, 3, 89, 69, 72, 9, 11, 32, 6, 174, - 234, 23, 65, 202, 138, 9, 89, 179, 247, 5, 87, 22, 28, 2, 69, 77, 247, - 45, 72, 17, 11, 32, 14, 72, 6, 87, 73, 84, 72, 32, 84, 226, 136, 1, 70, - 202, 43, 73, 211, 9, 77, 6, 170, 238, 14, 87, 203, 205, 18, 72, 70, 98, - 65, 208, 1, 4, 69, 72, 69, 72, 180, 2, 7, 73, 82, 71, 72, 73, 90, 32, - 137, 32, 2, 72, 65, 24, 46, 70, 229, 174, 1, 5, 83, 72, 77, 73, 82, 23, - 11, 32, 20, 68, 5, 87, 73, 84, 72, 32, 214, 134, 1, 70, 202, 43, 73, 211, - 9, 77, 12, 42, 84, 218, 194, 35, 68, 151, 211, 3, 82, 6, 254, 27, 87, - 255, 152, 37, 72, 25, 11, 32, 22, 68, 5, 87, 73, 84, 72, 32, 182, 133, 1, - 70, 202, 43, 73, 211, 9, 77, 14, 38, 84, 206, 42, 83, 191, 186, 38, 68, - 10, 60, 10, 72, 82, 69, 69, 32, 68, 79, 84, 83, 32, 167, 26, 87, 6, 42, - 80, 254, 194, 37, 66, 131, 165, 1, 65, 2, 193, 179, 37, 14, 79, 73, 78, - 84, 73, 78, 71, 32, 85, 80, 87, 65, 82, 68, 12, 130, 40, 79, 13, 2, 89, - 85, 26, 40, 2, 65, 77, 161, 183, 1, 2, 79, 87, 25, 11, 32, 22, 68, 5, 87, - 73, 84, 72, 32, 182, 130, 1, 70, 202, 43, 73, 211, 9, 77, 14, 88, 2, 68, - 79, 36, 6, 83, 77, 65, 76, 76, 32, 200, 180, 33, 2, 84, 72, 251, 137, 5, - 66, 4, 146, 251, 17, 85, 139, 234, 20, 84, 4, 224, 27, 16, 65, 82, 65, - 66, 73, 67, 32, 76, 69, 84, 84, 69, 82, 32, 84, 65, 155, 198, 39, 86, 18, - 36, 3, 69, 69, 77, 215, 159, 39, 65, 17, 11, 32, 14, 64, 5, 87, 73, 84, - 72, 32, 222, 127, 70, 202, 43, 73, 211, 9, 77, 6, 158, 18, 84, 239, 169, - 35, 68, 62, 38, 71, 26, 89, 17, 3, 79, 79, 78, 21, 22, 79, 183, 122, 32, - 10, 175, 27, 69, 33, 11, 32, 30, 92, 5, 71, 72, 85, 78, 78, 16, 5, 87, - 73, 84, 72, 32, 242, 125, 70, 202, 43, 73, 211, 9, 77, 6, 187, 34, 65, - 16, 136, 1, 6, 83, 77, 65, 76, 76, 32, 38, 84, 220, 24, 8, 73, 78, 86, - 69, 82, 84, 69, 68, 132, 139, 24, 4, 82, 73, 78, 71, 223, 230, 2, 68, 4, - 170, 239, 32, 84, 131, 238, 6, 86, 4, 250, 137, 7, 72, 195, 161, 30, 87, - 25, 22, 32, 187, 24, 69, 12, 88, 11, 87, 73, 84, 72, 32, 83, 77, 65, 76, - 76, 32, 170, 123, 70, 202, 43, 73, 211, 9, 77, 4, 26, 77, 215, 219, 39, - 86, 2, 205, 222, 38, 3, 69, 69, 77, 19, 11, 32, 16, 64, 5, 87, 73, 84, - 72, 32, 158, 122, 70, 202, 43, 73, 211, 9, 77, 8, 36, 4, 68, 79, 84, 32, - 187, 12, 84, 6, 44, 5, 66, 69, 76, 79, 87, 163, 221, 38, 65, 5, 141, 223, - 14, 6, 32, 65, 78, 68, 32, 78, 52, 112, 2, 69, 72, 224, 28, 3, 82, 69, - 72, 156, 3, 4, 78, 79, 79, 78, 149, 130, 1, 7, 79, 72, 73, 78, 71, 89, - 65, 35, 11, 32, 32, 52, 5, 87, 73, 84, 72, 32, 226, 119, 70, 231, 52, 73, - 28, 134, 1, 83, 96, 2, 84, 87, 234, 5, 73, 174, 23, 72, 194, 197, 11, 70, - 128, 138, 7, 5, 68, 79, 84, 32, 66, 234, 39, 76, 131, 241, 19, 82, 10, - 44, 5, 77, 65, 76, 76, 32, 131, 167, 39, 84, 8, 198, 6, 65, 166, 246, 6, - 78, 151, 211, 16, 86, 4, 37, 7, 79, 32, 68, 79, 84, 83, 32, 4, 166, 8, - 86, 135, 209, 38, 65, 60, 184, 1, 2, 65, 68, 120, 3, 69, 69, 78, 136, 6, - 4, 72, 69, 69, 78, 232, 160, 1, 4, 85, 80, 69, 82, 160, 181, 4, 7, 84, - 82, 65, 73, 71, 72, 84, 133, 246, 32, 6, 87, 65, 83, 72, 32, 75, 17, 11, - 32, 14, 68, 6, 87, 73, 84, 72, 32, 84, 162, 115, 70, 202, 43, 73, 211, 9, - 77, 6, 178, 166, 33, 72, 235, 251, 3, 87, 27, 11, 32, 24, 64, 5, 87, 73, - 84, 72, 32, 174, 114, 70, 202, 43, 73, 211, 9, 77, 16, 232, 1, 3, 68, 79, - 84, 50, 73, 48, 7, 83, 77, 65, 76, 76, 32, 65, 110, 84, 210, 219, 11, 70, - 241, 159, 5, 31, 69, 88, 84, 69, 78, 68, 69, 68, 32, 65, 82, 65, 66, 73, - 67, 45, 73, 78, 68, 73, 67, 32, 68, 73, 71, 73, 84, 32, 70, 79, 85, 2, - 193, 231, 18, 7, 32, 66, 69, 76, 79, 87, 32, 2, 213, 207, 17, 7, 78, 86, - 69, 82, 84, 69, 68, 2, 85, 19, 82, 65, 66, 73, 67, 32, 76, 69, 84, 84, - 69, 82, 32, 84, 65, 72, 32, 65, 78, 2, 147, 147, 23, 68, 6, 96, 11, 72, - 82, 69, 69, 32, 68, 79, 84, 83, 32, 66, 105, 9, 87, 79, 32, 68, 79, 84, - 83, 32, 86, 4, 25, 4, 69, 76, 79, 87, 5, 11, 32, 2, 21, 3, 65, 78, 68, 2, - 17, 2, 32, 84, 2, 247, 250, 6, 72, 2, 169, 216, 11, 8, 69, 82, 84, 73, - 67, 65, 76, 76, 13, 11, 32, 10, 46, 87, 186, 108, 70, 202, 43, 73, 211, - 9, 77, 2, 177, 250, 26, 5, 73, 84, 72, 32, 68, 122, 92, 2, 65, 72, 136, - 2, 4, 67, 72, 69, 72, 124, 2, 69, 72, 150, 3, 72, 97, 3, 84, 69, 72, 21, - 11, 32, 18, 64, 5, 87, 73, 84, 72, 32, 226, 106, 70, 202, 43, 73, 211, 9, - 77, 10, 26, 84, 195, 248, 26, 68, 8, 26, 87, 191, 157, 33, 72, 4, 37, 7, - 79, 32, 68, 79, 84, 83, 32, 4, 48, 6, 86, 69, 82, 84, 73, 67, 171, 205, - 38, 65, 2, 249, 152, 37, 4, 65, 76, 76, 89, 25, 22, 32, 199, 5, 69, 12, - 64, 5, 87, 73, 84, 72, 32, 206, 104, 70, 202, 43, 73, 211, 9, 77, 4, 138, - 14, 83, 191, 186, 38, 68, 37, 22, 32, 203, 4, 69, 24, 62, 77, 116, 5, 87, - 73, 84, 72, 32, 226, 102, 70, 203, 43, 73, 10, 48, 6, 65, 82, 66, 85, 84, - 65, 199, 156, 1, 69, 9, 11, 32, 6, 146, 103, 70, 230, 52, 73, 137, 160, - 37, 2, 71, 79, 8, 104, 6, 83, 77, 65, 76, 76, 32, 56, 12, 84, 72, 82, 69, - 69, 32, 68, 79, 84, 83, 32, 65, 131, 245, 38, 82, 4, 32, 2, 84, 69, 155, - 198, 39, 86, 2, 147, 201, 38, 72, 2, 205, 129, 28, 4, 66, 79, 86, 69, 20, - 42, 65, 16, 3, 73, 78, 32, 147, 1, 69, 6, 167, 9, 76, 4, 198, 207, 32, - 89, 183, 203, 3, 78, 23, 18, 32, 91, 69, 10, 60, 4, 87, 73, 84, 72, 230, - 99, 70, 202, 43, 73, 211, 9, 77, 2, 161, 9, 2, 32, 83, 10, 163, 11, 72, - 15, 158, 1, 32, 181, 92, 33, 73, 71, 72, 85, 82, 32, 75, 65, 90, 65, 75, - 72, 32, 75, 73, 82, 71, 72, 73, 90, 32, 65, 76, 69, 70, 32, 77, 65, 75, - 83, 85, 82, 65, 8, 96, 16, 87, 73, 84, 72, 32, 72, 65, 77, 90, 65, 32, - 65, 66, 79, 86, 69, 186, 97, 70, 231, 52, 73, 5, 155, 87, 32, 17, 254, 8, - 72, 147, 88, 32, 25, 11, 32, 22, 52, 5, 87, 73, 84, 72, 32, 202, 96, 70, - 231, 52, 73, 18, 80, 4, 68, 79, 84, 32, 162, 2, 69, 182, 1, 72, 226, 193, - 14, 84, 135, 170, 24, 82, 4, 204, 180, 31, 3, 87, 73, 84, 131, 143, 7, - 65, 56, 28, 2, 69, 72, 227, 3, 85, 51, 11, 32, 48, 100, 6, 66, 65, 82, - 82, 69, 69, 252, 2, 5, 87, 73, 84, 72, 32, 182, 91, 70, 202, 43, 73, 211, - 9, 77, 17, 11, 32, 14, 52, 5, 87, 73, 84, 72, 32, 238, 93, 70, 231, 52, - 73, 10, 22, 69, 183, 1, 72, 4, 121, 28, 88, 84, 69, 78, 68, 69, 68, 32, - 65, 82, 65, 66, 73, 67, 45, 73, 78, 68, 73, 67, 32, 68, 73, 71, 73, 84, - 32, 84, 4, 148, 150, 36, 3, 72, 82, 69, 133, 170, 2, 2, 87, 79, 6, 21, 3, - 65, 77, 90, 6, 11, 65, 6, 17, 2, 32, 65, 6, 21, 3, 66, 79, 86, 6, 11, 69, - 7, 171, 91, 32, 24, 96, 10, 72, 65, 77, 90, 65, 32, 65, 66, 79, 86, 18, - 83, 38, 84, 165, 137, 37, 4, 70, 79, 85, 82, 10, 167, 2, 69, 2, 133, 186, - 17, 4, 77, 65, 76, 76, 10, 108, 18, 87, 79, 32, 68, 79, 84, 83, 32, 66, - 69, 76, 79, 87, 32, 65, 78, 68, 32, 130, 136, 37, 72, 167, 82, 65, 6, 70, - 72, 168, 223, 6, 7, 83, 77, 65, 76, 76, 32, 78, 187, 217, 31, 68, 2, 237, - 141, 34, 3, 65, 77, 90, 18, 26, 72, 17, 2, 73, 78, 11, 223, 83, 32, 9, - 11, 32, 6, 138, 88, 70, 230, 52, 73, 177, 11, 13, 87, 73, 84, 72, 32, 73, - 78, 86, 69, 82, 84, 69, 68, 158, 8, 166, 5, 65, 178, 7, 66, 176, 2, 2, - 68, 65, 184, 1, 9, 70, 69, 72, 32, 87, 73, 84, 72, 32, 72, 11, 71, 72, - 65, 73, 78, 32, 87, 73, 84, 72, 32, 154, 1, 72, 150, 4, 74, 234, 2, 75, - 216, 2, 9, 76, 65, 77, 32, 87, 73, 84, 72, 32, 226, 4, 77, 154, 4, 78, - 202, 3, 81, 146, 4, 82, 186, 5, 83, 186, 17, 84, 196, 9, 7, 87, 65, 83, - 65, 76, 76, 65, 40, 9, 89, 69, 72, 32, 87, 73, 84, 72, 32, 216, 3, 53, - 85, 73, 71, 72, 85, 82, 32, 75, 73, 82, 71, 72, 73, 90, 32, 89, 69, 72, - 32, 87, 73, 84, 72, 32, 72, 65, 77, 90, 65, 32, 65, 66, 79, 86, 69, 32, - 87, 73, 84, 72, 32, 65, 76, 69, 70, 32, 77, 65, 75, 83, 85, 82, 65, 205, - 6, 14, 90, 65, 72, 32, 87, 73, 84, 72, 32, 77, 69, 69, 77, 32, 66, 192, - 1, 8, 73, 78, 32, 87, 73, 84, 72, 32, 68, 13, 74, 74, 65, 76, 32, 65, 76, - 76, 65, 65, 72, 85, 32, 146, 1, 76, 196, 68, 4, 75, 66, 65, 82, 189, 224, - 36, 8, 90, 90, 65, 32, 87, 65, 32, 74, 28, 236, 23, 4, 77, 69, 69, 77, - 130, 22, 74, 154, 25, 65, 255, 8, 89, 4, 54, 70, 1, 9, 84, 65, 65, 65, - 76, 65, 65, 32, 70, 2, 133, 207, 28, 17, 65, 82, 65, 74, 65, 72, 85, 32, - 65, 83, 72, 45, 83, 72, 65, 82, 69, 30, 56, 3, 65, 89, 72, 156, 2, 3, 69, - 70, 32, 207, 16, 76, 20, 30, 73, 102, 65, 135, 67, 69, 14, 24, 2, 32, 65, - 55, 77, 6, 110, 83, 205, 191, 32, 6, 82, 45, 82, 65, 72, 77, 8, 18, 65, - 23, 32, 4, 17, 2, 65, 32, 4, 17, 2, 65, 83, 4, 33, 6, 45, 83, 65, 76, 65, - 65, 4, 160, 168, 33, 10, 84, 85, 32, 87, 65, 83, 45, 83, 65, 76, 135, - 133, 6, 77, 8, 236, 75, 29, 77, 65, 75, 83, 85, 82, 65, 32, 87, 73, 84, - 72, 32, 83, 85, 80, 69, 82, 83, 67, 82, 73, 80, 84, 32, 65, 76, 69, 70, - 1, 13, 87, 73, 84, 72, 32, 70, 65, 84, 72, 65, 84, 65, 78, 44, 160, 1, 8, - 69, 72, 32, 87, 73, 84, 72, 32, 165, 243, 25, 25, 73, 83, 77, 73, 76, 76, - 65, 72, 32, 65, 82, 45, 82, 65, 72, 77, 65, 78, 32, 65, 82, 45, 82, 65, - 72, 42, 98, 72, 24, 3, 75, 72, 65, 254, 62, 65, 250, 3, 74, 78, 77, 86, - 78, 78, 90, 242, 2, 82, 43, 89, 10, 22, 65, 195, 66, 69, 6, 155, 69, 72, - 38, 100, 7, 68, 32, 87, 73, 84, 72, 32, 185, 28, 13, 65, 77, 65, 84, 32, - 66, 65, 82, 65, 75, 65, 65, 84, 36, 154, 8, 72, 250, 7, 75, 242, 45, 65, - 250, 3, 74, 2, 77, 134, 5, 82, 3, 89, 30, 194, 15, 75, 242, 45, 65, 250, - 3, 74, 146, 2, 77, 110, 72, 139, 2, 89, 22, 64, 5, 77, 69, 69, 77, 32, - 170, 60, 65, 250, 3, 74, 135, 5, 89, 10, 40, 5, 87, 73, 84, 72, 32, 255, - 112, 73, 6, 158, 25, 77, 234, 30, 65, 203, 12, 89, 48, 54, 65, 241, 1, 8, - 69, 72, 32, 87, 73, 84, 72, 32, 30, 68, 6, 70, 73, 90, 65, 72, 85, 101, - 7, 72, 32, 87, 73, 84, 72, 32, 8, 22, 77, 247, 28, 32, 4, 30, 32, 1, 3, - 65, 65, 32, 2, 201, 47, 7, 65, 76, 76, 65, 65, 72, 85, 22, 152, 4, 4, 77, - 69, 69, 77, 214, 53, 65, 138, 6, 74, 247, 2, 89, 18, 164, 1, 5, 77, 69, - 69, 77, 32, 204, 12, 6, 65, 76, 69, 70, 32, 77, 150, 2, 89, 158, 45, 74, - 53, 16, 83, 85, 80, 69, 82, 83, 67, 82, 73, 80, 84, 32, 65, 76, 69, 70, - 8, 40, 5, 87, 73, 84, 72, 32, 219, 108, 73, 4, 158, 52, 74, 3, 77, 32, - 68, 4, 65, 76, 76, 65, 81, 9, 69, 69, 77, 32, 87, 73, 84, 72, 32, 4, 168, - 145, 4, 7, 74, 65, 76, 65, 76, 79, 85, 241, 173, 24, 4, 32, 87, 65, 45, - 28, 62, 72, 60, 5, 77, 69, 69, 77, 32, 174, 53, 65, 255, 8, 89, 8, 17, 2, - 65, 72, 8, 11, 32, 8, 150, 37, 87, 179, 69, 73, 12, 40, 5, 87, 73, 84, - 72, 32, 131, 106, 73, 8, 154, 45, 72, 242, 3, 65, 203, 12, 89, 66, 58, + 69, 214, 218, 6, 81, 196, 150, 14, 3, 78, 79, 84, 22, 69, 178, 224, 5, + 66, 178, 169, 7, 83, 250, 144, 5, 71, 218, 118, 82, 135, 82, 74, 4, 158, + 207, 39, 73, 167, 135, 1, 79, 12, 54, 73, 36, 3, 79, 87, 78, 145, 229, + 37, 2, 69, 76, 4, 170, 236, 32, 86, 211, 247, 6, 65, 4, 206, 146, 4, 32, + 227, 240, 35, 87, 4, 190, 140, 39, 83, 183, 118, 70, 4, 234, 207, 12, 81, + 155, 225, 24, 85, 4, 184, 3, 5, 73, 71, 72, 84, 87, 167, 130, 41, 72, 10, + 88, 5, 69, 77, 73, 67, 79, 34, 76, 34, 84, 249, 205, 12, 7, 81, 85, 73, + 83, 72, 32, 81, 2, 157, 252, 32, 3, 76, 79, 78, 2, 141, 255, 39, 3, 65, + 83, 72, 4, 192, 197, 16, 2, 65, 82, 219, 212, 7, 73, 12, 22, 32, 171, 1, + 87, 10, 78, 67, 36, 5, 84, 65, 67, 75, 32, 149, 209, 40, 6, 83, 72, 79, + 69, 32, 74, 2, 153, 153, 24, 4, 65, 82, 69, 84, 6, 150, 151, 20, 68, 182, + 212, 17, 79, 203, 229, 2, 74, 2, 153, 252, 37, 6, 65, 82, 68, 83, 32, 86, + 4, 162, 244, 34, 83, 211, 220, 5, 76, 14, 26, 76, 93, 2, 82, 79, 4, 212, + 166, 27, 14, 73, 67, 65, 84, 73, 79, 78, 32, 80, 82, 79, 71, 82, 65, 147, + 228, 12, 69, 10, 112, 9, 88, 73, 77, 65, 84, 69, 76, 89, 32, 165, 130, + 41, 13, 65, 67, 72, 69, 83, 32, 84, 72, 69, 32, 76, 73, 77, 8, 76, 6, 69, + 81, 85, 65, 76, 32, 233, 253, 25, 7, 66, 85, 84, 32, 78, 79, 84, 6, 32, + 2, 84, 79, 159, 247, 32, 79, 5, 157, 167, 27, 13, 32, 79, 82, 32, 84, 72, + 69, 32, 73, 77, 65, 71, 69, 142, 24, 148, 1, 4, 65, 66, 73, 67, 128, 138, + 2, 7, 77, 69, 78, 73, 65, 78, 32, 212, 12, 3, 82, 79, 87, 228, 3, 2, 84, + 73, 202, 235, 37, 73, 135, 150, 1, 67, 188, 22, 54, 32, 189, 136, 2, 7, + 45, 73, 78, 68, 73, 67, 32, 160, 22, 254, 2, 66, 134, 1, 67, 238, 3, 68, + 138, 3, 69, 186, 1, 70, 136, 2, 2, 72, 65, 104, 5, 75, 65, 83, 82, 65, + 86, 76, 144, 180, 1, 2, 77, 65, 222, 18, 78, 196, 1, 5, 79, 80, 69, 78, + 32, 82, 80, 238, 1, 82, 208, 2, 6, 73, 78, 86, 69, 82, 84, 98, 83, 154, + 36, 84, 202, 4, 86, 216, 246, 17, 9, 87, 65, 86, 89, 32, 72, 65, 77, 90, + 158, 197, 18, 81, 193, 202, 1, 6, 90, 87, 65, 82, 65, 75, 4, 248, 217, 1, + 7, 65, 83, 69, 76, 73, 78, 69, 153, 179, 38, 17, 73, 66, 76, 73, 67, 65, + 76, 32, 69, 78, 68, 32, 79, 70, 32, 86, 69, 60, 104, 2, 79, 77, 80, 12, + 82, 79, 87, 78, 32, 76, 69, 84, 84, 69, 82, 32, 197, 1, 5, 85, 82, 76, + 89, 32, 4, 156, 237, 19, 11, 66, 73, 78, 73, 78, 71, 32, 65, 76, 69, 70, + 255, 166, 21, 77, 44, 250, 205, 1, 84, 250, 2, 83, 146, 151, 25, 72, 30, + 75, 230, 108, 74, 2, 77, 230, 197, 6, 66, 2, 70, 2, 80, 2, 89, 222, 7, + 90, 222, 58, 71, 182, 138, 3, 78, 130, 173, 2, 81, 222, 1, 65, 171, 57, + 68, 12, 72, 4, 68, 65, 77, 77, 0, 4, 70, 65, 84, 72, 1, 4, 75, 65, 83, + 82, 4, 11, 65, 5, 211, 196, 39, 84, 26, 158, 1, 65, 108, 5, 79, 85, 66, + 76, 69, 204, 190, 24, 5, 69, 67, 73, 77, 65, 177, 223, 9, 16, 73, 83, 80, + 85, 84, 69, 68, 32, 69, 78, 68, 32, 79, 70, 32, 65, 14, 36, 3, 77, 77, + 65, 247, 192, 34, 84, 13, 22, 32, 143, 6, 84, 6, 154, 243, 1, 73, 54, 77, + 227, 247, 37, 87, 8, 22, 32, 243, 4, 68, 6, 216, 211, 1, 17, 82, 73, 71, + 72, 84, 32, 65, 82, 82, 79, 87, 72, 69, 65, 68, 32, 65, 199, 33, 86, 8, + 88, 12, 77, 80, 84, 89, 32, 67, 69, 78, 84, 82, 69, 32, 57, 6, 78, 68, + 32, 79, 70, 32, 4, 224, 182, 38, 4, 72, 73, 71, 72, 1, 3, 76, 79, 87, 4, + 218, 234, 30, 84, 147, 177, 3, 65, 24, 64, 4, 65, 84, 72, 65, 126, 73, + 238, 223, 1, 79, 199, 212, 36, 85, 17, 22, 32, 211, 2, 84, 10, 52, 5, 87, + 73, 84, 72, 32, 170, 239, 1, 73, 55, 77, 6, 254, 183, 39, 84, 182, 85, + 68, 203, 47, 82, 4, 220, 236, 1, 7, 76, 76, 69, 68, 32, 83, 81, 141, 225, + 4, 2, 86, 69, 6, 72, 13, 76, 70, 32, 77, 65, 68, 68, 65, 32, 79, 86, 69, + 82, 207, 16, 77, 2, 169, 136, 18, 2, 32, 77, 13, 18, 32, 43, 84, 6, 138, + 72, 87, 174, 165, 1, 73, 55, 77, 4, 225, 82, 2, 65, 78, 176, 16, 84, 5, + 65, 82, 71, 69, 32, 146, 1, 69, 233, 90, 8, 73, 71, 65, 84, 85, 82, 69, + 32, 10, 64, 10, 82, 79, 85, 78, 68, 32, 68, 79, 84, 32, 215, 228, 38, 67, + 6, 132, 172, 11, 6, 73, 78, 83, 73, 68, 69, 158, 185, 27, 66, 163, 168, + 1, 65, 136, 8, 52, 5, 84, 84, 69, 82, 32, 181, 197, 1, 2, 70, 84, 132, 8, + 210, 2, 65, 240, 10, 2, 66, 69, 150, 4, 68, 186, 5, 70, 246, 4, 71, 226, + 2, 72, 156, 9, 2, 74, 69, 158, 1, 75, 138, 5, 76, 226, 2, 77, 154, 1, 78, + 160, 3, 3, 80, 69, 72, 176, 1, 3, 81, 65, 70, 214, 1, 82, 234, 3, 83, + 162, 9, 84, 214, 8, 85, 148, 2, 2, 86, 69, 28, 3, 87, 65, 87, 202, 1, 89, + 246, 3, 79, 140, 3, 2, 90, 65, 31, 69, 112, 92, 7, 70, 82, 73, 67, 65, + 78, 32, 92, 2, 73, 78, 144, 2, 3, 76, 69, 70, 135, 131, 41, 69, 8, 52, 3, + 81, 65, 70, 158, 138, 34, 70, 239, 204, 3, 78, 5, 153, 64, 5, 32, 87, 73, + 84, 72, 21, 11, 32, 18, 72, 6, 87, 73, 84, 72, 32, 84, 202, 172, 1, 70, + 186, 46, 73, 155, 11, 77, 10, 60, 10, 72, 82, 69, 69, 32, 68, 79, 84, 83, + 32, 187, 54, 87, 6, 148, 179, 15, 17, 80, 79, 73, 78, 84, 73, 78, 71, 32, + 68, 79, 87, 78, 87, 65, 82, 68, 218, 171, 23, 66, 163, 168, 1, 65, 83, + 11, 32, 80, 70, 87, 228, 44, 6, 77, 65, 75, 83, 85, 82, 218, 125, 70, + 159, 57, 73, 70, 48, 4, 73, 84, 72, 32, 177, 44, 3, 65, 83, 76, 64, 192, + 2, 9, 65, 84, 84, 65, 67, 72, 69, 68, 32, 220, 1, 19, 82, 73, 71, 72, 84, + 32, 77, 73, 68, 68, 76, 69, 32, 83, 84, 82, 79, 75, 69, 188, 1, 6, 72, + 65, 77, 90, 65, 32, 44, 8, 87, 65, 86, 89, 32, 72, 65, 77, 214, 70, 69, + 204, 1, 4, 77, 65, 68, 68, 240, 190, 37, 9, 76, 69, 70, 84, 32, 77, 73, + 68, 68, 155, 244, 1, 68, 28, 204, 1, 17, 66, 79, 84, 84, 79, 77, 32, 82, + 73, 71, 72, 84, 32, 75, 65, 83, 82, 0, 14, 84, 79, 80, 32, 82, 73, 71, + 72, 84, 32, 70, 65, 84, 72, 94, 82, 56, 3, 76, 69, 70, 154, 217, 1, 75, + 199, 147, 33, 70, 6, 11, 65, 7, 29, 5, 32, 65, 78, 68, 32, 4, 148, 252, + 19, 3, 76, 69, 70, 219, 128, 20, 68, 8, 52, 3, 73, 71, 72, 229, 231, 1, + 4, 79, 85, 78, 68, 4, 17, 2, 84, 32, 4, 138, 190, 1, 82, 227, 40, 72, 12, + 234, 72, 65, 37, 5, 66, 69, 76, 79, 87, 4, 231, 194, 38, 90, 50, 22, 72, + 179, 64, 69, 41, 22, 32, 155, 64, 69, 28, 68, 5, 87, 73, 84, 72, 32, 246, + 162, 1, 70, 186, 46, 73, 155, 11, 77, 20, 116, 6, 83, 77, 65, 76, 76, 32, + 34, 84, 254, 18, 73, 160, 33, 10, 68, 79, 84, 32, 66, 69, 76, 79, 87, 32, + 135, 21, 72, 6, 150, 39, 77, 183, 178, 24, 86, 8, 88, 10, 72, 82, 69, 69, + 32, 68, 79, 84, 83, 32, 233, 48, 7, 87, 79, 32, 68, 79, 84, 83, 6, 144, + 1, 22, 80, 79, 73, 78, 84, 73, 78, 71, 32, 85, 80, 87, 65, 82, 68, 83, + 32, 66, 69, 76, 79, 87, 201, 54, 8, 72, 79, 82, 73, 90, 79, 78, 84, 5, + 159, 166, 15, 32, 78, 90, 65, 136, 4, 2, 68, 65, 40, 7, 79, 84, 76, 69, + 83, 83, 32, 250, 27, 89, 147, 26, 85, 44, 34, 76, 254, 3, 72, 147, 46, + 68, 27, 11, 32, 24, 56, 5, 87, 73, 84, 72, 32, 146, 158, 1, 70, 159, 57, + 73, 20, 108, 9, 73, 78, 86, 69, 82, 84, 69, 68, 32, 34, 84, 168, 1, 3, + 68, 79, 84, 226, 169, 12, 70, 235, 248, 27, 82, 4, 238, 14, 83, 167, 230, + 40, 86, 8, 132, 1, 10, 72, 82, 69, 69, 32, 68, 79, 84, 83, 32, 33, 18, + 87, 79, 32, 68, 79, 84, 83, 32, 86, 69, 82, 84, 73, 67, 65, 76, 76, 89, + 4, 226, 54, 65, 255, 151, 38, 66, 4, 33, 6, 32, 66, 69, 76, 79, 87, 5, + 213, 211, 15, 11, 32, 65, 78, 68, 32, 83, 77, 65, 76, 76, 32, 12, 22, 72, + 195, 63, 76, 6, 151, 54, 65, 6, 162, 247, 33, 66, 2, 70, 239, 249, 5, 81, + 44, 60, 8, 65, 82, 83, 73, 32, 89, 69, 72, 169, 2, 2, 69, 72, 23, 11, 32, + 20, 68, 5, 87, 73, 84, 72, 32, 142, 153, 1, 70, 186, 46, 73, 155, 11, 77, + 12, 144, 1, 28, 69, 88, 84, 69, 78, 68, 69, 68, 32, 65, 82, 65, 66, 73, + 67, 45, 73, 78, 68, 73, 67, 32, 68, 73, 71, 73, 84, 32, 30, 84, 247, 39, + 73, 6, 250, 8, 70, 207, 50, 84, 4, 166, 174, 7, 72, 151, 240, 7, 87, 23, + 11, 32, 20, 68, 5, 87, 73, 84, 72, 32, 230, 150, 1, 70, 186, 46, 73, 155, + 11, 77, 12, 32, 4, 68, 79, 84, 32, 51, 84, 6, 214, 40, 66, 177, 248, 15, + 4, 77, 79, 86, 69, 6, 64, 10, 72, 82, 69, 69, 32, 68, 79, 84, 83, 32, + 251, 183, 38, 87, 4, 210, 17, 80, 227, 182, 38, 66, 44, 72, 2, 65, 70, + 160, 1, 4, 72, 65, 73, 78, 238, 20, 85, 155, 213, 39, 82, 19, 11, 32, 16, + 68, 5, 87, 73, 84, 72, 32, 142, 148, 1, 70, 186, 46, 73, 155, 11, 77, 8, + 242, 23, 84, 138, 131, 40, 82, 241, 32, 8, 73, 78, 86, 69, 82, 84, 69, + 68, 15, 11, 32, 12, 68, 5, 87, 73, 84, 72, 32, 238, 146, 1, 70, 186, 46, + 73, 155, 11, 77, 4, 214, 37, 84, 167, 232, 27, 68, 82, 78, 65, 236, 5, 2, + 69, 72, 161, 2, 9, 73, 71, 72, 32, 72, 65, 77, 90, 65, 34, 34, 72, 201, + 48, 3, 77, 90, 65, 31, 11, 32, 28, 68, 5, 87, 73, 84, 72, 32, 134, 145, + 1, 70, 186, 46, 73, 155, 11, 77, 20, 132, 2, 29, 69, 88, 84, 69, 78, 68, + 69, 68, 32, 65, 82, 65, 66, 73, 67, 45, 73, 78, 68, 73, 67, 32, 68, 73, + 71, 73, 84, 32, 70, 30, 73, 92, 24, 83, 77, 65, 76, 76, 32, 65, 82, 65, + 66, 73, 67, 32, 76, 69, 84, 84, 69, 82, 32, 84, 65, 72, 32, 62, 84, 143, + 53, 72, 2, 145, 203, 1, 2, 79, 85, 2, 45, 9, 78, 86, 69, 82, 84, 69, 68, + 32, 83, 2, 141, 177, 38, 6, 77, 65, 76, 76, 32, 86, 6, 26, 65, 211, 192, + 38, 66, 4, 134, 31, 78, 247, 201, 39, 66, 8, 88, 10, 72, 82, 69, 69, 32, + 68, 79, 84, 83, 32, 33, 8, 87, 79, 32, 68, 79, 84, 83, 32, 4, 242, 8, 80, + 131, 223, 39, 65, 4, 184, 231, 39, 8, 86, 69, 82, 84, 73, 67, 65, 76, 27, + 65, 41, 11, 32, 38, 144, 1, 4, 71, 79, 65, 76, 88, 5, 87, 73, 84, 72, 32, + 240, 47, 10, 68, 79, 65, 67, 72, 65, 83, 72, 77, 69, 170, 90, 70, 186, + 46, 73, 155, 11, 77, 13, 11, 32, 10, 164, 50, 6, 87, 73, 84, 72, 32, 72, + 190, 88, 70, 186, 46, 73, 155, 11, 77, 8, 174, 26, 73, 149, 20, 3, 89, + 69, 72, 9, 11, 32, 6, 150, 234, 24, 65, 166, 252, 8, 89, 243, 252, 5, 87, + 22, 28, 2, 69, 77, 247, 45, 72, 17, 11, 32, 14, 72, 6, 87, 73, 84, 72, + 32, 84, 186, 136, 1, 70, 186, 46, 73, 155, 11, 77, 6, 150, 143, 15, 87, + 151, 158, 19, 72, 70, 98, 65, 208, 1, 4, 69, 72, 69, 72, 180, 2, 7, 73, + 82, 71, 72, 73, 90, 32, 137, 32, 2, 72, 65, 24, 46, 70, 253, 176, 1, 5, + 83, 72, 77, 73, 82, 23, 11, 32, 20, 68, 5, 87, 73, 84, 72, 32, 174, 134, + 1, 70, 186, 46, 73, 155, 11, 77, 12, 42, 84, 242, 179, 36, 68, 131, 217, + 3, 82, 6, 254, 27, 87, 135, 140, 38, 72, 25, 11, 32, 22, 68, 5, 87, 73, + 84, 72, 32, 142, 133, 1, 70, 186, 46, 73, 155, 11, 77, 14, 38, 84, 206, + 42, 83, 195, 177, 39, 68, 10, 60, 10, 72, 82, 69, 69, 32, 68, 79, 84, 83, + 32, 167, 26, 87, 6, 42, 80, 226, 182, 38, 66, 163, 168, 1, 65, 2, 201, + 166, 38, 14, 79, 73, 78, 84, 73, 78, 71, 32, 85, 80, 87, 65, 82, 68, 12, + 130, 40, 79, 13, 2, 89, 85, 26, 40, 2, 65, 77, 177, 187, 1, 2, 79, 87, + 25, 11, 32, 22, 68, 5, 87, 73, 84, 72, 32, 142, 130, 1, 70, 186, 46, 73, + 155, 11, 77, 14, 88, 2, 68, 79, 36, 6, 83, 77, 65, 76, 76, 32, 128, 166, + 34, 2, 84, 72, 135, 143, 5, 66, 4, 182, 201, 23, 85, 235, 146, 16, 84, 4, + 224, 27, 16, 65, 82, 65, 66, 73, 67, 32, 76, 69, 84, 84, 69, 82, 32, 84, + 65, 159, 189, 40, 86, 18, 36, 3, 69, 69, 77, 219, 150, 40, 65, 17, 11, + 32, 14, 64, 5, 87, 73, 84, 72, 32, 182, 127, 70, 186, 46, 73, 155, 11, + 77, 6, 158, 18, 84, 135, 155, 36, 68, 62, 38, 71, 26, 89, 17, 3, 79, 79, + 78, 21, 22, 79, 155, 122, 32, 10, 175, 27, 69, 33, 11, 32, 30, 92, 5, 71, + 72, 85, 78, 78, 16, 5, 87, 73, 84, 72, 32, 202, 125, 70, 186, 46, 73, + 155, 11, 77, 6, 187, 34, 65, 16, 136, 1, 6, 83, 77, 65, 76, 76, 32, 38, + 84, 220, 24, 8, 73, 78, 86, 69, 82, 84, 69, 68, 188, 246, 24, 4, 82, 73, + 78, 71, 147, 232, 2, 68, 4, 238, 224, 33, 84, 195, 243, 6, 86, 4, 226, + 146, 7, 72, 227, 139, 31, 87, 25, 22, 32, 187, 24, 69, 12, 88, 11, 87, + 73, 84, 72, 32, 83, 77, 65, 76, 76, 32, 130, 123, 70, 186, 46, 73, 155, + 11, 77, 4, 26, 77, 219, 210, 40, 86, 2, 209, 213, 39, 3, 69, 69, 77, 19, + 11, 32, 16, 64, 5, 87, 73, 84, 72, 32, 246, 121, 70, 186, 46, 73, 155, + 11, 77, 8, 36, 4, 68, 79, 84, 32, 187, 12, 84, 6, 44, 5, 66, 69, 76, 79, + 87, 167, 212, 39, 65, 5, 249, 255, 14, 6, 32, 65, 78, 68, 32, 78, 52, + 112, 2, 69, 72, 224, 28, 3, 82, 69, 72, 156, 3, 4, 78, 79, 79, 78, 221, + 132, 1, 7, 79, 72, 73, 78, 71, 89, 65, 35, 11, 32, 32, 52, 5, 87, 73, 84, + 72, 32, 186, 119, 70, 159, 57, 73, 28, 134, 1, 83, 96, 2, 84, 87, 234, 5, + 73, 174, 23, 72, 198, 230, 11, 70, 138, 148, 7, 76, 244, 10, 5, 68, 79, + 84, 32, 66, 239, 217, 20, 82, 10, 44, 5, 77, 65, 76, 76, 32, 135, 158, + 40, 84, 8, 198, 6, 65, 142, 255, 6, 78, 255, 167, 17, 86, 4, 37, 7, 79, + 32, 68, 79, 84, 83, 32, 4, 166, 8, 86, 139, 200, 39, 65, 60, 184, 1, 2, + 65, 68, 120, 3, 69, 69, 78, 136, 6, 4, 72, 69, 69, 78, 248, 164, 1, 4, + 85, 80, 69, 82, 204, 183, 4, 7, 84, 82, 65, 73, 71, 72, 84, 205, 230, 33, + 6, 87, 65, 83, 72, 32, 75, 17, 11, 32, 14, 68, 6, 87, 73, 84, 72, 32, 84, + 250, 114, 70, 186, 46, 73, 155, 11, 77, 6, 234, 151, 34, 72, 187, 253, 3, + 87, 27, 11, 32, 24, 64, 5, 87, 73, 84, 72, 32, 134, 114, 70, 186, 46, 73, + 155, 11, 77, 16, 232, 1, 3, 68, 79, 84, 50, 73, 48, 7, 83, 77, 65, 76, + 76, 32, 65, 110, 84, 214, 252, 11, 70, 213, 164, 5, 31, 69, 88, 84, 69, + 78, 68, 69, 68, 32, 65, 82, 65, 66, 73, 67, 45, 73, 78, 68, 73, 67, 32, + 68, 73, 71, 73, 84, 32, 70, 79, 85, 2, 193, 157, 19, 7, 32, 66, 69, 76, + 79, 87, 32, 2, 189, 245, 17, 7, 78, 86, 69, 82, 84, 69, 68, 2, 85, 19, + 82, 65, 66, 73, 67, 32, 76, 69, 84, 84, 69, 82, 32, 84, 65, 72, 32, 65, + 78, 2, 239, 230, 23, 68, 6, 96, 11, 72, 82, 69, 69, 32, 68, 79, 84, 83, + 32, 66, 105, 9, 87, 79, 32, 68, 79, 84, 83, 32, 86, 4, 25, 4, 69, 76, 79, + 87, 5, 11, 32, 2, 21, 3, 65, 78, 68, 2, 17, 2, 32, 84, 2, 223, 131, 7, + 72, 2, 173, 249, 11, 8, 69, 82, 84, 73, 67, 65, 76, 76, 13, 11, 32, 10, + 46, 87, 146, 108, 70, 186, 46, 73, 155, 11, 77, 2, 157, 231, 27, 5, 73, + 84, 72, 32, 68, 122, 92, 2, 65, 72, 136, 2, 4, 67, 72, 69, 72, 124, 2, + 69, 72, 150, 3, 72, 97, 3, 84, 69, 72, 21, 11, 32, 18, 64, 5, 87, 73, 84, + 72, 32, 186, 106, 70, 186, 46, 73, 155, 11, 77, 10, 26, 84, 175, 229, 27, + 68, 8, 26, 87, 247, 142, 34, 72, 4, 37, 7, 79, 32, 68, 79, 84, 83, 32, 4, + 48, 6, 86, 69, 82, 84, 73, 67, 175, 196, 39, 65, 2, 129, 140, 38, 4, 65, + 76, 76, 89, 25, 22, 32, 199, 5, 69, 12, 64, 5, 87, 73, 84, 72, 32, 166, + 104, 70, 186, 46, 73, 155, 11, 77, 4, 138, 14, 83, 195, 177, 39, 68, 37, + 22, 32, 203, 4, 69, 24, 62, 77, 116, 5, 87, 73, 84, 72, 32, 186, 102, 70, + 187, 46, 73, 10, 48, 6, 65, 82, 66, 85, 84, 65, 215, 160, 1, 69, 9, 11, + 32, 6, 234, 102, 70, 158, 57, 73, 253, 146, 38, 2, 71, 79, 8, 104, 6, 83, + 77, 65, 76, 76, 32, 56, 12, 84, 72, 82, 69, 69, 32, 68, 79, 84, 83, 32, + 65, 135, 236, 39, 82, 4, 32, 2, 84, 69, 159, 189, 40, 86, 2, 151, 192, + 39, 72, 2, 141, 239, 28, 4, 66, 79, 86, 69, 20, 42, 65, 16, 3, 73, 78, + 32, 147, 1, 69, 6, 167, 9, 76, 4, 138, 193, 33, 89, 239, 204, 3, 78, 23, + 18, 32, 91, 69, 10, 60, 4, 87, 73, 84, 72, 190, 99, 70, 186, 46, 73, 155, + 11, 77, 2, 161, 9, 2, 32, 83, 10, 163, 11, 72, 15, 158, 1, 32, 185, 92, + 33, 73, 71, 72, 85, 82, 32, 75, 65, 90, 65, 75, 72, 32, 75, 73, 82, 71, + 72, 73, 90, 32, 65, 76, 69, 70, 32, 77, 65, 75, 83, 85, 82, 65, 8, 96, + 16, 87, 73, 84, 72, 32, 72, 65, 77, 90, 65, 32, 65, 66, 79, 86, 69, 146, + 97, 70, 159, 57, 73, 5, 159, 87, 32, 17, 254, 8, 72, 235, 87, 32, 25, 11, + 32, 22, 52, 5, 87, 73, 84, 72, 32, 162, 96, 70, 159, 57, 73, 18, 80, 4, + 68, 79, 84, 32, 162, 2, 69, 182, 1, 72, 206, 226, 14, 84, 159, 128, 25, + 82, 4, 136, 164, 32, 3, 87, 73, 84, 203, 150, 7, 65, 56, 28, 2, 69, 72, + 227, 3, 85, 51, 11, 32, 48, 100, 6, 66, 65, 82, 82, 69, 69, 252, 2, 5, + 87, 73, 84, 72, 32, 142, 91, 70, 186, 46, 73, 155, 11, 77, 17, 11, 32, + 14, 52, 5, 87, 73, 84, 72, 32, 198, 93, 70, 159, 57, 73, 10, 22, 69, 183, + 1, 72, 4, 121, 28, 88, 84, 69, 78, 68, 69, 68, 32, 65, 82, 65, 66, 73, + 67, 45, 73, 78, 68, 73, 67, 32, 68, 73, 71, 73, 84, 32, 84, 4, 156, 137, + 37, 3, 72, 82, 69, 129, 174, 2, 2, 87, 79, 6, 21, 3, 65, 77, 90, 6, 11, + 65, 6, 17, 2, 32, 65, 6, 21, 3, 66, 79, 86, 6, 11, 69, 7, 131, 91, 32, + 24, 96, 10, 72, 65, 77, 90, 65, 32, 65, 66, 79, 86, 18, 83, 38, 84, 173, + 252, 37, 4, 70, 79, 85, 82, 10, 167, 2, 69, 2, 237, 223, 17, 4, 77, 65, + 76, 76, 10, 108, 18, 87, 79, 32, 68, 79, 84, 83, 32, 66, 69, 76, 79, 87, + 32, 65, 78, 68, 32, 138, 251, 37, 72, 147, 83, 65, 6, 70, 72, 144, 232, + 6, 7, 83, 77, 65, 76, 76, 32, 78, 215, 199, 32, 68, 2, 161, 255, 34, 3, + 65, 77, 90, 18, 26, 72, 17, 2, 73, 78, 11, 195, 83, 32, 9, 11, 32, 6, + 226, 87, 70, 158, 57, 73, 177, 11, 13, 87, 73, 84, 72, 32, 73, 78, 86, + 69, 82, 84, 69, 68, 158, 8, 166, 5, 65, 178, 7, 66, 176, 2, 2, 68, 65, + 184, 1, 9, 70, 69, 72, 32, 87, 73, 84, 72, 32, 72, 11, 71, 72, 65, 73, + 78, 32, 87, 73, 84, 72, 32, 154, 1, 72, 154, 4, 74, 234, 2, 75, 216, 2, + 9, 76, 65, 77, 32, 87, 73, 84, 72, 32, 226, 4, 77, 154, 4, 78, 202, 3, + 81, 146, 4, 82, 186, 5, 83, 186, 17, 84, 196, 9, 7, 87, 65, 83, 65, 76, + 76, 65, 40, 9, 89, 69, 72, 32, 87, 73, 84, 72, 32, 216, 3, 53, 85, 73, + 71, 72, 85, 82, 32, 75, 73, 82, 71, 72, 73, 90, 32, 89, 69, 72, 32, 87, + 73, 84, 72, 32, 72, 65, 77, 90, 65, 32, 65, 66, 79, 86, 69, 32, 87, 73, + 84, 72, 32, 65, 76, 69, 70, 32, 77, 65, 75, 83, 85, 82, 65, 161, 6, 14, + 90, 65, 72, 32, 87, 73, 84, 72, 32, 77, 69, 69, 77, 32, 66, 192, 1, 8, + 73, 78, 32, 87, 73, 84, 72, 32, 68, 13, 74, 74, 65, 76, 32, 65, 76, 76, + 65, 65, 72, 85, 32, 146, 1, 76, 200, 68, 4, 75, 66, 65, 82, 157, 212, 37, + 8, 90, 90, 65, 32, 87, 65, 32, 74, 28, 240, 23, 4, 77, 69, 69, 77, 130, + 22, 74, 154, 25, 65, 211, 8, 89, 4, 54, 70, 1, 9, 84, 65, 65, 65, 76, 65, + 65, 32, 70, 2, 137, 189, 29, 17, 65, 82, 65, 74, 65, 72, 85, 32, 65, 83, + 72, 45, 83, 72, 65, 82, 69, 30, 56, 3, 65, 89, 72, 156, 2, 3, 69, 70, 32, + 211, 16, 76, 20, 30, 73, 102, 65, 139, 67, 69, 14, 24, 2, 32, 65, 55, 77, + 6, 110, 83, 145, 177, 33, 6, 82, 45, 82, 65, 72, 77, 8, 18, 65, 23, 32, + 4, 17, 2, 65, 32, 4, 17, 2, 65, 83, 4, 33, 6, 45, 83, 65, 76, 65, 65, 4, + 188, 153, 34, 10, 84, 85, 32, 87, 65, 83, 45, 83, 65, 76, 239, 138, 6, + 77, 8, 196, 75, 29, 77, 65, 75, 83, 85, 82, 65, 32, 87, 73, 84, 72, 32, + 83, 85, 80, 69, 82, 83, 67, 82, 73, 80, 84, 32, 65, 76, 69, 70, 1, 13, + 87, 73, 84, 72, 32, 70, 65, 84, 72, 65, 84, 65, 78, 44, 160, 1, 8, 69, + 72, 32, 87, 73, 84, 72, 32, 253, 223, 26, 25, 73, 83, 77, 73, 76, 76, 65, + 72, 32, 65, 82, 45, 82, 65, 72, 77, 65, 78, 32, 65, 82, 45, 82, 65, 72, + 42, 98, 72, 24, 3, 75, 72, 65, 130, 63, 65, 250, 3, 74, 46, 77, 86, 78, + 78, 90, 230, 2, 82, 43, 89, 10, 22, 65, 199, 66, 69, 6, 255, 68, 72, 38, + 100, 7, 68, 32, 87, 73, 84, 72, 32, 189, 28, 13, 65, 77, 65, 84, 32, 66, + 65, 82, 65, 75, 65, 65, 84, 36, 158, 8, 72, 250, 7, 75, 242, 45, 65, 250, + 3, 74, 2, 77, 218, 4, 82, 3, 89, 30, 198, 15, 75, 242, 45, 65, 250, 3, + 74, 242, 1, 77, 110, 72, 255, 1, 89, 22, 64, 5, 77, 69, 69, 77, 32, 174, + 60, 65, 250, 3, 74, 219, 4, 89, 10, 40, 5, 87, 73, 84, 72, 32, 199, 115, + 73, 6, 162, 25, 77, 234, 30, 65, 159, 12, 89, 48, 54, 65, 241, 1, 8, 69, + 72, 32, 87, 73, 84, 72, 32, 30, 68, 6, 70, 73, 90, 65, 72, 85, 101, 7, + 72, 32, 87, 73, 84, 72, 32, 8, 22, 77, 251, 28, 32, 4, 30, 32, 1, 3, 65, + 65, 32, 2, 205, 47, 7, 65, 76, 76, 65, 65, 72, 85, 22, 156, 4, 4, 77, 69, + 69, 77, 214, 53, 65, 234, 5, 74, 235, 2, 89, 18, 168, 1, 5, 77, 69, 69, + 77, 32, 204, 12, 6, 65, 76, 69, 70, 32, 77, 150, 2, 89, 158, 45, 74, 217, + 47, 16, 83, 85, 80, 69, 82, 83, 67, 82, 73, 80, 84, 32, 65, 76, 69, 70, + 8, 40, 5, 87, 73, 84, 72, 32, 159, 111, 73, 4, 158, 52, 74, 3, 77, 32, + 68, 4, 65, 76, 76, 65, 81, 9, 69, 69, 77, 32, 87, 73, 84, 72, 32, 4, 188, + 151, 4, 7, 74, 65, 76, 65, 76, 79, 85, 221, 149, 25, 4, 32, 87, 65, 45, + 28, 62, 72, 60, 5, 77, 69, 69, 77, 32, 174, 53, 65, 211, 8, 89, 8, 17, 2, + 65, 72, 8, 11, 32, 8, 150, 37, 87, 247, 71, 73, 12, 40, 5, 87, 73, 84, + 72, 32, 199, 108, 73, 8, 154, 45, 72, 242, 3, 65, 159, 12, 89, 66, 58, 65, 213, 1, 9, 72, 65, 72, 32, 87, 73, 84, 72, 32, 48, 116, 7, 70, 32, - 87, 73, 84, 72, 32, 221, 99, 17, 82, 82, 65, 77, 65, 32, 65, 76, 76, 65, - 65, 72, 85, 32, 87, 65, 74, 46, 192, 53, 2, 65, 76, 218, 1, 74, 96, 2, - 76, 65, 146, 2, 75, 14, 72, 30, 77, 239, 1, 89, 18, 54, 72, 146, 50, 65, - 250, 3, 74, 2, 77, 135, 5, 89, 2, 247, 8, 65, 74, 116, 5, 65, 76, 69, 70, + 87, 73, 84, 72, 32, 241, 101, 17, 82, 82, 65, 77, 65, 32, 65, 76, 76, 65, + 65, 72, 85, 32, 87, 65, 74, 46, 192, 53, 2, 65, 76, 218, 1, 74, 64, 2, + 76, 65, 146, 2, 75, 14, 72, 30, 77, 227, 1, 89, 18, 54, 72, 146, 50, 65, + 250, 3, 74, 2, 77, 219, 4, 89, 2, 247, 8, 65, 74, 116, 5, 65, 76, 69, 70, 32, 210, 1, 72, 124, 5, 74, 69, 69, 77, 32, 78, 75, 28, 5, 77, 69, 69, - 77, 32, 211, 54, 89, 20, 64, 5, 87, 73, 84, 72, 32, 162, 51, 77, 222, 6, - 70, 231, 52, 73, 12, 68, 6, 72, 65, 77, 90, 65, 32, 41, 7, 77, 65, 68, - 68, 65, 32, 65, 8, 38, 65, 145, 53, 4, 66, 69, 76, 79, 4, 253, 52, 3, 66, - 79, 86, 14, 28, 2, 65, 72, 187, 51, 69, 12, 11, 32, 12, 40, 5, 87, 73, - 84, 72, 32, 227, 99, 73, 8, 234, 42, 65, 130, 12, 77, 75, 89, 14, 40, 5, - 87, 73, 84, 72, 32, 147, 99, 73, 10, 154, 54, 74, 2, 77, 75, 89, 8, 237, - 20, 3, 72, 65, 72, 14, 130, 20, 87, 138, 35, 70, 202, 43, 73, 211, 9, 77, - 48, 84, 9, 69, 69, 77, 32, 87, 73, 84, 72, 32, 217, 43, 7, 79, 72, 65, - 77, 77, 65, 68, 46, 116, 5, 65, 76, 69, 70, 32, 66, 72, 0, 2, 75, 72, + 77, 32, 167, 54, 89, 20, 64, 5, 87, 73, 84, 72, 32, 162, 51, 77, 178, 6, + 70, 159, 57, 73, 12, 68, 6, 72, 65, 77, 90, 65, 32, 41, 7, 77, 65, 68, + 68, 65, 32, 65, 8, 38, 65, 241, 52, 4, 66, 69, 76, 79, 4, 221, 52, 3, 66, + 79, 86, 14, 28, 2, 65, 72, 223, 98, 69, 12, 11, 32, 12, 40, 5, 87, 73, + 84, 72, 32, 167, 102, 73, 8, 234, 42, 65, 226, 11, 77, 63, 89, 14, 40, 5, + 87, 73, 84, 72, 32, 215, 101, 73, 10, 250, 53, 74, 2, 77, 63, 89, 8, 237, + 20, 3, 72, 65, 72, 14, 130, 20, 87, 222, 34, 70, 186, 46, 73, 155, 11, + 77, 48, 84, 9, 69, 69, 77, 32, 87, 73, 84, 72, 32, 217, 43, 7, 79, 72, + 65, 77, 77, 65, 68, 46, 116, 5, 65, 76, 69, 70, 32, 66, 72, 0, 2, 75, 72, 104, 5, 74, 69, 69, 77, 32, 92, 5, 77, 69, 69, 77, 32, 43, 89, 4, 22, 77, - 243, 52, 70, 2, 197, 42, 6, 65, 75, 83, 85, 82, 65, 10, 21, 3, 65, 72, - 32, 10, 40, 5, 87, 73, 84, 72, 32, 207, 95, 73, 6, 146, 39, 74, 2, 77, - 143, 12, 89, 12, 40, 5, 87, 73, 84, 72, 32, 255, 94, 73, 8, 194, 38, 77, - 194, 7, 75, 14, 72, 195, 4, 89, 8, 142, 48, 87, 246, 2, 70, 203, 43, 73, + 199, 52, 70, 2, 197, 42, 6, 65, 75, 83, 85, 82, 65, 10, 21, 3, 65, 72, + 32, 10, 40, 5, 87, 73, 84, 72, 32, 147, 98, 73, 6, 146, 39, 74, 2, 77, + 227, 11, 89, 12, 40, 5, 87, 73, 84, 72, 32, 195, 97, 73, 8, 194, 38, 77, + 194, 7, 75, 14, 72, 151, 4, 89, 8, 238, 47, 87, 234, 2, 70, 187, 46, 73, 2, 11, 69, 2, 167, 40, 72, 62, 144, 1, 9, 79, 79, 78, 32, 87, 73, 84, 72, - 32, 153, 151, 13, 20, 65, 87, 87, 65, 82, 65, 32, 65, 76, 76, 65, 65, 72, + 32, 129, 184, 13, 20, 65, 87, 87, 65, 82, 65, 32, 65, 76, 76, 65, 65, 72, 85, 32, 77, 65, 82, 81, 65, 60, 134, 1, 72, 28, 5, 74, 69, 69, 77, 32, - 92, 5, 77, 69, 69, 77, 32, 246, 37, 65, 154, 5, 78, 78, 90, 134, 1, 75, - 238, 1, 82, 43, 89, 14, 150, 33, 65, 155, 9, 69, 16, 40, 5, 87, 73, 84, - 72, 32, 167, 91, 73, 12, 190, 30, 72, 242, 3, 65, 130, 12, 77, 75, 89, - 12, 194, 21, 87, 234, 25, 70, 202, 43, 73, 211, 9, 77, 36, 46, 65, 209, + 92, 5, 77, 69, 69, 77, 32, 246, 37, 65, 250, 4, 78, 78, 90, 134, 1, 75, + 226, 1, 82, 43, 89, 14, 150, 33, 65, 155, 9, 69, 16, 40, 5, 87, 73, 84, + 72, 32, 235, 93, 73, 12, 190, 30, 72, 242, 3, 65, 226, 11, 77, 63, 89, + 12, 194, 21, 87, 190, 25, 70, 186, 46, 73, 155, 11, 77, 36, 46, 65, 209, 2, 6, 85, 68, 68, 73, 83, 65, 28, 156, 1, 7, 70, 32, 87, 73, 84, 72, 32, - 212, 12, 4, 76, 65, 32, 85, 157, 147, 32, 18, 68, 68, 65, 83, 65, 32, 65, + 212, 12, 4, 76, 65, 32, 85, 221, 132, 33, 18, 68, 68, 65, 83, 65, 32, 65, 76, 76, 65, 65, 72, 85, 32, 83, 73, 82, 82, 24, 64, 5, 77, 69, 69, 77, - 32, 174, 35, 65, 246, 6, 72, 139, 2, 89, 12, 40, 5, 87, 73, 84, 72, 32, - 131, 88, 73, 8, 34, 77, 250, 26, 72, 187, 16, 89, 2, 193, 43, 3, 69, 69, + 32, 174, 35, 65, 214, 6, 72, 255, 1, 89, 12, 40, 5, 87, 73, 84, 72, 32, + 199, 90, 73, 8, 34, 77, 250, 26, 72, 143, 16, 89, 2, 149, 43, 3, 69, 69, 77, 8, 68, 5, 32, 83, 73, 82, 82, 45, 8, 84, 32, 65, 83, 82, 65, 65, 82, - 6, 220, 5, 3, 85, 72, 85, 139, 133, 39, 65, 2, 165, 224, 37, 2, 85, 72, + 6, 220, 5, 3, 85, 72, 85, 139, 252, 39, 65, 2, 229, 214, 38, 2, 85, 72, 44, 30, 65, 177, 30, 2, 69, 72, 42, 92, 11, 68, 73, 32, 65, 76, 76, 65, 65, 72, 85, 32, 170, 1, 72, 153, 30, 4, 83, 79, 85, 76, 18, 72, 3, 65, 78, 72, 61, 11, 84, 65, 65, 65, 76, 65, 65, 32, 65, 78, 72, 11, 26, 85, - 147, 135, 39, 65, 6, 186, 3, 77, 247, 199, 37, 78, 9, 142, 3, 85, 227, - 131, 39, 65, 22, 92, 5, 73, 77, 65, 72, 85, 149, 1, 13, 77, 65, 84, 85, + 147, 254, 39, 65, 6, 186, 3, 77, 243, 187, 38, 78, 9, 142, 3, 85, 227, + 250, 39, 65, 22, 92, 5, 73, 77, 65, 72, 85, 149, 1, 13, 77, 65, 84, 85, 32, 65, 76, 76, 65, 65, 72, 73, 32, 12, 44, 7, 32, 65, 76, 76, 65, 65, 72, 19, 77, 5, 215, 20, 32, 8, 30, 32, 1, 3, 65, 65, 32, 4, 33, 6, 65, 76, 76, 65, 65, 72, 5, 211, 18, 85, 10, 92, 5, 65, 76, 65, 89, 72, 165, - 133, 39, 12, 84, 65, 65, 65, 76, 65, 65, 32, 65, 76, 65, 89, 9, 26, 73, - 227, 131, 39, 65, 4, 11, 77, 5, 211, 131, 39, 65, 194, 1, 134, 1, 65, + 252, 39, 12, 84, 65, 65, 65, 76, 65, 65, 32, 65, 76, 65, 89, 9, 26, 73, + 227, 250, 39, 65, 4, 11, 77, 5, 211, 250, 39, 65, 194, 1, 134, 1, 65, 220, 7, 9, 69, 69, 78, 32, 87, 73, 84, 72, 32, 250, 3, 72, 201, 4, 12, 85, 66, 72, 65, 65, 78, 65, 72, 85, 32, 87, 65, 50, 48, 7, 68, 32, 87, 73, 84, 72, 32, 251, 1, 76, 32, 76, 4, 72, 65, 72, 32, 82, 77, 154, 25, - 65, 138, 4, 75, 246, 4, 82, 3, 89, 10, 22, 87, 211, 78, 73, 6, 25, 4, 73, - 84, 72, 32, 6, 206, 17, 72, 187, 16, 89, 8, 21, 3, 69, 69, 77, 8, 11, 32, - 8, 252, 32, 6, 87, 73, 84, 72, 32, 77, 247, 44, 73, 18, 26, 65, 77, 2, - 76, 65, 4, 178, 23, 77, 189, 245, 36, 11, 65, 77, 85, 72, 85, 32, 65, 76, - 65, 89, 78, 14, 34, 32, 133, 1, 3, 76, 76, 65, 4, 22, 85, 187, 85, 73, 2, + 65, 138, 4, 75, 202, 4, 82, 3, 89, 10, 22, 87, 151, 81, 73, 6, 25, 4, 73, + 84, 72, 32, 6, 206, 17, 72, 143, 16, 89, 8, 21, 3, 69, 69, 77, 8, 11, 32, + 8, 220, 32, 6, 87, 73, 84, 72, 32, 77, 219, 47, 73, 18, 26, 65, 77, 2, + 76, 65, 4, 178, 23, 77, 165, 233, 37, 11, 65, 77, 85, 72, 85, 32, 65, 76, + 65, 89, 78, 14, 34, 32, 133, 1, 3, 76, 76, 65, 4, 22, 85, 199, 89, 73, 2, 245, 9, 23, 83, 69, 68, 32, 65, 83, 32, 75, 79, 82, 65, 78, 73, 67, 32, 83, 84, 79, 80, 32, 83, 73, 71, 10, 36, 4, 65, 72, 85, 32, 147, 1, 72, 4, 212, 2, 14, 84, 65, 65, 65, 76, 65, 65, 32, 65, 76, 65, 89, 72, 73, 161, - 252, 38, 14, 65, 76, 65, 89, 72, 73, 32, 87, 65, 45, 65, 65, 76, 73, 6, - 112, 11, 85, 32, 65, 76, 65, 89, 72, 73, 32, 87, 65, 205, 63, 12, 79, 85, + 243, 39, 14, 65, 76, 65, 89, 72, 73, 32, 87, 65, 45, 65, 65, 76, 73, 6, + 112, 11, 85, 32, 65, 76, 65, 89, 72, 73, 32, 87, 65, 173, 65, 12, 79, 85, 32, 65, 76, 65, 89, 72, 69, 32, 87, 65, 4, 44, 7, 45, 65, 76, 65, 65, 32, - 65, 3, 65, 2, 33, 6, 65, 76, 73, 72, 69, 69, 2, 245, 62, 4, 32, 87, 65, + 65, 3, 65, 2, 33, 6, 65, 76, 73, 72, 69, 69, 2, 213, 64, 4, 32, 87, 65, 45, 60, 130, 1, 72, 100, 5, 74, 69, 69, 77, 32, 84, 5, 75, 72, 65, 72, - 32, 92, 5, 77, 69, 69, 77, 32, 250, 15, 65, 254, 8, 82, 3, 89, 12, 32, 3, - 65, 72, 32, 175, 21, 69, 8, 172, 14, 6, 87, 73, 84, 72, 32, 74, 186, 56, - 73, 211, 9, 77, 10, 52, 5, 87, 73, 84, 72, 32, 242, 69, 73, 211, 9, 77, - 4, 250, 12, 65, 139, 8, 72, 10, 34, 87, 178, 69, 73, 211, 9, 77, 4, 25, - 4, 73, 84, 72, 32, 4, 158, 12, 65, 203, 12, 89, 16, 52, 5, 87, 73, 84, - 72, 32, 194, 68, 73, 211, 9, 77, 10, 218, 7, 72, 174, 4, 74, 199, 11, 77, - 82, 96, 10, 65, 68, 68, 65, 32, 87, 73, 84, 72, 32, 161, 1, 9, 69, 69, - 78, 32, 87, 73, 84, 72, 32, 18, 96, 4, 68, 65, 77, 77, 0, 4, 75, 65, 83, - 82, 154, 11, 83, 245, 41, 6, 70, 65, 84, 72, 65, 32, 6, 11, 65, 6, 28, 2, - 84, 65, 227, 52, 32, 2, 179, 12, 78, 64, 130, 1, 72, 36, 5, 74, 69, 69, - 77, 32, 52, 5, 77, 69, 69, 77, 32, 186, 11, 65, 228, 4, 4, 75, 72, 65, - 72, 154, 4, 82, 3, 89, 18, 210, 15, 69, 229, 3, 2, 65, 72, 10, 174, 18, - 87, 246, 2, 70, 202, 43, 73, 211, 9, 77, 16, 64, 5, 87, 73, 84, 72, 32, - 174, 20, 70, 202, 43, 73, 211, 9, 77, 8, 140, 3, 2, 75, 72, 243, 15, 77, - 2, 175, 1, 32, 122, 66, 65, 176, 2, 8, 69, 72, 32, 87, 73, 84, 72, 32, - 179, 4, 72, 28, 88, 11, 66, 65, 65, 82, 65, 75, 65, 32, 87, 65, 45, 29, - 7, 72, 32, 87, 73, 84, 72, 32, 2, 181, 145, 28, 2, 84, 65, 26, 64, 5, 77, - 69, 69, 77, 32, 194, 8, 65, 246, 6, 72, 139, 2, 89, 14, 52, 5, 87, 73, - 84, 72, 32, 138, 61, 73, 211, 9, 77, 8, 34, 72, 174, 4, 77, 143, 12, 89, - 4, 133, 16, 2, 65, 72, 66, 138, 1, 72, 108, 3, 75, 72, 65, 12, 4, 74, 69, - 69, 77, 92, 5, 77, 69, 69, 77, 32, 238, 4, 65, 154, 5, 78, 78, 90, 242, - 2, 82, 43, 89, 14, 32, 3, 65, 72, 32, 227, 9, 69, 10, 40, 5, 87, 73, 84, - 72, 32, 243, 58, 73, 6, 182, 2, 77, 199, 11, 74, 10, 11, 72, 10, 11, 32, - 10, 40, 5, 87, 73, 84, 72, 32, 147, 58, 73, 6, 154, 1, 65, 62, 77, 143, - 12, 89, 18, 64, 5, 87, 73, 84, 72, 32, 226, 13, 70, 202, 43, 73, 211, 9, - 77, 10, 50, 65, 62, 74, 194, 7, 75, 14, 72, 195, 4, 89, 2, 217, 12, 11, - 76, 69, 70, 32, 77, 65, 75, 83, 85, 82, 65, 2, 225, 7, 3, 69, 69, 77, 28, - 56, 2, 65, 76, 117, 8, 69, 72, 32, 87, 73, 84, 72, 32, 2, 37, 7, 32, 87, - 73, 84, 72, 32, 83, 2, 197, 1, 15, 85, 80, 69, 82, 83, 67, 82, 73, 80, - 84, 32, 65, 76, 69, 70, 26, 108, 3, 74, 69, 69, 126, 65, 198, 4, 77, 86, - 78, 78, 90, 242, 2, 82, 42, 89, 213, 53, 5, 72, 69, 72, 32, 77, 2, 11, - 77, 2, 11, 32, 2, 255, 62, 73, 114, 82, 65, 38, 72, 246, 4, 78, 78, 90, - 38, 74, 98, 75, 42, 77, 198, 1, 82, 43, 89, 4, 217, 2, 5, 76, 69, 70, 32, - 77, 76, 22, 65, 139, 3, 69, 72, 80, 15, 77, 90, 65, 32, 65, 66, 79, 86, - 69, 32, 87, 73, 84, 72, 32, 147, 5, 72, 66, 118, 65, 126, 69, 42, 72, 78, - 74, 18, 75, 62, 77, 86, 78, 22, 79, 16, 2, 87, 65, 18, 89, 26, 90, 242, - 2, 82, 67, 85, 12, 22, 76, 247, 6, 69, 8, 21, 3, 69, 70, 32, 8, 34, 77, - 222, 6, 70, 231, 52, 73, 4, 181, 6, 6, 65, 75, 83, 85, 82, 65, 6, 11, 32, - 6, 166, 6, 70, 203, 43, 73, 8, 22, 69, 191, 3, 65, 4, 11, 72, 4, 11, 32, - 4, 230, 4, 73, 143, 54, 77, 4, 223, 48, 69, 2, 11, 72, 2, 11, 65, 2, 11, - 72, 2, 149, 4, 2, 32, 73, 8, 17, 2, 69, 69, 8, 11, 77, 8, 11, 32, 8, 198, - 4, 70, 202, 43, 73, 211, 9, 77, 2, 93, 2, 79, 79, 4, 231, 3, 69, 4, 215, - 3, 87, 8, 186, 3, 69, 15, 85, 2, 17, 2, 65, 73, 2, 239, 2, 78, 6, 21, 3, - 69, 69, 77, 6, 11, 32, 6, 22, 87, 191, 46, 73, 2, 141, 2, 5, 73, 84, 72, - 32, 89, 4, 11, 72, 4, 11, 65, 4, 235, 45, 72, 14, 21, 3, 69, 69, 77, 14, - 11, 32, 14, 64, 5, 87, 73, 84, 72, 32, 194, 1, 70, 202, 43, 73, 211, 9, - 77, 6, 18, 77, 75, 89, 4, 21, 3, 69, 69, 77, 4, 11, 32, 4, 18, 73, 119, - 70, 2, 211, 44, 78, 2, 17, 2, 69, 72, 2, 77, 2, 32, 70, 4, 11, 69, 4, 11, - 72, 4, 11, 32, 4, 22, 70, 231, 52, 73, 2, 185, 53, 2, 73, 78, 6, 174, 43, - 73, 211, 9, 77, 166, 2, 92, 3, 68, 68, 65, 52, 3, 82, 75, 32, 109, 11, - 84, 72, 69, 77, 65, 84, 73, 67, 65, 76, 32, 4, 168, 161, 37, 5, 32, 87, - 65, 65, 74, 131, 65, 72, 4, 58, 78, 1, 10, 83, 73, 68, 69, 87, 65, 89, - 83, 32, 78, 2, 253, 163, 35, 7, 79, 79, 78, 32, 71, 72, 85, 158, 2, 174, - 2, 68, 140, 3, 8, 73, 78, 73, 84, 73, 65, 76, 32, 222, 1, 76, 132, 2, 9, - 79, 80, 69, 82, 65, 84, 79, 82, 32, 166, 1, 83, 142, 3, 84, 182, 173, 24, - 65, 102, 75, 110, 90, 234, 106, 74, 2, 77, 250, 192, 6, 66, 2, 70, 2, 82, - 2, 89, 222, 7, 72, 222, 58, 71, 254, 136, 3, 78, 250, 168, 2, 81, 135, 3, - 87, 62, 26, 79, 143, 217, 37, 65, 58, 88, 6, 84, 76, 69, 83, 83, 32, 61, - 12, 85, 66, 76, 69, 45, 83, 84, 82, 85, 67, 75, 32, 8, 134, 229, 31, 66, - 2, 70, 182, 203, 3, 78, 251, 168, 2, 81, 50, 178, 12, 83, 174, 20, 75, - 198, 151, 24, 84, 74, 90, 234, 106, 74, 2, 77, 250, 192, 6, 66, 2, 70, 2, - 82, 2, 89, 222, 7, 72, 222, 58, 71, 254, 136, 3, 78, 154, 237, 1, 76, - 210, 58, 68, 146, 1, 81, 222, 1, 65, 171, 1, 87, 40, 182, 1, 84, 166, 9, - 83, 178, 171, 24, 72, 30, 75, 214, 107, 74, 2, 77, 250, 192, 6, 66, 2, - 70, 2, 89, 186, 66, 71, 254, 136, 3, 78, 154, 237, 1, 76, 226, 59, 81, - 222, 1, 65, 171, 57, 68, 4, 186, 225, 31, 72, 207, 244, 6, 69, 56, 48, 6, - 79, 79, 80, 69, 68, 32, 235, 197, 38, 65, 54, 202, 8, 83, 174, 20, 75, - 190, 150, 24, 65, 74, 72, 66, 84, 74, 90, 234, 106, 74, 2, 77, 250, 192, - 6, 66, 2, 70, 2, 82, 2, 89, 186, 66, 71, 254, 136, 3, 78, 154, 237, 1, - 76, 210, 58, 68, 146, 1, 81, 135, 3, 87, 4, 200, 144, 29, 23, 77, 69, 69, + 32, 92, 5, 77, 69, 69, 77, 32, 250, 15, 65, 210, 8, 82, 3, 89, 12, 32, 3, + 65, 72, 32, 175, 21, 69, 8, 172, 14, 6, 87, 73, 84, 72, 32, 74, 254, 58, + 73, 155, 11, 77, 10, 52, 5, 87, 73, 84, 72, 32, 182, 72, 73, 155, 11, 77, + 4, 250, 12, 65, 139, 8, 72, 10, 34, 87, 246, 71, 73, 155, 11, 77, 4, 25, + 4, 73, 84, 72, 32, 4, 158, 12, 65, 159, 12, 89, 16, 52, 5, 87, 73, 84, + 72, 32, 134, 71, 73, 155, 11, 77, 10, 218, 7, 72, 174, 4, 74, 167, 11, + 77, 82, 96, 10, 65, 68, 68, 65, 32, 87, 73, 84, 72, 32, 161, 1, 9, 69, + 69, 78, 32, 87, 73, 84, 72, 32, 18, 96, 4, 68, 65, 77, 77, 0, 4, 75, 65, + 83, 82, 154, 11, 83, 213, 43, 6, 70, 65, 84, 72, 65, 32, 6, 11, 65, 6, + 28, 2, 84, 65, 195, 54, 32, 2, 179, 12, 78, 64, 130, 1, 72, 36, 5, 74, + 69, 69, 77, 32, 52, 5, 77, 69, 69, 77, 32, 186, 11, 65, 196, 4, 4, 75, + 72, 65, 72, 142, 4, 82, 3, 89, 18, 210, 15, 69, 197, 3, 2, 65, 72, 10, + 142, 18, 87, 234, 2, 70, 186, 46, 73, 155, 11, 77, 16, 64, 5, 87, 73, 84, + 72, 32, 130, 20, 70, 186, 46, 73, 155, 11, 77, 8, 140, 3, 2, 75, 72, 211, + 15, 77, 2, 175, 1, 32, 122, 66, 65, 176, 2, 8, 69, 72, 32, 87, 73, 84, + 72, 32, 179, 4, 72, 28, 88, 11, 66, 65, 65, 82, 65, 75, 65, 32, 87, 65, + 45, 29, 7, 72, 32, 87, 73, 84, 72, 32, 2, 181, 255, 28, 2, 84, 65, 26, + 64, 5, 77, 69, 69, 77, 32, 194, 8, 65, 214, 6, 72, 255, 1, 89, 14, 52, 5, + 87, 73, 84, 72, 32, 206, 63, 73, 155, 11, 77, 8, 34, 72, 174, 4, 77, 227, + 11, 89, 4, 229, 15, 2, 65, 72, 66, 138, 1, 72, 108, 3, 75, 72, 65, 12, 4, + 74, 69, 69, 77, 92, 5, 77, 69, 69, 77, 32, 238, 4, 65, 250, 4, 78, 78, + 90, 230, 2, 82, 43, 89, 14, 32, 3, 65, 72, 32, 227, 9, 69, 10, 40, 5, 87, + 73, 84, 72, 32, 183, 61, 73, 6, 182, 2, 77, 167, 11, 74, 10, 11, 72, 10, + 11, 32, 10, 40, 5, 87, 73, 84, 72, 32, 215, 60, 73, 6, 154, 1, 65, 62, + 77, 227, 11, 89, 18, 64, 5, 87, 73, 84, 72, 32, 182, 13, 70, 186, 46, 73, + 155, 11, 77, 10, 50, 65, 62, 74, 194, 7, 75, 14, 72, 151, 4, 89, 2, 173, + 12, 11, 76, 69, 70, 32, 77, 65, 75, 83, 85, 82, 65, 2, 133, 55, 3, 69, + 69, 77, 28, 56, 2, 65, 76, 117, 8, 69, 72, 32, 87, 73, 84, 72, 32, 2, 37, + 7, 32, 87, 73, 84, 72, 32, 83, 2, 197, 1, 15, 85, 80, 69, 82, 83, 67, 82, + 73, 80, 84, 32, 65, 76, 69, 70, 26, 108, 3, 74, 69, 69, 126, 65, 166, 4, + 77, 86, 78, 78, 90, 230, 2, 82, 42, 89, 141, 58, 5, 72, 69, 72, 32, 77, + 2, 11, 77, 2, 11, 32, 2, 139, 67, 73, 114, 82, 65, 38, 72, 214, 4, 78, + 78, 90, 38, 74, 98, 75, 42, 77, 186, 1, 82, 43, 89, 4, 217, 2, 5, 76, 69, + 70, 32, 77, 76, 22, 65, 139, 3, 69, 72, 80, 15, 77, 90, 65, 32, 65, 66, + 79, 86, 69, 32, 87, 73, 84, 72, 32, 243, 4, 72, 66, 118, 65, 126, 69, 42, + 72, 78, 74, 18, 75, 30, 77, 86, 78, 22, 79, 16, 2, 87, 65, 18, 89, 26, + 90, 230, 2, 82, 67, 85, 12, 22, 76, 203, 6, 69, 8, 21, 3, 69, 70, 32, 8, + 34, 77, 178, 6, 70, 159, 57, 73, 4, 137, 6, 6, 65, 75, 83, 85, 82, 65, 6, + 11, 32, 6, 250, 5, 70, 187, 46, 73, 8, 22, 69, 159, 3, 65, 4, 11, 72, 4, + 11, 32, 4, 134, 48, 73, 251, 14, 77, 4, 163, 51, 69, 2, 11, 72, 2, 175, + 47, 65, 8, 17, 2, 69, 69, 8, 11, 77, 8, 11, 32, 8, 186, 4, 70, 186, 46, + 73, 155, 11, 77, 2, 93, 2, 79, 79, 4, 219, 3, 69, 4, 203, 3, 87, 8, 174, + 3, 69, 15, 85, 2, 17, 2, 65, 73, 2, 227, 2, 78, 6, 21, 3, 69, 69, 77, 6, + 11, 32, 6, 22, 87, 163, 49, 73, 2, 129, 2, 5, 73, 84, 72, 32, 89, 4, 11, + 72, 4, 11, 65, 4, 207, 48, 72, 14, 21, 3, 69, 69, 77, 14, 11, 32, 14, 64, + 5, 87, 73, 84, 72, 32, 182, 1, 70, 186, 46, 73, 155, 11, 77, 6, 18, 77, + 63, 89, 4, 21, 3, 69, 69, 77, 4, 11, 32, 4, 122, 70, 219, 42, 73, 2, 17, + 2, 69, 72, 2, 77, 2, 32, 70, 4, 11, 69, 4, 11, 72, 4, 11, 32, 4, 22, 70, + 159, 57, 73, 2, 241, 57, 2, 73, 78, 6, 158, 46, 73, 155, 11, 77, 168, 2, + 92, 3, 68, 68, 65, 52, 3, 82, 75, 32, 125, 11, 84, 72, 69, 77, 65, 84, + 73, 67, 65, 76, 32, 4, 208, 149, 38, 5, 32, 87, 65, 65, 74, 135, 68, 72, + 6, 74, 78, 0, 10, 83, 73, 68, 69, 87, 65, 89, 83, 32, 78, 215, 204, 26, + 67, 2, 145, 151, 36, 7, 79, 79, 78, 32, 71, 72, 85, 158, 2, 174, 2, 68, + 140, 3, 8, 73, 78, 73, 84, 73, 65, 76, 32, 222, 1, 76, 132, 2, 9, 79, 80, + 69, 82, 65, 84, 79, 82, 32, 166, 1, 83, 142, 3, 84, 150, 153, 25, 65, + 102, 75, 110, 90, 250, 107, 74, 2, 77, 230, 197, 6, 66, 2, 70, 2, 82, 2, + 89, 222, 7, 72, 222, 58, 71, 182, 138, 3, 78, 130, 173, 2, 81, 135, 3, + 87, 62, 26, 79, 171, 208, 38, 65, 58, 88, 6, 84, 76, 69, 83, 83, 32, 61, + 12, 85, 66, 76, 69, 45, 83, 84, 82, 85, 67, 75, 32, 8, 226, 214, 32, 66, + 2, 70, 238, 204, 3, 78, 131, 173, 2, 81, 50, 178, 12, 83, 222, 22, 75, + 246, 128, 25, 84, 74, 90, 250, 107, 74, 2, 77, 230, 197, 6, 66, 2, 70, 2, + 82, 2, 89, 222, 7, 72, 222, 58, 71, 182, 138, 3, 78, 158, 238, 1, 76, + 214, 61, 68, 146, 1, 81, 222, 1, 65, 171, 1, 87, 40, 182, 1, 84, 166, 9, + 83, 146, 151, 25, 72, 30, 75, 230, 108, 74, 2, 77, 230, 197, 6, 66, 2, + 70, 2, 89, 186, 66, 71, 182, 138, 3, 78, 158, 238, 1, 76, 230, 62, 81, + 222, 1, 65, 171, 57, 68, 4, 150, 211, 32, 72, 143, 250, 6, 69, 56, 48, 6, + 79, 79, 80, 69, 68, 32, 135, 189, 39, 65, 54, 202, 8, 83, 222, 22, 75, + 238, 255, 24, 65, 74, 72, 66, 84, 74, 90, 250, 107, 74, 2, 77, 230, 197, + 6, 66, 2, 70, 2, 82, 2, 89, 186, 66, 71, 182, 138, 3, 78, 158, 238, 1, + 76, 214, 61, 68, 146, 1, 81, 135, 3, 87, 4, 156, 128, 30, 23, 77, 69, 69, 77, 32, 87, 73, 84, 72, 32, 72, 65, 72, 32, 87, 73, 84, 72, 32, 84, 65, - 84, 87, 197, 174, 8, 9, 72, 65, 72, 32, 87, 73, 84, 72, 32, 52, 84, 9, - 84, 82, 69, 84, 67, 72, 69, 68, 32, 230, 252, 36, 72, 14, 69, 231, 143, - 1, 65, 46, 178, 1, 68, 86, 84, 250, 2, 83, 178, 171, 24, 72, 30, 75, 214, - 107, 74, 2, 77, 250, 192, 6, 66, 2, 70, 2, 89, 222, 7, 90, 222, 58, 71, - 254, 136, 3, 78, 250, 168, 2, 81, 223, 1, 65, 6, 52, 7, 79, 84, 76, 69, - 83, 83, 32, 235, 138, 38, 65, 4, 170, 219, 31, 66, 3, 70, 6, 142, 219, - 31, 72, 206, 244, 6, 65, 3, 69, 38, 42, 65, 182, 174, 24, 72, 211, 160, - 14, 69, 32, 44, 5, 73, 76, 69, 68, 32, 231, 207, 38, 72, 30, 146, 1, 68, - 94, 83, 174, 20, 75, 246, 130, 25, 74, 250, 192, 6, 89, 222, 7, 72, 222, - 58, 71, 254, 136, 3, 78, 154, 237, 1, 76, 226, 59, 81, 223, 1, 65, 6, 52, - 7, 79, 84, 76, 69, 83, 83, 32, 251, 135, 38, 65, 4, 238, 163, 35, 78, - 251, 168, 2, 81, 6, 226, 247, 36, 72, 14, 69, 231, 143, 1, 65, 4, 250, - 207, 18, 77, 231, 246, 18, 83, 6, 244, 246, 24, 3, 75, 65, 83, 12, 4, 68, - 65, 77, 77, 1, 4, 70, 65, 84, 72, 12, 118, 69, 38, 79, 220, 208, 12, 11, - 76, 65, 67, 69, 32, 79, 70, 32, 83, 65, 74, 253, 252, 5, 6, 73, 65, 83, - 84, 82, 69, 4, 254, 172, 32, 82, 199, 233, 5, 80, 4, 172, 193, 12, 8, 69, - 84, 73, 67, 32, 86, 69, 82, 169, 140, 6, 3, 85, 78, 68, 14, 238, 1, 65, - 96, 5, 69, 86, 69, 82, 83, 36, 15, 73, 71, 72, 84, 32, 65, 82, 82, 79, - 87, 72, 69, 65, 68, 32, 157, 174, 23, 28, 79, 85, 78, 68, 69, 68, 32, 72, - 73, 71, 72, 32, 83, 84, 79, 80, 32, 87, 73, 84, 72, 32, 70, 73, 76, 76, - 69, 68, 4, 40, 4, 73, 83, 69, 68, 207, 200, 38, 89, 2, 17, 2, 32, 82, 2, - 157, 250, 36, 3, 79, 85, 78, 2, 225, 229, 21, 4, 69, 68, 32, 68, 6, 26, - 65, 239, 165, 36, 66, 4, 173, 161, 37, 3, 66, 79, 86, 206, 1, 238, 1, 69, - 244, 2, 5, 72, 65, 68, 68, 65, 36, 4, 73, 71, 78, 32, 240, 4, 5, 77, 65, - 76, 76, 32, 222, 15, 85, 240, 2, 6, 89, 77, 66, 79, 76, 32, 249, 236, 36, - 18, 84, 65, 82, 84, 32, 79, 70, 32, 82, 85, 66, 32, 69, 76, 32, 72, 73, - 90, 20, 52, 7, 81, 85, 69, 78, 67, 69, 32, 139, 246, 34, 77, 18, 184, 1, - 26, 89, 69, 72, 32, 87, 73, 84, 72, 32, 72, 65, 77, 90, 65, 32, 65, 66, - 79, 86, 69, 32, 87, 73, 84, 72, 32, 245, 205, 31, 13, 78, 79, 79, 78, 32, - 87, 73, 84, 72, 32, 75, 69, 72, 16, 70, 65, 222, 196, 37, 87, 198, 89, - 89, 150, 14, 79, 214, 22, 69, 3, 85, 6, 36, 3, 76, 69, 70, 227, 194, 38, - 69, 5, 251, 12, 32, 7, 11, 32, 4, 222, 22, 73, 55, 77, 22, 132, 1, 2, 82, - 65, 158, 1, 83, 188, 1, 7, 65, 76, 65, 89, 72, 69, 32, 136, 15, 2, 77, - 73, 185, 164, 34, 6, 84, 65, 75, 72, 65, 76, 4, 132, 1, 13, 72, 77, 65, - 84, 85, 76, 76, 65, 72, 32, 65, 76, 65, 213, 201, 33, 13, 68, 73, 32, 65, - 76, 76, 65, 72, 79, 85, 32, 65, 78, 2, 143, 147, 38, 89, 12, 46, 65, 193, - 1, 6, 73, 78, 68, 72, 73, 32, 8, 136, 1, 18, 76, 76, 65, 76, 76, 65, 72, - 79, 85, 32, 65, 76, 65, 89, 72, 69, 32, 87, 206, 208, 31, 78, 218, 240, - 4, 70, 249, 115, 2, 77, 86, 2, 17, 2, 65, 83, 2, 217, 233, 15, 3, 83, 65, - 76, 4, 160, 215, 20, 12, 80, 79, 83, 84, 80, 79, 83, 73, 84, 73, 79, 78, - 129, 148, 14, 2, 65, 77, 110, 120, 2, 70, 65, 32, 5, 72, 73, 71, 72, 32, - 134, 11, 89, 88, 4, 76, 79, 87, 32, 118, 75, 158, 205, 21, 68, 139, 228, - 15, 87, 4, 166, 3, 82, 243, 187, 36, 84, 74, 212, 2, 17, 68, 79, 84, 76, - 69, 83, 83, 32, 72, 69, 65, 68, 32, 79, 70, 32, 75, 22, 70, 102, 76, 142, - 3, 77, 118, 83, 78, 84, 38, 87, 198, 2, 89, 142, 1, 78, 128, 187, 14, 18, - 85, 80, 82, 73, 71, 72, 84, 32, 82, 69, 67, 84, 65, 78, 71, 85, 76, 65, - 176, 217, 8, 7, 82, 79, 85, 78, 68, 69, 68, 166, 122, 90, 234, 106, 74, - 166, 181, 12, 81, 223, 1, 65, 2, 199, 203, 31, 72, 4, 24, 2, 65, 82, 31, - 79, 2, 11, 83, 2, 175, 2, 73, 2, 157, 193, 26, 6, 79, 84, 78, 79, 84, 69, - 10, 60, 8, 73, 71, 65, 84, 85, 82, 69, 32, 225, 11, 2, 65, 77, 8, 88, 10, + 84, 87, 141, 182, 8, 9, 72, 65, 72, 32, 87, 73, 84, 72, 32, 52, 84, 9, + 84, 82, 69, 84, 67, 72, 69, 68, 32, 242, 240, 37, 72, 14, 69, 247, 146, + 1, 65, 46, 178, 1, 68, 86, 84, 250, 2, 83, 146, 151, 25, 72, 30, 75, 230, + 108, 74, 2, 77, 230, 197, 6, 66, 2, 70, 2, 89, 222, 7, 90, 222, 58, 71, + 182, 138, 3, 78, 130, 173, 2, 81, 223, 1, 65, 6, 52, 7, 79, 84, 76, 69, + 83, 83, 32, 135, 130, 39, 65, 4, 134, 205, 32, 66, 3, 70, 6, 234, 204, + 32, 72, 142, 250, 6, 65, 3, 69, 38, 42, 65, 150, 154, 25, 72, 143, 172, + 14, 69, 32, 44, 5, 73, 76, 69, 68, 32, 131, 199, 39, 72, 30, 146, 1, 68, + 94, 83, 222, 22, 75, 182, 237, 25, 74, 230, 197, 6, 89, 222, 7, 72, 222, + 58, 71, 182, 138, 3, 78, 158, 238, 1, 76, 230, 62, 81, 223, 1, 65, 6, 52, + 7, 79, 84, 76, 69, 83, 83, 32, 151, 255, 38, 65, 4, 130, 151, 36, 78, + 131, 173, 2, 81, 6, 238, 235, 37, 72, 14, 69, 247, 146, 1, 65, 8, 108, + 17, 79, 82, 84, 72, 69, 65, 83, 84, 32, 80, 79, 73, 78, 84, 73, 78, 71, + 49, 6, 85, 77, 66, 69, 82, 32, 4, 181, 237, 5, 7, 32, 65, 82, 82, 79, 87, + 72, 4, 214, 147, 19, 77, 135, 169, 19, 83, 6, 184, 226, 25, 3, 75, 65, + 83, 12, 4, 68, 65, 77, 77, 1, 4, 70, 65, 84, 72, 12, 118, 69, 38, 79, + 192, 240, 12, 11, 76, 65, 67, 69, 32, 79, 70, 32, 83, 65, 74, 245, 160, + 6, 6, 73, 65, 83, 84, 82, 69, 4, 146, 157, 33, 82, 175, 239, 5, 80, 4, + 144, 225, 12, 8, 69, 84, 73, 67, 32, 86, 69, 82, 161, 176, 6, 3, 85, 78, + 68, 14, 238, 1, 65, 96, 5, 69, 86, 69, 82, 83, 36, 15, 73, 71, 72, 84, + 32, 65, 82, 82, 79, 87, 72, 69, 65, 68, 32, 245, 152, 24, 28, 79, 85, 78, + 68, 69, 68, 32, 72, 73, 71, 72, 32, 83, 84, 79, 80, 32, 87, 73, 84, 72, + 32, 70, 73, 76, 76, 69, 68, 4, 40, 4, 73, 83, 69, 68, 203, 190, 39, 89, + 2, 17, 2, 32, 82, 2, 161, 237, 37, 3, 79, 85, 78, 2, 137, 176, 22, 4, 69, + 68, 32, 68, 6, 26, 65, 203, 152, 37, 66, 4, 233, 150, 38, 3, 66, 79, 86, + 230, 1, 202, 2, 69, 244, 2, 5, 72, 65, 68, 68, 65, 36, 4, 73, 71, 78, 32, + 240, 4, 5, 77, 65, 76, 76, 32, 234, 17, 81, 34, 85, 240, 2, 6, 89, 77, + 66, 79, 76, 32, 184, 212, 5, 17, 79, 85, 84, 72, 87, 69, 83, 84, 32, 80, + 79, 73, 78, 84, 73, 78, 71, 177, 136, 32, 18, 84, 65, 82, 84, 32, 79, 70, + 32, 82, 85, 66, 32, 69, 76, 32, 72, 73, 90, 20, 52, 7, 81, 85, 69, 78, + 67, 69, 32, 187, 230, 35, 77, 18, 184, 1, 26, 89, 69, 72, 32, 87, 73, 84, + 72, 32, 72, 65, 77, 90, 65, 32, 65, 66, 79, 86, 69, 32, 87, 73, 84, 72, + 32, 213, 189, 32, 13, 78, 79, 79, 78, 32, 87, 73, 84, 72, 32, 75, 69, 72, + 16, 70, 65, 254, 185, 38, 87, 198, 89, 89, 150, 14, 79, 214, 22, 69, 3, + 85, 6, 36, 3, 76, 69, 70, 131, 184, 39, 69, 5, 223, 13, 32, 7, 11, 32, 4, + 138, 25, 73, 55, 77, 22, 132, 1, 2, 82, 65, 158, 1, 83, 188, 1, 7, 65, + 76, 65, 89, 72, 69, 32, 188, 16, 2, 77, 73, 217, 146, 35, 6, 84, 65, 75, + 72, 65, 76, 4, 132, 1, 13, 72, 77, 65, 84, 85, 76, 76, 65, 72, 32, 65, + 76, 65, 133, 185, 34, 13, 68, 73, 32, 65, 76, 76, 65, 72, 79, 85, 32, 65, + 78, 2, 175, 136, 39, 89, 12, 46, 65, 193, 1, 6, 73, 78, 68, 72, 73, 32, + 8, 136, 1, 18, 76, 76, 65, 76, 76, 65, 72, 79, 85, 32, 65, 76, 65, 89, + 72, 69, 32, 87, 174, 192, 32, 78, 130, 243, 4, 70, 145, 119, 2, 77, 86, + 2, 17, 2, 65, 83, 2, 221, 141, 16, 3, 83, 65, 76, 4, 136, 157, 21, 12, + 80, 79, 83, 84, 80, 79, 83, 73, 84, 73, 79, 78, 201, 190, 14, 2, 65, 77, + 130, 1, 188, 1, 9, 66, 65, 83, 69, 76, 73, 78, 69, 32, 32, 2, 70, 65, 32, + 5, 72, 73, 71, 72, 32, 158, 11, 89, 88, 4, 76, 79, 87, 32, 170, 1, 75, + 182, 149, 22, 68, 234, 226, 13, 67, 247, 172, 2, 87, 4, 150, 2, 68, 139, + 159, 33, 70, 4, 242, 2, 82, 199, 173, 37, 84, 82, 214, 1, 68, 98, 70, + 100, 2, 72, 69, 50, 76, 142, 3, 77, 118, 83, 78, 84, 38, 87, 226, 2, 89, + 154, 1, 78, 138, 1, 85, 152, 252, 23, 7, 82, 79, 85, 78, 68, 69, 68, 142, + 122, 90, 250, 107, 74, 210, 191, 12, 81, 223, 1, 65, 2, 73, 16, 79, 84, + 76, 69, 83, 83, 32, 72, 69, 65, 68, 32, 79, 70, 32, 75, 2, 243, 186, 32, + 72, 4, 24, 2, 65, 82, 31, 79, 2, 11, 83, 2, 223, 2, 73, 2, 137, 172, 27, + 6, 79, 84, 78, 79, 84, 69, 2, 11, 72, 2, 17, 2, 32, 73, 2, 247, 3, 78, + 10, 60, 8, 73, 71, 65, 84, 85, 82, 69, 32, 169, 13, 2, 65, 77, 8, 88, 10, 65, 76, 69, 70, 32, 87, 73, 84, 72, 32, 116, 3, 81, 65, 70, 1, 3, 83, 65, - 68, 4, 84, 8, 76, 65, 77, 32, 87, 73, 84, 72, 177, 196, 36, 7, 89, 69, - 72, 32, 66, 65, 82, 2, 253, 192, 31, 2, 32, 89, 2, 89, 20, 32, 87, 73, + 68, 4, 84, 8, 76, 65, 77, 32, 87, 73, 84, 72, 213, 181, 37, 7, 89, 69, + 72, 32, 66, 65, 82, 2, 249, 175, 32, 2, 32, 89, 2, 89, 20, 32, 87, 73, 84, 72, 32, 76, 65, 77, 32, 87, 73, 84, 72, 32, 65, 76, 69, 70, 32, 2, - 133, 161, 22, 3, 77, 65, 75, 6, 26, 69, 191, 130, 16, 65, 4, 17, 2, 69, - 77, 4, 17, 2, 32, 73, 4, 22, 78, 147, 9, 83, 2, 205, 9, 2, 73, 84, 6, - 164, 183, 36, 7, 73, 71, 78, 32, 83, 65, 70, 166, 39, 69, 231, 143, 1, - 65, 4, 162, 212, 23, 72, 211, 222, 14, 65, 20, 40, 4, 79, 82, 68, 32, - 151, 181, 37, 65, 18, 74, 65, 172, 1, 2, 83, 65, 220, 184, 25, 3, 87, 65, - 81, 247, 246, 11, 81, 10, 244, 133, 7, 3, 76, 45, 74, 240, 187, 18, 3, - 82, 45, 82, 240, 230, 6, 7, 84, 72, 45, 84, 72, 65, 76, 236, 136, 5, 5, - 78, 45, 78, 73, 83, 161, 92, 5, 83, 45, 83, 65, 74, 4, 238, 140, 38, 75, - 207, 36, 72, 4, 17, 2, 69, 72, 5, 233, 187, 10, 12, 32, 66, 65, 82, 82, - 69, 69, 32, 87, 73, 84, 72, 22, 50, 78, 98, 87, 222, 248, 24, 77, 199, - 224, 11, 83, 4, 21, 3, 79, 79, 78, 5, 37, 7, 32, 87, 73, 84, 72, 32, 75, - 2, 11, 65, 2, 131, 235, 37, 83, 14, 40, 4, 79, 82, 68, 32, 231, 176, 37, - 65, 12, 106, 73, 162, 251, 15, 77, 180, 177, 9, 3, 84, 65, 83, 208, 228, - 8, 2, 83, 65, 153, 228, 3, 3, 81, 65, 83, 4, 244, 159, 13, 2, 77, 65, - 157, 137, 19, 3, 83, 72, 77, 12, 138, 1, 66, 64, 3, 75, 85, 78, 193, 250, - 24, 22, 80, 69, 82, 83, 67, 82, 73, 80, 84, 32, 65, 76, 69, 70, 32, 77, - 79, 75, 72, 65, 83, 83, 2, 33, 6, 83, 67, 82, 73, 80, 84, 2, 137, 172, - 22, 2, 32, 65, 9, 11, 32, 6, 34, 73, 54, 77, 199, 137, 36, 66, 2, 11, 83, - 2, 133, 221, 31, 5, 79, 76, 65, 84, 69, 2, 11, 69, 2, 11, 68, 2, 11, 73, - 2, 169, 172, 37, 2, 65, 76, 34, 156, 1, 2, 68, 79, 126, 84, 188, 179, 5, - 8, 83, 77, 65, 76, 76, 32, 84, 65, 252, 199, 26, 4, 70, 79, 85, 82, 224, - 129, 1, 4, 87, 65, 83, 76, 187, 218, 4, 82, 6, 48, 6, 85, 66, 76, 69, 32, - 86, 139, 135, 36, 84, 2, 49, 10, 69, 82, 84, 73, 67, 65, 76, 32, 66, 65, - 2, 207, 247, 35, 82, 16, 88, 10, 72, 82, 69, 69, 32, 68, 79, 84, 83, 32, - 121, 8, 87, 79, 32, 68, 79, 84, 83, 32, 8, 244, 250, 31, 17, 80, 79, 73, - 78, 84, 73, 78, 71, 32, 68, 79, 87, 78, 87, 65, 82, 68, 150, 139, 4, 66, - 131, 165, 1, 65, 8, 204, 177, 10, 9, 86, 69, 82, 84, 73, 67, 65, 76, 76, - 198, 211, 25, 66, 131, 165, 1, 65, 30, 202, 1, 65, 152, 2, 4, 79, 78, 69, - 32, 240, 249, 10, 12, 82, 73, 80, 76, 69, 32, 68, 79, 84, 32, 80, 85, - 196, 201, 6, 8, 85, 82, 78, 69, 68, 32, 68, 65, 249, 149, 14, 8, 72, 79, - 85, 83, 65, 78, 68, 83, 12, 68, 5, 84, 87, 69, 69, 76, 229, 133, 36, 6, - 73, 76, 32, 70, 82, 65, 11, 33, 6, 32, 87, 73, 84, 72, 32, 8, 112, 11, - 79, 86, 69, 82, 83, 84, 82, 85, 67, 75, 32, 140, 201, 5, 7, 70, 65, 84, - 72, 65, 84, 65, 235, 228, 4, 84, 4, 26, 72, 183, 164, 37, 87, 2, 185, - 244, 29, 2, 65, 77, 12, 68, 3, 79, 78, 69, 246, 149, 30, 84, 245, 233, 5, - 4, 76, 79, 79, 80, 4, 225, 253, 33, 2, 32, 68, 8, 64, 10, 79, 87, 69, 76, - 32, 83, 73, 71, 78, 32, 179, 148, 24, 69, 6, 72, 10, 73, 78, 86, 69, 82, - 84, 69, 68, 32, 83, 2, 83, 135, 206, 25, 68, 2, 25, 4, 77, 65, 76, 76, 2, - 173, 163, 37, 2, 32, 86, 28, 104, 4, 80, 69, 82, 32, 236, 249, 5, 3, 67, - 85, 66, 152, 134, 5, 5, 70, 79, 85, 82, 84, 163, 171, 25, 68, 4, 158, - 153, 25, 77, 31, 84, 188, 1, 222, 1, 65, 34, 67, 138, 3, 69, 60, 7, 83, - 77, 65, 76, 76, 32, 76, 200, 143, 21, 17, 77, 79, 68, 73, 70, 73, 69, 82, - 32, 76, 69, 84, 84, 69, 82, 32, 76, 146, 249, 8, 72, 140, 188, 2, 3, 68, - 82, 65, 178, 255, 2, 70, 83, 81, 4, 142, 220, 31, 66, 143, 26, 80, 78, - 80, 14, 65, 80, 73, 84, 65, 76, 32, 76, 69, 84, 84, 69, 82, 32, 243, 198, - 35, 79, 76, 250, 1, 84, 36, 2, 89, 73, 150, 3, 67, 38, 82, 34, 69, 42, - 71, 34, 74, 38, 75, 22, 80, 38, 83, 106, 65, 22, 86, 158, 1, 76, 170, - 157, 31, 70, 2, 88, 134, 241, 1, 73, 214, 174, 3, 66, 2, 77, 222, 57, 78, - 230, 28, 90, 210, 96, 72, 190, 28, 68, 171, 1, 79, 4, 138, 196, 36, 73, - 179, 214, 1, 79, 5, 183, 202, 37, 87, 4, 214, 245, 31, 88, 233, 210, 4, - 6, 77, 80, 72, 65, 83, 73, 92, 76, 6, 69, 84, 84, 69, 82, 32, 157, 5, 8, - 73, 71, 65, 84, 85, 82, 69, 32, 80, 242, 1, 67, 38, 82, 34, 69, 42, 71, - 34, 74, 38, 75, 22, 80, 38, 83, 34, 84, 74, 65, 22, 86, 32, 2, 89, 73, - 126, 76, 170, 157, 31, 70, 2, 88, 134, 241, 1, 73, 214, 174, 3, 66, 2, - 77, 222, 57, 78, 230, 28, 90, 210, 96, 72, 190, 28, 68, 171, 1, 79, 8, - 34, 72, 226, 150, 38, 65, 3, 79, 4, 206, 149, 38, 69, 147, 1, 65, 6, 174, - 149, 38, 67, 146, 1, 72, 3, 84, 4, 234, 207, 37, 72, 215, 53, 73, 4, 154, - 160, 31, 72, 223, 245, 6, 65, 4, 147, 234, 33, 69, 4, 214, 251, 3, 73, - 219, 152, 34, 69, 4, 226, 146, 38, 72, 171, 1, 69, 6, 68, 7, 85, 82, 78, - 69, 68, 32, 65, 134, 190, 36, 73, 179, 214, 1, 79, 2, 187, 214, 36, 89, - 4, 254, 149, 37, 69, 163, 126, 79, 7, 194, 183, 21, 32, 223, 140, 16, 87, - 12, 84, 5, 69, 67, 72, 32, 89, 20, 4, 77, 69, 78, 32, 145, 254, 29, 4, - 86, 69, 87, 32, 2, 211, 188, 36, 73, 8, 146, 157, 31, 88, 134, 241, 1, - 73, 178, 232, 3, 78, 131, 122, 69, 14, 108, 10, 32, 80, 79, 73, 78, 84, - 73, 78, 71, 32, 189, 209, 36, 11, 72, 69, 65, 68, 45, 83, 72, 65, 80, 69, - 68, 12, 156, 2, 24, 82, 73, 71, 72, 84, 87, 65, 82, 68, 83, 32, 84, 72, - 69, 78, 32, 67, 85, 82, 86, 73, 78, 71, 32, 48, 16, 85, 80, 87, 65, 82, - 68, 83, 32, 84, 72, 69, 78, 32, 78, 79, 82, 249, 172, 35, 22, 68, 79, 87, - 78, 87, 65, 82, 68, 83, 32, 84, 72, 69, 78, 32, 67, 85, 82, 86, 73, 78, - 71, 6, 44, 3, 83, 79, 85, 146, 221, 26, 68, 35, 85, 2, 205, 156, 34, 4, - 84, 72, 32, 87, 4, 228, 200, 31, 11, 67, 85, 76, 65, 84, 69, 68, 32, 76, - 79, 82, 189, 252, 4, 6, 83, 84, 32, 80, 65, 76, 24, 58, 67, 38, 84, 202, - 168, 23, 89, 201, 197, 9, 2, 83, 69, 4, 242, 177, 8, 69, 167, 186, 11, - 73, 16, 48, 4, 69, 82, 73, 83, 36, 2, 79, 78, 31, 82, 6, 174, 227, 2, 75, - 163, 169, 35, 77, 2, 185, 130, 14, 2, 73, 83, 8, 104, 20, 79, 78, 79, 77, - 73, 67, 65, 76, 32, 83, 89, 77, 66, 79, 76, 32, 70, 79, 82, 32, 159, 130, - 14, 65, 4, 216, 210, 25, 13, 65, 83, 84, 69, 82, 79, 73, 68, 32, 80, 82, - 79, 83, 205, 175, 10, 2, 85, 82, 4, 164, 185, 19, 6, 72, 76, 69, 84, 73, - 67, 217, 187, 17, 2, 79, 77, 10, 68, 2, 84, 79, 160, 237, 21, 2, 83, 84, - 133, 165, 2, 3, 66, 69, 82, 6, 54, 77, 213, 138, 37, 7, 32, 82, 73, 67, - 75, 83, 72, 4, 214, 145, 24, 79, 209, 202, 5, 12, 65, 84, 69, 68, 32, 84, - 69, 76, 76, 69, 82, 32, 112, 56, 6, 69, 83, 84, 65, 78, 32, 169, 227, 4, - 2, 79, 67, 110, 52, 7, 76, 69, 84, 84, 69, 82, 32, 147, 198, 31, 65, 108, - 234, 1, 65, 58, 71, 42, 72, 34, 78, 50, 88, 42, 83, 42, 89, 34, 84, 178, - 172, 34, 85, 206, 141, 1, 79, 238, 60, 73, 166, 140, 1, 66, 2, 68, 2, 90, - 130, 64, 69, 206, 41, 67, 2, 70, 2, 74, 2, 75, 2, 76, 2, 77, 2, 80, 2, - 82, 3, 86, 17, 234, 181, 35, 65, 194, 143, 2, 69, 162, 64, 78, 3, 79, 6, - 190, 238, 37, 71, 2, 72, 215, 22, 69, 4, 150, 238, 37, 77, 215, 22, 69, - 12, 46, 71, 202, 237, 37, 78, 2, 89, 215, 22, 69, 6, 198, 237, 37, 86, 2, - 89, 215, 22, 69, 8, 38, 72, 194, 214, 37, 83, 143, 45, 69, 4, 246, 236, - 37, 89, 215, 22, 69, 6, 214, 236, 37, 72, 2, 84, 215, 22, 69, 178, 42, - 178, 1, 65, 194, 171, 1, 69, 244, 21, 9, 72, 65, 73, 75, 83, 85, 75, 73, - 32, 202, 6, 73, 130, 3, 76, 182, 45, 79, 138, 70, 82, 246, 18, 85, 138, - 8, 89, 138, 167, 35, 80, 147, 1, 83, 198, 14, 132, 1, 2, 66, 89, 94, 67, - 206, 2, 68, 146, 1, 71, 106, 76, 192, 29, 4, 77, 85, 77, 32, 190, 115, - 78, 178, 1, 82, 98, 83, 223, 6, 84, 11, 11, 32, 8, 174, 245, 12, 67, 146, - 245, 5, 66, 196, 128, 14, 3, 65, 78, 71, 135, 128, 4, 83, 16, 62, 75, - 244, 131, 9, 5, 84, 82, 73, 65, 78, 211, 171, 28, 79, 12, 42, 32, 46, 83, - 221, 227, 10, 2, 45, 84, 4, 162, 129, 10, 87, 229, 229, 20, 2, 79, 70, 6, - 132, 1, 26, 76, 65, 78, 84, 69, 68, 32, 83, 79, 85, 84, 72, 32, 65, 82, - 82, 79, 87, 32, 87, 73, 84, 72, 32, 72, 79, 191, 192, 37, 80, 4, 190, - 204, 29, 82, 165, 193, 5, 2, 79, 75, 4, 148, 139, 35, 27, 77, 73, 78, 84, - 79, 78, 32, 82, 65, 67, 81, 85, 69, 84, 32, 65, 78, 68, 32, 83, 72, 85, - 84, 84, 76, 69, 67, 151, 180, 2, 71, 6, 148, 242, 30, 6, 85, 69, 84, 84, - 69, 32, 162, 254, 5, 69, 129, 9, 8, 71, 65, 71, 69, 32, 67, 76, 65, 156, - 2, 44, 6, 73, 78, 69, 83, 69, 32, 183, 25, 76, 254, 1, 132, 3, 6, 67, 65, - 82, 73, 75, 32, 84, 15, 73, 78, 86, 69, 82, 84, 69, 68, 32, 67, 65, 82, - 73, 75, 32, 68, 7, 76, 69, 84, 84, 69, 82, 32, 224, 8, 15, 77, 85, 83, - 73, 67, 65, 76, 32, 83, 89, 77, 66, 79, 76, 32, 196, 6, 2, 80, 65, 184, - 1, 5, 83, 73, 71, 78, 32, 176, 1, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, - 78, 32, 168, 176, 14, 5, 65, 68, 69, 71, 32, 234, 150, 19, 87, 167, 169, - 2, 68, 6, 32, 2, 80, 65, 167, 136, 3, 83, 4, 86, 82, 229, 136, 31, 5, 77, - 85, 78, 71, 75, 4, 36, 3, 80, 65, 82, 207, 135, 3, 83, 2, 221, 160, 36, + 189, 243, 22, 3, 77, 65, 75, 6, 26, 69, 223, 165, 16, 65, 4, 17, 2, 69, + 77, 4, 17, 2, 32, 73, 4, 22, 78, 219, 10, 83, 2, 149, 11, 2, 73, 84, 6, + 200, 168, 37, 7, 73, 71, 78, 32, 83, 65, 70, 174, 39, 69, 247, 146, 1, + 65, 4, 166, 189, 24, 72, 139, 234, 14, 65, 22, 40, 4, 79, 82, 68, 32, + 211, 169, 38, 65, 20, 102, 65, 172, 1, 2, 83, 65, 192, 156, 26, 4, 75, + 65, 66, 66, 148, 6, 3, 87, 65, 81, 159, 129, 12, 81, 10, 232, 162, 7, 3, + 76, 45, 74, 244, 136, 19, 3, 82, 45, 82, 176, 235, 6, 7, 84, 72, 45, 84, + 72, 65, 76, 212, 142, 5, 5, 78, 45, 78, 73, 83, 161, 92, 5, 83, 45, 83, + 65, 74, 4, 142, 129, 39, 75, 207, 36, 72, 4, 17, 2, 69, 72, 5, 137, 218, + 10, 12, 32, 66, 65, 82, 82, 69, 69, 32, 87, 73, 84, 72, 28, 62, 78, 138, + 1, 85, 90, 87, 198, 225, 25, 77, 227, 231, 11, 83, 8, 21, 3, 79, 79, 78, + 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 42, 75, 182, 149, 22, 68, 147, 254, + 10, 70, 2, 11, 65, 2, 239, 222, 38, 83, 2, 165, 216, 14, 17, 80, 82, 73, + 71, 72, 84, 32, 82, 69, 67, 84, 65, 78, 71, 85, 76, 65, 14, 40, 4, 79, + 82, 68, 32, 251, 163, 38, 65, 12, 106, 73, 154, 157, 16, 77, 164, 248, 9, + 3, 84, 65, 83, 132, 233, 8, 2, 83, 65, 145, 234, 3, 3, 81, 65, 83, 4, + 240, 188, 13, 2, 77, 65, 205, 217, 19, 3, 83, 72, 77, 2, 141, 141, 31, 3, + 85, 65, 82, 12, 138, 1, 66, 64, 3, 75, 85, 78, 137, 227, 25, 22, 80, 69, + 82, 83, 67, 82, 73, 80, 84, 32, 65, 76, 69, 70, 32, 77, 79, 75, 72, 65, + 83, 83, 2, 33, 6, 83, 67, 82, 73, 80, 84, 2, 225, 167, 23, 2, 32, 65, 9, + 11, 32, 6, 34, 73, 54, 77, 155, 249, 36, 66, 2, 11, 83, 2, 185, 202, 32, + 5, 79, 76, 65, 84, 69, 2, 11, 69, 2, 11, 68, 2, 11, 73, 2, 157, 159, 38, + 2, 65, 76, 34, 156, 1, 2, 68, 79, 126, 84, 156, 184, 5, 8, 83, 77, 65, + 76, 76, 32, 84, 65, 196, 176, 27, 4, 70, 79, 85, 82, 220, 129, 1, 4, 87, + 65, 83, 76, 139, 224, 4, 82, 6, 48, 6, 85, 66, 76, 69, 32, 86, 223, 246, + 36, 84, 2, 49, 10, 69, 82, 84, 73, 67, 65, 76, 32, 66, 65, 2, 199, 230, + 36, 82, 16, 88, 10, 72, 82, 69, 69, 32, 68, 79, 84, 83, 32, 121, 8, 87, + 79, 32, 68, 79, 84, 83, 32, 8, 156, 232, 32, 17, 80, 79, 73, 78, 84, 73, + 78, 71, 32, 68, 79, 87, 78, 87, 65, 82, 68, 194, 141, 4, 66, 163, 168, 1, + 65, 8, 192, 206, 10, 9, 86, 69, 82, 84, 73, 67, 65, 76, 76, 166, 166, 26, + 66, 163, 168, 1, 65, 30, 202, 1, 65, 152, 2, 4, 79, 78, 69, 32, 140, 151, + 11, 12, 82, 73, 80, 76, 69, 32, 68, 79, 84, 32, 80, 85, 156, 224, 6, 8, + 85, 82, 78, 69, 68, 32, 68, 65, 185, 207, 14, 8, 72, 79, 85, 83, 65, 78, + 68, 83, 12, 68, 5, 84, 87, 69, 69, 76, 185, 245, 36, 6, 73, 76, 32, 70, + 82, 65, 11, 33, 6, 32, 87, 73, 84, 72, 32, 8, 112, 11, 79, 86, 69, 82, + 83, 84, 82, 85, 67, 75, 32, 228, 205, 5, 7, 70, 65, 84, 72, 65, 84, 65, + 135, 253, 4, 84, 4, 26, 72, 171, 151, 38, 87, 2, 213, 223, 30, 2, 65, 77, + 12, 68, 3, 79, 78, 69, 162, 129, 31, 84, 157, 238, 5, 4, 76, 79, 79, 80, + 4, 233, 234, 34, 2, 32, 68, 8, 64, 10, 79, 87, 69, 76, 32, 83, 73, 71, + 78, 32, 235, 251, 24, 69, 6, 72, 10, 73, 78, 86, 69, 82, 84, 69, 68, 32, + 83, 2, 83, 227, 182, 26, 68, 2, 25, 4, 77, 65, 76, 76, 2, 161, 150, 38, + 2, 32, 86, 28, 104, 4, 80, 69, 82, 32, 160, 157, 11, 5, 70, 79, 85, 82, + 84, 252, 178, 20, 3, 67, 85, 66, 231, 202, 5, 68, 4, 230, 129, 26, 77, + 31, 84, 188, 1, 214, 1, 65, 34, 67, 138, 3, 69, 56, 7, 83, 77, 65, 76, + 76, 32, 76, 224, 212, 21, 17, 77, 79, 68, 73, 70, 73, 69, 82, 32, 76, 69, + 84, 84, 69, 82, 32, 76, 178, 159, 9, 72, 200, 212, 4, 2, 68, 82, 194, + 106, 70, 83, 81, 4, 202, 201, 32, 66, 131, 26, 80, 78, 80, 14, 65, 80, + 73, 84, 65, 76, 32, 76, 69, 84, 84, 69, 82, 32, 243, 181, 36, 79, 76, + 250, 1, 84, 36, 2, 89, 73, 146, 3, 67, 38, 82, 34, 69, 42, 71, 34, 74, + 38, 75, 22, 80, 38, 83, 106, 65, 22, 86, 158, 1, 76, 234, 138, 32, 70, 2, + 88, 214, 240, 1, 73, 182, 177, 3, 66, 2, 77, 182, 60, 78, 158, 29, 90, + 210, 96, 72, 190, 28, 68, 171, 1, 79, 4, 246, 179, 37, 73, 195, 217, 1, + 79, 5, 179, 189, 38, 87, 4, 168, 184, 37, 6, 77, 80, 72, 65, 83, 73, 167, + 56, 88, 92, 76, 6, 69, 84, 84, 69, 82, 32, 157, 5, 8, 73, 71, 65, 84, 85, + 82, 69, 32, 80, 242, 1, 67, 38, 82, 34, 69, 42, 71, 34, 74, 38, 75, 22, + 80, 38, 83, 34, 84, 74, 65, 22, 86, 32, 2, 89, 73, 126, 76, 234, 138, 32, + 70, 2, 88, 214, 240, 1, 73, 182, 177, 3, 66, 2, 77, 182, 60, 78, 158, 29, + 90, 210, 96, 72, 190, 28, 68, 171, 1, 79, 8, 34, 72, 226, 137, 39, 65, 3, + 79, 4, 206, 136, 39, 69, 147, 1, 65, 6, 174, 136, 39, 67, 146, 1, 72, 3, + 84, 4, 234, 194, 38, 72, 215, 53, 73, 4, 218, 141, 32, 72, 159, 251, 6, + 65, 4, 167, 215, 34, 69, 4, 142, 254, 3, 73, 163, 137, 35, 69, 4, 226, + 133, 39, 72, 171, 1, 69, 6, 68, 7, 85, 82, 78, 69, 68, 32, 65, 246, 173, + 37, 73, 195, 217, 1, 79, 2, 183, 198, 37, 89, 4, 254, 136, 38, 69, 163, + 126, 79, 7, 226, 226, 22, 32, 191, 212, 15, 87, 12, 84, 5, 69, 67, 72, + 32, 89, 20, 4, 77, 69, 78, 32, 201, 233, 30, 4, 86, 69, 87, 32, 2, 195, + 172, 37, 73, 8, 210, 138, 32, 88, 214, 240, 1, 73, 234, 237, 3, 78, 187, + 122, 69, 14, 108, 10, 32, 80, 79, 73, 78, 84, 73, 78, 71, 32, 185, 193, + 37, 11, 72, 69, 65, 68, 45, 83, 72, 65, 80, 69, 68, 12, 156, 2, 24, 82, + 73, 71, 72, 84, 87, 65, 82, 68, 83, 32, 84, 72, 69, 78, 32, 67, 85, 82, + 86, 73, 78, 71, 32, 48, 16, 85, 80, 87, 65, 82, 68, 83, 32, 84, 72, 69, + 78, 32, 78, 79, 82, 253, 155, 36, 22, 68, 79, 87, 78, 87, 65, 82, 68, 83, + 32, 84, 72, 69, 78, 32, 67, 85, 82, 86, 73, 78, 71, 6, 44, 3, 83, 79, 85, + 246, 198, 27, 68, 35, 85, 2, 209, 138, 35, 4, 84, 72, 32, 87, 4, 164, + 182, 32, 11, 67, 85, 76, 65, 84, 69, 68, 32, 76, 79, 82, 133, 255, 4, 6, + 83, 84, 32, 80, 65, 76, 24, 58, 67, 38, 84, 146, 144, 24, 89, 153, 203, + 9, 2, 83, 69, 4, 202, 205, 8, 69, 155, 225, 11, 73, 16, 48, 4, 69, 82, + 73, 83, 48, 2, 79, 78, 31, 82, 6, 26, 75, 183, 255, 38, 77, 5, 131, 183, + 35, 32, 2, 161, 159, 14, 2, 73, 83, 8, 104, 20, 79, 78, 79, 77, 73, 67, + 65, 76, 32, 83, 89, 77, 66, 79, 76, 32, 70, 79, 82, 32, 135, 159, 14, 65, + 4, 180, 187, 26, 13, 65, 83, 84, 69, 82, 79, 73, 68, 32, 80, 82, 79, 83, + 205, 182, 10, 2, 85, 82, 4, 216, 250, 19, 6, 72, 76, 69, 84, 73, 67, 153, + 237, 17, 2, 79, 77, 10, 68, 2, 84, 79, 248, 188, 22, 2, 83, 84, 153, 189, + 2, 3, 66, 69, 82, 6, 54, 77, 201, 253, 37, 7, 32, 82, 73, 67, 75, 83, 72, + 4, 194, 249, 24, 79, 129, 206, 5, 12, 65, 84, 69, 68, 32, 84, 69, 76, 76, + 69, 82, 32, 112, 56, 6, 69, 83, 84, 65, 78, 32, 157, 231, 4, 2, 79, 67, + 110, 52, 7, 76, 69, 84, 84, 69, 82, 32, 199, 179, 32, 65, 108, 234, 1, + 65, 58, 71, 42, 72, 34, 78, 50, 88, 42, 83, 42, 89, 34, 84, 182, 154, 35, + 85, 194, 142, 1, 79, 202, 61, 73, 198, 143, 1, 66, 2, 68, 2, 90, 130, 64, + 69, 206, 41, 67, 2, 70, 2, 74, 2, 75, 2, 76, 2, 77, 2, 80, 2, 82, 3, 86, + 17, 226, 164, 36, 65, 190, 147, 2, 69, 162, 64, 78, 3, 79, 6, 178, 225, + 38, 71, 2, 72, 215, 22, 69, 4, 138, 225, 38, 77, 215, 22, 69, 12, 46, 71, + 190, 224, 38, 78, 2, 89, 215, 22, 69, 6, 186, 224, 38, 86, 2, 89, 215, + 22, 69, 8, 38, 72, 182, 201, 38, 83, 143, 45, 69, 4, 234, 223, 38, 89, + 215, 22, 69, 6, 202, 223, 38, 72, 2, 84, 215, 22, 69, 186, 42, 178, 1, + 65, 190, 171, 1, 69, 180, 23, 9, 72, 65, 73, 75, 83, 85, 75, 73, 32, 202, + 6, 73, 130, 3, 76, 210, 45, 79, 138, 70, 82, 246, 18, 85, 186, 8, 89, + 246, 151, 36, 80, 147, 1, 83, 198, 14, 132, 1, 2, 66, 89, 94, 67, 206, 2, + 68, 146, 1, 71, 106, 76, 192, 29, 4, 77, 85, 77, 32, 190, 115, 78, 178, + 1, 82, 98, 83, 219, 6, 84, 11, 11, 32, 8, 138, 146, 13, 67, 146, 153, 6, + 66, 244, 172, 14, 3, 65, 78, 71, 239, 133, 4, 83, 16, 62, 75, 232, 160, + 9, 5, 84, 82, 73, 65, 78, 211, 129, 29, 79, 12, 42, 32, 46, 83, 253, 128, + 11, 2, 45, 84, 4, 150, 158, 10, 87, 165, 182, 21, 2, 79, 70, 6, 132, 1, + 26, 76, 65, 78, 84, 69, 68, 32, 83, 79, 85, 84, 72, 32, 65, 82, 82, 79, + 87, 32, 87, 73, 84, 72, 32, 72, 79, 179, 179, 38, 80, 4, 218, 183, 30, + 82, 129, 197, 5, 2, 79, 75, 4, 140, 250, 35, 27, 77, 73, 78, 84, 79, 78, + 32, 82, 65, 67, 81, 85, 69, 84, 32, 65, 78, 68, 32, 83, 72, 85, 84, 84, + 76, 69, 67, 147, 184, 2, 71, 6, 200, 223, 31, 6, 85, 69, 84, 84, 69, 32, + 226, 131, 6, 69, 129, 9, 8, 71, 65, 71, 69, 32, 67, 76, 65, 156, 2, 44, + 6, 73, 78, 69, 83, 69, 32, 183, 25, 76, 254, 1, 132, 3, 6, 67, 65, 82, + 73, 75, 32, 84, 15, 73, 78, 86, 69, 82, 84, 69, 68, 32, 67, 65, 82, 73, + 75, 32, 68, 7, 76, 69, 84, 84, 69, 82, 32, 224, 8, 15, 77, 85, 83, 73, + 67, 65, 76, 32, 83, 89, 77, 66, 79, 76, 32, 196, 6, 2, 80, 65, 184, 1, 5, + 83, 73, 71, 78, 32, 176, 1, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, + 32, 184, 207, 14, 5, 65, 68, 69, 71, 32, 214, 228, 19, 87, 135, 172, 2, + 68, 6, 32, 2, 80, 65, 171, 138, 3, 83, 4, 86, 82, 153, 246, 31, 5, 77, + 85, 78, 71, 75, 4, 36, 3, 80, 65, 82, 211, 137, 3, 83, 2, 193, 144, 37, 2, 69, 82, 110, 166, 2, 65, 112, 2, 66, 65, 32, 2, 67, 65, 32, 2, 68, 65, 110, 69, 32, 2, 71, 65, 30, 73, 2, 79, 2, 85, 36, 2, 74, 65, 30, 75, 68, 2, 76, 65, 18, 78, 72, 2, 80, 65, 36, 2, 82, 65, 16, 2, 83, 65, 54, 84, - 128, 1, 2, 86, 69, 0, 3, 90, 65, 76, 206, 235, 37, 72, 2, 77, 2, 87, 3, - 89, 10, 226, 2, 75, 184, 3, 5, 83, 89, 85, 82, 65, 184, 170, 15, 8, 82, - 67, 72, 65, 73, 67, 32, 74, 187, 255, 3, 73, 5, 197, 130, 19, 3, 32, 75, - 69, 5, 213, 135, 31, 3, 32, 76, 65, 9, 17, 2, 32, 77, 6, 44, 5, 85, 82, - 68, 65, 32, 155, 213, 33, 65, 4, 202, 187, 14, 77, 25, 3, 65, 76, 80, 4, - 254, 3, 70, 187, 169, 37, 75, 5, 141, 253, 34, 2, 32, 71, 4, 11, 75, 4, - 161, 15, 2, 65, 82, 5, 173, 223, 35, 2, 32, 74, 8, 34, 65, 225, 2, 3, 72, - 79, 84, 7, 222, 2, 70, 155, 183, 14, 32, 7, 131, 13, 32, 8, 34, 65, 218, - 237, 37, 71, 3, 89, 5, 157, 135, 27, 4, 32, 82, 65, 77, 5, 141, 228, 36, - 4, 32, 75, 65, 80, 7, 167, 12, 32, 7, 21, 3, 32, 83, 65, 4, 230, 236, 37, - 71, 3, 80, 10, 30, 65, 97, 3, 90, 73, 82, 9, 11, 32, 6, 232, 183, 14, 6, - 77, 85, 82, 68, 65, 32, 212, 7, 3, 76, 65, 84, 179, 181, 18, 84, 2, 137, - 180, 14, 2, 32, 83, 56, 168, 1, 10, 67, 79, 77, 66, 73, 78, 73, 78, 71, + 128, 1, 2, 86, 69, 0, 3, 90, 65, 76, 194, 222, 38, 72, 2, 77, 2, 87, 3, + 89, 10, 226, 2, 75, 184, 3, 5, 83, 89, 85, 82, 65, 144, 204, 15, 8, 82, + 67, 72, 65, 73, 67, 32, 74, 151, 159, 4, 73, 5, 249, 195, 19, 3, 32, 75, + 69, 5, 137, 245, 31, 3, 32, 76, 65, 9, 17, 2, 32, 77, 6, 44, 5, 85, 82, + 68, 65, 32, 151, 194, 34, 65, 4, 218, 218, 14, 77, 25, 3, 65, 76, 80, 4, + 254, 3, 70, 175, 156, 38, 75, 5, 133, 236, 35, 2, 32, 71, 4, 11, 75, 4, + 161, 15, 2, 65, 82, 5, 129, 207, 36, 2, 32, 74, 8, 34, 65, 225, 2, 3, 72, + 79, 84, 7, 222, 2, 70, 171, 214, 14, 32, 7, 131, 13, 32, 8, 34, 65, 206, + 224, 38, 71, 3, 89, 5, 145, 241, 27, 4, 32, 82, 65, 77, 5, 129, 215, 37, + 4, 32, 75, 65, 80, 7, 167, 12, 32, 7, 21, 3, 32, 83, 65, 4, 218, 223, 38, + 71, 3, 80, 10, 30, 65, 97, 3, 90, 73, 82, 9, 11, 32, 6, 248, 214, 14, 6, + 77, 85, 82, 68, 65, 32, 212, 7, 3, 76, 65, 84, 167, 131, 19, 84, 2, 153, + 211, 14, 2, 32, 83, 56, 168, 1, 10, 67, 79, 77, 66, 73, 78, 73, 78, 71, 32, 246, 1, 68, 172, 1, 10, 76, 69, 70, 84, 45, 72, 65, 78, 68, 32, 117, 11, 82, 73, 71, 72, 84, 45, 72, 65, 78, 68, 32, 18, 132, 1, 4, 75, 69, - 77, 80, 78, 74, 168, 146, 20, 2, 66, 69, 220, 182, 7, 3, 69, 78, 68, 136, - 172, 3, 3, 84, 69, 71, 207, 174, 4, 71, 8, 32, 2, 76, 73, 1, 2, 85, 76, - 5, 37, 7, 32, 87, 73, 84, 72, 32, 74, 2, 133, 174, 14, 3, 69, 71, 79, 20, - 50, 65, 90, 69, 198, 152, 37, 73, 2, 79, 3, 85, 10, 40, 2, 78, 71, 242, - 152, 37, 69, 3, 73, 7, 11, 32, 4, 218, 4, 83, 247, 254, 10, 71, 4, 194, - 152, 37, 85, 167, 80, 78, 10, 76, 6, 79, 80, 69, 78, 32, 80, 113, 9, 67, - 76, 79, 83, 69, 68, 32, 80, 76, 6, 210, 151, 37, 65, 2, 73, 3, 85, 8, 72, - 8, 67, 76, 79, 83, 69, 68, 32, 84, 29, 6, 79, 80, 69, 78, 32, 68, 4, 194, - 228, 37, 65, 3, 85, 4, 234, 230, 37, 65, 3, 85, 12, 30, 77, 69, 3, 78, - 84, 73, 6, 44, 3, 65, 68, 65, 245, 159, 35, 2, 69, 78, 5, 69, 2, 32, 76, - 7, 11, 32, 4, 38, 76, 133, 173, 35, 3, 66, 65, 87, 2, 181, 141, 37, 3, - 65, 78, 84, 12, 106, 83, 20, 4, 85, 76, 85, 32, 254, 239, 30, 67, 240, 6, - 3, 66, 73, 83, 133, 255, 1, 4, 82, 69, 82, 69, 2, 223, 242, 24, 85, 4, - 210, 209, 20, 67, 237, 128, 17, 3, 82, 73, 67, 30, 120, 3, 76, 65, 32, + 77, 80, 78, 74, 228, 213, 20, 2, 66, 69, 204, 222, 7, 3, 69, 78, 68, 144, + 174, 3, 3, 84, 69, 71, 147, 176, 4, 71, 8, 32, 2, 76, 73, 1, 2, 85, 76, + 5, 37, 7, 32, 87, 73, 84, 72, 32, 74, 2, 149, 205, 14, 3, 69, 71, 79, 20, + 50, 65, 90, 69, 186, 139, 38, 73, 2, 79, 3, 85, 10, 40, 2, 78, 71, 230, + 139, 38, 69, 3, 73, 7, 11, 32, 4, 218, 4, 83, 227, 155, 11, 71, 4, 182, + 139, 38, 85, 167, 80, 78, 10, 76, 6, 79, 80, 69, 78, 32, 80, 113, 9, 67, + 76, 79, 83, 69, 68, 32, 80, 76, 6, 198, 138, 38, 65, 2, 73, 3, 85, 8, 72, + 8, 67, 76, 79, 83, 69, 68, 32, 84, 29, 6, 79, 80, 69, 78, 32, 68, 4, 182, + 215, 38, 65, 3, 85, 4, 222, 217, 38, 65, 3, 85, 12, 30, 77, 69, 3, 78, + 84, 73, 6, 44, 3, 65, 68, 65, 237, 142, 36, 2, 69, 78, 5, 69, 2, 32, 76, + 7, 11, 32, 4, 38, 76, 253, 155, 36, 3, 66, 65, 87, 2, 169, 128, 38, 3, + 65, 78, 84, 12, 106, 83, 20, 4, 85, 76, 85, 32, 178, 221, 31, 67, 240, 6, + 3, 66, 73, 83, 213, 254, 1, 4, 82, 69, 82, 69, 2, 171, 219, 25, 85, 4, + 178, 149, 21, 67, 129, 176, 17, 3, 82, 73, 67, 30, 120, 3, 76, 65, 32, 32, 3, 82, 65, 32, 12, 4, 83, 85, 75, 85, 34, 84, 104, 5, 80, 69, 80, 69, - 84, 53, 3, 85, 76, 85, 4, 165, 1, 4, 76, 69, 78, 71, 4, 115, 82, 5, 193, - 233, 36, 3, 32, 73, 76, 10, 36, 5, 65, 76, 73, 78, 71, 99, 69, 9, 11, 32, + 84, 53, 3, 85, 76, 85, 4, 165, 1, 4, 76, 69, 78, 71, 4, 115, 82, 5, 181, + 220, 37, 3, 32, 73, 76, 10, 36, 5, 65, 76, 73, 78, 71, 99, 69, 9, 11, 32, 6, 18, 82, 55, 84, 4, 17, 2, 69, 80, 4, 11, 65, 5, 17, 2, 32, 84, 2, 11, - 69, 2, 175, 238, 30, 68, 5, 137, 246, 30, 3, 32, 83, 65, 30, 86, 79, 132, - 158, 23, 5, 32, 79, 70, 32, 89, 217, 172, 13, 6, 69, 84, 32, 83, 72, 79, - 26, 32, 2, 79, 78, 21, 2, 84, 32, 5, 187, 200, 35, 45, 22, 44, 2, 66, 79, - 246, 1, 83, 135, 222, 37, 88, 18, 38, 88, 205, 1, 4, 76, 68, 32, 83, 17, - 33, 6, 32, 87, 73, 84, 72, 32, 14, 82, 66, 86, 83, 132, 222, 12, 4, 76, - 73, 71, 72, 238, 180, 10, 67, 151, 203, 14, 88, 6, 52, 4, 79, 76, 68, 32, - 233, 141, 37, 3, 65, 76, 76, 4, 26, 83, 243, 146, 23, 67, 2, 129, 222, + 69, 2, 227, 219, 31, 68, 5, 189, 227, 31, 3, 32, 83, 65, 30, 86, 79, 188, + 133, 24, 5, 32, 79, 70, 32, 89, 149, 184, 13, 6, 69, 84, 32, 83, 72, 79, + 26, 32, 2, 79, 78, 21, 2, 84, 32, 5, 143, 184, 36, 45, 22, 44, 2, 66, 79, + 246, 1, 83, 251, 208, 38, 88, 18, 38, 88, 205, 1, 4, 76, 68, 32, 83, 17, + 33, 6, 32, 87, 73, 84, 72, 32, 14, 82, 66, 86, 83, 224, 250, 12, 4, 76, + 73, 71, 72, 198, 255, 10, 67, 215, 214, 14, 88, 6, 52, 4, 79, 76, 68, 32, + 221, 128, 38, 3, 65, 76, 76, 4, 26, 83, 167, 250, 23, 67, 2, 221, 250, 12, 4, 67, 82, 73, 80, 172, 10, 120, 2, 67, 79, 180, 1, 7, 76, 69, 84, - 84, 69, 82, 32, 208, 92, 3, 78, 74, 65, 246, 221, 28, 83, 182, 203, 5, - 70, 83, 81, 8, 26, 77, 219, 140, 37, 76, 6, 72, 12, 66, 73, 78, 73, 78, - 71, 32, 77, 65, 82, 75, 32, 195, 217, 37, 77, 4, 184, 230, 21, 6, 84, 85, - 75, 87, 69, 78, 141, 169, 3, 4, 75, 79, 81, 78, 156, 10, 170, 1, 70, 58, + 84, 69, 82, 32, 208, 92, 3, 78, 74, 65, 154, 201, 29, 83, 138, 207, 5, + 70, 83, 81, 8, 26, 77, 207, 255, 37, 76, 6, 72, 12, 66, 73, 78, 73, 78, + 71, 32, 77, 65, 82, 75, 32, 183, 204, 38, 77, 4, 180, 199, 22, 6, 84, 85, + 75, 87, 69, 78, 237, 176, 3, 4, 75, 79, 81, 78, 156, 10, 170, 1, 70, 58, 75, 170, 1, 76, 66, 77, 102, 78, 234, 1, 80, 166, 104, 82, 102, 83, 134, - 1, 84, 54, 89, 162, 225, 2, 87, 222, 242, 33, 69, 214, 22, 65, 2, 73, 2, - 79, 3, 85, 8, 170, 80, 65, 254, 242, 36, 69, 254, 5, 79, 219, 16, 85, 22, - 78, 69, 46, 79, 170, 230, 35, 89, 234, 239, 1, 80, 186, 2, 65, 2, 73, 3, - 85, 6, 178, 202, 36, 85, 194, 142, 1, 78, 3, 84, 7, 214, 227, 35, 86, - 141, 228, 1, 2, 71, 72, 10, 154, 103, 69, 234, 141, 26, 79, 154, 227, 10, - 65, 2, 73, 3, 85, 19, 62, 69, 254, 101, 66, 162, 241, 36, 65, 2, 73, 2, - 79, 3, 85, 4, 250, 228, 35, 69, 163, 242, 1, 78, 30, 102, 71, 50, 74, 50, - 84, 238, 101, 85, 158, 242, 34, 83, 246, 7, 68, 222, 225, 1, 89, 218, 19, - 65, 3, 73, 6, 186, 230, 32, 75, 158, 237, 4, 71, 187, 2, 65, 6, 234, 216, - 26, 85, 162, 230, 10, 69, 171, 4, 65, 4, 198, 176, 37, 85, 151, 14, 69, - 136, 9, 76, 5, 72, 65, 83, 69, 45, 170, 101, 69, 138, 2, 85, 142, 237, - 36, 65, 3, 73, 252, 8, 116, 2, 65, 32, 168, 18, 2, 66, 32, 180, 13, 2, + 1, 84, 54, 89, 206, 227, 2, 87, 166, 227, 34, 69, 214, 22, 65, 2, 73, 2, + 79, 3, 85, 8, 170, 80, 65, 242, 229, 37, 69, 254, 5, 79, 219, 16, 85, 22, + 78, 69, 46, 79, 134, 214, 36, 89, 130, 243, 1, 80, 186, 2, 65, 2, 73, 3, + 85, 6, 166, 189, 37, 85, 194, 142, 1, 78, 3, 84, 7, 178, 211, 36, 86, + 165, 231, 1, 2, 71, 72, 10, 154, 103, 69, 222, 247, 26, 79, 154, 236, 10, + 65, 2, 73, 3, 85, 19, 62, 69, 254, 101, 66, 150, 228, 37, 65, 2, 73, 2, + 79, 3, 85, 4, 214, 212, 36, 69, 187, 245, 1, 78, 30, 102, 71, 50, 74, 50, + 84, 238, 101, 85, 250, 225, 35, 83, 246, 7, 68, 246, 228, 1, 89, 218, 19, + 65, 3, 73, 6, 190, 211, 33, 75, 142, 243, 4, 71, 187, 2, 65, 6, 230, 194, + 27, 85, 154, 239, 10, 69, 171, 4, 65, 4, 186, 163, 38, 85, 151, 14, 69, + 136, 9, 76, 5, 72, 65, 83, 69, 45, 170, 101, 69, 138, 2, 85, 130, 224, + 37, 65, 3, 73, 252, 8, 116, 2, 65, 32, 168, 18, 2, 66, 32, 180, 13, 2, 67, 32, 180, 20, 2, 68, 32, 172, 18, 2, 69, 32, 153, 25, 2, 70, 32, 176, 1, 158, 1, 71, 106, 75, 130, 1, 76, 102, 77, 198, 3, 78, 210, 4, 80, 146, - 2, 83, 190, 2, 84, 154, 1, 85, 140, 214, 30, 2, 70, 73, 174, 249, 4, 86, - 191, 225, 1, 82, 6, 60, 5, 72, 69, 85, 65, 69, 153, 47, 5, 66, 73, 69, - 69, 32, 4, 220, 27, 2, 71, 72, 139, 185, 26, 82, 12, 38, 65, 34, 69, 214, - 67, 80, 3, 85, 4, 210, 206, 37, 70, 187, 2, 81, 4, 240, 240, 33, 5, 85, - 75, 69, 85, 84, 251, 223, 3, 84, 10, 78, 85, 166, 66, 79, 156, 170, 26, - 2, 65, 80, 213, 233, 9, 4, 69, 84, 32, 75, 5, 255, 173, 27, 65, 36, 142, + 2, 83, 190, 2, 84, 154, 1, 85, 192, 195, 31, 2, 70, 73, 214, 251, 4, 86, + 215, 228, 1, 82, 6, 60, 5, 72, 69, 85, 65, 69, 153, 47, 5, 66, 73, 69, + 69, 32, 4, 220, 27, 2, 71, 72, 135, 163, 27, 82, 12, 38, 65, 34, 69, 214, + 67, 80, 3, 85, 4, 198, 193, 38, 70, 187, 2, 81, 4, 244, 222, 34, 5, 85, + 75, 69, 85, 84, 235, 228, 3, 84, 10, 78, 85, 166, 66, 79, 144, 148, 27, + 2, 65, 80, 213, 242, 9, 4, 69, 84, 32, 75, 5, 171, 153, 28, 65, 36, 142, 1, 65, 176, 1, 2, 66, 65, 38, 79, 76, 6, 86, 69, 85, 65, 69, 78, 180, 71, - 8, 69, 85, 78, 74, 79, 77, 78, 68, 153, 201, 34, 2, 71, 66, 20, 62, 69, - 236, 49, 2, 78, 83, 221, 131, 32, 4, 80, 32, 80, 73, 16, 58, 77, 218, - 181, 12, 75, 190, 172, 7, 78, 219, 215, 17, 83, 11, 230, 24, 66, 14, 71, - 214, 44, 86, 255, 235, 27, 75, 4, 222, 225, 19, 78, 179, 235, 17, 81, 6, - 36, 2, 79, 77, 237, 1, 2, 78, 32, 4, 190, 135, 13, 80, 183, 203, 23, 69, - 2, 143, 143, 36, 71, 48, 122, 65, 32, 2, 68, 65, 54, 71, 98, 75, 32, 2, - 83, 72, 38, 84, 102, 89, 74, 90, 222, 138, 36, 74, 178, 109, 69, 251, 70, - 73, 4, 250, 8, 65, 151, 194, 37, 81, 4, 22, 65, 203, 22, 32, 2, 217, 44, - 3, 78, 71, 71, 8, 52, 3, 75, 85, 69, 222, 209, 32, 65, 167, 162, 3, 71, - 4, 250, 7, 32, 149, 166, 12, 2, 78, 90, 4, 166, 26, 65, 143, 217, 19, 73, - 4, 154, 215, 35, 73, 163, 242, 1, 65, 8, 40, 2, 65, 80, 237, 172, 28, 2, - 79, 81, 7, 11, 32, 4, 168, 211, 35, 2, 77, 70, 1, 2, 78, 84, 6, 26, 73, - 239, 171, 37, 69, 5, 193, 13, 7, 84, 32, 77, 79, 78, 71, 75, 4, 214, 5, - 65, 213, 170, 12, 4, 85, 78, 32, 77, 22, 58, 65, 80, 3, 79, 78, 32, 134, - 170, 37, 69, 163, 28, 85, 10, 42, 65, 198, 18, 32, 142, 18, 77, 15, 83, - 4, 222, 201, 26, 82, 247, 252, 10, 77, 8, 56, 4, 77, 70, 79, 78, 1, 6, + 8, 69, 85, 78, 74, 79, 77, 78, 68, 145, 184, 35, 2, 71, 66, 20, 62, 69, + 236, 49, 2, 78, 83, 233, 240, 32, 4, 80, 32, 80, 73, 16, 58, 77, 182, + 210, 12, 75, 158, 211, 7, 78, 147, 135, 18, 83, 11, 230, 24, 66, 14, 71, + 214, 44, 86, 183, 215, 28, 75, 4, 154, 165, 20, 78, 235, 154, 18, 81, 6, + 36, 2, 79, 77, 237, 1, 2, 78, 32, 4, 238, 164, 13, 80, 251, 160, 24, 69, + 2, 255, 254, 36, 71, 48, 122, 65, 32, 2, 68, 65, 54, 71, 98, 75, 32, 2, + 83, 72, 38, 84, 102, 89, 74, 90, 206, 250, 36, 74, 182, 112, 69, 251, 70, + 73, 4, 250, 8, 65, 139, 181, 38, 81, 4, 22, 65, 203, 22, 32, 2, 217, 44, + 3, 78, 71, 71, 8, 52, 3, 75, 85, 69, 226, 190, 33, 65, 135, 165, 3, 71, + 4, 250, 7, 32, 241, 194, 12, 2, 78, 90, 4, 166, 26, 65, 203, 156, 20, 73, + 4, 246, 198, 36, 73, 187, 245, 1, 65, 8, 40, 2, 65, 80, 165, 152, 29, 2, + 79, 81, 7, 11, 32, 4, 132, 195, 36, 2, 77, 70, 1, 2, 78, 84, 6, 26, 73, + 227, 158, 38, 69, 5, 193, 13, 7, 84, 32, 77, 79, 78, 71, 75, 4, 214, 5, + 65, 177, 199, 12, 4, 85, 78, 32, 77, 22, 58, 65, 80, 3, 79, 78, 32, 250, + 156, 38, 69, 163, 28, 85, 10, 42, 65, 198, 18, 32, 142, 18, 77, 15, 83, + 4, 218, 179, 27, 82, 239, 133, 11, 77, 8, 56, 4, 77, 70, 79, 78, 1, 6, 80, 65, 32, 78, 74, 73, 4, 37, 7, 32, 80, 73, 80, 65, 69, 77, 4, 250, 16, - 71, 155, 178, 37, 66, 22, 70, 72, 194, 1, 79, 144, 67, 2, 69, 85, 174, - 219, 36, 85, 167, 34, 73, 10, 74, 73, 70, 85, 177, 152, 36, 10, 79, 81, - 32, 78, 83, 72, 85, 84, 32, 89, 4, 162, 199, 26, 82, 237, 220, 6, 8, 78, - 68, 65, 32, 80, 65, 32, 78, 4, 204, 11, 4, 69, 78, 83, 72, 135, 184, 37, - 77, 6, 144, 134, 36, 2, 78, 74, 146, 189, 1, 81, 3, 84, 10, 44, 2, 69, - 85, 44, 3, 73, 84, 65, 31, 85, 4, 186, 236, 35, 65, 1, 4, 84, 69, 85, 87, - 2, 11, 32, 2, 195, 31, 77, 4, 234, 26, 32, 171, 133, 27, 65, 4, 228, 3, - 5, 32, 89, 85, 81, 32, 169, 246, 27, 3, 78, 75, 78, 116, 164, 1, 7, 71, + 71, 143, 165, 38, 66, 22, 70, 72, 194, 1, 79, 144, 67, 2, 69, 85, 162, + 206, 37, 85, 167, 34, 73, 10, 74, 73, 70, 85, 229, 138, 37, 10, 79, 81, + 32, 78, 83, 72, 85, 84, 32, 89, 4, 158, 177, 27, 82, 133, 224, 6, 8, 78, + 68, 65, 32, 80, 65, 32, 78, 4, 204, 11, 4, 69, 78, 83, 72, 251, 170, 38, + 77, 6, 128, 246, 36, 2, 78, 74, 150, 192, 1, 81, 3, 84, 10, 44, 2, 69, + 85, 44, 3, 73, 84, 65, 31, 85, 4, 158, 220, 36, 65, 1, 4, 84, 69, 85, 87, + 2, 11, 32, 2, 195, 31, 77, 4, 234, 26, 32, 215, 240, 27, 65, 4, 228, 3, + 5, 32, 89, 85, 81, 32, 213, 225, 28, 3, 78, 75, 78, 116, 164, 1, 7, 71, 72, 69, 85, 71, 72, 69, 34, 75, 126, 76, 122, 77, 154, 3, 78, 250, 2, 80, - 118, 83, 178, 1, 84, 106, 89, 210, 22, 87, 220, 46, 2, 70, 69, 163, 211, - 11, 86, 4, 134, 57, 85, 235, 134, 37, 78, 12, 40, 2, 69, 85, 50, 73, 159, - 174, 37, 65, 6, 166, 55, 89, 250, 194, 12, 80, 219, 178, 24, 65, 4, 198, - 172, 37, 69, 175, 18, 81, 8, 46, 65, 192, 70, 2, 79, 77, 187, 219, 36, - 69, 4, 50, 65, 209, 61, 7, 77, 32, 78, 83, 72, 85, 84, 2, 251, 192, 26, + 118, 83, 178, 1, 84, 106, 89, 210, 22, 87, 220, 46, 2, 70, 69, 255, 239, + 11, 86, 4, 134, 57, 85, 223, 249, 37, 78, 12, 40, 2, 69, 85, 50, 73, 147, + 161, 38, 65, 6, 166, 55, 89, 170, 224, 12, 80, 159, 136, 25, 65, 4, 186, + 159, 38, 69, 175, 18, 81, 8, 46, 65, 192, 70, 2, 79, 77, 175, 206, 37, + 69, 4, 50, 65, 209, 61, 7, 77, 32, 78, 83, 72, 85, 84, 2, 247, 170, 27, 78, 26, 70, 65, 74, 66, 140, 1, 2, 69, 85, 58, 70, 193, 23, 3, 79, 78, - 84, 7, 21, 3, 32, 78, 74, 4, 210, 226, 18, 85, 133, 156, 17, 3, 69, 85, - 65, 10, 90, 65, 218, 46, 85, 204, 161, 30, 2, 69, 85, 133, 153, 6, 7, 73, - 84, 32, 77, 66, 65, 65, 4, 198, 12, 65, 213, 206, 19, 4, 32, 77, 65, 69, - 4, 132, 163, 32, 5, 84, 32, 78, 71, 71, 187, 152, 5, 81, 4, 48, 4, 79, - 78, 32, 84, 177, 215, 26, 2, 73, 89, 2, 243, 65, 69, 26, 110, 71, 182, 1, - 83, 50, 89, 200, 23, 8, 84, 73, 69, 69, 32, 83, 72, 69, 245, 170, 35, 5, - 68, 85, 32, 78, 74, 14, 70, 71, 248, 191, 36, 8, 75, 73, 78, 68, 73, 32, - 77, 86, 191, 104, 79, 10, 76, 3, 85, 79, 81, 244, 225, 19, 2, 69, 85, - 186, 153, 16, 65, 187, 172, 1, 79, 5, 129, 196, 28, 2, 32, 76, 4, 26, 72, - 167, 232, 36, 69, 2, 235, 130, 37, 85, 4, 168, 46, 2, 65, 69, 227, 17, - 73, 10, 76, 3, 85, 78, 71, 200, 205, 10, 2, 69, 69, 154, 169, 12, 65, - 243, 163, 14, 73, 4, 246, 177, 31, 71, 247, 199, 4, 65, 12, 88, 2, 65, - 75, 16, 2, 72, 69, 156, 200, 19, 2, 69, 84, 178, 251, 15, 73, 207, 219, - 1, 85, 2, 231, 25, 69, 4, 196, 210, 26, 4, 84, 32, 78, 74, 221, 138, 5, - 4, 85, 65, 69, 81, 6, 32, 2, 85, 32, 247, 247, 35, 65, 4, 36, 4, 77, 65, + 84, 7, 21, 3, 32, 78, 74, 4, 134, 164, 19, 85, 193, 202, 17, 3, 69, 85, + 65, 10, 90, 65, 218, 46, 85, 128, 143, 31, 2, 69, 85, 197, 158, 6, 7, 73, + 84, 32, 77, 66, 65, 65, 4, 198, 12, 65, 149, 146, 20, 4, 32, 77, 65, 69, + 4, 144, 144, 33, 5, 84, 32, 78, 71, 71, 163, 158, 5, 81, 4, 48, 4, 79, + 78, 32, 84, 165, 193, 27, 2, 73, 89, 2, 243, 65, 69, 26, 110, 71, 182, 1, + 83, 50, 89, 200, 23, 8, 84, 73, 69, 69, 32, 83, 72, 69, 209, 154, 36, 5, + 68, 85, 32, 78, 74, 14, 70, 71, 236, 178, 37, 8, 75, 73, 78, 68, 73, 32, + 77, 86, 191, 104, 79, 10, 76, 3, 85, 79, 81, 176, 165, 20, 2, 69, 85, + 238, 197, 16, 65, 191, 175, 1, 79, 5, 185, 175, 29, 2, 32, 76, 4, 26, 72, + 155, 219, 37, 69, 2, 223, 245, 37, 85, 4, 168, 46, 2, 65, 69, 227, 17, + 73, 10, 76, 3, 85, 78, 71, 180, 234, 10, 2, 69, 69, 230, 243, 12, 65, + 175, 175, 14, 73, 4, 130, 159, 32, 71, 219, 202, 4, 65, 12, 88, 2, 65, + 75, 16, 2, 72, 69, 216, 139, 20, 2, 69, 84, 210, 167, 16, 73, 231, 222, + 1, 85, 2, 231, 25, 69, 4, 184, 188, 27, 4, 84, 32, 78, 74, 253, 141, 5, + 4, 85, 65, 69, 81, 6, 32, 2, 85, 32, 231, 231, 36, 65, 4, 36, 4, 77, 65, 69, 77, 143, 7, 78, 2, 11, 71, 2, 139, 7, 66, 4, 44, 4, 65, 70, 85, 32, - 233, 4, 2, 69, 85, 2, 177, 186, 32, 6, 76, 69, 69, 82, 65, 69, 198, 1, + 233, 4, 2, 69, 85, 2, 181, 167, 33, 6, 76, 69, 69, 82, 65, 69, 198, 1, 174, 1, 71, 82, 75, 206, 2, 76, 50, 77, 250, 3, 78, 238, 6, 80, 78, 83, - 134, 1, 84, 176, 1, 3, 86, 69, 85, 46, 87, 62, 89, 222, 172, 30, 66, 226, - 227, 2, 70, 247, 234, 3, 82, 6, 40, 2, 72, 65, 213, 198, 19, 2, 66, 65, - 4, 142, 181, 26, 82, 247, 252, 10, 80, 22, 66, 69, 182, 1, 85, 196, 204, - 26, 3, 80, 65, 82, 239, 224, 10, 65, 14, 40, 2, 78, 32, 54, 85, 191, 176, - 37, 84, 4, 132, 161, 33, 4, 70, 65, 84, 73, 191, 145, 3, 76, 8, 42, 83, - 238, 204, 26, 75, 167, 227, 10, 77, 4, 248, 14, 3, 72, 69, 85, 255, 53, - 69, 4, 48, 6, 79, 80, 32, 78, 75, 65, 183, 175, 37, 84, 2, 11, 65, 2, - 179, 178, 26, 82, 8, 234, 47, 65, 146, 156, 26, 73, 155, 227, 10, 85, 38, - 82, 65, 130, 1, 66, 158, 176, 26, 85, 208, 25, 4, 71, 66, 65, 83, 135, - 241, 8, 73, 8, 18, 32, 79, 69, 4, 42, 78, 141, 240, 17, 4, 75, 69, 85, - 65, 2, 11, 83, 2, 163, 187, 35, 73, 4, 134, 128, 37, 77, 211, 25, 83, 24, - 34, 65, 114, 69, 82, 73, 35, 85, 6, 32, 2, 65, 32, 155, 193, 19, 78, 4, - 244, 226, 31, 8, 67, 65, 66, 66, 65, 71, 69, 45, 253, 246, 4, 2, 80, 73, - 8, 50, 85, 214, 174, 26, 82, 189, 228, 5, 2, 69, 75, 4, 198, 171, 37, 77, - 3, 88, 7, 226, 7, 82, 203, 163, 37, 84, 4, 222, 152, 37, 65, 175, 18, 69, + 134, 1, 84, 176, 1, 3, 86, 69, 85, 46, 87, 62, 89, 146, 154, 31, 66, 214, + 227, 2, 70, 195, 240, 3, 82, 6, 40, 2, 72, 65, 145, 138, 20, 2, 66, 65, + 4, 138, 159, 27, 82, 239, 133, 11, 80, 22, 66, 69, 182, 1, 85, 184, 182, + 27, 3, 80, 65, 82, 239, 233, 10, 65, 14, 40, 2, 78, 32, 54, 85, 179, 163, + 38, 84, 4, 172, 142, 34, 4, 70, 65, 84, 73, 139, 151, 3, 76, 8, 42, 83, + 226, 182, 27, 75, 167, 236, 10, 77, 4, 248, 14, 3, 72, 69, 85, 255, 53, + 69, 4, 48, 6, 79, 80, 32, 78, 75, 65, 171, 162, 38, 84, 2, 11, 65, 2, + 175, 156, 27, 82, 8, 234, 47, 65, 134, 134, 27, 73, 155, 236, 10, 85, 38, + 82, 65, 130, 1, 66, 154, 154, 27, 85, 200, 25, 4, 71, 66, 65, 83, 239, + 246, 8, 73, 8, 18, 32, 79, 69, 4, 42, 78, 233, 176, 18, 4, 75, 69, 85, + 65, 2, 11, 83, 2, 255, 170, 36, 73, 4, 250, 242, 37, 77, 211, 25, 83, 24, + 34, 65, 114, 69, 82, 73, 35, 85, 6, 32, 2, 65, 32, 215, 132, 20, 78, 4, + 252, 207, 32, 8, 67, 65, 66, 66, 65, 71, 69, 45, 233, 252, 4, 2, 80, 73, + 8, 50, 85, 210, 152, 27, 82, 205, 231, 5, 2, 69, 75, 4, 186, 158, 38, 77, + 3, 88, 7, 226, 7, 82, 191, 150, 38, 84, 4, 210, 139, 38, 65, 175, 18, 69, 72, 130, 1, 65, 54, 68, 110, 71, 222, 1, 74, 102, 83, 130, 1, 84, 102, - 90, 253, 7, 12, 89, 73, 82, 32, 77, 75, 80, 65, 82, 65, 81, 32, 4, 192, - 198, 26, 4, 78, 83, 65, 78, 167, 227, 10, 81, 12, 60, 2, 69, 85, 206, 41, - 65, 238, 168, 19, 79, 187, 177, 17, 73, 4, 196, 182, 35, 2, 65, 69, 175, - 242, 1, 84, 20, 50, 71, 98, 75, 158, 196, 26, 65, 195, 210, 10, 79, 12, - 26, 85, 155, 216, 36, 69, 11, 212, 39, 3, 65, 69, 78, 194, 176, 36, 79, - 202, 26, 69, 155, 53, 77, 4, 36, 3, 85, 69, 32, 247, 195, 26, 65, 2, 249, - 193, 19, 3, 77, 65, 69, 10, 34, 65, 34, 69, 147, 225, 12, 85, 4, 238, - 149, 37, 69, 219, 16, 77, 4, 134, 180, 35, 69, 227, 99, 85, 12, 78, 85, - 150, 194, 26, 72, 220, 243, 5, 2, 69, 85, 242, 222, 4, 79, 219, 16, 65, - 4, 132, 146, 37, 4, 79, 84, 32, 78, 179, 19, 78, 8, 54, 69, 152, 136, 37, - 4, 85, 32, 77, 66, 131, 26, 65, 4, 176, 189, 19, 2, 85, 78, 159, 231, 17, - 78, 4, 254, 248, 35, 69, 167, 171, 1, 65, 6, 26, 73, 135, 212, 36, 69, 4, - 26, 82, 203, 163, 37, 78, 2, 183, 205, 35, 73, 12, 30, 69, 30, 72, 163, - 7, 85, 4, 78, 84, 135, 148, 36, 85, 6, 48, 2, 69, 84, 174, 221, 12, 85, - 131, 226, 13, 73, 2, 215, 210, 36, 70, 10, 40, 2, 65, 65, 34, 69, 41, 2, - 73, 84, 2, 11, 83, 2, 131, 165, 26, 72, 4, 228, 25, 2, 85, 84, 255, 135, - 37, 84, 4, 38, 85, 185, 145, 33, 3, 65, 32, 89, 2, 175, 255, 26, 65, 4, - 252, 132, 28, 2, 65, 69, 131, 156, 9, 88, 4, 40, 4, 65, 78, 71, 75, 159, - 160, 37, 85, 2, 143, 19, 85, 10, 42, 85, 234, 218, 12, 69, 207, 194, 24, - 65, 6, 210, 18, 87, 212, 3, 4, 32, 77, 85, 79, 199, 137, 37, 77, 234, 1, + 90, 253, 7, 12, 89, 73, 82, 32, 77, 75, 80, 65, 82, 65, 81, 32, 4, 180, + 176, 27, 4, 78, 83, 65, 78, 167, 236, 10, 81, 12, 60, 2, 69, 85, 206, 41, + 65, 170, 236, 19, 79, 243, 224, 17, 73, 4, 160, 166, 36, 2, 65, 69, 199, + 245, 1, 84, 20, 50, 71, 98, 75, 146, 174, 27, 65, 195, 219, 10, 79, 12, + 26, 85, 143, 203, 37, 69, 11, 212, 39, 3, 65, 69, 78, 182, 163, 37, 79, + 202, 26, 69, 155, 53, 77, 4, 36, 3, 85, 69, 32, 235, 173, 27, 65, 2, 181, + 133, 20, 3, 77, 65, 69, 10, 34, 65, 34, 69, 195, 254, 12, 85, 4, 226, + 136, 38, 69, 219, 16, 77, 4, 226, 163, 36, 69, 251, 102, 85, 12, 78, 85, + 138, 172, 27, 72, 236, 246, 5, 2, 69, 85, 226, 228, 4, 79, 219, 16, 65, + 4, 248, 132, 38, 4, 79, 84, 32, 78, 179, 19, 78, 8, 54, 69, 140, 251, 37, + 4, 85, 32, 77, 66, 131, 26, 65, 4, 236, 128, 20, 2, 85, 78, 215, 150, 18, + 78, 4, 178, 235, 36, 69, 231, 171, 1, 65, 6, 26, 73, 251, 198, 37, 69, 4, + 26, 82, 191, 150, 38, 78, 2, 155, 189, 36, 73, 12, 30, 69, 30, 72, 163, + 7, 85, 4, 78, 84, 251, 134, 37, 85, 6, 48, 2, 69, 84, 222, 250, 12, 85, + 199, 174, 14, 73, 2, 203, 197, 37, 70, 10, 40, 2, 65, 65, 34, 69, 41, 2, + 73, 84, 2, 11, 83, 2, 255, 142, 27, 72, 4, 228, 25, 2, 85, 84, 243, 250, + 37, 84, 4, 38, 85, 225, 254, 33, 3, 65, 32, 89, 2, 219, 234, 27, 65, 4, + 180, 240, 28, 2, 65, 69, 191, 163, 9, 88, 4, 40, 4, 65, 78, 71, 75, 147, + 147, 38, 85, 2, 143, 19, 85, 10, 42, 85, 154, 248, 12, 69, 147, 152, 25, + 65, 6, 210, 18, 87, 212, 3, 4, 32, 77, 85, 79, 187, 252, 37, 77, 234, 1, 134, 1, 70, 68, 2, 71, 72, 34, 75, 254, 1, 76, 142, 1, 77, 130, 3, 78, 130, 5, 80, 122, 82, 90, 83, 190, 1, 84, 158, 1, 87, 39, 89, 4, 36, 3, - 69, 85, 70, 199, 155, 37, 65, 2, 11, 69, 2, 151, 2, 85, 4, 202, 1, 69, - 223, 153, 37, 65, 22, 46, 69, 146, 1, 85, 42, 87, 187, 169, 35, 89, 10, - 26, 85, 247, 156, 37, 84, 8, 72, 3, 65, 69, 84, 20, 5, 79, 84, 32, 77, - 66, 150, 156, 37, 77, 3, 80, 2, 155, 132, 12, 77, 2, 159, 159, 26, 85, 9, - 166, 139, 37, 79, 218, 16, 78, 3, 81, 2, 191, 230, 36, 65, 14, 58, 69, - 242, 183, 26, 79, 250, 240, 8, 73, 203, 225, 1, 85, 8, 42, 85, 190, 168, - 35, 69, 163, 242, 1, 84, 4, 246, 248, 26, 65, 231, 161, 10, 77, 41, 94, - 65, 58, 66, 66, 69, 38, 70, 80, 2, 71, 66, 150, 147, 32, 79, 198, 139, 4, - 86, 151, 121, 85, 4, 144, 220, 17, 2, 76, 69, 173, 136, 19, 3, 69, 78, - 74, 6, 32, 2, 65, 65, 139, 250, 36, 85, 5, 185, 246, 28, 2, 32, 83, 6, - 202, 190, 18, 85, 247, 231, 16, 69, 10, 44, 2, 69, 85, 162, 154, 35, 79, - 207, 11, 73, 4, 182, 129, 37, 65, 215, 22, 84, 6, 202, 165, 35, 73, 252, - 70, 2, 79, 70, 247, 42, 69, 72, 78, 68, 46, 71, 226, 1, 74, 98, 83, 110, - 84, 34, 89, 242, 146, 37, 73, 3, 85, 8, 210, 39, 69, 182, 159, 36, 79, - 139, 63, 65, 24, 18, 71, 99, 75, 12, 54, 65, 218, 42, 69, 210, 251, 31, - 87, 231, 222, 4, 85, 6, 168, 38, 2, 65, 77, 199, 239, 36, 80, 12, 68, 2, - 69, 85, 226, 162, 35, 73, 2, 89, 194, 162, 1, 85, 215, 79, 65, 4, 230, - 207, 12, 65, 195, 177, 24, 82, 12, 60, 2, 69, 85, 230, 15, 73, 162, 191, - 12, 85, 143, 197, 24, 65, 4, 238, 129, 37, 65, 175, 18, 84, 10, 46, 72, - 32, 3, 73, 69, 69, 215, 130, 37, 85, 4, 158, 247, 36, 85, 219, 5, 69, 4, - 170, 147, 37, 80, 3, 84, 6, 130, 14, 69, 167, 224, 36, 85, 8, 194, 246, - 36, 69, 218, 5, 85, 254, 5, 65, 219, 16, 73, 12, 42, 69, 46, 85, 214, - 145, 37, 65, 3, 73, 4, 148, 149, 26, 2, 85, 84, 247, 252, 10, 69, 4, 178, - 245, 36, 85, 175, 28, 81, 8, 48, 3, 69, 78, 32, 182, 253, 36, 73, 175, 1, - 65, 4, 190, 225, 26, 79, 155, 141, 10, 77, 26, 58, 72, 90, 85, 202, 16, - 65, 174, 6, 69, 183, 220, 36, 79, 12, 54, 69, 222, 172, 26, 79, 194, 207, - 10, 73, 219, 19, 85, 6, 214, 7, 85, 159, 136, 37, 69, 6, 254, 248, 36, - 65, 214, 22, 69, 3, 85, 18, 62, 69, 74, 85, 142, 171, 26, 79, 198, 204, - 10, 65, 215, 22, 73, 8, 26, 85, 179, 156, 35, 69, 6, 202, 184, 35, 65, - 134, 214, 1, 78, 3, 84, 5, 247, 241, 36, 79, 4, 198, 158, 32, 85, 191, - 239, 4, 65, 10, 40, 2, 65, 69, 18, 85, 211, 189, 36, 69, 2, 251, 3, 77, - 6, 22, 87, 243, 13, 79, 2, 255, 169, 26, 79, 188, 2, 178, 1, 70, 154, 1, + 69, 85, 70, 187, 142, 38, 65, 2, 11, 69, 2, 151, 2, 85, 4, 202, 1, 69, + 211, 140, 38, 65, 22, 46, 69, 146, 1, 85, 42, 87, 151, 153, 36, 89, 10, + 26, 85, 235, 143, 38, 84, 8, 72, 3, 65, 69, 84, 20, 5, 79, 84, 32, 77, + 66, 138, 143, 38, 77, 3, 80, 2, 247, 160, 12, 77, 2, 155, 137, 27, 85, 9, + 154, 254, 37, 79, 218, 16, 78, 3, 81, 2, 179, 217, 37, 65, 14, 58, 69, + 230, 161, 27, 79, 226, 246, 8, 73, 227, 228, 1, 85, 8, 42, 85, 154, 152, + 36, 69, 187, 245, 1, 84, 4, 162, 228, 27, 65, 175, 169, 10, 77, 41, 94, + 65, 58, 66, 66, 69, 38, 70, 80, 2, 71, 66, 154, 128, 33, 79, 182, 145, 4, + 86, 151, 121, 85, 4, 236, 156, 18, 2, 76, 69, 197, 186, 19, 3, 69, 78, + 74, 6, 32, 2, 65, 65, 255, 236, 37, 85, 5, 221, 225, 29, 2, 32, 83, 6, + 254, 255, 18, 85, 159, 150, 17, 69, 10, 44, 2, 69, 85, 254, 137, 36, 79, + 207, 11, 73, 4, 170, 244, 37, 65, 215, 22, 84, 6, 166, 149, 36, 73, 212, + 73, 2, 79, 70, 183, 43, 69, 72, 78, 68, 46, 71, 226, 1, 74, 98, 83, 110, + 84, 34, 89, 230, 133, 38, 73, 3, 85, 8, 210, 39, 69, 170, 146, 37, 79, + 139, 63, 65, 24, 18, 71, 99, 75, 12, 54, 65, 218, 42, 69, 214, 232, 32, + 87, 215, 228, 4, 85, 6, 168, 38, 2, 65, 77, 187, 226, 37, 80, 12, 68, 2, + 69, 85, 190, 146, 36, 73, 2, 89, 218, 165, 1, 85, 215, 79, 65, 4, 150, + 237, 12, 65, 135, 135, 25, 82, 12, 60, 2, 69, 85, 230, 15, 73, 210, 220, + 12, 85, 211, 154, 25, 65, 4, 226, 244, 37, 65, 175, 18, 84, 10, 46, 72, + 32, 3, 73, 69, 69, 203, 245, 37, 85, 4, 146, 234, 37, 85, 219, 5, 69, 4, + 158, 134, 38, 80, 3, 84, 6, 130, 14, 69, 155, 211, 37, 85, 8, 182, 233, + 37, 69, 218, 5, 85, 254, 5, 65, 219, 16, 73, 12, 42, 69, 46, 85, 202, + 132, 38, 65, 3, 73, 4, 144, 255, 26, 2, 85, 84, 239, 133, 11, 69, 4, 166, + 232, 37, 85, 175, 28, 81, 8, 48, 3, 69, 78, 32, 170, 240, 37, 73, 175, 1, + 65, 4, 234, 204, 27, 79, 227, 148, 10, 77, 26, 58, 72, 90, 85, 202, 16, + 65, 174, 6, 69, 171, 207, 37, 79, 12, 54, 69, 210, 150, 27, 79, 194, 216, + 10, 73, 219, 19, 85, 6, 214, 7, 85, 147, 251, 37, 69, 6, 242, 235, 37, + 65, 214, 22, 69, 3, 85, 18, 62, 69, 74, 85, 130, 149, 27, 79, 198, 213, + 10, 65, 215, 22, 73, 8, 26, 85, 143, 140, 36, 69, 6, 174, 168, 36, 65, + 150, 217, 1, 78, 3, 84, 5, 235, 228, 37, 79, 4, 202, 139, 33, 85, 175, + 245, 4, 65, 10, 40, 2, 65, 69, 18, 85, 199, 176, 37, 69, 2, 251, 3, 77, + 6, 22, 87, 243, 13, 79, 2, 243, 147, 27, 79, 188, 2, 178, 1, 70, 154, 1, 71, 202, 1, 75, 170, 1, 76, 158, 1, 77, 134, 2, 78, 206, 7, 80, 166, 2, - 82, 78, 83, 166, 1, 84, 246, 1, 86, 66, 87, 34, 89, 242, 245, 36, 65, 2, - 73, 3, 79, 18, 54, 85, 210, 139, 23, 65, 242, 232, 13, 69, 255, 5, 79, - 10, 26, 32, 163, 162, 31, 69, 6, 208, 238, 23, 4, 82, 69, 77, 69, 242, - 145, 11, 67, 183, 138, 2, 73, 16, 24, 2, 66, 69, 39, 72, 4, 214, 251, 35, - 85, 195, 142, 1, 84, 12, 34, 65, 34, 69, 219, 248, 36, 79, 2, 11, 65, 2, - 207, 140, 26, 77, 8, 26, 85, 151, 137, 37, 84, 6, 190, 242, 36, 65, 214, - 22, 78, 3, 88, 18, 50, 69, 62, 80, 18, 85, 238, 135, 37, 73, 3, 79, 6, - 26, 85, 159, 136, 37, 84, 4, 198, 241, 36, 65, 215, 22, 88, 2, 227, 28, - 69, 6, 190, 235, 36, 69, 162, 28, 79, 15, 84, 18, 50, 65, 40, 2, 69, 85, - 22, 79, 215, 134, 37, 85, 6, 182, 246, 36, 65, 218, 16, 80, 3, 81, 2, - 187, 244, 36, 65, 8, 190, 172, 18, 79, 150, 218, 18, 77, 3, 81, 32, 110, - 65, 44, 2, 66, 69, 34, 70, 20, 2, 71, 66, 34, 73, 198, 135, 26, 85, 150, - 173, 10, 69, 2, 79, 139, 60, 86, 11, 218, 128, 18, 69, 222, 132, 19, 80, - 3, 81, 4, 178, 244, 36, 85, 219, 16, 69, 2, 231, 191, 12, 69, 4, 246, - 180, 36, 69, 227, 79, 65, 5, 227, 237, 36, 69, 82, 114, 68, 170, 1, 71, - 154, 3, 74, 112, 2, 83, 72, 58, 84, 32, 3, 89, 73, 32, 54, 90, 214, 188, - 36, 65, 191, 47, 75, 12, 34, 65, 98, 73, 207, 178, 36, 85, 6, 32, 2, 65, - 32, 235, 130, 37, 80, 4, 208, 178, 18, 3, 77, 89, 32, 241, 183, 13, 3, - 83, 79, 70, 4, 146, 159, 26, 65, 155, 227, 10, 81, 38, 78, 71, 66, 85, - 122, 75, 118, 79, 204, 231, 11, 3, 69, 85, 82, 195, 151, 25, 65, 14, 34, - 69, 50, 85, 219, 128, 37, 79, 6, 26, 85, 219, 142, 35, 69, 4, 219, 154, - 24, 65, 6, 64, 6, 65, 69, 83, 72, 65, 69, 174, 131, 26, 82, 247, 252, 10, - 80, 2, 11, 32, 2, 243, 198, 23, 78, 12, 34, 65, 20, 2, 69, 85, 35, 85, 5, - 247, 235, 36, 65, 4, 154, 237, 36, 65, 175, 18, 88, 4, 166, 255, 36, 77, - 3, 80, 4, 138, 255, 36, 80, 3, 81, 8, 18, 65, 31, 69, 2, 249, 250, 31, 2, - 69, 77, 6, 26, 69, 231, 239, 35, 85, 5, 249, 219, 36, 4, 32, 69, 80, 79, - 6, 26, 85, 199, 139, 35, 73, 4, 214, 253, 36, 79, 15, 69, 4, 238, 236, - 36, 85, 207, 16, 65, 4, 232, 169, 26, 4, 67, 76, 69, 65, 167, 248, 1, 66, - 4, 218, 153, 26, 65, 3, 85, 34, 42, 65, 90, 69, 58, 73, 50, 79, 23, 85, - 8, 32, 2, 32, 80, 175, 247, 17, 65, 4, 176, 163, 28, 2, 69, 79, 237, 204, - 7, 2, 76, 85, 6, 26, 85, 227, 234, 36, 69, 4, 182, 251, 36, 84, 3, 88, 7, - 11, 69, 4, 246, 151, 26, 69, 155, 227, 10, 84, 5, 139, 171, 36, 79, 11, - 82, 65, 134, 250, 36, 69, 3, 77, 8, 46, 65, 238, 14, 69, 253, 131, 19, 2, - 73, 77, 4, 130, 250, 36, 69, 3, 81, 18, 62, 69, 30, 72, 198, 137, 32, 85, - 242, 222, 4, 79, 163, 14, 65, 4, 166, 249, 36, 69, 3, 84, 8, 42, 69, 158, - 249, 22, 79, 175, 156, 3, 73, 2, 197, 179, 12, 2, 85, 65, 28, 34, 65, 94, - 69, 50, 79, 39, 85, 10, 56, 2, 69, 78, 162, 248, 22, 65, 198, 255, 13, - 77, 3, 81, 2, 237, 219, 11, 3, 32, 78, 84, 6, 26, 85, 171, 247, 36, 78, - 5, 143, 178, 12, 65, 6, 166, 249, 34, 79, 239, 253, 1, 81, 6, 170, 7, 77, - 243, 216, 36, 65, 6, 26, 69, 223, 229, 36, 79, 4, 190, 249, 25, 85, 247, - 252, 10, 69, 6, 246, 10, 69, 179, 207, 32, 85, 26, 68, 2, 69, 85, 46, 73, - 32, 3, 79, 81, 32, 54, 85, 159, 244, 36, 65, 8, 138, 143, 24, 65, 158, - 230, 12, 77, 3, 88, 4, 166, 222, 36, 69, 215, 22, 84, 4, 244, 205, 12, 4, - 83, 87, 73, 77, 191, 201, 9, 67, 8, 142, 145, 26, 69, 150, 141, 9, 65, - 134, 214, 1, 78, 3, 81, 108, 162, 1, 75, 82, 76, 46, 77, 98, 78, 190, 1, - 80, 66, 82, 50, 83, 110, 84, 38, 89, 130, 228, 2, 87, 152, 196, 9, 2, 86, - 85, 198, 174, 24, 69, 242, 5, 70, 231, 16, 85, 14, 178, 152, 18, 69, 246, - 231, 16, 89, 234, 239, 1, 80, 186, 2, 65, 2, 79, 3, 85, 6, 222, 142, 26, - 79, 154, 227, 10, 65, 3, 73, 13, 42, 66, 34, 69, 130, 241, 36, 65, 3, 79, - 4, 190, 161, 36, 69, 171, 77, 65, 2, 223, 254, 34, 69, 22, 94, 71, 38, - 74, 38, 85, 158, 242, 34, 83, 246, 7, 68, 150, 3, 84, 202, 222, 1, 89, - 219, 19, 73, 4, 182, 128, 32, 75, 159, 237, 4, 71, 4, 242, 242, 25, 85, - 203, 234, 10, 65, 5, 239, 216, 36, 65, 6, 26, 69, 163, 242, 25, 85, 4, - 210, 224, 35, 85, 195, 142, 1, 69, 12, 186, 2, 69, 254, 137, 9, 73, 187, - 226, 27, 85, 14, 66, 72, 230, 2, 69, 138, 134, 19, 65, 170, 192, 17, 85, - 235, 36, 73, 6, 162, 218, 36, 73, 218, 19, 79, 3, 85, 6, 214, 155, 21, - 65, 211, 181, 15, 69, 4, 150, 138, 26, 79, 155, 227, 10, 65, 4, 182, 214, - 36, 65, 215, 22, 69, 14, 54, 69, 254, 137, 9, 73, 230, 203, 27, 65, 215, - 22, 85, 6, 242, 221, 35, 85, 194, 142, 1, 69, 3, 78, 16, 62, 72, 50, 69, - 138, 134, 19, 65, 170, 192, 17, 85, 235, 36, 73, 8, 46, 69, 194, 215, 36, - 73, 218, 19, 79, 3, 85, 2, 215, 220, 35, 85, 10, 238, 144, 18, 69, 154, - 136, 3, 65, 255, 209, 15, 73, 6, 182, 135, 26, 79, 2, 85, 155, 227, 10, - 65, 14, 42, 75, 226, 171, 35, 65, 167, 159, 1, 74, 11, 49, 10, 78, 79, - 84, 69, 32, 87, 73, 84, 72, 32, 8, 172, 212, 9, 2, 80, 79, 198, 1, 89, - 192, 186, 12, 2, 69, 85, 247, 177, 6, 68, 6, 38, 32, 149, 253, 16, 3, 66, - 69, 82, 4, 250, 216, 29, 67, 201, 252, 5, 5, 79, 70, 32, 83, 79, 78, 72, - 3, 75, 69, 84, 60, 7, 83, 65, 32, 86, 65, 72, 32, 207, 220, 34, 69, 5, - 193, 165, 16, 10, 66, 65, 76, 76, 32, 65, 78, 68, 32, 72, 72, 104, 10, + 82, 78, 83, 166, 1, 84, 246, 1, 86, 66, 87, 34, 89, 230, 232, 37, 65, 2, + 73, 3, 79, 18, 54, 85, 138, 243, 23, 65, 174, 244, 13, 69, 255, 5, 79, + 10, 26, 32, 183, 143, 32, 69, 6, 152, 215, 24, 4, 82, 69, 77, 69, 254, + 152, 11, 67, 215, 141, 2, 73, 16, 24, 2, 66, 69, 39, 72, 4, 202, 238, 36, + 85, 195, 142, 1, 84, 12, 34, 65, 34, 69, 207, 235, 37, 79, 2, 11, 65, 2, + 203, 246, 26, 77, 8, 26, 85, 139, 252, 37, 84, 6, 178, 229, 37, 65, 214, + 22, 78, 3, 88, 18, 50, 69, 62, 80, 18, 85, 226, 250, 37, 73, 3, 79, 6, + 26, 85, 147, 251, 37, 84, 4, 186, 228, 37, 65, 215, 22, 88, 2, 227, 28, + 69, 6, 178, 222, 37, 69, 162, 28, 79, 15, 84, 18, 50, 65, 40, 2, 69, 85, + 22, 79, 203, 249, 37, 85, 6, 170, 233, 37, 65, 218, 16, 80, 3, 81, 2, + 175, 231, 37, 65, 8, 242, 237, 18, 79, 214, 139, 19, 77, 3, 81, 32, 110, + 65, 44, 2, 66, 69, 34, 70, 20, 2, 71, 66, 34, 73, 194, 241, 26, 85, 142, + 182, 10, 69, 2, 79, 139, 60, 86, 11, 142, 194, 18, 69, 158, 182, 19, 80, + 3, 81, 4, 166, 231, 37, 85, 219, 16, 69, 2, 151, 221, 12, 69, 4, 234, + 167, 37, 69, 227, 79, 65, 5, 215, 224, 37, 69, 82, 114, 68, 170, 1, 71, + 154, 3, 74, 112, 2, 83, 72, 58, 84, 32, 3, 89, 73, 32, 54, 90, 202, 175, + 37, 65, 191, 47, 75, 12, 34, 65, 98, 73, 195, 165, 37, 85, 6, 32, 2, 65, + 32, 223, 245, 37, 80, 4, 132, 244, 18, 3, 77, 89, 32, 201, 227, 13, 3, + 83, 79, 70, 4, 134, 137, 27, 65, 155, 236, 10, 81, 38, 78, 71, 66, 85, + 122, 75, 118, 79, 168, 132, 12, 3, 69, 85, 82, 219, 237, 25, 65, 14, 34, + 69, 50, 85, 207, 243, 37, 79, 6, 26, 85, 183, 254, 35, 69, 4, 167, 131, + 25, 65, 6, 64, 6, 65, 69, 83, 72, 65, 69, 170, 237, 26, 82, 239, 133, 11, + 80, 2, 11, 32, 2, 187, 175, 24, 78, 12, 34, 65, 20, 2, 69, 85, 35, 85, 5, + 235, 222, 37, 65, 4, 142, 224, 37, 65, 175, 18, 88, 4, 154, 242, 37, 77, + 3, 80, 4, 254, 241, 37, 80, 3, 81, 8, 18, 65, 31, 69, 2, 253, 231, 32, 2, + 69, 77, 6, 26, 69, 219, 226, 36, 85, 5, 237, 206, 37, 4, 32, 69, 80, 79, + 6, 26, 85, 163, 251, 35, 73, 4, 202, 240, 37, 79, 15, 69, 4, 226, 223, + 37, 85, 207, 16, 65, 4, 220, 147, 27, 4, 67, 76, 69, 65, 235, 249, 1, 66, + 4, 206, 131, 27, 65, 3, 85, 34, 42, 65, 90, 69, 58, 73, 50, 79, 23, 85, + 8, 32, 2, 32, 80, 227, 184, 18, 65, 4, 232, 142, 29, 2, 69, 79, 169, 212, + 7, 2, 76, 85, 6, 26, 85, 215, 221, 37, 69, 4, 170, 238, 37, 84, 3, 88, 7, + 11, 69, 4, 234, 129, 27, 69, 155, 236, 10, 84, 5, 255, 157, 37, 79, 11, + 82, 65, 250, 236, 37, 69, 3, 77, 8, 46, 65, 238, 14, 69, 185, 199, 19, 2, + 73, 77, 4, 246, 236, 37, 69, 3, 81, 18, 62, 69, 30, 72, 202, 246, 32, 85, + 226, 228, 4, 79, 163, 14, 65, 4, 154, 236, 37, 69, 3, 84, 8, 42, 69, 214, + 224, 23, 79, 235, 158, 3, 73, 2, 245, 208, 12, 2, 85, 65, 28, 34, 65, 94, + 69, 50, 79, 39, 85, 10, 56, 2, 69, 78, 218, 223, 23, 65, 130, 139, 14, + 77, 3, 81, 2, 201, 248, 11, 3, 32, 78, 84, 6, 26, 85, 159, 234, 37, 78, + 5, 191, 207, 12, 65, 6, 130, 233, 35, 79, 135, 129, 2, 81, 6, 170, 7, 77, + 231, 203, 37, 65, 6, 26, 69, 211, 216, 37, 79, 4, 186, 227, 26, 85, 239, + 133, 11, 69, 6, 246, 10, 69, 175, 188, 33, 85, 26, 68, 2, 69, 85, 46, 73, + 32, 3, 79, 81, 32, 54, 85, 147, 231, 37, 65, 8, 214, 247, 24, 65, 198, + 240, 12, 77, 3, 88, 4, 154, 209, 37, 69, 215, 22, 84, 4, 208, 234, 12, 4, + 83, 87, 73, 77, 159, 148, 10, 67, 8, 130, 251, 26, 69, 134, 147, 9, 65, + 150, 217, 1, 78, 3, 81, 108, 162, 1, 75, 82, 76, 46, 77, 98, 78, 190, 1, + 80, 66, 82, 50, 83, 110, 84, 38, 89, 174, 230, 2, 87, 156, 223, 9, 2, 86, + 85, 138, 132, 25, 69, 242, 5, 70, 231, 16, 85, 14, 230, 217, 18, 69, 158, + 150, 17, 89, 130, 243, 1, 80, 186, 2, 65, 2, 79, 3, 85, 6, 210, 248, 26, + 79, 154, 236, 10, 65, 3, 73, 13, 42, 66, 34, 69, 246, 227, 37, 65, 3, 79, + 4, 178, 148, 37, 69, 171, 77, 65, 2, 187, 238, 35, 69, 22, 94, 71, 38, + 74, 38, 85, 250, 225, 35, 83, 246, 7, 68, 150, 3, 84, 226, 225, 1, 89, + 219, 19, 73, 4, 186, 237, 32, 75, 143, 243, 4, 71, 4, 238, 220, 26, 85, + 195, 243, 10, 65, 5, 227, 203, 37, 65, 6, 26, 69, 159, 220, 26, 85, 4, + 198, 211, 36, 85, 195, 142, 1, 69, 12, 186, 2, 69, 138, 167, 9, 73, 163, + 184, 28, 85, 14, 66, 72, 230, 2, 69, 198, 201, 19, 65, 226, 239, 17, 85, + 235, 36, 73, 6, 150, 205, 37, 73, 218, 19, 79, 3, 85, 6, 250, 130, 22, + 65, 163, 193, 15, 69, 4, 138, 244, 26, 79, 155, 236, 10, 65, 4, 170, 201, + 37, 65, 215, 22, 69, 14, 54, 69, 138, 167, 9, 73, 206, 161, 28, 65, 215, + 22, 85, 6, 230, 208, 36, 85, 194, 142, 1, 69, 3, 78, 16, 62, 72, 50, 69, + 198, 201, 19, 65, 226, 239, 17, 85, 235, 36, 73, 8, 46, 69, 182, 202, 37, + 73, 218, 19, 79, 3, 85, 2, 203, 207, 36, 85, 10, 162, 210, 18, 69, 138, + 174, 3, 65, 207, 221, 15, 73, 6, 170, 241, 26, 79, 2, 85, 155, 236, 10, + 65, 14, 42, 75, 210, 155, 36, 65, 171, 162, 1, 74, 11, 49, 10, 78, 79, + 84, 69, 32, 87, 73, 84, 72, 32, 8, 204, 241, 9, 2, 80, 79, 198, 1, 89, + 220, 132, 13, 2, 69, 85, 215, 181, 6, 68, 6, 38, 32, 241, 189, 17, 3, 66, + 69, 82, 4, 174, 198, 30, 67, 137, 130, 6, 5, 79, 70, 32, 83, 79, 78, 72, + 3, 75, 69, 84, 60, 7, 83, 65, 32, 86, 65, 72, 32, 163, 204, 35, 69, 5, + 213, 164, 16, 10, 66, 65, 76, 76, 32, 65, 78, 68, 32, 72, 72, 104, 10, 67, 79, 77, 66, 73, 78, 73, 78, 71, 32, 164, 1, 7, 76, 69, 84, 84, 69, - 82, 32, 203, 143, 34, 70, 10, 52, 4, 72, 73, 71, 72, 44, 3, 76, 79, 87, - 39, 77, 4, 136, 234, 21, 2, 45, 76, 179, 134, 11, 32, 4, 32, 2, 45, 77, - 239, 239, 32, 32, 2, 221, 239, 32, 2, 73, 68, 60, 238, 1, 68, 38, 69, 38, - 71, 34, 75, 38, 85, 20, 2, 87, 65, 22, 89, 216, 243, 29, 2, 72, 87, 154, - 197, 1, 77, 186, 223, 2, 79, 202, 164, 2, 86, 246, 5, 74, 2, 84, 2, 90, - 162, 8, 67, 2, 83, 158, 20, 66, 2, 70, 2, 80, 186, 2, 65, 3, 73, 4, 190, - 156, 34, 72, 207, 198, 2, 79, 7, 142, 222, 31, 78, 219, 132, 5, 69, 4, - 218, 189, 36, 66, 219, 35, 65, 4, 162, 244, 29, 80, 131, 238, 6, 65, 5, - 151, 189, 36, 87, 5, 231, 188, 36, 68, 4, 130, 226, 35, 69, 131, 105, 73, - 121, 48, 3, 65, 75, 32, 230, 10, 72, 231, 183, 22, 84, 112, 196, 1, 15, - 67, 79, 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, 32, 28, 7, 76, - 69, 84, 84, 69, 82, 32, 248, 4, 3, 80, 65, 78, 50, 83, 141, 2, 11, 86, - 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 4, 230, 222, 36, 78, 87, 72, 76, - 194, 1, 77, 114, 78, 68, 2, 80, 65, 38, 83, 192, 236, 18, 4, 75, 65, 82, - 79, 142, 237, 17, 66, 2, 67, 2, 68, 2, 71, 2, 72, 2, 74, 2, 76, 2, 82, 2, - 87, 2, 89, 186, 2, 65, 2, 73, 3, 85, 10, 26, 65, 139, 219, 36, 66, 9, 45, - 9, 78, 68, 65, 73, 76, 73, 78, 71, 32, 6, 214, 218, 36, 72, 2, 78, 3, 83, - 10, 152, 2, 2, 79, 82, 154, 216, 36, 68, 2, 71, 2, 89, 187, 2, 65, 5, - 221, 130, 21, 4, 75, 80, 65, 75, 24, 80, 10, 73, 77, 65, 76, 85, 78, 71, - 85, 78, 32, 96, 2, 79, 85, 211, 218, 36, 65, 20, 246, 216, 36, 71, 2, 72, - 2, 76, 2, 77, 2, 80, 2, 82, 2, 83, 2, 87, 2, 89, 187, 2, 65, 2, 233, 236, - 18, 5, 84, 72, 69, 82, 78, 4, 166, 2, 71, 249, 236, 18, 4, 79, 78, 71, - 79, 10, 96, 12, 89, 77, 66, 79, 76, 32, 66, 73, 78, 68, 85, 32, 137, 190, - 10, 6, 73, 71, 78, 32, 84, 79, 8, 78, 80, 168, 169, 11, 3, 74, 85, 68, - 249, 171, 25, 6, 78, 65, 32, 77, 69, 84, 4, 64, 3, 65, 78, 71, 173, 166, - 23, 7, 73, 78, 65, 82, 66, 79, 82, 2, 183, 238, 25, 79, 18, 122, 85, 188, - 158, 26, 6, 80, 65, 75, 80, 65, 75, 152, 254, 2, 5, 75, 65, 82, 79, 32, - 254, 249, 6, 69, 162, 64, 73, 3, 79, 5, 173, 202, 30, 15, 32, 70, 79, 82, - 32, 83, 73, 77, 65, 76, 85, 78, 71, 85, 78, 5, 159, 229, 23, 84, 228, 2, - 182, 1, 65, 230, 2, 69, 50, 76, 146, 1, 78, 188, 10, 9, 82, 73, 65, 32, - 69, 82, 70, 69, 32, 186, 5, 84, 152, 248, 32, 2, 67, 65, 176, 185, 2, 5, + 82, 32, 195, 254, 34, 70, 10, 52, 4, 72, 73, 71, 72, 44, 3, 76, 79, 87, + 39, 77, 4, 192, 209, 22, 2, 45, 76, 183, 140, 11, 32, 4, 32, 2, 45, 77, + 171, 221, 33, 32, 2, 153, 221, 33, 2, 73, 68, 60, 234, 1, 68, 38, 69, 38, + 71, 34, 75, 38, 85, 20, 2, 87, 65, 22, 89, 144, 225, 30, 2, 72, 87, 150, + 166, 4, 79, 238, 120, 77, 218, 175, 1, 86, 246, 5, 74, 2, 84, 2, 90, 162, + 8, 67, 2, 83, 158, 20, 66, 2, 70, 2, 80, 186, 2, 65, 3, 73, 4, 186, 139, + 35, 72, 203, 202, 2, 79, 7, 150, 203, 32, 78, 203, 138, 5, 69, 4, 210, + 176, 37, 66, 219, 35, 65, 4, 218, 225, 30, 80, 195, 243, 6, 65, 5, 143, + 176, 37, 87, 5, 223, 175, 37, 68, 4, 250, 212, 36, 69, 131, 105, 73, 121, + 48, 3, 65, 75, 32, 230, 10, 72, 163, 159, 23, 84, 112, 196, 1, 15, 67, + 79, 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, 32, 28, 7, 76, 69, + 84, 84, 69, 82, 32, 248, 4, 3, 80, 65, 78, 50, 83, 141, 2, 11, 86, 79, + 87, 69, 76, 32, 83, 73, 71, 78, 32, 4, 222, 209, 37, 78, 87, 72, 76, 194, + 1, 77, 114, 78, 68, 2, 80, 65, 38, 83, 128, 176, 19, 4, 75, 65, 82, 79, + 198, 156, 18, 66, 2, 67, 2, 68, 2, 71, 2, 72, 2, 74, 2, 76, 2, 82, 2, 87, + 2, 89, 186, 2, 65, 2, 73, 3, 85, 10, 26, 65, 131, 206, 37, 66, 9, 45, 9, + 78, 68, 65, 73, 76, 73, 78, 71, 32, 6, 206, 205, 37, 72, 2, 78, 3, 83, + 10, 152, 2, 2, 79, 82, 146, 203, 37, 68, 2, 71, 2, 89, 187, 2, 65, 5, + 133, 234, 21, 4, 75, 80, 65, 75, 24, 80, 10, 73, 77, 65, 76, 85, 78, 71, + 85, 78, 32, 96, 2, 79, 85, 203, 205, 37, 65, 20, 238, 203, 37, 71, 2, 72, + 2, 76, 2, 77, 2, 80, 2, 82, 2, 83, 2, 87, 2, 89, 187, 2, 65, 2, 169, 176, + 19, 5, 84, 72, 69, 82, 78, 4, 166, 2, 71, 185, 176, 19, 4, 79, 78, 71, + 79, 10, 96, 12, 89, 77, 66, 79, 76, 32, 66, 73, 78, 68, 85, 32, 233, 218, + 10, 6, 73, 71, 78, 32, 84, 79, 8, 78, 80, 136, 198, 11, 3, 74, 85, 68, + 145, 130, 26, 6, 78, 65, 32, 77, 69, 84, 4, 64, 3, 65, 78, 71, 249, 142, + 24, 7, 73, 78, 65, 82, 66, 79, 82, 2, 175, 216, 26, 79, 18, 122, 85, 236, + 137, 27, 6, 80, 65, 75, 80, 65, 75, 168, 128, 3, 5, 75, 65, 82, 79, 32, + 182, 255, 6, 69, 162, 64, 73, 3, 79, 5, 189, 183, 31, 15, 32, 70, 79, 82, + 32, 83, 73, 77, 65, 76, 85, 78, 71, 85, 78, 5, 239, 205, 24, 84, 232, 2, + 182, 1, 65, 230, 2, 69, 50, 76, 146, 1, 78, 252, 11, 9, 82, 73, 65, 32, + 69, 82, 70, 69, 32, 186, 5, 84, 216, 228, 33, 2, 67, 65, 168, 190, 2, 5, 86, 69, 82, 65, 71, 243, 142, 1, 68, 20, 136, 1, 4, 77, 69, 68, 32, 170, - 1, 82, 140, 172, 3, 10, 67, 72, 32, 87, 73, 84, 72, 32, 85, 77, 142, 165, - 7, 84, 154, 195, 25, 86, 19, 78, 8, 86, 65, 0, 2, 68, 69, 52, 4, 69, 73, - 71, 72, 1, 7, 83, 73, 88, 84, 69, 69, 78, 2, 169, 178, 20, 8, 83, 67, 69, - 78, 68, 73, 78, 71, 2, 161, 178, 20, 2, 84, 72, 4, 220, 205, 32, 3, 68, - 69, 68, 171, 199, 3, 32, 4, 228, 200, 8, 3, 82, 32, 77, 203, 226, 26, 84, - 15, 11, 76, 13, 54, 32, 252, 165, 25, 3, 72, 79, 80, 231, 236, 9, 79, 6, - 238, 195, 12, 80, 212, 164, 16, 6, 87, 73, 84, 72, 32, 67, 139, 211, 6, - 83, 208, 1, 84, 5, 71, 65, 76, 73, 32, 158, 9, 84, 37, 9, 90, 69, 78, 69, - 32, 82, 73, 78, 71, 200, 1, 210, 1, 65, 40, 9, 67, 85, 82, 82, 69, 78, - 67, 89, 32, 148, 2, 7, 76, 69, 84, 84, 69, 82, 32, 204, 3, 6, 82, 85, 80, - 69, 69, 32, 34, 83, 170, 223, 22, 73, 134, 4, 86, 158, 240, 11, 68, 225, - 110, 3, 71, 65, 78, 6, 190, 173, 32, 66, 50, 78, 135, 63, 85, 12, 120, - 10, 78, 85, 77, 69, 82, 65, 84, 79, 82, 32, 205, 179, 23, 14, 68, 69, 78, - 79, 77, 73, 78, 65, 84, 79, 82, 32, 83, 73, 10, 52, 3, 79, 78, 69, 210, - 176, 31, 70, 135, 169, 3, 84, 5, 225, 191, 29, 19, 32, 76, 69, 83, 83, - 32, 84, 72, 65, 78, 32, 84, 72, 69, 32, 68, 69, 78, 79, 108, 226, 1, 75, - 90, 82, 238, 197, 21, 86, 242, 138, 8, 89, 178, 154, 3, 65, 38, 68, 114, - 84, 230, 5, 85, 186, 202, 1, 73, 138, 196, 1, 78, 46, 83, 82, 66, 2, 67, - 2, 71, 2, 74, 2, 80, 138, 69, 72, 2, 76, 2, 77, 186, 2, 69, 3, 79, 8, 26, - 72, 191, 201, 36, 65, 6, 26, 65, 215, 133, 14, 73, 5, 185, 219, 18, 3, - 78, 68, 65, 10, 34, 65, 166, 198, 36, 72, 3, 82, 7, 33, 6, 32, 87, 73, - 84, 72, 32, 4, 156, 158, 25, 5, 76, 79, 87, 69, 82, 1, 6, 77, 73, 68, 68, - 76, 69, 4, 134, 193, 35, 83, 191, 69, 77, 20, 116, 19, 69, 81, 85, 69, - 78, 67, 69, 32, 70, 79, 82, 32, 76, 69, 84, 84, 69, 82, 32, 210, 137, 26, - 65, 227, 158, 6, 73, 6, 206, 225, 22, 82, 175, 226, 13, 89, 4, 186, 157, - 26, 32, 151, 154, 9, 79, 5, 249, 203, 33, 3, 32, 87, 73, 100, 56, 6, 67, - 65, 80, 73, 84, 65, 1, 4, 83, 77, 65, 76, 50, 45, 9, 76, 32, 76, 69, 84, - 84, 69, 82, 32, 50, 182, 2, 65, 50, 68, 42, 69, 82, 71, 38, 78, 38, 83, - 154, 131, 17, 77, 136, 235, 1, 6, 72, 73, 82, 68, 69, 65, 0, 2, 75, 79, - 224, 194, 13, 6, 84, 65, 84, 65, 83, 79, 196, 209, 2, 5, 66, 65, 83, 73, - 71, 244, 50, 3, 87, 65, 83, 164, 108, 3, 70, 73, 84, 0, 3, 76, 65, 75, - 170, 11, 79, 2, 80, 2, 85, 219, 19, 73, 4, 26, 82, 179, 194, 36, 89, 2, - 139, 141, 23, 75, 4, 212, 206, 31, 3, 65, 82, 66, 3, 74, 6, 40, 4, 82, - 73, 71, 79, 203, 193, 36, 72, 5, 245, 172, 20, 4, 32, 84, 65, 77, 4, 210, - 226, 29, 79, 155, 220, 6, 78, 4, 166, 188, 31, 73, 187, 246, 3, 71, 4, - 246, 158, 26, 72, 155, 182, 3, 69, 4, 166, 234, 34, 87, 219, 64, 32, 194, - 1, 184, 2, 7, 76, 69, 84, 84, 69, 82, 32, 244, 1, 7, 78, 85, 77, 66, 69, - 82, 32, 72, 5, 83, 73, 71, 78, 32, 48, 11, 86, 79, 87, 69, 76, 32, 83, - 73, 71, 78, 32, 242, 249, 25, 68, 198, 247, 3, 87, 208, 195, 2, 10, 71, - 65, 80, 32, 70, 73, 76, 76, 69, 82, 161, 187, 3, 12, 72, 85, 78, 68, 82, - 69, 68, 83, 32, 85, 78, 73, 92, 210, 1, 86, 146, 222, 32, 65, 38, 68, - 114, 84, 230, 5, 85, 186, 202, 1, 73, 138, 196, 1, 78, 46, 83, 82, 66, 2, - 67, 2, 71, 2, 74, 2, 75, 2, 80, 138, 69, 72, 2, 76, 2, 77, 2, 82, 2, 89, - 186, 2, 69, 3, 79, 8, 234, 1, 79, 155, 186, 36, 65, 36, 142, 126, 69, 38, - 70, 66, 78, 26, 83, 234, 176, 21, 84, 195, 240, 12, 79, 10, 186, 157, 32, - 67, 158, 67, 65, 187, 151, 3, 86, 24, 80, 2, 86, 79, 250, 226, 32, 65, - 38, 85, 186, 202, 1, 73, 198, 140, 2, 69, 3, 79, 6, 33, 6, 67, 65, 76, - 73, 67, 32, 6, 214, 227, 32, 82, 159, 214, 3, 76, 26, 148, 1, 4, 67, 89, - 67, 76, 36, 2, 71, 32, 28, 2, 76, 76, 46, 82, 66, 84, 224, 174, 19, 4, - 79, 72, 65, 90, 212, 131, 12, 2, 75, 73, 239, 180, 4, 83, 4, 194, 202, - 32, 73, 247, 237, 3, 69, 4, 226, 158, 34, 82, 67, 83, 4, 240, 219, 9, 2, - 69, 68, 235, 250, 23, 73, 4, 160, 203, 32, 7, 84, 72, 68, 65, 89, 32, 67, - 171, 236, 3, 68, 4, 192, 216, 13, 2, 67, 79, 145, 221, 22, 4, 73, 78, 71, - 32, 196, 7, 42, 65, 174, 33, 79, 165, 11, 2, 85, 69, 246, 2, 32, 2, 67, - 75, 207, 244, 17, 78, 244, 2, 22, 32, 223, 31, 45, 228, 2, 210, 1, 67, - 254, 4, 68, 174, 2, 70, 102, 72, 82, 76, 186, 4, 77, 250, 2, 78, 38, 80, - 46, 82, 150, 4, 83, 154, 4, 84, 82, 85, 248, 2, 3, 86, 69, 82, 158, 133, - 12, 79, 140, 220, 20, 3, 66, 79, 87, 187, 249, 1, 81, 102, 196, 1, 5, 73, - 82, 67, 76, 69, 200, 1, 6, 85, 82, 86, 69, 68, 32, 168, 129, 26, 12, 82, - 79, 83, 83, 32, 79, 78, 32, 83, 72, 73, 69, 248, 161, 3, 5, 69, 78, 84, - 82, 69, 254, 172, 5, 72, 159, 14, 76, 11, 11, 32, 8, 72, 5, 87, 73, 84, - 72, 32, 189, 238, 16, 7, 70, 79, 82, 32, 82, 69, 67, 6, 140, 69, 8, 87, - 72, 73, 84, 69, 32, 68, 79, 218, 250, 18, 68, 177, 146, 2, 8, 84, 87, 79, - 32, 87, 72, 73, 84, 16, 84, 4, 68, 79, 87, 78, 0, 2, 85, 80, 56, 3, 76, - 69, 70, 1, 4, 82, 73, 71, 72, 4, 205, 138, 32, 9, 87, 65, 82, 68, 83, 32, - 65, 78, 68, 4, 53, 11, 84, 87, 65, 82, 68, 83, 32, 65, 78, 68, 32, 4, - 194, 151, 21, 85, 255, 165, 12, 68, 30, 64, 6, 73, 65, 77, 79, 78, 68, - 152, 1, 3, 79, 87, 78, 43, 82, 13, 11, 32, 10, 154, 19, 67, 248, 255, 12, - 10, 77, 73, 78, 85, 83, 32, 87, 72, 73, 84, 168, 169, 6, 6, 87, 73, 84, - 72, 32, 68, 178, 174, 15, 79, 135, 13, 83, 12, 214, 19, 32, 62, 45, 203, - 182, 31, 87, 6, 248, 202, 34, 2, 79, 80, 179, 21, 65, 8, 18, 76, 39, 79, - 4, 194, 243, 27, 79, 179, 184, 8, 65, 4, 184, 219, 2, 2, 85, 82, 147, - 173, 31, 76, 12, 38, 69, 210, 227, 34, 65, 251, 2, 79, 6, 152, 229, 34, - 2, 65, 82, 247, 11, 88, 40, 64, 5, 65, 82, 71, 69, 32, 140, 2, 3, 69, 70, - 84, 203, 1, 79, 12, 48, 6, 67, 73, 82, 67, 76, 69, 211, 135, 35, 83, 11, - 37, 7, 32, 77, 73, 78, 85, 83, 32, 8, 54, 76, 36, 4, 82, 73, 71, 72, 13, - 3, 85, 80, 80, 4, 32, 2, 69, 70, 13, 2, 79, 87, 2, 31, 84, 2, 17, 2, 69, - 82, 2, 229, 166, 33, 8, 32, 81, 85, 65, 82, 84, 69, 82, 22, 96, 10, 45, - 80, 79, 73, 78, 84, 73, 78, 71, 32, 64, 6, 87, 65, 82, 68, 83, 32, 227, - 228, 34, 32, 12, 146, 7, 68, 190, 8, 73, 182, 216, 34, 80, 206, 24, 83, - 51, 84, 4, 174, 184, 33, 69, 231, 140, 1, 66, 6, 158, 15, 87, 167, 224, - 34, 90, 30, 76, 6, 69, 68, 73, 85, 77, 32, 205, 226, 21, 7, 79, 79, 78, - 32, 76, 73, 76, 28, 66, 68, 42, 76, 36, 4, 82, 73, 71, 72, 12, 2, 85, 80, - 111, 83, 6, 84, 3, 79, 87, 78, 155, 230, 34, 73, 6, 32, 2, 69, 70, 187, - 237, 34, 79, 4, 11, 84, 4, 81, 18, 45, 80, 79, 73, 78, 84, 73, 78, 71, - 32, 84, 82, 73, 65, 78, 71, 76, 69, 5, 145, 9, 2, 32, 67, 8, 198, 13, 77, - 255, 243, 34, 81, 4, 194, 153, 17, 69, 191, 204, 17, 73, 8, 158, 140, 25, - 85, 230, 217, 9, 65, 87, 69, 34, 52, 4, 73, 71, 72, 84, 162, 145, 34, 79, - 239, 85, 69, 30, 94, 32, 84, 10, 45, 80, 79, 73, 78, 84, 73, 78, 71, 32, - 245, 1, 6, 87, 65, 82, 68, 83, 32, 6, 60, 9, 84, 82, 73, 65, 78, 71, 76, - 69, 32, 163, 248, 34, 80, 2, 243, 206, 6, 67, 16, 90, 68, 88, 8, 84, 82, - 73, 65, 78, 71, 76, 69, 230, 7, 73, 186, 221, 34, 80, 203, 19, 83, 4, 65, - 14, 79, 85, 66, 76, 69, 32, 84, 82, 73, 65, 78, 71, 76, 69, 5, 175, 194, - 12, 32, 5, 241, 237, 20, 11, 32, 87, 73, 84, 72, 32, 68, 79, 85, 66, 76, - 8, 250, 166, 19, 65, 202, 137, 14, 69, 231, 140, 1, 66, 40, 158, 2, 77, - 148, 1, 5, 81, 85, 65, 82, 69, 180, 133, 26, 3, 85, 78, 32, 160, 224, 1, - 5, 75, 85, 76, 76, 32, 228, 183, 3, 3, 78, 79, 87, 168, 228, 1, 5, 65, - 70, 69, 84, 89, 184, 131, 1, 13, 76, 73, 71, 72, 84, 76, 89, 32, 83, 77, - 65, 76, 76, 198, 93, 67, 50, 72, 222, 1, 80, 191, 19, 84, 12, 40, 4, 65, - 76, 76, 32, 195, 229, 34, 73, 10, 206, 221, 34, 68, 150, 7, 76, 70, 83, - 213, 15, 13, 85, 80, 45, 80, 79, 73, 78, 84, 73, 78, 71, 32, 67, 9, 11, - 32, 6, 54, 67, 140, 198, 33, 3, 70, 79, 82, 223, 159, 1, 66, 2, 245, 134, - 31, 3, 69, 78, 84, 14, 192, 4, 3, 73, 78, 89, 214, 178, 23, 82, 174, 182, - 11, 79, 54, 69, 135, 2, 87, 18, 38, 80, 157, 233, 32, 3, 78, 73, 86, 16, - 46, 32, 62, 45, 170, 1, 80, 163, 181, 31, 87, 2, 225, 240, 34, 10, 80, - 79, 73, 78, 84, 73, 78, 71, 32, 66, 8, 45, 9, 80, 79, 73, 78, 84, 73, 78, - 71, 32, 8, 66, 73, 148, 237, 34, 5, 68, 79, 85, 66, 76, 238, 3, 83, 51, - 84, 2, 141, 238, 33, 8, 83, 79, 83, 67, 69, 76, 69, 83, 4, 21, 3, 69, 82, - 32, 4, 182, 187, 24, 76, 163, 178, 9, 82, 10, 56, 6, 84, 73, 67, 65, 76, - 32, 41, 4, 89, 32, 83, 77, 4, 144, 219, 34, 2, 82, 69, 235, 22, 69, 6, - 21, 3, 65, 76, 76, 6, 11, 32, 6, 178, 215, 34, 68, 150, 7, 76, 135, 21, - 83, 16, 84, 15, 76, 69, 84, 84, 69, 82, 32, 67, 65, 80, 73, 84, 65, 76, - 32, 247, 150, 11, 70, 10, 166, 149, 36, 67, 2, 72, 2, 73, 2, 82, 3, 90, - 200, 4, 52, 3, 67, 75, 32, 186, 151, 2, 83, 167, 206, 10, 87, 196, 4, 80, - 7, 79, 67, 84, 65, 78, 84, 45, 149, 7, 8, 83, 69, 88, 84, 65, 78, 84, 45, - 204, 3, 58, 49, 130, 3, 50, 114, 53, 50, 54, 18, 51, 215, 1, 52, 234, 1, - 74, 50, 246, 1, 51, 174, 91, 52, 46, 53, 38, 54, 30, 55, 199, 180, 35, - 56, 116, 62, 51, 226, 92, 52, 46, 53, 38, 54, 30, 55, 199, 180, 35, 56, - 55, 54, 52, 214, 92, 53, 38, 54, 30, 55, 199, 180, 35, 56, 22, 50, 53, - 166, 2, 54, 190, 90, 55, 199, 180, 35, 56, 11, 42, 54, 202, 229, 28, 55, - 179, 171, 7, 56, 4, 246, 144, 36, 55, 3, 56, 56, 170, 1, 53, 50, 54, 210, - 89, 52, 110, 55, 199, 180, 35, 56, 118, 62, 52, 254, 89, 51, 98, 53, 38, - 54, 30, 55, 199, 180, 35, 56, 24, 46, 53, 50, 54, 190, 90, 55, 199, 180, - 35, 56, 13, 206, 1, 54, 178, 226, 28, 55, 179, 171, 7, 56, 7, 187, 90, - 55, 61, 54, 52, 118, 53, 230, 88, 54, 30, 55, 199, 180, 35, 56, 31, 46, - 53, 170, 89, 54, 30, 55, 199, 180, 35, 56, 15, 38, 54, 158, 89, 55, 199, - 180, 35, 56, 7, 222, 141, 36, 55, 3, 56, 14, 226, 88, 54, 30, 55, 199, - 180, 35, 56, 31, 46, 54, 234, 87, 53, 66, 55, 199, 180, 35, 56, 6, 166, - 88, 55, 199, 180, 35, 56, 120, 70, 49, 238, 1, 50, 162, 193, 25, 51, 38, - 52, 30, 53, 187, 200, 10, 54, 61, 58, 50, 126, 51, 250, 193, 25, 52, 30, - 53, 187, 200, 10, 54, 31, 50, 51, 194, 194, 25, 52, 30, 53, 187, 200, 10, - 54, 15, 42, 52, 178, 194, 25, 53, 187, 200, 10, 54, 7, 230, 138, 36, 53, - 3, 54, 15, 246, 193, 25, 52, 186, 157, 3, 53, 159, 171, 7, 54, 31, 50, - 52, 238, 192, 25, 51, 66, 53, 187, 200, 10, 54, 7, 171, 193, 25, 53, 6, - 150, 157, 22, 32, 213, 206, 8, 4, 66, 69, 82, 82, 232, 4, 200, 1, 3, 76, - 68, 32, 78, 79, 104, 7, 80, 79, 77, 79, 70, 79, 32, 188, 6, 2, 84, 84, - 216, 6, 5, 85, 81, 85, 69, 84, 54, 87, 198, 1, 88, 182, 217, 5, 77, 222, - 170, 3, 89, 162, 186, 26, 65, 139, 34, 78, 14, 138, 189, 8, 83, 242, 208, - 7, 69, 254, 223, 17, 70, 234, 2, 87, 203, 11, 71, 10, 26, 75, 187, 148, - 23, 77, 9, 40, 4, 77, 65, 82, 75, 187, 134, 36, 83, 5, 241, 174, 23, 3, - 32, 84, 65, 150, 1, 96, 13, 70, 73, 78, 65, 76, 32, 76, 69, 84, 84, 69, - 82, 32, 53, 7, 76, 69, 84, 84, 69, 82, 32, 10, 174, 133, 36, 71, 2, 72, - 2, 75, 2, 80, 3, 84, 140, 1, 234, 1, 65, 54, 85, 22, 69, 82, 71, 46, 73, - 70, 78, 38, 79, 98, 90, 190, 156, 7, 75, 230, 210, 24, 67, 2, 76, 2, 83, - 230, 57, 66, 186, 202, 1, 74, 198, 140, 2, 68, 2, 70, 2, 72, 2, 77, 2, - 80, 2, 81, 2, 82, 2, 84, 2, 86, 3, 88, 21, 50, 73, 2, 85, 74, 78, 146, - 130, 36, 72, 3, 77, 5, 247, 178, 35, 78, 17, 50, 78, 146, 130, 36, 69, 2, - 72, 2, 73, 3, 82, 7, 142, 130, 36, 71, 3, 78, 11, 242, 129, 36, 72, 2, - 78, 2, 85, 3, 87, 15, 216, 131, 34, 2, 78, 78, 238, 253, 1, 72, 2, 77, 2, - 82, 3, 85, 9, 130, 131, 34, 71, 131, 254, 1, 78, 17, 66, 78, 154, 255, - 34, 32, 134, 129, 1, 69, 2, 77, 2, 79, 3, 85, 4, 154, 128, 36, 71, 3, 78, - 9, 254, 255, 35, 72, 2, 73, 3, 89, 66, 104, 3, 79, 77, 32, 145, 183, 21, - 17, 76, 69, 32, 87, 73, 84, 72, 32, 80, 79, 80, 80, 73, 78, 71, 32, 67, - 64, 152, 2, 5, 72, 65, 76, 70, 32, 232, 1, 5, 76, 69, 70, 84, 32, 88, 6, - 82, 73, 71, 72, 84, 32, 88, 14, 83, 81, 85, 65, 82, 69, 32, 66, 82, 65, - 67, 75, 69, 84, 210, 216, 15, 65, 150, 150, 16, 67, 210, 3, 80, 140, 3, - 13, 74, 85, 83, 84, 73, 70, 73, 69, 68, 32, 85, 80, 80, 135, 5, 84, 32, - 148, 1, 16, 70, 79, 82, 87, 65, 82, 68, 45, 70, 65, 67, 73, 78, 71, 32, - 82, 186, 243, 31, 76, 22, 82, 252, 2, 2, 83, 84, 174, 5, 66, 211, 245, 1, - 73, 10, 248, 162, 29, 11, 85, 78, 78, 69, 82, 32, 70, 82, 65, 77, 69, - 155, 210, 2, 79, 8, 248, 248, 31, 13, 74, 85, 83, 84, 73, 70, 73, 69, 68, - 32, 85, 80, 80, 126, 67, 51, 72, 8, 158, 249, 31, 67, 50, 72, 33, 13, 74, - 85, 83, 84, 73, 70, 73, 69, 68, 32, 85, 80, 80, 5, 181, 219, 23, 9, 32, - 79, 86, 69, 82, 32, 84, 79, 80, 5, 133, 232, 34, 8, 32, 79, 70, 32, 70, - 76, 79, 87, 14, 58, 76, 116, 3, 84, 73, 69, 201, 153, 33, 3, 32, 65, 78, - 6, 26, 32, 131, 167, 35, 73, 4, 172, 187, 9, 7, 79, 70, 32, 72, 89, 71, - 73, 149, 146, 23, 6, 87, 73, 84, 72, 32, 83, 7, 135, 215, 32, 32, 218, 2, - 88, 10, 32, 68, 82, 65, 87, 73, 78, 71, 83, 32, 205, 249, 34, 6, 73, 78, - 71, 32, 71, 76, 216, 2, 176, 1, 2, 68, 79, 228, 6, 6, 72, 69, 65, 86, 89, - 32, 254, 2, 76, 204, 25, 6, 82, 73, 71, 72, 84, 32, 144, 4, 3, 85, 80, - 32, 245, 3, 9, 86, 69, 82, 84, 73, 67, 65, 76, 32, 66, 52, 5, 85, 66, 76, - 69, 32, 165, 3, 3, 87, 78, 32, 30, 58, 68, 216, 2, 2, 85, 80, 234, 5, 86, - 255, 171, 29, 72, 14, 64, 8, 73, 65, 71, 79, 78, 65, 76, 32, 149, 2, 3, - 79, 87, 78, 8, 104, 6, 85, 80, 80, 69, 82, 32, 205, 14, 15, 76, 79, 87, - 69, 82, 32, 76, 69, 70, 84, 32, 84, 79, 32, 77, 6, 76, 8, 76, 69, 70, 84, - 32, 84, 79, 32, 237, 24, 6, 82, 73, 71, 72, 84, 32, 4, 204, 23, 14, 77, - 73, 68, 68, 76, 69, 32, 67, 69, 78, 84, 82, 69, 32, 243, 177, 23, 76, 6, - 199, 26, 32, 36, 128, 1, 10, 72, 69, 65, 86, 89, 32, 65, 78, 68, 32, 132, - 1, 10, 76, 73, 71, 72, 84, 32, 65, 78, 68, 32, 210, 38, 68, 131, 4, 83, - 12, 76, 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, 228, 35, 2, 85, 80, 151, 5, - 72, 4, 17, 2, 84, 32, 4, 230, 32, 85, 251, 163, 35, 76, 12, 76, 3, 76, - 69, 70, 0, 4, 82, 73, 71, 72, 156, 36, 2, 85, 80, 235, 4, 72, 4, 17, 2, - 84, 32, 4, 198, 32, 85, 135, 9, 72, 46, 136, 1, 4, 76, 69, 70, 84, 68, 2, - 85, 80, 130, 1, 86, 172, 20, 2, 68, 79, 170, 2, 81, 100, 2, 84, 82, 198, - 148, 29, 72, 247, 148, 6, 82, 5, 45, 9, 32, 65, 78, 68, 32, 76, 73, 71, - 72, 2, 179, 153, 34, 84, 11, 29, 5, 32, 65, 78, 68, 32, 8, 42, 76, 178, - 172, 29, 72, 247, 148, 6, 82, 4, 144, 179, 24, 4, 73, 71, 72, 84, 131, - 142, 11, 69, 8, 209, 20, 7, 69, 82, 84, 73, 67, 65, 76, 156, 1, 56, 4, - 69, 70, 84, 32, 169, 2, 5, 73, 71, 72, 84, 32, 16, 160, 27, 19, 68, 79, - 87, 78, 32, 72, 69, 65, 86, 89, 32, 65, 78, 68, 32, 82, 73, 71, 72, 24, - 14, 72, 69, 65, 86, 89, 32, 65, 78, 68, 32, 82, 73, 71, 72, 100, 14, 76, - 73, 71, 72, 84, 32, 65, 78, 68, 32, 82, 73, 71, 72, 97, 17, 85, 80, 32, - 72, 69, 65, 86, 89, 32, 65, 78, 68, 32, 82, 73, 71, 72, 140, 1, 248, 1, - 4, 65, 82, 67, 32, 30, 68, 248, 15, 10, 72, 79, 82, 73, 90, 79, 78, 84, - 65, 76, 112, 4, 76, 69, 70, 84, 62, 81, 34, 84, 172, 1, 2, 85, 80, 120, - 8, 86, 69, 82, 84, 73, 67, 65, 76, 156, 199, 13, 7, 66, 79, 84, 84, 79, - 77, 32, 191, 224, 21, 82, 8, 166, 210, 17, 68, 67, 85, 80, 52, 8, 73, 65, - 71, 79, 78, 65, 76, 32, 199, 14, 79, 68, 168, 1, 14, 76, 79, 87, 69, 82, - 32, 76, 69, 70, 84, 32, 84, 79, 32, 96, 7, 77, 73, 68, 68, 76, 69, 32, - 136, 3, 6, 85, 80, 80, 69, 82, 32, 154, 157, 34, 67, 183, 4, 68, 4, 38, - 77, 33, 5, 85, 80, 80, 69, 82, 2, 29, 5, 73, 68, 68, 76, 69, 2, 129, 12, - 2, 32, 67, 16, 88, 8, 76, 69, 70, 84, 32, 84, 79, 32, 213, 1, 9, 82, 73, - 71, 72, 84, 32, 84, 79, 32, 10, 156, 1, 6, 76, 79, 87, 69, 82, 32, 33, - 28, 85, 80, 80, 69, 82, 32, 67, 69, 78, 84, 82, 69, 32, 84, 79, 32, 77, - 73, 68, 68, 76, 69, 32, 82, 73, 71, 72, 84, 6, 246, 3, 67, 139, 179, 35, - 82, 5, 171, 199, 20, 32, 6, 232, 4, 15, 85, 80, 80, 69, 82, 32, 67, 69, - 78, 84, 82, 69, 32, 84, 79, 235, 3, 76, 44, 144, 1, 10, 67, 69, 78, 84, - 82, 69, 32, 84, 79, 32, 248, 3, 8, 76, 69, 70, 84, 32, 84, 79, 32, 193, - 2, 9, 82, 73, 71, 72, 84, 32, 84, 79, 32, 20, 52, 7, 77, 73, 68, 68, 76, - 69, 32, 255, 180, 23, 76, 16, 56, 4, 76, 69, 70, 84, 165, 1, 5, 82, 73, - 71, 72, 84, 9, 11, 32, 6, 84, 10, 84, 79, 32, 76, 79, 87, 69, 82, 32, 67, - 141, 195, 20, 5, 65, 78, 68, 32, 77, 4, 29, 5, 69, 78, 84, 82, 69, 5, - 189, 215, 32, 3, 32, 84, 79, 9, 11, 32, 6, 88, 3, 65, 78, 68, 65, 15, 84, - 79, 32, 76, 79, 87, 69, 82, 32, 67, 69, 78, 84, 82, 69, 2, 149, 194, 20, - 11, 32, 77, 73, 68, 68, 76, 69, 32, 76, 69, 70, 5, 209, 215, 10, 9, 32, - 84, 79, 32, 77, 73, 68, 68, 76, 14, 68, 6, 76, 79, 87, 69, 82, 32, 97, 7, - 77, 73, 68, 68, 76, 69, 32, 6, 48, 6, 67, 69, 78, 84, 82, 69, 239, 175, - 35, 82, 5, 11, 32, 2, 233, 4, 4, 84, 79, 32, 85, 8, 76, 10, 67, 69, 78, - 84, 82, 69, 32, 84, 79, 32, 33, 5, 82, 73, 71, 72, 84, 4, 250, 3, 85, - 231, 202, 13, 76, 5, 11, 32, 2, 157, 206, 13, 2, 84, 79, 10, 46, 76, 69, - 7, 77, 73, 68, 68, 76, 69, 32, 4, 29, 5, 79, 87, 69, 82, 32, 4, 254, 210, - 32, 67, 191, 218, 2, 76, 6, 34, 67, 37, 4, 76, 69, 70, 84, 2, 45, 6, 69, - 78, 84, 82, 69, 32, 5, 11, 32, 2, 217, 174, 23, 2, 84, 79, 12, 36, 2, 87, - 78, 253, 2, 2, 85, 66, 9, 11, 32, 6, 25, 4, 65, 78, 68, 32, 6, 254, 150, - 29, 72, 218, 148, 6, 76, 31, 82, 9, 11, 32, 6, 40, 4, 65, 78, 68, 32, - 239, 164, 35, 87, 4, 26, 85, 135, 173, 23, 76, 2, 149, 173, 23, 2, 80, - 80, 5, 133, 130, 34, 10, 32, 65, 78, 68, 32, 72, 69, 65, 86, 89, 4, 109, - 5, 85, 65, 68, 82, 85, 6, 66, 82, 189, 201, 13, 10, 79, 80, 32, 65, 78, - 68, 32, 85, 80, 80, 4, 11, 73, 4, 11, 80, 4, 41, 8, 76, 69, 32, 68, 65, - 83, 72, 32, 4, 166, 181, 16, 86, 219, 222, 12, 72, 11, 29, 5, 32, 65, 78, - 68, 32, 8, 34, 72, 242, 167, 35, 76, 31, 82, 4, 248, 153, 24, 4, 69, 65, - 86, 89, 171, 249, 4, 79, 17, 29, 5, 32, 65, 78, 68, 32, 14, 154, 152, 28, - 66, 42, 84, 130, 122, 72, 218, 148, 6, 76, 31, 82, 16, 148, 2, 18, 68, - 79, 87, 78, 32, 72, 69, 65, 86, 89, 32, 65, 78, 68, 32, 76, 69, 70, 24, - 13, 72, 69, 65, 86, 89, 32, 65, 78, 68, 32, 76, 69, 70, 100, 13, 76, 73, - 71, 72, 84, 32, 65, 78, 68, 32, 76, 69, 70, 97, 16, 85, 80, 32, 72, 69, - 65, 86, 89, 32, 65, 78, 68, 32, 76, 69, 70, 2, 101, 3, 84, 32, 85, 6, 17, - 2, 84, 32, 6, 58, 85, 178, 3, 68, 245, 4, 6, 86, 69, 82, 84, 73, 67, 2, - 231, 177, 33, 80, 6, 17, 2, 84, 32, 6, 58, 85, 134, 4, 68, 205, 4, 6, 86, - 69, 82, 84, 73, 67, 2, 239, 8, 80, 2, 185, 2, 3, 84, 32, 68, 36, 128, 1, - 10, 72, 69, 65, 86, 89, 32, 65, 78, 68, 32, 188, 1, 10, 76, 73, 71, 72, - 84, 32, 65, 78, 68, 32, 186, 2, 68, 131, 4, 83, 12, 80, 4, 68, 79, 87, - 78, 24, 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, 255, 4, 72, 2, 145, 5, 2, - 32, 72, 4, 17, 2, 84, 32, 4, 26, 68, 203, 160, 35, 76, 2, 181, 174, 33, - 3, 79, 87, 78, 12, 80, 4, 68, 79, 87, 78, 24, 3, 76, 69, 70, 0, 4, 82, - 73, 71, 72, 211, 4, 72, 2, 229, 4, 2, 32, 72, 4, 17, 2, 84, 32, 4, 22, - 68, 131, 5, 72, 2, 233, 4, 3, 79, 87, 78, 24, 130, 1, 68, 188, 1, 10, 72, - 69, 65, 86, 89, 32, 65, 78, 68, 32, 144, 1, 10, 76, 73, 71, 72, 84, 32, - 65, 78, 68, 32, 183, 1, 83, 6, 49, 10, 79, 85, 66, 76, 69, 32, 65, 78, - 68, 32, 6, 92, 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, 13, 10, 72, 79, 82, - 73, 90, 79, 78, 84, 65, 76, 2, 11, 84, 2, 221, 240, 26, 2, 32, 83, 6, 54, - 72, 68, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, 2, 37, 7, 79, 82, 73, 90, - 79, 78, 84, 2, 193, 169, 33, 2, 65, 76, 2, 167, 169, 33, 84, 6, 54, 72, - 60, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, 2, 37, 7, 79, 82, 73, 90, 79, - 78, 84, 2, 29, 2, 65, 76, 2, 11, 84, 2, 17, 2, 32, 72, 2, 149, 179, 35, - 3, 69, 65, 86, 6, 49, 10, 73, 78, 71, 76, 69, 32, 65, 78, 68, 32, 6, 96, - 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, 229, 180, 26, 9, 72, 79, 82, 73, 90, - 79, 78, 84, 65, 2, 239, 180, 26, 84, 134, 6, 46, 65, 178, 14, 69, 150, 1, - 73, 179, 1, 79, 232, 5, 36, 4, 72, 77, 73, 32, 247, 9, 73, 230, 1, 192, - 1, 7, 76, 69, 84, 84, 69, 82, 32, 196, 2, 7, 78, 85, 77, 66, 69, 82, 32, - 144, 2, 12, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 32, 84, 5, 83, - 73, 71, 78, 32, 122, 86, 211, 249, 24, 68, 108, 210, 1, 79, 166, 225, 31, - 65, 38, 68, 114, 84, 46, 86, 186, 5, 85, 186, 202, 1, 73, 42, 76, 226, - 195, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 138, 69, - 72, 2, 77, 2, 82, 2, 89, 187, 2, 69, 15, 45, 9, 76, 68, 32, 84, 65, 77, - 73, 76, 32, 12, 202, 135, 29, 76, 142, 155, 2, 83, 210, 97, 78, 131, 246, - 2, 82, 42, 82, 69, 38, 70, 66, 78, 26, 83, 234, 176, 21, 84, 130, 234, 5, - 79, 227, 227, 7, 74, 4, 181, 172, 31, 4, 73, 71, 72, 84, 8, 26, 79, 195, - 151, 21, 73, 4, 178, 205, 33, 82, 135, 183, 1, 85, 4, 65, 3, 73, 78, 69, - 8, 40, 4, 69, 86, 69, 78, 1, 2, 73, 88, 5, 227, 170, 35, 84, 10, 46, 76, - 206, 213, 12, 68, 177, 16, 2, 67, 82, 4, 242, 198, 19, 79, 199, 217, 14, - 73, 12, 226, 157, 31, 67, 228, 67, 9, 79, 76, 68, 32, 84, 65, 77, 73, 76, - 246, 157, 1, 74, 158, 2, 86, 122, 85, 255, 243, 1, 65, 34, 64, 10, 79, - 87, 69, 76, 32, 83, 73, 71, 78, 32, 239, 253, 32, 73, 32, 138, 1, 79, - 152, 183, 29, 11, 66, 72, 65, 84, 84, 73, 80, 82, 79, 76, 85, 198, 170, - 2, 65, 38, 85, 22, 86, 166, 202, 1, 73, 199, 140, 2, 69, 7, 233, 156, 31, - 10, 76, 68, 32, 84, 65, 77, 73, 76, 32, 83, 130, 4, 72, 12, 76, 76, 69, - 32, 80, 65, 84, 84, 69, 82, 78, 32, 243, 183, 35, 78, 128, 4, 44, 5, 68, - 79, 84, 83, 45, 175, 246, 6, 66, 254, 3, 74, 49, 74, 50, 66, 51, 54, 52, - 46, 53, 38, 54, 30, 55, 199, 180, 35, 56, 129, 2, 66, 50, 66, 51, 54, 52, - 46, 53, 38, 54, 30, 55, 199, 180, 35, 56, 129, 1, 58, 51, 54, 52, 46, 53, - 38, 54, 30, 55, 199, 180, 35, 56, 65, 50, 52, 46, 53, 38, 54, 30, 55, - 199, 180, 35, 56, 33, 42, 53, 38, 54, 30, 55, 199, 180, 35, 56, 17, 34, - 54, 30, 55, 199, 180, 35, 56, 9, 26, 55, 199, 180, 35, 56, 5, 195, 180, - 35, 56, 8, 26, 65, 195, 157, 35, 86, 6, 196, 193, 20, 11, 75, 32, 80, 69, - 82, 77, 73, 84, 84, 69, 68, 152, 172, 8, 6, 83, 84, 45, 70, 69, 69, 183, - 198, 6, 68, 10, 42, 68, 96, 2, 69, 70, 251, 174, 35, 67, 4, 136, 181, 32, - 6, 71, 69, 32, 65, 84, 32, 149, 158, 1, 9, 69, 32, 87, 73, 84, 72, 32, - 86, 69, 4, 242, 136, 32, 67, 159, 169, 3, 83, 12, 84, 4, 75, 69, 78, 32, - 192, 196, 8, 2, 67, 67, 152, 229, 25, 2, 87, 78, 231, 118, 79, 6, 248, - 182, 27, 17, 67, 73, 82, 67, 76, 69, 32, 87, 73, 84, 72, 32, 78, 79, 82, - 84, 72, 222, 214, 6, 66, 151, 28, 72, 134, 1, 208, 1, 4, 66, 66, 76, 69, - 46, 71, 156, 4, 4, 72, 73, 68, 32, 36, 2, 76, 76, 122, 83, 56, 4, 84, 84, - 69, 82, 240, 253, 10, 10, 73, 76, 68, 73, 78, 71, 32, 67, 79, 78, 248, - 217, 16, 2, 82, 82, 255, 253, 6, 67, 4, 196, 154, 28, 2, 32, 84, 131, - 148, 7, 83, 63, 33, 6, 73, 78, 69, 83, 69, 32, 60, 144, 1, 7, 76, 69, 84, - 84, 69, 82, 32, 172, 2, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, - 146, 184, 16, 69, 193, 248, 13, 4, 80, 65, 76, 76, 46, 154, 1, 77, 34, - 78, 242, 168, 35, 66, 2, 67, 2, 68, 2, 71, 2, 72, 2, 74, 2, 75, 2, 76, 2, - 80, 2, 82, 2, 83, 2, 84, 2, 86, 2, 89, 187, 2, 65, 4, 142, 169, 35, 80, - 187, 2, 65, 12, 46, 71, 34, 89, 162, 168, 35, 82, 187, 2, 65, 4, 190, - 168, 35, 75, 187, 2, 65, 4, 158, 168, 35, 67, 187, 2, 65, 10, 226, 147, - 35, 65, 214, 22, 69, 2, 73, 2, 79, 3, 85, 40, 178, 156, 10, 76, 143, 245, - 18, 86, 10, 56, 2, 69, 84, 20, 4, 72, 79, 82, 78, 251, 166, 9, 83, 5, - 231, 229, 31, 32, 5, 241, 193, 27, 5, 32, 87, 73, 84, 72, 9, 26, 84, 199, - 211, 32, 32, 4, 234, 193, 27, 83, 15, 32, 5, 251, 132, 35, 70, 240, 3, - 140, 1, 23, 90, 65, 78, 84, 73, 78, 69, 32, 77, 85, 83, 73, 67, 65, 76, - 32, 83, 89, 77, 66, 79, 76, 32, 149, 188, 20, 5, 84, 69, 32, 79, 82, 238, - 3, 154, 2, 65, 128, 7, 2, 67, 72, 170, 1, 68, 158, 5, 69, 206, 2, 70, - 166, 8, 71, 202, 3, 73, 162, 2, 75, 142, 5, 76, 190, 2, 77, 250, 4, 79, - 114, 80, 174, 4, 82, 42, 83, 194, 5, 84, 196, 5, 2, 86, 65, 250, 1, 89, - 230, 179, 32, 78, 201, 146, 2, 9, 88, 73, 82, 79, 78, 32, 75, 76, 65, 62, - 60, 5, 71, 79, 71, 73, 32, 222, 1, 78, 118, 80, 199, 2, 82, 16, 70, 65, - 0, 2, 71, 79, 64, 2, 77, 69, 37, 5, 80, 79, 76, 73, 32, 4, 17, 2, 82, 71, - 4, 128, 230, 15, 2, 79, 84, 199, 189, 19, 73, 4, 234, 155, 9, 84, 219, - 243, 25, 83, 4, 26, 65, 1, 2, 71, 79, 2, 239, 210, 17, 82, 6, 72, 6, 84, - 73, 75, 69, 78, 79, 213, 128, 35, 6, 65, 84, 82, 73, 67, 72, 4, 168, 32, - 2, 75, 89, 155, 255, 34, 77, 22, 52, 5, 69, 83, 79, 32, 69, 38, 79, 163, - 141, 35, 76, 4, 204, 1, 2, 88, 79, 147, 55, 75, 16, 80, 6, 83, 84, 82, - 79, 70, 79, 188, 40, 3, 68, 69, 82, 237, 129, 1, 2, 84, 72, 10, 24, 2, - 73, 32, 79, 83, 4, 56, 9, 83, 89, 78, 68, 69, 83, 77, 79, 83, 195, 24, - 84, 2, 143, 44, 32, 7, 11, 32, 4, 214, 60, 68, 235, 149, 22, 78, 18, 48, - 2, 71, 79, 33, 6, 75, 84, 73, 75, 79, 32, 4, 170, 21, 83, 179, 137, 35, - 78, 14, 182, 199, 27, 86, 146, 184, 7, 90, 162, 8, 75, 254, 2, 68, 2, 78, - 162, 17, 71, 3, 80, 14, 80, 4, 82, 79, 65, 32, 168, 37, 4, 79, 82, 69, - 86, 221, 2, 4, 65, 77, 73, 76, 6, 132, 223, 19, 2, 83, 80, 156, 188, 3, - 3, 90, 89, 71, 205, 204, 10, 3, 75, 76, 73, 42, 50, 73, 192, 223, 8, 2, - 65, 83, 215, 157, 26, 89, 38, 122, 65, 200, 1, 5, 69, 83, 73, 83, 32, 70, - 71, 208, 1, 3, 80, 76, 73, 173, 192, 27, 8, 70, 84, 79, 71, 71, 79, 83, - 32, 10, 48, 6, 83, 84, 79, 76, 73, 32, 167, 224, 33, 82, 8, 80, 6, 65, - 80, 76, 73, 32, 77, 174, 55, 68, 237, 224, 22, 5, 84, 72, 69, 83, 69, 4, - 40, 2, 69, 71, 141, 174, 28, 2, 73, 75, 2, 247, 149, 30, 65, 12, 38, 84, - 246, 50, 65, 42, 68, 63, 77, 6, 194, 10, 69, 239, 41, 82, 10, 72, 5, 79, - 82, 71, 79, 78, 225, 151, 35, 7, 82, 65, 77, 77, 65, 32, 71, 9, 69, 15, - 32, 80, 65, 82, 69, 83, 84, 73, 71, 77, 69, 78, 79, 78, 32, 6, 222, 38, - 68, 137, 10, 8, 65, 82, 73, 83, 84, 69, 82, 65, 5, 175, 47, 32, 16, 166, - 1, 78, 116, 6, 84, 69, 82, 79, 78, 32, 188, 44, 4, 88, 79, 32, 69, 188, - 130, 33, 4, 80, 69, 71, 69, 236, 48, 6, 75, 83, 84, 82, 69, 80, 237, 13, - 3, 76, 65, 70, 4, 224, 22, 3, 68, 79, 70, 145, 168, 27, 18, 65, 82, 88, - 73, 83, 32, 75, 65, 73, 32, 70, 84, 72, 79, 82, 65, 32, 86, 4, 208, 11, - 5, 65, 82, 71, 79, 83, 151, 20, 80, 44, 180, 1, 9, 65, 78, 69, 82, 79, - 83, 73, 83, 32, 52, 6, 84, 72, 79, 82, 65, 32, 165, 6, 22, 72, 84, 79, - 82, 65, 32, 83, 75, 76, 73, 82, 79, 78, 32, 67, 72, 82, 79, 77, 65, 32, - 86, 6, 246, 4, 68, 14, 77, 25, 5, 84, 69, 84, 82, 65, 36, 220, 2, 8, 65, - 82, 67, 72, 65, 73, 79, 78, 80, 10, 68, 73, 65, 84, 79, 78, 73, 75, 73, - 32, 96, 11, 73, 32, 89, 70, 69, 83, 73, 83, 32, 84, 69, 32, 15, 77, 65, - 76, 65, 75, 79, 78, 32, 67, 72, 82, 79, 77, 65, 32, 74, 78, 40, 8, 83, - 75, 76, 73, 82, 79, 78, 32, 157, 217, 18, 18, 69, 78, 65, 82, 77, 79, 78, - 73, 79, 83, 32, 65, 78, 84, 73, 70, 79, 78, 5, 57, 12, 32, 68, 69, 89, - 84, 69, 82, 79, 85, 32, 73, 67, 2, 199, 184, 27, 72, 14, 62, 78, 134, - 240, 34, 90, 162, 8, 75, 254, 2, 68, 163, 17, 80, 6, 242, 39, 73, 239, - 168, 33, 65, 2, 237, 42, 4, 84, 65, 82, 84, 4, 18, 68, 15, 77, 2, 35, 73, - 2, 21, 3, 79, 78, 79, 2, 151, 19, 70, 4, 166, 19, 65, 245, 239, 32, 2, - 69, 78, 6, 84, 7, 67, 72, 82, 79, 77, 65, 32, 193, 157, 17, 8, 68, 73, - 65, 84, 79, 78, 79, 78, 4, 42, 86, 169, 161, 17, 4, 83, 89, 78, 65, 2, - 175, 229, 32, 65, 22, 80, 6, 69, 78, 73, 75, 73, 32, 44, 2, 79, 82, 185, - 26, 5, 82, 79, 78, 84, 72, 4, 244, 132, 31, 2, 68, 73, 1, 2, 89, 70, 16, - 68, 2, 71, 79, 225, 1, 10, 84, 72, 77, 73, 75, 79, 78, 32, 78, 32, 12, - 28, 2, 78, 32, 155, 1, 83, 10, 96, 14, 80, 65, 82, 69, 83, 84, 73, 71, - 77, 69, 78, 79, 78, 32, 242, 33, 65, 113, 3, 78, 69, 79, 4, 214, 24, 68, - 153, 223, 32, 5, 65, 82, 73, 83, 84, 2, 141, 212, 33, 5, 89, 78, 84, 72, - 69, 4, 142, 28, 65, 1, 2, 68, 73, 16, 56, 2, 77, 73, 114, 83, 233, 135, - 34, 4, 67, 72, 65, 68, 8, 34, 70, 169, 28, 3, 68, 73, 65, 6, 40, 4, 84, - 72, 79, 82, 175, 251, 33, 79, 4, 250, 183, 34, 79, 227, 79, 65, 6, 44, 6, - 65, 75, 73, 65, 32, 84, 231, 13, 79, 2, 217, 204, 21, 12, 69, 76, 79, 85, - 83, 32, 73, 67, 72, 73, 77, 65, 54, 108, 2, 65, 84, 96, 6, 69, 78, 84, - 73, 77, 65, 140, 1, 5, 76, 65, 83, 77, 65, 18, 79, 98, 82, 175, 1, 89, 6, - 40, 3, 65, 86, 65, 201, 3, 2, 72, 73, 4, 140, 29, 5, 32, 84, 82, 79, 77, - 143, 199, 34, 83, 18, 24, 2, 84, 65, 15, 32, 11, 11, 32, 8, 36, 4, 78, - 69, 79, 32, 183, 28, 65, 6, 132, 150, 28, 2, 77, 69, 170, 222, 2, 75, - 235, 230, 3, 65, 7, 243, 28, 32, 8, 64, 6, 78, 84, 69, 86, 77, 65, 222, - 216, 8, 82, 139, 137, 26, 85, 5, 145, 169, 14, 2, 32, 65, 14, 44, 4, 65, - 84, 73, 77, 105, 3, 69, 77, 65, 12, 18, 65, 35, 79, 8, 182, 23, 32, 203, - 232, 34, 84, 4, 134, 12, 75, 233, 203, 31, 5, 89, 80, 79, 82, 82, 2, 227, - 149, 27, 83, 2, 167, 224, 34, 76, 14, 22, 69, 147, 22, 89, 12, 44, 5, 73, - 77, 77, 65, 32, 243, 137, 30, 77, 10, 72, 2, 69, 78, 0, 5, 73, 77, 73, - 83, 69, 54, 84, 69, 3, 68, 89, 79, 2, 161, 169, 27, 8, 79, 83, 32, 67, - 72, 82, 79, 78, 4, 44, 5, 69, 83, 83, 65, 82, 1, 2, 82, 73, 2, 17, 2, 79, - 78, 2, 25, 4, 32, 67, 72, 82, 2, 227, 242, 33, 79, 28, 84, 8, 65, 82, 84, - 89, 82, 73, 65, 32, 153, 250, 30, 7, 73, 75, 82, 79, 78, 32, 73, 26, 72, - 5, 65, 76, 76, 73, 32, 38, 68, 38, 80, 134, 1, 86, 30, 84, 87, 76, 4, 34, - 68, 177, 2, 3, 80, 82, 79, 2, 237, 2, 5, 69, 89, 84, 69, 82, 8, 60, 7, - 76, 65, 71, 73, 79, 83, 32, 45, 4, 82, 79, 84, 79, 4, 200, 1, 5, 84, 69, - 84, 65, 82, 111, 73, 4, 22, 86, 227, 1, 83, 2, 209, 1, 3, 65, 82, 89, 8, - 56, 8, 69, 84, 65, 82, 84, 79, 83, 32, 61, 2, 82, 73, 4, 22, 76, 135, 1, - 73, 2, 21, 3, 69, 71, 69, 2, 63, 84, 4, 18, 70, 35, 84, 2, 145, 201, 21, - 3, 79, 78, 73, 2, 11, 79, 2, 11, 83, 2, 17, 2, 32, 73, 2, 251, 243, 22, - 67, 18, 92, 4, 76, 73, 71, 79, 180, 1, 5, 89, 82, 65, 78, 73, 210, 14, - 88, 173, 153, 34, 2, 77, 65, 4, 211, 1, 78, 42, 60, 2, 65, 82, 100, 2, - 73, 65, 90, 69, 169, 1, 2, 83, 73, 12, 40, 2, 65, 75, 161, 178, 17, 2, - 73, 67, 10, 52, 3, 65, 76, 69, 45, 6, 76, 73, 84, 73, 75, 73, 4, 11, 83, - 4, 17, 2, 77, 65, 4, 23, 32, 7, 11, 32, 4, 198, 15, 65, 135, 155, 22, 78, - 12, 72, 3, 84, 65, 83, 136, 3, 6, 76, 65, 83, 84, 79, 78, 211, 220, 8, - 82, 6, 26, 84, 255, 243, 34, 77, 4, 32, 2, 79, 75, 147, 246, 34, 73, 2, - 217, 212, 34, 2, 79, 85, 14, 36, 5, 70, 73, 83, 84, 79, 67, 76, 10, 46, - 80, 214, 1, 78, 170, 8, 76, 187, 1, 83, 2, 135, 11, 65, 4, 170, 165, 34, - 79, 227, 79, 73, 4, 178, 5, 69, 145, 206, 34, 2, 65, 80, 42, 120, 5, 69, + 1, 82, 132, 176, 3, 10, 67, 72, 32, 87, 73, 84, 72, 32, 85, 77, 246, 189, + 7, 84, 178, 153, 26, 86, 19, 78, 8, 86, 65, 0, 2, 68, 69, 52, 4, 69, 73, + 71, 72, 1, 7, 83, 73, 88, 84, 69, 69, 78, 2, 253, 129, 21, 8, 83, 67, 69, + 78, 68, 73, 78, 71, 2, 245, 129, 21, 2, 84, 72, 4, 136, 187, 33, 3, 68, + 69, 68, 247, 204, 3, 32, 4, 220, 229, 8, 3, 82, 32, 77, 139, 184, 27, 84, + 15, 11, 76, 13, 54, 32, 216, 143, 26, 3, 72, 79, 80, 255, 242, 9, 79, 6, + 218, 224, 12, 80, 152, 243, 16, 6, 87, 73, 84, 72, 32, 67, 211, 218, 6, + 83, 212, 1, 84, 5, 71, 65, 76, 73, 32, 222, 10, 84, 37, 9, 90, 69, 78, + 69, 32, 82, 73, 78, 71, 204, 1, 210, 1, 65, 40, 9, 67, 85, 82, 82, 69, + 78, 67, 89, 32, 148, 2, 7, 76, 69, 84, 84, 69, 82, 32, 192, 4, 6, 82, 85, + 80, 69, 69, 32, 34, 83, 166, 198, 23, 73, 214, 4, 86, 190, 247, 11, 68, + 249, 113, 3, 71, 65, 78, 6, 214, 154, 33, 66, 50, 78, 247, 63, 85, 12, + 120, 10, 78, 85, 77, 69, 82, 65, 84, 79, 82, 32, 153, 156, 24, 14, 68, + 69, 78, 79, 77, 73, 78, 65, 84, 79, 82, 32, 83, 73, 10, 52, 3, 79, 78, + 69, 226, 157, 32, 70, 215, 171, 3, 84, 5, 153, 173, 30, 19, 32, 76, 69, + 83, 83, 32, 84, 72, 65, 78, 32, 84, 72, 69, 32, 68, 69, 78, 79, 110, 226, + 1, 65, 118, 75, 90, 82, 206, 172, 22, 86, 214, 144, 8, 89, 166, 155, 3, + 68, 114, 84, 230, 5, 85, 138, 204, 1, 73, 170, 199, 1, 78, 46, 83, 82, + 66, 2, 67, 2, 71, 2, 74, 2, 80, 138, 69, 72, 2, 76, 2, 77, 186, 2, 69, 3, + 79, 11, 208, 157, 19, 16, 76, 84, 69, 82, 78, 65, 84, 69, 32, 66, 65, 82, + 71, 73, 89, 65, 254, 158, 18, 65, 2, 73, 3, 85, 8, 26, 72, 195, 187, 37, + 65, 6, 26, 65, 191, 166, 14, 73, 5, 133, 158, 19, 3, 78, 68, 65, 10, 34, + 65, 170, 184, 37, 72, 3, 82, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 132, + 135, 26, 5, 76, 79, 87, 69, 82, 1, 6, 77, 73, 68, 68, 76, 69, 4, 138, + 179, 36, 83, 191, 69, 77, 22, 128, 1, 19, 69, 81, 85, 69, 78, 67, 69, 32, + 70, 79, 82, 32, 76, 69, 84, 84, 69, 82, 32, 36, 4, 73, 71, 78, 32, 223, + 243, 26, 65, 6, 190, 200, 23, 82, 183, 237, 13, 89, 14, 214, 138, 10, 67, + 222, 138, 23, 78, 198, 67, 65, 171, 156, 3, 86, 4, 170, 135, 27, 32, 223, + 161, 9, 79, 5, 181, 185, 34, 3, 32, 87, 73, 100, 56, 6, 67, 65, 80, 73, + 84, 65, 1, 4, 83, 77, 65, 76, 50, 45, 9, 76, 32, 76, 69, 84, 84, 69, 82, + 32, 50, 182, 2, 65, 50, 68, 42, 69, 82, 71, 38, 78, 38, 83, 186, 194, 17, + 77, 232, 237, 1, 6, 72, 73, 82, 68, 69, 65, 0, 2, 75, 79, 204, 236, 13, + 6, 84, 65, 84, 65, 83, 79, 140, 212, 2, 5, 66, 65, 83, 73, 71, 248, 53, + 3, 87, 65, 83, 164, 108, 3, 70, 73, 84, 0, 3, 76, 65, 75, 170, 11, 79, 2, + 80, 2, 85, 219, 19, 73, 4, 26, 82, 235, 179, 37, 89, 2, 151, 244, 23, 75, + 4, 156, 186, 32, 3, 65, 82, 66, 3, 74, 6, 40, 4, 82, 73, 71, 79, 131, + 179, 37, 72, 5, 169, 252, 20, 4, 32, 84, 65, 77, 4, 202, 206, 30, 79, + 219, 225, 6, 78, 4, 238, 167, 32, 73, 171, 252, 3, 71, 4, 230, 136, 27, + 72, 163, 184, 3, 69, 4, 206, 216, 35, 87, 235, 67, 32, 194, 1, 184, 2, 7, + 76, 69, 84, 84, 69, 82, 32, 244, 1, 7, 78, 85, 77, 66, 69, 82, 32, 72, 5, + 83, 73, 71, 78, 32, 48, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, + 226, 227, 26, 68, 206, 249, 3, 87, 196, 195, 2, 10, 71, 65, 80, 32, 70, + 73, 76, 76, 69, 82, 237, 192, 3, 12, 72, 85, 78, 68, 82, 69, 68, 83, 32, + 85, 78, 73, 92, 210, 1, 86, 218, 202, 33, 65, 38, 68, 114, 84, 230, 5, + 85, 138, 204, 1, 73, 170, 199, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, + 74, 2, 75, 2, 80, 138, 69, 72, 2, 76, 2, 77, 2, 82, 2, 89, 186, 2, 69, 3, + 79, 8, 234, 1, 79, 211, 171, 37, 65, 36, 170, 126, 69, 38, 70, 66, 78, + 26, 83, 202, 150, 22, 84, 255, 251, 12, 79, 10, 250, 136, 33, 67, 166, + 68, 65, 171, 156, 3, 86, 24, 80, 2, 86, 79, 194, 207, 33, 65, 38, 85, + 138, 204, 1, 73, 230, 143, 2, 69, 3, 79, 6, 33, 6, 67, 65, 76, 73, 67, + 32, 6, 158, 208, 33, 82, 143, 219, 3, 76, 26, 148, 1, 4, 67, 89, 67, 76, + 36, 2, 71, 32, 28, 2, 76, 76, 46, 82, 66, 84, 176, 242, 19, 4, 79, 72, + 65, 90, 204, 171, 12, 2, 75, 73, 223, 186, 4, 83, 4, 138, 183, 33, 73, + 231, 242, 3, 69, 4, 250, 140, 35, 82, 67, 83, 4, 160, 247, 9, 2, 69, 68, + 247, 204, 24, 73, 4, 232, 183, 33, 7, 84, 72, 68, 65, 89, 32, 67, 155, + 241, 3, 68, 4, 220, 248, 13, 2, 67, 79, 173, 174, 23, 4, 73, 78, 71, 32, + 198, 7, 42, 65, 202, 33, 79, 165, 11, 2, 85, 69, 248, 2, 32, 2, 67, 75, + 199, 180, 18, 78, 246, 2, 22, 32, 251, 31, 45, 230, 2, 210, 1, 67, 154, + 5, 68, 174, 2, 70, 102, 72, 82, 76, 186, 4, 77, 250, 2, 78, 38, 80, 46, + 82, 150, 4, 83, 154, 4, 84, 82, 85, 248, 2, 3, 86, 69, 82, 174, 160, 12, + 79, 144, 174, 21, 3, 66, 79, 87, 191, 250, 1, 81, 104, 196, 1, 5, 73, 82, + 67, 76, 69, 228, 1, 6, 85, 82, 86, 69, 68, 32, 252, 234, 26, 12, 82, 79, + 83, 83, 32, 79, 78, 32, 83, 72, 73, 69, 128, 164, 3, 5, 69, 78, 84, 82, + 69, 174, 175, 5, 72, 159, 14, 76, 13, 11, 32, 10, 72, 5, 87, 73, 84, 72, + 32, 221, 173, 17, 7, 70, 79, 82, 32, 82, 69, 67, 8, 96, 6, 87, 72, 73, + 84, 69, 32, 170, 131, 20, 68, 141, 180, 2, 8, 84, 87, 79, 32, 87, 72, 73, + 84, 4, 196, 68, 2, 68, 79, 243, 255, 33, 86, 16, 84, 4, 68, 79, 87, 78, + 0, 2, 85, 80, 56, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, 4, 253, 245, 32, + 9, 87, 65, 82, 68, 83, 32, 65, 78, 68, 4, 53, 11, 84, 87, 65, 82, 68, 83, + 32, 65, 78, 68, 32, 4, 186, 253, 21, 85, 167, 173, 12, 68, 30, 64, 6, 73, + 65, 77, 79, 78, 68, 152, 1, 3, 79, 87, 78, 43, 82, 13, 11, 32, 10, 154, + 19, 67, 184, 158, 13, 10, 77, 73, 78, 85, 83, 32, 87, 72, 73, 84, 240, + 206, 6, 6, 87, 73, 84, 72, 32, 68, 194, 216, 15, 79, 135, 13, 83, 12, + 214, 19, 32, 62, 45, 251, 161, 32, 87, 6, 252, 184, 35, 2, 79, 80, 211, + 21, 65, 8, 18, 76, 39, 79, 4, 162, 221, 28, 79, 239, 191, 8, 65, 4, 212, + 221, 2, 2, 85, 82, 223, 152, 32, 76, 12, 38, 69, 246, 209, 35, 65, 251, + 2, 79, 6, 188, 211, 35, 2, 65, 82, 235, 11, 88, 40, 64, 5, 65, 82, 71, + 69, 32, 140, 2, 3, 69, 70, 84, 203, 1, 79, 12, 48, 6, 67, 73, 82, 67, 76, + 69, 175, 248, 35, 83, 11, 37, 7, 32, 77, 73, 78, 85, 83, 32, 8, 54, 76, + 36, 4, 82, 73, 71, 72, 13, 3, 85, 80, 80, 4, 32, 2, 69, 70, 13, 2, 79, + 87, 2, 31, 84, 2, 17, 2, 69, 82, 2, 133, 148, 34, 8, 32, 81, 85, 65, 82, + 84, 69, 82, 22, 96, 10, 45, 80, 79, 73, 78, 84, 73, 78, 71, 32, 64, 6, + 87, 65, 82, 68, 83, 32, 251, 210, 35, 32, 12, 146, 7, 68, 190, 8, 73, + 206, 198, 35, 80, 146, 27, 83, 51, 84, 4, 206, 165, 34, 69, 203, 141, 1, + 66, 6, 158, 15, 87, 191, 206, 35, 90, 30, 76, 6, 69, 68, 73, 85, 77, 32, + 173, 200, 22, 7, 79, 79, 78, 32, 76, 73, 76, 28, 66, 68, 42, 76, 36, 4, + 82, 73, 71, 72, 12, 2, 85, 80, 111, 83, 6, 84, 3, 79, 87, 78, 179, 212, + 35, 73, 6, 32, 2, 69, 70, 211, 219, 35, 79, 4, 11, 84, 4, 81, 18, 45, 80, + 79, 73, 78, 84, 73, 78, 71, 32, 84, 82, 73, 65, 78, 71, 76, 69, 5, 145, + 9, 2, 32, 67, 8, 198, 13, 77, 219, 228, 35, 81, 4, 158, 217, 17, 69, 251, + 250, 17, 73, 8, 162, 244, 25, 85, 250, 223, 9, 65, 87, 69, 34, 52, 4, 73, + 71, 72, 84, 158, 255, 34, 79, 139, 86, 69, 30, 94, 32, 84, 10, 45, 80, + 79, 73, 78, 84, 73, 78, 71, 32, 245, 1, 6, 87, 65, 82, 68, 83, 32, 6, 60, + 9, 84, 82, 73, 65, 78, 71, 76, 69, 32, 255, 232, 35, 80, 2, 231, 232, 6, + 67, 16, 90, 68, 88, 8, 84, 82, 73, 65, 78, 71, 76, 69, 230, 7, 73, 210, + 203, 35, 80, 143, 22, 83, 4, 65, 14, 79, 85, 66, 76, 69, 32, 84, 82, 73, + 65, 78, 71, 76, 69, 5, 219, 199, 16, 32, 5, 193, 211, 21, 11, 32, 87, 73, + 84, 72, 32, 68, 79, 85, 66, 76, 8, 154, 235, 19, 65, 202, 178, 14, 69, + 203, 141, 1, 66, 40, 158, 2, 77, 148, 1, 5, 81, 85, 65, 82, 69, 136, 239, + 26, 3, 85, 78, 32, 156, 224, 1, 5, 75, 85, 76, 76, 32, 192, 185, 3, 3, + 78, 79, 87, 156, 230, 1, 5, 65, 70, 69, 84, 89, 148, 132, 1, 13, 76, 73, + 71, 72, 84, 76, 89, 32, 83, 77, 65, 76, 76, 226, 93, 67, 50, 72, 222, 1, + 80, 131, 22, 84, 12, 40, 4, 65, 76, 76, 32, 219, 211, 35, 73, 10, 230, + 203, 35, 68, 150, 7, 76, 70, 83, 153, 18, 13, 85, 80, 45, 80, 79, 73, 78, + 84, 73, 78, 71, 32, 67, 9, 11, 32, 6, 54, 67, 172, 179, 34, 3, 70, 79, + 82, 215, 160, 1, 66, 2, 169, 242, 31, 3, 69, 78, 84, 14, 192, 4, 3, 73, + 78, 89, 218, 153, 24, 82, 134, 192, 11, 79, 54, 69, 135, 2, 87, 18, 38, + 80, 177, 214, 33, 3, 78, 73, 86, 16, 46, 32, 62, 45, 170, 1, 80, 211, + 160, 32, 87, 2, 189, 225, 35, 10, 80, 79, 73, 78, 84, 73, 78, 71, 32, 66, + 8, 45, 9, 80, 79, 73, 78, 84, 73, 78, 71, 32, 8, 66, 73, 240, 221, 35, 5, + 68, 79, 85, 66, 76, 238, 3, 83, 51, 84, 2, 181, 219, 34, 8, 83, 79, 83, + 67, 69, 76, 69, 83, 4, 21, 3, 69, 82, 32, 4, 142, 163, 25, 76, 243, 183, + 9, 82, 10, 56, 6, 84, 73, 67, 65, 76, 32, 41, 4, 89, 32, 83, 77, 4, 168, + 201, 35, 2, 82, 69, 175, 25, 69, 6, 21, 3, 65, 76, 76, 6, 11, 32, 6, 202, + 197, 35, 68, 150, 7, 76, 203, 23, 83, 16, 84, 15, 76, 69, 84, 84, 69, 82, + 32, 67, 65, 80, 73, 84, 65, 76, 32, 251, 177, 11, 70, 10, 194, 134, 37, + 67, 2, 72, 2, 73, 2, 82, 3, 90, 200, 4, 52, 3, 67, 75, 32, 142, 152, 2, + 83, 139, 235, 10, 87, 196, 4, 80, 7, 79, 67, 84, 65, 78, 84, 45, 149, 7, + 8, 83, 69, 88, 84, 65, 78, 84, 45, 204, 3, 58, 49, 130, 3, 50, 114, 53, + 50, 54, 18, 51, 215, 1, 52, 234, 1, 74, 50, 246, 1, 51, 174, 91, 52, 46, + 53, 38, 54, 30, 55, 227, 165, 36, 56, 116, 62, 51, 226, 92, 52, 46, 53, + 38, 54, 30, 55, 227, 165, 36, 56, 55, 54, 52, 214, 92, 53, 38, 54, 30, + 55, 227, 165, 36, 56, 22, 50, 53, 166, 2, 54, 190, 90, 55, 227, 165, 36, + 56, 11, 42, 54, 174, 209, 29, 55, 235, 176, 7, 56, 4, 146, 130, 37, 55, + 3, 56, 56, 170, 1, 53, 50, 54, 210, 89, 52, 110, 55, 227, 165, 36, 56, + 118, 62, 52, 254, 89, 51, 98, 53, 38, 54, 30, 55, 227, 165, 36, 56, 24, + 46, 53, 50, 54, 190, 90, 55, 227, 165, 36, 56, 13, 206, 1, 54, 150, 206, + 29, 55, 235, 176, 7, 56, 7, 187, 90, 55, 61, 54, 52, 118, 53, 230, 88, + 54, 30, 55, 227, 165, 36, 56, 31, 46, 53, 170, 89, 54, 30, 55, 227, 165, + 36, 56, 15, 38, 54, 158, 89, 55, 227, 165, 36, 56, 7, 250, 254, 36, 55, + 3, 56, 14, 226, 88, 54, 30, 55, 227, 165, 36, 56, 31, 46, 54, 234, 87, + 53, 66, 55, 227, 165, 36, 56, 6, 166, 88, 55, 227, 165, 36, 56, 120, 70, + 49, 238, 1, 50, 246, 170, 26, 51, 38, 52, 30, 53, 131, 208, 10, 54, 61, + 58, 50, 126, 51, 206, 171, 26, 52, 30, 53, 131, 208, 10, 54, 31, 50, 51, + 150, 172, 26, 52, 30, 53, 131, 208, 10, 54, 15, 42, 52, 134, 172, 26, 53, + 131, 208, 10, 54, 7, 130, 252, 36, 53, 3, 54, 15, 202, 171, 26, 52, 202, + 159, 3, 53, 215, 176, 7, 54, 31, 50, 52, 194, 170, 26, 51, 66, 53, 131, + 208, 10, 54, 7, 255, 170, 26, 53, 6, 170, 131, 23, 32, 245, 211, 8, 4, + 66, 69, 82, 82, 232, 4, 200, 1, 3, 76, 68, 32, 78, 79, 104, 7, 80, 79, + 77, 79, 70, 79, 32, 188, 6, 2, 84, 84, 216, 6, 5, 85, 81, 85, 69, 84, 54, + 87, 198, 1, 88, 178, 243, 5, 77, 246, 171, 3, 89, 170, 144, 27, 65, 139, + 34, 78, 14, 190, 216, 8, 83, 202, 244, 7, 69, 238, 142, 18, 70, 234, 2, + 87, 203, 11, 71, 10, 26, 75, 175, 251, 23, 77, 9, 40, 4, 77, 65, 82, 75, + 215, 247, 36, 83, 5, 245, 149, 24, 3, 32, 84, 65, 150, 1, 96, 13, 70, 73, + 78, 65, 76, 32, 76, 69, 84, 84, 69, 82, 32, 53, 7, 76, 69, 84, 84, 69, + 82, 32, 10, 202, 246, 36, 71, 2, 72, 2, 75, 2, 80, 3, 84, 140, 1, 234, 1, + 65, 54, 85, 22, 69, 82, 71, 46, 73, 70, 78, 38, 79, 98, 90, 218, 183, 7, + 75, 238, 162, 25, 67, 2, 76, 2, 83, 238, 58, 66, 138, 204, 1, 74, 230, + 143, 2, 68, 2, 70, 2, 72, 2, 77, 2, 80, 2, 81, 2, 82, 2, 84, 2, 86, 3, + 88, 21, 50, 73, 2, 85, 74, 78, 174, 243, 36, 72, 3, 77, 5, 147, 164, 36, + 78, 17, 50, 78, 174, 243, 36, 69, 2, 72, 2, 73, 3, 82, 7, 170, 243, 36, + 71, 3, 78, 11, 142, 243, 36, 72, 2, 78, 2, 85, 3, 87, 15, 220, 241, 34, + 2, 78, 78, 134, 129, 2, 72, 2, 77, 2, 82, 3, 85, 9, 134, 241, 34, 71, + 155, 129, 2, 78, 17, 66, 78, 182, 240, 35, 32, 134, 129, 1, 69, 2, 77, 2, + 79, 3, 85, 4, 182, 241, 36, 71, 3, 78, 9, 154, 241, 36, 72, 2, 73, 3, 89, + 66, 104, 3, 79, 77, 32, 241, 156, 22, 17, 76, 69, 32, 87, 73, 84, 72, 32, + 80, 79, 80, 80, 73, 78, 71, 32, 67, 64, 152, 2, 5, 72, 65, 76, 70, 32, + 232, 1, 5, 76, 69, 70, 84, 32, 88, 6, 82, 73, 71, 72, 84, 32, 88, 14, 83, + 81, 85, 65, 82, 69, 32, 66, 82, 65, 67, 75, 69, 84, 162, 142, 16, 65, + 150, 204, 16, 67, 210, 3, 80, 140, 3, 13, 74, 85, 83, 84, 73, 70, 73, 69, + 68, 32, 85, 80, 80, 147, 5, 84, 32, 148, 1, 16, 70, 79, 82, 87, 65, 82, + 68, 45, 70, 65, 67, 73, 78, 71, 32, 82, 138, 223, 32, 76, 22, 82, 252, 2, + 2, 83, 84, 186, 5, 66, 247, 247, 1, 73, 10, 212, 142, 30, 11, 85, 78, 78, + 69, 82, 32, 70, 82, 65, 77, 69, 143, 210, 2, 79, 8, 200, 228, 32, 13, 74, + 85, 83, 84, 73, 70, 73, 69, 68, 32, 85, 80, 80, 126, 67, 51, 72, 8, 238, + 228, 32, 67, 50, 72, 33, 13, 74, 85, 83, 84, 73, 70, 73, 69, 68, 32, 85, + 80, 80, 5, 157, 194, 24, 9, 32, 79, 86, 69, 82, 32, 84, 79, 80, 5, 161, + 217, 35, 8, 32, 79, 70, 32, 70, 76, 79, 87, 14, 58, 76, 116, 3, 84, 73, + 69, 233, 134, 34, 3, 32, 65, 78, 6, 26, 32, 159, 152, 36, 73, 4, 172, + 214, 9, 7, 79, 70, 32, 72, 89, 71, 73, 169, 228, 23, 6, 87, 73, 84, 72, + 32, 83, 7, 167, 196, 33, 32, 218, 2, 88, 10, 32, 68, 82, 65, 87, 73, 78, + 71, 83, 32, 233, 234, 35, 6, 73, 78, 71, 32, 71, 76, 216, 2, 176, 1, 2, + 68, 79, 228, 6, 6, 72, 69, 65, 86, 89, 32, 254, 2, 76, 204, 25, 6, 82, + 73, 71, 72, 84, 32, 144, 4, 3, 85, 80, 32, 245, 3, 9, 86, 69, 82, 84, 73, + 67, 65, 76, 32, 66, 52, 5, 85, 66, 76, 69, 32, 165, 3, 3, 87, 78, 32, 30, + 58, 68, 216, 2, 2, 85, 80, 234, 5, 86, 219, 151, 30, 72, 14, 64, 8, 73, + 65, 71, 79, 78, 65, 76, 32, 149, 2, 3, 79, 87, 78, 8, 104, 6, 85, 80, 80, + 69, 82, 32, 205, 14, 15, 76, 79, 87, 69, 82, 32, 76, 69, 70, 84, 32, 84, + 79, 32, 77, 6, 76, 8, 76, 69, 70, 84, 32, 84, 79, 32, 237, 24, 6, 82, 73, + 71, 72, 84, 32, 4, 204, 23, 14, 77, 73, 68, 68, 76, 69, 32, 67, 69, 78, + 84, 82, 69, 32, 247, 152, 24, 76, 6, 199, 26, 32, 36, 128, 1, 10, 72, 69, + 65, 86, 89, 32, 65, 78, 68, 32, 132, 1, 10, 76, 73, 71, 72, 84, 32, 65, + 78, 68, 32, 210, 38, 68, 131, 4, 83, 12, 76, 3, 76, 69, 70, 0, 4, 82, 73, + 71, 72, 228, 35, 2, 85, 80, 151, 5, 72, 4, 17, 2, 84, 32, 4, 230, 32, 85, + 151, 149, 36, 76, 12, 76, 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, 156, 36, + 2, 85, 80, 235, 4, 72, 4, 17, 2, 84, 32, 4, 198, 32, 85, 135, 9, 72, 46, + 136, 1, 4, 76, 69, 70, 84, 68, 2, 85, 80, 130, 1, 86, 172, 20, 2, 68, 79, + 170, 2, 81, 100, 2, 84, 82, 162, 128, 30, 72, 183, 154, 6, 82, 5, 45, 9, + 32, 65, 78, 68, 32, 76, 73, 71, 72, 2, 191, 135, 35, 84, 11, 29, 5, 32, + 65, 78, 68, 32, 8, 42, 76, 142, 152, 30, 72, 183, 154, 6, 82, 4, 232, + 154, 25, 4, 73, 71, 72, 84, 199, 151, 11, 69, 8, 209, 20, 7, 69, 82, 84, + 73, 67, 65, 76, 156, 1, 56, 4, 69, 70, 84, 32, 169, 2, 5, 73, 71, 72, 84, + 32, 16, 160, 27, 19, 68, 79, 87, 78, 32, 72, 69, 65, 86, 89, 32, 65, 78, + 68, 32, 82, 73, 71, 72, 24, 14, 72, 69, 65, 86, 89, 32, 65, 78, 68, 32, + 82, 73, 71, 72, 100, 14, 76, 73, 71, 72, 84, 32, 65, 78, 68, 32, 82, 73, + 71, 72, 97, 17, 85, 80, 32, 72, 69, 65, 86, 89, 32, 65, 78, 68, 32, 82, + 73, 71, 72, 140, 1, 248, 1, 4, 65, 82, 67, 32, 30, 68, 248, 15, 10, 72, + 79, 82, 73, 90, 79, 78, 84, 65, 76, 112, 4, 76, 69, 70, 84, 62, 81, 34, + 84, 172, 1, 2, 85, 80, 120, 8, 86, 69, 82, 84, 73, 67, 65, 76, 156, 231, + 13, 7, 66, 79, 84, 84, 79, 77, 32, 219, 177, 22, 82, 8, 138, 148, 18, 68, + 67, 85, 80, 52, 8, 73, 65, 71, 79, 78, 65, 76, 32, 199, 14, 79, 68, 168, + 1, 14, 76, 79, 87, 69, 82, 32, 76, 69, 70, 84, 32, 84, 79, 32, 96, 7, 77, + 73, 68, 68, 76, 69, 32, 136, 3, 6, 85, 80, 80, 69, 82, 32, 178, 139, 35, + 67, 183, 4, 68, 4, 38, 77, 33, 5, 85, 80, 80, 69, 82, 2, 29, 5, 73, 68, + 68, 76, 69, 2, 129, 12, 2, 32, 67, 16, 88, 8, 76, 69, 70, 84, 32, 84, 79, + 32, 213, 1, 9, 82, 73, 71, 72, 84, 32, 84, 79, 32, 10, 156, 1, 6, 76, 79, + 87, 69, 82, 32, 33, 28, 85, 80, 80, 69, 82, 32, 67, 69, 78, 84, 82, 69, + 32, 84, 79, 32, 77, 73, 68, 68, 76, 69, 32, 82, 73, 71, 72, 84, 6, 246, + 3, 67, 167, 164, 36, 82, 5, 163, 173, 21, 32, 6, 232, 4, 15, 85, 80, 80, + 69, 82, 32, 67, 69, 78, 84, 82, 69, 32, 84, 79, 235, 3, 76, 44, 144, 1, + 10, 67, 69, 78, 84, 82, 69, 32, 84, 79, 32, 248, 3, 8, 76, 69, 70, 84, + 32, 84, 79, 32, 193, 2, 9, 82, 73, 71, 72, 84, 32, 84, 79, 32, 20, 52, 7, + 77, 73, 68, 68, 76, 69, 32, 131, 156, 24, 76, 16, 56, 4, 76, 69, 70, 84, + 165, 1, 5, 82, 73, 71, 72, 84, 9, 11, 32, 6, 84, 10, 84, 79, 32, 76, 79, + 87, 69, 82, 32, 67, 133, 169, 21, 5, 65, 78, 68, 32, 77, 4, 29, 5, 69, + 78, 84, 82, 69, 5, 221, 196, 33, 3, 32, 84, 79, 9, 11, 32, 6, 88, 3, 65, + 78, 68, 65, 15, 84, 79, 32, 76, 79, 87, 69, 82, 32, 67, 69, 78, 84, 82, + 69, 2, 141, 168, 21, 11, 32, 77, 73, 68, 68, 76, 69, 32, 76, 69, 70, 5, + 213, 242, 10, 9, 32, 84, 79, 32, 77, 73, 68, 68, 76, 14, 68, 6, 76, 79, + 87, 69, 82, 32, 97, 7, 77, 73, 68, 68, 76, 69, 32, 6, 48, 6, 67, 69, 78, + 84, 82, 69, 139, 161, 36, 82, 5, 11, 32, 2, 233, 4, 4, 84, 79, 32, 85, 8, + 76, 10, 67, 69, 78, 84, 82, 69, 32, 84, 79, 32, 33, 5, 82, 73, 71, 72, + 84, 4, 250, 3, 85, 231, 234, 13, 76, 5, 11, 32, 2, 157, 238, 13, 2, 84, + 79, 10, 46, 76, 69, 7, 77, 73, 68, 68, 76, 69, 32, 4, 29, 5, 79, 87, 69, + 82, 32, 4, 158, 192, 33, 67, 187, 222, 2, 76, 6, 34, 67, 37, 4, 76, 69, + 70, 84, 2, 45, 6, 69, 78, 84, 82, 69, 32, 5, 11, 32, 2, 221, 149, 24, 2, + 84, 79, 12, 36, 2, 87, 78, 253, 2, 2, 85, 66, 9, 11, 32, 6, 25, 4, 65, + 78, 68, 32, 6, 218, 130, 30, 72, 154, 154, 6, 76, 31, 82, 9, 11, 32, 6, + 40, 4, 65, 78, 68, 32, 139, 150, 36, 87, 4, 26, 85, 139, 148, 24, 76, 2, + 153, 148, 24, 2, 80, 80, 5, 145, 240, 34, 10, 32, 65, 78, 68, 32, 72, 69, + 65, 86, 89, 4, 109, 5, 85, 65, 68, 82, 85, 6, 66, 82, 189, 233, 13, 10, + 79, 80, 32, 65, 78, 68, 32, 85, 80, 80, 4, 11, 73, 4, 11, 80, 4, 41, 8, + 76, 69, 32, 68, 65, 83, 72, 32, 4, 170, 244, 16, 86, 179, 139, 13, 72, + 11, 29, 5, 32, 65, 78, 68, 32, 8, 34, 72, 142, 153, 36, 76, 31, 82, 4, + 208, 129, 25, 4, 69, 65, 86, 89, 175, 253, 4, 79, 17, 29, 5, 32, 65, 78, + 68, 32, 14, 254, 131, 29, 66, 42, 84, 250, 121, 72, 154, 154, 6, 76, 31, + 82, 16, 148, 2, 18, 68, 79, 87, 78, 32, 72, 69, 65, 86, 89, 32, 65, 78, + 68, 32, 76, 69, 70, 24, 13, 72, 69, 65, 86, 89, 32, 65, 78, 68, 32, 76, + 69, 70, 100, 13, 76, 73, 71, 72, 84, 32, 65, 78, 68, 32, 76, 69, 70, 97, + 16, 85, 80, 32, 72, 69, 65, 86, 89, 32, 65, 78, 68, 32, 76, 69, 70, 2, + 101, 3, 84, 32, 85, 6, 17, 2, 84, 32, 6, 58, 85, 178, 3, 68, 245, 4, 6, + 86, 69, 82, 84, 73, 67, 2, 227, 159, 34, 80, 6, 17, 2, 84, 32, 6, 58, 85, + 134, 4, 68, 205, 4, 6, 86, 69, 82, 84, 73, 67, 2, 239, 8, 80, 2, 185, 2, + 3, 84, 32, 68, 36, 128, 1, 10, 72, 69, 65, 86, 89, 32, 65, 78, 68, 32, + 188, 1, 10, 76, 73, 71, 72, 84, 32, 65, 78, 68, 32, 186, 2, 68, 131, 4, + 83, 12, 80, 4, 68, 79, 87, 78, 24, 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, + 255, 4, 72, 2, 145, 5, 2, 32, 72, 4, 17, 2, 84, 32, 4, 26, 68, 231, 145, + 36, 76, 2, 177, 156, 34, 3, 79, 87, 78, 12, 80, 4, 68, 79, 87, 78, 24, 3, + 76, 69, 70, 0, 4, 82, 73, 71, 72, 211, 4, 72, 2, 229, 4, 2, 32, 72, 4, + 17, 2, 84, 32, 4, 22, 68, 131, 5, 72, 2, 233, 4, 3, 79, 87, 78, 24, 130, + 1, 68, 188, 1, 10, 72, 69, 65, 86, 89, 32, 65, 78, 68, 32, 144, 1, 10, + 76, 73, 71, 72, 84, 32, 65, 78, 68, 32, 183, 1, 83, 6, 49, 10, 79, 85, + 66, 76, 69, 32, 65, 78, 68, 32, 6, 92, 3, 76, 69, 70, 0, 4, 82, 73, 71, + 72, 13, 10, 72, 79, 82, 73, 90, 79, 78, 84, 65, 76, 2, 11, 84, 2, 189, + 218, 27, 2, 32, 83, 6, 54, 72, 68, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, + 2, 37, 7, 79, 82, 73, 90, 79, 78, 84, 2, 189, 151, 34, 2, 65, 76, 2, 163, + 151, 34, 84, 6, 54, 72, 60, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, 2, 37, + 7, 79, 82, 73, 90, 79, 78, 84, 2, 29, 2, 65, 76, 2, 11, 84, 2, 17, 2, 32, + 72, 2, 177, 164, 36, 3, 69, 65, 86, 6, 49, 10, 73, 78, 71, 76, 69, 32, + 65, 78, 68, 32, 6, 96, 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, 197, 158, 27, + 9, 72, 79, 82, 73, 90, 79, 78, 84, 65, 2, 207, 158, 27, 84, 134, 6, 46, + 65, 178, 14, 69, 150, 1, 73, 179, 1, 79, 232, 5, 36, 4, 72, 77, 73, 32, + 247, 9, 73, 230, 1, 192, 1, 7, 76, 69, 84, 84, 69, 82, 32, 196, 2, 7, 78, + 85, 77, 66, 69, 82, 32, 144, 2, 12, 80, 85, 78, 67, 84, 85, 65, 84, 73, + 79, 78, 32, 84, 5, 83, 73, 71, 78, 32, 122, 86, 167, 227, 25, 68, 108, + 210, 1, 79, 210, 205, 32, 65, 38, 68, 114, 84, 46, 86, 186, 5, 85, 138, + 204, 1, 73, 42, 76, 130, 199, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 74, + 2, 75, 2, 80, 138, 69, 72, 2, 77, 2, 82, 2, 89, 187, 2, 69, 15, 45, 9, + 76, 68, 32, 84, 65, 77, 73, 76, 32, 12, 166, 243, 29, 76, 214, 154, 2, + 83, 194, 99, 78, 139, 250, 2, 82, 42, 82, 69, 38, 70, 66, 78, 26, 83, + 202, 150, 22, 84, 238, 237, 5, 79, 179, 235, 7, 74, 4, 217, 151, 32, 4, + 73, 71, 72, 84, 8, 26, 79, 163, 253, 21, 73, 4, 182, 187, 34, 82, 159, + 186, 1, 85, 4, 65, 3, 73, 78, 69, 8, 40, 4, 69, 86, 69, 78, 1, 2, 73, 88, + 5, 255, 155, 36, 84, 10, 46, 76, 206, 245, 12, 68, 177, 16, 2, 67, 82, 4, + 150, 166, 20, 79, 191, 235, 14, 73, 12, 134, 137, 32, 67, 236, 68, 9, 79, + 76, 68, 32, 84, 65, 77, 73, 76, 234, 158, 1, 74, 158, 2, 86, 122, 85, + 251, 247, 1, 65, 34, 64, 10, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 143, + 235, 33, 73, 32, 138, 1, 79, 192, 162, 30, 11, 66, 72, 65, 84, 84, 73, + 80, 82, 79, 76, 85, 202, 171, 2, 65, 38, 85, 22, 86, 246, 203, 1, 73, + 231, 143, 2, 69, 7, 141, 136, 32, 10, 76, 68, 32, 84, 65, 77, 73, 76, 32, + 83, 130, 4, 72, 12, 76, 76, 69, 32, 80, 65, 84, 84, 69, 82, 78, 32, 143, + 169, 36, 78, 128, 4, 44, 5, 68, 79, 84, 83, 45, 203, 145, 7, 66, 254, 3, + 74, 49, 74, 50, 66, 51, 54, 52, 46, 53, 38, 54, 30, 55, 227, 165, 36, 56, + 129, 2, 66, 50, 66, 51, 54, 52, 46, 53, 38, 54, 30, 55, 227, 165, 36, 56, + 129, 1, 58, 51, 54, 52, 46, 53, 38, 54, 30, 55, 227, 165, 36, 56, 65, 50, + 52, 46, 53, 38, 54, 30, 55, 227, 165, 36, 56, 33, 42, 53, 38, 54, 30, 55, + 227, 165, 36, 56, 17, 34, 54, 30, 55, 227, 165, 36, 56, 9, 26, 55, 227, + 165, 36, 56, 5, 223, 165, 36, 56, 8, 26, 65, 223, 142, 36, 86, 6, 164, + 167, 21, 11, 75, 32, 80, 69, 82, 77, 73, 84, 84, 69, 68, 148, 178, 8, 6, + 83, 84, 45, 70, 69, 69, 247, 203, 6, 68, 10, 42, 68, 96, 2, 69, 70, 151, + 160, 36, 67, 4, 168, 162, 33, 6, 71, 69, 32, 65, 84, 32, 129, 159, 1, 9, + 69, 32, 87, 73, 84, 72, 32, 86, 69, 4, 134, 246, 32, 67, 167, 173, 3, 83, + 12, 84, 4, 75, 69, 78, 32, 212, 223, 8, 2, 67, 67, 160, 187, 26, 2, 87, + 78, 231, 118, 79, 6, 204, 160, 28, 17, 67, 73, 82, 67, 76, 69, 32, 87, + 73, 84, 72, 32, 78, 79, 82, 84, 72, 230, 221, 6, 66, 215, 28, 72, 136, 1, + 212, 1, 4, 66, 66, 76, 69, 46, 71, 156, 4, 4, 72, 73, 68, 32, 36, 2, 76, + 76, 166, 1, 83, 56, 4, 84, 84, 69, 82, 196, 152, 11, 10, 73, 76, 68, 73, + 78, 71, 32, 67, 79, 78, 212, 168, 17, 2, 82, 82, 187, 133, 7, 67, 4, 156, + 134, 29, 2, 32, 84, 195, 153, 7, 83, 63, 33, 6, 73, 78, 69, 83, 69, 32, + 60, 144, 1, 7, 76, 69, 84, 84, 69, 82, 32, 172, 2, 11, 86, 79, 87, 69, + 76, 32, 83, 73, 71, 78, 32, 234, 247, 16, 69, 145, 164, 14, 4, 80, 65, + 76, 76, 46, 154, 1, 77, 34, 78, 138, 154, 36, 66, 2, 67, 2, 68, 2, 71, 2, + 72, 2, 74, 2, 75, 2, 76, 2, 80, 2, 82, 2, 83, 2, 84, 2, 86, 2, 89, 187, + 2, 65, 4, 166, 154, 36, 80, 187, 2, 65, 12, 46, 71, 34, 89, 186, 153, 36, + 82, 187, 2, 65, 4, 214, 153, 36, 75, 187, 2, 65, 4, 182, 153, 36, 67, + 187, 2, 65, 10, 250, 132, 36, 65, 214, 22, 69, 2, 73, 2, 79, 3, 85, 40, + 178, 183, 10, 76, 191, 197, 19, 86, 12, 56, 2, 69, 84, 64, 4, 72, 79, 82, + 78, 207, 193, 9, 83, 7, 11, 32, 4, 188, 216, 19, 4, 73, 78, 32, 68, 203, + 249, 12, 79, 5, 149, 171, 28, 5, 32, 87, 73, 84, 72, 9, 26, 84, 183, 192, + 33, 32, 4, 142, 171, 28, 83, 15, 32, 5, 231, 245, 35, 70, 240, 3, 140, 1, + 23, 90, 65, 78, 84, 73, 78, 69, 32, 77, 85, 83, 73, 67, 65, 76, 32, 83, + 89, 77, 66, 79, 76, 32, 201, 161, 21, 5, 84, 69, 32, 79, 82, 238, 3, 154, + 2, 65, 128, 7, 2, 67, 72, 170, 1, 68, 158, 5, 69, 206, 2, 70, 166, 8, 71, + 202, 3, 73, 162, 2, 75, 138, 5, 76, 190, 2, 77, 250, 4, 79, 114, 80, 174, + 4, 82, 42, 83, 194, 5, 84, 196, 5, 2, 86, 65, 250, 1, 89, 218, 160, 33, + 78, 197, 150, 2, 9, 88, 73, 82, 79, 78, 32, 75, 76, 65, 62, 60, 5, 71, + 79, 71, 73, 32, 222, 1, 78, 118, 80, 199, 2, 82, 16, 70, 65, 0, 2, 71, + 79, 64, 2, 77, 69, 37, 5, 80, 79, 76, 73, 32, 4, 17, 2, 82, 71, 4, 212, + 164, 16, 2, 79, 84, 223, 239, 19, 73, 4, 190, 182, 9, 84, 243, 201, 26, + 83, 4, 26, 65, 1, 2, 71, 79, 2, 163, 148, 18, 82, 6, 72, 6, 84, 73, 75, + 69, 78, 79, 193, 241, 35, 6, 65, 84, 82, 73, 67, 72, 4, 164, 32, 2, 75, + 89, 139, 240, 35, 77, 22, 52, 5, 69, 83, 79, 32, 69, 38, 79, 143, 254, + 35, 76, 4, 204, 1, 2, 88, 79, 143, 55, 75, 16, 80, 6, 83, 84, 82, 79, 70, + 79, 184, 40, 3, 68, 69, 82, 149, 130, 1, 2, 84, 72, 10, 24, 2, 73, 32, + 79, 83, 4, 56, 9, 83, 89, 78, 68, 69, 83, 77, 79, 83, 195, 24, 84, 2, + 139, 44, 32, 7, 11, 32, 4, 210, 60, 68, 195, 252, 22, 78, 18, 48, 2, 71, + 79, 33, 6, 75, 84, 73, 75, 79, 32, 4, 170, 21, 83, 159, 250, 35, 78, 14, + 230, 176, 28, 86, 206, 191, 7, 90, 162, 8, 75, 254, 2, 68, 2, 78, 162, + 17, 71, 3, 80, 14, 80, 4, 82, 79, 65, 32, 164, 37, 4, 79, 82, 69, 86, + 221, 2, 4, 65, 77, 73, 76, 6, 164, 196, 20, 2, 83, 80, 232, 189, 3, 3, + 90, 89, 71, 201, 211, 10, 3, 75, 76, 73, 42, 50, 73, 144, 250, 8, 2, 65, + 83, 243, 243, 26, 89, 38, 122, 65, 200, 1, 5, 69, 83, 73, 83, 32, 70, 71, + 208, 1, 3, 80, 76, 73, 221, 169, 28, 8, 70, 84, 79, 71, 71, 79, 83, 32, + 10, 48, 6, 83, 84, 79, 76, 73, 32, 143, 206, 34, 82, 8, 80, 6, 65, 80, + 76, 73, 32, 77, 170, 55, 68, 221, 199, 23, 5, 84, 72, 69, 83, 69, 4, 40, + 2, 69, 71, 185, 153, 29, 2, 73, 75, 2, 243, 128, 31, 65, 12, 38, 84, 242, + 50, 65, 42, 68, 63, 77, 6, 194, 10, 69, 235, 41, 82, 10, 72, 5, 79, 82, + 71, 79, 78, 205, 136, 36, 7, 82, 65, 77, 77, 65, 32, 71, 9, 69, 15, 32, + 80, 65, 82, 69, 83, 84, 73, 71, 77, 69, 78, 79, 78, 32, 6, 218, 38, 68, + 137, 10, 8, 65, 82, 73, 83, 84, 69, 82, 65, 5, 171, 47, 32, 16, 166, 1, + 78, 116, 6, 84, 69, 82, 79, 78, 32, 184, 44, 4, 88, 79, 32, 69, 148, 240, + 33, 4, 80, 69, 71, 69, 128, 49, 6, 75, 83, 84, 82, 69, 80, 177, 16, 3, + 76, 65, 70, 4, 220, 22, 3, 68, 79, 70, 197, 145, 28, 18, 65, 82, 88, 73, + 83, 32, 75, 65, 73, 32, 70, 84, 72, 79, 82, 65, 32, 86, 4, 208, 11, 5, + 65, 82, 71, 79, 83, 147, 20, 80, 44, 180, 1, 9, 65, 78, 69, 82, 79, 83, + 73, 83, 32, 52, 6, 84, 72, 79, 82, 65, 32, 165, 6, 22, 72, 84, 79, 82, + 65, 32, 83, 75, 76, 73, 82, 79, 78, 32, 67, 72, 82, 79, 77, 65, 32, 86, + 6, 246, 4, 68, 14, 77, 25, 5, 84, 69, 84, 82, 65, 36, 220, 2, 8, 65, 82, + 67, 72, 65, 73, 79, 78, 80, 10, 68, 73, 65, 84, 79, 78, 73, 75, 73, 32, + 96, 11, 73, 32, 89, 70, 69, 83, 73, 83, 32, 84, 69, 32, 15, 77, 65, 76, + 65, 75, 79, 78, 32, 67, 72, 82, 79, 77, 65, 32, 74, 78, 40, 8, 83, 75, + 76, 73, 82, 79, 78, 32, 225, 166, 19, 18, 69, 78, 65, 82, 77, 79, 78, 73, + 79, 83, 32, 65, 78, 84, 73, 70, 79, 78, 5, 57, 12, 32, 68, 69, 89, 84, + 69, 82, 79, 85, 32, 73, 67, 2, 247, 161, 28, 72, 14, 62, 78, 242, 224, + 35, 90, 162, 8, 75, 254, 2, 68, 163, 17, 80, 6, 238, 39, 73, 219, 150, + 34, 65, 2, 233, 42, 4, 84, 65, 82, 84, 4, 18, 68, 15, 77, 2, 35, 73, 2, + 21, 3, 79, 78, 79, 2, 147, 19, 70, 4, 162, 19, 65, 197, 221, 33, 2, 69, + 78, 6, 84, 7, 67, 72, 82, 79, 77, 65, 32, 245, 222, 17, 8, 68, 73, 65, + 84, 79, 78, 79, 78, 4, 42, 86, 221, 226, 17, 4, 83, 89, 78, 65, 2, 231, + 210, 33, 65, 22, 80, 6, 69, 78, 73, 75, 73, 32, 44, 2, 79, 82, 181, 26, + 5, 82, 79, 78, 84, 72, 4, 148, 240, 31, 2, 68, 73, 1, 2, 89, 70, 16, 68, + 2, 71, 79, 225, 1, 10, 84, 72, 77, 73, 75, 79, 78, 32, 78, 32, 12, 28, 2, + 78, 32, 155, 1, 83, 10, 96, 14, 80, 65, 82, 69, 83, 84, 73, 71, 77, 69, + 78, 79, 78, 32, 238, 33, 65, 113, 3, 78, 69, 79, 4, 210, 24, 68, 233, + 204, 33, 5, 65, 82, 73, 83, 84, 2, 245, 193, 34, 5, 89, 78, 84, 72, 69, + 4, 138, 28, 65, 1, 2, 68, 73, 16, 56, 2, 77, 73, 114, 83, 213, 248, 34, + 4, 67, 72, 65, 68, 8, 34, 70, 165, 28, 3, 68, 73, 65, 6, 40, 4, 84, 72, + 79, 82, 155, 236, 34, 79, 4, 230, 168, 35, 79, 227, 79, 65, 6, 44, 6, 65, + 75, 73, 65, 32, 84, 227, 13, 79, 2, 153, 179, 22, 12, 69, 76, 79, 85, 83, + 32, 73, 67, 72, 73, 77, 65, 54, 108, 2, 65, 84, 96, 6, 69, 78, 84, 73, + 77, 65, 136, 1, 5, 76, 65, 83, 77, 65, 18, 79, 98, 82, 175, 1, 89, 6, 40, + 3, 65, 86, 65, 197, 3, 2, 72, 73, 4, 136, 29, 5, 32, 84, 82, 79, 77, 255, + 183, 35, 83, 18, 24, 2, 84, 65, 15, 32, 11, 11, 32, 8, 36, 4, 78, 69, 79, + 32, 179, 28, 65, 6, 234, 144, 28, 75, 200, 112, 2, 77, 69, 211, 202, 6, + 65, 7, 243, 28, 32, 8, 64, 6, 78, 84, 69, 86, 77, 65, 182, 243, 8, 82, + 163, 223, 26, 85, 5, 189, 219, 14, 2, 32, 65, 14, 44, 4, 65, 84, 73, 77, + 105, 3, 69, 77, 65, 12, 18, 65, 35, 79, 8, 182, 23, 32, 187, 217, 35, 84, + 4, 134, 12, 75, 209, 184, 32, 5, 89, 80, 79, 82, 82, 2, 139, 255, 27, 83, + 2, 151, 209, 35, 76, 14, 22, 69, 147, 22, 89, 12, 44, 5, 73, 77, 77, 65, + 32, 243, 244, 30, 77, 10, 72, 2, 69, 78, 0, 5, 73, 77, 73, 83, 69, 54, + 84, 69, 3, 68, 89, 79, 2, 213, 146, 28, 8, 79, 83, 32, 67, 72, 82, 79, + 78, 4, 44, 5, 69, 83, 83, 65, 82, 1, 2, 82, 73, 2, 17, 2, 79, 78, 2, 25, + 4, 32, 67, 72, 82, 2, 211, 227, 34, 79, 28, 84, 8, 65, 82, 84, 89, 82, + 73, 65, 32, 189, 229, 31, 7, 73, 75, 82, 79, 78, 32, 73, 26, 72, 5, 65, + 76, 76, 73, 32, 38, 68, 38, 80, 134, 1, 86, 30, 84, 87, 76, 4, 34, 68, + 177, 2, 3, 80, 82, 79, 2, 237, 2, 5, 69, 89, 84, 69, 82, 8, 60, 7, 76, + 65, 71, 73, 79, 83, 32, 45, 4, 82, 79, 84, 79, 4, 200, 1, 5, 84, 69, 84, + 65, 82, 111, 73, 4, 22, 86, 227, 1, 83, 2, 209, 1, 3, 65, 82, 89, 8, 56, + 8, 69, 84, 65, 82, 84, 79, 83, 32, 61, 2, 82, 73, 4, 22, 76, 135, 1, 73, + 2, 21, 3, 69, 71, 69, 2, 63, 84, 4, 18, 70, 35, 84, 2, 213, 175, 22, 3, + 79, 78, 73, 2, 11, 79, 2, 11, 83, 2, 17, 2, 32, 73, 2, 179, 218, 23, 67, + 18, 92, 4, 76, 73, 71, 79, 180, 1, 5, 89, 82, 65, 78, 73, 210, 14, 88, + 157, 138, 35, 2, 77, 65, 4, 211, 1, 78, 42, 60, 2, 65, 82, 100, 2, 73, + 65, 90, 69, 169, 1, 2, 83, 73, 12, 40, 2, 65, 75, 229, 243, 17, 2, 73, + 67, 10, 52, 3, 65, 76, 69, 45, 6, 76, 73, 84, 73, 75, 73, 4, 11, 83, 4, + 17, 2, 77, 65, 4, 23, 32, 7, 11, 32, 4, 198, 15, 65, 223, 129, 23, 78, + 12, 72, 3, 84, 65, 83, 136, 3, 6, 76, 65, 83, 84, 79, 78, 171, 247, 8, + 82, 6, 26, 84, 239, 228, 35, 77, 4, 32, 2, 79, 75, 131, 231, 35, 73, 2, + 201, 197, 35, 2, 79, 85, 14, 36, 5, 70, 73, 83, 84, 79, 67, 76, 10, 46, + 80, 214, 1, 78, 170, 8, 76, 187, 1, 83, 2, 135, 11, 65, 4, 154, 150, 35, + 79, 227, 79, 73, 4, 178, 5, 69, 129, 191, 35, 2, 65, 80, 42, 120, 5, 69, 73, 83, 77, 65, 32, 8, 73, 77, 65, 78, 83, 73, 83, 32, 182, 1, 84, 154, - 1, 89, 229, 239, 1, 3, 65, 88, 73, 5, 11, 32, 2, 203, 166, 22, 78, 16, + 1, 89, 201, 243, 19, 3, 65, 88, 73, 5, 11, 32, 2, 163, 141, 23, 78, 16, 36, 2, 65, 82, 1, 3, 84, 72, 69, 8, 25, 4, 83, 69, 79, 83, 9, 11, 32, 6, - 18, 84, 39, 68, 4, 34, 82, 13, 4, 69, 84, 82, 65, 2, 11, 73, 2, 141, 155, - 27, 3, 83, 73, 77, 8, 68, 5, 65, 86, 82, 79, 83, 52, 4, 82, 65, 71, 71, - 251, 206, 16, 73, 5, 29, 5, 32, 65, 80, 79, 68, 2, 147, 224, 8, 69, 2, - 253, 239, 1, 2, 73, 83, 12, 34, 78, 149, 1, 3, 82, 77, 65, 8, 36, 5, 65, - 71, 77, 65, 32, 91, 69, 6, 154, 8, 65, 134, 155, 22, 78, 237, 245, 4, 10, - 77, 69, 84, 65, 32, 83, 84, 65, 86, 82, 2, 167, 206, 34, 86, 5, 11, 84, - 2, 243, 253, 16, 73, 40, 42, 69, 70, 72, 218, 1, 82, 227, 2, 73, 6, 136, - 12, 3, 84, 82, 65, 134, 166, 8, 76, 213, 170, 24, 2, 83, 83, 12, 26, 69, - 175, 201, 34, 73, 10, 64, 2, 77, 65, 141, 215, 33, 8, 83, 32, 75, 65, 73, + 18, 84, 39, 68, 4, 34, 82, 13, 4, 69, 84, 82, 65, 2, 11, 73, 2, 193, 132, + 28, 3, 83, 73, 77, 8, 68, 5, 65, 86, 82, 79, 83, 52, 4, 82, 65, 71, 71, + 163, 143, 17, 73, 5, 29, 5, 32, 65, 80, 79, 68, 2, 235, 250, 8, 69, 2, + 225, 243, 19, 2, 73, 83, 12, 34, 78, 149, 1, 3, 82, 77, 65, 8, 36, 5, 65, + 71, 77, 65, 32, 91, 69, 6, 154, 8, 65, 222, 129, 23, 78, 201, 248, 4, 10, + 77, 69, 84, 65, 32, 83, 84, 65, 86, 82, 2, 151, 191, 35, 86, 5, 11, 84, + 2, 171, 191, 17, 73, 40, 42, 69, 70, 72, 218, 1, 82, 227, 2, 73, 6, 136, + 12, 3, 84, 82, 65, 218, 192, 8, 76, 209, 253, 24, 2, 83, 83, 12, 26, 69, + 159, 186, 35, 73, 10, 64, 2, 77, 65, 253, 199, 34, 8, 83, 32, 75, 65, 73, 32, 65, 80, 9, 56, 2, 32, 65, 33, 8, 84, 73, 83, 77, 79, 83, 32, 69, 2, - 197, 236, 33, 3, 80, 76, 79, 4, 226, 205, 34, 83, 3, 88, 20, 38, 73, 73, - 5, 79, 77, 73, 75, 79, 6, 48, 2, 71, 79, 130, 232, 29, 80, 227, 131, 5, - 65, 2, 171, 177, 33, 82, 14, 42, 76, 32, 2, 78, 32, 62, 80, 95, 83, 2, - 11, 89, 2, 235, 201, 34, 71, 6, 26, 65, 247, 157, 22, 78, 4, 250, 2, 82, - 155, 197, 34, 76, 4, 46, 65, 245, 180, 33, 5, 83, 73, 70, 73, 83, 2, 245, - 200, 34, 6, 82, 65, 75, 65, 76, 69, 2, 11, 89, 2, 217, 199, 16, 2, 78, - 65, 10, 26, 82, 227, 199, 34, 84, 8, 21, 3, 69, 73, 65, 8, 26, 32, 113, - 2, 73, 32, 6, 38, 69, 242, 5, 68, 235, 149, 22, 78, 2, 11, 75, 2, 29, 5, - 70, 79, 78, 73, 84, 2, 173, 152, 34, 2, 73, 75, 2, 11, 65, 2, 11, 82, 2, - 161, 151, 34, 3, 67, 72, 65, 22, 28, 2, 70, 69, 231, 3, 80, 14, 34, 78, - 49, 4, 83, 73, 83, 32, 4, 11, 32, 4, 254, 214, 30, 75, 235, 230, 3, 65, + 181, 221, 34, 3, 80, 76, 79, 4, 210, 190, 35, 83, 3, 88, 20, 38, 73, 73, + 5, 79, 77, 73, 75, 79, 6, 48, 2, 71, 79, 130, 211, 30, 80, 211, 137, 5, + 65, 2, 151, 159, 34, 82, 14, 42, 76, 32, 2, 78, 32, 62, 80, 95, 83, 2, + 11, 89, 2, 219, 186, 35, 71, 6, 26, 65, 207, 132, 23, 78, 4, 250, 2, 82, + 139, 182, 35, 76, 4, 46, 65, 225, 162, 34, 5, 83, 73, 70, 73, 83, 2, 229, + 185, 35, 6, 82, 65, 75, 65, 76, 69, 2, 11, 89, 2, 129, 136, 17, 2, 78, + 65, 10, 26, 82, 211, 184, 35, 84, 8, 21, 3, 69, 73, 65, 8, 26, 32, 113, + 2, 73, 32, 6, 38, 69, 242, 5, 68, 195, 252, 22, 78, 2, 11, 75, 2, 29, 5, + 70, 79, 78, 73, 84, 2, 157, 137, 35, 2, 73, 75, 2, 11, 65, 2, 11, 82, 2, + 145, 136, 35, 3, 67, 72, 65, 22, 28, 2, 70, 69, 231, 3, 80, 14, 34, 78, + 49, 4, 83, 73, 83, 32, 4, 11, 32, 4, 190, 243, 27, 75, 155, 187, 7, 65, 10, 42, 65, 42, 68, 62, 77, 89, 2, 84, 82, 2, 133, 2, 6, 80, 76, 73, 32, 68, 89, 2, 233, 1, 11, 73, 71, 82, 65, 77, 77, 79, 83, 32, 69, 88, 2, 173, 1, 18, 79, 78, 79, 71, 82, 65, 77, 77, 79, 83, 32, 84, 69, 83, 83, 69, 82, 65, 4, 11, 73, 4, 60, 11, 71, 82, 65, 77, 77, 79, 83, 32, 79, 75, - 84, 59, 84, 2, 11, 79, 2, 153, 176, 2, 6, 32, 68, 79, 68, 69, 75, 2, 161, - 147, 34, 4, 73, 77, 79, 82, 8, 26, 79, 191, 223, 29, 83, 6, 56, 6, 75, - 82, 73, 83, 73, 83, 233, 235, 29, 2, 82, 82, 5, 17, 2, 32, 68, 2, 11, 73, - 2, 235, 222, 29, 80, 252, 66, 182, 1, 65, 250, 71, 69, 230, 1, 72, 222, - 32, 73, 208, 41, 3, 74, 75, 32, 138, 22, 76, 186, 18, 79, 238, 117, 82, - 234, 7, 85, 150, 128, 2, 89, 186, 167, 19, 71, 190, 235, 10, 83, 203, 18, - 67, 198, 13, 110, 68, 58, 76, 50, 77, 90, 78, 174, 51, 80, 62, 82, 198, - 7, 84, 138, 1, 85, 162, 173, 18, 67, 151, 204, 6, 83, 4, 34, 85, 129, - 148, 27, 2, 65, 32, 2, 223, 220, 7, 67, 4, 196, 211, 9, 3, 76, 32, 77, - 207, 210, 19, 69, 6, 36, 3, 69, 82, 65, 247, 141, 34, 80, 5, 161, 186, - 27, 7, 32, 87, 73, 84, 72, 32, 70, 193, 11, 148, 1, 16, 65, 68, 73, 65, - 78, 32, 83, 89, 76, 76, 65, 66, 73, 67, 83, 32, 148, 49, 2, 67, 69, 94, - 68, 192, 232, 23, 3, 78, 69, 68, 171, 172, 10, 79, 172, 11, 226, 1, 65, - 190, 1, 66, 162, 2, 67, 242, 8, 69, 50, 70, 198, 4, 72, 38, 73, 30, 75, - 134, 1, 76, 82, 77, 174, 1, 78, 202, 4, 81, 178, 1, 79, 194, 1, 80, 70, - 82, 142, 1, 83, 194, 4, 84, 246, 3, 87, 254, 5, 89, 143, 213, 17, 71, 21, - 90, 65, 30, 73, 40, 10, 84, 72, 65, 80, 65, 83, 67, 65, 78, 32, 166, 218, - 34, 78, 3, 89, 7, 230, 218, 34, 73, 3, 89, 5, 221, 225, 23, 5, 86, 73, - 76, 73, 75, 4, 162, 218, 34, 77, 3, 83, 42, 156, 1, 9, 76, 65, 67, 75, - 70, 79, 79, 84, 32, 212, 159, 19, 9, 73, 66, 76, 69, 45, 67, 82, 69, 69, - 189, 203, 7, 10, 69, 65, 86, 69, 82, 32, 68, 69, 78, 69, 36, 82, 87, 238, - 233, 11, 75, 2, 78, 170, 238, 22, 65, 2, 69, 2, 73, 2, 79, 3, 83, 11, - 146, 216, 34, 65, 2, 69, 2, 73, 3, 79, 141, 3, 82, 65, 186, 42, 87, 170, - 173, 8, 72, 130, 182, 23, 79, 238, 60, 73, 199, 140, 2, 69, 241, 2, 48, - 6, 82, 82, 73, 69, 82, 32, 151, 202, 32, 65, 234, 2, 170, 1, 68, 122, 71, - 94, 72, 46, 73, 46, 74, 82, 75, 30, 78, 66, 83, 66, 80, 2, 90, 58, 84, - 38, 76, 132, 1, 2, 67, 72, 2, 77, 2, 82, 2, 87, 2, 89, 223, 184, 34, 69, - 32, 46, 69, 202, 5, 76, 2, 90, 179, 207, 34, 73, 6, 26, 78, 223, 212, 34, - 69, 4, 134, 142, 17, 69, 173, 207, 6, 2, 84, 65, 30, 254, 4, 72, 254, - 169, 21, 87, 198, 147, 9, 65, 210, 209, 3, 69, 162, 64, 73, 2, 79, 3, 85, - 19, 162, 4, 87, 222, 184, 34, 69, 215, 22, 73, 5, 197, 138, 14, 6, 78, - 73, 84, 73, 65, 76, 26, 202, 3, 74, 146, 143, 34, 69, 234, 61, 87, 186, - 2, 65, 2, 73, 2, 79, 3, 85, 26, 154, 1, 75, 227, 1, 72, 14, 238, 145, 34, - 69, 162, 64, 65, 2, 71, 2, 73, 2, 79, 3, 85, 26, 62, 72, 242, 144, 34, - 69, 162, 64, 65, 2, 73, 2, 79, 3, 85, 15, 238, 144, 34, 69, 162, 64, 65, + 84, 59, 84, 2, 11, 79, 2, 137, 231, 19, 6, 32, 68, 79, 68, 69, 75, 2, + 145, 132, 35, 4, 73, 77, 79, 82, 8, 26, 79, 191, 202, 30, 83, 6, 56, 6, + 75, 82, 73, 83, 73, 83, 233, 214, 30, 2, 82, 82, 5, 17, 2, 32, 68, 2, 11, + 73, 2, 235, 201, 30, 80, 156, 72, 182, 1, 65, 162, 72, 69, 230, 1, 72, + 222, 32, 73, 152, 43, 3, 74, 75, 32, 138, 22, 76, 186, 18, 79, 150, 119, + 82, 134, 8, 85, 178, 150, 2, 89, 226, 245, 19, 71, 182, 244, 10, 83, 203, + 18, 67, 200, 13, 110, 68, 58, 76, 50, 77, 90, 78, 174, 51, 80, 62, 82, + 238, 7, 84, 138, 1, 85, 242, 139, 19, 67, 211, 214, 6, 83, 4, 34, 85, + 181, 253, 27, 2, 65, 32, 2, 219, 247, 7, 67, 4, 156, 238, 9, 3, 76, 32, + 77, 151, 163, 20, 69, 6, 36, 3, 69, 82, 65, 231, 254, 34, 80, 5, 217, + 165, 28, 7, 32, 87, 73, 84, 72, 32, 70, 193, 11, 148, 1, 16, 65, 68, 73, + 65, 78, 32, 83, 89, 76, 76, 65, 66, 73, 67, 83, 32, 148, 49, 2, 67, 69, + 94, 68, 232, 209, 24, 3, 78, 69, 68, 243, 179, 10, 79, 172, 11, 226, 1, + 65, 190, 1, 66, 162, 2, 67, 242, 8, 69, 50, 70, 198, 4, 72, 38, 73, 30, + 75, 134, 1, 76, 82, 77, 174, 1, 78, 202, 4, 81, 178, 1, 79, 194, 1, 80, + 70, 82, 142, 1, 83, 194, 4, 84, 246, 3, 87, 254, 5, 89, 179, 156, 18, 71, + 21, 90, 65, 30, 73, 40, 10, 84, 72, 65, 80, 65, 83, 67, 65, 78, 32, 150, + 203, 35, 78, 3, 89, 7, 214, 203, 35, 73, 3, 89, 5, 213, 201, 24, 5, 86, + 73, 76, 73, 75, 4, 146, 203, 35, 77, 3, 83, 42, 156, 1, 9, 76, 65, 67, + 75, 70, 79, 79, 84, 32, 248, 132, 20, 9, 73, 66, 76, 69, 45, 67, 82, 69, + 69, 193, 207, 7, 10, 69, 65, 86, 69, 82, 32, 68, 69, 78, 69, 36, 82, 87, + 194, 137, 12, 75, 2, 78, 198, 191, 23, 65, 2, 69, 2, 73, 2, 79, 3, 83, + 11, 130, 201, 35, 65, 2, 69, 2, 73, 3, 79, 141, 3, 82, 65, 186, 42, 87, + 130, 200, 8, 72, 158, 136, 24, 79, 202, 61, 73, 231, 143, 2, 69, 241, 2, + 48, 6, 82, 82, 73, 69, 82, 32, 231, 183, 33, 65, 234, 2, 170, 1, 68, 122, + 71, 94, 72, 46, 73, 46, 74, 82, 75, 30, 78, 66, 83, 66, 80, 2, 90, 58, + 84, 38, 76, 132, 1, 2, 67, 72, 2, 77, 2, 82, 2, 87, 2, 89, 207, 169, 35, + 69, 32, 46, 69, 202, 5, 76, 2, 90, 163, 192, 35, 73, 6, 26, 78, 207, 197, + 35, 69, 4, 202, 207, 17, 69, 225, 245, 6, 2, 84, 65, 30, 254, 4, 72, 194, + 144, 22, 87, 250, 151, 9, 65, 202, 215, 3, 69, 162, 64, 73, 2, 79, 3, 85, + 19, 162, 4, 87, 206, 169, 35, 69, 215, 22, 73, 5, 241, 190, 14, 6, 78, + 73, 84, 73, 65, 76, 26, 202, 3, 74, 130, 128, 35, 69, 234, 61, 87, 186, + 2, 65, 2, 73, 2, 79, 3, 85, 26, 154, 1, 75, 227, 1, 72, 14, 222, 130, 35, + 69, 162, 64, 65, 2, 71, 2, 73, 2, 79, 3, 85, 26, 62, 72, 226, 129, 35, + 69, 162, 64, 65, 2, 73, 2, 79, 3, 85, 15, 222, 129, 35, 69, 162, 64, 65, 2, 73, 2, 79, 3, 85, 72, 34, 76, 70, 84, 66, 72, 3, 83, 24, 130, 1, 72, - 146, 143, 34, 69, 162, 64, 65, 2, 73, 2, 79, 3, 85, 24, 62, 83, 146, 143, - 34, 69, 162, 64, 65, 2, 73, 2, 79, 3, 85, 12, 142, 143, 34, 69, 162, 64, - 65, 2, 73, 2, 79, 3, 85, 7, 236, 29, 4, 65, 83, 84, 69, 139, 177, 34, 78, - 51, 74, 65, 22, 73, 194, 248, 31, 85, 250, 11, 79, 254, 83, 87, 183, 245, - 1, 69, 7, 183, 193, 32, 65, 33, 40, 4, 78, 65, 76, 32, 191, 205, 34, 73, - 28, 160, 1, 2, 68, 79, 134, 1, 82, 78, 83, 138, 136, 14, 71, 186, 2, 65, - 180, 182, 3, 6, 66, 79, 84, 84, 79, 77, 0, 3, 84, 79, 80, 202, 254, 12, - 80, 175, 247, 2, 77, 6, 44, 5, 85, 66, 76, 69, 32, 159, 168, 24, 87, 4, - 240, 196, 6, 12, 83, 72, 79, 82, 84, 32, 86, 69, 82, 84, 73, 67, 239, - 198, 7, 65, 6, 38, 73, 201, 252, 32, 3, 65, 73, 83, 4, 254, 192, 17, 71, - 155, 137, 17, 78, 4, 164, 155, 25, 4, 77, 65, 76, 76, 133, 135, 7, 4, 72, - 79, 82, 84, 4, 158, 185, 26, 89, 231, 144, 8, 75, 7, 222, 201, 34, 73, 3, - 78, 39, 66, 87, 234, 27, 65, 234, 227, 31, 79, 238, 60, 73, 199, 140, 2, - 69, 19, 210, 144, 12, 65, 254, 238, 19, 79, 238, 60, 73, 199, 140, 2, 69, - 49, 142, 7, 72, 154, 20, 65, 66, 87, 170, 227, 31, 79, 238, 60, 73, 199, - 140, 2, 69, 43, 70, 69, 38, 79, 238, 25, 65, 66, 87, 150, 160, 32, 73, - 199, 140, 2, 72, 7, 205, 217, 26, 4, 68, 73, 65, 76, 7, 11, 79, 5, 245, - 255, 32, 8, 83, 69, 45, 67, 82, 69, 69, 32, 149, 1, 164, 1, 8, 45, 67, + 130, 128, 35, 69, 162, 64, 65, 2, 73, 2, 79, 3, 85, 24, 62, 83, 130, 128, + 35, 69, 162, 64, 65, 2, 73, 2, 79, 3, 85, 12, 254, 255, 34, 69, 162, 64, + 65, 2, 73, 2, 79, 3, 85, 7, 236, 29, 4, 65, 83, 84, 69, 251, 161, 35, 78, + 51, 74, 65, 22, 73, 182, 229, 32, 85, 250, 11, 79, 226, 84, 87, 207, 248, + 1, 69, 7, 135, 175, 33, 65, 33, 40, 4, 78, 65, 76, 32, 175, 190, 35, 73, + 28, 160, 1, 2, 68, 79, 134, 1, 82, 78, 83, 206, 188, 14, 71, 158, 2, 65, + 148, 197, 3, 6, 66, 79, 84, 84, 79, 77, 0, 3, 84, 79, 80, 230, 166, 13, + 80, 251, 252, 2, 77, 6, 44, 5, 85, 66, 76, 69, 32, 199, 145, 25, 87, 4, + 224, 223, 6, 12, 83, 72, 79, 82, 84, 32, 86, 69, 82, 84, 73, 67, 167, + 224, 7, 65, 6, 38, 73, 193, 234, 33, 3, 65, 73, 83, 4, 134, 132, 18, 71, + 131, 183, 17, 78, 4, 216, 132, 26, 4, 77, 65, 76, 76, 205, 138, 7, 4, 72, + 79, 82, 84, 4, 198, 162, 27, 89, 175, 152, 8, 75, 7, 206, 186, 35, 73, 3, + 78, 39, 66, 87, 234, 27, 65, 222, 208, 32, 79, 202, 61, 73, 231, 143, 2, + 69, 19, 166, 176, 12, 65, 158, 188, 20, 79, 202, 61, 73, 231, 143, 2, 69, + 49, 142, 7, 72, 154, 20, 65, 66, 87, 158, 208, 32, 79, 202, 61, 73, 231, + 143, 2, 69, 43, 70, 69, 38, 79, 238, 25, 65, 66, 87, 230, 141, 33, 73, + 231, 143, 2, 72, 7, 245, 194, 27, 4, 68, 73, 65, 76, 7, 11, 79, 5, 237, + 237, 33, 8, 83, 69, 45, 67, 82, 69, 69, 32, 149, 1, 164, 1, 8, 45, 67, 82, 69, 69, 32, 84, 72, 38, 65, 250, 2, 71, 76, 2, 78, 71, 48, 4, 85, 78, - 65, 86, 142, 20, 79, 30, 87, 150, 160, 32, 73, 198, 140, 2, 69, 3, 72, 6, - 210, 184, 32, 73, 199, 140, 2, 69, 63, 104, 6, 83, 75, 65, 80, 73, 32, - 188, 1, 7, 84, 84, 73, 76, 73, 75, 32, 138, 182, 32, 65, 199, 140, 2, 89, + 65, 86, 142, 20, 79, 30, 87, 230, 141, 33, 73, 230, 143, 2, 69, 3, 72, 6, + 162, 166, 33, 73, 231, 143, 2, 69, 63, 104, 6, 83, 75, 65, 80, 73, 32, + 188, 1, 7, 84, 84, 73, 76, 73, 75, 32, 218, 163, 33, 65, 231, 143, 2, 89, 30, 70, 83, 86, 87, 210, 17, 67, 2, 75, 2, 77, 2, 78, 2, 84, 3, 89, 14, - 226, 201, 29, 67, 2, 80, 2, 84, 236, 103, 2, 75, 87, 190, 156, 2, 87, - 151, 119, 45, 4, 246, 163, 34, 79, 191, 28, 65, 24, 30, 72, 1, 3, 83, 72, - 82, 12, 186, 176, 30, 65, 194, 200, 1, 79, 239, 60, 73, 19, 38, 65, 166, - 248, 31, 79, 239, 60, 73, 9, 142, 181, 32, 65, 199, 140, 2, 73, 15, 190, - 175, 30, 65, 194, 200, 1, 79, 239, 60, 73, 18, 224, 9, 3, 73, 75, 32, - 237, 190, 23, 2, 85, 84, 33, 68, 7, 74, 73, 66, 87, 65, 89, 32, 134, 192, - 34, 78, 2, 79, 3, 89, 24, 74, 78, 218, 174, 30, 83, 226, 144, 4, 67, 2, - 75, 2, 77, 2, 80, 3, 84, 11, 11, 87, 8, 250, 245, 31, 79, 239, 60, 73, - 39, 206, 4, 87, 166, 13, 65, 38, 79, 178, 160, 32, 73, 199, 140, 2, 69, - 39, 104, 7, 45, 67, 82, 69, 69, 32, 82, 146, 14, 87, 182, 2, 65, 234, - 227, 31, 79, 238, 60, 73, 199, 140, 2, 69, 4, 134, 167, 34, 87, 215, 22, - 69, 125, 94, 65, 218, 1, 72, 138, 1, 79, 238, 2, 87, 234, 200, 11, 80, - 230, 225, 20, 73, 199, 140, 2, 69, 43, 26, 89, 255, 175, 32, 65, 37, 25, - 4, 73, 83, 73, 32, 34, 70, 72, 54, 74, 218, 4, 83, 250, 162, 34, 89, 202, - 18, 84, 147, 1, 77, 10, 170, 242, 31, 79, 178, 201, 2, 65, 2, 69, 3, 73, - 6, 170, 228, 30, 85, 255, 214, 3, 73, 37, 70, 87, 202, 13, 79, 202, 244, - 11, 65, 234, 171, 20, 73, 199, 140, 2, 69, 16, 198, 13, 79, 134, 155, 30, - 65, 174, 133, 2, 73, 199, 140, 2, 69, 15, 80, 12, 85, 84, 72, 45, 83, 76, - 65, 86, 69, 89, 32, 75, 170, 185, 34, 79, 3, 89, 8, 150, 184, 34, 65, 2, + 226, 180, 30, 67, 2, 80, 2, 84, 228, 103, 2, 75, 87, 158, 159, 2, 87, + 175, 122, 45, 4, 230, 148, 35, 79, 191, 28, 65, 24, 30, 72, 1, 3, 83, 72, + 82, 12, 178, 155, 31, 65, 190, 202, 1, 79, 203, 61, 73, 19, 38, 65, 154, + 229, 32, 79, 203, 61, 73, 9, 222, 162, 33, 65, 231, 143, 2, 73, 15, 182, + 154, 31, 65, 190, 202, 1, 79, 203, 61, 73, 18, 224, 9, 3, 73, 75, 32, + 229, 166, 24, 2, 85, 84, 33, 68, 7, 74, 73, 66, 87, 65, 89, 32, 246, 176, + 35, 78, 2, 79, 3, 89, 24, 74, 78, 210, 153, 31, 83, 218, 150, 4, 67, 2, + 75, 2, 77, 2, 80, 3, 84, 11, 11, 87, 8, 238, 226, 32, 79, 203, 61, 73, + 39, 206, 4, 87, 166, 13, 65, 38, 79, 130, 142, 33, 73, 231, 143, 2, 69, + 39, 104, 7, 45, 67, 82, 69, 69, 32, 82, 146, 14, 87, 182, 2, 65, 222, + 208, 32, 79, 202, 61, 73, 231, 143, 2, 69, 4, 246, 151, 35, 87, 215, 22, + 69, 125, 94, 65, 218, 1, 72, 138, 1, 79, 238, 2, 87, 190, 232, 11, 80, + 226, 175, 21, 73, 231, 143, 2, 69, 43, 26, 89, 207, 157, 33, 65, 37, 25, + 4, 73, 83, 73, 32, 34, 70, 72, 54, 74, 218, 4, 83, 234, 147, 35, 89, 202, + 18, 84, 147, 1, 77, 10, 158, 223, 32, 79, 174, 205, 2, 65, 2, 69, 3, 73, + 6, 170, 208, 31, 85, 239, 219, 3, 73, 37, 70, 87, 202, 13, 79, 158, 148, + 12, 65, 230, 249, 20, 73, 231, 143, 2, 69, 16, 198, 13, 79, 254, 133, 31, + 65, 134, 136, 2, 73, 231, 143, 2, 69, 15, 80, 12, 85, 84, 72, 45, 83, 76, + 65, 86, 69, 89, 32, 75, 154, 170, 35, 79, 3, 89, 8, 134, 169, 35, 65, 2, 69, 2, 73, 3, 79, 117, 110, 72, 190, 1, 76, 78, 84, 238, 8, 65, 66, 87, - 178, 190, 11, 89, 250, 164, 20, 79, 238, 60, 73, 199, 140, 2, 69, 39, - 108, 7, 45, 67, 82, 69, 69, 32, 84, 226, 4, 87, 206, 160, 30, 65, 194, - 200, 1, 79, 238, 60, 73, 199, 140, 2, 69, 16, 11, 72, 17, 158, 165, 30, - 65, 194, 200, 1, 79, 238, 60, 73, 199, 140, 2, 69, 12, 11, 72, 12, 146, - 237, 31, 79, 222, 178, 2, 87, 214, 22, 65, 2, 69, 3, 73, 24, 50, 72, 210, - 181, 34, 65, 2, 69, 2, 73, 3, 79, 17, 222, 163, 30, 65, 194, 200, 1, 79, - 222, 178, 2, 87, 214, 22, 69, 3, 73, 224, 1, 54, 69, 218, 3, 79, 202, - 248, 11, 65, 235, 171, 20, 73, 185, 1, 17, 2, 83, 84, 182, 1, 44, 6, 45, + 134, 222, 11, 89, 154, 242, 20, 79, 202, 61, 73, 231, 143, 2, 69, 39, + 108, 7, 45, 67, 82, 69, 69, 32, 84, 226, 4, 87, 198, 139, 31, 65, 190, + 202, 1, 79, 202, 61, 73, 231, 143, 2, 69, 16, 11, 72, 17, 150, 144, 31, + 65, 190, 202, 1, 79, 202, 61, 73, 231, 143, 2, 69, 12, 11, 72, 12, 134, + 218, 32, 79, 218, 182, 2, 87, 214, 22, 65, 2, 69, 3, 73, 24, 50, 72, 194, + 166, 35, 65, 2, 69, 2, 73, 3, 79, 17, 214, 142, 31, 65, 190, 202, 1, 79, + 218, 182, 2, 87, 214, 22, 69, 3, 73, 224, 1, 54, 69, 218, 3, 79, 158, + 152, 12, 65, 231, 249, 20, 73, 185, 1, 17, 2, 83, 84, 182, 1, 44, 6, 45, 67, 82, 69, 69, 32, 251, 2, 69, 180, 1, 110, 76, 66, 77, 2, 80, 2, 89, 16, 2, 78, 87, 38, 82, 62, 83, 26, 67, 2, 75, 18, 84, 26, 70, 199, 4, 87, - 27, 178, 6, 87, 234, 154, 30, 65, 194, 200, 1, 79, 179, 201, 2, 69, 17, - 243, 5, 87, 6, 202, 160, 30, 65, 243, 145, 4, 69, 13, 226, 188, 32, 87, - 182, 245, 1, 65, 2, 69, 2, 73, 3, 79, 28, 22, 72, 239, 4, 87, 14, 235, 4, - 87, 16, 22, 72, 199, 4, 87, 2, 231, 187, 32, 87, 2, 223, 187, 23, 82, 31, + 27, 178, 6, 87, 226, 133, 31, 65, 190, 202, 1, 79, 175, 205, 2, 69, 17, + 243, 5, 87, 6, 194, 139, 31, 65, 235, 151, 4, 69, 13, 186, 170, 33, 87, + 206, 248, 1, 65, 2, 69, 2, 73, 3, 79, 28, 22, 72, 239, 4, 87, 14, 235, 4, + 87, 16, 22, 72, 199, 4, 87, 2, 191, 169, 33, 87, 2, 207, 163, 24, 82, 31, 11, 79, 29, 41, 8, 68, 83, 45, 67, 82, 69, 69, 32, 26, 56, 2, 84, 72, - 137, 171, 32, 6, 70, 73, 78, 65, 76, 32, 25, 50, 87, 206, 175, 34, 65, 2, - 69, 2, 73, 3, 79, 14, 218, 157, 30, 65, 194, 200, 1, 79, 238, 60, 73, - 243, 245, 1, 69, 61, 92, 6, 45, 67, 82, 69, 69, 32, 150, 1, 65, 38, 79, - 30, 87, 150, 160, 32, 73, 199, 140, 2, 69, 24, 110, 80, 198, 226, 31, 67, - 2, 75, 2, 76, 2, 77, 2, 78, 2, 83, 2, 84, 2, 89, 134, 172, 2, 79, 247, - 30, 87, 4, 134, 184, 32, 87, 195, 214, 1, 79, 9, 210, 160, 32, 65, 199, - 140, 2, 89, 7, 242, 172, 34, 79, 3, 89, 14, 230, 154, 30, 65, 194, 200, - 1, 79, 238, 60, 73, 199, 140, 2, 69, 10, 26, 76, 255, 171, 34, 82, 9, 26, - 32, 179, 185, 9, 76, 4, 142, 155, 22, 67, 231, 164, 10, 84, 4, 230, 148, - 34, 76, 215, 22, 89, 4, 180, 179, 15, 3, 73, 84, 85, 213, 129, 8, 3, 82, - 73, 67, 124, 140, 1, 2, 68, 32, 102, 69, 72, 11, 73, 65, 78, 32, 76, 69, - 84, 84, 69, 82, 32, 210, 3, 79, 62, 80, 90, 82, 141, 221, 27, 4, 32, 83, - 76, 73, 6, 52, 5, 73, 78, 68, 69, 88, 157, 154, 33, 2, 70, 73, 5, 153, - 152, 33, 6, 32, 68, 73, 86, 73, 68, 6, 26, 84, 203, 194, 21, 32, 5, 141, - 161, 10, 6, 32, 73, 78, 83, 69, 82, 98, 196, 1, 2, 67, 45, 38, 76, 22, - 77, 50, 78, 38, 83, 46, 84, 22, 85, 166, 215, 3, 65, 2, 68, 2, 69, 2, 71, - 2, 75, 2, 80, 210, 247, 26, 82, 218, 201, 1, 73, 198, 140, 2, 66, 2, 79, - 2, 81, 3, 88, 4, 170, 251, 26, 49, 155, 177, 3, 51, 7, 203, 216, 3, 68, - 11, 11, 66, 9, 150, 166, 34, 50, 2, 51, 3, 52, 9, 242, 165, 34, 68, 2, - 71, 3, 78, 13, 226, 215, 3, 72, 2, 84, 239, 205, 30, 83, 7, 183, 215, 3, - 84, 13, 11, 85, 11, 11, 85, 9, 246, 164, 34, 50, 2, 51, 3, 85, 4, 148, - 153, 33, 6, 85, 83, 69, 76, 32, 72, 191, 139, 1, 78, 4, 224, 198, 27, 6, - 32, 83, 84, 82, 69, 65, 137, 223, 5, 7, 69, 78, 84, 82, 89, 32, 83, 4, - 142, 209, 27, 73, 135, 182, 6, 79, 9, 29, 5, 32, 70, 65, 67, 69, 7, 33, - 6, 32, 87, 73, 84, 72, 32, 4, 224, 233, 6, 2, 84, 69, 173, 144, 25, 6, - 87, 82, 89, 32, 83, 77, 108, 88, 16, 67, 65, 83, 73, 65, 78, 32, 65, 76, - 66, 65, 78, 73, 65, 78, 32, 167, 156, 30, 84, 106, 60, 7, 76, 69, 84, 84, - 69, 82, 32, 213, 130, 28, 2, 67, 73, 104, 170, 2, 65, 34, 67, 146, 1, 68, - 78, 69, 34, 71, 46, 73, 46, 74, 34, 75, 34, 76, 34, 80, 34, 83, 74, 84, - 62, 89, 46, 90, 148, 249, 16, 2, 81, 65, 242, 188, 6, 77, 252, 132, 9, 3, - 86, 69, 89, 154, 33, 70, 128, 19, 3, 78, 79, 87, 226, 32, 82, 186, 11, - 88, 154, 46, 79, 202, 26, 66, 237, 24, 3, 72, 69, 89, 4, 238, 229, 33, - 79, 179, 28, 76, 16, 34, 65, 34, 72, 49, 2, 89, 65, 4, 166, 206, 33, 89, - 227, 79, 82, 8, 142, 181, 28, 65, 146, 215, 5, 79, 203, 17, 73, 4, 182, - 157, 34, 87, 3, 89, 8, 42, 90, 214, 208, 32, 89, 243, 175, 1, 65, 4, 206, - 142, 33, 89, 219, 124, 65, 4, 238, 204, 33, 89, 227, 79, 66, 4, 136, 238, - 32, 2, 72, 69, 207, 157, 1, 73, 6, 138, 222, 32, 82, 154, 110, 87, 135, - 77, 78, 4, 138, 141, 33, 72, 227, 16, 65, 4, 150, 157, 33, 73, 199, 69, - 65, 4, 182, 203, 33, 65, 171, 51, 89, 4, 142, 1, 73, 139, 202, 33, 69, 8, - 34, 72, 157, 151, 34, 2, 69, 89, 6, 158, 155, 20, 65, 207, 237, 13, 79, - 6, 38, 73, 202, 139, 33, 89, 199, 80, 65, 2, 139, 225, 33, 87, 4, 176, - 211, 33, 2, 65, 89, 1, 2, 79, 87, 6, 242, 154, 16, 72, 183, 181, 4, 65, - 16, 72, 2, 68, 73, 32, 2, 78, 84, 128, 177, 32, 3, 76, 84, 73, 151, 81, - 82, 4, 194, 145, 33, 32, 223, 100, 76, 8, 32, 2, 82, 69, 131, 145, 33, - 32, 6, 44, 5, 76, 73, 78, 69, 32, 167, 228, 4, 32, 4, 170, 218, 21, 76, - 207, 210, 10, 79, 130, 6, 102, 65, 170, 17, 69, 162, 8, 73, 190, 2, 79, - 188, 193, 13, 6, 82, 73, 83, 84, 77, 65, 207, 132, 10, 85, 198, 2, 66, - 73, 32, 4, 75, 77, 65, 32, 148, 6, 2, 77, 32, 131, 8, 82, 4, 142, 216, - 33, 78, 223, 61, 82, 142, 1, 156, 1, 7, 76, 69, 84, 84, 69, 82, 32, 142, - 3, 83, 98, 86, 194, 207, 23, 68, 154, 236, 7, 81, 176, 95, 5, 77, 65, 65, - 89, 89, 240, 179, 1, 2, 65, 85, 3, 79, 76, 202, 1, 68, 54, 78, 54, 84, - 54, 89, 230, 136, 29, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 76, 2, 80, 170, - 147, 3, 72, 2, 77, 2, 82, 2, 83, 2, 86, 2, 87, 254, 242, 1, 65, 186, 2, - 69, 2, 73, 3, 85, 8, 254, 137, 29, 68, 170, 147, 3, 72, 255, 242, 1, 65, - 8, 242, 156, 32, 71, 2, 78, 2, 89, 255, 242, 1, 65, 8, 150, 137, 29, 84, - 170, 147, 3, 72, 255, 242, 1, 65, 4, 138, 156, 32, 89, 255, 242, 1, 65, - 8, 40, 4, 73, 71, 78, 32, 247, 253, 21, 69, 6, 142, 243, 29, 67, 246, - 227, 1, 86, 247, 244, 1, 65, 26, 64, 10, 79, 87, 69, 76, 32, 83, 73, 71, - 78, 32, 223, 211, 31, 73, 24, 130, 178, 30, 65, 250, 6, 85, 186, 202, 1, - 69, 2, 73, 3, 79, 166, 1, 236, 1, 15, 67, 79, 78, 83, 79, 78, 65, 78, 84, - 32, 83, 73, 71, 78, 32, 112, 7, 76, 69, 84, 84, 69, 82, 32, 152, 4, 12, - 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 32, 60, 11, 86, 79, 87, 69, - 76, 32, 83, 73, 71, 78, 32, 251, 147, 32, 68, 14, 72, 6, 70, 73, 78, 65, - 76, 32, 194, 138, 34, 76, 2, 82, 2, 87, 3, 89, 6, 162, 140, 34, 78, 86, - 72, 3, 77, 104, 132, 2, 6, 70, 73, 78, 65, 76, 32, 110, 78, 50, 77, 78, - 80, 174, 217, 11, 66, 226, 141, 6, 68, 210, 140, 12, 83, 198, 136, 2, 65, - 132, 197, 1, 2, 67, 72, 2, 71, 2, 74, 2, 75, 2, 84, 138, 69, 72, 2, 76, - 2, 82, 2, 86, 2, 89, 186, 2, 69, 2, 73, 2, 79, 3, 85, 22, 202, 140, 32, - 78, 166, 192, 1, 83, 206, 60, 67, 146, 1, 71, 2, 75, 2, 76, 2, 80, 2, 82, - 2, 84, 3, 89, 14, 46, 71, 34, 72, 190, 242, 33, 85, 215, 22, 65, 4, 218, - 242, 33, 85, 215, 22, 65, 6, 186, 242, 33, 85, 158, 20, 74, 187, 2, 65, - 6, 170, 134, 34, 72, 2, 80, 187, 2, 65, 8, 130, 162, 11, 83, 238, 133, - 19, 68, 45, 4, 84, 82, 73, 80, 20, 222, 176, 30, 65, 222, 202, 1, 73, - 166, 204, 1, 79, 2, 85, 203, 44, 69, 14, 72, 7, 65, 67, 84, 69, 82, 32, - 84, 49, 7, 84, 32, 87, 73, 84, 72, 32, 8, 192, 247, 9, 3, 65, 66, 85, - 215, 248, 23, 73, 6, 128, 1, 13, 85, 80, 87, 65, 82, 68, 83, 32, 84, 82, - 69, 78, 68, 213, 169, 25, 12, 68, 79, 87, 78, 87, 65, 82, 68, 83, 32, 84, - 82, 5, 229, 241, 6, 6, 32, 65, 78, 68, 32, 89, 236, 2, 80, 2, 67, 75, 82, - 69, 90, 82, 176, 249, 4, 2, 83, 84, 185, 153, 15, 2, 81, 85, 6, 56, 8, - 69, 82, 32, 66, 79, 65, 82, 68, 195, 194, 33, 32, 5, 151, 136, 31, 32, 4, - 148, 186, 27, 4, 83, 69, 32, 87, 221, 156, 5, 9, 82, 73, 78, 71, 32, 77, - 69, 71, 65, 222, 2, 40, 5, 79, 75, 69, 69, 32, 143, 5, 82, 216, 2, 46, - 76, 1, 7, 83, 77, 65, 76, 76, 32, 76, 172, 1, 33, 6, 69, 84, 84, 69, 82, - 32, 172, 1, 170, 1, 68, 74, 72, 74, 78, 70, 83, 62, 84, 54, 71, 2, 76, 2, - 77, 0, 2, 81, 85, 2, 87, 2, 89, 214, 251, 33, 75, 186, 2, 65, 2, 69, 2, - 73, 2, 79, 2, 85, 3, 86, 14, 150, 254, 33, 76, 186, 2, 65, 2, 69, 2, 73, - 2, 79, 2, 85, 3, 86, 14, 206, 253, 33, 78, 186, 2, 65, 2, 69, 2, 73, 2, - 79, 2, 85, 3, 86, 14, 222, 238, 29, 65, 226, 144, 4, 69, 2, 73, 2, 79, 2, - 85, 3, 86, 15, 250, 254, 33, 65, 2, 69, 2, 73, 2, 79, 2, 85, 3, 86, 30, - 50, 76, 2, 83, 142, 254, 33, 65, 2, 69, 3, 73, 12, 138, 254, 33, 65, 2, - 69, 2, 73, 2, 79, 2, 85, 3, 86, 6, 32, 2, 89, 32, 171, 231, 32, 73, 4, - 40, 4, 66, 76, 79, 83, 215, 231, 32, 83, 2, 155, 236, 33, 83, 16, 152, 1, - 2, 76, 68, 48, 11, 78, 69, 83, 69, 32, 83, 77, 65, 76, 76, 32, 154, 239, - 7, 32, 184, 247, 2, 2, 80, 77, 204, 190, 21, 2, 67, 75, 155, 134, 1, 82, - 5, 225, 230, 28, 7, 82, 69, 78, 32, 67, 82, 79, 4, 172, 208, 19, 10, 83, - 73, 77, 80, 76, 73, 70, 73, 69, 68, 1, 11, 84, 82, 65, 68, 73, 84, 73, - 79, 78, 65, 76, 60, 92, 8, 82, 65, 83, 77, 73, 65, 78, 32, 254, 254, 4, - 80, 197, 133, 12, 5, 67, 79, 76, 65, 84, 56, 52, 7, 76, 69, 84, 84, 69, - 82, 32, 251, 197, 21, 78, 42, 224, 1, 6, 67, 85, 82, 76, 69, 68, 30, 83, - 210, 194, 21, 68, 34, 76, 134, 206, 1, 82, 142, 220, 2, 65, 50, 71, 90, - 90, 98, 89, 198, 207, 1, 72, 234, 5, 75, 174, 81, 66, 170, 225, 4, 78, - 134, 2, 84, 2, 87, 218, 103, 80, 171, 4, 77, 2, 133, 249, 32, 2, 32, 87, - 6, 184, 194, 21, 6, 77, 65, 76, 76, 32, 65, 232, 243, 5, 2, 65, 77, 163, - 193, 5, 72, 232, 4, 66, 78, 20, 2, 82, 67, 201, 40, 7, 84, 89, 83, 67, - 65, 80, 69, 2, 235, 212, 33, 69, 226, 4, 28, 2, 76, 69, 207, 39, 85, 220, - 4, 30, 32, 185, 6, 2, 68, 32, 24, 244, 1, 5, 87, 73, 84, 72, 32, 161, - 193, 18, 49, 68, 73, 86, 73, 68, 69, 68, 32, 66, 89, 32, 72, 79, 82, 73, - 90, 79, 78, 84, 65, 76, 32, 66, 65, 82, 32, 65, 78, 68, 32, 84, 79, 80, - 32, 72, 65, 76, 70, 32, 68, 73, 86, 73, 68, 69, 68, 32, 66, 89, 22, 146, - 2, 76, 46, 83, 108, 22, 84, 87, 79, 32, 72, 79, 82, 73, 90, 79, 78, 84, - 65, 76, 32, 83, 84, 82, 79, 75, 69, 83, 44, 6, 85, 80, 80, 69, 82, 32, - 44, 17, 65, 76, 76, 32, 66, 85, 84, 32, 85, 80, 80, 69, 82, 32, 76, 69, - 70, 242, 188, 26, 86, 242, 146, 4, 82, 183, 251, 1, 72, 4, 194, 209, 30, - 69, 49, 4, 79, 87, 69, 82, 4, 104, 11, 77, 65, 76, 76, 32, 67, 73, 82, - 67, 76, 69, 221, 5, 10, 85, 80, 69, 82, 73, 77, 80, 79, 83, 69, 2, 149, - 235, 30, 6, 32, 84, 79, 32, 84, 72, 4, 40, 4, 82, 73, 71, 72, 155, 208, - 30, 72, 2, 173, 208, 30, 10, 84, 32, 81, 85, 65, 68, 82, 65, 78, 84, 196, - 4, 230, 2, 65, 186, 1, 66, 58, 67, 230, 1, 68, 246, 1, 72, 230, 2, 73, - 194, 10, 75, 190, 2, 76, 38, 77, 136, 1, 7, 78, 85, 77, 66, 69, 82, 32, - 192, 4, 17, 79, 80, 69, 78, 32, 67, 69, 78, 84, 82, 69, 32, 69, 73, 71, - 72, 84, 54, 80, 114, 82, 50, 84, 78, 87, 140, 252, 9, 4, 90, 69, 82, 79, - 134, 188, 16, 69, 182, 188, 4, 86, 146, 68, 71, 150, 115, 83, 227, 162, - 1, 88, 6, 100, 12, 78, 84, 73, 67, 76, 79, 67, 75, 87, 73, 83, 69, 209, - 167, 30, 7, 83, 84, 69, 82, 73, 83, 75, 4, 160, 241, 8, 11, 45, 82, 79, - 84, 65, 84, 69, 68, 32, 68, 73, 167, 221, 23, 32, 4, 32, 2, 79, 76, 143, - 136, 32, 85, 2, 223, 209, 14, 68, 16, 60, 4, 82, 79, 83, 83, 210, 2, 32, - 254, 230, 33, 67, 3, 68, 10, 26, 32, 199, 193, 1, 73, 8, 64, 6, 70, 79, - 82, 77, 69, 69, 205, 246, 31, 4, 80, 79, 77, 77, 7, 33, 6, 32, 87, 73, - 84, 72, 32, 4, 210, 193, 31, 70, 135, 84, 84, 30, 34, 73, 70, 79, 187, - 252, 31, 65, 24, 168, 188, 4, 8, 86, 73, 83, 73, 79, 78, 32, 83, 235, - 183, 27, 71, 4, 64, 10, 76, 76, 65, 82, 32, 83, 73, 71, 78, 32, 187, 163, - 30, 84, 2, 225, 158, 19, 13, 87, 73, 84, 72, 32, 79, 86, 69, 82, 76, 65, - 73, 68, 64, 192, 1, 6, 65, 78, 71, 85, 76, 32, 252, 191, 12, 20, 79, 82, - 73, 90, 79, 78, 84, 65, 76, 32, 66, 65, 82, 32, 87, 73, 84, 72, 32, 78, - 128, 213, 9, 4, 85, 77, 65, 78, 145, 1, 4, 69, 65, 86, 89, 58, 110, 67, - 192, 190, 20, 5, 73, 69, 85, 78, 71, 42, 72, 30, 75, 66, 77, 34, 78, 34, - 80, 62, 82, 30, 83, 27, 84, 8, 158, 190, 20, 72, 157, 3, 4, 73, 69, 85, - 67, 116, 220, 1, 9, 68, 69, 79, 71, 82, 65, 80, 72, 32, 196, 8, 27, 84, - 65, 76, 73, 67, 32, 76, 65, 84, 73, 78, 32, 67, 65, 80, 73, 84, 65, 76, - 32, 76, 69, 84, 84, 69, 82, 32, 221, 145, 27, 9, 78, 70, 79, 82, 77, 65, - 84, 73, 79, 110, 174, 1, 65, 110, 67, 90, 69, 86, 70, 62, 72, 38, 75, 70, - 76, 50, 77, 86, 78, 62, 81, 30, 82, 74, 83, 146, 170, 6, 80, 138, 149, - 14, 84, 50, 87, 202, 215, 1, 73, 163, 168, 10, 79, 8, 166, 191, 20, 76, - 200, 134, 1, 3, 67, 67, 69, 184, 249, 6, 3, 84, 84, 69, 249, 17, 5, 68, - 86, 65, 78, 84, 8, 26, 79, 159, 218, 30, 69, 6, 184, 204, 10, 2, 82, 82, - 166, 242, 9, 78, 147, 143, 13, 80, 8, 242, 190, 20, 78, 174, 179, 9, 65, - 180, 169, 3, 5, 88, 67, 69, 76, 76, 231, 24, 73, 10, 254, 190, 20, 73, - 144, 190, 5, 2, 69, 77, 199, 232, 6, 79, 4, 198, 176, 29, 73, 211, 176, - 3, 65, 4, 176, 158, 7, 8, 73, 78, 68, 69, 82, 71, 65, 82, 143, 204, 22, - 79, 6, 142, 190, 20, 65, 214, 160, 12, 79, 195, 83, 69, 8, 38, 69, 242, - 181, 32, 65, 211, 86, 79, 4, 236, 192, 32, 3, 68, 73, 67, 227, 15, 84, 6, - 26, 73, 247, 193, 32, 65, 4, 170, 177, 33, 71, 231, 19, 78, 2, 157, 192, - 28, 2, 85, 69, 8, 26, 69, 203, 176, 33, 73, 6, 150, 189, 20, 83, 217, - 136, 8, 2, 76, 73, 22, 90, 69, 38, 85, 184, 149, 14, 2, 67, 72, 182, 167, - 6, 79, 22, 80, 34, 84, 131, 142, 12, 73, 4, 186, 156, 10, 67, 199, 231, - 21, 86, 6, 234, 189, 20, 80, 146, 128, 2, 73, 231, 155, 11, 78, 4, 170, - 217, 33, 67, 3, 82, 98, 116, 8, 65, 84, 65, 75, 65, 78, 65, 32, 133, 1, - 16, 79, 82, 69, 65, 78, 32, 67, 72, 65, 82, 65, 67, 84, 69, 82, 32, 94, - 242, 232, 10, 72, 2, 75, 2, 77, 2, 78, 2, 82, 2, 83, 2, 84, 126, 87, 46, - 89, 254, 237, 22, 65, 2, 69, 2, 73, 2, 79, 3, 85, 4, 152, 145, 16, 3, 74, - 85, 69, 249, 166, 17, 4, 67, 72, 65, 77, 106, 146, 180, 27, 65, 255, 140, - 4, 69, 4, 100, 19, 85, 76, 84, 73, 80, 76, 73, 67, 65, 84, 73, 79, 78, - 32, 83, 73, 71, 78, 32, 219, 204, 31, 73, 2, 209, 81, 4, 87, 73, 84, 72, - 98, 50, 69, 46, 70, 98, 83, 94, 84, 199, 185, 20, 78, 6, 180, 1, 3, 73, - 71, 72, 255, 176, 25, 76, 30, 28, 3, 73, 70, 84, 35, 79, 6, 214, 1, 89, - 207, 252, 31, 69, 24, 142, 2, 82, 175, 185, 20, 85, 8, 40, 4, 69, 86, 69, - 78, 1, 2, 73, 88, 4, 11, 84, 4, 104, 2, 89, 32, 195, 252, 31, 69, 52, 56, - 2, 69, 78, 32, 4, 72, 73, 82, 84, 29, 2, 87, 69, 5, 11, 32, 2, 191, 206, - 25, 79, 24, 74, 89, 227, 251, 31, 69, 24, 26, 78, 167, 213, 32, 76, 22, - 17, 2, 84, 89, 23, 11, 32, 20, 72, 2, 79, 78, 130, 222, 31, 70, 30, 83, - 42, 84, 142, 87, 78, 239, 112, 69, 4, 154, 205, 25, 32, 243, 131, 8, 69, - 2, 245, 182, 31, 8, 32, 80, 79, 73, 78, 84, 69, 68, 8, 248, 205, 17, 3, - 79, 83, 84, 242, 246, 6, 65, 228, 203, 2, 8, 69, 82, 80, 69, 78, 68, 73, - 67, 131, 183, 4, 76, 4, 252, 139, 30, 3, 73, 78, 71, 163, 170, 1, 69, 6, - 52, 7, 82, 73, 65, 78, 71, 76, 69, 195, 182, 26, 73, 5, 135, 150, 22, 32, - 6, 44, 5, 72, 73, 84, 69, 32, 155, 206, 33, 90, 4, 246, 235, 31, 66, 215, - 25, 83, 6, 206, 167, 27, 77, 184, 190, 4, 6, 76, 65, 84, 73, 79, 78, 201, - 164, 1, 3, 83, 32, 84, 5, 157, 134, 32, 6, 32, 65, 84, 32, 68, 85, 178, - 2, 80, 8, 82, 65, 68, 73, 67, 65, 76, 32, 245, 17, 7, 83, 84, 82, 79, 75, - 69, 32, 230, 1, 210, 1, 66, 126, 67, 226, 4, 68, 62, 69, 50, 70, 34, 71, - 50, 72, 86, 74, 154, 1, 76, 62, 77, 130, 1, 80, 46, 82, 78, 83, 182, 3, - 84, 82, 87, 240, 225, 10, 2, 78, 69, 208, 13, 4, 75, 78, 73, 70, 255, - 155, 12, 79, 14, 74, 79, 188, 254, 10, 4, 82, 85, 83, 72, 162, 240, 4, - 65, 195, 203, 13, 76, 6, 130, 169, 10, 76, 162, 138, 23, 78, 215, 22, 88, - 56, 104, 12, 45, 83, 73, 77, 80, 76, 73, 70, 73, 69, 68, 32, 162, 3, 73, - 50, 76, 238, 198, 32, 79, 191, 78, 72, 44, 114, 69, 38, 70, 50, 71, 38, - 76, 34, 83, 94, 84, 182, 209, 14, 87, 42, 68, 182, 239, 16, 66, 170, 121, - 72, 163, 4, 67, 4, 226, 241, 31, 86, 219, 185, 1, 65, 6, 186, 220, 31, - 73, 194, 217, 1, 76, 235, 16, 82, 4, 198, 151, 23, 79, 187, 230, 8, 65, - 4, 190, 197, 32, 69, 187, 48, 79, 10, 238, 225, 6, 73, 250, 190, 17, 65, - 194, 194, 1, 72, 128, 193, 7, 3, 80, 69, 69, 215, 11, 69, 6, 214, 10, 85, - 224, 183, 10, 2, 65, 78, 159, 161, 4, 79, 4, 180, 216, 20, 3, 86, 73, 76, - 191, 219, 12, 84, 4, 150, 225, 17, 73, 219, 205, 14, 79, 6, 164, 160, 24, - 2, 73, 86, 222, 240, 2, 69, 147, 179, 6, 79, 10, 196, 6, 2, 65, 84, 146, - 167, 33, 87, 3, 89, 4, 190, 161, 32, 73, 135, 82, 79, 8, 244, 5, 4, 82, - 65, 83, 83, 231, 207, 29, 72, 10, 48, 2, 69, 65, 150, 176, 28, 79, 211, - 130, 4, 65, 6, 186, 8, 82, 191, 186, 33, 68, 10, 72, 12, 45, 83, 73, 77, - 80, 76, 73, 70, 73, 69, 68, 32, 155, 175, 31, 65, 8, 42, 84, 202, 205, - 14, 68, 195, 129, 17, 69, 4, 194, 6, 85, 255, 216, 14, 79, 12, 128, 246, - 10, 3, 79, 78, 71, 129, 253, 15, 3, 65, 77, 69, 14, 18, 69, 35, 79, 4, - 194, 164, 33, 65, 159, 27, 83, 10, 144, 245, 10, 3, 85, 78, 68, 234, 169, - 13, 84, 138, 217, 7, 82, 239, 120, 79, 6, 196, 244, 10, 2, 65, 87, 163, - 199, 18, 69, 8, 34, 65, 249, 181, 32, 2, 69, 80, 6, 210, 239, 32, 73, - 226, 79, 77, 3, 80, 38, 122, 69, 90, 73, 186, 1, 78, 196, 1, 4, 80, 73, - 82, 73, 128, 239, 10, 4, 77, 65, 76, 76, 218, 153, 12, 72, 135, 226, 9, - 85, 8, 40, 4, 67, 79, 78, 68, 151, 178, 32, 65, 6, 11, 32, 6, 142, 203, - 31, 84, 155, 87, 79, 12, 60, 9, 77, 80, 76, 73, 70, 73, 69, 68, 32, 227, - 185, 33, 76, 10, 34, 72, 50, 87, 207, 189, 10, 89, 4, 212, 167, 10, 3, - 65, 76, 70, 155, 130, 18, 79, 4, 194, 215, 6, 65, 167, 219, 25, 72, 6, - 192, 1, 2, 79, 85, 231, 138, 33, 65, 8, 58, 85, 202, 228, 24, 65, 242, - 204, 1, 72, 191, 184, 3, 73, 2, 187, 146, 24, 82, 12, 26, 65, 49, 2, 69, - 83, 8, 172, 239, 10, 2, 76, 75, 1, 3, 84, 69, 82, 4, 255, 238, 10, 84, - 76, 110, 72, 182, 1, 80, 38, 83, 246, 185, 31, 84, 152, 253, 1, 2, 66, - 88, 2, 87, 2, 88, 86, 68, 2, 78, 3, 81, 31, 42, 80, 22, 88, 30, 90, 223, - 184, 33, 71, 5, 183, 184, 33, 87, 4, 162, 184, 33, 87, 87, 71, 19, 50, - 90, 170, 186, 31, 87, 130, 254, 1, 71, 3, 84, 9, 166, 186, 31, 90, 131, - 254, 1, 80, 9, 130, 184, 33, 68, 2, 71, 3, 90, 23, 50, 87, 30, 90, 146, - 183, 33, 71, 2, 80, 3, 84, 7, 170, 183, 33, 71, 3, 90, 9, 186, 182, 33, - 87, 86, 80, 3, 90, 124, 62, 65, 194, 1, 73, 114, 79, 233, 247, 20, 4, 69, - 65, 82, 32, 8, 132, 1, 2, 80, 80, 128, 217, 3, 6, 83, 83, 73, 67, 65, 76, - 181, 175, 28, 14, 77, 83, 72, 69, 76, 76, 32, 77, 79, 66, 73, 76, 69, 32, - 4, 232, 195, 19, 5, 73, 78, 71, 32, 72, 227, 228, 1, 69, 6, 48, 6, 78, - 75, 73, 78, 71, 32, 171, 155, 32, 80, 4, 246, 156, 25, 71, 149, 189, 3, - 6, 66, 69, 69, 82, 32, 77, 108, 72, 2, 67, 75, 140, 10, 2, 83, 69, 236, - 3, 2, 85, 68, 131, 175, 30, 87, 70, 64, 6, 32, 70, 65, 67, 69, 32, 237, - 2, 5, 87, 73, 83, 69, 32, 48, 58, 69, 46, 70, 36, 2, 78, 73, 2, 79, 18, - 83, 51, 84, 8, 120, 2, 76, 69, 125, 4, 73, 71, 72, 84, 8, 178, 1, 73, 25, - 3, 79, 85, 82, 4, 155, 1, 78, 8, 26, 69, 125, 2, 73, 88, 4, 57, 2, 86, - 69, 16, 38, 69, 14, 87, 41, 3, 72, 82, 69, 4, 63, 78, 8, 24, 2, 69, 76, - 27, 79, 4, 11, 86, 4, 11, 69, 4, 228, 140, 29, 2, 32, 79, 193, 179, 2, 3, - 45, 84, 72, 22, 90, 67, 58, 68, 122, 71, 48, 5, 82, 73, 71, 72, 84, 226, - 2, 84, 122, 79, 247, 159, 31, 73, 4, 196, 1, 3, 76, 79, 83, 181, 103, 4, - 79, 78, 84, 79, 2, 141, 3, 26, 79, 87, 78, 87, 65, 82, 68, 83, 32, 65, - 78, 68, 32, 85, 80, 87, 65, 82, 68, 83, 32, 79, 80, 69, 78, 32, 2, 21, 3, - 65, 80, 80, 2, 133, 4, 2, 69, 68, 6, 228, 1, 14, 32, 65, 78, 68, 32, 76, - 69, 70, 84, 32, 83, 69, 77, 73, 45, 38, 87, 65, 82, 68, 83, 32, 65, 78, - 68, 32, 76, 69, 70, 84, 87, 65, 82, 68, 83, 32, 79, 80, 69, 78, 32, 67, - 73, 82, 67, 76, 69, 32, 65, 82, 82, 79, 87, 83, 2, 185, 204, 30, 6, 67, - 73, 82, 67, 76, 69, 5, 253, 85, 15, 32, 87, 73, 84, 72, 32, 67, 73, 82, - 67, 76, 69, 68, 32, 79, 4, 82, 79, 37, 16, 82, 73, 65, 78, 71, 76, 69, - 45, 72, 69, 65, 68, 69, 68, 32, 79, 2, 69, 6, 80, 32, 83, 69, 77, 73, 2, - 21, 3, 80, 69, 78, 2, 11, 32, 2, 217, 202, 30, 4, 67, 73, 82, 67, 26, 32, - 2, 68, 32, 143, 179, 32, 32, 24, 216, 1, 2, 83, 85, 66, 85, 214, 181, 19, - 77, 180, 3, 9, 76, 79, 67, 75, 32, 87, 73, 84, 72, 238, 151, 12, 66, 149, - 152, 1, 23, 73, 78, 84, 69, 82, 83, 69, 67, 84, 73, 79, 78, 32, 87, 73, - 84, 72, 32, 83, 69, 82, 73, 70, 8, 30, 66, 1, 3, 80, 69, 82, 4, 237, 135, - 25, 3, 83, 69, 84, 6, 82, 77, 33, 16, 78, 73, 79, 78, 32, 87, 73, 84, 72, - 32, 83, 69, 82, 73, 70, 83, 2, 201, 234, 24, 3, 66, 82, 69, 5, 161, 148, - 32, 9, 32, 65, 78, 68, 32, 83, 77, 65, 83, 11, 33, 6, 32, 87, 73, 84, 72, - 32, 8, 72, 4, 84, 79, 82, 78, 138, 168, 5, 76, 226, 231, 19, 83, 251, - 229, 6, 82, 2, 135, 229, 25, 65, 152, 10, 158, 1, 67, 82, 76, 98, 77, - 202, 86, 78, 220, 5, 2, 79, 75, 58, 80, 154, 19, 82, 138, 1, 85, 170, - 137, 28, 87, 232, 167, 3, 2, 70, 70, 246, 47, 73, 183, 51, 65, 6, 26, 75, - 155, 153, 4, 79, 4, 150, 240, 8, 82, 129, 153, 23, 4, 84, 65, 73, 76, 8, - 44, 2, 79, 78, 237, 145, 25, 3, 76, 73, 83, 7, 11, 32, 4, 202, 139, 26, - 69, 211, 143, 6, 83, 212, 6, 72, 7, 66, 73, 78, 73, 78, 71, 32, 206, 84, - 77, 94, 80, 191, 175, 32, 69, 196, 6, 210, 2, 65, 186, 2, 66, 118, 67, - 246, 12, 68, 226, 10, 69, 142, 2, 70, 70, 71, 156, 9, 2, 72, 79, 82, 73, - 248, 1, 2, 75, 65, 162, 1, 76, 158, 14, 77, 178, 2, 78, 78, 79, 138, 2, - 80, 182, 1, 82, 248, 4, 5, 90, 73, 71, 90, 65, 138, 2, 83, 162, 4, 84, - 238, 2, 85, 168, 1, 8, 86, 69, 82, 84, 73, 67, 65, 76, 204, 1, 2, 87, 73, - 171, 1, 88, 26, 148, 1, 4, 67, 85, 84, 69, 98, 78, 188, 143, 25, 6, 83, - 84, 69, 82, 73, 83, 241, 234, 5, 14, 76, 77, 79, 83, 84, 32, 69, 81, 85, - 65, 76, 32, 84, 79, 12, 22, 45, 231, 34, 32, 6, 186, 57, 86, 184, 152, - 12, 6, 71, 82, 65, 86, 69, 45, 251, 210, 3, 77, 6, 228, 2, 4, 84, 73, 67, - 76, 237, 183, 3, 4, 78, 85, 73, 84, 12, 42, 82, 189, 234, 30, 4, 73, 78, - 68, 85, 10, 32, 3, 69, 86, 69, 243, 37, 73, 7, 210, 169, 12, 45, 211, - 192, 18, 32, 142, 1, 142, 1, 65, 34, 76, 98, 79, 116, 8, 89, 82, 73, 76, - 76, 73, 67, 32, 252, 29, 11, 73, 82, 67, 85, 77, 70, 76, 69, 88, 32, 65, - 171, 154, 12, 69, 6, 222, 19, 82, 211, 232, 28, 78, 4, 41, 8, 79, 67, 75, - 87, 73, 83, 69, 32, 4, 248, 176, 12, 4, 82, 73, 78, 71, 191, 234, 16, 65, - 10, 76, 4, 77, 77, 65, 32, 249, 17, 10, 78, 74, 79, 73, 78, 73, 78, 71, - 32, 77, 6, 142, 153, 13, 65, 175, 221, 17, 66, 116, 252, 1, 8, 72, 85, - 78, 68, 82, 69, 68, 32, 32, 7, 76, 69, 84, 84, 69, 82, 32, 166, 5, 80, - 116, 5, 68, 65, 83, 73, 65, 38, 84, 106, 77, 230, 247, 2, 75, 220, 144, - 13, 15, 83, 77, 65, 76, 76, 32, 76, 69, 84, 84, 69, 82, 32, 66, 89, 221, - 208, 16, 2, 86, 90, 4, 194, 7, 77, 247, 162, 3, 84, 84, 238, 1, 66, 38, - 68, 50, 69, 82, 73, 106, 79, 22, 83, 66, 85, 30, 89, 238, 141, 3, 76, - 140, 5, 5, 77, 79, 78, 79, 71, 150, 18, 72, 154, 233, 12, 84, 182, 130, - 16, 90, 150, 83, 67, 2, 71, 182, 8, 70, 134, 14, 80, 2, 86, 158, 20, 75, - 187, 2, 65, 4, 218, 168, 6, 73, 155, 235, 26, 69, 4, 188, 245, 25, 3, 74, - 69, 82, 147, 158, 7, 69, 14, 58, 83, 230, 146, 33, 70, 2, 76, 2, 77, 2, - 78, 3, 82, 5, 207, 201, 31, 45, 11, 56, 8, 79, 84, 73, 70, 73, 69, 68, - 32, 151, 146, 33, 69, 6, 238, 166, 6, 66, 166, 235, 26, 65, 3, 69, 5, - 227, 204, 25, 77, 6, 26, 72, 139, 144, 16, 79, 4, 142, 148, 31, 67, 171, - 253, 1, 65, 5, 225, 157, 3, 2, 75, 82, 8, 250, 206, 28, 69, 210, 165, 4, - 65, 174, 28, 73, 3, 85, 8, 66, 65, 48, 4, 83, 73, 76, 73, 193, 217, 29, - 4, 79, 75, 82, 89, 4, 194, 250, 2, 89, 169, 234, 12, 3, 76, 65, 84, 2, - 209, 14, 5, 32, 80, 78, 69, 85, 10, 80, 2, 69, 78, 0, 7, 72, 79, 85, 83, - 65, 78, 68, 237, 9, 4, 73, 84, 76, 79, 2, 17, 2, 32, 77, 2, 253, 241, 21, - 5, 73, 76, 76, 73, 79, 124, 66, 69, 244, 1, 8, 73, 65, 69, 82, 69, 83, - 73, 83, 131, 1, 79, 38, 68, 9, 86, 65, 78, 65, 71, 65, 82, 73, 32, 229, - 163, 32, 2, 76, 69, 36, 92, 7, 76, 69, 84, 84, 69, 82, 32, 172, 143, 26, - 6, 83, 73, 71, 78, 32, 65, 251, 136, 5, 68, 14, 210, 248, 32, 86, 162, - 17, 75, 2, 78, 2, 80, 2, 82, 186, 2, 65, 3, 85, 9, 26, 32, 131, 246, 27, - 45, 4, 214, 233, 30, 66, 189, 142, 1, 16, 87, 73, 84, 72, 32, 82, 65, 73, - 83, 69, 68, 32, 76, 69, 70, 84, 78, 58, 84, 164, 1, 4, 85, 66, 76, 69, - 169, 5, 2, 87, 78, 16, 74, 32, 180, 182, 10, 5, 45, 65, 78, 68, 45, 213, - 222, 5, 3, 84, 69, 68, 10, 64, 5, 65, 66, 79, 86, 69, 165, 185, 6, 5, 66, - 69, 76, 79, 87, 7, 147, 222, 32, 32, 56, 22, 32, 247, 4, 68, 54, 222, 1, - 65, 34, 66, 0, 10, 73, 78, 86, 69, 82, 84, 69, 68, 32, 66, 26, 67, 34, - 77, 54, 79, 34, 80, 68, 2, 82, 73, 48, 5, 84, 73, 76, 68, 69, 80, 9, 86, - 69, 82, 84, 73, 67, 65, 76, 32, 146, 144, 16, 71, 243, 182, 4, 76, 6, - 226, 17, 82, 131, 129, 16, 67, 4, 145, 17, 2, 82, 69, 4, 154, 223, 31, - 65, 135, 42, 73, 4, 21, 3, 65, 67, 82, 4, 165, 255, 16, 2, 79, 78, 4, - 138, 37, 80, 179, 246, 30, 86, 6, 146, 38, 76, 253, 228, 7, 9, 65, 82, - 69, 78, 84, 72, 69, 83, 69, 6, 240, 52, 4, 71, 72, 84, 87, 155, 253, 9, - 78, 7, 11, 32, 4, 44, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, 2, 143, 224, - 30, 84, 6, 182, 155, 12, 83, 227, 182, 14, 76, 2, 201, 138, 16, 2, 32, - 67, 6, 138, 51, 32, 131, 175, 31, 87, 18, 72, 9, 78, 67, 76, 79, 83, 73, - 78, 71, 32, 177, 35, 4, 81, 85, 65, 76, 14, 132, 1, 6, 67, 73, 82, 67, - 76, 69, 22, 83, 216, 165, 6, 3, 75, 69, 89, 216, 208, 19, 7, 85, 80, 87, - 65, 82, 68, 32, 171, 204, 5, 68, 5, 215, 185, 18, 32, 4, 234, 226, 25, - 67, 147, 252, 5, 81, 6, 48, 2, 69, 82, 154, 141, 5, 79, 175, 131, 12, 76, - 2, 255, 76, 77, 128, 1, 88, 17, 76, 65, 71, 79, 76, 73, 84, 73, 67, 32, - 76, 69, 84, 84, 69, 82, 32, 143, 3, 82, 76, 238, 1, 68, 30, 73, 46, 83, - 50, 84, 158, 142, 6, 65, 22, 66, 94, 67, 134, 1, 70, 38, 71, 238, 2, 77, - 32, 2, 76, 74, 34, 78, 88, 2, 80, 79, 30, 82, 194, 2, 86, 22, 89, 90, 90, - 210, 137, 19, 72, 190, 133, 2, 85, 162, 177, 5, 79, 235, 5, 75, 4, 214, - 144, 6, 74, 31, 79, 11, 226, 145, 6, 78, 54, 79, 219, 190, 26, 90, 8, - 194, 146, 6, 77, 130, 4, 76, 223, 210, 22, 72, 4, 246, 150, 6, 86, 211, - 210, 26, 83, 52, 38, 65, 185, 3, 4, 69, 69, 75, 32, 38, 84, 5, 78, 84, - 72, 65, 32, 196, 1, 2, 86, 69, 189, 203, 28, 5, 80, 72, 69, 77, 69, 24, - 68, 6, 68, 73, 71, 73, 84, 32, 65, 7, 76, 69, 84, 84, 69, 82, 32, 14, - 170, 239, 16, 83, 254, 152, 14, 70, 70, 84, 62, 90, 223, 86, 79, 10, 154, - 231, 32, 86, 162, 17, 75, 2, 78, 2, 80, 187, 2, 65, 12, 18, 32, 67, 45, - 6, 26, 65, 131, 176, 16, 84, 4, 237, 147, 4, 4, 67, 67, 69, 78, 6, 150, - 22, 86, 168, 242, 11, 6, 65, 67, 85, 84, 69, 45, 139, 249, 3, 77, 14, - 148, 1, 8, 77, 85, 83, 73, 67, 65, 76, 32, 130, 155, 4, 75, 246, 197, 2, - 80, 174, 4, 89, 141, 236, 3, 11, 68, 73, 65, 76, 89, 84, 73, 75, 65, 32, - 84, 6, 26, 84, 255, 195, 15, 80, 4, 214, 196, 15, 69, 35, 82, 6, 146, - 250, 12, 79, 180, 128, 19, 8, 77, 79, 84, 72, 69, 84, 73, 67, 167, 45, - 82, 16, 26, 78, 203, 197, 30, 83, 14, 52, 7, 86, 69, 82, 84, 69, 68, 32, - 167, 197, 28, 70, 12, 60, 2, 66, 82, 69, 9, 68, 79, 85, 66, 76, 69, 32, - 65, 82, 8, 18, 69, 23, 73, 4, 203, 224, 11, 86, 4, 157, 211, 30, 2, 68, - 71, 4, 11, 67, 4, 131, 211, 30, 72, 8, 128, 1, 16, 84, 65, 75, 65, 78, - 65, 45, 72, 73, 82, 65, 71, 65, 78, 65, 32, 229, 242, 17, 9, 86, 89, 75, - 65, 32, 65, 66, 79, 86, 4, 190, 135, 10, 83, 35, 86, 162, 1, 80, 5, 65, - 84, 73, 78, 32, 164, 8, 3, 69, 70, 84, 232, 3, 2, 73, 71, 83, 79, 106, - 156, 1, 21, 76, 69, 84, 84, 69, 82, 32, 83, 77, 65, 76, 76, 32, 67, 65, - 80, 73, 84, 65, 76, 32, 53, 13, 83, 77, 65, 76, 76, 32, 76, 69, 84, 84, - 69, 82, 32, 10, 234, 241, 32, 71, 2, 76, 2, 77, 2, 78, 3, 82, 96, 226, 1, - 65, 70, 67, 34, 69, 30, 70, 78, 73, 86, 76, 106, 79, 2, 85, 134, 1, 82, - 50, 84, 158, 175, 12, 83, 162, 151, 2, 66, 238, 157, 2, 87, 242, 134, 16, - 68, 2, 71, 2, 72, 2, 75, 2, 77, 2, 78, 2, 80, 2, 86, 2, 88, 3, 90, 13, - 182, 246, 2, 32, 150, 157, 26, 76, 138, 220, 3, 69, 2, 79, 3, 86, 5, 173, - 143, 12, 3, 32, 67, 69, 7, 222, 237, 32, 83, 3, 84, 5, 149, 195, 27, 14, + 225, 152, 33, 6, 70, 73, 78, 65, 76, 32, 25, 50, 87, 190, 160, 35, 65, 2, + 69, 2, 73, 3, 79, 14, 210, 136, 31, 65, 190, 202, 1, 79, 202, 61, 73, + 147, 249, 1, 69, 61, 92, 6, 45, 67, 82, 69, 69, 32, 150, 1, 65, 38, 79, + 30, 87, 230, 141, 33, 73, 231, 143, 2, 69, 24, 110, 80, 186, 207, 32, 67, + 2, 75, 2, 76, 2, 77, 2, 78, 2, 83, 2, 84, 2, 89, 130, 176, 2, 79, 247, + 30, 87, 4, 222, 165, 33, 87, 219, 217, 1, 79, 9, 162, 142, 33, 65, 231, + 143, 2, 89, 7, 226, 157, 35, 79, 3, 89, 14, 222, 133, 31, 65, 190, 202, + 1, 79, 202, 61, 73, 231, 143, 2, 69, 10, 26, 76, 239, 156, 35, 82, 9, 26, + 32, 247, 211, 9, 76, 4, 202, 129, 23, 67, 131, 172, 10, 84, 4, 214, 133, + 35, 76, 215, 22, 89, 4, 228, 242, 15, 3, 73, 84, 85, 157, 170, 8, 3, 82, + 73, 67, 126, 180, 1, 2, 68, 32, 102, 69, 72, 11, 73, 65, 78, 32, 76, 69, + 84, 84, 69, 82, 32, 210, 3, 79, 62, 80, 90, 82, 204, 184, 26, 6, 84, 69, + 83, 73, 65, 78, 201, 143, 2, 4, 32, 83, 76, 73, 6, 52, 5, 73, 78, 68, 69, + 88, 229, 138, 34, 2, 70, 73, 5, 225, 136, 34, 6, 32, 68, 73, 86, 73, 68, + 6, 26, 84, 235, 168, 22, 32, 5, 241, 187, 10, 6, 32, 73, 78, 83, 69, 82, + 98, 196, 1, 2, 67, 45, 38, 76, 22, 77, 50, 78, 38, 83, 46, 84, 22, 85, + 214, 240, 3, 65, 2, 68, 2, 69, 2, 71, 2, 75, 2, 80, 250, 201, 27, 82, + 170, 203, 1, 73, 230, 143, 2, 66, 2, 79, 2, 81, 3, 88, 4, 186, 230, 27, + 49, 143, 177, 3, 51, 7, 251, 241, 3, 68, 11, 11, 66, 9, 222, 150, 35, 50, + 2, 51, 3, 52, 9, 186, 150, 35, 68, 2, 71, 3, 78, 13, 146, 241, 3, 72, 2, + 84, 135, 165, 31, 83, 7, 231, 240, 3, 84, 13, 11, 85, 11, 11, 85, 9, 190, + 149, 35, 50, 2, 51, 3, 85, 4, 220, 137, 34, 6, 85, 83, 69, 76, 32, 72, + 191, 139, 1, 78, 4, 232, 177, 28, 6, 32, 83, 84, 82, 69, 65, 201, 228, 5, + 7, 69, 78, 84, 82, 89, 32, 83, 4, 150, 188, 28, 73, 199, 187, 6, 79, 9, + 29, 5, 32, 70, 65, 67, 69, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 208, 132, + 7, 2, 84, 69, 145, 226, 25, 6, 87, 82, 89, 32, 83, 77, 108, 88, 16, 67, + 65, 83, 73, 65, 78, 32, 65, 76, 66, 65, 78, 73, 65, 78, 32, 163, 135, 31, + 84, 106, 60, 7, 76, 69, 84, 84, 69, 82, 32, 181, 237, 28, 2, 67, 73, 104, + 170, 2, 65, 34, 67, 146, 1, 68, 78, 69, 34, 71, 46, 73, 46, 74, 34, 75, + 34, 76, 34, 80, 34, 83, 74, 84, 62, 89, 46, 90, 192, 186, 17, 2, 81, 65, + 142, 227, 6, 77, 236, 138, 9, 3, 86, 69, 89, 166, 33, 70, 196, 21, 3, 78, + 79, 87, 162, 33, 82, 186, 11, 88, 154, 46, 79, 202, 26, 66, 237, 24, 3, + 72, 69, 89, 4, 182, 214, 34, 79, 179, 28, 76, 16, 34, 65, 34, 72, 49, 2, + 89, 65, 4, 238, 190, 34, 89, 227, 79, 82, 8, 246, 159, 29, 65, 242, 220, + 5, 79, 203, 17, 73, 4, 254, 141, 35, 87, 3, 89, 8, 42, 90, 166, 190, 33, + 89, 235, 178, 1, 65, 4, 150, 255, 33, 89, 219, 124, 65, 4, 182, 189, 34, + 89, 227, 79, 66, 4, 144, 222, 33, 2, 72, 69, 143, 158, 1, 73, 6, 206, + 203, 33, 82, 158, 113, 87, 135, 77, 78, 4, 210, 253, 33, 72, 227, 16, 65, + 4, 222, 141, 34, 73, 199, 69, 65, 4, 254, 187, 34, 65, 171, 51, 89, 4, + 142, 1, 73, 211, 186, 34, 69, 8, 34, 72, 229, 135, 35, 2, 69, 89, 6, 170, + 128, 21, 65, 139, 249, 13, 79, 6, 38, 73, 146, 252, 33, 89, 199, 80, 65, + 2, 211, 209, 34, 87, 4, 248, 195, 34, 2, 65, 89, 1, 2, 79, 87, 6, 130, + 220, 16, 72, 195, 218, 4, 65, 16, 72, 2, 68, 73, 32, 2, 78, 84, 176, 158, + 33, 3, 76, 84, 73, 175, 84, 82, 4, 138, 130, 34, 32, 223, 100, 76, 8, 32, + 2, 82, 69, 203, 129, 34, 32, 6, 44, 5, 76, 73, 78, 69, 32, 255, 253, 4, + 32, 4, 218, 192, 22, 76, 207, 217, 10, 79, 130, 6, 102, 65, 170, 17, 69, + 162, 8, 73, 190, 2, 79, 184, 246, 13, 6, 82, 73, 83, 84, 77, 65, 211, + 184, 10, 85, 198, 2, 66, 73, 32, 4, 75, 77, 65, 32, 148, 6, 2, 77, 32, + 131, 8, 82, 4, 214, 200, 34, 78, 223, 61, 82, 142, 1, 156, 1, 7, 76, 69, + 84, 84, 69, 82, 32, 142, 3, 83, 98, 86, 194, 184, 24, 68, 230, 239, 7, + 81, 148, 96, 5, 77, 65, 65, 89, 89, 136, 183, 1, 2, 65, 85, 3, 79, 76, + 202, 1, 68, 54, 78, 54, 84, 54, 89, 190, 243, 29, 66, 2, 67, 2, 71, 2, + 74, 2, 75, 2, 76, 2, 80, 130, 150, 3, 72, 2, 77, 2, 82, 2, 83, 2, 86, 2, + 87, 150, 246, 1, 65, 186, 2, 69, 2, 73, 3, 85, 8, 214, 244, 29, 68, 130, + 150, 3, 72, 151, 246, 1, 65, 8, 162, 138, 33, 71, 2, 78, 2, 89, 151, 246, + 1, 65, 8, 238, 243, 29, 84, 130, 150, 3, 72, 151, 246, 1, 65, 4, 186, + 137, 33, 89, 151, 246, 1, 65, 8, 40, 4, 73, 71, 78, 32, 139, 228, 22, 69, + 6, 222, 221, 30, 67, 242, 229, 1, 86, 243, 248, 1, 65, 26, 64, 10, 79, + 87, 69, 76, 32, 83, 73, 71, 78, 32, 171, 192, 32, 73, 24, 218, 157, 31, + 65, 250, 6, 85, 138, 204, 1, 69, 2, 73, 3, 79, 166, 1, 236, 1, 15, 67, + 79, 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, 32, 112, 7, 76, 69, + 84, 84, 69, 82, 32, 152, 4, 12, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, + 78, 32, 60, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 171, 129, 33, + 68, 14, 72, 6, 70, 73, 78, 65, 76, 32, 138, 251, 34, 76, 2, 82, 2, 87, 3, + 89, 6, 234, 252, 34, 78, 86, 72, 3, 77, 104, 132, 2, 6, 70, 73, 78, 65, + 76, 32, 110, 78, 50, 77, 78, 80, 218, 248, 11, 66, 218, 187, 6, 68, 254, + 169, 12, 83, 158, 139, 2, 65, 164, 200, 1, 2, 67, 72, 2, 71, 2, 74, 2, + 75, 2, 84, 138, 69, 72, 2, 76, 2, 82, 2, 86, 2, 89, 186, 2, 69, 2, 73, 2, + 79, 3, 85, 22, 250, 249, 32, 78, 190, 195, 1, 83, 206, 60, 67, 146, 1, + 71, 2, 75, 2, 76, 2, 80, 2, 82, 2, 84, 3, 89, 14, 46, 71, 34, 72, 134, + 227, 34, 85, 215, 22, 65, 4, 162, 227, 34, 85, 215, 22, 65, 6, 130, 227, + 34, 85, 158, 20, 74, 187, 2, 65, 6, 242, 246, 34, 72, 2, 80, 187, 2, 65, + 8, 174, 193, 11, 83, 154, 210, 19, 68, 45, 4, 84, 82, 73, 80, 20, 182, + 156, 31, 65, 174, 204, 1, 73, 198, 207, 1, 79, 2, 85, 203, 44, 69, 14, + 72, 7, 65, 67, 84, 69, 82, 32, 84, 49, 7, 84, 32, 87, 73, 84, 72, 32, 8, + 252, 145, 10, 3, 65, 66, 85, 227, 206, 24, 73, 6, 128, 1, 13, 85, 80, 87, + 65, 82, 68, 83, 32, 84, 82, 69, 78, 68, 225, 146, 26, 12, 68, 79, 87, 78, + 87, 65, 82, 68, 83, 32, 84, 82, 5, 217, 140, 7, 6, 32, 65, 78, 68, 32, + 89, 236, 2, 80, 2, 67, 75, 82, 69, 90, 82, 128, 148, 5, 2, 83, 84, 169, + 228, 15, 2, 81, 85, 6, 56, 8, 69, 82, 32, 66, 79, 65, 82, 68, 139, 179, + 34, 32, 5, 227, 244, 31, 32, 4, 156, 165, 28, 4, 83, 69, 32, 87, 221, + 161, 5, 9, 82, 73, 78, 71, 32, 77, 69, 71, 65, 222, 2, 40, 5, 79, 75, 69, + 69, 32, 143, 5, 82, 216, 2, 46, 76, 1, 7, 83, 77, 65, 76, 76, 32, 76, + 172, 1, 33, 6, 69, 84, 84, 69, 82, 32, 172, 1, 170, 1, 68, 74, 72, 74, + 78, 70, 83, 62, 84, 54, 71, 2, 76, 2, 77, 0, 2, 81, 85, 2, 87, 2, 89, + 158, 236, 34, 75, 186, 2, 65, 2, 69, 2, 73, 2, 79, 2, 85, 3, 86, 14, 222, + 238, 34, 76, 186, 2, 65, 2, 69, 2, 73, 2, 79, 2, 85, 3, 86, 14, 150, 238, + 34, 78, 186, 2, 65, 2, 69, 2, 73, 2, 79, 2, 85, 3, 86, 14, 174, 217, 30, + 65, 218, 150, 4, 69, 2, 73, 2, 79, 2, 85, 3, 86, 15, 194, 239, 34, 65, 2, + 69, 2, 73, 2, 79, 2, 85, 3, 86, 30, 50, 76, 2, 83, 214, 238, 34, 65, 2, + 69, 3, 73, 12, 210, 238, 34, 65, 2, 69, 2, 73, 2, 79, 2, 85, 3, 86, 6, + 32, 2, 89, 32, 243, 215, 33, 73, 4, 40, 4, 66, 76, 79, 83, 159, 216, 33, + 83, 2, 227, 220, 34, 83, 16, 152, 1, 2, 76, 68, 48, 11, 78, 69, 83, 69, + 32, 83, 77, 65, 76, 76, 32, 202, 137, 8, 32, 244, 250, 2, 2, 80, 77, 152, + 142, 22, 2, 67, 75, 171, 137, 1, 82, 5, 193, 209, 29, 7, 82, 69, 78, 32, + 67, 82, 79, 4, 184, 181, 20, 10, 83, 73, 77, 80, 76, 73, 70, 73, 69, 68, + 1, 11, 84, 82, 65, 68, 73, 84, 73, 79, 78, 65, 76, 60, 92, 8, 82, 65, 83, + 77, 73, 65, 78, 32, 198, 153, 5, 80, 253, 192, 12, 5, 67, 79, 76, 65, 84, + 56, 52, 7, 76, 69, 84, 84, 69, 82, 32, 171, 172, 22, 78, 42, 224, 1, 6, + 67, 85, 82, 76, 69, 68, 30, 83, 130, 169, 22, 68, 34, 76, 158, 207, 1, + 82, 198, 221, 2, 65, 50, 71, 90, 90, 98, 89, 206, 209, 1, 72, 234, 5, 75, + 142, 81, 66, 138, 231, 4, 78, 134, 2, 84, 2, 87, 218, 103, 80, 171, 4, + 77, 2, 205, 233, 33, 2, 32, 87, 6, 232, 168, 22, 6, 77, 65, 76, 76, 32, + 65, 192, 248, 5, 2, 65, 77, 227, 198, 5, 72, 236, 4, 66, 78, 20, 2, 82, + 67, 145, 42, 7, 84, 89, 83, 67, 65, 80, 69, 2, 179, 197, 34, 69, 230, 4, + 28, 2, 76, 69, 151, 41, 85, 224, 4, 30, 32, 149, 7, 2, 68, 32, 26, 244, + 1, 5, 87, 73, 84, 72, 32, 157, 166, 19, 49, 68, 73, 86, 73, 68, 69, 68, + 32, 66, 89, 32, 72, 79, 82, 73, 90, 79, 78, 84, 65, 76, 32, 66, 65, 82, + 32, 65, 78, 68, 32, 84, 79, 80, 32, 72, 65, 76, 70, 32, 68, 73, 86, 73, + 68, 69, 68, 32, 66, 89, 24, 238, 2, 76, 46, 83, 108, 22, 84, 87, 79, 32, + 72, 79, 82, 73, 90, 79, 78, 84, 65, 76, 32, 83, 84, 82, 79, 75, 69, 83, + 44, 6, 85, 80, 80, 69, 82, 32, 44, 17, 65, 76, 76, 32, 66, 85, 84, 32, + 85, 80, 80, 69, 82, 32, 76, 69, 70, 248, 241, 4, 19, 68, 79, 85, 66, 76, + 69, 32, 86, 69, 82, 84, 73, 67, 65, 76, 32, 65, 78, 68, 174, 181, 22, 86, + 174, 148, 4, 82, 243, 254, 1, 72, 4, 178, 189, 31, 69, 49, 4, 79, 87, 69, + 82, 4, 104, 11, 77, 65, 76, 76, 32, 67, 73, 82, 67, 76, 69, 201, 6, 10, + 85, 80, 69, 82, 73, 77, 80, 79, 83, 69, 2, 133, 215, 31, 6, 32, 84, 79, + 32, 84, 72, 4, 40, 4, 82, 73, 71, 72, 139, 188, 31, 72, 2, 157, 188, 31, + 10, 84, 32, 81, 85, 65, 68, 82, 65, 78, 84, 198, 4, 234, 2, 65, 178, 1, + 66, 170, 1, 67, 230, 1, 68, 246, 1, 72, 230, 2, 73, 194, 10, 75, 190, 2, + 76, 38, 77, 136, 1, 7, 78, 85, 77, 66, 69, 82, 32, 192, 4, 17, 79, 80, + 69, 78, 32, 67, 69, 78, 84, 82, 69, 32, 69, 73, 71, 72, 84, 54, 80, 114, + 82, 50, 84, 78, 87, 244, 149, 10, 4, 90, 69, 82, 79, 222, 139, 17, 69, + 250, 189, 4, 86, 238, 68, 71, 246, 117, 83, 163, 163, 1, 88, 6, 100, 12, + 78, 84, 73, 67, 76, 79, 67, 75, 87, 73, 83, 69, 193, 146, 31, 7, 83, 84, + 69, 82, 73, 83, 75, 4, 236, 149, 14, 9, 45, 82, 79, 84, 65, 84, 69, 68, + 32, 139, 168, 19, 32, 6, 26, 79, 239, 244, 32, 85, 4, 118, 76, 133, 212, + 30, 23, 84, 84, 79, 77, 32, 82, 73, 71, 72, 84, 32, 79, 66, 76, 73, 81, + 85, 69, 32, 72, 65, 76, 70, 2, 199, 142, 15, 68, 16, 60, 4, 82, 79, 83, + 83, 210, 2, 32, 254, 213, 34, 67, 3, 68, 10, 26, 32, 139, 195, 1, 73, 8, + 64, 6, 70, 79, 82, 77, 69, 69, 181, 226, 32, 4, 80, 79, 77, 77, 7, 33, 6, + 32, 87, 73, 84, 72, 32, 4, 158, 173, 32, 70, 171, 84, 84, 30, 34, 73, 70, + 79, 163, 232, 32, 65, 24, 184, 212, 4, 8, 86, 73, 83, 73, 79, 78, 32, 83, + 195, 139, 28, 71, 4, 64, 10, 76, 76, 65, 82, 32, 83, 73, 71, 78, 32, 195, + 141, 31, 84, 2, 165, 130, 20, 13, 87, 73, 84, 72, 32, 79, 86, 69, 82, 76, + 65, 73, 68, 64, 192, 1, 6, 65, 78, 71, 85, 76, 32, 132, 233, 12, 20, 79, + 82, 73, 90, 79, 78, 84, 65, 76, 32, 66, 65, 82, 32, 87, 73, 84, 72, 32, + 78, 180, 145, 10, 4, 85, 77, 65, 78, 145, 1, 4, 69, 65, 86, 89, 58, 110, + 67, 148, 163, 21, 5, 73, 69, 85, 78, 71, 42, 72, 30, 75, 66, 77, 34, 78, + 34, 80, 62, 82, 30, 83, 27, 84, 8, 242, 162, 21, 72, 157, 3, 4, 73, 69, + 85, 67, 116, 220, 1, 9, 68, 69, 79, 71, 82, 65, 80, 72, 32, 196, 8, 27, + 84, 65, 76, 73, 67, 32, 76, 65, 84, 73, 78, 32, 67, 65, 80, 73, 84, 65, + 76, 32, 76, 69, 84, 84, 69, 82, 32, 157, 251, 27, 9, 78, 70, 79, 82, 77, + 65, 84, 73, 79, 110, 174, 1, 65, 110, 67, 90, 69, 86, 70, 62, 72, 38, 75, + 70, 76, 50, 77, 86, 78, 62, 81, 30, 82, 74, 83, 186, 195, 6, 80, 182, + 224, 14, 84, 50, 87, 178, 216, 1, 73, 231, 177, 10, 79, 8, 250, 163, 21, + 76, 192, 134, 1, 3, 67, 67, 69, 132, 254, 6, 3, 84, 84, 69, 241, 17, 5, + 68, 86, 65, 78, 84, 8, 26, 79, 163, 197, 31, 69, 6, 220, 232, 10, 2, 82, + 82, 214, 186, 10, 78, 191, 153, 13, 80, 8, 198, 163, 21, 78, 234, 184, 9, + 65, 164, 174, 3, 5, 88, 67, 69, 76, 76, 231, 24, 73, 10, 210, 163, 21, + 73, 244, 192, 5, 2, 69, 77, 143, 240, 6, 79, 4, 218, 153, 30, 73, 191, + 182, 3, 65, 4, 148, 183, 7, 8, 73, 78, 68, 69, 82, 71, 65, 82, 175, 157, + 23, 79, 6, 226, 162, 21, 65, 130, 171, 12, 79, 195, 83, 69, 8, 38, 69, + 178, 164, 33, 65, 147, 87, 79, 4, 236, 175, 33, 3, 68, 73, 67, 227, 15, + 84, 6, 26, 73, 247, 176, 33, 65, 4, 170, 160, 34, 71, 231, 19, 78, 2, + 181, 169, 29, 2, 85, 69, 8, 26, 69, 203, 159, 34, 73, 6, 234, 161, 21, + 83, 157, 141, 8, 2, 76, 73, 22, 90, 69, 38, 85, 160, 210, 14, 2, 67, 72, + 162, 207, 6, 79, 22, 80, 34, 84, 175, 152, 12, 73, 4, 214, 183, 10, 67, + 155, 184, 22, 86, 6, 190, 162, 21, 80, 166, 129, 2, 73, 255, 164, 11, 78, + 4, 170, 200, 34, 67, 3, 82, 98, 116, 8, 65, 84, 65, 75, 65, 78, 65, 32, + 133, 1, 16, 79, 82, 69, 65, 78, 32, 67, 72, 65, 82, 65, 67, 84, 69, 82, + 32, 94, 242, 134, 11, 72, 2, 75, 2, 77, 2, 78, 2, 82, 2, 83, 2, 84, 98, + 87, 46, 89, 154, 191, 23, 65, 2, 69, 2, 73, 2, 79, 3, 85, 4, 236, 208, + 16, 3, 74, 85, 69, 165, 214, 17, 4, 67, 72, 65, 77, 106, 170, 157, 28, + 65, 199, 143, 4, 69, 4, 100, 19, 85, 76, 84, 73, 80, 76, 73, 67, 65, 84, + 73, 79, 78, 32, 83, 73, 71, 78, 32, 195, 184, 32, 73, 2, 193, 82, 4, 87, + 73, 84, 72, 98, 50, 69, 46, 70, 98, 83, 94, 84, 155, 158, 21, 78, 6, 180, + 1, 3, 73, 71, 72, 175, 152, 26, 76, 30, 28, 3, 73, 70, 84, 35, 79, 6, + 214, 1, 89, 191, 232, 32, 69, 24, 142, 2, 82, 131, 158, 21, 85, 8, 40, 4, + 69, 86, 69, 78, 1, 2, 73, 88, 4, 11, 84, 4, 104, 2, 89, 32, 179, 232, 32, + 69, 52, 56, 2, 69, 78, 32, 4, 72, 73, 82, 84, 29, 2, 87, 69, 5, 11, 32, + 2, 247, 181, 26, 79, 24, 74, 89, 211, 231, 32, 69, 24, 26, 78, 167, 196, + 33, 76, 22, 17, 2, 84, 89, 23, 11, 32, 20, 72, 2, 79, 78, 234, 201, 32, + 70, 30, 83, 42, 84, 166, 90, 78, 239, 112, 69, 4, 210, 180, 26, 32, 187, + 139, 8, 69, 2, 213, 162, 32, 8, 32, 80, 79, 73, 78, 84, 69, 68, 8, 232, + 167, 18, 3, 79, 83, 84, 198, 132, 7, 65, 224, 205, 2, 8, 69, 82, 80, 69, + 78, 68, 73, 67, 171, 185, 4, 76, 4, 132, 246, 30, 3, 73, 78, 71, 251, + 171, 1, 69, 6, 52, 7, 82, 73, 65, 78, 71, 76, 69, 131, 160, 27, 73, 5, + 195, 251, 22, 32, 6, 44, 5, 72, 73, 84, 69, 32, 155, 189, 34, 90, 4, 222, + 215, 32, 66, 247, 25, 83, 6, 130, 145, 28, 77, 236, 192, 4, 6, 76, 65, + 84, 73, 79, 78, 225, 167, 1, 3, 83, 32, 84, 5, 165, 242, 32, 6, 32, 65, + 84, 32, 68, 85, 178, 2, 80, 8, 82, 65, 68, 73, 67, 65, 76, 32, 245, 17, + 7, 83, 84, 82, 79, 75, 69, 32, 230, 1, 210, 1, 66, 126, 67, 226, 4, 68, + 62, 69, 50, 70, 34, 71, 50, 72, 86, 74, 154, 1, 76, 62, 77, 130, 1, 80, + 46, 82, 78, 83, 182, 3, 84, 82, 87, 212, 255, 10, 2, 78, 69, 208, 13, 4, + 75, 78, 73, 70, 211, 229, 12, 79, 14, 74, 79, 160, 156, 11, 4, 82, 85, + 83, 72, 134, 146, 5, 65, 175, 245, 13, 76, 6, 166, 197, 10, 76, 254, 220, + 23, 78, 215, 22, 88, 56, 104, 12, 45, 83, 73, 77, 80, 76, 73, 70, 73, 69, + 68, 32, 162, 3, 73, 50, 76, 238, 181, 33, 79, 191, 78, 72, 44, 114, 69, + 38, 70, 50, 71, 38, 76, 34, 83, 94, 84, 246, 142, 15, 87, 42, 68, 222, + 157, 17, 66, 194, 124, 72, 163, 4, 67, 4, 210, 221, 32, 86, 235, 188, 1, + 65, 6, 162, 200, 32, 73, 218, 220, 1, 76, 235, 16, 82, 4, 254, 254, 23, + 79, 139, 235, 8, 65, 4, 190, 180, 33, 69, 187, 48, 79, 10, 230, 250, 6, + 73, 198, 141, 18, 65, 182, 194, 1, 72, 200, 200, 7, 3, 80, 69, 69, 215, + 11, 69, 6, 214, 10, 85, 132, 212, 10, 2, 65, 78, 187, 194, 4, 79, 4, 140, + 189, 21, 3, 86, 73, 76, 231, 229, 12, 84, 4, 174, 200, 18, 73, 195, 213, + 14, 79, 6, 232, 135, 25, 2, 73, 86, 218, 242, 2, 69, 211, 184, 6, 79, 10, + 196, 6, 2, 65, 84, 146, 150, 34, 87, 3, 89, 4, 254, 143, 33, 73, 199, 82, + 79, 8, 244, 5, 4, 82, 65, 83, 83, 247, 185, 30, 72, 10, 48, 2, 69, 65, + 150, 153, 29, 79, 211, 136, 4, 65, 6, 186, 8, 82, 191, 169, 34, 68, 10, + 72, 12, 45, 83, 73, 77, 80, 76, 73, 70, 73, 69, 68, 32, 251, 154, 32, 65, + 8, 42, 84, 138, 139, 15, 68, 235, 175, 17, 69, 4, 194, 6, 85, 191, 150, + 15, 79, 12, 228, 147, 11, 3, 79, 78, 71, 221, 200, 16, 3, 65, 77, 69, 14, + 18, 69, 35, 79, 4, 194, 147, 34, 65, 159, 27, 83, 10, 244, 146, 11, 3, + 85, 78, 68, 202, 243, 13, 84, 206, 221, 7, 82, 231, 123, 79, 6, 168, 146, + 11, 2, 65, 87, 243, 146, 19, 69, 8, 34, 65, 249, 164, 33, 2, 69, 80, 6, + 210, 222, 33, 73, 226, 79, 77, 3, 80, 38, 122, 69, 90, 73, 186, 1, 78, + 196, 1, 4, 80, 73, 82, 73, 228, 140, 11, 4, 77, 65, 76, 76, 174, 227, 12, + 72, 207, 233, 9, 85, 8, 40, 4, 67, 79, 78, 68, 151, 161, 33, 65, 6, 11, + 32, 6, 246, 182, 32, 84, 179, 90, 79, 12, 60, 9, 77, 80, 76, 73, 70, 73, + 69, 68, 32, 227, 168, 34, 76, 10, 34, 72, 50, 87, 243, 217, 10, 89, 4, + 248, 195, 10, 3, 65, 76, 70, 247, 206, 18, 79, 4, 186, 240, 6, 65, 175, + 177, 26, 72, 6, 192, 1, 2, 79, 85, 231, 249, 33, 65, 8, 58, 85, 142, 204, + 25, 65, 238, 206, 1, 72, 143, 185, 3, 73, 2, 255, 249, 24, 82, 12, 26, + 65, 49, 2, 69, 83, 8, 144, 141, 11, 2, 76, 75, 1, 3, 84, 69, 82, 4, 227, + 140, 11, 84, 76, 110, 72, 182, 1, 80, 38, 83, 222, 165, 32, 84, 176, 128, + 2, 2, 66, 88, 2, 87, 2, 88, 86, 68, 2, 78, 3, 81, 31, 42, 80, 22, 88, 30, + 90, 223, 167, 34, 71, 5, 183, 167, 34, 87, 4, 162, 167, 34, 87, 87, 71, + 19, 50, 90, 146, 166, 32, 87, 154, 129, 2, 71, 3, 84, 9, 142, 166, 32, + 90, 155, 129, 2, 80, 9, 130, 167, 34, 68, 2, 71, 3, 90, 23, 50, 87, 30, + 90, 146, 166, 34, 71, 2, 80, 3, 84, 7, 170, 166, 34, 71, 3, 90, 9, 186, + 165, 34, 87, 86, 80, 3, 90, 124, 62, 65, 194, 1, 73, 114, 79, 209, 220, + 21, 4, 69, 65, 82, 32, 8, 132, 1, 2, 80, 80, 216, 240, 3, 6, 83, 83, 73, + 67, 65, 76, 157, 134, 29, 14, 77, 83, 72, 69, 76, 76, 32, 77, 79, 66, 73, + 76, 69, 32, 4, 224, 167, 20, 5, 73, 78, 71, 32, 72, 183, 229, 1, 69, 6, + 48, 6, 78, 75, 73, 78, 71, 32, 171, 138, 33, 80, 4, 154, 132, 26, 71, + 133, 191, 3, 6, 66, 69, 69, 82, 32, 77, 108, 72, 2, 67, 75, 140, 10, 2, + 83, 69, 236, 3, 2, 85, 68, 135, 154, 31, 87, 70, 64, 6, 32, 70, 65, 67, + 69, 32, 237, 2, 5, 87, 73, 83, 69, 32, 48, 58, 69, 46, 70, 36, 2, 78, 73, + 2, 79, 18, 83, 51, 84, 8, 120, 2, 76, 69, 125, 4, 73, 71, 72, 84, 8, 178, + 1, 73, 25, 3, 79, 85, 82, 4, 155, 1, 78, 8, 26, 69, 125, 2, 73, 88, 4, + 57, 2, 86, 69, 16, 38, 69, 14, 87, 41, 3, 72, 82, 69, 4, 63, 78, 8, 24, + 2, 69, 76, 27, 79, 4, 11, 86, 4, 11, 69, 4, 248, 245, 29, 2, 32, 79, 149, + 182, 2, 3, 45, 84, 72, 22, 90, 67, 58, 68, 122, 71, 48, 5, 82, 73, 71, + 72, 84, 226, 2, 84, 122, 79, 219, 139, 32, 73, 4, 196, 1, 3, 76, 79, 83, + 233, 104, 4, 79, 78, 84, 79, 2, 141, 3, 26, 79, 87, 78, 87, 65, 82, 68, + 83, 32, 65, 78, 68, 32, 85, 80, 87, 65, 82, 68, 83, 32, 79, 80, 69, 78, + 32, 2, 21, 3, 65, 80, 80, 2, 133, 4, 2, 69, 68, 6, 228, 1, 14, 32, 65, + 78, 68, 32, 76, 69, 70, 84, 32, 83, 69, 77, 73, 45, 38, 87, 65, 82, 68, + 83, 32, 65, 78, 68, 32, 76, 69, 70, 84, 87, 65, 82, 68, 83, 32, 79, 80, + 69, 78, 32, 67, 73, 82, 67, 76, 69, 32, 65, 82, 82, 79, 87, 83, 2, 189, + 183, 31, 6, 67, 73, 82, 67, 76, 69, 5, 225, 86, 15, 32, 87, 73, 84, 72, + 32, 67, 73, 82, 67, 76, 69, 68, 32, 79, 4, 82, 79, 37, 16, 82, 73, 65, + 78, 71, 76, 69, 45, 72, 69, 65, 68, 69, 68, 32, 79, 2, 69, 6, 80, 32, 83, + 69, 77, 73, 2, 21, 3, 80, 69, 78, 2, 11, 32, 2, 221, 181, 31, 4, 67, 73, + 82, 67, 26, 32, 2, 68, 32, 143, 162, 33, 32, 24, 216, 1, 2, 83, 85, 66, + 85, 206, 153, 20, 77, 180, 3, 9, 76, 79, 67, 75, 32, 87, 73, 84, 72, 230, + 159, 12, 66, 165, 155, 1, 23, 73, 78, 84, 69, 82, 83, 69, 67, 84, 73, 79, + 78, 32, 87, 73, 84, 72, 32, 83, 69, 82, 73, 70, 8, 30, 66, 1, 3, 80, 69, + 82, 4, 157, 239, 25, 3, 83, 69, 84, 6, 82, 77, 33, 16, 78, 73, 79, 78, + 32, 87, 73, 84, 72, 32, 83, 69, 82, 73, 70, 83, 2, 141, 210, 25, 3, 66, + 82, 69, 5, 161, 131, 33, 9, 32, 65, 78, 68, 32, 83, 77, 65, 83, 11, 33, + 6, 32, 87, 73, 84, 72, 32, 8, 72, 4, 84, 79, 82, 78, 138, 193, 5, 76, + 154, 182, 20, 83, 131, 237, 6, 82, 2, 207, 204, 26, 65, 170, 10, 158, 1, + 67, 82, 76, 98, 77, 254, 87, 78, 220, 5, 2, 79, 75, 58, 80, 142, 19, 82, + 138, 1, 85, 150, 241, 28, 87, 212, 173, 3, 2, 70, 70, 246, 47, 73, 183, + 51, 65, 6, 26, 75, 163, 178, 4, 79, 4, 254, 136, 9, 82, 153, 239, 23, 4, + 84, 65, 73, 76, 8, 44, 2, 79, 78, 165, 249, 25, 3, 76, 73, 83, 7, 11, 32, + 4, 138, 245, 26, 69, 147, 149, 6, 83, 230, 6, 72, 7, 66, 73, 78, 73, 78, + 71, 32, 234, 85, 77, 118, 80, 139, 157, 33, 69, 210, 6, 210, 2, 65, 174, + 2, 66, 118, 67, 158, 13, 68, 182, 11, 69, 142, 2, 70, 50, 71, 172, 9, 2, + 72, 79, 82, 73, 248, 1, 2, 75, 65, 162, 1, 76, 146, 14, 77, 178, 2, 78, + 78, 79, 142, 2, 80, 182, 1, 82, 248, 4, 5, 90, 73, 71, 90, 65, 138, 2, + 83, 162, 4, 84, 238, 2, 85, 168, 1, 8, 86, 69, 82, 84, 73, 67, 65, 76, + 132, 2, 2, 87, 73, 171, 1, 88, 26, 148, 1, 4, 67, 85, 84, 69, 86, 78, + 128, 247, 25, 6, 83, 84, 69, 82, 73, 83, 153, 239, 5, 14, 76, 77, 79, 83, + 84, 32, 69, 81, 85, 65, 76, 32, 84, 79, 12, 22, 45, 195, 35, 32, 6, 154, + 58, 86, 200, 21, 4, 71, 82, 65, 86, 143, 151, 16, 77, 6, 136, 3, 4, 84, + 73, 67, 76, 173, 207, 3, 4, 78, 85, 73, 84, 12, 42, 82, 205, 213, 31, 4, + 73, 78, 68, 85, 10, 32, 3, 69, 86, 69, 235, 38, 73, 7, 222, 215, 12, 45, + 215, 253, 18, 32, 144, 1, 134, 1, 65, 78, 76, 98, 79, 116, 8, 89, 82, 73, + 76, 76, 73, 67, 32, 216, 17, 9, 73, 82, 67, 85, 77, 70, 76, 69, 88, 183, + 214, 12, 69, 8, 36, 3, 82, 79, 78, 167, 229, 29, 78, 7, 210, 128, 13, 45, + 139, 211, 18, 32, 4, 41, 8, 79, 67, 75, 87, 73, 83, 69, 32, 4, 220, 222, + 12, 4, 82, 73, 78, 71, 131, 166, 17, 65, 10, 76, 4, 77, 77, 65, 32, 221, + 18, 10, 78, 74, 79, 73, 78, 73, 78, 71, 32, 77, 6, 214, 213, 13, 65, 175, + 140, 18, 66, 116, 252, 1, 8, 72, 85, 78, 68, 82, 69, 68, 32, 32, 7, 76, + 69, 84, 84, 69, 82, 32, 166, 5, 80, 116, 5, 68, 65, 83, 73, 65, 42, 84, + 106, 77, 174, 143, 3, 75, 180, 186, 13, 15, 83, 77, 65, 76, 76, 32, 76, + 69, 84, 84, 69, 82, 32, 66, 89, 161, 254, 16, 2, 86, 90, 4, 198, 7, 77, + 179, 186, 3, 84, 84, 238, 1, 66, 38, 68, 50, 69, 82, 73, 106, 79, 22, 83, + 66, 85, 30, 89, 174, 165, 3, 76, 140, 5, 5, 77, 79, 78, 79, 71, 150, 18, + 72, 254, 146, 13, 84, 250, 175, 16, 90, 150, 83, 67, 2, 71, 182, 8, 70, + 134, 14, 80, 2, 86, 158, 20, 75, 187, 2, 65, 4, 186, 193, 6, 73, 163, + 193, 27, 69, 4, 236, 222, 26, 3, 74, 69, 82, 203, 163, 7, 69, 14, 58, 83, + 206, 129, 34, 70, 2, 76, 2, 77, 2, 78, 3, 82, 5, 191, 181, 32, 45, 11, + 56, 8, 79, 84, 73, 70, 73, 69, 68, 32, 255, 128, 34, 69, 6, 206, 191, 6, + 66, 174, 193, 27, 65, 3, 69, 5, 147, 180, 26, 77, 6, 26, 72, 175, 209, + 16, 79, 4, 222, 255, 31, 67, 195, 128, 2, 65, 5, 161, 181, 3, 2, 75, 82, + 8, 246, 183, 29, 69, 190, 171, 4, 65, 174, 28, 73, 3, 85, 8, 66, 65, 48, + 4, 83, 73, 76, 73, 161, 196, 30, 4, 79, 75, 82, 89, 4, 142, 146, 3, 89, + 165, 146, 13, 3, 76, 65, 84, 2, 173, 144, 18, 5, 32, 80, 78, 69, 85, 10, + 80, 2, 69, 78, 0, 7, 72, 79, 85, 83, 65, 78, 68, 193, 10, 4, 73, 84, 76, + 79, 2, 17, 2, 32, 77, 2, 201, 215, 22, 5, 73, 76, 76, 73, 79, 132, 1, 66, + 69, 244, 1, 8, 73, 65, 69, 82, 69, 83, 73, 83, 131, 1, 79, 38, 68, 9, 86, + 65, 78, 65, 71, 65, 82, 73, 32, 197, 146, 33, 2, 76, 69, 36, 92, 7, 76, + 69, 84, 84, 69, 82, 32, 204, 248, 26, 6, 83, 73, 71, 78, 32, 65, 163, + 139, 5, 68, 14, 178, 231, 33, 86, 162, 17, 75, 2, 78, 2, 80, 2, 82, 186, + 2, 65, 3, 85, 9, 26, 32, 251, 222, 28, 45, 4, 150, 213, 31, 66, 221, 145, + 1, 16, 87, 73, 84, 72, 32, 82, 65, 73, 83, 69, 68, 32, 76, 69, 70, 84, + 86, 58, 84, 192, 1, 4, 85, 66, 76, 69, 221, 5, 2, 87, 78, 18, 54, 32, 88, + 2, 45, 65, 153, 214, 16, 3, 84, 69, 68, 10, 64, 5, 65, 66, 79, 86, 69, + 145, 210, 6, 5, 66, 69, 76, 79, 87, 7, 135, 205, 33, 32, 4, 176, 211, 10, + 3, 78, 68, 45, 143, 153, 16, 67, 62, 22, 32, 171, 5, 68, 60, 230, 1, 65, + 36, 4, 71, 82, 65, 86, 38, 66, 0, 10, 73, 78, 86, 69, 82, 84, 69, 68, 32, + 66, 26, 67, 50, 77, 42, 79, 34, 80, 68, 2, 82, 73, 48, 5, 84, 73, 76, 68, + 69, 80, 9, 86, 69, 82, 84, 73, 67, 65, 76, 32, 251, 170, 21, 76, 8, 32, + 3, 67, 85, 84, 235, 17, 82, 4, 11, 69, 4, 229, 12, 2, 32, 65, 4, 145, 17, + 2, 82, 69, 6, 174, 172, 16, 79, 194, 160, 16, 65, 199, 42, 73, 4, 141, + 212, 17, 5, 65, 67, 82, 79, 78, 4, 254, 36, 80, 183, 225, 31, 86, 6, 134, + 38, 76, 129, 253, 7, 9, 65, 82, 69, 78, 84, 72, 69, 83, 69, 6, 228, 52, + 4, 71, 72, 84, 87, 155, 154, 10, 78, 7, 11, 32, 4, 44, 3, 76, 69, 70, 1, + 4, 82, 73, 71, 72, 2, 235, 202, 31, 84, 6, 194, 200, 12, 83, 167, 242, + 14, 76, 2, 221, 203, 16, 2, 32, 67, 6, 254, 50, 32, 223, 156, 32, 87, 18, + 72, 9, 78, 67, 76, 79, 83, 73, 78, 71, 32, 165, 35, 4, 81, 85, 65, 76, + 14, 132, 1, 6, 67, 73, 82, 67, 76, 69, 22, 83, 224, 189, 6, 3, 75, 69, + 89, 160, 161, 20, 7, 85, 80, 87, 65, 82, 68, 32, 231, 206, 5, 68, 5, 171, + 156, 19, 32, 4, 194, 203, 26, 67, 139, 129, 6, 81, 6, 218, 165, 5, 79, + 230, 200, 12, 76, 239, 18, 69, 130, 1, 88, 17, 76, 65, 71, 79, 76, 73, + 84, 73, 67, 32, 76, 69, 84, 84, 69, 82, 32, 143, 3, 82, 76, 238, 1, 68, + 30, 73, 46, 83, 50, 84, 186, 166, 6, 65, 22, 66, 94, 67, 134, 1, 70, 38, + 71, 238, 2, 77, 32, 2, 76, 74, 34, 78, 88, 2, 80, 79, 30, 82, 194, 2, 86, + 22, 89, 90, 90, 158, 216, 19, 72, 154, 135, 2, 85, 130, 183, 5, 79, 235, + 5, 75, 4, 242, 168, 6, 74, 31, 79, 11, 254, 169, 6, 78, 54, 79, 227, 148, + 27, 90, 8, 222, 170, 6, 77, 130, 4, 76, 239, 162, 23, 72, 4, 146, 175, 6, + 86, 219, 168, 27, 83, 54, 38, 65, 201, 3, 4, 69, 69, 75, 32, 40, 84, 5, + 78, 84, 72, 65, 32, 196, 1, 2, 86, 69, 245, 179, 29, 5, 80, 72, 69, 77, + 69, 24, 68, 6, 68, 73, 71, 73, 84, 32, 65, 7, 76, 69, 84, 84, 69, 82, 32, + 14, 158, 190, 17, 83, 150, 181, 14, 70, 70, 84, 62, 90, 247, 89, 79, 10, + 190, 213, 33, 86, 162, 17, 75, 2, 78, 2, 80, 187, 2, 65, 14, 18, 32, 67, + 45, 6, 26, 65, 187, 250, 16, 84, 4, 145, 172, 4, 4, 67, 67, 69, 78, 8, + 154, 22, 86, 200, 159, 12, 6, 65, 67, 85, 84, 69, 45, 142, 141, 4, 77, + 227, 212, 16, 68, 14, 148, 1, 8, 77, 85, 83, 73, 67, 65, 76, 32, 150, + 179, 4, 75, 222, 197, 2, 80, 174, 4, 89, 137, 241, 3, 11, 68, 73, 65, 76, + 89, 84, 73, 75, 65, 32, 84, 6, 26, 84, 243, 130, 16, 80, 4, 202, 131, 16, + 69, 35, 82, 6, 134, 182, 13, 79, 212, 178, 19, 8, 77, 79, 84, 72, 69, 84, + 73, 67, 167, 45, 82, 16, 26, 78, 227, 175, 31, 83, 14, 52, 7, 86, 69, 82, + 84, 69, 68, 32, 207, 173, 29, 70, 12, 60, 2, 66, 82, 69, 9, 68, 79, 85, + 66, 76, 69, 32, 65, 82, 8, 18, 69, 23, 73, 4, 135, 138, 12, 86, 4, 145, + 190, 31, 2, 68, 71, 4, 11, 67, 4, 247, 189, 31, 72, 8, 128, 1, 16, 84, + 65, 75, 65, 78, 65, 45, 72, 73, 82, 65, 71, 65, 78, 65, 32, 213, 213, 18, + 9, 86, 89, 75, 65, 32, 65, 66, 79, 86, 4, 182, 164, 10, 83, 35, 86, 162, + 1, 80, 5, 65, 84, 73, 78, 32, 152, 8, 3, 69, 70, 84, 232, 3, 2, 73, 71, + 83, 79, 106, 156, 1, 21, 76, 69, 84, 84, 69, 82, 32, 83, 77, 65, 76, 76, + 32, 67, 65, 80, 73, 84, 65, 76, 32, 53, 13, 83, 77, 65, 76, 76, 32, 76, + 69, 84, 84, 69, 82, 32, 10, 254, 223, 33, 71, 2, 76, 2, 77, 2, 78, 3, 82, + 96, 226, 1, 65, 70, 67, 22, 69, 30, 70, 78, 73, 86, 76, 106, 79, 2, 85, + 134, 1, 82, 50, 84, 194, 225, 12, 83, 198, 162, 2, 66, 146, 181, 2, 87, + 166, 160, 16, 68, 2, 71, 2, 72, 2, 75, 2, 77, 2, 78, 2, 80, 2, 86, 2, 88, + 3, 90, 13, 162, 141, 3, 32, 206, 239, 26, 76, 250, 224, 3, 69, 2, 79, 3, + 86, 5, 139, 227, 11, 32, 7, 254, 219, 33, 83, 3, 84, 5, 229, 171, 28, 14, 76, 65, 84, 84, 69, 78, 69, 68, 32, 79, 80, 69, 78, 32, 11, 37, 7, 78, - 83, 85, 76, 65, 82, 32, 8, 222, 237, 32, 68, 2, 71, 2, 82, 3, 84, 7, 148, - 143, 16, 14, 32, 87, 73, 84, 72, 32, 68, 79, 85, 66, 76, 69, 32, 77, 185, - 228, 12, 3, 79, 78, 71, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 146, 159, - 12, 68, 133, 229, 12, 15, 76, 73, 71, 72, 84, 32, 67, 69, 78, 84, 82, 65, - 76, 73, 90, 7, 11, 32, 4, 210, 253, 11, 82, 255, 203, 18, 66, 5, 253, - 185, 30, 7, 85, 82, 78, 69, 68, 32, 87, 36, 46, 32, 133, 3, 6, 87, 65, + 83, 85, 76, 65, 82, 32, 8, 254, 219, 33, 68, 2, 71, 2, 82, 3, 84, 7, 200, + 210, 16, 14, 32, 87, 73, 84, 72, 32, 68, 79, 85, 66, 76, 69, 32, 77, 237, + 137, 13, 3, 79, 78, 71, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 146, 208, + 12, 68, 221, 154, 13, 15, 76, 73, 71, 72, 84, 32, 67, 69, 78, 84, 82, 65, + 76, 73, 90, 7, 11, 32, 4, 182, 171, 12, 82, 155, 137, 19, 66, 5, 161, + 164, 31, 7, 85, 82, 78, 69, 68, 32, 87, 36, 46, 32, 133, 3, 6, 87, 65, 82, 68, 83, 32, 32, 122, 65, 192, 1, 12, 80, 65, 82, 69, 78, 84, 72, 69, - 83, 73, 83, 32, 166, 13, 72, 154, 10, 84, 57, 5, 82, 73, 71, 72, 84, 14, - 52, 5, 78, 71, 76, 69, 32, 77, 4, 82, 82, 79, 87, 6, 140, 253, 3, 6, 67, - 69, 78, 84, 82, 69, 138, 202, 26, 66, 131, 165, 1, 65, 8, 26, 72, 151, - 198, 30, 32, 4, 133, 198, 30, 3, 69, 65, 68, 4, 220, 227, 7, 4, 65, 66, - 79, 86, 217, 209, 24, 5, 66, 69, 76, 79, 87, 4, 142, 14, 72, 245, 240, - 11, 5, 65, 82, 82, 79, 87, 10, 52, 6, 65, 84, 85, 82, 69, 32, 129, 18, 2, - 72, 84, 8, 234, 1, 76, 23, 82, 10, 36, 3, 78, 71, 32, 183, 202, 31, 87, - 8, 236, 7, 7, 68, 79, 85, 66, 76, 69, 32, 242, 7, 83, 71, 86, 26, 48, 5, - 65, 67, 82, 79, 78, 205, 5, 2, 73, 78, 23, 18, 32, 127, 45, 10, 34, 76, - 22, 82, 223, 194, 30, 66, 4, 41, 2, 69, 70, 4, 21, 3, 73, 71, 72, 4, 189, - 221, 16, 6, 84, 32, 72, 65, 76, 70, 10, 54, 86, 250, 20, 65, 150, 140, - 12, 71, 235, 176, 3, 66, 2, 129, 200, 31, 8, 69, 82, 84, 73, 67, 65, 76, - 45, 4, 164, 9, 9, 85, 77, 66, 69, 82, 32, 83, 73, 71, 129, 215, 11, 2, + 83, 73, 83, 32, 170, 13, 72, 154, 10, 84, 57, 5, 82, 73, 71, 72, 84, 14, + 52, 5, 78, 71, 76, 69, 32, 77, 4, 82, 82, 79, 87, 6, 172, 149, 4, 6, 67, + 69, 78, 84, 82, 69, 234, 156, 27, 66, 163, 168, 1, 65, 8, 26, 72, 151, + 177, 31, 32, 4, 133, 177, 31, 3, 69, 65, 68, 4, 228, 251, 7, 4, 65, 66, + 79, 86, 241, 167, 25, 5, 66, 69, 76, 79, 87, 4, 146, 14, 72, 141, 158, + 12, 5, 65, 82, 82, 79, 87, 10, 52, 6, 65, 84, 85, 82, 69, 32, 133, 18, 2, + 72, 84, 8, 234, 1, 76, 23, 82, 10, 36, 3, 78, 71, 32, 215, 184, 32, 87, + 8, 240, 7, 7, 68, 79, 85, 66, 76, 69, 32, 242, 7, 83, 71, 86, 26, 48, 5, + 65, 67, 82, 79, 78, 209, 5, 2, 73, 78, 23, 18, 32, 127, 45, 10, 34, 76, + 22, 82, 223, 173, 31, 66, 4, 41, 2, 69, 70, 4, 21, 3, 73, 71, 72, 4, 169, + 178, 17, 6, 84, 32, 72, 65, 76, 70, 10, 54, 86, 154, 21, 65, 234, 189, + 12, 71, 131, 190, 3, 66, 2, 161, 182, 32, 8, 69, 82, 84, 73, 67, 65, 76, + 45, 4, 168, 9, 9, 85, 77, 66, 69, 82, 32, 83, 73, 71, 217, 128, 12, 2, 79, 84, 18, 136, 1, 17, 76, 68, 32, 80, 69, 82, 77, 73, 67, 32, 76, 69, - 84, 84, 69, 82, 32, 82, 80, 216, 158, 12, 4, 71, 79, 78, 69, 219, 215, - 18, 86, 10, 198, 45, 90, 194, 150, 18, 78, 182, 166, 9, 68, 186, 176, 2, - 83, 239, 246, 1, 65, 2, 153, 212, 24, 6, 69, 78, 32, 77, 65, 82, 12, 18, - 65, 107, 76, 8, 220, 7, 9, 82, 69, 78, 84, 72, 69, 83, 69, 83, 225, 203, - 24, 9, 76, 65, 84, 65, 76, 73, 90, 69, 68, 4, 11, 85, 4, 165, 189, 30, 6, - 83, 32, 83, 73, 71, 78, 40, 18, 69, 127, 73, 6, 72, 5, 86, 69, 82, 83, - 69, 193, 209, 24, 7, 84, 82, 79, 70, 76, 69, 88, 4, 22, 32, 251, 12, 68, - 2, 137, 8, 2, 83, 79, 34, 40, 3, 71, 72, 84, 133, 5, 2, 78, 71, 28, 50, - 32, 253, 3, 7, 87, 65, 82, 68, 83, 32, 72, 26, 108, 5, 65, 82, 82, 79, - 87, 218, 1, 72, 124, 12, 80, 65, 82, 69, 78, 84, 72, 69, 83, 73, 83, 32, - 159, 9, 84, 12, 44, 5, 72, 69, 65, 68, 32, 251, 185, 30, 32, 8, 26, 65, - 251, 185, 30, 66, 6, 36, 3, 78, 68, 32, 223, 222, 31, 66, 4, 40, 4, 68, - 79, 87, 78, 1, 2, 85, 80, 2, 197, 227, 8, 9, 32, 65, 82, 82, 79, 87, 72, - 69, 65, 6, 11, 65, 6, 48, 6, 76, 70, 32, 82, 73, 78, 21, 2, 82, 80, 4, - 131, 184, 30, 71, 2, 17, 2, 79, 79, 2, 235, 220, 31, 78, 4, 222, 223, 9, - 65, 221, 166, 21, 5, 66, 69, 76, 79, 87, 2, 237, 148, 21, 16, 65, 82, 80, - 79, 79, 78, 32, 87, 73, 84, 72, 32, 66, 65, 82, 66, 6, 11, 32, 6, 166, - 240, 11, 79, 178, 198, 18, 66, 131, 165, 1, 65, 24, 166, 1, 72, 204, 1, - 6, 81, 85, 65, 82, 69, 32, 84, 5, 84, 82, 79, 78, 71, 128, 195, 3, 2, 85, - 83, 160, 133, 21, 2, 78, 65, 149, 234, 5, 6, 69, 65, 71, 85, 76, 76, 8, - 40, 4, 79, 82, 84, 32, 187, 186, 16, 65, 6, 18, 83, 71, 86, 4, 26, 79, - 187, 237, 11, 84, 2, 217, 237, 11, 5, 76, 73, 68, 85, 83, 2, 49, 10, 69, - 82, 84, 73, 67, 65, 76, 32, 76, 73, 2, 243, 236, 11, 78, 6, 26, 66, 151, - 216, 31, 65, 4, 164, 218, 7, 5, 82, 65, 67, 75, 69, 251, 216, 22, 69, 2, - 133, 200, 24, 17, 32, 67, 69, 78, 84, 82, 65, 76, 73, 90, 65, 84, 73, 79, + 84, 84, 69, 82, 32, 86, 80, 200, 208, 12, 4, 71, 79, 78, 69, 239, 144, + 19, 86, 10, 230, 225, 17, 90, 134, 197, 1, 78, 130, 172, 9, 68, 174, 178, + 2, 83, 235, 250, 1, 65, 2, 237, 186, 25, 6, 69, 78, 32, 77, 65, 82, 12, + 18, 65, 107, 76, 8, 220, 7, 9, 82, 69, 78, 84, 72, 69, 83, 69, 83, 181, + 178, 25, 9, 76, 65, 84, 65, 76, 73, 90, 69, 68, 4, 11, 85, 4, 161, 168, + 31, 6, 83, 32, 83, 73, 71, 78, 40, 18, 69, 127, 73, 6, 72, 5, 86, 69, 82, + 83, 69, 149, 184, 25, 7, 84, 82, 79, 70, 76, 69, 88, 4, 22, 32, 251, 12, + 68, 2, 137, 8, 2, 83, 79, 34, 40, 3, 71, 72, 84, 133, 5, 2, 78, 71, 28, + 50, 32, 253, 3, 7, 87, 65, 82, 68, 83, 32, 72, 26, 108, 5, 65, 82, 82, + 79, 87, 218, 1, 72, 124, 12, 80, 65, 82, 69, 78, 84, 72, 69, 83, 73, 83, + 32, 159, 9, 84, 12, 44, 5, 72, 69, 65, 68, 32, 247, 164, 31, 32, 8, 26, + 65, 247, 164, 31, 66, 6, 36, 3, 78, 68, 32, 251, 204, 32, 66, 4, 40, 4, + 68, 79, 87, 78, 1, 2, 85, 80, 2, 253, 251, 8, 9, 32, 65, 82, 82, 79, 87, + 72, 69, 65, 6, 11, 65, 6, 48, 6, 76, 70, 32, 82, 73, 78, 21, 2, 82, 80, + 4, 255, 162, 31, 71, 2, 17, 2, 79, 79, 2, 135, 203, 32, 78, 4, 158, 251, + 9, 65, 169, 246, 21, 5, 66, 69, 76, 79, 87, 2, 197, 249, 21, 16, 65, 82, + 80, 79, 79, 78, 32, 87, 73, 84, 72, 32, 66, 65, 82, 66, 6, 11, 32, 6, + 190, 157, 12, 79, 150, 132, 19, 66, 163, 168, 1, 65, 24, 166, 1, 72, 204, + 1, 6, 81, 85, 65, 82, 69, 32, 84, 5, 84, 82, 79, 78, 71, 164, 219, 3, 2, + 85, 83, 208, 211, 21, 2, 78, 65, 189, 238, 5, 6, 69, 65, 71, 85, 76, 76, + 8, 40, 4, 79, 82, 84, 32, 187, 133, 17, 65, 6, 18, 83, 71, 86, 4, 26, 79, + 211, 154, 12, 84, 2, 241, 154, 12, 5, 76, 73, 68, 85, 83, 2, 49, 10, 69, + 82, 84, 73, 67, 65, 76, 32, 76, 73, 2, 139, 154, 12, 78, 6, 26, 66, 179, + 198, 32, 65, 4, 168, 242, 7, 5, 82, 65, 67, 75, 69, 243, 171, 23, 69, 2, + 217, 174, 25, 17, 32, 67, 69, 78, 84, 82, 65, 76, 73, 90, 65, 84, 73, 79, 78, 32, 83, 20, 98, 72, 32, 4, 73, 76, 68, 69, 136, 1, 6, 82, 73, 80, 76, - 69, 32, 69, 5, 85, 82, 78, 69, 68, 2, 153, 216, 7, 3, 82, 69, 69, 11, 11, - 32, 8, 76, 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, 246, 233, 11, 79, 179, - 198, 18, 66, 2, 245, 160, 30, 6, 84, 32, 72, 65, 76, 70, 6, 178, 221, 15, - 65, 140, 225, 15, 5, 85, 78, 68, 69, 82, 239, 66, 68, 2, 249, 183, 15, 2, - 32, 67, 12, 34, 80, 222, 211, 31, 82, 3, 83, 8, 18, 32, 43, 87, 4, 11, - 84, 4, 185, 195, 24, 2, 65, 67, 4, 25, 4, 65, 82, 68, 83, 4, 241, 173, - 30, 6, 32, 65, 82, 82, 79, 87, 16, 42, 32, 37, 6, 45, 76, 73, 78, 69, 45, - 6, 174, 157, 26, 76, 175, 202, 2, 84, 10, 54, 65, 48, 5, 71, 82, 65, 86, - 69, 139, 214, 15, 77, 4, 25, 4, 67, 85, 84, 69, 5, 147, 221, 11, 45, 5, - 143, 131, 12, 45, 6, 52, 3, 68, 69, 32, 137, 230, 11, 4, 71, 71, 76, 89, - 4, 184, 193, 24, 14, 73, 78, 86, 69, 82, 84, 69, 68, 32, 66, 82, 73, 68, - 71, 149, 229, 4, 5, 66, 82, 73, 68, 71, 6, 194, 237, 11, 45, 159, 189, - 18, 32, 6, 52, 7, 69, 82, 67, 73, 65, 76, 32, 143, 204, 32, 65, 4, 218, - 153, 29, 77, 135, 150, 3, 65, 8, 234, 161, 8, 82, 204, 153, 16, 3, 79, - 83, 73, 250, 244, 2, 76, 231, 130, 4, 65, 38, 214, 1, 70, 84, 10, 83, 84, - 82, 85, 67, 84, 73, 79, 78, 32, 46, 84, 252, 235, 2, 8, 86, 69, 78, 73, - 69, 78, 67, 69, 128, 183, 18, 6, 73, 67, 65, 76, 32, 84, 234, 189, 9, 74, - 217, 102, 7, 71, 82, 85, 69, 78, 84, 32, 6, 192, 160, 27, 4, 69, 84, 84, - 73, 150, 242, 1, 85, 245, 163, 2, 4, 79, 85, 78, 68, 4, 164, 209, 20, 2, - 87, 79, 223, 240, 10, 83, 20, 80, 5, 65, 73, 78, 83, 32, 198, 1, 79, 28, - 4, 82, 79, 76, 32, 183, 146, 3, 73, 12, 48, 3, 65, 83, 32, 93, 5, 87, 73, - 84, 72, 32, 6, 238, 159, 24, 77, 181, 8, 15, 78, 79, 82, 77, 65, 76, 32, - 83, 85, 66, 71, 82, 79, 85, 80, 6, 198, 191, 4, 76, 178, 225, 19, 86, - 239, 243, 4, 79, 2, 153, 188, 30, 2, 85, 82, 4, 196, 238, 19, 3, 75, 78, - 79, 173, 134, 4, 8, 83, 69, 81, 85, 69, 78, 67, 69, 6, 26, 73, 147, 158, - 2, 69, 4, 202, 196, 32, 78, 87, 69, 206, 2, 36, 4, 84, 73, 67, 32, 175, + 69, 32, 69, 5, 85, 82, 78, 69, 68, 2, 157, 240, 7, 3, 82, 69, 69, 11, 11, + 32, 8, 76, 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, 142, 151, 12, 79, 151, + 132, 19, 66, 2, 149, 139, 31, 6, 84, 32, 72, 65, 76, 70, 6, 194, 158, 16, + 65, 152, 142, 16, 5, 85, 78, 68, 69, 82, 239, 66, 68, 2, 249, 246, 15, 2, + 32, 67, 12, 34, 80, 250, 193, 32, 82, 3, 83, 8, 18, 32, 43, 87, 4, 11, + 84, 4, 141, 170, 25, 2, 65, 67, 4, 25, 4, 65, 82, 68, 83, 4, 237, 152, + 31, 6, 32, 65, 82, 82, 79, 87, 18, 42, 32, 37, 6, 45, 76, 73, 78, 69, 45, + 6, 138, 134, 27, 76, 255, 202, 2, 84, 12, 82, 65, 48, 5, 68, 79, 85, 66, + 76, 28, 5, 71, 82, 65, 86, 69, 243, 150, 16, 77, 4, 25, 4, 67, 85, 84, + 69, 5, 147, 138, 12, 45, 2, 145, 180, 12, 2, 69, 45, 5, 247, 179, 12, 45, + 6, 52, 3, 68, 69, 32, 233, 146, 12, 4, 71, 71, 76, 89, 4, 212, 167, 25, + 14, 73, 78, 86, 69, 82, 84, 69, 68, 32, 66, 82, 73, 68, 71, 225, 232, 4, + 5, 66, 82, 73, 68, 71, 6, 166, 156, 12, 45, 255, 248, 18, 32, 10, 26, 69, + 143, 186, 33, 65, 8, 48, 6, 82, 67, 73, 65, 76, 32, 211, 253, 8, 78, 4, + 158, 131, 30, 77, 143, 154, 3, 65, 8, 158, 185, 8, 82, 156, 232, 16, 3, + 79, 83, 73, 218, 246, 2, 76, 207, 136, 4, 65, 38, 214, 1, 70, 84, 10, 83, + 84, 82, 85, 67, 84, 73, 79, 78, 32, 46, 84, 160, 130, 3, 8, 86, 69, 78, + 73, 69, 78, 67, 69, 136, 133, 19, 6, 73, 67, 65, 76, 32, 84, 242, 195, 9, + 74, 241, 105, 7, 71, 82, 85, 69, 78, 84, 32, 6, 188, 136, 28, 4, 69, 84, + 84, 73, 222, 243, 1, 85, 253, 167, 2, 4, 79, 85, 78, 68, 4, 240, 180, 21, + 2, 87, 79, 223, 250, 10, 83, 20, 80, 5, 65, 73, 78, 83, 32, 198, 1, 79, + 28, 4, 82, 79, 76, 32, 147, 169, 3, 73, 12, 48, 3, 65, 83, 32, 93, 5, 87, + 73, 84, 72, 32, 6, 226, 133, 25, 77, 189, 8, 15, 78, 79, 82, 77, 65, 76, + 32, 83, 85, 66, 71, 82, 79, 85, 80, 6, 146, 215, 4, 76, 226, 175, 20, 86, + 183, 247, 4, 79, 2, 201, 166, 31, 2, 85, 82, 4, 248, 209, 20, 3, 75, 78, + 79, 137, 137, 4, 8, 83, 69, 81, 85, 69, 78, 67, 69, 6, 26, 73, 191, 180, + 2, 69, 4, 150, 178, 33, 78, 87, 69, 206, 2, 36, 4, 84, 73, 67, 32, 163, 18, 89, 202, 2, 186, 1, 67, 204, 1, 6, 69, 80, 65, 67, 84, 32, 86, 70, - 36, 11, 79, 76, 68, 32, 78, 85, 66, 73, 65, 78, 32, 110, 83, 137, 134, + 36, 11, 79, 76, 68, 32, 78, 85, 66, 73, 65, 78, 32, 110, 83, 205, 239, 29, 13, 77, 79, 82, 80, 72, 79, 76, 79, 71, 73, 67, 65, 76, 126, 76, 9, 79, 77, 66, 73, 78, 73, 78, 71, 32, 161, 3, 5, 65, 80, 73, 84, 65, 6, 68, - 9, 83, 80, 73, 82, 73, 84, 85, 83, 32, 253, 196, 31, 2, 78, 73, 4, 204, - 151, 6, 2, 76, 69, 157, 136, 17, 2, 65, 83, 56, 210, 175, 21, 78, 170, - 198, 2, 68, 141, 250, 6, 8, 84, 72, 79, 85, 83, 65, 78, 68, 4, 142, 175, - 18, 82, 195, 188, 11, 85, 8, 58, 68, 0, 3, 73, 78, 68, 146, 15, 86, 215, - 219, 29, 70, 2, 177, 235, 29, 7, 73, 82, 69, 67, 84, 32, 81, 134, 1, 56, - 3, 77, 65, 76, 197, 11, 6, 89, 77, 66, 79, 76, 32, 120, 45, 9, 76, 32, - 76, 69, 84, 84, 69, 82, 32, 120, 138, 2, 65, 48, 6, 66, 79, 72, 65, 73, + 9, 83, 80, 73, 82, 73, 84, 85, 83, 32, 201, 178, 32, 2, 78, 73, 4, 128, + 175, 6, 2, 76, 69, 249, 214, 17, 2, 65, 83, 56, 166, 148, 22, 78, 230, + 199, 2, 68, 185, 254, 6, 8, 84, 72, 79, 85, 83, 65, 78, 68, 4, 158, 145, + 19, 82, 131, 196, 11, 85, 8, 58, 68, 0, 3, 73, 78, 68, 134, 15, 86, 179, + 197, 30, 70, 2, 129, 213, 30, 7, 73, 82, 69, 67, 84, 32, 81, 134, 1, 56, + 3, 77, 65, 76, 185, 11, 6, 89, 77, 66, 79, 76, 32, 120, 45, 9, 76, 32, + 76, 69, 84, 84, 69, 82, 32, 120, 146, 2, 65, 48, 6, 66, 79, 72, 65, 73, 82, 32, 2, 67, 82, 170, 1, 68, 160, 1, 2, 71, 65, 34, 72, 38, 75, 46, 70, - 34, 76, 66, 79, 138, 3, 83, 90, 84, 46, 90, 150, 214, 5, 86, 214, 54, 80, - 170, 211, 3, 73, 246, 180, 22, 82, 198, 3, 69, 218, 7, 77, 2, 78, 163, - 17, 85, 4, 44, 5, 75, 72, 77, 73, 77, 223, 195, 19, 76, 2, 177, 1, 4, 73, - 67, 32, 75, 10, 92, 12, 89, 80, 84, 79, 71, 82, 65, 77, 77, 73, 67, 32, - 53, 7, 79, 83, 83, 69, 68, 32, 83, 8, 50, 83, 226, 4, 71, 250, 154, 32, - 69, 219, 7, 78, 2, 239, 227, 24, 72, 12, 80, 9, 73, 65, 76, 69, 67, 84, - 45, 80, 32, 156, 149, 32, 2, 65, 76, 175, 17, 69, 8, 154, 159, 8, 72, - 226, 154, 8, 65, 252, 194, 12, 2, 75, 65, 211, 169, 3, 78, 4, 190, 3, 78, - 135, 149, 32, 77, 4, 230, 205, 25, 79, 187, 162, 5, 65, 8, 42, 72, 190, - 251, 28, 65, 211, 169, 3, 83, 4, 138, 165, 32, 69, 219, 19, 73, 4, 176, - 193, 19, 7, 45, 83, 72, 65, 80, 69, 68, 239, 251, 7, 65, 35, 36, 3, 76, - 68, 32, 247, 146, 32, 79, 30, 76, 7, 67, 79, 80, 84, 73, 67, 32, 193, 1, - 7, 78, 85, 66, 73, 65, 78, 32, 22, 98, 71, 42, 72, 188, 1, 2, 83, 72, - 162, 228, 14, 68, 162, 249, 9, 79, 254, 235, 5, 69, 183, 107, 65, 2, 17, - 2, 65, 78, 2, 231, 129, 16, 71, 8, 178, 202, 25, 79, 246, 130, 1, 65, - 131, 213, 5, 69, 8, 50, 78, 172, 184, 16, 2, 83, 72, 147, 154, 5, 87, 4, - 190, 161, 32, 71, 3, 89, 10, 54, 72, 186, 153, 6, 65, 166, 246, 25, 79, - 219, 3, 73, 4, 178, 147, 32, 73, 187, 13, 69, 4, 148, 135, 32, 3, 72, 69, - 84, 167, 8, 65, 2, 171, 143, 32, 65, 14, 62, 75, 30, 77, 2, 80, 22, 83, - 185, 247, 27, 3, 84, 65, 85, 4, 26, 72, 179, 159, 32, 65, 2, 203, 247, - 27, 73, 4, 132, 182, 16, 6, 72, 73, 77, 65, 32, 83, 245, 250, 3, 3, 84, - 65, 85, 4, 216, 207, 24, 3, 76, 69, 70, 133, 151, 2, 4, 82, 73, 71, 72, - 6, 96, 6, 78, 73, 83, 72, 32, 86, 240, 207, 25, 8, 82, 69, 83, 80, 79, - 78, 68, 83, 203, 213, 5, 65, 2, 165, 247, 28, 4, 69, 82, 83, 69, 44, 104, - 2, 78, 84, 192, 132, 3, 6, 67, 72, 32, 65, 78, 68, 253, 163, 28, 8, 80, - 76, 69, 32, 87, 73, 84, 72, 40, 56, 2, 69, 82, 37, 8, 73, 78, 71, 32, 82, - 79, 68, 32, 4, 170, 194, 27, 66, 167, 136, 1, 83, 36, 48, 4, 84, 69, 78, - 83, 1, 4, 85, 78, 73, 84, 18, 145, 227, 23, 2, 32, 68, 51, 82, 69, 76, 5, - 73, 67, 75, 69, 84, 34, 79, 198, 5, 85, 50, 89, 159, 233, 30, 65, 4, 188, - 171, 8, 3, 68, 73, 84, 141, 216, 20, 7, 83, 67, 69, 78, 84, 32, 77, 5, - 129, 132, 27, 3, 32, 66, 65, 28, 84, 2, 83, 83, 232, 131, 30, 3, 67, 79, - 68, 208, 156, 1, 3, 73, 83, 83, 155, 60, 87, 22, 46, 32, 184, 2, 3, 69, - 68, 32, 223, 1, 73, 14, 44, 3, 79, 70, 32, 82, 80, 215, 233, 31, 77, 4, - 140, 190, 28, 6, 74, 69, 82, 85, 83, 65, 133, 210, 2, 5, 76, 79, 82, 82, - 65, 8, 76, 10, 65, 84, 84, 89, 32, 87, 73, 84, 72, 32, 41, 5, 79, 77, 77, - 69, 69, 4, 206, 165, 10, 82, 25, 3, 76, 69, 70, 5, 225, 161, 3, 11, 32, - 87, 73, 84, 72, 32, 72, 65, 76, 70, 45, 6, 220, 139, 25, 37, 78, 69, 71, - 65, 84, 73, 86, 69, 32, 83, 81, 85, 65, 82, 69, 68, 32, 76, 65, 84, 73, - 78, 32, 67, 65, 80, 73, 84, 65, 76, 32, 76, 69, 84, 84, 69, 82, 248, 226, - 2, 2, 70, 76, 177, 216, 2, 3, 83, 87, 79, 2, 157, 242, 23, 5, 78, 71, 32, - 76, 65, 4, 176, 206, 17, 3, 90, 69, 73, 235, 182, 14, 84, 6, 138, 222, - 19, 73, 141, 160, 7, 4, 83, 84, 65, 76, 206, 19, 154, 1, 66, 20, 8, 78, - 69, 73, 70, 79, 82, 77, 32, 154, 250, 1, 80, 114, 82, 180, 3, 2, 83, 84, - 150, 222, 15, 67, 161, 191, 13, 6, 84, 32, 79, 70, 32, 77, 2, 255, 177, - 5, 69, 170, 19, 176, 1, 13, 78, 85, 77, 69, 82, 73, 67, 32, 83, 73, 71, - 78, 32, 184, 20, 17, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 32, 83, - 73, 71, 78, 32, 233, 1, 5, 83, 73, 71, 78, 32, 222, 1, 78, 69, 166, 2, - 70, 152, 3, 2, 78, 73, 154, 2, 79, 130, 3, 83, 151, 4, 84, 24, 68, 5, 73, - 71, 72, 84, 32, 153, 1, 7, 76, 65, 77, 73, 84, 69, 32, 16, 142, 14, 83, - 230, 113, 85, 238, 50, 71, 136, 56, 17, 86, 65, 82, 73, 65, 78, 84, 32, - 70, 79, 82, 77, 32, 85, 83, 83, 85, 166, 211, 26, 68, 199, 249, 1, 65, 8, - 176, 143, 21, 5, 79, 78, 69, 32, 84, 234, 160, 9, 70, 175, 14, 84, 58, - 48, 4, 73, 86, 69, 32, 125, 4, 79, 85, 82, 32, 26, 70, 83, 206, 1, 66, - 250, 12, 65, 82, 71, 138, 110, 85, 155, 190, 27, 68, 6, 182, 15, 72, 169, - 146, 19, 5, 73, 88, 84, 72, 83, 32, 150, 1, 66, 44, 18, 86, 65, 82, 73, - 65, 78, 84, 32, 70, 79, 82, 77, 32, 76, 73, 77, 77, 85, 206, 12, 65, 82, - 71, 26, 83, 242, 109, 85, 155, 190, 27, 68, 6, 204, 123, 3, 65, 78, 50, - 235, 224, 26, 85, 9, 206, 203, 12, 32, 187, 210, 19, 52, 24, 44, 4, 71, - 73, 68, 65, 33, 3, 78, 69, 32, 4, 170, 178, 30, 69, 183, 107, 77, 20, - 156, 1, 19, 86, 65, 82, 73, 65, 78, 84, 32, 70, 79, 82, 77, 32, 73, 76, - 73, 77, 77, 85, 174, 7, 83, 230, 113, 85, 238, 50, 71, 174, 139, 27, 68, - 199, 249, 1, 65, 9, 186, 153, 32, 32, 186, 2, 51, 3, 52, 28, 92, 16, 76, - 68, 32, 65, 83, 83, 89, 82, 73, 65, 78, 32, 79, 78, 69, 32, 37, 3, 78, - 69, 32, 4, 170, 196, 18, 83, 219, 208, 11, 81, 24, 166, 1, 69, 52, 8, 81, - 85, 65, 82, 84, 69, 82, 32, 206, 7, 66, 54, 71, 84, 5, 84, 72, 73, 82, - 68, 216, 201, 24, 2, 83, 72, 237, 205, 6, 6, 72, 65, 76, 70, 32, 71, 4, - 158, 8, 83, 205, 164, 1, 5, 73, 71, 72, 84, 72, 4, 226, 173, 30, 65, 183, - 114, 71, 38, 144, 1, 5, 69, 86, 69, 78, 32, 188, 1, 20, 72, 65, 82, 50, - 32, 84, 73, 77, 69, 83, 32, 71, 65, 76, 32, 80, 76, 85, 83, 32, 37, 3, - 73, 88, 32, 18, 148, 1, 17, 86, 65, 82, 73, 65, 78, 84, 32, 70, 79, 82, - 77, 32, 73, 77, 73, 78, 218, 1, 83, 230, 113, 85, 238, 50, 71, 174, 139, - 27, 68, 199, 249, 1, 65, 6, 230, 195, 12, 32, 187, 210, 19, 51, 4, 174, - 177, 28, 68, 251, 228, 2, 77, 16, 142, 1, 83, 142, 3, 65, 218, 110, 85, - 238, 50, 71, 224, 245, 26, 16, 86, 65, 82, 73, 65, 78, 84, 32, 70, 79, - 82, 77, 32, 65, 83, 72, 207, 21, 68, 2, 227, 61, 72, 50, 52, 5, 72, 82, - 69, 69, 32, 241, 1, 3, 87, 79, 32, 28, 142, 1, 66, 40, 4, 83, 72, 65, 82, - 24, 16, 86, 65, 82, 73, 65, 78, 84, 32, 70, 79, 82, 77, 32, 69, 83, 72, - 118, 65, 82, 71, 163, 172, 28, 68, 6, 136, 112, 3, 85, 82, 85, 199, 10, - 65, 8, 226, 111, 50, 3, 85, 4, 146, 231, 24, 49, 203, 3, 50, 22, 82, 65, - 30, 66, 32, 2, 69, 83, 22, 71, 26, 83, 61, 6, 84, 72, 73, 82, 68, 83, 4, - 225, 184, 1, 2, 83, 72, 4, 254, 120, 65, 167, 214, 26, 85, 2, 135, 234, - 24, 72, 4, 53, 3, 69, 83, 72, 4, 11, 72, 4, 17, 2, 65, 82, 4, 178, 144, - 32, 50, 3, 85, 4, 11, 32, 4, 140, 199, 27, 12, 86, 65, 82, 73, 65, 78, - 84, 32, 70, 79, 82, 77, 179, 100, 68, 10, 160, 1, 9, 68, 73, 65, 71, 79, - 78, 65, 76, 32, 144, 210, 25, 6, 86, 69, 82, 84, 73, 67, 145, 130, 3, 14, - 79, 76, 68, 32, 65, 83, 83, 89, 82, 73, 65, 78, 32, 87, 6, 144, 191, 28, - 2, 84, 82, 244, 254, 2, 4, 81, 85, 65, 68, 15, 67, 194, 17, 202, 1, 65, - 186, 15, 66, 170, 5, 68, 190, 15, 69, 202, 10, 71, 182, 30, 72, 238, 3, - 73, 238, 4, 75, 154, 20, 76, 134, 37, 77, 134, 6, 78, 226, 17, 80, 210, - 3, 82, 42, 83, 238, 19, 84, 186, 8, 85, 207, 20, 90, 141, 1, 160, 1, 7, - 32, 84, 73, 77, 69, 83, 32, 142, 1, 66, 250, 3, 68, 38, 75, 90, 76, 212, - 1, 3, 77, 65, 82, 78, 78, 134, 2, 82, 42, 83, 190, 128, 31, 80, 215, 127, - 50, 16, 144, 173, 1, 5, 76, 65, 71, 65, 82, 226, 23, 71, 254, 245, 12, - 73, 226, 192, 13, 77, 162, 163, 2, 83, 194, 165, 1, 66, 246, 67, 72, 187, - 2, 65, 45, 22, 32, 219, 2, 50, 28, 48, 6, 84, 73, 77, 69, 83, 32, 139, - 203, 1, 71, 26, 180, 1, 2, 71, 65, 38, 73, 36, 2, 83, 72, 128, 113, 8, - 85, 32, 80, 76, 85, 83, 32, 85, 188, 56, 4, 68, 85, 78, 51, 166, 2, 65, - 204, 2, 3, 78, 85, 78, 242, 27, 76, 179, 186, 30, 72, 4, 194, 210, 1, 78, - 139, 181, 30, 76, 4, 210, 169, 1, 71, 131, 222, 29, 77, 4, 194, 223, 24, - 85, 187, 188, 5, 69, 15, 37, 7, 32, 84, 73, 77, 69, 83, 32, 12, 206, 133, - 1, 77, 130, 59, 71, 194, 9, 83, 234, 10, 84, 200, 197, 28, 2, 66, 65, - 251, 235, 1, 65, 5, 249, 51, 5, 32, 84, 73, 77, 69, 7, 37, 7, 32, 84, 73, - 77, 69, 83, 32, 4, 252, 27, 5, 83, 72, 73, 84, 65, 215, 80, 69, 23, 68, - 7, 32, 84, 73, 77, 69, 83, 32, 158, 209, 25, 69, 155, 227, 5, 65, 16, - 102, 75, 156, 173, 1, 2, 68, 73, 198, 241, 26, 71, 198, 249, 1, 85, 186, - 95, 65, 198, 94, 83, 215, 42, 72, 4, 130, 158, 1, 65, 171, 229, 30, 73, - 7, 37, 7, 32, 84, 73, 77, 69, 83, 32, 4, 218, 249, 3, 75, 251, 219, 27, - 83, 13, 26, 32, 151, 213, 31, 83, 8, 128, 1, 10, 80, 76, 85, 83, 32, 78, - 65, 71, 65, 32, 248, 187, 8, 7, 84, 72, 82, 69, 69, 32, 84, 193, 255, 5, - 4, 79, 86, 69, 82, 4, 144, 140, 1, 16, 79, 80, 80, 79, 83, 73, 78, 71, - 32, 65, 78, 32, 80, 76, 85, 83, 139, 183, 23, 83, 6, 200, 49, 2, 65, 68, - 203, 153, 18, 75, 18, 26, 72, 139, 165, 12, 65, 17, 42, 32, 166, 202, 18, - 71, 167, 181, 13, 50, 10, 68, 9, 79, 86, 69, 82, 32, 65, 83, 72, 32, 174, - 97, 90, 135, 112, 75, 6, 176, 1, 8, 79, 86, 69, 82, 32, 65, 83, 72, 157, - 143, 1, 29, 84, 85, 71, 50, 32, 79, 86, 69, 82, 32, 84, 85, 71, 50, 32, - 84, 85, 71, 50, 32, 79, 86, 69, 82, 32, 84, 85, 71, 50, 5, 149, 145, 1, - 27, 32, 67, 82, 79, 83, 83, 73, 78, 71, 32, 65, 83, 72, 32, 79, 86, 69, - 82, 32, 65, 83, 72, 32, 79, 86, 69, 82, 52, 30, 65, 158, 2, 73, 95, 85, - 27, 66, 68, 44, 4, 72, 65, 82, 50, 90, 76, 66, 82, 203, 255, 27, 71, 5, - 145, 208, 1, 6, 32, 84, 73, 77, 69, 83, 9, 37, 7, 32, 84, 73, 77, 69, 83, - 32, 6, 238, 164, 1, 65, 206, 194, 30, 78, 163, 17, 90, 7, 132, 239, 30, - 7, 32, 79, 86, 69, 82, 32, 66, 139, 139, 1, 65, 5, 227, 210, 24, 65, 9, - 37, 7, 32, 84, 73, 77, 69, 83, 32, 6, 134, 156, 1, 73, 166, 186, 29, 71, - 191, 163, 1, 65, 19, 50, 32, 168, 1, 3, 76, 85, 71, 239, 169, 1, 82, 8, - 88, 8, 79, 86, 69, 82, 32, 66, 85, 32, 201, 195, 27, 8, 67, 82, 79, 83, - 83, 73, 78, 71, 6, 160, 199, 12, 7, 84, 73, 77, 69, 83, 32, 78, 138, 243, - 17, 65, 155, 110, 85, 5, 197, 238, 3, 8, 32, 79, 86, 69, 82, 32, 66, 85, - 180, 1, 34, 65, 222, 5, 73, 195, 2, 85, 67, 50, 71, 150, 5, 82, 146, 49, - 32, 167, 192, 31, 77, 55, 26, 32, 175, 246, 31, 51, 50, 76, 13, 75, 73, - 83, 73, 77, 53, 32, 84, 73, 77, 69, 83, 32, 227, 198, 1, 84, 48, 146, 1, - 65, 30, 66, 38, 71, 112, 2, 73, 82, 42, 76, 94, 85, 182, 131, 1, 80, 162, - 61, 84, 186, 248, 27, 75, 182, 162, 2, 78, 254, 2, 83, 163, 17, 72, 4, - 110, 32, 159, 208, 30, 77, 4, 178, 136, 30, 65, 251, 235, 1, 73, 10, 34, - 65, 58, 73, 143, 173, 31, 85, 5, 11, 32, 2, 193, 136, 30, 6, 80, 76, 85, - 83, 32, 77, 5, 235, 203, 24, 82, 5, 129, 134, 14, 5, 32, 80, 76, 85, 83, - 8, 26, 85, 215, 242, 31, 65, 7, 160, 151, 1, 7, 32, 80, 76, 85, 83, 32, - 77, 179, 219, 30, 77, 6, 52, 7, 50, 32, 80, 76, 85, 83, 32, 207, 240, 31, - 83, 4, 128, 27, 2, 71, 73, 199, 235, 29, 77, 7, 187, 194, 12, 65, 25, 54, - 77, 150, 1, 78, 76, 2, 83, 72, 139, 239, 31, 66, 13, 44, 7, 32, 84, 73, - 77, 69, 83, 32, 59, 50, 6, 220, 69, 2, 85, 32, 238, 218, 13, 73, 227, - 162, 17, 83, 5, 205, 158, 13, 6, 32, 84, 73, 77, 69, 83, 5, 177, 241, 18, - 14, 32, 75, 65, 83, 75, 65, 76, 32, 85, 32, 71, 85, 78, 85, 5, 245, 157, - 1, 5, 32, 80, 76, 85, 83, 91, 70, 32, 66, 66, 94, 71, 234, 4, 78, 214, - 192, 24, 82, 195, 167, 7, 72, 6, 154, 176, 1, 71, 170, 3, 83, 181, 203, - 12, 4, 79, 86, 69, 82, 9, 52, 7, 32, 84, 73, 77, 69, 83, 32, 163, 237, - 31, 50, 4, 250, 145, 1, 69, 155, 174, 30, 83, 61, 52, 7, 32, 84, 73, 77, - 69, 83, 32, 167, 166, 31, 85, 56, 122, 65, 58, 68, 30, 71, 74, 75, 90, - 76, 110, 77, 50, 83, 130, 80, 69, 218, 58, 73, 182, 200, 16, 72, 214, - 129, 14, 78, 3, 80, 6, 32, 2, 83, 72, 143, 190, 31, 78, 5, 251, 212, 14, - 32, 4, 174, 155, 31, 73, 3, 85, 8, 26, 73, 219, 234, 31, 65, 7, 140, 141, - 1, 2, 82, 50, 187, 220, 30, 83, 8, 26, 85, 211, 185, 1, 65, 6, 40, 4, 83, - 72, 85, 50, 231, 233, 31, 82, 5, 175, 26, 32, 8, 26, 65, 45, 2, 85, 72, - 6, 202, 26, 77, 221, 165, 24, 3, 75, 45, 48, 2, 225, 57, 5, 32, 80, 76, - 85, 83, 6, 222, 253, 29, 65, 174, 173, 1, 69, 223, 61, 73, 4, 238, 138, - 1, 73, 247, 198, 30, 72, 11, 26, 51, 251, 231, 31, 52, 7, 143, 9, 32, - 117, 130, 1, 32, 90, 50, 210, 1, 78, 202, 1, 82, 60, 3, 83, 72, 50, 52, - 3, 90, 69, 78, 166, 227, 18, 71, 142, 255, 11, 68, 215, 127, 76, 4, 168, - 25, 11, 79, 86, 69, 82, 32, 69, 32, 78, 85, 78, 32, 253, 94, 4, 84, 73, - 77, 69, 19, 37, 7, 32, 84, 73, 77, 69, 83, 32, 16, 134, 1, 83, 144, 168, - 1, 10, 65, 32, 80, 76, 85, 83, 32, 72, 65, 32, 146, 153, 29, 71, 182, 16, - 80, 182, 26, 75, 254, 100, 77, 219, 19, 85, 4, 138, 217, 30, 65, 255, - 116, 72, 15, 11, 32, 12, 96, 4, 67, 82, 79, 83, 0, 4, 79, 80, 80, 79, 36, - 6, 84, 73, 77, 69, 83, 32, 171, 165, 24, 83, 2, 245, 152, 14, 4, 83, 73, - 78, 71, 6, 204, 138, 1, 4, 71, 65, 78, 50, 135, 194, 30, 77, 6, 36, 3, - 73, 78, 50, 239, 146, 31, 69, 5, 139, 212, 30, 32, 5, 229, 16, 9, 32, 67, - 82, 79, 83, 83, 73, 78, 71, 63, 11, 32, 60, 96, 14, 83, 72, 69, 83, 72, - 73, 71, 32, 84, 73, 77, 69, 83, 32, 97, 6, 84, 73, 77, 69, 83, 32, 16, - 178, 131, 1, 73, 202, 220, 2, 77, 146, 150, 26, 65, 220, 110, 2, 76, 65, - 198, 87, 83, 147, 17, 72, 44, 134, 1, 65, 68, 5, 68, 85, 78, 51, 32, 26, - 75, 58, 76, 62, 83, 34, 85, 222, 127, 73, 204, 31, 2, 72, 65, 166, 144, - 29, 71, 199, 103, 66, 9, 244, 86, 9, 32, 80, 76, 85, 83, 32, 76, 65, 76, - 183, 136, 31, 78, 4, 217, 32, 2, 71, 85, 6, 184, 160, 24, 5, 65, 83, 75, - 65, 76, 187, 195, 3, 85, 8, 34, 65, 246, 221, 31, 73, 3, 85, 5, 201, 85, - 2, 76, 32, 4, 134, 199, 31, 72, 215, 22, 85, 4, 186, 221, 31, 50, 3, 68, - 160, 2, 42, 65, 166, 19, 69, 122, 73, 135, 5, 85, 191, 1, 114, 50, 144, - 16, 2, 66, 65, 94, 68, 22, 76, 38, 78, 206, 140, 1, 32, 154, 6, 82, 218, - 162, 28, 83, 155, 149, 2, 77, 153, 1, 11, 32, 150, 1, 68, 6, 84, 73, 77, - 69, 83, 32, 153, 128, 1, 5, 79, 86, 69, 82, 32, 148, 1, 202, 1, 65, 162, - 2, 66, 154, 1, 68, 178, 1, 69, 58, 71, 178, 1, 72, 230, 1, 73, 70, 75, - 194, 1, 76, 62, 77, 50, 78, 130, 1, 83, 142, 1, 85, 222, 154, 1, 84, 128, - 138, 23, 3, 90, 73, 90, 139, 165, 7, 80, 18, 132, 1, 6, 32, 80, 76, 85, - 83, 32, 50, 78, 52, 2, 83, 72, 189, 162, 18, 14, 66, 50, 32, 84, 69, 78, - 85, 32, 80, 76, 85, 83, 32, 84, 6, 202, 58, 68, 142, 206, 13, 73, 183, - 205, 17, 72, 5, 185, 61, 9, 32, 80, 76, 85, 83, 32, 75, 65, 75, 7, 11, - 50, 5, 133, 90, 6, 32, 80, 76, 85, 83, 32, 10, 26, 65, 77, 2, 85, 82, 6, - 42, 72, 44, 2, 82, 32, 187, 214, 31, 68, 2, 11, 65, 2, 151, 175, 24, 82, - 5, 11, 32, 2, 221, 139, 31, 4, 80, 76, 85, 83, 14, 34, 73, 54, 85, 191, - 213, 31, 65, 7, 17, 2, 77, 32, 4, 146, 22, 84, 207, 129, 1, 71, 6, 56, 8, - 71, 32, 84, 73, 77, 69, 83, 32, 131, 213, 31, 66, 4, 158, 119, 73, 151, - 45, 75, 10, 38, 78, 254, 2, 76, 191, 251, 29, 82, 5, 243, 28, 32, 18, 18, - 65, 99, 73, 11, 26, 82, 247, 158, 1, 78, 7, 33, 6, 32, 80, 76, 85, 83, - 32, 4, 130, 189, 31, 78, 255, 2, 68, 9, 174, 122, 52, 253, 234, 12, 7, - 82, 50, 32, 80, 76, 85, 83, 12, 62, 65, 154, 124, 85, 233, 232, 12, 6, - 73, 32, 80, 76, 85, 83, 8, 40, 6, 32, 80, 76, 85, 83, 32, 83, 76, 4, 48, - 6, 76, 85, 32, 80, 76, 85, 223, 209, 31, 65, 2, 11, 83, 2, 215, 97, 32, - 5, 149, 228, 13, 5, 32, 80, 76, 85, 83, 4, 176, 100, 10, 83, 72, 32, 80, - 76, 85, 83, 32, 72, 85, 147, 15, 71, 12, 34, 65, 36, 2, 73, 68, 27, 85, - 4, 158, 212, 24, 83, 147, 252, 6, 75, 5, 225, 77, 2, 32, 80, 4, 60, 5, - 83, 72, 85, 50, 32, 197, 127, 5, 51, 32, 80, 76, 85, 2, 205, 158, 1, 3, - 80, 76, 85, 8, 26, 65, 235, 205, 31, 85, 7, 11, 77, 5, 227, 159, 1, 32, - 6, 250, 77, 69, 214, 149, 29, 85, 139, 235, 1, 73, 10, 26, 69, 73, 2, 85, - 78, 7, 33, 6, 32, 80, 76, 85, 83, 32, 4, 166, 166, 24, 69, 235, 147, 7, - 71, 5, 11, 32, 2, 187, 101, 79, 14, 42, 72, 178, 223, 23, 65, 247, 220, - 7, 85, 8, 18, 69, 51, 73, 5, 145, 212, 30, 7, 32, 80, 76, 85, 83, 32, 84, - 4, 182, 204, 31, 68, 3, 77, 7, 11, 68, 5, 237, 220, 13, 5, 32, 80, 76, - 85, 83, 7, 11, 32, 4, 130, 237, 29, 82, 177, 177, 1, 11, 67, 82, 79, 83, - 83, 73, 78, 71, 32, 71, 65, 5, 191, 131, 1, 32, 7, 134, 131, 1, 32, 155, - 183, 30, 65, 11, 11, 50, 9, 11, 32, 6, 80, 8, 67, 82, 79, 83, 83, 73, 78, - 71, 0, 4, 79, 86, 69, 82, 163, 195, 26, 84, 2, 197, 49, 3, 32, 71, 65, 8, - 44, 5, 83, 72, 84, 73, 78, 223, 161, 24, 50, 7, 37, 7, 32, 84, 73, 77, - 69, 83, 32, 4, 158, 208, 30, 75, 215, 120, 85, 49, 70, 32, 94, 52, 114, - 82, 190, 1, 83, 182, 194, 30, 68, 211, 130, 1, 71, 6, 152, 253, 8, 6, 84, - 73, 77, 69, 83, 32, 249, 250, 4, 8, 67, 82, 79, 83, 83, 73, 78, 71, 7, - 11, 32, 4, 64, 8, 67, 82, 79, 83, 83, 73, 78, 71, 1, 4, 79, 86, 69, 82, - 2, 249, 157, 24, 3, 32, 71, 73, 16, 26, 51, 147, 136, 1, 50, 13, 37, 7, - 32, 84, 73, 77, 69, 83, 32, 10, 70, 65, 0, 2, 76, 85, 206, 127, 71, 254, - 245, 12, 73, 183, 205, 17, 80, 2, 197, 245, 13, 7, 32, 80, 76, 85, 83, - 32, 73, 14, 26, 72, 155, 185, 30, 65, 13, 11, 32, 10, 22, 84, 247, 20, - 67, 8, 44, 5, 73, 77, 69, 83, 32, 163, 159, 31, 69, 6, 192, 20, 6, 71, - 73, 83, 72, 32, 67, 146, 126, 84, 151, 235, 29, 66, 43, 110, 50, 174, 1, - 68, 218, 1, 77, 54, 82, 152, 242, 13, 9, 32, 67, 82, 79, 83, 83, 73, 78, - 71, 147, 205, 17, 76, 15, 11, 32, 12, 48, 6, 84, 73, 77, 69, 83, 32, 167, - 132, 1, 71, 10, 252, 24, 3, 75, 65, 75, 194, 75, 73, 152, 20, 10, 83, 65, - 76, 32, 80, 76, 85, 83, 32, 84, 155, 201, 29, 78, 11, 11, 32, 8, 128, 1, - 10, 80, 76, 85, 83, 32, 71, 73, 83, 72, 32, 16, 6, 84, 73, 77, 69, 83, - 32, 177, 66, 8, 79, 86, 69, 82, 32, 71, 85, 68, 2, 135, 121, 84, 4, 172, - 145, 1, 5, 65, 32, 80, 76, 85, 147, 182, 29, 75, 5, 17, 2, 32, 84, 2, - 241, 42, 4, 73, 77, 69, 83, 9, 26, 85, 143, 191, 31, 55, 4, 250, 189, 31, - 83, 147, 1, 78, 50, 30, 65, 82, 73, 215, 1, 85, 11, 26, 32, 179, 190, 31, - 76, 6, 32, 2, 84, 69, 147, 128, 1, 71, 4, 235, 127, 78, 23, 37, 7, 32, - 84, 73, 77, 69, 83, 32, 20, 104, 3, 65, 83, 72, 158, 216, 27, 68, 158, - 228, 2, 78, 94, 75, 170, 57, 66, 2, 71, 162, 25, 83, 143, 45, 85, 7, 224, - 55, 8, 32, 79, 86, 69, 82, 32, 72, 73, 135, 133, 31, 50, 19, 48, 2, 66, - 50, 182, 148, 24, 76, 179, 166, 7, 83, 13, 37, 7, 32, 84, 73, 77, 69, 83, - 32, 10, 254, 138, 1, 75, 130, 204, 26, 76, 242, 216, 2, 72, 254, 59, 65, - 195, 9, 85, 49, 104, 3, 68, 73, 77, 94, 71, 214, 1, 76, 62, 77, 242, 180, - 31, 32, 170, 1, 83, 146, 1, 66, 2, 78, 3, 82, 7, 53, 11, 32, 79, 86, 69, - 82, 32, 73, 68, 73, 77, 32, 4, 218, 251, 23, 83, 175, 197, 6, 66, 13, 11, - 73, 11, 11, 32, 8, 162, 123, 71, 204, 236, 11, 31, 79, 86, 69, 82, 32, - 73, 71, 73, 32, 83, 72, 73, 82, 32, 79, 86, 69, 82, 32, 83, 72, 73, 82, - 32, 85, 68, 32, 79, 86, 69, 82, 174, 147, 17, 68, 175, 170, 1, 82, 7, 26, - 32, 203, 183, 31, 50, 2, 169, 72, 4, 84, 73, 77, 69, 13, 26, 32, 175, - 231, 30, 73, 8, 76, 4, 67, 82, 79, 83, 0, 4, 79, 80, 80, 79, 162, 111, - 84, 159, 137, 23, 83, 2, 233, 179, 30, 5, 83, 73, 78, 71, 32, 224, 1, 78, - 65, 146, 15, 73, 242, 1, 85, 158, 73, 69, 245, 175, 23, 4, 87, 85, 51, - 49, 177, 1, 164, 1, 7, 32, 84, 73, 77, 69, 83, 32, 210, 9, 50, 66, 68, - 102, 75, 50, 76, 98, 77, 28, 4, 83, 75, 65, 76, 184, 199, 15, 6, 80, 32, - 69, 76, 65, 77, 191, 224, 15, 66, 134, 1, 170, 1, 65, 94, 66, 82, 69, 30, - 71, 182, 2, 73, 34, 75, 34, 76, 38, 77, 170, 1, 83, 118, 84, 34, 85, 214, - 8, 72, 246, 51, 78, 214, 217, 16, 80, 198, 240, 13, 82, 147, 17, 90, 13, - 46, 68, 158, 133, 31, 78, 165, 44, 2, 83, 72, 5, 229, 50, 7, 32, 80, 76, - 85, 83, 32, 75, 10, 34, 65, 230, 177, 31, 73, 3, 85, 6, 246, 197, 29, 76, - 238, 235, 1, 68, 3, 82, 4, 138, 25, 82, 151, 61, 83, 26, 30, 65, 98, 73, - 147, 1, 85, 11, 38, 82, 206, 123, 78, 139, 181, 30, 76, 5, 249, 21, 10, - 32, 80, 76, 85, 83, 32, 83, 72, 65, 51, 11, 32, 2, 83, 72, 187, 136, 24, - 82, 7, 11, 32, 4, 26, 67, 255, 130, 1, 80, 2, 37, 7, 82, 79, 83, 83, 73, - 78, 71, 2, 217, 202, 27, 2, 32, 71, 7, 134, 181, 27, 82, 135, 250, 3, 68, - 4, 142, 155, 31, 71, 219, 19, 77, 8, 250, 8, 73, 187, 166, 17, 65, 6, - 202, 169, 12, 85, 223, 132, 19, 73, 12, 18, 69, 83, 73, 9, 33, 6, 32, 80, - 76, 85, 83, 32, 6, 226, 136, 31, 68, 150, 14, 84, 255, 2, 71, 5, 45, 9, - 32, 80, 76, 85, 83, 32, 78, 85, 78, 2, 199, 206, 29, 85, 18, 62, 72, 130, - 214, 27, 65, 200, 221, 2, 2, 85, 72, 131, 120, 73, 10, 238, 175, 30, 85, - 142, 54, 73, 162, 70, 65, 3, 69, 4, 138, 243, 30, 65, 223, 56, 85, 17, - 110, 32, 238, 92, 82, 252, 154, 26, 9, 77, 85, 77, 32, 84, 73, 77, 69, - 83, 226, 177, 4, 83, 146, 1, 50, 3, 68, 2, 131, 144, 21, 85, 5, 193, 249, - 11, 11, 32, 67, 82, 79, 83, 83, 73, 78, 71, 32, 75, 10, 42, 53, 218, 169, - 31, 50, 2, 51, 3, 52, 5, 145, 128, 24, 9, 32, 79, 86, 69, 82, 32, 75, 65, - 68, 5, 189, 75, 8, 32, 84, 73, 77, 69, 83, 32, 73, 9, 26, 32, 255, 151, - 31, 65, 4, 166, 105, 84, 157, 195, 23, 9, 67, 82, 79, 83, 83, 73, 78, 71, - 32, 4, 142, 168, 31, 50, 3, 52, 7, 11, 32, 4, 70, 76, 1, 13, 79, 86, 69, - 82, 32, 75, 65, 83, 75, 65, 76, 32, 76, 2, 173, 116, 24, 65, 71, 65, 66, + 34, 76, 66, 79, 138, 3, 83, 90, 84, 254, 237, 5, 86, 198, 54, 80, 166, + 216, 3, 73, 142, 183, 7, 90, 134, 207, 15, 82, 198, 3, 69, 218, 7, 77, 2, + 78, 163, 17, 85, 4, 44, 5, 75, 72, 77, 73, 77, 251, 166, 20, 76, 2, 177, + 1, 4, 73, 67, 32, 75, 10, 92, 12, 89, 80, 84, 79, 71, 82, 65, 77, 77, 73, + 67, 32, 53, 7, 79, 83, 83, 69, 68, 32, 83, 8, 50, 83, 226, 4, 71, 190, + 136, 33, 69, 219, 7, 78, 2, 247, 201, 25, 72, 12, 80, 9, 73, 65, 76, 69, + 67, 84, 45, 80, 32, 224, 130, 33, 2, 65, 76, 175, 17, 69, 8, 130, 222, 9, + 72, 162, 210, 7, 65, 144, 182, 12, 2, 75, 65, 219, 173, 3, 78, 4, 190, 3, + 78, 203, 130, 33, 77, 4, 234, 181, 26, 79, 131, 165, 5, 65, 8, 42, 72, + 250, 228, 29, 65, 219, 173, 3, 83, 4, 206, 146, 33, 69, 219, 19, 73, 4, + 204, 164, 20, 7, 45, 83, 72, 65, 80, 69, 68, 167, 128, 8, 65, 35, 36, 3, + 76, 68, 32, 187, 128, 33, 79, 30, 76, 7, 67, 79, 80, 84, 73, 67, 32, 193, + 1, 7, 78, 85, 66, 73, 65, 78, 32, 22, 98, 71, 42, 72, 188, 1, 2, 83, 72, + 174, 162, 15, 68, 158, 161, 10, 79, 162, 240, 5, 69, 207, 110, 65, 2, 17, + 2, 65, 78, 2, 131, 204, 16, 71, 8, 182, 178, 26, 79, 214, 130, 1, 65, + 227, 218, 5, 69, 8, 50, 78, 220, 145, 17, 2, 83, 72, 167, 165, 5, 87, 4, + 130, 143, 33, 71, 3, 89, 10, 54, 72, 230, 176, 6, 65, 190, 204, 26, 79, + 219, 3, 73, 4, 246, 128, 33, 73, 187, 13, 69, 4, 216, 244, 32, 3, 72, 69, + 84, 167, 8, 65, 14, 62, 75, 30, 77, 2, 80, 22, 83, 165, 223, 28, 3, 84, + 65, 85, 4, 26, 72, 139, 141, 33, 65, 2, 183, 223, 28, 73, 4, 200, 143, + 17, 6, 72, 73, 77, 65, 32, 83, 137, 133, 4, 3, 84, 65, 85, 4, 232, 181, + 25, 3, 76, 69, 70, 225, 152, 2, 4, 82, 73, 71, 72, 6, 96, 6, 78, 73, 83, + 72, 32, 86, 136, 184, 26, 8, 82, 69, 83, 80, 79, 78, 68, 83, 139, 219, 5, + 65, 2, 245, 224, 29, 4, 69, 82, 83, 69, 44, 104, 2, 78, 84, 168, 155, 3, + 6, 67, 72, 32, 65, 78, 68, 237, 250, 28, 8, 80, 76, 69, 32, 87, 73, 84, + 72, 40, 56, 2, 69, 82, 37, 8, 73, 78, 71, 32, 82, 79, 68, 32, 4, 150, + 170, 28, 66, 163, 137, 1, 83, 36, 48, 4, 84, 69, 78, 83, 1, 4, 85, 78, + 73, 84, 18, 173, 201, 24, 2, 32, 68, 53, 74, 65, 38, 69, 76, 5, 73, 67, + 75, 69, 84, 34, 79, 198, 5, 85, 51, 89, 4, 218, 252, 24, 67, 251, 158, 8, + 66, 4, 148, 195, 8, 3, 68, 73, 84, 233, 169, 21, 7, 83, 67, 69, 78, 84, + 32, 77, 5, 237, 235, 27, 3, 32, 66, 65, 28, 84, 2, 83, 83, 176, 237, 30, + 3, 67, 79, 68, 196, 160, 1, 3, 73, 83, 83, 155, 60, 87, 22, 46, 32, 184, + 2, 3, 69, 68, 32, 223, 1, 73, 14, 44, 3, 79, 70, 32, 82, 80, 147, 215, + 32, 77, 4, 216, 166, 29, 6, 74, 69, 82, 85, 83, 65, 245, 214, 2, 5, 76, + 79, 82, 82, 65, 8, 76, 10, 65, 84, 84, 89, 32, 87, 73, 84, 72, 32, 41, 5, + 79, 77, 77, 69, 69, 4, 238, 193, 10, 82, 25, 3, 76, 69, 70, 5, 165, 185, + 3, 11, 32, 87, 73, 84, 72, 32, 72, 65, 76, 70, 45, 6, 224, 243, 25, 37, + 78, 69, 71, 65, 84, 73, 86, 69, 32, 83, 81, 85, 65, 82, 69, 68, 32, 76, + 65, 84, 73, 78, 32, 67, 65, 80, 73, 84, 65, 76, 32, 76, 69, 84, 84, 69, + 82, 196, 226, 2, 2, 70, 76, 133, 219, 2, 3, 83, 87, 79, 2, 177, 225, 31, + 5, 78, 71, 32, 76, 65, 4, 180, 176, 18, 3, 90, 69, 73, 163, 194, 14, 84, + 6, 174, 193, 20, 73, 213, 164, 7, 4, 83, 84, 65, 76, 212, 24, 160, 1, 8, + 78, 69, 73, 70, 79, 82, 77, 32, 194, 144, 2, 80, 114, 82, 180, 3, 2, 83, + 84, 250, 169, 16, 67, 150, 146, 7, 66, 201, 184, 6, 6, 84, 32, 79, 70, + 32, 77, 176, 24, 176, 1, 13, 78, 85, 77, 69, 82, 73, 67, 32, 83, 73, 71, + 78, 32, 208, 42, 17, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 32, 83, + 73, 71, 78, 32, 233, 1, 5, 83, 73, 71, 78, 32, 228, 6, 132, 1, 10, 65, + 83, 72, 32, 84, 73, 77, 69, 83, 32, 246, 1, 69, 174, 2, 70, 216, 5, 2, + 78, 73, 206, 3, 79, 202, 10, 83, 131, 6, 84, 18, 86, 70, 48, 2, 78, 73, + 2, 79, 22, 83, 54, 84, 237, 139, 2, 5, 69, 73, 71, 72, 84, 4, 212, 140, + 2, 2, 73, 86, 13, 3, 79, 85, 82, 2, 167, 140, 2, 78, 4, 156, 140, 2, 4, + 69, 86, 69, 78, 1, 2, 73, 88, 4, 202, 139, 2, 72, 33, 2, 87, 79, 62, 68, + 5, 73, 71, 72, 84, 32, 161, 1, 7, 76, 65, 77, 73, 84, 69, 32, 54, 230, + 25, 78, 218, 1, 83, 198, 5, 65, 226, 114, 85, 130, 51, 71, 236, 55, 17, + 86, 65, 82, 73, 65, 78, 84, 32, 70, 79, 82, 77, 32, 85, 83, 83, 85, 235, + 165, 27, 68, 8, 204, 241, 21, 5, 79, 78, 69, 32, 84, 202, 166, 9, 70, + 175, 14, 84, 192, 1, 52, 4, 73, 86, 69, 32, 153, 2, 4, 79, 85, 82, 32, + 86, 86, 78, 142, 1, 83, 226, 1, 66, 162, 27, 65, 142, 1, 71, 214, 113, + 85, 215, 144, 28, 68, 56, 70, 51, 42, 52, 234, 2, 48, 238, 24, 53, 254, + 3, 49, 219, 209, 12, 50, 8, 154, 34, 52, 154, 232, 32, 53, 3, 54, 4, 138, + 138, 33, 53, 3, 56, 6, 246, 33, 72, 177, 223, 19, 5, 73, 88, 84, 72, 83, + 106, 170, 1, 66, 42, 78, 140, 1, 18, 86, 65, 82, 73, 65, 78, 84, 32, 70, + 79, 82, 77, 32, 76, 73, 77, 77, 85, 238, 25, 65, 142, 1, 71, 226, 3, 83, + 246, 109, 85, 215, 144, 28, 68, 10, 236, 23, 3, 65, 78, 50, 247, 3, 85, + 70, 66, 48, 242, 23, 51, 58, 52, 70, 53, 254, 3, 49, 219, 209, 12, 50, + 18, 138, 31, 49, 2, 52, 154, 232, 32, 50, 2, 51, 2, 53, 2, 54, 3, 56, 9, + 138, 130, 13, 32, 211, 132, 20, 52, 66, 32, 4, 71, 73, 68, 65, 35, 78, 4, + 242, 151, 31, 69, 207, 110, 77, 62, 100, 19, 68, 65, 50, 32, 84, 73, 77, + 69, 83, 32, 83, 72, 69, 32, 80, 76, 85, 83, 32, 81, 2, 69, 32, 4, 40, 3, + 79, 78, 69, 1, 3, 84, 87, 79, 2, 209, 24, 5, 32, 65, 83, 72, 32, 58, 164, + 1, 19, 86, 65, 82, 73, 65, 78, 84, 32, 70, 79, 82, 77, 32, 73, 76, 73, + 77, 77, 85, 138, 15, 78, 218, 1, 83, 198, 5, 65, 226, 114, 85, 130, 51, + 71, 215, 221, 27, 68, 9, 218, 128, 33, 32, 186, 2, 51, 3, 52, 196, 1, 92, + 16, 76, 68, 32, 65, 83, 83, 89, 82, 73, 65, 78, 32, 79, 78, 69, 32, 37, + 3, 78, 69, 32, 4, 142, 161, 19, 83, 251, 215, 11, 81, 192, 1, 170, 1, 69, + 124, 5, 72, 65, 76, 70, 32, 34, 78, 148, 6, 8, 81, 85, 65, 82, 84, 69, + 82, 32, 178, 12, 66, 114, 71, 156, 4, 5, 84, 72, 73, 82, 68, 209, 153, + 25, 2, 83, 72, 8, 44, 6, 73, 71, 72, 84, 72, 32, 143, 20, 83, 6, 240, + 133, 1, 10, 73, 75, 85, 32, 67, 85, 82, 86, 69, 68, 243, 139, 30, 65, 4, + 218, 6, 73, 139, 128, 32, 71, 156, 1, 82, 48, 146, 1, 49, 66, 50, 162, 1, + 51, 210, 1, 52, 182, 17, 53, 179, 188, 25, 54, 28, 94, 49, 202, 21, 52, + 2, 56, 202, 227, 12, 55, 210, 132, 20, 50, 2, 51, 2, 53, 2, 54, 3, 57, 7, + 11, 32, 4, 242, 149, 11, 82, 155, 245, 10, 70, 16, 150, 21, 52, 2, 57, + 154, 232, 32, 49, 2, 50, 2, 53, 3, 56, 36, 102, 57, 30, 56, 214, 19, 50, + 162, 243, 1, 54, 198, 139, 2, 52, 182, 233, 28, 48, 2, 49, 2, 53, 3, 55, + 8, 26, 65, 239, 251, 32, 66, 7, 234, 251, 32, 66, 3, 67, 38, 102, 48, 66, + 52, 146, 18, 54, 202, 227, 12, 57, 210, 132, 20, 49, 2, 50, 2, 51, 2, 53, + 2, 55, 3, 56, 12, 42, 65, 2, 67, 190, 250, 32, 68, 3, 69, 5, 187, 250, + 32, 67, 7, 181, 202, 1, 5, 32, 70, 76, 65, 84, 24, 86, 53, 146, 17, 54, + 202, 227, 12, 50, 210, 132, 20, 48, 2, 49, 2, 55, 2, 56, 3, 57, 7, 194, + 139, 17, 32, 231, 237, 15, 65, 6, 38, 73, 190, 138, 31, 65, 207, 117, 71, + 2, 213, 126, 10, 75, 85, 32, 67, 85, 82, 86, 69, 68, 32, 112, 144, 1, 5, + 69, 86, 69, 78, 32, 196, 1, 20, 72, 65, 82, 50, 32, 84, 73, 77, 69, 83, + 32, 71, 65, 76, 32, 80, 76, 85, 83, 32, 37, 3, 73, 88, 32, 56, 156, 1, + 17, 86, 65, 82, 73, 65, 78, 84, 32, 70, 79, 82, 77, 32, 73, 77, 73, 78, + 230, 1, 78, 218, 1, 83, 198, 5, 65, 226, 114, 85, 130, 51, 71, 215, 221, + 27, 68, 6, 158, 241, 12, 32, 211, 132, 20, 51, 4, 142, 140, 29, 68, 235, + 233, 2, 77, 52, 154, 1, 78, 218, 1, 83, 198, 5, 65, 226, 114, 85, 130, + 51, 71, 180, 199, 27, 16, 86, 65, 82, 73, 65, 78, 84, 32, 70, 79, 82, 77, + 32, 65, 83, 72, 163, 22, 68, 36, 62, 48, 50, 49, 42, 51, 34, 53, 218, + 195, 25, 52, 227, 2, 50, 10, 178, 11, 49, 154, 232, 32, 50, 2, 54, 3, 56, + 10, 130, 11, 52, 2, 57, 155, 232, 32, 56, 6, 218, 10, 52, 155, 232, 32, + 54, 6, 186, 10, 49, 155, 232, 32, 50, 2, 159, 68, 72, 222, 1, 52, 5, 72, + 82, 69, 69, 32, 153, 4, 3, 87, 79, 32, 106, 162, 1, 66, 82, 78, 236, 1, + 4, 83, 72, 65, 82, 24, 16, 86, 65, 82, 73, 65, 78, 84, 32, 70, 79, 82, + 77, 32, 69, 83, 72, 130, 1, 65, 142, 1, 71, 171, 130, 29, 68, 10, 32, 3, + 85, 82, 85, 227, 3, 65, 7, 11, 32, 4, 154, 118, 86, 227, 164, 22, 67, 74, + 62, 51, 58, 52, 70, 53, 166, 3, 48, 90, 49, 219, 209, 12, 50, 12, 154, 7, + 52, 202, 227, 12, 57, 210, 132, 20, 53, 3, 54, 14, 170, 234, 12, 50, 210, + 132, 20, 48, 2, 49, 2, 53, 2, 56, 3, 57, 10, 158, 6, 49, 154, 232, 32, + 48, 2, 50, 3, 52, 8, 246, 115, 50, 3, 85, 4, 154, 189, 25, 49, 203, 3, + 50, 116, 94, 65, 30, 66, 92, 2, 69, 83, 22, 71, 30, 78, 198, 3, 83, 61, + 6, 84, 72, 73, 82, 68, 83, 4, 253, 188, 1, 2, 83, 72, 8, 18, 65, 23, 85, + 4, 37, 2, 78, 50, 4, 17, 2, 82, 85, 5, 11, 32, 2, 243, 150, 23, 67, 2, + 199, 191, 25, 72, 4, 253, 3, 3, 69, 83, 72, 90, 50, 48, 90, 49, 50, 50, + 42, 51, 66, 52, 91, 53, 22, 250, 2, 49, 2, 52, 202, 227, 12, 55, 210, + 132, 20, 50, 2, 51, 2, 53, 2, 54, 3, 56, 12, 162, 2, 52, 2, 57, 154, 232, + 32, 53, 3, 56, 8, 242, 1, 50, 154, 232, 32, 48, 3, 49, 14, 202, 1, 52, + 202, 227, 12, 57, 210, 132, 20, 53, 2, 54, 3, 55, 22, 138, 1, 53, 2, 54, + 202, 227, 12, 50, 210, 132, 20, 48, 2, 49, 2, 55, 2, 56, 3, 57, 12, 50, + 49, 154, 232, 32, 48, 2, 50, 2, 52, 3, 54, 5, 179, 250, 16, 32, 4, 11, + 72, 4, 17, 2, 65, 82, 4, 226, 231, 32, 50, 3, 85, 4, 11, 32, 4, 208, 152, + 28, 12, 86, 65, 82, 73, 65, 78, 84, 32, 70, 79, 82, 77, 175, 101, 68, 10, + 160, 1, 9, 68, 73, 65, 71, 79, 78, 65, 76, 32, 128, 164, 26, 6, 86, 69, + 82, 84, 73, 67, 201, 131, 3, 14, 79, 76, 68, 32, 65, 83, 83, 89, 82, 73, + 65, 78, 32, 87, 6, 208, 145, 29, 2, 84, 82, 228, 131, 3, 4, 81, 85, 65, + 68, 15, 67, 194, 17, 202, 1, 65, 186, 15, 66, 170, 5, 68, 190, 15, 69, + 202, 10, 71, 182, 30, 72, 242, 3, 73, 238, 4, 75, 170, 20, 76, 134, 37, + 77, 134, 6, 78, 230, 17, 80, 210, 3, 82, 42, 83, 238, 19, 84, 186, 8, 85, + 179, 20, 90, 141, 1, 160, 1, 7, 32, 84, 73, 77, 69, 83, 32, 142, 1, 66, + 250, 3, 68, 38, 75, 90, 76, 212, 1, 3, 77, 65, 82, 78, 78, 134, 2, 82, + 42, 83, 238, 215, 31, 80, 215, 127, 50, 16, 168, 173, 1, 5, 76, 65, 71, + 65, 82, 226, 23, 71, 222, 157, 13, 73, 206, 234, 13, 77, 214, 165, 2, 83, + 218, 168, 1, 66, 246, 67, 72, 187, 2, 65, 45, 22, 32, 219, 2, 50, 28, 48, + 6, 84, 73, 77, 69, 83, 32, 163, 203, 1, 71, 26, 180, 1, 2, 71, 65, 38, + 73, 36, 2, 83, 72, 148, 113, 8, 85, 32, 80, 76, 85, 83, 32, 85, 192, 56, + 4, 68, 85, 78, 51, 166, 2, 65, 204, 2, 3, 78, 85, 78, 242, 27, 76, 203, + 145, 31, 72, 4, 190, 210, 1, 78, 191, 140, 31, 76, 4, 234, 169, 1, 71, + 155, 181, 30, 77, 4, 186, 177, 25, 85, 219, 190, 5, 69, 15, 37, 7, 32, + 84, 73, 77, 69, 83, 32, 12, 226, 133, 1, 77, 134, 59, 71, 194, 9, 83, + 206, 10, 84, 228, 153, 29, 2, 66, 65, 147, 239, 1, 65, 5, 249, 51, 5, 32, + 84, 73, 77, 69, 7, 37, 7, 32, 84, 73, 77, 69, 83, 32, 4, 252, 27, 5, 83, + 72, 73, 84, 65, 235, 80, 69, 23, 68, 7, 32, 84, 73, 77, 69, 83, 32, 142, + 163, 26, 69, 219, 232, 5, 65, 16, 102, 75, 180, 173, 1, 2, 68, 73, 238, + 195, 27, 71, 158, 251, 1, 85, 210, 98, 65, 198, 94, 83, 215, 42, 72, 4, + 154, 158, 1, 65, 195, 188, 31, 73, 7, 37, 7, 32, 84, 73, 77, 69, 83, 32, + 4, 138, 251, 3, 75, 251, 177, 28, 83, 13, 26, 32, 199, 172, 32, 83, 8, + 128, 1, 10, 80, 76, 85, 83, 32, 78, 65, 71, 65, 32, 196, 191, 8, 7, 84, + 72, 82, 69, 69, 32, 84, 249, 163, 6, 4, 79, 86, 69, 82, 4, 168, 140, 1, + 16, 79, 80, 80, 79, 83, 73, 78, 71, 32, 65, 78, 32, 80, 76, 85, 83, 243, + 134, 24, 83, 6, 200, 49, 2, 65, 68, 207, 230, 18, 75, 18, 26, 72, 163, + 202, 12, 65, 17, 42, 32, 170, 151, 19, 71, 211, 191, 13, 50, 10, 68, 9, + 79, 86, 69, 82, 32, 65, 83, 72, 32, 194, 97, 90, 239, 111, 75, 6, 176, 1, + 8, 79, 86, 69, 82, 32, 65, 83, 72, 181, 143, 1, 29, 84, 85, 71, 50, 32, + 79, 86, 69, 82, 32, 84, 85, 71, 50, 32, 84, 85, 71, 50, 32, 79, 86, 69, + 82, 32, 84, 85, 71, 50, 5, 173, 145, 1, 27, 32, 67, 82, 79, 83, 83, 73, + 78, 71, 32, 65, 83, 72, 32, 79, 86, 69, 82, 32, 65, 83, 72, 32, 79, 86, + 69, 82, 52, 30, 65, 158, 2, 73, 95, 85, 27, 66, 68, 44, 4, 72, 65, 82, + 50, 90, 76, 66, 82, 183, 209, 28, 71, 5, 161, 208, 1, 6, 32, 84, 73, 77, + 69, 83, 9, 37, 7, 32, 84, 73, 77, 69, 83, 32, 6, 134, 165, 1, 65, 230, + 153, 31, 78, 163, 17, 90, 7, 180, 198, 31, 7, 32, 79, 86, 69, 82, 32, 66, + 139, 139, 1, 65, 5, 219, 164, 25, 65, 9, 37, 7, 32, 84, 73, 77, 69, 83, + 32, 6, 158, 156, 1, 73, 254, 144, 30, 71, 255, 163, 1, 65, 19, 50, 32, + 168, 1, 3, 76, 85, 71, 135, 170, 1, 82, 8, 88, 8, 79, 86, 69, 82, 32, 66, + 85, 32, 141, 149, 28, 8, 67, 82, 79, 83, 83, 73, 78, 71, 6, 184, 236, 12, + 7, 84, 73, 77, 69, 83, 32, 78, 158, 162, 18, 65, 159, 113, 85, 5, 245, + 239, 3, 8, 32, 79, 86, 69, 82, 32, 66, 85, 180, 1, 34, 65, 222, 5, 73, + 195, 2, 85, 67, 50, 71, 150, 5, 82, 146, 49, 32, 215, 151, 32, 77, 55, + 26, 32, 223, 205, 32, 51, 50, 76, 13, 75, 73, 83, 73, 77, 53, 32, 84, 73, + 77, 69, 83, 32, 223, 198, 1, 84, 48, 146, 1, 65, 30, 66, 38, 71, 112, 2, + 73, 82, 42, 76, 94, 85, 206, 131, 1, 80, 134, 61, 84, 242, 203, 28, 75, + 178, 166, 2, 78, 254, 2, 83, 163, 17, 72, 4, 110, 32, 143, 167, 31, 77, + 4, 202, 220, 30, 65, 147, 239, 1, 73, 10, 34, 65, 58, 73, 191, 132, 32, + 85, 5, 11, 32, 2, 217, 220, 30, 6, 80, 76, 85, 83, 32, 77, 5, 227, 157, + 25, 82, 5, 249, 173, 14, 5, 32, 80, 76, 85, 83, 8, 26, 85, 135, 202, 32, + 65, 7, 184, 151, 1, 7, 32, 80, 76, 85, 83, 32, 77, 203, 178, 31, 77, 6, + 52, 7, 50, 32, 80, 76, 85, 83, 32, 255, 199, 32, 83, 4, 128, 27, 2, 71, + 73, 223, 191, 30, 77, 7, 211, 231, 12, 65, 25, 54, 77, 150, 1, 78, 76, 2, + 83, 72, 187, 198, 32, 66, 13, 44, 7, 32, 84, 73, 77, 69, 83, 32, 59, 50, + 6, 224, 69, 2, 85, 32, 226, 130, 14, 73, 155, 210, 17, 83, 5, 189, 196, + 13, 6, 32, 84, 73, 77, 69, 83, 5, 185, 190, 19, 14, 32, 75, 65, 83, 75, + 65, 76, 32, 85, 32, 71, 85, 78, 85, 5, 141, 158, 1, 5, 32, 80, 76, 85, + 83, 91, 70, 32, 66, 66, 94, 71, 234, 4, 78, 206, 146, 25, 82, 251, 172, + 7, 72, 6, 178, 176, 1, 71, 170, 3, 83, 149, 243, 12, 4, 79, 86, 69, 82, + 9, 52, 7, 32, 84, 73, 77, 69, 83, 32, 211, 196, 32, 50, 4, 146, 146, 1, + 69, 179, 133, 31, 83, 61, 52, 7, 32, 84, 73, 77, 69, 83, 32, 215, 253, + 31, 85, 56, 122, 65, 58, 68, 30, 71, 74, 75, 90, 76, 110, 77, 50, 83, + 150, 80, 69, 222, 58, 73, 146, 148, 17, 72, 146, 141, 14, 78, 3, 80, 6, + 32, 2, 83, 72, 191, 149, 32, 78, 5, 151, 253, 14, 32, 4, 222, 242, 31, + 73, 3, 85, 8, 26, 73, 139, 194, 32, 65, 7, 164, 141, 1, 2, 82, 50, 211, + 179, 31, 83, 8, 26, 85, 207, 185, 1, 65, 6, 40, 4, 83, 72, 85, 50, 151, + 193, 32, 82, 5, 175, 26, 32, 8, 26, 65, 45, 2, 85, 72, 6, 202, 26, 77, + 213, 247, 24, 3, 75, 45, 48, 2, 229, 57, 5, 32, 80, 76, 85, 83, 6, 246, + 209, 30, 65, 198, 176, 1, 69, 223, 61, 73, 4, 134, 139, 1, 73, 143, 158, + 31, 72, 11, 26, 51, 171, 191, 32, 52, 7, 143, 9, 32, 117, 130, 1, 32, 90, + 50, 210, 1, 78, 202, 1, 82, 60, 3, 83, 72, 50, 52, 3, 90, 69, 78, 154, + 176, 19, 71, 202, 137, 12, 68, 215, 127, 76, 4, 168, 25, 11, 79, 86, 69, + 82, 32, 69, 32, 78, 85, 78, 32, 149, 95, 4, 84, 73, 77, 69, 19, 37, 7, + 32, 84, 73, 77, 69, 83, 32, 16, 134, 1, 83, 168, 168, 1, 10, 65, 32, 80, + 76, 85, 83, 32, 72, 65, 32, 234, 239, 29, 71, 246, 16, 80, 182, 26, 75, + 254, 100, 77, 219, 19, 85, 4, 186, 176, 31, 65, 255, 116, 72, 15, 11, 32, + 12, 96, 4, 67, 82, 79, 83, 0, 4, 79, 80, 80, 79, 36, 6, 84, 73, 77, 69, + 83, 32, 171, 245, 24, 83, 2, 249, 192, 14, 4, 83, 73, 78, 71, 6, 228, + 138, 1, 4, 71, 65, 78, 50, 159, 153, 31, 77, 6, 36, 3, 73, 78, 50, 159, + 234, 31, 69, 5, 187, 171, 31, 32, 5, 229, 16, 9, 32, 67, 82, 79, 83, 83, + 73, 78, 71, 63, 11, 32, 60, 96, 14, 83, 72, 69, 83, 72, 73, 71, 32, 84, + 73, 77, 69, 83, 32, 97, 6, 84, 73, 77, 69, 83, 32, 16, 202, 131, 1, 73, + 226, 221, 2, 77, 250, 232, 26, 65, 244, 113, 2, 76, 65, 198, 87, 83, 147, + 17, 72, 44, 134, 1, 65, 68, 5, 68, 85, 78, 51, 32, 26, 75, 58, 76, 62, + 83, 34, 85, 246, 127, 73, 204, 31, 2, 72, 65, 254, 230, 29, 71, 135, 104, + 66, 9, 136, 87, 9, 32, 80, 76, 85, 83, 32, 76, 65, 76, 211, 223, 31, 78, + 4, 217, 32, 2, 71, 85, 6, 184, 240, 24, 5, 65, 83, 75, 65, 76, 167, 197, + 3, 85, 8, 34, 65, 166, 181, 32, 73, 3, 85, 5, 221, 85, 2, 76, 32, 4, 182, + 158, 32, 72, 215, 22, 85, 4, 234, 180, 32, 50, 3, 68, 160, 2, 42, 65, + 166, 19, 69, 122, 73, 135, 5, 85, 191, 1, 114, 50, 144, 16, 2, 66, 65, + 94, 68, 22, 76, 38, 78, 230, 140, 1, 32, 254, 5, 82, 238, 246, 28, 83, + 187, 152, 2, 77, 153, 1, 11, 32, 150, 1, 68, 6, 84, 73, 77, 69, 83, 32, + 177, 128, 1, 5, 79, 86, 69, 82, 32, 148, 1, 202, 1, 65, 162, 2, 66, 154, + 1, 68, 178, 1, 69, 58, 71, 178, 1, 72, 230, 1, 73, 70, 75, 194, 1, 76, + 62, 77, 50, 78, 130, 1, 83, 142, 1, 85, 218, 154, 1, 84, 252, 219, 23, 3, + 90, 73, 90, 195, 170, 7, 80, 18, 132, 1, 6, 32, 80, 76, 85, 83, 32, 50, + 78, 52, 2, 83, 72, 193, 239, 18, 14, 66, 50, 32, 84, 69, 78, 85, 32, 80, + 76, 85, 83, 32, 84, 6, 222, 58, 68, 242, 245, 13, 73, 239, 252, 17, 72, + 5, 205, 61, 9, 32, 80, 76, 85, 83, 32, 75, 65, 75, 7, 11, 50, 5, 153, 90, + 6, 32, 80, 76, 85, 83, 32, 10, 26, 65, 77, 2, 85, 82, 6, 42, 72, 44, 2, + 82, 32, 235, 173, 32, 68, 2, 11, 65, 2, 143, 129, 25, 82, 5, 11, 32, 2, + 141, 227, 31, 4, 80, 76, 85, 83, 14, 34, 73, 54, 85, 239, 172, 32, 65, 7, + 17, 2, 77, 32, 4, 146, 22, 84, 231, 129, 1, 71, 6, 56, 8, 71, 32, 84, 73, + 77, 69, 83, 32, 179, 172, 32, 66, 4, 182, 119, 73, 251, 44, 75, 10, 38, + 78, 254, 2, 76, 223, 207, 30, 82, 5, 247, 28, 32, 18, 18, 65, 99, 73, 11, + 26, 82, 243, 158, 1, 78, 7, 33, 6, 32, 80, 76, 85, 83, 32, 4, 178, 148, + 32, 78, 255, 2, 68, 9, 198, 122, 52, 221, 146, 13, 7, 82, 50, 32, 80, 76, + 85, 83, 12, 62, 65, 178, 124, 85, 201, 144, 13, 6, 73, 32, 80, 76, 85, + 83, 8, 40, 6, 32, 80, 76, 85, 83, 32, 83, 76, 4, 48, 6, 76, 85, 32, 80, + 76, 85, 143, 169, 32, 65, 2, 11, 83, 2, 239, 97, 32, 5, 141, 140, 14, 5, + 32, 80, 76, 85, 83, 4, 200, 100, 10, 83, 72, 32, 80, 76, 85, 83, 32, 72, + 85, 147, 15, 71, 12, 34, 65, 36, 2, 73, 68, 27, 85, 4, 142, 166, 25, 83, + 211, 129, 7, 75, 5, 245, 77, 2, 32, 80, 4, 60, 5, 83, 72, 85, 50, 32, + 221, 127, 5, 51, 32, 80, 76, 85, 2, 201, 158, 1, 3, 80, 76, 85, 8, 26, + 65, 155, 165, 32, 85, 7, 11, 77, 5, 223, 159, 1, 32, 6, 142, 78, 69, 218, + 233, 29, 85, 163, 238, 1, 73, 10, 26, 69, 73, 2, 85, 78, 7, 33, 6, 32, + 80, 76, 85, 83, 32, 4, 158, 248, 24, 69, 163, 153, 7, 71, 5, 11, 32, 2, + 211, 101, 79, 14, 42, 72, 154, 175, 24, 65, 191, 228, 7, 85, 8, 18, 69, + 51, 73, 5, 193, 171, 31, 7, 32, 80, 76, 85, 83, 32, 84, 4, 230, 163, 32, + 68, 3, 77, 7, 11, 68, 5, 229, 132, 14, 5, 32, 80, 76, 85, 83, 7, 11, 32, + 4, 162, 193, 30, 82, 193, 180, 1, 11, 67, 82, 79, 83, 83, 73, 78, 71, 32, + 71, 65, 5, 215, 131, 1, 32, 7, 158, 131, 1, 32, 179, 142, 31, 65, 11, 11, + 50, 9, 11, 32, 6, 80, 8, 67, 82, 79, 83, 83, 73, 78, 71, 0, 4, 79, 86, + 69, 82, 227, 148, 27, 84, 2, 217, 49, 3, 32, 71, 65, 8, 44, 5, 83, 72, + 84, 73, 78, 215, 243, 24, 50, 7, 37, 7, 32, 84, 73, 77, 69, 83, 32, 4, + 206, 167, 31, 75, 215, 120, 85, 49, 70, 32, 94, 52, 114, 82, 190, 1, 83, + 230, 153, 31, 68, 211, 130, 1, 71, 6, 172, 131, 9, 6, 84, 73, 77, 69, 83, + 32, 221, 156, 5, 8, 67, 82, 79, 83, 83, 73, 78, 71, 7, 11, 32, 4, 64, 8, + 67, 82, 79, 83, 83, 73, 78, 71, 1, 4, 79, 86, 69, 82, 2, 241, 239, 24, 3, + 32, 71, 73, 16, 26, 51, 171, 136, 1, 50, 13, 37, 7, 32, 84, 73, 77, 69, + 83, 32, 10, 70, 65, 0, 2, 76, 85, 230, 127, 71, 222, 157, 13, 73, 239, + 252, 17, 80, 2, 189, 157, 14, 7, 32, 80, 76, 85, 83, 32, 73, 14, 26, 72, + 203, 144, 31, 65, 13, 11, 32, 10, 22, 84, 251, 20, 67, 8, 44, 5, 73, 77, + 69, 83, 32, 211, 246, 31, 69, 6, 196, 20, 6, 71, 73, 83, 72, 32, 67, 138, + 126, 84, 203, 194, 30, 66, 43, 110, 50, 174, 1, 68, 218, 1, 77, 54, 82, + 156, 154, 14, 9, 32, 67, 82, 79, 83, 83, 73, 78, 71, 191, 252, 17, 76, + 15, 11, 32, 12, 48, 6, 84, 73, 77, 69, 83, 32, 191, 132, 1, 71, 10, 128, + 25, 3, 75, 65, 75, 214, 75, 73, 152, 20, 10, 83, 65, 76, 32, 80, 76, 85, + 83, 32, 84, 179, 160, 30, 78, 11, 11, 32, 8, 128, 1, 10, 80, 76, 85, 83, + 32, 71, 73, 83, 72, 32, 16, 6, 84, 73, 77, 69, 83, 32, 197, 66, 8, 79, + 86, 69, 82, 32, 71, 85, 68, 2, 159, 121, 84, 4, 168, 145, 1, 5, 65, 32, + 80, 76, 85, 199, 141, 30, 75, 5, 17, 2, 32, 84, 2, 133, 43, 4, 73, 77, + 69, 83, 9, 26, 85, 191, 150, 32, 55, 4, 170, 149, 32, 83, 147, 1, 78, 50, + 30, 65, 86, 73, 215, 1, 85, 11, 26, 32, 227, 149, 32, 76, 6, 32, 2, 84, + 69, 171, 128, 1, 71, 4, 131, 128, 1, 78, 23, 37, 7, 32, 84, 73, 77, 69, + 83, 32, 20, 104, 3, 65, 83, 72, 218, 170, 28, 68, 142, 233, 2, 78, 94, + 75, 170, 57, 66, 2, 71, 162, 25, 83, 143, 45, 85, 7, 240, 55, 8, 32, 79, + 86, 69, 82, 32, 72, 73, 163, 220, 31, 50, 19, 48, 2, 66, 50, 170, 230, + 24, 76, 235, 171, 7, 83, 13, 37, 7, 32, 84, 73, 77, 69, 83, 32, 10, 246, + 138, 1, 75, 198, 158, 27, 76, 226, 221, 2, 72, 254, 59, 65, 195, 9, 85, + 49, 104, 3, 68, 73, 77, 94, 71, 214, 1, 76, 62, 77, 158, 140, 32, 32, + 170, 1, 83, 146, 1, 66, 2, 78, 3, 82, 7, 53, 11, 32, 79, 86, 69, 82, 32, + 73, 68, 73, 77, 32, 4, 214, 203, 24, 83, 223, 204, 6, 66, 13, 11, 73, 11, + 11, 32, 8, 182, 123, 71, 164, 146, 12, 31, 79, 86, 69, 82, 32, 73, 71, + 73, 32, 83, 72, 73, 82, 32, 79, 86, 69, 82, 32, 83, 72, 73, 82, 32, 85, + 68, 32, 79, 86, 69, 82, 234, 193, 17, 68, 179, 173, 1, 82, 7, 26, 32, + 247, 142, 32, 50, 2, 189, 72, 4, 84, 73, 77, 69, 13, 26, 32, 219, 190, + 31, 73, 8, 76, 4, 67, 82, 79, 83, 0, 4, 79, 80, 80, 79, 182, 111, 84, + 135, 217, 23, 83, 2, 149, 139, 31, 5, 83, 73, 78, 71, 32, 224, 1, 78, 65, + 146, 15, 73, 242, 1, 85, 178, 73, 69, 213, 129, 24, 4, 87, 85, 51, 49, + 177, 1, 164, 1, 7, 32, 84, 73, 77, 69, 83, 32, 210, 9, 50, 66, 68, 102, + 75, 50, 76, 98, 77, 28, 4, 83, 75, 65, 76, 196, 144, 16, 6, 80, 32, 69, + 76, 65, 77, 223, 238, 15, 66, 134, 1, 170, 1, 65, 94, 66, 82, 69, 30, 71, + 182, 2, 73, 34, 75, 34, 76, 38, 77, 170, 1, 83, 118, 84, 34, 85, 214, 8, + 72, 138, 52, 78, 178, 165, 17, 80, 130, 252, 13, 82, 147, 17, 90, 13, 46, + 68, 202, 220, 31, 78, 165, 44, 2, 83, 72, 5, 245, 50, 7, 32, 80, 76, 85, + 83, 32, 75, 10, 34, 65, 146, 137, 32, 73, 3, 85, 6, 138, 154, 30, 76, + 134, 239, 1, 68, 3, 82, 4, 154, 25, 82, 155, 61, 83, 26, 30, 65, 98, 73, + 147, 1, 85, 11, 38, 82, 198, 123, 78, 191, 140, 31, 76, 5, 137, 22, 10, + 32, 80, 76, 85, 83, 32, 83, 72, 65, 51, 11, 32, 2, 83, 72, 175, 218, 24, + 82, 7, 11, 32, 4, 26, 67, 247, 130, 1, 80, 2, 37, 7, 82, 79, 83, 83, 73, + 78, 71, 2, 149, 157, 28, 2, 32, 71, 7, 238, 134, 28, 82, 203, 255, 3, 68, + 4, 186, 242, 31, 71, 219, 19, 77, 8, 250, 8, 73, 171, 242, 17, 65, 6, + 182, 207, 12, 85, 159, 182, 19, 73, 12, 18, 69, 83, 73, 9, 33, 6, 32, 80, + 76, 85, 83, 32, 6, 142, 224, 31, 68, 150, 14, 84, 255, 2, 71, 5, 45, 9, + 32, 80, 76, 85, 83, 32, 78, 85, 78, 2, 227, 162, 30, 85, 18, 62, 72, 190, + 168, 28, 65, 184, 226, 2, 2, 85, 72, 131, 120, 73, 10, 154, 135, 31, 85, + 142, 54, 73, 162, 70, 65, 3, 69, 4, 182, 202, 31, 65, 223, 56, 85, 17, + 110, 32, 130, 93, 82, 168, 236, 26, 9, 77, 85, 77, 32, 84, 73, 77, 69, + 83, 206, 183, 4, 83, 146, 1, 50, 3, 68, 2, 231, 223, 21, 85, 5, 213, 158, + 12, 11, 32, 67, 82, 79, 83, 83, 73, 78, 71, 32, 75, 10, 42, 53, 134, 129, + 32, 50, 2, 51, 3, 52, 5, 133, 210, 24, 9, 32, 79, 86, 69, 82, 32, 75, 65, + 68, 5, 209, 75, 8, 32, 84, 73, 77, 69, 83, 32, 73, 9, 26, 32, 171, 239, + 31, 65, 4, 186, 105, 84, 245, 148, 24, 9, 67, 82, 79, 83, 83, 73, 78, 71, + 32, 4, 186, 255, 31, 50, 3, 52, 7, 11, 32, 4, 70, 76, 1, 13, 79, 86, 69, + 82, 32, 75, 65, 83, 75, 65, 76, 32, 76, 2, 165, 116, 24, 65, 71, 65, 66, 32, 84, 73, 77, 69, 83, 32, 85, 32, 79, 86, 69, 82, 32, 76, 65, 71, 65, - 66, 32, 21, 68, 7, 32, 84, 73, 77, 69, 83, 32, 50, 83, 186, 165, 31, 68, - 3, 78, 6, 26, 85, 163, 223, 30, 66, 5, 203, 165, 31, 68, 8, 52, 3, 73, - 77, 53, 178, 153, 30, 65, 211, 139, 1, 72, 5, 185, 251, 23, 11, 32, 79, + 66, 32, 21, 68, 7, 32, 84, 73, 77, 69, 83, 32, 50, 83, 230, 252, 31, 68, + 3, 78, 6, 26, 85, 207, 182, 31, 66, 5, 247, 252, 31, 68, 8, 52, 3, 73, + 77, 53, 222, 240, 30, 65, 211, 139, 1, 72, 5, 173, 205, 24, 11, 32, 79, 86, 69, 82, 32, 75, 73, 83, 73, 77, 25, 200, 1, 29, 32, 79, 86, 69, 82, 32, 72, 73, 32, 84, 73, 77, 69, 83, 32, 65, 83, 72, 50, 32, 75, 85, 32, - 79, 86, 69, 82, 32, 72, 18, 52, 54, 82, 186, 98, 83, 230, 1, 76, 150, - 190, 30, 51, 2, 55, 3, 78, 2, 155, 71, 73, 5, 129, 164, 30, 8, 32, 86, - 65, 82, 73, 65, 78, 84, 5, 213, 115, 9, 32, 79, 80, 80, 79, 83, 73, 78, - 71, 240, 2, 30, 65, 174, 26, 73, 59, 85, 141, 2, 68, 2, 71, 65, 252, 12, - 2, 75, 45, 222, 11, 76, 46, 77, 135, 55, 72, 118, 22, 66, 131, 11, 82, - 109, 11, 32, 106, 48, 6, 84, 73, 77, 69, 83, 32, 183, 226, 23, 83, 104, - 190, 1, 65, 186, 1, 66, 34, 71, 70, 72, 66, 73, 94, 75, 118, 76, 46, 77, - 46, 83, 138, 2, 84, 126, 85, 232, 167, 4, 8, 90, 85, 32, 79, 86, 69, 82, - 32, 202, 203, 25, 68, 222, 83, 69, 143, 57, 78, 15, 80, 6, 32, 80, 76, - 85, 83, 32, 76, 4, 83, 72, 32, 90, 214, 157, 31, 76, 3, 78, 6, 38, 68, - 190, 250, 29, 71, 227, 23, 76, 2, 201, 62, 5, 65, 32, 80, 76, 85, 2, 149, - 112, 2, 73, 68, 4, 154, 215, 30, 65, 163, 70, 73, 10, 48, 2, 85, 68, 206, - 198, 27, 65, 159, 214, 3, 73, 5, 191, 105, 32, 6, 128, 240, 17, 7, 73, - 32, 84, 73, 77, 69, 83, 171, 176, 12, 65, 8, 22, 77, 175, 62, 71, 7, 33, - 6, 32, 80, 76, 85, 83, 32, 4, 242, 246, 30, 76, 179, 34, 72, 10, 26, 85, - 183, 157, 29, 73, 6, 26, 76, 135, 155, 31, 51, 5, 41, 8, 32, 80, 76, 85, - 83, 32, 72, 73, 2, 219, 65, 32, 8, 198, 100, 65, 250, 202, 28, 73, 223, - 110, 85, 6, 26, 69, 251, 174, 29, 85, 5, 175, 25, 32, 12, 26, 72, 255, - 136, 31, 85, 10, 100, 14, 73, 84, 65, 32, 80, 76, 85, 83, 32, 71, 73, 83, - 72, 32, 96, 2, 85, 50, 217, 3, 2, 69, 32, 4, 48, 6, 80, 76, 85, 83, 32, - 69, 243, 145, 26, 84, 2, 11, 82, 2, 11, 73, 2, 223, 240, 23, 78, 5, 189, - 73, 5, 32, 80, 76, 85, 83, 6, 86, 65, 189, 30, 16, 69, 32, 80, 76, 85, - 83, 32, 65, 32, 80, 76, 85, 83, 32, 83, 85, 4, 170, 238, 23, 75, 231, - 168, 7, 71, 13, 72, 6, 32, 80, 76, 85, 83, 32, 190, 41, 50, 214, 235, 30, - 83, 147, 1, 68, 4, 26, 85, 135, 150, 31, 65, 2, 255, 40, 32, 11, 11, 32, - 8, 68, 4, 71, 85, 78, 85, 97, 9, 84, 73, 77, 69, 83, 32, 83, 72, 69, 5, - 73, 16, 32, 79, 86, 69, 82, 32, 76, 65, 71, 65, 82, 32, 71, 85, 78, 85, - 2, 187, 231, 30, 32, 5, 11, 32, 2, 201, 202, 14, 4, 80, 76, 85, 83, 136, - 1, 82, 48, 146, 2, 49, 30, 50, 114, 51, 82, 52, 222, 2, 54, 154, 4, 55, - 243, 24, 53, 22, 158, 1, 50, 30, 56, 180, 52, 15, 55, 57, 32, 79, 86, 69, - 82, 32, 76, 65, 75, 45, 48, 55, 57, 254, 246, 10, 53, 142, 191, 12, 54, - 2, 57, 94, 51, 139, 172, 3, 48, 4, 150, 146, 31, 49, 3, 53, 4, 152, 234, - 23, 12, 49, 32, 79, 86, 69, 82, 32, 76, 65, 75, 45, 48, 227, 167, 7, 48, - 4, 230, 233, 23, 52, 95, 51, 16, 46, 50, 38, 54, 238, 226, 23, 49, 159, - 2, 51, 6, 218, 144, 31, 48, 2, 53, 3, 56, 4, 182, 144, 31, 53, 3, 54, 12, - 42, 52, 250, 224, 11, 56, 151, 136, 12, 57, 6, 238, 143, 31, 51, 2, 55, - 3, 56, 30, 62, 52, 214, 1, 53, 30, 57, 186, 230, 23, 55, 139, 172, 3, 56, - 14, 26, 57, 243, 142, 31, 49, 13, 37, 7, 32, 84, 73, 77, 69, 83, 32, 10, - 116, 9, 80, 65, 80, 32, 80, 76, 85, 83, 32, 140, 158, 13, 7, 85, 50, 32, - 80, 76, 85, 83, 218, 31, 73, 135, 171, 17, 71, 4, 210, 13, 80, 51, 76, 4, - 182, 141, 31, 48, 3, 55, 8, 154, 141, 31, 48, 2, 50, 2, 51, 3, 53, 46, - 60, 2, 49, 55, 240, 1, 2, 52, 56, 146, 223, 23, 48, 23, 51, 23, 37, 7, - 32, 84, 73, 77, 69, 83, 32, 20, 122, 84, 34, 85, 162, 11, 75, 132, 34, 9, - 68, 85, 78, 51, 32, 71, 85, 78, 85, 194, 242, 28, 65, 222, 164, 1, 66, - 247, 67, 76, 4, 174, 210, 30, 65, 223, 56, 69, 6, 222, 205, 14, 82, 142, - 189, 16, 50, 3, 68, 21, 37, 7, 32, 84, 73, 77, 69, 83, 32, 18, 154, 1, - 85, 220, 8, 4, 80, 65, 80, 32, 146, 45, 73, 224, 225, 12, 10, 83, 72, 69, - 83, 72, 32, 80, 76, 85, 83, 178, 128, 5, 68, 170, 221, 12, 78, 163, 17, - 71, 4, 238, 203, 14, 82, 143, 189, 16, 68, 4, 242, 223, 23, 50, 207, 174, - 3, 52, 5, 11, 32, 2, 145, 6, 4, 84, 73, 77, 69, 7, 49, 10, 32, 84, 73, - 77, 69, 83, 32, 75, 85, 82, 5, 221, 207, 11, 5, 32, 80, 76, 85, 83, 9, - 200, 207, 11, 2, 77, 77, 210, 182, 19, 83, 147, 1, 76, 93, 90, 50, 212, - 7, 3, 71, 65, 76, 142, 1, 77, 130, 62, 32, 186, 191, 30, 51, 2, 72, 3, - 76, 69, 11, 32, 66, 88, 4, 67, 82, 79, 83, 0, 4, 79, 80, 80, 79, 44, 4, - 71, 85, 78, 85, 38, 83, 35, 84, 2, 205, 205, 11, 6, 83, 73, 78, 71, 32, - 76, 2, 193, 24, 5, 32, 84, 73, 77, 69, 6, 250, 68, 72, 243, 129, 23, 81, - 54, 44, 5, 73, 77, 69, 83, 32, 159, 223, 30, 69, 52, 188, 1, 4, 69, 83, - 72, 50, 94, 72, 42, 75, 68, 2, 76, 65, 34, 77, 60, 3, 80, 65, 80, 118, - 83, 90, 84, 250, 56, 71, 250, 250, 7, 78, 166, 230, 18, 68, 254, 216, 2, - 65, 166, 69, 66, 215, 53, 73, 7, 11, 32, 4, 26, 80, 227, 251, 25, 84, 2, - 17, 2, 76, 85, 2, 181, 246, 29, 3, 83, 32, 76, 4, 184, 66, 2, 73, 32, - 235, 179, 29, 65, 8, 32, 2, 65, 68, 171, 129, 31, 73, 6, 226, 19, 51, - 199, 237, 30, 50, 4, 174, 20, 32, 183, 183, 17, 71, 2, 11, 69, 2, 11, 32, - 2, 249, 181, 13, 4, 80, 76, 85, 83, 5, 11, 32, 2, 33, 6, 80, 76, 85, 83, - 32, 80, 2, 45, 9, 65, 80, 32, 80, 76, 85, 83, 32, 76, 2, 239, 132, 27, - 85, 6, 26, 73, 183, 218, 30, 72, 4, 194, 18, 32, 253, 183, 26, 7, 75, 50, - 32, 80, 76, 85, 83, 4, 162, 53, 85, 139, 24, 65, 9, 11, 32, 6, 22, 79, - 207, 67, 83, 4, 56, 7, 80, 80, 79, 83, 73, 78, 71, 1, 3, 86, 69, 82, 2, - 21, 3, 32, 76, 85, 2, 239, 241, 29, 71, 7, 45, 9, 32, 79, 86, 69, 82, 32, - 76, 85, 77, 5, 187, 59, 32, 70, 34, 65, 70, 69, 22, 73, 71, 85, 17, 170, - 45, 32, 188, 1, 2, 83, 72, 238, 205, 30, 50, 2, 72, 3, 82, 7, 175, 235, - 26, 83, 7, 244, 129, 27, 8, 32, 80, 76, 85, 83, 32, 90, 65, 135, 250, 3, - 78, 43, 104, 2, 83, 72, 186, 60, 71, 140, 134, 11, 5, 32, 79, 86, 69, 82, - 40, 2, 82, 71, 225, 198, 6, 2, 78, 83, 31, 22, 32, 183, 2, 51, 16, 136, + 79, 86, 69, 82, 32, 72, 18, 52, 70, 82, 190, 98, 83, 230, 1, 76, 174, + 149, 31, 51, 2, 55, 3, 78, 2, 175, 71, 73, 5, 11, 32, 2, 11, 86, 2, 149, + 251, 30, 6, 65, 82, 73, 65, 78, 84, 5, 189, 115, 9, 32, 79, 80, 80, 79, + 83, 73, 78, 71, 240, 2, 30, 65, 174, 26, 73, 59, 85, 141, 2, 68, 2, 71, + 65, 252, 12, 2, 75, 45, 222, 11, 76, 46, 77, 139, 55, 72, 118, 22, 66, + 131, 11, 82, 109, 11, 32, 106, 48, 6, 84, 73, 77, 69, 83, 32, 163, 178, + 24, 83, 104, 190, 1, 65, 186, 1, 66, 34, 71, 70, 72, 66, 73, 94, 75, 118, + 76, 46, 77, 46, 83, 138, 2, 84, 126, 85, 252, 168, 4, 8, 90, 85, 32, 79, + 86, 69, 82, 32, 146, 161, 26, 68, 158, 84, 69, 143, 57, 78, 15, 80, 6, + 32, 80, 76, 85, 83, 32, 76, 4, 83, 72, 32, 90, 242, 244, 31, 76, 3, 78, + 6, 38, 68, 154, 209, 30, 71, 163, 24, 76, 2, 205, 62, 5, 65, 32, 80, 76, + 85, 2, 253, 111, 2, 73, 68, 4, 182, 174, 31, 65, 163, 70, 73, 10, 48, 2, + 85, 68, 250, 152, 28, 65, 143, 219, 3, 73, 5, 167, 105, 32, 6, 240, 188, + 18, 7, 73, 32, 84, 73, 77, 69, 83, 215, 186, 12, 65, 8, 22, 77, 179, 62, + 71, 7, 33, 6, 32, 80, 76, 85, 83, 32, 4, 142, 206, 31, 76, 179, 34, 72, + 10, 26, 85, 187, 241, 29, 73, 6, 26, 76, 163, 242, 31, 51, 5, 41, 8, 32, + 80, 76, 85, 83, 32, 72, 73, 2, 223, 65, 32, 8, 174, 100, 65, 150, 159, + 29, 73, 247, 113, 85, 6, 26, 69, 255, 130, 30, 85, 5, 175, 25, 32, 12, + 26, 72, 155, 224, 31, 85, 10, 100, 14, 73, 84, 65, 32, 80, 76, 85, 83, + 32, 71, 73, 83, 72, 32, 96, 2, 85, 50, 217, 3, 2, 69, 32, 4, 48, 6, 80, + 76, 85, 83, 32, 69, 159, 227, 26, 84, 2, 11, 82, 2, 11, 73, 2, 195, 194, + 24, 78, 5, 193, 73, 5, 32, 80, 76, 85, 83, 6, 86, 65, 189, 30, 16, 69, + 32, 80, 76, 85, 83, 32, 65, 32, 80, 76, 85, 83, 32, 83, 85, 4, 142, 192, + 24, 75, 159, 174, 7, 71, 13, 72, 6, 32, 80, 76, 85, 83, 32, 194, 41, 50, + 238, 194, 31, 83, 147, 1, 68, 4, 26, 85, 163, 237, 31, 65, 2, 131, 41, + 32, 11, 11, 32, 8, 68, 4, 71, 85, 78, 85, 97, 9, 84, 73, 77, 69, 83, 32, + 83, 72, 69, 5, 73, 16, 32, 79, 86, 69, 82, 32, 76, 65, 71, 65, 82, 32, + 71, 85, 78, 85, 2, 215, 190, 31, 32, 5, 11, 32, 2, 249, 253, 14, 4, 80, + 76, 85, 83, 136, 1, 82, 48, 146, 2, 49, 30, 50, 114, 51, 82, 52, 222, 2, + 54, 154, 4, 55, 247, 24, 53, 22, 158, 1, 50, 30, 56, 184, 52, 15, 55, 57, + 32, 79, 86, 69, 82, 32, 76, 65, 75, 45, 48, 55, 57, 254, 155, 11, 53, + 238, 235, 12, 54, 2, 57, 94, 51, 255, 171, 3, 48, 4, 178, 233, 31, 49, 3, + 53, 4, 252, 187, 24, 12, 49, 32, 79, 86, 69, 82, 32, 76, 65, 75, 45, 48, + 155, 173, 7, 48, 4, 202, 187, 24, 52, 95, 51, 16, 46, 50, 38, 54, 210, + 180, 24, 49, 159, 2, 51, 6, 246, 231, 31, 48, 2, 53, 3, 56, 4, 210, 231, + 31, 53, 3, 54, 12, 42, 52, 254, 133, 12, 56, 247, 180, 12, 57, 6, 138, + 231, 31, 51, 2, 55, 3, 56, 30, 62, 52, 214, 1, 53, 30, 57, 158, 184, 24, + 55, 255, 171, 3, 56, 14, 26, 57, 143, 230, 31, 49, 13, 37, 7, 32, 84, 73, + 77, 69, 83, 32, 10, 116, 9, 80, 65, 80, 32, 80, 76, 85, 83, 32, 240, 197, + 13, 7, 85, 50, 32, 80, 76, 85, 83, 218, 31, 73, 191, 218, 17, 71, 4, 210, + 13, 80, 51, 76, 4, 210, 228, 31, 48, 3, 55, 8, 182, 228, 31, 48, 2, 50, + 2, 51, 3, 53, 46, 60, 2, 49, 55, 240, 1, 2, 52, 56, 246, 176, 24, 48, 23, + 51, 23, 37, 7, 32, 84, 73, 77, 69, 83, 32, 20, 122, 84, 34, 85, 162, 11, + 75, 136, 34, 9, 68, 85, 78, 51, 32, 71, 85, 78, 85, 194, 198, 29, 65, + 246, 167, 1, 66, 247, 67, 76, 4, 202, 169, 31, 65, 223, 56, 69, 6, 210, + 129, 15, 82, 182, 224, 16, 50, 3, 68, 21, 37, 7, 32, 84, 73, 77, 69, 83, + 32, 18, 154, 1, 85, 220, 8, 4, 80, 65, 80, 32, 150, 45, 73, 192, 137, 13, + 10, 83, 72, 69, 83, 72, 32, 80, 76, 85, 83, 194, 165, 5, 68, 210, 231, + 12, 78, 163, 17, 71, 4, 226, 255, 14, 82, 183, 224, 16, 68, 4, 214, 177, + 24, 50, 195, 174, 3, 52, 5, 11, 32, 2, 145, 6, 4, 84, 73, 77, 69, 7, 49, + 10, 32, 84, 73, 77, 69, 83, 32, 75, 85, 82, 5, 225, 244, 11, 5, 32, 80, + 76, 85, 83, 9, 204, 244, 11, 2, 77, 77, 234, 232, 19, 83, 147, 1, 76, 93, + 90, 50, 212, 7, 3, 71, 65, 76, 142, 1, 77, 134, 62, 32, 210, 150, 31, 51, + 2, 72, 3, 76, 69, 11, 32, 66, 88, 4, 67, 82, 79, 83, 0, 4, 79, 80, 80, + 79, 44, 4, 71, 85, 78, 85, 38, 83, 35, 84, 2, 209, 242, 11, 6, 83, 73, + 78, 71, 32, 76, 2, 197, 24, 5, 32, 84, 73, 77, 69, 6, 254, 68, 72, 219, + 209, 23, 81, 54, 44, 5, 73, 77, 69, 83, 32, 187, 182, 31, 69, 52, 188, 1, + 4, 69, 83, 72, 50, 94, 72, 42, 75, 68, 2, 76, 65, 34, 77, 60, 3, 80, 65, + 80, 118, 83, 90, 84, 254, 56, 71, 246, 128, 8, 78, 210, 178, 19, 68, 238, + 221, 2, 65, 166, 69, 66, 215, 53, 73, 7, 11, 32, 4, 26, 80, 143, 205, 26, + 84, 2, 17, 2, 76, 85, 2, 209, 205, 30, 3, 83, 32, 76, 4, 188, 66, 2, 73, + 32, 131, 139, 30, 65, 8, 32, 2, 65, 68, 199, 216, 31, 73, 6, 230, 19, 51, + 223, 196, 31, 50, 4, 178, 20, 32, 163, 132, 18, 71, 2, 11, 69, 2, 11, 32, + 2, 233, 221, 13, 4, 80, 76, 85, 83, 5, 11, 32, 2, 33, 6, 80, 76, 85, 83, + 32, 80, 2, 45, 9, 65, 80, 32, 80, 76, 85, 83, 32, 76, 2, 199, 214, 27, + 85, 6, 26, 73, 211, 177, 31, 72, 4, 198, 18, 32, 169, 137, 27, 7, 75, 50, + 32, 80, 76, 85, 83, 4, 166, 53, 85, 239, 23, 65, 9, 11, 32, 6, 22, 79, + 211, 67, 83, 4, 56, 7, 80, 80, 79, 83, 73, 78, 71, 1, 3, 86, 69, 82, 2, + 21, 3, 32, 76, 85, 2, 139, 201, 30, 71, 7, 45, 9, 32, 79, 86, 69, 82, 32, + 76, 85, 77, 5, 191, 59, 32, 70, 34, 65, 70, 69, 22, 73, 71, 85, 17, 174, + 45, 32, 188, 1, 2, 83, 72, 134, 165, 31, 50, 2, 72, 3, 82, 7, 211, 188, + 27, 83, 7, 204, 211, 27, 8, 32, 80, 76, 85, 83, 32, 90, 65, 203, 255, 3, + 78, 43, 104, 2, 83, 72, 190, 60, 71, 140, 171, 11, 5, 32, 79, 86, 69, 82, + 40, 2, 82, 71, 209, 238, 6, 2, 78, 83, 31, 22, 32, 183, 2, 51, 16, 136, 1, 9, 79, 86, 69, 82, 32, 77, 85, 83, 72, 124, 6, 84, 73, 77, 69, 83, 32, - 161, 233, 26, 10, 67, 82, 79, 83, 83, 73, 78, 71, 32, 77, 9, 37, 7, 32, - 84, 73, 77, 69, 83, 32, 6, 42, 65, 206, 191, 28, 75, 211, 182, 2, 71, 2, - 237, 189, 11, 5, 32, 80, 76, 85, 83, 6, 214, 255, 29, 75, 158, 118, 90, - 187, 2, 65, 13, 11, 32, 10, 44, 6, 84, 73, 77, 69, 83, 32, 203, 57, 71, - 8, 38, 65, 198, 227, 30, 68, 163, 17, 90, 5, 233, 135, 13, 5, 32, 80, 76, - 85, 83, 158, 1, 42, 65, 134, 2, 69, 94, 73, 199, 7, 85, 23, 52, 2, 71, - 65, 166, 1, 77, 234, 244, 30, 50, 3, 52, 11, 26, 32, 243, 245, 30, 82, 6, - 100, 8, 79, 80, 80, 79, 83, 73, 78, 71, 146, 59, 73, 197, 14, 9, 84, 73, - 77, 69, 83, 32, 83, 72, 85, 2, 193, 178, 30, 3, 32, 78, 65, 7, 204, 21, - 2, 32, 78, 155, 223, 30, 50, 9, 11, 32, 6, 44, 6, 84, 73, 77, 69, 83, 32, - 179, 57, 83, 4, 226, 173, 30, 85, 163, 70, 65, 73, 90, 77, 78, 78, 136, - 186, 20, 6, 32, 84, 73, 77, 69, 83, 202, 204, 8, 83, 239, 235, 1, 50, 7, - 45, 9, 32, 84, 73, 77, 69, 83, 32, 71, 65, 4, 158, 3, 82, 179, 58, 78, - 59, 36, 3, 68, 65, 50, 151, 242, 30, 57, 55, 37, 7, 32, 84, 73, 77, 69, - 83, 32, 52, 162, 1, 65, 34, 71, 50, 75, 16, 5, 76, 65, 75, 45, 48, 22, - 77, 86, 78, 34, 80, 76, 3, 83, 72, 69, 94, 85, 240, 15, 3, 68, 73, 77, - 238, 209, 29, 66, 135, 120, 72, 6, 246, 2, 83, 211, 237, 30, 78, 8, 26, - 73, 219, 237, 29, 85, 5, 251, 238, 30, 83, 2, 211, 20, 69, 2, 131, 201, - 23, 53, 4, 26, 69, 179, 132, 29, 65, 2, 25, 4, 32, 80, 76, 85, 2, 177, - 41, 3, 83, 32, 71, 4, 158, 159, 30, 85, 227, 79, 69, 2, 33, 6, 65, 80, - 32, 80, 76, 85, 2, 11, 83, 2, 165, 219, 29, 2, 32, 80, 9, 37, 7, 32, 80, - 76, 85, 83, 32, 65, 6, 26, 83, 183, 161, 29, 32, 4, 11, 72, 5, 107, 32, - 11, 50, 32, 34, 50, 218, 175, 14, 82, 255, 187, 16, 83, 2, 217, 148, 14, - 3, 80, 76, 85, 2, 11, 32, 2, 21, 3, 80, 76, 85, 2, 11, 83, 2, 159, 129, - 29, 32, 57, 24, 2, 49, 49, 99, 78, 9, 11, 32, 6, 200, 25, 9, 79, 86, 69, - 82, 32, 78, 85, 49, 49, 230, 203, 25, 84, 243, 167, 3, 82, 47, 30, 32, - 169, 3, 2, 85, 90, 18, 144, 1, 12, 67, 82, 79, 83, 83, 73, 78, 71, 32, - 78, 85, 78, 72, 12, 76, 65, 71, 65, 82, 32, 84, 73, 77, 69, 83, 32, 174, - 1, 79, 183, 225, 25, 84, 5, 209, 40, 14, 32, 76, 65, 71, 65, 82, 32, 79, - 86, 69, 82, 32, 76, 65, 10, 56, 3, 83, 65, 76, 218, 253, 28, 77, 14, 85, - 207, 71, 71, 5, 141, 221, 29, 23, 32, 79, 86, 69, 82, 32, 78, 85, 78, 32, - 76, 65, 71, 65, 82, 32, 84, 73, 77, 69, 83, 32, 83, 2, 165, 187, 17, 3, - 86, 69, 82, 27, 11, 32, 24, 120, 10, 65, 66, 50, 32, 84, 73, 77, 69, 83, - 32, 205, 37, 15, 75, 73, 83, 73, 77, 53, 32, 84, 73, 77, 69, 83, 32, 66, - 73, 20, 168, 1, 2, 75, 65, 202, 7, 73, 212, 39, 2, 65, 83, 138, 173, 2, - 68, 220, 211, 8, 3, 83, 73, 76, 234, 141, 12, 85, 210, 249, 5, 71, 158, - 151, 1, 78, 254, 2, 66, 163, 17, 76, 2, 203, 234, 26, 68, 46, 42, 65, 36, - 4, 69, 83, 72, 50, 23, 73, 9, 230, 228, 30, 68, 2, 78, 3, 80, 5, 135, - 205, 28, 32, 35, 22, 32, 151, 1, 82, 20, 80, 6, 84, 73, 77, 69, 83, 32, - 193, 133, 18, 8, 67, 82, 79, 83, 83, 73, 78, 71, 18, 214, 21, 85, 150, - 48, 65, 2, 73, 162, 221, 29, 66, 187, 64, 69, 12, 32, 2, 73, 71, 227, - 226, 30, 50, 11, 11, 32, 8, 96, 6, 84, 73, 77, 69, 83, 32, 141, 166, 26, - 12, 79, 80, 80, 79, 83, 73, 78, 71, 32, 80, 73, 82, 6, 146, 214, 29, 75, - 190, 69, 85, 235, 67, 90, 8, 234, 67, 65, 218, 157, 30, 73, 3, 85, 202, - 1, 46, 65, 250, 5, 72, 150, 11, 73, 163, 1, 85, 63, 46, 71, 190, 4, 76, - 122, 78, 135, 219, 30, 82, 53, 11, 32, 50, 92, 4, 71, 85, 78, 85, 54, 78, - 32, 6, 84, 73, 77, 69, 83, 32, 241, 21, 4, 79, 86, 69, 82, 5, 29, 5, 32, - 84, 73, 77, 69, 2, 155, 232, 17, 83, 2, 237, 176, 25, 3, 85, 84, 73, 42, - 150, 1, 73, 42, 75, 34, 83, 64, 2, 84, 65, 38, 85, 220, 62, 2, 68, 85, - 182, 242, 28, 76, 246, 42, 78, 210, 48, 69, 138, 60, 77, 162, 17, 72, - 187, 2, 65, 2, 11, 71, 2, 11, 73, 2, 191, 31, 32, 4, 218, 164, 30, 85, - 199, 53, 65, 6, 26, 72, 175, 209, 29, 65, 4, 198, 198, 13, 69, 151, 208, - 16, 73, 4, 242, 179, 23, 75, 231, 168, 7, 66, 10, 162, 219, 30, 83, 146, + 241, 186, 27, 10, 67, 82, 79, 83, 83, 73, 78, 71, 32, 77, 9, 37, 7, 32, + 84, 73, 77, 69, 83, 32, 6, 42, 65, 238, 146, 29, 75, 207, 186, 2, 71, 2, + 241, 226, 11, 5, 32, 80, 76, 85, 83, 6, 242, 214, 30, 75, 158, 118, 90, + 187, 2, 65, 13, 11, 32, 10, 44, 6, 84, 73, 77, 69, 83, 32, 207, 57, 71, + 8, 38, 65, 226, 186, 31, 68, 163, 17, 90, 5, 205, 175, 13, 5, 32, 80, 76, + 85, 83, 158, 1, 42, 65, 138, 2, 69, 94, 73, 199, 7, 85, 23, 52, 2, 71, + 65, 170, 1, 77, 130, 204, 31, 50, 3, 52, 11, 26, 32, 143, 205, 31, 82, 6, + 104, 8, 79, 80, 80, 79, 83, 73, 78, 71, 204, 73, 9, 84, 73, 77, 69, 83, + 32, 83, 72, 85, 255, 185, 10, 73, 2, 217, 137, 31, 3, 32, 78, 65, 7, 204, + 21, 2, 32, 78, 179, 182, 31, 50, 9, 11, 32, 6, 44, 6, 84, 73, 77, 69, 83, + 32, 179, 57, 83, 4, 250, 132, 31, 85, 163, 70, 65, 73, 90, 77, 78, 78, + 216, 137, 21, 6, 32, 84, 73, 77, 69, 83, 250, 208, 8, 83, 135, 239, 1, + 50, 7, 45, 9, 32, 84, 73, 77, 69, 83, 32, 71, 65, 4, 158, 3, 82, 151, 58, + 78, 59, 36, 3, 68, 65, 50, 175, 201, 31, 57, 55, 37, 7, 32, 84, 73, 77, + 69, 83, 32, 52, 162, 1, 65, 34, 71, 50, 75, 16, 5, 76, 65, 75, 45, 48, + 22, 77, 86, 78, 34, 80, 76, 3, 83, 72, 69, 94, 85, 240, 15, 3, 68, 73, + 77, 134, 169, 30, 66, 135, 120, 72, 6, 246, 2, 83, 235, 196, 31, 78, 8, + 26, 73, 243, 196, 30, 85, 5, 147, 198, 31, 83, 2, 211, 20, 69, 2, 227, + 154, 24, 53, 4, 26, 69, 179, 216, 29, 65, 2, 25, 4, 32, 80, 76, 85, 2, + 177, 41, 3, 83, 32, 71, 4, 182, 246, 30, 85, 227, 79, 69, 2, 33, 6, 65, + 80, 32, 80, 76, 85, 2, 11, 83, 2, 189, 178, 30, 2, 32, 80, 9, 37, 7, 32, + 80, 76, 85, 83, 32, 65, 6, 26, 83, 215, 245, 29, 32, 4, 11, 72, 5, 107, + 32, 11, 50, 32, 34, 50, 202, 227, 14, 82, 167, 223, 16, 83, 2, 137, 195, + 14, 3, 80, 76, 85, 2, 11, 32, 2, 21, 3, 80, 76, 85, 2, 11, 83, 2, 159, + 213, 29, 32, 57, 24, 2, 49, 49, 99, 78, 9, 11, 32, 6, 200, 25, 9, 79, 86, + 69, 82, 32, 78, 85, 49, 49, 142, 157, 26, 84, 211, 170, 3, 82, 47, 30, + 32, 169, 3, 2, 85, 90, 18, 144, 1, 12, 67, 82, 79, 83, 83, 73, 78, 71, + 32, 78, 85, 78, 72, 12, 76, 65, 71, 65, 82, 32, 84, 73, 77, 69, 83, 32, + 174, 1, 79, 223, 178, 26, 84, 5, 209, 40, 14, 32, 76, 65, 71, 65, 82, 32, + 79, 86, 69, 82, 32, 76, 65, 10, 56, 3, 83, 65, 76, 218, 209, 29, 77, 14, + 85, 167, 74, 71, 5, 165, 180, 30, 23, 32, 79, 86, 69, 82, 32, 78, 85, 78, + 32, 76, 65, 71, 65, 82, 32, 84, 73, 77, 69, 83, 32, 83, 2, 145, 136, 18, + 3, 86, 69, 82, 27, 11, 32, 24, 120, 10, 65, 66, 50, 32, 84, 73, 77, 69, + 83, 32, 205, 37, 15, 75, 73, 83, 73, 77, 53, 32, 84, 73, 77, 69, 83, 32, + 66, 73, 20, 168, 1, 2, 75, 65, 202, 7, 73, 184, 39, 2, 65, 83, 190, 174, + 2, 68, 196, 247, 8, 3, 83, 73, 76, 202, 186, 12, 85, 202, 254, 5, 71, + 222, 151, 1, 78, 254, 2, 66, 163, 17, 76, 2, 159, 188, 27, 68, 46, 42, + 65, 36, 4, 69, 83, 72, 50, 23, 73, 9, 254, 187, 31, 68, 2, 78, 3, 80, 5, + 255, 160, 29, 32, 35, 22, 32, 151, 1, 82, 20, 80, 6, 84, 73, 77, 69, 83, + 32, 193, 210, 18, 8, 67, 82, 79, 83, 83, 73, 78, 71, 18, 214, 21, 85, + 142, 48, 65, 2, 73, 194, 180, 30, 66, 187, 64, 69, 12, 32, 2, 73, 71, + 251, 185, 31, 50, 11, 11, 32, 8, 96, 6, 84, 73, 77, 69, 83, 32, 185, 247, + 26, 12, 79, 80, 80, 79, 83, 73, 78, 71, 32, 80, 73, 82, 6, 170, 173, 30, + 75, 190, 69, 85, 235, 67, 90, 8, 226, 67, 65, 250, 244, 30, 73, 3, 85, + 202, 1, 46, 65, 250, 5, 72, 150, 11, 73, 163, 1, 85, 63, 46, 71, 190, 4, + 76, 122, 78, 159, 178, 31, 82, 53, 11, 32, 50, 92, 4, 71, 85, 78, 85, 54, + 78, 32, 6, 84, 73, 77, 69, 83, 32, 241, 21, 4, 79, 86, 69, 82, 5, 29, 5, + 32, 84, 73, 77, 69, 2, 139, 181, 18, 83, 2, 181, 130, 26, 3, 85, 84, 73, + 42, 150, 1, 73, 42, 75, 34, 83, 64, 2, 84, 65, 38, 85, 212, 62, 2, 68, + 85, 150, 201, 29, 76, 182, 43, 78, 210, 48, 69, 138, 60, 77, 162, 17, 72, + 187, 2, 65, 2, 11, 71, 2, 11, 73, 2, 191, 31, 32, 4, 242, 251, 30, 85, + 199, 53, 65, 6, 26, 72, 199, 168, 30, 65, 4, 202, 238, 13, 69, 171, 255, + 16, 73, 4, 210, 133, 24, 75, 159, 174, 7, 66, 10, 186, 178, 31, 83, 146, 1, 50, 2, 66, 2, 77, 3, 82, 5, 33, 6, 32, 76, 65, 71, 65, 66, 2, 37, 7, - 32, 84, 73, 77, 69, 83, 32, 2, 11, 65, 2, 11, 83, 2, 215, 179, 23, 72, 2, - 131, 170, 11, 71, 106, 46, 65, 250, 1, 69, 242, 2, 73, 239, 3, 85, 29, - 50, 51, 182, 1, 54, 190, 173, 23, 66, 223, 3, 82, 19, 37, 7, 32, 84, 73, - 77, 69, 83, 32, 16, 90, 85, 146, 25, 83, 174, 219, 26, 71, 250, 235, 2, - 84, 170, 50, 66, 218, 47, 78, 215, 22, 65, 5, 11, 32, 2, 253, 143, 26, 4, - 80, 76, 85, 83, 5, 175, 45, 32, 27, 62, 32, 140, 2, 2, 83, 72, 230, 219, - 26, 71, 155, 250, 3, 78, 14, 84, 8, 79, 86, 69, 82, 32, 83, 72, 69, 88, - 5, 80, 76, 85, 83, 32, 243, 177, 30, 72, 7, 11, 32, 4, 190, 15, 71, 141, + 32, 84, 73, 77, 69, 83, 32, 2, 11, 65, 2, 11, 83, 2, 183, 133, 24, 72, 2, + 131, 207, 11, 71, 106, 46, 65, 250, 1, 69, 242, 2, 73, 239, 3, 85, 29, + 50, 51, 182, 1, 54, 158, 255, 23, 66, 223, 3, 82, 19, 37, 7, 32, 84, 73, + 77, 69, 83, 32, 16, 90, 85, 146, 25, 83, 214, 173, 27, 71, 234, 240, 2, + 84, 170, 50, 66, 218, 47, 78, 215, 22, 65, 5, 11, 32, 2, 169, 225, 26, 4, + 80, 76, 85, 83, 5, 167, 45, 32, 27, 62, 32, 140, 2, 2, 83, 72, 186, 173, + 27, 71, 223, 255, 3, 78, 14, 84, 8, 79, 86, 69, 82, 32, 83, 72, 69, 88, + 5, 80, 76, 85, 83, 32, 139, 137, 31, 72, 7, 11, 32, 4, 190, 15, 71, 141, 6, 12, 84, 65, 66, 32, 79, 86, 69, 82, 32, 84, 65, 66, 6, 48, 2, 72, 85, - 20, 2, 78, 65, 215, 178, 29, 83, 2, 227, 174, 23, 66, 2, 207, 174, 23, - 77, 7, 234, 152, 29, 76, 147, 189, 1, 50, 40, 62, 68, 74, 77, 218, 1, 82, - 150, 151, 26, 78, 175, 185, 4, 84, 7, 37, 7, 32, 84, 73, 77, 69, 83, 32, - 4, 150, 196, 30, 73, 219, 16, 65, 25, 37, 7, 32, 84, 73, 77, 69, 83, 32, - 22, 114, 66, 38, 73, 130, 19, 75, 142, 183, 2, 77, 234, 217, 2, 76, 226, - 139, 24, 71, 226, 23, 83, 138, 12, 68, 215, 127, 65, 4, 162, 202, 2, 85, - 195, 253, 26, 65, 4, 249, 20, 2, 71, 73, 7, 11, 32, 4, 60, 9, 79, 86, 69, - 82, 32, 83, 72, 73, 82, 231, 203, 25, 84, 2, 213, 217, 29, 11, 32, 66, + 20, 2, 78, 65, 175, 137, 30, 83, 2, 195, 128, 24, 66, 2, 175, 128, 24, + 77, 7, 254, 236, 29, 76, 151, 192, 1, 50, 40, 62, 68, 74, 77, 218, 1, 82, + 194, 232, 26, 78, 155, 191, 4, 84, 7, 37, 7, 32, 84, 73, 77, 69, 83, 32, + 4, 174, 155, 31, 73, 219, 16, 65, 25, 37, 7, 32, 84, 73, 77, 69, 83, 32, + 22, 114, 66, 38, 73, 130, 19, 75, 166, 184, 2, 77, 210, 217, 2, 76, 186, + 225, 24, 71, 162, 24, 83, 138, 12, 68, 215, 127, 65, 4, 186, 203, 2, 85, + 195, 211, 27, 65, 4, 249, 20, 2, 71, 73, 7, 11, 32, 4, 60, 9, 79, 86, 69, + 82, 32, 83, 72, 73, 82, 143, 157, 26, 84, 2, 237, 176, 30, 11, 32, 66, 85, 82, 32, 79, 86, 69, 82, 32, 66, 13, 88, 14, 32, 79, 86, 69, 82, 32, - 73, 78, 86, 69, 82, 84, 69, 68, 34, 50, 159, 216, 29, 66, 2, 11, 32, 2, - 187, 218, 25, 83, 7, 33, 6, 32, 80, 76, 85, 83, 32, 4, 88, 7, 69, 50, 32, - 84, 73, 77, 69, 173, 153, 11, 9, 68, 85, 71, 32, 84, 73, 77, 69, 83, 2, - 139, 138, 13, 83, 17, 50, 32, 30, 71, 230, 153, 11, 76, 235, 141, 12, 75, + 73, 78, 86, 69, 82, 84, 69, 68, 34, 50, 183, 175, 30, 66, 2, 11, 32, 2, + 227, 171, 26, 83, 7, 33, 6, 32, 80, 76, 85, 83, 32, 4, 88, 7, 69, 50, 32, + 84, 73, 77, 69, 173, 190, 11, 9, 68, 85, 71, 32, 84, 73, 77, 69, 83, 2, + 247, 177, 13, 83, 17, 50, 32, 30, 71, 230, 190, 11, 76, 203, 186, 12, 75, 4, 138, 8, 84, 163, 9, 71, 7, 11, 52, 5, 49, 10, 32, 79, 86, 69, 82, 32, - 83, 73, 71, 52, 2, 199, 14, 32, 19, 78, 68, 22, 77, 22, 82, 184, 223, 12, - 5, 32, 79, 86, 69, 82, 187, 245, 16, 72, 5, 235, 205, 30, 50, 5, 207, - 226, 28, 65, 5, 195, 205, 30, 57, 72, 46, 65, 150, 4, 73, 250, 1, 85, - 227, 8, 69, 37, 66, 32, 94, 66, 166, 1, 71, 148, 1, 2, 75, 52, 171, 201, - 30, 82, 8, 60, 6, 84, 73, 77, 69, 83, 32, 130, 14, 71, 207, 166, 28, 65, - 4, 162, 184, 30, 72, 3, 77, 7, 11, 32, 4, 176, 205, 17, 29, 79, 86, 69, + 83, 73, 71, 52, 2, 199, 14, 32, 19, 78, 68, 22, 77, 22, 82, 152, 135, 13, + 5, 32, 79, 86, 69, 82, 243, 164, 17, 72, 5, 131, 165, 31, 50, 5, 207, + 182, 29, 65, 5, 219, 164, 31, 57, 72, 46, 65, 150, 4, 73, 250, 1, 85, + 227, 8, 69, 37, 66, 32, 94, 66, 166, 1, 71, 148, 1, 2, 75, 52, 195, 160, + 31, 82, 8, 60, 6, 84, 73, 77, 69, 83, 32, 130, 14, 71, 199, 250, 28, 65, + 4, 186, 143, 31, 72, 3, 77, 7, 11, 32, 4, 160, 154, 18, 29, 79, 86, 69, 82, 32, 84, 65, 66, 32, 78, 73, 32, 79, 86, 69, 82, 32, 78, 73, 32, 68, - 73, 83, 72, 32, 79, 86, 69, 82, 163, 192, 5, 83, 15, 37, 7, 32, 84, 73, - 77, 69, 83, 32, 12, 74, 84, 216, 254, 7, 2, 83, 72, 130, 157, 21, 71, - 210, 103, 85, 203, 50, 66, 2, 11, 85, 2, 251, 161, 23, 71, 5, 29, 5, 32, - 80, 76, 85, 83, 2, 153, 221, 28, 2, 32, 83, 17, 46, 82, 150, 29, 32, 170, - 171, 30, 50, 3, 76, 9, 11, 32, 6, 48, 8, 79, 86, 69, 82, 32, 84, 73, 82, + 73, 83, 72, 32, 79, 86, 69, 82, 155, 195, 5, 83, 15, 37, 7, 32, 84, 73, + 77, 69, 83, 32, 12, 74, 84, 212, 132, 8, 2, 83, 72, 222, 237, 21, 71, + 146, 104, 85, 203, 50, 66, 2, 11, 85, 2, 219, 243, 23, 71, 5, 29, 5, 32, + 80, 76, 85, 83, 2, 153, 177, 29, 2, 32, 83, 17, 46, 82, 142, 29, 32, 202, + 130, 31, 50, 3, 76, 9, 11, 32, 6, 48, 8, 79, 86, 69, 82, 32, 84, 73, 82, 99, 84, 5, 11, 32, 2, 11, 71, 2, 21, 3, 65, 68, 32, 2, 241, 5, 8, 79, 86, - 69, 82, 32, 71, 65, 68, 2, 217, 21, 6, 73, 77, 69, 83, 32, 84, 17, 50, - 77, 114, 82, 146, 158, 23, 71, 195, 167, 7, 75, 7, 37, 7, 32, 84, 73, 77, - 69, 83, 32, 4, 46, 71, 201, 199, 17, 5, 84, 72, 82, 69, 69, 2, 221, 16, - 2, 65, 78, 5, 137, 140, 11, 17, 32, 79, 86, 69, 82, 32, 84, 85, 82, 32, + 69, 82, 32, 71, 65, 68, 2, 189, 21, 6, 73, 77, 69, 83, 32, 84, 17, 50, + 77, 114, 82, 242, 239, 23, 71, 251, 172, 7, 75, 7, 37, 7, 32, 84, 73, 77, + 69, 83, 32, 4, 46, 71, 185, 148, 18, 5, 84, 72, 82, 69, 69, 2, 193, 16, + 2, 65, 78, 5, 137, 177, 11, 17, 32, 79, 86, 69, 82, 32, 84, 85, 82, 32, 90, 65, 32, 79, 86, 69, 82, 179, 1, 138, 1, 32, 246, 2, 68, 226, 2, 78, - 46, 77, 158, 2, 82, 128, 9, 2, 83, 72, 174, 1, 90, 252, 191, 12, 2, 84, - 85, 166, 241, 17, 50, 3, 66, 12, 64, 7, 79, 86, 69, 82, 32, 85, 32, 158, - 2, 85, 155, 147, 29, 71, 6, 200, 1, 10, 80, 65, 32, 79, 86, 69, 82, 32, - 80, 65, 220, 159, 9, 19, 85, 32, 82, 69, 86, 69, 82, 83, 69, 68, 32, 79, - 86, 69, 82, 32, 85, 32, 82, 169, 169, 20, 10, 83, 85, 82, 32, 79, 86, 69, + 46, 77, 158, 2, 82, 228, 8, 2, 83, 72, 174, 1, 90, 248, 231, 12, 2, 84, + 85, 222, 160, 18, 50, 3, 66, 12, 64, 7, 79, 86, 69, 82, 32, 85, 32, 158, + 2, 85, 243, 233, 29, 71, 6, 200, 1, 10, 80, 65, 32, 79, 86, 69, 82, 32, + 80, 65, 144, 177, 9, 19, 85, 32, 82, 69, 86, 69, 82, 83, 69, 68, 32, 79, + 86, 69, 82, 32, 85, 32, 82, 141, 239, 20, 10, 83, 85, 82, 32, 79, 86, 69, 82, 32, 83, 2, 11, 32, 2, 45, 9, 71, 65, 82, 32, 79, 86, 69, 82, 32, 2, - 223, 157, 29, 71, 5, 159, 156, 30, 32, 21, 26, 32, 135, 192, 30, 85, 16, + 183, 244, 29, 71, 5, 183, 243, 30, 32, 21, 26, 32, 159, 151, 31, 85, 16, 70, 75, 44, 2, 83, 72, 100, 6, 84, 73, 77, 69, 83, 32, 135, 1, 71, 2, 11, - 85, 2, 11, 83, 2, 151, 136, 11, 72, 4, 29, 5, 69, 83, 72, 73, 71, 5, 11, - 32, 2, 11, 84, 2, 253, 248, 29, 6, 73, 77, 69, 83, 32, 66, 8, 92, 14, 85, - 32, 80, 76, 85, 83, 32, 85, 32, 80, 76, 85, 83, 32, 246, 247, 29, 66, - 215, 50, 77, 4, 11, 85, 5, 11, 32, 2, 11, 71, 2, 135, 153, 30, 85, 21, - 72, 7, 32, 84, 73, 77, 69, 83, 32, 136, 1, 2, 85, 77, 195, 188, 29, 66, - 10, 50, 76, 16, 2, 77, 69, 50, 83, 171, 188, 30, 85, 2, 231, 6, 65, 5, - 11, 32, 2, 145, 254, 25, 4, 80, 76, 85, 83, 2, 255, 134, 11, 72, 7, 37, - 7, 32, 84, 73, 77, 69, 83, 32, 4, 158, 11, 75, 151, 174, 30, 80, 93, 54, - 32, 102, 50, 194, 2, 73, 22, 85, 223, 183, 30, 52, 4, 62, 83, 129, 194, - 29, 9, 67, 82, 79, 83, 83, 73, 78, 71, 32, 2, 237, 254, 25, 4, 72, 69, - 83, 72, 23, 11, 32, 20, 42, 73, 37, 6, 84, 73, 77, 69, 83, 32, 2, 233, - 136, 24, 4, 78, 86, 69, 82, 18, 46, 65, 82, 85, 166, 184, 29, 78, 251, - 125, 72, 6, 48, 6, 32, 80, 76, 85, 83, 32, 243, 184, 30, 76, 4, 182, 182, - 30, 72, 3, 78, 8, 26, 50, 187, 184, 30, 68, 7, 33, 6, 32, 80, 76, 85, 83, - 32, 4, 138, 205, 28, 65, 179, 215, 1, 66, 5, 239, 183, 30, 51, 59, 56, 7, - 32, 84, 73, 77, 69, 83, 32, 165, 4, 2, 68, 65, 52, 134, 1, 65, 46, 68, - 38, 71, 82, 73, 46, 76, 78, 83, 46, 85, 154, 144, 29, 66, 234, 35, 77, - 238, 90, 84, 146, 17, 75, 162, 17, 72, 3, 80, 5, 11, 83, 2, 11, 72, 2, - 219, 128, 17, 71, 4, 186, 255, 10, 65, 211, 230, 18, 85, 10, 26, 65, 175, - 181, 30, 85, 9, 34, 78, 138, 181, 30, 76, 3, 82, 2, 211, 9, 50, 6, 158, - 161, 30, 71, 202, 18, 83, 147, 1, 77, 6, 46, 85, 237, 136, 23, 5, 65, 75, - 45, 54, 54, 4, 154, 180, 30, 51, 3, 77, 4, 152, 139, 23, 2, 73, 71, 147, - 146, 7, 72, 6, 42, 32, 158, 246, 13, 82, 143, 189, 16, 68, 2, 181, 133, - 29, 6, 80, 76, 85, 83, 32, 71, 5, 11, 32, 2, 197, 218, 13, 4, 84, 73, 77, - 69, 17, 84, 7, 32, 84, 73, 77, 69, 83, 32, 180, 163, 29, 2, 85, 77, 194, - 142, 1, 50, 3, 88, 8, 50, 84, 164, 219, 26, 2, 75, 85, 159, 214, 3, 65, - 2, 11, 65, 2, 207, 136, 23, 75, 6, 26, 51, 135, 177, 30, 85, 5, 29, 5, - 32, 84, 73, 77, 69, 2, 21, 3, 83, 32, 75, 2, 11, 65, 2, 175, 180, 23, 83, - 42, 50, 65, 190, 1, 73, 146, 1, 85, 239, 133, 23, 69, 13, 50, 32, 134, - 161, 29, 77, 194, 142, 1, 55, 3, 71, 4, 56, 8, 83, 81, 85, 65, 82, 69, - 68, 32, 195, 168, 25, 84, 2, 11, 84, 2, 21, 3, 73, 77, 69, 2, 11, 83, 2, - 129, 182, 29, 2, 32, 75, 15, 86, 66, 236, 236, 22, 6, 32, 79, 86, 69, 82, - 32, 186, 25, 90, 194, 167, 7, 51, 3, 71, 5, 17, 2, 32, 75, 2, 17, 2, 65, - 66, 2, 135, 2, 65, 15, 84, 10, 32, 79, 86, 69, 82, 32, 90, 85, 32, 80, - 42, 53, 218, 179, 29, 66, 215, 120, 77, 2, 149, 137, 29, 5, 76, 85, 83, - 32, 83, 7, 37, 7, 32, 84, 73, 77, 69, 83, 32, 4, 44, 5, 84, 72, 82, 69, - 69, 215, 171, 30, 65, 2, 29, 5, 32, 68, 73, 83, 72, 2, 11, 32, 2, 223, - 164, 25, 84, 8, 42, 32, 170, 235, 22, 73, 155, 211, 3, 67, 4, 226, 166, - 22, 79, 217, 133, 7, 8, 87, 73, 84, 72, 32, 83, 84, 82, 18, 134, 1, 76, - 162, 1, 82, 157, 228, 29, 23, 86, 69, 68, 32, 83, 84, 69, 77, 32, 80, 65, - 82, 65, 71, 82, 65, 80, 72, 32, 83, 73, 71, 78, 10, 48, 2, 89, 32, 133, - 160, 3, 4, 73, 78, 71, 32, 8, 68, 2, 76, 79, 145, 133, 28, 9, 66, 82, 65, - 67, 75, 69, 84, 32, 69, 6, 166, 227, 26, 71, 239, 196, 3, 79, 6, 52, 5, - 69, 78, 67, 89, 32, 53, 4, 89, 32, 65, 78, 4, 172, 132, 25, 4, 69, 88, - 67, 72, 175, 156, 4, 83, 2, 185, 239, 19, 3, 68, 32, 82, 4, 182, 128, 3, - 79, 203, 141, 26, 65, 240, 8, 128, 1, 2, 80, 82, 140, 9, 7, 82, 73, 76, - 76, 73, 67, 32, 204, 235, 25, 7, 76, 73, 78, 68, 82, 73, 67, 149, 132, 3, - 2, 67, 76, 180, 2, 140, 1, 13, 73, 79, 84, 32, 83, 89, 76, 76, 65, 66, - 76, 69, 32, 169, 1, 16, 79, 45, 77, 73, 78, 79, 65, 78, 32, 83, 73, 71, - 78, 32, 67, 77, 110, 138, 181, 7, 75, 2, 76, 2, 77, 2, 78, 2, 80, 2, 82, - 2, 83, 2, 84, 126, 87, 202, 38, 74, 2, 90, 230, 245, 6, 88, 254, 209, 15, - 65, 2, 69, 2, 73, 2, 79, 3, 85, 198, 1, 46, 48, 146, 5, 49, 233, 151, 26, - 2, 51, 48, 170, 1, 102, 48, 78, 49, 74, 50, 78, 51, 78, 52, 62, 53, 86, - 55, 198, 187, 10, 57, 190, 3, 54, 143, 161, 14, 56, 16, 230, 161, 30, 49, - 2, 50, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 16, 194, 3, 50, 218, - 157, 30, 48, 2, 49, 2, 51, 2, 53, 2, 55, 3, 57, 16, 210, 160, 30, 49, 2, - 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 16, 134, 160, 30, 48, 2, - 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 12, 186, 159, 30, 48, 2, - 49, 2, 52, 2, 54, 2, 55, 3, 57, 18, 254, 158, 30, 48, 2, 49, 2, 50, 2, - 51, 2, 52, 2, 53, 2, 54, 2, 56, 3, 57, 20, 82, 53, 218, 157, 30, 48, 2, - 49, 2, 50, 2, 51, 2, 52, 2, 54, 2, 56, 3, 57, 5, 215, 157, 30, 66, 24, - 18, 48, 87, 49, 18, 174, 157, 30, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, - 2, 55, 2, 56, 3, 57, 6, 218, 156, 30, 48, 2, 50, 3, 52, 184, 6, 140, 1, - 9, 67, 65, 80, 73, 84, 65, 76, 32, 76, 202, 4, 75, 32, 7, 76, 69, 84, 84, - 69, 82, 32, 132, 1, 3, 80, 65, 89, 30, 83, 211, 41, 84, 242, 2, 44, 6, - 69, 84, 84, 69, 82, 32, 175, 43, 73, 236, 2, 150, 2, 76, 46, 78, 34, 80, - 34, 82, 58, 84, 62, 85, 190, 5, 65, 214, 1, 66, 242, 1, 67, 150, 1, 68, - 254, 1, 69, 206, 2, 71, 130, 1, 72, 134, 1, 73, 230, 3, 75, 226, 3, 77, - 218, 1, 79, 226, 2, 83, 218, 7, 89, 166, 1, 90, 198, 204, 29, 70, 134, - 14, 74, 2, 86, 2, 87, 159, 20, 81, 6, 222, 25, 73, 162, 232, 29, 74, 159, - 20, 72, 4, 134, 27, 69, 207, 230, 29, 74, 8, 134, 34, 69, 171, 226, 29, - 83, 12, 220, 9, 3, 79, 85, 78, 226, 18, 69, 243, 248, 29, 72, 20, 174, - 33, 69, 106, 83, 142, 200, 29, 67, 186, 22, 74, 3, 87, 13, 198, 34, 32, - 115, 75, 2, 241, 141, 30, 3, 65, 86, 89, 6, 248, 10, 5, 77, 85, 76, 84, - 73, 244, 135, 13, 2, 80, 65, 157, 238, 11, 14, 83, 77, 65, 76, 76, 32, - 67, 65, 80, 73, 84, 65, 76, 32, 2, 213, 235, 29, 2, 69, 82, 186, 3, 136, - 1, 6, 77, 65, 76, 76, 32, 76, 201, 37, 22, 85, 66, 83, 67, 82, 73, 80, - 84, 32, 83, 77, 65, 76, 76, 32, 76, 69, 84, 84, 69, 82, 32, 134, 3, 44, - 6, 69, 84, 84, 69, 82, 32, 151, 36, 73, 128, 3, 154, 2, 65, 214, 1, 66, - 242, 1, 67, 150, 1, 68, 254, 1, 69, 206, 2, 71, 130, 1, 72, 134, 1, 73, - 230, 3, 75, 222, 2, 76, 134, 1, 77, 114, 78, 106, 79, 110, 80, 50, 82, - 198, 1, 83, 218, 2, 84, 218, 2, 85, 246, 1, 87, 54, 89, 166, 1, 90, 198, - 204, 29, 70, 134, 14, 74, 2, 86, 159, 20, 81, 17, 108, 6, 32, 87, 73, 84, - 72, 32, 36, 9, 66, 75, 72, 65, 83, 73, 65, 78, 32, 149, 159, 12, 4, 76, - 69, 85, 84, 4, 178, 195, 9, 68, 191, 187, 3, 66, 8, 216, 139, 13, 3, 67, - 72, 69, 210, 210, 6, 68, 195, 175, 10, 72, 18, 110, 65, 78, 73, 32, 3, - 82, 79, 65, 148, 163, 3, 6, 76, 69, 78, 68, 69, 68, 246, 228, 9, 89, 131, - 134, 17, 69, 6, 200, 21, 6, 82, 82, 69, 68, 32, 79, 153, 136, 12, 5, 83, - 72, 75, 73, 82, 4, 230, 2, 78, 207, 160, 3, 71, 2, 163, 180, 10, 68, 14, - 76, 2, 72, 69, 246, 9, 76, 136, 153, 13, 4, 82, 79, 83, 83, 159, 189, 16, - 67, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 150, 29, 68, 163, 191, 29, 86, - 26, 96, 2, 74, 69, 20, 6, 79, 85, 66, 76, 69, 32, 66, 90, 158, 222, 29, - 67, 186, 22, 87, 215, 22, 69, 5, 235, 237, 22, 82, 4, 36, 3, 77, 79, 78, - 195, 139, 30, 79, 2, 153, 13, 2, 79, 67, 12, 46, 69, 218, 138, 29, 90, - 206, 105, 72, 3, 87, 5, 131, 236, 29, 76, 41, 86, 76, 98, 78, 110, 82, - 166, 15, 32, 214, 244, 12, 83, 230, 204, 14, 77, 231, 183, 2, 70, 11, 33, - 6, 32, 87, 73, 84, 72, 32, 8, 166, 20, 77, 174, 241, 12, 68, 242, 204, - 14, 84, 183, 97, 72, 13, 33, 6, 32, 87, 73, 84, 72, 32, 10, 198, 19, 77, - 174, 241, 12, 68, 202, 52, 76, 170, 152, 14, 84, 183, 97, 72, 5, 149, - 214, 28, 5, 32, 87, 73, 84, 72, 14, 32, 2, 72, 69, 163, 241, 29, 74, 13, - 33, 6, 32, 87, 73, 84, 72, 32, 10, 142, 18, 77, 146, 15, 85, 158, 226, - 12, 68, 155, 31, 83, 12, 26, 65, 171, 240, 29, 87, 11, 48, 6, 32, 87, 73, - 84, 72, 32, 139, 155, 28, 82, 6, 178, 130, 13, 68, 166, 174, 15, 72, 247, - 165, 1, 83, 35, 84, 6, 32, 87, 73, 84, 72, 32, 50, 69, 74, 79, 201, 1, 6, - 90, 72, 73, 84, 83, 65, 6, 166, 184, 9, 68, 214, 10, 71, 167, 202, 3, 77, - 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 166, 194, 9, 71, 235, 176, 3, 66, - 17, 11, 84, 14, 48, 6, 73, 70, 73, 69, 68, 32, 135, 132, 30, 65, 12, 80, - 2, 67, 76, 38, 76, 234, 151, 3, 66, 246, 225, 25, 89, 178, 137, 1, 65, 3, - 69, 2, 33, 6, 79, 83, 69, 68, 32, 76, 2, 151, 4, 73, 5, 241, 142, 13, 14, - 32, 87, 73, 84, 72, 32, 68, 79, 85, 66, 76, 69, 32, 71, 34, 102, 65, 98, - 79, 232, 206, 17, 10, 72, 65, 75, 65, 83, 83, 73, 65, 78, 32, 174, 155, - 12, 74, 255, 2, 83, 11, 33, 6, 32, 87, 73, 84, 72, 32, 8, 142, 253, 12, - 68, 166, 174, 15, 72, 170, 165, 1, 86, 79, 83, 18, 36, 3, 77, 73, 32, - 155, 195, 26, 80, 16, 58, 68, 254, 166, 12, 76, 2, 78, 2, 83, 2, 84, 3, - 90, 6, 250, 166, 12, 90, 182, 194, 17, 74, 215, 22, 69, 8, 94, 73, 224, - 201, 10, 10, 79, 78, 71, 45, 76, 69, 71, 71, 69, 68, 194, 158, 19, 74, - 159, 20, 72, 2, 253, 147, 3, 4, 84, 84, 76, 69, 4, 21, 3, 79, 78, 79, 4, - 18, 67, 39, 71, 2, 217, 134, 19, 4, 85, 76, 65, 82, 2, 245, 10, 4, 82, - 65, 80, 72, 6, 62, 69, 216, 133, 19, 5, 65, 82, 82, 79, 87, 247, 224, 10, - 74, 2, 209, 251, 12, 5, 85, 84, 82, 65, 76, 11, 52, 4, 77, 69, 71, 65, - 166, 3, 32, 159, 249, 29, 84, 5, 209, 211, 29, 8, 32, 87, 73, 84, 72, 32, - 84, 73, 10, 138, 6, 69, 182, 242, 12, 65, 247, 239, 16, 83, 14, 50, 69, - 100, 4, 79, 85, 78, 68, 143, 248, 29, 72, 8, 37, 7, 86, 69, 82, 83, 69, - 68, 32, 8, 134, 201, 19, 68, 214, 166, 9, 84, 190, 102, 89, 151, 14, 90, - 4, 234, 160, 10, 32, 153, 249, 1, 2, 69, 68, 34, 108, 4, 67, 72, 87, 65, - 34, 72, 132, 1, 4, 79, 70, 84, 32, 130, 245, 12, 84, 213, 1, 5, 69, 77, - 73, 83, 79, 5, 11, 32, 2, 167, 241, 5, 87, 16, 92, 4, 79, 82, 84, 32, - 224, 243, 12, 2, 72, 65, 162, 135, 15, 67, 214, 230, 1, 87, 215, 22, 65, - 6, 194, 192, 27, 73, 231, 183, 2, 85, 8, 38, 69, 246, 240, 28, 83, 151, - 112, 68, 4, 218, 247, 29, 76, 3, 77, 28, 140, 1, 4, 65, 76, 76, 32, 50, - 69, 106, 83, 232, 141, 12, 11, 72, 82, 69, 69, 45, 76, 69, 71, 71, 69, - 68, 166, 186, 17, 67, 186, 22, 74, 3, 87, 6, 130, 238, 12, 72, 254, 254, - 15, 89, 223, 114, 84, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 26, 77, 175, - 241, 12, 68, 2, 217, 251, 21, 5, 73, 68, 68, 76, 69, 8, 194, 222, 29, 72, - 2, 83, 2, 87, 215, 22, 69, 15, 58, 32, 114, 75, 53, 8, 78, 66, 76, 69, - 78, 68, 69, 68, 6, 29, 5, 87, 73, 84, 72, 32, 6, 26, 68, 215, 251, 12, - 77, 4, 204, 168, 9, 5, 79, 85, 66, 76, 69, 187, 8, 73, 5, 11, 82, 2, 213, - 4, 6, 65, 73, 78, 73, 65, 78, 2, 159, 245, 24, 32, 4, 236, 220, 28, 4, - 73, 68, 69, 32, 135, 150, 1, 69, 18, 62, 65, 28, 3, 69, 82, 85, 230, 241, - 29, 73, 2, 78, 3, 85, 7, 254, 241, 29, 69, 3, 84, 7, 33, 6, 32, 87, 73, - 84, 72, 32, 4, 170, 164, 9, 68, 179, 203, 3, 66, 18, 18, 69, 71, 72, 9, - 156, 1, 7, 32, 87, 73, 84, 72, 32, 68, 141, 237, 29, 2, 77, 76, 10, 26, - 69, 215, 217, 29, 87, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 26, 68, 147, - 222, 12, 66, 4, 254, 172, 9, 73, 227, 190, 3, 69, 6, 37, 7, 71, 65, 84, - 85, 82, 69, 32, 6, 66, 65, 180, 200, 15, 2, 84, 69, 153, 249, 13, 4, 69, - 78, 32, 71, 2, 167, 211, 29, 32, 52, 198, 1, 66, 38, 68, 38, 69, 36, 3, - 71, 72, 69, 38, 72, 158, 144, 22, 89, 170, 222, 5, 83, 134, 114, 84, 134, - 11, 90, 130, 64, 73, 150, 19, 67, 186, 22, 80, 2, 86, 158, 20, 75, 186, - 2, 65, 2, 79, 3, 85, 4, 250, 230, 12, 89, 131, 134, 17, 69, 6, 182, 236, - 28, 90, 163, 128, 1, 69, 6, 178, 236, 29, 70, 2, 76, 3, 83, 5, 201, 5, 5, - 32, 87, 73, 84, 72, 4, 11, 65, 5, 159, 128, 28, 82, 2, 145, 250, 15, 4, - 72, 79, 85, 83, 214, 15, 178, 1, 65, 138, 4, 67, 54, 69, 154, 35, 73, - 166, 23, 79, 154, 45, 82, 174, 3, 85, 172, 238, 12, 13, 78, 65, 32, 68, - 79, 85, 66, 76, 69, 32, 72, 69, 76, 234, 197, 15, 86, 207, 47, 76, 30, - 116, 4, 71, 71, 69, 82, 146, 1, 78, 32, 4, 82, 75, 32, 83, 36, 2, 83, 72, - 212, 132, 22, 2, 76, 69, 131, 145, 1, 84, 9, 11, 32, 6, 44, 5, 87, 73, - 84, 72, 32, 247, 213, 6, 75, 4, 44, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, - 2, 141, 207, 28, 4, 84, 32, 71, 85, 4, 250, 169, 29, 67, 251, 30, 71, 4, - 242, 207, 21, 85, 155, 157, 5, 72, 10, 30, 32, 105, 3, 69, 68, 32, 4, 60, - 9, 87, 73, 84, 72, 32, 76, 69, 70, 84, 155, 209, 28, 83, 2, 17, 2, 32, - 85, 2, 163, 148, 23, 80, 6, 154, 236, 4, 84, 234, 188, 12, 76, 207, 210, - 10, 79, 10, 230, 229, 29, 49, 2, 50, 2, 51, 2, 52, 3, 83, 180, 4, 222, 1, - 67, 248, 1, 5, 71, 82, 69, 69, 32, 98, 76, 82, 78, 228, 3, 8, 80, 65, 82, - 84, 77, 69, 78, 84, 32, 12, 82, 69, 76, 73, 67, 84, 32, 72, 79, 85, 83, - 69, 42, 83, 174, 6, 86, 148, 209, 25, 2, 65, 70, 227, 203, 3, 69, 8, 50, - 73, 173, 253, 5, 6, 82, 69, 65, 83, 69, 32, 6, 56, 4, 77, 65, 76, 32, - 237, 169, 9, 4, 68, 85, 79, 85, 4, 88, 9, 83, 69, 80, 65, 82, 65, 84, 79, - 82, 181, 255, 21, 7, 69, 88, 80, 79, 78, 69, 78, 2, 21, 3, 32, 75, 69, 2, - 167, 204, 28, 89, 6, 164, 201, 22, 4, 67, 69, 76, 83, 202, 145, 6, 83, - 177, 106, 8, 70, 65, 72, 82, 69, 78, 72, 69, 9, 248, 252, 16, 5, 73, 86, - 69, 82, 89, 160, 130, 6, 2, 84, 65, 203, 152, 5, 69, 34, 104, 20, 84, 73, - 83, 84, 82, 89, 32, 83, 89, 77, 66, 79, 76, 32, 76, 73, 71, 72, 84, 32, - 167, 244, 21, 83, 30, 88, 4, 68, 79, 87, 78, 0, 2, 85, 80, 153, 1, 9, 86, - 69, 82, 84, 73, 67, 65, 76, 32, 8, 69, 15, 32, 65, 78, 68, 32, 72, 79, - 82, 73, 90, 79, 78, 84, 65, 76, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 214, - 239, 27, 87, 134, 26, 67, 167, 45, 84, 14, 52, 4, 65, 78, 68, 32, 45, 5, - 87, 73, 84, 72, 32, 10, 162, 163, 22, 66, 42, 84, 171, 203, 5, 87, 4, - 202, 136, 28, 67, 167, 45, 84, 2, 177, 239, 24, 3, 32, 83, 84, 2, 237, - 149, 23, 5, 32, 66, 85, 73, 76, 170, 1, 64, 2, 67, 69, 48, 2, 69, 82, - 129, 5, 5, 75, 84, 79, 80, 32, 2, 177, 200, 27, 7, 78, 68, 73, 78, 71, + 85, 2, 11, 83, 2, 151, 173, 11, 72, 4, 29, 5, 69, 83, 72, 73, 71, 5, 11, + 32, 2, 11, 84, 2, 149, 208, 30, 6, 73, 77, 69, 83, 32, 66, 8, 92, 14, 85, + 32, 80, 76, 85, 83, 32, 85, 32, 80, 76, 85, 83, 32, 142, 207, 30, 66, + 215, 50, 77, 4, 11, 85, 5, 11, 32, 2, 11, 71, 2, 159, 240, 30, 85, 21, + 72, 7, 32, 84, 73, 77, 69, 83, 32, 136, 1, 2, 85, 77, 219, 147, 30, 66, + 10, 50, 76, 16, 2, 77, 69, 50, 83, 195, 147, 31, 85, 2, 203, 6, 65, 5, + 11, 32, 2, 189, 207, 26, 4, 80, 76, 85, 83, 2, 255, 171, 11, 72, 7, 37, + 7, 32, 84, 73, 77, 69, 83, 32, 4, 130, 11, 75, 203, 133, 31, 80, 93, 54, + 32, 102, 50, 166, 2, 73, 22, 85, 147, 143, 31, 52, 4, 62, 83, 153, 153, + 30, 9, 67, 82, 79, 83, 83, 73, 78, 71, 32, 2, 153, 208, 26, 4, 72, 69, + 83, 72, 23, 11, 32, 20, 48, 6, 84, 73, 77, 69, 83, 32, 179, 200, 10, 73, + 18, 46, 65, 82, 85, 218, 143, 30, 78, 251, 125, 72, 6, 48, 6, 32, 80, 76, + 85, 83, 32, 167, 144, 31, 76, 4, 234, 141, 31, 72, 3, 78, 8, 26, 50, 239, + 143, 31, 68, 7, 33, 6, 32, 80, 76, 85, 83, 32, 4, 166, 161, 29, 65, 203, + 218, 1, 66, 5, 163, 143, 31, 51, 59, 56, 7, 32, 84, 73, 77, 69, 83, 32, + 165, 4, 2, 68, 65, 52, 134, 1, 65, 46, 68, 38, 71, 82, 73, 46, 76, 78, + 83, 46, 85, 142, 231, 29, 66, 170, 36, 77, 238, 90, 84, 146, 17, 75, 162, + 17, 72, 3, 80, 5, 11, 83, 2, 11, 72, 2, 227, 205, 17, 71, 4, 214, 164, + 11, 65, 235, 152, 19, 85, 10, 26, 65, 227, 140, 31, 85, 9, 34, 78, 190, + 140, 31, 76, 3, 82, 2, 231, 9, 50, 6, 210, 248, 30, 71, 202, 18, 83, 147, + 1, 77, 6, 46, 85, 233, 218, 23, 5, 65, 75, 45, 54, 54, 4, 206, 139, 31, + 51, 3, 77, 4, 148, 221, 23, 2, 73, 71, 203, 151, 7, 72, 6, 42, 32, 170, + 170, 14, 82, 183, 224, 16, 68, 2, 169, 220, 29, 6, 80, 76, 85, 83, 32, + 71, 5, 11, 32, 2, 145, 137, 14, 4, 84, 73, 77, 69, 17, 84, 7, 32, 84, 73, + 77, 69, 83, 32, 232, 250, 29, 2, 85, 77, 194, 142, 1, 50, 3, 88, 8, 50, + 84, 232, 173, 27, 2, 75, 85, 143, 219, 3, 65, 2, 11, 65, 2, 203, 218, 23, + 75, 6, 26, 51, 187, 136, 31, 85, 5, 29, 5, 32, 84, 73, 77, 69, 2, 21, 3, + 83, 32, 75, 2, 11, 65, 2, 163, 134, 24, 83, 42, 50, 65, 190, 1, 73, 146, + 1, 85, 235, 215, 23, 69, 13, 50, 32, 186, 248, 29, 77, 194, 142, 1, 55, + 3, 71, 4, 56, 8, 83, 81, 85, 65, 82, 69, 68, 32, 135, 250, 25, 84, 2, 11, + 84, 2, 21, 3, 73, 77, 69, 2, 11, 83, 2, 181, 141, 30, 2, 32, 75, 15, 86, + 66, 232, 188, 23, 6, 32, 79, 86, 69, 82, 32, 186, 27, 90, 250, 172, 7, + 51, 3, 71, 5, 17, 2, 32, 75, 2, 17, 2, 65, 66, 2, 155, 2, 65, 15, 84, 10, + 32, 79, 86, 69, 82, 32, 90, 85, 32, 80, 42, 53, 142, 139, 30, 66, 215, + 120, 77, 2, 137, 224, 29, 5, 76, 85, 83, 32, 83, 7, 37, 7, 32, 84, 73, + 77, 69, 83, 32, 4, 32, 2, 84, 72, 151, 131, 31, 65, 2, 17, 2, 82, 69, 2, + 11, 69, 2, 29, 5, 32, 68, 73, 83, 72, 2, 11, 32, 2, 143, 246, 25, 84, 8, + 42, 32, 146, 187, 23, 73, 227, 213, 3, 67, 4, 186, 246, 22, 79, 161, 141, + 7, 8, 87, 73, 84, 72, 32, 83, 84, 82, 18, 134, 1, 76, 162, 1, 82, 189, + 187, 30, 23, 86, 69, 68, 32, 83, 84, 69, 77, 32, 80, 65, 82, 65, 71, 82, + 65, 80, 72, 32, 83, 73, 71, 78, 10, 48, 2, 89, 32, 177, 161, 3, 4, 73, + 78, 71, 32, 8, 68, 2, 76, 79, 253, 216, 28, 9, 66, 82, 65, 67, 75, 69, + 84, 32, 69, 6, 206, 181, 27, 71, 231, 201, 3, 79, 6, 52, 5, 69, 78, 67, + 89, 32, 53, 4, 89, 32, 65, 78, 4, 228, 213, 25, 4, 69, 88, 67, 72, 151, + 162, 4, 83, 2, 145, 191, 20, 3, 68, 32, 82, 4, 254, 129, 3, 79, 163, 227, + 26, 65, 240, 8, 128, 1, 2, 80, 82, 140, 9, 7, 82, 73, 76, 76, 73, 67, 32, + 128, 189, 26, 7, 76, 73, 78, 68, 82, 73, 67, 193, 137, 3, 2, 67, 76, 180, + 2, 140, 1, 13, 73, 79, 84, 32, 83, 89, 76, 76, 65, 66, 76, 69, 32, 169, + 1, 16, 79, 45, 77, 73, 78, 79, 65, 78, 32, 83, 73, 71, 78, 32, 67, 77, + 110, 170, 187, 7, 75, 2, 76, 2, 77, 2, 78, 2, 80, 2, 82, 2, 83, 2, 84, + 98, 87, 202, 38, 74, 2, 90, 178, 187, 7, 88, 206, 221, 15, 65, 2, 69, 2, + 73, 2, 79, 3, 85, 198, 1, 46, 48, 146, 5, 49, 189, 233, 26, 2, 51, 48, + 170, 1, 102, 48, 78, 49, 74, 50, 78, 51, 78, 52, 62, 53, 86, 55, 206, + 224, 10, 57, 190, 3, 54, 187, 205, 14, 56, 16, 134, 249, 30, 49, 2, 50, + 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 16, 194, 3, 50, 250, 244, 30, + 48, 2, 49, 2, 51, 2, 53, 2, 55, 3, 57, 16, 242, 247, 30, 49, 2, 51, 2, + 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 16, 166, 247, 30, 48, 2, 51, 2, + 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 12, 218, 246, 30, 48, 2, 49, 2, + 52, 2, 54, 2, 55, 3, 57, 18, 158, 246, 30, 48, 2, 49, 2, 50, 2, 51, 2, + 52, 2, 53, 2, 54, 2, 56, 3, 57, 20, 82, 53, 250, 244, 30, 48, 2, 49, 2, + 50, 2, 51, 2, 52, 2, 54, 2, 56, 3, 57, 5, 247, 244, 30, 66, 24, 18, 48, + 87, 49, 18, 206, 244, 30, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 55, + 2, 56, 3, 57, 6, 250, 243, 30, 48, 2, 50, 3, 52, 184, 6, 140, 1, 9, 67, + 65, 80, 73, 84, 65, 76, 32, 76, 206, 4, 75, 32, 7, 76, 69, 84, 84, 69, + 82, 32, 132, 1, 3, 80, 65, 89, 30, 83, 199, 41, 84, 242, 2, 44, 6, 69, + 84, 84, 69, 82, 32, 167, 43, 73, 236, 2, 150, 2, 76, 46, 78, 34, 80, 34, + 82, 62, 84, 62, 85, 190, 5, 65, 214, 1, 66, 230, 1, 67, 150, 1, 68, 254, + 1, 69, 206, 2, 71, 130, 1, 72, 134, 1, 73, 230, 3, 75, 226, 3, 77, 218, + 1, 79, 226, 2, 83, 218, 7, 89, 166, 1, 90, 238, 163, 30, 70, 134, 14, 74, + 2, 86, 2, 87, 159, 20, 81, 6, 214, 25, 73, 202, 191, 30, 74, 159, 20, 72, + 4, 254, 26, 69, 247, 189, 30, 74, 8, 254, 33, 69, 211, 185, 30, 83, 12, + 182, 28, 69, 224, 188, 9, 3, 79, 85, 78, 187, 147, 21, 72, 20, 162, 33, + 69, 106, 83, 182, 159, 30, 67, 186, 22, 74, 3, 87, 13, 186, 34, 32, 115, + 75, 2, 141, 229, 30, 3, 65, 86, 89, 6, 236, 10, 5, 77, 85, 76, 84, 73, + 216, 177, 13, 2, 80, 65, 249, 149, 12, 14, 83, 77, 65, 76, 76, 32, 67, + 65, 80, 73, 84, 65, 76, 32, 2, 241, 194, 30, 2, 69, 82, 186, 3, 136, 1, + 6, 77, 65, 76, 76, 32, 76, 189, 37, 22, 85, 66, 83, 67, 82, 73, 80, 84, + 32, 83, 77, 65, 76, 76, 32, 76, 69, 84, 84, 69, 82, 32, 134, 3, 44, 6, + 69, 84, 84, 69, 82, 32, 139, 36, 73, 128, 3, 154, 2, 65, 214, 1, 66, 230, + 1, 67, 150, 1, 68, 254, 1, 69, 206, 2, 71, 130, 1, 72, 134, 1, 73, 230, + 3, 75, 222, 2, 76, 134, 1, 77, 114, 78, 106, 79, 110, 80, 50, 82, 198, 1, + 83, 218, 2, 84, 218, 2, 85, 246, 1, 87, 54, 89, 166, 1, 90, 238, 163, 30, + 70, 134, 14, 74, 2, 86, 159, 20, 81, 17, 108, 6, 32, 87, 73, 84, 72, 32, + 36, 9, 66, 75, 72, 65, 83, 73, 65, 78, 32, 249, 198, 12, 4, 76, 69, 85, + 84, 4, 174, 221, 9, 68, 203, 201, 3, 66, 8, 176, 181, 13, 3, 67, 72, 69, + 206, 248, 6, 68, 139, 183, 10, 72, 18, 118, 65, 78, 73, 192, 164, 3, 6, + 76, 69, 78, 68, 69, 68, 140, 171, 6, 3, 82, 79, 65, 174, 226, 3, 89, 199, + 179, 17, 69, 6, 180, 21, 6, 82, 82, 69, 68, 32, 79, 137, 176, 12, 5, 83, + 72, 75, 73, 82, 4, 210, 2, 78, 239, 161, 3, 71, 14, 76, 2, 72, 69, 246, + 9, 76, 248, 166, 13, 4, 82, 79, 83, 83, 215, 134, 17, 67, 9, 33, 6, 32, + 87, 73, 84, 72, 32, 6, 150, 29, 68, 203, 150, 30, 86, 26, 96, 2, 74, 69, + 20, 6, 79, 85, 66, 76, 69, 32, 66, 90, 198, 181, 30, 67, 186, 22, 87, + 215, 22, 69, 5, 219, 191, 23, 82, 4, 36, 3, 77, 79, 78, 235, 226, 30, 79, + 2, 153, 13, 2, 79, 67, 12, 46, 69, 130, 226, 29, 90, 206, 105, 72, 3, 87, + 5, 171, 195, 30, 76, 41, 86, 76, 98, 78, 110, 82, 166, 15, 32, 186, 158, + 13, 83, 174, 246, 14, 77, 227, 187, 2, 70, 11, 33, 6, 32, 87, 73, 84, 72, + 32, 8, 166, 20, 77, 146, 155, 13, 68, 186, 246, 14, 84, 163, 98, 72, 13, + 33, 6, 32, 87, 73, 84, 72, 32, 10, 198, 19, 77, 146, 155, 13, 68, 138, + 60, 76, 178, 186, 14, 84, 163, 98, 72, 5, 253, 172, 29, 5, 32, 87, 73, + 84, 72, 14, 32, 2, 72, 69, 203, 200, 30, 74, 13, 33, 6, 32, 87, 73, 84, + 72, 32, 10, 142, 18, 77, 146, 15, 85, 130, 140, 13, 68, 163, 32, 83, 12, + 26, 65, 211, 199, 30, 87, 11, 48, 6, 32, 87, 73, 84, 72, 32, 155, 239, + 28, 82, 6, 150, 172, 13, 68, 218, 216, 15, 72, 135, 169, 1, 83, 35, 84, + 6, 32, 87, 73, 84, 72, 32, 50, 69, 74, 79, 201, 1, 6, 90, 72, 73, 84, 83, + 65, 6, 174, 210, 9, 68, 202, 11, 71, 215, 217, 3, 77, 7, 33, 6, 32, 87, + 73, 84, 72, 32, 4, 162, 221, 9, 71, 131, 190, 3, 66, 17, 11, 84, 14, 48, + 6, 73, 70, 73, 69, 68, 32, 175, 219, 30, 65, 12, 80, 2, 67, 76, 38, 76, + 138, 153, 3, 66, 254, 183, 26, 89, 178, 137, 1, 65, 3, 69, 2, 33, 6, 79, + 83, 69, 68, 32, 76, 2, 151, 4, 73, 5, 141, 185, 13, 14, 32, 87, 73, 84, + 72, 32, 68, 79, 85, 66, 76, 69, 32, 71, 34, 102, 65, 98, 79, 248, 155, + 18, 10, 72, 65, 75, 65, 83, 83, 73, 65, 78, 32, 198, 165, 12, 74, 255, 2, + 83, 11, 33, 6, 32, 87, 73, 84, 72, 32, 8, 242, 166, 13, 68, 218, 216, 15, + 72, 186, 168, 1, 86, 79, 83, 18, 36, 3, 77, 73, 32, 187, 150, 27, 80, 16, + 58, 68, 238, 206, 12, 76, 2, 78, 2, 83, 2, 84, 3, 90, 6, 234, 206, 12, + 90, 238, 241, 17, 74, 215, 22, 69, 8, 94, 73, 240, 238, 10, 10, 79, 78, + 71, 45, 76, 69, 71, 71, 69, 68, 218, 208, 19, 74, 159, 20, 72, 2, 157, + 149, 3, 4, 84, 84, 76, 69, 4, 21, 3, 79, 78, 79, 4, 18, 67, 39, 71, 2, + 137, 213, 19, 4, 85, 76, 65, 82, 2, 245, 10, 4, 82, 65, 80, 72, 6, 62, + 69, 136, 212, 19, 5, 65, 82, 82, 79, 87, 239, 233, 10, 74, 2, 181, 165, + 13, 5, 85, 84, 82, 65, 76, 11, 52, 4, 77, 69, 71, 65, 166, 3, 32, 199, + 208, 30, 84, 5, 249, 170, 30, 8, 32, 87, 73, 84, 72, 32, 84, 73, 10, 138, + 6, 69, 154, 156, 13, 65, 187, 157, 17, 83, 14, 50, 69, 100, 4, 79, 85, + 78, 68, 183, 207, 30, 72, 8, 37, 7, 86, 69, 82, 83, 69, 68, 32, 8, 230, + 152, 20, 68, 158, 174, 9, 84, 190, 102, 89, 151, 14, 90, 4, 250, 197, 10, + 32, 253, 251, 1, 2, 69, 68, 34, 108, 4, 67, 72, 87, 65, 34, 72, 132, 1, + 4, 79, 70, 84, 32, 230, 158, 13, 84, 213, 1, 5, 69, 77, 73, 83, 79, 5, + 11, 32, 2, 235, 242, 5, 87, 16, 92, 4, 79, 82, 84, 32, 196, 157, 13, 2, + 72, 65, 206, 177, 15, 67, 238, 233, 1, 87, 215, 22, 65, 6, 238, 147, 28, + 73, 227, 187, 2, 85, 8, 38, 69, 158, 200, 29, 83, 151, 112, 68, 4, 130, + 207, 30, 76, 3, 77, 28, 140, 1, 4, 65, 76, 76, 32, 50, 69, 106, 83, 216, + 181, 12, 11, 72, 82, 69, 69, 45, 76, 69, 71, 71, 69, 68, 222, 233, 17, + 67, 186, 22, 74, 3, 87, 6, 194, 151, 13, 72, 230, 172, 16, 89, 223, 114, + 84, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 26, 77, 147, 155, 13, 68, 2, + 185, 203, 22, 5, 73, 68, 68, 76, 69, 8, 234, 181, 30, 72, 2, 83, 2, 87, + 215, 22, 69, 15, 58, 32, 114, 75, 53, 8, 78, 66, 76, 69, 78, 68, 69, 68, + 6, 29, 5, 87, 73, 84, 72, 32, 6, 26, 68, 131, 166, 13, 77, 4, 248, 194, + 9, 5, 79, 85, 66, 76, 69, 139, 9, 73, 5, 11, 82, 2, 213, 4, 6, 65, 73, + 78, 73, 65, 78, 2, 215, 198, 25, 32, 4, 148, 180, 29, 4, 73, 68, 69, 32, + 135, 150, 1, 69, 18, 62, 65, 28, 3, 69, 82, 85, 142, 201, 30, 73, 2, 78, + 3, 85, 7, 166, 201, 30, 69, 3, 84, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, + 178, 190, 9, 68, 143, 219, 3, 66, 18, 18, 69, 71, 72, 9, 156, 1, 7, 32, + 87, 73, 84, 72, 32, 68, 181, 196, 30, 2, 77, 76, 10, 26, 69, 255, 176, + 30, 87, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 26, 68, 167, 134, 13, 66, 4, + 250, 199, 9, 73, 203, 205, 3, 69, 6, 37, 7, 71, 65, 84, 85, 82, 69, 32, + 6, 66, 65, 160, 148, 16, 2, 84, 69, 213, 132, 14, 4, 69, 78, 32, 71, 2, + 207, 170, 30, 32, 52, 198, 1, 66, 38, 68, 38, 69, 36, 3, 71, 72, 69, 38, + 72, 138, 224, 22, 89, 206, 226, 5, 83, 158, 117, 84, 134, 11, 90, 130, + 64, 73, 150, 19, 67, 186, 22, 80, 2, 86, 158, 20, 75, 186, 2, 65, 2, 79, + 3, 85, 4, 222, 144, 13, 89, 199, 179, 17, 69, 6, 222, 195, 29, 90, 163, + 128, 1, 69, 6, 218, 195, 30, 70, 2, 76, 3, 83, 5, 201, 5, 5, 32, 87, 73, + 84, 72, 4, 11, 65, 5, 175, 212, 28, 82, 2, 177, 198, 16, 4, 72, 79, 85, + 83, 218, 15, 178, 1, 65, 138, 4, 67, 54, 69, 210, 35, 73, 166, 23, 79, + 138, 46, 82, 174, 3, 85, 252, 164, 13, 13, 78, 65, 32, 68, 79, 85, 66, + 76, 69, 32, 72, 69, 76, 154, 229, 15, 86, 207, 47, 76, 30, 116, 4, 71, + 71, 69, 82, 146, 1, 78, 32, 4, 82, 75, 32, 83, 36, 2, 83, 72, 180, 212, + 22, 2, 76, 69, 139, 147, 1, 84, 9, 11, 32, 6, 44, 5, 87, 73, 84, 72, 32, + 195, 218, 6, 75, 4, 44, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, 2, 181, 166, + 29, 4, 84, 32, 71, 85, 4, 162, 129, 30, 67, 251, 30, 71, 4, 190, 159, 22, + 85, 251, 160, 5, 72, 10, 30, 32, 105, 3, 69, 68, 32, 4, 60, 9, 87, 73, + 84, 72, 32, 76, 69, 70, 84, 195, 168, 29, 83, 2, 17, 2, 32, 85, 2, 139, + 230, 23, 80, 6, 178, 237, 4, 84, 226, 136, 13, 76, 207, 217, 10, 79, 10, + 142, 189, 30, 49, 2, 50, 2, 51, 2, 52, 3, 83, 182, 4, 222, 1, 67, 248, 1, + 5, 71, 82, 69, 69, 32, 98, 76, 82, 78, 228, 3, 8, 80, 65, 82, 84, 77, 69, + 78, 84, 32, 12, 82, 69, 76, 73, 67, 84, 32, 72, 79, 85, 83, 69, 42, 83, + 174, 6, 86, 240, 162, 26, 2, 65, 70, 175, 209, 3, 69, 8, 50, 73, 217, + 255, 5, 6, 82, 69, 65, 83, 69, 32, 6, 56, 4, 77, 65, 76, 32, 201, 197, 9, + 4, 68, 85, 79, 85, 4, 88, 9, 83, 69, 80, 65, 82, 65, 84, 79, 82, 149, + 207, 22, 7, 69, 88, 80, 79, 78, 69, 78, 2, 21, 3, 32, 75, 69, 2, 207, + 163, 29, 89, 6, 140, 155, 23, 4, 67, 69, 76, 83, 138, 151, 6, 83, 177, + 106, 8, 70, 65, 72, 82, 69, 78, 72, 69, 9, 136, 202, 17, 5, 73, 86, 69, + 82, 89, 248, 134, 6, 2, 84, 65, 147, 155, 5, 69, 34, 104, 20, 84, 73, 83, + 84, 82, 89, 32, 83, 89, 77, 66, 79, 76, 32, 76, 73, 71, 72, 84, 32, 135, + 196, 22, 83, 30, 88, 4, 68, 79, 87, 78, 0, 2, 85, 80, 153, 1, 9, 86, 69, + 82, 84, 73, 67, 65, 76, 32, 8, 69, 15, 32, 65, 78, 68, 32, 72, 79, 82, + 73, 90, 79, 78, 84, 65, 76, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 230, + 195, 28, 87, 142, 26, 67, 247, 47, 84, 14, 52, 4, 65, 78, 68, 32, 45, 5, + 87, 73, 84, 72, 32, 10, 146, 245, 22, 66, 42, 84, 203, 205, 5, 87, 4, + 226, 220, 28, 67, 247, 47, 84, 2, 237, 192, 25, 3, 32, 83, 84, 2, 213, + 231, 23, 5, 32, 66, 85, 73, 76, 170, 1, 64, 2, 67, 69, 48, 2, 69, 82, + 129, 5, 5, 75, 84, 79, 80, 32, 2, 185, 156, 28, 7, 78, 68, 73, 78, 71, 32, 78, 164, 1, 32, 3, 69, 84, 32, 183, 4, 84, 160, 1, 56, 6, 67, 65, 80, 73, 84, 65, 1, 4, 83, 77, 65, 76, 80, 45, 9, 76, 32, 76, 69, 84, 84, 69, 82, 32, 80, 218, 1, 69, 96, 4, 76, 79, 78, 71, 0, 5, 83, 72, 79, 82, 84, - 74, 79, 30, 84, 2, 90, 158, 237, 11, 67, 146, 247, 15, 66, 2, 68, 2, 74, - 2, 80, 2, 86, 2, 89, 130, 100, 71, 2, 75, 186, 105, 87, 162, 19, 65, 203, - 17, 72, 20, 174, 199, 25, 83, 226, 146, 2, 78, 242, 252, 1, 84, 146, 1, - 70, 2, 76, 2, 77, 2, 82, 3, 87, 12, 11, 32, 12, 194, 198, 25, 65, 178, - 199, 1, 79, 178, 201, 2, 69, 3, 73, 4, 230, 214, 29, 73, 3, 87, 4, 170, - 228, 27, 72, 207, 219, 1, 69, 5, 133, 198, 28, 4, 32, 73, 83, 76, 4, 206, - 215, 26, 67, 141, 226, 1, 4, 87, 73, 78, 68, 202, 2, 100, 8, 65, 78, 65, - 71, 65, 82, 73, 32, 133, 18, 12, 73, 67, 69, 32, 67, 79, 78, 84, 82, 79, - 76, 32, 192, 2, 222, 1, 65, 38, 67, 22, 71, 36, 4, 72, 69, 65, 68, 96, 7, - 76, 69, 84, 84, 69, 82, 32, 202, 5, 83, 148, 7, 11, 86, 79, 87, 69, 76, - 32, 83, 73, 71, 78, 32, 238, 131, 19, 68, 160, 139, 6, 4, 74, 65, 73, 78, - 135, 165, 4, 79, 4, 218, 222, 12, 67, 239, 211, 12, 66, 2, 147, 149, 6, - 65, 4, 202, 222, 12, 82, 151, 238, 1, 65, 6, 44, 5, 32, 77, 65, 82, 75, - 251, 161, 29, 83, 5, 141, 146, 19, 7, 32, 87, 73, 84, 72, 32, 72, 158, 1, - 162, 2, 65, 54, 67, 62, 68, 50, 71, 62, 72, 52, 2, 77, 65, 46, 83, 170, - 157, 7, 66, 150, 131, 5, 75, 130, 198, 3, 82, 150, 173, 3, 79, 238, 192, - 3, 89, 214, 118, 85, 250, 35, 78, 138, 199, 1, 74, 174, 57, 76, 70, 84, - 46, 86, 242, 207, 1, 73, 134, 197, 1, 80, 2, 90, 138, 69, 70, 2, 81, 187, - 2, 69, 13, 154, 207, 29, 65, 2, 73, 2, 85, 2, 87, 3, 89, 10, 26, 65, 151, - 204, 29, 72, 9, 185, 2, 4, 78, 68, 82, 65, 12, 218, 240, 25, 68, 154, - 219, 3, 72, 187, 2, 65, 10, 134, 244, 12, 76, 182, 146, 16, 72, 138, 69, - 71, 187, 2, 65, 4, 188, 212, 16, 4, 69, 65, 86, 89, 131, 249, 12, 65, 5, - 157, 154, 7, 6, 82, 87, 65, 82, 73, 32, 12, 38, 72, 130, 202, 29, 83, - 187, 2, 65, 8, 36, 3, 79, 82, 84, 147, 204, 29, 65, 6, 167, 142, 12, 32, - 68, 168, 1, 19, 69, 81, 85, 69, 78, 67, 69, 32, 70, 79, 82, 32, 76, 69, - 84, 84, 69, 82, 32, 104, 4, 73, 71, 78, 32, 189, 143, 27, 10, 84, 82, 69, - 83, 83, 32, 83, 73, 71, 78, 16, 158, 219, 3, 71, 2, 75, 136, 242, 23, 3, - 68, 68, 68, 2, 82, 206, 250, 1, 89, 38, 70, 2, 81, 3, 90, 48, 178, 3, 66, - 0, 10, 69, 88, 84, 69, 78, 68, 69, 68, 32, 66, 36, 11, 67, 65, 78, 68, - 82, 65, 66, 73, 78, 68, 85, 64, 8, 87, 69, 83, 84, 69, 82, 78, 32, 32, - 10, 82, 69, 86, 69, 82, 83, 69, 68, 32, 78, 214, 203, 6, 83, 158, 190, - 12, 73, 150, 158, 6, 77, 46, 78, 190, 66, 65, 72, 18, 68, 79, 85, 66, 76, - 69, 32, 67, 65, 78, 68, 82, 65, 66, 73, 78, 68, 85, 62, 80, 144, 198, 2, - 12, 72, 73, 71, 72, 32, 83, 80, 65, 67, 73, 78, 71, 167, 80, 86, 4, 245, - 228, 12, 4, 72, 65, 76, 69, 11, 11, 32, 8, 130, 201, 22, 65, 154, 163, 3, - 86, 163, 231, 1, 84, 4, 30, 78, 21, 3, 70, 73, 86, 2, 17, 2, 73, 78, 2, - 245, 227, 21, 8, 69, 45, 76, 73, 75, 69, 32, 66, 50, 150, 1, 65, 52, 7, - 67, 65, 78, 68, 82, 65, 32, 142, 138, 19, 79, 34, 80, 162, 183, 4, 85, - 194, 229, 1, 83, 170, 69, 86, 166, 202, 1, 73, 199, 140, 2, 69, 10, 206, - 195, 29, 65, 2, 73, 2, 85, 2, 87, 3, 89, 6, 228, 138, 19, 4, 76, 79, 78, - 71, 182, 184, 10, 69, 3, 79, 10, 146, 167, 24, 70, 136, 6, 2, 83, 84, - 254, 162, 3, 84, 155, 87, 79, 232, 2, 182, 2, 65, 150, 2, 69, 74, 71, - 224, 4, 6, 78, 71, 66, 65, 84, 32, 248, 1, 5, 82, 69, 67, 84, 32, 98, 83, - 206, 2, 86, 200, 7, 2, 89, 65, 32, 4, 90, 90, 89, 32, 180, 175, 5, 2, 84, - 84, 204, 160, 15, 10, 70, 70, 69, 82, 69, 78, 67, 69, 32, 66, 197, 219, - 7, 12, 77, 69, 78, 83, 73, 79, 78, 32, 79, 82, 73, 71, 20, 42, 77, 226, - 252, 8, 69, 207, 140, 13, 71, 16, 40, 4, 79, 78, 68, 32, 247, 154, 3, 69, - 14, 128, 1, 5, 87, 73, 84, 72, 32, 250, 166, 18, 84, 232, 228, 2, 12, 83, - 72, 65, 80, 69, 32, 87, 73, 84, 72, 32, 65, 251, 238, 4, 79, 8, 198, 135, - 22, 66, 182, 2, 84, 174, 148, 4, 76, 27, 82, 14, 132, 134, 5, 5, 32, 70, - 65, 67, 69, 189, 165, 17, 4, 83, 69, 76, 32, 78, 64, 3, 73, 84, 32, 149, - 2, 8, 82, 65, 77, 32, 70, 79, 82, 32, 60, 98, 70, 44, 2, 78, 73, 2, 79, - 14, 83, 46, 84, 44, 3, 90, 69, 82, 13, 5, 69, 73, 71, 72, 84, 12, 128, 1, - 2, 73, 86, 25, 3, 79, 85, 82, 6, 87, 78, 12, 96, 4, 69, 86, 69, 78, 1, 2, - 73, 88, 12, 28, 3, 72, 82, 69, 15, 87, 6, 23, 69, 6, 11, 79, 7, 143, 249, - 16, 32, 18, 88, 5, 69, 65, 82, 84, 72, 64, 5, 71, 82, 69, 65, 84, 0, 4, - 76, 69, 83, 83, 39, 72, 7, 25, 4, 76, 89, 32, 72, 4, 138, 187, 24, 85, - 239, 145, 1, 69, 4, 193, 138, 13, 4, 69, 82, 32, 89, 4, 148, 151, 5, 7, - 69, 65, 86, 69, 78, 76, 89, 1, 4, 85, 77, 65, 78, 64, 120, 17, 78, 69, - 71, 65, 84, 73, 86, 69, 32, 67, 73, 82, 67, 76, 69, 68, 32, 41, 9, 67, - 73, 82, 67, 76, 69, 68, 32, 83, 42, 38, 83, 182, 32, 78, 255, 202, 20, - 68, 22, 49, 10, 65, 78, 83, 45, 83, 69, 82, 73, 70, 32, 22, 254, 31, 78, - 199, 162, 27, 68, 4, 184, 161, 27, 15, 67, 85, 82, 82, 69, 78, 84, 32, - 83, 89, 77, 66, 79, 76, 32, 187, 248, 1, 72, 12, 98, 65, 144, 1, 5, 67, - 79, 78, 84, 73, 244, 227, 15, 3, 84, 79, 82, 253, 152, 10, 3, 71, 85, 73, - 6, 76, 9, 80, 80, 79, 73, 78, 84, 69, 68, 32, 169, 149, 27, 4, 66, 76, - 69, 68, 4, 196, 162, 17, 7, 66, 85, 84, 32, 82, 69, 76, 203, 212, 11, 70, - 2, 53, 11, 78, 85, 79, 85, 83, 32, 85, 78, 68, 69, 82, 2, 209, 132, 17, - 3, 76, 73, 78, 156, 1, 80, 9, 69, 83, 32, 65, 75, 85, 82, 85, 32, 238, 5, - 73, 229, 253, 16, 2, 79, 82, 144, 1, 142, 2, 68, 36, 7, 76, 69, 84, 84, - 69, 82, 32, 236, 1, 5, 83, 73, 71, 78, 32, 58, 86, 240, 162, 9, 6, 77, - 69, 68, 73, 65, 76, 234, 132, 5, 71, 186, 232, 4, 69, 148, 209, 4, 12, - 80, 82, 69, 70, 73, 88, 69, 68, 32, 78, 65, 83, 209, 129, 5, 7, 73, 78, - 73, 84, 73, 65, 76, 22, 218, 207, 25, 79, 191, 236, 1, 73, 84, 218, 200, - 10, 84, 242, 238, 11, 89, 182, 230, 2, 65, 162, 52, 68, 214, 6, 85, 186, - 202, 1, 73, 42, 76, 226, 195, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 75, - 2, 80, 138, 69, 72, 2, 74, 2, 77, 2, 82, 2, 86, 2, 90, 186, 2, 69, 3, 79, - 8, 210, 229, 24, 72, 210, 42, 67, 98, 78, 139, 216, 3, 65, 18, 64, 10, - 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 239, 240, 26, 73, 16, 218, 151, - 15, 65, 178, 190, 10, 85, 186, 202, 1, 73, 198, 140, 2, 69, 3, 79, 10, - 68, 5, 83, 73, 79, 78, 32, 212, 237, 1, 2, 78, 71, 159, 168, 26, 68, 6, - 26, 83, 183, 230, 5, 84, 4, 194, 192, 27, 76, 187, 100, 73, 2, 177, 138, - 19, 3, 32, 76, 65, 4, 234, 149, 28, 83, 167, 88, 70, 212, 5, 188, 2, 6, - 67, 85, 77, 69, 78, 84, 124, 7, 69, 83, 32, 78, 79, 84, 32, 194, 3, 71, - 202, 3, 76, 36, 10, 77, 73, 78, 79, 32, 84, 73, 76, 69, 32, 226, 1, 78, - 38, 84, 246, 2, 85, 204, 17, 2, 87, 78, 136, 191, 16, 8, 32, 78, 79, 84, - 32, 76, 73, 84, 184, 141, 12, 8, 86, 69, 32, 79, 70, 32, 80, 69, 174, 4, - 79, 235, 25, 68, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 40, 4, 84, 69, 88, - 84, 251, 138, 2, 80, 5, 245, 138, 2, 6, 32, 65, 78, 68, 32, 80, 22, 164, - 1, 11, 67, 79, 78, 84, 65, 73, 78, 32, 65, 83, 32, 92, 6, 68, 73, 86, 73, - 68, 69, 112, 2, 80, 82, 48, 7, 83, 85, 67, 67, 69, 69, 68, 237, 220, 22, - 2, 70, 79, 6, 248, 1, 15, 78, 79, 82, 77, 65, 76, 32, 83, 85, 66, 71, 82, - 79, 85, 80, 207, 252, 20, 77, 5, 197, 128, 22, 23, 32, 87, 73, 84, 72, + 74, 79, 30, 84, 2, 90, 142, 149, 12, 67, 178, 163, 16, 66, 2, 68, 2, 74, + 2, 80, 2, 86, 2, 89, 154, 103, 71, 2, 75, 186, 105, 87, 162, 19, 65, 203, + 17, 72, 20, 222, 152, 26, 83, 194, 149, 2, 78, 138, 128, 2, 84, 146, 1, + 70, 2, 76, 2, 77, 2, 82, 3, 87, 12, 11, 32, 12, 242, 151, 26, 65, 174, + 201, 1, 79, 174, 205, 2, 69, 3, 73, 4, 142, 174, 30, 73, 3, 87, 4, 186, + 184, 28, 72, 231, 222, 1, 69, 5, 173, 157, 29, 4, 32, 73, 83, 76, 4, 250, + 170, 27, 67, 209, 229, 1, 4, 87, 73, 78, 68, 204, 2, 100, 8, 65, 78, 65, + 71, 65, 82, 73, 32, 189, 18, 12, 73, 67, 69, 32, 67, 79, 78, 84, 82, 79, + 76, 32, 194, 2, 222, 1, 65, 38, 67, 22, 71, 36, 4, 72, 69, 65, 68, 96, 7, + 76, 69, 84, 84, 69, 82, 32, 130, 6, 83, 148, 7, 11, 86, 79, 87, 69, 76, + 32, 83, 73, 71, 78, 32, 150, 211, 19, 68, 252, 140, 6, 4, 74, 65, 73, 78, + 243, 170, 4, 79, 4, 246, 136, 13, 67, 155, 251, 12, 66, 2, 215, 152, 6, + 65, 4, 230, 136, 13, 82, 255, 143, 2, 65, 6, 44, 5, 32, 77, 65, 82, 75, + 163, 249, 29, 83, 5, 237, 225, 19, 7, 32, 87, 73, 84, 72, 32, 72, 160, 1, + 162, 2, 65, 110, 67, 62, 68, 50, 71, 62, 72, 52, 2, 77, 65, 46, 83, 254, + 162, 7, 66, 146, 165, 5, 75, 154, 234, 3, 82, 214, 176, 3, 79, 246, 194, + 3, 89, 182, 118, 85, 250, 35, 78, 242, 198, 1, 74, 182, 58, 76, 70, 84, + 46, 86, 194, 209, 1, 73, 166, 200, 1, 80, 2, 90, 138, 69, 70, 2, 81, 187, + 2, 69, 15, 184, 162, 7, 10, 76, 84, 69, 82, 78, 65, 84, 69, 32, 68, 138, + 132, 23, 65, 2, 73, 2, 85, 2, 87, 3, 89, 10, 26, 65, 135, 163, 30, 72, 9, + 185, 2, 4, 78, 68, 82, 65, 12, 218, 194, 26, 68, 138, 224, 3, 72, 187, 2, + 65, 10, 170, 161, 13, 76, 130, 188, 16, 72, 138, 69, 71, 187, 2, 65, 4, + 132, 161, 17, 4, 69, 65, 86, 89, 171, 131, 13, 65, 5, 241, 159, 7, 6, 82, + 87, 65, 82, 73, 32, 12, 38, 72, 242, 160, 30, 83, 187, 2, 65, 8, 36, 3, + 79, 82, 84, 131, 163, 30, 65, 6, 235, 181, 12, 32, 68, 168, 1, 19, 69, + 81, 85, 69, 78, 67, 69, 32, 70, 79, 82, 32, 76, 69, 84, 84, 69, 82, 32, + 104, 4, 73, 71, 78, 32, 177, 226, 27, 10, 84, 82, 69, 83, 83, 32, 83, 73, + 71, 78, 16, 246, 219, 3, 71, 2, 75, 136, 197, 24, 3, 68, 68, 68, 2, 82, + 230, 253, 1, 89, 38, 70, 2, 81, 3, 90, 48, 178, 3, 66, 0, 10, 69, 88, 84, + 69, 78, 68, 69, 68, 32, 66, 36, 11, 67, 65, 78, 68, 82, 65, 66, 73, 78, + 68, 85, 64, 8, 87, 69, 83, 84, 69, 82, 78, 32, 32, 10, 82, 69, 86, 69, + 82, 83, 69, 68, 32, 78, 234, 207, 6, 83, 178, 137, 13, 73, 230, 159, 6, + 77, 46, 78, 198, 67, 65, 72, 18, 68, 79, 85, 66, 76, 69, 32, 67, 65, 78, + 68, 82, 65, 66, 73, 78, 68, 85, 62, 80, 128, 203, 2, 12, 72, 73, 71, 72, + 32, 83, 80, 65, 67, 73, 78, 71, 167, 80, 86, 4, 185, 144, 13, 4, 72, 65, + 76, 69, 11, 11, 32, 8, 178, 154, 23, 65, 234, 163, 3, 86, 251, 232, 1, + 84, 4, 30, 78, 21, 3, 70, 73, 86, 2, 17, 2, 73, 78, 2, 157, 179, 22, 8, + 69, 45, 76, 73, 75, 69, 32, 66, 50, 150, 1, 65, 52, 7, 67, 65, 78, 68, + 82, 65, 32, 182, 217, 19, 79, 34, 80, 138, 185, 4, 85, 170, 229, 1, 83, + 178, 70, 86, 246, 203, 1, 73, 231, 143, 2, 69, 10, 190, 154, 30, 65, 2, + 73, 2, 85, 2, 87, 3, 89, 6, 140, 218, 19, 4, 76, 79, 78, 71, 254, 191, + 10, 69, 3, 79, 10, 154, 248, 24, 70, 136, 6, 2, 83, 84, 206, 165, 3, 84, + 179, 90, 79, 232, 2, 182, 2, 65, 150, 2, 69, 74, 71, 224, 4, 6, 78, 71, + 66, 65, 84, 32, 248, 1, 5, 82, 69, 67, 84, 32, 98, 83, 206, 2, 86, 200, + 7, 2, 89, 65, 32, 4, 90, 90, 89, 32, 192, 176, 5, 2, 84, 84, 244, 238, + 15, 10, 70, 70, 69, 82, 69, 78, 67, 69, 32, 66, 129, 227, 7, 12, 77, 69, + 78, 83, 73, 79, 78, 32, 79, 82, 73, 71, 20, 42, 77, 166, 151, 9, 69, 195, + 195, 13, 71, 16, 40, 4, 79, 78, 68, 32, 207, 155, 3, 69, 14, 128, 1, 5, + 87, 73, 84, 72, 32, 210, 244, 18, 84, 168, 230, 2, 12, 83, 72, 65, 80, + 69, 32, 87, 73, 84, 72, 32, 65, 219, 241, 4, 79, 8, 254, 216, 22, 66, + 182, 2, 84, 234, 149, 4, 76, 27, 82, 14, 220, 134, 5, 5, 32, 70, 65, 67, + 69, 149, 246, 17, 4, 83, 69, 76, 32, 78, 64, 3, 73, 84, 32, 149, 2, 8, + 82, 65, 77, 32, 70, 79, 82, 32, 60, 98, 70, 44, 2, 78, 73, 2, 79, 14, 83, + 46, 84, 44, 3, 90, 69, 82, 13, 5, 69, 73, 71, 72, 84, 12, 128, 1, 2, 73, + 86, 25, 3, 79, 85, 82, 6, 87, 78, 12, 96, 4, 69, 86, 69, 78, 1, 2, 73, + 88, 12, 28, 3, 72, 82, 69, 15, 87, 6, 23, 69, 6, 11, 79, 7, 231, 197, 17, + 32, 18, 88, 5, 69, 65, 82, 84, 72, 64, 5, 71, 82, 69, 65, 84, 0, 4, 76, + 69, 83, 83, 39, 72, 7, 25, 4, 76, 89, 32, 72, 4, 138, 140, 25, 85, 239, + 146, 1, 69, 4, 137, 190, 13, 4, 69, 82, 32, 89, 4, 236, 151, 5, 7, 69, + 65, 86, 69, 78, 76, 89, 1, 4, 85, 77, 65, 78, 64, 120, 17, 78, 69, 71, + 65, 84, 73, 86, 69, 32, 67, 73, 82, 67, 76, 69, 68, 32, 41, 9, 67, 73, + 82, 67, 76, 69, 68, 32, 83, 42, 38, 83, 174, 33, 78, 187, 153, 21, 68, + 22, 49, 10, 65, 78, 83, 45, 83, 69, 82, 73, 70, 32, 22, 246, 32, 78, 167, + 245, 27, 68, 4, 136, 245, 27, 15, 67, 85, 82, 82, 69, 78, 84, 32, 83, 89, + 77, 66, 79, 76, 32, 219, 251, 1, 72, 12, 98, 65, 144, 1, 5, 67, 79, 78, + 84, 73, 172, 176, 16, 3, 84, 79, 82, 173, 159, 10, 3, 71, 85, 73, 6, 76, + 9, 80, 80, 79, 73, 78, 84, 69, 68, 32, 249, 232, 27, 4, 66, 76, 69, 68, + 4, 128, 239, 17, 7, 66, 85, 84, 32, 82, 69, 76, 255, 222, 11, 70, 2, 53, + 11, 78, 85, 79, 85, 83, 32, 85, 78, 68, 69, 82, 2, 169, 209, 17, 3, 76, + 73, 78, 156, 1, 80, 9, 69, 83, 32, 65, 75, 85, 82, 85, 32, 238, 5, 73, + 189, 202, 17, 2, 79, 82, 144, 1, 142, 2, 68, 36, 7, 76, 69, 84, 84, 69, + 82, 32, 236, 1, 5, 83, 73, 71, 78, 32, 58, 86, 192, 199, 9, 6, 77, 69, + 68, 73, 65, 76, 230, 171, 5, 71, 150, 236, 4, 69, 240, 210, 4, 12, 80, + 82, 69, 70, 73, 88, 69, 68, 32, 78, 65, 83, 189, 135, 5, 7, 73, 78, 73, + 84, 73, 65, 76, 22, 218, 161, 26, 79, 151, 238, 1, 73, 84, 138, 238, 10, + 84, 242, 154, 12, 89, 254, 229, 2, 65, 170, 53, 68, 214, 6, 85, 138, 204, + 1, 73, 42, 76, 130, 199, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 75, 2, + 80, 138, 69, 72, 2, 74, 2, 77, 2, 82, 2, 86, 2, 90, 186, 2, 69, 3, 79, 8, + 214, 182, 25, 72, 198, 42, 67, 98, 78, 131, 222, 3, 65, 18, 64, 10, 79, + 87, 69, 76, 32, 83, 73, 71, 78, 32, 227, 195, 27, 73, 16, 142, 227, 15, + 65, 254, 196, 10, 85, 138, 204, 1, 73, 230, 143, 2, 69, 3, 79, 10, 68, 5, + 83, 73, 79, 78, 32, 236, 238, 1, 2, 78, 71, 247, 253, 26, 68, 6, 26, 83, + 195, 233, 5, 84, 4, 154, 148, 28, 76, 211, 103, 73, 2, 217, 217, 19, 3, + 32, 76, 65, 4, 218, 236, 28, 83, 167, 88, 70, 214, 5, 188, 2, 6, 67, 85, + 77, 69, 78, 84, 124, 7, 69, 83, 32, 78, 79, 84, 32, 194, 3, 71, 202, 3, + 76, 36, 10, 77, 73, 78, 79, 32, 84, 73, 76, 69, 32, 226, 1, 78, 38, 84, + 246, 2, 85, 196, 18, 2, 87, 78, 232, 138, 17, 8, 32, 78, 79, 84, 32, 76, + 73, 84, 208, 151, 12, 8, 86, 69, 32, 79, 70, 32, 80, 69, 174, 4, 79, 235, + 25, 68, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 40, 4, 84, 69, 88, 84, 151, + 140, 2, 80, 5, 145, 140, 2, 6, 32, 65, 78, 68, 32, 80, 22, 164, 1, 11, + 67, 79, 78, 84, 65, 73, 78, 32, 65, 83, 32, 92, 6, 68, 73, 86, 73, 68, + 69, 112, 2, 80, 82, 48, 7, 83, 85, 67, 67, 69, 69, 68, 157, 174, 23, 2, + 70, 79, 6, 248, 1, 15, 78, 79, 82, 77, 65, 76, 32, 83, 85, 66, 71, 82, + 79, 85, 80, 231, 203, 21, 77, 5, 253, 209, 22, 23, 32, 87, 73, 84, 72, 32, 82, 69, 86, 69, 82, 83, 69, 68, 32, 78, 69, 71, 65, 84, 73, 79, 78, - 6, 44, 5, 69, 67, 69, 68, 69, 195, 167, 28, 79, 5, 205, 159, 9, 2, 32, - 79, 125, 36, 3, 82, 65, 32, 191, 230, 28, 32, 120, 120, 7, 76, 69, 84, + 6, 44, 5, 69, 67, 69, 68, 69, 179, 254, 28, 79, 5, 157, 196, 9, 2, 32, + 79, 125, 36, 3, 82, 65, 32, 175, 189, 29, 32, 120, 120, 7, 76, 69, 84, 84, 69, 82, 32, 208, 1, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, - 178, 173, 23, 65, 187, 2, 83, 88, 222, 196, 25, 65, 38, 68, 82, 82, 34, - 84, 230, 5, 85, 186, 202, 1, 73, 138, 196, 1, 78, 46, 83, 82, 66, 2, 67, + 194, 254, 23, 65, 187, 2, 83, 88, 222, 150, 26, 65, 38, 68, 82, 82, 34, + 84, 230, 5, 85, 138, 204, 1, 73, 170, 199, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 138, 69, 72, 2, 76, 2, 77, 2, 86, 2, 89, 186, - 2, 69, 3, 79, 22, 182, 146, 19, 86, 174, 183, 6, 65, 38, 85, 186, 202, 1, - 73, 198, 140, 2, 69, 3, 79, 4, 194, 148, 21, 80, 199, 193, 2, 76, 200, 1, + 2, 69, 3, 79, 22, 222, 225, 19, 86, 134, 186, 6, 65, 38, 85, 138, 204, 1, + 73, 230, 143, 2, 69, 3, 79, 4, 234, 227, 21, 80, 163, 195, 2, 76, 200, 1, 72, 8, 72, 79, 82, 73, 90, 79, 78, 84, 1, 6, 86, 69, 82, 84, 73, 67, 100, - 17, 2, 65, 76, 100, 32, 2, 45, 48, 207, 135, 24, 32, 98, 58, 48, 2, 49, - 2, 50, 2, 51, 2, 52, 2, 53, 3, 54, 14, 201, 173, 20, 2, 45, 48, 4, 210, - 128, 27, 75, 219, 150, 1, 71, 26, 34, 32, 57, 4, 84, 69, 68, 32, 8, 214, - 146, 25, 80, 34, 77, 194, 71, 79, 195, 198, 2, 65, 18, 214, 1, 67, 34, - 83, 180, 147, 16, 3, 76, 73, 78, 148, 134, 1, 4, 79, 66, 69, 76, 244, 9, - 9, 84, 82, 65, 78, 83, 80, 79, 83, 73, 202, 230, 6, 70, 161, 41, 14, 82, - 73, 71, 72, 84, 45, 80, 79, 73, 78, 84, 73, 78, 71, 4, 198, 199, 27, 73, - 239, 16, 82, 4, 170, 132, 27, 79, 183, 116, 81, 162, 1, 40, 3, 66, 76, - 69, 137, 17, 2, 71, 72, 160, 1, 42, 32, 190, 10, 45, 241, 5, 2, 68, 32, - 106, 226, 2, 67, 174, 1, 68, 38, 72, 32, 4, 73, 78, 84, 69, 38, 76, 144, + 17, 2, 65, 76, 100, 32, 2, 45, 48, 215, 216, 24, 32, 98, 58, 48, 2, 49, + 2, 50, 2, 51, 2, 52, 2, 53, 3, 54, 14, 253, 252, 20, 2, 45, 48, 4, 162, + 212, 27, 75, 251, 153, 1, 71, 26, 34, 32, 57, 4, 84, 69, 68, 32, 8, 250, + 227, 25, 80, 34, 77, 150, 72, 79, 187, 203, 2, 65, 18, 214, 1, 67, 34, + 83, 248, 223, 16, 3, 76, 73, 78, 192, 134, 1, 4, 79, 66, 69, 76, 244, 9, + 9, 84, 82, 65, 78, 83, 80, 79, 83, 73, 218, 234, 6, 70, 165, 41, 14, 82, + 73, 71, 72, 84, 45, 80, 79, 73, 78, 84, 73, 78, 71, 4, 166, 155, 28, 73, + 251, 16, 82, 4, 250, 215, 27, 79, 151, 119, 81, 164, 1, 40, 3, 66, 76, + 69, 129, 18, 2, 71, 72, 162, 1, 42, 32, 182, 11, 45, 241, 5, 2, 68, 32, + 108, 222, 2, 67, 170, 2, 68, 38, 72, 32, 4, 73, 78, 84, 69, 38, 76, 144, 1, 7, 78, 69, 83, 84, 69, 68, 32, 74, 80, 66, 83, 130, 2, 85, 36, 9, 86, - 69, 82, 84, 73, 67, 65, 76, 32, 136, 164, 6, 6, 79, 66, 76, 73, 81, 85, - 196, 187, 2, 9, 82, 73, 71, 72, 84, 32, 65, 82, 67, 134, 189, 3, 65, 218, - 216, 9, 69, 246, 198, 4, 81, 153, 106, 6, 87, 65, 86, 89, 32, 79, 24, - 100, 7, 73, 82, 67, 76, 69, 68, 32, 140, 207, 7, 4, 85, 82, 76, 89, 253, - 197, 1, 4, 79, 76, 79, 78, 20, 26, 78, 255, 202, 20, 68, 2, 169, 215, 2, - 5, 85, 77, 66, 69, 82, 4, 202, 242, 18, 79, 167, 210, 6, 65, 4, 174, 197, - 20, 73, 239, 63, 89, 4, 198, 147, 26, 82, 179, 246, 1, 71, 12, 54, 79, - 217, 158, 17, 7, 69, 70, 84, 32, 65, 82, 67, 10, 26, 87, 243, 207, 25, - 71, 6, 26, 45, 135, 249, 27, 32, 4, 150, 196, 20, 82, 211, 1, 57, 6, 184, - 140, 17, 9, 76, 69, 83, 83, 45, 84, 72, 65, 78, 255, 241, 9, 71, 8, 26, - 82, 231, 138, 27, 76, 6, 214, 153, 1, 69, 195, 242, 15, 73, 18, 80, 6, - 81, 85, 65, 82, 69, 32, 30, 84, 50, 85, 173, 221, 13, 4, 79, 76, 73, 68, - 4, 146, 223, 25, 73, 55, 85, 4, 212, 197, 12, 3, 65, 67, 75, 215, 197, 4, - 82, 8, 58, 83, 246, 151, 1, 67, 250, 147, 21, 80, 175, 247, 4, 66, 2, - 169, 168, 28, 4, 80, 69, 78, 83, 4, 226, 237, 18, 80, 255, 210, 9, 78, - 10, 36, 3, 66, 65, 82, 159, 245, 27, 76, 9, 11, 32, 6, 52, 7, 68, 79, 85, - 66, 76, 69, 32, 195, 230, 26, 76, 4, 190, 230, 26, 76, 51, 82, 48, 112, - 5, 76, 73, 78, 69, 32, 220, 1, 7, 83, 84, 82, 85, 67, 75, 32, 133, 227, - 8, 7, 69, 78, 68, 69, 68, 32, 77, 12, 48, 8, 83, 76, 65, 78, 84, 69, 68, - 32, 75, 69, 8, 70, 69, 56, 7, 71, 82, 69, 65, 84, 69, 82, 1, 4, 76, 69, - 83, 83, 4, 161, 186, 20, 9, 81, 85, 65, 76, 32, 84, 79, 32, 79, 2, 245, - 171, 14, 5, 45, 84, 72, 65, 78, 34, 160, 1, 8, 67, 65, 80, 73, 84, 65, - 76, 32, 92, 7, 73, 84, 65, 76, 73, 67, 32, 124, 6, 83, 77, 65, 76, 76, - 32, 141, 215, 13, 8, 78, 45, 65, 82, 89, 32, 83, 85, 18, 206, 169, 12, - 71, 242, 213, 14, 80, 198, 140, 2, 67, 2, 72, 2, 78, 2, 81, 2, 82, 3, 90, - 10, 76, 6, 83, 77, 65, 76, 76, 32, 181, 237, 21, 7, 67, 65, 80, 73, 84, - 65, 76, 8, 214, 138, 29, 68, 2, 69, 2, 73, 3, 74, 4, 246, 167, 12, 71, - 223, 206, 16, 80, 6, 166, 167, 10, 70, 26, 77, 159, 205, 17, 83, 2, 139, - 144, 28, 78, 166, 1, 50, 32, 158, 1, 45, 189, 1, 4, 87, 65, 82, 68, 10, - 60, 4, 84, 65, 67, 75, 142, 224, 25, 70, 30, 82, 195, 79, 65, 5, 29, 5, - 32, 87, 73, 84, 72, 2, 11, 32, 2, 11, 67, 2, 249, 251, 20, 4, 73, 82, 67, - 76, 28, 60, 9, 80, 79, 73, 78, 84, 73, 78, 71, 32, 255, 224, 25, 70, 24, - 62, 83, 162, 227, 25, 65, 86, 69, 62, 70, 46, 82, 207, 1, 84, 4, 230, - 182, 17, 84, 161, 175, 8, 6, 77, 65, 76, 76, 32, 82, 128, 1, 56, 8, 32, - 70, 65, 67, 73, 78, 71, 32, 89, 2, 83, 32, 8, 54, 72, 1, 9, 78, 79, 84, - 67, 72, 69, 68, 32, 72, 4, 161, 223, 27, 3, 79, 79, 75, 120, 178, 1, 65, - 200, 2, 6, 66, 76, 65, 67, 75, 32, 38, 84, 144, 238, 8, 2, 87, 72, 138, - 156, 8, 90, 178, 137, 9, 68, 50, 70, 82, 72, 150, 4, 67, 46, 81, 42, 82, - 22, 83, 247, 7, 80, 34, 40, 4, 82, 82, 79, 87, 227, 142, 26, 78, 33, 11, - 32, 30, 144, 1, 5, 87, 73, 84, 72, 32, 184, 234, 13, 14, 76, 69, 70, 84, - 87, 65, 82, 68, 83, 32, 79, 70, 32, 85, 190, 164, 12, 65, 178, 10, 70, - 179, 5, 84, 22, 140, 186, 5, 6, 67, 79, 82, 78, 69, 82, 146, 215, 20, 68, - 58, 76, 42, 77, 38, 78, 58, 83, 66, 69, 250, 12, 84, 135, 58, 72, 6, 170, - 137, 21, 65, 231, 137, 5, 67, 36, 36, 2, 82, 73, 161, 2, 2, 87, 79, 32, - 44, 5, 65, 78, 71, 76, 69, 191, 161, 26, 80, 30, 56, 8, 45, 72, 69, 65, - 68, 69, 68, 32, 251, 166, 26, 32, 28, 68, 5, 65, 82, 82, 79, 87, 190, - 136, 17, 90, 254, 150, 9, 68, 39, 80, 23, 11, 32, 20, 232, 154, 26, 15, - 76, 69, 70, 84, 87, 65, 82, 68, 83, 32, 79, 70, 32, 85, 80, 98, 84, 23, - 87, 4, 182, 160, 26, 32, 105, 15, 45, 72, 69, 65, 68, 69, 68, 32, 65, 82, - 82, 79, 87, 32, 87, 22, 138, 1, 65, 106, 79, 152, 1, 12, 85, 77, 32, 87, - 73, 84, 72, 32, 68, 82, 85, 77, 248, 244, 16, 6, 73, 86, 69, 32, 83, 76, - 139, 237, 10, 69, 8, 250, 204, 2, 67, 180, 146, 6, 10, 70, 84, 73, 78, - 71, 32, 80, 79, 73, 78, 233, 245, 15, 3, 71, 79, 78, 8, 56, 6, 77, 69, - 68, 65, 82, 89, 34, 80, 139, 196, 27, 79, 2, 209, 241, 20, 3, 32, 67, 65, - 4, 164, 184, 18, 6, 32, 79, 70, 32, 66, 76, 211, 141, 10, 76, 2, 213, - 223, 12, 3, 83, 84, 73, 162, 2, 76, 7, 80, 76, 79, 89, 65, 78, 32, 240, - 139, 20, 2, 77, 80, 219, 234, 8, 67, 158, 2, 212, 2, 6, 65, 70, 70, 73, - 88, 32, 160, 7, 7, 76, 69, 84, 84, 69, 82, 32, 180, 190, 1, 16, 84, 72, - 73, 67, 75, 32, 76, 69, 84, 84, 69, 82, 32, 83, 69, 76, 232, 180, 3, 4, - 68, 79, 85, 66, 248, 234, 16, 19, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, - 78, 32, 67, 72, 73, 78, 79, 79, 75, 145, 206, 5, 11, 83, 73, 71, 78, 32, - 79, 32, 87, 73, 84, 72, 64, 140, 1, 9, 65, 84, 84, 65, 67, 72, 69, 68, - 32, 184, 1, 5, 72, 73, 71, 72, 32, 106, 76, 40, 4, 82, 73, 71, 72, 173, - 2, 4, 77, 73, 68, 32, 14, 112, 2, 84, 65, 232, 4, 13, 76, 69, 70, 84, 45, - 84, 79, 45, 82, 73, 71, 72, 84, 26, 83, 158, 246, 20, 69, 3, 73, 6, 44, - 5, 78, 71, 69, 78, 84, 131, 233, 27, 73, 5, 247, 250, 20, 32, 20, 174, 2, - 76, 50, 84, 38, 86, 250, 174, 8, 71, 186, 2, 65, 238, 209, 18, 87, 134, - 26, 67, 227, 131, 1, 68, 24, 36, 2, 69, 70, 29, 3, 79, 87, 32, 2, 213, 2, - 3, 84, 32, 72, 22, 94, 65, 38, 76, 50, 84, 38, 86, 250, 174, 8, 71, 166, - 212, 18, 87, 134, 26, 67, 227, 131, 1, 68, 4, 186, 236, 21, 67, 195, 233, - 5, 82, 4, 216, 128, 8, 3, 79, 78, 71, 131, 214, 19, 73, 2, 185, 166, 8, - 4, 73, 71, 72, 84, 4, 37, 7, 69, 82, 84, 73, 67, 65, 76, 5, 131, 1, 32, - 4, 42, 72, 41, 6, 86, 69, 82, 84, 73, 67, 2, 37, 7, 79, 82, 73, 90, 79, - 78, 84, 2, 17, 2, 65, 76, 2, 11, 32, 2, 11, 83, 2, 133, 228, 27, 2, 69, - 67, 214, 1, 222, 1, 65, 22, 68, 34, 69, 30, 70, 22, 71, 22, 74, 170, 1, - 75, 66, 76, 50, 77, 62, 78, 134, 1, 79, 50, 80, 86, 82, 74, 83, 210, 2, - 84, 66, 85, 42, 86, 38, 87, 70, 88, 154, 231, 27, 72, 142, 60, 73, 206, - 41, 89, 215, 22, 66, 5, 151, 201, 28, 79, 7, 142, 176, 28, 32, 223, 61, - 72, 7, 202, 237, 28, 69, 3, 85, 5, 207, 157, 28, 32, 5, 171, 243, 24, 32, - 19, 11, 32, 16, 76, 8, 87, 73, 84, 72, 32, 68, 79, 84, 238, 5, 77, 2, 78, - 167, 192, 27, 83, 5, 53, 11, 83, 32, 73, 78, 83, 73, 68, 69, 32, 65, 78, - 2, 239, 238, 27, 68, 9, 26, 32, 199, 235, 28, 75, 4, 222, 241, 24, 82, - 231, 249, 3, 77, 9, 148, 211, 22, 3, 79, 78, 71, 139, 152, 6, 72, 11, 11, - 32, 8, 162, 4, 78, 190, 192, 27, 87, 135, 166, 1, 83, 19, 38, 32, 49, 5, - 65, 83, 65, 76, 32, 8, 202, 3, 77, 190, 192, 27, 87, 135, 166, 1, 83, 8, - 218, 233, 28, 65, 2, 73, 2, 79, 3, 85, 11, 158, 232, 28, 79, 146, 1, 65, - 2, 85, 3, 87, 9, 52, 7, 69, 82, 78, 73, 78, 32, 65, 235, 152, 28, 32, 4, - 198, 232, 28, 77, 3, 78, 11, 148, 208, 22, 6, 79, 77, 65, 78, 73, 65, - 186, 218, 5, 32, 223, 61, 72, 49, 58, 32, 164, 1, 5, 76, 79, 65, 78, 32, - 239, 177, 6, 72, 26, 102, 74, 22, 75, 2, 80, 2, 84, 20, 7, 87, 73, 84, - 72, 32, 68, 79, 154, 230, 28, 77, 2, 78, 3, 83, 5, 227, 168, 28, 32, 5, - 207, 173, 28, 32, 4, 167, 223, 12, 84, 18, 74, 69, 214, 198, 5, 79, 134, - 207, 22, 65, 210, 78, 68, 146, 1, 74, 3, 85, 6, 182, 229, 28, 69, 2, 72, - 3, 78, 9, 26, 32, 251, 228, 28, 72, 4, 146, 235, 24, 82, 231, 249, 3, 83, - 9, 242, 148, 28, 32, 226, 79, 72, 3, 73, 5, 137, 149, 7, 4, 79, 67, 65, - 76, 17, 66, 79, 234, 170, 28, 32, 134, 37, 69, 218, 19, 65, 2, 72, 3, 73, - 5, 195, 227, 28, 87, 140, 29, 234, 2, 65, 188, 3, 10, 68, 73, 84, 79, 82, - 73, 65, 76, 32, 67, 22, 71, 188, 75, 4, 73, 71, 72, 84, 146, 2, 76, 194, - 9, 77, 214, 5, 78, 246, 3, 79, 36, 2, 81, 85, 182, 8, 82, 222, 1, 83, - 118, 84, 242, 31, 85, 226, 1, 88, 128, 5, 2, 89, 69, 208, 86, 4, 45, 77, - 65, 73, 132, 145, 19, 3, 74, 69, 67, 244, 152, 2, 8, 86, 69, 82, 71, 82, - 69, 69, 78, 167, 199, 5, 80, 22, 38, 82, 218, 248, 26, 83, 135, 65, 71, - 19, 30, 32, 137, 1, 2, 84, 72, 6, 88, 3, 79, 70, 32, 181, 232, 4, 13, 87, - 73, 84, 72, 32, 72, 69, 65, 82, 73, 78, 71, 32, 4, 132, 196, 11, 2, 77, - 65, 195, 227, 6, 82, 11, 17, 2, 32, 71, 8, 44, 5, 76, 79, 66, 69, 32, - 239, 165, 25, 82, 6, 70, 65, 173, 242, 21, 11, 69, 85, 82, 79, 80, 69, - 45, 65, 70, 82, 73, 4, 244, 142, 10, 4, 77, 69, 82, 73, 193, 154, 2, 11, - 83, 73, 65, 45, 65, 85, 83, 84, 82, 65, 76, 2, 187, 178, 2, 79, 176, 17, - 112, 18, 89, 80, 84, 73, 65, 78, 32, 72, 73, 69, 82, 79, 71, 76, 89, 80, - 72, 32, 202, 212, 2, 69, 179, 135, 26, 71, 172, 17, 146, 3, 65, 178, 4, - 66, 52, 2, 67, 48, 224, 1, 2, 68, 48, 170, 4, 69, 178, 3, 70, 164, 4, 2, - 71, 48, 210, 3, 72, 214, 1, 73, 238, 2, 76, 122, 77, 222, 8, 78, 210, 5, - 79, 140, 5, 2, 80, 48, 120, 2, 82, 48, 232, 1, 2, 83, 48, 190, 3, 84, - 220, 2, 2, 85, 48, 250, 2, 86, 134, 5, 87, 236, 2, 3, 88, 48, 48, 88, 3, - 89, 48, 48, 84, 2, 90, 48, 188, 217, 3, 3, 75, 48, 48, 129, 151, 15, 3, - 81, 48, 48, 228, 1, 30, 48, 133, 3, 2, 65, 48, 160, 1, 86, 48, 98, 49, - 102, 52, 166, 55, 51, 150, 248, 20, 55, 198, 232, 1, 50, 2, 53, 3, 54, - 24, 170, 68, 54, 198, 129, 24, 53, 242, 145, 4, 49, 2, 50, 2, 51, 2, 52, - 2, 55, 2, 56, 3, 57, 24, 142, 197, 24, 52, 2, 55, 242, 145, 4, 48, 2, 49, - 2, 50, 2, 51, 2, 53, 2, 54, 2, 56, 3, 57, 28, 170, 196, 24, 48, 2, 50, 2, - 51, 2, 53, 242, 145, 4, 49, 2, 52, 2, 54, 2, 55, 2, 56, 3, 57, 68, 46, - 48, 246, 54, 51, 246, 223, 22, 49, 3, 50, 22, 210, 65, 55, 182, 147, 28, - 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 56, 3, 57, 26, 148, 9, 4, 69, - 71, 73, 78, 185, 25, 2, 48, 48, 56, 34, 48, 90, 49, 155, 245, 8, 50, 24, - 230, 39, 50, 242, 171, 28, 49, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, - 3, 57, 22, 142, 193, 24, 48, 242, 145, 4, 49, 2, 50, 2, 51, 2, 52, 2, 53, - 2, 54, 2, 55, 2, 56, 3, 57, 184, 1, 70, 48, 94, 51, 102, 52, 102, 53, - 106, 54, 194, 29, 50, 231, 242, 22, 49, 20, 222, 191, 24, 56, 242, 145, - 4, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, 57, 24, 130, 191, 24, - 49, 2, 52, 242, 145, 4, 48, 2, 50, 2, 51, 2, 53, 2, 54, 2, 55, 2, 56, 3, - 57, 24, 158, 190, 24, 54, 2, 56, 242, 145, 4, 48, 2, 49, 2, 50, 2, 51, 2, - 52, 2, 53, 2, 55, 3, 57, 42, 214, 60, 48, 230, 128, 24, 50, 2, 52, 242, - 145, 4, 49, 2, 51, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 32, 194, 60, 55, - 130, 146, 28, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 3, 54, 94, 30, 48, - 189, 2, 2, 78, 68, 88, 38, 48, 94, 50, 102, 51, 215, 7, 49, 22, 186, 187, - 24, 56, 2, 57, 242, 145, 4, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 3, 55, - 24, 222, 186, 24, 48, 2, 56, 242, 145, 4, 49, 2, 50, 2, 51, 2, 52, 2, 53, - 2, 54, 2, 55, 3, 57, 18, 250, 185, 24, 52, 242, 145, 4, 48, 2, 49, 2, 50, - 2, 51, 2, 54, 2, 55, 3, 56, 6, 11, 32, 6, 136, 183, 5, 6, 87, 65, 76, 76, - 69, 68, 210, 19, 69, 247, 225, 20, 83, 132, 1, 42, 48, 133, 9, 5, 85, 76, - 76, 32, 66, 130, 1, 54, 48, 94, 49, 102, 51, 102, 52, 102, 53, 215, 1, - 50, 20, 230, 183, 24, 49, 242, 145, 4, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, - 55, 2, 56, 3, 57, 22, 138, 183, 24, 51, 242, 145, 4, 48, 2, 49, 2, 50, 2, - 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 26, 166, 182, 24, 49, 2, 55, 2, - 56, 242, 145, 4, 48, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 3, 57, 26, 194, - 181, 24, 53, 2, 54, 2, 55, 242, 145, 4, 48, 2, 49, 2, 50, 2, 51, 2, 52, - 2, 56, 3, 57, 14, 222, 26, 49, 242, 171, 28, 48, 2, 50, 3, 51, 128, 1, - 62, 48, 98, 49, 102, 51, 102, 52, 210, 27, 50, 255, 201, 8, 53, 24, 166, - 50, 55, 198, 129, 24, 54, 242, 145, 4, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, - 56, 3, 57, 22, 138, 179, 24, 49, 242, 145, 4, 48, 2, 50, 2, 51, 2, 52, 2, - 53, 2, 54, 2, 55, 2, 56, 3, 57, 24, 166, 178, 24, 54, 2, 55, 242, 145, 4, - 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 56, 3, 57, 24, 194, 177, 24, - 51, 2, 53, 242, 145, 4, 48, 2, 49, 2, 50, 2, 52, 2, 54, 2, 55, 2, 56, 3, - 57, 24, 80, 2, 48, 48, 84, 4, 65, 76, 70, 32, 161, 40, 7, 79, 82, 73, 90, - 79, 78, 84, 18, 138, 176, 24, 54, 242, 145, 4, 49, 2, 50, 2, 51, 2, 52, - 2, 53, 2, 55, 3, 56, 4, 22, 66, 255, 42, 76, 2, 191, 241, 16, 76, 52, 58, - 48, 181, 1, 9, 78, 83, 69, 82, 84, 32, 65, 84, 32, 38, 18, 48, 95, 49, - 22, 186, 174, 24, 53, 2, 57, 242, 145, 4, 49, 2, 50, 2, 51, 2, 52, 2, 54, - 2, 55, 3, 56, 16, 222, 173, 24, 48, 2, 49, 242, 145, 4, 50, 2, 51, 2, 52, - 3, 53, 14, 68, 6, 66, 79, 84, 84, 79, 77, 0, 3, 84, 79, 80, 199, 219, 19, - 77, 7, 11, 32, 4, 162, 174, 27, 69, 249, 8, 2, 83, 84, 22, 32, 2, 48, 48, - 167, 223, 15, 79, 20, 250, 171, 24, 50, 2, 54, 242, 145, 4, 49, 2, 51, 2, - 52, 2, 53, 2, 55, 3, 56, 164, 1, 118, 48, 128, 4, 15, 79, 68, 73, 70, 73, - 69, 82, 32, 68, 65, 77, 65, 71, 69, 68, 129, 246, 24, 5, 73, 82, 82, 79, - 82, 132, 1, 42, 48, 98, 49, 106, 50, 102, 51, 107, 52, 24, 182, 40, 49, - 198, 129, 24, 51, 242, 145, 4, 50, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, - 57, 44, 138, 41, 50, 146, 128, 24, 48, 2, 53, 2, 54, 2, 55, 242, 145, 4, - 49, 2, 51, 2, 52, 2, 56, 3, 57, 26, 178, 168, 24, 50, 2, 52, 2, 56, 242, - 145, 4, 48, 2, 49, 2, 51, 2, 53, 2, 54, 2, 55, 3, 57, 26, 138, 38, 51, - 198, 129, 24, 49, 242, 145, 4, 48, 2, 50, 2, 52, 2, 53, 2, 54, 2, 55, 2, - 56, 3, 57, 12, 230, 166, 24, 48, 242, 145, 4, 49, 2, 50, 2, 51, 3, 52, - 31, 25, 4, 32, 65, 84, 32, 28, 96, 6, 66, 79, 84, 84, 79, 77, 120, 5, 83, - 84, 65, 82, 84, 68, 3, 84, 79, 80, 207, 165, 27, 69, 11, 11, 32, 8, 56, - 5, 83, 84, 65, 82, 84, 186, 1, 65, 139, 165, 27, 69, 5, 129, 2, 8, 32, - 65, 78, 68, 32, 84, 79, 80, 7, 29, 5, 32, 65, 78, 68, 32, 4, 222, 198, - 24, 66, 147, 246, 2, 84, 11, 11, 32, 8, 54, 65, 20, 5, 83, 84, 65, 82, - 84, 247, 164, 27, 69, 2, 73, 2, 78, 68, 5, 53, 11, 32, 65, 78, 68, 32, - 66, 79, 84, 84, 79, 77, 2, 235, 216, 19, 32, 194, 1, 50, 48, 128, 2, 2, - 76, 48, 229, 1, 2, 85, 48, 98, 58, 49, 98, 51, 194, 14, 50, 150, 6, 52, - 247, 221, 22, 48, 24, 146, 32, 56, 182, 147, 28, 48, 2, 49, 2, 50, 2, 51, - 2, 52, 2, 53, 2, 54, 2, 55, 3, 57, 28, 246, 160, 24, 51, 2, 52, 2, 53, 2, - 55, 242, 145, 4, 48, 2, 49, 2, 50, 2, 54, 2, 56, 3, 57, 44, 34, 48, 94, - 49, 163, 138, 21, 50, 20, 238, 159, 24, 53, 242, 145, 4, 49, 2, 50, 2, - 51, 2, 52, 2, 54, 2, 55, 2, 56, 3, 57, 22, 146, 159, 24, 55, 242, 145, 4, - 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 56, 3, 57, 52, 34, 49, - 102, 50, 251, 238, 22, 48, 26, 138, 158, 24, 48, 2, 49, 2, 56, 242, 145, - 4, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, 57, 8, 166, 157, 24, 50, - 242, 145, 4, 48, 3, 49, 152, 1, 50, 48, 149, 254, 18, 6, 86, 69, 82, 76, - 65, 89, 150, 1, 66, 48, 154, 1, 49, 138, 1, 50, 102, 51, 106, 53, 227, - 235, 22, 52, 34, 90, 54, 162, 155, 24, 49, 2, 53, 242, 145, 4, 50, 2, 51, - 2, 52, 2, 55, 2, 56, 3, 57, 15, 142, 173, 28, 65, 2, 66, 2, 67, 2, 68, 2, - 69, 3, 70, 28, 98, 48, 130, 154, 24, 57, 242, 145, 4, 49, 2, 50, 2, 51, - 2, 52, 2, 53, 2, 54, 2, 55, 3, 56, 9, 238, 171, 28, 65, 2, 66, 3, 67, 28, - 218, 153, 24, 48, 2, 52, 2, 53, 2, 57, 242, 145, 4, 49, 2, 50, 2, 51, 2, - 54, 2, 55, 3, 56, 32, 134, 23, 54, 242, 129, 24, 48, 2, 51, 242, 145, 4, - 49, 2, 50, 2, 52, 2, 53, 2, 55, 2, 56, 3, 57, 8, 202, 22, 48, 183, 147, - 28, 49, 26, 26, 48, 251, 194, 8, 49, 22, 210, 151, 24, 49, 2, 51, 242, - 145, 4, 50, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 68, 34, 48, 98, 49, - 199, 233, 22, 50, 24, 142, 21, 51, 198, 129, 24, 50, 242, 145, 4, 49, 2, - 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 24, 242, 149, 24, 48, 2, 54, 242, - 145, 4, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 55, 2, 56, 3, 57, 108, 50, 48, - 94, 49, 106, 50, 98, 51, 175, 179, 19, 52, 22, 218, 148, 24, 50, 2, 54, - 242, 145, 4, 49, 2, 51, 2, 52, 2, 53, 2, 55, 2, 56, 3, 57, 26, 186, 18, - 52, 198, 129, 24, 55, 242, 145, 4, 48, 2, 49, 2, 50, 2, 51, 2, 53, 2, 54, - 2, 56, 3, 57, 24, 210, 17, 54, 182, 147, 28, 48, 2, 49, 2, 50, 2, 51, 2, - 52, 2, 53, 2, 55, 2, 56, 3, 57, 22, 182, 146, 24, 53, 242, 145, 4, 48, 2, - 49, 2, 50, 2, 51, 2, 52, 2, 54, 2, 55, 2, 56, 3, 57, 90, 34, 48, 249, 12, - 3, 65, 76, 76, 88, 42, 48, 94, 49, 102, 51, 151, 227, 22, 50, 26, 130, - 145, 24, 51, 2, 55, 2, 56, 2, 57, 242, 145, 4, 49, 2, 50, 2, 52, 2, 53, - 3, 54, 24, 166, 144, 24, 49, 2, 54, 242, 145, 4, 48, 2, 50, 2, 51, 2, 52, - 2, 53, 2, 55, 2, 56, 3, 57, 18, 194, 143, 24, 50, 2, 51, 242, 145, 4, 48, - 2, 49, 2, 52, 2, 53, 3, 54, 94, 50, 48, 90, 50, 102, 51, 102, 52, 247, - 223, 22, 49, 22, 254, 12, 54, 182, 147, 28, 49, 2, 50, 2, 51, 2, 52, 2, - 53, 2, 55, 2, 56, 3, 57, 24, 234, 141, 24, 51, 2, 57, 242, 145, 4, 48, 2, - 49, 2, 50, 2, 52, 2, 53, 2, 54, 2, 55, 3, 56, 22, 134, 141, 24, 50, 242, - 145, 4, 48, 2, 49, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 6, - 146, 158, 28, 48, 2, 49, 3, 50, 158, 1, 42, 48, 185, 4, 5, 69, 82, 84, - 73, 67, 156, 1, 62, 48, 98, 49, 98, 50, 210, 1, 51, 253, 135, 24, 2, 52, - 48, 42, 198, 9, 55, 98, 49, 230, 128, 24, 50, 242, 145, 4, 51, 2, 52, 2, - 53, 2, 54, 2, 56, 3, 57, 32, 186, 8, 49, 46, 50, 182, 147, 28, 48, 2, 51, - 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 50, 98, 48, 234, 136, 24, 51, - 2, 56, 2, 57, 242, 145, 4, 49, 2, 50, 2, 52, 2, 53, 2, 54, 3, 55, 27, - 214, 154, 28, 65, 2, 66, 2, 67, 2, 68, 2, 69, 2, 70, 2, 71, 2, 72, 2, 73, - 2, 74, 2, 75, 3, 76, 28, 250, 135, 24, 48, 2, 49, 2, 51, 2, 55, 242, 145, - 4, 50, 2, 52, 2, 53, 2, 54, 2, 56, 3, 57, 2, 137, 234, 23, 2, 65, 76, 66, - 34, 48, 161, 2, 3, 73, 68, 69, 64, 26, 48, 94, 49, 103, 50, 22, 186, 134, - 24, 51, 2, 57, 242, 145, 4, 49, 2, 50, 2, 52, 2, 53, 2, 54, 2, 55, 3, 56, - 28, 222, 133, 24, 48, 2, 52, 2, 55, 2, 56, 242, 145, 4, 49, 2, 50, 2, 51, - 2, 53, 2, 54, 3, 57, 14, 250, 132, 24, 52, 242, 145, 4, 48, 2, 49, 2, 50, - 2, 51, 3, 53, 2, 17, 2, 32, 76, 2, 203, 183, 15, 79, 24, 202, 2, 52, 198, - 129, 24, 54, 2, 56, 242, 145, 4, 49, 2, 50, 2, 51, 2, 53, 3, 55, 18, 182, - 131, 24, 49, 242, 145, 4, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, 56, - 82, 22, 48, 167, 1, 49, 34, 90, 50, 46, 51, 198, 129, 24, 52, 2, 53, 242, - 145, 4, 49, 2, 54, 2, 55, 2, 56, 3, 57, 11, 222, 147, 28, 65, 2, 66, 2, - 67, 3, 68, 7, 178, 147, 28, 65, 3, 66, 48, 66, 53, 86, 54, 130, 146, 28, - 48, 2, 49, 2, 50, 2, 51, 3, 52, 21, 210, 146, 28, 65, 2, 66, 2, 67, 2, - 68, 2, 69, 2, 70, 2, 71, 2, 72, 3, 73, 19, 254, 145, 28, 65, 2, 66, 2, - 67, 2, 68, 2, 69, 2, 70, 2, 71, 3, 72, 18, 26, 32, 211, 233, 15, 72, 16, - 70, 80, 124, 5, 82, 65, 89, 83, 32, 226, 152, 3, 84, 131, 223, 22, 83, 8, - 222, 152, 3, 79, 209, 190, 16, 22, 69, 84, 65, 76, 76, 69, 68, 32, 79, - 85, 84, 76, 73, 78, 69, 68, 32, 66, 76, 65, 67, 75, 4, 252, 245, 18, 2, - 73, 78, 1, 3, 79, 85, 84, 160, 1, 132, 1, 13, 66, 65, 83, 65, 78, 32, 76, - 69, 84, 84, 69, 82, 32, 166, 3, 69, 176, 4, 7, 89, 77, 65, 73, 67, 32, - 76, 199, 134, 28, 70, 80, 230, 1, 71, 78, 76, 34, 78, 50, 82, 210, 254, - 25, 69, 166, 140, 1, 67, 2, 68, 2, 75, 2, 83, 2, 84, 2, 90, 206, 105, 66, - 2, 70, 2, 72, 2, 74, 2, 77, 2, 80, 2, 81, 2, 86, 2, 88, 214, 22, 65, 2, - 73, 2, 79, 2, 85, 3, 89, 8, 38, 72, 182, 245, 27, 74, 215, 22, 69, 4, - 190, 182, 25, 65, 203, 213, 2, 69, 4, 142, 245, 27, 76, 215, 22, 69, 8, - 238, 244, 27, 68, 2, 74, 214, 22, 65, 3, 69, 4, 190, 244, 27, 82, 215, - 22, 69, 32, 96, 5, 67, 84, 82, 73, 67, 160, 1, 7, 77, 69, 78, 84, 32, 79, - 70, 238, 252, 26, 80, 135, 83, 86, 10, 26, 32, 131, 151, 24, 65, 8, 98, - 80, 232, 212, 17, 2, 84, 79, 176, 246, 8, 9, 76, 73, 71, 72, 84, 32, 66, - 85, 76, 187, 33, 65, 2, 11, 76, 2, 175, 136, 28, 85, 19, 11, 32, 16, 72, - 5, 87, 73, 84, 72, 32, 153, 214, 16, 7, 79, 80, 69, 78, 73, 78, 71, 12, - 130, 1, 76, 32, 12, 84, 87, 79, 32, 72, 79, 82, 73, 90, 79, 78, 84, 146, - 225, 19, 86, 226, 182, 4, 85, 142, 61, 79, 175, 177, 2, 68, 2, 245, 222, - 25, 3, 79, 78, 71, 2, 173, 219, 14, 7, 65, 76, 32, 83, 84, 82, 79, 46, - 238, 175, 4, 69, 165, 206, 15, 15, 73, 71, 65, 84, 85, 82, 69, 32, 90, - 65, 89, 73, 78, 45, 89, 53, 48, 4, 79, 74, 73, 32, 218, 2, 80, 163, 3, - 32, 18, 164, 1, 10, 67, 79, 77, 80, 79, 78, 69, 78, 84, 32, 109, 26, 77, - 79, 68, 73, 70, 73, 69, 82, 32, 70, 73, 84, 90, 80, 65, 84, 82, 73, 67, - 75, 32, 84, 89, 80, 69, 45, 8, 244, 132, 15, 2, 82, 69, 12, 5, 67, 85, - 82, 76, 89, 0, 5, 87, 72, 73, 84, 69, 185, 207, 2, 2, 66, 65, 10, 216, - 219, 20, 2, 49, 45, 194, 167, 7, 51, 2, 52, 2, 53, 3, 54, 26, 44, 3, 84, - 89, 32, 149, 251, 3, 2, 72, 65, 24, 82, 78, 60, 3, 80, 65, 71, 20, 3, 83, - 69, 84, 209, 189, 27, 4, 68, 79, 67, 85, 8, 36, 3, 79, 84, 69, 187, 147, - 24, 69, 7, 251, 162, 13, 32, 4, 191, 247, 25, 69, 11, 33, 6, 32, 87, 73, - 84, 72, 32, 8, 242, 135, 14, 82, 24, 3, 76, 69, 70, 224, 166, 1, 2, 83, - 77, 255, 159, 9, 79, 38, 86, 32, 64, 2, 68, 32, 214, 1, 81, 20, 6, 86, - 69, 76, 79, 80, 69, 199, 227, 15, 84, 6, 42, 81, 250, 147, 26, 68, 235, - 172, 1, 83, 2, 223, 184, 27, 85, 20, 32, 3, 79, 70, 32, 131, 1, 87, 18, - 88, 3, 80, 82, 79, 254, 232, 20, 71, 56, 2, 83, 69, 166, 71, 77, 30, 84, - 203, 177, 5, 76, 4, 190, 233, 20, 84, 151, 147, 6, 79, 2, 193, 250, 19, - 7, 73, 84, 72, 32, 76, 69, 70, 5, 247, 176, 21, 85, 7, 33, 6, 32, 87, 73, - 84, 72, 32, 4, 42, 76, 153, 254, 23, 4, 68, 79, 87, 78, 2, 161, 220, 22, - 4, 73, 71, 72, 84, 6, 154, 252, 27, 76, 2, 77, 3, 84, 46, 28, 2, 65, 76, - 231, 6, 73, 40, 30, 32, 133, 2, 2, 83, 32, 12, 56, 3, 84, 79, 32, 229, - 151, 13, 5, 65, 78, 68, 32, 80, 10, 68, 3, 79, 82, 32, 249, 168, 27, 8, - 66, 89, 32, 68, 69, 70, 73, 78, 8, 64, 3, 80, 82, 69, 28, 3, 83, 85, 67, - 226, 227, 25, 71, 39, 76, 2, 189, 162, 15, 2, 67, 69, 2, 157, 151, 26, 3, - 67, 69, 69, 28, 72, 4, 83, 73, 71, 78, 160, 225, 25, 4, 87, 73, 84, 72, - 199, 199, 1, 67, 25, 11, 32, 22, 42, 65, 201, 1, 5, 87, 73, 84, 72, 32, - 12, 112, 5, 66, 79, 86, 69, 32, 65, 19, 78, 68, 32, 83, 76, 65, 78, 84, - 69, 68, 32, 80, 65, 82, 65, 76, 76, 69, 76, 8, 182, 143, 21, 80, 210, 5, - 84, 146, 189, 2, 76, 171, 131, 3, 82, 5, 239, 243, 6, 32, 10, 160, 1, 4, - 66, 85, 77, 80, 20, 7, 73, 78, 70, 73, 78, 73, 84, 20, 18, 84, 87, 79, - 32, 68, 79, 84, 83, 32, 65, 66, 79, 86, 69, 32, 65, 78, 68, 211, 162, 15, - 68, 2, 191, 248, 26, 89, 4, 155, 211, 25, 89, 2, 17, 2, 32, 84, 2, 187, - 195, 25, 87, 6, 80, 7, 86, 65, 76, 69, 78, 84, 32, 137, 147, 21, 7, 65, - 78, 71, 85, 76, 65, 82, 4, 48, 6, 87, 73, 84, 72, 32, 70, 251, 212, 27, - 84, 2, 11, 79, 2, 237, 248, 2, 2, 85, 82, 20, 152, 1, 11, 82, 79, 82, 45, - 66, 65, 82, 82, 69, 68, 32, 236, 166, 5, 7, 73, 83, 32, 70, 79, 82, 77, - 161, 202, 7, 9, 65, 83, 69, 32, 84, 79, 32, 84, 72, 12, 140, 224, 5, 4, - 87, 72, 73, 84, 13, 5, 66, 76, 65, 67, 75, 10, 58, 67, 20, 6, 84, 73, 77, - 65, 84, 69, 155, 241, 27, 65, 5, 211, 167, 26, 65, 4, 210, 219, 26, 68, - 199, 149, 1, 83, 154, 8, 60, 7, 72, 73, 79, 80, 73, 67, 32, 178, 240, 27, - 66, 3, 88, 150, 8, 204, 1, 2, 67, 79, 232, 1, 7, 78, 85, 77, 66, 69, 82, - 32, 114, 80, 54, 83, 156, 24, 11, 84, 79, 78, 65, 76, 32, 77, 65, 82, 75, - 32, 230, 135, 19, 68, 158, 246, 5, 70, 82, 81, 173, 150, 2, 4, 87, 79, - 82, 68, 10, 26, 77, 215, 158, 27, 76, 8, 52, 7, 66, 73, 78, 73, 78, 71, - 32, 211, 235, 27, 77, 6, 60, 11, 71, 69, 77, 73, 78, 65, 84, 73, 79, 78, - 32, 51, 86, 4, 44, 5, 65, 78, 68, 32, 86, 239, 171, 27, 77, 2, 145, 140, - 24, 4, 79, 87, 69, 76, 22, 66, 84, 134, 144, 22, 72, 238, 234, 3, 69, 30, - 70, 42, 78, 39, 83, 8, 130, 206, 16, 69, 158, 174, 9, 72, 27, 87, 4, 202, - 119, 65, 145, 164, 26, 5, 82, 69, 70, 65, 67, 198, 7, 50, 69, 37, 8, 89, - 76, 76, 65, 66, 76, 69, 32, 4, 146, 156, 24, 77, 223, 229, 2, 67, 194, 7, - 210, 1, 66, 90, 67, 246, 1, 68, 186, 1, 70, 90, 71, 214, 2, 72, 162, 1, - 75, 102, 77, 90, 78, 90, 80, 138, 2, 81, 174, 1, 82, 86, 83, 210, 1, 84, - 122, 74, 2, 76, 138, 1, 87, 2, 89, 66, 88, 134, 1, 90, 95, 86, 38, 194, - 12, 87, 230, 8, 66, 134, 194, 23, 65, 2, 79, 210, 209, 3, 69, 162, 64, - 73, 3, 85, 78, 94, 67, 254, 15, 72, 250, 197, 23, 65, 2, 79, 210, 209, 3, - 69, 234, 61, 87, 186, 2, 73, 3, 85, 42, 70, 72, 174, 213, 23, 65, 210, - 209, 3, 69, 162, 64, 73, 2, 79, 3, 85, 28, 166, 19, 72, 134, 194, 23, 65, - 210, 209, 3, 69, 162, 64, 73, 2, 79, 3, 85, 60, 94, 68, 214, 14, 90, 174, - 197, 23, 65, 2, 79, 210, 209, 3, 69, 234, 61, 87, 186, 2, 73, 3, 85, 30, - 210, 14, 72, 174, 197, 23, 65, 2, 79, 210, 209, 3, 69, 234, 61, 87, 186, - 2, 73, 3, 85, 24, 190, 8, 87, 234, 202, 23, 65, 210, 209, 3, 69, 234, 61, - 89, 186, 2, 73, 2, 79, 3, 85, 118, 142, 1, 85, 226, 7, 71, 232, 3, 7, 76, - 79, 84, 84, 65, 76, 32, 158, 2, 87, 218, 1, 89, 134, 194, 23, 65, 2, 79, - 210, 209, 3, 69, 163, 64, 73, 39, 29, 5, 82, 65, 71, 69, 32, 36, 74, 66, - 2, 70, 2, 77, 2, 80, 46, 71, 2, 75, 2, 81, 247, 140, 12, 72, 4, 11, 87, - 4, 226, 203, 27, 69, 215, 22, 73, 6, 11, 87, 6, 234, 161, 27, 69, 163, - 64, 73, 52, 70, 72, 182, 207, 23, 65, 2, 79, 210, 209, 3, 69, 162, 64, - 73, 3, 85, 36, 202, 4, 87, 230, 8, 89, 134, 194, 23, 65, 210, 209, 3, 69, - 162, 64, 73, 2, 79, 3, 85, 64, 250, 4, 88, 134, 6, 87, 218, 1, 89, 134, - 194, 23, 65, 2, 79, 210, 209, 3, 69, 162, 64, 73, 3, 85, 26, 142, 3, 87, - 234, 202, 23, 65, 2, 79, 210, 209, 3, 69, 234, 61, 89, 186, 2, 73, 3, 85, - 36, 166, 7, 89, 250, 197, 23, 65, 2, 79, 210, 209, 3, 69, 234, 61, 87, - 186, 2, 73, 3, 85, 56, 82, 72, 142, 1, 87, 234, 202, 23, 65, 2, 79, 210, - 209, 3, 69, 162, 64, 73, 3, 85, 32, 74, 65, 170, 203, 23, 79, 210, 209, - 3, 69, 234, 61, 87, 186, 2, 73, 3, 85, 19, 160, 9, 8, 82, 89, 78, 71, 69, - 65, 76, 32, 247, 211, 27, 65, 8, 182, 156, 27, 69, 162, 64, 65, 3, 73, - 64, 94, 72, 134, 6, 87, 218, 1, 89, 134, 194, 23, 65, 2, 79, 210, 209, 3, - 69, 162, 64, 73, 3, 85, 24, 130, 6, 87, 222, 195, 23, 65, 210, 209, 3, - 69, 162, 64, 73, 2, 79, 3, 85, 20, 146, 201, 23, 65, 2, 79, 210, 209, 3, - 69, 234, 61, 87, 2, 89, 186, 2, 73, 3, 85, 74, 102, 69, 226, 1, 72, 170, - 3, 90, 78, 83, 134, 194, 23, 65, 2, 79, 186, 143, 4, 87, 186, 2, 73, 3, - 85, 13, 56, 8, 66, 65, 84, 66, 69, 73, 84, 32, 143, 217, 27, 69, 8, 174, - 223, 22, 66, 2, 70, 2, 77, 3, 80, 80, 118, 72, 76, 2, 84, 72, 62, 90, - 162, 2, 83, 210, 194, 23, 65, 2, 79, 210, 209, 3, 69, 234, 61, 87, 186, - 2, 73, 3, 85, 18, 246, 197, 23, 65, 2, 79, 210, 209, 3, 69, 234, 61, 87, - 186, 2, 73, 3, 85, 12, 250, 150, 27, 69, 234, 61, 65, 186, 2, 73, 2, 79, - 3, 85, 16, 238, 196, 23, 65, 2, 79, 210, 209, 3, 69, 162, 64, 73, 3, 85, - 40, 82, 87, 218, 1, 89, 134, 194, 23, 65, 2, 79, 210, 209, 3, 69, 162, - 64, 73, 3, 85, 10, 218, 195, 23, 65, 210, 209, 3, 69, 163, 64, 73, 48, - 90, 72, 78, 90, 134, 194, 23, 65, 2, 79, 210, 209, 3, 69, 234, 61, 87, - 186, 2, 73, 3, 85, 16, 206, 194, 23, 65, 210, 209, 3, 69, 234, 61, 87, - 186, 2, 73, 2, 79, 3, 85, 14, 130, 194, 23, 65, 210, 209, 3, 69, 162, 64, - 73, 2, 79, 3, 85, 20, 130, 1, 68, 74, 72, 30, 75, 42, 82, 0, 7, 83, 72, - 79, 82, 84, 32, 82, 220, 147, 4, 3, 67, 72, 73, 177, 136, 23, 3, 89, 73, - 90, 6, 48, 4, 69, 82, 69, 84, 205, 200, 26, 2, 73, 70, 5, 17, 2, 45, 72, - 2, 205, 156, 27, 2, 73, 68, 4, 152, 200, 26, 2, 69, 78, 163, 2, 85, 2, - 137, 162, 4, 3, 73, 75, 82, 12, 96, 2, 82, 79, 244, 155, 11, 3, 78, 79, - 77, 181, 168, 15, 9, 76, 69, 82, 32, 67, 79, 78, 83, 84, 8, 92, 5, 80, - 69, 65, 78, 32, 248, 152, 24, 8, 45, 67, 85, 82, 82, 69, 78, 67, 215, - 175, 2, 32, 4, 202, 142, 4, 67, 19, 80, 50, 30, 67, 102, 80, 187, 1, 84, - 6, 60, 9, 76, 65, 77, 65, 84, 73, 79, 78, 32, 243, 181, 26, 69, 4, 222, - 249, 24, 81, 187, 147, 2, 77, 10, 96, 7, 76, 79, 83, 73, 79, 78, 32, 157, - 144, 27, 11, 82, 69, 83, 83, 73, 79, 78, 76, 69, 83, 83, 8, 136, 220, 11, - 4, 70, 82, 65, 77, 197, 161, 15, 8, 65, 84, 32, 72, 79, 82, 73, 90, 34, - 98, 82, 209, 189, 21, 18, 69, 78, 68, 69, 68, 32, 65, 82, 65, 66, 73, 67, - 45, 73, 78, 68, 73, 67, 14, 140, 1, 12, 69, 77, 69, 76, 89, 32, 72, 69, - 65, 86, 89, 32, 241, 244, 25, 16, 65, 84, 69, 82, 82, 69, 83, 84, 82, 73, - 65, 76, 32, 65, 76, 73, 12, 50, 83, 238, 176, 25, 70, 234, 2, 87, 203, - 11, 71, 4, 254, 177, 25, 65, 43, 73, 7, 226, 178, 19, 71, 195, 151, 8, - 83, 152, 4, 142, 1, 65, 130, 19, 69, 190, 1, 73, 134, 8, 76, 138, 6, 79, - 142, 7, 82, 130, 5, 85, 228, 193, 20, 2, 86, 83, 242, 203, 4, 83, 199, - 140, 2, 70, 92, 122, 67, 178, 15, 76, 176, 2, 2, 88, 32, 170, 148, 3, 77, - 176, 250, 5, 2, 82, 83, 140, 251, 1, 2, 84, 72, 203, 230, 9, 73, 70, 72, - 2, 69, 32, 156, 179, 16, 4, 83, 73, 77, 73, 165, 206, 4, 2, 84, 79, 66, - 226, 1, 83, 160, 1, 4, 87, 73, 84, 72, 172, 128, 13, 2, 80, 65, 252, 136, - 2, 2, 77, 65, 164, 162, 11, 13, 84, 72, 82, 79, 87, 73, 78, 71, 32, 65, - 32, 75, 73, 201, 1, 14, 72, 79, 76, 68, 73, 78, 71, 32, 66, 65, 67, 75, - 32, 84, 4, 192, 130, 17, 18, 65, 86, 79, 85, 82, 73, 78, 71, 32, 68, 69, - 76, 73, 67, 73, 79, 85, 83, 141, 138, 5, 13, 67, 82, 69, 65, 77, 73, 78, - 71, 32, 73, 78, 32, 70, 54, 38, 32, 245, 158, 24, 3, 79, 85, 84, 52, 196, - 4, 2, 67, 79, 44, 5, 72, 69, 65, 68, 45, 38, 77, 98, 79, 92, 7, 78, 79, - 32, 71, 79, 79, 68, 238, 1, 80, 164, 1, 16, 83, 84, 85, 67, 75, 45, 79, - 85, 84, 32, 84, 79, 78, 71, 85, 69, 110, 84, 204, 183, 1, 9, 66, 65, 71, - 83, 32, 85, 78, 68, 69, 188, 163, 17, 22, 70, 73, 78, 71, 69, 82, 32, 67, - 79, 86, 69, 82, 73, 78, 71, 32, 67, 76, 79, 83, 69, 68, 244, 67, 3, 82, - 79, 76, 180, 231, 1, 13, 76, 79, 79, 75, 32, 79, 70, 32, 84, 82, 73, 85, - 77, 244, 141, 3, 8, 68, 73, 65, 71, 79, 78, 65, 76, 1, 20, 85, 78, 69, - 86, 69, 78, 32, 69, 89, 69, 83, 32, 65, 78, 68, 32, 87, 65, 86, 89, 4, - 252, 4, 3, 87, 66, 79, 203, 159, 19, 76, 2, 225, 175, 22, 4, 66, 65, 78, - 68, 4, 60, 6, 69, 68, 73, 67, 65, 76, 161, 234, 25, 3, 79, 78, 79, 2, - 157, 247, 25, 3, 32, 77, 65, 12, 90, 75, 36, 4, 80, 69, 78, 32, 189, 172, - 20, 10, 78, 69, 32, 69, 89, 69, 66, 82, 79, 87, 2, 217, 158, 22, 4, 32, - 71, 69, 83, 8, 116, 5, 77, 79, 85, 84, 72, 133, 151, 24, 18, 69, 89, 69, - 83, 32, 65, 78, 68, 32, 72, 65, 78, 68, 32, 79, 86, 69, 82, 7, 11, 32, 4, - 236, 133, 10, 3, 86, 79, 77, 145, 155, 9, 5, 65, 78, 68, 32, 67, 6, 132, - 1, 18, 65, 82, 84, 89, 32, 72, 79, 82, 78, 32, 65, 78, 68, 32, 80, 65, - 82, 84, 100, 2, 69, 69, 173, 159, 19, 4, 76, 69, 65, 68, 2, 205, 200, 22, - 2, 89, 32, 7, 29, 5, 32, 65, 78, 68, 32, 4, 36, 3, 87, 73, 78, 207, 159, - 19, 84, 2, 169, 183, 1, 4, 75, 73, 78, 71, 4, 50, 69, 169, 204, 22, 6, - 72, 69, 82, 77, 79, 77, 2, 157, 167, 27, 8, 65, 82, 83, 32, 79, 70, 32, - 74, 10, 34, 76, 237, 162, 22, 2, 65, 70, 8, 84, 13, 73, 78, 71, 32, 68, - 73, 65, 71, 79, 78, 65, 76, 32, 233, 233, 23, 2, 69, 78, 6, 128, 1, 9, - 67, 82, 79, 83, 83, 73, 78, 71, 32, 177, 178, 19, 16, 73, 78, 32, 87, 72, - 73, 84, 69, 32, 67, 73, 82, 67, 76, 69, 32, 4, 140, 140, 16, 3, 82, 73, - 83, 227, 173, 3, 78, 4, 194, 250, 14, 73, 131, 143, 4, 77, 14, 50, 65, - 50, 77, 44, 2, 82, 82, 251, 227, 18, 78, 4, 156, 171, 8, 3, 82, 70, 85, - 199, 232, 9, 84, 4, 152, 243, 8, 2, 73, 78, 231, 173, 7, 65, 4, 144, 243, - 7, 2, 73, 83, 203, 193, 19, 89, 58, 138, 1, 71, 90, 76, 178, 1, 78, 98, - 82, 182, 2, 83, 164, 14, 4, 86, 69, 32, 68, 141, 252, 4, 10, 69, 76, 68, - 32, 72, 79, 67, 75, 69, 89, 6, 48, 4, 85, 82, 69, 32, 221, 132, 26, 2, - 72, 84, 4, 218, 199, 25, 68, 235, 172, 1, 83, 10, 32, 2, 69, 32, 65, 2, - 77, 32, 6, 218, 192, 13, 70, 140, 155, 2, 3, 67, 65, 66, 147, 165, 8, 83, - 4, 52, 4, 80, 82, 79, 74, 149, 153, 20, 3, 70, 82, 65, 2, 227, 209, 15, - 69, 4, 72, 4, 71, 69, 82, 80, 197, 166, 25, 8, 73, 84, 69, 32, 80, 65, - 82, 84, 2, 171, 133, 16, 82, 22, 34, 69, 189, 1, 3, 83, 84, 32, 13, 56, - 2, 32, 69, 68, 4, 87, 79, 82, 75, 227, 176, 15, 67, 4, 198, 184, 13, 78, - 193, 213, 4, 8, 88, 84, 73, 78, 71, 85, 73, 83, 4, 192, 193, 23, 6, 32, - 83, 80, 65, 82, 75, 215, 237, 3, 83, 10, 238, 173, 5, 81, 224, 179, 10, - 8, 83, 84, 82, 79, 78, 71, 32, 73, 223, 225, 6, 80, 10, 38, 72, 141, 221, - 23, 3, 84, 69, 68, 9, 128, 255, 3, 13, 73, 78, 71, 32, 80, 79, 76, 69, - 32, 65, 78, 68, 32, 226, 205, 5, 69, 137, 218, 16, 19, 32, 67, 65, 75, - 69, 32, 87, 73, 84, 72, 32, 83, 87, 73, 82, 76, 32, 68, 69, 46, 50, 65, - 170, 1, 69, 98, 79, 194, 1, 85, 39, 89, 12, 114, 84, 236, 163, 4, 5, 80, - 80, 73, 78, 71, 244, 155, 3, 6, 71, 32, 73, 78, 32, 72, 213, 219, 17, 3, - 77, 73, 78, 6, 242, 217, 8, 32, 174, 199, 11, 66, 135, 241, 5, 78, 4, - 172, 242, 23, 8, 88, 69, 68, 32, 66, 73, 67, 69, 153, 145, 1, 7, 85, 82, - 45, 68, 69, 45, 76, 12, 52, 2, 82, 65, 20, 3, 87, 69, 82, 243, 225, 25, - 80, 5, 251, 161, 26, 76, 7, 17, 2, 32, 80, 4, 58, 85, 185, 199, 24, 8, - 76, 65, 89, 73, 78, 71, 32, 67, 2, 157, 191, 26, 4, 78, 67, 84, 85, 4, - 190, 158, 3, 83, 159, 243, 23, 84, 15, 25, 4, 73, 78, 71, 32, 12, 64, 6, - 83, 65, 85, 67, 69, 82, 134, 140, 10, 68, 207, 131, 10, 69, 9, 11, 32, 6, - 40, 4, 87, 73, 84, 72, 203, 145, 26, 83, 4, 34, 32, 1, 4, 79, 85, 84, 32, - 2, 21, 3, 66, 69, 65, 2, 219, 232, 26, 77, 56, 102, 71, 20, 2, 76, 68, - 68, 2, 79, 84, 22, 82, 142, 2, 85, 232, 146, 23, 2, 78, 68, 191, 210, 3, - 88, 5, 243, 147, 27, 71, 4, 208, 201, 9, 8, 73, 78, 71, 32, 72, 65, 78, - 68, 251, 162, 17, 69, 5, 171, 153, 14, 80, 18, 78, 75, 132, 1, 3, 84, 85, - 78, 238, 215, 20, 77, 222, 192, 4, 32, 179, 116, 67, 8, 80, 10, 32, 65, - 78, 68, 32, 75, 78, 73, 70, 69, 218, 156, 15, 69, 223, 181, 11, 73, 5, - 177, 214, 15, 7, 32, 87, 73, 84, 72, 32, 80, 4, 200, 135, 27, 6, 69, 32, - 67, 79, 79, 75, 179, 27, 65, 22, 26, 82, 175, 182, 23, 78, 20, 38, 32, - 218, 2, 84, 199, 231, 18, 45, 16, 110, 67, 174, 1, 68, 182, 170, 2, 66, - 136, 152, 10, 7, 76, 69, 65, 70, 32, 67, 76, 242, 106, 84, 235, 215, 11, - 80, 4, 252, 174, 13, 3, 76, 85, 66, 181, 86, 32, 79, 82, 78, 69, 82, 32, - 65, 82, 82, 79, 87, 83, 32, 67, 73, 82, 67, 76, 73, 78, 71, 32, 65, 78, - 84, 73, 67, 76, 79, 67, 75, 87, 4, 21, 3, 79, 84, 32, 4, 222, 217, 23, - 80, 195, 132, 3, 77, 2, 231, 43, 72, 30, 78, 65, 250, 1, 69, 98, 79, 237, - 250, 16, 8, 73, 69, 68, 32, 83, 72, 82, 73, 12, 96, 6, 67, 84, 73, 79, - 78, 32, 68, 8, 77, 69, 32, 87, 73, 84, 72, 32, 245, 238, 10, 2, 71, 73, - 4, 142, 249, 19, 83, 177, 6, 9, 78, 85, 77, 69, 82, 65, 84, 79, 82, 6, - 50, 80, 218, 170, 2, 65, 253, 176, 21, 2, 84, 73, 2, 161, 254, 21, 2, 73, - 67, 6, 48, 6, 78, 67, 72, 32, 70, 82, 243, 133, 19, 69, 4, 150, 134, 26, - 73, 133, 15, 3, 65, 78, 67, 10, 52, 3, 78, 84, 45, 116, 2, 87, 78, 167, - 221, 26, 71, 4, 70, 84, 217, 143, 2, 11, 70, 65, 67, 73, 78, 71, 32, 66, - 65, 66, 89, 2, 237, 187, 12, 6, 73, 76, 84, 69, 68, 32, 5, 237, 143, 8, - 6, 73, 78, 71, 32, 70, 65, 226, 1, 80, 2, 76, 76, 134, 6, 78, 184, 242, - 16, 5, 69, 76, 32, 80, 85, 179, 138, 10, 83, 216, 1, 42, 32, 73, 6, 87, - 73, 68, 84, 72, 32, 10, 158, 137, 12, 77, 188, 166, 3, 2, 79, 85, 170, - 247, 8, 66, 151, 29, 83, 206, 1, 242, 1, 67, 42, 76, 78, 78, 30, 80, 66, - 82, 142, 1, 83, 38, 89, 182, 155, 10, 77, 226, 208, 10, 65, 158, 2, 68, - 58, 69, 98, 71, 118, 72, 202, 4, 81, 198, 153, 2, 87, 182, 29, 84, 162, - 146, 1, 70, 224, 177, 1, 6, 66, 82, 79, 75, 69, 78, 211, 7, 86, 10, 138, - 240, 20, 73, 62, 79, 131, 81, 69, 116, 42, 69, 190, 243, 20, 65, 231, - 183, 4, 79, 10, 162, 1, 70, 175, 245, 20, 83, 4, 142, 202, 21, 79, 35, - 85, 6, 42, 79, 174, 246, 20, 69, 211, 236, 2, 76, 2, 199, 169, 25, 85, - 10, 36, 3, 73, 71, 72, 183, 251, 24, 69, 8, 17, 2, 84, 32, 8, 244, 172, - 20, 5, 87, 72, 73, 84, 69, 246, 220, 2, 67, 210, 3, 80, 239, 7, 83, 4, - 226, 196, 23, 69, 139, 184, 1, 79, 2, 199, 151, 25, 69, 6, 180, 201, 11, - 8, 67, 84, 73, 79, 78, 32, 65, 80, 132, 248, 8, 5, 69, 82, 65, 76, 32, - 211, 188, 1, 78, 130, 21, 114, 65, 250, 6, 69, 222, 22, 73, 162, 1, 76, - 134, 15, 79, 198, 6, 82, 178, 92, 85, 242, 146, 22, 72, 131, 238, 3, 83, - 142, 1, 42, 82, 253, 245, 26, 4, 77, 69, 32, 68, 140, 1, 36, 3, 65, 89, - 32, 231, 230, 25, 76, 138, 1, 166, 1, 67, 210, 1, 83, 192, 2, 6, 86, 79, - 87, 69, 76, 32, 224, 174, 8, 6, 82, 69, 68, 85, 80, 76, 246, 203, 10, 72, - 238, 168, 1, 80, 214, 181, 3, 77, 171, 190, 1, 68, 52, 42, 79, 205, 1, 5, - 65, 80, 73, 84, 65, 8, 88, 10, 77, 66, 73, 78, 73, 78, 71, 32, 68, 79, - 37, 8, 78, 83, 79, 78, 65, 78, 84, 32, 4, 158, 145, 12, 85, 171, 128, 14, - 84, 4, 230, 145, 12, 78, 223, 156, 11, 71, 46, 36, 3, 77, 65, 76, 147, - 138, 22, 85, 44, 45, 9, 76, 32, 76, 69, 84, 84, 69, 82, 32, 44, 200, 1, - 4, 79, 76, 68, 32, 190, 147, 20, 78, 238, 245, 6, 66, 2, 67, 2, 68, 2, - 70, 2, 71, 2, 72, 2, 74, 2, 75, 2, 76, 2, 77, 2, 80, 2, 82, 2, 83, 2, 84, - 2, 87, 2, 88, 2, 89, 187, 2, 65, 4, 166, 137, 27, 75, 3, 78, 12, 44, 5, - 83, 73, 71, 78, 32, 155, 201, 26, 76, 10, 242, 202, 26, 69, 162, 64, 65, - 2, 73, 3, 79, 146, 3, 112, 2, 65, 82, 110, 77, 50, 79, 136, 210, 23, 9, - 82, 77, 65, 78, 32, 80, 69, 78, 78, 174, 177, 2, 84, 239, 105, 78, 7, 29, - 5, 32, 87, 73, 84, 72, 4, 200, 152, 14, 5, 79, 85, 84, 32, 72, 233, 175, - 9, 5, 32, 72, 65, 78, 68, 4, 26, 32, 143, 132, 22, 73, 2, 183, 147, 23, - 83, 130, 3, 46, 77, 245, 5, 6, 82, 71, 73, 65, 78, 32, 38, 92, 13, 65, - 78, 84, 73, 67, 32, 70, 73, 71, 85, 82, 69, 32, 205, 4, 5, 69, 84, 82, - 73, 67, 32, 158, 1, 65, 82, 67, 172, 1, 9, 70, 79, 82, 84, 85, 78, 65, - 32, 77, 44, 3, 76, 65, 69, 0, 4, 84, 82, 73, 83, 34, 80, 80, 3, 82, 85, - 66, 219, 206, 10, 86, 6, 216, 1, 6, 67, 81, 85, 73, 83, 73, 12, 4, 77, - 73, 83, 83, 211, 158, 23, 76, 8, 42, 65, 97, 6, 79, 78, 74, 85, 78, 67, - 6, 56, 3, 80, 85, 84, 0, 3, 85, 68, 65, 131, 180, 18, 82, 2, 165, 90, 5, - 32, 68, 82, 65, 67, 2, 11, 84, 2, 191, 229, 26, 73, 4, 206, 167, 2, 73, - 233, 163, 24, 2, 65, 74, 2, 197, 207, 10, 3, 84, 73, 84, 6, 44, 2, 85, - 69, 153, 248, 22, 3, 79, 80, 85, 4, 138, 225, 26, 76, 155, 34, 82, 2, - 159, 250, 24, 69, 6, 228, 255, 19, 4, 65, 76, 76, 89, 137, 228, 1, 5, 32, - 80, 82, 79, 80, 220, 2, 228, 1, 6, 67, 65, 80, 73, 84, 65, 0, 4, 83, 77, - 65, 76, 172, 3, 7, 76, 69, 84, 84, 69, 82, 32, 180, 2, 24, 77, 84, 65, - 86, 82, 85, 76, 73, 32, 67, 65, 80, 73, 84, 65, 76, 32, 76, 69, 84, 84, - 69, 82, 32, 165, 6, 2, 80, 65, 80, 45, 9, 76, 32, 76, 69, 84, 84, 69, 82, - 32, 80, 142, 2, 65, 34, 72, 166, 5, 67, 118, 71, 130, 1, 74, 34, 75, 82, - 80, 34, 83, 94, 90, 176, 178, 5, 2, 84, 65, 214, 144, 8, 76, 226, 180, 2, - 82, 218, 176, 9, 66, 2, 77, 2, 88, 226, 40, 78, 2, 81, 234, 35, 86, 234, - 47, 68, 14, 69, 2, 73, 2, 79, 2, 85, 2, 89, 143, 57, 87, 4, 154, 174, 26, - 69, 227, 79, 78, 10, 46, 65, 218, 230, 26, 73, 2, 79, 215, 22, 69, 4, - 170, 253, 26, 69, 3, 82, 94, 254, 1, 85, 178, 2, 65, 42, 67, 74, 69, 46, - 71, 34, 72, 98, 74, 34, 75, 34, 76, 50, 80, 34, 83, 34, 84, 62, 90, 230, - 247, 15, 82, 218, 176, 9, 66, 2, 77, 2, 88, 226, 40, 78, 2, 81, 234, 35, - 86, 234, 47, 68, 14, 73, 2, 79, 2, 89, 142, 57, 87, 255, 2, 70, 4, 240, - 130, 22, 4, 45, 66, 82, 74, 159, 248, 4, 78, 92, 250, 1, 65, 42, 67, 74, - 69, 46, 71, 34, 72, 98, 74, 34, 75, 34, 76, 50, 80, 34, 83, 34, 84, 62, - 90, 230, 247, 15, 82, 218, 176, 9, 66, 2, 77, 2, 88, 226, 40, 78, 2, 81, - 234, 35, 86, 234, 47, 68, 14, 73, 2, 79, 2, 85, 2, 89, 142, 57, 87, 255, - 2, 70, 6, 254, 168, 26, 69, 2, 73, 227, 79, 78, 8, 38, 72, 194, 236, 25, - 73, 243, 59, 65, 4, 174, 168, 26, 73, 135, 23, 65, 4, 208, 140, 9, 2, 76, - 73, 159, 235, 17, 78, 4, 166, 171, 25, 72, 191, 124, 65, 12, 46, 65, 162, - 224, 26, 73, 2, 79, 215, 22, 69, 6, 26, 82, 219, 246, 26, 69, 5, 215, - 239, 25, 68, 4, 166, 170, 25, 72, 207, 64, 73, 4, 230, 210, 25, 72, 223, - 83, 65, 4, 11, 65, 4, 174, 210, 15, 66, 203, 163, 11, 83, 4, 150, 210, - 25, 72, 227, 106, 65, 4, 222, 245, 25, 72, 247, 47, 65, 6, 176, 184, 3, - 6, 85, 82, 78, 69, 68, 32, 187, 250, 1, 65, 4, 154, 209, 25, 72, 223, 83, - 69, 2, 157, 171, 20, 7, 82, 65, 71, 82, 65, 80, 72, 10, 48, 2, 77, 69, - 20, 4, 78, 71, 69, 82, 31, 82, 2, 143, 222, 25, 76, 2, 237, 188, 18, 2, - 32, 82, 6, 38, 76, 253, 234, 13, 3, 65, 70, 70, 5, 183, 221, 25, 83, 202, - 1, 66, 65, 214, 13, 79, 161, 163, 26, 7, 69, 73, 67, 72, 32, 83, 84, 194, - 1, 84, 8, 71, 79, 76, 73, 84, 73, 67, 32, 229, 12, 8, 83, 83, 32, 79, 70, - 32, 77, 73, 192, 1, 56, 6, 67, 65, 80, 73, 84, 65, 1, 4, 83, 77, 65, 76, - 96, 45, 9, 76, 32, 76, 69, 84, 84, 69, 82, 32, 96, 206, 1, 65, 22, 66, - 42, 67, 94, 68, 94, 70, 38, 71, 46, 73, 138, 2, 76, 58, 77, 66, 78, 34, - 79, 30, 80, 58, 82, 30, 83, 186, 1, 84, 110, 86, 22, 89, 90, 90, 210, - 137, 19, 72, 190, 133, 2, 85, 139, 183, 5, 75, 2, 155, 202, 26, 90, 4, - 214, 3, 73, 209, 217, 26, 2, 85, 75, 4, 48, 8, 65, 85, 68, 65, 84, 69, - 32, 67, 15, 72, 2, 11, 72, 2, 209, 255, 19, 2, 82, 73, 6, 42, 74, 30, 79, - 213, 202, 26, 2, 90, 69, 2, 137, 255, 19, 2, 69, 82, 2, 163, 251, 24, 66, - 4, 186, 148, 21, 82, 139, 180, 5, 73, 2, 21, 3, 76, 65, 71, 2, 243, 232, - 21, 79, 13, 38, 78, 54, 79, 141, 1, 2, 90, 72, 2, 137, 191, 26, 8, 73, - 84, 73, 65, 76, 32, 73, 90, 4, 33, 6, 84, 65, 84, 69, 68, 32, 4, 26, 66, - 25, 2, 83, 77, 2, 11, 73, 2, 35, 71, 2, 21, 3, 65, 76, 76, 2, 141, 226, - 24, 2, 32, 89, 4, 134, 232, 26, 73, 211, 2, 69, 4, 52, 9, 65, 84, 73, 78, - 65, 84, 69, 32, 77, 35, 74, 2, 193, 137, 11, 3, 89, 83, 76, 2, 213, 144, - 9, 3, 85, 68, 73, 2, 11, 65, 2, 187, 145, 21, 83, 4, 182, 196, 26, 78, 3, - 84, 4, 26, 79, 235, 232, 26, 69, 2, 221, 200, 22, 2, 75, 79, 2, 213, 245, - 21, 2, 73, 84, 14, 106, 72, 58, 76, 252, 239, 13, 6, 80, 73, 68, 69, 82, - 89, 173, 191, 10, 8, 77, 65, 76, 76, 32, 89, 85, 83, 6, 32, 2, 84, 65, - 163, 231, 26, 65, 5, 131, 189, 25, 80, 2, 231, 251, 19, 79, 6, 78, 86, - 172, 157, 22, 9, 82, 79, 75, 85, 84, 65, 83, 84, 73, 167, 181, 4, 83, 2, - 229, 166, 19, 2, 82, 73, 2, 151, 211, 24, 69, 12, 50, 69, 198, 249, 18, - 65, 130, 236, 7, 79, 3, 85, 6, 250, 140, 21, 83, 147, 152, 5, 82, 4, 248, - 148, 9, 3, 69, 77, 76, 145, 135, 16, 4, 72, 73, 86, 69, 2, 199, 225, 26, - 76, 6, 248, 242, 11, 13, 66, 69, 32, 87, 73, 84, 72, 32, 77, 69, 82, 73, - 68, 154, 196, 4, 87, 183, 151, 9, 86, 68, 162, 1, 65, 44, 12, 84, 72, 73, - 67, 32, 76, 69, 84, 84, 69, 82, 32, 198, 166, 18, 82, 222, 102, 71, 228, - 141, 5, 3, 78, 71, 71, 238, 187, 1, 79, 185, 77, 2, 76, 70, 4, 172, 183, - 15, 2, 76, 32, 147, 171, 11, 84, 54, 210, 2, 65, 50, 72, 46, 73, 46, 78, - 46, 80, 2, 81, 40, 2, 82, 65, 22, 84, 160, 141, 9, 2, 87, 73, 246, 147, - 12, 85, 244, 69, 3, 70, 65, 73, 204, 7, 4, 66, 65, 73, 82, 248, 21, 2, - 79, 84, 150, 30, 68, 166, 128, 1, 77, 198, 147, 1, 69, 164, 30, 3, 76, - 65, 71, 148, 41, 3, 83, 65, 85, 230, 161, 1, 74, 196, 16, 2, 71, 73, 141, - 12, 2, 75, 85, 4, 216, 214, 24, 3, 73, 72, 86, 163, 134, 2, 72, 4, 162, - 224, 13, 87, 157, 243, 11, 2, 65, 71, 4, 190, 142, 9, 85, 165, 241, 14, - 2, 71, 71, 6, 178, 206, 15, 73, 241, 140, 9, 2, 65, 85, 2, 201, 153, 26, - 5, 65, 73, 82, 84, 72, 2, 223, 184, 26, 73, 4, 224, 184, 23, 2, 72, 73, - 237, 69, 2, 69, 73, 234, 9, 46, 65, 198, 5, 69, 206, 82, 73, 151, 3, 79, - 152, 1, 96, 7, 68, 85, 65, 84, 73, 79, 78, 32, 5, 78, 84, 72, 65, 32, - 138, 184, 20, 86, 219, 141, 5, 80, 2, 11, 32, 2, 239, 200, 25, 67, 146, - 1, 120, 7, 76, 69, 84, 84, 69, 82, 32, 212, 2, 5, 83, 73, 71, 78, 32, - 130, 247, 22, 65, 248, 8, 2, 86, 79, 195, 199, 3, 79, 100, 214, 1, 86, - 154, 251, 22, 65, 38, 68, 114, 84, 230, 5, 85, 186, 202, 1, 73, 42, 76, - 226, 195, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 206, - 40, 79, 162, 8, 69, 158, 20, 72, 2, 77, 2, 82, 3, 89, 14, 60, 5, 69, 68, - 73, 67, 32, 242, 129, 23, 79, 223, 214, 3, 65, 4, 164, 159, 24, 6, 68, - 79, 85, 66, 76, 69, 175, 244, 1, 65, 16, 66, 67, 206, 186, 22, 78, 190, - 66, 65, 182, 1, 80, 135, 150, 3, 86, 4, 162, 242, 7, 79, 215, 199, 14, - 65, 192, 8, 76, 10, 65, 84, 69, 82, 45, 84, 72, 65, 78, 32, 206, 7, 69, - 207, 199, 25, 89, 56, 134, 1, 65, 150, 3, 66, 62, 79, 216, 2, 11, 69, 81, - 85, 65, 76, 32, 84, 79, 32, 79, 82, 182, 204, 6, 67, 138, 4, 87, 131, - 248, 18, 83, 16, 44, 5, 66, 79, 86, 69, 32, 147, 209, 6, 78, 12, 150, 1, - 83, 180, 1, 19, 68, 79, 85, 66, 76, 69, 45, 76, 73, 78, 69, 32, 69, 81, - 85, 65, 76, 32, 65, 184, 203, 6, 4, 76, 69, 83, 83, 159, 229, 18, 82, 6, - 148, 1, 7, 73, 77, 73, 76, 65, 82, 32, 185, 206, 6, 23, 76, 65, 78, 84, - 69, 68, 32, 69, 81, 85, 65, 76, 32, 65, 66, 79, 86, 69, 32, 76, 69, 83, - 83, 4, 26, 65, 143, 206, 6, 79, 2, 65, 3, 66, 79, 86, 6, 40, 4, 69, 83, - 73, 68, 247, 206, 6, 85, 2, 231, 2, 69, 20, 40, 2, 82, 32, 245, 1, 3, 86, - 69, 82, 16, 120, 16, 83, 76, 65, 78, 84, 69, 68, 32, 69, 81, 85, 65, 76, - 32, 84, 79, 190, 208, 6, 65, 166, 253, 12, 69, 167, 237, 4, 76, 9, 49, - 10, 32, 87, 73, 84, 72, 32, 68, 79, 84, 32, 6, 44, 5, 65, 66, 79, 86, 69, - 255, 157, 18, 73, 5, 183, 157, 26, 32, 4, 52, 7, 76, 65, 80, 80, 73, 78, - 71, 215, 237, 19, 32, 2, 209, 185, 24, 2, 32, 76, 134, 8, 36, 2, 75, 32, - 185, 73, 2, 78, 32, 254, 7, 130, 3, 65, 216, 15, 8, 67, 65, 80, 73, 84, - 65, 76, 32, 182, 11, 68, 134, 1, 70, 68, 2, 73, 78, 222, 3, 75, 138, 1, - 76, 174, 3, 78, 66, 77, 84, 3, 88, 69, 83, 22, 79, 202, 1, 80, 90, 82, - 182, 1, 83, 130, 22, 84, 200, 2, 13, 85, 80, 83, 73, 76, 79, 78, 32, 87, - 73, 84, 72, 32, 150, 1, 86, 142, 2, 89, 230, 228, 7, 66, 212, 176, 3, 4, - 71, 82, 65, 77, 196, 23, 2, 90, 69, 175, 132, 12, 81, 112, 92, 10, 67, - 82, 79, 80, 72, 79, 78, 73, 67, 32, 172, 14, 6, 78, 79, 32, 84, 69, 76, - 23, 82, 106, 188, 2, 6, 65, 84, 84, 73, 67, 32, 222, 5, 67, 92, 3, 78, - 65, 88, 32, 12, 68, 69, 76, 80, 72, 73, 67, 32, 70, 73, 86, 69, 0, 14, - 83, 84, 82, 65, 84, 73, 65, 78, 32, 70, 73, 70, 84, 89, 40, 11, 69, 80, - 73, 68, 65, 85, 82, 69, 65, 78, 32, 112, 3, 72, 69, 82, 164, 1, 9, 77, - 69, 83, 83, 69, 78, 73, 65, 78, 35, 84, 48, 72, 2, 70, 73, 180, 2, 4, 79, - 78, 69, 32, 205, 1, 4, 84, 69, 78, 32, 26, 36, 3, 70, 84, 89, 105, 2, 86, - 69, 11, 11, 32, 8, 22, 84, 171, 4, 83, 6, 48, 7, 72, 79, 85, 83, 65, 78, - 68, 215, 3, 65, 5, 231, 3, 32, 17, 11, 32, 14, 56, 7, 72, 85, 78, 68, 82, - 69, 68, 18, 84, 143, 3, 83, 7, 131, 2, 32, 6, 48, 7, 72, 79, 85, 83, 65, - 78, 68, 187, 2, 65, 5, 213, 1, 2, 32, 84, 14, 98, 72, 48, 7, 84, 72, 79, - 85, 83, 65, 78, 186, 190, 24, 81, 217, 228, 1, 5, 68, 82, 65, 67, 72, 6, - 44, 5, 85, 78, 68, 82, 69, 155, 190, 24, 65, 4, 17, 2, 68, 32, 4, 22, 84, - 131, 1, 83, 2, 95, 65, 8, 30, 84, 86, 83, 175, 1, 77, 4, 50, 65, 21, 8, - 72, 79, 85, 83, 65, 78, 68, 32, 2, 163, 178, 16, 76, 2, 11, 83, 2, 157, - 191, 24, 2, 84, 65, 4, 88, 5, 65, 82, 89, 83, 84, 145, 1, 12, 89, 82, 69, - 78, 65, 73, 67, 32, 84, 87, 79, 32, 2, 101, 5, 73, 65, 78, 32, 70, 2, 17, - 2, 32, 77, 2, 243, 143, 13, 78, 6, 30, 70, 29, 3, 84, 87, 79, 2, 201, - 178, 15, 2, 73, 86, 5, 11, 32, 2, 237, 148, 10, 5, 68, 82, 65, 67, 72, 8, - 112, 8, 77, 73, 79, 78, 73, 65, 78, 32, 157, 152, 25, 14, 65, 69, 85, 77, - 32, 79, 78, 69, 32, 80, 76, 69, 84, 72, 6, 182, 185, 12, 70, 150, 176, - 12, 84, 215, 58, 79, 2, 11, 32, 2, 143, 233, 24, 84, 32, 92, 8, 72, 69, - 83, 80, 73, 65, 78, 32, 129, 1, 10, 82, 79, 69, 90, 69, 78, 73, 65, 78, - 32, 20, 40, 2, 70, 73, 38, 84, 227, 155, 18, 79, 6, 158, 225, 20, 86, - 247, 236, 3, 70, 8, 226, 174, 15, 72, 142, 191, 10, 69, 239, 48, 87, 12, - 36, 2, 70, 73, 209, 24, 2, 84, 69, 8, 250, 180, 18, 86, 213, 136, 7, 3, - 70, 84, 89, 2, 155, 136, 10, 69, 4, 144, 231, 22, 2, 79, 85, 153, 181, 1, - 3, 84, 65, 66, 154, 2, 66, 76, 174, 45, 82, 66, 68, 144, 230, 7, 2, 75, - 65, 135, 6, 84, 144, 2, 44, 6, 69, 84, 84, 69, 82, 32, 239, 45, 85, 142, - 2, 198, 2, 65, 190, 1, 69, 28, 4, 73, 79, 84, 65, 128, 1, 2, 79, 77, 156, - 3, 3, 82, 72, 79, 46, 83, 48, 7, 85, 80, 83, 73, 76, 79, 78, 146, 33, 80, - 170, 2, 84, 146, 182, 5, 68, 252, 180, 2, 2, 75, 65, 238, 192, 1, 71, - 190, 138, 11, 67, 230, 154, 2, 66, 2, 72, 2, 90, 166, 1, 76, 186, 235, 2, - 89, 210, 43, 77, 2, 78, 147, 17, 88, 48, 68, 4, 76, 80, 72, 65, 213, 28, - 8, 82, 67, 72, 65, 73, 67, 32, 83, 47, 33, 6, 32, 87, 73, 84, 72, 32, 44, - 242, 2, 68, 30, 80, 226, 29, 86, 226, 5, 79, 162, 234, 3, 84, 191, 174, - 5, 77, 62, 186, 1, 84, 131, 27, 80, 31, 33, 6, 32, 87, 73, 84, 72, 32, - 28, 186, 5, 68, 136, 25, 2, 80, 83, 158, 1, 86, 226, 5, 79, 162, 234, 3, - 84, 191, 174, 5, 77, 62, 28, 2, 69, 71, 235, 34, 73, 42, 11, 65, 43, 33, - 6, 32, 87, 73, 84, 72, 32, 40, 54, 68, 30, 80, 194, 35, 79, 22, 86, 143, - 234, 3, 84, 16, 65, 4, 65, 83, 73, 65, 18, 36, 4, 83, 73, 76, 73, 211, - 16, 82, 17, 29, 5, 32, 65, 78, 68, 32, 14, 44, 2, 79, 88, 0, 3, 86, 65, - 82, 23, 80, 4, 81, 2, 73, 65, 6, 60, 10, 69, 82, 73, 83, 80, 79, 77, 69, - 78, 73, 175, 15, 82, 5, 169, 15, 7, 32, 65, 78, 68, 32, 80, 82, 5, 161, - 35, 7, 32, 87, 73, 84, 72, 32, 68, 6, 146, 144, 8, 73, 162, 210, 17, 65, - 239, 48, 72, 23, 33, 6, 32, 87, 73, 84, 72, 32, 20, 66, 68, 166, 26, 86, - 226, 5, 79, 162, 234, 3, 84, 191, 174, 5, 77, 10, 130, 24, 65, 213, 191, - 22, 5, 73, 65, 76, 89, 84, 18, 76, 9, 73, 65, 76, 89, 84, 73, 75, 65, 32, - 32, 3, 82, 65, 67, 227, 22, 65, 8, 174, 24, 65, 243, 240, 3, 84, 2, 131, - 191, 11, 72, 4, 40, 3, 73, 86, 69, 1, 3, 79, 85, 82, 2, 205, 37, 2, 32, - 79, 76, 144, 1, 27, 83, 84, 82, 85, 77, 69, 78, 84, 65, 76, 32, 78, 79, - 84, 65, 84, 73, 79, 78, 32, 83, 89, 77, 66, 79, 76, 45, 193, 168, 22, 2, - 68, 73, 74, 70, 49, 70, 50, 62, 51, 62, 52, 170, 37, 53, 194, 134, 26, - 55, 3, 56, 17, 162, 173, 26, 49, 2, 50, 2, 51, 2, 52, 2, 55, 2, 56, 3, - 57, 15, 222, 172, 26, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, 57, 12, 162, - 172, 26, 48, 2, 50, 2, 54, 2, 55, 2, 56, 3, 57, 17, 230, 171, 26, 48, 2, - 50, 2, 51, 2, 53, 2, 55, 2, 56, 3, 57, 8, 54, 65, 38, 79, 169, 32, 6, 89, - 65, 84, 72, 79, 83, 4, 186, 130, 8, 80, 239, 146, 17, 73, 2, 11, 82, 2, - 11, 79, 2, 167, 131, 24, 78, 32, 128, 1, 6, 69, 84, 84, 69, 82, 32, 168, - 2, 6, 79, 87, 69, 82, 32, 78, 32, 6, 85, 78, 65, 84, 69, 32, 177, 209, - 22, 2, 73, 84, 24, 94, 83, 140, 13, 9, 65, 82, 67, 72, 65, 73, 67, 32, - 75, 2, 75, 182, 11, 68, 195, 191, 25, 89, 16, 88, 13, 77, 65, 76, 76, 32, - 67, 65, 80, 73, 84, 65, 76, 32, 210, 12, 65, 171, 247, 7, 84, 12, 74, 80, - 222, 196, 9, 71, 166, 157, 9, 79, 154, 212, 2, 82, 139, 181, 1, 76, 4, - 182, 147, 26, 83, 219, 19, 73, 2, 213, 138, 10, 3, 85, 77, 69, 4, 222, - 25, 83, 139, 228, 7, 69, 4, 80, 4, 69, 84, 82, 69, 149, 208, 23, 10, 85, - 83, 73, 67, 65, 76, 32, 76, 69, 73, 2, 235, 212, 2, 84, 12, 88, 3, 78, - 69, 32, 194, 240, 9, 88, 176, 151, 5, 3, 85, 78, 75, 225, 208, 5, 2, 66, - 79, 6, 64, 8, 72, 65, 76, 70, 32, 83, 73, 71, 21, 4, 81, 85, 65, 82, 4, - 255, 164, 25, 78, 2, 251, 216, 20, 84, 16, 62, 82, 206, 11, 83, 114, 69, - 206, 239, 7, 72, 247, 145, 17, 73, 2, 217, 29, 2, 79, 83, 6, 100, 3, 72, - 79, 32, 217, 249, 7, 16, 69, 86, 69, 82, 83, 69, 68, 32, 76, 85, 78, 65, - 84, 69, 32, 69, 4, 240, 243, 13, 10, 87, 73, 84, 72, 32, 83, 84, 82, 79, - 75, 163, 153, 11, 83, 226, 2, 220, 1, 5, 77, 65, 76, 76, 32, 192, 19, 22, - 85, 66, 83, 67, 82, 73, 80, 84, 32, 83, 77, 65, 76, 76, 32, 76, 69, 84, - 84, 69, 82, 32, 72, 10, 89, 77, 66, 79, 76, 32, 84, 65, 85, 32, 201, 160, - 24, 6, 73, 78, 85, 83, 79, 73, 212, 2, 56, 7, 76, 69, 84, 84, 69, 82, 32, - 202, 17, 82, 67, 68, 206, 2, 178, 2, 65, 162, 2, 68, 38, 69, 52, 4, 73, - 79, 84, 65, 0, 7, 85, 80, 83, 73, 76, 79, 78, 254, 3, 75, 28, 2, 79, 77, - 182, 5, 80, 112, 3, 82, 72, 79, 94, 83, 94, 84, 168, 234, 7, 2, 70, 73, - 210, 193, 1, 71, 190, 138, 11, 67, 230, 154, 2, 66, 2, 72, 2, 90, 166, 1, - 76, 138, 151, 3, 77, 2, 78, 147, 17, 88, 58, 64, 4, 76, 80, 72, 65, 149, - 1, 7, 82, 67, 72, 65, 73, 67, 32, 55, 33, 6, 32, 87, 73, 84, 72, 32, 52, - 82, 86, 226, 6, 68, 30, 80, 114, 79, 142, 1, 89, 142, 236, 3, 84, 191, - 174, 5, 77, 6, 154, 5, 82, 155, 3, 65, 4, 18, 75, 23, 83, 2, 139, 248, 7, - 79, 2, 11, 65, 2, 147, 189, 13, 77, 4, 202, 226, 7, 73, 203, 251, 14, 69, - 70, 22, 80, 215, 4, 84, 20, 249, 7, 3, 83, 73, 76, 41, 33, 6, 32, 87, 73, - 84, 72, 32, 38, 78, 68, 166, 1, 80, 178, 1, 86, 226, 5, 79, 162, 234, 3, - 84, 191, 174, 5, 77, 18, 50, 65, 29, 8, 73, 65, 76, 89, 84, 73, 75, 65, - 8, 153, 1, 3, 83, 73, 65, 11, 29, 5, 32, 65, 78, 68, 32, 8, 170, 1, 80, - 154, 6, 79, 22, 86, 143, 234, 3, 84, 10, 18, 83, 115, 69, 8, 21, 3, 73, - 76, 73, 9, 17, 2, 32, 65, 6, 21, 3, 78, 68, 32, 6, 30, 80, 154, 6, 79, - 23, 86, 2, 11, 69, 2, 11, 82, 2, 181, 17, 4, 73, 83, 80, 79, 4, 22, 82, - 147, 15, 65, 2, 249, 244, 25, 2, 65, 67, 4, 130, 243, 7, 65, 3, 79, 70, - 28, 2, 69, 71, 151, 3, 73, 50, 11, 65, 51, 33, 6, 32, 87, 73, 84, 72, 32, - 48, 58, 68, 30, 80, 114, 79, 62, 86, 82, 89, 143, 236, 3, 84, 16, 61, 4, - 65, 83, 73, 65, 20, 32, 4, 83, 73, 76, 73, 91, 69, 17, 29, 5, 32, 65, 78, - 68, 32, 14, 42, 79, 12, 2, 80, 69, 50, 86, 83, 89, 4, 83, 88, 4, 89, 9, - 82, 73, 83, 80, 79, 77, 69, 78, 73, 4, 11, 65, 4, 11, 82, 4, 17, 2, 73, - 65, 5, 33, 6, 32, 65, 78, 68, 32, 89, 2, 243, 12, 80, 20, 17, 2, 67, 82, - 20, 17, 2, 79, 78, 21, 33, 6, 32, 87, 73, 84, 72, 32, 18, 88, 5, 68, 65, - 83, 73, 65, 0, 5, 80, 83, 73, 76, 73, 54, 79, 22, 86, 143, 234, 3, 84, 7, - 29, 5, 32, 65, 78, 68, 32, 4, 18, 79, 23, 86, 2, 203, 220, 9, 88, 2, 179, - 9, 65, 8, 88, 11, 65, 77, 80, 72, 89, 76, 73, 65, 78, 32, 68, 162, 252, - 25, 72, 2, 83, 219, 19, 73, 2, 203, 215, 7, 73, 7, 33, 6, 32, 87, 73, 84, - 72, 32, 4, 34, 68, 177, 139, 21, 2, 80, 83, 2, 203, 201, 8, 65, 10, 54, - 65, 238, 234, 7, 84, 230, 1, 73, 143, 131, 18, 72, 4, 214, 176, 13, 77, - 251, 221, 12, 78, 4, 150, 209, 22, 72, 175, 152, 3, 65, 4, 41, 8, 69, 86, - 69, 82, 83, 69, 68, 32, 4, 18, 68, 43, 76, 2, 37, 7, 79, 84, 84, 69, 68, - 32, 76, 2, 11, 85, 2, 33, 6, 78, 65, 84, 69, 32, 83, 2, 221, 235, 7, 3, - 73, 71, 77, 10, 154, 170, 9, 71, 190, 138, 11, 67, 2, 80, 130, 103, 82, - 231, 179, 1, 66, 2, 143, 155, 21, 82, 16, 106, 72, 104, 7, 82, 89, 66, - 76, 73, 79, 78, 44, 3, 87, 79, 32, 170, 227, 3, 79, 185, 209, 16, 2, 65, - 76, 6, 40, 4, 82, 69, 69, 32, 195, 233, 7, 69, 4, 146, 1, 79, 189, 215, - 22, 7, 81, 85, 65, 82, 84, 69, 82, 2, 21, 3, 32, 66, 65, 2, 255, 233, 23, - 83, 4, 42, 79, 165, 152, 12, 4, 84, 72, 73, 82, 2, 133, 229, 19, 2, 66, - 79, 6, 80, 5, 65, 67, 85, 84, 69, 0, 9, 68, 73, 65, 69, 82, 69, 83, 73, - 83, 39, 72, 2, 33, 6, 32, 65, 78, 68, 32, 72, 2, 133, 199, 7, 2, 79, 79, - 60, 102, 65, 21, 21, 79, 67, 65, 76, 32, 78, 79, 84, 65, 84, 73, 79, 78, - 32, 83, 89, 77, 66, 79, 76, 45, 2, 131, 211, 9, 82, 58, 90, 50, 2, 53, - 190, 194, 23, 49, 134, 196, 2, 51, 2, 52, 2, 54, 2, 55, 2, 56, 3, 57, 13, - 190, 134, 26, 48, 2, 49, 2, 50, 2, 51, 3, 52, 4, 26, 80, 203, 187, 20, - 69, 2, 11, 79, 2, 33, 6, 71, 69, 71, 82, 65, 77, 2, 229, 128, 21, 2, 77, - 69, 8, 230, 237, 13, 65, 206, 193, 10, 66, 202, 78, 72, 253, 64, 3, 83, - 65, 76, 12, 60, 6, 78, 78, 73, 78, 71, 32, 253, 251, 24, 3, 77, 65, 67, - 10, 100, 4, 70, 65, 67, 69, 241, 232, 17, 15, 67, 65, 84, 32, 70, 65, 67, - 69, 32, 87, 73, 84, 72, 32, 83, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 108, - 23, 79, 78, 69, 32, 76, 65, 82, 71, 69, 32, 65, 78, 68, 32, 79, 78, 69, - 32, 83, 77, 65, 76, 76, 35, 83, 2, 11, 32, 2, 151, 161, 8, 69, 4, 32, 2, - 84, 65, 167, 231, 17, 77, 2, 223, 130, 23, 82, 6, 28, 3, 85, 80, 32, 39, - 87, 4, 246, 207, 22, 83, 135, 240, 2, 77, 2, 207, 149, 18, 73, 220, 4, - 136, 1, 2, 65, 82, 70, 73, 52, 7, 74, 65, 82, 65, 84, 73, 32, 184, 6, 12, - 78, 74, 65, 76, 65, 32, 71, 79, 78, 68, 73, 32, 143, 3, 82, 4, 34, 65, - 149, 129, 21, 2, 68, 83, 2, 11, 78, 2, 175, 248, 24, 73, 4, 222, 219, 24, - 84, 221, 162, 1, 4, 68, 69, 32, 68, 182, 1, 168, 1, 7, 76, 69, 84, 84, - 69, 82, 32, 220, 1, 5, 83, 73, 71, 78, 32, 160, 2, 6, 86, 79, 87, 69, 76, - 32, 234, 133, 20, 65, 154, 24, 82, 182, 231, 3, 68, 179, 227, 1, 79, 98, - 194, 159, 22, 65, 38, 68, 114, 84, 46, 86, 186, 5, 85, 186, 202, 1, 73, - 42, 76, 246, 14, 90, 238, 180, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, - 74, 2, 75, 2, 80, 138, 69, 72, 2, 77, 2, 82, 2, 89, 186, 2, 69, 3, 79, - 24, 98, 67, 28, 3, 77, 65, 68, 22, 84, 182, 199, 3, 83, 150, 150, 18, 78, - 190, 66, 65, 187, 151, 3, 86, 4, 118, 73, 175, 220, 21, 65, 2, 219, 140, - 19, 68, 4, 68, 5, 87, 79, 45, 67, 73, 29, 8, 72, 82, 69, 69, 45, 68, 79, - 84, 2, 25, 4, 82, 67, 76, 69, 2, 165, 206, 20, 5, 32, 78, 85, 75, 84, 34, - 44, 5, 83, 73, 71, 78, 32, 215, 191, 15, 67, 30, 210, 191, 15, 67, 154, - 226, 6, 65, 38, 85, 22, 86, 166, 202, 1, 73, 198, 140, 2, 69, 3, 79, 126, - 108, 7, 76, 69, 84, 84, 69, 82, 32, 216, 1, 5, 83, 73, 71, 78, 32, 38, - 86, 190, 129, 24, 68, 179, 227, 1, 79, 80, 186, 129, 22, 78, 146, 24, 65, - 38, 68, 114, 84, 230, 5, 85, 186, 202, 1, 73, 42, 76, 222, 196, 1, 66, 2, - 67, 2, 71, 2, 74, 2, 75, 2, 80, 206, 40, 79, 162, 8, 69, 158, 20, 72, 2, - 77, 2, 82, 2, 83, 2, 86, 3, 89, 4, 250, 187, 23, 86, 247, 244, 1, 65, 20, - 190, 7, 79, 235, 177, 23, 73, 160, 2, 84, 6, 77, 85, 75, 72, 73, 32, 189, - 7, 10, 85, 78, 71, 32, 75, 72, 69, 77, 65, 32, 172, 1, 194, 1, 65, 44, 7, - 76, 69, 84, 84, 69, 82, 32, 238, 1, 83, 228, 2, 2, 86, 79, 140, 144, 13, - 3, 84, 73, 80, 174, 242, 5, 73, 252, 175, 2, 5, 69, 75, 32, 79, 78, 202, - 199, 2, 68, 203, 175, 1, 85, 4, 198, 210, 21, 66, 177, 231, 1, 2, 68, 68, - 96, 174, 198, 8, 71, 2, 75, 178, 206, 13, 65, 38, 68, 82, 82, 34, 84, - 230, 5, 85, 186, 202, 1, 73, 42, 76, 226, 195, 1, 78, 126, 66, 2, 67, 2, - 74, 2, 80, 2, 83, 206, 40, 79, 162, 8, 69, 158, 20, 70, 2, 72, 2, 77, 2, - 86, 2, 89, 3, 90, 26, 108, 19, 69, 81, 85, 69, 78, 67, 69, 32, 70, 79, - 82, 32, 76, 69, 84, 84, 69, 82, 32, 93, 4, 73, 71, 78, 32, 12, 70, 71, 2, - 75, 138, 242, 23, 83, 146, 219, 1, 76, 226, 31, 70, 3, 90, 2, 135, 242, - 23, 72, 14, 128, 1, 6, 65, 68, 65, 75, 32, 66, 2, 66, 220, 140, 15, 2, - 85, 68, 190, 196, 6, 78, 236, 177, 2, 3, 89, 65, 75, 139, 168, 1, 86, 2, - 239, 151, 8, 73, 18, 45, 9, 87, 69, 76, 32, 83, 73, 71, 78, 32, 18, 178, - 150, 22, 65, 38, 85, 186, 202, 1, 73, 210, 237, 1, 79, 163, 8, 69, 116, - 216, 1, 22, 67, 79, 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, 32, - 77, 69, 68, 73, 65, 76, 32, 44, 7, 76, 69, 84, 84, 69, 82, 32, 168, 1, 5, - 83, 73, 71, 78, 32, 56, 6, 86, 79, 87, 69, 76, 32, 159, 245, 23, 68, 8, - 246, 232, 25, 72, 2, 82, 2, 86, 3, 89, 60, 254, 244, 21, 78, 182, 24, 68, - 114, 84, 162, 149, 3, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 138, 69, 72, - 2, 76, 2, 77, 2, 82, 2, 83, 2, 86, 2, 89, 187, 2, 65, 4, 226, 164, 25, - 65, 233, 35, 6, 84, 72, 79, 76, 72, 79, 24, 150, 158, 20, 83, 147, 137, - 5, 76, 168, 23, 110, 65, 214, 95, 69, 150, 104, 73, 146, 9, 79, 158, 12, - 84, 30, 85, 130, 1, 89, 225, 236, 12, 4, 82, 89, 86, 78, 140, 11, 236, 1, - 2, 73, 82, 100, 8, 76, 70, 87, 73, 68, 84, 72, 32, 242, 10, 77, 210, 1, - 78, 236, 76, 21, 80, 80, 89, 32, 80, 69, 82, 83, 79, 78, 32, 82, 65, 73, - 83, 73, 78, 71, 32, 79, 78, 22, 82, 38, 84, 208, 247, 17, 2, 85, 77, 255, - 253, 5, 68, 8, 66, 32, 140, 199, 20, 6, 89, 32, 67, 82, 69, 65, 251, 164, - 4, 67, 4, 194, 179, 24, 80, 231, 115, 83, 244, 1, 140, 2, 7, 72, 65, 78, - 71, 85, 76, 32, 216, 4, 8, 75, 65, 84, 65, 75, 65, 78, 65, 204, 3, 3, 76, - 69, 70, 0, 4, 82, 73, 71, 72, 204, 188, 6, 11, 70, 79, 82, 77, 83, 32, - 76, 73, 71, 72, 84, 202, 134, 4, 85, 250, 213, 2, 73, 142, 190, 4, 66, - 166, 238, 4, 87, 215, 35, 68, 104, 52, 7, 76, 69, 84, 84, 69, 82, 32, - 163, 221, 10, 70, 102, 206, 1, 75, 28, 5, 78, 73, 69, 85, 78, 42, 80, 24, - 5, 82, 73, 69, 85, 76, 86, 83, 98, 89, 202, 61, 67, 54, 69, 30, 73, 242, - 4, 77, 138, 1, 84, 206, 3, 87, 198, 1, 72, 202, 213, 24, 65, 2, 79, 163, - 64, 85, 6, 222, 65, 72, 155, 3, 73, 7, 11, 45, 4, 134, 72, 67, 131, 3, - 72, 6, 146, 69, 72, 35, 73, 17, 11, 45, 14, 206, 49, 84, 226, 14, 80, - 130, 4, 77, 194, 3, 75, 218, 2, 72, 99, 83, 12, 40, 4, 83, 65, 78, 71, - 211, 221, 13, 73, 10, 210, 70, 67, 42, 75, 74, 80, 34, 84, 211, 2, 83, - 14, 214, 149, 23, 69, 146, 137, 2, 65, 162, 64, 73, 2, 79, 3, 85, 118, - 70, 32, 157, 241, 2, 11, 45, 72, 73, 82, 65, 71, 65, 78, 65, 32, 80, 116, - 76, 7, 76, 69, 84, 84, 69, 82, 32, 242, 240, 2, 83, 34, 86, 195, 216, 21, - 77, 110, 146, 1, 83, 230, 234, 2, 78, 150, 2, 72, 2, 75, 2, 77, 2, 82, 2, - 84, 170, 1, 89, 158, 38, 87, 226, 199, 22, 65, 2, 69, 2, 73, 2, 79, 3, - 85, 28, 76, 5, 77, 65, 76, 76, 32, 206, 219, 25, 65, 2, 69, 2, 73, 2, 79, - 3, 85, 18, 206, 237, 2, 89, 150, 201, 22, 84, 234, 36, 65, 2, 69, 2, 73, - 2, 79, 3, 85, 4, 11, 84, 4, 156, 157, 13, 2, 32, 67, 135, 156, 11, 87, - 14, 56, 3, 77, 69, 82, 106, 83, 249, 135, 22, 3, 66, 85, 82, 9, 29, 5, - 32, 65, 78, 68, 32, 6, 196, 169, 12, 3, 87, 82, 69, 212, 233, 3, 2, 83, - 73, 191, 148, 8, 80, 4, 252, 155, 25, 3, 84, 69, 82, 163, 61, 65, 194, 8, - 118, 68, 202, 2, 71, 128, 66, 13, 73, 70, 73, 32, 82, 79, 72, 73, 78, 71, - 89, 65, 32, 165, 5, 5, 85, 78, 79, 79, 32, 10, 100, 12, 32, 87, 73, 84, - 72, 32, 73, 78, 68, 69, 88, 32, 188, 1, 2, 66, 65, 173, 233, 21, 2, 83, - 72, 4, 156, 1, 18, 65, 78, 68, 32, 77, 73, 68, 68, 76, 69, 32, 70, 73, - 78, 71, 69, 82, 83, 1, 16, 70, 73, 78, 71, 69, 82, 32, 65, 78, 68, 32, - 84, 72, 85, 77, 66, 2, 201, 139, 16, 2, 32, 67, 4, 130, 202, 24, 76, 211, - 139, 1, 71, 170, 7, 84, 3, 85, 76, 32, 217, 64, 13, 90, 72, 79, 85, 32, - 78, 85, 77, 69, 82, 65, 76, 32, 146, 7, 164, 1, 9, 67, 72, 79, 83, 69, - 79, 78, 71, 32, 244, 15, 4, 68, 79, 85, 66, 0, 4, 83, 73, 78, 71, 46, 74, - 180, 31, 7, 76, 69, 84, 84, 69, 82, 32, 143, 158, 10, 70, 250, 1, 246, 1, - 67, 172, 2, 5, 73, 69, 85, 78, 71, 146, 1, 75, 132, 1, 5, 77, 73, 69, 85, - 77, 56, 5, 78, 73, 69, 85, 78, 74, 80, 172, 2, 5, 82, 73, 69, 85, 76, - 210, 1, 83, 166, 3, 84, 124, 2, 89, 69, 200, 40, 5, 72, 73, 69, 85, 72, - 195, 149, 10, 70, 30, 76, 2, 72, 73, 84, 7, 69, 79, 78, 71, 67, 72, 73, - 121, 4, 73, 69, 85, 67, 16, 40, 4, 69, 85, 67, 72, 41, 2, 84, 85, 7, 11, - 45, 4, 202, 31, 75, 243, 26, 72, 10, 21, 3, 69, 85, 77, 10, 22, 83, 155, - 46, 67, 6, 40, 4, 83, 65, 78, 71, 195, 205, 13, 73, 4, 194, 54, 67, 227, - 3, 83, 5, 215, 30, 45, 27, 11, 45, 24, 90, 80, 234, 30, 82, 242, 13, 67, - 194, 5, 77, 138, 1, 84, 186, 2, 75, 218, 2, 72, 99, 83, 6, 214, 50, 72, - 214, 3, 73, 207, 2, 65, 16, 80, 7, 65, 80, 89, 69, 79, 85, 78, 228, 20, - 5, 73, 89, 69, 79, 75, 131, 25, 72, 10, 234, 29, 82, 178, 15, 80, 30, 83, - 231, 3, 77, 11, 11, 45, 8, 158, 52, 75, 74, 80, 34, 84, 211, 2, 83, 15, - 11, 45, 12, 190, 51, 67, 42, 75, 74, 80, 34, 84, 242, 1, 72, 99, 83, 42, - 68, 6, 72, 73, 69, 85, 80, 72, 40, 4, 73, 69, 85, 80, 223, 53, 65, 7, 11, - 45, 4, 158, 51, 80, 147, 2, 72, 35, 11, 45, 32, 82, 83, 234, 20, 80, 214, - 7, 75, 162, 12, 67, 202, 6, 84, 226, 2, 78, 179, 2, 72, 14, 32, 3, 73, - 79, 83, 251, 3, 83, 13, 11, 45, 10, 242, 46, 84, 146, 2, 67, 42, 75, 75, - 80, 29, 11, 45, 26, 78, 75, 42, 83, 190, 44, 77, 154, 3, 67, 82, 78, 34, - 80, 34, 84, 243, 1, 72, 6, 170, 22, 65, 130, 19, 72, 135, 7, 73, 8, 40, - 4, 83, 65, 78, 71, 167, 198, 13, 73, 6, 206, 47, 75, 74, 80, 35, 84, 58, - 48, 3, 73, 79, 83, 217, 1, 4, 83, 65, 78, 71, 33, 11, 45, 30, 130, 1, 80, - 44, 2, 83, 83, 210, 22, 82, 210, 1, 75, 162, 12, 67, 194, 5, 77, 138, 1, - 84, 226, 2, 78, 178, 2, 72, 163, 162, 18, 73, 6, 184, 23, 4, 73, 69, 85, - 80, 179, 19, 72, 2, 233, 48, 3, 65, 78, 71, 26, 236, 17, 5, 67, 73, 69, - 85, 67, 172, 3, 4, 83, 73, 79, 83, 154, 1, 82, 186, 20, 84, 54, 89, 134, - 2, 75, 42, 78, 34, 80, 146, 2, 72, 163, 162, 18, 73, 16, 40, 5, 73, 75, - 69, 85, 84, 195, 41, 72, 15, 11, 45, 12, 226, 20, 82, 178, 19, 77, 154, - 3, 67, 42, 75, 74, 80, 243, 2, 83, 4, 150, 19, 83, 139, 22, 79, 2, 149, - 249, 8, 6, 76, 69, 32, 68, 79, 84, 216, 3, 92, 9, 79, 78, 71, 83, 69, 79, - 78, 71, 32, 165, 21, 9, 85, 78, 71, 83, 69, 79, 78, 71, 32, 154, 2, 226, - 1, 67, 80, 5, 72, 73, 69, 85, 72, 60, 5, 73, 69, 85, 78, 71, 46, 75, 220, - 1, 5, 77, 73, 69, 85, 77, 188, 1, 5, 78, 73, 69, 85, 78, 94, 80, 240, 2, - 5, 82, 73, 69, 85, 76, 190, 4, 83, 194, 3, 84, 213, 1, 2, 89, 69, 8, 36, - 4, 73, 69, 85, 67, 239, 30, 72, 7, 11, 45, 4, 162, 32, 83, 239, 7, 80, - 11, 11, 45, 8, 174, 16, 82, 178, 19, 77, 234, 3, 78, 35, 80, 9, 11, 45, - 6, 194, 17, 75, 57, 2, 83, 83, 28, 76, 7, 65, 80, 89, 69, 79, 85, 78, 40, - 5, 73, 89, 69, 79, 75, 215, 30, 72, 8, 130, 15, 82, 178, 15, 80, 131, 4, - 77, 19, 11, 45, 16, 166, 13, 75, 170, 1, 82, 42, 83, 224, 13, 2, 67, 72, - 146, 9, 78, 34, 80, 147, 2, 72, 27, 11, 45, 24, 74, 80, 30, 83, 134, 13, - 82, 242, 13, 67, 130, 9, 75, 42, 78, 179, 2, 72, 6, 174, 33, 73, 131, 6, - 65, 6, 40, 4, 83, 65, 78, 71, 159, 186, 13, 73, 4, 238, 35, 78, 147, 3, - 83, 21, 11, 45, 18, 174, 12, 82, 242, 13, 67, 202, 6, 84, 186, 2, 75, - 218, 2, 72, 62, 80, 39, 83, 36, 88, 6, 65, 78, 83, 73, 79, 83, 48, 6, 72, - 73, 69, 85, 80, 72, 53, 4, 73, 69, 85, 80, 7, 11, 45, 4, 236, 7, 2, 75, - 65, 195, 26, 80, 9, 11, 45, 6, 150, 11, 84, 234, 22, 80, 243, 2, 83, 23, - 11, 45, 20, 112, 5, 82, 73, 69, 85, 76, 24, 4, 83, 73, 79, 83, 134, 3, - 80, 246, 19, 67, 194, 5, 77, 170, 4, 84, 243, 1, 72, 5, 153, 3, 2, 45, - 80, 5, 221, 32, 2, 45, 84, 57, 11, 45, 54, 102, 75, 92, 5, 77, 73, 69, - 85, 77, 50, 80, 126, 83, 74, 84, 44, 2, 89, 69, 154, 28, 78, 179, 2, 72, - 10, 52, 5, 73, 89, 69, 79, 75, 190, 4, 65, 131, 19, 72, 7, 11, 45, 4, - 254, 32, 72, 99, 83, 9, 11, 45, 6, 130, 30, 75, 218, 2, 72, 99, 83, 14, - 48, 4, 73, 69, 85, 80, 174, 26, 72, 163, 6, 65, 11, 11, 45, 8, 42, 80, - 222, 29, 84, 242, 1, 72, 99, 83, 2, 243, 25, 72, 6, 40, 4, 83, 65, 78, - 71, 143, 179, 13, 73, 4, 182, 28, 75, 187, 3, 83, 6, 100, 5, 73, 75, 69, - 85, 84, 151, 25, 72, 6, 56, 9, 79, 82, 73, 78, 72, 73, 69, 85, 72, 191, - 3, 83, 5, 255, 29, 45, 52, 48, 3, 73, 79, 83, 161, 1, 4, 83, 65, 78, 71, - 25, 11, 45, 22, 82, 75, 162, 3, 82, 242, 13, 67, 198, 2, 80, 254, 2, 77, - 138, 1, 84, 147, 5, 72, 4, 22, 65, 135, 26, 73, 2, 237, 18, 6, 80, 89, - 69, 79, 85, 78, 28, 160, 1, 5, 82, 73, 69, 85, 76, 36, 6, 84, 73, 75, 69, - 85, 84, 16, 3, 89, 69, 83, 138, 19, 83, 178, 1, 77, 154, 3, 67, 42, 75, - 42, 78, 34, 80, 179, 164, 18, 73, 5, 17, 2, 45, 75, 2, 159, 17, 72, 5, - 255, 16, 45, 2, 239, 188, 18, 73, 20, 40, 5, 73, 75, 69, 85, 84, 155, 21, - 72, 19, 11, 45, 16, 58, 82, 42, 83, 42, 84, 162, 13, 67, 130, 9, 75, 75, - 80, 2, 17, 2, 73, 69, 2, 203, 163, 24, 85, 4, 21, 3, 73, 79, 83, 5, 223, - 1, 45, 2, 255, 19, 72, 18, 44, 6, 83, 73, 69, 85, 78, 71, 243, 19, 79, - 17, 11, 45, 14, 50, 75, 30, 83, 198, 17, 77, 154, 6, 72, 63, 80, 4, 166, - 14, 72, 135, 7, 73, 4, 26, 83, 191, 171, 13, 73, 2, 21, 3, 65, 78, 71, 2, - 207, 20, 75, 190, 1, 122, 65, 118, 69, 134, 1, 73, 92, 7, 83, 83, 65, 78, - 71, 65, 82, 106, 79, 138, 1, 85, 102, 89, 174, 15, 87, 231, 145, 10, 70, - 23, 48, 4, 82, 65, 69, 65, 98, 45, 239, 170, 25, 69, 13, 11, 45, 10, 142, - 226, 22, 69, 178, 201, 2, 65, 2, 73, 3, 85, 25, 18, 79, 55, 85, 9, 11, - 45, 6, 130, 134, 25, 69, 234, 36, 79, 3, 85, 15, 11, 45, 12, 170, 9, 69, - 142, 161, 25, 65, 2, 79, 3, 85, 31, 11, 45, 28, 66, 65, 34, 89, 166, 1, - 79, 142, 131, 25, 69, 234, 36, 73, 3, 85, 5, 11, 82, 2, 171, 149, 18, 65, - 14, 50, 65, 182, 223, 22, 69, 178, 201, 2, 79, 3, 85, 7, 238, 137, 25, - 45, 247, 30, 69, 23, 26, 45, 171, 168, 25, 69, 18, 50, 79, 22, 89, 178, - 222, 22, 69, 179, 201, 2, 85, 5, 155, 148, 25, 45, 8, 174, 222, 22, 69, - 147, 137, 2, 65, 17, 11, 45, 14, 158, 19, 89, 130, 163, 5, 73, 180, 132, - 13, 3, 69, 79, 45, 190, 172, 6, 65, 163, 64, 85, 62, 42, 65, 70, 69, 66, - 73, 22, 79, 107, 85, 11, 26, 45, 147, 166, 25, 69, 6, 154, 135, 25, 89, - 246, 30, 79, 3, 85, 11, 11, 79, 9, 11, 45, 6, 150, 163, 25, 89, 186, 2, - 79, 3, 85, 5, 191, 128, 25, 45, 19, 11, 45, 16, 58, 89, 174, 228, 24, 65, - 174, 33, 69, 246, 30, 73, 3, 79, 6, 170, 228, 24, 65, 175, 33, 69, 21, - 11, 45, 18, 142, 16, 89, 226, 202, 22, 69, 146, 137, 2, 65, 162, 64, 73, - 2, 79, 3, 85, 186, 1, 226, 1, 65, 46, 67, 54, 69, 30, 73, 22, 75, 188, 1, - 5, 77, 73, 69, 85, 77, 64, 5, 78, 73, 69, 85, 78, 70, 80, 168, 1, 5, 82, - 73, 69, 85, 76, 254, 1, 84, 90, 83, 246, 2, 87, 50, 89, 150, 1, 72, 202, - 213, 24, 79, 163, 64, 85, 9, 156, 13, 3, 82, 65, 69, 207, 148, 25, 69, 4, - 22, 72, 207, 8, 73, 2, 241, 254, 24, 2, 73, 69, 7, 138, 161, 25, 79, 3, - 85, 5, 179, 173, 18, 69, 14, 56, 7, 65, 80, 89, 69, 79, 85, 78, 106, 72, - 155, 3, 73, 8, 30, 80, 30, 83, 231, 3, 77, 4, 190, 4, 72, 215, 3, 73, 2, - 25, 4, 83, 65, 78, 71, 2, 207, 7, 80, 2, 241, 60, 2, 73, 69, 9, 11, 45, - 6, 22, 80, 247, 9, 83, 4, 142, 7, 73, 207, 2, 65, 13, 11, 45, 10, 234, 5, - 67, 146, 1, 84, 242, 1, 72, 62, 80, 39, 83, 20, 48, 4, 73, 69, 85, 80, - 170, 2, 72, 163, 6, 65, 17, 11, 45, 14, 42, 83, 186, 2, 84, 146, 2, 67, - 43, 75, 6, 21, 3, 73, 79, 83, 7, 11, 45, 4, 202, 4, 75, 107, 84, 27, 11, - 45, 24, 68, 2, 75, 73, 34, 77, 34, 80, 106, 84, 54, 89, 222, 4, 72, 99, - 83, 4, 149, 1, 4, 89, 69, 79, 75, 2, 11, 73, 2, 207, 240, 23, 69, 8, 30, - 72, 34, 73, 131, 6, 65, 2, 197, 232, 18, 3, 73, 69, 85, 4, 21, 3, 69, 85, - 80, 5, 243, 5, 45, 4, 22, 72, 151, 3, 73, 2, 241, 245, 21, 2, 73, 69, 2, - 17, 2, 69, 79, 2, 167, 4, 82, 28, 44, 3, 73, 79, 83, 57, 4, 83, 65, 78, - 71, 13, 11, 45, 10, 122, 67, 42, 75, 42, 78, 34, 80, 35, 84, 16, 78, 67, - 42, 75, 42, 78, 34, 80, 34, 84, 242, 1, 72, 98, 83, 195, 161, 18, 73, 2, - 11, 73, 2, 201, 238, 23, 2, 69, 85, 2, 11, 73, 2, 209, 238, 24, 2, 89, - 69, 2, 11, 73, 2, 219, 151, 24, 69, 2, 11, 73, 2, 247, 161, 24, 69, 2, - 11, 73, 2, 11, 75, 2, 239, 157, 24, 69, 10, 250, 205, 22, 69, 146, 137, - 2, 65, 163, 64, 73, 34, 58, 69, 206, 1, 79, 62, 85, 154, 212, 24, 65, - 163, 64, 73, 13, 42, 79, 73, 6, 83, 73, 69, 85, 78, 71, 5, 11, 82, 2, 17, - 2, 73, 78, 2, 11, 72, 2, 157, 239, 9, 2, 73, 69, 7, 11, 45, 4, 18, 80, - 39, 83, 2, 11, 65, 2, 11, 78, 2, 11, 83, 2, 155, 147, 13, 73, 9, 11, 45, - 6, 26, 89, 207, 148, 25, 73, 4, 171, 212, 24, 65, 9, 11, 45, 6, 26, 89, - 147, 148, 25, 73, 4, 223, 202, 22, 69, 24, 138, 136, 11, 84, 230, 152, - 12, 70, 30, 83, 182, 87, 78, 14, 79, 227, 112, 69, 100, 156, 1, 7, 76, - 69, 84, 84, 69, 82, 32, 196, 2, 5, 77, 65, 82, 75, 32, 72, 5, 83, 73, 71, - 78, 32, 224, 159, 2, 6, 86, 79, 87, 69, 76, 32, 159, 251, 20, 68, 58, - 202, 1, 68, 34, 75, 246, 251, 20, 84, 178, 55, 82, 238, 223, 1, 78, 214, - 181, 1, 83, 138, 69, 66, 2, 67, 2, 70, 2, 71, 2, 72, 2, 74, 2, 76, 2, 77, - 2, 80, 2, 86, 2, 87, 2, 89, 2, 90, 187, 2, 65, 4, 138, 142, 25, 68, 187, - 2, 65, 8, 56, 5, 73, 78, 78, 65, 32, 178, 141, 25, 72, 187, 2, 65, 4, - 174, 141, 25, 87, 3, 89, 4, 136, 213, 21, 6, 78, 65, 32, 75, 72, 79, 237, - 186, 2, 3, 83, 65, 75, 8, 52, 2, 84, 65, 213, 254, 22, 5, 72, 65, 82, 66, - 65, 6, 42, 72, 174, 155, 20, 83, 191, 240, 4, 78, 2, 135, 236, 24, 65, - 42, 62, 76, 152, 243, 18, 6, 83, 73, 71, 78, 32, 80, 247, 1, 86, 36, 33, - 6, 69, 84, 84, 69, 82, 32, 36, 162, 151, 21, 78, 206, 243, 3, 66, 2, 68, - 2, 71, 2, 72, 2, 75, 2, 76, 2, 77, 2, 80, 2, 82, 2, 83, 2, 84, 2, 87, 2, - 89, 186, 2, 65, 2, 73, 3, 85, 2, 211, 251, 23, 69, 4, 210, 196, 23, 68, - 163, 199, 1, 80, 54, 52, 5, 67, 72, 73, 78, 71, 41, 4, 82, 65, 78, 32, 2, - 17, 2, 32, 67, 2, 243, 216, 23, 72, 52, 52, 7, 76, 69, 84, 84, 69, 82, - 32, 223, 182, 6, 78, 42, 218, 1, 65, 186, 173, 11, 90, 238, 46, 84, 146, - 120, 76, 50, 81, 60, 6, 68, 65, 76, 69, 84, 72, 214, 169, 4, 71, 122, 83, - 66, 89, 198, 207, 1, 72, 234, 5, 75, 174, 81, 66, 170, 225, 4, 78, 134, - 2, 87, 218, 103, 80, 171, 4, 77, 4, 222, 254, 16, 76, 159, 186, 7, 89, - 174, 9, 210, 1, 65, 242, 32, 66, 130, 33, 76, 200, 1, 16, 78, 84, 65, 73, - 71, 65, 78, 65, 32, 76, 69, 84, 84, 69, 82, 32, 174, 12, 82, 120, 11, 88, - 65, 71, 82, 65, 77, 32, 70, 79, 82, 32, 165, 181, 24, 4, 68, 71, 69, 72, - 214, 1, 42, 68, 98, 82, 201, 1, 3, 86, 89, 32, 6, 44, 5, 83, 84, 79, 78, - 69, 159, 217, 23, 80, 5, 137, 223, 2, 7, 32, 71, 82, 65, 86, 69, 89, 12, - 32, 2, 84, 32, 251, 155, 17, 45, 10, 60, 5, 87, 73, 84, 72, 32, 198, 163, - 12, 68, 239, 158, 9, 72, 6, 76, 9, 84, 73, 80, 32, 79, 78, 32, 84, 72, - 238, 242, 12, 82, 243, 244, 10, 65, 2, 215, 209, 24, 69, 196, 1, 134, 2, - 65, 202, 1, 66, 230, 2, 67, 154, 3, 68, 162, 1, 69, 186, 3, 70, 94, 72, - 62, 76, 222, 1, 77, 110, 79, 162, 1, 82, 142, 2, 83, 228, 1, 3, 78, 79, - 82, 198, 1, 84, 128, 2, 2, 85, 80, 174, 1, 87, 162, 140, 14, 73, 222, - 243, 3, 80, 130, 142, 4, 86, 227, 78, 71, 12, 108, 17, 82, 82, 79, 87, - 32, 83, 72, 65, 70, 84, 32, 87, 73, 68, 84, 72, 32, 158, 163, 18, 77, - 207, 198, 4, 83, 8, 36, 3, 79, 78, 69, 239, 157, 23, 84, 7, 11, 32, 4, - 202, 238, 13, 84, 251, 139, 9, 72, 14, 48, 4, 65, 76, 76, 79, 21, 4, 76, - 65, 67, 75, 2, 191, 231, 5, 84, 12, 30, 32, 153, 1, 2, 45, 70, 6, 52, 7, - 67, 85, 82, 86, 69, 68, 32, 239, 247, 23, 72, 4, 40, 4, 68, 79, 87, 78, - 1, 2, 85, 80, 2, 201, 220, 23, 8, 87, 65, 82, 68, 83, 32, 65, 78, 6, 45, - 9, 69, 65, 84, 72, 69, 82, 69, 68, 32, 6, 134, 212, 13, 83, 174, 173, 3, - 78, 215, 218, 6, 82, 14, 116, 2, 72, 69, 52, 5, 73, 82, 67, 76, 69, 253, - 224, 17, 14, 79, 78, 67, 65, 86, 69, 45, 80, 79, 73, 78, 84, 69, 68, 4, - 172, 213, 20, 4, 86, 82, 79, 78, 255, 225, 2, 67, 9, 64, 6, 32, 87, 73, - 84, 72, 32, 161, 227, 22, 4, 68, 32, 83, 65, 4, 52, 7, 83, 84, 82, 79, - 75, 69, 32, 163, 253, 4, 67, 2, 29, 5, 65, 78, 68, 32, 84, 2, 11, 87, 2, - 11, 79, 2, 21, 3, 32, 68, 79, 2, 11, 84, 2, 199, 253, 23, 83, 14, 52, 7, - 65, 83, 72, 69, 68, 32, 84, 18, 73, 31, 79, 2, 175, 16, 82, 2, 137, 154, - 19, 2, 86, 73, 10, 192, 16, 3, 87, 78, 87, 222, 139, 14, 85, 191, 184, 4, - 76, 16, 120, 5, 73, 71, 72, 84, 32, 156, 2, 16, 88, 67, 76, 65, 77, 65, - 84, 73, 79, 78, 32, 77, 65, 82, 75, 32, 175, 209, 18, 81, 10, 40, 2, 80, - 79, 126, 84, 131, 223, 22, 83, 6, 33, 6, 73, 78, 84, 69, 68, 32, 6, 170, - 191, 16, 80, 128, 158, 6, 11, 82, 69, 67, 84, 73, 76, 73, 78, 69, 65, 82, - 23, 66, 2, 169, 223, 22, 24, 69, 65, 82, 68, 82, 79, 80, 45, 83, 80, 79, - 75, 69, 68, 32, 80, 82, 79, 80, 69, 76, 76, 69, 82, 4, 210, 224, 23, 83, - 227, 81, 79, 6, 44, 5, 79, 85, 82, 32, 66, 231, 252, 4, 73, 2, 157, 131, - 11, 6, 65, 76, 76, 79, 79, 78, 4, 214, 191, 17, 79, 161, 233, 5, 6, 69, - 65, 82, 84, 32, 69, 20, 74, 65, 44, 3, 69, 70, 84, 28, 2, 79, 87, 241, - 247, 4, 3, 73, 71, 65, 4, 208, 222, 21, 2, 82, 71, 211, 209, 1, 84, 8, - 254, 3, 45, 195, 6, 87, 6, 26, 32, 239, 147, 10, 69, 4, 178, 150, 14, 68, - 25, 4, 83, 73, 78, 71, 4, 56, 8, 85, 76, 84, 73, 80, 76, 73, 67, 143, - 192, 21, 73, 2, 25, 4, 65, 84, 73, 79, 2, 211, 217, 5, 78, 6, 200, 143, - 6, 9, 80, 69, 78, 32, 67, 69, 78, 84, 82, 172, 176, 10, 13, 86, 65, 76, - 32, 87, 73, 84, 72, 32, 79, 86, 65, 76, 213, 151, 6, 5, 85, 84, 76, 73, - 78, 12, 76, 4, 73, 71, 72, 84, 233, 205, 23, 9, 79, 85, 78, 68, 45, 84, - 73, 80, 80, 10, 62, 45, 109, 11, 87, 65, 82, 68, 83, 32, 65, 82, 82, 79, - 87, 4, 69, 15, 80, 79, 73, 78, 84, 73, 78, 71, 32, 65, 78, 71, 76, 69, - 32, 4, 138, 233, 6, 66, 255, 169, 7, 81, 7, 139, 6, 32, 26, 106, 65, 78, - 73, 44, 2, 79, 85, 240, 154, 14, 7, 67, 82, 73, 80, 84, 32, 76, 193, 139, - 1, 3, 80, 65, 82, 4, 132, 146, 14, 10, 78, 83, 45, 83, 69, 82, 73, 70, - 32, 73, 175, 195, 8, 76, 8, 240, 143, 14, 2, 78, 71, 183, 194, 8, 88, 10, - 21, 3, 84, 72, 32, 10, 60, 5, 69, 65, 83, 84, 32, 29, 6, 87, 69, 83, 84, - 32, 80, 6, 26, 80, 191, 207, 23, 65, 4, 41, 8, 79, 73, 78, 84, 73, 78, - 71, 32, 4, 226, 242, 16, 86, 255, 202, 6, 66, 12, 88, 9, 69, 65, 82, 68, - 82, 79, 80, 45, 83, 130, 1, 82, 197, 229, 6, 4, 87, 69, 76, 86, 6, 64, 6, - 80, 79, 75, 69, 68, 32, 229, 199, 23, 4, 72, 65, 78, 75, 4, 192, 210, 22, - 8, 80, 73, 78, 87, 72, 69, 69, 76, 27, 65, 2, 193, 3, 5, 73, 65, 78, 71, - 76, 6, 26, 87, 219, 137, 10, 80, 4, 53, 11, 65, 82, 68, 83, 32, 65, 82, - 82, 79, 87, 32, 4, 29, 5, 87, 73, 84, 72, 32, 4, 128, 134, 20, 5, 76, 65, - 82, 71, 69, 179, 243, 1, 69, 12, 76, 5, 72, 73, 84, 69, 32, 164, 1, 2, - 73, 68, 253, 252, 22, 3, 69, 68, 71, 8, 64, 6, 83, 81, 85, 65, 82, 69, - 158, 219, 17, 68, 187, 183, 5, 67, 5, 145, 178, 23, 19, 32, 67, 79, 78, - 84, 65, 73, 78, 73, 78, 71, 32, 66, 76, 65, 67, 75, 32, 86, 2, 157, 247, - 20, 2, 69, 45, 142, 2, 40, 4, 82, 69, 87, 32, 195, 229, 24, 69, 140, 2, - 112, 7, 65, 67, 67, 69, 78, 84, 32, 142, 8, 76, 164, 14, 5, 77, 65, 82, - 75, 32, 114, 80, 201, 172, 21, 2, 89, 79, 60, 128, 2, 9, 65, 84, 78, 65, - 72, 32, 72, 65, 70, 22, 68, 36, 3, 71, 69, 82, 74, 77, 124, 2, 80, 65, - 28, 4, 69, 84, 78, 65, 20, 2, 81, 65, 58, 83, 58, 84, 156, 1, 2, 89, 69, - 78, 90, 148, 169, 8, 3, 82, 69, 86, 242, 141, 15, 79, 245, 148, 1, 3, 73, - 76, 85, 2, 219, 161, 18, 85, 4, 182, 138, 19, 69, 171, 149, 5, 65, 6, 32, - 3, 69, 83, 72, 179, 28, 83, 5, 165, 224, 6, 4, 32, 77, 85, 81, 8, 84, 5, - 69, 82, 75, 72, 65, 236, 242, 17, 2, 85, 78, 153, 45, 5, 65, 72, 65, 80, - 65, 5, 197, 229, 19, 4, 32, 75, 69, 70, 4, 26, 83, 195, 162, 24, 90, 2, - 223, 187, 24, 72, 4, 200, 155, 24, 6, 82, 78, 69, 89, 32, 80, 191, 35, - 68, 4, 182, 24, 69, 161, 229, 22, 6, 72, 65, 76, 83, 72, 69, 8, 38, 69, - 217, 225, 22, 3, 73, 80, 69, 6, 48, 6, 76, 73, 83, 72, 65, 32, 239, 223, - 11, 86, 4, 228, 170, 22, 3, 81, 69, 84, 205, 145, 2, 4, 71, 69, 68, 79, - 4, 228, 208, 8, 10, 82, 65, 72, 32, 66, 69, 78, 32, 89, 79, 155, 217, 2, - 84, 8, 18, 65, 95, 73, 6, 40, 4, 81, 69, 70, 32, 219, 130, 6, 82, 4, 222, - 134, 11, 81, 149, 193, 12, 3, 71, 65, 68, 2, 231, 163, 24, 78, 150, 1, - 76, 6, 69, 84, 84, 69, 82, 32, 201, 11, 8, 73, 71, 65, 84, 85, 82, 69, - 32, 140, 1, 134, 3, 65, 204, 1, 3, 66, 69, 84, 0, 3, 75, 65, 70, 0, 2, - 80, 69, 68, 6, 70, 73, 78, 65, 76, 32, 92, 2, 81, 79, 16, 2, 72, 69, 52, - 2, 78, 85, 0, 4, 90, 65, 89, 73, 18, 83, 48, 3, 82, 69, 83, 170, 1, 84, - 52, 4, 68, 65, 76, 69, 12, 5, 71, 73, 77, 69, 76, 0, 5, 76, 65, 77, 69, - 68, 0, 3, 77, 69, 77, 48, 3, 86, 65, 86, 80, 5, 87, 73, 68, 69, 32, 153, - 1, 3, 89, 79, 68, 14, 26, 76, 239, 216, 23, 89, 12, 64, 2, 69, 70, 73, - 10, 84, 69, 82, 78, 65, 84, 73, 86, 69, 32, 9, 33, 6, 32, 87, 73, 84, 72, - 32, 6, 130, 13, 77, 130, 1, 80, 35, 81, 4, 174, 206, 16, 65, 131, 161, 1, - 80, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 138, 15, 82, 171, 225, 13, 68, - 14, 88, 2, 75, 65, 236, 2, 2, 80, 69, 148, 154, 1, 2, 84, 83, 194, 184, - 22, 78, 135, 110, 77, 4, 235, 2, 70, 7, 244, 10, 5, 32, 87, 73, 84, 72, - 235, 202, 24, 84, 4, 167, 2, 78, 16, 44, 4, 65, 77, 69, 75, 17, 3, 72, - 73, 78, 4, 231, 1, 72, 13, 33, 6, 32, 87, 73, 84, 72, 32, 10, 40, 6, 68, - 65, 71, 69, 83, 72, 39, 83, 7, 33, 6, 32, 65, 78, 68, 32, 83, 4, 142, - 130, 6, 72, 155, 193, 2, 73, 12, 50, 69, 12, 2, 65, 86, 1, 4, 83, 65, 68, - 73, 4, 11, 84, 5, 201, 236, 13, 7, 32, 87, 73, 84, 72, 32, 68, 7, 33, 6, - 32, 87, 73, 84, 72, 32, 4, 208, 253, 1, 2, 72, 79, 167, 238, 11, 68, 16, - 174, 2, 76, 178, 207, 8, 65, 230, 191, 2, 84, 158, 218, 2, 82, 156, 132, - 9, 2, 68, 65, 218, 96, 75, 222, 106, 72, 169, 4, 7, 70, 73, 78, 65, 76, - 32, 77, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 172, 7, 2, 72, 73, 227, 226, - 13, 68, 10, 72, 6, 65, 76, 69, 70, 32, 76, 29, 8, 89, 73, 68, 68, 73, 83, - 72, 32, 2, 185, 187, 19, 2, 65, 77, 8, 120, 7, 68, 79, 85, 66, 76, 69, - 32, 232, 4, 9, 89, 79, 68, 32, 89, 79, 68, 32, 80, 169, 143, 21, 5, 86, - 65, 86, 32, 89, 4, 250, 141, 11, 86, 151, 134, 10, 89, 6, 80, 3, 76, 79, - 87, 0, 3, 85, 80, 80, 149, 249, 22, 6, 77, 65, 83, 79, 82, 65, 2, 145, - 186, 23, 2, 69, 82, 50, 84, 5, 79, 73, 78, 84, 32, 225, 5, 11, 85, 78, - 67, 84, 85, 65, 84, 73, 79, 78, 32, 38, 228, 1, 9, 68, 65, 71, 69, 83, - 72, 32, 79, 82, 46, 72, 106, 80, 162, 1, 81, 86, 82, 22, 83, 148, 213, 9, - 2, 84, 83, 148, 153, 11, 17, 74, 85, 68, 69, 79, 45, 83, 80, 65, 78, 73, - 83, 72, 32, 86, 65, 82, 189, 147, 3, 3, 77, 69, 84, 2, 17, 2, 32, 77, 2, - 197, 1, 2, 65, 80, 12, 60, 5, 65, 84, 65, 70, 32, 102, 73, 33, 4, 79, 76, - 65, 77, 6, 38, 80, 34, 81, 141, 2, 2, 83, 69, 2, 11, 65, 2, 199, 219, 17, - 84, 2, 233, 192, 23, 2, 65, 77, 2, 11, 82, 2, 243, 229, 13, 73, 5, 181, - 136, 11, 12, 32, 72, 65, 83, 69, 82, 32, 70, 79, 82, 32, 86, 6, 52, 5, - 65, 77, 65, 84, 83, 221, 190, 11, 2, 85, 66, 5, 217, 241, 10, 2, 32, 81, - 2, 211, 228, 6, 65, 8, 34, 69, 22, 72, 215, 182, 8, 73, 2, 155, 178, 23, - 71, 4, 210, 182, 8, 73, 147, 210, 7, 69, 12, 152, 1, 3, 71, 69, 82, 60, - 3, 80, 65, 83, 20, 7, 83, 79, 70, 32, 80, 65, 83, 216, 136, 22, 7, 78, - 85, 78, 32, 72, 65, 70, 253, 186, 1, 3, 77, 65, 81, 4, 26, 83, 179, 218, - 22, 69, 2, 229, 194, 23, 3, 72, 65, 89, 2, 255, 225, 13, 69, 2, 235, 225, - 13, 85, 8, 114, 77, 176, 149, 12, 15, 76, 83, 67, 72, 82, 69, 73, 66, 69, - 82, 32, 80, 65, 85, 83, 229, 227, 5, 3, 73, 67, 79, 4, 196, 225, 5, 12, - 69, 84, 32, 87, 73, 84, 72, 32, 87, 72, 73, 84, 255, 204, 17, 32, 188, 4, - 164, 1, 2, 65, 45, 50, 72, 70, 75, 230, 1, 77, 114, 78, 146, 2, 82, 66, - 83, 154, 1, 84, 226, 1, 87, 62, 89, 110, 69, 234, 244, 8, 85, 150, 170, - 5, 79, 139, 192, 3, 73, 8, 134, 163, 24, 87, 246, 30, 49, 2, 50, 3, 51, - 72, 166, 6, 79, 250, 194, 8, 65, 230, 223, 5, 85, 166, 116, 69, 3, 73, - 74, 72, 2, 65, 45, 104, 2, 79, 45, 178, 4, 73, 226, 3, 69, 163, 147, 15, - 85, 24, 250, 233, 11, 49, 238, 191, 12, 75, 214, 22, 50, 2, 51, 2, 52, 2, - 53, 2, 54, 2, 55, 2, 56, 3, 57, 8, 250, 171, 24, 75, 218, 19, 49, 2, 50, - 3, 51, 54, 68, 2, 69, 45, 154, 7, 79, 162, 147, 15, 65, 2, 73, 231, 203, - 2, 85, 6, 162, 188, 24, 77, 186, 2, 49, 3, 50, 68, 116, 2, 69, 45, 72, 2, - 73, 45, 246, 2, 65, 166, 247, 8, 79, 150, 170, 5, 85, 225, 146, 6, 6, 45, - 77, 85, 45, 77, 79, 14, 198, 158, 24, 75, 246, 30, 49, 2, 50, 2, 51, 2, - 52, 2, 53, 3, 54, 16, 158, 166, 24, 84, 214, 22, 49, 2, 50, 2, 51, 2, 52, - 2, 53, 2, 54, 3, 55, 54, 222, 4, 79, 2, 85, 162, 147, 15, 73, 230, 203, - 2, 65, 3, 69, 68, 62, 65, 2, 85, 226, 3, 73, 234, 244, 8, 69, 187, 158, - 6, 79, 16, 11, 45, 16, 150, 187, 24, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, - 54, 2, 55, 3, 56, 64, 74, 69, 20, 2, 79, 45, 72, 2, 85, 45, 130, 149, 15, - 73, 231, 203, 2, 65, 18, 223, 249, 18, 45, 14, 178, 183, 24, 82, 186, 2, - 49, 2, 50, 2, 51, 2, 52, 2, 53, 3, 54, 10, 174, 154, 24, 84, 246, 30, 49, - 2, 50, 2, 51, 3, 52, 42, 142, 246, 8, 65, 2, 73, 186, 158, 6, 79, 231, - 203, 2, 69, 32, 40, 2, 65, 45, 66, 79, 135, 223, 17, 85, 12, 142, 153, - 24, 89, 246, 30, 49, 2, 50, 2, 51, 2, 52, 3, 53, 12, 11, 45, 12, 182, - 183, 24, 49, 2, 50, 2, 51, 2, 52, 2, 53, 3, 54, 4, 240, 170, 8, 21, 77, - 73, 84, 73, 65, 78, 32, 67, 79, 78, 74, 85, 71, 65, 84, 69, 32, 77, 65, - 84, 82, 139, 140, 16, 66, 128, 1, 210, 2, 65, 110, 66, 144, 1, 2, 67, 79, - 94, 68, 198, 2, 70, 66, 71, 40, 4, 72, 79, 76, 68, 164, 1, 2, 73, 78, - 116, 2, 77, 79, 58, 79, 122, 80, 100, 2, 82, 69, 66, 83, 238, 1, 84, 210, - 5, 87, 148, 160, 15, 4, 76, 73, 77, 73, 140, 191, 5, 11, 89, 79, 85, 84, - 72, 70, 85, 76, 32, 70, 79, 137, 177, 3, 9, 69, 78, 84, 72, 85, 83, 73, - 65, 83, 6, 76, 3, 80, 80, 82, 124, 4, 70, 84, 69, 82, 185, 161, 19, 4, - 66, 85, 78, 68, 2, 177, 144, 24, 2, 79, 65, 6, 92, 5, 69, 70, 79, 82, 69, - 156, 213, 3, 6, 73, 84, 73, 78, 71, 32, 1, 4, 82, 69, 65, 75, 2, 141, - 225, 23, 7, 32, 67, 79, 77, 80, 76, 69, 6, 26, 78, 179, 152, 19, 77, 4, - 180, 202, 20, 4, 84, 69, 77, 80, 209, 213, 2, 3, 70, 76, 73, 14, 110, 69, - 78, 73, 202, 156, 19, 85, 241, 245, 2, 15, 65, 82, 75, 69, 78, 73, 78, - 71, 32, 79, 70, 32, 84, 72, 69, 6, 218, 152, 19, 67, 192, 6, 2, 76, 73, - 149, 205, 4, 5, 86, 69, 76, 79, 80, 4, 248, 142, 19, 21, 70, 70, 73, 67, - 85, 76, 84, 89, 32, 65, 84, 32, 84, 72, 69, 32, 66, 69, 71, 73, 78, 169, - 253, 2, 4, 83, 80, 69, 82, 4, 216, 147, 19, 2, 79, 76, 165, 197, 4, 5, - 69, 76, 76, 79, 87, 12, 36, 5, 65, 84, 72, 69, 82, 35, 82, 2, 165, 139, - 15, 3, 73, 78, 71, 10, 40, 4, 69, 65, 84, 32, 227, 239, 23, 65, 8, 22, - 80, 215, 5, 84, 6, 22, 79, 151, 5, 82, 4, 172, 2, 2, 83, 83, 147, 236, - 23, 87, 8, 50, 78, 202, 148, 19, 67, 217, 5, 3, 70, 76, 85, 4, 156, 154, - 19, 2, 79, 67, 197, 236, 1, 5, 69, 82, 32, 84, 82, 4, 172, 187, 22, 3, - 68, 69, 83, 145, 62, 3, 85, 84, 72, 6, 26, 66, 37, 2, 80, 80, 2, 221, - 217, 23, 4, 83, 84, 82, 85, 4, 26, 82, 183, 216, 23, 79, 2, 133, 135, 22, - 2, 69, 83, 6, 136, 144, 15, 9, 85, 83, 72, 73, 78, 71, 32, 85, 80, 192, - 137, 2, 3, 82, 79, 71, 143, 211, 6, 69, 6, 26, 84, 203, 132, 19, 86, 4, - 250, 149, 19, 85, 171, 137, 4, 82, 8, 132, 1, 5, 77, 65, 76, 76, 32, 224, - 171, 21, 6, 84, 65, 78, 68, 83, 84, 185, 244, 1, 11, 80, 76, 73, 84, 84, - 73, 78, 71, 32, 65, 80, 4, 24, 2, 80, 82, 43, 84, 2, 217, 150, 19, 5, 69, - 80, 79, 78, 68, 2, 11, 65, 2, 223, 213, 23, 77, 30, 36, 3, 72, 69, 32, - 227, 223, 17, 82, 28, 186, 2, 65, 130, 1, 67, 132, 1, 3, 70, 65, 77, 20, - 9, 82, 69, 67, 69, 80, 84, 73, 86, 69, 30, 87, 172, 22, 12, 77, 65, 82, - 82, 89, 73, 78, 71, 32, 77, 65, 73, 184, 150, 5, 6, 71, 69, 78, 84, 76, - 69, 164, 223, 10, 13, 75, 69, 69, 80, 73, 78, 71, 32, 83, 84, 73, 76, 76, - 173, 238, 3, 7, 74, 79, 89, 79, 85, 83, 32, 6, 58, 82, 161, 180, 11, 8, - 66, 89, 83, 77, 65, 76, 32, 87, 4, 196, 183, 20, 8, 79, 85, 83, 73, 78, - 71, 32, 84, 163, 218, 3, 77, 6, 188, 131, 1, 2, 65, 85, 228, 178, 19, 9, - 82, 69, 65, 84, 73, 86, 69, 32, 72, 161, 212, 1, 9, 76, 73, 78, 71, 73, - 78, 71, 32, 70, 2, 183, 254, 23, 73, 2, 233, 180, 20, 2, 32, 69, 4, 142, - 151, 22, 69, 189, 204, 1, 5, 65, 78, 68, 69, 82, 4, 242, 234, 6, 65, 205, - 162, 6, 14, 79, 82, 75, 32, 79, 78, 32, 84, 72, 69, 32, 68, 69, 67, 222, - 1, 236, 1, 2, 71, 72, 180, 2, 7, 82, 65, 71, 65, 78, 65, 32, 212, 4, 7, - 83, 84, 79, 82, 73, 67, 32, 212, 190, 15, 7, 78, 68, 85, 32, 84, 69, 77, - 240, 33, 4, 75, 73, 78, 71, 218, 249, 1, 66, 169, 180, 4, 8, 80, 80, 79, - 80, 79, 84, 65, 77, 12, 18, 32, 119, 45, 6, 216, 138, 5, 2, 66, 82, 184, - 243, 16, 6, 86, 79, 76, 84, 65, 71, 217, 49, 9, 79, 67, 84, 69, 84, 32, - 80, 82, 69, 6, 92, 11, 83, 80, 69, 69, 68, 32, 84, 82, 65, 73, 78, 173, - 203, 5, 6, 72, 69, 69, 76, 69, 68, 5, 157, 185, 11, 14, 32, 87, 73, 84, - 72, 32, 66, 85, 76, 76, 69, 84, 32, 78, 200, 1, 112, 9, 68, 73, 71, 82, - 65, 80, 72, 32, 89, 20, 7, 76, 69, 84, 84, 69, 82, 32, 154, 173, 1, 86, - 191, 199, 20, 73, 2, 183, 175, 17, 79, 194, 1, 194, 1, 65, 74, 83, 138, - 164, 1, 66, 162, 3, 78, 150, 2, 68, 2, 71, 2, 72, 2, 75, 2, 77, 2, 80, 2, - 82, 2, 84, 2, 90, 126, 87, 46, 89, 150, 201, 22, 86, 234, 36, 69, 2, 73, - 2, 79, 3, 85, 7, 37, 7, 82, 67, 72, 65, 73, 67, 32, 4, 150, 244, 23, 87, - 151, 14, 89, 42, 76, 5, 77, 65, 76, 76, 32, 146, 152, 24, 65, 2, 69, 2, - 73, 2, 79, 3, 85, 32, 230, 169, 1, 87, 46, 89, 150, 176, 5, 75, 130, 153, - 17, 84, 234, 36, 65, 2, 69, 2, 73, 2, 79, 3, 85, 2, 235, 182, 8, 83, 108, - 166, 1, 76, 52, 3, 78, 69, 89, 46, 82, 146, 7, 84, 138, 1, 85, 206, 192, - 16, 83, 178, 219, 2, 67, 220, 198, 3, 6, 77, 79, 84, 72, 69, 84, 134, - 167, 1, 79, 155, 3, 80, 6, 236, 144, 16, 4, 76, 79, 87, 32, 255, 132, 8, - 69, 4, 150, 163, 22, 66, 233, 161, 1, 2, 32, 80, 66, 60, 8, 73, 90, 79, - 78, 84, 65, 76, 32, 153, 6, 2, 83, 69, 60, 218, 1, 66, 110, 76, 152, 1, - 17, 79, 78, 69, 32, 69, 73, 71, 72, 84, 72, 32, 66, 76, 79, 67, 75, 45, - 88, 10, 83, 67, 65, 78, 32, 76, 73, 78, 69, 45, 46, 84, 146, 232, 21, 67, - 42, 69, 230, 6, 77, 150, 1, 82, 247, 2, 90, 6, 44, 5, 76, 65, 67, 75, 32, - 231, 217, 23, 65, 4, 38, 79, 217, 215, 22, 3, 72, 69, 88, 2, 203, 215, - 22, 67, 10, 40, 4, 73, 78, 69, 32, 247, 237, 21, 65, 8, 44, 5, 87, 73, - 84, 72, 32, 155, 238, 21, 69, 6, 26, 84, 195, 239, 21, 70, 4, 226, 239, - 21, 72, 243, 91, 73, 14, 184, 229, 16, 3, 49, 51, 53, 178, 171, 7, 50, 2, - 51, 2, 52, 2, 53, 2, 54, 3, 55, 8, 146, 144, 24, 49, 2, 51, 2, 55, 3, 57, - 10, 32, 2, 65, 66, 199, 242, 21, 82, 8, 26, 85, 199, 241, 21, 32, 6, 33, - 6, 76, 65, 84, 73, 79, 78, 7, 11, 32, 4, 128, 197, 9, 8, 87, 73, 84, 72, - 32, 74, 85, 83, 223, 148, 14, 83, 7, 11, 32, 4, 128, 195, 7, 2, 82, 65, - 159, 142, 16, 70, 10, 26, 32, 147, 130, 23, 69, 8, 86, 80, 232, 253, 18, - 5, 66, 69, 86, 69, 82, 144, 80, 3, 83, 80, 82, 179, 190, 4, 68, 2, 231, - 234, 14, 69, 12, 48, 6, 82, 71, 76, 65, 83, 83, 77, 2, 83, 69, 5, 233, - 185, 20, 14, 32, 87, 73, 84, 72, 32, 70, 76, 79, 87, 73, 78, 71, 32, 9, - 11, 32, 6, 88, 8, 87, 73, 84, 72, 32, 71, 65, 82, 181, 129, 22, 8, 66, - 85, 73, 76, 68, 73, 78, 71, 2, 135, 181, 22, 68, 7, 246, 138, 24, 74, 3, - 83, 8, 106, 83, 160, 244, 22, 11, 78, 68, 82, 69, 68, 32, 80, 79, 73, 78, - 84, 176, 13, 2, 71, 71, 163, 136, 1, 84, 2, 251, 246, 22, 72, 20, 80, 2, - 71, 73, 22, 80, 224, 1, 5, 83, 84, 69, 82, 69, 161, 129, 22, 2, 65, 67, - 4, 255, 243, 21, 69, 12, 60, 3, 72, 69, 78, 145, 157, 4, 6, 79, 68, 73, - 65, 83, 84, 11, 34, 32, 82, 65, 203, 252, 19, 45, 4, 26, 87, 215, 165, - 22, 66, 2, 21, 3, 73, 84, 72, 2, 197, 186, 3, 2, 32, 68, 2, 141, 220, 12, - 6, 84, 73, 79, 78, 32, 80, 2, 193, 241, 22, 2, 83, 73, 210, 5, 172, 1, 3, - 67, 69, 32, 152, 1, 2, 68, 69, 222, 24, 77, 222, 2, 78, 230, 35, 82, 132, - 2, 7, 90, 65, 75, 65, 89, 65, 32, 185, 242, 19, 9, 32, 76, 79, 86, 69, - 32, 89, 79, 85, 8, 114, 67, 236, 160, 11, 18, 72, 79, 67, 75, 69, 89, 32, - 83, 84, 73, 67, 75, 32, 65, 78, 68, 32, 80, 235, 190, 1, 83, 4, 138, 244, - 15, 82, 223, 231, 2, 85, 246, 1, 68, 3, 78, 84, 73, 201, 1, 9, 79, 71, - 82, 65, 80, 72, 73, 67, 32, 8, 64, 4, 67, 65, 76, 32, 105, 8, 70, 73, 67, - 65, 84, 73, 79, 78, 6, 32, 2, 84, 79, 131, 130, 23, 87, 5, 149, 247, 14, - 12, 32, 65, 78, 68, 32, 83, 76, 65, 78, 84, 69, 68, 2, 181, 233, 22, 2, - 32, 67, 238, 1, 208, 2, 11, 65, 78, 78, 79, 84, 65, 84, 73, 79, 78, 32, - 242, 3, 67, 72, 2, 68, 69, 248, 5, 5, 78, 85, 77, 66, 69, 22, 84, 224, - 239, 5, 8, 72, 65, 76, 70, 32, 70, 73, 76, 232, 186, 1, 5, 69, 78, 84, - 69, 82, 0, 3, 82, 73, 83, 24, 5, 76, 69, 86, 69, 76, 240, 138, 9, 5, 86, - 65, 82, 73, 65, 250, 233, 4, 70, 154, 47, 73, 243, 231, 1, 83, 32, 232, - 1, 5, 66, 79, 84, 84, 79, 22, 70, 82, 77, 62, 84, 140, 1, 4, 76, 73, 78, - 75, 196, 143, 1, 4, 83, 69, 67, 79, 234, 161, 6, 79, 224, 130, 6, 6, 82, - 69, 86, 69, 82, 83, 152, 222, 9, 5, 72, 69, 65, 86, 69, 169, 39, 3, 69, - 65, 82, 2, 143, 188, 23, 77, 6, 48, 3, 79, 85, 82, 197, 178, 23, 3, 73, - 82, 83, 4, 186, 187, 23, 84, 27, 32, 4, 36, 3, 73, 68, 68, 199, 147, 23, - 65, 2, 171, 181, 13, 76, 8, 34, 72, 46, 87, 151, 134, 8, 79, 4, 134, 146, - 9, 82, 237, 157, 14, 2, 73, 82, 2, 159, 186, 23, 79, 4, 36, 3, 76, 79, - 83, 227, 165, 21, 79, 2, 225, 185, 23, 3, 73, 78, 71, 36, 104, 20, 83, - 67, 82, 73, 80, 84, 73, 79, 78, 32, 67, 72, 65, 82, 65, 67, 84, 69, 82, - 32, 211, 175, 7, 80, 34, 144, 2, 9, 65, 66, 79, 86, 69, 32, 84, 79, 32, - 84, 8, 76, 69, 70, 84, 32, 84, 79, 32, 76, 5, 79, 86, 69, 82, 76, 20, 2, - 83, 85, 222, 245, 14, 82, 172, 200, 5, 8, 70, 85, 76, 76, 32, 83, 85, 82, - 229, 231, 2, 15, 72, 79, 82, 73, 90, 79, 78, 84, 65, 76, 32, 82, 69, 70, - 76, 4, 60, 9, 77, 73, 68, 68, 76, 69, 32, 65, 78, 223, 213, 21, 66, 2, - 175, 198, 21, 68, 4, 144, 164, 22, 10, 77, 73, 68, 68, 76, 69, 32, 65, - 78, 68, 211, 168, 1, 82, 2, 147, 225, 16, 65, 18, 72, 12, 82, 82, 79, 85, - 78, 68, 32, 70, 82, 79, 77, 32, 223, 181, 17, 66, 16, 82, 76, 208, 203, - 11, 3, 85, 80, 80, 250, 135, 10, 66, 130, 165, 1, 65, 159, 82, 82, 6, - 194, 203, 11, 79, 147, 255, 11, 69, 2, 175, 217, 8, 82, 148, 1, 92, 10, - 65, 76, 76, 89, 32, 77, 65, 82, 75, 32, 41, 9, 69, 76, 69, 71, 82, 65, - 80, 72, 32, 10, 138, 129, 22, 70, 70, 84, 155, 87, 79, 138, 1, 140, 1, - 11, 83, 89, 77, 66, 79, 76, 32, 70, 79, 82, 32, 221, 230, 12, 17, 76, 73, - 78, 69, 32, 70, 69, 69, 68, 32, 83, 69, 80, 65, 82, 65, 84, 136, 1, 182, - 1, 65, 58, 68, 200, 2, 5, 72, 79, 85, 82, 32, 214, 1, 74, 28, 4, 70, 69, - 66, 82, 64, 2, 77, 65, 168, 196, 15, 3, 78, 79, 86, 0, 4, 83, 69, 80, 84, - 25, 4, 79, 67, 84, 79, 4, 168, 131, 20, 3, 85, 71, 85, 165, 142, 2, 2, - 80, 82, 64, 44, 3, 65, 89, 32, 241, 200, 15, 2, 69, 67, 62, 66, 84, 142, - 212, 5, 69, 66, 70, 70, 78, 26, 83, 159, 255, 16, 79, 34, 34, 72, 90, 87, - 155, 159, 23, 69, 8, 36, 3, 73, 82, 84, 139, 253, 21, 82, 6, 26, 89, 139, - 153, 22, 69, 5, 179, 194, 22, 45, 24, 26, 69, 223, 238, 23, 79, 22, 36, - 3, 78, 84, 89, 227, 241, 22, 76, 21, 139, 163, 15, 45, 50, 78, 84, 234, - 209, 5, 69, 66, 70, 70, 78, 26, 83, 194, 168, 16, 90, 223, 86, 79, 20, - 42, 87, 198, 211, 5, 72, 131, 202, 17, 69, 14, 26, 69, 139, 237, 23, 79, - 12, 36, 3, 78, 84, 89, 143, 240, 22, 76, 11, 175, 158, 17, 45, 6, 24, 2, - 65, 78, 35, 85, 2, 11, 85, 2, 191, 166, 17, 65, 4, 186, 213, 23, 78, 143, - 5, 76, 4, 198, 201, 23, 82, 171, 34, 89, 68, 40, 6, 65, 71, 69, 32, 79, - 70, 83, 80, 5, 161, 135, 9, 15, 32, 79, 82, 32, 65, 80, 80, 82, 79, 88, - 73, 77, 65, 84, 69, 65, 65, 14, 69, 82, 73, 65, 76, 32, 65, 82, 65, 77, - 65, 73, 67, 32, 62, 72, 7, 78, 85, 77, 66, 69, 82, 32, 230, 18, 76, 181, - 209, 19, 2, 83, 69, 16, 26, 84, 187, 199, 15, 79, 10, 130, 183, 11, 87, - 250, 147, 1, 69, 131, 172, 9, 72, 136, 3, 202, 1, 67, 234, 1, 68, 214, 6, - 70, 132, 2, 5, 72, 73, 66, 73, 84, 156, 1, 15, 80, 85, 84, 32, 83, 89, - 77, 66, 79, 76, 32, 70, 79, 82, 32, 206, 1, 83, 236, 5, 2, 84, 69, 206, - 8, 86, 147, 250, 9, 66, 10, 32, 2, 79, 77, 69, 2, 82, 69, 4, 140, 207, - 16, 3, 73, 78, 71, 209, 230, 2, 5, 80, 76, 69, 84, 69, 6, 36, 3, 65, 83, - 69, 239, 162, 23, 77, 4, 34, 32, 157, 180, 10, 2, 83, 32, 2, 161, 183, - 11, 8, 70, 79, 78, 84, 32, 83, 73, 90, 145, 1, 24, 2, 69, 88, 103, 73, 5, - 149, 202, 22, 20, 32, 80, 79, 73, 78, 84, 73, 78, 71, 32, 65, 84, 32, 84, - 72, 69, 32, 86, 73, 69, 138, 1, 72, 8, 67, 32, 83, 73, 89, 65, 81, 32, - 173, 136, 18, 4, 65, 78, 32, 82, 136, 1, 196, 1, 11, 65, 76, 84, 69, 82, - 78, 65, 84, 69, 32, 76, 2, 76, 28, 9, 70, 82, 65, 67, 84, 73, 79, 78, 32, - 100, 7, 78, 85, 77, 66, 69, 82, 32, 130, 247, 8, 82, 209, 120, 6, 80, 76, - 65, 67, 69, 72, 2, 201, 160, 23, 2, 65, 75, 6, 68, 4, 79, 78, 69, 32, - 205, 221, 21, 7, 84, 72, 82, 69, 69, 32, 81, 4, 162, 219, 21, 72, 47, 81, - 122, 212, 1, 10, 65, 76, 84, 69, 82, 78, 65, 84, 69, 32, 72, 5, 75, 65, - 82, 79, 82, 0, 4, 76, 65, 75, 72, 222, 137, 10, 69, 66, 70, 94, 78, 26, - 83, 78, 84, 236, 135, 5, 8, 80, 82, 69, 70, 73, 88, 69, 68, 199, 41, 79, - 6, 26, 84, 251, 195, 22, 79, 4, 132, 164, 6, 2, 69, 78, 175, 156, 17, 87, - 5, 155, 143, 23, 65, 16, 72, 5, 73, 78, 73, 84, 89, 85, 9, 79, 82, 77, - 65, 84, 73, 79, 78, 32, 5, 45, 9, 32, 78, 69, 71, 65, 84, 69, 68, 32, 2, - 225, 171, 8, 4, 87, 73, 84, 72, 12, 42, 83, 225, 216, 19, 4, 68, 69, 83, - 75, 10, 244, 152, 7, 5, 69, 80, 65, 82, 65, 243, 252, 9, 79, 4, 11, 32, - 4, 196, 139, 23, 15, 65, 82, 65, 66, 73, 67, 32, 70, 79, 82, 77, 32, 83, - 72, 65, 1, 14, 83, 89, 77, 77, 69, 84, 82, 73, 67, 32, 83, 87, 65, 80, - 10, 80, 6, 76, 65, 84, 73, 78, 32, 218, 244, 14, 83, 161, 213, 7, 4, 78, - 85, 77, 66, 6, 64, 6, 67, 65, 80, 73, 84, 65, 0, 4, 83, 77, 65, 76, 27, - 76, 2, 21, 3, 76, 32, 76, 2, 193, 214, 21, 2, 69, 84, 116, 84, 13, 67, - 82, 73, 80, 84, 73, 79, 78, 65, 76, 32, 80, 65, 245, 200, 15, 2, 69, 82, - 114, 72, 6, 72, 76, 65, 86, 73, 32, 225, 1, 7, 82, 84, 72, 73, 65, 78, - 32, 54, 48, 7, 76, 69, 84, 84, 69, 82, 32, 191, 3, 78, 38, 234, 171, 10, - 84, 222, 119, 65, 22, 68, 34, 76, 22, 77, 50, 87, 254, 169, 4, 71, 90, - 90, 34, 83, 66, 89, 198, 207, 1, 72, 234, 5, 75, 174, 81, 66, 170, 225, - 4, 78, 223, 105, 80, 60, 22, 76, 251, 1, 78, 44, 11, 69, 44, 29, 5, 84, - 84, 69, 82, 32, 44, 250, 169, 10, 84, 242, 119, 68, 34, 76, 50, 81, 214, - 205, 1, 82, 142, 220, 2, 65, 50, 71, 90, 90, 34, 83, 66, 89, 198, 207, 1, - 72, 234, 5, 75, 174, 81, 66, 170, 225, 4, 78, 134, 2, 87, 218, 103, 80, - 171, 4, 77, 16, 33, 6, 85, 77, 66, 69, 82, 32, 16, 242, 161, 11, 84, 226, - 144, 4, 79, 167, 134, 3, 70, 50, 36, 4, 71, 82, 65, 76, 179, 3, 82, 23, - 11, 32, 20, 58, 65, 140, 1, 5, 87, 73, 84, 72, 32, 135, 175, 21, 69, 4, - 96, 6, 86, 69, 82, 65, 71, 69, 169, 172, 16, 12, 82, 79, 85, 78, 68, 32, - 65, 32, 80, 79, 73, 78, 2, 205, 173, 16, 5, 32, 87, 73, 84, 72, 14, 160, - 1, 3, 84, 73, 77, 20, 2, 85, 78, 172, 239, 6, 16, 76, 69, 70, 84, 87, 65, - 82, 68, 83, 32, 65, 82, 82, 79, 87, 32, 246, 173, 13, 73, 198, 1, 79, - 251, 64, 68, 2, 227, 158, 20, 69, 4, 238, 158, 20, 68, 131, 226, 2, 73, - 28, 94, 76, 232, 1, 7, 83, 69, 67, 84, 73, 79, 78, 146, 7, 82, 232, 249, - 11, 2, 67, 65, 43, 73, 8, 164, 1, 17, 73, 78, 69, 65, 82, 32, 65, 78, 78, - 79, 84, 65, 84, 73, 79, 78, 32, 221, 235, 4, 17, 79, 67, 75, 69, 68, 32, - 70, 69, 77, 65, 76, 69, 32, 65, 78, 68, 32, 6, 208, 167, 8, 3, 65, 78, - 67, 146, 154, 8, 84, 159, 219, 3, 83, 15, 11, 32, 12, 168, 1, 6, 65, 66, - 79, 86, 69, 32, 64, 5, 87, 73, 84, 72, 32, 169, 152, 20, 22, 66, 69, 83, - 73, 68, 69, 32, 65, 78, 68, 32, 74, 79, 73, 78, 69, 68, 32, 87, 73, 84, - 72, 4, 152, 153, 20, 9, 66, 65, 82, 32, 65, 66, 79, 86, 69, 23, 85, 6, - 206, 169, 4, 76, 178, 240, 15, 79, 195, 225, 2, 68, 40, 56, 2, 69, 82, - 189, 5, 7, 73, 83, 73, 66, 76, 69, 32, 34, 48, 3, 83, 69, 32, 225, 2, 4, - 84, 69, 68, 32, 16, 174, 1, 66, 80, 5, 67, 72, 69, 67, 75, 68, 24, 68, - 79, 87, 78, 87, 65, 82, 68, 83, 32, 65, 82, 82, 79, 87, 32, 87, 73, 84, - 72, 32, 84, 73, 80, 210, 178, 20, 87, 219, 26, 77, 6, 44, 5, 76, 65, 67, - 75, 32, 227, 230, 21, 85, 4, 250, 137, 22, 68, 227, 27, 83, 4, 228, 204, - 20, 8, 69, 82, 32, 66, 79, 65, 82, 68, 183, 186, 2, 32, 2, 197, 230, 20, - 2, 32, 76, 18, 144, 1, 6, 73, 78, 84, 69, 82, 82, 22, 76, 146, 242, 11, - 80, 230, 184, 4, 69, 244, 198, 1, 2, 79, 72, 204, 158, 2, 4, 85, 78, 68, - 69, 183, 97, 81, 2, 131, 214, 4, 79, 6, 60, 9, 79, 87, 32, 75, 65, 86, - 89, 75, 65, 215, 231, 6, 65, 5, 205, 154, 18, 11, 32, 87, 73, 84, 72, 32, - 75, 65, 86, 89, 75, 6, 38, 84, 154, 186, 19, 80, 223, 89, 83, 2, 135, - 173, 16, 73, 4, 222, 169, 22, 69, 215, 93, 73, 218, 1, 94, 65, 138, 21, - 69, 62, 79, 42, 85, 133, 187, 11, 10, 73, 71, 83, 65, 87, 32, 80, 85, 90, - 90, 202, 1, 120, 5, 67, 75, 45, 79, 45, 32, 7, 80, 65, 78, 69, 83, 69, - 32, 184, 2, 7, 86, 65, 78, 69, 83, 69, 32, 183, 192, 23, 82, 2, 145, 176, - 18, 3, 76, 65, 78, 16, 246, 1, 67, 18, 80, 204, 153, 1, 10, 73, 78, 68, - 85, 83, 84, 82, 73, 65, 76, 236, 229, 3, 3, 66, 65, 78, 134, 174, 3, 68, - 144, 139, 11, 15, 83, 89, 77, 66, 79, 76, 32, 70, 79, 82, 32, 66, 69, 71, - 73, 180, 248, 1, 3, 71, 79, 66, 169, 109, 2, 79, 71, 2, 207, 32, 65, 2, - 141, 137, 13, 7, 79, 83, 84, 32, 79, 70, 70, 182, 1, 172, 2, 15, 67, 79, - 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, 32, 76, 2, 76, 69, 40, 4, - 82, 73, 71, 72, 224, 6, 2, 80, 65, 176, 3, 14, 84, 85, 82, 78, 69, 68, - 32, 80, 65, 68, 65, 32, 80, 73, 88, 5, 83, 73, 71, 78, 32, 144, 1, 11, - 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 143, 189, 21, 68, 6, 52, 2, - 75, 69, 164, 193, 16, 2, 80, 69, 175, 5, 67, 2, 175, 136, 23, 82, 96, 38, - 70, 65, 5, 84, 84, 69, 82, 32, 2, 41, 8, 84, 32, 82, 69, 82, 69, 78, 71, - 2, 195, 240, 21, 71, 94, 230, 1, 68, 26, 73, 48, 2, 75, 65, 66, 78, 130, - 1, 66, 2, 67, 2, 71, 16, 2, 80, 65, 56, 2, 82, 65, 32, 2, 83, 65, 42, 84, - 74, 74, 194, 170, 21, 65, 142, 138, 2, 72, 2, 76, 2, 77, 2, 87, 2, 89, - 186, 2, 69, 2, 79, 3, 85, 8, 222, 3, 68, 15, 65, 7, 236, 201, 5, 3, 32, - 75, 65, 223, 240, 17, 73, 7, 11, 32, 4, 22, 83, 215, 2, 77, 2, 237, 128, - 21, 2, 65, 83, 14, 36, 2, 71, 65, 90, 89, 167, 1, 65, 7, 33, 6, 32, 76, - 69, 76, 69, 84, 5, 29, 5, 32, 82, 65, 83, 87, 2, 211, 226, 5, 65, 4, 163, - 1, 65, 7, 11, 32, 4, 154, 1, 77, 129, 180, 23, 3, 67, 69, 82, 5, 213, - 196, 16, 3, 32, 65, 71, 7, 17, 2, 32, 77, 4, 70, 85, 71, 65, 8, 18, 65, - 55, 84, 5, 17, 2, 32, 77, 2, 11, 85, 2, 147, 146, 23, 82, 4, 11, 65, 5, - 11, 32, 2, 11, 77, 2, 11, 65, 2, 11, 72, 2, 213, 177, 17, 2, 65, 80, 28, - 40, 3, 68, 65, 32, 165, 3, 2, 78, 71, 24, 174, 1, 65, 90, 76, 86, 80, - 168, 147, 7, 10, 84, 73, 82, 84, 65, 32, 84, 85, 77, 69, 210, 130, 12, - 87, 168, 199, 2, 7, 73, 83, 69, 78, 45, 73, 83, 169, 211, 1, 3, 77, 65, - 68, 6, 44, 3, 68, 69, 71, 153, 161, 22, 2, 78, 68, 5, 11, 32, 2, 169, - 238, 22, 2, 65, 68, 6, 38, 85, 141, 177, 23, 3, 73, 78, 71, 4, 216, 192, - 18, 2, 78, 71, 163, 250, 3, 72, 4, 38, 73, 181, 185, 18, 3, 65, 78, 71, - 2, 157, 189, 16, 3, 83, 69, 76, 4, 244, 144, 13, 5, 82, 65, 78, 71, 75, - 251, 209, 9, 75, 10, 108, 5, 67, 69, 67, 65, 75, 172, 202, 5, 3, 87, 73, - 71, 254, 241, 10, 76, 249, 228, 2, 5, 80, 65, 78, 89, 65, 5, 133, 168, - 18, 3, 32, 84, 69, 18, 116, 4, 83, 85, 75, 85, 42, 84, 64, 4, 87, 85, 76, - 85, 246, 186, 16, 80, 137, 224, 1, 7, 68, 73, 82, 71, 65, 32, 77, 5, 201, - 182, 22, 5, 32, 77, 69, 78, 68, 6, 26, 65, 179, 188, 16, 79, 4, 154, 188, - 16, 82, 187, 162, 6, 76, 5, 25, 4, 32, 77, 69, 76, 2, 255, 171, 23, 73, - 4, 36, 3, 76, 76, 89, 179, 231, 19, 65, 2, 143, 202, 19, 70, 4, 168, 252, - 21, 2, 89, 83, 191, 98, 73, 6, 172, 192, 14, 2, 71, 71, 194, 135, 5, 80, - 191, 199, 3, 78, 142, 18, 74, 65, 178, 78, 69, 218, 1, 72, 214, 46, 73, - 198, 6, 78, 50, 79, 111, 82, 202, 10, 200, 1, 5, 73, 84, 72, 73, 32, 234, - 4, 78, 188, 45, 6, 84, 65, 75, 65, 78, 65, 208, 13, 3, 87, 73, 32, 220, - 8, 7, 89, 65, 72, 32, 76, 73, 32, 148, 198, 4, 6, 75, 84, 79, 86, 73, 75, - 187, 239, 17, 65, 136, 1, 204, 1, 7, 76, 69, 84, 84, 69, 82, 32, 178, 2, - 83, 202, 112, 68, 228, 243, 3, 2, 86, 79, 236, 137, 3, 11, 78, 85, 77, - 66, 69, 82, 32, 83, 73, 71, 78, 214, 197, 9, 65, 189, 211, 1, 6, 69, 78, - 85, 77, 69, 82, 90, 214, 1, 68, 166, 202, 19, 65, 150, 1, 84, 230, 5, 85, - 186, 202, 1, 73, 138, 196, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 74, 2, - 75, 2, 80, 2, 82, 138, 69, 72, 2, 76, 2, 77, 2, 86, 2, 89, 186, 2, 69, 3, - 79, 10, 38, 68, 186, 165, 23, 72, 187, 2, 65, 6, 198, 170, 21, 68, 242, - 250, 1, 72, 187, 2, 65, 12, 40, 4, 73, 71, 78, 32, 155, 148, 11, 69, 10, - 178, 137, 19, 67, 98, 78, 138, 216, 3, 65, 239, 1, 86, 232, 4, 42, 71, - 241, 39, 5, 78, 65, 68, 65, 32, 174, 3, 76, 11, 88, 73, 32, 82, 65, 68, - 73, 67, 65, 76, 32, 225, 218, 20, 2, 65, 82, 172, 3, 130, 2, 65, 94, 66, - 230, 2, 67, 150, 2, 68, 158, 3, 69, 198, 1, 70, 138, 2, 71, 146, 1, 72, - 210, 2, 73, 76, 2, 74, 65, 34, 75, 30, 76, 230, 1, 77, 254, 1, 78, 62, - 79, 102, 80, 110, 82, 166, 1, 83, 230, 6, 84, 226, 2, 86, 50, 87, 210, 2, - 89, 183, 243, 21, 85, 10, 56, 2, 82, 82, 174, 244, 21, 71, 202, 104, 78, - 207, 47, 88, 4, 242, 164, 22, 79, 207, 1, 73, 34, 58, 65, 38, 73, 46, 76, - 54, 79, 102, 82, 183, 212, 21, 69, 4, 166, 199, 5, 77, 235, 137, 14, 68, - 6, 134, 232, 21, 84, 238, 115, 82, 163, 70, 71, 6, 186, 231, 19, 79, 170, - 136, 2, 65, 179, 155, 1, 85, 10, 62, 76, 202, 132, 23, 65, 218, 5, 78, - 142, 5, 68, 203, 17, 87, 2, 177, 216, 3, 4, 84, 32, 79, 70, 6, 42, 73, - 134, 240, 9, 65, 155, 197, 11, 85, 2, 195, 247, 13, 83, 28, 58, 65, 70, - 76, 74, 79, 182, 173, 10, 72, 183, 129, 11, 73, 6, 38, 85, 130, 131, 23, - 82, 219, 5, 86, 2, 245, 247, 21, 2, 76, 68, 8, 42, 65, 242, 186, 7, 73, - 219, 205, 14, 79, 4, 226, 158, 23, 78, 3, 87, 10, 234, 249, 21, 82, 148, - 2, 2, 77, 80, 222, 100, 86, 134, 5, 76, 235, 56, 87, 34, 38, 69, 38, 73, - 98, 79, 195, 1, 82, 4, 218, 152, 21, 65, 159, 204, 1, 69, 8, 38, 83, 202, - 248, 13, 86, 175, 2, 80, 4, 184, 184, 19, 5, 84, 73, 78, 71, 85, 207, - 228, 3, 72, 16, 94, 84, 76, 3, 85, 66, 76, 242, 249, 12, 87, 252, 208, 9, - 2, 32, 78, 222, 23, 79, 223, 56, 71, 7, 25, 4, 84, 69, 68, 32, 4, 220, - 183, 7, 3, 67, 76, 73, 207, 160, 15, 84, 2, 227, 130, 4, 69, 6, 218, 224, - 21, 65, 222, 169, 1, 85, 219, 16, 89, 20, 106, 65, 38, 78, 32, 3, 86, 69, - 78, 244, 250, 8, 6, 77, 66, 82, 79, 73, 68, 250, 243, 13, 73, 243, 19, - 89, 6, 146, 225, 16, 82, 227, 184, 6, 84, 4, 178, 25, 67, 179, 194, 22, - 84, 5, 183, 200, 22, 73, 28, 74, 65, 50, 73, 62, 76, 38, 82, 170, 20, 69, - 226, 178, 22, 79, 223, 23, 85, 6, 250, 246, 13, 84, 130, 139, 9, 67, 131, - 22, 78, 8, 210, 232, 12, 69, 150, 133, 10, 71, 230, 19, 82, 199, 21, 83, - 4, 206, 206, 21, 85, 151, 201, 1, 89, 4, 156, 231, 21, 2, 65, 71, 207, - 175, 1, 79, 14, 58, 79, 52, 2, 82, 65, 166, 168, 19, 72, 239, 164, 2, 65, - 7, 182, 208, 22, 76, 241, 34, 5, 32, 83, 76, 79, 87, 4, 194, 198, 22, 73, - 135, 18, 83, 22, 58, 65, 142, 1, 69, 60, 5, 73, 68, 73, 78, 71, 19, 79, - 8, 38, 76, 130, 207, 22, 78, 199, 13, 73, 4, 34, 70, 141, 252, 21, 2, 66, - 69, 2, 41, 8, 32, 84, 82, 69, 69, 32, 84, 82, 2, 239, 175, 19, 85, 6, 26, - 65, 151, 148, 23, 77, 4, 242, 247, 22, 82, 175, 28, 68, 2, 195, 19, 32, - 6, 26, 82, 191, 144, 23, 79, 4, 254, 252, 22, 83, 215, 22, 78, 6, 26, 78, - 199, 252, 22, 67, 4, 26, 83, 239, 145, 23, 67, 2, 239, 129, 22, 69, 4, - 146, 252, 22, 68, 215, 22, 82, 2, 185, 175, 5, 2, 78, 73, 22, 46, 65, 34, - 69, 78, 73, 41, 3, 79, 78, 71, 4, 166, 251, 22, 77, 191, 19, 67, 8, 38, - 65, 218, 211, 22, 71, 199, 58, 69, 4, 222, 239, 13, 84, 215, 161, 9, 70, - 6, 186, 250, 22, 70, 2, 78, 215, 22, 68, 5, 129, 196, 11, 3, 32, 83, 84, - 22, 42, 69, 34, 73, 46, 79, 243, 191, 22, 65, 4, 174, 192, 22, 76, 195, - 51, 65, 4, 232, 234, 11, 2, 78, 73, 139, 195, 9, 76, 12, 34, 82, 34, 85, - 175, 191, 22, 79, 4, 238, 235, 21, 84, 187, 82, 78, 6, 26, 78, 227, 141, - 23, 84, 4, 134, 224, 21, 84, 235, 174, 1, 68, 6, 26, 79, 135, 242, 22, - 69, 4, 218, 247, 22, 83, 215, 22, 84, 10, 40, 2, 78, 69, 22, 80, 179, - 199, 22, 76, 5, 251, 153, 6, 83, 4, 166, 170, 10, 80, 247, 193, 2, 69, - 10, 54, 82, 206, 240, 21, 76, 166, 1, 79, 179, 154, 1, 73, 4, 252, 198, - 12, 2, 73, 86, 181, 141, 7, 2, 79, 70, 18, 62, 65, 42, 73, 210, 165, 10, - 79, 170, 150, 12, 85, 195, 9, 69, 6, 158, 188, 22, 73, 226, 79, 80, 3, - 84, 6, 132, 234, 12, 3, 71, 72, 84, 230, 227, 9, 86, 155, 39, 67, 74, - 170, 1, 65, 86, 67, 54, 69, 62, 72, 178, 1, 73, 46, 76, 62, 80, 106, 84, - 246, 236, 17, 87, 158, 159, 1, 78, 234, 64, 79, 130, 174, 1, 77, 226, - 103, 81, 130, 35, 75, 247, 47, 85, 6, 196, 191, 3, 9, 67, 82, 73, 70, 73, - 67, 73, 65, 76, 254, 173, 19, 76, 175, 28, 89, 4, 200, 238, 10, 2, 82, - 73, 249, 218, 5, 2, 72, 79, 8, 146, 202, 21, 67, 134, 51, 65, 174, 10, - 76, 167, 129, 1, 69, 10, 18, 69, 39, 79, 4, 198, 252, 21, 76, 199, 139, - 1, 69, 6, 40, 4, 82, 84, 32, 84, 159, 235, 22, 79, 4, 44, 5, 65, 73, 76, - 69, 68, 183, 253, 15, 72, 2, 177, 130, 21, 2, 32, 66, 4, 160, 239, 17, 2, - 67, 75, 195, 148, 5, 76, 6, 26, 65, 187, 201, 22, 73, 4, 222, 239, 22, - 86, 199, 21, 83, 10, 50, 69, 34, 73, 166, 140, 19, 82, 179, 169, 3, 79, - 4, 130, 205, 22, 65, 183, 22, 69, 2, 135, 233, 22, 82, 12, 34, 69, 34, - 79, 215, 244, 21, 65, 4, 174, 244, 22, 65, 219, 16, 80, 6, 26, 80, 251, - 237, 22, 78, 5, 199, 179, 22, 80, 30, 82, 65, 98, 73, 34, 79, 38, 82, 52, - 2, 85, 82, 32, 2, 87, 79, 143, 178, 22, 69, 6, 38, 78, 130, 221, 21, 66, - 239, 26, 76, 2, 33, 6, 78, 69, 68, 32, 76, 69, 2, 183, 225, 13, 65, 4, - 150, 197, 22, 71, 155, 39, 76, 4, 250, 242, 18, 78, 243, 138, 2, 79, 6, - 166, 232, 16, 73, 150, 232, 4, 65, 179, 155, 1, 69, 4, 238, 181, 21, 66, - 227, 37, 84, 5, 163, 191, 19, 32, 4, 230, 212, 12, 65, 209, 157, 5, 3, - 73, 76, 76, 26, 58, 65, 110, 69, 42, 72, 32, 2, 73, 78, 30, 79, 39, 82, - 6, 32, 2, 76, 75, 223, 194, 22, 84, 5, 11, 32, 2, 11, 69, 2, 17, 2, 78, - 67, 2, 213, 235, 17, 2, 76, 79, 4, 144, 176, 22, 2, 65, 80, 195, 51, 83, - 4, 194, 182, 21, 73, 231, 63, 69, 4, 182, 255, 22, 68, 3, 69, 4, 254, - 178, 21, 77, 135, 201, 1, 82, 4, 254, 173, 22, 79, 239, 80, 65, 2, 245, - 220, 20, 2, 69, 76, 186, 1, 92, 2, 76, 69, 148, 2, 5, 83, 73, 71, 78, 32, - 146, 199, 17, 65, 186, 9, 86, 247, 182, 3, 68, 110, 44, 5, 84, 84, 69, - 82, 32, 195, 187, 22, 78, 108, 166, 206, 17, 78, 142, 209, 1, 65, 38, 68, - 46, 76, 38, 82, 34, 84, 46, 86, 186, 5, 85, 206, 141, 1, 79, 238, 60, 73, - 182, 196, 1, 83, 82, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 162, 7, 69, - 234, 61, 70, 2, 72, 2, 77, 3, 89, 22, 94, 67, 138, 1, 83, 222, 220, 18, - 78, 190, 66, 65, 190, 158, 1, 74, 150, 3, 85, 235, 245, 1, 86, 4, 100, - 19, 79, 77, 66, 73, 78, 73, 78, 71, 32, 65, 78, 85, 83, 86, 65, 82, 65, - 32, 65, 171, 220, 18, 65, 2, 149, 245, 19, 3, 66, 79, 86, 4, 192, 190, - 12, 6, 80, 65, 67, 73, 78, 71, 255, 143, 5, 73, 162, 2, 62, 32, 173, 11, - 10, 45, 72, 73, 82, 65, 71, 65, 78, 65, 32, 154, 2, 140, 1, 7, 76, 69, - 84, 84, 69, 82, 32, 242, 9, 86, 208, 250, 18, 10, 68, 73, 71, 82, 65, 80, - 72, 32, 75, 79, 238, 204, 1, 73, 191, 146, 1, 77, 146, 2, 186, 1, 65, - 178, 1, 66, 106, 77, 186, 2, 78, 54, 83, 226, 1, 68, 2, 71, 2, 72, 2, 75, - 2, 80, 2, 82, 2, 84, 2, 86, 2, 90, 126, 87, 46, 89, 254, 237, 22, 69, 2, - 73, 2, 79, 3, 85, 19, 60, 4, 73, 78, 85, 32, 45, 7, 82, 67, 72, 65, 73, - 67, 32, 8, 130, 7, 84, 242, 215, 22, 67, 215, 22, 80, 8, 38, 89, 142, - 208, 22, 87, 235, 36, 69, 4, 242, 244, 22, 69, 3, 73, 20, 50, 73, 166, - 244, 22, 65, 2, 69, 2, 79, 3, 85, 13, 253, 4, 9, 68, 65, 75, 85, 79, 78, - 32, 78, 71, 36, 50, 73, 190, 243, 22, 65, 2, 69, 2, 79, 3, 85, 29, 29, 5, - 78, 78, 65, 78, 32, 26, 96, 15, 78, 65, 83, 65, 76, 73, 90, 69, 68, 32, - 84, 79, 78, 69, 45, 69, 5, 84, 79, 78, 69, 45, 14, 182, 242, 22, 49, 2, - 50, 2, 51, 2, 52, 2, 53, 2, 55, 3, 56, 12, 242, 241, 22, 50, 2, 51, 2, - 52, 2, 53, 2, 55, 3, 56, 13, 182, 241, 22, 65, 2, 69, 2, 73, 2, 79, 3, - 85, 76, 76, 5, 77, 65, 76, 76, 32, 182, 240, 22, 65, 2, 69, 2, 73, 2, 79, - 3, 85, 66, 142, 1, 72, 2, 82, 54, 75, 46, 84, 30, 87, 46, 89, 130, 151, - 19, 78, 198, 150, 3, 83, 210, 27, 77, 234, 36, 65, 2, 69, 2, 73, 2, 79, - 3, 85, 10, 162, 239, 22, 65, 2, 69, 2, 73, 2, 79, 3, 85, 8, 238, 238, 22, - 65, 2, 69, 2, 79, 3, 85, 4, 194, 238, 22, 79, 3, 85, 8, 166, 238, 22, 65, - 2, 69, 2, 73, 3, 79, 6, 250, 237, 22, 65, 2, 79, 3, 85, 2, 165, 199, 20, + 69, 82, 84, 73, 67, 65, 76, 32, 228, 168, 6, 6, 79, 66, 76, 73, 81, 85, + 148, 209, 2, 9, 82, 73, 71, 72, 84, 32, 65, 82, 67, 198, 203, 3, 65, 222, + 200, 14, 81, 252, 106, 6, 87, 65, 86, 89, 32, 79, 171, 81, 69, 26, 92, 5, + 73, 82, 67, 76, 69, 236, 183, 8, 4, 85, 82, 76, 89, 249, 129, 1, 4, 79, + 76, 79, 78, 22, 72, 12, 32, 87, 73, 84, 72, 32, 68, 79, 85, 66, 76, 69, + 57, 2, 68, 32, 2, 173, 209, 28, 9, 32, 72, 79, 82, 73, 90, 79, 78, 84, + 20, 26, 78, 187, 153, 21, 68, 2, 133, 215, 2, 5, 85, 77, 66, 69, 82, 4, + 250, 192, 19, 79, 255, 212, 6, 65, 4, 234, 147, 21, 73, 227, 63, 89, 4, + 194, 229, 26, 82, 175, 250, 1, 71, 12, 54, 79, 209, 234, 17, 7, 69, 70, + 84, 32, 65, 82, 67, 10, 26, 87, 243, 160, 26, 71, 6, 26, 45, 255, 206, + 28, 32, 4, 210, 146, 21, 82, 211, 1, 57, 6, 248, 215, 17, 9, 76, 69, 83, + 83, 45, 84, 72, 65, 78, 151, 249, 9, 71, 8, 26, 82, 199, 221, 27, 76, 6, + 206, 153, 1, 69, 139, 190, 16, 73, 18, 80, 6, 81, 85, 65, 82, 69, 32, 30, + 84, 50, 85, 217, 167, 14, 4, 79, 76, 73, 68, 4, 130, 177, 26, 73, 55, 85, + 4, 224, 247, 12, 3, 65, 67, 75, 139, 223, 4, 82, 8, 58, 83, 238, 151, 1, + 67, 186, 228, 21, 80, 215, 249, 4, 66, 2, 161, 254, 28, 4, 80, 69, 78, + 83, 4, 146, 188, 19, 80, 199, 218, 9, 78, 10, 36, 3, 66, 65, 82, 151, + 203, 28, 76, 9, 11, 32, 6, 52, 7, 68, 79, 85, 66, 76, 69, 32, 199, 184, + 27, 76, 4, 194, 184, 27, 76, 51, 82, 48, 112, 5, 76, 73, 78, 69, 32, 220, + 1, 7, 83, 84, 82, 85, 67, 75, 32, 177, 253, 8, 7, 69, 78, 68, 69, 68, 32, + 77, 12, 48, 8, 83, 76, 65, 78, 84, 69, 68, 32, 75, 69, 8, 70, 69, 56, 7, + 71, 82, 69, 65, 84, 69, 82, 1, 4, 76, 69, 83, 83, 4, 221, 136, 21, 9, 81, + 85, 65, 76, 32, 84, 79, 32, 79, 2, 181, 246, 14, 5, 45, 84, 72, 65, 78, + 34, 160, 1, 8, 67, 65, 80, 73, 84, 65, 76, 32, 92, 7, 73, 84, 65, 76, 73, + 67, 32, 124, 6, 83, 77, 65, 76, 76, 32, 185, 161, 14, 8, 78, 45, 65, 82, + 89, 32, 83, 85, 18, 242, 211, 12, 71, 166, 254, 14, 80, 230, 143, 2, 67, + 2, 72, 2, 78, 2, 81, 2, 82, 3, 90, 10, 76, 6, 83, 77, 65, 76, 76, 32, + 245, 189, 22, 7, 67, 65, 80, 73, 84, 65, 76, 8, 206, 224, 29, 68, 2, 69, + 2, 73, 3, 74, 4, 154, 210, 12, 71, 179, 250, 16, 80, 6, 222, 203, 10, 70, + 26, 77, 223, 254, 17, 83, 2, 131, 230, 28, 78, 166, 1, 50, 32, 150, 1, + 45, 189, 1, 4, 87, 65, 82, 68, 10, 60, 4, 84, 65, 67, 75, 254, 177, 26, + 70, 30, 82, 207, 79, 65, 5, 29, 5, 32, 87, 73, 84, 72, 2, 11, 32, 2, 181, + 202, 21, 5, 67, 73, 82, 67, 76, 28, 60, 9, 80, 79, 73, 78, 84, 73, 78, + 71, 32, 131, 179, 26, 70, 24, 62, 83, 166, 181, 26, 65, 86, 69, 62, 70, + 46, 82, 207, 1, 84, 4, 162, 131, 18, 84, 233, 180, 8, 6, 77, 65, 76, 76, + 32, 82, 128, 1, 56, 8, 32, 70, 65, 67, 73, 78, 71, 32, 89, 2, 83, 32, 8, + 54, 72, 1, 9, 78, 79, 84, 67, 72, 69, 68, 32, 72, 4, 225, 180, 28, 3, 79, + 79, 75, 120, 178, 1, 65, 200, 2, 6, 66, 76, 65, 67, 75, 32, 38, 84, 204, + 136, 9, 2, 87, 72, 206, 205, 8, 90, 182, 143, 9, 68, 50, 70, 82, 72, 150, + 4, 67, 46, 81, 42, 82, 22, 83, 247, 7, 80, 34, 40, 4, 82, 82, 79, 87, + 231, 224, 26, 78, 33, 11, 32, 30, 144, 1, 5, 87, 73, 84, 72, 32, 148, + 181, 14, 14, 76, 69, 70, 84, 87, 65, 82, 68, 83, 32, 79, 70, 32, 85, 230, + 171, 12, 65, 178, 10, 70, 179, 5, 84, 22, 244, 186, 5, 6, 67, 79, 82, 78, + 69, 82, 174, 168, 21, 68, 58, 76, 42, 77, 38, 78, 58, 83, 66, 69, 250, + 12, 84, 143, 58, 72, 6, 226, 215, 21, 65, 179, 141, 5, 67, 36, 36, 2, 82, + 73, 161, 2, 2, 87, 79, 32, 44, 5, 65, 78, 71, 76, 69, 195, 243, 26, 80, + 30, 56, 8, 45, 72, 69, 65, 68, 69, 68, 32, 255, 248, 26, 32, 28, 68, 5, + 65, 82, 82, 79, 87, 190, 212, 17, 90, 130, 157, 9, 68, 39, 80, 23, 11, + 32, 20, 236, 236, 26, 15, 76, 69, 70, 84, 87, 65, 82, 68, 83, 32, 79, 70, + 32, 85, 80, 98, 84, 23, 87, 4, 186, 242, 26, 32, 105, 15, 45, 72, 69, 65, + 68, 69, 68, 32, 65, 82, 82, 79, 87, 32, 87, 22, 138, 1, 65, 106, 79, 152, + 1, 12, 85, 77, 32, 87, 73, 84, 72, 32, 68, 82, 85, 77, 192, 192, 17, 6, + 73, 86, 69, 32, 83, 76, 195, 247, 10, 69, 8, 226, 204, 2, 67, 128, 173, + 6, 10, 70, 84, 73, 78, 71, 32, 80, 79, 73, 78, 201, 171, 16, 3, 71, 79, + 78, 8, 56, 6, 77, 69, 68, 65, 82, 89, 34, 80, 135, 151, 28, 79, 2, 137, + 192, 21, 3, 32, 67, 65, 4, 220, 134, 19, 6, 32, 79, 70, 32, 66, 76, 155, + 149, 10, 76, 2, 185, 146, 13, 3, 83, 84, 73, 162, 2, 76, 7, 80, 76, 79, + 89, 65, 78, 32, 180, 218, 20, 2, 77, 80, 151, 242, 8, 67, 158, 2, 212, 2, + 6, 65, 70, 70, 73, 88, 32, 160, 7, 7, 76, 69, 84, 84, 69, 82, 32, 220, + 190, 1, 16, 84, 72, 73, 67, 75, 32, 76, 69, 84, 84, 69, 82, 32, 83, 69, + 76, 220, 180, 3, 4, 68, 79, 85, 66, 156, 187, 17, 19, 80, 85, 78, 67, 84, + 85, 65, 84, 73, 79, 78, 32, 67, 72, 73, 78, 79, 79, 75, 205, 208, 5, 11, + 83, 73, 71, 78, 32, 79, 32, 87, 73, 84, 72, 64, 140, 1, 9, 65, 84, 84, + 65, 67, 72, 69, 68, 32, 184, 1, 5, 72, 73, 71, 72, 32, 106, 76, 40, 4, + 82, 73, 71, 72, 173, 2, 4, 77, 73, 68, 32, 14, 112, 2, 84, 65, 232, 4, + 13, 76, 69, 70, 84, 45, 84, 79, 45, 82, 73, 71, 72, 84, 26, 83, 214, 196, + 21, 69, 3, 73, 6, 44, 5, 78, 71, 69, 78, 84, 131, 191, 28, 73, 5, 175, + 201, 21, 32, 20, 174, 2, 76, 50, 84, 38, 86, 206, 200, 8, 71, 158, 2, 65, + 158, 139, 19, 87, 142, 26, 67, 243, 134, 1, 68, 24, 36, 2, 69, 70, 29, 3, + 79, 87, 32, 2, 213, 2, 3, 84, 32, 72, 22, 94, 65, 38, 76, 50, 84, 38, 86, + 206, 200, 8, 71, 186, 141, 19, 87, 142, 26, 67, 243, 134, 1, 68, 4, 250, + 188, 22, 67, 203, 238, 5, 82, 4, 216, 149, 8, 3, 79, 78, 71, 131, 151, + 20, 73, 2, 189, 191, 8, 4, 73, 71, 72, 84, 4, 37, 7, 69, 82, 84, 73, 67, + 65, 76, 5, 131, 1, 32, 4, 42, 72, 41, 6, 86, 69, 82, 84, 73, 67, 2, 37, + 7, 79, 82, 73, 90, 79, 78, 84, 2, 17, 2, 65, 76, 2, 11, 32, 2, 11, 83, 2, + 133, 186, 28, 2, 69, 67, 214, 1, 222, 1, 65, 22, 68, 34, 69, 30, 70, 22, + 71, 22, 74, 170, 1, 75, 66, 76, 50, 77, 62, 78, 134, 1, 79, 50, 80, 86, + 82, 74, 83, 210, 2, 84, 66, 85, 42, 86, 38, 87, 70, 88, 154, 189, 28, 72, + 142, 60, 73, 206, 41, 89, 215, 22, 66, 5, 151, 159, 29, 79, 7, 142, 134, + 29, 32, 223, 61, 72, 7, 202, 195, 29, 69, 3, 85, 5, 207, 243, 28, 32, 5, + 243, 195, 25, 32, 19, 11, 32, 16, 76, 8, 87, 73, 84, 72, 32, 68, 79, 84, + 238, 5, 77, 2, 78, 231, 149, 28, 83, 5, 53, 11, 83, 32, 73, 78, 83, 73, + 68, 69, 32, 65, 78, 2, 239, 196, 28, 68, 9, 26, 32, 199, 193, 29, 75, 4, + 166, 194, 25, 82, 159, 255, 3, 77, 9, 172, 163, 23, 3, 79, 78, 71, 243, + 157, 6, 72, 11, 11, 32, 8, 162, 4, 78, 254, 149, 28, 87, 199, 166, 1, 83, + 19, 38, 32, 49, 5, 65, 83, 65, 76, 32, 8, 202, 3, 77, 254, 149, 28, 87, + 199, 166, 1, 83, 8, 218, 191, 29, 65, 2, 73, 2, 79, 3, 85, 11, 158, 190, + 29, 79, 146, 1, 65, 2, 85, 3, 87, 9, 52, 7, 69, 82, 78, 73, 78, 32, 65, + 235, 238, 28, 32, 4, 198, 190, 29, 77, 3, 78, 11, 172, 160, 23, 6, 79, + 77, 65, 78, 73, 65, 162, 224, 5, 32, 223, 61, 72, 49, 58, 32, 164, 1, 5, + 76, 79, 65, 78, 32, 211, 182, 6, 72, 26, 102, 74, 22, 75, 2, 80, 2, 84, + 20, 7, 87, 73, 84, 72, 32, 68, 79, 154, 188, 29, 77, 2, 78, 3, 83, 5, + 227, 254, 28, 32, 5, 207, 131, 29, 32, 4, 243, 155, 13, 84, 18, 74, 69, + 250, 201, 5, 79, 226, 161, 23, 65, 210, 78, 68, 146, 1, 74, 3, 85, 6, + 182, 187, 29, 69, 2, 72, 3, 78, 9, 26, 32, 251, 186, 29, 72, 4, 218, 187, + 25, 82, 159, 255, 3, 83, 9, 242, 234, 28, 32, 226, 79, 72, 3, 73, 5, 245, + 156, 7, 4, 79, 67, 65, 76, 17, 66, 79, 234, 128, 29, 32, 134, 37, 69, + 218, 19, 65, 2, 72, 3, 73, 5, 195, 185, 29, 87, 142, 29, 234, 2, 65, 188, + 3, 10, 68, 73, 84, 79, 82, 73, 65, 76, 32, 67, 22, 71, 188, 75, 4, 73, + 71, 72, 84, 146, 2, 76, 194, 9, 77, 214, 5, 78, 246, 3, 79, 36, 2, 81, + 85, 182, 8, 82, 246, 1, 83, 118, 84, 242, 31, 85, 226, 1, 88, 128, 5, 2, + 89, 69, 204, 86, 4, 45, 77, 65, 73, 168, 223, 19, 3, 74, 69, 67, 208, + 154, 2, 8, 86, 69, 82, 71, 82, 69, 69, 78, 147, 205, 5, 80, 22, 38, 82, + 194, 203, 27, 83, 223, 67, 71, 19, 30, 32, 137, 1, 2, 84, 72, 6, 88, 3, + 79, 70, 32, 209, 232, 4, 13, 87, 73, 84, 72, 32, 72, 69, 65, 82, 73, 78, + 71, 32, 4, 232, 234, 11, 2, 77, 65, 151, 139, 7, 82, 11, 17, 2, 32, 71, + 8, 44, 5, 76, 79, 66, 69, 32, 231, 247, 25, 82, 6, 70, 65, 237, 194, 22, + 11, 69, 85, 82, 79, 80, 69, 45, 65, 70, 82, 73, 4, 180, 179, 10, 4, 77, + 69, 82, 73, 217, 168, 2, 11, 83, 73, 65, 45, 65, 85, 83, 84, 82, 65, 76, + 2, 163, 178, 2, 79, 176, 17, 112, 18, 89, 80, 84, 73, 65, 78, 32, 72, 73, + 69, 82, 79, 71, 76, 89, 80, 72, 32, 178, 212, 2, 69, 203, 221, 26, 71, + 172, 17, 146, 3, 65, 178, 4, 66, 52, 2, 67, 48, 224, 1, 2, 68, 48, 170, + 4, 69, 178, 3, 70, 164, 4, 2, 71, 48, 210, 3, 72, 214, 1, 73, 238, 2, 76, + 122, 77, 222, 8, 78, 210, 5, 79, 140, 5, 2, 80, 48, 120, 2, 82, 48, 232, + 1, 2, 83, 48, 190, 3, 84, 220, 2, 2, 85, 48, 250, 2, 86, 134, 5, 87, 236, + 2, 3, 88, 48, 48, 88, 3, 89, 48, 48, 84, 2, 90, 48, 192, 185, 12, 3, 75, + 48, 48, 193, 133, 7, 3, 81, 48, 48, 228, 1, 30, 48, 133, 3, 2, 65, 48, + 160, 1, 86, 48, 98, 49, 102, 52, 166, 55, 51, 222, 200, 21, 55, 146, 232, + 1, 50, 2, 53, 3, 54, 24, 170, 68, 54, 206, 209, 24, 53, 234, 151, 4, 49, + 2, 50, 2, 51, 2, 52, 2, 55, 2, 56, 3, 57, 24, 150, 149, 25, 52, 2, 55, + 234, 151, 4, 48, 2, 49, 2, 50, 2, 51, 2, 53, 2, 54, 2, 56, 3, 57, 28, + 178, 148, 25, 48, 2, 50, 2, 51, 2, 53, 234, 151, 4, 49, 2, 52, 2, 54, 2, + 55, 2, 56, 3, 57, 68, 46, 48, 246, 54, 51, 138, 176, 23, 49, 3, 50, 22, + 210, 65, 55, 182, 233, 28, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 56, + 3, 57, 26, 148, 9, 4, 69, 71, 73, 78, 185, 25, 2, 48, 48, 56, 34, 48, 90, + 49, 131, 153, 9, 50, 24, 230, 39, 50, 242, 129, 29, 49, 2, 51, 2, 52, 2, + 53, 2, 54, 2, 55, 2, 56, 3, 57, 22, 150, 145, 25, 48, 234, 151, 4, 49, 2, + 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 184, 1, 70, 48, 94, + 51, 102, 52, 102, 53, 106, 54, 194, 29, 50, 251, 194, 23, 49, 20, 230, + 143, 25, 56, 234, 151, 4, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, + 3, 57, 24, 138, 143, 25, 49, 2, 52, 234, 151, 4, 48, 2, 50, 2, 51, 2, 53, + 2, 54, 2, 55, 2, 56, 3, 57, 24, 166, 142, 25, 54, 2, 56, 234, 151, 4, 48, + 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 55, 3, 57, 42, 214, 60, 48, 238, + 208, 24, 50, 2, 52, 234, 151, 4, 49, 2, 51, 2, 53, 2, 54, 2, 55, 2, 56, + 3, 57, 32, 194, 60, 55, 130, 232, 28, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, + 53, 3, 54, 94, 30, 48, 189, 2, 2, 78, 68, 88, 38, 48, 94, 50, 102, 51, + 215, 7, 49, 22, 194, 139, 25, 56, 2, 57, 234, 151, 4, 49, 2, 50, 2, 51, + 2, 52, 2, 53, 2, 54, 3, 55, 24, 230, 138, 25, 48, 2, 56, 234, 151, 4, 49, + 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, 57, 18, 130, 138, 25, 52, + 234, 151, 4, 48, 2, 49, 2, 50, 2, 51, 2, 54, 2, 55, 3, 56, 6, 11, 32, 6, + 172, 186, 5, 6, 87, 65, 76, 76, 69, 68, 210, 19, 69, 179, 177, 21, 83, + 132, 1, 42, 48, 133, 9, 5, 85, 76, 76, 32, 66, 130, 1, 54, 48, 94, 49, + 102, 51, 102, 52, 102, 53, 215, 1, 50, 20, 238, 135, 25, 49, 234, 151, 4, + 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 22, 146, 135, 25, + 51, 234, 151, 4, 48, 2, 49, 2, 50, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, + 57, 26, 174, 134, 25, 49, 2, 55, 2, 56, 234, 151, 4, 48, 2, 50, 2, 51, 2, + 52, 2, 53, 2, 54, 3, 57, 26, 202, 133, 25, 53, 2, 54, 2, 55, 234, 151, 4, + 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 56, 3, 57, 14, 222, 26, 49, 242, 129, + 29, 48, 2, 50, 3, 51, 128, 1, 62, 48, 98, 49, 102, 51, 102, 52, 210, 27, + 50, 231, 237, 8, 53, 24, 166, 50, 55, 206, 209, 24, 54, 234, 151, 4, 49, + 2, 50, 2, 51, 2, 52, 2, 53, 2, 56, 3, 57, 22, 146, 131, 25, 49, 234, 151, + 4, 48, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 24, 174, + 130, 25, 54, 2, 55, 234, 151, 4, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, + 2, 56, 3, 57, 24, 202, 129, 25, 51, 2, 53, 234, 151, 4, 48, 2, 49, 2, 50, + 2, 52, 2, 54, 2, 55, 2, 56, 3, 57, 24, 80, 2, 48, 48, 84, 4, 65, 76, 70, + 32, 161, 40, 7, 79, 82, 73, 90, 79, 78, 84, 18, 146, 128, 25, 54, 234, + 151, 4, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 55, 3, 56, 4, 22, 66, 255, 42, + 76, 2, 251, 189, 17, 76, 52, 58, 48, 181, 1, 9, 78, 83, 69, 82, 84, 32, + 65, 84, 32, 38, 18, 48, 95, 49, 22, 194, 254, 24, 53, 2, 57, 234, 151, 4, + 49, 2, 50, 2, 51, 2, 52, 2, 54, 2, 55, 3, 56, 16, 230, 253, 24, 48, 2, + 49, 234, 151, 4, 50, 2, 51, 2, 52, 3, 53, 14, 68, 6, 66, 79, 84, 84, 79, + 77, 0, 3, 84, 79, 80, 139, 170, 20, 77, 7, 11, 32, 4, 162, 132, 28, 69, + 249, 8, 2, 83, 84, 22, 32, 2, 48, 48, 143, 171, 16, 79, 20, 130, 252, 24, + 50, 2, 54, 234, 151, 4, 49, 2, 51, 2, 52, 2, 53, 2, 55, 3, 56, 164, 1, + 118, 48, 128, 4, 15, 79, 68, 73, 70, 73, 69, 82, 32, 68, 65, 77, 65, 71, + 69, 68, 137, 199, 25, 5, 73, 82, 82, 79, 82, 132, 1, 42, 48, 98, 49, 106, + 50, 102, 51, 107, 52, 24, 182, 40, 49, 206, 209, 24, 51, 234, 151, 4, 50, + 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 44, 138, 41, 50, 154, 208, 24, + 48, 2, 53, 2, 54, 2, 55, 234, 151, 4, 49, 2, 51, 2, 52, 2, 56, 3, 57, 26, + 186, 248, 24, 50, 2, 52, 2, 56, 234, 151, 4, 48, 2, 49, 2, 51, 2, 53, 2, + 54, 2, 55, 3, 57, 26, 138, 38, 51, 206, 209, 24, 49, 234, 151, 4, 48, 2, + 50, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 12, 238, 246, 24, 48, 234, + 151, 4, 49, 2, 50, 2, 51, 3, 52, 31, 25, 4, 32, 65, 84, 32, 28, 96, 6, + 66, 79, 84, 84, 79, 77, 120, 5, 83, 84, 65, 82, 84, 68, 3, 84, 79, 80, + 207, 251, 27, 69, 11, 11, 32, 8, 56, 5, 83, 84, 65, 82, 84, 186, 1, 65, + 139, 251, 27, 69, 5, 129, 2, 8, 32, 65, 78, 68, 32, 84, 79, 80, 7, 29, 5, + 32, 65, 78, 68, 32, 4, 238, 151, 25, 66, 131, 251, 2, 84, 11, 11, 32, 8, + 54, 65, 20, 5, 83, 84, 65, 82, 84, 247, 250, 27, 69, 2, 73, 2, 78, 68, 5, + 53, 11, 32, 65, 78, 68, 32, 66, 79, 84, 84, 79, 77, 2, 175, 167, 20, 32, + 194, 1, 50, 48, 128, 2, 2, 76, 48, 229, 1, 2, 85, 48, 98, 58, 49, 98, 51, + 194, 14, 50, 150, 6, 52, 139, 174, 23, 48, 24, 146, 32, 56, 182, 233, 28, + 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, 57, 28, 254, 240, + 24, 51, 2, 52, 2, 53, 2, 55, 234, 151, 4, 48, 2, 49, 2, 50, 2, 54, 2, 56, + 3, 57, 44, 34, 48, 94, 49, 235, 218, 21, 50, 20, 246, 239, 24, 53, 234, + 151, 4, 49, 2, 50, 2, 51, 2, 52, 2, 54, 2, 55, 2, 56, 3, 57, 22, 154, + 239, 24, 55, 234, 151, 4, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, + 2, 56, 3, 57, 52, 34, 49, 102, 50, 143, 191, 23, 48, 26, 146, 238, 24, + 48, 2, 49, 2, 56, 234, 151, 4, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, + 57, 8, 174, 237, 24, 50, 234, 151, 4, 48, 3, 49, 152, 1, 50, 48, 205, + 204, 19, 6, 86, 69, 82, 76, 65, 89, 150, 1, 66, 48, 154, 1, 49, 138, 1, + 50, 102, 51, 106, 53, 247, 187, 23, 52, 34, 90, 54, 170, 235, 24, 49, 2, + 53, 234, 151, 4, 50, 2, 51, 2, 52, 2, 55, 2, 56, 3, 57, 15, 142, 131, 29, + 65, 2, 66, 2, 67, 2, 68, 2, 69, 3, 70, 28, 98, 48, 138, 234, 24, 57, 234, + 151, 4, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, 56, 9, 238, 129, + 29, 65, 2, 66, 3, 67, 28, 226, 233, 24, 48, 2, 52, 2, 53, 2, 57, 234, + 151, 4, 49, 2, 50, 2, 51, 2, 54, 2, 55, 3, 56, 32, 134, 23, 54, 250, 209, + 24, 48, 2, 51, 234, 151, 4, 49, 2, 50, 2, 52, 2, 53, 2, 55, 2, 56, 3, 57, + 8, 202, 22, 48, 183, 233, 28, 49, 26, 26, 48, 227, 230, 8, 49, 22, 218, + 231, 24, 49, 2, 51, 234, 151, 4, 50, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, + 3, 57, 68, 34, 48, 98, 49, 219, 185, 23, 50, 24, 142, 21, 51, 206, 209, + 24, 50, 234, 151, 4, 49, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 24, + 250, 229, 24, 48, 2, 54, 234, 151, 4, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, + 55, 2, 56, 3, 57, 108, 50, 48, 94, 49, 106, 50, 98, 51, 243, 129, 20, 52, + 22, 226, 228, 24, 50, 2, 54, 234, 151, 4, 49, 2, 51, 2, 52, 2, 53, 2, 55, + 2, 56, 3, 57, 26, 186, 18, 52, 206, 209, 24, 55, 234, 151, 4, 48, 2, 49, + 2, 50, 2, 51, 2, 53, 2, 54, 2, 56, 3, 57, 24, 210, 17, 54, 182, 233, 28, + 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 55, 2, 56, 3, 57, 22, 190, 226, + 24, 53, 234, 151, 4, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 54, 2, 55, 2, 56, + 3, 57, 90, 34, 48, 249, 12, 3, 65, 76, 76, 88, 42, 48, 94, 49, 102, 51, + 171, 179, 23, 50, 26, 138, 225, 24, 51, 2, 55, 2, 56, 2, 57, 234, 151, 4, + 49, 2, 50, 2, 52, 2, 53, 3, 54, 24, 174, 224, 24, 49, 2, 54, 234, 151, 4, + 48, 2, 50, 2, 51, 2, 52, 2, 53, 2, 55, 2, 56, 3, 57, 18, 202, 223, 24, + 50, 2, 51, 234, 151, 4, 48, 2, 49, 2, 52, 2, 53, 3, 54, 94, 50, 48, 90, + 50, 102, 51, 102, 52, 139, 176, 23, 49, 22, 254, 12, 54, 182, 233, 28, + 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 55, 2, 56, 3, 57, 24, 242, 221, 24, + 51, 2, 57, 234, 151, 4, 48, 2, 49, 2, 50, 2, 52, 2, 53, 2, 54, 2, 55, 3, + 56, 22, 142, 221, 24, 50, 234, 151, 4, 48, 2, 49, 2, 51, 2, 52, 2, 53, 2, + 54, 2, 55, 2, 56, 3, 57, 6, 146, 244, 28, 48, 2, 49, 3, 50, 158, 1, 42, + 48, 185, 4, 5, 69, 82, 84, 73, 67, 156, 1, 62, 48, 98, 49, 98, 50, 210, + 1, 51, 133, 216, 24, 2, 52, 48, 42, 198, 9, 55, 98, 49, 238, 208, 24, 50, + 234, 151, 4, 51, 2, 52, 2, 53, 2, 54, 2, 56, 3, 57, 32, 186, 8, 49, 46, + 50, 182, 233, 28, 48, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, + 50, 98, 48, 242, 216, 24, 51, 2, 56, 2, 57, 234, 151, 4, 49, 2, 50, 2, + 52, 2, 53, 2, 54, 3, 55, 27, 214, 240, 28, 65, 2, 66, 2, 67, 2, 68, 2, + 69, 2, 70, 2, 71, 2, 72, 2, 73, 2, 74, 2, 75, 3, 76, 28, 130, 216, 24, + 48, 2, 49, 2, 51, 2, 55, 234, 151, 4, 50, 2, 52, 2, 53, 2, 54, 2, 56, 3, + 57, 2, 157, 186, 24, 2, 65, 76, 66, 34, 48, 161, 2, 3, 73, 68, 69, 64, + 26, 48, 94, 49, 103, 50, 22, 194, 214, 24, 51, 2, 57, 234, 151, 4, 49, 2, + 50, 2, 52, 2, 53, 2, 54, 2, 55, 3, 56, 28, 230, 213, 24, 48, 2, 52, 2, + 55, 2, 56, 234, 151, 4, 49, 2, 50, 2, 51, 2, 53, 2, 54, 3, 57, 14, 130, + 213, 24, 52, 234, 151, 4, 48, 2, 49, 2, 50, 2, 51, 3, 53, 2, 17, 2, 32, + 76, 2, 179, 131, 16, 79, 24, 202, 2, 52, 206, 209, 24, 54, 2, 56, 234, + 151, 4, 49, 2, 50, 2, 51, 2, 53, 3, 55, 18, 190, 211, 24, 49, 234, 151, + 4, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, 56, 82, 22, 48, 167, 1, 49, + 34, 90, 50, 46, 51, 206, 209, 24, 52, 2, 53, 234, 151, 4, 49, 2, 54, 2, + 55, 2, 56, 3, 57, 11, 222, 233, 28, 65, 2, 66, 2, 67, 3, 68, 7, 178, 233, + 28, 65, 3, 66, 48, 66, 53, 86, 54, 130, 232, 28, 48, 2, 49, 2, 50, 2, 51, + 3, 52, 21, 210, 232, 28, 65, 2, 66, 2, 67, 2, 68, 2, 69, 2, 70, 2, 71, 2, + 72, 3, 73, 19, 254, 231, 28, 65, 2, 66, 2, 67, 2, 68, 2, 69, 2, 70, 2, + 71, 3, 72, 18, 26, 32, 187, 181, 16, 72, 16, 70, 80, 124, 5, 82, 65, 89, + 83, 32, 182, 152, 3, 84, 143, 178, 23, 83, 8, 178, 152, 3, 79, 193, 141, + 17, 22, 69, 84, 65, 76, 76, 69, 68, 32, 79, 85, 84, 76, 73, 78, 69, 68, + 32, 66, 76, 65, 67, 75, 4, 192, 196, 19, 2, 73, 78, 1, 3, 79, 85, 84, + 160, 1, 132, 1, 13, 66, 65, 83, 65, 78, 32, 76, 69, 84, 84, 69, 82, 32, + 166, 3, 69, 176, 4, 7, 89, 77, 65, 73, 67, 32, 76, 199, 220, 28, 70, 80, + 230, 1, 71, 78, 76, 34, 78, 50, 82, 178, 209, 26, 69, 198, 143, 1, 67, 2, + 68, 2, 75, 2, 83, 2, 84, 2, 90, 206, 105, 66, 2, 70, 2, 72, 2, 74, 2, 77, + 2, 80, 2, 81, 2, 86, 2, 88, 214, 22, 65, 2, 73, 2, 79, 2, 85, 3, 89, 8, + 38, 72, 182, 203, 28, 74, 215, 22, 69, 4, 194, 136, 26, 65, 199, 217, 2, + 69, 4, 142, 203, 28, 76, 215, 22, 69, 8, 238, 202, 28, 68, 2, 74, 214, + 22, 65, 3, 69, 4, 190, 202, 28, 82, 215, 22, 69, 32, 96, 5, 67, 84, 82, + 73, 67, 160, 1, 7, 77, 69, 78, 84, 32, 79, 70, 238, 210, 27, 80, 135, 83, + 86, 10, 26, 32, 135, 232, 24, 65, 8, 98, 80, 160, 163, 18, 2, 84, 79, + 244, 250, 8, 9, 76, 73, 71, 72, 84, 32, 66, 85, 76, 135, 36, 65, 2, 11, + 76, 2, 175, 222, 28, 85, 19, 11, 32, 16, 72, 5, 87, 73, 84, 72, 32, 253, + 162, 17, 7, 79, 80, 69, 78, 73, 78, 71, 12, 130, 1, 76, 32, 12, 84, 87, + 79, 32, 72, 79, 82, 73, 90, 79, 78, 84, 194, 175, 20, 86, 194, 185, 4, + 85, 246, 61, 79, 183, 181, 2, 68, 2, 129, 177, 26, 3, 79, 78, 71, 2, 129, + 167, 15, 7, 65, 76, 32, 83, 84, 82, 79, 46, 214, 176, 4, 69, 245, 155, + 16, 15, 73, 71, 65, 84, 85, 82, 69, 32, 90, 65, 89, 73, 78, 45, 89, 53, + 48, 4, 79, 74, 73, 32, 218, 2, 80, 163, 3, 32, 18, 164, 1, 10, 67, 79, + 77, 80, 79, 78, 69, 78, 84, 32, 109, 26, 77, 79, 68, 73, 70, 73, 69, 82, + 32, 70, 73, 84, 90, 80, 65, 84, 82, 73, 67, 75, 32, 84, 89, 80, 69, 45, + 8, 184, 208, 15, 2, 82, 69, 12, 5, 67, 85, 82, 76, 89, 0, 5, 87, 72, 73, + 84, 69, 173, 210, 2, 2, 66, 65, 10, 160, 172, 21, 2, 49, 45, 250, 172, 7, + 51, 2, 52, 2, 53, 3, 54, 26, 44, 3, 84, 89, 32, 177, 251, 3, 2, 72, 65, + 24, 82, 78, 60, 3, 80, 65, 71, 20, 3, 83, 69, 84, 209, 147, 28, 4, 68, + 79, 67, 85, 8, 36, 3, 79, 84, 69, 203, 228, 24, 69, 7, 195, 237, 13, 32, + 4, 167, 202, 26, 69, 11, 33, 6, 32, 87, 73, 84, 72, 32, 8, 234, 210, 14, + 82, 24, 3, 76, 69, 70, 208, 167, 1, 2, 83, 77, 143, 166, 9, 79, 38, 86, + 32, 64, 2, 68, 32, 214, 1, 81, 20, 6, 86, 69, 76, 79, 80, 69, 147, 175, + 16, 84, 6, 42, 81, 226, 230, 26, 68, 131, 176, 1, 83, 2, 223, 142, 28, + 85, 20, 32, 3, 79, 70, 32, 131, 1, 87, 18, 88, 3, 80, 82, 79, 190, 185, + 21, 71, 56, 2, 83, 69, 166, 71, 77, 30, 84, 139, 183, 5, 76, 4, 254, 185, + 21, 84, 215, 152, 6, 79, 2, 249, 200, 20, 7, 73, 84, 72, 32, 76, 69, 70, + 5, 183, 129, 22, 85, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 42, 76, 217, + 206, 24, 4, 68, 79, 87, 78, 2, 185, 172, 23, 4, 73, 71, 72, 84, 6, 154, + 210, 28, 76, 2, 77, 3, 84, 46, 28, 2, 65, 76, 231, 6, 73, 40, 30, 32, + 133, 2, 2, 83, 32, 12, 56, 3, 84, 79, 32, 173, 226, 13, 5, 65, 78, 68, + 32, 80, 10, 68, 3, 79, 82, 32, 249, 254, 27, 8, 66, 89, 32, 68, 69, 70, + 73, 78, 8, 64, 3, 80, 82, 69, 28, 3, 83, 85, 67, 194, 182, 26, 71, 39, + 76, 2, 165, 238, 15, 2, 67, 69, 2, 133, 234, 26, 3, 67, 69, 69, 28, 72, + 4, 83, 73, 71, 78, 128, 180, 26, 4, 87, 73, 84, 72, 231, 202, 1, 67, 25, + 11, 32, 22, 42, 65, 201, 1, 5, 87, 73, 84, 72, 32, 12, 112, 5, 66, 79, + 86, 69, 32, 65, 19, 78, 68, 32, 83, 76, 65, 78, 84, 69, 68, 32, 80, 65, + 82, 65, 76, 76, 69, 76, 8, 246, 223, 21, 80, 210, 5, 84, 230, 188, 2, 76, + 215, 136, 3, 82, 5, 171, 133, 7, 32, 10, 160, 1, 4, 66, 85, 77, 80, 20, + 7, 73, 78, 70, 73, 78, 73, 84, 20, 18, 84, 87, 79, 32, 68, 79, 84, 83, + 32, 65, 66, 79, 86, 69, 32, 65, 78, 68, 187, 238, 15, 68, 2, 191, 206, + 27, 89, 4, 251, 165, 26, 89, 2, 17, 2, 32, 84, 2, 191, 149, 26, 87, 6, + 80, 7, 86, 65, 76, 69, 78, 84, 32, 201, 227, 21, 7, 65, 78, 71, 85, 76, + 65, 82, 4, 48, 6, 87, 73, 84, 72, 32, 70, 251, 170, 28, 84, 2, 11, 79, 2, + 213, 248, 2, 2, 85, 82, 22, 116, 3, 65, 83, 69, 60, 11, 82, 79, 82, 45, + 66, 65, 82, 82, 69, 68, 32, 185, 171, 5, 7, 73, 83, 32, 70, 79, 82, 77, + 6, 136, 188, 13, 6, 32, 84, 79, 32, 84, 72, 195, 140, 15, 82, 12, 216, + 228, 5, 4, 87, 72, 73, 84, 13, 5, 66, 76, 65, 67, 75, 10, 58, 67, 20, 6, + 84, 73, 77, 65, 84, 69, 131, 199, 28, 65, 5, 195, 250, 26, 65, 4, 186, + 177, 27, 68, 199, 149, 1, 83, 154, 8, 60, 7, 72, 73, 79, 80, 73, 67, 32, + 154, 198, 28, 66, 3, 88, 150, 8, 204, 1, 2, 67, 79, 232, 1, 7, 78, 85, + 77, 66, 69, 82, 32, 114, 80, 54, 83, 156, 24, 11, 84, 79, 78, 65, 76, 32, + 77, 65, 82, 75, 32, 146, 214, 19, 68, 222, 249, 5, 70, 82, 81, 169, 154, + 2, 4, 87, 79, 82, 68, 10, 26, 77, 191, 244, 27, 76, 8, 52, 7, 66, 73, 78, + 73, 78, 71, 32, 187, 193, 28, 77, 6, 60, 11, 71, 69, 77, 73, 78, 65, 84, + 73, 79, 78, 32, 51, 86, 4, 44, 5, 65, 78, 68, 32, 86, 215, 129, 28, 77, + 2, 137, 221, 24, 4, 79, 87, 69, 76, 22, 66, 84, 142, 224, 22, 72, 182, + 237, 3, 69, 30, 70, 42, 78, 39, 83, 8, 210, 154, 17, 69, 158, 180, 9, 72, + 27, 87, 4, 190, 119, 65, 133, 250, 26, 5, 82, 69, 70, 65, 67, 198, 7, 50, + 69, 37, 8, 89, 76, 76, 65, 66, 76, 69, 32, 4, 138, 237, 24, 77, 207, 234, + 2, 67, 194, 7, 210, 1, 66, 90, 67, 246, 1, 68, 186, 1, 70, 90, 71, 214, + 2, 72, 162, 1, 75, 102, 77, 90, 78, 90, 80, 138, 2, 81, 174, 1, 82, 86, + 83, 210, 1, 84, 122, 74, 2, 76, 138, 1, 87, 2, 89, 66, 88, 134, 1, 90, + 95, 86, 38, 194, 12, 87, 230, 8, 66, 246, 145, 24, 65, 2, 79, 202, 215, + 3, 69, 162, 64, 73, 3, 85, 78, 94, 67, 254, 15, 72, 234, 149, 24, 65, 2, + 79, 202, 215, 3, 69, 234, 61, 87, 186, 2, 73, 3, 85, 42, 70, 72, 158, + 165, 24, 65, 202, 215, 3, 69, 162, 64, 73, 2, 79, 3, 85, 28, 166, 19, 72, + 246, 145, 24, 65, 202, 215, 3, 69, 162, 64, 73, 2, 79, 3, 85, 60, 94, 68, + 214, 14, 90, 158, 149, 24, 65, 2, 79, 202, 215, 3, 69, 234, 61, 87, 186, + 2, 73, 3, 85, 30, 210, 14, 72, 158, 149, 24, 65, 2, 79, 202, 215, 3, 69, + 234, 61, 87, 186, 2, 73, 3, 85, 24, 190, 8, 87, 218, 154, 24, 65, 202, + 215, 3, 69, 234, 61, 89, 186, 2, 73, 2, 79, 3, 85, 118, 142, 1, 85, 226, + 7, 71, 232, 3, 7, 76, 79, 84, 84, 65, 76, 32, 158, 2, 87, 218, 1, 89, + 246, 145, 24, 65, 2, 79, 202, 215, 3, 69, 163, 64, 73, 39, 29, 5, 82, 65, + 71, 69, 32, 36, 74, 66, 2, 70, 2, 77, 2, 80, 46, 71, 2, 75, 2, 81, 143, + 215, 12, 72, 4, 11, 87, 4, 202, 161, 28, 69, 215, 22, 73, 6, 11, 87, 6, + 210, 247, 27, 69, 163, 64, 73, 52, 70, 72, 166, 159, 24, 65, 2, 79, 202, + 215, 3, 69, 162, 64, 73, 3, 85, 36, 202, 4, 87, 230, 8, 89, 246, 145, 24, + 65, 202, 215, 3, 69, 162, 64, 73, 2, 79, 3, 85, 64, 250, 4, 88, 134, 6, + 87, 218, 1, 89, 246, 145, 24, 65, 2, 79, 202, 215, 3, 69, 162, 64, 73, 3, + 85, 26, 142, 3, 87, 218, 154, 24, 65, 2, 79, 202, 215, 3, 69, 234, 61, + 89, 186, 2, 73, 3, 85, 36, 166, 7, 89, 234, 149, 24, 65, 2, 79, 202, 215, + 3, 69, 234, 61, 87, 186, 2, 73, 3, 85, 56, 82, 72, 142, 1, 87, 218, 154, + 24, 65, 2, 79, 202, 215, 3, 69, 162, 64, 73, 3, 85, 32, 74, 65, 154, 155, + 24, 79, 202, 215, 3, 69, 234, 61, 87, 186, 2, 73, 3, 85, 19, 160, 9, 8, + 82, 89, 78, 71, 69, 65, 76, 32, 223, 169, 28, 65, 8, 158, 242, 27, 69, + 162, 64, 65, 3, 73, 64, 94, 72, 134, 6, 87, 218, 1, 89, 246, 145, 24, 65, + 2, 79, 202, 215, 3, 69, 162, 64, 73, 3, 85, 24, 130, 6, 87, 206, 147, 24, + 65, 202, 215, 3, 69, 162, 64, 73, 2, 79, 3, 85, 20, 130, 153, 24, 65, 2, + 79, 202, 215, 3, 69, 234, 61, 87, 2, 89, 186, 2, 73, 3, 85, 74, 102, 69, + 226, 1, 72, 170, 3, 90, 78, 83, 246, 145, 24, 65, 2, 79, 178, 149, 4, 87, + 186, 2, 73, 3, 85, 13, 56, 8, 66, 65, 84, 66, 69, 73, 84, 32, 247, 174, + 28, 69, 8, 166, 175, 23, 66, 2, 70, 2, 77, 3, 80, 80, 118, 72, 76, 2, 84, + 72, 62, 90, 162, 2, 83, 194, 146, 24, 65, 2, 79, 202, 215, 3, 69, 234, + 61, 87, 186, 2, 73, 3, 85, 18, 230, 149, 24, 65, 2, 79, 202, 215, 3, 69, + 234, 61, 87, 186, 2, 73, 3, 85, 12, 226, 236, 27, 69, 234, 61, 65, 186, + 2, 73, 2, 79, 3, 85, 16, 222, 148, 24, 65, 2, 79, 202, 215, 3, 69, 162, + 64, 73, 3, 85, 40, 82, 87, 218, 1, 89, 246, 145, 24, 65, 2, 79, 202, 215, + 3, 69, 162, 64, 73, 3, 85, 10, 202, 147, 24, 65, 202, 215, 3, 69, 163, + 64, 73, 48, 90, 72, 78, 90, 246, 145, 24, 65, 2, 79, 202, 215, 3, 69, + 234, 61, 87, 186, 2, 73, 3, 85, 16, 190, 146, 24, 65, 202, 215, 3, 69, + 234, 61, 87, 186, 2, 73, 2, 79, 3, 85, 14, 242, 145, 24, 65, 202, 215, 3, + 69, 162, 64, 73, 2, 79, 3, 85, 20, 130, 1, 68, 74, 72, 30, 75, 42, 82, 0, + 7, 83, 72, 79, 82, 84, 32, 82, 224, 149, 4, 3, 67, 72, 73, 149, 220, 23, + 3, 89, 73, 90, 6, 48, 4, 69, 82, 69, 84, 181, 158, 27, 2, 73, 70, 5, 17, + 2, 45, 72, 2, 181, 242, 27, 2, 73, 68, 4, 128, 158, 27, 2, 69, 78, 163, + 2, 85, 2, 141, 164, 4, 3, 73, 75, 82, 12, 96, 2, 82, 79, 180, 206, 11, 3, + 78, 79, 77, 221, 203, 15, 9, 76, 69, 82, 32, 67, 79, 78, 83, 84, 8, 92, + 5, 80, 69, 65, 78, 32, 216, 234, 24, 8, 45, 67, 85, 82, 82, 69, 78, 67, + 223, 179, 2, 32, 4, 206, 144, 4, 67, 19, 80, 50, 30, 67, 102, 80, 187, 1, + 84, 6, 60, 9, 76, 65, 77, 65, 84, 73, 79, 78, 32, 219, 139, 27, 69, 4, + 202, 203, 25, 81, 183, 151, 2, 77, 10, 96, 7, 76, 79, 83, 73, 79, 78, 32, + 133, 230, 27, 11, 82, 69, 83, 83, 73, 79, 78, 76, 69, 83, 83, 8, 252, + 159, 12, 4, 70, 82, 65, 77, 185, 179, 15, 8, 65, 84, 32, 72, 79, 82, 73, + 90, 34, 98, 82, 209, 141, 22, 18, 69, 78, 68, 69, 68, 32, 65, 82, 65, 66, + 73, 67, 45, 73, 78, 68, 73, 67, 14, 140, 1, 12, 69, 77, 69, 76, 89, 32, + 72, 69, 65, 86, 89, 32, 201, 199, 26, 16, 65, 84, 69, 82, 82, 69, 83, 84, + 82, 73, 65, 76, 32, 65, 76, 73, 12, 50, 83, 182, 131, 26, 70, 234, 2, 87, + 203, 11, 71, 4, 198, 132, 26, 65, 43, 73, 7, 238, 128, 20, 71, 159, 159, + 8, 83, 154, 4, 142, 1, 65, 146, 19, 69, 190, 1, 73, 134, 8, 76, 138, 6, + 79, 146, 7, 82, 130, 5, 85, 248, 145, 21, 2, 86, 83, 146, 206, 4, 83, + 231, 143, 2, 70, 94, 122, 67, 194, 15, 76, 176, 2, 2, 88, 32, 234, 147, + 3, 77, 172, 168, 8, 2, 84, 72, 178, 132, 10, 73, 221, 181, 2, 2, 82, 83, + 72, 88, 2, 69, 32, 252, 255, 16, 4, 83, 73, 77, 73, 234, 178, 3, 73, 245, + 158, 1, 2, 84, 79, 66, 226, 1, 83, 160, 1, 4, 87, 73, 84, 72, 200, 202, + 13, 2, 80, 65, 160, 138, 2, 2, 77, 65, 188, 172, 11, 13, 84, 72, 82, 79, + 87, 73, 78, 71, 32, 65, 32, 75, 73, 201, 1, 14, 72, 79, 76, 68, 73, 78, + 71, 32, 66, 65, 67, 75, 32, 84, 4, 208, 208, 17, 18, 65, 86, 79, 85, 82, + 73, 78, 71, 32, 68, 69, 76, 73, 67, 73, 79, 85, 83, 133, 140, 5, 13, 67, + 82, 69, 65, 77, 73, 78, 71, 32, 73, 78, 32, 70, 54, 38, 32, 209, 240, 24, + 3, 79, 85, 84, 52, 196, 4, 2, 67, 79, 44, 5, 72, 69, 65, 68, 45, 38, 77, + 98, 79, 92, 7, 78, 79, 32, 71, 79, 79, 68, 238, 1, 80, 164, 1, 16, 83, + 84, 85, 67, 75, 45, 79, 85, 84, 32, 84, 79, 78, 71, 85, 69, 110, 84, 140, + 183, 1, 9, 66, 65, 71, 83, 32, 85, 78, 68, 69, 152, 242, 17, 22, 70, 73, + 78, 71, 69, 82, 32, 67, 79, 86, 69, 82, 73, 78, 71, 32, 67, 76, 79, 83, + 69, 68, 212, 67, 3, 82, 79, 76, 208, 233, 1, 13, 76, 79, 79, 75, 32, 79, + 70, 32, 84, 82, 73, 85, 77, 184, 143, 3, 8, 68, 73, 65, 71, 79, 78, 65, + 76, 1, 20, 85, 78, 69, 86, 69, 78, 32, 69, 89, 69, 83, 32, 65, 78, 68, + 32, 87, 65, 86, 89, 4, 252, 4, 3, 87, 66, 79, 199, 237, 19, 76, 2, 201, + 255, 22, 4, 66, 65, 78, 68, 4, 60, 6, 69, 68, 73, 67, 65, 76, 233, 188, + 26, 3, 79, 78, 79, 2, 253, 201, 26, 3, 32, 77, 65, 12, 90, 75, 36, 4, 80, + 69, 78, 32, 213, 252, 20, 10, 78, 69, 32, 69, 89, 69, 66, 82, 79, 87, 2, + 201, 238, 22, 4, 32, 71, 69, 83, 8, 116, 5, 77, 79, 85, 84, 72, 225, 232, + 24, 18, 69, 89, 69, 83, 32, 65, 78, 68, 32, 72, 65, 78, 68, 32, 79, 86, + 69, 82, 7, 11, 32, 4, 152, 172, 10, 3, 86, 79, 77, 225, 194, 9, 5, 65, + 78, 68, 32, 67, 6, 132, 1, 18, 65, 82, 84, 89, 32, 72, 79, 82, 78, 32, + 65, 78, 68, 32, 80, 65, 82, 84, 100, 2, 69, 69, 169, 237, 19, 4, 76, 69, + 65, 68, 2, 181, 152, 23, 2, 89, 32, 7, 29, 5, 32, 65, 78, 68, 32, 4, 36, + 3, 87, 73, 78, 203, 237, 19, 84, 2, 233, 182, 1, 4, 75, 73, 78, 71, 4, + 50, 69, 149, 156, 23, 6, 72, 69, 82, 77, 79, 77, 2, 245, 252, 27, 8, 65, + 82, 83, 32, 79, 70, 32, 74, 10, 34, 76, 221, 242, 22, 2, 65, 70, 8, 84, + 13, 73, 78, 71, 32, 68, 73, 65, 71, 79, 78, 65, 76, 32, 209, 186, 24, 2, + 69, 78, 6, 128, 1, 9, 67, 82, 79, 83, 83, 73, 78, 71, 32, 193, 128, 20, + 16, 73, 78, 32, 87, 72, 73, 84, 69, 32, 67, 73, 82, 67, 76, 69, 32, 4, + 200, 216, 16, 3, 82, 73, 83, 183, 175, 3, 78, 4, 130, 198, 15, 73, 195, + 145, 4, 77, 14, 50, 65, 50, 77, 44, 2, 82, 82, 151, 178, 19, 78, 4, 180, + 207, 8, 3, 82, 70, 85, 203, 146, 10, 84, 4, 176, 151, 9, 2, 73, 78, 175, + 214, 7, 65, 4, 208, 150, 8, 2, 73, 83, 227, 243, 19, 89, 58, 138, 1, 71, + 90, 76, 178, 1, 78, 98, 82, 182, 2, 83, 164, 14, 4, 86, 69, 32, 68, 201, + 128, 5, 10, 69, 76, 68, 32, 72, 79, 67, 75, 69, 89, 6, 48, 4, 85, 82, 69, + 32, 245, 217, 26, 2, 72, 84, 4, 154, 154, 26, 68, 131, 176, 1, 83, 10, + 32, 2, 69, 32, 65, 2, 77, 32, 6, 170, 139, 14, 70, 208, 156, 2, 3, 67, + 65, 66, 207, 170, 8, 83, 4, 52, 4, 80, 82, 79, 74, 173, 233, 20, 3, 70, + 82, 65, 2, 247, 157, 16, 69, 4, 72, 4, 71, 69, 82, 80, 129, 249, 25, 8, + 73, 84, 69, 32, 80, 65, 82, 84, 2, 231, 209, 16, 82, 22, 34, 69, 189, 1, + 3, 83, 84, 32, 13, 56, 2, 32, 69, 68, 4, 87, 79, 82, 75, 187, 252, 15, + 67, 4, 150, 131, 14, 78, 141, 217, 4, 8, 88, 84, 73, 78, 71, 85, 73, 83, + 4, 168, 146, 24, 6, 32, 83, 80, 65, 82, 75, 199, 242, 3, 83, 10, 170, + 178, 5, 81, 184, 251, 10, 8, 83, 84, 82, 79, 78, 71, 32, 73, 183, 229, 6, + 80, 10, 38, 72, 245, 173, 24, 3, 84, 69, 68, 9, 244, 128, 4, 13, 73, 78, + 71, 32, 80, 79, 76, 69, 32, 65, 78, 68, 32, 146, 242, 5, 69, 189, 137, + 17, 19, 32, 67, 65, 75, 69, 32, 87, 73, 84, 72, 32, 83, 87, 73, 82, 76, + 32, 68, 69, 46, 50, 65, 170, 1, 69, 98, 79, 194, 1, 85, 39, 89, 12, 114, + 84, 232, 166, 4, 5, 80, 80, 73, 78, 71, 184, 188, 3, 6, 71, 32, 73, 78, + 32, 72, 205, 138, 18, 3, 77, 73, 78, 6, 138, 254, 8, 32, 174, 243, 11, + 66, 199, 246, 5, 78, 4, 252, 195, 24, 8, 88, 69, 68, 32, 66, 73, 67, 69, + 237, 145, 1, 7, 85, 82, 45, 68, 69, 45, 76, 12, 52, 2, 82, 65, 20, 3, 87, + 69, 82, 211, 180, 26, 80, 5, 211, 247, 26, 76, 7, 17, 2, 32, 80, 4, 58, + 85, 149, 153, 25, 8, 76, 65, 89, 73, 78, 71, 32, 67, 2, 245, 148, 27, 4, + 78, 67, 84, 85, 4, 138, 158, 3, 83, 171, 201, 24, 84, 15, 25, 4, 73, 78, + 71, 32, 12, 64, 6, 83, 65, 85, 67, 69, 82, 194, 178, 10, 68, 171, 173, + 10, 69, 9, 11, 32, 6, 40, 4, 87, 73, 84, 72, 163, 231, 26, 83, 4, 34, 32, + 1, 4, 79, 85, 84, 32, 2, 21, 3, 66, 69, 65, 2, 179, 190, 27, 77, 56, 102, + 71, 20, 2, 76, 68, 68, 2, 79, 84, 22, 82, 142, 2, 85, 244, 226, 23, 2, + 78, 68, 139, 216, 3, 88, 5, 203, 233, 27, 71, 4, 240, 239, 9, 8, 73, 78, + 71, 32, 72, 65, 78, 68, 179, 210, 17, 69, 5, 215, 228, 14, 80, 18, 78, + 75, 132, 1, 3, 84, 85, 78, 134, 168, 21, 77, 254, 194, 4, 32, 211, 119, + 67, 8, 80, 10, 32, 65, 78, 68, 32, 75, 78, 73, 70, 69, 250, 231, 15, 69, + 151, 192, 11, 73, 5, 197, 162, 16, 7, 32, 87, 73, 84, 72, 32, 80, 4, 160, + 221, 27, 6, 69, 32, 67, 79, 79, 75, 179, 27, 65, 22, 26, 82, 151, 135, + 24, 78, 20, 38, 32, 218, 2, 84, 227, 181, 19, 45, 16, 110, 67, 174, 1, + 68, 226, 169, 2, 66, 252, 226, 10, 7, 76, 69, 65, 70, 32, 67, 76, 162, + 107, 84, 211, 223, 11, 80, 4, 204, 249, 13, 3, 76, 85, 66, 145, 87, 32, + 79, 82, 78, 69, 82, 32, 65, 82, 82, 79, 87, 83, 32, 67, 73, 82, 67, 76, + 73, 78, 71, 32, 65, 78, 84, 73, 67, 76, 79, 67, 75, 87, 4, 21, 3, 79, 84, + 32, 4, 190, 170, 24, 80, 187, 137, 3, 77, 2, 135, 179, 20, 72, 30, 78, + 65, 250, 1, 69, 98, 79, 249, 200, 17, 8, 73, 69, 68, 32, 83, 72, 82, 73, + 12, 96, 6, 67, 84, 73, 79, 78, 32, 68, 8, 77, 69, 32, 87, 73, 84, 72, 32, + 161, 161, 11, 2, 71, 73, 4, 170, 201, 20, 83, 177, 6, 9, 78, 85, 77, 69, + 82, 65, 84, 79, 82, 6, 50, 80, 130, 170, 2, 65, 177, 130, 22, 2, 84, 73, + 2, 141, 206, 22, 2, 73, 67, 6, 48, 6, 78, 67, 72, 32, 70, 82, 255, 211, + 19, 69, 4, 234, 219, 26, 73, 133, 15, 3, 65, 78, 67, 10, 52, 3, 78, 84, + 45, 116, 2, 87, 78, 251, 178, 27, 71, 4, 70, 84, 149, 143, 2, 11, 70, 65, + 67, 73, 78, 71, 32, 66, 65, 66, 89, 2, 137, 134, 13, 6, 73, 76, 84, 69, + 68, 32, 5, 129, 180, 8, 6, 73, 78, 71, 32, 70, 65, 226, 1, 80, 2, 76, 76, + 134, 6, 78, 196, 192, 17, 5, 69, 76, 32, 80, 85, 251, 145, 10, 83, 216, + 1, 42, 32, 73, 6, 87, 73, 68, 84, 72, 32, 10, 206, 211, 12, 77, 252, 167, + 3, 2, 79, 85, 146, 253, 8, 66, 151, 29, 83, 206, 1, 242, 1, 67, 42, 76, + 78, 78, 30, 80, 66, 82, 142, 1, 83, 38, 89, 142, 196, 10, 77, 146, 248, + 10, 65, 158, 2, 68, 58, 69, 70, 71, 118, 72, 202, 4, 81, 226, 153, 2, 87, + 146, 30, 84, 150, 147, 1, 70, 156, 181, 1, 6, 66, 82, 79, 75, 69, 78, + 135, 8, 86, 10, 146, 192, 21, 73, 62, 79, 239, 80, 69, 116, 42, 69, 170, + 195, 21, 65, 183, 186, 4, 79, 10, 162, 1, 70, 155, 197, 21, 83, 4, 246, + 153, 22, 79, 35, 85, 6, 42, 79, 154, 198, 21, 69, 179, 238, 2, 76, 2, + 131, 252, 25, 85, 10, 36, 3, 73, 71, 72, 235, 205, 25, 69, 8, 17, 2, 84, + 32, 8, 136, 253, 20, 5, 87, 72, 73, 84, 69, 234, 220, 2, 67, 210, 3, 80, + 251, 7, 83, 4, 198, 149, 24, 69, 219, 185, 1, 79, 2, 131, 234, 25, 69, 6, + 184, 147, 12, 8, 67, 84, 73, 79, 78, 32, 65, 80, 148, 254, 8, 5, 69, 82, + 65, 76, 32, 171, 188, 1, 78, 130, 21, 114, 65, 218, 6, 69, 222, 22, 73, + 142, 1, 76, 134, 15, 79, 198, 6, 82, 162, 92, 85, 154, 228, 22, 72, 243, + 242, 3, 83, 142, 1, 42, 82, 209, 203, 27, 4, 77, 69, 32, 68, 140, 1, 36, + 3, 65, 89, 32, 251, 187, 26, 76, 138, 1, 166, 1, 67, 178, 1, 83, 192, 2, + 6, 86, 79, 87, 69, 76, 32, 148, 211, 8, 6, 82, 69, 68, 85, 80, 76, 238, + 245, 10, 72, 246, 170, 1, 80, 142, 183, 3, 77, 155, 191, 1, 68, 52, 42, + 79, 173, 1, 5, 65, 80, 73, 84, 65, 8, 92, 8, 78, 83, 79, 78, 65, 78, 84, + 32, 249, 244, 13, 9, 77, 66, 73, 78, 73, 78, 71, 32, 68, 4, 158, 220, 12, + 78, 171, 163, 11, 71, 46, 36, 3, 77, 65, 76, 151, 218, 22, 85, 44, 45, 9, + 76, 32, 76, 69, 84, 84, 69, 82, 32, 44, 200, 1, 4, 79, 76, 68, 32, 242, + 227, 20, 78, 174, 251, 6, 66, 2, 67, 2, 68, 2, 70, 2, 71, 2, 72, 2, 74, + 2, 75, 2, 76, 2, 77, 2, 80, 2, 82, 2, 83, 2, 84, 2, 87, 2, 88, 2, 89, + 187, 2, 65, 4, 154, 223, 27, 75, 3, 78, 12, 44, 5, 83, 73, 71, 78, 32, + 143, 159, 27, 76, 10, 230, 160, 27, 69, 162, 64, 65, 2, 73, 3, 79, 146, + 3, 112, 2, 65, 82, 110, 77, 50, 79, 244, 163, 24, 9, 82, 77, 65, 78, 32, + 80, 69, 78, 78, 182, 181, 2, 84, 239, 105, 78, 7, 29, 5, 32, 87, 73, 84, + 72, 4, 148, 228, 14, 5, 79, 85, 84, 32, 72, 153, 181, 9, 5, 32, 72, 65, + 78, 68, 4, 26, 32, 147, 212, 22, 73, 2, 243, 227, 23, 83, 130, 3, 46, 77, + 245, 5, 6, 82, 71, 73, 65, 78, 32, 38, 92, 13, 65, 78, 84, 73, 67, 32, + 70, 73, 71, 85, 82, 69, 32, 205, 4, 5, 69, 84, 82, 73, 67, 32, 158, 1, + 65, 82, 67, 172, 1, 9, 70, 79, 82, 84, 85, 78, 65, 32, 77, 44, 3, 76, 65, + 69, 0, 4, 84, 82, 73, 83, 34, 80, 80, 3, 82, 85, 66, 167, 129, 11, 86, 6, + 216, 1, 6, 67, 81, 85, 73, 83, 73, 12, 4, 77, 73, 83, 83, 215, 239, 23, + 76, 8, 42, 65, 97, 6, 79, 78, 74, 85, 78, 67, 6, 56, 3, 80, 85, 84, 0, 3, + 85, 68, 65, 187, 130, 19, 82, 2, 129, 90, 5, 32, 68, 82, 65, 67, 2, 11, + 84, 2, 179, 187, 27, 73, 4, 142, 167, 2, 73, 157, 250, 24, 2, 65, 74, 2, + 145, 130, 11, 3, 84, 73, 84, 6, 44, 2, 85, 69, 193, 200, 23, 3, 79, 80, + 85, 4, 254, 182, 27, 76, 155, 34, 82, 2, 251, 204, 25, 69, 6, 152, 208, + 20, 4, 65, 76, 76, 89, 225, 227, 1, 5, 32, 80, 82, 79, 80, 220, 2, 228, + 1, 6, 67, 65, 80, 73, 84, 65, 0, 4, 83, 77, 65, 76, 172, 3, 7, 76, 69, + 84, 84, 69, 82, 32, 180, 2, 24, 77, 84, 65, 86, 82, 85, 76, 73, 32, 67, + 65, 80, 73, 84, 65, 76, 32, 76, 69, 84, 84, 69, 82, 32, 165, 6, 2, 80, + 65, 80, 45, 9, 76, 32, 76, 69, 84, 84, 69, 82, 32, 80, 142, 2, 65, 34, + 72, 166, 5, 67, 118, 71, 130, 1, 74, 34, 75, 82, 80, 34, 83, 94, 90, 252, + 188, 5, 2, 84, 65, 210, 209, 8, 76, 150, 182, 2, 82, 218, 182, 9, 66, 2, + 77, 2, 88, 154, 43, 78, 2, 81, 170, 36, 86, 234, 47, 68, 14, 69, 2, 73, + 2, 79, 2, 85, 2, 89, 143, 57, 87, 4, 142, 132, 27, 69, 227, 79, 78, 10, + 46, 65, 206, 188, 27, 73, 2, 79, 215, 22, 69, 4, 158, 211, 27, 69, 3, 82, + 94, 254, 1, 85, 178, 2, 65, 42, 67, 74, 69, 46, 71, 34, 72, 98, 74, 34, + 75, 34, 76, 50, 80, 34, 83, 34, 84, 62, 90, 226, 196, 16, 82, 218, 182, + 9, 66, 2, 77, 2, 88, 154, 43, 78, 2, 81, 170, 36, 86, 234, 47, 68, 14, + 73, 2, 79, 2, 89, 142, 57, 87, 255, 2, 70, 4, 244, 210, 22, 4, 45, 66, + 82, 74, 143, 254, 4, 78, 92, 250, 1, 65, 42, 67, 74, 69, 46, 71, 34, 72, + 98, 74, 34, 75, 34, 76, 50, 80, 34, 83, 34, 84, 62, 90, 226, 196, 16, 82, + 218, 182, 9, 66, 2, 77, 2, 88, 154, 43, 78, 2, 81, 170, 36, 86, 234, 47, + 68, 14, 73, 2, 79, 2, 85, 2, 89, 142, 57, 87, 255, 2, 70, 6, 242, 254, + 26, 69, 2, 73, 227, 79, 78, 8, 38, 72, 182, 194, 26, 73, 243, 59, 65, 4, + 162, 254, 26, 73, 135, 23, 65, 4, 140, 179, 9, 2, 76, 73, 215, 154, 18, + 78, 4, 162, 254, 25, 72, 183, 127, 65, 12, 46, 65, 150, 182, 27, 73, 2, + 79, 215, 22, 69, 6, 26, 82, 207, 204, 27, 69, 5, 203, 197, 26, 68, 4, + 162, 253, 25, 72, 199, 67, 73, 4, 154, 168, 26, 72, 159, 84, 65, 4, 11, + 65, 4, 138, 159, 16, 66, 227, 172, 11, 83, 4, 202, 167, 26, 72, 163, 107, + 65, 4, 210, 203, 26, 72, 247, 47, 65, 6, 192, 186, 3, 6, 85, 82, 78, 69, + 68, 32, 247, 130, 2, 65, 4, 206, 166, 26, 72, 159, 84, 69, 2, 209, 251, + 20, 7, 82, 65, 71, 82, 65, 80, 72, 10, 56, 2, 77, 69, 22, 82, 181, 135, + 20, 4, 78, 71, 69, 82, 2, 251, 179, 26, 76, 6, 38, 76, 217, 182, 14, 3, + 65, 70, 70, 5, 191, 179, 26, 83, 202, 1, 66, 65, 214, 13, 79, 169, 249, + 26, 7, 69, 73, 67, 72, 32, 83, 84, 194, 1, 84, 8, 71, 79, 76, 73, 84, 73, + 67, 32, 229, 12, 8, 83, 83, 32, 79, 70, 32, 77, 73, 192, 1, 56, 6, 67, + 65, 80, 73, 84, 65, 1, 4, 83, 77, 65, 76, 96, 45, 9, 76, 32, 76, 69, 84, + 84, 69, 82, 32, 96, 206, 1, 65, 22, 66, 42, 67, 94, 68, 94, 70, 38, 71, + 46, 73, 138, 2, 76, 58, 77, 66, 78, 34, 79, 30, 80, 58, 82, 30, 83, 186, + 1, 84, 110, 86, 22, 89, 90, 90, 158, 216, 19, 72, 154, 135, 2, 85, 235, + 188, 5, 75, 2, 163, 160, 27, 90, 4, 214, 3, 73, 217, 175, 27, 2, 85, 75, + 4, 48, 8, 65, 85, 68, 65, 84, 69, 32, 67, 15, 72, 2, 11, 72, 2, 153, 208, + 20, 2, 82, 73, 6, 42, 74, 30, 79, 221, 160, 27, 2, 90, 69, 2, 209, 207, + 20, 2, 69, 82, 2, 147, 206, 25, 66, 4, 226, 228, 21, 82, 235, 185, 5, 73, + 2, 21, 3, 76, 65, 71, 2, 139, 185, 22, 79, 13, 38, 78, 54, 79, 141, 1, 2, + 90, 72, 2, 145, 149, 27, 8, 73, 84, 73, 65, 76, 32, 73, 90, 4, 33, 6, 84, + 65, 84, 69, 68, 32, 4, 26, 66, 25, 2, 83, 77, 2, 11, 73, 2, 35, 71, 2, + 21, 3, 65, 76, 76, 2, 253, 180, 25, 2, 32, 89, 4, 142, 190, 27, 73, 211, + 2, 69, 4, 52, 9, 65, 84, 73, 78, 65, 84, 69, 32, 77, 35, 74, 2, 169, 209, + 11, 3, 89, 83, 76, 2, 165, 183, 9, 3, 85, 68, 73, 2, 11, 65, 2, 227, 225, + 21, 83, 4, 190, 154, 27, 78, 3, 84, 4, 26, 79, 243, 190, 27, 69, 2, 133, + 153, 23, 2, 75, 79, 2, 237, 197, 22, 2, 73, 84, 14, 106, 72, 58, 76, 220, + 187, 14, 6, 80, 73, 68, 69, 82, 89, 217, 197, 10, 8, 77, 65, 76, 76, 32, + 89, 85, 83, 6, 32, 2, 84, 65, 171, 189, 27, 65, 5, 203, 146, 26, 80, 2, + 175, 204, 20, 79, 6, 78, 86, 200, 237, 22, 9, 82, 79, 75, 85, 84, 65, 83, + 84, 73, 147, 187, 4, 83, 2, 181, 245, 19, 2, 82, 73, 2, 255, 165, 25, 69, + 12, 50, 69, 134, 200, 19, 65, 202, 243, 7, 79, 3, 85, 6, 162, 221, 21, + 83, 243, 157, 5, 82, 4, 200, 187, 9, 3, 69, 77, 76, 209, 179, 16, 4, 72, + 73, 86, 69, 2, 207, 183, 27, 76, 6, 196, 189, 12, 13, 66, 69, 32, 87, 73, + 84, 72, 32, 77, 69, 82, 73, 68, 142, 200, 4, 87, 255, 158, 9, 86, 68, + 162, 1, 65, 44, 12, 84, 72, 73, 67, 32, 76, 69, 84, 84, 69, 82, 32, 146, + 245, 18, 82, 222, 102, 71, 164, 145, 5, 3, 78, 71, 71, 234, 191, 1, 79, + 185, 77, 2, 76, 70, 4, 152, 132, 16, 2, 76, 32, 175, 180, 11, 84, 54, + 210, 2, 65, 50, 72, 46, 73, 46, 78, 46, 80, 2, 81, 40, 2, 82, 65, 22, 84, + 240, 179, 9, 2, 87, 73, 206, 189, 12, 85, 228, 69, 3, 70, 65, 73, 204, 7, + 4, 66, 65, 73, 82, 252, 21, 2, 79, 84, 150, 30, 68, 138, 130, 1, 77, 154, + 148, 1, 69, 192, 30, 3, 76, 65, 71, 156, 41, 3, 83, 65, 85, 246, 164, 1, + 74, 196, 16, 2, 71, 73, 141, 12, 2, 75, 85, 4, 200, 169, 25, 3, 73, 72, + 86, 187, 137, 2, 72, 4, 238, 171, 14, 87, 217, 253, 11, 2, 65, 71, 4, + 142, 181, 9, 85, 225, 156, 15, 2, 71, 71, 6, 194, 155, 16, 73, 209, 146, + 9, 2, 65, 85, 2, 209, 239, 26, 5, 65, 73, 82, 84, 72, 2, 231, 142, 27, + 73, 4, 236, 138, 24, 2, 72, 73, 237, 69, 2, 69, 73, 234, 9, 46, 65, 198, + 5, 69, 190, 82, 73, 151, 3, 79, 152, 1, 96, 7, 68, 85, 65, 84, 73, 79, + 78, 32, 5, 78, 84, 72, 65, 32, 170, 136, 21, 86, 195, 147, 5, 80, 2, 11, + 32, 2, 247, 158, 26, 67, 146, 1, 120, 7, 76, 69, 84, 84, 69, 82, 32, 212, + 2, 5, 83, 73, 71, 78, 32, 154, 200, 23, 65, 248, 8, 2, 86, 79, 179, 204, + 3, 79, 100, 214, 1, 86, 178, 204, 23, 65, 38, 68, 114, 84, 230, 5, 85, + 138, 204, 1, 73, 42, 76, 130, 199, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, + 2, 74, 2, 75, 2, 80, 206, 40, 79, 162, 8, 69, 158, 20, 72, 2, 77, 2, 82, + 3, 89, 14, 60, 5, 69, 68, 73, 67, 32, 138, 211, 23, 79, 207, 219, 3, 65, + 4, 176, 241, 24, 6, 68, 79, 85, 66, 76, 69, 171, 248, 1, 65, 16, 66, 67, + 222, 138, 23, 78, 198, 67, 65, 182, 1, 80, 247, 154, 3, 86, 4, 234, 150, + 8, 79, 159, 243, 14, 65, 192, 8, 76, 10, 65, 84, 69, 82, 45, 84, 72, 65, + 78, 32, 186, 7, 69, 235, 157, 26, 89, 56, 130, 1, 65, 150, 3, 66, 66, 79, + 232, 225, 6, 10, 69, 81, 85, 65, 76, 32, 84, 79, 32, 79, 142, 17, 67, + 138, 4, 87, 163, 170, 19, 83, 16, 44, 5, 66, 79, 86, 69, 32, 255, 244, 6, + 78, 12, 150, 1, 83, 180, 1, 19, 68, 79, 85, 66, 76, 69, 45, 76, 73, 78, + 69, 32, 69, 81, 85, 65, 76, 32, 65, 164, 239, 6, 4, 76, 69, 83, 83, 255, + 150, 19, 82, 6, 148, 1, 7, 73, 77, 73, 76, 65, 82, 32, 165, 242, 6, 23, + 76, 65, 78, 84, 69, 68, 32, 69, 81, 85, 65, 76, 32, 65, 66, 79, 86, 69, + 32, 76, 69, 83, 83, 4, 26, 65, 251, 241, 6, 79, 2, 65, 3, 66, 79, 86, 6, + 40, 4, 69, 83, 73, 68, 227, 242, 6, 85, 2, 135, 226, 6, 69, 20, 40, 2, + 82, 32, 245, 1, 3, 86, 69, 82, 16, 120, 16, 83, 76, 65, 78, 84, 69, 68, + 32, 69, 81, 85, 65, 76, 32, 84, 79, 166, 244, 6, 65, 134, 170, 13, 69, + 199, 239, 4, 76, 9, 49, 10, 32, 87, 73, 84, 72, 32, 68, 79, 84, 32, 6, + 44, 5, 65, 66, 79, 86, 69, 175, 236, 18, 73, 5, 191, 243, 26, 32, 4, 208, + 223, 6, 7, 76, 65, 80, 80, 73, 78, 71, 131, 223, 13, 32, 134, 8, 36, 2, + 75, 32, 189, 73, 2, 78, 32, 254, 7, 130, 3, 65, 216, 15, 8, 67, 65, 80, + 73, 84, 65, 76, 32, 186, 11, 68, 134, 1, 70, 68, 2, 73, 78, 222, 3, 75, + 138, 1, 76, 174, 3, 78, 66, 77, 84, 3, 88, 69, 83, 22, 79, 202, 1, 80, + 90, 82, 182, 1, 83, 130, 22, 84, 200, 2, 13, 85, 80, 83, 73, 76, 79, 78, + 32, 87, 73, 84, 72, 32, 150, 1, 86, 142, 2, 89, 202, 138, 8, 66, 204, + 213, 3, 4, 71, 82, 65, 77, 200, 23, 2, 90, 69, 235, 139, 12, 81, 112, 92, + 10, 67, 82, 79, 80, 72, 79, 78, 73, 67, 32, 172, 14, 6, 78, 79, 32, 84, + 69, 76, 23, 82, 106, 188, 2, 6, 65, 84, 84, 73, 67, 32, 222, 5, 67, 92, + 3, 78, 65, 88, 32, 12, 68, 69, 76, 80, 72, 73, 67, 32, 70, 73, 86, 69, 0, + 14, 83, 84, 82, 65, 84, 73, 65, 78, 32, 70, 73, 70, 84, 89, 40, 11, 69, + 80, 73, 68, 65, 85, 82, 69, 65, 78, 32, 112, 3, 72, 69, 82, 164, 1, 9, + 77, 69, 83, 83, 69, 78, 73, 65, 78, 35, 84, 48, 72, 2, 70, 73, 180, 2, 4, + 79, 78, 69, 32, 205, 1, 4, 84, 69, 78, 32, 26, 36, 3, 70, 84, 89, 105, 2, + 86, 69, 11, 11, 32, 8, 22, 84, 171, 4, 83, 6, 48, 7, 72, 79, 85, 83, 65, + 78, 68, 215, 3, 65, 5, 231, 3, 32, 17, 11, 32, 14, 56, 7, 72, 85, 78, 68, + 82, 69, 68, 18, 84, 143, 3, 83, 7, 131, 2, 32, 6, 48, 7, 72, 79, 85, 83, + 65, 78, 68, 187, 2, 65, 5, 213, 1, 2, 32, 84, 14, 98, 72, 48, 7, 84, 72, + 79, 85, 83, 65, 78, 190, 145, 25, 81, 241, 231, 1, 5, 68, 82, 65, 67, 72, + 6, 44, 5, 85, 78, 68, 82, 69, 159, 145, 25, 65, 4, 17, 2, 68, 32, 4, 22, + 84, 131, 1, 83, 2, 95, 65, 8, 30, 84, 86, 83, 175, 1, 77, 4, 50, 65, 21, + 8, 72, 79, 85, 83, 65, 78, 68, 32, 2, 247, 128, 17, 76, 2, 11, 83, 2, + 161, 146, 25, 2, 84, 65, 4, 88, 5, 65, 82, 89, 83, 84, 145, 1, 12, 89, + 82, 69, 78, 65, 73, 67, 32, 84, 87, 79, 32, 2, 101, 5, 73, 65, 78, 32, + 70, 2, 17, 2, 32, 77, 2, 227, 219, 13, 78, 6, 30, 70, 29, 3, 84, 87, 79, + 2, 237, 255, 15, 2, 73, 86, 5, 11, 32, 2, 225, 199, 10, 5, 68, 82, 65, + 67, 72, 8, 112, 8, 77, 73, 79, 78, 73, 65, 78, 32, 249, 237, 25, 14, 65, + 69, 85, 77, 32, 79, 78, 69, 32, 80, 76, 69, 84, 72, 6, 150, 132, 13, 70, + 194, 184, 12, 84, 231, 61, 79, 2, 11, 32, 2, 155, 188, 25, 84, 32, 92, 8, + 72, 69, 83, 80, 73, 65, 78, 32, 129, 1, 10, 82, 79, 69, 90, 69, 78, 73, + 65, 78, 32, 20, 40, 2, 70, 73, 38, 84, 175, 234, 18, 79, 6, 218, 177, 21, + 86, 191, 239, 3, 70, 8, 134, 252, 15, 72, 134, 200, 10, 69, 239, 48, 87, + 12, 36, 2, 70, 73, 213, 24, 2, 84, 69, 8, 206, 131, 19, 86, 157, 144, 7, + 3, 70, 84, 89, 2, 143, 187, 10, 69, 4, 188, 184, 23, 2, 79, 85, 233, 182, + 1, 3, 84, 65, 66, 154, 2, 70, 76, 174, 45, 82, 66, 68, 250, 145, 8, 84, + 161, 188, 14, 2, 75, 65, 144, 2, 44, 6, 69, 84, 84, 69, 82, 32, 239, 45, + 85, 142, 2, 198, 2, 65, 190, 1, 69, 28, 4, 73, 79, 84, 65, 128, 1, 2, 79, + 77, 156, 3, 3, 82, 72, 79, 46, 83, 48, 7, 85, 80, 83, 73, 76, 79, 78, + 146, 33, 80, 170, 2, 84, 234, 206, 5, 68, 244, 193, 2, 2, 75, 65, 226, + 197, 1, 71, 178, 176, 11, 67, 190, 156, 2, 66, 2, 72, 2, 90, 166, 1, 76, + 194, 239, 2, 89, 210, 43, 77, 2, 78, 147, 17, 88, 48, 68, 4, 76, 80, 72, + 65, 213, 28, 8, 82, 67, 72, 65, 73, 67, 32, 83, 47, 33, 6, 32, 87, 73, + 84, 72, 32, 44, 242, 2, 68, 30, 80, 226, 29, 86, 226, 5, 79, 158, 239, 3, + 84, 223, 210, 5, 77, 62, 186, 1, 84, 131, 27, 80, 31, 33, 6, 32, 87, 73, + 84, 72, 32, 28, 186, 5, 68, 136, 25, 2, 80, 83, 158, 1, 86, 226, 5, 79, + 158, 239, 3, 84, 223, 210, 5, 77, 62, 28, 2, 69, 71, 235, 34, 73, 42, 11, + 65, 43, 33, 6, 32, 87, 73, 84, 72, 32, 40, 54, 68, 30, 80, 194, 35, 79, + 22, 86, 139, 239, 3, 84, 16, 65, 4, 65, 83, 73, 65, 18, 36, 4, 83, 73, + 76, 73, 211, 16, 82, 17, 29, 5, 32, 65, 78, 68, 32, 14, 44, 2, 79, 88, 0, + 3, 86, 65, 82, 23, 80, 4, 81, 2, 73, 65, 6, 60, 10, 69, 82, 73, 83, 80, + 79, 77, 69, 78, 73, 175, 15, 82, 5, 169, 15, 7, 32, 65, 78, 68, 32, 80, + 82, 5, 161, 35, 7, 32, 87, 73, 84, 72, 32, 68, 6, 226, 181, 8, 73, 234, + 130, 18, 65, 239, 48, 72, 23, 33, 6, 32, 87, 73, 84, 72, 32, 20, 66, 68, + 166, 26, 86, 226, 5, 79, 158, 239, 3, 84, 223, 210, 5, 77, 10, 130, 24, + 65, 253, 144, 23, 5, 73, 65, 76, 89, 84, 18, 76, 9, 73, 65, 76, 89, 84, + 73, 75, 65, 32, 32, 3, 82, 65, 67, 227, 22, 65, 8, 174, 24, 65, 239, 245, + 3, 84, 2, 223, 137, 12, 72, 4, 40, 3, 73, 86, 69, 1, 3, 79, 85, 82, 2, + 205, 37, 2, 32, 79, 76, 144, 1, 27, 83, 84, 82, 85, 77, 69, 78, 84, 65, + 76, 32, 78, 79, 84, 65, 84, 73, 79, 78, 32, 83, 89, 77, 66, 79, 76, 45, + 141, 249, 22, 2, 68, 73, 74, 70, 49, 70, 50, 62, 51, 62, 52, 170, 37, 53, + 218, 220, 26, 55, 3, 56, 17, 186, 131, 27, 49, 2, 50, 2, 51, 2, 52, 2, + 55, 2, 56, 3, 57, 15, 246, 130, 27, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, + 57, 12, 186, 130, 27, 48, 2, 50, 2, 54, 2, 55, 2, 56, 3, 57, 17, 254, + 129, 27, 48, 2, 50, 2, 51, 2, 53, 2, 55, 2, 56, 3, 57, 8, 54, 65, 38, 79, + 169, 32, 6, 89, 65, 84, 72, 79, 83, 4, 142, 168, 8, 80, 179, 195, 17, 73, + 2, 11, 82, 2, 11, 79, 2, 139, 214, 24, 78, 32, 128, 1, 6, 69, 84, 84, 69, + 82, 32, 168, 2, 6, 79, 87, 69, 82, 32, 78, 32, 6, 85, 78, 65, 84, 69, 32, + 217, 162, 23, 2, 73, 84, 24, 94, 83, 140, 13, 9, 65, 82, 67, 72, 65, 73, + 67, 32, 75, 2, 75, 182, 11, 68, 219, 149, 26, 89, 16, 88, 13, 77, 65, 76, + 76, 32, 67, 65, 80, 73, 84, 65, 76, 32, 210, 12, 65, 251, 156, 8, 84, 12, + 74, 80, 162, 239, 9, 71, 194, 193, 9, 79, 226, 213, 2, 82, 243, 182, 1, + 76, 4, 206, 233, 26, 83, 219, 19, 73, 2, 209, 189, 10, 3, 85, 77, 69, 4, + 222, 25, 83, 223, 137, 8, 69, 4, 80, 4, 69, 84, 82, 69, 177, 162, 24, 10, + 85, 83, 73, 67, 65, 76, 32, 76, 69, 73, 2, 235, 213, 2, 84, 12, 88, 3, + 78, 69, 32, 178, 163, 10, 88, 192, 177, 5, 3, 85, 78, 75, 141, 212, 5, 2, + 66, 79, 6, 64, 8, 72, 65, 76, 70, 32, 83, 73, 71, 21, 4, 81, 85, 65, 82, + 4, 151, 251, 25, 78, 2, 167, 169, 21, 84, 16, 62, 82, 206, 11, 83, 114, + 69, 214, 215, 22, 72, 135, 128, 3, 73, 2, 217, 29, 2, 79, 83, 6, 100, 3, + 72, 79, 32, 173, 159, 8, 16, 69, 86, 69, 82, 83, 69, 68, 32, 76, 85, 78, + 65, 84, 69, 32, 69, 4, 240, 191, 14, 10, 87, 73, 84, 72, 32, 83, 84, 82, + 79, 75, 187, 163, 11, 83, 226, 2, 220, 1, 5, 77, 65, 76, 76, 32, 192, 19, + 22, 85, 66, 83, 67, 82, 73, 80, 84, 32, 83, 77, 65, 76, 76, 32, 76, 69, + 84, 84, 69, 82, 32, 72, 10, 89, 77, 66, 79, 76, 32, 84, 65, 85, 32, 201, + 243, 24, 6, 73, 78, 85, 83, 79, 73, 212, 2, 56, 7, 76, 69, 84, 84, 69, + 82, 32, 202, 17, 82, 67, 68, 206, 2, 178, 2, 65, 162, 2, 68, 38, 69, 52, + 4, 73, 79, 84, 65, 0, 7, 85, 80, 83, 73, 76, 79, 78, 254, 3, 75, 28, 2, + 79, 77, 182, 5, 80, 112, 3, 82, 72, 79, 94, 83, 94, 84, 248, 143, 8, 2, + 70, 73, 198, 198, 1, 71, 178, 176, 11, 67, 190, 156, 2, 66, 2, 72, 2, 90, + 166, 1, 76, 146, 155, 3, 77, 2, 78, 147, 17, 88, 58, 64, 4, 76, 80, 72, + 65, 149, 1, 7, 82, 67, 72, 65, 73, 67, 32, 55, 33, 6, 32, 87, 73, 84, 72, + 32, 52, 82, 86, 226, 6, 68, 30, 80, 114, 79, 142, 1, 89, 138, 241, 3, 84, + 223, 210, 5, 77, 6, 154, 5, 82, 155, 3, 65, 4, 18, 75, 23, 83, 2, 219, + 157, 8, 79, 2, 11, 65, 2, 147, 137, 14, 77, 4, 146, 135, 8, 73, 147, 169, + 15, 69, 70, 22, 80, 215, 4, 84, 20, 249, 7, 3, 83, 73, 76, 41, 33, 6, 32, + 87, 73, 84, 72, 32, 38, 78, 68, 166, 1, 80, 178, 1, 86, 226, 5, 79, 158, + 239, 3, 84, 223, 210, 5, 77, 18, 50, 65, 29, 8, 73, 65, 76, 89, 84, 73, + 75, 65, 8, 153, 1, 3, 83, 73, 65, 11, 29, 5, 32, 65, 78, 68, 32, 8, 170, + 1, 80, 154, 6, 79, 22, 86, 139, 239, 3, 84, 10, 18, 83, 115, 69, 8, 21, + 3, 73, 76, 73, 9, 17, 2, 32, 65, 6, 21, 3, 78, 68, 32, 6, 30, 80, 154, 6, + 79, 23, 86, 2, 11, 69, 2, 11, 82, 2, 181, 17, 4, 73, 83, 80, 79, 4, 22, + 82, 147, 15, 65, 2, 145, 203, 26, 2, 65, 67, 4, 210, 152, 8, 65, 3, 79, + 70, 28, 2, 69, 71, 151, 3, 73, 50, 11, 65, 51, 33, 6, 32, 87, 73, 84, 72, + 32, 48, 58, 68, 30, 80, 114, 79, 62, 86, 82, 89, 139, 241, 3, 84, 16, 61, + 4, 65, 83, 73, 65, 20, 32, 4, 83, 73, 76, 73, 91, 69, 17, 29, 5, 32, 65, + 78, 68, 32, 14, 42, 79, 12, 2, 80, 69, 50, 86, 83, 89, 4, 83, 88, 4, 89, + 9, 82, 73, 83, 80, 79, 77, 69, 78, 73, 4, 11, 65, 4, 11, 82, 4, 17, 2, + 73, 65, 5, 33, 6, 32, 65, 78, 68, 32, 89, 2, 243, 12, 80, 20, 17, 2, 67, + 82, 20, 17, 2, 79, 78, 21, 33, 6, 32, 87, 73, 84, 72, 32, 18, 88, 5, 68, + 65, 83, 73, 65, 0, 5, 80, 83, 73, 76, 73, 54, 79, 22, 86, 139, 239, 3, + 84, 7, 29, 5, 32, 65, 78, 68, 32, 4, 18, 79, 23, 86, 2, 187, 143, 10, 88, + 2, 179, 9, 65, 8, 88, 11, 65, 77, 80, 72, 89, 76, 73, 65, 78, 32, 68, + 186, 210, 26, 72, 2, 83, 219, 19, 73, 2, 147, 252, 7, 73, 7, 33, 6, 32, + 87, 73, 84, 72, 32, 4, 34, 68, 217, 219, 21, 2, 80, 83, 2, 183, 240, 8, + 65, 10, 54, 65, 190, 144, 8, 84, 230, 1, 73, 215, 179, 18, 72, 4, 214, + 252, 13, 77, 147, 232, 12, 78, 4, 166, 163, 23, 72, 183, 156, 3, 65, 4, + 41, 8, 69, 86, 69, 82, 83, 69, 68, 32, 4, 18, 68, 43, 76, 2, 37, 7, 79, + 84, 84, 69, 68, 32, 76, 2, 11, 85, 2, 33, 6, 78, 65, 84, 69, 32, 83, 2, + 193, 145, 8, 3, 73, 71, 77, 10, 222, 212, 9, 71, 178, 176, 11, 67, 2, 80, + 242, 102, 82, 207, 181, 1, 66, 2, 183, 235, 21, 82, 16, 106, 72, 104, 7, + 82, 89, 66, 76, 73, 79, 78, 44, 3, 87, 79, 32, 166, 232, 3, 79, 245, 156, + 17, 2, 65, 76, 6, 40, 4, 82, 69, 69, 32, 167, 143, 8, 69, 4, 146, 1, 79, + 205, 169, 23, 7, 81, 85, 65, 82, 84, 69, 82, 2, 21, 3, 32, 66, 65, 2, + 247, 188, 24, 83, 4, 42, 79, 181, 227, 12, 4, 84, 72, 73, 82, 2, 217, + 181, 20, 2, 66, 79, 6, 80, 5, 65, 67, 85, 84, 69, 0, 9, 68, 73, 65, 69, + 82, 69, 83, 73, 83, 39, 72, 2, 33, 6, 32, 65, 78, 68, 32, 72, 2, 221, + 235, 7, 2, 79, 79, 60, 102, 65, 21, 21, 79, 67, 65, 76, 32, 78, 79, 84, + 65, 84, 73, 79, 78, 32, 83, 89, 77, 66, 79, 76, 45, 2, 243, 133, 10, 82, + 58, 90, 50, 2, 53, 218, 148, 24, 49, 130, 200, 2, 51, 2, 52, 2, 54, 2, + 55, 2, 56, 3, 57, 13, 214, 220, 26, 48, 2, 49, 2, 50, 2, 51, 3, 52, 4, + 26, 80, 247, 139, 21, 69, 2, 11, 79, 2, 33, 6, 71, 69, 71, 82, 65, 77, 2, + 141, 209, 21, 2, 77, 69, 8, 202, 185, 14, 65, 242, 200, 10, 66, 218, 81, + 72, 253, 64, 3, 83, 65, 76, 12, 60, 6, 78, 78, 73, 78, 71, 32, 149, 210, + 25, 3, 77, 65, 67, 10, 100, 4, 70, 65, 67, 69, 173, 183, 18, 15, 67, 65, + 84, 32, 70, 65, 67, 69, 32, 87, 73, 84, 72, 32, 83, 9, 33, 6, 32, 87, 73, + 84, 72, 32, 6, 108, 23, 79, 78, 69, 32, 76, 65, 82, 71, 69, 32, 65, 78, + 68, 32, 79, 78, 69, 32, 83, 77, 65, 76, 76, 35, 83, 2, 11, 32, 2, 251, + 199, 8, 69, 4, 32, 2, 84, 65, 227, 181, 18, 77, 2, 251, 212, 23, 82, 6, + 28, 3, 85, 80, 32, 39, 87, 4, 134, 162, 23, 83, 143, 244, 2, 77, 2, 159, + 228, 18, 73, 220, 4, 136, 1, 2, 65, 82, 70, 73, 52, 7, 74, 65, 82, 65, + 84, 73, 32, 184, 6, 12, 78, 74, 65, 76, 65, 32, 71, 79, 78, 68, 73, 32, + 143, 3, 82, 4, 34, 65, 189, 209, 21, 2, 68, 83, 2, 11, 78, 2, 199, 206, + 25, 73, 4, 182, 177, 25, 84, 157, 163, 1, 4, 68, 69, 32, 68, 182, 1, 168, + 1, 7, 76, 69, 84, 84, 69, 82, 32, 220, 1, 5, 83, 73, 71, 78, 32, 160, 2, + 6, 86, 79, 87, 69, 76, 32, 162, 214, 20, 65, 154, 24, 82, 254, 233, 3, + 68, 203, 230, 1, 79, 98, 234, 240, 22, 65, 38, 68, 114, 84, 46, 86, 186, + 5, 85, 138, 204, 1, 73, 42, 76, 254, 14, 90, 134, 184, 1, 78, 46, 83, 82, + 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 138, 69, 72, 2, 77, 2, 82, 2, 89, + 186, 2, 69, 3, 79, 24, 98, 67, 28, 3, 77, 65, 68, 22, 84, 178, 204, 3, + 83, 186, 225, 18, 78, 198, 67, 65, 171, 156, 3, 86, 4, 118, 73, 207, 172, + 22, 65, 2, 179, 221, 19, 68, 4, 68, 5, 87, 79, 45, 67, 73, 29, 8, 72, 82, + 69, 69, 45, 68, 79, 84, 2, 25, 4, 82, 67, 76, 69, 2, 237, 158, 21, 5, 32, + 78, 85, 75, 84, 34, 44, 5, 83, 73, 71, 78, 32, 167, 142, 16, 67, 30, 162, + 142, 16, 67, 242, 228, 6, 65, 38, 85, 22, 86, 246, 203, 1, 73, 230, 143, + 2, 69, 3, 79, 126, 108, 7, 76, 69, 84, 84, 69, 82, 32, 216, 1, 5, 83, 73, + 71, 78, 32, 38, 86, 190, 212, 24, 68, 203, 230, 1, 79, 80, 154, 210, 22, + 78, 218, 24, 65, 38, 68, 114, 84, 230, 5, 85, 138, 204, 1, 73, 42, 76, + 254, 199, 1, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 206, 40, 79, 162, 8, + 69, 158, 20, 72, 2, 77, 2, 82, 2, 83, 2, 86, 3, 89, 4, 150, 142, 24, 86, + 243, 248, 1, 65, 20, 190, 7, 79, 135, 132, 24, 73, 160, 2, 84, 6, 77, 85, + 75, 72, 73, 32, 189, 7, 10, 85, 78, 71, 32, 75, 72, 69, 77, 65, 32, 172, + 1, 194, 1, 65, 44, 7, 76, 69, 84, 84, 69, 82, 32, 238, 1, 83, 228, 2, 2, + 86, 79, 140, 220, 13, 3, 84, 73, 80, 134, 247, 5, 73, 208, 175, 2, 5, 69, + 75, 32, 79, 78, 158, 202, 2, 68, 227, 178, 1, 85, 4, 254, 162, 22, 66, + 149, 233, 1, 2, 68, 68, 96, 166, 237, 8, 71, 2, 75, 226, 248, 13, 65, 38, + 68, 82, 82, 34, 84, 230, 5, 85, 138, 204, 1, 73, 42, 76, 130, 199, 1, 78, + 126, 66, 2, 67, 2, 74, 2, 80, 2, 83, 206, 40, 79, 162, 8, 69, 158, 20, + 70, 2, 72, 2, 77, 2, 86, 2, 89, 3, 90, 26, 108, 19, 69, 81, 85, 69, 78, + 67, 69, 32, 70, 79, 82, 32, 76, 69, 84, 84, 69, 82, 32, 93, 4, 73, 71, + 78, 32, 12, 70, 71, 2, 75, 138, 197, 24, 83, 170, 222, 1, 76, 226, 31, + 70, 3, 90, 2, 135, 197, 24, 72, 14, 128, 1, 6, 65, 68, 65, 75, 32, 66, 2, + 66, 244, 217, 15, 2, 85, 68, 198, 199, 6, 78, 204, 180, 2, 3, 89, 65, 75, + 163, 171, 1, 86, 2, 207, 190, 8, 73, 18, 45, 9, 87, 69, 76, 32, 83, 73, + 71, 78, 32, 18, 218, 231, 22, 65, 38, 85, 138, 204, 1, 73, 242, 240, 1, + 79, 163, 8, 69, 116, 216, 1, 22, 67, 79, 78, 83, 79, 78, 65, 78, 84, 32, + 83, 73, 71, 78, 32, 77, 69, 68, 73, 65, 76, 32, 44, 7, 76, 69, 84, 84, + 69, 82, 32, 168, 1, 5, 83, 73, 71, 78, 32, 56, 6, 86, 79, 87, 69, 76, 32, + 159, 200, 24, 68, 8, 142, 191, 26, 72, 2, 82, 2, 86, 3, 89, 60, 222, 197, + 22, 78, 254, 24, 68, 114, 84, 146, 154, 3, 66, 2, 67, 2, 71, 2, 74, 2, + 75, 2, 80, 138, 69, 72, 2, 76, 2, 77, 2, 82, 2, 83, 2, 86, 2, 89, 187, 2, + 65, 4, 250, 250, 25, 65, 233, 35, 6, 84, 72, 79, 76, 72, 79, 24, 194, + 238, 20, 83, 255, 142, 5, 76, 178, 23, 110, 65, 214, 95, 69, 150, 104, + 73, 150, 9, 79, 166, 12, 84, 30, 85, 130, 1, 89, 213, 185, 13, 4, 82, 89, + 86, 78, 140, 11, 236, 1, 2, 73, 82, 100, 8, 76, 70, 87, 73, 68, 84, 72, + 32, 242, 10, 77, 210, 1, 78, 236, 76, 21, 80, 80, 89, 32, 80, 69, 82, 83, + 79, 78, 32, 82, 65, 73, 83, 73, 78, 71, 32, 79, 78, 22, 82, 38, 84, 168, + 200, 18, 2, 85, 77, 191, 131, 6, 68, 8, 66, 32, 188, 151, 21, 6, 89, 32, + 67, 82, 69, 65, 227, 170, 4, 67, 4, 154, 137, 25, 80, 167, 116, 83, 244, + 1, 140, 2, 7, 72, 65, 78, 71, 85, 76, 32, 216, 4, 8, 75, 65, 84, 65, 75, + 65, 78, 65, 204, 3, 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, 204, 224, 6, 11, + 70, 79, 82, 77, 83, 32, 76, 73, 71, 72, 84, 190, 173, 4, 85, 134, 215, 2, + 73, 222, 192, 4, 66, 242, 241, 4, 87, 215, 35, 68, 104, 52, 7, 76, 69, + 84, 84, 69, 82, 32, 151, 168, 11, 70, 102, 206, 1, 75, 28, 5, 78, 73, 69, + 85, 78, 42, 80, 24, 5, 82, 73, 69, 85, 76, 86, 83, 98, 89, 202, 61, 67, + 54, 69, 30, 73, 242, 4, 77, 138, 1, 84, 206, 3, 87, 198, 1, 72, 226, 171, + 25, 65, 2, 79, 163, 64, 85, 6, 222, 65, 72, 155, 3, 73, 7, 11, 45, 4, + 134, 72, 67, 131, 3, 72, 6, 146, 69, 72, 35, 73, 17, 11, 45, 14, 206, 49, + 84, 226, 14, 80, 130, 4, 77, 194, 3, 75, 218, 2, 72, 99, 83, 12, 40, 4, + 83, 65, 78, 71, 235, 169, 14, 73, 10, 210, 70, 67, 42, 75, 74, 80, 34, + 84, 211, 2, 83, 14, 242, 231, 23, 69, 142, 141, 2, 65, 162, 64, 73, 2, + 79, 3, 85, 118, 70, 32, 153, 246, 2, 11, 45, 72, 73, 82, 65, 71, 65, 78, + 65, 32, 80, 116, 76, 7, 76, 69, 84, 84, 69, 82, 32, 238, 245, 2, 83, 34, + 86, 223, 169, 22, 77, 110, 146, 1, 83, 202, 239, 2, 78, 202, 2, 72, 2, + 75, 2, 77, 2, 82, 2, 84, 142, 1, 89, 158, 38, 87, 254, 152, 23, 65, 2, + 69, 2, 73, 2, 79, 3, 85, 28, 76, 5, 77, 65, 76, 76, 32, 230, 177, 26, 65, + 2, 69, 2, 73, 2, 79, 3, 85, 18, 202, 242, 2, 89, 178, 154, 23, 84, 234, + 36, 65, 2, 69, 2, 73, 2, 79, 3, 85, 4, 11, 84, 4, 156, 233, 13, 2, 32, + 67, 223, 165, 11, 87, 14, 56, 3, 77, 69, 82, 106, 83, 161, 217, 22, 3, + 66, 85, 82, 9, 29, 5, 32, 65, 78, 68, 32, 6, 176, 245, 12, 3, 87, 82, 69, + 184, 236, 3, 2, 83, 73, 199, 155, 8, 80, 4, 148, 242, 25, 3, 84, 69, 82, + 163, 61, 65, 194, 8, 118, 68, 202, 2, 71, 128, 66, 13, 73, 70, 73, 32, + 82, 79, 72, 73, 78, 71, 89, 65, 32, 165, 5, 5, 85, 78, 79, 79, 32, 10, + 100, 12, 32, 87, 73, 84, 72, 32, 73, 78, 68, 69, 88, 32, 188, 1, 2, 66, + 65, 213, 186, 22, 2, 83, 72, 4, 156, 1, 18, 65, 78, 68, 32, 77, 73, 68, + 68, 76, 69, 32, 70, 73, 78, 71, 69, 82, 83, 1, 16, 70, 73, 78, 71, 69, + 82, 32, 65, 78, 68, 32, 84, 72, 85, 77, 66, 2, 153, 218, 16, 2, 32, 67, + 4, 154, 160, 25, 76, 211, 139, 1, 71, 170, 7, 84, 3, 85, 76, 32, 217, 64, + 13, 90, 72, 79, 85, 32, 78, 85, 77, 69, 82, 65, 76, 32, 146, 7, 164, 1, + 9, 67, 72, 79, 83, 69, 79, 78, 71, 32, 244, 15, 4, 68, 79, 85, 66, 0, 4, + 83, 73, 78, 71, 46, 74, 180, 31, 7, 76, 69, 84, 84, 69, 82, 32, 131, 233, + 10, 70, 250, 1, 246, 1, 67, 172, 2, 5, 73, 69, 85, 78, 71, 146, 1, 75, + 132, 1, 5, 77, 73, 69, 85, 77, 56, 5, 78, 73, 69, 85, 78, 74, 80, 172, 2, + 5, 82, 73, 69, 85, 76, 210, 1, 83, 166, 3, 84, 124, 2, 89, 69, 200, 40, + 5, 72, 73, 69, 85, 72, 183, 224, 10, 70, 30, 76, 2, 72, 73, 84, 7, 69, + 79, 78, 71, 67, 72, 73, 121, 4, 73, 69, 85, 67, 16, 40, 4, 69, 85, 67, + 72, 41, 2, 84, 85, 7, 11, 45, 4, 202, 31, 75, 243, 26, 72, 10, 21, 3, 69, + 85, 77, 10, 22, 83, 155, 46, 67, 6, 40, 4, 83, 65, 78, 71, 219, 153, 14, + 73, 4, 194, 54, 67, 227, 3, 83, 5, 215, 30, 45, 27, 11, 45, 24, 90, 80, + 234, 30, 82, 242, 13, 67, 194, 5, 77, 138, 1, 84, 186, 2, 75, 218, 2, 72, + 99, 83, 6, 214, 50, 72, 214, 3, 73, 207, 2, 65, 16, 80, 7, 65, 80, 89, + 69, 79, 85, 78, 228, 20, 5, 73, 89, 69, 79, 75, 131, 25, 72, 10, 234, 29, + 82, 178, 15, 80, 30, 83, 231, 3, 77, 11, 11, 45, 8, 158, 52, 75, 74, 80, + 34, 84, 211, 2, 83, 15, 11, 45, 12, 190, 51, 67, 42, 75, 74, 80, 34, 84, + 242, 1, 72, 99, 83, 42, 68, 6, 72, 73, 69, 85, 80, 72, 40, 4, 73, 69, 85, + 80, 223, 53, 65, 7, 11, 45, 4, 158, 51, 80, 147, 2, 72, 35, 11, 45, 32, + 82, 83, 234, 20, 80, 214, 7, 75, 162, 12, 67, 202, 6, 84, 226, 2, 78, + 179, 2, 72, 14, 32, 3, 73, 79, 83, 251, 3, 83, 13, 11, 45, 10, 242, 46, + 84, 146, 2, 67, 42, 75, 75, 80, 29, 11, 45, 26, 78, 75, 42, 83, 190, 44, + 77, 154, 3, 67, 82, 78, 34, 80, 34, 84, 243, 1, 72, 6, 170, 22, 65, 130, + 19, 72, 135, 7, 73, 8, 40, 4, 83, 65, 78, 71, 191, 146, 14, 73, 6, 206, + 47, 75, 74, 80, 35, 84, 58, 48, 3, 73, 79, 83, 217, 1, 4, 83, 65, 78, 71, + 33, 11, 45, 30, 130, 1, 80, 44, 2, 83, 83, 210, 22, 82, 210, 1, 75, 162, + 12, 67, 194, 5, 77, 138, 1, 84, 226, 2, 78, 178, 2, 72, 251, 242, 18, 73, + 6, 184, 23, 4, 73, 69, 85, 80, 179, 19, 72, 2, 233, 48, 3, 65, 78, 71, + 26, 236, 17, 5, 67, 73, 69, 85, 67, 172, 3, 4, 83, 73, 79, 83, 154, 1, + 82, 186, 20, 84, 54, 89, 134, 2, 75, 42, 78, 34, 80, 146, 2, 72, 251, + 242, 18, 73, 16, 40, 5, 73, 75, 69, 85, 84, 195, 41, 72, 15, 11, 45, 12, + 226, 20, 82, 178, 19, 77, 154, 3, 67, 42, 75, 74, 80, 243, 2, 83, 4, 150, + 19, 83, 139, 22, 79, 2, 193, 171, 9, 6, 76, 69, 32, 68, 79, 84, 216, 3, + 92, 9, 79, 78, 71, 83, 69, 79, 78, 71, 32, 165, 21, 9, 85, 78, 71, 83, + 69, 79, 78, 71, 32, 154, 2, 226, 1, 67, 80, 5, 72, 73, 69, 85, 72, 60, 5, + 73, 69, 85, 78, 71, 46, 75, 220, 1, 5, 77, 73, 69, 85, 77, 188, 1, 5, 78, + 73, 69, 85, 78, 94, 80, 240, 2, 5, 82, 73, 69, 85, 76, 190, 4, 83, 194, + 3, 84, 213, 1, 2, 89, 69, 8, 36, 4, 73, 69, 85, 67, 239, 30, 72, 7, 11, + 45, 4, 162, 32, 83, 239, 7, 80, 11, 11, 45, 8, 174, 16, 82, 178, 19, 77, + 234, 3, 78, 35, 80, 9, 11, 45, 6, 194, 17, 75, 57, 2, 83, 83, 28, 76, 7, + 65, 80, 89, 69, 79, 85, 78, 40, 5, 73, 89, 69, 79, 75, 215, 30, 72, 8, + 130, 15, 82, 178, 15, 80, 131, 4, 77, 19, 11, 45, 16, 166, 13, 75, 170, + 1, 82, 42, 83, 224, 13, 2, 67, 72, 146, 9, 78, 34, 80, 147, 2, 72, 27, + 11, 45, 24, 74, 80, 30, 83, 134, 13, 82, 242, 13, 67, 130, 9, 75, 42, 78, + 179, 2, 72, 6, 174, 33, 73, 131, 6, 65, 6, 40, 4, 83, 65, 78, 71, 183, + 134, 14, 73, 4, 238, 35, 78, 147, 3, 83, 21, 11, 45, 18, 174, 12, 82, + 242, 13, 67, 202, 6, 84, 186, 2, 75, 218, 2, 72, 62, 80, 39, 83, 36, 88, + 6, 65, 78, 83, 73, 79, 83, 48, 6, 72, 73, 69, 85, 80, 72, 53, 4, 73, 69, + 85, 80, 7, 11, 45, 4, 236, 7, 2, 75, 65, 195, 26, 80, 9, 11, 45, 6, 150, + 11, 84, 234, 22, 80, 243, 2, 83, 23, 11, 45, 20, 112, 5, 82, 73, 69, 85, + 76, 24, 4, 83, 73, 79, 83, 134, 3, 80, 246, 19, 67, 194, 5, 77, 170, 4, + 84, 243, 1, 72, 5, 153, 3, 2, 45, 80, 5, 221, 32, 2, 45, 84, 57, 11, 45, + 54, 102, 75, 92, 5, 77, 73, 69, 85, 77, 50, 80, 126, 83, 74, 84, 44, 2, + 89, 69, 154, 28, 78, 179, 2, 72, 10, 52, 5, 73, 89, 69, 79, 75, 190, 4, + 65, 131, 19, 72, 7, 11, 45, 4, 254, 32, 72, 99, 83, 9, 11, 45, 6, 130, + 30, 75, 218, 2, 72, 99, 83, 14, 48, 4, 73, 69, 85, 80, 174, 26, 72, 163, + 6, 65, 11, 11, 45, 8, 42, 80, 222, 29, 84, 242, 1, 72, 99, 83, 2, 243, + 25, 72, 6, 40, 4, 83, 65, 78, 71, 167, 255, 13, 73, 4, 182, 28, 75, 187, + 3, 83, 6, 100, 5, 73, 75, 69, 85, 84, 151, 25, 72, 6, 56, 9, 79, 82, 73, + 78, 72, 73, 69, 85, 72, 191, 3, 83, 5, 255, 29, 45, 52, 48, 3, 73, 79, + 83, 161, 1, 4, 83, 65, 78, 71, 25, 11, 45, 22, 82, 75, 162, 3, 82, 242, + 13, 67, 198, 2, 80, 254, 2, 77, 138, 1, 84, 147, 5, 72, 4, 22, 65, 135, + 26, 73, 2, 237, 18, 6, 80, 89, 69, 79, 85, 78, 28, 160, 1, 5, 82, 73, 69, + 85, 76, 36, 6, 84, 73, 75, 69, 85, 84, 16, 3, 89, 69, 83, 138, 19, 83, + 178, 1, 77, 154, 3, 67, 42, 75, 42, 78, 34, 80, 139, 245, 18, 73, 5, 17, + 2, 45, 75, 2, 159, 17, 72, 5, 255, 16, 45, 2, 199, 141, 19, 73, 20, 40, + 5, 73, 75, 69, 85, 84, 155, 21, 72, 19, 11, 45, 16, 58, 82, 42, 83, 42, + 84, 162, 13, 67, 130, 9, 75, 75, 80, 2, 17, 2, 73, 69, 2, 227, 249, 24, + 85, 4, 21, 3, 73, 79, 83, 5, 223, 1, 45, 2, 255, 19, 72, 18, 44, 6, 83, + 73, 69, 85, 78, 71, 243, 19, 79, 17, 11, 45, 14, 50, 75, 30, 83, 198, 17, + 77, 154, 6, 72, 63, 80, 4, 166, 14, 72, 135, 7, 73, 4, 26, 83, 215, 247, + 13, 73, 2, 21, 3, 65, 78, 71, 2, 207, 20, 75, 190, 1, 122, 65, 118, 69, + 134, 1, 73, 92, 7, 83, 83, 65, 78, 71, 65, 82, 106, 79, 138, 1, 85, 102, + 89, 174, 15, 87, 219, 220, 10, 70, 23, 48, 4, 82, 65, 69, 65, 98, 45, + 135, 129, 26, 69, 13, 11, 45, 10, 170, 180, 23, 69, 174, 205, 2, 65, 2, + 73, 3, 85, 25, 18, 79, 55, 85, 9, 11, 45, 6, 154, 220, 25, 69, 234, 36, + 79, 3, 85, 15, 11, 45, 12, 170, 9, 69, 166, 247, 25, 65, 2, 79, 3, 85, + 31, 11, 45, 28, 66, 65, 34, 89, 166, 1, 79, 166, 217, 25, 69, 234, 36, + 73, 3, 85, 5, 11, 82, 2, 131, 230, 18, 65, 14, 50, 65, 210, 177, 23, 69, + 174, 205, 2, 79, 3, 85, 7, 134, 224, 25, 45, 247, 30, 69, 23, 26, 45, + 195, 254, 25, 69, 18, 50, 79, 22, 89, 206, 176, 23, 69, 175, 205, 2, 85, + 5, 179, 234, 25, 45, 8, 202, 176, 23, 69, 143, 141, 2, 65, 17, 11, 45, + 14, 158, 19, 89, 130, 199, 5, 73, 140, 177, 13, 3, 69, 79, 45, 254, 177, + 6, 65, 163, 64, 85, 62, 42, 65, 70, 69, 66, 73, 22, 79, 107, 85, 11, 26, + 45, 171, 252, 25, 69, 6, 178, 221, 25, 89, 246, 30, 79, 3, 85, 11, 11, + 79, 9, 11, 45, 6, 174, 249, 25, 89, 186, 2, 79, 3, 85, 5, 215, 214, 25, + 45, 19, 11, 45, 16, 58, 89, 198, 186, 25, 65, 174, 33, 69, 246, 30, 73, + 3, 79, 6, 194, 186, 25, 65, 175, 33, 69, 21, 11, 45, 18, 142, 16, 89, + 254, 156, 23, 69, 142, 141, 2, 65, 162, 64, 73, 2, 79, 3, 85, 186, 1, + 226, 1, 65, 46, 67, 54, 69, 30, 73, 22, 75, 188, 1, 5, 77, 73, 69, 85, + 77, 64, 5, 78, 73, 69, 85, 78, 70, 80, 168, 1, 5, 82, 73, 69, 85, 76, + 254, 1, 84, 90, 83, 246, 2, 87, 50, 89, 150, 1, 72, 226, 171, 25, 79, + 163, 64, 85, 9, 156, 13, 3, 82, 65, 69, 231, 234, 25, 69, 4, 22, 72, 207, + 8, 73, 2, 137, 213, 25, 2, 73, 69, 7, 162, 247, 25, 79, 3, 85, 5, 139, + 254, 18, 69, 14, 56, 7, 65, 80, 89, 69, 79, 85, 78, 106, 72, 155, 3, 73, + 8, 30, 80, 30, 83, 231, 3, 77, 4, 190, 4, 72, 215, 3, 73, 2, 25, 4, 83, + 65, 78, 71, 2, 207, 7, 80, 2, 221, 60, 2, 73, 69, 9, 11, 45, 6, 22, 80, + 247, 9, 83, 4, 142, 7, 73, 207, 2, 65, 13, 11, 45, 10, 234, 5, 67, 146, + 1, 84, 242, 1, 72, 62, 80, 39, 83, 20, 48, 4, 73, 69, 85, 80, 170, 2, 72, + 163, 6, 65, 17, 11, 45, 14, 42, 83, 186, 2, 84, 146, 2, 67, 43, 75, 6, + 21, 3, 73, 79, 83, 7, 11, 45, 4, 202, 4, 75, 107, 84, 27, 11, 45, 24, 68, + 2, 75, 73, 34, 77, 34, 80, 106, 84, 54, 89, 222, 4, 72, 99, 83, 4, 149, + 1, 4, 89, 69, 79, 75, 2, 11, 73, 2, 167, 198, 24, 69, 8, 30, 72, 34, 73, + 131, 6, 65, 2, 157, 185, 19, 3, 73, 69, 85, 4, 21, 3, 69, 85, 80, 5, 243, + 5, 45, 4, 22, 72, 151, 3, 73, 2, 141, 200, 22, 2, 73, 69, 2, 17, 2, 69, + 79, 2, 167, 4, 82, 28, 44, 3, 73, 79, 83, 57, 4, 83, 65, 78, 71, 13, 11, + 45, 10, 122, 67, 42, 75, 42, 78, 34, 80, 35, 84, 16, 78, 67, 42, 75, 42, + 78, 34, 80, 34, 84, 242, 1, 72, 98, 83, 155, 242, 18, 73, 2, 11, 73, 2, + 161, 196, 24, 2, 69, 85, 2, 11, 73, 2, 233, 196, 25, 2, 89, 69, 2, 11, + 73, 2, 243, 237, 24, 69, 2, 11, 73, 2, 143, 248, 24, 69, 2, 11, 73, 2, + 11, 75, 2, 135, 244, 24, 69, 10, 150, 160, 23, 69, 142, 141, 2, 65, 163, + 64, 73, 34, 58, 69, 206, 1, 79, 62, 85, 178, 170, 25, 65, 163, 64, 73, + 13, 42, 79, 73, 6, 83, 73, 69, 85, 78, 71, 5, 11, 82, 2, 17, 2, 73, 78, + 2, 11, 72, 2, 233, 185, 10, 2, 73, 69, 7, 11, 45, 4, 18, 80, 39, 83, 2, + 11, 65, 2, 11, 78, 2, 11, 83, 2, 179, 223, 13, 73, 9, 11, 45, 6, 26, 89, + 231, 234, 25, 73, 4, 195, 170, 25, 65, 9, 11, 45, 6, 26, 89, 171, 234, + 25, 73, 4, 251, 156, 23, 69, 24, 230, 210, 11, 84, 138, 161, 12, 70, 30, + 83, 206, 90, 78, 14, 79, 227, 112, 69, 100, 156, 1, 7, 76, 69, 84, 84, + 69, 82, 32, 196, 2, 5, 77, 65, 82, 75, 32, 72, 5, 83, 73, 71, 78, 32, + 248, 164, 2, 6, 86, 79, 87, 69, 76, 32, 135, 201, 21, 68, 58, 202, 1, 68, + 34, 75, 150, 204, 21, 84, 186, 56, 82, 198, 225, 1, 78, 238, 184, 1, 83, + 138, 69, 66, 2, 67, 2, 70, 2, 71, 2, 72, 2, 74, 2, 76, 2, 77, 2, 80, 2, + 86, 2, 87, 2, 89, 2, 90, 187, 2, 65, 4, 162, 228, 25, 68, 187, 2, 65, 8, + 56, 5, 73, 78, 78, 65, 32, 202, 227, 25, 72, 187, 2, 65, 4, 198, 227, 25, + 87, 3, 89, 4, 152, 167, 22, 6, 78, 65, 32, 75, 72, 79, 245, 190, 2, 3, + 83, 65, 75, 8, 52, 2, 84, 65, 205, 209, 23, 5, 72, 65, 82, 66, 65, 6, 42, + 72, 214, 235, 20, 83, 175, 246, 4, 78, 2, 159, 194, 25, 65, 42, 62, 76, + 200, 195, 19, 6, 83, 73, 71, 78, 32, 80, 247, 1, 86, 36, 33, 6, 69, 84, + 84, 69, 82, 32, 36, 130, 232, 21, 78, 134, 249, 3, 66, 2, 68, 2, 71, 2, + 72, 2, 75, 2, 76, 2, 77, 2, 80, 2, 82, 2, 83, 2, 84, 2, 87, 2, 89, 186, + 2, 65, 2, 73, 3, 85, 2, 235, 209, 24, 69, 4, 242, 151, 24, 68, 155, 202, + 1, 80, 54, 52, 5, 67, 72, 73, 78, 71, 41, 4, 82, 65, 78, 32, 2, 17, 2, + 32, 67, 2, 203, 174, 24, 72, 52, 52, 7, 76, 69, 84, 84, 69, 82, 32, 183, + 219, 6, 78, 42, 218, 1, 65, 154, 249, 11, 90, 250, 46, 84, 166, 120, 76, + 50, 81, 60, 6, 68, 65, 76, 69, 84, 72, 166, 172, 4, 71, 122, 83, 66, 89, + 206, 209, 1, 72, 234, 5, 75, 142, 81, 66, 138, 231, 4, 78, 134, 2, 87, + 218, 103, 80, 171, 4, 77, 4, 174, 205, 17, 76, 231, 193, 7, 89, 178, 9, + 210, 1, 65, 222, 32, 66, 234, 33, 76, 200, 1, 16, 78, 84, 65, 73, 71, 65, + 78, 65, 32, 76, 69, 84, 84, 69, 82, 32, 218, 11, 82, 120, 11, 88, 65, 71, + 82, 65, 77, 32, 70, 79, 82, 32, 189, 139, 25, 4, 68, 71, 69, 72, 214, 1, + 42, 68, 98, 82, 201, 1, 3, 86, 89, 32, 6, 44, 5, 83, 84, 79, 78, 69, 247, + 174, 24, 80, 5, 133, 228, 2, 7, 32, 71, 82, 65, 86, 69, 89, 12, 32, 2, + 84, 32, 203, 234, 17, 45, 10, 60, 5, 87, 73, 84, 72, 32, 198, 239, 12, + 68, 143, 164, 9, 72, 6, 76, 9, 84, 73, 80, 32, 79, 78, 32, 84, 72, 210, + 190, 13, 82, 239, 254, 10, 65, 2, 239, 167, 25, 69, 196, 1, 134, 2, 65, + 202, 1, 66, 230, 2, 67, 154, 3, 68, 142, 1, 69, 186, 3, 70, 94, 72, 62, + 76, 222, 1, 77, 110, 79, 162, 1, 82, 142, 2, 83, 228, 1, 3, 78, 79, 82, + 198, 1, 84, 128, 2, 2, 85, 80, 174, 1, 87, 206, 217, 14, 73, 158, 247, 3, + 80, 198, 143, 4, 86, 191, 79, 71, 12, 108, 17, 82, 82, 79, 87, 32, 83, + 72, 65, 70, 84, 32, 87, 73, 68, 84, 72, 32, 246, 243, 18, 77, 239, 200, + 4, 83, 8, 36, 3, 79, 78, 69, 239, 240, 23, 84, 7, 11, 32, 4, 234, 187, + 14, 84, 219, 145, 9, 72, 14, 48, 4, 65, 76, 76, 79, 21, 4, 76, 65, 67, + 75, 2, 191, 139, 6, 84, 12, 30, 32, 153, 1, 2, 45, 70, 6, 52, 7, 67, 85, + 82, 86, 69, 68, 32, 135, 206, 24, 72, 4, 40, 4, 68, 79, 87, 78, 1, 2, 85, + 80, 2, 161, 178, 24, 8, 87, 65, 82, 68, 83, 32, 65, 78, 6, 45, 9, 69, 65, + 84, 72, 69, 82, 69, 68, 32, 6, 130, 161, 14, 83, 130, 175, 3, 78, 223, + 225, 6, 82, 14, 116, 2, 72, 69, 52, 5, 73, 82, 67, 76, 69, 213, 177, 18, + 14, 79, 78, 67, 65, 86, 69, 45, 80, 79, 73, 78, 84, 69, 68, 4, 216, 165, + 21, 4, 86, 82, 79, 78, 243, 228, 2, 67, 9, 64, 6, 32, 87, 73, 84, 72, 32, + 153, 182, 23, 4, 68, 32, 83, 65, 4, 52, 7, 83, 84, 82, 79, 75, 69, 32, + 155, 161, 5, 67, 2, 29, 5, 65, 78, 68, 32, 84, 2, 11, 87, 2, 11, 79, 2, + 21, 3, 32, 68, 79, 2, 11, 84, 2, 223, 211, 24, 83, 14, 60, 7, 65, 83, 72, + 69, 68, 32, 84, 18, 79, 139, 139, 5, 73, 2, 147, 16, 82, 10, 192, 16, 3, + 87, 78, 87, 138, 217, 14, 85, 243, 187, 4, 76, 16, 120, 5, 73, 71, 72, + 84, 32, 156, 2, 16, 88, 67, 76, 65, 77, 65, 84, 73, 79, 78, 32, 77, 65, + 82, 75, 32, 151, 162, 19, 81, 10, 40, 2, 80, 79, 126, 84, 143, 178, 23, + 83, 6, 33, 6, 73, 78, 84, 69, 68, 32, 6, 154, 142, 17, 80, 156, 162, 6, + 11, 82, 69, 67, 84, 73, 76, 73, 78, 69, 65, 82, 23, 66, 2, 181, 178, 23, + 24, 69, 65, 82, 68, 82, 79, 80, 45, 83, 80, 79, 75, 69, 68, 32, 80, 82, + 79, 80, 69, 76, 76, 69, 82, 4, 254, 182, 24, 83, 227, 81, 79, 6, 44, 5, + 79, 85, 82, 32, 66, 131, 161, 5, 73, 2, 193, 206, 11, 6, 65, 76, 76, 79, + 79, 78, 4, 202, 144, 18, 79, 225, 235, 5, 6, 69, 65, 82, 84, 32, 69, 20, + 74, 65, 44, 3, 69, 70, 84, 28, 2, 79, 87, 253, 155, 5, 3, 73, 71, 65, 4, + 128, 177, 22, 2, 82, 71, 203, 210, 1, 84, 8, 254, 3, 45, 195, 6, 87, 6, + 26, 32, 227, 222, 10, 69, 4, 222, 227, 14, 68, 25, 4, 83, 73, 78, 71, 4, + 56, 8, 85, 76, 84, 73, 80, 76, 73, 67, 179, 146, 22, 73, 2, 25, 4, 65, + 84, 73, 79, 2, 231, 253, 5, 78, 6, 180, 180, 6, 9, 80, 69, 78, 32, 67, + 69, 78, 84, 82, 148, 218, 10, 13, 86, 65, 76, 32, 87, 73, 84, 72, 32, 79, + 86, 65, 76, 141, 156, 6, 5, 85, 84, 76, 73, 78, 12, 76, 4, 73, 71, 72, + 84, 213, 163, 24, 9, 79, 85, 78, 68, 45, 84, 73, 80, 80, 10, 62, 45, 109, + 11, 87, 65, 82, 68, 83, 32, 65, 82, 82, 79, 87, 4, 69, 15, 80, 79, 73, + 78, 84, 73, 78, 71, 32, 65, 78, 71, 76, 69, 32, 4, 254, 143, 7, 66, 183, + 208, 7, 81, 7, 139, 6, 32, 26, 106, 65, 78, 73, 44, 2, 79, 85, 156, 232, + 14, 7, 67, 82, 73, 80, 84, 32, 76, 249, 140, 1, 3, 80, 65, 82, 4, 176, + 223, 14, 10, 78, 83, 45, 83, 69, 82, 73, 70, 32, 73, 143, 201, 8, 76, 8, + 156, 221, 14, 2, 78, 71, 151, 200, 8, 88, 10, 21, 3, 84, 72, 32, 10, 60, + 5, 69, 65, 83, 84, 32, 29, 6, 87, 69, 83, 84, 32, 80, 6, 26, 80, 179, + 165, 24, 65, 4, 41, 8, 79, 73, 78, 84, 73, 78, 71, 32, 4, 198, 193, 17, + 86, 135, 210, 6, 66, 12, 88, 9, 69, 65, 82, 68, 82, 79, 80, 45, 83, 130, + 1, 82, 185, 140, 7, 4, 87, 69, 76, 86, 6, 64, 6, 80, 79, 75, 69, 68, 32, + 209, 157, 24, 4, 72, 65, 78, 75, 4, 204, 165, 23, 8, 80, 73, 78, 87, 72, + 69, 69, 76, 27, 65, 2, 193, 3, 5, 73, 65, 78, 71, 76, 6, 26, 87, 207, + 212, 10, 80, 4, 53, 11, 65, 82, 68, 83, 32, 65, 82, 82, 79, 87, 32, 4, + 29, 5, 87, 73, 84, 72, 32, 4, 192, 214, 20, 5, 76, 65, 82, 71, 69, 163, + 245, 1, 69, 12, 76, 5, 72, 73, 84, 69, 32, 164, 1, 2, 73, 68, 145, 208, + 23, 3, 69, 68, 71, 8, 64, 6, 83, 81, 85, 65, 82, 69, 138, 172, 18, 68, + 235, 185, 5, 67, 5, 185, 133, 24, 19, 32, 67, 79, 78, 84, 65, 73, 78, 73, + 78, 71, 32, 66, 76, 65, 67, 75, 32, 86, 2, 217, 200, 21, 2, 69, 45, 146, + 2, 40, 4, 82, 69, 87, 32, 239, 187, 25, 69, 144, 2, 112, 7, 65, 67, 67, + 69, 78, 84, 32, 134, 8, 76, 164, 14, 5, 77, 65, 82, 75, 32, 114, 80, 129, + 255, 21, 2, 89, 79, 60, 128, 2, 9, 65, 84, 78, 65, 72, 32, 72, 65, 70, + 22, 68, 36, 3, 71, 69, 82, 74, 77, 124, 2, 80, 65, 28, 4, 69, 84, 78, 65, + 20, 2, 81, 65, 58, 83, 58, 84, 148, 1, 2, 89, 69, 78, 90, 160, 220, 8, 3, + 82, 69, 86, 218, 176, 15, 79, 181, 149, 1, 3, 73, 76, 85, 2, 199, 242, + 18, 85, 4, 130, 219, 19, 69, 139, 155, 5, 65, 6, 32, 3, 69, 83, 72, 155, + 29, 83, 5, 153, 135, 7, 4, 32, 77, 85, 81, 8, 84, 5, 69, 82, 75, 72, 65, + 216, 195, 18, 2, 85, 78, 153, 45, 5, 65, 72, 65, 80, 65, 5, 129, 182, 20, + 4, 32, 75, 69, 70, 4, 26, 83, 239, 248, 24, 90, 2, 139, 146, 25, 72, 4, + 244, 241, 24, 6, 82, 78, 69, 89, 32, 80, 191, 35, 68, 4, 218, 24, 69, + 145, 184, 23, 6, 72, 65, 76, 83, 72, 69, 8, 38, 69, 237, 180, 23, 3, 73, + 80, 69, 6, 48, 6, 76, 73, 83, 72, 65, 32, 223, 171, 12, 86, 4, 200, 86, + 3, 71, 69, 68, 205, 166, 22, 3, 81, 69, 84, 4, 152, 134, 9, 10, 82, 65, + 72, 32, 66, 69, 78, 32, 89, 79, 239, 239, 2, 84, 8, 18, 65, 95, 73, 6, + 40, 4, 81, 69, 70, 32, 207, 167, 6, 82, 4, 218, 210, 11, 81, 205, 203, + 12, 3, 71, 65, 68, 2, 155, 250, 24, 78, 150, 1, 76, 6, 69, 84, 84, 69, + 82, 32, 201, 11, 8, 73, 71, 65, 84, 85, 82, 69, 32, 140, 1, 134, 3, 65, + 204, 1, 3, 66, 69, 84, 0, 3, 75, 65, 70, 0, 2, 80, 69, 68, 6, 70, 73, 78, + 65, 76, 32, 92, 2, 81, 79, 16, 2, 72, 69, 52, 2, 78, 85, 0, 4, 90, 65, + 89, 73, 18, 83, 48, 3, 82, 69, 83, 170, 1, 84, 52, 4, 68, 65, 76, 69, 12, + 5, 71, 73, 77, 69, 76, 0, 5, 76, 65, 77, 69, 68, 0, 3, 77, 69, 77, 48, 3, + 86, 65, 86, 80, 5, 87, 73, 68, 69, 32, 153, 1, 3, 89, 79, 68, 14, 26, 76, + 163, 175, 24, 89, 12, 64, 2, 69, 70, 73, 10, 84, 69, 82, 78, 65, 84, 73, + 86, 69, 32, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 174, 13, 77, 130, 1, 80, + 35, 81, 4, 154, 157, 17, 65, 139, 163, 1, 80, 7, 33, 6, 32, 87, 73, 84, + 72, 32, 4, 182, 15, 82, 179, 174, 14, 68, 14, 88, 2, 75, 65, 236, 2, 2, + 80, 69, 228, 156, 1, 2, 84, 83, 166, 140, 23, 78, 135, 110, 77, 4, 235, + 2, 70, 7, 160, 11, 5, 32, 87, 73, 84, 72, 243, 160, 25, 84, 4, 167, 2, + 78, 16, 44, 4, 65, 77, 69, 75, 17, 3, 72, 73, 78, 4, 231, 1, 72, 13, 33, + 6, 32, 87, 73, 84, 72, 32, 10, 40, 6, 68, 65, 71, 69, 83, 72, 39, 83, 7, + 33, 6, 32, 65, 78, 68, 32, 83, 4, 130, 167, 6, 72, 199, 208, 2, 73, 12, + 50, 69, 12, 2, 65, 86, 1, 4, 83, 65, 68, 73, 4, 11, 84, 5, 253, 185, 14, + 7, 32, 87, 73, 84, 72, 32, 68, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 232, + 130, 2, 2, 72, 79, 195, 182, 12, 68, 16, 174, 2, 76, 202, 174, 9, 65, + 214, 172, 2, 84, 202, 219, 2, 82, 132, 138, 9, 2, 68, 65, 242, 99, 75, + 222, 106, 72, 169, 4, 7, 70, 73, 78, 65, 76, 32, 77, 7, 33, 6, 32, 87, + 73, 84, 72, 32, 4, 216, 7, 2, 72, 73, 235, 175, 14, 68, 10, 72, 6, 65, + 76, 69, 70, 32, 76, 29, 8, 89, 73, 68, 68, 73, 83, 72, 32, 2, 233, 241, + 23, 2, 65, 77, 8, 120, 7, 68, 79, 85, 66, 76, 69, 32, 148, 5, 9, 89, 79, + 68, 32, 89, 79, 68, 32, 80, 169, 225, 21, 5, 86, 65, 86, 32, 89, 4, 130, + 218, 11, 86, 187, 140, 10, 89, 6, 80, 3, 76, 79, 87, 0, 3, 85, 80, 80, + 185, 204, 23, 6, 77, 65, 83, 79, 82, 65, 2, 197, 144, 24, 2, 69, 82, 54, + 84, 5, 79, 73, 78, 84, 32, 209, 6, 11, 85, 78, 67, 84, 85, 65, 84, 73, + 79, 78, 32, 42, 220, 1, 7, 68, 65, 71, 69, 83, 72, 32, 98, 72, 106, 80, + 162, 1, 81, 86, 82, 22, 83, 224, 159, 10, 2, 84, 83, 224, 159, 11, 17, + 74, 85, 68, 69, 79, 45, 83, 80, 65, 78, 73, 83, 72, 32, 86, 65, 82, 173, + 152, 3, 3, 77, 69, 84, 4, 48, 2, 79, 82, 149, 4, 5, 72, 65, 90, 65, 81, + 2, 17, 2, 32, 77, 2, 197, 1, 2, 65, 80, 12, 60, 5, 65, 84, 65, 70, 32, + 102, 73, 33, 4, 79, 76, 65, 77, 6, 38, 80, 34, 81, 141, 2, 2, 83, 69, 2, + 11, 65, 2, 143, 172, 18, 84, 2, 241, 150, 24, 2, 65, 77, 2, 11, 82, 2, + 251, 178, 14, 73, 5, 145, 212, 11, 12, 32, 72, 65, 83, 69, 82, 32, 70, + 79, 82, 32, 86, 6, 52, 5, 65, 77, 65, 84, 83, 185, 138, 12, 2, 85, 66, 5, + 169, 189, 11, 2, 32, 81, 2, 163, 139, 7, 65, 10, 34, 69, 22, 72, 203, + 234, 8, 73, 2, 163, 136, 24, 71, 6, 36, 3, 69, 86, 65, 163, 234, 8, 73, + 5, 21, 3, 32, 78, 65, 2, 173, 174, 23, 5, 32, 77, 85, 68, 71, 12, 152, 1, + 3, 71, 69, 82, 60, 3, 80, 65, 83, 20, 7, 83, 79, 70, 32, 80, 65, 83, 160, + 218, 22, 7, 78, 85, 78, 32, 72, 65, 70, 249, 190, 1, 3, 77, 65, 81, 4, + 26, 83, 223, 172, 23, 69, 2, 169, 152, 24, 3, 72, 65, 89, 2, 195, 174, + 14, 69, 2, 175, 174, 14, 85, 8, 114, 77, 220, 224, 12, 15, 76, 83, 67, + 72, 82, 69, 73, 66, 69, 82, 32, 80, 65, 85, 83, 189, 232, 5, 3, 73, 67, + 79, 4, 200, 133, 6, 12, 69, 84, 32, 87, 73, 84, 72, 32, 87, 72, 73, 84, + 191, 254, 17, 32, 188, 4, 160, 1, 2, 65, 45, 50, 72, 70, 75, 234, 1, 77, + 114, 78, 146, 2, 82, 66, 83, 70, 84, 226, 1, 87, 62, 89, 110, 69, 178, + 191, 9, 85, 158, 174, 5, 79, 147, 194, 3, 73, 8, 206, 248, 24, 87, 246, + 30, 49, 2, 50, 3, 51, 72, 242, 229, 8, 79, 254, 38, 65, 150, 234, 5, 85, + 178, 116, 69, 3, 73, 74, 76, 2, 65, 45, 104, 2, 79, 45, 190, 7, 69, 190, + 220, 8, 73, 195, 133, 7, 85, 24, 166, 181, 12, 49, 134, 202, 12, 75, 214, + 22, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 8, 190, 129, 25, + 75, 218, 19, 49, 2, 50, 3, 51, 54, 68, 2, 69, 45, 198, 6, 79, 254, 225, + 15, 65, 2, 73, 227, 205, 2, 85, 6, 230, 145, 25, 77, 186, 2, 49, 3, 50, + 68, 116, 2, 69, 45, 72, 2, 73, 45, 162, 2, 65, 238, 193, 9, 79, 158, 174, + 5, 85, 221, 148, 6, 6, 45, 77, 85, 45, 77, 79, 14, 138, 244, 24, 75, 246, + 30, 49, 2, 50, 2, 51, 2, 52, 2, 53, 3, 54, 16, 226, 251, 24, 84, 214, 22, + 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 3, 55, 54, 138, 4, 79, 2, 85, 254, + 225, 15, 73, 226, 205, 2, 65, 3, 69, 68, 202, 3, 73, 190, 220, 8, 65, 2, + 85, 246, 98, 69, 207, 162, 6, 79, 64, 74, 69, 20, 2, 79, 45, 72, 2, 85, + 45, 222, 227, 15, 73, 227, 205, 2, 65, 18, 139, 202, 19, 45, 14, 202, + 141, 25, 82, 186, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 3, 54, 10, 198, 240, + 24, 84, 246, 30, 49, 2, 50, 2, 51, 3, 52, 42, 214, 192, 9, 65, 2, 73, + 206, 162, 6, 79, 227, 205, 2, 69, 32, 40, 2, 65, 45, 66, 79, 223, 175, + 18, 85, 12, 166, 239, 24, 89, 246, 30, 49, 2, 50, 2, 51, 2, 52, 3, 53, + 12, 11, 45, 12, 206, 141, 25, 49, 2, 50, 2, 51, 2, 52, 2, 53, 3, 54, 4, + 216, 225, 8, 21, 77, 73, 84, 73, 65, 78, 32, 67, 79, 78, 74, 85, 71, 65, + 84, 69, 32, 77, 65, 84, 82, 187, 171, 16, 66, 128, 1, 210, 2, 65, 110, + 66, 144, 1, 2, 67, 79, 94, 68, 198, 2, 70, 66, 71, 40, 4, 72, 79, 76, 68, + 164, 1, 2, 73, 78, 116, 2, 77, 79, 58, 79, 122, 80, 100, 2, 82, 69, 66, + 83, 238, 1, 84, 210, 5, 87, 240, 238, 15, 4, 76, 73, 77, 73, 208, 193, 5, + 11, 89, 79, 85, 84, 72, 70, 85, 76, 32, 70, 79, 129, 182, 3, 9, 69, 78, + 84, 72, 85, 83, 73, 65, 83, 6, 76, 3, 80, 80, 82, 124, 4, 70, 84, 69, 82, + 225, 241, 19, 4, 66, 85, 78, 68, 2, 201, 230, 24, 2, 79, 65, 6, 92, 5, + 69, 70, 79, 82, 69, 240, 235, 3, 6, 73, 84, 73, 78, 71, 32, 1, 4, 82, 69, + 65, 75, 2, 165, 183, 24, 7, 32, 67, 79, 77, 80, 76, 69, 6, 26, 78, 227, + 232, 19, 77, 4, 220, 155, 21, 4, 84, 69, 77, 80, 193, 218, 2, 3, 70, 76, + 73, 14, 110, 69, 78, 73, 226, 236, 19, 85, 209, 248, 2, 15, 65, 82, 75, + 69, 78, 73, 78, 71, 32, 79, 70, 32, 84, 72, 69, 6, 138, 233, 19, 67, 184, + 6, 2, 76, 73, 133, 211, 4, 5, 86, 69, 76, 79, 80, 4, 168, 223, 19, 21, + 70, 70, 73, 67, 85, 76, 84, 89, 32, 65, 84, 32, 84, 72, 69, 32, 66, 69, + 71, 73, 78, 233, 255, 2, 4, 83, 80, 69, 82, 4, 136, 228, 19, 2, 79, 76, + 141, 203, 4, 5, 69, 76, 76, 79, 87, 12, 36, 5, 65, 84, 72, 69, 82, 35, + 82, 2, 129, 218, 15, 3, 73, 78, 71, 10, 40, 4, 69, 65, 84, 32, 251, 197, + 24, 65, 8, 22, 80, 215, 5, 84, 6, 22, 79, 151, 5, 82, 4, 172, 2, 2, 83, + 83, 171, 194, 24, 87, 8, 50, 78, 250, 228, 19, 67, 209, 5, 3, 70, 76, 85, + 4, 196, 234, 19, 2, 79, 67, 185, 238, 1, 5, 69, 82, 32, 84, 82, 4, 172, + 142, 23, 3, 68, 69, 83, 233, 64, 3, 85, 84, 72, 6, 26, 66, 37, 2, 80, 80, + 2, 245, 175, 24, 4, 83, 84, 82, 85, 4, 26, 82, 207, 174, 24, 79, 2, 245, + 217, 22, 2, 69, 83, 6, 228, 222, 15, 9, 85, 83, 72, 73, 78, 71, 32, 85, + 80, 188, 139, 2, 3, 82, 79, 71, 207, 216, 6, 69, 6, 26, 84, 251, 212, 19, + 86, 4, 146, 230, 19, 85, 171, 143, 4, 82, 8, 132, 1, 5, 77, 65, 76, 76, + 32, 252, 253, 21, 6, 84, 65, 78, 68, 83, 84, 181, 248, 1, 11, 80, 76, 73, + 84, 84, 73, 78, 71, 32, 65, 80, 4, 24, 2, 80, 82, 43, 84, 2, 129, 231, + 19, 5, 69, 80, 79, 78, 68, 2, 11, 65, 2, 247, 171, 24, 77, 30, 36, 3, 72, + 69, 32, 187, 176, 18, 82, 28, 186, 2, 65, 130, 1, 67, 132, 1, 3, 70, 65, + 77, 20, 9, 82, 69, 67, 69, 80, 84, 73, 86, 69, 30, 87, 184, 22, 12, 77, + 65, 82, 82, 89, 73, 78, 71, 32, 77, 65, 73, 132, 187, 5, 6, 71, 69, 78, + 84, 76, 69, 156, 137, 11, 13, 75, 69, 69, 80, 73, 78, 71, 32, 83, 84, 73, + 76, 76, 137, 240, 3, 7, 74, 79, 89, 79, 85, 83, 32, 6, 58, 82, 145, 128, + 12, 8, 66, 89, 83, 77, 65, 76, 32, 87, 4, 236, 136, 21, 8, 79, 85, 83, + 73, 78, 71, 32, 84, 147, 223, 3, 77, 6, 248, 134, 1, 2, 65, 85, 208, 128, + 20, 9, 82, 69, 65, 84, 73, 86, 69, 32, 72, 241, 213, 1, 9, 76, 73, 78, + 71, 73, 78, 71, 32, 70, 2, 207, 212, 24, 73, 2, 145, 134, 21, 2, 32, 69, + 4, 134, 234, 22, 69, 221, 207, 1, 5, 65, 78, 68, 69, 82, 4, 222, 145, 7, + 65, 129, 201, 6, 14, 79, 82, 75, 32, 79, 78, 32, 84, 72, 69, 32, 68, 69, + 67, 224, 1, 236, 1, 2, 71, 72, 180, 2, 7, 82, 65, 71, 65, 78, 65, 32, + 216, 4, 7, 83, 84, 79, 82, 73, 67, 32, 172, 141, 16, 7, 78, 68, 85, 32, + 84, 69, 77, 240, 33, 4, 75, 73, 78, 71, 214, 251, 1, 66, 209, 182, 4, 8, + 80, 80, 79, 80, 79, 84, 65, 77, 12, 18, 32, 119, 45, 6, 216, 174, 5, 2, + 66, 82, 176, 162, 17, 6, 86, 79, 76, 84, 65, 71, 225, 49, 9, 79, 67, 84, + 69, 84, 32, 80, 82, 69, 6, 92, 11, 83, 80, 69, 69, 68, 32, 84, 82, 65, + 73, 78, 133, 240, 5, 6, 72, 69, 69, 76, 69, 68, 5, 157, 133, 12, 14, 32, + 87, 73, 84, 72, 32, 66, 85, 76, 76, 69, 84, 32, 78, 202, 1, 108, 8, 68, + 73, 71, 82, 65, 80, 72, 32, 28, 7, 76, 69, 84, 84, 69, 82, 32, 146, 178, + 1, 86, 167, 149, 21, 73, 4, 138, 167, 1, 75, 55, 89, 194, 1, 194, 1, 65, + 74, 83, 234, 168, 1, 66, 162, 3, 78, 202, 2, 68, 2, 71, 2, 72, 2, 75, 2, + 77, 2, 80, 2, 82, 2, 84, 2, 90, 98, 87, 46, 89, 178, 154, 23, 86, 234, + 36, 69, 2, 73, 2, 79, 3, 85, 7, 37, 7, 82, 67, 72, 65, 73, 67, 32, 4, + 170, 202, 24, 87, 151, 14, 89, 42, 76, 5, 77, 65, 76, 76, 32, 166, 238, + 24, 65, 2, 69, 2, 73, 2, 79, 3, 85, 32, 222, 174, 1, 87, 46, 89, 134, + 210, 5, 75, 174, 200, 17, 84, 234, 36, 65, 2, 69, 2, 73, 2, 79, 3, 85, 2, + 223, 254, 8, 83, 110, 166, 1, 76, 52, 3, 78, 69, 89, 46, 82, 154, 7, 84, + 138, 1, 85, 158, 143, 17, 83, 254, 220, 2, 67, 140, 204, 3, 6, 77, 79, + 84, 72, 69, 84, 198, 167, 1, 79, 155, 3, 80, 6, 184, 223, 16, 4, 76, 79, + 87, 32, 199, 140, 8, 69, 4, 146, 246, 22, 66, 129, 165, 1, 2, 32, 80, 68, + 60, 8, 73, 90, 79, 78, 84, 65, 76, 32, 161, 6, 2, 83, 69, 62, 226, 1, 66, + 110, 76, 152, 1, 17, 79, 78, 69, 32, 69, 73, 71, 72, 84, 72, 32, 66, 76, + 79, 67, 75, 45, 88, 10, 83, 67, 65, 78, 32, 76, 73, 78, 69, 45, 46, 84, + 170, 186, 22, 67, 42, 68, 66, 69, 250, 6, 77, 150, 1, 82, 247, 2, 90, 6, + 44, 5, 76, 65, 67, 75, 32, 243, 175, 24, 65, 4, 38, 79, 225, 170, 23, 3, + 72, 69, 88, 2, 211, 170, 23, 67, 10, 40, 4, 73, 78, 69, 32, 207, 192, 22, + 65, 8, 44, 5, 87, 73, 84, 72, 32, 243, 192, 22, 69, 6, 26, 84, 175, 194, + 22, 70, 4, 206, 194, 22, 72, 155, 92, 73, 14, 140, 182, 17, 3, 49, 51, + 53, 234, 176, 7, 50, 2, 51, 2, 52, 2, 53, 2, 54, 3, 55, 8, 158, 230, 24, + 49, 2, 51, 2, 55, 3, 57, 10, 32, 2, 65, 66, 179, 197, 22, 82, 8, 26, 85, + 179, 196, 22, 32, 6, 33, 6, 76, 65, 84, 73, 79, 78, 7, 11, 32, 4, 208, + 143, 10, 8, 87, 73, 84, 72, 32, 74, 85, 83, 155, 160, 14, 83, 7, 11, 32, + 4, 160, 245, 7, 2, 82, 65, 139, 178, 16, 70, 10, 26, 32, 159, 216, 23, + 69, 8, 86, 80, 132, 206, 19, 5, 66, 69, 86, 69, 82, 148, 80, 3, 83, 80, + 82, 159, 196, 4, 68, 2, 183, 185, 15, 69, 12, 48, 6, 82, 71, 76, 65, 83, + 83, 77, 2, 83, 69, 5, 133, 139, 21, 14, 32, 87, 73, 84, 72, 32, 70, 76, + 79, 87, 73, 78, 71, 32, 9, 11, 32, 6, 88, 8, 87, 73, 84, 72, 32, 71, 65, + 82, 169, 212, 22, 8, 66, 85, 73, 76, 68, 73, 78, 71, 2, 131, 136, 23, 68, + 7, 130, 225, 24, 74, 3, 83, 8, 106, 83, 172, 202, 23, 11, 78, 68, 82, 69, + 68, 32, 80, 79, 73, 78, 84, 176, 13, 2, 71, 71, 163, 136, 1, 84, 2, 135, + 205, 23, 72, 22, 80, 2, 71, 73, 22, 80, 136, 2, 5, 83, 84, 69, 82, 69, + 237, 211, 22, 2, 65, 67, 4, 235, 198, 22, 69, 14, 80, 3, 69, 82, 66, 20, + 3, 72, 69, 78, 221, 192, 4, 6, 79, 68, 73, 65, 83, 84, 2, 147, 188, 24, + 79, 11, 34, 32, 82, 65, 227, 204, 20, 45, 4, 26, 87, 163, 248, 22, 66, 2, + 21, 3, 73, 84, 72, 2, 137, 211, 3, 2, 32, 68, 2, 213, 168, 13, 6, 84, 73, + 79, 78, 32, 80, 2, 165, 199, 23, 2, 83, 73, 222, 5, 172, 1, 3, 67, 69, + 32, 152, 1, 2, 68, 69, 222, 24, 77, 222, 2, 78, 230, 37, 82, 132, 2, 7, + 90, 65, 75, 65, 89, 65, 32, 173, 193, 20, 9, 32, 76, 79, 86, 69, 32, 89, + 79, 85, 8, 114, 67, 184, 236, 11, 18, 72, 79, 67, 75, 69, 89, 32, 83, 84, + 73, 67, 75, 32, 65, 78, 68, 32, 80, 227, 191, 1, 83, 4, 166, 194, 16, 82, + 207, 195, 6, 85, 246, 1, 68, 3, 78, 84, 73, 201, 1, 9, 79, 71, 82, 65, + 80, 72, 73, 67, 32, 8, 64, 4, 67, 65, 76, 32, 105, 8, 70, 73, 67, 65, 84, + 73, 79, 78, 6, 32, 2, 84, 79, 231, 215, 23, 87, 5, 189, 197, 15, 12, 32, + 65, 78, 68, 32, 83, 76, 65, 78, 84, 69, 68, 2, 153, 191, 23, 2, 32, 67, + 238, 1, 208, 2, 11, 65, 78, 78, 79, 84, 65, 84, 73, 79, 78, 32, 242, 3, + 67, 72, 2, 68, 69, 248, 5, 5, 78, 85, 77, 66, 69, 22, 84, 140, 150, 6, 8, + 72, 65, 76, 70, 32, 70, 73, 76, 180, 198, 1, 5, 69, 78, 84, 69, 82, 0, 3, + 82, 73, 83, 24, 5, 76, 69, 86, 69, 76, 164, 167, 9, 5, 86, 65, 82, 73, + 65, 182, 237, 4, 70, 226, 47, 73, 167, 235, 1, 83, 32, 232, 1, 5, 66, 79, + 84, 84, 79, 22, 70, 82, 77, 62, 84, 140, 1, 4, 76, 73, 78, 75, 140, 148, + 1, 4, 83, 69, 67, 79, 154, 207, 6, 79, 132, 159, 6, 6, 82, 69, 86, 69, + 82, 83, 224, 229, 9, 5, 72, 69, 65, 86, 69, 169, 39, 3, 69, 65, 82, 2, + 243, 145, 24, 77, 6, 48, 3, 79, 85, 82, 169, 136, 24, 3, 73, 82, 83, 4, + 158, 145, 24, 84, 27, 32, 4, 36, 3, 73, 68, 68, 171, 233, 23, 65, 2, 199, + 131, 14, 76, 8, 34, 72, 46, 87, 131, 202, 8, 79, 4, 178, 220, 9, 82, 165, + 169, 14, 2, 73, 82, 2, 131, 144, 24, 79, 4, 36, 3, 76, 79, 83, 203, 247, + 21, 79, 2, 197, 143, 24, 3, 73, 78, 71, 36, 104, 20, 83, 67, 82, 73, 80, + 84, 73, 79, 78, 32, 67, 72, 65, 82, 65, 67, 84, 69, 82, 32, 203, 225, 7, + 80, 34, 144, 2, 9, 65, 66, 79, 86, 69, 32, 84, 79, 32, 84, 8, 76, 69, 70, + 84, 32, 84, 79, 32, 76, 5, 79, 86, 69, 82, 76, 20, 2, 83, 85, 134, 196, + 15, 82, 224, 203, 5, 8, 70, 85, 76, 76, 32, 83, 85, 82, 237, 235, 2, 15, + 72, 79, 82, 73, 90, 79, 78, 84, 65, 76, 32, 82, 69, 70, 76, 4, 60, 9, 77, + 73, 68, 68, 76, 69, 32, 65, 78, 163, 168, 22, 66, 2, 151, 152, 22, 68, 4, + 228, 246, 22, 10, 77, 73, 68, 68, 76, 69, 32, 65, 78, 68, 227, 171, 1, + 82, 2, 183, 177, 17, 65, 18, 72, 12, 82, 82, 79, 85, 78, 68, 32, 70, 82, + 79, 77, 32, 131, 134, 18, 66, 16, 82, 76, 156, 151, 12, 3, 85, 80, 80, + 242, 142, 10, 66, 162, 168, 1, 65, 159, 82, 82, 6, 142, 151, 12, 79, 171, + 137, 12, 69, 2, 239, 163, 9, 82, 148, 1, 92, 10, 65, 76, 76, 89, 32, 77, + 65, 82, 75, 32, 41, 9, 69, 76, 69, 71, 82, 65, 80, 72, 32, 10, 214, 211, + 22, 70, 70, 84, 179, 90, 79, 138, 1, 140, 1, 11, 83, 89, 77, 66, 79, 76, + 32, 70, 79, 82, 32, 201, 179, 13, 17, 76, 73, 78, 69, 32, 70, 69, 69, 68, + 32, 83, 69, 80, 65, 82, 65, 84, 136, 1, 182, 1, 65, 58, 68, 200, 2, 5, + 72, 79, 85, 82, 32, 214, 1, 74, 28, 4, 70, 69, 66, 82, 64, 2, 77, 65, + 180, 146, 16, 3, 78, 79, 86, 0, 4, 83, 69, 80, 84, 25, 4, 79, 67, 84, 79, + 4, 156, 212, 20, 3, 85, 71, 85, 133, 144, 2, 2, 80, 82, 64, 44, 3, 65, + 89, 32, 253, 150, 16, 2, 69, 67, 62, 66, 84, 190, 249, 5, 69, 66, 70, 70, + 78, 26, 83, 211, 175, 17, 79, 34, 34, 72, 90, 87, 255, 244, 23, 69, 8, + 36, 3, 73, 82, 84, 215, 207, 22, 82, 6, 26, 89, 223, 235, 22, 69, 5, 215, + 151, 23, 45, 24, 26, 69, 195, 196, 24, 79, 22, 36, 3, 78, 84, 89, 199, + 199, 23, 76, 21, 179, 241, 15, 45, 50, 78, 84, 154, 247, 5, 69, 66, 70, + 70, 78, 26, 83, 222, 213, 16, 90, 247, 89, 79, 20, 42, 87, 246, 248, 5, + 72, 183, 250, 17, 69, 14, 26, 69, 239, 194, 24, 79, 12, 36, 3, 78, 84, + 89, 243, 197, 23, 76, 11, 211, 238, 17, 45, 6, 24, 2, 65, 78, 35, 85, 2, + 11, 85, 2, 227, 246, 17, 65, 4, 158, 171, 24, 78, 143, 5, 76, 4, 170, + 159, 24, 82, 171, 34, 89, 68, 40, 6, 65, 71, 69, 32, 79, 70, 83, 80, 5, + 205, 209, 9, 15, 32, 79, 82, 32, 65, 80, 80, 82, 79, 88, 73, 77, 65, 84, + 69, 65, 65, 14, 69, 82, 73, 65, 76, 32, 65, 82, 65, 77, 65, 73, 67, 32, + 62, 72, 7, 78, 85, 77, 66, 69, 82, 32, 178, 19, 76, 129, 161, 20, 2, 83, + 69, 16, 26, 84, 207, 149, 16, 79, 10, 206, 130, 12, 87, 250, 148, 1, 69, + 131, 178, 9, 72, 148, 3, 202, 1, 67, 210, 2, 68, 214, 6, 70, 232, 1, 5, + 72, 73, 66, 73, 84, 156, 1, 15, 80, 85, 84, 32, 83, 89, 77, 66, 79, 76, + 32, 70, 79, 82, 32, 206, 1, 83, 236, 5, 2, 84, 69, 206, 8, 86, 243, 196, + 10, 66, 14, 36, 2, 79, 77, 169, 1, 2, 82, 69, 8, 84, 3, 77, 69, 78, 216, + 158, 17, 3, 73, 78, 71, 165, 230, 2, 5, 80, 76, 69, 84, 69, 4, 49, 10, + 83, 85, 82, 65, 66, 73, 76, 73, 84, 89, 5, 153, 234, 22, 2, 32, 73, 6, + 36, 3, 65, 83, 69, 235, 247, 23, 77, 4, 34, 32, 237, 254, 10, 2, 83, 32, + 2, 133, 130, 12, 8, 70, 79, 78, 84, 32, 83, 73, 90, 145, 1, 24, 2, 69, + 88, 103, 73, 5, 145, 159, 23, 20, 32, 80, 79, 73, 78, 84, 73, 78, 71, 32, + 65, 84, 32, 84, 72, 69, 32, 86, 73, 69, 138, 1, 72, 8, 67, 32, 83, 73, + 89, 65, 81, 32, 201, 215, 18, 4, 65, 78, 32, 82, 136, 1, 196, 1, 11, 65, + 76, 84, 69, 82, 78, 65, 84, 69, 32, 76, 2, 76, 28, 9, 70, 82, 65, 67, 84, + 73, 79, 78, 32, 100, 7, 78, 85, 77, 66, 69, 82, 32, 198, 192, 9, 82, 129, + 121, 6, 80, 76, 65, 67, 69, 72, 2, 197, 245, 23, 2, 65, 75, 6, 68, 4, 79, + 78, 69, 32, 177, 175, 22, 7, 84, 72, 82, 69, 69, 32, 81, 4, 134, 173, 22, + 72, 47, 81, 122, 212, 1, 10, 65, 76, 84, 69, 82, 78, 65, 84, 69, 32, 72, + 5, 75, 65, 82, 79, 82, 0, 4, 76, 65, 75, 72, 162, 212, 10, 69, 66, 70, + 94, 78, 26, 83, 78, 84, 232, 138, 5, 8, 80, 82, 69, 70, 73, 88, 69, 68, + 179, 41, 79, 6, 26, 84, 247, 152, 23, 79, 4, 212, 201, 6, 2, 69, 78, 219, + 203, 17, 87, 5, 151, 228, 23, 65, 16, 72, 5, 73, 78, 73, 84, 89, 57, 9, + 79, 82, 77, 65, 84, 73, 79, 78, 32, 5, 185, 233, 3, 9, 32, 78, 69, 71, + 65, 84, 69, 68, 32, 12, 42, 83, 173, 168, 20, 4, 68, 69, 83, 75, 10, 228, + 202, 7, 5, 69, 80, 65, 82, 65, 219, 154, 10, 79, 4, 11, 32, 4, 220, 224, + 23, 15, 65, 82, 65, 66, 73, 67, 32, 70, 79, 82, 77, 32, 83, 72, 65, 1, + 14, 83, 89, 77, 77, 69, 84, 82, 73, 67, 32, 83, 87, 65, 80, 10, 80, 6, + 76, 65, 84, 73, 78, 32, 182, 194, 15, 83, 221, 220, 7, 4, 78, 85, 77, 66, + 6, 64, 6, 67, 65, 80, 73, 84, 65, 0, 4, 83, 77, 65, 76, 27, 76, 2, 21, 3, + 76, 32, 76, 2, 193, 168, 22, 2, 69, 84, 116, 84, 13, 67, 82, 73, 80, 84, + 73, 79, 78, 65, 76, 32, 80, 65, 197, 150, 16, 2, 69, 82, 114, 72, 6, 72, + 76, 65, 86, 73, 32, 225, 1, 7, 82, 84, 72, 73, 65, 78, 32, 54, 48, 7, 76, + 69, 84, 84, 69, 82, 32, 191, 3, 78, 38, 214, 246, 10, 84, 242, 119, 65, + 22, 68, 34, 76, 22, 77, 50, 87, 206, 172, 4, 71, 90, 90, 34, 83, 66, 89, + 206, 209, 1, 72, 234, 5, 75, 142, 81, 66, 138, 231, 4, 78, 223, 105, 80, + 60, 22, 76, 251, 1, 78, 44, 11, 69, 44, 29, 5, 84, 84, 69, 82, 32, 44, + 230, 244, 10, 84, 134, 120, 68, 34, 76, 50, 81, 238, 206, 1, 82, 198, + 221, 2, 65, 50, 71, 90, 90, 34, 83, 66, 89, 206, 209, 1, 72, 234, 5, 75, + 142, 81, 66, 138, 231, 4, 78, 134, 2, 87, 218, 103, 80, 171, 4, 77, 16, + 33, 6, 85, 77, 66, 69, 82, 32, 16, 242, 236, 11, 84, 170, 147, 4, 79, + 143, 136, 3, 70, 50, 36, 4, 71, 82, 65, 76, 179, 3, 82, 23, 11, 32, 20, + 58, 65, 140, 1, 5, 87, 73, 84, 72, 32, 235, 128, 22, 69, 4, 96, 6, 86, + 69, 82, 65, 71, 69, 137, 252, 16, 12, 82, 79, 85, 78, 68, 32, 65, 32, 80, + 79, 73, 78, 2, 173, 253, 16, 5, 32, 87, 73, 84, 72, 14, 160, 1, 3, 84, + 73, 77, 20, 2, 85, 78, 148, 160, 7, 16, 76, 69, 70, 84, 87, 65, 82, 68, + 83, 32, 65, 82, 82, 79, 87, 32, 158, 206, 13, 73, 198, 1, 79, 135, 65, + 68, 2, 243, 239, 20, 69, 4, 254, 239, 20, 68, 139, 230, 2, 73, 28, 94, + 76, 232, 1, 7, 83, 69, 67, 84, 73, 79, 78, 222, 7, 82, 240, 196, 12, 2, + 67, 65, 43, 73, 8, 164, 1, 17, 73, 78, 69, 65, 82, 32, 65, 78, 78, 79, + 84, 65, 84, 73, 79, 78, 32, 181, 143, 5, 17, 79, 67, 75, 69, 68, 32, 70, + 69, 77, 65, 76, 69, 32, 65, 78, 68, 32, 6, 156, 241, 8, 3, 65, 78, 67, + 158, 160, 8, 84, 215, 220, 3, 83, 15, 11, 32, 12, 168, 1, 6, 65, 66, 79, + 86, 69, 32, 64, 5, 87, 73, 84, 72, 32, 185, 233, 20, 22, 66, 69, 83, 73, + 68, 69, 32, 65, 78, 68, 32, 74, 79, 73, 78, 69, 68, 32, 87, 73, 84, 72, + 4, 168, 234, 20, 9, 66, 65, 82, 32, 65, 66, 79, 86, 69, 23, 85, 6, 206, + 204, 4, 76, 194, 158, 16, 79, 203, 229, 2, 68, 48, 56, 2, 69, 82, 241, 6, + 7, 73, 83, 73, 66, 76, 69, 32, 42, 48, 3, 83, 69, 32, 225, 2, 4, 84, 69, + 68, 32, 16, 174, 1, 66, 80, 5, 67, 72, 69, 67, 75, 68, 24, 68, 79, 87, + 78, 87, 65, 82, 68, 83, 32, 65, 82, 82, 79, 87, 32, 87, 73, 84, 72, 32, + 84, 73, 80, 238, 131, 21, 87, 219, 26, 77, 6, 44, 5, 76, 65, 67, 75, 32, + 227, 184, 22, 85, 4, 142, 220, 22, 68, 167, 30, 83, 4, 128, 158, 21, 8, + 69, 82, 32, 66, 79, 65, 82, 68, 179, 190, 2, 32, 2, 225, 183, 21, 2, 32, + 76, 26, 220, 1, 6, 73, 78, 84, 69, 82, 82, 22, 76, 180, 1, 7, 83, 81, 85, + 65, 82, 69, 32, 230, 187, 12, 80, 220, 188, 4, 6, 87, 73, 71, 71, 76, 89, + 192, 221, 3, 2, 79, 72, 196, 9, 4, 85, 78, 68, 69, 194, 97, 81, 167, 188, + 1, 69, 2, 143, 249, 4, 79, 8, 72, 5, 65, 90, 89, 32, 83, 41, 9, 79, 87, + 32, 75, 65, 86, 89, 75, 65, 5, 153, 145, 7, 5, 32, 79, 86, 69, 82, 5, + 149, 233, 18, 11, 32, 87, 73, 84, 72, 32, 75, 65, 86, 89, 75, 4, 184, + 199, 16, 2, 76, 69, 129, 14, 3, 82, 73, 71, 6, 38, 84, 178, 136, 20, 80, + 163, 91, 83, 2, 171, 251, 16, 73, 4, 194, 253, 22, 69, 215, 93, 73, 192, + 2, 94, 65, 138, 21, 69, 62, 79, 42, 85, 233, 132, 12, 10, 73, 71, 83, 65, + 87, 32, 80, 85, 90, 90, 202, 1, 120, 5, 67, 75, 45, 79, 45, 32, 7, 80, + 65, 78, 69, 83, 69, 32, 184, 2, 7, 86, 65, 78, 69, 83, 69, 32, 155, 148, + 24, 82, 2, 245, 253, 18, 3, 76, 65, 78, 16, 246, 1, 67, 18, 80, 148, 156, + 1, 10, 73, 78, 68, 85, 83, 84, 82, 73, 65, 76, 200, 133, 4, 3, 66, 65, + 78, 162, 212, 3, 68, 232, 144, 11, 15, 83, 89, 77, 66, 79, 76, 32, 70, + 79, 82, 32, 66, 69, 71, 73, 224, 250, 1, 3, 71, 79, 66, 137, 112, 2, 79, + 71, 2, 215, 33, 65, 2, 169, 213, 13, 7, 79, 83, 84, 32, 79, 70, 70, 182, + 1, 172, 2, 15, 67, 79, 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, + 32, 76, 2, 76, 69, 40, 4, 82, 73, 71, 72, 224, 6, 2, 80, 65, 176, 3, 14, + 84, 85, 82, 78, 69, 68, 32, 80, 65, 68, 65, 32, 80, 73, 88, 5, 83, 73, + 71, 78, 32, 144, 1, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 219, + 141, 22, 68, 6, 52, 2, 75, 69, 200, 143, 17, 2, 80, 69, 175, 5, 67, 2, + 147, 220, 23, 82, 96, 38, 70, 65, 5, 84, 84, 69, 82, 32, 2, 41, 8, 84, + 32, 82, 69, 82, 69, 78, 71, 2, 175, 193, 22, 71, 94, 230, 1, 68, 26, 73, + 48, 2, 75, 65, 66, 78, 130, 1, 66, 2, 67, 2, 71, 16, 2, 80, 65, 56, 2, + 82, 65, 32, 2, 83, 65, 42, 84, 74, 74, 134, 251, 21, 65, 174, 141, 2, 72, + 2, 76, 2, 77, 2, 87, 2, 89, 186, 2, 69, 2, 79, 3, 85, 8, 222, 3, 68, 15, + 65, 7, 152, 238, 5, 3, 32, 75, 65, 151, 160, 18, 73, 7, 11, 32, 4, 22, + 83, 215, 2, 77, 2, 213, 208, 21, 2, 65, 83, 14, 36, 2, 71, 65, 90, 89, + 167, 1, 65, 7, 33, 6, 32, 76, 69, 76, 69, 84, 5, 29, 5, 32, 82, 65, 83, + 87, 2, 255, 134, 6, 65, 4, 163, 1, 65, 7, 11, 32, 4, 154, 1, 77, 229, + 135, 24, 3, 67, 69, 82, 5, 249, 146, 17, 3, 32, 65, 71, 7, 17, 2, 32, 77, + 4, 70, 85, 71, 65, 8, 18, 65, 55, 84, 5, 17, 2, 32, 77, 2, 11, 85, 2, + 247, 229, 23, 82, 4, 11, 65, 5, 11, 32, 2, 11, 77, 2, 11, 65, 2, 11, 72, + 2, 209, 255, 17, 2, 65, 80, 28, 40, 3, 68, 65, 32, 165, 3, 2, 78, 71, 24, + 174, 1, 65, 90, 76, 86, 80, 232, 195, 7, 10, 84, 73, 82, 84, 65, 32, 84, + 85, 77, 69, 254, 159, 12, 87, 144, 202, 2, 7, 73, 83, 69, 78, 45, 73, 83, + 185, 214, 1, 3, 77, 65, 68, 6, 44, 3, 68, 69, 71, 253, 244, 22, 2, 78, + 68, 5, 11, 32, 2, 141, 194, 23, 2, 65, 68, 6, 38, 85, 241, 132, 24, 3, + 73, 78, 71, 4, 204, 142, 19, 2, 78, 71, 147, 128, 4, 72, 4, 38, 73, 169, + 135, 19, 3, 65, 78, 71, 2, 193, 139, 17, 3, 83, 69, 76, 4, 144, 221, 13, + 5, 82, 65, 78, 71, 75, 195, 217, 9, 75, 10, 108, 5, 67, 69, 67, 65, 75, + 216, 238, 5, 3, 87, 73, 71, 246, 155, 11, 76, 193, 228, 2, 5, 80, 65, 78, + 89, 65, 5, 249, 245, 18, 3, 32, 84, 69, 18, 116, 4, 83, 85, 75, 85, 42, + 84, 64, 4, 87, 85, 76, 85, 154, 137, 17, 80, 225, 223, 1, 7, 68, 73, 82, + 71, 65, 32, 77, 5, 173, 138, 23, 5, 32, 77, 69, 78, 68, 6, 26, 65, 215, + 138, 17, 79, 4, 190, 138, 17, 82, 251, 167, 6, 76, 5, 25, 4, 32, 77, 69, + 76, 2, 227, 255, 23, 73, 4, 36, 3, 76, 76, 89, 159, 182, 20, 65, 2, 131, + 153, 20, 70, 4, 204, 207, 22, 2, 89, 83, 255, 98, 73, 108, 120, 14, 82, + 67, 72, 69, 78, 32, 82, 65, 68, 73, 67, 65, 76, 45, 220, 139, 15, 2, 71, + 71, 142, 138, 5, 80, 175, 204, 3, 78, 102, 162, 232, 3, 53, 218, 210, 14, + 48, 130, 2, 49, 2, 50, 2, 51, 3, 52, 154, 18, 74, 65, 242, 79, 69, 218, + 1, 72, 214, 46, 73, 198, 6, 78, 50, 79, 111, 82, 214, 10, 200, 1, 5, 73, + 84, 72, 73, 32, 234, 4, 78, 188, 45, 6, 84, 65, 75, 65, 78, 65, 144, 15, + 3, 87, 73, 32, 220, 8, 7, 89, 65, 72, 32, 76, 73, 32, 252, 230, 4, 6, 75, + 84, 79, 86, 73, 75, 239, 159, 18, 65, 136, 1, 204, 1, 7, 76, 69, 84, 84, + 69, 82, 32, 178, 2, 83, 138, 114, 68, 192, 147, 4, 2, 86, 79, 224, 175, + 3, 11, 78, 85, 77, 66, 69, 82, 32, 83, 73, 71, 78, 194, 203, 9, 65, 189, + 211, 1, 6, 69, 78, 85, 77, 69, 82, 90, 214, 1, 68, 146, 152, 20, 65, 150, + 1, 84, 230, 5, 85, 138, 204, 1, 73, 170, 199, 1, 78, 46, 83, 82, 66, 2, + 67, 2, 71, 2, 74, 2, 75, 2, 80, 2, 82, 138, 69, 72, 2, 76, 2, 77, 2, 86, + 2, 89, 186, 2, 69, 3, 79, 10, 38, 68, 150, 248, 23, 72, 187, 2, 65, 6, + 138, 250, 21, 68, 138, 254, 1, 72, 187, 2, 65, 12, 40, 4, 73, 71, 78, 32, + 195, 220, 11, 69, 10, 150, 214, 19, 67, 98, 78, 130, 222, 3, 65, 239, 1, + 86, 232, 4, 42, 71, 241, 39, 5, 78, 65, 68, 65, 32, 174, 3, 76, 11, 88, + 73, 32, 82, 65, 68, 73, 67, 65, 76, 32, 193, 169, 21, 2, 65, 82, 172, 3, + 130, 2, 65, 94, 66, 230, 2, 67, 150, 2, 68, 158, 3, 69, 198, 1, 70, 138, + 2, 71, 146, 1, 72, 210, 2, 73, 76, 2, 74, 65, 34, 75, 30, 76, 230, 1, 77, + 254, 1, 78, 62, 79, 102, 80, 110, 82, 166, 1, 83, 230, 6, 84, 226, 2, 86, + 50, 87, 210, 2, 89, 147, 198, 22, 85, 10, 56, 2, 82, 82, 202, 198, 22, + 71, 138, 105, 78, 207, 47, 88, 4, 206, 247, 22, 79, 207, 1, 73, 34, 58, + 65, 38, 73, 46, 76, 54, 79, 102, 82, 155, 164, 22, 69, 4, 202, 234, 5, + 77, 179, 180, 14, 68, 6, 222, 183, 22, 84, 242, 118, 82, 163, 70, 71, 6, + 142, 182, 20, 79, 242, 139, 2, 65, 243, 155, 1, 85, 10, 62, 76, 166, 215, + 23, 65, 218, 5, 78, 142, 5, 68, 203, 17, 87, 2, 245, 248, 3, 4, 84, 32, + 79, 70, 6, 42, 73, 182, 184, 10, 65, 175, 204, 11, 85, 2, 227, 194, 14, + 83, 28, 58, 65, 70, 76, 74, 79, 234, 245, 10, 72, 199, 136, 11, 73, 6, + 38, 85, 222, 213, 23, 82, 219, 5, 86, 2, 145, 202, 22, 2, 76, 68, 8, 42, + 65, 230, 133, 8, 73, 195, 213, 14, 79, 4, 190, 241, 23, 78, 3, 87, 10, + 134, 204, 22, 82, 148, 2, 2, 77, 80, 158, 101, 86, 134, 5, 76, 235, 56, + 87, 34, 38, 69, 38, 73, 98, 79, 195, 1, 82, 4, 158, 232, 21, 65, 183, + 207, 1, 69, 8, 38, 83, 234, 195, 14, 86, 175, 2, 80, 4, 164, 134, 20, 5, + 84, 73, 78, 71, 85, 191, 233, 3, 72, 16, 94, 84, 76, 3, 85, 66, 76, 134, + 197, 13, 87, 196, 216, 9, 2, 32, 78, 222, 23, 79, 223, 56, 71, 7, 25, 4, + 84, 69, 68, 32, 4, 208, 130, 8, 3, 67, 76, 73, 183, 168, 15, 84, 2, 167, + 163, 4, 69, 6, 178, 176, 22, 65, 226, 172, 1, 85, 219, 16, 89, 20, 106, + 65, 38, 78, 32, 3, 86, 69, 78, 148, 194, 9, 6, 77, 66, 82, 79, 73, 68, + 182, 255, 13, 73, 243, 19, 89, 6, 174, 174, 17, 82, 163, 190, 6, 84, 4, + 178, 25, 67, 143, 149, 23, 84, 5, 147, 155, 23, 73, 28, 74, 65, 50, 73, + 62, 76, 38, 82, 170, 20, 69, 190, 133, 23, 79, 223, 23, 85, 6, 154, 194, + 14, 84, 190, 146, 9, 67, 131, 22, 78, 8, 230, 179, 13, 69, 222, 140, 10, + 71, 230, 19, 82, 199, 21, 83, 4, 178, 158, 22, 85, 143, 204, 1, 89, 4, + 184, 185, 22, 2, 65, 71, 143, 176, 1, 79, 14, 58, 79, 52, 2, 82, 65, 146, + 246, 19, 72, 231, 166, 2, 65, 7, 146, 163, 23, 76, 241, 34, 5, 32, 83, + 76, 79, 87, 4, 158, 153, 23, 73, 135, 18, 83, 22, 58, 65, 142, 1, 69, 60, + 5, 73, 68, 73, 78, 71, 19, 79, 8, 38, 76, 222, 161, 23, 78, 199, 13, 73, + 4, 34, 70, 233, 206, 22, 2, 66, 69, 2, 41, 8, 32, 84, 82, 69, 69, 32, 84, + 82, 2, 219, 253, 19, 85, 6, 26, 65, 243, 230, 23, 77, 4, 206, 202, 23, + 82, 175, 28, 68, 2, 195, 19, 32, 6, 26, 82, 155, 227, 23, 79, 4, 218, + 207, 23, 83, 215, 22, 78, 6, 26, 78, 163, 207, 23, 67, 4, 26, 83, 203, + 228, 23, 67, 2, 203, 212, 22, 69, 4, 238, 206, 23, 68, 215, 22, 82, 2, + 221, 210, 5, 2, 78, 73, 22, 46, 65, 34, 69, 78, 73, 41, 3, 79, 78, 71, 4, + 130, 206, 23, 77, 191, 19, 67, 8, 38, 65, 182, 166, 23, 71, 199, 58, 69, + 4, 254, 186, 14, 84, 147, 169, 9, 70, 6, 150, 205, 23, 70, 2, 78, 215, + 22, 68, 5, 153, 141, 12, 3, 32, 83, 84, 22, 42, 69, 34, 73, 46, 79, 207, + 146, 23, 65, 4, 138, 147, 23, 76, 195, 51, 65, 4, 164, 180, 12, 2, 78, + 73, 147, 201, 9, 76, 12, 34, 82, 34, 85, 139, 146, 23, 79, 4, 138, 190, + 22, 84, 251, 82, 78, 6, 26, 78, 191, 224, 23, 84, 4, 162, 178, 22, 84, + 171, 175, 1, 68, 6, 26, 79, 227, 196, 23, 69, 4, 182, 202, 23, 83, 215, + 22, 84, 10, 40, 2, 78, 69, 22, 80, 143, 154, 23, 76, 5, 203, 191, 6, 83, + 4, 234, 242, 10, 80, 199, 196, 2, 69, 10, 54, 82, 242, 194, 22, 76, 222, + 1, 79, 179, 154, 1, 73, 4, 144, 146, 13, 2, 73, 86, 245, 144, 7, 2, 79, + 70, 18, 62, 65, 42, 73, 134, 238, 10, 79, 210, 160, 12, 85, 195, 9, 69, + 6, 250, 142, 23, 73, 226, 79, 80, 3, 84, 6, 152, 181, 13, 3, 71, 72, 84, + 174, 235, 9, 86, 155, 39, 67, 74, 170, 1, 65, 86, 67, 54, 69, 62, 72, + 178, 1, 73, 46, 76, 62, 80, 106, 84, 234, 185, 18, 87, 206, 159, 1, 78, + 154, 66, 79, 234, 174, 1, 77, 194, 106, 81, 194, 35, 75, 247, 47, 85, 6, + 136, 224, 3, 9, 67, 82, 73, 70, 73, 67, 73, 65, 76, 150, 224, 19, 76, + 175, 28, 89, 4, 240, 182, 11, 2, 82, 73, 237, 223, 5, 2, 72, 79, 8, 234, + 153, 22, 67, 138, 54, 65, 174, 10, 76, 167, 129, 1, 69, 10, 18, 69, 39, + 79, 4, 162, 207, 22, 76, 199, 139, 1, 69, 6, 40, 4, 82, 84, 32, 84, 251, + 189, 23, 79, 4, 44, 5, 65, 73, 76, 69, 68, 211, 202, 16, 72, 2, 245, 209, + 21, 2, 32, 66, 4, 148, 188, 18, 2, 67, 75, 171, 154, 5, 76, 6, 26, 65, + 151, 156, 23, 73, 4, 186, 194, 23, 86, 199, 21, 83, 10, 50, 69, 34, 73, + 202, 217, 19, 82, 235, 174, 3, 79, 4, 222, 159, 23, 65, 183, 22, 69, 2, + 227, 187, 23, 82, 12, 34, 69, 34, 79, 179, 199, 22, 65, 4, 138, 199, 23, + 65, 219, 16, 80, 6, 26, 80, 215, 192, 23, 78, 5, 163, 134, 23, 80, 30, + 82, 65, 98, 73, 34, 79, 38, 82, 52, 2, 85, 82, 32, 2, 87, 79, 235, 132, + 23, 69, 6, 38, 78, 158, 175, 22, 66, 175, 27, 76, 2, 33, 6, 78, 69, 68, + 32, 76, 69, 2, 215, 172, 14, 65, 4, 242, 151, 23, 71, 155, 39, 76, 4, + 138, 192, 19, 78, 167, 141, 2, 79, 6, 154, 181, 17, 73, 190, 237, 4, 65, + 243, 155, 1, 69, 4, 210, 133, 22, 66, 155, 40, 84, 5, 135, 141, 20, 32, + 4, 250, 159, 13, 65, 169, 159, 5, 3, 73, 76, 76, 26, 58, 65, 110, 69, 42, + 72, 32, 2, 73, 78, 30, 79, 39, 82, 6, 32, 2, 76, 75, 187, 149, 23, 84, 5, + 11, 32, 2, 11, 69, 2, 17, 2, 78, 67, 2, 201, 184, 18, 2, 76, 79, 4, 236, + 130, 23, 2, 65, 80, 195, 51, 83, 4, 166, 134, 22, 73, 223, 66, 69, 4, + 146, 210, 23, 68, 3, 69, 4, 226, 130, 22, 77, 255, 203, 1, 82, 4, 218, + 128, 23, 79, 239, 80, 65, 2, 177, 172, 21, 2, 69, 76, 186, 1, 92, 2, 76, + 69, 148, 2, 5, 83, 73, 71, 78, 32, 158, 148, 18, 65, 186, 9, 86, 175, + 185, 3, 68, 110, 44, 5, 84, 84, 69, 82, 32, 159, 142, 23, 78, 108, 178, + 155, 18, 78, 238, 209, 1, 65, 38, 68, 46, 76, 38, 82, 34, 84, 46, 86, + 186, 5, 85, 194, 142, 1, 79, 202, 61, 73, 214, 199, 1, 83, 82, 66, 2, 67, + 2, 71, 2, 74, 2, 75, 2, 80, 162, 7, 69, 234, 61, 70, 2, 72, 2, 77, 3, 89, + 22, 94, 67, 138, 1, 83, 194, 169, 19, 78, 198, 67, 65, 178, 159, 1, 74, + 150, 3, 85, 231, 249, 1, 86, 4, 100, 19, 79, 77, 66, 73, 78, 73, 78, 71, + 32, 65, 78, 85, 83, 86, 65, 82, 65, 32, 65, 143, 169, 19, 65, 2, 245, + 195, 20, 3, 66, 79, 86, 4, 212, 137, 13, 6, 80, 65, 67, 73, 78, 71, 247, + 145, 5, 73, 174, 2, 62, 32, 237, 12, 10, 45, 72, 73, 82, 65, 71, 65, 78, + 65, 32, 166, 2, 120, 8, 68, 73, 71, 82, 65, 80, 72, 32, 108, 7, 76, 69, + 84, 84, 69, 82, 32, 218, 10, 86, 166, 149, 21, 73, 243, 149, 1, 77, 8, + 34, 75, 20, 2, 84, 79, 35, 89, 2, 143, 210, 19, 79, 4, 170, 179, 23, 84, + 255, 2, 75, 2, 211, 216, 16, 79, 152, 2, 186, 1, 65, 130, 2, 66, 106, 77, + 186, 2, 78, 54, 83, 150, 2, 68, 2, 71, 2, 72, 2, 75, 2, 80, 2, 82, 2, 84, + 2, 86, 2, 90, 98, 87, 46, 89, 154, 191, 23, 69, 2, 73, 2, 79, 3, 85, 23, + 104, 4, 73, 78, 85, 32, 48, 9, 76, 84, 69, 82, 78, 65, 84, 69, 32, 33, 7, + 82, 67, 72, 65, 73, 67, 32, 8, 190, 198, 6, 84, 142, 234, 16, 67, 215, + 22, 80, 4, 154, 176, 23, 78, 255, 2, 87, 8, 38, 89, 194, 161, 23, 87, + 235, 36, 69, 4, 166, 198, 23, 69, 3, 73, 20, 50, 73, 218, 197, 23, 65, 2, + 69, 2, 79, 3, 85, 13, 177, 5, 9, 68, 65, 75, 85, 79, 78, 32, 78, 71, 36, + 50, 73, 242, 196, 23, 65, 2, 69, 2, 79, 3, 85, 29, 29, 5, 78, 78, 65, 78, + 32, 26, 96, 15, 78, 65, 83, 65, 76, 73, 90, 69, 68, 32, 84, 79, 78, 69, + 45, 69, 5, 84, 79, 78, 69, 45, 14, 234, 195, 23, 49, 2, 50, 2, 51, 2, 52, + 2, 53, 2, 55, 3, 56, 12, 166, 195, 23, 50, 2, 51, 2, 52, 2, 53, 2, 55, 3, + 56, 13, 234, 194, 23, 65, 2, 69, 2, 73, 2, 79, 3, 85, 78, 76, 5, 77, 65, + 76, 76, 32, 234, 193, 23, 65, 2, 69, 2, 73, 2, 79, 3, 85, 68, 150, 1, 65, + 46, 72, 2, 82, 54, 75, 46, 87, 46, 89, 186, 190, 6, 84, 246, 164, 13, 78, + 182, 155, 3, 83, 210, 27, 77, 234, 36, 69, 2, 73, 2, 79, 3, 85, 5, 145, + 176, 5, 6, 82, 67, 72, 65, 73, 67, 10, 162, 192, 23, 65, 2, 69, 2, 73, 2, + 79, 3, 85, 8, 238, 191, 23, 65, 2, 69, 2, 79, 3, 85, 8, 194, 191, 23, 65, + 2, 69, 2, 73, 3, 79, 6, 150, 191, 23, 65, 2, 79, 3, 85, 2, 141, 149, 21, 5, 79, 73, 67, 69, 68, 8, 52, 5, 68, 79, 85, 66, 76, 22, 80, 38, 83, 35, - 86, 2, 175, 253, 7, 69, 2, 89, 6, 82, 79, 76, 79, 78, 71, 2, 29, 5, 69, + 86, 2, 143, 195, 8, 69, 2, 89, 6, 82, 79, 76, 79, 78, 71, 2, 29, 5, 69, 77, 73, 45, 86, 2, 21, 3, 79, 73, 67, 2, 33, 6, 69, 68, 32, 83, 79, 85, - 2, 199, 159, 22, 78, 174, 1, 216, 1, 7, 76, 69, 84, 84, 69, 82, 32, 128, + 2, 227, 240, 22, 78, 174, 1, 216, 1, 7, 76, 69, 84, 84, 69, 82, 32, 128, 2, 12, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 32, 148, 3, 5, 83, 73, - 71, 78, 32, 88, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 138, 163, - 12, 68, 151, 224, 6, 67, 94, 226, 1, 65, 250, 162, 4, 74, 198, 231, 14, - 68, 114, 84, 230, 5, 85, 22, 86, 166, 202, 1, 73, 138, 196, 1, 78, 46, + 71, 78, 32, 88, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 222, 236, + 12, 68, 239, 226, 6, 67, 94, 226, 1, 65, 214, 194, 4, 74, 150, 148, 15, + 68, 114, 84, 230, 5, 85, 22, 86, 246, 203, 1, 73, 170, 199, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 75, 2, 80, 138, 69, 72, 2, 76, 2, 77, 2, 82, - 2, 87, 2, 89, 186, 2, 69, 3, 79, 7, 138, 232, 22, 65, 3, 73, 22, 122, 67, + 2, 87, 2, 89, 186, 2, 69, 3, 79, 7, 166, 185, 23, 65, 3, 73, 22, 122, 67, 90, 68, 58, 70, 54, 83, 20, 12, 65, 76, 84, 69, 82, 78, 65, 84, 69, 32, - 83, 69, 213, 209, 21, 4, 84, 82, 73, 80, 4, 56, 8, 76, 79, 83, 73, 78, - 71, 32, 83, 175, 146, 21, 73, 2, 205, 218, 21, 2, 80, 73, 4, 11, 79, 4, - 196, 210, 21, 2, 85, 66, 203, 147, 1, 84, 4, 176, 145, 21, 5, 73, 76, 76, - 69, 68, 163, 57, 76, 6, 18, 69, 23, 80, 2, 163, 237, 10, 67, 4, 192, 147, - 4, 2, 65, 67, 223, 197, 17, 73, 12, 146, 223, 7, 75, 234, 231, 10, 67, - 98, 78, 238, 64, 82, 170, 162, 1, 86, 247, 244, 1, 65, 20, 66, 65, 170, - 161, 4, 86, 158, 235, 14, 69, 2, 85, 187, 202, 1, 73, 6, 216, 225, 16, 8, - 76, 84, 69, 82, 78, 65, 84, 69, 230, 129, 6, 65, 3, 73, 96, 148, 1, 7, + 83, 69, 241, 162, 22, 4, 84, 82, 73, 80, 4, 56, 8, 76, 79, 83, 73, 78, + 71, 32, 83, 187, 224, 21, 73, 2, 233, 171, 22, 2, 80, 73, 4, 11, 79, 4, + 224, 163, 22, 2, 85, 66, 203, 147, 1, 84, 4, 188, 223, 21, 5, 73, 76, 76, + 69, 68, 179, 60, 76, 6, 18, 69, 23, 80, 2, 191, 180, 11, 67, 4, 156, 179, + 4, 2, 65, 67, 159, 247, 17, 73, 12, 138, 165, 8, 75, 150, 237, 10, 67, + 98, 78, 246, 65, 82, 158, 163, 1, 86, 243, 248, 1, 65, 20, 66, 65, 134, + 193, 4, 86, 238, 151, 15, 69, 2, 85, 139, 204, 1, 73, 6, 128, 173, 17, 8, + 76, 84, 69, 82, 78, 65, 84, 69, 218, 135, 6, 65, 3, 73, 96, 148, 1, 7, 76, 69, 84, 84, 69, 82, 32, 200, 1, 5, 83, 73, 71, 78, 32, 44, 5, 84, 79, - 78, 69, 32, 92, 6, 86, 79, 87, 69, 76, 32, 135, 235, 20, 68, 56, 242, - 197, 18, 79, 186, 7, 72, 158, 151, 2, 78, 214, 181, 1, 75, 2, 80, 2, 83, + 78, 69, 32, 92, 6, 86, 79, 87, 69, 76, 32, 139, 185, 21, 68, 56, 150, + 145, 19, 79, 186, 7, 72, 254, 153, 2, 78, 238, 184, 1, 75, 2, 80, 2, 83, 2, 84, 138, 69, 66, 2, 67, 2, 68, 2, 71, 2, 76, 2, 77, 2, 82, 2, 86, 2, - 87, 2, 89, 2, 90, 186, 2, 65, 3, 73, 4, 182, 239, 4, 67, 129, 238, 17, 2, - 83, 72, 6, 36, 5, 67, 65, 76, 89, 65, 23, 80, 5, 17, 2, 32, 80, 2, 225, - 232, 17, 3, 76, 79, 80, 10, 234, 158, 22, 69, 2, 85, 163, 64, 79, 36, 24, - 2, 76, 86, 23, 89, 2, 191, 226, 20, 73, 35, 68, 5, 66, 79, 65, 82, 68, - 36, 4, 67, 65, 80, 32, 167, 242, 2, 72, 5, 169, 149, 19, 4, 32, 65, 78, - 68, 26, 142, 146, 17, 78, 138, 180, 3, 65, 170, 35, 68, 135, 30, 84, 142, + 87, 2, 89, 2, 90, 186, 2, 65, 3, 73, 4, 154, 145, 5, 67, 185, 157, 18, 2, + 83, 72, 6, 36, 5, 67, 65, 76, 89, 65, 23, 80, 5, 17, 2, 32, 80, 2, 141, + 180, 18, 3, 76, 79, 80, 10, 134, 240, 22, 69, 2, 85, 163, 64, 79, 36, 24, + 2, 76, 86, 23, 89, 2, 195, 176, 21, 73, 35, 68, 5, 66, 79, 65, 82, 68, + 36, 4, 67, 65, 80, 32, 171, 145, 3, 72, 5, 205, 225, 19, 4, 32, 65, 78, + 68, 26, 190, 221, 17, 78, 214, 182, 3, 65, 178, 35, 68, 143, 30, 84, 142, 6, 202, 1, 65, 224, 9, 4, 77, 69, 82, 32, 204, 25, 5, 79, 74, 75, 73, 32, - 140, 6, 8, 85, 68, 65, 87, 65, 68, 73, 32, 169, 172, 7, 17, 73, 84, 65, + 140, 6, 8, 85, 68, 65, 87, 65, 68, 73, 32, 161, 242, 7, 17, 73, 84, 65, 78, 32, 83, 77, 65, 76, 76, 32, 83, 67, 82, 73, 80, 84, 138, 1, 56, 8, - 82, 79, 83, 72, 84, 72, 73, 32, 251, 181, 22, 78, 136, 1, 220, 1, 4, 68, + 82, 79, 83, 72, 84, 72, 73, 32, 151, 135, 23, 78, 136, 1, 220, 1, 4, 68, 73, 71, 73, 20, 7, 76, 69, 84, 84, 69, 82, 32, 144, 2, 7, 78, 85, 77, 66, 69, 82, 32, 36, 12, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 32, 136, - 2, 5, 83, 73, 71, 78, 32, 210, 1, 86, 135, 193, 8, 70, 8, 219, 138, 16, - 84, 74, 182, 1, 75, 42, 84, 142, 137, 7, 78, 202, 240, 11, 68, 194, 149, + 2, 5, 83, 73, 71, 78, 32, 210, 1, 86, 231, 134, 9, 70, 8, 183, 214, 16, + 84, 74, 182, 1, 75, 42, 84, 218, 206, 7, 78, 170, 247, 11, 68, 178, 154, 3, 83, 82, 66, 2, 67, 2, 71, 2, 80, 2, 86, 138, 69, 72, 2, 74, 2, 76, 2, - 77, 2, 82, 2, 89, 2, 90, 187, 2, 65, 6, 146, 213, 22, 72, 2, 75, 187, 2, - 65, 12, 194, 250, 18, 84, 170, 218, 3, 72, 187, 2, 65, 8, 162, 207, 14, - 84, 243, 170, 2, 79, 18, 70, 67, 74, 68, 66, 76, 36, 5, 77, 65, 78, 71, - 65, 139, 128, 21, 83, 4, 26, 82, 227, 129, 21, 73, 2, 149, 178, 21, 6, - 69, 83, 67, 69, 78, 84, 6, 26, 79, 175, 245, 18, 65, 4, 246, 244, 18, 85, - 175, 224, 3, 84, 4, 138, 224, 6, 79, 171, 191, 7, 73, 2, 203, 151, 21, - 76, 12, 72, 2, 66, 65, 22, 67, 20, 2, 68, 79, 234, 153, 20, 86, 247, 244, - 1, 65, 2, 247, 214, 21, 82, 2, 219, 150, 6, 65, 4, 44, 5, 85, 66, 76, 69, - 32, 143, 162, 20, 84, 2, 21, 3, 82, 73, 78, 2, 243, 161, 20, 71, 14, 44, - 5, 79, 87, 69, 76, 32, 175, 150, 20, 73, 12, 44, 5, 83, 73, 71, 78, 32, - 159, 144, 22, 76, 10, 254, 143, 4, 86, 154, 194, 18, 69, 2, 73, 2, 79, 3, + 77, 2, 82, 2, 89, 2, 90, 187, 2, 65, 6, 174, 166, 23, 72, 2, 75, 187, 2, + 65, 12, 238, 198, 19, 84, 154, 223, 3, 72, 187, 2, 65, 8, 246, 152, 15, + 84, 219, 172, 2, 79, 18, 70, 67, 74, 68, 66, 76, 36, 5, 77, 65, 78, 71, + 65, 151, 206, 21, 83, 4, 26, 82, 239, 207, 21, 73, 2, 241, 130, 22, 6, + 69, 83, 67, 69, 78, 84, 6, 26, 79, 219, 193, 19, 65, 4, 162, 193, 19, 85, + 159, 229, 3, 84, 4, 174, 159, 7, 79, 251, 210, 14, 73, 2, 227, 229, 21, + 76, 12, 72, 2, 66, 65, 22, 67, 20, 2, 68, 79, 138, 231, 20, 86, 243, 248, + 1, 65, 2, 147, 168, 22, 82, 2, 207, 196, 6, 65, 4, 44, 5, 85, 66, 76, 69, + 32, 175, 239, 20, 84, 2, 21, 3, 82, 73, 78, 2, 147, 239, 20, 71, 14, 44, + 5, 79, 87, 69, 76, 32, 207, 227, 20, 73, 12, 44, 5, 83, 73, 71, 78, 32, + 187, 225, 22, 76, 10, 218, 175, 4, 86, 218, 243, 18, 69, 2, 73, 2, 79, 3, 85, 246, 2, 202, 1, 67, 240, 2, 18, 73, 78, 68, 69, 80, 69, 78, 68, 69, 78, 84, 32, 86, 79, 87, 69, 76, 32, 220, 2, 7, 76, 69, 84, 84, 69, 82, - 32, 254, 2, 83, 208, 12, 6, 86, 79, 87, 69, 76, 32, 239, 198, 20, 68, 70, + 32, 254, 2, 83, 208, 12, 6, 86, 79, 87, 69, 76, 32, 243, 148, 21, 68, 70, 176, 1, 20, 79, 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, 32, 67, - 79, 69, 78, 71, 32, 169, 185, 17, 17, 85, 82, 82, 69, 78, 67, 89, 32, 83, + 79, 69, 78, 71, 32, 221, 132, 18, 17, 85, 82, 82, 69, 78, 67, 89, 32, 83, 89, 77, 66, 79, 76, 32, 82, 73, 68, 138, 1, 78, 154, 4, 67, 2, 75, 90, - 80, 74, 84, 54, 68, 2, 76, 210, 255, 21, 83, 158, 41, 77, 2, 82, 2, 86, - 2, 89, 190, 28, 66, 3, 72, 8, 214, 174, 22, 71, 2, 89, 246, 30, 65, 3, + 80, 74, 84, 54, 68, 2, 76, 238, 208, 22, 83, 158, 41, 77, 2, 82, 2, 86, + 2, 89, 190, 28, 66, 3, 72, 8, 242, 255, 22, 71, 2, 89, 246, 30, 65, 3, 79, 42, 82, 81, 196, 1, 11, 83, 73, 71, 78, 32, 67, 79, 69, 78, 71, 32, - 50, 76, 3, 82, 26, 82, 65, 44, 6, 79, 79, 32, 84, 89, 80, 34, 85, 230, - 190, 20, 73, 199, 140, 2, 69, 8, 242, 203, 22, 65, 2, 73, 2, 81, 3, 85, - 4, 11, 69, 4, 251, 144, 10, 32, 9, 166, 192, 7, 85, 131, 139, 15, 75, 8, - 18, 81, 31, 82, 4, 238, 202, 22, 69, 3, 85, 4, 183, 185, 18, 89, 70, 138, - 1, 67, 2, 75, 42, 78, 50, 80, 30, 83, 46, 84, 54, 68, 2, 76, 238, 168, + 50, 76, 3, 82, 26, 82, 65, 44, 6, 79, 79, 32, 84, 89, 80, 34, 85, 226, + 140, 21, 73, 231, 143, 2, 69, 8, 142, 157, 23, 65, 2, 73, 2, 81, 3, 85, + 4, 11, 69, 4, 255, 215, 10, 32, 9, 158, 134, 8, 85, 167, 150, 15, 75, 8, + 18, 81, 31, 82, 4, 138, 156, 23, 69, 3, 85, 4, 219, 132, 19, 89, 70, 138, + 1, 67, 2, 75, 42, 78, 50, 80, 30, 83, 46, 84, 54, 68, 2, 76, 138, 250, 22, 77, 2, 82, 2, 86, 2, 89, 190, 28, 66, 2, 72, 3, 81, 8, 210, 1, 72, - 226, 199, 22, 65, 3, 79, 8, 150, 170, 22, 71, 2, 78, 2, 89, 247, 30, 79, - 6, 122, 72, 227, 199, 22, 79, 6, 202, 169, 22, 83, 190, 28, 72, 187, 2, - 65, 12, 50, 72, 0, 2, 84, 72, 226, 199, 22, 65, 3, 79, 4, 222, 199, 22, + 254, 152, 23, 65, 3, 79, 8, 178, 251, 22, 71, 2, 78, 2, 89, 247, 30, 79, + 6, 122, 72, 255, 152, 23, 79, 6, 230, 250, 22, 83, 190, 28, 72, 187, 2, + 65, 12, 50, 72, 0, 2, 84, 72, 254, 152, 23, 65, 3, 79, 4, 250, 152, 23, 65, 3, 79, 130, 1, 60, 4, 73, 71, 78, 32, 221, 6, 6, 89, 77, 66, 79, 76, 32, 46, 202, 2, 65, 104, 10, 83, 65, 77, 89, 79, 75, 32, 83, 65, 78, 22, - 66, 118, 67, 86, 75, 74, 82, 54, 84, 188, 229, 4, 3, 76, 69, 75, 168, 11, - 6, 80, 72, 78, 65, 69, 75, 148, 228, 10, 10, 89, 85, 85, 75, 65, 76, 69, - 65, 80, 73, 244, 243, 1, 3, 78, 73, 75, 236, 171, 3, 9, 77, 85, 85, 83, - 73, 75, 65, 84, 79, 141, 15, 4, 86, 73, 82, 73, 6, 100, 9, 86, 65, 75, - 82, 65, 72, 65, 83, 65, 156, 141, 18, 4, 84, 84, 72, 65, 173, 145, 4, 2, - 72, 83, 2, 239, 192, 22, 78, 8, 38, 65, 181, 183, 21, 3, 69, 89, 89, 6, - 174, 6, 84, 216, 1, 2, 78, 84, 237, 238, 20, 6, 82, 73, 89, 79, 79, 83, - 4, 248, 155, 7, 12, 65, 77, 78, 85, 67, 32, 80, 73, 73, 32, 75, 85, 235, - 223, 12, 79, 6, 240, 216, 11, 2, 65, 75, 226, 156, 9, 72, 205, 82, 4, 79, - 79, 77, 85, 4, 182, 216, 11, 79, 137, 235, 5, 4, 69, 65, 72, 77, 4, 232, - 173, 21, 4, 82, 73, 73, 83, 217, 9, 8, 79, 65, 78, 68, 65, 75, 72, 73, + 66, 118, 67, 86, 75, 74, 82, 54, 84, 160, 135, 5, 3, 76, 69, 75, 168, 11, + 6, 80, 72, 78, 65, 69, 75, 140, 142, 11, 10, 89, 85, 85, 75, 65, 76, 69, + 65, 80, 73, 196, 243, 1, 3, 78, 73, 75, 228, 174, 3, 9, 77, 85, 85, 83, + 73, 75, 65, 84, 79, 129, 15, 4, 86, 73, 82, 73, 6, 100, 9, 86, 65, 75, + 82, 65, 72, 65, 83, 65, 204, 216, 18, 4, 84, 84, 72, 65, 153, 151, 4, 2, + 72, 83, 2, 139, 146, 23, 78, 8, 38, 65, 209, 136, 22, 3, 69, 89, 89, 6, + 174, 6, 84, 216, 1, 2, 78, 84, 145, 189, 21, 6, 82, 73, 89, 79, 79, 83, + 4, 200, 225, 7, 12, 65, 77, 78, 85, 67, 32, 80, 73, 73, 32, 75, 85, 187, + 231, 12, 79, 6, 140, 161, 12, 2, 65, 75, 234, 162, 9, 72, 197, 85, 4, 79, + 79, 77, 85, 4, 210, 160, 12, 79, 153, 238, 5, 4, 69, 65, 72, 77, 4, 132, + 255, 21, 4, 82, 73, 73, 83, 217, 9, 8, 79, 65, 78, 68, 65, 75, 72, 73, 84, 128, 1, 3, 68, 65, 80, 92, 10, 76, 69, 75, 32, 65, 84, 84, 65, 75, 32, 182, 1, 80, 72, 5, 84, 85, 84, 69, 89, 78, 66, 47, 77, 24, 22, 45, 223, 3, 32, 20, 30, 80, 238, 2, 66, 47, 77, 8, 138, 3, 73, 37, 3, 82, 65, - 77, 20, 50, 80, 98, 66, 238, 145, 11, 77, 219, 219, 10, 83, 12, 36, 3, - 82, 65, 77, 147, 170, 22, 73, 11, 11, 45, 8, 42, 66, 238, 145, 11, 77, - 251, 228, 8, 80, 4, 194, 237, 21, 85, 151, 60, 69, 26, 44, 2, 65, 84, 44, - 3, 82, 65, 77, 91, 73, 2, 21, 3, 72, 65, 77, 2, 227, 185, 16, 65, 20, 18, + 77, 20, 50, 80, 98, 66, 238, 217, 11, 77, 247, 228, 10, 83, 12, 36, 3, + 82, 65, 77, 175, 251, 22, 73, 11, 11, 45, 8, 42, 66, 238, 217, 11, 77, + 155, 234, 8, 80, 4, 222, 190, 22, 85, 151, 60, 69, 26, 44, 2, 65, 84, 44, + 3, 82, 65, 77, 91, 73, 2, 21, 3, 72, 65, 77, 2, 151, 133, 17, 65, 20, 18, 45, 119, 32, 16, 34, 66, 32, 2, 80, 73, 15, 77, 8, 30, 69, 37, 3, 85, 79, - 78, 4, 35, 73, 4, 21, 3, 85, 79, 89, 4, 11, 32, 4, 34, 82, 241, 133, 22, - 2, 75, 79, 2, 247, 144, 21, 79, 42, 76, 10, 73, 78, 72, 69, 82, 69, 78, - 84, 32, 65, 29, 5, 83, 73, 71, 78, 32, 4, 162, 186, 22, 65, 3, 81, 38, - 102, 65, 54, 73, 30, 79, 38, 89, 216, 254, 2, 5, 67, 79, 69, 78, 71, 234, - 167, 7, 85, 239, 145, 12, 69, 10, 194, 180, 3, 65, 222, 132, 19, 69, 2, - 73, 3, 85, 7, 234, 184, 22, 69, 3, 73, 6, 206, 184, 22, 69, 2, 77, 3, 79, - 7, 170, 184, 22, 65, 3, 89, 130, 1, 146, 1, 68, 88, 7, 76, 69, 84, 84, + 78, 4, 35, 73, 4, 21, 3, 85, 79, 89, 4, 11, 32, 4, 34, 82, 141, 215, 22, + 2, 75, 79, 2, 211, 225, 21, 79, 42, 76, 10, 73, 78, 72, 69, 82, 69, 78, + 84, 32, 65, 29, 5, 83, 73, 71, 78, 32, 4, 190, 139, 23, 65, 3, 81, 38, + 102, 65, 54, 73, 30, 79, 38, 89, 220, 157, 3, 5, 67, 79, 69, 78, 71, 206, + 207, 7, 85, 163, 156, 12, 69, 10, 158, 212, 3, 65, 158, 182, 19, 69, 2, + 73, 3, 85, 7, 134, 138, 23, 69, 3, 73, 6, 234, 137, 23, 69, 2, 77, 3, 79, + 7, 198, 137, 23, 65, 3, 89, 130, 1, 146, 1, 68, 88, 7, 76, 69, 84, 84, 69, 82, 32, 170, 2, 83, 160, 1, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, - 78, 32, 162, 233, 15, 87, 231, 85, 65, 6, 48, 6, 79, 85, 66, 76, 69, 32, - 207, 214, 18, 65, 4, 186, 163, 10, 83, 135, 179, 8, 68, 90, 234, 1, 83, - 254, 4, 66, 42, 71, 146, 141, 6, 68, 218, 140, 12, 74, 182, 55, 65, 150, - 1, 84, 198, 208, 1, 76, 226, 195, 1, 78, 126, 67, 2, 75, 2, 80, 138, 69, + 78, 32, 254, 180, 16, 87, 199, 85, 65, 6, 48, 6, 79, 85, 66, 76, 69, 32, + 251, 162, 19, 65, 4, 162, 234, 10, 83, 203, 184, 8, 68, 90, 234, 1, 83, + 254, 4, 66, 42, 71, 138, 187, 6, 68, 134, 170, 12, 74, 190, 56, 65, 150, + 1, 84, 150, 210, 1, 76, 130, 199, 1, 78, 126, 67, 2, 75, 2, 80, 138, 69, 72, 2, 77, 2, 81, 2, 82, 2, 86, 2, 89, 186, 2, 69, 2, 73, 2, 79, 3, 85, - 4, 26, 72, 155, 180, 22, 65, 2, 133, 244, 21, 3, 79, 82, 84, 12, 40, 4, - 73, 71, 78, 32, 211, 160, 10, 69, 10, 54, 83, 150, 150, 18, 78, 154, 67, - 86, 243, 148, 3, 65, 4, 26, 72, 175, 175, 17, 85, 2, 11, 65, 2, 231, 141, - 22, 68, 18, 190, 240, 3, 86, 250, 234, 14, 65, 222, 202, 1, 73, 198, 140, + 4, 26, 72, 183, 133, 23, 65, 2, 161, 197, 22, 3, 79, 82, 84, 12, 40, 4, + 73, 71, 78, 32, 187, 231, 10, 69, 10, 54, 83, 186, 225, 18, 78, 162, 68, + 86, 227, 153, 3, 65, 4, 26, 72, 219, 250, 17, 85, 2, 11, 65, 2, 131, 223, + 22, 68, 18, 154, 144, 4, 86, 202, 151, 15, 65, 174, 204, 1, 73, 230, 143, 2, 69, 2, 79, 3, 85, 138, 1, 100, 7, 76, 69, 84, 84, 69, 82, 32, 176, 2, - 5, 83, 73, 71, 78, 32, 154, 190, 16, 86, 203, 252, 3, 68, 94, 222, 1, 66, - 42, 71, 146, 141, 6, 68, 178, 139, 12, 74, 222, 56, 65, 118, 82, 34, 84, - 230, 5, 85, 186, 202, 1, 73, 138, 196, 1, 78, 126, 67, 2, 75, 2, 80, 2, - 83, 138, 69, 72, 2, 76, 2, 77, 2, 86, 2, 89, 186, 2, 69, 3, 79, 6, 254, - 172, 22, 66, 2, 72, 187, 2, 65, 6, 214, 172, 22, 71, 2, 72, 187, 2, 65, - 6, 230, 145, 18, 78, 154, 67, 86, 243, 148, 3, 65, 136, 1, 140, 1, 8, 82, - 65, 84, 32, 82, 65, 73, 32, 216, 3, 2, 83, 83, 132, 243, 20, 4, 87, 73, - 70, 82, 202, 47, 80, 240, 93, 2, 77, 79, 191, 18, 84, 116, 140, 1, 7, 76, + 5, 83, 73, 71, 78, 32, 214, 137, 17, 86, 147, 255, 3, 68, 94, 222, 1, 66, + 42, 71, 138, 187, 6, 68, 222, 168, 12, 74, 230, 57, 65, 118, 82, 34, 84, + 230, 5, 85, 138, 204, 1, 73, 170, 199, 1, 78, 126, 67, 2, 75, 2, 80, 2, + 83, 138, 69, 72, 2, 76, 2, 77, 2, 86, 2, 89, 186, 2, 69, 3, 79, 6, 154, + 254, 22, 66, 2, 72, 187, 2, 65, 6, 242, 253, 22, 71, 2, 72, 187, 2, 65, + 6, 138, 221, 18, 78, 162, 68, 86, 227, 153, 3, 65, 136, 1, 140, 1, 8, 82, + 65, 84, 32, 82, 65, 73, 32, 216, 3, 2, 83, 83, 156, 193, 21, 4, 87, 73, + 70, 82, 206, 50, 80, 240, 93, 2, 77, 79, 191, 18, 84, 116, 140, 1, 7, 76, 69, 84, 84, 69, 82, 32, 172, 1, 5, 83, 73, 71, 78, 32, 92, 11, 86, 79, - 87, 69, 76, 32, 83, 73, 71, 78, 32, 147, 233, 11, 68, 64, 194, 206, 18, - 68, 114, 84, 206, 223, 1, 78, 214, 181, 1, 66, 2, 67, 2, 71, 2, 74, 2, + 87, 69, 76, 32, 83, 73, 71, 78, 32, 231, 178, 12, 68, 64, 238, 154, 19, + 68, 114, 84, 166, 225, 1, 78, 238, 184, 1, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 2, 83, 138, 69, 72, 2, 76, 2, 77, 2, 82, 2, 86, 2, 89, 187, 2, - 65, 12, 236, 204, 9, 3, 84, 79, 78, 0, 2, 89, 85, 190, 252, 1, 83, 198, - 156, 10, 65, 239, 1, 86, 16, 234, 210, 18, 65, 130, 151, 3, 85, 162, 64, - 69, 2, 73, 3, 79, 13, 40, 4, 73, 78, 71, 32, 235, 231, 21, 32, 8, 96, 4, - 70, 65, 67, 69, 229, 142, 14, 14, 67, 65, 84, 32, 70, 65, 67, 69, 32, 87, - 73, 84, 72, 32, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 210, 141, 14, 83, - 159, 155, 5, 67, 4, 156, 163, 18, 3, 69, 69, 76, 171, 232, 3, 79, 4, 40, - 4, 82, 69, 65, 78, 131, 133, 22, 65, 2, 33, 6, 32, 83, 84, 65, 78, 68, 2, - 245, 245, 18, 2, 65, 82, 2, 11, 79, 2, 223, 164, 10, 78, 200, 43, 154, 1, - 65, 178, 233, 1, 69, 198, 62, 73, 226, 83, 79, 206, 33, 85, 94, 89, 190, - 221, 7, 82, 232, 195, 9, 5, 32, 66, 32, 66, 65, 142, 163, 1, 76, 239, 66, - 70, 134, 23, 142, 1, 66, 44, 6, 67, 82, 79, 83, 83, 69, 46, 68, 58, 78, + 65, 12, 240, 147, 10, 3, 84, 79, 78, 0, 2, 89, 85, 214, 253, 1, 83, 198, + 165, 10, 65, 239, 1, 86, 16, 150, 159, 19, 65, 242, 155, 3, 85, 162, 64, + 69, 2, 73, 3, 79, 13, 40, 4, 73, 78, 71, 32, 135, 185, 22, 32, 8, 96, 4, + 70, 65, 67, 69, 165, 216, 14, 14, 67, 65, 84, 32, 70, 65, 67, 69, 32, 87, + 73, 84, 72, 32, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 146, 215, 14, 83, + 255, 158, 5, 67, 4, 236, 238, 18, 3, 69, 69, 76, 247, 237, 3, 79, 4, 40, + 4, 82, 69, 65, 78, 159, 214, 22, 65, 2, 33, 6, 32, 83, 84, 65, 78, 68, 2, + 137, 195, 19, 2, 65, 82, 2, 11, 79, 2, 251, 235, 10, 78, 218, 45, 154, 1, + 65, 210, 254, 1, 69, 162, 72, 73, 234, 83, 79, 166, 34, 85, 94, 89, 226, + 133, 8, 82, 236, 201, 9, 5, 32, 66, 32, 66, 65, 166, 166, 1, 76, 239, 66, + 70, 222, 24, 142, 1, 66, 44, 6, 67, 82, 79, 83, 83, 69, 46, 68, 58, 78, 64, 2, 79, 32, 222, 11, 82, 236, 21, 4, 83, 84, 32, 81, 77, 4, 84, 73, - 78, 32, 4, 152, 190, 14, 2, 32, 67, 155, 218, 6, 69, 2, 189, 250, 16, 6, - 32, 83, 84, 73, 67, 75, 4, 200, 250, 12, 5, 89, 32, 66, 69, 69, 247, 234, - 8, 68, 4, 230, 197, 9, 68, 161, 241, 10, 7, 71, 85, 65, 71, 69, 32, 84, + 78, 32, 4, 236, 135, 15, 2, 32, 67, 227, 225, 6, 69, 2, 137, 198, 17, 6, + 32, 83, 84, 73, 67, 75, 4, 168, 196, 13, 5, 89, 32, 66, 69, 69, 179, 242, + 8, 68, 4, 234, 140, 10, 68, 161, 248, 10, 7, 71, 85, 65, 71, 69, 32, 84, 174, 1, 200, 2, 3, 72, 79, 32, 28, 7, 76, 69, 84, 84, 69, 82, 32, 214, 5, 83, 148, 1, 9, 84, 79, 78, 69, 32, 77, 65, 73, 32, 84, 11, 86, 79, 87, - 69, 76, 32, 83, 73, 71, 78, 32, 228, 170, 4, 2, 75, 79, 148, 254, 12, 2, - 89, 65, 230, 199, 2, 69, 170, 51, 68, 212, 138, 1, 7, 67, 65, 78, 67, 69, - 76, 76, 221, 68, 6, 78, 73, 71, 71, 65, 72, 4, 238, 128, 22, 77, 3, 78, + 69, 76, 32, 83, 73, 71, 78, 32, 200, 204, 4, 2, 75, 79, 220, 167, 13, 2, + 89, 65, 162, 202, 2, 69, 198, 51, 68, 236, 141, 1, 7, 67, 65, 78, 67, 69, + 76, 76, 221, 68, 6, 78, 73, 71, 71, 65, 72, 4, 138, 210, 22, 77, 3, 78, 94, 176, 1, 3, 70, 79, 32, 78, 75, 96, 2, 76, 79, 50, 80, 154, 1, 83, 86, - 84, 30, 72, 214, 156, 16, 78, 234, 222, 5, 66, 2, 67, 2, 68, 2, 77, 2, - 82, 2, 87, 2, 89, 247, 30, 79, 8, 42, 70, 174, 170, 15, 83, 175, 182, 5, - 84, 4, 134, 206, 21, 79, 155, 62, 65, 10, 26, 72, 175, 157, 22, 79, 8, - 32, 3, 77, 85, 32, 231, 2, 79, 4, 194, 196, 21, 78, 211, 57, 71, 7, 17, - 2, 32, 76, 4, 218, 203, 21, 73, 67, 79, 30, 52, 4, 65, 76, 73, 32, 210, - 1, 72, 179, 154, 22, 79, 24, 230, 200, 6, 68, 34, 84, 206, 6, 78, 134, - 207, 13, 66, 2, 67, 2, 71, 2, 74, 147, 219, 1, 76, 8, 52, 9, 65, 78, 83, - 75, 82, 73, 84, 32, 83, 71, 79, 4, 174, 152, 22, 72, 3, 83, 6, 26, 72, - 179, 154, 22, 79, 4, 11, 79, 4, 11, 32, 4, 218, 166, 15, 83, 175, 182, 5, + 84, 30, 72, 146, 232, 16, 78, 202, 228, 5, 66, 2, 67, 2, 68, 2, 77, 2, + 82, 2, 87, 2, 89, 247, 30, 79, 8, 42, 70, 138, 246, 15, 83, 235, 184, 5, + 84, 4, 162, 159, 22, 79, 155, 62, 65, 10, 26, 72, 203, 238, 22, 79, 8, + 32, 3, 77, 85, 32, 231, 2, 79, 4, 222, 149, 22, 78, 211, 57, 71, 7, 17, + 2, 32, 76, 4, 246, 156, 22, 73, 67, 79, 30, 52, 4, 65, 76, 73, 32, 210, + 1, 72, 207, 235, 22, 79, 24, 178, 142, 7, 68, 34, 84, 206, 6, 78, 190, + 215, 13, 66, 2, 67, 2, 71, 2, 74, 171, 222, 1, 76, 8, 52, 9, 65, 78, 83, + 75, 82, 73, 84, 32, 83, 71, 79, 4, 202, 233, 22, 72, 3, 83, 6, 26, 72, + 207, 235, 22, 79, 4, 11, 79, 4, 11, 32, 4, 182, 242, 15, 83, 235, 184, 5, 84, 6, 112, 14, 69, 77, 73, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, - 133, 191, 18, 8, 73, 71, 78, 32, 80, 65, 76, 73, 4, 186, 192, 21, 78, - 211, 57, 76, 8, 50, 84, 184, 158, 17, 2, 67, 65, 223, 246, 4, 69, 4, 182, - 249, 21, 72, 247, 30, 73, 32, 106, 65, 44, 5, 77, 65, 73, 32, 75, 218, - 133, 18, 89, 162, 58, 85, 186, 202, 1, 69, 2, 73, 199, 140, 2, 79, 11, - 158, 151, 22, 65, 2, 73, 2, 77, 3, 89, 4, 146, 199, 21, 65, 3, 79, 166, - 1, 32, 2, 71, 69, 179, 143, 21, 73, 164, 1, 26, 32, 223, 246, 13, 82, - 160, 1, 254, 1, 66, 44, 4, 71, 82, 69, 69, 22, 79, 250, 1, 84, 242, 237, - 11, 68, 36, 2, 85, 80, 164, 193, 3, 12, 76, 69, 70, 84, 32, 84, 82, 73, - 65, 78, 71, 76, 200, 203, 4, 5, 80, 85, 82, 80, 76, 12, 3, 82, 69, 68, 0, - 6, 89, 69, 76, 76, 79, 87, 179, 66, 67, 10, 40, 3, 82, 79, 87, 201, 1, 2, - 76, 85, 4, 151, 253, 19, 78, 10, 48, 3, 78, 69, 32, 129, 1, 4, 82, 65, - 78, 71, 4, 164, 157, 8, 5, 68, 79, 84, 32, 79, 133, 234, 2, 18, 82, 73, + 177, 139, 19, 8, 73, 71, 78, 32, 80, 65, 76, 73, 4, 214, 145, 22, 78, + 211, 57, 76, 8, 50, 84, 228, 233, 17, 2, 67, 65, 207, 252, 4, 69, 4, 210, + 202, 22, 72, 247, 30, 73, 32, 106, 65, 44, 5, 77, 65, 73, 32, 75, 254, + 208, 18, 89, 170, 59, 85, 138, 204, 1, 69, 2, 73, 231, 143, 2, 79, 11, + 186, 232, 22, 65, 2, 73, 2, 77, 3, 89, 4, 174, 152, 22, 65, 3, 79, 166, + 1, 32, 2, 71, 69, 207, 224, 21, 73, 164, 1, 26, 32, 171, 192, 14, 82, + 160, 1, 254, 1, 66, 44, 4, 71, 82, 69, 69, 22, 79, 250, 1, 84, 198, 183, + 12, 68, 36, 2, 85, 80, 172, 195, 3, 12, 76, 69, 70, 84, 32, 84, 82, 73, + 65, 78, 71, 76, 232, 205, 4, 5, 80, 85, 82, 80, 76, 12, 3, 82, 69, 68, 0, + 6, 89, 69, 76, 76, 79, 87, 195, 66, 67, 10, 40, 3, 82, 79, 87, 201, 1, 2, + 76, 85, 4, 147, 203, 20, 78, 10, 48, 3, 78, 69, 32, 129, 1, 4, 82, 65, + 78, 71, 4, 184, 227, 8, 5, 68, 79, 84, 32, 79, 149, 236, 2, 18, 82, 73, 78, 71, 32, 79, 86, 69, 82, 32, 84, 87, 79, 32, 82, 73, 78, 71, 6, 11, - 69, 6, 11, 32, 6, 230, 189, 20, 67, 162, 21, 68, 155, 28, 83, 116, 156, - 1, 3, 87, 79, 32, 108, 10, 89, 80, 69, 32, 80, 73, 69, 67, 69, 32, 249, - 203, 18, 17, 82, 73, 80, 76, 69, 32, 86, 69, 82, 84, 73, 67, 65, 76, 32, - 66, 65, 4, 166, 237, 17, 68, 141, 93, 19, 82, 73, 78, 71, 83, 32, 79, 86, + 69, 6, 11, 32, 6, 242, 139, 21, 67, 174, 21, 68, 223, 30, 83, 116, 156, + 1, 3, 87, 79, 32, 108, 10, 89, 80, 69, 32, 80, 73, 69, 67, 69, 32, 157, + 152, 19, 17, 82, 73, 80, 76, 69, 32, 86, 69, 82, 84, 73, 67, 65, 76, 32, + 66, 65, 4, 214, 184, 18, 68, 129, 94, 19, 82, 73, 78, 71, 83, 32, 79, 86, 69, 82, 32, 79, 78, 69, 32, 82, 73, 78, 71, 110, 182, 1, 67, 136, 2, 9, 68, 73, 65, 71, 79, 78, 65, 76, 32, 218, 1, 76, 186, 2, 82, 158, 1, 83, 204, 3, 6, 85, 80, 80, 69, 82, 32, 145, 2, 9, 86, 69, 82, 84, 69, 88, 32, 79, 70, 14, 80, 9, 69, 78, 84, 82, 69, 32, 79, 70, 32, 73, 7, 82, 79, 83, - 83, 66, 65, 82, 8, 252, 8, 6, 90, 32, 87, 73, 84, 72, 190, 132, 22, 75, + 83, 66, 65, 82, 8, 252, 8, 6, 90, 32, 87, 73, 84, 72, 218, 213, 22, 75, 2, 88, 3, 89, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 40, 3, 76, 79, 87, 1, - 3, 85, 80, 80, 2, 189, 200, 10, 2, 69, 82, 12, 48, 6, 85, 80, 80, 69, 82, - 32, 219, 225, 9, 76, 8, 56, 4, 76, 69, 70, 84, 149, 226, 9, 4, 82, 73, + 3, 85, 80, 80, 2, 149, 144, 11, 2, 69, 82, 12, 48, 6, 85, 80, 80, 69, 82, + 32, 223, 168, 10, 76, 8, 56, 4, 76, 69, 70, 84, 153, 169, 10, 4, 82, 73, 71, 72, 5, 11, 32, 2, 21, 3, 65, 78, 68, 2, 17, 2, 32, 76, 2, 17, 2, 79, - 87, 2, 133, 216, 21, 2, 69, 82, 26, 48, 5, 79, 87, 69, 82, 32, 129, 3, 2, + 87, 2, 161, 169, 22, 2, 69, 82, 26, 48, 5, 79, 87, 69, 82, 32, 129, 3, 2, 69, 70, 24, 84, 5, 76, 69, 70, 84, 32, 56, 6, 82, 73, 71, 72, 84, 32, - 158, 6, 72, 179, 1, 84, 8, 22, 65, 207, 7, 67, 4, 194, 1, 78, 187, 221, - 20, 82, 10, 22, 65, 151, 7, 67, 6, 192, 1, 13, 78, 68, 32, 85, 80, 80, - 69, 82, 32, 82, 73, 71, 72, 173, 207, 19, 2, 82, 67, 4, 44, 4, 65, 73, + 158, 6, 72, 179, 1, 84, 8, 22, 65, 207, 7, 67, 4, 194, 1, 78, 151, 174, + 21, 82, 10, 22, 65, 151, 7, 67, 6, 192, 1, 13, 78, 68, 32, 85, 80, 80, + 69, 82, 32, 82, 73, 71, 72, 205, 156, 20, 2, 82, 67, 4, 44, 4, 65, 73, 83, 69, 77, 3, 73, 71, 72, 2, 53, 11, 68, 32, 85, 80, 80, 69, 82, 32, 76, - 69, 70, 2, 155, 135, 19, 84, 2, 189, 136, 21, 3, 84, 32, 65, 34, 48, 5, + 69, 70, 2, 187, 212, 19, 84, 2, 217, 217, 21, 3, 84, 32, 65, 34, 48, 5, 72, 79, 82, 84, 32, 77, 3, 84, 69, 77, 4, 40, 3, 76, 79, 87, 1, 3, 85, 80, 80, 2, 217, 4, 4, 69, 82, 32, 84, 31, 44, 6, 32, 87, 73, 84, 72, 32, 171, 1, 45, 8, 44, 5, 76, 69, 70, 84, 32, 30, 82, 59, 67, 4, 82, 67, 251, - 216, 10, 74, 2, 21, 3, 73, 71, 72, 2, 11, 84, 2, 17, 2, 32, 67, 2, 221, - 224, 20, 4, 82, 79, 83, 83, 20, 48, 2, 49, 50, 22, 50, 26, 52, 255, 184, - 11, 51, 5, 235, 218, 14, 51, 9, 11, 51, 7, 11, 52, 5, 163, 131, 22, 53, + 160, 11, 74, 2, 21, 3, 73, 71, 72, 2, 11, 84, 2, 17, 2, 32, 67, 2, 185, + 177, 21, 4, 82, 79, 83, 83, 20, 48, 2, 49, 50, 22, 50, 26, 52, 211, 130, + 12, 51, 5, 207, 166, 15, 51, 9, 11, 51, 7, 11, 52, 5, 191, 212, 22, 53, 18, 62, 72, 96, 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, 83, 84, 4, 65, 14, - 65, 76, 70, 32, 86, 69, 82, 84, 69, 88, 32, 79, 70, 32, 4, 138, 130, 22, - 77, 3, 87, 6, 17, 2, 84, 32, 6, 26, 67, 227, 129, 19, 65, 4, 202, 92, 82, - 159, 164, 17, 79, 2, 209, 245, 8, 3, 69, 82, 77, 2, 239, 226, 14, 32, 6, - 53, 11, 85, 65, 82, 84, 69, 82, 32, 77, 79, 79, 78, 7, 223, 240, 6, 32, - 158, 20, 150, 1, 67, 224, 46, 18, 69, 80, 73, 71, 82, 65, 80, 72, 73, 67, - 32, 76, 69, 84, 84, 69, 82, 32, 252, 1, 7, 76, 69, 84, 84, 69, 82, 32, - 247, 12, 83, 206, 7, 56, 8, 65, 80, 73, 84, 65, 76, 32, 76, 167, 187, 20, - 82, 204, 7, 76, 6, 69, 84, 84, 69, 82, 32, 169, 45, 8, 73, 71, 65, 84, - 85, 82, 69, 32, 200, 7, 154, 2, 65, 158, 3, 66, 154, 1, 67, 254, 1, 68, - 186, 2, 69, 174, 2, 70, 82, 71, 194, 1, 72, 146, 1, 73, 154, 2, 74, 118, - 75, 126, 76, 234, 2, 77, 114, 78, 134, 2, 79, 198, 2, 80, 114, 81, 62, - 82, 190, 2, 83, 130, 3, 84, 142, 3, 85, 234, 1, 86, 146, 1, 87, 118, 88, - 50, 89, 167, 1, 90, 93, 172, 1, 6, 32, 87, 73, 84, 72, 32, 166, 1, 69, - 246, 65, 78, 228, 153, 14, 6, 70, 82, 73, 67, 65, 78, 158, 193, 3, 76, - 210, 183, 2, 86, 186, 164, 1, 65, 2, 79, 2, 85, 3, 89, 66, 246, 64, 66, - 34, 68, 108, 3, 82, 73, 78, 242, 33, 77, 250, 21, 67, 150, 50, 72, 158, - 1, 79, 198, 10, 71, 186, 2, 65, 246, 173, 3, 73, 194, 170, 13, 84, 219, - 183, 3, 83, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 206, 184, 1, 65, 239, - 199, 3, 77, 21, 60, 6, 32, 87, 73, 84, 72, 32, 190, 68, 82, 239, 142, 21, - 69, 14, 154, 67, 84, 138, 60, 70, 210, 57, 76, 234, 154, 16, 68, 170, - 206, 2, 72, 247, 165, 1, 83, 33, 108, 6, 32, 87, 73, 84, 72, 32, 204, 70, - 7, 76, 79, 83, 69, 68, 32, 73, 54, 85, 206, 223, 20, 79, 139, 60, 72, 20, - 94, 67, 198, 181, 1, 65, 154, 233, 3, 80, 130, 129, 15, 72, 182, 50, 66, - 242, 34, 68, 211, 80, 83, 8, 198, 68, 69, 190, 113, 73, 151, 152, 19, 65, - 35, 76, 6, 32, 87, 73, 84, 72, 32, 178, 1, 90, 25, 6, 79, 85, 66, 76, 69, - 32, 24, 78, 83, 226, 15, 67, 202, 47, 84, 218, 117, 76, 234, 154, 16, 68, - 171, 206, 2, 72, 8, 92, 13, 77, 65, 76, 76, 32, 76, 69, 84, 84, 69, 82, - 32, 90, 150, 138, 1, 72, 159, 185, 20, 84, 5, 209, 72, 2, 32, 87, 4, 254, - 71, 87, 239, 180, 10, 84, 91, 104, 6, 32, 87, 73, 84, 72, 32, 152, 1, 2, - 90, 72, 134, 76, 71, 130, 148, 17, 84, 210, 143, 4, 83, 63, 78, 70, 254, - 73, 67, 158, 2, 68, 194, 16, 84, 158, 23, 77, 250, 1, 86, 238, 45, 72, - 158, 1, 79, 198, 10, 71, 186, 2, 65, 246, 173, 3, 73, 62, 66, 223, 225, - 16, 83, 7, 11, 32, 4, 138, 70, 87, 211, 8, 82, 9, 33, 6, 32, 87, 73, 84, - 72, 32, 6, 166, 154, 20, 72, 166, 85, 68, 211, 80, 83, 35, 76, 6, 32, 87, - 73, 84, 72, 32, 190, 81, 76, 154, 200, 18, 65, 147, 211, 2, 72, 20, 154, - 84, 67, 250, 90, 65, 178, 174, 3, 66, 190, 25, 77, 150, 136, 4, 79, 154, - 154, 11, 72, 166, 85, 68, 211, 80, 83, 29, 76, 6, 32, 87, 73, 84, 72, 32, - 250, 126, 65, 250, 239, 7, 87, 247, 173, 12, 69, 20, 186, 82, 66, 34, 67, - 46, 68, 230, 196, 19, 72, 247, 165, 1, 83, 59, 80, 6, 32, 87, 73, 84, 72, - 32, 132, 88, 2, 78, 83, 250, 239, 20, 79, 207, 36, 83, 40, 138, 1, 68, - 162, 83, 67, 242, 1, 77, 142, 1, 84, 130, 71, 72, 158, 1, 79, 198, 10, - 71, 186, 2, 65, 246, 173, 3, 73, 62, 66, 223, 225, 16, 83, 10, 22, 79, - 191, 83, 73, 6, 218, 121, 85, 183, 207, 18, 84, 11, 33, 6, 32, 87, 73, - 84, 72, 32, 8, 42, 67, 226, 130, 18, 84, 219, 183, 3, 83, 4, 234, 170, 1, - 73, 131, 223, 3, 82, 25, 33, 6, 32, 87, 73, 84, 72, 32, 22, 182, 89, 67, - 34, 68, 50, 83, 222, 79, 65, 138, 1, 76, 250, 206, 7, 79, 155, 154, 11, - 72, 41, 60, 6, 32, 87, 73, 84, 72, 32, 190, 94, 65, 155, 138, 21, 74, 32, - 138, 1, 66, 36, 2, 68, 79, 52, 7, 77, 73, 68, 68, 76, 69, 32, 38, 83, - 174, 2, 67, 182, 91, 72, 230, 72, 65, 138, 1, 76, 175, 215, 16, 84, 4, - 222, 193, 12, 69, 143, 237, 8, 65, 6, 22, 85, 231, 91, 84, 2, 249, 241, - 4, 2, 66, 76, 4, 154, 255, 17, 84, 159, 151, 3, 68, 4, 214, 2, 77, 135, - 180, 21, 84, 19, 44, 6, 32, 87, 73, 84, 72, 32, 207, 94, 73, 10, 242, - 165, 1, 65, 242, 155, 16, 68, 198, 60, 84, 231, 145, 2, 72, 33, 48, 6, - 32, 87, 73, 84, 72, 32, 139, 229, 21, 74, 28, 102, 67, 44, 2, 83, 77, - 178, 96, 76, 134, 65, 71, 186, 2, 65, 102, 68, 158, 207, 7, 79, 183, 136, - 9, 84, 6, 190, 132, 1, 69, 22, 73, 155, 184, 19, 65, 2, 209, 228, 10, 10, - 65, 76, 76, 32, 76, 69, 84, 84, 69, 82, 101, 108, 6, 32, 87, 73, 84, 72, - 32, 178, 103, 76, 138, 159, 4, 80, 142, 151, 9, 77, 134, 197, 7, 73, 2, - 79, 3, 85, 84, 144, 1, 2, 76, 79, 34, 77, 226, 96, 67, 70, 68, 154, 2, - 79, 38, 83, 66, 84, 106, 86, 222, 44, 72, 242, 12, 71, 186, 2, 65, 246, - 173, 3, 73, 63, 66, 4, 158, 99, 78, 139, 254, 20, 79, 8, 154, 99, 65, - 235, 159, 4, 73, 19, 44, 6, 32, 87, 73, 84, 72, 32, 155, 23, 72, 14, 242, - 103, 70, 34, 83, 170, 56, 65, 154, 234, 18, 72, 167, 85, 68, 7, 33, 6, - 32, 87, 73, 84, 72, 32, 4, 190, 105, 68, 39, 83, 43, 94, 32, 156, 1, 8, - 69, 86, 69, 82, 83, 69, 68, 32, 216, 111, 3, 85, 77, 32, 167, 147, 4, 65, - 28, 40, 5, 87, 73, 84, 72, 32, 215, 112, 82, 26, 134, 78, 67, 218, 29, - 68, 170, 2, 84, 174, 48, 65, 138, 1, 76, 238, 172, 3, 73, 142, 162, 4, - 79, 143, 192, 12, 83, 8, 218, 110, 72, 154, 156, 4, 79, 238, 194, 13, 67, - 239, 143, 3, 69, 49, 136, 1, 6, 32, 87, 73, 84, 72, 32, 136, 1, 5, 77, - 65, 76, 76, 32, 240, 115, 2, 65, 76, 234, 1, 72, 152, 2, 2, 73, 71, 167, - 138, 4, 67, 32, 86, 67, 138, 112, 65, 118, 68, 138, 1, 83, 174, 1, 86, - 242, 247, 7, 79, 155, 154, 11, 72, 10, 226, 112, 65, 230, 10, 69, 82, 79, - 203, 31, 73, 4, 184, 163, 19, 11, 81, 32, 87, 73, 84, 72, 32, 72, 79, 79, - 75, 173, 247, 1, 7, 67, 65, 80, 73, 84, 65, 76, 59, 136, 1, 6, 32, 87, - 73, 84, 72, 32, 168, 1, 6, 85, 82, 78, 69, 68, 32, 188, 123, 2, 72, 79, - 176, 1, 2, 79, 78, 74, 82, 167, 218, 20, 90, 22, 82, 67, 50, 68, 254, - 152, 1, 76, 234, 237, 3, 82, 170, 251, 14, 72, 247, 165, 1, 83, 8, 202, - 120, 69, 22, 73, 62, 79, 223, 183, 19, 65, 6, 190, 142, 1, 73, 179, 165, - 16, 79, 18, 246, 39, 73, 242, 138, 3, 65, 242, 164, 18, 72, 2, 75, 2, 76, - 2, 77, 2, 84, 3, 86, 79, 26, 32, 183, 135, 5, 80, 74, 44, 5, 87, 73, 84, - 72, 32, 251, 178, 20, 66, 72, 166, 132, 1, 67, 74, 68, 150, 2, 72, 170, - 1, 77, 134, 1, 79, 142, 1, 84, 186, 9, 71, 186, 2, 65, 246, 173, 3, 73, - 62, 66, 158, 221, 14, 82, 195, 132, 2, 83, 23, 88, 6, 32, 87, 73, 84, 72, - 32, 178, 139, 1, 73, 66, 79, 186, 184, 19, 69, 151, 144, 1, 89, 8, 226, - 138, 1, 68, 134, 226, 16, 84, 231, 145, 2, 72, 19, 48, 6, 32, 87, 73, 84, - 72, 32, 167, 147, 7, 89, 14, 190, 144, 1, 67, 18, 68, 70, 71, 186, 2, 65, - 155, 234, 18, 72, 7, 201, 140, 1, 7, 32, 87, 73, 84, 72, 32, 68, 29, 48, - 6, 32, 87, 73, 84, 72, 32, 143, 165, 17, 79, 24, 154, 143, 1, 67, 18, 68, - 70, 71, 22, 72, 42, 76, 254, 1, 65, 238, 199, 3, 77, 202, 144, 13, 84, - 219, 183, 3, 83, 25, 33, 6, 32, 87, 73, 84, 72, 32, 22, 254, 56, 67, 150, - 88, 65, 102, 68, 38, 76, 34, 83, 242, 231, 3, 80, 131, 129, 15, 72, 4, - 178, 209, 10, 73, 195, 232, 10, 79, 12, 128, 1, 5, 65, 82, 67, 72, 65, - 30, 73, 64, 9, 82, 69, 86, 69, 82, 83, 69, 68, 32, 253, 206, 10, 7, 83, - 73, 68, 69, 87, 65, 89, 2, 141, 242, 13, 2, 73, 67, 4, 220, 107, 5, 78, - 86, 69, 82, 84, 201, 211, 14, 3, 32, 76, 79, 4, 194, 206, 21, 70, 3, 80, - 138, 1, 242, 2, 65, 36, 2, 66, 73, 152, 1, 21, 73, 78, 86, 69, 82, 84, - 69, 68, 32, 71, 76, 79, 84, 84, 65, 76, 32, 83, 84, 79, 80, 72, 2, 80, - 72, 16, 2, 82, 69, 222, 1, 83, 132, 8, 3, 84, 87, 79, 182, 20, 87, 128, - 170, 4, 2, 68, 69, 148, 5, 2, 76, 65, 206, 11, 71, 136, 192, 15, 20, 86, - 79, 73, 67, 69, 68, 32, 76, 65, 82, 89, 78, 71, 69, 65, 76, 32, 83, 80, - 73, 199, 119, 89, 4, 230, 187, 4, 76, 235, 191, 16, 73, 6, 76, 7, 76, 65, - 66, 73, 65, 76, 32, 29, 8, 68, 69, 78, 84, 65, 76, 32, 80, 4, 26, 80, - 239, 206, 4, 67, 2, 205, 141, 16, 6, 69, 82, 67, 85, 83, 83, 7, 33, 6, - 32, 87, 73, 84, 72, 32, 4, 234, 243, 4, 67, 235, 165, 16, 83, 2, 207, 81, - 65, 8, 104, 7, 86, 69, 82, 83, 69, 68, 32, 233, 243, 4, 13, 84, 82, 79, - 70, 76, 69, 88, 32, 67, 76, 73, 67, 75, 4, 80, 3, 69, 83, 72, 161, 8, 12, - 71, 76, 79, 84, 84, 65, 76, 32, 83, 84, 79, 80, 2, 213, 133, 1, 2, 32, - 76, 96, 172, 1, 13, 77, 65, 76, 76, 32, 67, 65, 80, 73, 84, 65, 76, 32, - 244, 112, 10, 84, 82, 69, 84, 67, 72, 69, 68, 32, 67, 237, 193, 19, 10, - 73, 78, 79, 76, 79, 71, 73, 67, 65, 76, 90, 230, 1, 69, 30, 73, 22, 76, - 74, 79, 42, 82, 126, 84, 254, 182, 4, 66, 214, 41, 71, 158, 161, 16, 65, - 162, 64, 67, 2, 68, 2, 70, 2, 72, 2, 74, 2, 75, 2, 77, 2, 78, 2, 80, 2, - 81, 2, 83, 2, 85, 2, 86, 2, 87, 2, 89, 3, 90, 7, 150, 195, 21, 84, 3, 90, - 5, 147, 220, 4, 78, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 162, 221, 8, 66, - 183, 182, 12, 83, 9, 238, 95, 80, 194, 227, 20, 69, 3, 85, 11, 92, 8, 69, - 86, 69, 82, 83, 69, 68, 32, 236, 128, 1, 5, 32, 87, 73, 84, 72, 231, 176, - 20, 85, 4, 166, 194, 21, 78, 3, 82, 13, 33, 6, 85, 82, 78, 69, 68, 32, - 10, 230, 193, 21, 69, 2, 71, 2, 75, 2, 77, 3, 82, 186, 11, 136, 1, 5, 77, - 65, 76, 76, 32, 145, 131, 1, 22, 85, 66, 83, 67, 82, 73, 80, 84, 32, 83, - 77, 65, 76, 76, 32, 76, 69, 84, 84, 69, 82, 32, 150, 11, 76, 15, 67, 65, - 80, 73, 84, 65, 76, 32, 76, 69, 84, 84, 69, 82, 32, 43, 76, 4, 18, 73, 3, - 85, 2, 255, 226, 4, 32, 146, 11, 80, 6, 69, 84, 84, 69, 82, 32, 161, 128, - 1, 8, 73, 71, 65, 84, 85, 82, 69, 32, 128, 11, 182, 2, 65, 190, 5, 66, - 198, 3, 67, 186, 4, 68, 182, 4, 69, 174, 9, 70, 214, 1, 71, 162, 2, 72, - 230, 2, 73, 166, 7, 74, 182, 1, 75, 178, 2, 76, 206, 6, 77, 178, 2, 78, - 218, 3, 79, 242, 8, 80, 218, 2, 81, 174, 1, 82, 142, 8, 83, 250, 10, 84, - 246, 13, 85, 218, 9, 86, 130, 3, 87, 110, 88, 226, 2, 89, 171, 3, 90, - 101, 118, 32, 198, 3, 69, 82, 78, 192, 226, 4, 4, 76, 80, 72, 65, 146, - 176, 15, 86, 186, 164, 1, 65, 2, 79, 2, 85, 3, 89, 72, 88, 5, 87, 73, 84, - 72, 32, 157, 229, 5, 11, 82, 69, 86, 69, 82, 83, 69, 68, 45, 83, 67, 70, - 150, 1, 66, 34, 68, 54, 82, 170, 34, 77, 250, 21, 67, 150, 50, 72, 158, - 1, 79, 198, 10, 71, 186, 2, 65, 246, 173, 3, 73, 194, 170, 13, 84, 219, - 183, 3, 83, 12, 161, 106, 4, 82, 69, 86, 69, 12, 22, 79, 151, 57, 73, 8, - 214, 57, 84, 211, 13, 85, 10, 26, 73, 175, 231, 4, 69, 8, 26, 78, 179, - 174, 4, 71, 6, 17, 2, 71, 32, 6, 236, 58, 4, 65, 66, 79, 86, 175, 219, - 18, 66, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 242, 116, 71, 186, 2, 65, - 239, 199, 3, 77, 2, 233, 193, 10, 7, 71, 76, 73, 67, 65, 78, 65, 41, 140, - 1, 6, 32, 87, 73, 84, 72, 32, 130, 1, 65, 108, 11, 76, 65, 67, 75, 76, - 69, 84, 84, 69, 82, 32, 38, 82, 174, 201, 4, 79, 195, 197, 16, 69, 18, - 110, 84, 138, 60, 70, 210, 57, 76, 230, 224, 3, 77, 174, 7, 80, 218, 178, - 12, 68, 170, 206, 2, 72, 247, 165, 1, 83, 2, 255, 7, 79, 8, 64, 5, 82, - 82, 69, 68, 32, 161, 81, 6, 83, 69, 76, 73, 78, 69, 6, 182, 32, 65, 206, - 147, 21, 69, 3, 79, 6, 242, 195, 4, 79, 235, 239, 16, 69, 2, 233, 181, - 10, 4, 79, 75, 69, 78, 47, 108, 6, 32, 87, 73, 84, 72, 32, 196, 1, 2, 72, - 73, 92, 6, 76, 79, 83, 69, 68, 32, 90, 85, 207, 223, 20, 79, 24, 102, 67, - 182, 113, 65, 154, 233, 3, 80, 218, 5, 82, 170, 251, 14, 72, 182, 50, 66, - 242, 34, 68, 211, 80, 83, 10, 54, 69, 190, 113, 73, 202, 246, 6, 85, 207, - 161, 12, 65, 4, 245, 51, 5, 68, 73, 76, 76, 65, 7, 49, 10, 32, 87, 73, - 84, 72, 32, 76, 79, 87, 32, 4, 162, 107, 82, 45, 4, 76, 69, 70, 84, 8, - 34, 73, 18, 79, 159, 200, 4, 82, 2, 163, 88, 78, 4, 130, 221, 4, 80, 203, - 141, 9, 77, 4, 37, 7, 65, 84, 82, 73, 76, 76, 79, 5, 133, 138, 13, 5, 32, - 87, 73, 84, 72, 73, 96, 6, 32, 87, 73, 84, 72, 32, 182, 1, 69, 34, 79, - 178, 1, 90, 178, 213, 4, 66, 239, 196, 16, 85, 32, 98, 83, 34, 84, 238, - 32, 67, 226, 45, 77, 170, 31, 76, 138, 217, 3, 72, 138, 15, 80, 219, 178, - 12, 68, 4, 134, 68, 72, 159, 185, 20, 84, 4, 26, 79, 139, 205, 19, 65, 2, - 143, 137, 20, 80, 8, 246, 78, 90, 131, 185, 20, 76, 16, 60, 6, 84, 76, - 69, 83, 83, 32, 49, 5, 85, 66, 76, 69, 32, 8, 26, 74, 203, 171, 21, 73, - 7, 167, 198, 4, 32, 8, 42, 87, 142, 202, 4, 82, 227, 234, 5, 84, 2, 215, - 234, 6, 89, 11, 11, 32, 8, 26, 87, 151, 198, 4, 68, 2, 169, 90, 5, 73, - 84, 72, 32, 67, 119, 112, 6, 32, 87, 73, 84, 72, 32, 214, 4, 71, 72, 2, - 78, 71, 68, 2, 83, 72, 164, 1, 2, 90, 72, 211, 145, 17, 84, 76, 182, 1, - 67, 158, 2, 68, 110, 78, 214, 15, 84, 158, 23, 77, 250, 1, 86, 190, 3, - 70, 178, 42, 72, 158, 1, 79, 198, 10, 71, 186, 2, 65, 246, 173, 3, 73, - 62, 66, 194, 64, 82, 159, 161, 16, 83, 24, 92, 6, 69, 68, 73, 76, 76, 65, - 32, 9, 73, 82, 67, 85, 77, 70, 76, 69, 88, 203, 255, 19, 65, 5, 169, 149, - 4, 3, 32, 65, 78, 19, 11, 32, 16, 40, 4, 65, 78, 68, 32, 219, 132, 19, - 66, 14, 162, 86, 67, 130, 2, 72, 226, 11, 71, 186, 2, 65, 238, 199, 3, - 77, 210, 165, 4, 68, 251, 234, 8, 84, 12, 22, 79, 227, 98, 73, 10, 28, 2, - 84, 32, 227, 51, 85, 8, 192, 88, 5, 65, 66, 79, 86, 69, 251, 170, 18, 66, - 2, 183, 149, 14, 79, 4, 209, 129, 7, 13, 89, 80, 84, 79, 76, 79, 71, 73, - 67, 65, 76, 32, 65, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 158, 195, 4, 67, - 231, 9, 80, 13, 33, 6, 32, 87, 73, 84, 72, 32, 10, 88, 10, 68, 79, 85, - 66, 76, 69, 32, 66, 65, 82, 230, 203, 4, 80, 142, 1, 67, 207, 4, 82, 5, - 217, 204, 4, 4, 32, 65, 78, 68, 15, 11, 32, 12, 38, 82, 37, 5, 87, 73, - 84, 72, 32, 2, 209, 145, 14, 4, 69, 86, 69, 82, 10, 54, 67, 178, 202, 4, - 80, 218, 5, 82, 247, 153, 14, 84, 4, 158, 216, 7, 85, 207, 161, 12, 65, - 17, 84, 6, 32, 87, 73, 84, 72, 32, 73, 11, 69, 78, 71, 32, 68, 73, 71, - 82, 65, 80, 72, 10, 134, 194, 4, 77, 174, 7, 80, 130, 129, 15, 72, 166, - 85, 68, 211, 80, 83, 5, 133, 164, 18, 8, 32, 87, 73, 84, 72, 32, 84, 82, - 37, 72, 6, 32, 87, 73, 84, 72, 32, 126, 76, 154, 200, 18, 65, 147, 211, - 2, 72, 22, 218, 3, 67, 250, 90, 65, 178, 174, 3, 66, 190, 25, 77, 174, - 33, 80, 234, 230, 3, 79, 154, 154, 11, 72, 166, 85, 68, 211, 80, 83, 8, - 33, 6, 79, 84, 84, 65, 76, 32, 8, 194, 200, 18, 83, 250, 212, 2, 65, 2, - 73, 3, 85, 39, 140, 1, 6, 32, 87, 73, 84, 72, 32, 150, 45, 65, 232, 25, - 12, 79, 79, 75, 69, 68, 32, 83, 67, 72, 87, 65, 32, 174, 243, 3, 69, 211, - 225, 16, 86, 24, 86, 66, 34, 67, 46, 68, 214, 91, 76, 146, 232, 3, 80, - 130, 129, 15, 72, 247, 165, 1, 83, 2, 129, 143, 13, 3, 82, 69, 86, 6, - 158, 59, 69, 154, 32, 73, 151, 152, 19, 65, 8, 234, 87, 73, 226, 190, 3, - 69, 255, 223, 12, 79, 75, 80, 6, 32, 87, 73, 84, 72, 32, 222, 4, 78, 188, - 1, 2, 79, 84, 187, 147, 21, 83, 48, 178, 1, 67, 34, 68, 210, 1, 77, 64, - 6, 79, 71, 79, 78, 69, 75, 78, 84, 130, 71, 72, 226, 11, 71, 186, 2, 65, - 246, 173, 3, 73, 62, 66, 144, 64, 6, 83, 84, 82, 79, 75, 69, 51, 82, 4, - 210, 88, 73, 151, 152, 19, 65, 14, 18, 73, 47, 79, 4, 217, 26, 7, 65, 69, - 82, 69, 83, 73, 83, 10, 28, 2, 84, 32, 215, 37, 85, 8, 64, 10, 65, 66, - 79, 86, 69, 32, 65, 78, 68, 32, 239, 244, 18, 66, 6, 150, 84, 71, 186, 2, - 65, 183, 216, 16, 84, 4, 29, 5, 65, 67, 82, 79, 78, 5, 217, 36, 4, 32, - 65, 78, 68, 7, 145, 73, 15, 32, 65, 78, 68, 32, 68, 79, 84, 32, 65, 66, - 79, 86, 69, 32, 4, 21, 3, 73, 76, 68, 4, 151, 142, 5, 69, 16, 46, 83, 93, - 7, 86, 69, 82, 84, 69, 68, 32, 12, 29, 5, 85, 76, 65, 82, 32, 12, 162, - 148, 21, 68, 2, 70, 2, 71, 2, 82, 2, 83, 3, 84, 4, 26, 65, 251, 252, 20, - 79, 2, 195, 183, 17, 76, 6, 206, 163, 4, 65, 181, 183, 6, 5, 73, 70, 73, - 69, 68, 13, 33, 6, 32, 87, 73, 84, 72, 32, 10, 94, 67, 148, 180, 4, 13, - 68, 79, 84, 32, 65, 66, 79, 86, 69, 32, 65, 78, 68, 239, 173, 16, 83, 6, - 178, 82, 73, 130, 223, 3, 82, 151, 185, 15, 65, 29, 48, 6, 32, 87, 73, - 84, 72, 32, 227, 142, 21, 82, 24, 98, 67, 34, 68, 50, 83, 222, 79, 65, - 138, 1, 76, 146, 232, 3, 80, 234, 230, 3, 79, 155, 154, 11, 72, 4, 210, - 48, 69, 175, 184, 19, 65, 6, 214, 70, 73, 182, 197, 3, 69, 203, 177, 4, - 79, 4, 29, 5, 84, 82, 79, 75, 69, 5, 161, 25, 6, 32, 65, 78, 68, 32, 68, - 79, 136, 1, 6, 32, 87, 73, 84, 72, 32, 250, 3, 65, 38, 69, 48, 5, 79, 78, - 71, 32, 83, 130, 180, 4, 83, 2, 90, 238, 196, 16, 85, 219, 16, 74, 50, - 178, 1, 66, 86, 67, 56, 2, 68, 79, 100, 3, 77, 73, 68, 130, 2, 72, 230, - 72, 65, 138, 1, 76, 150, 224, 3, 73, 162, 1, 82, 222, 2, 70, 130, 4, 80, - 158, 239, 12, 84, 219, 183, 3, 83, 6, 36, 3, 69, 76, 84, 219, 211, 20, - 65, 5, 193, 181, 4, 6, 32, 65, 78, 68, 32, 80, 8, 166, 44, 69, 22, 73, - 206, 150, 7, 85, 207, 161, 12, 65, 8, 38, 84, 25, 5, 85, 66, 76, 69, 32, - 4, 141, 25, 2, 32, 66, 4, 242, 172, 4, 77, 227, 186, 15, 66, 8, 36, 4, - 68, 76, 69, 32, 207, 44, 45, 6, 238, 162, 17, 84, 210, 150, 3, 82, 79, - 68, 4, 173, 154, 4, 4, 77, 66, 68, 65, 6, 158, 181, 4, 90, 241, 133, 13, - 3, 78, 73, 83, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 18, 68, 35, 72, 4, - 206, 63, 73, 255, 200, 19, 79, 2, 197, 172, 4, 2, 73, 71, 27, 56, 6, 32, - 87, 73, 84, 72, 32, 102, 73, 219, 246, 20, 85, 16, 138, 72, 65, 182, 223, - 3, 67, 186, 2, 77, 174, 7, 80, 218, 178, 12, 68, 198, 60, 84, 231, 145, - 2, 72, 6, 25, 4, 68, 68, 76, 69, 6, 76, 7, 45, 87, 69, 76, 83, 72, 32, - 225, 140, 17, 6, 32, 83, 67, 79, 84, 83, 4, 242, 250, 19, 76, 211, 139, - 1, 86, 49, 58, 32, 216, 2, 2, 71, 32, 182, 242, 20, 85, 219, 16, 74, 40, - 88, 5, 87, 73, 84, 72, 32, 209, 142, 6, 11, 80, 82, 69, 67, 69, 68, 69, - 68, 32, 66, 89, 38, 122, 67, 74, 76, 158, 37, 77, 234, 27, 71, 186, 2, - 65, 102, 68, 182, 232, 3, 80, 218, 5, 82, 146, 225, 3, 79, 183, 136, 9, - 84, 10, 170, 36, 69, 22, 73, 134, 255, 3, 82, 202, 151, 3, 85, 207, 161, - 12, 65, 6, 132, 66, 3, 79, 78, 71, 202, 2, 73, 183, 239, 3, 69, 2, 25, 4, - 87, 73, 84, 72, 2, 229, 219, 17, 5, 32, 84, 73, 76, 68, 115, 116, 6, 32, - 87, 73, 84, 72, 32, 186, 6, 76, 52, 4, 80, 69, 78, 32, 226, 181, 13, 77, - 134, 197, 7, 73, 2, 79, 3, 85, 86, 154, 1, 67, 70, 68, 152, 1, 2, 76, 79, - 86, 77, 46, 79, 38, 83, 66, 84, 106, 86, 222, 44, 72, 242, 12, 71, 186, - 2, 65, 246, 173, 3, 73, 62, 66, 195, 64, 82, 14, 172, 49, 9, 73, 82, 67, - 85, 77, 70, 76, 69, 88, 211, 167, 19, 65, 14, 18, 73, 47, 79, 4, 221, 13, - 7, 65, 69, 82, 69, 83, 73, 83, 10, 22, 84, 171, 47, 85, 6, 11, 32, 6, - 140, 13, 5, 65, 66, 79, 86, 69, 147, 208, 18, 66, 6, 66, 78, 140, 204, - 12, 6, 87, 32, 82, 73, 78, 71, 255, 177, 8, 79, 2, 159, 21, 71, 6, 11, - 65, 6, 189, 2, 4, 67, 82, 79, 78, 4, 217, 11, 5, 71, 79, 78, 69, 75, 4, - 25, 4, 84, 82, 79, 75, 4, 11, 69, 5, 213, 49, 2, 32, 65, 8, 25, 4, 73, - 76, 68, 69, 9, 29, 5, 32, 65, 78, 68, 32, 6, 162, 47, 68, 142, 13, 65, - 239, 199, 3, 77, 6, 81, 18, 69, 82, 84, 73, 67, 65, 76, 32, 76, 73, 78, - 69, 32, 66, 69, 76, 79, 87, 7, 221, 43, 4, 32, 65, 78, 68, 2, 205, 131, - 10, 8, 68, 32, 80, 79, 76, 73, 83, 72, 16, 26, 79, 131, 166, 4, 69, 13, - 48, 6, 32, 87, 73, 84, 72, 32, 151, 250, 20, 69, 8, 210, 55, 71, 186, 2, - 65, 242, 238, 3, 82, 159, 161, 16, 83, 25, 44, 6, 32, 87, 73, 84, 72, 32, - 179, 1, 72, 18, 86, 70, 34, 83, 170, 56, 65, 238, 225, 3, 77, 174, 7, 80, - 130, 129, 15, 72, 167, 85, 68, 2, 205, 191, 14, 3, 76, 79, 85, 6, 210, - 28, 84, 133, 171, 12, 6, 81, 85, 73, 82, 82, 69, 4, 26, 65, 223, 247, 20, - 73, 2, 193, 183, 5, 18, 82, 89, 78, 71, 69, 65, 76, 32, 86, 79, 73, 67, - 69, 68, 32, 70, 82, 73, 13, 48, 6, 32, 87, 73, 84, 72, 32, 139, 161, 4, - 80, 8, 42, 68, 16, 4, 72, 79, 79, 75, 23, 83, 2, 227, 44, 73, 5, 223, - 190, 18, 32, 2, 197, 26, 6, 84, 82, 79, 75, 69, 32, 77, 90, 32, 228, 4, - 8, 69, 86, 69, 82, 83, 69, 68, 32, 148, 2, 2, 85, 77, 179, 147, 4, 65, - 46, 36, 4, 87, 73, 84, 72, 235, 6, 82, 44, 26, 32, 247, 185, 15, 79, 42, - 166, 1, 67, 50, 68, 200, 1, 8, 70, 73, 83, 72, 72, 79, 79, 75, 66, 76, - 34, 84, 142, 18, 77, 162, 30, 65, 246, 173, 3, 73, 166, 59, 80, 234, 230, - 3, 79, 143, 192, 12, 83, 6, 170, 19, 69, 154, 255, 3, 82, 151, 185, 15, - 65, 8, 11, 79, 8, 24, 2, 84, 32, 111, 85, 6, 26, 66, 175, 245, 19, 65, 4, - 25, 4, 69, 76, 79, 87, 5, 29, 5, 32, 65, 78, 68, 32, 2, 191, 249, 3, 77, - 2, 21, 3, 66, 76, 69, 2, 11, 32, 2, 227, 46, 71, 7, 29, 5, 32, 65, 78, - 68, 32, 4, 214, 146, 4, 77, 175, 7, 80, 4, 222, 49, 73, 131, 236, 3, 79, - 4, 162, 211, 18, 73, 195, 61, 65, 22, 162, 1, 72, 40, 6, 79, 80, 69, 78, - 32, 69, 216, 147, 4, 8, 82, 32, 87, 73, 84, 72, 32, 70, 168, 2, 3, 83, - 67, 82, 242, 218, 14, 69, 190, 87, 67, 159, 166, 1, 75, 2, 11, 65, 2, - 177, 246, 9, 2, 76, 70, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 138, 157, 4, - 82, 171, 251, 14, 72, 5, 11, 32, 2, 11, 82, 2, 237, 141, 17, 3, 79, 84, - 85, 85, 180, 1, 6, 32, 87, 73, 84, 72, 32, 218, 4, 65, 66, 67, 218, 1, - 72, 34, 73, 156, 2, 13, 81, 85, 65, 84, 32, 82, 69, 86, 69, 82, 83, 69, - 68, 145, 231, 9, 6, 84, 73, 82, 82, 85, 80, 40, 110, 65, 34, 67, 86, 68, - 138, 1, 83, 174, 1, 86, 210, 9, 77, 186, 135, 4, 80, 234, 230, 3, 79, - 155, 154, 11, 72, 4, 205, 1, 4, 67, 85, 84, 69, 12, 58, 65, 230, 10, 69, - 82, 79, 202, 31, 73, 203, 246, 6, 85, 4, 113, 3, 82, 79, 78, 8, 32, 3, - 79, 84, 32, 207, 32, 73, 6, 26, 66, 131, 237, 19, 65, 4, 25, 4, 69, 76, - 79, 87, 5, 11, 32, 2, 225, 232, 19, 3, 65, 78, 68, 4, 22, 72, 203, 42, - 87, 2, 21, 3, 79, 82, 84, 2, 17, 2, 32, 83, 2, 11, 84, 2, 21, 3, 82, 79, - 75, 2, 11, 69, 2, 17, 2, 32, 79, 2, 249, 217, 19, 4, 86, 69, 82, 76, 2, - 37, 7, 69, 82, 84, 73, 67, 65, 76, 2, 205, 40, 2, 32, 76, 4, 46, 76, 217, - 221, 19, 5, 75, 72, 65, 32, 89, 2, 247, 12, 84, 18, 48, 3, 72, 87, 65, - 97, 5, 82, 73, 80, 84, 32, 11, 33, 6, 32, 87, 73, 84, 72, 32, 8, 222, 35, - 71, 186, 2, 65, 242, 238, 3, 82, 171, 251, 14, 72, 8, 26, 82, 207, 132, - 4, 71, 5, 165, 182, 11, 5, 32, 87, 73, 84, 72, 2, 185, 235, 16, 3, 65, - 82, 80, 14, 48, 7, 68, 69, 87, 65, 89, 83, 32, 199, 1, 71, 12, 110, 79, - 56, 4, 84, 85, 82, 78, 208, 200, 10, 11, 68, 73, 65, 69, 82, 69, 83, 73, - 90, 69, 68, 215, 154, 10, 85, 7, 26, 80, 135, 135, 4, 32, 2, 245, 235, 9, - 2, 69, 78, 2, 145, 134, 13, 2, 69, 68, 2, 161, 233, 16, 4, 77, 79, 73, - 68, 2, 191, 252, 9, 32, 147, 1, 188, 1, 6, 32, 87, 73, 84, 72, 32, 192, - 3, 2, 69, 83, 70, 72, 130, 2, 79, 102, 82, 54, 85, 174, 131, 4, 67, 202, - 1, 83, 132, 253, 10, 9, 65, 73, 76, 76, 69, 83, 83, 32, 80, 251, 215, 5, - 90, 34, 110, 67, 182, 1, 68, 66, 77, 170, 31, 76, 146, 232, 3, 80, 168, - 5, 4, 72, 79, 79, 75, 50, 82, 159, 161, 16, 83, 10, 58, 69, 22, 73, 62, - 79, 146, 150, 7, 85, 207, 161, 12, 65, 2, 143, 164, 12, 68, 2, 37, 7, 82, - 67, 85, 77, 70, 76, 69, 2, 139, 174, 18, 88, 2, 17, 2, 77, 77, 2, 227, - 173, 18, 65, 8, 32, 2, 73, 65, 187, 186, 16, 79, 4, 154, 21, 71, 215, 6, - 69, 4, 17, 2, 73, 68, 4, 26, 45, 255, 255, 3, 68, 2, 149, 142, 4, 6, 72, - 69, 73, 71, 72, 84, 6, 45, 9, 72, 32, 68, 73, 71, 82, 65, 80, 72, 7, 243, - 133, 4, 32, 8, 64, 12, 32, 87, 73, 84, 72, 32, 83, 84, 82, 73, 75, 69, - 43, 79, 2, 157, 175, 16, 5, 84, 72, 82, 79, 85, 6, 17, 2, 82, 78, 7, 41, - 8, 32, 87, 73, 84, 72, 32, 83, 84, 4, 25, 4, 82, 79, 75, 69, 5, 11, 32, - 2, 133, 215, 3, 6, 84, 72, 82, 79, 85, 71, 8, 26, 78, 203, 133, 4, 80, 6, - 17, 2, 69, 32, 6, 206, 206, 4, 83, 186, 207, 10, 70, 155, 168, 3, 84, 2, - 17, 2, 69, 83, 2, 11, 73, 2, 179, 183, 20, 76, 76, 44, 5, 82, 78, 69, 68, - 32, 195, 217, 20, 77, 74, 162, 1, 68, 22, 72, 66, 73, 54, 79, 142, 1, 82, - 110, 84, 22, 86, 198, 129, 4, 65, 38, 77, 198, 2, 89, 134, 189, 16, 85, - 218, 19, 69, 2, 71, 2, 75, 2, 76, 3, 87, 2, 183, 155, 17, 69, 7, 141, - 242, 3, 11, 32, 87, 73, 84, 72, 32, 70, 73, 83, 72, 72, 5, 11, 78, 2, - 249, 213, 9, 5, 83, 85, 76, 65, 82, 12, 66, 69, 232, 230, 3, 7, 32, 79, - 80, 69, 78, 45, 79, 159, 29, 80, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, - 162, 174, 18, 72, 143, 248, 1, 83, 15, 33, 6, 32, 87, 73, 84, 72, 32, 12, - 198, 247, 3, 77, 174, 7, 80, 130, 5, 76, 206, 154, 14, 84, 183, 97, 72, - 5, 135, 255, 3, 32, 7, 11, 32, 4, 161, 5, 4, 87, 73, 84, 72, 97, 90, 32, - 152, 228, 3, 6, 80, 83, 73, 76, 79, 78, 234, 239, 16, 69, 2, 73, 2, 77, - 3, 79, 82, 48, 3, 66, 65, 82, 49, 5, 87, 73, 84, 72, 32, 5, 245, 17, 8, - 32, 87, 73, 84, 72, 32, 83, 72, 78, 142, 1, 67, 74, 68, 150, 2, 72, 170, - 1, 77, 134, 1, 79, 106, 82, 38, 84, 186, 9, 71, 82, 83, 234, 1, 65, 246, - 173, 3, 73, 62, 66, 143, 66, 76, 6, 152, 203, 4, 9, 73, 82, 67, 85, 77, - 70, 76, 69, 88, 191, 223, 14, 65, 18, 52, 8, 73, 65, 69, 82, 69, 83, 73, - 83, 131, 1, 79, 13, 11, 32, 10, 40, 4, 65, 78, 68, 32, 235, 174, 18, 66, - 8, 50, 67, 226, 13, 71, 186, 2, 65, 239, 199, 3, 77, 2, 235, 168, 19, 65, - 6, 26, 85, 219, 158, 18, 84, 4, 21, 3, 66, 76, 69, 4, 11, 32, 4, 138, 13, - 71, 187, 2, 65, 14, 11, 79, 14, 28, 2, 82, 78, 207, 81, 79, 13, 29, 5, - 32, 65, 78, 68, 32, 10, 66, 72, 226, 11, 71, 186, 2, 65, 190, 237, 7, 68, - 251, 234, 8, 84, 2, 229, 80, 2, 79, 79, 10, 29, 5, 65, 67, 82, 79, 78, - 11, 29, 5, 32, 65, 78, 68, 32, 8, 50, 68, 214, 10, 71, 186, 2, 65, 183, - 216, 16, 84, 2, 171, 10, 73, 6, 29, 5, 71, 79, 78, 69, 75, 7, 11, 32, 4, - 25, 4, 65, 78, 68, 32, 4, 178, 12, 65, 183, 216, 16, 84, 4, 142, 251, 3, - 69, 223, 156, 14, 73, 6, 25, 4, 73, 76, 68, 69, 7, 11, 32, 4, 26, 65, - 203, 169, 18, 66, 2, 17, 2, 78, 68, 2, 11, 32, 2, 139, 11, 65, 29, 84, 6, - 32, 87, 73, 84, 72, 32, 162, 1, 73, 66, 79, 186, 184, 19, 69, 151, 144, - 1, 89, 14, 82, 68, 234, 242, 3, 80, 142, 1, 67, 146, 7, 82, 130, 231, 12, - 84, 231, 145, 2, 72, 4, 26, 73, 255, 246, 7, 79, 2, 17, 2, 65, 71, 2, - 253, 152, 20, 2, 79, 78, 2, 41, 8, 83, 73, 71, 79, 84, 72, 73, 67, 2, - 183, 234, 18, 32, 6, 33, 6, 76, 65, 80, 85, 75, 32, 6, 210, 177, 20, 65, - 2, 79, 3, 85, 19, 33, 6, 32, 87, 73, 84, 72, 32, 16, 202, 4, 67, 18, 68, - 70, 71, 186, 2, 65, 206, 139, 18, 82, 207, 94, 72, 17, 33, 6, 32, 87, 73, - 84, 72, 32, 14, 42, 68, 32, 2, 76, 79, 187, 239, 3, 80, 4, 222, 3, 73, - 171, 194, 19, 79, 8, 60, 11, 78, 71, 32, 76, 69, 70, 84, 32, 76, 69, 71, - 79, 87, 7, 11, 32, 4, 60, 7, 65, 78, 68, 32, 76, 79, 87, 65, 4, 87, 73, - 84, 72, 2, 17, 2, 32, 82, 2, 21, 3, 73, 71, 72, 2, 207, 149, 11, 84, 2, - 237, 194, 19, 4, 32, 83, 69, 82, 33, 48, 6, 32, 87, 73, 84, 72, 32, 227, - 150, 16, 79, 28, 110, 67, 18, 68, 70, 71, 22, 72, 42, 76, 22, 83, 234, 1, - 65, 238, 199, 3, 77, 202, 144, 13, 84, 155, 179, 1, 82, 2, 203, 3, 73, 6, - 26, 73, 223, 158, 16, 79, 2, 17, 2, 65, 69, 2, 239, 187, 16, 82, 2, 163, - 212, 18, 82, 4, 17, 2, 79, 79, 4, 239, 136, 5, 75, 2, 239, 200, 19, 79, - 4, 26, 72, 231, 145, 20, 84, 2, 21, 3, 79, 82, 84, 2, 249, 247, 7, 6, 32, - 82, 73, 71, 72, 84, 31, 33, 6, 32, 87, 73, 84, 72, 32, 28, 98, 65, 22, - 67, 82, 68, 38, 76, 34, 83, 198, 224, 3, 77, 174, 7, 80, 218, 5, 82, 171, - 251, 14, 72, 2, 147, 186, 13, 67, 6, 42, 73, 202, 246, 6, 85, 207, 161, - 12, 65, 2, 153, 199, 11, 4, 82, 67, 85, 77, 6, 154, 187, 3, 69, 255, 223, - 12, 79, 2, 11, 73, 2, 215, 178, 12, 78, 4, 26, 87, 215, 142, 20, 84, 2, - 139, 150, 17, 65, 18, 90, 70, 194, 190, 9, 73, 172, 9, 6, 76, 79, 78, 71, - 32, 83, 190, 217, 10, 83, 219, 5, 79, 10, 34, 70, 178, 189, 20, 73, 3, - 76, 7, 174, 189, 20, 73, 3, 76, 36, 150, 1, 83, 254, 187, 20, 65, 2, 69, - 2, 72, 2, 73, 2, 74, 2, 75, 2, 76, 2, 77, 2, 78, 2, 79, 2, 80, 2, 82, 2, - 84, 2, 85, 2, 86, 3, 88, 5, 215, 230, 4, 67, 226, 5, 240, 1, 2, 65, 70, - 144, 1, 2, 70, 84, 190, 38, 79, 20, 5, 80, 67, 72, 65, 32, 164, 8, 8, 83, - 83, 45, 84, 72, 65, 78, 32, 236, 245, 12, 5, 85, 75, 79, 84, 72, 218, - 194, 3, 68, 228, 23, 6, 86, 69, 76, 32, 83, 76, 218, 233, 2, 77, 239, 79, - 71, 6, 120, 3, 76, 69, 83, 160, 196, 1, 14, 32, 70, 76, 85, 84, 84, 69, - 82, 73, 78, 71, 32, 73, 78, 241, 213, 11, 3, 89, 32, 71, 2, 151, 239, 14, - 83, 134, 4, 58, 32, 250, 20, 45, 217, 2, 6, 87, 65, 82, 68, 83, 32, 246, - 1, 166, 2, 65, 234, 4, 66, 202, 1, 67, 96, 2, 68, 79, 112, 2, 72, 65, - 166, 3, 76, 46, 77, 38, 79, 102, 82, 146, 3, 83, 82, 84, 222, 1, 87, 210, - 178, 8, 70, 236, 5, 14, 74, 85, 83, 84, 73, 70, 73, 69, 68, 32, 82, 73, - 71, 72, 86, 78, 202, 1, 80, 153, 13, 10, 86, 69, 82, 84, 73, 67, 65, 76, - 32, 66, 28, 22, 78, 143, 4, 82, 22, 28, 2, 68, 32, 191, 3, 71, 16, 96, 6, - 76, 79, 87, 69, 82, 32, 32, 6, 82, 73, 71, 72, 84, 32, 89, 6, 85, 80, 80, - 69, 82, 32, 4, 202, 1, 65, 163, 192, 17, 79, 6, 50, 84, 133, 139, 18, 6, - 68, 79, 85, 66, 76, 69, 4, 174, 153, 17, 82, 211, 232, 1, 65, 6, 82, 65, - 53, 16, 79, 78, 69, 32, 69, 73, 71, 72, 84, 72, 32, 66, 76, 79, 67, 75, - 2, 161, 151, 17, 8, 78, 68, 32, 82, 73, 71, 72, 84, 5, 169, 143, 19, 17, - 32, 67, 79, 78, 84, 65, 73, 78, 73, 78, 71, 32, 66, 76, 65, 67, 75, 6, - 250, 183, 8, 69, 185, 1, 4, 76, 69, 32, 66, 6, 26, 67, 215, 187, 8, 82, - 2, 177, 187, 8, 5, 32, 76, 69, 83, 83, 12, 40, 4, 65, 82, 66, 32, 239, - 187, 8, 76, 8, 40, 4, 68, 79, 87, 78, 1, 2, 85, 80, 4, 57, 12, 32, 82, - 73, 71, 72, 84, 32, 66, 65, 82, 66, 32, 4, 164, 133, 17, 4, 68, 79, 87, - 78, 1, 2, 85, 80, 14, 178, 187, 8, 85, 166, 26, 79, 242, 235, 2, 69, 141, - 168, 2, 8, 76, 79, 83, 69, 68, 32, 69, 78, 10, 44, 5, 85, 66, 76, 69, 32, - 223, 187, 8, 84, 8, 146, 189, 8, 87, 190, 30, 65, 154, 132, 3, 81, 199, - 199, 4, 80, 38, 36, 3, 76, 70, 32, 215, 193, 8, 78, 36, 132, 2, 6, 67, - 73, 82, 67, 76, 69, 214, 188, 8, 66, 90, 70, 82, 72, 50, 82, 58, 84, 70, - 87, 246, 13, 76, 22, 85, 176, 200, 8, 30, 73, 78, 86, 69, 82, 83, 69, 32, - 77, 69, 68, 73, 85, 77, 32, 83, 72, 65, 68, 69, 32, 65, 78, 68, 32, 82, - 73, 71, 72, 84, 255, 26, 77, 11, 33, 6, 32, 87, 73, 84, 72, 32, 8, 42, - 84, 130, 132, 18, 70, 191, 214, 1, 68, 4, 146, 203, 5, 72, 255, 140, 13, - 87, 4, 232, 162, 1, 2, 85, 71, 215, 156, 7, 79, 2, 141, 151, 19, 4, 85, - 76, 84, 73, 8, 36, 3, 78, 69, 32, 167, 192, 8, 85, 6, 246, 178, 17, 81, - 146, 4, 69, 45, 5, 84, 72, 73, 82, 68, 30, 44, 5, 73, 71, 72, 84, 32, - 251, 192, 8, 65, 28, 152, 1, 5, 65, 82, 82, 79, 87, 132, 1, 12, 68, 79, - 85, 66, 76, 69, 32, 65, 82, 82, 79, 87, 30, 87, 138, 238, 8, 79, 162, - 143, 8, 66, 54, 83, 211, 68, 84, 11, 11, 32, 8, 72, 5, 87, 73, 84, 72, - 32, 145, 210, 18, 7, 84, 72, 82, 79, 85, 71, 72, 6, 198, 190, 16, 68, - 234, 183, 3, 86, 79, 83, 7, 169, 230, 8, 2, 32, 87, 4, 254, 248, 8, 65, - 227, 191, 8, 72, 34, 142, 191, 8, 45, 70, 69, 78, 73, 168, 1, 3, 80, 69, - 69, 26, 81, 227, 2, 85, 26, 106, 82, 230, 195, 8, 72, 130, 226, 7, 79, - 212, 134, 1, 8, 87, 79, 32, 84, 72, 73, 82, 68, 151, 198, 1, 65, 6, 40, - 4, 73, 65, 78, 71, 223, 198, 8, 65, 4, 140, 242, 4, 8, 76, 69, 32, 66, - 69, 83, 73, 68, 231, 186, 12, 85, 16, 130, 201, 8, 72, 202, 1, 73, 181, - 200, 10, 2, 82, 73, 62, 128, 1, 9, 80, 79, 73, 78, 84, 73, 78, 71, 32, - 138, 1, 83, 174, 201, 8, 70, 226, 2, 72, 153, 7, 7, 84, 79, 45, 82, 73, - 71, 72, 30, 86, 65, 182, 206, 8, 67, 94, 68, 58, 77, 58, 82, 182, 1, 83, - 74, 84, 211, 172, 8, 69, 6, 242, 206, 8, 78, 158, 175, 8, 84, 159, 2, 73, - 4, 44, 5, 73, 68, 69, 32, 65, 227, 209, 8, 72, 2, 205, 147, 1, 2, 82, 67, - 210, 1, 172, 1, 5, 65, 82, 82, 79, 87, 174, 5, 66, 70, 72, 242, 3, 84, - 178, 2, 87, 214, 209, 8, 68, 210, 1, 70, 170, 7, 76, 26, 79, 34, 80, 50, - 82, 70, 83, 242, 206, 8, 67, 47, 81, 73, 26, 32, 211, 231, 17, 45, 68, - 102, 65, 138, 1, 84, 132, 2, 5, 87, 73, 84, 72, 32, 166, 211, 8, 70, 217, - 165, 10, 4, 79, 86, 69, 82, 12, 44, 5, 66, 79, 86, 69, 32, 147, 213, 8, - 78, 10, 64, 4, 83, 72, 79, 82, 138, 212, 8, 82, 182, 230, 4, 65, 55, 84, - 2, 147, 251, 18, 84, 12, 56, 7, 72, 82, 79, 85, 71, 72, 32, 53, 3, 79, - 32, 66, 6, 150, 184, 13, 83, 238, 206, 4, 76, 211, 149, 2, 88, 6, 32, 2, - 65, 82, 155, 214, 8, 76, 5, 169, 164, 12, 23, 32, 79, 86, 69, 82, 32, 82, - 73, 71, 72, 84, 87, 65, 82, 68, 83, 32, 65, 82, 82, 79, 87, 32, 36, 118, - 76, 250, 213, 8, 68, 182, 1, 80, 30, 83, 38, 84, 138, 210, 8, 77, 38, 78, - 122, 69, 150, 153, 1, 72, 171, 165, 1, 86, 4, 214, 169, 17, 65, 171, 247, - 1, 79, 8, 158, 216, 8, 65, 172, 10, 5, 79, 84, 84, 79, 77, 219, 200, 8, - 76, 30, 26, 65, 183, 176, 17, 69, 26, 48, 6, 82, 80, 79, 79, 78, 32, 191, - 210, 19, 78, 24, 80, 10, 87, 73, 84, 72, 32, 66, 65, 82, 66, 32, 173, - 241, 9, 4, 79, 86, 69, 82, 22, 40, 4, 68, 79, 87, 78, 117, 2, 85, 80, 10, - 26, 32, 167, 182, 17, 87, 8, 158, 219, 8, 66, 188, 2, 7, 65, 66, 79, 86, - 69, 32, 82, 234, 208, 8, 70, 179, 5, 84, 12, 26, 32, 179, 181, 17, 87, - 10, 60, 6, 65, 66, 79, 86, 69, 32, 146, 173, 17, 70, 179, 5, 84, 6, 42, - 76, 137, 219, 8, 4, 82, 73, 71, 72, 4, 174, 217, 8, 69, 147, 223, 4, 79, - 54, 44, 2, 82, 73, 254, 222, 8, 79, 159, 5, 87, 34, 44, 5, 65, 78, 71, - 76, 69, 179, 227, 8, 80, 30, 56, 8, 45, 72, 69, 65, 68, 69, 68, 32, 175, - 187, 17, 32, 28, 52, 5, 65, 82, 82, 79, 87, 254, 179, 17, 68, 39, 80, 25, - 11, 32, 22, 244, 223, 8, 9, 79, 86, 69, 82, 32, 82, 73, 71, 72, 22, 87, - 135, 208, 8, 84, 6, 26, 72, 195, 229, 8, 65, 4, 45, 9, 73, 84, 69, 32, - 65, 82, 82, 79, 87, 5, 225, 184, 17, 2, 32, 87, 5, 167, 249, 18, 80, 148, - 1, 252, 1, 15, 67, 79, 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, - 32, 124, 7, 76, 69, 84, 84, 69, 82, 32, 236, 1, 12, 80, 85, 78, 67, 84, - 85, 65, 84, 73, 79, 78, 32, 198, 1, 83, 172, 1, 11, 86, 79, 87, 69, 76, - 32, 83, 73, 71, 78, 32, 175, 150, 18, 68, 18, 66, 75, 22, 78, 182, 143, - 20, 76, 2, 77, 2, 80, 2, 82, 3, 84, 5, 207, 190, 19, 65, 5, 241, 207, 12, - 4, 89, 73, 78, 45, 78, 194, 1, 75, 2, 80, 178, 149, 7, 68, 130, 236, 10, - 66, 2, 70, 2, 71, 2, 72, 2, 77, 138, 15, 78, 170, 181, 1, 84, 46, 67, 2, - 83, 138, 69, 74, 2, 76, 2, 82, 2, 86, 2, 87, 2, 89, 187, 2, 65, 6, 146, - 139, 20, 72, 2, 76, 187, 2, 65, 10, 82, 84, 40, 14, 78, 89, 69, 84, 32, - 84, 72, 89, 79, 79, 77, 32, 84, 65, 43, 67, 6, 38, 65, 21, 5, 83, 72, 79, - 79, 75, 2, 171, 249, 6, 45, 5, 17, 2, 32, 67, 2, 161, 146, 15, 3, 69, 82, - 45, 8, 92, 4, 73, 71, 78, 32, 37, 15, 85, 66, 74, 79, 73, 78, 69, 68, 32, - 76, 69, 84, 84, 69, 82, 4, 254, 237, 15, 78, 231, 208, 2, 82, 4, 11, 32, - 4, 150, 136, 20, 82, 3, 89, 14, 182, 179, 16, 85, 206, 141, 1, 79, 250, - 198, 2, 65, 186, 2, 69, 3, 73, 52, 138, 1, 65, 128, 4, 11, 69, 81, 85, - 65, 76, 32, 84, 79, 32, 79, 82, 200, 1, 2, 66, 85, 42, 67, 186, 1, 79, - 210, 2, 87, 131, 248, 18, 83, 16, 40, 5, 66, 79, 86, 69, 32, 171, 4, 78, - 12, 152, 1, 7, 71, 82, 69, 65, 84, 69, 82, 110, 83, 176, 1, 19, 68, 79, - 85, 66, 76, 69, 45, 76, 73, 78, 69, 32, 69, 81, 85, 65, 76, 32, 65, 219, - 223, 15, 76, 2, 181, 5, 23, 45, 84, 72, 65, 78, 32, 65, 66, 79, 86, 69, - 32, 68, 79, 85, 66, 76, 69, 45, 76, 73, 78, 69, 6, 152, 1, 7, 73, 77, 73, - 76, 65, 82, 32, 93, 26, 76, 65, 78, 84, 69, 68, 32, 69, 81, 85, 65, 76, - 32, 65, 66, 79, 86, 69, 32, 71, 82, 69, 65, 84, 69, 82, 4, 18, 65, 59, - 79, 2, 25, 4, 66, 79, 86, 69, 2, 233, 238, 17, 2, 32, 71, 2, 227, 2, 82, - 2, 145, 2, 6, 45, 84, 72, 65, 78, 32, 4, 17, 2, 68, 32, 4, 220, 3, 5, 78, - 79, 84, 32, 65, 145, 158, 13, 11, 83, 73, 78, 71, 76, 69, 45, 76, 73, 78, - 69, 4, 141, 128, 13, 5, 84, 32, 78, 79, 84, 4, 65, 14, 76, 79, 83, 69, - 68, 32, 66, 89, 32, 67, 85, 82, 86, 69, 5, 11, 32, 2, 61, 13, 65, 66, 79, - 86, 69, 32, 83, 76, 65, 78, 84, 69, 68, 2, 17, 2, 32, 69, 2, 203, 240, - 14, 81, 18, 40, 2, 82, 32, 145, 226, 11, 2, 86, 69, 16, 114, 65, 48, 16, - 83, 76, 65, 78, 84, 69, 68, 32, 69, 81, 85, 65, 76, 32, 84, 79, 246, 252, - 12, 69, 131, 237, 4, 71, 2, 161, 186, 9, 7, 80, 80, 82, 79, 88, 73, 77, - 9, 49, 10, 32, 87, 73, 84, 72, 32, 68, 79, 84, 32, 6, 26, 65, 167, 205, - 11, 73, 4, 25, 4, 66, 79, 86, 69, 5, 231, 171, 18, 32, 6, 25, 4, 73, 84, - 72, 32, 6, 66, 67, 40, 8, 81, 85, 69, 83, 84, 73, 79, 78, 171, 173, 19, - 68, 2, 253, 203, 11, 5, 73, 82, 67, 76, 69, 2, 17, 2, 32, 77, 2, 17, 2, - 65, 82, 2, 179, 128, 19, 75, 136, 11, 190, 1, 71, 186, 5, 77, 166, 7, 78, - 156, 65, 2, 80, 83, 20, 3, 83, 85, 32, 194, 216, 15, 82, 136, 35, 11, 86, - 82, 69, 32, 84, 79, 85, 82, 78, 79, 73, 214, 59, 79, 190, 221, 1, 90, - 191, 84, 66, 44, 26, 65, 57, 2, 72, 84, 2, 233, 169, 9, 9, 84, 85, 82, - 69, 32, 79, 80, 69, 78, 42, 38, 32, 137, 4, 4, 78, 73, 78, 71, 36, 146, - 1, 69, 38, 70, 126, 82, 40, 3, 76, 69, 70, 86, 83, 42, 84, 160, 200, 7, - 3, 66, 76, 85, 238, 170, 9, 87, 254, 41, 86, 226, 78, 71, 219, 69, 67, 2, - 193, 225, 17, 4, 73, 71, 72, 84, 8, 94, 73, 205, 175, 18, 17, 79, 85, 82, - 32, 80, 79, 73, 78, 84, 69, 68, 32, 66, 76, 65, 67, 75, 4, 213, 221, 17, - 2, 86, 69, 4, 36, 3, 73, 71, 72, 187, 152, 18, 65, 2, 245, 241, 1, 16, - 84, 32, 84, 79, 82, 84, 79, 73, 83, 69, 32, 83, 72, 69, 76, 76, 6, 246, - 252, 16, 72, 254, 97, 65, 43, 73, 4, 144, 170, 16, 2, 87, 69, 21, 3, 72, - 82, 69, 7, 29, 5, 32, 77, 79, 79, 68, 5, 143, 151, 8, 32, 138, 1, 80, 3, - 66, 85, 32, 253, 158, 8, 11, 73, 84, 69, 68, 32, 76, 73, 65, 66, 73, 76, - 136, 1, 128, 1, 7, 76, 69, 84, 84, 69, 82, 32, 222, 1, 83, 200, 2, 5, 86, - 79, 87, 69, 76, 206, 212, 12, 69, 246, 198, 4, 81, 223, 96, 68, 60, 170, - 1, 71, 250, 140, 6, 84, 234, 231, 8, 89, 186, 136, 1, 78, 246, 173, 3, - 83, 82, 66, 2, 67, 2, 68, 2, 74, 2, 75, 2, 80, 138, 69, 72, 2, 76, 2, 77, - 2, 82, 3, 87, 6, 254, 166, 18, 89, 230, 201, 1, 72, 187, 2, 65, 32, 108, - 4, 73, 71, 78, 32, 128, 1, 12, 77, 65, 76, 76, 32, 76, 69, 84, 84, 69, - 82, 32, 169, 251, 6, 2, 85, 66, 8, 72, 3, 75, 69, 77, 0, 3, 77, 85, 75, - 32, 2, 83, 65, 155, 166, 17, 76, 2, 205, 170, 17, 3, 80, 72, 82, 2, 183, - 221, 19, 45, 18, 246, 250, 15, 78, 142, 177, 3, 65, 194, 66, 75, 2, 76, - 2, 77, 2, 80, 2, 82, 3, 84, 20, 84, 6, 32, 83, 73, 71, 78, 32, 149, 90, - 10, 45, 67, 65, 82, 82, 73, 69, 82, 32, 76, 18, 154, 212, 5, 65, 130, - 210, 11, 79, 146, 137, 2, 69, 162, 64, 73, 3, 85, 226, 8, 22, 69, 187, + 65, 76, 70, 32, 86, 69, 82, 84, 69, 88, 32, 79, 70, 32, 4, 166, 211, 22, + 77, 3, 87, 6, 17, 2, 84, 32, 6, 26, 67, 131, 207, 19, 65, 4, 238, 103, + 82, 203, 228, 17, 79, 2, 193, 188, 9, 3, 69, 82, 77, 2, 211, 174, 15, 32, + 6, 53, 11, 85, 65, 82, 84, 69, 82, 32, 77, 79, 79, 78, 7, 215, 182, 7, + 32, 246, 21, 150, 1, 67, 232, 49, 18, 69, 80, 73, 71, 82, 65, 80, 72, 73, + 67, 32, 76, 69, 84, 84, 69, 82, 32, 252, 1, 7, 76, 69, 84, 84, 69, 82, + 32, 227, 15, 83, 250, 7, 56, 8, 65, 80, 73, 84, 65, 76, 32, 76, 191, 137, + 21, 82, 248, 7, 76, 6, 69, 84, 84, 69, 82, 32, 177, 48, 8, 73, 71, 65, + 84, 85, 82, 69, 32, 244, 7, 158, 2, 65, 182, 3, 66, 238, 1, 67, 158, 2, + 68, 190, 2, 69, 230, 2, 70, 82, 71, 194, 1, 72, 150, 1, 73, 158, 2, 74, + 118, 75, 126, 76, 186, 2, 77, 114, 78, 134, 2, 79, 198, 2, 80, 134, 1, + 81, 62, 82, 162, 3, 83, 210, 3, 84, 162, 3, 85, 242, 1, 86, 146, 1, 87, + 118, 88, 50, 89, 167, 1, 90, 95, 172, 1, 6, 32, 87, 73, 84, 72, 32, 190, + 1, 69, 226, 71, 78, 192, 223, 14, 6, 70, 82, 73, 67, 65, 78, 230, 193, 3, + 76, 130, 188, 2, 86, 250, 164, 1, 65, 2, 79, 2, 85, 3, 89, 68, 154, 1, + 84, 190, 69, 66, 34, 67, 34, 68, 108, 3, 82, 73, 78, 178, 40, 77, 198, + 79, 72, 194, 1, 79, 150, 11, 71, 158, 2, 65, 170, 187, 3, 73, 175, 145, + 17, 83, 4, 162, 87, 79, 203, 210, 19, 73, 7, 33, 6, 32, 87, 73, 84, 72, + 32, 4, 134, 205, 1, 65, 187, 215, 3, 77, 31, 92, 6, 32, 87, 73, 84, 72, + 32, 88, 6, 65, 82, 82, 69, 68, 32, 206, 74, 82, 231, 216, 21, 69, 14, + 238, 72, 84, 174, 67, 70, 242, 64, 76, 198, 209, 16, 68, 134, 209, 2, 72, + 135, 169, 1, 83, 10, 250, 199, 22, 65, 2, 75, 2, 77, 2, 78, 3, 86, 37, + 108, 6, 32, 87, 73, 84, 72, 32, 140, 1, 6, 76, 79, 83, 69, 68, 32, 146, + 78, 85, 222, 167, 21, 79, 139, 60, 72, 20, 94, 67, 170, 201, 1, 65, 142, + 137, 4, 80, 198, 154, 15, 72, 134, 53, 66, 178, 35, 68, 211, 80, 83, 8, + 138, 75, 69, 222, 126, 73, 159, 212, 19, 65, 6, 150, 77, 73, 45, 2, 79, + 77, 35, 76, 6, 32, 87, 73, 84, 72, 32, 182, 1, 90, 25, 6, 79, 85, 66, 76, + 69, 32, 24, 82, 83, 242, 15, 67, 182, 52, 84, 158, 132, 1, 76, 198, 209, + 16, 68, 135, 209, 2, 72, 8, 92, 13, 77, 65, 76, 76, 32, 76, 69, 84, 84, + 69, 82, 32, 90, 154, 153, 1, 72, 163, 250, 20, 84, 5, 233, 82, 2, 32, 87, + 4, 154, 82, 87, 227, 241, 10, 84, 93, 104, 6, 32, 87, 73, 84, 72, 32, + 208, 1, 2, 90, 72, 222, 85, 71, 130, 212, 17, 84, 202, 149, 4, 83, 63, + 78, 72, 154, 1, 66, 246, 82, 67, 158, 2, 68, 226, 17, 84, 250, 23, 77, + 250, 1, 86, 202, 52, 72, 194, 1, 79, 150, 11, 71, 158, 2, 65, 170, 187, + 3, 73, 175, 145, 17, 83, 4, 128, 65, 5, 69, 78, 84, 32, 84, 135, 191, 4, + 82, 7, 11, 32, 4, 234, 79, 87, 223, 8, 82, 9, 33, 6, 32, 87, 73, 84, 72, + 32, 6, 230, 230, 20, 72, 182, 88, 68, 211, 80, 83, 35, 76, 6, 32, 87, 73, + 84, 72, 32, 182, 91, 76, 246, 137, 19, 65, 143, 215, 2, 72, 20, 154, 94, + 67, 130, 100, 65, 230, 187, 3, 66, 214, 27, 77, 234, 170, 4, 79, 178, + 161, 11, 72, 182, 88, 68, 211, 80, 83, 29, 80, 6, 32, 87, 73, 84, 72, 32, + 230, 141, 1, 65, 158, 166, 8, 87, 179, 184, 12, 69, 20, 182, 92, 66, 34, + 67, 46, 68, 166, 135, 20, 72, 135, 169, 1, 83, 59, 80, 6, 32, 87, 73, 84, + 72, 32, 248, 98, 2, 78, 83, 210, 180, 21, 79, 207, 36, 83, 40, 138, 1, + 68, 150, 94, 67, 242, 1, 77, 142, 1, 84, 186, 78, 72, 194, 1, 79, 150, + 11, 71, 158, 2, 65, 170, 187, 3, 73, 62, 66, 243, 144, 17, 83, 10, 22, + 79, 179, 94, 73, 6, 166, 136, 1, 85, 151, 141, 19, 84, 11, 33, 6, 32, 87, + 73, 84, 72, 32, 8, 42, 67, 186, 205, 18, 84, 203, 188, 3, 83, 4, 234, + 189, 1, 73, 167, 240, 3, 82, 25, 33, 6, 32, 87, 73, 84, 72, 32, 22, 162, + 100, 67, 34, 68, 50, 83, 242, 87, 65, 138, 1, 76, 154, 129, 8, 79, 179, + 161, 11, 72, 41, 60, 6, 32, 87, 73, 84, 72, 32, 134, 105, 65, 155, 207, + 21, 74, 32, 144, 1, 2, 68, 79, 32, 7, 77, 73, 68, 68, 76, 69, 32, 38, 83, + 174, 2, 67, 198, 102, 72, 134, 81, 65, 138, 1, 76, 206, 241, 3, 66, 187, + 157, 13, 84, 6, 218, 102, 84, 195, 192, 4, 85, 4, 162, 202, 18, 84, 143, + 156, 3, 68, 4, 214, 2, 77, 255, 131, 22, 84, 19, 44, 6, 32, 87, 73, 84, + 72, 32, 147, 106, 73, 10, 162, 185, 1, 65, 206, 210, 16, 68, 194, 61, 84, + 199, 147, 2, 72, 33, 48, 6, 32, 87, 73, 84, 72, 32, 131, 181, 22, 74, 28, + 102, 67, 44, 2, 83, 77, 242, 107, 76, 146, 73, 71, 158, 2, 65, 102, 68, + 190, 129, 8, 79, 239, 141, 9, 84, 6, 182, 149, 1, 69, 22, 73, 219, 246, + 19, 65, 2, 209, 171, 11, 10, 65, 76, 76, 32, 76, 69, 84, 84, 69, 82, 103, + 108, 6, 32, 87, 73, 84, 72, 32, 194, 115, 76, 214, 184, 4, 80, 242, 185, + 9, 77, 190, 204, 7, 73, 2, 79, 3, 85, 86, 144, 1, 2, 76, 79, 34, 77, 158, + 108, 67, 94, 68, 154, 1, 72, 170, 1, 79, 38, 83, 66, 84, 106, 86, 158, + 65, 71, 158, 2, 65, 170, 187, 3, 73, 63, 66, 4, 154, 111, 78, 135, 194, + 21, 79, 8, 150, 111, 65, 251, 184, 4, 73, 27, 40, 6, 32, 87, 73, 84, 72, + 32, 67, 72, 14, 134, 116, 70, 34, 83, 202, 63, 65, 210, 163, 19, 72, 183, + 88, 68, 10, 186, 116, 65, 111, 79, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, + 178, 119, 68, 39, 83, 49, 94, 32, 216, 1, 8, 69, 86, 69, 82, 83, 69, 68, + 32, 196, 126, 3, 85, 77, 32, 143, 170, 4, 65, 30, 40, 5, 87, 73, 84, 72, + 32, 255, 127, 82, 28, 102, 76, 38, 84, 134, 88, 67, 182, 33, 68, 142, 55, + 65, 170, 187, 3, 73, 250, 198, 4, 79, 183, 202, 12, 83, 4, 250, 177, 1, + 73, 175, 130, 4, 79, 4, 226, 140, 20, 73, 211, 61, 65, 12, 162, 125, 72, + 222, 182, 4, 79, 228, 152, 8, 4, 83, 67, 82, 85, 170, 204, 5, 67, 234, + 147, 3, 69, 3, 85, 53, 132, 1, 6, 32, 87, 73, 84, 72, 32, 138, 1, 67, 84, + 5, 77, 65, 76, 76, 32, 156, 129, 1, 2, 65, 76, 242, 1, 72, 153, 2, 2, 73, + 71, 32, 86, 67, 138, 126, 65, 118, 68, 138, 1, 83, 174, 1, 86, 206, 174, + 8, 79, 179, 161, 11, 72, 10, 226, 126, 65, 234, 12, 69, 82, 79, 131, 34, + 73, 8, 44, 5, 82, 73, 80, 84, 32, 131, 170, 17, 72, 6, 166, 129, 6, 82, + 167, 168, 16, 71, 4, 236, 237, 19, 11, 81, 32, 87, 73, 84, 72, 32, 72, + 79, 79, 75, 169, 251, 1, 7, 67, 65, 80, 73, 84, 65, 76, 61, 140, 1, 6, + 32, 87, 73, 84, 72, 32, 172, 1, 6, 85, 82, 78, 69, 68, 32, 192, 138, 1, + 2, 72, 79, 144, 2, 2, 79, 78, 74, 82, 235, 152, 21, 90, 22, 82, 67, 54, + 68, 222, 170, 1, 76, 178, 136, 4, 82, 154, 154, 15, 72, 135, 169, 1, 83, + 8, 246, 135, 1, 69, 22, 73, 62, 79, 159, 246, 19, 65, 6, 234, 159, 1, 73, + 195, 220, 16, 79, 20, 202, 45, 73, 162, 98, 67, 206, 192, 2, 65, 202, + 213, 18, 72, 2, 75, 2, 76, 2, 77, 2, 84, 3, 86, 83, 26, 32, 255, 210, 3, + 80, 78, 44, 5, 87, 73, 84, 72, 32, 215, 128, 21, 66, 76, 242, 148, 1, 67, + 74, 68, 150, 2, 72, 218, 1, 77, 134, 1, 78, 38, 79, 142, 1, 84, 138, 10, + 71, 158, 2, 65, 170, 187, 3, 73, 62, 66, 182, 136, 15, 82, 191, 136, 2, + 83, 23, 88, 6, 32, 87, 73, 84, 72, 32, 130, 157, 1, 73, 66, 79, 254, 244, + 19, 69, 151, 144, 1, 89, 8, 250, 155, 1, 68, 146, 154, 17, 84, 199, 147, + 2, 72, 19, 48, 6, 32, 87, 73, 84, 72, 32, 255, 213, 7, 89, 14, 166, 162, + 1, 67, 18, 68, 70, 71, 158, 2, 65, 211, 163, 19, 72, 7, 169, 158, 1, 7, + 32, 87, 73, 84, 72, 32, 68, 29, 48, 6, 32, 87, 73, 84, 72, 32, 183, 237, + 17, 79, 24, 222, 106, 76, 166, 54, 67, 18, 68, 70, 71, 22, 72, 138, 2, + 65, 186, 215, 3, 77, 214, 184, 13, 84, 203, 188, 3, 83, 25, 33, 6, 32, + 87, 73, 84, 72, 32, 22, 186, 66, 67, 166, 96, 65, 102, 68, 38, 76, 34, + 83, 230, 135, 4, 80, 199, 154, 15, 72, 4, 206, 150, 11, 73, 187, 241, 10, + 79, 12, 128, 1, 5, 65, 82, 67, 72, 65, 30, 73, 64, 9, 82, 69, 86, 69, 82, + 83, 69, 68, 32, 153, 148, 11, 7, 83, 73, 68, 69, 87, 65, 89, 2, 217, 184, + 14, 2, 73, 67, 4, 244, 120, 5, 78, 86, 69, 82, 84, 221, 142, 15, 3, 32, + 76, 79, 4, 214, 156, 22, 70, 3, 80, 150, 1, 254, 3, 65, 36, 2, 66, 73, + 152, 1, 12, 71, 76, 79, 84, 84, 65, 76, 32, 83, 84, 79, 80, 72, 21, 73, + 78, 86, 69, 82, 84, 69, 68, 32, 71, 76, 79, 84, 84, 65, 76, 32, 83, 84, + 79, 80, 72, 2, 82, 69, 198, 1, 83, 182, 35, 87, 140, 54, 27, 80, 72, 65, + 82, 89, 78, 71, 69, 65, 76, 32, 86, 79, 73, 67, 69, 68, 32, 70, 82, 73, + 67, 65, 84, 73, 86, 69, 156, 140, 4, 2, 68, 69, 220, 5, 2, 76, 65, 182, + 132, 1, 84, 220, 243, 14, 20, 86, 79, 73, 67, 69, 68, 32, 76, 65, 82, 89, + 78, 71, 69, 65, 76, 32, 83, 80, 73, 135, 120, 89, 4, 214, 218, 4, 76, + 131, 238, 16, 73, 6, 76, 7, 76, 65, 66, 73, 65, 76, 32, 29, 8, 68, 69, + 78, 84, 65, 76, 32, 80, 4, 26, 80, 251, 238, 4, 67, 2, 245, 212, 16, 6, + 69, 82, 67, 85, 83, 83, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 218, 161, + 19, 68, 131, 197, 2, 83, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 182, 162, + 5, 67, 223, 195, 16, 83, 8, 104, 7, 86, 69, 82, 83, 69, 68, 32, 149, 153, + 5, 13, 84, 82, 79, 70, 76, 69, 88, 32, 67, 76, 73, 67, 75, 4, 248, 94, 2, + 69, 83, 221, 145, 5, 12, 71, 76, 79, 84, 84, 65, 76, 32, 83, 84, 79, 80, + 104, 176, 1, 13, 77, 65, 76, 76, 32, 67, 65, 80, 73, 84, 65, 76, 32, 152, + 128, 1, 10, 84, 82, 69, 84, 67, 72, 69, 68, 32, 67, 173, 255, 19, 10, 73, + 78, 79, 76, 79, 71, 73, 67, 65, 76, 98, 222, 1, 66, 66, 69, 30, 71, 74, + 73, 54, 76, 74, 79, 42, 82, 154, 1, 84, 150, 205, 21, 65, 162, 64, 67, 2, + 68, 2, 70, 2, 72, 2, 74, 2, 75, 2, 77, 2, 78, 2, 80, 2, 81, 2, 83, 2, 85, + 2, 86, 2, 87, 2, 89, 3, 90, 7, 33, 6, 65, 82, 82, 69, 68, 32, 4, 238, + 144, 22, 66, 3, 69, 7, 194, 143, 22, 84, 3, 90, 7, 33, 6, 32, 87, 73, 84, + 72, 32, 4, 206, 156, 5, 80, 199, 154, 15, 72, 7, 133, 85, 9, 78, 86, 69, + 82, 84, 69, 68, 32, 82, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 190, 158, 9, + 66, 223, 192, 12, 83, 9, 182, 106, 80, 190, 164, 21, 69, 3, 85, 13, 88, + 6, 32, 87, 73, 84, 72, 32, 32, 8, 69, 86, 69, 82, 83, 69, 68, 32, 251, + 252, 21, 85, 4, 134, 135, 5, 82, 167, 19, 80, 4, 206, 141, 22, 78, 3, 82, + 13, 33, 6, 85, 82, 78, 69, 68, 32, 10, 142, 141, 22, 69, 2, 71, 2, 75, 2, + 77, 3, 82, 218, 12, 136, 1, 5, 77, 65, 76, 76, 32, 149, 146, 1, 22, 85, + 66, 83, 67, 82, 73, 80, 84, 32, 83, 77, 65, 76, 76, 32, 76, 69, 84, 84, + 69, 82, 32, 174, 12, 76, 15, 67, 65, 80, 73, 84, 65, 76, 32, 76, 69, 84, + 84, 69, 82, 32, 31, 76, 4, 206, 230, 5, 73, 3, 85, 170, 12, 80, 6, 69, + 84, 84, 69, 82, 32, 141, 143, 1, 8, 73, 71, 65, 84, 85, 82, 69, 32, 150, + 12, 182, 2, 65, 222, 5, 66, 226, 4, 67, 162, 6, 68, 214, 6, 69, 182, 9, + 70, 214, 1, 71, 178, 2, 72, 174, 3, 73, 218, 7, 74, 182, 1, 75, 178, 2, + 76, 246, 6, 77, 178, 2, 78, 202, 3, 79, 206, 9, 80, 194, 4, 81, 190, 1, + 82, 194, 9, 83, 186, 11, 84, 178, 16, 85, 158, 10, 86, 186, 3, 87, 126, + 88, 226, 2, 89, 155, 3, 90, 101, 118, 32, 226, 3, 69, 86, 78, 176, 134, + 5, 4, 76, 80, 72, 65, 246, 214, 15, 86, 250, 164, 1, 65, 2, 79, 2, 85, 3, + 89, 72, 88, 5, 87, 73, 84, 72, 32, 129, 165, 6, 11, 82, 69, 86, 69, 82, + 83, 69, 68, 45, 83, 67, 70, 146, 1, 66, 34, 67, 34, 68, 54, 82, 234, 40, + 77, 198, 79, 72, 194, 1, 79, 150, 11, 71, 158, 2, 65, 170, 187, 3, 73, + 230, 212, 13, 84, 203, 188, 3, 83, 12, 185, 120, 4, 82, 69, 86, 69, 14, + 250, 63, 73, 211, 156, 20, 65, 12, 22, 79, 139, 64, 73, 8, 202, 64, 84, + 247, 16, 85, 10, 26, 73, 199, 144, 5, 69, 8, 26, 78, 227, 203, 4, 71, 6, + 17, 2, 71, 32, 6, 136, 66, 4, 65, 66, 79, 86, 139, 156, 19, 66, 9, 33, 6, + 32, 87, 73, 84, 72, 32, 6, 222, 131, 1, 71, 158, 2, 65, 187, 215, 3, 77, + 2, 253, 131, 11, 7, 71, 76, 73, 67, 65, 78, 65, 73, 148, 1, 6, 32, 87, + 73, 84, 72, 32, 130, 1, 65, 128, 2, 11, 76, 65, 67, 75, 76, 69, 84, 84, + 69, 82, 32, 38, 82, 232, 25, 2, 69, 84, 195, 204, 4, 79, 18, 110, 84, + 174, 67, 70, 242, 64, 76, 194, 242, 3, 77, 198, 21, 80, 194, 201, 12, 68, + 134, 209, 2, 72, 135, 169, 1, 83, 2, 235, 12, 79, 38, 68, 5, 82, 82, 69, + 68, 32, 133, 255, 4, 6, 83, 69, 76, 73, 78, 69, 36, 130, 1, 67, 34, 79, + 162, 168, 3, 65, 154, 190, 1, 84, 202, 10, 72, 2, 77, 250, 139, 15, 69, + 242, 128, 2, 75, 2, 78, 2, 86, 3, 87, 4, 254, 103, 76, 179, 130, 21, 72, + 7, 187, 247, 4, 80, 6, 190, 136, 5, 79, 151, 245, 16, 69, 2, 233, 246, + 10, 4, 79, 75, 69, 78, 57, 112, 6, 32, 87, 73, 84, 72, 32, 200, 2, 2, 72, + 73, 120, 6, 76, 79, 83, 69, 68, 32, 158, 1, 85, 223, 167, 21, 79, 30, + 114, 67, 92, 2, 76, 79, 74, 82, 178, 125, 65, 142, 137, 4, 80, 198, 154, + 15, 72, 134, 53, 66, 178, 35, 68, 211, 80, 83, 10, 54, 69, 222, 126, 73, + 230, 168, 7, 85, 187, 171, 12, 65, 4, 225, 57, 5, 68, 73, 76, 76, 65, 4, + 44, 5, 79, 80, 69, 68, 32, 247, 207, 14, 87, 2, 181, 91, 2, 67, 69, 4, + 132, 68, 4, 73, 71, 72, 84, 239, 194, 4, 69, 9, 33, 6, 32, 87, 73, 84, + 72, 32, 6, 40, 4, 76, 79, 87, 32, 191, 133, 5, 80, 4, 194, 119, 82, 45, + 4, 76, 69, 70, 84, 10, 34, 73, 18, 79, 195, 228, 4, 82, 2, 247, 98, 78, + 6, 26, 77, 163, 255, 4, 80, 4, 21, 3, 69, 71, 65, 5, 193, 200, 5, 8, 32, + 87, 73, 84, 72, 32, 76, 79, 4, 37, 7, 65, 84, 82, 73, 76, 76, 79, 5, 197, + 202, 13, 5, 32, 87, 73, 84, 72, 87, 82, 32, 182, 3, 45, 58, 69, 34, 79, + 174, 1, 90, 150, 235, 4, 66, 247, 244, 16, 85, 36, 172, 1, 5, 87, 73, 84, + 72, 32, 241, 62, 32, 82, 79, 84, 85, 78, 68, 65, 32, 87, 73, 84, 72, 32, + 68, 69, 83, 67, 69, 78, 68, 73, 78, 71, 32, 67, 82, 79, 83, 83, 73, 78, + 71, 34, 108, 4, 72, 79, 79, 75, 70, 83, 34, 84, 138, 34, 67, 254, 61, 77, + 202, 23, 76, 134, 136, 4, 80, 195, 201, 12, 68, 7, 29, 5, 32, 65, 78, 68, + 32, 4, 146, 128, 5, 80, 167, 184, 14, 84, 4, 162, 73, 72, 163, 250, 20, + 84, 4, 26, 79, 155, 144, 20, 65, 2, 239, 206, 20, 80, 6, 128, 80, 2, 69, + 84, 193, 166, 4, 4, 76, 69, 90, 72, 10, 130, 85, 90, 223, 248, 20, 76, + 16, 60, 6, 84, 76, 69, 83, 83, 32, 49, 5, 85, 66, 76, 69, 32, 8, 26, 74, + 179, 241, 21, 73, 7, 211, 223, 4, 32, 8, 38, 87, 170, 74, 82, 187, 167, + 10, 84, 2, 135, 165, 7, 89, 13, 11, 32, 10, 22, 87, 175, 83, 68, 2, 201, + 98, 5, 73, 84, 72, 32, 67, 123, 104, 6, 32, 87, 73, 84, 72, 32, 214, 4, + 71, 72, 2, 78, 71, 68, 2, 83, 72, 170, 1, 84, 17, 2, 90, 72, 76, 182, 1, + 67, 158, 2, 68, 110, 78, 246, 16, 84, 250, 23, 77, 250, 1, 86, 210, 3, + 70, 250, 48, 72, 194, 1, 79, 150, 11, 71, 158, 2, 65, 170, 187, 3, 73, + 62, 66, 214, 77, 82, 159, 195, 16, 83, 24, 92, 6, 69, 68, 73, 76, 76, 65, + 32, 9, 73, 82, 67, 85, 77, 70, 76, 69, 88, 131, 197, 20, 65, 5, 141, 172, + 4, 3, 32, 65, 78, 19, 11, 32, 16, 40, 4, 65, 78, 68, 32, 179, 199, 19, + 66, 14, 202, 94, 67, 178, 2, 72, 214, 12, 71, 158, 2, 65, 186, 215, 3, + 77, 182, 200, 4, 68, 163, 240, 8, 84, 12, 22, 79, 175, 108, 73, 10, 28, + 2, 84, 32, 219, 56, 85, 8, 188, 97, 5, 65, 66, 79, 86, 69, 215, 228, 18, + 66, 2, 239, 213, 14, 79, 4, 141, 188, 7, 13, 89, 80, 84, 79, 76, 79, 71, + 73, 67, 65, 76, 32, 65, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 242, 221, 4, + 67, 183, 24, 80, 15, 44, 6, 32, 87, 73, 84, 72, 32, 191, 70, 45, 10, 80, + 10, 68, 79, 85, 66, 76, 69, 32, 66, 65, 82, 242, 244, 4, 67, 22, 80, 47, + 82, 5, 233, 234, 4, 4, 32, 65, 78, 68, 7, 187, 45, 72, 15, 11, 32, 12, + 38, 82, 37, 5, 87, 73, 84, 72, 32, 2, 245, 209, 14, 4, 69, 86, 69, 82, + 10, 50, 67, 198, 243, 4, 80, 46, 82, 251, 183, 14, 84, 4, 218, 147, 8, + 85, 187, 171, 12, 65, 17, 84, 6, 32, 87, 73, 84, 72, 32, 73, 11, 69, 78, + 71, 32, 68, 73, 71, 82, 65, 80, 72, 10, 130, 221, 4, 77, 198, 21, 80, + 198, 154, 15, 72, 182, 88, 68, 211, 80, 83, 5, 241, 229, 18, 8, 32, 87, + 73, 84, 72, 32, 84, 82, 41, 76, 6, 32, 87, 73, 84, 72, 32, 120, 3, 65, + 77, 77, 18, 76, 131, 225, 21, 72, 24, 238, 3, 67, 94, 83, 166, 99, 65, + 230, 187, 3, 66, 214, 27, 77, 214, 49, 80, 150, 249, 3, 79, 178, 161, 11, + 72, 183, 88, 68, 4, 223, 40, 65, 8, 33, 6, 79, 84, 84, 65, 76, 32, 8, + 158, 138, 19, 83, 246, 216, 2, 65, 2, 73, 3, 85, 43, 156, 1, 6, 32, 87, + 73, 84, 72, 32, 240, 1, 4, 65, 76, 70, 32, 148, 77, 12, 79, 79, 75, 69, + 68, 32, 83, 67, 72, 87, 65, 32, 194, 133, 4, 69, 255, 140, 17, 86, 26, + 78, 66, 34, 67, 46, 68, 50, 83, 174, 100, 76, 134, 136, 4, 80, 199, 154, + 15, 72, 2, 137, 205, 13, 3, 82, 69, 86, 6, 238, 65, 69, 210, 34, 73, 159, + 212, 19, 65, 8, 142, 97, 73, 202, 205, 3, 69, 215, 135, 13, 79, 4, 233, + 89, 5, 84, 82, 79, 75, 69, 4, 206, 223, 21, 65, 3, 72, 79, 88, 6, 32, 87, + 73, 84, 72, 32, 142, 5, 78, 184, 1, 2, 79, 84, 150, 216, 21, 69, 3, 83, + 50, 226, 1, 67, 34, 68, 210, 1, 77, 64, 6, 79, 71, 79, 78, 69, 75, 78, + 84, 186, 78, 72, 214, 12, 71, 158, 2, 65, 170, 187, 3, 73, 62, 66, 176, + 73, 6, 83, 84, 82, 79, 75, 69, 166, 4, 82, 217, 254, 12, 7, 80, 73, 71, + 84, 65, 73, 76, 4, 226, 96, 73, 159, 212, 19, 65, 14, 18, 73, 47, 79, 4, + 181, 27, 7, 65, 69, 82, 69, 83, 73, 83, 10, 28, 2, 84, 32, 175, 41, 85, + 8, 64, 10, 65, 66, 79, 86, 69, 32, 65, 78, 68, 32, 167, 182, 19, 66, 6, + 194, 92, 71, 158, 2, 65, 143, 144, 17, 84, 4, 29, 5, 65, 67, 82, 79, 78, + 5, 177, 40, 4, 32, 65, 78, 68, 7, 237, 80, 15, 32, 65, 78, 68, 32, 68, + 79, 84, 32, 65, 66, 79, 86, 69, 32, 4, 21, 3, 73, 76, 68, 4, 187, 185, 5, + 69, 16, 46, 83, 93, 7, 86, 69, 82, 84, 69, 68, 32, 12, 29, 5, 85, 76, 65, + 82, 32, 12, 250, 216, 21, 68, 2, 70, 2, 71, 2, 82, 2, 83, 3, 84, 4, 196, + 247, 17, 2, 65, 76, 167, 202, 3, 79, 6, 254, 226, 4, 65, 153, 181, 6, 5, + 73, 70, 73, 69, 68, 13, 33, 6, 32, 87, 73, 84, 72, 32, 10, 94, 67, 132, + 206, 4, 13, 68, 79, 84, 32, 65, 66, 79, 86, 69, 32, 65, 78, 68, 219, 216, + 16, 83, 6, 198, 90, 73, 166, 240, 3, 82, 251, 227, 15, 65, 29, 48, 6, 32, + 87, 73, 84, 72, 32, 191, 211, 21, 82, 24, 98, 67, 34, 68, 50, 83, 242, + 87, 65, 138, 1, 76, 134, 136, 4, 80, 150, 249, 3, 79, 179, 161, 11, 72, + 4, 174, 54, 69, 239, 246, 19, 65, 6, 182, 78, 73, 238, 212, 3, 69, 247, + 212, 4, 79, 4, 29, 5, 84, 82, 79, 75, 69, 5, 141, 28, 6, 32, 65, 78, 68, + 32, 68, 85, 136, 1, 6, 32, 87, 73, 84, 72, 32, 214, 3, 65, 38, 69, 48, 5, + 79, 78, 71, 32, 83, 142, 1, 85, 238, 199, 4, 83, 2, 90, 207, 133, 17, 74, + 50, 178, 1, 66, 46, 67, 56, 2, 68, 79, 100, 3, 77, 73, 68, 158, 2, 72, + 134, 81, 65, 138, 1, 76, 242, 241, 3, 73, 162, 1, 82, 198, 5, 70, 178, + 15, 80, 130, 135, 13, 84, 203, 188, 3, 83, 6, 172, 75, 3, 69, 76, 84, + 175, 205, 20, 65, 8, 170, 50, 69, 22, 73, 162, 203, 7, 85, 187, 171, 12, + 65, 8, 38, 84, 25, 5, 85, 66, 76, 69, 32, 4, 145, 29, 2, 32, 66, 4, 138, + 199, 4, 77, 143, 229, 15, 66, 8, 40, 4, 68, 76, 69, 32, 191, 216, 4, 45, + 6, 254, 226, 17, 84, 194, 155, 3, 82, 79, 68, 4, 129, 218, 4, 4, 77, 66, + 68, 65, 8, 226, 209, 4, 90, 189, 169, 13, 3, 78, 73, 83, 11, 33, 6, 32, + 87, 73, 84, 72, 32, 8, 42, 68, 34, 72, 221, 23, 3, 84, 79, 80, 4, 186, + 71, 73, 251, 133, 20, 79, 2, 177, 209, 5, 2, 73, 71, 4, 228, 208, 3, 4, + 78, 65, 84, 69, 211, 252, 17, 77, 27, 56, 6, 32, 87, 73, 84, 72, 32, 102, + 73, 143, 187, 21, 85, 16, 246, 79, 65, 218, 240, 3, 67, 242, 2, 77, 198, + 21, 80, 194, 201, 12, 68, 194, 61, 84, 199, 147, 2, 72, 6, 25, 4, 68, 68, + 76, 69, 6, 76, 7, 45, 87, 69, 76, 83, 72, 32, 221, 203, 17, 6, 32, 83, + 67, 79, 84, 83, 4, 166, 191, 20, 76, 211, 139, 1, 86, 49, 58, 32, 200, 2, + 2, 71, 32, 250, 182, 21, 85, 219, 16, 74, 40, 88, 5, 87, 73, 84, 72, 32, + 201, 199, 6, 11, 80, 82, 69, 67, 69, 68, 69, 68, 32, 66, 89, 38, 118, 67, + 74, 76, 238, 52, 77, 166, 20, 71, 158, 2, 65, 102, 68, 170, 136, 4, 80, + 46, 82, 234, 248, 3, 79, 239, 141, 9, 84, 10, 226, 41, 69, 22, 73, 226, + 146, 4, 82, 194, 184, 3, 85, 187, 171, 12, 65, 6, 190, 76, 73, 174, 244, + 3, 79, 207, 17, 69, 2, 25, 4, 87, 73, 84, 72, 2, 173, 156, 18, 5, 32, 84, + 73, 76, 68, 123, 128, 1, 6, 32, 87, 73, 84, 72, 32, 246, 6, 73, 2, 85, + 22, 76, 52, 4, 80, 69, 78, 32, 160, 8, 3, 77, 69, 71, 175, 182, 21, 79, + 88, 150, 1, 67, 94, 68, 154, 1, 72, 40, 2, 76, 79, 86, 77, 46, 79, 38, + 83, 66, 84, 106, 86, 158, 65, 71, 158, 2, 65, 170, 187, 3, 73, 62, 66, + 215, 77, 82, 16, 42, 73, 154, 241, 7, 85, 187, 171, 12, 65, 12, 157, 56, + 8, 82, 67, 85, 77, 70, 76, 69, 88, 14, 18, 73, 47, 79, 4, 129, 17, 7, 65, + 69, 82, 69, 83, 73, 83, 10, 22, 84, 255, 53, 85, 6, 11, 32, 6, 176, 16, + 5, 65, 66, 79, 86, 69, 243, 141, 19, 66, 14, 11, 79, 14, 190, 54, 82, + 219, 92, 79, 6, 66, 78, 176, 136, 13, 6, 87, 32, 82, 73, 78, 71, 215, + 185, 8, 79, 2, 151, 24, 71, 6, 11, 65, 6, 189, 2, 4, 67, 82, 79, 78, 4, + 213, 14, 5, 71, 79, 78, 69, 75, 4, 25, 4, 84, 82, 79, 75, 4, 11, 69, 5, + 213, 56, 2, 32, 65, 8, 25, 4, 73, 76, 68, 69, 9, 29, 5, 32, 65, 78, 68, + 32, 6, 254, 53, 68, 230, 13, 65, 187, 215, 3, 77, 6, 81, 18, 69, 82, 84, + 73, 67, 65, 76, 32, 76, 73, 78, 69, 32, 66, 69, 76, 79, 87, 7, 137, 50, + 4, 32, 65, 78, 68, 5, 211, 185, 4, 32, 2, 189, 190, 10, 8, 68, 32, 80, + 79, 76, 73, 83, 72, 16, 26, 79, 199, 194, 4, 69, 13, 48, 6, 32, 87, 73, + 84, 72, 32, 255, 189, 21, 69, 8, 142, 63, 71, 158, 2, 65, 186, 137, 4, + 82, 159, 195, 16, 83, 35, 44, 6, 32, 87, 73, 84, 72, 32, 179, 1, 72, 18, + 86, 70, 34, 83, 202, 63, 65, 202, 243, 3, 77, 198, 21, 80, 198, 154, 15, + 72, 183, 88, 68, 2, 245, 253, 14, 3, 76, 79, 85, 6, 150, 33, 84, 209, + 226, 12, 6, 81, 85, 73, 82, 82, 69, 14, 26, 65, 94, 73, 19, 79, 2, 221, + 239, 5, 18, 82, 89, 78, 71, 69, 65, 76, 32, 86, 79, 73, 67, 69, 68, 32, + 70, 82, 73, 5, 135, 31, 32, 8, 41, 8, 78, 79, 84, 89, 80, 73, 67, 32, 8, + 228, 178, 15, 9, 68, 73, 80, 72, 84, 72, 79, 78, 71, 220, 184, 1, 8, 82, + 79, 85, 78, 68, 84, 79, 80, 188, 224, 2, 9, 65, 32, 87, 73, 84, 72, 32, + 83, 87, 159, 237, 1, 84, 15, 48, 6, 32, 87, 73, 84, 72, 32, 131, 179, 4, + 80, 10, 58, 68, 16, 4, 72, 79, 79, 75, 22, 83, 171, 196, 4, 80, 2, 215, + 49, 73, 5, 211, 252, 18, 32, 2, 145, 29, 6, 84, 82, 79, 75, 69, 32, 91, + 90, 32, 252, 5, 8, 69, 86, 69, 82, 83, 69, 68, 32, 176, 2, 2, 85, 77, + 155, 170, 4, 65, 52, 56, 6, 82, 79, 84, 85, 78, 68, 93, 4, 87, 73, 84, + 72, 4, 11, 65, 5, 25, 4, 32, 87, 73, 84, 2, 11, 72, 2, 17, 2, 32, 76, 2, + 207, 188, 20, 79, 48, 26, 32, 155, 245, 15, 79, 46, 166, 1, 67, 50, 68, + 200, 1, 8, 70, 73, 83, 72, 72, 79, 79, 75, 66, 76, 62, 84, 138, 30, 77, + 194, 22, 65, 170, 187, 3, 73, 230, 77, 80, 150, 249, 3, 79, 183, 202, 12, + 83, 6, 170, 21, 69, 246, 146, 4, 82, 251, 227, 15, 65, 8, 11, 79, 8, 24, + 2, 84, 32, 111, 85, 6, 26, 66, 175, 182, 20, 65, 4, 25, 4, 69, 76, 79, + 87, 5, 29, 5, 32, 65, 78, 68, 32, 2, 195, 141, 4, 77, 2, 21, 3, 66, 76, + 69, 2, 11, 32, 2, 183, 51, 71, 7, 29, 5, 32, 65, 78, 68, 32, 4, 234, 168, + 4, 77, 199, 21, 80, 6, 150, 54, 73, 174, 130, 4, 79, 205, 163, 2, 3, 69, + 70, 84, 6, 140, 43, 3, 65, 73, 76, 219, 229, 18, 73, 30, 154, 1, 72, 40, + 6, 79, 80, 69, 78, 32, 69, 72, 3, 83, 67, 82, 246, 11, 84, 210, 159, 4, + 82, 174, 130, 15, 69, 150, 90, 67, 222, 166, 1, 75, 2, 85, 3, 90, 2, 11, + 65, 2, 153, 174, 10, 2, 76, 70, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 234, + 187, 4, 82, 155, 154, 15, 72, 4, 178, 173, 4, 73, 159, 161, 8, 85, 5, 11, + 32, 2, 11, 82, 2, 185, 201, 17, 3, 79, 84, 85, 95, 108, 6, 32, 87, 73, + 84, 72, 32, 218, 4, 65, 66, 67, 226, 1, 72, 34, 73, 158, 2, 84, 230, 162, + 4, 80, 59, 81, 40, 110, 65, 34, 67, 86, 68, 138, 1, 83, 174, 1, 86, 238, + 21, 77, 206, 159, 4, 80, 150, 249, 3, 79, 179, 161, 11, 72, 4, 205, 1, 4, + 67, 85, 84, 69, 12, 58, 65, 234, 12, 69, 82, 79, 130, 34, 73, 231, 168, + 7, 85, 4, 113, 3, 82, 79, 78, 8, 32, 3, 79, 84, 32, 215, 36, 73, 6, 26, + 66, 135, 174, 20, 65, 4, 25, 4, 69, 76, 79, 87, 5, 11, 32, 2, 229, 169, + 20, 3, 65, 78, 68, 4, 22, 72, 135, 47, 87, 2, 21, 3, 79, 82, 84, 2, 17, + 2, 32, 83, 2, 11, 84, 2, 21, 3, 82, 79, 75, 2, 11, 69, 2, 17, 2, 32, 79, + 2, 253, 154, 20, 4, 86, 69, 82, 76, 2, 37, 7, 69, 82, 84, 73, 67, 65, 76, + 2, 137, 45, 2, 32, 76, 4, 46, 76, 221, 158, 20, 5, 75, 72, 65, 32, 89, 2, + 183, 15, 84, 18, 48, 3, 72, 87, 65, 97, 5, 82, 73, 80, 84, 32, 11, 33, 6, + 32, 87, 73, 84, 72, 32, 8, 182, 40, 71, 158, 2, 65, 186, 137, 4, 82, 155, + 154, 15, 72, 8, 26, 71, 171, 254, 4, 82, 5, 209, 154, 4, 7, 32, 87, 73, + 84, 72, 32, 67, 2, 253, 166, 17, 3, 65, 82, 80, 14, 48, 7, 68, 69, 87, + 65, 89, 83, 32, 199, 1, 71, 12, 110, 79, 56, 4, 84, 85, 82, 78, 132, 130, + 11, 11, 68, 73, 65, 69, 82, 69, 83, 73, 90, 69, 68, 159, 162, 10, 85, 7, + 26, 80, 163, 128, 5, 32, 2, 249, 163, 10, 2, 69, 78, 2, 197, 191, 13, 2, + 69, 68, 2, 229, 164, 17, 4, 77, 79, 73, 68, 8, 76, 8, 82, 69, 84, 67, 72, + 69, 68, 32, 197, 158, 10, 5, 73, 82, 82, 85, 80, 6, 34, 67, 2, 84, 239, + 162, 21, 73, 2, 11, 45, 2, 147, 157, 4, 72, 165, 1, 196, 2, 6, 32, 87, + 73, 84, 72, 32, 216, 2, 2, 69, 83, 70, 72, 184, 2, 15, 76, 32, 68, 73, + 71, 82, 65, 80, 72, 32, 87, 73, 84, 72, 32, 98, 79, 102, 82, 52, 9, 83, + 32, 68, 73, 71, 82, 65, 80, 72, 66, 85, 168, 146, 4, 6, 45, 84, 72, 69, + 84, 65, 166, 7, 67, 208, 160, 11, 9, 65, 73, 76, 76, 69, 83, 83, 32, 80, + 219, 221, 5, 90, 34, 98, 67, 182, 1, 68, 218, 10, 77, 202, 23, 76, 134, + 253, 3, 72, 130, 11, 80, 46, 82, 159, 195, 16, 83, 10, 58, 69, 22, 73, + 62, 79, 230, 202, 7, 85, 187, 171, 12, 65, 2, 211, 219, 12, 68, 2, 37, 7, + 82, 67, 85, 77, 70, 76, 69, 2, 143, 233, 18, 88, 2, 17, 2, 77, 77, 2, + 231, 232, 18, 65, 8, 32, 2, 73, 65, 207, 243, 16, 79, 4, 158, 23, 71, + 167, 7, 69, 8, 21, 3, 72, 32, 68, 8, 245, 168, 4, 6, 73, 71, 82, 65, 80, + 72, 10, 88, 12, 32, 87, 73, 84, 72, 32, 83, 84, 82, 73, 75, 69, 40, 4, + 69, 84, 65, 32, 35, 79, 2, 245, 232, 16, 5, 84, 72, 82, 79, 85, 2, 241, + 21, 4, 87, 73, 84, 72, 6, 17, 2, 82, 78, 7, 41, 8, 32, 87, 73, 84, 72, + 32, 83, 84, 4, 25, 4, 82, 79, 75, 69, 5, 11, 32, 2, 229, 232, 3, 6, 84, + 72, 82, 79, 85, 71, 4, 188, 146, 4, 15, 82, 69, 84, 82, 79, 70, 76, 69, + 88, 32, 72, 79, 79, 75, 32, 151, 151, 4, 66, 8, 26, 78, 235, 156, 4, 80, + 6, 17, 2, 69, 32, 6, 226, 237, 4, 83, 138, 233, 10, 70, 219, 170, 3, 84, + 2, 17, 2, 69, 83, 2, 11, 73, 2, 247, 245, 20, 76, 7, 33, 6, 32, 87, 73, + 84, 72, 32, 4, 202, 164, 4, 80, 47, 82, 82, 44, 5, 82, 78, 69, 68, 32, + 199, 151, 21, 77, 80, 174, 1, 67, 58, 68, 22, 73, 54, 79, 142, 1, 82, + 174, 1, 84, 22, 86, 242, 151, 4, 65, 38, 72, 114, 77, 230, 2, 89, 138, + 227, 16, 85, 218, 19, 69, 2, 71, 2, 75, 2, 76, 3, 87, 2, 11, 76, 2, 21, + 3, 79, 83, 69, 2, 243, 137, 1, 68, 2, 239, 212, 17, 69, 5, 11, 78, 2, + 129, 139, 10, 5, 83, 85, 76, 65, 82, 12, 66, 69, 234, 155, 4, 80, 213, 3, + 7, 32, 79, 80, 69, 78, 45, 79, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 174, + 232, 18, 72, 131, 252, 1, 83, 19, 33, 6, 32, 87, 73, 84, 72, 32, 16, 82, + 77, 174, 155, 4, 76, 162, 4, 80, 166, 184, 14, 84, 162, 98, 72, 135, 169, + 1, 83, 4, 17, 2, 73, 68, 4, 146, 138, 4, 68, 227, 17, 45, 5, 227, 148, 4, + 32, 7, 11, 32, 4, 145, 5, 4, 87, 73, 84, 72, 101, 66, 32, 166, 156, 4, + 80, 182, 245, 16, 69, 2, 73, 2, 77, 3, 79, 86, 48, 3, 66, 65, 82, 49, 5, + 87, 73, 84, 72, 32, 5, 173, 19, 8, 32, 87, 73, 84, 72, 32, 83, 72, 82, + 150, 1, 67, 74, 68, 150, 2, 72, 218, 1, 77, 134, 1, 78, 38, 79, 106, 82, + 38, 84, 138, 10, 71, 94, 83, 194, 1, 65, 170, 187, 3, 73, 62, 66, 159, + 75, 76, 6, 180, 239, 4, 9, 73, 82, 67, 85, 77, 70, 76, 69, 88, 179, 248, + 14, 65, 18, 52, 8, 73, 65, 69, 82, 69, 83, 73, 83, 131, 1, 79, 13, 11, + 32, 10, 40, 4, 65, 78, 68, 32, 155, 233, 18, 66, 8, 50, 67, 134, 15, 71, + 158, 2, 65, 187, 215, 3, 77, 2, 251, 229, 19, 65, 6, 26, 85, 175, 216, + 18, 84, 4, 21, 3, 66, 76, 69, 4, 11, 32, 4, 174, 14, 71, 159, 2, 65, 16, + 11, 79, 16, 28, 3, 79, 75, 32, 39, 82, 4, 178, 209, 18, 84, 183, 190, 1, + 65, 12, 11, 78, 13, 29, 5, 32, 65, 78, 68, 32, 10, 66, 72, 214, 12, 71, + 158, 2, 65, 238, 159, 8, 68, 163, 240, 8, 84, 2, 229, 91, 2, 79, 79, 10, + 29, 5, 65, 67, 82, 79, 78, 11, 29, 5, 32, 65, 78, 68, 32, 8, 50, 68, 202, + 11, 71, 158, 2, 65, 143, 144, 17, 84, 2, 159, 11, 73, 2, 225, 149, 17, 4, + 79, 84, 67, 72, 6, 29, 5, 71, 79, 78, 69, 75, 7, 11, 32, 4, 25, 4, 65, + 78, 68, 32, 4, 230, 12, 65, 143, 144, 17, 84, 4, 138, 150, 4, 69, 227, + 186, 14, 73, 6, 25, 4, 73, 76, 68, 69, 7, 11, 32, 4, 26, 65, 167, 227, + 18, 66, 2, 17, 2, 78, 68, 2, 11, 32, 2, 191, 11, 65, 31, 84, 6, 32, 87, + 73, 84, 72, 32, 218, 1, 73, 66, 79, 254, 244, 19, 69, 151, 144, 1, 89, + 16, 82, 68, 76, 4, 72, 79, 79, 75, 198, 145, 4, 82, 110, 67, 22, 80, 131, + 135, 13, 84, 4, 26, 73, 227, 169, 8, 79, 2, 17, 2, 65, 71, 2, 249, 213, + 20, 2, 79, 78, 5, 25, 4, 32, 65, 78, 68, 2, 165, 146, 4, 2, 32, 80, 2, + 41, 8, 83, 73, 71, 79, 84, 72, 73, 67, 2, 235, 163, 19, 32, 6, 33, 6, 76, + 65, 80, 85, 75, 32, 6, 150, 238, 20, 65, 2, 79, 3, 85, 21, 48, 6, 32, 87, + 73, 84, 72, 32, 203, 254, 3, 72, 16, 210, 4, 67, 18, 68, 70, 71, 158, 2, + 65, 154, 196, 18, 82, 187, 95, 72, 17, 33, 6, 32, 87, 73, 84, 72, 32, 14, + 42, 68, 32, 2, 76, 79, 155, 143, 4, 80, 4, 230, 3, 73, 215, 254, 19, 79, + 8, 60, 11, 78, 71, 32, 76, 69, 70, 84, 32, 76, 69, 71, 79, 87, 7, 11, 32, + 4, 60, 7, 65, 78, 68, 32, 76, 79, 87, 65, 4, 87, 73, 84, 72, 2, 17, 2, + 32, 82, 2, 21, 3, 73, 71, 72, 2, 199, 202, 11, 84, 2, 161, 255, 19, 4, + 32, 83, 69, 82, 35, 48, 6, 32, 87, 73, 84, 72, 32, 171, 205, 16, 79, 30, + 118, 67, 18, 68, 70, 71, 22, 72, 40, 2, 76, 79, 34, 83, 194, 1, 65, 186, + 215, 3, 77, 214, 184, 13, 84, 143, 180, 1, 82, 2, 175, 3, 73, 6, 26, 73, + 159, 213, 16, 79, 2, 17, 2, 65, 69, 2, 207, 242, 16, 82, 2, 183, 141, 19, + 82, 4, 17, 2, 79, 79, 4, 207, 185, 5, 75, 4, 154, 206, 20, 87, 139, 48, + 79, 4, 26, 72, 135, 206, 20, 84, 2, 245, 246, 3, 3, 79, 82, 84, 31, 33, + 6, 32, 87, 73, 84, 72, 32, 28, 94, 65, 22, 67, 82, 68, 38, 76, 34, 83, + 162, 242, 3, 77, 198, 21, 80, 46, 82, 155, 154, 15, 72, 2, 155, 241, 13, + 67, 6, 42, 73, 230, 168, 7, 85, 187, 171, 12, 65, 2, 165, 252, 11, 4, 82, + 67, 85, 77, 6, 158, 202, 3, 69, 215, 135, 13, 79, 2, 11, 73, 2, 215, 231, + 12, 78, 4, 26, 87, 159, 203, 20, 84, 2, 203, 206, 17, 65, 20, 90, 70, 64, + 7, 76, 79, 78, 71, 32, 83, 32, 210, 241, 9, 73, 226, 235, 10, 83, 219, 5, + 79, 10, 34, 70, 250, 249, 20, 73, 3, 76, 7, 246, 249, 20, 73, 3, 76, 4, + 138, 152, 2, 87, 211, 225, 18, 84, 44, 190, 1, 83, 242, 233, 3, 71, 138, + 142, 17, 65, 2, 69, 2, 72, 2, 73, 2, 74, 2, 75, 2, 76, 2, 77, 2, 78, 2, + 79, 2, 80, 2, 82, 2, 84, 2, 85, 2, 86, 2, 87, 2, 88, 2, 89, 3, 90, 5, + 131, 151, 5, 67, 150, 6, 160, 2, 2, 65, 70, 144, 1, 2, 70, 84, 196, 38, + 9, 73, 66, 78, 73, 90, 73, 65, 78, 32, 166, 9, 79, 20, 5, 80, 67, 72, 65, + 32, 164, 8, 8, 83, 83, 45, 84, 72, 65, 78, 32, 204, 162, 13, 5, 85, 75, + 79, 84, 72, 170, 195, 3, 68, 204, 24, 6, 86, 69, 76, 32, 83, 76, 226, + 237, 2, 77, 239, 79, 71, 6, 120, 3, 76, 69, 83, 172, 206, 1, 14, 32, 70, + 76, 85, 84, 84, 69, 82, 73, 78, 71, 32, 73, 78, 249, 129, 12, 3, 89, 32, + 71, 2, 247, 164, 15, 83, 140, 4, 58, 32, 250, 20, 45, 217, 2, 6, 87, 65, + 82, 68, 83, 32, 250, 1, 166, 2, 65, 234, 4, 66, 202, 1, 67, 96, 2, 68, + 79, 112, 2, 72, 65, 166, 3, 76, 46, 77, 38, 79, 102, 82, 146, 3, 83, 82, + 84, 222, 1, 87, 158, 228, 8, 70, 136, 6, 14, 74, 85, 83, 84, 73, 70, 73, + 69, 68, 32, 82, 73, 71, 72, 86, 78, 202, 1, 80, 185, 13, 10, 86, 69, 82, + 84, 73, 67, 65, 76, 32, 66, 28, 22, 78, 143, 4, 82, 22, 28, 2, 68, 32, + 191, 3, 71, 16, 96, 6, 76, 79, 87, 69, 82, 32, 32, 6, 82, 73, 71, 72, 84, + 32, 89, 6, 85, 80, 80, 69, 82, 32, 4, 202, 1, 65, 243, 247, 17, 79, 6, + 50, 84, 221, 194, 18, 6, 68, 79, 85, 66, 76, 69, 4, 254, 208, 17, 82, + 143, 236, 1, 65, 6, 82, 65, 53, 16, 79, 78, 69, 32, 69, 73, 71, 72, 84, + 72, 32, 66, 76, 79, 67, 75, 2, 241, 206, 17, 8, 78, 68, 32, 82, 73, 71, + 72, 84, 5, 181, 202, 19, 17, 32, 67, 79, 78, 84, 65, 73, 78, 73, 78, 71, + 32, 66, 76, 65, 67, 75, 6, 198, 233, 8, 69, 185, 1, 4, 76, 69, 32, 66, 6, + 26, 67, 163, 237, 8, 82, 2, 253, 236, 8, 5, 32, 76, 69, 83, 83, 12, 40, + 4, 65, 82, 66, 32, 187, 237, 8, 76, 8, 40, 4, 68, 79, 87, 78, 1, 2, 85, + 80, 4, 57, 12, 32, 82, 73, 71, 72, 84, 32, 66, 65, 82, 66, 32, 4, 232, + 188, 17, 4, 68, 79, 87, 78, 1, 2, 85, 80, 14, 254, 236, 8, 85, 226, 26, + 79, 250, 237, 2, 69, 137, 170, 2, 8, 76, 79, 83, 69, 68, 32, 69, 78, 10, + 44, 5, 85, 66, 76, 69, 32, 171, 237, 8, 84, 8, 222, 238, 8, 87, 250, 30, + 65, 162, 134, 3, 81, 183, 201, 4, 80, 40, 36, 3, 76, 70, 32, 191, 243, 8, + 78, 38, 132, 2, 6, 67, 73, 82, 67, 76, 69, 162, 238, 8, 66, 90, 70, 82, + 72, 50, 82, 58, 84, 70, 87, 178, 14, 76, 22, 85, 248, 205, 8, 30, 73, 78, + 86, 69, 82, 83, 69, 32, 77, 69, 68, 73, 85, 77, 32, 83, 72, 65, 68, 69, + 32, 65, 78, 68, 32, 82, 73, 71, 72, 84, 255, 26, 77, 11, 33, 6, 32, 87, + 73, 84, 72, 32, 8, 42, 84, 154, 188, 18, 70, 243, 217, 1, 68, 4, 166, + 251, 5, 72, 167, 149, 13, 87, 4, 244, 172, 1, 2, 85, 71, 179, 196, 7, 79, + 2, 217, 210, 19, 4, 85, 76, 84, 73, 8, 36, 3, 78, 69, 32, 143, 242, 8, + 85, 6, 198, 234, 17, 81, 146, 4, 69, 45, 5, 84, 72, 73, 82, 68, 30, 44, + 5, 73, 71, 72, 84, 32, 131, 243, 8, 65, 28, 152, 1, 5, 65, 82, 82, 79, + 87, 132, 1, 12, 68, 79, 85, 66, 76, 69, 32, 65, 82, 82, 79, 87, 30, 87, + 146, 160, 9, 79, 222, 148, 8, 66, 54, 83, 223, 68, 84, 11, 11, 32, 8, 72, + 5, 87, 73, 84, 72, 32, 205, 138, 19, 7, 84, 72, 82, 79, 85, 71, 72, 6, + 162, 245, 16, 68, 218, 188, 3, 86, 79, 83, 7, 177, 152, 9, 2, 32, 87, 4, + 174, 171, 9, 65, 131, 197, 8, 72, 34, 150, 241, 8, 45, 70, 69, 78, 73, + 168, 1, 3, 80, 69, 69, 26, 81, 227, 2, 85, 26, 106, 82, 238, 245, 8, 72, + 134, 230, 7, 79, 152, 136, 1, 8, 87, 79, 32, 84, 72, 73, 82, 68, 211, + 201, 1, 65, 6, 40, 4, 73, 65, 78, 71, 231, 248, 8, 65, 4, 140, 162, 5, 8, + 76, 69, 32, 66, 69, 83, 73, 68, 183, 194, 12, 85, 16, 138, 251, 8, 72, + 202, 1, 73, 249, 209, 10, 2, 82, 73, 62, 128, 1, 9, 80, 79, 73, 78, 84, + 73, 78, 71, 32, 138, 1, 83, 182, 251, 8, 70, 226, 2, 72, 153, 7, 7, 84, + 79, 45, 82, 73, 71, 72, 30, 86, 65, 190, 128, 9, 67, 94, 68, 58, 77, 58, + 82, 182, 1, 83, 74, 84, 155, 178, 8, 69, 6, 250, 128, 9, 78, 230, 180, 8, + 84, 159, 2, 73, 4, 44, 5, 73, 68, 69, 32, 65, 235, 131, 9, 72, 2, 149, + 157, 1, 2, 82, 67, 212, 1, 172, 1, 5, 65, 82, 82, 79, 87, 174, 5, 66, 70, + 72, 242, 3, 84, 186, 2, 87, 214, 131, 9, 68, 210, 1, 70, 170, 7, 76, 26, + 79, 34, 80, 50, 82, 70, 83, 186, 212, 8, 67, 47, 81, 73, 26, 32, 163, + 159, 18, 45, 68, 102, 65, 138, 1, 84, 132, 2, 5, 87, 73, 84, 72, 32, 174, + 133, 9, 70, 221, 174, 10, 4, 79, 86, 69, 82, 12, 44, 5, 66, 79, 86, 69, + 32, 155, 135, 9, 78, 10, 64, 4, 83, 72, 79, 82, 146, 134, 9, 82, 186, + 234, 4, 65, 55, 84, 2, 159, 182, 19, 84, 12, 56, 7, 72, 82, 79, 85, 71, + 72, 32, 53, 3, 79, 32, 66, 6, 162, 238, 13, 83, 142, 209, 4, 76, 243, + 152, 2, 88, 6, 32, 2, 65, 82, 163, 136, 9, 76, 5, 173, 216, 12, 23, 32, + 79, 86, 69, 82, 32, 82, 73, 71, 72, 84, 87, 65, 82, 68, 83, 32, 65, 82, + 82, 79, 87, 32, 36, 118, 76, 130, 136, 9, 68, 182, 1, 80, 30, 83, 38, 84, + 210, 215, 8, 77, 38, 78, 122, 69, 130, 154, 1, 72, 187, 168, 1, 86, 4, + 166, 225, 17, 65, 167, 251, 1, 79, 8, 166, 138, 9, 65, 172, 10, 5, 79, + 84, 84, 79, 77, 163, 206, 8, 76, 30, 26, 65, 135, 232, 17, 69, 26, 48, 6, + 82, 80, 79, 79, 78, 32, 139, 142, 20, 78, 24, 80, 10, 87, 73, 84, 72, 32, + 66, 65, 82, 66, 32, 177, 165, 10, 4, 79, 86, 69, 82, 22, 40, 4, 68, 79, + 87, 78, 117, 2, 85, 80, 10, 26, 32, 247, 237, 17, 87, 8, 166, 141, 9, 66, + 188, 2, 7, 65, 66, 79, 86, 69, 32, 82, 178, 214, 8, 70, 179, 5, 84, 12, + 26, 32, 131, 237, 17, 87, 10, 60, 6, 65, 66, 79, 86, 69, 32, 226, 228, + 17, 70, 179, 5, 84, 6, 42, 76, 145, 141, 9, 4, 82, 73, 71, 72, 4, 182, + 139, 9, 69, 151, 227, 4, 79, 56, 52, 2, 82, 73, 134, 145, 9, 72, 34, 79, + 159, 5, 87, 34, 44, 5, 65, 78, 71, 76, 69, 219, 149, 9, 80, 30, 56, 8, + 45, 72, 69, 65, 68, 69, 68, 32, 247, 242, 17, 32, 28, 52, 5, 65, 82, 82, + 79, 87, 198, 235, 17, 68, 39, 80, 25, 11, 32, 22, 156, 146, 9, 9, 79, 86, + 69, 82, 32, 82, 73, 71, 72, 22, 87, 167, 213, 8, 84, 6, 26, 72, 235, 151, + 9, 65, 4, 45, 9, 73, 84, 69, 32, 65, 82, 82, 79, 87, 5, 169, 240, 17, 2, + 32, 87, 46, 156, 3, 2, 67, 79, 196, 2, 2, 68, 73, 60, 11, 69, 81, 85, 65, + 76, 83, 32, 83, 73, 71, 78, 140, 1, 12, 71, 82, 69, 65, 84, 69, 82, 45, + 84, 72, 65, 78, 72, 9, 76, 69, 83, 83, 45, 84, 72, 65, 78, 76, 14, 77, + 85, 76, 84, 73, 80, 76, 73, 67, 65, 84, 73, 79, 78, 80, 9, 83, 73, 77, + 73, 76, 65, 82, 73, 84, 165, 185, 16, 23, 70, 82, 65, 67, 84, 73, 79, 78, + 32, 82, 69, 68, 85, 67, 84, 73, 79, 78, 32, 83, 73, 71, 78, 14, 76, 8, + 78, 71, 82, 85, 69, 78, 67, 69, 217, 178, 15, 5, 73, 78, 67, 73, 68, 13, + 26, 32, 37, 2, 45, 50, 2, 133, 140, 5, 4, 87, 73, 84, 72, 9, 11, 32, 6, + 82, 73, 37, 16, 87, 73, 84, 72, 32, 72, 79, 82, 73, 90, 79, 78, 84, 65, + 76, 32, 2, 173, 148, 19, 4, 78, 86, 69, 82, 4, 220, 138, 5, 3, 65, 78, + 68, 219, 153, 14, 66, 4, 150, 3, 86, 177, 172, 15, 7, 83, 83, 73, 77, 73, + 76, 65, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 128, 199, 9, 4, 83, 77, 65, + 76, 189, 228, 3, 13, 68, 79, 85, 66, 76, 69, 32, 86, 69, 82, 84, 73, 67, + 7, 11, 32, 4, 18, 79, 63, 87, 2, 11, 82, 2, 157, 173, 18, 2, 32, 76, 5, + 17, 2, 32, 87, 2, 189, 162, 13, 9, 73, 84, 72, 32, 83, 77, 65, 76, 76, 4, + 26, 45, 155, 190, 19, 32, 2, 17, 2, 68, 73, 2, 11, 86, 2, 167, 223, 14, + 73, 4, 219, 163, 6, 89, 5, 199, 171, 19, 80, 148, 1, 252, 1, 15, 67, 79, + 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, 32, 124, 7, 76, 69, 84, + 84, 69, 82, 32, 236, 1, 12, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, + 32, 198, 1, 83, 172, 1, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, + 183, 197, 18, 68, 18, 66, 75, 22, 78, 214, 193, 20, 76, 2, 77, 2, 80, 2, + 82, 3, 84, 5, 239, 240, 19, 65, 5, 217, 250, 12, 4, 89, 73, 78, 45, 78, + 194, 1, 75, 2, 80, 170, 189, 7, 68, 138, 243, 10, 66, 2, 70, 2, 71, 2, + 72, 2, 77, 146, 15, 78, 194, 184, 1, 84, 46, 67, 2, 83, 138, 69, 74, 2, + 76, 2, 82, 2, 86, 2, 87, 2, 89, 187, 2, 65, 6, 178, 189, 20, 72, 2, 76, + 187, 2, 65, 10, 82, 84, 40, 14, 78, 89, 69, 84, 32, 84, 72, 89, 79, 79, + 77, 32, 84, 65, 43, 67, 6, 38, 65, 21, 5, 83, 72, 79, 79, 75, 2, 159, + 161, 7, 45, 5, 17, 2, 32, 67, 2, 209, 190, 15, 3, 69, 82, 45, 8, 92, 4, + 73, 71, 78, 32, 37, 15, 85, 66, 74, 79, 73, 78, 69, 68, 32, 76, 69, 84, + 84, 69, 82, 4, 166, 154, 16, 78, 231, 211, 2, 82, 4, 11, 32, 4, 182, 186, + 20, 82, 3, 89, 14, 230, 224, 16, 85, 194, 142, 1, 79, 246, 202, 2, 65, + 186, 2, 69, 3, 73, 52, 138, 1, 65, 128, 4, 11, 69, 81, 85, 65, 76, 32, + 84, 79, 32, 79, 82, 200, 1, 2, 66, 85, 42, 67, 186, 1, 79, 210, 2, 87, + 163, 170, 19, 83, 16, 40, 5, 66, 79, 86, 69, 32, 171, 4, 78, 12, 152, 1, + 7, 71, 82, 69, 65, 84, 69, 82, 110, 83, 176, 1, 19, 68, 79, 85, 66, 76, + 69, 45, 76, 73, 78, 69, 32, 69, 81, 85, 65, 76, 32, 65, 143, 140, 16, 76, + 2, 181, 5, 23, 45, 84, 72, 65, 78, 32, 65, 66, 79, 86, 69, 32, 68, 79, + 85, 66, 76, 69, 45, 76, 73, 78, 69, 6, 152, 1, 7, 73, 77, 73, 76, 65, 82, + 32, 93, 26, 76, 65, 78, 84, 69, 68, 32, 69, 81, 85, 65, 76, 32, 65, 66, + 79, 86, 69, 32, 71, 82, 69, 65, 84, 69, 82, 4, 18, 65, 59, 79, 2, 25, 4, + 66, 79, 86, 69, 2, 233, 157, 18, 2, 32, 71, 2, 227, 2, 82, 2, 145, 2, 6, + 45, 84, 72, 65, 78, 32, 4, 17, 2, 68, 32, 4, 220, 3, 5, 78, 79, 84, 32, + 65, 241, 202, 13, 11, 83, 73, 78, 71, 76, 69, 45, 76, 73, 78, 69, 4, 237, + 172, 13, 5, 84, 32, 78, 79, 84, 4, 65, 14, 76, 79, 83, 69, 68, 32, 66, + 89, 32, 67, 85, 82, 86, 69, 5, 11, 32, 2, 61, 13, 65, 66, 79, 86, 69, 32, + 83, 76, 65, 78, 84, 69, 68, 2, 17, 2, 32, 69, 2, 251, 156, 15, 81, 18, + 40, 2, 82, 32, 225, 140, 12, 2, 86, 69, 16, 114, 65, 48, 16, 83, 76, 65, + 78, 84, 69, 68, 32, 69, 81, 85, 65, 76, 32, 84, 79, 214, 169, 13, 69, + 163, 239, 4, 71, 2, 249, 228, 9, 7, 80, 80, 82, 79, 88, 73, 77, 9, 49, + 10, 32, 87, 73, 84, 72, 32, 68, 79, 84, 32, 6, 26, 65, 239, 247, 11, 73, + 4, 25, 4, 66, 79, 86, 69, 5, 247, 218, 18, 32, 6, 25, 4, 73, 84, 72, 32, + 6, 66, 67, 40, 8, 81, 85, 69, 83, 84, 73, 79, 78, 203, 223, 19, 68, 2, + 197, 246, 11, 5, 73, 82, 67, 76, 69, 2, 17, 2, 32, 77, 2, 17, 2, 65, 82, + 2, 211, 178, 19, 75, 138, 11, 190, 1, 71, 202, 5, 77, 158, 7, 78, 156, + 65, 2, 80, 83, 20, 3, 83, 85, 32, 234, 133, 16, 82, 240, 35, 11, 86, 82, + 69, 32, 84, 79, 85, 82, 78, 79, 73, 226, 59, 79, 186, 225, 1, 90, 191, + 84, 66, 46, 26, 65, 57, 2, 72, 84, 2, 137, 211, 9, 9, 84, 85, 82, 69, 32, + 79, 80, 69, 78, 44, 54, 32, 136, 4, 4, 78, 73, 78, 71, 203, 219, 16, 72, + 36, 146, 1, 69, 38, 70, 126, 82, 40, 3, 76, 69, 70, 86, 83, 42, 84, 152, + 240, 7, 3, 66, 76, 85, 138, 177, 9, 87, 254, 41, 86, 190, 79, 71, 131, + 70, 67, 2, 177, 144, 18, 4, 73, 71, 72, 84, 8, 94, 73, 229, 222, 18, 17, + 79, 85, 82, 32, 80, 79, 73, 78, 84, 69, 68, 32, 66, 76, 65, 67, 75, 4, + 197, 140, 18, 2, 86, 69, 4, 36, 3, 73, 71, 72, 187, 199, 18, 65, 2, 205, + 244, 1, 16, 84, 32, 84, 79, 82, 84, 79, 73, 83, 69, 32, 83, 72, 69, 76, + 76, 6, 138, 171, 17, 72, 218, 98, 65, 43, 73, 4, 176, 215, 16, 2, 87, 69, + 21, 3, 72, 82, 69, 7, 29, 5, 32, 77, 79, 79, 68, 5, 219, 191, 8, 32, 138, + 1, 80, 3, 66, 85, 32, 201, 199, 8, 11, 73, 84, 69, 68, 32, 76, 73, 65, + 66, 73, 76, 136, 1, 120, 7, 76, 69, 84, 84, 69, 82, 32, 222, 1, 83, 200, + 2, 5, 86, 79, 87, 69, 76, 222, 201, 17, 81, 194, 97, 68, 231, 90, 69, 60, + 170, 1, 71, 138, 180, 6, 84, 130, 237, 8, 89, 242, 136, 1, 78, 174, 179, + 3, 83, 82, 66, 2, 67, 2, 68, 2, 74, 2, 75, 2, 80, 138, 69, 72, 2, 76, 2, + 77, 2, 82, 3, 87, 6, 158, 214, 18, 89, 222, 204, 1, 72, 187, 2, 65, 32, + 108, 4, 73, 71, 78, 32, 128, 1, 12, 77, 65, 76, 76, 32, 76, 69, 84, 84, + 69, 82, 32, 153, 163, 7, 2, 85, 66, 8, 72, 3, 75, 69, 77, 0, 3, 77, 85, + 75, 32, 2, 83, 65, 183, 212, 17, 76, 2, 233, 216, 17, 3, 80, 72, 82, 2, + 207, 143, 20, 45, 18, 214, 167, 16, 78, 198, 182, 3, 65, 194, 66, 75, 2, + 76, 2, 77, 2, 80, 2, 82, 3, 84, 20, 84, 6, 32, 83, 73, 71, 78, 32, 149, + 90, 10, 45, 67, 65, 82, 82, 73, 69, 82, 32, 76, 18, 246, 250, 5, 65, 194, + 217, 11, 79, 142, 141, 2, 69, 162, 64, 73, 3, 85, 226, 8, 22, 69, 187, 64, 75, 222, 8, 34, 32, 177, 3, 3, 65, 82, 32, 14, 120, 12, 73, 78, 84, - 69, 71, 82, 65, 84, 73, 79, 78, 32, 202, 162, 13, 70, 206, 153, 3, 83, - 237, 147, 1, 4, 84, 65, 66, 85, 6, 108, 5, 87, 73, 84, 72, 32, 157, 1, + 69, 71, 82, 65, 84, 73, 79, 78, 32, 162, 207, 13, 70, 134, 155, 3, 83, + 213, 148, 1, 4, 84, 65, 66, 85, 6, 108, 5, 87, 73, 84, 72, 32, 157, 1, 17, 78, 79, 84, 32, 73, 78, 67, 76, 85, 68, 73, 78, 71, 32, 84, 72, 69, 4, 76, 7, 82, 69, 67, 84, 65, 78, 71, 1, 8, 83, 69, 77, 73, 67, 73, 82, 67, 2, 73, 16, 85, 76, 65, 82, 32, 80, 65, 84, 72, 32, 65, 82, 79, 85, - 78, 68, 2, 17, 2, 32, 80, 2, 231, 196, 18, 79, 208, 8, 60, 8, 65, 32, 83, + 78, 68, 2, 17, 2, 32, 80, 2, 191, 246, 18, 79, 208, 8, 60, 8, 65, 32, 83, 73, 71, 78, 32, 65, 205, 24, 2, 66, 32, 170, 5, 122, 49, 86, 51, 202, 2, - 52, 214, 1, 53, 158, 4, 54, 142, 3, 55, 132, 4, 2, 56, 48, 78, 66, 237, - 154, 18, 3, 48, 50, 56, 6, 136, 194, 12, 5, 48, 48, 45, 49, 48, 200, 233, - 5, 2, 50, 48, 233, 19, 2, 51, 49, 150, 1, 78, 48, 90, 49, 130, 1, 55, - 174, 168, 14, 50, 2, 51, 2, 52, 2, 53, 3, 54, 22, 178, 1, 57, 242, 230, - 19, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, 56, 24, 90, 51, 242, - 230, 19, 48, 2, 49, 2, 50, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 6, - 238, 230, 19, 65, 2, 66, 3, 67, 4, 202, 230, 19, 48, 3, 49, 38, 18, 48, + 52, 214, 1, 53, 158, 4, 54, 142, 3, 55, 132, 4, 2, 56, 48, 78, 66, 129, + 202, 18, 3, 48, 50, 56, 6, 232, 238, 12, 5, 48, 48, 45, 49, 48, 252, 235, + 5, 2, 50, 48, 173, 22, 2, 51, 49, 150, 1, 78, 48, 90, 49, 130, 1, 55, + 218, 212, 14, 50, 2, 51, 2, 52, 2, 53, 3, 54, 22, 178, 1, 57, 138, 153, + 20, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, 56, 24, 90, 51, 138, + 153, 20, 48, 2, 49, 2, 50, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 6, + 134, 153, 20, 65, 2, 66, 3, 67, 4, 226, 152, 20, 48, 3, 49, 38, 18, 48, 91, 49, 20, 162, 1, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 18, 74, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, - 55, 3, 56, 2, 161, 179, 6, 2, 45, 86, 160, 1, 102, 48, 78, 49, 62, 51, - 86, 52, 70, 53, 86, 54, 190, 11, 50, 194, 171, 2, 57, 226, 235, 11, 55, - 3, 56, 16, 238, 227, 19, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 56, 3, - 57, 12, 162, 227, 19, 48, 2, 49, 2, 50, 2, 51, 2, 53, 3, 54, 18, 230, - 226, 19, 48, 2, 49, 2, 50, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 14, - 146, 226, 19, 48, 2, 49, 2, 50, 2, 53, 2, 55, 2, 56, 3, 57, 18, 206, 225, - 19, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, 57, 12, 250, - 224, 19, 51, 2, 52, 2, 53, 2, 54, 2, 56, 3, 57, 104, 70, 48, 78, 50, 86, - 51, 38, 52, 78, 54, 202, 157, 14, 53, 131, 2, 49, 16, 246, 223, 19, 48, - 2, 49, 2, 50, 2, 51, 2, 52, 2, 54, 2, 56, 3, 57, 18, 170, 223, 19, 48, 2, - 49, 2, 50, 2, 51, 2, 52, 2, 54, 2, 55, 2, 56, 3, 57, 6, 214, 222, 19, 52, - 2, 55, 3, 56, 16, 178, 222, 19, 48, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, - 56, 3, 57, 10, 230, 221, 19, 48, 2, 49, 2, 50, 2, 51, 3, 52, 44, 86, 48, - 134, 2, 49, 196, 129, 2, 2, 51, 50, 205, 199, 17, 6, 50, 54, 32, 69, 89, - 89, 26, 110, 57, 206, 220, 8, 55, 182, 6, 50, 62, 54, 254, 63, 52, 146, - 155, 3, 51, 114, 56, 186, 211, 2, 49, 155, 122, 53, 10, 26, 45, 131, 208, - 18, 32, 8, 96, 2, 50, 32, 208, 175, 12, 3, 54, 32, 76, 184, 2, 3, 52, 32, - 76, 137, 174, 3, 3, 51, 32, 76, 2, 171, 179, 12, 76, 14, 114, 51, 32, 3, - 52, 32, 65, 0, 2, 53, 32, 134, 65, 49, 174, 223, 3, 50, 250, 195, 4, 48, - 249, 249, 6, 2, 55, 32, 2, 11, 32, 2, 199, 148, 12, 79, 2, 203, 155, 18, - 66, 16, 174, 217, 19, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 3, + 55, 3, 56, 2, 141, 219, 6, 2, 45, 86, 160, 1, 102, 48, 78, 49, 62, 51, + 86, 52, 70, 53, 86, 54, 190, 11, 50, 186, 174, 2, 57, 150, 149, 12, 55, + 3, 56, 16, 134, 150, 20, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 56, 3, + 57, 12, 186, 149, 20, 48, 2, 49, 2, 50, 2, 51, 2, 53, 3, 54, 18, 254, + 148, 20, 48, 2, 49, 2, 50, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 14, + 170, 148, 20, 48, 2, 49, 2, 50, 2, 53, 2, 55, 2, 56, 3, 57, 18, 230, 147, + 20, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, 57, 12, 146, + 147, 20, 51, 2, 52, 2, 53, 2, 54, 2, 56, 3, 57, 104, 70, 48, 78, 50, 86, + 51, 38, 52, 78, 54, 246, 201, 14, 53, 131, 2, 49, 16, 142, 146, 20, 48, + 2, 49, 2, 50, 2, 51, 2, 52, 2, 54, 2, 56, 3, 57, 18, 194, 145, 20, 48, 2, + 49, 2, 50, 2, 51, 2, 52, 2, 54, 2, 55, 2, 56, 3, 57, 6, 238, 144, 20, 52, + 2, 55, 3, 56, 16, 202, 144, 20, 48, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, + 56, 3, 57, 10, 254, 143, 20, 48, 2, 49, 2, 50, 2, 51, 3, 52, 44, 86, 48, + 134, 2, 49, 164, 132, 2, 2, 51, 50, 133, 247, 17, 6, 50, 54, 32, 69, 89, + 89, 26, 110, 57, 238, 133, 9, 55, 182, 6, 50, 62, 54, 174, 65, 52, 162, + 157, 3, 51, 114, 56, 134, 211, 2, 49, 151, 123, 53, 10, 26, 45, 155, 130, + 19, 32, 8, 96, 2, 50, 32, 176, 220, 12, 3, 54, 32, 76, 184, 2, 3, 52, 32, + 76, 253, 173, 3, 3, 51, 32, 76, 2, 139, 224, 12, 76, 14, 114, 51, 32, 3, + 52, 32, 65, 0, 2, 53, 32, 134, 65, 49, 250, 133, 4, 50, 198, 198, 4, 48, + 181, 253, 6, 2, 55, 32, 2, 11, 32, 2, 167, 191, 12, 79, 2, 223, 202, 18, + 66, 16, 198, 139, 20, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 3, 55, 162, 1, 22, 48, 155, 5, 49, 140, 1, 82, 49, 54, 50, 118, 51, 62, 52, - 78, 53, 86, 54, 62, 55, 70, 56, 207, 147, 14, 48, 10, 238, 215, 19, 48, - 2, 49, 2, 51, 2, 54, 3, 55, 28, 86, 49, 2, 50, 138, 82, 51, 222, 132, 19, - 48, 2, 52, 2, 54, 2, 55, 2, 56, 3, 57, 7, 226, 214, 19, 70, 3, 77, 12, - 198, 214, 19, 48, 2, 49, 2, 52, 2, 55, 2, 56, 3, 57, 16, 138, 214, 19, - 48, 2, 49, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 18, 190, 213, 19, - 48, 2, 49, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 12, 234, 212, - 19, 48, 2, 49, 2, 53, 2, 54, 2, 55, 3, 57, 14, 174, 212, 19, 48, 2, 51, - 2, 52, 2, 54, 2, 55, 2, 56, 3, 57, 12, 234, 211, 19, 48, 2, 49, 2, 50, 2, - 53, 2, 54, 3, 55, 22, 82, 50, 36, 2, 51, 49, 30, 56, 238, 166, 12, 49, - 206, 2, 54, 146, 1, 55, 3, 57, 6, 218, 210, 19, 48, 2, 50, 3, 51, 4, 182, - 210, 19, 65, 3, 66, 4, 154, 210, 19, 48, 3, 56, 166, 3, 116, 9, 73, 68, + 78, 53, 86, 54, 62, 55, 70, 56, 251, 191, 14, 48, 10, 134, 138, 20, 48, + 2, 49, 2, 51, 2, 54, 3, 55, 28, 86, 49, 2, 50, 226, 82, 51, 158, 182, 19, + 48, 2, 52, 2, 54, 2, 55, 2, 56, 3, 57, 7, 250, 136, 20, 70, 3, 77, 12, + 222, 136, 20, 48, 2, 49, 2, 52, 2, 55, 2, 56, 3, 57, 16, 162, 136, 20, + 48, 2, 49, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 18, 214, 135, 20, + 48, 2, 49, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 12, 130, 135, + 20, 48, 2, 49, 2, 53, 2, 54, 2, 55, 3, 57, 14, 198, 134, 20, 48, 2, 51, + 2, 52, 2, 54, 2, 55, 2, 56, 3, 57, 12, 130, 134, 20, 48, 2, 49, 2, 50, 2, + 53, 2, 54, 3, 55, 22, 82, 50, 36, 2, 51, 49, 30, 56, 206, 211, 12, 49, + 206, 2, 54, 146, 1, 55, 3, 57, 6, 242, 132, 20, 48, 2, 50, 3, 51, 4, 206, + 132, 20, 65, 3, 66, 4, 178, 132, 20, 48, 3, 56, 166, 3, 116, 9, 73, 68, 69, 79, 71, 82, 65, 77, 32, 220, 17, 10, 77, 79, 78, 79, 71, 82, 65, 77, 32, 66, 249, 1, 2, 83, 89, 234, 1, 54, 66, 253, 15, 8, 86, 69, 83, 83, 69, 76, 32, 66, 176, 1, 22, 49, 131, 11, 50, 126, 86, 48, 210, 3, 50, 166, 1, 51, 86, 52, 122, 53, 114, 54, 146, 1, 55, 118, 56, 71, 57, 28, - 114, 53, 98, 54, 58, 55, 78, 56, 62, 57, 208, 134, 7, 3, 50, 32, 87, 254, - 88, 48, 137, 175, 11, 4, 52, 32, 68, 69, 6, 184, 133, 7, 2, 32, 69, 220, - 166, 11, 3, 70, 32, 77, 133, 82, 7, 77, 32, 83, 84, 65, 76, 76, 4, 168, - 245, 1, 3, 70, 32, 69, 185, 155, 16, 2, 77, 32, 4, 36, 3, 70, 32, 83, 1, - 2, 77, 32, 2, 181, 231, 11, 4, 72, 69, 45, 71, 4, 164, 155, 9, 3, 77, 32, - 66, 173, 149, 9, 3, 70, 32, 83, 4, 148, 194, 17, 4, 77, 32, 66, 85, 129, - 110, 3, 70, 32, 67, 10, 172, 148, 9, 4, 51, 32, 83, 80, 240, 10, 5, 49, - 32, 66, 65, 82, 148, 240, 4, 4, 50, 32, 79, 76, 20, 6, 53, 32, 67, 89, - 80, 69, 129, 179, 4, 4, 48, 32, 87, 72, 6, 54, 49, 216, 234, 17, 3, 48, - 32, 79, 211, 223, 1, 50, 2, 233, 174, 18, 2, 32, 87, 10, 224, 5, 3, 53, - 32, 87, 176, 146, 9, 6, 48, 32, 66, 82, 79, 78, 172, 2, 4, 49, 32, 71, - 79, 206, 175, 10, 50, 3, 54, 16, 82, 57, 134, 238, 2, 49, 190, 218, 16, - 48, 2, 50, 2, 51, 2, 52, 2, 55, 3, 56, 2, 157, 102, 3, 32, 67, 76, 20, - 212, 172, 14, 5, 51, 32, 65, 82, 77, 152, 216, 4, 5, 50, 32, 71, 65, 82, - 182, 67, 48, 2, 49, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 18, 182, - 253, 13, 54, 216, 196, 3, 4, 51, 32, 77, 79, 134, 133, 2, 48, 2, 49, 2, - 50, 2, 52, 2, 55, 2, 56, 3, 57, 14, 158, 198, 19, 48, 2, 49, 2, 50, 2, - 51, 2, 52, 2, 53, 3, 57, 4, 204, 169, 2, 3, 49, 32, 72, 143, 156, 17, 48, + 114, 53, 98, 54, 58, 55, 78, 56, 62, 57, 208, 174, 7, 3, 50, 32, 87, 150, + 89, 48, 137, 185, 11, 4, 52, 32, 68, 69, 6, 184, 173, 7, 2, 32, 69, 180, + 176, 11, 3, 70, 32, 77, 197, 82, 7, 77, 32, 83, 84, 65, 76, 76, 4, 136, + 248, 1, 3, 70, 32, 69, 237, 199, 16, 2, 77, 32, 4, 36, 3, 70, 32, 83, 1, + 2, 77, 32, 2, 133, 146, 12, 4, 72, 69, 45, 71, 4, 244, 197, 9, 3, 77, 32, + 66, 189, 156, 9, 3, 70, 32, 83, 4, 140, 241, 17, 4, 77, 32, 66, 85, 233, + 112, 3, 70, 32, 67, 10, 252, 190, 9, 4, 51, 32, 83, 80, 240, 10, 5, 49, + 32, 66, 65, 82, 252, 241, 4, 4, 50, 32, 79, 76, 20, 6, 53, 32, 67, 89, + 80, 69, 225, 184, 4, 4, 48, 32, 87, 72, 6, 54, 49, 224, 153, 18, 3, 48, + 32, 79, 227, 226, 1, 50, 2, 129, 225, 18, 2, 32, 87, 10, 224, 5, 3, 53, + 32, 87, 128, 189, 9, 6, 48, 32, 66, 82, 79, 78, 172, 2, 4, 49, 32, 71, + 79, 150, 183, 10, 50, 3, 54, 16, 82, 57, 202, 246, 2, 49, 146, 132, 17, + 48, 2, 50, 2, 51, 2, 52, 2, 55, 3, 56, 2, 245, 102, 3, 32, 67, 76, 20, + 132, 217, 14, 5, 51, 32, 65, 82, 77, 128, 222, 4, 5, 50, 32, 71, 65, 82, + 182, 67, 48, 2, 49, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 18, 226, + 169, 14, 54, 172, 199, 3, 4, 51, 32, 77, 79, 158, 136, 2, 48, 2, 49, 2, + 50, 2, 52, 2, 55, 2, 56, 3, 57, 14, 182, 248, 19, 48, 2, 49, 2, 50, 2, + 51, 2, 52, 2, 53, 3, 57, 4, 200, 172, 2, 3, 49, 32, 72, 171, 203, 17, 48, 50, 42, 50, 110, 51, 130, 1, 52, 227, 1, 53, 4, 84, 8, 48, 32, 70, 79, - 79, 84, 83, 84, 169, 211, 6, 7, 53, 32, 66, 65, 84, 72, 84, 2, 155, 175, - 18, 79, 12, 104, 4, 51, 32, 83, 87, 184, 138, 14, 4, 48, 32, 83, 80, 154, - 156, 4, 49, 218, 156, 1, 50, 2, 52, 3, 54, 2, 183, 170, 18, 79, 16, 168, - 1, 9, 48, 32, 87, 72, 69, 69, 76, 69, 68, 2, 49, 34, 51, 232, 175, 17, - 12, 50, 32, 67, 72, 65, 82, 73, 79, 84, 32, 70, 82, 226, 145, 2, 53, 2, - 54, 2, 56, 3, 57, 2, 197, 181, 18, 3, 32, 67, 72, 2, 247, 191, 6, 32, 18, - 148, 186, 18, 3, 52, 32, 68, 158, 135, 1, 49, 2, 50, 2, 51, 2, 53, 2, 54, - 2, 55, 2, 56, 3, 57, 58, 50, 50, 212, 150, 12, 2, 49, 53, 1, 2, 51, 48, - 54, 50, 50, 130, 153, 12, 53, 198, 232, 1, 48, 3, 49, 12, 226, 191, 19, + 79, 84, 83, 84, 153, 251, 6, 7, 53, 32, 66, 65, 84, 72, 84, 2, 179, 225, + 18, 79, 12, 104, 4, 51, 32, 83, 87, 128, 183, 14, 4, 48, 32, 83, 80, 178, + 161, 4, 49, 146, 157, 1, 50, 2, 52, 3, 54, 2, 207, 220, 18, 79, 16, 168, + 1, 9, 48, 32, 87, 72, 69, 69, 76, 69, 68, 2, 49, 34, 51, 224, 222, 17, + 12, 50, 32, 67, 72, 65, 82, 73, 79, 84, 32, 70, 82, 130, 149, 2, 53, 2, + 54, 2, 56, 3, 57, 2, 221, 231, 18, 3, 32, 67, 72, 2, 227, 231, 6, 32, 18, + 172, 236, 18, 3, 52, 32, 68, 158, 135, 1, 49, 2, 50, 2, 51, 2, 53, 2, 54, + 2, 55, 2, 56, 3, 57, 58, 50, 50, 180, 195, 12, 2, 49, 53, 1, 2, 51, 48, + 54, 50, 50, 226, 197, 12, 53, 146, 232, 1, 48, 3, 49, 12, 250, 241, 19, 49, 2, 50, 2, 54, 2, 55, 2, 56, 3, 57, 12, 46, 49, 153, 12, 6, 50, 52, 55, 32, 68, 73, 10, 50, 50, 70, 51, 181, 11, 5, 53, 54, 32, 84, 85, 4, - 148, 180, 3, 3, 55, 32, 75, 161, 235, 15, 5, 56, 32, 75, 65, 78, 4, 56, - 3, 53, 32, 77, 157, 128, 16, 5, 51, 32, 65, 82, 69, 2, 247, 209, 12, 69, + 188, 199, 3, 3, 55, 32, 75, 145, 138, 16, 5, 56, 32, 75, 65, 78, 4, 56, + 3, 53, 32, 77, 173, 174, 16, 5, 51, 32, 65, 82, 69, 2, 207, 254, 12, 69, 176, 1, 84, 9, 76, 76, 65, 66, 76, 69, 32, 66, 48, 229, 12, 7, 77, 66, 79, 76, 32, 66, 48, 148, 1, 114, 48, 142, 1, 49, 162, 1, 50, 230, 1, 51, 174, 1, 52, 162, 1, 53, 154, 1, 54, 186, 1, 55, 198, 1, 56, 87, 57, 18, - 118, 54, 182, 203, 1, 55, 130, 8, 52, 190, 14, 57, 222, 247, 10, 53, 158, - 152, 2, 56, 198, 10, 49, 254, 2, 50, 207, 8, 51, 2, 203, 252, 17, 32, 16, - 122, 54, 18, 55, 202, 212, 1, 49, 134, 2, 50, 166, 26, 52, 176, 187, 1, - 2, 53, 32, 210, 242, 5, 48, 229, 128, 9, 2, 51, 32, 2, 171, 95, 32, 2, - 159, 139, 11, 32, 18, 166, 1, 51, 22, 54, 20, 3, 57, 32, 80, 224, 6, 2, - 53, 32, 168, 180, 3, 2, 48, 32, 156, 218, 14, 2, 55, 32, 140, 7, 2, 52, - 32, 162, 91, 56, 185, 44, 3, 49, 32, 81, 2, 171, 176, 14, 32, 2, 247, - 245, 14, 32, 2, 159, 144, 12, 85, 16, 134, 1, 48, 20, 2, 51, 32, 186, - 200, 1, 55, 234, 34, 54, 142, 237, 4, 57, 210, 165, 2, 56, 246, 171, 4, - 49, 205, 237, 5, 3, 50, 32, 81, 2, 235, 177, 14, 32, 2, 135, 1, 82, 16, - 116, 2, 51, 32, 22, 53, 174, 196, 1, 48, 222, 1, 49, 242, 5, 50, 218, 10, - 52, 178, 5, 54, 185, 223, 12, 3, 56, 32, 78, 2, 203, 186, 15, 65, 2, 159, - 162, 17, 32, 18, 130, 1, 51, 222, 196, 1, 49, 150, 1, 56, 42, 57, 102, - 55, 194, 5, 48, 250, 141, 2, 52, 184, 176, 15, 2, 50, 32, 157, 4, 2, 53, - 32, 2, 175, 200, 12, 32, 16, 132, 1, 2, 50, 32, 20, 2, 56, 32, 204, 1, 3, - 54, 32, 84, 210, 191, 1, 55, 226, 3, 57, 146, 2, 53, 250, 243, 6, 49, - 243, 172, 10, 48, 2, 203, 233, 17, 80, 2, 137, 139, 12, 2, 82, 79, 18, - 172, 1, 3, 54, 32, 82, 242, 191, 1, 55, 138, 8, 48, 170, 16, 53, 12, 3, - 49, 32, 68, 220, 166, 7, 2, 52, 32, 222, 252, 3, 50, 200, 158, 6, 3, 56, - 32, 81, 241, 2, 2, 51, 32, 2, 191, 137, 12, 65, 8, 238, 191, 1, 49, 168, - 24, 3, 55, 32, 84, 248, 245, 6, 2, 53, 32, 191, 156, 6, 48, 4, 202, 155, - 17, 49, 21, 3, 48, 32, 68, 28, 90, 52, 30, 54, 30, 56, 194, 131, 12, 53, - 158, 2, 49, 30, 51, 166, 1, 50, 171, 173, 3, 55, 4, 146, 175, 19, 55, 3, - 57, 4, 246, 174, 19, 51, 3, 52, 8, 218, 174, 19, 50, 2, 51, 2, 54, 3, 57, - 4, 152, 208, 10, 9, 69, 68, 32, 80, 65, 80, 69, 82, 67, 223, 200, 7, 32, - 5, 215, 251, 17, 84, 98, 96, 7, 76, 69, 84, 84, 69, 82, 32, 181, 235, 6, - 11, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 94, 238, 1, 84, 150, 246, - 2, 68, 234, 159, 10, 85, 130, 159, 2, 78, 138, 31, 69, 190, 143, 3, 67, + 118, 54, 150, 206, 1, 55, 130, 8, 52, 190, 14, 57, 214, 161, 11, 53, 242, + 151, 2, 56, 198, 10, 49, 254, 2, 50, 207, 8, 51, 2, 223, 171, 18, 32, 16, + 122, 54, 18, 55, 170, 215, 1, 49, 134, 2, 50, 178, 26, 52, 220, 201, 1, + 2, 53, 32, 138, 140, 6, 48, 173, 136, 9, 2, 51, 32, 2, 131, 96, 32, 2, + 223, 181, 11, 32, 18, 166, 1, 51, 22, 54, 20, 3, 57, 32, 80, 224, 6, 2, + 53, 32, 172, 210, 3, 2, 48, 32, 240, 237, 14, 2, 55, 32, 204, 7, 2, 52, + 32, 162, 91, 56, 185, 44, 3, 49, 32, 81, 2, 211, 220, 14, 32, 2, 163, + 162, 15, 32, 2, 255, 188, 12, 85, 16, 134, 1, 48, 20, 2, 51, 32, 154, + 203, 1, 55, 246, 34, 54, 162, 146, 5, 57, 162, 168, 2, 56, 214, 173, 4, + 49, 181, 243, 5, 3, 50, 32, 81, 2, 147, 222, 14, 32, 2, 135, 1, 82, 16, + 116, 2, 51, 32, 22, 53, 142, 199, 1, 48, 222, 1, 49, 242, 5, 50, 222, 10, + 52, 174, 5, 54, 129, 137, 13, 3, 56, 32, 78, 2, 159, 231, 15, 65, 2, 151, + 209, 17, 32, 18, 130, 1, 51, 190, 199, 1, 49, 150, 1, 56, 42, 57, 102, + 55, 194, 5, 48, 226, 177, 2, 52, 136, 188, 15, 2, 50, 32, 157, 4, 2, 53, + 32, 2, 135, 245, 12, 32, 16, 132, 1, 2, 50, 32, 20, 2, 56, 32, 204, 1, 3, + 54, 32, 84, 178, 194, 1, 55, 226, 3, 57, 146, 2, 53, 186, 154, 7, 49, + 235, 181, 10, 48, 2, 235, 152, 18, 80, 2, 233, 183, 12, 2, 82, 79, 18, + 172, 1, 3, 54, 32, 82, 210, 194, 1, 55, 138, 8, 48, 170, 16, 53, 12, 3, + 49, 32, 68, 204, 206, 7, 2, 52, 32, 230, 254, 3, 50, 136, 164, 6, 3, 56, + 32, 81, 241, 2, 2, 51, 32, 2, 159, 182, 12, 65, 8, 206, 194, 1, 49, 168, + 24, 3, 55, 32, 84, 176, 156, 7, 2, 53, 32, 211, 159, 6, 48, 4, 194, 202, + 17, 49, 21, 3, 48, 32, 68, 28, 90, 52, 30, 54, 30, 56, 162, 176, 12, 53, + 158, 2, 49, 30, 51, 166, 1, 50, 159, 173, 3, 55, 4, 170, 225, 19, 55, 3, + 57, 4, 142, 225, 19, 51, 3, 52, 8, 242, 224, 19, 50, 2, 51, 2, 54, 3, 57, + 4, 244, 250, 10, 9, 69, 68, 32, 80, 65, 80, 69, 82, 67, 155, 208, 7, 32, + 5, 175, 173, 18, 84, 98, 96, 7, 76, 69, 84, 84, 69, 82, 32, 181, 147, 7, + 11, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 94, 238, 1, 84, 134, 133, + 3, 68, 170, 189, 10, 85, 178, 159, 2, 78, 210, 31, 69, 174, 148, 3, 67, 2, 71, 2, 72, 2, 75, 2, 80, 2, 83, 2, 89, 2, 90, 162, 7, 65, 2, 79, 234, 61, 66, 2, 70, 2, 74, 2, 76, 2, 77, 2, 87, 2, 88, 187, 2, 73, 20, 64, 4, - 79, 78, 69, 32, 254, 226, 18, 83, 138, 69, 72, 187, 2, 65, 12, 48, 4, 77, - 89, 65, 32, 141, 197, 1, 2, 78, 65, 10, 170, 189, 12, 74, 234, 205, 6, - 66, 158, 11, 84, 254, 16, 67, 39, 78, 210, 2, 232, 1, 2, 67, 75, 132, 1, + 79, 78, 69, 32, 150, 149, 19, 83, 138, 69, 72, 187, 2, 65, 12, 48, 4, 77, + 89, 65, 32, 237, 199, 1, 2, 78, 65, 10, 130, 234, 12, 74, 170, 211, 6, + 66, 158, 11, 84, 254, 16, 67, 39, 78, 214, 2, 232, 1, 2, 67, 75, 132, 1, 3, 71, 73, 67, 176, 6, 3, 78, 71, 32, 206, 9, 84, 116, 3, 86, 69, 32, 70, - 87, 172, 12, 5, 90, 69, 78, 71, 69, 226, 227, 7, 66, 240, 156, 10, 8, 85, + 87, 132, 13, 5, 90, 69, 78, 71, 69, 130, 140, 8, 66, 144, 166, 10, 8, 85, 68, 76, 89, 32, 67, 82, 89, 141, 15, 4, 76, 76, 73, 80, 9, 96, 10, 73, - 78, 71, 45, 83, 72, 73, 70, 84, 32, 137, 25, 9, 32, 87, 73, 84, 72, 32, - 73, 78, 75, 4, 226, 180, 17, 90, 223, 86, 79, 40, 56, 6, 32, 71, 65, 84, + 78, 71, 45, 83, 72, 73, 70, 84, 32, 157, 25, 9, 32, 87, 73, 84, 72, 32, + 73, 78, 75, 4, 226, 227, 17, 90, 247, 89, 79, 40, 56, 6, 32, 71, 65, 84, 69, 32, 137, 2, 3, 65, 76, 32, 12, 104, 6, 66, 85, 70, 70, 69, 82, 84, 9, - 73, 78, 86, 69, 82, 84, 69, 68, 32, 194, 148, 18, 65, 187, 87, 79, 5, + 73, 78, 86, 69, 82, 84, 69, 68, 32, 218, 198, 18, 65, 187, 87, 79, 5, 133, 1, 17, 32, 87, 73, 84, 72, 32, 73, 78, 86, 69, 82, 84, 69, 68, 32, - 73, 78, 4, 48, 3, 79, 85, 84, 129, 155, 6, 3, 73, 78, 80, 2, 207, 170, + 73, 78, 4, 48, 3, 79, 85, 84, 237, 194, 6, 3, 73, 78, 80, 2, 231, 220, 18, 80, 28, 36, 3, 65, 78, 68, 85, 2, 79, 82, 15, 33, 6, 32, 87, 73, 84, - 72, 32, 12, 226, 1, 68, 94, 72, 58, 77, 199, 177, 15, 85, 15, 11, 32, 12, + 72, 32, 12, 226, 1, 68, 94, 72, 58, 77, 239, 222, 15, 85, 15, 11, 32, 12, 88, 13, 79, 86, 69, 82, 76, 65, 80, 80, 73, 78, 71, 32, 76, 49, 5, 87, - 73, 84, 72, 32, 2, 133, 146, 18, 7, 79, 71, 73, 67, 65, 76, 32, 10, 26, - 68, 94, 72, 59, 77, 6, 11, 79, 6, 44, 5, 85, 66, 76, 69, 32, 159, 164, - 18, 84, 4, 154, 178, 15, 85, 143, 61, 79, 2, 133, 224, 15, 9, 79, 82, 73, - 90, 79, 78, 84, 65, 76, 2, 225, 220, 7, 5, 73, 68, 68, 76, 69, 48, 70, + 73, 84, 72, 32, 2, 157, 196, 18, 7, 79, 71, 73, 67, 65, 76, 32, 10, 26, + 68, 94, 72, 59, 77, 6, 11, 79, 6, 44, 5, 85, 66, 76, 69, 32, 183, 214, + 18, 84, 4, 194, 223, 15, 85, 247, 61, 79, 2, 209, 141, 16, 9, 79, 82, 73, + 90, 79, 78, 84, 65, 76, 2, 181, 133, 8, 5, 73, 68, 68, 76, 69, 48, 70, 68, 228, 1, 4, 76, 69, 70, 84, 241, 2, 5, 82, 73, 71, 72, 84, 6, 164, 1, 30, 65, 83, 72, 32, 70, 82, 79, 77, 32, 76, 69, 70, 84, 32, 77, 69, 77, - 66, 69, 82, 32, 79, 70, 32, 68, 79, 85, 66, 76, 69, 250, 160, 16, 73, - 151, 210, 1, 82, 2, 17, 2, 32, 86, 2, 189, 146, 18, 5, 69, 82, 84, 73, + 66, 69, 82, 32, 79, 70, 32, 68, 79, 85, 66, 76, 69, 150, 207, 16, 73, + 211, 213, 1, 82, 2, 17, 2, 32, 86, 2, 213, 196, 18, 5, 69, 82, 84, 73, 67, 20, 46, 32, 193, 1, 6, 87, 65, 82, 68, 83, 32, 8, 48, 6, 82, 73, 71, - 72, 84, 32, 191, 254, 15, 84, 6, 44, 5, 65, 82, 82, 79, 87, 255, 243, 15, - 68, 5, 245, 243, 13, 18, 32, 87, 73, 84, 72, 32, 68, 69, 80, 69, 78, 68, - 69, 78, 84, 32, 76, 79, 12, 214, 3, 68, 42, 65, 146, 1, 83, 153, 240, 8, + 72, 84, 32, 219, 172, 16, 84, 6, 44, 5, 65, 82, 82, 79, 87, 143, 162, 16, + 68, 5, 181, 250, 17, 18, 32, 87, 73, 84, 72, 32, 68, 69, 80, 69, 78, 68, + 69, 78, 84, 32, 76, 79, 12, 214, 3, 68, 42, 65, 146, 1, 83, 233, 154, 9, 19, 72, 65, 82, 80, 79, 79, 78, 32, 65, 66, 79, 86, 69, 32, 83, 72, 79, - 82, 84, 22, 48, 6, 87, 65, 82, 68, 83, 32, 159, 247, 8, 32, 20, 88, 5, + 82, 84, 22, 48, 6, 87, 65, 82, 68, 83, 32, 239, 161, 9, 32, 20, 88, 5, 65, 82, 82, 79, 87, 202, 1, 68, 96, 8, 72, 65, 82, 80, 79, 79, 78, 32, - 91, 83, 11, 11, 32, 8, 164, 1, 7, 84, 72, 82, 79, 85, 71, 72, 132, 143, - 3, 10, 87, 73, 84, 72, 32, 68, 79, 85, 66, 76, 248, 227, 5, 9, 79, 86, - 69, 82, 32, 76, 79, 78, 71, 203, 188, 7, 70, 2, 255, 137, 18, 32, 4, 37, - 7, 79, 85, 66, 76, 69, 32, 65, 4, 25, 4, 82, 82, 79, 87, 5, 233, 174, 16, - 2, 32, 70, 4, 160, 242, 8, 4, 79, 86, 69, 82, 33, 11, 65, 66, 79, 86, 69, - 32, 83, 72, 79, 82, 84, 2, 157, 224, 7, 3, 81, 85, 73, 6, 92, 5, 73, 79, - 78, 32, 66, 196, 250, 17, 9, 32, 79, 70, 32, 70, 79, 82, 84, 85, 215, 93, - 85, 2, 135, 237, 9, 79, 4, 38, 76, 137, 128, 14, 3, 72, 79, 84, 2, 169, - 219, 17, 2, 69, 84, 222, 1, 34, 32, 229, 1, 3, 69, 82, 32, 14, 138, 1, - 66, 228, 196, 10, 11, 68, 79, 85, 66, 76, 69, 32, 80, 82, 73, 77, 214, - 183, 6, 65, 148, 113, 6, 75, 65, 86, 89, 75, 65, 227, 10, 76, 4, 38, 82, - 133, 245, 4, 3, 65, 84, 84, 2, 237, 253, 17, 7, 73, 71, 72, 84, 78, 69, - 83, 208, 1, 158, 1, 72, 140, 2, 5, 76, 69, 70, 84, 32, 236, 2, 6, 82, 73, - 71, 72, 84, 32, 206, 242, 15, 66, 74, 67, 74, 70, 234, 10, 77, 150, 2, - 79, 170, 18, 83, 67, 84, 20, 84, 4, 65, 76, 70, 32, 129, 182, 7, 11, 79, - 82, 73, 90, 79, 78, 84, 65, 76, 32, 82, 18, 228, 161, 7, 9, 65, 78, 68, - 32, 85, 80, 80, 69, 82, 32, 7, 73, 78, 86, 69, 82, 83, 69, 150, 216, 8, - 72, 230, 1, 86, 174, 26, 77, 130, 3, 76, 22, 82, 202, 5, 66, 247, 157, 1, - 67, 72, 186, 1, 66, 60, 8, 70, 79, 85, 78, 84, 65, 73, 78, 22, 80, 56, - 12, 83, 69, 77, 73, 67, 73, 82, 67, 85, 76, 65, 82, 154, 1, 81, 246, 2, - 84, 156, 193, 11, 3, 67, 82, 65, 203, 187, 4, 79, 24, 56, 8, 65, 76, 76, - 80, 79, 73, 78, 84, 227, 130, 16, 76, 2, 231, 241, 9, 32, 4, 184, 254, - 14, 5, 65, 73, 78, 84, 66, 163, 141, 1, 69, 2, 237, 190, 7, 5, 32, 65, - 78, 84, 73, 74, 110, 81, 166, 2, 83, 82, 84, 254, 173, 7, 82, 158, 199, - 8, 66, 238, 3, 67, 226, 3, 79, 222, 7, 68, 207, 2, 80, 30, 17, 2, 85, 65, - 30, 48, 6, 68, 82, 65, 78, 84, 32, 163, 142, 16, 82, 28, 74, 70, 60, 2, - 78, 69, 50, 83, 202, 137, 16, 67, 226, 1, 77, 143, 1, 84, 4, 26, 65, 155, - 194, 17, 82, 2, 201, 180, 7, 3, 67, 69, 32, 2, 25, 4, 85, 84, 82, 65, 2, - 247, 204, 18, 76, 4, 158, 220, 10, 77, 215, 175, 5, 84, 6, 164, 187, 7, - 11, 69, 77, 73, 67, 73, 82, 67, 85, 76, 65, 82, 191, 209, 8, 72, 6, 202, - 141, 16, 82, 155, 1, 87, 5, 177, 226, 17, 25, 32, 68, 73, 86, 73, 68, 69, - 68, 32, 66, 89, 32, 72, 79, 82, 73, 90, 79, 78, 84, 65, 76, 32, 82, 85, - 6, 18, 71, 23, 78, 2, 195, 248, 13, 71, 4, 220, 226, 17, 5, 65, 82, 32, - 69, 67, 151, 103, 71, 114, 104, 12, 67, 73, 65, 78, 32, 76, 69, 84, 84, - 69, 82, 32, 232, 1, 5, 68, 73, 65, 78, 32, 183, 252, 17, 73, 58, 210, 1, - 77, 202, 133, 5, 75, 154, 214, 9, 84, 158, 24, 66, 246, 146, 2, 65, 2, - 69, 2, 78, 238, 253, 1, 68, 2, 71, 2, 72, 2, 73, 2, 74, 2, 76, 2, 80, 2, - 81, 2, 82, 2, 83, 2, 85, 2, 87, 2, 88, 3, 90, 5, 219, 132, 19, 77, 54, - 88, 7, 76, 69, 84, 84, 69, 82, 32, 205, 219, 14, 9, 84, 82, 73, 65, 78, - 71, 85, 76, 65, 52, 146, 155, 13, 84, 190, 215, 1, 76, 198, 135, 2, 83, - 238, 11, 65, 2, 69, 2, 78, 238, 253, 1, 66, 2, 67, 2, 68, 2, 70, 2, 71, - 2, 73, 2, 75, 2, 77, 2, 79, 2, 81, 2, 82, 2, 85, 2, 86, 3, 89, 128, 54, - 162, 1, 65, 194, 103, 69, 182, 103, 73, 154, 25, 79, 164, 112, 3, 82, 79, - 32, 234, 3, 85, 204, 70, 7, 89, 65, 78, 77, 65, 82, 32, 190, 160, 15, 86, - 198, 61, 77, 27, 87, 204, 23, 186, 1, 71, 62, 72, 254, 10, 75, 234, 3, - 76, 252, 13, 2, 77, 77, 22, 78, 154, 17, 80, 118, 82, 174, 7, 83, 190, 7, - 84, 184, 36, 3, 89, 65, 78, 204, 129, 1, 3, 88, 73, 77, 227, 243, 15, 67, - 6, 152, 239, 17, 4, 73, 67, 32, 87, 138, 91, 78, 155, 53, 69, 166, 1, 84, - 6, 65, 74, 65, 78, 73, 32, 129, 3, 10, 74, 79, 78, 71, 32, 84, 73, 76, - 69, 32, 78, 38, 76, 162, 2, 83, 139, 136, 13, 65, 72, 88, 6, 69, 84, 84, - 69, 82, 32, 213, 145, 12, 10, 73, 71, 65, 84, 85, 82, 69, 32, 83, 72, 70, - 134, 175, 3, 78, 202, 240, 11, 68, 82, 82, 34, 84, 162, 149, 3, 66, 2, - 67, 2, 71, 2, 74, 2, 75, 2, 80, 138, 69, 72, 2, 76, 2, 77, 2, 83, 2, 86, - 186, 2, 65, 2, 69, 2, 73, 2, 79, 3, 85, 4, 222, 232, 6, 69, 253, 245, 7, - 5, 73, 71, 78, 32, 78, 88, 236, 1, 2, 66, 65, 38, 69, 46, 70, 46, 78, 42, - 79, 46, 80, 22, 83, 118, 84, 194, 1, 87, 112, 5, 71, 82, 69, 69, 78, 0, - 3, 82, 69, 68, 220, 131, 6, 3, 65, 85, 84, 222, 21, 74, 209, 175, 11, 11, - 67, 72, 82, 89, 83, 65, 78, 84, 72, 69, 77, 4, 162, 158, 1, 77, 251, 215, - 17, 67, 8, 228, 2, 4, 73, 71, 72, 84, 195, 1, 65, 12, 172, 2, 2, 73, 86, - 13, 3, 79, 85, 82, 8, 192, 1, 2, 79, 82, 65, 2, 73, 78, 8, 218, 1, 78, - 225, 224, 11, 3, 82, 67, 72, 2, 191, 204, 17, 76, 18, 88, 2, 79, 85, 76, - 4, 69, 86, 69, 78, 0, 2, 73, 88, 234, 152, 12, 85, 255, 199, 1, 80, 2, - 157, 2, 2, 84, 72, 12, 36, 3, 72, 82, 69, 13, 2, 87, 79, 6, 11, 69, 6, - 25, 4, 32, 79, 70, 32, 6, 46, 67, 241, 243, 6, 5, 66, 65, 77, 66, 79, 4, - 236, 135, 6, 2, 73, 82, 153, 234, 10, 5, 72, 65, 82, 65, 67, 6, 50, 69, - 60, 4, 72, 73, 84, 69, 151, 186, 17, 73, 2, 17, 2, 83, 84, 2, 17, 2, 32, - 87, 2, 171, 228, 17, 73, 2, 17, 2, 32, 68, 2, 215, 185, 17, 82, 52, 52, - 5, 65, 83, 65, 82, 32, 165, 135, 15, 2, 69, 77, 50, 162, 1, 69, 40, 7, - 76, 69, 84, 84, 69, 82, 32, 152, 1, 5, 80, 65, 83, 83, 73, 32, 11, 86, - 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 225, 231, 18, 3, 65, 78, 71, 2, - 129, 240, 15, 5, 78, 68, 32, 79, 70, 36, 234, 244, 16, 78, 222, 250, 1, - 66, 2, 67, 2, 68, 2, 71, 2, 74, 2, 75, 2, 76, 2, 77, 2, 80, 2, 82, 2, 83, - 2, 84, 2, 86, 2, 89, 187, 2, 65, 2, 11, 77, 2, 135, 152, 18, 66, 8, 198, - 240, 18, 69, 2, 73, 2, 79, 3, 85, 246, 1, 80, 7, 65, 89, 65, 76, 65, 77, - 32, 176, 11, 2, 69, 32, 225, 1, 3, 84, 69, 83, 236, 1, 198, 1, 68, 44, 9, - 70, 82, 65, 67, 84, 73, 79, 78, 32, 240, 1, 7, 76, 69, 84, 84, 69, 82, - 32, 164, 5, 7, 78, 85, 77, 66, 69, 82, 32, 36, 5, 83, 73, 71, 78, 32, - 154, 187, 13, 86, 239, 201, 1, 65, 22, 216, 166, 8, 2, 65, 84, 163, 211, - 8, 73, 26, 56, 4, 79, 78, 69, 32, 121, 6, 84, 72, 82, 69, 69, 32, 18, 82, - 84, 178, 131, 5, 83, 130, 132, 8, 70, 62, 79, 146, 222, 3, 69, 46, 72, - 47, 81, 4, 186, 138, 13, 87, 255, 220, 3, 69, 8, 202, 131, 5, 83, 198, - 135, 8, 69, 110, 84, 179, 220, 3, 81, 132, 1, 226, 1, 65, 82, 67, 158, 1, - 68, 78, 84, 82, 86, 150, 137, 13, 78, 182, 128, 2, 76, 38, 82, 134, 6, - 85, 206, 141, 1, 79, 238, 60, 73, 182, 196, 1, 83, 82, 66, 2, 71, 2, 74, - 2, 75, 2, 80, 162, 7, 69, 234, 61, 72, 2, 77, 3, 89, 11, 164, 163, 16, 7, - 82, 67, 72, 65, 73, 67, 32, 206, 198, 2, 65, 2, 73, 3, 85, 22, 26, 72, - 139, 233, 18, 65, 20, 44, 5, 73, 76, 76, 85, 32, 219, 232, 18, 65, 18, - 190, 255, 12, 76, 174, 235, 3, 78, 146, 197, 1, 82, 222, 56, 75, 2, 77, - 3, 89, 10, 136, 222, 10, 4, 79, 84, 32, 82, 190, 194, 7, 68, 138, 69, 72, - 187, 2, 65, 10, 38, 84, 222, 228, 18, 72, 187, 2, 65, 6, 218, 228, 18, - 72, 2, 84, 187, 2, 65, 12, 242, 227, 3, 69, 158, 172, 11, 79, 223, 214, - 3, 65, 6, 214, 137, 13, 79, 223, 134, 4, 84, 18, 50, 67, 114, 86, 174, - 138, 15, 65, 251, 149, 3, 80, 6, 54, 79, 120, 5, 73, 82, 67, 85, 76, 223, - 198, 14, 65, 2, 197, 185, 13, 9, 77, 66, 73, 78, 73, 78, 71, 32, 65, 6, - 60, 9, 69, 82, 84, 73, 67, 65, 76, 32, 66, 179, 161, 18, 73, 2, 177, 138, - 15, 2, 65, 82, 8, 80, 12, 87, 73, 84, 72, 32, 83, 84, 82, 79, 75, 69, 32, - 70, 65, 151, 220, 17, 83, 4, 64, 10, 65, 78, 68, 32, 77, 65, 76, 69, 32, - 65, 151, 220, 17, 83, 2, 25, 4, 78, 68, 32, 70, 2, 11, 69, 2, 11, 77, 2, - 191, 206, 7, 65, 2, 243, 158, 17, 69, 2, 167, 221, 16, 79, 185, 1, 210, - 1, 32, 220, 2, 5, 68, 65, 73, 67, 32, 224, 3, 8, 73, 67, 72, 65, 69, 65, - 78, 32, 222, 8, 83, 156, 166, 2, 3, 85, 65, 76, 182, 223, 10, 65, 240, - 167, 1, 8, 84, 69, 76, 80, 73, 69, 67, 69, 235, 132, 4, 71, 12, 132, 1, - 3, 73, 78, 32, 128, 1, 5, 87, 73, 84, 72, 32, 136, 147, 2, 3, 68, 65, 78, - 161, 136, 13, 8, 65, 78, 68, 32, 87, 79, 77, 65, 4, 172, 136, 10, 19, 66, - 85, 83, 73, 78, 69, 83, 83, 32, 83, 85, 73, 84, 32, 76, 69, 86, 73, 84, - 189, 151, 1, 4, 84, 85, 88, 69, 4, 192, 238, 13, 8, 71, 85, 65, 32, 80, - 73, 32, 77, 205, 163, 3, 4, 84, 85, 82, 66, 58, 112, 4, 65, 70, 70, 82, - 28, 7, 76, 69, 84, 84, 69, 82, 32, 132, 180, 14, 3, 86, 79, 67, 226, 72, - 71, 251, 25, 80, 2, 173, 243, 17, 2, 73, 67, 50, 82, 65, 176, 1, 2, 68, - 85, 2, 85, 28, 3, 72, 65, 76, 22, 73, 235, 147, 18, 75, 38, 154, 1, 75, - 130, 242, 12, 84, 250, 191, 1, 83, 130, 217, 3, 73, 226, 79, 66, 2, 68, - 2, 71, 2, 72, 2, 76, 2, 77, 2, 78, 2, 80, 2, 81, 2, 82, 3, 90, 5, 159, - 216, 18, 83, 2, 237, 255, 7, 2, 83, 72, 2, 239, 215, 18, 81, 4, 146, 218, - 18, 78, 3, 84, 102, 216, 1, 7, 76, 69, 84, 84, 69, 82, 32, 194, 4, 78, - 80, 12, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 32, 220, 1, 4, 83, - 73, 71, 78, 173, 196, 10, 16, 65, 66, 66, 82, 69, 86, 73, 65, 84, 73, 79, - 78, 32, 77, 65, 82, 72, 218, 1, 65, 46, 66, 38, 68, 30, 71, 30, 74, 2, - 90, 30, 75, 30, 81, 38, 83, 50, 84, 54, 88, 210, 159, 6, 76, 134, 206, 1, - 82, 246, 221, 2, 89, 198, 207, 1, 72, 190, 184, 5, 78, 134, 2, 87, 218, - 103, 70, 2, 80, 171, 4, 77, 6, 194, 204, 10, 76, 122, 65, 179, 137, 7, - 89, 4, 186, 244, 12, 72, 227, 220, 3, 69, 4, 178, 161, 6, 65, 23, 72, 4, - 234, 203, 10, 72, 15, 73, 4, 166, 204, 10, 72, 15, 65, 4, 150, 162, 12, - 72, 15, 65, 4, 134, 161, 6, 72, 131, 129, 6, 79, 8, 238, 200, 10, 83, - 154, 3, 65, 131, 137, 7, 72, 6, 130, 160, 6, 72, 178, 175, 10, 69, 219, - 134, 1, 65, 4, 254, 160, 12, 65, 3, 79, 10, 33, 6, 85, 77, 66, 69, 82, - 32, 10, 174, 203, 10, 79, 58, 84, 131, 203, 2, 70, 14, 80, 2, 68, 79, - 116, 3, 76, 73, 78, 242, 162, 5, 70, 230, 219, 11, 84, 167, 10, 83, 6, - 54, 84, 13, 9, 85, 66, 76, 69, 32, 68, 79, 84, 32, 5, 11, 32, 2, 25, 4, - 87, 73, 84, 72, 2, 151, 193, 2, 73, 2, 231, 203, 3, 69, 2, 191, 163, 17, - 32, 2, 11, 32, 2, 173, 186, 18, 2, 83, 72, 4, 92, 17, 32, 83, 89, 77, 66, - 79, 76, 32, 70, 79, 82, 32, 76, 73, 71, 72, 84, 191, 215, 10, 76, 2, 231, - 135, 15, 72, 142, 1, 142, 1, 65, 20, 5, 67, 72, 69, 78, 32, 140, 160, 6, - 4, 82, 73, 65, 71, 249, 175, 11, 13, 84, 73, 65, 76, 32, 65, 82, 84, 83, - 32, 85, 78, 73, 2, 151, 157, 5, 67, 136, 1, 152, 1, 7, 76, 69, 84, 84, - 69, 82, 32, 194, 1, 83, 236, 2, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, - 78, 32, 222, 252, 17, 72, 225, 5, 4, 77, 65, 82, 75, 60, 254, 3, 84, 206, - 148, 2, 68, 218, 183, 14, 78, 214, 181, 1, 67, 2, 75, 2, 80, 2, 83, 2, - 90, 138, 69, 45, 2, 66, 2, 71, 2, 72, 2, 74, 2, 76, 2, 77, 2, 82, 2, 87, - 2, 89, 187, 2, 65, 62, 96, 4, 73, 71, 78, 32, 37, 16, 85, 66, 74, 79, 73, - 78, 69, 68, 32, 76, 69, 84, 84, 69, 82, 32, 4, 178, 173, 14, 67, 235, - 216, 3, 65, 58, 182, 1, 84, 206, 148, 2, 68, 218, 183, 14, 78, 214, 181, - 1, 67, 2, 75, 2, 80, 2, 83, 2, 90, 138, 69, 66, 2, 71, 2, 72, 2, 74, 2, - 76, 2, 77, 2, 82, 2, 87, 2, 89, 187, 2, 65, 8, 246, 129, 18, 83, 138, 69, - 72, 187, 2, 65, 10, 210, 198, 18, 65, 186, 2, 69, 2, 73, 2, 79, 3, 85, - 156, 1, 120, 11, 65, 82, 65, 77, 32, 71, 79, 78, 68, 73, 32, 232, 5, 3, - 67, 85, 76, 64, 5, 75, 32, 87, 79, 82, 235, 255, 17, 85, 150, 1, 100, 7, - 76, 69, 84, 84, 69, 82, 32, 178, 2, 82, 56, 5, 83, 73, 71, 78, 32, 82, - 86, 171, 207, 16, 68, 94, 210, 1, 74, 42, 84, 250, 230, 14, 65, 38, 68, - 214, 6, 85, 186, 202, 1, 73, 42, 76, 190, 195, 1, 75, 38, 78, 46, 83, 82, - 66, 2, 67, 2, 71, 2, 80, 138, 69, 72, 2, 77, 2, 82, 2, 86, 2, 89, 186, 2, - 69, 3, 79, 6, 182, 194, 18, 78, 38, 72, 187, 2, 65, 10, 170, 253, 17, 84, - 138, 69, 72, 2, 82, 187, 2, 65, 4, 32, 2, 65, 45, 143, 232, 14, 69, 2, - 199, 255, 17, 75, 10, 230, 176, 1, 67, 234, 202, 12, 72, 178, 43, 78, - 150, 227, 1, 86, 247, 244, 1, 65, 22, 26, 79, 251, 134, 16, 73, 20, 45, - 9, 87, 69, 76, 32, 83, 73, 71, 78, 32, 20, 74, 86, 250, 234, 14, 65, 38, - 85, 186, 202, 1, 73, 198, 140, 2, 69, 3, 79, 2, 193, 198, 7, 6, 79, 67, - 65, 76, 73, 67, 2, 197, 136, 18, 11, 73, 78, 69, 32, 79, 82, 68, 73, 78, - 65, 76, 2, 231, 171, 17, 75, 226, 15, 76, 10, 72, 69, 77, 65, 84, 73, 67, - 65, 76, 32, 205, 219, 14, 3, 69, 32, 68, 224, 15, 252, 1, 5, 66, 79, 76, - 68, 32, 168, 6, 14, 68, 79, 85, 66, 76, 69, 45, 83, 84, 82, 85, 67, 75, - 32, 238, 1, 70, 164, 2, 7, 73, 84, 65, 76, 73, 67, 32, 180, 3, 10, 77, - 79, 78, 79, 83, 80, 65, 67, 69, 32, 40, 2, 82, 73, 36, 3, 76, 69, 70, - 167, 1, 83, 160, 5, 176, 1, 8, 67, 65, 80, 73, 84, 65, 76, 32, 130, 2, - 83, 210, 14, 73, 210, 3, 69, 38, 75, 38, 78, 30, 80, 98, 82, 242, 5, 84, - 56, 7, 70, 82, 65, 75, 84, 85, 82, 247, 172, 16, 68, 104, 190, 4, 68, - 174, 15, 84, 174, 4, 65, 22, 66, 2, 90, 42, 69, 98, 71, 22, 73, 22, 75, - 34, 76, 22, 79, 50, 80, 42, 82, 22, 83, 70, 85, 214, 197, 1, 67, 250, - 132, 13, 77, 2, 78, 186, 202, 1, 88, 198, 140, 2, 70, 2, 72, 2, 74, 2, - 81, 2, 86, 2, 87, 3, 89, 208, 1, 60, 5, 77, 65, 76, 76, 32, 201, 25, 5, - 67, 82, 73, 80, 84, 104, 250, 1, 68, 218, 19, 65, 22, 66, 2, 90, 42, 69, - 38, 70, 62, 71, 22, 73, 22, 75, 34, 76, 22, 79, 50, 80, 42, 82, 22, 83, - 34, 84, 38, 85, 214, 197, 1, 67, 250, 132, 13, 77, 2, 78, 186, 202, 1, - 88, 198, 140, 2, 72, 2, 74, 2, 81, 2, 86, 2, 87, 3, 89, 7, 26, 73, 203, - 251, 14, 69, 2, 247, 213, 1, 71, 110, 68, 8, 67, 65, 80, 73, 84, 65, 76, - 32, 150, 23, 83, 183, 172, 16, 68, 38, 206, 183, 18, 65, 2, 66, 2, 68, 2, - 69, 2, 70, 2, 71, 2, 73, 2, 74, 2, 75, 2, 76, 2, 77, 2, 79, 2, 83, 2, 84, - 2, 85, 2, 86, 2, 87, 2, 88, 3, 89, 96, 52, 7, 82, 65, 75, 84, 85, 82, 32, - 179, 139, 7, 65, 94, 52, 8, 67, 65, 80, 73, 84, 65, 76, 32, 131, 21, 83, - 42, 186, 181, 18, 65, 2, 66, 2, 68, 2, 69, 2, 70, 2, 71, 2, 74, 2, 75, 2, + 91, 83, 11, 11, 32, 8, 164, 1, 7, 84, 72, 82, 79, 85, 71, 72, 220, 162, + 3, 10, 87, 73, 84, 72, 32, 68, 79, 85, 66, 76, 240, 250, 5, 9, 79, 86, + 69, 82, 32, 76, 79, 78, 71, 151, 192, 7, 70, 2, 151, 188, 18, 32, 4, 37, + 7, 79, 85, 66, 76, 69, 32, 65, 4, 25, 4, 82, 82, 79, 87, 5, 133, 221, 16, + 2, 32, 70, 4, 240, 156, 9, 4, 79, 86, 69, 82, 33, 11, 65, 66, 79, 86, 69, + 32, 83, 72, 79, 82, 84, 2, 241, 136, 8, 3, 81, 85, 73, 6, 92, 5, 73, 79, + 78, 32, 66, 220, 172, 18, 9, 32, 79, 70, 32, 70, 79, 82, 84, 85, 215, 93, + 85, 2, 227, 151, 10, 79, 4, 38, 76, 185, 172, 14, 3, 72, 79, 84, 2, 189, + 138, 18, 2, 69, 84, 226, 1, 34, 32, 229, 1, 3, 69, 82, 32, 14, 138, 1, + 66, 192, 239, 10, 11, 68, 79, 85, 66, 76, 69, 32, 80, 82, 73, 77, 242, + 187, 6, 65, 244, 115, 6, 75, 65, 86, 89, 75, 65, 163, 11, 76, 4, 38, 82, + 225, 155, 5, 3, 65, 84, 84, 2, 133, 176, 18, 7, 73, 71, 72, 84, 78, 69, + 83, 212, 1, 158, 1, 72, 140, 2, 5, 76, 69, 70, 84, 32, 128, 3, 6, 82, 73, + 71, 72, 84, 32, 214, 160, 16, 66, 74, 67, 74, 70, 234, 10, 77, 150, 2, + 79, 170, 18, 83, 67, 84, 20, 84, 4, 65, 76, 70, 32, 213, 222, 7, 11, 79, + 82, 73, 90, 79, 78, 84, 65, 76, 32, 82, 18, 252, 201, 7, 9, 65, 78, 68, + 32, 85, 80, 80, 69, 82, 32, 7, 73, 78, 86, 69, 82, 83, 69, 154, 222, 8, + 72, 230, 1, 86, 174, 26, 77, 130, 3, 76, 22, 82, 202, 5, 66, 227, 158, 1, + 67, 74, 154, 1, 66, 62, 70, 74, 80, 56, 12, 83, 69, 77, 73, 67, 73, 82, + 67, 85, 76, 65, 82, 222, 1, 81, 246, 2, 84, 164, 235, 11, 3, 67, 82, 65, + 135, 191, 4, 79, 24, 108, 8, 65, 76, 76, 80, 79, 73, 78, 84, 235, 176, + 16, 76, 4, 48, 7, 79, 85, 78, 84, 65, 73, 78, 251, 1, 76, 2, 175, 156, + 10, 32, 4, 240, 170, 15, 5, 65, 73, 78, 84, 66, 243, 142, 1, 69, 2, 173, + 231, 7, 5, 32, 65, 78, 84, 73, 76, 128, 1, 2, 70, 76, 50, 81, 166, 2, 83, + 82, 84, 250, 213, 7, 82, 230, 204, 8, 66, 238, 3, 67, 226, 3, 79, 222, 7, + 68, 207, 2, 80, 2, 233, 143, 17, 7, 65, 84, 84, 69, 78, 69, 68, 30, 17, + 2, 85, 65, 30, 48, 6, 68, 82, 65, 78, 84, 32, 231, 187, 16, 82, 28, 74, + 70, 60, 2, 78, 69, 50, 83, 142, 183, 16, 67, 226, 1, 77, 143, 1, 84, 4, + 26, 65, 227, 240, 17, 82, 2, 197, 220, 7, 3, 67, 69, 32, 2, 25, 4, 85, + 84, 82, 65, 2, 183, 254, 18, 76, 4, 134, 134, 11, 77, 179, 179, 5, 84, 6, + 160, 227, 7, 11, 69, 77, 73, 67, 73, 82, 67, 85, 76, 65, 82, 135, 215, 8, + 72, 6, 142, 187, 16, 82, 155, 1, 87, 5, 177, 147, 18, 25, 32, 68, 73, 86, + 73, 68, 69, 68, 32, 66, 89, 32, 72, 79, 82, 73, 90, 79, 78, 84, 65, 76, + 32, 82, 85, 6, 18, 71, 23, 78, 2, 147, 164, 14, 71, 4, 220, 147, 18, 5, + 65, 82, 32, 69, 67, 215, 103, 71, 114, 104, 12, 67, 73, 65, 78, 32, 76, + 69, 84, 84, 69, 82, 32, 232, 1, 5, 68, 73, 65, 78, 32, 247, 173, 18, 73, + 58, 210, 1, 77, 206, 171, 5, 75, 234, 219, 9, 84, 146, 24, 66, 214, 149, + 2, 65, 2, 69, 2, 78, 134, 129, 2, 68, 2, 71, 2, 72, 2, 73, 2, 74, 2, 76, + 2, 80, 2, 81, 2, 82, 2, 83, 2, 85, 2, 87, 2, 88, 3, 90, 5, 155, 182, 19, + 77, 54, 88, 7, 76, 69, 84, 84, 69, 82, 32, 161, 135, 15, 9, 84, 82, 73, + 65, 78, 71, 85, 76, 65, 52, 242, 198, 13, 84, 166, 215, 1, 76, 166, 138, + 2, 83, 238, 11, 65, 2, 69, 2, 78, 134, 129, 2, 66, 2, 67, 2, 68, 2, 70, + 2, 71, 2, 73, 2, 75, 2, 77, 2, 79, 2, 81, 2, 82, 2, 85, 2, 86, 3, 89, + 148, 56, 162, 1, 65, 206, 104, 69, 202, 104, 73, 166, 25, 79, 144, 124, + 3, 82, 79, 32, 238, 3, 85, 160, 94, 7, 89, 65, 78, 77, 65, 82, 32, 142, + 172, 15, 86, 198, 61, 77, 27, 87, 206, 23, 186, 1, 71, 62, 72, 254, 10, + 75, 234, 3, 76, 252, 13, 2, 77, 77, 22, 78, 154, 17, 80, 118, 82, 174, 7, + 83, 190, 7, 84, 196, 37, 3, 89, 65, 78, 228, 130, 1, 3, 88, 73, 77, 191, + 162, 16, 67, 6, 216, 160, 18, 4, 73, 67, 32, 87, 138, 91, 78, 155, 53, + 69, 166, 1, 84, 6, 65, 74, 65, 78, 73, 32, 129, 3, 10, 74, 79, 78, 71, + 32, 84, 73, 76, 69, 32, 78, 38, 76, 162, 2, 83, 235, 179, 13, 65, 72, 88, + 6, 69, 84, 84, 69, 82, 32, 213, 189, 12, 10, 73, 71, 65, 84, 85, 82, 69, + 32, 83, 72, 70, 246, 212, 3, 78, 170, 247, 11, 68, 82, 82, 34, 84, 146, + 154, 3, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 138, 69, 72, 2, 76, 2, 77, + 2, 83, 2, 86, 186, 2, 65, 2, 69, 2, 73, 2, 79, 3, 85, 4, 234, 143, 7, 69, + 185, 250, 7, 5, 73, 71, 78, 32, 78, 88, 236, 1, 2, 66, 65, 38, 69, 46, + 70, 46, 78, 42, 79, 46, 80, 22, 83, 118, 84, 194, 1, 87, 112, 5, 71, 82, + 69, 69, 78, 0, 3, 82, 69, 68, 244, 170, 6, 3, 65, 85, 84, 238, 21, 74, + 169, 185, 11, 11, 67, 72, 82, 89, 83, 65, 78, 84, 72, 69, 77, 4, 170, + 160, 1, 77, 179, 135, 18, 67, 8, 228, 2, 4, 73, 71, 72, 84, 195, 1, 65, + 12, 172, 2, 2, 73, 86, 13, 3, 79, 85, 82, 8, 192, 1, 2, 79, 82, 65, 2, + 73, 78, 8, 218, 1, 78, 225, 140, 12, 3, 82, 67, 72, 2, 191, 253, 17, 76, + 18, 88, 2, 79, 85, 76, 4, 69, 86, 69, 78, 0, 2, 73, 88, 234, 196, 12, 85, + 215, 199, 1, 80, 2, 157, 2, 2, 84, 72, 12, 36, 3, 72, 82, 69, 13, 2, 87, + 79, 6, 11, 69, 6, 25, 4, 32, 79, 70, 32, 6, 46, 67, 177, 155, 7, 5, 66, + 65, 77, 66, 79, 4, 132, 175, 6, 2, 73, 82, 169, 241, 10, 5, 72, 65, 82, + 65, 67, 6, 50, 69, 60, 4, 72, 73, 84, 69, 211, 232, 17, 73, 2, 17, 2, 83, + 84, 2, 17, 2, 32, 87, 2, 235, 149, 18, 73, 2, 17, 2, 32, 68, 2, 147, 232, + 17, 82, 52, 52, 5, 65, 83, 65, 82, 32, 245, 179, 15, 2, 69, 77, 50, 162, + 1, 69, 40, 7, 76, 69, 84, 84, 69, 82, 32, 152, 1, 5, 80, 65, 83, 83, 73, + 32, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 161, 153, 19, 3, 65, + 78, 71, 2, 197, 157, 16, 5, 78, 68, 32, 79, 70, 36, 146, 163, 17, 78, + 246, 253, 1, 66, 2, 67, 2, 68, 2, 71, 2, 74, 2, 75, 2, 76, 2, 77, 2, 80, + 2, 82, 2, 83, 2, 84, 2, 86, 2, 89, 187, 2, 65, 2, 11, 77, 2, 199, 201, + 18, 66, 8, 134, 162, 19, 69, 2, 73, 2, 79, 3, 85, 246, 1, 80, 7, 65, 89, + 65, 76, 65, 77, 32, 176, 11, 2, 69, 32, 225, 1, 3, 84, 69, 83, 236, 1, + 198, 1, 68, 44, 9, 70, 82, 65, 67, 84, 73, 79, 78, 32, 240, 1, 7, 76, 69, + 84, 84, 69, 82, 32, 164, 5, 7, 78, 85, 77, 66, 69, 82, 32, 36, 5, 83, 73, + 71, 78, 32, 138, 231, 13, 86, 207, 202, 1, 65, 22, 208, 208, 8, 2, 65, + 84, 211, 215, 8, 73, 26, 56, 4, 79, 78, 69, 32, 121, 6, 84, 72, 82, 69, + 69, 32, 18, 82, 84, 234, 169, 5, 83, 170, 137, 8, 70, 62, 79, 218, 224, + 3, 69, 46, 72, 47, 81, 4, 154, 182, 13, 87, 199, 223, 3, 69, 8, 130, 170, + 5, 83, 238, 140, 8, 69, 110, 84, 251, 222, 3, 81, 132, 1, 226, 1, 65, 82, + 67, 158, 1, 68, 78, 84, 82, 86, 246, 180, 13, 78, 166, 129, 2, 76, 38, + 82, 134, 6, 85, 194, 142, 1, 79, 202, 61, 73, 214, 199, 1, 83, 82, 66, 2, + 71, 2, 74, 2, 75, 2, 80, 162, 7, 69, 234, 61, 72, 2, 77, 3, 89, 11, 232, + 208, 16, 7, 82, 67, 72, 65, 73, 67, 32, 202, 202, 2, 65, 2, 73, 3, 85, + 22, 26, 72, 203, 154, 19, 65, 20, 44, 5, 73, 76, 76, 85, 32, 155, 154, + 19, 65, 18, 158, 171, 13, 76, 246, 237, 3, 78, 170, 200, 1, 82, 222, 56, + 75, 2, 77, 3, 89, 10, 128, 136, 11, 4, 79, 84, 32, 82, 134, 202, 7, 68, + 138, 69, 72, 187, 2, 65, 10, 38, 84, 158, 150, 19, 72, 187, 2, 65, 6, + 154, 150, 19, 72, 2, 84, 187, 2, 65, 12, 142, 138, 4, 69, 210, 178, 11, + 79, 207, 219, 3, 65, 6, 182, 181, 13, 79, 175, 137, 4, 84, 18, 50, 67, + 114, 86, 254, 182, 15, 65, 235, 154, 3, 80, 6, 54, 79, 120, 5, 73, 82, + 67, 85, 76, 167, 242, 14, 65, 2, 181, 229, 13, 9, 77, 66, 73, 78, 73, 78, + 71, 32, 65, 6, 60, 9, 69, 82, 84, 73, 67, 65, 76, 32, 66, 243, 210, 18, + 73, 2, 129, 183, 15, 2, 65, 82, 8, 80, 12, 87, 73, 84, 72, 32, 83, 84, + 82, 79, 75, 69, 32, 70, 65, 215, 141, 18, 83, 4, 64, 10, 65, 78, 68, 32, + 77, 65, 76, 69, 32, 65, 215, 141, 18, 83, 2, 25, 4, 78, 68, 32, 70, 2, + 11, 69, 2, 11, 77, 2, 135, 247, 7, 65, 2, 175, 205, 17, 69, 2, 207, 139, + 17, 79, 185, 1, 210, 1, 32, 220, 2, 5, 68, 65, 73, 67, 32, 224, 3, 8, 73, + 67, 72, 65, 69, 65, 78, 32, 222, 8, 83, 180, 180, 2, 3, 85, 65, 76, 242, + 252, 10, 65, 240, 167, 1, 8, 84, 69, 76, 80, 73, 69, 67, 69, 215, 138, 4, + 71, 12, 132, 1, 3, 73, 78, 32, 128, 1, 5, 87, 73, 84, 72, 32, 220, 160, + 2, 3, 68, 65, 78, 149, 167, 13, 8, 65, 78, 68, 32, 87, 79, 77, 65, 4, + 176, 178, 10, 19, 66, 85, 83, 73, 78, 69, 83, 83, 32, 83, 85, 73, 84, 32, + 76, 69, 86, 73, 84, 193, 151, 1, 4, 84, 85, 88, 69, 4, 144, 154, 14, 8, + 71, 85, 65, 32, 80, 73, 32, 77, 197, 166, 3, 4, 84, 85, 82, 66, 58, 112, + 4, 65, 70, 70, 82, 28, 7, 76, 69, 84, 84, 69, 82, 32, 216, 223, 14, 3, + 86, 79, 67, 222, 73, 71, 243, 25, 80, 2, 237, 164, 18, 2, 73, 67, 50, 82, + 65, 176, 1, 2, 68, 85, 2, 85, 28, 3, 72, 65, 76, 22, 73, 171, 197, 18, + 75, 38, 154, 1, 75, 226, 157, 13, 84, 238, 191, 1, 83, 238, 222, 3, 73, + 226, 79, 66, 2, 68, 2, 71, 2, 72, 2, 76, 2, 77, 2, 78, 2, 80, 2, 81, 2, + 82, 3, 90, 5, 223, 137, 19, 83, 2, 173, 168, 8, 2, 83, 72, 2, 175, 137, + 19, 81, 4, 210, 139, 19, 78, 3, 84, 102, 216, 1, 7, 76, 69, 84, 84, 69, + 82, 32, 194, 4, 78, 80, 12, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, + 32, 220, 1, 4, 83, 73, 71, 78, 165, 238, 10, 16, 65, 66, 66, 82, 69, 86, + 73, 65, 84, 73, 79, 78, 32, 77, 65, 82, 72, 218, 1, 65, 46, 66, 38, 68, + 30, 71, 30, 74, 2, 90, 30, 75, 30, 81, 38, 83, 50, 84, 54, 88, 250, 198, + 6, 76, 158, 207, 1, 82, 174, 223, 2, 89, 206, 209, 1, 72, 254, 189, 5, + 78, 134, 2, 87, 218, 103, 70, 2, 80, 171, 4, 77, 6, 186, 246, 10, 76, + 122, 65, 251, 144, 7, 89, 4, 154, 160, 13, 72, 171, 223, 3, 69, 4, 218, + 200, 6, 65, 23, 72, 4, 226, 245, 10, 72, 15, 73, 4, 158, 246, 10, 72, 15, + 65, 4, 150, 206, 12, 72, 15, 65, 4, 174, 200, 6, 72, 219, 133, 6, 79, 8, + 230, 242, 10, 83, 154, 3, 65, 203, 144, 7, 72, 6, 170, 199, 6, 72, 178, + 182, 10, 69, 243, 137, 1, 65, 4, 254, 204, 12, 65, 3, 79, 10, 33, 6, 85, + 77, 66, 69, 82, 32, 10, 166, 245, 10, 79, 58, 84, 235, 204, 2, 70, 14, + 80, 2, 68, 79, 116, 3, 76, 73, 78, 134, 202, 5, 70, 130, 227, 11, 84, + 191, 10, 83, 6, 54, 84, 13, 9, 85, 66, 76, 69, 32, 68, 79, 84, 32, 5, 11, + 32, 2, 25, 4, 87, 73, 84, 72, 2, 195, 208, 2, 73, 2, 131, 242, 3, 69, 2, + 191, 212, 17, 32, 2, 11, 32, 2, 237, 235, 18, 2, 83, 72, 4, 92, 17, 32, + 83, 89, 77, 66, 79, 76, 32, 70, 79, 82, 32, 76, 73, 71, 72, 84, 183, 129, + 11, 76, 2, 175, 180, 15, 72, 142, 1, 142, 1, 65, 20, 5, 67, 72, 69, 78, + 32, 180, 199, 6, 4, 82, 73, 65, 71, 145, 186, 11, 13, 84, 73, 65, 76, 32, + 65, 82, 84, 83, 32, 85, 78, 73, 2, 171, 196, 5, 67, 136, 1, 152, 1, 7, + 76, 69, 84, 84, 69, 82, 32, 194, 1, 83, 236, 2, 11, 86, 79, 87, 69, 76, + 32, 83, 73, 71, 78, 32, 158, 174, 18, 72, 225, 5, 4, 77, 65, 82, 75, 60, + 254, 3, 84, 230, 162, 2, 68, 234, 215, 14, 78, 238, 184, 1, 67, 2, 75, 2, + 80, 2, 83, 2, 90, 138, 69, 45, 2, 66, 2, 71, 2, 72, 2, 74, 2, 76, 2, 77, + 2, 82, 2, 87, 2, 89, 187, 2, 65, 62, 96, 4, 73, 71, 78, 32, 37, 16, 85, + 66, 74, 79, 73, 78, 69, 68, 32, 76, 69, 84, 84, 69, 82, 32, 4, 250, 216, + 14, 67, 227, 222, 3, 65, 58, 182, 1, 84, 230, 162, 2, 68, 234, 215, 14, + 78, 238, 184, 1, 67, 2, 75, 2, 80, 2, 83, 2, 90, 138, 69, 66, 2, 71, 2, + 72, 2, 74, 2, 76, 2, 77, 2, 82, 2, 87, 2, 89, 187, 2, 65, 8, 182, 179, + 18, 83, 138, 69, 72, 187, 2, 65, 10, 146, 248, 18, 65, 186, 2, 69, 2, 73, + 2, 79, 3, 85, 156, 1, 120, 11, 65, 82, 65, 77, 32, 71, 79, 78, 68, 73, + 32, 232, 5, 3, 67, 85, 76, 64, 5, 75, 32, 87, 79, 82, 171, 177, 18, 85, + 150, 1, 100, 7, 76, 69, 84, 84, 69, 82, 32, 178, 2, 82, 56, 5, 83, 73, + 71, 78, 32, 82, 86, 211, 253, 16, 68, 94, 210, 1, 74, 42, 84, 202, 147, + 15, 65, 38, 68, 214, 6, 85, 138, 204, 1, 73, 42, 76, 222, 198, 1, 75, 38, + 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 80, 138, 69, 72, 2, 77, 2, 82, 2, + 86, 2, 89, 186, 2, 69, 3, 79, 6, 246, 243, 18, 78, 38, 72, 187, 2, 65, + 10, 234, 174, 18, 84, 138, 69, 72, 2, 82, 187, 2, 65, 4, 32, 2, 65, 45, + 223, 148, 15, 69, 2, 135, 177, 18, 75, 10, 146, 179, 1, 67, 146, 244, 12, + 72, 166, 43, 78, 146, 229, 1, 86, 243, 248, 1, 65, 22, 26, 79, 191, 180, + 16, 73, 20, 45, 9, 87, 69, 76, 32, 83, 73, 71, 78, 32, 20, 74, 86, 202, + 151, 15, 65, 38, 85, 138, 204, 1, 73, 230, 143, 2, 69, 3, 79, 2, 137, + 239, 7, 6, 79, 67, 65, 76, 73, 67, 2, 133, 186, 18, 11, 73, 78, 69, 32, + 79, 82, 68, 73, 78, 65, 76, 2, 167, 221, 17, 75, 228, 15, 76, 10, 72, 69, + 77, 65, 84, 73, 67, 65, 76, 32, 157, 136, 15, 3, 69, 32, 68, 226, 15, + 252, 1, 5, 66, 79, 76, 68, 32, 152, 6, 14, 68, 79, 85, 66, 76, 69, 45, + 83, 84, 82, 85, 67, 75, 32, 238, 1, 70, 164, 2, 7, 73, 84, 65, 76, 73, + 67, 32, 200, 4, 10, 77, 79, 78, 79, 83, 80, 65, 67, 69, 32, 40, 2, 82, + 73, 36, 3, 76, 69, 70, 167, 1, 83, 160, 5, 176, 1, 8, 67, 65, 80, 73, 84, + 65, 76, 32, 250, 1, 83, 222, 15, 73, 202, 3, 69, 38, 75, 38, 78, 30, 80, + 86, 82, 142, 6, 84, 56, 7, 70, 82, 65, 75, 84, 85, 82, 147, 218, 16, 68, + 104, 174, 4, 68, 186, 16, 84, 154, 4, 65, 22, 66, 2, 90, 22, 67, 42, 69, + 94, 71, 22, 73, 22, 75, 34, 76, 22, 79, 50, 80, 42, 82, 22, 83, 70, 85, + 166, 246, 14, 77, 2, 78, 138, 204, 1, 88, 230, 143, 2, 70, 2, 72, 2, 74, + 2, 81, 2, 86, 2, 87, 3, 89, 208, 1, 60, 5, 77, 65, 76, 76, 32, 221, 26, + 5, 67, 82, 73, 80, 84, 104, 242, 1, 68, 210, 20, 65, 22, 66, 2, 90, 22, + 67, 42, 69, 34, 70, 62, 71, 22, 73, 22, 75, 34, 76, 22, 79, 50, 80, 42, + 82, 22, 83, 34, 84, 38, 85, 166, 246, 14, 77, 2, 78, 138, 204, 1, 88, + 230, 143, 2, 72, 2, 74, 2, 81, 2, 86, 2, 87, 3, 89, 7, 26, 73, 147, 169, + 15, 69, 2, 243, 219, 1, 71, 110, 68, 8, 67, 65, 80, 73, 84, 65, 76, 32, + 178, 24, 83, 211, 217, 16, 68, 38, 158, 233, 18, 65, 2, 66, 2, 68, 2, 69, + 2, 70, 2, 71, 2, 73, 2, 74, 2, 75, 2, 76, 2, 77, 2, 79, 2, 83, 2, 84, 2, + 85, 2, 86, 2, 87, 2, 88, 3, 89, 96, 52, 7, 82, 65, 75, 84, 85, 82, 32, + 231, 179, 7, 65, 94, 52, 8, 67, 65, 80, 73, 84, 65, 76, 32, 159, 22, 83, + 42, 138, 231, 18, 65, 2, 66, 2, 68, 2, 69, 2, 70, 2, 71, 2, 74, 2, 75, 2, 76, 2, 77, 2, 78, 2, 79, 2, 80, 2, 81, 2, 83, 2, 84, 2, 85, 2, 86, 2, 87, - 2, 88, 3, 89, 222, 1, 100, 6, 83, 77, 65, 76, 76, 32, 222, 7, 67, 218, 2, - 69, 38, 75, 38, 78, 30, 80, 98, 82, 243, 5, 84, 104, 242, 1, 68, 186, 12, - 65, 22, 66, 2, 90, 42, 69, 38, 70, 62, 71, 22, 73, 22, 75, 34, 76, 22, - 79, 50, 80, 42, 82, 22, 83, 34, 84, 38, 85, 214, 197, 1, 67, 250, 132, - 13, 77, 2, 78, 186, 202, 1, 88, 198, 140, 2, 74, 2, 81, 2, 86, 2, 87, 3, - 89, 9, 52, 7, 79, 84, 76, 69, 83, 83, 32, 143, 244, 14, 69, 4, 238, 176, - 18, 73, 3, 74, 124, 246, 15, 67, 34, 83, 183, 172, 16, 68, 12, 32, 2, 71, - 72, 219, 133, 7, 83, 10, 17, 2, 84, 32, 10, 112, 6, 87, 72, 73, 84, 69, - 32, 194, 240, 5, 68, 222, 107, 65, 153, 235, 4, 9, 70, 76, 65, 84, 84, - 69, 78, 69, 68, 4, 226, 175, 14, 83, 39, 84, 130, 6, 84, 10, 65, 78, 83, - 45, 83, 69, 82, 73, 70, 32, 249, 13, 6, 67, 82, 73, 80, 84, 32, 176, 5, - 96, 5, 66, 79, 76, 68, 32, 164, 12, 6, 73, 84, 65, 76, 73, 67, 34, 67, - 34, 83, 183, 172, 16, 68, 204, 3, 98, 73, 122, 67, 218, 2, 69, 38, 75, - 38, 78, 30, 80, 98, 82, 30, 83, 214, 5, 84, 175, 173, 16, 68, 220, 1, 33, - 6, 84, 65, 76, 73, 67, 32, 220, 1, 74, 67, 218, 2, 69, 38, 75, 38, 78, - 30, 80, 98, 82, 30, 83, 215, 5, 84, 102, 37, 7, 65, 80, 73, 84, 65, 76, - 32, 102, 250, 1, 84, 174, 4, 65, 22, 66, 2, 90, 22, 68, 22, 69, 98, 71, - 22, 73, 22, 75, 34, 76, 22, 79, 50, 80, 42, 82, 22, 83, 70, 85, 214, 197, - 1, 67, 250, 132, 13, 77, 2, 78, 186, 202, 1, 88, 198, 140, 2, 70, 2, 72, - 2, 74, 2, 81, 2, 86, 2, 87, 3, 89, 9, 156, 155, 11, 4, 72, 69, 84, 65, - 151, 233, 6, 65, 2, 173, 174, 16, 4, 80, 83, 73, 76, 2, 17, 2, 65, 80, 2, - 159, 7, 80, 2, 133, 134, 18, 2, 65, 66, 6, 74, 72, 200, 145, 5, 8, 65, - 82, 84, 73, 65, 76, 32, 68, 175, 128, 12, 73, 2, 243, 145, 17, 73, 2, - 221, 145, 17, 2, 72, 79, 102, 29, 5, 77, 65, 76, 76, 32, 102, 246, 1, 65, - 22, 66, 2, 90, 22, 68, 22, 69, 38, 70, 62, 71, 22, 73, 22, 75, 34, 76, - 22, 79, 50, 80, 42, 82, 22, 83, 34, 84, 38, 85, 214, 197, 1, 67, 250, - 132, 13, 77, 2, 78, 186, 202, 1, 88, 198, 140, 2, 72, 2, 74, 2, 81, 2, - 86, 2, 87, 3, 89, 5, 231, 200, 14, 76, 5, 143, 128, 18, 69, 5, 227, 231, - 14, 69, 7, 130, 213, 1, 80, 251, 204, 16, 84, 5, 11, 73, 2, 29, 5, 78, - 65, 76, 32, 83, 2, 227, 1, 73, 5, 139, 206, 15, 65, 5, 243, 254, 17, 79, - 5, 11, 65, 2, 247, 229, 14, 80, 5, 167, 231, 14, 65, 7, 11, 77, 4, 190, - 171, 1, 73, 235, 180, 16, 69, 9, 238, 142, 18, 72, 2, 83, 219, 19, 73, 5, - 171, 131, 18, 72, 5, 11, 73, 2, 239, 128, 18, 71, 7, 214, 228, 14, 72, - 175, 152, 3, 65, 5, 151, 210, 1, 80, 2, 11, 72, 2, 11, 69, 2, 11, 84, 2, - 203, 139, 17, 65, 104, 11, 32, 104, 18, 67, 35, 83, 52, 53, 5, 65, 80, - 73, 84, 65, 52, 21, 3, 77, 65, 76, 52, 247, 254, 11, 76, 82, 76, 8, 67, - 65, 80, 73, 84, 65, 76, 32, 157, 1, 6, 83, 77, 65, 76, 76, 32, 36, 190, - 159, 18, 65, 2, 67, 2, 68, 2, 71, 2, 74, 2, 75, 2, 78, 2, 79, 2, 80, 2, - 81, 2, 83, 2, 84, 2, 85, 2, 86, 2, 87, 2, 88, 2, 89, 3, 90, 46, 162, 158, - 18, 65, 2, 66, 2, 67, 2, 68, 2, 70, 2, 72, 2, 73, 2, 74, 2, 75, 2, 76, 2, - 77, 2, 78, 2, 80, 2, 81, 2, 82, 2, 83, 2, 84, 2, 85, 2, 86, 2, 87, 2, 88, - 2, 89, 3, 90, 40, 45, 9, 32, 78, 85, 77, 69, 82, 65, 76, 32, 40, 70, 69, - 66, 70, 70, 78, 26, 83, 66, 84, 130, 168, 16, 90, 223, 86, 79, 6, 40, 4, - 73, 71, 72, 84, 255, 248, 9, 76, 5, 183, 197, 16, 69, 8, 30, 73, 105, 3, - 79, 85, 82, 4, 198, 130, 5, 70, 239, 129, 13, 86, 4, 65, 3, 73, 78, 69, - 8, 40, 4, 69, 86, 69, 78, 1, 2, 73, 88, 5, 143, 196, 16, 84, 10, 42, 72, - 202, 248, 9, 87, 187, 209, 7, 69, 4, 146, 129, 5, 73, 175, 166, 11, 82, - 130, 9, 226, 1, 65, 188, 4, 9, 67, 72, 65, 78, 73, 67, 65, 76, 32, 34, - 68, 204, 15, 11, 69, 84, 69, 73, 32, 77, 65, 89, 69, 75, 32, 178, 11, 76, - 62, 78, 134, 50, 82, 176, 15, 8, 83, 83, 65, 71, 69, 32, 87, 65, 22, 84, - 135, 151, 17, 77, 26, 68, 6, 83, 85, 82, 69, 68, 32, 189, 177, 14, 5, 84, - 32, 79, 78, 32, 24, 96, 5, 65, 78, 71, 76, 69, 216, 143, 10, 9, 82, 73, - 71, 72, 84, 32, 65, 78, 71, 139, 245, 7, 66, 21, 11, 32, 18, 212, 1, 39, - 87, 73, 84, 72, 32, 79, 80, 69, 78, 32, 65, 82, 77, 32, 69, 78, 68, 73, - 78, 71, 32, 73, 78, 32, 65, 82, 82, 79, 87, 32, 80, 79, 73, 78, 84, 73, - 78, 71, 32, 129, 226, 17, 7, 79, 80, 69, 78, 73, 78, 71, 16, 62, 68, 24, - 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, 43, 85, 4, 73, 3, 79, 87, 78, 4, - 209, 145, 8, 5, 84, 32, 65, 78, 68, 4, 11, 80, 4, 205, 228, 11, 3, 32, - 65, 78, 4, 218, 148, 17, 65, 215, 56, 76, 252, 1, 56, 9, 69, 70, 65, 73, - 68, 82, 73, 78, 32, 159, 7, 73, 190, 1, 174, 1, 67, 52, 6, 68, 73, 71, - 73, 84, 32, 152, 1, 7, 78, 85, 77, 66, 69, 82, 32, 114, 83, 148, 143, 7, - 12, 69, 88, 67, 76, 65, 77, 65, 84, 73, 79, 78, 32, 131, 170, 8, 70, 70, - 128, 3, 5, 65, 80, 73, 84, 65, 187, 184, 15, 79, 26, 82, 84, 48, 2, 79, - 78, 194, 156, 16, 70, 30, 83, 102, 90, 210, 86, 78, 239, 112, 69, 8, 44, - 3, 72, 82, 69, 165, 144, 17, 2, 87, 79, 4, 163, 144, 17, 69, 20, 50, 84, - 234, 244, 4, 69, 46, 70, 42, 78, 31, 83, 6, 170, 246, 4, 72, 220, 247, 4, - 2, 87, 69, 159, 209, 7, 69, 70, 68, 3, 77, 65, 76, 209, 207, 9, 8, 89, - 77, 66, 79, 76, 32, 65, 73, 68, 45, 9, 76, 32, 76, 69, 84, 84, 69, 82, - 32, 68, 242, 1, 65, 38, 78, 142, 223, 3, 72, 2, 75, 178, 213, 10, 89, - 222, 150, 3, 79, 162, 64, 66, 2, 67, 2, 68, 2, 69, 2, 70, 2, 71, 2, 73, - 2, 74, 2, 76, 2, 77, 2, 80, 2, 81, 2, 82, 2, 83, 2, 84, 2, 85, 2, 86, 2, - 87, 2, 88, 3, 90, 7, 178, 239, 3, 84, 171, 156, 14, 73, 7, 182, 139, 18, - 71, 3, 89, 62, 48, 5, 69, 86, 65, 76, 32, 45, 3, 85, 77, 32, 6, 142, 239, - 10, 69, 134, 198, 4, 67, 115, 81, 56, 210, 1, 66, 50, 70, 164, 1, 3, 76, - 69, 70, 0, 4, 82, 73, 71, 72, 248, 1, 11, 77, 65, 84, 72, 69, 77, 65, 84, - 73, 67, 65, 22, 83, 124, 4, 84, 72, 82, 69, 138, 170, 15, 86, 246, 62, - 69, 166, 4, 87, 203, 11, 71, 4, 216, 153, 6, 3, 79, 76, 68, 211, 239, 7, - 76, 10, 84, 9, 76, 65, 84, 84, 69, 78, 69, 68, 32, 224, 3, 3, 79, 85, 82, - 187, 234, 15, 73, 4, 44, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, 2, 213, 1, + 2, 88, 3, 89, 224, 1, 100, 6, 83, 77, 65, 76, 76, 32, 242, 8, 67, 210, 2, + 69, 38, 75, 38, 78, 30, 80, 86, 82, 143, 6, 84, 106, 234, 1, 68, 86, 76, + 230, 12, 65, 22, 66, 2, 90, 22, 67, 42, 69, 34, 70, 62, 71, 22, 73, 22, + 75, 54, 79, 50, 80, 42, 82, 22, 83, 34, 84, 38, 85, 166, 246, 14, 77, 2, + 78, 138, 204, 1, 88, 230, 143, 2, 74, 2, 81, 2, 86, 2, 87, 3, 89, 9, 52, + 7, 79, 84, 76, 69, 83, 83, 32, 223, 161, 15, 69, 4, 198, 226, 18, 73, 3, + 74, 7, 88, 16, 73, 71, 65, 84, 85, 82, 69, 32, 76, 79, 78, 71, 32, 83, + 32, 87, 231, 161, 15, 65, 2, 153, 226, 14, 11, 73, 84, 72, 32, 68, 69, + 83, 67, 69, 78, 68, 124, 254, 15, 67, 34, 83, 211, 217, 16, 68, 12, 32, + 2, 71, 72, 251, 172, 7, 83, 10, 17, 2, 84, 32, 10, 112, 6, 87, 72, 73, + 84, 69, 32, 230, 150, 6, 68, 178, 108, 65, 157, 239, 4, 9, 70, 76, 65, + 84, 84, 69, 78, 69, 68, 4, 222, 218, 14, 83, 39, 84, 130, 6, 84, 10, 65, + 78, 83, 45, 83, 69, 82, 73, 70, 32, 129, 14, 6, 67, 82, 73, 80, 84, 32, + 176, 5, 96, 5, 66, 79, 76, 68, 32, 172, 12, 6, 73, 84, 65, 76, 73, 67, + 34, 67, 34, 83, 211, 217, 16, 68, 204, 3, 98, 73, 122, 67, 210, 2, 69, + 38, 75, 38, 78, 30, 80, 86, 82, 30, 83, 242, 5, 84, 203, 218, 16, 68, + 220, 1, 33, 6, 84, 65, 76, 73, 67, 32, 220, 1, 74, 67, 210, 2, 69, 38, + 75, 38, 78, 30, 80, 86, 82, 30, 83, 243, 5, 84, 102, 37, 7, 65, 80, 73, + 84, 65, 76, 32, 102, 242, 1, 84, 154, 4, 65, 22, 66, 2, 90, 22, 67, 22, + 68, 22, 69, 94, 71, 22, 73, 22, 75, 34, 76, 22, 79, 50, 80, 42, 82, 22, + 83, 70, 85, 166, 246, 14, 77, 2, 78, 138, 204, 1, 88, 230, 143, 2, 70, 2, + 72, 2, 74, 2, 81, 2, 86, 2, 87, 3, 89, 9, 160, 198, 11, 4, 72, 69, 84, + 65, 215, 238, 6, 65, 2, 217, 219, 16, 4, 80, 83, 73, 76, 2, 17, 2, 65, + 80, 2, 175, 7, 80, 2, 201, 182, 18, 2, 65, 66, 6, 168, 184, 5, 8, 65, 82, + 84, 73, 65, 76, 32, 68, 214, 138, 9, 72, 135, 128, 3, 73, 2, 173, 194, + 17, 2, 72, 79, 102, 29, 5, 77, 65, 76, 76, 32, 102, 238, 1, 65, 22, 66, + 2, 90, 22, 67, 22, 68, 22, 69, 34, 70, 62, 71, 22, 73, 22, 75, 34, 76, + 22, 79, 50, 80, 42, 82, 22, 83, 34, 84, 38, 85, 166, 246, 14, 77, 2, 78, + 138, 204, 1, 88, 230, 143, 2, 72, 2, 74, 2, 81, 2, 86, 2, 87, 3, 89, 5, + 207, 244, 14, 76, 5, 231, 176, 18, 69, 5, 199, 193, 18, 72, 5, 159, 148, + 15, 69, 7, 242, 2, 80, 207, 207, 18, 84, 5, 11, 73, 2, 29, 5, 78, 65, 76, + 32, 83, 2, 227, 1, 73, 5, 215, 250, 15, 65, 5, 187, 175, 18, 79, 5, 11, + 65, 2, 183, 146, 15, 80, 5, 231, 147, 15, 65, 7, 11, 77, 4, 138, 175, 1, + 73, 231, 225, 16, 69, 9, 182, 191, 18, 72, 2, 83, 219, 19, 73, 5, 243, + 179, 18, 72, 5, 11, 73, 2, 183, 177, 18, 71, 7, 150, 145, 15, 72, 183, + 156, 3, 65, 5, 11, 80, 2, 137, 130, 18, 2, 83, 73, 2, 11, 72, 2, 11, 69, + 2, 11, 84, 2, 255, 187, 17, 65, 104, 11, 32, 104, 18, 67, 35, 83, 52, 53, + 5, 65, 80, 73, 84, 65, 52, 21, 3, 77, 65, 76, 52, 195, 169, 12, 76, 82, + 76, 8, 67, 65, 80, 73, 84, 65, 76, 32, 157, 1, 6, 83, 77, 65, 76, 76, 32, + 36, 242, 207, 18, 65, 2, 67, 2, 68, 2, 71, 2, 74, 2, 75, 2, 78, 2, 79, 2, + 80, 2, 81, 2, 83, 2, 84, 2, 85, 2, 86, 2, 87, 2, 88, 2, 89, 3, 90, 46, + 214, 206, 18, 65, 2, 66, 2, 67, 2, 68, 2, 70, 2, 72, 2, 73, 2, 74, 2, 75, + 2, 76, 2, 77, 2, 78, 2, 80, 2, 81, 2, 82, 2, 83, 2, 84, 2, 85, 2, 86, 2, + 87, 2, 88, 2, 89, 3, 90, 40, 45, 9, 32, 78, 85, 77, 69, 82, 65, 76, 32, + 40, 70, 69, 66, 70, 70, 78, 26, 83, 66, 84, 158, 213, 16, 90, 247, 89, + 79, 6, 40, 4, 73, 71, 72, 84, 227, 161, 10, 76, 5, 219, 242, 16, 69, 8, + 30, 73, 105, 3, 79, 85, 82, 4, 206, 168, 5, 70, 155, 140, 13, 86, 4, 65, + 3, 73, 78, 69, 8, 40, 4, 69, 86, 69, 78, 1, 2, 73, 88, 5, 179, 241, 16, + 84, 10, 42, 72, 174, 161, 10, 87, 139, 217, 7, 69, 4, 154, 167, 5, 73, + 195, 173, 11, 82, 138, 9, 226, 1, 65, 184, 5, 9, 67, 72, 65, 78, 73, 67, + 65, 76, 32, 34, 68, 204, 15, 11, 69, 84, 69, 73, 32, 77, 65, 89, 69, 75, + 32, 178, 11, 76, 62, 78, 146, 50, 82, 176, 15, 8, 83, 83, 65, 71, 69, 32, + 87, 65, 22, 84, 179, 198, 17, 77, 32, 68, 6, 83, 85, 82, 69, 68, 32, 129, + 221, 14, 5, 84, 32, 79, 78, 32, 30, 96, 5, 65, 78, 71, 76, 69, 196, 184, + 10, 9, 82, 73, 71, 72, 84, 32, 65, 78, 71, 211, 252, 7, 66, 27, 11, 32, + 24, 72, 5, 87, 73, 84, 72, 32, 193, 147, 18, 7, 79, 80, 69, 78, 73, 78, + 71, 22, 192, 1, 7, 68, 79, 85, 66, 76, 69, 32, 30, 67, 41, 34, 79, 80, + 69, 78, 32, 65, 82, 77, 32, 69, 78, 68, 73, 78, 71, 32, 73, 78, 32, 65, + 82, 82, 79, 87, 32, 80, 79, 73, 78, 84, 73, 78, 71, 32, 4, 26, 67, 203, + 192, 15, 65, 2, 173, 238, 7, 5, 79, 78, 67, 65, 86, 16, 62, 68, 24, 3, + 76, 69, 70, 0, 4, 82, 73, 71, 72, 43, 85, 4, 73, 3, 79, 87, 78, 4, 193, + 185, 8, 5, 84, 32, 65, 78, 68, 4, 11, 80, 4, 185, 142, 12, 3, 32, 65, 78, + 4, 146, 196, 17, 65, 215, 56, 76, 252, 1, 56, 9, 69, 70, 65, 73, 68, 82, + 73, 78, 32, 159, 7, 73, 190, 1, 174, 1, 67, 52, 6, 68, 73, 71, 73, 84, + 32, 152, 1, 7, 78, 85, 77, 66, 69, 82, 32, 114, 83, 212, 181, 7, 12, 69, + 88, 67, 76, 65, 77, 65, 84, 73, 79, 78, 32, 255, 174, 8, 70, 70, 128, 3, + 5, 65, 80, 73, 84, 65, 247, 227, 15, 79, 26, 82, 84, 48, 2, 79, 78, 226, + 200, 16, 70, 30, 83, 102, 90, 234, 89, 78, 239, 112, 69, 8, 44, 3, 72, + 82, 69, 221, 191, 17, 2, 87, 79, 4, 219, 191, 17, 69, 20, 50, 84, 246, + 153, 5, 69, 46, 70, 42, 78, 31, 83, 6, 182, 155, 5, 72, 184, 250, 4, 2, + 87, 69, 239, 216, 7, 69, 70, 68, 3, 77, 65, 76, 205, 247, 9, 8, 89, 77, + 66, 79, 76, 32, 65, 73, 68, 45, 9, 76, 32, 76, 69, 84, 84, 69, 82, 32, + 68, 242, 1, 65, 38, 78, 138, 131, 4, 72, 2, 75, 254, 219, 10, 89, 206, + 155, 3, 79, 162, 64, 66, 2, 67, 2, 68, 2, 69, 2, 70, 2, 71, 2, 73, 2, 74, + 2, 76, 2, 77, 2, 80, 2, 81, 2, 82, 2, 83, 2, 84, 2, 85, 2, 86, 2, 87, 2, + 88, 3, 90, 7, 174, 147, 4, 84, 231, 167, 14, 73, 7, 238, 186, 18, 71, 3, + 89, 62, 48, 5, 69, 86, 65, 76, 32, 45, 3, 85, 77, 32, 6, 206, 224, 15, + 67, 114, 81, 167, 188, 1, 69, 56, 210, 1, 66, 50, 70, 164, 1, 3, 76, 69, + 70, 0, 4, 82, 73, 71, 72, 248, 1, 11, 77, 65, 84, 72, 69, 77, 65, 84, 73, + 67, 65, 22, 83, 124, 4, 84, 72, 82, 69, 198, 213, 15, 86, 210, 63, 69, + 166, 4, 87, 203, 11, 71, 4, 144, 191, 6, 3, 79, 76, 68, 147, 244, 7, 76, + 10, 84, 9, 76, 65, 84, 84, 69, 78, 69, 68, 32, 224, 3, 3, 79, 85, 82, + 211, 150, 16, 73, 4, 44, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, 2, 213, 1, 3, 84, 32, 80, 6, 11, 84, 6, 78, 32, 41, 15, 45, 80, 79, 73, 78, 84, 73, 78, 71, 32, 65, 78, 71, 76, 69, 4, 36, 5, 67, 85, 82, 76, 89, 59, 80, 2, - 17, 2, 32, 66, 2, 173, 180, 7, 4, 82, 65, 67, 75, 2, 245, 193, 17, 10, - 65, 82, 69, 78, 84, 72, 69, 83, 73, 83, 2, 215, 198, 17, 76, 12, 202, - 138, 15, 72, 200, 95, 2, 73, 88, 182, 2, 65, 245, 115, 15, 77, 65, 76, + 17, 2, 32, 66, 2, 229, 218, 7, 4, 82, 65, 67, 75, 2, 173, 241, 17, 10, + 65, 82, 69, 78, 84, 72, 69, 83, 73, 83, 2, 143, 246, 17, 76, 12, 134, + 182, 15, 72, 164, 96, 2, 73, 88, 182, 2, 65, 213, 118, 15, 77, 65, 76, 76, 32, 87, 72, 73, 84, 69, 32, 67, 73, 82, 67, 4, 11, 69, 4, 45, 9, 32, - 80, 79, 73, 78, 84, 69, 68, 32, 4, 174, 203, 9, 80, 151, 158, 6, 66, 158, + 80, 79, 73, 78, 84, 69, 68, 32, 4, 170, 243, 9, 80, 179, 162, 6, 66, 158, 1, 146, 1, 65, 104, 6, 67, 72, 69, 73, 75, 72, 34, 76, 144, 6, 8, 83, 89, - 76, 76, 65, 66, 76, 69, 0, 4, 87, 79, 82, 68, 50, 86, 199, 134, 16, 68, - 6, 80, 8, 72, 65, 78, 71, 32, 75, 72, 85, 164, 6, 3, 80, 85, 78, 151, - 219, 13, 78, 2, 175, 196, 16, 68, 4, 202, 177, 17, 65, 139, 60, 69, 94, + 76, 76, 65, 66, 76, 69, 0, 4, 87, 79, 82, 68, 50, 86, 231, 178, 16, 68, + 6, 80, 8, 72, 65, 78, 71, 32, 75, 72, 85, 164, 6, 3, 80, 85, 78, 239, + 132, 14, 78, 2, 227, 240, 16, 68, 4, 130, 225, 17, 65, 139, 60, 69, 94, 52, 6, 69, 84, 84, 69, 82, 32, 185, 5, 2, 85, 77, 92, 250, 1, 66, 36, 2, 67, 72, 38, 68, 50, 71, 38, 74, 34, 75, 42, 78, 62, 80, 30, 83, 42, 84, - 54, 73, 0, 3, 76, 65, 73, 0, 3, 77, 73, 84, 218, 253, 12, 72, 166, 10, - 82, 2, 87, 248, 186, 2, 2, 65, 84, 250, 223, 1, 89, 246, 8, 85, 226, 79, - 69, 3, 79, 4, 198, 193, 16, 72, 147, 189, 1, 65, 4, 226, 242, 16, 73, - 211, 139, 1, 65, 8, 138, 167, 10, 72, 182, 203, 6, 73, 147, 68, 68, 4, - 218, 166, 10, 72, 239, 211, 7, 79, 4, 170, 192, 16, 72, 195, 49, 73, 6, - 216, 1, 2, 79, 75, 191, 164, 10, 72, 12, 178, 1, 65, 0, 3, 71, 79, 85, - 138, 249, 17, 78, 3, 89, 6, 118, 65, 179, 190, 16, 72, 6, 194, 235, 17, - 65, 162, 14, 72, 3, 83, 10, 48, 2, 73, 76, 190, 164, 10, 72, 199, 143, 7, - 84, 5, 225, 177, 1, 4, 32, 76, 79, 78, 2, 245, 247, 17, 3, 32, 73, 89, 2, - 209, 145, 17, 7, 32, 82, 69, 80, 69, 84, 73, 30, 64, 10, 79, 87, 69, 76, - 32, 83, 73, 71, 78, 32, 239, 189, 15, 73, 28, 130, 1, 65, 44, 4, 67, 72, - 69, 73, 2, 79, 0, 3, 83, 79, 85, 0, 2, 89, 69, 22, 73, 38, 85, 230, 132, - 11, 78, 211, 185, 4, 86, 8, 250, 229, 16, 78, 210, 82, 65, 187, 64, 85, - 2, 207, 229, 16, 78, 4, 186, 229, 16, 78, 139, 147, 1, 73, 4, 150, 229, - 16, 78, 139, 147, 1, 85, 6, 200, 220, 16, 4, 80, 79, 77, 69, 146, 19, 84, + 54, 73, 0, 3, 76, 65, 73, 0, 3, 77, 73, 84, 162, 167, 13, 72, 166, 10, + 82, 2, 87, 236, 188, 2, 2, 65, 84, 246, 227, 1, 89, 246, 8, 85, 226, 79, + 69, 3, 79, 4, 250, 237, 16, 72, 151, 192, 1, 65, 4, 154, 162, 17, 73, + 211, 139, 1, 65, 8, 134, 207, 10, 72, 242, 210, 6, 73, 147, 68, 68, 4, + 214, 206, 10, 72, 171, 219, 7, 79, 4, 222, 236, 16, 72, 199, 52, 73, 6, + 216, 1, 2, 79, 75, 187, 204, 10, 72, 12, 178, 1, 65, 0, 3, 71, 79, 85, + 194, 168, 18, 78, 3, 89, 6, 118, 65, 231, 234, 16, 72, 6, 250, 154, 18, + 65, 162, 14, 72, 3, 83, 10, 48, 2, 73, 76, 186, 204, 10, 72, 131, 151, 7, + 84, 5, 173, 189, 1, 4, 32, 76, 79, 78, 2, 173, 167, 18, 3, 32, 73, 89, 2, + 137, 193, 17, 7, 32, 82, 69, 80, 69, 84, 73, 30, 64, 10, 79, 87, 69, 76, + 32, 83, 73, 71, 78, 32, 171, 233, 15, 73, 28, 130, 1, 65, 44, 4, 67, 72, + 69, 73, 2, 79, 0, 3, 83, 79, 85, 0, 2, 89, 69, 22, 73, 38, 85, 222, 174, + 11, 78, 151, 187, 4, 86, 8, 178, 149, 17, 78, 210, 82, 65, 187, 64, 85, + 2, 135, 149, 17, 78, 4, 242, 148, 17, 78, 139, 147, 1, 73, 4, 206, 148, + 17, 78, 139, 147, 1, 85, 6, 128, 140, 17, 4, 80, 79, 77, 69, 146, 19, 84, 195, 56, 79, 178, 3, 160, 1, 11, 68, 69, 32, 75, 73, 75, 65, 75, 85, 73, - 32, 136, 224, 16, 20, 79, 82, 65, 72, 32, 87, 73, 84, 72, 32, 78, 73, 78, + 32, 192, 143, 17, 20, 79, 82, 65, 72, 32, 87, 73, 84, 72, 32, 78, 73, 78, 69, 32, 66, 82, 65, 78, 67, 79, 83, 174, 3, 148, 1, 17, 67, 79, 77, 66, 73, 78, 73, 78, 71, 32, 78, 85, 77, 66, 69, 82, 32, 164, 1, 10, 83, 89, - 76, 76, 65, 66, 76, 69, 32, 77, 139, 168, 9, 68, 14, 62, 84, 56, 7, 72, - 85, 78, 68, 82, 69, 68, 199, 181, 4, 77, 8, 26, 69, 143, 182, 4, 72, 6, - 26, 78, 219, 172, 14, 69, 4, 224, 181, 4, 2, 32, 84, 163, 190, 13, 83, - 142, 3, 22, 48, 143, 21, 49, 198, 1, 118, 48, 250, 1, 49, 210, 1, 50, + 76, 76, 65, 66, 76, 69, 32, 77, 135, 208, 9, 68, 14, 62, 84, 56, 7, 72, + 85, 78, 68, 82, 69, 68, 211, 218, 4, 77, 8, 26, 69, 155, 219, 4, 72, 6, + 26, 78, 155, 215, 14, 69, 4, 236, 218, 4, 2, 32, 84, 207, 200, 13, 83, + 142, 3, 22, 48, 147, 21, 49, 198, 1, 118, 48, 250, 1, 49, 210, 1, 50, 138, 2, 51, 254, 1, 52, 130, 2, 53, 158, 2, 54, 242, 1, 55, 134, 2, 56, - 187, 2, 57, 18, 142, 1, 49, 34, 50, 22, 51, 22, 52, 162, 151, 2, 53, 214, - 236, 3, 56, 196, 236, 10, 3, 57, 32, 77, 92, 3, 55, 32, 77, 237, 90, 3, - 54, 32, 87, 2, 11, 32, 2, 203, 221, 17, 75, 2, 167, 232, 17, 32, 2, 231, - 154, 12, 32, 2, 11, 32, 2, 131, 221, 17, 87, 20, 130, 1, 49, 22, 54, 18, - 56, 22, 57, 228, 28, 2, 48, 32, 214, 183, 7, 53, 218, 209, 5, 52, 198, - 10, 55, 222, 9, 50, 207, 244, 3, 51, 2, 155, 194, 17, 32, 2, 147, 25, 32, - 2, 139, 210, 13, 32, 2, 151, 252, 12, 32, 20, 106, 49, 22, 50, 22, 51, - 22, 52, 22, 53, 22, 54, 22, 55, 22, 57, 194, 224, 11, 48, 185, 236, 1, 2, - 56, 32, 2, 199, 170, 10, 32, 2, 247, 129, 10, 32, 2, 151, 201, 17, 32, 2, - 135, 149, 12, 32, 2, 219, 233, 12, 32, 2, 143, 203, 17, 32, 2, 231, 227, - 12, 32, 2, 219, 28, 32, 20, 174, 1, 48, 16, 2, 49, 32, 20, 2, 52, 32, 20, - 2, 56, 32, 182, 190, 4, 57, 214, 51, 50, 22, 53, 220, 240, 7, 2, 54, 32, - 188, 136, 4, 3, 55, 32, 78, 237, 90, 3, 51, 32, 89, 2, 159, 37, 32, 2, - 215, 215, 17, 89, 2, 195, 215, 17, 70, 2, 235, 158, 16, 78, 20, 192, 1, - 2, 48, 32, 22, 53, 22, 56, 160, 8, 3, 52, 32, 75, 128, 22, 3, 54, 32, 72, - 222, 2, 55, 254, 208, 4, 49, 224, 184, 4, 3, 57, 32, 87, 156, 174, 4, 2, - 51, 32, 157, 197, 1, 3, 50, 32, 72, 2, 143, 247, 15, 72, 2, 227, 212, 15, - 32, 2, 135, 202, 17, 32, 20, 178, 1, 48, 18, 53, 20, 2, 54, 32, 20, 2, - 56, 32, 22, 57, 156, 214, 9, 2, 50, 32, 236, 4, 2, 51, 32, 210, 214, 1, - 49, 164, 234, 3, 3, 52, 32, 76, 197, 144, 1, 3, 55, 32, 78, 2, 159, 4, - 32, 2, 155, 158, 16, 32, 2, 243, 185, 17, 71, 2, 183, 151, 13, 78, 2, - 237, 144, 16, 2, 32, 77, 20, 196, 1, 2, 50, 32, 22, 54, 238, 25, 51, 168, - 2, 3, 55, 32, 78, 200, 216, 1, 2, 52, 32, 158, 146, 3, 56, 144, 150, 5, - 3, 48, 32, 78, 192, 89, 3, 49, 32, 87, 158, 13, 57, 249, 238, 4, 3, 53, - 32, 75, 2, 231, 183, 17, 77, 2, 131, 153, 10, 32, 20, 196, 1, 3, 52, 32, + 191, 2, 57, 18, 142, 1, 49, 34, 50, 22, 51, 22, 52, 138, 187, 2, 53, 166, + 238, 3, 56, 196, 246, 10, 3, 57, 32, 77, 92, 3, 55, 32, 77, 237, 90, 3, + 54, 32, 87, 2, 11, 32, 2, 131, 141, 18, 75, 2, 223, 151, 18, 32, 2, 191, + 196, 12, 32, 2, 11, 32, 2, 187, 140, 18, 87, 20, 130, 1, 49, 22, 54, 18, + 56, 22, 57, 228, 28, 2, 48, 32, 198, 223, 7, 53, 182, 211, 5, 52, 198, + 10, 55, 222, 9, 50, 187, 250, 3, 51, 2, 211, 241, 17, 32, 2, 147, 25, 32, + 2, 203, 251, 13, 32, 2, 223, 165, 13, 32, 20, 106, 49, 22, 50, 22, 51, + 22, 52, 22, 53, 22, 54, 22, 55, 22, 57, 146, 138, 12, 48, 193, 236, 1, 2, + 56, 32, 2, 199, 210, 10, 32, 2, 231, 169, 10, 32, 2, 207, 248, 17, 32, 2, + 223, 190, 12, 32, 2, 163, 147, 13, 32, 2, 199, 250, 17, 32, 2, 175, 141, + 13, 32, 2, 219, 28, 32, 20, 174, 1, 48, 16, 2, 49, 32, 20, 2, 52, 32, 20, + 2, 56, 32, 194, 227, 4, 57, 218, 51, 50, 22, 53, 148, 245, 7, 2, 54, 32, + 172, 142, 4, 3, 55, 32, 78, 237, 90, 3, 51, 32, 89, 2, 171, 37, 32, 2, + 143, 135, 18, 89, 2, 251, 134, 18, 70, 2, 171, 203, 16, 78, 20, 192, 1, + 2, 48, 32, 22, 53, 22, 56, 164, 8, 3, 52, 32, 75, 136, 22, 3, 54, 32, 72, + 222, 2, 55, 130, 246, 4, 49, 204, 187, 4, 3, 57, 32, 87, 224, 175, 4, 2, + 51, 32, 153, 199, 1, 3, 50, 32, 72, 2, 175, 163, 16, 72, 2, 251, 128, 16, + 32, 2, 191, 249, 17, 32, 20, 178, 1, 48, 18, 53, 20, 2, 54, 32, 20, 2, + 56, 32, 22, 57, 140, 254, 9, 2, 50, 32, 236, 4, 2, 51, 32, 218, 216, 1, + 49, 232, 235, 3, 3, 52, 32, 76, 189, 145, 1, 3, 55, 32, 78, 2, 159, 4, + 32, 2, 219, 202, 16, 32, 2, 171, 233, 17, 71, 2, 131, 193, 13, 78, 2, + 149, 189, 16, 2, 32, 77, 20, 196, 1, 2, 50, 32, 22, 54, 250, 25, 51, 168, + 2, 3, 55, 32, 78, 172, 247, 1, 2, 52, 32, 206, 152, 3, 56, 240, 152, 5, + 3, 48, 32, 78, 184, 91, 3, 49, 32, 87, 158, 13, 57, 161, 241, 4, 3, 53, + 32, 75, 2, 159, 231, 17, 77, 2, 255, 192, 10, 32, 20, 196, 1, 3, 52, 32, 75, 20, 2, 53, 32, 22, 57, 232, 7, 3, 49, 32, 71, 234, 1, 51, 236, 6, 3, - 48, 32, 71, 146, 5, 50, 136, 226, 10, 2, 55, 32, 172, 160, 4, 3, 54, 32, - 75, 217, 88, 3, 56, 32, 70, 2, 183, 190, 17, 80, 2, 183, 204, 17, 70, 2, - 215, 244, 10, 32, 20, 228, 1, 2, 48, 32, 20, 2, 49, 32, 20, 2, 52, 32, - 22, 53, 172, 14, 6, 54, 32, 76, 79, 78, 71, 224, 11, 2, 57, 32, 152, 169, - 3, 3, 51, 32, 72, 128, 165, 9, 4, 50, 32, 78, 71, 236, 247, 3, 3, 55, 32, - 72, 189, 97, 3, 56, 32, 70, 2, 167, 202, 17, 89, 2, 199, 238, 15, 80, 2, - 179, 238, 15, 76, 2, 235, 227, 16, 32, 20, 230, 1, 53, 216, 14, 4, 48, - 32, 78, 71, 244, 7, 3, 51, 32, 71, 144, 159, 12, 2, 55, 32, 250, 117, 57, - 200, 117, 3, 50, 32, 75, 136, 203, 1, 3, 49, 32, 84, 156, 28, 4, 56, 32, - 78, 89, 152, 134, 1, 3, 52, 32, 77, 225, 34, 2, 54, 32, 2, 235, 174, 17, - 32, 200, 1, 118, 48, 186, 2, 49, 210, 2, 50, 166, 2, 51, 222, 1, 52, 186, - 2, 53, 214, 2, 54, 166, 2, 55, 190, 2, 56, 223, 2, 57, 20, 222, 1, 49, - 30, 52, 28, 7, 53, 32, 76, 79, 78, 71, 32, 12, 2, 51, 32, 184, 11, 6, 54, - 32, 76, 79, 78, 71, 254, 236, 4, 50, 170, 170, 2, 48, 204, 143, 5, 3, 55, - 32, 71, 200, 182, 3, 3, 57, 32, 89, 201, 40, 3, 56, 32, 75, 2, 181, 143, - 16, 2, 32, 70, 2, 189, 144, 15, 2, 32, 84, 2, 11, 77, 2, 151, 144, 15, + 48, 32, 71, 138, 5, 50, 136, 140, 11, 2, 55, 32, 240, 161, 4, 3, 54, 32, + 75, 189, 89, 3, 56, 32, 70, 2, 239, 237, 17, 80, 2, 239, 251, 17, 70, 2, + 207, 158, 11, 32, 20, 222, 1, 48, 32, 2, 49, 32, 20, 2, 52, 32, 22, 53, + 168, 14, 6, 54, 32, 76, 79, 78, 71, 236, 11, 2, 57, 32, 136, 205, 3, 3, + 51, 32, 72, 204, 170, 9, 4, 50, 32, 78, 71, 220, 253, 3, 3, 55, 32, 72, + 189, 97, 3, 56, 32, 70, 2, 11, 32, 2, 219, 249, 17, 89, 2, 227, 154, 16, + 80, 2, 207, 154, 16, 76, 2, 159, 147, 17, 32, 20, 230, 1, 53, 212, 14, 4, + 48, 32, 78, 71, 128, 8, 3, 51, 32, 71, 202, 190, 13, 57, 172, 119, 3, 50, + 32, 75, 248, 203, 1, 3, 49, 32, 84, 164, 28, 4, 56, 32, 78, 89, 212, 4, + 2, 55, 32, 212, 132, 1, 3, 52, 32, 77, 225, 34, 2, 54, 32, 2, 159, 222, + 17, 32, 200, 1, 118, 48, 182, 2, 49, 210, 2, 50, 166, 2, 51, 222, 1, 52, + 186, 2, 53, 214, 2, 54, 178, 2, 55, 190, 2, 56, 223, 2, 57, 20, 218, 1, + 49, 30, 52, 28, 7, 53, 32, 76, 79, 78, 71, 32, 12, 2, 51, 32, 184, 11, 6, + 54, 32, 76, 79, 78, 71, 158, 146, 5, 50, 250, 172, 2, 48, 196, 202, 8, 3, + 57, 32, 89, 248, 32, 3, 55, 32, 71, 241, 7, 3, 56, 32, 75, 2, 245, 187, + 16, 2, 32, 70, 2, 249, 187, 15, 2, 32, 84, 2, 11, 77, 2, 211, 187, 15, 66, 20, 208, 1, 6, 48, 32, 76, 79, 78, 71, 22, 51, 34, 54, 22, 56, 32, 2, - 57, 32, 248, 17, 4, 53, 32, 78, 71, 128, 209, 2, 2, 55, 32, 248, 146, 2, - 3, 50, 32, 75, 216, 151, 10, 3, 52, 32, 87, 181, 136, 2, 2, 49, 32, 2, - 235, 178, 16, 32, 2, 11, 32, 2, 179, 194, 17, 74, 2, 207, 205, 16, 32, 2, - 11, 32, 2, 255, 193, 17, 87, 2, 203, 197, 15, 78, 20, 226, 1, 50, 32, 2, - 51, 32, 128, 4, 3, 52, 32, 71, 254, 9, 48, 168, 241, 9, 4, 56, 32, 72, - 79, 208, 225, 2, 5, 55, 32, 78, 71, 71, 148, 88, 2, 53, 32, 168, 61, 2, - 57, 32, 216, 237, 1, 3, 54, 32, 87, 221, 153, 1, 2, 49, 32, 2, 11, 32, 2, - 235, 161, 13, 77, 2, 11, 78, 2, 195, 194, 17, 68, 20, 200, 3, 2, 56, 32, - 252, 4, 3, 52, 32, 78, 200, 239, 4, 3, 50, 32, 75, 250, 215, 2, 49, 2, - 53, 232, 174, 2, 2, 55, 32, 160, 140, 5, 3, 51, 32, 70, 0, 3, 54, 32, 83, - 224, 53, 2, 48, 32, 197, 152, 1, 3, 57, 32, 87, 20, 236, 1, 8, 50, 32, + 57, 32, 132, 18, 4, 53, 32, 78, 71, 240, 244, 2, 2, 55, 32, 156, 148, 2, + 3, 50, 32, 75, 244, 157, 10, 3, 52, 32, 87, 177, 140, 2, 2, 49, 32, 2, + 227, 225, 16, 32, 2, 11, 32, 2, 235, 241, 17, 74, 2, 135, 253, 16, 32, 2, + 11, 32, 2, 183, 241, 17, 87, 2, 227, 241, 15, 78, 20, 226, 1, 50, 32, 2, + 51, 32, 128, 4, 3, 52, 32, 71, 138, 10, 48, 152, 153, 10, 4, 56, 32, 72, + 79, 156, 227, 2, 5, 55, 32, 78, 71, 71, 140, 88, 2, 53, 32, 176, 62, 2, + 57, 32, 176, 239, 1, 3, 54, 32, 87, 245, 156, 1, 2, 49, 32, 2, 11, 32, 2, + 183, 203, 13, 77, 2, 11, 78, 2, 251, 241, 17, 68, 20, 200, 3, 2, 56, 32, + 244, 4, 3, 52, 32, 78, 240, 148, 5, 3, 50, 32, 75, 202, 218, 2, 49, 2, + 53, 244, 174, 2, 2, 55, 32, 224, 143, 5, 3, 51, 32, 70, 0, 3, 54, 32, 83, + 188, 54, 2, 48, 32, 229, 155, 1, 3, 57, 32, 87, 20, 236, 1, 8, 50, 32, 76, 79, 78, 71, 32, 77, 20, 3, 53, 32, 77, 22, 54, 224, 2, 3, 57, 32, 78, - 238, 215, 6, 55, 176, 160, 3, 3, 51, 32, 87, 160, 230, 2, 2, 48, 32, 168, - 60, 3, 56, 32, 71, 216, 233, 1, 3, 49, 32, 89, 1, 3, 52, 32, 86, 2, 199, - 179, 17, 66, 2, 207, 190, 17, 66, 2, 221, 154, 16, 3, 32, 78, 71, 20, - 192, 1, 2, 50, 32, 34, 52, 26, 53, 34, 54, 36, 2, 55, 32, 188, 7, 2, 48, - 32, 128, 252, 9, 3, 56, 32, 75, 188, 198, 2, 2, 49, 32, 136, 144, 3, 5, - 57, 32, 78, 71, 71, 229, 210, 1, 2, 51, 32, 2, 11, 78, 2, 235, 205, 17, - 74, 2, 165, 5, 2, 32, 77, 2, 11, 32, 2, 147, 188, 17, 71, 2, 221, 132, - 15, 4, 32, 78, 71, 71, 2, 147, 221, 15, 74, 20, 220, 1, 2, 48, 32, 20, 6, - 49, 32, 76, 79, 78, 71, 30, 56, 156, 2, 2, 55, 32, 240, 193, 9, 3, 52, - 32, 78, 236, 49, 4, 54, 32, 71, 85, 160, 140, 5, 2, 53, 32, 216, 88, 3, - 50, 32, 83, 0, 2, 51, 32, 241, 101, 2, 57, 32, 2, 199, 130, 15, 74, 2, - 193, 164, 12, 2, 32, 77, 2, 243, 212, 12, 32, 24, 198, 1, 50, 2, 52, 36, - 6, 53, 32, 76, 79, 78, 71, 28, 3, 55, 32, 78, 34, 56, 220, 242, 11, 2, - 54, 32, 196, 98, 3, 57, 32, 75, 148, 131, 3, 3, 51, 32, 86, 240, 113, 4, - 48, 32, 78, 89, 219, 53, 49, 4, 129, 130, 15, 4, 32, 77, 66, 79, 2, 153, - 172, 17, 2, 32, 74, 2, 11, 71, 2, 203, 254, 15, 85, 2, 207, 244, 15, 32, - 20, 212, 1, 2, 48, 32, 22, 49, 22, 50, 20, 6, 51, 32, 76, 79, 78, 71, 34, - 56, 220, 137, 9, 2, 53, 32, 128, 129, 1, 3, 52, 32, 78, 232, 198, 2, 2, - 54, 32, 216, 129, 3, 4, 55, 32, 77, 66, 237, 30, 4, 57, 32, 77, 85, 2, - 239, 253, 14, 68, 2, 147, 137, 10, 32, 2, 139, 218, 10, 32, 2, 217, 184, - 15, 3, 32, 78, 71, 2, 17, 2, 32, 77, 2, 215, 213, 15, 66, 16, 142, 1, 48, - 32, 3, 49, 32, 78, 20, 3, 50, 32, 78, 20, 2, 51, 32, 20, 3, 52, 32, 87, - 22, 53, 20, 2, 54, 32, 157, 208, 12, 3, 55, 32, 70, 2, 11, 32, 2, 167, - 212, 15, 71, 2, 147, 212, 15, 68, 2, 183, 161, 17, 74, 2, 159, 246, 16, - 72, 2, 159, 178, 17, 85, 2, 199, 249, 15, 32, 2, 163, 145, 1, 83, 248, 1, - 72, 6, 79, 73, 84, 73, 67, 32, 136, 255, 10, 2, 67, 85, 191, 193, 2, 80, - 244, 1, 104, 8, 67, 85, 82, 83, 73, 86, 69, 32, 221, 10, 13, 72, 73, 69, - 82, 79, 71, 76, 89, 80, 72, 73, 67, 32, 180, 1, 96, 9, 70, 82, 65, 67, - 84, 73, 79, 78, 32, 250, 2, 76, 133, 3, 7, 78, 85, 77, 66, 69, 82, 32, - 24, 78, 69, 50, 70, 44, 4, 79, 78, 69, 32, 46, 83, 50, 84, 61, 3, 78, 73, - 78, 4, 160, 1, 2, 76, 69, 93, 4, 73, 71, 72, 84, 4, 192, 1, 2, 73, 86, - 13, 3, 79, 85, 82, 4, 192, 187, 15, 4, 84, 87, 69, 76, 19, 72, 4, 26, 69, - 93, 2, 73, 88, 2, 65, 2, 86, 69, 6, 46, 69, 12, 3, 72, 82, 69, 13, 2, 87, - 79, 2, 23, 78, 2, 11, 69, 2, 161, 189, 15, 5, 32, 84, 87, 69, 76, 52, 76, - 6, 69, 84, 84, 69, 82, 32, 137, 2, 8, 79, 71, 79, 71, 82, 65, 77, 32, 48, - 182, 1, 65, 46, 84, 238, 235, 1, 78, 2, 83, 214, 212, 13, 72, 234, 181, - 1, 75, 138, 69, 66, 2, 68, 2, 76, 2, 77, 2, 80, 2, 81, 2, 82, 2, 87, 2, - 89, 186, 2, 69, 2, 73, 3, 79, 5, 209, 177, 11, 6, 82, 67, 72, 65, 73, 67, - 6, 230, 189, 17, 65, 2, 69, 3, 79, 4, 254, 204, 4, 73, 153, 212, 12, 2, - 82, 77, 104, 92, 5, 69, 73, 71, 72, 84, 30, 70, 92, 4, 78, 73, 78, 69, - 54, 83, 78, 84, 73, 2, 79, 78, 11, 150, 1, 89, 223, 1, 32, 24, 18, 73, - 35, 79, 12, 142, 2, 86, 215, 231, 3, 70, 12, 148, 2, 2, 85, 82, 175, 231, - 3, 82, 11, 28, 2, 84, 89, 223, 1, 32, 2, 139, 157, 6, 32, 24, 40, 4, 69, - 86, 69, 78, 1, 2, 73, 88, 13, 154, 1, 32, 175, 231, 3, 84, 28, 34, 72, - 50, 87, 195, 155, 6, 69, 12, 32, 2, 82, 69, 163, 231, 3, 73, 8, 39, 69, - 12, 26, 79, 163, 231, 3, 69, 9, 11, 32, 6, 230, 153, 6, 72, 207, 195, 5, - 84, 64, 96, 7, 76, 69, 84, 84, 69, 82, 32, 253, 162, 3, 11, 83, 89, 77, - 66, 79, 76, 32, 86, 73, 68, 74, 60, 174, 1, 66, 2, 82, 22, 78, 30, 83, - 38, 84, 146, 185, 15, 72, 234, 181, 1, 75, 138, 69, 68, 2, 76, 2, 77, 2, - 80, 2, 81, 2, 87, 2, 89, 186, 2, 65, 2, 69, 2, 73, 3, 79, 4, 203, 161, 3, - 65, 8, 182, 161, 3, 65, 3, 69, 6, 154, 161, 3, 65, 195, 149, 14, 69, 10, - 246, 160, 3, 65, 2, 69, 195, 149, 14, 79, 2, 167, 167, 12, 73, 22, 26, - 82, 131, 248, 16, 73, 20, 44, 5, 73, 67, 65, 76, 32, 175, 181, 17, 79, - 18, 116, 10, 76, 79, 78, 71, 32, 79, 86, 69, 82, 32, 74, 80, 26, 84, 168, - 1, 7, 83, 72, 79, 82, 84, 32, 79, 215, 32, 66, 4, 232, 241, 2, 2, 83, 72, - 169, 253, 10, 7, 84, 87, 79, 32, 83, 72, 79, 2, 109, 3, 69, 78, 84, 8, - 66, 69, 34, 82, 41, 10, 87, 79, 32, 83, 72, 79, 82, 84, 83, 32, 2, 17, 2, - 84, 82, 2, 23, 65, 2, 11, 73, 2, 241, 152, 16, 2, 83, 69, 4, 26, 79, 159, - 255, 7, 74, 2, 129, 191, 10, 4, 86, 69, 82, 32, 230, 2, 104, 3, 65, 79, - 32, 136, 18, 2, 67, 82, 142, 1, 68, 142, 1, 76, 130, 1, 78, 245, 2, 4, - 82, 82, 79, 82, 170, 2, 156, 1, 7, 76, 69, 84, 84, 69, 82, 32, 180, 10, - 5, 83, 73, 71, 78, 32, 212, 1, 5, 84, 79, 78, 69, 32, 69, 11, 86, 79, 87, - 69, 76, 32, 83, 73, 71, 78, 32, 178, 1, 214, 1, 65, 110, 66, 34, 68, 106, - 71, 34, 76, 50, 78, 106, 82, 170, 1, 83, 54, 84, 218, 1, 86, 32, 3, 89, - 73, 32, 118, 90, 162, 176, 13, 81, 234, 233, 1, 80, 222, 196, 1, 72, 2, - 77, 138, 69, 70, 2, 75, 2, 87, 3, 88, 10, 52, 7, 82, 67, 72, 65, 73, 67, - 32, 227, 173, 17, 72, 8, 186, 255, 8, 90, 162, 184, 4, 78, 207, 243, 3, - 77, 4, 210, 153, 17, 82, 219, 19, 65, 16, 50, 90, 154, 4, 76, 138, 166, - 17, 68, 187, 2, 65, 8, 254, 152, 17, 89, 162, 17, 72, 2, 90, 187, 2, 65, - 6, 226, 228, 16, 72, 195, 71, 65, 8, 222, 179, 10, 72, 238, 245, 6, 89, - 187, 2, 65, 18, 54, 65, 222, 227, 16, 71, 2, 78, 2, 89, 139, 69, 72, 5, - 11, 83, 2, 193, 229, 13, 4, 65, 76, 73, 90, 16, 60, 9, 69, 70, 79, 82, - 77, 69, 68, 32, 84, 219, 147, 17, 84, 14, 40, 4, 79, 78, 69, 45, 219, - 172, 15, 83, 12, 254, 169, 17, 49, 2, 50, 2, 52, 2, 53, 2, 54, 3, 56, 8, - 234, 149, 17, 89, 162, 17, 72, 2, 83, 187, 2, 65, 32, 78, 76, 20, 4, 79, - 78, 69, 45, 70, 83, 178, 165, 17, 84, 186, 2, 65, 3, 69, 4, 155, 176, 10, - 72, 14, 170, 168, 17, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 3, 56, 8, - 174, 165, 17, 72, 2, 83, 186, 2, 65, 3, 69, 4, 254, 164, 17, 70, 187, 2, - 65, 16, 70, 84, 168, 169, 15, 2, 68, 90, 146, 63, 78, 226, 187, 1, 75, 3, - 80, 8, 142, 223, 16, 83, 138, 69, 84, 187, 2, 65, 16, 50, 90, 178, 222, - 16, 83, 138, 69, 72, 187, 2, 65, 8, 202, 173, 10, 83, 238, 245, 6, 89, - 187, 2, 65, 8, 144, 1, 9, 82, 69, 70, 79, 82, 77, 69, 68, 32, 34, 65, - 185, 128, 16, 18, 67, 79, 78, 83, 79, 78, 65, 78, 84, 32, 77, 79, 68, 73, - 70, 73, 69, 82, 4, 30, 65, 221, 88, 2, 86, 79, 2, 185, 145, 12, 3, 83, - 80, 73, 8, 254, 129, 15, 66, 204, 78, 3, 84, 79, 80, 182, 86, 65, 159, - 82, 82, 104, 146, 1, 65, 78, 69, 62, 73, 78, 79, 74, 85, 74, 89, 148, - 145, 7, 9, 82, 79, 85, 78, 68, 69, 68, 32, 69, 238, 196, 7, 87, 178, 75, - 78, 227, 127, 86, 19, 146, 164, 15, 78, 226, 189, 1, 69, 146, 63, 72, - 146, 1, 65, 2, 73, 3, 85, 15, 170, 203, 13, 82, 158, 216, 1, 78, 130, - 254, 1, 65, 3, 73, 23, 254, 162, 15, 65, 54, 79, 134, 253, 1, 78, 86, 69, - 2, 71, 2, 73, 3, 85, 13, 42, 69, 150, 160, 17, 71, 2, 79, 3, 85, 4, 146, - 160, 17, 82, 3, 89, 19, 234, 161, 15, 65, 182, 234, 1, 69, 134, 19, 78, - 2, 79, 86, 73, 3, 85, 7, 214, 139, 17, 85, 219, 19, 73, 12, 18, 32, 63, - 79, 4, 168, 137, 16, 4, 79, 78, 32, 85, 13, 4, 68, 65, 83, 72, 8, 194, - 232, 11, 83, 154, 137, 4, 80, 242, 37, 32, 163, 112, 66, 12, 64, 4, 68, - 76, 69, 32, 161, 219, 4, 6, 76, 73, 78, 69, 32, 72, 10, 144, 189, 5, 3, - 84, 72, 73, 198, 232, 8, 76, 22, 82, 159, 167, 2, 68, 8, 76, 6, 73, 84, - 65, 82, 89, 32, 216, 189, 10, 3, 75, 89, 32, 211, 215, 5, 76, 4, 26, 72, - 143, 177, 12, 77, 2, 187, 173, 4, 69, 24, 42, 73, 76, 2, 85, 83, 131, - 155, 17, 89, 6, 34, 68, 22, 77, 179, 146, 15, 66, 2, 255, 152, 6, 73, 2, - 155, 233, 6, 73, 16, 46, 32, 205, 178, 10, 5, 45, 79, 82, 45, 80, 14, 40, - 4, 83, 73, 71, 78, 211, 178, 13, 84, 13, 11, 32, 10, 44, 5, 87, 73, 84, - 72, 32, 171, 169, 6, 73, 8, 66, 67, 218, 198, 4, 68, 230, 173, 8, 82, 21, - 4, 70, 65, 76, 76, 2, 229, 237, 11, 3, 79, 77, 77, 5, 195, 142, 15, 32, - 186, 9, 184, 1, 10, 66, 73, 76, 69, 32, 80, 72, 79, 78, 69, 166, 1, 68, - 198, 76, 78, 178, 27, 79, 172, 1, 3, 83, 81, 85, 38, 84, 250, 1, 85, 142, - 183, 11, 89, 189, 225, 2, 5, 86, 73, 69, 32, 67, 7, 11, 32, 4, 108, 21, - 87, 73, 84, 72, 32, 82, 73, 71, 72, 84, 87, 65, 82, 68, 83, 32, 65, 82, - 82, 79, 87, 195, 178, 1, 79, 2, 11, 32, 2, 225, 227, 16, 2, 65, 84, 156, - 6, 58, 69, 74, 73, 157, 75, 7, 85, 76, 79, 32, 84, 87, 79, 4, 208, 197, - 16, 10, 82, 78, 32, 80, 69, 78, 84, 65, 84, 72, 159, 18, 76, 150, 6, 42, - 32, 221, 1, 5, 70, 73, 69, 82, 32, 158, 1, 88, 5, 83, 73, 71, 78, 32, - 210, 175, 3, 86, 170, 163, 3, 68, 186, 1, 76, 243, 203, 4, 65, 10, 42, - 65, 142, 213, 8, 72, 179, 251, 7, 86, 4, 44, 5, 82, 68, 72, 65, 67, 175, - 206, 16, 78, 2, 213, 206, 16, 3, 65, 78, 68, 248, 4, 92, 12, 66, 82, 69, - 86, 69, 32, 87, 73, 84, 72, 32, 73, 89, 7, 76, 69, 84, 84, 69, 82, 32, 2, - 33, 6, 78, 86, 69, 82, 84, 69, 2, 21, 3, 68, 32, 66, 2, 129, 149, 16, 2, - 82, 69, 246, 4, 198, 1, 65, 82, 66, 66, 67, 198, 13, 68, 202, 1, 69, 182, - 2, 71, 82, 72, 46, 76, 230, 4, 77, 216, 3, 7, 79, 80, 69, 78, 32, 83, 72, - 22, 80, 38, 82, 182, 4, 83, 206, 33, 84, 114, 85, 118, 86, 63, 89, 6, 38, - 76, 166, 27, 67, 151, 205, 10, 80, 2, 253, 19, 6, 86, 69, 79, 76, 65, 82, - 6, 192, 19, 5, 73, 76, 65, 66, 73, 193, 45, 4, 69, 71, 73, 78, 162, 1, - 240, 1, 7, 65, 80, 73, 84, 65, 76, 32, 200, 2, 7, 69, 78, 84, 82, 69, 68, - 32, 100, 13, 72, 73, 78, 69, 83, 69, 32, 84, 79, 78, 69, 32, 89, 108, 8, - 89, 82, 73, 76, 76, 73, 67, 32, 142, 226, 10, 73, 244, 2, 4, 82, 79, 83, - 83, 219, 211, 5, 79, 58, 214, 1, 66, 42, 82, 130, 27, 72, 238, 152, 13, - 79, 222, 150, 3, 65, 162, 64, 67, 2, 68, 2, 69, 2, 70, 2, 71, 2, 73, 2, - 74, 2, 75, 2, 76, 2, 77, 2, 78, 2, 80, 2, 81, 2, 83, 2, 84, 2, 85, 2, 86, - 3, 87, 5, 161, 146, 6, 5, 65, 82, 82, 69, 68, 7, 41, 8, 69, 86, 69, 82, - 83, 69, 68, 32, 4, 186, 138, 17, 69, 3, 78, 4, 30, 76, 21, 3, 82, 73, 71, - 2, 29, 2, 69, 70, 2, 11, 72, 2, 11, 84, 2, 181, 26, 2, 32, 72, 16, 36, 3, - 65, 78, 71, 1, 2, 73, 78, 8, 11, 32, 8, 218, 140, 12, 83, 170, 171, 4, - 80, 158, 44, 81, 3, 82, 78, 34, 72, 30, 83, 179, 184, 16, 69, 2, 233, - 156, 15, 2, 65, 82, 74, 40, 5, 77, 65, 76, 76, 32, 183, 6, 79, 72, 186, - 1, 66, 138, 1, 68, 38, 69, 150, 1, 80, 58, 83, 94, 84, 34, 89, 150, 130, + 174, 254, 6, 55, 236, 161, 3, 3, 51, 32, 87, 236, 231, 2, 2, 48, 32, 172, + 60, 3, 56, 32, 71, 200, 235, 1, 3, 49, 32, 89, 1, 3, 52, 32, 86, 2, 255, + 226, 17, 66, 2, 135, 238, 17, 66, 2, 145, 199, 16, 3, 32, 78, 71, 20, + 192, 1, 2, 50, 32, 34, 52, 26, 53, 34, 54, 36, 2, 55, 32, 200, 7, 2, 48, + 32, 240, 163, 10, 3, 56, 32, 75, 136, 200, 2, 2, 49, 32, 224, 146, 3, 5, + 57, 32, 78, 71, 71, 253, 213, 1, 2, 51, 32, 2, 11, 78, 2, 163, 253, 17, + 74, 2, 177, 5, 2, 32, 77, 2, 11, 32, 2, 203, 235, 17, 71, 2, 153, 176, + 15, 4, 32, 78, 71, 71, 2, 179, 137, 16, 74, 20, 212, 1, 2, 48, 32, 20, 6, + 49, 32, 76, 79, 78, 71, 30, 51, 22, 56, 156, 2, 2, 55, 32, 212, 233, 9, + 3, 52, 32, 78, 248, 49, 4, 54, 32, 71, 85, 224, 143, 5, 2, 53, 32, 188, + 89, 3, 50, 32, 83, 137, 105, 2, 57, 32, 2, 139, 174, 15, 74, 2, 169, 168, + 16, 2, 32, 77, 2, 151, 135, 16, 32, 2, 175, 254, 12, 32, 24, 198, 1, 50, + 2, 52, 36, 6, 53, 32, 76, 79, 78, 71, 28, 3, 55, 32, 78, 34, 56, 168, + 156, 12, 2, 54, 32, 180, 98, 3, 57, 32, 75, 236, 133, 3, 3, 51, 32, 86, + 136, 117, 4, 48, 32, 78, 89, 219, 53, 49, 4, 177, 173, 15, 4, 32, 77, 66, + 79, 2, 197, 219, 17, 2, 32, 74, 2, 11, 71, 2, 255, 170, 16, 85, 2, 235, + 160, 16, 32, 20, 212, 1, 2, 48, 32, 22, 49, 22, 50, 20, 6, 51, 32, 76, + 79, 78, 71, 34, 56, 204, 177, 9, 2, 53, 32, 140, 129, 1, 3, 52, 32, 78, + 168, 200, 2, 2, 54, 32, 176, 132, 3, 4, 55, 32, 77, 66, 245, 30, 4, 57, + 32, 77, 85, 2, 159, 169, 15, 68, 2, 135, 177, 10, 32, 2, 247, 131, 11, + 32, 2, 229, 228, 15, 3, 32, 78, 71, 2, 17, 2, 32, 77, 2, 235, 129, 16, + 66, 16, 142, 1, 48, 32, 3, 49, 32, 78, 20, 3, 50, 32, 78, 20, 2, 51, 32, + 20, 3, 52, 32, 87, 22, 53, 20, 2, 54, 32, 217, 249, 12, 3, 55, 32, 70, 2, + 11, 32, 2, 187, 128, 16, 71, 2, 167, 128, 16, 68, 2, 227, 208, 17, 74, 2, + 203, 165, 17, 72, 2, 203, 225, 17, 85, 2, 251, 165, 16, 32, 2, 167, 157, + 1, 83, 248, 1, 72, 6, 79, 73, 84, 73, 67, 32, 244, 168, 11, 2, 67, 85, + 179, 193, 2, 80, 244, 1, 104, 8, 67, 85, 82, 83, 73, 86, 69, 32, 221, 10, + 13, 72, 73, 69, 82, 79, 71, 76, 89, 80, 72, 73, 67, 32, 180, 1, 96, 9, + 70, 82, 65, 67, 84, 73, 79, 78, 32, 250, 2, 76, 133, 3, 7, 78, 85, 77, + 66, 69, 82, 32, 24, 78, 69, 50, 70, 44, 4, 79, 78, 69, 32, 46, 83, 50, + 84, 61, 3, 78, 73, 78, 4, 160, 1, 2, 76, 69, 93, 4, 73, 71, 72, 84, 4, + 192, 1, 2, 73, 86, 13, 3, 79, 85, 82, 4, 212, 231, 15, 4, 84, 87, 69, 76, + 19, 72, 4, 26, 69, 93, 2, 73, 88, 2, 65, 2, 86, 69, 6, 46, 69, 12, 3, 72, + 82, 69, 13, 2, 87, 79, 2, 23, 78, 2, 11, 69, 2, 181, 233, 15, 5, 32, 84, + 87, 69, 76, 52, 76, 6, 69, 84, 84, 69, 82, 32, 137, 2, 8, 79, 71, 79, 71, + 82, 65, 77, 32, 48, 182, 1, 65, 46, 84, 202, 143, 2, 78, 2, 83, 142, 221, + 13, 72, 130, 185, 1, 75, 138, 69, 66, 2, 68, 2, 76, 2, 77, 2, 80, 2, 81, + 2, 82, 2, 87, 2, 89, 186, 2, 69, 2, 73, 3, 79, 5, 149, 219, 11, 6, 82, + 67, 72, 65, 73, 67, 6, 146, 237, 17, 65, 2, 69, 3, 79, 4, 130, 242, 4, + 73, 193, 222, 12, 2, 82, 77, 104, 92, 5, 69, 73, 71, 72, 84, 30, 70, 92, + 4, 78, 73, 78, 69, 54, 83, 78, 84, 73, 2, 79, 78, 11, 150, 1, 89, 223, 1, + 32, 24, 18, 73, 35, 79, 12, 142, 2, 86, 203, 140, 4, 70, 12, 148, 2, 2, + 85, 82, 163, 140, 4, 82, 11, 28, 2, 84, 89, 223, 1, 32, 2, 159, 195, 6, + 32, 24, 40, 4, 69, 86, 69, 78, 1, 2, 73, 88, 13, 154, 1, 32, 163, 140, 4, + 84, 28, 34, 72, 50, 87, 215, 193, 6, 69, 12, 32, 2, 82, 69, 151, 140, 4, + 73, 8, 39, 69, 12, 26, 79, 151, 140, 4, 69, 9, 11, 32, 6, 250, 191, 6, + 72, 135, 199, 5, 84, 64, 96, 7, 76, 69, 84, 84, 69, 82, 32, 237, 198, 3, + 11, 83, 89, 77, 66, 79, 76, 32, 86, 73, 68, 74, 60, 174, 1, 66, 2, 82, + 22, 78, 30, 83, 38, 84, 166, 229, 15, 72, 130, 185, 1, 75, 138, 69, 68, + 2, 76, 2, 77, 2, 80, 2, 81, 2, 87, 2, 89, 186, 2, 65, 2, 69, 2, 73, 3, + 79, 4, 187, 197, 3, 65, 8, 166, 197, 3, 65, 3, 69, 6, 138, 197, 3, 65, + 255, 160, 14, 69, 10, 230, 196, 3, 65, 2, 69, 255, 160, 14, 79, 2, 227, + 208, 12, 73, 24, 38, 82, 162, 167, 17, 73, 247, 4, 69, 20, 44, 5, 73, 67, + 65, 76, 32, 207, 228, 17, 79, 18, 116, 10, 76, 79, 78, 71, 32, 79, 86, + 69, 82, 32, 74, 80, 26, 84, 168, 1, 7, 83, 72, 79, 82, 84, 32, 79, 227, + 32, 66, 4, 204, 149, 3, 2, 83, 72, 237, 131, 11, 7, 84, 87, 79, 32, 83, + 72, 79, 2, 109, 3, 69, 78, 84, 8, 66, 69, 34, 82, 41, 10, 87, 79, 32, 83, + 72, 79, 82, 84, 83, 32, 2, 17, 2, 84, 82, 2, 23, 65, 2, 11, 73, 2, 145, + 200, 16, 2, 83, 69, 4, 26, 79, 247, 166, 8, 74, 2, 225, 232, 10, 4, 86, + 69, 82, 32, 230, 2, 104, 3, 65, 79, 32, 140, 18, 2, 67, 82, 142, 1, 68, + 142, 1, 76, 130, 1, 78, 253, 2, 4, 82, 82, 79, 82, 170, 2, 156, 1, 7, 76, + 69, 84, 84, 69, 82, 32, 180, 10, 5, 83, 73, 71, 78, 32, 212, 1, 5, 84, + 79, 78, 69, 32, 69, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 178, + 1, 214, 1, 65, 110, 66, 34, 68, 106, 71, 34, 76, 50, 78, 106, 82, 170, 1, + 83, 54, 84, 218, 1, 86, 32, 3, 89, 73, 32, 118, 90, 138, 218, 13, 81, + 130, 236, 1, 80, 254, 199, 1, 72, 2, 77, 138, 69, 70, 2, 75, 2, 87, 3, + 88, 10, 52, 7, 82, 67, 72, 65, 73, 67, 32, 131, 221, 17, 72, 8, 130, 167, + 9, 90, 194, 186, 4, 78, 135, 249, 3, 77, 4, 242, 200, 17, 82, 219, 19, + 65, 16, 50, 90, 154, 4, 76, 170, 213, 17, 68, 187, 2, 65, 8, 158, 200, + 17, 89, 162, 17, 72, 2, 90, 187, 2, 65, 6, 130, 148, 17, 72, 195, 71, 65, + 8, 190, 221, 10, 72, 174, 251, 6, 89, 187, 2, 65, 18, 54, 65, 254, 146, + 17, 71, 2, 78, 2, 89, 139, 69, 72, 5, 11, 83, 2, 233, 143, 14, 4, 65, 76, + 73, 90, 16, 60, 9, 69, 70, 79, 82, 77, 69, 68, 32, 84, 251, 194, 17, 84, + 14, 40, 4, 79, 78, 69, 45, 227, 216, 15, 83, 12, 158, 217, 17, 49, 2, 50, + 2, 52, 2, 53, 2, 54, 3, 56, 8, 138, 197, 17, 89, 162, 17, 72, 2, 83, 187, + 2, 65, 32, 78, 76, 20, 4, 79, 78, 69, 45, 70, 83, 210, 212, 17, 84, 186, + 2, 65, 3, 69, 4, 251, 217, 10, 72, 14, 202, 215, 17, 50, 2, 51, 2, 52, 2, + 53, 2, 54, 2, 55, 3, 56, 8, 206, 212, 17, 72, 2, 83, 186, 2, 65, 3, 69, + 4, 158, 212, 17, 70, 187, 2, 65, 16, 70, 84, 176, 213, 15, 2, 68, 90, + 166, 63, 78, 230, 190, 1, 75, 3, 80, 8, 174, 142, 17, 83, 138, 69, 84, + 187, 2, 65, 16, 50, 90, 210, 141, 17, 83, 138, 69, 72, 187, 2, 65, 8, + 170, 215, 10, 83, 174, 251, 6, 89, 187, 2, 65, 8, 144, 1, 9, 82, 69, 70, + 79, 82, 77, 69, 68, 32, 34, 65, 153, 175, 16, 18, 67, 79, 78, 83, 79, 78, + 65, 78, 84, 32, 77, 79, 68, 73, 70, 73, 69, 82, 4, 30, 65, 145, 100, 2, + 86, 79, 2, 217, 186, 12, 3, 83, 80, 73, 8, 254, 173, 15, 66, 220, 78, 3, + 84, 79, 80, 198, 89, 65, 159, 82, 82, 104, 150, 1, 65, 78, 69, 62, 73, + 78, 79, 74, 85, 74, 89, 232, 184, 7, 9, 82, 79, 85, 78, 68, 69, 68, 32, + 69, 186, 200, 7, 87, 150, 76, 78, 251, 130, 1, 86, 19, 150, 208, 15, 78, + 250, 192, 1, 69, 146, 63, 72, 146, 1, 65, 2, 73, 3, 85, 15, 214, 245, 13, + 82, 246, 217, 1, 78, 154, 129, 2, 65, 3, 73, 23, 130, 207, 15, 65, 54, + 79, 158, 128, 2, 78, 86, 69, 2, 71, 2, 73, 3, 85, 13, 42, 69, 178, 207, + 17, 71, 2, 79, 3, 85, 4, 174, 207, 17, 82, 3, 89, 19, 238, 205, 15, 65, + 206, 237, 1, 69, 134, 19, 78, 2, 79, 86, 73, 3, 85, 7, 242, 186, 17, 85, + 219, 19, 73, 12, 18, 32, 63, 79, 4, 196, 184, 16, 4, 79, 78, 32, 85, 13, + 4, 68, 65, 83, 72, 8, 142, 146, 12, 83, 170, 142, 4, 80, 178, 38, 32, + 163, 112, 66, 12, 64, 4, 68, 76, 69, 32, 165, 128, 5, 6, 76, 73, 78, 69, + 32, 72, 10, 232, 226, 5, 3, 84, 72, 73, 142, 238, 8, 76, 22, 82, 155, + 171, 2, 68, 8, 76, 6, 73, 84, 65, 82, 89, 32, 180, 231, 10, 3, 75, 89, + 32, 147, 221, 5, 76, 4, 26, 72, 191, 218, 12, 77, 2, 175, 210, 4, 69, 24, + 42, 73, 76, 2, 85, 83, 159, 202, 17, 89, 6, 34, 68, 22, 77, 183, 190, 15, + 66, 2, 163, 191, 6, 73, 2, 239, 144, 7, 73, 16, 46, 32, 169, 220, 10, 5, + 45, 79, 82, 45, 80, 14, 40, 4, 83, 73, 71, 78, 255, 220, 13, 84, 13, 11, + 32, 10, 44, 5, 87, 73, 84, 72, 32, 199, 207, 6, 73, 8, 66, 67, 222, 235, + 4, 68, 146, 178, 8, 82, 21, 4, 70, 65, 76, 76, 2, 11, 79, 2, 165, 151, + 12, 2, 77, 77, 5, 183, 186, 15, 32, 178, 10, 184, 1, 10, 66, 73, 76, 69, + 32, 80, 72, 79, 78, 69, 166, 1, 68, 238, 87, 78, 246, 27, 79, 172, 1, 3, + 83, 81, 85, 38, 84, 250, 1, 85, 198, 212, 11, 89, 141, 228, 2, 5, 86, 73, + 69, 32, 67, 7, 11, 32, 4, 108, 21, 87, 73, 84, 72, 32, 82, 73, 71, 72, + 84, 87, 65, 82, 68, 83, 32, 65, 82, 82, 79, 87, 239, 217, 1, 79, 2, 11, + 32, 2, 245, 146, 17, 2, 65, 84, 146, 7, 58, 69, 74, 73, 197, 86, 7, 85, + 76, 79, 32, 84, 87, 79, 4, 228, 244, 16, 10, 82, 78, 32, 80, 69, 78, 84, + 65, 84, 72, 159, 18, 76, 140, 7, 42, 32, 221, 1, 5, 70, 73, 69, 82, 32, + 158, 1, 88, 5, 83, 73, 71, 78, 32, 174, 212, 3, 86, 154, 166, 3, 68, 186, + 1, 76, 219, 205, 4, 65, 10, 42, 65, 230, 252, 8, 72, 239, 130, 8, 86, 4, + 44, 5, 82, 68, 72, 65, 67, 195, 253, 16, 78, 2, 233, 253, 16, 3, 65, 78, + 68, 238, 5, 92, 12, 66, 82, 69, 86, 69, 32, 87, 73, 84, 72, 32, 73, 93, + 7, 76, 69, 84, 84, 69, 82, 32, 2, 33, 6, 78, 86, 69, 82, 84, 69, 2, 21, + 3, 68, 32, 66, 2, 11, 82, 2, 139, 196, 16, 69, 236, 5, 254, 1, 65, 194, + 1, 66, 66, 67, 234, 13, 68, 202, 1, 69, 182, 2, 71, 82, 72, 118, 76, 230, + 4, 77, 200, 3, 7, 79, 80, 69, 78, 32, 83, 72, 22, 80, 38, 82, 158, 4, 83, + 212, 24, 10, 73, 78, 86, 69, 82, 84, 69, 68, 32, 71, 178, 18, 84, 114, + 85, 118, 86, 63, 89, 12, 102, 76, 40, 14, 82, 77, 69, 78, 73, 65, 78, 32, + 83, 77, 65, 76, 76, 32, 138, 28, 67, 215, 244, 10, 80, 2, 153, 21, 6, 86, + 69, 79, 76, 65, 82, 6, 238, 178, 12, 73, 242, 246, 4, 89, 203, 18, 69, 6, + 172, 20, 5, 73, 76, 65, 66, 73, 209, 54, 4, 69, 71, 73, 78, 162, 1, 240, + 1, 7, 65, 80, 73, 84, 65, 76, 32, 200, 2, 7, 69, 78, 84, 82, 69, 68, 32, + 100, 13, 72, 73, 78, 69, 83, 69, 32, 84, 79, 78, 69, 32, 89, 108, 8, 89, + 82, 73, 76, 76, 73, 67, 32, 170, 138, 11, 73, 216, 2, 4, 82, 79, 83, 83, + 195, 217, 5, 79, 58, 214, 1, 66, 42, 82, 190, 67, 72, 170, 153, 13, 79, + 206, 155, 3, 65, 162, 64, 67, 2, 68, 2, 69, 2, 70, 2, 71, 2, 73, 2, 74, + 2, 75, 2, 76, 2, 77, 2, 78, 2, 80, 2, 81, 2, 83, 2, 84, 2, 85, 2, 86, 3, + 87, 5, 145, 183, 6, 5, 65, 82, 82, 69, 68, 7, 41, 8, 69, 86, 69, 82, 83, + 69, 68, 32, 4, 162, 184, 17, 69, 3, 78, 4, 30, 76, 21, 3, 82, 73, 71, 2, + 29, 2, 69, 70, 2, 11, 72, 2, 11, 84, 2, 249, 26, 2, 32, 72, 16, 36, 3, + 65, 78, 71, 1, 2, 73, 78, 8, 11, 32, 8, 210, 180, 12, 83, 154, 177, 4, + 80, 158, 44, 81, 3, 82, 78, 34, 72, 30, 83, 155, 230, 16, 69, 2, 185, + 199, 15, 2, 65, 82, 74, 40, 5, 77, 65, 76, 76, 32, 219, 6, 79, 72, 186, + 1, 66, 174, 1, 68, 38, 69, 150, 1, 80, 58, 83, 94, 84, 34, 89, 218, 175, 16, 90, 130, 64, 73, 150, 19, 67, 2, 71, 186, 22, 74, 2, 86, 158, 20, 72, - 2, 75, 186, 2, 65, 2, 79, 3, 85, 6, 38, 89, 198, 27, 65, 191, 234, 16, - 69, 2, 237, 202, 1, 19, 69, 76, 79, 82, 85, 83, 83, 73, 65, 78, 45, 85, - 75, 82, 65, 73, 78, 73, 65, 4, 166, 211, 6, 90, 251, 177, 10, 69, 15, 50, - 83, 202, 132, 17, 70, 2, 76, 2, 77, 3, 82, 5, 25, 4, 32, 87, 73, 84, 2, - 21, 3, 72, 32, 68, 2, 11, 69, 2, 177, 152, 13, 3, 83, 67, 69, 4, 26, 65, - 207, 131, 17, 69, 2, 129, 215, 16, 2, 76, 79, 8, 42, 84, 226, 173, 1, 67, - 239, 210, 15, 72, 4, 153, 19, 8, 82, 65, 73, 71, 72, 84, 32, 85, 4, 254, - 235, 16, 83, 215, 22, 69, 6, 36, 3, 69, 82, 85, 143, 130, 17, 85, 5, 37, - 7, 32, 87, 73, 84, 72, 32, 66, 2, 21, 3, 65, 67, 75, 2, 221, 195, 16, 2, - 32, 89, 2, 227, 181, 11, 70, 16, 18, 69, 27, 79, 2, 169, 5, 2, 78, 84, - 14, 64, 2, 84, 32, 52, 5, 85, 66, 76, 69, 32, 129, 52, 2, 87, 78, 6, 214, - 219, 9, 83, 210, 202, 4, 86, 247, 181, 1, 72, 4, 210, 137, 2, 65, 155, - 244, 2, 80, 24, 40, 5, 88, 84, 82, 65, 45, 131, 49, 78, 20, 52, 5, 72, - 73, 71, 72, 32, 81, 4, 76, 79, 87, 32, 10, 156, 1, 9, 69, 88, 84, 82, 65, - 45, 76, 79, 87, 154, 7, 68, 70, 76, 79, 84, 10, 76, 10, 69, 88, 84, 82, - 65, 45, 72, 73, 71, 72, 154, 7, 68, 70, 76, 79, 84, 2, 145, 8, 8, 32, 67, - 79, 78, 84, 79, 85, 82, 8, 162, 9, 82, 226, 3, 76, 225, 204, 15, 9, 69, - 79, 82, 71, 73, 65, 78, 32, 78, 10, 248, 5, 4, 73, 71, 72, 32, 255, 40, - 65, 44, 46, 65, 84, 2, 79, 87, 201, 11, 2, 69, 70, 2, 21, 3, 84, 69, 82, - 2, 17, 2, 65, 76, 2, 17, 2, 32, 67, 2, 163, 201, 15, 76, 36, 86, 32, 185, - 146, 12, 15, 69, 82, 32, 82, 73, 71, 72, 84, 32, 67, 79, 82, 78, 69, 82, - 34, 158, 1, 67, 20, 2, 68, 79, 40, 4, 76, 69, 70, 84, 82, 77, 12, 2, 82, - 73, 50, 84, 178, 3, 65, 42, 71, 170, 2, 73, 224, 152, 14, 2, 85, 80, 255, - 188, 1, 86, 2, 227, 210, 10, 73, 6, 238, 2, 84, 165, 157, 14, 2, 87, 78, - 6, 28, 2, 32, 65, 247, 2, 45, 4, 25, 4, 82, 82, 79, 87, 5, 239, 159, 14, - 72, 2, 111, 65, 4, 140, 159, 14, 3, 71, 72, 84, 175, 216, 2, 78, 4, 194, - 2, 79, 143, 216, 14, 73, 18, 18, 65, 23, 73, 2, 247, 207, 15, 67, 16, 26, - 68, 231, 196, 13, 78, 14, 38, 32, 217, 1, 4, 68, 76, 69, 32, 8, 26, 68, - 70, 76, 79, 84, 4, 17, 2, 79, 84, 4, 25, 4, 84, 69, 68, 32, 4, 18, 76, - 79, 84, 2, 25, 4, 69, 70, 84, 45, 2, 25, 4, 83, 84, 69, 77, 2, 17, 2, 32, - 84, 2, 11, 79, 2, 11, 78, 2, 187, 209, 15, 69, 6, 40, 6, 68, 79, 85, 66, - 76, 69, 75, 71, 4, 11, 32, 4, 18, 65, 43, 71, 2, 11, 67, 2, 197, 208, 10, - 2, 85, 84, 2, 11, 82, 2, 147, 208, 10, 65, 2, 223, 237, 14, 69, 4, 186, - 193, 13, 76, 159, 152, 2, 82, 26, 104, 6, 65, 73, 83, 69, 68, 32, 150, 1, - 69, 216, 1, 3, 73, 71, 72, 245, 245, 8, 5, 72, 79, 84, 73, 67, 10, 70, - 68, 30, 73, 138, 214, 9, 69, 128, 255, 5, 2, 85, 80, 215, 76, 67, 2, 249, - 158, 15, 2, 79, 87, 2, 241, 213, 9, 7, 78, 86, 69, 82, 84, 69, 68, 8, - 104, 7, 86, 69, 82, 83, 69, 68, 32, 137, 28, 14, 84, 82, 79, 70, 76, 69, - 88, 32, 67, 76, 73, 67, 75, 32, 6, 26, 71, 215, 154, 14, 67, 4, 11, 76, - 4, 49, 10, 79, 84, 84, 65, 76, 32, 83, 84, 79, 80, 5, 171, 19, 32, 6, 17, - 2, 84, 32, 6, 38, 72, 202, 208, 13, 84, 239, 69, 65, 2, 249, 191, 7, 3, - 65, 76, 70, 156, 2, 138, 1, 72, 48, 5, 77, 65, 76, 76, 32, 148, 31, 8, - 84, 82, 69, 83, 83, 32, 65, 78, 53, 11, 85, 80, 69, 82, 83, 67, 82, 73, - 80, 84, 32, 4, 232, 153, 8, 3, 79, 82, 84, 251, 205, 6, 69, 144, 2, 154, - 2, 65, 50, 66, 130, 1, 67, 238, 2, 68, 238, 2, 90, 66, 69, 46, 70, 30, - 71, 110, 72, 102, 77, 34, 73, 34, 74, 98, 76, 176, 3, 7, 78, 32, 87, 73, - 84, 72, 32, 30, 79, 94, 80, 22, 82, 146, 2, 83, 190, 1, 84, 246, 7, 85, - 142, 1, 86, 150, 207, 16, 75, 2, 81, 2, 87, 2, 88, 3, 89, 9, 146, 143, - 13, 76, 170, 140, 3, 73, 227, 79, 69, 11, 46, 65, 50, 79, 222, 8, 32, - 231, 188, 16, 69, 2, 17, 2, 82, 82, 2, 221, 242, 5, 2, 69, 68, 2, 229, - 20, 4, 84, 84, 79, 77, 41, 100, 7, 65, 80, 73, 84, 65, 76, 32, 180, 1, 6, - 76, 79, 83, 69, 68, 32, 190, 17, 32, 191, 194, 16, 72, 30, 114, 73, 214, - 6, 71, 226, 16, 76, 138, 186, 16, 79, 158, 20, 65, 186, 2, 66, 2, 72, 2, - 78, 2, 82, 2, 85, 3, 89, 7, 22, 78, 191, 11, 32, 2, 149, 236, 5, 5, 86, - 69, 82, 84, 69, 4, 26, 82, 167, 162, 9, 79, 2, 217, 20, 9, 69, 86, 69, - 82, 83, 69, 68, 32, 79, 23, 104, 6, 32, 87, 73, 84, 72, 32, 86, 69, 32, - 9, 79, 84, 76, 69, 83, 83, 32, 74, 32, 105, 3, 90, 32, 68, 6, 26, 72, - 215, 174, 14, 84, 4, 21, 3, 79, 79, 75, 5, 137, 246, 13, 3, 32, 65, 78, - 4, 238, 15, 90, 135, 177, 16, 76, 4, 33, 6, 87, 73, 84, 72, 32, 83, 4, - 29, 5, 84, 82, 79, 75, 69, 5, 245, 234, 8, 4, 32, 65, 78, 68, 6, 33, 6, - 73, 71, 82, 65, 80, 72, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 138, 14, 67, - 207, 4, 82, 11, 194, 226, 16, 83, 2, 84, 2, 90, 63, 78, 5, 225, 13, 3, - 69, 78, 71, 11, 56, 5, 82, 69, 69, 75, 32, 162, 1, 32, 235, 139, 14, 65, - 4, 26, 71, 191, 138, 11, 80, 2, 235, 140, 14, 65, 11, 40, 6, 32, 87, 73, - 84, 72, 32, 39, 69, 4, 130, 140, 15, 72, 247, 165, 1, 83, 4, 17, 2, 78, - 71, 5, 11, 32, 2, 179, 231, 8, 87, 4, 222, 4, 32, 243, 183, 16, 79, 5, - 37, 7, 32, 87, 73, 84, 72, 32, 67, 2, 11, 82, 2, 149, 169, 14, 6, 79, 83, - 83, 69, 68, 45, 25, 116, 6, 32, 87, 73, 84, 72, 32, 226, 9, 83, 2, 90, - 112, 2, 69, 90, 245, 189, 16, 8, 73, 71, 65, 84, 85, 82, 69, 32, 12, 54, - 73, 82, 77, 82, 82, 222, 6, 80, 195, 240, 3, 66, 2, 49, 10, 78, 86, 69, - 82, 84, 69, 68, 32, 76, 65, 2, 209, 228, 12, 2, 90, 89, 2, 11, 73, 2, 17, - 2, 68, 68, 2, 17, 2, 76, 69, 2, 145, 246, 12, 2, 32, 84, 4, 61, 13, 69, - 84, 82, 79, 70, 76, 69, 88, 32, 72, 79, 79, 75, 5, 205, 12, 4, 32, 65, - 78, 68, 4, 210, 11, 82, 207, 1, 76, 9, 18, 32, 47, 80, 2, 21, 3, 87, 73, - 84, 2, 143, 172, 16, 72, 4, 153, 192, 12, 2, 69, 78, 5, 155, 200, 16, 72, - 15, 80, 6, 32, 87, 73, 84, 72, 32, 62, 65, 41, 8, 69, 86, 69, 82, 83, 69, - 68, 32, 4, 26, 70, 207, 163, 14, 84, 2, 149, 225, 8, 3, 73, 83, 72, 2, - 17, 2, 77, 83, 2, 159, 228, 5, 32, 6, 38, 71, 170, 7, 79, 219, 210, 16, - 69, 2, 11, 76, 2, 213, 132, 14, 4, 79, 84, 84, 65, 13, 72, 6, 32, 87, 73, - 84, 72, 32, 34, 67, 61, 6, 73, 68, 69, 87, 65, 89, 4, 158, 3, 67, 247, - 255, 14, 72, 4, 26, 82, 239, 222, 11, 72, 2, 133, 215, 5, 3, 73, 80, 84, - 2, 211, 189, 6, 83, 51, 106, 32, 102, 67, 116, 2, 69, 83, 44, 2, 79, 80, - 42, 83, 96, 6, 85, 82, 78, 69, 68, 32, 139, 151, 13, 72, 4, 29, 5, 87, - 73, 84, 72, 32, 4, 22, 80, 219, 5, 82, 2, 137, 221, 8, 6, 65, 76, 65, 84, - 65, 76, 2, 45, 9, 32, 68, 73, 71, 82, 65, 80, 72, 32, 2, 25, 4, 87, 73, - 84, 72, 2, 17, 2, 32, 67, 2, 227, 140, 3, 85, 2, 11, 72, 2, 241, 150, 10, - 3, 32, 68, 73, 2, 217, 221, 5, 5, 32, 72, 65, 76, 70, 4, 37, 7, 32, 68, - 73, 71, 82, 65, 80, 4, 11, 72, 5, 11, 32, 2, 141, 3, 4, 87, 73, 84, 72, - 32, 86, 65, 38, 77, 74, 79, 42, 82, 214, 1, 89, 222, 208, 16, 72, 2, 73, - 2, 86, 3, 87, 7, 186, 247, 12, 76, 139, 220, 3, 69, 5, 41, 8, 32, 87, 73, - 84, 72, 32, 76, 79, 2, 177, 137, 4, 2, 78, 71, 2, 11, 80, 2, 149, 154, 6, - 2, 69, 78, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 26, 76, 131, 252, 14, 72, - 4, 37, 7, 79, 78, 71, 32, 76, 69, 71, 5, 25, 4, 32, 65, 78, 68, 2, 17, 2, - 32, 82, 2, 11, 69, 2, 165, 215, 8, 7, 84, 82, 79, 70, 76, 69, 88, 5, 29, - 5, 32, 87, 73, 84, 72, 2, 137, 234, 3, 2, 32, 66, 9, 18, 32, 95, 80, 4, - 40, 4, 87, 73, 84, 72, 167, 172, 15, 66, 2, 17, 2, 32, 76, 2, 11, 69, 2, - 131, 1, 70, 2, 181, 255, 15, 2, 83, 73, 7, 33, 6, 32, 87, 73, 84, 72, 32, - 4, 26, 82, 231, 248, 14, 72, 2, 21, 3, 73, 71, 72, 2, 215, 212, 8, 84, 4, - 11, 68, 4, 11, 32, 4, 146, 210, 1, 72, 35, 76, 4, 24, 2, 72, 65, 31, 84, + 2, 75, 186, 2, 65, 2, 79, 3, 85, 6, 44, 3, 65, 82, 82, 30, 89, 199, 179, + 17, 69, 2, 157, 179, 6, 2, 69, 68, 2, 229, 236, 1, 19, 69, 76, 79, 82, + 85, 83, 83, 73, 65, 78, 45, 85, 75, 82, 65, 73, 78, 73, 65, 4, 162, 249, + 6, 90, 195, 185, 10, 69, 15, 50, 83, 142, 178, 17, 70, 2, 76, 2, 77, 3, + 82, 5, 25, 4, 32, 87, 73, 84, 2, 21, 3, 72, 32, 68, 2, 11, 69, 2, 133, + 193, 13, 3, 83, 67, 69, 4, 26, 65, 147, 177, 17, 69, 2, 197, 132, 17, 2, + 76, 79, 8, 42, 84, 214, 207, 1, 67, 191, 222, 15, 72, 4, 177, 59, 8, 82, + 65, 73, 71, 72, 84, 32, 85, 4, 194, 153, 17, 83, 215, 22, 69, 6, 36, 3, + 69, 82, 85, 211, 175, 17, 85, 5, 37, 7, 32, 87, 73, 84, 72, 32, 66, 2, + 21, 3, 65, 67, 75, 2, 161, 241, 16, 2, 32, 89, 2, 187, 221, 11, 70, 16, + 18, 69, 27, 79, 2, 241, 5, 2, 78, 84, 14, 64, 2, 84, 32, 52, 5, 85, 66, + 76, 69, 32, 217, 61, 2, 87, 78, 6, 226, 131, 10, 83, 142, 204, 4, 86, + 179, 185, 1, 72, 4, 218, 171, 2, 65, 159, 245, 2, 80, 24, 40, 5, 88, 84, + 82, 65, 45, 219, 58, 78, 20, 52, 5, 72, 73, 71, 72, 32, 81, 4, 76, 79, + 87, 32, 10, 156, 1, 9, 69, 88, 84, 82, 65, 45, 76, 79, 87, 226, 7, 68, + 70, 76, 79, 84, 10, 76, 10, 69, 88, 84, 82, 65, 45, 72, 73, 71, 72, 226, + 7, 68, 70, 76, 79, 84, 2, 217, 8, 8, 32, 67, 79, 78, 84, 79, 85, 82, 8, + 218, 9, 82, 214, 3, 76, 185, 249, 15, 9, 69, 79, 82, 71, 73, 65, 78, 32, + 78, 12, 36, 4, 73, 71, 72, 32, 171, 56, 65, 10, 182, 6, 68, 70, 76, 78, + 84, 153, 238, 15, 7, 65, 78, 68, 32, 76, 79, 87, 44, 46, 65, 84, 2, 79, + 87, 161, 11, 2, 69, 70, 2, 21, 3, 84, 69, 82, 2, 17, 2, 65, 76, 2, 17, 2, + 32, 67, 2, 223, 245, 15, 76, 36, 86, 32, 201, 185, 12, 15, 69, 82, 32, + 82, 73, 71, 72, 84, 32, 67, 79, 82, 78, 69, 82, 34, 158, 1, 67, 20, 2, + 68, 79, 40, 4, 76, 69, 70, 84, 82, 77, 12, 2, 82, 73, 50, 84, 162, 3, 65, + 42, 71, 162, 2, 73, 248, 193, 14, 2, 85, 80, 239, 192, 1, 86, 2, 147, + 250, 10, 73, 6, 238, 2, 84, 165, 198, 14, 2, 87, 78, 6, 28, 2, 32, 65, + 247, 2, 45, 4, 25, 4, 82, 82, 79, 87, 5, 239, 200, 14, 72, 2, 111, 65, 4, + 140, 200, 14, 3, 71, 72, 84, 171, 220, 2, 78, 4, 194, 2, 79, 235, 129, + 15, 73, 18, 18, 65, 23, 73, 2, 179, 252, 15, 67, 16, 26, 68, 219, 237, + 13, 78, 14, 38, 32, 201, 1, 4, 68, 76, 69, 32, 8, 26, 68, 70, 76, 79, 84, + 4, 17, 2, 79, 84, 4, 25, 4, 84, 69, 68, 32, 4, 18, 76, 79, 84, 2, 25, 4, + 69, 70, 84, 45, 2, 25, 4, 83, 84, 69, 77, 2, 17, 2, 32, 84, 2, 11, 79, 2, + 191, 18, 78, 6, 40, 6, 68, 79, 85, 66, 76, 69, 75, 71, 4, 11, 32, 4, 18, + 65, 43, 71, 2, 11, 67, 2, 233, 247, 10, 2, 85, 84, 2, 11, 82, 2, 183, + 247, 10, 65, 2, 211, 151, 15, 69, 4, 190, 234, 13, 76, 167, 156, 2, 82, + 26, 104, 6, 65, 73, 83, 69, 68, 32, 142, 1, 69, 200, 1, 3, 73, 71, 72, + 209, 155, 9, 5, 72, 79, 84, 73, 67, 10, 62, 68, 30, 73, 228, 129, 16, 2, + 85, 80, 86, 69, 187, 76, 67, 2, 253, 200, 15, 2, 79, 87, 2, 205, 253, 9, + 7, 78, 86, 69, 82, 84, 69, 68, 8, 104, 7, 86, 69, 82, 83, 69, 68, 32, + 249, 33, 14, 84, 82, 79, 70, 76, 69, 88, 32, 67, 76, 73, 67, 75, 32, 6, + 32, 2, 71, 76, 231, 195, 14, 67, 4, 157, 40, 10, 79, 84, 84, 65, 76, 32, + 83, 84, 79, 80, 6, 17, 2, 84, 32, 6, 38, 72, 242, 249, 13, 84, 239, 69, + 65, 2, 225, 229, 7, 3, 65, 76, 70, 136, 3, 114, 72, 48, 5, 77, 65, 76, + 76, 32, 156, 40, 3, 84, 82, 69, 125, 11, 85, 80, 69, 82, 83, 67, 82, 73, + 80, 84, 32, 4, 232, 191, 8, 3, 79, 82, 84, 159, 210, 6, 69, 250, 2, 166, + 2, 65, 50, 66, 182, 1, 67, 186, 3, 68, 190, 2, 69, 178, 1, 70, 30, 71, + 210, 1, 72, 114, 75, 2, 77, 18, 73, 34, 74, 122, 76, 240, 3, 7, 78, 32, + 87, 73, 84, 72, 32, 142, 1, 79, 54, 80, 30, 81, 82, 82, 210, 2, 83, 226, + 2, 84, 210, 9, 85, 162, 1, 86, 110, 90, 154, 244, 16, 87, 2, 88, 3, 89, + 9, 210, 183, 13, 76, 154, 145, 3, 73, 227, 79, 69, 17, 68, 6, 65, 82, 82, + 69, 68, 32, 78, 79, 154, 8, 32, 167, 234, 16, 69, 6, 34, 84, 178, 151, + 17, 79, 3, 87, 2, 133, 150, 6, 5, 85, 82, 78, 69, 68, 2, 189, 26, 4, 84, + 84, 79, 77, 51, 120, 6, 32, 87, 73, 84, 72, 32, 32, 7, 65, 80, 73, 84, + 65, 76, 32, 204, 1, 6, 76, 79, 83, 69, 68, 32, 171, 128, 17, 72, 4, 146, + 34, 67, 219, 154, 15, 72, 38, 146, 1, 73, 210, 7, 71, 138, 22, 76, 250, + 222, 12, 65, 150, 129, 4, 79, 214, 22, 66, 2, 68, 2, 69, 2, 72, 2, 78, 2, + 80, 2, 82, 2, 85, 3, 89, 7, 154, 112, 32, 197, 159, 5, 6, 78, 86, 69, 82, + 84, 69, 4, 26, 82, 159, 199, 9, 79, 2, 237, 26, 9, 69, 86, 69, 82, 83, + 69, 68, 32, 79, 35, 108, 6, 32, 87, 73, 84, 72, 32, 70, 69, 32, 9, 79, + 84, 76, 69, 83, 83, 32, 74, 32, 146, 12, 66, 151, 8, 90, 12, 194, 24, 72, + 166, 6, 67, 22, 80, 166, 184, 14, 84, 167, 139, 2, 83, 8, 182, 20, 90, + 251, 216, 16, 76, 4, 33, 6, 87, 73, 84, 72, 32, 83, 4, 29, 5, 84, 82, 79, + 75, 69, 5, 233, 143, 9, 4, 32, 65, 78, 68, 21, 52, 2, 83, 72, 174, 19, + 90, 130, 252, 16, 84, 63, 78, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 40, 3, + 68, 79, 85, 150, 28, 67, 67, 82, 2, 17, 2, 66, 76, 2, 195, 235, 15, 69, + 5, 245, 9, 3, 69, 78, 71, 17, 54, 32, 68, 5, 82, 69, 69, 75, 32, 235, + 180, 14, 65, 4, 29, 5, 87, 73, 84, 72, 32, 4, 206, 181, 15, 72, 135, 169, + 1, 83, 8, 34, 71, 22, 80, 175, 193, 9, 79, 2, 195, 180, 14, 65, 4, 154, + 250, 16, 72, 3, 83, 13, 40, 6, 32, 87, 73, 84, 72, 32, 51, 69, 6, 230, + 25, 80, 198, 154, 15, 72, 135, 169, 1, 83, 4, 17, 2, 78, 71, 5, 135, 7, + 32, 4, 186, 104, 32, 211, 255, 15, 79, 7, 33, 6, 32, 87, 73, 84, 72, 32, + 4, 26, 67, 255, 219, 16, 83, 2, 11, 82, 2, 189, 208, 14, 6, 79, 83, 83, + 69, 68, 45, 31, 120, 6, 32, 87, 73, 84, 72, 32, 250, 4, 83, 2, 90, 212, + 9, 2, 69, 90, 153, 229, 16, 8, 73, 71, 65, 84, 85, 82, 69, 32, 18, 70, + 66, 38, 73, 82, 77, 82, 82, 226, 20, 67, 22, 80, 203, 195, 16, 83, 4, + 214, 220, 7, 69, 203, 244, 8, 65, 2, 37, 7, 78, 86, 69, 82, 84, 69, 68, + 2, 145, 138, 13, 5, 32, 76, 65, 90, 89, 2, 11, 73, 2, 17, 2, 68, 68, 2, + 17, 2, 76, 69, 2, 141, 156, 13, 2, 32, 84, 4, 61, 13, 69, 84, 82, 79, 70, + 76, 69, 88, 32, 72, 79, 79, 75, 5, 11, 32, 2, 169, 17, 3, 65, 78, 68, 10, + 38, 76, 210, 19, 67, 22, 80, 47, 82, 4, 22, 79, 207, 17, 69, 2, 17, 2, + 78, 71, 2, 17, 2, 32, 82, 2, 141, 179, 4, 4, 73, 71, 72, 84, 9, 22, 80, + 147, 98, 32, 4, 189, 228, 12, 2, 69, 78, 7, 46, 32, 139, 242, 16, 72, 7, + 18, 32, 23, 80, 2, 155, 132, 9, 87, 2, 11, 32, 2, 173, 193, 10, 2, 68, + 73, 19, 80, 6, 32, 87, 73, 84, 72, 32, 46, 65, 41, 8, 69, 86, 69, 82, 83, + 69, 68, 32, 6, 218, 1, 70, 218, 9, 76, 255, 189, 14, 84, 2, 17, 2, 77, + 83, 2, 251, 132, 6, 32, 8, 46, 71, 50, 82, 170, 10, 79, 247, 248, 16, 69, + 2, 11, 76, 2, 165, 170, 14, 4, 79, 84, 84, 65, 2, 37, 7, 32, 87, 73, 84, + 72, 32, 70, 2, 209, 129, 9, 3, 73, 83, 72, 21, 88, 6, 32, 87, 73, 84, 72, + 32, 42, 67, 64, 6, 73, 68, 69, 87, 65, 89, 22, 80, 59, 81, 6, 158, 14, + 67, 22, 80, 199, 154, 15, 72, 4, 32, 2, 82, 73, 227, 129, 12, 72, 2, 241, + 246, 5, 2, 80, 84, 2, 243, 222, 6, 83, 4, 25, 4, 76, 73, 84, 32, 4, 222, + 128, 17, 79, 3, 85, 2, 57, 12, 85, 65, 84, 32, 82, 69, 86, 69, 82, 83, + 69, 68, 2, 227, 144, 6, 32, 73, 132, 1, 6, 32, 87, 73, 84, 72, 32, 70, + 67, 100, 2, 69, 83, 124, 2, 79, 80, 42, 83, 96, 6, 85, 82, 78, 69, 68, + 32, 167, 186, 13, 72, 10, 38, 72, 238, 10, 67, 22, 80, 47, 82, 4, 133, 7, + 3, 79, 79, 75, 2, 45, 9, 32, 68, 73, 71, 82, 65, 80, 72, 32, 2, 25, 4, + 87, 73, 84, 72, 2, 129, 10, 2, 32, 67, 6, 11, 72, 6, 37, 7, 32, 68, 73, + 71, 82, 65, 80, 6, 11, 72, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 134, 9, + 67, 67, 82, 2, 133, 252, 5, 5, 32, 72, 65, 76, 70, 4, 37, 7, 32, 68, 73, + 71, 82, 65, 80, 4, 11, 72, 5, 11, 32, 2, 189, 4, 4, 87, 73, 84, 72, 44, + 102, 65, 38, 72, 114, 77, 82, 79, 42, 82, 238, 1, 89, 226, 246, 16, 73, + 2, 75, 2, 84, 2, 86, 3, 87, 7, 222, 153, 13, 76, 251, 224, 3, 69, 7, 53, + 11, 32, 87, 73, 84, 72, 32, 70, 73, 83, 72, 72, 4, 21, 3, 79, 79, 75, 5, + 145, 134, 14, 3, 32, 65, 78, 5, 37, 7, 32, 87, 73, 84, 72, 32, 76, 2, 11, + 79, 2, 181, 165, 4, 2, 78, 71, 2, 11, 80, 2, 233, 184, 6, 2, 69, 78, 13, + 33, 6, 32, 87, 73, 84, 72, 32, 10, 66, 76, 92, 4, 77, 73, 68, 45, 138, + 158, 15, 72, 135, 169, 1, 83, 4, 37, 7, 79, 78, 71, 32, 76, 69, 71, 5, + 25, 4, 32, 65, 78, 68, 2, 133, 4, 2, 32, 82, 2, 161, 1, 6, 72, 69, 73, + 71, 72, 84, 5, 29, 5, 32, 87, 73, 84, 72, 2, 229, 133, 4, 2, 32, 66, 11, + 18, 32, 95, 80, 4, 40, 4, 87, 73, 84, 72, 235, 209, 15, 66, 2, 17, 2, 32, + 76, 2, 11, 69, 2, 151, 1, 70, 4, 29, 5, 83, 73, 76, 79, 78, 5, 247, 80, + 32, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 26, 82, 199, 155, 15, 72, 2, 21, + 3, 73, 71, 72, 2, 255, 242, 8, 84, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, + 26, 67, 22, 80, 47, 82, 2, 171, 160, 3, 85, 2, 149, 242, 8, 6, 65, 76, + 65, 84, 65, 76, 2, 11, 69, 2, 221, 241, 8, 7, 84, 82, 79, 70, 76, 69, 88, + 6, 68, 5, 83, 83, 32, 65, 78, 197, 199, 15, 6, 84, 67, 72, 69, 68, 32, 4, + 11, 68, 4, 11, 32, 4, 194, 234, 1, 72, 35, 76, 4, 24, 2, 72, 65, 31, 84, 2, 25, 4, 76, 70, 32, 84, 2, 43, 82, 4, 30, 82, 53, 3, 85, 82, 78, 2, - 241, 252, 15, 8, 73, 65, 78, 71, 85, 76, 65, 82, 2, 221, 167, 8, 2, 69, - 68, 8, 70, 80, 236, 154, 10, 7, 78, 65, 83, 80, 73, 82, 65, 143, 177, 6, - 83, 4, 11, 32, 4, 150, 173, 13, 84, 239, 69, 65, 4, 26, 79, 187, 175, 15, - 69, 2, 11, 73, 2, 159, 250, 15, 67, 4, 36, 3, 65, 78, 71, 1, 2, 73, 78, + 221, 160, 16, 8, 73, 65, 78, 71, 85, 76, 65, 82, 2, 249, 195, 8, 2, 69, + 68, 8, 70, 80, 188, 187, 15, 7, 78, 65, 83, 80, 73, 82, 65, 171, 180, 1, + 83, 4, 11, 32, 4, 134, 205, 13, 84, 239, 69, 65, 4, 26, 79, 155, 211, 15, + 69, 2, 11, 73, 2, 139, 158, 16, 67, 4, 36, 3, 65, 78, 71, 1, 2, 73, 78, 2, 25, 4, 32, 68, 69, 80, 2, 21, 3, 65, 82, 84, 2, 21, 3, 73, 78, 71, 2, - 17, 2, 32, 84, 2, 11, 79, 2, 223, 130, 6, 78, 2, 11, 32, 2, 183, 158, 15, - 83, 234, 2, 92, 2, 69, 89, 88, 7, 71, 79, 76, 73, 65, 78, 32, 206, 24, - 79, 133, 136, 12, 3, 75, 69, 89, 6, 26, 32, 255, 138, 16, 45, 4, 180, - 137, 12, 6, 87, 73, 84, 72, 32, 87, 167, 211, 2, 66, 214, 2, 194, 2, 68, - 46, 70, 148, 1, 14, 73, 78, 86, 69, 82, 84, 69, 68, 32, 66, 73, 82, 71, - 65, 16, 7, 76, 69, 84, 84, 69, 82, 32, 138, 16, 83, 132, 1, 7, 82, 79, - 84, 65, 84, 69, 68, 22, 66, 98, 84, 160, 2, 4, 86, 79, 87, 69, 246, 236, - 3, 67, 164, 1, 6, 77, 65, 78, 67, 72, 85, 160, 201, 7, 4, 78, 73, 82, 85, - 239, 208, 2, 69, 22, 232, 20, 3, 79, 85, 66, 223, 188, 14, 73, 12, 112, - 19, 82, 69, 69, 32, 86, 65, 82, 73, 65, 84, 73, 79, 78, 32, 83, 69, 76, - 69, 67, 254, 238, 13, 85, 195, 46, 79, 8, 229, 245, 9, 3, 84, 79, 82, 5, + 17, 2, 32, 84, 2, 11, 79, 2, 131, 159, 6, 78, 2, 11, 32, 2, 227, 193, 15, + 83, 236, 2, 160, 1, 2, 69, 89, 88, 7, 71, 79, 76, 73, 65, 78, 32, 206, + 24, 79, 192, 165, 12, 3, 75, 69, 89, 249, 137, 4, 12, 65, 82, 67, 72, 32, + 66, 85, 84, 84, 69, 82, 70, 6, 26, 32, 167, 174, 16, 45, 4, 240, 166, 12, + 6, 87, 73, 84, 72, 32, 87, 251, 213, 2, 66, 214, 2, 194, 2, 68, 46, 70, + 148, 1, 14, 73, 78, 86, 69, 82, 84, 69, 68, 32, 66, 73, 82, 71, 65, 16, + 7, 76, 69, 84, 84, 69, 82, 32, 138, 16, 83, 132, 1, 7, 82, 79, 84, 65, + 84, 69, 68, 22, 66, 98, 84, 160, 2, 4, 86, 79, 87, 69, 134, 134, 4, 67, + 164, 1, 6, 77, 65, 78, 67, 72, 85, 200, 205, 7, 4, 78, 73, 82, 85, 171, + 211, 2, 69, 22, 232, 20, 3, 79, 85, 66, 239, 220, 14, 73, 12, 112, 19, + 82, 69, 69, 32, 86, 65, 82, 73, 65, 84, 73, 79, 78, 32, 83, 69, 76, 69, + 67, 170, 142, 14, 85, 139, 47, 79, 8, 205, 147, 10, 3, 84, 79, 82, 5, 227, 19, 32, 136, 2, 130, 2, 65, 244, 4, 2, 67, 72, 88, 2, 77, 65, 174, - 2, 83, 246, 1, 84, 234, 3, 90, 230, 190, 14, 72, 246, 173, 1, 75, 2, 76, + 2, 83, 246, 1, 84, 234, 3, 90, 246, 222, 14, 72, 142, 177, 1, 75, 2, 76, 162, 7, 69, 2, 79, 2, 85, 234, 61, 66, 2, 68, 2, 70, 2, 71, 2, 74, 2, 78, 2, 80, 2, 81, 2, 82, 2, 87, 2, 89, 187, 2, 73, 59, 56, 8, 76, 73, 32, 71, - 65, 76, 73, 32, 223, 192, 16, 78, 54, 174, 1, 65, 52, 6, 86, 73, 83, 65, + 65, 76, 73, 32, 135, 228, 16, 78, 54, 174, 1, 65, 52, 6, 86, 73, 83, 65, 82, 71, 22, 68, 76, 5, 72, 65, 76, 70, 32, 34, 73, 50, 85, 34, 78, 30, - 84, 66, 66, 226, 245, 15, 80, 2, 90, 254, 68, 83, 14, 67, 3, 75, 7, 48, - 6, 78, 85, 83, 86, 65, 82, 207, 191, 16, 72, 2, 167, 161, 9, 65, 8, 26, - 65, 231, 188, 16, 68, 7, 218, 248, 8, 77, 253, 131, 7, 3, 71, 65, 76, 4, - 178, 188, 16, 89, 187, 2, 85, 5, 45, 9, 78, 86, 69, 82, 84, 69, 68, 32, - 85, 2, 173, 251, 15, 3, 66, 65, 68, 4, 194, 187, 16, 71, 3, 78, 8, 60, 6, - 72, 82, 69, 69, 32, 66, 226, 245, 15, 84, 195, 71, 65, 2, 17, 2, 65, 76, - 2, 135, 152, 16, 85, 6, 26, 65, 223, 188, 16, 73, 5, 29, 5, 32, 87, 73, - 84, 72, 2, 201, 233, 14, 2, 32, 84, 41, 29, 5, 78, 67, 72, 85, 32, 38, - 104, 9, 65, 76, 73, 32, 71, 65, 76, 73, 32, 238, 189, 14, 90, 242, 250, - 1, 70, 2, 75, 2, 82, 187, 2, 73, 28, 122, 68, 246, 193, 9, 67, 246, 227, - 2, 84, 138, 151, 2, 66, 2, 71, 2, 74, 2, 76, 234, 181, 1, 90, 254, 4, 78, - 131, 64, 83, 4, 238, 188, 14, 68, 243, 250, 1, 72, 48, 52, 4, 73, 66, 69, - 32, 134, 183, 16, 72, 187, 2, 65, 44, 138, 218, 5, 71, 2, 72, 170, 202, - 6, 84, 238, 3, 73, 246, 147, 2, 67, 2, 83, 246, 7, 82, 190, 164, 1, 65, + 84, 66, 66, 138, 153, 16, 80, 2, 90, 254, 68, 83, 14, 67, 3, 75, 7, 48, + 6, 78, 85, 83, 86, 65, 82, 247, 226, 16, 72, 2, 151, 191, 9, 65, 8, 26, + 65, 143, 224, 16, 68, 7, 202, 148, 9, 77, 181, 139, 7, 3, 71, 65, 76, 4, + 218, 223, 16, 89, 187, 2, 85, 5, 45, 9, 78, 86, 69, 82, 84, 69, 68, 32, + 85, 2, 213, 158, 16, 3, 66, 65, 68, 4, 234, 222, 16, 71, 3, 78, 8, 60, 6, + 72, 82, 69, 69, 32, 66, 138, 153, 16, 84, 195, 71, 65, 2, 17, 2, 65, 76, + 2, 175, 187, 16, 85, 6, 26, 65, 135, 224, 16, 73, 5, 29, 5, 32, 87, 73, + 84, 72, 2, 225, 137, 15, 2, 32, 84, 41, 29, 5, 78, 67, 72, 85, 32, 38, + 104, 9, 65, 76, 73, 32, 71, 65, 76, 73, 32, 254, 221, 14, 90, 138, 254, + 1, 70, 2, 75, 2, 82, 187, 2, 73, 28, 122, 68, 222, 223, 9, 67, 190, 227, + 2, 84, 234, 153, 2, 66, 2, 71, 2, 74, 2, 76, 130, 185, 1, 90, 254, 4, 78, + 131, 64, 83, 4, 254, 220, 14, 68, 139, 254, 1, 72, 48, 52, 4, 73, 66, 69, + 32, 174, 218, 16, 72, 187, 2, 65, 44, 178, 244, 5, 71, 2, 72, 178, 205, + 6, 84, 238, 3, 73, 214, 150, 2, 67, 2, 83, 246, 7, 82, 214, 167, 1, 65, 186, 9, 90, 162, 7, 85, 234, 61, 68, 2, 70, 2, 74, 2, 75, 2, 80, 187, 2, - 69, 60, 52, 4, 79, 68, 79, 32, 146, 181, 16, 83, 187, 2, 65, 56, 250, 1, - 65, 98, 68, 34, 74, 34, 78, 252, 164, 1, 8, 76, 79, 78, 71, 32, 86, 79, - 87, 130, 176, 4, 71, 170, 202, 6, 84, 226, 151, 2, 67, 246, 7, 72, 150, - 181, 1, 79, 2, 85, 234, 61, 66, 2, 75, 2, 77, 2, 80, 2, 81, 2, 87, 2, 89, - 186, 2, 69, 3, 73, 6, 56, 8, 76, 73, 32, 71, 65, 76, 73, 32, 191, 180, - 16, 78, 4, 230, 183, 14, 90, 243, 250, 1, 84, 4, 178, 178, 16, 90, 187, - 2, 65, 4, 146, 178, 16, 73, 187, 2, 65, 2, 243, 177, 16, 73, 6, 190, 160, - 16, 72, 162, 17, 82, 187, 2, 65, 8, 128, 1, 4, 87, 73, 82, 76, 141, 187, + 69, 60, 52, 4, 79, 68, 79, 32, 186, 216, 16, 83, 187, 2, 65, 56, 250, 1, + 65, 98, 68, 34, 74, 34, 78, 128, 189, 1, 8, 76, 79, 78, 71, 32, 86, 79, + 87, 166, 178, 4, 71, 178, 205, 6, 84, 194, 154, 2, 67, 246, 7, 72, 174, + 184, 1, 79, 2, 85, 234, 61, 66, 2, 75, 2, 77, 2, 80, 2, 81, 2, 87, 2, 89, + 186, 2, 69, 3, 73, 6, 56, 8, 76, 73, 32, 71, 65, 76, 73, 32, 231, 215, + 16, 78, 4, 246, 215, 14, 90, 139, 254, 1, 84, 4, 218, 213, 16, 90, 187, + 2, 65, 4, 186, 213, 16, 73, 187, 2, 65, 2, 155, 213, 16, 73, 6, 230, 195, + 16, 72, 162, 17, 82, 187, 2, 65, 8, 128, 1, 4, 87, 73, 82, 76, 181, 212, 4, 21, 73, 66, 69, 32, 83, 89, 76, 76, 65, 66, 76, 69, 32, 66, 79, 85, 78, 68, 65, 82, 89, 6, 17, 2, 32, 66, 6, 25, 4, 73, 82, 71, 65, 7, 33, 6, - 32, 87, 73, 84, 72, 32, 4, 150, 2, 68, 179, 236, 15, 79, 6, 152, 1, 3, + 32, 87, 73, 84, 72, 32, 4, 150, 2, 68, 219, 143, 16, 79, 6, 152, 1, 3, 82, 73, 80, 56, 18, 85, 82, 78, 69, 68, 32, 83, 87, 73, 82, 76, 32, 66, - 73, 82, 71, 65, 32, 217, 192, 1, 8, 79, 68, 79, 32, 83, 79, 70, 84, 2, - 217, 236, 15, 9, 76, 69, 32, 66, 73, 82, 71, 65, 32, 2, 33, 6, 87, 73, - 84, 72, 32, 68, 2, 153, 236, 15, 5, 79, 85, 66, 76, 69, 2, 187, 230, 9, + 73, 82, 71, 65, 32, 197, 216, 1, 8, 79, 68, 79, 32, 83, 79, 70, 84, 2, + 129, 144, 16, 9, 76, 69, 32, 66, 73, 82, 71, 65, 32, 2, 33, 6, 87, 73, + 84, 72, 32, 68, 2, 193, 143, 16, 5, 79, 85, 66, 76, 69, 2, 163, 132, 10, 76, 10, 84, 9, 71, 82, 65, 77, 32, 70, 79, 82, 32, 60, 4, 83, 84, 65, 66, - 139, 247, 13, 82, 6, 26, 89, 231, 193, 12, 69, 4, 210, 221, 15, 65, 155, - 1, 73, 2, 223, 255, 3, 76, 10, 48, 2, 78, 32, 174, 206, 4, 68, 231, 200, - 11, 83, 6, 88, 12, 86, 73, 69, 87, 73, 78, 71, 32, 67, 69, 82, 69, 226, - 192, 12, 67, 85, 2, 76, 65, 2, 173, 141, 16, 2, 77, 79, 4, 226, 185, 12, - 73, 139, 243, 3, 69, 10, 26, 72, 69, 2, 79, 82, 2, 45, 9, 69, 82, 32, 67, - 72, 82, 73, 83, 84, 2, 167, 250, 2, 77, 8, 50, 32, 52, 4, 73, 90, 69, 68, - 227, 156, 15, 87, 4, 202, 197, 8, 66, 221, 171, 6, 4, 83, 67, 79, 79, 2, - 133, 172, 3, 7, 32, 87, 72, 69, 69, 76, 67, 18, 52, 2, 78, 84, 152, 1, 2, - 83, 69, 243, 167, 16, 84, 10, 48, 3, 65, 73, 78, 221, 137, 12, 3, 32, 70, - 85, 9, 11, 32, 6, 238, 202, 9, 82, 24, 5, 67, 65, 66, 76, 69, 177, 241, - 1, 6, 66, 73, 67, 89, 67, 76, 7, 11, 32, 4, 232, 149, 15, 2, 84, 82, 131, - 86, 70, 86, 52, 7, 76, 69, 84, 84, 69, 82, 32, 155, 231, 5, 68, 62, 198, - 1, 75, 62, 77, 34, 78, 34, 79, 30, 80, 34, 84, 242, 105, 68, 136, 129, 8, - 2, 72, 65, 2, 82, 166, 226, 1, 83, 190, 89, 76, 246, 7, 67, 218, 100, 69, - 254, 242, 3, 89, 190, 28, 66, 2, 87, 187, 2, 65, 6, 212, 169, 5, 2, 69, - 65, 178, 137, 6, 72, 199, 243, 4, 79, 4, 226, 147, 16, 65, 215, 1, 73, 4, - 142, 214, 15, 73, 139, 60, 71, 7, 206, 165, 16, 76, 3, 79, 4, 218, 145, - 16, 72, 219, 19, 65, 6, 146, 145, 9, 72, 234, 144, 7, 69, 155, 3, 65, - 206, 4, 44, 2, 76, 84, 234, 6, 83, 171, 135, 14, 67, 102, 36, 4, 65, 78, - 73, 32, 219, 2, 73, 76, 52, 7, 76, 69, 84, 84, 69, 82, 32, 203, 144, 4, - 83, 74, 206, 1, 68, 234, 83, 78, 246, 231, 1, 82, 254, 208, 9, 74, 202, - 56, 84, 162, 149, 3, 66, 2, 67, 2, 71, 2, 75, 2, 80, 138, 69, 72, 2, 76, - 2, 77, 2, 83, 2, 86, 2, 89, 186, 2, 65, 2, 69, 2, 73, 3, 85, 10, 38, 68, - 162, 159, 16, 72, 187, 2, 65, 6, 158, 159, 16, 68, 2, 72, 187, 2, 65, 26, - 56, 2, 80, 76, 236, 2, 3, 83, 69, 84, 131, 139, 15, 77, 18, 50, 69, 89, - 8, 73, 67, 65, 84, 73, 79, 78, 32, 2, 41, 8, 32, 77, 85, 83, 73, 67, 65, - 76, 2, 21, 3, 32, 78, 79, 2, 247, 137, 15, 84, 16, 40, 4, 83, 73, 71, 78, - 191, 159, 16, 88, 15, 11, 32, 12, 48, 3, 73, 78, 32, 81, 5, 87, 73, 84, - 72, 32, 8, 178, 202, 3, 76, 22, 82, 140, 191, 9, 5, 68, 79, 85, 66, 76, - 183, 238, 1, 84, 4, 166, 175, 12, 85, 187, 238, 2, 68, 7, 11, 32, 4, 244, - 83, 5, 77, 85, 76, 84, 73, 255, 150, 12, 85, 228, 3, 44, 5, 72, 82, 79, - 79, 77, 21, 2, 73, 67, 5, 139, 239, 14, 32, 224, 3, 30, 32, 109, 3, 65, - 76, 32, 6, 64, 4, 78, 65, 84, 85, 20, 3, 83, 72, 65, 209, 43, 2, 70, 76, - 2, 239, 207, 10, 82, 2, 151, 187, 11, 82, 218, 3, 64, 8, 75, 69, 89, 66, - 79, 65, 82, 68, 66, 83, 183, 243, 3, 78, 5, 41, 8, 32, 87, 73, 84, 72, - 32, 74, 65, 2, 155, 250, 13, 67, 212, 3, 48, 6, 89, 77, 66, 79, 76, 32, - 163, 173, 11, 67, 210, 3, 230, 2, 66, 238, 1, 67, 230, 9, 68, 250, 2, 69, - 162, 1, 70, 166, 2, 71, 112, 9, 65, 82, 80, 69, 71, 71, 73, 65, 84, 168, - 1, 2, 72, 65, 126, 75, 198, 3, 76, 138, 1, 77, 186, 2, 78, 162, 1, 79, - 218, 2, 80, 200, 2, 2, 81, 85, 146, 2, 82, 198, 2, 83, 226, 5, 84, 182, - 10, 86, 42, 88, 42, 87, 156, 141, 9, 9, 73, 78, 86, 69, 82, 84, 69, 68, - 32, 143, 210, 6, 90, 20, 36, 5, 69, 71, 73, 78, 32, 59, 82, 8, 142, 15, - 80, 30, 83, 174, 247, 7, 66, 151, 245, 7, 84, 12, 24, 2, 65, 67, 35, 69, - 4, 174, 225, 15, 75, 155, 53, 69, 8, 26, 86, 179, 212, 15, 65, 6, 32, 2, - 73, 83, 235, 149, 16, 69, 5, 179, 26, 32, 84, 120, 2, 65, 69, 34, 76, 94, - 79, 194, 7, 82, 242, 11, 32, 224, 32, 7, 73, 82, 67, 76, 69, 32, 88, 157, - 223, 5, 2, 85, 84, 2, 11, 83, 2, 143, 208, 15, 85, 8, 42, 73, 249, 23, 5, - 85, 83, 84, 69, 82, 4, 26, 77, 239, 236, 13, 86, 2, 251, 214, 9, 65, 64, - 26, 77, 143, 145, 16, 68, 62, 64, 7, 66, 73, 78, 73, 78, 71, 32, 205, - 146, 6, 3, 77, 79, 78, 60, 202, 1, 65, 80, 7, 77, 65, 82, 67, 65, 84, 79, - 56, 2, 68, 79, 56, 2, 85, 80, 28, 2, 70, 76, 40, 5, 72, 65, 82, 77, 79, - 22, 83, 142, 2, 84, 174, 177, 7, 66, 172, 199, 3, 2, 76, 79, 143, 147, 5, - 82, 6, 76, 5, 67, 67, 69, 78, 84, 37, 10, 85, 71, 77, 69, 78, 84, 65, 84, - 73, 79, 5, 205, 2, 5, 45, 83, 84, 65, 67, 2, 143, 253, 14, 78, 6, 52, 2, - 87, 78, 168, 3, 2, 85, 66, 163, 240, 15, 73, 2, 201, 243, 14, 2, 32, 66, - 12, 248, 76, 2, 65, 71, 211, 194, 15, 73, 2, 147, 229, 14, 78, 12, 132, - 1, 9, 78, 65, 80, 32, 80, 73, 90, 90, 73, 22, 84, 156, 202, 4, 11, 80, - 82, 69, 67, 72, 71, 69, 83, 65, 78, 71, 247, 138, 6, 77, 2, 155, 254, 11, - 67, 6, 44, 5, 65, 67, 67, 65, 84, 251, 252, 15, 69, 4, 40, 4, 73, 83, 83, - 73, 167, 141, 16, 79, 2, 175, 238, 15, 77, 10, 34, 82, 217, 153, 12, 2, - 69, 78, 8, 28, 2, 73, 80, 199, 6, 69, 2, 225, 252, 11, 6, 76, 69, 32, 84, - 79, 78, 4, 22, 79, 179, 2, 69, 2, 199, 253, 14, 73, 24, 98, 65, 142, 1, - 69, 92, 6, 79, 85, 66, 76, 69, 32, 197, 164, 10, 7, 82, 85, 77, 32, 67, - 76, 69, 10, 96, 2, 32, 67, 20, 2, 77, 80, 204, 29, 4, 83, 72, 69, 68, - 189, 195, 15, 5, 76, 32, 83, 69, 71, 2, 179, 190, 8, 65, 5, 227, 255, 13, - 32, 4, 40, 3, 67, 82, 69, 29, 3, 71, 82, 69, 2, 181, 25, 3, 83, 67, 69, - 2, 207, 228, 8, 69, 6, 242, 21, 83, 254, 6, 66, 243, 130, 5, 70, 14, 32, - 3, 78, 68, 32, 151, 16, 73, 10, 74, 80, 30, 83, 204, 13, 3, 79, 70, 32, - 226, 233, 7, 66, 151, 245, 7, 84, 2, 237, 222, 12, 2, 72, 82, 2, 155, - 143, 15, 76, 34, 104, 6, 69, 82, 77, 65, 84, 65, 22, 73, 122, 79, 102, - 32, 144, 36, 3, 85, 83, 65, 137, 226, 3, 2, 76, 65, 5, 227, 213, 13, 32, - 10, 22, 78, 135, 34, 86, 8, 56, 9, 71, 69, 82, 69, 68, 32, 84, 82, 69, - 239, 20, 65, 6, 189, 237, 5, 4, 77, 79, 76, 79, 6, 208, 25, 3, 85, 82, - 45, 255, 162, 14, 82, 18, 54, 32, 56, 7, 76, 73, 83, 83, 65, 78, 68, 23, - 82, 6, 25, 4, 67, 76, 69, 70, 7, 157, 13, 3, 32, 79, 84, 4, 175, 130, 6, - 79, 8, 84, 9, 65, 67, 69, 32, 78, 79, 84, 69, 32, 37, 8, 69, 71, 79, 82, - 73, 65, 78, 32, 4, 236, 222, 8, 2, 78, 79, 27, 83, 4, 250, 2, 67, 3, 70, - 8, 44, 3, 76, 70, 32, 205, 8, 3, 85, 80, 84, 6, 52, 3, 80, 69, 68, 134, - 219, 3, 78, 151, 181, 8, 82, 2, 191, 194, 5, 65, 24, 48, 6, 73, 69, 86, - 65, 78, 32, 191, 218, 14, 79, 22, 178, 1, 67, 46, 69, 68, 7, 81, 85, 65, - 82, 84, 69, 82, 62, 70, 200, 215, 3, 4, 72, 65, 76, 70, 0, 5, 87, 72, 79, - 76, 69, 173, 224, 1, 9, 82, 69, 67, 73, 84, 65, 84, 73, 86, 2, 11, 32, 2, - 11, 67, 2, 159, 159, 5, 76, 6, 64, 5, 73, 71, 72, 84, 72, 145, 199, 14, - 5, 78, 68, 32, 79, 70, 4, 177, 253, 5, 10, 32, 78, 79, 84, 69, 32, 83, - 84, 69, 77, 4, 218, 14, 76, 237, 200, 3, 4, 73, 78, 65, 76, 8, 44, 4, 79, - 78, 71, 65, 217, 13, 2, 69, 70, 7, 11, 32, 4, 28, 3, 73, 77, 80, 3, 80, - 2, 193, 2, 7, 69, 82, 70, 69, 67, 84, 65, 18, 104, 2, 65, 88, 20, 2, 69, - 90, 20, 5, 73, 78, 73, 77, 65, 44, 3, 79, 79, 78, 25, 4, 85, 76, 84, 73, - 2, 219, 219, 15, 73, 2, 227, 221, 15, 90, 7, 11, 32, 4, 150, 138, 12, 82, - 195, 83, 66, 4, 189, 17, 2, 32, 78, 4, 60, 11, 80, 76, 69, 32, 77, 69, - 65, 83, 85, 82, 69, 15, 32, 2, 11, 32, 2, 147, 137, 12, 82, 10, 120, 4, - 69, 66, 69, 78, 212, 26, 3, 85, 76, 76, 160, 221, 5, 3, 65, 84, 85, 189, - 227, 6, 7, 79, 84, 69, 72, 69, 65, 68, 2, 177, 224, 14, 4, 83, 84, 73, - 77, 32, 88, 2, 78, 69, 120, 14, 82, 78, 65, 77, 69, 78, 84, 32, 83, 84, - 82, 79, 75, 69, 107, 84, 6, 92, 18, 32, 72, 85, 78, 68, 82, 69, 68, 32, - 84, 87, 69, 78, 84, 89, 45, 69, 73, 159, 20, 45, 4, 181, 13, 2, 71, 72, - 22, 11, 45, 22, 222, 161, 3, 49, 194, 214, 12, 50, 2, 51, 2, 52, 2, 53, - 2, 54, 2, 55, 2, 56, 3, 57, 4, 173, 4, 3, 84, 65, 86, 18, 96, 9, 65, 82, - 69, 78, 84, 72, 69, 83, 73, 0, 2, 76, 85, 18, 69, 142, 1, 79, 215, 234, - 13, 73, 2, 243, 22, 83, 6, 68, 4, 68, 65, 76, 32, 49, 9, 83, 32, 83, 85, - 66, 80, 85, 78, 67, 4, 26, 85, 167, 180, 15, 77, 2, 139, 180, 15, 80, 2, - 179, 206, 13, 84, 6, 48, 2, 68, 65, 245, 5, 5, 82, 82, 69, 67, 84, 2, - 143, 236, 13, 84, 12, 76, 6, 65, 82, 84, 69, 82, 32, 125, 9, 73, 78, 68, - 73, 67, 69, 83, 73, 77, 8, 60, 5, 84, 79, 78, 69, 32, 158, 204, 3, 78, - 151, 181, 8, 82, 4, 26, 83, 239, 137, 5, 70, 2, 165, 243, 15, 3, 72, 65, - 82, 4, 17, 2, 65, 32, 4, 154, 182, 12, 65, 161, 186, 3, 3, 66, 65, 83, - 14, 22, 69, 175, 1, 73, 10, 72, 4, 80, 69, 65, 84, 81, 10, 86, 69, 82, - 83, 69, 32, 70, 73, 78, 65, 8, 56, 8, 69, 68, 32, 70, 73, 71, 85, 82, - 231, 158, 14, 32, 6, 231, 216, 5, 69, 2, 207, 4, 76, 4, 48, 2, 71, 72, - 57, 6, 78, 70, 79, 82, 90, 65, 2, 33, 6, 84, 32, 82, 69, 80, 69, 2, 231, - 164, 10, 65, 2, 223, 176, 8, 78, 48, 136, 1, 6, 67, 65, 78, 68, 73, 67, - 62, 69, 162, 1, 72, 54, 73, 252, 1, 6, 81, 85, 65, 82, 69, 32, 176, 154, - 8, 2, 85, 66, 251, 100, 79, 4, 17, 2, 85, 83, 5, 133, 230, 13, 5, 32, 70, - 76, 69, 88, 14, 32, 2, 77, 73, 147, 197, 15, 71, 12, 64, 6, 66, 82, 69, - 86, 73, 83, 1, 6, 77, 73, 78, 73, 77, 65, 6, 11, 32, 6, 134, 13, 87, 170, - 238, 11, 82, 195, 83, 66, 6, 84, 3, 79, 82, 84, 181, 234, 5, 3, 65, 82, - 80, 14, 32, 4, 78, 71, 76, 69, 43, 88, 2, 17, 2, 32, 66, 2, 131, 130, 14, - 65, 12, 18, 45, 79, 84, 4, 242, 7, 76, 141, 203, 14, 11, 83, 84, 82, 73, - 78, 71, 32, 70, 82, 69, 84, 8, 52, 3, 69, 69, 78, 1, 6, 89, 45, 70, 79, - 85, 82, 4, 193, 12, 2, 84, 72, 6, 26, 78, 219, 234, 15, 66, 4, 229, 9, 7, - 79, 84, 69, 72, 69, 65, 68, 60, 132, 1, 6, 69, 77, 80, 85, 83, 32, 154, - 4, 72, 88, 2, 87, 79, 84, 7, 79, 82, 67, 85, 76, 85, 83, 46, 82, 141, 3, - 3, 85, 82, 78, 16, 232, 1, 27, 73, 77, 80, 69, 82, 70, 69, 67, 84, 85, - 77, 32, 67, 85, 77, 32, 80, 82, 79, 76, 65, 84, 73, 79, 78, 69, 32, 129, - 1, 25, 80, 69, 82, 70, 69, 67, 84, 85, 77, 32, 67, 85, 77, 32, 80, 82, - 79, 76, 65, 84, 73, 79, 78, 69, 32, 10, 60, 10, 73, 77, 80, 69, 82, 70, - 69, 67, 84, 65, 131, 1, 80, 9, 173, 206, 5, 11, 32, 68, 73, 77, 73, 78, - 85, 84, 73, 79, 78, 6, 60, 3, 73, 77, 80, 41, 8, 80, 69, 82, 70, 69, 67, - 84, 65, 2, 169, 193, 15, 5, 69, 82, 70, 69, 67, 5, 249, 189, 8, 12, 32, - 68, 73, 77, 73, 78, 85, 84, 73, 79, 78, 45, 6, 72, 2, 82, 69, 249, 5, 11, - 73, 82, 84, 89, 45, 83, 69, 67, 79, 78, 68, 2, 11, 69, 2, 11, 45, 2, 11, - 76, 2, 37, 7, 73, 78, 69, 32, 83, 84, 65, 2, 207, 226, 14, 70, 5, 241, - 216, 11, 6, 32, 82, 69, 83, 85, 80, 27, 33, 6, 73, 65, 78, 71, 76, 69, - 24, 128, 1, 10, 32, 78, 79, 84, 69, 72, 69, 65, 68, 32, 61, 17, 45, 82, - 79, 85, 78, 68, 32, 78, 79, 84, 69, 72, 69, 65, 68, 32, 68, 20, 58, 68, - 24, 3, 85, 80, 32, 38, 82, 25, 3, 76, 69, 70, 4, 93, 3, 79, 87, 78, 8, - 34, 82, 78, 87, 235, 193, 12, 66, 4, 21, 3, 73, 71, 72, 4, 11, 84, 4, 11, - 32, 4, 26, 87, 235, 193, 12, 66, 2, 11, 72, 2, 167, 151, 14, 73, 7, 11, - 32, 4, 198, 187, 8, 83, 203, 164, 7, 85, 4, 36, 3, 79, 73, 68, 131, 157, - 15, 73, 2, 129, 135, 13, 5, 32, 78, 79, 84, 69, 6, 92, 4, 72, 79, 76, 69, - 177, 200, 8, 13, 73, 84, 72, 32, 70, 73, 78, 71, 69, 82, 78, 65, 73, 4, - 11, 32, 4, 134, 183, 3, 78, 151, 181, 8, 82, 232, 3, 224, 2, 15, 67, 79, - 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, 32, 254, 1, 76, 212, 14, - 16, 77, 79, 68, 73, 70, 73, 69, 82, 32, 76, 69, 84, 84, 69, 82, 32, 122, - 83, 80, 16, 69, 65, 83, 84, 69, 82, 78, 32, 80, 87, 79, 32, 75, 65, 82, - 69, 218, 9, 84, 204, 1, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, - 192, 175, 9, 3, 80, 65, 79, 175, 154, 4, 68, 16, 66, 77, 165, 1, 11, 83, - 72, 65, 78, 32, 77, 69, 68, 73, 65, 76, 14, 80, 6, 69, 68, 73, 65, 76, - 32, 45, 10, 79, 78, 32, 77, 69, 68, 73, 65, 76, 32, 8, 222, 215, 15, 72, - 2, 82, 2, 87, 3, 89, 6, 178, 215, 15, 76, 2, 77, 3, 78, 2, 235, 223, 10, - 32, 238, 1, 104, 6, 69, 84, 84, 69, 82, 32, 185, 13, 15, 79, 71, 79, 71, - 82, 65, 77, 32, 75, 72, 65, 77, 84, 73, 32, 232, 1, 238, 1, 65, 50, 69, - 146, 1, 71, 50, 75, 254, 1, 77, 134, 1, 78, 58, 82, 86, 83, 130, 3, 84, - 198, 1, 87, 194, 238, 11, 68, 214, 6, 85, 22, 86, 166, 202, 1, 73, 42, - 76, 222, 196, 1, 66, 2, 67, 2, 74, 2, 80, 138, 69, 72, 2, 89, 187, 2, 79, - 7, 244, 139, 15, 4, 73, 84, 79, 78, 219, 74, 85, 9, 77, 17, 65, 83, 84, - 69, 82, 78, 32, 80, 87, 79, 32, 75, 65, 82, 69, 78, 32, 6, 42, 71, 202, - 219, 10, 89, 199, 187, 3, 78, 2, 199, 219, 10, 72, 6, 182, 200, 9, 82, - 162, 138, 6, 72, 187, 2, 65, 44, 32, 2, 72, 65, 191, 212, 15, 65, 43, 25, - 4, 77, 84, 73, 32, 40, 134, 1, 68, 34, 84, 214, 218, 8, 78, 230, 176, 6, - 67, 2, 72, 2, 74, 170, 37, 76, 226, 31, 70, 2, 71, 2, 82, 2, 83, 2, 88, - 3, 90, 6, 214, 139, 15, 68, 139, 69, 72, 4, 183, 139, 15, 84, 12, 36, 3, - 79, 78, 32, 191, 210, 15, 65, 10, 60, 2, 66, 66, 214, 212, 13, 74, 230, - 186, 1, 78, 199, 66, 69, 4, 250, 209, 15, 65, 3, 69, 10, 186, 217, 8, 78, - 238, 245, 6, 71, 2, 89, 187, 2, 65, 4, 184, 216, 2, 12, 85, 77, 65, 73, - 32, 80, 65, 76, 65, 85, 78, 71, 239, 248, 12, 65, 50, 90, 72, 252, 216, - 2, 9, 71, 65, 87, 32, 75, 65, 82, 69, 78, 198, 244, 12, 83, 187, 2, 65, - 44, 66, 65, 197, 1, 11, 87, 69, 32, 80, 65, 76, 65, 85, 78, 71, 32, 41, - 17, 2, 78, 32, 38, 134, 1, 78, 242, 208, 13, 74, 2, 80, 2, 84, 234, 181, - 1, 66, 2, 67, 2, 71, 2, 75, 138, 69, 68, 2, 70, 2, 72, 2, 90, 187, 2, 65, - 6, 222, 203, 15, 78, 2, 89, 187, 2, 65, 4, 198, 208, 13, 67, 3, 83, 36, - 38, 65, 238, 133, 15, 84, 139, 69, 72, 31, 41, 8, 73, 32, 76, 65, 73, 78, - 71, 32, 28, 82, 78, 222, 238, 11, 68, 146, 150, 3, 66, 2, 71, 2, 74, 170, - 37, 76, 227, 31, 70, 4, 242, 201, 15, 78, 3, 89, 6, 92, 17, 69, 83, 84, - 69, 82, 78, 32, 80, 87, 79, 32, 75, 65, 82, 69, 78, 32, 179, 203, 15, 65, - 4, 210, 209, 10, 80, 183, 252, 2, 84, 6, 234, 188, 14, 79, 194, 62, 81, - 139, 63, 72, 4, 56, 6, 75, 72, 65, 77, 84, 73, 1, 4, 83, 72, 65, 78, 2, - 29, 5, 32, 82, 69, 68, 85, 2, 165, 128, 1, 2, 80, 76, 90, 76, 2, 72, 65, - 20, 4, 73, 71, 78, 32, 233, 6, 6, 89, 77, 66, 79, 76, 32, 20, 227, 186, - 9, 78, 52, 202, 3, 65, 32, 12, 75, 72, 65, 77, 84, 73, 32, 84, 79, 78, - 69, 45, 30, 83, 132, 2, 15, 84, 65, 73, 32, 76, 65, 73, 78, 71, 32, 84, - 79, 78, 69, 45, 28, 22, 87, 69, 83, 84, 69, 82, 78, 32, 80, 87, 79, 32, - 75, 65, 82, 69, 78, 32, 84, 79, 78, 69, 146, 240, 2, 68, 136, 169, 5, 19, - 82, 85, 77, 65, 73, 32, 80, 65, 76, 65, 85, 78, 71, 32, 84, 79, 78, 69, - 45, 140, 180, 3, 9, 80, 65, 79, 32, 75, 65, 82, 69, 78, 148, 115, 6, 76, - 73, 84, 84, 76, 69, 155, 191, 2, 86, 4, 134, 188, 14, 83, 199, 68, 78, 4, - 150, 197, 15, 49, 3, 51, 18, 40, 4, 72, 65, 78, 32, 247, 243, 14, 69, 16, - 84, 8, 67, 79, 85, 78, 67, 73, 76, 32, 84, 5, 84, 79, 78, 69, 45, 251, - 196, 14, 83, 6, 188, 206, 11, 8, 69, 77, 80, 72, 65, 84, 73, 67, 185, - 244, 3, 4, 84, 79, 78, 69, 8, 162, 195, 15, 50, 2, 51, 2, 53, 3, 54, 4, - 246, 194, 15, 50, 3, 53, 10, 11, 45, 10, 206, 194, 15, 49, 2, 50, 2, 51, - 2, 52, 3, 53, 18, 130, 1, 65, 128, 1, 2, 76, 79, 28, 5, 83, 72, 65, 78, - 32, 152, 174, 8, 4, 71, 69, 78, 73, 217, 96, 6, 67, 79, 77, 80, 76, 69, - 8, 84, 5, 73, 84, 79, 78, 32, 237, 174, 6, 10, 70, 79, 82, 69, 77, 69, - 78, 84, 73, 79, 6, 94, 69, 170, 171, 13, 84, 139, 121, 79, 2, 177, 174, - 8, 2, 67, 65, 4, 26, 69, 179, 164, 14, 79, 2, 201, 12, 4, 88, 67, 76, 65, - 24, 140, 1, 20, 79, 78, 69, 32, 77, 65, 82, 75, 32, 83, 71, 65, 87, 32, - 75, 65, 82, 69, 78, 32, 253, 175, 9, 8, 65, 73, 32, 76, 65, 73, 78, 71, - 4, 38, 72, 233, 206, 8, 3, 75, 69, 32, 2, 243, 208, 8, 65, 56, 150, 2, - 65, 76, 9, 71, 69, 66, 65, 32, 75, 65, 82, 69, 20, 6, 75, 65, 89, 65, 72, - 32, 40, 4, 77, 79, 78, 32, 34, 83, 142, 1, 69, 40, 18, 87, 69, 83, 84, - 69, 82, 78, 32, 80, 87, 79, 32, 75, 65, 82, 69, 78, 32, 136, 183, 9, 2, - 84, 65, 254, 170, 2, 85, 22, 86, 167, 202, 1, 73, 8, 26, 73, 195, 187, - 15, 65, 7, 25, 4, 84, 79, 78, 32, 4, 223, 174, 13, 65, 2, 255, 250, 14, - 78, 6, 166, 164, 15, 69, 2, 79, 215, 22, 85, 4, 250, 166, 15, 73, 219, - 19, 79, 10, 80, 4, 72, 65, 78, 32, 133, 205, 8, 10, 71, 65, 87, 32, 75, - 65, 82, 69, 78, 32, 8, 54, 69, 20, 5, 70, 73, 78, 65, 76, 223, 182, 15, - 65, 5, 175, 188, 14, 32, 2, 203, 167, 15, 32, 4, 150, 148, 15, 69, 151, - 14, 85, 208, 11, 152, 2, 5, 45, 65, 82, 89, 32, 214, 4, 65, 222, 16, 66, - 30, 69, 146, 32, 73, 136, 1, 3, 75, 79, 32, 170, 10, 79, 162, 24, 85, - 152, 4, 22, 89, 73, 65, 75, 69, 78, 71, 32, 80, 85, 65, 67, 72, 85, 69, - 32, 72, 77, 79, 78, 71, 32, 232, 135, 2, 2, 80, 78, 252, 208, 12, 2, 78, - 66, 27, 76, 32, 130, 1, 67, 114, 84, 46, 83, 160, 1, 5, 85, 78, 73, 79, - 78, 108, 4, 87, 72, 73, 84, 138, 237, 11, 76, 210, 17, 73, 151, 162, 2, - 80, 8, 52, 7, 73, 82, 67, 76, 69, 68, 32, 211, 163, 14, 79, 6, 40, 2, 80, - 76, 14, 84, 175, 142, 8, 68, 2, 35, 85, 2, 21, 3, 73, 77, 69, 2, 239, - 240, 11, 83, 6, 40, 6, 81, 85, 65, 82, 69, 32, 87, 85, 4, 60, 9, 73, 78, - 84, 69, 82, 83, 69, 67, 84, 1, 2, 85, 78, 2, 199, 202, 11, 73, 2, 11, 77, - 2, 199, 237, 11, 77, 7, 69, 15, 32, 79, 80, 69, 82, 65, 84, 79, 82, 32, - 87, 73, 84, 72, 32, 4, 170, 167, 11, 80, 215, 186, 3, 68, 2, 11, 69, 2, - 129, 216, 12, 2, 32, 86, 188, 2, 170, 2, 66, 252, 4, 10, 71, 32, 77, 85, - 78, 68, 65, 82, 73, 32, 142, 4, 73, 52, 2, 78, 68, 208, 4, 7, 84, 73, 79, - 78, 65, 76, 32, 184, 209, 1, 2, 85, 83, 148, 147, 8, 5, 77, 69, 32, 66, - 65, 220, 218, 3, 7, 90, 65, 82, 32, 65, 77, 85, 164, 163, 1, 8, 82, 82, - 79, 87, 32, 78, 79, 45, 231, 62, 75, 82, 52, 7, 65, 84, 65, 69, 65, 78, - 32, 207, 172, 15, 76, 80, 160, 1, 7, 76, 69, 84, 84, 69, 82, 32, 236, 2, - 7, 78, 85, 77, 66, 69, 82, 32, 161, 249, 9, 16, 67, 82, 85, 67, 73, 70, - 79, 82, 77, 32, 78, 85, 77, 66, 69, 82, 62, 236, 1, 6, 70, 73, 78, 65, - 76, 32, 186, 255, 1, 84, 242, 119, 68, 34, 76, 50, 81, 214, 205, 1, 82, - 142, 220, 2, 65, 50, 71, 90, 90, 34, 83, 66, 89, 198, 207, 1, 72, 234, 5, - 75, 174, 81, 66, 170, 225, 4, 78, 134, 2, 87, 218, 103, 80, 171, 4, 77, - 18, 146, 247, 2, 65, 54, 76, 190, 168, 4, 83, 190, 3, 89, 174, 213, 1, - 75, 174, 81, 66, 170, 225, 4, 78, 222, 105, 72, 171, 4, 77, 16, 162, 248, - 2, 84, 202, 170, 4, 79, 255, 148, 6, 70, 84, 84, 7, 76, 69, 84, 84, 69, - 82, 32, 164, 2, 5, 83, 73, 71, 78, 32, 191, 179, 13, 68, 54, 42, 65, 50, - 69, 66, 73, 50, 79, 47, 85, 11, 242, 151, 15, 78, 202, 17, 66, 2, 72, 3, - 74, 15, 158, 171, 13, 78, 158, 114, 76, 166, 111, 84, 174, 28, 71, 3, 77, - 11, 170, 226, 14, 68, 162, 70, 72, 2, 83, 3, 84, 11, 198, 167, 15, 78, - 86, 76, 2, 80, 3, 89, 11, 238, 167, 15, 67, 2, 68, 2, 75, 3, 82, 10, 100, - 2, 77, 85, 20, 3, 83, 85, 84, 230, 113, 73, 184, 250, 10, 2, 79, 74, 197, - 129, 3, 3, 84, 79, 89, 2, 243, 237, 14, 72, 2, 183, 165, 15, 85, 4, 228, - 193, 11, 5, 76, 32, 80, 79, 76, 187, 15, 82, 133, 1, 41, 8, 73, 78, 65, - 71, 65, 82, 73, 32, 130, 1, 140, 1, 7, 76, 69, 84, 84, 69, 82, 32, 248, - 1, 5, 83, 73, 71, 78, 32, 52, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, - 32, 175, 226, 4, 72, 94, 210, 1, 86, 246, 196, 11, 65, 38, 68, 82, 82, - 34, 84, 230, 5, 85, 186, 202, 1, 73, 42, 76, 226, 195, 1, 78, 46, 83, 82, - 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 138, 69, 72, 2, 77, 2, 89, 186, 2, - 69, 3, 79, 6, 166, 148, 5, 79, 195, 142, 10, 65, 10, 154, 247, 9, 83, - 230, 208, 1, 65, 187, 151, 3, 86, 24, 158, 233, 4, 80, 166, 42, 86, 174, - 183, 6, 65, 38, 85, 186, 202, 1, 73, 198, 140, 2, 69, 3, 79, 4, 162, 48, - 68, 227, 175, 14, 80, 4, 130, 161, 15, 83, 15, 72, 254, 4, 216, 1, 3, 71, - 65, 84, 192, 7, 6, 73, 84, 72, 69, 82, 32, 194, 3, 83, 136, 1, 2, 85, 84, - 242, 1, 87, 148, 16, 3, 88, 84, 32, 232, 186, 8, 4, 80, 84, 85, 78, 148, - 144, 3, 2, 67, 75, 166, 163, 2, 82, 235, 146, 1, 76, 162, 1, 152, 1, 4, - 73, 86, 69, 32, 181, 244, 12, 27, 69, 68, 32, 68, 79, 85, 66, 76, 69, 32, - 86, 69, 82, 84, 73, 67, 65, 76, 32, 66, 65, 82, 32, 68, 79, 85, 66, 160, - 1, 152, 1, 8, 67, 73, 82, 67, 76, 69, 68, 32, 224, 1, 9, 68, 73, 65, 71, - 79, 78, 65, 76, 32, 184, 1, 8, 83, 81, 85, 65, 82, 69, 68, 32, 195, 207, - 8, 65, 78, 112, 5, 68, 73, 71, 73, 84, 28, 7, 78, 85, 77, 66, 69, 82, 32, - 180, 3, 2, 76, 65, 158, 241, 13, 84, 151, 4, 83, 2, 209, 169, 13, 2, 32, - 90, 20, 50, 84, 246, 128, 2, 69, 46, 70, 42, 78, 31, 83, 6, 182, 130, 2, - 72, 47, 87, 6, 38, 77, 162, 215, 13, 67, 183, 4, 68, 2, 49, 10, 73, 68, - 68, 76, 69, 32, 82, 73, 71, 72, 2, 17, 2, 84, 32, 2, 41, 8, 84, 79, 32, - 76, 79, 87, 69, 82, 2, 173, 148, 12, 2, 32, 67, 74, 142, 1, 76, 70, 85, - 254, 165, 12, 68, 138, 29, 81, 140, 131, 1, 2, 67, 82, 226, 19, 65, 234, - 19, 73, 2, 87, 150, 8, 82, 198, 159, 1, 80, 3, 83, 54, 26, 65, 251, 242, - 10, 69, 52, 141, 246, 8, 5, 84, 73, 78, 32, 67, 2, 143, 246, 13, 80, 18, - 158, 1, 65, 216, 1, 17, 71, 82, 69, 65, 84, 69, 82, 45, 84, 72, 65, 78, - 32, 78, 79, 82, 32, 37, 14, 76, 69, 83, 83, 45, 84, 72, 65, 78, 32, 78, - 79, 82, 32, 6, 92, 3, 32, 83, 85, 85, 16, 80, 80, 82, 79, 88, 73, 77, 65, - 84, 69, 76, 89, 32, 78, 79, 82, 4, 30, 66, 1, 3, 80, 69, 82, 2, 169, 246, - 6, 8, 83, 69, 84, 32, 79, 70, 32, 78, 2, 233, 48, 5, 32, 65, 67, 84, 85, - 6, 230, 145, 8, 69, 167, 237, 4, 76, 6, 194, 145, 8, 69, 131, 237, 4, 71, - 6, 26, 84, 151, 139, 13, 83, 4, 76, 5, 73, 78, 71, 32, 68, 197, 216, 10, - 8, 32, 87, 73, 84, 72, 32, 69, 71, 2, 141, 253, 7, 2, 79, 76, 64, 40, 4, - 82, 65, 76, 32, 135, 218, 14, 69, 62, 48, 6, 67, 72, 69, 83, 83, 32, 167, - 213, 14, 70, 60, 74, 75, 162, 178, 13, 66, 38, 69, 150, 5, 80, 22, 81, - 38, 82, 131, 2, 84, 20, 44, 5, 78, 73, 71, 72, 84, 199, 179, 13, 73, 15, - 243, 179, 13, 32, 246, 2, 70, 32, 184, 8, 2, 65, 32, 252, 6, 3, 76, 73, - 78, 207, 219, 3, 83, 174, 1, 90, 77, 64, 4, 83, 72, 69, 81, 20, 8, 84, - 65, 73, 32, 76, 85, 69, 32, 227, 243, 13, 76, 4, 25, 4, 79, 79, 78, 32, - 4, 242, 143, 8, 87, 183, 234, 5, 83, 2, 147, 195, 9, 69, 166, 1, 160, 1, + 183, 150, 14, 82, 6, 26, 89, 159, 224, 12, 69, 4, 250, 128, 16, 65, 155, + 1, 73, 2, 239, 152, 4, 76, 10, 48, 2, 78, 32, 146, 232, 4, 68, 171, 210, + 11, 83, 6, 88, 12, 86, 73, 69, 87, 73, 78, 71, 32, 67, 69, 82, 69, 154, + 223, 12, 67, 85, 2, 76, 65, 2, 213, 176, 16, 2, 77, 79, 4, 142, 216, 12, + 73, 135, 248, 3, 69, 10, 26, 72, 69, 2, 79, 82, 2, 45, 9, 69, 82, 32, 67, + 72, 82, 73, 83, 84, 2, 163, 147, 3, 77, 8, 50, 32, 52, 4, 73, 90, 69, 68, + 139, 192, 15, 87, 4, 170, 225, 8, 66, 161, 176, 6, 4, 83, 67, 79, 79, 2, + 241, 196, 3, 7, 32, 87, 72, 69, 69, 76, 67, 18, 52, 2, 78, 84, 152, 1, 2, + 83, 69, 155, 203, 16, 84, 10, 48, 3, 65, 73, 78, 165, 167, 12, 3, 32, 70, + 85, 9, 11, 32, 6, 214, 232, 9, 82, 24, 5, 67, 65, 66, 76, 69, 129, 241, + 1, 6, 66, 73, 67, 89, 67, 76, 7, 11, 32, 4, 144, 185, 15, 2, 84, 82, 131, + 86, 70, 86, 52, 7, 76, 69, 84, 84, 69, 82, 32, 251, 130, 6, 68, 62, 202, + 1, 75, 62, 77, 34, 78, 34, 79, 30, 80, 34, 84, 202, 129, 1, 68, 156, 135, + 8, 2, 72, 65, 2, 82, 254, 225, 1, 83, 174, 89, 76, 246, 7, 67, 210, 100, + 69, 246, 248, 3, 89, 190, 28, 66, 2, 87, 187, 2, 65, 6, 128, 196, 5, 2, + 69, 65, 186, 140, 6, 72, 183, 249, 4, 79, 4, 134, 183, 16, 65, 215, 1, + 73, 4, 178, 249, 15, 73, 139, 60, 71, 7, 242, 200, 16, 76, 3, 79, 4, 254, + 180, 16, 72, 219, 19, 65, 6, 246, 174, 9, 72, 170, 150, 7, 69, 155, 3, + 65, 224, 5, 44, 2, 76, 84, 242, 6, 83, 167, 167, 14, 67, 102, 36, 4, 65, + 78, 73, 32, 219, 2, 73, 76, 52, 7, 76, 69, 84, 84, 69, 82, 32, 187, 169, + 4, 83, 74, 206, 1, 68, 190, 107, 78, 190, 232, 1, 82, 142, 214, 9, 74, + 210, 57, 84, 146, 154, 3, 66, 2, 67, 2, 71, 2, 75, 2, 80, 138, 69, 72, 2, + 76, 2, 77, 2, 83, 2, 86, 2, 89, 186, 2, 65, 2, 69, 2, 73, 3, 85, 10, 38, + 68, 198, 194, 16, 72, 187, 2, 65, 6, 194, 194, 16, 68, 2, 72, 187, 2, 65, + 26, 56, 2, 80, 76, 244, 2, 3, 83, 69, 84, 159, 174, 15, 77, 18, 50, 69, + 89, 8, 73, 67, 65, 84, 73, 79, 78, 32, 2, 41, 8, 32, 77, 85, 83, 73, 67, + 65, 76, 2, 21, 3, 32, 78, 79, 2, 155, 173, 15, 84, 16, 40, 4, 83, 73, 71, + 78, 227, 194, 16, 88, 15, 11, 32, 12, 48, 3, 73, 78, 32, 89, 5, 87, 73, + 84, 72, 32, 8, 50, 68, 142, 227, 3, 76, 22, 82, 155, 183, 11, 84, 2, 197, + 168, 13, 4, 79, 85, 66, 76, 4, 210, 205, 12, 85, 171, 243, 2, 68, 7, 11, + 32, 4, 192, 107, 5, 77, 85, 76, 84, 73, 199, 158, 12, 85, 246, 4, 44, 5, + 72, 82, 79, 79, 77, 21, 2, 73, 67, 5, 231, 145, 15, 32, 242, 4, 30, 32, + 109, 3, 65, 76, 32, 6, 64, 4, 78, 65, 84, 85, 20, 3, 83, 72, 65, 165, 62, + 2, 70, 76, 2, 159, 237, 10, 82, 2, 199, 216, 11, 82, 236, 4, 64, 8, 75, + 69, 89, 66, 79, 65, 82, 68, 66, 83, 187, 140, 4, 78, 5, 41, 8, 32, 87, + 73, 84, 72, 32, 74, 65, 2, 151, 154, 14, 67, 230, 4, 48, 6, 89, 77, 66, + 79, 76, 32, 211, 202, 11, 67, 228, 4, 232, 2, 11, 65, 82, 80, 69, 71, 71, + 73, 65, 84, 79, 32, 70, 66, 238, 1, 67, 186, 13, 68, 246, 7, 69, 162, 1, + 70, 230, 4, 71, 154, 4, 72, 198, 2, 75, 158, 3, 76, 154, 1, 77, 158, 2, + 78, 194, 1, 79, 242, 4, 80, 200, 2, 2, 81, 85, 170, 2, 82, 222, 3, 83, + 210, 7, 84, 190, 13, 86, 42, 88, 42, 87, 172, 147, 9, 9, 73, 78, 86, 69, + 82, 84, 69, 68, 32, 207, 215, 6, 90, 6, 32, 2, 85, 80, 171, 235, 6, 68, + 5, 213, 137, 6, 3, 32, 87, 73, 20, 36, 5, 69, 71, 73, 78, 32, 59, 82, 8, + 222, 23, 80, 30, 83, 234, 137, 8, 66, 223, 252, 7, 84, 12, 24, 2, 65, 67, + 35, 69, 4, 130, 132, 16, 75, 155, 53, 69, 8, 26, 86, 135, 247, 15, 65, 6, + 32, 2, 73, 83, 191, 184, 16, 69, 5, 151, 76, 32, 112, 120, 5, 32, 67, 76, + 69, 70, 80, 2, 65, 69, 34, 76, 94, 79, 150, 10, 82, 46, 85, 133, 64, 7, + 73, 82, 67, 76, 69, 32, 88, 7, 11, 32, 4, 254, 27, 79, 29, 11, 81, 85, + 73, 78, 68, 73, 67, 69, 83, 73, 77, 2, 11, 83, 2, 147, 242, 15, 85, 8, + 42, 73, 233, 37, 5, 85, 83, 84, 69, 82, 4, 26, 77, 191, 139, 14, 86, 2, + 191, 243, 9, 65, 84, 26, 77, 147, 179, 16, 68, 82, 64, 7, 66, 73, 78, 73, + 78, 71, 32, 137, 173, 6, 3, 77, 79, 78, 80, 186, 1, 65, 80, 7, 77, 65, + 82, 67, 65, 84, 79, 58, 66, 68, 2, 68, 79, 56, 2, 70, 76, 124, 5, 72, 65, + 82, 77, 79, 22, 83, 178, 3, 84, 114, 85, 244, 145, 11, 2, 76, 79, 247, + 152, 5, 82, 6, 76, 5, 67, 67, 69, 78, 84, 37, 10, 85, 71, 77, 69, 78, 84, + 65, 84, 73, 79, 5, 181, 3, 5, 45, 83, 84, 65, 67, 2, 163, 159, 15, 78, 4, + 148, 229, 4, 8, 85, 90, 90, 32, 82, 79, 76, 76, 151, 189, 10, 69, 6, 184, + 5, 2, 85, 66, 84, 2, 87, 78, 195, 143, 16, 73, 18, 32, 2, 65, 71, 151, + 177, 16, 73, 16, 11, 45, 16, 146, 177, 16, 49, 2, 50, 2, 51, 2, 52, 2, + 53, 2, 54, 2, 55, 3, 56, 2, 235, 133, 15, 78, 18, 112, 9, 78, 65, 80, 32, + 80, 73, 90, 90, 73, 20, 9, 80, 82, 69, 67, 72, 71, 69, 83, 65, 30, 84, + 211, 240, 10, 77, 2, 151, 203, 8, 67, 2, 129, 226, 4, 2, 78, 71, 12, 60, + 5, 65, 67, 67, 65, 84, 64, 2, 69, 77, 179, 149, 15, 82, 4, 40, 4, 73, 83, + 83, 73, 167, 174, 16, 79, 2, 175, 143, 16, 77, 7, 29, 5, 32, 66, 79, 87, + 32, 4, 76, 6, 66, 69, 72, 73, 78, 68, 1, 9, 79, 78, 32, 84, 79, 80, 32, + 79, 70, 2, 197, 234, 10, 2, 32, 66, 14, 34, 82, 209, 180, 12, 2, 69, 78, + 12, 28, 2, 73, 80, 139, 13, 69, 2, 137, 151, 12, 6, 76, 69, 32, 84, 79, + 78, 4, 38, 80, 153, 150, 9, 3, 78, 83, 84, 2, 137, 143, 15, 2, 32, 66, 6, + 22, 79, 243, 2, 69, 2, 247, 156, 15, 73, 4, 166, 163, 6, 84, 221, 137, 9, + 3, 82, 76, 69, 56, 114, 65, 142, 1, 69, 142, 1, 73, 220, 3, 6, 79, 85, + 66, 76, 69, 32, 201, 185, 10, 7, 82, 85, 77, 32, 67, 76, 69, 10, 96, 2, + 32, 67, 20, 2, 77, 80, 172, 45, 4, 83, 72, 69, 68, 205, 210, 15, 5, 76, + 32, 83, 69, 71, 2, 231, 213, 8, 65, 5, 179, 155, 14, 32, 6, 40, 3, 67, + 82, 69, 77, 3, 71, 82, 69, 4, 33, 6, 83, 67, 69, 78, 68, 79, 5, 197, 241, + 6, 5, 32, 87, 73, 84, 72, 2, 215, 253, 8, 69, 24, 92, 15, 65, 77, 79, 78, + 68, 32, 78, 79, 84, 69, 72, 69, 65, 68, 32, 117, 4, 71, 73, 84, 32, 8, + 80, 2, 87, 72, 220, 132, 7, 8, 72, 65, 76, 70, 45, 70, 73, 76, 255, 254, + 5, 66, 4, 166, 218, 14, 73, 147, 37, 79, 16, 50, 70, 46, 83, 122, 84, 21, + 4, 78, 73, 78, 69, 6, 84, 3, 73, 86, 69, 97, 3, 79, 85, 82, 6, 40, 4, 69, + 86, 69, 78, 97, 2, 73, 88, 4, 33, 6, 32, 87, 73, 84, 72, 32, 4, 204, 244, + 15, 3, 76, 79, 87, 27, 83, 2, 17, 2, 87, 79, 2, 11, 32, 2, 231, 39, 87, + 12, 90, 83, 234, 39, 66, 246, 3, 71, 140, 9, 7, 84, 82, 73, 65, 78, 71, + 85, 131, 252, 4, 70, 4, 234, 29, 72, 149, 23, 5, 81, 85, 65, 82, 69, 14, + 32, 3, 78, 68, 32, 143, 23, 73, 10, 74, 80, 30, 83, 192, 19, 3, 79, 70, + 32, 170, 246, 7, 66, 223, 252, 7, 84, 2, 233, 244, 12, 2, 72, 82, 2, 159, + 169, 15, 76, 50, 136, 1, 5, 32, 67, 76, 69, 70, 48, 6, 69, 82, 77, 65, + 84, 65, 22, 73, 200, 1, 4, 76, 65, 84, 32, 162, 1, 79, 153, 46, 3, 85, + 83, 65, 11, 11, 32, 8, 182, 6, 81, 213, 16, 2, 79, 84, 5, 155, 235, 13, + 32, 16, 26, 78, 93, 2, 86, 69, 12, 56, 9, 71, 69, 82, 69, 68, 32, 84, 82, + 69, 235, 28, 65, 10, 137, 81, 4, 77, 79, 76, 79, 4, 208, 50, 14, 32, 72, + 85, 78, 68, 82, 69, 68, 32, 84, 87, 69, 76, 70, 55, 45, 10, 60, 5, 87, + 73, 84, 72, 32, 250, 206, 6, 68, 135, 207, 9, 85, 6, 60, 9, 68, 79, 85, + 66, 76, 69, 32, 83, 84, 207, 237, 15, 83, 4, 226, 237, 15, 82, 143, 31, + 69, 6, 132, 34, 3, 85, 82, 45, 151, 175, 14, 82, 26, 88, 5, 32, 67, 76, + 69, 70, 170, 2, 82, 153, 144, 6, 8, 76, 73, 83, 83, 65, 78, 68, 79, 15, + 11, 32, 12, 22, 79, 239, 1, 81, 8, 84, 11, 80, 84, 73, 79, 78, 65, 76, + 76, 89, 32, 79, 57, 6, 84, 84, 65, 86, 65, 32, 2, 25, 4, 84, 84, 65, 86, + 2, 185, 22, 3, 65, 32, 66, 6, 44, 5, 66, 65, 83, 83, 65, 211, 217, 12, + 65, 5, 229, 34, 7, 32, 87, 73, 84, 72, 32, 67, 4, 229, 20, 2, 85, 73, 8, + 84, 9, 65, 67, 69, 32, 78, 79, 84, 69, 32, 37, 8, 69, 71, 79, 82, 73, 65, + 78, 32, 4, 248, 238, 8, 2, 78, 79, 27, 83, 4, 166, 33, 67, 3, 70, 22, 22, + 65, 171, 1, 69, 16, 44, 3, 76, 70, 32, 233, 9, 3, 85, 80, 84, 14, 80, 3, + 80, 69, 68, 20, 5, 83, 72, 65, 82, 80, 234, 229, 3, 78, 179, 186, 8, 82, + 2, 135, 208, 5, 65, 9, 211, 26, 32, 6, 68, 4, 78, 90, 69, 32, 237, 26, 8, + 65, 86, 89, 32, 68, 79, 85, 66, 4, 168, 40, 4, 76, 79, 78, 71, 1, 5, 83, + 72, 79, 82, 84, 24, 48, 6, 73, 69, 86, 65, 78, 32, 251, 237, 14, 79, 22, + 182, 1, 69, 68, 7, 81, 85, 65, 82, 84, 69, 82, 62, 70, 226, 27, 67, 244, + 197, 3, 4, 72, 65, 76, 70, 0, 5, 87, 72, 79, 76, 69, 253, 226, 1, 9, 82, + 69, 67, 73, 84, 65, 84, 73, 86, 6, 64, 5, 73, 71, 72, 84, 72, 177, 216, + 14, 5, 78, 68, 32, 79, 70, 4, 141, 138, 6, 10, 32, 78, 79, 84, 69, 32, + 83, 84, 69, 77, 4, 182, 18, 76, 157, 207, 3, 4, 73, 78, 65, 76, 10, 44, + 4, 79, 78, 71, 65, 181, 17, 2, 69, 70, 9, 11, 32, 6, 44, 3, 73, 77, 80, + 2, 80, 255, 154, 12, 82, 2, 229, 37, 7, 69, 82, 70, 69, 67, 84, 65, 18, + 104, 2, 65, 88, 20, 2, 69, 90, 20, 5, 73, 78, 73, 77, 65, 44, 3, 79, 79, + 78, 25, 4, 85, 76, 84, 73, 2, 239, 239, 15, 73, 2, 247, 241, 15, 90, 7, + 11, 32, 4, 174, 153, 12, 82, 195, 84, 66, 4, 205, 22, 2, 32, 78, 4, 224, + 35, 11, 80, 76, 69, 32, 77, 69, 65, 83, 85, 82, 69, 15, 32, 12, 152, 1, + 4, 69, 66, 69, 78, 148, 35, 3, 85, 76, 76, 168, 225, 5, 3, 65, 84, 85, + 136, 231, 6, 7, 79, 84, 69, 72, 69, 65, 68, 229, 214, 1, 3, 73, 69, 78, + 2, 193, 244, 14, 4, 83, 84, 73, 77, 44, 40, 2, 78, 69, 174, 2, 82, 255, + 1, 84, 14, 22, 32, 191, 33, 45, 12, 248, 1, 17, 72, 85, 78, 68, 82, 69, + 68, 32, 84, 87, 69, 78, 84, 89, 45, 69, 73, 232, 9, 16, 65, 78, 68, 32, + 65, 32, 72, 65, 76, 70, 32, 83, 72, 65, 82, 80, 165, 21, 20, 84, 72, 79, + 85, 83, 65, 78, 68, 32, 84, 87, 69, 78, 84, 89, 45, 70, 79, 85, 82, 4, + 177, 17, 2, 71, 72, 26, 108, 10, 71, 65, 78, 32, 80, 69, 68, 65, 76, 32, + 37, 13, 78, 65, 77, 69, 78, 84, 32, 83, 84, 82, 79, 75, 69, 4, 218, 190, + 6, 72, 143, 181, 9, 84, 22, 11, 45, 22, 190, 169, 3, 49, 218, 224, 12, + 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 4, 189, 4, 3, 84, + 65, 86, 18, 96, 9, 65, 82, 69, 78, 84, 72, 69, 83, 73, 0, 2, 76, 85, 18, + 69, 142, 1, 79, 175, 249, 13, 73, 2, 155, 29, 83, 6, 68, 4, 68, 65, 76, + 32, 49, 9, 83, 32, 83, 85, 66, 80, 85, 78, 67, 4, 26, 85, 159, 198, 15, + 77, 2, 131, 198, 15, 80, 2, 247, 220, 13, 84, 6, 48, 2, 68, 65, 253, 7, + 5, 82, 82, 69, 67, 84, 2, 239, 250, 13, 84, 12, 44, 6, 65, 82, 84, 69, + 82, 32, 131, 1, 73, 8, 60, 5, 84, 79, 78, 69, 32, 158, 212, 3, 78, 179, + 186, 8, 82, 4, 32, 2, 83, 72, 255, 146, 5, 70, 2, 181, 133, 16, 2, 65, + 82, 4, 41, 8, 78, 68, 73, 67, 69, 83, 73, 77, 4, 17, 2, 65, 32, 4, 26, + 66, 227, 195, 12, 65, 2, 133, 130, 16, 2, 65, 83, 26, 22, 69, 199, 2, 73, + 22, 52, 4, 80, 69, 65, 84, 81, 5, 86, 69, 82, 83, 69, 8, 56, 8, 69, 68, + 32, 70, 73, 71, 85, 82, 203, 173, 14, 32, 6, 147, 227, 5, 69, 14, 60, 5, + 32, 70, 73, 78, 65, 17, 6, 68, 32, 70, 76, 65, 84, 2, 243, 6, 76, 13, 11, + 32, 10, 72, 8, 65, 78, 68, 32, 70, 76, 65, 84, 218, 178, 6, 68, 135, 207, + 9, 85, 7, 147, 248, 5, 32, 4, 48, 2, 71, 72, 57, 6, 78, 70, 79, 82, 90, + 65, 2, 33, 6, 84, 32, 82, 69, 80, 69, 2, 195, 175, 10, 65, 2, 239, 185, + 8, 78, 58, 224, 1, 6, 67, 65, 78, 68, 73, 67, 62, 69, 162, 1, 72, 138, 1, + 73, 136, 2, 6, 81, 85, 65, 82, 69, 32, 86, 85, 166, 136, 9, 79, 164, 179, + 3, 5, 89, 83, 84, 69, 77, 141, 252, 2, 11, 65, 76, 90, 69, 68, 79, 32, + 66, 82, 69, 65, 4, 17, 2, 85, 83, 5, 221, 242, 13, 5, 32, 70, 76, 69, 88, + 14, 32, 2, 77, 73, 131, 213, 15, 71, 12, 64, 6, 66, 82, 69, 86, 73, 83, + 1, 6, 77, 73, 78, 73, 77, 65, 6, 11, 32, 6, 214, 14, 87, 206, 247, 11, + 82, 195, 84, 66, 8, 48, 4, 65, 82, 80, 32, 133, 1, 3, 79, 82, 84, 6, 42, + 87, 166, 173, 6, 68, 135, 207, 9, 85, 2, 17, 2, 73, 84, 2, 139, 204, 15, + 72, 14, 24, 2, 78, 71, 63, 88, 2, 17, 2, 76, 69, 2, 17, 2, 32, 66, 2, + 251, 141, 14, 65, 12, 18, 45, 79, 84, 4, 154, 15, 76, 245, 210, 14, 11, + 83, 84, 82, 73, 78, 71, 32, 70, 82, 69, 84, 8, 52, 3, 69, 69, 78, 1, 6, + 89, 45, 70, 79, 85, 82, 4, 129, 16, 2, 84, 72, 8, 38, 78, 194, 11, 70, + 159, 238, 15, 66, 4, 201, 10, 7, 79, 84, 69, 72, 69, 65, 68, 4, 174, 161, + 8, 66, 209, 177, 5, 2, 83, 80, 68, 172, 1, 8, 65, 66, 76, 65, 84, 85, 82, + 69, 40, 6, 69, 77, 80, 85, 83, 32, 154, 4, 72, 88, 7, 79, 82, 67, 85, 76, + 85, 83, 46, 82, 192, 4, 3, 85, 82, 78, 49, 2, 87, 79, 2, 17, 2, 32, 67, + 2, 187, 141, 5, 76, 16, 232, 1, 27, 73, 77, 80, 69, 82, 70, 69, 67, 84, + 85, 77, 32, 67, 85, 77, 32, 80, 82, 79, 76, 65, 84, 73, 79, 78, 69, 32, + 129, 1, 25, 80, 69, 82, 70, 69, 67, 84, 85, 77, 32, 67, 85, 77, 32, 80, + 82, 79, 76, 65, 84, 73, 79, 78, 69, 32, 10, 60, 10, 73, 77, 80, 69, 82, + 70, 69, 67, 84, 65, 131, 1, 80, 9, 237, 212, 5, 11, 32, 68, 73, 77, 73, + 78, 85, 84, 73, 79, 78, 6, 60, 3, 73, 77, 80, 41, 8, 80, 69, 82, 70, 69, + 67, 84, 65, 2, 177, 207, 15, 5, 69, 82, 70, 69, 67, 5, 201, 198, 8, 12, + 32, 68, 73, 77, 73, 78, 85, 84, 73, 79, 78, 45, 6, 128, 7, 4, 82, 69, 69, + 45, 249, 1, 11, 73, 82, 84, 89, 45, 83, 69, 67, 79, 78, 68, 5, 129, 226, + 11, 6, 32, 82, 69, 83, 85, 80, 31, 11, 73, 28, 48, 3, 65, 78, 71, 237, 3, + 4, 80, 76, 69, 32, 26, 28, 2, 76, 69, 235, 2, 85, 24, 128, 1, 10, 32, 78, + 79, 84, 69, 72, 69, 65, 68, 32, 61, 17, 45, 82, 79, 85, 78, 68, 32, 78, + 79, 84, 69, 72, 69, 65, 68, 32, 68, 20, 58, 68, 24, 3, 85, 80, 32, 38, + 82, 25, 3, 76, 69, 70, 4, 93, 3, 79, 87, 78, 8, 34, 82, 78, 87, 143, 204, + 12, 66, 4, 21, 3, 73, 71, 72, 4, 11, 84, 4, 11, 32, 4, 26, 87, 143, 204, + 12, 66, 2, 11, 72, 2, 207, 162, 14, 73, 2, 21, 3, 76, 65, 82, 2, 17, 2, + 32, 70, 2, 11, 69, 2, 11, 82, 2, 11, 77, 2, 171, 201, 15, 65, 2, 155, + 251, 4, 70, 7, 11, 32, 4, 182, 195, 8, 83, 131, 170, 7, 85, 4, 88, 18, + 32, 72, 85, 78, 68, 82, 69, 68, 32, 70, 73, 70, 84, 89, 45, 83, 73, 88, + 55, 45, 2, 17, 2, 84, 72, 2, 11, 32, 2, 135, 245, 11, 82, 2, 11, 76, 2, + 37, 7, 73, 78, 69, 32, 83, 84, 65, 2, 183, 234, 14, 70, 4, 36, 3, 79, 73, + 68, 211, 168, 15, 73, 2, 213, 142, 13, 5, 32, 78, 79, 84, 69, 6, 92, 4, + 72, 79, 76, 69, 193, 206, 8, 13, 73, 84, 72, 32, 70, 73, 78, 71, 69, 82, + 78, 65, 73, 4, 11, 32, 4, 190, 184, 3, 78, 179, 186, 8, 82, 232, 3, 224, + 2, 15, 67, 79, 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, 32, 254, + 1, 76, 212, 14, 16, 77, 79, 68, 73, 70, 73, 69, 82, 32, 76, 69, 84, 84, + 69, 82, 32, 122, 83, 80, 16, 69, 65, 83, 84, 69, 82, 78, 32, 80, 87, 79, + 32, 75, 65, 82, 69, 222, 9, 84, 204, 1, 11, 86, 79, 87, 69, 76, 32, 83, + 73, 71, 78, 32, 164, 181, 9, 3, 80, 65, 79, 255, 156, 4, 68, 16, 66, 77, + 165, 1, 11, 83, 72, 65, 78, 32, 77, 69, 68, 73, 65, 76, 14, 80, 6, 69, + 68, 73, 65, 76, 32, 45, 10, 79, 78, 32, 77, 69, 68, 73, 65, 76, 32, 8, + 174, 227, 15, 72, 2, 82, 2, 87, 3, 89, 6, 130, 227, 15, 76, 2, 77, 3, 78, + 2, 203, 229, 10, 32, 238, 1, 104, 6, 69, 84, 84, 69, 82, 32, 185, 13, 15, + 79, 71, 79, 71, 82, 65, 77, 32, 75, 72, 65, 77, 84, 73, 32, 232, 1, 238, + 1, 65, 50, 69, 146, 1, 71, 50, 75, 254, 1, 77, 134, 1, 78, 58, 82, 86, + 83, 130, 3, 84, 198, 1, 87, 162, 245, 11, 68, 214, 6, 85, 22, 86, 246, + 203, 1, 73, 42, 76, 254, 199, 1, 66, 2, 67, 2, 74, 2, 80, 138, 69, 72, 2, + 89, 187, 2, 79, 7, 196, 151, 15, 4, 73, 84, 79, 78, 219, 74, 85, 9, 77, + 17, 65, 83, 84, 69, 82, 78, 32, 80, 87, 79, 32, 75, 65, 82, 69, 78, 32, + 6, 42, 71, 170, 225, 10, 89, 179, 190, 3, 78, 2, 167, 225, 10, 72, 6, + 158, 206, 9, 82, 138, 144, 6, 72, 187, 2, 65, 44, 32, 2, 72, 65, 143, + 224, 15, 65, 43, 25, 4, 77, 84, 73, 32, 40, 134, 1, 68, 34, 84, 230, 224, + 8, 78, 166, 182, 6, 67, 2, 72, 2, 74, 170, 37, 76, 226, 31, 70, 2, 71, 2, + 82, 2, 83, 2, 88, 3, 90, 6, 166, 151, 15, 68, 139, 69, 72, 4, 135, 151, + 15, 84, 12, 36, 3, 79, 78, 32, 143, 222, 15, 65, 10, 60, 2, 66, 66, 142, + 221, 13, 74, 254, 189, 1, 78, 199, 66, 69, 4, 202, 221, 15, 65, 3, 69, + 10, 202, 223, 8, 78, 174, 251, 6, 71, 2, 89, 187, 2, 65, 4, 224, 217, 2, + 12, 85, 77, 65, 73, 32, 80, 65, 76, 65, 85, 78, 71, 151, 131, 13, 65, 50, + 90, 72, 164, 218, 2, 9, 71, 65, 87, 32, 75, 65, 82, 69, 78, 238, 254, 12, + 83, 187, 2, 65, 44, 66, 65, 197, 1, 11, 87, 69, 32, 80, 65, 76, 65, 85, + 78, 71, 32, 41, 17, 2, 78, 32, 38, 134, 1, 78, 170, 217, 13, 74, 2, 80, + 2, 84, 130, 185, 1, 66, 2, 67, 2, 71, 2, 75, 138, 69, 68, 2, 70, 2, 72, + 2, 90, 187, 2, 65, 6, 174, 215, 15, 78, 2, 89, 187, 2, 65, 4, 254, 216, + 13, 67, 3, 83, 36, 38, 65, 190, 145, 15, 84, 139, 69, 72, 31, 41, 8, 73, + 32, 76, 65, 73, 78, 71, 32, 28, 82, 78, 190, 245, 11, 68, 130, 155, 3, + 66, 2, 71, 2, 74, 170, 37, 76, 227, 31, 70, 4, 194, 213, 15, 78, 3, 89, + 6, 92, 17, 69, 83, 84, 69, 82, 78, 32, 80, 87, 79, 32, 75, 65, 82, 69, + 78, 32, 131, 215, 15, 65, 4, 178, 215, 10, 80, 143, 255, 2, 84, 6, 186, + 200, 14, 79, 194, 62, 81, 139, 63, 72, 4, 56, 6, 75, 72, 65, 77, 84, 73, + 1, 4, 83, 72, 65, 78, 2, 29, 5, 32, 82, 69, 68, 85, 2, 185, 128, 1, 2, + 80, 76, 90, 76, 2, 72, 65, 20, 4, 73, 71, 78, 32, 233, 6, 6, 89, 77, 66, + 79, 76, 32, 20, 203, 192, 9, 78, 52, 202, 3, 65, 32, 12, 75, 72, 65, 77, + 84, 73, 32, 84, 79, 78, 69, 45, 30, 83, 132, 2, 15, 84, 65, 73, 32, 76, + 65, 73, 78, 71, 32, 84, 79, 78, 69, 45, 28, 22, 87, 69, 83, 84, 69, 82, + 78, 32, 80, 87, 79, 32, 75, 65, 82, 69, 78, 32, 84, 79, 78, 69, 202, 241, + 2, 68, 232, 173, 5, 19, 82, 85, 77, 65, 73, 32, 80, 65, 76, 65, 85, 78, + 71, 32, 84, 79, 78, 69, 45, 140, 180, 3, 9, 80, 65, 79, 32, 75, 65, 82, + 69, 78, 208, 116, 6, 76, 73, 84, 84, 76, 69, 151, 195, 2, 86, 4, 214, + 199, 14, 83, 199, 68, 78, 4, 230, 208, 15, 49, 3, 51, 18, 40, 4, 72, 65, + 78, 32, 199, 255, 14, 69, 16, 84, 8, 67, 79, 85, 78, 67, 73, 76, 32, 84, + 5, 84, 79, 78, 69, 45, 203, 208, 14, 83, 6, 212, 212, 11, 8, 69, 77, 80, + 72, 65, 84, 73, 67, 241, 249, 3, 4, 84, 79, 78, 69, 8, 242, 206, 15, 50, + 2, 51, 2, 53, 3, 54, 4, 198, 206, 15, 50, 3, 53, 10, 11, 45, 10, 158, + 206, 15, 49, 2, 50, 2, 51, 2, 52, 3, 53, 18, 134, 1, 65, 128, 1, 2, 76, + 79, 28, 5, 83, 72, 65, 78, 32, 164, 180, 8, 4, 71, 69, 78, 73, 253, 226, + 5, 6, 67, 79, 77, 80, 76, 69, 8, 84, 5, 73, 84, 79, 78, 32, 253, 178, 6, + 10, 70, 79, 82, 69, 77, 69, 78, 84, 73, 79, 6, 94, 69, 214, 179, 13, 84, + 171, 124, 79, 2, 189, 180, 8, 2, 67, 65, 4, 26, 69, 255, 175, 14, 79, 2, + 201, 12, 4, 88, 67, 76, 65, 24, 140, 1, 20, 79, 78, 69, 32, 77, 65, 82, + 75, 32, 83, 71, 65, 87, 32, 75, 65, 82, 69, 78, 32, 225, 181, 9, 8, 65, + 73, 32, 76, 65, 73, 78, 71, 4, 38, 72, 245, 212, 8, 3, 75, 69, 32, 2, + 255, 214, 8, 65, 56, 150, 2, 65, 76, 9, 71, 69, 66, 65, 32, 75, 65, 82, + 69, 20, 6, 75, 65, 89, 65, 72, 32, 40, 4, 77, 79, 78, 32, 34, 83, 142, 1, + 69, 40, 18, 87, 69, 83, 84, 69, 82, 78, 32, 80, 87, 79, 32, 75, 65, 82, + 69, 78, 32, 224, 188, 9, 2, 84, 65, 130, 172, 2, 85, 22, 86, 247, 203, 1, + 73, 8, 26, 73, 143, 199, 15, 65, 7, 25, 4, 84, 79, 78, 32, 4, 139, 183, + 13, 65, 2, 203, 134, 15, 78, 6, 242, 175, 15, 69, 2, 79, 215, 22, 85, 4, + 198, 178, 15, 73, 219, 19, 79, 10, 80, 4, 72, 65, 78, 32, 145, 211, 8, + 10, 71, 65, 87, 32, 75, 65, 82, 69, 78, 32, 8, 54, 69, 20, 5, 70, 73, 78, + 65, 76, 171, 194, 15, 65, 5, 251, 199, 14, 32, 2, 151, 179, 15, 32, 4, + 226, 159, 15, 69, 151, 14, 85, 210, 11, 152, 2, 5, 45, 65, 82, 89, 32, + 214, 4, 65, 222, 16, 66, 30, 69, 186, 32, 73, 136, 1, 3, 75, 79, 32, 146, + 10, 79, 166, 24, 85, 152, 4, 22, 89, 73, 65, 75, 69, 78, 71, 32, 80, 85, + 65, 67, 72, 85, 69, 32, 72, 77, 79, 78, 71, 32, 136, 137, 2, 2, 80, 78, + 148, 219, 12, 2, 78, 66, 27, 76, 32, 130, 1, 67, 114, 84, 46, 83, 160, 1, + 5, 85, 78, 73, 79, 78, 108, 4, 87, 72, 73, 84, 222, 243, 11, 76, 194, 18, + 73, 159, 166, 2, 80, 8, 52, 7, 73, 82, 67, 76, 69, 68, 32, 159, 175, 14, + 79, 6, 40, 2, 80, 76, 14, 84, 195, 148, 8, 68, 2, 35, 85, 2, 21, 3, 73, + 77, 69, 2, 195, 247, 11, 83, 6, 40, 6, 81, 85, 65, 82, 69, 32, 87, 85, 4, + 60, 9, 73, 78, 84, 69, 82, 83, 69, 67, 84, 1, 2, 85, 78, 2, 163, 209, 11, + 73, 2, 11, 77, 2, 155, 244, 11, 77, 7, 69, 15, 32, 79, 80, 69, 82, 65, + 84, 79, 82, 32, 87, 73, 84, 72, 32, 4, 170, 173, 11, 80, 163, 192, 3, 68, + 2, 11, 69, 2, 209, 223, 12, 2, 32, 86, 188, 2, 170, 2, 66, 252, 4, 10, + 71, 32, 77, 85, 78, 68, 65, 82, 73, 32, 142, 4, 73, 52, 2, 78, 68, 208, + 4, 7, 84, 73, 79, 78, 65, 76, 32, 204, 210, 1, 2, 85, 83, 236, 151, 8, 5, + 77, 69, 32, 66, 65, 164, 221, 3, 7, 90, 65, 82, 32, 65, 77, 85, 188, 166, + 1, 8, 82, 82, 79, 87, 32, 78, 79, 45, 231, 62, 75, 82, 52, 7, 65, 84, 65, + 69, 65, 78, 32, 155, 184, 15, 76, 80, 160, 1, 7, 76, 69, 84, 84, 69, 82, + 32, 236, 2, 7, 78, 85, 77, 66, 69, 82, 32, 157, 255, 9, 16, 67, 82, 85, + 67, 73, 70, 79, 82, 77, 32, 78, 85, 77, 66, 69, 82, 62, 236, 1, 6, 70, + 73, 78, 65, 76, 32, 218, 128, 2, 84, 134, 120, 68, 34, 76, 50, 81, 238, + 206, 1, 82, 198, 221, 2, 65, 50, 71, 90, 90, 34, 83, 66, 89, 206, 209, 1, + 72, 234, 5, 75, 142, 81, 66, 138, 231, 4, 78, 134, 2, 87, 218, 103, 80, + 171, 4, 77, 18, 198, 248, 2, 65, 54, 76, 142, 171, 4, 83, 190, 3, 89, + 182, 215, 1, 75, 142, 81, 66, 138, 231, 4, 78, 222, 105, 72, 171, 4, 77, + 16, 214, 249, 2, 84, 154, 173, 4, 79, 175, 153, 6, 70, 84, 84, 7, 76, 69, + 84, 84, 69, 82, 32, 164, 2, 5, 83, 73, 71, 78, 32, 243, 187, 13, 68, 54, + 42, 65, 50, 69, 66, 73, 50, 79, 47, 85, 11, 190, 163, 15, 78, 202, 17, + 66, 2, 72, 3, 74, 15, 210, 179, 13, 78, 182, 117, 76, 166, 111, 84, 174, + 28, 71, 3, 77, 11, 246, 237, 14, 68, 162, 70, 72, 2, 83, 3, 84, 11, 146, + 179, 15, 78, 86, 76, 2, 80, 3, 89, 11, 186, 179, 15, 67, 2, 68, 2, 75, 3, + 82, 10, 100, 2, 77, 85, 20, 3, 83, 85, 84, 246, 113, 73, 236, 129, 11, 2, + 79, 74, 205, 133, 3, 3, 84, 79, 89, 2, 191, 249, 14, 72, 2, 131, 177, 15, + 85, 4, 192, 200, 11, 5, 76, 32, 80, 79, 76, 187, 15, 82, 133, 1, 41, 8, + 73, 78, 65, 71, 65, 82, 73, 32, 130, 1, 140, 1, 7, 76, 69, 84, 84, 69, + 82, 32, 248, 1, 5, 83, 73, 71, 78, 32, 52, 11, 86, 79, 87, 69, 76, 32, + 83, 73, 71, 78, 32, 179, 230, 4, 72, 94, 210, 1, 86, 210, 203, 11, 65, + 38, 68, 82, 82, 34, 84, 230, 5, 85, 138, 204, 1, 73, 42, 76, 130, 199, 1, + 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 138, 69, 72, 2, + 77, 2, 89, 186, 2, 69, 3, 79, 6, 170, 152, 5, 79, 139, 150, 10, 65, 10, + 150, 253, 9, 83, 198, 209, 1, 65, 171, 156, 3, 86, 24, 162, 237, 4, 80, + 166, 42, 86, 134, 186, 6, 65, 38, 85, 138, 204, 1, 73, 230, 143, 2, 69, + 3, 79, 4, 178, 48, 68, 159, 187, 14, 80, 4, 206, 172, 15, 83, 15, 72, + 128, 5, 128, 2, 3, 71, 65, 84, 192, 7, 6, 73, 84, 72, 69, 82, 32, 194, 3, + 83, 136, 1, 2, 85, 84, 242, 1, 87, 148, 16, 3, 88, 84, 32, 204, 192, 8, + 4, 80, 84, 85, 78, 216, 139, 1, 6, 84, 32, 87, 73, 84, 72, 244, 133, 2, + 2, 67, 75, 174, 167, 2, 82, 235, 146, 1, 76, 162, 1, 152, 1, 4, 73, 86, + 69, 32, 229, 251, 12, 27, 69, 68, 32, 68, 79, 85, 66, 76, 69, 32, 86, 69, + 82, 84, 73, 67, 65, 76, 32, 66, 65, 82, 32, 68, 79, 85, 66, 160, 1, 152, + 1, 8, 67, 73, 82, 67, 76, 69, 68, 32, 224, 1, 9, 68, 73, 65, 71, 79, 78, + 65, 76, 32, 184, 1, 8, 83, 81, 85, 65, 82, 69, 68, 32, 167, 213, 8, 65, + 78, 112, 5, 68, 73, 71, 73, 84, 28, 7, 78, 85, 77, 66, 69, 82, 32, 180, + 3, 2, 76, 65, 130, 252, 13, 84, 151, 4, 83, 2, 221, 177, 13, 2, 32, 90, + 20, 50, 84, 238, 129, 2, 69, 46, 70, 42, 78, 31, 83, 6, 174, 131, 2, 72, + 47, 87, 6, 38, 77, 194, 223, 13, 67, 183, 4, 68, 2, 49, 10, 73, 68, 68, + 76, 69, 32, 82, 73, 71, 72, 2, 17, 2, 84, 32, 2, 41, 8, 84, 79, 32, 76, + 79, 87, 69, 82, 2, 213, 155, 12, 2, 32, 67, 74, 142, 1, 76, 70, 85, 166, + 173, 12, 68, 138, 29, 81, 248, 131, 1, 2, 67, 82, 238, 19, 65, 174, 22, + 73, 2, 87, 150, 8, 82, 134, 160, 1, 80, 3, 83, 54, 26, 65, 179, 248, 10, + 69, 52, 201, 251, 8, 5, 84, 73, 78, 32, 67, 2, 243, 128, 14, 80, 18, 158, + 1, 65, 216, 1, 17, 71, 82, 69, 65, 84, 69, 82, 45, 84, 72, 65, 78, 32, + 78, 79, 82, 32, 37, 14, 76, 69, 83, 83, 45, 84, 72, 65, 78, 32, 78, 79, + 82, 32, 6, 92, 3, 32, 83, 85, 85, 16, 80, 80, 82, 79, 88, 73, 77, 65, 84, + 69, 76, 89, 32, 78, 79, 82, 4, 30, 66, 1, 3, 80, 69, 82, 2, 253, 249, 6, + 8, 83, 69, 84, 32, 79, 70, 32, 78, 2, 213, 48, 5, 32, 65, 67, 84, 85, 6, + 202, 151, 8, 69, 199, 239, 4, 76, 6, 166, 151, 8, 69, 163, 239, 4, 71, 6, + 26, 84, 163, 147, 13, 83, 4, 76, 5, 73, 78, 71, 32, 68, 253, 221, 10, 8, + 32, 87, 73, 84, 72, 32, 69, 71, 2, 241, 130, 8, 2, 79, 76, 64, 40, 4, 82, + 65, 76, 32, 171, 229, 14, 69, 62, 48, 6, 67, 72, 69, 83, 83, 32, 203, + 224, 14, 70, 60, 74, 75, 182, 186, 13, 66, 38, 69, 150, 5, 80, 22, 81, + 38, 82, 131, 2, 84, 20, 44, 5, 78, 73, 71, 72, 84, 219, 187, 13, 73, 15, + 135, 188, 13, 32, 246, 2, 70, 32, 184, 8, 2, 65, 32, 252, 6, 3, 76, 73, + 78, 211, 221, 3, 83, 174, 1, 90, 77, 64, 4, 83, 72, 69, 81, 20, 8, 84, + 65, 73, 32, 76, 85, 69, 32, 135, 255, 13, 76, 4, 25, 4, 79, 79, 78, 32, + 4, 214, 149, 8, 87, 247, 239, 5, 83, 2, 203, 200, 9, 69, 166, 1, 160, 1, 7, 76, 69, 84, 84, 69, 82, 32, 244, 2, 8, 83, 73, 71, 78, 32, 76, 65, 69, - 22, 84, 76, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 155, 150, 13, + 22, 84, 76, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 167, 158, 13, 68, 102, 76, 6, 70, 73, 78, 65, 76, 32, 68, 4, 72, 73, 71, 72, 1, 3, 76, - 79, 87, 14, 162, 143, 13, 78, 130, 254, 1, 66, 2, 68, 2, 75, 2, 77, 3, - 86, 44, 11, 32, 44, 146, 1, 75, 2, 88, 34, 83, 158, 149, 11, 78, 246, - 173, 3, 84, 82, 80, 138, 69, 66, 2, 68, 2, 70, 2, 72, 2, 76, 2, 77, 2, - 81, 2, 86, 3, 89, 4, 134, 137, 15, 86, 187, 2, 65, 4, 230, 136, 15, 85, - 187, 2, 65, 5, 255, 138, 15, 86, 6, 220, 155, 7, 3, 79, 78, 69, 221, 80, + 79, 87, 14, 174, 151, 13, 78, 154, 129, 2, 66, 2, 68, 2, 75, 2, 77, 3, + 86, 44, 11, 32, 44, 146, 1, 75, 2, 88, 34, 83, 138, 155, 11, 78, 174, + 179, 3, 84, 82, 80, 138, 69, 66, 2, 68, 2, 70, 2, 72, 2, 76, 2, 77, 2, + 81, 2, 86, 3, 89, 4, 170, 148, 15, 86, 187, 2, 65, 4, 138, 148, 15, 85, + 187, 2, 65, 5, 163, 150, 15, 86, 6, 184, 159, 7, 3, 79, 78, 69, 237, 82, 8, 72, 65, 77, 32, 68, 73, 71, 73, 34, 110, 65, 46, 73, 30, 79, 38, 85, - 240, 186, 12, 11, 86, 79, 87, 69, 76, 32, 83, 72, 79, 82, 84, 215, 205, - 2, 69, 8, 146, 248, 10, 65, 158, 145, 4, 69, 3, 89, 4, 130, 137, 15, 73, - 3, 89, 9, 202, 247, 10, 65, 159, 145, 4, 89, 11, 166, 247, 10, 69, 158, - 145, 4, 85, 3, 89, 194, 1, 182, 1, 68, 106, 71, 72, 7, 76, 69, 84, 84, - 69, 82, 32, 214, 2, 83, 194, 23, 80, 246, 134, 1, 86, 210, 240, 7, 65, - 180, 238, 1, 5, 73, 78, 83, 69, 82, 206, 175, 1, 67, 255, 196, 2, 79, 26, - 64, 6, 79, 85, 66, 76, 69, 32, 162, 166, 11, 65, 255, 235, 1, 73, 4, 146, - 166, 11, 68, 179, 138, 1, 67, 2, 11, 65, 2, 11, 80, 2, 17, 2, 32, 70, 2, - 241, 151, 11, 2, 73, 76, 108, 218, 1, 78, 62, 86, 162, 165, 11, 65, 38, - 68, 114, 84, 230, 5, 85, 186, 202, 1, 73, 182, 196, 1, 83, 82, 66, 2, 67, + 152, 194, 12, 11, 86, 79, 87, 69, 76, 32, 83, 72, 79, 82, 84, 211, 209, + 2, 69, 8, 190, 253, 10, 65, 150, 151, 4, 69, 3, 89, 4, 166, 148, 15, 73, + 3, 89, 9, 246, 252, 10, 65, 151, 151, 4, 89, 11, 210, 252, 10, 69, 150, + 151, 4, 85, 3, 89, 194, 1, 182, 1, 68, 106, 71, 72, 7, 76, 69, 84, 84, + 69, 82, 32, 214, 2, 83, 174, 23, 80, 246, 135, 1, 86, 170, 245, 7, 65, + 200, 238, 1, 5, 73, 78, 83, 69, 82, 158, 177, 1, 67, 251, 200, 2, 79, 26, + 64, 6, 79, 85, 66, 76, 69, 32, 214, 172, 11, 65, 215, 237, 1, 73, 4, 198, + 172, 11, 68, 167, 139, 1, 67, 2, 11, 65, 2, 11, 80, 2, 17, 2, 32, 70, 2, + 165, 158, 11, 2, 73, 76, 108, 218, 1, 78, 62, 86, 214, 171, 11, 65, 38, + 68, 114, 84, 230, 5, 85, 138, 204, 1, 73, 214, 199, 1, 83, 82, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 76, 2, 77, 2, 80, 2, 82, 138, 69, 72, 2, 87, 2, - 89, 186, 2, 69, 3, 79, 14, 142, 188, 14, 71, 2, 89, 138, 69, 72, 2, 78, - 187, 2, 65, 10, 26, 69, 159, 172, 11, 79, 2, 209, 201, 12, 3, 68, 73, 67, - 22, 26, 73, 183, 197, 4, 65, 20, 44, 3, 71, 78, 32, 149, 170, 9, 2, 68, - 68, 18, 170, 228, 10, 67, 98, 78, 190, 66, 65, 190, 158, 1, 74, 228, 2, - 5, 70, 73, 78, 65, 76, 50, 85, 235, 245, 1, 86, 4, 143, 214, 14, 69, 4, - 230, 241, 9, 80, 231, 243, 3, 76, 6, 70, 78, 157, 233, 13, 11, 71, 72, - 84, 32, 87, 73, 84, 72, 32, 83, 84, 4, 176, 242, 7, 7, 69, 32, 80, 79, - 73, 78, 84, 179, 139, 7, 74, 124, 152, 1, 3, 67, 79, 77, 130, 3, 68, 78, - 76, 156, 4, 4, 72, 73, 71, 72, 72, 7, 83, 89, 77, 66, 79, 76, 32, 186, - 218, 7, 69, 229, 193, 1, 3, 84, 65, 77, 20, 52, 7, 66, 73, 78, 73, 78, - 71, 32, 211, 251, 14, 77, 18, 88, 3, 68, 79, 85, 32, 5, 76, 79, 78, 71, - 32, 78, 78, 33, 6, 83, 72, 79, 82, 84, 32, 2, 201, 252, 13, 3, 66, 76, - 69, 8, 142, 1, 72, 34, 76, 250, 133, 11, 82, 21, 7, 68, 69, 83, 67, 69, - 78, 68, 2, 11, 65, 2, 239, 211, 10, 83, 6, 34, 72, 34, 76, 251, 133, 11, - 82, 2, 193, 134, 11, 3, 73, 71, 72, 2, 161, 134, 11, 2, 79, 87, 24, 152, - 1, 4, 65, 78, 84, 65, 156, 218, 12, 4, 79, 82, 79, 77, 143, 44, 73, 70, - 76, 4, 65, 74, 65, 78, 32, 6, 69, 84, 84, 69, 82, 32, 173, 3, 2, 79, 87, - 2, 133, 174, 13, 3, 89, 65, 76, 66, 228, 1, 2, 68, 65, 42, 74, 90, 78, - 158, 154, 11, 82, 210, 147, 1, 79, 138, 76, 67, 138, 189, 1, 69, 250, 18, - 71, 242, 42, 66, 2, 70, 2, 72, 2, 75, 2, 76, 2, 77, 2, 80, 2, 83, 2, 84, - 2, 87, 2, 89, 186, 2, 65, 2, 73, 3, 85, 5, 217, 189, 11, 5, 71, 66, 65, - 83, 73, 8, 40, 4, 79, 78, 65, 32, 203, 247, 14, 65, 6, 158, 250, 12, 67, - 242, 250, 1, 74, 3, 82, 11, 26, 65, 1, 2, 89, 65, 5, 221, 136, 8, 5, 32, - 87, 79, 76, 79, 2, 29, 5, 32, 84, 79, 78, 69, 2, 17, 2, 32, 65, 2, 147, - 207, 8, 80, 4, 68, 7, 71, 66, 65, 75, 85, 82, 85, 1, 6, 79, 79, 32, 68, - 69, 78, 2, 195, 159, 13, 78, 186, 1, 94, 32, 156, 3, 2, 77, 73, 118, 78, - 150, 1, 82, 234, 7, 84, 134, 209, 6, 83, 223, 215, 7, 45, 18, 202, 1, 66, - 96, 5, 69, 78, 84, 82, 89, 22, 80, 148, 182, 2, 15, 79, 78, 69, 32, 85, - 78, 68, 69, 82, 32, 69, 73, 71, 72, 84, 164, 134, 4, 9, 77, 79, 66, 73, - 76, 69, 32, 80, 72, 189, 30, 3, 83, 77, 79, 4, 52, 4, 82, 69, 65, 75, - 225, 132, 2, 3, 73, 67, 89, 2, 17, 2, 32, 72, 2, 251, 207, 13, 69, 5, - 175, 235, 13, 32, 4, 60, 6, 69, 68, 69, 83, 84, 82, 245, 207, 9, 3, 73, - 82, 65, 2, 161, 170, 11, 2, 73, 65, 4, 36, 5, 78, 65, 76, 32, 68, 59, 83, - 2, 133, 219, 13, 9, 73, 71, 73, 84, 32, 83, 72, 65, 80, 2, 191, 155, 11, - 77, 6, 38, 45, 145, 224, 9, 3, 70, 79, 82, 4, 76, 8, 66, 82, 69, 65, 75, - 73, 78, 71, 233, 164, 2, 5, 80, 79, 84, 65, 66, 2, 213, 222, 6, 2, 32, - 72, 97, 56, 2, 84, 72, 142, 11, 77, 237, 239, 10, 3, 68, 73, 67, 88, 42, - 32, 149, 206, 6, 4, 69, 65, 83, 84, 86, 96, 5, 69, 65, 83, 84, 32, 148, - 2, 6, 73, 78, 68, 73, 67, 32, 217, 1, 5, 87, 69, 83, 84, 32, 32, 82, 65, - 202, 243, 6, 80, 130, 1, 84, 190, 207, 4, 66, 38, 68, 18, 83, 251, 58, - 87, 14, 40, 4, 82, 82, 79, 87, 179, 239, 6, 78, 13, 11, 32, 10, 96, 9, - 67, 82, 79, 83, 83, 73, 78, 71, 32, 244, 2, 2, 65, 78, 130, 239, 6, 87, - 131, 145, 5, 70, 4, 242, 193, 3, 83, 187, 175, 3, 78, 20, 50, 80, 60, 3, - 81, 85, 65, 66, 82, 255, 127, 70, 2, 37, 7, 76, 65, 67, 69, 72, 79, 76, - 2, 179, 176, 4, 68, 4, 156, 176, 4, 2, 82, 84, 249, 248, 9, 5, 78, 84, - 73, 84, 89, 2, 17, 2, 85, 80, 2, 235, 162, 4, 69, 34, 82, 65, 222, 239, - 6, 80, 130, 1, 84, 190, 207, 4, 66, 38, 68, 18, 83, 251, 58, 87, 16, 34, - 78, 33, 4, 82, 82, 79, 87, 2, 253, 190, 3, 3, 68, 32, 83, 15, 11, 32, 12, - 84, 3, 84, 79, 32, 238, 234, 6, 67, 40, 3, 65, 78, 68, 234, 2, 87, 131, - 145, 5, 70, 4, 246, 235, 6, 67, 173, 216, 6, 4, 76, 79, 78, 71, 56, 54, - 32, 236, 5, 5, 67, 72, 69, 68, 32, 207, 2, 69, 38, 162, 1, 65, 132, 2, 4, - 78, 79, 82, 77, 78, 80, 46, 83, 170, 1, 84, 210, 222, 7, 69, 196, 33, 7, - 73, 68, 69, 78, 84, 73, 67, 190, 203, 4, 71, 38, 76, 135, 80, 67, 10, 88, - 3, 32, 83, 85, 52, 7, 78, 32, 69, 76, 69, 77, 69, 28, 2, 83, 89, 227, - 129, 8, 76, 4, 30, 66, 1, 3, 80, 69, 82, 2, 29, 2, 83, 69, 2, 11, 78, 2, - 139, 121, 84, 2, 37, 7, 77, 80, 84, 79, 84, 73, 67, 2, 17, 2, 65, 76, 2, - 161, 130, 8, 2, 76, 89, 4, 205, 196, 6, 14, 65, 76, 32, 83, 85, 66, 71, - 82, 79, 85, 80, 32, 79, 70, 2, 241, 129, 8, 6, 65, 82, 65, 76, 76, 69, 6, - 48, 6, 81, 85, 65, 82, 69, 32, 223, 219, 13, 73, 4, 68, 5, 73, 77, 65, - 71, 69, 1, 8, 79, 82, 73, 71, 73, 78, 65, 76, 2, 21, 3, 32, 79, 70, 2, - 207, 194, 6, 32, 4, 230, 209, 10, 82, 207, 242, 1, 73, 8, 58, 76, 40, 4, - 82, 73, 71, 72, 133, 1, 3, 85, 80, 80, 4, 36, 2, 69, 70, 133, 1, 2, 79, - 87, 2, 89, 20, 84, 32, 83, 69, 77, 73, 67, 73, 82, 67, 76, 69, 32, 87, - 73, 84, 72, 32, 84, 72, 2, 17, 2, 82, 69, 2, 243, 140, 13, 69, 2, 11, 69, - 2, 41, 8, 82, 32, 82, 73, 71, 72, 84, 45, 2, 133, 144, 3, 6, 83, 72, 65, - 68, 79, 87, 11, 34, 32, 53, 4, 66, 79, 79, 75, 4, 17, 2, 80, 65, 4, 198, - 199, 14, 71, 215, 22, 68, 5, 81, 18, 32, 87, 73, 84, 72, 32, 68, 69, 67, - 79, 82, 65, 84, 73, 86, 69, 32, 67, 2, 235, 137, 4, 79, 34, 102, 77, 196, - 182, 5, 8, 84, 32, 65, 78, 68, 32, 66, 79, 184, 255, 6, 3, 83, 72, 85, - 135, 170, 1, 76, 26, 36, 4, 66, 69, 82, 32, 247, 2, 69, 24, 58, 69, 50, - 70, 42, 83, 66, 84, 57, 4, 78, 73, 78, 69, 4, 204, 1, 3, 73, 71, 72, 21, - 3, 76, 69, 86, 4, 144, 1, 2, 79, 85, 13, 2, 73, 70, 6, 34, 73, 85, 4, 69, - 86, 69, 78, 4, 82, 88, 155, 138, 14, 71, 8, 40, 2, 72, 73, 46, 69, 21, 2, - 87, 69, 2, 11, 82, 2, 17, 2, 84, 69, 2, 11, 69, 2, 135, 200, 7, 78, 4, - 240, 199, 7, 3, 76, 86, 69, 1, 3, 78, 84, 89, 2, 187, 243, 6, 82, 142, 1, - 118, 76, 226, 3, 83, 164, 2, 5, 84, 79, 78, 69, 45, 196, 230, 7, 8, 67, - 73, 82, 67, 76, 69, 68, 32, 179, 247, 4, 68, 92, 88, 6, 69, 84, 84, 69, - 82, 32, 173, 163, 1, 10, 79, 71, 79, 71, 82, 65, 77, 32, 78, 89, 90, 130, - 2, 78, 90, 84, 166, 220, 7, 88, 182, 230, 2, 65, 144, 1, 2, 72, 65, 226, - 51, 82, 210, 147, 1, 79, 150, 61, 68, 2, 77, 2, 80, 254, 203, 1, 69, 234, - 61, 67, 2, 70, 2, 71, 2, 75, 2, 76, 2, 81, 2, 83, 2, 86, 2, 89, 2, 90, - 186, 2, 73, 2, 85, 3, 87, 22, 86, 84, 174, 200, 12, 80, 230, 137, 2, 67, - 2, 75, 2, 81, 2, 82, 2, 89, 187, 2, 65, 6, 142, 210, 14, 83, 2, 88, 187, - 2, 65, 14, 64, 4, 73, 71, 78, 32, 189, 1, 7, 89, 76, 76, 65, 66, 76, 69, - 12, 56, 4, 70, 79, 82, 32, 129, 213, 13, 4, 88, 87, 32, 88, 10, 204, 9, - 2, 76, 79, 230, 164, 3, 84, 156, 94, 8, 73, 78, 86, 69, 82, 84, 69, 66, - 232, 144, 4, 3, 65, 78, 73, 195, 177, 2, 80, 2, 177, 132, 12, 4, 32, 76, - 69, 78, 14, 250, 209, 14, 66, 2, 68, 2, 71, 2, 74, 2, 77, 2, 83, 3, 86, - 254, 14, 226, 2, 66, 226, 1, 67, 226, 5, 71, 244, 6, 4, 73, 76, 32, 68, - 22, 76, 198, 69, 78, 150, 5, 80, 234, 7, 82, 242, 10, 83, 188, 8, 2, 84, - 84, 154, 8, 85, 248, 1, 3, 86, 69, 82, 254, 170, 2, 89, 148, 151, 4, 14, - 70, 70, 73, 67, 69, 32, 66, 85, 73, 76, 68, 73, 78, 71, 154, 185, 1, 72, - 146, 132, 2, 75, 210, 250, 1, 68, 194, 64, 77, 246, 9, 87, 211, 139, 1, - 88, 10, 132, 1, 6, 76, 73, 81, 85, 69, 32, 252, 158, 2, 9, 83, 69, 82, - 86, 69, 82, 32, 69, 89, 189, 29, 8, 74, 69, 67, 84, 32, 82, 69, 80, 6, - 172, 203, 4, 13, 65, 78, 71, 76, 69, 32, 79, 80, 69, 78, 73, 78, 71, 171, - 241, 1, 72, 28, 56, 2, 82, 32, 234, 4, 84, 225, 198, 5, 3, 67, 85, 76, - 22, 156, 1, 11, 65, 77, 79, 85, 78, 84, 32, 79, 70, 32, 67, 22, 66, 198, - 1, 67, 118, 68, 106, 70, 0, 10, 73, 78, 86, 69, 82, 84, 69, 68, 32, 70, - 243, 241, 12, 72, 2, 203, 184, 5, 72, 6, 136, 1, 15, 82, 65, 78, 67, 72, - 32, 66, 65, 78, 75, 32, 73, 68, 69, 78, 156, 131, 5, 5, 69, 76, 84, 32, - 66, 205, 144, 6, 3, 79, 87, 32, 2, 21, 3, 84, 73, 70, 2, 11, 73, 2, 131, - 132, 11, 67, 4, 92, 17, 85, 83, 84, 79, 77, 69, 82, 32, 65, 67, 67, 79, - 85, 78, 84, 32, 78, 243, 201, 1, 72, 2, 159, 161, 6, 85, 4, 44, 5, 79, - 85, 66, 76, 69, 147, 221, 12, 65, 2, 11, 32, 2, 11, 66, 2, 157, 163, 7, - 3, 65, 67, 75, 2, 191, 134, 14, 79, 4, 160, 251, 8, 4, 65, 71, 79, 78, - 197, 195, 3, 2, 79, 80, 60, 48, 4, 72, 65, 77, 32, 185, 195, 14, 2, 79, - 78, 58, 122, 70, 0, 10, 82, 69, 86, 69, 82, 83, 69, 68, 32, 70, 36, 7, - 76, 69, 84, 84, 69, 82, 32, 149, 254, 3, 3, 83, 80, 65, 2, 161, 139, 4, - 4, 69, 65, 84, 72, 52, 196, 1, 2, 65, 73, 22, 66, 2, 80, 34, 67, 36, 2, - 69, 65, 64, 2, 70, 69, 22, 71, 22, 73, 58, 76, 2, 82, 22, 78, 46, 79, 34, - 83, 46, 85, 222, 184, 1, 77, 170, 9, 68, 189, 227, 11, 3, 84, 73, 78, 2, - 155, 179, 14, 76, 2, 11, 69, 2, 219, 190, 12, 73, 4, 226, 151, 8, 69, - 183, 161, 4, 79, 6, 138, 1, 66, 2, 68, 153, 143, 4, 6, 77, 72, 65, 78, - 67, 72, 2, 247, 175, 9, 65, 2, 183, 187, 13, 79, 4, 32, 2, 79, 68, 191, - 194, 13, 70, 2, 195, 137, 8, 72, 2, 243, 154, 12, 85, 4, 132, 172, 13, 3, - 71, 69, 65, 247, 69, 73, 4, 218, 241, 13, 78, 227, 79, 82, 4, 202, 225, - 12, 65, 229, 93, 3, 84, 82, 65, 6, 60, 5, 73, 76, 76, 69, 65, 186, 187, - 12, 65, 251, 132, 2, 82, 2, 207, 240, 13, 78, 2, 247, 148, 13, 82, 182, - 8, 38, 32, 142, 11, 68, 255, 183, 13, 73, 184, 1, 64, 6, 67, 72, 73, 75, - 73, 32, 205, 6, 5, 79, 78, 65, 76, 32, 96, 132, 1, 7, 76, 69, 84, 84, 69, - 82, 32, 148, 3, 2, 77, 85, 62, 71, 74, 80, 164, 216, 3, 2, 82, 69, 202, - 237, 8, 68, 211, 173, 1, 65, 60, 50, 65, 98, 69, 54, 73, 50, 76, 62, 79, - 51, 85, 16, 50, 65, 210, 188, 14, 78, 86, 71, 2, 76, 3, 84, 8, 162, 189, - 14, 74, 2, 75, 2, 77, 3, 87, 8, 214, 246, 13, 68, 198, 13, 82, 222, 56, - 78, 3, 80, 8, 250, 170, 14, 78, 202, 17, 72, 2, 82, 3, 83, 12, 162, 170, - 10, 65, 242, 145, 4, 69, 2, 73, 2, 79, 3, 85, 8, 170, 159, 14, 84, 174, - 28, 66, 2, 72, 3, 86, 8, 198, 235, 13, 78, 226, 79, 67, 2, 68, 3, 89, 4, - 56, 2, 45, 71, 209, 206, 12, 6, 32, 84, 84, 85, 68, 68, 2, 205, 206, 12, - 13, 65, 65, 72, 76, 65, 65, 32, 84, 84, 85, 68, 68, 65, 6, 84, 11, 85, - 78, 67, 84, 85, 65, 84, 73, 79, 78, 32, 177, 224, 6, 4, 72, 65, 65, 82, - 4, 48, 8, 68, 79, 85, 66, 76, 69, 32, 77, 3, 77, 2, 185, 242, 13, 3, 85, - 67, 65, 88, 100, 7, 76, 69, 84, 84, 69, 82, 32, 192, 2, 5, 83, 73, 71, - 78, 32, 206, 193, 8, 65, 207, 255, 3, 68, 60, 42, 65, 54, 69, 58, 73, 54, - 79, 59, 85, 13, 178, 183, 14, 66, 2, 68, 2, 72, 2, 76, 3, 87, 13, 158, - 231, 13, 78, 226, 79, 67, 2, 71, 2, 72, 3, 83, 13, 238, 205, 8, 84, 218, - 232, 5, 68, 2, 78, 3, 80, 13, 182, 253, 13, 82, 138, 56, 78, 86, 77, 2, - 79, 3, 89, 13, 186, 239, 13, 68, 218, 52, 78, 202, 17, 74, 2, 75, 3, 82, - 6, 58, 73, 144, 246, 12, 4, 72, 79, 68, 68, 239, 153, 1, 77, 2, 131, 182, - 1, 75, 252, 6, 34, 32, 165, 57, 3, 69, 82, 32, 246, 6, 240, 2, 8, 67, 72, - 73, 78, 69, 83, 69, 32, 44, 10, 72, 85, 78, 71, 65, 82, 73, 65, 78, 32, - 128, 7, 7, 73, 84, 65, 76, 73, 67, 32, 212, 4, 14, 78, 79, 82, 84, 72, - 32, 65, 82, 65, 66, 73, 65, 78, 32, 196, 4, 3, 80, 69, 82, 216, 13, 2, - 83, 79, 144, 13, 14, 84, 85, 82, 75, 73, 67, 32, 76, 69, 84, 84, 69, 82, - 32, 132, 7, 7, 85, 89, 71, 72, 85, 82, 32, 171, 225, 11, 75, 4, 146, 139, - 12, 73, 241, 96, 3, 72, 79, 79, 216, 1, 96, 6, 67, 65, 80, 73, 84, 65, 0, - 4, 83, 77, 65, 76, 233, 5, 7, 78, 85, 77, 66, 69, 82, 32, 102, 45, 9, 76, - 32, 76, 69, 84, 84, 69, 82, 32, 102, 214, 1, 65, 54, 69, 168, 2, 10, 78, - 73, 75, 79, 76, 83, 66, 85, 82, 71, 0, 9, 82, 85, 68, 73, 77, 69, 78, 84, - 65, 42, 79, 32, 5, 83, 72, 79, 82, 84, 22, 85, 168, 242, 3, 5, 67, 76, - 79, 83, 69, 243, 171, 8, 73, 11, 154, 240, 12, 77, 218, 119, 78, 162, 70, - 65, 3, 75, 63, 178, 1, 77, 22, 78, 78, 83, 182, 130, 10, 67, 254, 23, 71, - 2, 76, 2, 84, 198, 135, 2, 90, 218, 137, 2, 66, 2, 68, 2, 69, 2, 70, 2, - 72, 2, 74, 2, 75, 2, 80, 2, 82, 3, 86, 5, 171, 172, 14, 80, 11, 34, 84, - 246, 171, 14, 67, 3, 89, 5, 197, 149, 2, 5, 45, 83, 72, 65, 80, 5, 203, - 171, 14, 90, 4, 11, 32, 4, 214, 148, 14, 79, 3, 85, 7, 186, 148, 14, 69, - 215, 22, 79, 2, 131, 237, 13, 32, 9, 194, 167, 14, 78, 154, 3, 83, 3, 85, - 12, 210, 4, 70, 242, 131, 6, 79, 239, 203, 6, 84, 78, 80, 7, 76, 69, 84, - 84, 69, 82, 32, 169, 3, 8, 78, 85, 77, 69, 82, 65, 76, 32, 70, 190, 1, - 69, 90, 75, 50, 83, 36, 3, 78, 79, 82, 202, 207, 10, 85, 186, 202, 1, 73, - 166, 140, 1, 80, 2, 84, 150, 83, 67, 186, 22, 66, 2, 68, 2, 72, 2, 86, 2, - 89, 2, 90, 214, 22, 65, 3, 79, 23, 214, 254, 9, 83, 194, 159, 2, 82, 254, - 203, 1, 75, 222, 61, 70, 2, 76, 2, 77, 3, 78, 8, 194, 144, 14, 72, 214, - 22, 65, 2, 69, 3, 85, 4, 32, 2, 79, 85, 243, 143, 14, 72, 2, 29, 5, 84, - 72, 69, 82, 78, 2, 253, 154, 13, 2, 32, 84, 8, 38, 70, 222, 207, 12, 84, - 215, 58, 79, 4, 11, 73, 4, 242, 181, 12, 70, 143, 217, 1, 86, 64, 76, 7, - 76, 69, 84, 84, 69, 82, 32, 209, 3, 7, 78, 85, 77, 66, 69, 82, 32, 58, - 210, 1, 65, 38, 71, 38, 72, 30, 75, 38, 84, 74, 90, 234, 106, 77, 140, - 158, 3, 2, 69, 83, 238, 162, 3, 66, 2, 70, 2, 82, 2, 89, 182, 203, 3, 78, - 154, 237, 1, 76, 210, 58, 68, 146, 1, 81, 134, 3, 87, 131, 56, 83, 4, - 134, 194, 3, 76, 167, 145, 10, 73, 4, 254, 243, 12, 72, 191, 156, 1, 69, - 4, 178, 161, 14, 65, 3, 69, 4, 166, 180, 7, 72, 223, 236, 5, 65, 8, 34, - 72, 210, 160, 14, 65, 3, 69, 4, 142, 150, 13, 65, 195, 138, 1, 69, 4, 11, - 65, 4, 206, 209, 13, 73, 227, 79, 72, 6, 190, 153, 6, 84, 163, 236, 6, - 79, 180, 1, 64, 11, 77, 73, 67, 32, 76, 69, 84, 84, 69, 82, 32, 183, 5, - 83, 76, 228, 1, 2, 67, 72, 22, 68, 66, 69, 22, 73, 30, 77, 2, 78, 30, 80, - 22, 83, 70, 84, 50, 86, 38, 89, 94, 90, 254, 195, 6, 76, 2, 82, 214, 227, - 2, 71, 150, 170, 2, 79, 222, 208, 1, 66, 246, 40, 65, 254, 31, 75, 174, - 45, 72, 187, 2, 85, 2, 215, 216, 7, 69, 6, 26, 90, 183, 138, 14, 79, 4, - 134, 167, 9, 72, 187, 210, 4, 73, 5, 231, 157, 14, 70, 7, 210, 157, 14, - 65, 3, 69, 2, 213, 134, 14, 2, 69, 78, 2, 131, 198, 6, 69, 6, 26, 72, - 151, 137, 14, 73, 4, 228, 165, 9, 3, 67, 72, 79, 3, 79, 4, 26, 83, 211, - 136, 14, 65, 2, 191, 247, 13, 73, 4, 142, 165, 9, 79, 171, 190, 4, 69, - 14, 60, 2, 69, 82, 218, 178, 8, 65, 146, 215, 5, 82, 203, 17, 85, 7, 174, - 155, 14, 73, 3, 85, 4, 142, 164, 9, 72, 187, 210, 4, 65, 104, 88, 4, 73, - 65, 78, 32, 241, 5, 13, 79, 78, 65, 76, 32, 67, 79, 77, 80, 85, 84, 69, - 82, 100, 80, 7, 78, 85, 77, 66, 69, 82, 32, 80, 5, 83, 73, 71, 78, 32, - 251, 222, 10, 87, 10, 42, 84, 234, 188, 8, 72, 255, 192, 4, 79, 6, 238, - 230, 1, 87, 199, 226, 11, 69, 88, 210, 1, 65, 86, 66, 62, 68, 98, 74, 2, - 86, 30, 84, 42, 88, 182, 111, 71, 2, 75, 2, 78, 2, 82, 150, 206, 9, 77, - 146, 143, 3, 83, 218, 69, 67, 2, 70, 2, 72, 2, 76, 2, 80, 2, 89, 2, 90, - 186, 2, 73, 3, 85, 9, 45, 9, 85, 82, 65, 77, 65, 90, 68, 65, 65, 7, 170, - 239, 6, 45, 139, 165, 7, 72, 6, 38, 65, 213, 177, 10, 3, 85, 85, 77, 5, - 231, 147, 14, 71, 10, 34, 65, 234, 149, 14, 73, 3, 85, 7, 37, 7, 72, 89, - 65, 65, 85, 83, 72, 5, 255, 237, 6, 45, 4, 170, 149, 14, 65, 3, 73, 6, - 214, 146, 14, 72, 186, 2, 65, 3, 85, 4, 152, 220, 11, 8, 83, 72, 65, 65, - 89, 65, 84, 72, 207, 184, 2, 65, 5, 181, 147, 5, 31, 32, 87, 73, 84, 72, - 32, 77, 79, 78, 73, 84, 79, 82, 32, 73, 78, 32, 80, 79, 82, 84, 82, 65, - 73, 84, 32, 79, 82, 73, 69, 78, 144, 1, 92, 6, 71, 68, 73, 65, 78, 32, - 141, 7, 12, 85, 84, 72, 32, 65, 82, 65, 66, 73, 65, 78, 32, 80, 58, 70, - 74, 76, 145, 5, 7, 78, 85, 77, 66, 69, 82, 32, 2, 11, 82, 2, 201, 237, - 11, 10, 65, 67, 84, 73, 79, 78, 32, 79, 78, 69, 60, 76, 6, 69, 84, 84, - 69, 82, 32, 149, 4, 8, 73, 71, 65, 84, 85, 82, 69, 32, 58, 234, 1, 65, - 96, 6, 70, 73, 78, 65, 76, 32, 200, 1, 5, 82, 69, 83, 72, 45, 162, 216, - 1, 76, 194, 170, 4, 71, 90, 90, 34, 83, 66, 89, 198, 207, 1, 72, 234, 5, - 75, 174, 81, 66, 170, 225, 4, 78, 134, 2, 84, 2, 87, 218, 103, 80, 171, - 4, 77, 6, 26, 76, 131, 143, 13, 89, 4, 192, 133, 6, 8, 84, 69, 82, 78, - 65, 84, 69, 32, 155, 214, 1, 69, 18, 116, 3, 78, 85, 78, 0, 5, 83, 65, - 68, 72, 69, 0, 3, 84, 65, 87, 190, 216, 1, 65, 134, 211, 6, 66, 135, 203, - 5, 72, 5, 41, 8, 32, 87, 73, 84, 72, 32, 86, 69, 2, 133, 220, 5, 4, 82, - 84, 73, 67, 2, 253, 215, 1, 6, 65, 89, 73, 78, 45, 68, 18, 42, 84, 234, - 131, 6, 79, 255, 148, 6, 70, 10, 42, 72, 162, 217, 1, 87, 199, 226, 11, - 69, 4, 162, 153, 12, 82, 159, 2, 73, 64, 60, 7, 76, 69, 84, 84, 69, 82, - 32, 245, 3, 3, 78, 85, 77, 58, 202, 1, 65, 38, 68, 74, 71, 34, 75, 34, - 83, 78, 84, 254, 43, 90, 254, 166, 1, 76, 50, 81, 214, 205, 1, 82, 246, - 221, 2, 89, 198, 207, 1, 72, 150, 87, 66, 170, 225, 4, 78, 134, 2, 87, - 218, 103, 70, 171, 4, 77, 4, 146, 168, 3, 76, 167, 145, 10, 89, 6, 32, 2, - 72, 65, 151, 212, 1, 65, 4, 246, 166, 8, 76, 207, 180, 5, 68, 4, 134, 45, - 72, 203, 209, 5, 73, 4, 146, 213, 7, 65, 163, 81, 72, 8, 26, 65, 255, - 135, 13, 72, 6, 218, 198, 7, 77, 234, 147, 6, 68, 143, 45, 84, 8, 230, - 90, 72, 194, 167, 11, 69, 219, 134, 1, 65, 6, 56, 4, 66, 69, 82, 32, 145, - 205, 13, 4, 69, 82, 73, 67, 4, 26, 70, 235, 234, 12, 79, 2, 139, 149, 12, - 73, 146, 1, 80, 7, 79, 82, 75, 72, 79, 78, 32, 197, 3, 8, 89, 69, 78, 73, - 83, 69, 73, 32, 84, 54, 65, 202, 1, 69, 122, 73, 30, 79, 135, 151, 12, - 66, 45, 106, 69, 170, 243, 9, 83, 226, 144, 4, 66, 2, 68, 2, 71, 2, 76, - 2, 78, 2, 81, 2, 82, 2, 84, 3, 89, 20, 134, 132, 14, 66, 2, 68, 2, 71, 2, - 75, 2, 76, 2, 78, 2, 82, 2, 83, 2, 84, 3, 89, 20, 74, 78, 182, 230, 13, - 76, 158, 27, 83, 146, 1, 67, 2, 77, 2, 80, 3, 90, 8, 222, 130, 14, 67, 2, - 71, 2, 84, 3, 89, 7, 178, 130, 14, 67, 3, 81, 13, 130, 3, 69, 150, 255, - 13, 80, 2, 81, 3, 84, 62, 38, 65, 170, 1, 69, 86, 73, 23, 79, 39, 98, 69, - 206, 255, 13, 83, 62, 78, 86, 66, 2, 68, 2, 71, 2, 76, 2, 81, 2, 82, 2, - 84, 3, 89, 17, 218, 130, 12, 78, 130, 254, 1, 66, 2, 71, 2, 75, 2, 84, 3, - 89, 15, 46, 78, 218, 254, 13, 83, 146, 1, 67, 3, 90, 6, 230, 255, 13, 67, - 2, 84, 3, 89, 5, 195, 255, 13, 81, 6, 26, 69, 151, 255, 13, 81, 5, 147, - 255, 13, 75, 52, 148, 1, 10, 67, 79, 77, 66, 73, 78, 73, 78, 71, 32, 36, - 7, 76, 69, 84, 84, 69, 82, 32, 233, 1, 12, 80, 85, 78, 67, 84, 85, 65, - 84, 73, 79, 78, 32, 8, 222, 241, 5, 84, 243, 231, 3, 68, 36, 230, 200, 1, - 65, 186, 206, 1, 82, 222, 220, 2, 76, 58, 90, 34, 83, 66, 89, 168, 210, - 1, 6, 70, 73, 78, 65, 76, 32, 0, 6, 71, 73, 77, 69, 76, 45, 134, 3, 75, - 174, 81, 66, 170, 225, 4, 78, 134, 2, 84, 2, 87, 218, 103, 80, 171, 4, - 77, 8, 56, 4, 84, 87, 79, 32, 174, 212, 11, 70, 187, 131, 1, 66, 4, 158, - 228, 12, 66, 75, 68, 6, 146, 181, 1, 87, 136, 160, 3, 3, 65, 68, 85, 207, - 217, 7, 77, 22, 212, 1, 34, 32, 87, 73, 84, 72, 32, 69, 88, 67, 76, 65, - 77, 65, 84, 73, 79, 78, 32, 77, 65, 82, 75, 32, 87, 73, 84, 72, 32, 76, - 69, 70, 84, 32, 82, 44, 7, 67, 79, 77, 73, 78, 71, 32, 194, 1, 69, 151, - 167, 13, 73, 2, 21, 3, 73, 71, 72, 2, 203, 250, 9, 84, 10, 148, 1, 6, 65, - 85, 84, 79, 77, 79, 20, 7, 70, 73, 82, 69, 32, 69, 78, 144, 225, 2, 2, - 84, 65, 148, 247, 8, 6, 80, 79, 76, 73, 67, 69, 143, 22, 66, 2, 223, 206, - 11, 66, 2, 215, 219, 12, 71, 8, 70, 32, 229, 191, 12, 11, 45, 80, 73, 69, - 67, 69, 32, 83, 87, 73, 77, 6, 40, 4, 68, 79, 84, 32, 175, 173, 10, 66, - 4, 26, 79, 135, 175, 10, 76, 2, 129, 234, 2, 11, 86, 69, 82, 32, 84, 87, - 79, 32, 68, 79, 84, 46, 82, 69, 188, 6, 2, 84, 73, 188, 229, 11, 5, 72, - 73, 85, 67, 72, 147, 183, 1, 80, 36, 70, 78, 201, 5, 12, 82, 65, 84, 73, - 78, 71, 32, 83, 89, 83, 84, 69, 34, 22, 32, 139, 4, 45, 28, 108, 2, 66, - 79, 32, 7, 67, 69, 78, 84, 82, 69, 32, 114, 70, 70, 72, 42, 77, 142, 139, - 7, 83, 135, 244, 3, 76, 4, 242, 239, 13, 79, 155, 3, 88, 8, 50, 84, 174, - 216, 11, 66, 222, 2, 65, 135, 84, 67, 2, 37, 7, 69, 65, 82, 68, 82, 79, - 80, 2, 143, 218, 11, 45, 4, 44, 5, 73, 76, 69, 32, 70, 243, 131, 2, 79, - 2, 239, 131, 2, 79, 2, 17, 2, 65, 78, 2, 151, 191, 10, 68, 4, 57, 12, 65, - 73, 76, 66, 79, 88, 32, 87, 73, 84, 72, 32, 4, 44, 3, 76, 79, 87, 21, 4, - 82, 65, 73, 83, 2, 17, 2, 69, 82, 2, 129, 132, 12, 2, 69, 68, 6, 108, 15, - 67, 73, 82, 67, 85, 73, 84, 45, 79, 85, 84, 80, 85, 84, 32, 221, 204, 12, - 6, 79, 85, 84, 76, 73, 78, 4, 18, 72, 3, 76, 2, 161, 192, 1, 4, 45, 84, - 89, 80, 2, 169, 222, 12, 6, 77, 32, 67, 79, 77, 77, 6, 64, 2, 79, 78, - 253, 177, 1, 8, 67, 65, 76, 32, 68, 73, 83, 67, 2, 247, 207, 11, 32, 208, - 1, 104, 3, 65, 78, 71, 66, 67, 34, 73, 212, 8, 5, 78, 65, 84, 69, 32, 32, - 3, 84, 72, 79, 199, 176, 5, 32, 6, 28, 2, 69, 32, 167, 22, 85, 4, 198, - 150, 12, 66, 203, 78, 72, 4, 186, 174, 13, 85, 223, 61, 65, 188, 1, 48, - 5, 71, 73, 78, 65, 76, 21, 3, 89, 65, 32, 2, 183, 133, 1, 32, 186, 1, - 106, 65, 30, 70, 250, 1, 73, 32, 7, 76, 69, 84, 84, 69, 82, 32, 142, 2, - 83, 218, 1, 86, 159, 240, 11, 68, 4, 182, 137, 10, 73, 3, 85, 12, 41, 8, - 82, 65, 67, 84, 73, 79, 78, 32, 12, 56, 4, 79, 78, 69, 32, 81, 6, 84, 72, - 82, 69, 69, 32, 8, 42, 83, 206, 226, 11, 69, 46, 72, 47, 81, 2, 217, 227, - 11, 4, 73, 88, 84, 69, 4, 26, 83, 227, 228, 11, 81, 2, 145, 136, 8, 4, - 73, 88, 84, 69, 2, 233, 196, 12, 3, 83, 83, 72, 104, 226, 1, 82, 130, - 238, 6, 89, 178, 154, 3, 65, 38, 68, 114, 84, 46, 86, 186, 5, 85, 186, - 202, 1, 73, 42, 76, 226, 195, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 74, - 2, 75, 2, 80, 138, 69, 72, 2, 77, 2, 87, 186, 2, 69, 3, 79, 6, 234, 227, - 13, 72, 2, 82, 187, 2, 65, 18, 112, 20, 69, 81, 85, 69, 78, 67, 69, 32, - 70, 79, 82, 32, 76, 69, 84, 84, 69, 82, 32, 82, 29, 4, 73, 71, 78, 32, 4, - 206, 226, 13, 72, 3, 82, 14, 138, 199, 9, 67, 98, 78, 190, 66, 65, 250, - 239, 1, 79, 195, 167, 1, 86, 26, 49, 10, 79, 87, 69, 76, 32, 83, 73, 71, - 78, 32, 26, 206, 140, 10, 65, 38, 85, 22, 86, 166, 202, 1, 73, 198, 140, - 2, 69, 3, 79, 4, 194, 220, 6, 76, 243, 30, 82, 4, 240, 245, 3, 2, 68, 79, - 139, 183, 2, 71, 226, 1, 76, 4, 65, 71, 69, 32, 140, 4, 6, 77, 65, 78, - 89, 65, 32, 251, 221, 13, 67, 144, 1, 56, 6, 67, 65, 80, 73, 84, 65, 1, - 4, 83, 77, 65, 76, 72, 45, 9, 76, 32, 76, 69, 84, 84, 69, 82, 32, 72, - 194, 1, 65, 38, 69, 90, 75, 42, 79, 22, 84, 246, 229, 6, 72, 254, 250, 4, - 67, 2, 68, 2, 71, 234, 181, 1, 83, 2, 90, 130, 3, 66, 138, 66, 76, 2, 77, - 2, 78, 2, 80, 2, 87, 186, 2, 73, 3, 85, 9, 226, 225, 11, 73, 239, 253, 1, - 72, 15, 26, 72, 179, 143, 13, 73, 10, 134, 202, 9, 84, 226, 151, 2, 67, - 242, 250, 1, 75, 3, 80, 6, 154, 220, 13, 72, 2, 89, 187, 2, 65, 5, 203, - 142, 13, 73, 6, 214, 150, 13, 83, 195, 71, 65, 80, 52, 7, 76, 69, 84, 84, - 69, 82, 32, 187, 233, 11, 68, 60, 246, 1, 65, 38, 67, 22, 68, 38, 75, 34, - 83, 30, 77, 162, 241, 2, 81, 226, 159, 8, 79, 148, 125, 2, 76, 65, 236, - 75, 2, 78, 85, 134, 2, 87, 142, 62, 69, 234, 61, 66, 2, 70, 2, 71, 2, 72, - 2, 74, 2, 82, 2, 84, 2, 88, 2, 89, 186, 2, 73, 3, 85, 7, 194, 250, 2, 76, - 135, 225, 10, 65, 2, 183, 221, 12, 65, 4, 222, 197, 8, 69, 251, 146, 5, - 72, 4, 186, 217, 12, 65, 251, 126, 72, 4, 26, 72, 179, 218, 13, 65, 2, - 219, 218, 12, 73, 124, 68, 11, 79, 77, 65, 78, 32, 83, 73, 89, 65, 81, - 32, 251, 160, 13, 69, 122, 172, 1, 17, 65, 76, 84, 69, 82, 78, 65, 84, - 69, 32, 78, 85, 77, 66, 69, 82, 32, 200, 1, 13, 70, 82, 65, 67, 84, 73, - 79, 78, 32, 79, 78, 69, 32, 48, 3, 77, 65, 82, 47, 78, 26, 54, 70, 50, - 83, 46, 84, 214, 187, 12, 78, 239, 112, 69, 6, 248, 207, 5, 3, 79, 85, - 82, 159, 139, 7, 73, 6, 200, 207, 5, 2, 73, 88, 155, 149, 6, 69, 10, 226, - 184, 2, 69, 12, 2, 87, 79, 247, 171, 9, 72, 4, 26, 83, 175, 208, 11, 72, - 2, 155, 209, 11, 73, 2, 11, 82, 2, 11, 65, 2, 247, 137, 12, 84, 90, 33, - 6, 85, 77, 66, 69, 82, 32, 90, 58, 69, 66, 70, 94, 78, 26, 83, 78, 84, - 179, 177, 5, 79, 10, 25, 4, 73, 71, 72, 84, 11, 226, 182, 2, 89, 227, - 193, 5, 32, 20, 18, 73, 35, 79, 10, 166, 2, 70, 195, 176, 5, 86, 10, 134, - 2, 82, 205, 176, 5, 2, 85, 82, 10, 65, 3, 73, 78, 69, 20, 40, 4, 69, 86, - 69, 78, 1, 2, 73, 88, 11, 166, 1, 84, 219, 245, 7, 32, 24, 34, 72, 50, - 87, 163, 180, 2, 69, 10, 34, 73, 245, 176, 5, 2, 82, 69, 4, 51, 82, 10, - 26, 69, 219, 176, 5, 79, 4, 11, 78, 4, 11, 84, 4, 247, 179, 2, 89, 84, - 34, 84, 217, 177, 11, 2, 78, 67, 82, 42, 66, 37, 6, 76, 73, 78, 69, 68, - 32, 2, 133, 195, 12, 4, 79, 88, 32, 84, 80, 92, 7, 76, 65, 84, 73, 78, - 32, 67, 242, 194, 6, 87, 182, 243, 4, 66, 234, 14, 71, 159, 23, 68, 54, - 186, 174, 7, 65, 215, 222, 4, 82, 12, 18, 72, 43, 76, 2, 17, 2, 69, 65, - 2, 239, 188, 12, 84, 10, 32, 2, 65, 80, 255, 179, 12, 73, 9, 29, 5, 80, - 73, 78, 71, 32, 6, 40, 6, 87, 72, 73, 84, 69, 32, 51, 66, 4, 44, 5, 65, - 78, 68, 32, 66, 151, 138, 10, 83, 2, 253, 137, 10, 4, 76, 65, 67, 75, - 152, 13, 150, 1, 65, 206, 65, 68, 30, 69, 134, 13, 72, 138, 25, 73, 202, - 4, 76, 160, 15, 2, 78, 80, 54, 79, 238, 8, 82, 210, 15, 83, 186, 6, 85, - 239, 177, 12, 77, 158, 6, 134, 2, 68, 38, 71, 212, 1, 11, 72, 65, 87, 72, - 32, 72, 77, 79, 78, 71, 32, 134, 23, 76, 130, 6, 78, 58, 82, 196, 22, 2, - 83, 83, 132, 2, 10, 85, 32, 67, 73, 78, 32, 72, 65, 85, 32, 176, 7, 3, - 87, 32, 80, 152, 252, 7, 2, 67, 75, 233, 141, 5, 4, 80, 69, 82, 67, 5, - 253, 185, 1, 4, 68, 73, 78, 71, 14, 26, 69, 163, 165, 13, 79, 13, 34, 32, - 130, 202, 13, 82, 3, 83, 6, 72, 6, 87, 73, 84, 72, 32, 67, 181, 159, 4, - 6, 70, 65, 67, 73, 78, 71, 4, 50, 85, 145, 237, 7, 6, 73, 82, 67, 76, 69, - 68, 2, 175, 189, 12, 82, 254, 1, 190, 1, 67, 160, 6, 9, 77, 65, 82, 75, - 32, 67, 73, 77, 32, 160, 1, 7, 78, 85, 77, 66, 69, 82, 32, 244, 1, 5, 83, - 73, 71, 78, 32, 144, 10, 7, 86, 79, 87, 69, 76, 32, 75, 223, 191, 11, 68, - 78, 92, 9, 76, 65, 78, 32, 83, 73, 71, 78, 32, 137, 3, 9, 79, 78, 83, 79, - 78, 65, 78, 84, 32, 38, 132, 1, 2, 72, 65, 38, 75, 46, 76, 34, 84, 82, - 86, 30, 89, 148, 9, 2, 88, 89, 172, 5, 2, 80, 72, 174, 1, 70, 165, 2, 2, - 77, 85, 4, 170, 198, 2, 87, 151, 255, 10, 77, 6, 246, 15, 72, 178, 150, - 13, 79, 159, 14, 87, 4, 210, 12, 65, 195, 250, 12, 73, 8, 22, 83, 247, 9, - 72, 6, 160, 197, 2, 3, 72, 69, 69, 158, 193, 9, 65, 3, 87, 4, 234, 196, - 2, 65, 3, 87, 4, 206, 196, 2, 65, 175, 185, 10, 69, 40, 122, 67, 38, 72, - 46, 78, 60, 2, 80, 76, 2, 81, 222, 222, 2, 76, 2, 77, 2, 82, 2, 86, 2, - 88, 2, 89, 247, 189, 10, 65, 4, 230, 223, 2, 72, 247, 189, 10, 65, 6, - 194, 223, 2, 76, 2, 78, 247, 189, 10, 65, 12, 58, 67, 22, 84, 202, 222, - 2, 75, 2, 76, 247, 189, 10, 65, 2, 219, 222, 2, 72, 4, 198, 222, 2, 72, - 3, 83, 14, 42, 75, 50, 83, 38, 84, 167, 175, 13, 72, 4, 26, 72, 231, 130, - 13, 69, 2, 175, 162, 6, 65, 4, 154, 131, 12, 85, 147, 189, 1, 79, 4, 142, - 130, 12, 85, 215, 18, 65, 14, 52, 7, 72, 85, 78, 68, 82, 69, 68, 38, 84, - 79, 77, 4, 108, 2, 32, 77, 195, 190, 13, 83, 8, 24, 2, 69, 78, 51, 82, 6, - 26, 32, 215, 190, 13, 83, 4, 18, 66, 35, 84, 2, 253, 213, 4, 3, 73, 76, - 76, 2, 11, 72, 2, 213, 251, 9, 3, 79, 85, 83, 72, 188, 1, 4, 67, 73, 77, - 32, 246, 2, 72, 32, 3, 73, 66, 32, 22, 77, 86, 78, 50, 84, 124, 4, 86, - 79, 83, 32, 198, 1, 88, 208, 1, 6, 90, 87, 74, 32, 84, 72, 142, 178, 1, - 76, 223, 227, 4, 65, 16, 174, 1, 67, 84, 5, 78, 82, 69, 83, 32, 22, 84, - 164, 252, 11, 7, 80, 85, 66, 32, 68, 65, 87, 153, 189, 1, 16, 72, 65, 73, - 83, 32, 76, 85, 83, 32, 78, 84, 79, 71, 32, 78, 84, 4, 48, 7, 85, 65, 77, - 32, 84, 83, 72, 255, 3, 72, 2, 11, 79, 2, 175, 187, 2, 79, 2, 195, 184, - 1, 84, 6, 52, 3, 88, 87, 86, 161, 151, 10, 4, 83, 79, 86, 32, 5, 209, - 155, 6, 4, 32, 67, 72, 87, 4, 190, 72, 78, 171, 221, 12, 76, 2, 143, 252, - 11, 89, 6, 40, 4, 69, 69, 74, 32, 135, 251, 12, 85, 4, 128, 3, 2, 84, 83, - 57, 2, 83, 85, 4, 26, 84, 187, 252, 8, 81, 2, 135, 185, 2, 85, 6, 196, 1, - 7, 88, 72, 69, 69, 74, 32, 67, 224, 178, 8, 12, 72, 73, 82, 68, 45, 83, - 84, 65, 71, 69, 32, 72, 251, 222, 4, 65, 14, 54, 70, 22, 83, 30, 84, 166, - 69, 76, 195, 251, 7, 78, 2, 167, 164, 13, 69, 2, 173, 152, 6, 2, 69, 69, - 6, 42, 72, 29, 6, 83, 72, 65, 66, 32, 67, 4, 82, 73, 207, 164, 13, 79, 2, - 175, 209, 5, 69, 14, 34, 73, 22, 89, 175, 172, 11, 65, 2, 171, 247, 11, - 65, 10, 40, 4, 69, 69, 77, 32, 243, 149, 13, 79, 8, 84, 3, 78, 84, 88, - 252, 149, 6, 2, 84, 79, 154, 173, 2, 82, 245, 178, 3, 2, 70, 65, 2, 251, - 149, 6, 73, 2, 227, 180, 2, 65, 56, 50, 65, 66, 69, 38, 73, 2, 85, 38, - 79, 39, 87, 20, 170, 1, 65, 2, 73, 2, 85, 2, 87, 134, 178, 13, 66, 3, 86, - 8, 106, 69, 134, 178, 13, 66, 3, 86, 8, 70, 65, 134, 178, 13, 66, 3, 86, - 8, 34, 79, 134, 178, 13, 66, 3, 86, 4, 130, 178, 13, 66, 3, 86, 76, 18, - 76, 23, 77, 2, 247, 243, 12, 65, 74, 74, 32, 104, 6, 89, 82, 69, 78, 69, - 32, 141, 142, 4, 4, 83, 32, 85, 80, 8, 80, 3, 66, 82, 65, 246, 189, 11, - 84, 248, 97, 4, 68, 79, 87, 78, 1, 2, 85, 80, 2, 247, 141, 13, 78, 64, + 89, 186, 2, 69, 3, 79, 14, 178, 199, 14, 71, 2, 89, 138, 69, 72, 2, 78, + 187, 2, 65, 10, 26, 69, 211, 178, 11, 79, 2, 249, 208, 12, 3, 68, 73, 67, + 22, 26, 73, 147, 201, 4, 65, 20, 44, 3, 71, 78, 32, 217, 175, 9, 2, 68, + 68, 18, 214, 233, 10, 67, 98, 78, 198, 67, 65, 178, 159, 1, 74, 228, 2, + 5, 70, 73, 78, 65, 76, 50, 85, 231, 249, 1, 86, 4, 179, 225, 14, 69, 4, + 154, 247, 9, 80, 215, 249, 3, 76, 6, 70, 78, 193, 244, 13, 11, 71, 72, + 84, 32, 87, 73, 84, 72, 32, 83, 84, 4, 148, 248, 7, 7, 69, 32, 80, 79, + 73, 78, 84, 243, 144, 7, 74, 124, 152, 1, 3, 67, 79, 77, 234, 2, 68, 78, + 76, 156, 4, 4, 72, 73, 71, 72, 72, 7, 83, 89, 77, 66, 79, 76, 32, 248, + 161, 9, 3, 84, 65, 77, 155, 195, 4, 69, 20, 52, 7, 66, 73, 78, 73, 78, + 71, 32, 247, 134, 15, 77, 18, 96, 5, 76, 79, 78, 71, 32, 78, 78, 32, 6, + 83, 72, 79, 82, 84, 32, 225, 152, 1, 3, 68, 79, 85, 8, 142, 1, 72, 34, + 76, 254, 139, 11, 82, 21, 7, 68, 69, 83, 67, 69, 78, 68, 2, 11, 65, 2, + 191, 217, 10, 83, 6, 34, 72, 34, 76, 255, 139, 11, 82, 2, 197, 140, 11, + 3, 73, 71, 72, 2, 165, 140, 11, 2, 79, 87, 24, 152, 1, 4, 65, 78, 84, 65, + 184, 226, 12, 4, 79, 82, 79, 77, 151, 44, 73, 70, 76, 4, 65, 74, 65, 78, + 32, 6, 69, 84, 84, 69, 82, 32, 173, 3, 2, 79, 87, 2, 201, 182, 13, 3, 89, + 65, 76, 66, 228, 1, 2, 68, 65, 42, 74, 90, 78, 234, 160, 11, 82, 198, + 148, 1, 79, 238, 76, 67, 162, 192, 1, 69, 250, 18, 71, 242, 42, 66, 2, + 70, 2, 72, 2, 75, 2, 76, 2, 77, 2, 80, 2, 83, 2, 84, 2, 87, 2, 89, 186, + 2, 65, 2, 73, 3, 85, 5, 141, 197, 11, 5, 71, 66, 65, 83, 73, 8, 40, 4, + 79, 78, 65, 32, 135, 131, 15, 65, 6, 194, 130, 13, 67, 138, 254, 1, 74, + 3, 82, 11, 26, 65, 1, 2, 89, 65, 5, 217, 142, 8, 5, 32, 87, 79, 76, 79, + 2, 29, 5, 32, 84, 79, 78, 69, 2, 17, 2, 32, 65, 2, 131, 213, 8, 80, 4, + 68, 7, 71, 66, 65, 75, 85, 82, 85, 1, 6, 79, 79, 32, 68, 69, 78, 2, 239, + 167, 13, 78, 186, 1, 94, 32, 156, 3, 2, 77, 73, 118, 78, 150, 1, 82, 238, + 7, 84, 246, 212, 6, 83, 167, 223, 7, 45, 18, 202, 1, 66, 96, 5, 69, 78, + 84, 82, 89, 22, 80, 184, 183, 2, 15, 79, 78, 69, 32, 85, 78, 68, 69, 82, + 32, 69, 73, 71, 72, 84, 240, 136, 4, 9, 77, 79, 66, 73, 76, 69, 32, 80, + 72, 193, 30, 3, 83, 77, 79, 4, 52, 4, 82, 69, 65, 75, 245, 133, 2, 3, 73, + 67, 89, 2, 17, 2, 32, 72, 2, 247, 218, 13, 69, 5, 235, 246, 13, 32, 4, + 60, 6, 69, 68, 69, 83, 84, 82, 201, 213, 9, 3, 73, 82, 65, 2, 229, 176, + 11, 2, 73, 65, 4, 36, 5, 78, 65, 76, 32, 68, 59, 83, 2, 193, 230, 13, 9, + 73, 71, 73, 84, 32, 83, 72, 65, 80, 2, 139, 162, 11, 77, 6, 38, 45, 221, + 229, 9, 3, 70, 79, 82, 4, 76, 8, 66, 82, 69, 65, 75, 73, 78, 71, 141, + 166, 2, 5, 80, 79, 84, 65, 66, 2, 201, 226, 6, 2, 32, 72, 97, 56, 2, 84, + 72, 146, 11, 77, 237, 245, 10, 3, 68, 73, 67, 88, 42, 32, 129, 210, 6, 4, + 69, 65, 83, 84, 86, 96, 5, 69, 65, 83, 84, 32, 148, 2, 6, 73, 78, 68, 73, + 67, 32, 221, 1, 5, 87, 69, 83, 84, 32, 32, 82, 65, 190, 247, 6, 80, 130, + 1, 84, 254, 210, 4, 66, 38, 68, 18, 83, 135, 59, 87, 14, 40, 4, 82, 82, + 79, 87, 167, 243, 6, 78, 13, 11, 32, 10, 96, 9, 67, 82, 79, 83, 83, 73, + 78, 71, 32, 248, 2, 2, 65, 78, 242, 242, 6, 87, 207, 148, 5, 70, 4, 146, + 196, 3, 83, 143, 177, 3, 78, 20, 54, 80, 60, 3, 81, 85, 65, 66, 82, 175, + 128, 1, 70, 2, 37, 7, 76, 65, 67, 69, 72, 79, 76, 2, 163, 180, 4, 68, 4, + 140, 180, 4, 2, 82, 84, 193, 128, 10, 5, 78, 84, 73, 84, 89, 2, 17, 2, + 85, 80, 2, 219, 166, 4, 69, 34, 82, 65, 206, 243, 6, 80, 130, 1, 84, 254, + 210, 4, 66, 38, 68, 18, 83, 135, 59, 87, 16, 34, 78, 33, 4, 82, 82, 79, + 87, 2, 153, 193, 3, 3, 68, 32, 83, 15, 11, 32, 12, 84, 3, 84, 79, 32, + 222, 238, 6, 67, 40, 3, 65, 78, 68, 234, 2, 87, 207, 148, 5, 70, 4, 230, + 239, 6, 67, 181, 223, 6, 4, 76, 79, 78, 71, 56, 54, 32, 236, 5, 5, 67, + 72, 69, 68, 32, 207, 2, 69, 38, 162, 1, 65, 132, 2, 4, 78, 79, 82, 77, + 78, 80, 46, 83, 170, 1, 84, 202, 228, 7, 69, 196, 33, 7, 73, 68, 69, 78, + 84, 73, 67, 222, 205, 4, 71, 38, 76, 175, 80, 67, 10, 88, 3, 32, 83, 85, + 52, 7, 78, 32, 69, 76, 69, 77, 69, 28, 2, 83, 89, 219, 135, 8, 76, 4, 30, + 66, 1, 3, 80, 69, 82, 2, 29, 2, 83, 69, 2, 11, 78, 2, 187, 121, 84, 2, + 37, 7, 77, 80, 84, 79, 84, 73, 67, 2, 17, 2, 65, 76, 2, 153, 136, 8, 2, + 76, 89, 4, 181, 200, 6, 14, 65, 76, 32, 83, 85, 66, 71, 82, 79, 85, 80, + 32, 79, 70, 2, 233, 135, 8, 6, 65, 82, 65, 76, 76, 69, 6, 48, 6, 81, 85, + 65, 82, 69, 32, 151, 231, 13, 73, 4, 68, 5, 73, 77, 65, 71, 69, 1, 8, 79, + 82, 73, 71, 73, 78, 65, 76, 2, 21, 3, 32, 79, 70, 2, 183, 198, 6, 32, 4, + 210, 215, 10, 82, 251, 244, 1, 73, 8, 58, 76, 40, 4, 82, 73, 71, 72, 133, + 1, 3, 85, 80, 80, 4, 36, 2, 69, 70, 133, 1, 2, 79, 87, 2, 89, 20, 84, 32, + 83, 69, 77, 73, 67, 73, 82, 67, 76, 69, 32, 87, 73, 84, 72, 32, 84, 72, + 2, 17, 2, 82, 69, 2, 155, 149, 13, 69, 2, 11, 69, 2, 41, 8, 82, 32, 82, + 73, 71, 72, 84, 45, 2, 249, 145, 3, 6, 83, 72, 65, 68, 79, 87, 11, 34, + 32, 53, 4, 66, 79, 79, 75, 4, 17, 2, 80, 65, 4, 254, 210, 14, 71, 215, + 22, 68, 5, 81, 18, 32, 87, 73, 84, 72, 32, 68, 69, 67, 79, 82, 65, 84, + 73, 86, 69, 32, 67, 2, 163, 140, 4, 79, 34, 102, 77, 192, 186, 5, 8, 84, + 32, 65, 78, 68, 32, 66, 79, 192, 131, 7, 3, 83, 72, 85, 187, 173, 1, 76, + 26, 36, 4, 66, 69, 82, 32, 247, 2, 69, 24, 58, 69, 50, 70, 42, 83, 66, + 84, 57, 4, 78, 73, 78, 69, 4, 204, 1, 3, 73, 71, 72, 21, 3, 76, 69, 86, + 4, 144, 1, 2, 79, 85, 13, 2, 73, 70, 6, 34, 73, 85, 4, 69, 86, 69, 78, 4, + 82, 88, 211, 149, 14, 71, 8, 40, 2, 72, 73, 46, 69, 21, 2, 87, 69, 2, 11, + 82, 2, 17, 2, 84, 69, 2, 11, 69, 2, 255, 205, 7, 78, 4, 232, 205, 7, 3, + 76, 86, 69, 1, 3, 78, 84, 89, 2, 171, 247, 6, 82, 142, 1, 118, 76, 226, + 3, 83, 164, 2, 5, 84, 79, 78, 69, 45, 188, 236, 7, 8, 67, 73, 82, 67, 76, + 69, 68, 32, 219, 249, 4, 68, 92, 88, 6, 69, 84, 84, 69, 82, 32, 185, 164, + 1, 10, 79, 71, 79, 71, 82, 65, 77, 32, 78, 89, 90, 130, 2, 78, 90, 84, + 158, 226, 7, 88, 254, 229, 2, 65, 144, 1, 2, 72, 65, 234, 52, 82, 198, + 148, 1, 79, 242, 61, 68, 2, 77, 2, 80, 158, 207, 1, 69, 234, 61, 67, 2, + 70, 2, 71, 2, 75, 2, 76, 2, 81, 2, 83, 2, 86, 2, 89, 2, 90, 186, 2, 73, + 2, 85, 3, 87, 22, 86, 84, 198, 208, 12, 80, 134, 141, 2, 67, 2, 75, 2, + 81, 2, 82, 2, 89, 187, 2, 65, 6, 198, 221, 14, 83, 2, 88, 187, 2, 65, 14, + 64, 4, 73, 71, 78, 32, 189, 1, 7, 89, 76, 76, 65, 66, 76, 69, 12, 56, 4, + 70, 79, 82, 32, 185, 224, 13, 4, 88, 87, 32, 88, 10, 200, 9, 2, 76, 79, + 130, 167, 3, 84, 244, 95, 8, 73, 78, 86, 69, 82, 84, 69, 66, 240, 146, 4, + 3, 65, 78, 73, 183, 177, 2, 80, 2, 237, 139, 12, 4, 32, 76, 69, 78, 14, + 178, 221, 14, 66, 2, 68, 2, 71, 2, 74, 2, 77, 2, 83, 3, 86, 132, 15, 218, + 2, 66, 226, 1, 67, 230, 5, 71, 244, 6, 4, 73, 76, 32, 68, 22, 76, 198, + 69, 77, 54, 78, 150, 5, 80, 234, 7, 82, 194, 11, 83, 188, 8, 2, 84, 84, + 154, 8, 85, 248, 1, 3, 86, 69, 82, 150, 172, 2, 89, 244, 154, 4, 14, 70, + 70, 73, 67, 69, 32, 66, 85, 73, 76, 68, 73, 78, 71, 250, 189, 3, 75, 226, + 17, 72, 210, 234, 1, 68, 198, 77, 87, 211, 139, 1, 88, 10, 132, 1, 6, 76, + 73, 81, 85, 69, 32, 164, 160, 2, 9, 83, 69, 82, 86, 69, 82, 32, 69, 89, + 161, 29, 8, 74, 69, 67, 84, 32, 82, 69, 80, 6, 164, 207, 4, 13, 65, 78, + 71, 76, 69, 32, 79, 80, 69, 78, 73, 78, 71, 171, 241, 1, 72, 28, 56, 2, + 82, 32, 238, 4, 84, 225, 202, 5, 3, 67, 85, 76, 22, 156, 1, 11, 65, 77, + 79, 85, 78, 84, 32, 79, 70, 32, 67, 22, 66, 202, 1, 67, 118, 68, 106, 70, + 0, 10, 73, 78, 86, 69, 82, 84, 69, 68, 32, 70, 159, 250, 12, 72, 2, 207, + 188, 5, 72, 6, 120, 2, 79, 87, 20, 15, 82, 65, 78, 67, 72, 32, 66, 65, + 78, 75, 32, 73, 68, 69, 78, 145, 135, 5, 5, 69, 76, 84, 32, 66, 2, 175, + 155, 11, 32, 2, 21, 3, 84, 73, 70, 2, 11, 73, 2, 199, 138, 11, 67, 4, 92, + 17, 85, 83, 84, 79, 77, 69, 82, 32, 65, 67, 67, 79, 85, 78, 84, 32, 78, + 243, 202, 1, 72, 2, 131, 165, 6, 85, 4, 44, 5, 79, 85, 66, 76, 69, 183, + 229, 12, 65, 2, 11, 32, 2, 11, 66, 2, 161, 169, 7, 3, 65, 67, 75, 2, 251, + 145, 14, 79, 4, 240, 128, 9, 4, 65, 71, 79, 78, 153, 198, 3, 2, 79, 80, + 60, 48, 4, 72, 65, 77, 32, 245, 206, 14, 2, 79, 78, 58, 122, 70, 0, 10, + 82, 69, 86, 69, 82, 83, 69, 68, 32, 70, 36, 7, 76, 69, 84, 84, 69, 82, + 32, 137, 130, 4, 3, 83, 80, 65, 2, 149, 143, 4, 4, 69, 65, 84, 72, 52, + 196, 1, 2, 65, 73, 22, 66, 2, 80, 34, 67, 36, 2, 69, 65, 64, 2, 70, 69, + 22, 71, 22, 73, 58, 76, 2, 82, 22, 78, 46, 79, 34, 83, 46, 85, 238, 185, + 1, 77, 154, 9, 68, 249, 237, 11, 3, 84, 73, 78, 2, 215, 190, 14, 76, 2, + 11, 69, 2, 255, 198, 12, 73, 4, 210, 157, 8, 69, 227, 163, 4, 79, 6, 138, + 1, 66, 2, 68, 141, 147, 4, 6, 77, 72, 65, 78, 67, 72, 2, 179, 181, 9, 65, + 2, 243, 198, 13, 79, 4, 32, 2, 79, 68, 251, 205, 13, 70, 2, 191, 143, 8, + 72, 2, 251, 162, 12, 85, 4, 192, 183, 13, 3, 71, 69, 65, 247, 69, 73, 4, + 150, 253, 13, 78, 227, 79, 82, 4, 246, 233, 12, 65, 245, 96, 3, 84, 82, + 65, 6, 60, 5, 73, 76, 76, 69, 65, 222, 195, 12, 65, 147, 136, 2, 82, 2, + 139, 252, 13, 78, 2, 243, 159, 13, 82, 182, 8, 38, 32, 142, 11, 68, 187, + 195, 13, 73, 184, 1, 64, 6, 67, 72, 73, 75, 73, 32, 205, 6, 5, 79, 78, + 65, 76, 32, 96, 132, 1, 7, 76, 69, 84, 84, 69, 82, 32, 148, 3, 2, 77, 85, + 62, 71, 74, 80, 224, 218, 3, 2, 82, 69, 178, 243, 8, 68, 235, 176, 1, 65, + 60, 50, 65, 98, 69, 54, 73, 50, 76, 62, 79, 51, 85, 16, 50, 65, 142, 200, + 14, 78, 86, 71, 2, 76, 3, 84, 8, 222, 200, 14, 74, 2, 75, 2, 77, 3, 87, + 8, 146, 130, 14, 68, 198, 13, 82, 222, 56, 78, 3, 80, 8, 182, 182, 14, + 78, 202, 17, 72, 2, 82, 3, 83, 12, 230, 175, 10, 65, 234, 151, 4, 69, 2, + 73, 2, 79, 3, 85, 8, 230, 170, 14, 84, 174, 28, 66, 2, 72, 3, 86, 8, 130, + 247, 13, 78, 226, 79, 67, 2, 68, 3, 89, 4, 56, 2, 45, 71, 245, 214, 12, + 6, 32, 84, 84, 85, 68, 68, 2, 241, 214, 12, 13, 65, 65, 72, 76, 65, 65, + 32, 84, 84, 85, 68, 68, 65, 6, 84, 11, 85, 78, 67, 84, 85, 65, 84, 73, + 79, 78, 32, 177, 228, 6, 4, 72, 65, 65, 82, 4, 48, 8, 68, 79, 85, 66, 76, + 69, 32, 77, 3, 77, 2, 245, 253, 13, 3, 85, 67, 65, 88, 100, 7, 76, 69, + 84, 84, 69, 82, 32, 192, 2, 5, 83, 73, 71, 78, 32, 170, 199, 8, 65, 151, + 130, 4, 68, 60, 42, 65, 54, 69, 58, 73, 54, 79, 59, 85, 13, 238, 194, 14, + 66, 2, 68, 2, 72, 2, 76, 3, 87, 13, 218, 242, 13, 78, 226, 79, 67, 2, 71, + 2, 72, 3, 83, 13, 202, 211, 8, 84, 186, 238, 5, 68, 2, 78, 3, 80, 13, + 242, 136, 14, 82, 138, 56, 78, 86, 77, 2, 79, 3, 89, 13, 246, 250, 13, + 68, 218, 52, 78, 202, 17, 74, 2, 75, 3, 82, 6, 58, 73, 200, 254, 12, 4, + 72, 79, 68, 68, 243, 156, 1, 77, 2, 131, 183, 1, 75, 252, 6, 34, 32, 165, + 57, 3, 69, 82, 32, 246, 6, 240, 2, 8, 67, 72, 73, 78, 69, 83, 69, 32, 44, + 10, 72, 85, 78, 71, 65, 82, 73, 65, 78, 32, 128, 7, 7, 73, 84, 65, 76, + 73, 67, 32, 212, 4, 14, 78, 79, 82, 84, 72, 32, 65, 82, 65, 66, 73, 65, + 78, 32, 196, 4, 3, 80, 69, 82, 216, 13, 2, 83, 79, 144, 13, 14, 84, 85, + 82, 75, 73, 67, 32, 76, 69, 84, 84, 69, 82, 32, 132, 7, 7, 85, 89, 71, + 72, 85, 82, 32, 199, 233, 11, 75, 4, 154, 147, 12, 73, 173, 97, 3, 72, + 79, 79, 216, 1, 96, 6, 67, 65, 80, 73, 84, 65, 0, 4, 83, 77, 65, 76, 233, + 5, 7, 78, 85, 77, 66, 69, 82, 32, 102, 45, 9, 76, 32, 76, 69, 84, 84, 69, + 82, 32, 102, 214, 1, 65, 54, 69, 168, 2, 10, 78, 73, 75, 79, 76, 83, 66, + 85, 82, 71, 0, 9, 82, 85, 68, 73, 77, 69, 78, 84, 65, 42, 79, 32, 5, 83, + 72, 79, 82, 84, 22, 85, 156, 246, 3, 5, 67, 76, 79, 83, 69, 155, 176, 8, + 73, 11, 210, 248, 12, 77, 222, 122, 78, 162, 70, 65, 3, 75, 63, 178, 1, + 77, 22, 78, 78, 83, 134, 136, 10, 67, 242, 23, 71, 2, 76, 2, 84, 166, + 138, 2, 90, 242, 140, 2, 66, 2, 68, 2, 69, 2, 70, 2, 72, 2, 74, 2, 75, 2, + 80, 2, 82, 3, 86, 5, 231, 183, 14, 80, 11, 34, 84, 178, 183, 14, 67, 3, + 89, 5, 205, 150, 2, 5, 45, 83, 72, 65, 80, 5, 135, 183, 14, 90, 4, 11, + 32, 4, 146, 160, 14, 79, 3, 85, 7, 246, 159, 14, 69, 215, 22, 79, 2, 191, + 248, 13, 32, 9, 254, 178, 14, 78, 154, 3, 83, 3, 85, 12, 210, 4, 70, 222, + 135, 6, 79, 175, 208, 6, 84, 78, 80, 7, 76, 69, 84, 84, 69, 82, 32, 169, + 3, 8, 78, 85, 77, 69, 82, 65, 76, 32, 70, 190, 1, 69, 90, 75, 50, 83, 36, + 3, 78, 79, 82, 150, 214, 10, 85, 138, 204, 1, 73, 198, 143, 1, 80, 2, 84, + 150, 83, 67, 186, 22, 66, 2, 68, 2, 72, 2, 86, 2, 89, 2, 90, 214, 22, 65, + 3, 79, 23, 166, 132, 10, 83, 150, 162, 2, 82, 150, 207, 1, 75, 222, 61, + 70, 2, 76, 2, 77, 3, 78, 8, 254, 155, 14, 72, 214, 22, 65, 2, 69, 3, 85, + 4, 32, 2, 79, 85, 175, 155, 14, 72, 2, 29, 5, 84, 72, 69, 82, 78, 2, 185, + 166, 13, 2, 32, 84, 8, 38, 70, 138, 216, 12, 84, 231, 61, 79, 4, 11, 73, + 4, 150, 190, 12, 70, 167, 220, 1, 86, 64, 76, 7, 76, 69, 84, 84, 69, 82, + 32, 209, 3, 7, 78, 85, 77, 66, 69, 82, 32, 58, 210, 1, 65, 38, 71, 38, + 72, 30, 75, 38, 84, 74, 90, 250, 107, 77, 240, 160, 3, 2, 69, 83, 246, + 164, 3, 66, 2, 70, 2, 82, 2, 89, 238, 204, 3, 78, 158, 238, 1, 76, 214, + 61, 68, 146, 1, 81, 134, 3, 87, 131, 56, 83, 4, 194, 196, 3, 76, 167, + 154, 10, 73, 4, 250, 254, 12, 72, 255, 156, 1, 69, 4, 238, 172, 14, 65, + 3, 69, 4, 162, 186, 7, 72, 159, 242, 5, 65, 8, 34, 72, 142, 172, 14, 65, + 3, 69, 4, 202, 161, 13, 65, 195, 138, 1, 69, 4, 11, 65, 4, 138, 221, 13, + 73, 227, 79, 72, 6, 178, 157, 6, 84, 235, 243, 6, 79, 180, 1, 64, 11, 77, + 73, 67, 32, 76, 69, 84, 84, 69, 82, 32, 183, 5, 83, 76, 228, 1, 2, 67, + 72, 22, 68, 66, 69, 22, 73, 30, 77, 2, 78, 30, 80, 22, 83, 70, 84, 50, + 86, 38, 89, 94, 90, 254, 199, 6, 76, 2, 82, 162, 229, 2, 71, 138, 172, 2, + 79, 218, 212, 1, 66, 246, 40, 65, 254, 31, 75, 174, 45, 72, 187, 2, 85, + 2, 211, 222, 7, 69, 6, 26, 90, 243, 149, 14, 79, 4, 210, 172, 9, 72, 171, + 216, 4, 73, 5, 163, 169, 14, 70, 7, 142, 169, 14, 65, 3, 69, 2, 145, 146, + 14, 2, 69, 78, 2, 131, 202, 6, 69, 6, 26, 72, 211, 148, 14, 73, 4, 176, + 171, 9, 3, 67, 72, 79, 3, 79, 4, 26, 83, 143, 148, 14, 65, 2, 251, 130, + 14, 73, 4, 218, 170, 9, 79, 155, 196, 4, 69, 14, 60, 2, 69, 82, 182, 184, + 8, 65, 242, 220, 5, 82, 203, 17, 85, 7, 234, 166, 14, 73, 3, 85, 4, 218, + 169, 9, 72, 171, 216, 4, 65, 104, 88, 4, 73, 65, 78, 32, 241, 5, 13, 79, + 78, 65, 76, 32, 67, 79, 77, 80, 85, 84, 69, 82, 100, 80, 7, 78, 85, 77, + 66, 69, 82, 32, 80, 5, 83, 73, 71, 78, 32, 175, 230, 10, 87, 10, 42, 84, + 198, 194, 8, 72, 223, 198, 4, 79, 6, 146, 232, 1, 87, 223, 236, 11, 69, + 88, 210, 1, 65, 86, 66, 62, 68, 98, 74, 2, 86, 30, 84, 42, 88, 198, 112, + 71, 2, 75, 2, 78, 2, 82, 210, 211, 9, 77, 130, 148, 3, 83, 218, 69, 67, + 2, 70, 2, 72, 2, 76, 2, 80, 2, 89, 2, 90, 186, 2, 73, 3, 85, 9, 45, 9, + 85, 82, 65, 77, 65, 90, 68, 65, 65, 7, 174, 245, 6, 45, 195, 170, 7, 72, + 6, 38, 65, 161, 184, 10, 3, 85, 85, 77, 5, 163, 159, 14, 71, 10, 34, 65, + 166, 161, 14, 73, 3, 85, 7, 37, 7, 72, 89, 65, 65, 85, 83, 72, 5, 131, + 244, 6, 45, 4, 230, 160, 14, 65, 3, 73, 6, 146, 158, 14, 72, 186, 2, 65, + 3, 85, 4, 216, 227, 11, 8, 83, 72, 65, 65, 89, 65, 84, 72, 203, 188, 2, + 65, 5, 181, 151, 5, 31, 32, 87, 73, 84, 72, 32, 77, 79, 78, 73, 84, 79, + 82, 32, 73, 78, 32, 80, 79, 82, 84, 82, 65, 73, 84, 32, 79, 82, 73, 69, + 78, 144, 1, 92, 6, 71, 68, 73, 65, 78, 32, 141, 7, 12, 85, 84, 72, 32, + 65, 82, 65, 66, 73, 65, 78, 32, 80, 58, 70, 74, 76, 145, 5, 7, 78, 85, + 77, 66, 69, 82, 32, 2, 11, 82, 2, 209, 245, 11, 10, 65, 67, 84, 73, 79, + 78, 32, 79, 78, 69, 60, 76, 6, 69, 84, 84, 69, 82, 32, 149, 4, 8, 73, 71, + 65, 84, 85, 82, 69, 32, 58, 234, 1, 65, 96, 6, 70, 73, 78, 65, 76, 32, + 200, 1, 5, 82, 69, 83, 72, 45, 198, 217, 1, 76, 146, 173, 4, 71, 90, 90, + 34, 83, 66, 89, 206, 209, 1, 72, 234, 5, 75, 142, 81, 66, 138, 231, 4, + 78, 134, 2, 84, 2, 87, 218, 103, 80, 171, 4, 77, 6, 26, 76, 191, 154, 13, + 89, 4, 180, 137, 6, 8, 84, 69, 82, 78, 65, 84, 69, 32, 163, 216, 1, 69, + 18, 116, 3, 78, 85, 78, 0, 5, 83, 65, 68, 72, 69, 0, 3, 84, 65, 87, 226, + 217, 1, 65, 190, 215, 6, 66, 231, 208, 5, 72, 5, 41, 8, 32, 87, 73, 84, + 72, 32, 86, 69, 2, 233, 223, 5, 4, 82, 84, 73, 67, 2, 161, 217, 1, 6, 65, + 89, 73, 78, 45, 68, 18, 42, 84, 222, 135, 6, 79, 175, 153, 6, 70, 10, 42, + 72, 198, 218, 1, 87, 223, 236, 11, 69, 4, 198, 161, 12, 82, 159, 2, 73, + 64, 60, 7, 76, 69, 84, 84, 69, 82, 32, 245, 3, 3, 78, 85, 77, 58, 202, 1, + 65, 38, 68, 74, 71, 34, 75, 34, 83, 78, 84, 130, 45, 90, 158, 167, 1, 76, + 50, 81, 238, 206, 1, 82, 174, 223, 2, 89, 206, 209, 1, 72, 246, 86, 66, + 138, 231, 4, 78, 134, 2, 87, 218, 103, 70, 171, 4, 77, 4, 206, 170, 3, + 76, 167, 154, 10, 89, 6, 32, 2, 72, 65, 187, 213, 1, 65, 4, 210, 172, 8, + 76, 175, 186, 5, 68, 4, 138, 46, 72, 187, 212, 5, 73, 4, 142, 219, 7, 65, + 131, 81, 72, 8, 26, 65, 187, 147, 13, 72, 6, 214, 204, 7, 77, 170, 153, + 6, 68, 143, 45, 84, 8, 246, 91, 72, 214, 174, 11, 69, 243, 137, 1, 65, 6, + 56, 4, 66, 69, 82, 32, 205, 216, 13, 4, 69, 82, 73, 67, 4, 26, 70, 167, + 246, 12, 79, 2, 175, 157, 12, 73, 146, 1, 80, 7, 79, 82, 75, 72, 79, 78, + 32, 197, 3, 8, 89, 69, 78, 73, 83, 69, 73, 32, 84, 54, 65, 202, 1, 69, + 122, 73, 30, 79, 171, 159, 12, 66, 45, 106, 69, 238, 248, 9, 83, 218, + 150, 4, 66, 2, 68, 2, 71, 2, 76, 2, 78, 2, 81, 2, 82, 2, 84, 3, 89, 20, + 194, 143, 14, 66, 2, 68, 2, 71, 2, 75, 2, 76, 2, 78, 2, 82, 2, 83, 2, 84, + 3, 89, 20, 74, 78, 242, 241, 13, 76, 158, 27, 83, 146, 1, 67, 2, 77, 2, + 80, 3, 90, 8, 154, 142, 14, 67, 2, 71, 2, 84, 3, 89, 7, 238, 141, 14, 67, + 3, 81, 13, 130, 3, 69, 210, 138, 14, 80, 2, 81, 3, 84, 62, 38, 65, 170, + 1, 69, 86, 73, 23, 79, 39, 98, 69, 138, 139, 14, 83, 62, 78, 86, 66, 2, + 68, 2, 71, 2, 76, 2, 81, 2, 82, 2, 84, 3, 89, 17, 254, 138, 12, 78, 154, + 129, 2, 66, 2, 71, 2, 75, 2, 84, 3, 89, 15, 46, 78, 150, 138, 14, 83, + 146, 1, 67, 3, 90, 6, 162, 139, 14, 67, 2, 84, 3, 89, 5, 255, 138, 14, + 81, 6, 26, 69, 211, 138, 14, 81, 5, 207, 138, 14, 75, 52, 148, 1, 10, 67, + 79, 77, 66, 73, 78, 73, 78, 71, 32, 36, 7, 76, 69, 84, 84, 69, 82, 32, + 233, 1, 12, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 32, 8, 210, 245, + 5, 84, 207, 233, 3, 68, 36, 138, 202, 1, 65, 210, 207, 1, 82, 150, 222, + 2, 76, 58, 90, 34, 83, 66, 89, 176, 212, 1, 6, 70, 73, 78, 65, 76, 32, 0, + 6, 71, 73, 77, 69, 76, 45, 134, 3, 75, 142, 81, 66, 138, 231, 4, 78, 134, + 2, 84, 2, 87, 218, 103, 80, 171, 4, 77, 8, 56, 4, 84, 87, 79, 32, 182, + 220, 11, 70, 175, 134, 1, 66, 4, 218, 239, 12, 66, 75, 68, 6, 182, 182, + 1, 87, 228, 162, 3, 3, 65, 68, 85, 147, 222, 7, 77, 4, 144, 217, 2, 4, + 65, 78, 73, 32, 183, 151, 10, 32, 22, 212, 1, 34, 32, 87, 73, 84, 72, 32, + 69, 88, 67, 76, 65, 77, 65, 84, 73, 79, 78, 32, 77, 65, 82, 75, 32, 87, + 73, 84, 72, 32, 76, 69, 70, 84, 32, 82, 44, 7, 67, 79, 77, 73, 78, 71, + 32, 194, 1, 69, 159, 178, 13, 73, 2, 21, 3, 73, 71, 72, 2, 147, 128, 10, + 84, 10, 148, 1, 6, 65, 85, 84, 79, 77, 79, 20, 7, 70, 73, 82, 69, 32, 69, + 78, 128, 227, 2, 2, 84, 65, 140, 253, 8, 6, 80, 79, 76, 73, 67, 69, 151, + 22, 66, 2, 243, 213, 11, 66, 2, 223, 230, 12, 71, 8, 70, 32, 233, 199, + 12, 11, 45, 80, 73, 69, 67, 69, 32, 83, 87, 73, 77, 6, 40, 4, 68, 79, 84, + 32, 191, 179, 10, 66, 4, 26, 79, 151, 181, 10, 76, 2, 145, 236, 2, 11, + 86, 69, 82, 32, 84, 87, 79, 32, 68, 79, 84, 46, 82, 69, 188, 6, 2, 84, + 73, 172, 237, 11, 5, 72, 73, 85, 67, 72, 171, 186, 1, 80, 36, 70, 78, + 201, 5, 12, 82, 65, 84, 73, 78, 71, 32, 83, 89, 83, 84, 69, 34, 22, 32, + 139, 4, 45, 28, 108, 2, 66, 79, 32, 7, 67, 69, 78, 84, 82, 69, 32, 114, + 70, 70, 72, 42, 77, 214, 144, 7, 83, 203, 245, 3, 76, 4, 250, 250, 13, + 79, 155, 3, 88, 8, 50, 84, 150, 224, 11, 66, 222, 2, 65, 163, 84, 67, 2, + 37, 7, 69, 65, 82, 68, 82, 79, 80, 2, 247, 225, 11, 45, 4, 44, 5, 73, 76, + 69, 32, 70, 251, 132, 2, 79, 2, 247, 132, 2, 79, 2, 17, 2, 65, 78, 2, + 151, 198, 10, 68, 4, 57, 12, 65, 73, 76, 66, 79, 88, 32, 87, 73, 84, 72, + 32, 4, 44, 3, 76, 79, 87, 21, 4, 82, 65, 73, 83, 2, 17, 2, 69, 82, 2, + 241, 139, 12, 2, 69, 68, 6, 108, 15, 67, 73, 82, 67, 85, 73, 84, 45, 79, + 85, 84, 80, 85, 84, 32, 165, 215, 12, 6, 79, 85, 84, 76, 73, 78, 4, 18, + 72, 3, 76, 2, 145, 193, 1, 4, 45, 84, 89, 80, 2, 177, 233, 12, 6, 77, 32, + 67, 79, 77, 77, 6, 64, 2, 79, 78, 237, 178, 1, 8, 67, 65, 76, 32, 68, 73, + 83, 67, 2, 223, 215, 11, 32, 212, 1, 104, 3, 65, 78, 71, 66, 67, 34, 73, + 164, 9, 5, 78, 65, 84, 69, 32, 32, 3, 84, 72, 79, 167, 179, 5, 32, 6, 28, + 2, 69, 32, 247, 22, 85, 4, 190, 158, 12, 66, 219, 81, 72, 4, 194, 185, + 13, 85, 223, 61, 65, 192, 1, 48, 5, 71, 73, 78, 65, 76, 21, 3, 89, 65, + 32, 2, 151, 134, 1, 32, 190, 1, 106, 65, 30, 70, 250, 1, 73, 32, 7, 76, + 69, 84, 84, 69, 82, 32, 142, 2, 83, 170, 2, 86, 191, 247, 11, 68, 4, 206, + 143, 10, 73, 3, 85, 12, 41, 8, 82, 65, 67, 84, 73, 79, 78, 32, 12, 56, 4, + 79, 78, 69, 32, 81, 6, 84, 72, 82, 69, 69, 32, 8, 42, 83, 190, 234, 11, + 69, 46, 72, 47, 81, 2, 201, 235, 11, 4, 73, 88, 84, 69, 4, 26, 83, 211, + 236, 11, 81, 2, 185, 141, 8, 4, 73, 88, 84, 69, 2, 177, 207, 12, 3, 83, + 83, 72, 104, 226, 1, 82, 202, 243, 6, 89, 130, 155, 3, 65, 38, 68, 114, + 84, 46, 86, 186, 5, 85, 138, 204, 1, 73, 42, 76, 130, 199, 1, 78, 46, 83, + 82, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 138, 69, 72, 2, 77, 2, 87, + 186, 2, 69, 3, 79, 6, 242, 238, 13, 72, 2, 82, 187, 2, 65, 22, 112, 20, + 69, 81, 85, 69, 78, 67, 69, 32, 70, 79, 82, 32, 76, 69, 84, 84, 69, 82, + 32, 82, 29, 4, 73, 71, 78, 32, 4, 214, 237, 13, 72, 3, 82, 18, 78, 68, + 206, 203, 9, 67, 98, 78, 198, 67, 65, 210, 241, 1, 79, 219, 170, 1, 86, + 4, 11, 79, 4, 26, 85, 251, 241, 12, 84, 2, 153, 238, 12, 3, 66, 76, 69, + 26, 49, 10, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 26, 150, 146, 10, 65, + 38, 85, 22, 86, 246, 203, 1, 73, 230, 143, 2, 69, 3, 79, 4, 186, 225, 6, + 76, 243, 30, 82, 4, 224, 248, 3, 2, 68, 79, 155, 185, 2, 71, 226, 1, 76, + 4, 65, 71, 69, 32, 140, 4, 6, 77, 65, 78, 89, 65, 32, 179, 232, 13, 67, + 144, 1, 56, 6, 67, 65, 80, 73, 84, 65, 1, 4, 83, 77, 65, 76, 72, 45, 9, + 76, 32, 76, 69, 84, 84, 69, 82, 32, 72, 194, 1, 65, 38, 69, 90, 75, 42, + 79, 22, 84, 238, 234, 6, 72, 166, 253, 4, 67, 2, 68, 2, 71, 130, 185, 1, + 83, 2, 90, 130, 3, 66, 138, 66, 76, 2, 77, 2, 78, 2, 80, 2, 87, 186, 2, + 73, 3, 85, 9, 130, 233, 11, 73, 135, 129, 2, 72, 15, 26, 72, 235, 153, + 13, 73, 10, 198, 206, 9, 84, 194, 154, 2, 67, 138, 254, 1, 75, 3, 80, 6, + 210, 230, 13, 72, 2, 89, 187, 2, 65, 5, 131, 153, 13, 73, 6, 142, 161, + 13, 83, 195, 71, 65, 80, 52, 7, 76, 69, 84, 84, 69, 82, 32, 219, 240, 11, + 68, 60, 246, 1, 65, 38, 67, 22, 68, 38, 75, 34, 83, 30, 77, 218, 242, 2, + 81, 230, 164, 8, 79, 152, 126, 2, 76, 65, 228, 78, 2, 78, 85, 134, 2, 87, + 142, 62, 69, 234, 61, 66, 2, 70, 2, 71, 2, 72, 2, 74, 2, 82, 2, 84, 2, + 88, 2, 89, 186, 2, 73, 3, 85, 7, 250, 251, 2, 76, 135, 234, 10, 65, 2, + 239, 231, 12, 65, 4, 174, 202, 8, 69, 227, 152, 5, 72, 4, 242, 227, 12, + 65, 251, 126, 72, 4, 26, 72, 235, 228, 13, 65, 2, 147, 229, 12, 73, 124, + 68, 11, 79, 77, 65, 78, 32, 83, 73, 89, 65, 81, 32, 179, 171, 13, 69, + 122, 172, 1, 17, 65, 76, 84, 69, 82, 78, 65, 84, 69, 32, 78, 85, 77, 66, + 69, 82, 32, 200, 1, 13, 70, 82, 65, 67, 84, 73, 79, 78, 32, 79, 78, 69, + 32, 48, 3, 77, 65, 82, 47, 78, 26, 54, 70, 50, 83, 46, 84, 142, 198, 12, + 78, 239, 112, 69, 6, 232, 210, 5, 3, 79, 85, 82, 231, 146, 7, 73, 6, 184, + 210, 5, 2, 73, 88, 203, 153, 6, 69, 10, 130, 186, 2, 69, 12, 2, 87, 79, + 247, 177, 9, 72, 4, 26, 83, 207, 215, 11, 72, 2, 187, 216, 11, 73, 2, 11, + 82, 2, 11, 65, 2, 183, 145, 12, 84, 90, 33, 6, 85, 77, 66, 69, 82, 32, + 90, 58, 69, 66, 70, 94, 78, 26, 83, 78, 84, 155, 180, 5, 79, 10, 25, 4, + 73, 71, 72, 84, 11, 130, 184, 2, 89, 155, 197, 5, 32, 20, 18, 73, 35, 79, + 10, 166, 2, 70, 171, 179, 5, 86, 10, 134, 2, 82, 181, 179, 5, 2, 85, 82, + 10, 65, 3, 73, 78, 69, 20, 40, 4, 69, 86, 69, 78, 1, 2, 73, 88, 11, 166, + 1, 84, 179, 250, 7, 32, 24, 34, 72, 50, 87, 195, 181, 2, 69, 10, 34, 73, + 221, 179, 5, 2, 82, 69, 4, 51, 82, 10, 26, 69, 195, 179, 5, 79, 4, 11, + 78, 4, 11, 84, 4, 151, 181, 2, 89, 84, 34, 84, 241, 184, 11, 2, 78, 67, + 82, 42, 66, 37, 6, 76, 73, 78, 69, 68, 32, 2, 189, 205, 12, 4, 79, 88, + 32, 84, 80, 92, 7, 76, 65, 84, 73, 78, 32, 67, 234, 199, 6, 87, 214, 245, + 4, 66, 234, 14, 71, 167, 23, 68, 54, 138, 179, 7, 65, 187, 225, 4, 82, + 12, 18, 72, 43, 76, 2, 17, 2, 69, 65, 2, 167, 199, 12, 84, 10, 32, 2, 65, + 80, 183, 190, 12, 73, 9, 29, 5, 80, 73, 78, 71, 32, 6, 40, 6, 87, 72, 73, + 84, 69, 32, 51, 66, 4, 44, 5, 65, 78, 68, 32, 66, 215, 143, 10, 83, 2, + 189, 143, 10, 4, 76, 65, 67, 75, 154, 13, 150, 1, 65, 218, 65, 68, 30, + 69, 138, 13, 72, 138, 25, 73, 218, 4, 76, 160, 15, 2, 78, 80, 54, 79, + 238, 8, 82, 210, 15, 83, 186, 6, 85, 135, 188, 12, 77, 158, 6, 134, 2, + 68, 38, 71, 224, 1, 11, 72, 65, 87, 72, 32, 72, 77, 79, 78, 71, 32, 134, + 23, 76, 130, 6, 78, 58, 82, 196, 22, 2, 83, 83, 132, 2, 10, 85, 32, 67, + 73, 78, 32, 72, 65, 85, 32, 176, 7, 3, 87, 32, 80, 212, 128, 8, 2, 67, + 75, 217, 147, 5, 4, 80, 69, 82, 67, 5, 129, 186, 1, 4, 68, 73, 78, 71, + 14, 26, 69, 219, 175, 13, 79, 13, 34, 32, 186, 212, 13, 82, 3, 83, 6, 52, + 3, 70, 65, 67, 33, 6, 87, 73, 84, 72, 32, 67, 2, 193, 162, 4, 3, 73, 78, + 71, 4, 50, 85, 221, 241, 7, 6, 73, 82, 67, 76, 69, 68, 2, 219, 199, 12, + 82, 254, 1, 190, 1, 67, 160, 6, 9, 77, 65, 82, 75, 32, 67, 73, 77, 32, + 160, 1, 7, 78, 85, 77, 66, 69, 82, 32, 244, 1, 5, 83, 73, 71, 78, 32, + 144, 10, 7, 86, 79, 87, 69, 76, 32, 75, 243, 198, 11, 68, 78, 92, 9, 76, + 65, 78, 32, 83, 73, 71, 78, 32, 137, 3, 9, 79, 78, 83, 79, 78, 65, 78, + 84, 32, 38, 132, 1, 2, 72, 65, 38, 75, 46, 76, 34, 84, 82, 86, 30, 89, + 148, 9, 2, 88, 89, 172, 5, 2, 80, 72, 174, 1, 70, 165, 2, 2, 77, 85, 4, + 222, 199, 2, 87, 143, 136, 11, 77, 6, 246, 15, 72, 222, 160, 13, 79, 159, + 14, 87, 4, 210, 12, 65, 239, 132, 13, 73, 8, 22, 83, 247, 9, 72, 6, 212, + 198, 2, 3, 72, 69, 69, 146, 199, 9, 65, 3, 87, 4, 158, 198, 2, 65, 3, 87, + 4, 130, 198, 2, 65, 167, 194, 10, 69, 40, 122, 67, 38, 72, 46, 78, 60, 2, + 80, 76, 2, 81, 138, 224, 2, 76, 2, 77, 2, 82, 2, 86, 2, 88, 2, 89, 247, + 198, 10, 65, 4, 146, 225, 2, 72, 247, 198, 10, 65, 6, 238, 224, 2, 76, 2, + 78, 247, 198, 10, 65, 12, 58, 67, 22, 84, 246, 223, 2, 75, 2, 76, 247, + 198, 10, 65, 2, 135, 224, 2, 72, 4, 242, 223, 2, 72, 3, 83, 14, 42, 75, + 50, 83, 38, 84, 211, 185, 13, 72, 4, 26, 72, 147, 141, 13, 69, 2, 163, + 167, 6, 65, 4, 194, 138, 12, 85, 151, 192, 1, 79, 4, 182, 137, 12, 85, + 155, 21, 65, 14, 52, 7, 72, 85, 78, 68, 82, 69, 68, 38, 84, 79, 77, 4, + 108, 2, 32, 77, 239, 200, 13, 83, 8, 24, 2, 69, 78, 51, 82, 6, 26, 32, + 131, 201, 13, 83, 4, 18, 66, 35, 84, 2, 237, 216, 4, 3, 73, 76, 76, 2, + 11, 72, 2, 137, 129, 10, 3, 79, 85, 83, 72, 188, 1, 4, 67, 73, 77, 32, + 246, 2, 72, 32, 3, 73, 66, 32, 22, 77, 86, 78, 50, 84, 124, 4, 86, 79, + 83, 32, 198, 1, 88, 208, 1, 6, 90, 87, 74, 32, 84, 72, 186, 178, 1, 76, + 167, 232, 4, 65, 16, 174, 1, 67, 84, 5, 78, 82, 69, 83, 32, 22, 84, 204, + 131, 12, 7, 80, 85, 66, 32, 68, 65, 87, 157, 192, 1, 16, 72, 65, 73, 83, + 32, 76, 85, 83, 32, 78, 84, 79, 71, 32, 78, 84, 4, 48, 7, 85, 65, 77, 32, + 84, 83, 72, 255, 3, 72, 2, 11, 79, 2, 227, 188, 2, 79, 2, 239, 184, 1, + 84, 6, 52, 3, 88, 87, 86, 209, 157, 10, 4, 83, 79, 86, 32, 5, 197, 160, + 6, 4, 32, 67, 72, 87, 4, 194, 72, 78, 211, 231, 12, 76, 2, 183, 131, 12, + 89, 6, 40, 4, 69, 69, 74, 32, 179, 133, 13, 85, 4, 128, 3, 2, 84, 83, 57, + 2, 83, 85, 4, 26, 84, 251, 128, 9, 81, 2, 187, 186, 2, 85, 6, 196, 1, 7, + 88, 72, 69, 69, 74, 32, 67, 156, 183, 8, 12, 72, 73, 82, 68, 45, 83, 84, + 65, 71, 69, 32, 72, 235, 228, 4, 65, 14, 54, 70, 22, 83, 30, 84, 170, 69, + 76, 251, 255, 7, 78, 2, 211, 174, 13, 69, 2, 161, 157, 6, 2, 69, 69, 6, + 42, 72, 29, 6, 83, 72, 65, 66, 32, 67, 4, 82, 73, 251, 174, 13, 79, 2, + 147, 212, 5, 69, 14, 34, 73, 22, 89, 195, 179, 11, 65, 2, 211, 254, 11, + 65, 10, 40, 4, 69, 69, 77, 32, 159, 160, 13, 79, 8, 84, 3, 78, 84, 88, + 240, 154, 6, 2, 84, 79, 226, 172, 2, 82, 225, 181, 3, 2, 70, 65, 2, 239, + 154, 6, 73, 2, 151, 182, 2, 65, 56, 50, 65, 66, 69, 38, 73, 2, 85, 38, + 79, 39, 87, 20, 170, 1, 65, 2, 73, 2, 85, 2, 87, 178, 188, 13, 66, 3, 86, + 8, 106, 69, 178, 188, 13, 66, 3, 86, 8, 70, 65, 178, 188, 13, 66, 3, 86, + 8, 34, 79, 178, 188, 13, 66, 3, 86, 4, 174, 188, 13, 66, 3, 86, 76, 18, + 76, 23, 77, 2, 163, 254, 12, 65, 74, 74, 32, 104, 6, 89, 82, 69, 78, 69, + 32, 253, 144, 4, 4, 83, 32, 85, 80, 8, 80, 3, 66, 82, 65, 138, 197, 11, + 84, 144, 101, 4, 68, 79, 87, 78, 1, 2, 85, 80, 2, 163, 152, 13, 78, 64, 80, 2, 76, 69, 40, 4, 82, 73, 71, 72, 253, 2, 7, 78, 85, 77, 66, 69, 82, 32, 48, 38, 70, 89, 5, 84, 84, 69, 82, 32, 2, 57, 12, 84, 45, 80, 79, 73, - 78, 84, 73, 78, 71, 32, 70, 2, 229, 231, 5, 2, 76, 69, 46, 224, 1, 5, 70, - 73, 78, 65, 76, 30, 84, 242, 119, 68, 34, 76, 50, 81, 214, 205, 1, 82, - 142, 220, 2, 65, 50, 71, 90, 90, 34, 83, 66, 89, 198, 207, 1, 72, 234, 5, - 75, 174, 81, 66, 170, 225, 4, 78, 134, 2, 87, 218, 103, 80, 171, 4, 77, - 2, 161, 172, 12, 2, 32, 78, 4, 190, 167, 11, 69, 219, 134, 1, 65, 14, - 194, 121, 84, 198, 191, 10, 70, 223, 87, 79, 4, 32, 2, 67, 65, 147, 236, - 12, 68, 2, 191, 149, 12, 75, 188, 2, 94, 65, 220, 1, 11, 69, 78, 84, 72, - 69, 83, 73, 90, 69, 68, 32, 242, 16, 84, 203, 199, 12, 82, 14, 80, 5, 71, - 82, 65, 80, 72, 52, 5, 76, 76, 69, 76, 32, 209, 163, 6, 2, 67, 72, 6, - 186, 248, 9, 32, 250, 223, 1, 85, 235, 147, 1, 79, 6, 44, 5, 87, 73, 84, - 72, 32, 163, 138, 13, 84, 4, 222, 198, 6, 84, 175, 186, 4, 72, 150, 2, + 78, 84, 73, 78, 71, 32, 70, 2, 217, 234, 5, 2, 76, 69, 46, 224, 1, 5, 70, + 73, 78, 65, 76, 30, 84, 134, 120, 68, 34, 76, 50, 81, 238, 206, 1, 82, + 198, 221, 2, 65, 50, 71, 90, 90, 34, 83, 66, 89, 206, 209, 1, 72, 234, 5, + 75, 142, 81, 66, 138, 231, 4, 78, 134, 2, 87, 218, 103, 80, 171, 4, 77, + 2, 205, 182, 12, 2, 32, 78, 4, 210, 174, 11, 69, 243, 137, 1, 65, 14, + 214, 121, 84, 198, 198, 10, 70, 247, 90, 79, 4, 32, 2, 67, 65, 191, 246, + 12, 68, 2, 235, 159, 12, 75, 188, 2, 94, 65, 220, 1, 11, 69, 78, 84, 72, + 69, 83, 73, 90, 69, 68, 32, 242, 16, 84, 247, 209, 12, 82, 14, 80, 5, 71, + 82, 65, 80, 72, 52, 5, 76, 76, 69, 76, 32, 189, 168, 6, 2, 67, 72, 6, + 222, 254, 9, 32, 242, 224, 1, 85, 251, 150, 1, 79, 6, 44, 5, 87, 73, 84, + 72, 32, 207, 148, 13, 84, 4, 202, 203, 6, 84, 251, 187, 4, 72, 150, 2, 252, 1, 7, 72, 65, 78, 71, 85, 76, 32, 188, 4, 10, 73, 68, 69, 79, 71, 82, 65, 80, 72, 32, 188, 7, 18, 75, 79, 82, 69, 65, 78, 32, 67, 72, 65, - 82, 65, 67, 84, 69, 82, 32, 79, 44, 7, 78, 85, 77, 66, 69, 82, 32, 250, - 206, 4, 68, 145, 169, 2, 2, 76, 65, 58, 102, 67, 110, 72, 30, 75, 66, 77, + 82, 65, 67, 84, 69, 82, 32, 79, 44, 7, 78, 85, 77, 66, 69, 82, 32, 234, + 209, 4, 68, 229, 170, 2, 2, 76, 65, 58, 102, 67, 110, 72, 30, 75, 66, 77, 34, 78, 34, 80, 62, 82, 30, 83, 26, 84, 73, 5, 73, 69, 85, 78, 71, 10, 34, 72, 33, 4, 73, 69, 85, 67, 4, 141, 3, 4, 73, 69, 85, 67, 7, 11, 32, - 4, 178, 165, 13, 65, 3, 85, 4, 197, 2, 3, 73, 69, 85, 8, 168, 2, 5, 72, + 4, 222, 175, 13, 65, 3, 85, 4, 197, 2, 3, 73, 69, 85, 8, 168, 2, 5, 72, 73, 69, 85, 75, 13, 5, 73, 89, 69, 79, 75, 4, 245, 1, 4, 73, 69, 85, 77, 4, 213, 1, 4, 73, 69, 85, 78, 8, 168, 1, 5, 72, 73, 69, 85, 80, 13, 4, 73, 69, 85, 80, 4, 121, 4, 73, 69, 85, 76, 4, 93, 3, 73, 79, 83, 8, 56, - 5, 72, 73, 69, 85, 84, 13, 5, 73, 75, 69, 85, 84, 4, 11, 72, 5, 139, 160, + 5, 72, 73, 69, 85, 84, 13, 5, 73, 75, 69, 85, 84, 4, 11, 72, 5, 183, 170, 13, 32, 72, 148, 1, 2, 65, 76, 30, 67, 74, 69, 82, 70, 112, 2, 76, 65, - 22, 77, 38, 78, 32, 2, 82, 69, 78, 83, 138, 2, 84, 50, 87, 254, 172, 11, - 72, 239, 82, 79, 2, 237, 144, 8, 2, 76, 73, 4, 32, 2, 79, 78, 179, 150, - 11, 65, 2, 181, 251, 7, 4, 71, 82, 65, 84, 6, 42, 78, 174, 179, 9, 65, - 155, 194, 3, 73, 2, 169, 4, 5, 84, 69, 82, 80, 82, 10, 58, 73, 204, 147, - 12, 5, 69, 83, 84, 73, 86, 139, 19, 79, 6, 208, 2, 3, 78, 65, 78, 130, - 134, 13, 82, 3, 86, 2, 139, 230, 12, 66, 4, 226, 198, 10, 69, 147, 136, - 2, 79, 4, 138, 131, 12, 73, 195, 1, 65, 8, 38, 83, 218, 139, 12, 80, 247, - 111, 65, 4, 190, 214, 6, 79, 183, 199, 6, 84, 18, 58, 69, 34, 79, 22, 80, - 34, 84, 50, 85, 211, 141, 12, 73, 4, 142, 199, 11, 86, 227, 84, 76, 2, - 239, 251, 7, 67, 2, 11, 69, 2, 227, 181, 4, 67, 4, 26, 85, 163, 234, 11, - 79, 2, 219, 138, 13, 68, 4, 26, 80, 247, 155, 13, 78, 2, 21, 3, 69, 82, - 86, 2, 183, 144, 12, 73, 6, 154, 169, 11, 72, 206, 162, 1, 69, 239, 48, - 87, 4, 234, 224, 9, 79, 163, 128, 2, 65, 4, 170, 164, 8, 32, 221, 166, 4, + 22, 77, 38, 78, 32, 2, 82, 69, 78, 83, 138, 2, 84, 50, 87, 146, 180, 11, + 72, 135, 86, 79, 2, 169, 149, 8, 2, 76, 73, 4, 32, 2, 79, 78, 191, 157, + 11, 65, 2, 249, 255, 7, 4, 71, 82, 65, 84, 6, 42, 78, 234, 184, 9, 65, + 139, 199, 3, 73, 2, 169, 4, 5, 84, 69, 82, 80, 82, 10, 58, 73, 248, 157, + 12, 5, 69, 83, 84, 73, 86, 139, 19, 79, 6, 208, 2, 3, 78, 65, 78, 174, + 144, 13, 82, 3, 86, 2, 183, 240, 12, 66, 4, 146, 205, 10, 69, 143, 140, + 2, 79, 4, 182, 141, 12, 73, 195, 1, 65, 8, 38, 83, 134, 150, 12, 80, 247, + 111, 65, 4, 170, 219, 6, 79, 247, 204, 6, 84, 18, 58, 69, 34, 79, 22, 80, + 34, 84, 50, 85, 255, 151, 12, 73, 4, 170, 206, 11, 86, 243, 87, 76, 2, + 179, 128, 8, 67, 2, 11, 69, 2, 211, 184, 4, 67, 4, 26, 85, 143, 244, 11, + 79, 2, 135, 149, 13, 68, 4, 26, 80, 163, 166, 13, 78, 2, 21, 3, 69, 82, + 86, 2, 227, 154, 12, 73, 6, 174, 176, 11, 72, 230, 165, 1, 69, 239, 48, + 87, 4, 142, 231, 9, 79, 167, 129, 2, 65, 4, 230, 168, 8, 32, 205, 172, 4, 2, 74, 69, 22, 42, 69, 46, 70, 42, 78, 30, 83, 51, 84, 4, 216, 1, 3, 73, - 71, 72, 131, 246, 4, 76, 4, 160, 1, 2, 79, 85, 13, 2, 73, 70, 2, 133, 1, + 71, 72, 223, 248, 4, 76, 4, 160, 1, 2, 79, 85, 13, 2, 73, 70, 2, 133, 1, 3, 73, 78, 69, 4, 34, 73, 73, 4, 69, 86, 69, 78, 2, 71, 88, 8, 34, 72, - 46, 87, 207, 200, 12, 69, 2, 11, 73, 2, 11, 82, 2, 175, 194, 11, 84, 4, - 11, 69, 4, 190, 168, 11, 78, 143, 115, 76, 22, 164, 1, 3, 73, 65, 76, - 216, 1, 3, 89, 32, 80, 224, 206, 6, 5, 72, 69, 78, 79, 80, 180, 229, 1, - 6, 78, 69, 82, 83, 72, 73, 225, 219, 3, 6, 32, 65, 76, 84, 69, 82, 12, - 62, 32, 173, 124, 10, 76, 89, 45, 82, 69, 67, 89, 67, 76, 69, 10, 38, 68, - 41, 5, 76, 73, 78, 69, 32, 2, 229, 174, 4, 5, 73, 70, 70, 69, 82, 8, 254, - 205, 3, 68, 226, 45, 70, 20, 4, 66, 65, 67, 75, 203, 153, 9, 85, 2, 223, - 242, 3, 79, 10, 98, 69, 52, 9, 73, 86, 69, 45, 80, 85, 76, 76, 45, 89, 9, - 80, 79, 82, 84, 32, 67, 79, 78, 84, 4, 176, 242, 9, 4, 78, 71, 69, 82, - 147, 140, 2, 68, 4, 40, 4, 68, 79, 87, 78, 1, 2, 85, 80, 2, 213, 176, 5, - 6, 45, 79, 85, 84, 80, 85, 2, 239, 253, 11, 82, 114, 192, 1, 12, 71, 76, + 46, 87, 251, 210, 12, 69, 2, 11, 73, 2, 11, 82, 2, 203, 201, 11, 84, 4, + 11, 69, 4, 210, 175, 11, 78, 167, 118, 76, 22, 164, 1, 3, 73, 65, 76, + 216, 1, 3, 89, 32, 80, 204, 211, 6, 5, 72, 69, 78, 79, 80, 136, 229, 1, + 6, 78, 69, 82, 83, 72, 73, 205, 225, 3, 6, 32, 65, 76, 84, 69, 82, 12, + 62, 32, 165, 124, 10, 76, 89, 45, 82, 69, 67, 89, 67, 76, 69, 10, 38, 68, + 41, 5, 76, 73, 78, 69, 32, 2, 213, 177, 4, 5, 73, 70, 70, 69, 82, 8, 226, + 208, 3, 68, 238, 45, 70, 20, 4, 66, 65, 67, 75, 135, 161, 9, 85, 2, 207, + 245, 3, 79, 10, 98, 69, 52, 9, 73, 86, 69, 45, 80, 85, 76, 76, 45, 89, 9, + 80, 79, 82, 84, 32, 67, 79, 78, 84, 4, 224, 248, 9, 4, 78, 71, 69, 82, + 143, 144, 2, 68, 4, 40, 4, 68, 79, 87, 78, 1, 2, 85, 80, 2, 185, 179, 5, + 6, 45, 79, 85, 84, 80, 85, 2, 155, 136, 12, 82, 114, 192, 1, 12, 71, 76, 79, 84, 84, 65, 76, 32, 83, 84, 79, 80, 62, 76, 156, 3, 3, 82, 73, 83, 36, 14, 77, 73, 68, 45, 76, 69, 86, 69, 76, 32, 84, 79, 78, 69, 57, 7, - 83, 65, 78, 68, 72, 73, 32, 7, 11, 32, 4, 202, 5, 70, 213, 255, 11, 4, + 83, 65, 78, 68, 72, 73, 32, 7, 11, 32, 4, 202, 5, 70, 129, 138, 12, 4, 86, 65, 82, 73, 82, 72, 6, 69, 84, 84, 69, 82, 32, 209, 2, 7, 79, 87, 45, - 70, 65, 76, 76, 74, 202, 1, 70, 226, 252, 8, 73, 2, 85, 238, 27, 78, 198, - 174, 3, 67, 2, 75, 2, 80, 2, 84, 138, 69, 66, 2, 68, 2, 71, 2, 72, 2, 76, + 70, 65, 76, 76, 74, 202, 1, 70, 150, 129, 9, 73, 2, 85, 174, 28, 78, 254, + 179, 3, 67, 2, 75, 2, 80, 2, 84, 138, 69, 66, 2, 68, 2, 71, 2, 72, 2, 76, 2, 77, 2, 82, 2, 83, 2, 86, 2, 90, 186, 2, 65, 2, 69, 3, 79, 20, 44, 5, - 73, 78, 65, 76, 32, 163, 142, 13, 65, 18, 158, 144, 11, 78, 130, 254, 1, + 73, 78, 65, 76, 32, 207, 152, 13, 65, 18, 178, 151, 11, 78, 154, 129, 2, 75, 2, 76, 2, 77, 2, 80, 2, 84, 2, 87, 3, 89, 8, 157, 1, 5, 73, 78, 71, 32, 84, 7, 11, 32, 4, 192, 1, 5, 76, 79, 78, 71, 32, 15, 70, 12, 66, 84, 73, 12, 71, 76, 79, 84, 84, 65, 76, 32, 83, 84, 79, 80, 8, 21, 3, 79, 78, 69, 9, 11, 32, 6, 32, 4, 76, 79, 78, 71, 27, 70, 5, 11, 32, 2, 11, 70, 2, - 131, 201, 3, 73, 2, 171, 181, 4, 82, 4, 162, 139, 13, 70, 3, 73, 80, 130, - 1, 65, 122, 78, 162, 1, 82, 162, 9, 83, 44, 3, 84, 82, 73, 130, 17, 68, - 157, 156, 12, 9, 79, 80, 76, 69, 32, 72, 85, 71, 71, 12, 50, 67, 50, 78, - 138, 239, 6, 32, 155, 154, 6, 82, 6, 202, 215, 11, 79, 194, 28, 69, 199, - 149, 1, 72, 2, 227, 128, 12, 85, 10, 118, 71, 20, 3, 83, 73, 86, 222, - 179, 1, 84, 156, 188, 4, 10, 32, 79, 86, 69, 82, 32, 83, 84, 65, 77, 187, - 184, 5, 67, 2, 191, 136, 12, 85, 2, 223, 202, 12, 69, 48, 186, 1, 32, - 116, 10, 80, 69, 78, 68, 73, 67, 85, 76, 65, 82, 42, 83, 130, 176, 7, 67, - 252, 9, 10, 77, 65, 78, 69, 78, 84, 32, 80, 65, 80, 237, 133, 2, 8, 70, - 79, 82, 77, 73, 78, 71, 32, 6, 34, 77, 30, 84, 139, 255, 11, 83, 2, 129, - 242, 1, 2, 73, 76, 2, 149, 154, 11, 8, 69, 78, 32, 84, 72, 79, 85, 83, 5, - 213, 139, 9, 5, 32, 87, 73, 84, 72, 32, 60, 2, 79, 78, 154, 75, 80, 157, - 177, 11, 4, 69, 86, 69, 82, 28, 38, 32, 237, 133, 10, 3, 65, 76, 32, 26, + 231, 203, 3, 73, 2, 155, 184, 4, 82, 4, 206, 149, 13, 70, 3, 73, 80, 130, + 1, 65, 122, 78, 162, 1, 82, 166, 9, 83, 44, 3, 84, 82, 73, 130, 17, 68, + 197, 166, 12, 9, 79, 80, 76, 69, 32, 72, 85, 71, 71, 12, 50, 67, 50, 78, + 206, 243, 6, 32, 131, 160, 6, 82, 6, 182, 225, 11, 79, 130, 29, 69, 199, + 149, 1, 72, 2, 143, 139, 12, 85, 10, 118, 71, 20, 3, 83, 73, 86, 198, + 180, 1, 84, 160, 192, 4, 10, 32, 79, 86, 69, 82, 32, 83, 84, 65, 77, 235, + 186, 5, 67, 2, 235, 146, 12, 85, 2, 139, 213, 12, 69, 48, 186, 1, 32, + 116, 10, 80, 69, 78, 68, 73, 67, 85, 76, 65, 82, 42, 83, 206, 180, 7, 67, + 240, 9, 10, 77, 65, 78, 69, 78, 84, 32, 80, 65, 80, 225, 134, 2, 8, 70, + 79, 82, 77, 73, 78, 71, 32, 6, 34, 77, 30, 84, 183, 137, 12, 83, 2, 181, + 243, 1, 2, 73, 76, 2, 169, 161, 11, 8, 69, 78, 32, 84, 72, 79, 85, 83, 5, + 201, 144, 9, 5, 32, 87, 73, 84, 72, 32, 60, 2, 79, 78, 174, 75, 80, 181, + 187, 11, 4, 69, 86, 69, 82, 28, 38, 32, 157, 140, 10, 3, 65, 76, 32, 26, 216, 2, 10, 68, 79, 73, 78, 71, 32, 67, 65, 82, 84, 32, 3, 73, 78, 32, - 92, 5, 87, 73, 84, 72, 32, 184, 224, 7, 4, 70, 82, 79, 87, 204, 13, 27, + 92, 5, 87, 73, 84, 72, 32, 252, 228, 7, 4, 70, 82, 79, 87, 180, 13, 27, 82, 65, 73, 83, 73, 78, 71, 32, 66, 79, 84, 72, 32, 72, 65, 78, 68, 83, - 32, 73, 78, 32, 67, 69, 76, 69, 66, 204, 193, 4, 5, 67, 76, 73, 77, 66, + 32, 73, 78, 32, 67, 69, 76, 69, 66, 204, 199, 4, 5, 67, 76, 73, 77, 66, 213, 45, 11, 66, 79, 87, 73, 78, 71, 32, 68, 69, 69, 80, 2, 11, 87, 2, - 159, 189, 3, 72, 4, 204, 175, 12, 6, 76, 79, 84, 85, 83, 32, 253, 64, 9, - 83, 84, 69, 65, 77, 89, 32, 82, 79, 12, 154, 1, 66, 180, 146, 2, 3, 80, - 79, 85, 188, 165, 1, 2, 67, 82, 244, 132, 6, 6, 70, 79, 76, 68, 69, 68, - 177, 193, 2, 8, 72, 69, 65, 68, 83, 67, 65, 82, 4, 36, 3, 76, 79, 78, - 235, 244, 10, 65, 2, 11, 68, 2, 11, 32, 2, 11, 72, 2, 11, 65, 2, 131, - 198, 12, 73, 4, 180, 169, 9, 2, 69, 84, 151, 206, 2, 79, 2, 209, 153, 9, + 131, 192, 3, 72, 4, 248, 185, 12, 6, 76, 79, 84, 85, 83, 32, 253, 64, 9, + 83, 84, 69, 65, 77, 89, 32, 82, 79, 12, 138, 1, 66, 110, 67, 132, 147, 2, + 3, 80, 79, 85, 184, 174, 7, 6, 70, 79, 76, 68, 69, 68, 169, 198, 2, 8, + 72, 69, 65, 68, 83, 67, 65, 82, 4, 36, 3, 76, 79, 78, 135, 252, 10, 65, + 2, 11, 68, 2, 11, 32, 2, 11, 72, 2, 11, 65, 2, 191, 208, 12, 73, 2, 247, + 185, 3, 82, 4, 236, 174, 9, 2, 69, 84, 135, 211, 2, 79, 2, 137, 159, 9, 2, 32, 68, 140, 2, 66, 65, 184, 19, 9, 73, 76, 73, 80, 80, 73, 78, 69, 32, 47, 79, 204, 1, 108, 6, 71, 83, 45, 80, 65, 32, 189, 7, 16, 73, 83, 84, 79, 83, 32, 68, 73, 83, 67, 32, 83, 73, 71, 78, 32, 112, 100, 7, 76, 69, 84, 84, 69, 82, 32, 248, 4, 5, 77, 65, 82, 75, 32, 30, 83, 33, 4, 68, 79, 85, 66, 96, 138, 2, 65, 138, 1, 67, 50, 68, 42, 83, 64, 5, 86, 79, - 73, 67, 69, 178, 129, 9, 71, 202, 173, 3, 78, 82, 84, 46, 75, 2, 80, 2, + 73, 67, 69, 162, 134, 9, 71, 130, 179, 3, 78, 82, 84, 46, 75, 2, 80, 2, 90, 162, 7, 69, 234, 61, 66, 2, 70, 2, 72, 2, 74, 2, 76, 2, 77, 2, 81, 2, 82, 2, 87, 2, 88, 2, 89, 186, 2, 73, 2, 79, 3, 85, 7, 80, 8, 76, 84, 69, - 82, 78, 65, 84, 69, 21, 8, 83, 80, 73, 82, 65, 84, 69, 68, 2, 163, 246, - 12, 32, 2, 11, 32, 2, 167, 246, 12, 70, 6, 26, 65, 251, 245, 12, 72, 5, - 231, 218, 8, 78, 6, 226, 245, 12, 68, 2, 90, 187, 2, 65, 6, 244, 174, 8, - 4, 77, 65, 76, 76, 198, 198, 4, 72, 187, 2, 65, 4, 34, 68, 21, 4, 76, 69, - 83, 83, 2, 231, 249, 10, 32, 2, 171, 187, 9, 32, 4, 246, 175, 12, 68, 59, - 83, 10, 28, 3, 73, 78, 71, 31, 85, 2, 229, 169, 12, 2, 76, 69, 8, 58, 66, - 213, 170, 12, 8, 80, 69, 82, 70, 73, 88, 69, 68, 6, 209, 189, 8, 13, 74, + 82, 78, 65, 84, 69, 21, 8, 83, 80, 73, 82, 65, 84, 69, 68, 2, 203, 128, + 13, 32, 2, 11, 32, 2, 207, 128, 13, 70, 6, 26, 65, 163, 128, 13, 72, 5, + 151, 223, 8, 78, 6, 138, 128, 13, 68, 2, 90, 187, 2, 65, 6, 176, 179, 8, + 4, 77, 65, 76, 76, 178, 204, 4, 72, 187, 2, 65, 4, 34, 68, 21, 4, 76, 69, + 83, 83, 2, 247, 128, 11, 32, 2, 203, 193, 9, 32, 4, 158, 186, 12, 68, 59, + 83, 10, 28, 3, 73, 78, 71, 31, 85, 2, 141, 180, 12, 2, 76, 69, 8, 58, 66, + 253, 180, 12, 8, 80, 69, 82, 70, 73, 88, 69, 68, 6, 141, 194, 8, 13, 74, 79, 73, 78, 69, 68, 32, 76, 69, 84, 84, 69, 82, 92, 238, 1, 66, 146, 1, 67, 172, 2, 2, 68, 79, 38, 71, 66, 72, 64, 2, 76, 73, 32, 2, 77, 65, 70, - 80, 162, 1, 82, 38, 83, 150, 1, 84, 70, 87, 200, 228, 5, 2, 70, 76, 176, - 238, 1, 2, 79, 88, 252, 240, 3, 2, 69, 65, 138, 10, 65, 135, 1, 86, 10, - 52, 2, 69, 69, 22, 79, 145, 41, 4, 85, 76, 76, 83, 5, 147, 182, 7, 72, 4, - 32, 2, 79, 77, 175, 242, 12, 87, 2, 11, 69, 2, 203, 153, 12, 82, 16, 34, - 65, 86, 72, 22, 76, 23, 79, 6, 130, 224, 5, 80, 208, 240, 3, 8, 82, 80, - 69, 78, 84, 82, 89, 32, 151, 161, 3, 84, 2, 199, 193, 2, 73, 2, 135, 179, - 11, 85, 6, 26, 76, 33, 2, 77, 66, 2, 11, 85, 2, 227, 160, 12, 77, 5, 37, - 7, 73, 78, 73, 78, 71, 32, 79, 2, 169, 255, 9, 5, 66, 76, 73, 81, 85, 4, - 174, 196, 11, 76, 223, 148, 1, 86, 4, 42, 82, 137, 141, 11, 4, 65, 85, - 78, 84, 2, 131, 181, 11, 65, 6, 42, 69, 238, 219, 7, 79, 243, 255, 2, 73, - 2, 171, 185, 12, 76, 4, 242, 220, 12, 76, 203, 17, 68, 4, 34, 78, 249, - 251, 9, 2, 84, 84, 2, 11, 65, 2, 211, 172, 9, 67, 8, 52, 2, 69, 68, 50, - 76, 181, 176, 7, 3, 65, 80, 89, 2, 25, 4, 69, 83, 84, 82, 2, 231, 160, - 11, 73, 4, 192, 187, 4, 2, 85, 77, 209, 231, 2, 3, 65, 78, 69, 4, 230, - 218, 10, 79, 251, 128, 2, 65, 12, 108, 2, 72, 73, 134, 237, 11, 65, 158, + 80, 162, 1, 82, 38, 83, 150, 1, 84, 70, 87, 176, 233, 5, 2, 70, 76, 136, + 238, 1, 2, 79, 88, 164, 246, 3, 2, 69, 65, 146, 10, 65, 191, 1, 86, 10, + 52, 2, 69, 69, 22, 79, 161, 41, 4, 85, 76, 76, 83, 5, 219, 186, 7, 72, 4, + 32, 2, 79, 77, 215, 252, 12, 87, 2, 11, 69, 2, 243, 163, 12, 82, 16, 34, + 65, 86, 72, 22, 76, 23, 79, 6, 234, 228, 5, 80, 148, 242, 3, 8, 82, 80, + 69, 78, 84, 82, 89, 32, 147, 165, 3, 84, 2, 167, 196, 2, 73, 2, 171, 186, + 11, 85, 6, 26, 76, 33, 2, 77, 66, 2, 11, 85, 2, 139, 171, 12, 77, 5, 37, + 7, 73, 78, 73, 78, 71, 32, 79, 2, 213, 133, 10, 5, 66, 76, 73, 81, 85, 4, + 150, 206, 11, 76, 159, 149, 1, 86, 4, 42, 82, 153, 148, 11, 4, 65, 85, + 78, 84, 2, 167, 188, 11, 65, 6, 42, 69, 150, 224, 7, 79, 211, 130, 3, 73, + 2, 211, 195, 12, 76, 4, 154, 231, 12, 76, 203, 17, 68, 4, 34, 78, 165, + 130, 10, 2, 84, 84, 2, 11, 65, 2, 131, 178, 9, 67, 8, 52, 2, 69, 68, 50, + 76, 253, 180, 7, 3, 65, 80, 89, 2, 25, 4, 69, 83, 84, 82, 2, 151, 168, + 11, 73, 4, 144, 190, 4, 2, 85, 77, 189, 233, 2, 3, 65, 78, 69, 4, 238, + 225, 10, 79, 155, 132, 2, 65, 12, 108, 2, 72, 73, 174, 247, 11, 65, 158, 45, 76, 128, 19, 3, 84, 82, 65, 177, 39, 7, 77, 65, 76, 76, 32, 65, 88, - 4, 214, 187, 2, 69, 207, 175, 10, 80, 6, 208, 185, 4, 5, 65, 84, 84, 79, - 79, 226, 236, 7, 73, 207, 36, 85, 4, 146, 236, 7, 79, 137, 238, 3, 5, 65, - 86, 89, 32, 66, 4, 250, 244, 1, 83, 25, 4, 68, 79, 85, 66, 60, 56, 8, 69, - 78, 73, 67, 73, 65, 78, 32, 187, 224, 10, 76, 58, 92, 7, 76, 69, 84, 84, - 69, 82, 32, 160, 3, 7, 78, 85, 77, 66, 69, 82, 32, 231, 155, 6, 87, 44, - 234, 1, 65, 34, 68, 22, 72, 22, 81, 22, 83, 58, 84, 226, 130, 2, 87, 154, - 239, 5, 90, 154, 185, 1, 89, 164, 207, 1, 2, 82, 79, 184, 95, 3, 71, 65, + 4, 182, 190, 2, 69, 151, 183, 10, 80, 6, 160, 188, 4, 5, 65, 84, 84, 79, + 79, 186, 244, 7, 73, 207, 36, 85, 4, 202, 240, 7, 79, 249, 243, 3, 5, 65, + 86, 89, 32, 66, 4, 162, 246, 1, 83, 25, 4, 68, 79, 85, 66, 60, 56, 8, 69, + 78, 73, 67, 73, 65, 78, 32, 203, 231, 10, 76, 58, 92, 7, 76, 69, 84, 84, + 69, 82, 32, 160, 3, 7, 78, 85, 77, 66, 69, 82, 32, 207, 160, 6, 87, 44, + 234, 1, 65, 34, 68, 22, 72, 22, 81, 22, 83, 58, 84, 138, 132, 2, 87, 170, + 242, 5, 90, 130, 187, 1, 89, 148, 208, 1, 2, 82, 79, 208, 98, 3, 71, 65, 77, 162, 10, 75, 130, 1, 78, 144, 58, 3, 76, 65, 77, 138, 17, 66, 198, - 30, 80, 171, 4, 77, 4, 170, 229, 11, 76, 199, 49, 73, 2, 199, 192, 3, 69, - 4, 195, 253, 6, 69, 2, 227, 228, 11, 79, 6, 254, 210, 10, 65, 162, 147, - 1, 72, 189, 124, 2, 69, 77, 4, 210, 192, 12, 65, 191, 8, 69, 12, 202, 50, - 84, 203, 170, 4, 79, 40, 104, 2, 67, 75, 66, 71, 62, 76, 90, 78, 178, 1, - 83, 28, 7, 84, 67, 72, 70, 79, 82, 75, 243, 224, 12, 69, 5, 17, 2, 85, - 80, 2, 21, 3, 32, 84, 82, 2, 223, 177, 11, 85, 7, 11, 32, 4, 26, 78, 163, - 166, 12, 70, 2, 131, 216, 11, 79, 6, 52, 4, 69, 32, 79, 70, 246, 92, 67, - 235, 133, 12, 76, 2, 11, 32, 2, 215, 151, 10, 80, 14, 68, 2, 67, 72, 46, - 69, 194, 169, 4, 87, 206, 176, 7, 75, 243, 98, 65, 4, 196, 160, 3, 2, 69, - 68, 231, 176, 8, 73, 4, 28, 2, 32, 68, 239, 73, 65, 2, 253, 134, 5, 2, - 69, 67, 4, 134, 203, 11, 67, 123, 84, 5, 245, 139, 10, 10, 32, 87, 73, - 84, 72, 32, 84, 69, 69, 32, 218, 1, 38, 65, 230, 9, 85, 167, 214, 12, 68, - 176, 1, 78, 67, 128, 1, 12, 78, 67, 75, 32, 67, 79, 78, 83, 84, 65, 78, - 84, 83, 89, 6, 44, 5, 69, 32, 79, 70, 32, 151, 198, 11, 65, 4, 56, 6, 73, - 78, 84, 69, 82, 69, 173, 137, 12, 2, 87, 79, 2, 251, 146, 7, 83, 5, 45, - 9, 32, 79, 86, 69, 82, 32, 84, 87, 79, 2, 11, 32, 2, 159, 202, 12, 80, - 166, 1, 80, 7, 71, 82, 79, 85, 78, 68, 32, 29, 9, 73, 78, 71, 32, 67, 65, - 82, 68, 32, 2, 173, 171, 4, 2, 83, 76, 164, 1, 182, 1, 66, 44, 3, 82, 69, - 68, 0, 5, 87, 72, 73, 84, 69, 42, 70, 74, 75, 38, 69, 34, 83, 36, 3, 81, - 85, 69, 14, 84, 92, 2, 65, 67, 0, 3, 78, 73, 78, 13, 4, 74, 65, 67, 75, - 4, 40, 4, 76, 65, 67, 75, 135, 169, 11, 65, 2, 17, 2, 32, 74, 2, 219, - 237, 1, 79, 18, 30, 79, 249, 1, 2, 73, 86, 10, 128, 2, 2, 85, 82, 239, - 204, 11, 79, 16, 34, 78, 185, 1, 3, 73, 78, 71, 8, 181, 1, 4, 73, 71, 72, - 84, 16, 32, 2, 69, 86, 117, 2, 73, 88, 8, 91, 69, 66, 78, 69, 12, 3, 72, - 82, 69, 12, 2, 87, 79, 161, 1, 5, 82, 85, 77, 80, 45, 8, 23, 78, 8, 11, - 69, 8, 25, 4, 32, 79, 70, 32, 8, 88, 3, 67, 76, 85, 20, 3, 83, 80, 65, - 250, 145, 9, 72, 137, 3, 5, 68, 73, 65, 77, 79, 2, 231, 153, 12, 66, 2, - 171, 193, 11, 68, 42, 90, 50, 190, 146, 10, 49, 134, 196, 2, 51, 2, 52, - 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 7, 190, 214, 12, 48, 3, 49, 41, 46, - 83, 160, 4, 2, 84, 79, 175, 128, 9, 78, 26, 52, 5, 32, 83, 73, 71, 78, - 141, 163, 9, 2, 45, 77, 25, 11, 32, 22, 64, 3, 73, 78, 32, 124, 5, 87, - 73, 84, 72, 32, 215, 255, 3, 65, 6, 34, 76, 22, 82, 195, 173, 11, 84, 2, - 41, 2, 69, 70, 2, 21, 3, 73, 71, 72, 2, 233, 255, 10, 6, 84, 32, 72, 65, - 76, 70, 14, 162, 1, 68, 34, 83, 140, 176, 10, 4, 84, 73, 76, 68, 152, - 123, 5, 66, 76, 65, 67, 75, 201, 38, 16, 67, 73, 82, 67, 85, 77, 70, 76, - 69, 88, 32, 65, 67, 67, 69, 78, 2, 11, 79, 2, 167, 161, 10, 84, 4, 54, - 77, 173, 181, 5, 7, 85, 66, 83, 67, 82, 73, 80, 2, 197, 170, 9, 3, 65, - 76, 76, 11, 33, 6, 32, 70, 79, 82, 77, 32, 8, 162, 222, 10, 70, 71, 84, - 2, 157, 152, 12, 8, 32, 84, 82, 65, 78, 83, 73, 83, 58, 232, 1, 5, 76, - 73, 67, 69, 32, 122, 80, 140, 1, 11, 82, 84, 65, 66, 76, 69, 32, 83, 84, - 69, 82, 22, 83, 158, 1, 84, 146, 1, 85, 196, 1, 4, 87, 69, 82, 32, 210, - 142, 7, 79, 157, 129, 5, 11, 67, 75, 69, 84, 32, 67, 65, 76, 67, 85, 76, - 6, 52, 3, 67, 65, 82, 217, 253, 3, 4, 79, 70, 70, 73, 5, 217, 177, 10, - 11, 83, 32, 82, 69, 86, 79, 76, 86, 73, 78, 71, 6, 76, 13, 32, 68, 73, - 82, 69, 67, 84, 73, 79, 78, 65, 76, 32, 159, 215, 1, 67, 4, 158, 128, 1, - 73, 169, 190, 6, 6, 70, 79, 82, 77, 65, 84, 2, 251, 173, 12, 69, 12, 40, - 2, 69, 73, 22, 84, 243, 140, 5, 73, 2, 195, 252, 11, 68, 8, 36, 3, 65, - 76, 32, 171, 189, 11, 66, 6, 226, 213, 1, 72, 213, 206, 6, 4, 77, 65, 82, - 75, 8, 66, 65, 238, 135, 2, 32, 153, 183, 9, 6, 84, 69, 68, 32, 80, 76, - 4, 26, 66, 239, 171, 12, 84, 2, 29, 5, 76, 69, 32, 87, 65, 2, 243, 48, - 84, 12, 108, 4, 76, 84, 82, 89, 28, 7, 82, 73, 78, 71, 32, 76, 73, 28, 2, - 84, 73, 202, 221, 10, 78, 179, 234, 1, 67, 2, 213, 131, 12, 2, 32, 76, 2, - 205, 179, 5, 2, 81, 85, 4, 149, 223, 10, 2, 78, 71, 8, 24, 2, 79, 78, 47, - 83, 4, 136, 179, 11, 4, 45, 79, 70, 70, 15, 32, 4, 156, 152, 9, 3, 76, - 69, 69, 231, 154, 2, 89, 140, 1, 74, 69, 162, 10, 73, 230, 2, 79, 237, - 221, 9, 6, 65, 89, 69, 82, 32, 66, 102, 132, 1, 6, 71, 78, 65, 78, 84, - 32, 66, 83, 252, 191, 5, 4, 67, 69, 68, 69, 192, 207, 1, 5, 86, 73, 79, - 85, 83, 241, 32, 2, 84, 90, 6, 42, 87, 202, 193, 8, 80, 143, 184, 2, 77, - 2, 199, 199, 7, 79, 70, 176, 1, 27, 69, 78, 84, 65, 84, 73, 79, 78, 32, - 70, 79, 82, 77, 32, 70, 79, 82, 32, 86, 69, 82, 84, 73, 67, 65, 76, 32, - 129, 216, 8, 10, 67, 82, 73, 80, 84, 73, 79, 78, 32, 84, 68, 198, 1, 67, - 22, 69, 46, 72, 50, 73, 94, 76, 188, 1, 6, 82, 73, 71, 72, 84, 32, 192, - 2, 6, 87, 65, 86, 89, 32, 76, 178, 156, 4, 83, 252, 217, 4, 9, 84, 87, - 79, 32, 68, 79, 84, 32, 76, 139, 114, 81, 4, 191, 190, 2, 79, 6, 158, - 158, 6, 88, 182, 227, 2, 77, 3, 78, 2, 173, 154, 9, 7, 79, 82, 73, 90, + 30, 80, 171, 4, 77, 4, 210, 239, 11, 76, 199, 49, 73, 2, 179, 195, 3, 69, + 4, 139, 130, 7, 69, 2, 139, 239, 11, 79, 6, 134, 218, 10, 65, 194, 150, + 1, 72, 189, 124, 2, 69, 77, 4, 250, 202, 12, 65, 191, 8, 69, 12, 218, 50, + 84, 155, 173, 4, 79, 42, 104, 2, 67, 75, 82, 71, 62, 76, 90, 78, 178, 1, + 83, 28, 7, 84, 67, 72, 70, 79, 82, 75, 139, 235, 12, 69, 7, 32, 2, 85, + 80, 195, 215, 12, 76, 2, 21, 3, 32, 84, 82, 2, 183, 187, 11, 85, 7, 11, + 32, 4, 26, 78, 187, 176, 12, 70, 2, 155, 226, 11, 79, 6, 52, 4, 69, 32, + 79, 70, 214, 92, 67, 163, 144, 12, 76, 2, 11, 32, 2, 243, 157, 10, 80, + 14, 68, 2, 67, 72, 46, 69, 158, 172, 4, 87, 138, 184, 7, 75, 243, 98, 65, + 4, 148, 163, 3, 2, 69, 68, 175, 184, 8, 73, 4, 28, 2, 32, 68, 211, 73, + 65, 2, 217, 137, 5, 2, 69, 67, 4, 158, 213, 11, 67, 123, 84, 5, 145, 146, + 10, 10, 32, 87, 73, 84, 72, 32, 84, 69, 69, 32, 218, 1, 38, 65, 230, 9, + 85, 191, 224, 12, 68, 176, 1, 78, 67, 128, 1, 12, 78, 67, 75, 32, 67, 79, + 78, 83, 84, 65, 78, 84, 83, 89, 6, 44, 5, 69, 32, 79, 70, 32, 175, 208, + 11, 65, 4, 56, 6, 73, 78, 84, 69, 82, 69, 197, 147, 12, 2, 87, 79, 2, + 167, 151, 7, 83, 5, 45, 9, 32, 79, 86, 69, 82, 32, 84, 87, 79, 2, 11, 32, + 2, 183, 212, 12, 80, 166, 1, 80, 7, 71, 82, 79, 85, 78, 68, 32, 29, 9, + 73, 78, 71, 32, 67, 65, 82, 68, 32, 2, 237, 173, 4, 2, 83, 76, 164, 1, + 182, 1, 66, 44, 3, 82, 69, 68, 0, 5, 87, 72, 73, 84, 69, 42, 70, 74, 75, + 38, 69, 34, 83, 36, 3, 81, 85, 69, 14, 84, 92, 2, 65, 67, 0, 3, 78, 73, + 78, 13, 4, 74, 65, 67, 75, 4, 40, 4, 76, 65, 67, 75, 223, 178, 11, 65, 2, + 17, 2, 32, 74, 2, 243, 238, 1, 79, 18, 30, 79, 249, 1, 2, 73, 86, 10, + 128, 2, 2, 85, 82, 135, 215, 11, 79, 16, 34, 78, 185, 1, 3, 73, 78, 71, + 8, 181, 1, 4, 73, 71, 72, 84, 16, 32, 2, 69, 86, 117, 2, 73, 88, 8, 91, + 69, 66, 78, 69, 12, 3, 72, 82, 69, 12, 2, 87, 79, 161, 1, 5, 82, 85, 77, + 80, 45, 8, 23, 78, 8, 11, 69, 8, 25, 4, 32, 79, 70, 32, 8, 88, 3, 67, 76, + 85, 20, 3, 83, 80, 65, 154, 151, 9, 72, 137, 3, 5, 68, 73, 65, 77, 79, 2, + 255, 163, 12, 66, 2, 195, 203, 11, 68, 42, 90, 50, 218, 152, 10, 49, 130, + 200, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 7, 214, 224, 12, + 48, 3, 49, 41, 46, 83, 160, 4, 2, 84, 79, 215, 133, 9, 78, 26, 52, 5, 32, + 83, 73, 71, 78, 157, 169, 9, 2, 45, 77, 25, 11, 32, 22, 64, 3, 73, 78, + 32, 124, 5, 87, 73, 84, 72, 32, 179, 130, 4, 65, 6, 34, 76, 22, 82, 155, + 183, 11, 84, 2, 41, 2, 69, 70, 2, 21, 3, 73, 71, 72, 2, 241, 134, 11, 6, + 84, 32, 72, 65, 76, 70, 14, 162, 1, 68, 34, 83, 132, 183, 10, 4, 84, 73, + 76, 68, 248, 125, 5, 66, 76, 65, 67, 75, 137, 39, 16, 67, 73, 82, 67, 85, + 77, 70, 76, 69, 88, 32, 65, 67, 67, 69, 78, 2, 11, 79, 2, 195, 167, 10, + 84, 4, 54, 77, 141, 186, 5, 7, 85, 66, 83, 67, 82, 73, 80, 2, 213, 176, + 9, 3, 65, 76, 76, 11, 33, 6, 32, 70, 79, 82, 77, 32, 8, 162, 229, 10, 70, + 71, 84, 2, 181, 162, 12, 8, 32, 84, 82, 65, 78, 83, 73, 83, 58, 232, 1, + 5, 76, 73, 67, 69, 32, 122, 80, 140, 1, 11, 82, 84, 65, 66, 76, 69, 32, + 83, 84, 69, 82, 22, 83, 158, 1, 84, 146, 1, 85, 196, 1, 4, 87, 69, 82, + 32, 154, 147, 7, 79, 237, 134, 5, 11, 67, 75, 69, 84, 32, 67, 65, 76, 67, + 85, 76, 6, 52, 3, 67, 65, 82, 181, 128, 4, 4, 79, 70, 70, 73, 5, 209, + 184, 10, 11, 83, 32, 82, 69, 86, 79, 76, 86, 73, 78, 71, 6, 76, 13, 32, + 68, 73, 82, 69, 67, 84, 73, 79, 78, 65, 76, 32, 191, 216, 1, 67, 4, 242, + 128, 1, 73, 253, 193, 6, 6, 70, 79, 82, 77, 65, 84, 2, 147, 184, 12, 69, + 12, 40, 2, 69, 73, 22, 84, 211, 143, 5, 73, 2, 219, 134, 12, 68, 8, 36, + 3, 65, 76, 32, 195, 199, 11, 66, 6, 130, 215, 1, 72, 225, 209, 6, 4, 77, + 65, 82, 75, 8, 66, 65, 190, 138, 2, 32, 225, 190, 9, 6, 84, 69, 68, 32, + 80, 76, 4, 26, 66, 135, 182, 12, 84, 2, 29, 5, 76, 69, 32, 87, 65, 2, + 215, 48, 84, 12, 108, 4, 76, 84, 82, 89, 28, 7, 82, 73, 78, 71, 32, 76, + 73, 28, 2, 84, 73, 202, 228, 10, 78, 203, 237, 1, 67, 2, 237, 141, 12, 2, + 32, 76, 2, 165, 184, 5, 2, 81, 85, 4, 149, 230, 10, 2, 78, 71, 8, 24, 2, + 79, 78, 47, 83, 4, 160, 189, 11, 4, 45, 79, 70, 70, 15, 32, 4, 172, 158, + 9, 3, 76, 69, 69, 239, 158, 2, 89, 140, 1, 74, 69, 162, 10, 73, 230, 2, + 79, 137, 228, 9, 6, 65, 89, 69, 82, 32, 66, 102, 132, 1, 6, 71, 78, 65, + 78, 84, 32, 66, 83, 212, 196, 5, 4, 67, 69, 68, 69, 176, 207, 1, 5, 86, + 73, 79, 85, 83, 217, 32, 2, 84, 90, 6, 42, 87, 150, 198, 8, 80, 227, 186, + 2, 77, 2, 239, 203, 7, 79, 70, 176, 1, 27, 69, 78, 84, 65, 84, 73, 79, + 78, 32, 70, 79, 82, 77, 32, 70, 79, 82, 32, 86, 69, 82, 84, 73, 67, 65, + 76, 32, 169, 221, 8, 10, 67, 82, 73, 80, 84, 73, 79, 78, 32, 84, 68, 198, + 1, 67, 22, 69, 46, 72, 50, 73, 94, 76, 188, 1, 6, 82, 73, 71, 72, 84, 32, + 192, 2, 6, 87, 65, 86, 89, 32, 76, 250, 158, 4, 83, 212, 220, 4, 9, 84, + 87, 79, 32, 68, 79, 84, 32, 76, 135, 115, 81, 4, 143, 193, 2, 79, 6, 158, + 135, 9, 77, 2, 78, 151, 169, 2, 88, 2, 189, 160, 9, 7, 79, 82, 73, 90, 79, 78, 84, 4, 49, 10, 68, 69, 79, 71, 82, 65, 80, 72, 73, 67, 4, 11, 32, - 4, 218, 235, 9, 67, 35, 70, 22, 40, 4, 69, 70, 84, 32, 143, 214, 10, 79, - 20, 112, 6, 87, 72, 73, 84, 69, 32, 142, 1, 66, 42, 68, 186, 100, 67, - 166, 7, 65, 222, 203, 7, 80, 238, 7, 83, 39, 84, 4, 162, 2, 67, 255, 99, - 76, 22, 110, 66, 42, 68, 36, 6, 87, 72, 73, 84, 69, 32, 150, 100, 67, - 166, 7, 65, 222, 203, 7, 80, 238, 7, 83, 39, 84, 2, 145, 101, 6, 76, 65, - 67, 75, 32, 76, 2, 197, 107, 5, 79, 85, 66, 76, 69, 6, 74, 67, 17, 14, - 76, 69, 78, 84, 73, 67, 85, 76, 65, 82, 32, 66, 82, 65, 2, 227, 99, 79, - 4, 246, 234, 11, 67, 177, 29, 2, 75, 67, 2, 187, 210, 10, 79, 22, 46, 78, - 156, 1, 2, 86, 65, 231, 164, 12, 77, 10, 34, 84, 133, 211, 6, 2, 67, 69, - 6, 26, 32, 53, 2, 69, 82, 2, 21, 3, 83, 67, 82, 2, 205, 193, 10, 2, 69, - 69, 5, 17, 2, 32, 73, 2, 223, 235, 11, 67, 10, 60, 5, 67, 89, 32, 77, 69, - 29, 6, 84, 69, 32, 85, 83, 69, 2, 213, 171, 7, 2, 83, 83, 8, 26, 32, 231, - 180, 8, 45, 4, 134, 166, 10, 84, 139, 121, 79, 14, 98, 74, 30, 80, 90, - 83, 156, 34, 5, 72, 73, 66, 73, 84, 173, 245, 8, 6, 66, 73, 78, 71, 32, - 67, 2, 213, 167, 5, 2, 69, 67, 6, 64, 6, 79, 82, 84, 73, 79, 78, 137, - 157, 11, 4, 69, 82, 84, 89, 5, 183, 215, 5, 65, 2, 173, 250, 10, 4, 69, + 4, 246, 241, 9, 67, 35, 70, 22, 40, 4, 69, 70, 84, 32, 143, 221, 10, 79, + 20, 112, 6, 87, 72, 73, 84, 69, 32, 142, 1, 66, 42, 68, 142, 101, 67, + 166, 7, 65, 214, 207, 7, 80, 250, 7, 83, 39, 84, 4, 162, 2, 67, 211, 100, + 76, 22, 110, 66, 42, 68, 36, 6, 87, 72, 73, 84, 69, 32, 234, 100, 67, + 166, 7, 65, 214, 207, 7, 80, 250, 7, 83, 39, 84, 2, 229, 101, 6, 76, 65, + 67, 75, 32, 76, 2, 153, 108, 5, 79, 85, 66, 76, 69, 6, 74, 67, 17, 14, + 76, 69, 78, 84, 73, 67, 85, 76, 65, 82, 32, 66, 82, 65, 2, 183, 100, 79, + 4, 142, 245, 11, 67, 177, 29, 2, 75, 67, 2, 187, 217, 10, 79, 22, 46, 78, + 156, 1, 2, 86, 65, 255, 174, 12, 77, 10, 34, 84, 189, 215, 6, 2, 67, 69, + 6, 26, 32, 53, 2, 69, 82, 2, 21, 3, 83, 67, 82, 2, 205, 200, 10, 2, 69, + 69, 5, 17, 2, 32, 73, 2, 247, 245, 11, 67, 10, 60, 5, 67, 89, 32, 77, 69, + 29, 6, 84, 69, 32, 85, 83, 69, 2, 253, 175, 7, 2, 83, 83, 8, 26, 32, 179, + 185, 8, 45, 4, 254, 172, 10, 84, 171, 124, 79, 14, 98, 74, 30, 80, 90, + 83, 128, 34, 5, 72, 73, 66, 73, 84, 229, 251, 8, 6, 66, 73, 78, 71, 32, + 67, 2, 173, 172, 5, 2, 69, 67, 6, 64, 6, 79, 82, 84, 73, 79, 78, 161, + 167, 11, 4, 69, 82, 84, 89, 5, 143, 220, 5, 65, 2, 193, 129, 11, 4, 69, 82, 80, 73, 60, 76, 14, 65, 76, 84, 69, 82, 32, 80, 65, 72, 76, 65, 86, 73, 32, 215, 5, 89, 58, 172, 1, 15, 70, 79, 85, 82, 32, 68, 79, 84, 83, 32, 87, 73, 84, 72, 32, 32, 7, 76, 69, 84, 84, 69, 82, 32, 230, 2, 78, - 154, 32, 83, 1, 8, 84, 85, 82, 78, 69, 68, 32, 83, 4, 246, 242, 10, 67, - 247, 114, 68, 36, 166, 1, 65, 22, 68, 34, 76, 22, 77, 50, 87, 254, 169, - 4, 71, 90, 90, 34, 83, 66, 89, 198, 207, 1, 72, 234, 5, 75, 174, 81, 66, - 170, 225, 4, 78, 134, 2, 84, 219, 103, 80, 2, 223, 170, 4, 76, 2, 11, 65, - 2, 227, 210, 6, 76, 2, 251, 170, 4, 65, 2, 25, 4, 69, 77, 45, 81, 2, 255, - 128, 6, 79, 2, 37, 7, 65, 87, 45, 65, 89, 73, 78, 2, 149, 205, 1, 2, 45, - 82, 14, 33, 6, 85, 77, 66, 69, 82, 32, 14, 42, 84, 202, 170, 4, 79, 191, - 236, 2, 70, 8, 42, 87, 250, 191, 10, 72, 207, 162, 1, 69, 4, 182, 194, - 10, 69, 239, 239, 1, 79, 2, 243, 132, 12, 67, 18, 252, 1, 4, 78, 67, 84, + 254, 31, 83, 1, 8, 84, 85, 82, 78, 69, 68, 32, 83, 4, 138, 250, 10, 67, + 251, 117, 68, 36, 166, 1, 65, 22, 68, 34, 76, 22, 77, 50, 87, 206, 172, + 4, 71, 90, 90, 34, 83, 66, 89, 206, 209, 1, 72, 234, 5, 75, 142, 81, 66, + 138, 231, 4, 78, 134, 2, 84, 219, 103, 80, 2, 175, 173, 4, 76, 2, 11, 65, + 2, 155, 215, 6, 76, 2, 203, 173, 4, 65, 2, 25, 4, 69, 77, 45, 81, 2, 215, + 133, 6, 79, 2, 37, 7, 65, 87, 45, 65, 89, 73, 78, 2, 173, 206, 1, 2, 45, + 82, 14, 33, 6, 85, 77, 66, 69, 82, 32, 14, 42, 84, 154, 173, 4, 79, 159, + 238, 2, 70, 8, 42, 87, 250, 198, 10, 72, 231, 165, 1, 69, 4, 182, 201, + 10, 69, 135, 243, 1, 79, 2, 139, 143, 12, 67, 18, 252, 1, 4, 78, 67, 84, 85, 94, 82, 56, 19, 84, 32, 76, 73, 84, 84, 69, 82, 32, 73, 78, 32, 73, - 84, 83, 32, 80, 76, 65, 178, 151, 1, 83, 132, 42, 20, 66, 76, 73, 67, 32, - 65, 68, 68, 82, 69, 83, 83, 32, 76, 79, 85, 68, 83, 80, 69, 166, 237, 10, - 49, 3, 50, 4, 164, 222, 10, 9, 83, 32, 69, 76, 69, 86, 65, 84, 85, 129, - 147, 1, 5, 65, 84, 73, 79, 78, 4, 32, 2, 80, 76, 155, 152, 12, 83, 2, - 175, 167, 11, 69, 2, 11, 67, 2, 135, 153, 11, 69, 40, 98, 65, 180, 6, 6, - 69, 83, 84, 73, 79, 78, 254, 136, 6, 79, 229, 143, 5, 5, 73, 78, 67, 85, + 84, 83, 32, 80, 76, 65, 178, 152, 1, 83, 156, 42, 20, 66, 76, 73, 67, 32, + 65, 68, 68, 82, 69, 83, 83, 32, 76, 79, 85, 68, 83, 80, 69, 166, 246, 10, + 49, 3, 50, 4, 172, 229, 10, 9, 83, 32, 69, 76, 69, 86, 65, 84, 85, 145, + 150, 1, 5, 65, 84, 73, 79, 78, 4, 32, 2, 80, 76, 179, 162, 12, 83, 2, + 199, 177, 11, 69, 2, 11, 67, 2, 159, 163, 11, 69, 40, 98, 65, 180, 6, 6, + 69, 83, 84, 73, 79, 78, 174, 141, 6, 79, 205, 149, 5, 5, 73, 78, 67, 85, 78, 30, 104, 2, 68, 82, 240, 4, 9, 84, 69, 82, 78, 73, 79, 78, 32, 73, - 48, 4, 82, 84, 69, 82, 143, 132, 11, 79, 24, 56, 4, 65, 78, 84, 32, 157, + 48, 4, 82, 84, 69, 82, 231, 141, 11, 79, 24, 56, 4, 65, 78, 84, 32, 157, 4, 5, 85, 80, 76, 69, 32, 20, 44, 6, 85, 80, 80, 69, 82, 32, 131, 2, 76, 16, 56, 4, 76, 69, 70, 84, 249, 1, 5, 82, 73, 71, 72, 84, 11, 29, 5, 32, 65, 78, 68, 32, 8, 108, 6, 76, 79, 87, 69, 82, 32, 53, 17, 85, 80, 80, 69, 82, 32, 82, 73, 71, 72, 84, 32, 65, 78, 68, 32, 76, 4, 192, 1, 5, 76, - 69, 70, 84, 32, 159, 254, 11, 82, 4, 11, 79, 4, 11, 87, 4, 213, 254, 11, + 69, 70, 84, 32, 183, 136, 12, 82, 4, 11, 79, 4, 11, 87, 4, 237, 136, 12, 2, 69, 82, 7, 65, 14, 32, 65, 78, 68, 32, 76, 79, 87, 69, 82, 32, 76, 69, 70, 4, 11, 84, 5, 11, 32, 2, 21, 3, 65, 78, 68, 2, 17, 2, 32, 76, 2, 17, - 2, 79, 87, 2, 137, 213, 10, 2, 69, 82, 4, 22, 73, 239, 37, 80, 2, 177, - 228, 8, 7, 78, 84, 69, 71, 82, 65, 76, 2, 17, 2, 32, 78, 2, 159, 222, 10, - 79, 6, 34, 32, 161, 197, 5, 2, 69, 68, 4, 162, 139, 5, 69, 175, 218, 6, - 77, 220, 9, 114, 65, 142, 8, 69, 220, 27, 6, 72, 73, 78, 79, 67, 69, 34, - 73, 250, 87, 76, 46, 79, 198, 19, 85, 243, 149, 11, 83, 62, 110, 67, 104, - 2, 68, 73, 130, 1, 73, 162, 5, 84, 172, 246, 7, 4, 66, 66, 73, 84, 214, - 238, 3, 90, 235, 56, 77, 6, 40, 4, 73, 78, 71, 32, 159, 250, 8, 67, 4, - 192, 208, 10, 7, 77, 79, 84, 79, 82, 67, 89, 199, 48, 67, 8, 66, 79, 141, - 180, 8, 10, 67, 65, 76, 32, 83, 89, 77, 66, 79, 76, 7, 168, 184, 6, 4, - 65, 67, 84, 73, 229, 181, 4, 2, 32, 66, 36, 60, 5, 76, 87, 65, 89, 32, - 46, 78, 21, 4, 83, 69, 68, 32, 4, 240, 131, 9, 2, 84, 82, 155, 251, 1, - 67, 5, 243, 133, 11, 66, 28, 152, 1, 3, 68, 79, 84, 34, 73, 48, 4, 72, - 65, 78, 68, 182, 1, 77, 38, 83, 166, 177, 7, 70, 206, 151, 2, 67, 161, - 197, 1, 7, 66, 65, 67, 75, 32, 79, 70, 5, 29, 5, 84, 69, 68, 32, 73, 2, - 209, 40, 8, 78, 84, 69, 82, 80, 79, 76, 65, 7, 33, 6, 32, 87, 73, 84, 72, - 32, 4, 214, 27, 70, 245, 194, 2, 28, 80, 65, 82, 84, 32, 66, 69, 84, 87, - 69, 69, 78, 32, 77, 73, 68, 68, 76, 69, 32, 65, 78, 68, 32, 82, 73, 78, - 71, 6, 230, 151, 11, 67, 2, 68, 3, 82, 4, 60, 9, 77, 65, 76, 76, 32, 76, - 69, 70, 84, 179, 251, 10, 81, 2, 229, 158, 8, 2, 32, 83, 5, 243, 254, 11, - 73, 250, 1, 226, 1, 67, 132, 4, 2, 68, 32, 64, 2, 71, 73, 144, 1, 5, 74, - 65, 78, 71, 32, 202, 4, 76, 32, 8, 77, 73, 78, 68, 69, 82, 32, 82, 34, - 80, 106, 83, 136, 1, 5, 84, 85, 82, 78, 32, 42, 86, 209, 199, 1, 5, 70, - 69, 82, 69, 78, 26, 114, 69, 60, 3, 89, 67, 76, 146, 209, 5, 79, 205, - 155, 4, 13, 82, 69, 65, 84, 73, 79, 78, 65, 76, 32, 86, 69, 72, 4, 38, - 73, 209, 198, 10, 3, 80, 84, 65, 2, 163, 254, 11, 80, 18, 78, 69, 53, 15, - 73, 78, 71, 32, 83, 89, 77, 66, 79, 76, 32, 70, 79, 82, 32, 2, 29, 5, 68, - 32, 80, 65, 80, 2, 211, 179, 10, 69, 16, 100, 5, 84, 89, 80, 69, 45, 173, - 130, 5, 14, 71, 69, 78, 69, 82, 73, 67, 32, 77, 65, 84, 69, 82, 73, 14, - 58, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 3, 55, 2, 133, 210, 5, 6, 32, - 80, 76, 65, 83, 84, 4, 42, 65, 205, 255, 4, 4, 71, 73, 70, 84, 2, 231, - 190, 3, 80, 54, 120, 4, 83, 84, 69, 82, 213, 244, 5, 20, 79, 78, 65, 76, - 32, 73, 78, 68, 73, 67, 65, 84, 79, 82, 32, 83, 89, 77, 66, 79, 2, 235, - 170, 10, 69, 74, 128, 1, 15, 67, 79, 78, 83, 79, 78, 65, 78, 84, 32, 83, - 73, 71, 78, 32, 44, 7, 76, 69, 84, 84, 69, 82, 32, 226, 1, 83, 35, 86, 8, - 146, 151, 10, 78, 130, 254, 1, 72, 3, 82, 46, 162, 1, 78, 186, 253, 7, - 77, 214, 147, 4, 66, 2, 67, 2, 68, 2, 71, 2, 72, 2, 74, 2, 75, 2, 76, 2, - 80, 2, 82, 2, 83, 2, 84, 2, 87, 2, 89, 187, 2, 65, 12, 154, 254, 7, 89, - 166, 31, 71, 206, 243, 3, 68, 187, 2, 65, 2, 11, 69, 2, 211, 169, 11, 67, - 18, 64, 10, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 139, 214, 9, 73, 16, - 54, 69, 182, 209, 11, 65, 186, 64, 73, 2, 79, 3, 85, 7, 234, 145, 12, 65, - 3, 85, 2, 217, 254, 10, 3, 73, 69, 86, 2, 193, 193, 11, 3, 73, 66, 66, 2, - 41, 8, 76, 65, 67, 69, 77, 69, 78, 84, 2, 17, 2, 32, 67, 2, 193, 214, 10, - 5, 72, 65, 82, 65, 67, 8, 32, 2, 84, 82, 231, 254, 6, 80, 6, 152, 138, 8, - 16, 73, 67, 84, 69, 68, 32, 76, 69, 70, 84, 32, 69, 78, 84, 82, 89, 135, - 245, 3, 79, 6, 242, 249, 10, 83, 194, 106, 76, 31, 82, 70, 64, 4, 69, 82, - 83, 69, 197, 246, 3, 6, 79, 76, 86, 73, 78, 71, 68, 30, 32, 169, 3, 2, - 68, 32, 20, 184, 1, 6, 67, 72, 69, 67, 75, 69, 28, 2, 76, 73, 108, 7, 83, - 79, 76, 73, 68, 85, 83, 232, 229, 7, 16, 84, 73, 76, 68, 69, 32, 79, 80, - 69, 82, 65, 84, 79, 82, 32, 65, 195, 253, 2, 73, 2, 197, 243, 10, 2, 82, - 32, 4, 152, 212, 3, 18, 71, 72, 84, 32, 70, 79, 85, 82, 32, 80, 79, 73, - 78, 84, 69, 68, 32, 80, 135, 237, 1, 78, 9, 11, 32, 6, 240, 166, 5, 9, - 80, 82, 69, 67, 69, 68, 73, 78, 71, 166, 161, 3, 79, 251, 154, 1, 87, 48, - 248, 2, 5, 65, 78, 71, 76, 69, 20, 7, 68, 79, 85, 66, 76, 69, 32, 118, - 78, 20, 5, 70, 79, 82, 75, 69, 70, 80, 82, 82, 214, 1, 83, 106, 84, 236, - 238, 6, 30, 72, 65, 78, 68, 32, 87, 73, 84, 72, 32, 77, 73, 68, 68, 76, - 69, 32, 70, 73, 78, 71, 69, 82, 32, 69, 88, 84, 69, 78, 68, 198, 190, 2, - 67, 114, 81, 180, 102, 6, 69, 77, 80, 84, 89, 32, 253, 93, 7, 86, 73, 67, - 84, 79, 82, 89, 5, 247, 231, 3, 32, 6, 40, 3, 80, 82, 73, 41, 3, 83, 84, - 82, 4, 17, 2, 77, 69, 5, 195, 184, 3, 32, 2, 29, 5, 79, 75, 69, 32, 78, - 2, 155, 187, 6, 79, 2, 49, 10, 68, 32, 80, 65, 82, 65, 71, 82, 65, 80, 2, - 179, 4, 72, 4, 36, 3, 73, 76, 67, 239, 235, 10, 82, 2, 11, 82, 2, 217, - 254, 10, 2, 79, 87, 6, 156, 1, 17, 65, 73, 83, 69, 68, 32, 72, 65, 78, - 68, 32, 87, 73, 84, 72, 32, 70, 148, 107, 8, 79, 84, 65, 84, 69, 68, 32, - 70, 253, 176, 6, 4, 73, 71, 72, 84, 2, 209, 112, 9, 73, 78, 71, 69, 82, - 83, 32, 83, 80, 4, 156, 134, 1, 17, 65, 78, 83, 45, 83, 69, 82, 73, 70, - 32, 67, 65, 80, 73, 84, 65, 76, 191, 174, 7, 69, 10, 88, 4, 73, 76, 68, - 69, 28, 7, 82, 73, 80, 76, 69, 32, 80, 225, 160, 7, 3, 72, 85, 77, 5, - 237, 235, 4, 2, 32, 69, 2, 143, 232, 10, 82, 2, 11, 82, 2, 143, 196, 11, - 79, 147, 4, 228, 1, 4, 66, 66, 79, 78, 152, 1, 3, 67, 69, 32, 60, 3, 71, - 72, 84, 188, 81, 2, 78, 71, 252, 1, 23, 83, 73, 78, 71, 32, 68, 73, 65, - 71, 79, 78, 65, 76, 32, 67, 82, 79, 83, 83, 73, 78, 71, 32, 198, 222, 5, - 65, 227, 165, 4, 70, 19, 37, 7, 32, 65, 82, 82, 79, 87, 32, 16, 88, 3, - 76, 69, 70, 0, 4, 82, 73, 71, 72, 178, 197, 4, 85, 161, 142, 7, 3, 68, - 79, 87, 4, 207, 252, 1, 84, 4, 26, 67, 135, 244, 9, 66, 2, 157, 145, 1, - 3, 82, 65, 67, 224, 3, 110, 32, 190, 36, 45, 152, 12, 11, 72, 65, 78, 68, - 32, 73, 78, 84, 69, 82, 73, 29, 6, 87, 65, 82, 68, 83, 32, 202, 1, 166, - 2, 65, 132, 6, 2, 66, 76, 62, 67, 184, 1, 2, 68, 79, 242, 1, 70, 60, 2, - 72, 65, 176, 5, 13, 74, 85, 83, 84, 73, 70, 73, 69, 68, 32, 76, 69, 70, - 20, 2, 76, 79, 66, 78, 82, 79, 122, 80, 148, 1, 2, 82, 65, 58, 83, 154, - 6, 84, 160, 5, 9, 86, 69, 82, 84, 73, 67, 65, 76, 32, 147, 1, 87, 28, 22, - 78, 163, 4, 82, 22, 24, 2, 68, 32, 39, 71, 4, 170, 50, 76, 21, 3, 85, 80, - 80, 18, 26, 69, 17, 2, 76, 69, 2, 203, 26, 82, 17, 11, 32, 14, 154, 1, - 66, 44, 8, 68, 79, 84, 84, 69, 68, 32, 83, 2, 83, 112, 5, 87, 73, 84, 72, - 32, 189, 212, 10, 12, 86, 65, 82, 73, 65, 78, 84, 32, 87, 73, 84, 72, 4, - 173, 210, 10, 6, 82, 65, 67, 75, 69, 84, 2, 37, 7, 85, 66, 83, 84, 73, - 84, 85, 2, 25, 4, 84, 73, 79, 78, 2, 21, 3, 32, 77, 65, 2, 171, 138, 1, - 82, 4, 68, 11, 68, 79, 87, 78, 87, 65, 82, 68, 83, 32, 90, 139, 247, 8, - 65, 2, 141, 218, 10, 5, 73, 71, 90, 65, 71, 6, 18, 67, 79, 82, 2, 41, 8, - 32, 71, 82, 69, 65, 84, 69, 82, 2, 249, 24, 4, 45, 84, 72, 65, 4, 41, 8, - 79, 87, 32, 87, 73, 84, 72, 32, 4, 144, 234, 7, 7, 67, 73, 82, 67, 76, - 69, 68, 207, 182, 2, 83, 4, 25, 4, 65, 67, 75, 32, 4, 130, 27, 76, 223, - 218, 7, 84, 12, 38, 85, 166, 26, 79, 243, 235, 2, 69, 8, 53, 11, 82, 76, - 89, 32, 66, 82, 65, 67, 75, 69, 84, 9, 11, 32, 6, 44, 4, 77, 73, 68, 68, - 250, 10, 76, 27, 85, 2, 221, 186, 10, 2, 76, 69, 12, 38, 84, 41, 5, 85, - 66, 76, 69, 32, 2, 137, 17, 6, 84, 69, 68, 32, 83, 85, 10, 50, 65, 94, - 87, 214, 162, 3, 81, 199, 199, 4, 80, 4, 162, 31, 78, 173, 161, 3, 15, - 82, 82, 79, 87, 32, 87, 73, 84, 72, 32, 82, 79, 85, 78, 68, 2, 139, 24, - 73, 6, 26, 73, 155, 131, 3, 76, 4, 238, 215, 8, 86, 191, 97, 83, 28, 32, - 3, 76, 70, 32, 187, 4, 78, 26, 128, 1, 8, 65, 78, 68, 32, 76, 69, 70, 84, - 62, 66, 90, 70, 82, 72, 50, 82, 58, 84, 70, 87, 246, 13, 76, 22, 85, 175, - 227, 8, 77, 2, 29, 5, 32, 72, 65, 76, 70, 2, 201, 217, 8, 2, 32, 87, 6, - 11, 76, 6, 40, 4, 65, 67, 75, 32, 183, 188, 10, 79, 4, 158, 154, 10, 67, - 207, 11, 83, 4, 58, 79, 237, 156, 3, 8, 76, 89, 73, 78, 71, 32, 83, 65, - 2, 131, 202, 9, 76, 2, 209, 216, 8, 7, 79, 82, 73, 90, 79, 78, 84, 2, 33, - 6, 85, 78, 78, 73, 78, 71, 2, 203, 238, 6, 32, 2, 153, 173, 5, 12, 82, - 73, 80, 76, 69, 32, 68, 65, 83, 72, 32, 72, 2, 209, 167, 10, 4, 72, 73, - 84, 69, 2, 173, 152, 1, 16, 68, 32, 84, 69, 76, 69, 80, 72, 79, 78, 69, - 32, 82, 69, 67, 69, 4, 187, 231, 7, 84, 2, 145, 152, 11, 11, 87, 32, 80, - 65, 82, 65, 80, 72, 82, 65, 83, 2, 177, 4, 16, 79, 82, 77, 65, 76, 32, - 70, 65, 67, 84, 79, 82, 32, 83, 69, 77, 8, 74, 85, 166, 221, 8, 78, 225, - 189, 1, 8, 80, 69, 78, 32, 83, 81, 85, 65, 2, 221, 233, 10, 6, 84, 69, - 82, 32, 74, 79, 8, 49, 10, 65, 82, 69, 78, 84, 72, 69, 83, 73, 83, 9, 11, - 32, 6, 34, 76, 26, 85, 255, 196, 9, 69, 2, 157, 37, 2, 79, 87, 2, 133, - 37, 2, 80, 80, 2, 217, 10, 10, 73, 83, 69, 68, 32, 79, 77, 73, 83, 83, - 40, 62, 45, 70, 69, 78, 73, 68, 2, 80, 69, 126, 81, 227, 2, 85, 2, 173, - 128, 8, 12, 83, 72, 65, 80, 69, 68, 32, 66, 65, 71, 32, 68, 4, 26, 77, - 191, 236, 8, 86, 2, 217, 212, 10, 7, 73, 68, 73, 82, 69, 67, 84, 4, 210, - 150, 3, 78, 169, 252, 7, 8, 68, 69, 87, 65, 89, 83, 32, 85, 8, 32, 4, 65, - 75, 69, 82, 67, 69, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 246, 252, 3, 79, - 55, 84, 2, 137, 5, 2, 67, 72, 20, 57, 12, 85, 65, 82, 69, 32, 66, 82, 65, - 67, 75, 69, 84, 21, 11, 32, 18, 84, 3, 76, 79, 87, 0, 3, 85, 80, 80, 28, - 5, 87, 73, 84, 72, 32, 227, 191, 9, 69, 2, 245, 230, 3, 2, 69, 82, 12, - 96, 8, 84, 73, 67, 75, 32, 73, 78, 32, 230, 6, 81, 166, 236, 7, 85, 134, - 126, 68, 135, 193, 2, 83, 4, 244, 229, 3, 6, 66, 79, 84, 84, 79, 77, 1, - 3, 84, 79, 80, 2, 165, 4, 6, 66, 83, 84, 73, 84, 85, 26, 54, 72, 130, 3, - 82, 130, 223, 7, 79, 235, 204, 2, 65, 14, 62, 73, 116, 5, 79, 85, 71, 72, - 84, 45, 4, 82, 69, 69, 32, 4, 21, 3, 82, 68, 32, 4, 68, 4, 73, 78, 68, - 85, 221, 211, 1, 7, 87, 72, 73, 84, 69, 32, 82, 2, 215, 166, 11, 67, 2, - 11, 32, 2, 213, 136, 3, 3, 66, 85, 66, 8, 60, 9, 81, 85, 65, 82, 84, 69, - 82, 83, 32, 151, 230, 8, 69, 6, 34, 76, 22, 85, 139, 236, 8, 66, 2, 37, - 2, 79, 87, 2, 17, 2, 80, 80, 2, 227, 230, 8, 69, 8, 34, 65, 89, 4, 73, - 65, 78, 71, 2, 33, 6, 78, 83, 80, 79, 83, 73, 2, 11, 84, 2, 17, 2, 73, - 79, 2, 147, 138, 11, 78, 6, 32, 2, 76, 69, 159, 229, 8, 85, 5, 41, 8, 32, - 65, 66, 79, 86, 69, 32, 76, 2, 181, 178, 9, 2, 69, 70, 6, 18, 66, 95, 82, - 4, 68, 9, 65, 82, 32, 87, 73, 84, 72, 32, 81, 213, 191, 10, 2, 79, 88, 2, - 211, 223, 8, 85, 2, 189, 188, 9, 3, 85, 76, 69, 14, 22, 72, 203, 1, 73, - 12, 25, 4, 73, 84, 69, 32, 12, 54, 67, 54, 76, 206, 210, 7, 80, 238, 7, - 83, 39, 84, 4, 26, 79, 163, 207, 7, 85, 2, 65, 3, 82, 78, 69, 2, 41, 8, - 69, 78, 84, 73, 67, 85, 76, 65, 2, 183, 134, 11, 82, 2, 225, 199, 6, 6, - 71, 71, 76, 89, 32, 70, 62, 118, 70, 226, 2, 72, 128, 1, 9, 80, 79, 73, - 78, 84, 73, 78, 71, 32, 214, 4, 83, 197, 1, 6, 84, 79, 45, 76, 69, 70, - 18, 33, 6, 65, 67, 73, 78, 71, 32, 18, 116, 14, 65, 82, 77, 69, 78, 73, - 65, 78, 32, 69, 84, 69, 82, 78, 20, 4, 66, 65, 83, 83, 16, 3, 70, 73, 83, - 87, 83, 2, 255, 159, 8, 73, 2, 175, 43, 73, 6, 26, 72, 151, 214, 11, 84, - 5, 11, 32, 2, 233, 176, 8, 6, 87, 73, 84, 72, 32, 79, 8, 140, 208, 3, 10, - 86, 65, 83, 84, 73, 32, 83, 73, 71, 78, 195, 223, 4, 78, 2, 81, 18, 65, - 78, 68, 69, 68, 32, 73, 78, 84, 69, 82, 76, 65, 67, 69, 68, 32, 80, 2, - 21, 3, 69, 78, 84, 2, 251, 150, 10, 65, 30, 90, 65, 30, 67, 94, 68, 58, - 77, 58, 82, 182, 1, 83, 74, 84, 210, 172, 8, 69, 179, 124, 71, 4, 90, 78, - 159, 175, 8, 84, 2, 29, 5, 85, 82, 86, 69, 68, 2, 17, 2, 32, 65, 2, 11, - 78, 2, 217, 255, 10, 2, 71, 76, 4, 136, 131, 3, 5, 79, 85, 66, 76, 69, - 179, 188, 6, 73, 2, 165, 184, 10, 9, 65, 71, 78, 73, 70, 89, 73, 78, 71, - 10, 38, 79, 154, 178, 9, 65, 235, 29, 73, 6, 92, 5, 67, 75, 69, 84, 32, - 213, 177, 9, 12, 76, 76, 69, 82, 32, 67, 79, 65, 83, 84, 69, 82, 4, 176, - 43, 3, 66, 79, 79, 143, 208, 10, 83, 2, 11, 84, 2, 21, 3, 73, 67, 75, 2, - 185, 187, 6, 4, 32, 70, 73, 71, 2, 239, 234, 7, 65, 4, 46, 72, 85, 7, 73, - 68, 69, 32, 65, 82, 67, 2, 17, 2, 65, 68, 2, 17, 2, 69, 68, 2, 209, 172, - 10, 6, 32, 87, 72, 73, 84, 69, 2, 11, 32, 2, 201, 239, 8, 8, 67, 76, 79, - 67, 75, 87, 73, 83, 8, 17, 2, 84, 32, 8, 86, 73, 40, 4, 79, 86, 69, 82, - 176, 134, 5, 5, 69, 77, 66, 69, 68, 139, 133, 6, 77, 2, 17, 2, 83, 79, 2, - 131, 135, 1, 76, 2, 135, 155, 3, 82, 2, 141, 187, 10, 2, 79, 82, 214, 1, - 160, 1, 5, 65, 82, 82, 79, 87, 130, 9, 66, 86, 68, 210, 1, 70, 122, 72, - 178, 6, 76, 26, 79, 34, 80, 50, 82, 70, 83, 94, 84, 206, 8, 87, 202, 197, - 8, 67, 47, 81, 75, 26, 32, 195, 147, 9, 45, 70, 94, 65, 170, 2, 70, 110, - 84, 184, 1, 5, 87, 73, 84, 72, 32, 129, 160, 1, 4, 79, 86, 69, 82, 12, - 40, 5, 66, 79, 86, 69, 32, 143, 1, 78, 10, 70, 82, 216, 163, 1, 5, 83, - 72, 79, 82, 84, 222, 194, 3, 65, 55, 84, 4, 37, 7, 69, 86, 69, 82, 83, - 69, 32, 4, 138, 230, 4, 65, 55, 84, 2, 61, 13, 68, 32, 85, 80, 80, 69, - 82, 32, 65, 78, 68, 32, 76, 2, 17, 2, 79, 87, 2, 129, 213, 8, 2, 69, 82, - 6, 25, 4, 82, 79, 77, 32, 6, 36, 3, 66, 65, 82, 187, 213, 8, 68, 5, 189, - 1, 6, 32, 84, 79, 32, 66, 76, 10, 56, 7, 72, 82, 79, 85, 71, 72, 32, 65, - 3, 79, 32, 66, 6, 224, 224, 4, 3, 83, 85, 80, 234, 207, 4, 71, 247, 149, - 2, 88, 4, 26, 76, 139, 141, 11, 65, 2, 153, 247, 9, 3, 65, 67, 75, 40, - 140, 1, 6, 67, 79, 82, 78, 69, 82, 26, 68, 98, 76, 86, 80, 30, 83, 38, - 84, 138, 210, 8, 77, 38, 78, 122, 69, 150, 153, 1, 72, 171, 165, 1, 86, - 2, 209, 18, 2, 32, 68, 4, 11, 79, 4, 40, 4, 84, 84, 69, 68, 203, 219, 7, - 85, 2, 17, 2, 32, 83, 2, 163, 177, 11, 84, 6, 26, 79, 231, 210, 8, 65, 4, - 26, 87, 251, 194, 11, 79, 2, 157, 201, 3, 2, 69, 82, 2, 193, 145, 9, 2, - 76, 85, 6, 146, 211, 8, 77, 203, 191, 2, 84, 10, 154, 16, 73, 171, 3, 65, - 8, 58, 65, 204, 11, 5, 79, 84, 84, 79, 77, 187, 199, 8, 76, 2, 145, 2, 2, - 67, 75, 14, 48, 6, 79, 85, 66, 76, 69, 32, 167, 225, 8, 65, 12, 40, 5, - 65, 82, 82, 79, 87, 211, 18, 68, 11, 26, 32, 143, 137, 9, 45, 6, 26, 87, - 167, 215, 8, 70, 4, 25, 4, 73, 84, 72, 32, 4, 186, 143, 11, 86, 79, 83, - 4, 40, 4, 82, 79, 78, 84, 195, 210, 8, 73, 2, 193, 209, 8, 14, 45, 84, - 73, 76, 84, 69, 68, 32, 83, 72, 65, 68, 79, 87, 30, 26, 65, 251, 213, 8, - 69, 26, 48, 6, 82, 80, 79, 79, 78, 32, 131, 248, 10, 78, 24, 80, 10, 87, - 73, 84, 72, 32, 66, 65, 82, 66, 32, 197, 152, 1, 4, 79, 86, 69, 82, 22, - 44, 4, 68, 79, 87, 78, 173, 1, 2, 85, 80, 10, 26, 32, 231, 219, 8, 87, 8, - 76, 8, 65, 66, 79, 86, 69, 32, 76, 69, 18, 66, 166, 211, 8, 70, 179, 5, - 84, 2, 227, 2, 70, 2, 253, 222, 4, 7, 69, 76, 79, 87, 32, 76, 79, 12, 26, - 32, 187, 218, 8, 87, 10, 60, 6, 65, 66, 79, 86, 69, 32, 154, 210, 8, 70, - 179, 5, 84, 6, 22, 76, 155, 1, 82, 4, 32, 2, 69, 70, 187, 221, 4, 79, 2, - 213, 144, 2, 24, 84, 87, 65, 82, 68, 83, 32, 72, 65, 82, 80, 79, 79, 78, - 32, 87, 73, 84, 72, 32, 66, 65, 82, 66, 2, 21, 3, 73, 71, 72, 2, 105, 24, - 84, 87, 65, 82, 68, 83, 32, 72, 65, 82, 80, 79, 79, 78, 32, 87, 73, 84, - 72, 32, 66, 65, 82, 66, 2, 11, 32, 2, 139, 241, 1, 68, 2, 141, 1, 2, 69, - 70, 2, 201, 212, 8, 3, 80, 69, 78, 4, 202, 216, 8, 65, 233, 206, 1, 3, - 85, 83, 72, 4, 36, 3, 73, 71, 72, 223, 228, 10, 79, 2, 11, 84, 2, 171, 1, - 45, 6, 32, 2, 81, 85, 215, 207, 8, 65, 4, 26, 73, 239, 207, 8, 65, 2, - 229, 215, 8, 2, 71, 71, 54, 38, 79, 60, 2, 82, 73, 227, 4, 87, 2, 11, 80, - 2, 11, 32, 2, 253, 199, 8, 4, 83, 72, 65, 68, 34, 40, 5, 65, 78, 71, 76, - 69, 255, 3, 80, 30, 56, 8, 45, 72, 69, 65, 68, 69, 68, 32, 251, 219, 8, - 32, 28, 52, 5, 65, 82, 82, 79, 87, 202, 212, 8, 68, 39, 80, 25, 11, 32, - 22, 64, 8, 79, 86, 69, 82, 32, 76, 69, 70, 22, 87, 135, 208, 8, 84, 2, - 183, 207, 8, 84, 18, 25, 4, 73, 84, 72, 32, 18, 128, 1, 7, 68, 79, 85, - 66, 76, 69, 32, 36, 7, 76, 79, 78, 71, 32, 84, 73, 230, 207, 8, 66, 158, - 1, 77, 34, 78, 34, 86, 35, 72, 4, 166, 138, 9, 72, 195, 247, 1, 86, 4, - 11, 80, 4, 11, 32, 4, 18, 68, 35, 85, 2, 181, 208, 8, 3, 79, 87, 78, 2, - 151, 208, 8, 80, 4, 21, 3, 76, 69, 32, 4, 138, 3, 68, 203, 145, 10, 65, - 18, 11, 79, 18, 56, 8, 45, 72, 69, 65, 68, 69, 68, 32, 175, 210, 8, 32, - 16, 76, 6, 65, 82, 82, 79, 87, 32, 213, 1, 8, 84, 82, 73, 80, 76, 69, 32, - 68, 14, 44, 5, 87, 73, 84, 72, 32, 179, 198, 8, 70, 12, 42, 84, 210, 198, - 7, 68, 235, 183, 3, 86, 8, 26, 65, 243, 209, 8, 82, 6, 17, 2, 73, 76, 7, - 33, 6, 32, 87, 73, 84, 72, 32, 4, 250, 197, 7, 68, 235, 183, 3, 86, 2, - 249, 132, 1, 2, 65, 83, 8, 58, 65, 21, 10, 72, 73, 84, 69, 32, 65, 82, - 82, 79, 87, 2, 207, 206, 8, 86, 7, 11, 32, 4, 216, 193, 2, 4, 70, 82, 79, - 77, 219, 145, 6, 87, 19, 66, 32, 136, 1, 6, 69, 68, 32, 80, 76, 65, 21, - 3, 73, 78, 71, 12, 82, 66, 22, 80, 212, 201, 4, 2, 73, 78, 26, 69, 154, - 158, 3, 79, 195, 198, 2, 65, 2, 239, 153, 11, 85, 2, 11, 79, 2, 135, 232, - 10, 73, 2, 247, 245, 10, 78, 2, 209, 199, 3, 2, 32, 66, 4, 24, 2, 70, 65, - 75, 83, 2, 17, 2, 76, 76, 2, 21, 3, 73, 78, 71, 2, 177, 231, 1, 2, 32, - 68, 2, 189, 173, 3, 2, 79, 85, 8, 222, 169, 11, 69, 2, 73, 2, 77, 3, 79, - 126, 136, 2, 2, 67, 75, 20, 2, 76, 76, 188, 2, 4, 77, 65, 78, 32, 194, 8, - 79, 80, 2, 83, 69, 20, 6, 84, 65, 84, 69, 68, 32, 152, 3, 3, 85, 78, 68, - 170, 178, 3, 87, 252, 213, 3, 15, 65, 83, 84, 69, 68, 32, 83, 87, 69, 69, - 84, 32, 80, 79, 84, 185, 166, 2, 2, 66, 79, 5, 251, 138, 11, 69, 10, 130, - 1, 69, 64, 4, 32, 79, 70, 32, 101, 21, 73, 78, 71, 32, 79, 78, 32, 84, - 72, 69, 32, 70, 76, 79, 79, 82, 32, 76, 65, 85, 71, 6, 60, 9, 68, 45, 85, - 80, 32, 78, 69, 87, 83, 33, 2, 82, 32, 2, 11, 80, 2, 175, 131, 2, 65, 4, - 28, 3, 67, 79, 65, 23, 83, 2, 131, 235, 9, 83, 2, 135, 95, 75, 2, 231, - 211, 10, 72, 72, 140, 1, 6, 67, 69, 78, 84, 85, 82, 22, 68, 100, 3, 81, - 85, 73, 28, 8, 78, 85, 77, 69, 82, 65, 76, 32, 182, 4, 83, 114, 85, 135, - 235, 7, 65, 2, 159, 215, 5, 73, 6, 98, 69, 232, 5, 5, 85, 80, 79, 78, 68, - 61, 12, 73, 77, 73, 68, 73, 65, 32, 83, 69, 88, 84, 85, 2, 229, 5, 3, 78, - 65, 82, 48, 142, 1, 70, 136, 1, 3, 79, 78, 69, 134, 1, 83, 66, 84, 232, - 14, 10, 82, 69, 86, 69, 82, 83, 69, 68, 32, 79, 150, 237, 2, 69, 163, - 135, 7, 78, 14, 26, 73, 183, 168, 10, 79, 12, 36, 3, 70, 84, 89, 255, - 254, 2, 86, 7, 11, 32, 4, 194, 196, 5, 84, 177, 221, 4, 5, 69, 65, 82, - 76, 89, 11, 11, 32, 8, 50, 72, 41, 8, 84, 72, 79, 85, 83, 65, 78, 68, 4, - 185, 1, 6, 85, 78, 68, 82, 69, 68, 5, 141, 130, 4, 2, 32, 67, 6, 32, 2, - 73, 88, 159, 172, 9, 69, 5, 241, 159, 10, 2, 32, 76, 10, 42, 69, 150, - 253, 2, 87, 239, 174, 6, 72, 4, 11, 78, 5, 11, 32, 2, 131, 194, 5, 84, - 10, 46, 69, 189, 200, 7, 5, 73, 76, 73, 81, 85, 8, 60, 2, 77, 85, 40, 5, - 83, 84, 69, 82, 84, 21, 2, 88, 84, 2, 17, 2, 78, 67, 2, 231, 199, 7, 73, - 2, 207, 234, 7, 73, 4, 18, 65, 23, 85, 2, 179, 234, 7, 78, 2, 151, 199, - 7, 76, 4, 48, 6, 84, 32, 86, 69, 71, 69, 219, 225, 9, 83, 2, 141, 197, 2, - 2, 84, 65, 5, 179, 210, 9, 84, 10, 166, 2, 70, 32, 11, 72, 69, 65, 86, - 89, 32, 66, 76, 65, 67, 75, 52, 24, 76, 73, 71, 72, 84, 32, 70, 79, 85, - 82, 32, 80, 79, 73, 78, 84, 69, 68, 32, 66, 76, 65, 67, 75, 0, 18, 87, - 72, 73, 84, 69, 32, 70, 79, 85, 82, 32, 80, 79, 73, 78, 84, 69, 68, 161, - 53, 8, 67, 65, 80, 73, 84, 65, 76, 32, 2, 29, 5, 76, 79, 82, 65, 76, 2, - 201, 182, 9, 8, 32, 72, 69, 65, 82, 84, 32, 66, 2, 213, 207, 9, 2, 32, - 67, 16, 74, 32, 89, 14, 69, 68, 32, 83, 89, 77, 66, 79, 76, 32, 70, 79, - 82, 32, 4, 24, 2, 80, 85, 43, 84, 2, 11, 83, 2, 209, 151, 10, 2, 72, 80, - 2, 147, 222, 3, 65, 12, 68, 2, 83, 72, 238, 162, 6, 67, 222, 206, 4, 70, - 2, 76, 147, 17, 88, 4, 40, 4, 85, 65, 78, 71, 159, 241, 10, 79, 2, 171, - 130, 11, 88, 136, 2, 226, 1, 66, 20, 3, 71, 66, 89, 40, 5, 76, 69, 45, - 68, 69, 40, 3, 77, 73, 32, 154, 5, 78, 156, 26, 26, 83, 83, 73, 65, 78, - 32, 65, 83, 84, 82, 79, 76, 79, 71, 73, 67, 65, 76, 32, 83, 89, 77, 66, - 79, 76, 32, 203, 152, 5, 80, 2, 255, 243, 8, 76, 2, 177, 137, 9, 5, 32, - 70, 79, 79, 84, 2, 11, 76, 2, 165, 255, 5, 2, 65, 89, 62, 68, 9, 70, 82, - 65, 67, 84, 73, 79, 78, 32, 102, 78, 171, 198, 2, 68, 8, 40, 4, 79, 78, - 69, 32, 187, 175, 9, 84, 6, 34, 84, 250, 139, 9, 72, 47, 81, 2, 167, 141, - 9, 72, 36, 33, 6, 85, 77, 66, 69, 82, 32, 36, 76, 5, 69, 73, 71, 72, 84, - 38, 70, 92, 2, 78, 73, 22, 79, 18, 83, 83, 84, 4, 158, 137, 3, 32, 231, - 135, 8, 89, 8, 18, 73, 35, 79, 4, 130, 2, 86, 235, 158, 9, 70, 4, 136, 2, - 2, 85, 82, 195, 158, 9, 82, 4, 77, 2, 78, 69, 2, 167, 1, 78, 8, 40, 4, - 69, 86, 69, 78, 1, 2, 73, 88, 4, 206, 135, 3, 32, 159, 246, 7, 84, 10, - 34, 72, 50, 87, 223, 190, 10, 69, 4, 32, 2, 82, 69, 199, 158, 9, 73, 2, - 39, 69, 4, 26, 79, 183, 158, 9, 69, 2, 187, 134, 3, 32, 182, 1, 32, 3, - 73, 67, 32, 147, 25, 78, 178, 1, 220, 1, 6, 66, 69, 76, 71, 84, 72, 20, - 4, 67, 82, 79, 83, 20, 7, 76, 69, 84, 84, 69, 82, 32, 210, 22, 83, 24, 6, - 77, 85, 76, 84, 73, 80, 216, 196, 7, 5, 65, 82, 76, 65, 85, 161, 202, 1, - 7, 84, 86, 73, 77, 65, 68, 85, 2, 135, 166, 9, 79, 2, 235, 197, 7, 83, + 2, 79, 87, 2, 145, 220, 10, 2, 69, 82, 4, 22, 73, 207, 37, 80, 2, 209, + 233, 8, 7, 78, 84, 69, 71, 82, 65, 76, 2, 17, 2, 32, 78, 2, 191, 229, 10, + 79, 6, 34, 32, 249, 201, 5, 2, 69, 68, 4, 214, 148, 11, 69, 147, 91, 77, + 230, 9, 90, 65, 142, 8, 69, 218, 27, 72, 90, 73, 222, 88, 76, 46, 79, + 202, 19, 85, 139, 159, 11, 83, 62, 110, 67, 104, 2, 68, 73, 130, 1, 73, + 162, 5, 84, 244, 250, 7, 4, 66, 66, 73, 84, 194, 244, 3, 90, 235, 56, 77, + 6, 40, 4, 73, 78, 71, 32, 203, 128, 9, 67, 4, 228, 215, 10, 7, 77, 79, + 84, 79, 82, 67, 89, 151, 51, 67, 8, 66, 79, 209, 185, 8, 10, 67, 65, 76, + 32, 83, 89, 77, 66, 79, 76, 7, 252, 188, 6, 4, 65, 67, 84, 73, 193, 184, + 4, 2, 32, 66, 36, 60, 5, 76, 87, 65, 89, 32, 46, 78, 21, 4, 83, 69, 68, + 32, 4, 168, 138, 9, 2, 84, 82, 215, 254, 1, 67, 5, 239, 143, 11, 66, 28, + 152, 1, 3, 68, 79, 84, 34, 73, 48, 4, 72, 65, 78, 68, 182, 1, 77, 38, 83, + 234, 181, 7, 70, 194, 153, 2, 67, 157, 201, 1, 7, 66, 65, 67, 75, 32, 79, + 70, 5, 29, 5, 84, 69, 68, 32, 73, 2, 133, 41, 8, 78, 84, 69, 82, 80, 79, + 76, 65, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 210, 27, 70, 229, 197, 2, + 28, 80, 65, 82, 84, 32, 66, 69, 84, 87, 69, 69, 78, 32, 77, 73, 68, 68, + 76, 69, 32, 65, 78, 68, 32, 82, 73, 78, 71, 6, 154, 162, 11, 67, 2, 68, + 3, 82, 4, 60, 9, 77, 65, 76, 76, 32, 76, 69, 70, 84, 167, 133, 11, 81, 2, + 217, 163, 8, 2, 32, 83, 5, 167, 137, 12, 73, 250, 1, 226, 1, 67, 132, 4, + 2, 68, 32, 64, 2, 71, 73, 144, 1, 5, 74, 65, 78, 71, 32, 202, 4, 76, 32, + 8, 77, 73, 78, 68, 69, 82, 32, 82, 34, 80, 106, 83, 136, 1, 5, 84, 85, + 82, 78, 32, 42, 86, 189, 202, 1, 5, 70, 69, 82, 69, 78, 26, 114, 69, 60, + 3, 89, 67, 76, 134, 214, 5, 79, 145, 157, 4, 13, 82, 69, 65, 84, 73, 79, + 78, 65, 76, 32, 86, 69, 72, 4, 38, 73, 245, 205, 10, 3, 80, 84, 65, 2, + 215, 136, 12, 80, 18, 78, 69, 53, 15, 73, 78, 71, 32, 83, 89, 77, 66, 79, + 76, 32, 70, 79, 82, 32, 2, 29, 5, 68, 32, 80, 65, 80, 2, 239, 186, 10, + 69, 16, 100, 5, 84, 89, 80, 69, 45, 161, 135, 5, 14, 71, 69, 78, 69, 82, + 73, 67, 32, 77, 65, 84, 69, 82, 73, 14, 58, 49, 2, 50, 2, 51, 2, 52, 2, + 53, 2, 54, 3, 55, 2, 249, 214, 5, 6, 32, 80, 76, 65, 83, 84, 4, 42, 65, + 193, 132, 5, 4, 71, 73, 70, 84, 2, 223, 193, 3, 80, 54, 120, 4, 83, 84, + 69, 82, 161, 249, 5, 20, 79, 78, 65, 76, 32, 73, 78, 68, 73, 67, 65, 84, + 79, 82, 32, 83, 89, 77, 66, 79, 2, 135, 178, 10, 69, 74, 128, 1, 15, 67, + 79, 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, 32, 44, 7, 76, 69, + 84, 84, 69, 82, 32, 226, 1, 83, 35, 86, 8, 174, 158, 10, 78, 154, 129, 2, + 72, 3, 82, 46, 162, 1, 78, 246, 129, 8, 77, 206, 153, 4, 66, 2, 67, 2, + 68, 2, 71, 2, 72, 2, 74, 2, 75, 2, 76, 2, 80, 2, 82, 2, 83, 2, 84, 2, 87, + 2, 89, 187, 2, 65, 12, 214, 130, 8, 89, 230, 31, 71, 134, 249, 3, 68, + 187, 2, 65, 2, 11, 69, 2, 135, 180, 11, 67, 18, 64, 10, 79, 87, 69, 76, + 32, 83, 73, 71, 78, 32, 195, 220, 9, 73, 16, 54, 69, 234, 219, 11, 65, + 186, 64, 73, 2, 79, 3, 85, 7, 158, 156, 12, 65, 3, 85, 2, 141, 137, 11, + 3, 73, 69, 86, 2, 245, 203, 11, 3, 73, 66, 66, 2, 41, 8, 76, 65, 67, 69, + 77, 69, 78, 84, 2, 17, 2, 32, 67, 2, 241, 221, 10, 5, 72, 65, 82, 65, 67, + 8, 32, 2, 84, 82, 171, 131, 7, 80, 6, 128, 143, 8, 16, 73, 67, 84, 69, + 68, 32, 76, 69, 70, 84, 32, 69, 78, 84, 82, 89, 211, 250, 3, 79, 6, 166, + 132, 11, 83, 194, 106, 76, 31, 82, 70, 64, 4, 69, 82, 83, 69, 157, 249, + 3, 6, 79, 76, 86, 73, 78, 71, 68, 30, 32, 169, 3, 2, 68, 32, 20, 184, 1, + 6, 67, 72, 69, 67, 75, 69, 28, 2, 76, 73, 108, 7, 83, 79, 76, 73, 68, 85, + 83, 176, 234, 7, 16, 84, 73, 76, 68, 69, 32, 79, 80, 69, 82, 65, 84, 79, + 82, 32, 65, 239, 130, 3, 73, 2, 249, 253, 10, 2, 82, 32, 4, 144, 215, 3, + 18, 71, 72, 84, 32, 70, 79, 85, 82, 32, 80, 79, 73, 78, 84, 69, 68, 32, + 80, 131, 239, 1, 78, 9, 11, 32, 6, 228, 171, 5, 9, 80, 82, 69, 67, 69, + 68, 73, 78, 71, 238, 161, 3, 79, 255, 155, 1, 87, 48, 244, 2, 5, 65, 78, + 71, 76, 69, 20, 7, 68, 79, 85, 66, 76, 69, 32, 118, 78, 20, 5, 70, 79, + 82, 75, 69, 70, 80, 82, 82, 214, 1, 83, 106, 84, 238, 179, 9, 67, 114, + 81, 152, 103, 6, 69, 77, 80, 84, 89, 32, 172, 61, 30, 72, 65, 78, 68, 32, + 87, 73, 84, 72, 32, 77, 73, 68, 68, 76, 69, 32, 70, 73, 78, 71, 69, 82, + 32, 69, 88, 84, 69, 78, 68, 233, 35, 7, 86, 73, 67, 84, 79, 82, 89, 5, + 223, 234, 3, 32, 6, 40, 3, 80, 82, 73, 41, 3, 83, 84, 82, 4, 17, 2, 77, + 69, 5, 191, 187, 3, 32, 2, 29, 5, 79, 75, 69, 32, 78, 2, 231, 191, 6, 79, + 2, 49, 10, 68, 32, 80, 65, 82, 65, 71, 82, 65, 80, 2, 235, 4, 72, 4, 36, + 3, 73, 76, 67, 167, 246, 10, 82, 2, 11, 82, 2, 145, 137, 11, 2, 79, 87, + 6, 156, 1, 17, 65, 73, 83, 69, 68, 32, 72, 65, 78, 68, 32, 87, 73, 84, + 72, 32, 70, 180, 108, 8, 79, 84, 65, 84, 69, 68, 32, 70, 169, 180, 6, 4, + 73, 71, 72, 84, 2, 145, 114, 9, 73, 78, 71, 69, 82, 83, 32, 83, 80, 4, + 220, 135, 1, 17, 65, 78, 83, 45, 83, 69, 82, 73, 70, 32, 67, 65, 80, 73, + 84, 65, 76, 199, 178, 7, 69, 10, 88, 4, 73, 76, 68, 69, 28, 7, 82, 73, + 80, 76, 69, 32, 80, 173, 165, 7, 3, 72, 85, 77, 5, 229, 240, 4, 2, 32, + 69, 2, 199, 242, 10, 82, 4, 52, 5, 73, 78, 79, 67, 69, 165, 161, 8, 2, + 79, 77, 2, 11, 82, 2, 143, 206, 11, 79, 153, 4, 228, 1, 4, 66, 66, 79, + 78, 152, 1, 3, 67, 69, 32, 60, 3, 71, 72, 84, 160, 82, 2, 78, 71, 252, 1, + 23, 83, 73, 78, 71, 32, 68, 73, 65, 71, 79, 78, 65, 76, 32, 67, 82, 79, + 83, 83, 73, 78, 71, 32, 246, 225, 5, 65, 143, 171, 4, 70, 19, 37, 7, 32, + 65, 82, 82, 79, 87, 32, 16, 88, 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, 250, + 201, 4, 85, 217, 147, 7, 3, 68, 79, 87, 4, 135, 255, 1, 84, 4, 26, 67, + 231, 250, 9, 66, 2, 157, 146, 1, 3, 82, 65, 67, 230, 3, 110, 32, 250, 36, + 45, 152, 12, 11, 72, 65, 78, 68, 32, 73, 78, 84, 69, 82, 73, 29, 6, 87, + 65, 82, 68, 83, 32, 206, 1, 166, 2, 65, 132, 6, 2, 66, 76, 62, 67, 184, + 1, 2, 68, 79, 242, 1, 70, 60, 2, 72, 65, 204, 5, 13, 74, 85, 83, 84, 73, + 70, 73, 69, 68, 32, 76, 69, 70, 20, 2, 76, 79, 66, 78, 82, 79, 122, 80, + 180, 1, 2, 82, 65, 58, 83, 154, 6, 84, 160, 5, 9, 86, 69, 82, 84, 73, 67, + 65, 76, 32, 147, 1, 87, 28, 22, 78, 163, 4, 82, 22, 24, 2, 68, 32, 39, + 71, 4, 230, 50, 76, 21, 3, 85, 80, 80, 18, 26, 69, 17, 2, 76, 69, 2, 135, + 27, 82, 17, 11, 32, 14, 154, 1, 66, 44, 8, 68, 79, 84, 84, 69, 68, 32, + 83, 2, 83, 112, 5, 87, 73, 84, 72, 32, 253, 221, 10, 12, 86, 65, 82, 73, + 65, 78, 84, 32, 87, 73, 84, 72, 4, 237, 219, 10, 6, 82, 65, 67, 75, 69, + 84, 2, 37, 7, 85, 66, 83, 84, 73, 84, 85, 2, 25, 4, 84, 73, 79, 78, 2, + 21, 3, 32, 77, 65, 2, 171, 139, 1, 82, 4, 68, 11, 68, 79, 87, 78, 87, 65, + 82, 68, 83, 32, 90, 143, 253, 8, 65, 2, 213, 227, 10, 5, 73, 71, 90, 65, + 71, 6, 18, 67, 79, 82, 2, 41, 8, 32, 71, 82, 69, 65, 84, 69, 82, 2, 181, + 25, 4, 45, 84, 72, 65, 4, 41, 8, 79, 87, 32, 87, 73, 84, 72, 32, 4, 196, + 238, 7, 7, 67, 73, 82, 67, 76, 69, 68, 139, 185, 2, 83, 4, 25, 4, 65, 67, + 75, 32, 4, 190, 27, 76, 227, 222, 7, 84, 12, 38, 85, 226, 26, 79, 251, + 237, 2, 69, 8, 53, 11, 82, 76, 89, 32, 66, 82, 65, 67, 75, 69, 84, 9, 11, + 32, 6, 44, 4, 77, 73, 68, 68, 182, 11, 76, 27, 85, 2, 217, 193, 10, 2, + 76, 69, 12, 38, 84, 41, 5, 85, 66, 76, 69, 32, 2, 197, 17, 6, 84, 69, 68, + 32, 83, 85, 10, 50, 65, 94, 87, 154, 165, 3, 81, 183, 201, 4, 80, 4, 222, + 31, 78, 153, 163, 3, 15, 82, 82, 79, 87, 32, 87, 73, 84, 72, 32, 82, 79, + 85, 78, 68, 2, 199, 24, 73, 6, 26, 73, 223, 133, 3, 76, 4, 242, 221, 8, + 86, 191, 97, 83, 30, 32, 3, 76, 70, 32, 215, 4, 78, 28, 128, 1, 8, 65, + 78, 68, 32, 76, 69, 70, 84, 62, 66, 90, 70, 82, 72, 50, 82, 58, 84, 70, + 87, 178, 14, 76, 22, 85, 247, 232, 8, 77, 2, 29, 5, 32, 72, 65, 76, 70, + 2, 205, 223, 8, 2, 32, 87, 6, 11, 76, 6, 40, 4, 65, 67, 75, 32, 247, 197, + 10, 79, 4, 142, 161, 10, 67, 231, 11, 83, 4, 58, 79, 177, 159, 3, 8, 76, + 89, 73, 78, 71, 32, 83, 65, 2, 207, 208, 9, 76, 2, 213, 222, 8, 7, 79, + 82, 73, 90, 79, 78, 84, 2, 33, 6, 85, 78, 78, 73, 78, 71, 2, 219, 242, 6, + 32, 2, 217, 177, 5, 12, 82, 73, 80, 76, 69, 32, 68, 65, 83, 72, 32, 72, + 4, 29, 5, 72, 73, 84, 69, 32, 4, 210, 158, 10, 67, 239, 49, 69, 2, 145, + 153, 1, 16, 68, 32, 84, 69, 76, 69, 80, 72, 79, 78, 69, 32, 82, 69, 67, + 69, 4, 211, 235, 7, 84, 2, 245, 161, 11, 11, 87, 32, 80, 65, 82, 65, 80, + 72, 82, 65, 83, 2, 209, 4, 16, 79, 82, 77, 65, 76, 32, 70, 65, 67, 84, + 79, 82, 32, 83, 69, 77, 8, 74, 85, 142, 227, 8, 78, 229, 190, 1, 8, 80, + 69, 78, 32, 83, 81, 85, 65, 2, 193, 243, 10, 6, 84, 69, 82, 32, 74, 79, + 10, 49, 10, 65, 82, 69, 78, 84, 72, 69, 83, 73, 83, 11, 11, 32, 8, 66, + 76, 26, 85, 192, 186, 2, 4, 87, 73, 84, 72, 207, 144, 7, 69, 2, 157, 37, + 2, 79, 87, 2, 133, 37, 2, 80, 80, 2, 217, 10, 10, 73, 83, 69, 68, 32, 79, + 77, 73, 83, 83, 40, 62, 45, 70, 69, 78, 73, 68, 2, 80, 69, 126, 81, 227, + 2, 85, 2, 129, 133, 8, 12, 83, 72, 65, 80, 69, 68, 32, 66, 65, 71, 32, + 68, 4, 26, 77, 135, 242, 8, 86, 2, 157, 222, 10, 7, 73, 68, 73, 82, 69, + 67, 84, 4, 218, 152, 3, 78, 229, 131, 8, 8, 68, 69, 87, 65, 89, 83, 32, + 85, 8, 32, 4, 65, 75, 69, 82, 67, 69, 7, 33, 6, 32, 87, 73, 84, 72, 32, + 4, 242, 254, 3, 79, 55, 84, 2, 137, 5, 2, 67, 72, 20, 57, 12, 85, 65, 82, + 69, 32, 66, 82, 65, 67, 75, 69, 84, 21, 11, 32, 18, 84, 3, 76, 79, 87, 0, + 3, 85, 80, 80, 28, 5, 87, 73, 84, 72, 32, 243, 197, 9, 69, 2, 241, 232, + 3, 2, 69, 82, 12, 96, 8, 84, 73, 67, 75, 32, 73, 78, 32, 230, 6, 81, 250, + 240, 7, 85, 250, 126, 68, 131, 197, 2, 83, 4, 240, 231, 3, 6, 66, 79, 84, + 84, 79, 77, 1, 3, 84, 79, 80, 2, 165, 4, 6, 66, 83, 84, 73, 84, 85, 26, + 54, 72, 130, 3, 82, 134, 227, 7, 79, 235, 209, 2, 65, 14, 62, 73, 116, 5, + 79, 85, 71, 72, 84, 45, 4, 82, 69, 69, 32, 4, 21, 3, 82, 68, 32, 4, 68, + 4, 73, 78, 68, 85, 217, 213, 1, 7, 87, 72, 73, 84, 69, 32, 82, 2, 155, + 176, 11, 67, 2, 11, 32, 2, 221, 138, 3, 3, 66, 85, 66, 8, 60, 9, 81, 85, + 65, 82, 84, 69, 82, 83, 32, 223, 235, 8, 69, 6, 34, 76, 22, 85, 211, 241, + 8, 66, 2, 37, 2, 79, 87, 2, 17, 2, 80, 80, 2, 171, 236, 8, 69, 8, 34, 65, + 89, 4, 73, 65, 78, 71, 2, 33, 6, 78, 83, 80, 79, 83, 73, 2, 11, 84, 2, + 17, 2, 73, 79, 2, 215, 147, 11, 78, 6, 32, 2, 76, 69, 231, 234, 8, 85, 5, + 41, 8, 32, 65, 66, 79, 86, 69, 32, 76, 2, 133, 184, 9, 2, 69, 70, 6, 18, + 66, 95, 82, 4, 68, 9, 65, 82, 32, 87, 73, 84, 72, 32, 81, 153, 201, 10, + 2, 79, 88, 2, 155, 229, 8, 85, 2, 225, 194, 9, 3, 85, 76, 69, 14, 22, 72, + 203, 1, 73, 12, 25, 4, 73, 84, 69, 32, 12, 54, 67, 54, 76, 198, 214, 7, + 80, 250, 7, 83, 39, 84, 4, 26, 79, 155, 211, 7, 85, 2, 65, 3, 82, 78, 69, + 2, 41, 8, 69, 78, 84, 73, 67, 85, 76, 65, 2, 251, 143, 11, 82, 2, 181, + 203, 6, 6, 71, 71, 76, 89, 32, 70, 62, 118, 70, 226, 2, 72, 128, 1, 9, + 80, 79, 73, 78, 84, 73, 78, 71, 32, 214, 4, 83, 197, 1, 6, 84, 79, 45, + 76, 69, 70, 18, 33, 6, 65, 67, 73, 78, 71, 32, 18, 116, 14, 65, 82, 77, + 69, 78, 73, 65, 78, 32, 69, 84, 69, 82, 78, 20, 4, 66, 65, 83, 83, 16, 3, + 70, 73, 83, 87, 83, 2, 187, 165, 8, 73, 2, 215, 43, 73, 6, 26, 72, 219, + 223, 11, 84, 5, 11, 32, 2, 177, 182, 8, 6, 87, 73, 84, 72, 32, 79, 8, + 136, 210, 3, 10, 86, 65, 83, 84, 73, 32, 83, 73, 71, 78, 143, 227, 4, 78, + 2, 81, 18, 65, 78, 68, 69, 68, 32, 73, 78, 84, 69, 82, 76, 65, 67, 69, + 68, 32, 80, 2, 21, 3, 69, 78, 84, 2, 187, 157, 10, 65, 30, 90, 65, 30, + 67, 94, 68, 58, 77, 58, 82, 182, 1, 83, 74, 84, 154, 178, 8, 69, 251, + 124, 71, 4, 90, 78, 231, 180, 8, 84, 2, 29, 5, 85, 82, 86, 69, 68, 2, 17, + 2, 32, 65, 2, 11, 78, 2, 157, 137, 11, 2, 71, 76, 4, 144, 133, 3, 5, 79, + 85, 66, 76, 69, 207, 192, 6, 73, 2, 233, 193, 10, 9, 65, 71, 78, 73, 70, + 89, 73, 78, 71, 10, 38, 79, 190, 184, 9, 65, 243, 29, 73, 6, 92, 5, 67, + 75, 69, 84, 32, 249, 183, 9, 12, 76, 76, 69, 82, 32, 67, 79, 65, 83, 84, + 69, 82, 4, 212, 43, 3, 66, 79, 79, 175, 217, 10, 83, 2, 11, 84, 2, 21, 3, + 73, 67, 75, 2, 149, 191, 6, 4, 32, 70, 73, 71, 2, 195, 239, 7, 65, 4, 46, + 72, 85, 7, 73, 68, 69, 32, 65, 82, 67, 2, 17, 2, 65, 68, 2, 17, 2, 69, + 68, 2, 213, 181, 10, 6, 32, 87, 72, 73, 84, 69, 2, 11, 32, 2, 145, 245, + 8, 8, 67, 76, 79, 67, 75, 87, 73, 83, 8, 17, 2, 84, 32, 8, 86, 73, 40, 4, + 79, 86, 69, 82, 180, 138, 5, 5, 69, 77, 66, 69, 68, 203, 138, 6, 77, 2, + 17, 2, 83, 79, 2, 255, 136, 1, 76, 2, 243, 156, 3, 82, 2, 209, 196, 10, + 2, 79, 82, 216, 1, 160, 1, 5, 65, 82, 82, 79, 87, 130, 9, 66, 86, 68, + 210, 1, 70, 122, 72, 178, 6, 76, 26, 79, 34, 80, 50, 82, 70, 83, 94, 84, + 246, 8, 87, 234, 202, 8, 67, 47, 81, 75, 26, 32, 139, 153, 9, 45, 70, 94, + 65, 170, 2, 70, 110, 84, 184, 1, 5, 87, 73, 84, 72, 32, 253, 161, 1, 4, + 79, 86, 69, 82, 12, 40, 5, 66, 79, 86, 69, 32, 143, 1, 78, 10, 70, 82, + 212, 165, 1, 5, 83, 72, 79, 82, 84, 230, 196, 3, 65, 55, 84, 4, 37, 7, + 69, 86, 69, 82, 83, 69, 32, 4, 142, 234, 4, 65, 55, 84, 2, 61, 13, 68, + 32, 85, 80, 80, 69, 82, 32, 65, 78, 68, 32, 76, 2, 17, 2, 79, 87, 2, 201, + 218, 8, 2, 69, 82, 6, 25, 4, 82, 79, 77, 32, 6, 36, 3, 66, 65, 82, 131, + 219, 8, 68, 5, 189, 1, 6, 32, 84, 79, 32, 66, 76, 10, 56, 7, 72, 82, 79, + 85, 71, 72, 32, 65, 3, 79, 32, 66, 6, 228, 228, 4, 3, 83, 85, 80, 138, + 210, 4, 71, 151, 153, 2, 88, 4, 26, 76, 207, 150, 11, 65, 2, 213, 253, 9, + 3, 65, 67, 75, 40, 140, 1, 6, 67, 79, 82, 78, 69, 82, 26, 68, 98, 76, 86, + 80, 30, 83, 38, 84, 210, 215, 8, 77, 38, 78, 122, 69, 130, 154, 1, 72, + 187, 168, 1, 86, 2, 249, 18, 2, 32, 68, 4, 11, 79, 4, 40, 4, 84, 84, 69, + 68, 159, 224, 7, 85, 2, 17, 2, 32, 83, 2, 231, 186, 11, 84, 6, 26, 79, + 175, 216, 8, 65, 4, 26, 87, 191, 204, 11, 79, 2, 153, 203, 3, 2, 69, 82, + 2, 137, 151, 9, 2, 76, 85, 6, 218, 216, 8, 77, 199, 195, 2, 84, 10, 194, + 16, 73, 171, 3, 65, 8, 58, 65, 244, 11, 5, 79, 84, 84, 79, 77, 219, 204, + 8, 76, 2, 145, 2, 2, 67, 75, 14, 48, 6, 79, 85, 66, 76, 69, 32, 239, 230, + 8, 65, 12, 40, 5, 65, 82, 82, 79, 87, 251, 18, 68, 11, 26, 32, 215, 142, + 9, 45, 6, 26, 87, 239, 220, 8, 70, 4, 25, 4, 73, 84, 72, 32, 4, 254, 152, + 11, 86, 79, 83, 4, 40, 4, 82, 79, 78, 84, 139, 216, 8, 73, 2, 137, 215, + 8, 14, 45, 84, 73, 76, 84, 69, 68, 32, 83, 72, 65, 68, 79, 87, 30, 26, + 65, 195, 219, 8, 69, 26, 48, 6, 82, 80, 79, 79, 78, 32, 199, 129, 11, 78, + 24, 80, 10, 87, 73, 84, 72, 32, 66, 65, 82, 66, 32, 193, 154, 1, 4, 79, + 86, 69, 82, 22, 44, 4, 68, 79, 87, 78, 173, 1, 2, 85, 80, 10, 26, 32, + 175, 225, 8, 87, 8, 76, 8, 65, 66, 79, 86, 69, 32, 76, 69, 18, 66, 238, + 216, 8, 70, 179, 5, 84, 2, 227, 2, 70, 2, 129, 227, 4, 7, 69, 76, 79, 87, + 32, 76, 79, 12, 26, 32, 131, 224, 8, 87, 10, 60, 6, 65, 66, 79, 86, 69, + 32, 226, 215, 8, 70, 179, 5, 84, 6, 22, 76, 155, 1, 82, 4, 32, 2, 69, 70, + 191, 225, 4, 79, 2, 221, 146, 2, 24, 84, 87, 65, 82, 68, 83, 32, 72, 65, + 82, 80, 79, 79, 78, 32, 87, 73, 84, 72, 32, 66, 65, 82, 66, 2, 21, 3, 73, + 71, 72, 2, 105, 24, 84, 87, 65, 82, 68, 83, 32, 72, 65, 82, 80, 79, 79, + 78, 32, 87, 73, 84, 72, 32, 66, 65, 82, 66, 2, 11, 32, 2, 135, 243, 1, + 68, 2, 141, 1, 2, 69, 70, 2, 145, 218, 8, 3, 80, 69, 78, 4, 146, 222, 8, + 65, 229, 210, 1, 3, 85, 83, 72, 4, 36, 3, 73, 71, 72, 163, 238, 10, 79, + 2, 11, 84, 2, 211, 1, 45, 6, 32, 2, 81, 85, 159, 213, 8, 65, 4, 26, 73, + 183, 213, 8, 65, 2, 173, 221, 8, 2, 71, 71, 56, 46, 72, 34, 79, 60, 2, + 82, 73, 227, 4, 87, 2, 201, 184, 10, 3, 85, 77, 66, 2, 11, 80, 2, 11, 32, + 2, 157, 205, 8, 4, 83, 72, 65, 68, 34, 40, 5, 65, 78, 71, 76, 69, 255, 3, + 80, 30, 56, 8, 45, 72, 69, 65, 68, 69, 68, 32, 155, 225, 8, 32, 28, 52, + 5, 65, 82, 82, 79, 87, 234, 217, 8, 68, 39, 80, 25, 11, 32, 22, 64, 8, + 79, 86, 69, 82, 32, 76, 69, 70, 22, 87, 167, 213, 8, 84, 2, 215, 212, 8, + 84, 18, 25, 4, 73, 84, 72, 32, 18, 128, 1, 7, 68, 79, 85, 66, 76, 69, 32, + 36, 7, 76, 79, 78, 71, 32, 84, 73, 134, 213, 8, 66, 158, 1, 77, 34, 78, + 34, 86, 35, 72, 4, 206, 143, 9, 72, 183, 251, 1, 86, 4, 11, 80, 4, 11, + 32, 4, 18, 68, 35, 85, 2, 213, 213, 8, 3, 79, 87, 78, 2, 183, 213, 8, 80, + 4, 21, 3, 76, 69, 32, 4, 138, 3, 68, 175, 154, 10, 65, 18, 11, 79, 18, + 56, 8, 45, 72, 69, 65, 68, 69, 68, 32, 207, 215, 8, 32, 16, 76, 6, 65, + 82, 82, 79, 87, 32, 213, 1, 8, 84, 82, 73, 80, 76, 69, 32, 68, 14, 44, 5, + 87, 73, 84, 72, 32, 211, 203, 8, 70, 12, 42, 84, 254, 202, 7, 68, 219, + 188, 3, 86, 8, 26, 65, 147, 215, 8, 82, 6, 17, 2, 73, 76, 7, 33, 6, 32, + 87, 73, 84, 72, 32, 4, 166, 202, 7, 68, 219, 188, 3, 86, 2, 205, 134, 1, + 2, 65, 83, 8, 58, 65, 21, 10, 72, 73, 84, 69, 32, 65, 82, 82, 79, 87, 2, + 239, 211, 8, 86, 7, 11, 32, 4, 184, 195, 2, 4, 70, 82, 79, 77, 155, 149, + 6, 87, 19, 66, 32, 136, 1, 6, 69, 68, 32, 80, 76, 65, 21, 3, 73, 78, 71, + 12, 82, 66, 22, 80, 176, 205, 4, 2, 73, 78, 26, 69, 226, 158, 3, 79, 187, + 203, 2, 65, 2, 139, 163, 11, 85, 2, 11, 79, 2, 163, 241, 10, 73, 2, 147, + 255, 10, 78, 2, 165, 201, 3, 2, 32, 66, 4, 24, 2, 70, 65, 75, 83, 2, 17, + 2, 76, 76, 2, 21, 3, 73, 78, 71, 2, 133, 233, 1, 2, 32, 68, 2, 145, 175, + 3, 2, 79, 85, 8, 250, 178, 11, 69, 2, 73, 2, 77, 3, 79, 126, 132, 2, 2, + 67, 75, 20, 2, 76, 76, 188, 2, 4, 77, 65, 78, 32, 202, 8, 79, 80, 2, 83, + 69, 20, 6, 84, 65, 84, 69, 68, 32, 152, 3, 3, 85, 78, 68, 250, 179, 3, + 87, 148, 9, 15, 65, 83, 84, 69, 68, 32, 83, 87, 69, 69, 84, 32, 80, 79, + 84, 209, 247, 5, 2, 66, 79, 5, 155, 148, 11, 69, 10, 130, 1, 69, 64, 4, + 32, 79, 70, 32, 101, 21, 73, 78, 71, 32, 79, 78, 32, 84, 72, 69, 32, 70, + 76, 79, 79, 82, 32, 76, 65, 85, 71, 6, 60, 9, 68, 45, 85, 80, 32, 78, 69, + 87, 83, 33, 2, 82, 32, 2, 11, 80, 2, 147, 133, 2, 65, 4, 28, 3, 67, 79, + 65, 23, 83, 2, 159, 241, 9, 83, 2, 223, 96, 75, 2, 135, 221, 10, 72, 72, + 136, 1, 5, 67, 69, 78, 84, 85, 34, 68, 100, 3, 81, 85, 73, 28, 8, 78, 85, + 77, 69, 82, 65, 76, 32, 182, 4, 83, 114, 85, 151, 240, 7, 65, 2, 11, 82, + 2, 203, 218, 5, 73, 6, 98, 69, 232, 5, 5, 85, 80, 79, 78, 68, 61, 12, 73, + 77, 73, 68, 73, 65, 32, 83, 69, 88, 84, 85, 2, 229, 5, 3, 78, 65, 82, 48, + 142, 1, 70, 136, 1, 3, 79, 78, 69, 134, 1, 83, 66, 84, 136, 15, 10, 82, + 69, 86, 69, 82, 83, 69, 68, 32, 79, 190, 238, 2, 69, 243, 142, 7, 78, 14, + 26, 73, 207, 177, 10, 79, 12, 36, 3, 70, 84, 89, 199, 128, 3, 86, 7, 11, + 32, 4, 250, 199, 5, 84, 145, 227, 4, 5, 69, 65, 82, 76, 89, 11, 11, 32, + 8, 50, 72, 41, 8, 84, 72, 79, 85, 83, 65, 78, 68, 4, 185, 1, 6, 85, 78, + 68, 82, 69, 68, 5, 237, 133, 4, 2, 32, 67, 6, 32, 2, 73, 88, 159, 178, 9, + 69, 5, 137, 169, 10, 2, 32, 76, 10, 42, 69, 222, 254, 2, 87, 167, 179, 6, + 72, 4, 11, 78, 5, 11, 32, 2, 187, 197, 5, 84, 10, 46, 69, 229, 204, 7, 5, + 73, 76, 73, 81, 85, 8, 60, 2, 77, 85, 40, 5, 83, 84, 69, 82, 84, 21, 2, + 88, 84, 2, 17, 2, 78, 67, 2, 143, 204, 7, 73, 2, 223, 239, 7, 73, 4, 18, + 65, 23, 85, 2, 195, 239, 7, 78, 2, 191, 203, 7, 76, 4, 48, 6, 84, 32, 86, + 69, 71, 69, 239, 231, 9, 83, 2, 233, 198, 2, 2, 84, 65, 5, 211, 216, 9, + 84, 10, 166, 2, 70, 32, 11, 72, 69, 65, 86, 89, 32, 66, 76, 65, 67, 75, + 52, 24, 76, 73, 71, 72, 84, 32, 70, 79, 85, 82, 32, 80, 79, 73, 78, 84, + 69, 68, 32, 66, 76, 65, 67, 75, 0, 18, 87, 72, 73, 84, 69, 32, 70, 79, + 85, 82, 32, 80, 79, 73, 78, 84, 69, 68, 185, 53, 8, 67, 65, 80, 73, 84, + 65, 76, 32, 2, 29, 5, 76, 79, 82, 65, 76, 2, 201, 188, 9, 8, 32, 72, 69, + 65, 82, 84, 32, 66, 2, 245, 213, 9, 2, 32, 67, 16, 74, 32, 89, 14, 69, + 68, 32, 83, 89, 77, 66, 79, 76, 32, 70, 79, 82, 32, 4, 24, 2, 80, 85, 43, + 84, 2, 11, 83, 2, 233, 160, 10, 2, 72, 80, 2, 243, 225, 3, 65, 12, 68, 2, + 83, 72, 150, 166, 6, 67, 206, 212, 4, 70, 2, 76, 147, 17, 88, 4, 40, 4, + 85, 65, 78, 71, 183, 250, 10, 79, 2, 195, 139, 11, 88, 138, 2, 130, 2, + 66, 20, 3, 71, 66, 89, 40, 5, 76, 69, 45, 68, 69, 40, 3, 77, 73, 32, 154, + 5, 78, 148, 26, 26, 83, 83, 73, 65, 78, 32, 65, 83, 84, 82, 79, 76, 79, + 71, 73, 67, 65, 76, 32, 83, 89, 77, 66, 79, 76, 32, 234, 155, 5, 80, 133, + 135, 2, 4, 70, 73, 89, 65, 2, 215, 249, 8, 76, 2, 137, 143, 9, 5, 32, 70, + 79, 79, 84, 2, 11, 76, 2, 153, 232, 9, 2, 65, 89, 62, 68, 9, 70, 82, 65, + 67, 84, 73, 79, 78, 32, 102, 78, 231, 199, 2, 68, 8, 40, 4, 79, 78, 69, + 32, 155, 181, 9, 84, 6, 34, 84, 218, 145, 9, 72, 47, 81, 2, 135, 147, 9, + 72, 36, 33, 6, 85, 77, 66, 69, 82, 32, 36, 76, 5, 69, 73, 71, 72, 84, 38, + 70, 92, 2, 78, 73, 22, 79, 18, 83, 83, 84, 4, 206, 138, 3, 32, 175, 143, + 8, 89, 8, 18, 73, 35, 79, 4, 130, 2, 86, 203, 164, 9, 70, 4, 136, 2, 2, + 85, 82, 163, 164, 9, 82, 4, 77, 2, 78, 69, 2, 167, 1, 78, 8, 40, 4, 69, + 86, 69, 78, 1, 2, 73, 88, 4, 254, 136, 3, 32, 231, 253, 7, 84, 10, 34, + 72, 50, 87, 215, 199, 10, 69, 4, 32, 2, 82, 69, 167, 164, 9, 73, 2, 39, + 69, 4, 26, 79, 151, 164, 9, 69, 2, 235, 135, 3, 32, 182, 1, 32, 3, 73, + 67, 32, 139, 25, 78, 178, 1, 220, 1, 6, 66, 69, 76, 71, 84, 72, 20, 4, + 67, 82, 79, 83, 20, 7, 76, 69, 84, 84, 69, 82, 32, 202, 22, 83, 24, 6, + 77, 85, 76, 84, 73, 80, 208, 201, 7, 5, 65, 82, 76, 65, 85, 145, 203, 1, + 7, 84, 86, 73, 77, 65, 68, 85, 2, 231, 171, 9, 79, 2, 235, 201, 7, 83, 166, 1, 202, 4, 65, 110, 67, 98, 68, 126, 69, 82, 70, 222, 1, 71, 104, 2, 72, 65, 50, 73, 220, 1, 5, 74, 69, 82, 65, 78, 34, 75, 58, 76, 234, 1, 79, 128, 1, 13, 82, 65, 73, 68, 79, 32, 82, 65, 68, 32, 82, 69, 73, 34, 83, 176, 2, 16, 66, 69, 82, 75, 65, 78, 65, 78, 32, 66, 69, 79, 82, 67, 32, 66, 144, 1, 12, 78, 65, 85, 68, 73, 90, 32, 78, 89, 68, 32, 78, 110, - 84, 194, 1, 87, 128, 91, 7, 85, 82, 85, 90, 32, 85, 82, 196, 189, 2, 10, - 77, 65, 78, 78, 65, 90, 32, 77, 65, 78, 168, 63, 13, 80, 69, 82, 84, 72, - 79, 32, 80, 69, 79, 82, 84, 72, 206, 199, 3, 89, 158, 214, 3, 81, 2, 86, - 2, 88, 3, 90, 8, 222, 4, 69, 174, 185, 6, 67, 0, 4, 78, 83, 85, 90, 189, - 186, 3, 9, 76, 71, 73, 90, 32, 69, 79, 76, 72, 11, 46, 69, 30, 65, 245, - 152, 7, 3, 87, 69, 79, 4, 26, 65, 211, 133, 11, 78, 2, 191, 219, 9, 76, - 11, 84, 6, 79, 84, 84, 69, 68, 45, 193, 231, 3, 9, 65, 71, 65, 90, 32, - 68, 65, 69, 71, 6, 226, 132, 11, 76, 2, 78, 3, 80, 11, 136, 76, 7, 72, - 87, 65, 90, 32, 69, 72, 218, 255, 9, 65, 206, 55, 84, 63, 78, 12, 120, - 13, 82, 65, 78, 75, 83, 32, 67, 65, 83, 75, 69, 84, 32, 145, 180, 7, 11, - 69, 72, 85, 32, 70, 69, 79, 72, 32, 70, 69, 10, 46, 65, 234, 196, 10, 73, - 2, 79, 207, 60, 69, 4, 26, 69, 171, 130, 11, 67, 2, 151, 216, 9, 83, 9, - 26, 69, 159, 201, 10, 65, 4, 52, 7, 66, 79, 32, 71, 89, 70, 85, 195, 129, - 11, 82, 2, 235, 128, 11, 32, 4, 236, 8, 2, 69, 71, 13, 4, 71, 76, 65, 90, + 84, 186, 1, 87, 184, 92, 7, 85, 82, 85, 90, 32, 85, 82, 196, 189, 2, 10, + 77, 65, 78, 78, 65, 90, 32, 77, 65, 78, 184, 65, 13, 80, 69, 82, 84, 72, + 79, 32, 80, 69, 79, 82, 84, 72, 150, 200, 3, 89, 142, 219, 3, 81, 2, 86, + 2, 88, 3, 90, 8, 222, 4, 69, 186, 188, 6, 67, 0, 4, 78, 83, 85, 90, 169, + 192, 3, 9, 76, 71, 73, 90, 32, 69, 79, 76, 72, 11, 46, 69, 30, 65, 253, + 156, 7, 3, 87, 69, 79, 4, 26, 65, 203, 142, 11, 78, 2, 247, 227, 9, 76, + 11, 84, 6, 79, 84, 84, 69, 68, 45, 129, 235, 3, 9, 65, 71, 65, 90, 32, + 68, 65, 69, 71, 6, 218, 141, 11, 76, 2, 78, 3, 80, 11, 184, 77, 7, 72, + 87, 65, 90, 32, 69, 72, 162, 135, 10, 65, 206, 55, 84, 63, 78, 12, 120, + 13, 82, 65, 78, 75, 83, 32, 67, 65, 83, 75, 69, 84, 32, 153, 184, 7, 11, + 69, 72, 85, 32, 70, 69, 79, 72, 32, 70, 69, 10, 46, 65, 226, 205, 10, 73, + 2, 79, 207, 60, 69, 4, 26, 69, 163, 139, 11, 67, 2, 207, 224, 9, 83, 9, + 26, 69, 151, 210, 10, 65, 4, 52, 7, 66, 79, 32, 71, 89, 70, 85, 187, 138, + 11, 82, 2, 227, 137, 11, 32, 4, 236, 8, 2, 69, 71, 13, 4, 71, 76, 65, 90, 12, 156, 1, 2, 78, 71, 20, 9, 83, 65, 90, 32, 73, 83, 32, 73, 83, 20, 5, - 87, 65, 90, 32, 69, 216, 198, 10, 10, 67, 69, 76, 65, 78, 68, 73, 67, 45, - 89, 3, 79, 5, 199, 211, 6, 87, 2, 183, 191, 10, 83, 2, 163, 254, 10, 79, - 2, 11, 32, 2, 147, 255, 10, 74, 7, 21, 3, 65, 85, 78, 4, 206, 251, 10, + 87, 65, 90, 32, 69, 208, 207, 10, 10, 67, 69, 76, 65, 78, 68, 73, 67, 45, + 89, 3, 79, 5, 211, 214, 6, 87, 2, 175, 200, 10, 83, 2, 155, 135, 11, 79, + 2, 11, 32, 2, 139, 136, 11, 74, 7, 21, 3, 65, 85, 78, 4, 198, 132, 11, 32, 155, 3, 65, 12, 120, 15, 65, 85, 75, 65, 90, 32, 76, 65, 71, 85, 32, 76, 79, 71, 82, 21, 11, 79, 78, 71, 45, 66, 82, 65, 78, 67, 72, 45, 2, - 251, 241, 9, 32, 10, 64, 3, 65, 82, 32, 158, 4, 72, 62, 77, 66, 79, 131, - 191, 10, 89, 2, 159, 230, 10, 65, 15, 150, 5, 83, 0, 12, 84, 72, 65, 76, - 65, 78, 32, 69, 84, 72, 69, 76, 188, 247, 10, 4, 80, 69, 78, 45, 14, 69, - 2, 78, 3, 79, 2, 11, 68, 2, 247, 194, 10, 32, 26, 150, 1, 72, 244, 2, 18, + 243, 250, 9, 32, 10, 64, 3, 65, 82, 32, 158, 4, 72, 62, 77, 66, 79, 251, + 199, 10, 89, 2, 151, 239, 10, 65, 15, 150, 5, 83, 0, 12, 84, 72, 65, 76, + 65, 78, 32, 69, 84, 72, 69, 76, 180, 128, 11, 4, 80, 69, 78, 45, 14, 69, + 2, 78, 3, 79, 2, 11, 68, 2, 239, 203, 10, 32, 26, 150, 1, 72, 244, 2, 18, 73, 71, 69, 76, 32, 76, 79, 78, 71, 45, 66, 82, 65, 78, 67, 72, 45, 83, - 208, 253, 6, 5, 79, 87, 73, 76, 79, 203, 173, 2, 84, 21, 45, 9, 79, 82, + 144, 129, 7, 5, 79, 87, 73, 76, 79, 139, 176, 2, 84, 21, 45, 9, 79, 82, 84, 45, 84, 87, 73, 71, 45, 18, 102, 66, 58, 72, 62, 77, 30, 78, 38, 79, - 42, 83, 186, 1, 84, 128, 173, 6, 2, 65, 82, 163, 144, 4, 89, 2, 33, 6, - 74, 65, 82, 75, 65, 78, 2, 243, 186, 9, 32, 2, 25, 4, 65, 71, 65, 76, 2, - 11, 76, 2, 159, 247, 10, 32, 2, 253, 154, 3, 2, 65, 68, 2, 157, 168, 10, - 4, 65, 85, 68, 32, 2, 17, 2, 83, 83, 2, 211, 216, 10, 32, 2, 11, 79, 2, - 195, 253, 6, 76, 4, 116, 15, 72, 85, 82, 73, 83, 65, 90, 32, 84, 72, 85, + 42, 83, 186, 1, 84, 140, 176, 6, 2, 65, 82, 143, 150, 4, 89, 2, 33, 6, + 74, 65, 82, 75, 65, 78, 2, 231, 192, 9, 32, 2, 25, 4, 65, 71, 65, 76, 2, + 11, 76, 2, 151, 128, 11, 32, 2, 173, 156, 3, 2, 65, 68, 2, 149, 177, 10, + 4, 65, 85, 68, 32, 2, 17, 2, 83, 83, 2, 203, 225, 10, 32, 2, 11, 79, 2, + 131, 129, 7, 76, 4, 116, 15, 72, 85, 82, 73, 83, 65, 90, 32, 84, 72, 85, 82, 83, 32, 84, 33, 10, 73, 87, 65, 90, 32, 84, 73, 82, 32, 84, 2, 11, - 72, 2, 171, 227, 5, 79, 2, 17, 2, 89, 82, 2, 187, 217, 10, 32, 5, 41, 8, - 85, 78, 74, 79, 32, 87, 89, 78, 2, 11, 78, 2, 251, 246, 9, 32, 2, 21, 3, - 73, 78, 71, 2, 237, 174, 7, 2, 76, 69, 4, 188, 137, 9, 16, 73, 78, 71, - 32, 83, 72, 73, 82, 84, 32, 87, 73, 84, 72, 32, 83, 187, 178, 1, 69, 12, - 120, 3, 66, 73, 78, 2, 78, 28, 2, 81, 85, 0, 3, 86, 73, 71, 174, 160, 7, - 83, 229, 169, 1, 6, 84, 82, 69, 68, 69, 67, 2, 169, 202, 8, 2, 79, 86, 2, - 129, 202, 8, 2, 73, 78, 200, 40, 244, 1, 2, 32, 73, 22, 65, 162, 26, 67, - 138, 5, 69, 166, 11, 72, 242, 36, 73, 162, 233, 1, 75, 154, 2, 76, 142, - 9, 77, 166, 21, 78, 190, 2, 79, 158, 39, 80, 172, 12, 2, 81, 85, 138, 70, - 83, 38, 84, 138, 17, 85, 150, 43, 87, 186, 1, 89, 247, 178, 5, 71, 2, - 183, 201, 9, 78, 198, 2, 132, 2, 5, 70, 69, 84, 89, 32, 36, 4, 71, 73, - 84, 84, 30, 76, 112, 8, 77, 65, 82, 73, 84, 65, 78, 32, 146, 14, 78, 190, - 3, 84, 102, 85, 204, 244, 2, 2, 73, 76, 242, 91, 88, 144, 148, 6, 15, 75, - 69, 32, 66, 79, 84, 84, 76, 69, 32, 65, 78, 68, 32, 67, 159, 98, 82, 4, - 254, 251, 6, 86, 207, 242, 2, 80, 2, 201, 213, 3, 2, 65, 82, 6, 18, 84, - 75, 85, 4, 36, 3, 32, 83, 72, 235, 202, 9, 73, 2, 11, 65, 2, 171, 175, - 10, 75, 2, 227, 228, 9, 84, 122, 184, 1, 7, 76, 69, 84, 84, 69, 82, 32, - 198, 3, 77, 248, 2, 12, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 32, - 136, 4, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 203, 159, 4, 65, - 44, 202, 1, 66, 32, 2, 68, 65, 22, 73, 38, 75, 22, 76, 34, 83, 46, 84, - 182, 2, 65, 212, 231, 5, 2, 71, 65, 222, 153, 1, 82, 202, 142, 2, 90, - 182, 83, 77, 172, 1, 2, 81, 85, 118, 78, 226, 6, 89, 251, 101, 70, 4, - 186, 205, 10, 73, 247, 25, 65, 2, 151, 224, 9, 76, 6, 178, 233, 10, 78, - 2, 84, 3, 89, 2, 223, 231, 9, 65, 2, 11, 65, 2, 191, 223, 9, 66, 4, 156, - 7, 3, 73, 78, 71, 163, 149, 9, 72, 6, 254, 230, 9, 65, 134, 101, 73, 229, - 10, 5, 83, 65, 65, 68, 73, 18, 96, 4, 65, 82, 75, 32, 165, 1, 15, 79, 68, - 73, 70, 73, 69, 82, 32, 76, 69, 84, 84, 69, 82, 32, 12, 82, 68, 40, 2, - 73, 78, 90, 69, 242, 2, 78, 213, 191, 8, 5, 79, 67, 67, 76, 85, 2, 17, 2, - 65, 71, 2, 155, 251, 8, 69, 5, 17, 2, 45, 65, 2, 203, 228, 9, 76, 6, 46, - 69, 184, 6, 2, 83, 72, 131, 223, 10, 73, 2, 229, 235, 9, 11, 80, 69, 78, - 84, 72, 69, 84, 73, 67, 32, 89, 28, 130, 1, 65, 154, 1, 66, 22, 78, 30, - 83, 134, 1, 90, 250, 166, 3, 84, 156, 149, 7, 9, 77, 69, 76, 79, 68, 73, - 67, 32, 81, 3, 81, 10, 76, 3, 70, 83, 65, 34, 78, 28, 2, 84, 77, 245, - 189, 10, 4, 82, 75, 65, 65, 2, 11, 65, 2, 151, 227, 10, 81, 4, 26, 78, - 211, 206, 5, 71, 2, 11, 65, 2, 243, 189, 10, 65, 2, 165, 143, 3, 2, 69, - 81, 4, 64, 4, 72, 73, 89, 89, 45, 8, 79, 70, 32, 77, 65, 83, 72, 70, 2, - 11, 65, 2, 11, 65, 2, 155, 236, 8, 76, 2, 139, 216, 9, 65, 4, 34, 65, - 209, 235, 8, 2, 73, 81, 2, 223, 223, 9, 69, 30, 92, 5, 76, 79, 78, 71, - 32, 54, 79, 66, 83, 174, 205, 6, 65, 242, 145, 4, 69, 2, 73, 3, 85, 10, - 158, 206, 6, 65, 242, 145, 4, 69, 2, 73, 3, 85, 7, 41, 8, 86, 69, 82, 76, - 79, 78, 71, 32, 4, 191, 205, 6, 65, 4, 26, 72, 183, 219, 5, 85, 2, 129, - 150, 6, 3, 79, 82, 84, 10, 68, 8, 83, 45, 83, 69, 82, 73, 70, 32, 241, - 187, 10, 3, 68, 87, 73, 8, 44, 6, 72, 69, 65, 86, 89, 32, 139, 2, 73, 6, - 48, 3, 68, 79, 85, 81, 5, 76, 79, 87, 32, 68, 4, 11, 66, 4, 21, 3, 76, - 69, 32, 4, 84, 6, 84, 85, 82, 78, 69, 68, 23, 67, 2, 21, 3, 79, 85, 66, - 2, 17, 2, 76, 69, 2, 17, 2, 32, 67, 2, 33, 6, 79, 77, 77, 65, 32, 81, 2, - 145, 144, 9, 3, 85, 79, 84, 2, 253, 151, 10, 10, 78, 84, 69, 82, 82, 79, - 66, 65, 78, 71, 6, 48, 6, 69, 76, 76, 73, 84, 69, 143, 200, 5, 85, 5, 25, - 4, 32, 65, 78, 84, 2, 147, 160, 7, 69, 168, 1, 50, 82, 225, 141, 5, 6, - 68, 73, 32, 82, 73, 89, 166, 1, 52, 7, 65, 83, 72, 84, 82, 65, 32, 183, - 191, 4, 79, 164, 1, 180, 1, 7, 76, 69, 84, 84, 69, 82, 32, 212, 1, 5, 83, - 73, 71, 78, 32, 194, 21, 68, 176, 250, 2, 16, 67, 79, 78, 83, 79, 78, 65, - 78, 84, 32, 83, 73, 71, 78, 32, 72, 211, 155, 2, 86, 100, 154, 250, 6, - 65, 38, 68, 114, 84, 46, 86, 186, 5, 85, 206, 141, 1, 79, 238, 60, 73, - 42, 76, 226, 195, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, - 80, 162, 7, 69, 234, 61, 72, 2, 77, 2, 82, 3, 89, 8, 218, 184, 6, 67, - 234, 216, 3, 65, 239, 1, 86, 52, 66, 65, 32, 4, 72, 79, 79, 76, 46, 79, - 74, 82, 183, 212, 10, 73, 4, 194, 191, 9, 76, 227, 20, 82, 5, 245, 191, - 5, 6, 32, 83, 65, 84, 67, 72, 6, 36, 3, 82, 80, 73, 203, 154, 9, 79, 4, - 242, 132, 10, 79, 135, 18, 85, 36, 66, 69, 72, 4, 73, 80, 84, 32, 214, - 250, 1, 85, 175, 206, 6, 79, 4, 36, 3, 87, 68, 82, 235, 131, 10, 69, 2, - 11, 73, 2, 207, 149, 10, 86, 28, 80, 8, 67, 65, 80, 73, 84, 65, 76, 32, - 86, 76, 81, 6, 83, 77, 65, 76, 76, 32, 18, 210, 210, 10, 66, 2, 69, 2, - 70, 2, 72, 2, 73, 2, 76, 2, 77, 2, 80, 3, 82, 2, 37, 7, 73, 71, 65, 84, - 85, 82, 69, 2, 11, 32, 2, 233, 141, 10, 2, 69, 84, 8, 174, 209, 10, 69, - 2, 71, 2, 76, 3, 79, 220, 1, 130, 2, 65, 30, 67, 74, 69, 36, 5, 71, 77, - 69, 78, 84, 28, 2, 77, 73, 172, 1, 8, 80, 65, 82, 65, 84, 69, 68, 32, - 138, 4, 82, 158, 1, 83, 68, 2, 84, 32, 168, 140, 5, 8, 87, 73, 78, 71, - 32, 78, 69, 69, 202, 145, 3, 88, 190, 106, 68, 233, 162, 1, 2, 76, 70, 4, - 250, 206, 10, 76, 3, 84, 6, 34, 84, 245, 226, 5, 2, 79, 78, 4, 178, 201, - 6, 73, 175, 204, 3, 79, 4, 166, 224, 1, 68, 191, 132, 1, 45, 23, 189, - 191, 4, 2, 69, 68, 6, 212, 84, 28, 68, 73, 82, 69, 67, 84, 32, 80, 82, - 79, 68, 85, 67, 84, 32, 87, 73, 84, 72, 32, 66, 79, 84, 84, 79, 77, 32, - 67, 172, 208, 7, 3, 83, 69, 88, 211, 216, 1, 67, 158, 1, 48, 6, 66, 76, - 79, 67, 75, 32, 203, 182, 9, 83, 156, 1, 88, 9, 81, 85, 65, 68, 82, 65, - 78, 84, 45, 129, 1, 8, 83, 69, 88, 84, 65, 78, 84, 45, 30, 42, 49, 38, - 50, 30, 51, 171, 202, 10, 52, 17, 34, 50, 30, 51, 171, 202, 10, 52, 9, - 26, 51, 171, 202, 10, 52, 5, 167, 202, 10, 52, 126, 58, 49, 54, 50, 46, - 51, 38, 52, 30, 53, 187, 200, 10, 54, 65, 50, 50, 46, 51, 38, 52, 30, 53, - 187, 200, 10, 54, 33, 42, 51, 38, 52, 30, 53, 187, 200, 10, 54, 17, 34, - 52, 30, 53, 187, 200, 10, 54, 9, 26, 53, 187, 200, 10, 54, 5, 183, 200, - 10, 54, 4, 120, 2, 86, 73, 129, 175, 2, 22, 73, 79, 85, 83, 32, 70, 65, - 67, 69, 32, 87, 73, 84, 72, 32, 83, 89, 77, 66, 79, 76, 83, 2, 11, 67, 2, - 215, 133, 10, 69, 4, 52, 7, 81, 85, 73, 81, 85, 65, 68, 239, 141, 9, 65, - 2, 91, 82, 4, 64, 10, 84, 82, 65, 78, 83, 77, 73, 84, 32, 83, 151, 187, - 6, 77, 2, 11, 84, 2, 223, 252, 8, 65, 134, 3, 102, 65, 218, 20, 73, 102, - 79, 214, 13, 69, 70, 82, 224, 143, 9, 5, 85, 70, 70, 76, 69, 195, 145, 1, - 89, 192, 2, 164, 1, 12, 68, 79, 87, 69, 68, 32, 87, 72, 73, 84, 69, 32, - 56, 9, 76, 76, 79, 87, 32, 80, 65, 78, 32, 62, 82, 182, 10, 86, 160, 198, - 7, 2, 77, 82, 227, 233, 1, 75, 6, 174, 239, 8, 67, 206, 11, 83, 245, 4, - 3, 76, 65, 84, 2, 17, 2, 79, 70, 2, 17, 2, 32, 70, 2, 187, 136, 7, 79, - 210, 1, 40, 4, 65, 68, 65, 32, 167, 194, 10, 75, 208, 1, 162, 1, 68, 46, - 69, 110, 72, 34, 76, 246, 1, 83, 212, 2, 6, 86, 79, 87, 69, 76, 32, 170, - 199, 4, 65, 188, 211, 1, 7, 67, 79, 78, 84, 73, 78, 85, 195, 143, 4, 79, - 24, 194, 224, 6, 79, 66, 65, 255, 235, 1, 73, 4, 84, 15, 88, 84, 82, 65, - 32, 83, 72, 79, 82, 84, 32, 86, 79, 87, 69, 235, 130, 9, 75, 2, 179, 254, - 9, 76, 2, 217, 143, 10, 3, 69, 65, 68, 96, 33, 6, 69, 84, 84, 69, 82, 32, - 96, 170, 225, 6, 65, 38, 68, 114, 84, 46, 86, 186, 5, 85, 186, 202, 1, - 73, 42, 76, 226, 195, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 74, 2, 75, - 2, 80, 138, 69, 72, 2, 77, 2, 82, 2, 89, 186, 2, 69, 3, 79, 30, 70, 65, - 38, 69, 56, 4, 73, 71, 78, 32, 145, 183, 9, 3, 85, 84, 82, 2, 193, 251, - 9, 4, 78, 68, 72, 73, 6, 212, 205, 2, 5, 67, 84, 73, 79, 78, 243, 189, 4, - 80, 20, 106, 73, 154, 144, 5, 83, 202, 141, 1, 67, 98, 78, 190, 66, 65, - 190, 158, 1, 74, 150, 3, 85, 235, 245, 1, 86, 2, 37, 7, 78, 86, 69, 82, - 84, 69, 68, 2, 181, 157, 6, 2, 32, 67, 46, 60, 6, 77, 79, 68, 73, 70, 73, - 21, 5, 83, 73, 71, 78, 32, 2, 155, 146, 6, 69, 44, 110, 67, 42, 79, 34, - 80, 162, 183, 4, 85, 194, 229, 1, 83, 242, 68, 65, 58, 86, 166, 202, 1, - 73, 199, 140, 2, 69, 4, 193, 157, 6, 5, 65, 78, 68, 82, 65, 7, 186, 162, - 10, 79, 215, 22, 69, 2, 57, 12, 82, 73, 83, 72, 84, 72, 65, 77, 65, 84, - 82, 65, 2, 223, 161, 10, 32, 98, 72, 3, 69, 68, 32, 21, 11, 73, 65, 78, - 32, 76, 69, 84, 84, 69, 82, 32, 2, 215, 250, 9, 73, 96, 158, 2, 65, 120, - 3, 67, 72, 85, 22, 69, 70, 72, 46, 73, 46, 76, 22, 77, 38, 79, 94, 80, - 18, 82, 22, 83, 38, 84, 64, 2, 87, 79, 36, 2, 89, 69, 212, 243, 4, 2, 74, - 85, 166, 228, 2, 68, 202, 13, 90, 218, 88, 70, 182, 6, 71, 234, 45, 66, - 246, 11, 75, 234, 21, 86, 250, 27, 78, 167, 128, 1, 85, 16, 82, 82, 242, - 251, 9, 73, 234, 25, 68, 162, 8, 71, 2, 87, 198, 21, 83, 147, 1, 72, 4, - 170, 166, 9, 82, 163, 142, 1, 69, 2, 255, 145, 10, 82, 8, 38, 65, 146, - 251, 9, 82, 139, 56, 71, 4, 234, 179, 10, 82, 3, 84, 4, 164, 182, 8, 2, - 65, 45, 179, 172, 1, 85, 6, 194, 227, 9, 65, 142, 57, 67, 215, 22, 70, 2, - 207, 168, 8, 79, 4, 146, 158, 5, 69, 227, 250, 3, 73, 12, 70, 79, 170, - 166, 9, 73, 166, 111, 85, 150, 25, 65, 154, 3, 78, 3, 82, 2, 163, 155, - 10, 90, 2, 255, 15, 69, 2, 151, 142, 9, 79, 4, 130, 143, 9, 85, 191, 162, - 1, 79, 6, 26, 72, 215, 148, 10, 79, 4, 218, 131, 6, 73, 223, 155, 4, 69, - 4, 138, 165, 9, 79, 211, 139, 1, 69, 4, 182, 176, 10, 65, 3, 87, 10, 78, - 69, 186, 232, 3, 70, 148, 126, 6, 78, 84, 79, 32, 83, 72, 131, 201, 5, - 80, 2, 171, 233, 9, 76, 50, 252, 1, 2, 79, 84, 32, 6, 80, 80, 73, 78, 71, - 32, 72, 2, 82, 84, 128, 11, 7, 85, 76, 68, 69, 82, 69, 68, 184, 240, 1, - 24, 67, 75, 69, 68, 32, 70, 65, 67, 69, 32, 87, 73, 84, 72, 32, 69, 88, - 80, 76, 79, 68, 73, 78, 71, 234, 155, 3, 86, 199, 215, 4, 87, 2, 197, - 147, 8, 3, 73, 78, 71, 4, 36, 3, 84, 82, 79, 131, 242, 5, 66, 2, 11, 76, - 2, 139, 143, 8, 76, 36, 102, 32, 200, 8, 12, 72, 65, 78, 68, 32, 70, 79, - 82, 77, 65, 84, 32, 250, 182, 6, 67, 171, 236, 3, 83, 24, 242, 1, 66, 92, - 11, 83, 76, 65, 78, 84, 69, 68, 32, 78, 79, 82, 196, 1, 4, 76, 69, 70, - 84, 156, 1, 11, 82, 73, 71, 72, 84, 87, 65, 82, 68, 83, 32, 248, 1, 7, - 85, 80, 32, 84, 65, 67, 75, 129, 161, 2, 9, 68, 79, 87, 78, 32, 84, 65, - 67, 75, 4, 88, 14, 65, 67, 75, 83, 76, 65, 78, 84, 69, 68, 32, 83, 79, - 85, 33, 4, 69, 78, 84, 32, 2, 11, 84, 2, 179, 140, 9, 72, 2, 221, 40, 37, - 65, 82, 82, 79, 87, 32, 80, 79, 73, 78, 84, 73, 78, 71, 32, 68, 79, 87, - 78, 87, 65, 82, 68, 83, 32, 84, 72, 69, 78, 32, 78, 79, 82, 84, 72, 32, - 69, 4, 116, 24, 87, 65, 82, 68, 83, 32, 72, 65, 82, 80, 79, 79, 78, 32, - 65, 66, 79, 86, 69, 32, 76, 79, 78, 71, 171, 3, 32, 2, 237, 1, 5, 32, 82, - 73, 71, 72, 4, 112, 11, 65, 82, 82, 79, 87, 32, 65, 66, 79, 86, 69, 29, - 13, 72, 65, 82, 80, 79, 79, 78, 32, 65, 66, 79, 86, 69, 2, 157, 128, 6, - 2, 32, 76, 2, 29, 5, 32, 76, 79, 78, 71, 2, 25, 4, 32, 76, 69, 70, 2, - 153, 250, 6, 6, 84, 87, 65, 82, 68, 83, 7, 11, 32, 4, 76, 13, 65, 66, 79, - 86, 69, 32, 83, 72, 79, 82, 84, 32, 68, 251, 131, 2, 87, 2, 11, 79, 2, - 11, 87, 2, 11, 78, 2, 11, 32, 2, 223, 132, 7, 84, 8, 120, 10, 67, 79, 78, - 84, 73, 78, 85, 73, 78, 71, 0, 6, 76, 69, 84, 84, 69, 82, 40, 4, 68, 79, - 87, 78, 1, 2, 85, 80, 2, 193, 179, 3, 5, 32, 79, 86, 69, 82, 2, 21, 3, - 32, 83, 84, 2, 215, 161, 10, 69, 2, 25, 4, 32, 79, 80, 69, 2, 207, 146, - 9, 78, 4, 26, 73, 179, 160, 10, 85, 2, 247, 160, 10, 77, 211, 14, 174, 1, - 68, 152, 20, 2, 71, 78, 184, 181, 1, 6, 77, 73, 76, 65, 82, 32, 158, 2, - 78, 202, 24, 88, 237, 238, 6, 15, 76, 72, 79, 85, 69, 84, 84, 69, 32, 79, - 70, 32, 74, 65, 80, 252, 1, 40, 5, 68, 72, 65, 77, 32, 135, 17, 69, 184, - 1, 202, 1, 69, 68, 7, 76, 69, 84, 84, 69, 82, 32, 176, 4, 15, 82, 69, 80, - 69, 84, 73, 84, 73, 79, 78, 32, 77, 65, 82, 75, 50, 83, 164, 8, 11, 86, - 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 171, 175, 6, 68, 2, 37, 7, 78, - 68, 32, 79, 70, 32, 84, 2, 201, 210, 9, 2, 69, 88, 102, 214, 1, 65, 98, - 84, 242, 188, 6, 68, 158, 1, 86, 186, 5, 85, 186, 202, 1, 73, 138, 196, - 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 138, 69, 72, 2, - 76, 2, 77, 2, 82, 2, 89, 186, 2, 69, 3, 79, 11, 72, 8, 76, 84, 69, 82, - 78, 65, 84, 69, 214, 154, 10, 65, 2, 73, 3, 85, 2, 235, 245, 9, 32, 14, - 134, 1, 72, 252, 231, 5, 19, 87, 79, 45, 67, 73, 82, 67, 76, 69, 32, 65, - 76, 84, 69, 82, 78, 65, 84, 69, 254, 233, 3, 84, 195, 71, 65, 4, 164, - 217, 9, 20, 82, 69, 69, 45, 67, 73, 82, 67, 76, 69, 32, 65, 76, 84, 69, - 82, 78, 65, 84, 69, 147, 64, 65, 6, 11, 45, 6, 186, 152, 10, 49, 2, 50, - 3, 51, 44, 38, 69, 181, 7, 4, 73, 71, 78, 32, 32, 96, 11, 67, 84, 73, 79, - 78, 32, 77, 65, 82, 75, 32, 177, 6, 8, 80, 65, 82, 65, 84, 79, 82, 32, - 28, 80, 11, 68, 79, 85, 66, 76, 69, 32, 82, 73, 78, 71, 57, 5, 87, 73, - 84, 72, 32, 5, 11, 32, 2, 249, 231, 8, 6, 87, 73, 84, 72, 32, 82, 24, - 212, 1, 12, 67, 73, 82, 67, 76, 69, 83, 32, 65, 78, 68, 32, 116, 5, 81, - 85, 65, 68, 82, 0, 4, 83, 69, 80, 84, 12, 16, 82, 65, 89, 83, 32, 65, 78, - 68, 32, 68, 79, 84, 84, 69, 68, 32, 46, 68, 45, 3, 84, 82, 73, 6, 60, 4, - 70, 79, 85, 82, 0, 3, 84, 87, 79, 187, 229, 8, 82, 2, 225, 207, 6, 8, 32, - 69, 78, 67, 76, 79, 83, 85, 2, 83, 85, 6, 42, 68, 28, 3, 84, 82, 73, 215, - 1, 67, 2, 197, 1, 3, 79, 85, 66, 2, 171, 1, 80, 6, 52, 9, 68, 69, 78, 84, - 32, 65, 78, 68, 32, 103, 80, 4, 116, 6, 68, 79, 84, 84, 69, 68, 49, 14, - 85, 45, 83, 72, 65, 80, 69, 68, 32, 79, 82, 78, 65, 77, 2, 17, 2, 76, 69, - 2, 17, 2, 32, 67, 2, 25, 4, 82, 69, 83, 67, 2, 239, 186, 1, 69, 4, 158, - 237, 8, 66, 135, 83, 68, 12, 146, 229, 4, 83, 202, 141, 1, 67, 98, 78, - 138, 216, 3, 65, 239, 1, 86, 26, 74, 65, 94, 86, 210, 183, 6, 85, 186, - 202, 1, 73, 198, 140, 2, 69, 3, 79, 10, 168, 184, 6, 10, 76, 84, 69, 82, - 78, 65, 84, 69, 32, 85, 254, 214, 3, 65, 2, 73, 3, 85, 4, 11, 79, 4, 33, - 6, 67, 65, 76, 73, 67, 32, 4, 255, 183, 6, 82, 68, 84, 12, 84, 73, 67, - 32, 76, 69, 84, 84, 69, 82, 32, 78, 49, 5, 87, 65, 89, 83, 32, 52, 178, - 156, 1, 50, 222, 176, 3, 48, 131, 2, 49, 16, 56, 5, 66, 76, 65, 67, 75, - 1, 5, 87, 72, 73, 84, 69, 8, 11, 32, 8, 70, 82, 24, 3, 76, 69, 70, 12, 4, - 68, 79, 87, 78, 1, 2, 85, 80, 2, 21, 3, 73, 71, 72, 2, 11, 84, 2, 225, - 92, 6, 32, 80, 79, 73, 78, 84, 194, 10, 96, 8, 87, 82, 73, 84, 73, 78, - 71, 32, 241, 238, 1, 10, 32, 79, 70, 32, 84, 72, 69, 32, 72, 79, 192, 10, - 136, 3, 4, 65, 73, 82, 32, 192, 1, 2, 66, 82, 102, 67, 138, 1, 68, 218, - 4, 69, 242, 6, 70, 244, 3, 4, 87, 65, 76, 76, 138, 1, 72, 234, 77, 76, - 212, 6, 2, 77, 79, 222, 42, 78, 218, 1, 82, 182, 7, 83, 162, 5, 84, 180, - 10, 5, 71, 82, 65, 83, 80, 184, 5, 30, 85, 80, 80, 69, 82, 32, 66, 79, - 68, 89, 32, 84, 73, 76, 84, 73, 78, 71, 32, 70, 82, 79, 77, 32, 72, 73, - 80, 32, 74, 79, 135, 207, 4, 80, 8, 48, 4, 66, 76, 79, 87, 29, 4, 83, 85, - 67, 75, 4, 58, 32, 211, 226, 4, 73, 4, 30, 32, 61, 3, 73, 78, 71, 2, 237, - 157, 1, 10, 83, 77, 65, 76, 76, 32, 82, 79, 84, 65, 2, 171, 134, 9, 32, - 10, 52, 5, 69, 65, 84, 72, 32, 229, 169, 1, 2, 85, 83, 4, 140, 164, 2, 2, - 69, 88, 1, 2, 73, 78, 10, 40, 6, 72, 69, 69, 75, 83, 32, 63, 79, 6, 154, - 107, 83, 146, 38, 78, 153, 223, 3, 4, 80, 85, 70, 70, 4, 178, 180, 9, 76, - 223, 46, 77, 28, 108, 15, 82, 69, 65, 77, 89, 32, 69, 89, 69, 66, 82, 79, - 87, 83, 32, 165, 1, 7, 89, 78, 65, 77, 73, 67, 32, 8, 64, 4, 68, 79, 87, - 78, 0, 2, 85, 80, 29, 4, 78, 69, 85, 84, 2, 153, 143, 1, 2, 32, 78, 4, - 21, 3, 82, 65, 76, 4, 11, 32, 4, 194, 58, 68, 191, 199, 9, 85, 20, 180, - 1, 11, 69, 86, 69, 82, 89, 32, 79, 84, 72, 69, 82, 30, 70, 22, 83, 128, - 122, 9, 65, 82, 82, 79, 87, 72, 69, 65, 68, 234, 38, 82, 136, 206, 3, 2, - 84, 69, 21, 4, 71, 82, 65, 68, 2, 181, 230, 8, 2, 32, 84, 2, 163, 146, 6, - 65, 6, 68, 11, 73, 77, 85, 76, 84, 65, 78, 69, 79, 85, 83, 151, 227, 8, - 76, 5, 203, 151, 1, 32, 54, 64, 2, 89, 69, 172, 227, 4, 4, 88, 67, 73, - 84, 203, 138, 4, 65, 50, 166, 1, 32, 56, 15, 66, 82, 79, 87, 83, 32, 83, - 84, 82, 65, 73, 71, 72, 84, 32, 44, 5, 71, 65, 90, 69, 45, 140, 2, 7, 76, - 65, 83, 72, 69, 83, 32, 65, 2, 83, 32, 6, 220, 150, 1, 5, 66, 76, 73, 78, - 75, 243, 129, 5, 87, 6, 186, 53, 68, 154, 84, 78, 167, 243, 8, 85, 18, - 100, 11, 70, 76, 79, 79, 82, 80, 76, 65, 78, 69, 32, 25, 10, 87, 65, 76, - 76, 80, 76, 65, 78, 69, 32, 8, 82, 83, 207, 45, 67, 10, 18, 67, 43, 83, - 4, 254, 45, 85, 213, 95, 3, 73, 82, 67, 6, 37, 7, 84, 82, 65, 73, 71, 72, - 84, 7, 11, 32, 4, 202, 163, 1, 65, 55, 68, 6, 130, 51, 68, 180, 173, 4, - 4, 70, 76, 85, 84, 139, 154, 5, 85, 14, 112, 5, 72, 65, 76, 70, 32, 26, - 67, 28, 4, 87, 73, 68, 69, 230, 92, 79, 233, 135, 4, 6, 83, 81, 85, 69, - 69, 90, 4, 22, 67, 131, 93, 79, 2, 213, 232, 2, 2, 76, 79, 4, 162, 67, - 32, 217, 61, 4, 78, 73, 78, 71, 38, 204, 1, 28, 65, 67, 69, 32, 68, 73, - 82, 69, 67, 84, 73, 79, 78, 32, 80, 79, 83, 73, 84, 73, 79, 78, 32, 78, - 79, 83, 69, 32, 138, 1, 73, 82, 76, 176, 1, 8, 79, 82, 69, 72, 69, 65, - 68, 32, 187, 158, 7, 85, 6, 88, 10, 85, 80, 32, 79, 82, 32, 68, 79, 87, - 78, 13, 8, 70, 79, 82, 87, 65, 82, 68, 32, 5, 11, 32, 2, 153, 231, 4, 3, - 84, 73, 76, 12, 180, 225, 3, 11, 76, 76, 32, 77, 79, 68, 73, 70, 73, 69, - 82, 131, 195, 2, 78, 12, 44, 4, 73, 67, 75, 32, 29, 3, 79, 79, 82, 10, - 254, 140, 1, 76, 35, 83, 2, 225, 247, 8, 20, 80, 76, 65, 78, 69, 32, 83, - 72, 79, 85, 76, 68, 69, 82, 32, 72, 73, 80, 32, 77, 6, 166, 89, 87, 222, - 38, 67, 47, 78, 156, 4, 34, 65, 133, 75, 3, 69, 65, 68, 140, 4, 36, 3, - 78, 68, 45, 143, 186, 9, 73, 138, 4, 92, 5, 65, 78, 71, 76, 69, 138, 5, - 67, 150, 10, 70, 186, 42, 72, 241, 12, 4, 79, 86, 65, 76, 37, 11, 32, 34, - 188, 1, 5, 73, 78, 68, 69, 88, 176, 1, 7, 76, 73, 84, 84, 76, 69, 32, - 136, 1, 5, 82, 73, 78, 71, 32, 173, 66, 18, 77, 73, 68, 68, 76, 69, 32, - 82, 73, 78, 71, 32, 76, 73, 84, 84, 76, 69, 17, 11, 32, 14, 128, 1, 7, - 77, 73, 68, 68, 76, 69, 32, 228, 24, 11, 82, 73, 78, 71, 32, 76, 73, 84, - 84, 76, 69, 241, 42, 5, 84, 72, 85, 77, 66, 4, 174, 70, 76, 247, 215, 8, - 82, 8, 44, 5, 73, 78, 68, 69, 88, 207, 238, 9, 85, 7, 145, 24, 18, 32, - 84, 72, 85, 77, 66, 32, 73, 78, 68, 69, 88, 32, 84, 72, 85, 77, 66, 4, - 108, 22, 68, 79, 87, 78, 32, 77, 73, 68, 68, 76, 69, 32, 84, 72, 85, 77, - 66, 32, 73, 78, 68, 69, 155, 68, 76, 2, 207, 169, 8, 88, 88, 64, 5, 73, - 82, 67, 76, 69, 184, 3, 3, 76, 65, 87, 183, 2, 85, 35, 11, 32, 32, 116, - 5, 73, 78, 68, 69, 88, 200, 1, 7, 76, 73, 84, 84, 76, 69, 32, 36, 7, 77, - 73, 68, 68, 76, 69, 32, 163, 64, 82, 21, 11, 32, 18, 72, 6, 77, 73, 68, - 68, 76, 69, 198, 26, 72, 242, 38, 82, 131, 230, 8, 66, 13, 11, 32, 10, - 64, 5, 67, 82, 79, 83, 83, 198, 64, 84, 82, 76, 247, 215, 8, 82, 4, 134, - 65, 32, 231, 226, 8, 69, 4, 194, 193, 8, 73, 159, 168, 1, 85, 6, 252, 47, - 10, 82, 73, 78, 71, 32, 76, 73, 84, 84, 76, 191, 185, 9, 85, 17, 11, 32, - 14, 144, 2, 28, 77, 73, 68, 68, 76, 69, 32, 82, 73, 78, 71, 32, 76, 73, - 84, 84, 76, 69, 32, 67, 79, 78, 74, 79, 73, 78, 69, 68, 176, 49, 2, 70, - 79, 198, 11, 78, 162, 1, 84, 197, 118, 23, 73, 78, 68, 69, 88, 32, 84, - 72, 85, 77, 66, 32, 67, 85, 82, 86, 69, 32, 84, 72, 85, 77, 66, 5, 247, - 180, 1, 32, 38, 46, 80, 149, 2, 6, 82, 76, 73, 67, 85, 69, 31, 11, 32, - 28, 188, 1, 5, 73, 78, 68, 69, 88, 56, 19, 70, 73, 86, 69, 32, 70, 73, - 78, 71, 69, 82, 83, 32, 83, 80, 82, 69, 65, 68, 196, 50, 7, 77, 73, 68, - 68, 76, 69, 32, 18, 79, 218, 7, 78, 163, 1, 84, 9, 11, 32, 6, 40, 5, 84, - 72, 85, 77, 66, 243, 58, 82, 5, 215, 46, 32, 9, 11, 32, 6, 72, 5, 73, 78, - 68, 69, 88, 0, 6, 77, 73, 68, 68, 76, 69, 179, 71, 79, 2, 193, 147, 9, - 13, 32, 82, 73, 78, 71, 32, 76, 73, 84, 84, 76, 69, 32, 172, 2, 44, 3, - 73, 83, 84, 177, 33, 3, 76, 65, 84, 247, 1, 11, 32, 244, 1, 160, 2, 5, - 73, 78, 68, 69, 88, 192, 16, 7, 76, 73, 84, 84, 76, 69, 32, 196, 2, 7, - 77, 73, 68, 68, 76, 69, 32, 200, 4, 5, 82, 73, 78, 71, 32, 132, 2, 5, 84, - 72, 85, 77, 66, 138, 2, 72, 205, 9, 22, 70, 79, 85, 82, 32, 70, 73, 78, - 71, 69, 82, 83, 32, 67, 79, 78, 74, 79, 73, 78, 69, 68, 137, 1, 11, 32, - 134, 1, 232, 1, 4, 66, 69, 78, 84, 36, 6, 72, 73, 78, 71, 69, 68, 76, 6, - 77, 73, 68, 68, 76, 69, 168, 7, 2, 67, 85, 64, 6, 84, 72, 85, 77, 66, 32, - 160, 5, 16, 85, 80, 32, 77, 73, 68, 68, 76, 69, 32, 72, 73, 78, 71, 69, - 68, 151, 4, 82, 5, 217, 45, 5, 32, 79, 86, 69, 82, 9, 11, 32, 6, 252, 20, - 8, 77, 73, 68, 68, 76, 69, 32, 85, 167, 172, 8, 76, 71, 11, 32, 68, 236, - 1, 4, 66, 69, 78, 84, 42, 67, 244, 1, 10, 85, 80, 32, 83, 80, 82, 69, 65, - 68, 32, 100, 6, 72, 73, 78, 71, 69, 68, 46, 82, 80, 5, 84, 72, 85, 77, - 66, 188, 28, 14, 83, 84, 82, 65, 73, 71, 72, 84, 32, 84, 72, 85, 77, 66, - 227, 17, 76, 5, 213, 92, 6, 32, 84, 72, 85, 77, 66, 28, 68, 8, 79, 78, - 74, 79, 73, 78, 69, 68, 233, 1, 4, 82, 79, 83, 83, 23, 11, 32, 20, 144, - 1, 6, 67, 85, 80, 80, 69, 68, 28, 6, 84, 72, 85, 77, 66, 32, 68, 5, 72, - 73, 78, 71, 69, 166, 22, 73, 165, 7, 6, 77, 73, 68, 68, 76, 69, 5, 11, - 32, 2, 203, 27, 84, 8, 160, 1, 4, 83, 73, 68, 69, 219, 61, 70, 6, 22, 69, - 159, 47, 32, 4, 223, 15, 68, 5, 241, 30, 7, 32, 83, 80, 82, 69, 65, 68, - 8, 32, 3, 73, 78, 71, 247, 19, 65, 7, 11, 32, 4, 138, 36, 67, 131, 240, - 8, 66, 19, 11, 32, 16, 64, 6, 65, 78, 71, 76, 69, 68, 22, 67, 106, 72, - 163, 146, 9, 66, 5, 167, 221, 5, 32, 6, 74, 85, 230, 7, 73, 241, 25, 10, - 79, 78, 74, 79, 73, 78, 69, 68, 32, 72, 2, 201, 193, 4, 2, 80, 80, 4, - 194, 33, 73, 217, 26, 2, 79, 79, 40, 164, 1, 7, 65, 78, 71, 76, 69, 68, + 72, 2, 163, 230, 5, 79, 2, 197, 226, 10, 3, 89, 82, 32, 5, 41, 8, 85, 78, + 74, 79, 32, 87, 89, 78, 2, 11, 78, 2, 251, 255, 9, 32, 2, 21, 3, 73, 78, + 71, 2, 245, 178, 7, 2, 76, 69, 4, 164, 143, 9, 16, 73, 78, 71, 32, 83, + 72, 73, 82, 84, 32, 87, 73, 84, 72, 32, 83, 211, 181, 1, 69, 12, 120, 3, + 66, 73, 78, 2, 78, 28, 2, 81, 85, 0, 3, 86, 73, 71, 190, 164, 7, 83, 225, + 170, 1, 6, 84, 82, 69, 68, 69, 67, 2, 181, 207, 8, 2, 79, 86, 2, 141, + 207, 8, 2, 73, 78, 212, 40, 244, 1, 2, 32, 73, 22, 65, 162, 26, 67, 138, + 5, 69, 222, 12, 72, 242, 36, 73, 174, 233, 1, 75, 254, 1, 76, 142, 9, 77, + 182, 21, 78, 190, 2, 79, 158, 39, 80, 172, 12, 2, 81, 85, 146, 72, 83, + 38, 84, 138, 17, 85, 150, 43, 87, 186, 1, 89, 247, 183, 5, 71, 2, 247, + 209, 9, 78, 198, 2, 132, 2, 5, 70, 69, 84, 89, 32, 36, 4, 71, 73, 84, 84, + 30, 76, 112, 8, 77, 65, 82, 73, 84, 65, 78, 32, 146, 14, 78, 190, 3, 84, + 102, 85, 132, 246, 2, 2, 73, 76, 250, 93, 88, 208, 153, 6, 15, 75, 69, + 32, 66, 79, 84, 84, 76, 69, 32, 65, 78, 68, 32, 67, 159, 98, 82, 4, 130, + 128, 7, 86, 203, 247, 2, 80, 2, 137, 217, 3, 2, 65, 82, 6, 18, 84, 75, + 85, 4, 36, 3, 32, 83, 72, 171, 211, 9, 73, 2, 11, 65, 2, 171, 184, 10, + 75, 2, 227, 237, 9, 84, 122, 184, 1, 7, 76, 69, 84, 84, 69, 82, 32, 198, + 3, 77, 248, 2, 12, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 32, 136, + 4, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 139, 163, 4, 65, 44, + 202, 1, 66, 32, 2, 68, 65, 22, 73, 38, 75, 22, 76, 34, 83, 46, 84, 182, + 2, 65, 228, 234, 5, 2, 71, 65, 222, 154, 1, 82, 170, 144, 2, 90, 198, 86, + 77, 172, 1, 2, 81, 85, 118, 78, 226, 6, 89, 251, 101, 70, 4, 186, 214, + 10, 73, 247, 25, 65, 2, 151, 233, 9, 76, 6, 178, 242, 10, 78, 2, 84, 3, + 89, 2, 223, 240, 9, 65, 2, 11, 65, 2, 191, 232, 9, 66, 4, 156, 7, 3, 73, + 78, 71, 171, 155, 9, 72, 6, 254, 239, 9, 65, 134, 101, 73, 229, 10, 5, + 83, 65, 65, 68, 73, 18, 96, 4, 65, 82, 75, 32, 165, 1, 15, 79, 68, 73, + 70, 73, 69, 82, 32, 76, 69, 84, 84, 69, 82, 32, 12, 82, 68, 40, 2, 73, + 78, 90, 69, 242, 2, 78, 173, 197, 8, 5, 79, 67, 67, 76, 85, 2, 17, 2, 65, + 71, 2, 131, 129, 9, 69, 5, 17, 2, 45, 65, 2, 203, 237, 9, 76, 6, 46, 69, + 184, 6, 2, 83, 72, 131, 232, 10, 73, 2, 229, 244, 9, 11, 80, 69, 78, 84, + 72, 69, 84, 73, 67, 32, 89, 28, 130, 1, 65, 154, 1, 66, 22, 78, 30, 83, + 134, 1, 90, 194, 170, 3, 84, 212, 154, 7, 9, 77, 69, 76, 79, 68, 73, 67, + 32, 81, 3, 81, 10, 76, 3, 70, 83, 65, 34, 78, 28, 2, 84, 77, 245, 198, + 10, 4, 82, 75, 65, 65, 2, 11, 65, 2, 151, 236, 10, 81, 4, 26, 78, 207, + 183, 9, 71, 2, 11, 65, 2, 243, 198, 10, 65, 2, 233, 144, 3, 2, 69, 81, 4, + 64, 4, 72, 73, 89, 89, 45, 8, 79, 70, 32, 77, 65, 83, 72, 70, 2, 11, 65, + 2, 11, 65, 2, 131, 242, 8, 76, 2, 139, 225, 9, 65, 4, 34, 65, 185, 241, + 8, 2, 73, 81, 2, 223, 232, 9, 69, 30, 92, 5, 76, 79, 78, 71, 32, 54, 79, + 66, 83, 182, 208, 6, 65, 234, 151, 4, 69, 2, 73, 3, 85, 10, 166, 209, 6, + 65, 234, 151, 4, 69, 2, 73, 3, 85, 7, 41, 8, 86, 69, 82, 76, 79, 78, 71, + 32, 4, 199, 208, 6, 65, 4, 26, 72, 199, 222, 5, 85, 2, 149, 153, 6, 3, + 79, 82, 84, 10, 68, 8, 83, 45, 83, 69, 82, 73, 70, 32, 241, 196, 10, 3, + 68, 87, 73, 8, 44, 6, 72, 69, 65, 86, 89, 32, 139, 2, 73, 6, 48, 3, 68, + 79, 85, 81, 5, 76, 79, 87, 32, 68, 4, 11, 66, 4, 21, 3, 76, 69, 32, 4, + 84, 6, 84, 85, 82, 78, 69, 68, 23, 67, 2, 21, 3, 79, 85, 66, 2, 17, 2, + 76, 69, 2, 17, 2, 32, 67, 2, 33, 6, 79, 77, 77, 65, 32, 81, 2, 153, 150, + 9, 3, 85, 79, 84, 2, 253, 160, 10, 10, 78, 84, 69, 82, 82, 79, 66, 65, + 78, 71, 6, 48, 6, 69, 76, 76, 73, 84, 69, 143, 203, 5, 85, 5, 25, 4, 32, + 65, 78, 84, 2, 139, 165, 7, 69, 168, 1, 50, 82, 245, 144, 5, 6, 68, 73, + 32, 82, 73, 89, 166, 1, 52, 7, 65, 83, 72, 84, 82, 65, 32, 207, 194, 4, + 79, 164, 1, 180, 1, 7, 76, 69, 84, 84, 69, 82, 32, 212, 1, 5, 83, 73, 71, + 78, 32, 250, 22, 68, 192, 250, 2, 16, 67, 79, 78, 83, 79, 78, 65, 78, 84, + 32, 83, 73, 71, 78, 32, 72, 187, 157, 2, 86, 100, 170, 254, 6, 65, 38, + 68, 114, 84, 46, 86, 186, 5, 85, 194, 142, 1, 79, 202, 61, 73, 42, 76, + 130, 199, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 162, + 7, 69, 234, 61, 72, 2, 77, 2, 82, 3, 89, 8, 226, 187, 6, 67, 226, 222, 3, + 65, 239, 1, 86, 52, 66, 65, 32, 4, 72, 79, 79, 76, 46, 79, 74, 82, 183, + 221, 10, 73, 4, 194, 200, 9, 76, 227, 20, 82, 5, 141, 195, 5, 6, 32, 83, + 65, 84, 67, 72, 6, 36, 3, 82, 80, 73, 199, 160, 9, 79, 4, 242, 141, 10, + 79, 135, 18, 85, 36, 66, 69, 72, 4, 73, 80, 84, 32, 154, 252, 1, 85, 203, + 210, 6, 79, 4, 36, 3, 87, 68, 82, 235, 140, 10, 69, 2, 11, 73, 2, 207, + 158, 10, 86, 28, 80, 8, 67, 65, 80, 73, 84, 65, 76, 32, 86, 76, 81, 6, + 83, 77, 65, 76, 76, 32, 18, 210, 219, 10, 66, 2, 69, 2, 70, 2, 72, 2, 73, + 2, 76, 2, 77, 2, 80, 3, 82, 2, 37, 7, 73, 71, 65, 84, 85, 82, 69, 2, 11, + 32, 2, 233, 150, 10, 2, 69, 84, 8, 174, 218, 10, 69, 2, 71, 2, 76, 3, 79, + 226, 1, 134, 2, 65, 30, 67, 254, 1, 69, 36, 5, 71, 77, 69, 78, 84, 28, 2, + 77, 73, 172, 1, 8, 80, 65, 82, 65, 84, 69, 68, 32, 138, 4, 82, 158, 1, + 83, 68, 2, 84, 32, 160, 142, 5, 8, 87, 73, 78, 71, 32, 78, 69, 69, 166, + 147, 3, 88, 174, 107, 68, 237, 165, 1, 2, 76, 70, 4, 246, 215, 10, 76, 3, + 84, 12, 34, 84, 133, 230, 5, 2, 79, 78, 10, 32, 2, 79, 82, 195, 204, 6, + 73, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 56, 5, 67, 72, 79, 82, 68, 65, + 5, 68, 79, 85, 66, 76, 5, 193, 210, 7, 11, 32, 65, 78, 68, 32, 68, 79, + 84, 84, 69, 68, 2, 131, 210, 7, 69, 4, 178, 224, 1, 68, 179, 132, 1, 45, + 23, 157, 193, 4, 2, 69, 68, 6, 212, 84, 28, 68, 73, 82, 69, 67, 84, 32, + 80, 82, 79, 68, 85, 67, 84, 32, 87, 73, 84, 72, 32, 66, 79, 84, 84, 79, + 77, 32, 67, 128, 212, 7, 3, 83, 69, 88, 199, 220, 1, 67, 158, 1, 48, 6, + 66, 76, 79, 67, 75, 32, 147, 190, 9, 83, 156, 1, 88, 9, 81, 85, 65, 68, + 82, 65, 78, 84, 45, 129, 1, 8, 83, 69, 88, 84, 65, 78, 84, 45, 30, 42, + 49, 38, 50, 30, 51, 243, 209, 10, 52, 17, 34, 50, 30, 51, 243, 209, 10, + 52, 9, 26, 51, 243, 209, 10, 52, 5, 239, 209, 10, 52, 126, 58, 49, 54, + 50, 46, 51, 38, 52, 30, 53, 131, 208, 10, 54, 65, 50, 50, 46, 51, 38, 52, + 30, 53, 131, 208, 10, 54, 33, 42, 51, 38, 52, 30, 53, 131, 208, 10, 54, + 17, 34, 52, 30, 53, 131, 208, 10, 54, 9, 26, 53, 131, 208, 10, 54, 5, + 255, 207, 10, 54, 4, 120, 2, 86, 73, 237, 174, 2, 22, 73, 79, 85, 83, 32, + 70, 65, 67, 69, 32, 87, 73, 84, 72, 32, 83, 89, 77, 66, 79, 76, 83, 2, + 11, 67, 2, 159, 141, 10, 69, 4, 52, 7, 81, 85, 73, 81, 85, 65, 68, 179, + 146, 9, 65, 2, 91, 82, 4, 64, 10, 84, 82, 65, 78, 83, 77, 73, 84, 32, 83, + 147, 189, 6, 77, 2, 11, 84, 2, 175, 129, 9, 65, 134, 3, 102, 65, 218, 20, + 73, 102, 79, 214, 13, 69, 70, 82, 168, 151, 9, 5, 85, 70, 70, 76, 69, + 195, 145, 1, 89, 192, 2, 164, 1, 12, 68, 79, 87, 69, 68, 32, 87, 72, 73, + 84, 69, 32, 56, 9, 76, 76, 79, 87, 32, 80, 65, 78, 32, 62, 82, 182, 10, + 86, 236, 201, 7, 2, 77, 82, 223, 237, 1, 75, 6, 230, 243, 8, 67, 230, 11, + 83, 233, 4, 3, 76, 65, 84, 2, 17, 2, 79, 70, 2, 17, 2, 32, 70, 2, 251, + 139, 7, 79, 210, 1, 40, 4, 65, 68, 65, 32, 239, 201, 10, 75, 208, 1, 162, + 1, 68, 46, 69, 110, 72, 34, 76, 246, 1, 83, 212, 2, 6, 86, 79, 87, 69, + 76, 32, 146, 201, 4, 65, 188, 211, 1, 7, 67, 79, 78, 84, 73, 78, 85, 163, + 149, 4, 79, 24, 154, 227, 6, 79, 66, 65, 215, 237, 1, 73, 4, 84, 15, 88, + 84, 82, 65, 32, 83, 72, 79, 82, 84, 32, 86, 79, 87, 69, 175, 135, 9, 75, + 2, 251, 133, 10, 76, 2, 161, 151, 10, 3, 69, 65, 68, 96, 33, 6, 69, 84, + 84, 69, 82, 32, 96, 130, 228, 6, 65, 38, 68, 114, 84, 46, 86, 186, 5, 85, + 138, 204, 1, 73, 42, 76, 130, 199, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, + 2, 74, 2, 75, 2, 80, 138, 69, 72, 2, 77, 2, 82, 2, 89, 186, 2, 69, 3, 79, + 30, 70, 65, 38, 69, 56, 4, 73, 71, 78, 32, 217, 190, 9, 3, 85, 84, 82, 2, + 137, 131, 10, 4, 78, 68, 72, 73, 6, 212, 205, 2, 5, 67, 84, 73, 79, 78, + 179, 193, 4, 80, 20, 106, 73, 146, 146, 5, 83, 162, 141, 1, 67, 98, 78, + 198, 67, 65, 178, 159, 1, 74, 150, 3, 85, 231, 249, 1, 86, 2, 37, 7, 78, + 86, 69, 82, 84, 69, 68, 2, 133, 159, 6, 2, 32, 67, 46, 60, 6, 77, 79, 68, + 73, 70, 73, 21, 5, 83, 73, 71, 78, 32, 2, 247, 147, 6, 69, 44, 110, 67, + 42, 79, 34, 80, 138, 185, 4, 85, 170, 229, 1, 83, 250, 69, 65, 58, 86, + 246, 203, 1, 73, 231, 143, 2, 69, 4, 145, 159, 6, 5, 65, 78, 68, 82, 65, + 7, 130, 170, 10, 79, 215, 22, 69, 2, 57, 12, 82, 73, 83, 72, 84, 72, 65, + 77, 65, 84, 82, 65, 2, 167, 169, 10, 32, 98, 72, 3, 69, 68, 32, 21, 11, + 73, 65, 78, 32, 76, 69, 84, 84, 69, 82, 32, 2, 159, 130, 10, 73, 96, 158, + 2, 65, 120, 3, 67, 72, 85, 22, 69, 70, 72, 46, 73, 46, 76, 22, 77, 38, + 79, 94, 80, 18, 82, 22, 83, 38, 84, 64, 2, 87, 79, 36, 2, 89, 69, 188, + 245, 4, 2, 74, 85, 138, 230, 2, 68, 202, 13, 90, 190, 89, 70, 182, 6, 71, + 254, 45, 66, 186, 14, 75, 242, 21, 86, 178, 28, 78, 167, 128, 1, 85, 16, + 82, 82, 186, 131, 10, 73, 234, 25, 68, 162, 8, 71, 2, 87, 198, 21, 83, + 147, 1, 72, 4, 242, 173, 9, 82, 163, 142, 1, 69, 2, 199, 153, 10, 82, 8, + 38, 65, 218, 130, 10, 82, 139, 56, 71, 4, 178, 187, 10, 82, 3, 84, 4, + 212, 186, 8, 2, 65, 45, 203, 175, 1, 85, 6, 138, 235, 9, 65, 142, 57, 67, + 215, 22, 70, 2, 247, 172, 8, 79, 4, 242, 159, 5, 69, 203, 128, 4, 73, 12, + 70, 79, 242, 173, 9, 73, 166, 111, 85, 150, 25, 65, 154, 3, 78, 3, 82, 2, + 235, 162, 10, 90, 2, 255, 15, 69, 2, 159, 149, 9, 79, 4, 138, 150, 9, 85, + 255, 162, 1, 79, 6, 26, 72, 159, 156, 10, 79, 4, 182, 133, 6, 73, 203, + 161, 4, 69, 4, 210, 172, 9, 79, 211, 139, 1, 69, 4, 254, 183, 10, 65, 3, + 87, 10, 78, 69, 194, 234, 3, 70, 232, 125, 6, 78, 84, 79, 32, 83, 72, + 239, 206, 5, 80, 2, 243, 240, 9, 76, 50, 252, 1, 2, 79, 84, 32, 6, 80, + 80, 73, 78, 71, 32, 72, 2, 82, 84, 128, 11, 7, 85, 76, 68, 69, 82, 69, + 68, 168, 240, 1, 24, 67, 75, 69, 68, 32, 70, 65, 67, 69, 32, 87, 73, 84, + 72, 32, 69, 88, 80, 76, 79, 68, 73, 78, 71, 218, 157, 3, 86, 175, 221, 4, + 87, 2, 237, 151, 8, 3, 73, 78, 71, 4, 36, 3, 84, 82, 79, 223, 243, 5, 66, + 2, 11, 76, 2, 179, 147, 8, 76, 36, 102, 32, 200, 8, 12, 72, 65, 78, 68, + 32, 70, 79, 82, 77, 65, 84, 32, 210, 185, 6, 67, 155, 241, 3, 83, 24, + 242, 1, 66, 92, 11, 83, 76, 65, 78, 84, 69, 68, 32, 78, 79, 82, 196, 1, + 4, 76, 69, 70, 84, 156, 1, 11, 82, 73, 71, 72, 84, 87, 65, 82, 68, 83, + 32, 248, 1, 7, 85, 80, 32, 84, 65, 67, 75, 129, 161, 2, 9, 68, 79, 87, + 78, 32, 84, 65, 67, 75, 4, 88, 14, 65, 67, 75, 83, 76, 65, 78, 84, 69, + 68, 32, 83, 79, 85, 33, 4, 69, 78, 84, 32, 2, 11, 84, 2, 195, 147, 9, 72, + 2, 221, 40, 37, 65, 82, 82, 79, 87, 32, 80, 79, 73, 78, 84, 73, 78, 71, + 32, 68, 79, 87, 78, 87, 65, 82, 68, 83, 32, 84, 72, 69, 78, 32, 78, 79, + 82, 84, 72, 32, 69, 4, 116, 24, 87, 65, 82, 68, 83, 32, 72, 65, 82, 80, + 79, 79, 78, 32, 65, 66, 79, 86, 69, 32, 76, 79, 78, 71, 171, 3, 32, 2, + 237, 1, 5, 32, 82, 73, 71, 72, 4, 112, 11, 65, 82, 82, 79, 87, 32, 65, + 66, 79, 86, 69, 29, 13, 72, 65, 82, 80, 79, 79, 78, 32, 65, 66, 79, 86, + 69, 2, 249, 129, 6, 2, 32, 76, 2, 29, 5, 32, 76, 79, 78, 71, 2, 25, 4, + 32, 76, 69, 70, 2, 217, 253, 6, 6, 84, 87, 65, 82, 68, 83, 7, 11, 32, 4, + 76, 13, 65, 66, 79, 86, 69, 32, 83, 72, 79, 82, 84, 32, 68, 243, 131, 2, + 87, 2, 11, 79, 2, 11, 87, 2, 11, 78, 2, 11, 32, 2, 171, 136, 7, 84, 8, + 120, 10, 67, 79, 78, 84, 73, 78, 85, 73, 78, 71, 0, 6, 76, 69, 84, 84, + 69, 82, 40, 4, 68, 79, 87, 78, 1, 2, 85, 80, 2, 201, 181, 3, 5, 32, 79, + 86, 69, 82, 2, 21, 3, 32, 83, 84, 2, 159, 169, 10, 69, 2, 25, 4, 32, 79, + 80, 69, 2, 151, 154, 9, 78, 4, 26, 73, 251, 167, 10, 85, 2, 191, 168, 10, + 77, 211, 14, 174, 1, 68, 152, 20, 2, 71, 78, 196, 181, 1, 6, 77, 73, 76, + 65, 82, 32, 158, 2, 78, 202, 24, 88, 177, 243, 6, 15, 76, 72, 79, 85, 69, + 84, 84, 69, 32, 79, 70, 32, 74, 65, 80, 252, 1, 40, 5, 68, 72, 65, 77, + 32, 135, 17, 69, 184, 1, 202, 1, 69, 68, 7, 76, 69, 84, 84, 69, 82, 32, + 176, 4, 15, 82, 69, 80, 69, 84, 73, 84, 73, 79, 78, 32, 77, 65, 82, 75, + 50, 83, 164, 8, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 131, 178, + 6, 68, 2, 37, 7, 78, 68, 32, 79, 70, 32, 84, 2, 145, 218, 9, 2, 69, 88, + 102, 214, 1, 65, 98, 84, 202, 191, 6, 68, 158, 1, 86, 186, 5, 85, 138, + 204, 1, 73, 170, 199, 1, 78, 46, 83, 82, 66, 2, 67, 2, 71, 2, 74, 2, 75, + 2, 80, 138, 69, 72, 2, 76, 2, 77, 2, 82, 2, 89, 186, 2, 69, 3, 79, 11, + 72, 8, 76, 84, 69, 82, 78, 65, 84, 69, 158, 162, 10, 65, 2, 73, 3, 85, 2, + 179, 253, 9, 32, 14, 134, 1, 72, 216, 233, 5, 19, 87, 79, 45, 67, 73, 82, + 67, 76, 69, 32, 65, 76, 84, 69, 82, 78, 65, 84, 69, 234, 239, 3, 84, 195, + 71, 65, 4, 236, 224, 9, 20, 82, 69, 69, 45, 67, 73, 82, 67, 76, 69, 32, + 65, 76, 84, 69, 82, 78, 65, 84, 69, 147, 64, 65, 6, 11, 45, 6, 130, 160, + 10, 49, 2, 50, 3, 51, 44, 38, 69, 181, 7, 4, 73, 71, 78, 32, 32, 96, 11, + 67, 84, 73, 79, 78, 32, 77, 65, 82, 75, 32, 177, 6, 8, 80, 65, 82, 65, + 84, 79, 82, 32, 28, 80, 11, 68, 79, 85, 66, 76, 69, 32, 82, 73, 78, 71, + 57, 5, 87, 73, 84, 72, 32, 5, 11, 32, 2, 129, 239, 8, 6, 87, 73, 84, 72, + 32, 82, 24, 212, 1, 12, 67, 73, 82, 67, 76, 69, 83, 32, 65, 78, 68, 32, + 116, 5, 81, 85, 65, 68, 82, 0, 4, 83, 69, 80, 84, 12, 16, 82, 65, 89, 83, + 32, 65, 78, 68, 32, 68, 79, 84, 84, 69, 68, 32, 46, 68, 45, 3, 84, 82, + 73, 6, 60, 4, 70, 79, 85, 82, 0, 3, 84, 87, 79, 195, 236, 8, 82, 2, 177, + 210, 6, 8, 32, 69, 78, 67, 76, 79, 83, 85, 2, 83, 85, 6, 42, 68, 28, 3, + 84, 82, 73, 215, 1, 67, 2, 197, 1, 3, 79, 85, 66, 2, 171, 1, 80, 6, 52, + 9, 68, 69, 78, 84, 32, 65, 78, 68, 32, 103, 80, 4, 116, 6, 68, 79, 84, + 84, 69, 68, 49, 14, 85, 45, 83, 72, 65, 80, 69, 68, 32, 79, 82, 78, 65, + 77, 2, 17, 2, 76, 69, 2, 17, 2, 32, 67, 2, 25, 4, 82, 69, 83, 67, 2, 251, + 186, 1, 69, 4, 166, 244, 8, 66, 199, 83, 68, 12, 138, 231, 4, 83, 162, + 141, 1, 67, 98, 78, 130, 222, 3, 65, 239, 1, 86, 26, 74, 65, 94, 86, 170, + 186, 6, 85, 138, 204, 1, 73, 230, 143, 2, 69, 3, 79, 10, 128, 187, 6, 10, + 76, 84, 69, 82, 78, 65, 84, 69, 32, 85, 238, 219, 3, 65, 2, 73, 3, 85, 4, + 11, 79, 4, 33, 6, 67, 65, 76, 73, 67, 32, 4, 215, 186, 6, 82, 68, 84, 12, + 84, 73, 67, 32, 76, 69, 84, 84, 69, 82, 32, 78, 49, 5, 87, 65, 89, 83, + 32, 52, 190, 156, 1, 50, 174, 178, 3, 48, 131, 2, 49, 16, 56, 5, 66, 76, + 65, 67, 75, 1, 5, 87, 72, 73, 84, 69, 8, 11, 32, 8, 70, 82, 24, 3, 76, + 69, 70, 12, 4, 68, 79, 87, 78, 1, 2, 85, 80, 2, 21, 3, 73, 71, 72, 2, 11, + 84, 2, 237, 92, 6, 32, 80, 79, 73, 78, 84, 194, 10, 96, 8, 87, 82, 73, + 84, 73, 78, 71, 32, 221, 238, 1, 10, 32, 79, 70, 32, 84, 72, 69, 32, 72, + 79, 192, 10, 136, 3, 4, 65, 73, 82, 32, 192, 1, 2, 66, 82, 102, 67, 138, + 1, 68, 218, 4, 69, 242, 6, 70, 244, 3, 4, 87, 65, 76, 76, 138, 1, 72, + 246, 77, 76, 212, 6, 2, 77, 79, 222, 42, 78, 218, 1, 82, 182, 7, 83, 162, + 5, 84, 180, 10, 5, 71, 82, 65, 83, 80, 184, 5, 30, 85, 80, 80, 69, 82, + 32, 66, 79, 68, 89, 32, 84, 73, 76, 84, 73, 78, 71, 32, 70, 82, 79, 77, + 32, 72, 73, 80, 32, 74, 79, 247, 208, 4, 80, 8, 48, 4, 66, 76, 79, 87, + 29, 4, 83, 85, 67, 75, 4, 58, 32, 179, 228, 4, 73, 4, 30, 32, 61, 3, 73, + 78, 71, 2, 249, 157, 1, 10, 83, 77, 65, 76, 76, 32, 82, 79, 84, 65, 2, + 243, 141, 9, 32, 10, 52, 5, 69, 65, 84, 72, 32, 241, 169, 1, 2, 85, 83, + 4, 140, 164, 2, 2, 69, 88, 1, 2, 73, 78, 10, 40, 6, 72, 69, 69, 75, 83, + 32, 63, 79, 6, 166, 107, 83, 146, 38, 78, 209, 198, 7, 4, 80, 85, 70, 70, + 4, 250, 187, 9, 76, 223, 46, 77, 28, 108, 15, 82, 69, 65, 77, 89, 32, 69, + 89, 69, 66, 82, 79, 87, 83, 32, 165, 1, 7, 89, 78, 65, 77, 73, 67, 32, 8, + 64, 4, 68, 79, 87, 78, 0, 2, 85, 80, 29, 4, 78, 69, 85, 84, 2, 165, 143, + 1, 2, 32, 78, 4, 21, 3, 82, 65, 76, 4, 11, 32, 4, 194, 58, 68, 135, 207, + 9, 85, 20, 180, 1, 11, 69, 86, 69, 82, 89, 32, 79, 84, 72, 69, 82, 30, + 70, 22, 83, 140, 122, 9, 65, 82, 82, 79, 87, 72, 69, 65, 68, 234, 38, 82, + 212, 207, 3, 2, 84, 69, 21, 4, 71, 82, 65, 68, 2, 253, 237, 8, 2, 32, 84, + 2, 251, 148, 6, 65, 6, 68, 11, 73, 77, 85, 76, 84, 65, 78, 69, 79, 85, + 83, 167, 234, 8, 76, 5, 215, 151, 1, 32, 54, 64, 2, 89, 69, 140, 229, 4, + 4, 88, 67, 73, 84, 179, 144, 4, 65, 50, 166, 1, 32, 56, 15, 66, 82, 79, + 87, 83, 32, 83, 84, 82, 65, 73, 71, 72, 84, 32, 44, 5, 71, 65, 90, 69, + 45, 140, 2, 7, 76, 65, 83, 72, 69, 83, 32, 65, 2, 83, 32, 6, 232, 150, 1, + 5, 66, 76, 73, 78, 75, 191, 132, 5, 87, 6, 186, 53, 68, 166, 84, 78, 227, + 250, 8, 85, 18, 100, 11, 70, 76, 79, 79, 82, 80, 76, 65, 78, 69, 32, 25, + 10, 87, 65, 76, 76, 80, 76, 65, 78, 69, 32, 8, 82, 83, 207, 45, 67, 10, + 18, 67, 43, 83, 4, 254, 45, 85, 225, 95, 3, 73, 82, 67, 6, 37, 7, 84, 82, + 65, 73, 71, 72, 84, 7, 11, 32, 4, 214, 163, 1, 65, 55, 68, 6, 130, 51, + 68, 148, 175, 4, 4, 70, 76, 85, 84, 243, 159, 5, 85, 14, 112, 5, 72, 65, + 76, 70, 32, 26, 67, 28, 4, 87, 73, 68, 69, 242, 92, 79, 161, 239, 7, 6, + 83, 81, 85, 69, 69, 90, 4, 22, 67, 143, 93, 79, 2, 221, 234, 2, 2, 76, + 79, 4, 162, 67, 32, 229, 61, 4, 78, 73, 78, 71, 38, 204, 1, 28, 65, 67, + 69, 32, 68, 73, 82, 69, 67, 84, 73, 79, 78, 32, 80, 79, 83, 73, 84, 73, + 79, 78, 32, 78, 79, 83, 69, 32, 138, 1, 73, 82, 76, 176, 1, 8, 79, 82, + 69, 72, 69, 65, 68, 32, 135, 162, 7, 85, 6, 88, 10, 85, 80, 32, 79, 82, + 32, 68, 79, 87, 78, 13, 8, 70, 79, 82, 87, 65, 82, 68, 32, 5, 11, 32, 2, + 241, 232, 4, 3, 84, 73, 76, 12, 148, 227, 3, 11, 76, 76, 32, 77, 79, 68, + 73, 70, 73, 69, 82, 251, 195, 2, 78, 12, 44, 4, 73, 67, 75, 32, 29, 3, + 79, 79, 82, 10, 138, 141, 1, 76, 35, 83, 2, 169, 255, 8, 20, 80, 76, 65, + 78, 69, 32, 83, 72, 79, 85, 76, 68, 69, 82, 32, 72, 73, 80, 32, 77, 6, + 178, 89, 87, 222, 38, 67, 47, 78, 156, 4, 34, 65, 145, 75, 3, 69, 65, 68, + 140, 4, 36, 3, 78, 68, 45, 215, 193, 9, 73, 138, 4, 92, 5, 65, 78, 71, + 76, 69, 138, 5, 67, 150, 10, 70, 186, 42, 72, 253, 12, 4, 79, 86, 65, 76, + 37, 11, 32, 34, 188, 1, 5, 73, 78, 68, 69, 88, 176, 1, 7, 76, 73, 84, 84, + 76, 69, 32, 136, 1, 5, 82, 73, 78, 71, 32, 185, 66, 18, 77, 73, 68, 68, + 76, 69, 32, 82, 73, 78, 71, 32, 76, 73, 84, 84, 76, 69, 17, 11, 32, 14, + 128, 1, 7, 77, 73, 68, 68, 76, 69, 32, 228, 24, 11, 82, 73, 78, 71, 32, + 76, 73, 84, 84, 76, 69, 253, 42, 5, 84, 72, 85, 77, 66, 4, 186, 70, 76, + 179, 223, 8, 82, 8, 44, 5, 73, 78, 68, 69, 88, 151, 246, 9, 85, 7, 145, + 24, 18, 32, 84, 72, 85, 77, 66, 32, 73, 78, 68, 69, 88, 32, 84, 72, 85, + 77, 66, 4, 108, 22, 68, 79, 87, 78, 32, 77, 73, 68, 68, 76, 69, 32, 84, + 72, 85, 77, 66, 32, 73, 78, 68, 69, 167, 68, 76, 2, 147, 174, 8, 88, 88, + 64, 5, 73, 82, 67, 76, 69, 184, 3, 3, 76, 65, 87, 183, 2, 85, 35, 11, 32, + 32, 116, 5, 73, 78, 68, 69, 88, 200, 1, 7, 76, 73, 84, 84, 76, 69, 32, + 36, 7, 77, 73, 68, 68, 76, 69, 32, 175, 64, 82, 21, 11, 32, 18, 72, 6, + 77, 73, 68, 68, 76, 69, 198, 26, 72, 254, 38, 82, 191, 237, 8, 66, 13, + 11, 32, 10, 64, 5, 67, 82, 79, 83, 83, 210, 64, 84, 82, 76, 179, 223, 8, + 82, 4, 146, 65, 32, 163, 234, 8, 69, 4, 202, 200, 8, 73, 223, 168, 1, 85, + 6, 252, 47, 10, 82, 73, 78, 71, 32, 76, 73, 84, 84, 76, 135, 193, 9, 85, + 17, 11, 32, 14, 144, 2, 28, 77, 73, 68, 68, 76, 69, 32, 82, 73, 78, 71, + 32, 76, 73, 84, 84, 76, 69, 32, 67, 79, 78, 74, 79, 73, 78, 69, 68, 176, + 49, 2, 70, 79, 210, 11, 78, 162, 1, 84, 169, 118, 23, 73, 78, 68, 69, 88, + 32, 84, 72, 85, 77, 66, 32, 67, 85, 82, 86, 69, 32, 84, 72, 85, 77, 66, + 5, 231, 180, 1, 32, 38, 46, 80, 149, 2, 6, 82, 76, 73, 67, 85, 69, 31, + 11, 32, 28, 188, 1, 5, 73, 78, 68, 69, 88, 56, 19, 70, 73, 86, 69, 32, + 70, 73, 78, 71, 69, 82, 83, 32, 83, 80, 82, 69, 65, 68, 196, 50, 7, 77, + 73, 68, 68, 76, 69, 32, 18, 79, 230, 7, 78, 163, 1, 84, 9, 11, 32, 6, 40, + 5, 84, 72, 85, 77, 66, 255, 58, 82, 5, 215, 46, 32, 9, 11, 32, 6, 72, 5, + 73, 78, 68, 69, 88, 0, 6, 77, 73, 68, 68, 76, 69, 191, 71, 79, 2, 137, + 155, 9, 13, 32, 82, 73, 78, 71, 32, 76, 73, 84, 84, 76, 69, 32, 172, 2, + 44, 3, 73, 83, 84, 177, 33, 3, 76, 65, 84, 247, 1, 11, 32, 244, 1, 160, + 2, 5, 73, 78, 68, 69, 88, 192, 16, 7, 76, 73, 84, 84, 76, 69, 32, 196, 2, + 7, 77, 73, 68, 68, 76, 69, 32, 200, 4, 5, 82, 73, 78, 71, 32, 132, 2, 5, + 84, 72, 85, 77, 66, 138, 2, 72, 205, 9, 22, 70, 79, 85, 82, 32, 70, 73, + 78, 71, 69, 82, 83, 32, 67, 79, 78, 74, 79, 73, 78, 69, 68, 137, 1, 11, + 32, 134, 1, 232, 1, 4, 66, 69, 78, 84, 36, 6, 72, 73, 78, 71, 69, 68, 76, + 6, 77, 73, 68, 68, 76, 69, 168, 7, 2, 67, 85, 64, 6, 84, 72, 85, 77, 66, + 32, 160, 5, 16, 85, 80, 32, 77, 73, 68, 68, 76, 69, 32, 72, 73, 78, 71, + 69, 68, 151, 4, 82, 5, 217, 45, 5, 32, 79, 86, 69, 82, 9, 11, 32, 6, 252, + 20, 8, 77, 73, 68, 68, 76, 69, 32, 85, 183, 179, 8, 76, 71, 11, 32, 68, + 236, 1, 4, 66, 69, 78, 84, 42, 67, 244, 1, 10, 85, 80, 32, 83, 80, 82, + 69, 65, 68, 32, 100, 6, 72, 73, 78, 71, 69, 68, 46, 82, 80, 5, 84, 72, + 85, 77, 66, 188, 28, 14, 83, 84, 82, 65, 73, 71, 72, 84, 32, 84, 72, 85, + 77, 66, 239, 17, 76, 5, 225, 92, 6, 32, 84, 72, 85, 77, 66, 28, 68, 8, + 79, 78, 74, 79, 73, 78, 69, 68, 233, 1, 4, 82, 79, 83, 83, 23, 11, 32, + 20, 144, 1, 6, 67, 85, 80, 80, 69, 68, 28, 6, 84, 72, 85, 77, 66, 32, 68, + 5, 72, 73, 78, 71, 69, 166, 22, 73, 165, 7, 6, 77, 73, 68, 68, 76, 69, 5, + 11, 32, 2, 203, 27, 84, 8, 160, 1, 4, 83, 73, 68, 69, 231, 61, 70, 6, 22, + 69, 171, 47, 32, 4, 223, 15, 68, 5, 241, 30, 7, 32, 83, 80, 82, 69, 65, + 68, 8, 32, 3, 73, 78, 71, 247, 19, 65, 7, 11, 32, 4, 138, 36, 67, 203, + 247, 8, 66, 19, 11, 32, 16, 64, 6, 65, 78, 71, 76, 69, 68, 22, 67, 106, + 72, 235, 153, 9, 66, 5, 183, 223, 5, 32, 6, 74, 85, 230, 7, 73, 241, 25, + 10, 79, 78, 74, 79, 73, 78, 69, 68, 32, 72, 2, 141, 169, 8, 2, 80, 80, 4, + 194, 33, 73, 229, 26, 2, 79, 79, 40, 164, 1, 7, 65, 78, 71, 76, 69, 68, 32, 46, 67, 220, 1, 14, 70, 79, 82, 87, 65, 82, 68, 32, 73, 78, 68, 69, 88, 32, 32, 4, 72, 79, 79, 75, 53, 4, 83, 73, 68, 69, 4, 128, 1, 2, 73, 78, 1, 3, 79, 85, 84, 12, 36, 5, 73, 82, 67, 76, 69, 15, 85, 5, 47, 68, - 8, 32, 4, 80, 80, 69, 68, 39, 82, 2, 225, 40, 5, 32, 77, 73, 68, 68, 6, - 56, 9, 86, 69, 32, 84, 72, 85, 77, 66, 32, 143, 37, 76, 4, 162, 160, 1, - 73, 163, 198, 4, 85, 4, 202, 84, 83, 131, 186, 8, 66, 7, 157, 8, 9, 69, + 8, 32, 4, 80, 80, 69, 68, 39, 82, 2, 237, 40, 5, 32, 77, 73, 68, 68, 6, + 56, 9, 86, 69, 32, 84, 72, 85, 77, 66, 32, 155, 37, 76, 4, 146, 160, 1, + 73, 139, 201, 4, 85, 4, 214, 84, 83, 191, 193, 8, 66, 7, 157, 8, 9, 69, 68, 32, 77, 73, 68, 68, 76, 69, 15, 11, 32, 12, 92, 6, 73, 78, 68, 69, 88, 32, 156, 13, 5, 84, 72, 85, 77, 66, 193, 8, 4, 66, 79, 84, 72, 4, 26, - 72, 243, 140, 9, 66, 2, 215, 152, 8, 73, 7, 37, 7, 32, 84, 72, 85, 77, - 66, 32, 4, 178, 28, 67, 207, 129, 1, 83, 22, 88, 4, 68, 79, 87, 78, 186, - 1, 84, 158, 6, 82, 130, 21, 73, 230, 238, 8, 66, 159, 67, 85, 9, 11, 32, + 72, 187, 148, 9, 66, 2, 155, 157, 8, 73, 7, 37, 7, 32, 84, 72, 85, 77, + 66, 32, 4, 178, 28, 67, 191, 129, 1, 83, 22, 88, 4, 68, 79, 87, 78, 186, + 1, 84, 158, 6, 82, 130, 21, 73, 174, 246, 8, 66, 159, 67, 85, 9, 11, 32, 6, 80, 9, 79, 84, 72, 69, 82, 83, 32, 67, 73, 25, 7, 82, 73, 80, 80, 76, - 69, 32, 2, 225, 51, 2, 82, 67, 4, 22, 67, 171, 80, 83, 2, 11, 85, 2, 169, - 185, 4, 2, 82, 86, 4, 196, 35, 6, 79, 85, 67, 72, 69, 83, 39, 72, 30, - 134, 1, 82, 28, 6, 84, 72, 85, 77, 66, 32, 138, 3, 85, 134, 1, 68, 210, - 30, 76, 189, 128, 8, 9, 66, 69, 78, 84, 32, 79, 86, 69, 82, 4, 238, 4, - 65, 231, 29, 73, 16, 80, 7, 65, 78, 71, 76, 69, 68, 32, 126, 67, 124, 4, - 72, 79, 79, 75, 147, 32, 76, 6, 60, 10, 79, 85, 84, 32, 73, 78, 68, 69, - 88, 32, 215, 1, 73, 4, 26, 67, 155, 202, 9, 85, 2, 249, 185, 2, 3, 82, + 69, 32, 2, 237, 51, 2, 82, 67, 4, 22, 67, 183, 80, 83, 2, 11, 85, 2, 237, + 160, 8, 2, 82, 86, 4, 208, 35, 6, 79, 85, 67, 72, 69, 83, 39, 72, 30, + 134, 1, 82, 28, 6, 84, 72, 85, 77, 66, 32, 138, 3, 85, 134, 1, 68, 222, + 30, 76, 185, 135, 8, 9, 66, 69, 78, 84, 32, 79, 86, 69, 82, 4, 238, 4, + 65, 243, 29, 73, 16, 80, 7, 65, 78, 71, 76, 69, 68, 32, 126, 67, 124, 4, + 72, 79, 79, 75, 159, 32, 76, 6, 60, 10, 79, 85, 84, 32, 73, 78, 68, 69, + 88, 32, 215, 1, 73, 4, 26, 67, 227, 209, 9, 85, 2, 129, 188, 2, 3, 82, 79, 83, 6, 76, 12, 73, 82, 67, 76, 69, 68, 32, 73, 78, 68, 69, 88, 45, 3, - 85, 80, 80, 4, 11, 32, 4, 150, 21, 72, 135, 180, 9, 85, 2, 25, 4, 69, 68, - 32, 73, 2, 233, 30, 4, 78, 68, 69, 88, 4, 11, 80, 5, 175, 15, 32, 18, - 102, 68, 20, 6, 77, 73, 68, 68, 76, 69, 42, 82, 198, 29, 84, 82, 76, 210, - 128, 8, 73, 159, 168, 1, 85, 2, 151, 241, 7, 79, 7, 11, 32, 4, 206, 3, + 85, 80, 80, 4, 11, 32, 4, 150, 21, 72, 207, 187, 9, 85, 2, 25, 4, 69, 68, + 32, 73, 2, 245, 30, 4, 78, 68, 69, 88, 4, 11, 80, 5, 175, 15, 32, 18, + 102, 68, 20, 6, 77, 73, 68, 68, 76, 69, 42, 82, 210, 29, 84, 82, 76, 206, + 135, 8, 73, 223, 168, 1, 85, 2, 207, 245, 7, 79, 7, 11, 32, 4, 206, 3, 82, 179, 16, 67, 2, 11, 65, 2, 37, 7, 73, 83, 69, 68, 32, 75, 78, 2, 11, - 85, 2, 11, 67, 2, 131, 160, 8, 75, 35, 11, 32, 32, 148, 1, 8, 66, 69, 84, + 85, 2, 11, 67, 2, 139, 167, 8, 75, 35, 11, 32, 32, 148, 1, 8, 66, 69, 84, 87, 69, 69, 78, 32, 102, 72, 20, 5, 79, 86, 69, 82, 32, 120, 4, 83, 73, - 68, 69, 100, 6, 85, 78, 68, 69, 82, 32, 207, 40, 70, 8, 80, 12, 73, 78, - 68, 69, 88, 32, 77, 73, 68, 68, 76, 69, 246, 20, 77, 155, 6, 82, 5, 135, - 70, 32, 2, 243, 174, 4, 69, 4, 52, 6, 70, 79, 85, 82, 32, 82, 161, 2, 2, - 84, 87, 2, 11, 65, 2, 233, 80, 9, 73, 83, 69, 68, 32, 75, 78, 85, 67, 6, - 11, 32, 6, 38, 68, 190, 15, 67, 131, 240, 8, 66, 2, 25, 4, 73, 65, 71, - 79, 2, 235, 182, 8, 78, 10, 54, 73, 34, 84, 48, 4, 70, 79, 85, 82, 131, + 68, 69, 100, 6, 85, 78, 68, 69, 82, 32, 219, 40, 70, 8, 80, 12, 73, 78, + 68, 69, 88, 32, 77, 73, 68, 68, 76, 69, 130, 21, 77, 155, 6, 82, 5, 147, + 70, 32, 2, 211, 176, 4, 69, 4, 52, 6, 70, 79, 85, 82, 32, 82, 161, 2, 2, + 84, 87, 2, 11, 65, 2, 245, 80, 9, 73, 83, 69, 68, 32, 75, 78, 85, 67, 6, + 11, 32, 6, 38, 68, 190, 15, 67, 203, 247, 8, 66, 2, 25, 4, 73, 65, 71, + 79, 2, 179, 190, 8, 78, 10, 54, 73, 34, 84, 48, 4, 70, 79, 85, 82, 143, 23, 76, 2, 161, 7, 4, 78, 68, 69, 88, 4, 34, 87, 13, 4, 72, 82, 69, 69, - 2, 11, 79, 2, 173, 176, 8, 5, 32, 70, 73, 78, 71, 55, 11, 32, 52, 194, 1, + 2, 11, 79, 2, 245, 183, 8, 5, 32, 70, 73, 78, 71, 55, 11, 32, 52, 194, 1, 70, 172, 3, 4, 72, 69, 69, 76, 192, 1, 6, 83, 80, 76, 73, 84, 32, 236, 1, - 6, 84, 72, 85, 77, 66, 32, 205, 249, 4, 16, 66, 69, 84, 87, 69, 69, 78, + 6, 84, 72, 85, 77, 66, 32, 169, 251, 4, 16, 66, 69, 84, 87, 69, 69, 78, 32, 80, 65, 76, 77, 32, 70, 65, 67, 24, 140, 1, 18, 73, 86, 69, 32, 70, 73, 78, 71, 69, 82, 83, 32, 83, 80, 82, 69, 65, 68, 165, 1, 11, 79, 85, 82, 32, 70, 73, 78, 71, 69, 82, 83, 15, 11, 32, 12, 68, 6, 72, 73, 78, - 71, 69, 68, 42, 84, 186, 2, 70, 203, 247, 8, 66, 7, 11, 32, 4, 190, 4, - 84, 155, 15, 78, 2, 189, 35, 6, 72, 85, 77, 66, 32, 70, 11, 11, 32, 8, - 72, 9, 67, 79, 78, 74, 79, 73, 78, 69, 68, 154, 8, 72, 235, 240, 8, 66, - 5, 225, 159, 9, 3, 32, 83, 80, 11, 11, 32, 8, 96, 19, 70, 73, 86, 69, 32, + 71, 69, 68, 42, 84, 186, 2, 70, 147, 255, 8, 66, 7, 11, 32, 4, 190, 4, + 84, 167, 15, 78, 2, 201, 35, 6, 72, 85, 77, 66, 32, 70, 11, 11, 32, 8, + 72, 9, 67, 79, 78, 74, 79, 73, 78, 69, 68, 154, 8, 72, 179, 248, 8, 66, + 5, 169, 167, 9, 3, 32, 83, 80, 11, 11, 32, 8, 96, 19, 70, 73, 86, 69, 32, 70, 73, 78, 71, 69, 82, 83, 32, 83, 80, 82, 69, 65, 68, 151, 2, 84, 7, - 11, 32, 4, 26, 70, 203, 247, 8, 66, 2, 21, 3, 79, 85, 82, 2, 167, 1, 32, - 10, 72, 6, 67, 69, 78, 84, 82, 69, 96, 5, 73, 78, 68, 69, 88, 167, 16, + 11, 32, 4, 26, 70, 147, 255, 8, 66, 2, 21, 3, 79, 85, 82, 2, 167, 1, 32, + 10, 72, 6, 67, 69, 78, 84, 82, 69, 96, 5, 73, 78, 68, 69, 88, 179, 16, 76, 7, 49, 10, 32, 84, 72, 85, 77, 66, 32, 83, 73, 68, 4, 11, 69, 5, 11, - 32, 2, 135, 246, 8, 66, 2, 11, 32, 2, 11, 84, 2, 153, 135, 1, 5, 72, 85, - 77, 66, 32, 6, 242, 30, 70, 142, 104, 83, 183, 238, 7, 66, 82, 48, 4, 73, - 78, 71, 69, 181, 9, 3, 79, 79, 75, 63, 11, 32, 60, 206, 1, 70, 172, 1, 5, + 32, 2, 207, 253, 8, 66, 2, 11, 32, 2, 11, 84, 2, 137, 135, 1, 5, 72, 85, + 77, 66, 32, 6, 254, 30, 70, 242, 103, 83, 143, 246, 7, 66, 82, 48, 4, 73, + 78, 71, 69, 193, 9, 3, 79, 79, 75, 63, 11, 32, 60, 206, 1, 70, 172, 1, 5, 73, 78, 68, 69, 88, 196, 2, 6, 76, 73, 84, 84, 76, 69, 80, 6, 77, 73, 68, 68, 76, 69, 30, 79, 64, 4, 82, 73, 78, 71, 124, 6, 84, 72, 85, 77, 66, - 32, 158, 6, 78, 195, 147, 4, 83, 4, 92, 19, 73, 86, 69, 32, 70, 73, 78, - 71, 69, 82, 83, 32, 83, 80, 82, 69, 65, 68, 32, 19, 79, 2, 191, 25, 79, + 32, 170, 6, 78, 151, 149, 4, 83, 4, 92, 19, 73, 86, 69, 32, 70, 73, 78, + 71, 69, 82, 83, 32, 83, 80, 82, 69, 65, 68, 32, 19, 79, 2, 203, 25, 79, 2, 249, 1, 11, 85, 82, 32, 70, 73, 78, 71, 69, 82, 83, 32, 23, 11, 32, 20, 86, 72, 40, 7, 77, 73, 68, 68, 76, 69, 32, 104, 5, 84, 72, 85, 77, - 66, 219, 9, 82, 2, 11, 73, 2, 233, 159, 4, 2, 78, 71, 6, 36, 4, 82, 73, - 78, 71, 203, 10, 76, 5, 11, 32, 2, 11, 67, 2, 21, 3, 79, 78, 74, 2, 175, - 33, 79, 11, 11, 32, 8, 34, 83, 210, 22, 79, 203, 39, 76, 4, 218, 159, 7, - 73, 195, 8, 77, 9, 11, 32, 6, 22, 73, 199, 8, 84, 4, 25, 4, 78, 68, 69, - 88, 5, 155, 8, 32, 5, 11, 32, 2, 171, 8, 82, 8, 21, 3, 80, 69, 78, 9, 11, - 32, 6, 178, 7, 78, 163, 1, 84, 5, 97, 22, 32, 68, 79, 87, 78, 32, 73, 78, - 68, 69, 88, 32, 84, 72, 85, 77, 66, 32, 72, 79, 79, 75, 2, 157, 77, 2, - 32, 77, 6, 68, 9, 66, 69, 84, 87, 69, 69, 78, 32, 77, 53, 4, 83, 73, 68, - 69, 2, 29, 5, 73, 68, 68, 76, 69, 2, 219, 153, 4, 32, 5, 33, 6, 32, 84, - 79, 85, 67, 72, 2, 169, 134, 8, 3, 73, 78, 71, 21, 11, 32, 18, 172, 1, 4, - 67, 85, 82, 76, 28, 18, 73, 78, 68, 69, 88, 32, 82, 73, 78, 71, 32, 76, - 73, 84, 84, 76, 69, 32, 48, 7, 77, 73, 68, 68, 76, 69, 32, 225, 2, 4, 82, - 73, 78, 71, 2, 173, 157, 5, 2, 73, 67, 6, 154, 193, 5, 85, 134, 242, 2, - 79, 243, 41, 73, 8, 104, 21, 82, 73, 78, 71, 32, 76, 73, 84, 84, 76, 69, - 32, 67, 79, 78, 74, 79, 73, 78, 69, 68, 143, 2, 84, 7, 211, 228, 2, 32, - 17, 11, 32, 14, 112, 14, 70, 73, 86, 69, 32, 70, 73, 78, 71, 69, 82, 83, - 32, 83, 22, 76, 66, 78, 70, 82, 94, 84, 167, 128, 8, 73, 2, 219, 160, 2, - 80, 2, 21, 3, 73, 84, 84, 2, 17, 2, 76, 69, 2, 139, 180, 8, 32, 2, 11, - 79, 2, 11, 32, 2, 11, 84, 2, 11, 72, 2, 167, 134, 6, 85, 2, 11, 73, 2, - 21, 3, 78, 71, 32, 2, 11, 76, 2, 11, 73, 2, 11, 84, 2, 163, 130, 8, 84, - 4, 29, 5, 72, 85, 77, 66, 32, 4, 194, 14, 70, 143, 104, 83, 17, 11, 32, - 14, 56, 8, 77, 79, 86, 69, 77, 69, 78, 84, 251, 164, 8, 82, 12, 26, 45, - 139, 211, 7, 32, 10, 100, 11, 70, 76, 79, 79, 82, 80, 76, 65, 78, 69, 32, - 25, 10, 87, 65, 76, 76, 80, 76, 65, 78, 69, 32, 4, 62, 67, 223, 40, 83, - 6, 38, 67, 28, 2, 84, 73, 195, 40, 83, 2, 173, 169, 8, 2, 85, 82, 2, 187, - 137, 9, 76, 38, 50, 73, 225, 3, 7, 79, 67, 65, 84, 73, 79, 78, 22, 32, 3, - 77, 66, 32, 171, 1, 80, 16, 56, 4, 67, 79, 77, 66, 29, 6, 76, 69, 78, 71, - 84, 72, 2, 241, 222, 5, 2, 73, 78, 14, 11, 45, 14, 150, 164, 9, 49, 2, - 50, 2, 51, 2, 52, 2, 53, 2, 54, 3, 55, 6, 58, 32, 153, 1, 9, 83, 32, 80, - 82, 69, 83, 83, 69, 68, 4, 116, 12, 76, 79, 87, 69, 82, 32, 79, 86, 69, - 82, 32, 85, 133, 135, 8, 11, 85, 80, 80, 69, 82, 32, 79, 86, 69, 82, 32, - 2, 11, 80, 2, 167, 228, 8, 80, 2, 29, 5, 32, 84, 79, 71, 69, 2, 11, 84, - 2, 231, 227, 8, 72, 16, 22, 32, 203, 1, 45, 12, 148, 1, 2, 72, 69, 240, - 177, 2, 3, 84, 79, 82, 168, 233, 4, 3, 68, 69, 80, 0, 3, 87, 73, 68, 189, - 124, 10, 76, 73, 77, 66, 83, 32, 68, 73, 71, 73, 4, 196, 13, 4, 65, 68, - 32, 78, 135, 232, 8, 73, 4, 52, 5, 70, 76, 79, 79, 82, 1, 4, 87, 65, 76, - 76, 2, 225, 224, 8, 5, 80, 76, 65, 78, 69, 156, 3, 64, 4, 85, 84, 72, 32, - 161, 5, 7, 86, 69, 77, 69, 78, 84, 45, 54, 186, 1, 67, 88, 5, 70, 82, 79, - 87, 78, 0, 5, 83, 77, 73, 76, 69, 56, 4, 75, 73, 83, 83, 36, 5, 79, 80, - 69, 78, 32, 192, 1, 5, 84, 69, 78, 83, 69, 165, 29, 5, 87, 82, 73, 78, - 75, 8, 48, 6, 76, 79, 83, 69, 68, 32, 147, 235, 7, 79, 6, 222, 2, 70, - 142, 38, 67, 47, 78, 7, 11, 32, 4, 22, 79, 203, 1, 87, 2, 251, 197, 7, - 80, 7, 11, 32, 4, 166, 1, 87, 83, 70, 18, 100, 4, 79, 86, 65, 76, 0, 9, - 82, 69, 67, 84, 65, 78, 71, 76, 69, 42, 87, 82, 70, 211, 197, 7, 67, 7, - 11, 32, 4, 26, 87, 255, 195, 7, 89, 2, 25, 4, 82, 73, 78, 75, 2, 131, - 134, 4, 76, 7, 11, 32, 4, 18, 70, 43, 83, 2, 17, 2, 79, 82, 2, 215, 128, - 8, 87, 2, 17, 2, 85, 67, 2, 147, 133, 4, 75, 230, 2, 192, 1, 9, 68, 73, - 65, 71, 79, 78, 65, 76, 32, 148, 1, 11, 70, 76, 79, 79, 82, 80, 76, 65, - 78, 69, 32, 184, 14, 6, 72, 73, 78, 71, 69, 32, 189, 2, 10, 87, 65, 76, - 76, 80, 76, 65, 78, 69, 32, 32, 56, 8, 66, 69, 84, 87, 69, 69, 78, 32, - 22, 65, 31, 84, 16, 18, 65, 31, 84, 8, 229, 28, 3, 87, 65, 89, 8, 201, - 28, 6, 79, 87, 65, 82, 68, 83, 150, 1, 208, 2, 24, 65, 82, 77, 32, 67, - 73, 82, 67, 76, 69, 32, 72, 73, 84, 84, 73, 78, 71, 32, 87, 65, 76, 76, - 32, 38, 66, 34, 67, 224, 1, 8, 70, 73, 78, 71, 69, 82, 32, 67, 52, 5, 72, - 85, 77, 80, 32, 184, 3, 5, 76, 79, 79, 80, 32, 198, 1, 83, 108, 7, 84, - 82, 73, 80, 76, 69, 32, 110, 87, 206, 12, 68, 198, 2, 80, 154, 6, 90, - 231, 246, 7, 74, 12, 178, 7, 76, 154, 9, 77, 39, 83, 8, 150, 17, 79, 151, - 242, 7, 69, 28, 86, 72, 20, 5, 85, 82, 86, 69, 32, 196, 29, 5, 79, 82, - 78, 69, 82, 211, 177, 7, 82, 2, 195, 224, 7, 69, 18, 80, 4, 67, 79, 77, - 66, 158, 8, 72, 230, 15, 76, 194, 172, 2, 77, 247, 182, 1, 83, 2, 11, 73, - 2, 187, 253, 3, 78, 6, 128, 9, 6, 73, 82, 67, 76, 69, 83, 239, 20, 79, - 18, 56, 8, 72, 73, 84, 84, 73, 78, 71, 32, 167, 250, 3, 83, 16, 72, 8, - 67, 69, 73, 76, 73, 78, 71, 32, 101, 6, 70, 76, 79, 79, 82, 32, 8, 56, 5, - 76, 65, 82, 71, 69, 1, 5, 83, 77, 65, 76, 76, 4, 11, 32, 4, 206, 54, 84, - 135, 2, 68, 8, 88, 4, 83, 77, 65, 76, 12, 5, 76, 65, 82, 71, 69, 17, 7, - 84, 82, 73, 80, 76, 69, 32, 2, 11, 76, 2, 255, 18, 32, 4, 56, 5, 76, 65, - 82, 71, 69, 1, 5, 83, 77, 65, 76, 76, 2, 253, 52, 2, 32, 84, 18, 56, 8, - 72, 73, 84, 84, 73, 78, 71, 32, 239, 246, 3, 83, 16, 64, 7, 67, 69, 73, - 76, 73, 78, 71, 1, 5, 70, 76, 79, 79, 82, 8, 11, 32, 8, 22, 76, 191, 9, - 83, 4, 249, 22, 4, 65, 82, 71, 69, 12, 44, 6, 72, 65, 75, 73, 78, 71, - 243, 16, 73, 2, 21, 3, 32, 80, 65, 2, 149, 246, 3, 4, 82, 65, 76, 76, 8, - 76, 12, 65, 76, 84, 69, 82, 78, 65, 84, 73, 78, 71, 32, 138, 18, 87, 63, - 83, 4, 134, 18, 87, 255, 20, 77, 18, 80, 4, 65, 86, 69, 32, 169, 1, 11, - 82, 73, 83, 84, 32, 67, 73, 82, 67, 76, 69, 14, 30, 72, 102, 83, 171, 20, - 76, 8, 37, 7, 73, 84, 84, 73, 78, 71, 32, 8, 252, 2, 4, 67, 69, 73, 76, - 25, 5, 70, 76, 79, 79, 82, 4, 182, 156, 5, 78, 247, 225, 1, 77, 4, 209, - 5, 10, 32, 72, 73, 84, 84, 73, 78, 71, 32, 87, 14, 112, 3, 85, 80, 32, - 184, 1, 6, 68, 79, 87, 78, 32, 83, 197, 235, 5, 10, 83, 73, 68, 69, 32, - 84, 79, 32, 83, 73, 10, 40, 5, 68, 79, 87, 78, 32, 143, 1, 83, 8, 68, 8, - 65, 76, 84, 69, 82, 78, 65, 84, 230, 17, 76, 143, 222, 3, 83, 4, 21, 3, - 73, 78, 71, 4, 11, 32, 4, 190, 17, 76, 143, 222, 3, 83, 2, 187, 30, 69, - 162, 1, 148, 2, 11, 65, 82, 77, 32, 67, 73, 82, 67, 76, 69, 32, 98, 66, - 54, 67, 174, 4, 68, 100, 8, 70, 73, 78, 71, 69, 82, 32, 67, 64, 5, 72, - 85, 77, 80, 32, 60, 5, 76, 79, 79, 80, 32, 102, 80, 34, 83, 216, 1, 7, - 84, 82, 73, 80, 76, 69, 32, 218, 1, 87, 202, 2, 90, 231, 246, 7, 74, 8, - 18, 77, 39, 83, 4, 225, 13, 5, 69, 68, 73, 85, 77, 4, 11, 77, 4, 177, 13, - 3, 65, 76, 76, 12, 34, 79, 185, 13, 3, 69, 78, 68, 6, 183, 13, 88, 46, - 100, 6, 79, 82, 78, 69, 82, 32, 88, 4, 85, 82, 86, 69, 232, 11, 4, 72, - 69, 67, 75, 211, 177, 7, 82, 8, 54, 82, 194, 12, 76, 154, 167, 2, 77, - 247, 182, 1, 83, 2, 11, 79, 2, 159, 187, 5, 84, 30, 50, 32, 137, 2, 7, - 68, 32, 67, 82, 79, 83, 83, 26, 66, 72, 68, 2, 84, 72, 133, 5, 7, 81, 85, - 65, 82, 84, 69, 82, 12, 196, 5, 10, 65, 76, 70, 45, 67, 73, 82, 67, 76, - 69, 147, 14, 73, 6, 96, 2, 69, 78, 29, 18, 82, 69, 69, 45, 81, 85, 65, - 82, 84, 69, 82, 32, 67, 73, 82, 67, 76, 69, 2, 11, 32, 2, 131, 1, 83, 4, - 11, 32, 4, 238, 176, 2, 77, 247, 182, 1, 83, 8, 33, 6, 79, 85, 66, 76, - 69, 32, 8, 30, 83, 150, 4, 65, 75, 87, 2, 213, 210, 8, 3, 84, 82, 65, 6, + 66, 231, 9, 82, 2, 11, 73, 2, 173, 135, 8, 2, 78, 71, 6, 36, 4, 82, 73, + 78, 71, 215, 10, 76, 5, 11, 32, 2, 11, 67, 2, 21, 3, 79, 78, 74, 2, 187, + 33, 79, 11, 11, 32, 8, 34, 83, 222, 22, 79, 203, 39, 76, 4, 130, 164, 7, + 73, 195, 8, 77, 9, 11, 32, 6, 22, 73, 211, 8, 84, 4, 25, 4, 78, 68, 69, + 88, 5, 167, 8, 32, 5, 11, 32, 2, 183, 8, 82, 8, 21, 3, 80, 69, 78, 9, 11, + 32, 6, 190, 7, 78, 163, 1, 84, 5, 97, 22, 32, 68, 79, 87, 78, 32, 73, 78, + 68, 69, 88, 32, 84, 72, 85, 77, 66, 32, 72, 79, 79, 75, 2, 169, 77, 2, + 32, 77, 6, 60, 7, 66, 69, 84, 87, 69, 69, 78, 73, 4, 83, 73, 68, 69, 2, + 17, 2, 32, 77, 2, 29, 5, 73, 68, 68, 76, 69, 2, 175, 155, 4, 32, 5, 33, + 6, 32, 84, 79, 85, 67, 72, 2, 165, 141, 8, 3, 73, 78, 71, 21, 11, 32, 18, + 172, 1, 4, 67, 85, 82, 76, 28, 18, 73, 78, 68, 69, 88, 32, 82, 73, 78, + 71, 32, 76, 73, 84, 84, 76, 69, 32, 48, 7, 77, 73, 68, 68, 76, 69, 32, + 225, 2, 4, 82, 73, 78, 71, 2, 157, 159, 5, 2, 73, 67, 6, 230, 195, 5, 85, + 246, 246, 2, 79, 243, 41, 73, 8, 104, 21, 82, 73, 78, 71, 32, 76, 73, 84, + 84, 76, 69, 32, 67, 79, 78, 74, 79, 73, 78, 69, 68, 143, 2, 84, 7, 207, + 230, 2, 32, 17, 11, 32, 14, 112, 14, 70, 73, 86, 69, 32, 70, 73, 78, 71, + 69, 82, 83, 32, 83, 22, 76, 66, 78, 70, 82, 94, 84, 163, 135, 8, 73, 2, + 215, 162, 2, 80, 2, 21, 3, 73, 84, 84, 2, 17, 2, 76, 69, 2, 199, 187, 8, + 32, 2, 11, 79, 2, 11, 32, 2, 11, 84, 2, 11, 72, 2, 231, 137, 6, 85, 2, + 11, 73, 2, 21, 3, 78, 71, 32, 2, 11, 76, 2, 11, 73, 2, 11, 84, 2, 159, + 137, 8, 84, 4, 29, 5, 72, 85, 77, 66, 32, 4, 194, 14, 70, 243, 103, 83, + 17, 11, 32, 14, 56, 8, 77, 79, 86, 69, 77, 69, 78, 84, 183, 172, 8, 82, + 12, 26, 45, 183, 215, 7, 32, 10, 100, 11, 70, 76, 79, 79, 82, 80, 76, 65, + 78, 69, 32, 25, 10, 87, 65, 76, 76, 80, 76, 65, 78, 69, 32, 4, 62, 67, + 223, 40, 83, 6, 38, 67, 28, 2, 84, 73, 195, 40, 83, 2, 233, 176, 8, 2, + 85, 82, 2, 247, 144, 9, 76, 38, 50, 73, 225, 3, 7, 79, 67, 65, 84, 73, + 79, 78, 22, 32, 3, 77, 66, 32, 171, 1, 80, 16, 56, 4, 67, 79, 77, 66, 29, + 6, 76, 69, 78, 71, 84, 72, 2, 181, 225, 5, 2, 73, 78, 14, 11, 45, 14, + 210, 171, 9, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 3, 55, 6, 58, 32, + 153, 1, 9, 83, 32, 80, 82, 69, 83, 83, 69, 68, 4, 116, 12, 76, 79, 87, + 69, 82, 32, 79, 86, 69, 82, 32, 85, 193, 142, 8, 11, 85, 80, 80, 69, 82, + 32, 79, 86, 69, 82, 32, 2, 11, 80, 2, 227, 235, 8, 80, 2, 29, 5, 32, 84, + 79, 71, 69, 2, 11, 84, 2, 163, 235, 8, 72, 16, 22, 32, 203, 1, 45, 12, + 148, 1, 2, 72, 69, 236, 179, 2, 3, 84, 79, 82, 208, 235, 4, 3, 68, 69, + 80, 0, 3, 87, 73, 68, 213, 127, 10, 76, 73, 77, 66, 83, 32, 68, 73, 71, + 73, 4, 196, 13, 4, 65, 68, 32, 78, 195, 239, 8, 73, 4, 52, 5, 70, 76, 79, + 79, 82, 1, 4, 87, 65, 76, 76, 2, 157, 232, 8, 5, 80, 76, 65, 78, 69, 156, + 3, 64, 4, 85, 84, 72, 32, 161, 5, 7, 86, 69, 77, 69, 78, 84, 45, 54, 186, + 1, 67, 88, 5, 70, 82, 79, 87, 78, 0, 5, 83, 77, 73, 76, 69, 56, 4, 75, + 73, 83, 83, 36, 5, 79, 80, 69, 78, 32, 192, 1, 5, 84, 69, 78, 83, 69, + 165, 29, 5, 87, 82, 73, 78, 75, 8, 48, 6, 76, 79, 83, 69, 68, 32, 143, + 242, 7, 79, 6, 222, 2, 70, 142, 38, 67, 47, 78, 7, 11, 32, 4, 22, 79, + 203, 1, 87, 2, 167, 202, 7, 80, 7, 11, 32, 4, 166, 1, 87, 83, 70, 18, + 100, 4, 79, 86, 65, 76, 0, 9, 82, 69, 67, 84, 65, 78, 71, 76, 69, 42, 87, + 82, 70, 255, 201, 7, 67, 7, 11, 32, 4, 26, 87, 171, 200, 7, 89, 2, 25, 4, + 82, 73, 78, 75, 2, 187, 237, 7, 76, 7, 11, 32, 4, 18, 70, 43, 83, 2, 17, + 2, 79, 82, 2, 147, 136, 8, 87, 2, 17, 2, 85, 67, 2, 203, 236, 7, 75, 230, + 2, 192, 1, 9, 68, 73, 65, 71, 79, 78, 65, 76, 32, 148, 1, 11, 70, 76, 79, + 79, 82, 80, 76, 65, 78, 69, 32, 184, 14, 6, 72, 73, 78, 71, 69, 32, 189, + 2, 10, 87, 65, 76, 76, 80, 76, 65, 78, 69, 32, 32, 56, 8, 66, 69, 84, 87, + 69, 69, 78, 32, 22, 65, 31, 84, 16, 18, 65, 31, 84, 8, 229, 28, 3, 87, + 65, 89, 8, 201, 28, 6, 79, 87, 65, 82, 68, 83, 150, 1, 208, 2, 24, 65, + 82, 77, 32, 67, 73, 82, 67, 76, 69, 32, 72, 73, 84, 84, 73, 78, 71, 32, + 87, 65, 76, 76, 32, 38, 66, 34, 67, 224, 1, 8, 70, 73, 78, 71, 69, 82, + 32, 67, 52, 5, 72, 85, 77, 80, 32, 184, 3, 5, 76, 79, 79, 80, 32, 198, 1, + 83, 108, 7, 84, 82, 73, 80, 76, 69, 32, 110, 87, 206, 12, 68, 198, 2, 80, + 154, 6, 90, 163, 254, 7, 74, 12, 178, 7, 76, 154, 9, 77, 39, 83, 8, 150, + 17, 79, 211, 249, 7, 69, 28, 86, 72, 20, 5, 85, 82, 86, 69, 32, 196, 29, + 5, 79, 82, 78, 69, 82, 139, 182, 7, 82, 2, 191, 231, 7, 69, 18, 80, 4, + 67, 79, 77, 66, 158, 8, 72, 230, 15, 76, 190, 174, 2, 77, 207, 182, 1, + 83, 2, 11, 73, 2, 243, 228, 7, 78, 6, 128, 9, 6, 73, 82, 67, 76, 69, 83, + 239, 20, 79, 18, 56, 8, 72, 73, 84, 84, 73, 78, 71, 32, 251, 251, 3, 83, + 16, 72, 8, 67, 69, 73, 76, 73, 78, 71, 32, 101, 6, 70, 76, 79, 79, 82, + 32, 8, 56, 5, 76, 65, 82, 71, 69, 1, 5, 83, 77, 65, 76, 76, 4, 11, 32, 4, + 206, 54, 84, 135, 2, 68, 8, 88, 4, 83, 77, 65, 76, 12, 5, 76, 65, 82, 71, + 69, 17, 7, 84, 82, 73, 80, 76, 69, 32, 2, 11, 76, 2, 255, 18, 32, 4, 56, + 5, 76, 65, 82, 71, 69, 1, 5, 83, 77, 65, 76, 76, 2, 253, 52, 2, 32, 84, + 18, 56, 8, 72, 73, 84, 84, 73, 78, 71, 32, 195, 248, 3, 83, 16, 64, 7, + 67, 69, 73, 76, 73, 78, 71, 1, 5, 70, 76, 79, 79, 82, 8, 11, 32, 8, 22, + 76, 191, 9, 83, 4, 249, 22, 4, 65, 82, 71, 69, 12, 44, 6, 72, 65, 75, 73, + 78, 71, 243, 16, 73, 2, 21, 3, 32, 80, 65, 2, 233, 247, 3, 4, 82, 65, 76, + 76, 8, 76, 12, 65, 76, 84, 69, 82, 78, 65, 84, 73, 78, 71, 32, 138, 18, + 87, 63, 83, 4, 134, 18, 87, 255, 20, 77, 18, 80, 4, 65, 86, 69, 32, 169, + 1, 11, 82, 73, 83, 84, 32, 67, 73, 82, 67, 76, 69, 14, 30, 72, 102, 83, + 171, 20, 76, 8, 37, 7, 73, 84, 84, 73, 78, 71, 32, 8, 252, 2, 4, 67, 69, + 73, 76, 25, 5, 70, 76, 79, 79, 82, 4, 130, 159, 5, 78, 199, 227, 1, 77, + 4, 209, 5, 10, 32, 72, 73, 84, 84, 73, 78, 71, 32, 87, 14, 112, 3, 85, + 80, 32, 184, 1, 6, 68, 79, 87, 78, 32, 83, 133, 239, 5, 10, 83, 73, 68, + 69, 32, 84, 79, 32, 83, 73, 10, 40, 5, 68, 79, 87, 78, 32, 143, 1, 83, 8, + 68, 8, 65, 76, 84, 69, 82, 78, 65, 84, 230, 17, 76, 227, 223, 3, 83, 4, + 21, 3, 73, 78, 71, 4, 11, 32, 4, 190, 17, 76, 227, 223, 3, 83, 2, 187, + 30, 69, 162, 1, 148, 2, 11, 65, 82, 77, 32, 67, 73, 82, 67, 76, 69, 32, + 98, 66, 54, 67, 174, 4, 68, 100, 8, 70, 73, 78, 71, 69, 82, 32, 67, 64, + 5, 72, 85, 77, 80, 32, 60, 5, 76, 79, 79, 80, 32, 102, 80, 34, 83, 216, + 1, 7, 84, 82, 73, 80, 76, 69, 32, 218, 1, 87, 202, 2, 90, 163, 254, 7, + 74, 8, 18, 77, 39, 83, 4, 225, 13, 5, 69, 68, 73, 85, 77, 4, 11, 77, 4, + 177, 13, 3, 65, 76, 76, 12, 34, 79, 185, 13, 3, 69, 78, 68, 6, 183, 13, + 88, 46, 100, 6, 79, 82, 78, 69, 82, 32, 88, 4, 85, 82, 86, 69, 232, 11, + 4, 72, 69, 67, 75, 139, 182, 7, 82, 8, 54, 82, 194, 12, 76, 150, 169, 2, + 77, 207, 182, 1, 83, 2, 11, 79, 2, 227, 189, 5, 84, 30, 50, 32, 137, 2, + 7, 68, 32, 67, 82, 79, 83, 83, 26, 66, 72, 68, 2, 84, 72, 133, 5, 7, 81, + 85, 65, 82, 84, 69, 82, 12, 196, 5, 10, 65, 76, 70, 45, 67, 73, 82, 67, + 76, 69, 147, 14, 73, 6, 96, 2, 69, 78, 29, 18, 82, 69, 69, 45, 81, 85, + 65, 82, 84, 69, 82, 32, 67, 73, 82, 67, 76, 69, 2, 11, 32, 2, 131, 1, 83, + 4, 11, 32, 4, 234, 178, 2, 77, 207, 182, 1, 83, 8, 33, 6, 79, 85, 66, 76, + 69, 32, 8, 30, 83, 150, 4, 65, 75, 87, 2, 145, 218, 8, 3, 84, 82, 65, 6, 32, 3, 73, 82, 67, 151, 9, 79, 4, 173, 7, 3, 76, 69, 83, 10, 142, 8, 76, - 166, 8, 72, 246, 158, 2, 77, 247, 182, 1, 83, 12, 68, 5, 83, 77, 65, 76, - 76, 142, 7, 76, 166, 8, 72, 247, 158, 2, 77, 5, 11, 32, 2, 207, 36, 68, + 166, 8, 72, 242, 160, 2, 77, 207, 182, 1, 83, 12, 68, 5, 83, 77, 65, 76, + 76, 142, 7, 76, 166, 8, 72, 243, 160, 2, 77, 5, 11, 32, 2, 207, 36, 68, 6, 181, 6, 4, 69, 65, 75, 83, 12, 22, 73, 211, 36, 72, 10, 29, 5, 78, 71, 76, 69, 32, 10, 52, 8, 83, 84, 82, 65, 73, 71, 72, 84, 207, 1, 87, 8, 11, - 32, 8, 42, 76, 194, 172, 2, 77, 247, 182, 1, 83, 4, 25, 4, 65, 82, 71, - 69, 5, 151, 221, 8, 83, 8, 26, 65, 74, 87, 63, 83, 4, 49, 10, 76, 84, 69, + 32, 8, 42, 76, 190, 174, 2, 77, 207, 182, 1, 83, 4, 25, 4, 65, 82, 71, + 69, 5, 211, 228, 8, 83, 8, 26, 65, 74, 87, 63, 83, 4, 49, 10, 76, 84, 69, 82, 78, 65, 84, 73, 78, 71, 5, 17, 2, 32, 87, 2, 29, 5, 82, 73, 83, 84, - 32, 2, 149, 208, 7, 2, 70, 76, 2, 37, 7, 84, 82, 65, 73, 71, 72, 84, 2, + 32, 2, 145, 215, 7, 2, 70, 76, 2, 37, 7, 84, 82, 65, 73, 71, 72, 84, 2, 139, 20, 32, 26, 104, 4, 65, 86, 69, 32, 185, 1, 17, 82, 73, 83, 84, 32, 67, 73, 82, 67, 76, 69, 32, 70, 82, 79, 78, 84, 22, 108, 6, 67, 85, 82, 86, 69, 32, 140, 1, 13, 68, 73, 65, 71, 79, 78, 65, 76, 32, 80, 65, 84, 72, 223, 8, 72, 12, 48, 4, 68, 79, 85, 66, 1, 4, 84, 82, 73, 80, 6, 85, 2, 76, 69, 4, 11, 32, 4, 190, 30, 68, 43, 83, 6, 29, 5, 73, 71, 90, 65, - 71, 6, 11, 32, 6, 42, 76, 154, 167, 2, 77, 247, 182, 1, 83, 2, 159, 178, - 7, 65, 10, 40, 4, 79, 83, 69, 32, 247, 193, 7, 69, 8, 26, 67, 46, 78, 35, - 87, 2, 11, 79, 2, 193, 226, 7, 3, 78, 84, 65, 2, 197, 231, 7, 3, 69, 85, - 84, 4, 44, 3, 82, 73, 78, 237, 157, 1, 2, 73, 71, 2, 199, 177, 5, 75, 72, + 71, 6, 11, 32, 6, 42, 76, 150, 169, 2, 77, 207, 182, 1, 83, 2, 215, 182, + 7, 65, 10, 40, 4, 79, 83, 69, 32, 243, 200, 7, 69, 8, 26, 67, 46, 78, 35, + 87, 2, 11, 79, 2, 253, 233, 7, 3, 78, 84, 65, 2, 129, 239, 7, 3, 69, 85, + 84, 4, 44, 3, 82, 73, 78, 237, 157, 1, 2, 73, 71, 2, 139, 180, 5, 75, 72, 56, 7, 79, 84, 65, 84, 73, 79, 78, 205, 22, 2, 85, 66, 66, 60, 10, 32, - 77, 79, 68, 73, 70, 73, 69, 82, 45, 155, 1, 45, 30, 82, 49, 254, 240, 8, - 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 14, 250, 240, 8, 48, + 77, 79, 68, 73, 70, 73, 69, 82, 45, 155, 1, 45, 30, 82, 49, 186, 248, 8, + 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 14, 182, 248, 8, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 3, 54, 36, 104, 11, 70, 76, 79, 79, 82, 80, 76, 65, 78, 69, 32, 133, 2, 10, 87, 65, 76, 76, 80, 76, 65, 78, 69, 32, 18, 100, 4, 68, 79, 85, 66, 0, 4, 83, 73, 78, 71, 21, 11, 65, 76, 84, 69, 82, 78, 65, 84, 73, 78, 71, 6, 17, 2, 76, 69, 7, 45, 9, 32, 72, 73, 84, 84, 73, 78, 71, 32, 4, 32, 2, 67, 69, 33, 2, 70, 76, 2, 11, 73, - 2, 235, 156, 8, 76, 2, 243, 180, 8, 79, 18, 88, 8, 65, 76, 84, 69, 82, + 2, 167, 164, 8, 76, 2, 175, 188, 8, 79, 18, 88, 8, 65, 76, 84, 69, 82, 78, 65, 84, 44, 4, 68, 79, 85, 66, 1, 4, 83, 73, 78, 71, 6, 72, 4, 73, - 78, 71, 32, 163, 236, 8, 69, 6, 17, 2, 76, 69, 7, 11, 32, 4, 11, 72, 4, + 78, 71, 32, 223, 243, 8, 69, 6, 17, 2, 76, 69, 7, 11, 32, 4, 11, 72, 4, 11, 73, 4, 33, 6, 84, 84, 73, 78, 71, 32, 4, 44, 5, 70, 82, 79, 78, 84, - 139, 249, 4, 67, 2, 253, 224, 6, 2, 32, 87, 30, 172, 1, 8, 72, 79, 85, + 203, 251, 4, 67, 2, 153, 229, 6, 2, 32, 87, 30, 172, 1, 8, 72, 79, 85, 76, 68, 69, 82, 32, 196, 1, 7, 81, 85, 69, 69, 90, 69, 32, 240, 1, 7, 85, - 82, 70, 65, 67, 69, 32, 240, 10, 5, 84, 82, 73, 75, 69, 183, 140, 5, 69, - 6, 100, 4, 72, 73, 80, 32, 225, 251, 3, 15, 84, 73, 76, 84, 73, 78, 71, - 32, 70, 82, 79, 77, 32, 87, 65, 4, 48, 4, 80, 79, 83, 73, 145, 205, 7, 2, - 83, 80, 2, 11, 84, 2, 145, 161, 5, 2, 73, 79, 12, 48, 6, 70, 76, 73, 67, + 82, 70, 65, 67, 69, 32, 240, 10, 5, 84, 82, 73, 75, 69, 131, 143, 5, 69, + 6, 100, 4, 72, 73, 80, 32, 173, 253, 3, 15, 84, 73, 76, 84, 73, 78, 71, + 32, 70, 82, 79, 77, 32, 87, 65, 4, 48, 4, 80, 79, 83, 73, 205, 212, 7, 2, + 83, 80, 2, 11, 84, 2, 213, 163, 5, 2, 73, 79, 12, 48, 6, 70, 76, 73, 67, 75, 32, 18, 76, 35, 83, 2, 211, 16, 65, 4, 129, 1, 4, 65, 82, 71, 69, 6, 34, 69, 65, 4, 77, 65, 76, 76, 2, 17, 2, 81, 85, 2, 21, 3, 69, 78, 84, 2, - 147, 219, 7, 73, 4, 11, 32, 4, 214, 11, 77, 187, 4, 83, 4, 22, 83, 135, - 11, 66, 2, 129, 208, 1, 4, 89, 77, 66, 79, 82, 58, 69, 218, 2, 79, 137, + 207, 226, 7, 73, 4, 11, 32, 4, 214, 11, 77, 187, 4, 83, 4, 22, 83, 135, + 11, 66, 2, 253, 209, 1, 4, 89, 77, 66, 79, 82, 58, 69, 218, 2, 79, 137, 8, 6, 82, 65, 86, 69, 76, 45, 20, 76, 3, 69, 84, 72, 185, 1, 11, 78, 83, 69, 32, 67, 72, 69, 69, 75, 83, 32, 15, 11, 32, 12, 56, 3, 79, 78, 32, 86, 77, 177, 5, 4, 66, 73, 84, 69, 8, 56, 4, 76, 73, 80, 83, 1, 6, 84, - 79, 78, 71, 85, 69, 5, 11, 32, 2, 11, 77, 2, 149, 200, 3, 2, 79, 86, 6, - 50, 77, 220, 181, 4, 2, 72, 73, 255, 144, 3, 76, 2, 225, 168, 3, 2, 73, + 79, 78, 71, 85, 69, 5, 11, 32, 2, 11, 77, 2, 233, 201, 3, 2, 79, 86, 6, + 50, 77, 172, 183, 4, 2, 72, 73, 179, 150, 3, 76, 2, 205, 170, 3, 2, 73, 68, 28, 76, 5, 78, 71, 85, 69, 32, 196, 4, 4, 82, 83, 79, 45, 129, 2, 2, 85, 67, 16, 192, 2, 7, 67, 69, 78, 84, 82, 69, 32, 52, 14, 73, 78, 83, 73, 68, 69, 32, 77, 79, 85, 84, 72, 32, 82, 36, 4, 84, 73, 80, 32, 88, 7, - 76, 73, 67, 75, 73, 78, 71, 228, 186, 7, 14, 83, 84, 73, 67, 75, 73, 78, - 71, 32, 79, 85, 84, 32, 70, 153, 160, 1, 17, 77, 79, 86, 69, 83, 32, 65, - 71, 65, 73, 78, 83, 84, 32, 67, 72, 69, 4, 214, 1, 73, 129, 186, 3, 5, - 83, 84, 73, 67, 75, 2, 129, 203, 3, 4, 69, 76, 65, 88, 4, 84, 7, 66, 69, + 76, 73, 67, 75, 73, 78, 71, 224, 193, 7, 14, 83, 84, 73, 67, 75, 73, 78, + 71, 32, 79, 85, 84, 32, 70, 217, 160, 1, 17, 77, 79, 86, 69, 83, 32, 65, + 71, 65, 73, 78, 83, 84, 32, 67, 72, 69, 4, 214, 1, 73, 213, 187, 3, 5, + 83, 84, 73, 67, 75, 2, 185, 178, 7, 4, 69, 76, 65, 88, 4, 84, 7, 66, 69, 84, 87, 69, 69, 78, 41, 10, 84, 79, 85, 67, 72, 73, 78, 71, 32, 73, 2, - 11, 32, 2, 241, 165, 5, 2, 76, 73, 2, 241, 184, 5, 5, 78, 83, 73, 68, 69, - 6, 120, 10, 87, 65, 76, 76, 80, 76, 65, 78, 69, 32, 201, 205, 3, 14, 70, + 11, 32, 2, 165, 169, 5, 2, 76, 73, 2, 177, 188, 5, 5, 78, 83, 73, 68, 69, + 6, 120, 10, 87, 65, 76, 76, 80, 76, 65, 78, 69, 32, 149, 207, 3, 14, 70, 76, 79, 79, 82, 80, 76, 65, 78, 69, 32, 84, 87, 73, 4, 108, 8, 67, 85, - 82, 86, 69, 68, 32, 66, 169, 204, 1, 13, 83, 84, 82, 65, 73, 71, 72, 84, - 32, 83, 84, 82, 69, 2, 207, 203, 7, 69, 6, 11, 72, 6, 11, 32, 6, 30, 66, - 34, 77, 187, 4, 83, 2, 133, 133, 7, 3, 69, 84, 87, 2, 149, 2, 3, 85, 76, + 82, 86, 69, 68, 32, 66, 165, 206, 1, 13, 83, 84, 82, 65, 73, 71, 72, 84, + 32, 83, 84, 82, 69, 2, 139, 211, 7, 69, 6, 11, 72, 6, 11, 32, 6, 30, 66, + 34, 77, 187, 4, 83, 2, 177, 137, 7, 3, 69, 84, 87, 2, 149, 2, 3, 85, 76, 84, 34, 100, 11, 70, 76, 79, 79, 82, 80, 76, 65, 78, 69, 32, 29, 10, 87, 65, 76, 76, 80, 76, 65, 78, 69, 32, 14, 178, 1, 82, 151, 2, 83, 20, 72, 11, 65, 82, 77, 32, 83, 80, 73, 82, 65, 76, 32, 78, 82, 151, 2, 83, 6, - 30, 84, 134, 2, 68, 43, 83, 2, 11, 82, 2, 11, 73, 2, 151, 178, 7, 80, 12, + 30, 84, 134, 2, 68, 43, 83, 2, 11, 82, 2, 11, 73, 2, 147, 185, 7, 80, 12, 41, 8, 79, 84, 65, 84, 73, 79, 78, 45, 12, 52, 5, 70, 76, 79, 79, 82, 1, 4, 87, 65, 76, 76, 6, 33, 6, 80, 76, 65, 78, 69, 32, 6, 26, 65, 54, 68, - 43, 83, 2, 29, 5, 76, 84, 69, 82, 78, 2, 151, 200, 3, 65, 2, 17, 2, 79, - 85, 2, 151, 176, 7, 66, 2, 235, 175, 7, 73, 2, 11, 72, 2, 151, 198, 3, - 65, 2, 11, 73, 2, 195, 205, 7, 78, 10, 100, 6, 65, 66, 79, 86, 69, 32, - 162, 1, 79, 141, 148, 2, 10, 77, 73, 78, 85, 83, 32, 83, 73, 77, 73, 4, + 43, 83, 2, 29, 5, 76, 84, 69, 82, 78, 2, 227, 201, 3, 65, 2, 17, 2, 79, + 85, 2, 147, 183, 7, 66, 2, 231, 182, 7, 73, 2, 11, 72, 2, 227, 199, 3, + 65, 2, 11, 73, 2, 255, 212, 7, 78, 10, 100, 6, 65, 66, 79, 86, 69, 32, + 162, 1, 79, 137, 150, 2, 10, 77, 73, 78, 85, 83, 32, 83, 73, 77, 73, 4, 60, 7, 71, 82, 69, 65, 84, 69, 82, 1, 4, 76, 69, 83, 83, 2, 37, 7, 45, - 84, 72, 65, 78, 32, 65, 2, 25, 4, 66, 79, 86, 69, 2, 185, 241, 1, 2, 32, - 69, 4, 207, 189, 6, 82, 250, 1, 68, 3, 71, 76, 69, 212, 4, 5, 72, 65, 76, - 65, 32, 211, 171, 5, 69, 20, 50, 32, 209, 209, 8, 6, 45, 83, 72, 73, 70, + 84, 72, 65, 78, 32, 65, 2, 25, 4, 66, 79, 86, 69, 2, 181, 243, 1, 2, 32, + 69, 4, 235, 193, 6, 82, 250, 1, 68, 3, 71, 76, 69, 212, 4, 5, 72, 65, 76, + 65, 32, 147, 175, 5, 69, 20, 50, 32, 141, 217, 8, 6, 45, 83, 72, 73, 70, 84, 16, 138, 1, 67, 0, 9, 71, 82, 65, 80, 72, 73, 67, 32, 67, 116, 2, 72, - 73, 74, 76, 36, 4, 82, 73, 71, 72, 209, 254, 4, 4, 83, 72, 73, 70, 2, 41, + 73, 74, 76, 36, 4, 82, 73, 71, 72, 157, 129, 5, 4, 83, 72, 73, 70, 2, 41, 8, 72, 65, 82, 65, 67, 84, 69, 82, 2, 37, 7, 32, 73, 78, 84, 82, 79, 68, - 2, 11, 85, 2, 247, 146, 8, 67, 2, 25, 4, 71, 72, 45, 82, 2, 185, 1, 7, + 2, 11, 85, 2, 179, 154, 8, 67, 2, 25, 4, 71, 72, 45, 82, 2, 185, 1, 7, 69, 86, 69, 82, 83, 69, 68, 4, 32, 2, 69, 70, 109, 2, 79, 87, 2, 49, 10, 84, 45, 80, 79, 73, 78, 84, 73, 78, 71, 2, 21, 3, 32, 65, 78, 2, 17, 2, - 71, 76, 2, 31, 69, 2, 17, 2, 45, 57, 2, 11, 32, 2, 11, 81, 2, 165, 176, + 71, 76, 2, 31, 69, 2, 17, 2, 45, 57, 2, 11, 32, 2, 11, 81, 2, 249, 177, 2, 2, 85, 79, 228, 1, 168, 2, 8, 65, 82, 67, 72, 65, 73, 67, 32, 224, 1, 15, 67, 79, 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, 32, 114, 76, 188, 8, 5, 83, 73, 71, 78, 32, 144, 1, 11, 86, 79, 87, 69, 76, 32, 83, - 73, 71, 78, 32, 209, 232, 2, 17, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, + 73, 71, 78, 32, 173, 234, 2, 17, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 32, 75, 85, 78, 68, 68, 40, 46, 68, 109, 7, 78, 85, 77, 66, 69, 82, - 32, 18, 25, 4, 73, 71, 73, 84, 18, 11, 32, 18, 154, 216, 6, 70, 30, 83, - 42, 84, 142, 87, 78, 14, 79, 227, 112, 69, 22, 130, 238, 2, 79, 162, 235, + 32, 18, 25, 4, 73, 71, 73, 84, 18, 11, 32, 18, 190, 220, 6, 70, 30, 83, + 42, 84, 166, 90, 78, 14, 79, 227, 112, 69, 22, 222, 239, 2, 79, 234, 237, 3, 69, 30, 70, 42, 78, 38, 83, 39, 84, 6, 18, 82, 63, 89, 4, 56, 6, 65, - 75, 65, 65, 82, 65, 233, 198, 8, 2, 69, 80, 2, 229, 198, 8, 3, 65, 78, - 83, 138, 1, 60, 6, 69, 84, 84, 69, 82, 32, 185, 186, 2, 3, 73, 84, 72, + 75, 65, 65, 82, 65, 165, 206, 8, 2, 69, 80, 2, 161, 206, 8, 3, 65, 78, + 83, 138, 1, 60, 6, 69, 84, 84, 69, 82, 32, 141, 188, 2, 3, 73, 84, 72, 118, 246, 1, 65, 106, 69, 34, 73, 62, 85, 34, 77, 220, 1, 4, 68, 65, 78, 84, 58, 79, 28, 8, 83, 65, 78, 89, 65, 75, 65, 32, 50, 70, 2, 72, 2, 82, 2, 86, 2, 89, 32, 8, 84, 65, 65, 76, 85, 74, 65, 32, 29, 9, 75, 65, 78, 84, 65, 74, 65, 32, 78, 34, 102, 69, 204, 1, 2, 76, 80, 144, 2, 5, 77, - 66, 65, 32, 66, 14, 65, 2, 73, 2, 85, 219, 135, 5, 89, 4, 230, 3, 69, - 219, 135, 5, 89, 12, 46, 76, 2, 82, 154, 3, 73, 219, 135, 5, 89, 4, 11, - 85, 4, 138, 3, 85, 219, 135, 5, 89, 28, 42, 65, 177, 1, 5, 85, 85, 82, - 68, 72, 22, 32, 2, 72, 65, 247, 137, 5, 89, 20, 41, 8, 65, 80, 82, 65, + 66, 65, 32, 66, 14, 65, 2, 73, 2, 85, 143, 139, 5, 89, 4, 230, 3, 69, + 143, 139, 5, 89, 12, 46, 76, 2, 82, 154, 3, 73, 143, 139, 5, 89, 4, 11, + 85, 4, 138, 3, 85, 143, 139, 5, 89, 28, 42, 65, 177, 1, 5, 85, 85, 82, + 68, 72, 22, 32, 2, 72, 65, 171, 141, 5, 89, 20, 41, 8, 65, 80, 82, 65, 65, 78, 65, 32, 20, 70, 84, 138, 1, 68, 22, 66, 2, 67, 2, 71, 2, 74, 2, 75, 3, 80, 4, 154, 1, 84, 15, 65, 6, 25, 4, 65, 74, 65, 32, 6, 102, 76, - 2, 78, 3, 83, 4, 86, 79, 219, 135, 5, 89, 8, 26, 68, 22, 71, 3, 74, 4, - 18, 68, 15, 65, 2, 11, 65, 2, 215, 135, 5, 89, 6, 26, 78, 21, 2, 83, 65, + 2, 78, 3, 83, 4, 86, 79, 143, 139, 5, 89, 8, 26, 68, 22, 71, 3, 74, 4, + 18, 68, 15, 65, 2, 11, 65, 2, 139, 139, 5, 89, 6, 26, 78, 21, 2, 83, 65, 2, 89, 2, 65, 65, 4, 68, 11, 78, 89, 79, 79, 71, 65, 32, 78, 65, 65, 75, - 207, 134, 5, 89, 2, 173, 190, 8, 4, 83, 73, 75, 89, 8, 66, 65, 210, 162, - 4, 67, 249, 154, 4, 6, 86, 73, 83, 65, 82, 71, 4, 200, 116, 5, 76, 45, - 76, 65, 75, 253, 200, 7, 6, 78, 85, 83, 86, 65, 82, 34, 56, 5, 68, 73, + 131, 138, 5, 89, 2, 233, 197, 8, 4, 83, 73, 75, 89, 8, 66, 65, 150, 164, + 4, 67, 241, 160, 4, 6, 86, 73, 83, 65, 82, 71, 4, 200, 116, 5, 76, 45, + 76, 65, 75, 185, 208, 7, 6, 78, 85, 83, 86, 65, 82, 34, 56, 5, 68, 73, 71, 65, 32, 62, 71, 82, 75, 155, 2, 65, 12, 58, 71, 48, 4, 75, 79, 77, 66, 118, 65, 26, 73, 19, 80, 4, 11, 65, 4, 236, 2, 3, 69, 84, 84, 67, 89, - 2, 11, 85, 2, 247, 187, 8, 86, 16, 52, 5, 69, 84, 84, 73, 32, 85, 4, 79, + 2, 11, 85, 2, 179, 195, 8, 86, 16, 52, 5, 69, 84, 84, 73, 32, 85, 4, 79, 77, 66, 85, 6, 26, 65, 26, 73, 19, 80, 2, 213, 1, 2, 69, 68, 2, 203, 1, - 83, 2, 175, 1, 65, 10, 40, 2, 86, 65, 161, 142, 8, 2, 32, 68, 9, 29, 5, + 83, 2, 175, 1, 65, 10, 40, 2, 86, 65, 221, 149, 8, 2, 32, 68, 9, 29, 5, 32, 72, 65, 65, 32, 6, 62, 65, 0, 6, 68, 73, 71, 65, 32, 65, 85, 3, 71, - 65, 89, 2, 17, 2, 69, 76, 2, 11, 65, 2, 17, 2, 45, 80, 2, 11, 73, 2, 171, - 153, 8, 76, 2, 129, 136, 6, 5, 65, 78, 85, 75, 73, 12, 84, 2, 32, 80, - 206, 2, 45, 137, 160, 6, 10, 84, 69, 69, 78, 32, 80, 79, 73, 78, 84, 8, + 65, 89, 2, 17, 2, 69, 76, 2, 11, 65, 2, 17, 2, 45, 80, 2, 11, 73, 2, 231, + 160, 8, 76, 2, 193, 139, 6, 5, 65, 78, 85, 75, 73, 12, 84, 2, 32, 80, + 206, 2, 45, 165, 164, 6, 10, 84, 69, 69, 78, 32, 80, 79, 73, 78, 84, 8, 140, 1, 23, 69, 84, 65, 76, 76, 69, 68, 32, 66, 76, 65, 67, 75, 32, 65, 78, 68, 32, 87, 72, 73, 84, 69, 49, 7, 79, 73, 78, 84, 69, 68, 32, 2, 25, - 4, 32, 70, 76, 79, 2, 219, 239, 6, 82, 6, 78, 80, 150, 158, 6, 66, 153, - 134, 1, 9, 83, 84, 65, 82, 32, 87, 73, 84, 72, 2, 21, 3, 73, 78, 87, 2, - 149, 158, 6, 4, 72, 69, 69, 76, 2, 235, 213, 3, 80, 12, 46, 73, 102, 85, - 173, 157, 7, 3, 65, 84, 69, 4, 56, 8, 32, 65, 78, 68, 32, 83, 75, 73, - 139, 254, 7, 69, 2, 17, 2, 32, 66, 2, 151, 230, 7, 79, 6, 32, 2, 76, 76, - 131, 179, 8, 78, 5, 11, 32, 2, 49, 10, 65, 78, 68, 32, 67, 82, 79, 83, - 83, 66, 2, 11, 79, 2, 199, 159, 7, 78, 42, 46, 65, 198, 4, 69, 210, 1, - 73, 167, 1, 79, 14, 64, 5, 78, 84, 69, 68, 32, 253, 156, 6, 5, 86, 79, - 78, 73, 67, 12, 148, 1, 12, 69, 81, 85, 65, 76, 32, 84, 79, 32, 79, 82, - 32, 229, 1, 19, 78, 79, 82, 84, 72, 32, 65, 82, 82, 79, 87, 32, 87, 73, - 84, 72, 32, 72, 79, 8, 60, 7, 71, 82, 69, 65, 84, 69, 82, 1, 4, 76, 69, - 83, 83, 4, 29, 5, 45, 84, 72, 65, 78, 5, 11, 32, 2, 25, 4, 87, 73, 84, - 72, 2, 25, 4, 32, 68, 79, 84, 2, 17, 2, 32, 73, 2, 11, 78, 2, 11, 83, 2, - 231, 158, 6, 73, 4, 24, 2, 79, 75, 43, 82, 2, 17, 2, 69, 68, 2, 203, 216, - 5, 32, 2, 29, 5, 73, 90, 79, 78, 84, 2, 11, 65, 2, 155, 249, 5, 76, 12, - 80, 2, 69, 80, 168, 158, 8, 9, 85, 84, 72, 32, 79, 82, 32, 83, 80, 203, - 17, 68, 8, 40, 4, 73, 78, 71, 32, 167, 242, 7, 89, 6, 244, 233, 4, 8, 65, - 67, 67, 79, 77, 77, 79, 68, 162, 176, 2, 83, 167, 88, 70, 6, 76, 9, 67, - 69, 32, 79, 70, 32, 80, 73, 90, 21, 6, 71, 72, 84, 76, 89, 32, 2, 235, - 171, 8, 90, 4, 40, 2, 83, 77, 169, 229, 6, 2, 70, 82, 2, 219, 246, 6, 73, - 10, 18, 80, 75, 84, 6, 220, 232, 4, 9, 73, 78, 71, 32, 76, 65, 82, 71, - 69, 223, 196, 3, 69, 4, 26, 32, 219, 172, 8, 72, 2, 11, 77, 2, 141, 145, - 7, 3, 65, 67, 72, 150, 1, 34, 65, 158, 13, 73, 207, 7, 79, 116, 32, 2, - 76, 76, 151, 154, 7, 83, 114, 30, 32, 141, 12, 2, 69, 82, 110, 194, 2, - 65, 48, 3, 66, 76, 85, 0, 5, 79, 82, 65, 78, 71, 20, 2, 67, 79, 158, 1, - 68, 22, 69, 140, 2, 11, 73, 68, 69, 79, 71, 82, 65, 80, 72, 73, 67, 28, - 2, 76, 69, 34, 82, 218, 3, 83, 22, 84, 36, 2, 85, 80, 56, 4, 86, 69, 69, - 32, 196, 252, 1, 3, 71, 82, 69, 34, 72, 146, 4, 80, 206, 83, 78, 134, - 246, 2, 70, 83, 81, 6, 134, 214, 4, 77, 214, 49, 73, 255, 137, 1, 83, 2, - 131, 218, 6, 69, 12, 68, 7, 78, 84, 65, 73, 78, 83, 32, 134, 130, 2, 77, - 131, 214, 5, 76, 6, 36, 4, 65, 83, 32, 77, 175, 1, 87, 2, 11, 69, 2, 11, - 77, 2, 195, 233, 7, 66, 2, 151, 130, 2, 79, 12, 84, 9, 76, 69, 77, 69, - 78, 84, 32, 79, 70, 222, 129, 2, 81, 42, 88, 183, 227, 2, 77, 7, 17, 2, - 32, 87, 4, 25, 4, 73, 84, 72, 32, 4, 26, 86, 239, 243, 4, 79, 2, 197, - 253, 5, 21, 69, 82, 84, 73, 67, 65, 76, 32, 66, 65, 82, 32, 65, 84, 32, - 69, 78, 68, 32, 79, 70, 2, 165, 207, 5, 2, 32, 67, 8, 130, 1, 70, 179, - 132, 2, 83, 40, 96, 3, 73, 71, 72, 64, 13, 79, 77, 65, 78, 32, 78, 85, - 77, 69, 82, 65, 76, 32, 251, 137, 6, 69, 6, 17, 2, 84, 32, 6, 238, 152, - 4, 67, 210, 3, 80, 147, 8, 84, 32, 62, 69, 50, 70, 62, 79, 46, 84, 214, - 174, 6, 83, 183, 87, 78, 4, 26, 76, 255, 247, 7, 73, 2, 231, 175, 6, 69, - 8, 26, 73, 191, 169, 7, 79, 6, 146, 26, 86, 159, 152, 6, 70, 6, 11, 78, - 6, 11, 69, 7, 151, 197, 2, 32, 8, 42, 87, 238, 174, 6, 72, 207, 162, 1, - 69, 4, 26, 69, 255, 160, 8, 79, 2, 167, 164, 7, 76, 2, 215, 209, 4, 69, - 4, 174, 253, 3, 87, 151, 134, 2, 73, 2, 253, 253, 4, 9, 45, 80, 79, 73, - 78, 84, 73, 78, 71, 2, 11, 87, 2, 21, 3, 73, 84, 72, 2, 11, 32, 2, 195, - 176, 4, 85, 4, 29, 5, 32, 84, 72, 65, 78, 5, 11, 32, 2, 11, 79, 2, 159, - 189, 1, 82, 32, 34, 76, 165, 150, 7, 2, 82, 75, 30, 40, 4, 73, 78, 71, - 32, 155, 158, 8, 69, 28, 112, 14, 67, 65, 84, 32, 70, 65, 67, 69, 32, 87, - 73, 84, 72, 32, 41, 10, 70, 65, 67, 69, 32, 87, 73, 84, 72, 32, 4, 160, - 1, 2, 72, 69, 231, 246, 4, 79, 24, 86, 72, 108, 10, 79, 80, 69, 78, 32, - 77, 79, 85, 84, 72, 246, 1, 83, 215, 224, 2, 84, 6, 34, 69, 54, 79, 255, - 248, 7, 65, 2, 237, 156, 5, 8, 65, 82, 84, 45, 83, 72, 65, 80, 2, 159, - 212, 4, 82, 9, 29, 5, 32, 65, 78, 68, 32, 6, 26, 67, 58, 83, 71, 84, 2, - 17, 2, 79, 76, 2, 169, 145, 7, 4, 68, 32, 83, 87, 2, 11, 77, 2, 11, 73, - 2, 11, 76, 2, 161, 155, 5, 3, 73, 78, 71, 2, 37, 7, 73, 71, 72, 84, 76, - 89, 45, 2, 175, 154, 5, 67, 8, 64, 11, 77, 73, 76, 73, 78, 71, 32, 69, - 89, 69, 83, 175, 1, 85, 7, 29, 5, 32, 65, 78, 68, 32, 4, 52, 4, 72, 65, - 78, 68, 57, 5, 84, 72, 82, 69, 69, 2, 161, 243, 4, 9, 32, 67, 79, 86, 69, - 82, 73, 78, 71, 2, 181, 210, 4, 2, 32, 72, 2, 17, 2, 78, 71, 2, 185, 129, - 7, 4, 76, 65, 83, 83, 2, 239, 230, 4, 75, 18, 42, 65, 48, 2, 69, 69, 21, - 2, 79, 87, 6, 26, 75, 243, 138, 7, 73, 4, 195, 136, 1, 69, 2, 139, 142, - 7, 90, 10, 100, 7, 32, 67, 65, 80, 80, 69, 68, 28, 3, 77, 65, 78, 132, - 223, 2, 3, 66, 79, 65, 143, 143, 1, 70, 2, 153, 169, 4, 2, 32, 77, 5, 49, - 10, 32, 87, 73, 84, 72, 79, 85, 84, 32, 83, 2, 183, 248, 6, 78, 155, 3, - 162, 2, 67, 48, 2, 70, 84, 228, 1, 6, 71, 68, 73, 65, 78, 32, 244, 10, 3, - 76, 73, 68, 140, 2, 12, 79, 78, 32, 87, 73, 84, 72, 32, 82, 73, 71, 72, - 20, 11, 82, 65, 32, 83, 79, 77, 80, 69, 78, 71, 32, 234, 2, 85, 216, 8, - 6, 89, 79, 77, 66, 79, 32, 190, 240, 6, 77, 130, 135, 1, 72, 3, 83, 4, - 164, 233, 2, 3, 67, 69, 82, 163, 235, 4, 75, 10, 70, 32, 124, 9, 87, 65, - 82, 69, 45, 70, 85, 78, 67, 255, 133, 6, 66, 6, 58, 72, 44, 6, 73, 67, - 69, 32, 67, 82, 227, 200, 6, 83, 2, 11, 89, 2, 11, 80, 2, 211, 186, 6, - 72, 2, 179, 211, 6, 69, 2, 11, 84, 2, 235, 149, 6, 73, 84, 248, 1, 10, - 67, 79, 77, 66, 73, 78, 73, 78, 71, 32, 168, 2, 13, 73, 78, 68, 69, 80, - 69, 78, 68, 69, 78, 84, 32, 83, 20, 7, 76, 69, 84, 84, 69, 82, 32, 188, - 3, 7, 78, 85, 77, 66, 69, 82, 32, 113, 12, 80, 85, 78, 67, 84, 85, 65, - 84, 73, 79, 78, 32, 22, 140, 1, 3, 72, 79, 79, 20, 4, 76, 79, 78, 71, 50, - 83, 58, 84, 242, 231, 3, 68, 128, 243, 1, 4, 82, 69, 83, 72, 249, 14, 4, - 67, 85, 82, 86, 4, 239, 234, 5, 75, 2, 25, 4, 32, 72, 79, 79, 2, 187, - 219, 5, 75, 2, 21, 3, 84, 82, 79, 2, 11, 75, 2, 131, 219, 5, 69, 4, 233, - 222, 1, 2, 87, 79, 2, 151, 140, 7, 72, 42, 190, 1, 65, 50, 71, 34, 76, - 56, 5, 82, 69, 83, 72, 45, 2, 90, 34, 83, 66, 89, 198, 207, 1, 72, 234, - 5, 75, 174, 81, 66, 2, 70, 170, 225, 4, 78, 134, 2, 84, 2, 87, 218, 103, - 80, 171, 4, 77, 4, 26, 76, 171, 138, 7, 89, 2, 131, 215, 1, 69, 2, 11, - 73, 2, 171, 244, 2, 77, 4, 26, 65, 167, 158, 6, 69, 2, 233, 208, 1, 2, - 77, 69, 2, 11, 65, 2, 175, 137, 7, 89, 6, 26, 65, 131, 137, 7, 72, 4, - 222, 199, 1, 77, 235, 147, 6, 68, 2, 239, 207, 1, 79, 8, 18, 79, 59, 84, - 4, 11, 78, 4, 11, 69, 5, 11, 32, 2, 183, 171, 2, 72, 4, 214, 151, 6, 87, - 155, 160, 1, 69, 10, 66, 67, 0, 6, 72, 65, 76, 70, 32, 67, 53, 4, 84, 87, - 79, 32, 2, 21, 3, 73, 82, 67, 2, 225, 246, 4, 2, 76, 69, 6, 100, 13, 86, - 69, 82, 84, 73, 67, 65, 76, 32, 66, 65, 82, 83, 13, 8, 67, 73, 82, 67, - 76, 69, 83, 32, 5, 11, 32, 2, 229, 178, 6, 4, 87, 73, 84, 72, 8, 30, 32, - 189, 1, 2, 85, 83, 4, 93, 21, 81, 85, 73, 76, 84, 32, 83, 81, 85, 65, 82, - 69, 32, 79, 82, 78, 65, 77, 69, 78, 84, 5, 11, 32, 2, 11, 73, 2, 17, 2, - 78, 32, 2, 11, 66, 2, 237, 224, 6, 4, 76, 65, 67, 75, 5, 197, 209, 4, 7, - 32, 87, 73, 84, 72, 32, 79, 2, 231, 132, 4, 84, 70, 52, 7, 76, 69, 84, - 84, 69, 82, 32, 191, 142, 6, 68, 50, 198, 1, 69, 32, 2, 77, 65, 30, 78, - 194, 146, 1, 66, 2, 67, 2, 68, 2, 71, 2, 72, 2, 74, 2, 75, 2, 76, 2, 80, - 2, 82, 2, 83, 2, 84, 2, 86, 2, 89, 242, 236, 6, 65, 2, 73, 2, 79, 3, 85, - 4, 234, 255, 7, 69, 147, 1, 72, 4, 218, 128, 8, 69, 3, 72, 6, 190, 146, - 1, 71, 2, 89, 243, 236, 6, 65, 58, 104, 3, 84, 72, 32, 149, 172, 6, 17, - 78, 68, 32, 82, 69, 67, 79, 82, 68, 73, 78, 71, 32, 67, 79, 80, 89, 56, - 60, 5, 69, 65, 83, 84, 32, 253, 2, 5, 87, 69, 83, 84, 32, 30, 96, 5, 65, - 82, 82, 79, 87, 194, 4, 80, 130, 1, 84, 190, 207, 4, 66, 38, 68, 18, 83, - 251, 58, 87, 13, 11, 32, 10, 68, 2, 65, 78, 38, 67, 120, 2, 84, 79, 154, - 2, 87, 131, 145, 5, 70, 2, 253, 2, 5, 68, 32, 83, 79, 85, 2, 37, 7, 82, - 79, 83, 83, 73, 78, 71, 2, 17, 2, 32, 78, 2, 17, 2, 79, 82, 2, 229, 143, - 5, 5, 84, 72, 32, 69, 65, 2, 17, 2, 32, 67, 2, 167, 251, 3, 79, 26, 96, - 5, 65, 82, 82, 79, 87, 198, 1, 80, 130, 1, 84, 190, 207, 4, 66, 38, 68, - 18, 83, 251, 58, 87, 9, 11, 32, 6, 52, 5, 65, 78, 68, 32, 78, 74, 87, - 131, 145, 5, 70, 2, 17, 2, 79, 82, 2, 21, 3, 84, 72, 32, 2, 193, 141, 5, - 2, 87, 69, 2, 21, 3, 73, 84, 72, 2, 11, 32, 2, 231, 163, 6, 72, 6, 41, 8, - 79, 73, 78, 84, 73, 78, 71, 32, 6, 42, 86, 166, 171, 4, 76, 219, 159, 2, - 66, 2, 17, 2, 73, 78, 2, 251, 170, 4, 69, 4, 73, 16, 82, 73, 65, 78, 71, - 76, 69, 45, 72, 69, 65, 68, 69, 68, 32, 65, 4, 25, 4, 82, 82, 79, 87, 5, - 11, 32, 2, 131, 148, 5, 84, 166, 1, 220, 3, 23, 67, 76, 85, 83, 84, 69, - 82, 45, 73, 78, 73, 84, 73, 65, 76, 32, 76, 69, 84, 84, 69, 82, 32, 40, - 21, 70, 73, 78, 65, 76, 32, 67, 79, 78, 83, 79, 78, 65, 78, 84, 32, 83, - 73, 71, 78, 32, 112, 27, 72, 69, 65, 68, 32, 77, 65, 82, 75, 32, 87, 73, - 84, 72, 32, 77, 79, 79, 78, 32, 65, 78, 68, 32, 83, 85, 78, 104, 7, 76, - 69, 84, 84, 69, 82, 32, 180, 1, 5, 77, 65, 82, 75, 32, 54, 83, 100, 8, - 84, 69, 82, 77, 73, 78, 65, 76, 40, 6, 86, 79, 87, 69, 76, 32, 131, 143, - 4, 71, 8, 150, 172, 7, 83, 138, 69, 76, 3, 82, 24, 206, 226, 3, 83, 226, - 146, 2, 78, 202, 251, 1, 45, 186, 2, 66, 2, 68, 2, 71, 2, 75, 2, 76, 2, - 77, 3, 82, 7, 29, 5, 32, 65, 78, 68, 32, 4, 50, 70, 1, 8, 84, 82, 73, 80, - 76, 69, 32, 70, 2, 139, 224, 5, 76, 82, 162, 194, 2, 68, 214, 230, 4, 75, - 38, 78, 46, 83, 38, 84, 46, 66, 2, 67, 2, 71, 2, 74, 2, 80, 2, 90, 138, - 69, 45, 2, 72, 2, 76, 2, 77, 2, 82, 2, 86, 2, 89, 187, 2, 65, 8, 146, - 151, 4, 80, 162, 146, 3, 68, 58, 83, 63, 84, 10, 40, 4, 73, 71, 78, 32, - 147, 173, 7, 85, 8, 186, 179, 5, 74, 158, 2, 86, 122, 85, 255, 243, 1, - 65, 4, 161, 233, 3, 5, 32, 77, 65, 82, 75, 22, 44, 5, 83, 73, 71, 78, 32, - 187, 172, 7, 76, 20, 88, 7, 86, 79, 67, 65, 76, 73, 67, 162, 173, 7, 65, - 26, 79, 2, 85, 162, 64, 69, 3, 73, 4, 11, 32, 4, 202, 237, 7, 76, 3, 82, - 71, 122, 65, 206, 1, 69, 168, 5, 13, 72, 69, 82, 73, 67, 65, 76, 32, 65, - 78, 71, 76, 69, 82, 73, 220, 1, 2, 76, 65, 91, 79, 17, 48, 4, 71, 72, 69, - 84, 22, 82, 155, 213, 7, 67, 2, 167, 216, 7, 84, 10, 24, 2, 75, 76, 59, - 83, 6, 26, 73, 223, 225, 5, 69, 2, 245, 227, 6, 2, 78, 71, 4, 17, 2, 69, - 32, 4, 202, 53, 72, 135, 3, 86, 22, 104, 2, 65, 75, 230, 3, 69, 68, 4, - 83, 77, 73, 76, 193, 223, 3, 9, 67, 75, 76, 69, 32, 70, 73, 76, 76, 12, - 70, 45, 64, 2, 69, 82, 153, 2, 8, 73, 78, 71, 32, 72, 69, 65, 68, 2, 205, - 203, 5, 11, 78, 79, 45, 69, 86, 73, 76, 32, 77, 79, 78, 9, 33, 6, 32, 87, - 73, 84, 72, 32, 6, 26, 67, 78, 79, 55, 84, 2, 33, 6, 65, 78, 67, 69, 76, - 76, 2, 249, 183, 7, 5, 65, 84, 73, 79, 78, 2, 133, 197, 4, 8, 78, 69, 32, - 83, 79, 85, 78, 68, 2, 25, 4, 72, 82, 69, 69, 2, 145, 209, 6, 10, 32, 83, - 79, 85, 78, 68, 32, 87, 65, 86, 2, 11, 32, 2, 165, 157, 6, 9, 73, 78, 32, - 83, 73, 76, 72, 79, 85, 4, 34, 68, 197, 251, 2, 2, 67, 72, 2, 11, 66, 2, - 183, 220, 6, 79, 2, 211, 222, 6, 79, 7, 45, 9, 32, 79, 80, 69, 78, 73, - 78, 71, 32, 4, 162, 186, 7, 76, 227, 42, 85, 10, 44, 3, 68, 69, 82, 41, - 4, 82, 65, 76, 32, 5, 17, 2, 32, 87, 2, 179, 166, 6, 69, 6, 80, 8, 67, - 65, 76, 69, 78, 68, 65, 82, 0, 4, 78, 79, 84, 69, 29, 2, 83, 72, 2, 149, - 157, 7, 2, 32, 80, 2, 255, 216, 5, 69, 4, 64, 10, 83, 72, 73, 78, 71, 32, - 83, 87, 69, 65, 199, 168, 6, 84, 2, 139, 205, 6, 84, 10, 90, 79, 60, 7, - 85, 84, 73, 78, 71, 32, 87, 144, 246, 2, 3, 82, 84, 83, 227, 179, 3, 78, - 4, 248, 87, 7, 76, 32, 79, 70, 32, 84, 72, 231, 137, 7, 78, 2, 11, 72, 2, - 219, 186, 6, 65, 222, 5, 26, 65, 199, 154, 7, 73, 220, 5, 28, 2, 82, 69, - 155, 69, 84, 218, 5, 30, 32, 233, 46, 2, 68, 32, 234, 3, 250, 1, 65, 104, - 2, 86, 32, 94, 66, 158, 1, 67, 170, 1, 68, 102, 69, 194, 2, 70, 146, 2, - 71, 222, 1, 72, 214, 2, 73, 94, 75, 182, 4, 76, 102, 77, 206, 5, 78, 94, - 79, 178, 1, 80, 222, 3, 82, 154, 3, 83, 206, 2, 84, 74, 87, 230, 6, 89, - 143, 226, 6, 85, 16, 102, 32, 58, 80, 252, 72, 2, 78, 80, 204, 158, 2, 3, - 82, 85, 72, 186, 51, 65, 254, 193, 4, 77, 3, 85, 2, 21, 3, 79, 86, 69, 2, - 11, 82, 2, 183, 204, 7, 32, 4, 166, 190, 2, 69, 223, 142, 1, 65, 14, 98, - 65, 36, 4, 85, 83, 83, 89, 214, 153, 3, 73, 232, 78, 2, 79, 82, 130, 54, - 69, 151, 189, 3, 81, 4, 32, 2, 65, 82, 211, 219, 7, 82, 2, 211, 153, 3, - 69, 22, 98, 65, 30, 79, 146, 20, 77, 216, 197, 7, 7, 32, 79, 86, 69, 82, - 32, 75, 74, 85, 14, 67, 3, 68, 4, 214, 218, 7, 76, 3, 80, 5, 17, 2, 82, - 80, 2, 215, 199, 2, 79, 20, 82, 65, 150, 19, 77, 186, 211, 2, 69, 250, - 48, 79, 254, 193, 4, 66, 2, 74, 3, 76, 5, 251, 21, 65, 18, 66, 69, 22, - 82, 152, 25, 5, 83, 85, 75, 85, 85, 195, 191, 7, 86, 2, 183, 227, 5, 75, - 12, 52, 7, 65, 32, 78, 65, 77, 69, 32, 163, 216, 7, 71, 10, 132, 1, 4, - 72, 69, 73, 83, 20, 5, 84, 65, 73, 83, 89, 140, 22, 3, 77, 69, 73, 156, - 199, 2, 3, 82, 69, 73, 1, 4, 83, 89, 79, 85, 2, 191, 195, 7, 69, 2, 155, - 178, 7, 79, 12, 26, 79, 215, 214, 7, 77, 10, 60, 9, 85, 82, 32, 67, 79, - 82, 78, 69, 82, 235, 185, 7, 79, 8, 26, 32, 251, 213, 7, 83, 6, 128, 1, - 11, 66, 76, 65, 67, 75, 32, 84, 82, 73, 65, 78, 208, 62, 6, 68, 73, 65, - 71, 79, 78, 161, 210, 3, 5, 83, 65, 76, 84, 73, 2, 219, 147, 4, 71, 24, - 102, 65, 46, 73, 160, 12, 5, 85, 82, 65, 77, 85, 134, 233, 5, 72, 242, - 219, 1, 80, 186, 2, 66, 3, 89, 6, 138, 132, 7, 82, 222, 46, 78, 147, 33, - 76, 6, 42, 82, 214, 140, 5, 78, 151, 196, 2, 71, 2, 233, 221, 5, 2, 85, - 68, 30, 130, 1, 65, 22, 69, 54, 79, 62, 85, 142, 191, 3, 80, 136, 137, 4, - 10, 73, 82, 65, 71, 65, 78, 65, 32, 72, 79, 234, 8, 71, 3, 90, 5, 183, - 249, 1, 73, 4, 156, 11, 3, 75, 85, 84, 133, 238, 1, 2, 82, 85, 6, 26, 79, - 159, 209, 7, 78, 4, 178, 172, 7, 82, 235, 36, 78, 6, 54, 73, 132, 17, 4, - 65, 82, 65, 68, 167, 243, 5, 82, 2, 187, 221, 3, 73, 14, 54, 78, 200, 12, - 4, 77, 65, 71, 69, 179, 195, 7, 85, 7, 206, 215, 2, 73, 211, 228, 4, 84, - 58, 234, 1, 65, 56, 3, 73, 82, 79, 78, 77, 90, 79, 60, 2, 85, 82, 140, 8, - 2, 69, 69, 208, 143, 2, 2, 89, 85, 206, 213, 3, 72, 206, 82, 67, 132, - 123, 3, 32, 79, 72, 162, 14, 80, 186, 2, 66, 2, 71, 2, 75, 2, 76, 2, 84, - 2, 86, 3, 87, 9, 22, 82, 135, 98, 73, 4, 166, 21, 65, 183, 132, 2, 79, 9, - 248, 16, 3, 77, 69, 69, 140, 4, 2, 87, 65, 193, 176, 2, 3, 71, 85, 82, 9, - 11, 32, 6, 22, 67, 195, 14, 83, 4, 22, 65, 175, 6, 85, 2, 169, 244, 4, 2, - 80, 73, 4, 18, 79, 23, 82, 2, 131, 173, 7, 80, 2, 203, 141, 6, 85, 4, - 204, 217, 5, 4, 85, 90, 69, 73, 171, 69, 79, 12, 62, 79, 240, 13, 2, 69, - 70, 242, 188, 7, 77, 2, 78, 3, 88, 4, 146, 147, 6, 90, 207, 183, 1, 71, - 82, 158, 1, 32, 70, 65, 122, 66, 22, 69, 54, 73, 110, 77, 68, 2, 85, 32, - 78, 86, 2, 87, 246, 230, 5, 72, 218, 82, 79, 154, 137, 1, 80, 186, 2, 71, - 2, 76, 3, 83, 10, 34, 79, 242, 2, 67, 139, 8, 83, 6, 198, 10, 86, 219, - 173, 7, 72, 13, 54, 73, 44, 2, 78, 83, 226, 84, 82, 239, 245, 4, 72, 4, - 156, 214, 5, 2, 75, 85, 155, 205, 1, 82, 2, 135, 248, 6, 89, 5, 167, 177, - 2, 32, 6, 28, 2, 71, 65, 251, 10, 69, 5, 191, 247, 6, 84, 8, 42, 75, 20, - 2, 82, 73, 219, 198, 7, 76, 2, 183, 159, 6, 85, 5, 11, 66, 2, 11, 65, 2, - 195, 132, 3, 65, 7, 11, 32, 4, 22, 67, 139, 8, 83, 2, 11, 85, 2, 227, - 177, 2, 66, 16, 230, 197, 7, 65, 2, 70, 2, 71, 2, 76, 2, 77, 2, 83, 2, - 86, 3, 87, 5, 11, 32, 2, 11, 77, 2, 191, 130, 7, 69, 16, 70, 65, 130, 12, - 79, 170, 184, 7, 70, 2, 77, 2, 83, 2, 86, 3, 87, 5, 179, 165, 7, 78, 12, - 78, 78, 20, 7, 82, 73, 71, 73, 78, 65, 76, 214, 187, 2, 79, 223, 135, 5, - 86, 2, 219, 158, 7, 83, 6, 21, 3, 32, 79, 70, 7, 25, 4, 32, 79, 82, 32, - 4, 134, 97, 78, 51, 69, 46, 118, 65, 82, 69, 94, 73, 74, 79, 162, 175, 7, + 4, 32, 70, 76, 79, 2, 159, 244, 6, 82, 6, 78, 80, 178, 162, 6, 66, 185, + 137, 1, 9, 83, 84, 65, 82, 32, 87, 73, 84, 72, 2, 21, 3, 73, 78, 87, 2, + 177, 162, 6, 4, 72, 69, 69, 76, 2, 187, 215, 3, 80, 12, 46, 73, 86, 85, + 249, 164, 7, 3, 65, 84, 69, 4, 56, 8, 32, 65, 78, 68, 32, 83, 75, 73, + 199, 133, 8, 69, 2, 185, 124, 2, 32, 66, 6, 32, 2, 76, 76, 207, 186, 8, + 78, 5, 11, 32, 2, 49, 10, 65, 78, 68, 32, 67, 82, 79, 83, 83, 66, 2, 175, + 137, 7, 79, 42, 46, 65, 198, 4, 69, 210, 1, 73, 167, 1, 79, 14, 64, 5, + 78, 84, 69, 68, 32, 181, 161, 6, 5, 86, 79, 78, 73, 67, 12, 148, 1, 12, + 69, 81, 85, 65, 76, 32, 84, 79, 32, 79, 82, 32, 229, 1, 19, 78, 79, 82, + 84, 72, 32, 65, 82, 82, 79, 87, 32, 87, 73, 84, 72, 32, 72, 79, 8, 60, 7, + 71, 82, 69, 65, 84, 69, 82, 1, 4, 76, 69, 83, 83, 4, 29, 5, 45, 84, 72, + 65, 78, 5, 11, 32, 2, 25, 4, 87, 73, 84, 72, 2, 25, 4, 32, 68, 79, 84, 2, + 17, 2, 32, 73, 2, 11, 78, 2, 11, 83, 2, 159, 163, 6, 73, 4, 24, 2, 79, + 75, 43, 82, 2, 17, 2, 69, 68, 2, 167, 220, 5, 32, 2, 29, 5, 73, 90, 79, + 78, 84, 2, 11, 65, 2, 247, 252, 5, 76, 12, 80, 2, 69, 80, 128, 166, 8, 9, + 85, 84, 72, 32, 79, 82, 32, 83, 80, 203, 17, 68, 8, 40, 4, 73, 78, 71, + 32, 255, 249, 7, 89, 6, 212, 236, 4, 8, 65, 67, 67, 79, 77, 77, 79, 68, + 154, 181, 2, 83, 167, 88, 70, 6, 76, 9, 67, 69, 32, 79, 70, 32, 80, 73, + 90, 21, 6, 71, 72, 84, 76, 89, 32, 2, 195, 179, 8, 90, 4, 40, 2, 83, 77, + 137, 234, 6, 2, 70, 82, 2, 175, 251, 6, 73, 10, 18, 80, 75, 84, 6, 188, + 235, 4, 9, 73, 78, 71, 32, 76, 65, 82, 71, 69, 215, 201, 3, 69, 4, 26, + 32, 179, 180, 8, 72, 2, 11, 77, 2, 229, 152, 7, 3, 65, 67, 72, 150, 1, + 34, 65, 166, 13, 73, 215, 7, 79, 116, 32, 2, 76, 76, 239, 161, 7, 83, + 114, 30, 32, 149, 12, 2, 69, 82, 110, 194, 2, 65, 48, 3, 66, 76, 85, 0, + 5, 79, 82, 65, 78, 71, 20, 2, 67, 79, 158, 1, 68, 22, 69, 148, 2, 11, 73, + 68, 69, 79, 71, 82, 65, 80, 72, 73, 67, 28, 2, 76, 69, 34, 82, 218, 3, + 83, 22, 84, 36, 2, 85, 80, 56, 4, 86, 69, 69, 32, 172, 254, 1, 3, 71, 82, + 69, 34, 72, 146, 4, 80, 202, 83, 78, 246, 247, 2, 70, 83, 81, 6, 238, + 216, 4, 77, 202, 50, 73, 219, 138, 1, 83, 2, 211, 222, 6, 69, 12, 68, 7, + 78, 84, 65, 73, 78, 83, 32, 146, 132, 2, 77, 207, 219, 5, 76, 6, 36, 4, + 65, 83, 32, 77, 183, 1, 87, 2, 11, 69, 2, 11, 77, 2, 155, 241, 7, 66, 2, + 163, 132, 2, 79, 12, 92, 9, 76, 69, 77, 69, 78, 84, 32, 79, 70, 234, 131, + 2, 81, 214, 228, 2, 77, 151, 169, 2, 88, 7, 17, 2, 32, 87, 4, 25, 4, 73, + 84, 72, 32, 4, 26, 86, 183, 247, 4, 79, 2, 161, 129, 6, 21, 69, 82, 84, + 73, 67, 65, 76, 32, 66, 65, 82, 32, 65, 84, 32, 69, 78, 68, 32, 79, 70, + 2, 249, 210, 5, 2, 32, 67, 8, 130, 1, 70, 155, 134, 2, 83, 40, 96, 3, 73, + 71, 72, 64, 13, 79, 77, 65, 78, 32, 78, 85, 77, 69, 82, 65, 76, 32, 171, + 142, 6, 69, 6, 17, 2, 84, 32, 6, 242, 154, 4, 67, 210, 3, 80, 159, 8, 84, + 32, 62, 69, 50, 70, 62, 79, 46, 84, 142, 179, 6, 83, 207, 90, 78, 4, 26, + 76, 207, 255, 7, 73, 2, 159, 180, 6, 69, 8, 26, 73, 143, 177, 7, 79, 6, + 154, 26, 86, 207, 156, 6, 70, 6, 11, 78, 6, 11, 69, 7, 135, 199, 2, 32, + 8, 42, 87, 166, 179, 6, 72, 231, 165, 1, 69, 4, 26, 69, 207, 168, 8, 79, + 2, 247, 171, 7, 76, 2, 183, 212, 4, 69, 4, 146, 255, 3, 87, 227, 136, 2, + 73, 2, 209, 129, 5, 9, 45, 80, 79, 73, 78, 84, 73, 78, 71, 2, 11, 87, 2, + 21, 3, 73, 84, 72, 2, 11, 32, 2, 163, 179, 4, 85, 4, 29, 5, 32, 84, 72, + 65, 78, 5, 11, 32, 2, 11, 79, 2, 175, 191, 1, 82, 32, 22, 76, 171, 7, 82, + 30, 40, 4, 73, 78, 71, 32, 247, 165, 8, 69, 28, 112, 14, 67, 65, 84, 32, + 70, 65, 67, 69, 32, 87, 73, 84, 72, 32, 41, 10, 70, 65, 67, 69, 32, 87, + 73, 84, 72, 32, 4, 160, 1, 2, 72, 69, 199, 250, 4, 79, 24, 86, 72, 108, + 10, 79, 80, 69, 78, 32, 77, 79, 85, 84, 72, 246, 1, 83, 227, 226, 2, 84, + 6, 34, 69, 54, 79, 219, 128, 8, 65, 2, 205, 160, 5, 8, 65, 82, 84, 45, + 83, 72, 65, 80, 2, 131, 215, 4, 82, 9, 29, 5, 32, 65, 78, 68, 32, 6, 26, + 67, 58, 83, 71, 84, 2, 17, 2, 79, 76, 2, 133, 153, 7, 4, 68, 32, 83, 87, + 2, 11, 77, 2, 11, 73, 2, 11, 76, 2, 129, 159, 5, 3, 73, 78, 71, 2, 37, 7, + 73, 71, 72, 84, 76, 89, 45, 2, 143, 158, 5, 67, 8, 64, 11, 77, 73, 76, + 73, 78, 71, 32, 69, 89, 69, 83, 175, 1, 85, 7, 29, 5, 32, 65, 78, 68, 32, + 4, 52, 4, 72, 65, 78, 68, 57, 5, 84, 72, 82, 69, 69, 2, 129, 247, 4, 9, + 32, 67, 79, 86, 69, 82, 73, 78, 71, 2, 153, 213, 4, 2, 32, 72, 2, 17, 2, + 78, 71, 2, 149, 137, 7, 4, 76, 65, 83, 83, 2, 215, 150, 7, 75, 2, 175, + 234, 4, 75, 18, 42, 65, 48, 2, 69, 69, 21, 2, 79, 87, 6, 26, 75, 187, + 146, 7, 73, 4, 203, 138, 1, 69, 2, 211, 149, 7, 90, 10, 100, 7, 32, 67, + 65, 80, 80, 69, 68, 28, 3, 77, 65, 78, 252, 224, 2, 3, 66, 79, 65, 243, + 142, 1, 70, 2, 241, 171, 4, 2, 32, 77, 5, 49, 10, 32, 87, 73, 84, 72, 79, + 85, 84, 32, 83, 2, 199, 255, 6, 78, 155, 3, 162, 2, 67, 48, 2, 70, 84, + 228, 1, 6, 71, 68, 73, 65, 78, 32, 244, 10, 3, 76, 73, 68, 140, 2, 12, + 79, 78, 32, 87, 73, 84, 72, 32, 82, 73, 71, 72, 20, 11, 82, 65, 32, 83, + 79, 77, 80, 69, 78, 71, 32, 234, 2, 85, 216, 8, 6, 89, 79, 77, 66, 79, + 32, 134, 248, 6, 77, 130, 135, 1, 72, 3, 83, 4, 156, 235, 2, 3, 67, 69, + 82, 243, 240, 4, 75, 10, 70, 32, 124, 9, 87, 65, 82, 69, 45, 70, 85, 78, + 67, 167, 138, 6, 66, 6, 58, 72, 44, 6, 73, 67, 69, 32, 67, 82, 179, 205, + 6, 83, 2, 11, 89, 2, 11, 80, 2, 139, 191, 6, 72, 2, 247, 215, 6, 69, 2, + 11, 84, 2, 155, 154, 6, 73, 84, 248, 1, 10, 67, 79, 77, 66, 73, 78, 73, + 78, 71, 32, 168, 2, 13, 73, 78, 68, 69, 80, 69, 78, 68, 69, 78, 84, 32, + 83, 20, 7, 76, 69, 84, 84, 69, 82, 32, 188, 3, 7, 78, 85, 77, 66, 69, 82, + 32, 113, 12, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 32, 22, 140, 1, + 3, 72, 79, 79, 20, 4, 76, 79, 78, 71, 50, 83, 58, 84, 206, 233, 3, 68, + 240, 244, 1, 4, 82, 69, 83, 72, 213, 15, 4, 67, 85, 82, 86, 4, 151, 239, + 5, 75, 2, 25, 4, 32, 72, 79, 79, 2, 135, 223, 5, 75, 2, 21, 3, 84, 82, + 79, 2, 11, 75, 2, 207, 222, 5, 69, 4, 229, 224, 1, 2, 87, 79, 2, 223, + 147, 7, 72, 42, 190, 1, 65, 50, 71, 34, 76, 56, 5, 82, 69, 83, 72, 45, 2, + 90, 34, 83, 66, 89, 206, 209, 1, 72, 234, 5, 75, 142, 81, 66, 2, 70, 138, + 231, 4, 78, 134, 2, 84, 2, 87, 218, 103, 80, 171, 4, 77, 4, 26, 76, 243, + 145, 7, 89, 2, 139, 217, 1, 69, 2, 11, 73, 2, 139, 246, 2, 77, 4, 26, 65, + 215, 162, 6, 69, 2, 241, 210, 1, 2, 77, 69, 2, 11, 65, 2, 247, 144, 7, + 89, 6, 26, 65, 203, 144, 7, 72, 4, 230, 201, 1, 77, 171, 153, 6, 68, 2, + 247, 209, 1, 79, 8, 18, 79, 59, 84, 4, 11, 78, 4, 11, 69, 5, 11, 32, 2, + 159, 173, 2, 72, 4, 134, 156, 6, 87, 179, 163, 1, 69, 10, 66, 67, 0, 6, + 72, 65, 76, 70, 32, 67, 53, 4, 84, 87, 79, 32, 2, 21, 3, 73, 82, 67, 2, + 173, 250, 4, 2, 76, 69, 6, 100, 13, 86, 69, 82, 84, 73, 67, 65, 76, 32, + 66, 65, 82, 83, 13, 8, 67, 73, 82, 67, 76, 69, 83, 32, 5, 11, 32, 2, 157, + 183, 6, 4, 87, 73, 84, 72, 8, 30, 32, 189, 1, 2, 85, 83, 4, 93, 21, 81, + 85, 73, 76, 84, 32, 83, 81, 85, 65, 82, 69, 32, 79, 82, 78, 65, 77, 69, + 78, 84, 5, 11, 32, 2, 11, 73, 2, 17, 2, 78, 32, 2, 11, 66, 2, 245, 231, + 6, 4, 76, 65, 67, 75, 5, 133, 213, 4, 7, 32, 87, 73, 84, 72, 32, 79, 2, + 239, 134, 4, 84, 70, 52, 7, 76, 69, 84, 84, 69, 82, 32, 239, 146, 6, 68, + 50, 198, 1, 69, 32, 2, 77, 65, 30, 78, 202, 148, 1, 66, 2, 67, 2, 68, 2, + 71, 2, 72, 2, 74, 2, 75, 2, 76, 2, 80, 2, 82, 2, 83, 2, 84, 2, 86, 2, 89, + 178, 242, 6, 65, 2, 73, 2, 79, 3, 85, 4, 178, 135, 8, 69, 147, 1, 72, 4, + 162, 136, 8, 69, 3, 72, 6, 198, 148, 1, 71, 2, 89, 179, 242, 6, 65, 58, + 104, 3, 84, 72, 32, 205, 176, 6, 17, 78, 68, 32, 82, 69, 67, 79, 82, 68, + 73, 78, 71, 32, 67, 79, 80, 89, 56, 60, 5, 69, 65, 83, 84, 32, 253, 2, 5, + 87, 69, 83, 84, 32, 30, 96, 5, 65, 82, 82, 79, 87, 194, 4, 80, 130, 1, + 84, 254, 210, 4, 66, 38, 68, 18, 83, 135, 59, 87, 13, 11, 32, 10, 68, 2, + 65, 78, 38, 67, 120, 2, 84, 79, 154, 2, 87, 207, 148, 5, 70, 2, 253, 2, + 5, 68, 32, 83, 79, 85, 2, 37, 7, 82, 79, 83, 83, 73, 78, 71, 2, 17, 2, + 32, 78, 2, 17, 2, 79, 82, 2, 177, 147, 5, 5, 84, 72, 32, 69, 65, 2, 17, + 2, 32, 67, 2, 163, 253, 3, 79, 26, 96, 5, 65, 82, 82, 79, 87, 198, 1, 80, + 130, 1, 84, 254, 210, 4, 66, 38, 68, 18, 83, 135, 59, 87, 9, 11, 32, 6, + 52, 5, 65, 78, 68, 32, 78, 74, 87, 207, 148, 5, 70, 2, 17, 2, 79, 82, 2, + 21, 3, 84, 72, 32, 2, 141, 145, 5, 2, 87, 69, 2, 21, 3, 73, 84, 72, 2, + 11, 32, 2, 159, 168, 6, 72, 6, 41, 8, 79, 73, 78, 84, 73, 78, 71, 32, 6, + 42, 86, 254, 173, 4, 76, 139, 164, 2, 66, 2, 17, 2, 73, 78, 2, 211, 173, + 4, 69, 4, 73, 16, 82, 73, 65, 78, 71, 76, 69, 45, 72, 69, 65, 68, 69, 68, + 32, 65, 4, 25, 4, 82, 82, 79, 87, 5, 11, 32, 2, 207, 151, 5, 84, 166, 1, + 220, 3, 23, 67, 76, 85, 83, 84, 69, 82, 45, 73, 78, 73, 84, 73, 65, 76, + 32, 76, 69, 84, 84, 69, 82, 32, 40, 21, 70, 73, 78, 65, 76, 32, 67, 79, + 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, 32, 112, 27, 72, 69, 65, + 68, 32, 77, 65, 82, 75, 32, 87, 73, 84, 72, 32, 77, 79, 79, 78, 32, 65, + 78, 68, 32, 83, 85, 78, 104, 7, 76, 69, 84, 84, 69, 82, 32, 180, 1, 5, + 77, 65, 82, 75, 32, 54, 83, 100, 8, 84, 69, 82, 77, 73, 78, 65, 76, 40, + 6, 86, 79, 87, 69, 76, 32, 219, 145, 4, 71, 8, 222, 179, 7, 83, 138, 69, + 76, 3, 82, 24, 158, 228, 3, 83, 194, 149, 2, 78, 226, 254, 1, 45, 186, 2, + 66, 2, 68, 2, 71, 2, 75, 2, 76, 2, 77, 3, 82, 7, 29, 5, 32, 65, 78, 68, + 32, 4, 50, 70, 1, 8, 84, 82, 73, 80, 76, 69, 32, 70, 2, 179, 228, 5, 76, + 82, 154, 196, 2, 68, 166, 236, 4, 75, 38, 78, 46, 83, 38, 84, 46, 66, 2, + 67, 2, 71, 2, 74, 2, 80, 2, 90, 138, 69, 45, 2, 72, 2, 76, 2, 77, 2, 82, + 2, 86, 2, 89, 187, 2, 65, 8, 234, 153, 4, 80, 146, 151, 3, 68, 58, 83, + 63, 84, 10, 40, 4, 73, 71, 78, 32, 219, 180, 7, 85, 8, 134, 183, 5, 74, + 158, 2, 86, 122, 85, 251, 247, 1, 65, 4, 157, 235, 3, 5, 32, 77, 65, 82, + 75, 22, 44, 5, 83, 73, 71, 78, 32, 131, 180, 7, 76, 20, 88, 7, 86, 79, + 67, 65, 76, 73, 67, 234, 180, 7, 65, 26, 79, 2, 85, 162, 64, 69, 3, 73, + 4, 11, 32, 4, 146, 245, 7, 76, 3, 82, 71, 122, 65, 206, 1, 69, 168, 5, + 13, 72, 69, 82, 73, 67, 65, 76, 32, 65, 78, 71, 76, 69, 82, 73, 220, 1, + 2, 76, 65, 91, 79, 17, 48, 4, 71, 72, 69, 84, 22, 82, 227, 220, 7, 67, 2, + 239, 223, 7, 84, 10, 24, 2, 75, 76, 59, 83, 6, 26, 73, 143, 230, 5, 69, + 2, 189, 235, 6, 2, 78, 71, 4, 17, 2, 69, 32, 4, 218, 55, 72, 135, 3, 86, + 22, 104, 2, 65, 75, 230, 3, 69, 68, 4, 83, 77, 73, 76, 189, 225, 3, 9, + 67, 75, 76, 69, 32, 70, 73, 76, 76, 12, 70, 45, 64, 2, 69, 82, 153, 2, 8, + 73, 78, 71, 32, 72, 69, 65, 68, 2, 245, 207, 5, 11, 78, 79, 45, 69, 86, + 73, 76, 32, 77, 79, 78, 9, 33, 6, 32, 87, 73, 84, 72, 32, 6, 26, 67, 78, + 79, 55, 84, 2, 33, 6, 65, 78, 67, 69, 76, 76, 2, 193, 191, 7, 5, 65, 84, + 73, 79, 78, 2, 209, 200, 4, 8, 78, 69, 32, 83, 79, 85, 78, 68, 2, 25, 4, + 72, 82, 69, 69, 2, 217, 216, 6, 10, 32, 83, 79, 85, 78, 68, 32, 87, 65, + 86, 2, 11, 32, 2, 245, 161, 6, 9, 73, 78, 32, 83, 73, 76, 72, 79, 85, 4, + 34, 68, 161, 253, 2, 2, 67, 72, 2, 11, 66, 2, 255, 227, 6, 79, 2, 155, + 230, 6, 79, 7, 45, 9, 32, 79, 80, 69, 78, 73, 78, 71, 32, 4, 234, 193, 7, + 76, 227, 42, 85, 10, 44, 3, 68, 69, 82, 41, 4, 82, 65, 76, 32, 5, 17, 2, + 32, 87, 2, 247, 170, 6, 69, 6, 80, 8, 67, 65, 76, 69, 78, 68, 65, 82, 0, + 4, 78, 79, 84, 69, 29, 2, 83, 72, 2, 221, 164, 7, 2, 32, 80, 2, 167, 221, + 5, 69, 4, 64, 10, 83, 72, 73, 78, 71, 32, 83, 87, 69, 65, 139, 173, 6, + 84, 2, 211, 212, 6, 84, 10, 90, 79, 60, 7, 85, 84, 73, 78, 71, 32, 87, + 236, 247, 2, 3, 82, 84, 83, 203, 182, 3, 78, 4, 128, 90, 7, 76, 32, 79, + 70, 32, 84, 72, 167, 143, 7, 78, 2, 11, 72, 2, 227, 193, 6, 65, 228, 5, + 26, 65, 143, 162, 7, 73, 226, 5, 28, 2, 82, 69, 163, 71, 84, 224, 5, 30, + 32, 249, 48, 2, 68, 32, 240, 3, 250, 1, 65, 104, 2, 86, 32, 106, 66, 158, + 1, 67, 170, 1, 68, 102, 69, 194, 2, 70, 146, 2, 71, 222, 1, 72, 214, 2, + 73, 94, 75, 182, 4, 76, 106, 77, 206, 5, 78, 94, 79, 178, 1, 80, 222, 3, + 82, 154, 5, 83, 206, 2, 84, 74, 87, 230, 6, 89, 199, 231, 6, 85, 16, 102, + 32, 58, 80, 132, 75, 2, 78, 80, 156, 158, 2, 3, 82, 85, 72, 190, 51, 65, + 234, 199, 4, 77, 3, 85, 2, 21, 3, 79, 86, 69, 2, 11, 82, 2, 255, 211, 7, + 32, 4, 26, 65, 239, 191, 2, 69, 2, 163, 236, 3, 65, 14, 98, 65, 36, 4, + 85, 83, 83, 89, 166, 155, 3, 73, 216, 79, 2, 79, 82, 246, 54, 69, 159, + 193, 3, 81, 4, 32, 2, 65, 82, 143, 227, 7, 82, 2, 163, 155, 3, 69, 22, + 98, 65, 30, 79, 150, 20, 77, 144, 205, 7, 7, 32, 79, 86, 69, 82, 32, 75, + 74, 85, 14, 67, 3, 68, 4, 146, 226, 7, 76, 3, 80, 5, 17, 2, 82, 80, 2, + 147, 201, 2, 79, 20, 82, 65, 154, 19, 77, 130, 213, 2, 69, 254, 48, 79, + 234, 199, 4, 66, 2, 74, 3, 76, 5, 255, 21, 65, 18, 66, 69, 22, 82, 156, + 25, 5, 83, 85, 75, 85, 85, 251, 198, 7, 86, 2, 219, 231, 5, 75, 12, 52, + 7, 65, 32, 78, 65, 77, 69, 32, 223, 223, 7, 71, 10, 132, 1, 4, 72, 69, + 73, 83, 20, 5, 84, 65, 73, 83, 89, 144, 22, 3, 77, 69, 73, 228, 200, 2, + 3, 82, 69, 73, 1, 4, 83, 89, 79, 85, 2, 251, 202, 7, 69, 2, 215, 185, 7, + 79, 12, 26, 79, 147, 222, 7, 77, 10, 60, 9, 85, 82, 32, 67, 79, 82, 78, + 69, 82, 167, 193, 7, 79, 8, 26, 32, 183, 221, 7, 83, 6, 128, 1, 11, 66, + 76, 65, 67, 75, 32, 84, 82, 73, 65, 78, 204, 64, 6, 68, 73, 65, 71, 79, + 78, 233, 210, 3, 5, 83, 65, 76, 84, 73, 2, 159, 150, 4, 71, 24, 102, 65, + 46, 73, 164, 12, 5, 85, 82, 65, 77, 85, 174, 237, 5, 72, 130, 223, 1, 80, + 186, 2, 66, 3, 89, 6, 198, 139, 7, 82, 222, 46, 78, 147, 33, 76, 6, 42, + 82, 150, 144, 5, 78, 147, 200, 2, 71, 2, 141, 226, 5, 2, 85, 68, 30, 130, + 1, 65, 22, 69, 54, 79, 62, 85, 210, 192, 3, 80, 128, 143, 4, 10, 73, 82, + 65, 71, 65, 78, 65, 32, 72, 79, 234, 8, 71, 3, 90, 5, 147, 251, 1, 73, 4, + 160, 11, 3, 75, 85, 84, 221, 239, 1, 2, 82, 85, 6, 26, 79, 219, 216, 7, + 78, 4, 238, 179, 7, 82, 235, 36, 78, 6, 54, 73, 136, 17, 4, 65, 82, 65, + 68, 231, 247, 5, 82, 2, 251, 223, 3, 73, 14, 54, 78, 204, 12, 4, 77, 65, + 71, 69, 235, 202, 7, 85, 7, 154, 217, 2, 73, 195, 234, 4, 84, 58, 234, 1, + 65, 56, 3, 73, 82, 79, 78, 77, 90, 79, 60, 2, 85, 82, 144, 8, 2, 69, 69, + 184, 145, 2, 2, 89, 85, 142, 216, 3, 72, 222, 85, 67, 132, 123, 3, 32, + 79, 72, 162, 14, 80, 186, 2, 66, 2, 71, 2, 75, 2, 76, 2, 84, 2, 86, 3, + 87, 9, 22, 82, 131, 100, 73, 4, 170, 23, 65, 159, 132, 2, 79, 9, 136, 17, + 3, 77, 69, 69, 128, 6, 2, 87, 65, 137, 176, 2, 3, 71, 85, 82, 9, 11, 32, + 6, 22, 67, 207, 14, 83, 4, 22, 65, 179, 6, 85, 2, 233, 247, 4, 2, 80, 73, + 4, 18, 79, 23, 82, 2, 191, 180, 7, 80, 2, 131, 146, 6, 85, 4, 240, 221, + 5, 4, 85, 90, 69, 73, 131, 72, 79, 12, 50, 69, 18, 79, 154, 210, 7, 77, + 2, 78, 3, 88, 2, 139, 14, 70, 4, 198, 151, 6, 90, 211, 186, 1, 71, 82, + 158, 1, 32, 70, 65, 122, 66, 22, 69, 54, 73, 110, 77, 68, 2, 85, 32, 78, + 86, 2, 87, 158, 235, 5, 72, 234, 85, 79, 154, 137, 1, 80, 186, 2, 71, 2, + 76, 3, 83, 10, 34, 79, 242, 2, 67, 147, 8, 83, 6, 206, 10, 86, 139, 181, + 7, 72, 13, 54, 73, 44, 2, 78, 83, 218, 86, 82, 151, 248, 4, 72, 4, 188, + 218, 5, 2, 75, 85, 179, 208, 1, 82, 2, 191, 255, 6, 89, 5, 247, 178, 2, + 32, 6, 28, 2, 71, 65, 135, 11, 69, 5, 247, 254, 6, 84, 8, 42, 75, 20, 2, + 82, 73, 147, 206, 7, 76, 2, 175, 166, 6, 85, 5, 11, 66, 2, 11, 65, 2, + 143, 134, 3, 65, 7, 11, 32, 4, 22, 67, 147, 8, 83, 2, 11, 85, 2, 151, + 153, 6, 66, 16, 158, 205, 7, 65, 2, 70, 2, 71, 2, 76, 2, 77, 2, 83, 2, + 86, 3, 87, 5, 11, 32, 2, 11, 77, 2, 247, 137, 7, 69, 16, 70, 65, 130, 14, + 79, 226, 189, 7, 70, 2, 77, 2, 83, 2, 86, 3, 87, 5, 235, 172, 7, 78, 12, + 78, 78, 20, 7, 82, 73, 71, 73, 78, 65, 76, 158, 189, 2, 79, 207, 141, 5, + 86, 2, 147, 166, 7, 83, 6, 21, 3, 32, 79, 70, 7, 25, 4, 32, 79, 82, 32, + 4, 254, 98, 78, 51, 69, 46, 118, 65, 82, 69, 94, 73, 74, 79, 218, 182, 7, 80, 218, 16, 67, 2, 70, 2, 72, 2, 77, 2, 82, 2, 83, 2, 86, 3, 87, 9, 38, - 65, 165, 137, 4, 3, 32, 65, 77, 4, 236, 1, 2, 83, 69, 239, 154, 7, 84, 8, - 34, 69, 22, 78, 243, 161, 7, 83, 2, 159, 173, 7, 90, 4, 234, 232, 1, 73, - 147, 179, 5, 83, 6, 34, 75, 233, 3, 3, 65, 83, 85, 4, 158, 254, 2, 85, - 255, 193, 4, 79, 6, 34, 73, 22, 78, 21, 2, 83, 73, 2, 203, 204, 3, 78, 2, - 203, 160, 7, 68, 2, 133, 134, 7, 4, 84, 73, 79, 78, 22, 60, 2, 65, 68, - 114, 69, 62, 73, 134, 1, 85, 227, 235, 6, 79, 7, 21, 3, 32, 79, 86, 4, - 25, 4, 69, 82, 32, 83, 5, 17, 2, 32, 83, 2, 11, 81, 2, 205, 169, 2, 2, - 85, 65, 4, 36, 3, 78, 84, 79, 203, 152, 7, 77, 2, 171, 231, 5, 71, 6, 40, - 2, 71, 72, 62, 84, 255, 185, 7, 82, 2, 169, 249, 3, 10, 84, 32, 79, 80, - 69, 78, 32, 66, 79, 88, 2, 181, 250, 2, 2, 84, 79, 4, 228, 1, 2, 85, 66, - 231, 243, 4, 80, 22, 138, 1, 65, 72, 3, 69, 78, 84, 28, 11, 80, 73, 82, - 65, 76, 32, 70, 82, 79, 77, 32, 216, 193, 2, 3, 73, 82, 73, 170, 248, 4, - 82, 3, 86, 4, 48, 2, 73, 75, 213, 178, 2, 4, 78, 84, 73, 73, 2, 179, 248, - 2, 85, 4, 154, 186, 7, 73, 3, 79, 8, 18, 66, 43, 84, 4, 221, 142, 7, 5, - 79, 84, 84, 79, 77, 4, 11, 79, 4, 171, 142, 7, 80, 6, 42, 65, 210, 218, - 5, 72, 203, 142, 1, 79, 2, 221, 131, 7, 2, 82, 71, 34, 50, 65, 20, 4, 73, - 84, 72, 32, 151, 184, 7, 66, 2, 159, 197, 3, 84, 30, 214, 1, 66, 40, 3, - 68, 73, 65, 0, 5, 79, 82, 84, 72, 79, 94, 72, 54, 76, 126, 84, 28, 6, 85, - 80, 80, 69, 82, 32, 186, 1, 86, 242, 146, 4, 82, 253, 131, 2, 13, 67, 79, - 78, 84, 79, 85, 82, 69, 68, 32, 79, 85, 84, 2, 153, 151, 4, 5, 79, 84, - 84, 79, 77, 2, 11, 71, 2, 153, 186, 4, 15, 79, 78, 65, 76, 32, 67, 82, - 79, 83, 83, 72, 65, 84, 67, 72, 2, 11, 79, 2, 149, 3, 6, 82, 73, 90, 79, - 78, 84, 6, 44, 5, 79, 87, 69, 82, 32, 135, 149, 4, 69, 4, 44, 3, 76, 69, - 70, 1, 4, 82, 73, 71, 72, 2, 189, 1, 3, 84, 32, 68, 2, 229, 148, 4, 2, - 79, 80, 8, 60, 5, 76, 69, 70, 84, 32, 37, 6, 82, 73, 71, 72, 84, 32, 4, - 70, 68, 249, 163, 4, 2, 84, 79, 4, 34, 68, 185, 182, 4, 2, 84, 79, 2, - 193, 147, 4, 7, 73, 65, 71, 79, 78, 65, 76, 2, 29, 5, 69, 82, 84, 73, 67, - 2, 165, 182, 4, 2, 65, 76, 6, 32, 2, 65, 65, 187, 229, 5, 85, 4, 234, - 140, 7, 82, 247, 5, 68, 240, 1, 226, 1, 67, 174, 9, 68, 34, 70, 88, 3, - 82, 73, 83, 142, 1, 72, 66, 75, 106, 76, 166, 1, 77, 38, 78, 34, 79, 94, - 80, 34, 83, 190, 2, 84, 160, 1, 5, 69, 73, 71, 72, 84, 22, 85, 90, 86, - 154, 132, 5, 65, 162, 109, 87, 243, 99, 73, 90, 128, 1, 21, 74, 75, 32, - 85, 78, 73, 70, 73, 69, 68, 32, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, - 190, 153, 6, 79, 143, 149, 1, 76, 86, 68, 2, 52, 69, 82, 53, 206, 2, 54, - 150, 2, 55, 166, 1, 56, 95, 57, 10, 50, 48, 234, 4, 65, 214, 254, 5, 56, - 243, 99, 50, 4, 202, 173, 7, 48, 3, 57, 30, 150, 1, 50, 42, 51, 38, 52, - 48, 2, 53, 66, 0, 2, 68, 69, 22, 57, 164, 4, 2, 56, 70, 158, 172, 3, 66, - 184, 208, 2, 2, 70, 56, 241, 99, 2, 49, 56, 6, 214, 4, 55, 162, 225, 6, - 49, 3, 52, 4, 146, 177, 3, 70, 207, 208, 2, 67, 4, 26, 48, 155, 177, 3, - 51, 2, 175, 171, 7, 56, 2, 155, 171, 7, 54, 4, 238, 176, 3, 50, 227, 247, - 3, 49, 24, 86, 50, 46, 51, 50, 53, 34, 54, 16, 2, 55, 48, 28, 2, 70, 49, - 129, 2, 2, 69, 56, 6, 70, 57, 234, 174, 3, 53, 231, 188, 2, 52, 4, 26, - 53, 195, 175, 3, 48, 2, 195, 169, 7, 53, 4, 202, 2, 66, 207, 172, 3, 57, - 2, 171, 2, 50, 4, 254, 168, 7, 56, 3, 57, 2, 227, 168, 7, 52, 12, 74, 53, - 38, 57, 12, 2, 49, 50, 20, 2, 68, 52, 137, 165, 7, 2, 65, 55, 4, 166, - 173, 3, 51, 187, 249, 2, 49, 2, 11, 56, 2, 211, 167, 7, 49, 2, 191, 167, - 7, 50, 6, 50, 57, 20, 2, 68, 55, 205, 172, 3, 2, 67, 65, 2, 155, 172, 3, - 69, 2, 227, 166, 7, 48, 4, 172, 224, 6, 2, 49, 52, 233, 67, 2, 48, 52, 2, - 11, 79, 2, 207, 226, 3, 84, 10, 84, 3, 65, 76, 76, 104, 4, 79, 85, 82, - 32, 240, 5, 3, 73, 86, 69, 179, 172, 5, 82, 2, 57, 12, 73, 78, 71, 32, - 68, 73, 65, 71, 79, 78, 65, 76, 2, 11, 32, 2, 11, 83, 2, 191, 185, 5, 76, - 4, 166, 222, 3, 68, 155, 198, 3, 75, 8, 148, 224, 3, 2, 73, 45, 170, 139, - 3, 68, 222, 56, 67, 3, 86, 8, 56, 8, 65, 84, 65, 75, 65, 78, 65, 32, 219, - 145, 7, 69, 6, 246, 239, 6, 75, 214, 28, 68, 159, 20, 83, 60, 36, 5, 65, - 84, 73, 78, 32, 79, 79, 54, 164, 5, 12, 83, 77, 65, 76, 76, 32, 76, 69, - 84, 84, 69, 82, 167, 123, 67, 6, 134, 221, 3, 71, 153, 172, 2, 3, 83, 83, - 76, 4, 222, 152, 5, 73, 243, 136, 2, 86, 4, 138, 163, 6, 69, 163, 126, - 71, 4, 140, 3, 15, 78, 69, 32, 72, 85, 78, 68, 82, 69, 68, 32, 84, 87, - 69, 78, 255, 157, 7, 75, 4, 158, 2, 80, 175, 149, 5, 76, 20, 110, 69, - 146, 1, 72, 20, 2, 73, 88, 190, 133, 5, 65, 250, 67, 77, 246, 49, 81, - 250, 100, 79, 222, 61, 68, 3, 83, 4, 56, 7, 67, 79, 78, 68, 32, 83, 67, - 21, 3, 86, 69, 78, 2, 211, 200, 5, 82, 2, 29, 5, 32, 80, 79, 73, 78, 2, - 11, 84, 2, 203, 241, 5, 32, 2, 143, 158, 7, 86, 2, 17, 2, 84, 89, 2, 219, - 157, 7, 32, 8, 44, 4, 72, 82, 69, 69, 22, 87, 247, 4, 73, 2, 131, 215, 6, - 32, 4, 68, 13, 69, 78, 84, 89, 45, 84, 87, 79, 32, 80, 79, 73, 78, 23, - 79, 2, 251, 135, 5, 84, 2, 155, 153, 7, 32, 4, 48, 6, 80, 32, 87, 73, 84, - 72, 207, 213, 6, 72, 2, 17, 2, 32, 69, 2, 171, 119, 88, 4, 166, 213, 6, - 79, 163, 70, 83, 2, 149, 249, 5, 6, 32, 66, 76, 65, 67, 75, 6, 250, 154, - 7, 50, 2, 51, 3, 65, 95, 134, 1, 65, 178, 6, 69, 236, 1, 10, 73, 67, 75, - 32, 70, 73, 71, 85, 82, 69, 182, 1, 79, 90, 82, 190, 4, 85, 238, 138, 7, - 83, 3, 88, 38, 92, 6, 70, 70, 32, 79, 70, 32, 106, 77, 82, 82, 206, 3, - 84, 142, 143, 3, 78, 179, 217, 2, 68, 4, 60, 8, 65, 69, 83, 67, 85, 76, - 65, 80, 21, 3, 72, 69, 82, 2, 203, 143, 5, 73, 2, 151, 130, 6, 77, 2, 21, - 3, 80, 69, 68, 2, 17, 2, 32, 69, 2, 233, 225, 1, 4, 78, 86, 69, 76, 24, - 42, 32, 205, 1, 5, 84, 32, 79, 70, 32, 12, 82, 69, 54, 79, 248, 240, 1, - 8, 65, 78, 68, 32, 67, 82, 69, 83, 131, 133, 2, 87, 2, 17, 2, 81, 85, 2, - 11, 65, 2, 187, 216, 6, 76, 4, 44, 5, 70, 32, 68, 65, 86, 183, 210, 3, - 80, 2, 179, 207, 6, 73, 12, 66, 71, 30, 83, 40, 4, 80, 82, 79, 84, 242, - 77, 72, 239, 106, 84, 2, 89, 4, 85, 65, 82, 68, 4, 26, 69, 131, 255, 1, + 65, 213, 140, 4, 3, 32, 65, 77, 4, 236, 1, 2, 83, 69, 167, 162, 7, 84, 8, + 34, 69, 22, 78, 171, 169, 7, 83, 2, 215, 180, 7, 90, 4, 194, 234, 1, 73, + 243, 184, 5, 83, 6, 34, 75, 245, 3, 3, 65, 83, 85, 4, 234, 255, 2, 85, + 235, 199, 4, 79, 6, 34, 73, 22, 78, 21, 2, 83, 73, 2, 135, 207, 3, 78, 2, + 131, 168, 7, 68, 2, 189, 141, 7, 4, 84, 73, 79, 78, 28, 68, 2, 65, 68, + 114, 69, 62, 73, 136, 1, 3, 79, 79, 84, 247, 1, 85, 7, 21, 3, 32, 79, 86, + 4, 25, 4, 69, 82, 32, 83, 5, 17, 2, 32, 83, 2, 11, 81, 2, 149, 171, 2, 2, + 85, 65, 4, 36, 3, 78, 84, 79, 251, 159, 7, 77, 2, 203, 235, 5, 71, 6, 34, + 71, 74, 84, 171, 193, 7, 82, 2, 11, 72, 2, 221, 251, 3, 10, 84, 32, 79, + 80, 69, 78, 32, 66, 79, 88, 2, 245, 251, 2, 2, 84, 79, 9, 69, 15, 32, 79, + 70, 32, 83, 81, 85, 65, 82, 69, 32, 82, 79, 79, 84, 7, 69, 15, 32, 79, + 70, 32, 83, 81, 85, 65, 82, 69, 32, 82, 79, 79, 84, 5, 45, 9, 32, 79, 70, + 32, 83, 81, 85, 65, 82, 2, 11, 69, 2, 17, 2, 32, 82, 2, 171, 241, 6, 79, + 4, 228, 1, 2, 85, 66, 163, 245, 4, 80, 22, 138, 1, 65, 72, 3, 69, 78, 84, + 28, 11, 80, 73, 82, 65, 76, 32, 70, 82, 79, 77, 32, 160, 193, 2, 3, 73, + 82, 73, 154, 254, 4, 82, 3, 86, 4, 48, 2, 73, 75, 157, 178, 2, 4, 78, 84, + 73, 73, 2, 255, 247, 2, 85, 4, 210, 191, 7, 73, 3, 79, 8, 18, 66, 43, 84, + 4, 149, 148, 7, 5, 79, 84, 84, 79, 77, 4, 11, 79, 4, 227, 147, 7, 80, 6, + 42, 65, 250, 220, 5, 72, 219, 145, 1, 79, 2, 149, 137, 7, 2, 82, 71, 34, + 50, 65, 20, 4, 73, 84, 72, 32, 207, 189, 7, 66, 2, 219, 197, 3, 84, 30, + 214, 1, 66, 40, 3, 68, 73, 65, 0, 5, 79, 82, 84, 72, 79, 94, 72, 54, 76, + 126, 84, 28, 6, 85, 80, 80, 69, 82, 32, 186, 1, 86, 174, 148, 4, 82, 249, + 135, 2, 13, 67, 79, 78, 84, 79, 85, 82, 69, 68, 32, 79, 85, 84, 2, 213, + 152, 4, 5, 79, 84, 84, 79, 77, 2, 11, 71, 2, 213, 187, 4, 15, 79, 78, 65, + 76, 32, 67, 82, 79, 83, 83, 72, 65, 84, 67, 72, 2, 11, 79, 2, 149, 3, 6, + 82, 73, 90, 79, 78, 84, 6, 44, 5, 79, 87, 69, 82, 32, 195, 150, 4, 69, 4, + 44, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, 2, 189, 1, 3, 84, 32, 68, 2, + 161, 150, 4, 2, 79, 80, 8, 60, 5, 76, 69, 70, 84, 32, 37, 6, 82, 73, 71, + 72, 84, 32, 4, 70, 68, 181, 165, 4, 2, 84, 79, 4, 34, 68, 245, 183, 4, 2, + 84, 79, 2, 253, 148, 4, 7, 73, 65, 71, 79, 78, 65, 76, 2, 29, 5, 69, 82, + 84, 73, 67, 2, 225, 183, 4, 2, 65, 76, 6, 32, 2, 65, 65, 251, 231, 5, 85, + 4, 162, 146, 7, 82, 247, 5, 68, 240, 1, 226, 1, 67, 174, 9, 68, 34, 70, + 88, 3, 82, 73, 83, 142, 1, 72, 66, 75, 106, 76, 166, 1, 77, 38, 78, 34, + 79, 94, 80, 34, 83, 190, 2, 84, 160, 1, 5, 69, 73, 71, 72, 84, 22, 85, + 82, 86, 186, 134, 5, 65, 130, 112, 87, 179, 100, 73, 90, 128, 1, 21, 74, + 75, 32, 85, 78, 73, 70, 73, 69, 68, 32, 73, 68, 69, 79, 71, 82, 65, 80, + 72, 45, 246, 158, 6, 79, 143, 149, 1, 76, 86, 68, 2, 52, 69, 82, 53, 206, + 2, 54, 150, 2, 55, 166, 1, 56, 95, 57, 10, 50, 48, 234, 4, 65, 206, 131, + 6, 56, 179, 100, 50, 4, 130, 179, 7, 48, 3, 57, 30, 150, 1, 50, 42, 51, + 38, 52, 48, 2, 53, 66, 0, 2, 68, 69, 22, 57, 164, 4, 2, 56, 70, 146, 172, + 3, 66, 188, 213, 2, 2, 70, 56, 177, 100, 2, 49, 56, 6, 214, 4, 55, 218, + 230, 6, 49, 3, 52, 4, 134, 177, 3, 70, 211, 213, 2, 67, 4, 26, 48, 143, + 177, 3, 51, 2, 231, 176, 7, 56, 2, 211, 176, 7, 54, 4, 226, 176, 3, 50, + 167, 253, 3, 49, 24, 86, 50, 46, 51, 50, 53, 34, 54, 16, 2, 55, 48, 28, + 2, 70, 49, 129, 2, 2, 69, 56, 6, 70, 57, 222, 174, 3, 53, 167, 191, 2, + 52, 4, 26, 53, 183, 175, 3, 48, 2, 251, 174, 7, 53, 4, 202, 2, 66, 195, + 172, 3, 57, 2, 171, 2, 50, 4, 182, 174, 7, 56, 3, 57, 2, 155, 174, 7, 52, + 12, 74, 53, 38, 57, 12, 2, 49, 50, 20, 2, 68, 52, 193, 170, 7, 2, 65, 55, + 4, 154, 173, 3, 51, 255, 254, 2, 49, 2, 11, 56, 2, 139, 173, 7, 49, 2, + 247, 172, 7, 50, 6, 50, 57, 20, 2, 68, 55, 193, 172, 3, 2, 67, 65, 2, + 143, 172, 3, 69, 2, 155, 172, 7, 48, 4, 228, 229, 6, 2, 49, 52, 233, 67, + 2, 48, 52, 2, 11, 79, 2, 143, 227, 3, 84, 10, 84, 3, 65, 76, 76, 104, 4, + 79, 85, 82, 32, 240, 5, 3, 73, 86, 69, 211, 174, 5, 82, 2, 57, 12, 73, + 78, 71, 32, 68, 73, 65, 71, 79, 78, 65, 76, 2, 11, 32, 2, 11, 83, 2, 223, + 187, 5, 76, 4, 230, 222, 3, 68, 147, 203, 3, 75, 8, 212, 224, 3, 2, 73, + 45, 162, 144, 3, 68, 222, 56, 67, 3, 86, 8, 56, 8, 65, 84, 65, 75, 65, + 78, 65, 32, 147, 151, 7, 69, 6, 174, 245, 6, 75, 214, 28, 68, 159, 20, + 83, 60, 36, 5, 65, 84, 73, 78, 32, 79, 79, 54, 164, 5, 12, 83, 77, 65, + 76, 76, 32, 76, 69, 84, 84, 69, 82, 247, 122, 67, 6, 198, 221, 3, 71, + 145, 177, 2, 3, 83, 83, 76, 4, 254, 154, 5, 73, 139, 140, 2, 86, 4, 194, + 168, 6, 69, 163, 126, 71, 4, 140, 3, 15, 78, 69, 32, 72, 85, 78, 68, 82, + 69, 68, 32, 84, 87, 69, 78, 183, 163, 7, 75, 4, 158, 2, 80, 207, 151, 5, + 76, 20, 110, 69, 146, 1, 72, 20, 2, 73, 88, 214, 135, 5, 65, 138, 68, 77, + 198, 52, 81, 186, 101, 79, 222, 61, 68, 3, 83, 4, 56, 7, 67, 79, 78, 68, + 32, 83, 67, 21, 3, 86, 69, 78, 2, 251, 202, 5, 82, 2, 29, 5, 32, 80, 79, + 73, 78, 2, 11, 84, 2, 195, 246, 5, 32, 2, 199, 163, 7, 86, 2, 17, 2, 84, + 89, 2, 147, 163, 7, 32, 8, 44, 4, 72, 82, 69, 69, 22, 87, 239, 4, 73, 2, + 187, 220, 6, 32, 4, 68, 13, 69, 78, 84, 89, 45, 84, 87, 79, 32, 80, 79, + 73, 78, 23, 79, 2, 147, 138, 5, 84, 2, 211, 158, 7, 32, 4, 48, 6, 80, 32, + 87, 73, 84, 72, 135, 219, 6, 72, 2, 229, 132, 6, 2, 32, 69, 4, 230, 218, + 6, 79, 163, 70, 83, 2, 149, 254, 5, 6, 32, 66, 76, 65, 67, 75, 6, 186, + 160, 7, 50, 2, 51, 3, 65, 95, 134, 1, 65, 178, 6, 69, 236, 1, 10, 73, 67, + 75, 32, 70, 73, 71, 85, 82, 69, 182, 1, 79, 90, 82, 190, 4, 85, 174, 144, + 7, 83, 3, 88, 38, 92, 6, 70, 70, 32, 79, 70, 32, 106, 77, 82, 82, 206, 3, + 84, 130, 143, 3, 78, 191, 222, 2, 68, 4, 60, 8, 65, 69, 83, 67, 85, 76, + 65, 80, 21, 3, 72, 69, 82, 2, 243, 145, 5, 73, 2, 215, 135, 6, 77, 2, 21, + 3, 80, 69, 68, 2, 17, 2, 32, 69, 2, 217, 225, 1, 4, 78, 86, 69, 76, 24, + 42, 32, 205, 1, 5, 84, 32, 79, 70, 32, 12, 82, 69, 54, 79, 208, 240, 1, + 8, 65, 78, 68, 32, 67, 82, 69, 83, 239, 134, 2, 87, 2, 17, 2, 81, 85, 2, + 11, 65, 2, 251, 221, 6, 76, 4, 44, 5, 70, 32, 68, 65, 86, 255, 210, 3, + 80, 2, 243, 212, 6, 73, 12, 66, 71, 30, 83, 40, 4, 80, 82, 79, 84, 242, + 77, 72, 207, 106, 84, 2, 89, 4, 85, 65, 82, 68, 4, 26, 69, 219, 254, 1, 84, 2, 11, 76, 2, 21, 3, 69, 67, 84, 2, 29, 5, 69, 68, 32, 65, 82, 2, - 199, 145, 7, 69, 4, 228, 163, 5, 10, 85, 69, 32, 79, 70, 32, 76, 73, 66, - 69, 155, 160, 1, 73, 8, 92, 2, 65, 77, 112, 9, 78, 79, 71, 82, 65, 80, - 72, 73, 67, 213, 219, 1, 4, 84, 72, 79, 83, 4, 54, 32, 185, 134, 6, 7, - 73, 78, 71, 32, 66, 79, 87, 2, 33, 6, 76, 79, 67, 79, 77, 79, 2, 147, - 213, 1, 84, 2, 153, 188, 4, 2, 32, 70, 11, 11, 32, 8, 60, 5, 87, 73, 84, - 72, 32, 193, 169, 2, 4, 76, 69, 65, 78, 4, 32, 4, 65, 82, 77, 83, 51, 68, - 2, 25, 4, 32, 82, 65, 73, 2, 143, 252, 1, 83, 2, 179, 247, 5, 82, 4, 44, - 4, 67, 75, 32, 67, 21, 3, 80, 87, 65, 2, 179, 136, 6, 72, 2, 147, 237, 6, + 135, 151, 7, 69, 4, 140, 166, 5, 10, 85, 69, 32, 79, 70, 32, 76, 73, 66, + 69, 179, 163, 1, 73, 8, 92, 2, 65, 77, 112, 9, 78, 79, 71, 82, 65, 80, + 72, 73, 67, 197, 219, 1, 4, 84, 72, 79, 83, 4, 54, 32, 249, 139, 6, 7, + 73, 78, 71, 32, 66, 79, 87, 2, 33, 6, 76, 79, 67, 79, 77, 79, 2, 243, + 212, 1, 84, 2, 221, 189, 4, 2, 32, 70, 11, 11, 32, 8, 60, 5, 87, 73, 84, + 72, 32, 149, 169, 2, 4, 76, 69, 65, 78, 4, 32, 4, 65, 82, 77, 83, 51, 68, + 2, 25, 4, 32, 82, 65, 73, 2, 203, 225, 5, 83, 2, 243, 252, 5, 82, 4, 44, + 4, 67, 75, 32, 67, 21, 3, 80, 87, 65, 2, 243, 141, 6, 72, 2, 211, 242, 6, 84, 22, 66, 65, 124, 10, 69, 83, 83, 32, 79, 85, 84, 76, 73, 78, 79, 73, - 8, 56, 4, 73, 71, 72, 84, 45, 6, 87, 66, 69, 82, 82, 89, 4, 196, 160, 3, - 2, 32, 82, 131, 213, 2, 78, 5, 195, 248, 5, 32, 2, 17, 2, 69, 68, 2, 17, - 2, 32, 87, 2, 205, 243, 4, 4, 72, 73, 84, 69, 12, 76, 4, 78, 71, 32, 84, + 8, 56, 4, 73, 71, 72, 84, 45, 6, 87, 66, 69, 82, 82, 89, 4, 148, 161, 3, + 2, 32, 82, 243, 217, 2, 78, 5, 131, 254, 5, 32, 2, 17, 2, 69, 68, 2, 17, + 2, 32, 87, 2, 237, 245, 4, 4, 72, 73, 84, 69, 12, 76, 4, 78, 71, 32, 84, 52, 4, 80, 69, 68, 32, 241, 8, 4, 67, 84, 76, 89, 2, 17, 2, 69, 82, 2, - 181, 211, 6, 3, 77, 73, 78, 8, 70, 68, 24, 3, 76, 69, 70, 0, 4, 82, 73, + 245, 216, 6, 3, 77, 73, 78, 8, 70, 68, 24, 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, 13, 2, 85, 80, 2, 33, 3, 79, 87, 78, 2, 11, 84, 2, 11, 45, 2, - 149, 228, 5, 8, 80, 79, 73, 78, 84, 73, 78, 71, 6, 100, 8, 68, 73, 79, - 32, 77, 73, 67, 82, 20, 9, 70, 70, 69, 68, 32, 70, 76, 65, 84, 187, 135, - 7, 80, 2, 147, 221, 5, 79, 2, 11, 66, 2, 163, 177, 4, 82, 162, 3, 150, 1, + 149, 233, 5, 8, 80, 79, 73, 78, 84, 73, 78, 71, 6, 100, 8, 68, 73, 79, + 32, 77, 73, 67, 82, 20, 9, 70, 70, 69, 68, 32, 70, 76, 65, 84, 251, 140, + 7, 80, 2, 147, 226, 5, 79, 2, 11, 66, 2, 231, 178, 4, 82, 162, 3, 150, 1, 66, 212, 2, 5, 67, 67, 69, 69, 68, 192, 3, 8, 77, 77, 65, 84, 73, 79, 78, 32, 70, 78, 204, 22, 3, 80, 69, 82, 188, 11, 2, 82, 70, 47, 83, 63, 11, 83, 60, 76, 6, 67, 82, 73, 80, 84, 32, 136, 1, 3, 69, 84, 32, 93, 3, 84, - 73, 84, 30, 118, 76, 186, 29, 69, 166, 1, 80, 22, 82, 134, 221, 2, 77, - 226, 151, 2, 70, 30, 83, 42, 84, 62, 90, 210, 86, 78, 15, 79, 2, 207, 30, + 73, 84, 30, 118, 76, 186, 29, 69, 166, 1, 80, 22, 82, 250, 220, 2, 77, + 150, 154, 2, 70, 30, 83, 42, 84, 62, 90, 234, 89, 78, 15, 79, 2, 207, 30, 69, 28, 56, 6, 65, 66, 79, 86, 69, 32, 246, 33, 79, 159, 3, 87, 6, 142, - 32, 83, 139, 196, 5, 82, 2, 223, 188, 5, 85, 22, 11, 83, 23, 11, 32, 20, + 32, 83, 139, 201, 5, 82, 2, 167, 191, 5, 85, 22, 11, 83, 23, 11, 32, 20, 128, 1, 6, 65, 66, 79, 86, 69, 32, 156, 1, 7, 66, 85, 84, 32, 78, 79, 84, - 32, 2, 79, 82, 149, 156, 3, 5, 85, 78, 68, 69, 82, 12, 100, 4, 78, 79, + 32, 2, 79, 82, 229, 156, 3, 5, 85, 78, 68, 69, 82, 12, 100, 4, 78, 79, 84, 32, 28, 12, 83, 73, 78, 71, 76, 69, 45, 76, 73, 78, 69, 32, 218, 32, 65, 39, 69, 4, 242, 32, 65, 167, 1, 69, 4, 250, 32, 69, 83, 78, 2, 93, 5, 32, 69, 81, 85, 73, 4, 17, 2, 32, 69, 4, 17, 2, 81, 85, 4, 22, 73, 167, - 33, 65, 2, 173, 33, 6, 86, 65, 76, 69, 78, 84, 6, 250, 146, 3, 66, 152, - 229, 1, 4, 87, 73, 84, 72, 251, 144, 1, 84, 249, 1, 194, 1, 32, 72, 7, + 33, 65, 2, 173, 33, 6, 86, 65, 76, 69, 78, 84, 6, 202, 147, 3, 66, 236, + 230, 1, 4, 87, 73, 84, 72, 151, 148, 1, 84, 249, 1, 194, 1, 32, 72, 7, 68, 65, 78, 69, 83, 69, 32, 204, 12, 4, 82, 73, 83, 69, 72, 5, 85, 87, - 65, 82, 32, 168, 179, 2, 14, 83, 69, 84, 32, 79, 86, 69, 82, 32, 66, 85, - 73, 76, 68, 247, 163, 3, 70, 4, 50, 87, 205, 209, 5, 6, 66, 69, 72, 73, - 78, 68, 2, 171, 194, 6, 73, 146, 1, 198, 2, 65, 20, 17, 67, 79, 78, 83, + 65, 82, 32, 252, 178, 2, 14, 83, 69, 84, 32, 79, 86, 69, 82, 32, 66, 85, + 73, 76, 68, 227, 169, 3, 70, 4, 50, 87, 205, 214, 5, 6, 66, 69, 72, 73, + 78, 68, 2, 235, 199, 6, 73, 146, 1, 198, 2, 65, 20, 17, 67, 79, 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, 32, 80, 65, 172, 1, 7, 76, 69, 84, 84, 69, 82, 32, 188, 3, 18, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 32, 66, 73, 78, 68, 85, 32, 228, 1, 5, 83, 73, 71, 78, 32, 204, 1, - 13, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 80, 65, 207, 128, 5, 68, - 2, 215, 162, 3, 86, 10, 68, 2, 77, 73, 40, 2, 78, 89, 33, 7, 83, 65, 78, - 71, 65, 78, 32, 2, 17, 2, 78, 71, 2, 179, 240, 5, 75, 4, 142, 5, 65, 219, - 160, 1, 73, 4, 162, 249, 6, 77, 3, 87, 76, 246, 1, 65, 58, 70, 78, 76, 2, - 82, 34, 83, 170, 161, 3, 69, 234, 217, 1, 78, 214, 181, 1, 66, 2, 75, + 13, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 80, 65, 247, 130, 5, 68, + 2, 167, 163, 3, 86, 10, 68, 2, 77, 73, 40, 2, 78, 89, 33, 7, 83, 65, 78, + 71, 65, 78, 32, 2, 17, 2, 78, 71, 2, 243, 245, 5, 75, 4, 142, 5, 65, 187, + 160, 1, 73, 4, 226, 254, 6, 77, 3, 87, 76, 246, 1, 65, 58, 70, 78, 76, 2, + 82, 34, 83, 250, 161, 3, 69, 194, 219, 1, 78, 238, 184, 1, 66, 2, 75, 138, 69, 67, 2, 68, 2, 71, 2, 72, 2, 74, 2, 77, 2, 80, 2, 81, 2, 84, 2, - 86, 2, 87, 2, 88, 2, 89, 2, 90, 186, 2, 73, 2, 79, 3, 85, 7, 180, 185, 6, + 86, 2, 87, 2, 88, 2, 89, 2, 90, 186, 2, 73, 2, 79, 3, 85, 7, 244, 190, 6, 6, 82, 67, 72, 65, 73, 67, 147, 64, 69, 6, 44, 5, 73, 78, 65, 76, 32, - 227, 248, 6, 65, 4, 222, 248, 6, 75, 3, 77, 4, 218, 211, 6, 69, 235, 36, - 65, 4, 234, 245, 6, 89, 187, 2, 65, 16, 90, 66, 2, 68, 2, 75, 12, 3, 76, - 69, 85, 38, 67, 34, 80, 253, 243, 6, 3, 83, 85, 82, 2, 11, 65, 2, 189, - 103, 5, 32, 83, 65, 84, 65, 2, 11, 65, 2, 171, 178, 6, 75, 4, 172, 3, 3, - 65, 78, 71, 189, 176, 6, 3, 85, 82, 78, 10, 32, 2, 80, 65, 151, 156, 3, - 86, 8, 28, 3, 77, 65, 65, 23, 78, 2, 203, 244, 6, 69, 6, 18, 71, 71, 89, - 4, 38, 76, 225, 174, 6, 3, 87, 73, 83, 2, 205, 209, 5, 2, 65, 89, 2, 201, - 241, 6, 2, 69, 67, 12, 18, 77, 23, 78, 2, 231, 144, 3, 69, 10, 96, 3, 69, - 85, 76, 34, 79, 22, 89, 232, 233, 1, 3, 71, 72, 85, 205, 194, 2, 4, 65, - 69, 76, 65, 2, 11, 69, 2, 195, 162, 6, 85, 2, 151, 172, 4, 76, 2, 255, - 156, 1, 85, 5, 209, 171, 3, 13, 32, 79, 86, 69, 82, 32, 77, 79, 85, 78, + 163, 254, 6, 65, 4, 158, 254, 6, 75, 3, 77, 4, 154, 217, 6, 69, 235, 36, + 65, 4, 170, 251, 6, 89, 187, 2, 65, 16, 90, 66, 2, 68, 2, 75, 12, 3, 76, + 69, 85, 38, 67, 34, 80, 189, 249, 6, 3, 83, 85, 82, 2, 11, 65, 2, 149, + 103, 5, 32, 83, 65, 84, 65, 2, 11, 65, 2, 235, 183, 6, 75, 4, 172, 3, 3, + 65, 78, 71, 253, 181, 6, 3, 85, 82, 78, 10, 32, 2, 80, 65, 231, 156, 3, + 86, 8, 28, 3, 77, 65, 65, 23, 78, 2, 139, 250, 6, 69, 6, 18, 71, 71, 89, + 4, 38, 76, 161, 180, 6, 3, 87, 73, 83, 2, 205, 214, 5, 2, 65, 89, 2, 137, + 247, 6, 2, 69, 67, 12, 18, 77, 23, 78, 2, 183, 145, 3, 69, 10, 96, 3, 69, + 85, 76, 34, 79, 22, 89, 184, 233, 1, 3, 71, 72, 85, 193, 196, 2, 4, 65, + 69, 76, 65, 2, 11, 69, 2, 131, 168, 6, 85, 2, 219, 173, 4, 76, 2, 223, + 156, 1, 85, 5, 153, 172, 3, 13, 32, 79, 86, 69, 82, 32, 77, 79, 85, 78, 84, 65, 73, 88, 88, 7, 76, 69, 84, 84, 69, 82, 32, 184, 6, 6, 83, 73, 71, - 78, 32, 80, 159, 247, 4, 68, 66, 142, 2, 65, 66, 67, 66, 68, 44, 3, 72, + 78, 32, 80, 199, 249, 4, 68, 66, 142, 2, 65, 66, 67, 66, 68, 44, 3, 72, 65, 77, 22, 74, 34, 75, 42, 78, 38, 79, 2, 85, 34, 80, 38, 82, 20, 4, 83, - 72, 89, 69, 34, 84, 112, 3, 86, 65, 82, 144, 238, 4, 4, 76, 79, 65, 67, - 218, 29, 71, 148, 60, 2, 73, 77, 142, 26, 89, 222, 16, 66, 214, 89, 69, - 203, 28, 77, 6, 42, 80, 210, 227, 5, 65, 155, 137, 1, 86, 2, 167, 254, 1, - 80, 4, 40, 2, 72, 69, 253, 218, 6, 2, 65, 82, 2, 215, 219, 5, 76, 4, 22, - 69, 219, 94, 79, 2, 219, 218, 6, 86, 2, 171, 207, 6, 83, 2, 11, 89, 2, - 239, 236, 6, 65, 6, 194, 186, 6, 76, 146, 48, 73, 99, 72, 4, 134, 202, 5, - 71, 175, 162, 1, 65, 2, 11, 84, 2, 155, 149, 1, 84, 4, 194, 201, 5, 72, - 179, 163, 1, 73, 2, 243, 199, 6, 69, 4, 242, 213, 6, 76, 215, 22, 82, 8, - 42, 69, 22, 72, 209, 201, 6, 2, 65, 83, 2, 179, 147, 1, 78, 4, 26, 65, - 147, 197, 5, 69, 2, 243, 215, 6, 82, 2, 255, 232, 6, 67, 2, 175, 204, 6, - 86, 72, 54, 83, 206, 248, 4, 72, 165, 67, 4, 86, 73, 76, 76, 68, 56, 6, + 72, 89, 69, 34, 84, 112, 3, 86, 65, 82, 184, 240, 4, 4, 76, 79, 65, 67, + 226, 29, 71, 228, 62, 2, 73, 77, 206, 26, 89, 222, 16, 66, 214, 89, 69, + 203, 28, 77, 6, 42, 80, 146, 233, 5, 65, 155, 137, 1, 86, 2, 247, 253, 1, + 80, 4, 40, 2, 72, 69, 189, 224, 6, 2, 65, 82, 2, 151, 225, 5, 76, 4, 22, + 69, 179, 94, 79, 2, 155, 224, 6, 86, 2, 235, 212, 6, 83, 2, 11, 89, 2, + 175, 242, 6, 65, 6, 130, 192, 6, 76, 146, 48, 73, 99, 72, 4, 134, 207, 5, + 71, 239, 162, 1, 65, 2, 11, 84, 2, 251, 148, 1, 84, 4, 194, 206, 5, 72, + 243, 163, 1, 73, 2, 179, 205, 6, 69, 4, 178, 219, 6, 76, 215, 22, 82, 8, + 42, 69, 22, 72, 145, 207, 6, 2, 65, 83, 2, 147, 147, 1, 78, 4, 26, 65, + 147, 202, 5, 69, 2, 179, 221, 6, 82, 2, 191, 238, 6, 67, 2, 239, 209, 6, + 86, 72, 54, 83, 246, 250, 4, 72, 253, 69, 4, 86, 73, 76, 76, 68, 56, 6, 67, 82, 73, 80, 84, 32, 229, 2, 3, 69, 84, 32, 34, 114, 69, 34, 76, 134, - 1, 80, 22, 82, 134, 221, 2, 77, 226, 151, 2, 70, 30, 83, 42, 84, 62, 90, - 210, 86, 78, 15, 79, 4, 210, 68, 81, 147, 250, 5, 73, 6, 88, 18, 65, 84, + 1, 80, 22, 82, 250, 220, 2, 77, 150, 154, 2, 70, 30, 83, 42, 84, 62, 90, + 234, 89, 78, 15, 79, 4, 206, 68, 81, 215, 255, 5, 73, 6, 88, 18, 65, 84, 73, 78, 32, 83, 77, 65, 76, 76, 32, 76, 69, 84, 84, 69, 82, 32, 31, 69, - 4, 170, 232, 6, 73, 3, 78, 2, 55, 70, 2, 235, 181, 3, 76, 2, 21, 3, 73, - 71, 72, 2, 11, 84, 2, 183, 224, 2, 32, 34, 148, 1, 6, 65, 66, 79, 86, 69, - 32, 96, 7, 66, 69, 83, 73, 68, 69, 32, 162, 1, 79, 158, 3, 87, 129, 200, - 4, 9, 80, 82, 69, 67, 69, 68, 73, 78, 71, 6, 26, 83, 227, 192, 2, 76, 4, - 11, 85, 4, 26, 80, 175, 247, 4, 66, 2, 169, 247, 4, 2, 69, 82, 4, 108, + 4, 234, 237, 6, 73, 3, 78, 2, 55, 70, 2, 163, 183, 3, 76, 2, 21, 3, 73, + 71, 72, 2, 11, 84, 2, 171, 224, 2, 32, 34, 148, 1, 6, 65, 66, 79, 86, 69, + 32, 96, 7, 66, 69, 83, 73, 68, 69, 32, 162, 1, 79, 158, 3, 87, 161, 202, + 4, 9, 80, 82, 69, 67, 69, 68, 73, 78, 71, 6, 26, 83, 183, 192, 2, 76, 4, + 11, 85, 4, 26, 80, 215, 249, 4, 66, 2, 209, 249, 4, 2, 69, 82, 4, 108, 23, 65, 78, 68, 32, 74, 79, 73, 78, 69, 68, 32, 66, 89, 32, 68, 65, 83, - 72, 32, 87, 73, 84, 72, 23, 83, 2, 17, 2, 32, 83, 2, 137, 246, 4, 2, 85, + 72, 32, 87, 73, 84, 72, 23, 83, 2, 17, 2, 32, 83, 2, 177, 248, 4, 2, 85, 66, 16, 11, 70, 17, 11, 32, 14, 120, 6, 65, 66, 79, 86, 69, 32, 132, 1, - 4, 87, 73, 84, 72, 249, 224, 5, 11, 79, 82, 32, 69, 81, 85, 65, 76, 32, + 4, 87, 73, 84, 72, 185, 230, 5, 11, 79, 82, 32, 69, 81, 85, 65, 76, 32, 84, 79, 8, 34, 65, 38, 69, 18, 84, 67, 78, 2, 11, 76, 2, 113, 3, 77, 79, - 83, 2, 239, 61, 81, 2, 21, 3, 73, 76, 68, 2, 215, 158, 3, 69, 2, 17, 2, + 83, 2, 235, 61, 81, 2, 21, 3, 73, 76, 68, 2, 159, 159, 3, 69, 2, 17, 2, 32, 78, 2, 11, 79, 2, 11, 84, 2, 11, 32, 2, 11, 69, 2, 17, 2, 81, 85, 2, - 11, 65, 2, 11, 76, 2, 143, 238, 2, 32, 6, 25, 4, 73, 84, 72, 32, 6, 104, + 11, 65, 2, 11, 76, 2, 211, 238, 2, 32, 6, 25, 4, 73, 84, 72, 32, 6, 104, 14, 77, 85, 76, 84, 73, 80, 76, 73, 67, 65, 84, 73, 79, 78, 0, 4, 80, 76, - 85, 83, 199, 143, 6, 68, 2, 225, 174, 4, 5, 32, 83, 73, 71, 78, 4, 184, - 213, 4, 2, 65, 67, 191, 209, 1, 69, 4, 60, 9, 80, 69, 78, 83, 73, 79, 78, - 32, 82, 147, 203, 6, 72, 2, 21, 3, 65, 73, 76, 2, 175, 208, 5, 87, 8, 26, - 65, 98, 73, 35, 85, 4, 44, 5, 83, 72, 32, 65, 77, 243, 221, 6, 78, 2, - 141, 154, 6, 7, 80, 69, 82, 83, 65, 78, 68, 2, 11, 77, 2, 199, 159, 6, - 77, 2, 165, 156, 3, 2, 78, 71, 236, 2, 92, 11, 76, 79, 84, 73, 32, 78, + 85, 83, 135, 149, 6, 68, 2, 165, 176, 4, 5, 32, 83, 73, 71, 78, 4, 220, + 215, 4, 2, 65, 67, 219, 212, 1, 69, 4, 60, 9, 80, 69, 78, 83, 73, 79, 78, + 32, 82, 211, 208, 6, 72, 2, 21, 3, 65, 73, 76, 2, 239, 213, 5, 87, 8, 26, + 65, 98, 73, 35, 85, 4, 44, 5, 83, 72, 32, 65, 77, 179, 227, 6, 78, 2, + 205, 159, 6, 7, 80, 69, 82, 83, 65, 78, 68, 2, 11, 77, 2, 135, 165, 6, + 77, 2, 153, 157, 3, 2, 78, 71, 236, 2, 92, 11, 76, 79, 84, 73, 32, 78, 65, 71, 82, 73, 32, 226, 5, 77, 242, 16, 78, 97, 2, 82, 73, 90, 180, 1, 7, 76, 69, 84, 84, 69, 82, 32, 168, 2, 11, 80, 79, 69, 84, 82, 89, 32, 77, 65, 82, 75, 56, 5, 83, 73, 71, 78, 32, 145, 1, 11, 86, 79, 87, 69, - 76, 32, 83, 73, 71, 78, 32, 64, 174, 1, 68, 46, 82, 34, 84, 242, 90, 66, - 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 138, 223, 5, 72, 2, 76, 2, 77, 2, 78, - 2, 83, 246, 30, 65, 2, 69, 2, 73, 2, 79, 3, 85, 8, 186, 91, 68, 138, 223, - 5, 72, 247, 30, 79, 4, 150, 186, 6, 82, 247, 30, 79, 8, 238, 90, 84, 138, - 223, 5, 72, 247, 30, 79, 8, 11, 45, 8, 178, 216, 6, 49, 2, 50, 2, 51, 3, - 52, 8, 46, 65, 70, 72, 181, 146, 6, 3, 68, 86, 73, 4, 64, 10, 76, 84, 69, - 82, 78, 65, 84, 69, 32, 72, 171, 146, 6, 78, 2, 245, 142, 2, 2, 65, 83, - 10, 130, 184, 6, 79, 246, 30, 65, 2, 69, 2, 73, 3, 85, 88, 60, 8, 66, 79, + 76, 32, 83, 73, 71, 78, 32, 64, 174, 1, 68, 46, 82, 34, 84, 210, 90, 66, + 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 234, 228, 5, 72, 2, 76, 2, 77, 2, 78, + 2, 83, 246, 30, 65, 2, 69, 2, 73, 2, 79, 3, 85, 8, 154, 91, 68, 234, 228, + 5, 72, 247, 30, 79, 4, 214, 191, 6, 82, 247, 30, 79, 8, 206, 90, 84, 234, + 228, 5, 72, 247, 30, 79, 8, 11, 45, 8, 242, 221, 6, 49, 2, 50, 2, 51, 3, + 52, 8, 46, 65, 70, 72, 245, 151, 6, 3, 68, 86, 73, 4, 64, 10, 76, 84, 69, + 82, 78, 65, 84, 69, 32, 72, 235, 151, 6, 78, 2, 201, 142, 2, 2, 65, 83, + 10, 194, 189, 6, 79, 246, 30, 65, 2, 69, 2, 73, 3, 85, 88, 60, 8, 66, 79, 76, 32, 70, 79, 82, 32, 145, 16, 2, 77, 69, 86, 238, 2, 66, 48, 2, 67, 65, 118, 68, 238, 3, 69, 130, 2, 70, 56, 8, 72, 79, 82, 73, 90, 79, 78, 84, 0, 6, 86, 69, 82, 84, 73, 67, 44, 3, 76, 73, 78, 52, 9, 77, 65, 82, 75, 83, 32, 67, 72, 65, 22, 78, 90, 65, 68, 3, 82, 69, 67, 32, 5, 71, 82, 79, 85, 80, 0, 4, 85, 78, 73, 84, 22, 83, 249, 2, 15, 84, 89, 80, 69, 32, - 65, 32, 69, 76, 69, 67, 84, 82, 79, 78, 4, 230, 200, 4, 69, 241, 203, 1, - 3, 65, 67, 75, 4, 44, 3, 82, 82, 73, 129, 189, 1, 2, 78, 67, 2, 33, 6, - 65, 71, 69, 32, 82, 69, 2, 11, 84, 2, 155, 191, 1, 85, 20, 24, 2, 65, 84, + 65, 32, 69, 76, 69, 67, 84, 82, 79, 78, 4, 134, 203, 4, 69, 145, 207, 1, + 3, 65, 67, 75, 4, 44, 3, 82, 82, 73, 217, 188, 1, 2, 78, 67, 2, 33, 6, + 65, 71, 69, 32, 82, 69, 2, 11, 84, 2, 219, 190, 1, 85, 20, 24, 2, 65, 84, 55, 69, 2, 177, 5, 9, 65, 32, 76, 73, 78, 75, 32, 69, 83, 18, 84, 4, 76, 69, 84, 69, 137, 2, 12, 86, 73, 67, 69, 32, 67, 79, 78, 84, 82, 79, 76, 11, 11, 32, 8, 164, 1, 11, 82, 69, 67, 84, 65, 78, 71, 85, 76, 65, 82, 0, - 6, 83, 81, 85, 65, 82, 69, 174, 186, 4, 70, 249, 149, 1, 11, 77, 69, 68, + 6, 83, 81, 85, 65, 82, 69, 206, 188, 4, 70, 153, 153, 1, 11, 77, 69, 68, 73, 85, 77, 32, 83, 72, 65, 68, 2, 61, 13, 32, 67, 72, 69, 67, 75, 69, - 82, 32, 66, 79, 65, 82, 2, 239, 207, 5, 68, 8, 11, 32, 8, 226, 178, 1, - 70, 134, 169, 3, 84, 155, 87, 79, 12, 22, 78, 207, 1, 83, 10, 48, 5, 68, - 32, 79, 70, 32, 137, 1, 2, 81, 85, 8, 18, 77, 31, 84, 2, 237, 161, 5, 2, - 69, 68, 6, 64, 11, 82, 65, 78, 83, 77, 73, 83, 83, 73, 79, 78, 243, 112, - 69, 5, 167, 218, 3, 32, 2, 199, 6, 73, 2, 193, 130, 5, 2, 67, 65, 4, 36, - 2, 73, 76, 73, 3, 79, 82, 77, 2, 191, 2, 69, 2, 165, 166, 1, 6, 65, 76, - 32, 84, 65, 66, 2, 11, 69, 2, 17, 2, 32, 70, 2, 227, 182, 1, 69, 2, 219, - 144, 5, 80, 6, 26, 69, 147, 192, 4, 85, 4, 56, 8, 71, 65, 84, 73, 86, 69, - 32, 65, 183, 174, 5, 87, 2, 21, 3, 67, 75, 78, 2, 21, 3, 79, 87, 76, 2, - 231, 140, 1, 69, 2, 11, 79, 2, 17, 2, 82, 68, 2, 219, 151, 3, 32, 18, + 82, 32, 66, 79, 65, 82, 2, 175, 213, 5, 68, 8, 11, 32, 8, 186, 178, 1, + 70, 214, 171, 3, 84, 179, 90, 79, 12, 22, 78, 207, 1, 83, 10, 48, 5, 68, + 32, 79, 70, 32, 137, 1, 2, 81, 85, 8, 18, 77, 31, 84, 2, 237, 166, 5, 2, + 69, 68, 6, 64, 11, 82, 65, 78, 83, 77, 73, 83, 83, 73, 79, 78, 211, 112, + 69, 5, 235, 219, 3, 32, 2, 199, 6, 73, 2, 137, 133, 5, 2, 67, 65, 4, 36, + 2, 73, 76, 73, 3, 79, 82, 77, 2, 191, 2, 69, 2, 253, 165, 1, 6, 65, 76, + 32, 84, 65, 66, 2, 11, 69, 2, 17, 2, 32, 70, 2, 159, 156, 5, 69, 2, 151, + 147, 5, 80, 6, 26, 69, 179, 194, 4, 85, 4, 56, 8, 71, 65, 84, 73, 86, 69, + 32, 65, 247, 179, 5, 87, 2, 21, 3, 67, 75, 78, 2, 21, 3, 79, 87, 76, 2, + 199, 140, 1, 69, 2, 11, 79, 2, 17, 2, 82, 68, 2, 147, 153, 3, 32, 18, 176, 1, 7, 65, 77, 65, 82, 73, 84, 65, 60, 3, 72, 73, 70, 52, 8, 84, 65, 82, 84, 32, 79, 70, 32, 64, 8, 85, 66, 83, 84, 73, 84, 85, 84, 120, 3, - 89, 78, 67, 163, 136, 6, 80, 2, 25, 4, 78, 32, 83, 79, 2, 11, 85, 2, 171, - 138, 6, 82, 4, 17, 2, 84, 32, 4, 174, 205, 5, 79, 243, 41, 73, 4, 22, 72, - 239, 106, 84, 2, 17, 2, 69, 65, 2, 175, 245, 5, 68, 4, 163, 177, 4, 69, - 2, 173, 136, 6, 2, 73, 67, 2, 11, 84, 2, 155, 180, 6, 82, 7, 38, 67, 193, - 181, 2, 3, 65, 71, 79, 2, 137, 139, 1, 9, 72, 82, 79, 78, 79, 85, 83, 32, - 73, 180, 1, 36, 3, 65, 67, 32, 147, 141, 5, 78, 178, 1, 150, 3, 65, 52, + 89, 78, 67, 227, 141, 6, 80, 2, 25, 4, 78, 32, 83, 79, 2, 11, 85, 2, 235, + 143, 6, 82, 4, 17, 2, 84, 32, 4, 238, 210, 5, 79, 243, 41, 73, 4, 22, 72, + 207, 106, 84, 2, 17, 2, 69, 65, 2, 239, 250, 5, 68, 4, 195, 179, 4, 69, + 2, 237, 141, 6, 2, 73, 67, 2, 11, 84, 2, 219, 185, 6, 82, 7, 38, 67, 181, + 181, 2, 3, 65, 71, 79, 2, 249, 138, 1, 9, 72, 82, 79, 78, 79, 85, 83, 32, + 73, 180, 1, 36, 3, 65, 67, 32, 207, 143, 5, 78, 178, 1, 150, 3, 65, 52, 4, 66, 65, 82, 82, 32, 2, 67, 79, 80, 13, 68, 79, 84, 84, 69, 68, 32, 90, 76, 65, 77, 65, 32, 118, 69, 90, 72, 204, 2, 7, 76, 69, 84, 84, 69, 82, 32, 236, 9, 9, 79, 66, 76, 73, 81, 85, 69, 32, 76, 28, 4, 80, 84, 72, 65, - 0, 4, 90, 81, 65, 80, 110, 82, 88, 2, 83, 85, 174, 2, 84, 216, 131, 5, 3, - 77, 85, 83, 224, 22, 7, 70, 69, 77, 73, 78, 73, 78, 153, 139, 1, 5, 81, - 85, 83, 72, 83, 2, 11, 66, 2, 229, 215, 5, 5, 66, 82, 69, 86, 73, 2, 11, - 69, 2, 215, 191, 6, 75, 6, 38, 78, 165, 17, 4, 76, 79, 78, 32, 2, 17, 2, - 84, 82, 2, 187, 239, 5, 65, 4, 28, 3, 65, 78, 71, 35, 72, 2, 11, 85, 2, - 155, 156, 5, 76, 2, 11, 79, 2, 185, 231, 3, 5, 82, 73, 90, 79, 78, 6, 60, - 10, 78, 68, 32, 79, 70, 32, 80, 65, 82, 65, 151, 14, 83, 2, 201, 11, 2, + 0, 4, 90, 81, 65, 80, 98, 82, 88, 2, 83, 85, 174, 2, 84, 228, 136, 5, 3, + 77, 85, 83, 160, 23, 7, 70, 69, 77, 73, 78, 73, 78, 153, 139, 1, 5, 81, + 85, 83, 72, 83, 2, 11, 66, 2, 165, 221, 5, 5, 66, 82, 69, 86, 73, 2, 11, + 69, 2, 151, 197, 6, 75, 6, 38, 78, 153, 17, 4, 76, 79, 78, 32, 2, 17, 2, + 84, 82, 2, 251, 244, 5, 65, 4, 28, 3, 65, 78, 71, 35, 72, 2, 11, 85, 2, + 155, 161, 5, 76, 2, 11, 79, 2, 253, 232, 3, 5, 82, 73, 90, 79, 78, 6, 60, + 10, 78, 68, 32, 79, 70, 32, 80, 65, 82, 65, 139, 14, 83, 2, 201, 11, 2, 71, 82, 14, 104, 8, 65, 82, 75, 76, 69, 65, 78, 32, 132, 1, 4, 66, 65, 83, 65, 65, 7, 79, 82, 73, 90, 79, 78, 84, 6, 60, 5, 65, 83, 84, 69, 82, - 40, 4, 77, 69, 84, 79, 3, 79, 2, 17, 2, 73, 83, 2, 147, 180, 4, 67, 2, - 213, 177, 2, 2, 66, 69, 6, 164, 11, 8, 45, 69, 83, 65, 83, 65, 32, 68, - 155, 143, 4, 32, 2, 233, 235, 5, 2, 65, 76, 92, 154, 2, 68, 102, 72, 32, + 40, 4, 77, 69, 84, 79, 3, 79, 2, 17, 2, 73, 83, 2, 187, 182, 4, 67, 2, + 201, 177, 2, 2, 66, 69, 6, 164, 11, 8, 45, 69, 83, 65, 83, 65, 32, 68, + 187, 145, 4, 32, 2, 169, 241, 5, 2, 65, 76, 92, 154, 2, 68, 102, 72, 32, 3, 76, 65, 77, 34, 77, 204, 1, 2, 80, 69, 142, 1, 82, 78, 83, 144, 1, 8, 70, 73, 78, 65, 76, 32, 83, 69, 106, 65, 14, 75, 2, 81, 34, 84, 40, 5, - 71, 65, 77, 65, 76, 40, 4, 89, 85, 68, 72, 190, 80, 66, 242, 178, 4, 90, - 186, 46, 78, 134, 2, 87, 175, 126, 69, 4, 76, 14, 79, 84, 76, 69, 83, 83, - 32, 68, 65, 76, 65, 84, 72, 32, 139, 3, 65, 2, 179, 212, 2, 82, 4, 11, - 69, 5, 207, 183, 6, 84, 2, 11, 65, 2, 175, 183, 6, 68, 24, 60, 9, 65, 76, - 65, 89, 65, 76, 65, 77, 32, 151, 167, 6, 73, 22, 78, 76, 22, 78, 226, - 185, 4, 66, 222, 216, 1, 84, 138, 34, 83, 14, 74, 3, 82, 4, 255, 170, 4, - 76, 8, 222, 89, 78, 242, 218, 5, 71, 3, 89, 9, 33, 6, 82, 83, 73, 65, 78, - 32, 6, 50, 66, 16, 3, 68, 72, 65, 17, 3, 71, 72, 65, 2, 175, 84, 72, 2, - 147, 2, 76, 2, 139, 170, 5, 77, 4, 52, 7, 69, 86, 69, 82, 83, 69, 68, - 151, 202, 4, 73, 2, 195, 235, 4, 32, 14, 142, 1, 69, 40, 7, 79, 71, 68, + 71, 65, 77, 65, 76, 40, 4, 89, 85, 68, 72, 158, 80, 66, 146, 184, 4, 90, + 250, 46, 78, 134, 2, 87, 175, 126, 69, 4, 76, 14, 79, 84, 76, 69, 83, 83, + 32, 68, 65, 76, 65, 84, 72, 32, 139, 3, 65, 2, 131, 213, 2, 82, 4, 11, + 69, 5, 143, 189, 6, 84, 2, 11, 65, 2, 239, 188, 6, 68, 24, 60, 9, 65, 76, + 65, 89, 65, 76, 65, 77, 32, 215, 172, 6, 73, 22, 78, 76, 22, 78, 138, + 188, 4, 66, 246, 219, 1, 84, 138, 34, 83, 14, 74, 3, 82, 4, 159, 173, 4, + 76, 8, 190, 89, 78, 210, 224, 5, 71, 3, 89, 9, 33, 6, 82, 83, 73, 65, 78, + 32, 6, 50, 66, 16, 3, 68, 72, 65, 17, 3, 71, 72, 65, 2, 143, 84, 72, 2, + 147, 2, 76, 2, 203, 175, 5, 77, 4, 52, 7, 69, 86, 69, 82, 83, 69, 68, + 191, 204, 4, 73, 2, 139, 238, 4, 32, 14, 142, 1, 69, 40, 7, 79, 71, 68, 73, 65, 78, 32, 64, 12, 85, 80, 69, 82, 83, 67, 82, 73, 80, 84, 32, 65, - 190, 179, 5, 72, 201, 82, 2, 65, 68, 2, 17, 2, 77, 75, 2, 235, 174, 4, - 65, 6, 42, 90, 32, 2, 75, 72, 179, 156, 6, 70, 2, 187, 132, 5, 72, 2, 11, - 76, 2, 11, 65, 2, 231, 177, 6, 80, 6, 36, 3, 69, 84, 72, 159, 180, 5, 65, - 5, 149, 91, 6, 32, 71, 65, 82, 83, 72, 5, 135, 133, 6, 32, 4, 221, 143, - 4, 2, 73, 78, 6, 21, 3, 72, 65, 32, 6, 42, 68, 182, 143, 4, 66, 131, 165, - 1, 65, 2, 17, 2, 79, 84, 2, 243, 156, 1, 84, 8, 58, 66, 174, 214, 2, 87, - 249, 166, 1, 4, 85, 75, 75, 65, 4, 169, 251, 3, 2, 65, 83, 14, 88, 8, 66, - 76, 73, 78, 69, 65, 82, 32, 113, 10, 80, 82, 65, 76, 73, 78, 69, 65, 82, - 32, 8, 44, 5, 67, 79, 76, 79, 78, 227, 217, 3, 70, 7, 11, 32, 4, 29, 5, - 83, 75, 69, 87, 69, 4, 219, 131, 6, 68, 6, 44, 5, 67, 79, 76, 79, 78, - 243, 216, 3, 70, 5, 221, 251, 5, 7, 32, 83, 75, 69, 87, 69, 68, 8, 62, - 72, 25, 11, 87, 79, 32, 86, 69, 82, 84, 73, 67, 65, 76, 4, 21, 3, 82, 69, - 69, 4, 25, 4, 32, 68, 79, 84, 4, 235, 138, 4, 83, 136, 47, 102, 45, 58, - 65, 162, 111, 69, 218, 45, 72, 202, 46, 73, 254, 68, 79, 246, 37, 82, - 214, 17, 85, 147, 22, 87, 4, 32, 2, 83, 72, 203, 131, 5, 82, 2, 203, 164, - 5, 73, 200, 29, 182, 1, 66, 86, 71, 196, 17, 2, 73, 32, 142, 35, 75, 144, - 5, 9, 76, 76, 89, 32, 77, 65, 82, 75, 32, 34, 77, 178, 37, 78, 240, 12, - 3, 80, 69, 32, 94, 85, 202, 157, 5, 67, 159, 11, 88, 5, 241, 128, 1, 16, - 76, 69, 32, 84, 69, 78, 78, 73, 83, 32, 80, 65, 68, 68, 76, 69, 144, 2, - 78, 32, 240, 11, 5, 65, 76, 79, 71, 32, 241, 2, 6, 66, 65, 78, 87, 65, - 32, 190, 1, 162, 1, 65, 102, 67, 186, 1, 68, 58, 69, 98, 71, 118, 72, 46, - 76, 230, 3, 80, 58, 81, 62, 82, 106, 83, 242, 81, 78, 230, 227, 1, 84, - 162, 146, 1, 70, 179, 185, 1, 86, 6, 42, 80, 158, 212, 2, 77, 211, 187, - 1, 83, 2, 17, 2, 79, 83, 2, 237, 249, 5, 4, 84, 82, 79, 80, 8, 18, 73, - 63, 79, 2, 25, 4, 82, 67, 85, 77, 2, 213, 2, 4, 70, 76, 69, 88, 6, 26, - 77, 131, 214, 5, 76, 4, 11, 77, 4, 172, 156, 5, 7, 69, 82, 67, 73, 65, - 76, 32, 179, 137, 1, 65, 22, 26, 79, 139, 177, 4, 73, 2, 11, 76, 2, 207, - 90, 76, 4, 18, 81, 43, 88, 2, 17, 2, 85, 65, 2, 179, 242, 2, 76, 2, 245, - 186, 5, 4, 67, 76, 65, 77, 4, 11, 82, 4, 18, 65, 55, 69, 2, 11, 86, 2, - 11, 69, 2, 193, 126, 3, 32, 65, 67, 2, 145, 4, 4, 65, 84, 69, 82, 2, 153, - 152, 2, 6, 89, 80, 72, 69, 78, 45, 114, 38, 65, 254, 2, 69, 235, 180, 4, - 79, 104, 25, 4, 84, 73, 78, 32, 104, 34, 67, 41, 4, 83, 77, 65, 76, 52, - 11, 65, 52, 25, 4, 80, 73, 84, 65, 52, 41, 8, 76, 32, 76, 69, 84, 84, 69, - 82, 52, 11, 32, 52, 158, 161, 6, 65, 2, 66, 2, 67, 2, 68, 2, 69, 2, 70, - 2, 71, 2, 72, 2, 73, 2, 74, 2, 75, 2, 76, 2, 77, 2, 78, 2, 79, 2, 80, 2, - 81, 2, 82, 2, 83, 2, 84, 2, 85, 2, 86, 2, 87, 2, 88, 2, 89, 3, 90, 8, 22, - 83, 199, 1, 70, 2, 11, 83, 2, 169, 69, 3, 45, 84, 72, 4, 26, 69, 211, - 236, 2, 76, 2, 11, 82, 2, 199, 73, 67, 4, 11, 85, 4, 26, 79, 215, 201, 3, - 69, 2, 239, 180, 5, 84, 8, 36, 3, 73, 71, 72, 199, 132, 4, 69, 6, 17, 2, - 84, 32, 6, 250, 146, 2, 67, 210, 3, 80, 239, 7, 83, 6, 150, 206, 2, 69, - 138, 184, 1, 79, 131, 218, 1, 80, 46, 80, 7, 76, 69, 84, 84, 69, 82, 32, - 208, 1, 5, 83, 73, 71, 78, 32, 147, 2, 86, 38, 162, 1, 65, 250, 164, 2, - 78, 206, 243, 3, 66, 2, 68, 2, 71, 2, 72, 2, 75, 2, 76, 2, 77, 2, 80, 2, - 82, 2, 83, 2, 84, 2, 87, 2, 89, 186, 2, 73, 3, 85, 5, 161, 208, 5, 6, 82, - 67, 72, 65, 73, 67, 4, 26, 80, 207, 192, 2, 86, 2, 25, 4, 65, 77, 85, 68, - 2, 235, 223, 2, 80, 36, 48, 7, 76, 69, 84, 84, 69, 82, 32, 147, 1, 86, - 32, 202, 163, 2, 78, 206, 243, 3, 66, 2, 68, 2, 71, 2, 75, 2, 76, 2, 77, - 2, 80, 2, 83, 2, 84, 2, 87, 2, 89, 186, 2, 65, 2, 73, 3, 85, 4, 41, 8, - 79, 87, 69, 76, 32, 83, 73, 71, 4, 11, 78, 4, 207, 215, 5, 32, 194, 4, - 140, 1, 10, 76, 69, 32, 76, 69, 84, 84, 69, 82, 32, 248, 2, 5, 84, 72, - 65, 77, 32, 184, 18, 5, 86, 73, 69, 84, 32, 225, 6, 3, 89, 79, 32, 70, - 186, 1, 65, 34, 69, 30, 84, 230, 158, 2, 78, 214, 172, 1, 79, 242, 129, - 2, 75, 2, 80, 162, 7, 85, 234, 61, 70, 2, 72, 2, 76, 2, 77, 2, 81, 2, 83, - 2, 86, 2, 88, 2, 89, 187, 2, 73, 7, 206, 254, 5, 85, 215, 22, 73, 7, 130, - 149, 6, 69, 3, 72, 18, 60, 3, 79, 78, 69, 234, 204, 5, 83, 138, 69, 72, - 187, 2, 65, 10, 11, 45, 10, 154, 148, 6, 50, 2, 51, 2, 52, 2, 53, 3, 54, - 254, 1, 196, 1, 2, 67, 79, 232, 3, 4, 72, 79, 82, 65, 0, 4, 84, 72, 65, - 77, 28, 7, 76, 69, 84, 84, 69, 82, 32, 220, 4, 5, 83, 73, 71, 78, 32, - 217, 5, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 20, 164, 1, 13, - 78, 83, 79, 78, 65, 78, 84, 32, 83, 73, 71, 78, 32, 197, 253, 4, 21, 77, - 66, 73, 78, 73, 78, 71, 32, 67, 82, 89, 80, 84, 79, 71, 82, 65, 77, 77, - 73, 67, 18, 148, 1, 6, 70, 73, 78, 65, 76, 32, 22, 76, 48, 16, 72, 73, - 71, 72, 32, 82, 65, 84, 72, 65, 32, 79, 82, 32, 76, 79, 22, 77, 206, 140, - 6, 66, 3, 83, 2, 151, 205, 5, 78, 4, 46, 79, 157, 26, 6, 65, 32, 84, 65, - 78, 71, 2, 167, 220, 1, 87, 6, 48, 6, 69, 68, 73, 65, 76, 32, 211, 142, - 6, 65, 4, 150, 140, 6, 76, 3, 82, 20, 169, 154, 4, 2, 32, 68, 106, 188, - 1, 2, 71, 82, 44, 5, 72, 73, 71, 72, 32, 94, 76, 222, 1, 82, 250, 178, 2, - 85, 186, 202, 1, 73, 178, 15, 78, 162, 222, 1, 79, 162, 8, 69, 158, 20, - 66, 2, 68, 2, 77, 2, 87, 187, 2, 65, 2, 21, 3, 69, 65, 84, 2, 251, 137, - 6, 32, 32, 242, 1, 75, 42, 82, 130, 194, 5, 83, 82, 67, 2, 80, 2, 84, - 138, 69, 70, 2, 72, 3, 89, 36, 60, 3, 79, 87, 32, 242, 202, 5, 65, 206, - 41, 85, 159, 20, 76, 28, 86, 75, 42, 82, 210, 194, 5, 67, 2, 80, 2, 84, - 138, 69, 70, 2, 72, 2, 83, 3, 89, 6, 254, 135, 6, 72, 2, 88, 187, 2, 65, - 2, 229, 140, 4, 2, 65, 84, 8, 26, 65, 135, 243, 5, 85, 7, 158, 135, 6, - 78, 3, 84, 50, 182, 1, 72, 34, 75, 176, 1, 4, 77, 65, 73, 32, 82, 82, - 136, 1, 2, 83, 65, 92, 5, 87, 73, 65, 78, 71, 172, 132, 1, 3, 68, 79, 75, - 224, 121, 3, 84, 79, 78, 161, 173, 3, 2, 67, 65, 4, 138, 183, 5, 65, 179, - 63, 79, 14, 52, 4, 72, 85, 69, 78, 134, 3, 65, 131, 232, 4, 69, 8, 80, 6, - 32, 84, 79, 78, 69, 45, 189, 186, 4, 8, 45, 76, 85, 69, 32, 75, 65, 82, - 6, 214, 134, 6, 51, 2, 52, 3, 53, 8, 56, 4, 75, 65, 78, 71, 246, 140, 1, - 89, 247, 187, 3, 83, 5, 167, 146, 1, 32, 4, 92, 3, 65, 32, 72, 21, 16, - 69, 86, 69, 82, 83, 69, 68, 32, 82, 79, 84, 65, 84, 69, 68, 32, 2, 243, - 199, 4, 65, 2, 139, 209, 3, 82, 8, 48, 3, 84, 75, 65, 142, 184, 4, 87, - 231, 123, 75, 4, 17, 2, 65, 78, 5, 163, 143, 4, 75, 5, 245, 202, 3, 2, - 87, 65, 38, 90, 65, 36, 4, 77, 65, 73, 32, 22, 79, 46, 84, 86, 85, 142, - 245, 3, 73, 199, 140, 2, 69, 9, 134, 131, 6, 65, 2, 69, 3, 73, 2, 179, - 249, 4, 83, 11, 186, 224, 3, 65, 150, 162, 2, 79, 3, 89, 4, 42, 65, 181, - 142, 1, 4, 72, 65, 77, 32, 2, 17, 2, 76, 76, 2, 175, 140, 4, 32, 9, 174, - 193, 5, 85, 163, 64, 69, 144, 1, 184, 1, 7, 76, 69, 84, 84, 69, 82, 32, - 188, 2, 5, 77, 65, 73, 32, 75, 32, 7, 83, 89, 77, 66, 79, 76, 32, 124, 9, - 84, 79, 78, 69, 32, 77, 65, 73, 32, 81, 6, 86, 79, 87, 69, 76, 32, 96, - 44, 4, 72, 73, 71, 72, 1, 3, 76, 79, 87, 48, 11, 32, 48, 154, 1, 75, 30, - 67, 2, 80, 2, 84, 34, 78, 234, 222, 5, 66, 2, 68, 2, 70, 2, 71, 2, 72, 2, - 76, 2, 77, 2, 82, 2, 83, 2, 86, 2, 89, 247, 30, 79, 6, 26, 72, 255, 253, - 5, 79, 4, 134, 223, 5, 72, 247, 30, 79, 6, 230, 222, 5, 71, 2, 89, 247, - 30, 79, 4, 186, 172, 5, 65, 195, 52, 72, 10, 72, 2, 75, 79, 110, 78, 216, - 132, 1, 4, 72, 79, 32, 72, 247, 185, 3, 83, 4, 192, 133, 1, 3, 73, 32, - 75, 135, 247, 4, 78, 8, 58, 78, 230, 138, 1, 84, 234, 169, 2, 83, 251, - 195, 2, 69, 2, 251, 180, 3, 85, 26, 62, 65, 206, 4, 85, 206, 228, 1, 73, - 242, 145, 4, 69, 3, 79, 10, 178, 228, 5, 85, 214, 22, 65, 2, 77, 2, 78, - 3, 89, 110, 72, 7, 76, 69, 84, 84, 69, 82, 32, 238, 3, 83, 157, 1, 3, 88, - 65, 77, 96, 206, 1, 65, 80, 2, 76, 79, 12, 4, 72, 73, 71, 72, 126, 78, - 34, 85, 198, 133, 1, 80, 2, 84, 138, 95, 73, 194, 200, 1, 79, 190, 170, - 2, 66, 2, 67, 2, 68, 2, 71, 2, 77, 2, 81, 2, 86, 2, 89, 247, 30, 69, 16, - 222, 225, 5, 85, 214, 22, 65, 2, 69, 2, 75, 2, 77, 2, 78, 2, 80, 3, 84, - 21, 11, 87, 18, 11, 32, 18, 70, 75, 194, 158, 5, 78, 210, 57, 70, 2, 72, - 2, 80, 2, 84, 3, 88, 6, 142, 216, 5, 72, 2, 86, 247, 30, 79, 4, 230, 215, - 5, 71, 247, 30, 79, 9, 202, 228, 1, 69, 243, 145, 4, 65, 12, 76, 4, 73, - 71, 78, 32, 245, 156, 5, 9, 89, 77, 66, 79, 76, 32, 77, 85, 69, 10, 38, - 65, 206, 222, 5, 85, 255, 5, 79, 6, 202, 244, 5, 78, 86, 85, 3, 89, 2, - 171, 129, 1, 32, 138, 1, 52, 3, 82, 73, 32, 201, 229, 4, 4, 69, 79, 85, - 84, 136, 1, 82, 65, 20, 7, 76, 69, 84, 84, 69, 82, 32, 166, 2, 83, 78, - 86, 203, 252, 3, 68, 2, 155, 211, 1, 66, 88, 210, 1, 65, 158, 148, 2, 68, - 82, 82, 34, 84, 230, 5, 85, 186, 202, 1, 73, 138, 196, 1, 78, 126, 66, 2, - 67, 2, 71, 2, 74, 2, 75, 2, 80, 2, 83, 138, 69, 72, 2, 76, 2, 77, 2, 86, - 2, 89, 186, 2, 69, 3, 79, 11, 208, 190, 3, 7, 82, 67, 72, 65, 73, 67, 32, - 154, 179, 2, 65, 2, 73, 3, 85, 8, 25, 4, 73, 71, 78, 32, 8, 254, 211, 1, - 78, 138, 216, 3, 65, 239, 1, 86, 18, 49, 10, 79, 87, 69, 76, 32, 83, 73, - 71, 78, 32, 18, 250, 152, 2, 65, 38, 85, 186, 202, 1, 73, 198, 140, 2, - 69, 3, 79, 4, 134, 51, 70, 163, 161, 4, 79, 188, 6, 36, 3, 73, 76, 32, - 211, 200, 4, 65, 186, 6, 154, 3, 65, 106, 67, 194, 2, 68, 72, 3, 87, 69, - 84, 48, 9, 70, 82, 65, 67, 84, 73, 79, 78, 32, 232, 7, 9, 73, 78, 32, 80, - 79, 83, 83, 69, 83, 22, 76, 200, 2, 7, 78, 85, 77, 66, 69, 82, 32, 152, - 1, 18, 80, 85, 78, 67, 84, 85, 65, 84, 73, 79, 78, 32, 69, 78, 68, 32, - 79, 70, 54, 82, 42, 83, 166, 14, 84, 228, 1, 7, 86, 79, 87, 69, 76, 32, - 83, 100, 2, 89, 69, 168, 195, 4, 5, 77, 79, 78, 84, 72, 171, 118, 79, 6, - 80, 5, 83, 32, 65, 66, 79, 150, 138, 2, 85, 197, 245, 1, 5, 78, 68, 32, - 79, 68, 2, 143, 203, 3, 86, 52, 80, 9, 79, 78, 83, 79, 78, 65, 78, 84, - 32, 156, 21, 3, 85, 82, 82, 171, 9, 82, 48, 130, 1, 75, 22, 76, 22, 78, - 46, 84, 194, 191, 1, 83, 254, 82, 82, 158, 214, 3, 67, 2, 72, 2, 74, 2, - 77, 2, 80, 2, 86, 3, 89, 5, 207, 171, 5, 83, 7, 235, 236, 4, 76, 11, 150, - 235, 3, 78, 238, 253, 1, 71, 3, 89, 5, 215, 232, 5, 84, 26, 68, 2, 82, - 89, 164, 28, 2, 69, 66, 146, 149, 2, 65, 207, 194, 1, 73, 2, 225, 199, 1, - 7, 32, 67, 85, 76, 84, 73, 86, 42, 168, 1, 4, 79, 78, 69, 32, 220, 4, 6, - 84, 72, 82, 69, 69, 32, 169, 224, 5, 22, 68, 79, 87, 78, 83, 67, 65, 76, - 73, 78, 71, 32, 70, 65, 67, 84, 79, 82, 32, 75, 73, 73, 30, 112, 5, 69, - 73, 71, 72, 84, 34, 70, 40, 3, 72, 65, 76, 22, 79, 88, 4, 83, 73, 88, 84, - 74, 84, 203, 221, 3, 81, 4, 210, 3, 73, 219, 225, 5, 72, 4, 156, 3, 2, - 79, 82, 203, 219, 3, 73, 4, 251, 222, 1, 70, 2, 225, 2, 18, 78, 69, 45, - 72, 85, 78, 68, 82, 69, 68, 45, 65, 78, 68, 45, 83, 73, 88, 6, 140, 222, - 1, 5, 69, 69, 78, 84, 72, 141, 25, 5, 89, 45, 70, 79, 85, 8, 38, 72, 138, - 1, 87, 255, 220, 3, 69, 4, 132, 1, 18, 82, 69, 69, 45, 72, 85, 78, 68, - 82, 69, 68, 45, 65, 78, 68, 45, 84, 87, 173, 163, 4, 8, 73, 82, 84, 89, - 45, 83, 69, 67, 2, 17, 2, 69, 78, 2, 17, 2, 84, 73, 2, 223, 220, 3, 69, - 10, 58, 69, 28, 4, 83, 73, 88, 84, 82, 84, 179, 220, 3, 81, 2, 129, 1, 3, - 73, 71, 72, 4, 50, 69, 165, 221, 3, 6, 89, 45, 70, 79, 85, 82, 2, 161, - 221, 3, 2, 69, 78, 2, 21, 3, 87, 69, 78, 2, 237, 220, 3, 3, 84, 73, 69, - 2, 207, 218, 1, 83, 72, 48, 6, 69, 84, 84, 69, 82, 32, 211, 243, 3, 65, - 70, 194, 1, 78, 170, 201, 1, 84, 190, 54, 65, 82, 76, 38, 82, 134, 6, 85, - 206, 141, 1, 79, 238, 60, 73, 182, 196, 1, 83, 242, 7, 69, 234, 61, 67, - 2, 72, 2, 74, 2, 75, 2, 77, 2, 80, 2, 86, 3, 89, 10, 46, 78, 242, 218, 5, - 71, 2, 89, 187, 2, 65, 4, 238, 218, 5, 78, 187, 2, 65, 8, 38, 79, 222, - 134, 4, 84, 159, 79, 83, 4, 11, 78, 4, 17, 2, 69, 32, 4, 18, 72, 31, 84, - 2, 133, 72, 3, 85, 78, 68, 2, 185, 137, 2, 3, 72, 79, 85, 2, 17, 2, 32, - 84, 2, 11, 69, 2, 163, 191, 5, 88, 2, 17, 2, 85, 80, 2, 159, 187, 3, 69, - 194, 4, 152, 1, 5, 65, 76, 84, 32, 80, 20, 4, 73, 71, 78, 32, 206, 4, 80, - 28, 9, 84, 65, 82, 84, 73, 78, 71, 32, 70, 41, 8, 89, 76, 76, 65, 66, 76, - 69, 32, 2, 235, 221, 3, 65, 40, 90, 65, 48, 3, 67, 69, 86, 34, 75, 80, 2, - 77, 85, 102, 85, 14, 80, 118, 86, 211, 64, 78, 4, 216, 2, 4, 65, 90, 72, - 65, 191, 145, 5, 78, 2, 11, 73, 2, 223, 179, 5, 84, 6, 38, 85, 165, 179, - 5, 3, 65, 65, 67, 4, 18, 90, 87, 82, 2, 159, 196, 5, 72, 6, 60, 4, 75, - 75, 85, 82, 16, 2, 84, 72, 21, 3, 85, 86, 85, 2, 203, 82, 85, 2, 175, - 155, 3, 65, 2, 75, 90, 8, 26, 65, 251, 134, 5, 79, 6, 34, 84, 154, 153, - 4, 65, 15, 78, 2, 11, 72, 2, 17, 2, 65, 75, 2, 171, 177, 5, 75, 10, 38, - 65, 250, 81, 69, 227, 192, 4, 73, 4, 216, 102, 3, 82, 65, 65, 201, 249, - 2, 6, 75, 65, 73, 89, 65, 82, 2, 11, 69, 2, 187, 9, 78, 2, 17, 2, 82, 79, - 2, 227, 205, 4, 77, 148, 4, 130, 1, 75, 166, 1, 76, 166, 1, 78, 186, 1, - 82, 86, 83, 178, 1, 84, 214, 2, 67, 2, 72, 2, 74, 2, 77, 2, 80, 2, 86, 3, - 89, 46, 84, 2, 83, 83, 210, 251, 1, 65, 38, 85, 206, 141, 1, 79, 238, 60, - 73, 167, 204, 1, 69, 24, 250, 244, 1, 65, 250, 6, 85, 206, 141, 1, 79, - 238, 60, 73, 167, 204, 1, 69, 66, 78, 76, 182, 250, 1, 65, 38, 85, 206, - 141, 1, 79, 238, 60, 73, 167, 204, 1, 69, 44, 226, 6, 76, 210, 243, 1, - 65, 38, 85, 206, 141, 1, 79, 238, 60, 73, 167, 204, 1, 69, 110, 98, 78, - 174, 5, 71, 2, 89, 210, 243, 1, 65, 38, 85, 206, 141, 1, 79, 238, 60, 73, - 167, 204, 1, 69, 44, 170, 5, 78, 210, 243, 1, 65, 38, 85, 206, 141, 1, - 79, 238, 60, 73, 167, 204, 1, 69, 44, 214, 4, 82, 210, 243, 1, 65, 38, - 85, 206, 141, 1, 79, 238, 60, 73, 167, 204, 1, 69, 68, 90, 72, 170, 3, - 83, 210, 243, 1, 65, 38, 85, 206, 141, 1, 79, 238, 60, 73, 167, 204, 1, - 69, 24, 246, 246, 1, 65, 38, 85, 206, 141, 1, 79, 230, 2, 82, 138, 58, - 73, 167, 204, 1, 69, 44, 210, 2, 84, 210, 243, 1, 65, 38, 85, 206, 141, - 1, 79, 238, 60, 73, 167, 204, 1, 69, 6, 68, 2, 79, 84, 33, 11, 82, 65, - 68, 73, 84, 73, 79, 78, 65, 76, 32, 2, 11, 65, 2, 155, 197, 4, 76, 4, 24, - 2, 67, 82, 55, 78, 2, 17, 2, 69, 68, 2, 11, 73, 2, 203, 196, 4, 84, 2, - 11, 85, 2, 17, 2, 77, 66, 2, 123, 69, 22, 25, 4, 73, 71, 78, 32, 22, 206, - 243, 1, 65, 38, 85, 206, 141, 1, 79, 238, 60, 73, 167, 204, 1, 69, 2, 11, - 65, 2, 155, 195, 4, 82, 158, 15, 36, 5, 65, 66, 65, 84, 65, 35, 71, 2, - 11, 32, 2, 163, 215, 3, 84, 156, 15, 54, 69, 20, 3, 83, 65, 32, 213, 6, - 3, 85, 84, 32, 2, 195, 173, 4, 82, 178, 1, 52, 7, 76, 69, 84, 84, 69, 82, - 32, 171, 212, 3, 68, 158, 1, 210, 1, 65, 58, 70, 54, 72, 38, 76, 58, 77, - 54, 78, 50, 83, 122, 85, 114, 69, 2, 73, 2, 79, 2, 86, 182, 250, 4, 84, - 82, 67, 2, 68, 2, 71, 2, 75, 2, 80, 138, 69, 66, 2, 82, 2, 87, 2, 88, 2, - 89, 3, 90, 16, 146, 4, 87, 198, 194, 5, 67, 2, 81, 2, 88, 3, 90, 4, 164, - 245, 4, 5, 73, 78, 65, 76, 32, 251, 80, 65, 6, 186, 177, 1, 84, 179, 148, - 4, 65, 4, 176, 157, 4, 5, 79, 78, 71, 32, 85, 151, 168, 1, 65, 10, 142, - 197, 5, 65, 2, 67, 2, 81, 2, 88, 3, 90, 8, 162, 194, 5, 71, 2, 72, 2, 89, - 187, 2, 65, 8, 26, 72, 147, 196, 5, 65, 6, 40, 4, 79, 82, 84, 32, 231, - 195, 5, 65, 4, 184, 229, 3, 2, 85, 69, 233, 79, 2, 65, 87, 32, 58, 73, - 54, 69, 198, 194, 5, 67, 2, 81, 2, 88, 3, 90, 16, 50, 85, 198, 194, 5, - 67, 2, 81, 2, 88, 3, 90, 8, 194, 194, 5, 67, 2, 81, 2, 88, 3, 90, 232, - 13, 64, 10, 67, 79, 77, 80, 79, 78, 69, 78, 84, 45, 183, 155, 3, 73, 230, - 13, 78, 48, 178, 1, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 95, 56, - 198, 1, 86, 48, 130, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, - 56, 3, 57, 18, 158, 192, 5, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, - 2, 56, 3, 57, 200, 1, 166, 1, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, - 54, 2, 55, 2, 56, 3, 57, 168, 1, 74, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, - 53, 2, 54, 2, 55, 95, 56, 20, 158, 190, 5, 48, 2, 49, 2, 50, 2, 51, 2, - 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 8, 194, 189, 5, 48, 2, 49, 2, 50, - 3, 51, 4, 48, 6, 67, 65, 82, 84, 82, 73, 21, 2, 68, 82, 2, 175, 133, 4, - 68, 2, 251, 191, 4, 73, 2, 215, 179, 3, 82, 144, 3, 154, 1, 65, 152, 2, - 5, 68, 68, 89, 32, 66, 22, 76, 230, 14, 78, 144, 1, 5, 83, 84, 32, 84, - 85, 21, 12, 84, 82, 65, 71, 82, 65, 77, 32, 70, 79, 82, 32, 10, 68, 9, - 67, 85, 80, 32, 87, 73, 84, 72, 79, 58, 82, 211, 233, 4, 80, 2, 33, 6, - 85, 84, 32, 72, 65, 78, 2, 223, 147, 4, 68, 6, 72, 9, 45, 79, 70, 70, 32, - 67, 65, 76, 69, 29, 5, 68, 82, 79, 80, 45, 2, 253, 149, 4, 2, 78, 68, 4, - 170, 161, 3, 83, 205, 117, 4, 66, 65, 82, 66, 2, 179, 149, 4, 69, 218, 1, - 38, 69, 213, 2, 4, 85, 71, 85, 32, 16, 60, 6, 80, 72, 79, 78, 69, 32, - 246, 1, 83, 211, 184, 2, 86, 12, 132, 1, 3, 82, 69, 67, 208, 150, 1, 3, - 76, 79, 67, 178, 153, 3, 83, 189, 116, 13, 79, 78, 32, 84, 79, 80, 32, - 79, 70, 32, 77, 79, 68, 6, 36, 5, 69, 73, 86, 69, 82, 51, 79, 5, 29, 5, - 32, 87, 73, 84, 72, 2, 243, 38, 32, 2, 183, 146, 3, 82, 2, 11, 67, 2, - 151, 236, 3, 79, 202, 1, 162, 1, 65, 84, 15, 70, 82, 65, 67, 84, 73, 79, - 78, 32, 68, 73, 71, 73, 84, 32, 164, 2, 2, 76, 69, 252, 3, 5, 83, 73, 71, - 78, 32, 198, 2, 86, 247, 182, 3, 68, 4, 60, 9, 82, 67, 72, 65, 73, 67, - 32, 83, 72, 243, 210, 1, 73, 2, 167, 237, 2, 82, 14, 74, 84, 40, 2, 79, - 78, 81, 10, 90, 69, 82, 79, 32, 70, 79, 82, 32, 79, 8, 36, 3, 72, 82, 69, - 13, 2, 87, 79, 4, 11, 69, 4, 29, 5, 32, 70, 79, 82, 32, 4, 34, 79, 21, 4, - 69, 86, 69, 78, 2, 17, 2, 68, 68, 2, 49, 10, 32, 80, 79, 87, 69, 82, 83, - 32, 79, 70, 2, 133, 22, 2, 32, 70, 114, 44, 5, 84, 84, 69, 82, 32, 167, - 239, 4, 78, 112, 214, 1, 68, 54, 78, 106, 82, 38, 84, 130, 208, 1, 65, - 82, 76, 114, 86, 186, 5, 85, 206, 141, 1, 79, 238, 60, 73, 182, 196, 1, - 83, 82, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 162, 7, 69, 234, 61, 72, - 2, 77, 3, 89, 10, 242, 231, 4, 68, 138, 69, 72, 2, 90, 187, 2, 65, 10, - 42, 65, 158, 172, 5, 71, 2, 78, 3, 89, 5, 41, 8, 75, 65, 65, 82, 65, 32, - 80, 79, 2, 251, 36, 76, 6, 150, 209, 1, 82, 131, 221, 3, 65, 10, 178, - 230, 4, 84, 138, 69, 72, 2, 83, 187, 2, 65, 20, 86, 67, 194, 1, 83, 204, - 35, 3, 84, 85, 85, 222, 106, 78, 190, 66, 65, 187, 151, 3, 86, 6, 60, 9, - 79, 77, 66, 73, 78, 73, 78, 71, 32, 215, 142, 1, 65, 4, 70, 65, 221, 174, - 4, 11, 67, 65, 78, 68, 82, 65, 66, 73, 78, 68, 85, 2, 33, 6, 78, 85, 83, - 86, 65, 82, 2, 183, 174, 4, 65, 2, 11, 73, 2, 137, 238, 3, 3, 68, 68, 72, - 30, 49, 10, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 30, 166, 211, 1, 65, - 38, 85, 22, 86, 186, 141, 1, 79, 238, 60, 73, 167, 204, 1, 69, 6, 80, 10, - 78, 73, 83, 32, 82, 65, 67, 81, 85, 69, 158, 137, 3, 71, 139, 160, 2, 84, - 2, 11, 84, 2, 25, 4, 32, 65, 78, 68, 2, 187, 158, 3, 32, 2, 147, 146, 5, - 66, 162, 1, 210, 2, 65, 134, 1, 66, 174, 1, 67, 222, 2, 68, 202, 3, 69, - 154, 2, 70, 182, 1, 71, 198, 1, 72, 64, 8, 89, 79, 85, 84, 72, 70, 85, - 76, 52, 2, 73, 78, 46, 75, 98, 76, 146, 1, 77, 134, 1, 79, 62, 80, 142, - 1, 82, 210, 1, 83, 224, 1, 14, 86, 65, 83, 84, 78, 69, 83, 83, 32, 79, - 82, 32, 87, 65, 12, 2, 87, 65, 138, 94, 85, 167, 159, 4, 74, 8, 88, 4, - 67, 67, 85, 77, 22, 83, 228, 20, 2, 68, 86, 221, 202, 1, 5, 71, 71, 82, - 65, 86, 2, 195, 190, 1, 85, 2, 227, 225, 4, 67, 6, 92, 7, 79, 76, 68, 32, - 82, 69, 83, 32, 5, 82, 65, 78, 67, 72, 229, 152, 4, 3, 65, 82, 82, 2, - 197, 211, 4, 3, 79, 76, 85, 2, 11, 73, 2, 205, 170, 1, 3, 78, 71, 32, 22, - 54, 72, 20, 3, 76, 79, 83, 66, 79, 167, 157, 2, 69, 2, 211, 235, 3, 65, - 6, 26, 69, 171, 128, 4, 85, 4, 222, 253, 1, 68, 167, 140, 2, 78, 12, 28, - 3, 77, 80, 76, 35, 78, 4, 246, 17, 73, 219, 191, 4, 69, 8, 32, 4, 83, 84, - 65, 78, 23, 84, 2, 147, 144, 5, 67, 6, 46, 69, 20, 3, 82, 65, 82, 251, - 143, 4, 65, 2, 199, 208, 4, 78, 2, 155, 176, 3, 73, 20, 80, 4, 65, 82, - 75, 69, 22, 69, 210, 1, 73, 74, 85, 197, 129, 5, 3, 79, 85, 66, 2, 151, - 207, 4, 78, 6, 132, 1, 19, 70, 69, 67, 84, 73, 86, 69, 78, 69, 83, 83, - 32, 79, 82, 32, 68, 73, 83, 84, 34, 80, 137, 7, 6, 67, 73, 83, 73, 86, - 69, 2, 11, 79, 2, 163, 206, 4, 82, 2, 11, 65, 2, 11, 82, 2, 143, 10, 84, - 8, 68, 6, 70, 70, 73, 67, 85, 76, 34, 77, 161, 12, 4, 86, 69, 82, 71, 2, - 11, 84, 2, 223, 135, 4, 73, 4, 140, 1, 2, 73, 78, 191, 203, 4, 77, 14, - 100, 5, 77, 66, 69, 76, 76, 34, 78, 124, 4, 88, 72, 65, 85, 172, 106, 3, - 84, 69, 82, 215, 165, 3, 65, 2, 137, 217, 4, 3, 73, 83, 72, 6, 80, 4, 68, - 69, 65, 86, 20, 4, 76, 65, 82, 71, 229, 151, 3, 4, 67, 79, 85, 78, 2, - 247, 162, 4, 79, 2, 131, 216, 4, 69, 2, 211, 202, 4, 83, 12, 70, 79, 76, - 3, 85, 76, 76, 196, 5, 3, 65, 73, 76, 235, 233, 4, 76, 4, 18, 76, 35, 83, - 2, 173, 201, 4, 3, 76, 79, 87, 2, 205, 4, 2, 84, 69, 4, 214, 197, 3, 32, - 199, 59, 78, 10, 96, 8, 65, 84, 72, 69, 82, 73, 78, 71, 22, 79, 64, 3, - 82, 69, 65, 65, 5, 85, 65, 82, 68, 69, 5, 163, 153, 4, 32, 2, 41, 8, 73, - 78, 71, 32, 84, 79, 32, 77, 2, 159, 227, 4, 69, 2, 75, 84, 4, 48, 2, 65, - 82, 33, 6, 79, 76, 68, 73, 78, 71, 2, 11, 68, 2, 247, 254, 3, 78, 2, 11, - 32, 2, 227, 248, 1, 66, 4, 26, 67, 159, 217, 4, 78, 2, 143, 5, 82, 4, 60, - 7, 69, 69, 80, 73, 78, 71, 32, 169, 193, 4, 2, 73, 78, 2, 11, 83, 2, 247, - 139, 3, 77, 6, 18, 65, 107, 69, 4, 60, 3, 66, 79, 85, 21, 8, 87, 32, 79, - 82, 32, 77, 79, 68, 2, 191, 196, 4, 82, 2, 223, 137, 4, 69, 2, 215, 196, - 4, 71, 6, 26, 65, 30, 69, 47, 73, 2, 229, 195, 4, 2, 83, 83, 2, 11, 65, - 2, 11, 83, 2, 251, 241, 3, 85, 2, 11, 82, 2, 247, 205, 4, 69, 4, 220, - 209, 3, 7, 78, 32, 84, 72, 69, 32, 86, 199, 112, 80, 8, 54, 65, 64, 4, - 69, 78, 69, 84, 229, 97, 2, 85, 82, 4, 22, 84, 243, 2, 67, 2, 17, 2, 84, - 69, 2, 131, 195, 4, 82, 2, 131, 205, 1, 82, 12, 30, 69, 157, 1, 2, 73, - 84, 10, 34, 76, 22, 83, 191, 239, 4, 65, 2, 219, 232, 1, 69, 6, 18, 73, - 51, 80, 4, 30, 68, 137, 1, 2, 83, 84, 2, 147, 1, 69, 2, 11, 79, 2, 239, - 133, 4, 78, 2, 163, 133, 4, 85, 10, 34, 69, 64, 2, 73, 78, 23, 84, 2, 11, - 86, 2, 17, 2, 69, 82, 2, 11, 65, 2, 159, 211, 4, 78, 2, 131, 191, 4, 75, - 6, 42, 79, 209, 138, 3, 4, 82, 69, 78, 71, 4, 26, 80, 219, 248, 4, 86, 2, - 11, 80, 2, 235, 215, 3, 65, 2, 39, 83, 4, 26, 73, 191, 236, 4, 84, 2, - 223, 189, 4, 84, 226, 2, 78, 65, 182, 31, 69, 146, 2, 73, 206, 1, 79, + 254, 184, 5, 72, 201, 82, 2, 65, 68, 2, 17, 2, 77, 75, 2, 147, 177, 4, + 65, 6, 42, 90, 32, 2, 75, 72, 243, 161, 6, 70, 2, 187, 137, 5, 72, 2, 11, + 76, 2, 11, 65, 2, 167, 183, 6, 80, 6, 36, 3, 69, 84, 72, 223, 185, 5, 65, + 5, 245, 90, 6, 32, 71, 65, 82, 83, 72, 5, 199, 138, 6, 32, 4, 253, 145, + 4, 2, 73, 78, 6, 21, 3, 72, 65, 32, 6, 42, 68, 214, 145, 4, 66, 163, 168, + 1, 65, 2, 181, 130, 5, 2, 79, 84, 8, 58, 66, 138, 215, 2, 87, 237, 167, + 1, 4, 85, 75, 75, 65, 4, 249, 252, 3, 2, 65, 83, 14, 88, 8, 66, 76, 73, + 78, 69, 65, 82, 32, 113, 10, 80, 82, 65, 76, 73, 78, 69, 65, 82, 32, 8, + 44, 5, 67, 79, 76, 79, 78, 179, 219, 3, 70, 7, 11, 32, 4, 29, 5, 83, 75, + 69, 87, 69, 4, 167, 137, 6, 68, 6, 44, 5, 67, 79, 76, 79, 78, 195, 218, + 3, 70, 5, 169, 129, 6, 7, 32, 83, 75, 69, 87, 69, 68, 8, 62, 72, 25, 11, + 87, 79, 32, 86, 69, 82, 84, 73, 67, 65, 76, 4, 21, 3, 82, 69, 69, 4, 25, + 4, 32, 68, 79, 84, 4, 151, 141, 4, 83, 144, 47, 102, 45, 58, 65, 142, + 111, 69, 202, 45, 72, 206, 46, 73, 242, 68, 79, 182, 38, 82, 158, 18, 85, + 147, 22, 87, 4, 32, 2, 83, 72, 215, 136, 5, 82, 2, 151, 170, 5, 73, 200, + 29, 182, 1, 66, 86, 71, 168, 17, 2, 73, 32, 150, 35, 75, 144, 5, 9, 76, + 76, 89, 32, 77, 65, 82, 75, 32, 34, 77, 166, 37, 78, 240, 12, 3, 80, 69, + 32, 106, 85, 170, 163, 5, 67, 159, 11, 88, 5, 237, 128, 1, 16, 76, 69, + 32, 84, 69, 78, 78, 73, 83, 32, 80, 65, 68, 68, 76, 69, 144, 2, 78, 32, + 212, 11, 5, 65, 76, 79, 71, 32, 241, 2, 6, 66, 65, 78, 87, 65, 32, 190, + 1, 162, 1, 65, 102, 67, 186, 1, 68, 58, 69, 70, 71, 118, 72, 46, 76, 230, + 3, 80, 58, 81, 62, 82, 106, 83, 238, 81, 78, 226, 228, 1, 84, 150, 147, + 1, 70, 163, 189, 1, 86, 6, 42, 80, 250, 212, 2, 77, 163, 189, 1, 83, 2, + 17, 2, 79, 83, 2, 185, 255, 5, 4, 84, 82, 79, 80, 8, 18, 73, 63, 79, 2, + 25, 4, 82, 67, 85, 77, 2, 185, 2, 4, 70, 76, 69, 88, 6, 26, 77, 207, 219, + 5, 76, 4, 11, 77, 4, 248, 161, 5, 7, 69, 82, 67, 73, 65, 76, 32, 179, + 137, 1, 65, 22, 26, 79, 191, 179, 4, 73, 2, 11, 76, 2, 175, 90, 76, 4, + 26, 81, 235, 141, 5, 88, 2, 17, 2, 85, 65, 2, 239, 243, 2, 76, 4, 11, 82, + 4, 18, 65, 55, 69, 2, 11, 86, 2, 11, 69, 2, 193, 126, 3, 32, 65, 67, 2, + 145, 4, 4, 65, 84, 69, 82, 2, 181, 152, 2, 6, 89, 80, 72, 69, 78, 45, + 114, 38, 65, 254, 2, 69, 187, 183, 4, 79, 104, 25, 4, 84, 73, 78, 32, + 104, 34, 67, 41, 4, 83, 77, 65, 76, 52, 11, 65, 52, 25, 4, 80, 73, 84, + 65, 52, 41, 8, 76, 32, 76, 69, 84, 84, 69, 82, 52, 11, 32, 52, 134, 167, + 6, 65, 2, 66, 2, 67, 2, 68, 2, 69, 2, 70, 2, 71, 2, 72, 2, 73, 2, 74, 2, + 75, 2, 76, 2, 77, 2, 78, 2, 79, 2, 80, 2, 81, 2, 82, 2, 83, 2, 84, 2, 85, + 2, 86, 2, 87, 2, 88, 2, 89, 3, 90, 8, 22, 83, 199, 1, 70, 2, 11, 83, 2, + 177, 69, 3, 45, 84, 72, 4, 26, 69, 179, 238, 2, 76, 2, 11, 82, 2, 207, + 73, 67, 4, 11, 85, 4, 26, 79, 195, 203, 3, 69, 2, 215, 186, 5, 84, 8, 36, + 3, 73, 71, 72, 143, 135, 4, 69, 6, 17, 2, 84, 32, 6, 150, 147, 2, 67, + 210, 3, 80, 251, 7, 83, 6, 142, 207, 2, 69, 218, 185, 1, 79, 163, 221, 1, + 80, 46, 80, 7, 76, 69, 84, 84, 69, 82, 32, 208, 1, 5, 83, 73, 71, 78, 32, + 147, 2, 86, 38, 162, 1, 65, 170, 165, 2, 78, 134, 249, 3, 66, 2, 68, 2, + 71, 2, 72, 2, 75, 2, 76, 2, 77, 2, 80, 2, 82, 2, 83, 2, 84, 2, 87, 2, 89, + 186, 2, 73, 3, 85, 5, 137, 214, 5, 6, 82, 67, 72, 65, 73, 67, 4, 26, 80, + 199, 193, 2, 86, 2, 25, 4, 65, 77, 85, 68, 2, 203, 225, 2, 80, 36, 48, 7, + 76, 69, 84, 84, 69, 82, 32, 147, 1, 86, 32, 250, 163, 2, 78, 134, 249, 3, + 66, 2, 68, 2, 71, 2, 75, 2, 76, 2, 77, 2, 80, 2, 83, 2, 84, 2, 87, 2, 89, + 186, 2, 65, 2, 73, 3, 85, 4, 41, 8, 79, 87, 69, 76, 32, 83, 73, 71, 4, + 11, 78, 4, 183, 221, 5, 32, 194, 4, 140, 1, 10, 76, 69, 32, 76, 69, 84, + 84, 69, 82, 32, 248, 2, 5, 84, 72, 65, 77, 32, 192, 18, 5, 86, 73, 69, + 84, 32, 225, 6, 3, 89, 79, 32, 70, 186, 1, 65, 34, 69, 30, 84, 150, 159, + 2, 78, 146, 174, 1, 79, 238, 133, 2, 75, 2, 80, 162, 7, 85, 234, 61, 70, + 2, 72, 2, 76, 2, 77, 2, 81, 2, 83, 2, 86, 2, 88, 2, 89, 187, 2, 73, 7, + 182, 132, 6, 85, 215, 22, 73, 7, 234, 154, 6, 69, 3, 72, 18, 60, 3, 79, + 78, 69, 210, 210, 5, 83, 138, 69, 72, 187, 2, 65, 10, 11, 45, 10, 130, + 154, 6, 50, 2, 51, 2, 52, 2, 53, 3, 54, 254, 1, 196, 1, 2, 67, 79, 232, + 3, 4, 72, 79, 82, 65, 0, 4, 84, 72, 65, 77, 28, 7, 76, 69, 84, 84, 69, + 82, 32, 220, 4, 5, 83, 73, 71, 78, 32, 217, 5, 11, 86, 79, 87, 69, 76, + 32, 83, 73, 71, 78, 32, 20, 164, 1, 13, 78, 83, 79, 78, 65, 78, 84, 32, + 83, 73, 71, 78, 32, 173, 131, 5, 21, 77, 66, 73, 78, 73, 78, 71, 32, 67, + 82, 89, 80, 84, 79, 71, 82, 65, 77, 77, 73, 67, 18, 148, 1, 6, 70, 73, + 78, 65, 76, 32, 22, 76, 48, 16, 72, 73, 71, 72, 32, 82, 65, 84, 72, 65, + 32, 79, 82, 32, 76, 79, 22, 77, 182, 146, 6, 66, 3, 83, 2, 255, 210, 5, + 78, 4, 46, 79, 165, 26, 6, 65, 32, 84, 65, 78, 71, 2, 163, 220, 1, 87, 6, + 48, 6, 69, 68, 73, 65, 76, 32, 187, 148, 6, 65, 4, 254, 145, 6, 76, 3, + 82, 20, 249, 156, 4, 2, 32, 68, 106, 188, 1, 2, 71, 82, 44, 5, 72, 73, + 71, 72, 32, 94, 76, 222, 1, 82, 242, 179, 2, 85, 138, 204, 1, 73, 186, + 15, 78, 186, 225, 1, 79, 162, 8, 69, 158, 20, 66, 2, 68, 2, 77, 2, 87, + 187, 2, 65, 2, 21, 3, 69, 65, 84, 2, 227, 143, 6, 32, 32, 242, 1, 75, 42, + 82, 234, 199, 5, 83, 82, 67, 2, 80, 2, 84, 138, 69, 70, 2, 72, 3, 89, 36, + 60, 3, 79, 87, 32, 218, 208, 5, 65, 206, 41, 85, 159, 20, 76, 28, 86, 75, + 42, 82, 186, 200, 5, 67, 2, 80, 2, 84, 138, 69, 70, 2, 72, 2, 83, 3, 89, + 6, 230, 141, 6, 72, 2, 88, 187, 2, 65, 2, 181, 143, 4, 2, 65, 84, 8, 26, + 65, 239, 248, 5, 85, 7, 134, 141, 6, 78, 3, 84, 50, 182, 1, 72, 34, 75, + 176, 1, 4, 77, 65, 73, 32, 82, 82, 136, 1, 2, 83, 65, 92, 5, 87, 73, 65, + 78, 71, 164, 132, 1, 3, 68, 79, 75, 132, 122, 3, 84, 79, 78, 237, 178, 3, + 2, 67, 65, 4, 242, 188, 5, 65, 179, 63, 79, 14, 52, 4, 72, 85, 69, 78, + 134, 3, 65, 179, 237, 4, 69, 8, 80, 6, 32, 84, 79, 78, 69, 45, 173, 189, + 4, 8, 45, 76, 85, 69, 32, 75, 65, 82, 6, 190, 140, 6, 51, 2, 52, 3, 53, + 8, 56, 4, 75, 65, 78, 71, 238, 140, 1, 89, 227, 190, 3, 83, 5, 159, 146, + 1, 32, 4, 92, 3, 65, 32, 72, 21, 16, 69, 86, 69, 82, 83, 69, 68, 32, 82, + 79, 84, 65, 84, 69, 68, 32, 2, 215, 202, 4, 65, 2, 247, 210, 3, 82, 8, + 48, 3, 84, 75, 65, 254, 186, 4, 87, 223, 126, 75, 4, 17, 2, 65, 78, 5, + 243, 145, 4, 75, 5, 225, 204, 3, 2, 87, 65, 38, 90, 65, 36, 4, 77, 65, + 73, 32, 22, 79, 46, 84, 94, 85, 206, 247, 3, 73, 231, 143, 2, 69, 9, 238, + 136, 6, 65, 2, 69, 3, 73, 2, 155, 255, 4, 83, 11, 130, 227, 3, 65, 182, + 165, 2, 79, 3, 89, 4, 30, 65, 41, 3, 72, 65, 77, 2, 17, 2, 76, 76, 2, + 139, 143, 4, 32, 2, 143, 142, 1, 32, 9, 142, 199, 5, 85, 163, 64, 69, + 144, 1, 184, 1, 7, 76, 69, 84, 84, 69, 82, 32, 188, 2, 5, 77, 65, 73, 32, + 75, 32, 7, 83, 89, 77, 66, 79, 76, 32, 124, 9, 84, 79, 78, 69, 32, 77, + 65, 73, 32, 81, 6, 86, 79, 87, 69, 76, 32, 96, 44, 4, 72, 73, 71, 72, 1, + 3, 76, 79, 87, 48, 11, 32, 48, 154, 1, 75, 30, 67, 2, 80, 2, 84, 34, 78, + 202, 228, 5, 66, 2, 68, 2, 70, 2, 71, 2, 72, 2, 76, 2, 77, 2, 82, 2, 83, + 2, 86, 2, 89, 247, 30, 79, 6, 26, 72, 223, 131, 6, 79, 4, 230, 228, 5, + 72, 247, 30, 79, 6, 198, 228, 5, 71, 2, 89, 247, 30, 79, 4, 154, 178, 5, + 65, 195, 52, 72, 10, 72, 2, 75, 79, 110, 78, 200, 132, 1, 4, 72, 79, 32, + 72, 227, 188, 3, 83, 4, 176, 133, 1, 3, 73, 32, 75, 247, 252, 4, 78, 8, + 58, 78, 214, 138, 1, 84, 222, 171, 2, 83, 247, 199, 2, 69, 2, 223, 182, + 3, 85, 26, 62, 65, 206, 4, 85, 182, 228, 1, 73, 234, 151, 4, 69, 3, 79, + 10, 146, 234, 5, 85, 214, 22, 65, 2, 77, 2, 78, 3, 89, 110, 72, 7, 76, + 69, 84, 84, 69, 82, 32, 238, 3, 83, 157, 1, 3, 88, 65, 77, 96, 206, 1, + 65, 80, 2, 76, 79, 12, 4, 72, 73, 71, 72, 126, 78, 34, 85, 182, 133, 1, + 80, 2, 84, 130, 95, 73, 190, 202, 1, 79, 186, 174, 2, 66, 2, 67, 2, 68, + 2, 71, 2, 77, 2, 81, 2, 86, 2, 89, 247, 30, 69, 16, 190, 231, 5, 85, 214, + 22, 65, 2, 69, 2, 75, 2, 77, 2, 78, 2, 80, 3, 84, 21, 11, 87, 18, 11, 32, + 18, 70, 75, 162, 164, 5, 78, 210, 57, 70, 2, 72, 2, 80, 2, 84, 3, 88, 6, + 238, 221, 5, 72, 2, 86, 247, 30, 79, 4, 198, 221, 5, 71, 247, 30, 79, 9, + 178, 228, 1, 69, 235, 151, 4, 65, 12, 76, 4, 73, 71, 78, 32, 213, 162, 5, + 9, 89, 77, 66, 79, 76, 32, 77, 85, 69, 10, 38, 65, 174, 228, 5, 85, 255, + 5, 79, 6, 170, 250, 5, 78, 86, 85, 3, 89, 2, 155, 129, 1, 32, 138, 1, 52, + 3, 82, 73, 32, 169, 235, 4, 4, 69, 79, 85, 84, 136, 1, 82, 65, 20, 7, 76, + 69, 84, 84, 69, 82, 32, 166, 2, 83, 78, 86, 147, 255, 3, 68, 2, 155, 211, + 1, 66, 88, 210, 1, 65, 142, 149, 2, 68, 82, 82, 34, 84, 230, 5, 85, 138, + 204, 1, 73, 170, 199, 1, 78, 126, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, + 2, 83, 138, 69, 72, 2, 76, 2, 77, 2, 86, 2, 89, 186, 2, 69, 3, 79, 11, + 180, 192, 3, 7, 82, 67, 72, 65, 73, 67, 32, 150, 183, 2, 65, 2, 73, 3, + 85, 8, 25, 4, 73, 71, 78, 32, 8, 230, 211, 1, 78, 130, 222, 3, 65, 239, + 1, 86, 18, 49, 10, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 18, 234, 153, + 2, 65, 38, 85, 138, 204, 1, 73, 230, 143, 2, 69, 3, 79, 4, 134, 51, 70, + 131, 167, 4, 79, 188, 6, 36, 3, 73, 76, 32, 243, 205, 4, 65, 186, 6, 154, + 3, 65, 106, 67, 194, 2, 68, 72, 3, 87, 69, 84, 48, 9, 70, 82, 65, 67, 84, + 73, 79, 78, 32, 232, 7, 9, 73, 78, 32, 80, 79, 83, 83, 69, 83, 22, 76, + 200, 2, 7, 78, 85, 77, 66, 69, 82, 32, 152, 1, 18, 80, 85, 78, 67, 84, + 85, 65, 84, 73, 79, 78, 32, 69, 78, 68, 32, 79, 70, 54, 82, 42, 83, 154, + 14, 84, 228, 1, 7, 86, 79, 87, 69, 76, 32, 83, 100, 2, 89, 69, 148, 201, + 4, 5, 77, 79, 78, 84, 72, 171, 118, 79, 6, 80, 5, 83, 32, 65, 66, 79, + 134, 139, 2, 85, 157, 247, 1, 5, 78, 68, 32, 79, 68, 2, 207, 205, 3, 86, + 52, 80, 9, 79, 78, 83, 79, 78, 65, 78, 84, 32, 156, 21, 3, 85, 82, 82, + 159, 9, 82, 48, 130, 1, 75, 22, 76, 22, 78, 46, 84, 182, 191, 1, 83, 250, + 83, 82, 142, 219, 3, 67, 2, 72, 2, 74, 2, 77, 2, 80, 2, 86, 3, 89, 5, + 175, 177, 5, 83, 7, 203, 242, 4, 76, 11, 222, 237, 3, 78, 134, 129, 2, + 71, 3, 89, 5, 183, 238, 5, 84, 26, 68, 2, 82, 89, 152, 28, 2, 69, 66, + 246, 150, 2, 65, 191, 195, 1, 73, 2, 225, 199, 1, 7, 32, 67, 85, 76, 84, + 73, 86, 42, 168, 1, 4, 79, 78, 69, 32, 220, 4, 6, 84, 72, 82, 69, 69, 32, + 137, 230, 5, 22, 68, 79, 87, 78, 83, 67, 65, 76, 73, 78, 71, 32, 70, 65, + 67, 84, 79, 82, 32, 75, 73, 73, 30, 112, 5, 69, 73, 71, 72, 84, 34, 70, + 40, 3, 72, 65, 76, 22, 79, 88, 4, 83, 73, 88, 84, 74, 84, 147, 224, 3, + 81, 4, 210, 3, 73, 187, 231, 5, 72, 4, 156, 3, 2, 79, 82, 147, 222, 3, + 73, 4, 143, 223, 1, 70, 2, 225, 2, 18, 78, 69, 45, 72, 85, 78, 68, 82, + 69, 68, 45, 65, 78, 68, 45, 83, 73, 88, 6, 160, 222, 1, 5, 69, 69, 78, + 84, 72, 233, 25, 5, 89, 45, 70, 79, 85, 8, 38, 72, 138, 1, 87, 199, 223, + 3, 69, 4, 132, 1, 18, 82, 69, 69, 45, 72, 85, 78, 68, 82, 69, 68, 45, 65, + 78, 68, 45, 84, 87, 137, 166, 4, 8, 73, 82, 84, 89, 45, 83, 69, 67, 2, + 17, 2, 69, 78, 2, 17, 2, 84, 73, 2, 167, 223, 3, 69, 10, 58, 69, 28, 4, + 83, 73, 88, 84, 82, 84, 251, 222, 3, 81, 2, 129, 1, 3, 73, 71, 72, 4, 50, + 69, 237, 223, 3, 6, 89, 45, 70, 79, 85, 82, 2, 233, 223, 3, 2, 69, 78, 2, + 21, 3, 87, 69, 78, 2, 181, 223, 3, 3, 84, 73, 69, 2, 227, 218, 1, 83, 72, + 48, 6, 69, 84, 84, 69, 82, 32, 155, 246, 3, 65, 70, 194, 1, 78, 146, 201, + 1, 84, 198, 55, 65, 82, 76, 38, 82, 134, 6, 85, 194, 142, 1, 79, 202, 61, + 73, 214, 199, 1, 83, 242, 7, 69, 234, 61, 67, 2, 72, 2, 74, 2, 75, 2, 77, + 2, 80, 2, 86, 3, 89, 10, 46, 78, 210, 224, 5, 71, 2, 89, 187, 2, 65, 4, + 206, 224, 5, 78, 187, 2, 65, 8, 38, 79, 174, 137, 4, 84, 175, 82, 83, 4, + 11, 78, 4, 17, 2, 69, 32, 4, 18, 72, 31, 84, 2, 253, 71, 3, 85, 78, 68, + 2, 169, 138, 2, 3, 72, 79, 85, 2, 17, 2, 32, 84, 2, 11, 69, 2, 131, 197, + 5, 88, 2, 17, 2, 85, 80, 2, 223, 189, 3, 69, 194, 4, 152, 1, 5, 65, 76, + 84, 32, 80, 20, 4, 73, 71, 78, 32, 206, 4, 80, 28, 9, 84, 65, 82, 84, 73, + 78, 71, 32, 70, 29, 8, 89, 76, 76, 65, 66, 76, 69, 32, 2, 179, 224, 3, + 65, 40, 90, 65, 48, 3, 67, 69, 86, 34, 75, 80, 2, 77, 85, 102, 85, 14, + 80, 118, 86, 203, 64, 78, 4, 216, 2, 4, 65, 90, 72, 65, 159, 151, 5, 78, + 2, 11, 73, 2, 191, 185, 5, 84, 6, 38, 85, 133, 185, 5, 3, 65, 65, 67, 4, + 18, 90, 87, 82, 2, 255, 201, 5, 72, 6, 60, 4, 75, 75, 85, 82, 16, 2, 84, + 72, 21, 3, 85, 86, 85, 2, 187, 82, 85, 2, 147, 157, 3, 65, 2, 75, 90, 8, + 26, 65, 219, 140, 5, 79, 6, 34, 84, 246, 155, 4, 65, 15, 78, 2, 11, 72, + 2, 17, 2, 65, 75, 2, 139, 183, 5, 75, 10, 38, 65, 234, 81, 69, 211, 198, + 4, 73, 4, 200, 102, 3, 82, 65, 65, 161, 252, 2, 6, 75, 65, 73, 89, 65, + 82, 2, 11, 69, 2, 175, 9, 78, 2, 241, 150, 2, 2, 82, 79, 148, 4, 130, 1, + 75, 166, 1, 76, 166, 1, 78, 186, 1, 82, 86, 83, 178, 1, 84, 214, 2, 67, + 2, 72, 2, 74, 2, 77, 2, 80, 2, 86, 3, 89, 46, 84, 2, 83, 83, 206, 252, 1, + 65, 38, 85, 194, 142, 1, 79, 202, 61, 73, 199, 207, 1, 69, 24, 246, 245, + 1, 65, 250, 6, 85, 194, 142, 1, 79, 202, 61, 73, 199, 207, 1, 69, 66, 78, + 76, 178, 251, 1, 65, 38, 85, 194, 142, 1, 79, 202, 61, 73, 199, 207, 1, + 69, 44, 226, 6, 76, 206, 244, 1, 65, 38, 85, 194, 142, 1, 79, 202, 61, + 73, 199, 207, 1, 69, 110, 98, 78, 174, 5, 71, 2, 89, 206, 244, 1, 65, 38, + 85, 194, 142, 1, 79, 202, 61, 73, 199, 207, 1, 69, 44, 170, 5, 78, 206, + 244, 1, 65, 38, 85, 194, 142, 1, 79, 202, 61, 73, 199, 207, 1, 69, 44, + 214, 4, 82, 206, 244, 1, 65, 38, 85, 194, 142, 1, 79, 202, 61, 73, 199, + 207, 1, 69, 68, 90, 72, 170, 3, 83, 206, 244, 1, 65, 38, 85, 194, 142, 1, + 79, 202, 61, 73, 199, 207, 1, 69, 24, 242, 247, 1, 65, 38, 85, 194, 142, + 1, 79, 230, 2, 82, 230, 58, 73, 199, 207, 1, 69, 44, 210, 2, 84, 206, + 244, 1, 65, 38, 85, 194, 142, 1, 79, 202, 61, 73, 199, 207, 1, 69, 6, 68, + 2, 79, 84, 33, 11, 82, 65, 68, 73, 84, 73, 79, 78, 65, 76, 32, 2, 11, 65, + 2, 135, 203, 4, 76, 4, 24, 2, 67, 82, 55, 78, 2, 17, 2, 69, 68, 2, 11, + 73, 2, 183, 202, 4, 84, 2, 11, 85, 2, 17, 2, 77, 66, 2, 123, 69, 22, 25, + 4, 73, 71, 78, 32, 22, 202, 244, 1, 65, 38, 85, 194, 142, 1, 79, 202, 61, + 73, 199, 207, 1, 69, 2, 11, 65, 2, 135, 201, 4, 82, 158, 15, 36, 5, 65, + 66, 65, 84, 65, 35, 71, 2, 11, 32, 2, 247, 217, 3, 84, 156, 15, 54, 69, + 20, 3, 83, 65, 32, 213, 6, 3, 85, 84, 32, 2, 175, 179, 4, 82, 178, 1, 52, + 7, 76, 69, 84, 84, 69, 82, 32, 255, 214, 3, 68, 158, 1, 210, 1, 65, 58, + 70, 54, 72, 38, 76, 58, 77, 54, 78, 50, 83, 122, 85, 114, 69, 2, 73, 2, + 79, 2, 86, 162, 128, 5, 84, 82, 67, 2, 68, 2, 71, 2, 75, 2, 80, 138, 69, + 66, 2, 82, 2, 87, 2, 88, 2, 89, 3, 90, 16, 146, 4, 87, 178, 200, 5, 67, + 2, 81, 2, 88, 3, 90, 4, 144, 251, 4, 5, 73, 78, 65, 76, 32, 251, 80, 65, + 6, 174, 177, 1, 84, 171, 154, 4, 65, 4, 220, 162, 4, 5, 79, 78, 71, 32, + 85, 215, 168, 1, 65, 10, 250, 202, 5, 65, 2, 67, 2, 81, 2, 88, 3, 90, 8, + 142, 200, 5, 71, 2, 72, 2, 89, 187, 2, 65, 8, 26, 72, 255, 201, 5, 65, 6, + 40, 4, 79, 82, 84, 32, 211, 201, 5, 65, 4, 148, 232, 3, 2, 85, 69, 249, + 82, 2, 65, 87, 32, 58, 73, 54, 69, 178, 200, 5, 67, 2, 81, 2, 88, 3, 90, + 16, 50, 85, 178, 200, 5, 67, 2, 81, 2, 88, 3, 90, 8, 174, 200, 5, 67, 2, + 81, 2, 88, 3, 90, 232, 13, 64, 10, 67, 79, 77, 80, 79, 78, 69, 78, 84, + 45, 239, 157, 3, 73, 230, 13, 78, 48, 178, 1, 49, 2, 50, 2, 51, 2, 52, 2, + 53, 2, 54, 2, 55, 95, 56, 198, 1, 86, 48, 130, 2, 49, 2, 50, 2, 51, 2, + 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 18, 138, 198, 5, 49, 2, 50, 2, 51, + 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 200, 1, 166, 1, 48, 2, 49, 2, + 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 168, 1, 74, 48, 2, + 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 95, 56, 20, 138, 196, 5, + 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 8, + 174, 195, 5, 48, 2, 49, 2, 50, 3, 51, 4, 40, 4, 67, 65, 82, 84, 41, 2, + 68, 82, 2, 17, 2, 82, 73, 2, 139, 136, 4, 68, 2, 219, 197, 4, 73, 2, 159, + 182, 3, 82, 144, 3, 158, 1, 65, 164, 2, 5, 68, 68, 89, 32, 66, 22, 76, + 230, 14, 78, 144, 1, 12, 84, 82, 65, 71, 82, 65, 77, 32, 70, 79, 82, 32, + 149, 182, 1, 4, 83, 84, 32, 84, 10, 68, 9, 67, 85, 80, 32, 87, 73, 84, + 72, 79, 70, 82, 163, 239, 4, 80, 2, 17, 2, 85, 84, 2, 25, 4, 32, 72, 65, + 78, 2, 239, 152, 4, 68, 6, 72, 9, 45, 79, 70, 70, 32, 67, 65, 76, 69, 29, + 5, 68, 82, 79, 80, 45, 2, 141, 155, 4, 2, 78, 68, 4, 218, 163, 3, 83, + 173, 120, 4, 66, 65, 82, 66, 2, 195, 154, 4, 69, 218, 1, 38, 69, 213, 2, + 4, 85, 71, 85, 32, 16, 60, 6, 80, 72, 79, 78, 69, 32, 246, 1, 83, 167, + 186, 2, 86, 12, 132, 1, 3, 82, 69, 67, 192, 150, 1, 3, 76, 79, 67, 146, + 159, 3, 83, 189, 116, 13, 79, 78, 32, 84, 79, 80, 32, 79, 70, 32, 77, 79, + 68, 6, 36, 5, 69, 73, 86, 69, 82, 51, 79, 5, 29, 5, 32, 87, 73, 84, 72, + 2, 211, 38, 32, 2, 211, 148, 3, 82, 2, 11, 67, 2, 239, 238, 3, 79, 202, + 1, 162, 1, 65, 84, 15, 70, 82, 65, 67, 84, 73, 79, 78, 32, 68, 73, 71, + 73, 84, 32, 164, 2, 2, 76, 69, 252, 3, 5, 83, 73, 71, 78, 32, 198, 2, 86, + 175, 185, 3, 68, 4, 60, 9, 82, 67, 72, 65, 73, 67, 32, 83, 72, 211, 211, + 1, 73, 2, 251, 238, 2, 82, 14, 74, 84, 40, 2, 79, 78, 81, 10, 90, 69, 82, + 79, 32, 70, 79, 82, 32, 79, 8, 36, 3, 72, 82, 69, 13, 2, 87, 79, 4, 11, + 69, 4, 29, 5, 32, 70, 79, 82, 32, 4, 34, 79, 21, 4, 69, 86, 69, 78, 2, + 17, 2, 68, 68, 2, 49, 10, 32, 80, 79, 87, 69, 82, 83, 32, 79, 70, 2, 237, + 21, 2, 32, 70, 114, 44, 5, 84, 84, 69, 82, 32, 247, 244, 4, 78, 112, 214, + 1, 68, 54, 78, 106, 82, 38, 84, 226, 208, 1, 65, 82, 76, 114, 86, 186, 5, + 85, 194, 142, 1, 79, 202, 61, 73, 214, 199, 1, 83, 82, 66, 2, 67, 2, 71, + 2, 74, 2, 75, 2, 80, 162, 7, 69, 234, 61, 72, 2, 77, 3, 89, 10, 194, 237, + 4, 68, 138, 69, 72, 2, 90, 187, 2, 65, 10, 42, 65, 238, 177, 5, 71, 2, + 78, 3, 89, 5, 41, 8, 75, 65, 65, 82, 65, 32, 80, 79, 2, 219, 36, 76, 6, + 246, 209, 1, 82, 243, 225, 3, 65, 10, 130, 236, 4, 84, 138, 69, 72, 2, + 83, 187, 2, 65, 20, 86, 67, 194, 1, 83, 172, 35, 3, 84, 85, 85, 214, 106, + 78, 198, 67, 65, 171, 156, 3, 86, 6, 60, 9, 79, 77, 66, 73, 78, 73, 78, + 71, 32, 175, 142, 1, 65, 4, 70, 65, 173, 180, 4, 11, 67, 65, 78, 68, 82, + 65, 66, 73, 78, 68, 85, 2, 33, 6, 78, 85, 83, 86, 65, 82, 2, 135, 180, 4, + 65, 2, 11, 73, 2, 213, 240, 3, 3, 68, 68, 72, 30, 49, 10, 79, 87, 69, 76, + 32, 83, 73, 71, 78, 32, 30, 134, 212, 1, 65, 38, 85, 22, 86, 174, 142, 1, + 79, 202, 61, 73, 199, 207, 1, 69, 6, 80, 10, 78, 73, 83, 32, 82, 65, 67, + 81, 85, 69, 206, 139, 3, 71, 171, 163, 2, 84, 2, 11, 84, 2, 25, 4, 32, + 65, 78, 68, 2, 235, 160, 3, 32, 162, 1, 206, 2, 65, 134, 1, 66, 174, 1, + 67, 222, 2, 68, 202, 3, 69, 154, 2, 70, 182, 1, 71, 198, 1, 72, 64, 8, + 89, 79, 85, 84, 72, 70, 85, 76, 52, 2, 73, 78, 46, 75, 98, 76, 146, 1, + 77, 122, 79, 62, 80, 146, 1, 82, 210, 1, 83, 224, 1, 14, 86, 65, 83, 84, + 78, 69, 83, 83, 32, 79, 82, 32, 87, 65, 12, 2, 87, 65, 142, 94, 85, 147, + 165, 4, 74, 8, 88, 4, 67, 67, 85, 77, 22, 83, 220, 20, 2, 68, 86, 213, + 203, 1, 5, 71, 71, 82, 65, 86, 2, 187, 191, 1, 85, 2, 203, 231, 4, 67, 6, + 92, 7, 79, 76, 68, 32, 82, 69, 83, 32, 5, 82, 65, 78, 67, 72, 205, 158, + 4, 3, 65, 82, 82, 2, 173, 217, 4, 3, 79, 76, 85, 2, 11, 73, 2, 253, 170, + 1, 3, 78, 71, 32, 22, 54, 72, 20, 3, 76, 79, 83, 66, 79, 147, 159, 2, 69, + 2, 183, 238, 3, 65, 6, 26, 69, 211, 133, 4, 85, 4, 202, 255, 1, 68, 163, + 144, 2, 78, 12, 28, 3, 77, 80, 76, 35, 78, 4, 238, 17, 73, 203, 197, 4, + 69, 8, 32, 4, 83, 84, 65, 78, 23, 84, 2, 251, 149, 5, 67, 6, 46, 69, 20, + 3, 82, 65, 82, 227, 149, 4, 65, 2, 175, 214, 4, 78, 2, 235, 178, 3, 73, + 20, 80, 4, 65, 82, 75, 69, 22, 69, 210, 1, 73, 74, 85, 173, 135, 5, 3, + 79, 85, 66, 2, 255, 212, 4, 78, 6, 132, 1, 19, 70, 69, 67, 84, 73, 86, + 69, 78, 69, 83, 83, 32, 79, 82, 32, 68, 73, 83, 84, 34, 80, 137, 7, 6, + 67, 73, 83, 73, 86, 69, 2, 11, 79, 2, 139, 212, 4, 82, 2, 11, 65, 2, 11, + 82, 2, 143, 10, 84, 8, 68, 6, 70, 70, 73, 67, 85, 76, 34, 77, 153, 12, 4, + 86, 69, 82, 71, 2, 11, 84, 2, 199, 141, 4, 73, 4, 140, 1, 2, 73, 78, 167, + 209, 4, 77, 14, 100, 5, 77, 66, 69, 76, 76, 34, 78, 124, 4, 88, 72, 65, + 85, 168, 106, 3, 84, 69, 82, 195, 171, 3, 65, 2, 241, 222, 4, 3, 73, 83, + 72, 6, 80, 4, 68, 69, 65, 86, 20, 4, 76, 65, 82, 71, 181, 154, 3, 4, 67, + 79, 85, 78, 2, 223, 168, 4, 79, 2, 235, 221, 4, 69, 2, 187, 208, 4, 83, + 12, 70, 79, 76, 3, 85, 76, 76, 196, 5, 3, 65, 73, 76, 211, 239, 4, 76, 4, + 18, 76, 35, 83, 2, 149, 207, 4, 3, 76, 79, 87, 2, 205, 4, 2, 84, 69, 4, + 174, 200, 3, 32, 215, 62, 78, 10, 96, 8, 65, 84, 72, 69, 82, 73, 78, 71, + 22, 79, 64, 3, 82, 69, 65, 65, 5, 85, 65, 82, 68, 69, 5, 139, 159, 4, 32, + 2, 41, 8, 73, 78, 71, 32, 84, 79, 32, 77, 2, 135, 233, 4, 69, 2, 75, 84, + 4, 48, 2, 65, 82, 33, 6, 79, 76, 68, 73, 78, 71, 2, 11, 68, 2, 223, 132, + 4, 78, 2, 11, 32, 2, 207, 250, 1, 66, 4, 26, 67, 135, 223, 4, 78, 2, 135, + 5, 82, 4, 60, 7, 69, 69, 80, 73, 78, 71, 32, 145, 199, 4, 2, 73, 78, 2, + 11, 83, 2, 191, 142, 3, 77, 6, 18, 65, 107, 69, 4, 60, 3, 66, 79, 85, 21, + 8, 87, 32, 79, 82, 32, 77, 79, 68, 2, 167, 202, 4, 82, 2, 199, 143, 4, + 69, 2, 191, 202, 4, 71, 6, 26, 65, 30, 69, 47, 73, 2, 205, 201, 4, 2, 83, + 83, 2, 11, 65, 2, 11, 83, 2, 163, 247, 3, 85, 2, 239, 229, 3, 82, 4, 204, + 212, 3, 7, 78, 32, 84, 72, 69, 32, 86, 203, 115, 80, 8, 42, 65, 64, 4, + 69, 78, 69, 84, 23, 85, 4, 22, 84, 131, 3, 67, 2, 17, 2, 84, 69, 2, 131, + 201, 4, 82, 2, 139, 206, 1, 82, 2, 227, 97, 82, 12, 30, 69, 157, 1, 2, + 73, 84, 10, 34, 76, 22, 83, 175, 245, 4, 65, 2, 195, 234, 1, 69, 6, 18, + 73, 51, 80, 4, 30, 68, 137, 1, 2, 83, 84, 2, 147, 1, 69, 2, 11, 79, 2, + 223, 139, 4, 78, 2, 147, 139, 4, 85, 10, 34, 69, 64, 2, 73, 78, 23, 84, + 2, 11, 86, 2, 17, 2, 69, 82, 2, 11, 65, 2, 143, 217, 4, 78, 2, 243, 196, + 4, 75, 6, 42, 79, 169, 141, 3, 4, 82, 69, 78, 71, 4, 26, 80, 203, 254, 4, + 86, 2, 11, 80, 2, 215, 218, 3, 65, 2, 39, 83, 4, 26, 73, 175, 242, 4, 84, + 2, 207, 195, 4, 84, 226, 2, 78, 65, 182, 31, 69, 150, 2, 73, 206, 1, 79, 100, 3, 82, 69, 69, 187, 8, 85, 146, 2, 44, 4, 65, 78, 65, 32, 145, 10, 2, 73, 32, 100, 122, 65, 38, 69, 76, 7, 76, 69, 84, 84, 69, 82, 32, 154, 7, 79, 76, 3, 73, 66, 73, 0, 3, 85, 66, 85, 45, 2, 83, 85, 4, 184, 8, 3, 65, 66, 65, 3, 66, 6, 58, 66, 0, 3, 69, 66, 69, 245, 7, 4, 89, 66, 69, 89, 2, 243, 7, 69, 78, 202, 1, 65, 42, 68, 82, 70, 2, 81, 14, 71, 50, 72, 38, 75, 62, 76, 32, 3, 77, 69, 69, 20, 2, 67, 72, 2, 74, 2, 80, 18, 78, - 42, 83, 94, 84, 102, 86, 2, 87, 42, 90, 246, 143, 3, 66, 2, 82, 3, 89, 4, - 252, 1, 2, 76, 73, 159, 227, 4, 73, 6, 30, 65, 29, 3, 72, 65, 65, 4, 218, - 2, 65, 255, 1, 86, 2, 195, 228, 4, 76, 2, 123, 65, 6, 110, 65, 86, 78, - 213, 226, 4, 3, 72, 65, 73, 4, 166, 147, 3, 72, 255, 242, 1, 65, 4, 26, - 65, 235, 146, 3, 72, 2, 11, 65, 2, 167, 227, 4, 70, 4, 18, 65, 35, 72, 2, - 11, 65, 2, 243, 226, 4, 77, 2, 211, 1, 65, 4, 192, 226, 4, 2, 79, 79, + 42, 83, 94, 84, 102, 86, 2, 87, 42, 90, 206, 146, 3, 66, 2, 82, 3, 89, 4, + 252, 1, 2, 76, 73, 143, 233, 4, 73, 6, 30, 65, 29, 3, 72, 65, 65, 4, 218, + 2, 65, 255, 1, 86, 2, 179, 234, 4, 76, 2, 123, 65, 6, 110, 65, 86, 78, + 197, 232, 4, 3, 72, 65, 73, 4, 254, 149, 3, 72, 151, 246, 1, 65, 4, 26, + 65, 195, 149, 3, 72, 2, 11, 65, 2, 151, 233, 4, 70, 4, 18, 65, 35, 72, 2, + 11, 65, 2, 227, 232, 4, 77, 2, 211, 1, 65, 4, 176, 232, 4, 2, 79, 79, 191, 34, 65, 8, 32, 2, 65, 65, 18, 72, 23, 69, 2, 163, 16, 68, 4, 18, 69, - 87, 65, 2, 211, 225, 4, 69, 10, 62, 65, 16, 3, 72, 65, 65, 178, 144, 3, - 84, 183, 245, 1, 79, 2, 131, 1, 86, 5, 251, 224, 4, 76, 2, 17, 2, 65, 65, - 2, 211, 224, 4, 86, 6, 26, 65, 143, 133, 5, 79, 4, 26, 86, 243, 132, 5, - 65, 2, 21, 3, 73, 89, 65, 2, 255, 240, 4, 78, 6, 48, 3, 65, 66, 79, 14, - 66, 1, 3, 79, 66, 79, 2, 23, 65, 2, 11, 79, 2, 11, 70, 2, 11, 73, 2, 135, - 240, 4, 76, 2, 155, 131, 4, 75, 174, 1, 26, 67, 147, 143, 3, 68, 154, 1, - 132, 1, 9, 72, 65, 82, 65, 67, 84, 69, 82, 32, 213, 215, 4, 17, 85, 82, + 87, 65, 2, 195, 231, 4, 69, 10, 62, 65, 16, 3, 72, 65, 65, 138, 147, 3, + 84, 207, 248, 1, 79, 2, 131, 1, 86, 5, 235, 230, 4, 76, 2, 17, 2, 65, 65, + 2, 195, 230, 4, 86, 6, 26, 65, 255, 138, 5, 79, 4, 26, 86, 227, 138, 5, + 65, 2, 21, 3, 73, 89, 65, 2, 239, 246, 4, 78, 6, 48, 3, 65, 66, 79, 14, + 66, 1, 3, 79, 66, 79, 2, 23, 65, 2, 11, 79, 2, 11, 70, 2, 11, 73, 2, 247, + 245, 4, 76, 2, 139, 137, 4, 75, 174, 1, 26, 67, 235, 145, 3, 68, 154, 1, + 132, 1, 9, 72, 65, 82, 65, 67, 84, 69, 82, 32, 197, 221, 4, 17, 85, 82, 82, 69, 78, 67, 89, 32, 83, 89, 77, 66, 79, 76, 32, 66, 65, 152, 1, 176, 2, 6, 66, 79, 32, 66, 65, 73, 16, 6, 67, 72, 79, 32, 67, 72, 56, 3, 68, 79, 32, 44, 2, 70, 79, 76, 3, 72, 79, 32, 66, 75, 190, 1, 76, 138, 1, 77, 252, 1, 7, 65, 78, 71, 75, 72, 65, 78, 46, 78, 158, 1, 80, 234, 1, 82, - 70, 83, 238, 2, 84, 224, 2, 3, 87, 79, 32, 34, 89, 225, 150, 4, 2, 79, - 32, 2, 143, 12, 77, 8, 192, 129, 3, 2, 65, 78, 138, 173, 1, 73, 167, 58, - 79, 4, 132, 218, 4, 3, 67, 72, 65, 227, 33, 68, 6, 32, 2, 32, 70, 21, 2, - 78, 71, 4, 207, 128, 3, 65, 2, 139, 178, 3, 77, 4, 40, 4, 78, 79, 75, 72, - 191, 252, 4, 72, 2, 207, 250, 4, 85, 14, 40, 2, 72, 79, 229, 9, 3, 79, - 32, 75, 12, 26, 32, 191, 131, 4, 77, 10, 36, 2, 75, 72, 57, 3, 82, 65, - 75, 8, 158, 9, 87, 150, 234, 3, 85, 210, 57, 79, 139, 60, 65, 2, 215, - 163, 4, 72, 8, 76, 2, 79, 32, 224, 11, 8, 65, 75, 75, 72, 65, 78, 71, 89, - 235, 239, 4, 85, 4, 32, 2, 67, 72, 163, 170, 4, 76, 2, 139, 217, 4, 85, - 16, 28, 2, 65, 73, 211, 52, 79, 14, 42, 32, 176, 1, 3, 84, 65, 73, 19, - 89, 10, 76, 4, 67, 72, 65, 84, 44, 5, 72, 65, 78, 45, 65, 22, 84, 159, - 246, 4, 69, 2, 11, 84, 2, 11, 65, 2, 163, 247, 4, 87, 2, 151, 240, 3, 75, - 4, 190, 218, 4, 72, 159, 11, 82, 2, 203, 2, 75, 2, 161, 207, 4, 2, 65, + 70, 83, 238, 2, 84, 224, 2, 3, 87, 79, 32, 34, 89, 209, 156, 4, 2, 79, + 32, 2, 143, 12, 77, 8, 152, 132, 3, 2, 65, 78, 162, 176, 1, 73, 167, 58, + 79, 4, 244, 223, 4, 3, 67, 72, 65, 227, 33, 68, 6, 32, 2, 32, 70, 21, 2, + 78, 71, 4, 167, 131, 3, 65, 2, 131, 181, 3, 77, 4, 40, 4, 78, 79, 75, 72, + 175, 130, 5, 72, 2, 191, 128, 5, 85, 14, 40, 2, 72, 79, 229, 9, 3, 79, + 32, 75, 12, 26, 32, 175, 137, 4, 77, 10, 36, 2, 75, 72, 57, 3, 82, 65, + 75, 8, 158, 9, 87, 134, 240, 3, 85, 210, 57, 79, 139, 60, 65, 2, 199, + 169, 4, 72, 8, 76, 2, 79, 32, 224, 11, 8, 65, 75, 75, 72, 65, 78, 71, 89, + 219, 245, 4, 85, 4, 32, 2, 67, 72, 147, 176, 4, 76, 2, 251, 222, 4, 85, + 16, 28, 2, 65, 73, 215, 52, 79, 14, 42, 32, 176, 1, 3, 84, 65, 73, 19, + 89, 10, 76, 4, 67, 72, 65, 84, 44, 5, 72, 65, 78, 45, 65, 22, 84, 143, + 252, 4, 69, 2, 11, 84, 2, 11, 65, 2, 147, 253, 4, 87, 2, 135, 246, 3, 75, + 4, 174, 224, 4, 72, 159, 11, 82, 2, 203, 2, 75, 2, 145, 213, 4, 2, 65, 77, 8, 60, 3, 71, 79, 32, 32, 3, 73, 75, 72, 29, 3, 79, 32, 78, 2, 11, - 78, 2, 179, 211, 4, 71, 2, 205, 219, 4, 2, 65, 72, 4, 138, 168, 4, 69, - 227, 79, 85, 12, 68, 6, 65, 73, 89, 65, 78, 78, 22, 72, 217, 212, 4, 3, - 79, 32, 80, 2, 171, 227, 4, 79, 8, 36, 3, 73, 78, 84, 21, 2, 79, 32, 2, - 223, 209, 4, 72, 6, 44, 2, 80, 72, 161, 5, 4, 83, 65, 77, 80, 4, 138, - 165, 4, 85, 155, 1, 65, 4, 32, 2, 79, 32, 195, 245, 4, 85, 2, 11, 82, 2, - 251, 242, 4, 85, 36, 44, 4, 65, 82, 65, 32, 225, 1, 2, 79, 32, 28, 62, - 65, 130, 1, 85, 238, 230, 2, 73, 198, 140, 2, 69, 3, 79, 13, 64, 6, 73, - 32, 77, 65, 73, 77, 238, 243, 4, 65, 2, 69, 3, 77, 4, 26, 65, 183, 167, - 3, 85, 2, 11, 76, 2, 235, 223, 4, 65, 9, 142, 179, 4, 69, 163, 64, 85, 8, - 24, 2, 82, 85, 23, 83, 2, 155, 223, 4, 83, 6, 198, 208, 4, 65, 226, 31, + 78, 2, 163, 217, 4, 71, 2, 189, 225, 4, 2, 65, 72, 4, 250, 173, 4, 69, + 227, 79, 85, 12, 68, 6, 65, 73, 89, 65, 78, 78, 22, 72, 201, 218, 4, 3, + 79, 32, 80, 2, 155, 233, 4, 79, 8, 36, 3, 73, 78, 84, 21, 2, 79, 32, 2, + 207, 215, 4, 72, 6, 44, 2, 80, 72, 161, 5, 4, 83, 65, 77, 80, 4, 250, + 170, 4, 85, 155, 1, 65, 4, 32, 2, 79, 32, 179, 251, 4, 85, 2, 11, 82, 2, + 235, 248, 4, 85, 36, 44, 4, 65, 82, 65, 32, 225, 1, 2, 79, 32, 28, 62, + 65, 130, 1, 85, 190, 233, 2, 73, 230, 143, 2, 69, 3, 79, 13, 64, 6, 73, + 32, 77, 65, 73, 77, 222, 249, 4, 65, 2, 69, 3, 77, 4, 26, 65, 175, 170, + 3, 85, 2, 11, 76, 2, 219, 229, 4, 65, 9, 254, 184, 4, 69, 163, 64, 85, 8, + 24, 2, 82, 85, 23, 83, 2, 139, 229, 4, 83, 6, 182, 214, 4, 65, 226, 31, 85, 187, 2, 79, 18, 30, 72, 133, 2, 2, 79, 32, 14, 48, 6, 65, 78, 84, 72, - 65, 75, 21, 2, 79, 32, 2, 175, 232, 3, 72, 12, 80, 8, 78, 65, 78, 71, 77, - 79, 78, 84, 20, 4, 80, 72, 85, 84, 13, 2, 84, 72, 2, 131, 210, 4, 72, 2, - 123, 72, 8, 34, 65, 190, 159, 4, 79, 3, 85, 4, 150, 164, 3, 72, 159, 204, - 1, 78, 4, 38, 84, 225, 182, 2, 3, 80, 65, 84, 2, 243, 208, 4, 65, 2, 11, - 87, 2, 195, 153, 3, 65, 6, 30, 65, 45, 3, 79, 32, 89, 2, 21, 3, 77, 65, - 75, 2, 223, 162, 3, 75, 4, 238, 157, 4, 73, 227, 77, 65, 12, 26, 82, 167, - 199, 2, 84, 10, 30, 69, 145, 1, 2, 77, 79, 6, 18, 32, 107, 70, 4, 84, 11, - 68, 79, 69, 83, 32, 78, 79, 84, 32, 69, 88, 229, 228, 3, 4, 69, 88, 73, - 83, 2, 171, 127, 73, 2, 211, 202, 3, 79, 4, 46, 77, 177, 194, 3, 5, 68, - 89, 78, 65, 77, 2, 191, 178, 3, 69, 10, 18, 78, 95, 82, 8, 26, 32, 235, - 227, 3, 75, 6, 26, 83, 203, 224, 2, 71, 4, 170, 211, 2, 65, 187, 219, 1, - 80, 2, 21, 3, 68, 32, 80, 2, 25, 4, 76, 65, 67, 69, 2, 17, 2, 32, 77, 2, - 159, 213, 3, 69, 4, 56, 4, 85, 71, 72, 84, 189, 212, 3, 4, 78, 71, 32, - 83, 2, 133, 192, 1, 5, 32, 66, 65, 76, 76, 46, 22, 32, 207, 3, 45, 30, - 154, 1, 68, 90, 76, 118, 82, 170, 158, 1, 66, 86, 67, 194, 6, 83, 254, - 166, 1, 80, 253, 22, 15, 78, 69, 84, 87, 79, 82, 75, 69, 68, 32, 67, 79, - 77, 80, 85, 4, 64, 10, 73, 77, 69, 78, 83, 73, 79, 78, 65, 76, 135, 162, - 1, 79, 2, 175, 193, 3, 32, 6, 80, 12, 73, 78, 69, 83, 32, 67, 79, 78, 86, - 69, 82, 71, 249, 154, 1, 2, 69, 70, 4, 153, 188, 4, 3, 73, 78, 71, 10, - 40, 4, 65, 89, 83, 32, 155, 154, 1, 73, 8, 238, 196, 2, 66, 130, 165, 1, - 65, 130, 82, 76, 31, 82, 16, 44, 2, 68, 32, 254, 3, 80, 247, 160, 1, 69, - 12, 196, 2, 12, 84, 79, 80, 45, 76, 73, 71, 72, 84, 69, 68, 32, 80, 17, - 76, 69, 70, 84, 45, 76, 73, 71, 72, 84, 69, 68, 32, 68, 79, 87, 78, 0, - 16, 82, 73, 71, 72, 84, 45, 76, 73, 71, 72, 84, 69, 68, 32, 85, 80, 221, - 137, 2, 25, 66, 79, 84, 84, 79, 77, 45, 76, 73, 71, 72, 84, 69, 68, 32, - 82, 73, 71, 72, 84, 87, 65, 82, 68, 83, 6, 76, 4, 76, 69, 70, 84, 69, 11, - 82, 73, 71, 72, 84, 87, 65, 82, 68, 83, 32, 2, 11, 87, 2, 25, 4, 65, 82, - 68, 83, 2, 173, 243, 1, 2, 32, 69, 4, 146, 243, 1, 69, 159, 22, 65, 2, - 177, 163, 4, 5, 69, 82, 45, 69, 77, 8, 34, 77, 85, 4, 78, 68, 69, 82, 4, - 21, 3, 66, 83, 32, 4, 38, 85, 229, 228, 2, 3, 68, 79, 87, 2, 235, 217, 3, - 80, 4, 216, 177, 3, 10, 32, 67, 76, 79, 85, 68, 32, 65, 78, 68, 181, 48, - 2, 83, 84, 230, 5, 204, 1, 6, 66, 69, 84, 65, 78, 32, 148, 45, 6, 69, 32, - 79, 86, 69, 82, 72, 7, 70, 73, 78, 65, 71, 72, 32, 206, 8, 71, 152, 1, 3, - 76, 68, 69, 252, 2, 2, 77, 69, 60, 2, 78, 89, 78, 82, 171, 208, 3, 67, - 160, 3, 228, 2, 18, 65, 83, 84, 82, 79, 76, 79, 71, 73, 67, 65, 76, 32, - 83, 73, 71, 78, 32, 172, 1, 18, 67, 65, 78, 84, 73, 76, 76, 65, 84, 73, - 79, 78, 32, 83, 73, 71, 78, 32, 172, 1, 6, 68, 73, 71, 73, 84, 32, 100, - 9, 75, 85, 32, 82, 85, 32, 75, 72, 65, 26, 76, 176, 3, 5, 77, 65, 82, 75, - 32, 222, 18, 83, 181, 15, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, - 6, 46, 83, 169, 40, 6, 45, 75, 72, 89, 85, 68, 4, 104, 8, 68, 79, 78, 71, - 32, 84, 83, 72, 169, 21, 13, 71, 82, 65, 32, 71, 67, 65, 78, 32, 45, 67, - 72, 65, 2, 199, 31, 85, 8, 148, 1, 7, 83, 66, 85, 66, 32, 45, 67, 180, - 207, 3, 5, 72, 69, 65, 86, 89, 0, 5, 76, 73, 71, 72, 84, 233, 100, 8, 67, - 65, 78, 71, 32, 84, 69, 45, 2, 167, 205, 3, 72, 40, 144, 229, 2, 4, 72, - 65, 76, 70, 82, 70, 30, 83, 42, 84, 62, 90, 210, 86, 78, 14, 79, 227, - 112, 69, 5, 221, 10, 2, 32, 66, 92, 96, 6, 69, 84, 84, 69, 82, 32, 153, - 2, 13, 79, 71, 79, 84, 89, 80, 69, 32, 83, 73, 71, 78, 32, 88, 230, 1, - 75, 170, 120, 82, 168, 146, 3, 10, 70, 73, 88, 69, 68, 45, 70, 79, 82, - 77, 202, 1, 68, 86, 78, 46, 83, 38, 84, 46, 66, 2, 67, 2, 71, 2, 80, 2, - 90, 138, 69, 45, 2, 72, 2, 74, 2, 76, 2, 77, 2, 87, 2, 89, 187, 2, 65, 8, - 226, 210, 4, 83, 14, 72, 2, 75, 187, 2, 65, 4, 224, 25, 3, 76, 72, 65, - 13, 4, 67, 72, 65, 68, 80, 254, 2, 66, 176, 1, 8, 77, 78, 89, 65, 77, 32, - 89, 73, 114, 67, 172, 2, 13, 89, 73, 71, 32, 77, 71, 79, 32, 84, 83, 72, - 69, 71, 190, 1, 71, 212, 2, 9, 65, 78, 71, 32, 75, 72, 65, 78, 71, 58, - 72, 48, 2, 73, 78, 246, 1, 78, 222, 1, 82, 118, 83, 46, 84, 36, 4, 76, - 69, 65, 68, 220, 105, 2, 80, 65, 173, 191, 1, 17, 68, 69, 76, 73, 77, 73, - 84, 69, 82, 32, 84, 83, 72, 69, 71, 32, 66, 10, 52, 9, 75, 65, 45, 32, - 83, 72, 79, 71, 32, 27, 83, 4, 142, 1, 71, 67, 89, 6, 34, 75, 201, 21, 3, - 68, 85, 83, 4, 56, 6, 65, 45, 32, 83, 72, 79, 89, 4, 85, 82, 32, 89, 2, - 21, 3, 71, 32, 71, 2, 41, 8, 73, 32, 77, 71, 79, 32, 82, 71, 2, 179, 131, - 3, 89, 2, 221, 2, 2, 73, 71, 12, 84, 5, 65, 82, 69, 84, 32, 240, 1, 2, - 72, 69, 29, 7, 76, 79, 83, 73, 78, 71, 32, 6, 112, 12, 45, 68, 90, 85, - 68, 32, 82, 84, 65, 71, 83, 32, 97, 12, 89, 73, 71, 32, 77, 71, 79, 32, - 80, 72, 85, 82, 4, 42, 66, 37, 6, 77, 69, 32, 76, 79, 78, 2, 33, 6, 90, - 72, 73, 32, 77, 73, 2, 203, 22, 71, 2, 225, 3, 3, 32, 83, 72, 2, 137, - 189, 2, 2, 32, 77, 4, 68, 13, 66, 82, 68, 65, 32, 82, 78, 89, 73, 78, 71, - 32, 89, 3, 89, 2, 213, 5, 11, 73, 71, 32, 77, 71, 79, 32, 83, 71, 65, 66, - 12, 68, 4, 84, 69, 82, 32, 141, 2, 8, 85, 71, 32, 82, 84, 65, 71, 83, 8, - 56, 8, 89, 73, 71, 32, 77, 71, 79, 32, 191, 132, 4, 84, 6, 68, 4, 45, 85, - 77, 32, 117, 9, 84, 82, 85, 78, 67, 65, 84, 69, 68, 4, 88, 7, 82, 78, 65, - 77, 32, 66, 67, 245, 2, 10, 71, 84, 69, 82, 32, 84, 83, 72, 69, 71, 2, - 241, 2, 2, 65, 68, 2, 195, 198, 4, 32, 4, 21, 3, 32, 71, 89, 4, 238, 248, - 3, 79, 135, 18, 65, 2, 17, 2, 65, 76, 2, 205, 163, 4, 2, 65, 78, 6, 92, - 6, 73, 84, 73, 65, 76, 32, 145, 129, 4, 11, 84, 69, 82, 83, 89, 76, 76, - 65, 66, 73, 67, 4, 68, 13, 66, 82, 68, 65, 32, 82, 78, 89, 73, 78, 71, - 32, 89, 3, 89, 2, 53, 11, 73, 71, 32, 77, 71, 79, 32, 77, 68, 85, 78, 2, - 143, 165, 4, 32, 10, 72, 10, 71, 65, 83, 32, 66, 90, 85, 78, 71, 32, 77, - 4, 89, 73, 83, 32, 4, 56, 3, 83, 71, 79, 237, 162, 4, 5, 78, 89, 73, 32, - 90, 2, 251, 9, 82, 6, 44, 5, 84, 83, 72, 69, 71, 143, 254, 3, 83, 5, 255, - 253, 3, 32, 4, 220, 253, 3, 8, 71, 89, 65, 32, 71, 82, 65, 77, 1, 14, 73, - 78, 32, 67, 72, 69, 78, 32, 83, 80, 85, 78, 71, 83, 4, 232, 252, 3, 4, - 66, 82, 85, 76, 39, 72, 6, 32, 4, 82, 65, 73, 76, 55, 83, 2, 225, 7, 9, - 73, 78, 71, 32, 77, 67, 72, 65, 78, 4, 56, 5, 65, 32, 45, 80, 72, 173, - 251, 3, 3, 72, 69, 71, 2, 147, 157, 4, 82, 156, 1, 84, 4, 73, 71, 78, 32, - 228, 6, 9, 85, 66, 74, 79, 73, 78, 69, 68, 32, 143, 4, 89, 42, 176, 1, 4, - 71, 82, 85, 32, 96, 2, 76, 67, 30, 77, 36, 11, 78, 89, 73, 32, 90, 76, - 65, 32, 78, 65, 65, 22, 82, 252, 2, 2, 89, 65, 130, 4, 73, 165, 4, 5, 83, - 78, 65, 32, 76, 4, 40, 3, 67, 65, 78, 1, 3, 77, 69, 68, 2, 25, 4, 32, 82, - 71, 89, 2, 169, 4, 2, 73, 78, 4, 238, 3, 73, 179, 4, 69, 4, 136, 4, 2, - 65, 82, 231, 3, 67, 2, 179, 153, 4, 32, 20, 116, 4, 68, 69, 76, 32, 240, - 1, 10, 74, 69, 83, 32, 83, 85, 32, 78, 71, 65, 145, 245, 3, 6, 78, 65, - 77, 32, 66, 67, 16, 52, 5, 68, 75, 65, 82, 32, 53, 4, 78, 65, 71, 32, 8, - 94, 71, 169, 208, 2, 6, 82, 68, 69, 76, 32, 78, 8, 42, 71, 69, 6, 82, 68, - 69, 76, 32, 68, 6, 46, 67, 220, 148, 2, 2, 78, 89, 231, 123, 83, 2, 143, - 187, 4, 73, 2, 147, 152, 3, 75, 2, 187, 201, 2, 32, 4, 18, 78, 71, 82, 2, - 11, 71, 2, 21, 3, 32, 82, 84, 2, 11, 65, 2, 135, 253, 3, 71, 2, 17, 2, - 32, 84, 2, 171, 164, 3, 83, 94, 68, 7, 76, 69, 84, 84, 69, 82, 32, 145, - 2, 5, 83, 73, 71, 78, 32, 88, 220, 1, 10, 70, 73, 88, 69, 68, 45, 70, 79, - 82, 77, 242, 238, 3, 68, 50, 75, 38, 78, 46, 83, 38, 84, 46, 66, 2, 67, - 2, 71, 2, 80, 2, 90, 138, 69, 45, 2, 72, 2, 74, 2, 76, 2, 77, 2, 82, 2, - 87, 2, 89, 187, 2, 65, 6, 11, 32, 6, 186, 181, 4, 82, 2, 87, 3, 89, 6, - 38, 73, 50, 77, 33, 3, 76, 67, 69, 2, 45, 9, 78, 86, 69, 82, 84, 69, 68, - 32, 77, 2, 11, 67, 2, 45, 2, 72, 85, 2, 25, 4, 32, 84, 83, 65, 2, 11, 32, - 2, 147, 234, 2, 67, 20, 60, 6, 76, 76, 65, 66, 76, 69, 21, 5, 77, 66, 79, - 76, 32, 2, 247, 164, 4, 32, 18, 104, 4, 68, 82, 73, 76, 32, 6, 78, 79, - 82, 32, 66, 85, 130, 1, 80, 93, 7, 82, 68, 79, 32, 82, 74, 69, 2, 11, 32, - 2, 231, 143, 4, 66, 9, 11, 32, 6, 72, 4, 66, 90, 72, 73, 0, 4, 71, 83, - 85, 77, 1, 4, 78, 89, 73, 83, 2, 145, 212, 2, 5, 32, 45, 75, 72, 89, 4, - 52, 6, 65, 68, 77, 65, 32, 71, 21, 3, 72, 85, 82, 2, 231, 230, 2, 68, 2, - 199, 117, 32, 5, 181, 245, 2, 6, 32, 82, 71, 89, 65, 32, 30, 116, 8, 82, - 69, 86, 69, 82, 83, 69, 68, 194, 90, 85, 22, 86, 186, 141, 1, 79, 238, - 60, 73, 166, 204, 1, 69, 235, 61, 65, 4, 245, 164, 2, 2, 32, 73, 2, 25, - 4, 32, 73, 78, 70, 2, 11, 73, 2, 11, 78, 2, 139, 193, 2, 73, 118, 216, 1, - 9, 67, 79, 78, 83, 79, 78, 65, 78, 84, 20, 7, 76, 69, 84, 84, 69, 82, 32, - 164, 6, 20, 77, 79, 68, 73, 70, 73, 69, 82, 32, 76, 69, 84, 84, 69, 82, - 32, 76, 65, 66, 73, 37, 8, 83, 69, 80, 65, 82, 65, 84, 79, 2, 223, 240, - 3, 32, 112, 106, 65, 108, 17, 66, 69, 82, 66, 69, 82, 32, 65, 67, 65, 68, - 69, 77, 89, 32, 89, 65, 30, 84, 211, 1, 89, 4, 84, 6, 89, 69, 82, 32, 89, - 65, 137, 172, 4, 9, 72, 65, 71, 71, 65, 82, 32, 89, 65, 2, 147, 172, 4, - 71, 4, 142, 173, 4, 72, 3, 74, 18, 92, 11, 65, 87, 69, 76, 76, 69, 77, - 69, 84, 32, 89, 21, 8, 85, 65, 82, 69, 71, 32, 89, 65, 2, 235, 205, 2, - 65, 16, 62, 71, 226, 26, 75, 210, 143, 4, 90, 62, 78, 86, 72, 3, 81, 4, - 190, 171, 4, 72, 3, 78, 86, 54, 65, 210, 25, 69, 158, 145, 4, 73, 2, 79, - 3, 85, 77, 194, 1, 71, 2, 75, 18, 83, 30, 84, 30, 90, 134, 23, 68, 126, - 66, 2, 72, 198, 58, 82, 142, 213, 3, 67, 146, 1, 65, 2, 70, 2, 74, 2, 76, - 2, 77, 2, 78, 2, 80, 2, 81, 2, 86, 2, 87, 3, 89, 7, 199, 24, 72, 7, 150, - 169, 4, 72, 3, 83, 7, 250, 168, 4, 72, 3, 84, 7, 222, 168, 4, 72, 3, 90, - 2, 141, 191, 3, 4, 65, 76, 73, 90, 2, 219, 230, 3, 82, 6, 76, 2, 69, 82, - 21, 13, 72, 84, 32, 84, 82, 73, 70, 79, 76, 73, 65, 84, 69, 5, 167, 234, - 3, 32, 2, 33, 6, 32, 83, 78, 79, 87, 70, 2, 219, 58, 76, 19, 11, 32, 16, - 72, 8, 79, 80, 69, 82, 65, 84, 79, 82, 233, 1, 5, 87, 73, 84, 72, 32, 11, - 11, 32, 8, 38, 65, 101, 5, 87, 73, 84, 72, 32, 4, 25, 4, 66, 79, 86, 69, - 4, 11, 32, 4, 26, 76, 171, 131, 3, 82, 2, 11, 69, 2, 179, 131, 3, 70, 4, - 26, 82, 159, 164, 3, 68, 2, 17, 2, 73, 83, 2, 249, 209, 2, 3, 73, 78, 71, - 6, 26, 68, 223, 239, 1, 82, 4, 11, 79, 4, 247, 129, 2, 84, 6, 26, 82, - 187, 131, 1, 83, 2, 11, 32, 2, 195, 177, 1, 67, 5, 21, 3, 32, 84, 87, 2, - 21, 3, 79, 32, 68, 2, 185, 92, 3, 79, 84, 83, 170, 1, 100, 5, 72, 85, 84, - 65, 32, 184, 6, 11, 79, 78, 73, 65, 78, 32, 83, 73, 71, 78, 32, 231, 136, - 3, 69, 164, 1, 178, 1, 65, 88, 7, 76, 69, 84, 84, 69, 82, 32, 204, 1, 2, - 83, 73, 200, 1, 11, 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 218, 168, - 2, 68, 180, 155, 1, 2, 71, 86, 255, 71, 79, 4, 18, 66, 51, 78, 2, 29, 5, - 66, 82, 69, 86, 73, 2, 247, 26, 65, 2, 175, 140, 4, 74, 94, 254, 65, 65, - 38, 68, 114, 84, 46, 86, 186, 5, 85, 186, 202, 1, 73, 138, 196, 1, 78, - 46, 83, 82, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 138, 69, 72, 2, 76, 2, - 77, 2, 82, 2, 89, 186, 2, 69, 3, 79, 12, 21, 3, 71, 78, 32, 12, 46, 67, - 98, 78, 190, 66, 65, 187, 151, 3, 86, 2, 11, 65, 2, 11, 78, 2, 25, 4, 68, - 82, 65, 66, 2, 11, 73, 2, 11, 78, 2, 171, 248, 3, 68, 2, 11, 85, 2, 167, - 248, 3, 75, 30, 78, 83, 242, 68, 65, 38, 85, 22, 86, 166, 202, 1, 73, - 198, 140, 2, 69, 3, 79, 4, 25, 4, 72, 79, 82, 84, 4, 11, 32, 4, 230, 155, - 4, 69, 3, 79, 4, 176, 230, 3, 8, 67, 65, 80, 73, 84, 65, 76, 32, 239, 24, - 69, 254, 2, 192, 2, 12, 68, 72, 82, 73, 32, 76, 69, 84, 84, 69, 82, 32, - 180, 4, 10, 76, 79, 78, 71, 32, 83, 73, 75, 73, 32, 154, 4, 77, 18, 78, - 34, 79, 80, 2, 80, 32, 168, 17, 23, 82, 84, 79, 73, 83, 69, 32, 83, 72, - 69, 76, 76, 32, 66, 82, 65, 67, 75, 69, 84, 69, 68, 32, 130, 4, 84, 202, - 151, 2, 73, 249, 70, 5, 75, 89, 79, 32, 84, 104, 242, 1, 71, 42, 74, 30, - 77, 34, 78, 70, 72, 34, 80, 34, 83, 234, 55, 82, 210, 147, 1, 79, 238, - 60, 69, 42, 76, 198, 2, 65, 154, 194, 1, 67, 2, 68, 2, 75, 2, 84, 2, 88, - 2, 90, 138, 69, 66, 2, 70, 2, 81, 2, 86, 186, 2, 73, 2, 85, 3, 89, 6, - 150, 148, 4, 72, 2, 74, 187, 2, 65, 4, 166, 150, 4, 65, 3, 89, 4, 210, - 147, 4, 66, 187, 2, 65, 14, 66, 71, 142, 201, 2, 74, 222, 132, 1, 88, - 138, 69, 68, 187, 2, 65, 4, 238, 146, 4, 74, 187, 2, 65, 4, 206, 146, 4, - 83, 187, 2, 65, 10, 54, 72, 150, 200, 2, 75, 230, 201, 1, 84, 187, 2, 65, - 4, 246, 145, 4, 84, 187, 2, 65, 108, 92, 7, 76, 69, 84, 84, 69, 82, 32, - 228, 2, 5, 83, 73, 71, 78, 32, 58, 85, 143, 156, 2, 68, 82, 190, 1, 65, - 22, 68, 30, 78, 58, 82, 14, 84, 30, 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, - 80, 226, 144, 4, 69, 2, 72, 2, 73, 2, 76, 2, 77, 2, 79, 2, 83, 2, 85, 2, - 86, 2, 88, 3, 89, 5, 239, 145, 4, 65, 9, 122, 68, 227, 144, 4, 72, 11, - 34, 78, 158, 145, 4, 71, 3, 89, 5, 155, 145, 4, 89, 7, 39, 82, 9, 26, 84, - 227, 144, 4, 72, 5, 223, 144, 4, 72, 4, 176, 238, 3, 2, 83, 69, 177, 25, - 4, 72, 69, 67, 65, 2, 205, 205, 3, 2, 78, 71, 2, 239, 28, 65, 2, 11, 71, - 2, 135, 249, 3, 85, 6, 32, 2, 84, 72, 207, 128, 3, 76, 5, 11, 66, 2, 11, - 82, 2, 131, 164, 2, 85, 72, 252, 1, 4, 65, 82, 67, 32, 162, 2, 67, 44, 2, - 72, 65, 166, 3, 80, 140, 3, 13, 74, 85, 83, 84, 73, 70, 73, 69, 68, 32, - 76, 79, 87, 84, 5, 76, 69, 70, 84, 32, 228, 1, 6, 82, 73, 71, 72, 84, 32, - 170, 2, 83, 38, 84, 81, 7, 87, 73, 84, 72, 32, 85, 80, 6, 180, 1, 19, 65, + 65, 75, 21, 2, 79, 32, 2, 159, 238, 3, 72, 12, 80, 8, 78, 65, 78, 71, 77, + 79, 78, 84, 20, 4, 80, 72, 85, 84, 13, 2, 84, 72, 2, 243, 215, 4, 72, 2, + 123, 72, 8, 34, 65, 174, 165, 4, 79, 3, 85, 4, 142, 167, 3, 72, 151, 207, + 1, 78, 4, 38, 84, 213, 184, 2, 3, 80, 65, 84, 2, 227, 214, 4, 65, 2, 11, + 87, 2, 163, 156, 3, 65, 6, 30, 65, 45, 3, 79, 32, 89, 2, 21, 3, 77, 65, + 75, 2, 215, 165, 3, 75, 4, 222, 163, 4, 73, 227, 77, 65, 12, 26, 82, 227, + 201, 2, 84, 10, 30, 69, 149, 1, 2, 77, 79, 6, 18, 32, 111, 70, 4, 84, 11, + 68, 79, 69, 83, 32, 78, 79, 84, 32, 69, 88, 213, 234, 3, 4, 69, 88, 73, + 83, 2, 171, 128, 1, 73, 2, 255, 207, 3, 79, 4, 46, 77, 221, 199, 3, 5, + 68, 89, 78, 65, 77, 2, 167, 181, 3, 69, 10, 18, 78, 95, 82, 8, 26, 32, + 215, 233, 3, 75, 6, 26, 83, 151, 227, 2, 71, 4, 246, 213, 2, 65, 219, + 222, 1, 80, 2, 21, 3, 68, 32, 80, 2, 25, 4, 76, 65, 67, 69, 2, 17, 2, 32, + 77, 2, 139, 219, 3, 69, 4, 56, 4, 85, 71, 72, 84, 169, 218, 3, 4, 78, 71, + 32, 83, 2, 233, 193, 1, 5, 32, 66, 65, 76, 76, 46, 22, 32, 207, 3, 45, + 30, 154, 1, 68, 90, 76, 118, 82, 158, 159, 1, 66, 86, 67, 194, 6, 83, + 214, 168, 1, 80, 133, 23, 15, 78, 69, 84, 87, 79, 82, 75, 69, 68, 32, 67, + 79, 77, 80, 85, 4, 64, 10, 73, 77, 69, 78, 83, 73, 79, 78, 65, 76, 251, + 162, 1, 79, 2, 219, 198, 3, 32, 6, 80, 12, 73, 78, 69, 83, 32, 67, 79, + 78, 86, 69, 82, 71, 245, 155, 1, 2, 69, 70, 4, 133, 194, 4, 3, 73, 78, + 71, 10, 40, 4, 65, 89, 83, 32, 151, 155, 1, 73, 8, 186, 199, 2, 66, 162, + 168, 1, 65, 130, 82, 76, 31, 82, 16, 44, 2, 68, 32, 254, 3, 80, 151, 162, + 1, 69, 12, 196, 2, 12, 84, 79, 80, 45, 76, 73, 71, 72, 84, 69, 68, 32, + 80, 17, 76, 69, 70, 84, 45, 76, 73, 71, 72, 84, 69, 68, 32, 68, 79, 87, + 78, 0, 16, 82, 73, 71, 72, 84, 45, 76, 73, 71, 72, 84, 69, 68, 32, 85, + 80, 205, 139, 2, 25, 66, 79, 84, 84, 79, 77, 45, 76, 73, 71, 72, 84, 69, + 68, 32, 82, 73, 71, 72, 84, 87, 65, 82, 68, 83, 6, 76, 4, 76, 69, 70, 84, + 69, 11, 82, 73, 71, 72, 84, 87, 65, 82, 68, 83, 32, 2, 11, 87, 2, 25, 4, + 65, 82, 68, 83, 2, 157, 245, 1, 2, 32, 69, 4, 130, 245, 1, 69, 159, 22, + 65, 2, 157, 169, 4, 5, 69, 82, 45, 69, 77, 8, 34, 77, 85, 4, 78, 68, 69, + 82, 4, 21, 3, 66, 83, 32, 4, 38, 85, 185, 231, 2, 3, 68, 79, 87, 2, 215, + 223, 3, 80, 4, 132, 183, 3, 10, 32, 67, 76, 79, 85, 68, 32, 65, 78, 68, + 245, 48, 2, 83, 84, 230, 5, 204, 1, 6, 66, 69, 84, 65, 78, 32, 148, 45, + 6, 69, 32, 79, 86, 69, 82, 72, 7, 70, 73, 78, 65, 71, 72, 32, 206, 8, 71, + 152, 1, 3, 76, 68, 69, 252, 2, 2, 77, 69, 60, 2, 78, 89, 78, 82, 151, + 214, 3, 67, 160, 3, 228, 2, 18, 65, 83, 84, 82, 79, 76, 79, 71, 73, 67, + 65, 76, 32, 83, 73, 71, 78, 32, 172, 1, 18, 67, 65, 78, 84, 73, 76, 76, + 65, 84, 73, 79, 78, 32, 83, 73, 71, 78, 32, 172, 1, 6, 68, 73, 71, 73, + 84, 32, 100, 9, 75, 85, 32, 82, 85, 32, 75, 72, 65, 26, 76, 176, 3, 5, + 77, 65, 82, 75, 32, 222, 18, 83, 181, 15, 11, 86, 79, 87, 69, 76, 32, 83, + 73, 71, 78, 32, 6, 46, 83, 169, 40, 6, 45, 75, 72, 89, 85, 68, 4, 104, 8, + 68, 79, 78, 71, 32, 84, 83, 72, 169, 21, 13, 71, 82, 65, 32, 71, 67, 65, + 78, 32, 45, 67, 72, 65, 2, 199, 31, 85, 8, 148, 1, 7, 83, 66, 85, 66, 32, + 45, 67, 160, 213, 3, 5, 72, 69, 65, 86, 89, 0, 5, 76, 73, 71, 72, 84, + 233, 100, 8, 67, 65, 78, 71, 32, 84, 69, 45, 2, 147, 211, 3, 72, 40, 228, + 231, 2, 4, 72, 65, 76, 70, 82, 70, 30, 83, 42, 84, 62, 90, 234, 89, 78, + 14, 79, 227, 112, 69, 5, 221, 10, 2, 32, 66, 92, 96, 6, 69, 84, 84, 69, + 82, 32, 153, 2, 13, 79, 71, 79, 84, 89, 80, 69, 32, 83, 73, 71, 78, 32, + 88, 230, 1, 75, 166, 121, 82, 152, 151, 3, 10, 70, 73, 88, 69, 68, 45, + 70, 79, 82, 77, 202, 1, 68, 86, 78, 46, 83, 38, 84, 46, 66, 2, 67, 2, 71, + 2, 80, 2, 90, 138, 69, 45, 2, 72, 2, 74, 2, 76, 2, 77, 2, 87, 2, 89, 187, + 2, 65, 8, 206, 216, 4, 83, 14, 72, 2, 75, 187, 2, 65, 4, 224, 25, 3, 76, + 72, 65, 13, 4, 67, 72, 65, 68, 80, 254, 2, 66, 176, 1, 8, 77, 78, 89, 65, + 77, 32, 89, 73, 114, 67, 172, 2, 13, 89, 73, 71, 32, 77, 71, 79, 32, 84, + 83, 72, 69, 71, 190, 1, 71, 212, 2, 9, 65, 78, 71, 32, 75, 72, 65, 78, + 71, 58, 72, 48, 2, 73, 78, 246, 1, 78, 222, 1, 82, 118, 83, 46, 84, 36, + 4, 76, 69, 65, 68, 216, 106, 2, 80, 65, 253, 192, 1, 17, 68, 69, 76, 73, + 77, 73, 84, 69, 82, 32, 84, 83, 72, 69, 71, 32, 66, 10, 52, 9, 75, 65, + 45, 32, 83, 72, 79, 71, 32, 27, 83, 4, 142, 1, 71, 67, 89, 6, 34, 75, + 201, 21, 3, 68, 85, 83, 4, 56, 6, 65, 45, 32, 83, 72, 79, 89, 4, 85, 82, + 32, 89, 2, 21, 3, 71, 32, 71, 2, 41, 8, 73, 32, 77, 71, 79, 32, 82, 71, + 2, 167, 134, 3, 89, 2, 221, 2, 2, 73, 71, 12, 84, 5, 65, 82, 69, 84, 32, + 240, 1, 2, 72, 69, 29, 7, 76, 79, 83, 73, 78, 71, 32, 6, 112, 12, 45, 68, + 90, 85, 68, 32, 82, 84, 65, 71, 83, 32, 97, 12, 89, 73, 71, 32, 77, 71, + 79, 32, 80, 72, 85, 82, 4, 42, 66, 37, 6, 77, 69, 32, 76, 79, 78, 2, 33, + 6, 90, 72, 73, 32, 77, 73, 2, 203, 22, 71, 2, 225, 3, 3, 32, 83, 72, 2, + 213, 191, 2, 2, 32, 77, 4, 68, 13, 66, 82, 68, 65, 32, 82, 78, 89, 73, + 78, 71, 32, 89, 3, 89, 2, 213, 5, 11, 73, 71, 32, 77, 71, 79, 32, 83, 71, + 65, 66, 12, 68, 4, 84, 69, 82, 32, 141, 2, 8, 85, 71, 32, 82, 84, 65, 71, + 83, 8, 56, 8, 89, 73, 71, 32, 77, 71, 79, 32, 171, 138, 4, 84, 6, 68, 4, + 45, 85, 77, 32, 117, 9, 84, 82, 85, 78, 67, 65, 84, 69, 68, 4, 88, 7, 82, + 78, 65, 77, 32, 66, 67, 245, 2, 10, 71, 84, 69, 82, 32, 84, 83, 72, 69, + 71, 2, 241, 2, 2, 65, 68, 2, 175, 204, 4, 32, 4, 21, 3, 32, 71, 89, 4, + 218, 254, 3, 79, 135, 18, 65, 2, 17, 2, 65, 76, 2, 185, 169, 4, 2, 65, + 78, 6, 92, 6, 73, 84, 73, 65, 76, 32, 253, 134, 4, 11, 84, 69, 82, 83, + 89, 76, 76, 65, 66, 73, 67, 4, 68, 13, 66, 82, 68, 65, 32, 82, 78, 89, + 73, 78, 71, 32, 89, 3, 89, 2, 53, 11, 73, 71, 32, 77, 71, 79, 32, 77, 68, + 85, 78, 2, 251, 170, 4, 32, 10, 72, 10, 71, 65, 83, 32, 66, 90, 85, 78, + 71, 32, 77, 4, 89, 73, 83, 32, 4, 56, 3, 83, 71, 79, 217, 168, 4, 5, 78, + 89, 73, 32, 90, 2, 251, 9, 82, 6, 44, 5, 84, 83, 72, 69, 71, 251, 131, 4, + 83, 5, 235, 131, 4, 32, 4, 200, 131, 4, 8, 71, 89, 65, 32, 71, 82, 65, + 77, 1, 14, 73, 78, 32, 67, 72, 69, 78, 32, 83, 80, 85, 78, 71, 83, 4, + 212, 130, 4, 4, 66, 82, 85, 76, 39, 72, 6, 32, 4, 82, 65, 73, 76, 55, 83, + 2, 225, 7, 9, 73, 78, 71, 32, 77, 67, 72, 65, 78, 4, 56, 5, 65, 32, 45, + 80, 72, 153, 129, 4, 3, 72, 69, 71, 2, 255, 162, 4, 82, 156, 1, 84, 4, + 73, 71, 78, 32, 228, 6, 9, 85, 66, 74, 79, 73, 78, 69, 68, 32, 143, 4, + 89, 42, 176, 1, 4, 71, 82, 85, 32, 96, 2, 76, 67, 30, 77, 36, 11, 78, 89, + 73, 32, 90, 76, 65, 32, 78, 65, 65, 22, 82, 252, 2, 2, 89, 65, 130, 4, + 73, 165, 4, 5, 83, 78, 65, 32, 76, 4, 40, 3, 67, 65, 78, 1, 3, 77, 69, + 68, 2, 25, 4, 32, 82, 71, 89, 2, 169, 4, 2, 73, 78, 4, 238, 3, 73, 179, + 4, 69, 4, 136, 4, 2, 65, 82, 231, 3, 67, 2, 159, 159, 4, 32, 20, 116, 4, + 68, 69, 76, 32, 240, 1, 10, 74, 69, 83, 32, 83, 85, 32, 78, 71, 65, 253, + 250, 3, 6, 78, 65, 77, 32, 66, 67, 16, 52, 5, 68, 75, 65, 82, 32, 53, 4, + 78, 65, 71, 32, 8, 94, 71, 253, 210, 2, 6, 82, 68, 69, 76, 32, 78, 8, 42, + 71, 69, 6, 82, 68, 69, 76, 32, 68, 6, 46, 67, 148, 151, 2, 2, 78, 89, + 219, 126, 83, 2, 251, 192, 4, 73, 2, 191, 157, 3, 75, 2, 143, 204, 2, 32, + 4, 18, 78, 71, 82, 2, 11, 71, 2, 21, 3, 32, 82, 84, 2, 11, 65, 2, 243, + 130, 4, 71, 2, 17, 2, 32, 84, 2, 151, 170, 3, 83, 94, 68, 7, 76, 69, 84, + 84, 69, 82, 32, 145, 2, 5, 83, 73, 71, 78, 32, 88, 220, 1, 10, 70, 73, + 88, 69, 68, 45, 70, 79, 82, 77, 222, 244, 3, 68, 50, 75, 38, 78, 46, 83, + 38, 84, 46, 66, 2, 67, 2, 71, 2, 80, 2, 90, 138, 69, 45, 2, 72, 2, 74, 2, + 76, 2, 77, 2, 82, 2, 87, 2, 89, 187, 2, 65, 6, 11, 32, 6, 166, 187, 4, + 82, 2, 87, 3, 89, 6, 38, 73, 50, 77, 33, 3, 76, 67, 69, 2, 45, 9, 78, 86, + 69, 82, 84, 69, 68, 32, 77, 2, 11, 67, 2, 45, 2, 72, 85, 2, 25, 4, 32, + 84, 83, 65, 2, 11, 32, 2, 135, 237, 2, 67, 20, 60, 6, 76, 76, 65, 66, 76, + 69, 21, 5, 77, 66, 79, 76, 32, 2, 227, 170, 4, 32, 18, 104, 4, 68, 82, + 73, 76, 32, 6, 78, 79, 82, 32, 66, 85, 130, 1, 80, 93, 7, 82, 68, 79, 32, + 82, 74, 69, 2, 11, 32, 2, 211, 149, 4, 66, 9, 11, 32, 6, 72, 4, 66, 90, + 72, 73, 0, 4, 71, 83, 85, 77, 1, 4, 78, 89, 73, 83, 2, 237, 214, 2, 5, + 32, 45, 75, 72, 89, 4, 52, 6, 65, 68, 77, 65, 32, 71, 21, 3, 72, 85, 82, + 2, 219, 233, 2, 68, 2, 171, 119, 32, 5, 157, 248, 2, 6, 32, 82, 71, 89, + 65, 32, 30, 116, 8, 82, 69, 86, 69, 82, 83, 69, 68, 190, 91, 85, 22, 86, + 174, 142, 1, 79, 202, 61, 73, 198, 207, 1, 69, 235, 61, 65, 4, 193, 167, + 2, 2, 32, 73, 2, 25, 4, 32, 73, 78, 70, 2, 11, 73, 2, 11, 78, 2, 223, + 195, 2, 73, 118, 216, 1, 9, 67, 79, 78, 83, 79, 78, 65, 78, 84, 20, 7, + 76, 69, 84, 84, 69, 82, 32, 164, 6, 20, 77, 79, 68, 73, 70, 73, 69, 82, + 32, 76, 69, 84, 84, 69, 82, 32, 76, 65, 66, 73, 37, 8, 83, 69, 80, 65, + 82, 65, 84, 79, 2, 203, 246, 3, 32, 112, 106, 65, 108, 17, 66, 69, 82, + 66, 69, 82, 32, 65, 67, 65, 68, 69, 77, 89, 32, 89, 65, 30, 84, 211, 1, + 89, 4, 84, 6, 89, 69, 82, 32, 89, 65, 245, 177, 4, 9, 72, 65, 71, 71, 65, + 82, 32, 89, 65, 2, 255, 177, 4, 71, 4, 250, 178, 4, 72, 3, 74, 18, 92, + 11, 65, 87, 69, 76, 76, 69, 77, 69, 84, 32, 89, 21, 8, 85, 65, 82, 69, + 71, 32, 89, 65, 2, 199, 208, 2, 65, 16, 62, 71, 214, 26, 75, 202, 149, 4, + 90, 62, 78, 86, 72, 3, 81, 4, 170, 177, 4, 72, 3, 78, 86, 54, 65, 198, + 25, 69, 150, 151, 4, 73, 2, 79, 3, 85, 77, 194, 1, 71, 2, 75, 18, 83, 30, + 84, 30, 90, 250, 22, 68, 126, 66, 2, 72, 206, 59, 82, 254, 217, 3, 67, + 146, 1, 65, 2, 70, 2, 74, 2, 76, 2, 77, 2, 78, 2, 80, 2, 81, 2, 86, 2, + 87, 3, 89, 7, 187, 24, 72, 7, 130, 175, 4, 72, 3, 83, 7, 230, 174, 4, 72, + 3, 84, 7, 202, 174, 4, 72, 3, 90, 2, 249, 196, 3, 4, 65, 76, 73, 90, 2, + 199, 236, 3, 82, 6, 76, 2, 69, 82, 21, 13, 72, 84, 32, 84, 82, 73, 70, + 79, 76, 73, 65, 84, 69, 5, 147, 240, 3, 32, 2, 33, 6, 32, 83, 78, 79, 87, + 70, 2, 215, 59, 76, 19, 11, 32, 16, 72, 8, 79, 80, 69, 82, 65, 84, 79, + 82, 233, 1, 5, 87, 73, 84, 72, 32, 11, 11, 32, 8, 38, 65, 101, 5, 87, 73, + 84, 72, 32, 4, 25, 4, 66, 79, 86, 69, 4, 11, 32, 4, 26, 76, 215, 136, 3, + 82, 2, 11, 69, 2, 223, 136, 3, 70, 4, 26, 82, 139, 170, 3, 68, 2, 17, 2, + 73, 83, 2, 213, 212, 2, 3, 73, 78, 71, 6, 26, 68, 207, 241, 1, 82, 4, 11, + 79, 4, 195, 132, 2, 84, 6, 26, 82, 171, 133, 1, 83, 2, 11, 32, 2, 179, + 179, 1, 67, 5, 21, 3, 32, 84, 87, 2, 21, 3, 79, 32, 68, 2, 173, 93, 3, + 79, 84, 83, 170, 1, 100, 5, 72, 85, 84, 65, 32, 172, 6, 11, 79, 78, 73, + 65, 78, 32, 83, 73, 71, 78, 32, 223, 142, 3, 69, 164, 1, 190, 1, 65, 88, + 7, 76, 69, 84, 84, 69, 82, 32, 204, 1, 5, 83, 73, 71, 78, 32, 176, 1, 11, + 86, 79, 87, 69, 76, 32, 83, 73, 71, 78, 32, 186, 171, 2, 68, 204, 158, 1, + 2, 71, 86, 255, 71, 79, 4, 18, 66, 51, 78, 2, 29, 5, 66, 82, 69, 86, 73, + 2, 139, 27, 65, 2, 143, 146, 4, 74, 94, 238, 66, 65, 38, 68, 114, 84, 46, + 86, 186, 5, 85, 138, 204, 1, 73, 170, 199, 1, 78, 46, 83, 82, 66, 2, 67, + 2, 71, 2, 74, 2, 75, 2, 80, 138, 69, 72, 2, 76, 2, 77, 2, 82, 2, 89, 186, + 2, 69, 3, 79, 12, 46, 67, 98, 78, 198, 67, 65, 171, 156, 3, 86, 2, 11, + 65, 2, 11, 78, 2, 25, 4, 68, 82, 65, 66, 2, 11, 73, 2, 11, 78, 2, 163, + 254, 3, 68, 2, 11, 85, 2, 159, 254, 3, 75, 30, 78, 83, 250, 69, 65, 38, + 85, 22, 86, 246, 203, 1, 73, 230, 143, 2, 69, 3, 79, 4, 25, 4, 72, 79, + 82, 84, 4, 11, 32, 4, 222, 161, 4, 69, 3, 79, 4, 168, 236, 3, 8, 67, 65, + 80, 73, 84, 65, 76, 32, 239, 24, 69, 128, 3, 192, 2, 12, 68, 72, 82, 73, + 32, 76, 69, 84, 84, 69, 82, 32, 180, 4, 10, 76, 79, 78, 71, 32, 83, 73, + 75, 73, 32, 154, 4, 77, 62, 78, 34, 79, 80, 2, 80, 32, 180, 17, 23, 82, + 84, 79, 73, 83, 69, 32, 83, 72, 69, 76, 76, 32, 66, 82, 65, 67, 75, 69, + 84, 69, 68, 32, 138, 4, 84, 234, 153, 2, 73, 145, 74, 5, 75, 89, 79, 32, + 84, 104, 242, 1, 71, 42, 74, 30, 77, 34, 78, 70, 72, 34, 80, 34, 83, 242, + 56, 82, 198, 148, 1, 79, 202, 61, 69, 42, 76, 206, 2, 65, 178, 197, 1, + 67, 2, 68, 2, 75, 2, 84, 2, 88, 2, 90, 138, 69, 66, 2, 70, 2, 81, 2, 86, + 186, 2, 73, 2, 85, 3, 89, 6, 142, 154, 4, 72, 2, 74, 187, 2, 65, 4, 158, + 156, 4, 65, 3, 89, 4, 202, 153, 4, 66, 187, 2, 65, 14, 66, 71, 142, 204, + 2, 74, 214, 135, 1, 88, 138, 69, 68, 187, 2, 65, 4, 230, 152, 4, 74, 187, + 2, 65, 4, 198, 152, 4, 83, 187, 2, 65, 10, 54, 72, 150, 203, 2, 75, 222, + 204, 1, 84, 187, 2, 65, 4, 238, 151, 4, 84, 187, 2, 65, 108, 92, 7, 76, + 69, 84, 84, 69, 82, 32, 228, 2, 5, 83, 73, 71, 78, 32, 58, 85, 239, 158, + 2, 68, 82, 190, 1, 65, 22, 68, 30, 78, 58, 82, 14, 84, 30, 66, 2, 67, 2, + 71, 2, 74, 2, 75, 2, 80, 218, 150, 4, 69, 2, 72, 2, 73, 2, 76, 2, 77, 2, + 79, 2, 83, 2, 85, 2, 86, 2, 88, 3, 89, 5, 231, 151, 4, 65, 9, 122, 68, + 219, 150, 4, 72, 11, 34, 78, 150, 151, 4, 71, 3, 89, 5, 147, 151, 4, 89, + 7, 39, 82, 9, 26, 84, 219, 150, 4, 72, 5, 215, 150, 4, 72, 4, 168, 244, + 3, 2, 83, 69, 177, 25, 4, 72, 69, 67, 65, 2, 197, 211, 3, 2, 78, 71, 4, + 36, 4, 79, 66, 73, 75, 199, 29, 65, 2, 131, 128, 3, 73, 2, 11, 71, 2, + 211, 254, 3, 85, 6, 32, 2, 84, 72, 155, 134, 3, 76, 5, 11, 66, 2, 11, 82, + 2, 183, 166, 2, 85, 72, 252, 1, 4, 65, 82, 67, 32, 162, 2, 67, 44, 2, 72, + 65, 166, 3, 80, 140, 3, 13, 74, 85, 83, 84, 73, 70, 73, 69, 68, 32, 76, + 79, 87, 84, 5, 76, 69, 70, 84, 32, 228, 1, 6, 82, 73, 71, 72, 84, 32, + 182, 2, 83, 38, 84, 81, 7, 87, 73, 84, 72, 32, 85, 80, 6, 180, 1, 19, 65, 78, 84, 73, 67, 76, 79, 67, 75, 87, 73, 83, 69, 32, 65, 82, 82, 79, 87, 73, 21, 67, 76, 79, 67, 75, 87, 73, 83, 69, 32, 65, 82, 82, 79, 87, 32, 87, 73, 84, 72, 32, 5, 29, 5, 32, 87, 73, 84, 72, 2, 17, 2, 32, 80, 2, - 167, 130, 2, 76, 2, 11, 77, 2, 251, 129, 2, 73, 2, 11, 85, 2, 217, 183, - 3, 3, 82, 76, 89, 34, 36, 3, 76, 70, 32, 135, 138, 4, 84, 32, 70, 70, - 186, 1, 76, 22, 82, 178, 2, 83, 250, 5, 66, 211, 245, 1, 73, 8, 136, 1, + 219, 132, 2, 76, 2, 11, 77, 2, 175, 132, 2, 73, 2, 11, 85, 2, 165, 189, + 3, 3, 82, 76, 89, 34, 36, 3, 76, 70, 32, 211, 143, 4, 84, 32, 70, 70, + 186, 1, 76, 22, 82, 178, 2, 83, 134, 6, 66, 247, 247, 1, 73, 8, 136, 1, 15, 79, 82, 87, 65, 82, 68, 45, 70, 65, 67, 73, 78, 71, 32, 82, 157, 2, 13, 76, 65, 73, 76, 73, 78, 71, 32, 82, 79, 66, 79, 84, 4, 22, 85, 243, - 1, 79, 2, 159, 202, 3, 78, 8, 41, 2, 69, 70, 8, 21, 3, 73, 71, 72, 8, 11, + 1, 79, 2, 235, 207, 3, 78, 8, 41, 2, 69, 70, 8, 21, 3, 73, 71, 72, 8, 11, 84, 8, 54, 32, 69, 9, 45, 70, 65, 67, 73, 78, 71, 32, 82, 2, 11, 80, 2, - 33, 6, 65, 82, 69, 78, 84, 72, 2, 207, 223, 1, 69, 6, 38, 79, 21, 5, 85, - 78, 78, 69, 82, 2, 239, 181, 3, 66, 4, 29, 5, 32, 70, 82, 65, 77, 4, 11, - 69, 4, 11, 45, 4, 218, 133, 4, 49, 3, 50, 4, 18, 69, 59, 84, 2, 11, 67, - 2, 11, 84, 2, 11, 73, 2, 255, 136, 2, 79, 2, 17, 2, 65, 78, 2, 11, 68, 2, - 21, 3, 73, 78, 71, 2, 17, 2, 32, 80, 2, 11, 69, 2, 11, 82, 2, 163, 180, - 3, 83, 4, 17, 2, 69, 82, 4, 33, 6, 32, 72, 65, 76, 70, 32, 4, 250, 3, 66, - 139, 106, 87, 10, 180, 1, 13, 74, 85, 83, 84, 73, 70, 73, 69, 68, 32, 76, - 79, 87, 126, 67, 50, 72, 161, 217, 2, 21, 66, 76, 65, 67, 75, 32, 76, 69, + 33, 6, 65, 82, 69, 78, 84, 72, 2, 231, 225, 1, 69, 6, 38, 79, 21, 5, 85, + 78, 78, 69, 82, 2, 187, 187, 3, 66, 4, 29, 5, 32, 70, 82, 65, 77, 4, 11, + 69, 4, 11, 45, 4, 166, 139, 4, 49, 3, 50, 4, 18, 69, 59, 84, 2, 11, 67, + 2, 11, 84, 2, 11, 73, 2, 179, 139, 2, 79, 2, 17, 2, 65, 78, 2, 11, 68, 2, + 21, 3, 73, 78, 71, 2, 17, 2, 32, 80, 2, 11, 69, 2, 11, 82, 2, 239, 185, + 3, 83, 4, 17, 2, 69, 82, 4, 33, 6, 32, 72, 65, 76, 70, 32, 4, 134, 4, 66, + 207, 107, 87, 10, 180, 1, 13, 74, 85, 83, 84, 73, 70, 73, 69, 68, 32, 76, + 79, 87, 126, 67, 50, 72, 173, 222, 2, 21, 66, 76, 65, 67, 75, 32, 76, 69, 70, 84, 45, 80, 79, 73, 78, 84, 73, 78, 71, 32, 83, 2, 237, 1, 7, 69, 82, 32, 82, 73, 71, 72, 8, 78, 67, 50, 72, 33, 13, 74, 85, 83, 84, 73, 70, - 73, 69, 68, 32, 76, 79, 87, 4, 26, 79, 199, 135, 3, 82, 2, 223, 194, 3, - 82, 2, 209, 173, 3, 3, 65, 76, 70, 2, 33, 6, 69, 82, 32, 76, 69, 70, 2, - 53, 11, 84, 32, 81, 85, 65, 82, 84, 69, 82, 32, 66, 2, 11, 76, 2, 137, - 171, 2, 3, 65, 67, 75, 2, 157, 172, 3, 4, 81, 85, 65, 82, 2, 11, 79, 2, - 249, 171, 3, 12, 82, 84, 79, 73, 83, 69, 32, 83, 72, 69, 76, 76, 2, 29, - 5, 87, 65, 82, 68, 83, 2, 17, 2, 32, 65, 2, 237, 128, 3, 4, 82, 82, 79, - 87, 20, 188, 1, 22, 67, 74, 75, 32, 85, 78, 73, 70, 73, 69, 68, 32, 73, - 68, 69, 79, 71, 82, 65, 80, 72, 45, 161, 2, 19, 76, 65, 84, 73, 78, 32, - 67, 65, 80, 73, 84, 65, 76, 32, 76, 69, 84, 84, 69, 18, 40, 2, 52, 69, - 34, 53, 54, 54, 87, 55, 4, 202, 1, 48, 139, 208, 2, 56, 4, 30, 50, 141, - 1, 2, 66, 56, 2, 131, 181, 3, 68, 6, 48, 2, 50, 53, 22, 53, 185, 208, 2, - 2, 55, 50, 2, 219, 250, 3, 51, 2, 67, 53, 4, 32, 2, 48, 66, 21, 2, 54, - 68, 2, 151, 250, 3, 57, 2, 131, 250, 3, 55, 2, 11, 82, 2, 135, 188, 3, - 32, 64, 48, 6, 65, 76, 32, 82, 85, 78, 21, 2, 79, 32, 2, 203, 255, 2, 79, - 62, 72, 7, 76, 69, 84, 84, 69, 82, 32, 217, 2, 6, 83, 73, 71, 78, 32, 82, - 60, 206, 1, 66, 106, 78, 138, 31, 73, 206, 141, 1, 69, 138, 76, 67, 138, - 189, 1, 65, 234, 61, 68, 2, 71, 2, 72, 2, 74, 2, 75, 2, 76, 2, 77, 2, 80, - 2, 82, 2, 83, 2, 84, 2, 87, 2, 89, 186, 2, 79, 3, 85, 12, 52, 7, 82, 69, - 65, 84, 72, 89, 32, 183, 246, 3, 65, 10, 182, 31, 73, 206, 141, 1, 69, - 223, 178, 2, 65, 4, 202, 243, 3, 71, 187, 2, 65, 2, 17, 2, 73, 83, 2, 21, - 3, 73, 78, 71, 2, 11, 32, 2, 211, 200, 2, 84, 104, 54, 65, 254, 1, 69, - 86, 73, 246, 11, 79, 231, 1, 85, 16, 66, 67, 36, 2, 68, 69, 34, 77, 20, - 2, 78, 83, 231, 163, 3, 73, 4, 218, 233, 1, 75, 219, 209, 1, 84, 2, 133, - 17, 4, 32, 77, 65, 82, 5, 243, 212, 1, 32, 4, 44, 2, 80, 76, 33, 5, 86, - 69, 82, 83, 65, 2, 11, 85, 2, 147, 212, 3, 84, 2, 163, 63, 76, 4, 52, 7, - 65, 83, 85, 82, 69, 32, 67, 235, 220, 2, 69, 2, 11, 72, 2, 171, 4, 69, - 66, 156, 1, 3, 65, 78, 71, 176, 3, 8, 68, 69, 78, 84, 32, 69, 77, 66, 20, - 9, 71, 82, 65, 77, 32, 70, 79, 82, 32, 140, 2, 4, 80, 76, 69, 32, 159, - 155, 3, 67, 16, 48, 2, 76, 69, 245, 1, 5, 85, 76, 65, 82, 32, 10, 44, 6, - 32, 87, 73, 84, 72, 32, 163, 1, 45, 8, 80, 9, 83, 69, 82, 73, 70, 83, 32, - 65, 84, 54, 85, 238, 169, 2, 82, 207, 68, 68, 2, 17, 2, 32, 66, 2, 189, - 222, 3, 3, 79, 84, 84, 2, 149, 61, 2, 78, 68, 2, 193, 204, 2, 4, 72, 69, - 65, 68, 6, 68, 9, 70, 76, 65, 71, 32, 79, 78, 32, 80, 34, 82, 195, 139, - 2, 66, 2, 11, 79, 2, 199, 209, 3, 83, 2, 11, 85, 2, 231, 175, 3, 76, 2, - 147, 219, 3, 76, 16, 66, 69, 34, 72, 34, 76, 22, 77, 46, 84, 42, 87, 155, - 211, 1, 70, 2, 11, 65, 2, 227, 231, 1, 82, 2, 11, 69, 2, 227, 249, 1, 65, - 2, 207, 188, 3, 65, 2, 21, 3, 79, 85, 78, 2, 147, 189, 2, 84, 2, 17, 2, - 72, 85, 2, 251, 199, 1, 78, 4, 178, 177, 2, 65, 251, 41, 73, 30, 176, 2, - 3, 67, 79, 76, 24, 20, 72, 79, 82, 73, 90, 79, 78, 84, 65, 76, 32, 66, - 65, 82, 32, 87, 73, 84, 72, 32, 98, 80, 34, 84, 20, 13, 86, 69, 82, 84, - 73, 67, 65, 76, 32, 66, 65, 82, 32, 44, 9, 83, 79, 76, 73, 68, 85, 83, - 32, 66, 224, 21, 2, 68, 65, 160, 187, 1, 6, 78, 69, 83, 84, 69, 68, 159, - 12, 73, 2, 165, 37, 2, 79, 78, 4, 34, 68, 33, 4, 84, 82, 73, 80, 2, 17, - 2, 79, 85, 2, 11, 66, 2, 177, 183, 3, 2, 76, 69, 4, 142, 223, 1, 76, 235, - 110, 82, 2, 195, 202, 1, 73, 8, 42, 66, 74, 68, 170, 189, 1, 82, 115, 87, - 2, 29, 5, 73, 78, 65, 82, 89, 2, 21, 3, 32, 82, 69, 2, 143, 33, 76, 2, - 25, 4, 69, 76, 73, 77, 2, 163, 172, 2, 73, 12, 32, 2, 76, 76, 42, 77, 23, - 80, 5, 17, 2, 69, 89, 2, 255, 220, 1, 66, 2, 247, 184, 2, 66, 6, 44, 5, - 73, 67, 65, 76, 32, 199, 211, 3, 72, 4, 18, 68, 47, 70, 2, 11, 82, 2, 11, - 73, 2, 199, 225, 3, 78, 2, 195, 249, 1, 73, 6, 18, 69, 79, 77, 5, 213, - 191, 3, 14, 32, 76, 73, 71, 72, 84, 32, 77, 79, 79, 78, 32, 65, 82, 2, - 191, 174, 3, 80, 216, 1, 76, 3, 71, 82, 73, 22, 76, 214, 12, 82, 173, - 188, 2, 5, 77, 66, 76, 69, 82, 2, 239, 219, 2, 75, 162, 1, 68, 11, 85, - 45, 84, 73, 71, 65, 76, 65, 82, 73, 32, 135, 226, 3, 73, 160, 1, 122, 65, - 42, 67, 30, 68, 106, 71, 32, 7, 76, 69, 84, 84, 69, 82, 32, 178, 3, 82, - 32, 5, 83, 73, 71, 78, 32, 131, 3, 86, 2, 11, 85, 2, 133, 159, 3, 2, 32, - 76, 2, 201, 162, 3, 2, 79, 78, 4, 18, 79, 67, 65, 2, 11, 85, 2, 11, 66, - 2, 25, 4, 76, 69, 32, 68, 2, 11, 65, 2, 243, 186, 3, 78, 2, 213, 218, 2, - 3, 69, 77, 73, 100, 206, 1, 65, 38, 68, 46, 76, 38, 82, 34, 84, 46, 86, - 186, 5, 85, 186, 202, 1, 73, 138, 196, 1, 78, 46, 83, 82, 66, 2, 67, 2, - 71, 2, 74, 2, 75, 2, 80, 206, 40, 79, 162, 8, 69, 158, 20, 72, 2, 77, 3, - 89, 9, 242, 221, 3, 65, 2, 73, 3, 85, 8, 142, 150, 3, 68, 138, 69, 72, - 187, 2, 65, 6, 134, 209, 1, 76, 159, 140, 2, 65, 4, 198, 218, 3, 82, 187, - 2, 65, 8, 158, 149, 3, 84, 138, 69, 72, 187, 2, 65, 10, 214, 5, 79, 223, - 214, 3, 65, 2, 11, 69, 2, 223, 222, 1, 80, 18, 174, 1, 65, 72, 6, 76, 79, - 79, 80, 69, 68, 40, 2, 79, 77, 0, 5, 83, 72, 82, 73, 73, 48, 13, 67, 65, - 78, 68, 82, 65, 32, 65, 78, 85, 78, 65, 83, 22, 80, 135, 150, 3, 86, 4, - 26, 86, 191, 149, 3, 78, 2, 21, 3, 65, 71, 82, 2, 231, 220, 1, 65, 2, 17, - 2, 32, 86, 2, 203, 157, 1, 73, 2, 17, 2, 32, 80, 2, 25, 4, 85, 83, 72, - 80, 2, 187, 208, 3, 73, 2, 193, 180, 3, 2, 76, 85, 30, 56, 10, 69, 68, - 73, 67, 32, 84, 79, 78, 69, 32, 35, 79, 4, 226, 164, 1, 65, 235, 4, 83, - 26, 45, 9, 87, 69, 76, 32, 83, 73, 71, 78, 32, 26, 70, 65, 38, 85, 22, - 86, 166, 202, 1, 73, 210, 237, 1, 79, 163, 8, 69, 6, 158, 215, 3, 65, 2, - 73, 3, 85, 5, 251, 214, 3, 85, 8, 11, 79, 8, 33, 6, 67, 65, 76, 73, 67, - 32, 8, 26, 82, 243, 217, 2, 76, 5, 155, 214, 3, 82, 50, 50, 75, 84, 4, - 78, 69, 68, 32, 199, 174, 2, 84, 4, 48, 6, 73, 83, 72, 32, 76, 73, 219, - 195, 3, 69, 2, 11, 82, 2, 147, 206, 2, 65, 44, 238, 1, 65, 80, 6, 66, 76, - 65, 67, 75, 32, 40, 7, 87, 72, 73, 84, 69, 32, 83, 22, 67, 50, 68, 96, 2, - 78, 79, 32, 2, 79, 75, 30, 83, 237, 171, 3, 21, 71, 82, 69, 69, 75, 32, - 83, 77, 65, 76, 76, 32, 76, 69, 84, 84, 69, 82, 32, 73, 79, 4, 26, 77, - 175, 172, 2, 78, 2, 17, 2, 80, 69, 2, 11, 82, 2, 179, 194, 2, 83, 4, 18, - 80, 23, 83, 2, 211, 151, 2, 69, 2, 195, 153, 2, 72, 4, 144, 3, 5, 65, 80, - 73, 84, 65, 171, 121, 79, 6, 30, 65, 33, 3, 73, 71, 73, 2, 11, 71, 2, - 187, 147, 3, 71, 4, 201, 222, 1, 3, 84, 32, 84, 6, 162, 2, 82, 211, 199, - 2, 84, 2, 249, 228, 1, 2, 32, 72, 14, 128, 1, 18, 65, 78, 83, 45, 83, 69, - 82, 73, 70, 32, 67, 65, 80, 73, 84, 65, 76, 32, 38, 69, 32, 3, 77, 65, - 76, 33, 2, 79, 85, 6, 178, 207, 3, 71, 2, 76, 3, 89, 2, 11, 77, 2, 243, - 254, 2, 73, 2, 11, 76, 2, 191, 205, 2, 32, 4, 21, 3, 84, 72, 32, 4, 32, - 2, 69, 65, 1, 2, 87, 69, 2, 53, 11, 83, 84, 32, 80, 79, 73, 78, 84, 73, - 78, 71, 2, 17, 2, 32, 76, 2, 151, 204, 2, 69, 38, 58, 69, 52, 8, 73, 83, - 84, 69, 68, 32, 82, 73, 63, 79, 2, 17, 2, 76, 86, 2, 145, 178, 1, 3, 69, - 32, 80, 2, 17, 2, 71, 72, 2, 141, 109, 6, 84, 87, 65, 82, 68, 83, 34, 30, - 32, 229, 10, 2, 45, 69, 32, 134, 3, 66, 86, 67, 116, 3, 68, 79, 84, 226, - 1, 72, 44, 14, 73, 78, 84, 69, 82, 83, 69, 67, 84, 73, 78, 71, 32, 76, - 92, 6, 74, 79, 73, 78, 69, 68, 64, 8, 76, 79, 71, 73, 67, 65, 76, 32, 98, - 77, 0, 3, 87, 79, 77, 116, 13, 82, 73, 78, 71, 83, 32, 65, 76, 73, 71, - 78, 69, 68, 48, 24, 65, 83, 84, 69, 82, 73, 83, 75, 83, 32, 65, 76, 73, - 71, 78, 69, 68, 32, 86, 69, 82, 84, 73, 67, 35, 83, 2, 29, 5, 85, 84, 84, - 79, 78, 2, 17, 2, 32, 77, 2, 11, 79, 2, 251, 188, 2, 85, 2, 93, 21, 79, - 78, 83, 69, 67, 85, 84, 73, 86, 69, 32, 69, 81, 85, 65, 76, 83, 32, 83, - 73, 71, 2, 207, 137, 3, 78, 6, 18, 32, 55, 83, 4, 22, 76, 131, 1, 80, 2, - 145, 163, 1, 2, 69, 65, 2, 53, 11, 32, 79, 86, 69, 82, 32, 79, 78, 69, + 73, 69, 68, 32, 76, 79, 87, 4, 26, 79, 147, 141, 3, 82, 2, 171, 200, 3, + 82, 2, 157, 179, 3, 3, 65, 76, 70, 2, 33, 6, 69, 82, 32, 76, 69, 70, 2, + 45, 9, 84, 32, 81, 85, 65, 82, 84, 69, 82, 2, 17, 2, 32, 66, 2, 11, 76, + 2, 185, 173, 2, 3, 65, 67, 75, 2, 221, 177, 3, 4, 81, 85, 65, 82, 2, 11, + 79, 2, 185, 177, 3, 12, 82, 84, 79, 73, 83, 69, 32, 83, 72, 69, 76, 76, + 2, 29, 5, 87, 65, 82, 68, 83, 2, 17, 2, 32, 65, 2, 173, 134, 3, 4, 82, + 82, 79, 87, 20, 184, 1, 22, 67, 74, 75, 32, 85, 78, 73, 70, 73, 69, 68, + 32, 73, 68, 69, 79, 71, 82, 65, 80, 72, 45, 161, 2, 18, 76, 65, 84, 73, + 78, 32, 67, 65, 80, 73, 84, 65, 76, 32, 76, 69, 84, 84, 18, 40, 2, 52, + 69, 34, 53, 54, 54, 87, 55, 4, 202, 1, 48, 143, 213, 2, 56, 4, 30, 50, + 141, 1, 2, 66, 56, 2, 199, 186, 3, 68, 6, 48, 2, 50, 53, 22, 53, 189, + 213, 2, 2, 55, 50, 2, 159, 128, 4, 51, 2, 67, 53, 4, 32, 2, 48, 66, 21, + 2, 54, 68, 2, 219, 255, 3, 57, 2, 199, 255, 3, 55, 2, 11, 69, 2, 11, 82, + 2, 191, 193, 3, 32, 64, 48, 6, 65, 76, 32, 82, 85, 78, 21, 2, 79, 32, 2, + 131, 133, 3, 79, 62, 72, 7, 76, 69, 84, 84, 69, 82, 32, 217, 2, 6, 83, + 73, 71, 78, 32, 82, 60, 206, 1, 66, 106, 78, 210, 31, 73, 194, 142, 1, + 69, 238, 76, 67, 162, 192, 1, 65, 234, 61, 68, 2, 71, 2, 72, 2, 74, 2, + 75, 2, 76, 2, 77, 2, 80, 2, 82, 2, 83, 2, 84, 2, 87, 2, 89, 186, 2, 79, + 3, 85, 12, 52, 7, 82, 69, 65, 84, 72, 89, 32, 239, 251, 3, 65, 10, 254, + 31, 73, 194, 142, 1, 69, 219, 182, 2, 65, 4, 130, 249, 3, 71, 187, 2, 65, + 2, 17, 2, 73, 83, 2, 21, 3, 73, 78, 71, 2, 11, 32, 2, 203, 205, 2, 84, + 106, 54, 65, 186, 2, 69, 86, 73, 130, 12, 79, 231, 1, 85, 18, 66, 67, 36, + 2, 68, 69, 34, 77, 20, 2, 78, 83, 159, 169, 3, 73, 4, 242, 235, 1, 75, + 251, 212, 1, 84, 2, 205, 17, 4, 32, 77, 65, 82, 5, 139, 215, 1, 32, 6, + 38, 80, 101, 5, 86, 69, 82, 83, 65, 4, 44, 7, 65, 82, 69, 78, 84, 32, 67, + 23, 76, 2, 227, 163, 2, 85, 2, 11, 85, 2, 143, 217, 3, 84, 2, 151, 64, + 76, 4, 52, 7, 65, 83, 85, 82, 69, 32, 67, 231, 225, 2, 69, 2, 11, 72, 2, + 183, 4, 69, 66, 156, 1, 3, 65, 78, 71, 188, 3, 8, 68, 69, 78, 84, 32, 69, + 77, 66, 20, 9, 71, 82, 65, 77, 32, 70, 79, 82, 32, 140, 2, 4, 80, 76, 69, + 32, 143, 160, 3, 67, 16, 48, 2, 76, 69, 129, 2, 5, 85, 76, 65, 82, 32, + 10, 44, 6, 32, 87, 73, 84, 72, 32, 175, 1, 45, 8, 68, 6, 83, 69, 82, 73, + 70, 83, 78, 85, 230, 171, 2, 82, 199, 71, 68, 2, 21, 3, 32, 65, 84, 2, + 17, 2, 32, 66, 2, 173, 227, 3, 3, 79, 84, 84, 2, 253, 61, 2, 78, 68, 2, + 241, 208, 2, 4, 72, 69, 65, 68, 6, 68, 9, 70, 76, 65, 71, 32, 79, 78, 32, + 80, 34, 82, 155, 141, 2, 66, 2, 11, 79, 2, 183, 214, 3, 83, 2, 11, 85, 2, + 215, 180, 3, 76, 2, 131, 224, 3, 76, 16, 66, 69, 34, 72, 34, 76, 22, 77, + 46, 84, 42, 87, 235, 212, 1, 70, 2, 11, 65, 2, 187, 233, 1, 82, 2, 11, + 69, 2, 187, 251, 1, 65, 2, 191, 193, 3, 65, 2, 21, 3, 79, 85, 78, 2, 195, + 193, 2, 84, 2, 17, 2, 72, 85, 2, 183, 201, 1, 78, 4, 158, 179, 2, 65, + 255, 44, 73, 30, 176, 2, 3, 67, 79, 76, 24, 20, 72, 79, 82, 73, 90, 79, + 78, 84, 65, 76, 32, 66, 65, 82, 32, 87, 73, 84, 72, 32, 98, 80, 34, 84, + 20, 13, 86, 69, 82, 84, 73, 67, 65, 76, 32, 66, 65, 82, 32, 44, 9, 83, + 79, 76, 73, 68, 85, 83, 32, 66, 224, 21, 2, 68, 65, 240, 188, 1, 6, 78, + 69, 83, 84, 69, 68, 163, 12, 73, 2, 157, 37, 2, 79, 78, 4, 34, 68, 33, 4, + 84, 82, 73, 80, 2, 17, 2, 79, 85, 2, 11, 66, 2, 161, 188, 3, 2, 76, 69, + 4, 230, 224, 1, 76, 131, 114, 82, 2, 147, 204, 1, 73, 8, 42, 66, 74, 68, + 166, 190, 1, 82, 115, 87, 2, 29, 5, 73, 78, 65, 82, 89, 2, 21, 3, 32, 82, + 69, 2, 135, 33, 76, 2, 25, 4, 69, 76, 73, 77, 2, 143, 174, 2, 73, 12, 32, + 2, 76, 76, 42, 77, 23, 80, 5, 17, 2, 69, 89, 2, 215, 222, 1, 66, 2, 167, + 189, 2, 66, 6, 44, 5, 73, 67, 65, 76, 32, 183, 216, 3, 72, 4, 18, 68, 47, + 70, 2, 11, 82, 2, 11, 73, 2, 183, 230, 3, 78, 2, 155, 251, 1, 73, 6, 18, + 69, 79, 77, 5, 197, 196, 3, 14, 32, 76, 73, 71, 72, 84, 32, 77, 79, 79, + 78, 32, 65, 82, 2, 175, 179, 3, 80, 216, 1, 76, 3, 71, 82, 73, 22, 76, + 214, 12, 82, 157, 193, 2, 5, 77, 66, 76, 69, 82, 2, 223, 224, 2, 75, 162, + 1, 68, 11, 85, 45, 84, 73, 71, 65, 76, 65, 82, 73, 32, 247, 230, 3, 73, + 160, 1, 122, 65, 42, 67, 30, 68, 106, 71, 32, 7, 76, 69, 84, 84, 69, 82, + 32, 178, 3, 82, 32, 5, 83, 73, 71, 78, 32, 131, 3, 86, 2, 11, 85, 2, 245, + 163, 3, 2, 32, 76, 2, 185, 167, 3, 2, 79, 78, 4, 18, 79, 67, 65, 2, 11, + 85, 2, 11, 66, 2, 25, 4, 76, 69, 32, 68, 2, 11, 65, 2, 227, 191, 3, 78, + 2, 197, 223, 2, 3, 69, 77, 73, 100, 206, 1, 65, 38, 68, 46, 76, 38, 82, + 34, 84, 46, 86, 186, 5, 85, 138, 204, 1, 73, 170, 199, 1, 78, 46, 83, 82, + 66, 2, 67, 2, 71, 2, 74, 2, 75, 2, 80, 206, 40, 79, 162, 8, 69, 158, 20, + 72, 2, 77, 3, 89, 9, 226, 226, 3, 65, 2, 73, 3, 85, 8, 254, 154, 3, 68, + 138, 69, 72, 187, 2, 65, 6, 214, 210, 1, 76, 191, 143, 2, 65, 4, 182, + 223, 3, 82, 187, 2, 65, 8, 142, 154, 3, 84, 138, 69, 72, 187, 2, 65, 10, + 214, 5, 79, 207, 219, 3, 65, 2, 11, 69, 2, 183, 224, 1, 80, 18, 174, 1, + 65, 72, 6, 76, 79, 79, 80, 69, 68, 40, 2, 79, 77, 0, 5, 83, 72, 82, 73, + 73, 48, 13, 67, 65, 78, 68, 82, 65, 32, 65, 78, 85, 78, 65, 83, 22, 80, + 247, 154, 3, 86, 4, 26, 86, 175, 154, 3, 78, 2, 21, 3, 65, 71, 82, 2, + 191, 222, 1, 65, 2, 17, 2, 32, 86, 2, 191, 158, 1, 73, 2, 17, 2, 32, 80, + 2, 25, 4, 85, 83, 72, 80, 2, 171, 213, 3, 73, 2, 177, 185, 3, 2, 76, 85, + 30, 56, 10, 69, 68, 73, 67, 32, 84, 79, 78, 69, 32, 35, 79, 4, 214, 165, + 1, 65, 235, 4, 83, 26, 45, 9, 87, 69, 76, 32, 83, 73, 71, 78, 32, 26, 70, + 65, 38, 85, 22, 86, 246, 203, 1, 73, 242, 240, 1, 79, 163, 8, 69, 6, 142, + 220, 3, 65, 2, 73, 3, 85, 5, 235, 219, 3, 85, 8, 11, 79, 8, 33, 6, 67, + 65, 76, 73, 67, 32, 8, 26, 82, 227, 222, 2, 76, 5, 139, 219, 3, 82, 50, + 50, 75, 84, 4, 78, 69, 68, 32, 247, 178, 2, 84, 4, 48, 6, 73, 83, 72, 32, + 76, 73, 203, 200, 3, 69, 2, 11, 82, 2, 131, 211, 2, 65, 44, 238, 1, 65, + 80, 6, 66, 76, 65, 67, 75, 32, 40, 7, 87, 72, 73, 84, 69, 32, 83, 22, 67, + 50, 68, 96, 2, 78, 79, 32, 2, 79, 75, 30, 83, 221, 176, 3, 21, 71, 82, + 69, 69, 75, 32, 83, 77, 65, 76, 76, 32, 76, 69, 84, 84, 69, 82, 32, 73, + 79, 4, 26, 77, 223, 176, 2, 78, 2, 17, 2, 80, 69, 2, 11, 82, 2, 163, 199, + 2, 83, 4, 18, 80, 23, 83, 2, 191, 153, 2, 69, 2, 175, 155, 2, 72, 4, 144, + 3, 5, 65, 80, 73, 84, 65, 159, 122, 79, 6, 30, 65, 33, 3, 73, 71, 73, 2, + 11, 71, 2, 171, 152, 3, 71, 4, 161, 224, 1, 3, 84, 32, 84, 6, 162, 2, 82, + 195, 204, 2, 84, 2, 209, 230, 1, 2, 32, 72, 14, 128, 1, 18, 65, 78, 83, + 45, 83, 69, 82, 73, 70, 32, 67, 65, 80, 73, 84, 65, 76, 32, 38, 69, 32, + 3, 77, 65, 76, 33, 2, 79, 85, 6, 162, 212, 3, 71, 2, 76, 3, 89, 2, 11, + 77, 2, 227, 131, 3, 73, 2, 11, 76, 2, 175, 210, 2, 32, 4, 21, 3, 84, 72, + 32, 4, 32, 2, 69, 65, 1, 2, 87, 69, 2, 53, 11, 83, 84, 32, 80, 79, 73, + 78, 84, 73, 78, 71, 2, 17, 2, 32, 76, 2, 135, 209, 2, 69, 42, 58, 69, 52, + 8, 73, 83, 84, 69, 68, 32, 82, 73, 63, 79, 2, 17, 2, 76, 86, 2, 225, 179, + 1, 3, 69, 32, 80, 2, 17, 2, 71, 72, 2, 129, 110, 6, 84, 87, 65, 82, 68, + 83, 38, 22, 32, 231, 10, 45, 32, 134, 3, 66, 86, 67, 116, 3, 68, 79, 84, + 226, 1, 72, 44, 14, 73, 78, 84, 69, 82, 83, 69, 67, 84, 73, 78, 71, 32, + 76, 92, 6, 74, 79, 73, 78, 69, 68, 64, 8, 76, 79, 71, 73, 67, 65, 76, 32, + 98, 77, 0, 3, 87, 79, 77, 116, 13, 82, 73, 78, 71, 83, 32, 65, 76, 73, + 71, 78, 69, 68, 48, 24, 65, 83, 84, 69, 82, 73, 83, 75, 83, 32, 65, 76, + 73, 71, 78, 69, 68, 32, 86, 69, 82, 84, 73, 67, 35, 83, 2, 29, 5, 85, 84, + 84, 79, 78, 2, 17, 2, 32, 77, 2, 11, 79, 2, 243, 193, 2, 85, 2, 93, 21, + 79, 78, 83, 69, 67, 85, 84, 73, 86, 69, 32, 69, 81, 85, 65, 76, 83, 32, + 83, 73, 71, 2, 199, 142, 3, 78, 6, 18, 32, 55, 83, 4, 22, 76, 131, 1, 80, + 2, 213, 164, 1, 2, 69, 65, 2, 53, 11, 32, 79, 86, 69, 82, 32, 79, 78, 69, 32, 68, 2, 11, 79, 2, 11, 84, 2, 17, 2, 32, 80, 2, 29, 5, 85, 78, 67, 84, - 85, 2, 251, 244, 2, 65, 2, 11, 69, 2, 11, 65, 2, 227, 188, 2, 82, 4, 17, - 2, 79, 71, 4, 25, 4, 73, 67, 65, 76, 4, 11, 32, 4, 186, 180, 2, 65, 187, - 87, 79, 2, 17, 2, 32, 83, 2, 21, 3, 81, 85, 65, 2, 255, 173, 2, 82, 4, + 85, 2, 243, 249, 2, 65, 2, 11, 69, 2, 11, 65, 2, 219, 193, 2, 82, 4, 17, + 2, 79, 71, 4, 25, 4, 73, 67, 65, 76, 4, 11, 32, 4, 178, 185, 2, 65, 187, + 87, 79, 2, 17, 2, 32, 83, 2, 21, 3, 81, 85, 65, 2, 247, 178, 2, 82, 4, 30, 79, 13, 3, 65, 78, 68, 2, 11, 82, 2, 11, 32, 2, 11, 79, 2, 11, 80, 2, - 143, 18, 69, 2, 11, 69, 2, 45, 9, 78, 32, 72, 79, 76, 68, 73, 78, 71, 2, - 11, 32, 2, 11, 72, 2, 11, 65, 2, 251, 223, 1, 78, 2, 45, 9, 32, 72, 79, - 82, 73, 90, 79, 78, 84, 2, 11, 65, 2, 175, 158, 3, 76, 2, 49, 10, 80, 69, - 69, 67, 72, 32, 66, 85, 66, 66, 2, 147, 171, 2, 76, 2, 11, 77, 2, 225, - 213, 1, 2, 32, 68, 248, 3, 140, 1, 8, 71, 65, 82, 73, 84, 73, 67, 32, - 152, 6, 7, 77, 66, 82, 69, 76, 76, 65, 166, 1, 78, 158, 8, 80, 246, 166, - 1, 82, 255, 136, 2, 83, 62, 48, 7, 76, 69, 84, 84, 69, 82, 32, 159, 5, - 87, 60, 206, 1, 65, 28, 2, 81, 79, 22, 66, 22, 68, 50, 71, 44, 2, 72, 79, - 22, 75, 34, 76, 32, 2, 82, 65, 22, 83, 74, 84, 74, 89, 22, 90, 234, 185, - 2, 78, 202, 91, 80, 246, 5, 87, 202, 12, 77, 174, 18, 73, 3, 85, 4, 26, - 76, 203, 237, 2, 73, 2, 239, 186, 3, 80, 2, 199, 152, 3, 69, 4, 26, 69, - 139, 177, 2, 72, 2, 151, 152, 3, 76, 4, 230, 141, 2, 72, 209, 140, 1, 2, - 65, 77, 5, 235, 185, 3, 84, 4, 234, 186, 2, 65, 239, 126, 72, 2, 11, 65, - 2, 223, 150, 3, 77, 2, 167, 190, 1, 83, 8, 38, 65, 194, 187, 2, 72, 239, - 90, 83, 4, 190, 164, 3, 68, 239, 13, 77, 6, 38, 72, 162, 158, 3, 69, 175, - 28, 79, 2, 11, 65, 2, 167, 252, 1, 78, 2, 139, 244, 2, 79, 4, 202, 149, - 3, 69, 207, 36, 85, 2, 21, 3, 79, 82, 68, 2, 25, 4, 32, 68, 73, 86, 2, - 235, 149, 1, 73, 7, 11, 32, 4, 84, 4, 79, 78, 32, 71, 45, 13, 87, 73, 84, - 72, 32, 82, 65, 73, 78, 32, 68, 82, 79, 2, 11, 82, 2, 11, 79, 2, 159, - 168, 2, 85, 2, 195, 250, 2, 80, 32, 160, 1, 3, 65, 77, 85, 20, 7, 67, 69, - 82, 84, 65, 73, 78, 34, 68, 62, 73, 245, 5, 18, 77, 65, 82, 82, 73, 69, - 68, 32, 80, 65, 82, 84, 78, 69, 82, 83, 72, 73, 2, 243, 163, 2, 83, 2, - 11, 84, 2, 199, 175, 2, 89, 4, 26, 69, 215, 160, 2, 79, 2, 11, 82, 2, - 219, 154, 3, 84, 22, 60, 2, 79, 78, 234, 3, 84, 106, 86, 177, 58, 3, 67, - 79, 82, 15, 11, 32, 12, 160, 1, 6, 65, 66, 79, 86, 69, 32, 108, 22, 66, - 69, 83, 73, 68, 69, 32, 65, 78, 68, 32, 74, 79, 73, 78, 69, 68, 32, 87, - 73, 84, 72, 41, 5, 87, 73, 84, 72, 32, 4, 52, 9, 66, 65, 82, 32, 65, 66, - 79, 86, 69, 23, 73, 2, 17, 2, 32, 73, 2, 161, 49, 4, 78, 84, 69, 82, 2, - 17, 2, 32, 85, 2, 195, 226, 2, 78, 6, 66, 77, 58, 79, 145, 249, 2, 8, 76, - 79, 71, 73, 67, 65, 76, 32, 2, 11, 73, 2, 11, 78, 2, 11, 85, 2, 139, 171, - 2, 83, 2, 11, 86, 2, 161, 142, 2, 2, 69, 82, 4, 18, 32, 67, 69, 2, 11, - 83, 2, 17, 2, 69, 80, 2, 11, 65, 2, 143, 248, 2, 82, 2, 183, 155, 2, 68, - 2, 57, 12, 69, 82, 83, 65, 76, 32, 82, 69, 67, 89, 67, 76, 2, 17, 2, 73, - 78, 2, 211, 154, 2, 71, 2, 191, 154, 2, 80, 144, 3, 130, 1, 32, 246, 7, - 45, 180, 8, 4, 80, 69, 82, 32, 136, 40, 8, 83, 73, 68, 69, 45, 68, 79, - 87, 21, 6, 87, 65, 82, 68, 83, 32, 38, 140, 1, 5, 65, 82, 82, 79, 87, - 224, 1, 5, 66, 65, 82, 66, 32, 228, 1, 5, 68, 79, 87, 78, 32, 210, 1, 70, - 30, 82, 93, 4, 84, 65, 67, 75, 8, 64, 4, 72, 69, 65, 68, 141, 51, 7, 32, - 84, 72, 82, 79, 85, 71, 7, 11, 32, 4, 112, 22, 66, 69, 84, 87, 69, 69, - 78, 32, 84, 87, 79, 32, 72, 79, 82, 73, 90, 79, 78, 84, 65, 76, 227, 156, - 2, 73, 2, 145, 149, 2, 2, 32, 66, 8, 44, 3, 76, 69, 70, 1, 4, 82, 73, 71, - 72, 4, 57, 12, 84, 32, 68, 79, 87, 78, 32, 66, 65, 82, 66, 32, 4, 44, 3, - 76, 69, 70, 1, 4, 82, 73, 71, 72, 2, 11, 84, 2, 25, 4, 32, 72, 65, 82, 2, - 11, 80, 2, 187, 218, 2, 79, 14, 76, 5, 65, 82, 82, 79, 87, 62, 66, 38, - 68, 18, 83, 250, 58, 87, 219, 9, 84, 5, 37, 7, 32, 87, 73, 84, 72, 32, - 66, 2, 247, 157, 2, 65, 2, 173, 140, 2, 4, 76, 65, 67, 75, 2, 195, 59, - 79, 2, 183, 65, 65, 2, 11, 73, 2, 239, 112, 83, 2, 53, 11, 73, 71, 72, - 84, 32, 68, 73, 65, 71, 79, 78, 2, 189, 128, 1, 4, 65, 76, 32, 69, 5, 29, - 5, 32, 87, 73, 84, 72, 2, 33, 6, 32, 67, 73, 82, 67, 76, 2, 131, 170, 2, - 69, 32, 58, 70, 225, 1, 9, 80, 79, 73, 78, 84, 73, 78, 71, 32, 4, 41, 8, - 65, 67, 73, 78, 71, 32, 83, 78, 4, 65, 14, 65, 75, 69, 32, 72, 69, 65, - 68, 32, 87, 73, 84, 72, 32, 4, 42, 79, 25, 6, 67, 76, 79, 83, 69, 68, 2, - 21, 3, 80, 69, 78, 2, 21, 3, 32, 77, 79, 2, 243, 159, 1, 85, 28, 130, 1, - 65, 86, 69, 62, 70, 20, 8, 77, 73, 76, 73, 84, 65, 82, 89, 26, 82, 88, 6, - 83, 77, 65, 76, 76, 32, 118, 84, 255, 121, 71, 4, 22, 84, 159, 2, 73, 2, - 37, 7, 79, 77, 73, 67, 32, 66, 79, 2, 155, 229, 1, 77, 2, 29, 5, 78, 69, - 82, 71, 89, 2, 193, 180, 1, 2, 32, 87, 2, 227, 161, 3, 82, 2, 129, 1, 2, - 32, 65, 8, 64, 5, 79, 67, 75, 69, 84, 118, 69, 214, 129, 1, 65, 235, 29, - 73, 2, 195, 204, 2, 32, 4, 18, 65, 67, 82, 2, 11, 73, 2, 11, 82, 2, 17, - 2, 80, 76, 2, 207, 133, 2, 65, 2, 11, 69, 2, 215, 249, 1, 68, 4, 37, 7, - 82, 73, 65, 78, 71, 76, 69, 4, 11, 32, 4, 11, 87, 4, 25, 4, 73, 84, 72, - 32, 4, 18, 76, 27, 82, 2, 11, 69, 2, 35, 70, 2, 21, 3, 73, 71, 72, 2, 11, - 84, 2, 17, 2, 32, 72, 2, 21, 3, 65, 76, 70, 2, 17, 2, 32, 66, 2, 11, 76, - 2, 207, 236, 1, 65, 200, 1, 192, 1, 4, 65, 78, 68, 32, 210, 2, 66, 74, - 67, 74, 70, 36, 5, 72, 65, 76, 70, 32, 200, 4, 5, 76, 69, 70, 84, 32, - 254, 5, 77, 150, 2, 79, 60, 6, 82, 73, 71, 72, 84, 32, 238, 17, 83, 67, - 84, 8, 34, 76, 53, 4, 82, 73, 71, 72, 6, 48, 2, 69, 70, 173, 1, 5, 79, - 87, 69, 82, 32, 2, 53, 11, 84, 32, 65, 78, 68, 32, 76, 79, 87, 69, 82, 2, - 205, 35, 25, 32, 84, 82, 73, 65, 78, 71, 85, 76, 65, 82, 32, 84, 72, 82, - 69, 69, 32, 81, 85, 65, 82, 84, 69, 82, 4, 28, 2, 84, 82, 235, 39, 79, 2, - 225, 4, 7, 73, 65, 78, 71, 85, 76, 65, 2, 17, 2, 76, 65, 2, 17, 2, 68, - 69, 2, 249, 224, 1, 3, 32, 83, 67, 10, 33, 6, 69, 78, 84, 82, 69, 32, 10, - 174, 12, 76, 22, 82, 255, 21, 79, 2, 17, 2, 73, 86, 2, 183, 31, 69, 20, - 140, 1, 5, 66, 76, 79, 67, 75, 110, 72, 32, 8, 73, 78, 86, 69, 82, 83, - 69, 32, 198, 1, 86, 174, 26, 77, 130, 3, 76, 22, 82, 191, 163, 1, 67, 5, - 229, 28, 23, 32, 65, 78, 68, 32, 76, 79, 87, 69, 82, 32, 72, 65, 76, 70, - 32, 73, 78, 86, 69, 82, 83, 69, 2, 225, 18, 4, 69, 65, 86, 89, 4, 100, - 21, 77, 69, 68, 73, 85, 77, 32, 83, 72, 65, 68, 69, 32, 65, 78, 68, 32, - 76, 79, 87, 69, 51, 87, 2, 11, 82, 2, 189, 35, 5, 32, 72, 65, 76, 70, 2, - 21, 3, 72, 73, 84, 2, 247, 192, 1, 69, 2, 29, 5, 69, 82, 84, 73, 67, 2, - 189, 115, 14, 65, 76, 32, 76, 73, 78, 69, 32, 87, 73, 84, 72, 32, 84, 62, - 50, 66, 238, 3, 67, 54, 79, 74, 84, 183, 13, 81, 22, 65, 14, 76, 79, 67, - 75, 32, 68, 73, 65, 71, 79, 78, 65, 76, 32, 22, 144, 1, 6, 76, 79, 87, - 69, 82, 32, 233, 8, 24, 85, 80, 80, 69, 82, 32, 77, 73, 68, 68, 76, 69, - 32, 76, 69, 70, 84, 32, 84, 79, 32, 85, 80, 80, 18, 176, 1, 10, 67, 69, - 78, 84, 82, 69, 32, 84, 79, 32, 36, 8, 76, 69, 70, 84, 32, 84, 79, 32, - 229, 10, 18, 77, 73, 68, 68, 76, 69, 32, 76, 69, 70, 84, 32, 84, 79, 32, - 85, 80, 80, 6, 70, 76, 253, 8, 3, 85, 80, 80, 6, 34, 76, 213, 9, 3, 85, - 80, 80, 2, 149, 10, 2, 79, 87, 2, 29, 5, 79, 82, 78, 69, 82, 2, 219, 233, - 1, 32, 4, 182, 12, 78, 53, 12, 82, 32, 76, 79, 87, 69, 82, 32, 82, 73, - 71, 72, 8, 34, 79, 170, 19, 82, 155, 1, 87, 2, 241, 18, 11, 32, 76, 79, - 87, 69, 82, 32, 82, 73, 71, 72, 12, 33, 6, 73, 68, 68, 76, 69, 32, 12, - 52, 7, 67, 69, 78, 84, 82, 69, 32, 74, 76, 23, 82, 4, 44, 3, 76, 69, 70, - 1, 4, 82, 73, 71, 72, 2, 117, 3, 84, 32, 79, 4, 41, 2, 69, 70, 4, 21, 3, - 73, 71, 72, 4, 17, 2, 84, 32, 4, 30, 79, 129, 18, 2, 84, 87, 2, 139, 9, - 78, 4, 11, 78, 4, 17, 2, 69, 32, 4, 154, 21, 81, 147, 4, 69, 68, 84, 2, - 66, 76, 186, 6, 68, 114, 79, 222, 1, 80, 42, 81, 224, 4, 2, 83, 72, 51, - 84, 22, 61, 13, 79, 67, 75, 32, 68, 73, 65, 71, 79, 78, 65, 76, 32, 22, - 140, 1, 24, 76, 79, 87, 69, 82, 32, 77, 73, 68, 68, 76, 69, 32, 76, 69, - 70, 84, 32, 84, 79, 32, 76, 79, 87, 57, 6, 85, 80, 80, 69, 82, 32, 4, 21, - 3, 69, 82, 32, 4, 246, 3, 67, 219, 218, 2, 82, 18, 176, 1, 10, 67, 69, - 78, 84, 82, 69, 32, 84, 79, 32, 92, 8, 76, 69, 70, 84, 32, 84, 79, 32, - 141, 1, 18, 77, 73, 68, 68, 76, 69, 32, 76, 69, 70, 84, 32, 84, 79, 32, - 76, 79, 87, 6, 32, 3, 76, 79, 87, 139, 1, 85, 4, 21, 3, 69, 82, 32, 4, - 142, 2, 77, 179, 218, 2, 82, 6, 28, 3, 76, 79, 87, 51, 85, 4, 21, 3, 69, - 82, 32, 4, 142, 1, 67, 43, 77, 2, 17, 2, 80, 80, 2, 17, 2, 69, 82, 2, - 117, 2, 32, 77, 6, 21, 3, 69, 82, 32, 6, 34, 67, 42, 77, 179, 218, 2, 82, - 2, 11, 69, 2, 221, 226, 1, 2, 78, 84, 2, 25, 4, 73, 68, 68, 76, 2, 195, - 177, 1, 69, 2, 57, 12, 82, 79, 80, 45, 83, 72, 65, 68, 79, 87, 69, 68, 2, - 17, 2, 32, 87, 2, 149, 192, 1, 3, 72, 73, 84, 4, 62, 78, 53, 11, 82, 32, - 76, 79, 87, 69, 82, 32, 76, 69, 70, 2, 229, 16, 9, 69, 32, 83, 73, 88, - 84, 69, 69, 78, 2, 69, 15, 84, 32, 67, 85, 82, 76, 89, 32, 66, 82, 65, - 67, 75, 69, 84, 2, 11, 32, 2, 175, 177, 2, 83, 2, 11, 69, 2, 165, 162, 1, - 2, 78, 67, 26, 17, 2, 85, 65, 26, 44, 6, 68, 82, 65, 78, 84, 32, 255, 3, - 82, 24, 90, 67, 112, 10, 70, 65, 67, 69, 32, 87, 73, 84, 72, 32, 114, 77, - 76, 2, 83, 84, 67, 84, 14, 68, 7, 73, 82, 67, 85, 76, 65, 82, 197, 168, - 1, 4, 72, 69, 83, 83, 2, 17, 2, 32, 65, 2, 207, 213, 1, 82, 4, 34, 67, - 45, 4, 79, 80, 69, 78, 2, 21, 3, 76, 79, 83, 2, 17, 2, 69, 68, 2, 245, - 232, 1, 3, 32, 69, 89, 2, 25, 4, 73, 67, 82, 79, 2, 11, 67, 2, 165, 196, - 1, 4, 79, 77, 80, 85, 2, 41, 8, 65, 78, 68, 73, 78, 71, 32, 75, 2, 147, - 211, 2, 78, 2, 21, 3, 69, 76, 69, 2, 11, 86, 2, 183, 90, 73, 2, 233, 168, - 1, 3, 84, 69, 82, 4, 141, 102, 8, 65, 68, 79, 87, 69, 68, 32, 87, 8, 30, - 79, 106, 82, 155, 1, 87, 2, 49, 10, 32, 76, 79, 87, 69, 82, 32, 76, 69, - 70, 2, 11, 84, 2, 11, 32, 2, 11, 70, 2, 171, 113, 73, 4, 25, 4, 73, 65, - 78, 71, 4, 40, 4, 85, 76, 65, 82, 171, 228, 2, 76, 2, 17, 2, 32, 77, 2, - 41, 8, 69, 68, 73, 85, 77, 32, 83, 72, 2, 199, 103, 65, 2, 21, 3, 69, 76, - 70, 2, 11, 84, 2, 215, 165, 1, 72, 2, 17, 2, 69, 86, 2, 17, 2, 69, 78, 2, - 145, 1, 2, 32, 69, 10, 64, 5, 72, 82, 69, 69, 32, 193, 1, 6, 82, 73, 65, - 78, 71, 85, 8, 54, 69, 49, 9, 81, 85, 65, 82, 84, 69, 82, 83, 32, 2, 29, - 5, 73, 71, 72, 84, 72, 2, 243, 5, 83, 6, 30, 76, 22, 82, 203, 5, 66, 2, - 41, 2, 69, 70, 2, 21, 3, 73, 71, 72, 2, 43, 84, 2, 17, 2, 76, 65, 2, 11, - 82, 2, 17, 2, 32, 79, 2, 25, 4, 78, 69, 32, 81, 2, 185, 4, 6, 85, 65, 82, - 84, 69, 82, 2, 151, 185, 2, 78, 128, 1, 154, 1, 65, 184, 6, 2, 66, 76, - 150, 1, 68, 50, 70, 82, 72, 150, 4, 67, 46, 81, 42, 82, 22, 83, 102, 84, - 146, 7, 80, 173, 3, 6, 87, 72, 73, 84, 69, 32, 32, 34, 78, 33, 4, 82, 82, - 79, 87, 2, 11, 67, 2, 147, 176, 2, 79, 31, 11, 32, 28, 134, 1, 65, 192, - 1, 14, 76, 69, 70, 84, 87, 65, 82, 68, 83, 32, 79, 70, 32, 68, 32, 5, 87, - 73, 84, 72, 32, 210, 8, 70, 179, 5, 84, 2, 41, 8, 78, 68, 32, 82, 73, 71, - 72, 84, 2, 17, 2, 32, 79, 2, 25, 4, 78, 69, 32, 69, 2, 21, 3, 73, 71, 72, - 2, 17, 2, 84, 72, 2, 11, 32, 2, 11, 66, 2, 11, 76, 2, 251, 191, 1, 79, 2, - 145, 208, 1, 3, 79, 87, 78, 20, 74, 68, 58, 76, 42, 77, 38, 78, 58, 83, - 66, 69, 250, 12, 84, 135, 58, 72, 2, 21, 3, 79, 85, 66, 2, 11, 76, 2, - 199, 192, 2, 69, 2, 11, 65, 2, 253, 22, 3, 82, 71, 69, 2, 225, 22, 5, 69, - 68, 73, 85, 77, 2, 25, 4, 79, 84, 67, 72, 2, 11, 69, 2, 151, 56, 68, 4, - 11, 77, 4, 25, 4, 65, 76, 76, 32, 4, 22, 69, 223, 21, 84, 2, 129, 22, 10, - 81, 85, 73, 76, 65, 84, 69, 82, 65, 76, 4, 25, 4, 65, 67, 75, 32, 4, 26, - 67, 215, 209, 1, 65, 2, 25, 4, 73, 82, 67, 76, 2, 25, 4, 69, 68, 32, 87, - 2, 11, 72, 2, 237, 14, 2, 73, 84, 4, 22, 79, 195, 13, 65, 2, 177, 14, 2, - 85, 66, 2, 11, 73, 2, 37, 7, 78, 71, 69, 82, 45, 80, 79, 2, 249, 207, 1, - 2, 83, 84, 20, 88, 17, 65, 82, 80, 79, 79, 78, 32, 87, 73, 84, 72, 32, - 66, 65, 82, 66, 32, 131, 3, 69, 16, 56, 4, 76, 69, 70, 84, 245, 1, 5, 82, - 73, 71, 72, 84, 10, 22, 32, 239, 9, 87, 8, 60, 7, 66, 69, 83, 73, 68, 69, - 32, 206, 1, 70, 179, 5, 84, 4, 40, 4, 68, 79, 87, 78, 1, 2, 85, 80, 2, - 249, 150, 1, 23, 87, 65, 82, 68, 83, 32, 72, 65, 82, 80, 79, 79, 78, 32, - 87, 73, 84, 72, 32, 66, 65, 82, 66, 6, 22, 32, 251, 7, 87, 4, 22, 70, - 179, 5, 84, 2, 165, 197, 1, 3, 82, 79, 77, 4, 25, 4, 65, 86, 89, 32, 4, - 26, 67, 231, 203, 1, 65, 2, 189, 10, 7, 79, 77, 80, 82, 69, 83, 83, 2, - 137, 9, 6, 85, 65, 68, 82, 85, 80, 2, 251, 148, 2, 79, 4, 30, 65, 53, 3, - 81, 85, 65, 2, 193, 202, 1, 8, 78, 83, 45, 83, 69, 82, 73, 70, 2, 131, 9, - 82, 36, 36, 2, 82, 73, 229, 7, 2, 87, 79, 30, 40, 5, 65, 78, 71, 76, 69, - 155, 7, 80, 28, 52, 8, 45, 72, 69, 65, 68, 69, 68, 32, 219, 12, 32, 26, - 48, 5, 65, 82, 82, 79, 87, 174, 5, 68, 39, 80, 23, 11, 32, 20, 92, 17, - 76, 69, 70, 84, 87, 65, 82, 68, 83, 32, 79, 70, 32, 68, 79, 87, 78, 98, - 84, 23, 87, 2, 37, 7, 87, 65, 82, 68, 83, 32, 84, 2, 37, 7, 82, 73, 65, - 78, 71, 76, 69, 2, 219, 5, 45, 2, 247, 191, 1, 79, 16, 25, 4, 73, 84, 72, - 32, 16, 114, 66, 28, 6, 76, 79, 78, 71, 32, 84, 130, 1, 77, 34, 78, 34, - 86, 34, 72, 145, 56, 6, 68, 79, 85, 66, 76, 69, 2, 149, 2, 3, 79, 76, 68, - 4, 17, 2, 73, 80, 4, 11, 32, 4, 34, 76, 21, 4, 82, 73, 71, 72, 2, 17, 2, - 69, 70, 2, 11, 84, 2, 11, 87, 2, 219, 126, 65, 2, 121, 5, 69, 68, 73, 85, - 77, 2, 89, 5, 65, 82, 82, 79, 87, 2, 29, 5, 69, 82, 89, 32, 72, 2, 25, 4, - 69, 65, 86, 89, 2, 173, 181, 2, 4, 32, 83, 72, 65, 2, 11, 65, 2, 249, 1, - 2, 83, 72, 2, 11, 65, 2, 25, 4, 73, 82, 69, 68, 2, 29, 5, 32, 65, 82, 82, - 79, 2, 163, 161, 2, 87, 2, 11, 76, 2, 135, 194, 1, 69, 6, 74, 32, 61, 14, - 45, 72, 69, 65, 68, 69, 68, 32, 65, 82, 82, 79, 87, 32, 2, 25, 4, 72, 69, - 65, 68, 2, 11, 69, 2, 255, 192, 1, 68, 4, 42, 87, 177, 136, 1, 4, 70, 82, - 79, 77, 2, 33, 6, 73, 84, 72, 32, 84, 82, 2, 61, 13, 73, 65, 78, 71, 76, - 69, 32, 65, 82, 82, 79, 87, 72, 2, 253, 121, 2, 69, 65, 18, 88, 5, 65, - 82, 82, 79, 87, 149, 3, 12, 68, 79, 85, 66, 76, 69, 32, 65, 82, 82, 79, - 87, 15, 11, 32, 12, 108, 11, 79, 78, 32, 80, 69, 68, 69, 83, 84, 65, 76, - 106, 87, 165, 181, 1, 8, 70, 82, 79, 77, 32, 66, 65, 82, 7, 33, 6, 32, - 87, 73, 84, 72, 32, 4, 26, 86, 247, 181, 1, 72, 2, 153, 182, 1, 5, 69, - 82, 84, 73, 67, 2, 29, 5, 73, 84, 72, 73, 78, 2, 17, 2, 32, 84, 2, 37, 7, - 82, 73, 65, 78, 71, 76, 69, 2, 11, 32, 2, 11, 65, 2, 25, 4, 82, 82, 79, - 87, 2, 11, 72, 2, 147, 146, 2, 69, 5, 45, 9, 32, 79, 78, 32, 80, 69, 68, - 69, 83, 2, 159, 204, 1, 84, 244, 15, 86, 65, 254, 16, 83, 174, 3, 69, - 194, 46, 73, 202, 8, 79, 134, 2, 84, 21, 2, 85, 76, 218, 8, 116, 2, 73, - 32, 128, 16, 17, 82, 73, 65, 84, 73, 79, 78, 32, 83, 69, 76, 69, 67, 84, - 79, 82, 45, 233, 45, 2, 77, 80, 216, 4, 54, 67, 34, 70, 82, 81, 40, 2, - 83, 89, 183, 96, 68, 2, 11, 79, 2, 183, 180, 2, 77, 2, 11, 85, 2, 11, 76, - 2, 11, 76, 2, 11, 32, 2, 11, 83, 2, 227, 219, 1, 84, 2, 17, 2, 85, 69, 2, - 167, 235, 1, 83, 190, 4, 68, 7, 76, 76, 65, 66, 76, 69, 32, 197, 11, 5, - 77, 66, 79, 76, 32, 164, 4, 214, 1, 68, 70, 66, 2, 83, 2, 84, 2, 90, 70, - 71, 122, 72, 82, 75, 134, 1, 76, 130, 1, 77, 86, 78, 134, 3, 67, 2, 70, - 2, 74, 2, 80, 2, 82, 2, 86, 2, 89, 78, 87, 50, 69, 34, 79, 226, 74, 65, - 2, 73, 3, 85, 42, 66, 72, 162, 8, 79, 146, 137, 2, 69, 162, 64, 65, 2, - 73, 3, 85, 28, 230, 7, 72, 58, 79, 146, 137, 2, 69, 162, 64, 65, 2, 73, - 3, 85, 34, 62, 66, 202, 6, 69, 86, 79, 178, 201, 2, 65, 2, 73, 3, 85, 18, - 106, 79, 222, 5, 69, 134, 202, 2, 65, 2, 73, 3, 85, 24, 50, 79, 222, 5, - 69, 154, 76, 65, 2, 73, 3, 85, 7, 222, 207, 2, 78, 3, 79, 34, 70, 80, - 206, 5, 79, 198, 75, 65, 206, 189, 1, 69, 162, 64, 73, 3, 85, 18, 246, 4, - 69, 86, 79, 198, 75, 65, 238, 253, 1, 73, 3, 85, 16, 54, 69, 218, 4, 79, - 178, 201, 2, 65, 2, 73, 3, 85, 7, 26, 78, 239, 205, 2, 69, 2, 21, 3, 71, - 84, 72, 2, 219, 143, 2, 69, 42, 214, 3, 66, 0, 2, 71, 66, 58, 79, 146, - 137, 2, 69, 162, 64, 65, 2, 73, 3, 85, 90, 90, 68, 174, 1, 71, 126, 74, - 2, 89, 58, 79, 146, 137, 2, 69, 162, 64, 65, 2, 73, 3, 85, 24, 54, 79, - 186, 139, 2, 69, 162, 64, 65, 2, 73, 3, 85, 15, 36, 3, 76, 69, 32, 179, - 203, 2, 79, 10, 54, 83, 134, 172, 2, 68, 190, 28, 70, 2, 75, 3, 77, 2, - 131, 172, 2, 79, 25, 42, 71, 218, 250, 1, 65, 2, 69, 3, 79, 16, 50, 69, - 86, 79, 178, 201, 2, 65, 2, 73, 3, 85, 7, 130, 202, 2, 69, 3, 78, 14, 54, - 79, 146, 137, 2, 69, 162, 64, 65, 2, 73, 3, 85, 5, 175, 201, 2, 79, 28, - 46, 69, 34, 79, 226, 74, 65, 2, 73, 3, 85, 9, 254, 74, 69, 239, 253, 1, - 78, 9, 222, 74, 79, 239, 253, 1, 78, 26, 66, 68, 62, 70, 30, 74, 22, 75, - 50, 78, 22, 84, 231, 237, 1, 66, 6, 26, 79, 215, 246, 1, 65, 4, 210, 246, - 1, 79, 135, 50, 45, 4, 74, 69, 171, 196, 2, 65, 2, 151, 246, 1, 79, 4, - 26, 69, 235, 245, 1, 85, 2, 231, 245, 1, 69, 2, 243, 178, 2, 73, 6, 190, - 245, 1, 73, 2, 79, 195, 78, 65, 128, 4, 74, 49, 94, 50, 98, 51, 2, 52, 2, - 53, 2, 54, 2, 55, 2, 56, 3, 57, 223, 1, 182, 1, 48, 2, 49, 2, 50, 2, 51, - 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 137, 1, 90, 48, 2, 49, 2, 50, - 2, 51, 2, 52, 94, 53, 170, 195, 2, 54, 2, 55, 2, 56, 3, 57, 23, 130, 196, - 2, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 17, - 166, 195, 2, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 3, 54, 196, 1, 128, - 1, 4, 68, 73, 67, 32, 190, 19, 82, 152, 25, 2, 83, 84, 201, 131, 1, 13, - 67, 84, 79, 82, 32, 79, 82, 32, 67, 82, 79, 83, 83, 86, 60, 5, 83, 73, - 71, 78, 32, 137, 10, 5, 84, 79, 78, 69, 32, 48, 218, 2, 65, 216, 1, 17, - 68, 79, 85, 66, 76, 69, 32, 65, 78, 85, 83, 86, 65, 82, 65, 32, 65, 98, - 74, 52, 6, 78, 73, 72, 83, 72, 86, 22, 82, 240, 1, 8, 72, 69, 88, 73, 70, - 79, 82, 77, 22, 76, 52, 4, 84, 73, 82, 89, 22, 85, 60, 8, 86, 73, 83, 65, - 82, 71, 65, 32, 221, 6, 17, 89, 65, 74, 85, 82, 86, 69, 68, 73, 67, 32, - 77, 73, 68, 76, 73, 78, 14, 76, 8, 78, 85, 83, 86, 65, 82, 65, 32, 212, - 1, 3, 84, 73, 75, 151, 2, 82, 10, 134, 1, 65, 24, 4, 66, 65, 72, 73, 24, - 9, 85, 66, 72, 65, 89, 65, 84, 79, 32, 201, 4, 10, 86, 65, 77, 65, 71, - 79, 77, 85, 75, 72, 2, 21, 3, 78, 84, 65, 2, 21, 3, 82, 71, 79, 2, 11, - 77, 2, 147, 9, 85, 2, 175, 249, 1, 82, 2, 33, 6, 73, 72, 86, 65, 77, 85, - 2, 151, 3, 76, 2, 143, 185, 2, 65, 8, 144, 1, 15, 69, 86, 69, 82, 83, 69, - 68, 32, 86, 73, 83, 65, 82, 71, 65, 36, 9, 79, 84, 65, 84, 69, 68, 32, - 65, 82, 57, 5, 84, 72, 65, 78, 71, 4, 11, 32, 4, 202, 6, 65, 23, 85, 2, - 25, 4, 68, 72, 65, 86, 2, 141, 247, 1, 2, 73, 83, 2, 17, 2, 32, 76, 2, - 21, 3, 79, 78, 71, 2, 169, 244, 1, 2, 32, 65, 2, 239, 181, 2, 65, 2, 37, - 7, 80, 65, 68, 72, 77, 65, 78, 2, 239, 181, 2, 73, 10, 40, 3, 65, 78, 85, - 2, 85, 163, 9, 83, 4, 25, 4, 68, 65, 84, 84, 4, 11, 65, 5, 25, 4, 32, 87, - 73, 84, 2, 11, 72, 2, 11, 32, 2, 11, 84, 2, 211, 87, 65, 38, 128, 2, 5, - 67, 65, 78, 68, 82, 16, 2, 68, 79, 96, 2, 75, 65, 136, 1, 4, 80, 82, 69, - 78, 16, 2, 82, 73, 106, 84, 164, 1, 11, 89, 65, 74, 85, 82, 86, 69, 68, - 73, 67, 32, 180, 1, 12, 65, 84, 72, 65, 82, 86, 65, 86, 69, 68, 73, 67, - 253, 234, 1, 2, 83, 72, 4, 251, 18, 65, 6, 40, 5, 85, 66, 76, 69, 32, - 191, 3, 84, 4, 22, 82, 211, 5, 83, 2, 11, 73, 2, 251, 1, 78, 4, 56, 3, - 82, 83, 72, 17, 7, 84, 72, 65, 75, 65, 32, 65, 2, 203, 117, 65, 2, 17, 2, - 78, 85, 2, 17, 2, 68, 65, 2, 223, 142, 2, 84, 2, 239, 53, 75, 4, 82, 78, - 237, 2, 15, 71, 86, 69, 68, 73, 67, 32, 75, 65, 83, 72, 77, 73, 82, 73, - 2, 175, 181, 1, 71, 6, 42, 72, 24, 4, 82, 73, 80, 76, 19, 87, 2, 49, 3, - 82, 69, 69, 2, 219, 2, 69, 2, 11, 79, 2, 25, 4, 32, 68, 79, 84, 2, 11, - 83, 2, 11, 32, 2, 159, 15, 66, 8, 176, 1, 10, 65, 71, 71, 82, 65, 86, 65, - 84, 69, 68, 22, 73, 105, 27, 75, 65, 84, 72, 65, 75, 65, 32, 73, 78, 68, - 69, 80, 69, 78, 68, 69, 78, 84, 32, 83, 86, 65, 82, 73, 84, 65, 2, 17, 2, - 32, 73, 2, 49, 10, 78, 68, 69, 80, 69, 78, 68, 69, 78, 84, 2, 17, 2, 32, - 83, 2, 145, 138, 2, 3, 86, 65, 82, 5, 241, 10, 7, 32, 83, 67, 72, 82, 79, - 69, 104, 62, 83, 16, 6, 84, 73, 67, 65, 76, 32, 173, 17, 2, 89, 32, 2, - 223, 89, 73, 76, 200, 2, 4, 66, 65, 82, 32, 174, 3, 67, 42, 69, 62, 70, - 38, 71, 32, 11, 73, 68, 69, 79, 71, 82, 65, 80, 72, 73, 67, 48, 12, 75, - 65, 78, 65, 32, 82, 69, 80, 69, 65, 84, 32, 254, 1, 76, 186, 3, 77, 88, - 17, 79, 78, 69, 32, 69, 73, 71, 72, 84, 72, 32, 66, 76, 79, 67, 75, 45, - 62, 82, 158, 1, 84, 218, 1, 90, 237, 73, 3, 83, 73, 88, 8, 108, 6, 66, - 69, 83, 73, 68, 69, 64, 8, 68, 79, 85, 66, 76, 69, 32, 76, 20, 4, 84, 82, - 73, 80, 143, 1, 87, 2, 17, 2, 32, 82, 2, 21, 3, 73, 71, 72, 2, 223, 130, - 1, 84, 2, 69, 2, 69, 70, 2, 25, 4, 76, 69, 32, 82, 2, 21, 3, 73, 71, 72, - 2, 11, 84, 2, 29, 5, 32, 84, 85, 82, 78, 2, 11, 83, 2, 11, 84, 2, 139, - 130, 1, 73, 2, 21, 3, 73, 84, 72, 2, 17, 2, 32, 72, 2, 221, 247, 1, 7, - 79, 82, 73, 90, 79, 78, 84, 2, 225, 238, 1, 5, 65, 80, 65, 67, 73, 2, 25, - 4, 76, 76, 73, 80, 2, 11, 83, 2, 171, 233, 1, 73, 2, 11, 79, 2, 141, 84, - 2, 85, 82, 2, 177, 159, 1, 3, 79, 45, 75, 2, 17, 2, 32, 73, 2, 217, 188, - 1, 2, 84, 69, 10, 120, 4, 77, 65, 82, 75, 45, 22, 87, 73, 84, 72, 32, 86, - 79, 73, 67, 69, 68, 32, 83, 79, 85, 78, 68, 32, 77, 65, 82, 75, 7, 11, - 32, 4, 50, 85, 21, 3, 76, 79, 87, 5, 17, 2, 32, 85, 2, 17, 2, 80, 80, 2, - 17, 2, 69, 82, 2, 133, 30, 2, 32, 72, 16, 30, 65, 33, 3, 73, 78, 69, 2, - 11, 68, 2, 235, 229, 1, 68, 15, 11, 32, 12, 38, 69, 49, 5, 87, 73, 84, - 72, 32, 2, 25, 4, 88, 84, 69, 78, 2, 175, 210, 1, 83, 10, 60, 5, 67, 73, - 82, 67, 76, 86, 70, 26, 84, 215, 141, 1, 77, 4, 11, 69, 4, 11, 32, 4, 26, - 66, 131, 165, 1, 65, 2, 11, 69, 2, 183, 133, 1, 76, 2, 57, 3, 79, 85, 82, - 2, 11, 72, 2, 21, 3, 82, 69, 69, 2, 45, 9, 32, 84, 73, 67, 75, 32, 77, - 65, 82, 2, 131, 227, 1, 75, 2, 65, 14, 65, 76, 69, 32, 87, 73, 84, 72, - 32, 83, 84, 82, 79, 75, 2, 135, 153, 1, 69, 12, 242, 159, 2, 50, 2, 51, - 2, 52, 2, 53, 2, 54, 3, 55, 4, 42, 65, 57, 6, 69, 83, 73, 83, 84, 79, 2, - 25, 4, 67, 73, 78, 71, 2, 11, 32, 2, 167, 123, 67, 2, 21, 3, 82, 32, 83, - 2, 11, 69, 2, 251, 218, 1, 71, 10, 32, 2, 65, 66, 106, 73, 19, 82, 6, 18, - 32, 35, 85, 2, 11, 75, 2, 143, 140, 2, 69, 4, 33, 6, 76, 65, 84, 73, 79, - 78, 5, 239, 46, 32, 2, 155, 10, 76, 2, 29, 5, 65, 70, 70, 73, 67, 2, 141, - 242, 1, 2, 32, 76, 2, 177, 108, 4, 73, 71, 90, 65, 26, 80, 6, 72, 69, 65, - 86, 89, 32, 176, 5, 3, 77, 85, 67, 229, 10, 3, 66, 79, 76, 20, 62, 69, - 190, 1, 70, 38, 82, 82, 83, 246, 1, 87, 203, 11, 71, 4, 25, 4, 73, 71, - 72, 84, 4, 11, 32, 4, 22, 80, 223, 2, 83, 2, 25, 4, 79, 73, 78, 84, 2, - 17, 2, 69, 68, 2, 17, 2, 32, 66, 2, 25, 4, 76, 65, 67, 75, 2, 11, 32, 2, - 151, 81, 83, 2, 11, 73, 2, 185, 1, 2, 86, 69, 2, 11, 69, 2, 29, 5, 86, - 69, 82, 83, 69, 2, 17, 2, 32, 83, 2, 231, 1, 79, 6, 30, 65, 42, 73, 147, - 1, 79, 2, 11, 76, 2, 11, 84, 2, 235, 117, 73, 2, 11, 88, 2, 11, 32, 2, - 11, 83, 2, 21, 3, 80, 79, 75, 2, 17, 2, 69, 68, 2, 11, 32, 2, 11, 65, 2, - 11, 83, 2, 149, 80, 3, 84, 69, 82, 2, 161, 14, 3, 76, 73, 68, 4, 21, 3, - 72, 73, 84, 4, 11, 69, 4, 11, 32, 4, 162, 66, 67, 187, 49, 83, 4, 11, 72, - 4, 11, 32, 4, 18, 71, 39, 76, 2, 69, 6, 82, 69, 65, 84, 69, 82, 2, 11, - 69, 2, 11, 83, 2, 11, 83, 2, 17, 2, 45, 84, 2, 251, 72, 72, 4, 11, 65, 5, - 11, 32, 2, 11, 70, 2, 21, 3, 79, 82, 77, 2, 17, 2, 32, 84, 2, 195, 245, - 1, 87, 162, 1, 156, 1, 9, 66, 82, 65, 84, 73, 79, 78, 32, 77, 32, 4, 67, - 84, 79, 82, 36, 3, 68, 69, 79, 126, 69, 222, 1, 79, 22, 82, 21, 7, 84, - 72, 75, 85, 81, 73, 32, 2, 11, 79, 2, 159, 252, 1, 68, 4, 170, 130, 1, - 89, 255, 141, 1, 73, 6, 30, 32, 77, 3, 67, 65, 83, 4, 18, 67, 43, 71, 2, - 17, 2, 65, 77, 2, 179, 205, 1, 69, 2, 239, 119, 65, 2, 167, 72, 83, 6, - 168, 1, 31, 84, 78, 65, 77, 69, 83, 69, 32, 65, 76, 84, 69, 82, 78, 65, - 84, 69, 32, 82, 69, 65, 68, 73, 78, 71, 32, 77, 65, 82, 75, 32, 161, 109, - 5, 87, 68, 65, 84, 65, 4, 26, 78, 195, 141, 2, 67, 2, 215, 129, 1, 72, 2, - 143, 144, 1, 76, 2, 219, 240, 1, 71, 140, 1, 56, 6, 67, 65, 80, 73, 84, - 65, 1, 4, 83, 77, 65, 76, 70, 45, 9, 76, 32, 76, 69, 84, 84, 69, 82, 32, - 70, 230, 1, 66, 34, 69, 22, 73, 22, 76, 34, 78, 222, 139, 1, 67, 2, 68, - 2, 83, 2, 84, 226, 56, 72, 238, 48, 70, 2, 74, 2, 77, 2, 80, 2, 82, 2, - 86, 2, 88, 2, 90, 158, 20, 71, 2, 75, 2, 81, 186, 2, 65, 2, 79, 2, 85, 3, - 89, 4, 142, 246, 1, 66, 215, 22, 69, 5, 195, 140, 2, 73, 5, 219, 245, 1, - 74, 4, 226, 137, 2, 76, 187, 2, 65, 4, 166, 245, 1, 74, 215, 22, 69, 8, - 28, 3, 73, 68, 69, 59, 76, 2, 21, 3, 68, 32, 71, 2, 225, 71, 4, 82, 69, - 69, 75, 6, 46, 67, 20, 3, 76, 69, 89, 41, 2, 85, 77, 2, 195, 225, 1, 65, - 2, 11, 66, 2, 11, 65, 2, 215, 126, 76, 2, 11, 69, 2, 17, 2, 32, 73, 2, - 141, 126, 4, 78, 84, 69, 71, 5, 215, 137, 2, 83, 40, 70, 67, 45, 13, 71, - 65, 82, 32, 70, 82, 65, 67, 84, 73, 79, 78, 32, 2, 11, 65, 2, 11, 78, 2, - 135, 203, 1, 85, 38, 106, 70, 96, 4, 79, 78, 69, 32, 178, 2, 84, 80, 7, - 83, 69, 86, 69, 78, 32, 69, 153, 33, 3, 90, 69, 82, 6, 56, 4, 73, 86, 69, - 32, 253, 3, 5, 79, 85, 82, 32, 70, 4, 162, 3, 69, 113, 3, 83, 73, 88, 18, - 66, 69, 28, 2, 70, 73, 18, 72, 34, 78, 14, 81, 30, 83, 55, 84, 2, 197, 1, - 3, 73, 71, 72, 2, 171, 1, 70, 2, 11, 65, 2, 227, 132, 1, 76, 2, 111, 73, - 2, 217, 75, 3, 85, 65, 82, 4, 24, 2, 69, 86, 15, 73, 2, 43, 69, 2, 43, - 88, 4, 18, 69, 35, 72, 2, 11, 78, 2, 231, 131, 2, 84, 2, 243, 107, 73, - 10, 48, 5, 72, 82, 69, 69, 32, 93, 3, 87, 79, 32, 6, 26, 69, 26, 81, 67, - 70, 2, 109, 3, 73, 71, 72, 2, 21, 3, 85, 65, 82, 2, 215, 114, 84, 4, 22, - 70, 219, 32, 84, 2, 11, 73, 2, 11, 70, 2, 181, 197, 1, 2, 84, 72, 168, 6, - 86, 65, 250, 23, 69, 158, 3, 72, 222, 69, 73, 234, 8, 79, 238, 5, 82, - 219, 146, 1, 74, 204, 2, 114, 70, 18, 78, 220, 5, 2, 88, 73, 158, 1, 82, - 210, 10, 84, 194, 1, 86, 197, 155, 1, 6, 83, 84, 69, 66, 65, 83, 2, 231, - 90, 70, 122, 36, 4, 67, 72, 79, 32, 183, 5, 73, 118, 100, 7, 76, 69, 84, - 84, 69, 82, 32, 252, 3, 3, 78, 71, 85, 16, 5, 84, 79, 78, 69, 32, 243, 7, - 68, 88, 210, 1, 65, 38, 79, 34, 69, 22, 73, 22, 76, 50, 78, 42, 84, 50, - 85, 22, 89, 234, 180, 1, 75, 2, 80, 2, 83, 138, 69, 66, 2, 67, 2, 68, 2, - 70, 2, 71, 2, 72, 2, 74, 2, 77, 2, 82, 2, 86, 2, 87, 3, 90, 13, 34, 65, - 186, 253, 1, 78, 87, 85, 7, 11, 78, 5, 255, 253, 1, 71, 5, 235, 253, 1, - 78, 5, 131, 253, 1, 78, 4, 26, 76, 171, 253, 1, 65, 2, 239, 250, 1, 72, - 6, 218, 250, 1, 71, 2, 89, 187, 2, 65, 8, 178, 250, 1, 72, 2, 82, 2, 83, - 187, 2, 65, 5, 219, 172, 1, 69, 4, 150, 251, 1, 73, 147, 1, 65, 2, 135, - 117, 78, 8, 40, 3, 75, 79, 73, 1, 3, 84, 85, 80, 5, 243, 231, 1, 78, 4, - 21, 3, 78, 71, 32, 4, 76, 8, 67, 82, 69, 83, 67, 69, 78, 84, 1, 7, 71, - 73, 66, 66, 79, 85, 83, 2, 21, 3, 32, 77, 79, 2, 11, 79, 2, 231, 100, 78, - 170, 1, 72, 9, 65, 78, 71, 32, 67, 73, 84, 73, 32, 205, 114, 4, 78, 73, - 78, 71, 168, 1, 128, 1, 6, 67, 65, 80, 73, 84, 65, 0, 4, 83, 77, 65, 76, - 190, 4, 68, 156, 2, 7, 78, 85, 77, 66, 69, 82, 32, 151, 225, 1, 79, 64, - 45, 9, 76, 32, 76, 69, 84, 84, 69, 82, 32, 64, 174, 1, 65, 38, 69, 42, - 72, 74, 78, 50, 79, 22, 83, 50, 85, 30, 89, 174, 43, 84, 208, 112, 2, 86, - 73, 222, 51, 66, 2, 80, 246, 5, 75, 158, 11, 73, 2, 87, 162, 17, 68, 3, - 71, 9, 142, 246, 1, 78, 86, 77, 3, 84, 7, 11, 78, 4, 178, 246, 1, 78, 3, - 89, 8, 38, 79, 174, 157, 1, 73, 235, 31, 65, 4, 146, 189, 1, 82, 235, 25, - 76, 4, 26, 71, 191, 164, 1, 85, 2, 251, 242, 1, 65, 5, 255, 174, 1, 68, - 4, 26, 83, 155, 225, 1, 73, 2, 135, 208, 1, 85, 4, 218, 244, 1, 67, 3, - 85, 8, 34, 85, 158, 244, 1, 65, 3, 79, 5, 155, 244, 1, 74, 20, 11, 73, - 20, 11, 71, 20, 17, 2, 73, 84, 20, 11, 32, 20, 66, 70, 30, 83, 42, 84, - 62, 90, 210, 86, 78, 14, 79, 227, 112, 69, 4, 182, 118, 73, 131, 4, 79, - 4, 22, 69, 155, 100, 73, 2, 211, 28, 86, 4, 26, 72, 187, 211, 1, 87, 2, - 11, 82, 2, 203, 219, 1, 69, 2, 11, 69, 2, 139, 211, 1, 82, 18, 42, 69, - 30, 70, 42, 78, 38, 83, 39, 84, 2, 221, 1, 3, 73, 71, 72, 4, 22, 73, 139, - 1, 79, 2, 171, 1, 70, 2, 17, 2, 73, 78, 2, 135, 1, 69, 4, 92, 2, 69, 86, - 25, 2, 73, 88, 6, 34, 72, 26, 87, 155, 160, 1, 69, 2, 11, 73, 2, 35, 82, - 2, 11, 69, 2, 11, 78, 2, 151, 222, 1, 84, 12, 32, 2, 69, 82, 155, 238, 1, - 67, 10, 34, 32, 141, 159, 1, 2, 77, 69, 8, 80, 3, 67, 76, 79, 22, 87, - 204, 203, 1, 5, 66, 85, 70, 70, 65, 1, 2, 80, 79, 2, 151, 185, 1, 83, 2, - 199, 113, 65, 20, 60, 2, 69, 32, 124, 4, 73, 78, 71, 32, 161, 1, 2, 89, - 32, 6, 182, 2, 68, 137, 192, 1, 23, 65, 82, 82, 79, 87, 32, 80, 79, 73, - 78, 84, 73, 78, 71, 32, 68, 73, 82, 69, 67, 84, 76, 89, 6, 64, 5, 66, 76, - 65, 67, 75, 0, 5, 87, 72, 73, 84, 69, 55, 72, 2, 17, 2, 32, 70, 2, 11, - 76, 2, 151, 235, 1, 65, 2, 11, 65, 2, 11, 78, 2, 191, 100, 68, 8, 26, 68, - 34, 76, 43, 79, 2, 11, 65, 2, 247, 233, 1, 83, 4, 22, 79, 175, 79, 73, 2, - 135, 79, 87, 2, 11, 86, 2, 11, 69, 2, 235, 78, 82, 14, 48, 3, 65, 82, 89, - 70, 68, 70, 73, 171, 1, 83, 4, 11, 32, 4, 32, 2, 67, 65, 187, 172, 1, 70, - 2, 159, 172, 1, 84, 4, 26, 71, 143, 152, 1, 68, 2, 229, 70, 6, 69, 45, + 255, 18, 69, 2, 11, 69, 2, 45, 9, 78, 32, 72, 79, 76, 68, 73, 78, 71, 2, + 11, 32, 2, 11, 72, 2, 11, 65, 2, 219, 225, 1, 78, 2, 45, 9, 32, 72, 79, + 82, 73, 90, 79, 78, 84, 2, 11, 65, 2, 167, 163, 3, 76, 2, 49, 10, 80, 69, + 69, 67, 72, 32, 66, 85, 66, 66, 2, 139, 176, 2, 76, 6, 42, 69, 157, 172, + 1, 4, 76, 73, 78, 69, 2, 11, 77, 2, 149, 215, 1, 2, 32, 68, 250, 3, 176, + 1, 7, 65, 69, 32, 68, 73, 82, 72, 32, 8, 71, 65, 82, 73, 84, 73, 67, 32, + 152, 6, 7, 77, 66, 82, 69, 76, 76, 65, 166, 1, 78, 158, 8, 80, 230, 167, + 1, 82, 151, 140, 2, 83, 2, 11, 65, 2, 227, 188, 2, 77, 62, 48, 7, 76, 69, + 84, 84, 69, 82, 32, 159, 5, 87, 60, 206, 1, 65, 28, 2, 81, 79, 22, 66, + 22, 68, 50, 71, 44, 2, 72, 79, 22, 75, 34, 76, 32, 2, 82, 65, 22, 83, 74, + 84, 74, 89, 22, 90, 242, 189, 2, 78, 202, 91, 80, 246, 5, 87, 202, 12, + 77, 174, 18, 73, 3, 85, 4, 26, 76, 211, 241, 2, 73, 2, 247, 190, 3, 80, + 2, 207, 156, 3, 69, 4, 26, 69, 147, 181, 2, 72, 2, 159, 156, 3, 76, 4, + 174, 145, 2, 72, 145, 141, 1, 2, 65, 77, 5, 243, 189, 3, 84, 4, 242, 190, + 2, 65, 239, 126, 72, 2, 11, 65, 2, 231, 154, 3, 77, 2, 151, 191, 1, 83, + 8, 38, 65, 202, 191, 2, 72, 239, 90, 83, 4, 198, 168, 3, 68, 239, 13, 77, + 6, 38, 72, 170, 162, 3, 69, 175, 28, 79, 2, 11, 65, 2, 171, 253, 1, 78, + 2, 147, 248, 2, 79, 4, 210, 153, 3, 69, 207, 36, 85, 2, 21, 3, 79, 82, + 68, 2, 25, 4, 32, 68, 73, 86, 2, 191, 150, 1, 73, 7, 11, 32, 4, 84, 4, + 79, 78, 32, 71, 45, 13, 87, 73, 84, 72, 32, 82, 65, 73, 78, 32, 68, 82, + 79, 2, 11, 82, 2, 11, 79, 2, 167, 172, 2, 85, 2, 203, 254, 2, 80, 32, + 160, 1, 3, 65, 77, 85, 20, 7, 67, 69, 82, 84, 65, 73, 78, 34, 68, 62, 73, + 245, 5, 18, 77, 65, 82, 82, 73, 69, 68, 32, 80, 65, 82, 84, 78, 69, 82, + 83, 72, 73, 2, 251, 167, 2, 83, 2, 11, 84, 2, 207, 179, 2, 89, 4, 26, 69, + 223, 164, 2, 79, 2, 11, 82, 2, 227, 158, 3, 84, 22, 60, 2, 79, 78, 234, + 3, 84, 106, 86, 189, 58, 3, 67, 79, 82, 15, 11, 32, 12, 160, 1, 6, 65, + 66, 79, 86, 69, 32, 108, 22, 66, 69, 83, 73, 68, 69, 32, 65, 78, 68, 32, + 74, 79, 73, 78, 69, 68, 32, 87, 73, 84, 72, 41, 5, 87, 73, 84, 72, 32, 4, + 52, 9, 66, 65, 82, 32, 65, 66, 79, 86, 69, 23, 73, 2, 17, 2, 32, 73, 2, + 173, 49, 4, 78, 84, 69, 82, 2, 17, 2, 32, 85, 2, 203, 230, 2, 78, 6, 66, + 77, 58, 79, 153, 253, 2, 8, 76, 79, 71, 73, 67, 65, 76, 32, 2, 11, 73, 2, + 11, 78, 2, 11, 85, 2, 147, 175, 2, 83, 2, 11, 86, 2, 233, 145, 2, 2, 69, + 82, 4, 18, 32, 67, 69, 2, 11, 83, 2, 17, 2, 69, 80, 2, 11, 65, 2, 151, + 252, 2, 82, 2, 191, 159, 2, 68, 2, 57, 12, 69, 82, 83, 65, 76, 32, 82, + 69, 67, 89, 67, 76, 2, 17, 2, 73, 78, 2, 219, 158, 2, 71, 2, 199, 158, 2, + 80, 144, 3, 130, 1, 32, 130, 8, 45, 180, 8, 4, 80, 69, 82, 32, 136, 40, + 8, 83, 73, 68, 69, 45, 68, 79, 87, 21, 6, 87, 65, 82, 68, 83, 32, 38, + 140, 1, 5, 65, 82, 82, 79, 87, 224, 1, 5, 66, 65, 82, 66, 32, 228, 1, 5, + 68, 79, 87, 78, 32, 210, 1, 70, 30, 82, 93, 4, 84, 65, 67, 75, 8, 64, 4, + 72, 69, 65, 68, 153, 51, 7, 32, 84, 72, 82, 79, 85, 71, 7, 11, 32, 4, + 112, 22, 66, 69, 84, 87, 69, 69, 78, 32, 84, 87, 79, 32, 72, 79, 82, 73, + 90, 79, 78, 84, 65, 76, 235, 160, 2, 73, 2, 153, 153, 2, 2, 32, 66, 8, + 44, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, 4, 57, 12, 84, 32, 68, 79, 87, + 78, 32, 66, 65, 82, 66, 32, 4, 44, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, + 2, 11, 84, 2, 25, 4, 32, 72, 65, 82, 2, 11, 80, 2, 195, 222, 2, 79, 14, + 76, 5, 65, 82, 82, 79, 87, 62, 66, 38, 68, 18, 83, 134, 59, 87, 219, 9, + 84, 5, 37, 7, 32, 87, 73, 84, 72, 32, 66, 2, 255, 161, 2, 65, 2, 253, + 143, 2, 4, 76, 65, 67, 75, 2, 207, 59, 79, 2, 195, 65, 65, 2, 11, 73, 2, + 251, 112, 83, 2, 53, 11, 73, 71, 72, 84, 32, 68, 73, 65, 71, 79, 78, 2, + 145, 129, 1, 4, 65, 76, 32, 69, 5, 29, 5, 32, 87, 73, 84, 72, 2, 17, 2, + 32, 67, 2, 25, 4, 73, 82, 67, 76, 2, 255, 173, 2, 69, 32, 58, 70, 225, 1, + 9, 80, 79, 73, 78, 84, 73, 78, 71, 32, 4, 41, 8, 65, 67, 73, 78, 71, 32, + 83, 78, 4, 65, 14, 65, 75, 69, 32, 72, 69, 65, 68, 32, 87, 73, 84, 72, + 32, 4, 42, 79, 25, 6, 67, 76, 79, 83, 69, 68, 2, 21, 3, 80, 69, 78, 2, + 21, 3, 32, 77, 79, 2, 215, 160, 1, 85, 28, 130, 1, 65, 86, 69, 62, 70, + 20, 8, 77, 73, 76, 73, 84, 65, 82, 89, 26, 82, 88, 6, 83, 77, 65, 76, 76, + 32, 118, 84, 199, 122, 71, 4, 22, 84, 159, 2, 73, 2, 37, 7, 79, 77, 73, + 67, 32, 66, 79, 2, 147, 230, 1, 77, 2, 29, 5, 78, 69, 82, 71, 89, 2, 165, + 181, 1, 2, 32, 87, 2, 223, 165, 3, 82, 2, 129, 1, 2, 32, 65, 8, 64, 5, + 79, 67, 75, 69, 84, 118, 69, 178, 130, 1, 65, 243, 29, 73, 2, 191, 208, + 2, 32, 4, 18, 65, 67, 82, 2, 11, 73, 2, 11, 82, 2, 17, 2, 80, 76, 2, 203, + 137, 2, 65, 2, 11, 69, 2, 147, 253, 1, 68, 4, 37, 7, 82, 73, 65, 78, 71, + 76, 69, 4, 11, 32, 4, 11, 87, 4, 25, 4, 73, 84, 72, 32, 4, 18, 76, 27, + 82, 2, 11, 69, 2, 35, 70, 2, 21, 3, 73, 71, 72, 2, 11, 84, 2, 17, 2, 32, + 72, 2, 21, 3, 65, 76, 70, 2, 17, 2, 32, 66, 2, 11, 76, 2, 139, 240, 1, + 65, 200, 1, 192, 1, 4, 65, 78, 68, 32, 210, 2, 66, 74, 67, 74, 70, 36, 5, + 72, 65, 76, 70, 32, 200, 4, 5, 76, 69, 70, 84, 32, 254, 5, 77, 150, 2, + 79, 60, 6, 82, 73, 71, 72, 84, 32, 238, 17, 83, 67, 84, 8, 34, 76, 53, 4, + 82, 73, 71, 72, 6, 48, 2, 69, 70, 173, 1, 5, 79, 87, 69, 82, 32, 2, 53, + 11, 84, 32, 65, 78, 68, 32, 76, 79, 87, 69, 82, 2, 205, 35, 25, 32, 84, + 82, 73, 65, 78, 71, 85, 76, 65, 82, 32, 84, 72, 82, 69, 69, 32, 81, 85, + 65, 82, 84, 69, 82, 4, 28, 2, 84, 82, 235, 39, 79, 2, 225, 4, 7, 73, 65, + 78, 71, 85, 76, 65, 2, 17, 2, 76, 65, 2, 17, 2, 68, 69, 2, 241, 225, 1, + 3, 32, 83, 67, 10, 33, 6, 69, 78, 84, 82, 69, 32, 10, 174, 12, 76, 22, + 82, 255, 21, 79, 2, 17, 2, 73, 86, 2, 183, 31, 69, 20, 140, 1, 5, 66, 76, + 79, 67, 75, 110, 72, 32, 8, 73, 78, 86, 69, 82, 83, 69, 32, 198, 1, 86, + 174, 26, 77, 130, 3, 76, 22, 82, 171, 164, 1, 67, 5, 229, 28, 23, 32, 65, + 78, 68, 32, 76, 79, 87, 69, 82, 32, 72, 65, 76, 70, 32, 73, 78, 86, 69, + 82, 83, 69, 2, 225, 18, 4, 69, 65, 86, 89, 4, 100, 21, 77, 69, 68, 73, + 85, 77, 32, 83, 72, 65, 68, 69, 32, 65, 78, 68, 32, 76, 79, 87, 69, 51, + 87, 2, 11, 82, 2, 189, 35, 5, 32, 72, 65, 76, 70, 2, 21, 3, 72, 73, 84, + 2, 227, 193, 1, 69, 2, 29, 5, 69, 82, 84, 73, 67, 2, 153, 116, 14, 65, + 76, 32, 76, 73, 78, 69, 32, 87, 73, 84, 72, 32, 84, 62, 50, 66, 238, 3, + 67, 54, 79, 74, 84, 183, 13, 81, 22, 65, 14, 76, 79, 67, 75, 32, 68, 73, + 65, 71, 79, 78, 65, 76, 32, 22, 144, 1, 6, 76, 79, 87, 69, 82, 32, 233, + 8, 24, 85, 80, 80, 69, 82, 32, 77, 73, 68, 68, 76, 69, 32, 76, 69, 70, + 84, 32, 84, 79, 32, 85, 80, 80, 18, 176, 1, 10, 67, 69, 78, 84, 82, 69, + 32, 84, 79, 32, 36, 8, 76, 69, 70, 84, 32, 84, 79, 32, 229, 10, 18, 77, + 73, 68, 68, 76, 69, 32, 76, 69, 70, 84, 32, 84, 79, 32, 85, 80, 80, 6, + 70, 76, 253, 8, 3, 85, 80, 80, 6, 34, 76, 213, 9, 3, 85, 80, 80, 2, 149, + 10, 2, 79, 87, 2, 29, 5, 79, 82, 78, 69, 82, 2, 151, 237, 1, 32, 4, 182, + 12, 78, 53, 12, 82, 32, 76, 79, 87, 69, 82, 32, 82, 73, 71, 72, 8, 34, + 79, 170, 19, 82, 155, 1, 87, 2, 241, 18, 11, 32, 76, 79, 87, 69, 82, 32, + 82, 73, 71, 72, 12, 33, 6, 73, 68, 68, 76, 69, 32, 12, 52, 7, 67, 69, 78, + 84, 82, 69, 32, 74, 76, 23, 82, 4, 44, 3, 76, 69, 70, 1, 4, 82, 73, 71, + 72, 2, 117, 3, 84, 32, 79, 4, 41, 2, 69, 70, 4, 21, 3, 73, 71, 72, 4, 17, + 2, 84, 32, 4, 30, 79, 129, 18, 2, 84, 87, 2, 139, 9, 78, 4, 11, 78, 4, + 17, 2, 69, 32, 4, 154, 21, 81, 147, 4, 69, 68, 84, 2, 66, 76, 186, 6, 68, + 114, 79, 222, 1, 80, 42, 81, 224, 4, 2, 83, 72, 51, 84, 22, 61, 13, 79, + 67, 75, 32, 68, 73, 65, 71, 79, 78, 65, 76, 32, 22, 140, 1, 24, 76, 79, + 87, 69, 82, 32, 77, 73, 68, 68, 76, 69, 32, 76, 69, 70, 84, 32, 84, 79, + 32, 76, 79, 87, 57, 6, 85, 80, 80, 69, 82, 32, 4, 21, 3, 69, 82, 32, 4, + 246, 3, 67, 215, 222, 2, 82, 18, 176, 1, 10, 67, 69, 78, 84, 82, 69, 32, + 84, 79, 32, 92, 8, 76, 69, 70, 84, 32, 84, 79, 32, 141, 1, 18, 77, 73, + 68, 68, 76, 69, 32, 76, 69, 70, 84, 32, 84, 79, 32, 76, 79, 87, 6, 32, 3, + 76, 79, 87, 139, 1, 85, 4, 21, 3, 69, 82, 32, 4, 142, 2, 77, 175, 222, 2, + 82, 6, 28, 3, 76, 79, 87, 51, 85, 4, 21, 3, 69, 82, 32, 4, 142, 1, 67, + 43, 77, 2, 17, 2, 80, 80, 2, 17, 2, 69, 82, 2, 117, 2, 32, 77, 6, 21, 3, + 69, 82, 32, 6, 34, 67, 42, 77, 175, 222, 2, 82, 2, 11, 69, 2, 153, 230, + 1, 2, 78, 84, 2, 25, 4, 73, 68, 68, 76, 2, 175, 178, 1, 69, 2, 57, 12, + 82, 79, 80, 45, 83, 72, 65, 68, 79, 87, 69, 68, 2, 17, 2, 32, 87, 2, 141, + 193, 1, 3, 72, 73, 84, 4, 62, 78, 53, 11, 82, 32, 76, 79, 87, 69, 82, 32, + 76, 69, 70, 2, 229, 16, 9, 69, 32, 83, 73, 88, 84, 69, 69, 78, 2, 69, 15, + 84, 32, 67, 85, 82, 76, 89, 32, 66, 82, 65, 67, 75, 69, 84, 2, 11, 32, 2, + 171, 181, 2, 83, 2, 11, 69, 2, 145, 163, 1, 2, 78, 67, 26, 17, 2, 85, 65, + 26, 44, 6, 68, 82, 65, 78, 84, 32, 255, 3, 82, 24, 90, 67, 112, 10, 70, + 65, 67, 69, 32, 87, 73, 84, 72, 32, 114, 77, 76, 2, 83, 84, 67, 84, 14, + 68, 7, 73, 82, 67, 85, 76, 65, 82, 177, 169, 1, 4, 72, 69, 83, 83, 2, 17, + 2, 32, 65, 2, 139, 217, 1, 82, 4, 34, 67, 45, 4, 79, 80, 69, 78, 2, 21, + 3, 76, 79, 83, 2, 17, 2, 69, 68, 2, 241, 236, 1, 3, 32, 69, 89, 2, 25, 4, + 73, 67, 82, 79, 2, 11, 67, 2, 157, 197, 1, 4, 79, 77, 80, 85, 2, 41, 8, + 65, 78, 68, 73, 78, 71, 32, 75, 2, 143, 215, 2, 78, 2, 21, 3, 69, 76, 69, + 2, 11, 86, 2, 139, 91, 73, 2, 213, 169, 1, 3, 84, 69, 82, 4, 233, 102, 8, + 65, 68, 79, 87, 69, 68, 32, 87, 8, 30, 79, 106, 82, 155, 1, 87, 2, 49, + 10, 32, 76, 79, 87, 69, 82, 32, 76, 69, 70, 2, 11, 84, 2, 11, 32, 2, 11, + 70, 2, 135, 114, 73, 4, 25, 4, 73, 65, 78, 71, 4, 40, 4, 85, 76, 65, 82, + 167, 232, 2, 76, 2, 17, 2, 32, 77, 2, 41, 8, 69, 68, 73, 85, 77, 32, 83, + 72, 2, 163, 104, 65, 2, 21, 3, 69, 76, 70, 2, 11, 84, 2, 195, 166, 1, 72, + 2, 17, 2, 69, 86, 2, 17, 2, 69, 78, 2, 145, 1, 2, 32, 69, 10, 64, 5, 72, + 82, 69, 69, 32, 193, 1, 6, 82, 73, 65, 78, 71, 85, 8, 54, 69, 49, 9, 81, + 85, 65, 82, 84, 69, 82, 83, 32, 2, 29, 5, 73, 71, 72, 84, 72, 2, 243, 5, + 83, 6, 30, 76, 22, 82, 203, 5, 66, 2, 41, 2, 69, 70, 2, 21, 3, 73, 71, + 72, 2, 43, 84, 2, 17, 2, 76, 65, 2, 11, 82, 2, 17, 2, 32, 79, 2, 25, 4, + 78, 69, 32, 81, 2, 185, 4, 6, 85, 65, 82, 84, 69, 82, 2, 147, 189, 2, 78, + 128, 1, 154, 1, 65, 184, 6, 2, 66, 76, 150, 1, 68, 50, 70, 82, 72, 150, + 4, 67, 46, 81, 42, 82, 22, 83, 102, 84, 146, 7, 80, 173, 3, 6, 87, 72, + 73, 84, 69, 32, 32, 34, 78, 33, 4, 82, 82, 79, 87, 2, 11, 67, 2, 143, + 180, 2, 79, 31, 11, 32, 28, 134, 1, 65, 192, 1, 14, 76, 69, 70, 84, 87, + 65, 82, 68, 83, 32, 79, 70, 32, 68, 32, 5, 87, 73, 84, 72, 32, 210, 8, + 70, 179, 5, 84, 2, 41, 8, 78, 68, 32, 82, 73, 71, 72, 84, 2, 17, 2, 32, + 79, 2, 25, 4, 78, 69, 32, 69, 2, 21, 3, 73, 71, 72, 2, 17, 2, 84, 72, 2, + 11, 32, 2, 11, 66, 2, 11, 76, 2, 183, 195, 1, 79, 2, 205, 211, 1, 3, 79, + 87, 78, 20, 74, 68, 58, 76, 42, 77, 38, 78, 58, 83, 66, 69, 250, 12, 84, + 143, 58, 72, 2, 21, 3, 79, 85, 66, 2, 11, 76, 2, 195, 196, 2, 69, 2, 11, + 65, 2, 253, 22, 3, 82, 71, 69, 2, 225, 22, 5, 69, 68, 73, 85, 77, 2, 25, + 4, 79, 84, 67, 72, 2, 11, 69, 2, 151, 56, 68, 4, 11, 77, 4, 25, 4, 65, + 76, 76, 32, 4, 22, 69, 223, 21, 84, 2, 129, 22, 10, 81, 85, 73, 76, 65, + 84, 69, 82, 65, 76, 4, 25, 4, 65, 67, 75, 32, 4, 26, 67, 155, 213, 1, 65, + 2, 25, 4, 73, 82, 67, 76, 2, 25, 4, 69, 68, 32, 87, 2, 11, 72, 2, 237, + 14, 2, 73, 84, 4, 22, 79, 195, 13, 65, 2, 177, 14, 2, 85, 66, 2, 11, 73, + 2, 37, 7, 78, 71, 69, 82, 45, 80, 79, 2, 189, 211, 1, 2, 83, 84, 20, 88, + 17, 65, 82, 80, 79, 79, 78, 32, 87, 73, 84, 72, 32, 66, 65, 82, 66, 32, + 131, 3, 69, 16, 56, 4, 76, 69, 70, 84, 245, 1, 5, 82, 73, 71, 72, 84, 10, + 22, 32, 239, 9, 87, 8, 60, 7, 66, 69, 83, 73, 68, 69, 32, 206, 1, 70, + 179, 5, 84, 4, 40, 4, 68, 79, 87, 78, 1, 2, 85, 80, 2, 229, 151, 1, 23, + 87, 65, 82, 68, 83, 32, 72, 65, 82, 80, 79, 79, 78, 32, 87, 73, 84, 72, + 32, 66, 65, 82, 66, 6, 22, 32, 251, 7, 87, 4, 22, 70, 179, 5, 84, 2, 225, + 200, 1, 3, 82, 79, 77, 4, 25, 4, 65, 86, 89, 32, 4, 26, 67, 171, 207, 1, + 65, 2, 189, 10, 7, 79, 77, 80, 82, 69, 83, 83, 2, 137, 9, 6, 85, 65, 68, + 82, 85, 80, 2, 247, 152, 2, 79, 4, 30, 65, 53, 3, 81, 85, 65, 2, 133, + 206, 1, 8, 78, 83, 45, 83, 69, 82, 73, 70, 2, 131, 9, 82, 36, 36, 2, 82, + 73, 229, 7, 2, 87, 79, 30, 40, 5, 65, 78, 71, 76, 69, 155, 7, 80, 28, 52, + 8, 45, 72, 69, 65, 68, 69, 68, 32, 219, 12, 32, 26, 48, 5, 65, 82, 82, + 79, 87, 174, 5, 68, 39, 80, 23, 11, 32, 20, 92, 17, 76, 69, 70, 84, 87, + 65, 82, 68, 83, 32, 79, 70, 32, 68, 79, 87, 78, 98, 84, 23, 87, 2, 37, 7, + 87, 65, 82, 68, 83, 32, 84, 2, 37, 7, 82, 73, 65, 78, 71, 76, 69, 2, 219, + 5, 45, 2, 179, 195, 1, 79, 16, 25, 4, 73, 84, 72, 32, 16, 114, 66, 28, 6, + 76, 79, 78, 71, 32, 84, 130, 1, 77, 34, 78, 34, 86, 34, 72, 153, 56, 6, + 68, 79, 85, 66, 76, 69, 2, 149, 2, 3, 79, 76, 68, 4, 17, 2, 73, 80, 4, + 11, 32, 4, 34, 76, 21, 4, 82, 73, 71, 72, 2, 17, 2, 69, 70, 2, 11, 84, 2, + 11, 87, 2, 191, 127, 65, 2, 121, 5, 69, 68, 73, 85, 77, 2, 89, 5, 65, 82, + 82, 79, 87, 2, 29, 5, 69, 82, 89, 32, 72, 2, 25, 4, 69, 65, 86, 89, 2, + 169, 185, 2, 4, 32, 83, 72, 65, 2, 11, 65, 2, 249, 1, 2, 83, 72, 2, 11, + 65, 2, 25, 4, 73, 82, 69, 68, 2, 29, 5, 32, 65, 82, 82, 79, 2, 159, 165, + 2, 87, 2, 11, 76, 2, 203, 197, 1, 69, 6, 74, 32, 61, 14, 45, 72, 69, 65, + 68, 69, 68, 32, 65, 82, 82, 79, 87, 32, 2, 25, 4, 72, 69, 65, 68, 2, 11, + 69, 2, 195, 196, 1, 68, 4, 42, 87, 157, 137, 1, 4, 70, 82, 79, 77, 2, 33, + 6, 73, 84, 72, 32, 84, 82, 2, 61, 13, 73, 65, 78, 71, 76, 69, 32, 65, 82, + 82, 79, 87, 72, 2, 225, 122, 2, 69, 65, 18, 88, 5, 65, 82, 82, 79, 87, + 149, 3, 12, 68, 79, 85, 66, 76, 69, 32, 65, 82, 82, 79, 87, 15, 11, 32, + 12, 108, 11, 79, 78, 32, 80, 69, 68, 69, 83, 84, 65, 76, 106, 87, 225, + 184, 1, 8, 70, 82, 79, 77, 32, 66, 65, 82, 7, 33, 6, 32, 87, 73, 84, 72, + 32, 4, 26, 86, 179, 185, 1, 72, 2, 213, 185, 1, 5, 69, 82, 84, 73, 67, 2, + 29, 5, 73, 84, 72, 73, 78, 2, 17, 2, 32, 84, 2, 37, 7, 82, 73, 65, 78, + 71, 76, 69, 2, 11, 32, 2, 11, 65, 2, 25, 4, 82, 82, 79, 87, 2, 11, 72, 2, + 143, 150, 2, 69, 5, 45, 9, 32, 79, 78, 32, 80, 69, 68, 69, 83, 2, 155, + 208, 1, 84, 246, 15, 86, 65, 254, 16, 83, 174, 3, 69, 158, 47, 73, 202, + 8, 79, 142, 2, 84, 21, 2, 85, 76, 218, 8, 116, 2, 73, 32, 128, 16, 17, + 82, 73, 65, 84, 73, 79, 78, 32, 83, 69, 76, 69, 67, 84, 79, 82, 45, 197, + 46, 2, 77, 80, 216, 4, 54, 67, 34, 70, 82, 81, 40, 2, 83, 89, 155, 97, + 68, 2, 11, 79, 2, 179, 184, 2, 77, 2, 11, 85, 2, 11, 76, 2, 11, 76, 2, + 11, 32, 2, 11, 83, 2, 223, 223, 1, 84, 2, 17, 2, 85, 69, 2, 163, 239, 1, + 83, 190, 4, 68, 7, 76, 76, 65, 66, 76, 69, 32, 197, 11, 5, 77, 66, 79, + 76, 32, 164, 4, 214, 1, 68, 70, 66, 2, 83, 2, 84, 2, 90, 70, 71, 122, 72, + 82, 75, 134, 1, 76, 130, 1, 77, 86, 78, 134, 3, 67, 2, 70, 2, 74, 2, 80, + 2, 82, 2, 86, 2, 89, 78, 87, 50, 69, 34, 79, 198, 75, 65, 2, 73, 3, 85, + 42, 66, 72, 162, 8, 79, 142, 141, 2, 69, 162, 64, 65, 2, 73, 3, 85, 28, + 230, 7, 72, 58, 79, 142, 141, 2, 69, 162, 64, 65, 2, 73, 3, 85, 34, 62, + 66, 202, 6, 69, 86, 79, 174, 205, 2, 65, 2, 73, 3, 85, 18, 106, 79, 222, + 5, 69, 130, 206, 2, 65, 2, 73, 3, 85, 24, 50, 79, 222, 5, 69, 254, 76, + 65, 2, 73, 3, 85, 7, 218, 211, 2, 78, 3, 79, 34, 70, 80, 206, 5, 79, 170, + 76, 65, 230, 192, 1, 69, 162, 64, 73, 3, 85, 18, 246, 4, 69, 86, 79, 170, + 76, 65, 134, 129, 2, 73, 3, 85, 16, 54, 69, 218, 4, 79, 174, 205, 2, 65, + 2, 73, 3, 85, 7, 26, 78, 235, 209, 2, 69, 2, 21, 3, 71, 84, 72, 2, 215, + 147, 2, 69, 42, 214, 3, 66, 0, 2, 71, 66, 58, 79, 142, 141, 2, 69, 162, + 64, 65, 2, 73, 3, 85, 90, 90, 68, 174, 1, 71, 126, 74, 2, 89, 58, 79, + 142, 141, 2, 69, 162, 64, 65, 2, 73, 3, 85, 24, 54, 79, 182, 143, 2, 69, + 162, 64, 65, 2, 73, 3, 85, 15, 36, 3, 76, 69, 32, 175, 207, 2, 79, 10, + 54, 83, 130, 176, 2, 68, 190, 28, 70, 2, 75, 3, 77, 2, 255, 175, 2, 79, + 25, 42, 71, 214, 254, 1, 65, 2, 69, 3, 79, 16, 50, 69, 86, 79, 174, 205, + 2, 65, 2, 73, 3, 85, 7, 254, 205, 2, 69, 3, 78, 14, 54, 79, 142, 141, 2, + 69, 162, 64, 65, 2, 73, 3, 85, 5, 171, 205, 2, 79, 28, 46, 69, 34, 79, + 198, 75, 65, 2, 73, 3, 85, 9, 226, 75, 69, 135, 129, 2, 78, 9, 194, 75, + 79, 135, 129, 2, 78, 26, 66, 68, 62, 70, 30, 74, 22, 75, 50, 78, 22, 84, + 227, 241, 1, 66, 6, 26, 79, 211, 250, 1, 65, 4, 206, 250, 1, 79, 135, 50, + 45, 4, 74, 69, 167, 200, 2, 65, 2, 147, 250, 1, 79, 4, 26, 69, 231, 249, + 1, 85, 2, 227, 249, 1, 69, 2, 239, 182, 2, 73, 6, 186, 249, 1, 73, 2, 79, + 195, 78, 65, 128, 4, 74, 49, 94, 50, 98, 51, 2, 52, 2, 53, 2, 54, 2, 55, + 2, 56, 3, 57, 223, 1, 182, 1, 48, 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 2, + 54, 2, 55, 2, 56, 3, 57, 137, 1, 90, 48, 2, 49, 2, 50, 2, 51, 2, 52, 94, + 53, 166, 199, 2, 54, 2, 55, 2, 56, 3, 57, 23, 254, 199, 2, 48, 2, 49, 2, + 50, 2, 51, 2, 52, 2, 53, 2, 54, 2, 55, 2, 56, 3, 57, 17, 162, 199, 2, 48, + 2, 49, 2, 50, 2, 51, 2, 52, 2, 53, 3, 54, 198, 1, 128, 1, 4, 68, 73, 67, + 32, 190, 19, 82, 244, 25, 2, 83, 84, 233, 134, 1, 13, 67, 84, 79, 82, 32, + 79, 82, 32, 67, 82, 79, 83, 83, 86, 60, 5, 83, 73, 71, 78, 32, 137, 10, + 5, 84, 79, 78, 69, 32, 48, 218, 2, 65, 216, 1, 17, 68, 79, 85, 66, 76, + 69, 32, 65, 78, 85, 83, 86, 65, 82, 65, 32, 65, 98, 74, 52, 6, 78, 73, + 72, 83, 72, 86, 22, 82, 240, 1, 8, 72, 69, 88, 73, 70, 79, 82, 77, 22, + 76, 52, 4, 84, 73, 82, 89, 22, 85, 60, 8, 86, 73, 83, 65, 82, 71, 65, 32, + 221, 6, 17, 89, 65, 74, 85, 82, 86, 69, 68, 73, 67, 32, 77, 73, 68, 76, + 73, 78, 14, 76, 8, 78, 85, 83, 86, 65, 82, 65, 32, 212, 1, 3, 84, 73, 75, + 151, 2, 82, 10, 134, 1, 65, 24, 4, 66, 65, 72, 73, 24, 9, 85, 66, 72, 65, + 89, 65, 84, 79, 32, 201, 4, 10, 86, 65, 77, 65, 71, 79, 77, 85, 75, 72, + 2, 21, 3, 78, 84, 65, 2, 21, 3, 82, 71, 79, 2, 11, 77, 2, 147, 9, 85, 2, + 171, 253, 1, 82, 2, 33, 6, 73, 72, 86, 65, 77, 85, 2, 151, 3, 76, 2, 139, + 189, 2, 65, 8, 144, 1, 15, 69, 86, 69, 82, 83, 69, 68, 32, 86, 73, 83, + 65, 82, 71, 65, 36, 9, 79, 84, 65, 84, 69, 68, 32, 65, 82, 57, 5, 84, 72, + 65, 78, 71, 4, 11, 32, 4, 202, 6, 65, 23, 85, 2, 25, 4, 68, 72, 65, 86, + 2, 137, 251, 1, 2, 73, 83, 2, 17, 2, 32, 76, 2, 21, 3, 79, 78, 71, 2, + 165, 248, 1, 2, 32, 65, 2, 235, 185, 2, 65, 2, 37, 7, 80, 65, 68, 72, 77, + 65, 78, 2, 235, 185, 2, 73, 10, 40, 3, 65, 78, 85, 2, 85, 163, 9, 83, 4, + 25, 4, 68, 65, 84, 84, 4, 11, 65, 5, 25, 4, 32, 87, 73, 84, 2, 11, 72, 2, + 11, 32, 2, 11, 84, 2, 191, 88, 65, 38, 128, 2, 5, 67, 65, 78, 68, 82, 16, + 2, 68, 79, 96, 2, 75, 65, 136, 1, 4, 80, 82, 69, 78, 16, 2, 82, 73, 106, + 84, 164, 1, 11, 89, 65, 74, 85, 82, 86, 69, 68, 73, 67, 32, 180, 1, 12, + 65, 84, 72, 65, 82, 86, 65, 86, 69, 68, 73, 67, 249, 238, 1, 2, 83, 72, + 4, 215, 19, 65, 6, 40, 5, 85, 66, 76, 69, 32, 191, 3, 84, 4, 22, 82, 211, + 5, 83, 2, 11, 73, 2, 251, 1, 78, 4, 56, 3, 82, 83, 72, 17, 7, 84, 72, 65, + 75, 65, 32, 65, 2, 195, 118, 65, 2, 17, 2, 78, 85, 2, 17, 2, 68, 65, 2, + 219, 146, 2, 84, 2, 211, 54, 75, 4, 82, 78, 237, 2, 15, 71, 86, 69, 68, + 73, 67, 32, 75, 65, 83, 72, 77, 73, 82, 73, 2, 171, 185, 1, 71, 6, 42, + 72, 24, 4, 82, 73, 80, 76, 19, 87, 2, 49, 3, 82, 69, 69, 2, 219, 2, 69, + 2, 11, 79, 2, 25, 4, 32, 68, 79, 84, 2, 11, 83, 2, 11, 32, 2, 251, 15, + 66, 8, 176, 1, 10, 65, 71, 71, 82, 65, 86, 65, 84, 69, 68, 22, 73, 105, + 27, 75, 65, 84, 72, 65, 75, 65, 32, 73, 78, 68, 69, 80, 69, 78, 68, 69, + 78, 84, 32, 83, 86, 65, 82, 73, 84, 65, 2, 17, 2, 32, 73, 2, 49, 10, 78, + 68, 69, 80, 69, 78, 68, 69, 78, 84, 2, 17, 2, 32, 83, 2, 141, 142, 2, 3, + 86, 65, 82, 5, 185, 11, 7, 32, 83, 67, 72, 82, 79, 69, 106, 62, 83, 16, + 6, 84, 73, 67, 65, 76, 32, 137, 18, 2, 89, 32, 2, 203, 90, 73, 78, 208, + 2, 4, 66, 65, 82, 32, 174, 3, 67, 42, 68, 66, 69, 62, 70, 38, 71, 32, 11, + 73, 68, 69, 79, 71, 82, 65, 80, 72, 73, 67, 48, 12, 75, 65, 78, 65, 32, + 82, 69, 80, 69, 65, 84, 32, 254, 1, 76, 206, 3, 77, 88, 17, 79, 78, 69, + 32, 69, 73, 71, 72, 84, 72, 32, 66, 76, 79, 67, 75, 45, 62, 82, 158, 1, + 84, 218, 1, 90, 253, 73, 3, 83, 73, 88, 8, 108, 6, 66, 69, 83, 73, 68, + 69, 64, 8, 68, 79, 85, 66, 76, 69, 32, 76, 20, 4, 84, 82, 73, 80, 143, 1, + 87, 2, 17, 2, 32, 82, 2, 21, 3, 73, 71, 72, 2, 147, 134, 1, 84, 2, 69, 2, + 69, 70, 2, 25, 4, 76, 69, 32, 82, 2, 21, 3, 73, 71, 72, 2, 11, 84, 2, 29, + 5, 32, 84, 85, 82, 78, 2, 11, 83, 2, 11, 84, 2, 191, 133, 1, 73, 2, 21, + 3, 73, 84, 72, 2, 17, 2, 32, 72, 2, 209, 251, 1, 7, 79, 82, 73, 90, 79, + 78, 84, 2, 213, 242, 1, 5, 65, 80, 65, 67, 73, 2, 181, 135, 1, 11, 79, + 85, 66, 76, 69, 32, 87, 72, 73, 84, 69, 2, 25, 4, 76, 76, 73, 80, 2, 11, + 83, 2, 223, 236, 1, 73, 2, 11, 79, 2, 177, 84, 2, 85, 82, 2, 229, 162, 1, + 3, 79, 45, 75, 2, 17, 2, 32, 73, 2, 141, 192, 1, 2, 84, 69, 10, 120, 4, + 77, 65, 82, 75, 45, 22, 87, 73, 84, 72, 32, 86, 79, 73, 67, 69, 68, 32, + 83, 79, 85, 78, 68, 32, 77, 65, 82, 75, 7, 11, 32, 4, 50, 85, 21, 3, 76, + 79, 87, 5, 17, 2, 32, 85, 2, 17, 2, 80, 80, 2, 17, 2, 69, 82, 2, 161, 30, + 2, 32, 72, 16, 30, 65, 33, 3, 73, 78, 69, 2, 11, 68, 2, 159, 233, 1, 68, + 15, 11, 32, 12, 38, 69, 61, 5, 87, 73, 84, 72, 32, 2, 17, 2, 88, 84, 2, + 17, 2, 69, 78, 2, 215, 213, 1, 83, 10, 42, 67, 114, 70, 26, 84, 247, 144, + 1, 77, 4, 25, 4, 73, 82, 67, 76, 4, 11, 69, 4, 11, 32, 4, 26, 66, 163, + 168, 1, 65, 2, 11, 69, 2, 159, 136, 1, 76, 2, 57, 3, 79, 85, 82, 2, 11, + 72, 2, 21, 3, 82, 69, 69, 2, 45, 9, 32, 84, 73, 67, 75, 32, 77, 65, 82, + 2, 163, 230, 1, 75, 2, 65, 14, 65, 76, 69, 32, 87, 73, 84, 72, 32, 83, + 84, 82, 79, 75, 2, 167, 156, 1, 69, 12, 146, 163, 2, 50, 2, 51, 2, 52, 2, + 53, 2, 54, 3, 55, 4, 42, 65, 57, 6, 69, 83, 73, 83, 84, 79, 2, 25, 4, 67, + 73, 78, 71, 2, 11, 32, 2, 135, 126, 67, 2, 21, 3, 82, 32, 83, 2, 11, 69, + 2, 155, 222, 1, 71, 10, 32, 2, 65, 66, 106, 73, 19, 82, 6, 18, 32, 35, + 85, 2, 11, 75, 2, 175, 143, 2, 69, 4, 33, 6, 76, 65, 84, 73, 79, 78, 5, + 247, 46, 32, 2, 155, 10, 76, 2, 29, 5, 65, 70, 70, 73, 67, 2, 173, 245, + 1, 2, 32, 76, 2, 145, 111, 4, 73, 71, 90, 65, 26, 80, 6, 72, 69, 65, 86, + 89, 32, 176, 5, 3, 77, 85, 67, 229, 10, 3, 66, 79, 76, 20, 62, 69, 190, + 1, 70, 38, 82, 82, 83, 246, 1, 87, 203, 11, 71, 4, 25, 4, 73, 71, 72, 84, + 4, 11, 32, 4, 22, 80, 223, 2, 83, 2, 25, 4, 79, 73, 78, 84, 2, 17, 2, 69, + 68, 2, 17, 2, 32, 66, 2, 25, 4, 76, 65, 67, 75, 2, 11, 32, 2, 191, 81, + 83, 2, 11, 73, 2, 185, 1, 2, 86, 69, 2, 11, 69, 2, 29, 5, 86, 69, 82, 83, + 69, 2, 17, 2, 32, 83, 2, 231, 1, 79, 6, 30, 65, 42, 73, 147, 1, 79, 2, + 11, 76, 2, 11, 84, 2, 203, 120, 73, 2, 11, 88, 2, 11, 32, 2, 11, 83, 2, + 21, 3, 80, 79, 75, 2, 17, 2, 69, 68, 2, 11, 32, 2, 11, 65, 2, 11, 83, 2, + 189, 80, 3, 84, 69, 82, 2, 169, 14, 3, 76, 73, 68, 4, 21, 3, 72, 73, 84, + 4, 11, 69, 4, 11, 32, 4, 178, 66, 67, 139, 52, 83, 4, 11, 72, 4, 11, 32, + 4, 18, 71, 39, 76, 2, 69, 6, 82, 69, 65, 84, 69, 82, 2, 11, 69, 2, 11, + 83, 2, 11, 83, 2, 17, 2, 45, 84, 2, 163, 73, 72, 4, 11, 65, 5, 11, 32, 2, + 11, 70, 2, 21, 3, 79, 82, 77, 2, 17, 2, 32, 84, 2, 227, 248, 1, 87, 162, + 1, 156, 1, 9, 66, 82, 65, 84, 73, 79, 78, 32, 77, 32, 4, 67, 84, 79, 82, + 36, 3, 68, 69, 79, 126, 69, 222, 1, 79, 22, 82, 21, 7, 84, 72, 75, 85, + 81, 73, 32, 2, 11, 79, 2, 191, 255, 1, 68, 4, 202, 133, 1, 89, 255, 141, + 1, 73, 6, 30, 32, 77, 3, 67, 65, 83, 4, 18, 67, 43, 71, 2, 17, 2, 65, 77, + 2, 211, 208, 1, 69, 2, 143, 123, 65, 2, 207, 72, 83, 6, 168, 1, 31, 84, + 78, 65, 77, 69, 83, 69, 32, 65, 76, 84, 69, 82, 78, 65, 84, 69, 32, 82, + 69, 65, 68, 73, 78, 71, 32, 77, 65, 82, 75, 32, 129, 112, 5, 87, 68, 65, + 84, 65, 4, 26, 78, 227, 144, 2, 67, 2, 247, 132, 1, 72, 2, 175, 147, 1, + 76, 2, 251, 243, 1, 71, 140, 1, 56, 6, 67, 65, 80, 73, 84, 65, 1, 4, 83, + 77, 65, 76, 70, 45, 9, 76, 32, 76, 69, 84, 84, 69, 82, 32, 70, 230, 1, + 66, 34, 69, 22, 73, 22, 76, 34, 78, 254, 142, 1, 67, 2, 68, 2, 83, 2, 84, + 226, 56, 72, 238, 48, 70, 2, 74, 2, 77, 2, 80, 2, 82, 2, 86, 2, 88, 2, + 90, 158, 20, 71, 2, 75, 2, 81, 186, 2, 65, 2, 79, 2, 85, 3, 89, 4, 174, + 249, 1, 66, 215, 22, 69, 5, 227, 143, 2, 73, 5, 251, 248, 1, 74, 4, 130, + 141, 2, 76, 187, 2, 65, 4, 198, 248, 1, 74, 215, 22, 69, 8, 28, 3, 73, + 68, 69, 59, 76, 2, 21, 3, 68, 32, 71, 2, 253, 71, 4, 82, 69, 69, 75, 6, + 46, 67, 20, 3, 76, 69, 89, 45, 2, 85, 77, 2, 227, 228, 1, 65, 2, 11, 66, + 2, 11, 65, 2, 247, 129, 1, 76, 2, 11, 69, 2, 17, 2, 32, 73, 2, 169, 129, + 1, 4, 78, 84, 69, 71, 5, 239, 140, 2, 83, 40, 70, 67, 45, 13, 71, 65, 82, + 32, 70, 82, 65, 67, 84, 73, 79, 78, 32, 2, 11, 65, 2, 11, 78, 2, 159, + 206, 1, 85, 38, 106, 70, 96, 4, 79, 78, 69, 32, 178, 2, 84, 80, 7, 83, + 69, 86, 69, 78, 32, 69, 153, 33, 3, 90, 69, 82, 6, 56, 4, 73, 86, 69, 32, + 253, 3, 5, 79, 85, 82, 32, 70, 4, 162, 3, 69, 113, 3, 83, 73, 88, 18, 66, + 69, 28, 2, 70, 73, 18, 72, 34, 78, 14, 81, 30, 83, 55, 84, 2, 197, 1, 3, + 73, 71, 72, 2, 171, 1, 70, 2, 11, 65, 2, 251, 135, 1, 76, 2, 111, 73, 2, + 237, 75, 3, 85, 65, 82, 4, 24, 2, 69, 86, 15, 73, 2, 43, 69, 2, 43, 88, + 4, 18, 69, 35, 72, 2, 11, 78, 2, 255, 134, 2, 84, 2, 139, 111, 73, 10, + 48, 5, 72, 82, 69, 69, 32, 93, 3, 87, 79, 32, 6, 26, 69, 26, 81, 67, 70, + 2, 109, 3, 73, 71, 72, 2, 21, 3, 85, 65, 82, 2, 239, 117, 84, 4, 22, 70, + 219, 32, 84, 2, 11, 73, 2, 11, 70, 2, 205, 200, 1, 2, 84, 72, 178, 6, 86, + 65, 250, 23, 69, 158, 3, 72, 182, 72, 73, 170, 9, 79, 238, 5, 82, 219, + 146, 1, 74, 204, 2, 114, 70, 18, 78, 220, 5, 2, 88, 73, 158, 1, 82, 210, + 10, 84, 194, 1, 86, 221, 158, 1, 6, 83, 84, 69, 66, 65, 83, 2, 191, 93, + 70, 122, 36, 4, 67, 72, 79, 32, 183, 5, 73, 118, 100, 7, 76, 69, 84, 84, + 69, 82, 32, 252, 3, 3, 78, 71, 85, 16, 5, 84, 79, 78, 69, 32, 243, 7, 68, + 88, 210, 1, 65, 38, 79, 34, 69, 22, 73, 22, 76, 50, 78, 42, 84, 50, 85, + 22, 89, 130, 184, 1, 75, 2, 80, 2, 83, 138, 69, 66, 2, 67, 2, 68, 2, 70, + 2, 71, 2, 72, 2, 74, 2, 77, 2, 82, 2, 86, 2, 87, 3, 90, 13, 34, 65, 210, + 128, 2, 78, 87, 85, 7, 11, 78, 5, 151, 129, 2, 71, 5, 131, 129, 2, 78, 5, + 155, 128, 2, 78, 4, 26, 76, 195, 128, 2, 65, 2, 135, 254, 1, 72, 6, 242, + 253, 1, 71, 2, 89, 187, 2, 65, 8, 202, 253, 1, 72, 2, 82, 2, 83, 187, 2, + 65, 5, 243, 175, 1, 69, 4, 174, 254, 1, 73, 147, 1, 65, 2, 159, 120, 78, + 8, 40, 3, 75, 79, 73, 1, 3, 84, 85, 80, 5, 139, 235, 1, 78, 4, 21, 3, 78, + 71, 32, 4, 76, 8, 67, 82, 69, 83, 67, 69, 78, 84, 1, 7, 71, 73, 66, 66, + 79, 85, 83, 2, 21, 3, 32, 77, 79, 2, 11, 79, 2, 255, 103, 78, 170, 1, 72, + 9, 65, 78, 71, 32, 67, 73, 84, 73, 32, 229, 117, 4, 78, 73, 78, 71, 168, + 1, 128, 1, 6, 67, 65, 80, 73, 84, 65, 0, 4, 83, 77, 65, 76, 190, 4, 68, + 156, 2, 7, 78, 85, 77, 66, 69, 82, 32, 175, 228, 1, 79, 64, 45, 9, 76, + 32, 76, 69, 84, 84, 69, 82, 32, 64, 174, 1, 65, 38, 69, 42, 72, 74, 78, + 50, 79, 22, 83, 50, 85, 30, 89, 206, 43, 84, 200, 115, 2, 86, 73, 222, + 51, 66, 2, 80, 246, 5, 75, 158, 11, 73, 2, 87, 162, 17, 68, 3, 71, 9, + 166, 249, 1, 78, 86, 77, 3, 84, 7, 11, 78, 4, 202, 249, 1, 78, 3, 89, 8, + 38, 79, 198, 160, 1, 73, 235, 31, 65, 4, 170, 192, 1, 82, 235, 25, 76, 4, + 26, 71, 215, 167, 1, 85, 2, 147, 246, 1, 65, 5, 151, 178, 1, 68, 4, 26, + 83, 179, 228, 1, 73, 2, 159, 211, 1, 85, 4, 242, 247, 1, 67, 3, 85, 8, + 34, 85, 182, 247, 1, 65, 3, 79, 5, 179, 247, 1, 74, 20, 11, 73, 20, 11, + 71, 20, 17, 2, 73, 84, 20, 11, 32, 20, 66, 70, 30, 83, 42, 84, 62, 90, + 234, 89, 78, 14, 79, 227, 112, 69, 4, 206, 121, 73, 131, 4, 79, 4, 22, + 69, 179, 103, 73, 2, 219, 28, 86, 4, 26, 72, 211, 214, 1, 87, 2, 11, 82, + 2, 227, 222, 1, 69, 2, 11, 69, 2, 163, 214, 1, 82, 18, 42, 69, 30, 70, + 42, 78, 38, 83, 39, 84, 2, 221, 1, 3, 73, 71, 72, 4, 22, 73, 139, 1, 79, + 2, 171, 1, 70, 2, 17, 2, 73, 78, 2, 135, 1, 69, 4, 92, 2, 69, 86, 25, 2, + 73, 88, 6, 34, 72, 26, 87, 179, 163, 1, 69, 2, 11, 73, 2, 35, 82, 2, 11, + 69, 2, 11, 78, 2, 175, 225, 1, 84, 12, 32, 2, 69, 82, 179, 241, 1, 67, + 10, 34, 32, 165, 162, 1, 2, 77, 69, 8, 80, 3, 67, 76, 79, 22, 87, 228, + 206, 1, 5, 66, 85, 70, 70, 65, 1, 2, 80, 79, 2, 175, 188, 1, 83, 2, 223, + 116, 65, 20, 60, 2, 69, 32, 124, 4, 73, 78, 71, 32, 161, 1, 2, 89, 32, 6, + 182, 2, 68, 161, 195, 1, 23, 65, 82, 82, 79, 87, 32, 80, 79, 73, 78, 84, + 73, 78, 71, 32, 68, 73, 82, 69, 67, 84, 76, 89, 6, 64, 5, 66, 76, 65, 67, + 75, 0, 5, 87, 72, 73, 84, 69, 55, 72, 2, 17, 2, 32, 70, 2, 11, 76, 2, + 175, 238, 1, 65, 2, 11, 65, 2, 11, 78, 2, 215, 103, 68, 8, 26, 68, 34, + 76, 43, 79, 2, 11, 65, 2, 143, 237, 1, 83, 4, 22, 79, 199, 82, 73, 2, + 159, 82, 87, 2, 11, 86, 2, 11, 69, 2, 131, 82, 82, 14, 48, 3, 65, 82, 89, + 70, 68, 70, 73, 171, 1, 83, 4, 11, 32, 4, 32, 2, 67, 65, 211, 175, 1, 70, + 2, 183, 175, 1, 84, 4, 26, 71, 167, 155, 1, 68, 2, 189, 73, 6, 69, 45, 84, 65, 73, 76, 4, 116, 17, 69, 82, 83, 84, 82, 65, 83, 83, 32, 69, 76, - 76, 73, 80, 84, 73, 67, 229, 45, 7, 71, 72, 84, 32, 76, 73, 70, 2, 17, 2, - 32, 70, 2, 253, 150, 1, 2, 85, 78, 2, 37, 7, 84, 32, 83, 89, 82, 73, 65, - 2, 215, 35, 67, 192, 2, 52, 3, 69, 69, 76, 100, 3, 73, 84, 69, 175, 63, - 65, 7, 60, 7, 32, 79, 70, 32, 68, 72, 65, 21, 4, 67, 72, 65, 73, 2, 251, - 196, 1, 82, 2, 179, 80, 82, 184, 2, 54, 32, 133, 67, 8, 45, 70, 69, 65, - 84, 72, 69, 82, 182, 2, 148, 2, 18, 65, 82, 82, 79, 87, 32, 83, 72, 65, - 70, 84, 32, 87, 73, 68, 84, 72, 32, 114, 66, 46, 67, 198, 16, 68, 166, 5, - 69, 50, 70, 186, 3, 72, 246, 3, 76, 210, 4, 77, 222, 1, 78, 34, 80, 146, - 1, 81, 78, 82, 142, 2, 83, 158, 12, 84, 228, 3, 2, 85, 80, 149, 4, 3, 86, - 69, 82, 4, 22, 84, 203, 71, 79, 2, 11, 87, 2, 21, 3, 79, 32, 84, 2, 17, - 2, 72, 73, 2, 11, 82, 2, 215, 164, 1, 68, 2, 11, 85, 2, 11, 76, 2, 239, - 172, 1, 76, 98, 154, 1, 72, 252, 10, 5, 73, 82, 67, 76, 69, 162, 3, 76, + 76, 73, 80, 84, 73, 67, 249, 45, 7, 71, 72, 84, 32, 76, 73, 70, 2, 17, 2, + 32, 70, 2, 149, 154, 1, 2, 85, 78, 2, 37, 7, 84, 32, 83, 89, 82, 73, 65, + 2, 235, 35, 67, 200, 2, 52, 3, 69, 69, 76, 100, 3, 73, 84, 69, 135, 66, + 65, 7, 60, 7, 32, 79, 70, 32, 68, 72, 65, 21, 4, 67, 72, 65, 73, 2, 147, + 200, 1, 82, 2, 203, 83, 82, 192, 2, 54, 32, 221, 69, 8, 45, 70, 69, 65, + 84, 72, 69, 82, 190, 2, 148, 2, 18, 65, 82, 82, 79, 87, 32, 83, 72, 65, + 70, 84, 32, 87, 73, 68, 84, 72, 32, 114, 66, 46, 67, 226, 16, 68, 170, 5, + 69, 50, 70, 186, 3, 72, 234, 3, 76, 210, 4, 77, 222, 1, 78, 34, 80, 146, + 1, 81, 78, 82, 142, 2, 83, 226, 14, 84, 228, 3, 2, 85, 80, 149, 4, 3, 86, + 69, 82, 4, 22, 84, 227, 74, 79, 2, 11, 87, 2, 21, 3, 79, 32, 84, 2, 17, + 2, 72, 73, 2, 11, 82, 2, 239, 167, 1, 68, 2, 11, 85, 2, 11, 76, 2, 135, + 176, 1, 76, 100, 162, 1, 72, 252, 10, 5, 73, 82, 67, 76, 69, 162, 3, 76, 24, 20, 79, 78, 67, 65, 86, 69, 45, 83, 73, 68, 69, 68, 32, 68, 73, 65, - 77, 79, 78, 68, 79, 82, 70, 25, 4, 69, 83, 83, 32, 70, 104, 3, 65, 76, - 70, 18, 66, 38, 69, 116, 3, 70, 69, 82, 22, 75, 142, 4, 80, 22, 81, 38, - 82, 131, 2, 84, 2, 255, 83, 73, 6, 133, 6, 5, 73, 83, 72, 79, 80, 4, 45, - 9, 81, 85, 73, 72, 79, 80, 80, 69, 82, 5, 17, 2, 32, 82, 2, 149, 6, 8, - 79, 84, 65, 84, 69, 68, 32, 78, 2, 167, 222, 1, 90, 26, 38, 73, 25, 5, - 78, 73, 71, 72, 84, 6, 177, 4, 2, 78, 71, 21, 22, 32, 151, 3, 45, 12, 41, - 8, 82, 79, 84, 65, 84, 69, 68, 32, 12, 104, 2, 70, 79, 0, 15, 79, 78, 69, - 32, 72, 85, 78, 68, 82, 69, 68, 32, 84, 72, 73, 18, 84, 215, 3, 78, 2, - 207, 1, 82, 6, 148, 1, 11, 87, 79, 32, 72, 85, 78, 68, 82, 69, 68, 32, + 77, 79, 78, 68, 78, 82, 43, 85, 70, 25, 4, 69, 83, 83, 32, 70, 104, 3, + 65, 76, 70, 18, 66, 38, 69, 116, 3, 70, 69, 82, 22, 75, 142, 4, 80, 22, + 81, 38, 82, 131, 2, 84, 2, 143, 87, 73, 6, 133, 6, 5, 73, 83, 72, 79, 80, + 4, 45, 9, 81, 85, 73, 72, 79, 80, 80, 69, 82, 5, 17, 2, 32, 82, 2, 149, + 6, 8, 79, 84, 65, 84, 69, 68, 32, 78, 2, 183, 225, 1, 90, 26, 38, 73, 25, + 5, 78, 73, 71, 72, 84, 6, 177, 4, 2, 78, 71, 21, 22, 32, 151, 3, 45, 12, + 41, 8, 82, 79, 84, 65, 84, 69, 68, 32, 12, 104, 2, 70, 79, 0, 15, 79, 78, + 69, 32, 72, 85, 78, 68, 82, 69, 68, 32, 84, 72, 73, 18, 84, 215, 3, 78, + 2, 207, 1, 82, 6, 148, 1, 11, 87, 79, 32, 72, 85, 78, 68, 82, 69, 68, 32, 133, 3, 20, 72, 82, 69, 69, 32, 72, 85, 78, 68, 82, 69, 68, 32, 70, 73, 70, 84, 69, 69, 78, 4, 36, 4, 84, 87, 69, 78, 175, 2, 83, 2, 217, 2, 7, 84, 89, 45, 70, 73, 86, 69, 6, 174, 3, 66, 94, 81, 47, 82, 6, 41, 2, 65, 87, 6, 21, 3, 85, 69, 69, 6, 35, 78, 6, 21, 3, 79, 79, 75, 7, 45, 9, 32, 82, 79, 84, 65, 84, 69, 68, 32, 4, 70, 78, 25, 13, 84, 87, 79, 32, 72, 85, 78, 68, 82, 69, 68, 32, 83, 2, 49, 3, 73, 78, 69, 2, 25, 4, 69, 86, - 69, 78, 2, 17, 2, 84, 89, 2, 241, 65, 6, 32, 68, 69, 71, 82, 69, 12, 29, + 69, 78, 2, 17, 2, 84, 89, 2, 129, 69, 6, 32, 68, 69, 71, 82, 69, 12, 29, 5, 85, 82, 78, 69, 68, 12, 11, 32, 12, 42, 66, 30, 75, 34, 80, 34, 81, - 47, 82, 2, 225, 93, 3, 73, 83, 72, 4, 226, 133, 1, 73, 171, 38, 78, 2, - 11, 65, 2, 207, 134, 1, 87, 2, 11, 85, 2, 11, 69, 2, 163, 134, 1, 69, 2, - 143, 172, 1, 79, 19, 11, 32, 16, 100, 16, 67, 79, 78, 84, 65, 73, 78, 73, + 47, 82, 2, 241, 96, 3, 73, 83, 72, 4, 242, 136, 1, 73, 171, 38, 78, 2, + 11, 65, 2, 223, 137, 1, 87, 2, 11, 85, 2, 11, 69, 2, 179, 137, 1, 69, 2, + 159, 175, 1, 79, 19, 11, 32, 16, 100, 16, 67, 79, 78, 84, 65, 73, 78, 73, 78, 71, 32, 66, 76, 65, 67, 75, 121, 5, 87, 73, 84, 72, 32, 2, 17, 2, 32, 83, 2, 11, 77, 2, 21, 3, 65, 76, 76, 2, 11, 32, 2, 11, 67, 2, 11, 73, 2, - 11, 82, 2, 195, 45, 67, 14, 56, 2, 68, 79, 70, 84, 236, 31, 2, 76, 79, - 231, 1, 85, 4, 18, 84, 35, 87, 2, 11, 32, 2, 195, 168, 1, 82, 2, 167, 54, - 78, 2, 11, 87, 2, 11, 79, 2, 11, 32, 2, 147, 60, 68, 2, 217, 27, 2, 85, - 66, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 236, 30, 2, 76, 69, 49, 2, 82, - 73, 2, 17, 2, 79, 83, 2, 255, 143, 1, 83, 28, 76, 6, 73, 65, 77, 79, 78, - 68, 216, 2, 3, 79, 87, 78, 177, 1, 2, 82, 65, 15, 11, 32, 12, 160, 1, 17, - 67, 79, 78, 84, 65, 73, 78, 73, 78, 71, 32, 66, 76, 65, 67, 75, 32, 128, - 1, 9, 87, 73, 84, 72, 32, 67, 69, 78, 84, 234, 23, 83, 213, 19, 2, 73, - 78, 6, 74, 83, 0, 6, 86, 69, 82, 89, 32, 83, 29, 6, 77, 69, 68, 73, 85, - 77, 2, 25, 4, 77, 65, 76, 76, 2, 205, 15, 2, 32, 68, 2, 11, 82, 2, 11, - 69, 2, 231, 58, 68, 10, 96, 10, 32, 80, 79, 73, 78, 84, 73, 78, 71, 32, - 53, 10, 45, 80, 79, 73, 78, 84, 73, 78, 71, 32, 6, 178, 36, 66, 24, 5, - 76, 69, 70, 84, 32, 51, 73, 4, 202, 37, 83, 51, 84, 4, 33, 6, 85, 71, 72, - 84, 83, 32, 4, 22, 77, 155, 123, 75, 2, 187, 124, 65, 2, 29, 5, 88, 67, - 76, 65, 77, 2, 175, 15, 65, 14, 74, 76, 144, 2, 11, 79, 85, 82, 32, 80, - 79, 73, 78, 84, 69, 68, 71, 82, 8, 28, 2, 65, 71, 175, 1, 79, 5, 149, 1, - 34, 32, 87, 73, 84, 72, 32, 72, 79, 82, 73, 90, 79, 78, 84, 65, 76, 32, - 77, 73, 68, 68, 76, 69, 32, 66, 76, 65, 67, 75, 32, 83, 84, 82, 73, 2, - 131, 179, 1, 80, 4, 26, 82, 191, 139, 1, 87, 2, 17, 2, 69, 84, 2, 191, - 178, 1, 84, 4, 11, 32, 4, 18, 67, 23, 83, 2, 199, 200, 1, 85, 2, 143, 37, - 84, 2, 141, 64, 2, 79, 87, 16, 34, 65, 150, 1, 69, 231, 1, 79, 2, 25, 4, - 82, 68, 32, 83, 2, 45, 9, 72, 69, 76, 76, 32, 70, 76, 79, 80, 2, 17, 2, - 80, 89, 2, 17, 2, 32, 68, 2, 11, 73, 2, 231, 195, 1, 83, 10, 22, 65, 151, - 12, 88, 8, 30, 82, 29, 3, 86, 89, 32, 4, 11, 84, 5, 211, 15, 32, 4, 74, - 67, 53, 14, 83, 65, 76, 84, 73, 82, 69, 32, 87, 73, 84, 72, 32, 82, 2, - 17, 2, 72, 69, 2, 11, 67, 2, 231, 131, 1, 75, 2, 167, 19, 79, 4, 60, 8, - 82, 73, 90, 79, 78, 84, 65, 76, 249, 42, 2, 85, 82, 2, 201, 31, 2, 32, - 69, 22, 42, 65, 116, 3, 69, 70, 84, 175, 1, 79, 4, 24, 2, 82, 71, 19, 84, - 2, 243, 32, 69, 2, 11, 73, 2, 11, 78, 2, 17, 2, 32, 67, 2, 11, 82, 2, - 203, 42, 79, 12, 58, 32, 77, 10, 45, 80, 79, 73, 78, 84, 73, 78, 71, 32, - 6, 44, 6, 76, 65, 78, 69, 32, 77, 247, 24, 80, 2, 11, 69, 2, 227, 10, 82, - 6, 150, 2, 80, 206, 24, 83, 51, 84, 6, 160, 1, 4, 87, 69, 82, 32, 221, 8, - 30, 90, 69, 78, 71, 69, 32, 67, 79, 78, 84, 65, 73, 78, 73, 78, 71, 32, - 66, 76, 65, 67, 75, 32, 83, 77, 65, 76, 76, 32, 76, 4, 44, 3, 76, 69, 70, - 1, 4, 82, 73, 71, 72, 2, 11, 84, 2, 17, 2, 32, 80, 2, 203, 5, 79, 12, 68, - 6, 69, 68, 73, 85, 77, 32, 117, 7, 79, 79, 78, 32, 83, 69, 76, 10, 30, - 68, 54, 83, 227, 6, 76, 2, 11, 73, 2, 11, 65, 2, 11, 77, 2, 191, 46, 79, - 6, 134, 27, 84, 50, 77, 59, 81, 2, 11, 69, 2, 223, 187, 1, 78, 2, 11, 73, - 2, 247, 189, 1, 66, 6, 18, 65, 87, 69, 2, 37, 7, 82, 65, 76, 76, 69, 76, - 79, 2, 11, 71, 2, 11, 82, 2, 183, 172, 1, 65, 4, 11, 78, 4, 174, 2, 84, - 203, 46, 78, 2, 21, 3, 85, 69, 83, 2, 217, 120, 9, 84, 73, 79, 78, 32, - 77, 65, 82, 75, 14, 34, 69, 25, 4, 73, 71, 72, 84, 2, 129, 21, 2, 67, 84, - 12, 60, 10, 45, 80, 79, 73, 78, 84, 73, 78, 71, 32, 211, 17, 32, 8, 30, - 80, 202, 19, 83, 51, 84, 4, 18, 69, 55, 79, 2, 11, 78, 2, 11, 84, 2, 11, - 65, 2, 199, 106, 71, 2, 11, 73, 2, 11, 78, 2, 159, 124, 84, 56, 118, 67, - 32, 3, 69, 83, 65, 18, 72, 58, 77, 166, 1, 80, 68, 5, 81, 85, 65, 82, 69, - 180, 6, 2, 85, 78, 199, 12, 84, 2, 145, 40, 4, 73, 83, 83, 79, 2, 167, - 37, 77, 2, 21, 3, 79, 71, 73, 2, 189, 123, 4, 32, 80, 73, 69, 8, 32, 4, - 65, 76, 76, 32, 115, 73, 6, 18, 76, 71, 83, 2, 11, 79, 2, 11, 90, 2, 11, - 69, 2, 11, 78, 2, 223, 160, 1, 71, 4, 226, 19, 84, 107, 81, 2, 231, 46, - 76, 2, 21, 3, 65, 68, 69, 2, 11, 32, 2, 11, 83, 2, 143, 154, 1, 85, 29, - 11, 32, 26, 114, 66, 36, 17, 67, 79, 78, 84, 65, 73, 78, 73, 78, 71, 32, - 66, 76, 65, 67, 75, 32, 85, 5, 87, 73, 84, 72, 32, 2, 17, 2, 85, 84, 2, - 179, 101, 84, 6, 54, 86, 194, 17, 83, 37, 6, 77, 69, 68, 73, 85, 77, 2, - 169, 17, 3, 69, 82, 89, 18, 150, 1, 76, 50, 82, 214, 1, 85, 144, 1, 17, - 86, 69, 82, 84, 73, 67, 65, 76, 32, 66, 73, 83, 69, 67, 84, 73, 78, 249, - 19, 6, 67, 69, 78, 84, 82, 69, 6, 18, 69, 15, 79, 2, 67, 70, 4, 247, 1, - 87, 4, 18, 73, 115, 79, 2, 17, 2, 71, 72, 2, 33, 6, 84, 87, 65, 82, 68, - 83, 2, 11, 32, 2, 11, 84, 2, 11, 73, 2, 235, 174, 1, 67, 2, 29, 5, 85, - 78, 68, 69, 68, 2, 21, 3, 32, 67, 79, 2, 185, 32, 2, 82, 78, 4, 17, 2, - 80, 80, 4, 21, 3, 69, 82, 32, 4, 44, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, - 2, 33, 6, 84, 32, 81, 85, 65, 68, 2, 167, 36, 82, 2, 187, 20, 71, 11, 11, - 32, 8, 84, 12, 66, 69, 72, 73, 78, 68, 32, 67, 76, 79, 85, 68, 69, 5, 87, - 73, 84, 72, 32, 5, 29, 5, 32, 87, 73, 84, 72, 2, 17, 2, 32, 82, 2, 147, - 47, 65, 4, 38, 82, 29, 5, 83, 77, 65, 76, 76, 2, 11, 65, 2, 199, 112, 89, - 2, 11, 32, 2, 21, 3, 67, 76, 79, 2, 207, 103, 85, 10, 38, 79, 54, 69, 62, - 82, 203, 1, 87, 2, 49, 10, 85, 67, 72, 84, 79, 78, 69, 32, 84, 69, 2, 17, - 2, 76, 69, 2, 11, 80, 2, 11, 72, 2, 167, 17, 79, 4, 148, 1, 4, 65, 80, - 69, 90, 33, 28, 73, 65, 78, 71, 76, 69, 32, 67, 79, 78, 84, 65, 73, 78, - 73, 78, 71, 32, 83, 77, 65, 76, 76, 32, 87, 72, 73, 84, 2, 11, 73, 2, - 203, 154, 1, 85, 2, 135, 4, 69, 2, 11, 79, 2, 85, 19, 45, 87, 65, 89, 32, - 76, 69, 70, 84, 32, 87, 65, 89, 32, 84, 82, 65, 70, 70, 2, 11, 73, 2, - 143, 170, 1, 67, 12, 62, 32, 185, 1, 10, 45, 80, 79, 73, 78, 84, 73, 78, - 71, 32, 4, 11, 80, 4, 41, 8, 79, 73, 78, 84, 73, 78, 71, 32, 4, 18, 66, - 75, 73, 2, 21, 3, 65, 67, 75, 2, 25, 4, 72, 65, 78, 68, 2, 17, 2, 32, 73, - 2, 17, 2, 78, 68, 2, 211, 25, 69, 8, 54, 67, 42, 83, 125, 7, 84, 82, 73, - 65, 78, 71, 76, 2, 21, 3, 72, 69, 86, 2, 199, 87, 82, 2, 25, 4, 77, 65, - 76, 76, 2, 17, 2, 32, 84, 2, 17, 2, 82, 73, 2, 11, 65, 2, 11, 78, 2, 11, - 71, 2, 231, 143, 1, 76, 4, 11, 69, 5, 11, 32, 2, 11, 87, 2, 209, 18, 3, - 73, 84, 72, 10, 44, 6, 84, 73, 67, 65, 76, 32, 143, 2, 89, 8, 58, 69, 48, - 7, 82, 69, 67, 84, 65, 78, 71, 147, 1, 66, 2, 11, 76, 2, 17, 2, 76, 73, - 2, 183, 25, 80, 4, 17, 2, 76, 69, 5, 37, 7, 32, 87, 73, 84, 72, 32, 72, - 2, 37, 7, 79, 82, 73, 90, 79, 78, 84, 2, 17, 2, 65, 76, 2, 11, 32, 2, 11, - 66, 2, 223, 106, 65, 2, 17, 2, 32, 83, 2, 11, 77, 2, 21, 3, 65, 76, 76, - 2, 17, 2, 32, 83, 2, 11, 81, 2, 11, 85, 2, 11, 65, 2, 231, 139, 1, 82, 2, - 11, 69, 2, 11, 68, 2, 17, 2, 32, 82, 2, 21, 3, 73, 71, 72, 2, 11, 84, 2, - 11, 87, 2, 241, 4, 4, 65, 82, 68, 83, 100, 140, 1, 10, 68, 69, 45, 72, - 69, 65, 68, 69, 68, 32, 132, 4, 4, 71, 71, 76, 89, 124, 6, 76, 84, 69, - 68, 32, 70, 42, 78, 189, 1, 2, 82, 69, 80, 128, 1, 3, 76, 69, 70, 0, 4, - 82, 73, 71, 72, 12, 4, 68, 79, 87, 78, 0, 2, 85, 80, 32, 3, 78, 79, 82, - 1, 3, 83, 79, 85, 10, 11, 84, 10, 109, 5, 87, 65, 82, 68, 83, 20, 21, 3, - 84, 72, 32, 20, 32, 2, 69, 65, 1, 2, 87, 69, 10, 17, 2, 83, 84, 10, 11, - 32, 10, 110, 72, 0, 6, 86, 69, 82, 89, 32, 72, 28, 5, 76, 73, 71, 72, 84, - 0, 6, 77, 69, 68, 73, 85, 77, 23, 66, 2, 25, 4, 69, 65, 86, 89, 2, 17, 2, - 32, 66, 2, 21, 3, 65, 82, 66, 2, 11, 32, 2, 11, 65, 2, 11, 82, 2, 11, 82, - 2, 135, 30, 79, 2, 17, 2, 32, 86, 2, 11, 69, 2, 33, 6, 82, 84, 73, 67, - 65, 76, 2, 11, 32, 2, 11, 76, 2, 11, 73, 2, 219, 132, 1, 78, 2, 11, 76, - 2, 11, 79, 2, 151, 93, 87, 12, 46, 68, 106, 69, 190, 17, 75, 163, 136, 1, - 71, 6, 22, 32, 143, 28, 79, 4, 44, 2, 67, 72, 221, 17, 4, 66, 76, 79, 87, - 2, 11, 73, 2, 155, 131, 1, 77, 2, 11, 32, 2, 121, 3, 71, 76, 65, 4, 36, - 5, 68, 32, 75, 69, 89, 51, 76, 2, 17, 2, 66, 79, 2, 11, 65, 2, 207, 82, - 82, 2, 11, 69, 2, 247, 90, 83, 30, 66, 77, 134, 3, 82, 254, 13, 78, 226, - 64, 79, 129, 9, 2, 76, 70, 14, 36, 2, 65, 78, 137, 2, 2, 69, 78, 13, 72, - 12, 32, 87, 73, 84, 72, 32, 66, 85, 78, 78, 89, 32, 29, 2, 83, 32, 2, 11, - 69, 2, 143, 6, 65, 8, 52, 2, 66, 79, 16, 2, 67, 76, 54, 83, 199, 12, 72, - 2, 251, 13, 79, 2, 11, 79, 2, 11, 84, 2, 11, 72, 2, 167, 88, 69, 2, 17, - 2, 65, 78, 2, 131, 10, 68, 2, 11, 83, 2, 11, 32, 2, 11, 83, 2, 11, 89, 2, - 17, 2, 77, 66, 2, 187, 9, 79, 10, 72, 2, 68, 32, 156, 1, 3, 76, 68, 32, - 32, 2, 82, 73, 247, 146, 1, 77, 4, 56, 9, 83, 69, 80, 65, 82, 65, 84, 79, - 82, 231, 85, 74, 2, 17, 2, 32, 77, 2, 21, 3, 73, 68, 68, 2, 11, 76, 2, - 11, 69, 2, 11, 32, 2, 235, 66, 68, 2, 11, 77, 2, 251, 146, 1, 65, 2, 11, - 69, 2, 199, 85, 68, 10, 56, 7, 65, 80, 80, 69, 68, 32, 80, 30, 69, 163, - 1, 73, 2, 241, 78, 3, 82, 69, 83, 6, 48, 2, 65, 84, 80, 3, 83, 84, 76, - 215, 110, 78, 2, 11, 72, 2, 11, 32, 2, 11, 80, 2, 25, 4, 82, 79, 68, 85, - 2, 223, 116, 67, 2, 11, 69, 2, 147, 83, 82, 2, 11, 84, 2, 11, 73, 2, 17, - 2, 78, 71, 2, 17, 2, 32, 72, 2, 11, 65, 2, 243, 73, 78, 34, 76, 2, 32, - 73, 138, 1, 45, 28, 7, 73, 65, 78, 71, 81, 73, 32, 183, 85, 79, 2, 53, - 11, 78, 32, 65, 32, 82, 69, 67, 84, 65, 78, 71, 2, 11, 76, 2, 11, 69, 2, - 11, 32, 2, 11, 66, 2, 11, 79, 2, 191, 142, 1, 88, 2, 11, 82, 2, 215, 124, - 65, 28, 48, 5, 66, 76, 65, 67, 75, 1, 3, 82, 69, 68, 14, 11, 32, 14, 130, - 1, 67, 72, 4, 69, 76, 69, 80, 28, 4, 71, 69, 78, 69, 46, 72, 40, 4, 83, - 79, 76, 68, 193, 11, 6, 77, 65, 78, 68, 65, 82, 4, 24, 2, 65, 78, 19, 72, - 2, 195, 60, 78, 2, 229, 59, 3, 65, 82, 73, 2, 11, 72, 2, 219, 72, 65, 2, - 11, 82, 2, 11, 65, 2, 207, 139, 1, 76, 2, 11, 79, 2, 11, 82, 2, 207, 116, - 83, 2, 167, 77, 73, 248, 19, 54, 65, 206, 2, 69, 226, 11, 73, 217, 35, 2, - 79, 45, 8, 84, 16, 78, 71, 81, 73, 78, 32, 83, 73, 71, 78, 32, 83, 76, - 79, 87, 32, 199, 1, 87, 6, 28, 3, 79, 78, 69, 51, 84, 2, 17, 2, 32, 66, - 2, 11, 69, 2, 131, 109, 65, 4, 60, 9, 72, 82, 69, 69, 32, 72, 65, 76, 70, - 1, 2, 87, 79, 2, 21, 3, 32, 66, 69, 2, 11, 65, 2, 223, 74, 84, 2, 11, 78, - 2, 11, 73, 2, 241, 74, 2, 78, 71, 98, 60, 4, 76, 76, 79, 87, 62, 78, 53, - 5, 90, 73, 68, 73, 32, 2, 17, 2, 32, 72, 2, 11, 69, 2, 11, 65, 2, 227, - 106, 82, 2, 11, 32, 2, 11, 83, 2, 11, 73, 2, 251, 54, 71, 94, 112, 10, - 67, 79, 77, 66, 73, 78, 73, 78, 71, 32, 76, 5, 72, 89, 80, 72, 69, 17, 7, - 76, 69, 84, 84, 69, 82, 32, 4, 44, 3, 77, 65, 68, 13, 4, 72, 65, 77, 90, - 2, 11, 68, 2, 215, 67, 65, 2, 215, 27, 78, 88, 250, 1, 67, 50, 77, 18, - 68, 42, 69, 58, 72, 30, 75, 22, 71, 2, 81, 32, 3, 76, 65, 77, 98, 78, 18, - 80, 30, 83, 66, 84, 28, 2, 86, 65, 126, 87, 14, 79, 18, 88, 52, 3, 89, - 79, 84, 154, 1, 90, 134, 53, 82, 238, 48, 66, 254, 5, 85, 162, 14, 70, 3, - 74, 6, 22, 72, 147, 114, 73, 4, 22, 72, 251, 113, 73, 2, 247, 113, 73, 4, - 11, 65, 4, 178, 130, 1, 68, 3, 76, 8, 42, 76, 142, 50, 89, 226, 79, 84, - 3, 87, 2, 71, 73, 4, 150, 112, 65, 147, 15, 72, 4, 18, 72, 15, 65, 2, 11, - 65, 2, 163, 129, 1, 70, 5, 11, 32, 2, 11, 87, 2, 21, 3, 73, 84, 72, 2, - 17, 2, 32, 68, 2, 11, 79, 2, 187, 3, 84, 2, 207, 48, 85, 4, 202, 105, 72, - 215, 22, 69, 8, 46, 72, 246, 47, 73, 194, 9, 65, 163, 70, 69, 2, 243, 47, - 73, 4, 238, 104, 72, 215, 22, 65, 5, 37, 7, 32, 65, 76, 84, 69, 82, 78, - 2, 17, 2, 65, 84, 2, 11, 69, 2, 11, 32, 2, 11, 70, 2, 11, 79, 2, 227, - 109, 82, 2, 11, 65, 2, 159, 126, 87, 4, 22, 72, 251, 125, 65, 2, 11, 69, - 2, 139, 46, 89, 5, 41, 8, 32, 87, 73, 84, 72, 32, 67, 73, 2, 41, 8, 82, - 67, 85, 77, 70, 76, 69, 88, 2, 11, 32, 2, 11, 65, 2, 11, 66, 2, 11, 79, - 2, 255, 101, 86, 6, 22, 65, 175, 124, 69, 5, 171, 124, 76, 140, 19, 34, - 32, 161, 35, 3, 78, 32, 89, 138, 19, 88, 8, 82, 65, 68, 73, 67, 65, 76, - 32, 181, 7, 9, 83, 89, 76, 76, 65, 66, 76, 69, 32, 110, 170, 1, 66, 42, - 67, 86, 68, 42, 71, 74, 72, 66, 74, 66, 75, 30, 76, 30, 77, 26, 78, 74, - 80, 26, 83, 74, 84, 30, 86, 30, 89, 30, 90, 250, 35, 81, 198, 49, 87, - 235, 30, 79, 4, 22, 66, 247, 64, 85, 2, 163, 93, 85, 12, 42, 85, 18, 89, - 178, 98, 72, 203, 22, 73, 2, 135, 121, 79, 7, 130, 121, 80, 3, 84, 4, 22, - 68, 215, 120, 85, 2, 247, 63, 85, 10, 42, 71, 238, 91, 79, 162, 28, 69, - 15, 65, 4, 162, 89, 85, 235, 30, 79, 8, 22, 88, 243, 88, 77, 6, 238, 88, - 85, 202, 2, 73, 163, 28, 79, 8, 22, 74, 167, 119, 79, 6, 246, 90, 85, - 218, 5, 73, 215, 22, 89, 4, 206, 90, 73, 175, 28, 69, 6, 190, 54, 73, - 199, 7, 89, 4, 182, 118, 79, 15, 73, 8, 30, 89, 26, 90, 199, 90, 66, 4, - 254, 117, 73, 3, 79, 2, 231, 117, 85, 4, 182, 89, 85, 3, 89, 10, 22, 72, - 223, 97, 83, 8, 214, 60, 85, 178, 28, 65, 162, 28, 79, 15, 89, 4, 214, - 88, 65, 175, 28, 85, 4, 138, 60, 85, 211, 56, 69, 4, 158, 88, 73, 175, - 28, 79, 10, 54, 85, 224, 62, 2, 90, 73, 238, 24, 79, 175, 28, 65, 4, 246, - 115, 80, 3, 82, 156, 18, 134, 2, 66, 134, 1, 67, 162, 1, 68, 110, 70, 50, - 71, 150, 1, 72, 138, 3, 73, 134, 1, 74, 98, 75, 54, 76, 62, 77, 134, 1, - 78, 234, 4, 80, 54, 81, 2, 89, 46, 82, 162, 1, 83, 134, 1, 84, 102, 86, - 82, 87, 58, 88, 50, 90, 140, 2, 2, 85, 79, 66, 65, 2, 79, 107, 69, 132, - 1, 66, 66, 238, 21, 85, 150, 1, 69, 26, 73, 42, 65, 2, 79, 67, 89, 64, - 234, 21, 85, 150, 1, 69, 26, 73, 42, 65, 2, 79, 3, 89, 122, 66, 72, 238, - 20, 85, 150, 1, 69, 26, 73, 42, 65, 2, 79, 67, 89, 54, 46, 85, 146, 22, - 65, 2, 69, 2, 79, 67, 89, 19, 142, 22, 79, 106, 82, 230, 88, 80, 3, 88, - 106, 58, 68, 138, 15, 85, 134, 5, 73, 94, 69, 66, 65, 3, 79, 54, 210, 19, - 85, 58, 73, 94, 69, 66, 65, 3, 79, 42, 182, 20, 79, 66, 65, 2, 73, 2, 89, - 67, 85, 116, 58, 71, 214, 15, 85, 146, 4, 73, 42, 65, 2, 69, 3, 79, 56, - 50, 73, 162, 15, 85, 186, 4, 65, 2, 69, 3, 79, 13, 150, 19, 69, 142, 90, - 84, 3, 88, 246, 1, 78, 73, 30, 76, 58, 77, 54, 78, 110, 88, 50, 85, 254, - 15, 69, 66, 65, 3, 79, 6, 198, 19, 69, 231, 88, 84, 64, 238, 16, 85, 58, - 73, 94, 69, 2, 79, 66, 65, 67, 89, 58, 182, 16, 85, 58, 73, 158, 1, 65, - 2, 79, 35, 89, 42, 46, 79, 34, 85, 202, 16, 69, 26, 73, 43, 65, 6, 242, - 106, 80, 2, 84, 3, 88, 6, 238, 17, 79, 231, 88, 84, 46, 46, 85, 254, 15, - 69, 26, 73, 42, 65, 3, 79, 8, 187, 16, 79, 19, 42, 84, 130, 16, 69, 206, - 89, 80, 3, 88, 5, 11, 69, 2, 11, 82, 2, 11, 65, 2, 11, 84, 2, 11, 73, 2, - 11, 79, 2, 191, 39, 78, 106, 50, 74, 190, 10, 85, 146, 4, 73, 42, 79, 67, - 89, 50, 158, 13, 85, 174, 1, 73, 42, 79, 3, 89, 56, 242, 12, 85, 58, 73, - 158, 1, 65, 2, 69, 3, 79, 70, 218, 9, 85, 250, 3, 69, 26, 73, 42, 65, 2, - 79, 67, 89, 106, 70, 71, 218, 8, 85, 158, 3, 73, 158, 1, 65, 2, 79, 2, - 89, 107, 69, 44, 186, 11, 85, 150, 1, 69, 66, 65, 2, 79, 105, 2, 73, 69, - 248, 2, 102, 66, 54, 68, 94, 71, 90, 74, 46, 82, 50, 89, 78, 90, 134, 7, - 85, 58, 73, 94, 65, 2, 69, 67, 79, 54, 202, 10, 73, 158, 1, 65, 2, 79, - 66, 85, 3, 89, 46, 46, 73, 198, 10, 69, 66, 65, 2, 79, 67, 85, 13, 234, - 11, 69, 230, 88, 80, 2, 84, 3, 88, 34, 60, 2, 85, 79, 218, 9, 69, 0, 2, - 73, 69, 66, 65, 3, 79, 7, 226, 99, 84, 3, 88, 50, 230, 1, 85, 242, 7, 73, - 42, 79, 67, 89, 46, 146, 9, 79, 66, 65, 2, 69, 66, 85, 3, 89, 38, 30, 85, - 222, 8, 73, 43, 79, 15, 194, 8, 79, 142, 90, 80, 2, 84, 3, 88, 56, 62, - 85, 206, 4, 79, 178, 2, 73, 158, 1, 65, 66, 89, 43, 69, 15, 254, 8, 79, - 2, 82, 230, 88, 80, 3, 88, 60, 150, 6, 85, 58, 73, 158, 1, 65, 2, 79, 67, - 89, 56, 254, 2, 85, 146, 4, 73, 42, 79, 67, 89, 100, 58, 82, 254, 4, 85, - 150, 1, 69, 66, 65, 2, 79, 67, 89, 48, 46, 85, 162, 6, 69, 2, 79, 66, 89, - 43, 65, 17, 134, 7, 79, 2, 82, 230, 88, 80, 2, 84, 3, 88, 176, 1, 70, 83, - 158, 3, 72, 50, 85, 58, 73, 94, 69, 66, 65, 2, 79, 67, 89, 56, 130, 4, - 73, 94, 69, 66, 65, 2, 79, 2, 85, 67, 89, 56, 46, 85, 158, 3, 73, 94, 69, - 66, 65, 3, 79, 21, 182, 4, 79, 106, 82, 230, 88, 80, 2, 84, 3, 88, 60, - 54, 69, 166, 3, 73, 42, 65, 2, 79, 66, 85, 3, 89, 4, 150, 93, 80, 3, 88, - 28, 38, 85, 206, 2, 69, 2, 79, 67, 65, 9, 203, 2, 79, 40, 210, 2, 73, 42, - 79, 66, 89, 41, 2, 85, 79, 178, 1, 66, 72, 50, 85, 58, 73, 42, 90, 54, - 69, 66, 65, 2, 79, 67, 89, 54, 46, 85, 214, 1, 65, 2, 69, 2, 79, 67, 89, - 19, 146, 1, 79, 170, 1, 82, 230, 88, 80, 2, 84, 3, 88, 15, 90, 69, 142, - 90, 80, 2, 84, 3, 88, 58, 50, 69, 2, 79, 26, 73, 42, 65, 34, 85, 35, 89, - 7, 138, 90, 80, 3, 88, 17, 38, 69, 206, 89, 80, 2, 84, 3, 88, 9, 202, 89, - 80, 2, 84, 3, 88, 11, 70, 82, 230, 88, 80, 3, 88, 13, 38, 82, 230, 88, - 80, 2, 84, 3, 88, 5, 227, 88, 88, 2, 219, 7, 65, 2, 207, 57, 89, 180, 4, - 252, 1, 10, 32, 78, 79, 84, 65, 84, 73, 79, 78, 32, 224, 6, 16, 65, 78, - 65, 66, 65, 90, 65, 82, 32, 83, 81, 85, 65, 82, 69, 32, 210, 15, 69, 180, - 2, 6, 73, 80, 80, 69, 82, 45, 96, 8, 78, 65, 77, 69, 78, 78, 89, 32, 188, - 33, 3, 79, 77, 66, 235, 26, 87, 26, 144, 1, 9, 66, 65, 71, 32, 77, 69, - 77, 66, 69, 42, 82, 104, 6, 68, 79, 77, 65, 73, 78, 60, 3, 76, 69, 70, - 154, 1, 83, 145, 2, 3, 84, 89, 80, 2, 11, 82, 2, 11, 83, 2, 215, 83, 72, - 8, 100, 4, 65, 78, 71, 69, 60, 3, 73, 71, 72, 221, 1, 11, 69, 76, 65, 84, - 73, 79, 78, 65, 76, 32, 67, 2, 173, 3, 11, 32, 65, 78, 84, 73, 82, 69, - 83, 84, 82, 73, 4, 17, 2, 84, 32, 4, 60, 4, 73, 77, 65, 71, 13, 7, 66, - 73, 78, 68, 73, 78, 71, 2, 11, 69, 2, 25, 4, 32, 66, 82, 65, 2, 11, 67, - 2, 175, 29, 75, 8, 44, 6, 67, 72, 69, 77, 65, 32, 211, 1, 80, 6, 18, 67, - 71, 80, 2, 17, 2, 79, 77, 2, 11, 80, 2, 11, 79, 2, 11, 83, 2, 107, 73, 4, - 30, 73, 41, 3, 82, 79, 74, 2, 11, 80, 2, 11, 73, 2, 163, 80, 78, 2, 11, - 69, 2, 11, 67, 2, 11, 84, 2, 87, 73, 2, 139, 52, 79, 2, 11, 69, 2, 11, - 32, 2, 11, 67, 2, 11, 79, 2, 11, 76, 2, 11, 79, 2, 223, 79, 78, 144, 1, - 240, 1, 2, 67, 76, 68, 7, 73, 78, 73, 84, 73, 65, 76, 204, 2, 14, 70, 73, - 78, 65, 76, 32, 67, 79, 78, 83, 79, 78, 65, 78, 16, 7, 76, 69, 84, 84, - 69, 82, 32, 148, 3, 5, 77, 65, 82, 75, 32, 206, 1, 83, 181, 3, 6, 86, 79, - 87, 69, 76, 32, 14, 64, 5, 79, 83, 73, 78, 71, 137, 1, 6, 85, 83, 84, 69, - 82, 45, 4, 11, 32, 4, 64, 12, 68, 79, 85, 66, 76, 69, 45, 76, 73, 78, 69, - 68, 23, 72, 2, 17, 2, 32, 72, 2, 17, 2, 69, 65, 2, 215, 10, 68, 10, 96, - 13, 70, 73, 78, 65, 76, 32, 76, 69, 84, 84, 69, 82, 32, 41, 7, 73, 78, - 73, 84, 73, 65, 76, 8, 238, 72, 76, 2, 82, 2, 86, 3, 89, 2, 37, 7, 32, - 76, 69, 84, 84, 69, 82, 2, 151, 6, 32, 2, 131, 9, 84, 82, 166, 1, 68, 50, - 75, 38, 78, 46, 83, 38, 84, 46, 66, 2, 67, 2, 71, 2, 80, 2, 90, 138, 69, - 45, 2, 72, 2, 74, 2, 76, 2, 77, 2, 82, 2, 86, 2, 89, 187, 2, 65, 12, 206, - 1, 68, 2, 90, 138, 69, 72, 187, 2, 65, 6, 154, 70, 83, 14, 72, 187, 2, - 65, 8, 130, 70, 71, 2, 78, 2, 89, 187, 2, 65, 6, 214, 69, 72, 2, 83, 187, - 2, 65, 12, 42, 83, 2, 84, 138, 69, 72, 187, 2, 65, 4, 134, 69, 72, 187, - 2, 65, 8, 50, 68, 58, 83, 40, 4, 76, 79, 78, 71, 23, 84, 2, 29, 5, 79, - 85, 66, 76, 69, 2, 11, 32, 2, 11, 83, 2, 11, 72, 2, 11, 65, 2, 159, 70, - 68, 2, 17, 2, 32, 84, 2, 17, 2, 83, 72, 2, 147, 69, 69, 14, 36, 4, 73, - 71, 78, 32, 255, 2, 85, 12, 54, 65, 72, 6, 67, 65, 78, 68, 82, 65, 167, - 1, 86, 2, 11, 78, 2, 11, 85, 2, 17, 2, 83, 86, 2, 11, 65, 2, 135, 66, 82, - 6, 36, 5, 66, 73, 78, 68, 85, 15, 32, 5, 11, 32, 2, 25, 4, 87, 73, 84, - 72, 2, 17, 2, 32, 79, 2, 21, 3, 82, 78, 65, 2, 11, 77, 2, 11, 69, 2, 239, - 38, 78, 4, 11, 73, 4, 18, 82, 19, 83, 2, 219, 33, 65, 2, 11, 65, 2, 11, - 82, 2, 139, 64, 71, 2, 151, 4, 66, 20, 38, 76, 109, 5, 83, 73, 71, 78, - 32, 2, 17, 2, 69, 78, 2, 11, 71, 2, 11, 84, 2, 11, 72, 2, 11, 32, 2, 11, - 77, 2, 11, 65, 2, 135, 62, 82, 18, 86, 65, 26, 79, 2, 85, 16, 8, 82, 69, - 86, 69, 82, 83, 69, 68, 146, 64, 69, 3, 73, 4, 182, 64, 73, 3, 85, 5, - 159, 64, 69, 2, 183, 44, 32, 12, 72, 2, 66, 82, 16, 9, 82, 79, 32, 87, - 73, 68, 84, 72, 32, 203, 1, 85, 2, 147, 2, 65, 8, 32, 2, 78, 79, 86, 83, - 31, 74, 4, 26, 45, 73, 2, 78, 45, 2, 29, 5, 66, 82, 69, 65, 75, 2, 11, - 32, 2, 11, 83, 2, 163, 1, 80, 2, 11, 74, 2, 11, 79, 2, 11, 73, 2, 11, 78, - 2, 143, 5, 69, 2, 219, 61, 83, 2, 21, 3, 77, 79, 85, 2, 17, 2, 84, 72, 2, - 11, 32, 2, 11, 70, 2, 11, 65, 2, 167, 38, 67, 242, 2, 168, 1, 10, 67, 79, - 77, 66, 73, 78, 73, 78, 71, 32, 224, 18, 6, 78, 69, 85, 77, 69, 32, 181, - 38, 17, 80, 82, 73, 90, 78, 65, 75, 32, 77, 79, 68, 73, 70, 73, 69, 82, - 32, 128, 1, 144, 2, 17, 76, 79, 87, 69, 82, 32, 84, 79, 78, 65, 76, 32, - 82, 65, 78, 71, 69, 88, 5, 77, 65, 82, 75, 32, 148, 3, 18, 65, 84, 84, - 65, 67, 72, 73, 78, 71, 32, 86, 69, 82, 84, 73, 67, 65, 76, 233, 11, 17, - 84, 79, 78, 65, 76, 32, 82, 65, 78, 71, 69, 32, 77, 65, 82, 75, 32, 2, - 33, 6, 32, 73, 78, 68, 73, 67, 2, 11, 65, 2, 11, 84, 2, 11, 79, 2, 219, - 56, 82, 118, 182, 2, 67, 142, 1, 68, 104, 8, 71, 79, 82, 65, 90, 68, 79, - 32, 34, 78, 106, 75, 114, 79, 72, 2, 80, 79, 152, 2, 8, 77, 65, 76, 79, - 32, 80, 79, 86, 100, 2, 82, 65, 50, 83, 186, 1, 84, 108, 7, 86, 89, 83, - 79, 75, 79, 32, 234, 1, 90, 224, 10, 2, 76, 79, 224, 22, 4, 85, 68, 65, - 82, 129, 6, 4, 66, 79, 82, 90, 6, 60, 6, 72, 65, 83, 72, 75, 65, 29, 5, - 85, 82, 86, 69, 68, 5, 197, 47, 3, 32, 80, 79, 2, 17, 2, 32, 79, 2, 11, - 77, 2, 235, 24, 69, 4, 240, 10, 13, 69, 77, 69, 83, 84, 86, 69, 78, 78, - 89, 32, 90, 65, 217, 14, 6, 86, 79, 69, 84, 79, 67, 10, 30, 78, 89, 3, - 86, 89, 83, 8, 29, 5, 73, 90, 75, 79, 32, 8, 164, 8, 8, 83, 32, 75, 82, - 89, 90, 72, 69, 35, 79, 2, 167, 20, 79, 8, 56, 4, 82, 89, 90, 72, 150, 6, - 65, 233, 39, 2, 85, 80, 5, 21, 3, 32, 79, 78, 2, 11, 32, 2, 203, 7, 76, - 6, 220, 5, 3, 84, 83, 69, 200, 13, 5, 66, 76, 65, 67, 72, 131, 31, 78, - 18, 22, 68, 131, 2, 86, 6, 60, 7, 67, 72, 65, 83, 72, 73, 69, 201, 22, 3, - 86, 69, 82, 5, 17, 2, 32, 87, 2, 21, 3, 73, 84, 72, 2, 17, 2, 32, 86, 2, - 29, 5, 69, 82, 84, 73, 67, 2, 17, 2, 65, 76, 2, 11, 32, 2, 11, 83, 2, 11, - 84, 2, 11, 82, 2, 11, 79, 2, 131, 25, 75, 12, 29, 5, 89, 83, 72, 69, 32, - 12, 22, 83, 251, 3, 79, 8, 154, 3, 32, 229, 2, 4, 84, 82, 65, 78, 4, 28, - 2, 90, 83, 183, 5, 86, 2, 219, 37, 69, 10, 136, 1, 2, 75, 79, 16, 16, 84, - 82, 65, 78, 78, 79, 32, 77, 65, 76, 79, 32, 80, 79, 86, 89, 236, 1, 5, - 82, 69, 68, 78, 69, 231, 26, 79, 2, 239, 42, 66, 2, 11, 83, 2, 183, 22, - 72, 10, 50, 79, 16, 5, 83, 65, 84, 65, 32, 139, 36, 73, 2, 187, 28, 67, - 6, 158, 1, 79, 201, 24, 3, 83, 32, 75, 10, 24, 2, 83, 32, 95, 79, 6, 11, - 75, 6, 44, 6, 72, 79, 75, 72, 76, 79, 247, 24, 82, 4, 11, 77, 4, 17, 2, - 32, 79, 4, 11, 78, 4, 11, 32, 4, 18, 76, 31, 82, 2, 11, 69, 2, 179, 14, - 70, 2, 11, 73, 2, 11, 71, 2, 139, 14, 72, 6, 18, 65, 31, 69, 2, 249, 25, - 3, 68, 69, 82, 4, 22, 86, 239, 10, 76, 2, 199, 38, 79, 6, 60, 5, 77, 82, - 65, 67, 72, 18, 83, 1, 4, 84, 82, 69, 83, 2, 155, 10, 78, 2, 17, 2, 86, - 69, 2, 155, 6, 84, 232, 1, 128, 2, 2, 67, 72, 38, 68, 218, 1, 70, 28, 10, - 71, 79, 76, 85, 66, 67, 72, 73, 75, 32, 158, 1, 75, 160, 2, 6, 77, 69, - 67, 72, 73, 75, 184, 1, 2, 78, 69, 18, 79, 138, 2, 80, 146, 2, 82, 114, - 83, 180, 20, 9, 86, 82, 65, 75, 72, 73, 89, 65, 32, 151, 2, 90, 4, 246, - 11, 69, 209, 10, 2, 65, 83, 10, 74, 69, 98, 85, 16, 9, 86, 65, 32, 86, - 32, 67, 72, 69, 76, 187, 27, 79, 4, 76, 2, 82, 66, 213, 2, 12, 77, 69, - 83, 84, 86, 69, 78, 78, 89, 32, 75, 76, 2, 195, 34, 73, 2, 203, 34, 68, - 2, 11, 78, 2, 231, 36, 85, 2, 11, 73, 2, 147, 34, 84, 10, 78, 84, 38, 83, - 240, 3, 5, 77, 82, 65, 67, 72, 145, 14, 4, 66, 79, 82, 90, 4, 32, 3, 82, - 69, 83, 251, 1, 73, 2, 21, 3, 86, 69, 84, 2, 231, 17, 76, 14, 76, 4, 72, - 65, 77, 73, 18, 76, 40, 3, 79, 66, 89, 16, 2, 82, 89, 87, 85, 2, 219, 3, - 76, 2, 11, 89, 2, 11, 85, 2, 151, 33, 67, 2, 223, 31, 76, 6, 28, 2, 85, - 75, 219, 32, 90, 5, 21, 3, 32, 84, 73, 2, 11, 75, 2, 251, 15, 72, 2, 11, - 70, 2, 11, 73, 2, 11, 83, 2, 215, 30, 77, 11, 11, 32, 8, 44, 7, 75, 76, - 89, 85, 67, 72, 69, 83, 80, 6, 64, 9, 78, 69, 80, 79, 83, 84, 79, 89, 65, - 14, 80, 163, 14, 86, 2, 39, 78, 2, 25, 4, 79, 86, 79, 68, 2, 143, 14, 78, - 2, 223, 22, 77, 14, 40, 2, 66, 76, 41, 4, 83, 79, 75, 65, 2, 11, 65, 2, - 11, 75, 2, 243, 30, 79, 13, 11, 32, 10, 30, 75, 142, 26, 84, 39, 83, 6, - 104, 11, 76, 89, 85, 67, 72, 69, 86, 65, 89, 65, 32, 185, 25, 10, 82, 89, - 85, 75, 79, 86, 65, 89, 65, 32, 4, 202, 16, 78, 251, 8, 83, 14, 58, 65, - 88, 8, 69, 82, 69, 86, 79, 68, 75, 65, 27, 79, 6, 44, 3, 82, 65, 75, 222, - 19, 76, 211, 5, 85, 2, 11, 76, 2, 11, 73, 2, 171, 28, 84, 5, 153, 15, 2, - 32, 78, 4, 68, 5, 68, 67, 72, 65, 83, 245, 9, 7, 76, 75, 85, 76, 73, 90, - 77, 2, 11, 72, 2, 219, 4, 73, 4, 64, 11, 69, 86, 69, 82, 83, 69, 68, 32, - 67, 72, 69, 139, 26, 79, 2, 25, 4, 76, 89, 85, 83, 2, 215, 17, 84, 126, - 96, 9, 75, 65, 77, 69, 89, 84, 83, 65, 32, 148, 2, 8, 76, 79, 90, 72, 73, - 84, 73, 69, 119, 84, 22, 128, 1, 13, 68, 86, 79, 69, 67, 72, 69, 76, 78, - 65, 89, 65, 32, 44, 7, 75, 76, 89, 85, 67, 72, 69, 74, 84, 218, 18, 77, - 119, 83, 8, 218, 10, 75, 110, 78, 178, 8, 80, 75, 83, 6, 40, 5, 86, 65, - 89, 65, 32, 243, 10, 78, 4, 178, 15, 84, 183, 4, 83, 4, 162, 15, 73, 147, - 4, 82, 9, 11, 32, 6, 48, 2, 83, 32, 25, 6, 90, 65, 75, 82, 89, 84, 4, - 166, 4, 75, 95, 90, 2, 11, 79, 2, 211, 22, 69, 96, 92, 4, 65, 84, 89, 65, - 172, 4, 6, 79, 80, 73, 84, 83, 65, 189, 1, 5, 82, 69, 76, 65, 32, 23, 11, - 32, 20, 76, 2, 83, 32, 236, 2, 9, 90, 65, 75, 82, 89, 84, 65, 89, 65, - 159, 5, 78, 14, 160, 1, 14, 68, 86, 85, 77, 89, 65, 32, 90, 65, 80, 89, - 65, 84, 89, 28, 7, 75, 82, 89, 90, 72, 69, 77, 24, 2, 82, 79, 17, 8, 90, - 65, 80, 89, 65, 84, 79, 89, 2, 11, 77, 2, 215, 19, 73, 5, 189, 1, 2, 32, - 73, 2, 203, 2, 71, 7, 21, 3, 32, 73, 32, 4, 54, 75, 37, 9, 80, 79, 68, - 67, 72, 65, 83, 72, 73, 2, 11, 82, 2, 21, 3, 89, 90, 72, 2, 211, 1, 69, - 5, 17, 2, 32, 83, 2, 17, 2, 32, 90, 2, 29, 5, 65, 80, 89, 65, 84, 2, 11, - 79, 2, 199, 17, 89, 7, 11, 32, 4, 68, 6, 83, 32, 79, 67, 72, 75, 29, 7, - 87, 73, 84, 72, 32, 83, 79, 2, 11, 79, 2, 215, 16, 77, 2, 45, 9, 82, 79, - 67, 72, 89, 65, 32, 78, 79, 2, 11, 90, 2, 163, 7, 72, 68, 140, 1, 9, 68, - 86, 79, 69, 67, 72, 69, 76, 78, 162, 1, 75, 78, 78, 174, 1, 71, 152, 3, - 8, 77, 82, 65, 67, 72, 78, 79, 84, 42, 80, 75, 84, 10, 18, 79, 71, 65, 6, - 64, 7, 80, 79, 86, 79, 68, 78, 65, 189, 5, 4, 75, 82, 89, 90, 4, 17, 2, - 89, 65, 5, 17, 2, 32, 75, 2, 145, 5, 4, 76, 89, 85, 67, 26, 48, 6, 76, - 89, 85, 67, 72, 69, 77, 2, 82, 89, 4, 22, 78, 203, 6, 80, 2, 157, 8, 9, - 69, 80, 79, 83, 84, 79, 89, 65, 78, 22, 48, 7, 85, 75, 79, 86, 65, 89, - 65, 195, 3, 90, 21, 11, 32, 18, 54, 71, 236, 2, 5, 84, 82, 89, 65, 83, - 179, 2, 80, 14, 21, 3, 82, 79, 77, 14, 32, 4, 78, 65, 89, 65, 47, 79, 5, - 237, 1, 7, 32, 87, 73, 84, 72, 32, 83, 10, 92, 10, 75, 82, 89, 90, 72, - 69, 86, 65, 89, 65, 17, 9, 80, 79, 86, 79, 68, 78, 65, 89, 65, 5, 175, 2, - 32, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 24, 2, 68, 79, 23, 83, 2, 41, 2, - 85, 66, 2, 21, 3, 73, 78, 71, 2, 133, 6, 6, 76, 69, 32, 90, 65, 80, 2, - 175, 6, 75, 2, 237, 5, 3, 72, 69, 86, 2, 11, 73, 2, 11, 75, 2, 187, 5, - 72, 6, 22, 79, 187, 3, 82, 4, 28, 2, 76, 85, 187, 1, 86, 2, 163, 1, 80, - 8, 80, 5, 82, 89, 65, 83, 79, 153, 2, 10, 73, 75, 72, 65, 89, 65, 32, 80, - 85, 84, 6, 62, 80, 44, 4, 83, 84, 82, 69, 173, 1, 4, 71, 76, 65, 83, 2, - 17, 2, 79, 86, 2, 193, 1, 2, 79, 68, 2, 171, 1, 76, 16, 88, 12, 75, 76, - 89, 85, 67, 72, 69, 86, 65, 89, 65, 32, 38, 77, 46, 80, 38, 84, 39, 83, - 8, 34, 77, 46, 80, 38, 84, 39, 83, 2, 25, 4, 82, 65, 67, 72, 2, 247, 1, - 78, 2, 11, 82, 2, 205, 1, 2, 79, 83, 2, 11, 82, 2, 11, 69, 2, 11, 83, 2, - 157, 1, 4, 86, 69, 84, 76, 6, 30, 65, 121, 3, 77, 69, 89, 4, 32, 4, 78, - 79, 90, 72, 31, 80, 2, 11, 69, 2, 151, 3, 75, 2, 17, 2, 89, 65, 2, 11, - 84, 2, 11, 65, 2, 35, 89, 2, 11, 84, 2, 11, 83, 2, 183, 2, 65, 10, 108, - 11, 68, 73, 82, 69, 67, 84, 73, 79, 78, 32, 70, 28, 3, 75, 82, 89, 28, 5, - 76, 69, 86, 69, 76, 35, 82, 2, 11, 76, 2, 159, 1, 73, 2, 11, 90, 2, 143, - 1, 72, 4, 11, 45, 4, 114, 50, 3, 51, 2, 11, 79, 2, 83, 71, 8, 26, 78, 34, - 83, 15, 74, 4, 18, 66, 27, 74, 2, 11, 83, 2, 11, 80, 3, 0, + 11, 82, 2, 147, 48, 67, 14, 56, 2, 68, 79, 70, 84, 188, 34, 2, 76, 79, + 231, 1, 85, 4, 18, 84, 35, 87, 2, 11, 32, 2, 211, 171, 1, 82, 2, 255, 56, + 78, 2, 11, 87, 2, 11, 79, 2, 11, 32, 2, 163, 63, 68, 2, 229, 27, 2, 85, + 66, 7, 33, 6, 32, 87, 73, 84, 72, 32, 4, 188, 33, 2, 76, 69, 49, 2, 82, + 73, 2, 17, 2, 79, 83, 2, 143, 147, 1, 83, 2, 235, 189, 1, 66, 28, 76, 6, + 73, 65, 77, 79, 78, 68, 220, 2, 3, 79, 87, 78, 177, 1, 2, 82, 65, 15, 11, + 32, 12, 148, 1, 17, 67, 79, 78, 84, 65, 73, 78, 73, 78, 71, 32, 66, 76, + 65, 67, 75, 32, 130, 1, 73, 16, 9, 87, 73, 84, 72, 32, 67, 69, 78, 84, + 223, 23, 83, 6, 74, 83, 0, 6, 86, 69, 82, 89, 32, 83, 29, 6, 77, 69, 68, + 73, 85, 77, 2, 25, 4, 77, 65, 76, 76, 2, 209, 15, 2, 32, 68, 2, 131, 46, + 78, 2, 11, 82, 2, 11, 69, 2, 223, 61, 68, 10, 96, 10, 32, 80, 79, 73, 78, + 84, 73, 78, 71, 32, 53, 10, 45, 80, 79, 73, 78, 84, 73, 78, 71, 32, 6, + 234, 38, 66, 24, 5, 76, 69, 70, 84, 32, 51, 73, 4, 130, 40, 83, 51, 84, + 4, 33, 6, 85, 71, 72, 84, 83, 32, 4, 22, 77, 147, 126, 75, 2, 179, 127, + 65, 2, 29, 5, 88, 67, 76, 65, 77, 2, 163, 15, 65, 14, 74, 76, 144, 2, 11, + 79, 85, 82, 32, 80, 79, 73, 78, 84, 69, 68, 71, 82, 8, 28, 2, 65, 71, + 175, 1, 79, 5, 149, 1, 34, 32, 87, 73, 84, 72, 32, 72, 79, 82, 73, 90, + 79, 78, 84, 65, 76, 32, 77, 73, 68, 68, 76, 69, 32, 66, 76, 65, 67, 75, + 32, 83, 84, 82, 73, 2, 251, 181, 1, 80, 4, 26, 82, 183, 142, 1, 87, 2, + 17, 2, 69, 84, 2, 183, 181, 1, 84, 4, 11, 32, 4, 18, 67, 23, 83, 2, 191, + 203, 1, 85, 2, 199, 39, 84, 2, 133, 67, 2, 79, 87, 16, 34, 65, 150, 1, + 69, 231, 1, 79, 2, 25, 4, 82, 68, 32, 83, 2, 45, 9, 72, 69, 76, 76, 32, + 70, 76, 79, 80, 2, 17, 2, 80, 89, 2, 17, 2, 32, 68, 2, 11, 73, 2, 223, + 198, 1, 83, 10, 22, 65, 139, 12, 88, 8, 30, 82, 29, 3, 86, 89, 32, 4, 11, + 84, 5, 199, 15, 32, 4, 74, 67, 53, 14, 83, 65, 76, 84, 73, 82, 69, 32, + 87, 73, 84, 72, 32, 82, 2, 17, 2, 72, 69, 2, 11, 67, 2, 223, 134, 1, 75, + 2, 223, 21, 79, 4, 192, 34, 10, 82, 73, 90, 79, 78, 84, 65, 76, 32, 69, + 237, 11, 2, 85, 82, 22, 42, 65, 116, 3, 69, 70, 84, 175, 1, 79, 4, 24, 2, + 82, 71, 19, 84, 2, 183, 35, 69, 2, 11, 73, 2, 11, 78, 2, 17, 2, 32, 67, + 2, 11, 82, 2, 207, 45, 79, 12, 58, 32, 77, 10, 45, 80, 79, 73, 78, 84, + 73, 78, 71, 32, 6, 44, 6, 76, 65, 78, 69, 32, 77, 187, 27, 80, 2, 11, 69, + 2, 227, 10, 82, 6, 150, 2, 80, 146, 27, 83, 51, 84, 6, 160, 1, 4, 87, 69, + 82, 32, 221, 8, 30, 90, 69, 78, 71, 69, 32, 67, 79, 78, 84, 65, 73, 78, + 73, 78, 71, 32, 66, 76, 65, 67, 75, 32, 83, 77, 65, 76, 76, 32, 76, 4, + 44, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, 2, 11, 84, 2, 17, 2, 32, 80, 2, + 203, 5, 79, 12, 68, 6, 69, 68, 73, 85, 77, 32, 117, 7, 79, 79, 78, 32, + 83, 69, 76, 10, 30, 68, 54, 83, 227, 6, 76, 2, 11, 73, 2, 11, 65, 2, 11, + 77, 2, 195, 49, 79, 6, 202, 29, 84, 50, 77, 59, 81, 2, 11, 69, 2, 227, + 190, 1, 78, 2, 11, 73, 2, 251, 192, 1, 66, 6, 18, 65, 87, 69, 2, 37, 7, + 82, 65, 76, 76, 69, 76, 79, 2, 11, 71, 2, 11, 82, 2, 187, 175, 1, 65, 4, + 11, 78, 4, 174, 2, 84, 207, 49, 78, 2, 21, 3, 85, 69, 83, 2, 221, 123, 9, + 84, 73, 79, 78, 32, 77, 65, 82, 75, 14, 34, 69, 25, 4, 73, 71, 72, 84, 2, + 197, 23, 2, 67, 84, 12, 60, 10, 45, 80, 79, 73, 78, 84, 73, 78, 71, 32, + 151, 20, 32, 8, 30, 80, 142, 22, 83, 51, 84, 4, 18, 69, 55, 79, 2, 11, + 78, 2, 11, 84, 2, 11, 65, 2, 203, 109, 71, 2, 11, 73, 2, 11, 78, 2, 163, + 127, 84, 62, 118, 67, 32, 3, 69, 83, 65, 18, 72, 58, 77, 166, 1, 80, 68, + 5, 81, 85, 65, 82, 69, 248, 8, 2, 85, 78, 199, 12, 84, 2, 149, 43, 4, 73, + 83, 83, 79, 2, 171, 40, 77, 2, 21, 3, 79, 71, 73, 2, 193, 126, 4, 32, 80, + 73, 69, 8, 32, 4, 65, 76, 76, 32, 115, 73, 6, 18, 76, 71, 83, 2, 11, 79, + 2, 11, 90, 2, 11, 69, 2, 11, 78, 2, 227, 163, 1, 71, 4, 166, 22, 84, 107, + 81, 2, 235, 49, 76, 2, 21, 3, 65, 68, 69, 2, 11, 32, 2, 11, 83, 2, 147, + 157, 1, 85, 35, 11, 32, 32, 114, 66, 36, 17, 67, 79, 78, 84, 65, 73, 78, + 73, 78, 71, 32, 66, 76, 65, 67, 75, 32, 85, 5, 87, 73, 84, 72, 32, 2, 17, + 2, 85, 84, 2, 183, 104, 84, 6, 54, 86, 134, 20, 83, 37, 6, 77, 69, 68, + 73, 85, 77, 2, 237, 19, 3, 69, 82, 89, 24, 220, 2, 6, 66, 79, 84, 84, 79, + 77, 0, 3, 84, 79, 80, 84, 6, 67, 69, 78, 84, 82, 69, 24, 36, 72, 79, 82, + 73, 90, 79, 78, 84, 65, 76, 32, 65, 78, 68, 32, 86, 69, 82, 84, 73, 67, + 65, 76, 32, 66, 73, 83, 69, 67, 84, 73, 78, 71, 32, 76, 73, 18, 76, 50, + 82, 214, 1, 85, 145, 1, 17, 86, 69, 82, 84, 73, 67, 65, 76, 32, 66, 73, + 83, 69, 67, 84, 73, 78, 2, 53, 11, 32, 72, 65, 76, 70, 32, 66, 73, 83, + 69, 67, 2, 11, 84, 2, 251, 109, 69, 2, 249, 23, 2, 32, 86, 2, 239, 29, + 78, 6, 18, 69, 15, 79, 2, 67, 70, 4, 247, 1, 87, 4, 18, 73, 115, 79, 2, + 17, 2, 71, 72, 2, 33, 6, 84, 87, 65, 82, 68, 83, 2, 11, 32, 2, 11, 84, 2, + 11, 73, 2, 171, 175, 1, 67, 2, 29, 5, 85, 78, 68, 69, 68, 2, 21, 3, 32, + 67, 79, 2, 249, 32, 2, 82, 78, 4, 17, 2, 80, 80, 4, 21, 3, 69, 82, 32, 4, + 44, 3, 76, 69, 70, 1, 4, 82, 73, 71, 72, 2, 33, 6, 84, 32, 81, 85, 65, + 68, 2, 231, 36, 82, 2, 251, 20, 71, 11, 11, 32, 8, 84, 12, 66, 69, 72, + 73, 78, 68, 32, 67, 76, 79, 85, 68, 69, 5, 87, 73, 84, 72, 32, 5, 29, 5, + 32, 87, 73, 84, 72, 2, 17, 2, 32, 82, 2, 211, 47, 65, 4, 38, 82, 29, 5, + 83, 77, 65, 76, 76, 2, 11, 65, 2, 135, 113, 89, 2, 11, 32, 2, 21, 3, 67, + 76, 79, 2, 143, 104, 85, 10, 38, 79, 54, 69, 62, 82, 203, 1, 87, 2, 49, + 10, 85, 67, 72, 84, 79, 78, 69, 32, 84, 69, 2, 17, 2, 76, 69, 2, 11, 80, + 2, 11, 72, 2, 231, 17, 79, 4, 148, 1, 4, 65, 80, 69, 90, 33, 28, 73, 65, + 78, 71, 76, 69, 32, 67, 79, 78, 84, 65, 73, 78, 73, 78, 71, 32, 83, 77, + 65, 76, 76, 32, 87, 72, 73, 84, 2, 11, 73, 2, 139, 155, 1, 85, 2, 135, 4, + 69, 2, 11, 79, 2, 85, 19, 45, 87, 65, 89, 32, 76, 69, 70, 84, 32, 87, 65, + 89, 32, 84, 82, 65, 70, 70, 2, 11, 73, 2, 207, 170, 1, 67, 12, 62, 32, + 185, 1, 10, 45, 80, 79, 73, 78, 84, 73, 78, 71, 32, 4, 11, 80, 4, 41, 8, + 79, 73, 78, 84, 73, 78, 71, 32, 4, 18, 66, 75, 73, 2, 21, 3, 65, 67, 75, + 2, 25, 4, 72, 65, 78, 68, 2, 17, 2, 32, 73, 2, 17, 2, 78, 68, 2, 147, 26, + 69, 8, 54, 67, 42, 83, 125, 7, 84, 82, 73, 65, 78, 71, 76, 2, 21, 3, 72, + 69, 86, 2, 135, 88, 82, 2, 25, 4, 77, 65, 76, 76, 2, 17, 2, 32, 84, 2, + 17, 2, 82, 73, 2, 11, 65, 2, 11, 78, 2, 11, 71, 2, 167, 144, 1, 76, 4, + 11, 69, 5, 11, 32, 2, 11, 87, 2, 145, 19, 3, 73, 84, 72, 10, 44, 6, 84, + 73, 67, 65, 76, 32, 143, 2, 89, 8, 58, 69, 48, 7, 82, 69, 67, 84, 65, 78, + 71, 147, 1, 66, 2, 11, 76, 2, 17, 2, 76, 73, 2, 247, 25, 80, 4, 17, 2, + 76, 69, 5, 37, 7, 32, 87, 73, 84, 72, 32, 72, 2, 37, 7, 79, 82, 73, 90, + 79, 78, 84, 2, 17, 2, 65, 76, 2, 11, 32, 2, 11, 66, 2, 159, 107, 65, 2, + 17, 2, 32, 83, 2, 11, 77, 2, 21, 3, 65, 76, 76, 2, 17, 2, 32, 83, 2, 11, + 81, 2, 11, 85, 2, 11, 65, 2, 167, 140, 1, 82, 2, 11, 69, 2, 11, 68, 2, + 17, 2, 32, 82, 2, 21, 3, 73, 71, 72, 2, 11, 84, 2, 11, 87, 2, 249, 4, 4, + 65, 82, 68, 83, 102, 148, 1, 10, 68, 69, 45, 72, 69, 65, 68, 69, 68, 32, + 132, 4, 5, 71, 71, 76, 89, 32, 180, 1, 6, 76, 84, 69, 68, 32, 70, 42, 78, + 189, 1, 2, 82, 69, 80, 128, 1, 3, 76, 69, 70, 0, 4, 82, 73, 71, 72, 12, + 4, 68, 79, 87, 78, 0, 2, 85, 80, 32, 3, 78, 79, 82, 1, 3, 83, 79, 85, 10, + 11, 84, 10, 109, 5, 87, 65, 82, 68, 83, 20, 21, 3, 84, 72, 32, 20, 32, 2, + 69, 65, 1, 2, 87, 69, 10, 17, 2, 83, 84, 10, 11, 32, 10, 110, 72, 0, 6, + 86, 69, 82, 89, 32, 72, 28, 5, 76, 73, 71, 72, 84, 0, 6, 77, 69, 68, 73, + 85, 77, 23, 66, 2, 25, 4, 69, 65, 86, 89, 2, 17, 2, 32, 66, 2, 21, 3, 65, + 82, 66, 2, 11, 32, 2, 11, 65, 2, 11, 82, 2, 11, 82, 2, 191, 30, 79, 4, + 18, 69, 47, 86, 2, 11, 88, 2, 249, 50, 4, 67, 76, 65, 77, 2, 11, 69, 2, + 25, 4, 82, 84, 73, 67, 2, 17, 2, 65, 76, 2, 11, 32, 2, 11, 76, 2, 11, 73, + 2, 219, 132, 1, 78, 2, 11, 76, 2, 11, 79, 2, 151, 93, 87, 12, 46, 68, + 106, 69, 190, 17, 75, 163, 136, 1, 71, 6, 22, 32, 143, 28, 79, 4, 44, 2, + 67, 72, 221, 17, 4, 66, 76, 79, 87, 2, 11, 73, 2, 155, 131, 1, 77, 2, 11, + 32, 2, 121, 3, 71, 76, 65, 4, 36, 5, 68, 32, 75, 69, 89, 51, 76, 2, 17, + 2, 66, 79, 2, 11, 65, 2, 207, 82, 82, 2, 11, 69, 2, 247, 90, 83, 30, 66, + 77, 134, 3, 82, 254, 13, 78, 226, 64, 79, 129, 9, 2, 76, 70, 14, 36, 2, + 65, 78, 137, 2, 2, 69, 78, 13, 72, 12, 32, 87, 73, 84, 72, 32, 66, 85, + 78, 78, 89, 32, 29, 2, 83, 32, 2, 11, 69, 2, 143, 6, 65, 8, 52, 2, 66, + 79, 16, 2, 67, 76, 54, 83, 199, 12, 72, 2, 251, 13, 79, 2, 11, 79, 2, 11, + 84, 2, 11, 72, 2, 167, 88, 69, 2, 17, 2, 65, 78, 2, 131, 10, 68, 2, 11, + 83, 2, 11, 32, 2, 11, 83, 2, 11, 89, 2, 17, 2, 77, 66, 2, 187, 9, 79, 10, + 72, 2, 68, 32, 156, 1, 3, 76, 68, 32, 32, 2, 82, 73, 247, 146, 1, 77, 4, + 56, 9, 83, 69, 80, 65, 82, 65, 84, 79, 82, 231, 85, 74, 2, 17, 2, 32, 77, + 2, 21, 3, 73, 68, 68, 2, 11, 76, 2, 11, 69, 2, 11, 32, 2, 235, 66, 68, 2, + 11, 77, 2, 251, 146, 1, 65, 2, 11, 69, 2, 199, 85, 68, 10, 56, 7, 65, 80, + 80, 69, 68, 32, 80, 30, 69, 163, 1, 73, 2, 241, 78, 3, 82, 69, 83, 6, 48, + 2, 65, 84, 80, 3, 83, 84, 76, 215, 110, 78, 2, 11, 72, 2, 11, 32, 2, 11, + 80, 2, 25, 4, 82, 79, 68, 85, 2, 223, 116, 67, 2, 11, 69, 2, 147, 83, 82, + 2, 11, 84, 2, 11, 73, 2, 17, 2, 78, 71, 2, 17, 2, 32, 72, 2, 11, 65, 2, + 243, 73, 78, 34, 76, 2, 32, 73, 138, 1, 45, 28, 7, 73, 65, 78, 71, 81, + 73, 32, 183, 85, 79, 2, 53, 11, 78, 32, 65, 32, 82, 69, 67, 84, 65, 78, + 71, 2, 11, 76, 2, 11, 69, 2, 11, 32, 2, 11, 66, 2, 11, 79, 2, 191, 142, + 1, 88, 2, 11, 82, 2, 215, 124, 65, 28, 48, 5, 66, 76, 65, 67, 75, 1, 3, + 82, 69, 68, 14, 11, 32, 14, 130, 1, 67, 72, 4, 69, 76, 69, 80, 28, 4, 71, + 69, 78, 69, 46, 72, 40, 4, 83, 79, 76, 68, 193, 11, 6, 77, 65, 78, 68, + 65, 82, 4, 24, 2, 65, 78, 19, 72, 2, 195, 60, 78, 2, 229, 59, 3, 65, 82, + 73, 2, 11, 72, 2, 219, 72, 65, 2, 11, 82, 2, 11, 65, 2, 207, 139, 1, 76, + 2, 11, 79, 2, 11, 82, 2, 207, 116, 83, 2, 167, 77, 73, 248, 19, 54, 65, + 206, 2, 69, 226, 11, 73, 217, 35, 2, 79, 45, 8, 84, 16, 78, 71, 81, 73, + 78, 32, 83, 73, 71, 78, 32, 83, 76, 79, 87, 32, 199, 1, 87, 6, 28, 3, 79, + 78, 69, 51, 84, 2, 17, 2, 32, 66, 2, 11, 69, 2, 131, 109, 65, 4, 60, 9, + 72, 82, 69, 69, 32, 72, 65, 76, 70, 1, 2, 87, 79, 2, 21, 3, 32, 66, 69, + 2, 11, 65, 2, 223, 74, 84, 2, 11, 78, 2, 11, 73, 2, 241, 74, 2, 78, 71, + 98, 60, 4, 76, 76, 79, 87, 62, 78, 53, 5, 90, 73, 68, 73, 32, 2, 17, 2, + 32, 72, 2, 11, 69, 2, 11, 65, 2, 227, 106, 82, 2, 11, 32, 2, 11, 83, 2, + 11, 73, 2, 251, 54, 71, 94, 112, 10, 67, 79, 77, 66, 73, 78, 73, 78, 71, + 32, 76, 5, 72, 89, 80, 72, 69, 17, 7, 76, 69, 84, 84, 69, 82, 32, 4, 44, + 3, 77, 65, 68, 13, 4, 72, 65, 77, 90, 2, 11, 68, 2, 215, 67, 65, 2, 215, + 27, 78, 88, 250, 1, 67, 50, 77, 18, 68, 42, 69, 58, 72, 30, 75, 22, 71, + 2, 81, 32, 3, 76, 65, 77, 98, 78, 18, 80, 30, 83, 66, 84, 28, 2, 86, 65, + 126, 87, 14, 79, 18, 88, 52, 3, 89, 79, 84, 154, 1, 90, 134, 53, 82, 238, + 48, 66, 254, 5, 85, 162, 14, 70, 3, 74, 6, 22, 72, 147, 114, 73, 4, 22, + 72, 251, 113, 73, 2, 247, 113, 73, 4, 11, 65, 4, 178, 130, 1, 68, 3, 76, + 8, 42, 76, 142, 50, 89, 226, 79, 84, 3, 87, 2, 71, 73, 4, 150, 112, 65, + 147, 15, 72, 4, 18, 72, 15, 65, 2, 11, 65, 2, 163, 129, 1, 70, 5, 11, 32, + 2, 11, 87, 2, 21, 3, 73, 84, 72, 2, 17, 2, 32, 68, 2, 11, 79, 2, 187, 3, + 84, 2, 207, 48, 85, 4, 202, 105, 72, 215, 22, 69, 8, 46, 72, 246, 47, 73, + 194, 9, 65, 163, 70, 69, 2, 243, 47, 73, 4, 238, 104, 72, 215, 22, 65, 5, + 37, 7, 32, 65, 76, 84, 69, 82, 78, 2, 17, 2, 65, 84, 2, 11, 69, 2, 11, + 32, 2, 11, 70, 2, 11, 79, 2, 227, 109, 82, 2, 11, 65, 2, 159, 126, 87, 4, + 22, 72, 251, 125, 65, 2, 11, 69, 2, 139, 46, 89, 5, 41, 8, 32, 87, 73, + 84, 72, 32, 67, 73, 2, 41, 8, 82, 67, 85, 77, 70, 76, 69, 88, 2, 11, 32, + 2, 11, 65, 2, 11, 66, 2, 11, 79, 2, 255, 101, 86, 6, 22, 65, 175, 124, + 69, 5, 171, 124, 76, 140, 19, 34, 32, 161, 35, 3, 78, 32, 89, 138, 19, + 88, 8, 82, 65, 68, 73, 67, 65, 76, 32, 181, 7, 9, 83, 89, 76, 76, 65, 66, + 76, 69, 32, 110, 170, 1, 66, 42, 67, 86, 68, 42, 71, 74, 72, 66, 74, 66, + 75, 30, 76, 30, 77, 26, 78, 74, 80, 26, 83, 74, 84, 30, 86, 30, 89, 30, + 90, 250, 35, 81, 198, 49, 87, 235, 30, 79, 4, 22, 66, 247, 64, 85, 2, + 163, 93, 85, 12, 42, 85, 18, 89, 178, 98, 72, 203, 22, 73, 2, 135, 121, + 79, 7, 130, 121, 80, 3, 84, 4, 22, 68, 215, 120, 85, 2, 247, 63, 85, 10, + 42, 71, 238, 91, 79, 162, 28, 69, 15, 65, 4, 162, 89, 85, 235, 30, 79, 8, + 22, 88, 243, 88, 77, 6, 238, 88, 85, 202, 2, 73, 163, 28, 79, 8, 22, 74, + 167, 119, 79, 6, 246, 90, 85, 218, 5, 73, 215, 22, 89, 4, 206, 90, 73, + 175, 28, 69, 6, 190, 54, 73, 199, 7, 89, 4, 182, 118, 79, 15, 73, 8, 30, + 89, 26, 90, 199, 90, 66, 4, 254, 117, 73, 3, 79, 2, 231, 117, 85, 4, 182, + 89, 85, 3, 89, 10, 22, 72, 223, 97, 83, 8, 214, 60, 85, 178, 28, 65, 162, + 28, 79, 15, 89, 4, 214, 88, 65, 175, 28, 85, 4, 138, 60, 85, 211, 56, 69, + 4, 158, 88, 73, 175, 28, 79, 10, 54, 85, 224, 62, 2, 90, 73, 238, 24, 79, + 175, 28, 65, 4, 246, 115, 80, 3, 82, 156, 18, 134, 2, 66, 134, 1, 67, + 162, 1, 68, 110, 70, 50, 71, 150, 1, 72, 138, 3, 73, 134, 1, 74, 98, 75, + 54, 76, 62, 77, 134, 1, 78, 234, 4, 80, 54, 81, 2, 89, 46, 82, 162, 1, + 83, 134, 1, 84, 102, 86, 82, 87, 58, 88, 50, 90, 140, 2, 2, 85, 79, 66, + 65, 2, 79, 107, 69, 132, 1, 66, 66, 238, 21, 85, 150, 1, 69, 26, 73, 42, + 65, 2, 79, 67, 89, 64, 234, 21, 85, 150, 1, 69, 26, 73, 42, 65, 2, 79, 3, + 89, 122, 66, 72, 238, 20, 85, 150, 1, 69, 26, 73, 42, 65, 2, 79, 67, 89, + 54, 46, 85, 146, 22, 65, 2, 69, 2, 79, 67, 89, 19, 142, 22, 79, 106, 82, + 230, 88, 80, 3, 88, 106, 58, 68, 138, 15, 85, 134, 5, 73, 94, 69, 66, 65, + 3, 79, 54, 210, 19, 85, 58, 73, 94, 69, 66, 65, 3, 79, 42, 182, 20, 79, + 66, 65, 2, 73, 2, 89, 67, 85, 116, 58, 71, 214, 15, 85, 146, 4, 73, 42, + 65, 2, 69, 3, 79, 56, 50, 73, 162, 15, 85, 186, 4, 65, 2, 69, 3, 79, 13, + 150, 19, 69, 142, 90, 84, 3, 88, 246, 1, 78, 73, 30, 76, 58, 77, 54, 78, + 110, 88, 50, 85, 254, 15, 69, 66, 65, 3, 79, 6, 198, 19, 69, 231, 88, 84, + 64, 238, 16, 85, 58, 73, 94, 69, 2, 79, 66, 65, 67, 89, 58, 182, 16, 85, + 58, 73, 158, 1, 65, 2, 79, 35, 89, 42, 46, 79, 34, 85, 202, 16, 69, 26, + 73, 43, 65, 6, 242, 106, 80, 2, 84, 3, 88, 6, 238, 17, 79, 231, 88, 84, + 46, 46, 85, 254, 15, 69, 26, 73, 42, 65, 3, 79, 8, 187, 16, 79, 19, 42, + 84, 130, 16, 69, 206, 89, 80, 3, 88, 5, 11, 69, 2, 11, 82, 2, 11, 65, 2, + 11, 84, 2, 11, 73, 2, 11, 79, 2, 191, 39, 78, 106, 50, 74, 190, 10, 85, + 146, 4, 73, 42, 79, 67, 89, 50, 158, 13, 85, 174, 1, 73, 42, 79, 3, 89, + 56, 242, 12, 85, 58, 73, 158, 1, 65, 2, 69, 3, 79, 70, 218, 9, 85, 250, + 3, 69, 26, 73, 42, 65, 2, 79, 67, 89, 106, 70, 71, 218, 8, 85, 158, 3, + 73, 158, 1, 65, 2, 79, 2, 89, 107, 69, 44, 186, 11, 85, 150, 1, 69, 66, + 65, 2, 79, 105, 2, 73, 69, 248, 2, 102, 66, 54, 68, 94, 71, 90, 74, 46, + 82, 50, 89, 78, 90, 134, 7, 85, 58, 73, 94, 65, 2, 69, 67, 79, 54, 202, + 10, 73, 158, 1, 65, 2, 79, 66, 85, 3, 89, 46, 46, 73, 198, 10, 69, 66, + 65, 2, 79, 67, 85, 13, 234, 11, 69, 230, 88, 80, 2, 84, 3, 88, 34, 60, 2, + 85, 79, 218, 9, 69, 0, 2, 73, 69, 66, 65, 3, 79, 7, 226, 99, 84, 3, 88, + 50, 230, 1, 85, 242, 7, 73, 42, 79, 67, 89, 46, 146, 9, 79, 66, 65, 2, + 69, 66, 85, 3, 89, 38, 30, 85, 222, 8, 73, 43, 79, 15, 194, 8, 79, 142, + 90, 80, 2, 84, 3, 88, 56, 62, 85, 206, 4, 79, 178, 2, 73, 158, 1, 65, 66, + 89, 43, 69, 15, 254, 8, 79, 2, 82, 230, 88, 80, 3, 88, 60, 150, 6, 85, + 58, 73, 158, 1, 65, 2, 79, 67, 89, 56, 254, 2, 85, 146, 4, 73, 42, 79, + 67, 89, 100, 58, 82, 254, 4, 85, 150, 1, 69, 66, 65, 2, 79, 67, 89, 48, + 46, 85, 162, 6, 69, 2, 79, 66, 89, 43, 65, 17, 134, 7, 79, 2, 82, 230, + 88, 80, 2, 84, 3, 88, 176, 1, 70, 83, 158, 3, 72, 50, 85, 58, 73, 94, 69, + 66, 65, 2, 79, 67, 89, 56, 130, 4, 73, 94, 69, 66, 65, 2, 79, 2, 85, 67, + 89, 56, 46, 85, 158, 3, 73, 94, 69, 66, 65, 3, 79, 21, 182, 4, 79, 106, + 82, 230, 88, 80, 2, 84, 3, 88, 60, 54, 69, 166, 3, 73, 42, 65, 2, 79, 66, + 85, 3, 89, 4, 150, 93, 80, 3, 88, 28, 38, 85, 206, 2, 69, 2, 79, 67, 65, + 9, 203, 2, 79, 40, 210, 2, 73, 42, 79, 66, 89, 41, 2, 85, 79, 178, 1, 66, + 72, 50, 85, 58, 73, 42, 90, 54, 69, 66, 65, 2, 79, 67, 89, 54, 46, 85, + 214, 1, 65, 2, 69, 2, 79, 67, 89, 19, 146, 1, 79, 170, 1, 82, 230, 88, + 80, 2, 84, 3, 88, 15, 90, 69, 142, 90, 80, 2, 84, 3, 88, 58, 50, 69, 2, + 79, 26, 73, 42, 65, 34, 85, 35, 89, 7, 138, 90, 80, 3, 88, 17, 38, 69, + 206, 89, 80, 2, 84, 3, 88, 9, 202, 89, 80, 2, 84, 3, 88, 11, 70, 82, 230, + 88, 80, 3, 88, 13, 38, 82, 230, 88, 80, 2, 84, 3, 88, 5, 227, 88, 88, 2, + 219, 7, 65, 2, 207, 57, 89, 180, 4, 252, 1, 10, 32, 78, 79, 84, 65, 84, + 73, 79, 78, 32, 224, 6, 16, 65, 78, 65, 66, 65, 90, 65, 82, 32, 83, 81, + 85, 65, 82, 69, 32, 210, 15, 69, 180, 2, 6, 73, 80, 80, 69, 82, 45, 96, + 8, 78, 65, 77, 69, 78, 78, 89, 32, 188, 33, 3, 79, 77, 66, 235, 26, 87, + 26, 144, 1, 9, 66, 65, 71, 32, 77, 69, 77, 66, 69, 42, 82, 104, 6, 68, + 79, 77, 65, 73, 78, 60, 3, 76, 69, 70, 154, 1, 83, 145, 2, 3, 84, 89, 80, + 2, 11, 82, 2, 11, 83, 2, 215, 83, 72, 8, 100, 4, 65, 78, 71, 69, 60, 3, + 73, 71, 72, 221, 1, 11, 69, 76, 65, 84, 73, 79, 78, 65, 76, 32, 67, 2, + 173, 3, 11, 32, 65, 78, 84, 73, 82, 69, 83, 84, 82, 73, 4, 17, 2, 84, 32, + 4, 60, 4, 73, 77, 65, 71, 13, 7, 66, 73, 78, 68, 73, 78, 71, 2, 11, 69, + 2, 25, 4, 32, 66, 82, 65, 2, 11, 67, 2, 175, 29, 75, 8, 44, 6, 67, 72, + 69, 77, 65, 32, 211, 1, 80, 6, 18, 67, 71, 80, 2, 17, 2, 79, 77, 2, 11, + 80, 2, 11, 79, 2, 11, 83, 2, 107, 73, 4, 30, 73, 41, 3, 82, 79, 74, 2, + 11, 80, 2, 11, 73, 2, 163, 80, 78, 2, 11, 69, 2, 11, 67, 2, 11, 84, 2, + 87, 73, 2, 139, 52, 79, 2, 11, 69, 2, 11, 32, 2, 11, 67, 2, 11, 79, 2, + 11, 76, 2, 11, 79, 2, 223, 79, 78, 144, 1, 240, 1, 2, 67, 76, 68, 7, 73, + 78, 73, 84, 73, 65, 76, 204, 2, 14, 70, 73, 78, 65, 76, 32, 67, 79, 78, + 83, 79, 78, 65, 78, 16, 7, 76, 69, 84, 84, 69, 82, 32, 148, 3, 5, 77, 65, + 82, 75, 32, 206, 1, 83, 181, 3, 6, 86, 79, 87, 69, 76, 32, 14, 64, 5, 79, + 83, 73, 78, 71, 137, 1, 6, 85, 83, 84, 69, 82, 45, 4, 11, 32, 4, 64, 12, + 68, 79, 85, 66, 76, 69, 45, 76, 73, 78, 69, 68, 23, 72, 2, 17, 2, 32, 72, + 2, 17, 2, 69, 65, 2, 215, 10, 68, 10, 96, 13, 70, 73, 78, 65, 76, 32, 76, + 69, 84, 84, 69, 82, 32, 41, 7, 73, 78, 73, 84, 73, 65, 76, 8, 238, 72, + 76, 2, 82, 2, 86, 3, 89, 2, 37, 7, 32, 76, 69, 84, 84, 69, 82, 2, 151, 6, + 32, 2, 131, 9, 84, 82, 166, 1, 68, 50, 75, 38, 78, 46, 83, 38, 84, 46, + 66, 2, 67, 2, 71, 2, 80, 2, 90, 138, 69, 45, 2, 72, 2, 74, 2, 76, 2, 77, + 2, 82, 2, 86, 2, 89, 187, 2, 65, 12, 206, 1, 68, 2, 90, 138, 69, 72, 187, + 2, 65, 6, 154, 70, 83, 14, 72, 187, 2, 65, 8, 130, 70, 71, 2, 78, 2, 89, + 187, 2, 65, 6, 214, 69, 72, 2, 83, 187, 2, 65, 12, 42, 83, 2, 84, 138, + 69, 72, 187, 2, 65, 4, 134, 69, 72, 187, 2, 65, 8, 50, 68, 58, 83, 40, 4, + 76, 79, 78, 71, 23, 84, 2, 29, 5, 79, 85, 66, 76, 69, 2, 11, 32, 2, 11, + 83, 2, 11, 72, 2, 11, 65, 2, 159, 70, 68, 2, 17, 2, 32, 84, 2, 17, 2, 83, + 72, 2, 147, 69, 69, 14, 36, 4, 73, 71, 78, 32, 255, 2, 85, 12, 54, 65, + 72, 6, 67, 65, 78, 68, 82, 65, 167, 1, 86, 2, 11, 78, 2, 11, 85, 2, 17, + 2, 83, 86, 2, 11, 65, 2, 135, 66, 82, 6, 36, 5, 66, 73, 78, 68, 85, 15, + 32, 5, 11, 32, 2, 25, 4, 87, 73, 84, 72, 2, 17, 2, 32, 79, 2, 21, 3, 82, + 78, 65, 2, 11, 77, 2, 11, 69, 2, 239, 38, 78, 4, 11, 73, 4, 18, 82, 19, + 83, 2, 219, 33, 65, 2, 11, 65, 2, 11, 82, 2, 139, 64, 71, 2, 151, 4, 66, + 20, 38, 76, 109, 5, 83, 73, 71, 78, 32, 2, 17, 2, 69, 78, 2, 11, 71, 2, + 11, 84, 2, 11, 72, 2, 11, 32, 2, 11, 77, 2, 11, 65, 2, 135, 62, 82, 18, + 86, 65, 26, 79, 2, 85, 16, 8, 82, 69, 86, 69, 82, 83, 69, 68, 146, 64, + 69, 3, 73, 4, 182, 64, 73, 3, 85, 5, 159, 64, 69, 2, 183, 44, 32, 12, 72, + 2, 66, 82, 16, 9, 82, 79, 32, 87, 73, 68, 84, 72, 32, 203, 1, 85, 2, 147, + 2, 65, 8, 32, 2, 78, 79, 86, 83, 31, 74, 4, 26, 45, 73, 2, 78, 45, 2, 29, + 5, 66, 82, 69, 65, 75, 2, 11, 32, 2, 11, 83, 2, 163, 1, 80, 2, 11, 74, 2, + 11, 79, 2, 11, 73, 2, 11, 78, 2, 143, 5, 69, 2, 219, 61, 83, 2, 21, 3, + 77, 79, 85, 2, 17, 2, 84, 72, 2, 11, 32, 2, 11, 70, 2, 11, 65, 2, 167, + 38, 67, 242, 2, 168, 1, 10, 67, 79, 77, 66, 73, 78, 73, 78, 71, 32, 224, + 18, 6, 78, 69, 85, 77, 69, 32, 181, 38, 17, 80, 82, 73, 90, 78, 65, 75, + 32, 77, 79, 68, 73, 70, 73, 69, 82, 32, 128, 1, 144, 2, 17, 76, 79, 87, + 69, 82, 32, 84, 79, 78, 65, 76, 32, 82, 65, 78, 71, 69, 88, 5, 77, 65, + 82, 75, 32, 148, 3, 18, 65, 84, 84, 65, 67, 72, 73, 78, 71, 32, 86, 69, + 82, 84, 73, 67, 65, 76, 233, 11, 17, 84, 79, 78, 65, 76, 32, 82, 65, 78, + 71, 69, 32, 77, 65, 82, 75, 32, 2, 33, 6, 32, 73, 78, 68, 73, 67, 2, 11, + 65, 2, 11, 84, 2, 11, 79, 2, 219, 56, 82, 118, 182, 2, 67, 142, 1, 68, + 104, 8, 71, 79, 82, 65, 90, 68, 79, 32, 34, 78, 106, 75, 114, 79, 72, 2, + 80, 79, 152, 2, 8, 77, 65, 76, 79, 32, 80, 79, 86, 100, 2, 82, 65, 50, + 83, 186, 1, 84, 108, 7, 86, 89, 83, 79, 75, 79, 32, 234, 1, 90, 224, 10, + 2, 76, 79, 224, 22, 4, 85, 68, 65, 82, 129, 6, 4, 66, 79, 82, 90, 6, 60, + 6, 72, 65, 83, 72, 75, 65, 29, 5, 85, 82, 86, 69, 68, 5, 197, 47, 3, 32, + 80, 79, 2, 17, 2, 32, 79, 2, 11, 77, 2, 235, 24, 69, 4, 240, 10, 13, 69, + 77, 69, 83, 84, 86, 69, 78, 78, 89, 32, 90, 65, 217, 14, 6, 86, 79, 69, + 84, 79, 67, 10, 30, 78, 89, 3, 86, 89, 83, 8, 29, 5, 73, 90, 75, 79, 32, + 8, 164, 8, 8, 83, 32, 75, 82, 89, 90, 72, 69, 35, 79, 2, 167, 20, 79, 8, + 56, 4, 82, 89, 90, 72, 150, 6, 65, 233, 39, 2, 85, 80, 5, 21, 3, 32, 79, + 78, 2, 11, 32, 2, 203, 7, 76, 6, 220, 5, 3, 84, 83, 69, 200, 13, 5, 66, + 76, 65, 67, 72, 131, 31, 78, 18, 22, 68, 131, 2, 86, 6, 60, 7, 67, 72, + 65, 83, 72, 73, 69, 201, 22, 3, 86, 69, 82, 5, 17, 2, 32, 87, 2, 21, 3, + 73, 84, 72, 2, 17, 2, 32, 86, 2, 29, 5, 69, 82, 84, 73, 67, 2, 17, 2, 65, + 76, 2, 11, 32, 2, 11, 83, 2, 11, 84, 2, 11, 82, 2, 11, 79, 2, 131, 25, + 75, 12, 29, 5, 89, 83, 72, 69, 32, 12, 22, 83, 251, 3, 79, 8, 154, 3, 32, + 229, 2, 4, 84, 82, 65, 78, 4, 28, 2, 90, 83, 183, 5, 86, 2, 219, 37, 69, + 10, 136, 1, 2, 75, 79, 16, 16, 84, 82, 65, 78, 78, 79, 32, 77, 65, 76, + 79, 32, 80, 79, 86, 89, 236, 1, 5, 82, 69, 68, 78, 69, 231, 26, 79, 2, + 239, 42, 66, 2, 11, 83, 2, 183, 22, 72, 10, 50, 79, 16, 5, 83, 65, 84, + 65, 32, 139, 36, 73, 2, 187, 28, 67, 6, 158, 1, 79, 201, 24, 3, 83, 32, + 75, 10, 24, 2, 83, 32, 95, 79, 6, 11, 75, 6, 44, 6, 72, 79, 75, 72, 76, + 79, 247, 24, 82, 4, 11, 77, 4, 17, 2, 32, 79, 4, 11, 78, 4, 11, 32, 4, + 18, 76, 31, 82, 2, 11, 69, 2, 179, 14, 70, 2, 11, 73, 2, 11, 71, 2, 139, + 14, 72, 6, 18, 65, 31, 69, 2, 249, 25, 3, 68, 69, 82, 4, 22, 86, 239, 10, + 76, 2, 199, 38, 79, 6, 60, 5, 77, 82, 65, 67, 72, 18, 83, 1, 4, 84, 82, + 69, 83, 2, 155, 10, 78, 2, 17, 2, 86, 69, 2, 155, 6, 84, 232, 1, 128, 2, + 2, 67, 72, 38, 68, 218, 1, 70, 28, 10, 71, 79, 76, 85, 66, 67, 72, 73, + 75, 32, 158, 1, 75, 160, 2, 6, 77, 69, 67, 72, 73, 75, 184, 1, 2, 78, 69, + 18, 79, 138, 2, 80, 146, 2, 82, 114, 83, 180, 20, 9, 86, 82, 65, 75, 72, + 73, 89, 65, 32, 151, 2, 90, 4, 246, 11, 69, 209, 10, 2, 65, 83, 10, 74, + 69, 98, 85, 16, 9, 86, 65, 32, 86, 32, 67, 72, 69, 76, 187, 27, 79, 4, + 76, 2, 82, 66, 213, 2, 12, 77, 69, 83, 84, 86, 69, 78, 78, 89, 32, 75, + 76, 2, 195, 34, 73, 2, 203, 34, 68, 2, 11, 78, 2, 231, 36, 85, 2, 11, 73, + 2, 147, 34, 84, 10, 78, 84, 38, 83, 240, 3, 5, 77, 82, 65, 67, 72, 145, + 14, 4, 66, 79, 82, 90, 4, 32, 3, 82, 69, 83, 251, 1, 73, 2, 21, 3, 86, + 69, 84, 2, 231, 17, 76, 14, 76, 4, 72, 65, 77, 73, 18, 76, 40, 3, 79, 66, + 89, 16, 2, 82, 89, 87, 85, 2, 219, 3, 76, 2, 11, 89, 2, 11, 85, 2, 151, + 33, 67, 2, 223, 31, 76, 6, 28, 2, 85, 75, 219, 32, 90, 5, 21, 3, 32, 84, + 73, 2, 11, 75, 2, 251, 15, 72, 2, 11, 70, 2, 11, 73, 2, 11, 83, 2, 215, + 30, 77, 11, 11, 32, 8, 44, 7, 75, 76, 89, 85, 67, 72, 69, 83, 80, 6, 64, + 9, 78, 69, 80, 79, 83, 84, 79, 89, 65, 14, 80, 163, 14, 86, 2, 39, 78, 2, + 25, 4, 79, 86, 79, 68, 2, 143, 14, 78, 2, 223, 22, 77, 14, 40, 2, 66, 76, + 41, 4, 83, 79, 75, 65, 2, 11, 65, 2, 11, 75, 2, 243, 30, 79, 13, 11, 32, + 10, 30, 75, 142, 26, 84, 39, 83, 6, 104, 11, 76, 89, 85, 67, 72, 69, 86, + 65, 89, 65, 32, 185, 25, 10, 82, 89, 85, 75, 79, 86, 65, 89, 65, 32, 4, + 202, 16, 78, 251, 8, 83, 14, 58, 65, 88, 8, 69, 82, 69, 86, 79, 68, 75, + 65, 27, 79, 6, 44, 3, 82, 65, 75, 222, 19, 76, 211, 5, 85, 2, 11, 76, 2, + 11, 73, 2, 171, 28, 84, 5, 153, 15, 2, 32, 78, 4, 68, 5, 68, 67, 72, 65, + 83, 245, 9, 7, 76, 75, 85, 76, 73, 90, 77, 2, 11, 72, 2, 219, 4, 73, 4, + 64, 11, 69, 86, 69, 82, 83, 69, 68, 32, 67, 72, 69, 139, 26, 79, 2, 25, + 4, 76, 89, 85, 83, 2, 215, 17, 84, 126, 96, 9, 75, 65, 77, 69, 89, 84, + 83, 65, 32, 148, 2, 8, 76, 79, 90, 72, 73, 84, 73, 69, 119, 84, 22, 128, + 1, 13, 68, 86, 79, 69, 67, 72, 69, 76, 78, 65, 89, 65, 32, 44, 7, 75, 76, + 89, 85, 67, 72, 69, 74, 84, 218, 18, 77, 119, 83, 8, 218, 10, 75, 110, + 78, 178, 8, 80, 75, 83, 6, 40, 5, 86, 65, 89, 65, 32, 243, 10, 78, 4, + 178, 15, 84, 183, 4, 83, 4, 162, 15, 73, 147, 4, 82, 9, 11, 32, 6, 48, 2, + 83, 32, 25, 6, 90, 65, 75, 82, 89, 84, 4, 166, 4, 75, 95, 90, 2, 11, 79, + 2, 211, 22, 69, 96, 92, 4, 65, 84, 89, 65, 172, 4, 6, 79, 80, 73, 84, 83, + 65, 189, 1, 5, 82, 69, 76, 65, 32, 23, 11, 32, 20, 76, 2, 83, 32, 236, 2, + 9, 90, 65, 75, 82, 89, 84, 65, 89, 65, 159, 5, 78, 14, 160, 1, 14, 68, + 86, 85, 77, 89, 65, 32, 90, 65, 80, 89, 65, 84, 89, 28, 7, 75, 82, 89, + 90, 72, 69, 77, 24, 2, 82, 79, 17, 8, 90, 65, 80, 89, 65, 84, 79, 89, 2, + 11, 77, 2, 215, 19, 73, 5, 189, 1, 2, 32, 73, 2, 203, 2, 71, 7, 21, 3, + 32, 73, 32, 4, 54, 75, 37, 9, 80, 79, 68, 67, 72, 65, 83, 72, 73, 2, 11, + 82, 2, 21, 3, 89, 90, 72, 2, 211, 1, 69, 5, 17, 2, 32, 83, 2, 17, 2, 32, + 90, 2, 29, 5, 65, 80, 89, 65, 84, 2, 11, 79, 2, 199, 17, 89, 7, 11, 32, + 4, 68, 6, 83, 32, 79, 67, 72, 75, 29, 7, 87, 73, 84, 72, 32, 83, 79, 2, + 11, 79, 2, 215, 16, 77, 2, 45, 9, 82, 79, 67, 72, 89, 65, 32, 78, 79, 2, + 11, 90, 2, 163, 7, 72, 68, 140, 1, 9, 68, 86, 79, 69, 67, 72, 69, 76, 78, + 162, 1, 75, 78, 78, 174, 1, 71, 152, 3, 8, 77, 82, 65, 67, 72, 78, 79, + 84, 42, 80, 75, 84, 10, 18, 79, 71, 65, 6, 64, 7, 80, 79, 86, 79, 68, 78, + 65, 189, 5, 4, 75, 82, 89, 90, 4, 17, 2, 89, 65, 5, 17, 2, 32, 75, 2, + 145, 5, 4, 76, 89, 85, 67, 26, 48, 6, 76, 89, 85, 67, 72, 69, 77, 2, 82, + 89, 4, 22, 78, 203, 6, 80, 2, 157, 8, 9, 69, 80, 79, 83, 84, 79, 89, 65, + 78, 22, 48, 7, 85, 75, 79, 86, 65, 89, 65, 195, 3, 90, 21, 11, 32, 18, + 54, 71, 236, 2, 5, 84, 82, 89, 65, 83, 179, 2, 80, 14, 21, 3, 82, 79, 77, + 14, 32, 4, 78, 65, 89, 65, 47, 79, 5, 237, 1, 7, 32, 87, 73, 84, 72, 32, + 83, 10, 92, 10, 75, 82, 89, 90, 72, 69, 86, 65, 89, 65, 17, 9, 80, 79, + 86, 79, 68, 78, 65, 89, 65, 5, 175, 2, 32, 7, 33, 6, 32, 87, 73, 84, 72, + 32, 4, 24, 2, 68, 79, 23, 83, 2, 41, 2, 85, 66, 2, 21, 3, 73, 78, 71, 2, + 133, 6, 6, 76, 69, 32, 90, 65, 80, 2, 175, 6, 75, 2, 237, 5, 3, 72, 69, + 86, 2, 11, 73, 2, 11, 75, 2, 187, 5, 72, 6, 22, 79, 187, 3, 82, 4, 28, 2, + 76, 85, 187, 1, 86, 2, 163, 1, 80, 8, 80, 5, 82, 89, 65, 83, 79, 153, 2, + 10, 73, 75, 72, 65, 89, 65, 32, 80, 85, 84, 6, 62, 80, 44, 4, 83, 84, 82, + 69, 173, 1, 4, 71, 76, 65, 83, 2, 17, 2, 79, 86, 2, 193, 1, 2, 79, 68, 2, + 171, 1, 76, 16, 88, 12, 75, 76, 89, 85, 67, 72, 69, 86, 65, 89, 65, 32, + 38, 77, 46, 80, 38, 84, 39, 83, 8, 34, 77, 46, 80, 38, 84, 39, 83, 2, 25, + 4, 82, 65, 67, 72, 2, 247, 1, 78, 2, 11, 82, 2, 205, 1, 2, 79, 83, 2, 11, + 82, 2, 11, 69, 2, 11, 83, 2, 157, 1, 4, 86, 69, 84, 76, 6, 30, 65, 121, + 3, 77, 69, 89, 4, 32, 4, 78, 79, 90, 72, 31, 80, 2, 11, 69, 2, 151, 3, + 75, 2, 17, 2, 89, 65, 2, 11, 84, 2, 11, 65, 2, 35, 89, 2, 11, 84, 2, 11, + 83, 2, 183, 2, 65, 10, 108, 11, 68, 73, 82, 69, 67, 84, 73, 79, 78, 32, + 70, 28, 3, 75, 82, 89, 28, 5, 76, 69, 86, 69, 76, 35, 82, 2, 11, 76, 2, + 159, 1, 73, 2, 11, 90, 2, 143, 1, 72, 4, 11, 45, 4, 114, 50, 3, 51, 2, + 11, 79, 2, 83, 71, 8, 26, 78, 34, 83, 15, 74, 4, 18, 66, 27, 74, 2, 11, + 83, 2, 11, 80, 3, 0, }; static const unsigned int dawg_pos_to_codepoint[] = { @@ -9310,7 +9528,7 @@ static const unsigned int dawg_pos_to_codepoint[] = { 125248, 125242, 125238, 125221, 125235, 125250, 125247, 125234, 125245, 125243, 125223, 125251, 125241, 125220, 125239, 125249, 125218, 125225, 125222, 125232, 125236, 125233, 125244, 125224, 125228, 125240, 125226, - 125246, 125227, 125229, 125230, 125237, 125257, 125254, 125278, 125279, + 125246, 125227, 125229, 125230, 125237, 125257, 125254, 125279, 125278, 125259, 125258, 125255, 125252, 125253, 125269, 125268, 125271, 125270, 125267, 125266, 125264, 125273, 125265, 125272, 11237, 127903, 129657, 8449, 129489, 9772, 65852, 65853, 65854, 65855, 65848, 65851, 65849, @@ -9332,106 +9550,109 @@ static const unsigned int dawg_pos_to_codepoint[] = { 128805, 128800, 128803, 128804, 128798, 128869, 128870, 128871, 128872, 128873, 128787, 128865, 128866, 128864, 128880, 128794, 128841, 128883, 128882, 128854, 128878, 128796, 128797, 128801, 128810, 128851, 128784, - 128785, 128786, 128824, 128881, 128789, 128879, 128782, 128843, 128858, - 128856, 128868, 128867, 128863, 128768, 128833, 128818, 128816, 128817, - 128799, 128819, 128820, 128821, 128827, 128828, 128877, 128792, 128793, - 128788, 128806, 128813, 128825, 128850, 128860, 128861, 128814, 128807, - 128812, 128802, 128862, 128781, 128839, 128795, 128852, 128847, 128831, - 128832, 128840, 128809, 128849, 128845, 128778, 128815, 128779, 128780, - 128790, 128791, 128808, 128772, 128842, 128853, 128771, 128770, 128838, - 9879, 8501, 983054, 128126, 117837, 117836, 117844, 117845, 117842, - 117843, 117839, 117838, 117841, 117840, 8780, 9006, 983203, 8776, 10863, - 8778, 9095, 9941, 118479, 127994, 38, 127944, 128657, 10815, 82970, - 82971, 82964, 82965, 82966, 82967, 82968, 82969, 82972, 82973, 82974, - 82994, 82995, 82996, 82987, 82988, 82992, 82993, 82986, 82989, 82990, - 82991, 82997, 82998, 82999, 83016, 83017, 83018, 83019, 83010, 83011, - 83012, 83013, 83014, 83015, 83020, 83021, 83022, 83050, 83051, 83052, - 83053, 83043, 83044, 83045, 83046, 83047, 83048, 83049, 83054, 82984, - 82985, 82975, 82976, 82977, 82978, 82979, 82980, 82981, 82982, 82983, - 82953, 82954, 82955, 82956, 82957, 82958, 82959, 82960, 82961, 82962, - 82963, 82944, 82945, 82946, 82947, 82948, 82949, 82950, 82951, 82952, - 83000, 83001, 83002, 83003, 83004, 83005, 83006, 83007, 83008, 83009, - 83023, 83024, 83025, 83026, 83027, 83028, 83029, 83030, 83031, 83032, - 83033, 83034, 83035, 83036, 83037, 83038, 83039, 83040, 83041, 83042, - 83062, 83063, 83064, 83065, 83070, 83071, 83072, 83073, 83066, 83067, - 83068, 83055, 83056, 83057, 83058, 83059, 83060, 83061, 83069, 83074, - 83075, 83076, 83077, 83078, 83083, 83084, 83079, 83080, 83081, 83082, - 83085, 83086, 83087, 83088, 83094, 83095, 83089, 83090, 83091, 83092, - 83093, 83096, 83097, 83098, 83099, 83105, 83106, 83100, 83101, 83102, - 83103, 83104, 83107, 83108, 83109, 83110, 83111, 83112, 83113, 83114, - 83115, 83116, 83117, 83118, 83119, 83120, 83121, 83122, 83123, 83124, - 83125, 83126, 83127, 83128, 83129, 83130, 83131, 83132, 83133, 83134, - 83135, 83136, 83137, 83138, 83139, 83140, 83141, 83142, 83143, 83144, - 83145, 83146, 83147, 83148, 83149, 83150, 83151, 83152, 83153, 83154, - 83155, 83156, 83157, 83158, 83159, 83160, 83161, 83162, 83163, 83164, - 83165, 83166, 83167, 83168, 83169, 83170, 83173, 83174, 83175, 83180, - 83181, 83183, 83184, 83171, 83172, 83176, 83177, 83178, 83179, 83182, - 83190, 83191, 83192, 83193, 83185, 83186, 83187, 83188, 83189, 83194, - 83195, 83196, 83274, 83275, 83280, 83281, 83270, 83271, 83272, 83273, - 83276, 83277, 83278, 83279, 83268, 83269, 83259, 83260, 83261, 83262, - 83263, 83264, 83265, 83266, 83267, 83204, 83205, 83197, 83198, 83199, - 83200, 83201, 83202, 83203, 83206, 83207, 83245, 83246, 83238, 83239, - 83240, 83241, 83242, 83243, 83244, 83247, 83248, 83208, 83209, 83210, - 83211, 83212, 83213, 83214, 83215, 83216, 83217, 83218, 83219, 83220, - 83221, 83222, 83223, 83224, 83225, 83226, 83227, 83228, 83229, 83230, - 83231, 83232, 83233, 83234, 83235, 83236, 83237, 83249, 83250, 83251, - 83252, 83253, 83254, 83255, 83256, 83257, 83258, 83291, 83292, 83282, - 83283, 83284, 83285, 83286, 83287, 83288, 83289, 83290, 83312, 83313, - 83303, 83304, 83305, 83306, 83307, 83308, 83309, 83310, 83311, 83348, - 83349, 83339, 83340, 83341, 83342, 83343, 83344, 83345, 83346, 83347, - 83322, 83323, 83324, 83325, 83316, 83317, 83318, 83314, 83315, 83319, - 83320, 83321, 83326, 83327, 83328, 83354, 83355, 83359, 83360, 83350, - 83351, 83352, 83353, 83356, 83357, 83358, 83361, 83377, 83378, 83374, - 83375, 83381, 83382, 83373, 83376, 83379, 83380, 83383, 83384, 83385, - 83389, 83386, 83387, 83388, 83390, 83391, 83392, 83393, 83394, 83395, - 83363, 83364, 83362, 83365, 83366, 83367, 83368, 83369, 83370, 83371, - 83372, 83293, 83294, 83295, 83296, 83297, 83298, 83299, 83300, 83301, - 83302, 83329, 83330, 83331, 83332, 83333, 83334, 83335, 83336, 83337, - 83338, 83406, 83407, 83408, 83409, 83410, 83411, 83412, 83413, 83414, - 83415, 83416, 83447, 83448, 83455, 83456, 83449, 83450, 83451, 83452, - 83453, 83454, 83457, 83458, 83489, 83490, 83491, 83492, 83493, 83494, - 83495, 83496, 83396, 83397, 83398, 83399, 83400, 83401, 83402, 83403, - 83404, 83405, 83417, 83418, 83419, 83420, 83421, 83422, 83423, 83424, - 83425, 83426, 83427, 83428, 83429, 83430, 83431, 83432, 83433, 83434, - 83435, 83436, 83437, 83438, 83439, 83440, 83441, 83442, 83443, 83444, - 83445, 83446, 83459, 83460, 83461, 83462, 83463, 83464, 83465, 83466, - 83467, 83468, 83469, 83470, 83471, 83472, 83473, 83474, 83475, 83476, - 83477, 83478, 83479, 83480, 83481, 83482, 83483, 83484, 83485, 83486, - 83487, 83488, 83526, 83497, 83498, 83499, 83500, 83501, 83502, 83503, - 83504, 83505, 83506, 83507, 83508, 83509, 83510, 83511, 83512, 83513, - 83514, 83515, 83516, 83517, 83518, 83519, 83520, 83521, 83522, 83523, - 83524, 83525, 129728, 8736, 10654, 10660, 128551, 8491, 128162, 128544, - 128028, 117768, 128246, 11150, 11148, 11149, 11151, 11119, 8630, 10560, - 8755, 128260, 10226, 8634, 10769, 9875, 10193, 9765, 9021, 9055, 9061, - 9033, 9052, 9022, 9066, 9058, 9067, 9042, 9049, 9035, 9034, 9038, 9062, - 9073, 9046, 9050, 9075, 9080, 9014, 9082, 9078, 9077, 9081, 9060, 9051, - 9063, 9029, 9109, 9020, 9056, 9017, 9018, 9036, 9047, 9044, 9037, 9043, - 9040, 9027, 9031, 9072, 9071, 9016, 9026, 9025, 9028, 9032, 9019, 9054, - 9048, 9030, 9076, 9070, 9023, 9059, 9069, 9015, 9079, 9024, 9074, 9057, - 9041, 9045, 9053, 9039, 9065, 9064, 9068, 39, 11236, 983195, 118461, - 8773, 8786, 10864, 8774, 8784, 983196, 2183, 69328, 69372, 1548, 2277, - 2280, 2276, 2279, 2278, 2281, 1615, 65144, 65145, 2302, 1612, 65138, - 1549, 2299, 2300, 69370, 2206, 1643, 2274, 1771, 1770, 1565, 1757, 1614, - 1630, 2293, 2292, 65142, 65143, 1611, 65136, 1538, 1645, 1748, 2207, - 1621, 1620, 1616, 2294, 65146, 65147, 1613, 65140, 2258, 2255, 2254, - 2257, 2236, 2244, 2235, 2237, 1593, 1886, 2227, 1696, 1887, 1885, 65226, - 65227, 65225, 65228, 1575, 2165, 2176, 2173, 2161, 2174, 2171, 2167, - 2177, 2169, 2166, 2168, 2178, 2164, 2160, 2162, 2175, 2172, 1571, 65156, - 65155, 1573, 65160, 65159, 1651, 1650, 1908, 1907, 1570, 65154, 65153, - 2163, 2170, 1649, 64337, 64336, 1609, 65264, 65263, 65166, 65165, 1749, - 1576, 2230, 1878, 2208, 1874, 1875, 1872, 1876, 1877, 1873, 2209, 65168, - 65169, 65167, 65170, 1664, 64347, 64348, 64346, 64349, 1659, 64339, - 64340, 64338, 64341, 1583, 1882, 1774, 1679, 2222, 69314, 1881, 1674, - 1675, 1680, 1673, 65194, 65193, 1676, 64389, 64388, 1590, 1787, 65214, - 65215, 65213, 65216, 1677, 64387, 64386, 1672, 64393, 64392, 1646, 1697, - 1647, 1668, 64371, 64372, 64370, 64373, 1678, 64391, 64390, 1740, 1911, - 1910, 1909, 1599, 1598, 1597, 64509, 64510, 64508, 64511, 1601, 1699, - 2212, 1698, 1889, 1701, 1888, 65234, 65235, 65233, 65236, 1711, 1716, - 1714, 1712, 2224, 64403, 64404, 64402, 64405, 1594, 2243, 1788, 65230, - 65231, 65229, 65232, 1715, 64407, 64408, 64406, 64409, 2248, 1581, 1916, - 2186, 1903, 1906, 1902, 1880, 1669, 1666, 1879, 1665, 65186, 65187, - 65185, 65188, 1569, 65152, 1607, 1729, 1730, 64423, 64424, 64422, 64425, - 1791, 1728, 64421, 64420, 1726, 64427, 64428, 64426, 64429, 65258, 65259, + 128785, 128786, 118483, 128881, 128824, 128789, 128879, 128838, 118482, + 128782, 128843, 128858, 128856, 128868, 128867, 128863, 128768, 128833, + 128818, 128816, 128817, 128799, 128819, 128820, 128821, 128827, 128828, + 128877, 128792, 128793, 128788, 128806, 128813, 118484, 128825, 128850, + 128860, 128861, 128814, 128807, 128812, 128802, 128862, 128781, 128839, + 128795, 128852, 128847, 128831, 128832, 128840, 128809, 128849, 128845, + 128778, 128815, 128779, 128780, 128790, 128791, 128808, 128772, 128842, + 128853, 128771, 128770, 9879, 8501, 983054, 128126, 117837, 117836, + 117844, 117845, 117842, 117843, 117839, 117838, 117841, 117840, 8780, + 9006, 983203, 8776, 10863, 8778, 9095, 9941, 118479, 127994, 38, 127944, + 128657, 10815, 82970, 82971, 82964, 82965, 82966, 82967, 82968, 82969, + 82972, 82973, 82974, 82994, 82995, 82996, 82987, 82988, 82992, 82993, + 82986, 82989, 82990, 82991, 82997, 82998, 82999, 83016, 83017, 83018, + 83019, 83010, 83011, 83012, 83013, 83014, 83015, 83020, 83021, 83022, + 83050, 83051, 83052, 83053, 83043, 83044, 83045, 83046, 83047, 83048, + 83049, 83054, 82984, 82985, 82975, 82976, 82977, 82978, 82979, 82980, + 82981, 82982, 82983, 82953, 82954, 82955, 82956, 82957, 82958, 82959, + 82960, 82961, 82962, 82963, 82944, 82945, 82946, 82947, 82948, 82949, + 82950, 82951, 82952, 83000, 83001, 83002, 83003, 83004, 83005, 83006, + 83007, 83008, 83009, 83023, 83024, 83025, 83026, 83027, 83028, 83029, + 83030, 83031, 83032, 83033, 83034, 83035, 83036, 83037, 83038, 83039, + 83040, 83041, 83042, 83062, 83063, 83064, 83065, 83070, 83071, 83072, + 83073, 83066, 83067, 83068, 83055, 83056, 83057, 83058, 83059, 83060, + 83061, 83069, 83074, 83075, 83076, 83077, 83078, 83083, 83084, 83079, + 83080, 83081, 83082, 83085, 83086, 83087, 83088, 83094, 83095, 83089, + 83090, 83091, 83092, 83093, 83096, 83097, 83098, 83099, 83105, 83106, + 83100, 83101, 83102, 83103, 83104, 83107, 83108, 83109, 83110, 83111, + 83112, 83113, 83114, 83115, 83116, 83117, 83118, 83119, 83120, 83121, + 83122, 83123, 83124, 83125, 83126, 83127, 83128, 83129, 83130, 83131, + 83132, 83133, 83134, 83135, 83136, 83137, 83138, 83139, 83140, 83141, + 83142, 83143, 83144, 83145, 83146, 83147, 83148, 83149, 83150, 83151, + 83152, 83153, 83154, 83155, 83156, 83157, 83158, 83159, 83160, 83161, + 83162, 83163, 83164, 83165, 83166, 83167, 83168, 83169, 83170, 83173, + 83174, 83175, 83180, 83181, 83183, 83184, 83171, 83172, 83176, 83177, + 83178, 83179, 83182, 83190, 83191, 83192, 83193, 83185, 83186, 83187, + 83188, 83189, 83194, 83195, 83196, 83274, 83275, 83280, 83281, 83270, + 83271, 83272, 83273, 83276, 83277, 83278, 83279, 83268, 83269, 83259, + 83260, 83261, 83262, 83263, 83264, 83265, 83266, 83267, 83204, 83205, + 83197, 83198, 83199, 83200, 83201, 83202, 83203, 83206, 83207, 83245, + 83246, 83238, 83239, 83240, 83241, 83242, 83243, 83244, 83247, 83248, + 83208, 83209, 83210, 83211, 83212, 83213, 83214, 83215, 83216, 83217, + 83218, 83219, 83220, 83221, 83222, 83223, 83224, 83225, 83226, 83227, + 83228, 83229, 83230, 83231, 83232, 83233, 83234, 83235, 83236, 83237, + 83249, 83250, 83251, 83252, 83253, 83254, 83255, 83256, 83257, 83258, + 83291, 83292, 83282, 83283, 83284, 83285, 83286, 83287, 83288, 83289, + 83290, 83312, 83313, 83303, 83304, 83305, 83306, 83307, 83308, 83309, + 83310, 83311, 83348, 83349, 83339, 83340, 83341, 83342, 83343, 83344, + 83345, 83346, 83347, 83322, 83323, 83324, 83325, 83316, 83317, 83318, + 83314, 83315, 83319, 83320, 83321, 83326, 83327, 83328, 83354, 83355, + 83359, 83360, 83350, 83351, 83352, 83353, 83356, 83357, 83358, 83361, + 83377, 83378, 83374, 83375, 83381, 83382, 83373, 83376, 83379, 83380, + 83383, 83384, 83385, 83389, 83386, 83387, 83388, 83390, 83391, 83392, + 83393, 83394, 83395, 83363, 83364, 83362, 83365, 83366, 83367, 83368, + 83369, 83370, 83371, 83372, 83293, 83294, 83295, 83296, 83297, 83298, + 83299, 83300, 83301, 83302, 83329, 83330, 83331, 83332, 83333, 83334, + 83335, 83336, 83337, 83338, 83406, 83407, 83408, 83409, 83410, 83411, + 83412, 83413, 83414, 83415, 83416, 83447, 83448, 83455, 83456, 83449, + 83450, 83451, 83452, 83453, 83454, 83457, 83458, 83489, 83490, 83491, + 83492, 83493, 83494, 83495, 83496, 83396, 83397, 83398, 83399, 83400, + 83401, 83402, 83403, 83404, 83405, 83417, 83418, 83419, 83420, 83421, + 83422, 83423, 83424, 83425, 83426, 83427, 83428, 83429, 83430, 83431, + 83432, 83433, 83434, 83435, 83436, 83437, 83438, 83439, 83440, 83441, + 83442, 83443, 83444, 83445, 83446, 83459, 83460, 83461, 83462, 83463, + 83464, 83465, 83466, 83467, 83468, 83469, 83470, 83471, 83472, 83473, + 83474, 83475, 83476, 83477, 83478, 83479, 83480, 83481, 83482, 83483, + 83484, 83485, 83486, 83487, 83488, 83526, 83497, 83498, 83499, 83500, + 83501, 83502, 83503, 83504, 83505, 83506, 83507, 83508, 83509, 83510, + 83511, 83512, 83513, 83514, 83515, 83516, 83517, 83518, 83519, 83520, + 83521, 83522, 83523, 83524, 83525, 129728, 8736, 10654, 10660, 118524, + 128551, 8491, 128162, 128544, 128028, 117768, 128246, 11150, 11148, + 11149, 11151, 11119, 8630, 10560, 8755, 128260, 10226, 8634, 10769, 9875, + 10193, 9765, 9021, 9055, 9061, 9033, 9052, 9022, 9066, 9058, 9067, 9042, + 9049, 9035, 9034, 9038, 9062, 9073, 9046, 9050, 9075, 9080, 9014, 9082, + 9078, 9077, 9081, 9060, 9051, 9063, 9029, 9109, 9020, 9056, 9017, 9018, + 9036, 9047, 9044, 9037, 9043, 9040, 9027, 9031, 9072, 9071, 9016, 9026, + 9025, 9028, 9032, 9019, 9054, 9048, 9030, 9076, 9070, 9023, 9059, 9069, + 9015, 9079, 9024, 9074, 9057, 9041, 9045, 9053, 9039, 9065, 9064, 9068, + 39, 11236, 983195, 118461, 8773, 8786, 10864, 8774, 8784, 983196, 2183, + 69328, 69372, 1548, 69340, 69348, 69339, 69345, 69344, 69346, 69342, + 69357, 69343, 69354, 69341, 69355, 69337, 69352, 69338, 69358, 69349, + 69351, 69356, 69353, 69350, 69347, 2277, 2280, 2276, 2279, 2278, 2281, + 1615, 65144, 65145, 2302, 1612, 65138, 1549, 2299, 2300, 69370, 2206, + 1643, 2274, 1771, 1770, 1565, 1757, 1614, 1630, 2293, 2292, 65142, 65143, + 1611, 65136, 69362, 1645, 1538, 1748, 2207, 1621, 1620, 1616, 2294, + 65146, 65147, 1613, 65140, 2258, 2255, 2254, 2257, 69327, 2236, 2244, + 2235, 2237, 1593, 1886, 2227, 1696, 1887, 1885, 65226, 65227, 65225, + 65228, 1575, 2165, 2176, 2173, 2161, 2174, 2171, 2167, 2177, 2169, 2166, + 2168, 2178, 2164, 2160, 2162, 2175, 2172, 1571, 65156, 65155, 1573, + 65160, 65159, 1651, 1650, 1908, 1907, 1570, 65154, 65153, 2163, 2170, + 1649, 64337, 64336, 1609, 65264, 65263, 65166, 65165, 1749, 1576, 2230, + 1878, 2208, 1874, 1875, 1872, 1876, 1877, 1873, 2209, 65168, 65169, + 65167, 65170, 1664, 64347, 64348, 64346, 64349, 1659, 64339, 64340, + 64338, 64341, 1583, 1882, 1774, 1679, 2222, 69314, 1881, 1674, 1675, + 1680, 1673, 65194, 65193, 1676, 64389, 64388, 1590, 1787, 65214, 65215, + 65213, 65216, 1677, 64387, 64386, 1672, 64393, 64392, 1646, 1697, 1647, + 1668, 64371, 64372, 64370, 64373, 1678, 64391, 64390, 1740, 1911, 1910, + 1909, 1599, 1598, 1597, 64509, 64510, 64508, 64511, 1601, 1699, 2212, + 1698, 1889, 1701, 1888, 65234, 65235, 65233, 65236, 1711, 1716, 1714, + 1712, 2224, 64403, 64404, 64402, 64405, 1594, 2243, 1788, 65230, 65231, + 65229, 65232, 1715, 64407, 64408, 64406, 64409, 2248, 1581, 1916, 2186, + 1903, 1906, 1902, 1880, 1669, 1666, 1879, 1665, 65186, 65187, 65185, + 65188, 1569, 65152, 1607, 1729, 1730, 64423, 64424, 64422, 64425, 1791, + 1728, 64421, 64420, 1726, 64427, 64428, 64426, 64429, 65258, 65259, 65257, 65260, 1652, 1653, 1656, 1654, 1580, 2210, 2246, 2245, 65182, 65183, 65181, 65184, 1688, 64395, 64394, 1603, 69316, 1919, 1710, 2228, 1708, 1707, 65242, 65243, 65241, 65244, 1568, 1705, 1892, 1596, 1891, @@ -9444,7 +9665,7 @@ static const unsigned int dawg_pos_to_codepoint[] = { 1724, 2191, 1721, 65254, 65255, 65253, 65256, 1662, 2231, 2238, 64343, 64344, 64342, 64345, 1702, 64367, 64368, 64366, 64369, 1602, 2213, 2229, 1703, 1704, 65238, 65239, 65237, 65240, 1585, 1905, 2233, 1682, 1685, - 1883, 1899, 1687, 1775, 1900, 1689, 1684, 1686, 2218, 1683, 65198, 65197, + 1883, 1899, 1687, 1775, 1900, 1689, 2218, 1684, 1686, 1683, 65198, 65197, 1681, 64397, 64396, 1723, 64417, 64418, 64416, 64419, 2220, 1589, 2223, 1694, 1693, 65210, 65211, 65209, 65212, 1587, 1690, 1918, 1904, 1691, 1692, 1901, 1884, 1917, 65202, 65203, 65201, 65204, 1588, 1786, 65206, @@ -9460,49 +9681,49 @@ static const unsigned int dawg_pos_to_codepoint[] = { 64433, 64432, 64431, 64430, 1574, 65162, 65163, 65161, 65164, 1742, 2216, 2234, 2217, 1745, 1741, 69319, 65266, 65267, 65265, 65268, 1736, 64476, 64475, 1734, 64474, 64473, 1592, 65222, 65223, 65221, 65224, 1586, 65200, - 65199, 2226, 1744, 64485, 64486, 64484, 64487, 2297, 2295, 64888, 64887, - 64886, 64950, 64699, 64554, 64964, 64885, 64698, 64553, 64787, 64759, + 65199, 2226, 1744, 64485, 64486, 64484, 64487, 2297, 2295, 64888, 64886, + 64887, 64950, 64699, 64554, 64885, 64964, 64698, 64553, 64787, 64759, 64788, 64760, 64465, 64973, 64842, 64839, 64466, 69331, 64841, 69330, 64840, 69329, 64845, 65015, 64656, 64605, 64828, 64829, 65010, 65011, 65023, 64962, 64669, 64518, 64672, 64738, 64926, 64670, 64519, 64622, 64521, 64668, 64517, 64620, 64671, 64520, 64737, 64621, 64619, 64618, - 64623, 64522, 65021, 64878, 64939, 64693, 64547, 64880, 64879, 64694, + 64623, 64522, 65021, 64878, 64939, 64693, 64547, 64879, 64880, 64694, 64548, 64803, 64775, 64692, 64546, 64695, 64549, 64812, 64784, 64804, - 64776, 64452, 64893, 64892, 64704, 64559, 64636, 64561, 64702, 64557, + 64776, 64452, 64892, 64893, 64704, 64559, 64636, 64561, 64702, 64557, 64961, 64705, 64560, 64703, 64558, 64637, 64562, 64889, 64891, 64890, 64701, 64556, 64789, 64761, 64700, 64555, 64790, 64762, 64462, 64463, 64460, 64461, 64859, 64858, 64682, 64536, 64795, 64767, 64959, 64681, 64535, 64796, 64768, 64915, 64916, 64728, 64594, 64595, 64596, 64727, - 64593, 64729, 65019, 64451, 64934, 64958, 64679, 64533, 64857, 64856, + 64593, 64729, 65019, 64451, 64934, 64958, 64679, 64533, 64856, 64857, 64935, 64933, 64680, 64534, 64797, 64769, 64798, 64770, 64643, 64573, 64640, 64567, 64708, 64568, 64641, 64711, 64571, 64747, 64710, 64570, - 64709, 64569, 64963, 64955, 64951, 64642, 64712, 64572, 64748, 64644, + 64709, 64569, 64955, 64963, 64951, 64642, 64712, 64572, 64748, 64644, 64574, 64974, 64538, 64799, 64771, 64683, 64537, 64684, 64539, 64800, 64772, 65272, 65271, 65274, 65273, 65270, 65269, 64646, 64579, 65276, - 65275, 64898, 64949, 64896, 64897, 64714, 64576, 64717, 64899, 64900, - 64954, 64956, 64940, 64713, 64575, 64902, 64901, 64715, 64577, 64904, - 64903, 64941, 64645, 64716, 64578, 64749, 64647, 64580, 64585, 64648, + 65275, 64898, 64896, 64949, 64897, 64714, 64576, 64717, 64900, 64899, + 64956, 64954, 64940, 64713, 64575, 64901, 64902, 64715, 64577, 64903, + 64904, 64941, 64645, 64716, 64578, 64749, 64647, 64580, 64585, 64648, 64905, 64906, 64907, 64719, 64582, 64910, 64911, 64953, 64720, 64583, 64909, 64914, 64908, 64960, 64718, 64581, 64945, 64649, 64721, 64584, - 64586, 65012, 64918, 64917, 64947, 64723, 64588, 64726, 64751, 64952, - 64957, 64921, 64920, 64919, 64967, 64722, 64587, 64923, 64922, 64652, + 64586, 65012, 64918, 64917, 64947, 64723, 64588, 64726, 64751, 64957, + 64952, 64921, 64919, 64920, 64967, 64722, 64587, 64923, 64922, 64652, 64725, 64590, 64750, 64654, 64591, 64653, 64651, 64724, 64589, 64650, - 64655, 64592, 69336, 64895, 64948, 64894, 64946, 64707, 64564, 64638, + 64655, 64592, 69336, 64895, 64894, 64948, 64946, 64707, 64564, 64638, 64565, 64706, 64563, 64639, 64566, 65009, 69332, 69333, 69334, 64843, 69335, 64833, 64835, 64836, 64837, 64834, 64969, 64459, 64971, 64970, 64832, 64968, 64847, 64456, 64457, 64458, 64912, 64454, 64455, 64913, - 64453, 65014, 64604, 64869, 64868, 64937, 64689, 64544, 64965, 64870, + 64453, 65014, 64604, 64868, 64869, 64937, 64689, 64544, 64870, 64965, 64691, 64545, 64801, 64773, 64690, 64811, 64783, 64802, 64774, 65013, 64975, 65008, 65017, 64464, 64838, 64972, 64844, 65018, 64860, 64686, 64541, 64821, 64817, 64744, 64862, 64861, 64685, 64540, 64820, 64936, - 64966, 64687, 64542, 64822, 64864, 64863, 64865, 64867, 64866, 64688, + 64966, 64687, 64542, 64822, 64863, 64864, 64865, 64866, 64867, 64688, 64543, 64743, 64791, 64763, 64810, 64782, 64792, 64764, 64606, 64609, - 64755, 64607, 64610, 64756, 64611, 64608, 64754, 64818, 64746, 64872, - 64871, 64938, 64806, 64814, 64778, 64824, 64873, 64805, 64813, 64777, - 64823, 64875, 64874, 64877, 64876, 64808, 64816, 64780, 64745, 64793, + 64755, 64607, 64610, 64756, 64611, 64608, 64754, 64818, 64746, 64871, + 64872, 64938, 64806, 64814, 64778, 64824, 64873, 64805, 64813, 64777, + 64823, 64874, 64875, 64876, 64877, 64808, 64816, 64780, 64745, 64793, 64765, 64807, 64815, 64779, 64825, 64809, 64781, 64794, 64766, 65022, - 64846, 64882, 64881, 64883, 64884, 64819, 64551, 64826, 64785, 64757, - 64696, 64550, 64786, 64758, 64851, 64850, 64849, 64674, 64524, 64677, + 64846, 64881, 64882, 64883, 64884, 64819, 64551, 64826, 64785, 64757, + 64696, 64550, 64786, 64758, 64851, 64849, 64850, 64674, 64524, 64677, 64740, 64930, 64852, 64929, 64675, 64525, 64928, 64848, 64927, 64673, 64523, 64932, 64853, 64855, 64854, 64931, 64626, 64676, 64526, 64739, 64628, 64527, 64627, 64625, 64624, 64629, 64528, 64603, 64529, 64634, @@ -9511,9 +9732,9 @@ static const unsigned int dawg_pos_to_codepoint[] = { 64503, 64504, 64502, 64667, 64736, 64664, 64513, 64663, 64512, 64665, 64614, 64666, 64514, 64735, 64615, 64499, 64498, 64495, 64494, 64617, 64516, 64501, 64500, 64613, 64612, 64497, 64496, 64942, 64731, 64598, - 64734, 64753, 64660, 64658, 64943, 64730, 64597, 64732, 64599, 64925, - 64924, 64944, 64659, 64733, 64600, 64752, 64657, 64662, 64602, 64506, - 64507, 64505, 64697, 64552, 64827, 2204, 1619, 1624, 2303, 126492, + 64734, 64753, 64660, 64658, 64943, 64730, 64597, 64732, 64599, 64924, + 64925, 64944, 64659, 64733, 64600, 64752, 64657, 64662, 64602, 64506, + 64507, 64505, 64697, 64552, 64827, 2204, 1619, 1624, 2303, 69369, 126492, 126494, 126493, 126495, 126644, 126638, 126641, 126647, 126648, 126646, 126632, 126645, 126630, 126650, 126626, 126636, 126625, 126640, 126643, 126633, 126631, 126651, 126637, 126635, 126649, 126627, 126642, 126639, @@ -9529,423 +9750,426 @@ static const unsigned int dawg_pos_to_codepoint[] = { 126553, 126548, 126542, 126545, 126551, 126530, 126537, 126535, 126555, 126541, 126539, 126546, 126543, 126472, 126488, 126486, 126485, 126464, 126479, 126487, 126474, 126470, 126490, 126466, 126476, 126465, 126480, - 126483, 126473, 126471, 126491, 126477, 126482, 126469, 1541, 1536, 2290, - 2289, 2288, 1642, 2199, 1550, 2192, 1769, 2193, 2184, 1544, 1629, 2296, - 2301, 2298, 1772, 1623, 983633, 983635, 983640, 983634, 983638, 983636, - 983639, 983637, 983641, 1563, 1617, 65148, 65149, 1554, 1555, 1552, 1537, - 1539, 1540, 1790, 1789, 1553, 1551, 1556, 2249, 1560, 1761, 2250, 2272, - 1558, 983202, 1751, 1750, 1753, 1752, 1762, 1764, 2273, 1756, 2261, 1755, - 1557, 2200, 2260, 2266, 2268, 2267, 2269, 2252, 2271, 2270, 2291, 1767, - 2251, 1768, 2264, 1760, 1759, 1559, 2253, 1754, 2263, 2262, 1766, 69317, - 69371, 2265, 2202, 2201, 69375, 2203, 69373, 69374, 2259, 1773, 1763, - 1562, 1561, 1765, 1622, 1618, 65150, 65151, 2256, 2205, 64444, 64435, - 64434, 64441, 64440, 64439, 64438, 64446, 64445, 64437, 64436, 64449, - 64448, 64443, 64442, 64450, 64447, 1758, 1600, 2179, 2180, 65137, 2181, - 65139, 2285, 2282, 2286, 2283, 2287, 2284, 1566, 2275, 1644, 1627, 1626, - 1628, 2190, 1631, 1567, 1625, 1545, 1546, 1542, 1543, 1637, 1636, 1639, - 1638, 1635, 1634, 1632, 1641, 1633, 1640, 1375, 1370, 1359, 1337, 1349, - 1362, 1347, 1353, 1342, 1361, 1360, 1356, 1333, 1335, 1336, 1346, 1331, - 1355, 1345, 1364, 1343, 1363, 1354, 1351, 1357, 1329, 1358, 1352, 1340, - 1366, 1341, 1339, 1330, 1348, 1350, 1338, 1334, 1344, 1332, 1365, 1373, - 1372, 1371, 1395, 1401, 1390, 1409, 1408, 1404, 1381, 1383, 1384, 1394, - 1379, 1403, 1393, 1412, 1391, 1411, 1402, 1399, 1405, 1376, 1407, 1385, - 1377, 1406, 1400, 1397, 1416, 1410, 1388, 1414, 1389, 1387, 1378, 1396, - 1398, 1386, 1382, 1392, 1380, 1413, 1415, 64279, 64277, 64275, 64276, - 64278, 1369, 1418, 1423, 1417, 1374, 129201, 10549, 10548, 129200, 10550, - 10551, 129968, 128667, 127912, 9800, 8978, 9738, 65948, 42, 8727, 8258, - 128562, 118477, 9954, 11225, 128888, 8771, 8870, 128095, 9883, 128663, - 127975, 128762, 8371, 127814, 68352, 68353, 68357, 68355, 68358, 68359, - 68356, 68354, 68373, 68374, 68372, 68393, 68405, 68388, 68387, 68386, - 68391, 68390, 68389, 68371, 68370, 68369, 68403, 68401, 68404, 68399, - 68394, 68395, 68378, 68381, 68377, 68366, 68367, 68362, 68363, 68364, - 68365, 68385, 68384, 68380, 68379, 68402, 68400, 68360, 68361, 68375, - 68383, 68376, 68368, 68398, 68392, 68382, 68397, 68396, 68409, 129361, - 8525, 1547, 129518, 9810, 129683, 128118, 128036, 127868, 128124, 128700, - 128281, 128386, 11101, 11099, 983056, 10155, 128043, 129363, 127992, - 129441, 129366, 129391, 128708, 7007, 7005, 7006, 6991, 6990, 6917, 6918, - 6987, 6988, 6928, 6953, 6954, 6936, 6937, 6948, 6944, 6943, 6949, 6984, - 6927, 6933, 6934, 6919, 6920, 6929, 6930, 6921, 6922, 6938, 6939, 6931, - 6981, 6932, 6982, 6958, 6925, 6926, 6950, 6945, 6935, 6940, 6951, 6952, - 6957, 6923, 6924, 6962, 6960, 6961, 6946, 6942, 6941, 6947, 6983, 6985, - 6986, 6963, 6955, 6959, 6956, 7022, 7025, 7021, 7024, 7023, 7026, 7020, - 7019, 7027, 7012, 7013, 7018, 7015, 7017, 7016, 7010, 7014, 7009, 7011, - 7032, 7036, 7033, 7034, 7035, 7031, 7030, 7029, 7028, 7003, 7038, 7008, - 7002, 7037, 7039, 6915, 6913, 6912, 6914, 6916, 6964, 6972, 6973, 6970, - 6971, 6968, 6969, 6974, 6975, 6977, 6976, 6965, 6978, 6979, 6966, 6967, - 6980, 7004, 6997, 6996, 6999, 6998, 6995, 6994, 6992, 7001, 6993, 7000, - 127880, 10057, 9744, 128503, 128505, 128499, 128501, 11197, 9745, 9746, - 128502, 128500, 10007, 129526, 129648, 42737, 42736, 42741, 42740, 42733, - 42699, 42713, 42712, 42692, 42706, 42683, 42719, 42734, 42735, 42682, - 42729, 42657, 42725, 42659, 42670, 42718, 42666, 42716, 42701, 42675, - 42671, 42722, 42720, 42727, 42723, 42702, 42726, 42677, 42707, 42708, - 42709, 42686, 42694, 42674, 42731, 42695, 42685, 42684, 42691, 42673, - 42664, 42715, 42703, 92193, 92188, 92161, 92199, 92240, 92179, 92211, - 92219, 92213, 92243, 92207, 92216, 92183, 92184, 92238, 92171, 983268, - 92174, 92203, 92186, 92210, 92230, 92175, 92221, 92232, 92246, 92198, - 92214, 92190, 92176, 92197, 92196, 92164, 92245, 92212, 92201, 92160, - 92182, 92173, 92229, 92227, 92180, 92237, 92241, 92223, 92185, 92194, - 92178, 92239, 92225, 92233, 92167, 92191, 92231, 92244, 92204, 92226, - 92236, 92200, 92189, 92187, 92162, 92163, 92169, 92170, 92202, 92205, - 92222, 92168, 92165, 92215, 92224, 92208, 92220, 92235, 92177, 92181, - 92195, 92234, 92209, 92166, 92172, 92206, 92192, 92228, 92217, 92242, - 92218, 92262, 92271, 92272, 92270, 92294, 92253, 92301, 92256, 92273, - 92259, 92251, 92297, 92300, 92296, 92295, 92255, 92252, 92292, 92286, - 92268, 92290, 92281, 92267, 92284, 92287, 92282, 92283, 92277, 92298, - 983270, 92276, 92302, 92247, 92299, 92288, 92269, 92260, 92261, 983269, - 92289, 92257, 92274, 92263, 92279, 92265, 92266, 92250, 92249, 92285, - 92248, 92264, 92280, 92258, 92254, 92278, 92291, 92293, 92275, 92310, - 92320, 92312, 92394, 92393, 92319, 92384, 92321, 92386, 92361, 92373, - 92366, 92328, 92329, 92357, 92342, 92397, 92365, 92376, 92339, 92382, - 92363, 92318, 92387, 92383, 92315, 92385, 92354, 92311, 92381, 92343, - 92326, 92364, 92324, 92391, 92344, 92390, 92338, 92396, 92308, 92349, - 92375, 92378, 92317, 92331, 92362, 92336, 92341, 92370, 92347, 92307, - 92303, 92309, 92395, 92368, 92356, 92367, 92360, 92389, 92333, 92359, - 92374, 92351, 92325, 92371, 92350, 92345, 92372, 92314, 92340, 92323, - 92304, 92313, 92316, 92398, 92399, 92380, 92330, 983271, 92379, 92392, - 92335, 92332, 92346, 92400, 92358, 92334, 92353, 92337, 92306, 92369, - 92388, 92322, 92305, 92327, 92377, 92352, 92348, 92355, 92436, 92517, - 92488, 92434, 92415, 92431, 92454, 92460, 92420, 92489, 92422, 92474, - 92479, 92449, 92502, 92439, 92484, 92495, 92464, 92511, 92406, 92446, - 92497, 92426, 92482, 92448, 92515, 92401, 92478, 92427, 92496, 92458, - 92424, 92445, 92404, 92466, 92444, 92438, 92442, 92441, 92510, 92499, - 92425, 92437, 92440, 92471, 92465, 92409, 92483, 92475, 92467, 92485, - 92457, 92432, 92476, 92435, 92412, 92414, 92430, 92407, 92403, 92405, - 92487, 92418, 92486, 92408, 92447, 92459, 92480, 92472, 92505, 92514, - 92450, 92463, 92410, 92493, 92507, 92503, 92462, 92506, 92443, 92509, - 92469, 92461, 92490, 92512, 92494, 92455, 92417, 92501, 92413, 92508, - 92500, 92504, 92473, 92419, 92498, 92423, 92516, 92428, 92452, 92451, - 92481, 92416, 92456, 92433, 92477, 92492, 92491, 92513, 92411, 92402, - 92421, 92453, 92468, 92470, 92429, 92661, 92626, 92616, 92596, 92612, - 92603, 92673, 92651, 92627, 92597, 92585, 92578, 92615, 92565, 92552, - 92602, 92674, 92570, 92646, 92599, 92532, 92587, 92538, 92620, 92670, - 92665, 92575, 92521, 92633, 92595, 92523, 92556, 92539, 92664, 92653, - 92667, 92600, 92542, 92555, 92668, 92520, 92582, 92591, 92581, 92551, - 92654, 92611, 92614, 92666, 92671, 92617, 92637, 92562, 92518, 92592, - 92558, 92528, 92607, 92535, 92557, 92563, 92550, 92624, 983272, 92640, - 92657, 92531, 92601, 92553, 92543, 92619, 92598, 92541, 92544, 92579, - 92658, 92554, 92628, 92648, 92547, 92527, 92545, 92540, 92604, 92622, - 92589, 92608, 92583, 92609, 92662, 92613, 92584, 92625, 92634, 92524, - 92536, 92605, 92647, 92548, 92663, 92593, 92621, 92568, 92610, 92576, - 92529, 92618, 92649, 92561, 92656, 92526, 92655, 92546, 92534, 92560, - 92580, 92659, 92660, 92638, 92571, 92525, 92549, 92559, 92635, 92577, - 92530, 92636, 92669, 92572, 92672, 92537, 92519, 92630, 92586, 92569, - 92566, 92573, 92652, 92522, 92574, 92650, 92533, 92567, 92623, 92606, - 92639, 92564, 92590, 92642, 92643, 92594, 92641, 92645, 92644, 92588, - 92629, 92632, 92631, 92710, 92695, 92694, 92726, 92675, 92719, 92677, - 92718, 92682, 92717, 92689, 92720, 92724, 92685, 92722, 92723, 92711, - 92712, 92698, 92688, 92697, 92696, 92702, 92687, 92704, 92681, 92708, - 92703, 92706, 92714, 92709, 92679, 92721, 92684, 92683, 92707, 92691, - 92713, 92700, 92693, 92727, 92690, 92692, 92686, 92680, 92725, 92699, - 92701, 92705, 92716, 92728, 92678, 92715, 92676, 42693, 42698, 42711, - 42696, 42667, 42717, 42704, 42661, 42721, 42669, 42668, 42705, 42700, - 42680, 42678, 42710, 42688, 42681, 42732, 42676, 42679, 42730, 42728, - 42672, 42662, 42724, 42687, 42689, 42690, 42697, 42714, 42660, 42656, - 42665, 42663, 42658, 42738, 42742, 42739, 42743, 127974, 128183, 128180, - 128182, 128181, 127820, 129685, 128202, 129532, 128136, 129530, 127936, - 92916, 92912, 92915, 92913, 92914, 92887, 92894, 92908, 92880, 92907, - 92893, 92886, 92888, 92881, 92906, 92896, 92891, 92902, 92900, 92885, - 92890, 92884, 92904, 92905, 92899, 92889, 92897, 92892, 92895, 92882, - 92898, 92883, 92901, 92903, 92909, 92917, 9918, 129415, 7152, 7153, 7124, - 7108, 7114, 7130, 7139, 7127, 7138, 7133, 7136, 7113, 7111, 7117, 7119, - 7107, 7135, 7125, 7112, 7123, 7129, 7116, 7132, 7105, 7126, 7128, 7110, - 7109, 7137, 7121, 7118, 7106, 7120, 7134, 7122, 7115, 7131, 7104, 7140, - 7141, 7154, 7155, 7167, 7165, 7166, 7164, 7142, 7150, 7151, 7144, 7147, - 7149, 7143, 7145, 7146, 7148, 128704, 128705, 128267, 127900, 127901, - 9835, 9836, 129492, 128059, 127958, 128147, 129451, 129752, 127866, - 129714, 983055, 128276, 129745, 128277, 9086, 128718, 118478, 2557, 2432, - 2519, 2548, 2552, 2551, 2550, 2549, 2553, 2454, 2510, 983661, 2453, 2480, - 2545, 2544, 2525, 2524, 2556, 2443, 2528, 2444, 2529, 2527, 2479, 2437, - 2438, 2448, 2452, 2466, 2465, 2471, 2470, 2464, 2463, 2469, 2468, 2441, - 2442, 2439, 2440, 2457, 2467, 2462, 2472, 2486, 2487, 2488, 2477, 2476, - 2459, 2458, 2456, 2455, 2461, 2460, 2475, 2474, 2489, 2482, 2478, 2447, - 2451, 2547, 2546, 983651, 983650, 983652, 2558, 2433, 2492, 2493, 2434, - 2509, 2435, 2554, 2494, 2504, 2508, 2497, 2498, 2499, 2500, 2530, 2531, - 2495, 2496, 2503, 2507, 2539, 2538, 2541, 2540, 2537, 2536, 2534, 2543, - 2535, 2542, 2555, 11102, 127857, 9004, 9187, 93856, 93880, 93858, 93864, - 93873, 93874, 93859, 93861, 93869, 93868, 93870, 93876, 93875, 93867, - 93862, 93865, 93877, 93857, 93879, 93860, 93866, 93871, 93872, 93878, - 93863, 93883, 93907, 93885, 93891, 93900, 93901, 93886, 93888, 93896, - 93895, 93897, 93903, 93902, 93894, 93889, 93892, 93904, 93884, 93906, - 93887, 93893, 93898, 93899, 93905, 93890, 8812, 8502, 8757, 129475, - 128719, 72710, 72711, 72712, 72746, 72704, 72705, 72715, 72717, 72731, - 72730, 72736, 72735, 72729, 72728, 72734, 72733, 72708, 72709, 72706, - 72707, 72722, 72732, 72727, 72737, 72747, 72748, 72749, 72741, 72740, - 72724, 72723, 72721, 72720, 72726, 72725, 72719, 72718, 72739, 72738, - 72750, 72745, 72742, 72744, 72743, 72714, 72716, 72801, 72810, 72806, - 72797, 72807, 72798, 72802, 72811, 72800, 72809, 72799, 72808, 72796, - 72805, 72804, 72795, 72803, 72794, 72764, 72768, 72765, 72767, 72766, - 72756, 72757, 72758, 72751, 72761, 72763, 72754, 72755, 72752, 72753, - 72760, 72762, 72770, 72769, 72789, 72788, 72791, 72790, 72787, 72786, - 72784, 72793, 72785, 72792, 72771, 72772, 72773, 72812, 128692, 128690, - 10745, 10744, 129506, 127921, 127874, 128038, 8383, 129766, 9763, 128089, - 129452, 9679, 9864, 10733, 9865, 9210, 11176, 11177, 11178, 11179, 11180, - 11182, 11181, 11183, 9960, 10028, 129623, 9821, 129554, 129596, 129609, - 129612, 129622, 9818, 129551, 129593, 9822, 129543, 129564, 129585, - 129597, 129606, 129555, 129619, 129617, 129618, 9823, 129556, 129598, - 9819, 129552, 129594, 9820, 129553, 129595, 129575, 129572, 129576, - 129577, 129573, 129574, 9827, 9670, 11201, 10070, 10730, 11230, 9830, - 128419, 128899, 9196, 9662, 9660, 11167, 127778, 9922, 9923, 10047, 9873, - 10022, 128447, 128420, 9829, 11042, 128426, 11052, 10711, 11044, 117867, - 117870, 117869, 117868, 11035, 9194, 9198, 128896, 9668, 9666, 9664, - 11164, 8268, 9944, 128412, 9754, 9699, 9698, 10731, 9207, 11206, 11045, - 9204, 11207, 11047, 9205, 11208, 9206, 11205, 128921, 128927, 9726, 9724, - 9912, 117871, 10002, 128392, 9648, 11039, 127986, 118451, 128413, 9755, - 9193, 9197, 9654, 9199, 128898, 11091, 9658, 9656, 10145, 10148, 11166, - 8269, 127990, 9644, 11049, 11050, 11089, 9642, 129997, 9787, 9632, 11200, - 9209, 128306, 9728, 128369, 9927, 9984, 128900, 128909, 9986, 9751, 9824, - 9733, 128919, 128925, 128908, 9951, 128383, 9742, 9942, 128418, 128897, - 9195, 9652, 9650, 9700, 9701, 11165, 9851, 9646, 11054, 128920, 128926, - 11037, 11204, 10707, 10067, 8493, 8460, 8465, 8476, 8488, 10164, 10166, - 10165, 9250, 118018, 118039, 118128, 118187, 118218, 118159, 118054, - 118112, 118234, 118084, 118202, 118143, 118031, 118062, 118120, 118240, - 118179, 118090, 118210, 118151, 118047, 118104, 118226, 118165, 118076, - 118194, 118135, 118021, 118035, 118066, 118124, 118243, 118183, 118093, - 118214, 118155, 118050, 118108, 118230, 118168, 118080, 118198, 118139, - 118028, 118058, 118116, 118237, 118175, 118087, 118206, 118147, 118043, - 118100, 118222, 118162, 118072, 118190, 118131, 118029, 118060, 118118, - 118177, 118208, 118149, 118045, 118102, 118224, 118023, 118037, 118068, - 118126, 118244, 118185, 118095, 118216, 118157, 118052, 118110, 118232, - 118170, 118082, 118200, 118141, 118074, 118192, 118133, 118020, 118033, - 118064, 118122, 118242, 118181, 118092, 118212, 118153, 118048, 118106, - 118228, 118167, 118078, 118196, 118137, 118026, 118056, 118114, 118235, - 118173, 118085, 118204, 118145, 118041, 118098, 118220, 118160, 118070, - 118188, 118129, 118034, 118065, 118123, 118182, 118213, 118154, 118049, - 118107, 118229, 118079, 118197, 118138, 118017, 118024, 118038, 118069, - 118127, 118245, 118186, 118096, 118217, 118158, 118053, 118111, 118233, - 118171, 118083, 118201, 118142, 118030, 118061, 118119, 118239, 118178, - 118089, 118209, 118150, 118046, 118103, 118225, 118164, 118075, 118193, - 118134, 118027, 118057, 118115, 118236, 118174, 118086, 118205, 118146, - 118042, 118099, 118221, 118161, 118071, 118189, 118130, 118025, 118055, - 118113, 118172, 118203, 118144, 118040, 118097, 118219, 118016, 118022, - 118036, 118067, 118125, 118184, 118094, 118215, 118156, 118051, 118109, - 118231, 118169, 118081, 118199, 118140, 118059, 118117, 118238, 118176, - 118088, 118207, 118148, 118044, 118101, 118223, 118163, 118073, 118191, - 118132, 118019, 118105, 118227, 118166, 118032, 118063, 118121, 118241, - 118180, 118091, 118211, 118152, 118077, 118195, 118136, 129792, 129794, - 129798, 129806, 129821, 129836, 129813, 129844, 129829, 129802, 129817, - 129848, 129832, 129810, 129840, 129825, 129796, 129804, 129819, 129850, - 129834, 129842, 129827, 129800, 129815, 129846, 129831, 129808, 129838, - 129823, 129793, 129801, 129816, 129847, 129797, 129805, 129820, 129851, - 129835, 129812, 129843, 129828, 129809, 129839, 129824, 129795, 129803, - 129818, 129849, 129833, 129811, 129841, 129826, 129799, 129814, 129845, - 129830, 129807, 129837, 129822, 127804, 128033, 128216, 128153, 129744, - 128939, 128951, 128957, 128945, 128902, 128912, 128932, 128366, 128278, - 128209, 128218, 129667, 12731, 12727, 12726, 12724, 12725, 12570, 12574, - 12718, 12576, 12719, 12578, 12580, 12713, 12735, 12720, 12584, 12715, - 12572, 12579, 12581, 12709, 12708, 12573, 12575, 12582, 12557, 12728, - 12588, 12707, 12732, 12583, 12714, 12723, 12589, 12716, 12712, 12585, - 12555, 12587, 12717, 12591, 12571, 12722, 12711, 12590, 12734, 12721, - 12710, 12577, 12567, 12563, 12705, 12730, 12558, 12733, 12568, 12564, - 12556, 12729, 12569, 12565, 12549, 12704, 12560, 12706, 12553, 12552, - 12559, 12551, 12550, 12561, 12566, 12554, 12586, 12562, 118257, 118258, - 118259, 118260, 117854, 11867, 117853, 118253, 118255, 11868, 117855, - 118249, 118251, 118247, 11211, 8993, 130029, 8990, 8973, 11812, 8991, - 8972, 11813, 130030, 9141, 9142, 10555, 9183, 9181, 130026, 130018, 9185, - 127870, 128144, 127893, 128335, 129379, 127923, 8904, 10705, 10706, - 127993, 118282, 117792, 117791, 118281, 9574, 9559, 9556, 9577, 9565, - 9562, 9553, 9580, 9571, 9568, 9552, 9511, 9490, 9503, 9486, 9537, 9520, - 9513, 9489, 9505, 9485, 9543, 9519, 9558, 9555, 9573, 9557, 9554, 9572, - 9592, 9598, 9593, 9599, 9499, 9531, 9495, 9475, 9547, 9515, 9507, 9595, - 9523, 9491, 9487, 9551, 9549, 9483, 9481, 9479, 9477, 9473, 9594, 9541, - 9525, 9517, 9533, 9530, 9522, 9546, 9539, 9582, 9581, 9583, 9584, 130010, - 130014, 129954, 129958, 130003, 129959, 129964, 129965, 129955, 130000, - 129952, 129956, 129963, 129960, 129953, 129961, 129957, 129962, 130007, - 130005, 130004, 130012, 9586, 130008, 130011, 130002, 130015, 130006, - 9585, 130009, 130001, 130013, 9587, 129966, 9591, 9516, 9488, 9484, 9550, - 9548, 9472, 117787, 117788, 129967, 9588, 9596, 9482, 9480, 9478, 9476, - 117789, 9589, 9597, 9524, 9496, 9492, 9474, 118297, 118295, 118296, - 118294, 9532, 9508, 9500, 117790, 9590, 9542, 9526, 9518, 9534, 9529, - 9521, 9545, 9540, 9536, 9510, 9498, 9502, 9494, 9528, 9544, 9514, 9497, - 9506, 9493, 9527, 9564, 9561, 9576, 9563, 9560, 9575, 9570, 9567, 9579, - 9538, 9512, 9504, 9535, 9509, 9501, 9569, 9566, 9578, 129354, 983263, - 128163, 128102, 128713, 128023, 129460, 69649, 69685, 69749, 69745, - 69746, 69687, 69686, 69637, 69638, 69648, 69650, 69664, 69663, 69669, - 69668, 69662, 69661, 69667, 69666, 69643, 69644, 69645, 69646, 69679, - 69641, 69642, 69639, 69640, 69684, 69678, 69655, 69665, 69660, 69670, - 69680, 69681, 69682, 69674, 69673, 69657, 69656, 69654, 69653, 69659, - 69658, 69652, 69651, 69672, 69671, 69683, 69675, 69677, 69676, 69647, - 69721, 69730, 69726, 69717, 69727, 69718, 69722, 69731, 69720, 69729, - 69719, 69728, 69716, 69725, 69724, 69715, 69723, 69714, 69732, 69733, - 69759, 69709, 69707, 69706, 69705, 69708, 69632, 69744, 69635, 69634, - 69636, 69633, 69700, 69747, 69748, 69689, 69688, 69699, 69701, 69692, - 69693, 69694, 69695, 69696, 69697, 69690, 69691, 69698, 69702, 69704, - 69703, 69739, 69738, 69741, 69740, 69737, 69736, 69734, 69743, 69735, - 69742, 10241, 10243, 10247, 10255, 10271, 10303, 10367, 10495, 10431, - 10335, 10463, 10399, 10287, 10351, 10479, 10415, 10319, 10447, 10383, - 10263, 10295, 10359, 10487, 10423, 10327, 10455, 10391, 10279, 10343, - 10471, 10407, 10311, 10439, 10375, 10251, 10267, 10299, 10363, 10491, - 10427, 10331, 10459, 10395, 10283, 10347, 10475, 10411, 10315, 10443, - 10379, 10259, 10291, 10355, 10483, 10419, 10323, 10451, 10387, 10275, - 10339, 10467, 10403, 10307, 10435, 10371, 10245, 10253, 10269, 10301, - 10365, 10493, 10429, 10333, 10461, 10397, 10285, 10349, 10477, 10413, - 10317, 10445, 10381, 10261, 10293, 10357, 10485, 10421, 10325, 10453, - 10389, 10277, 10341, 10469, 10405, 10309, 10437, 10373, 10249, 10265, - 10297, 10361, 10489, 10425, 10329, 10457, 10393, 10281, 10345, 10473, - 10409, 10313, 10441, 10377, 10257, 10289, 10353, 10481, 10417, 10321, - 10449, 10385, 10273, 10337, 10465, 10401, 10305, 10433, 10369, 10242, - 10246, 10254, 10270, 10302, 10366, 10494, 10430, 10334, 10462, 10398, - 10286, 10350, 10478, 10414, 10318, 10446, 10382, 10262, 10294, 10358, - 10486, 10422, 10326, 10454, 10390, 10278, 10342, 10470, 10406, 10310, - 10438, 10374, 10250, 10266, 10298, 10362, 10490, 10426, 10330, 10458, - 10394, 10282, 10346, 10474, 10410, 10314, 10442, 10378, 10258, 10290, - 10354, 10482, 10418, 10322, 10450, 10386, 10274, 10338, 10466, 10402, - 10306, 10434, 10370, 10244, 10252, 10268, 10300, 10364, 10492, 10428, - 10332, 10460, 10396, 10284, 10348, 10476, 10412, 10316, 10444, 10380, - 10260, 10292, 10356, 10484, 10420, 10324, 10452, 10388, 10276, 10340, - 10468, 10404, 10308, 10436, 10372, 10248, 10264, 10296, 10360, 10488, - 10424, 10328, 10456, 10392, 10280, 10344, 10472, 10408, 10312, 10440, - 10376, 10256, 10288, 10352, 10480, 10416, 10320, 10448, 10384, 10272, - 10336, 10464, 10400, 10304, 10432, 10368, 10240, 129504, 983125, 129329, - 127838, 728, 127753, 128112, 128188, 129650, 129521, 9099, 166, 128148, - 129382, 129294, 129529, 129483, 129767, 128027, 6663, 6662, 6659, 6658, - 6671, 6670, 6667, 6666, 6661, 6668, 6665, 6657, 6678, 6669, 6656, 6674, - 6660, 6673, 6676, 6664, 6675, 6672, 6677, 6683, 6681, 6679, 6682, 6680, - 6687, 6686, 5957, 5960, 5962, 5959, 5956, 5969, 5955, 5966, 5963, 5961, - 5965, 5968, 5958, 5967, 5964, 5952, 5953, 5954, 5970, 5971, 8226, 8729, - 128363, 128364, 9678, 128652, 128101, 128100, 128655, 129480, 129419, - 127959, 127791, 129699, 118939, 118940, 118944, 118943, 118941, 118942, - 118938, 118945, 118882, 118876, 118824, 118835, 118797, 118866, 118957, - 118801, 118802, 118865, 118818, 118916, 118819, 118917, 118899, 118935, - 119018, 119022, 119021, 119020, 119023, 119019, 119017, 118986, 118984, - 118985, 118843, 118887, 118808, 118870, 119003, 119002, 119004, 119005, - 118937, 118991, 118995, 118990, 118992, 118994, 118993, 118930, 118933, - 118931, 118932, 119014, 118918, 118912, 119015, 118785, 118831, 118907, - 118966, 118900, 118880, 118798, 118888, 118884, 118869, 118960, 118959, - 118958, 118836, 118969, 118977, 118978, 118971, 118976, 118975, 118973, - 118970, 118987, 118979, 118980, 118972, 118983, 983278, 118982, 118974, - 118988, 118981, 119000, 119001, 118929, 118928, 118806, 119029, 118927, - 118898, 118964, 118965, 118853, 118968, 118837, 118967, 118936, 118956, - 118810, 118854, 118847, 118839, 118906, 118791, 118800, 119024, 119026, - 118862, 118812, 119025, 119027, 118863, 118811, 118820, 119028, 118911, - 118842, 118850, 118921, 118858, 118913, 118914, 118915, 118834, 118860, - 118868, 118796, 118881, 118922, 118926, 118925, 118924, 118923, 118830, - 118877, 118949, 118947, 118948, 118963, 118955, 118962, 118946, 118961, - 118953, 118952, 118951, 118950, 118954, 118871, 118805, 118855, 118828, - 118901, 118787, 118788, 118856, 118816, 118875, 118845, 118879, 118793, - 118846, 118878, 118814, 118822, 118873, 118859, 118857, 118849, 118840, - 118861, 118786, 118895, 118841, 118874, 118892, 118897, 118807, 118784, - 118821, 118844, 118825, 118889, 119010, 119012, 119013, 119011, 119006, - 119008, 119009, 119007, 118910, 118815, 118852, 119016, 118826, 118885, - 118827, 118803, 118886, 118792, 118813, 118920, 118799, 118833, 118829, - 118904, 118902, 118903, 118905, 118804, 118934, 118919, 118832, 118893, - 118838, 118851, 118883, 118894, 118891, 118896, 118823, 118789, 118790, - 118872, 118817, 118809, 118908, 118909, 118996, 118998, 118997, 118999, - 118989, 118794, 118795, 118867, 118864, 118848, 118890, 983262, 983126, - 983057, 9764, 8454, 129305, 128197, 128247, 128248, 127957, 983098, 5130, - 5131, 5122, 6322, 5148, 5551, 5310, 5382, 5166, 6321, 5759, 5559, 5556, - 5557, 5558, 5567, 5564, 5565, 5566, 5563, 5560, 5561, 5562, 5555, 5552, - 5553, 5554, 5384, 5439, 6387, 6388, 5281, 5264, 6382, 6389, 5203, 5674, - 5675, 5677, 5676, 5673, 5672, 5706, 5707, 5709, 5708, 5705, 5704, 5204, - 5574, 5575, 5577, 5576, 5573, 5572, 6384, 6381, 5620, 6383, 5617, 5618, - 5619, 5616, 5615, 5195, 5592, 5593, 5595, 5594, 5591, 5590, 5174, 5175, - 5129, 5703, 5662, 5663, 5665, 5664, 5661, 5660, 5655, 5656, 6386, 5659, - 5657, 5654, 5652, 5633, 5629, 5630, 5632, 5631, 5628, 5627, 5623, 5624, - 5626, 5625, 5622, 5621, 5636, 5637, 5639, 5329, 5638, 5635, 5634, 5722, - 5718, 5719, 5721, 5720, 5717, 5716, 5712, 5713, 5715, 5714, 5711, 5710, - 5614, 5610, 5611, 5613, 5612, 5609, 5608, 5702, 5698, 5699, 5701, 5700, - 5697, 5696, 5686, 5687, 5689, 5688, 5685, 5684, 5692, 5693, 5695, 5694, - 5691, 5690, 5737, 5738, 5740, 5739, 5736, 5735, 5604, 5605, 5607, 5606, - 5603, 5602, 5598, 5599, 5601, 5600, 5597, 5596, 5725, 5726, 5728, 5727, - 5724, 5723, 5680, 5681, 5683, 5682, 5679, 5678, 5668, 5669, 5671, 5670, - 5667, 5666, 5731, 5732, 5734, 5733, 5730, 5729, 5642, 5643, 5645, 5644, - 5641, 5640, 5580, 5581, 5583, 5582, 5579, 5578, 5586, 5587, 5589, 5588, - 5585, 5584, 5648, 5649, 5651, 5650, 5647, 5646, 5128, 5265, 5258, 5276, - 5278, 5272, 5274, 5268, 5270, 5266, 5741, 5261, 5262, 5259, 5260, 5257, - 5121, 6364, 5163, 5469, 5465, 5466, 5460, 5461, 5158, 5157, 5162, 5155, - 5156, 6367, 6366, 5160, 5152, 5151, 5153, 5154, 5161, 5159, 5462, 5742, - 5463, 5464, 5467, 5459, 5120, 5501, 5123, 5124, 5164, 5251, 5252, 5246, - 5248, 6329, 5242, 5244, 5238, 5240, 5236, 5234, 5235, 5228, 6328, 5231, - 5232, 5229, 5230, 5227, 5354, 5542, 5540, 5541, 5538, 5539, 5536, 5537, - 5338, 5339, 5332, 6333, 5350, 5352, 5346, 5348, 5342, 5344, 5340, 5335, - 5336, 5333, 5334, 5331, 5307, 5283, 5356, 5458, 5287, 5288, 5385, 5290, - 5291, 5284, 6330, 5302, 5304, 5298, 5300, 5294, 5296, 5292, 5285, 5286, - 5309, 5328, 5473, 5475, 5471, 5319, 5391, 5388, 5389, 5386, 5390, 5380, - 5387, 5142, 5147, 5280, 5250, 5306, 5327, 5221, 5437, 72372, 72373, - 72370, 72371, 72368, 72369, 72378, 72379, 72376, 72377, 72374, 72375, - 5320, 5313, 6332, 5525, 5523, 5524, 5518, 5744, 5521, 5522, 5519, 5520, - 5526, 5749, 5750, 5747, 5748, 5745, 5746, 5499, 5497, 5498, 5495, 5496, - 5493, 5494, 5492, 5500, 5316, 5317, 6331, 5323, 5325, 6346, 6348, 6342, - 6344, 5321, 5314, 5315, 5312, 5330, 5509, 5507, 5508, 5502, 5743, 5505, - 5506, 5503, 5504, 5125, 6361, 6347, 6349, 6343, 6345, 6362, 6363, 6359, - 6358, 6360, 6356, 6357, 5165, 5126, 6320, 5193, 5184, 5186, 6326, 5188, - 5190, 5180, 5182, 5178, 5176, 5177, 5168, 6325, 5171, 5172, 6324, 5169, - 5170, 5167, 5456, 6368, 5443, 6355, 5454, 6353, 6354, 6351, 6352, 6350, - 5451, 5452, 5445, 6341, 5448, 5449, 5446, 5447, 5442, 5381, 5364, 6335, - 5570, 6380, 5571, 5568, 5569, 5653, 6385, 5658, 5529, 6379, 6378, 5530, - 5527, 5528, 5441, 5282, 5311, 5365, 5358, 5413, 5405, 5407, 6338, 5409, - 5411, 5401, 5403, 5399, 5395, 5396, 6336, 5397, 5398, 6337, 5393, 5394, - 5392, 5361, 5256, 5253, 5254, 5255, 5362, 6334, 5383, 5376, 5378, 5372, - 5374, 5368, 5370, 5366, 72383, 72380, 72381, 72382, 5359, 5360, 5357, - 5222, 5482, 5550, 5548, 5549, 5546, 5547, 5544, 5545, 5543, 6372, 5480, - 6371, 5478, 5479, 5476, 5477, 5472, 5474, 5470, 5512, 6377, 6376, 5513, - 5510, 5511, 5487, 5486, 6375, 5485, 6374, 6373, 5483, 5484, 5226, 5223, - 5224, 5225, 5205, 5206, 5197, 6327, 5217, 5219, 5213, 5215, 5209, 5211, - 5207, 5491, 5488, 5489, 5490, 5200, 5201, 5198, 5199, 5196, 5132, 5355, - 5351, 5353, 5347, 5349, 5343, 5345, 5341, 5453, 6370, 5450, 6369, 5444, - 5308, 5303, 5305, 5299, 5301, 5295, 5297, 5293, 5194, 5189, 5191, 5185, - 5187, 5181, 5183, 5179, 5440, 5434, 5436, 5430, 5432, 5426, 5428, 5424, - 5324, 5326, 5322, 5457, 5455, 5517, 5514, 5515, 5516, 5410, 5412, 5406, - 5408, 5402, 5404, 5400, 5377, 5379, 5373, 5375, 5369, 5371, 5367, 5277, - 5279, 5273, 5275, 5269, 5271, 5267, 5247, 5249, 5243, 5245, 5239, 5241, - 5237, 5481, 5218, 5220, 5214, 5216, 5210, 5212, 5208, 5468, 5144, 5146, - 5139, 5141, 5135, 5137, 5133, 6365, 5138, 5140, 5535, 5756, 5757, 5754, - 5755, 5752, 5753, 5751, 5534, 5531, 5532, 5533, 5758, 5143, 5145, 6323, - 5134, 5136, 5438, 5192, 5173, 5263, 5233, 5337, 5289, 5318, 5363, 5202, - 5420, 5127, 5149, 5421, 5422, 5415, 6340, 5418, 5419, 6339, 5433, 5435, - 5429, 5431, 5425, 5427, 5423, 5416, 5417, 5414, 5150, 983097, 983171, - 917631, 128473, 9803, 128367, 127852, 129387, 128758, 11839, 9809, - 128199, 128450, 128451, 8248, 8257, 8453, 66225, 66246, 66211, 66214, - 66254, 66218, 66250, 66251, 66252, 66253, 66229, 66238, 66244, 66227, - 66224, 66222, 66223, 66242, 66243, 66232, 66221, 66247, 66230, 66226, - 66239, 66212, 66248, 66256, 66235, 66208, 66215, 66210, 66220, 66234, - 66255, 66240, 66241, 66236, 66237, 66231, 66209, 66213, 66249, 66233, - 66245, 66217, 66219, 66216, 66228, 127904, 711, 127887, 129690, 983073, - 129365, 9936, 128008, 128049, 128569, 128572, 66888, 66864, 66912, 66882, - 66873, 66902, 66889, 66890, 66911, 66891, 66895, 66901, 66881, 66867, - 66870, 66868, 66904, 66866, 66876, 66910, 66879, 66883, 66897, 66915, - 66884, 66878, 66885, 66914, 66903, 66877, 66896, 66909, 66906, 66908, - 66899, 66872, 66913, 66874, 66871, 66875, 66869, 66893, 66887, 66892, - 66907, 66900, 66894, 66905, 66880, 66898, 66865, 66886, 66927, 9761, - 127797, 9963, 8373, 184, 65102, 65098, 8452, 162, 128328, 9907, 9939, - 129681, 69908, 69907, 69913, 69912, 69899, 69909, 69904, 69914, 69906, - 69905, 69911, 69910, 69920, 69921, 69918, 69917, 69901, 69900, 69898, - 69897, 69903, 69902, 69896, 69895, 69956, 69923, 69916, 69915, 69926, - 69919, 69922, 69925, 69959, 69924, 69891, 69894, 69892, 69893, 69888, - 69890, 69889, 69952, 69927, 69957, 69933, 69935, 69930, 69931, 69932, - 69958, 69928, 69929, 69934, 69936, 69939, 69954, 69953, 69947, 69946, - 69949, 69948, 69945, 69944, 69942, 69951, 69943, 69950, 69955, 69940, - 69938, 69937, 43587, 43597, 43596, 43573, 43572, 43574, 43571, 43590, - 43586, 43595, 43588, 43585, 43584, 43594, 43591, 43593, 43589, 43592, - 43530, 43531, 43536, 43538, 43537, 43543, 43544, 43551, 43552, 43548, - 43547, 43546, 43553, 43550, 43549, 43545, 43542, 43541, 43558, 43559, - 43520, 43524, 43533, 43532, 43529, 43528, 43535, 43534, 43527, 43526, - 43540, 43539, 43560, 43556, 43555, 43557, 43554, 43523, 43521, 43525, - 43522, 43612, 43614, 43613, 43615, 43561, 43568, 43569, 43562, 43563, - 43567, 43566, 43565, 43570, 43564, 43605, 43604, 43607, 43606, 43603, - 43602, 43600, 43609, 43601, 43608, 983058, 983140, 983137, 8256, 128200, - 128185, 128201, 128638, 129941, 10003, 129472, 128227, 5084, 5075, 5077, - 5079, 5081, 5082, 5083, 5055, 5037, 5038, 5039, 5040, 5041, 5042, 5054, - 5056, 5057, 5058, 5059, 5060, 5061, 5069, 5068, 5070, 5071, 5072, 5073, - 5074, 5085, 5086, 5087, 5088, 5089, 5090, 5091, 5092, 5093, 5094, 5095, - 5096, 5076, 5078, 5080, 5030, 5032, 5033, 5034, 5035, 5036, 5043, 5044, - 5045, 5046, 5047, 5048, 5049, 5050, 5051, 5052, 5053, 5109, 5062, 5063, - 5064, 5065, 5066, 5067, 5097, 5098, 5099, 5100, 5101, 5102, 5103, 5104, - 5105, 5106, 5107, 5108, 5031, 5024, 5025, 5026, 5027, 5028, 5029, 43948, - 43939, 43941, 43943, 43945, 43946, 43947, 43919, 43901, 43902, 43903, - 43904, 43905, 43906, 43918, 43920, 43921, 43922, 43923, 43924, 43925, - 43933, 43932, 43934, 43935, 43936, 43937, 43938, 43949, 43950, 43951, - 43952, 43953, 43954, 43955, 43956, 43957, 43958, 43959, 43960, 43940, - 43942, 43944, 43894, 43896, 43897, 43898, 43899, 43900, 43907, 43908, - 43909, 43910, 43911, 43912, 43913, 43914, 43915, 43916, 43917, 5117, - 43926, 43927, 43928, 43929, 43930, 43931, 43961, 43962, 43963, 43964, - 43965, 43966, 43967, 5112, 5113, 5114, 5115, 5116, 43895, 43888, 43889, - 43890, 43891, 43892, 43893, 127800, 118462, 127826, 127792, 127937, - 129490, 128696, 94194, 94195, 9767, 128063, 128020, 9911, 69559, 69553, - 69567, 69571, 69556, 69564, 69570, 69552, 69568, 69555, 69560, 69562, - 69557, 69561, 69563, 69554, 69566, 69572, 69558, 69569, 69565, 69578, - 69574, 69575, 69577, 69573, 69579, 69576, 129378, 127851, 127876, 9962, - 127910, 9680, 9682, 10690, 10683, 10691, 9684, 9683, 9685, 9677, 9681, - 10677, 10682, 10684, 127246, 8859, 11199, 10687, 129282, 129280, 129281, + 126483, 126473, 126471, 126491, 126477, 126482, 126469, 69324, 69323, + 1541, 1536, 2290, 2289, 2288, 1642, 2199, 1550, 2192, 1769, 2193, 2184, + 1544, 1629, 2296, 2301, 2298, 1772, 1623, 983633, 983635, 983640, 983634, + 983638, 983636, 983639, 983637, 983641, 1563, 1617, 65148, 65149, 1554, + 1555, 1552, 1537, 1539, 1540, 1790, 1789, 1553, 1551, 1556, 69322, 69321, + 2249, 1560, 1761, 2250, 2272, 69367, 1558, 983202, 1751, 1750, 1753, + 1752, 1762, 1764, 2273, 1756, 2261, 1755, 1557, 2200, 2260, 2266, 2268, + 2267, 2269, 2252, 69368, 2271, 2270, 2291, 1767, 2251, 1768, 2264, 69365, + 69363, 1760, 1759, 1559, 2253, 1754, 2263, 2262, 1766, 69317, 69371, + 2265, 69366, 69364, 69360, 2202, 2201, 69375, 2203, 69373, 69374, 2259, + 1773, 1763, 1562, 1561, 69326, 1765, 69361, 1622, 1618, 65150, 65151, + 2256, 2205, 64444, 64435, 64434, 64441, 64440, 64439, 64438, 64446, + 64445, 64437, 64436, 64449, 64448, 64443, 64442, 64450, 64447, 69325, + 1758, 1600, 2179, 2180, 65137, 2181, 65139, 2285, 2282, 2286, 2283, 2287, + 2284, 1566, 2275, 1644, 1627, 1626, 1628, 2190, 1631, 1567, 1625, 1545, + 1546, 1543, 1542, 1637, 1636, 1639, 1638, 1635, 1634, 1632, 1641, 1633, + 1640, 1375, 1370, 1359, 1337, 1349, 1362, 1347, 1353, 1342, 1361, 1360, + 1356, 1333, 1335, 1336, 1346, 1331, 1355, 1345, 1364, 1343, 1363, 1354, + 1351, 1357, 1329, 1358, 1352, 1340, 1366, 1341, 1339, 1330, 1348, 1350, + 1338, 1334, 1344, 1332, 1365, 1373, 1371, 1372, 1395, 1401, 1390, 1409, + 1408, 1404, 1381, 1383, 1384, 1394, 1379, 1403, 1393, 1412, 1391, 1411, + 1402, 1399, 1405, 1376, 1407, 1385, 1377, 1406, 1400, 1397, 1416, 1410, + 1388, 1414, 1389, 1387, 1378, 1396, 1398, 1386, 1382, 1392, 1380, 1413, + 1415, 64279, 64277, 64275, 64276, 64278, 1369, 1418, 1423, 1417, 1374, + 129201, 10549, 10548, 129200, 10550, 10551, 129968, 128667, 127912, 9800, + 8978, 9738, 65948, 42, 8727, 8258, 128562, 118477, 9954, 11225, 128888, + 8771, 8870, 128095, 9883, 128663, 127975, 128762, 8371, 127814, 68352, + 68353, 68357, 68355, 68358, 68359, 68356, 68354, 68373, 68374, 68372, + 68393, 68405, 68388, 68387, 68386, 68391, 68390, 68389, 68371, 68370, + 68369, 68403, 68401, 68404, 68399, 68394, 68395, 68378, 68381, 68377, + 68366, 68367, 68362, 68363, 68364, 68365, 68385, 68384, 68380, 68379, + 68402, 68400, 68360, 68361, 68375, 68383, 68376, 68368, 68398, 68392, + 68382, 68397, 68396, 68409, 129361, 8525, 1547, 129518, 9810, 129683, + 128118, 128036, 127868, 128124, 128700, 128281, 128386, 11101, 11099, + 983056, 10155, 128043, 129363, 127992, 129441, 129366, 129391, 128708, + 7007, 7005, 7006, 6991, 6990, 6917, 6918, 6987, 6988, 6928, 6953, 6954, + 6936, 6937, 6948, 6944, 6943, 6949, 6984, 6927, 6933, 6934, 6919, 6920, + 6929, 6930, 6921, 6922, 6938, 6939, 6931, 6981, 6932, 6982, 6958, 6925, + 6926, 6950, 6945, 6935, 6940, 6951, 6952, 6957, 6923, 6924, 6962, 6960, + 6961, 6946, 6942, 6941, 6947, 6983, 6985, 6986, 6963, 6955, 6959, 6956, + 7022, 7025, 7021, 7024, 7023, 7026, 7020, 7019, 7027, 7012, 7013, 7018, + 7015, 7017, 7016, 7010, 7014, 7009, 7011, 7032, 7036, 7033, 7034, 7035, + 7031, 7030, 7029, 7028, 7003, 7038, 7008, 7002, 7037, 7039, 6915, 6913, + 6912, 6914, 6916, 6964, 6972, 6973, 6970, 6971, 6968, 6969, 6974, 6975, + 6977, 6976, 6965, 6978, 6979, 6966, 6967, 6980, 7004, 6997, 6996, 6999, + 6998, 6995, 6994, 6992, 7001, 6993, 7000, 127880, 10057, 9744, 128503, + 128505, 128499, 128501, 11197, 9745, 9746, 128502, 128500, 10007, 129526, + 129648, 42737, 42736, 42741, 42740, 42733, 42699, 42713, 42712, 42692, + 42706, 42683, 42719, 42734, 42735, 42682, 42729, 42657, 42725, 42659, + 42670, 42718, 42666, 42716, 42701, 42675, 42671, 42722, 42720, 42727, + 42723, 42702, 42726, 42677, 42707, 42708, 42709, 42686, 42694, 42674, + 42731, 42695, 42685, 42684, 42691, 42673, 42664, 42715, 42703, 92193, + 92188, 92161, 92199, 92240, 92179, 92211, 92219, 92213, 92243, 92207, + 92216, 92183, 92184, 92238, 92171, 983268, 92174, 92203, 92186, 92210, + 92230, 92175, 92221, 92232, 92246, 92198, 92214, 92190, 92176, 92197, + 92196, 92164, 92245, 92212, 92201, 92160, 92182, 92173, 92229, 92227, + 92180, 92237, 92241, 92223, 92185, 92194, 92178, 92239, 92225, 92233, + 92167, 92191, 92231, 92244, 92204, 92226, 92236, 92200, 92189, 92187, + 92162, 92163, 92169, 92170, 92202, 92205, 92222, 92168, 92165, 92215, + 92224, 92208, 92220, 92235, 92177, 92181, 92195, 92234, 92209, 92166, + 92172, 92206, 92192, 92228, 92217, 92242, 92218, 92262, 92271, 92272, + 92270, 92294, 92253, 92301, 92256, 92273, 92259, 92251, 92297, 92300, + 92296, 92295, 92255, 92252, 92292, 92286, 92268, 92290, 92281, 92267, + 92284, 92287, 92282, 92283, 92277, 92298, 983270, 92276, 92302, 92247, + 92299, 92288, 92269, 92260, 92261, 983269, 92289, 92257, 92274, 92263, + 92279, 92265, 92266, 92250, 92249, 92285, 92248, 92264, 92280, 92258, + 92254, 92278, 92291, 92293, 92275, 92310, 92320, 92312, 92394, 92393, + 92319, 92384, 92321, 92386, 92361, 92373, 92366, 92328, 92329, 92357, + 92342, 92397, 92365, 92376, 92339, 92382, 92363, 92318, 92387, 92383, + 92315, 92385, 92354, 92311, 92381, 92343, 92326, 92364, 92324, 92391, + 92344, 92390, 92338, 92396, 92308, 92349, 92375, 92378, 92317, 92331, + 92362, 92336, 92341, 92370, 92347, 92307, 92303, 92309, 92395, 92368, + 92356, 92367, 92360, 92389, 92333, 92359, 92374, 92351, 92325, 92371, + 92350, 92345, 92372, 92314, 92340, 92323, 92304, 92313, 92316, 92398, + 92399, 92380, 92330, 983271, 92379, 92392, 92335, 92332, 92346, 92400, + 92358, 92334, 92353, 92337, 92306, 92369, 92388, 92322, 92305, 92327, + 92377, 92352, 92348, 92355, 92436, 92517, 92488, 92434, 92415, 92431, + 92454, 92460, 92420, 92489, 92422, 92474, 92479, 92449, 92502, 92439, + 92484, 92495, 92464, 92511, 92406, 92446, 92497, 92426, 92482, 92448, + 92515, 92401, 92478, 92427, 92496, 92458, 92424, 92445, 92404, 92466, + 92444, 92438, 92442, 92441, 92510, 92499, 92425, 92437, 92440, 92471, + 92465, 92409, 92483, 92475, 92467, 92485, 92457, 92432, 92476, 92435, + 92412, 92414, 92430, 92407, 92403, 92405, 92487, 92418, 92486, 92408, + 92447, 92459, 92480, 92472, 92505, 92514, 92450, 92463, 92410, 92493, + 92507, 92503, 92462, 92506, 92443, 92509, 92469, 92461, 92490, 92512, + 92494, 92455, 92417, 92501, 92413, 92508, 92500, 92504, 92473, 92419, + 92498, 92423, 92516, 92428, 92452, 92451, 92481, 92416, 92456, 92433, + 92477, 92492, 92491, 92513, 92411, 92402, 92421, 92453, 92468, 92470, + 92429, 92661, 92626, 92616, 92596, 92612, 92603, 92673, 92651, 92627, + 92597, 92585, 92578, 92615, 92565, 92552, 92602, 92674, 92570, 92646, + 92599, 92532, 92587, 92538, 92620, 92670, 92665, 92575, 92521, 92633, + 92595, 92523, 92556, 92539, 92664, 92653, 92667, 92600, 92542, 92555, + 92668, 92520, 92582, 92591, 92581, 92551, 92654, 92611, 92614, 92666, + 92671, 92617, 92637, 92562, 92518, 92592, 92558, 92528, 92607, 92535, + 92557, 92563, 92550, 92624, 983272, 92640, 92657, 92531, 92601, 92553, + 92543, 92619, 92598, 92541, 92544, 92579, 92658, 92554, 92628, 92648, + 92547, 92527, 92545, 92540, 92604, 92622, 92589, 92608, 92583, 92609, + 92662, 92613, 92584, 92625, 92634, 92524, 92536, 92605, 92647, 92548, + 92663, 92593, 92621, 92568, 92610, 92576, 92529, 92618, 92649, 92561, + 92656, 92526, 92655, 92546, 92534, 92560, 92580, 92659, 92660, 92638, + 92571, 92525, 92549, 92559, 92635, 92577, 92530, 92636, 92669, 92572, + 92672, 92537, 92519, 92630, 92586, 92569, 92566, 92573, 92652, 92522, + 92574, 92650, 92533, 92567, 92623, 92606, 92639, 92564, 92590, 92642, + 92643, 92594, 92641, 92645, 92644, 92588, 92629, 92632, 92631, 92710, + 92695, 92694, 92726, 92675, 92719, 92677, 92718, 92682, 92717, 92689, + 92720, 92724, 92685, 92722, 92723, 92711, 92712, 92698, 92688, 92697, + 92696, 92702, 92687, 92704, 92681, 92708, 92703, 92706, 92714, 92709, + 92679, 92721, 92684, 92683, 92707, 92691, 92713, 92700, 92693, 92727, + 92690, 92692, 92686, 92680, 92725, 92699, 92701, 92705, 92716, 92728, + 92678, 92715, 92676, 42693, 42698, 42711, 42696, 42667, 42717, 42704, + 42661, 42721, 42669, 42668, 42705, 42700, 42680, 42678, 42710, 42688, + 42681, 42732, 42676, 42679, 42730, 42728, 42672, 42662, 42724, 42687, + 42689, 42690, 42697, 42714, 42660, 42656, 42665, 42663, 42658, 42738, + 42742, 42739, 42743, 127974, 128183, 128180, 128182, 128181, 127820, + 129685, 128202, 129532, 128136, 129530, 127936, 92916, 92912, 92915, + 92913, 92914, 92887, 92894, 92908, 92880, 92907, 92893, 92886, 92888, + 92881, 92906, 92896, 92891, 92902, 92900, 92885, 92890, 92904, 92905, + 92884, 92899, 92889, 92897, 92892, 92895, 92882, 92898, 92883, 92901, + 92903, 92909, 92917, 9918, 129415, 7152, 7153, 7124, 7108, 7114, 7130, + 7139, 7127, 7138, 7133, 7136, 7113, 7111, 7117, 7119, 7107, 7135, 7125, + 7112, 7123, 7129, 7116, 7132, 7105, 7126, 7128, 7110, 7109, 7137, 7121, + 7118, 7106, 7120, 7134, 7122, 7115, 7131, 7104, 7140, 7141, 7154, 7155, + 7167, 7165, 7166, 7164, 7142, 7150, 7151, 7144, 7147, 7149, 7143, 7145, + 7146, 7148, 128704, 128705, 128267, 127900, 127901, 9835, 9836, 129492, + 128059, 127958, 128147, 129451, 129752, 127866, 129714, 983055, 128276, + 129745, 128277, 9086, 128718, 118478, 2557, 2432, 2519, 2548, 2552, 2551, + 2550, 2549, 2553, 2437, 73201, 2438, 2448, 2452, 2454, 2510, 983661, + 2453, 2480, 2545, 2544, 2525, 2524, 2556, 2443, 2528, 2444, 2529, 2527, + 2479, 2466, 2465, 2471, 2470, 2464, 2463, 2469, 2468, 2441, 2442, 2439, + 2440, 2457, 2467, 2462, 2472, 2486, 2487, 2488, 2477, 2476, 2459, 2458, + 2456, 2455, 2461, 2460, 2475, 2474, 2489, 2482, 2478, 2447, 2451, 2547, + 2546, 983651, 983650, 983652, 73200, 2433, 2492, 2493, 2434, 2509, 2435, + 2558, 2554, 2494, 2504, 2508, 2497, 2498, 2499, 2500, 2530, 2531, 2495, + 2496, 2503, 2507, 2539, 2538, 2541, 2540, 2537, 2536, 2534, 2543, 2535, + 2542, 2555, 11102, 127857, 9004, 9187, 93856, 93880, 93858, 93864, 93873, + 93874, 93859, 93861, 93869, 93868, 93870, 93876, 93875, 93867, 93862, + 93865, 93877, 93857, 93879, 93860, 93866, 93871, 93872, 93878, 93863, + 93883, 93907, 93885, 93891, 93900, 93901, 93886, 93888, 93896, 93895, + 93897, 93903, 93902, 93894, 93889, 93892, 93904, 93884, 93906, 93887, + 93893, 93898, 93899, 93905, 93890, 8812, 8502, 8757, 129475, 128719, + 72710, 72711, 72712, 72746, 72704, 72705, 72715, 72717, 72731, 72730, + 72736, 72735, 72729, 72728, 72734, 72733, 72708, 72709, 72706, 72707, + 72722, 72732, 72727, 72737, 72747, 72748, 72749, 72741, 72740, 72724, + 72723, 72721, 72720, 72726, 72725, 72719, 72718, 72739, 72738, 72750, + 72745, 72742, 72744, 72743, 72714, 72716, 72801, 72810, 72806, 72797, + 72807, 72798, 72802, 72811, 72800, 72809, 72799, 72808, 72796, 72805, + 72804, 72795, 72803, 72794, 72764, 72768, 72765, 72767, 72766, 72756, + 72757, 72758, 72751, 72761, 72763, 72754, 72755, 72752, 72753, 72760, + 72762, 72770, 72769, 72789, 72788, 72791, 72790, 72787, 72786, 72784, + 72793, 72785, 72792, 72771, 72772, 72773, 72812, 128692, 128690, 10745, + 10744, 129506, 127921, 127874, 128038, 8383, 129766, 9763, 128089, + 129452, 9679, 9864, 128986, 10733, 9865, 9210, 11176, 11177, 11178, + 11179, 11180, 11182, 11181, 11183, 9960, 10028, 129623, 9821, 129554, + 129596, 129609, 129612, 129622, 9818, 129551, 129593, 9822, 129543, + 129564, 129585, 129597, 129606, 129555, 129619, 129617, 129618, 9823, + 129556, 129598, 9819, 129552, 129594, 9820, 129553, 129595, 129575, + 129572, 129576, 129577, 129573, 129574, 9827, 9670, 11201, 10070, 10730, + 11230, 9830, 128419, 128899, 9196, 9662, 9660, 11167, 127778, 9922, 9923, + 10047, 9873, 10022, 128447, 128420, 9829, 11042, 128426, 11052, 10711, + 11044, 117867, 117870, 117869, 117868, 11035, 9194, 9198, 128896, 9668, + 9666, 9664, 11164, 8268, 9944, 128412, 9754, 9699, 9698, 10731, 9207, + 11206, 11045, 9204, 11207, 11047, 9205, 11208, 9206, 11205, 128921, + 128927, 9726, 9724, 9912, 117871, 10002, 128392, 9648, 11039, 127986, + 118451, 128413, 9755, 9193, 9197, 9654, 9199, 128898, 11091, 9658, 9656, + 10145, 10148, 11166, 8269, 127990, 9644, 11049, 11050, 11089, 9642, + 129997, 9787, 9632, 11200, 9209, 128306, 9728, 128369, 9927, 9984, + 128900, 128909, 9986, 9751, 9824, 9733, 128919, 128925, 128908, 9951, + 128383, 9742, 9942, 128418, 128897, 9195, 9652, 9650, 9700, 9701, 11165, + 9851, 9646, 11054, 128920, 128926, 11037, 11204, 10707, 10067, 8493, + 8460, 8465, 8476, 8488, 10164, 10166, 10165, 9250, 118018, 118039, + 118128, 118187, 118218, 118159, 118054, 118112, 118234, 118084, 118202, + 118143, 118031, 118062, 118120, 118240, 118179, 118090, 118210, 118151, + 118047, 118104, 118226, 118165, 118076, 118194, 118135, 118021, 118035, + 118066, 118124, 118243, 118183, 118093, 118214, 118155, 118050, 118108, + 118230, 118168, 118080, 118198, 118139, 118028, 118058, 118116, 118237, + 118175, 118087, 118206, 118147, 118043, 118100, 118222, 118162, 118072, + 118190, 118131, 118029, 118060, 118118, 118177, 118208, 118149, 118045, + 118102, 118224, 118023, 118037, 118068, 118126, 118244, 118185, 118095, + 118216, 118157, 118052, 118110, 118232, 118170, 118082, 118200, 118141, + 118074, 118192, 118133, 118020, 118033, 118064, 118122, 118242, 118181, + 118092, 118212, 118153, 118048, 118106, 118228, 118167, 118078, 118196, + 118137, 118026, 118056, 118114, 118235, 118173, 118085, 118204, 118145, + 118041, 118098, 118220, 118160, 118070, 118188, 118129, 118034, 118065, + 118123, 118182, 118213, 118154, 118049, 118107, 118229, 118079, 118197, + 118138, 118017, 118024, 118038, 118069, 118127, 118245, 118186, 118096, + 118217, 118158, 118053, 118111, 118233, 118171, 118083, 118201, 118142, + 118030, 118061, 118119, 118239, 118178, 118089, 118209, 118150, 118046, + 118103, 118225, 118164, 118075, 118193, 118134, 118027, 118057, 118115, + 118236, 118174, 118086, 118205, 118146, 118042, 118099, 118221, 118161, + 118071, 118189, 118130, 118025, 118055, 118113, 118172, 118203, 118144, + 118040, 118097, 118219, 118016, 118022, 118036, 118067, 118125, 118184, + 118094, 118215, 118156, 118051, 118109, 118231, 118169, 118081, 118199, + 118140, 118059, 118117, 118238, 118176, 118088, 118207, 118148, 118044, + 118101, 118223, 118163, 118073, 118191, 118132, 118019, 118105, 118227, + 118166, 118032, 118063, 118121, 118241, 118180, 118091, 118211, 118152, + 118077, 118195, 118136, 129792, 129794, 129798, 129806, 129821, 129836, + 129813, 129844, 129829, 129802, 129817, 129848, 129832, 129810, 129840, + 129825, 129796, 129804, 129819, 129850, 129834, 129842, 129827, 129800, + 129815, 129846, 129831, 129808, 129838, 129823, 129793, 129801, 129816, + 129847, 129797, 129805, 129820, 129851, 129835, 129812, 129843, 129828, + 129809, 129839, 129824, 129795, 129803, 129818, 129849, 129833, 129811, + 129841, 129826, 129799, 129814, 129845, 129830, 129807, 129837, 129822, + 127804, 128033, 128216, 128153, 129744, 128939, 128951, 128957, 128945, + 128902, 128912, 128932, 128366, 128278, 128209, 128218, 129667, 12731, + 12727, 12726, 12724, 12725, 12570, 12574, 12718, 12576, 12719, 12578, + 12580, 12713, 12735, 12720, 12584, 12715, 12572, 12579, 12581, 12709, + 12708, 12573, 12575, 12582, 12557, 12728, 12588, 12707, 12732, 12583, + 12714, 12723, 12589, 12716, 12712, 12585, 12555, 12587, 12717, 12591, + 12571, 12722, 12711, 12590, 12734, 12721, 12710, 12577, 12567, 12563, + 12705, 12730, 12558, 12733, 12568, 12564, 12556, 12729, 12569, 12565, + 12549, 12704, 12560, 12706, 12553, 12552, 12559, 12551, 12550, 12561, + 12566, 12554, 12586, 12562, 118257, 118258, 118259, 118260, 117854, + 11867, 117853, 118253, 118255, 11868, 117855, 118249, 118251, 118247, + 11211, 8993, 130029, 8990, 8973, 11812, 8991, 8972, 11813, 130030, 9141, + 9142, 10555, 9183, 9181, 130026, 130018, 9185, 127870, 128144, 127893, + 128335, 129379, 127923, 8904, 10705, 10706, 127993, 118282, 117792, + 117791, 118281, 9574, 9559, 9556, 9577, 9565, 9562, 9553, 9580, 9571, + 9568, 9552, 9511, 9490, 9503, 9486, 9537, 9520, 9513, 9489, 9505, 9485, + 9543, 9519, 9558, 9555, 9573, 9557, 9554, 9572, 9592, 9598, 9593, 9599, + 9499, 9531, 9495, 9475, 9547, 9515, 9507, 9595, 9523, 9491, 9487, 9551, + 9549, 9483, 9481, 9479, 9477, 9473, 9594, 9541, 9525, 9517, 9533, 9530, + 9522, 9546, 9539, 9582, 9581, 9583, 9584, 130010, 130014, 129954, 129958, + 130003, 129959, 129964, 129965, 129955, 130000, 129952, 129956, 129963, + 129960, 129953, 129961, 129957, 129962, 130007, 130005, 130004, 130012, + 9586, 130008, 130011, 130002, 130015, 130006, 9585, 130009, 130001, + 130013, 9587, 129966, 9591, 9516, 9488, 9484, 9550, 9548, 9472, 117787, + 117788, 129967, 9588, 9596, 9482, 9480, 9478, 9476, 117789, 9589, 9597, + 9524, 9496, 9492, 9474, 118297, 118295, 118296, 118294, 9532, 9508, 9500, + 117790, 9590, 9542, 9526, 9518, 9534, 9529, 9521, 9545, 9540, 9536, 9510, + 9498, 9502, 9494, 9528, 9544, 9514, 9497, 9506, 9493, 9527, 9564, 9561, + 9576, 9563, 9560, 9575, 9570, 9567, 9579, 9538, 9512, 9504, 9535, 9509, + 9501, 9569, 9566, 9578, 129354, 983263, 128163, 128102, 128713, 128023, + 129460, 69649, 69685, 69749, 69745, 69746, 69687, 69686, 69637, 69638, + 69648, 69650, 69664, 69663, 69669, 69668, 69662, 69661, 69667, 69666, + 69643, 69644, 69645, 69646, 69679, 69641, 69642, 69639, 69640, 69684, + 69678, 69655, 69665, 69660, 69670, 69680, 69681, 69682, 69674, 69673, + 69657, 69656, 69654, 69653, 69659, 69658, 69652, 69651, 69672, 69671, + 69683, 69675, 69677, 69676, 69647, 69721, 69730, 69726, 69717, 69727, + 69718, 69722, 69731, 69720, 69729, 69719, 69728, 69716, 69725, 69724, + 69715, 69723, 69714, 69732, 69733, 69759, 69709, 69707, 69706, 69705, + 69708, 69632, 69744, 69635, 69634, 69636, 69633, 69700, 69747, 69748, + 69689, 69688, 69699, 69701, 69692, 69693, 69694, 69695, 69696, 69697, + 69690, 69691, 69698, 69702, 69704, 69703, 69739, 69738, 69741, 69740, + 69737, 69736, 69734, 69743, 69735, 69742, 10241, 10243, 10247, 10255, + 10271, 10303, 10367, 10495, 10431, 10335, 10463, 10399, 10287, 10351, + 10479, 10415, 10319, 10447, 10383, 10263, 10295, 10359, 10487, 10423, + 10327, 10455, 10391, 10279, 10343, 10471, 10407, 10311, 10439, 10375, + 10251, 10267, 10299, 10363, 10491, 10427, 10331, 10459, 10395, 10283, + 10347, 10475, 10411, 10315, 10443, 10379, 10259, 10291, 10355, 10483, + 10419, 10323, 10451, 10387, 10275, 10339, 10467, 10403, 10307, 10435, + 10371, 10245, 10253, 10269, 10301, 10365, 10493, 10429, 10333, 10461, + 10397, 10285, 10349, 10477, 10413, 10317, 10445, 10381, 10261, 10293, + 10357, 10485, 10421, 10325, 10453, 10389, 10277, 10341, 10469, 10405, + 10309, 10437, 10373, 10249, 10265, 10297, 10361, 10489, 10425, 10329, + 10457, 10393, 10281, 10345, 10473, 10409, 10313, 10441, 10377, 10257, + 10289, 10353, 10481, 10417, 10321, 10449, 10385, 10273, 10337, 10465, + 10401, 10305, 10433, 10369, 10242, 10246, 10254, 10270, 10302, 10366, + 10494, 10430, 10334, 10462, 10398, 10286, 10350, 10478, 10414, 10318, + 10446, 10382, 10262, 10294, 10358, 10486, 10422, 10326, 10454, 10390, + 10278, 10342, 10470, 10406, 10310, 10438, 10374, 10250, 10266, 10298, + 10362, 10490, 10426, 10330, 10458, 10394, 10282, 10346, 10474, 10410, + 10314, 10442, 10378, 10258, 10290, 10354, 10482, 10418, 10322, 10450, + 10386, 10274, 10338, 10466, 10402, 10306, 10434, 10370, 10244, 10252, + 10268, 10300, 10364, 10492, 10428, 10332, 10460, 10396, 10284, 10348, + 10476, 10412, 10316, 10444, 10380, 10260, 10292, 10356, 10484, 10420, + 10324, 10452, 10388, 10276, 10340, 10468, 10404, 10308, 10436, 10372, + 10248, 10264, 10296, 10360, 10488, 10424, 10328, 10456, 10392, 10280, + 10344, 10472, 10408, 10312, 10440, 10376, 10256, 10288, 10352, 10480, + 10416, 10320, 10448, 10384, 10272, 10336, 10464, 10400, 10304, 10432, + 10368, 10240, 129504, 983125, 129329, 127838, 728, 127753, 128112, + 128188, 129650, 129521, 9099, 166, 128148, 129382, 129294, 129529, + 129483, 129767, 128027, 6663, 6662, 6659, 6658, 6671, 6670, 6667, 6666, + 6661, 6668, 6665, 6657, 6678, 6669, 6656, 6674, 6660, 6673, 6676, 6664, + 6675, 6672, 6677, 6683, 6681, 6679, 6682, 6680, 6687, 6686, 5957, 5960, + 5962, 5959, 5956, 5969, 5955, 5966, 5963, 5961, 5965, 5968, 5958, 5967, + 5964, 5952, 5953, 5954, 5970, 5971, 8226, 128987, 8729, 128363, 128364, + 9678, 128652, 128101, 128100, 128655, 129480, 129419, 127959, 127791, + 129699, 118939, 118940, 118944, 118943, 118941, 118942, 118938, 118945, + 118882, 118876, 118824, 118835, 118797, 118866, 118957, 118801, 118802, + 118865, 118818, 118916, 118819, 118917, 118899, 118935, 119018, 119022, + 119021, 119020, 119023, 119019, 119017, 118986, 118984, 118985, 118843, + 118887, 118808, 118870, 119003, 119002, 119004, 119005, 118937, 118991, + 118995, 118990, 118992, 118994, 118993, 118930, 118933, 118931, 118932, + 119014, 118918, 118912, 119015, 118785, 118831, 118907, 118966, 118900, + 118880, 118798, 118888, 118884, 118869, 118960, 118959, 118958, 118836, + 118969, 118977, 118978, 118971, 118976, 118975, 118973, 118970, 118987, + 118979, 118980, 118972, 118983, 983278, 118982, 118974, 118988, 118981, + 119000, 119001, 118929, 118928, 118806, 119029, 118927, 118898, 118964, + 118965, 118853, 118968, 118837, 118967, 118936, 118956, 118810, 118854, + 118847, 118839, 118906, 118791, 118800, 119026, 119024, 118862, 118812, + 119027, 119025, 118863, 118811, 118820, 119028, 118911, 118842, 118850, + 118921, 118858, 118913, 118914, 118915, 118834, 118860, 118868, 118796, + 118881, 118922, 118926, 118925, 118924, 118923, 118830, 118877, 118949, + 118947, 118948, 118963, 118955, 118962, 118946, 118961, 118953, 118952, + 118951, 118950, 118954, 118871, 118805, 118855, 118828, 118901, 118787, + 118788, 118856, 118816, 118875, 118845, 118879, 118793, 118846, 118878, + 118814, 118822, 118873, 118859, 118857, 118849, 118840, 118861, 118786, + 118895, 118841, 118874, 118892, 118897, 118807, 118784, 118821, 118844, + 118825, 118889, 119010, 119012, 119013, 119011, 119006, 119008, 119009, + 119007, 118910, 118815, 118852, 119016, 118826, 118885, 118827, 118803, + 118886, 118792, 118813, 118920, 118799, 118833, 118829, 118904, 118902, + 118903, 118905, 118804, 118934, 118919, 118832, 118893, 118838, 118851, + 118883, 118894, 118891, 118896, 118823, 118789, 118790, 118872, 118817, + 118809, 118908, 118909, 118996, 118998, 118997, 118999, 118989, 118794, + 118795, 118867, 118864, 118848, 118890, 983262, 983126, 983057, 9764, + 8454, 129305, 128197, 128247, 128248, 127957, 983098, 5130, 5131, 5122, + 6322, 5148, 5551, 5310, 5382, 5166, 6321, 5759, 5559, 5556, 5557, 5558, + 5567, 5564, 5565, 5566, 5563, 5560, 5561, 5562, 5555, 5552, 5553, 5554, + 5384, 5439, 6387, 6388, 5281, 5264, 6382, 6389, 5203, 5674, 5675, 5677, + 5676, 5673, 5672, 5706, 5707, 5709, 5708, 5705, 5704, 5204, 5574, 5575, + 5577, 5576, 5573, 5572, 6384, 6381, 5620, 6383, 5617, 5618, 5619, 5616, + 5615, 5195, 5592, 5593, 5595, 5594, 5591, 5590, 5174, 5175, 5129, 5703, + 5662, 5663, 5665, 5664, 5661, 5660, 5655, 5656, 6386, 5659, 5657, 5654, + 5652, 5633, 5629, 5630, 5632, 5631, 5628, 5627, 5623, 5624, 5626, 5625, + 5622, 5621, 5636, 5637, 5639, 5329, 5638, 5635, 5634, 5722, 5718, 5719, + 5721, 5720, 5717, 5716, 5712, 5713, 5715, 5714, 5711, 5710, 5614, 5610, + 5611, 5613, 5612, 5609, 5608, 5702, 5698, 5699, 5701, 5700, 5697, 5696, + 5686, 5687, 5689, 5688, 5685, 5684, 5692, 5693, 5695, 5694, 5691, 5690, + 5737, 5738, 5740, 5739, 5736, 5735, 5604, 5605, 5607, 5606, 5603, 5602, + 5598, 5599, 5601, 5600, 5597, 5596, 5725, 5726, 5728, 5727, 5724, 5723, + 5680, 5681, 5683, 5682, 5679, 5678, 5668, 5669, 5671, 5670, 5667, 5666, + 5731, 5732, 5734, 5733, 5730, 5729, 5642, 5643, 5645, 5644, 5641, 5640, + 5580, 5581, 5583, 5582, 5579, 5578, 5586, 5587, 5589, 5588, 5585, 5584, + 5648, 5649, 5651, 5650, 5647, 5646, 5128, 5265, 5258, 5276, 5278, 5272, + 5274, 5268, 5270, 5266, 5741, 5261, 5262, 5259, 5260, 5257, 5121, 6364, + 5163, 5469, 5465, 5466, 5460, 5461, 5158, 5157, 5162, 5155, 5156, 6367, + 6366, 5160, 5152, 5151, 5153, 5154, 5161, 5159, 5462, 5742, 5463, 5464, + 5467, 5459, 5120, 5501, 5123, 5124, 5164, 5251, 5252, 5246, 5248, 6329, + 5242, 5244, 5238, 5240, 5236, 5234, 5235, 5228, 6328, 5231, 5232, 5229, + 5230, 5227, 5354, 5542, 5540, 5541, 5538, 5539, 5536, 5537, 5338, 5339, + 5332, 6333, 5350, 5352, 5346, 5348, 5342, 5344, 5340, 5335, 5336, 5333, + 5334, 5331, 5307, 5283, 5356, 5458, 5287, 5288, 5385, 5290, 5291, 5284, + 6330, 5302, 5304, 5298, 5300, 5294, 5296, 5292, 5285, 5286, 5309, 5328, + 5473, 5475, 5471, 5319, 5391, 5388, 5389, 5386, 5390, 5380, 5387, 5142, + 5147, 5280, 5250, 5306, 5327, 5221, 5437, 72372, 72373, 72370, 72371, + 72368, 72369, 72378, 72379, 72376, 72377, 72374, 72375, 5320, 5313, 6332, + 5525, 5523, 5524, 5518, 5744, 5521, 5522, 5519, 5520, 5526, 5749, 5750, + 5747, 5748, 5745, 5746, 5499, 5497, 5498, 5495, 5496, 5493, 5494, 5492, + 5500, 5316, 5317, 6331, 5323, 5325, 6346, 6348, 6342, 6344, 5321, 5314, + 5315, 5312, 5330, 5509, 5507, 5508, 5502, 5743, 5505, 5506, 5503, 5504, + 5125, 6361, 6347, 6349, 6343, 6345, 6362, 6363, 6359, 6358, 6360, 6356, + 6357, 5165, 5126, 6320, 5193, 5184, 5186, 6326, 5188, 5190, 5180, 5182, + 5178, 5176, 5177, 5168, 6325, 5171, 5172, 6324, 5169, 5170, 5167, 5456, + 6368, 5443, 6355, 5454, 6353, 6354, 6351, 6352, 6350, 5451, 5452, 5445, + 6341, 5448, 5449, 5446, 5447, 5442, 5381, 5364, 6335, 5570, 6380, 5571, + 5568, 5569, 5653, 6385, 5658, 5529, 6379, 6378, 5530, 5527, 5528, 5441, + 5282, 5311, 5365, 5358, 5413, 5405, 5407, 6338, 5409, 5411, 5401, 5403, + 5399, 5395, 5396, 6336, 5397, 5398, 6337, 5393, 5394, 5392, 5361, 5256, + 5253, 5254, 5255, 5362, 6334, 5383, 5376, 5378, 5372, 5374, 5368, 5370, + 5366, 72383, 72380, 72381, 72382, 5359, 5360, 5357, 5222, 5482, 5550, + 5548, 5549, 5546, 5547, 5544, 5545, 5543, 6372, 5480, 6371, 5478, 5479, + 5476, 5477, 5472, 5474, 5470, 5512, 6377, 6376, 5513, 5510, 5511, 5487, + 5486, 6375, 5485, 6374, 6373, 5483, 5484, 5226, 5223, 5224, 5225, 5205, + 5206, 5197, 6327, 5217, 5219, 5213, 5215, 5209, 5211, 5207, 5491, 5488, + 5489, 5490, 5200, 5201, 5198, 5199, 5196, 5132, 5355, 5351, 5353, 5347, + 5349, 5343, 5345, 5341, 5453, 6370, 5450, 6369, 5444, 5308, 5303, 5305, + 5299, 5301, 5295, 5297, 5293, 5194, 5189, 5191, 5185, 5187, 5181, 5183, + 5179, 5440, 5434, 5436, 5430, 5432, 5426, 5428, 5424, 5324, 5326, 5322, + 5457, 5455, 5517, 5514, 5515, 5516, 5410, 5412, 5406, 5408, 5402, 5404, + 5400, 5377, 5379, 5373, 5375, 5369, 5371, 5367, 5277, 5279, 5273, 5275, + 5269, 5271, 5267, 5247, 5249, 5243, 5245, 5239, 5241, 5237, 5481, 5218, + 5220, 5214, 5216, 5210, 5212, 5208, 5468, 5144, 5146, 5139, 5141, 5135, + 5137, 5133, 6365, 5138, 5140, 5535, 5756, 5757, 5754, 5755, 5752, 5753, + 5751, 5534, 5531, 5532, 5533, 5758, 5143, 5145, 6323, 5134, 5136, 5438, + 5192, 5173, 5263, 5233, 5337, 5289, 5318, 5363, 5202, 5420, 5127, 5149, + 5421, 5422, 5415, 6340, 5418, 5419, 6339, 5433, 5435, 5429, 5431, 5425, + 5427, 5423, 5416, 5417, 5414, 5150, 983097, 983171, 917631, 128473, 9803, + 128367, 127852, 129387, 128758, 11839, 9809, 128199, 128450, 128451, + 8248, 8257, 8453, 66225, 66246, 66211, 66214, 66254, 66218, 66250, 66251, + 66252, 66253, 66229, 66238, 66244, 66227, 66224, 66222, 66223, 66242, + 66243, 66232, 66221, 66247, 66230, 66226, 66239, 66212, 66248, 66256, + 66235, 66208, 66215, 66210, 66220, 66234, 66255, 66240, 66241, 66236, + 66237, 66231, 66209, 66213, 66249, 66233, 66245, 66217, 66219, 66216, + 66228, 127904, 711, 127887, 129690, 983073, 129365, 121616, 9936, 128008, + 128049, 128569, 128572, 66888, 66864, 66912, 66882, 66873, 66902, 66889, + 66890, 66911, 66891, 66895, 66901, 66881, 66867, 66870, 66868, 66904, + 66866, 66876, 66910, 66879, 66883, 66897, 66915, 66884, 66878, 66885, + 66914, 66903, 66877, 66896, 66909, 66906, 66908, 66899, 66872, 66913, + 66874, 66871, 66875, 66869, 66893, 66887, 66892, 66907, 66900, 66894, + 66905, 66880, 66898, 66865, 66886, 66927, 9761, 127797, 9963, 8373, 184, + 65102, 65098, 8452, 162, 128328, 9907, 9939, 129681, 69908, 69907, 69913, + 69912, 69899, 69909, 69904, 69914, 69906, 69905, 69911, 69910, 69920, + 69921, 69918, 69917, 69901, 69900, 69898, 69897, 69903, 69902, 69896, + 69895, 69956, 69923, 69916, 69915, 69926, 69919, 69922, 69925, 69959, + 69924, 69891, 69894, 69892, 69893, 69888, 69890, 69889, 69952, 69927, + 69957, 69933, 69935, 69930, 69931, 69932, 69958, 69928, 69929, 69934, + 69936, 69939, 69954, 69953, 69947, 69946, 69949, 69948, 69945, 69944, + 69942, 69951, 69943, 69950, 69955, 69940, 69938, 69937, 43587, 43597, + 43596, 43573, 43572, 43574, 43571, 43590, 43586, 43595, 43588, 43585, + 43584, 43594, 43591, 43593, 43589, 43592, 43530, 43531, 43536, 43538, + 43537, 43543, 43544, 43551, 43552, 43548, 43547, 43546, 43553, 43550, + 43549, 43545, 43542, 43541, 43558, 43559, 43520, 43524, 43533, 43532, + 43529, 43528, 43535, 43534, 43527, 43526, 43540, 43539, 43560, 43556, + 43555, 43557, 43554, 43523, 43521, 43525, 43522, 43612, 43614, 43613, + 43615, 43561, 43568, 43569, 43562, 43563, 43567, 43566, 43565, 43570, + 43564, 43605, 43604, 43607, 43606, 43603, 43602, 43600, 43609, 43601, + 43608, 983058, 983140, 983137, 8256, 128200, 128185, 128201, 128638, + 129941, 10003, 129472, 128227, 5084, 5075, 5077, 5079, 5081, 5082, 5083, + 5055, 5037, 5038, 5039, 5040, 5041, 5042, 5054, 5056, 5057, 5058, 5059, + 5060, 5061, 5069, 5068, 5070, 5071, 5072, 5073, 5074, 5085, 5086, 5087, + 5088, 5089, 5090, 5091, 5092, 5093, 5094, 5095, 5096, 5076, 5078, 5080, + 5030, 5032, 5033, 5034, 5035, 5036, 5043, 5044, 5045, 5046, 5047, 5048, + 5049, 5050, 5051, 5052, 5053, 5109, 5062, 5063, 5064, 5065, 5066, 5067, + 5097, 5098, 5099, 5100, 5101, 5102, 5103, 5104, 5105, 5106, 5107, 5108, + 5031, 5024, 5025, 5026, 5027, 5028, 5029, 43948, 43939, 43941, 43943, + 43945, 43946, 43947, 43919, 43901, 43902, 43903, 43904, 43905, 43906, + 43918, 43920, 43921, 43922, 43923, 43924, 43925, 43933, 43932, 43934, + 43935, 43936, 43937, 43938, 43949, 43950, 43951, 43952, 43953, 43954, + 43955, 43956, 43957, 43958, 43959, 43960, 43940, 43942, 43944, 43894, + 43896, 43897, 43898, 43899, 43900, 43907, 43908, 43909, 43910, 43911, + 43912, 43913, 43914, 43915, 43916, 43917, 5117, 43926, 43927, 43928, + 43929, 43930, 43931, 43961, 43962, 43963, 43964, 43965, 43966, 43967, + 5112, 5113, 5114, 5115, 5116, 43895, 43888, 43889, 43890, 43891, 43892, + 43893, 127800, 118462, 127826, 127792, 127937, 129490, 128696, 94194, + 94195, 9767, 128063, 128020, 9911, 69559, 69553, 69567, 69571, 69556, + 69564, 69570, 69552, 69568, 69555, 69560, 69562, 69557, 69561, 69563, + 69554, 69566, 69572, 69558, 69569, 69565, 69578, 69574, 69575, 69577, + 69573, 69579, 69576, 129378, 127851, 127876, 9962, 127910, 9680, 9682, + 10690, 10683, 10691, 9684, 9683, 9685, 129009, 9677, 9681, 10677, 10682, + 10684, 127246, 8859, 11199, 129011, 10687, 129282, 129280, 129281, 128320, 9938, 127342, 127341, 127277, 8856, 10808, 9316, 9315, 9318, 9317, 9314, 9313, 9450, 9320, 9312, 9319, 127247, 8857, 8861, 12905, 12919, 12904, 12918, 12903, 12917, 12926, 12909, 12923, 12906, 12920, @@ -9997,528 +10221,562 @@ static const unsigned int dawg_pos_to_codepoint[] = { 128235, 128272, 128213, 10829, 8272, 9729, 127786, 127785, 127784, 127783, 129313, 9114, 129715, 127864, 129381, 58, 8788, 8353, 128165, 6867, 7625, 7623, 769, 791, 833, 8410, 8404, 8423, 857, 8432, 7677, 844, - 774, 7627, 814, 810, 838, 70459, 780, 812, 784, 8409, 8405, 787, 789, - 806, 65062, 65069, 42609, 1160, 11774, 11744, 11768, 11747, 11757, 11765, - 42654, 11751, 11752, 11753, 11756, 42613, 11775, 11772, 42655, 11767, - 11754, 42619, 11763, 11762, 42618, 42615, 42612, 42617, 11770, 42614, - 11771, 11773, 11769, 11759, 42616, 11760, 11758, 11748, 11749, 11761, - 11746, 11764, 11755, 11745, 11750, 11766, 42621, 1156, 1158, 1159, 1157, - 42608, 42610, 1155, 65070, 65071, 1161, 42620, 123023, 42607, 770, 813, - 807, 43248, 43244, 43245, 43246, 43247, 43242, 43243, 43249, 43237, + 774, 7627, 814, 810, 838, 70459, 780, 6892, 812, 784, 8409, 8405, 787, + 789, 806, 65062, 65069, 42609, 1160, 11774, 11744, 11768, 11747, 11757, + 11765, 42654, 11751, 11752, 11753, 11756, 42613, 11775, 11772, 42655, + 11767, 11754, 42619, 11763, 11762, 42618, 42615, 42612, 42617, 11770, + 42614, 11771, 11773, 11769, 11759, 42616, 11760, 11758, 11748, 11749, + 11761, 11746, 11764, 11755, 11745, 11750, 11766, 42621, 1156, 1158, 1159, + 1157, 42608, 42610, 1155, 65070, 65071, 1161, 42620, 123023, 42607, 770, + 813, 807, 43248, 43244, 43245, 43246, 43247, 43242, 43243, 43249, 43237, 43236, 43239, 43238, 43235, 43234, 43232, 43241, 43233, 43240, 7675, 776, - 804, 6876, 6833, 775, 7672, 856, 803, 7674, 6877, 7617, 7616, 6886, 6887, - 779, 861, 860, 865, 7676, 6863, 7629, 862, 863, 6840, 831, 6858, 6857, - 6844, 866, 6891, 858, 864, 65058, 65059, 8422, 840, 782, 783, 819, 6832, - 798, 6875, 6835, 8413, 8416, 8418, 8414, 8419, 8420, 8415, 839, 6888, - 850, 8412, 6874, 122892, 122884, 122891, 122890, 122921, 122919, 122889, - 122916, 122900, 122907, 122910, 122901, 122908, 122880, 122920, 122881, - 122909, 122903, 122922, 122883, 122895, 122894, 122896, 122898, 122899, - 122882, 122885, 122912, 122911, 122913, 122918, 122915, 122888, 122886, - 122904, 122902, 122897, 122893, 70508, 70507, 70506, 70505, 70504, 70502, - 70503, 70515, 70513, 70514, 70516, 70512, 768, 790, 832, 6865, 7624, - 7621, 847, 119363, 119362, 119364, 835, 834, 837, 836, 777, 843, 795, - 785, 815, 826, 6883, 811, 6855, 6834, 7632, 12442, 12441, 7671, 7670, - 7643, 7646, 7647, 7649, 7650, 867, 7666, 7655, 7636, 7637, 7638, 872, - 7639, 868, 7663, 7641, 7659, 7635, 869, 7640, 6860, 6861, 6862, 7645, - 7660, 7653, 870, 7667, 7661, 871, 7668, 7664, 876, 7651, 7626, 877, 6848, - 7652, 7658, 7656, 7657, 7665, 6847, 873, 7642, 874, 7644, 875, 7648, - 7662, 878, 879, 7654, 6889, 841, 794, 852, 7678, 8430, 8406, 6849, 6851, - 796, 849, 8400, 792, 6880, 845, 8417, 8429, 8426, 65056, 65063, 65057, - 65064, 6841, 8427, 824, 822, 8402, 818, 772, 65060, 65067, 65061, 65068, - 817, 6869, 7620, 6872, 7622, 7628, 800, 6882, 6854, 842, 66424, 66425, - 66423, 66426, 66422, 6839, 808, 7630, 773, 6846, 6845, 6843, 801, 799, - 6856, 8421, 788, 802, 7679, 854, 848, 853, 8431, 8407, 825, 855, 8401, - 6850, 6852, 793, 6881, 8428, 8408, 805, 778, 7631, 859, 823, 821, 8403, - 6873, 6853, 827, 6884, 6842, 7619, 7618, 828, 6885, 8411, 771, 65065, - 65066, 820, 816, 6859, 8424, 6836, 786, 797, 7669, 846, 6890, 7633, 7634, - 809, 781, 830, 6864, 6870, 6866, 6871, 6868, 7673, 8425, 6838, 6837, 851, - 829, 8274, 64, 44, 128476, 9092, 8705, 129517, 9732, 127882, 128533, - 128534, 128119, 128679, 8715, 8883, 8885, 8954, 8955, 8957, 8750, 127899, - 983187, 9089, 127978, 9010, 9740, 10861, 127859, 127850, 127834, 11505, - 11504, 11503, 11464, 11392, 11506, 11499, 11501, 11446, 11452, 11458, - 11466, 11442, 11448, 11450, 11398, 1006, 1002, 11396, 1000, 11406, 998, - 11436, 11412, 11420, 996, 11434, 11472, 11414, 11422, 11478, 11468, - 11470, 11476, 11474, 11482, 11460, 11480, 11454, 11462, 11444, 11486, - 11488, 11484, 11490, 11440, 1004, 994, 11456, 11402, 11428, 11408, 11430, - 11404, 11394, 11438, 11424, 11410, 11426, 11400, 11416, 11418, 11432, - 66298, 66289, 66295, 66286, 66294, 66285, 66299, 66290, 66291, 66297, - 66288, 66296, 66287, 66293, 66284, 66292, 66283, 66282, 66277, 66276, - 66279, 66278, 66275, 66274, 66281, 66273, 66280, 66272, 11517, 11518, - 11514, 11515, 11516, 11513, 11465, 11393, 11507, 11500, 11502, 11447, - 11453, 11459, 11467, 11443, 11449, 11451, 11399, 1007, 1003, 11397, 1001, - 11407, 999, 11437, 11413, 11421, 997, 11435, 11473, 11415, 11423, 11479, - 11469, 11471, 11477, 11475, 11483, 11461, 11481, 11455, 11463, 11445, - 11487, 11489, 11485, 11491, 11441, 1005, 995, 11457, 11403, 11429, 11409, - 11431, 11405, 11395, 11439, 11425, 11411, 11427, 11401, 11417, 11419, - 11433, 11497, 11492, 11493, 11494, 11498, 11495, 11496, 11519, 127279, - 169, 11855, 8792, 129720, 9012, 9013, 119661, 119660, 119663, 119662, - 119659, 119658, 119665, 119657, 119664, 119652, 119651, 119654, 119653, - 119650, 119649, 119656, 119648, 119655, 128715, 128145, 128004, 128046, - 9904, 129689, 129509, 983074, 128179, 127769, 129431, 127951, 9769, 9768, - 11856, 11857, 128322, 128321, 10060, 127370, 127884, 9876, 9932, 128010, - 129360, 128081, 8354, 129660, 128575, 128546, 128302, 129408, 8731, - 74794, 74771, 74861, 74780, 74820, 74821, 74765, 74758, 74853, 74856, - 74855, 74854, 74791, 74801, 74844, 74836, 74837, 74809, 74755, 74829, - 74777, 74786, 74768, 74858, 74762, 74834, 74835, 74808, 74812, 74814, - 74815, 74813, 74754, 74828, 74776, 74785, 74790, 74800, 74767, 74857, - 74761, 74839, 74838, 74822, 74825, 74823, 74824, 74795, 74772, 74862, - 74781, 74766, 74759, 74849, 74850, 74840, 74847, 74848, 74851, 74831, - 74804, 74773, 74782, 74845, 74842, 74796, 74852, 74818, 74819, 74817, - 74793, 74770, 74860, 74779, 74764, 74757, 74802, 74803, 74792, 74756, - 74830, 74769, 74859, 74778, 74816, 74763, 74806, 74807, 74833, 74788, - 74789, 74798, 74799, 74810, 74811, 74753, 74827, 74775, 74784, 74760, - 74752, 74826, 74832, 74805, 74841, 74774, 74783, 74787, 74797, 74846, - 74843, 74867, 74868, 74866, 74865, 74864, 73728, 73734, 73731, 73733, - 73735, 73736, 73730, 73732, 73729, 73738, 73742, 73741, 73744, 73745, - 74881, 73747, 73748, 73740, 73739, 74608, 74880, 73746, 73743, 73749, - 73750, 73753, 73752, 73754, 73755, 73751, 74609, 73756, 74882, 73757, - 73759, 73758, 73760, 73765, 73766, 73762, 73763, 73768, 73761, 73767, - 73764, 73770, 73769, 73771, 74610, 73772, 73773, 73776, 73777, 73775, - 73774, 73778, 73780, 73781, 73782, 73784, 73788, 73789, 73787, 73785, - 73786, 73791, 73790, 73783, 73779, 73737, 73792, 73793, 74883, 73795, - 74884, 74885, 74886, 73796, 73797, 73798, 73799, 73800, 73794, 73801, - 73804, 73803, 73802, 73805, 74887, 73806, 73807, 73808, 73809, 73810, - 73811, 73812, 73813, 73814, 73815, 73816, 73817, 73818, 73819, 73820, - 73821, 73822, 73823, 73825, 73826, 73829, 73830, 73831, 73828, 73836, - 74611, 73837, 73833, 73835, 73827, 73832, 73834, 73824, 74889, 74612, - 73839, 73840, 73841, 74888, 73838, 73842, 73844, 74891, 74890, 73845, - 73846, 74892, 73847, 73848, 73849, 74613, 73843, 73850, 73852, 73853, - 73851, 73854, 73855, 74614, 73856, 73857, 74894, 74895, 74893, 74896, - 74897, 74900, 74901, 74902, 74899, 74908, 74909, 74907, 74906, 74911, - 74912, 74910, 74913, 74914, 74915, 74916, 74920, 74919, 74898, 74905, - 74903, 74904, 74917, 74918, 73858, 73860, 73861, 73862, 73863, 73864, - 73865, 73859, 73866, 73868, 73867, 73869, 73873, 73874, 73870, 73871, - 74922, 74921, 73872, 73875, 73879, 73883, 73884, 73880, 73881, 73882, - 73885, 73887, 74923, 73886, 73888, 74924, 73889, 74927, 74930, 74931, - 74925, 74928, 74929, 74932, 74926, 73890, 73891, 73892, 73893, 73895, - 73896, 73900, 73901, 73902, 73903, 73904, 73905, 73906, 74616, 74933, - 73907, 73908, 73899, 73897, 73898, 74615, 73894, 73877, 73876, 73878, - 73909, 73911, 73912, 73914, 73913, 73916, 74617, 73917, 74618, 73918, - 73915, 74934, 73920, 73919, 73921, 73922, 73924, 73925, 74935, 74936, - 74937, 73926, 73923, 73929, 73930, 73927, 73928, 74938, 74939, 73932, - 74941, 74940, 73931, 73933, 73934, 73935, 73936, 73937, 74942, 73938, - 73939, 73941, 73940, 73943, 73942, 73945, 73944, 73946, 73947, 74943, - 73948, 73949, 74944, 74945, 74946, 73950, 74947, 73951, 74948, 74949, - 74950, 73952, 73953, 73957, 73958, 73959, 74951, 73955, 73956, 73960, - 73962, 73963, 73964, 73961, 74952, 73954, 73965, 73966, 74953, 73967, - 73968, 73969, 73970, 73971, 73972, 73974, 73975, 73978, 73977, 73976, - 73910, 73979, 73980, 73981, 73973, 73982, 73983, 74954, 74619, 73984, - 73985, 73986, 73987, 73988, 73990, 73989, 73994, 73995, 73998, 73996, - 73997, 73999, 73992, 73993, 74001, 74955, 74004, 74003, 74005, 74002, - 74000, 73991, 74620, 74006, 74008, 74009, 74010, 74956, 74012, 74011, - 74013, 74014, 74957, 74015, 74016, 74017, 74019, 74020, 74021, 74024, - 74023, 74022, 74007, 74018, 74025, 74026, 74958, 74027, 74028, 74029, - 74030, 74959, 74031, 74033, 74036, 74035, 74032, 74034, 74037, 74038, - 74039, 74040, 74043, 74044, 74042, 74041, 74045, 74046, 74621, 74047, - 74050, 74052, 74051, 74053, 74054, 74058, 74057, 74055, 74056, 74059, - 74060, 74061, 74062, 74064, 74065, 74063, 74066, 74067, 74048, 74070, - 74049, 74068, 74069, 74071, 74072, 74073, 74074, 74622, 74075, 74623, - 74077, 74076, 74078, 74079, 74960, 74080, 74081, 74082, 74085, 74086, - 74084, 74083, 74087, 74624, 74090, 74089, 74088, 74091, 74092, 74625, - 74093, 74094, 74096, 74097, 74961, 74095, 74099, 74627, 74098, 74100, - 74101, 74103, 74102, 74104, 74105, 74115, 74629, 74114, 74112, 74113, - 74110, 74111, 74117, 74116, 74118, 74630, 74119, 74962, 74963, 74631, - 74122, 74123, 74120, 74121, 74626, 74107, 74106, 74628, 74108, 74109, - 74124, 74125, 74126, 74131, 74132, 74128, 74129, 74130, 74133, 74134, - 74135, 74136, 74137, 983267, 74138, 74139, 74140, 74141, 74142, 74607, - 74127, 74144, 74146, 74147, 74145, 74152, 74153, 74150, 74151, 74148, - 74149, 74154, 74155, 74157, 74158, 74163, 74164, 74165, 74160, 74161, - 74156, 74159, 74162, 74143, 74166, 74167, 74168, 74169, 74170, 74171, - 74172, 74175, 74173, 74174, 74176, 74177, 74182, 74183, 74180, 74181, - 74632, 74186, 74184, 74185, 74188, 74190, 74189, 74187, 74194, 74195, - 74193, 74191, 74192, 74196, 74197, 74198, 74199, 74200, 74201, 74202, - 74205, 74206, 74207, 74208, 74204, 74209, 74211, 74210, 74212, 74213, - 74215, 74214, 74216, 74218, 74217, 74964, 74178, 74179, 74203, 74219, - 74220, 74223, 74224, 74221, 74222, 74966, 74967, 74974, 74973, 74972, - 74969, 74970, 74971, 74975, 74968, 74965, 74977, 74976, 74980, 74981, - 74982, 74984, 74985, 74978, 74979, 74983, 74986, 74987, 74988, 74989, - 74990, 74991, 74993, 74997, 74996, 74998, 74995, 74994, 74992, 74999, - 75000, 75003, 75004, 75005, 75006, 75001, 75002, 75009, 75015, 75016, - 75019, 75017, 75018, 75013, 75012, 75010, 75011, 75014, 75021, 75030, - 75029, 75027, 75024, 75025, 75028, 75022, 75026, 75023, 75008, 75020, - 75031, 75032, 75007, 74226, 74227, 74228, 74229, 74230, 74225, 74231, - 74233, 74234, 74232, 74235, 74237, 74258, 74259, 75033, 74261, 74633, - 74260, 74240, 74634, 74241, 74243, 75035, 74246, 74247, 74245, 74248, - 74249, 74250, 74251, 75036, 75037, 74254, 74255, 74635, 74256, 75038, - 74242, 74252, 74253, 75034, 74238, 74239, 74244, 74257, 74263, 74265, - 74264, 74266, 74269, 74270, 74271, 74236, 74262, 74267, 74268, 74272, - 74273, 74274, 74278, 74279, 74275, 74276, 74277, 74280, 74281, 74636, - 74282, 75039, 74283, 74284, 74290, 74294, 74295, 75041, 75040, 74292, - 74293, 74291, 74296, 74297, 74298, 74299, 74300, 74637, 74301, 74286, - 74287, 74285, 74289, 74288, 74302, 74304, 74307, 74305, 74306, 74308, - 74310, 74309, 74311, 74303, 74638, 74312, 74314, 74313, 74315, 74316, - 74319, 74321, 74320, 74639, 74322, 74324, 74325, 74323, 74642, 75043, - 74326, 75044, 75046, 75047, 74327, 75048, 74329, 74328, 75049, 74330, - 74332, 74333, 74331, 75050, 75051, 74334, 75052, 74335, 75042, 74641, - 75045, 74640, 74317, 74336, 74318, 74337, 74338, 983266, 983265, 74643, - 74339, 74347, 74348, 74342, 74343, 74341, 74344, 74340, 74346, 74345, - 74349, 74355, 74354, 74350, 74352, 74358, 74359, 74353, 74357, 74351, - 74356, 74360, 74361, 74362, 74363, 74364, 74365, 74366, 74644, 74367, - 74375, 74376, 74368, 74369, 74373, 74374, 74370, 74371, 74372, 74377, - 74378, 74379, 74380, 74381, 74382, 74645, 74383, 74384, 74385, 74386, - 74387, 74389, 74408, 75053, 74388, 74646, 74395, 74394, 75055, 74400, - 74399, 75056, 74401, 74406, 74402, 74403, 74404, 74405, 74391, 74392, - 74396, 74398, 75054, 74397, 74393, 74390, 74407, 74409, 74410, 74411, - 74412, 74413, 74414, 74421, 74422, 74419, 74417, 74420, 74416, 74418, - 74415, 74423, 75057, 74424, 74425, 74426, 75058, 74428, 74429, 75059, - 75060, 75061, 74427, 74432, 74434, 74433, 74430, 74431, 74435, 74437, - 74436, 74438, 74441, 74440, 74444, 74445, 74446, 74448, 74447, 74443, - 74449, 74442, 74439, 74451, 74453, 74452, 74450, 74454, 74455, 74456, - 74457, 75063, 75062, 74458, 74459, 75064, 74460, 74461, 74462, 74463, - 74465, 74464, 74466, 74468, 74469, 74471, 74472, 74473, 74474, 74467, - 74470, 74475, 74477, 74478, 74479, 74476, 74480, 74481, 74482, 74483, - 74488, 74486, 74487, 74485, 74489, 74484, 74490, 75065, 74491, 74494, - 74497, 74499, 74500, 74498, 74495, 74647, 74496, 74501, 74504, 75066, - 75067, 74505, 74506, 74502, 74503, 74492, 74493, 74507, 74510, 74512, - 74511, 74649, 74509, 74508, 74515, 74516, 74522, 74523, 74519, 74520, - 74517, 74518, 74521, 74524, 74534, 74535, 74525, 74526, 74648, 74527, - 74528, 74529, 74531, 74532, 74533, 74530, 74536, 74538, 74537, 74539, - 75068, 74540, 74541, 74542, 74545, 74546, 74547, 75069, 74544, 74543, - 74549, 74550, 74551, 74552, 74553, 75070, 74555, 74556, 74558, 74557, - 74559, 74560, 74562, 74564, 74563, 75072, 74566, 75071, 74570, 74569, - 74572, 74574, 74573, 74554, 74567, 74571, 74565, 74561, 74568, 74575, - 74576, 74548, 74577, 74581, 74579, 74580, 74578, 74584, 74583, 74582, - 74586, 74587, 74588, 74585, 74513, 74514, 74589, 74591, 74590, 74593, - 75073, 74592, 74595, 74598, 74599, 74596, 74601, 74597, 74600, 74602, - 75074, 74603, 75075, 74604, 74605, 74606, 74594, 9982, 129380, 11232, - 129473, 8911, 8910, 10160, 9130, 129356, 128177, 164, 127835, 10081, - 128707, 127854, 129362, 129385, 67594, 67595, 67596, 67597, 67598, 67599, - 67600, 67601, 67602, 67603, 67604, 67605, 67606, 67607, 67608, 67609, - 67610, 67611, 67612, 67613, 67614, 67615, 67616, 67617, 67618, 67619, - 67620, 67621, 67622, 67623, 67624, 67625, 67626, 67627, 67628, 67629, - 67630, 67631, 67632, 67633, 67634, 67635, 67636, 67637, 67589, 67592, - 67644, 67647, 67639, 67640, 67584, 67585, 67586, 67587, 67588, 77712, - 77713, 77714, 77715, 77716, 77717, 77718, 77719, 77722, 77723, 77720, - 77721, 77724, 77725, 77726, 77727, 77728, 77729, 77730, 77731, 77732, - 77733, 77734, 77735, 77736, 77737, 77738, 77739, 77740, 77741, 77742, - 77743, 77744, 77745, 77746, 77747, 77748, 77749, 77750, 77751, 77752, - 77753, 77754, 77755, 77756, 77757, 77758, 77773, 77774, 77768, 77769, - 77770, 77771, 77772, 77775, 77776, 77777, 77788, 77789, 77790, 77791, - 77792, 77793, 77794, 77795, 77796, 77759, 77760, 77761, 77762, 77763, - 77764, 77765, 77766, 77767, 77778, 77779, 77780, 77781, 77782, 77783, - 77784, 77785, 77786, 77787, 77797, 77798, 77799, 77800, 77801, 77802, - 77803, 77804, 77805, 77806, 77807, 77808, 77809, 77810, 1126, 1033, 1300, - 42574, 1034, 1055, 1190, 1316, 1136, 1146, 42564, 42592, 42580, 1296, - 1302, 1058, 42634, 1196, 1035, 42640, 42638, 1062, 42642, 7305, 42636, - 1059, 1266, 1264, 1262, 1144, 1028, 1040, 1234, 1232, 1212, 1214, 1248, - 1192, 1310, 1256, 1258, 1184, 42602, 1130, 42572, 42586, 1030, 1041, - 1063, 1268, 1206, 1208, 42584, 42650, 42630, 1026, 42568, 42604, 42648, - 1029, 42562, 1322, 42632, 1039, 42626, 1324, 42624, 1044, 1069, 1051, - 1312, 1326, 1221, 1298, 1053, 1314, 1186, 1320, 1225, 1223, 1056, 1166, - 1260, 1057, 1194, 1052, 1229, 1060, 1043, 1172, 1168, 1270, 1170, 1274, - 1027, 1061, 1202, 1276, 1278, 1066, 42644, 1048, 1252, 1037, 1250, 1045, - 1024, 1238, 1025, 42588, 1128, 1132, 42578, 42582, 1124, 42566, 1140, - 1142, 1050, 1178, 1219, 1180, 1182, 1286, 1282, 1280, 1288, 1290, 1292, - 1294, 1284, 1152, 1227, 1036, 1134, 42600, 42570, 1054, 1120, 1148, 1254, - 1150, 1240, 1242, 1049, 1162, 1038, 1210, 1318, 1065, 42646, 1064, 42596, - 42598, 1068, 42594, 1198, 1200, 1164, 1071, 1304, 1122, 1067, 1272, - 42576, 1031, 42590, 1070, 1047, 1246, 1176, 42560, 1046, 1244, 1174, - 1217, 42628, 1138, 1032, 1042, 1308, 1306, 1236, 1204, 1188, 42622, - 42606, 1216, 7467, 42623, 1072, 1235, 1233, 1213, 1215, 1249, 1193, 1311, - 1257, 1259, 1185, 42603, 1131, 42573, 42587, 1110, 1073, 1095, 1269, - 1207, 1209, 42585, 42651, 42631, 1106, 42569, 42605, 42649, 1109, 42563, - 1323, 42633, 1119, 42627, 1325, 42625, 1076, 1101, 1083, 1313, 1327, - 1222, 1299, 1085, 1315, 1187, 1321, 1226, 1224, 1088, 1167, 1261, 1089, - 1195, 1084, 1230, 1092, 1075, 1173, 1169, 1271, 1171, 1275, 1107, 1093, - 1203, 1277, 1279, 1098, 42645, 1080, 1253, 1117, 1251, 1077, 1104, 1239, - 1105, 42589, 1129, 1133, 42579, 42583, 1125, 42567, 1141, 1143, 1082, - 1179, 1220, 1181, 1183, 1287, 1283, 1281, 1289, 1291, 1293, 1295, 1285, - 1153, 1228, 1116, 1135, 1127, 7297, 1113, 1301, 42601, 42571, 42575, - 7298, 1114, 1086, 1121, 1149, 1255, 1151, 1087, 1191, 1317, 1231, 1137, - 42565, 42593, 42581, 1297, 1147, 7296, 1303, 1241, 1243, 1081, 1163, - 1118, 1211, 1319, 1097, 42647, 1096, 42597, 42599, 1100, 42595, 1199, - 1201, 1165, 7302, 7303, 7300, 1090, 42635, 1197, 1115, 42641, 42639, - 1094, 7301, 42643, 7306, 42637, 1091, 1267, 1265, 1263, 1145, 1108, 7304, - 7299, 1309, 1103, 1305, 1123, 1099, 1273, 42577, 1111, 42591, 1102, 1079, - 1247, 1177, 42561, 1078, 1245, 1175, 1218, 42629, 1139, 1112, 1074, 1307, - 1237, 1205, 1189, 122984, 122962, 122986, 122985, 122965, 122976, 122971, - 122974, 122964, 122983, 122977, 122981, 122982, 122980, 122978, 122967, - 122968, 122969, 122966, 122979, 122973, 122963, 122970, 122961, 122972, - 122975, 1154, 9005, 127744, 983201, 983188, 983172, 8224, 11830, 11831, - 128481, 128131, 127841, 128374, 9619, 11843, 128168, 10143, 65101, 65097, - 8504, 983081, 983084, 983086, 983088, 983090, 983162, 9110, 9192, 127795, - 128475, 8451, 176, 8457, 983120, 128666, 8796, 983119, 9161, 9159, 9153, - 9156, 9162, 9160, 9154, 9157, 9164, 9151, 9163, 9150, 9158, 9152, 9155, - 117829, 117828, 127980, 127962, 9739, 66589, 66591, 66596, 66597, 66587, - 66585, 66594, 66595, 66593, 66599, 66562, 66563, 66564, 66565, 66561, - 66560, 66568, 66569, 66570, 66571, 66567, 66566, 66598, 66573, 66588, - 66579, 66592, 66590, 66581, 66578, 66580, 66582, 66577, 66586, 66575, - 66584, 66583, 66574, 66572, 66576, 66629, 66631, 66636, 66637, 66627, - 66625, 66634, 66635, 66633, 66639, 66602, 66603, 66604, 66605, 66601, - 66600, 66608, 66609, 66610, 66611, 66607, 66606, 66638, 66613, 66628, - 66619, 66632, 66630, 66621, 66618, 66620, 66622, 66617, 66626, 66615, - 66624, 66623, 66614, 66612, 66616, 127964, 127965, 128421, 128468, 2388, - 2416, 43258, 2387, 43257, 72448, 72449, 43259, 2309, 2310, 2320, 2324, - 2421, 43262, 2330, 2418, 2317, 2321, 2331, 2396, 2430, 2338, 2337, 2343, - 2342, 2429, 2394, 2328, 2427, 2327, 2426, 2361, 2350, 2424, 2308, 2318, - 2322, 2358, 2359, 2360, 2431, 2349, 2348, 2393, 2326, 2325, 2397, 2353, - 2352, 2323, 2420, 2419, 2399, 2351, 2313, 2314, 2423, 2422, 2345, 2339, - 2329, 2334, 2344, 2333, 2428, 2332, 2356, 2355, 2354, 2336, 2335, 2341, - 2340, 2315, 2400, 2316, 2401, 2357, 2311, 2312, 2347, 2346, 2425, 2395, - 2398, 2392, 2319, 983644, 983643, 983646, 983647, 983649, 983648, 983642, - 983645, 72450, 72451, 72452, 72453, 2305, 43255, 43251, 43254, 43253, - 72455, 72454, 72456, 43250, 43260, 2304, 72457, 2364, 2365, 2306, 43252, - 43256, 2417, 2381, 2307, 2386, 2385, 2366, 2376, 2380, 2383, 43263, 2389, - 2373, 2377, 2379, 2363, 2362, 2382, 2369, 2370, 2391, 2390, 2374, 2378, - 2371, 2372, 2402, 2403, 2367, 2368, 2375, 2405, 2404, 2411, 2410, 2413, - 2412, 2409, 2408, 2406, 2415, 2407, 2414, 43261, 2384, 983089, 983161, - 983087, 983085, 983083, 129487, 129420, 11033, 11032, 11030, 11031, - 128924, 128160, 8900, 8960, 168, 117827, 9856, 9857, 9858, 9859, 9860, - 9861, 128754, 53, 127238, 9356, 52, 127237, 9355, 57, 127242, 9360, 49, - 127234, 9352, 55, 127240, 9358, 54, 127239, 9357, 51, 127236, 9354, 50, - 127235, 9353, 48, 127233, 127232, 56, 127241, 9359, 119557, 119556, - 119555, 9868, 9871, 9870, 9869, 119553, 119554, 10131, 10126, 10125, - 10128, 10127, 10124, 10123, 127244, 10130, 10122, 10129, 10111, 10106, - 10105, 10108, 10107, 10104, 10103, 10110, 10102, 10109, 10121, 10116, - 10115, 10118, 10117, 10114, 10113, 127243, 10120, 10112, 10119, 9107, - 127919, 128549, 128542, 9933, 9090, 129770, 129400, 72004, 72021, 72020, - 72023, 72022, 72019, 72018, 72016, 72025, 72017, 72024, 71964, 71958, - 71963, 71974, 71973, 71936, 71937, 71961, 71960, 71966, 71965, 71940, - 71941, 71938, 71939, 71982, 71976, 71952, 71962, 71957, 71967, 71978, - 71979, 71980, 71971, 71970, 71954, 71953, 71951, 71950, 71949, 71948, - 71969, 71968, 71981, 71955, 71972, 71975, 71977, 71983, 71942, 71945, - 71997, 71996, 72003, 71995, 71984, 71991, 71987, 71988, 71985, 71986, - 71989, 71992, 71998, 72002, 72000, 72005, 72006, 71999, 72001, 8725, 247, - 8903, 129343, 8739, 9902, 129684, 128171, 128565, 12291, 8783, 9009, - 128462, 128441, 128442, 128443, 8939, 8941, 8716, 8740, 10990, 8832, - 8928, 8876, 8833, 8929, 8878, 128021, 71680, 71681, 71687, 71689, 71703, - 71702, 71708, 71707, 71723, 71716, 71701, 71700, 71706, 71705, 71684, - 71685, 71682, 71683, 71694, 71704, 71699, 71709, 71719, 71720, 71721, - 71713, 71712, 71696, 71695, 71693, 71692, 71698, 71697, 71691, 71690, - 71711, 71710, 71722, 71717, 71714, 71718, 71715, 71686, 71688, 71729, - 71730, 71724, 71732, 71734, 71727, 71728, 71725, 71726, 71731, 71733, - 71739, 71738, 71735, 71737, 71736, 128054, 128044, 36, 127025, 127026, - 127027, 127028, 127029, 127030, 127031, 127032, 127033, 127034, 127035, - 127036, 127037, 127038, 127039, 127040, 127041, 127042, 127043, 127044, - 127045, 127046, 127047, 127048, 127049, 127050, 127051, 127052, 127053, - 127054, 127055, 127056, 127057, 127058, 127059, 127060, 127061, 127062, - 127063, 127064, 127065, 127066, 127067, 127068, 127069, 127070, 127071, - 127072, 127073, 127024, 127075, 127076, 127077, 127078, 127079, 127080, - 127081, 127082, 127083, 127084, 127085, 127086, 127087, 127088, 127089, - 127090, 127091, 127092, 127093, 127094, 127095, 127096, 127097, 127098, - 127099, 127100, 127101, 127102, 127103, 127104, 127105, 127106, 127107, - 127108, 127109, 127110, 127111, 127112, 127113, 127114, 127115, 127116, - 127117, 127118, 127119, 127120, 127121, 127122, 127123, 127074, 129743, - 8363, 8724, 8760, 8901, 729, 9676, 8284, 11850, 11034, 129765, 11795, - 11784, 10649, 11798, 9470, 9465, 9464, 9467, 9466, 9463, 9462, 9469, - 9461, 9468, 10175, 10868, 10986, 8225, 8223, 11840, 8914, 8748, 11842, - 8222, 8215, 10835, 10836, 10645, 10913, 10915, 10914, 10939, 8243, 12318, - 10746, 10830, 10831, 11849, 10988, 11844, 10940, 8913, 8912, 11005, - 10987, 8915, 9208, 10981, 8875, 10979, 8214, 11799, 10646, 733, 8252, - 8263, 65100, 10908, 10907, 11002, 11001, 10906, 10905, 8510, 8473, 8511, - 8450, 8461, 8469, 8474, 8477, 8484, 8518, 8519, 8520, 8521, 8517, 8509, - 8508, 8512, 10719, 9890, 9891, 11260, 127849, 8868, 10993, 10623, 8945, - 8964, 117764, 128317, 117859, 118264, 117883, 118268, 117849, 128315, - 117914, 117864, 10728, 10729, 117875, 117879, 129288, 129290, 129289, - 129291, 8595, 8629, 8671, 129035, 129031, 129179, 129043, 129027, 129047, - 8626, 8627, 10504, 8693, 129975, 8615, 10515, 11796, 11015, 129203, - 11147, 11107, 11139, 11123, 129067, 11168, 11169, 129063, 129059, 129075, - 129071, 11133, 11085, 11117, 11143, 129171, 10507, 8609, 11247, 8681, - 129175, 8623, 8659, 8675, 129079, 10597, 10607, 10593, 10585, 8643, - 10589, 10581, 8642, 129091, 129095, 129087, 10225, 128623, 129107, - 129083, 8650, 128687, 128330, 128682, 129444, 8367, 10139, 128009, - 128050, 128042, 129656, 128167, 129316, 129345, 9946, 128087, 113784, - 113788, 113785, 113783, 113782, 113786, 113787, 113795, 113798, 113793, - 113800, 113781, 113794, 113792, 113799, 113797, 113796, 113776, 113808, - 113817, 113811, 113814, 113809, 113816, 113779, 113810, 113815, 113813, - 113812, 113778, 113777, 113780, 113729, 113733, 113672, 113677, 113683, - 113735, 113739, 113746, 113668, 113678, 113674, 113726, 113691, 113699, - 113700, 113695, 113709, 113712, 113713, 113705, 113711, 113669, 113725, - 113679, 113684, 113670, 113743, 113749, 113687, 113689, 113693, 113707, - 113697, 113703, 113690, 113694, 113708, 113698, 113704, 113764, 113763, - 113762, 113761, 113732, 113753, 113731, 113755, 113754, 113666, 113766, - 113765, 113676, 113675, 113741, 113750, 113680, 113688, 113692, 113696, - 113710, 113727, 113728, 113716, 113717, 113714, 113715, 113701, 113702, - 113724, 113723, 113706, 113742, 113740, 113767, 113769, 113730, 113768, - 113682, 113685, 113752, 113737, 113667, 113719, 113718, 113681, 113745, - 113748, 113751, 113738, 113673, 113770, 113720, 113757, 113760, 113722, - 113759, 113756, 113721, 113758, 113665, 113747, 113664, 113686, 113734, - 113736, 113744, 113671, 113821, 113822, 113823, 113820, 129375, 129414, - 129516, 128192, 983082, 128066, 127805, 127806, 129467, 9793, 127758, - 127759, 127757, 9178, 9841, 129413, 11790, 77830, 77831, 77832, 77828, - 77829, 77824, 77825, 77826, 77827, 77833, 77834, 77835, 77840, 77841, - 77844, 77845, 77836, 77837, 77838, 77839, 77842, 77843, 77846, 77847, - 77869, 77870, 77872, 77873, 77874, 77875, 77877, 77878, 77871, 77876, - 77879, 77880, 77881, 77882, 77860, 77861, 77858, 77859, 77862, 77863, - 77864, 77865, 77866, 77867, 77868, 77903, 77848, 77849, 77850, 77851, - 77852, 77853, 77854, 77855, 77856, 77857, 77883, 77884, 77885, 77886, - 77887, 77888, 77889, 77890, 77891, 77892, 77893, 77894, 77895, 77896, - 77897, 77898, 77899, 77900, 77901, 77902, 78867, 78868, 78869, 78861, - 78862, 78863, 78864, 78865, 78866, 78870, 78871, 78892, 78893, 78894, - 78872, 78873, 78874, 78875, 78876, 78877, 78878, 78879, 78880, 78881, - 78882, 78883, 78884, 78885, 78886, 78887, 78888, 78889, 78890, 78891, - 78910, 78908, 78903, 77908, 77909, 77904, 77905, 77906, 77907, 77910, - 77911, 77912, 77913, 77915, 77916, 77917, 77918, 77914, 77919, 77920, - 77921, 77922, 77923, 77924, 77925, 77926, 77927, 77928, 77929, 77930, - 77931, 77932, 77933, 77934, 77935, 77936, 77937, 77938, 77939, 77940, - 77941, 77949, 77950, 77942, 77943, 77944, 77945, 77946, 77947, 77948, - 77951, 77974, 77975, 77978, 77979, 77973, 77976, 77977, 77980, 77981, - 77982, 77983, 77984, 77991, 77992, 77994, 77995, 77985, 77986, 77987, - 77988, 77989, 77990, 77993, 77996, 77997, 77998, 77999, 78000, 78001, - 78002, 78003, 78004, 78005, 78006, 78008, 78009, 78011, 78012, 78007, - 78010, 78013, 78014, 78015, 78016, 78017, 78025, 78026, 78027, 78028, - 78029, 78030, 78031, 78032, 78033, 78018, 78019, 78020, 78021, 78022, - 78023, 78024, 77969, 77970, 77962, 77963, 77964, 77965, 77966, 77967, - 77968, 77971, 77972, 77952, 77953, 77954, 77955, 77956, 77957, 77958, - 77959, 77960, 77961, 78041, 78042, 78043, 78044, 78034, 78035, 78036, - 78037, 78038, 78039, 78040, 78057, 78058, 78066, 78067, 78059, 78060, - 78061, 78062, 78063, 78064, 78065, 78068, 78073, 78074, 78069, 78070, - 78071, 78072, 78075, 78076, 78077, 78051, 78052, 78053, 78054, 78045, - 78046, 78047, 78048, 78049, 78050, 78055, 78056, 78911, 78909, 78904, - 78078, 78079, 78080, 78081, 78082, 78083, 78084, 78085, 78086, 78087, - 78091, 78092, 78088, 78089, 78090, 78093, 78094, 78095, 78096, 78097, - 78098, 78111, 78112, 78118, 78119, 78120, 78121, 78110, 78113, 78114, - 78115, 78116, 78117, 78122, 78128, 78129, 78130, 78131, 78132, 78133, - 78123, 78124, 78125, 78126, 78127, 78134, 78135, 78137, 78138, 78139, - 78140, 78136, 78141, 78142, 78100, 78101, 78099, 78102, 78103, 78104, - 78105, 78106, 78107, 78108, 78109, 78913, 78150, 78151, 78152, 78148, - 78149, 78143, 78144, 78145, 78146, 78147, 78153, 78154, 78156, 78157, - 78155, 78158, 78159, 78160, 78161, 78162, 78163, 78164, 78165, 78184, - 78185, 78186, 78187, 78178, 78179, 78180, 78181, 78182, 78183, 78188, - 78189, 78193, 78194, 78196, 78197, 78190, 78191, 78192, 78195, 78198, - 78199, 78200, 78201, 78166, 78167, 78173, 78174, 78168, 78169, 78170, - 78171, 78172, 78175, 78176, 78177, 78202, 78203, 78204, 78205, 78206, - 78212, 78213, 78207, 78208, 78209, 78210, 78211, 78214, 78215, 78914, - 78916, 78897, 78220, 78221, 78225, 78226, 78216, 78217, 78218, 78219, - 78222, 78223, 78224, 78227, 78228, 78229, 78230, 78231, 78232, 78233, - 78234, 78907, 78901, 78899, 78906, 78900, 78898, 78905, 78244, 78245, - 78249, 78250, 78243, 78246, 78247, 78248, 78251, 78252, 78915, 78253, - 78254, 78255, 78257, 78258, 78256, 78259, 78260, 78261, 78262, 78263, - 78264, 78268, 78269, 78270, 78271, 78272, 78273, 78274, 78275, 78276, - 78265, 78266, 78279, 78280, 78281, 78282, 78283, 78284, 78267, 78277, - 78278, 78285, 78286, 78289, 78290, 78292, 78293, 78297, 78298, 78287, - 78288, 78291, 78294, 78295, 78296, 78299, 78304, 78305, 78306, 78301, - 78302, 78300, 78303, 78307, 78308, 78309, 78310, 78311, 78312, 78313, - 78314, 78315, 78316, 78317, 78318, 78933, 78928, 78920, 78924, 78932, - 78926, 78921, 78929, 78925, 78923, 78931, 78919, 78927, 78922, 78930, - 78912, 78336, 78337, 78338, 78328, 78329, 78330, 78331, 78332, 78333, - 78334, 78335, 78339, 78354, 78355, 78356, 78357, 78358, 78359, 78361, - 78362, 78351, 78352, 78353, 78360, 78363, 78364, 78345, 78346, 78340, - 78341, 78342, 78343, 78344, 78347, 78348, 78349, 78350, 78365, 78366, - 78367, 78319, 78320, 78321, 78322, 78323, 78324, 78325, 78326, 78327, - 78372, 78373, 78368, 78369, 78370, 78371, 78374, 78375, 78376, 78377, - 78385, 78386, 78378, 78379, 78380, 78381, 78382, 78383, 78384, 78387, - 78388, 78389, 78399, 78400, 78401, 78402, 78409, 78410, 78403, 78404, - 78405, 78406, 78407, 78408, 78411, 78414, 78415, 78412, 78413, 78390, - 78391, 78392, 78393, 78394, 78395, 78396, 78397, 78398, 78423, 78424, - 78425, 78426, 78427, 78428, 78429, 78416, 78417, 78421, 78422, 78418, - 78419, 78420, 78430, 78431, 78432, 78433, 78434, 78435, 78436, 78445, - 78446, 78437, 78438, 78439, 78440, 78441, 78442, 78443, 78444, 78447, - 78448, 78452, 78453, 78454, 78455, 78459, 78460, 78449, 78450, 78451, - 78456, 78457, 78458, 78469, 78470, 78471, 78472, 78473, 78461, 78462, - 78465, 78466, 78463, 78464, 78467, 78468, 78474, 78475, 78476, 78487, - 78488, 78489, 78490, 78477, 78478, 78479, 78480, 78481, 78482, 78483, - 78484, 78485, 78486, 78902, 78491, 78492, 78494, 78495, 78493, 78496, - 78497, 78498, 78499, 78500, 78501, 78502, 78503, 78514, 78515, 78516, - 78512, 78513, 78511, 78517, 78518, 78519, 78520, 78521, 78522, 78523, - 78524, 78530, 78531, 78525, 78526, 78527, 78528, 78529, 78532, 78533, - 78534, 78535, 78536, 78537, 78538, 78539, 78540, 78541, 78542, 78543, - 78544, 78546, 78547, 78551, 78552, 78545, 78548, 78549, 78550, 78553, - 78554, 78555, 78560, 78561, 78562, 78565, 78566, 78556, 78557, 78558, - 78559, 78563, 78564, 78567, 78568, 78575, 78576, 78577, 78569, 78570, - 78571, 78572, 78573, 78574, 78578, 78579, 78580, 78586, 78587, 78581, - 78582, 78583, 78584, 78585, 78588, 78589, 78590, 78591, 78592, 78593, - 78594, 78595, 78596, 78597, 78598, 78601, 78602, 78606, 78607, 78608, - 78609, 78610, 78611, 78599, 78600, 78603, 78604, 78605, 78613, 78614, - 78619, 78620, 78612, 78615, 78616, 78617, 78618, 78621, 78622, 78623, - 78636, 78637, 78638, 78639, 78634, 78635, 78640, 78641, 78642, 78624, - 78625, 78626, 78627, 78628, 78629, 78630, 78631, 78632, 78633, 78917, - 78648, 78649, 78650, 78643, 78644, 78645, 78646, 78647, 78651, 78652, - 78653, 78667, 78668, 78674, 78675, 78664, 78665, 78666, 78669, 78670, - 78671, 78672, 78673, 78678, 78679, 78676, 78677, 78680, 78681, 78682, - 78683, 78684, 78685, 78686, 78687, 78688, 78689, 78654, 78655, 78656, - 78657, 78658, 78659, 78660, 78661, 78662, 78663, 78706, 78707, 78708, - 78690, 78691, 78692, 78693, 78694, 78695, 78696, 78697, 78698, 78699, - 78700, 78701, 78702, 78703, 78704, 78705, 78709, 78710, 78712, 78713, - 78714, 78715, 78895, 78716, 78717, 78718, 78711, 78719, 78720, 78721, - 78722, 78723, 78724, 78725, 78726, 78727, 78728, 78729, 78730, 78731, - 78732, 78733, 78734, 78735, 78736, 78737, 78738, 78741, 78742, 78747, - 78748, 78749, 78750, 78739, 78740, 78743, 78744, 78745, 78746, 78751, - 78752, 78753, 78754, 78756, 78757, 78761, 78762, 78755, 78758, 78759, - 78760, 78763, 78764, 78765, 78766, 78896, 78769, 78770, 78776, 78777, - 78767, 78768, 78771, 78772, 78773, 78774, 78775, 78778, 78779, 78783, - 78784, 78787, 78788, 78789, 78790, 78780, 78781, 78782, 78785, 78786, - 78791, 78796, 78797, 78792, 78793, 78794, 78795, 78798, 78918, 78802, - 78803, 78804, 78806, 78807, 78809, 78810, 78799, 78800, 78801, 78805, - 78808, 78811, 78812, 78813, 78814, 78815, 78816, 78817, 78818, 78819, - 78821, 78822, 78823, 78824, 78825, 78826, 78827, 78828, 78829, 78830, - 78831, 78832, 78820, 78833, 78834, 78835, 78836, 78842, 78843, 78844, - 78845, 78846, 78847, 78848, 78849, 78850, 78851, 78852, 78853, 78854, - 78855, 78856, 78857, 78858, 78859, 78860, 78837, 78838, 78839, 78840, - 78841, 78235, 78236, 78237, 78238, 78239, 78240, 78241, 78242, 78504, - 78505, 78506, 78507, 78508, 78509, 78510, 118470, 129370, 10037, 10039, - 10036, 10049, 117865, 117866, 10058, 10035, 9834, 66854, 66853, 66827, - 66826, 66833, 66832, 66821, 66837, 66836, 66835, 66842, 66841, 66824, - 66823, 66819, 66818, 66822, 66820, 66855, 66831, 66844, 66843, 66846, - 66845, 66852, 66851, 66817, 66825, 66828, 66830, 66834, 66839, 66840, - 66848, 66849, 66816, 66829, 66838, 66847, 66850, 128268, 128294, 128161, - 8961, 9191, 8712, 8946, 8953, 8947, 8952, 8950, 8949, 10969, 10194, - 128024, 128727, 69608, 69621, 69603, 69611, 69618, 69619, 69600, 69615, - 69602, 69606, 69614, 69617, 69620, 69609, 69604, 69607, 69610, 69601, - 69613, 69605, 69616, 69612, 69622, 129501, 983101, 129456, 129457, - 129459, 129458, 127995, 127996, 127997, 127998, 127999, 128453, 128454, - 128455, 129721, 128460, 128461, 8709, 10675, 10676, 10674, 10673, 128459, - 9091, 8193, 8212, 8195, 8192, 8211, 8194, 983179, 8718, 983178, 983135, - 983099, 983048, 983095, 983046, 983064, 128282, 983051, 983050, 9993, - 128388, 128233, 9094, 983067, 983100, 983049, 8926, 8927, 8925, 8924, - 8797, 8917, 61, 10865, 10867, 11072, 10609, 10723, 10724, 10926, 11257, - 11158, 10871, 10854, 10862, 8789, 10872, 8781, 8794, 10738, 10736, 10734, - 10739, 10737, 10735, 11249, 11248, 9003, 8998, 983105, 983104, 8494, - 8793, 983136, 4957, 4959, 4958, 4963, 4965, 4978, 4988, 4980, 4979, 4987, - 4985, 4982, 4981, 4986, 4984, 4983, 4968, 4966, 4964, 4960, 4999, 4998, - 4711, 4997, 43816, 43819, 43821, 43820, 43818, 43822, 43817, 4704, 4707, - 4710, 11653, 4709, 4708, 4706, 4705, 43808, 43811, 43813, 43812, 43810, - 43814, 43809, 11704, 11707, 11709, 11708, 11706, 11710, 11705, 11688, - 11691, 11693, 11692, 11690, 11694, 11689, 4904, 4907, 4910, 11664, 4909, - 4908, 4911, 4906, 4905, 4728, 4731, 4734, 11655, 4733, 4732, 4735, 4730, - 4729, 43789, 43788, 43787, 43786, 43790, 43785, 4856, 4859, 4862, 11661, - 4861, 4860, 4863, 4858, 4857, 43797, 43796, 43795, 43794, 43798, 43793, - 4848, 4851, 4854, 11660, 4853, 4852, 4855, 4850, 4849, 5003, 5002, 4943, - 5001, 4936, 4939, 4941, 4940, 4954, 4938, 4942, 4937, 4873, 124916, - 124915, 124924, 124923, 124910, 124909, 124926, 124925, 124922, 124921, - 124920, 124919, 124918, 124917, 124914, 124913, 124912, 124904, 11667, - 4895, 11670, 11669, 11668, 4888, 4891, 4893, 4892, 4890, 4894, 4889, - 4768, 4771, 4774, 11658, 4773, 4772, 4775, 4770, 4769, 4880, 4883, 4885, - 4884, 4882, 11736, 11739, 11741, 11740, 11738, 11742, 11737, 4872, 4875, - 4878, 4879, 4877, 4876, 4874, 124907, 124906, 4631, 124905, 124896, - 124899, 124901, 124900, 124898, 124902, 124897, 4624, 4627, 4629, 4628, - 4626, 4630, 4625, 4608, 4611, 4614, 4615, 4613, 4612, 4610, 4609, 4800, - 4803, 4805, 4804, 4802, 4792, 4795, 4797, 4796, 4794, 4798, 4793, 4784, - 4787, 4789, 4788, 4786, 11720, 11723, 11725, 11724, 11722, 11726, 11721, - 4776, 4779, 4782, 4783, 4781, 4780, 4778, 4777, 4995, 4994, 4639, 4993, - 4632, 4635, 4638, 11649, 4637, 4636, 4953, 4634, 4633, 4760, 4763, 4766, - 11657, 4765, 4764, 4767, 4762, 4761, 4752, 4755, 4758, 11656, 4757, 4756, - 4759, 4754, 4753, 4912, 4816, 4819, 4821, 4820, 4818, 4822, 4817, 4915, - 4918, 11665, 4917, 4916, 4919, 4914, 4913, 5007, 5006, 4951, 5005, 4944, - 4947, 4950, 11666, 4949, 4948, 4946, 4945, 4696, 4699, 4701, 4700, 4698, - 4688, 4691, 4693, 4692, 4690, 4694, 4689, 4680, 4683, 4685, 4684, 4682, - 11712, 11715, 11717, 11716, 11714, 11718, 11713, 4672, 4675, 4678, 4679, - 4677, 4676, 4674, 4673, 4648, 4651, 4654, 11650, 4653, 4652, 4655, 4952, - 4650, 4649, 4661, 4996, 5000, 4992, 5004, 4660, 4664, 4667, 4670, 11652, - 4669, 4668, 4671, 4666, 4665, 4640, 4643, 4645, 4644, 4647, 4642, 4646, - 4641, 11680, 11683, 11685, 11684, 11682, 11686, 11681, 4656, 4659, 4662, - 11651, 4663, 4658, 4657, 4896, 4899, 4902, 11663, 4901, 4900, 4903, 4898, - 4897, 43781, 43780, 43779, 43778, 43782, 43777, 4928, 4931, 4934, 4935, - 4933, 4932, 4930, 4929, 4920, 4923, 4925, 4924, 4927, 4922, 4926, 4921, - 4720, 4723, 4726, 11654, 4725, 4724, 4727, 4722, 4721, 4864, 4867, 4870, - 11662, 4869, 4868, 4871, 4866, 4865, 4616, 4619, 4622, 11648, 4621, 4620, - 4623, 4618, 4617, 4808, 4811, 4814, 4815, 4813, 4812, 4810, 4809, 4840, - 4843, 4846, 4847, 4845, 4844, 4842, 4841, 4744, 4747, 4749, 4748, 4746, - 11728, 11731, 11733, 11732, 11730, 11734, 11729, 4736, 4739, 4742, 4743, - 4741, 4740, 4738, 4737, 4832, 4835, 4837, 4836, 4839, 4834, 4838, 4833, - 11696, 11699, 11701, 11700, 11698, 11702, 11697, 4824, 4827, 4830, 11659, - 4829, 4828, 4831, 4826, 4825, 4712, 4715, 4717, 4716, 4719, 4714, 4718, - 4713, 5009, 5016, 5012, 5015, 5013, 5017, 5010, 5011, 5014, 5008, 4973, - 4972, 4975, 4974, 4971, 4970, 4977, 4969, 4976, 4962, 4967, 4961, 983096, - 983047, 127984, 127972, 8352, 8364, 118472, 8455, 8265, 33, 8761, 118269, - 118270, 118271, 118274, 128529, 128942, 128954, 128948, 128905, 128915, - 128935, 128125, 1781, 1780, 1783, 1782, 1779, 1778, 1776, 1785, 1777, - 1784, 128065, 128083, 128064, 128231, 9167, 127794, 983180, 128523, - 128561, 129312, 128531, 129301, 128567, 129488, 128582, 128558, 129326, - 128560, 129762, 129320, 128581, 129395, 129763, 129402, 128539, 128540, - 128541, 128514, 129298, 129769, 129323, 128580, 128548, 129764, 129396, - 128566, 129318, 128134, 128536, 129401, 8507, 127981, 10540, 10543, 9950, - 127810, 129478, 128439, 128224, 128106, 9771, 127877, 129498, 128552, + 804, 6876, 6833, 775, 7672, 856, 803, 7674, 6877, 6879, 7617, 7616, 779, + 6895, 6886, 6887, 783, 6894, 861, 860, 865, 7676, 6896, 6863, 7629, 862, + 863, 6840, 831, 6858, 6857, 6844, 866, 6891, 858, 864, 65058, 65059, + 8422, 840, 782, 819, 6832, 798, 6875, 6835, 8413, 8416, 8418, 8414, 8419, + 8420, 8415, 839, 6888, 8412, 6874, 850, 122892, 122884, 122891, 122890, + 122921, 122919, 122889, 122916, 122900, 122907, 122910, 122901, 122908, + 122880, 122920, 122881, 122909, 122903, 122922, 122883, 122895, 122894, + 122896, 122898, 122899, 122882, 122885, 122912, 122911, 122913, 122918, + 122915, 122888, 122886, 122904, 122902, 122897, 122893, 70508, 70507, + 70506, 70505, 70504, 70502, 70503, 70515, 70513, 70514, 70516, 70512, + 768, 790, 832, 6865, 7624, 7621, 6878, 847, 119363, 119362, 119364, 835, + 834, 837, 836, 777, 843, 795, 785, 815, 826, 6883, 811, 6855, 6834, 7632, + 12442, 12441, 7671, 7670, 7643, 7646, 7647, 7649, 7650, 867, 7666, 7655, + 7636, 7637, 7638, 872, 7639, 868, 7663, 7641, 7659, 7635, 869, 7640, + 6860, 6861, 6862, 7645, 7660, 7653, 870, 7667, 7661, 871, 7668, 7664, + 876, 7651, 7626, 877, 6848, 7652, 7658, 7656, 7657, 7665, 6847, 873, + 7642, 874, 7644, 875, 7648, 7662, 878, 879, 7654, 6889, 841, 794, 852, + 7678, 8430, 8406, 6849, 6851, 796, 849, 8400, 792, 6880, 845, 8417, 8429, + 8426, 65056, 65063, 65057, 65064, 6841, 8427, 824, 822, 8402, 818, 772, + 65060, 65067, 65061, 65068, 817, 6869, 7620, 6872, 7622, 7628, 800, 6882, + 6854, 842, 66424, 66425, 66423, 66426, 66422, 6839, 808, 7630, 773, 6846, + 6845, 6843, 801, 799, 6856, 8421, 788, 802, 7679, 854, 848, 853, 8431, + 8407, 825, 855, 8401, 6850, 6852, 793, 6881, 8428, 8408, 805, 778, 7631, + 859, 823, 821, 8403, 6873, 6853, 827, 6884, 6842, 7619, 7618, 828, 6885, + 8411, 771, 65065, 65066, 820, 816, 6859, 8424, 6836, 786, 797, 7669, 846, + 6890, 7633, 7634, 809, 781, 830, 6864, 6870, 6893, 6866, 6871, 6868, + 7673, 8425, 6838, 6837, 851, 829, 8274, 64, 121612, 121614, 44, 128476, + 9092, 8705, 129517, 9732, 127882, 128533, 128534, 128119, 128679, 8715, + 8883, 8885, 8954, 8955, 8957, 8750, 127899, 983187, 9089, 127978, 9010, + 9740, 10861, 127859, 127850, 127834, 11505, 11504, 11503, 11464, 11392, + 11506, 11499, 11501, 11446, 11452, 11458, 11466, 11442, 11448, 11450, + 11398, 1006, 1002, 11396, 1000, 11406, 998, 11436, 11412, 11420, 996, + 11434, 11472, 11414, 11422, 11478, 11468, 11470, 11476, 11474, 11482, + 11460, 11480, 11454, 11462, 11444, 11486, 11488, 11484, 11490, 11440, + 1004, 994, 11456, 11402, 11428, 11408, 11430, 11394, 11438, 11424, 11410, + 11404, 11426, 11400, 11416, 11418, 11432, 66298, 66289, 66295, 66286, + 66294, 66285, 66299, 66290, 66291, 66297, 66288, 66296, 66287, 66293, + 66284, 66292, 66283, 66282, 66277, 66276, 66279, 66278, 66275, 66274, + 66281, 66273, 66280, 66272, 11517, 11518, 11514, 11515, 11516, 11513, + 11465, 11393, 11507, 11500, 11502, 11447, 11453, 11459, 11467, 11443, + 11449, 11451, 11399, 1007, 1003, 11397, 1001, 11407, 999, 11437, 11413, + 11421, 997, 11435, 11473, 11415, 11423, 11479, 11469, 11471, 11477, + 11475, 11483, 11461, 11481, 11455, 11463, 11445, 11487, 11489, 11485, + 11491, 11441, 1005, 995, 11457, 11403, 11429, 11409, 11431, 11395, 11439, + 11425, 11411, 11405, 11427, 11401, 11417, 11419, 11433, 11497, 11492, + 11493, 11494, 11498, 11495, 11496, 11519, 127279, 169, 11855, 8792, + 129720, 9012, 9013, 119661, 119660, 119663, 119662, 119659, 119658, + 119665, 119657, 119664, 119652, 119651, 119654, 119653, 119650, 119649, + 119656, 119648, 119655, 128715, 128145, 128004, 128046, 9904, 129689, + 129509, 983074, 129771, 129408, 128179, 127769, 129431, 127951, 9769, + 9768, 11856, 11857, 128322, 128321, 10060, 127370, 127884, 9876, 9932, + 128010, 129360, 128081, 8354, 129660, 128575, 128546, 128302, 74875, + 74874, 74879, 74871, 74877, 74876, 74873, 74872, 74878, 75095, 75347, + 75205, 75224, 75104, 75113, 75357, 75282, 75394, 75259, 75122, 75366, + 75293, 75169, 75379, 75239, 75136, 75325, 74794, 74758, 74869, 74771, + 74861, 74780, 74820, 74821, 74765, 74853, 74856, 74855, 74854, 75119, + 75363, 75216, 75290, 75133, 75128, 75092, 75344, 75274, 75386, 75202, + 75251, 75317, 75221, 75101, 75166, 75376, 75142, 75236, 75175, 75110, + 75354, 75279, 75391, 75211, 75256, 75322, 75230, 74791, 74801, 74844, + 74836, 74837, 75159, 74809, 75154, 74755, 74829, 74777, 74786, 74768, + 74858, 74762, 74834, 74835, 75158, 74808, 75153, 75091, 75343, 75273, + 75385, 75201, 75250, 75316, 75220, 75100, 75118, 75362, 75193, 75197, + 75215, 75289, 75308, 75312, 75246, 75269, 75132, 75127, 75298, 75165, + 75375, 75141, 75235, 75174, 75109, 75353, 75278, 75390, 75210, 75255, + 75321, 75229, 74812, 74814, 74815, 74813, 74754, 74828, 74776, 74785, + 74790, 74800, 74767, 74857, 74761, 74839, 74838, 75160, 75161, 74822, + 74825, 74823, 74824, 75096, 75348, 75206, 75225, 75105, 75114, 75358, + 75283, 75395, 75260, 75123, 75367, 75294, 75170, 75380, 75240, 75137, + 75326, 74795, 74759, 74870, 74772, 74862, 74781, 74766, 74849, 74850, + 75143, 75144, 74847, 74840, 75147, 74852, 75088, 75145, 75340, 75270, + 75382, 75097, 75349, 75334, 75337, 75198, 75247, 75313, 75217, 75331, + 75106, 75350, 75275, 75387, 75332, 75333, 75207, 75252, 75181, 75265, + 75302, 75182, 75180, 75264, 75301, 75148, 75370, 75179, 75263, 75178, + 75242, 75262, 75318, 75226, 75299, 75300, 75183, 75303, 75184, 75304, + 75185, 75186, 75115, 75359, 75381, 75286, 75398, 75190, 75194, 75187, + 75188, 75189, 75212, 75329, 75231, 75129, 75368, 75261, 75284, 75396, + 75305, 75309, 75243, 75266, 75327, 75124, 75295, 75162, 75372, 75138, + 75232, 75171, 75176, 75241, 75146, 74848, 74851, 74831, 75155, 74804, + 75150, 74773, 74782, 74845, 74842, 74796, 74818, 74819, 74817, 75094, + 75346, 75204, 75223, 75103, 75112, 75356, 75281, 75393, 75258, 75121, + 75365, 75292, 75168, 75378, 75238, 75135, 75324, 74793, 74757, 74863, + 74770, 74860, 74779, 74764, 74802, 74803, 75093, 75345, 75203, 75222, + 75102, 75111, 75355, 75280, 75392, 75257, 75120, 75364, 75291, 75167, + 75377, 75237, 75134, 75323, 74792, 74756, 74830, 74769, 74859, 74778, + 74816, 74763, 74806, 74807, 75152, 74833, 75157, 75117, 75361, 75192, + 75196, 75214, 75288, 75307, 75311, 75245, 75268, 75131, 75126, 75297, + 75164, 75374, 75140, 75234, 75173, 75090, 75342, 75272, 75384, 75336, + 75339, 75200, 75249, 75315, 75219, 75099, 75108, 75352, 75277, 75389, + 75209, 75254, 75320, 75228, 74788, 74789, 74798, 74799, 74810, 74811, + 74753, 74827, 74775, 74784, 74760, 74752, 74826, 74832, 75156, 74805, + 75151, 74841, 74774, 74783, 75089, 75341, 75271, 75383, 75335, 75338, + 75199, 75248, 75314, 75218, 75098, 75107, 75351, 75276, 75388, 75208, + 75253, 75149, 75371, 75319, 75227, 75116, 75360, 75191, 75195, 75213, + 75287, 75330, 75130, 75369, 75285, 75397, 75306, 75310, 75244, 75267, + 75328, 75125, 75296, 75163, 75373, 75139, 75233, 75172, 75177, 74787, + 74797, 74846, 74843, 74867, 74868, 74866, 74865, 74864, 73728, 73734, + 73731, 73733, 73735, 73736, 73730, 73732, 73729, 73738, 73742, 73741, + 73744, 73745, 74881, 73747, 73748, 73740, 73739, 74608, 74880, 73746, + 73743, 73749, 73750, 73753, 73752, 73754, 73755, 73751, 74609, 73756, + 74882, 73757, 73759, 73758, 73760, 73765, 73766, 73762, 73763, 73768, + 73761, 73767, 73764, 73770, 73769, 73771, 74610, 73772, 73773, 73776, + 73777, 73775, 73774, 73778, 73780, 73781, 73782, 73784, 73788, 73789, + 73787, 73785, 73786, 73791, 73790, 73783, 73779, 73737, 73792, 73793, + 74883, 73795, 74884, 74885, 74886, 73796, 73797, 73798, 73799, 73800, + 73794, 73801, 73804, 73803, 73802, 73805, 74887, 73806, 73807, 73808, + 73809, 73810, 73811, 73812, 73813, 73814, 73815, 73816, 73817, 73818, + 73819, 73820, 73821, 73822, 73823, 73825, 73826, 73829, 73830, 73831, + 73828, 73836, 74611, 73837, 73833, 73835, 73827, 73832, 73834, 73824, + 74889, 74612, 73839, 73840, 73841, 74888, 73838, 73842, 73844, 74891, + 74890, 73845, 73846, 74892, 73847, 73848, 73849, 74613, 73843, 73850, + 73852, 73853, 73851, 73854, 73855, 74614, 73856, 73857, 74894, 74895, + 74893, 74896, 74897, 74900, 74901, 74902, 74899, 74908, 74909, 74907, + 74906, 74911, 74912, 74910, 74913, 74914, 74915, 74916, 74920, 74919, + 74898, 74905, 74903, 74904, 74917, 74918, 73858, 73860, 73861, 73862, + 73863, 73864, 73865, 73859, 73866, 73868, 73867, 73869, 73873, 73874, + 73870, 73871, 74922, 74921, 73872, 73875, 73879, 73883, 73884, 73880, + 73881, 73882, 73885, 73887, 74923, 73886, 73888, 74924, 73889, 74927, + 74930, 74931, 74925, 74928, 74929, 74932, 74926, 73890, 73891, 73892, + 73893, 73895, 73896, 73900, 73901, 73902, 73903, 73904, 73905, 73906, + 74616, 74933, 73907, 73908, 73899, 73897, 73898, 74615, 73894, 73877, + 73876, 73878, 73909, 73911, 73912, 73914, 73913, 73916, 74617, 73917, + 74618, 73918, 73915, 74934, 73920, 73919, 73921, 73922, 73924, 73925, + 74935, 74936, 74937, 73926, 73923, 73929, 73930, 73927, 73928, 74938, + 74939, 73932, 74941, 74940, 73931, 73933, 73934, 73935, 73936, 73937, + 74942, 73938, 73939, 73941, 73940, 73943, 73942, 73945, 73944, 73946, + 73947, 74943, 73948, 73949, 74944, 74945, 74946, 73950, 74947, 73951, + 74948, 74949, 74950, 73952, 73953, 73957, 73958, 73959, 74951, 73955, + 73956, 73960, 73962, 73963, 73964, 73961, 74952, 73954, 73965, 73966, + 74953, 73967, 73968, 73969, 73970, 73971, 73972, 73974, 73975, 73978, + 73977, 73976, 73910, 73979, 73980, 73981, 73973, 73982, 73983, 74954, + 74619, 73984, 73985, 73986, 73987, 73988, 73990, 73989, 73994, 73995, + 73998, 73996, 73997, 73999, 73992, 73993, 74001, 74955, 74004, 74003, + 74005, 74002, 74000, 73991, 74620, 74006, 74008, 74009, 74010, 74956, + 74012, 74011, 74013, 74014, 74957, 74015, 74016, 74017, 74019, 74020, + 74021, 74024, 74023, 74022, 74007, 74018, 74025, 74026, 74958, 74027, + 74028, 74029, 74030, 74959, 74031, 74033, 74036, 74035, 74032, 74034, + 74037, 74038, 74039, 74040, 74043, 74044, 74042, 74041, 74045, 74046, + 74621, 74047, 74050, 74052, 74051, 74053, 74054, 74058, 74057, 74055, + 74056, 74059, 74060, 74061, 74062, 74064, 74065, 74063, 74066, 74067, + 74048, 74070, 74049, 74068, 74069, 74071, 74072, 74073, 74074, 74622, + 74075, 74623, 74077, 74076, 74078, 74079, 74960, 74080, 74081, 74082, + 74085, 74086, 74084, 74083, 74087, 74624, 74090, 74089, 74088, 74091, + 74092, 74625, 74093, 74094, 74096, 74097, 74961, 74095, 74099, 74627, + 74098, 74100, 74101, 74103, 74102, 74104, 74105, 74115, 74629, 74114, + 74112, 74113, 74110, 74111, 74117, 74116, 74118, 74630, 74119, 74962, + 74963, 74631, 74122, 74123, 74120, 74121, 74626, 74107, 74106, 74628, + 74108, 74109, 74124, 74125, 74126, 74131, 74132, 74128, 74129, 74130, + 74133, 74134, 74135, 74136, 74137, 983267, 74138, 74139, 74140, 74141, + 74142, 74607, 74127, 74144, 74146, 74147, 74145, 74152, 74153, 74150, + 74151, 74148, 74149, 74154, 74155, 74157, 74158, 74163, 74164, 74165, + 74160, 74161, 74156, 74159, 74162, 74143, 74166, 74167, 74168, 74169, + 74170, 74171, 74172, 74175, 74173, 74174, 74176, 74177, 74182, 74183, + 74180, 74181, 74632, 74186, 74184, 74185, 74188, 74190, 74189, 74187, + 74194, 74195, 74193, 74191, 74192, 74196, 74197, 74198, 74199, 74200, + 74201, 74202, 74205, 74206, 74207, 74208, 74204, 74209, 74211, 74210, + 74212, 74213, 74215, 74214, 74216, 74218, 74217, 74964, 74178, 74179, + 74203, 74219, 74220, 74223, 74224, 74221, 74222, 74966, 74967, 74974, + 74973, 74972, 74969, 74970, 74971, 74975, 74968, 74965, 74977, 74976, + 74980, 74981, 74982, 74984, 74985, 74978, 74979, 74983, 74986, 74987, + 74988, 74989, 74990, 74991, 74993, 74997, 74996, 74998, 74995, 74994, + 74992, 74999, 75000, 75003, 75004, 75005, 75006, 75001, 75002, 75009, + 75015, 75016, 75019, 75017, 75018, 75013, 75012, 75010, 75011, 75014, + 75021, 75030, 75029, 75027, 75024, 75025, 75028, 75022, 75026, 75023, + 75008, 75020, 75031, 75032, 75007, 74226, 74227, 74228, 74229, 74230, + 74225, 74231, 74233, 74234, 74232, 74235, 74237, 74258, 74259, 75033, + 74261, 74633, 74260, 74240, 74634, 74241, 74243, 75035, 74246, 74247, + 74245, 74248, 74249, 74250, 74251, 75036, 75037, 74254, 74255, 74635, + 74256, 75038, 74242, 74252, 74253, 75034, 74238, 74239, 74244, 74257, + 74263, 74265, 74264, 74266, 74269, 74270, 74271, 74236, 74262, 74267, + 74268, 74272, 74273, 74274, 74278, 74279, 74275, 74276, 74277, 74280, + 74281, 74636, 74282, 75039, 74283, 74284, 74290, 74294, 74295, 75041, + 75040, 74292, 74293, 74291, 74296, 74297, 74298, 74299, 74300, 74637, + 74301, 74286, 74287, 74285, 74289, 74288, 74302, 74304, 74307, 74306, + 74305, 74308, 74310, 74309, 74311, 74303, 74638, 74312, 74314, 74313, + 74315, 74316, 74319, 74321, 74320, 74639, 74322, 74324, 74325, 74323, + 74642, 75043, 74326, 75044, 75046, 75047, 74327, 75048, 74329, 74328, + 75049, 74330, 74332, 74333, 74331, 75050, 75051, 74334, 75052, 74335, + 75042, 74641, 75045, 74640, 74317, 74336, 74318, 74337, 74338, 983266, + 983265, 74643, 74339, 74347, 74348, 74342, 74343, 74341, 74344, 74340, + 74346, 74345, 74349, 74355, 74354, 74350, 74352, 74358, 74359, 74353, + 74357, 74351, 74356, 74360, 74361, 74362, 74363, 74364, 74365, 74366, + 74644, 74367, 74375, 74376, 74368, 74369, 74373, 74374, 74370, 74371, + 74372, 74377, 74378, 74379, 74380, 74381, 74382, 74645, 74383, 74384, + 74385, 74386, 74387, 74389, 74408, 75053, 74388, 74646, 74395, 74394, + 75055, 74400, 74399, 75056, 74401, 74406, 74402, 74403, 74404, 74405, + 74391, 74392, 74396, 74398, 75054, 74397, 74393, 74390, 74407, 74409, + 74410, 74411, 74412, 74413, 74414, 74421, 74422, 74419, 74417, 74420, + 74416, 74418, 74415, 74423, 75057, 74424, 74425, 74426, 75058, 74428, + 74429, 75059, 75060, 75061, 74427, 74432, 74434, 74433, 74430, 74431, + 74435, 74437, 74436, 74438, 74441, 74440, 74444, 74445, 74446, 74448, + 74447, 74443, 74449, 74442, 74439, 74451, 74453, 74452, 74450, 74454, + 74455, 74456, 74457, 75063, 75062, 74458, 74459, 75064, 74460, 74461, + 74462, 74463, 74465, 74464, 74466, 74468, 74469, 74471, 74472, 74473, + 74474, 74467, 74470, 74475, 74477, 74478, 74479, 74476, 74480, 74481, + 74482, 74483, 74488, 74486, 74487, 74485, 74489, 74484, 74490, 75065, + 74491, 74494, 74497, 74499, 74500, 74498, 74495, 74647, 74496, 74501, + 74504, 75066, 75067, 74505, 74506, 74502, 74503, 74492, 74493, 74507, + 74510, 74512, 74511, 74649, 74509, 74508, 74515, 74516, 74522, 74523, + 74519, 74520, 74517, 74518, 74521, 74524, 74534, 74535, 74525, 74526, + 74648, 74527, 74528, 74529, 74531, 74532, 74533, 74530, 74536, 74538, + 74537, 74539, 74540, 74541, 74542, 74545, 74546, 74547, 75069, 74544, + 74543, 75068, 74549, 74550, 74551, 74552, 74553, 75070, 74555, 74556, + 74558, 74557, 74559, 74560, 74562, 74564, 74563, 75072, 74566, 75071, + 74570, 74569, 74572, 74574, 74573, 74554, 74567, 74571, 74565, 74561, + 74568, 74575, 74576, 74548, 74577, 74581, 74579, 74580, 74578, 74584, + 74583, 74582, 74586, 74587, 74588, 74585, 74513, 74514, 74589, 74591, + 74590, 74593, 75073, 74592, 74595, 74598, 74599, 74596, 74601, 74597, + 74600, 74602, 75074, 74603, 75075, 74604, 74605, 74606, 74594, 9982, + 129380, 11232, 129473, 8911, 8910, 10160, 9130, 129356, 128177, 164, + 127835, 10081, 128707, 127854, 129362, 8731, 129385, 67594, 67595, 67596, + 67597, 67598, 67599, 67600, 67601, 67602, 67603, 67604, 67605, 67606, + 67607, 67608, 67609, 67610, 67611, 67612, 67613, 67614, 67615, 67616, + 67617, 67618, 67619, 67620, 67621, 67622, 67623, 67624, 67625, 67626, + 67627, 67628, 67629, 67630, 67631, 67632, 67633, 67634, 67635, 67636, + 67637, 67589, 67592, 67644, 67647, 67639, 67640, 67584, 67585, 67586, + 67587, 67588, 77712, 77713, 77714, 77715, 77716, 77717, 77718, 77719, + 77722, 77723, 77720, 77721, 77724, 77725, 77726, 77727, 77728, 77729, + 77730, 77731, 77732, 77733, 77734, 77735, 77736, 77737, 77738, 77739, + 77740, 77741, 77742, 77743, 77744, 77745, 77746, 77747, 77748, 77749, + 77750, 77751, 77752, 77753, 77754, 77755, 77756, 77757, 77758, 77773, + 77774, 77768, 77769, 77770, 77771, 77772, 77775, 77776, 77777, 77788, + 77789, 77790, 77791, 77792, 77793, 77794, 77795, 77796, 77759, 77760, + 77761, 77762, 77763, 77764, 77765, 77766, 77767, 77778, 77779, 77780, + 77781, 77782, 77783, 77784, 77785, 77786, 77787, 77797, 77798, 77799, + 77800, 77801, 77802, 77803, 77804, 77805, 77806, 77807, 77808, 77809, + 77810, 1126, 1033, 1300, 42574, 1034, 1055, 1190, 1316, 1136, 42564, + 42592, 42580, 1296, 1146, 1302, 1058, 42634, 1196, 1035, 42640, 42638, + 1062, 42642, 7305, 42636, 1059, 1266, 1264, 1262, 1144, 1028, 1040, 1234, + 1232, 1212, 1214, 1248, 1192, 1310, 1256, 1258, 1184, 42602, 1130, 42586, + 42572, 1030, 1041, 1063, 1268, 1206, 1208, 42584, 42650, 42630, 1026, + 42568, 42604, 42648, 1029, 42562, 1322, 42632, 1039, 42626, 1324, 42624, + 1044, 1069, 1051, 1312, 1326, 1221, 1298, 1053, 1314, 1186, 1320, 1225, + 1223, 1056, 1166, 1260, 1057, 1194, 1052, 1229, 1060, 1043, 1172, 1168, + 1270, 1170, 1274, 1027, 1061, 1202, 1276, 1278, 1066, 42644, 1048, 1252, + 1037, 1250, 1045, 1024, 1238, 1025, 42588, 1128, 1132, 42578, 42582, + 1124, 42566, 1140, 1142, 1050, 1178, 1219, 1180, 1182, 1286, 1282, 1280, + 1288, 1290, 1292, 1294, 1284, 1152, 1227, 1036, 1134, 42600, 42570, 1054, + 1120, 1148, 1254, 1150, 1240, 1242, 1049, 1162, 1038, 1210, 1318, 1065, + 42646, 1064, 42596, 42598, 1068, 42594, 1198, 1200, 1164, 1071, 1304, + 1122, 1067, 1272, 42576, 1031, 42590, 1070, 1047, 1246, 1176, 42560, + 1046, 1244, 1174, 1217, 42628, 1138, 1032, 1042, 1308, 1306, 1236, 1204, + 1188, 42622, 42606, 1216, 7467, 42623, 1072, 1235, 1233, 1213, 1215, + 1249, 1193, 1311, 1257, 1259, 1185, 42603, 1131, 42587, 42573, 1110, + 1073, 1095, 1269, 1207, 1209, 42585, 42651, 42631, 1106, 42569, 42605, + 42649, 1109, 42563, 1323, 42633, 1119, 42627, 1325, 42625, 1076, 1101, + 1083, 1313, 1327, 1222, 1299, 1085, 1315, 1187, 1321, 1226, 1224, 1088, + 1167, 1261, 1089, 1195, 1084, 1230, 1092, 1075, 1173, 1169, 1271, 1171, + 1275, 1107, 1093, 1203, 1277, 1279, 1098, 42645, 1080, 1253, 1117, 1251, + 1077, 1104, 1239, 1105, 42589, 1129, 1133, 42579, 42583, 1125, 42567, + 1141, 1143, 1082, 1179, 1220, 1181, 1183, 1287, 1283, 1281, 1289, 1291, + 1293, 1295, 1285, 1153, 1228, 1116, 1135, 1127, 7297, 1113, 1301, 42601, + 42571, 42575, 7298, 1114, 1086, 1121, 1149, 1255, 1151, 1087, 1191, 1317, + 1231, 1137, 42565, 42593, 42581, 1297, 1147, 7296, 1303, 1241, 1243, + 1081, 1163, 1118, 1211, 1319, 1097, 42647, 1096, 42597, 42599, 1100, + 42595, 1199, 1201, 1165, 7302, 7303, 7300, 1090, 42635, 1197, 1115, + 42641, 42639, 1094, 7301, 42643, 7306, 42637, 1091, 1267, 1265, 1263, + 1145, 1108, 7304, 7299, 1309, 1103, 1305, 1123, 1099, 1273, 42577, 1111, + 42591, 1102, 1079, 1247, 1177, 42561, 1078, 1245, 1175, 1218, 42629, + 1139, 1112, 1074, 1307, 1237, 1205, 1189, 122984, 122962, 122986, 122985, + 122965, 122976, 122971, 122974, 122964, 122983, 122977, 122981, 122982, + 122980, 122978, 122967, 122968, 122969, 122966, 122979, 122973, 122963, + 122970, 122961, 122972, 122975, 1154, 9005, 127744, 983201, 983188, + 983172, 8224, 11830, 11831, 128481, 128131, 127841, 128374, 9619, 11843, + 128168, 10143, 65101, 65097, 8504, 983081, 983084, 983086, 983088, + 983090, 983162, 9110, 9192, 127795, 128475, 8451, 176, 8457, 983120, + 128666, 8796, 983119, 9161, 9159, 9153, 9156, 9162, 9160, 9154, 9157, + 9164, 9151, 9163, 9150, 9158, 9152, 9155, 117829, 117828, 127980, 127962, + 9739, 66589, 66591, 66596, 66597, 66587, 66585, 66594, 66595, 66593, + 66599, 66562, 66563, 66564, 66565, 66561, 66560, 66568, 66569, 66570, + 66571, 66567, 66566, 66598, 66573, 66588, 66579, 66592, 66590, 66581, + 66578, 66580, 66582, 66577, 66586, 66575, 66584, 66583, 66574, 66572, + 66576, 66629, 66631, 66636, 66637, 66627, 66625, 66634, 66635, 66633, + 66639, 66602, 66603, 66604, 66605, 66601, 66600, 66608, 66609, 66610, + 66611, 66607, 66606, 66638, 66613, 66628, 66619, 66632, 66630, 66621, + 66618, 66620, 66622, 66617, 66626, 66615, 66624, 66623, 66614, 66612, + 66616, 127964, 127965, 128421, 128468, 2388, 2416, 43258, 2387, 43257, + 72448, 72449, 43259, 2309, 72458, 2310, 2320, 2324, 2421, 43262, 2330, + 2418, 2317, 2321, 2331, 2396, 2430, 2338, 2337, 2343, 2342, 2429, 2394, + 2328, 2427, 2327, 2426, 2361, 2350, 2424, 2308, 2318, 2322, 2358, 2359, + 2360, 2431, 2349, 2348, 2393, 2326, 2325, 2397, 2353, 2352, 2323, 2420, + 2419, 2399, 2351, 2313, 2314, 2423, 2422, 2345, 2339, 2329, 2334, 2344, + 2333, 2428, 2332, 2356, 2355, 2354, 2336, 2335, 2341, 2340, 2315, 2400, + 2316, 2401, 2357, 2311, 2312, 2347, 2346, 2425, 2395, 2398, 2392, 2319, + 983644, 983643, 983646, 983647, 983649, 983648, 983642, 983645, 72450, + 72451, 72452, 72453, 2305, 43255, 43251, 43254, 43253, 72455, 72454, + 72456, 43250, 43260, 2304, 72457, 2364, 2365, 2306, 43252, 43256, 2417, + 2381, 2307, 2386, 2385, 2366, 2376, 2380, 2383, 43263, 2389, 2373, 2377, + 2379, 2363, 2362, 2382, 2369, 2370, 2391, 2390, 2374, 2378, 2371, 2372, + 2402, 2403, 2367, 2368, 2375, 2405, 2404, 2411, 2410, 2413, 2412, 2409, + 2408, 2406, 2415, 2407, 2414, 43261, 2384, 983089, 983161, 983087, + 983085, 983083, 129487, 129420, 11033, 11032, 11030, 11031, 128924, + 128160, 8900, 8960, 168, 117827, 9856, 9857, 9858, 9859, 9860, 9861, + 128754, 53, 127238, 9356, 52, 127237, 9355, 57, 127242, 9360, 49, 127234, + 9352, 55, 127240, 9358, 54, 127239, 9357, 51, 127236, 9354, 50, 127235, + 9353, 48, 127233, 127232, 56, 127241, 9359, 119557, 119556, 119555, 9868, + 9871, 9870, 9869, 119553, 119554, 10131, 10126, 10125, 10128, 10127, + 10124, 10123, 127244, 10130, 10122, 10129, 10111, 10106, 10105, 10108, + 10107, 10104, 10103, 10110, 10102, 10109, 10121, 10116, 10115, 10118, + 10117, 10114, 10113, 127243, 10120, 10112, 10119, 9107, 127919, 128549, + 128542, 9933, 9090, 129770, 129400, 72004, 72021, 72020, 72023, 72022, + 72019, 72018, 72016, 72025, 72017, 72024, 71964, 71958, 71963, 71974, + 71973, 71936, 71937, 71961, 71960, 71966, 71965, 71940, 71941, 71938, + 71939, 71982, 71976, 71952, 71962, 71957, 71967, 71978, 71979, 71980, + 71971, 71970, 71954, 71953, 71951, 71950, 71949, 71948, 71969, 71968, + 71981, 71955, 71972, 71975, 71977, 71983, 71942, 71945, 71997, 71996, + 72003, 71995, 71984, 71991, 71987, 71988, 71985, 71986, 71989, 71992, + 71998, 72002, 72000, 72005, 72006, 71999, 72001, 8725, 247, 8903, 129343, + 8739, 9902, 129684, 128171, 128565, 12291, 8783, 9009, 128462, 128441, + 128442, 128443, 8939, 8941, 8716, 8740, 10990, 8832, 8928, 8876, 8833, + 8929, 8878, 128021, 71680, 71681, 71687, 71689, 71703, 71702, 71708, + 71707, 71723, 71716, 71701, 71700, 71706, 71705, 71684, 71685, 71682, + 71683, 71694, 71704, 71699, 71709, 71719, 71720, 71721, 71713, 71712, + 71696, 71695, 71693, 71692, 71698, 71697, 71691, 71690, 71711, 71710, + 71722, 71717, 71714, 71718, 71715, 71686, 71688, 71729, 71730, 71724, + 71732, 71734, 71727, 71728, 71725, 71726, 71731, 71733, 71739, 71738, + 71735, 71737, 71736, 128054, 128044, 36, 127025, 127026, 127027, 127028, + 127029, 127030, 127031, 127032, 127033, 127034, 127035, 127036, 127037, + 127038, 127039, 127040, 127041, 127042, 127043, 127044, 127045, 127046, + 127047, 127048, 127049, 127050, 127051, 127052, 127053, 127054, 127055, + 127056, 127057, 127058, 127059, 127060, 127061, 127062, 127063, 127064, + 127065, 127066, 127067, 127068, 127069, 127070, 127071, 127072, 127073, + 127024, 127075, 127076, 127077, 127078, 127079, 127080, 127081, 127082, + 127083, 127084, 127085, 127086, 127087, 127088, 127089, 127090, 127091, + 127092, 127093, 127094, 127095, 127096, 127097, 127098, 127099, 127100, + 127101, 127102, 127103, 127104, 127105, 127106, 127107, 127108, 127109, + 127110, 127111, 127112, 127113, 127114, 127115, 127116, 127117, 127118, + 127119, 127120, 127121, 127122, 127123, 127074, 129743, 8363, 8724, 8760, + 8901, 729, 9676, 8284, 11850, 11034, 129765, 11795, 11784, 10649, 11798, + 129010, 9470, 9465, 9464, 9467, 9466, 9463, 9462, 9469, 9461, 9468, + 10175, 10868, 10986, 8225, 8223, 11840, 8914, 8748, 11842, 8222, 8215, + 10835, 10836, 10645, 10913, 10915, 10914, 10939, 8243, 12318, 10746, + 10830, 10831, 11849, 10988, 11844, 10940, 8913, 8912, 11005, 10987, 8915, + 9208, 10981, 8875, 10979, 8214, 11799, 10646, 733, 8263, 65100, 8252, + 10908, 10907, 11002, 11001, 10906, 10905, 8510, 8473, 8511, 8450, 8461, + 8469, 8474, 8477, 8484, 8518, 8519, 8520, 8521, 8517, 8509, 8508, 8512, + 10719, 9890, 9891, 11260, 127849, 8868, 10993, 10623, 8945, 8964, 117764, + 128317, 117859, 118264, 117883, 118268, 117849, 128315, 117914, 117864, + 10728, 10729, 117875, 117879, 129288, 129290, 129289, 129291, 8595, 8629, + 8671, 129035, 129031, 129179, 129043, 129027, 129047, 8626, 8627, 10504, + 8693, 129975, 8615, 10515, 11796, 11015, 129203, 11147, 11107, 11139, + 11123, 129067, 11168, 11169, 129063, 129059, 129075, 129071, 11133, + 11085, 11117, 11143, 129171, 10507, 8609, 11247, 8681, 129175, 8623, + 8659, 8675, 129079, 10597, 10607, 10593, 10585, 8643, 10589, 10581, 8642, + 129091, 129095, 129087, 10225, 128623, 129107, 129083, 8650, 128687, + 128330, 128682, 129444, 8367, 10139, 128009, 128050, 128042, 129656, + 128167, 129316, 129345, 9946, 128087, 113784, 113788, 113785, 113783, + 113782, 113786, 113787, 113795, 113798, 113793, 113800, 113781, 113794, + 113792, 113799, 113797, 113796, 113776, 113808, 113817, 113811, 113814, + 113809, 113816, 113779, 113810, 113815, 113813, 113812, 113778, 113777, + 113780, 113729, 113733, 113672, 113677, 113683, 113735, 113739, 113746, + 113668, 113678, 113674, 113726, 113691, 113699, 113700, 113695, 113709, + 113712, 113713, 113705, 113711, 113669, 113725, 113679, 113684, 113670, + 113743, 113749, 113687, 113689, 113693, 113707, 113697, 113703, 113690, + 113694, 113708, 113698, 113704, 113764, 113763, 113762, 113761, 113732, + 113753, 113731, 113755, 113754, 113666, 113766, 113765, 113676, 113675, + 113741, 113750, 113680, 113688, 113692, 113696, 113710, 113727, 113728, + 113716, 113717, 113714, 113715, 113701, 113702, 113724, 113723, 113706, + 113742, 113740, 113767, 113769, 113730, 113768, 113682, 113685, 113752, + 113737, 113667, 113719, 113718, 113681, 113745, 113748, 113751, 113738, + 113673, 113770, 113720, 113757, 113760, 113722, 113759, 113756, 113721, + 113758, 113665, 113747, 113664, 113686, 113734, 113736, 113744, 113671, + 113821, 113822, 113823, 113820, 129375, 129414, 129516, 128192, 983082, + 128066, 127805, 127806, 129467, 9793, 127758, 127759, 127757, 9178, 9841, + 129413, 11790, 77830, 77831, 77832, 77828, 77829, 77824, 77825, 77826, + 77827, 77833, 77834, 77835, 77840, 77841, 77844, 77845, 77836, 77837, + 77838, 77839, 77842, 77843, 77846, 77847, 77869, 77870, 77872, 77873, + 77874, 77875, 77877, 77878, 77871, 77876, 77879, 77880, 77881, 77882, + 77860, 77861, 77858, 77859, 77862, 77863, 77864, 77865, 77866, 77867, + 77868, 77903, 77848, 77849, 77850, 77851, 77852, 77853, 77854, 77855, + 77856, 77857, 77883, 77884, 77885, 77886, 77887, 77888, 77889, 77890, + 77891, 77892, 77893, 77894, 77895, 77896, 77897, 77898, 77899, 77900, + 77901, 77902, 78867, 78868, 78869, 78861, 78862, 78863, 78864, 78865, + 78866, 78870, 78871, 78892, 78893, 78894, 78872, 78873, 78874, 78875, + 78876, 78877, 78878, 78879, 78880, 78881, 78882, 78883, 78884, 78885, + 78886, 78887, 78888, 78889, 78890, 78891, 78910, 78908, 78903, 77908, + 77909, 77904, 77905, 77906, 77907, 77910, 77911, 77912, 77913, 77915, + 77916, 77917, 77918, 77914, 77919, 77920, 77921, 77922, 77923, 77924, + 77925, 77926, 77927, 77928, 77929, 77930, 77931, 77932, 77933, 77934, + 77935, 77936, 77937, 77938, 77939, 77940, 77941, 77949, 77950, 77942, + 77943, 77944, 77945, 77946, 77947, 77948, 77951, 77974, 77975, 77978, + 77979, 77973, 77976, 77977, 77980, 77981, 77982, 77983, 77984, 77991, + 77992, 77994, 77995, 77985, 77986, 77987, 77988, 77989, 77990, 77993, + 77996, 77997, 77998, 77999, 78000, 78001, 78002, 78003, 78004, 78005, + 78006, 78008, 78009, 78011, 78012, 78007, 78010, 78013, 78014, 78015, + 78016, 78017, 78025, 78026, 78027, 78028, 78029, 78030, 78031, 78032, + 78033, 78018, 78019, 78020, 78021, 78022, 78023, 78024, 77969, 77970, + 77962, 77963, 77964, 77965, 77966, 77967, 77968, 77971, 77972, 77952, + 77953, 77954, 77955, 77956, 77957, 77958, 77959, 77960, 77961, 78041, + 78042, 78043, 78044, 78034, 78035, 78036, 78037, 78038, 78039, 78040, + 78057, 78058, 78066, 78067, 78059, 78060, 78061, 78062, 78063, 78064, + 78065, 78068, 78073, 78074, 78069, 78070, 78071, 78072, 78075, 78076, + 78077, 78051, 78052, 78053, 78054, 78045, 78046, 78047, 78048, 78049, + 78050, 78055, 78056, 78911, 78909, 78904, 78078, 78079, 78080, 78081, + 78082, 78083, 78084, 78085, 78086, 78087, 78091, 78092, 78088, 78089, + 78090, 78093, 78094, 78095, 78096, 78097, 78098, 78111, 78112, 78118, + 78119, 78120, 78121, 78110, 78113, 78114, 78115, 78116, 78117, 78122, + 78128, 78129, 78130, 78131, 78132, 78133, 78123, 78124, 78125, 78126, + 78127, 78134, 78135, 78137, 78138, 78139, 78140, 78136, 78141, 78142, + 78100, 78101, 78099, 78102, 78103, 78104, 78105, 78106, 78107, 78108, + 78109, 78913, 78150, 78151, 78152, 78148, 78149, 78143, 78144, 78145, + 78146, 78147, 78153, 78154, 78156, 78157, 78155, 78158, 78159, 78160, + 78161, 78162, 78163, 78164, 78165, 78184, 78185, 78186, 78187, 78178, + 78179, 78180, 78181, 78182, 78183, 78188, 78189, 78193, 78194, 78196, + 78197, 78190, 78191, 78192, 78195, 78198, 78199, 78200, 78201, 78166, + 78167, 78173, 78174, 78168, 78169, 78170, 78171, 78172, 78175, 78176, + 78177, 78202, 78203, 78204, 78205, 78206, 78212, 78213, 78207, 78208, + 78209, 78210, 78211, 78214, 78215, 78914, 78916, 78897, 78220, 78221, + 78225, 78226, 78216, 78217, 78218, 78219, 78222, 78223, 78224, 78227, + 78228, 78229, 78230, 78231, 78232, 78233, 78234, 78907, 78901, 78899, + 78906, 78900, 78898, 78905, 78244, 78245, 78249, 78250, 78243, 78246, + 78247, 78248, 78251, 78252, 78915, 78253, 78254, 78255, 78257, 78258, + 78256, 78259, 78260, 78261, 78262, 78263, 78264, 78268, 78269, 78270, + 78271, 78272, 78273, 78274, 78275, 78276, 78265, 78266, 78279, 78280, + 78281, 78282, 78283, 78284, 78267, 78277, 78278, 78285, 78286, 78289, + 78290, 78292, 78293, 78297, 78298, 78287, 78288, 78291, 78294, 78295, + 78296, 78299, 78304, 78305, 78306, 78301, 78302, 78300, 78303, 78307, + 78308, 78309, 78310, 78311, 78312, 78313, 78314, 78315, 78316, 78317, + 78318, 78933, 78928, 78920, 78924, 78932, 78926, 78921, 78929, 78925, + 78923, 78931, 78919, 78927, 78922, 78930, 78912, 78336, 78337, 78338, + 78328, 78329, 78330, 78331, 78332, 78333, 78334, 78335, 78339, 78354, + 78355, 78356, 78357, 78358, 78359, 78361, 78362, 78351, 78352, 78353, + 78360, 78363, 78364, 78345, 78346, 78340, 78341, 78342, 78343, 78344, + 78347, 78348, 78349, 78350, 78365, 78366, 78367, 78319, 78320, 78321, + 78322, 78323, 78324, 78325, 78326, 78327, 78372, 78373, 78368, 78369, + 78370, 78371, 78374, 78375, 78376, 78377, 78385, 78386, 78378, 78379, + 78380, 78381, 78382, 78383, 78384, 78387, 78388, 78389, 78399, 78400, + 78401, 78402, 78409, 78410, 78403, 78404, 78405, 78406, 78407, 78408, + 78411, 78414, 78415, 78412, 78413, 78390, 78391, 78392, 78393, 78394, + 78395, 78396, 78397, 78398, 78423, 78424, 78425, 78426, 78427, 78428, + 78429, 78416, 78417, 78421, 78422, 78418, 78419, 78420, 78430, 78431, + 78432, 78433, 78434, 78435, 78436, 78445, 78446, 78437, 78438, 78439, + 78440, 78441, 78442, 78443, 78444, 78447, 78448, 78452, 78453, 78454, + 78455, 78459, 78460, 78449, 78450, 78451, 78456, 78457, 78458, 78469, + 78470, 78471, 78472, 78473, 78461, 78462, 78465, 78466, 78463, 78464, + 78467, 78468, 78474, 78475, 78476, 78487, 78488, 78489, 78490, 78477, + 78478, 78479, 78480, 78481, 78482, 78483, 78484, 78485, 78486, 78902, + 78491, 78492, 78494, 78495, 78493, 78496, 78497, 78498, 78499, 78500, + 78501, 78502, 78503, 78514, 78515, 78516, 78512, 78513, 78511, 78517, + 78518, 78519, 78520, 78521, 78522, 78523, 78524, 78530, 78531, 78525, + 78526, 78527, 78528, 78529, 78532, 78533, 78534, 78535, 78536, 78537, + 78538, 78539, 78540, 78541, 78542, 78543, 78544, 78546, 78547, 78551, + 78552, 78545, 78548, 78549, 78550, 78553, 78554, 78555, 78560, 78561, + 78562, 78565, 78566, 78556, 78557, 78558, 78559, 78563, 78564, 78567, + 78568, 78575, 78576, 78577, 78569, 78570, 78571, 78572, 78573, 78574, + 78578, 78579, 78580, 78586, 78587, 78581, 78582, 78583, 78584, 78585, + 78588, 78589, 78590, 78591, 78592, 78593, 78594, 78595, 78596, 78597, + 78598, 78601, 78602, 78606, 78607, 78608, 78609, 78610, 78611, 78599, + 78600, 78603, 78604, 78605, 78613, 78614, 78619, 78620, 78612, 78615, + 78616, 78617, 78618, 78621, 78622, 78623, 78636, 78637, 78638, 78639, + 78634, 78635, 78640, 78641, 78642, 78624, 78625, 78626, 78627, 78628, + 78629, 78630, 78631, 78632, 78633, 78917, 78648, 78649, 78650, 78643, + 78644, 78645, 78646, 78647, 78651, 78652, 78653, 78667, 78668, 78674, + 78675, 78664, 78665, 78666, 78669, 78670, 78671, 78672, 78673, 78678, + 78679, 78676, 78677, 78680, 78681, 78682, 78683, 78684, 78685, 78686, + 78687, 78688, 78689, 78654, 78655, 78656, 78657, 78658, 78659, 78660, + 78661, 78662, 78663, 78706, 78707, 78708, 78690, 78691, 78692, 78693, + 78694, 78695, 78696, 78697, 78698, 78699, 78700, 78701, 78702, 78703, + 78704, 78705, 78709, 78710, 78712, 78713, 78714, 78715, 78895, 78716, + 78717, 78718, 78711, 78719, 78720, 78721, 78722, 78723, 78724, 78725, + 78726, 78727, 78728, 78729, 78730, 78731, 78732, 78733, 78734, 78735, + 78736, 78737, 78738, 78741, 78742, 78747, 78748, 78749, 78750, 78739, + 78740, 78743, 78744, 78745, 78746, 78751, 78752, 78753, 78754, 78756, + 78757, 78761, 78762, 78755, 78758, 78759, 78760, 78763, 78764, 78765, + 78766, 78896, 78769, 78770, 78776, 78777, 78767, 78768, 78771, 78772, + 78773, 78774, 78775, 78778, 78779, 78783, 78784, 78787, 78788, 78789, + 78790, 78780, 78781, 78782, 78785, 78786, 78791, 78796, 78797, 78792, + 78793, 78794, 78795, 78798, 78918, 78802, 78803, 78804, 78806, 78807, + 78809, 78810, 78799, 78800, 78801, 78805, 78808, 78811, 78812, 78813, + 78814, 78815, 78816, 78817, 78818, 78819, 78821, 78822, 78823, 78824, + 78825, 78826, 78827, 78828, 78829, 78830, 78831, 78832, 78820, 78833, + 78834, 78835, 78836, 78842, 78843, 78844, 78845, 78846, 78847, 78848, + 78849, 78850, 78851, 78852, 78853, 78854, 78855, 78856, 78857, 78858, + 78859, 78860, 78837, 78838, 78839, 78840, 78841, 78235, 78236, 78237, + 78238, 78239, 78240, 78241, 78242, 78504, 78505, 78506, 78507, 78508, + 78509, 78510, 118470, 129370, 10037, 10039, 10036, 10049, 117865, 117866, + 10058, 10035, 9834, 66854, 66853, 66827, 66826, 66833, 66832, 66821, + 66837, 66836, 66835, 66842, 66841, 66824, 66823, 66819, 66818, 66822, + 66820, 66855, 66831, 66844, 66843, 66846, 66845, 66852, 66851, 66817, + 66825, 66828, 66830, 66834, 66839, 66840, 66848, 66849, 66816, 66829, + 66838, 66847, 66850, 128268, 128294, 128161, 8961, 9191, 8712, 8946, + 8953, 8947, 8952, 8950, 8949, 10969, 10194, 128024, 128727, 69608, 69621, + 69603, 69611, 69618, 69619, 69600, 69615, 69602, 69606, 69614, 69617, + 69620, 69609, 69604, 69607, 69610, 69601, 69613, 69605, 69616, 69612, + 69622, 129501, 983101, 129456, 129457, 129459, 129458, 127995, 127996, + 127997, 127998, 127999, 128453, 128454, 128455, 129721, 128460, 128461, + 8709, 10675, 10676, 10674, 10673, 128459, 9091, 8193, 8212, 8195, 8192, + 8211, 8194, 983179, 8718, 983178, 983135, 983099, 983048, 983095, 983046, + 983064, 128282, 983051, 983050, 9993, 128388, 128233, 9094, 983067, + 983100, 983049, 8926, 8927, 8925, 8924, 8797, 8917, 61, 10865, 10867, + 11072, 10609, 10723, 10724, 10926, 11257, 11158, 10871, 10854, 10862, + 8789, 10872, 8781, 8794, 9003, 8998, 129676, 10738, 10736, 10734, 10739, + 10737, 10735, 11249, 11248, 983105, 983104, 8494, 8793, 983136, 4957, + 4959, 4958, 4963, 4965, 4978, 4988, 4980, 4979, 4987, 4985, 4982, 4981, + 4986, 4984, 4983, 4968, 4966, 4964, 4960, 4999, 4998, 4711, 4997, 43816, + 43819, 43821, 43820, 43818, 43822, 43817, 4704, 4707, 4710, 11653, 4709, + 4708, 4706, 4705, 43808, 43811, 43813, 43812, 43810, 43814, 43809, 11704, + 11707, 11709, 11708, 11706, 11710, 11705, 11688, 11691, 11693, 11692, + 11690, 11694, 11689, 4904, 4907, 4910, 11664, 4909, 4908, 4911, 4906, + 4905, 4728, 4731, 4734, 11655, 4733, 4732, 4735, 4730, 4729, 43789, + 43788, 43787, 43786, 43790, 43785, 4856, 4859, 4862, 11661, 4861, 4860, + 4863, 4858, 4857, 43797, 43796, 43795, 43794, 43798, 43793, 4848, 4851, + 4854, 11660, 4853, 4852, 4855, 4850, 4849, 5003, 5002, 4943, 5001, 4936, + 4939, 4941, 4940, 4954, 4938, 4942, 4937, 4873, 124916, 124915, 124924, + 124923, 124910, 124909, 124926, 124925, 124922, 124921, 124920, 124919, + 124918, 124917, 124914, 124913, 124912, 124904, 11667, 4895, 11670, + 11669, 11668, 4888, 4891, 4893, 4892, 4890, 4894, 4889, 4768, 4771, 4774, + 11658, 4773, 4772, 4775, 4770, 4769, 4880, 4883, 4885, 4884, 4882, 11736, + 11739, 11741, 11740, 11738, 11742, 11737, 4872, 4875, 4878, 4879, 4877, + 4876, 4874, 124907, 124906, 4631, 124905, 124896, 124899, 124901, 124900, + 124898, 124902, 124897, 4624, 4627, 4629, 4628, 4626, 4630, 4625, 4608, + 4611, 4614, 4615, 4613, 4612, 4610, 4609, 4800, 4803, 4805, 4804, 4802, + 4792, 4795, 4797, 4796, 4794, 4798, 4793, 4784, 4787, 4789, 4788, 4786, + 11720, 11723, 11725, 11724, 11722, 11726, 11721, 4776, 4779, 4782, 4783, + 4781, 4780, 4778, 4777, 4995, 4994, 4639, 4993, 4632, 4635, 4638, 11649, + 4637, 4636, 4953, 4634, 4633, 4760, 4763, 4766, 11657, 4765, 4764, 4767, + 4762, 4761, 4752, 4755, 4758, 11656, 4757, 4756, 4759, 4754, 4753, 4912, + 4816, 4819, 4821, 4820, 4818, 4822, 4817, 4915, 4918, 11665, 4917, 4916, + 4919, 4914, 4913, 5007, 5006, 4951, 5005, 4944, 4947, 4950, 11666, 4949, + 4948, 4946, 4945, 4696, 4699, 4701, 4700, 4698, 4688, 4691, 4693, 4692, + 4690, 4694, 4689, 4680, 4683, 4685, 4684, 4682, 11712, 11715, 11717, + 11716, 11714, 11718, 11713, 4672, 4675, 4678, 4679, 4677, 4676, 4674, + 4673, 4648, 4651, 4654, 11650, 4653, 4652, 4655, 4952, 4650, 4649, 4661, + 4996, 5000, 4992, 5004, 4660, 4664, 4667, 4670, 11652, 4669, 4668, 4671, + 4666, 4665, 4640, 4643, 4645, 4644, 4647, 4642, 4646, 4641, 11680, 11683, + 11685, 11684, 11682, 11686, 11681, 4656, 4659, 4662, 11651, 4663, 4658, + 4657, 4896, 4899, 4902, 11663, 4901, 4900, 4903, 4898, 4897, 43781, + 43780, 43779, 43778, 43782, 43777, 4928, 4931, 4934, 4935, 4933, 4932, + 4930, 4929, 4920, 4923, 4925, 4924, 4927, 4922, 4926, 4921, 4720, 4723, + 4726, 11654, 4725, 4724, 4727, 4722, 4721, 4864, 4867, 4870, 11662, 4869, + 4868, 4871, 4866, 4865, 4616, 4619, 4622, 11648, 4621, 4620, 4623, 4618, + 4617, 4808, 4811, 4814, 4815, 4813, 4812, 4810, 4809, 4840, 4843, 4846, + 4847, 4845, 4844, 4842, 4841, 4744, 4747, 4749, 4748, 4746, 11728, 11731, + 11733, 11732, 11730, 11734, 11729, 4736, 4739, 4742, 4743, 4741, 4740, + 4738, 4737, 4832, 4835, 4837, 4836, 4839, 4834, 4838, 4833, 11696, 11699, + 11701, 11700, 11698, 11702, 11697, 4824, 4827, 4830, 11659, 4829, 4828, + 4831, 4826, 4825, 4712, 4715, 4717, 4716, 4719, 4714, 4718, 4713, 5009, + 5016, 5012, 5015, 5013, 5017, 5010, 5011, 5014, 5008, 4973, 4972, 4975, + 4974, 4971, 4970, 4977, 4969, 4976, 4962, 4967, 4961, 983096, 983047, + 127984, 127972, 8352, 8364, 118472, 8455, 8265, 33, 8761, 118269, 118270, + 118271, 118274, 128529, 128942, 128954, 128948, 128905, 128915, 128935, + 128125, 1781, 1780, 1783, 1782, 1779, 1778, 1776, 1785, 1777, 1784, + 128065, 128083, 128064, 128231, 9167, 127794, 983180, 128523, 128561, + 129312, 128531, 129301, 128567, 129488, 128582, 128558, 129326, 128560, + 129762, 129320, 128581, 129395, 129763, 129402, 128539, 128540, 128541, + 128514, 129298, 129769, 129323, 128580, 128548, 129764, 129396, 128566, + 129318, 128134, 128536, 129401, 8507, 121628, 127981, 10540, 10543, 9950, + 127810, 129478, 128439, 128224, 128106, 127877, 129498, 9771, 128552, 129718, 170, 9792, 127905, 9972, 129338, 8210, 8199, 129775, 128193, 128452, 983107, 128253, 127902, 129734, 10765, 128293, 128658, 129519, 127879, 127878, 129512, 9789, 127771, 127763, 8296, 129351, 128031, @@ -10541,7 +10799,7 @@ static const unsigned int dawg_pos_to_codepoint[] = { 65284, 65301, 65300, 65303, 65302, 65299, 65298, 65296, 65305, 65297, 65304, 65309, 65281, 65344, 65310, 65293, 65282, 65311, 65510, 65374, 65294, 65508, 65372, 8289, 9905, 118280, 9981, 9179, 983215, 983216, - 983217, 983219, 983108, 983236, 983072, 68972, 68971, 68973, 68970, + 983217, 983219, 983108, 983236, 983072, 68973, 68970, 68972, 68971, 68964, 68965, 68959, 68961, 68948, 68945, 68954, 68960, 68953, 68963, 68949, 68947, 68952, 68946, 68962, 68958, 68950, 68957, 68951, 68955, 68956, 68944, 68996, 68997, 68991, 68993, 68980, 68977, 68986, 68992, @@ -10566,8 +10824,8 @@ static const unsigned int dawg_pos_to_codepoint[] = { 7338, 7352, 7316, 7334, 7314, 7348, 7358, 7344, 7346, 7349, 7345, 7343, 7339, 7333, 7321, 7359, 7322, 7332, 7326, 7336, 7329, 7353, 7319, 7330, 7327, 7318, 7328, 7313, 7323, 7342, 7324, 7335, 7317, 7315, 7320, 7325, - 7331, 7351, 7347, 7350, 4347, 8368, 12307, 129502, 8503, 129754, 128103, - 128714, 129426, 11264, 11304, 11265, 11311, 11293, 11276, 11268, 11271, + 7331, 7351, 7347, 7350, 4347, 8368, 12307, 129502, 8503, 128103, 128714, + 129426, 129754, 11264, 11304, 11265, 11311, 11293, 11276, 11268, 11271, 11287, 11306, 11267, 11275, 11274, 11305, 11303, 11307, 11273, 11310, 11278, 11279, 11280, 11281, 11289, 11282, 11290, 11283, 11291, 11308, 11294, 11284, 11298, 11300, 11301, 11285, 11309, 11292, 11266, 11269, @@ -10607,7 +10865,7 @@ static const unsigned int dawg_pos_to_codepoint[] = { 8186, 911, 927, 8009, 8013, 8011, 8008, 8012, 8010, 8185, 8184, 908, 929, 8172, 931, 1018, 1015, 933, 8025, 8031, 8029, 8027, 939, 8168, 8170, 8171, 910, 8169, 886, 934, 936, 928, 920, 932, 916, 922, 915, 935, 914, - 880, 918, 923, 895, 924, 925, 926, 1017, 1023, 1021, 1022, 975, 1012, + 880, 918, 923, 895, 924, 925, 926, 1017, 1023, 1021, 1022, 1012, 975, 8129, 8174, 8173, 901, 65915, 8190, 8159, 8158, 8157, 65920, 65919, 119325, 119331, 119332, 119333, 119334, 119335, 119336, 119337, 119326, 119338, 119339, 119340, 119341, 119342, 119343, 119344, 119345, 119346, @@ -10734,17 +10992,17 @@ static const unsigned int dawg_pos_to_codepoint[] = { 67836, 128891, 11233, 129702, 9980, 127911, 127892, 128157, 128152, 128159, 129782, 128585, 129180, 129183, 129182, 129181, 128628, 10033, 10008, 10149, 10150, 10084, 10167, 10169, 10168, 10054, 10004, 11096, - 9955, 11095, 11097, 10152, 10144, 10135, 129055, 129051, 10077, 10078, - 128178, 128977, 10040, 128975, 10059, 128958, 10071, 10082, 129008, - 10020, 128970, 128946, 129943, 10083, 11093, 128327, 10096, 10094, - 129052, 129048, 10080, 10079, 10157, 128627, 10006, 10134, 10012, 11094, - 10030, 10097, 10095, 10137, 129054, 129050, 10140, 128635, 128940, 10075, - 10076, 128972, 128952, 128607, 128615, 10136, 128605, 128613, 128625, - 10056, 128606, 128614, 10138, 128604, 128612, 10051, 10045, 10171, 10142, + 9955, 11095, 11097, 10152, 10144, 129055, 129051, 10077, 10078, 128178, + 10135, 128977, 10040, 128975, 10059, 128958, 10071, 10082, 129008, 10020, + 128970, 128946, 129943, 10083, 11093, 128327, 10096, 10094, 129052, + 129048, 10080, 10079, 10157, 128627, 10006, 10134, 10012, 11094, 10030, + 10097, 10095, 10137, 129054, 129050, 10140, 128635, 128940, 10075, 10076, + 128972, 128952, 128607, 128615, 10136, 128605, 128613, 128625, 10056, + 128606, 128614, 10138, 128604, 128612, 10051, 10045, 10171, 10142, 128980, 128979, 129053, 129049, 10158, 128913, 118277, 9947, 128903, 10132, 10173, 128633, 10133, 10074, 10010, 1442, 1453, 1447, 1436, 1437, 1438, 1445, 1446, 1443, 1444, 1433, 1441, 1425, 1439, 1448, 1426, 1427, - 1449, 1440, 1435, 1430, 1450, 1434, 1428, 1429, 1432, 1454, 1431, 1451, + 1440, 1449, 1435, 1430, 1450, 1434, 1428, 1429, 1432, 1454, 1431, 1451, 1452, 1488, 64304, 64302, 64303, 64288, 64297, 1506, 1489, 64332, 64305, 1499, 64333, 64315, 1508, 64334, 64324, 1498, 64314, 1507, 64323, 1509, 1503, 1501, 1511, 64327, 1492, 64308, 1495, 1504, 64320, 1494, 64310, @@ -10752,164 +11010,172 @@ static const unsigned int dawg_pos_to_codepoint[] = { 64312, 1514, 64330, 1510, 64326, 1491, 64307, 1490, 64306, 1500, 64316, 1502, 64318, 1493, 64331, 64309, 64293, 64289, 64296, 64295, 64290, 64292, 64291, 64294, 1497, 64285, 64313, 64335, 1520, 1522, 64287, 1521, - 1477, 1476, 1455, 1468, 1458, 1459, 1457, 1460, 1465, 1466, 1463, 1464, - 1479, 1467, 1471, 1462, 1473, 1456, 1474, 1461, 64286, 1469, 1524, 1523, - 1472, 1475, 1478, 1470, 1519, 118464, 9937, 9096, 11263, 128641, 110597, - 110594, 110595, 110596, 110778, 110779, 110780, 110781, 110782, 110783, - 110784, 110785, 110750, 110759, 110760, 110751, 110752, 110753, 110754, - 110755, 110756, 110757, 110758, 110768, 110769, 110770, 110771, 110772, - 110773, 110774, 110775, 110776, 110777, 110761, 110762, 110763, 110764, - 110765, 110766, 110767, 110615, 110624, 110625, 110626, 110616, 110617, - 110618, 110619, 110620, 110621, 110622, 110623, 110651, 110648, 110649, - 110650, 110627, 110628, 110629, 110630, 110631, 110632, 110633, 110634, - 110642, 110643, 110644, 110645, 110646, 110647, 110635, 110636, 110637, - 110638, 110639, 110640, 110641, 110806, 110804, 110805, 110807, 110808, - 110809, 110810, 110811, 110812, 110786, 110787, 110788, 110789, 110790, - 110791, 110792, 110793, 110794, 110795, 110796, 110797, 110798, 110799, - 110800, 110801, 110802, 110803, 110744, 110738, 110739, 110740, 110741, - 110742, 110743, 110734, 110727, 110728, 110729, 110730, 110731, 110732, - 110733, 110718, 110719, 110720, 110721, 110722, 110723, 110724, 110725, - 110726, 110745, 110746, 110747, 110748, 110749, 110735, 110736, 110737, - 110877, 110878, 110850, 110851, 110852, 110853, 110854, 110855, 110840, - 110841, 110842, 110843, 110844, 110845, 110833, 110834, 110835, 110836, - 110837, 110838, 110839, 110829, 110830, 110831, 110832, 110846, 110847, - 110848, 110849, 110652, 110653, 110654, 110655, 110656, 110657, 110658, - 110659, 110666, 110667, 110668, 110669, 110670, 110671, 110672, 110673, - 110660, 110661, 110662, 110663, 110664, 110665, 110674, 110675, 110676, - 110677, 110678, 110679, 110680, 110681, 110682, 110683, 110684, 110685, - 110702, 110703, 110704, 110705, 110706, 110707, 110708, 110709, 110710, - 110717, 110711, 110712, 110713, 110714, 110715, 110716, 110701, 110697, - 110698, 110699, 110700, 110690, 110691, 110692, 110693, 110694, 110695, - 110696, 110686, 110687, 110688, 110689, 110856, 110857, 110858, 110859, - 110860, 110861, 110862, 110863, 110864, 110865, 110870, 110871, 110872, - 110873, 110874, 110875, 110876, 110866, 110867, 110868, 110869, 110818, - 110813, 110814, 110815, 110816, 110817, 110823, 110824, 110825, 110826, - 110827, 110828, 110819, 110820, 110821, 110822, 983277, 110607, 110608, - 110609, 110610, 110611, 110602, 110603, 110604, 110605, 110606, 110612, - 110613, 110614, 110598, 110599, 110600, 110601, 8889, 127807, 19922, - 19966, 19958, 19967, 19924, 19946, 19923, 19909, 19947, 19944, 19943, - 19956, 19906, 19962, 19935, 19939, 19920, 19916, 19948, 19917, 19937, - 19931, 19929, 19925, 19911, 19928, 19964, 19945, 19934, 19918, 19930, - 19942, 19950, 19941, 19949, 19938, 19914, 19927, 19936, 19952, 19965, - 19912, 19915, 19926, 19954, 19910, 19932, 19953, 19904, 19933, 19940, - 19905, 19951, 19959, 19957, 19960, 19955, 19961, 19913, 19908, 19921, - 19963, 19907, 19919, 129428, 128262, 9889, 983123, 128644, 128645, - 128096, 12447, 12354, 110879, 110593, 12430, 110929, 110928, 110930, - 12419, 12423, 12421, 12437, 12438, 110898, 12387, 12353, 12359, 12355, - 12361, 12357, 12373, 12379, 12375, 12381, 12377, 12403, 983997, 984000, - 983998, 984001, 983999, 12400, 12409, 12412, 12406, 12435, 12394, 12397, - 12395, 12398, 12396, 12384, 12391, 12386, 12393, 12389, 12364, 12370, - 12366, 12372, 12368, 12399, 12408, 12402, 12411, 12405, 12363, 12369, - 12365, 12371, 12367, 12414, 12417, 12415, 12418, 12416, 12401, 12410, - 12404, 12413, 12407, 12425, 12428, 12426, 12429, 12427, 12383, 12390, - 12385, 12392, 12388, 12374, 12380, 12376, 12382, 12378, 12431, 12433, - 12432, 12434, 12420, 12424, 12422, 12436, 12360, 12356, 12362, 12358, - 12446, 12445, 9964, 128725, 129406, 127802, 129435, 128616, 128617, - 128371, 128029, 127855, 11203, 11043, 8213, 118290, 118287, 117905, 9135, - 117893, 129921, 129910, 129911, 129912, 129913, 129914, 129915, 9146, - 9147, 9148, 9149, 983059, 983141, 983138, 11134, 128677, 117779, 8230, - 9897, 117915, 117769, 118448, 128014, 127943, 128052, 127798, 9749, 9832, - 127789, 127976, 8987, 9203, 8962, 127969, 127968, 127960, 127973, 128298, - 8763, 129693, 983124, 983060, 983142, 983139, 128559, 128175, 129303, - 128726, 11226, 128889, 8208, 11802, 8259, 8231, 45, 11794, 9102, 129723, - 8372, 127848, 129482, 127954, 9976, 8801, 10725, 10855, 129706, 12696, - 12700, 12693, 12697, 12695, 12703, 12692, 12699, 12691, 12694, 12688, - 12698, 12690, 12689, 12701, 12702, 12294, 12289, 12275, 12273, 12274, - 12272, 12283, 12282, 12285, 12279, 12280, 12281, 12278, 12277, 12284, - 12783, 12287, 12276, 12286, 12332, 12295, 119670, 119669, 119668, 119667, - 119666, 12999, 12995, 13309, 13310, 13292, 13282, 13299, 13304, 13303, - 13306, 13305, 13302, 13301, 13308, 13300, 13307, 13291, 13281, 13289, - 13287, 13297, 13290, 13294, 13284, 13283, 13293, 13288, 13298, 13286, - 13296, 13285, 13295, 13280, 13003, 13164, 13168, 13167, 13166, 13165, - 13156, 13146, 13157, 13147, 13154, 13152, 13162, 13155, 13159, 13149, - 13148, 13158, 13153, 13163, 13151, 13161, 13150, 13160, 13144, 13145, - 12992, 12997, 12998, 12993, 12994, 12996, 13002, 13000, 13001, 12343, - 12351, 12333, 12331, 12330, 12350, 12290, 12293, 12288, 8887, 8787, - 128127, 67676, 67673, 67675, 67679, 67674, 67672, 67677, 67678, 67656, - 67669, 67651, 67659, 67666, 67667, 67648, 67663, 67650, 67654, 67662, - 67665, 67668, 67657, 67652, 67655, 67658, 67649, 67661, 67653, 67664, - 67660, 67671, 128232, 10716, 128474, 10721, 8710, 983130, 983129, 129781, - 126132, 126112, 126126, 126125, 126127, 126131, 126130, 126129, 126113, - 126114, 126110, 126111, 126072, 126081, 126108, 126090, 126099, 126078, - 126105, 126069, 126087, 126096, 126077, 126104, 126068, 126086, 126095, - 126073, 126082, 126109, 126091, 126100, 126071, 126080, 126107, 126089, - 126098, 126070, 126079, 126106, 126088, 126097, 126076, 126103, 126067, - 126085, 126094, 126075, 126102, 126066, 126084, 126093, 126074, 126101, - 126119, 126118, 126121, 126120, 126117, 126116, 126123, 126115, 126122, - 126065, 126083, 126092, 126128, 126124, 8377, 8734, 10718, 983106, - 983109, 983112, 983115, 8505, 128129, 8300, 8298, 128288, 128289, 128292, - 128291, 128290, 68456, 68466, 68448, 68451, 68459, 68460, 68453, 68450, - 68454, 68462, 68464, 68465, 68457, 68452, 68455, 68458, 68449, 68461, - 68463, 68477, 68473, 68474, 68476, 68472, 68478, 68479, 68475, 68424, - 68437, 68419, 68427, 68434, 68435, 68416, 68431, 68418, 68422, 68430, - 68433, 68436, 68425, 68420, 68423, 68426, 68417, 68429, 68421, 68432, - 68428, 68445, 68441, 68442, 68444, 68440, 68446, 68447, 68443, 9088, - 8747, 10767, 10773, 10776, 10780, 10778, 10775, 10777, 10779, 10766, - 9134, 65529, 65531, 65530, 9892, 8745, 10825, 10823, 10820, 10819, 10816, - 10827, 8253, 8890, 10812, 117901, 117903, 9688, 129942, 129969, 129972, - 9689, 129936, 11800, 11845, 11846, 8766, 9959, 161, 8487, 8276, 191, - 8290, 8292, 8291, 128229, 118471, 118465, 127982, 129311, 127875, 127983, - 127971, 12292, 9979, 127886, 128304, 128122, 128121, 43453, 43454, 43455, - 43457, 43421, 43422, 43426, 43427, 43398, 43397, 43399, 43407, 43408, - 43409, 43412, 43402, 43403, 43418, 43416, 43428, 43423, 43431, 43432, - 43413, 43414, 43410, 43411, 43429, 43430, 43401, 43435, 43436, 43441, - 43439, 43440, 43424, 43425, 43419, 43420, 43415, 43417, 43396, 43405, - 43442, 43437, 43433, 43438, 43434, 43404, 43406, 43400, 43458, 43466, - 43467, 43459, 43465, 43461, 43464, 43468, 43463, 43486, 43462, 43487, - 43460, 43471, 43456, 43469, 43393, 43443, 43395, 43394, 43392, 43448, - 43449, 43444, 43450, 43445, 43446, 43447, 43452, 43451, 43477, 43476, - 43479, 43478, 43475, 43474, 43472, 43481, 43473, 43480, 129753, 129724, - 128086, 128377, 10781, 129337, 9795, 9909, 129513, 69786, 69787, 69785, - 69793, 69792, 69763, 69764, 69770, 69772, 69784, 69783, 69791, 69790, - 69767, 69768, 69765, 69766, 69777, 69789, 69782, 69794, 69804, 69805, - 69806, 69798, 69797, 69779, 69778, 69776, 69775, 69781, 69780, 69774, - 69773, 69796, 69795, 69788, 69801, 69807, 69802, 69799, 69803, 69800, - 69769, 69771, 69760, 69818, 69761, 69817, 69762, 69822, 69823, 69825, - 69824, 69826, 69808, 69814, 69816, 69811, 69812, 69809, 69810, 69813, - 69815, 69821, 69837, 69819, 69820, 12142, 12164, 12060, 12157, 12100, - 12149, 12184, 12191, 12227, 12068, 12174, 12234, 12205, 12134, 12168, - 12219, 12189, 12088, 12090, 12096, 12160, 12182, 12224, 12190, 12147, - 12114, 12118, 12058, 12176, 12075, 12112, 12045, 12170, 12124, 12070, - 12194, 12109, 12229, 12196, 12139, 12056, 12099, 12034, 12084, 12136, - 12120, 12044, 12111, 12094, 12125, 12243, 12238, 12082, 12159, 12063, - 12215, 12062, 12042, 12241, 12067, 12235, 12043, 12140, 12119, 12207, - 12123, 12133, 12222, 12117, 12226, 12245, 12214, 12217, 12236, 12155, - 12188, 12113, 12065, 12198, 12066, 12146, 12171, 12225, 12200, 12121, - 12093, 12095, 12221, 12092, 12216, 12231, 12054, 12218, 12179, 12037, - 12173, 12072, 12046, 12127, 12152, 12049, 12074, 12107, 12208, 12212, - 12041, 12210, 12131, 12033, 12039, 12199, 12085, 12128, 12161, 12162, - 12233, 12165, 12192, 12077, 12201, 12061, 12105, 12040, 12240, 12102, - 12153, 12032, 12080, 12167, 12048, 12156, 12059, 12126, 12158, 12050, - 12183, 12204, 12097, 12239, 12053, 12078, 12150, 12071, 12187, 12186, - 12223, 12228, 12104, 12098, 12064, 12036, 12057, 12163, 12178, 12185, - 12154, 12203, 12083, 12087, 12135, 12151, 12202, 12035, 12122, 12141, - 12180, 12144, 12076, 12052, 12115, 12091, 12108, 12169, 12143, 12148, - 12130, 12089, 12211, 12073, 12101, 12138, 12103, 12209, 12047, 12220, - 12172, 12129, 12166, 12242, 12237, 12145, 12106, 12081, 12244, 12038, - 12086, 12055, 12181, 12197, 12193, 12175, 12116, 12110, 12177, 12137, - 12230, 12213, 12195, 12069, 12079, 12206, 12051, 12232, 12132, 129432, - 3240, 3293, 3225, 3235, 3230, 3205, 3206, 3216, 3220, 3234, 3233, 3239, - 3238, 983205, 3251, 3250, 3249, 3248, 3232, 3231, 3237, 3236, 3211, 3296, - 3212, 3297, 3253, 3209, 3210, 3218, 3219, 3207, 3208, 3254, 3255, 3256, - 3245, 3244, 3227, 3226, 3224, 3223, 3229, 3228, 3222, 3221, 3243, 3242, - 3214, 3215, 3294, 3257, 3246, 3247, 3285, 3315, 3201, 3200, 3204, 3260, - 3261, 3202, 3313, 3314, 3277, 3203, 3292, 3286, 3262, 3272, 3276, 3265, - 3266, 3267, 3268, 3298, 3299, 3274, 3275, 3263, 3264, 3270, 3271, 3307, - 3306, 3309, 3308, 3305, 3304, 3302, 3311, 3303, 3310, 12450, 984009, - 984008, 984007, 984010, 110881, 110880, 110882, 110592, 12499, 984002, + 1477, 1476, 1455, 1468, 1481, 1458, 1459, 1457, 1460, 1465, 1466, 1463, + 1464, 1479, 1467, 1471, 1462, 1456, 1480, 1473, 1474, 1461, 64286, 1469, + 1524, 1523, 1472, 1475, 1478, 1470, 1519, 118464, 9937, 9096, 11263, + 128641, 110597, 110594, 110595, 110596, 110778, 110779, 110780, 110781, + 110782, 110783, 110784, 110785, 110750, 110759, 110760, 110751, 110752, + 110753, 110754, 110755, 110756, 110757, 110758, 110768, 110769, 110770, + 110771, 110772, 110773, 110774, 110775, 110776, 110777, 110761, 110762, + 110763, 110764, 110765, 110766, 110767, 110615, 110624, 110625, 110626, + 110616, 110617, 110618, 110619, 110620, 110621, 110622, 110623, 110651, + 110648, 110649, 110650, 110642, 110643, 110644, 110645, 110646, 110647, + 110627, 110628, 110629, 110630, 110631, 110632, 110633, 110634, 110635, + 110636, 110637, 110638, 110639, 110640, 110641, 110806, 110804, 110805, + 110807, 110808, 110809, 110810, 110811, 110812, 110786, 110787, 110788, + 110789, 110790, 110791, 110792, 110793, 110794, 110795, 110796, 110797, + 110798, 110799, 110800, 110801, 110802, 110803, 110744, 110738, 110739, + 110740, 110741, 110742, 110743, 110734, 110727, 110728, 110729, 110730, + 110731, 110732, 110733, 110718, 110719, 110720, 110721, 110722, 110723, + 110724, 110725, 110726, 110745, 110746, 110747, 110748, 110749, 110735, + 110736, 110737, 110877, 110878, 110850, 110851, 110852, 110853, 110854, + 110855, 110840, 110841, 110842, 110843, 110844, 110845, 110833, 110834, + 110835, 110836, 110837, 110838, 110839, 110829, 110830, 110831, 110832, + 110846, 110847, 110848, 110849, 110660, 110661, 110662, 110663, 110664, + 110665, 110652, 110653, 110654, 110655, 110656, 110657, 110658, 110659, + 110666, 110667, 110668, 110669, 110670, 110671, 110672, 110673, 110674, + 110675, 110676, 110677, 110678, 110679, 110680, 110681, 110682, 110683, + 110684, 110685, 110702, 110703, 110704, 110705, 110706, 110707, 110708, + 110709, 110710, 110717, 110711, 110712, 110713, 110714, 110715, 110716, + 110701, 110697, 110698, 110699, 110700, 110690, 110691, 110692, 110693, + 110694, 110695, 110696, 110686, 110687, 110688, 110689, 110856, 110857, + 110858, 110859, 110860, 110861, 110862, 110863, 110864, 110865, 110870, + 110871, 110872, 110873, 110874, 110875, 110876, 110866, 110867, 110868, + 110869, 110818, 110813, 110814, 110815, 110816, 110817, 110823, 110824, + 110825, 110826, 110827, 110828, 110819, 110820, 110821, 110822, 983277, + 110607, 110608, 110609, 110610, 110611, 110602, 110603, 110604, 110605, + 110606, 110612, 110613, 110614, 110598, 110599, 110600, 110601, 8889, + 127807, 19922, 19966, 19958, 19967, 19924, 19946, 19923, 19909, 19947, + 19944, 19943, 19956, 19906, 19962, 19935, 19939, 19920, 19916, 19948, + 19917, 19937, 19931, 19929, 19925, 19911, 19928, 19964, 19945, 19934, + 19918, 19930, 19942, 19950, 19941, 19949, 19938, 19914, 19927, 19936, + 19952, 19965, 19912, 19915, 19926, 19954, 19910, 19932, 19953, 19904, + 19933, 19940, 19905, 19951, 19959, 19957, 19960, 19955, 19961, 19913, + 19908, 19921, 19963, 19907, 19919, 129428, 128262, 9889, 983123, 128644, + 128645, 128096, 110883, 12447, 12354, 110879, 110593, 12430, 110929, + 110928, 110930, 12419, 12423, 12421, 12437, 12438, 110898, 12387, 12353, + 12359, 12355, 12361, 12357, 12373, 12379, 12375, 12381, 12377, 12403, + 983997, 984000, 983998, 984001, 983999, 12400, 12409, 12412, 12406, + 12435, 12394, 12397, 12395, 12398, 12396, 12384, 12391, 12386, 12393, + 12389, 12364, 12370, 12366, 12372, 12368, 12399, 12408, 12402, 12411, + 12405, 12363, 12369, 12365, 12371, 12367, 12414, 12417, 12415, 12418, + 12416, 12401, 12410, 12404, 12413, 12407, 12425, 12428, 12426, 12429, + 12427, 12383, 12390, 12385, 12392, 12388, 12374, 12380, 12376, 12382, + 12378, 12431, 12433, 12432, 12434, 12420, 12424, 12422, 12436, 12360, + 12356, 12362, 12358, 12446, 12445, 9964, 128725, 129406, 127802, 129435, + 128616, 128617, 128371, 128029, 127855, 11203, 11043, 8213, 118290, + 118287, 117905, 9135, 117893, 129921, 129910, 129911, 129912, 129913, + 129914, 129915, 9146, 9147, 9148, 9149, 983059, 983141, 983138, 11134, + 128677, 117779, 129016, 8230, 9897, 117915, 117769, 118448, 128014, + 127943, 128052, 127798, 9749, 9832, 127789, 127976, 8987, 9203, 8962, + 127969, 127968, 127960, 127973, 128298, 8763, 129693, 983124, 983060, + 983142, 983139, 128559, 128175, 129303, 128726, 11226, 128889, 118525, + 8208, 11802, 8259, 8231, 45, 11794, 9102, 129723, 8372, 127848, 129482, + 127954, 9976, 8801, 10725, 10855, 129706, 12696, 12700, 12693, 12697, + 12695, 12703, 12692, 12699, 12691, 12694, 12688, 12698, 12690, 12689, + 12701, 12702, 12294, 12289, 12275, 12273, 12274, 12272, 12283, 12282, + 12285, 12279, 12280, 12281, 12278, 12277, 12284, 12783, 12287, 12276, + 12286, 12332, 12295, 119670, 119669, 119668, 119667, 119666, 12999, + 12995, 13309, 13310, 13292, 13282, 13299, 13304, 13303, 13306, 13305, + 13302, 13301, 13308, 13300, 13307, 13291, 13281, 13289, 13287, 13297, + 13290, 13294, 13284, 13283, 13293, 13288, 13298, 13286, 13296, 13285, + 13295, 13280, 13003, 13164, 13168, 13167, 13166, 13165, 13156, 13146, + 13157, 13147, 13154, 13152, 13162, 13155, 13159, 13149, 13148, 13158, + 13153, 13163, 13151, 13161, 13150, 13160, 13144, 13145, 12992, 12997, + 12998, 12993, 12994, 12996, 13002, 13000, 13001, 12343, 12351, 12333, + 12331, 12330, 12350, 12290, 12293, 12288, 8887, 8787, 128127, 67676, + 67673, 67675, 67679, 67674, 67672, 67677, 67678, 67656, 67669, 67651, + 67659, 67666, 67667, 67648, 67663, 67650, 67654, 67662, 67665, 67668, + 67657, 67652, 67655, 67658, 67649, 67661, 67653, 67664, 67660, 67671, + 121613, 121615, 128232, 10716, 128474, 10721, 8710, 983130, 983129, + 129781, 126132, 126112, 126126, 126125, 126127, 126131, 126130, 126129, + 126113, 126114, 126110, 126111, 126072, 126081, 126108, 126090, 126099, + 126078, 126105, 126069, 126087, 126096, 126077, 126104, 126068, 126086, + 126095, 126073, 126082, 126109, 126091, 126100, 126071, 126080, 126107, + 126089, 126098, 126070, 126079, 126106, 126088, 126097, 126076, 126103, + 126067, 126085, 126094, 126075, 126102, 126066, 126084, 126093, 126074, + 126101, 126119, 126118, 126121, 126120, 126117, 126116, 126123, 126115, + 126122, 126065, 126083, 126092, 126128, 126124, 8377, 8734, 10718, + 983106, 983109, 983112, 983115, 8505, 128129, 8300, 8298, 128288, 128289, + 128292, 128291, 128290, 68456, 68466, 68448, 68451, 68459, 68460, 68453, + 68450, 68454, 68462, 68464, 68465, 68457, 68452, 68455, 68458, 68449, + 68461, 68463, 68477, 68473, 68474, 68476, 68472, 68478, 68479, 68475, + 68424, 68437, 68419, 68427, 68434, 68435, 68416, 68431, 68418, 68422, + 68430, 68433, 68436, 68425, 68420, 68423, 68426, 68417, 68429, 68421, + 68432, 68428, 68445, 68441, 68442, 68444, 68440, 68446, 68447, 68443, + 9088, 8747, 10767, 10773, 10776, 10780, 10778, 10775, 10777, 10779, + 10766, 9134, 65529, 65531, 65530, 9892, 8745, 10825, 10823, 10820, 10819, + 10816, 10827, 8253, 8890, 10812, 117901, 117903, 9688, 129942, 129969, + 129972, 9689, 129936, 11800, 8766, 121624, 11845, 11846, 121608, 121609, + 9959, 11873, 8487, 8276, 191, 161, 8290, 8292, 8291, 128229, 118471, + 118465, 127982, 129311, 127875, 127983, 127971, 12292, 9979, 127886, + 128304, 128122, 128121, 43453, 43454, 43455, 43457, 43421, 43422, 43426, + 43427, 43398, 43397, 43399, 43407, 43408, 43409, 43412, 43402, 43403, + 43418, 43416, 43428, 43423, 43431, 43432, 43413, 43414, 43410, 43411, + 43429, 43430, 43401, 43435, 43436, 43441, 43439, 43440, 43424, 43425, + 43419, 43420, 43415, 43417, 43396, 43405, 43442, 43437, 43433, 43438, + 43434, 43404, 43406, 43400, 43458, 43466, 43467, 43459, 43465, 43461, + 43464, 43468, 43463, 43486, 43462, 43487, 43460, 43471, 43456, 43469, + 43393, 43443, 43395, 43394, 43392, 43448, 43449, 43444, 43450, 43445, + 43446, 43447, 43452, 43451, 43477, 43476, 43479, 43478, 43475, 43474, + 43472, 43481, 43473, 43480, 129753, 129724, 128086, 128377, 10781, + 102865, 102866, 102816, 102817, 102818, 102819, 102820, 102821, 102822, + 102823, 102824, 102825, 102826, 102827, 102828, 102829, 102830, 102831, + 102832, 102833, 102834, 102835, 102836, 102837, 102838, 102839, 102840, + 102841, 102842, 102843, 102844, 102845, 102846, 102847, 102848, 102849, + 102850, 102851, 102852, 102853, 102854, 102855, 102856, 102857, 102858, + 102859, 102860, 102861, 102862, 102863, 102864, 129337, 9795, 9909, + 129513, 69786, 69787, 69785, 69793, 69792, 69763, 69764, 69770, 69772, + 69784, 69783, 69791, 69790, 69767, 69768, 69765, 69766, 69777, 69789, + 69782, 69794, 69804, 69805, 69806, 69798, 69797, 69779, 69778, 69776, + 69775, 69781, 69780, 69774, 69773, 69796, 69795, 69788, 69801, 69807, + 69802, 69799, 69803, 69800, 69769, 69771, 69760, 69818, 69761, 69817, + 69762, 69822, 69823, 69825, 69824, 69826, 69808, 69814, 69816, 69811, + 69812, 69809, 69810, 69813, 69815, 69821, 69837, 69819, 69820, 12142, + 12164, 12060, 12157, 12100, 12149, 12184, 12191, 12227, 12068, 12174, + 12234, 12205, 12134, 12168, 12219, 12189, 12088, 12090, 12096, 12160, + 12182, 12224, 12190, 12147, 12114, 12118, 12058, 12176, 12075, 12112, + 12045, 12170, 12124, 12070, 12194, 12109, 12229, 12196, 12139, 12056, + 12099, 12034, 12084, 12136, 12120, 12044, 12111, 12094, 12125, 12243, + 12238, 12082, 12159, 12063, 12215, 12062, 12042, 12241, 12067, 12235, + 12043, 12140, 12119, 12207, 12123, 12133, 12222, 12117, 12226, 12245, + 12214, 12217, 12236, 12155, 12188, 12113, 12065, 12198, 12066, 12146, + 12171, 12225, 12200, 12121, 12093, 12095, 12221, 12092, 12216, 12231, + 12054, 12218, 12179, 12037, 12173, 12072, 12046, 12127, 12152, 12049, + 12074, 12107, 12208, 12212, 12041, 12210, 12131, 12033, 12039, 12199, + 12085, 12128, 12161, 12162, 12233, 12165, 12192, 12077, 12201, 12061, + 12105, 12040, 12240, 12102, 12153, 12032, 12080, 12167, 12048, 12156, + 12059, 12126, 12158, 12050, 12183, 12204, 12097, 12239, 12053, 12078, + 12150, 12071, 12187, 12186, 12223, 12228, 12104, 12098, 12064, 12036, + 12057, 12163, 12178, 12185, 12154, 12203, 12083, 12087, 12135, 12151, + 12202, 12035, 12122, 12141, 12180, 12144, 12076, 12052, 12115, 12091, + 12108, 12169, 12143, 12148, 12130, 12089, 12211, 12073, 12101, 12138, + 12103, 12209, 12047, 12220, 12172, 12129, 12166, 12242, 12237, 12145, + 12106, 12081, 12244, 12038, 12086, 12055, 12181, 12197, 12193, 12175, + 12116, 12110, 12177, 12137, 12230, 12213, 12195, 12069, 12079, 12206, + 12051, 12232, 12132, 129432, 3240, 3293, 3225, 3235, 3230, 3205, 3206, + 3216, 3220, 3234, 3233, 3239, 3238, 983205, 3251, 3250, 3249, 3248, 3232, + 3231, 3237, 3236, 3211, 3296, 3212, 3297, 3253, 3209, 3210, 3218, 3219, + 3207, 3208, 3254, 3255, 3256, 3245, 3244, 3227, 3226, 3224, 3223, 3229, + 3228, 3222, 3221, 3243, 3242, 3214, 3215, 3294, 3257, 3246, 3247, 3285, + 3315, 3201, 3200, 3204, 3260, 3261, 3202, 3313, 3314, 3277, 3203, 3292, + 3286, 3262, 3272, 3276, 3265, 3266, 3267, 3268, 3298, 3299, 3274, 3275, + 3263, 3264, 3270, 3271, 3307, 3306, 3309, 3308, 3305, 3304, 3302, 3311, + 3303, 3310, 12543, 110885, 110884, 110886, 12450, 984009, 984008, 984007, + 984010, 110887, 110888, 110881, 110880, 110882, 110592, 12499, 984002, 984005, 984003, 984006, 984004, 12496, 12505, 12508, 12502, 12511, 110583, 110584, 110585, 110586, 110587, 110589, 110590, 110576, 110577, 110578, 110579, 110581, 110582, 12510, 12513, 12514, 12512, 12531, 12490, - 12493, 12491, 12494, 12492, 12789, 12792, 12790, 12793, 12791, 12795, - 12798, 12796, 12799, 12797, 12533, 12534, 110933, 12784, 12787, 12483, - 12526, 110949, 110948, 110950, 12515, 12519, 12517, 110951, 12788, 12785, - 12786, 12794, 12449, 12455, 12451, 12457, 12453, 12469, 12475, 12471, - 12477, 12473, 12480, 12487, 12482, 12489, 12485, 12460, 12466, 12462, - 12468, 12464, 12495, 12504, 12498, 12507, 12501, 12459, 12465, 12461, - 12467, 12463, 12497, 12506, 12500, 12509, 12503, 12521, 12524, 12522, - 12525, 12523, 12479, 12486, 12481, 12488, 12484, 12535, 12537, 12536, - 12538, 12532, 12470, 12476, 12472, 12478, 12474, 12527, 12529, 12528, - 12530, 12516, 12520, 12518, 12456, 12452, 12458, 12454, 12542, 12543, + 12493, 12491, 12494, 12492, 12449, 110952, 12789, 12792, 12790, 12793, + 12791, 12795, 12798, 12796, 12799, 12797, 12533, 12534, 110933, 12784, + 12526, 110949, 110948, 110950, 12515, 12519, 12517, 12787, 12483, 110951, + 12788, 12785, 12786, 12794, 12455, 12451, 12457, 12453, 12469, 12475, + 12471, 12477, 12473, 12480, 12487, 12482, 12489, 12485, 12460, 12466, + 12462, 12468, 12464, 12495, 12504, 12498, 12507, 12501, 12459, 12465, + 12461, 12467, 12463, 12497, 12506, 12500, 12509, 12503, 12521, 12524, + 12522, 12525, 12523, 12479, 12486, 12481, 12488, 12484, 12535, 12537, + 12536, 12538, 12532, 12470, 12476, 12472, 12478, 12474, 12527, 12529, + 12528, 12530, 12516, 12520, 12518, 12456, 12452, 12458, 12454, 12542, 12541, 12539, 12448, 12540, 12444, 12443, 73476, 73477, 73487, 73523, 73498, 73497, 73503, 73502, 73508, 73507, 73501, 73500, 73506, 73505, 73480, 73481, 73482, 73483, 73484, 73485, 73478, 73479, 73494, 73504, @@ -10990,141 +11256,156 @@ static const unsigned int dawg_pos_to_codepoint[] = { 118350, 118347, 118344, 118345, 118343, 118349, 118346, 118305, 118321, 118301, 118299, 118298, 118310, 118311, 118308, 118300, 118337, 11004, 10201, 10200, 10782, 128995, 129002, 128308, 128997, 128993, 129000, - 9711, 10923, 10925, 8382, 9790, 127772, 127767, 65, 258, 7858, 7856, - 7854, 7862, 7860, 550, 480, 7840, 512, 196, 478, 197, 506, 7680, 256, - 983564, 194, 7848, 7846, 7844, 7852, 7850, 461, 7842, 260, 983590, - 983592, 192, 193, 514, 195, 570, 198, 508, 482, 42946, 393, 11373, 42808, - 42810, 42802, 42804, 42806, 42812, 66, 386, 42902, 7686, 7684, 7682, 385, - 579, 42822, 42932, 67, 199, 7688, 264, 268, 262, 42948, 391, 42898, 266, - 571, 42960, 42796, 42798, 42862, 42931, 68, 498, 453, 42951, 272, 7696, - 7698, 270, 395, 7694, 7692, 7690, 394, 497, 452, 42964, 42962, 69, 552, - 7708, 202, 983586, 7874, 7872, 7870, 983584, 7878, 7876, 7704, 282, 278, - 983598, 983600, 7864, 516, 203, 7868, 7706, 274, 7700, 7702, 983570, - 983572, 983574, 7866, 280, 983594, 983596, 200, 201, 518, 276, 582, 439, - 494, 440, 42786, 42788, 42858, 208, 425, 330, 70, 401, 7710, 42904, 71, - 290, 284, 486, 500, 286, 7712, 42912, 403, 288, 484, 577, 42938, 42940, - 42942, 404, 983199, 72, 7722, 7720, 292, 542, 7718, 11367, 7716, 7714, - 42922, 294, 11381, 502, 42790, 73, 520, 7882, 304, 207, 7726, 206, 463, - 298, 983566, 296, 7724, 7880, 302, 983604, 983606, 204, 205, 522, 300, - 407, 42873, 42875, 42877, 42882, 42884, 42886, 406, 42860, 74, 308, - 42930, 983608, 584, 75, 310, 488, 42818, 11369, 7730, 42816, 42820, 7728, - 7732, 42914, 408, 76, 42925, 573, 11360, 7734, 7736, 11362, 319, 456, - 321, 315, 7740, 317, 42824, 313, 7738, 983610, 42970, 42972, 455, 77, - 7742, 7746, 7744, 983612, 11374, 7930, 7932, 42966, 78, 325, 7754, 327, - 459, 544, 7752, 413, 504, 323, 42896, 7750, 7748, 42916, 209, 458, 79, - 42826, 42828, 332, 7760, 7762, 415, 212, 7892, 7890, 7888, 7896, 7894, - 465, 214, 554, 558, 560, 7884, 524, 336, 490, 492, 216, 510, 213, 7758, - 7756, 556, 983576, 983578, 983580, 416, 7902, 7900, 7898, 7906, 7904, - 7886, 210, 211, 526, 334, 42944, 400, 390, 42934, 418, 42830, 546, 80, - 42834, 11363, 42832, 42836, 7764, 420, 7766, 42958, 81, 42840, 42838, 82, - 342, 344, 7770, 7772, 7768, 528, 983614, 11364, 340, 7774, 530, 42918, - 588, 42842, 42997, 42923, 42814, 398, 42844, 42955, 83, 352, 7782, 350, - 536, 348, 346, 7780, 7778, 7784, 7776, 42956, 42953, 11390, 983582, - 42920, 42949, 586, 42926, 42891, 7838, 42968, 42924, 399, 84, 354, 7792, - 538, 356, 574, 7788, 7786, 7790, 430, 428, 358, 42878, 11375, 11376, + 9711, 10923, 10925, 8382, 9790, 127772, 127767, 65, 122752, 195, 258, + 7858, 7856, 7854, 7862, 7860, 194, 7848, 7846, 7844, 7852, 7850, 461, + 550, 480, 7840, 512, 196, 478, 197, 506, 7680, 256, 983564, 7842, 260, + 983590, 983592, 192, 193, 514, 570, 198, 508, 482, 42946, 393, 11373, + 42808, 42810, 42802, 42804, 42806, 42812, 66, 386, 42902, 7686, 7684, + 7682, 385, 579, 122688, 122696, 122698, 122701, 122705, 42822, 42932, 67, + 199, 7688, 264, 268, 262, 42948, 391, 42898, 266, 571, 42960, 42973, + 122740, 42796, 42798, 42862, 42931, 68, 498, 453, 42951, 272, 7696, 7698, + 270, 395, 7694, 7692, 7690, 394, 497, 452, 42964, 42962, 69, 122753, 276, + 552, 7708, 202, 983586, 7874, 7872, 7870, 983584, 7878, 7876, 7704, 282, + 278, 983598, 983600, 7864, 516, 203, 7868, 7706, 274, 7700, 7702, 983570, + 983572, 983574, 7866, 280, 983594, 983596, 200, 201, 518, 582, 439, 494, + 440, 42786, 42788, 42858, 208, 425, 330, 70, 401, 7710, 42904, 71, 290, + 284, 486, 500, 286, 7712, 42912, 403, 288, 484, 577, 42938, 42940, 42942, + 404, 983199, 72, 7722, 7720, 292, 542, 7718, 11367, 7716, 7714, 42922, + 294, 11381, 502, 42790, 73, 520, 7882, 304, 207, 7726, 206, 463, 298, + 983566, 296, 7724, 7880, 302, 983604, 983606, 204, 205, 522, 300, 407, + 42873, 42875, 42877, 42882, 42884, 42886, 406, 42860, 74, 308, 42930, + 983608, 584, 75, 310, 488, 42818, 11369, 7730, 42816, 42820, 7728, 7732, + 42914, 408, 76, 7734, 7736, 11360, 11362, 319, 456, 321, 315, 7740, 317, + 42824, 313, 7738, 42925, 573, 983610, 42970, 42972, 455, 77, 7742, 7746, + 7744, 983612, 11374, 7930, 7932, 42966, 78, 325, 7754, 327, 459, 7752, + 544, 413, 504, 323, 42896, 7750, 7748, 42916, 209, 458, 79, 42826, 42828, + 332, 7760, 7762, 415, 212, 7892, 7890, 7888, 7896, 7894, 122738, 465, + 214, 554, 558, 560, 7884, 524, 336, 416, 7902, 7900, 7898, 7906, 7904, + 7886, 490, 492, 216, 510, 213, 7758, 7756, 556, 983576, 983578, 983580, + 210, 211, 526, 334, 42944, 400, 390, 42934, 418, 42830, 546, 80, 42834, + 11363, 42832, 42836, 7764, 420, 7766, 42958, 122734, 122730, 122728, + 122744, 81, 42840, 42838, 82, 7774, 42978, 983614, 11364, 342, 344, 7770, + 7772, 7768, 528, 340, 530, 42918, 588, 42842, 42997, 42923, 122732, + 42814, 398, 122750, 42844, 42955, 83, 352, 7782, 350, 536, 348, 346, + 7780, 7778, 7784, 7776, 42956, 42953, 11390, 983582, 42920, 42949, 43884, + 43885, 42924, 399, 586, 42926, 42891, 7838, 42968, 84, 354, 7792, 538, + 356, 574, 7788, 7786, 7790, 430, 428, 358, 42878, 122742, 11375, 11376, 42893, 42928, 42880, 412, 42929, 581, 222, 42852, 42854, 388, 444, 423, 42794, 42792, 85, 219, 7798, 467, 220, 473, 475, 471, 469, 7794, 532, - 368, 7908, 431, 7916, 7914, 7912, 7920, 7918, 7910, 362, 7802, 983568, - 983620, 983622, 370, 983616, 983618, 360, 7800, 7796, 217, 218, 534, 364, - 366, 42936, 580, 433, 86, 42846, 7806, 7804, 434, 42850, 42906, 42908, - 42910, 42856, 42848, 87, 372, 7812, 7816, 7814, 7808, 7810, 11378, 503, - 88, 7820, 7818, 89, 374, 376, 7924, 7822, 7922, 435, 7926, 7934, 221, - 562, 7928, 590, 540, 90, 7824, 381, 377, 11371, 7826, 379, 7828, 11391, - 437, 42950, 548, 306, 338, 10013, 43007, 43005, 43006, 43003, 43004, - 42999, 450, 7461, 684, 664, 685, 662, 122638, 446, 661, 426, 674, 451, - 122634, 7431, 7430, 7459, 618, 641, 671, 122628, 7436, 7439, 7440, 630, - 7445, 640, 7438, 7449, 43846, 42870, 7451, 11387, 122626, 122640, 43002, - 7450, 665, 7427, 610, 667, 7424, 7425, 7428, 7429, 42800, 668, 7434, - 7435, 7437, 628, 7448, 42927, 42801, 7452, 7456, 7457, 655, 7458, 663, - 122639, 42895, 443, 447, 448, 449, 660, 673, 7460, 422, 7547, 7550, 97, - 259, 7859, 7857, 7855, 7863, 7861, 551, 481, 7841, 513, 228, 479, 229, - 507, 7681, 7834, 7567, 257, 983565, 226, 7849, 7847, 7845, 7853, 7851, - 462, 7843, 261, 983591, 983593, 224, 225, 515, 227, 11365, 43825, 230, - 983624, 509, 483, 42947, 593, 7568, 42809, 42811, 42803, 42805, 42807, - 42813, 98, 387, 42903, 7687, 7532, 7552, 7685, 7683, 595, 384, 43824, - 43827, 629, 43853, 43837, 43838, 43826, 42823, 7447, 42933, 99, 231, - 7689, 265, 597, 269, 263, 42900, 122653, 392, 42899, 267, 572, 43859, - 43860, 43861, 42961, 666, 631, 606, 42797, 42799, 42863, 100, 42952, 273, - 396, 598, 7697, 7699, 545, 271, 122661, 7533, 7695, 599, 7569, 7553, - 7693, 7691, 676, 122642, 122649, 7839, 567, 607, 644, 305, 42965, 43848, - 43850, 42963, 499, 454, 675, 677, 43878, 568, 42865, 101, 553, 7709, 234, - 983587, 7875, 7873, 7871, 983585, 7879, 7877, 7705, 283, 279, 983599, - 983601, 7865, 517, 235, 11384, 7869, 7707, 275, 7701, 7703, 983571, - 983573, 983575, 43828, 7867, 281, 983595, 983597, 232, 233, 519, 277, - 7570, 583, 42787, 42789, 331, 43836, 122644, 643, 122635, 122636, 7563, - 646, 7576, 658, 441, 659, 495, 122648, 7578, 442, 42859, 240, 102, 7534, - 7554, 402, 7711, 42905, 681, 122624, 103, 291, 285, 487, 501, 287, 7713, - 7555, 42913, 608, 289, 485, 578, 42939, 42941, 42943, 611, 983200, 104, - 7723, 7721, 293, 543, 7719, 11368, 7717, 7715, 7830, 42901, 614, 295, - 11382, 983631, 983632, 42791, 615, 405, 105, 238, 464, 239, 7727, 983602, - 983588, 983603, 7883, 521, 299, 983567, 303, 983605, 983607, 297, 7725, - 7881, 236, 237, 523, 301, 616, 122650, 7574, 42874, 42876, 7545, 42883, - 42885, 42887, 43876, 43840, 617, 7548, 43873, 42861, 106, 309, 669, 496, + 368, 7908, 122746, 7910, 431, 7916, 7914, 7912, 7920, 7918, 362, 7802, + 983568, 983620, 983622, 122748, 370, 983616, 983618, 360, 7800, 7796, + 217, 218, 534, 364, 366, 42936, 580, 433, 86, 42846, 7806, 7804, 434, + 42850, 42906, 42908, 42910, 42856, 42848, 87, 372, 7812, 7816, 7814, + 7808, 7810, 11378, 503, 88, 7820, 7818, 89, 7934, 374, 376, 7924, 7822, + 7922, 435, 7926, 221, 562, 7928, 590, 540, 90, 7824, 381, 377, 11371, + 7826, 379, 7828, 11391, 437, 42950, 548, 306, 338, 10013, 43007, 43005, + 43006, 43003, 43004, 42999, 450, 7461, 684, 664, 685, 660, 122710, 673, + 662, 122638, 446, 426, 674, 451, 122634, 665, 7427, 122691, 7431, 7430, + 7459, 610, 122672, 667, 618, 641, 122678, 671, 122628, 7436, 7439, 7440, + 630, 7445, 640, 43846, 122677, 7438, 7449, 42870, 7451, 11387, 122626, + 122640, 43002, 7450, 7424, 7425, 7428, 7429, 42800, 668, 7434, 7435, + 7437, 628, 7448, 42927, 42801, 7452, 7456, 7457, 655, 7458, 663, 122639, + 42895, 447, 661, 122682, 448, 449, 443, 7460, 422, 7547, 7550, 97, 259, + 7859, 7857, 7855, 7863, 7861, 226, 7849, 7847, 7845, 7853, 7851, 462, + 551, 481, 7841, 513, 228, 479, 229, 507, 7681, 7834, 7567, 257, 983565, + 7843, 261, 983591, 983593, 224, 225, 515, 227, 11365, 43825, 230, 983624, + 509, 483, 42947, 593, 7568, 42809, 42811, 42803, 42805, 42807, 42813, 98, + 387, 42903, 7687, 7532, 7552, 7685, 7683, 595, 384, 122707, 122708, 629, + 122692, 122690, 122689, 43824, 122686, 122694, 122695, 122699, 122700, + 43827, 122703, 122697, 122702, 122706, 122687, 43853, 43837, 43838, + 43826, 42823, 42933, 122683, 7447, 99, 231, 7689, 265, 597, 269, 122769, + 122768, 122770, 122653, 263, 42900, 392, 42899, 267, 572, 43859, 43860, + 43861, 122685, 42961, 631, 122741, 666, 606, 42797, 42799, 42863, 100, + 599, 122669, 7569, 42952, 273, 396, 598, 7697, 7699, 545, 271, 7533, + 122661, 7695, 7553, 7693, 7691, 122771, 122655, 122656, 122657, 676, + 122667, 122642, 122649, 7839, 567, 607, 644, 305, 42965, 43848, 43850, + 42963, 499, 454, 675, 677, 122670, 43878, 568, 42865, 101, 553, 7709, + 234, 983587, 7875, 7873, 7871, 983585, 7879, 7877, 7705, 283, 279, + 983599, 983601, 7865, 517, 235, 11384, 7869, 7707, 275, 7701, 7703, + 983571, 983573, 983575, 43828, 7867, 281, 983595, 983597, 232, 233, 519, + 277, 7570, 583, 42787, 42789, 331, 43836, 122644, 643, 122635, 122636, + 646, 7563, 7576, 122722, 42859, 240, 122671, 658, 441, 659, 495, 122648, + 7578, 442, 102, 7534, 7554, 402, 7711, 42905, 681, 122624, 103, 291, 285, + 487, 485, 122693, 501, 287, 7713, 7555, 42913, 608, 289, 611, 122673, + 578, 42939, 42941, 42943, 983200, 104, 7723, 7721, 293, 543, 7719, 11368, + 7717, 7715, 295, 122674, 7830, 42901, 614, 122714, 11382, 983631, 983632, + 42791, 615, 405, 105, 238, 464, 239, 7727, 983602, 983588, 983603, 7883, + 521, 299, 983567, 303, 983605, 983607, 297, 7725, 7881, 236, 237, 523, + 301, 616, 122650, 7574, 122736, 42874, 42876, 7545, 42883, 42885, 42887, + 43876, 43840, 617, 7548, 43873, 122717, 42861, 106, 309, 669, 496, 983609, 585, 107, 311, 489, 42819, 11370, 7731, 42817, 42821, 7729, 7733, 7556, 42915, 409, 312, 108, 620, 122643, 410, 316, 7741, 564, 318, 7735, 7737, 43832, 11361, 619, 43833, 320, 122662, 42825, 314, 7739, 43831, - 621, 42894, 122641, 7557, 983611, 322, 42971, 411, 622, 122629, 43829, - 383, 7836, 7835, 7837, 682, 683, 42866, 457, 109, 7743, 43834, 7535, - 7558, 7747, 7745, 983613, 625, 7931, 7933, 42967, 42867, 110, 326, 7755, - 43835, 565, 328, 414, 7753, 626, 122663, 7536, 505, 324, 42897, 7751, - 7749, 7559, 627, 42917, 241, 329, 983589, 42868, 460, 111, 244, 7893, - 7891, 7889, 7897, 7895, 466, 246, 555, 559, 561, 7885, 525, 337, 42827, + 621, 42894, 122641, 7557, 983611, 322, 42971, 411, 622, 122727, 122629, + 43829, 383, 7836, 7835, 7837, 122774, 122716, 42866, 682, 683, 457, 109, + 7743, 43834, 7535, 7558, 7747, 7745, 983613, 625, 7931, 7933, 42967, + 42867, 110, 326, 7755, 43835, 565, 328, 7753, 414, 626, 7536, 122663, + 505, 324, 42897, 7751, 7749, 7559, 627, 42917, 241, 329, 983589, 42868, + 460, 111, 244, 7893, 7891, 7889, 7897, 7895, 122739, 466, 246, 555, 559, + 561, 7885, 525, 337, 417, 7903, 7901, 7899, 7907, 7905, 7887, 42827, 11386, 42829, 333, 7761, 7763, 491, 493, 248, 511, 245, 7759, 7757, 557, - 983577, 983579, 983581, 417, 7903, 7901, 7899, 7907, 7905, 7887, 242, - 243, 527, 335, 122651, 42945, 596, 983625, 983626, 7575, 43839, 43874, - 603, 7571, 42935, 419, 42831, 547, 112, 42835, 7549, 42833, 42837, 7765, - 7537, 7560, 421, 7767, 42959, 632, 113, 42841, 672, 587, 42839, 569, 114, - 343, 43849, 345, 7771, 7773, 7769, 529, 638, 7539, 122646, 7775, 636, - 983615, 637, 122664, 7538, 341, 531, 7561, 42919, 589, 43847, 42843, - 42998, 604, 7572, 605, 639, 122625, 600, 122631, 8580, 42815, 122627, - 42869, 42845, 612, 115, 347, 7781, 353, 7783, 351, 537, 349, 122654, - 7779, 7785, 7777, 42957, 42954, 575, 983583, 122665, 7540, 7562, 42921, - 642, 42892, 43872, 601, 983629, 983630, 7573, 602, 43851, 43852, 609, - 43830, 223, 7441, 7442, 7443, 7455, 7454, 7453, 42969, 645, 43845, 116, - 355, 7793, 539, 566, 357, 11366, 7831, 7789, 7787, 122666, 7541, 7791, - 427, 429, 122633, 648, 359, 679, 122647, 122652, 7546, 254, 42853, 42855, - 389, 445, 424, 7446, 42795, 397, 613, 686, 687, 7433, 42879, 7444, 43842, - 43841, 43843, 43844, 7432, 633, 43880, 122645, 634, 122632, 11385, 635, - 647, 122637, 652, 983627, 983628, 592, 594, 7426, 623, 624, 654, 122630, - 43857, 477, 7543, 670, 42881, 653, 42871, 680, 678, 43879, 11383, 42793, - 117, 649, 43855, 251, 7799, 468, 252, 474, 476, 472, 470, 7795, 533, 369, - 7909, 432, 7917, 7915, 7913, 7921, 7919, 7911, 363, 7803, 983569, 983621, - 983623, 371, 983617, 983619, 7577, 367, 361, 7801, 7797, 249, 43854, - 42937, 250, 535, 365, 43858, 650, 7551, 7531, 43856, 42872, 43875, 118, - 42847, 7807, 7564, 11380, 11377, 7805, 651, 42851, 42907, 42909, 42911, - 42857, 42849, 119, 373, 7813, 7817, 7815, 7809, 7811, 7832, 11379, 120, - 7821, 7819, 43863, 43864, 43865, 43862, 7565, 121, 375, 255, 7925, 7823, - 7923, 436, 7927, 7935, 43866, 591, 253, 563, 7929, 7833, 541, 122, 378, - 7825, 657, 382, 11372, 7827, 380, 7829, 576, 438, 7542, 7566, 656, 549, - 64256, 64259, 64260, 64257, 64258, 307, 64261, 64262, 339, 8347, 8340, - 8336, 8337, 8341, 7522, 11388, 8342, 8343, 8344, 8345, 8338, 8346, 7523, - 8348, 7524, 7525, 8339, 129726, 127811, 129388, 129897, 129916, 129947, - 10203, 10202, 129899, 129917, 117902, 128494, 12296, 10641, 10643, 11058, - 11056, 10576, 10571, 10570, 10574, 12304, 10647, 123, 9128, 9129, 9127, - 12300, 8968, 9948, 10714, 12298, 8220, 11816, 11780, 129287, 129284, - 129285, 129283, 129286, 9686, 11240, 9612, 129977, 117924, 118288, - 129970, 118285, 118283, 118435, 118440, 129940, 129932, 128379, 128709, - 11804, 10204, 9614, 9615, 129999, 10197, 8596, 8700, 8697, 8622, 10568, - 8660, 10500, 8654, 8621, 11012, 8703, 11020, 129112, 11108, 11788, 10181, - 8907, 9609, 8216, 11814, 128488, 91, 9123, 9121, 10639, 10637, 8261, - 10635, 11863, 11861, 9122, 11778, 10703, 129900, 11785, 117771, 129985, - 128492, 118434, 118441, 9610, 9613, 12308, 129998, 8867, 12302, 10627, - 12310, 10629, 12314, 12312, 10712, 128398, 9611, 10620, 8970, 130027, - 130019, 8905, 40, 9117, 9115, 9116, 11808, 9144, 9001, 117856, 118265, - 10748, 171, 117774, 128269, 117920, 117846, 117922, 117911, 117861, - 117762, 117918, 117880, 10553, 10154, 1422, 117832, 117906, 117908, - 129307, 4054, 4056, 117872, 117876, 9958, 8294, 8237, 8234, 8206, 8592, - 10563, 11074, 11083, 11082, 10611, 129973, 10618, 10615, 11070, 8676, - 8633, 10525, 129032, 8619, 11064, 8698, 10566, 129040, 129024, 8602, - 11024, 11025, 8610, 11066, 11065, 129028, 129176, 129044, 8617, 8695, - 8612, 10527, 129216, 8646, 10521, 129192, 129184, 11144, 11013, 10603, - 10599, 10590, 10582, 8637, 10594, 10602, 10598, 10586, 10578, 8636, 8651, - 129778, 129088, 129092, 11104, 11136, 11130, 983241, 11174, 11172, - 129064, 129060, 129056, 129072, 129068, 11120, 11114, 11140, 129168, - 10510, 8666, 129186, 11067, 11069, 11068, 11244, 11061, 11060, 11062, - 11063, 8606, 8678, 129172, 8604, 8656, 10498, 8653, 10502, 10523, 10508, - 8672, 129194, 129076, 129188, 8701, 8647, 129783, 129190, 128620, 8668, - 129080, 129104, 129084, 11077, 9804, 128006, 7213, 7221, 7216, 7220, + 983577, 983579, 983581, 242, 243, 527, 335, 122651, 419, 122718, 547, + 122719, 42945, 596, 983625, 983626, 7575, 43839, 43874, 603, 7571, 42935, + 122720, 42831, 112, 42835, 7549, 42833, 42837, 7765, 7537, 7560, 421, + 7767, 42959, 632, 122675, 122735, 122731, 122729, 122745, 113, 42841, + 672, 587, 42839, 122676, 569, 114, 42843, 122772, 343, 43849, 345, 7771, + 7773, 7769, 529, 638, 7539, 122646, 7775, 636, 122721, 637, 122679, + 983615, 7538, 122664, 341, 531, 7561, 42919, 589, 43847, 42998, 604, + 7572, 605, 122625, 122733, 122724, 639, 600, 122631, 8580, 42815, 122627, + 122751, 122726, 42869, 42845, 612, 115, 347, 7781, 353, 7783, 351, 537, + 349, 122654, 7779, 7785, 7777, 42957, 42954, 575, 983583, 7540, 122665, + 7562, 42921, 642, 42892, 43872, 601, 983629, 983630, 7573, 602, 609, + 43830, 43851, 43852, 223, 7441, 7442, 7443, 7455, 7454, 7453, 42969, + 122715, 122723, 122737, 43845, 122712, 122713, 645, 116, 355, 7793, 539, + 566, 357, 11366, 7831, 7789, 7787, 7541, 122666, 7791, 429, 122633, 427, + 648, 359, 679, 122668, 122647, 122652, 7546, 122684, 254, 42853, 42855, + 122659, 122658, 389, 445, 424, 7446, 42795, 678, 122680, 43879, 122743, + 397, 7433, 42879, 7444, 43842, 43841, 7432, 43843, 43844, 633, 43880, + 122711, 634, 122632, 122645, 11385, 635, 122704, 647, 122637, 652, + 983627, 983628, 592, 594, 7426, 613, 686, 687, 623, 624, 654, 122630, + 43857, 477, 7543, 670, 42881, 653, 42871, 122660, 680, 11383, 42793, 117, + 649, 43855, 251, 7799, 468, 252, 474, 476, 472, 470, 7795, 533, 369, + 7909, 122747, 7911, 432, 7917, 7915, 7913, 7921, 7919, 363, 7803, 983569, + 983621, 983623, 122749, 371, 983617, 983619, 7577, 367, 361, 7801, 7797, + 249, 43854, 42937, 250, 535, 365, 43858, 650, 7551, 7531, 43856, 42872, + 43875, 118, 42847, 7807, 651, 122681, 11377, 11380, 7564, 7805, 42851, + 42907, 42909, 42911, 42857, 42849, 119, 373, 7813, 7817, 7815, 7809, + 7811, 7832, 11379, 122725, 120, 7821, 7819, 43863, 43864, 43865, 43862, + 7565, 121, 375, 255, 7925, 7823, 7923, 436, 7927, 122709, 7935, 43866, + 591, 253, 563, 7929, 7833, 541, 122, 378, 7825, 657, 382, 11372, 7827, + 380, 7829, 576, 438, 7542, 7566, 656, 549, 64256, 64259, 64260, 64257, + 64258, 122773, 64261, 307, 64262, 339, 8347, 8340, 122832, 8336, 8337, + 8341, 7522, 11388, 8342, 8343, 8344, 8345, 8338, 8346, 7523, 8348, 7524, + 7525, 8349, 8339, 8350, 8351, 129726, 127811, 129388, 129897, 129916, + 129947, 10203, 10202, 129899, 129917, 117902, 128494, 12296, 10641, + 10643, 11058, 11056, 10576, 10571, 10570, 10574, 12304, 10647, 123, 9128, + 9129, 9127, 12300, 8968, 9948, 10714, 12298, 8220, 11816, 11780, 129287, + 129284, 129285, 129283, 129286, 9686, 11240, 9612, 129977, 117924, + 118288, 129970, 118285, 129012, 118283, 118435, 118440, 129940, 129932, + 128379, 128709, 11804, 10204, 9614, 9615, 129999, 10197, 8596, 8700, + 8697, 8622, 10568, 8660, 10500, 8654, 8621, 11012, 8703, 11020, 129112, + 11108, 11788, 10181, 8907, 9609, 8216, 11814, 128488, 91, 9123, 9121, + 10639, 10637, 8261, 10635, 11863, 11861, 9122, 11778, 10703, 129900, + 11785, 117771, 129985, 128492, 118434, 118441, 9610, 9613, 12308, 129998, + 8867, 12302, 10627, 12310, 10629, 12314, 12312, 10712, 128398, 9611, + 10620, 8970, 130027, 130019, 8905, 40, 9117, 9115, 11874, 9116, 11808, + 9144, 9001, 117856, 118265, 10748, 171, 117774, 128269, 117920, 117846, + 117922, 117911, 117861, 117762, 117918, 117880, 10553, 10154, 1422, + 117832, 117906, 117908, 129307, 4054, 4056, 117872, 117876, 9958, 8294, + 8237, 8234, 8206, 8592, 10563, 11074, 11083, 11082, 10611, 129973, 10618, + 10615, 11070, 8676, 8633, 10525, 129032, 8619, 11064, 8698, 10566, + 129040, 129024, 8602, 11024, 11025, 8610, 11066, 11065, 129028, 129176, + 129044, 8617, 8695, 8612, 10527, 129216, 8646, 10521, 129192, 129184, + 11144, 11013, 10603, 10599, 10590, 10582, 8637, 10594, 10602, 10598, + 10586, 10578, 8636, 8651, 129778, 129088, 129092, 11104, 11136, 11130, + 983241, 11174, 11172, 129064, 129060, 129056, 129072, 129068, 11120, + 11114, 11140, 129168, 10510, 8666, 129785, 129186, 11067, 11069, 11068, + 11244, 11061, 11060, 11062, 11063, 8606, 8678, 129172, 8604, 8656, 10498, + 8653, 10502, 10523, 10508, 8672, 129194, 129076, 129188, 8701, 8647, + 129783, 129190, 128620, 8668, 129080, 129104, 129084, 11077, 121617, + 121618, 121619, 121620, 121622, 121621, 121623, 118513, 121627, 121600, + 121602, 121601, 121603, 121607, 121605, 121604, 121606, 118515, 118514, + 121625, 121626, 118516, 118517, 9804, 128006, 7213, 7221, 7216, 7220, 7215, 7214, 7217, 7218, 7219, 7170, 7169, 7168, 7184, 7183, 7182, 7247, 7193, 7180, 7188, 7187, 7186, 7185, 7172, 7171, 7198, 7197, 7190, 7189, 7173, 7177, 7181, 7192, 7191, 7246, 7245, 7179, 7178, 7175, 7174, 7201, @@ -11136,478 +11417,494 @@ static const unsigned int dawg_pos_to_codepoint[] = { 8918, 60, 118480, 128210, 127898, 127819, 129461, 128626, 128955, 128969, 128943, 11212, 128964, 10099, 128648, 10098, 9617, 128937, 128949, 128978, 128960, 129653, 128910, 10072, 128930, 128504, 9735, 128498, - 128497, 6429, 6404, 6403, 6412, 6430, 6411, 6421, 6410, 6405, 6415, 6425, - 6426, 6427, 6419, 6418, 6407, 6406, 6414, 6413, 6409, 6408, 6402, 6401, - 6417, 6416, 6428, 6423, 6420, 6422, 6424, 6458, 6457, 6459, 6464, 6449, - 6452, 6450, 6448, 6456, 6454, 6453, 6455, 6451, 6442, 6443, 6441, 6432, - 6436, 6438, 6440, 6437, 6439, 6435, 6433, 6434, 6400, 6468, 6469, 6475, - 6474, 6477, 6476, 6473, 6472, 6470, 6479, 6471, 6478, 13007, 10770, - 10771, 10772, 983062, 8232, 983068, 983143, 67143, 67146, 67151, 67165, - 67166, 67167, 67157, 67158, 67159, 67160, 67161, 67162, 67163, 67164, - 67171, 67172, 67173, 67168, 67169, 67170, 67174, 67175, 67176, 67177, - 67178, 67179, 67230, 67231, 67180, 67181, 67182, 67183, 67184, 67185, - 67186, 67187, 67188, 67189, 67190, 67191, 67192, 67193, 67194, 67195, - 67196, 67197, 67198, 67199, 67200, 67201, 67202, 67203, 67204, 67205, - 67206, 67207, 67208, 67209, 67210, 67211, 67212, 67213, 67214, 67215, - 67216, 67217, 67218, 67219, 67220, 67221, 67222, 67223, 67224, 67225, - 67226, 67227, 67228, 67229, 67232, 67233, 67234, 67235, 67236, 67237, - 67238, 67239, 67240, 67241, 67242, 67243, 67244, 67245, 67246, 67247, - 67248, 67249, 67250, 67251, 67252, 67253, 67254, 67255, 67256, 67257, - 67258, 67259, 67260, 67261, 67262, 67263, 67264, 67274, 67275, 67276, - 67277, 67278, 67279, 67280, 67281, 67282, 67283, 67284, 67285, 67286, - 67287, 67288, 67289, 67290, 67291, 67292, 67293, 67294, 67295, 67296, - 67297, 67298, 67299, 67300, 67301, 67302, 67303, 67304, 67265, 67266, - 67267, 67268, 67269, 67270, 67271, 67272, 67273, 67325, 67326, 67327, - 67328, 67329, 67330, 67305, 67306, 67307, 67308, 67309, 67310, 67311, - 67312, 67313, 67314, 67315, 67316, 67317, 67318, 67319, 67320, 67321, - 67322, 67323, 67324, 67331, 67332, 67333, 67334, 67335, 67336, 67337, - 67338, 67349, 67350, 67351, 67352, 67353, 67354, 67355, 67356, 67357, - 67358, 67359, 67360, 67361, 67362, 67363, 67364, 67365, 67366, 67367, - 67368, 67378, 67379, 67380, 67381, 67382, 67369, 67370, 67371, 67372, - 67373, 67374, 67375, 67376, 67377, 67339, 67340, 67341, 67342, 67343, - 67344, 67345, 67346, 67347, 67348, 67401, 67404, 67403, 67402, 67400, - 67398, 67393, 67397, 67395, 67394, 67399, 67392, 67396, 67408, 67409, - 67410, 67406, 67407, 67405, 67411, 67413, 67412, 67424, 67425, 67426, - 67427, 67428, 67429, 67430, 67431, 67081, 67082, 67083, 67084, 67085, - 67087, 67088, 67089, 67090, 67091, 67092, 67093, 67094, 67086, 67095, - 67096, 67097, 67098, 67100, 67101, 67102, 67103, 67104, 67105, 67106, - 67107, 67108, 67109, 67110, 67111, 67112, 67113, 67114, 67115, 67116, - 67117, 67118, 67119, 67120, 67121, 67122, 67123, 67124, 67125, 67126, - 67127, 67128, 67129, 67130, 67131, 67132, 67133, 67134, 67135, 67136, - 67137, 67138, 67139, 67140, 67141, 67142, 67072, 67073, 67074, 67075, - 67076, 67077, 67078, 67079, 67080, 67145, 67147, 67148, 67149, 67150, - 67154, 67155, 67144, 67152, 67153, 67156, 67099, 65667, 65668, 65669, - 65670, 65671, 65672, 65673, 65675, 65674, 65677, 65676, 65665, 65664, - 65666, 65681, 65679, 65680, 65682, 65678, 65686, 65685, 65687, 65693, - 65690, 65691, 65692, 65694, 65703, 65696, 65695, 65697, 65698, 65699, - 65701, 65702, 65707, 65706, 65704, 65705, 65708, 65709, 65710, 65711, - 65712, 65713, 65719, 65717, 65714, 65715, 65716, 65718, 65720, 65721, - 65722, 65723, 65724, 65725, 65726, 65727, 65728, 65729, 65731, 65730, - 65732, 65733, 65737, 65734, 65735, 65736, 65738, 65739, 65740, 65741, - 65743, 65742, 65744, 65745, 65747, 65748, 65752, 65749, 65750, 65751, - 65753, 65754, 65755, 65756, 65757, 65779, 65780, 65781, 65782, 65783, - 65784, 65785, 65759, 65760, 65761, 65762, 65763, 65764, 65765, 65766, - 65767, 65768, 65769, 65770, 65771, 65772, 65773, 65774, 65775, 65776, - 65777, 65778, 65758, 65786, 65683, 65684, 65689, 65688, 65700, 65746, - 65561, 65543, 65587, 65582, 65589, 65536, 65541, 65579, 65566, 65571, - 65596, 65569, 65584, 65544, 65559, 65540, 65557, 65560, 65580, 65606, - 65600, 65599, 65577, 65562, 65538, 65573, 65563, 65609, 65588, 65549, - 65568, 65537, 65581, 65574, 65601, 65542, 65593, 65583, 65594, 65552, - 65547, 65605, 65578, 65545, 65585, 65586, 65546, 65570, 65591, 65564, - 65565, 65607, 65610, 65611, 65553, 65590, 65550, 65539, 65576, 65608, - 65551, 65554, 65592, 65603, 65597, 65567, 65572, 65558, 65555, 65612, - 65602, 65556, 65613, 65604, 65620, 65621, 65623, 65624, 65626, 65627, - 65628, 65629, 65622, 65616, 65617, 65619, 65618, 65625, 128391, 128279, - 128482, 128132, 42237, 42235, 42232, 42234, 42236, 42233, 42206, 42205, - 42197, 42196, 42204, 42195, 42228, 42229, 42230, 42213, 42208, 42224, - 42225, 42203, 42202, 42221, 42198, 42216, 42214, 42200, 42199, 42194, - 42193, 42219, 42210, 73648, 42220, 42211, 42212, 42222, 42223, 42227, - 42231, 42192, 42217, 42201, 42209, 42207, 42218, 42215, 42226, 42238, - 42239, 8356, 8374, 129409, 129422, 9806, 128274, 983079, 983076, 128271, - 117785, 117786, 117784, 117783, 117782, 117781, 8743, 10848, 10846, - 10833, 10844, 10842, 10847, 8744, 10841, 10851, 10850, 10834, 10845, - 10843, 10982, 10188, 129688, 10231, 129240, 10234, 10206, 10232, 10237, - 10229, 10235, 11059, 129236, 10230, 129238, 129239, 129232, 10236, 10233, - 10238, 129233, 129234, 10239, 10205, 129524, 128884, 129719, 128140, - 127977, 128261, 129707, 12319, 8270, 11847, 11848, 95, 118273, 9691, - 118276, 118291, 129935, 118436, 118447, 9604, 9697, 117765, 128394, + 128497, 128729, 6429, 6404, 6403, 6412, 6430, 6411, 6421, 6410, 6405, + 6415, 6425, 6426, 6427, 6419, 6418, 6407, 6406, 6414, 6413, 6409, 6408, + 6402, 6401, 6417, 6416, 6428, 6423, 6420, 6422, 6424, 6458, 6457, 6459, + 6464, 6449, 6452, 6450, 6448, 6456, 6454, 6453, 6455, 6451, 6442, 6443, + 6441, 6432, 6436, 6438, 6440, 6437, 6439, 6435, 6433, 6434, 6400, 6469, + 6475, 6474, 6477, 6476, 6473, 6472, 6470, 6479, 6471, 6478, 6468, 13007, + 10770, 10771, 10772, 983062, 8232, 983068, 983143, 67143, 67146, 67151, + 67165, 67166, 67167, 67157, 67158, 67159, 67160, 67161, 67162, 67163, + 67164, 67171, 67172, 67173, 67168, 67169, 67170, 67174, 67175, 67176, + 67177, 67178, 67179, 67230, 67231, 67180, 67181, 67182, 67183, 67184, + 67185, 67186, 67187, 67188, 67189, 67190, 67191, 67192, 67193, 67194, + 67195, 67196, 67197, 67198, 67199, 67200, 67201, 67202, 67203, 67204, + 67205, 67206, 67207, 67208, 67209, 67210, 67211, 67212, 67213, 67214, + 67215, 67216, 67217, 67218, 67219, 67220, 67221, 67222, 67223, 67224, + 67225, 67226, 67227, 67228, 67229, 67232, 67233, 67234, 67235, 67236, + 67237, 67238, 67239, 67240, 67241, 67242, 67243, 67244, 67245, 67246, + 67247, 67248, 67249, 67250, 67251, 67252, 67253, 67254, 67255, 67256, + 67257, 67258, 67259, 67260, 67261, 67262, 67263, 67264, 67274, 67275, + 67276, 67277, 67278, 67279, 67280, 67281, 67282, 67283, 67284, 67285, + 67286, 67287, 67288, 67289, 67290, 67291, 67292, 67293, 67294, 67295, + 67296, 67297, 67298, 67299, 67300, 67301, 67302, 67303, 67304, 67265, + 67266, 67267, 67268, 67269, 67270, 67271, 67272, 67273, 67325, 67326, + 67327, 67328, 67329, 67330, 67305, 67306, 67307, 67308, 67309, 67310, + 67311, 67312, 67313, 67314, 67315, 67316, 67317, 67318, 67319, 67320, + 67321, 67322, 67323, 67324, 67331, 67332, 67333, 67334, 67335, 67336, + 67337, 67338, 67349, 67350, 67351, 67352, 67353, 67354, 67355, 67356, + 67357, 67358, 67359, 67360, 67361, 67362, 67363, 67364, 67365, 67366, + 67367, 67368, 67378, 67379, 67380, 67381, 67382, 67369, 67370, 67371, + 67372, 67373, 67374, 67375, 67376, 67377, 67339, 67340, 67341, 67342, + 67343, 67344, 67345, 67346, 67347, 67348, 67401, 67404, 67403, 67402, + 67400, 67398, 67393, 67397, 67395, 67394, 67399, 67392, 67396, 67408, + 67409, 67410, 67406, 67407, 67405, 67411, 67413, 67412, 67424, 67425, + 67426, 67427, 67428, 67429, 67430, 67431, 67081, 67082, 67083, 67084, + 67085, 67087, 67088, 67089, 67090, 67091, 67092, 67093, 67094, 67086, + 67095, 67096, 67097, 67098, 67100, 67101, 67102, 67103, 67104, 67105, + 67106, 67107, 67108, 67109, 67110, 67111, 67112, 67113, 67114, 67115, + 67116, 67117, 67118, 67119, 67120, 67121, 67122, 67123, 67124, 67125, + 67126, 67127, 67128, 67129, 67130, 67131, 67132, 67133, 67134, 67135, + 67136, 67137, 67138, 67139, 67140, 67141, 67142, 67072, 67073, 67074, + 67075, 67076, 67077, 67078, 67079, 67080, 67145, 67147, 67148, 67149, + 67150, 67154, 67155, 67144, 67152, 67153, 67156, 67099, 65667, 65668, + 65669, 65670, 65671, 65672, 65673, 65675, 65674, 65677, 65676, 65665, + 65664, 65666, 65681, 65679, 65680, 65682, 65678, 65686, 65685, 65687, + 65693, 65690, 65691, 65692, 65694, 65703, 65696, 65695, 65697, 65698, + 65699, 65701, 65702, 65707, 65706, 65704, 65705, 65708, 65709, 65710, + 65711, 65712, 65713, 65719, 65717, 65714, 65715, 65716, 65718, 65720, + 65721, 65722, 65723, 65724, 65725, 65726, 65727, 65728, 65729, 65731, + 65730, 65732, 65733, 65737, 65734, 65735, 65736, 65738, 65739, 65740, + 65741, 65743, 65742, 65744, 65745, 65747, 65748, 65752, 65749, 65750, + 65751, 65753, 65754, 65755, 65756, 65757, 65779, 65780, 65781, 65782, + 65783, 65784, 65785, 65759, 65760, 65761, 65762, 65763, 65764, 65765, + 65766, 65767, 65768, 65769, 65770, 65771, 65772, 65773, 65774, 65775, + 65776, 65777, 65778, 65758, 65786, 65683, 65684, 65689, 65688, 65700, + 65746, 65561, 65543, 65587, 65582, 65589, 65536, 65541, 65579, 65566, + 65571, 65596, 65569, 65584, 65544, 65559, 65540, 65557, 65560, 65580, + 65606, 65600, 65599, 65577, 65562, 65538, 65573, 65563, 65609, 65588, + 65549, 65568, 65537, 65581, 65574, 65601, 65542, 65593, 65583, 65594, + 65552, 65547, 65605, 65578, 65545, 65585, 65586, 65546, 65570, 65591, + 65564, 65565, 65607, 65610, 65611, 65553, 65590, 65550, 65539, 65576, + 65608, 65551, 65554, 65592, 65603, 65597, 65567, 65572, 65558, 65555, + 65612, 65602, 65556, 65613, 65604, 65620, 65621, 65623, 65624, 65626, + 65627, 65628, 65629, 65622, 65616, 65617, 65619, 65618, 65625, 128391, + 128279, 128482, 128132, 42237, 42235, 42232, 42234, 42236, 42233, 42206, + 42205, 42197, 42196, 42204, 42195, 42228, 42229, 42230, 42213, 42208, + 42224, 42225, 42203, 42202, 42221, 42198, 42216, 42214, 42200, 42199, + 42194, 42193, 42219, 42210, 73648, 42220, 42211, 42212, 42222, 42223, + 42227, 42231, 42192, 42217, 42201, 42209, 42207, 42218, 42215, 42226, + 42238, 42239, 8356, 8374, 129409, 129422, 9806, 128274, 983079, 983076, + 128271, 117785, 117786, 117784, 117783, 117782, 117781, 8743, 10848, + 10846, 10833, 10844, 10842, 10847, 8744, 10841, 10851, 10850, 10834, + 10845, 10843, 10982, 10188, 129688, 10231, 129240, 10234, 10206, 10232, + 10237, 10229, 10235, 11059, 129236, 10230, 129238, 129239, 129232, 10236, + 10233, 10238, 129233, 129234, 10239, 10205, 129524, 128884, 129719, + 128140, 127977, 128261, 129707, 12319, 8270, 11847, 11848, 95, 118273, + 9691, 118276, 118291, 129935, 118436, 118447, 9604, 9697, 117765, 128394, 129852, 129853, 129870, 129872, 129868, 129856, 129871, 129869, 129854, - 129873, 129855, 128395, 128396, 128393, 10559, 117934, 117936, 117932, - 117930, 117972, 9695, 117960, 117948, 117964, 117968, 117952, 117956, - 117944, 117940, 117817, 129951, 9722, 117820, 128397, 118428, 117935, - 117937, 117933, 117931, 117973, 9694, 117961, 117949, 117965, 117969, - 117953, 117957, 117945, 117941, 117818, 10558, 128318, 10065, 129950, - 9727, 117823, 117767, 129863, 129865, 129867, 129864, 129861, 129866, - 129859, 129862, 129860, 129857, 129858, 10195, 118431, 10063, 9998, 9987, - 118429, 117821, 118430, 117822, 130021, 9605, 118425, 118426, 118424, - 117816, 118427, 117819, 9602, 9601, 9607, 9603, 118437, 118446, 9606, - 129903, 9674, 10208, 129438, 128557, 127853, 129523, 128886, 129729, - 66190, 66192, 66187, 66196, 66199, 66185, 66200, 66178, 66179, 66176, - 66201, 66177, 66202, 66191, 66193, 66181, 66180, 66203, 66182, 66186, - 66189, 66195, 66188, 66197, 66198, 66194, 66183, 66204, 66184, 67887, - 67892, 67881, 67895, 67891, 67886, 67872, 67893, 67876, 67894, 67883, - 67896, 67873, 67897, 67875, 67889, 67874, 67878, 67880, 67882, 67884, - 67890, 67885, 67888, 67877, 67879, 67903, 129317, 983226, 983234, 983224, - 983229, 8468, 129433, 983065, 129668, 129522, 129497, 69986, 69981, - 69991, 69985, 69984, 69990, 69989, 70002, 69997, 69983, 69982, 69988, - 69987, 69995, 69994, 69978, 69977, 69976, 69975, 69980, 69979, 69974, - 69973, 69993, 69992, 70001, 69998, 69996, 70000, 69999, 69968, 69971, - 69969, 69972, 69970, 70006, 70005, 70003, 70004, 127012, 127019, 127008, - 126990, 126999, 126976, 127005, 126987, 126996, 127004, 126986, 126995, - 126979, 127009, 126991, 127000, 127001, 126983, 126992, 127011, 127010, - 126977, 127007, 126989, 126998, 127006, 126988, 126997, 127015, 127014, - 127003, 126985, 126994, 127002, 126984, 126993, 126978, 126982, 127017, - 126981, 126980, 127016, 127018, 127013, 73464, 73442, 73451, 73448, - 73444, 73449, 73447, 73441, 73450, 73440, 73454, 73445, 73443, 73453, - 73456, 73446, 73455, 73452, 73457, 73463, 73461, 73459, 73462, 73460, - 73458, 128892, 3449, 3435, 3434, 3437, 3436, 3433, 3432, 3430, 3439, - 3431, 3438, 3419, 3420, 3446, 3417, 3422, 3416, 3447, 3444, 3443, 3448, - 3418, 3421, 3445, 3333, 3423, 3334, 3344, 3348, 3453, 3454, 3414, 3451, - 3450, 3452, 3455, 3412, 3413, 3355, 3354, 3406, 3362, 3361, 3367, 3366, - 3360, 3386, 3359, 3365, 3364, 3332, 3339, 3424, 3340, 3425, 3381, 3369, - 3363, 3353, 3358, 3368, 3380, 3379, 3378, 3377, 3376, 3337, 3338, 3346, - 3347, 3335, 3336, 3382, 3383, 3384, 3373, 3372, 3352, 3351, 3357, 3356, - 3350, 3349, 3371, 3370, 3342, 3343, 3385, 3374, 3375, 3441, 3442, 3440, - 3328, 3388, 3329, 3387, 3405, 3331, 3389, 3330, 3407, 3390, 3400, 3404, - 3393, 3394, 3395, 3396, 3426, 3427, 3402, 3403, 3391, 3392, 3398, 3399, - 3415, 9895, 9894, 9893, 9794, 10016, 129443, 128104, 128372, 129333, - 128114, 128115, 128378, 128107, 2137, 2122, 2121, 2133, 2120, 2126, 2132, - 2129, 2136, 2113, 2115, 2114, 2116, 2123, 2124, 2125, 2128, 2130, 2131, - 2118, 2134, 2117, 2112, 2127, 2119, 2135, 2138, 2139, 2142, 68288, 68314, - 68313, 68290, 68289, 68293, 68308, 68292, 68291, 68300, 68299, 68298, - 68297, 68306, 68304, 68320, 68318, 68323, 68312, 68317, 68322, 68309, - 68302, 68324, 68305, 68319, 68307, 68321, 68303, 68294, 68301, 68311, - 68295, 68316, 68315, 68310, 68331, 68335, 68334, 68333, 68332, 68340, - 68339, 68338, 68342, 68337, 68341, 68336, 68296, 68326, 68325, 128094, - 129469, 8380, 128368, 129389, 9967, 127809, 129671, 72835, 72834, 72827, - 72826, 72836, 72828, 72821, 72825, 72829, 72823, 72822, 72819, 72818, - 72831, 72830, 72844, 72845, 72838, 72839, 72840, 72832, 72820, 72846, - 72824, 72843, 72833, 72842, 72837, 72841, 72847, 72886, 72885, 72867, - 72866, 72859, 72858, 72868, 72860, 72853, 72857, 72861, 72855, 72854, - 72851, 72850, 72863, 72862, 72876, 72877, 72870, 72871, 72864, 72852, - 72878, 72856, 72875, 72865, 72874, 72869, 72873, 72879, 72880, 72883, - 72881, 72884, 72882, 72816, 72817, 9901, 129355, 73007, 72980, 72979, - 72983, 72982, 72988, 73008, 72987, 72960, 72961, 72968, 72971, 72985, - 72984, 72990, 72989, 72964, 72965, 72962, 72963, 73005, 72999, 73006, - 72973, 72972, 72976, 72986, 72981, 72991, 73001, 73002, 73003, 72995, - 72994, 72978, 72977, 72975, 72974, 72993, 72992, 73004, 72996, 72998, - 73000, 72997, 72966, 72969, 73031, 73030, 73027, 73028, 73026, 73025, - 73024, 73014, 73009, 73020, 73023, 73012, 73013, 73010, 73011, 73018, - 73021, 73029, 73045, 73044, 73047, 73046, 73043, 73042, 73040, 73049, - 73041, 73048, 186, 127405, 12348, 119811, 120778, 120491, 119827, 120495, - 120505, 120507, 119808, 120488, 119809, 120489, 119833, 120493, 119812, - 120492, 120494, 119814, 120490, 119816, 120496, 119818, 120497, 119819, - 120498, 119822, 120502, 120512, 119823, 120509, 120511, 120503, 119825, - 120504, 119826, 120506, 119828, 120508, 119810, 120510, 119820, 120499, - 119821, 120500, 119831, 120501, 119813, 119815, 119817, 119824, 119829, - 119830, 119832, 119837, 120779, 120517, 119834, 120514, 119835, 120515, - 119859, 120519, 119838, 120518, 120520, 119839, 120531, 119840, 120516, - 119842, 120522, 119844, 120523, 119845, 120524, 119848, 120528, 120538, - 119849, 120535, 120537, 120529, 119851, 120530, 119852, 120532, 119853, - 120521, 120533, 119854, 120534, 119836, 120536, 119846, 120525, 119847, - 120526, 119857, 120527, 119841, 119843, 119850, 119855, 119856, 119858, - 120016, 120017, 120018, 120019, 120020, 120021, 120022, 120023, 120024, - 120025, 120026, 120027, 120028, 120029, 120030, 120031, 120032, 120033, - 120034, 120035, 120036, 120037, 120038, 120039, 120040, 120041, 120042, - 120043, 120044, 120045, 120046, 120047, 120048, 120049, 120050, 120051, - 120052, 120053, 120054, 120055, 120056, 120057, 120058, 120059, 120060, - 120061, 120062, 120063, 120064, 120065, 120066, 120067, 119931, 120611, - 120621, 120623, 119912, 120604, 119913, 120605, 119937, 120609, 119915, - 120607, 119916, 120608, 120610, 119918, 120606, 119920, 120612, 119922, - 120613, 119923, 120614, 119926, 120618, 120628, 119927, 120625, 120627, - 120619, 119929, 120620, 119930, 120622, 119932, 120624, 119914, 120626, - 119924, 120615, 119925, 120616, 119935, 120617, 119917, 119919, 119921, - 119928, 119933, 119934, 119936, 120656, 120658, 120629, 120659, 120655, - 120661, 120660, 119938, 120630, 119939, 120631, 119963, 120635, 119941, - 120633, 119942, 120634, 120636, 119943, 120647, 119944, 120632, 119946, - 120638, 119948, 120639, 119949, 120640, 119952, 120644, 120654, 119953, - 120651, 120653, 120645, 119955, 120646, 119956, 120648, 119957, 120637, - 120649, 119958, 120650, 119940, 120652, 119950, 120641, 119951, 120642, - 119961, 120643, 119945, 119947, 119954, 119959, 119960, 119962, 120657, - 120540, 120542, 120513, 120543, 120539, 120545, 120544, 120541, 120172, - 120173, 120174, 120175, 120176, 120177, 120178, 120179, 120180, 120181, - 120182, 120183, 120184, 120185, 120186, 120187, 120188, 120189, 120190, - 120191, 120192, 120193, 120194, 120195, 120196, 120197, 120198, 120199, - 120200, 120201, 120202, 120203, 120204, 120205, 120206, 120207, 120208, - 120209, 120210, 120211, 120212, 120213, 120214, 120215, 120216, 120217, - 120218, 120219, 120220, 120221, 120222, 120223, 120787, 120786, 120789, - 120788, 120785, 120784, 120782, 120791, 120783, 120790, 120120, 120121, - 120123, 120124, 120125, 120126, 120128, 120129, 120130, 120131, 120132, - 120134, 120138, 120139, 120140, 120141, 120142, 120143, 120144, 120146, - 120147, 120148, 120149, 120150, 120151, 120152, 120153, 120154, 120155, - 120156, 120157, 120158, 120159, 120160, 120161, 120162, 120163, 120164, - 120165, 120166, 120167, 120168, 120169, 120170, 120171, 120797, 120796, - 120799, 120798, 120795, 120794, 120792, 120801, 120793, 120800, 120068, - 120069, 120071, 120072, 120073, 120074, 120077, 120078, 120079, 120080, - 120081, 120082, 120083, 120084, 120086, 120087, 120088, 120089, 120090, - 120091, 120092, 120094, 120095, 120096, 120097, 120098, 120099, 120100, - 120101, 120102, 120103, 120104, 120105, 120106, 120107, 120108, 120109, - 120110, 120111, 120112, 120113, 120114, 120115, 120116, 120117, 120118, - 120119, 10189, 119889, 120484, 120485, 120575, 119886, 120572, 119887, - 120573, 119911, 120577, 119890, 120576, 120578, 119891, 120589, 119892, - 120574, 119894, 120580, 119896, 120581, 119897, 120582, 119900, 120586, - 120596, 119901, 120593, 120595, 120587, 119903, 120588, 119904, 120590, - 119905, 120579, 120591, 119906, 120592, 119888, 120594, 119898, 120583, - 119899, 120584, 119909, 120585, 119895, 119902, 119907, 119908, 119910, - 119879, 120553, 120563, 120565, 119860, 120546, 119861, 120547, 119885, - 120551, 119863, 120549, 119864, 120550, 120552, 119866, 120548, 119868, - 120554, 119870, 120555, 119871, 120556, 119874, 120560, 120570, 119875, - 120567, 120569, 120561, 119877, 120562, 119878, 120564, 119880, 120566, - 119862, 120568, 119872, 120557, 119873, 120558, 119883, 120559, 119865, - 119867, 119869, 119876, 119881, 119882, 119884, 120598, 120600, 120571, - 120601, 120597, 120603, 120602, 120599, 120432, 120433, 120434, 120435, - 120436, 120437, 120438, 120439, 120440, 120441, 120442, 120443, 120444, - 120445, 120446, 120447, 120448, 120449, 120450, 120451, 120452, 120453, - 120454, 120455, 120456, 120457, 120458, 120459, 120460, 120461, 120462, - 120463, 120464, 120465, 120466, 120467, 120468, 120469, 120470, 120471, - 120472, 120473, 120474, 120475, 120476, 120477, 120478, 120479, 120480, - 120481, 120482, 120483, 120827, 120826, 120829, 120828, 120825, 120824, - 120822, 120831, 120823, 120830, 10215, 10221, 10219, 10217, 10223, 10187, - 10214, 10220, 10218, 10216, 10222, 120399, 120727, 120737, 120739, - 120380, 120720, 120381, 120721, 120405, 120725, 120383, 120723, 120384, - 120724, 120726, 120386, 120722, 120388, 120728, 120390, 120729, 120391, - 120730, 120394, 120734, 120744, 120395, 120741, 120743, 120735, 120397, - 120736, 120398, 120738, 120400, 120740, 120382, 120742, 120392, 120731, - 120393, 120732, 120403, 120733, 120385, 120387, 120389, 120396, 120401, - 120402, 120404, 120772, 120774, 120745, 120775, 120771, 120777, 120776, - 120406, 120746, 120407, 120747, 120431, 120751, 120409, 120749, 120410, - 120750, 120752, 120411, 120763, 120412, 120748, 120414, 120754, 120416, - 120755, 120417, 120756, 120420, 120760, 120770, 120421, 120767, 120769, - 120761, 120423, 120762, 120424, 120764, 120425, 120753, 120765, 120426, - 120766, 120408, 120768, 120418, 120757, 120419, 120758, 120429, 120759, - 120413, 120415, 120422, 120427, 120428, 120430, 120773, 120295, 120669, - 120679, 120681, 120276, 120662, 120277, 120663, 120301, 120667, 120279, - 120665, 120280, 120666, 120668, 120282, 120664, 120284, 120670, 120286, - 120671, 120287, 120672, 120290, 120676, 120686, 120291, 120683, 120685, - 120677, 120293, 120678, 120294, 120680, 120296, 120682, 120278, 120684, - 120288, 120673, 120289, 120674, 120299, 120675, 120281, 120283, 120285, - 120292, 120297, 120298, 120300, 120714, 120716, 120687, 120717, 120713, - 120719, 120718, 120302, 120688, 120303, 120689, 120327, 120693, 120305, - 120691, 120306, 120692, 120694, 120307, 120705, 120308, 120690, 120310, - 120696, 120312, 120697, 120313, 120698, 120316, 120702, 120712, 120317, - 120709, 120711, 120703, 120319, 120704, 120320, 120706, 120321, 120695, - 120707, 120322, 120708, 120304, 120710, 120314, 120699, 120315, 120700, - 120325, 120701, 120309, 120311, 120318, 120323, 120324, 120326, 120715, - 120817, 120816, 120819, 120818, 120815, 120814, 120812, 120821, 120813, - 120820, 120328, 120329, 120330, 120331, 120332, 120333, 120334, 120335, - 120336, 120337, 120338, 120339, 120340, 120341, 120342, 120343, 120344, - 120345, 120346, 120347, 120348, 120349, 120350, 120351, 120352, 120353, - 120354, 120355, 120356, 120357, 120358, 120359, 120360, 120361, 120362, - 120363, 120364, 120365, 120366, 120367, 120368, 120369, 120370, 120371, - 120372, 120373, 120374, 120375, 120376, 120377, 120378, 120379, 120224, - 120225, 120226, 120227, 120228, 120229, 120230, 120231, 120232, 120233, - 120234, 120235, 120236, 120237, 120238, 120239, 120240, 120241, 120242, - 120243, 120244, 120245, 120246, 120247, 120248, 120249, 120250, 120251, - 120252, 120253, 120254, 120255, 120256, 120257, 120258, 120259, 120260, - 120261, 120262, 120263, 120264, 120265, 120266, 120267, 120268, 120269, - 120270, 120271, 120272, 120273, 120274, 120275, 120807, 120806, 120809, - 120808, 120805, 120804, 120802, 120811, 120803, 120810, 119964, 119966, - 119967, 119970, 119973, 119974, 119977, 119978, 119979, 119980, 119982, - 119983, 119984, 119985, 119986, 119987, 119988, 119989, 119990, 119991, - 119992, 119993, 119995, 119997, 119998, 119999, 120000, 120001, 120002, - 120003, 120005, 120006, 120007, 120008, 120009, 120010, 120011, 120012, - 120013, 120014, 120015, 129481, 119528, 119538, 119531, 119535, 119525, - 119524, 119534, 119529, 119539, 119527, 119537, 119526, 119536, 119533, - 119523, 119532, 119522, 119530, 119520, 119521, 128470, 175, 8737, 10667, - 10666, 10671, 10669, 10670, 10668, 10665, 10664, 10651, 10653, 8798, - 127830, 129470, 129471, 93773, 93764, 93790, 93787, 983274, 93783, - 983273, 93782, 93772, 93766, 93791, 93779, 93789, 93786, 93776, 93777, - 93785, 93775, 93770, 93769, 93771, 93774, 93780, 93760, 93767, 93781, - 93788, 93761, 93768, 93778, 93762, 93763, 93784, 93765, 93847, 93827, - 93846, 93826, 93845, 93825, 93844, 93829, 93828, 93831, 93830, 93824, - 93833, 93832, 93837, 93836, 93834, 93842, 93835, 93838, 93839, 93843, - 93840, 93841, 93805, 93796, 93822, 93819, 983276, 93815, 983275, 93814, - 93804, 93798, 93823, 93811, 93821, 93818, 93808, 93809, 93817, 93807, - 93802, 93801, 93803, 93806, 93812, 93792, 93799, 93813, 93820, 93793, - 93800, 93810, 93794, 93795, 93816, 93797, 93849, 93850, 93848, 11859, - 11852, 11860, 128901, 9899, 10090, 10091, 128967, 128965, 128944, 10100, - 10088, 10092, 10101, 10089, 10093, 8287, 9618, 128971, 128950, 128938, - 9900, 118512, 128963, 128961, 10073, 128974, 128956, 9898, 128911, - 128931, 43761, 44013, 43762, 43760, 44011, 43994, 43989, 43974, 43746, - 43993, 43991, 43751, 43750, 43992, 43986, 43987, 43990, 43968, 43995, - 43976, 43973, 43999, 43977, 44001, 43752, 43747, 43972, 43998, 43984, - 43969, 43753, 43754, 43975, 44000, 43978, 43749, 43748, 43983, 44002, - 43970, 43996, 43971, 43997, 43981, 43988, 43979, 43985, 43980, 43982, - 43744, 43745, 44012, 43763, 43764, 44005, 43757, 43759, 43758, 44009, - 44003, 44007, 44006, 44004, 43755, 44008, 43756, 44010, 43765, 43766, - 44021, 44020, 44023, 44022, 44019, 44018, 44016, 44025, 44017, 44024, - 118475, 129760, 127816, 125140, 125137, 125136, 125139, 125141, 125138, - 125142, 124928, 124929, 124930, 124936, 124937, 124949, 124950, 124948, - 124938, 124956, 124990, 124992, 124974, 124955, 124964, 124963, 124991, - 124957, 124962, 124976, 124996, 124997, 124998, 124982, 124983, 124984, - 125004, 124975, 125003, 125005, 125011, 125018, 125028, 125029, 125012, - 125019, 125020, 125027, 125013, 125035, 124942, 124934, 125090, 125046, - 125078, 125033, 124946, 125048, 125037, 125070, 125000, 125095, 125121, - 124951, 125044, 125041, 125072, 124987, 125066, 125076, 125074, 125009, - 125107, 125108, 125068, 125124, 124945, 125002, 124931, 125089, 125022, - 124980, 125099, 124986, 125100, 125080, 125119, 124933, 125021, 125015, - 125071, 124985, 125117, 125056, 124993, 125039, 125049, 125043, 125024, - 124932, 125047, 125097, 124959, 125069, 125088, 124999, 125123, 124952, - 125036, 125026, 125001, 125085, 124960, 125057, 125073, 124966, 125098, - 125014, 125091, 124989, 125007, 124978, 124940, 125106, 125050, 125030, - 125092, 124941, 125060, 125077, 125102, 125094, 125053, 125040, 125055, - 125104, 125103, 124939, 125017, 124961, 125112, 125087, 124970, 124971, - 124969, 125023, 124979, 125042, 124947, 125086, 125075, 125051, 125111, - 124968, 124944, 125038, 125096, 125016, 125118, 125109, 124953, 125059, - 125052, 125006, 124958, 125093, 125115, 125054, 124988, 125008, 125084, - 125061, 125064, 125120, 125063, 124967, 124977, 124965, 125031, 983279, - 125081, 125082, 983280, 125010, 125067, 124973, 125032, 124935, 125116, - 125122, 125101, 124994, 124995, 125113, 125058, 125079, 125114, 125065, - 125034, 125083, 124954, 125062, 125105, 125110, 125045, 124943, 124972, - 124981, 125025, 125131, 125130, 125133, 125132, 125129, 125128, 125135, - 125127, 125134, 128334, 128697, 68028, 68093, 68090, 68089, 68086, 68029, - 68092, 68091, 68095, 68088, 68087, 68094, 68000, 68016, 68020, 68021, - 68022, 68009, 68010, 68015, 68017, 68014, 68013, 68018, 68006, 68023, - 68012, 68008, 68007, 68019, 68011, 68005, 68004, 68001, 68002, 68003, - 68031, 68030, 68039, 68075, 68057, 68084, 68066, 68036, 68054, 68081, - 68063, 68045, 68072, 68035, 68053, 68080, 68062, 68044, 68071, 68040, - 68076, 68058, 68085, 68067, 68038, 68056, 68083, 68065, 68047, 68074, - 68037, 68055, 68082, 68064, 68046, 68073, 68034, 68052, 68079, 68061, - 68043, 68070, 68033, 68051, 68078, 68060, 68042, 68069, 68041, 68068, - 68032, 68050, 68077, 68059, 67974, 67975, 67982, 67983, 67978, 67979, - 67980, 67981, 67987, 67988, 67989, 67992, 67993, 67994, 67995, 67996, - 67986, 67985, 67990, 67997, 67984, 67977, 67976, 67991, 67973, 67972, - 67968, 67969, 67970, 67971, 67998, 67999, 9791, 129500, 983173, 9170, - 9172, 9177, 9176, 9175, 9173, 9174, 9171, 9169, 128647, 118467, 128221, - 94015, 93989, 93971, 93958, 94019, 94021, 93953, 94023, 93999, 93995, - 94008, 93981, 93979, 93967, 93963, 93993, 93992, 93983, 93977, 93976, - 93975, 93974, 93968, 94032, 93988, 93987, 93973, 93972, 93997, 93996, - 93969, 94106, 94107, 94108, 94109, 94110, 94111, 94002, 94026, 94022, - 94003, 94004, 94010, 93980, 93978, 94099, 94100, 94101, 94102, 94103, - 94104, 94105, 93998, 93994, 94007, 94025, 93966, 93962, 94024, 93961, - 93960, 94000, 94009, 93964, 93965, 94001, 93970, 93984, 93954, 94017, - 94014, 94016, 94013, 94006, 94012, 94005, 94011, 93986, 93985, 93955, - 93952, 94020, 93990, 93957, 93956, 93959, 93982, 94018, 93991, 94035, - 94034, 94033, 94031, 94098, 94096, 94097, 94095, 94036, 94039, 94040, - 94067, 94068, 94038, 94037, 94073, 94075, 94045, 94071, 94069, 94046, - 94047, 94085, 94074, 94049, 94050, 94051, 94052, 94053, 94086, 94057, - 94054, 94084, 94055, 94056, 94041, 94082, 94048, 94081, 94042, 94076, - 94058, 94059, 94060, 94061, 94063, 94064, 94079, 94087, 94062, 94065, - 94080, 94066, 94072, 94070, 94044, 94043, 94077, 94078, 94083, 983239, - 983240, 128300, 127908, 181, 129440, 117772, 129986, 130022, 130023, 183, - 8943, 129686, 127894, 127756, 8357, 128189, 128469, 128656, 8722, 10793, - 10794, 10796, 10795, 10810, 8770, 8723, 10751, 129694, 129705, 128241, - 128242, 128244, 129339, 8871, 71232, 71229, 71236, 71231, 71230, 71216, - 71226, 71228, 71219, 71220, 71221, 71222, 71223, 71224, 71217, 71218, - 71225, 71227, 71234, 71233, 71253, 71252, 71255, 71254, 71251, 71250, - 71248, 71257, 71249, 71256, 71168, 71169, 71179, 71181, 71195, 71194, - 71200, 71199, 71193, 71192, 71198, 71197, 71174, 71175, 71176, 71177, - 71210, 71172, 71173, 71170, 71171, 71215, 71209, 71186, 71196, 71191, - 71201, 71211, 71212, 71213, 71205, 71204, 71188, 71187, 71185, 71184, - 71190, 71189, 71183, 71182, 71203, 71202, 71214, 71206, 71208, 71207, - 71178, 71180, 71235, 43867, 67512, 714, 700, 67509, 761, 763, 7470, 7471, + 129873, 129855, 128395, 129021, 128396, 128393, 10559, 117934, 117936, + 117932, 117930, 117972, 9695, 117960, 117948, 117964, 117968, 117952, + 117956, 117944, 117940, 117817, 129951, 9722, 117820, 128397, 118428, + 129022, 117935, 117937, 117933, 117931, 117973, 9694, 117961, 117949, + 117965, 117969, 117953, 117957, 117945, 117941, 117818, 10558, 128318, + 10065, 129950, 9727, 117823, 117767, 129863, 129865, 129867, 129864, + 129861, 129866, 129859, 129862, 129860, 129857, 129858, 10195, 118431, + 10063, 9998, 9987, 118429, 117821, 118430, 117822, 130021, 9605, 118425, + 118426, 118424, 117816, 118427, 117819, 9602, 9601, 9607, 9603, 118437, + 118446, 9606, 129903, 9674, 10208, 129438, 128557, 127853, 129523, + 128886, 129729, 66190, 66192, 66187, 66196, 66199, 66185, 66200, 66178, + 66179, 66176, 66201, 66177, 66202, 66191, 66193, 66181, 66180, 66203, + 66182, 66186, 66189, 66195, 66188, 66197, 66198, 66194, 66183, 66204, + 66184, 67887, 67892, 67881, 67895, 67891, 67886, 67872, 67893, 67876, + 67894, 67883, 67896, 67873, 67897, 67875, 67889, 67874, 67878, 67880, + 67882, 67884, 67890, 67885, 67888, 67877, 67879, 67903, 129317, 983226, + 983234, 983224, 983229, 8468, 129433, 983065, 129668, 129522, 129497, + 69986, 69981, 69991, 69985, 69984, 69990, 69989, 70002, 69997, 69983, + 69982, 69988, 69987, 69995, 69994, 69978, 69977, 69976, 69975, 69980, + 69979, 69974, 69973, 69993, 69992, 70001, 69998, 69996, 70000, 69999, + 69968, 69971, 69969, 69972, 69970, 70006, 70005, 70003, 70004, 127012, + 127019, 127008, 126990, 126999, 126976, 127005, 126987, 126996, 127004, + 126986, 126995, 126979, 127009, 126991, 127000, 127001, 126983, 126992, + 127011, 127010, 126977, 127007, 126989, 126998, 127006, 126988, 126997, + 127015, 127014, 127003, 126985, 126994, 127002, 126984, 126993, 126978, + 126982, 127017, 126981, 126980, 127016, 127018, 127013, 73464, 73442, + 73451, 73448, 73444, 73449, 73447, 73441, 73450, 73440, 73454, 73445, + 73443, 73453, 73456, 73446, 73455, 73452, 73457, 73463, 73461, 73459, + 73462, 73460, 73458, 128892, 3449, 3435, 3434, 3437, 3436, 3433, 3432, + 3430, 3439, 3431, 3438, 3419, 3420, 3446, 3417, 3422, 3416, 3447, 3444, + 3443, 3448, 3418, 3421, 3445, 3333, 3423, 3334, 3344, 3348, 3453, 3454, + 3414, 3451, 3450, 3452, 3455, 3412, 3413, 3355, 3354, 3406, 3362, 3361, + 3367, 3366, 3360, 3386, 3359, 3365, 3364, 3332, 3339, 3424, 3340, 3425, + 3381, 3369, 3363, 3353, 3358, 3368, 3380, 3379, 3378, 3377, 3376, 3337, + 3338, 3346, 3347, 3335, 3336, 3382, 3383, 3384, 3373, 3372, 3352, 3351, + 3357, 3356, 3350, 3349, 3371, 3370, 3342, 3343, 3385, 3374, 3375, 3441, + 3442, 3440, 3328, 3388, 3329, 3387, 3405, 3331, 3389, 3330, 3407, 3390, + 3400, 3404, 3393, 3394, 3395, 3396, 3426, 3427, 3402, 3403, 3391, 3392, + 3398, 3399, 3415, 9895, 9894, 9893, 9794, 10016, 129443, 128104, 128372, + 129333, 128114, 128115, 128378, 128107, 2137, 2122, 2121, 2133, 2120, + 2126, 2132, 2129, 2136, 2113, 2115, 2114, 2116, 2123, 2124, 2125, 2128, + 2130, 2131, 2118, 2134, 2117, 2112, 2127, 2119, 2135, 2138, 2139, 2142, + 68288, 68314, 68313, 68290, 68289, 68293, 68308, 68292, 68291, 68300, + 68299, 68298, 68297, 68306, 68304, 68320, 68318, 68323, 68312, 68317, + 68322, 68309, 68302, 68324, 68305, 68319, 68307, 68321, 68303, 68294, + 68301, 68311, 68295, 68316, 68315, 68310, 68331, 68335, 68334, 68333, + 68332, 68340, 68339, 68338, 68342, 68337, 68341, 68336, 68296, 68326, + 68325, 128094, 129469, 8380, 128368, 129389, 9967, 127809, 129671, 72835, + 72834, 72827, 72826, 72836, 72828, 72821, 72825, 72829, 72823, 72822, + 72819, 72818, 72831, 72830, 72844, 72845, 72838, 72839, 72840, 72832, + 72820, 72846, 72824, 72843, 72833, 72842, 72837, 72841, 72847, 72886, + 72885, 72867, 72866, 72859, 72858, 72868, 72860, 72853, 72857, 72861, + 72855, 72854, 72851, 72850, 72863, 72862, 72876, 72877, 72870, 72871, + 72864, 72852, 72878, 72856, 72875, 72865, 72874, 72869, 72873, 72879, + 72880, 72883, 72881, 72884, 72882, 72816, 72817, 9901, 129355, 73007, + 72980, 72979, 72983, 72982, 72988, 73008, 72987, 72960, 72961, 72968, + 72971, 72985, 72984, 72990, 72989, 72964, 72965, 72962, 72963, 73005, + 72999, 73006, 72973, 72972, 72976, 72986, 72981, 72991, 73001, 73002, + 73003, 72995, 72994, 72978, 72977, 72975, 72974, 72993, 72992, 73004, + 72996, 72998, 73000, 72997, 72966, 72969, 73031, 73030, 73027, 73028, + 73026, 73025, 73024, 73014, 73009, 73020, 73023, 73012, 73013, 73010, + 73011, 73018, 73021, 73029, 73045, 73044, 73047, 73046, 73043, 73042, + 73040, 73049, 73041, 73048, 186, 127405, 12348, 119811, 120778, 120491, + 119827, 120495, 120505, 120507, 119808, 120488, 119809, 120489, 119833, + 120493, 119810, 120510, 119812, 120492, 120494, 119814, 120490, 119816, + 120496, 119818, 120497, 119819, 120498, 119822, 120502, 120512, 119823, + 120509, 120511, 120503, 119825, 120504, 119826, 120506, 119828, 120508, + 119820, 120499, 119821, 120500, 119831, 120501, 119813, 119815, 119817, + 119824, 119829, 119830, 119832, 119837, 120779, 120517, 119834, 120514, + 119835, 120515, 119859, 120519, 119836, 120536, 119838, 120518, 120520, + 119839, 120531, 119840, 120516, 119842, 120522, 119844, 120523, 119845, + 120524, 119848, 120528, 120538, 119849, 120535, 120537, 120529, 119851, + 120530, 119852, 120532, 119853, 120521, 120533, 119854, 120534, 119846, + 120525, 119847, 120526, 119857, 120527, 119841, 119843, 119850, 119855, + 119856, 119858, 120016, 120017, 120018, 120019, 120020, 120021, 120022, + 120023, 120024, 120025, 120026, 120027, 120028, 120029, 120030, 120031, + 120032, 120033, 120034, 120035, 120036, 120037, 120038, 120039, 120040, + 120041, 120042, 120043, 120044, 120045, 120046, 120047, 120048, 120049, + 120050, 120051, 120052, 120053, 120054, 120055, 120056, 120057, 120058, + 120059, 120060, 120061, 120062, 120063, 120064, 120065, 120066, 120067, + 119931, 120611, 120621, 120623, 119912, 120604, 119913, 120605, 119937, + 120609, 119914, 120626, 119915, 120607, 119916, 120608, 120610, 119918, + 120606, 119920, 120612, 119922, 120613, 119923, 120614, 119926, 120618, + 120628, 119927, 120625, 120627, 120619, 119929, 120620, 119930, 120622, + 119932, 120624, 119924, 120615, 119925, 120616, 119935, 120617, 119917, + 119919, 119921, 119928, 119933, 119934, 119936, 120656, 120658, 120629, + 120655, 120659, 120661, 120660, 119938, 120630, 119939, 120631, 119963, + 120635, 119940, 120652, 119941, 120633, 119942, 120634, 120636, 119943, + 120647, 119944, 120632, 119946, 120638, 119948, 120639, 119949, 120640, + 119952, 120644, 120654, 119953, 120651, 120653, 120645, 119955, 120646, + 119956, 120648, 119957, 120637, 120649, 119958, 120650, 119950, 120641, + 119951, 120642, 119961, 120643, 119945, 119947, 119954, 119959, 119960, + 119962, 120657, 120540, 120542, 120513, 120539, 120543, 120545, 120544, + 120541, 120172, 120173, 120174, 120175, 120176, 120177, 120178, 120179, + 120180, 120181, 120182, 120183, 120184, 120185, 120186, 120187, 120188, + 120189, 120190, 120191, 120192, 120193, 120194, 120195, 120196, 120197, + 120198, 120199, 120200, 120201, 120202, 120203, 120204, 120205, 120206, + 120207, 120208, 120209, 120210, 120211, 120212, 120213, 120214, 120215, + 120216, 120217, 120218, 120219, 120220, 120221, 120222, 120223, 120787, + 120786, 120789, 120788, 120785, 120784, 120782, 120791, 120783, 120790, + 120120, 120121, 120123, 120124, 120125, 120126, 120128, 120129, 120130, + 120131, 120132, 120134, 120138, 120139, 120140, 120141, 120142, 120143, + 120144, 120146, 120147, 120148, 120149, 120150, 120151, 120152, 120153, + 120154, 120155, 120156, 120157, 120158, 120159, 120160, 120161, 120162, + 120163, 120164, 120165, 120166, 120167, 120168, 120169, 120170, 120171, + 120797, 120796, 120799, 120798, 120795, 120794, 120792, 120801, 120793, + 120800, 120068, 120069, 120071, 120072, 120073, 120074, 120077, 120078, + 120079, 120080, 120081, 120082, 120083, 120084, 120086, 120087, 120088, + 120089, 120090, 120091, 120092, 120094, 120095, 120096, 120097, 120098, + 120099, 120100, 120101, 120102, 120103, 120104, 120105, 120106, 120107, + 120108, 120109, 120110, 120111, 120112, 120113, 120114, 120115, 120116, + 120117, 120118, 120119, 10189, 119889, 120484, 120485, 120575, 119897, + 120486, 120582, 119886, 120572, 119887, 120573, 119911, 120577, 119888, + 120594, 119890, 120576, 120578, 119891, 120589, 119892, 120574, 119894, + 120580, 119896, 120581, 119900, 120586, 120596, 119901, 120593, 120595, + 120587, 119903, 120588, 119904, 120590, 119905, 120579, 120591, 119906, + 120592, 119898, 120583, 119899, 120584, 119909, 120585, 119895, 119902, + 119907, 119908, 119910, 119879, 120553, 120563, 120565, 119860, 120546, + 119861, 120547, 119885, 120551, 119862, 120568, 119863, 120549, 119864, + 120550, 120552, 119866, 120548, 119868, 120554, 119870, 120555, 119871, + 120556, 119874, 120560, 120570, 119875, 120567, 120569, 120561, 119877, + 120562, 119878, 120564, 119880, 120566, 119872, 120557, 119873, 120558, + 119883, 120559, 119865, 119867, 119869, 119876, 119881, 119882, 119884, + 120598, 120600, 120571, 120597, 120601, 120603, 120602, 120599, 120432, + 120433, 120434, 120435, 120436, 120437, 120438, 120439, 120440, 120441, + 120442, 120443, 120444, 120445, 120446, 120447, 120448, 120449, 120450, + 120451, 120452, 120453, 120454, 120455, 120456, 120457, 120458, 120459, + 120460, 120461, 120462, 120463, 120464, 120465, 120466, 120467, 120468, + 120469, 120470, 120471, 120472, 120473, 120474, 120475, 120476, 120477, + 120478, 120479, 120480, 120481, 120482, 120483, 120827, 120826, 120829, + 120828, 120825, 120824, 120822, 120831, 120823, 120830, 10215, 10221, + 10219, 10217, 10223, 10187, 10214, 10220, 10218, 10216, 10222, 120399, + 120727, 120737, 120739, 120380, 120720, 120381, 120721, 120405, 120725, + 120382, 120742, 120383, 120723, 120384, 120724, 120726, 120386, 120722, + 120388, 120728, 120390, 120729, 120391, 120730, 120394, 120734, 120744, + 120395, 120741, 120743, 120735, 120397, 120736, 120398, 120738, 120400, + 120740, 120392, 120731, 120393, 120732, 120403, 120733, 120385, 120387, + 120389, 120396, 120401, 120402, 120404, 120772, 120774, 120745, 120771, + 120775, 120777, 120776, 120406, 120746, 120407, 120747, 120431, 120751, + 120408, 120768, 120409, 120749, 120410, 120750, 120752, 120411, 120763, + 120412, 120748, 120414, 120754, 120416, 120755, 120417, 120756, 120420, + 120760, 120770, 120421, 120767, 120769, 120761, 120423, 120762, 120424, + 120764, 120425, 120753, 120765, 120426, 120766, 120418, 120757, 120419, + 120758, 120429, 120759, 120413, 120415, 120422, 120427, 120428, 120430, + 120773, 120295, 120669, 120679, 120681, 120276, 120662, 120277, 120663, + 120301, 120667, 120278, 120684, 120279, 120665, 120280, 120666, 120668, + 120282, 120664, 120284, 120670, 120286, 120671, 120287, 120672, 120290, + 120676, 120686, 120291, 120683, 120685, 120677, 120293, 120678, 120294, + 120680, 120296, 120682, 120288, 120673, 120289, 120674, 120299, 120675, + 120281, 120283, 120285, 120292, 120297, 120298, 120300, 120714, 120716, + 120687, 120713, 120717, 120719, 120718, 120302, 120688, 120303, 120689, + 120327, 120693, 120304, 120710, 120305, 120691, 120306, 120692, 120694, + 120307, 120705, 120308, 120690, 120310, 120696, 120312, 120697, 120313, + 120698, 120316, 120702, 120712, 120317, 120709, 120711, 120703, 120319, + 120704, 120320, 120706, 120321, 120695, 120707, 120322, 120708, 120314, + 120699, 120315, 120700, 120325, 120701, 120309, 120311, 120318, 120323, + 120324, 120326, 120715, 120817, 120816, 120819, 120818, 120815, 120814, + 120812, 120821, 120813, 120820, 120328, 120329, 120330, 120331, 120332, + 120333, 120334, 120335, 120336, 120337, 120338, 120339, 120340, 120341, + 120342, 120343, 120344, 120345, 120346, 120347, 120348, 120349, 120350, + 120351, 120352, 120353, 120354, 120355, 120356, 120357, 120358, 120359, + 120360, 120361, 120362, 120363, 120364, 120365, 120366, 120367, 120368, + 120369, 120370, 120371, 120372, 120373, 120374, 120375, 120376, 120377, + 120378, 120379, 120224, 120225, 120226, 120227, 120228, 120229, 120230, + 120231, 120232, 120233, 120234, 120235, 120236, 120237, 120238, 120239, + 120240, 120241, 120242, 120243, 120244, 120245, 120246, 120247, 120248, + 120249, 120250, 120251, 120252, 120253, 120254, 120255, 120256, 120257, + 120258, 120259, 120260, 120261, 120262, 120263, 120264, 120265, 120266, + 120267, 120268, 120269, 120270, 120271, 120272, 120273, 120274, 120275, + 120807, 120806, 120809, 120808, 120805, 120804, 120802, 120811, 120803, + 120810, 119964, 119966, 119967, 119970, 119973, 119974, 119977, 119978, + 119979, 119980, 119982, 119983, 119984, 119985, 119986, 119987, 119988, + 119989, 119990, 119991, 119992, 119993, 119995, 119997, 119998, 119999, + 120000, 120001, 120002, 120003, 120005, 120006, 120007, 120008, 120009, + 120010, 120011, 120012, 120013, 120014, 120015, 129481, 119528, 119538, + 119531, 119535, 119525, 119524, 119534, 119529, 119539, 119527, 119537, + 119526, 119536, 119533, 119523, 119532, 119522, 119530, 119520, 119521, + 128470, 175, 8737, 118523, 118521, 118522, 10667, 10666, 10671, 10669, + 10670, 10668, 10665, 10664, 10651, 10653, 8798, 127830, 129470, 129471, + 93773, 93764, 93790, 93787, 983274, 93783, 983273, 93782, 93772, 93766, + 93791, 93779, 93789, 93786, 93776, 93777, 93785, 93775, 93770, 93769, + 93771, 93774, 93780, 93760, 93767, 93781, 93788, 93761, 93768, 93778, + 93762, 93763, 93784, 93765, 93847, 93827, 93846, 93826, 93845, 93825, + 93844, 93829, 93828, 93831, 93830, 93824, 93833, 93832, 93837, 93836, + 93834, 93842, 93835, 93838, 93839, 93843, 93840, 93841, 93805, 93796, + 93822, 93819, 983276, 93815, 983275, 93814, 93804, 93798, 93823, 93811, + 93821, 93818, 93808, 93809, 93817, 93807, 93802, 93801, 93803, 93806, + 93812, 93792, 93799, 93813, 93820, 93793, 93800, 93810, 93794, 93795, + 93816, 93797, 93849, 93850, 93848, 11852, 11860, 11859, 128901, 9899, + 10090, 10091, 128967, 128965, 128944, 10100, 10088, 10092, 10101, 10089, + 10093, 8287, 9618, 128971, 128950, 128938, 9900, 118512, 128963, 128961, + 10073, 128974, 128956, 9898, 128911, 128931, 43761, 44013, 43762, 43760, + 44011, 43994, 43989, 43974, 43746, 43993, 43991, 43751, 43750, 43992, + 43986, 43987, 43990, 43968, 43995, 43976, 43973, 43999, 43977, 44001, + 43752, 43747, 43972, 43998, 43984, 43969, 43753, 43754, 43975, 44000, + 43978, 43749, 43748, 43983, 44002, 43970, 43996, 43971, 43997, 43981, + 43988, 43979, 43985, 43980, 43982, 43744, 43745, 44012, 43763, 43764, + 44005, 43757, 43759, 43758, 44009, 44003, 44007, 44006, 44004, 43755, + 44008, 43756, 44010, 43765, 43766, 44021, 44020, 44023, 44022, 44019, + 44018, 44016, 44025, 44017, 44024, 118475, 129760, 127816, 125140, + 125137, 125136, 125139, 125141, 125138, 125142, 124928, 124929, 124930, + 124936, 124937, 124949, 124950, 124948, 124938, 124956, 124990, 124992, + 124974, 124955, 124964, 124963, 124991, 124957, 124962, 124976, 124996, + 124997, 124998, 124982, 124983, 124984, 125004, 124975, 125003, 125005, + 125011, 125018, 125028, 125029, 125012, 125019, 125020, 125027, 125013, + 125035, 124942, 124934, 125090, 125046, 125078, 125033, 124946, 125048, + 125037, 125070, 125000, 125095, 125121, 124951, 125044, 125041, 125072, + 124987, 125066, 125076, 125074, 125009, 125107, 125108, 125068, 125124, + 124945, 125002, 124931, 125089, 125022, 124980, 125099, 124986, 125100, + 125080, 125119, 124933, 125021, 125015, 125071, 124985, 125117, 125056, + 124993, 125039, 125049, 125043, 125024, 124932, 125047, 125097, 125069, + 125088, 124999, 125123, 124959, 124952, 125036, 125026, 125001, 125085, + 124960, 125057, 125073, 124966, 125014, 125098, 125091, 124989, 125007, + 124978, 124940, 125106, 125050, 125030, 125092, 124941, 125060, 125077, + 125102, 125094, 125053, 125040, 125055, 125104, 125103, 124939, 125017, + 124961, 125112, 125087, 124970, 124971, 124969, 125023, 124979, 125042, + 124947, 125086, 125075, 125051, 125111, 124968, 124944, 125038, 125096, + 125016, 125118, 125109, 124953, 125059, 125052, 125006, 124958, 125093, + 125115, 125054, 124988, 125008, 125084, 124965, 125061, 125064, 125120, + 125063, 124967, 124977, 125031, 983279, 125081, 125082, 983280, 125010, + 125067, 124973, 125032, 124935, 125116, 125122, 125101, 124994, 124995, + 125113, 125058, 125079, 125114, 125065, 125034, 125083, 124954, 125062, + 125105, 125110, 125045, 124943, 124972, 124981, 125025, 125131, 125130, + 125133, 125132, 125129, 125128, 125135, 125127, 125134, 128334, 128697, + 68028, 68093, 68090, 68089, 68086, 68029, 68092, 68091, 68095, 68088, + 68087, 68094, 68000, 68016, 68020, 68021, 68022, 68009, 68010, 68015, + 68017, 68014, 68013, 68018, 68006, 68023, 68012, 68008, 68007, 68019, + 68011, 68005, 68004, 68001, 68002, 68003, 68031, 68030, 68039, 68075, + 68057, 68084, 68066, 68036, 68054, 68081, 68063, 68045, 68072, 68035, + 68053, 68080, 68062, 68044, 68071, 68040, 68076, 68058, 68085, 68067, + 68038, 68056, 68083, 68065, 68047, 68074, 68037, 68055, 68082, 68064, + 68046, 68073, 68034, 68052, 68079, 68061, 68043, 68070, 68033, 68051, + 68078, 68060, 68042, 68069, 68041, 68068, 68032, 68050, 68077, 68059, + 67974, 67975, 67982, 67983, 67978, 67979, 67980, 67981, 67987, 67988, + 67989, 67992, 67993, 67994, 67995, 67996, 67986, 67985, 67990, 67997, + 67984, 67977, 67976, 67991, 67973, 67972, 67968, 67969, 67970, 67971, + 67998, 67999, 9791, 129500, 983173, 9170, 9172, 9177, 9176, 9175, 9173, + 9174, 9171, 9169, 128647, 118467, 129675, 128221, 94015, 93989, 93971, + 93958, 94019, 94021, 93953, 94023, 93999, 93995, 94008, 93981, 93979, + 93967, 93963, 93993, 93992, 93983, 93977, 93976, 93975, 93974, 93968, + 94032, 93988, 93987, 93973, 93972, 93997, 93996, 93969, 94106, 94107, + 94108, 94109, 94110, 94111, 94002, 94026, 94022, 94003, 94004, 94010, + 93980, 93978, 94099, 94100, 94101, 94102, 94103, 94104, 94105, 93998, + 93994, 94007, 94025, 93966, 93962, 94024, 93961, 93960, 94000, 94009, + 93964, 93965, 94001, 93970, 93984, 93954, 94017, 94014, 94016, 94013, + 94006, 94012, 94005, 94011, 93986, 93985, 93955, 93952, 94020, 93990, + 93957, 93956, 93959, 93982, 94018, 93991, 94035, 94034, 94033, 94031, + 94098, 94096, 94097, 94095, 94036, 94039, 94040, 94067, 94068, 94038, + 94037, 94073, 94075, 94045, 94071, 94069, 94046, 94047, 94085, 94074, + 94049, 94050, 94051, 94052, 94053, 94086, 94057, 94054, 94084, 94055, + 94056, 94041, 94082, 94048, 94081, 94042, 94076, 94058, 94059, 94060, + 94061, 94063, 94064, 94079, 94087, 94062, 94065, 94080, 94066, 94072, + 94070, 94044, 94043, 94077, 94078, 94083, 983239, 983240, 128300, 127908, + 181, 129440, 117772, 129986, 130022, 130023, 183, 8943, 129686, 127894, + 127756, 8357, 128189, 128469, 128656, 8722, 10793, 10794, 10796, 10795, + 10810, 8770, 8723, 10751, 129694, 129705, 128241, 128242, 128244, 129339, + 8871, 71232, 71229, 71236, 71231, 71230, 71216, 71226, 71228, 71219, + 71220, 71221, 71222, 71223, 71224, 71217, 71218, 71225, 71227, 71234, + 71233, 71253, 71252, 71255, 71254, 71251, 71250, 71248, 71257, 71249, + 71256, 71168, 71169, 71179, 71181, 71195, 71194, 71200, 71199, 71193, + 71192, 71198, 71197, 71174, 71175, 71176, 71177, 71210, 71172, 71173, + 71170, 71171, 71215, 71209, 71186, 71196, 71191, 71201, 71211, 71212, + 71213, 71205, 71204, 71188, 71187, 71185, 71184, 71190, 71189, 71183, + 71182, 71203, 71202, 71214, 71206, 71208, 71207, 71178, 71180, 71235, + 43867, 67512, 1419, 1420, 1368, 714, 700, 67509, 761, 763, 7470, 7471, 7487, 7474, 7483, 7476, 43000, 7484, 7485, 7468, 7469, 42994, 7472, 7473, 42995, 7475, 7477, 7478, 7479, 7480, 7481, 7482, 7486, 42996, 42993, 7488, 7489, 11389, 7490, 723, 722, 42755, 42753, 42757, 42759, 42754, - 42752, 42756, 42758, 42652, 122956, 122958, 122929, 122954, 122932, + 42752, 42756, 42758, 42652, 122958, 122956, 122929, 122954, 122932, 122952, 122943, 122987, 122946, 122938, 122939, 122942, 122960, 122941, 122959, 122989, 122955, 122950, 122948, 122944, 122951, 122988, 122953, 122934, 122935, 122936, 122933, 122949, 122931, 122957, 122930, 122947, 122937, 122928, 122940, 122945, 42653, 7544, 710, 735, 42889, 67510, 42776, 42775, 42777, 750, 698, 725, 709, 984011, 42765, 42760, 42770, 741, 984012, 42769, 42764, 42774, 745, 762, 764, 715, 704, 67507, 4348, - 42766, 42761, 42771, 742, 721, 67511, 42888, 42768, 42763, 751, 767, 753, - 42773, 717, 754, 755, 744, 759, 719, 718, 42783, 752, 716, 42778, 703, - 43882, 706, 713, 42767, 42762, 42772, 743, 758, 757, 756, 727, 766, 726, - 697, 42780, 42782, 42781, 42779, 760, 705, 67508, 701, 67513, 702, 43883, - 707, 734, 42890, 765, 7491, 7493, 7516, 67459, 7495, 7601, 7509, 67461, - 7517, 7580, 7590, 694, 7591, 67474, 67476, 7595, 67484, 67491, 67456, - 67460, 67478, 7600, 67498, 7608, 67506, 67471, 67492, 7581, 7521, 7496, - 67468, 67469, 67467, 67466, 7519, 7585, 67480, 67463, 67465, 67464, 7611, - 7613, 7612, 7497, 7604, 7582, 7614, 7505, 7584, 67472, 7501, 7518, 7520, - 67475, 736, 688, 689, 67477, 43868, 67479, 7504, 7596, 7588, 7589, 690, - 7592, 737, 43869, 43870, 7593, 67485, 7594, 67483, 67481, 67482, 67486, - 67487, 43001, 7599, 7598, 7506, 67490, 7499, 7507, 7510, 7602, 691, - 67497, 67496, 67473, 740, 7583, 67470, 738, 67514, 7603, 7586, 7498, - 7513, 7511, 7605, 67503, 67499, 67502, 7508, 67500, 67501, 7492, 7579, - 7494, 7514, 7597, 7500, 692, 67494, 67495, 693, 67488, 67489, 7587, 7502, - 7610, 43881, 7615, 7512, 43871, 7606, 7607, 7515, 67504, 7609, 7503, - 67493, 695, 739, 696, 42784, 42785, 67458, 67457, 720, 699, 724, 708, - 749, 42864, 748, 712, 747, 746, 10762, 128184, 128176, 129297, 71266, - 6165, 6164, 6167, 6166, 6163, 6162, 6160, 6169, 6161, 6168, 6159, 6157, - 6156, 6155, 6147, 6149, 71271, 71272, 6176, 6279, 6272, 6295, 6273, 6289, - 6274, 6313, 6286, 6311, 6310, 6280, 6276, 6275, 6282, 6287, 6278, 6285, - 6284, 6288, 6277, 6291, 6290, 6293, 6294, 6292, 6283, 6281, 6185, 6196, - 6264, 6210, 6190, 6303, 6305, 6307, 6300, 6302, 6304, 6312, 6298, 6301, - 6314, 6308, 6309, 6299, 6306, 6263, 6262, 6260, 6261, 6259, 6244, 6252, - 6245, 6253, 6254, 6248, 6238, 6239, 6257, 6247, 6256, 6242, 6258, 6255, - 6241, 6240, 6249, 6251, 6250, 6243, 6246, 6237, 6193, 6192, 6297, 6296, - 6218, 6236, 6225, 6234, 6227, 6235, 6211, 6222, 6232, 6228, 6224, 6226, - 6233, 6214, 6216, 6215, 6217, 6219, 6231, 6223, 6220, 6221, 6230, 6229, - 6212, 6213, 6204, 6194, 6209, 6207, 6205, 6206, 6203, 6202, 6208, 6191, - 6177, 6183, 6179, 6181, 6180, 6182, 6186, 6195, 6201, 6189, 6197, 6184, - 6187, 6188, 6199, 6200, 6198, 6178, 71273, 71275, 71274, 6151, 71265, - 71270, 71269, 6144, 71268, 71264, 71267, 71276, 6150, 6158, 6148, 6146, - 6152, 6153, 6154, 6145, 9866, 9867, 119552, 9101, 128669, 128018, 128053, - 127889, 129390, 118261, 128496, 129742, 129439, 128332, 129334, 128741, - 128757, 129468, 128739, 9968, 128670, 128672, 128693, 128507, 128001, - 129700, 128045, 128068, 128511, 127909, 92748, 92744, 92761, 92750, - 92739, 92751, 92737, 92754, 92749, 92753, 92743, 92752, 92757, 92766, - 92736, 92741, 92746, 92764, 92745, 92765, 92755, 92756, 92763, 92762, - 92747, 92760, 92758, 92738, 92740, 92759, 92742, 92783, 92782, 92773, - 92772, 92775, 92774, 92771, 92770, 92768, 92777, 92769, 92776, 70291, - 70292, 70290, 70297, 70296, 70293, 70287, 70298, 70312, 70311, 70306, - 70285, 70284, 70289, 70288, 70295, 70294, 70303, 70301, 70283, 70282, - 70280, 70278, 70277, 70276, 70300, 70299, 70310, 70307, 70304, 70309, - 70308, 70305, 70272, 70275, 70273, 70274, 70313, 127926, 215, 10804, - 10805, 10807, 10811, 10801, 10800, 10005, 8844, 8845, 8846, 8888, 127812, - 117860, 9838, 9839, 9837, 127929, 127896, 119161, 119159, 119155, 119157, - 119061, 119060, 119224, 119235, 119132, 119058, 119059, 119255, 119253, - 119130, 119131, 119163, 119169, 119149, 119167, 119168, 119210, 119178, - 119173, 119211, 119150, 119151, 119152, 119153, 119154, 119175, 119212, - 119213, 119166, 119164, 119141, 119142, 119176, 119179, 119143, 119144, - 119145, 119165, 119177, 119170, 119174, 119092, 119052, 119247, 119186, - 119073, 119109, 119093, 119050, 119220, 119221, 119044, 119049, 119187, - 119209, 119082, 119041, 119083, 119077, 119078, 119162, 119160, 119208, - 119156, 119158, 119136, 119102, 119056, 119057, 119146, 119147, 119148, - 119042, 119066, 119065, 119069, 119185, 119074, 119075, 119076, 119231, - 119232, 119085, 119084, 119070, 119071, 119072, 119218, 119217, 119189, - 119188, 119248, 119249, 119172, 119171, 119216, 119134, 119100, 119206, - 119262, 119270, 119271, 119263, 119268, 119269, 119272, 119264, 119267, - 119266, 119265, 119274, 119223, 119234, 119233, 119046, 119222, 119184, - 119227, 119237, 119228, 119122, 119123, 119081, 119098, 119207, 119129, - 119087, 119086, 119128, 119140, 119106, 119062, 119195, 119204, 119205, - 119196, 119197, 119198, 119199, 119200, 119201, 119202, 119203, 119094, - 119095, 119126, 119108, 119215, 119214, 119261, 119252, 119257, 119258, - 119183, 119090, 119091, 119135, 119101, 119096, 119097, 119053, 119054, - 119055, 119048, 119043, 119047, 119180, 119254, 119259, 119225, 119236, - 119226, 119229, 119238, 119230, 119051, 119045, 119089, 119088, 119040, - 119067, 119068, 119137, 119103, 119139, 119105, 119110, 119111, 119250, - 119181, 119273, 119243, 119244, 119245, 119246, 119242, 119240, 119239, - 119241, 119064, 119138, 119104, 119063, 119256, 119260, 119190, 119118, - 119119, 119120, 119121, 119112, 119113, 119116, 119117, 119114, 119115, - 119124, 119125, 119191, 119193, 119194, 119127, 119251, 119107, 119133, - 119099, 119219, 119192, 119182, 127932, 127925, 8811, 8810, 4158, 4156, - 4157, 4155, 4192, 4191, 4190, 4226, 4129, 43642, 4138, 4135, 4208, 4207, - 4206, 4159, 4099, 4098, 4097, 43625, 43624, 43626, 43623, 43622, 43621, - 43627, 43618, 43617, 43630, 43629, 43620, 43619, 983244, 43631, 43616, - 43635, 43628, 43633, 43634, 4096, 4188, 4189, 4187, 4186, 4136, 4121, - 4106, 4111, 4100, 4105, 4116, 4238, 4123, 4176, 43491, 4218, 4220, 43490, - 4221, 4224, 43492, 4223, 43489, 4216, 43488, 4215, 4214, 4213, 4219, - 4222, 4225, 4217, 4130, 43646, 43647, 4193, 4177, 4126, 4112, 43503, - 43495, 43502, 43501, 43516, 43515, 43518, 43517, 43498, 43497, 43500, - 43499, 43514, 43496, 4108, 4107, 4113, 4198, 4197, 4125, 4110, 4109, - 4115, 4114, 4133, 4134, 4178, 4179, 4180, 4181, 4131, 4132, 4128, 4124, - 4120, 4119, 4102, 4101, 4104, 4103, 4118, 4117, 4127, 4122, 4137, 43636, - 43637, 43638, 43632, 43494, 4245, 4244, 4247, 4246, 4243, 4242, 4240, - 4249, 4241, 4248, 4154, 4150, 4250, 4251, 4237, 4235, 4236, 4231, 4232, - 4233, 4234, 43493, 4171, 43644, 43645, 4201, 4202, 4203, 4204, 4205, - 4151, 4239, 43643, 4170, 4153, 4152, 43639, 43641, 43640, 4174, 4172, - 4255, 4254, 4175, 4173, 71391, 71390, 71393, 71392, 71389, 71388, 71386, - 71395, 71387, 71394, 4195, 4196, 43509, 43508, 43511, 43510, 43507, - 43506, 43504, 43513, 43505, 43512, 4146, 4252, 4253, 4140, 4209, 4212, - 4210, 4211, 4147, 4148, 4228, 4229, 4230, 4227, 4194, 4145, 4149, 4199, - 4200, 4139, 4143, 4144, 4182, 4183, 4184, 4185, 4141, 4142, 71381, 71380, - 71383, 71382, 71379, 71378, 71376, 71385, 71377, 71384, 4165, 4164, 4167, - 4166, 4163, 4162, 4160, 4169, 4161, 4168, 983218, 983232, 983174, 10753, - 10754, 10752, 8720, 10761, 10757, 10758, 8721, 8899, 10756, 10755, 11007, - 8896, 8897, 8898, 8719, 67712, 67728, 67740, 67724, 67726, 67714, 67732, - 67718, 67730, 67723, 67742, 67717, 67729, 67738, 67739, 67713, 67735, - 67716, 67721, 67734, 67737, 67741, 67725, 67719, 67722, 67727, 67715, - 67733, 67720, 67736, 67731, 67758, 67752, 67753, 67757, 67751, 67759, - 67756, 67754, 67755, 8711, 124117, 124120, 124119, 124121, 124118, - 124132, 124136, 124133, 124138, 124137, 124134, 124135, 124122, 124124, - 124126, 124123, 124125, 124112, 124116, 124114, 124113, 124115, 124127, - 124128, 124129, 124130, 124131, 124140, 124143, 124142, 124139, 124141, - 124149, 124148, 124151, 124150, 124147, 124146, 124144, 124153, 124145, - 124152, 128133, 8358, 8892, 72102, 72103, 72138, 72096, 72097, 72107, - 72109, 72123, 72122, 72128, 72127, 72144, 72136, 72121, 72120, 72126, - 72125, 72100, 72101, 72098, 72099, 72143, 72137, 72114, 72124, 72119, - 72129, 72139, 72140, 72141, 72133, 72132, 72116, 72115, 72113, 72112, - 72118, 72117, 72111, 72110, 72131, 72130, 72142, 72134, 72135, 72106, - 72108, 72162, 72161, 72158, 72160, 72159, 72164, 72150, 72151, 72145, - 72155, 72157, 72148, 72149, 72146, 72147, 72154, 72156, 72163, 8302, - 127966, 129314, 128219, 129535, 8239, 983092, 983197, 983128, 9471, 9453, - 9460, 9452, 9458, 9451, 9454, 9455, 9459, 9456, 9457, 127312, 127313, - 127314, 127315, 127316, 127317, 127318, 127319, 127320, 127321, 127322, - 127323, 127324, 127325, 127326, 127327, 127328, 127329, 127330, 127331, - 127332, 127333, 127334, 127335, 127336, 127337, 128982, 128984, 129982, - 129981, 129983, 127344, 127345, 127346, 127347, 127348, 127349, 127350, - 127351, 127352, 127353, 127354, 127355, 127356, 127357, 127358, 127359, - 127360, 127361, 127362, 127363, 127364, 127365, 127366, 127367, 127368, - 127369, 129204, 129205, 129207, 129988, 10062, 127374, 127371, 127375, - 129206, 127372, 127373, 983091, 8879, 8840, 8841, 8775, 8821, 8817, 8825, - 8820, 8816, 8824, 129670, 129722, 11228, 129540, 129544, 129565, 129586, + 42766, 42761, 42771, 742, 8335, 721, 67511, 42888, 42768, 42763, 751, + 767, 753, 42773, 717, 754, 755, 744, 759, 719, 718, 42783, 752, 716, + 42778, 703, 43882, 706, 713, 42767, 42762, 42772, 743, 758, 757, 756, + 727, 766, 726, 697, 42780, 42782, 42779, 42781, 760, 705, 67508, 701, + 67513, 702, 43883, 707, 734, 42890, 765, 7491, 7493, 7516, 67459, 7495, + 122840, 7601, 122843, 7509, 67461, 122834, 7517, 7580, 7581, 122874, + 7590, 7591, 694, 67474, 67476, 7595, 67484, 122857, 67456, 67491, 67460, + 122856, 122858, 67478, 7600, 122833, 67498, 7608, 67506, 67471, 67492, + 7521, 7496, 67468, 67469, 122863, 122869, 67467, 122835, 67466, 122848, + 122849, 7519, 7585, 67480, 122846, 67463, 67465, 67464, 7497, 7604, + 67519, 122850, 122851, 7614, 122854, 122855, 7582, 7505, 7584, 67472, + 7501, 67475, 122836, 7518, 7520, 122867, 122868, 736, 688, 122870, 689, + 67477, 43868, 67479, 7503, 122875, 7504, 7596, 7588, 7589, 690, 7592, + 122841, 737, 67483, 122838, 43869, 43870, 7593, 67485, 122864, 7594, + 122837, 67481, 67482, 67486, 67487, 43001, 122844, 7598, 122865, 122871, + 7599, 7506, 7499, 7507, 67490, 7510, 122876, 7602, 67493, 122877, 122847, + 691, 67497, 122845, 67496, 67473, 740, 122859, 7583, 67470, 738, 67514, + 122872, 7603, 7586, 7498, 7513, 122830, 122831, 122860, 7511, 122878, + 122879, 122866, 7605, 67503, 67499, 67502, 122852, 122853, 7508, 67500, + 67501, 7492, 7579, 7494, 7587, 122861, 122862, 7514, 7597, 7500, 692, + 67494, 67495, 122829, 693, 122839, 67488, 67489, 7502, 67518, 67515, + 7610, 43881, 7615, 7512, 43871, 7606, 7607, 122842, 7515, 67504, 7609, + 7611, 7613, 122873, 7612, 695, 739, 696, 42784, 42785, 67517, 67458, + 67457, 67516, 720, 699, 724, 708, 749, 42864, 748, 712, 747, 746, 10762, + 128184, 128176, 129297, 71266, 6165, 6164, 6167, 6166, 6163, 6162, 6160, + 6169, 6161, 6168, 6159, 6157, 6156, 6155, 6147, 6149, 71271, 71272, 6176, + 6279, 6272, 6295, 6273, 6289, 6274, 6313, 6286, 6311, 6310, 6280, 6276, + 6275, 6282, 6287, 6278, 6285, 6284, 6288, 6277, 6291, 6290, 6293, 6294, + 6292, 6283, 6281, 6185, 6196, 6264, 6210, 6190, 6303, 6305, 6307, 6300, + 6302, 6304, 6312, 6298, 6301, 6314, 6308, 6309, 6299, 6306, 6263, 6262, + 6260, 6261, 6259, 6244, 6252, 6245, 6253, 6254, 6248, 6238, 6239, 6257, + 6247, 6256, 6242, 6258, 6255, 6241, 6240, 6249, 6251, 6250, 6243, 6246, + 6237, 6193, 6192, 6297, 6296, 6218, 6236, 6225, 6234, 6227, 6235, 6211, + 6222, 6232, 6228, 6224, 6226, 6233, 6214, 6216, 6215, 6217, 6219, 6231, + 6223, 6220, 6221, 6230, 6229, 6212, 6213, 6204, 6194, 6209, 6207, 6205, + 6206, 6203, 6202, 6208, 6191, 6177, 6183, 6179, 6181, 6180, 6182, 6186, + 6195, 6201, 6189, 6197, 6184, 6187, 6188, 6199, 6200, 6198, 6178, 71273, + 71275, 71274, 6151, 71265, 71270, 71269, 6144, 71268, 71264, 71267, + 71276, 6150, 6158, 6148, 6146, 6152, 6153, 6154, 6145, 9866, 9867, + 119552, 9101, 128669, 128018, 128053, 129740, 127889, 129390, 118261, + 128496, 129742, 129439, 128332, 129334, 128741, 128757, 129468, 128739, + 9968, 128670, 128672, 128693, 128507, 128001, 129700, 128045, 128068, + 128511, 127909, 92748, 92744, 92761, 92750, 92739, 92751, 92737, 92754, + 92749, 92753, 92743, 92752, 92757, 92766, 92736, 92741, 92746, 92764, + 92745, 92765, 92755, 92756, 92763, 92762, 92747, 92760, 92758, 92738, + 92740, 92759, 92742, 92783, 92782, 92773, 92772, 92775, 92774, 92771, + 92770, 92768, 92777, 92769, 92776, 70291, 70292, 70290, 70297, 70296, + 70293, 70287, 70298, 70312, 70311, 70306, 70285, 70284, 70289, 70288, + 70295, 70294, 70303, 70301, 70283, 70282, 70280, 70278, 70277, 70276, + 70300, 70299, 70310, 70307, 70304, 70309, 70308, 70305, 70272, 70275, + 70273, 70274, 70313, 127926, 215, 10807, 10804, 10805, 10811, 10801, + 10800, 10005, 8844, 8845, 8846, 8888, 127812, 117860, 9838, 9839, 9837, + 127929, 127896, 119171, 119423, 119172, 119161, 119159, 119155, 119157, + 119061, 119060, 119224, 119235, 119132, 119058, 119073, 119416, 119421, + 119059, 119255, 119253, 119130, 119131, 119163, 119169, 119149, 119167, + 119168, 119391, 119177, 119178, 119210, 119173, 119150, 119151, 119152, + 119153, 119154, 119376, 119377, 119378, 119175, 119212, 119213, 119142, + 119166, 119164, 119141, 119424, 119425, 119079, 119176, 119179, 119143, + 119144, 119145, 119387, 119388, 119165, 119211, 119080, 119170, 119174, + 119092, 119052, 119247, 119186, 119397, 119093, 119409, 119109, 119050, + 119220, 119221, 119044, 119049, 119187, 119398, 119209, 119400, 119399, + 119402, 119401, 119293, 119289, 119288, 119294, 119291, 119290, 119287, + 119292, 119082, 119406, 119041, 119414, 119404, 119083, 119077, 119078, + 119162, 119160, 119208, 119156, 119158, 119136, 119102, 119074, 119420, + 119419, 119076, 119075, 119056, 119057, 119146, 119147, 119148, 119389, + 119390, 119042, 119380, 119066, 119383, 119384, 119382, 119085, 119084, + 119065, 119069, 119185, 119231, 119232, 119070, 119413, 119072, 119415, + 119071, 119418, 119417, 119189, 119188, 119248, 119249, 119218, 119217, + 119216, 119275, 119385, 119280, 119279, 119134, 119100, 119206, 119407, + 119408, 119394, 119270, 119271, 119263, 119268, 119269, 119272, 119264, + 119262, 119267, 119266, 119265, 119274, 119223, 119234, 119233, 119295, + 119046, 119222, 119184, 119227, 119237, 119228, 119122, 119123, 119081, + 119098, 119207, 119129, 119087, 119086, 119128, 119396, 119140, 119106, + 119276, 119282, 119281, 119381, 119062, 119411, 119412, 119195, 119204, + 119205, 119196, 119197, 119198, 119199, 119200, 119201, 119202, 119203, + 119095, 119094, 119126, 119108, 119215, 119214, 119261, 119252, 119257, + 119258, 119183, 119090, 119091, 119135, 119101, 119097, 119096, 119053, + 119054, 119055, 119048, 119043, 119277, 119278, 119286, 119285, 119284, + 119283, 119047, 119180, 119254, 119259, 119225, 119236, 119226, 119229, + 119238, 119230, 119051, 119386, 119089, 119088, 119045, 119040, 119067, + 119068, 119137, 119103, 119139, 119105, 119110, 119111, 119405, 119250, + 119181, 119393, 119273, 119395, 119410, 119422, 119243, 119244, 119245, + 119246, 119242, 119240, 119239, 119241, 119064, 119138, 119104, 119256, + 119260, 119190, 119118, 119119, 119120, 119121, 119112, 119113, 119116, + 119117, 119114, 119115, 119124, 119125, 119403, 119392, 119191, 119193, + 119194, 119379, 119063, 119127, 119251, 119107, 119133, 119099, 119219, + 119192, 119182, 127932, 127925, 8811, 8810, 4158, 4156, 4157, 4155, 4192, + 4191, 4190, 4226, 4129, 43642, 4138, 4135, 4208, 4207, 4206, 4159, 4099, + 4098, 4097, 43625, 43624, 43626, 43623, 43622, 43621, 43627, 43618, + 43617, 43630, 43629, 43620, 43619, 983244, 43631, 43616, 43635, 43628, + 43633, 43634, 4096, 4188, 4189, 4187, 4186, 4136, 4121, 4106, 4111, 4100, + 4105, 4116, 4238, 4123, 4176, 43491, 4218, 4220, 43490, 4221, 4224, + 43492, 4223, 43489, 4216, 43488, 4215, 4214, 4213, 4219, 4222, 4225, + 4217, 4130, 43646, 43647, 4193, 4177, 4126, 4112, 43503, 43495, 43502, + 43501, 43516, 43515, 43518, 43517, 43498, 43497, 43500, 43499, 43514, + 43496, 4108, 4107, 4113, 4198, 4197, 4125, 4110, 4109, 4115, 4114, 4133, + 4134, 4178, 4179, 4180, 4181, 4131, 4132, 4128, 4124, 4120, 4119, 4102, + 4101, 4104, 4103, 4118, 4117, 4127, 4122, 4137, 43636, 43637, 43638, + 43632, 43494, 4245, 4244, 4247, 4246, 4243, 4242, 4240, 4249, 4241, 4248, + 4154, 4150, 4250, 4251, 4237, 4235, 4236, 4231, 4232, 4233, 4234, 43493, + 4171, 43644, 43645, 4201, 4202, 4203, 4204, 4205, 4151, 4239, 43643, + 4170, 4153, 4152, 43639, 43641, 43640, 4174, 4172, 4255, 4254, 4175, + 4173, 71391, 71390, 71393, 71392, 71389, 71388, 71386, 71395, 71387, + 71394, 4195, 4196, 43509, 43508, 43511, 43510, 43507, 43506, 43504, + 43513, 43505, 43512, 4146, 4252, 4253, 4140, 4209, 4212, 4210, 4211, + 4147, 4148, 4228, 4229, 4230, 4227, 4194, 4145, 4149, 4199, 4200, 4139, + 4143, 4144, 4182, 4183, 4184, 4185, 4141, 4142, 71381, 71380, 71383, + 71382, 71379, 71378, 71376, 71385, 71377, 71384, 4165, 4164, 4167, 4166, + 4163, 4162, 4160, 4169, 4161, 4168, 983218, 983232, 983174, 10753, 10754, + 10752, 8720, 10761, 10757, 10758, 8721, 8899, 10756, 10755, 11007, 8896, + 8897, 8898, 8719, 67712, 67728, 67740, 67724, 67726, 67714, 67732, 67718, + 67730, 67723, 67742, 67717, 67729, 67738, 67739, 67713, 67735, 67716, + 67721, 67734, 67737, 67741, 67725, 67719, 67722, 67727, 67715, 67733, + 67720, 67736, 67731, 67758, 67752, 67753, 67757, 67751, 67759, 67756, + 67754, 67755, 8711, 124117, 124120, 124119, 124121, 124118, 124132, + 124136, 124133, 124138, 124137, 124134, 124135, 124122, 124124, 124126, + 124123, 124125, 124112, 124116, 124114, 124113, 124115, 124127, 124128, + 124129, 124130, 124131, 124140, 124143, 124142, 124139, 124141, 124149, + 124148, 124151, 124150, 124147, 124146, 124144, 124153, 124145, 124152, + 128133, 8358, 8892, 72102, 72103, 72138, 72096, 72097, 72107, 72109, + 72123, 72122, 72128, 72127, 72144, 72136, 72121, 72120, 72126, 72125, + 72100, 72101, 72098, 72099, 72143, 72137, 72114, 72124, 72119, 72129, + 72139, 72140, 72141, 72133, 72132, 72116, 72115, 72113, 72112, 72118, + 72117, 72111, 72110, 72131, 72130, 72142, 72134, 72135, 72106, 72108, + 72162, 72161, 72158, 72160, 72159, 72164, 72150, 72151, 72145, 72155, + 72157, 72148, 72149, 72146, 72147, 72154, 72156, 72163, 8302, 127966, + 129314, 128219, 129535, 8239, 983092, 983197, 983128, 9471, 9453, 9460, + 9452, 9458, 9451, 9454, 9455, 9459, 9456, 9457, 127312, 127313, 127314, + 127315, 127316, 127317, 127318, 127319, 127320, 127321, 127322, 127323, + 127324, 127325, 127326, 127327, 127328, 127329, 127330, 127331, 127332, + 127333, 127334, 127335, 127336, 127337, 128982, 128984, 129982, 129981, + 129983, 127344, 127345, 127346, 127347, 127348, 127349, 127350, 127351, + 127352, 127353, 127354, 127355, 127356, 127357, 127358, 127359, 127360, + 127361, 127362, 127363, 127364, 127365, 127366, 127367, 127368, 127369, + 129204, 129205, 129207, 129988, 10062, 127374, 127371, 127375, 129206, + 127372, 127373, 983091, 8879, 8840, 8841, 8775, 8821, 8817, 8825, 8820, + 8816, 8824, 129670, 129722, 11228, 129540, 129544, 129565, 129586, 129603, 129607, 129561, 129536, 129557, 129599, 129539, 129560, 129602, 129610, 129613, 129541, 129562, 129604, 129537, 129558, 129600, 129538, 129559, 129601, 129581, 129578, 129582, 129583, 129579, 129580, 128528, @@ -11628,215 +11925,216 @@ static const unsigned int dawg_pos_to_codepoint[] = { 70666, 70668, 70723, 70726, 70727, 70724, 70752, 70728, 70753, 70722, 70725, 70730, 70750, 70747, 70709, 70719, 70721, 70712, 70713, 70714, 70715, 70716, 70717, 70710, 70711, 70718, 70720, 70735, 70749, 70733, - 70729, 11154, 11155, 128240, 9112, 983131, 9798, 11209, 128084, 129299, - 983132, 128985, 129399, 127747, 2035, 2031, 2032, 2033, 2030, 2034, 2027, - 2028, 2029, 2040, 2045, 2046, 1989, 1988, 1991, 1990, 1987, 1986, 1984, - 1993, 1985, 1992, 2042, 2008, 2001, 2025, 2024, 2026, 2006, 2002, 2019, - 2016, 2018, 2023, 2010, 2009, 2000, 1999, 2007, 1997, 1995, 2012, 2003, - 2013, 2020, 2014, 2015, 2017, 2004, 2011, 2005, 2021, 2022, 1994, 1996, - 1998, 2037, 2036, 2039, 2038, 2041, 2047, 983127, 128691, 9940, 128683, - 128695, 128370, 128286, 128245, 128685, 8303, 65934, 8209, 128689, 10973, - 8893, 8599, 10542, 10545, 10536, 10532, 129209, 10530, 128602, 128594, - 128610, 11111, 11127, 11016, 8663, 129109, 11008, 43063, 43062, 43065, - 43064, 43059, 43060, 43057, 43056, 43061, 43058, 10529, 8598, 8689, 8632, - 10546, 10535, 10531, 129208, 128600, 128592, 128608, 11110, 11126, 11017, - 8662, 129108, 11009, 128746, 8882, 8884, 8379, 8836, 8837, 8713, 8772, - 8777, 8938, 8940, 8742, 8930, 8931, 172, 8877, 8769, 8813, 8800, 8802, - 8815, 8814, 9083, 128323, 10159, 128324, 10161, 128456, 128457, 128458, - 128211, 128212, 128067, 118012, 160, 9369, 9362, 9365, 9366, 9367, 35, - 9368, 9364, 9361, 9363, 9371, 9370, 8470, 128297, 94177, 983041, 983040, - 123149, 123155, 123138, 123166, 123164, 123148, 123143, 123161, 123153, - 123152, 123141, 123137, 123156, 123139, 123163, 123142, 123172, 123173, - 123140, 123167, 123171, 123158, 123176, 123177, 123165, 123151, 123168, - 123136, 123169, 123162, 123178, 123179, 123144, 123157, 123170, 123150, - 123145, 123159, 123146, 123154, 123160, 123147, 123174, 123175, 123180, - 123214, 123193, 123192, 123195, 123194, 123191, 123196, 123197, 123184, - 123190, 123189, 123186, 123185, 123188, 123187, 123215, 123205, 123204, - 123207, 123206, 123203, 123202, 123200, 123209, 123201, 123208, 117776, - 983231, 983066, 10663, 10662, 11869, 9215, 65532, 9287, 9286, 9284, 9285, - 9289, 9281, 9290, 9288, 9282, 9283, 9280, 128721, 128025, 128885, 5787, - 5788, 5776, 5761, 5786, 5770, 5769, 5781, 5779, 5785, 5763, 5772, 5780, - 5784, 5762, 5775, 5773, 5765, 5777, 5782, 5764, 5774, 5783, 5766, 5778, - 5771, 5767, 5768, 5760, 731, 128738, 7265, 7264, 7266, 7267, 7261, 7260, - 7262, 7259, 7280, 7282, 7281, 7279, 7271, 7270, 7272, 7269, 7258, 7263, - 7278, 7268, 7283, 7273, 7284, 7285, 7287, 7286, 7276, 7274, 7275, 7277, - 7290, 7288, 7289, 7295, 7294, 7292, 7291, 7253, 7252, 7255, 7254, 7251, - 7250, 7248, 7257, 7249, 7256, 7293, 124374, 124376, 124375, 124377, - 124378, 124379, 124392, 124396, 124395, 124397, 124394, 124393, 124380, - 124381, 124383, 124384, 124385, 124382, 124368, 124371, 124370, 124369, - 124372, 124373, 124386, 124388, 124390, 124389, 124387, 124391, 124399, - 124400, 124398, 124415, 124406, 124405, 124408, 124407, 124404, 124403, - 124401, 124410, 124402, 124409, 94179, 94178, 68736, 68739, 68744, 68737, - 68756, 68745, 68760, 68769, 68761, 68775, 68785, 68741, 68762, 68772, - 68773, 68740, 68777, 68742, 68749, 68750, 68758, 68759, 68774, 68776, - 68783, 68784, 68738, 68743, 68747, 68748, 68751, 68754, 68755, 68768, - 68770, 68782, 68765, 68780, 68766, 68781, 68763, 68767, 68764, 68771, - 68778, 68757, 68786, 68779, 68746, 68752, 68753, 68800, 68803, 68808, - 68801, 68820, 68809, 68824, 68833, 68825, 68839, 68849, 68805, 68826, - 68836, 68837, 68804, 68841, 68806, 68813, 68814, 68822, 68823, 68838, - 68840, 68847, 68848, 68802, 68807, 68811, 68812, 68815, 68818, 68819, - 68832, 68834, 68846, 68829, 68844, 68830, 68845, 68827, 68831, 68828, - 68835, 68842, 68821, 68850, 68843, 68810, 68816, 68817, 68861, 68859, - 68858, 68862, 68863, 68860, 66308, 66324, 66318, 66335, 66323, 66331, - 66327, 66330, 66315, 66316, 66317, 66329, 66314, 66306, 66322, 66351, - 66321, 66350, 66326, 66334, 66313, 66333, 66328, 66320, 66312, 66325, - 66332, 66305, 66307, 66311, 66309, 66349, 66310, 66304, 66319, 66339, - 66337, 66338, 66336, 68241, 68242, 68246, 68244, 68226, 68224, 68237, - 68235, 68249, 68251, 68247, 68233, 68248, 68252, 68227, 68234, 68230, - 68239, 68232, 68240, 68231, 68250, 68236, 68225, 68243, 68245, 68228, - 68229, 68238, 68255, 68254, 68253, 66404, 66390, 66392, 66387, 66388, - 66411, 66393, 66421, 66418, 66396, 66397, 66399, 66406, 66405, 66401, - 66413, 66402, 66398, 66414, 66415, 66416, 66408, 66420, 66417, 66407, - 66419, 66389, 66391, 66395, 66400, 66386, 66409, 66410, 66385, 66384, - 66394, 66412, 66403, 66516, 66514, 66515, 66517, 66513, 66464, 66504, - 66505, 66506, 66482, 66510, 66511, 66477, 66508, 66509, 66478, 66479, - 66473, 66474, 66490, 66491, 66480, 66475, 66476, 66507, 66471, 66469, - 66470, 66467, 66468, 66484, 66485, 66492, 66493, 66486, 66487, 66488, - 66497, 66498, 66495, 66472, 66483, 66499, 66494, 66481, 66489, 66496, - 66465, 66466, 66512, 128435, 118450, 69414, 69395, 69376, 69394, 69391, - 69392, 69398, 69399, 69403, 69404, 69377, 69379, 69382, 69400, 69388, - 69380, 69384, 69393, 69397, 69401, 69386, 69381, 69385, 69387, 69378, - 69390, 69402, 69383, 69396, 69389, 69415, 69407, 69412, 69411, 69406, - 69410, 69405, 69413, 69409, 69408, 68209, 68210, 68217, 68211, 68213, - 68214, 68212, 68203, 68205, 68207, 68206, 68202, 68198, 68220, 68219, - 68215, 68201, 68216, 68193, 68196, 68199, 68218, 68192, 68194, 68200, - 68204, 68197, 68208, 68195, 68222, 68221, 68223, 68608, 68619, 68627, - 68623, 68634, 68640, 68644, 68668, 68670, 68677, 68632, 68669, 68671, - 68617, 68625, 68621, 68638, 68643, 68660, 68666, 68675, 68630, 68648, - 68653, 68646, 68650, 68641, 68673, 68658, 68642, 68655, 68628, 68611, - 68657, 68662, 68614, 68615, 68636, 68656, 68664, 68679, 68680, 68609, - 68610, 68645, 68654, 68620, 68624, 68635, 68678, 68633, 68672, 68652, - 68618, 68626, 68622, 68639, 68661, 68667, 68676, 68631, 68613, 68649, - 68647, 68651, 68674, 68659, 68629, 68612, 68663, 68616, 68637, 68665, - 69509, 69508, 69507, 69506, 69488, 69502, 69496, 69505, 69492, 69499, - 69501, 69503, 69494, 69493, 69490, 69495, 69489, 69498, 69504, 69491, - 69500, 69497, 69511, 69512, 69513, 69510, 128477, 128117, 129491, 128116, - 129746, 128283, 128664, 128753, 128662, 128660, 128653, 11819, 8228, - 128431, 129649, 129477, 128214, 9251, 10044, 10027, 10034, 10011, 128194, - 128449, 128080, 128237, 128236, 10180, 10179, 128275, 9103, 9104, 10174, - 983191, 8997, 128191, 128440, 9934, 9741, 128217, 129505, 129447, 128895, - 129741, 8886, 2902, 2903, 2933, 2934, 2931, 2930, 2935, 2932, 2928, 2909, - 2908, 2864, 2911, 2863, 2821, 2822, 2832, 2836, 2850, 2849, 2855, 2854, - 2848, 2847, 2853, 2852, 2827, 2912, 2828, 2913, 2869, 2825, 2826, 2823, - 2824, 2867, 2866, 2841, 2851, 2846, 2856, 2870, 2871, 2872, 2861, 2860, - 2843, 2842, 2840, 2839, 2845, 2844, 2838, 2837, 2859, 2858, 2873, 2862, - 2929, 2831, 2835, 983660, 983659, 2817, 2876, 2877, 2818, 2901, 2893, - 2819, 2878, 2888, 2892, 2881, 2882, 2883, 2884, 2914, 2915, 2879, 2880, - 2887, 2891, 2923, 2922, 2925, 2924, 2921, 2920, 2918, 2927, 2919, 2926, - 64830, 64831, 9766, 117826, 10183, 66736, 66737, 66738, 66739, 66743, - 66763, 66761, 66742, 66749, 66757, 66744, 66768, 66750, 66748, 66754, - 66755, 66764, 66762, 66760, 66746, 66745, 66741, 66765, 66769, 66759, - 66758, 66771, 66770, 66740, 66751, 66752, 66753, 66756, 66767, 66747, - 66766, 66776, 66777, 66778, 66779, 66783, 66803, 66801, 66782, 66789, - 66797, 66784, 66808, 66790, 66788, 66794, 66795, 66804, 66802, 66800, - 66786, 66785, 66781, 66805, 66809, 66799, 66798, 66811, 66810, 66780, - 66791, 66792, 66793, 66796, 66807, 66787, 66806, 66710, 66688, 66715, - 66699, 66694, 66698, 66703, 66693, 66697, 66696, 66705, 66702, 66713, - 66717, 66704, 66706, 66707, 66711, 66716, 66689, 66701, 66700, 66708, - 66691, 66695, 66690, 66692, 66709, 66712, 66714, 66725, 66724, 66727, - 66726, 66723, 66722, 66720, 66729, 66721, 66728, 983192, 126257, 126264, - 126258, 126259, 126265, 126260, 126263, 126267, 126255, 126266, 126256, - 126262, 126261, 126269, 126268, 126254, 126216, 126225, 126252, 126234, - 126243, 126222, 126249, 126213, 126231, 126240, 126221, 126248, 126212, - 126230, 126239, 126217, 126226, 126253, 126235, 126244, 126215, 126224, - 126251, 126233, 126242, 126214, 126223, 126250, 126232, 126241, 126220, - 126247, 126211, 126229, 126238, 126219, 126246, 126210, 126228, 126237, - 126218, 126245, 126209, 126227, 126236, 129446, 128228, 117974, 117975, - 117976, 117977, 117978, 117979, 117980, 117981, 117982, 117983, 117984, - 117985, 117986, 117987, 117988, 117989, 117990, 117991, 117992, 117993, - 117994, 117995, 117996, 117997, 117998, 117999, 10015, 9885, 10029, - 10009, 118005, 118004, 118007, 118006, 118003, 118002, 118000, 118009, - 118001, 118008, 8485, 129397, 128471, 11195, 11194, 11196, 8254, 129450, - 127970, 118459, 8486, 128076, 127842, 128329, 129417, 128002, 983122, - 983121, 128463, 128195, 128479, 128196, 128223, 128464, 128724, 93059, - 93065, 93064, 93058, 93070, 93056, 93055, 93053, 93062, 93069, 93061, - 93066, 93071, 93068, 93054, 93057, 93063, 93067, 93060, 92967, 92975, - 92965, 92969, 92959, 92968, 92971, 92957, 92962, 92960, 92972, 92970, - 92963, 92958, 92966, 92961, 92956, 92974, 92964, 92973, 92979, 92978, - 92980, 92977, 92976, 92982, 92981, 93023, 93020, 93024, 93021, 93019, - 93025, 93022, 93043, 92985, 93047, 93044, 93045, 92997, 93046, 93042, - 93032, 93029, 92995, 93038, 92993, 93041, 93035, 93033, 93037, 93030, - 93039, 92987, 92992, 92986, 92983, 92984, 93027, 92994, 93034, 92988, - 92990, 92989, 92991, 93028, 92996, 93031, 93040, 93036, 92954, 92955, - 92938, 92939, 92932, 92933, 92942, 92943, 92950, 92951, 92928, 92929, - 92936, 92937, 92948, 92949, 92930, 92931, 92944, 92945, 92934, 92935, - 92940, 92941, 92946, 92947, 92952, 92953, 93013, 93012, 93015, 93014, - 93011, 93010, 93008, 93017, 93009, 93016, 9908, 11801, 127796, 129779, - 129780, 67703, 67693, 67688, 67702, 67683, 67691, 67699, 67700, 67680, - 67696, 67682, 67686, 67695, 67698, 67701, 67689, 67684, 67687, 67690, - 67681, 67694, 67685, 67697, 67692, 67704, 67711, 67706, 67707, 67710, - 67709, 67708, 67705, 129330, 129374, 128060, 8233, 11853, 11791, 10995, - 10994, 8741, 129666, 12809, 12823, 12808, 12822, 12828, 12813, 12827, - 12810, 12824, 12800, 12814, 12804, 12818, 12801, 12815, 12812, 12826, - 12805, 12819, 12803, 12817, 12806, 12820, 12811, 12825, 12802, 12816, - 12807, 12821, 12863, 12855, 12858, 12861, 12847, 12839, 12854, 12843, - 12836, 12864, 12835, 12856, 12846, 12842, 12840, 12852, 12862, 12865, - 12857, 12867, 12838, 12866, 12851, 12853, 12859, 12849, 12860, 12848, - 12837, 12834, 12841, 12833, 12845, 12844, 12850, 12832, 12830, 12829, - 9349, 9342, 9345, 9346, 9350, 9347, 9348, 9344, 9351, 9343, 9341, 9336, - 9335, 9338, 9337, 9334, 9333, 9340, 9332, 9339, 127248, 127249, 127250, - 127251, 127252, 127253, 127254, 127255, 127256, 127257, 127258, 127259, - 127260, 127261, 127262, 127263, 127264, 127265, 127266, 127267, 127268, - 127269, 127270, 127271, 127272, 127273, 9372, 9373, 9374, 9375, 9376, - 9377, 9378, 9379, 9380, 9381, 9382, 9383, 9384, 9385, 9386, 9387, 9388, - 9389, 9390, 9391, 9392, 9393, 9394, 9395, 9396, 9397, 8706, 983147, - 983146, 983149, 983150, 9853, 127881, 118468, 128890, 12880, 12349, - 129436, 128755, 11261, 9105, 9106, 128706, 72437, 72440, 72432, 72416, - 72419, 72413, 72417, 72415, 72412, 72414, 72418, 72420, 72403, 72407, - 72411, 72409, 72410, 72391, 72400, 72404, 72397, 72394, 72385, 72401, - 72384, 72399, 72398, 72396, 72388, 72393, 72392, 72386, 72387, 72402, - 72395, 72390, 72389, 72405, 72406, 72408, 72436, 72435, 72438, 72439, - 72422, 72421, 72424, 72425, 72431, 72433, 72434, 72428, 72427, 72429, - 72430, 72423, 72426, 128062, 128230, 128206, 983228, 983237, 129434, - 9774, 127825, 129372, 129755, 127824, 128039, 128532, 9956, 128390, 9999, - 8240, 8241, 8524, 10178, 10977, 129336, 129496, 129494, 128113, 9977, - 128590, 129733, 128591, 129493, 128589, 128588, 129495, 128583, 128187, - 8966, 128547, 37, 9854, 127917, 8359, 8369, 129515, 128694, 129730, - 43101, 43117, 43120, 43076, 43123, 43077, 43115, 43090, 43082, 43094, - 43098, 43099, 43119, 43118, 43109, 43074, 43075, 43116, 43079, 43083, - 43089, 43088, 43114, 43113, 43081, 43080, 43073, 43072, 43085, 43084, - 43092, 43093, 43104, 43110, 43086, 43108, 43100, 43078, 43097, 43087, - 43106, 43096, 43091, 43107, 43095, 43102, 43105, 43103, 43127, 43126, - 43124, 43121, 43111, 43112, 43122, 43125, 66033, 66023, 66017, 66010, - 66027, 66003, 66018, 66028, 66004, 66012, 66022, 66020, 66045, 66019, - 66031, 66041, 66007, 66006, 66025, 66026, 66038, 66016, 66013, 66014, - 66000, 66001, 66034, 66036, 66037, 66029, 66011, 66024, 66015, 66021, - 66042, 66043, 66002, 66008, 66032, 66005, 66044, 66040, 66039, 66030, - 66009, 66035, 5941, 5942, 67840, 67855, 67843, 67844, 67847, 67858, - 67857, 67860, 67854, 67861, 67848, 67845, 67846, 67849, 67859, 67842, - 67850, 67853, 67851, 67841, 67856, 67852, 67864, 67866, 67867, 67863, - 67862, 67865, 67871, 11227, 9935, 128763, 128022, 128061, 128055, 128169, - 182, 128138, 129292, 129295, 127885, 127821, 10031, 129655, 129669, 9811, - 128299, 8916, 10970, 129383, 8984, 128720, 129703, 8462, 8463, 128733, - 127183, 127136, 127167, 127199, 127188, 127140, 127156, 127172, 127200, - 127189, 127141, 127157, 127173, 127196, 127148, 127164, 127180, 127198, - 127150, 127166, 127182, 127192, 127144, 127160, 127176, 127191, 127143, - 127159, 127175, 127190, 127142, 127158, 127174, 127197, 127149, 127165, - 127181, 127194, 127146, 127162, 127178, 127187, 127139, 127155, 127171, - 127186, 127138, 127154, 127170, 127202, 127220, 127221, 127201, 127210, - 127211, 127212, 127213, 127214, 127215, 127216, 127217, 127218, 127219, - 127203, 127204, 127205, 127206, 127207, 127208, 127209, 127185, 127137, - 127153, 127169, 127193, 127145, 127161, 127177, 127195, 127147, 127163, - 127179, 983151, 43, 10797, 10798, 10809, 10789, 10786, 10791, 10790, - 10788, 10792, 10787, 10866, 177, 9799, 11222, 11221, 11220, 11219, - 129696, 983148, 117777, 128659, 128680, 128110, 8297, 8236, 127871, - 128254, 11239, 128239, 12306, 12320, 128238, 8982, 128688, 129364, - 127858, 129716, 127831, 129751, 128574, 128545, 163, 128093, 9212, 9213, - 9214, 9211, 128041, 128425, 129328, 129732, 129731, 65043, 65040, 65045, - 65073, 65074, 65049, 65041, 65042, 65091, 65047, 65083, 65085, 65089, - 65079, 65087, 65077, 65095, 65081, 65075, 65084, 65086, 65092, 983261, - 65048, 65090, 65080, 65088, 65078, 65096, 65082, 65076, 65044, 65072, - 65046, 8478, 8826, 10937, 10933, 10927, 10929, 10935, 10931, 8936, 8830, - 8828, 8880, 9111, 129384, 9113, 128424, 128438, 129332, 128120, 983193, - 983166, 983163, 983164, 983167, 8242, 8965, 8759, 8733, 8522, 11224, - 128711, 129455, 128255, 68507, 68508, 68480, 68483, 68490, 68491, 68485, - 68482, 68486, 68493, 68495, 68496, 68488, 68484, 68487, 68489, 68481, - 68492, 68497, 68494, 68526, 68522, 68523, 68525, 68521, 68527, 68524, - 68505, 68506, 118473, 11854, 8200, 128156, 128091, 128686, 128204, - 128226, 983165, 983168, 983194, 9624, 9625, 9626, 9627, 9628, 9629, 9630, - 9631, 9622, 9623, 10764, 8279, 10774, 9833, 128894, 8264, 63, 8799, 34, - 9915, 127949, 127950, 129437, 128251, 9762, 128280, 9143, 128740, 128643, - 9926, 127752, 11827, 11783, 11782, 9995, 128400, 128406, 127338, 127339, + 70729, 11154, 11155, 128240, 9112, 983131, 9798, 11209, 129677, 128084, + 129299, 983132, 128985, 129399, 127747, 2031, 2032, 2033, 2030, 2034, + 2027, 2028, 2029, 2035, 2040, 2045, 2046, 1989, 1988, 1991, 1990, 1987, + 1986, 1984, 1993, 1985, 1992, 2042, 2008, 2001, 2025, 2024, 2026, 2006, + 2002, 2019, 2016, 2018, 2023, 2010, 2009, 2000, 1999, 2007, 1997, 1995, + 2012, 2003, 2013, 2020, 2014, 2015, 2017, 2004, 2011, 2005, 2021, 2022, + 1994, 1996, 1998, 2037, 2036, 2039, 2038, 2047, 2041, 983127, 128691, + 9940, 128683, 128695, 128370, 128286, 128245, 128685, 8303, 65934, 8209, + 128689, 10973, 8893, 8599, 10542, 10545, 10536, 10532, 129209, 10530, + 128602, 128594, 128610, 11111, 11127, 11016, 8663, 129109, 11008, 43063, + 43062, 43065, 43064, 43059, 43060, 43057, 43056, 43061, 43058, 10529, + 8598, 8689, 8632, 10546, 10535, 10531, 129208, 128600, 128592, 128608, + 11110, 11126, 11017, 8662, 129108, 11009, 128746, 8882, 8884, 8379, 8836, + 8837, 8713, 8772, 8777, 8938, 8940, 8742, 8930, 8931, 172, 8877, 8769, + 8813, 8800, 8802, 8815, 8814, 9083, 128323, 10159, 128324, 10161, 128456, + 128457, 128458, 128211, 128212, 128067, 118012, 160, 9369, 9362, 9365, + 9366, 9367, 35, 9368, 9364, 9361, 9363, 9371, 9370, 8470, 128297, 94177, + 983041, 983040, 123149, 123155, 123138, 123166, 123164, 123148, 123143, + 123161, 123153, 123152, 123141, 123137, 123156, 123139, 123163, 123142, + 123172, 123173, 123140, 123167, 123171, 123158, 123176, 123177, 123165, + 123151, 123168, 123136, 123169, 123162, 123178, 123179, 123144, 123157, + 123170, 123150, 123145, 123159, 123146, 123154, 123160, 123147, 123174, + 123175, 123180, 123214, 123193, 123192, 123195, 123194, 123191, 123196, + 123197, 123184, 123190, 123189, 123186, 123185, 123188, 123187, 123215, + 123205, 123204, 123207, 123206, 123203, 123202, 123200, 123209, 123201, + 123208, 117776, 983231, 983066, 10663, 10662, 11869, 9215, 65532, 9287, + 9285, 9286, 9284, 9289, 9281, 9290, 9288, 9282, 9283, 9280, 128721, + 128025, 128885, 5787, 5788, 5776, 5761, 5786, 5770, 5769, 5781, 5779, + 5785, 5763, 5772, 5780, 5784, 5762, 5775, 5773, 5765, 5777, 5782, 5764, + 5774, 5783, 5766, 5778, 5771, 5767, 5768, 5760, 731, 128738, 7265, 7264, + 7266, 7267, 7261, 7260, 7262, 7259, 7280, 7282, 7281, 7279, 7271, 7270, + 7272, 7269, 7258, 7263, 7278, 7268, 7283, 7273, 7284, 7285, 7287, 7286, + 7276, 7274, 7275, 7277, 7290, 7288, 7289, 7295, 7294, 7292, 7291, 7253, + 7252, 7255, 7254, 7251, 7250, 7248, 7257, 7249, 7256, 7293, 124374, + 124376, 124375, 124377, 124378, 124379, 124392, 124396, 124395, 124397, + 124394, 124393, 124380, 124381, 124383, 124384, 124385, 124382, 124368, + 124371, 124370, 124369, 124372, 124373, 124386, 124388, 124390, 124389, + 124387, 124391, 124399, 124400, 124398, 124415, 124406, 124405, 124408, + 124407, 124404, 124403, 124401, 124410, 124402, 124409, 94179, 94178, + 68736, 68739, 68744, 68737, 68756, 68745, 68760, 68769, 68761, 68775, + 68785, 68741, 68762, 68772, 68773, 68740, 68777, 68742, 68749, 68750, + 68758, 68759, 68774, 68776, 68783, 68784, 68738, 68743, 68747, 68748, + 68751, 68754, 68755, 68768, 68770, 68782, 68765, 68780, 68766, 68781, + 68763, 68767, 68764, 68771, 68778, 68757, 68786, 68779, 68746, 68752, + 68753, 68800, 68803, 68808, 68801, 68820, 68809, 68824, 68833, 68825, + 68839, 68849, 68805, 68826, 68836, 68837, 68804, 68841, 68806, 68813, + 68814, 68822, 68823, 68838, 68840, 68847, 68848, 68802, 68807, 68811, + 68812, 68815, 68818, 68819, 68832, 68834, 68846, 68829, 68844, 68830, + 68845, 68827, 68831, 68828, 68835, 68842, 68821, 68850, 68843, 68810, + 68816, 68817, 68861, 68859, 68858, 68862, 68863, 68860, 66308, 66324, + 66318, 66335, 66323, 66331, 66327, 66330, 66315, 66316, 66317, 66329, + 66314, 66306, 66322, 66351, 66321, 66350, 66326, 66334, 66313, 66333, + 66328, 66320, 66312, 66325, 66332, 66305, 66307, 66311, 66309, 66349, + 66310, 66304, 66319, 66339, 66337, 66338, 66336, 68241, 68242, 68246, + 68244, 68226, 68224, 68237, 68235, 68249, 68251, 68247, 68233, 68248, + 68252, 68227, 68234, 68230, 68239, 68232, 68240, 68231, 68250, 68236, + 68225, 68243, 68245, 68228, 68229, 68238, 68255, 68254, 68253, 66404, + 66390, 66392, 66387, 66388, 66411, 66393, 66421, 66418, 66396, 66397, + 66399, 66406, 66405, 66401, 66413, 66402, 66398, 66414, 66415, 66416, + 66408, 66420, 66417, 66407, 66419, 66389, 66391, 66395, 66400, 66386, + 66409, 66410, 66385, 66384, 66394, 66412, 66403, 66516, 66514, 66515, + 66517, 66513, 66464, 66504, 66505, 66506, 66482, 66510, 66511, 66477, + 66508, 66509, 66478, 66479, 66473, 66474, 66490, 66491, 66480, 66475, + 66476, 66507, 66471, 66469, 66470, 66467, 66468, 66484, 66485, 66492, + 66493, 66486, 66487, 66488, 66497, 66498, 66495, 66472, 66483, 66499, + 66494, 66481, 66489, 66496, 66465, 66466, 66512, 128435, 118450, 69414, + 69395, 69376, 69394, 69391, 69392, 69398, 69399, 69403, 69404, 69377, + 69379, 69382, 69400, 69388, 69380, 69384, 69393, 69397, 69401, 69386, + 69381, 69385, 69387, 69378, 69390, 69402, 69383, 69396, 69389, 69415, + 69407, 69412, 69411, 69406, 69410, 69405, 69413, 69409, 69408, 68209, + 68210, 68217, 68211, 68213, 68214, 68212, 68203, 68205, 68207, 68206, + 68202, 68198, 68220, 68219, 68215, 68201, 68216, 68193, 68196, 68199, + 68218, 68192, 68194, 68200, 68204, 68197, 68208, 68195, 68222, 68221, + 68223, 68608, 68619, 68627, 68623, 68634, 68640, 68644, 68668, 68670, + 68677, 68632, 68669, 68671, 68617, 68625, 68621, 68638, 68643, 68660, + 68666, 68675, 68630, 68648, 68653, 68646, 68650, 68641, 68673, 68658, + 68642, 68655, 68628, 68611, 68657, 68662, 68614, 68615, 68636, 68656, + 68664, 68679, 68680, 68609, 68610, 68645, 68654, 68620, 68624, 68635, + 68678, 68633, 68672, 68652, 68618, 68626, 68622, 68639, 68661, 68667, + 68676, 68631, 68613, 68649, 68647, 68651, 68674, 68659, 68629, 68612, + 68663, 68616, 68637, 68665, 69509, 69508, 69507, 69506, 69488, 69502, + 69496, 69505, 69492, 69499, 69501, 69503, 69494, 69493, 69490, 69495, + 69489, 69498, 69504, 69491, 69500, 69497, 69511, 69512, 69513, 69510, + 128477, 128117, 129491, 128116, 129746, 8388, 128329, 128283, 128664, + 128753, 128662, 128660, 128653, 11819, 8228, 128431, 129649, 129477, + 128214, 9251, 10044, 10027, 10034, 10011, 128194, 128449, 128080, 128237, + 128236, 10180, 10179, 128275, 9103, 9104, 10174, 983191, 8997, 128191, + 128440, 9934, 9741, 128217, 129505, 129447, 128895, 129741, 8886, 2902, + 2903, 2933, 2934, 2931, 2930, 2935, 2932, 2928, 2909, 2908, 2864, 2911, + 2863, 2821, 2822, 2832, 2836, 2850, 2849, 2855, 2854, 2848, 2847, 2853, + 2852, 2827, 2912, 2828, 2913, 2869, 2825, 2826, 2823, 2824, 2867, 2866, + 2841, 2851, 2846, 2856, 2870, 2871, 2872, 2861, 2860, 2843, 2842, 2840, + 2839, 2845, 2844, 2838, 2837, 2859, 2858, 2873, 2862, 2929, 2831, 2835, + 983660, 983659, 2900, 2899, 2817, 2876, 2877, 2818, 2901, 2893, 2819, + 2878, 2888, 2892, 2881, 2882, 2883, 2884, 2914, 2915, 2879, 2880, 2887, + 2891, 2923, 2922, 2925, 2924, 2921, 2920, 2918, 2927, 2919, 2926, 64830, + 64831, 9766, 117826, 10183, 66736, 66737, 66738, 66739, 66743, 66763, + 66761, 66742, 66749, 66757, 66744, 66768, 66750, 66748, 66754, 66755, + 66764, 66762, 66760, 66746, 66745, 66741, 66765, 66769, 66759, 66758, + 66771, 66770, 66740, 66751, 66752, 66753, 66756, 66767, 66747, 66766, + 66776, 66777, 66778, 66779, 66783, 66803, 66801, 66782, 66789, 66797, + 66784, 66808, 66790, 66788, 66794, 66795, 66804, 66802, 66800, 66786, + 66785, 66781, 66805, 66809, 66799, 66798, 66811, 66810, 66780, 66791, + 66792, 66793, 66796, 66807, 66787, 66806, 66710, 66688, 66715, 66699, + 66694, 66698, 66703, 66693, 66697, 66696, 66705, 66702, 66713, 66717, + 66704, 66706, 66707, 66711, 66716, 66689, 66701, 66700, 66708, 66691, + 66695, 66690, 66692, 66709, 66712, 66714, 66725, 66724, 66727, 66726, + 66723, 66722, 66720, 66729, 66721, 66728, 983192, 126257, 126264, 126258, + 126259, 126265, 126260, 126263, 126267, 126255, 126266, 126256, 126262, + 126261, 126269, 126268, 126254, 126216, 126225, 126252, 126234, 126243, + 126222, 126249, 126213, 126231, 126240, 126221, 126248, 126212, 126230, + 126239, 126217, 126226, 126253, 126235, 126244, 126215, 126224, 126251, + 126233, 126242, 126214, 126223, 126250, 126232, 126241, 126220, 126247, + 126211, 126229, 126238, 126219, 126246, 126210, 126228, 126237, 126218, + 126245, 126209, 126227, 126236, 129446, 128228, 117974, 117975, 117976, + 117977, 117978, 117979, 117980, 117981, 117982, 117983, 117984, 117985, + 117986, 117987, 117988, 117989, 117990, 117991, 117992, 117993, 117994, + 117995, 117996, 117997, 117998, 117999, 10015, 9885, 10029, 10009, + 118005, 118004, 118007, 118006, 118003, 118002, 118000, 118009, 118001, + 118008, 8485, 129397, 128471, 11195, 11194, 11196, 8254, 129450, 127970, + 118459, 128076, 8486, 127842, 129417, 128002, 983122, 983121, 128463, + 128196, 128195, 128479, 128223, 128464, 128724, 93059, 93065, 93064, + 93058, 93070, 93056, 93055, 93053, 93062, 93069, 93061, 93066, 93071, + 93068, 93054, 93057, 93063, 93067, 93060, 92967, 92975, 92965, 92969, + 92959, 92968, 92971, 92957, 92962, 92960, 92972, 92970, 92963, 92958, + 92966, 92961, 92956, 92974, 92964, 92973, 92979, 92978, 92980, 92977, + 92976, 92982, 92981, 93023, 93020, 93024, 93021, 93019, 93025, 93022, + 93043, 92985, 93047, 93044, 93045, 92997, 93046, 93042, 93032, 93029, + 92995, 93038, 92993, 93041, 93035, 93033, 93037, 93030, 93039, 92987, + 92992, 92986, 92983, 92984, 93027, 92994, 93034, 92988, 92990, 92989, + 92991, 93028, 92996, 93031, 93040, 93036, 92954, 92955, 92938, 92939, + 92932, 92933, 92942, 92943, 92950, 92951, 92928, 92929, 92936, 92937, + 92948, 92949, 92930, 92931, 92944, 92945, 92934, 92935, 92940, 92941, + 92946, 92947, 92952, 92953, 93013, 93012, 93015, 93014, 93011, 93010, + 93008, 93017, 93009, 93016, 9908, 11801, 127796, 129779, 129780, 67703, + 67693, 67688, 67702, 67683, 67691, 67699, 67700, 67680, 67696, 67682, + 67686, 67695, 67698, 67701, 67689, 67684, 67687, 67690, 67681, 67694, + 67685, 67697, 67692, 67704, 67711, 67706, 67707, 67710, 67709, 67708, + 67705, 129330, 129374, 128060, 8233, 11853, 11791, 10995, 10994, 8741, + 129666, 12809, 12823, 12808, 12822, 12828, 12813, 12827, 12810, 12824, + 12800, 12814, 12804, 12818, 12801, 12815, 12812, 12826, 12805, 12819, + 12803, 12817, 12806, 12820, 12811, 12825, 12802, 12816, 12807, 12821, + 12863, 12855, 12858, 12861, 12847, 12839, 12854, 12843, 12836, 12864, + 12835, 12856, 12846, 12842, 12840, 12852, 12862, 12865, 12857, 12867, + 12838, 12866, 12851, 12853, 12859, 12849, 12860, 12848, 12837, 12834, + 12841, 12833, 12845, 12844, 12850, 12832, 12830, 12829, 9349, 9342, 9345, + 9346, 9350, 9347, 9348, 9344, 9351, 9343, 9341, 9336, 9335, 9338, 9337, + 9334, 9333, 9340, 9332, 9339, 127248, 127249, 127250, 127251, 127252, + 127253, 127254, 127255, 127256, 127257, 127258, 127259, 127260, 127261, + 127262, 127263, 127264, 127265, 127266, 127267, 127268, 127269, 127270, + 127271, 127272, 127273, 9372, 9373, 9374, 9375, 9376, 9377, 9378, 9379, + 9380, 9381, 9382, 9383, 9384, 9385, 9386, 9387, 9388, 9389, 9390, 9391, + 9392, 9393, 9394, 9395, 9396, 9397, 8706, 983147, 983146, 983149, 983150, + 9853, 127881, 118468, 128890, 12880, 12349, 129436, 128755, 11261, 9105, + 9106, 128706, 72437, 72440, 72432, 72416, 72419, 72413, 72417, 72415, + 72412, 72414, 72418, 72420, 72403, 72407, 72411, 72409, 72410, 72391, + 72400, 72404, 72397, 72394, 72385, 72401, 72384, 72399, 72398, 72396, + 72388, 72393, 72392, 72386, 72387, 72402, 72395, 72390, 72389, 72405, + 72406, 72408, 72436, 72435, 72438, 72439, 72422, 72421, 72424, 72425, + 72431, 72433, 72434, 72428, 72427, 72429, 72430, 72423, 72426, 128062, + 128230, 128206, 983228, 983237, 129434, 9774, 127825, 129372, 129755, + 127824, 128039, 128532, 9956, 128390, 9999, 8240, 8241, 8524, 10178, + 10977, 129336, 129496, 129494, 128113, 9977, 129733, 128590, 128591, + 129493, 128589, 128588, 129495, 128583, 128187, 8966, 128547, 37, 9854, + 127917, 8359, 8369, 129515, 128694, 129730, 43101, 43117, 43120, 43076, + 43123, 43077, 43115, 43090, 43082, 43094, 43098, 43099, 43119, 43118, + 43109, 43074, 43075, 43116, 43079, 43083, 43089, 43088, 43114, 43113, + 43081, 43080, 43073, 43072, 43085, 43084, 43092, 43093, 43104, 43110, + 43086, 43108, 43100, 43078, 43097, 43087, 43106, 43096, 43091, 43107, + 43095, 43102, 43105, 43103, 43127, 43126, 43124, 43121, 43111, 43112, + 43122, 43125, 66033, 66023, 66017, 66010, 66027, 66003, 66018, 66028, + 66004, 66012, 66022, 66020, 66045, 66019, 66031, 66041, 66007, 66006, + 66025, 66026, 66038, 66016, 66013, 66014, 66000, 66001, 66034, 66036, + 66037, 66029, 66011, 66024, 66015, 66021, 66042, 66043, 66002, 66008, + 66032, 66005, 66044, 66040, 66039, 66030, 66009, 66035, 5941, 5942, + 67840, 67855, 67843, 67844, 67847, 67858, 67857, 67860, 67854, 67861, + 67848, 67845, 67846, 67849, 67859, 67842, 67850, 67853, 67851, 67841, + 67856, 67852, 67864, 67866, 67867, 67863, 67862, 67865, 67871, 11227, + 9935, 128763, 129757, 128022, 128061, 128055, 128169, 182, 128138, + 129292, 129295, 127885, 127821, 10031, 129655, 129669, 9811, 128299, + 8916, 10970, 129383, 8984, 128720, 129703, 8462, 8463, 128733, 127183, + 127136, 127167, 127199, 127188, 127140, 127156, 127172, 127200, 127189, + 127141, 127157, 127173, 127196, 127148, 127164, 127180, 127198, 127150, + 127166, 127182, 127192, 127144, 127160, 127176, 127191, 127143, 127159, + 127175, 127190, 127142, 127158, 127174, 127197, 127149, 127165, 127181, + 127194, 127146, 127162, 127178, 127187, 127139, 127155, 127171, 127186, + 127138, 127154, 127170, 127202, 127220, 127221, 127201, 127210, 127211, + 127212, 127213, 127214, 127215, 127216, 127217, 127218, 127219, 127203, + 127204, 127205, 127206, 127207, 127208, 127209, 127185, 127137, 127153, + 127169, 127193, 127145, 127161, 127177, 127195, 127147, 127163, 127179, + 983151, 43, 10797, 10798, 10809, 10789, 10786, 10791, 10790, 10788, + 10792, 10787, 10866, 177, 9799, 11222, 11221, 11220, 11219, 129696, + 983148, 117777, 128659, 128680, 128110, 8297, 8236, 127871, 128254, + 11239, 128239, 12306, 12320, 128238, 8982, 128688, 129364, 127858, + 129716, 127831, 129751, 128574, 128545, 163, 128093, 9212, 9213, 9214, + 9211, 128041, 128425, 129328, 129732, 129731, 65043, 65040, 65073, 65074, + 65045, 65049, 65041, 65042, 65091, 65047, 65083, 65085, 65089, 65079, + 65087, 65077, 65095, 65081, 65075, 65084, 65086, 65092, 983261, 65048, + 65090, 65080, 65088, 65078, 65096, 65082, 65076, 65044, 65072, 65046, + 8478, 8826, 10937, 10933, 10927, 10929, 10935, 10931, 8936, 8830, 8828, + 8880, 9111, 129384, 9113, 128424, 128438, 129332, 128120, 983193, 983166, + 983163, 983164, 983167, 8242, 8965, 8759, 8733, 8522, 11224, 128711, + 129455, 128255, 68507, 68508, 68480, 68483, 68490, 68491, 68485, 68482, + 68486, 68493, 68495, 68496, 68488, 68484, 68487, 68489, 68481, 68492, + 68497, 68494, 68526, 68522, 68523, 68525, 68521, 68527, 68524, 68505, + 68506, 118473, 11854, 8200, 128156, 128091, 128686, 128204, 128226, + 983165, 983168, 983194, 9624, 9625, 9626, 9627, 9628, 9629, 9630, 9631, + 9622, 9623, 10764, 8279, 10774, 9833, 128894, 8264, 63, 8799, 34, 9915, + 127949, 127950, 129437, 128251, 9762, 128280, 9143, 128740, 128643, 9926, + 127752, 11827, 11783, 11782, 9995, 128400, 128406, 127338, 127339, 127340, 129996, 11787, 9994, 11828, 129306, 128000, 8758, 128007, 128048, 129682, 128015, 129534, 117778, 9852, 9843, 9844, 9845, 9846, 9847, 9848, 9849, 9850, 983113, 128665, 127822, 129511, 174, 127462, 127463, 127464, @@ -11850,526 +12148,526 @@ static const unsigned int dawg_pos_to_codepoint[] = { 9166, 11152, 11153, 128639, 128968, 983152, 92, 10184, 10741, 10743, 11073, 11079, 983153, 10659, 10661, 8246, 12317, 10989, 8976, 11793, 8267, 8245, 128401, 9753, 11262, 8515, 8271, 8765, 8909, 8247, 128402, - 128403, 128405, 11841, 11822, 10672, 128404, 128158, 8251, 129423, - 983154, 127872, 11190, 11188, 11191, 11189, 11186, 11187, 11184, 11185, - 127832, 127833, 129919, 129918, 128495, 8735, 12297, 10642, 11777, 11776, - 9084, 8894, 10652, 10644, 10228, 8692, 12305, 10648, 125, 9132, 9133, - 9131, 12301, 8969, 11781, 12299, 10608, 10715, 8221, 11817, 129929, + 128403, 11841, 11822, 10672, 128405, 128404, 128158, 8251, 129423, + 129023, 983154, 127872, 11190, 11188, 11191, 11189, 11186, 11187, 11184, + 11185, 127832, 127833, 129919, 129918, 128495, 8735, 12297, 10642, 11777, + 11776, 9084, 8894, 10652, 10644, 10228, 8692, 12305, 10648, 125, 9132, + 9133, 9131, 12301, 8969, 11781, 12299, 10608, 10715, 8221, 11817, 129929, 10621, 8971, 118272, 9687, 11241, 9616, 129978, 117925, 118289, 129971, - 118286, 118284, 118432, 118443, 129933, 128381, 130025, 130017, 11805, - 8906, 10198, 129927, 9621, 129980, 41, 9120, 9118, 9119, 11789, 10182, - 8908, 129931, 8217, 11815, 128360, 128361, 128362, 128489, 93, 9126, - 9124, 10638, 10640, 8262, 10636, 11864, 11862, 9125, 11779, 117773, - 129987, 128493, 118433, 118442, 129930, 129928, 11786, 8895, 10702, - 129902, 12309, 8866, 11809, 9145, 117766, 12303, 10628, 12311, 10630, - 12315, 12313, 10713, 1421, 117833, 117907, 117909, 129308, 4053, 4055, - 117874, 117878, 9957, 9002, 117858, 10749, 187, 117775, 128270, 117921, - 117848, 117923, 117913, 117863, 117763, 117919, 117882, 117761, 10153, - 10552, 8295, 8238, 8235, 8207, 10813, 8594, 11080, 11084, 10562, 10613, - 10612, 129974, 8614, 10528, 129217, 11076, 11075, 10567, 10526, 8677, - 8628, 10513, 8699, 129202, 8620, 129034, 10565, 129042, 129026, 8603, - 11022, 11023, 8611, 10517, 10516, 129030, 129178, 129046, 8618, 8696, - 8644, 10522, 129193, 129185, 11146, 11157, 8658, 10499, 8655, 10503, - 10524, 10509, 8674, 129195, 129078, 10601, 10605, 10591, 10583, 8641, - 10600, 10604, 10596, 10587, 10579, 8640, 8652, 129777, 129090, 129094, - 129191, 8702, 8649, 129784, 129189, 128622, 8669, 129082, 129106, 129187, - 11106, 11138, 11132, 983242, 11175, 11173, 129066, 129062, 129058, - 129074, 129070, 11122, 11116, 11142, 129170, 10511, 8667, 10518, 10520, - 10519, 11246, 10497, 10496, 10501, 10512, 8608, 8605, 8680, 8688, 129174, - 129086, 11078, 128141, 128735, 11824, 8790, 8791, 8728, 730, 129680, - 128365, 10539, 10544, 65020, 129350, 983227, 983235, 983225, 983230, - 129704, 128640, 128478, 127906, 128764, 129531, 129315, 65947, 65942, - 65945, 65940, 65943, 8556, 8583, 8582, 8548, 8558, 8577, 8547, 8544, - 8557, 8584, 8559, 8576, 8549, 8581, 8550, 8553, 8578, 8555, 8545, 8546, - 8579, 8554, 8551, 8552, 65938, 65944, 65936, 65939, 65941, 65937, 65946, - 129756, 128019, 127801, 127989, 10087, 10085, 11213, 11215, 8506, 128205, - 128907, 127588, 127586, 127589, 127584, 127585, 127587, 128675, 127840, - 129302, 8381, 127945, 10740, 69245, 69243, 69244, 69246, 69241, 69232, - 69238, 69229, 69237, 69228, 69242, 69233, 69234, 69240, 69231, 69239, - 69230, 69236, 69227, 69235, 69226, 69225, 69220, 69219, 69222, 69221, - 69218, 69217, 69224, 69216, 69223, 5872, 5869, 5803, 5802, 5800, 5833, - 5837, 5860, 5811, 5859, 5858, 5841, 5851, 5824, 5844, 5854, 5826, 5846, - 5856, 5799, 5814, 5880, 5879, 5877, 5876, 5878, 5792, 5813, 5815, 5828, - 5816, 5819, 5818, 5853, 5852, 5825, 5831, 5864, 5857, 5827, 5873, 5812, - 5810, 5850, 5829, 5820, 5848, 5804, 5862, 5806, 5801, 5855, 5845, 5807, - 5808, 5875, 5809, 5874, 5843, 5821, 5849, 5823, 5805, 5836, 5840, 5830, - 5863, 5835, 5834, 5861, 5842, 5822, 5798, 5839, 5797, 5817, 5794, 5847, - 5832, 5796, 5795, 5865, 5793, 5866, 5838, 5867, 5868, 5870, 5871, 127933, - 127939, 11254, 11252, 11253, 11251, 11255, 11256, 8360, 983114, 10700, - 129466, 129527, 9808, 129474, 9747, 129761, 2049, 2053, 2051, 2063, 2055, - 2052, 2058, 2059, 2062, 2068, 2069, 2056, 2065, 2048, 2050, 2067, 2054, - 2060, 2066, 2061, 2057, 2064, 2073, 2070, 2071, 2075, 2093, 2072, 2074, - 2084, 2088, 2097, 2110, 2098, 2100, 2108, 2099, 2096, 2101, 2109, 2106, - 2104, 2107, 2103, 2105, 2082, 2079, 2076, 2089, 2086, 2091, 2081, 2078, - 2085, 2092, 2083, 2080, 2077, 2090, 2087, 2102, 128630, 128631, 128632, - 128634, 129386, 128752, 128225, 9796, 43138, 43139, 43150, 43153, 43167, - 43166, 43172, 43171, 43165, 43164, 43170, 43169, 43144, 43145, 43146, - 43147, 43182, 43142, 43143, 43151, 43152, 43140, 43141, 43187, 43181, - 43158, 43168, 43163, 43173, 43183, 43184, 43185, 43177, 43176, 43160, - 43159, 43157, 43156, 43162, 43161, 43155, 43154, 43175, 43174, 43148, - 43149, 43186, 43178, 43180, 43179, 43205, 43136, 43204, 43137, 43215, - 43214, 43221, 43220, 43223, 43222, 43219, 43218, 43216, 43225, 43217, - 43224, 43188, 43189, 43200, 43203, 43192, 43193, 43194, 43195, 43196, - 43197, 43201, 43202, 43190, 43191, 43198, 43199, 129429, 8385, 9973, - 127927, 127862, 129403, 9878, 129507, 127979, 127890, 129410, 9807, - 128756, 129691, 128437, 8492, 8496, 8497, 8459, 8464, 8466, 8499, 8472, - 8475, 128624, 8495, 8458, 8467, 8500, 8456, 128220, 983186, 129453, - 128186, 167, 8980, 129352, 127793, 128584, 8979, 130037, 130036, 130039, - 130038, 130035, 130034, 130032, 130041, 130033, 130040, 10802, 9914, 59, - 117793, 117795, 117799, 117807, 117803, 117797, 117805, 117801, 117794, - 117798, 117806, 117802, 117796, 117804, 117800, 118353, 118355, 118359, - 118367, 118383, 118415, 118399, 118375, 118407, 118391, 118363, 118379, - 118411, 118395, 118371, 118403, 118387, 118357, 118365, 118381, 118413, - 118397, 118373, 118405, 118389, 118361, 118377, 118409, 118393, 118369, - 118401, 118385, 118354, 118358, 118366, 118382, 118414, 118398, 118374, - 118406, 118390, 118362, 118378, 118410, 118394, 118370, 118402, 118386, - 118356, 118364, 118380, 118412, 118396, 118372, 118404, 118388, 118360, - 118376, 118408, 118392, 118368, 118400, 118384, 11259, 8480, 129324, - 9916, 65093, 983169, 8726, 129697, 9913, 11250, 129331, 10061, 10032, - 10014, 129368, 70086, 70085, 70101, 70100, 70103, 70102, 70099, 70098, - 70096, 70105, 70097, 70104, 70092, 70106, 70108, 70019, 70020, 70030, - 70032, 70046, 70045, 70051, 70050, 70044, 70043, 70049, 70048, 70025, - 70026, 70027, 70028, 70062, 70023, 70024, 70021, 70022, 70061, 70060, - 70037, 70047, 70042, 70052, 70063, 70064, 70065, 70056, 70055, 70039, - 70038, 70036, 70035, 70041, 70040, 70034, 70033, 70054, 70053, 70066, - 70057, 70059, 70058, 70029, 70031, 70089, 70110, 70111, 70088, 70095, - 70107, 70016, 70090, 70081, 70017, 70082, 70083, 70080, 70018, 70093, - 70091, 72550, 72551, 70078, 72545, 72544, 70094, 70070, 70071, 72547, - 72546, 72548, 72549, 70067, 70077, 70079, 70072, 70073, 70074, 70075, - 70068, 70069, 70076, 70087, 70109, 70084, 129416, 127847, 66684, 66680, - 66682, 66665, 66673, 66679, 66664, 66669, 66647, 66685, 66672, 66683, - 66663, 66659, 66649, 66686, 66674, 66662, 66660, 66656, 66661, 66677, - 66678, 66668, 66676, 66666, 66681, 66640, 66670, 66646, 66645, 66644, - 66654, 66641, 66667, 66658, 66648, 66687, 66657, 66651, 66655, 66643, - 66652, 66650, 66642, 66653, 66671, 66675, 9752, 129768, 128737, 983075, - 983078, 9961, 128674, 127776, 128722, 128717, 11087, 11103, 11086, - 129237, 10974, 10564, 129235, 10976, 10985, 10984, 10975, 10983, 113825, - 113824, 113826, 113827, 127856, 129651, 9085, 129327, 129679, 128703, - 128017, 129424, 129335, 10722, 983198, 983080, 71113, 71040, 71131, - 71041, 71051, 71053, 71128, 71070, 71129, 71130, 71065, 71064, 71069, - 71067, 71066, 71072, 71071, 71046, 71047, 71048, 71049, 71082, 71044, - 71045, 71042, 71043, 71058, 71068, 71063, 71073, 71083, 71084, 71085, - 71077, 71076, 71060, 71059, 71057, 71056, 71062, 71061, 71055, 71054, - 71075, 71074, 71086, 71081, 71078, 71080, 71079, 71050, 71052, 71110, - 71111, 71112, 71119, 71120, 71127, 71126, 71125, 71123, 71124, 71117, - 71118, 71116, 71121, 71115, 71114, 71122, 71109, 71108, 71105, 71100, - 71104, 71101, 71103, 71102, 71132, 71133, 71087, 71097, 71099, 71092, - 71093, 71090, 71091, 71088, 71089, 71096, 71098, 71107, 71106, 67923, - 67924, 67925, 67926, 67927, 67928, 67929, 67904, 67905, 67906, 67907, - 67908, 67909, 67910, 67911, 67912, 67913, 67914, 67915, 67916, 67917, - 67918, 67919, 67920, 67921, 67922, 128411, 128410, 128417, 128416, - 128409, 128408, 128415, 128414, 121399, 121397, 121400, 121398, 121402, - 121401, 121104, 121103, 121102, 121388, 121387, 121386, 121482, 121479, - 121358, 121359, 121357, 121360, 121341, 121335, 121339, 121340, 121336, - 121334, 121333, 121338, 121337, 121342, 121368, 121367, 121373, 121356, - 121355, 121354, 121380, 121382, 121381, 121384, 121383, 121385, 121377, - 121379, 121378, 121375, 121376, 121374, 121371, 121369, 121366, 121370, - 121372, 121364, 121365, 121452, 121392, 121352, 121353, 121351, 121499, - 121500, 121501, 121502, 121503, 121470, 121117, 121115, 121119, 121118, - 121116, 121456, 121363, 121362, 121361, 121480, 121455, 120965, 120837, - 121000, 120969, 121027, 121026, 121076, 121074, 121075, 120995, 120991, - 120990, 120982, 121005, 121011, 121044, 121042, 121043, 120950, 120833, - 120847, 121002, 120859, 120863, 120997, 120967, 120845, 121019, 120839, - 120993, 120980, 121038, 121045, 121031, 121009, 120934, 121046, 121047, - 120905, 120936, 120937, 120935, 121065, 120941, 120834, 121068, 121069, - 121024, 120915, 120916, 121040, 120940, 120944, 120946, 120942, 120945, - 120947, 120943, 120949, 121020, 121039, 120948, 121091, 120832, 120838, - 120861, 120843, 120852, 120870, 120844, 120846, 120848, 120865, 120853, - 120856, 120885, 120877, 120878, 120879, 120884, 120857, 120882, 120854, - 120855, 120858, 120883, 121001, 120871, 120850, 120867, 120966, 120972, - 120971, 120849, 120862, 120895, 120894, 120872, 120873, 120893, 120875, - 120874, 120866, 120864, 120996, 120842, 120891, 120890, 121067, 120892, - 120887, 121064, 121066, 121063, 121060, 121061, 121062, 120899, 120881, - 121052, 121059, 121057, 121054, 121055, 121056, 121058, 120851, 120869, - 120868, 120841, 121018, 120974, 120977, 120976, 120975, 120985, 120986, - 120983, 120992, 120988, 120984, 120978, 121032, 121037, 120897, 120896, - 120898, 120889, 120888, 120886, 120880, 121035, 121030, 121033, 121028, - 121036, 120860, 121003, 121012, 121014, 121013, 121007, 121016, 121008, - 121015, 121006, 121077, 121083, 120876, 121084, 121085, 121078, 121090, - 121087, 121079, 121080, 121081, 120840, 121086, 121088, 121089, 120979, - 121082, 121092, 120906, 120922, 120908, 120919, 120920, 120921, 120914, - 120910, 120912, 120900, 120903, 120904, 120902, 120901, 120924, 120909, - 120911, 120913, 120926, 120930, 120931, 120932, 120929, 120933, 120928, - 120925, 120927, 120923, 120957, 120917, 120907, 120836, 121051, 120968, - 120973, 120998, 121072, 121053, 121073, 121070, 121071, 121025, 120970, - 120994, 120989, 120987, 121029, 121041, 120955, 120961, 120956, 120959, - 120999, 121004, 120964, 120960, 120963, 120962, 120958, 120939, 120938, - 121023, 121021, 121022, 121050, 121048, 121049, 121034, 121017, 120951, - 120918, 120981, 120953, 121010, 120954, 120952, 120835, 121451, 121343, - 121349, 121347, 121348, 121346, 121345, 121350, 121344, 121462, 121463, - 121464, 121465, 121466, 121467, 121468, 121469, 121428, 121429, 121427, - 121476, 121473, 121477, 121475, 121474, 121478, 121472, 121471, 121404, - 121405, 121403, 121430, 121409, 121411, 121410, 121406, 121408, 121407, - 121421, 121423, 121422, 121415, 121416, 121417, 121418, 121419, 121420, - 121414, 121413, 121412, 121424, 121425, 121426, 121432, 121431, 121183, - 121184, 121182, 121181, 121187, 121188, 121186, 121185, 121175, 121176, - 121174, 121173, 121179, 121180, 121178, 121177, 121324, 121321, 121323, - 121320, 121322, 121319, 121210, 121209, 121208, 121203, 121207, 121305, - 121272, 121271, 121287, 121286, 121303, 121304, 121302, 121301, 121206, - 121205, 121204, 121198, 121332, 121331, 121129, 121276, 121274, 121275, - 121273, 121288, 121289, 121291, 121290, 121306, 121280, 121278, 121279, - 121277, 121295, 121293, 121294, 121292, 121307, 121314, 121191, 121192, - 121190, 121189, 121193, 121202, 121201, 121200, 121199, 121282, 121281, - 121297, 121296, 121308, 121309, 121310, 121328, 121327, 121194, 121196, - 121197, 121195, 121216, 121215, 121214, 121213, 121212, 121211, 121449, - 121125, 121126, 121121, 121122, 121123, 121124, 121127, 121318, 121316, - 121317, 121315, 121156, 121155, 121154, 121146, 121145, 121144, 121150, - 121149, 121148, 121147, 121230, 121231, 121229, 121228, 121254, 121261, - 121247, 121233, 121232, 121226, 121227, 121225, 121224, 121249, 121248, - 121153, 121152, 121151, 121139, 121135, 121137, 121138, 121136, 121330, - 121329, 121128, 121236, 121255, 121262, 121235, 121234, 121237, 121240, - 121239, 121256, 121263, 121238, 121162, 121161, 121160, 121132, 121133, - 121131, 121130, 121134, 121253, 121142, 121143, 121141, 121140, 121243, - 121242, 121241, 121246, 121245, 121244, 121270, 121269, 121268, 121257, - 121264, 121326, 121325, 121159, 121158, 121157, 121448, 121394, 121393, - 121395, 121396, 121450, 121513, 121514, 121515, 121516, 121517, 121518, - 121519, 121505, 121506, 121507, 121508, 121509, 121510, 121511, 121512, - 121312, 121284, 121299, 121311, 121283, 121298, 121313, 121285, 121300, - 121260, 121267, 121252, 121251, 121259, 121266, 121250, 121258, 121265, - 121107, 121106, 121105, 121454, 121453, 121457, 121120, 121112, 121110, - 121114, 121113, 121111, 121108, 121109, 121101, 121100, 121099, 121481, - 121441, 121445, 121446, 121443, 121444, 121442, 121447, 121390, 121389, - 121391, 121440, 121439, 121437, 121435, 121436, 121434, 121433, 121438, - 121459, 121458, 121460, 121095, 121094, 121093, 121219, 121218, 121217, - 121222, 121221, 121220, 121223, 121172, 121171, 121170, 121168, 121167, - 121166, 121165, 121164, 121163, 121169, 121098, 121097, 121096, 121461, - 121483, 129304, 10912, 10911, 10910, 10909, 10860, 983185, 983183, 8219, - 8249, 8218, 8250, 983158, 983155, 983156, 983159, 70117, 70116, 70119, - 70118, 70115, 70114, 70121, 70113, 70120, 70131, 70132, 70129, 70126, - 70125, 70130, 70128, 70127, 70124, 70123, 70122, 983953, 983954, 983952, - 3464, 3463, 3495, 3501, 3497, 3503, 3510, 3488, 3484, 3490, 3482, 3508, - 3513, 3462, 3475, 3478, 3461, 3474, 3473, 3472, 3471, 3470, 3469, 3466, - 3465, 3468, 3467, 3496, 3502, 3498, 3504, 3511, 3489, 3485, 3491, 3483, - 3509, 3512, 3525, 3499, 3522, 3517, 3505, 3523, 3477, 3476, 3500, 3507, - 3487, 3494, 3526, 3524, 3515, 3520, 3514, 3492, 3493, 3521, 3486, 3563, - 3562, 3565, 3564, 3561, 3560, 3558, 3567, 3559, 3566, 3530, 3458, 3457, - 3459, 3570, 3571, 3546, 3537, 3539, 3542, 3544, 3551, 3536, 3538, 3540, - 3545, 3548, 3549, 3550, 3547, 3535, 3572, 8767, 10046, 128973, 10038, - 128303, 8198, 10042, 128510, 127935, 9975, 128128, 9760, 129448, 128761, - 10902, 10904, 10901, 10903, 11098, 11100, 42611, 128716, 128164, 128564, - 128554, 128373, 128759, 127829, 128578, 128577, 10840, 10839, 9011, - 127920, 129445, 65120, 128745, 65121, 128313, 128312, 8717, 8956, 8958, - 65131, 65104, 65109, 65129, 8714, 8948, 8951, 65126, 65111, 65112, 65105, - 65115, 65113, 65117, 65124, 65116, 65114, 65118, 8570, 8567, 8564, 8574, - 8572, 8563, 8560, 8573, 8575, 8571, 8561, 8562, 8569, 8566, 8565, 8568, - 65128, 65108, 68411, 732, 118266, 10849, 65125, 65123, 65130, 65122, - 65119, 65106, 65110, 10922, 10924, 10803, 128571, 128570, 128525, 128520, - 128519, 128515, 128517, 128516, 128518, 128522, 129325, 129392, 128526, - 129394, 8995, 128527, 128684, 128013, 118010, 128012, 129319, 127956, - 9731, 9924, 127938, 10052, 983077, 9917, 129510, 173, 127846, 128428, - 9108, 129358, 69453, 69452, 69454, 69456, 69447, 69449, 69446, 69448, - 69455, 69451, 69450, 69445, 69424, 69437, 69426, 69433, 69444, 69440, - 69429, 69436, 69439, 69441, 69431, 69427, 69430, 69432, 69425, 69443, - 69435, 69442, 69428, 69438, 69434, 69457, 69460, 69459, 69458, 69463, - 69465, 69461, 69462, 69464, 128618, 128619, 47, 10742, 128284, 69859, - 69863, 69864, 69846, 69847, 69857, 69849, 69842, 69843, 69844, 69845, - 69854, 69856, 69855, 69848, 69851, 69853, 69840, 69841, 69850, 69852, - 69858, 69860, 69862, 69861, 69877, 69876, 69879, 69878, 69875, 69874, - 69872, 69881, 69873, 69880, 8600, 10537, 10541, 8690, 10533, 129210, - 128603, 128595, 128611, 11112, 11128, 11018, 8664, 129110, 11010, 8601, - 10538, 10534, 129211, 128601, 128593, 128609, 11113, 11129, 11019, 8665, - 129111, 11011, 8471, 72328, 72329, 72327, 72326, 72340, 72339, 72334, - 72332, 72341, 72335, 72333, 72330, 72331, 72338, 72336, 72337, 72352, - 72351, 72350, 72297, 72296, 72302, 72311, 72301, 72323, 72285, 72284, - 72288, 72298, 72293, 72303, 72319, 72320, 72321, 72310, 72309, 72295, - 72294, 72300, 72299, 72307, 72306, 72290, 72289, 72287, 72286, 72292, - 72291, 72305, 72304, 72312, 72313, 72314, 72322, 72317, 72308, 72316, - 72318, 72315, 72272, 72349, 72348, 72347, 72346, 72324, 72343, 72325, - 72342, 72345, 72353, 72354, 72282, 72281, 72279, 72280, 72277, 72278, - 72275, 72274, 72276, 72273, 72283, 72344, 8384, 983043, 983182, 983118, - 983177, 127837, 128150, 10055, 10024, 117824, 117825, 32, 128586, 128264, - 128263, 128265, 128266, 128483, 128676, 128172, 8375, 117830, 117831, - 8738, 10656, 10657, 128375, 128376, 128467, 128466, 128026, 128166, - 129759, 129525, 129348, 128051, 127941, 129533, 13279, 117900, 13056, - 13058, 13057, 13059, 13250, 13171, 13278, 13101, 13172, 13108, 13105, - 13118, 13116, 13251, 13192, 8851, 13255, 13183, 13213, 13220, 13216, - 13254, 8852, 13252, 13253, 13170, 13092, 13175, 13177, 13176, 13093, - 13094, 13256, 127376, 13207, 13064, 13179, 13181, 13182, 13055, 13180, - 13005, 13063, 13006, 117899, 117898, 117897, 9974, 9165, 13209, 13070, - 13071, 13311, 13075, 13073, 13072, 13080, 13081, 13203, 13228, 13191, - 13257, 13258, 13098, 13110, 13113, 13121, 13122, 13119, 13107, 13106, - 13109, 13259, 13169, 127488, 13004, 13200, 13260, 13060, 13061, 8847, - 8932, 8849, 13178, 13188, 13068, 13069, 13067, 13076, 13078, 13079, - 13077, 13214, 13262, 13222, 13218, 13086, 13085, 13082, 13083, 13084, - 13074, 13201, 13193, 13248, 13226, 13189, 13199, 13261, 13208, 13263, - 13240, 13246, 8977, 13266, 10957, 13264, 13265, 13267, 13223, 13224, - 13249, 13221, 13217, 13187, 13123, 13124, 13127, 13126, 13125, 13190, - 13268, 13131, 13132, 13133, 13128, 13129, 13130, 13269, 13212, 13219, - 13215, 13186, 13196, 13197, 13205, 13211, 13234, 13238, 13244, 13239, - 13241, 13245, 13247, 13202, 13270, 13227, 13198, 13206, 13235, 13185, - 13096, 13097, 13195, 13210, 13233, 13237, 13243, 13065, 8848, 8933, 8850, - 13066, 13173, 13225, 13099, 13100, 13184, 13115, 13112, 13114, 13111, - 13103, 13104, 13102, 13117, 13120, 11216, 13273, 13174, 13194, 13271, - 13272, 13274, 13232, 13236, 13242, 13229, 13230, 13231, 13142, 13141, - 10958, 13137, 13138, 13140, 13139, 8730, 13087, 13088, 13090, 13091, - 117887, 117886, 117884, 117885, 13089, 13275, 13276, 128918, 13204, - 13095, 13143, 11027, 9641, 9638, 9636, 11029, 9706, 9703, 11026, 9705, - 9639, 11028, 9640, 9637, 9704, 10720, 13277, 13135, 13134, 13136, 13062, - 127529, 127530, 127512, 127508, 127533, 127545, 127520, 127516, 127534, - 127506, 127540, 127525, 127546, 127532, 127511, 127509, 127524, 127505, - 127517, 127518, 127527, 127537, 127504, 127528, 127535, 127519, 127515, - 127513, 127543, 127542, 127526, 127541, 127544, 127522, 127538, 127514, - 127521, 127539, 127510, 127536, 127523, 127547, 127531, 127378, 127377, - 8865, 10693, 11820, 127390, 127392, 127379, 10692, 127400, 127399, - 127398, 127306, 127489, 127507, 127490, 9919, 127397, 127280, 127281, - 127282, 127283, 127284, 127285, 127286, 127287, 127288, 127289, 127290, - 127291, 127292, 127293, 127294, 127295, 127296, 127297, 127298, 127299, - 127300, 127301, 127302, 127303, 127304, 127305, 10190, 10191, 127401, - 8863, 127307, 127381, 127382, 127396, 127383, 127310, 8862, 127388, - 127393, 127402, 127395, 9949, 10695, 10696, 127384, 127308, 127309, - 127387, 127394, 127389, 8864, 127391, 127385, 127403, 127404, 127386, - 10694, 127311, 127380, 10151, 129425, 983157, 983160, 983134, 983190, - 9877, 9882, 128387, 8795, 10017, 8902, 9770, 11242, 11243, 983175, - 983133, 983181, 983176, 983042, 983044, 128509, 128649, 129485, 127967, - 128642, 127836, 11836, 129658, 129989, 129990, 129993, 129991, 129992, - 128480, 9201, 128207, 9188, 127827, 118463, 10025, 983189, 117891, - 117888, 117890, 117889, 8803, 127897, 129369, 128723, 983170, 983045, - 983103, 8333, 8332, 8328, 8330, 8334, 8331, 8325, 8324, 8327, 8326, 8323, - 8322, 8320, 8329, 8321, 10963, 10965, 10617, 8834, 10953, 10949, 10951, - 10955, 8842, 8838, 10947, 10945, 10943, 10941, 983102, 8827, 10938, - 10934, 10928, 10930, 10936, 10932, 8937, 8831, 8829, 8881, 9139, 10763, - 9138, 9737, 127774, 9925, 7098, 7073, 7074, 7075, 7084, 7085, 7043, - 983220, 7046, 7102, 7103, 7062, 7100, 7068, 7099, 7067, 7087, 7070, 7048, - 7049, 7053, 7057, 7060, 7101, 7064, 7086, 7050, 7054, 7059, 7052, 7072, - 7055, 7065, 7061, 7051, 7058, 7063, 7069, 7071, 7066, 7056, 7044, 7047, - 7045, 7367, 7366, 7365, 7364, 7363, 7361, 7362, 7360, 7082, 7041, 7042, - 7040, 7083, 7080, 7081, 7079, 7077, 7076, 7078, 7093, 7092, 7095, 7094, - 7091, 7090, 7088, 7097, 7089, 7096, 127749, 127748, 72648, 72662, 72661, - 72669, 72652, 72640, 72663, 72651, 72655, 72672, 72646, 72667, 72666, - 72653, 72657, 72645, 72665, 72649, 72644, 72658, 72668, 72670, 72664, - 72671, 72641, 72659, 72656, 72650, 72643, 72660, 72654, 72642, 72647, - 72673, 72693, 72692, 72695, 72694, 72691, 72690, 72688, 72697, 72689, - 72696, 127751, 127803, 8316, 8312, 8305, 8319, 8317, 8314, 8318, 8315, - 8309, 8308, 8311, 8310, 179, 178, 8304, 8313, 185, 10966, 10964, 10619, - 10968, 10967, 8835, 10954, 10950, 10952, 10956, 8843, 8839, 10948, 10946, - 10944, 10942, 10185, 129464, 129465, 8751, 127940, 128671, 127843, - 128629, 129442, 127946, 8275, 43027, 43026, 43031, 43030, 43040, 43038, - 43025, 43024, 43029, 43028, 43036, 43035, 43021, 43020, 43018, 43017, - 43023, 43022, 43016, 43015, 43034, 43033, 43042, 43039, 43037, 43032, - 43041, 43008, 43012, 43009, 43013, 43011, 43048, 43049, 43050, 43051, - 43052, 43019, 43014, 43010, 43047, 43043, 43046, 43044, 43045, 9223, - 9224, 9229, 9240, 9232, 9249, 9256, 9255, 9253, 9257, 9236, 9235, 9234, - 9233, 9241, 9220, 9239, 9219, 9221, 9243, 9244, 9228, 9225, 9227, 9226, - 128325, 9237, 9252, 9216, 9222, 9246, 9245, 9247, 8527, 9230, 9231, 9217, - 9218, 9242, 9254, 9238, 9248, 11159, 9007, 983094, 983093, 128333, 1807, - 1866, 1802, 1798, 1799, 1849, 1848, 1792, 1854, 1853, 1805, 1804, 1803, - 1852, 1851, 1850, 1797, 1814, 1813, 1815, 1818, 1824, 2153, 2152, 2149, - 2148, 2144, 2146, 2150, 2147, 2154, 2145, 2151, 1825, 1830, 1837, 1839, - 1838, 1831, 1834, 1827, 1869, 1870, 1871, 1809, 1835, 1832, 1828, 1808, - 1823, 1833, 1819, 1820, 1836, 1811, 1812, 1821, 1822, 1810, 1817, 1826, - 1816, 1829, 1864, 1863, 1842, 1841, 1840, 1845, 1844, 1843, 1847, 1846, - 1855, 1858, 1796, 983204, 1801, 1794, 1795, 1800, 1793, 1862, 1861, 1860, - 1859, 1865, 1856, 1857, 128137, 983184, 128085, 129430, 983061, 127955, - 917543, 917542, 917546, 917598, 917568, 917548, 917562, 917540, 917557, - 917556, 917559, 917558, 917555, 917554, 917552, 917561, 917553, 917560, - 917565, 917537, 917600, 917566, 917549, 917569, 917570, 917571, 917572, - 917573, 917574, 917575, 917576, 917577, 917578, 917579, 917580, 917581, - 917582, 917583, 917584, 917585, 917586, 917587, 917588, 917589, 917590, - 917591, 917592, 917593, 917594, 917601, 917602, 917603, 917604, 917605, - 917606, 917607, 917608, 917609, 917610, 917611, 917612, 917613, 917614, - 917615, 917616, 917617, 917618, 917619, 917620, 917621, 917622, 917623, - 917624, 917625, 917626, 917564, 917627, 917544, 917595, 917599, 917541, - 917547, 917538, 917567, 917629, 917545, 917597, 917596, 917563, 917551, - 917536, 917539, 917630, 917550, 917628, 5888, 5919, 5893, 5896, 5898, - 5895, 5892, 5905, 5891, 5902, 5899, 5897, 5901, 5904, 5894, 5903, 5900, - 5889, 5890, 5909, 5908, 5906, 5907, 5989, 5992, 5994, 5991, 5988, 5987, - 5998, 5995, 5993, 6000, 5990, 5999, 5996, 5984, 5985, 5986, 6002, 6003, - 6499, 6508, 6509, 6507, 6501, 6502, 6512, 6513, 6514, 6515, 6516, 6497, - 6483, 6487, 6486, 6482, 6498, 6505, 6504, 6496, 6480, 6490, 6489, 6503, - 6506, 6492, 6494, 6488, 6491, 6495, 6484, 6493, 6481, 6485, 6500, 6745, - 6746, 6743, 6747, 6742, 6741, 6748, 6749, 6750, 6783, 6789, 6788, 6791, - 6790, 6787, 6786, 6784, 6793, 6785, 6792, 6805, 6804, 6807, 6806, 6803, - 6802, 6800, 6809, 6801, 6808, 6740, 6689, 6690, 6688, 6702, 6726, 6727, - 6728, 6696, 6695, 6713, 6712, 6707, 6706, 6714, 6729, 6720, 6693, 6692, - 6691, 6704, 6699, 6697, 6717, 6715, 6709, 6708, 6716, 6732, 6698, 6719, - 6723, 6739, 6724, 6730, 6721, 6705, 6701, 6722, 6735, 6736, 6733, 6734, - 6694, 6700, 6710, 6738, 6737, 6711, 6703, 6718, 6725, 6731, 6828, 6820, - 6775, 6776, 6777, 6780, 6824, 6825, 6819, 6772, 6744, 6823, 6779, 6778, - 6822, 6826, 6827, 6818, 6752, 6816, 6817, 6821, 6773, 6774, 6829, 6753, - 6755, 6767, 6769, 6754, 6763, 6764, 6771, 6768, 6765, 6756, 6770, 6761, - 6762, 6760, 6759, 6757, 6758, 6766, 43653, 43651, 43649, 43661, 43659, - 43679, 43677, 43671, 43669, 43657, 43665, 43673, 43675, 43667, 43681, - 43655, 43693, 43689, 43683, 43687, 43663, 43691, 43685, 43695, 43652, - 43650, 43648, 43660, 43658, 43678, 43676, 43670, 43668, 43656, 43664, - 43672, 43674, 43666, 43680, 43654, 43692, 43688, 43682, 43686, 43662, - 43690, 43684, 43694, 43696, 43703, 43743, 43739, 43740, 43742, 43741, - 43712, 43713, 43714, 43711, 43707, 43697, 43710, 43709, 43708, 43700, - 43699, 43705, 43706, 43698, 43704, 43701, 43702, 124653, 124640, 124645, - 124658, 124657, 124656, 124660, 124659, 124632, 124610, 124637, 124608, - 124617, 124628, 124634, 124625, 124620, 124615, 124611, 124638, 124609, - 124618, 124629, 124635, 124626, 124621, 124616, 124613, 124623, 124644, - 124642, 124650, 124651, 124627, 124622, 124641, 124649, 124647, 124652, - 124624, 124614, 124619, 124612, 124630, 124636, 124633, 124631, 124648, - 124655, 124646, 124654, 124643, 124661, 124670, 124671, 71353, 71296, - 71352, 71297, 71303, 71305, 71319, 71318, 71324, 71323, 71338, 71332, - 71317, 71316, 71322, 71321, 71300, 71301, 71298, 71299, 71310, 71320, - 71315, 71325, 71329, 71328, 71312, 71311, 71309, 71308, 71314, 71313, - 71307, 71306, 71327, 71326, 71335, 71336, 71337, 71333, 71330, 71334, - 71331, 71302, 71304, 71351, 71339, 71350, 71340, 71341, 71347, 71349, - 71344, 71345, 71342, 71343, 71346, 71348, 71365, 71364, 71367, 71366, - 71363, 71362, 71360, 71369, 71361, 71368, 129377, 119672, 119671, 3064, - 3031, 73707, 983662, 983685, 983674, 983677, 983676, 983669, 983667, - 983679, 983663, 983665, 983668, 983666, 983683, 983681, 983682, 983673, - 983678, 983664, 983684, 983680, 983671, 983670, 983675, 983672, 73706, - 3063, 73701, 3062, 3059, 3051, 3050, 3053, 3052, 3049, 3048, 3046, 3055, - 3047, 3054, 73700, 73666, 73676, 73668, 73679, 73681, 73682, 73665, - 73673, 73674, 73667, 73664, 73669, 73672, 73675, 73680, 73670, 73678, - 73671, 73677, 73683, 73684, 73710, 2985, 2979, 2969, 2974, 2984, 2975, - 2980, 2949, 2950, 2960, 2964, 2996, 2995, 2994, 2993, 2992, 2953, 2954, - 2962, 2963, 2951, 2952, 2998, 2999, 3000, 2958, 2959, 2970, 3001, 2972, - 2965, 2990, 2986, 2997, 2991, 73702, 3057, 3058, 3056, 3066, 73727, 3065, - 73703, 73687, 2946, 73686, 73698, 73690, 73693, 73692, 73712, 73689, - 73688, 73691, 73697, 73694, 73695, 73696, 73713, 73699, 3021, 2947, - 73685, 73708, 73711, 983939, 983940, 983947, 983950, 983943, 983944, - 983948, 983949, 983941, 983942, 983945, 983946, 983686, 983693, 983696, - 983689, 983690, 983694, 983695, 983687, 983688, 983691, 983692, 983840, - 983847, 983850, 983843, 983844, 983848, 983849, 983841, 983842, 983845, - 983846, 983851, 983858, 983861, 983854, 983855, 983859, 983860, 983852, - 983853, 983856, 983857, 983818, 983825, 983828, 983821, 983822, 983826, - 983827, 983819, 983820, 983823, 983824, 983873, 983880, 983883, 983876, - 983877, 983881, 983882, 983874, 983875, 983878, 983879, 983741, 983748, - 983751, 983744, 983745, 983749, 983750, 983742, 983743, 983746, 983747, - 983697, 983704, 983707, 983700, 983701, 983705, 983706, 983698, 983699, - 983702, 983703, 983719, 983726, 983729, 983722, 983723, 983727, 983728, - 983720, 983721, 983724, 983725, 983763, 983770, 983773, 983766, 983767, - 983771, 983772, 983764, 983765, 983768, 983769, 983862, 983869, 983872, - 983865, 983866, 983870, 983871, 983863, 983864, 983867, 983868, 983807, - 983814, 983817, 983810, 983811, 983815, 983816, 983808, 983809, 983812, - 983813, 983895, 983902, 983905, 983898, 983899, 983903, 983904, 983951, - 983896, 983897, 983900, 983901, 983906, 983913, 983916, 983909, 983910, - 983914, 983915, 983907, 983908, 983911, 983912, 983917, 983924, 983927, - 983920, 983921, 983925, 983926, 983918, 983919, 983922, 983923, 983730, - 983737, 983740, 983733, 983734, 983738, 983739, 983731, 983732, 983735, - 983736, 983752, 983759, 983762, 983755, 983756, 983760, 983761, 983753, - 983754, 983757, 983758, 983708, 983715, 983718, 983711, 983712, 983716, - 983717, 983709, 983710, 983713, 983714, 983928, 983935, 983938, 983931, - 983932, 983936, 983937, 983929, 983930, 983933, 983934, 983884, 983891, - 983894, 983887, 983888, 983892, 983893, 983885, 983886, 983889, 983890, - 983785, 983792, 983795, 983788, 983789, 983793, 983794, 983786, 983787, - 983790, 983791, 983774, 983781, 983784, 983777, 983778, 983782, 983783, - 983775, 983776, 983779, 983780, 983829, 983836, 983839, 983832, 983833, - 983837, 983838, 983830, 983831, 983834, 983835, 983796, 983803, 983806, - 983799, 983800, 983804, 983805, 983797, 983798, 983801, 983802, 73709, - 73704, 73705, 3006, 3016, 3020, 3009, 3010, 3018, 3019, 3007, 3008, 3014, - 3015, 3061, 3060, 3024, 129748, 127883, 127818, 92809, 92810, 92811, - 92808, 92789, 92790, 92791, 92788, 92816, 92859, 92856, 92847, 92845, - 92817, 92846, 92843, 92829, 92830, 92831, 92828, 92835, 92851, 92840, - 92844, 92818, 92819, 92852, 92836, 92825, 92826, 92827, 92824, 92813, - 92814, 92815, 92812, 92820, 92822, 92823, 92821, 92805, 92806, 92807, - 92804, 92797, 92798, 92799, 92796, 92801, 92802, 92803, 92800, 92785, - 92786, 92787, 92784, 92793, 92794, 92795, 92792, 92857, 92854, 92848, - 92861, 92853, 92860, 92849, 92855, 92834, 92833, 92832, 92841, 92839, - 92842, 92850, 92838, 92858, 92837, 92862, 92869, 92868, 92871, 92870, - 92867, 92866, 92864, 92873, 92865, 92872, 100352, 100353, 100354, 100355, - 100356, 100357, 100358, 100359, 100360, 100361, 100362, 100363, 100364, - 100365, 100366, 100367, 100368, 100369, 100370, 100371, 100372, 100373, - 100374, 100375, 100376, 100377, 100378, 100379, 100380, 100381, 100382, - 100383, 100384, 100385, 100386, 100387, 100388, 100389, 100390, 100391, - 100392, 100393, 100394, 100395, 100396, 100397, 100398, 100399, 100400, - 100401, 100402, 100403, 100404, 100405, 100406, 100407, 100408, 100409, - 100410, 100411, 100412, 100413, 100414, 100415, 100416, 100417, 100418, - 100419, 100420, 100421, 100422, 100423, 100424, 100425, 100426, 100427, - 100428, 100429, 100430, 100431, 100432, 100433, 100434, 100435, 100436, - 100437, 100438, 100439, 100440, 100441, 100442, 100443, 100444, 100445, - 100446, 100447, 100448, 100449, 100450, 100451, 100452, 100453, 100454, - 100455, 100456, 100457, 100458, 100459, 100460, 100461, 100462, 100463, - 100464, 100465, 100466, 100467, 100468, 100469, 100470, 100471, 100472, - 100473, 100474, 100475, 100476, 100477, 100478, 100479, 100480, 100481, - 100482, 100483, 100484, 100485, 100486, 100487, 100488, 100489, 100490, - 100491, 100492, 100493, 100494, 100495, 100496, 100497, 100498, 100499, - 100500, 100501, 100502, 100503, 100504, 100505, 100506, 100507, 100508, - 100509, 100510, 100511, 100512, 100513, 100514, 100515, 100516, 100517, - 100518, 100519, 100520, 100521, 100522, 100523, 100524, 100525, 100526, - 100527, 100528, 100529, 100530, 100531, 100532, 100533, 100534, 100535, - 100536, 100537, 100538, 100539, 100540, 100541, 100542, 100543, 100544, - 100545, 100546, 100547, 100548, 100549, 100550, 100551, 100552, 100553, - 100554, 100555, 100556, 100557, 100558, 100559, 100560, 100561, 100562, - 100563, 100564, 100565, 100566, 100567, 100568, 100569, 100570, 100571, - 100572, 100573, 100574, 100575, 100576, 100577, 100578, 100579, 100580, - 100581, 100582, 100583, 100584, 100585, 100586, 100587, 100588, 100589, - 100590, 100591, 100592, 100593, 100594, 100595, 100596, 100597, 100598, - 100599, 100600, 100601, 100602, 100603, 100604, 100605, 100606, 100607, - 100608, 100609, 100610, 100611, 100612, 100613, 100614, 100615, 100616, - 100617, 100618, 100619, 100620, 100621, 100622, 100623, 100624, 100625, - 100626, 100627, 100628, 100629, 100630, 100631, 100632, 100633, 100634, - 100635, 100636, 100637, 100638, 100639, 100640, 100641, 100642, 100643, - 100644, 100645, 100646, 100647, 100648, 100649, 100650, 100651, 100652, - 100653, 100654, 100655, 100656, 100657, 100658, 100659, 100660, 100661, - 100662, 100663, 100664, 100665, 100666, 100667, 100668, 100669, 100670, - 100671, 100672, 100673, 100674, 100675, 100676, 100677, 100678, 100679, - 100680, 100681, 100682, 100683, 100684, 100685, 100686, 100687, 100688, - 100689, 100690, 100691, 100692, 100693, 100694, 100695, 100696, 100697, - 100698, 100699, 100700, 100701, 100702, 100703, 100704, 100705, 100706, - 100707, 100708, 100709, 100710, 100711, 100712, 100713, 100714, 100715, - 100716, 100717, 100718, 100719, 100720, 100721, 100722, 100723, 100724, - 100725, 100726, 100727, 100728, 100729, 100730, 100731, 100732, 100733, - 100734, 100735, 100736, 100737, 100738, 100739, 100740, 100741, 100742, - 100743, 100744, 100745, 100746, 100747, 100748, 100749, 100750, 100751, - 100752, 100753, 100754, 100755, 100756, 100757, 100758, 100759, 100760, - 100761, 100762, 100763, 100764, 100765, 100766, 100767, 100768, 100769, - 100770, 100771, 100772, 100773, 100774, 100775, 100776, 100777, 100778, - 100779, 100780, 100781, 100782, 100783, 100784, 100785, 100786, 100787, - 100788, 100789, 100790, 100791, 100792, 100793, 100794, 100795, 100796, - 100797, 100798, 100799, 100800, 100801, 100802, 100803, 100804, 100805, - 100806, 100807, 100808, 100809, 100810, 100811, 100812, 100813, 100814, - 100815, 100816, 100817, 100818, 100819, 100820, 100821, 100822, 100823, - 100824, 100825, 100826, 100827, 100828, 100829, 100830, 100831, 100832, - 100833, 100834, 100835, 100836, 100837, 100838, 100839, 100840, 100841, - 100842, 100843, 100844, 100845, 100846, 100847, 100848, 100849, 100850, - 100851, 100852, 100853, 100854, 100855, 100856, 100857, 100858, 100859, - 100860, 100861, 100862, 100863, 100864, 100865, 100866, 100867, 100868, - 100869, 100870, 100871, 100872, 100873, 100874, 100875, 100876, 100877, - 100878, 100879, 100880, 100881, 100882, 100883, 100884, 100885, 100886, - 100887, 100888, 100889, 100890, 100891, 100892, 100893, 100894, 100895, - 100896, 100897, 100898, 100899, 100900, 100901, 100902, 100903, 100904, - 100905, 100906, 100907, 100908, 100909, 100910, 100911, 100912, 100913, - 100914, 100915, 100916, 100917, 100918, 100919, 100920, 100921, 100922, - 100923, 100924, 100925, 100926, 100927, 100928, 100929, 100930, 100931, - 100932, 100933, 100934, 100935, 100936, 100937, 100938, 100939, 100940, - 100941, 100942, 100943, 100944, 100945, 100946, 100947, 100948, 100949, - 100950, 100951, 100952, 100953, 100954, 100955, 100956, 100957, 100958, - 100959, 100960, 100961, 100962, 100963, 100964, 100965, 100966, 100967, - 100968, 100969, 100970, 100971, 100972, 100973, 100974, 100975, 100976, - 100977, 100978, 100979, 100980, 100981, 100982, 100983, 100984, 100985, - 100986, 100987, 100988, 100989, 100990, 100991, 100992, 100993, 100994, - 100995, 100996, 100997, 100998, 100999, 101000, 101001, 101002, 101003, - 101004, 101005, 101006, 101007, 101008, 101009, 101010, 101011, 101012, - 101013, 101014, 101015, 101016, 101017, 101018, 101019, 101020, 101021, - 101022, 101023, 101024, 101025, 101026, 101027, 101028, 101029, 101030, - 101031, 101032, 101033, 101034, 101035, 101036, 101037, 101038, 101039, - 101040, 101041, 101042, 101043, 101044, 101045, 101046, 101047, 101048, - 101049, 101050, 101051, 101052, 101053, 101054, 101055, 101056, 101057, - 101058, 101059, 101060, 101061, 101062, 101063, 101064, 101065, 101066, - 101067, 101068, 101069, 101070, 101071, 101072, 101073, 101074, 101075, - 101076, 101077, 101078, 101079, 101080, 101081, 101082, 101083, 101084, - 101085, 101086, 101087, 101088, 101089, 101090, 101091, 101092, 101093, - 101094, 101095, 101096, 101097, 101098, 101099, 101100, 101101, 101102, - 101103, 101104, 101105, 101106, 101107, 101108, 101109, 101110, 101111, - 101112, 101113, 101114, 101115, 101116, 101117, 101118, 101119, 101760, - 101761, 101762, 101763, 101764, 101765, 101766, 101767, 101768, 101769, - 101770, 101771, 101772, 101773, 101774, 101775, 101776, 101777, 101778, - 101779, 101780, 101781, 101782, 101783, 101784, 101785, 101786, 101787, - 101788, 101789, 101790, 101791, 101792, 101793, 101794, 101795, 101796, - 101797, 101798, 101799, 101800, 101801, 101802, 101803, 101804, 101805, - 101806, 101807, 101808, 101809, 101810, 101811, 101812, 101813, 101814, - 101815, 101816, 101817, 101818, 101819, 101820, 101821, 101822, 101823, - 101824, 101825, 101826, 101827, 101828, 101829, 101830, 101831, 101832, - 101833, 101834, 101835, 101836, 101837, 101838, 101839, 101840, 101841, - 101842, 101843, 101844, 101845, 101846, 101847, 101848, 101849, 101850, - 101851, 101852, 101853, 101854, 101855, 101856, 101857, 101858, 101859, - 101860, 101861, 101862, 101863, 101864, 101865, 101866, 101867, 101868, - 101869, 101870, 101871, 101872, 101873, 101874, 94176, 128429, 9991, - 9801, 127790, 128661, 127861, 128198, 10043, 10170, 129750, 129528, - 128222, 128380, 8981, 9990, 8481, 128384, 128301, 128250, 3164, 3158, - 3195, 3198, 3194, 3197, 3193, 3196, 3192, 3106, 3105, 3111, 3161, 3110, - 3112, 3165, 3097, 3107, 3102, 3162, 3121, 3120, 3104, 3103, 3109, 3160, - 3108, 3077, 3078, 3088, 3092, 3124, 3123, 3122, 3083, 3168, 3084, 3169, - 3125, 3081, 3082, 3090, 3091, 3079, 3080, 3126, 3127, 3128, 3117, 3116, - 3099, 3098, 3096, 3095, 3101, 3100, 3094, 3093, 3115, 3114, 3086, 3087, - 3129, 3118, 3119, 3157, 3076, 3072, 3073, 3191, 3199, 3132, 3133, 3074, - 3149, 3075, 3134, 3144, 3148, 3137, 3138, 3139, 3140, 3170, 3171, 3146, - 3147, 3135, 3136, 3142, 3143, 3179, 3178, 3181, 3180, 3177, 3176, 3174, - 3183, 3175, 3182, 127934, 8376, 9978, 129514, 119617, 119564, 119577, + 118286, 129013, 118284, 118432, 118443, 129933, 128381, 130025, 130017, + 11805, 8906, 10198, 129927, 9621, 129980, 41, 9120, 9118, 11875, 9119, + 11789, 10182, 8908, 129931, 8217, 11815, 128360, 128361, 128362, 128489, + 93, 9126, 9124, 10638, 10640, 8262, 10636, 11864, 11862, 9125, 11779, + 117773, 129987, 128493, 118433, 118442, 129930, 129928, 11786, 8895, + 10702, 129902, 12309, 8866, 11809, 9145, 117766, 12303, 10628, 12311, + 10630, 12315, 12313, 10713, 1421, 117833, 117907, 117909, 129308, 4053, + 4055, 117874, 117878, 9957, 9002, 117858, 10749, 187, 117775, 128270, + 117921, 117848, 117923, 117913, 117863, 117763, 117919, 117882, 117761, + 10153, 10552, 8295, 8238, 8235, 8207, 10813, 8594, 11080, 11084, 10562, + 10613, 10612, 129974, 8614, 10528, 129217, 11076, 11075, 10567, 10526, + 8677, 8628, 10513, 8699, 129202, 8620, 129034, 10565, 129042, 129026, + 8603, 11022, 11023, 8611, 10517, 10516, 129030, 129178, 129046, 8618, + 8696, 8644, 10522, 129193, 129185, 11146, 11157, 8658, 10499, 8655, + 10503, 10524, 10509, 8674, 129195, 129078, 10601, 10605, 10591, 10583, + 8641, 10600, 10604, 10596, 10587, 10579, 8640, 8652, 129777, 129090, + 129094, 129191, 8702, 8649, 129784, 129189, 128622, 8669, 129082, 129106, + 129786, 129187, 11106, 11138, 11132, 983242, 11175, 11173, 129066, + 129062, 129058, 129074, 129070, 11122, 11116, 11142, 129170, 10511, 8667, + 10518, 10520, 10519, 11246, 10497, 10496, 10501, 10512, 8608, 8605, 8680, + 8688, 129174, 129086, 11078, 128141, 128735, 11824, 8790, 8791, 8728, + 730, 129680, 128365, 10539, 10544, 65020, 129350, 983227, 983235, 983225, + 983230, 129704, 128640, 128478, 127906, 128764, 129531, 129315, 65947, + 65942, 65945, 65940, 65943, 8556, 8583, 8582, 8548, 8558, 8577, 8547, + 8544, 8557, 8584, 8559, 8576, 8549, 8581, 8550, 8553, 8578, 8555, 8545, + 8546, 8579, 8554, 8551, 8552, 65938, 65944, 65936, 65939, 65941, 65937, + 65946, 129756, 128019, 127801, 127989, 10087, 10085, 11213, 11215, 8506, + 128205, 128907, 127588, 127586, 127589, 127584, 127585, 127587, 128675, + 127840, 129302, 8381, 127945, 10740, 69245, 69243, 69244, 69246, 69241, + 69232, 69238, 69229, 69237, 69228, 69242, 69233, 69234, 69240, 69231, + 69239, 69230, 69236, 69227, 69235, 69226, 69225, 69220, 69219, 69222, + 69221, 69218, 69217, 69224, 69216, 69223, 5872, 5869, 5803, 5802, 5800, + 5833, 5837, 5860, 5811, 5859, 5858, 5841, 5851, 5824, 5844, 5854, 5826, + 5846, 5856, 5799, 5814, 5880, 5879, 5877, 5876, 5878, 5792, 5813, 5815, + 5828, 5816, 5819, 5818, 5853, 5852, 5825, 5831, 5864, 5857, 5827, 5873, + 5812, 5810, 5850, 5829, 5820, 5848, 5804, 5862, 5806, 5801, 5855, 5845, + 5807, 5808, 5875, 5809, 5874, 5843, 5821, 5849, 5823, 5805, 5836, 5840, + 5830, 5863, 5835, 5834, 5861, 5842, 5822, 5798, 5839, 5797, 5817, 5794, + 5847, 5832, 5796, 5795, 5865, 5793, 5866, 5838, 5867, 5868, 5870, 5871, + 127933, 127939, 11254, 11252, 11253, 11251, 11255, 11256, 8360, 8386, + 983114, 10700, 129466, 129527, 9808, 129474, 9747, 129761, 2049, 2053, + 2051, 2063, 2055, 2052, 2058, 2059, 2062, 2068, 2069, 2056, 2065, 2048, + 2050, 2067, 2054, 2060, 2066, 2061, 2057, 2064, 2073, 2070, 2071, 2075, + 2093, 2072, 2074, 2084, 2088, 2097, 2110, 2098, 2100, 2108, 2099, 2096, + 2101, 2109, 2106, 2104, 2107, 2103, 2105, 2082, 2079, 2076, 2089, 2086, + 2091, 2081, 2078, 2085, 2092, 2083, 2080, 2077, 2090, 2087, 2102, 128630, + 128631, 128632, 128634, 129386, 128752, 128225, 9796, 43138, 43139, + 43150, 43153, 43167, 43166, 43172, 43171, 43165, 43164, 43170, 43169, + 43144, 43145, 43146, 43147, 43182, 43142, 43143, 43151, 43152, 43140, + 43141, 43187, 43181, 43158, 43168, 43163, 43173, 43183, 43184, 43185, + 43177, 43176, 43160, 43159, 43157, 43156, 43162, 43161, 43155, 43154, + 43175, 43174, 43148, 43149, 43186, 43178, 43180, 43179, 43205, 43136, + 43204, 43137, 43215, 43214, 43221, 43220, 43223, 43222, 43219, 43218, + 43216, 43225, 43217, 43224, 43188, 43189, 43200, 43203, 43192, 43193, + 43194, 43195, 43196, 43197, 43201, 43202, 43190, 43191, 43198, 43199, + 129429, 8385, 9973, 127927, 127862, 129403, 9878, 129507, 127979, 127890, + 129410, 9807, 128756, 129691, 128437, 8492, 8496, 8497, 8459, 8464, 8466, + 8499, 8472, 8475, 128624, 8495, 8458, 8467, 8500, 8456, 128220, 983186, + 129453, 128186, 8980, 118518, 118520, 118519, 167, 129352, 127793, + 128584, 8979, 130037, 130036, 130039, 130038, 130035, 130034, 130032, + 130041, 130033, 130040, 10802, 9914, 59, 117793, 117795, 117799, 117807, + 117803, 117797, 117805, 117801, 117794, 117798, 117806, 117802, 117796, + 117804, 117800, 118353, 118355, 118359, 118367, 118383, 118415, 118399, + 118375, 118407, 118391, 118363, 118379, 118411, 118395, 118371, 118403, + 118387, 118357, 118365, 118381, 118413, 118397, 118373, 118405, 118389, + 118361, 118377, 118409, 118393, 118369, 118401, 118385, 118354, 118358, + 118366, 118382, 118414, 118398, 118374, 118406, 118390, 118362, 118378, + 118410, 118394, 118370, 118402, 118386, 118356, 118364, 118380, 118412, + 118396, 118372, 118404, 118388, 118360, 118376, 118408, 118392, 118368, + 118400, 118384, 11259, 8480, 129324, 9916, 65093, 983169, 8726, 129697, + 9913, 11250, 129331, 10061, 10032, 10014, 129368, 70086, 70085, 70101, + 70100, 70103, 70102, 70099, 70098, 70096, 70105, 70097, 70104, 70092, + 70106, 70108, 70019, 70020, 70030, 70032, 70046, 70045, 70051, 70050, + 70044, 70043, 70049, 70048, 70025, 70026, 70027, 70028, 70062, 70023, + 70024, 70021, 70022, 70061, 70060, 70037, 70047, 70042, 70052, 70063, + 70064, 70065, 70056, 70055, 70039, 70038, 70036, 70035, 70041, 70040, + 70034, 70033, 70054, 70053, 70066, 70057, 70059, 70058, 70029, 70031, + 70089, 70110, 70111, 70088, 70095, 70107, 70016, 70090, 70081, 70017, + 70082, 70083, 70080, 70018, 70093, 70091, 72550, 72551, 70078, 72545, + 72544, 70094, 70070, 70071, 72547, 72546, 72548, 72549, 70067, 70077, + 70079, 70072, 70073, 70074, 70075, 70068, 70069, 70076, 70087, 70109, + 70084, 129416, 127847, 66684, 66680, 66682, 66665, 66673, 66679, 66664, + 66669, 66647, 66685, 66672, 66683, 66663, 66659, 66649, 66686, 66674, + 66662, 66660, 66656, 66661, 66677, 66678, 66668, 66676, 66666, 66681, + 66640, 66670, 66646, 66645, 66644, 66654, 66641, 66667, 66658, 66648, + 66687, 66657, 66651, 66655, 66643, 66652, 66650, 66642, 66653, 66671, + 66675, 9752, 129768, 128737, 983075, 983078, 9961, 128674, 127776, + 128722, 128717, 11087, 11103, 11086, 129237, 10974, 10564, 129235, 10976, + 10985, 10984, 10975, 10983, 113825, 113824, 113826, 113827, 127856, + 129651, 9085, 129327, 129679, 128703, 128017, 129424, 129335, 10722, + 983198, 983080, 71113, 71040, 71131, 71041, 71051, 71053, 71128, 71070, + 71129, 71130, 71065, 71064, 71069, 71067, 71066, 71072, 71071, 71046, + 71047, 71048, 71049, 71082, 71044, 71045, 71042, 71043, 71058, 71068, + 71063, 71073, 71083, 71084, 71085, 71077, 71076, 71060, 71059, 71057, + 71056, 71062, 71061, 71055, 71054, 71075, 71074, 71086, 71081, 71078, + 71080, 71079, 71050, 71052, 71110, 71111, 71112, 71119, 71120, 71127, + 71126, 71125, 71123, 71124, 71117, 71118, 71116, 71121, 71115, 71114, + 71122, 71109, 71108, 71105, 71100, 71104, 71101, 71103, 71102, 71132, + 71133, 71087, 71097, 71099, 71092, 71093, 71090, 71091, 71088, 71089, + 71096, 71098, 71107, 71106, 67923, 67924, 67925, 67926, 67927, 67928, + 67929, 67904, 67905, 67906, 67907, 67908, 67909, 67910, 67911, 67912, + 67913, 67914, 67915, 67916, 67917, 67918, 67919, 67920, 67921, 67922, + 128411, 128410, 128417, 128416, 128409, 128408, 128415, 128414, 121399, + 121397, 121400, 121398, 121402, 121401, 121104, 121103, 121102, 121388, + 121387, 121386, 121482, 121479, 121358, 121359, 121357, 121360, 121341, + 121335, 121339, 121340, 121336, 121334, 121333, 121338, 121337, 121342, + 121368, 121367, 121373, 121356, 121355, 121354, 121380, 121382, 121381, + 121384, 121383, 121385, 121377, 121379, 121378, 121375, 121376, 121374, + 121371, 121369, 121366, 121370, 121372, 121364, 121365, 121452, 121392, + 121352, 121353, 121351, 121499, 121500, 121501, 121502, 121503, 121470, + 121117, 121115, 121119, 121118, 121116, 121456, 121363, 121362, 121361, + 121480, 121455, 120965, 120837, 121000, 120969, 121027, 121026, 121076, + 121074, 121075, 120995, 120991, 120990, 120982, 121005, 121011, 121044, + 121042, 121043, 120950, 120833, 120847, 121002, 120859, 120863, 120997, + 120967, 120845, 121019, 120839, 120993, 120980, 121038, 121045, 121031, + 121009, 120934, 121046, 121047, 120905, 120936, 120937, 120935, 121065, + 120941, 120834, 121068, 121069, 121024, 120915, 120916, 121040, 120940, + 120944, 120946, 120942, 120945, 120947, 120943, 120949, 121020, 121039, + 120948, 121091, 120832, 120838, 120861, 120843, 120852, 120870, 120844, + 120846, 120848, 120865, 120853, 120856, 120885, 120877, 120878, 120879, + 120884, 120857, 120882, 120854, 120855, 120858, 120883, 121001, 120871, + 120850, 120867, 120966, 120972, 120971, 120849, 120862, 120895, 120894, + 120872, 120873, 120893, 120875, 120874, 120866, 120864, 120996, 120842, + 120891, 120890, 121067, 120892, 120887, 121064, 121066, 121063, 121060, + 121061, 121062, 120899, 120881, 121052, 121059, 121057, 121054, 121055, + 121056, 121058, 120851, 120869, 120868, 120841, 121018, 120974, 120977, + 120976, 120975, 120985, 120986, 120983, 120992, 120988, 120984, 120978, + 121032, 121037, 120897, 120896, 120898, 120889, 120888, 120886, 120880, + 121035, 121030, 121033, 121028, 121036, 120860, 121003, 121012, 121014, + 121013, 121007, 121016, 121008, 121015, 121006, 121077, 121083, 120876, + 121084, 121085, 121078, 121090, 121087, 121079, 121080, 121081, 120840, + 121086, 121088, 121089, 120979, 121082, 121092, 120906, 120922, 120908, + 120919, 120920, 120921, 120914, 120910, 120912, 120900, 120903, 120904, + 120902, 120901, 120924, 120909, 120911, 120913, 120926, 120930, 120931, + 120932, 120929, 120933, 120928, 120925, 120927, 120923, 120957, 120917, + 120907, 120836, 121051, 120968, 120973, 120998, 121072, 121053, 121073, + 121070, 121071, 121025, 120970, 120994, 120989, 120987, 121029, 121041, + 120955, 120961, 120956, 120959, 120999, 121004, 120964, 120960, 120963, + 120962, 120958, 120939, 120938, 121023, 121021, 121022, 121050, 121048, + 121049, 121034, 121017, 120951, 120918, 120981, 120953, 121010, 120954, + 120952, 120835, 121451, 121343, 121349, 121347, 121348, 121346, 121345, + 121350, 121344, 121462, 121463, 121464, 121465, 121466, 121467, 121468, + 121469, 121428, 121429, 121427, 121476, 121473, 121477, 121475, 121474, + 121478, 121472, 121471, 121404, 121405, 121403, 121430, 121409, 121411, + 121410, 121406, 121408, 121407, 121421, 121423, 121422, 121415, 121416, + 121417, 121418, 121419, 121420, 121414, 121413, 121412, 121424, 121425, + 121426, 121432, 121431, 121183, 121184, 121182, 121181, 121187, 121188, + 121186, 121185, 121175, 121176, 121174, 121173, 121179, 121180, 121178, + 121177, 121324, 121321, 121323, 121320, 121322, 121319, 121210, 121209, + 121208, 121203, 121207, 121305, 121272, 121271, 121287, 121286, 121303, + 121304, 121302, 121301, 121206, 121205, 121204, 121198, 121332, 121331, + 121129, 121276, 121274, 121275, 121273, 121288, 121289, 121291, 121290, + 121306, 121280, 121278, 121279, 121277, 121295, 121293, 121294, 121292, + 121307, 121314, 121191, 121192, 121190, 121189, 121193, 121202, 121201, + 121200, 121199, 121282, 121281, 121297, 121296, 121308, 121309, 121310, + 121328, 121327, 121194, 121196, 121197, 121195, 121216, 121215, 121214, + 121213, 121212, 121211, 121449, 121125, 121126, 121121, 121122, 121123, + 121124, 121127, 121318, 121316, 121317, 121315, 121156, 121155, 121154, + 121146, 121145, 121144, 121150, 121149, 121148, 121147, 121230, 121231, + 121229, 121228, 121254, 121261, 121247, 121233, 121232, 121226, 121227, + 121225, 121224, 121249, 121248, 121153, 121152, 121151, 121139, 121135, + 121137, 121138, 121136, 121330, 121329, 121128, 121236, 121255, 121262, + 121235, 121234, 121237, 121240, 121239, 121256, 121263, 121238, 121162, + 121161, 121160, 121132, 121133, 121131, 121130, 121134, 121253, 121142, + 121143, 121141, 121140, 121243, 121242, 121241, 121246, 121245, 121244, + 121270, 121269, 121268, 121257, 121264, 121326, 121325, 121159, 121158, + 121157, 121448, 121394, 121393, 121395, 121396, 121450, 121513, 121514, + 121515, 121516, 121517, 121518, 121519, 121505, 121506, 121507, 121508, + 121509, 121510, 121511, 121512, 121312, 121284, 121299, 121311, 121283, + 121298, 121313, 121285, 121300, 121260, 121267, 121252, 121251, 121259, + 121266, 121250, 121258, 121265, 121107, 121106, 121105, 121454, 121453, + 121457, 121120, 121112, 121110, 121114, 121113, 121111, 121108, 121109, + 121101, 121100, 121099, 121481, 121441, 121445, 121446, 121443, 121444, + 121442, 121447, 121390, 121389, 121391, 121440, 121439, 121437, 121435, + 121436, 121434, 121433, 121438, 121459, 121458, 121460, 121095, 121094, + 121093, 121219, 121218, 121217, 121222, 121221, 121220, 121223, 121172, + 121171, 121170, 121168, 121167, 121166, 121165, 121164, 121163, 121169, + 121098, 121097, 121096, 121461, 121483, 129304, 10912, 10911, 10910, + 10909, 10860, 983185, 983183, 8219, 8249, 8218, 8250, 983158, 983155, + 983156, 983159, 70117, 70116, 70119, 70118, 70115, 70114, 70121, 70113, + 70120, 70131, 70132, 70129, 70126, 70125, 70130, 70128, 70127, 70124, + 70123, 70122, 983953, 983954, 983952, 3464, 3463, 3495, 3501, 3497, 3503, + 3510, 3488, 3484, 3490, 3482, 3508, 3513, 3462, 3475, 3478, 3461, 3474, + 3473, 3472, 3471, 3470, 3469, 3466, 3465, 3468, 3467, 3496, 3502, 3498, + 3504, 3511, 3489, 3485, 3491, 3483, 3509, 3512, 3525, 3499, 3522, 3517, + 3505, 3523, 3477, 3476, 3500, 3507, 3487, 3494, 3526, 3524, 3515, 3520, + 3514, 3492, 3493, 3521, 3486, 3563, 3562, 3565, 3564, 3561, 3560, 3558, + 3567, 3559, 3566, 3530, 3458, 3457, 3459, 3570, 3571, 3546, 3537, 3539, + 3542, 3544, 3551, 3536, 3538, 3540, 3545, 3548, 3549, 3550, 3547, 3535, + 3572, 8767, 10046, 128973, 10038, 128303, 8198, 10042, 128510, 127935, + 9975, 128128, 9760, 129448, 128761, 10902, 10904, 10901, 10903, 11098, + 11100, 42611, 128716, 128164, 128564, 128554, 128373, 128759, 127829, + 128578, 128577, 10840, 10839, 9011, 127920, 129445, 65120, 128745, 65121, + 128313, 128312, 8717, 8956, 8958, 65131, 65104, 65109, 65129, 8714, 8948, + 8951, 65126, 65112, 65111, 65105, 65115, 65113, 65117, 65124, 65116, + 65114, 65118, 8570, 8567, 8564, 8574, 8572, 8563, 8560, 8573, 8575, 8571, + 8561, 8562, 8569, 8566, 8565, 8568, 65128, 65108, 68411, 732, 118266, + 10849, 65125, 65123, 65130, 65122, 65119, 65106, 65110, 10922, 10924, + 10803, 128571, 128570, 128525, 128520, 128519, 128515, 128517, 128516, + 128518, 128522, 129325, 129392, 128526, 129394, 8995, 128527, 128684, + 128013, 118010, 128012, 129319, 127956, 9731, 9924, 127938, 10052, + 983077, 9917, 129510, 173, 127846, 128428, 9108, 129358, 69453, 69452, + 69454, 69456, 69447, 69449, 69446, 69448, 69455, 69451, 69450, 69445, + 69424, 69437, 69426, 69433, 69444, 69440, 69429, 69436, 69439, 69441, + 69431, 69427, 69430, 69432, 69425, 69443, 69435, 69442, 69428, 69438, + 69434, 69457, 69460, 69459, 69458, 69463, 69465, 69461, 69462, 69464, + 128618, 128619, 47, 10742, 128284, 69859, 69863, 69864, 69846, 69847, + 69857, 69849, 69842, 69843, 69844, 69845, 69854, 69856, 69855, 69848, + 69851, 69853, 69840, 69841, 69850, 69852, 69858, 69860, 69862, 69861, + 69877, 69876, 69879, 69878, 69875, 69874, 69872, 69881, 69873, 69880, + 8600, 10537, 10541, 8690, 10533, 129210, 128603, 128595, 128611, 11112, + 11128, 11018, 8664, 129110, 11010, 8601, 10538, 10534, 129211, 128601, + 128593, 128609, 11113, 11129, 11019, 8665, 129111, 11011, 8471, 72328, + 72329, 72327, 72326, 72340, 72339, 72334, 72332, 72341, 72335, 72333, + 72330, 72331, 72338, 72336, 72337, 72352, 72351, 72350, 72297, 72296, + 72302, 72311, 72301, 72323, 72285, 72284, 72288, 72298, 72293, 72303, + 72319, 72320, 72321, 72310, 72309, 72295, 72294, 72300, 72299, 72307, + 72306, 72290, 72289, 72287, 72286, 72292, 72291, 72305, 72304, 72312, + 72313, 72314, 72322, 72317, 72308, 72316, 72318, 72315, 72272, 72349, + 72348, 72347, 72346, 72324, 72343, 72325, 72342, 72345, 72353, 72354, + 72282, 72281, 72279, 72280, 72277, 72278, 72275, 72274, 72276, 72273, + 72283, 72344, 8384, 983043, 983182, 983118, 983177, 127837, 128150, + 10055, 10024, 117824, 117825, 32, 128586, 128264, 128263, 128265, 128266, + 128483, 128676, 128172, 8375, 117830, 117831, 8738, 10656, 10657, 128375, + 128376, 128467, 128466, 128026, 128166, 129759, 129525, 129348, 128051, + 127941, 129533, 13279, 13056, 117900, 13058, 13057, 13059, 13250, 13171, + 13278, 13101, 13172, 13108, 13105, 13118, 13116, 13251, 13192, 8851, + 13255, 13183, 13213, 13220, 13216, 13254, 8852, 13252, 13253, 13170, + 13092, 13175, 13177, 13176, 13093, 13094, 13256, 127376, 13207, 13064, + 13179, 13181, 13182, 13055, 13180, 13005, 13063, 13006, 117899, 117898, + 117897, 9974, 9165, 13209, 13070, 13071, 13311, 13075, 13073, 13072, + 13080, 13081, 13203, 13228, 13191, 13257, 13258, 13098, 13110, 13113, + 13121, 13122, 13119, 13107, 13106, 13109, 13259, 13169, 127488, 13004, + 13200, 13260, 13060, 13061, 8847, 8932, 8849, 13178, 13188, 13068, 13069, + 13067, 13076, 13078, 13079, 13077, 13214, 13262, 13222, 13218, 13086, + 13085, 13082, 13083, 13084, 13074, 13201, 13193, 13248, 13226, 13189, + 13199, 13261, 13208, 13263, 13240, 13246, 10957, 8977, 13266, 13264, + 13265, 13267, 13223, 13224, 13249, 13221, 13217, 13187, 13123, 13124, + 13127, 13126, 13125, 13190, 13268, 13131, 13132, 13133, 13128, 13129, + 13130, 13269, 13212, 13219, 13215, 13186, 13196, 13197, 13205, 13211, + 13234, 13238, 13244, 13239, 13241, 13245, 13247, 13202, 13270, 13227, + 13198, 13206, 13235, 13185, 13096, 13097, 13195, 13210, 13233, 13237, + 13243, 13065, 8848, 8933, 8850, 13066, 13173, 13225, 13099, 13100, 13184, + 13115, 13112, 13114, 13111, 13103, 13104, 13102, 13117, 13120, 11216, + 13273, 13174, 13194, 13271, 13272, 13274, 13232, 13236, 13242, 13229, + 13230, 13231, 13142, 13141, 10958, 13137, 13138, 8730, 118493, 118494, + 118495, 13140, 13139, 13087, 13088, 13090, 13091, 117887, 117886, 117884, + 117885, 13089, 13275, 13276, 128918, 13204, 13095, 13143, 11027, 9641, + 9638, 9636, 11029, 9706, 9703, 11026, 9705, 9639, 11028, 9640, 9637, + 9704, 10720, 13277, 13135, 13134, 13136, 13062, 127529, 127530, 127512, + 127508, 127533, 127545, 127520, 127516, 127534, 127506, 127540, 127525, + 127546, 127532, 127511, 127509, 127524, 127505, 127517, 127518, 127527, + 127537, 127504, 127528, 127535, 127519, 127515, 127513, 127543, 127542, + 127526, 127541, 127544, 127522, 127538, 127514, 127521, 127539, 127510, + 127536, 127523, 127547, 127531, 127378, 127377, 8865, 10693, 11820, + 127390, 127392, 127379, 10692, 127400, 127399, 127398, 127306, 127489, + 127507, 127490, 9919, 127397, 127280, 127281, 127282, 127283, 127284, + 127285, 127286, 127287, 127288, 127289, 127290, 127291, 127292, 127293, + 127294, 127295, 127296, 127297, 127298, 127299, 127300, 127301, 127302, + 127303, 127304, 127305, 10190, 10191, 127401, 8863, 127307, 127381, + 127382, 127396, 127383, 127310, 8862, 127388, 127393, 127402, 127395, + 9949, 10695, 10696, 127384, 127308, 127309, 127387, 127394, 127389, 8864, + 127391, 127385, 127403, 127404, 127386, 10694, 127311, 127380, 10151, + 129425, 983157, 983160, 983134, 983190, 9877, 9882, 128387, 8795, 10017, + 8902, 9770, 11242, 11243, 983175, 983133, 983181, 983176, 983042, 983044, + 128509, 128649, 129485, 127967, 128642, 127836, 11836, 129658, 129989, + 129990, 129993, 129991, 129992, 128480, 9201, 128207, 9188, 127827, + 118463, 10025, 983189, 117891, 117888, 117890, 117889, 8803, 127897, + 129369, 128723, 983170, 983045, 983103, 8333, 8332, 8328, 8330, 8334, + 8331, 8325, 8324, 8327, 8326, 8323, 8322, 8320, 8329, 8321, 10963, 10965, + 10617, 8834, 10953, 10949, 10951, 10955, 8842, 8838, 10947, 10945, 10943, + 10941, 983102, 8827, 10938, 10934, 10928, 10930, 10936, 10932, 8937, + 8831, 8829, 8881, 9139, 10763, 9138, 9737, 127774, 9925, 7098, 7073, + 7074, 7075, 7084, 7085, 7043, 983220, 7046, 7102, 7103, 7062, 7100, 7068, + 7099, 7067, 7087, 7070, 7048, 7049, 7053, 7057, 7060, 7101, 7064, 7086, + 7050, 7054, 7059, 7052, 7072, 7055, 7065, 7061, 7051, 7058, 7063, 7069, + 7071, 7066, 7056, 7044, 7047, 7045, 7367, 7366, 7365, 7364, 7363, 7361, + 7362, 7360, 7082, 7041, 7042, 7040, 7083, 7080, 7081, 7079, 7077, 7076, + 7078, 7093, 7092, 7095, 7094, 7091, 7090, 7088, 7097, 7089, 7096, 127749, + 127748, 72648, 72662, 72661, 72669, 72652, 72640, 72663, 72651, 72655, + 72672, 72646, 72667, 72666, 72653, 72657, 72645, 72665, 72649, 72644, + 72658, 72668, 72670, 72664, 72671, 72641, 72659, 72656, 72650, 72643, + 72660, 72654, 72642, 72647, 72673, 72693, 72692, 72695, 72694, 72691, + 72690, 72688, 72697, 72689, 72696, 127751, 127803, 8316, 8312, 8305, + 8319, 8317, 8314, 8318, 8315, 8309, 8308, 8311, 8310, 179, 178, 8304, + 8313, 185, 10966, 10964, 10619, 10968, 10967, 8835, 10954, 10950, 10952, + 10956, 8843, 8839, 10948, 10946, 10944, 10942, 10185, 129464, 129465, + 8751, 127940, 128671, 127843, 128629, 129442, 127946, 8275, 43027, 43026, + 43031, 43030, 43040, 43038, 43025, 43024, 43029, 43028, 43036, 43035, + 43021, 43020, 43018, 43017, 43023, 43022, 43016, 43015, 43034, 43033, + 43042, 43039, 43037, 43032, 43041, 43008, 43012, 43009, 43013, 43011, + 43048, 43049, 43050, 43051, 43052, 43019, 43014, 43010, 43047, 43043, + 43046, 43044, 43045, 9223, 9224, 9229, 9240, 9232, 9249, 9256, 9255, + 9253, 9257, 9236, 9235, 9234, 9233, 9241, 9220, 9239, 9219, 9221, 9243, + 9244, 9228, 9225, 9227, 9226, 128325, 9237, 9252, 9216, 9222, 9246, 9245, + 9247, 8527, 9230, 9231, 9217, 9218, 9242, 9254, 9238, 9248, 11159, 9007, + 983094, 983093, 128333, 1807, 1866, 1802, 1798, 1799, 1849, 1848, 1792, + 1854, 1853, 1805, 1804, 1803, 1852, 1851, 1850, 1797, 1814, 1813, 1815, + 1818, 1824, 2153, 2152, 2149, 2148, 2144, 2146, 2150, 2147, 2154, 2145, + 2151, 1825, 1830, 1837, 1839, 1838, 1831, 1834, 1827, 1869, 1870, 1871, + 1809, 1835, 1832, 1828, 1808, 1823, 1833, 1819, 1820, 1836, 1811, 1812, + 1821, 1822, 1810, 1817, 1826, 1816, 1829, 1864, 1863, 1842, 1841, 1840, + 1845, 1844, 1843, 1847, 1846, 1855, 1858, 1796, 983204, 1801, 1794, 1795, + 1800, 1793, 1862, 1861, 1860, 1859, 1865, 1856, 1857, 128137, 983184, + 128085, 129430, 983061, 127955, 917543, 917542, 917546, 917598, 917568, + 917548, 917562, 917540, 917557, 917556, 917559, 917558, 917555, 917554, + 917552, 917561, 917553, 917560, 917565, 917537, 917600, 917566, 917549, + 917569, 917570, 917571, 917572, 917573, 917574, 917575, 917576, 917577, + 917578, 917579, 917580, 917581, 917582, 917583, 917584, 917585, 917586, + 917587, 917588, 917589, 917590, 917591, 917592, 917593, 917594, 917601, + 917602, 917603, 917604, 917605, 917606, 917607, 917608, 917609, 917610, + 917611, 917612, 917613, 917614, 917615, 917616, 917617, 917618, 917619, + 917620, 917621, 917622, 917623, 917624, 917625, 917626, 917564, 917627, + 917544, 917595, 917599, 917541, 917547, 917538, 917567, 917629, 917545, + 917597, 917596, 917563, 917551, 917536, 917539, 917630, 917550, 917628, + 5888, 5919, 5893, 5896, 5898, 5895, 5892, 5905, 5891, 5902, 5899, 5897, + 5901, 5904, 5894, 5903, 5900, 5889, 5890, 5909, 5908, 5906, 5907, 5989, + 5992, 5994, 5991, 5988, 5987, 5998, 5995, 5993, 6000, 5990, 5999, 5996, + 5984, 5985, 5986, 6002, 6003, 6499, 6508, 6509, 6507, 6501, 6502, 6512, + 6513, 6514, 6515, 6516, 6497, 6483, 6487, 6486, 6482, 6498, 6505, 6504, + 6496, 6480, 6490, 6489, 6503, 6506, 6492, 6494, 6488, 6491, 6495, 6484, + 6493, 6481, 6485, 6500, 6745, 6746, 6743, 6747, 6742, 6741, 6748, 6749, + 6750, 6783, 6789, 6788, 6791, 6790, 6787, 6786, 6784, 6793, 6785, 6792, + 6805, 6804, 6807, 6806, 6803, 6802, 6800, 6809, 6801, 6808, 6740, 6689, + 6690, 6688, 6702, 6726, 6727, 6728, 6696, 6695, 6713, 6712, 6707, 6706, + 6714, 6729, 6720, 6693, 6692, 6691, 6704, 6699, 6697, 6717, 6715, 6709, + 6708, 6716, 6732, 6698, 6719, 6723, 6739, 6724, 6730, 6721, 6705, 6701, + 6722, 6735, 6736, 6733, 6734, 6694, 6700, 6710, 6738, 6737, 6711, 6703, + 6718, 6725, 6731, 6828, 6820, 6775, 6776, 6777, 6780, 6824, 6825, 6819, + 6772, 6744, 6823, 6779, 6778, 6822, 6826, 6827, 6818, 6752, 6816, 6817, + 6821, 6773, 6774, 6829, 6753, 6755, 6767, 6769, 6754, 6763, 6764, 6771, + 6768, 6765, 6756, 6770, 6761, 6762, 6760, 6759, 6757, 6758, 6766, 43653, + 43651, 43649, 43661, 43659, 43679, 43677, 43671, 43669, 43657, 43665, + 43673, 43675, 43667, 43681, 43655, 43693, 43689, 43683, 43687, 43663, + 43691, 43685, 43695, 43652, 43650, 43648, 43660, 43658, 43678, 43676, + 43670, 43668, 43656, 43664, 43672, 43674, 43666, 43680, 43654, 43692, + 43688, 43682, 43686, 43662, 43690, 43684, 43694, 43696, 43703, 43743, + 43739, 43740, 43742, 43741, 43712, 43713, 43714, 43711, 43707, 43697, + 43710, 43709, 43708, 43700, 43699, 43705, 43706, 43698, 43704, 43701, + 43702, 124653, 124640, 124645, 124658, 124657, 124656, 124660, 124659, + 124632, 124610, 124637, 124608, 124617, 124628, 124634, 124625, 124620, + 124615, 124611, 124638, 124609, 124618, 124629, 124635, 124626, 124621, + 124616, 124613, 124623, 124644, 124642, 124650, 124651, 124627, 124622, + 124641, 124649, 124647, 124652, 124624, 124614, 124619, 124612, 124630, + 124636, 124633, 124631, 124648, 124655, 124646, 124654, 124643, 124661, + 124670, 124671, 71353, 71296, 71352, 71297, 71303, 71305, 71319, 71318, + 71324, 71323, 71338, 71332, 71317, 71316, 71322, 71321, 71300, 71301, + 71298, 71299, 71310, 71320, 71315, 71325, 71329, 71328, 71312, 71311, + 71309, 71308, 71314, 71313, 71307, 71306, 71327, 71326, 71335, 71336, + 71337, 71333, 71330, 71334, 71331, 71302, 71304, 71351, 71339, 71350, + 71340, 71341, 71347, 71349, 71344, 71345, 71342, 71343, 71346, 71348, + 71365, 71364, 71367, 71366, 71363, 71362, 71360, 71369, 71361, 71368, + 129377, 119672, 119671, 3064, 3031, 73707, 983662, 983685, 983674, + 983677, 983676, 983669, 983667, 983679, 983663, 983665, 983668, 983666, + 983683, 983681, 983682, 983673, 983678, 983664, 983684, 983680, 983671, + 983670, 983675, 983672, 73706, 3063, 73701, 3062, 3059, 3051, 3050, 3053, + 3052, 3049, 3048, 3046, 3055, 3047, 3054, 73700, 73666, 73676, 73668, + 73679, 73681, 73682, 73665, 73673, 73674, 73667, 73664, 73669, 73672, + 73675, 73680, 73670, 73678, 73671, 73677, 73683, 73684, 73710, 2985, + 2979, 2969, 2974, 2984, 2975, 2980, 2949, 2950, 2960, 2964, 2996, 2995, + 2994, 2993, 2992, 2953, 2954, 2962, 2963, 2951, 2952, 2998, 2999, 3000, + 2958, 2959, 2970, 3001, 2972, 2965, 2990, 2986, 2997, 2991, 73702, 3057, + 3058, 3056, 3066, 73727, 3065, 73703, 73687, 2946, 73686, 73698, 73690, + 73693, 73692, 73712, 73689, 73688, 73691, 73697, 73694, 73695, 73696, + 73713, 73699, 3021, 2947, 73685, 73708, 73711, 983939, 983940, 983947, + 983950, 983943, 983944, 983948, 983949, 983941, 983942, 983945, 983946, + 983686, 983693, 983696, 983689, 983690, 983694, 983695, 983687, 983688, + 983691, 983692, 983840, 983847, 983850, 983843, 983844, 983848, 983849, + 983841, 983842, 983845, 983846, 983851, 983858, 983861, 983854, 983855, + 983859, 983860, 983852, 983853, 983856, 983857, 983818, 983825, 983828, + 983821, 983822, 983826, 983827, 983819, 983820, 983823, 983824, 983873, + 983880, 983883, 983876, 983877, 983881, 983882, 983874, 983875, 983878, + 983879, 983741, 983748, 983751, 983744, 983745, 983749, 983750, 983742, + 983743, 983746, 983747, 983697, 983704, 983707, 983700, 983701, 983705, + 983706, 983698, 983699, 983702, 983703, 983719, 983726, 983729, 983722, + 983723, 983727, 983728, 983720, 983721, 983724, 983725, 983763, 983770, + 983773, 983766, 983767, 983771, 983772, 983764, 983765, 983768, 983769, + 983862, 983869, 983872, 983865, 983866, 983870, 983871, 983863, 983864, + 983867, 983868, 983807, 983814, 983817, 983810, 983811, 983815, 983816, + 983808, 983809, 983812, 983813, 983895, 983902, 983905, 983898, 983899, + 983903, 983904, 983951, 983896, 983897, 983900, 983901, 983906, 983913, + 983916, 983909, 983910, 983914, 983915, 983907, 983908, 983911, 983912, + 983917, 983924, 983927, 983920, 983921, 983925, 983926, 983918, 983919, + 983922, 983923, 983730, 983737, 983740, 983733, 983734, 983738, 983739, + 983731, 983732, 983735, 983736, 983752, 983759, 983762, 983755, 983756, + 983760, 983761, 983753, 983754, 983757, 983758, 983708, 983715, 983718, + 983711, 983712, 983716, 983717, 983709, 983710, 983713, 983714, 983928, + 983935, 983938, 983931, 983932, 983936, 983937, 983929, 983930, 983933, + 983934, 983884, 983891, 983894, 983887, 983888, 983892, 983893, 983885, + 983886, 983889, 983890, 983785, 983792, 983795, 983788, 983789, 983793, + 983794, 983786, 983787, 983790, 983791, 983774, 983781, 983784, 983777, + 983778, 983782, 983783, 983775, 983776, 983779, 983780, 983829, 983836, + 983839, 983832, 983833, 983837, 983838, 983830, 983831, 983834, 983835, + 983796, 983803, 983806, 983799, 983800, 983804, 983805, 983797, 983798, + 983801, 983802, 73709, 73704, 73705, 3006, 3016, 3020, 3009, 3010, 3018, + 3019, 3007, 3008, 3014, 3015, 3061, 3060, 3024, 129748, 127883, 127818, + 92809, 92810, 92811, 92808, 92789, 92790, 92791, 92788, 92816, 92859, + 92856, 92847, 92845, 92817, 92846, 92843, 92829, 92830, 92831, 92828, + 92835, 92851, 92840, 92844, 92818, 92819, 92852, 92836, 92825, 92826, + 92827, 92824, 92813, 92814, 92815, 92812, 92820, 92822, 92823, 92821, + 92805, 92806, 92807, 92804, 92797, 92798, 92799, 92796, 92801, 92802, + 92803, 92800, 92785, 92786, 92787, 92784, 92793, 92794, 92795, 92792, + 92857, 92854, 92848, 92861, 92853, 92860, 92849, 92855, 92834, 92833, + 92832, 92841, 92839, 92842, 92850, 92838, 92858, 92837, 92862, 92869, + 92868, 92871, 92870, 92867, 92866, 92864, 92873, 92865, 92872, 100352, + 100353, 100354, 100355, 100356, 100357, 100358, 100359, 100360, 100361, + 100362, 100363, 100364, 100365, 100366, 100367, 100368, 100369, 100370, + 100371, 100372, 100373, 100374, 100375, 100376, 100377, 100378, 100379, + 100380, 100381, 100382, 100383, 100384, 100385, 100386, 100387, 100388, + 100389, 100390, 100391, 100392, 100393, 100394, 100395, 100396, 100397, + 100398, 100399, 100400, 100401, 100402, 100403, 100404, 100405, 100406, + 100407, 100408, 100409, 100410, 100411, 100412, 100413, 100414, 100415, + 100416, 100417, 100418, 100419, 100420, 100421, 100422, 100423, 100424, + 100425, 100426, 100427, 100428, 100429, 100430, 100431, 100432, 100433, + 100434, 100435, 100436, 100437, 100438, 100439, 100440, 100441, 100442, + 100443, 100444, 100445, 100446, 100447, 100448, 100449, 100450, 100451, + 100452, 100453, 100454, 100455, 100456, 100457, 100458, 100459, 100460, + 100461, 100462, 100463, 100464, 100465, 100466, 100467, 100468, 100469, + 100470, 100471, 100472, 100473, 100474, 100475, 100476, 100477, 100478, + 100479, 100480, 100481, 100482, 100483, 100484, 100485, 100486, 100487, + 100488, 100489, 100490, 100491, 100492, 100493, 100494, 100495, 100496, + 100497, 100498, 100499, 100500, 100501, 100502, 100503, 100504, 100505, + 100506, 100507, 100508, 100509, 100510, 100511, 100512, 100513, 100514, + 100515, 100516, 100517, 100518, 100519, 100520, 100521, 100522, 100523, + 100524, 100525, 100526, 100527, 100528, 100529, 100530, 100531, 100532, + 100533, 100534, 100535, 100536, 100537, 100538, 100539, 100540, 100541, + 100542, 100543, 100544, 100545, 100546, 100547, 100548, 100549, 100550, + 100551, 100552, 100553, 100554, 100555, 100556, 100557, 100558, 100559, + 100560, 100561, 100562, 100563, 100564, 100565, 100566, 100567, 100568, + 100569, 100570, 100571, 100572, 100573, 100574, 100575, 100576, 100577, + 100578, 100579, 100580, 100581, 100582, 100583, 100584, 100585, 100586, + 100587, 100588, 100589, 100590, 100591, 100592, 100593, 100594, 100595, + 100596, 100597, 100598, 100599, 100600, 100601, 100602, 100603, 100604, + 100605, 100606, 100607, 100608, 100609, 100610, 100611, 100612, 100613, + 100614, 100615, 100616, 100617, 100618, 100619, 100620, 100621, 100622, + 100623, 100624, 100625, 100626, 100627, 100628, 100629, 100630, 100631, + 100632, 100633, 100634, 100635, 100636, 100637, 100638, 100639, 100640, + 100641, 100642, 100643, 100644, 100645, 100646, 100647, 100648, 100649, + 100650, 100651, 100652, 100653, 100654, 100655, 100656, 100657, 100658, + 100659, 100660, 100661, 100662, 100663, 100664, 100665, 100666, 100667, + 100668, 100669, 100670, 100671, 100672, 100673, 100674, 100675, 100676, + 100677, 100678, 100679, 100680, 100681, 100682, 100683, 100684, 100685, + 100686, 100687, 100688, 100689, 100690, 100691, 100692, 100693, 100694, + 100695, 100696, 100697, 100698, 100699, 100700, 100701, 100702, 100703, + 100704, 100705, 100706, 100707, 100708, 100709, 100710, 100711, 100712, + 100713, 100714, 100715, 100716, 100717, 100718, 100719, 100720, 100721, + 100722, 100723, 100724, 100725, 100726, 100727, 100728, 100729, 100730, + 100731, 100732, 100733, 100734, 100735, 100736, 100737, 100738, 100739, + 100740, 100741, 100742, 100743, 100744, 100745, 100746, 100747, 100748, + 100749, 100750, 100751, 100752, 100753, 100754, 100755, 100756, 100757, + 100758, 100759, 100760, 100761, 100762, 100763, 100764, 100765, 100766, + 100767, 100768, 100769, 100770, 100771, 100772, 100773, 100774, 100775, + 100776, 100777, 100778, 100779, 100780, 100781, 100782, 100783, 100784, + 100785, 100786, 100787, 100788, 100789, 100790, 100791, 100792, 100793, + 100794, 100795, 100796, 100797, 100798, 100799, 100800, 100801, 100802, + 100803, 100804, 100805, 100806, 100807, 100808, 100809, 100810, 100811, + 100812, 100813, 100814, 100815, 100816, 100817, 100818, 100819, 100820, + 100821, 100822, 100823, 100824, 100825, 100826, 100827, 100828, 100829, + 100830, 100831, 100832, 100833, 100834, 100835, 100836, 100837, 100838, + 100839, 100840, 100841, 100842, 100843, 100844, 100845, 100846, 100847, + 100848, 100849, 100850, 100851, 100852, 100853, 100854, 100855, 100856, + 100857, 100858, 100859, 100860, 100861, 100862, 100863, 100864, 100865, + 100866, 100867, 100868, 100869, 100870, 100871, 100872, 100873, 100874, + 100875, 100876, 100877, 100878, 100879, 100880, 100881, 100882, 100883, + 100884, 100885, 100886, 100887, 100888, 100889, 100890, 100891, 100892, + 100893, 100894, 100895, 100896, 100897, 100898, 100899, 100900, 100901, + 100902, 100903, 100904, 100905, 100906, 100907, 100908, 100909, 100910, + 100911, 100912, 100913, 100914, 100915, 100916, 100917, 100918, 100919, + 100920, 100921, 100922, 100923, 100924, 100925, 100926, 100927, 100928, + 100929, 100930, 100931, 100932, 100933, 100934, 100935, 100936, 100937, + 100938, 100939, 100940, 100941, 100942, 100943, 100944, 100945, 100946, + 100947, 100948, 100949, 100950, 100951, 100952, 100953, 100954, 100955, + 100956, 100957, 100958, 100959, 100960, 100961, 100962, 100963, 100964, + 100965, 100966, 100967, 100968, 100969, 100970, 100971, 100972, 100973, + 100974, 100975, 100976, 100977, 100978, 100979, 100980, 100981, 100982, + 100983, 100984, 100985, 100986, 100987, 100988, 100989, 100990, 100991, + 100992, 100993, 100994, 100995, 100996, 100997, 100998, 100999, 101000, + 101001, 101002, 101003, 101004, 101005, 101006, 101007, 101008, 101009, + 101010, 101011, 101012, 101013, 101014, 101015, 101016, 101017, 101018, + 101019, 101020, 101021, 101022, 101023, 101024, 101025, 101026, 101027, + 101028, 101029, 101030, 101031, 101032, 101033, 101034, 101035, 101036, + 101037, 101038, 101039, 101040, 101041, 101042, 101043, 101044, 101045, + 101046, 101047, 101048, 101049, 101050, 101051, 101052, 101053, 101054, + 101055, 101056, 101057, 101058, 101059, 101060, 101061, 101062, 101063, + 101064, 101065, 101066, 101067, 101068, 101069, 101070, 101071, 101072, + 101073, 101074, 101075, 101076, 101077, 101078, 101079, 101080, 101081, + 101082, 101083, 101084, 101085, 101086, 101087, 101088, 101089, 101090, + 101091, 101092, 101093, 101094, 101095, 101096, 101097, 101098, 101099, + 101100, 101101, 101102, 101103, 101104, 101105, 101106, 101107, 101108, + 101109, 101110, 101111, 101112, 101113, 101114, 101115, 101116, 101117, + 101118, 101119, 101760, 101761, 101762, 101763, 101764, 101765, 101766, + 101767, 101768, 101769, 101770, 101771, 101772, 101773, 101774, 101775, + 101776, 101777, 101778, 101779, 101780, 101781, 101782, 101783, 101784, + 101785, 101786, 101787, 101788, 101789, 101790, 101791, 101792, 101793, + 101794, 101795, 101796, 101797, 101798, 101799, 101800, 101801, 101802, + 101803, 101804, 101805, 101806, 101807, 101808, 101809, 101810, 101811, + 101812, 101813, 101814, 101815, 101816, 101817, 101818, 101819, 101820, + 101821, 101822, 101823, 101824, 101825, 101826, 101827, 101828, 101829, + 101830, 101831, 101832, 101833, 101834, 101835, 101836, 101837, 101838, + 101839, 101840, 101841, 101842, 101843, 101844, 101845, 101846, 101847, + 101848, 101849, 101850, 101851, 101852, 101853, 101854, 101855, 101856, + 101857, 101858, 101859, 101860, 101861, 101862, 101863, 101864, 101865, + 101866, 101867, 101868, 101869, 101870, 101871, 101872, 101873, 101874, + 94176, 128429, 9991, 9801, 127790, 128661, 127861, 128198, 10043, 10170, + 129750, 129528, 128222, 128380, 8981, 9990, 8481, 128384, 128301, 128250, + 3164, 3158, 3195, 3198, 3194, 3197, 3193, 3196, 3192, 3106, 3105, 3111, + 3161, 3110, 3112, 3165, 3097, 3107, 3102, 3162, 3121, 3120, 3104, 3103, + 3109, 3160, 3108, 3077, 3078, 3088, 3092, 3124, 3123, 3122, 3083, 3168, + 3084, 3169, 3125, 3081, 3082, 3090, 3091, 3079, 3080, 3126, 3127, 3128, + 3117, 3116, 3099, 3098, 3096, 3095, 3101, 3100, 3094, 3093, 3115, 3114, + 3086, 3087, 3129, 3118, 3119, 3157, 3076, 3072, 3073, 3191, 3199, 3132, + 3133, 3074, 3149, 3075, 3134, 3144, 3148, 3137, 3138, 3139, 3140, 3170, + 3171, 3146, 3147, 3135, 3136, 3142, 3143, 3179, 3178, 3181, 3180, 3177, + 3176, 3174, 3183, 3175, 3182, 127934, 8376, 9978, 119617, 119564, 119577, 119633, 119587, 119566, 119561, 119585, 119613, 119590, 119631, 119634, 119630, 119608, 119582, 119563, 119573, 119558, 119624, 119567, 119623, 119586, 119636, 119612, 119625, 119568, 119584, 119619, 119618, 119583, @@ -12378,432 +12676,433 @@ static const unsigned int dawg_pos_to_codepoint[] = { 119569, 119570, 119622, 119562, 119591, 119637, 119597, 119589, 119616, 119609, 119560, 119635, 119565, 119604, 119588, 119571, 119594, 119578, 119596, 119579, 119598, 119572, 119605, 119627, 119621, 119628, 119601, - 119593, 119607, 119575, 119620, 119611, 119581, 1959, 1958, 1964, 1961, - 1965, 1927, 1954, 1951, 1937, 1931, 1930, 1956, 1934, 1935, 1955, 1945, - 1920, 1926, 1946, 1933, 1925, 1929, 1943, 1942, 1941, 1922, 1969, 1950, - 1949, 1921, 1936, 1939, 1932, 1947, 1944, 1952, 1928, 1957, 1938, 1948, - 1953, 1924, 1923, 1940, 1967, 1966, 1963, 1960, 1962, 1968, 3610, 3592, - 3594, 3593, 3596, 3598, 3604, 3613, 3615, 3663, 3630, 3627, 3588, 3587, - 3589, 3586, 3590, 3675, 3585, 3628, 3621, 3653, 3622, 3659, 3633, 3657, - 3658, 3656, 3655, 3654, 3617, 3674, 3591, 3661, 3603, 3609, 3631, 3642, - 3612, 3614, 3616, 3611, 3619, 3620, 3632, 3652, 3651, 3634, 3649, 3635, - 3640, 3638, 3639, 3641, 3636, 3637, 3648, 3650, 3625, 3624, 3626, 3595, - 3660, 3601, 3602, 3607, 3600, 3608, 3606, 3605, 3599, 3623, 3662, 3597, - 3618, 3629, 3647, 3669, 3668, 3671, 3670, 3667, 3666, 3664, 3673, 3665, - 3672, 8708, 8707, 8756, 127777, 10727, 118474, 128936, 8201, 128929, - 129300, 129353, 128173, 129652, 10176, 8278, 9887, 9886, 11057, 128485, - 128484, 128486, 128487, 8694, 128433, 10870, 128491, 128962, 128423, - 11160, 11162, 10146, 11163, 11161, 10147, 8196, 11835, 128077, 128078, - 9928, 9736, 3865, 3863, 3864, 4035, 4032, 4033, 4034, 3886, 3885, 3888, - 3887, 3884, 3883, 3891, 3890, 3882, 3889, 3877, 3876, 3879, 3878, 3875, - 3874, 3872, 3881, 3873, 3880, 4030, 4031, 3945, 3905, 3947, 3904, 3948, - 3938, 3946, 3917, 3916, 3932, 3931, 3922, 3921, 3908, 3918, 3913, 3923, - 3940, 3941, 3942, 3930, 3929, 3915, 3914, 3920, 3919, 3927, 3926, 3910, - 3909, 3907, 3906, 3925, 3924, 3934, 3935, 3936, 3943, 3911, 3939, 3928, - 3933, 3937, 3944, 3862, 3861, 983210, 3850, 4048, 3849, 3892, 4049, 3894, - 3859, 3846, 3896, 4052, 3845, 3847, 3842, 3843, 3841, 3860, 3898, 3899, - 3900, 3901, 3972, 4051, 3844, 3851, 3895, 3893, 4050, 3856, 3854, 3858, - 3857, 3848, 3853, 4058, 3897, 3855, 4057, 3973, 3852, 3978, 3979, 3974, - 3976, 3903, 3977, 3970, 3866, 3867, 3868, 3871, 3869, 3870, 4047, 4046, - 3966, 3967, 3975, 3902, 3980, 3971, 4028, 4026, 4027, 3997, 3996, 4012, - 4011, 4002, 4001, 4025, 3985, 3984, 3988, 3998, 3993, 4003, 4020, 4021, - 4022, 4010, 4009, 3995, 3994, 4000, 3999, 4007, 4006, 3990, 3989, 3987, - 3986, 4005, 4004, 4014, 4015, 4016, 4023, 3991, 4019, 4008, 4018, 4013, - 4017, 4024, 3983, 3982, 3981, 3840, 4036, 4041, 4044, 4043, 4042, 4038, - 4040, 4037, 4039, 3968, 3969, 3956, 3957, 3958, 3959, 3960, 3961, 3964, - 3965, 3954, 3955, 3962, 3963, 3953, 10717, 11647, 11608, 11595, 11585, - 11573, 11620, 11607, 11600, 11582, 11590, 11596, 11601, 11586, 11592, - 11568, 11571, 11606, 11572, 11581, 11589, 11583, 11609, 11611, 11610, - 11612, 11613, 11615, 11619, 11594, 11621, 11575, 11577, 11578, 11576, - 11569, 11570, 11584, 11587, 11604, 11605, 11614, 11588, 11580, 11574, - 11597, 11598, 11599, 11602, 11591, 11616, 11617, 11618, 11622, 11579, - 11593, 11623, 11603, 11631, 11632, 128005, 128047, 10053, 126, 8764, - 11081, 10610, 10859, 10858, 11807, 11806, 11803, 9202, 10708, 10709, - 10750, 68410, 70854, 70784, 70785, 70786, 70796, 70798, 70812, 70811, - 70817, 70816, 70810, 70809, 70815, 70814, 70791, 70792, 70793, 70794, - 70827, 70789, 70790, 70787, 70788, 70803, 70813, 70808, 70818, 70828, - 70829, 70830, 70822, 70821, 70805, 70804, 70802, 70801, 70807, 70806, - 70800, 70799, 70820, 70819, 70831, 70826, 70823, 70825, 70824, 70795, - 70797, 70847, 70851, 70852, 70848, 70850, 70849, 70842, 70845, 70832, - 70843, 70846, 70835, 70836, 70837, 70838, 70839, 70840, 70833, 70834, - 70841, 70844, 70869, 70868, 70871, 70870, 70867, 70866, 70864, 70873, - 70865, 70872, 70853, 70855, 11858, 8266, 128555, 127915, 67054, 67022, - 67020, 67027, 67051, 67011, 67031, 67023, 67021, 67033, 67049, 67047, - 67015, 67032, 67025, 67024, 67058, 67035, 67041, 67040, 67056, 67055, - 67039, 67038, 67037, 67034, 67059, 67018, 67017, 67030, 67029, 67008, - 67009, 67013, 67012, 67016, 67014, 67057, 67028, 67043, 67042, 67048, - 67046, 67053, 67052, 67010, 67019, 67036, 67045, 67026, 67044, 67050, - 73140, 73141, 73149, 73154, 73155, 73150, 73151, 73156, 73171, 73166, - 73161, 73168, 73175, 73176, 73147, 73152, 73153, 73148, 73144, 73145, - 73157, 73158, 73164, 73165, 73159, 73160, 73162, 73163, 73142, 73143, - 73137, 73173, 73136, 73169, 73146, 73139, 73172, 73138, 73170, 73174, - 73167, 73177, 73178, 73179, 73189, 73188, 73191, 73190, 73187, 73186, - 73184, 73193, 73185, 73192, 127813, 128069, 129463, 129701, 129520, - 10554, 10557, 10556, 9182, 118256, 117851, 118262, 118263, 11865, 117850, - 118252, 118254, 11866, 117852, 118248, 118250, 11833, 118246, 11210, - 8992, 127913, 9180, 130024, 130016, 130031, 8988, 8975, 11810, 118279, - 8989, 8974, 11811, 130028, 9140, 9184, 128285, 127553, 127554, 127559, - 127555, 127557, 127560, 127552, 127556, 127558, 127274, 9008, 123554, - 123556, 123559, 123561, 123564, 123537, 123544, 123543, 123553, 123555, - 123558, 123560, 123546, 123565, 123563, 123539, 123541, 123550, 123549, - 123540, 123552, 123542, 123536, 123551, 123545, 123538, 123548, 123547, - 123562, 123557, 123566, 128701, 128508, 128434, 128668, 8482, 128650, - 128651, 11223, 10971, 128646, 129678, 118460, 10701, 10699, 128710, - 10698, 10141, 128681, 128208, 8227, 128305, 9783, 9776, 9777, 9782, 9779, - 9781, 9780, 9778, 10998, 10856, 10857, 10747, 8244, 8779, 10996, 10624, - 8874, 10997, 11003, 11851, 11000, 10999, 8749, 8285, 129484, 128654, - 129674, 127865, 128032, 127942, 8872, 11231, 127930, 8366, 70601, 70608, - 70613, 70612, 70610, 70528, 70529, 70542, 70545, 70559, 70558, 70564, - 70563, 70581, 70579, 70573, 70580, 70572, 70557, 70556, 70562, 70561, - 70534, 70535, 70536, 70537, 70574, 70532, 70533, 70530, 70531, 70550, - 70560, 70555, 70565, 70575, 70576, 70577, 70569, 70568, 70552, 70551, - 70549, 70548, 70554, 70553, 70547, 70546, 70567, 70566, 70544, 70539, - 70578, 70570, 70571, 70609, 70583, 70604, 70607, 70615, 70616, 70602, - 70611, 70606, 70605, 70626, 70625, 70584, 70597, 70600, 70587, 70588, - 70589, 70590, 70591, 70592, 70585, 70586, 70599, 70594, 127799, 8378, - 129411, 8523, 10658, 11202, 9930, 9929, 8498, 11826, 11832, 8587, 8586, - 128598, 128596, 8985, 128399, 8513, 8514, 8516, 11829, 8526, 128599, - 128597, 8489, 128034, 129347, 10041, 128256, 128432, 10869, 8229, 8282, - 11818, 128149, 10837, 10838, 10697, 10760, 10759, 128108, 128109, 117896, - 8273, 128490, 11834, 66432, 66451, 66454, 66433, 66436, 66447, 66457, - 66434, 66437, 66440, 66443, 66435, 66445, 66455, 66453, 66450, 66444, - 66461, 66456, 66441, 66458, 66442, 66439, 66449, 66448, 66452, 66438, - 66446, 66459, 66460, 66463, 9730, 9969, 9748, 128530, 11217, 8255, 9100, - 8746, 10824, 10822, 10826, 10817, 10818, 10821, 983116, 11258, 9842, - 129412, 9903, 8963, 8996, 11193, 10685, 10577, 10573, 10572, 10575, 8597, - 8616, 11021, 8661, 129113, 8691, 11109, 10622, 8944, 8869, 10207, 117873, - 117877, 117857, 128743, 117881, 118267, 128742, 117847, 128314, 117912, - 117862, 128744, 128316, 9709, 9710, 117760, 129898, 129946, 129920, - 129896, 9985, 118417, 117809, 118418, 117810, 130020, 129924, 9600, - 129937, 118275, 129938, 9690, 118292, 129934, 118439, 118444, 9696, - 129885, 129887, 129889, 129886, 129883, 129888, 129881, 129884, 129882, - 129879, 129880, 10196, 118416, 9136, 129944, 129948, 9720, 117808, 9692, - 117958, 117946, 117962, 117966, 117950, 117954, 117928, 117926, 117942, - 117970, 117938, 117813, 118421, 118422, 118420, 117812, 118423, 117815, - 129922, 9620, 129874, 129875, 129892, 129894, 129890, 129878, 129893, - 129891, 129876, 129895, 129877, 10064, 118419, 9137, 10000, 9693, 117959, - 117947, 117963, 117967, 117951, 117955, 117929, 117927, 117943, 117971, - 117939, 117814, 128319, 10066, 129945, 129949, 9721, 117811, 129926, - 129923, 118438, 118445, 129925, 129901, 128579, 11797, 8593, 129976, - 8645, 8670, 129033, 129029, 129177, 129041, 129025, 129045, 8624, 8625, - 10505, 8613, 10514, 11145, 11014, 8657, 8673, 129077, 10606, 10595, - 10592, 10584, 8639, 10588, 10580, 8638, 129089, 129093, 129085, 10224, - 128621, 129105, 129081, 11105, 11137, 11121, 129065, 11170, 11171, - 129061, 129057, 129073, 129069, 11131, 11115, 11141, 129169, 10506, 8607, - 11245, 10569, 8648, 8679, 8683, 8685, 8684, 129173, 8682, 11192, 8686, - 8687, 9797, 983117, 42509, 42510, 42511, 42446, 42370, 42486, 42257, - 42333, 42294, 42407, 42445, 42369, 42485, 42256, 42332, 42293, 42406, - 42449, 42373, 42489, 42260, 42336, 42297, 42410, 42434, 42359, 42473, - 42246, 42321, 42283, 42396, 42435, 42360, 42474, 42247, 42322, 42284, - 42397, 42452, 42376, 42492, 42263, 42339, 42300, 42413, 42451, 42375, - 42491, 42262, 42338, 42299, 42412, 42444, 42368, 42484, 42255, 42331, - 42292, 42405, 42443, 42367, 42483, 42254, 42330, 42291, 42404, 42454, - 42378, 42494, 42265, 42341, 42302, 42415, 42453, 42377, 42493, 42264, - 42340, 42301, 42414, 42439, 42440, 42364, 42479, 42251, 42480, 42327, - 42288, 42401, 42502, 42272, 42503, 42461, 42385, 42349, 42309, 42422, - 42429, 42430, 42355, 42468, 42242, 42469, 42316, 42317, 42278, 42279, - 42391, 42392, 42476, 42249, 42477, 42437, 42362, 42324, 42325, 42286, - 42399, 42459, 42383, 42346, 42347, 42499, 42270, 42307, 42420, 42487, - 42508, 42258, 42447, 42371, 42334, 42295, 42408, 42436, 42361, 42475, - 42248, 42323, 42285, 42398, 42438, 42363, 42478, 42250, 42326, 42287, - 42400, 42462, 42386, 42504, 42273, 42350, 42310, 42423, 42450, 42514, - 42539, 42512, 42513, 42538, 42374, 42490, 42261, 42337, 42298, 42411, - 42507, 42500, 42271, 42501, 42460, 42384, 42348, 42308, 42421, 42315, - 42467, 42428, 42457, 42381, 42497, 42268, 42344, 42305, 42418, 42464, - 42388, 42506, 42275, 42352, 42312, 42425, 42463, 42387, 42505, 42274, - 42351, 42311, 42424, 42455, 42379, 42495, 42266, 42342, 42303, 42416, - 42441, 42365, 42481, 42252, 42328, 42289, 42402, 42456, 42380, 42496, - 42267, 42343, 42304, 42417, 42433, 42358, 42472, 42245, 42320, 42282, - 42395, 42448, 42372, 42488, 42259, 42335, 42296, 42409, 42442, 42366, - 42482, 42253, 42329, 42290, 42403, 42458, 42382, 42498, 42269, 42345, - 42306, 42419, 42470, 42243, 42244, 42471, 42431, 42356, 42357, 42432, - 42318, 42319, 42280, 42281, 42393, 42394, 42465, 42240, 42241, 42466, - 42426, 42353, 42354, 42427, 42313, 42314, 42276, 42277, 42389, 42390, - 42523, 42526, 42522, 42515, 42520, 42527, 42516, 42524, 42518, 42517, - 42525, 42521, 42519, 42533, 42532, 42535, 42534, 42531, 42530, 42528, - 42537, 42529, 42536, 65024, 65033, 917843, 917844, 917845, 917846, - 917847, 917848, 917849, 917850, 917851, 917852, 65034, 917853, 917854, - 917855, 917856, 917857, 917858, 917859, 917860, 917861, 917862, 65035, - 917863, 917864, 917865, 917866, 917867, 917868, 917869, 917870, 917871, - 917872, 65036, 917873, 917874, 917875, 917876, 917877, 917878, 917879, - 917880, 917881, 917882, 65037, 917883, 917884, 917885, 917886, 917887, - 917888, 917889, 917890, 917891, 917892, 65038, 917893, 917894, 917895, - 917896, 917897, 917898, 917899, 917900, 917901, 917902, 65039, 917903, - 917904, 917905, 917906, 917907, 917908, 917909, 917910, 917911, 917912, - 917760, 917913, 917914, 917915, 917916, 917917, 917918, 917919, 917920, - 917921, 917922, 917761, 917923, 917924, 917925, 917926, 917927, 917928, - 917929, 917930, 917931, 917932, 917762, 917933, 917934, 917935, 917936, - 917937, 917938, 917939, 917940, 917941, 917942, 65025, 917763, 917943, - 917944, 917945, 917946, 917947, 917948, 917949, 917950, 917951, 917952, - 917764, 917953, 917954, 917955, 917956, 917957, 917958, 917959, 917960, - 917961, 917962, 917765, 917963, 917964, 917965, 917966, 917967, 917968, - 917969, 917970, 917971, 917972, 917766, 917973, 917974, 917975, 917976, - 917977, 917978, 917979, 917980, 917981, 917982, 917767, 917983, 917984, - 917985, 917986, 917987, 917988, 917989, 917990, 917991, 917992, 917768, - 917993, 917994, 917995, 917996, 917997, 917998, 917999, 917769, 917770, - 917771, 917772, 65026, 917773, 917774, 917775, 917776, 917777, 917778, - 917779, 917780, 917781, 917782, 65027, 917783, 917784, 917785, 917786, - 917787, 917788, 917789, 917790, 917791, 917792, 65028, 917793, 917794, - 917795, 917796, 917797, 917798, 917799, 917800, 917801, 917802, 65029, - 917803, 917804, 917805, 917806, 917807, 917808, 917809, 917810, 917811, - 917812, 65030, 917813, 917814, 917815, 917816, 917817, 917818, 917819, - 917820, 917821, 917822, 65031, 917823, 917824, 917825, 917826, 917827, - 917828, 917829, 917830, 917831, 917832, 65032, 917833, 917834, 917835, - 917836, 917837, 917838, 917839, 917840, 917841, 917842, 129499, 983245, - 983254, 983364, 983365, 983366, 983367, 983368, 983369, 983370, 983371, - 983372, 983373, 983255, 983374, 983375, 983376, 983377, 983378, 983379, - 983380, 983381, 983382, 983383, 983256, 983384, 983385, 983386, 983387, - 983388, 983389, 983390, 983391, 983392, 983393, 983257, 983394, 983395, - 983396, 983397, 983398, 983399, 983400, 983401, 983402, 983403, 983258, - 983404, 983405, 983406, 983407, 983408, 983409, 983410, 983411, 983412, - 983413, 983259, 983414, 983415, 983416, 983417, 983418, 983419, 983420, - 983421, 983422, 983423, 983260, 983424, 983425, 983426, 983427, 983428, - 983429, 983430, 983431, 983432, 983433, 983281, 983434, 983435, 983436, - 983437, 983438, 983439, 983440, 983441, 983442, 983443, 983282, 983444, - 983445, 983446, 983447, 983448, 983449, 983450, 983451, 983452, 983453, - 983283, 983454, 983455, 983456, 983457, 983458, 983459, 983460, 983461, - 983462, 983463, 983246, 983284, 983464, 983465, 983466, 983467, 983468, - 983469, 983470, 983471, 983472, 983473, 983285, 983474, 983475, 983476, - 983477, 983478, 983479, 983480, 983481, 983482, 983483, 983286, 983484, - 983485, 983486, 983487, 983488, 983489, 983490, 983491, 983492, 983493, - 983287, 983494, 983495, 983496, 983497, 983498, 983499, 983500, 983501, - 983502, 983503, 983288, 983504, 983505, 983506, 983507, 983508, 983509, - 983510, 983511, 983512, 983513, 983289, 983514, 983515, 983516, 983517, - 983518, 983519, 983520, 983290, 983291, 983292, 983293, 983247, 983294, - 983295, 983296, 983297, 983298, 983299, 983300, 983301, 983302, 983303, - 983248, 983304, 983305, 983306, 983307, 983308, 983309, 983310, 983311, - 983312, 983313, 983249, 983314, 983315, 983316, 983317, 983318, 983319, - 983320, 983321, 983322, 983323, 983250, 983324, 983325, 983326, 983327, - 983328, 983329, 983330, 983331, 983332, 983333, 983251, 983334, 983335, - 983336, 983337, 983338, 983339, 983340, 983341, 983342, 983343, 983252, - 983344, 983345, 983346, 983347, 983348, 983349, 983350, 983351, 983352, - 983353, 983253, 983354, 983355, 983356, 983357, 983358, 983359, 983360, - 983361, 983362, 983363, 7401, 7402, 7409, 7403, 7404, 7415, 7410, 7418, - 7413, 7379, 7398, 7396, 7411, 7408, 7406, 7407, 7405, 7414, 7397, 7400, - 7395, 7399, 7394, 7380, 7384, 7412, 7417, 7386, 7389, 7376, 7388, 7378, - 7416, 7392, 7391, 7387, 7390, 7381, 7382, 7383, 7385, 7393, 7377, 8483, - 10704, 10980, 10978, 10186, 117780, 8942, 8286, 117917, 12347, 12337, - 12339, 12341, 12338, 12340, 117892, 124, 9168, 10992, 10991, 117904, - 118293, 9087, 9896, 129904, 129905, 129906, 129907, 129908, 129909, - 117916, 117770, 11135, 983069, 983144, 11823, 128678, 10650, 11837, - 128976, 128959, 128947, 128637, 128941, 128953, 128636, 128904, 128914, - 128934, 8921, 8920, 128933, 9910, 128887, 10799, 128243, 9996, 118469, - 128249, 127918, 128252, 94193, 94192, 8983, 127931, 9805, 66929, 66930, - 66936, 66935, 66942, 66943, 66947, 66946, 66950, 66949, 66932, 66931, - 66934, 66933, 66957, 66956, 66959, 66958, 66941, 66940, 66937, 66944, - 66948, 66952, 66954, 66961, 66962, 66965, 66938, 66945, 66953, 66928, - 66951, 66960, 66964, 66968, 66969, 66975, 66974, 66981, 66982, 66986, - 66985, 66989, 66988, 66971, 66970, 66973, 66972, 66996, 66995, 66998, - 66997, 66980, 66979, 66976, 66983, 66987, 66991, 66993, 67000, 67001, - 67004, 66977, 66984, 66992, 66967, 66990, 66999, 67003, 129979, 127755, - 127952, 8752, 983070, 983145, 11238, 8541, 8538, 8536, 8539, 8533, 189, - 8529, 188, 8528, 8537, 8530, 8531, 8540, 190, 8535, 8534, 8532, 8542, - 8585, 129479, 123585, 123584, 123624, 123619, 123620, 123606, 123605, - 123622, 123618, 123611, 123623, 123612, 123621, 123615, 123592, 123613, - 123625, 123593, 123596, 123617, 123616, 123595, 123614, 123626, 123627, - 123590, 123609, 123604, 123591, 123594, 123599, 123598, 123586, 123587, - 123588, 123597, 123589, 123610, 123600, 123608, 123607, 123603, 123602, - 123601, 123647, 123630, 123631, 123628, 123629, 123637, 123636, 123639, - 123638, 123635, 123634, 123632, 123641, 123633, 123640, 127768, 127766, - 127762, 127764, 71841, 71850, 71862, 71861, 71848, 71856, 71853, 71867, - 71866, 71865, 71868, 71840, 71859, 71849, 71857, 71869, 71870, 71855, - 71847, 71843, 71854, 71844, 71845, 71858, 71871, 71863, 71864, 71852, - 71846, 71842, 71860, 71851, 71873, 71882, 71894, 71893, 71880, 71888, - 71885, 71899, 71898, 71897, 71900, 71872, 71891, 71881, 71889, 71901, - 71902, 71887, 71879, 71875, 71886, 71876, 71877, 71890, 71903, 71895, - 71896, 71884, 71878, 71874, 71892, 71883, 71909, 71908, 71911, 71910, - 71907, 71906, 71904, 71913, 71905, 71912, 71921, 71918, 71917, 71922, - 71920, 71919, 71916, 71915, 71914, 71935, 9888, 128702, 127754, 128003, - 129341, 127817, 8986, 12316, 11071, 10547, 127988, 127987, 128075, 12336, - 65103, 8967, 65099, 128465, 128576, 128553, 10172, 128146, 983238, - 127947, 9840, 128734, 9784, 9855, 129197, 129196, 9702, 129621, 9815, - 129548, 129590, 129608, 129611, 129620, 9812, 129545, 129587, 9816, - 129542, 129563, 129584, 129591, 129605, 129549, 129616, 129614, 129615, - 9817, 129550, 129592, 9813, 129546, 129588, 9814, 129547, 129589, 129569, - 129566, 129570, 129571, 129567, 129568, 9675, 128906, 9862, 10732, 9863, - 9717, 9718, 9716, 9719, 9831, 10209, 10210, 10211, 129995, 9671, 9672, - 128922, 128923, 10192, 9826, 9931, 128071, 128407, 9759, 9663, 9661, + 119593, 119607, 119575, 119620, 119611, 119581, 129514, 1959, 1958, 1964, + 1961, 1965, 1927, 1954, 1951, 1937, 1931, 1930, 1956, 1934, 1935, 1955, + 1945, 1920, 1926, 1946, 1933, 1925, 1929, 1943, 1942, 1941, 1922, 1969, + 1950, 1949, 1921, 1936, 1939, 1932, 1947, 1944, 1952, 1928, 1957, 1938, + 1948, 1953, 1924, 1923, 1940, 1967, 1966, 1963, 1960, 1962, 1968, 3610, + 3592, 3594, 3593, 3596, 3598, 3604, 3613, 3615, 3663, 3630, 3627, 3588, + 3587, 3589, 3586, 3590, 3675, 3585, 3628, 3621, 3653, 3622, 3659, 3633, + 3657, 3658, 3656, 3655, 3654, 3617, 3674, 3591, 3661, 3603, 3609, 3631, + 3642, 3612, 3614, 3616, 3611, 3619, 3620, 3632, 3652, 3651, 3634, 3649, + 3635, 3640, 3638, 3639, 3641, 3636, 3637, 3648, 3650, 3625, 3624, 3626, + 3595, 3660, 3601, 3602, 3607, 3600, 3608, 3606, 3605, 3599, 3623, 3662, + 3597, 3618, 3629, 3647, 3669, 3668, 3671, 3670, 3667, 3666, 3664, 3673, + 3665, 3672, 8708, 8707, 8756, 127777, 10727, 118474, 128936, 8201, + 128929, 129300, 129353, 128173, 129652, 10176, 8278, 9887, 9886, 11057, + 128485, 128484, 128486, 128487, 8694, 128433, 10870, 128491, 128962, + 128423, 11160, 11162, 10146, 11163, 11161, 10147, 8196, 11835, 128077, + 128078, 9928, 9736, 3865, 3863, 3864, 4035, 4032, 4033, 4034, 3886, 3885, + 3888, 3887, 3884, 3883, 3891, 3890, 3882, 3889, 3877, 3876, 3879, 3878, + 3875, 3874, 3872, 3881, 3873, 3880, 4030, 4031, 3945, 3905, 3947, 3904, + 3948, 3938, 3946, 3917, 3916, 3932, 3931, 3922, 3921, 3908, 3918, 3913, + 3923, 3940, 3941, 3942, 3930, 3929, 3915, 3914, 3920, 3919, 3927, 3926, + 3910, 3909, 3907, 3906, 3925, 3924, 3934, 3935, 3936, 3943, 3911, 3939, + 3928, 3933, 3937, 3944, 3862, 3861, 983210, 3850, 4048, 3849, 3892, 4049, + 3894, 3859, 3846, 3896, 4052, 3845, 3847, 3842, 3843, 3841, 3860, 3898, + 3899, 3900, 3901, 3972, 4051, 3844, 3851, 3895, 3893, 4050, 3856, 3854, + 3858, 3857, 3848, 3853, 4058, 3897, 3855, 4057, 3973, 3852, 3978, 3979, + 3974, 3976, 3903, 3977, 3970, 3866, 3867, 3868, 3871, 3869, 3870, 4047, + 4046, 3966, 3967, 3975, 3902, 3980, 3971, 4028, 4026, 4027, 3997, 3996, + 4012, 4011, 4002, 4001, 4025, 3985, 3984, 3988, 3998, 3993, 4003, 4020, + 4021, 4022, 4010, 4009, 3995, 3994, 4000, 3999, 4007, 4006, 3990, 3989, + 3987, 3986, 4005, 4004, 4014, 4015, 4016, 4023, 3991, 4019, 4008, 4018, + 4013, 4017, 4024, 3983, 3982, 3981, 3840, 4036, 4041, 4044, 4043, 4042, + 4038, 4040, 4037, 4039, 3968, 3969, 3956, 3957, 3958, 3959, 3960, 3961, + 3964, 3965, 3954, 3955, 3962, 3963, 3953, 10717, 11647, 11608, 11595, + 11585, 11573, 11620, 11607, 11600, 11582, 11590, 11596, 11601, 11586, + 11592, 11568, 11571, 11606, 11572, 11581, 11589, 11583, 11609, 11611, + 11610, 11612, 11613, 11615, 11619, 11594, 11621, 11575, 11577, 11578, + 11576, 11569, 11570, 11584, 11587, 11604, 11605, 11614, 11588, 11580, + 11574, 11597, 11598, 11599, 11602, 11591, 11616, 11617, 11618, 11622, + 11579, 11593, 11623, 11603, 11631, 11632, 128005, 128047, 10053, 126, + 8764, 11081, 10610, 10859, 10858, 11807, 11806, 11803, 9202, 10708, + 10709, 10750, 68410, 70854, 70784, 70785, 70786, 70796, 70798, 70812, + 70811, 70817, 70816, 70810, 70809, 70815, 70814, 70791, 70792, 70793, + 70794, 70827, 70789, 70790, 70787, 70788, 70803, 70813, 70808, 70818, + 70828, 70829, 70830, 70822, 70821, 70805, 70804, 70802, 70801, 70807, + 70806, 70800, 70799, 70820, 70819, 70831, 70826, 70823, 70825, 70824, + 70795, 70797, 70847, 70851, 70852, 70848, 70850, 70849, 70842, 70845, + 70832, 70843, 70846, 70835, 70836, 70837, 70838, 70839, 70840, 70833, + 70834, 70841, 70844, 70869, 70868, 70871, 70870, 70867, 70866, 70864, + 70873, 70865, 70872, 70853, 70855, 11858, 8266, 128555, 127915, 67054, + 67022, 67020, 67027, 67051, 67011, 67031, 67023, 67021, 67033, 67049, + 67047, 67015, 67032, 67025, 67024, 67058, 67035, 67041, 67040, 67056, + 67055, 67039, 67038, 67037, 67034, 67059, 67018, 67017, 67030, 67029, + 67008, 67009, 67013, 67012, 67016, 67014, 67057, 67028, 67043, 67042, + 67048, 67046, 67053, 67052, 67010, 67019, 67036, 67045, 67026, 67044, + 67050, 73140, 73141, 73149, 73154, 73155, 73150, 73151, 73156, 73171, + 73166, 73161, 73168, 73175, 73176, 73147, 73152, 73153, 73148, 73144, + 73145, 73157, 73158, 73164, 73165, 73159, 73160, 73162, 73163, 73142, + 73143, 73137, 73173, 73136, 73169, 73146, 73139, 73172, 73138, 73170, + 73174, 73167, 73177, 73178, 73179, 73189, 73188, 73191, 73190, 73187, + 73186, 73184, 73193, 73185, 73192, 127406, 127813, 128069, 129463, + 129701, 129520, 10554, 10557, 10556, 9182, 118256, 117851, 118262, + 118263, 11865, 117850, 118252, 118254, 11866, 117852, 118248, 118250, + 11833, 118246, 11210, 8992, 127913, 9180, 130024, 130016, 130031, 8988, + 8975, 11810, 118279, 8989, 8974, 11811, 130028, 9140, 9184, 128285, + 127553, 127554, 127559, 127555, 127557, 127560, 127552, 127556, 127558, + 127274, 9008, 123554, 123556, 123559, 123561, 123564, 123537, 123544, + 123543, 123553, 123555, 123558, 123560, 123546, 123565, 123563, 123539, + 123541, 123550, 123549, 123540, 123552, 123542, 123536, 123551, 123545, + 123538, 123548, 123547, 123562, 123557, 123566, 128701, 128508, 128434, + 128668, 8482, 128650, 128651, 129014, 11223, 10971, 128646, 129678, + 118460, 10701, 10699, 128710, 10698, 10141, 128681, 128208, 8227, 128305, + 9783, 9776, 9777, 9782, 9779, 9781, 9780, 9778, 10998, 10856, 10857, + 10747, 8244, 8779, 10996, 10624, 8874, 10997, 11003, 11851, 11000, 10999, + 8749, 8285, 129484, 128654, 129674, 127865, 128032, 127942, 8872, 11231, + 127930, 8366, 70601, 70608, 70613, 70612, 70610, 70528, 70529, 70542, + 70545, 70559, 70558, 70564, 70563, 70581, 70579, 70573, 70580, 70572, + 70557, 70556, 70562, 70561, 70534, 70535, 70536, 70537, 70574, 70532, + 70533, 70530, 70531, 70550, 70560, 70555, 70565, 70575, 70576, 70577, + 70569, 70568, 70552, 70551, 70549, 70548, 70554, 70553, 70547, 70546, + 70567, 70566, 70544, 70539, 70578, 70570, 70571, 70609, 70583, 70604, + 70607, 70615, 70616, 70602, 70611, 70606, 70605, 70626, 70625, 70584, + 70597, 70600, 70587, 70588, 70589, 70590, 70591, 70592, 70585, 70586, + 70599, 70594, 127799, 8378, 129411, 8523, 10658, 11202, 9930, 9929, 8498, + 11826, 11832, 8587, 8586, 128598, 128596, 8985, 128399, 8513, 8514, 8516, + 11829, 8526, 128599, 128597, 8489, 128034, 129347, 10041, 128256, 128432, + 10869, 8229, 8282, 11818, 128149, 10837, 10838, 10697, 10760, 10759, + 128108, 128109, 117896, 8273, 128490, 11834, 121610, 121611, 8387, 66432, + 66451, 66454, 66433, 66436, 66447, 66457, 66434, 66437, 66440, 66443, + 66435, 66445, 66455, 66453, 66450, 66444, 66461, 66456, 66441, 66458, + 66442, 66439, 66449, 66448, 66452, 66438, 66446, 66459, 66460, 66463, + 9730, 9969, 9748, 128530, 11217, 8255, 9100, 8746, 10824, 10822, 10826, + 10817, 10818, 10821, 983116, 11258, 9842, 129412, 9903, 8963, 8996, + 11193, 10685, 10577, 10573, 10572, 10575, 8597, 8616, 11021, 8661, + 129113, 8691, 11109, 10622, 8944, 8869, 10207, 117873, 117877, 117857, + 128743, 117881, 118267, 128742, 117847, 128314, 117912, 117862, 128744, + 128316, 9709, 9710, 117760, 129898, 129946, 129920, 129896, 9985, 118417, + 117809, 118418, 117810, 130020, 129924, 9600, 129937, 118275, 129938, + 9690, 118292, 129934, 118439, 118444, 9696, 129885, 129887, 129889, + 129886, 129883, 129888, 129881, 129884, 129882, 129879, 129880, 10196, + 118416, 9136, 129944, 129948, 9720, 117808, 9692, 117958, 117946, 117962, + 117966, 117950, 117954, 117928, 117926, 117942, 117970, 117938, 117813, + 118421, 118422, 118420, 117812, 118423, 117815, 129922, 9620, 129874, + 129875, 129892, 129894, 129890, 129878, 129893, 129891, 129876, 129895, + 129877, 10064, 118419, 9137, 10000, 9693, 117959, 117947, 117963, 117967, + 117951, 117955, 117929, 117927, 117943, 117971, 117939, 117814, 128319, + 10066, 129945, 129949, 9721, 117811, 129926, 129923, 118438, 118445, + 129925, 129901, 128579, 11797, 8593, 129976, 8645, 8670, 129033, 129029, + 129177, 129041, 129025, 129045, 8624, 8625, 10505, 8613, 10514, 11145, + 11014, 8657, 8673, 129077, 10606, 10595, 10592, 10584, 8639, 10588, + 10580, 8638, 129089, 129093, 129085, 10224, 128621, 129105, 129081, + 11105, 11137, 11121, 129065, 11170, 11171, 129061, 129057, 129073, + 129069, 11131, 11115, 11141, 129169, 10506, 8607, 11245, 10569, 8648, + 8679, 8683, 8685, 8684, 129173, 8682, 11192, 8686, 8687, 9797, 983117, + 42509, 42510, 42511, 42446, 42370, 42486, 42257, 42333, 42294, 42407, + 42445, 42369, 42485, 42256, 42332, 42293, 42406, 42449, 42373, 42489, + 42260, 42336, 42297, 42410, 42434, 42359, 42473, 42246, 42321, 42283, + 42396, 42435, 42360, 42474, 42247, 42322, 42284, 42397, 42452, 42376, + 42492, 42263, 42339, 42300, 42413, 42451, 42375, 42491, 42262, 42338, + 42299, 42412, 42444, 42368, 42484, 42255, 42331, 42292, 42405, 42443, + 42367, 42483, 42254, 42330, 42291, 42404, 42454, 42378, 42494, 42265, + 42341, 42302, 42415, 42453, 42377, 42493, 42264, 42340, 42301, 42414, + 42439, 42440, 42364, 42479, 42251, 42480, 42327, 42288, 42401, 42502, + 42272, 42503, 42461, 42385, 42349, 42309, 42422, 42429, 42430, 42355, + 42468, 42242, 42469, 42316, 42317, 42278, 42279, 42391, 42392, 42476, + 42249, 42477, 42437, 42362, 42324, 42325, 42286, 42399, 42459, 42383, + 42346, 42347, 42499, 42270, 42307, 42420, 42487, 42508, 42258, 42447, + 42371, 42334, 42295, 42408, 42436, 42361, 42475, 42248, 42323, 42285, + 42398, 42438, 42363, 42478, 42250, 42326, 42287, 42400, 42462, 42386, + 42504, 42273, 42350, 42310, 42423, 42450, 42514, 42539, 42512, 42513, + 42538, 42374, 42490, 42261, 42337, 42298, 42411, 42507, 42500, 42271, + 42501, 42460, 42384, 42348, 42308, 42421, 42315, 42467, 42428, 42457, + 42381, 42497, 42268, 42344, 42305, 42418, 42464, 42388, 42506, 42275, + 42352, 42312, 42425, 42463, 42387, 42505, 42274, 42351, 42311, 42424, + 42455, 42379, 42495, 42266, 42342, 42303, 42416, 42441, 42365, 42481, + 42252, 42328, 42289, 42402, 42456, 42380, 42496, 42267, 42343, 42304, + 42417, 42433, 42358, 42472, 42245, 42320, 42282, 42395, 42448, 42372, + 42488, 42259, 42335, 42296, 42409, 42442, 42366, 42482, 42253, 42329, + 42290, 42403, 42458, 42382, 42498, 42269, 42345, 42306, 42419, 42470, + 42243, 42244, 42471, 42431, 42356, 42357, 42432, 42318, 42319, 42280, + 42281, 42393, 42394, 42465, 42240, 42241, 42466, 42426, 42353, 42354, + 42427, 42313, 42314, 42276, 42277, 42389, 42390, 42523, 42526, 42522, + 42515, 42520, 42527, 42516, 42524, 42518, 42517, 42525, 42521, 42519, + 42533, 42532, 42535, 42534, 42531, 42530, 42528, 42537, 42529, 42536, + 65024, 65033, 917843, 917844, 917845, 917846, 917847, 917848, 917849, + 917850, 917851, 917852, 65034, 917853, 917854, 917855, 917856, 917857, + 917858, 917859, 917860, 917861, 917862, 65035, 917863, 917864, 917865, + 917866, 917867, 917868, 917869, 917870, 917871, 917872, 65036, 917873, + 917874, 917875, 917876, 917877, 917878, 917879, 917880, 917881, 917882, + 65037, 917883, 917884, 917885, 917886, 917887, 917888, 917889, 917890, + 917891, 917892, 65038, 917893, 917894, 917895, 917896, 917897, 917898, + 917899, 917900, 917901, 917902, 65039, 917903, 917904, 917905, 917906, + 917907, 917908, 917909, 917910, 917911, 917912, 917760, 917913, 917914, + 917915, 917916, 917917, 917918, 917919, 917920, 917921, 917922, 917761, + 917923, 917924, 917925, 917926, 917927, 917928, 917929, 917930, 917931, + 917932, 917762, 917933, 917934, 917935, 917936, 917937, 917938, 917939, + 917940, 917941, 917942, 65025, 917763, 917943, 917944, 917945, 917946, + 917947, 917948, 917949, 917950, 917951, 917952, 917764, 917953, 917954, + 917955, 917956, 917957, 917958, 917959, 917960, 917961, 917962, 917765, + 917963, 917964, 917965, 917966, 917967, 917968, 917969, 917970, 917971, + 917972, 917766, 917973, 917974, 917975, 917976, 917977, 917978, 917979, + 917980, 917981, 917982, 917767, 917983, 917984, 917985, 917986, 917987, + 917988, 917989, 917990, 917991, 917992, 917768, 917993, 917994, 917995, + 917996, 917997, 917998, 917999, 917769, 917770, 917771, 917772, 65026, + 917773, 917774, 917775, 917776, 917777, 917778, 917779, 917780, 917781, + 917782, 65027, 917783, 917784, 917785, 917786, 917787, 917788, 917789, + 917790, 917791, 917792, 65028, 917793, 917794, 917795, 917796, 917797, + 917798, 917799, 917800, 917801, 917802, 65029, 917803, 917804, 917805, + 917806, 917807, 917808, 917809, 917810, 917811, 917812, 65030, 917813, + 917814, 917815, 917816, 917817, 917818, 917819, 917820, 917821, 917822, + 65031, 917823, 917824, 917825, 917826, 917827, 917828, 917829, 917830, + 917831, 917832, 65032, 917833, 917834, 917835, 917836, 917837, 917838, + 917839, 917840, 917841, 917842, 129499, 983245, 983254, 983364, 983365, + 983366, 983367, 983368, 983369, 983370, 983371, 983372, 983373, 983255, + 983374, 983375, 983376, 983377, 983378, 983379, 983380, 983381, 983382, + 983383, 983256, 983384, 983385, 983386, 983387, 983388, 983389, 983390, + 983391, 983392, 983393, 983257, 983394, 983395, 983396, 983397, 983398, + 983399, 983400, 983401, 983402, 983403, 983258, 983404, 983405, 983406, + 983407, 983408, 983409, 983410, 983411, 983412, 983413, 983259, 983414, + 983415, 983416, 983417, 983418, 983419, 983420, 983421, 983422, 983423, + 983260, 983424, 983425, 983426, 983427, 983428, 983429, 983430, 983431, + 983432, 983433, 983281, 983434, 983435, 983436, 983437, 983438, 983439, + 983440, 983441, 983442, 983443, 983282, 983444, 983445, 983446, 983447, + 983448, 983449, 983450, 983451, 983452, 983453, 983283, 983454, 983455, + 983456, 983457, 983458, 983459, 983460, 983461, 983462, 983463, 983246, + 983284, 983464, 983465, 983466, 983467, 983468, 983469, 983470, 983471, + 983472, 983473, 983285, 983474, 983475, 983476, 983477, 983478, 983479, + 983480, 983481, 983482, 983483, 983286, 983484, 983485, 983486, 983487, + 983488, 983489, 983490, 983491, 983492, 983493, 983287, 983494, 983495, + 983496, 983497, 983498, 983499, 983500, 983501, 983502, 983503, 983288, + 983504, 983505, 983506, 983507, 983508, 983509, 983510, 983511, 983512, + 983513, 983289, 983514, 983515, 983516, 983517, 983518, 983519, 983520, + 983290, 983291, 983292, 983293, 983247, 983294, 983295, 983296, 983297, + 983298, 983299, 983300, 983301, 983302, 983303, 983248, 983304, 983305, + 983306, 983307, 983308, 983309, 983310, 983311, 983312, 983313, 983249, + 983314, 983315, 983316, 983317, 983318, 983319, 983320, 983321, 983322, + 983323, 983250, 983324, 983325, 983326, 983327, 983328, 983329, 983330, + 983331, 983332, 983333, 983251, 983334, 983335, 983336, 983337, 983338, + 983339, 983340, 983341, 983342, 983343, 983252, 983344, 983345, 983346, + 983347, 983348, 983349, 983350, 983351, 983352, 983353, 983253, 983354, + 983355, 983356, 983357, 983358, 983359, 983360, 983361, 983362, 983363, + 7401, 7402, 7409, 7403, 7404, 7415, 7410, 7418, 7413, 7379, 7398, 7396, + 7411, 7408, 7406, 7407, 7405, 7414, 7397, 7400, 7395, 7399, 7394, 7380, + 7384, 7412, 7417, 7386, 7389, 7376, 7388, 7378, 7416, 7392, 7391, 7387, + 7390, 7381, 7382, 7383, 7385, 7393, 7377, 8483, 10704, 10980, 10978, + 10186, 117780, 129017, 8942, 8286, 117917, 12347, 12337, 12339, 12341, + 12338, 12340, 117892, 124, 9168, 10992, 10991, 117904, 118293, 9087, + 9896, 129904, 129905, 129906, 129907, 129908, 129909, 117916, 117770, + 11135, 983069, 983144, 11823, 128678, 10650, 11837, 128976, 128959, + 128947, 128637, 128941, 128953, 128636, 128904, 128914, 128934, 8921, + 8920, 128933, 9910, 128887, 10799, 128243, 9996, 118469, 128249, 127918, + 128252, 94193, 94192, 8983, 127931, 9805, 66929, 66930, 66936, 66935, + 66942, 66943, 66947, 66946, 66950, 66949, 66932, 66931, 66934, 66933, + 66957, 66956, 66959, 66958, 66941, 66940, 66937, 66944, 66948, 66952, + 66954, 66961, 66962, 66965, 66938, 66945, 66953, 66928, 66951, 66960, + 66964, 66968, 66969, 66975, 66974, 66981, 66982, 66986, 66985, 66989, + 66988, 66971, 66970, 66973, 66972, 66996, 66995, 66998, 66997, 66980, + 66979, 66976, 66983, 66987, 66991, 66993, 67000, 67001, 67004, 66977, + 66984, 66992, 66967, 66990, 66999, 67003, 129979, 127755, 127952, 8752, + 983070, 983145, 11238, 8541, 8538, 8536, 8539, 8533, 189, 8529, 188, + 8528, 8537, 8530, 8531, 8540, 190, 8535, 8534, 8532, 8542, 8585, 129479, + 123585, 123584, 123624, 123619, 123620, 123606, 123605, 123622, 123618, + 123611, 123623, 123612, 123621, 123615, 123592, 123613, 123625, 123593, + 123596, 123617, 123616, 123595, 123614, 123626, 123627, 123590, 123609, + 123604, 123591, 123594, 123599, 123598, 123586, 123587, 123588, 123597, + 123589, 123610, 123600, 123608, 123607, 123603, 123602, 123601, 123647, + 123630, 123631, 123628, 123629, 123637, 123636, 123639, 123638, 123635, + 123634, 123632, 123641, 123633, 123640, 127768, 127766, 127762, 127764, + 71841, 71850, 71862, 71861, 71848, 71856, 71853, 71867, 71866, 71865, + 71868, 71840, 71859, 71849, 71857, 71869, 71870, 71855, 71847, 71843, + 71854, 71844, 71845, 71858, 71871, 71863, 71864, 71852, 71846, 71842, + 71860, 71851, 71873, 71882, 71894, 71893, 71880, 71888, 71885, 71899, + 71898, 71897, 71900, 71872, 71891, 71881, 71889, 71901, 71902, 71887, + 71879, 71875, 71886, 71876, 71877, 71890, 71903, 71895, 71896, 71884, + 71878, 71874, 71892, 71883, 71909, 71908, 71911, 71910, 71907, 71906, + 71904, 71913, 71905, 71912, 71921, 71918, 71917, 71922, 71920, 71919, + 71916, 71915, 71914, 71935, 9888, 128702, 127754, 128003, 129341, 127817, + 8986, 12316, 11071, 10547, 127988, 127987, 128075, 12336, 65103, 8967, + 65099, 128465, 128576, 128553, 10172, 128146, 983238, 127947, 9840, + 128734, 9784, 9855, 129197, 129196, 9702, 129621, 9815, 129548, 129590, + 129608, 129611, 129620, 9812, 129545, 129587, 9816, 129542, 129563, + 129584, 129591, 129605, 129549, 129616, 129614, 129615, 9817, 129550, + 129592, 9813, 129546, 129588, 9814, 129547, 129589, 129569, 129566, + 129570, 129571, 129567, 129568, 9675, 128906, 9862, 10732, 9863, 9717, + 9718, 9716, 9719, 9831, 10209, 10210, 10211, 129995, 129015, 9671, 9672, + 128922, 128923, 9931, 10192, 9826, 128071, 128407, 9759, 9663, 9661, 9920, 9921, 10069, 9872, 9983, 10048, 128174, 11214, 10023, 9785, 128427, 129293, 9825, 9989, 129984, 11041, 11053, 10710, 11036, 128326, 9945, 128072, 9756, 9669, 9667, 9665, 117894, 117895, 128928, 11046, 11088, 9725, 9723, 11048, 11229, 10001, 9649, 11040, 127985, 10068, 9645, 11092, 9659, 9657, 9655, 128073, 9758, 9988, 65094, 9750, 11051, 11090, 9643, - 9786, 9828, 9633, 128307, 128916, 9635, 128917, 10212, 9713, 9714, 10213, - 9634, 9712, 9715, 9707, 9093, 127779, 127781, 127782, 9788, 127780, 9734, - 128382, 9743, 9186, 10177, 9943, 128070, 9757, 129994, 9653, 9651, 9708, - 11055, 9647, 118278, 11006, 11038, 10163, 128011, 129144, 129152, 129120, - 129136, 129128, 129146, 129154, 129122, 129138, 129130, 129147, 129155, - 129123, 129139, 129131, 129145, 129153, 129121, 129137, 129129, 129149, - 129157, 129125, 129141, 129133, 129148, 129156, 129124, 129140, 129132, - 129150, 129158, 129126, 129142, 129134, 129151, 129159, 129127, 129143, - 129135, 11838, 129344, 127888, 127788, 129695, 127863, 128521, 129725, - 128430, 128732, 128105, 128111, 128098, 128090, 128097, 128082, 128698, - 11825, 8288, 128506, 128543, 129713, 8361, 129717, 128058, 127873, 8768, - 129340, 128295, 9997, 983233, 8999, 129659, 129644, 129643, 129641, - 129639, 129642, 129645, 129640, 129637, 129636, 129634, 129632, 129635, - 129638, 129633, 8891, 94196, 94197, 94198, 129393, 128155, 165, 69292, - 69291, 69293, 69256, 69255, 69254, 69281, 69268, 69259, 69248, 69271, - 69289, 69286, 69287, 69257, 69278, 69277, 69279, 69276, 69280, 69296, - 69282, 69251, 69250, 69266, 69265, 69267, 69253, 69252, 69269, 69274, - 69275, 69284, 69285, 69272, 69258, 69288, 69297, 69263, 69260, 69270, - 69262, 69261, 69249, 69283, 69273, 69264, 42139, 42149, 42173, 42172, - 42132, 42147, 42179, 42174, 42148, 42169, 42150, 42134, 42166, 42135, - 42145, 42143, 42137, 42175, 42157, 42154, 42167, 42165, 42163, 42130, - 42182, 42129, 42171, 42138, 42140, 42136, 42131, 42151, 42164, 42181, - 42142, 42156, 42170, 42176, 42178, 42160, 42133, 42144, 42152, 42159, - 42161, 42158, 42141, 42146, 42177, 42180, 42155, 42162, 42128, 42168, - 42153, 41070, 41059, 41060, 41058, 41073, 41072, 41071, 41068, 41069, - 41066, 41067, 41065, 41048, 41052, 41053, 41050, 41051, 41049, 41046, - 41047, 41056, 41057, 41054, 41055, 41063, 41064, 41061, 41062, 41076, - 41077, 41074, 41075, 41006, 40995, 40996, 40994, 41009, 41008, 41007, - 41004, 41005, 41002, 41003, 41001, 40984, 40988, 40989, 40986, 40987, - 40985, 40982, 40983, 40992, 40993, 40990, 40991, 40999, 41000, 40997, - 40998, 41012, 41015, 41014, 41013, 41010, 41011, 41842, 41831, 41832, - 41829, 41830, 41845, 41844, 41843, 41841, 41827, 41828, 41825, 41826, - 41839, 41840, 41837, 41838, 41835, 41836, 41833, 41834, 41848, 41851, - 41850, 41849, 41846, 41847, 41670, 41659, 41660, 41658, 41673, 41672, - 41671, 41668, 41669, 41666, 41667, 41665, 41648, 41652, 41653, 41650, - 41651, 41649, 41646, 41647, 41656, 41657, 41654, 41655, 41663, 41664, - 41661, 41662, 41676, 41679, 41678, 41677, 41674, 41675, 41293, 41282, - 41283, 41281, 41296, 41295, 41294, 41291, 41292, 41272, 41275, 41276, - 41274, 41273, 41270, 41271, 41289, 41290, 41288, 41279, 41280, 41277, - 41278, 41286, 41287, 41284, 41285, 41238, 41228, 41227, 41241, 41240, - 41239, 41236, 41237, 41218, 41221, 41222, 41220, 41219, 41216, 41217, - 41234, 41235, 41233, 41225, 41226, 41223, 41224, 41231, 41232, 41229, - 41230, 41174, 41175, 41173, 41171, 41172, 41169, 41170, 41167, 41168, - 41165, 41166, 41184, 41185, 41182, 41183, 41178, 41181, 41180, 41179, - 41176, 41177, 41494, 41496, 41497, 41495, 41492, 41493, 41516, 41504, - 41505, 41502, 41503, 41519, 41518, 41517, 41514, 41515, 41500, 41501, - 41498, 41499, 41512, 41513, 41510, 41511, 41508, 41509, 41506, 41507, - 41460, 41448, 41449, 41446, 41447, 41463, 41462, 41461, 41458, 41459, - 41436, 41440, 41441, 41438, 41439, 41437, 41434, 41435, 41444, 41445, - 41442, 41443, 41456, 41457, 41454, 41455, 41452, 41453, 41450, 41451, - 41584, 41583, 41582, 41389, 41379, 41380, 41378, 41392, 41391, 41390, - 41387, 41388, 41369, 41372, 41373, 41371, 41370, 41367, 41368, 41385, - 41386, 41384, 41382, 41383, 41381, 41376, 41377, 41374, 41375, 41395, - 41398, 41397, 41396, 41393, 41394, 41125, 41117, 41118, 41116, 41128, - 41127, 41126, 41123, 41124, 41107, 41110, 41111, 41109, 41108, 41105, - 41106, 41114, 41115, 41112, 41113, 41121, 41122, 41119, 41120, 41130, - 41133, 41132, 41131, 41129, 41336, 41334, 41335, 41333, 41332, 41340, - 41338, 41339, 41337, 41322, 41326, 41327, 41324, 41325, 41323, 41320, - 41321, 41330, 41331, 41328, 41329, 41556, 41557, 41554, 41555, 41563, - 41564, 41562, 41544, 41548, 41549, 41546, 41547, 41545, 41542, 41543, - 41552, 41553, 41550, 41551, 41560, 41561, 41558, 41559, 41591, 41592, - 41589, 41590, 41598, 41599, 41597, 41587, 41588, 41585, 41586, 41595, - 41596, 41593, 41594, 40962, 40960, 983243, 40966, 40967, 40964, 40965, - 40963, 40961, 42025, 42017, 42018, 42016, 42028, 42027, 42026, 42023, - 42024, 42010, 42014, 42015, 42012, 42013, 42011, 42008, 42009, 42021, - 42022, 42019, 42020, 42031, 42032, 42029, 42030, 41970, 41962, 41963, - 41960, 41961, 41973, 41972, 41971, 41968, 41969, 41954, 41958, 41959, - 41956, 41957, 41955, 41952, 41953, 41966, 41967, 41964, 41965, 41976, - 41979, 41978, 41977, 41974, 41975, 41488, 41476, 41477, 41475, 41491, - 41490, 41489, 41486, 41487, 41466, 41469, 41470, 41468, 41467, 41464, - 41465, 41473, 41474, 41471, 41472, 41484, 41485, 41482, 41483, 41480, - 41481, 41478, 41479, 41424, 41413, 41414, 41411, 41412, 41427, 41426, - 41425, 41422, 41423, 41420, 41421, 41419, 41401, 41405, 41406, 41403, - 41404, 41402, 41399, 41400, 41409, 41410, 41407, 41408, 41417, 41418, - 41415, 41416, 41430, 41433, 41432, 41431, 41428, 41429, 41538, 41527, - 41528, 41526, 41541, 41540, 41539, 41536, 41537, 41534, 41535, 41533, - 41524, 41525, 41522, 41523, 41531, 41532, 41529, 41530, 41521, 41520, - 41157, 41147, 41148, 41145, 41146, 41160, 41159, 41158, 41155, 41156, - 41136, 41139, 41140, 41138, 41137, 41134, 41135, 41143, 41144, 41141, - 41142, 41151, 41152, 41149, 41150, 41163, 41164, 41161, 41162, 41154, - 41153, 41080, 41083, 41084, 41082, 41081, 41078, 41079, 41087, 41088, - 41085, 41086, 41091, 41092, 41089, 41090, 41095, 41098, 41097, 41096, - 41093, 41094, 41101, 41104, 41103, 41102, 41099, 41100, 41299, 41302, - 41301, 41300, 41297, 41298, 41312, 41313, 41311, 41305, 41306, 41303, - 41304, 41309, 41310, 41307, 41308, 41316, 41319, 41318, 41317, 41314, - 41315, 41574, 41572, 41573, 41580, 41581, 41579, 41566, 41567, 41565, - 41570, 41571, 41568, 41569, 41577, 41578, 41575, 41576, 42048, 42042, - 42041, 42051, 42050, 42049, 42047, 42035, 42039, 42040, 42037, 42038, - 42036, 42033, 42034, 42045, 42046, 42043, 42044, 42054, 42057, 42056, - 42055, 42052, 42053, 41881, 41882, 41880, 41878, 41879, 41876, 41877, - 41885, 41886, 41883, 41884, 41889, 41892, 41891, 41890, 41887, 41888, - 41895, 41898, 41897, 41896, 41893, 41894, 42075, 42067, 42068, 42066, - 42076, 42073, 42074, 42060, 42064, 42065, 42062, 42063, 42061, 42058, - 42059, 42071, 42072, 42069, 42070, 41727, 41721, 41720, 41730, 41729, - 41728, 41726, 41723, 41722, 41711, 41714, 41715, 41713, 41712, 41709, - 41710, 41718, 41719, 41716, 41717, 41733, 41736, 41735, 41734, 41731, - 41732, 41725, 41724, 41363, 41352, 41353, 41351, 41366, 41365, 41364, - 41361, 41362, 41343, 41346, 41347, 41345, 41344, 41341, 41342, 41349, - 41350, 41348, 41359, 41360, 41358, 41356, 41357, 41354, 41355, 41036, - 41028, 41029, 41027, 41039, 41038, 41037, 41034, 41035, 41018, 41021, - 41022, 41020, 41019, 41016, 41017, 41025, 41026, 41023, 41024, 41032, - 41033, 41030, 41031, 41042, 41045, 41044, 41043, 41040, 41041, 41998, - 41990, 41991, 41988, 41989, 42001, 42000, 41999, 41996, 41997, 41982, - 41986, 41987, 41984, 41985, 41983, 41980, 41981, 41994, 41995, 41992, - 41993, 42004, 42007, 42006, 42005, 42002, 42003, 42115, 42107, 42108, - 42105, 42106, 42118, 42117, 42116, 42113, 42114, 42099, 42103, 42104, - 42101, 42102, 42100, 42097, 42098, 42111, 42112, 42109, 42110, 42121, - 42124, 42123, 42122, 42119, 42120, 41866, 41855, 41854, 41869, 41868, - 41867, 41864, 41865, 41862, 41863, 41860, 41861, 41858, 41859, 41856, - 41857, 41872, 41875, 41874, 41873, 41870, 41871, 41853, 41852, 41942, - 41931, 41932, 41930, 41945, 41944, 41943, 41940, 41941, 41938, 41939, - 41937, 41928, 41929, 41926, 41927, 41935, 41936, 41933, 41934, 41948, - 41951, 41950, 41949, 41946, 41947, 41772, 41775, 41776, 41774, 41773, - 41770, 41771, 41786, 41787, 41785, 41779, 41780, 41777, 41778, 41783, - 41784, 41781, 41782, 41790, 41791, 41788, 41789, 41794, 41797, 41796, - 41795, 41792, 41793, 41916, 41904, 41905, 41903, 41919, 41918, 41917, - 41914, 41915, 41901, 41902, 41899, 41900, 41912, 41913, 41910, 41911, - 41908, 41909, 41906, 41907, 41922, 41925, 41924, 41923, 41920, 41921, - 41760, 41749, 41750, 41748, 41763, 41762, 41761, 41758, 41759, 41739, - 41742, 41743, 41741, 41740, 41737, 41738, 41756, 41757, 41755, 41746, - 41747, 41744, 41745, 41753, 41754, 41751, 41752, 41766, 41769, 41768, - 41767, 41764, 41765, 41266, 41255, 41256, 41253, 41254, 41269, 41268, - 41267, 41264, 41265, 41244, 41247, 41248, 41246, 41245, 41242, 41243, - 41262, 41263, 41261, 41251, 41252, 41249, 41250, 41259, 41260, 41257, - 41258, 41203, 41202, 41188, 41192, 41193, 41190, 41191, 41189, 41186, - 41187, 41196, 41197, 41194, 41195, 41200, 41201, 41198, 41199, 41206, - 41209, 41208, 41207, 41204, 41205, 41212, 41215, 41214, 41213, 41210, - 41211, 40981, 41605, 41606, 41604, 41611, 41612, 41610, 41608, 41609, - 41607, 41602, 41603, 41600, 41601, 42079, 42083, 42084, 42081, 42082, - 42080, 42077, 42078, 42089, 42090, 42087, 42088, 42093, 42096, 42095, - 42094, 42091, 42092, 42086, 42085, 41815, 41803, 41804, 41802, 41818, - 41817, 41816, 41813, 41814, 41800, 41801, 41798, 41799, 41811, 41812, - 41809, 41810, 41807, 41808, 41805, 41806, 41821, 41824, 41823, 41822, - 41819, 41820, 41636, 41625, 41626, 41624, 41639, 41638, 41637, 41634, - 41635, 41615, 41618, 41619, 41617, 41616, 41613, 41614, 41696, 41697, - 41695, 41693, 41694, 41692, 41682, 41686, 41687, 41684, 41685, 41683, - 41680, 41681, 41690, 41691, 41688, 41689, 41699, 41702, 41701, 41700, - 41698, 41705, 41708, 41707, 41706, 41703, 41704, 41632, 41633, 41631, - 41622, 41623, 41620, 41621, 41629, 41630, 41627, 41628, 41642, 41645, - 41644, 41643, 41640, 41641, 40973, 40974, 40972, 40970, 40971, 40968, - 40969, 40977, 40978, 40975, 40976, 40980, 40979, 9775, 129664, 8959, - 10853, 10632, 10634, 10814, 10852, 10631, 10633, 10783, 10784, 10785, - 10625, 10626, 72262, 72256, 72253, 72252, 72254, 72251, 72250, 72261, - 72255, 72243, 72215, 72214, 72230, 72229, 72220, 72219, 72242, 72204, - 72203, 72207, 72216, 72211, 72221, 72238, 72239, 72240, 72228, 72227, - 72213, 72212, 72218, 72217, 72225, 72224, 72209, 72208, 72206, 72205, - 72223, 72222, 72231, 72232, 72233, 72241, 72210, 72236, 72226, 72235, - 72237, 72234, 72192, 72259, 72258, 72260, 72257, 72248, 72245, 72246, - 72247, 72244, 72249, 72263, 72202, 72199, 72200, 72198, 72197, 72195, - 72194, 72201, 72196, 72193, 129427, 65279, 8204, 8203, 8205, 11234, - 129296, 118593, 118584, 118585, 118591, 118580, 118589, 118528, 118540, - 118531, 118543, 118559, 118529, 118541, 118532, 118544, 118592, 118573, - 118569, 118568, 118581, 118586, 118561, 118582, 118583, 118566, 118538, - 118550, 118555, 118556, 118535, 118547, 118537, 118549, 118553, 118558, - 118534, 118546, 118572, 118562, 118571, 118554, 118533, 118545, 118587, - 118588, 118530, 118542, 118552, 118563, 118539, 118551, 118557, 118536, - 118548, 118579, 118570, 118560, 118567, 118565, 118564, 118590, 118576, - 118577, 118578, 118619, 118639, 118637, 118645, 118721, 118611, 118635, - 118659, 118626, 118623, 118625, 118624, 118622, 118638, 118612, 118660, - 118608, 118609, 118657, 118719, 118695, 118699, 118698, 118697, 118696, - 118722, 118720, 118703, 118708, 118707, 118706, 118705, 118704, 118610, - 118620, 118723, 118616, 118617, 118640, 118672, 118636, 118658, 118652, - 118651, 118649, 118650, 118648, 118646, 118647, 118644, 118643, 118641, - 118642, 118653, 118656, 118654, 118655, 118662, 118670, 118664, 118666, - 118669, 118663, 118665, 118671, 118667, 118668, 118673, 118614, 118615, - 118618, 118685, 118687, 118684, 118683, 118686, 118681, 118680, 118709, - 118713, 118711, 118716, 118717, 118714, 118715, 118712, 118718, 118710, - 118676, 118679, 118690, 118688, 118693, 118694, 118691, 118692, 118689, - 118675, 118677, 118678, 118674, 118701, 118702, 118700, 118682, 118632, - 118631, 118634, 118633, 118628, 118627, 118630, 118629, 118613, 118621, - 118661, 118596, 118597, 118594, 118595, 118598, 129503, 983264, 983222, - 983221, 983223, + 9786, 9828, 9633, 128307, 128916, 9635, 128917, 129018, 129019, 9093, + 129020, 10212, 9713, 9714, 10213, 9634, 9712, 9715, 9707, 127779, 127781, + 127782, 9788, 127780, 9734, 128382, 9743, 9186, 10177, 9943, 128070, + 9757, 129994, 9653, 9651, 9708, 11055, 9647, 118278, 11006, 11038, 10163, + 128011, 129144, 129152, 129120, 129136, 129128, 129146, 129154, 129122, + 129138, 129130, 129147, 129155, 129123, 129139, 129131, 129145, 129153, + 129121, 129137, 129129, 129149, 129157, 129125, 129141, 129133, 129148, + 129156, 129124, 129140, 129132, 129150, 129158, 129126, 129142, 129134, + 129151, 129159, 129127, 129143, 129135, 11872, 11838, 129344, 127888, + 127788, 129695, 127863, 128521, 129725, 128430, 128732, 128105, 128111, + 128098, 128090, 128097, 128082, 128698, 11825, 8288, 128506, 128543, + 129713, 8361, 129717, 128058, 127873, 8768, 129340, 128295, 9997, 983233, + 8999, 129659, 129644, 129643, 129641, 129639, 129642, 129645, 129640, + 129637, 129636, 129634, 129632, 129635, 129638, 129633, 8891, 94196, + 94197, 94198, 129393, 128155, 165, 69292, 69291, 69293, 69256, 69255, + 69254, 69281, 69268, 69259, 69248, 69271, 69289, 69286, 69287, 69257, + 69278, 69277, 69279, 69276, 69280, 69296, 69282, 69251, 69250, 69266, + 69265, 69267, 69253, 69252, 69269, 69274, 69275, 69284, 69285, 69272, + 69258, 69288, 69297, 69263, 69260, 69270, 69262, 69261, 69249, 69283, + 69273, 69264, 42139, 42149, 42173, 42172, 42132, 42147, 42179, 42174, + 42148, 42169, 42150, 42134, 42166, 42135, 42145, 42143, 42137, 42175, + 42157, 42154, 42167, 42165, 42163, 42130, 42182, 42129, 42171, 42138, + 42140, 42136, 42131, 42151, 42164, 42181, 42142, 42156, 42170, 42176, + 42178, 42160, 42133, 42144, 42152, 42159, 42161, 42158, 42141, 42146, + 42177, 42180, 42155, 42162, 42128, 42168, 42153, 41070, 41059, 41060, + 41058, 41073, 41072, 41071, 41068, 41069, 41066, 41067, 41065, 41048, + 41052, 41053, 41050, 41051, 41049, 41046, 41047, 41056, 41057, 41054, + 41055, 41063, 41064, 41061, 41062, 41076, 41077, 41074, 41075, 41006, + 40995, 40996, 40994, 41009, 41008, 41007, 41004, 41005, 41002, 41003, + 41001, 40984, 40988, 40989, 40986, 40987, 40985, 40982, 40983, 40992, + 40993, 40990, 40991, 40999, 41000, 40997, 40998, 41012, 41015, 41014, + 41013, 41010, 41011, 41842, 41831, 41832, 41829, 41830, 41845, 41844, + 41843, 41841, 41827, 41828, 41825, 41826, 41839, 41840, 41837, 41838, + 41835, 41836, 41833, 41834, 41848, 41851, 41850, 41849, 41846, 41847, + 41670, 41659, 41660, 41658, 41673, 41672, 41671, 41668, 41669, 41666, + 41667, 41665, 41648, 41652, 41653, 41650, 41651, 41649, 41646, 41647, + 41656, 41657, 41654, 41655, 41663, 41664, 41661, 41662, 41676, 41679, + 41678, 41677, 41674, 41675, 41293, 41282, 41283, 41281, 41296, 41295, + 41294, 41291, 41292, 41272, 41275, 41276, 41274, 41273, 41270, 41271, + 41289, 41290, 41288, 41279, 41280, 41277, 41278, 41286, 41287, 41284, + 41285, 41238, 41228, 41227, 41241, 41240, 41239, 41236, 41237, 41218, + 41221, 41222, 41220, 41219, 41216, 41217, 41234, 41235, 41233, 41225, + 41226, 41223, 41224, 41231, 41232, 41229, 41230, 41174, 41175, 41173, + 41171, 41172, 41169, 41170, 41167, 41168, 41165, 41166, 41184, 41185, + 41182, 41183, 41178, 41181, 41180, 41179, 41176, 41177, 41494, 41496, + 41497, 41495, 41492, 41493, 41516, 41504, 41505, 41502, 41503, 41519, + 41518, 41517, 41514, 41515, 41500, 41501, 41498, 41499, 41512, 41513, + 41510, 41511, 41508, 41509, 41506, 41507, 41460, 41448, 41449, 41446, + 41447, 41463, 41462, 41461, 41458, 41459, 41436, 41440, 41441, 41438, + 41439, 41437, 41434, 41435, 41444, 41445, 41442, 41443, 41456, 41457, + 41454, 41455, 41452, 41453, 41450, 41451, 41584, 41583, 41582, 41389, + 41379, 41380, 41378, 41392, 41391, 41390, 41387, 41388, 41369, 41372, + 41373, 41371, 41370, 41367, 41368, 41385, 41386, 41384, 41382, 41383, + 41381, 41376, 41377, 41374, 41375, 41395, 41398, 41397, 41396, 41393, + 41394, 41125, 41117, 41118, 41116, 41128, 41127, 41126, 41123, 41124, + 41107, 41110, 41111, 41109, 41108, 41105, 41106, 41114, 41115, 41112, + 41113, 41121, 41122, 41119, 41120, 41130, 41133, 41132, 41131, 41129, + 41336, 41334, 41335, 41333, 41332, 41340, 41338, 41339, 41337, 41322, + 41326, 41327, 41324, 41325, 41323, 41320, 41321, 41330, 41331, 41328, + 41329, 41556, 41557, 41554, 41555, 41563, 41564, 41562, 41544, 41548, + 41549, 41546, 41547, 41545, 41542, 41543, 41552, 41553, 41550, 41551, + 41560, 41561, 41558, 41559, 41591, 41592, 41589, 41590, 41598, 41599, + 41597, 41587, 41588, 41585, 41586, 41595, 41596, 41593, 41594, 40962, + 40960, 983243, 40966, 40967, 40964, 40965, 40963, 40961, 42025, 42017, + 42018, 42016, 42028, 42027, 42026, 42023, 42024, 42010, 42014, 42015, + 42012, 42013, 42011, 42008, 42009, 42021, 42022, 42019, 42020, 42031, + 42032, 42029, 42030, 41970, 41962, 41963, 41960, 41961, 41973, 41972, + 41971, 41968, 41969, 41954, 41958, 41959, 41956, 41957, 41955, 41952, + 41953, 41966, 41967, 41964, 41965, 41976, 41979, 41978, 41977, 41974, + 41975, 41488, 41476, 41477, 41475, 41491, 41490, 41489, 41486, 41487, + 41466, 41469, 41470, 41468, 41467, 41464, 41465, 41473, 41474, 41471, + 41472, 41484, 41485, 41482, 41483, 41480, 41481, 41478, 41479, 41424, + 41413, 41414, 41411, 41412, 41427, 41426, 41425, 41422, 41423, 41420, + 41421, 41419, 41401, 41405, 41406, 41403, 41404, 41402, 41399, 41400, + 41409, 41410, 41407, 41408, 41417, 41418, 41415, 41416, 41430, 41433, + 41432, 41431, 41428, 41429, 41538, 41527, 41528, 41526, 41541, 41540, + 41539, 41536, 41537, 41534, 41535, 41533, 41524, 41525, 41522, 41523, + 41531, 41532, 41529, 41530, 41521, 41520, 41157, 41147, 41148, 41145, + 41146, 41160, 41159, 41158, 41155, 41156, 41136, 41139, 41140, 41138, + 41137, 41134, 41135, 41143, 41144, 41141, 41142, 41151, 41152, 41149, + 41150, 41163, 41164, 41161, 41162, 41154, 41153, 41080, 41083, 41084, + 41082, 41081, 41078, 41079, 41087, 41088, 41085, 41086, 41091, 41092, + 41089, 41090, 41095, 41098, 41097, 41096, 41093, 41094, 41101, 41104, + 41103, 41102, 41099, 41100, 41299, 41302, 41301, 41300, 41297, 41298, + 41312, 41313, 41311, 41305, 41306, 41303, 41304, 41309, 41310, 41307, + 41308, 41316, 41319, 41318, 41317, 41314, 41315, 41574, 41572, 41573, + 41580, 41581, 41579, 41566, 41567, 41565, 41570, 41571, 41568, 41569, + 41577, 41578, 41575, 41576, 42048, 42042, 42041, 42051, 42050, 42049, + 42047, 42035, 42039, 42040, 42037, 42038, 42036, 42033, 42034, 42045, + 42046, 42043, 42044, 42054, 42057, 42056, 42055, 42052, 42053, 41881, + 41882, 41880, 41878, 41879, 41876, 41877, 41885, 41886, 41883, 41884, + 41889, 41892, 41891, 41890, 41887, 41888, 41895, 41898, 41897, 41896, + 41893, 41894, 42075, 42067, 42068, 42066, 42076, 42073, 42074, 42060, + 42064, 42065, 42062, 42063, 42061, 42058, 42059, 42071, 42072, 42069, + 42070, 41727, 41721, 41720, 41730, 41729, 41728, 41726, 41723, 41722, + 41711, 41714, 41715, 41713, 41712, 41709, 41710, 41718, 41719, 41716, + 41717, 41733, 41736, 41735, 41734, 41731, 41732, 41725, 41724, 41363, + 41352, 41353, 41351, 41366, 41365, 41364, 41361, 41362, 41343, 41346, + 41347, 41345, 41344, 41341, 41342, 41349, 41350, 41348, 41359, 41360, + 41358, 41356, 41357, 41354, 41355, 41036, 41028, 41029, 41027, 41039, + 41038, 41037, 41034, 41035, 41018, 41021, 41022, 41020, 41019, 41016, + 41017, 41025, 41026, 41023, 41024, 41032, 41033, 41030, 41031, 41042, + 41045, 41044, 41043, 41040, 41041, 41998, 41990, 41991, 41988, 41989, + 42001, 42000, 41999, 41996, 41997, 41982, 41986, 41987, 41984, 41985, + 41983, 41980, 41981, 41994, 41995, 41992, 41993, 42004, 42007, 42006, + 42005, 42002, 42003, 42115, 42107, 42108, 42105, 42106, 42118, 42117, + 42116, 42113, 42114, 42099, 42103, 42104, 42101, 42102, 42100, 42097, + 42098, 42111, 42112, 42109, 42110, 42121, 42124, 42123, 42122, 42119, + 42120, 41866, 41855, 41854, 41869, 41868, 41867, 41864, 41865, 41862, + 41863, 41860, 41861, 41858, 41859, 41856, 41857, 41872, 41875, 41874, + 41873, 41870, 41871, 41853, 41852, 41942, 41931, 41932, 41930, 41945, + 41944, 41943, 41940, 41941, 41938, 41939, 41937, 41928, 41929, 41926, + 41927, 41935, 41936, 41933, 41934, 41948, 41951, 41950, 41949, 41946, + 41947, 41772, 41775, 41776, 41774, 41773, 41770, 41771, 41786, 41787, + 41785, 41779, 41780, 41777, 41778, 41783, 41784, 41781, 41782, 41790, + 41791, 41788, 41789, 41794, 41797, 41796, 41795, 41792, 41793, 41916, + 41904, 41905, 41903, 41919, 41918, 41917, 41914, 41915, 41901, 41902, + 41899, 41900, 41912, 41913, 41910, 41911, 41908, 41909, 41906, 41907, + 41922, 41925, 41924, 41923, 41920, 41921, 41760, 41749, 41750, 41748, + 41763, 41762, 41761, 41758, 41759, 41739, 41742, 41743, 41741, 41740, + 41737, 41738, 41756, 41757, 41755, 41746, 41747, 41744, 41745, 41753, + 41754, 41751, 41752, 41766, 41769, 41768, 41767, 41764, 41765, 41266, + 41255, 41256, 41253, 41254, 41269, 41268, 41267, 41264, 41265, 41244, + 41247, 41248, 41246, 41245, 41242, 41243, 41262, 41263, 41261, 41251, + 41252, 41249, 41250, 41259, 41260, 41257, 41258, 41203, 41202, 41188, + 41192, 41193, 41190, 41191, 41189, 41186, 41187, 41196, 41197, 41194, + 41195, 41200, 41201, 41198, 41199, 41206, 41209, 41208, 41207, 41204, + 41205, 41212, 41215, 41214, 41213, 41210, 41211, 40981, 41605, 41606, + 41604, 41611, 41612, 41610, 41608, 41609, 41607, 41602, 41603, 41600, + 41601, 42079, 42083, 42084, 42081, 42082, 42080, 42077, 42078, 42089, + 42090, 42087, 42088, 42093, 42096, 42095, 42094, 42091, 42092, 42086, + 42085, 41815, 41803, 41804, 41802, 41818, 41817, 41816, 41813, 41814, + 41800, 41801, 41798, 41799, 41811, 41812, 41809, 41810, 41807, 41808, + 41805, 41806, 41821, 41824, 41823, 41822, 41819, 41820, 41636, 41625, + 41626, 41624, 41639, 41638, 41637, 41634, 41635, 41615, 41618, 41619, + 41617, 41616, 41613, 41614, 41696, 41697, 41695, 41693, 41694, 41692, + 41682, 41686, 41687, 41684, 41685, 41683, 41680, 41681, 41690, 41691, + 41688, 41689, 41699, 41702, 41701, 41700, 41698, 41705, 41708, 41707, + 41706, 41703, 41704, 41632, 41633, 41631, 41622, 41623, 41620, 41621, + 41629, 41630, 41627, 41628, 41642, 41645, 41644, 41643, 41640, 41641, + 40973, 40974, 40972, 40970, 40971, 40968, 40969, 40977, 40978, 40975, + 40976, 40980, 40979, 9775, 129664, 8959, 10853, 10632, 10634, 10814, + 10852, 10631, 10633, 10783, 10784, 10785, 10625, 10626, 72262, 72256, + 72253, 72252, 72254, 72251, 72250, 72261, 72255, 72243, 72215, 72214, + 72230, 72229, 72220, 72219, 72242, 72204, 72203, 72207, 72216, 72211, + 72221, 72238, 72239, 72240, 72228, 72227, 72213, 72212, 72218, 72217, + 72225, 72224, 72209, 72208, 72206, 72205, 72223, 72222, 72231, 72232, + 72233, 72241, 72210, 72236, 72226, 72235, 72237, 72234, 72192, 72259, + 72258, 72260, 72257, 72248, 72245, 72246, 72247, 72244, 72249, 72263, + 72202, 72199, 72200, 72198, 72197, 72195, 72194, 72201, 72196, 72193, + 129427, 65279, 8204, 8203, 8205, 11234, 129296, 118593, 118584, 118585, + 118591, 118580, 118589, 118528, 118540, 118531, 118543, 118559, 118529, + 118541, 118532, 118544, 118592, 118573, 118569, 118568, 118581, 118586, + 118561, 118582, 118583, 118566, 118538, 118550, 118555, 118556, 118535, + 118547, 118537, 118549, 118553, 118558, 118534, 118546, 118572, 118562, + 118571, 118554, 118533, 118545, 118587, 118588, 118530, 118542, 118552, + 118563, 118539, 118551, 118557, 118536, 118548, 118579, 118570, 118560, + 118567, 118565, 118564, 118590, 118576, 118577, 118578, 118619, 118639, + 118637, 118645, 118721, 118611, 118635, 118659, 118626, 118623, 118625, + 118624, 118622, 118638, 118612, 118660, 118608, 118609, 118657, 118719, + 118695, 118699, 118698, 118697, 118696, 118722, 118720, 118703, 118708, + 118707, 118706, 118705, 118704, 118610, 118620, 118723, 118616, 118617, + 118640, 118672, 118636, 118658, 118652, 118651, 118649, 118650, 118648, + 118646, 118647, 118644, 118643, 118641, 118642, 118653, 118656, 118654, + 118655, 118662, 118670, 118664, 118666, 118669, 118663, 118665, 118671, + 118667, 118668, 118673, 118614, 118615, 118618, 118685, 118687, 118684, + 118683, 118686, 118681, 118680, 118709, 118713, 118711, 118716, 118717, + 118714, 118715, 118712, 118718, 118710, 118676, 118679, 118690, 118688, + 118693, 118694, 118691, 118692, 118689, 118675, 118677, 118678, 118674, + 118701, 118702, 118700, 118682, 118632, 118631, 118634, 118633, 118628, + 118627, 118630, 118629, 118613, 118621, 118661, 118596, 118597, 118594, + 118595, 118598, 129503, 983264, 983222, 983221, 983223, }; #define DAWG_CODEPOINT_TO_POS_SHIFT 8 -#define DAWG_CODEPOINT_TO_POS_NOTFOUND 35536 +#define DAWG_CODEPOINT_TO_POS_NOTFOUND 36293 static const unsigned char dawg_codepoint_to_pos_index1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, @@ -12821,20 +13120,20 @@ static const unsigned char dawg_codepoint_to_pos_index1[] = { 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 52, 52, 52, 52, 52, 52, 52, 52, 52, 110, 111, 112, - 113, 114, 115, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 116, 117, 118, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 119, 52, 52, 52, 52, - 52, 52, 120, 121, 122, 123, 52, 124, 125, 126, 52, 52, 52, 52, 52, 52, + 106, 107, 108, 109, 110, 52, 52, 52, 52, 52, 52, 52, 52, 111, 112, 113, + 114, 115, 116, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 117, 118, 119, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 120, 52, 52, 52, 52, + 52, 52, 121, 122, 123, 124, 52, 125, 126, 127, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 127, 128, 129, 52, 52, 130, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 128, 129, 130, 52, 52, 131, 52, 52, 52, 132, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 131, 132, 133, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 134, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 135, - 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 52, - 52, 52, 52, 150, 151, 152, 153, 52, 154, 155, 156, 157, 158, 159, 52, 52, - 160, 161, 162, 52, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, - 174, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 133, 134, 135, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 136, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 137, + 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, + 152, 52, 52, 52, 153, 154, 155, 156, 52, 157, 158, 159, 160, 161, 162, + 52, 52, 163, 164, 165, 52, 166, 167, 168, 169, 170, 171, 172, 173, 174, + 175, 176, 177, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, @@ -13004,9 +13303,8 @@ static const unsigned char dawg_codepoint_to_pos_index1[] = { 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 175, - 176, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 178, 179, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, @@ -13019,8 +13317,8 @@ static const unsigned char dawg_codepoint_to_pos_index1[] = { 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 177, 178, 179, 180, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 180, 181, 182, 183, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, @@ -13047,4461 +13345,4540 @@ static const unsigned char dawg_codepoint_to_pos_index1[] = { 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, }; static const unsigned short dawg_codepoint_to_pos_index2[] = { - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 28435, 12481, 26055, 24148, 10207, 25626, 371, 1054, 18841, - 26279, 2570, 25877, 7571, 15612, 12664, 28274, 9990, 9975, 9987, 9984, - 9969, 9966, 9981, 9978, 9993, 9972, 7147, 26889, 19084, 11917, 13295, - 26053, 7570, 17426, 17472, 17482, 17498, 17515, 17560, 17564, 17581, - 17595, 17624, 17629, 17641, 17661, 17670, 17686, 17736, 17745, 17748, - 17769, 17793, 17822, 17861, 17872, 17881, 17884, 17898, 18803, 26180, - 26293, 6924, 19857, 13266, 17990, 18040, 18060, 18083, 18119, 18178, - 18186, 18204, 18223, 18260, 18266, 18280, 18319, 18332, 18356, 18413, - 18425, 18431, 18469, 18511, 18584, 18632, 18646, 18655, 18663, 18679, - 18744, 33411, 26242, 31817, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 24142, 15966, 6233, - 25919, 9069, 33983, 5039, 26871, 9957, 7765, 12560, 18851, 24122, 28225, - 26103, 21543, 9672, 25889, 29061, 29060, 4, 22274, 25774, 22280, 6229, - 29064, 20510, 26340, 33545, 33543, 33551, 15969, 17455, 17456, 17444, - 17458, 17437, 17439, 17460, 17483, 17546, 17547, 17518, 17533, 17611, - 17612, 17601, 17599, 17557, 17684, 17725, 17726, 17693, 17711, 17700, - 22987, 17709, 17853, 17854, 17823, 17826, 17893, 17814, 18501, 18021, - 18022, 18010, 18024, 18001, 18003, 18027, 18061, 18152, 18153, 18122, - 18137, 18241, 18242, 18224, 18226, 18177, 18351, 18395, 18396, 18357, - 18381, 18364, 10118, 18379, 18619, 18622, 18587, 18590, 18674, 18533, - 18665, 17442, 18008, 17427, 17991, 17452, 18018, 17487, 18066, 17485, - 18063, 17491, 18071, 17486, 18065, 17505, 18091, 17502, 18085, 17536, - 18141, 17549, 18155, 17528, 18132, 17543, 18149, 17527, 18131, 17566, - 18188, 17569, 18191, 17573, 18196, 17565, 18187, 17584, 18207, 17591, - 18216, 17605, 18238, 17603, 18233, 17614, 18244, 17608, 18235, 17598, - 18107, 17910, 18699, 17625, 18261, 17630, 18267, 18279, 17655, 18297, - 17651, 18284, 17653, 18287, 17648, 18294, 17650, 18305, 17679, 18344, - 17671, 18333, 17673, 18337, 18352, 17559, 18160, 17689, 18374, 17728, - 18398, 17706, 18370, 17911, 18702, 17757, 18448, 17749, 18432, 17750, - 18434, 17775, 18470, 17774, 18476, 17772, 18474, 17770, 18472, 17794, - 18512, 17797, 18516, 17804, 18528, 17850, 18616, 17842, 18606, 17856, - 18624, 17857, 18615, 17833, 18597, 17847, 18611, 17873, 18647, 17885, - 18664, 17886, 17901, 18680, 17904, 18686, 17900, 18683, 18311, 18049, - 17478, 17473, 18041, 17817, 18536, 17731, 17489, 18069, 17464, 17510, - 17506, 18086, 18541, 17766, 17792, 17730, 17561, 18181, 17572, 17579, - 18222, 17622, 17615, 17640, 18278, 18283, 18307, 17811, 17677, 18338, - 17692, 17718, 18388, 17733, 18410, 17742, 18421, 17987, 17819, 18538, - 17558, 17928, 18524, 17803, 18525, 17802, 17835, 18599, 17860, 17865, - 17890, 18669, 17907, 18689, 17551, 17553, 18170, 18175, 17980, 17818, - 18537, 17926, 17981, 17982, 17983, 17919, 17930, 17512, 17500, 18113, - 17660, 17649, 18318, 17685, 17674, 18355, 17450, 18016, 17602, 18225, - 17699, 18363, 17825, 18589, 17830, 18594, 17829, 18593, 17827, 18591, - 17828, 18592, 18573, 17438, 18002, 17434, 17998, 17462, 18030, 17574, - 18197, 17567, 18189, 17631, 18268, 17707, 18377, 17708, 18378, 17552, - 18172, 18263, 17511, 17499, 18112, 17568, 18190, 17593, 17880, 17678, - 18343, 17440, 18004, 17461, 18029, 17710, 18380, 17436, 18000, 17457, - 18023, 17532, 18136, 17548, 18154, 17596, 18232, 17613, 18243, 17705, - 18369, 17727, 18397, 17754, 18438, 17759, 18449, 17832, 18596, 17855, - 18623, 17773, 18475, 17796, 18514, 17897, 18678, 17585, 18208, 17675, - 18090, 17735, 18412, 17909, 18693, 17433, 17997, 17516, 18120, 17701, - 18365, 17714, 18384, 17702, 18366, 17703, 18367, 17894, 18675, 18286, - 18336, 18515, 18104, 18117, 18430, 17459, 17492, 18072, 17643, 17798, - 18483, 18688, 17575, 18198, 17479, 17859, 17813, 17550, 18157, 17628, - 18265, 17786, 18428, 17761, 18452, 17896, 18673, 18565, 18032, 18566, - 18048, 18401, 18064, 18087, 18095, 18461, 18492, 18496, 18407, 18456, - 18458, 18079, 18105, 18195, 18499, 17957, 18202, 18468, 18542, 18215, - 18221, 18245, 18256, 17935, 18292, 18281, 18300, 18308, 18568, 18569, - 18327, 18340, 18349, 17968, 18052, 17942, 18078, 18424, 18553, 18556, - 18559, 18443, 18445, 18439, 18459, 17944, 17936, 18489, 18163, 18106, - 18509, 18167, 18560, 18527, 18585, 18626, 18639, 18562, 18577, 18570, - 17975, 18692, 18682, 18169, 18171, 17984, 17927, 17924, 17977, 17922, - 17955, 18077, 17958, 17964, 18262, 18575, 17937, 18427, 17985, 17929, - 18114, 18100, 18115, 18580, 18529, 18579, 18184, 18315, 18316, 17921, - 17923, 18543, 18544, 22605, 22606, 22614, 22636, 22663, 22666, 22561, - 22683, 22685, 22534, 22477, 22691, 22387, 22542, 22544, 22520, 22493, - 22540, 22522, 22546, 22693, 22479, 22469, 6162, 22697, 22523, 22386, - 22492, 22518, 22509, 22515, 22514, 22690, 22500, 22421, 22420, 22692, - 22478, 22533, 22531, 5032, 10313, 26472, 24282, 28183, 10372, 22547, - 22470, 22604, 22616, 22643, 22684, 22640, 22484, 22499, 22527, 22512, - 22489, 22699, 22698, 22696, 22694, 22476, 22505, 22517, 22507, 22510, - 22511, 22530, 22529, 22528, 22513, 22539, 22389, 22490, 22390, 22491, - 22549, 22532, 22506, 7365, 7154, 7238, 7540, 7475, 7498, 7164, 7264, - 7260, 7379, 7524, 7274, 7170, 7556, 7296, 7297, 7172, 7382, 7548, 7175, - 7506, 7176, 7366, 7155, 7459, 7519, 7449, 7381, 7456, 7549, 7300, 7503, - 7486, 7502, 7507, 7267, 7261, 7523, 7177, 7240, 7496, 7555, 7167, 7386, - 7171, 7239, 7166, 7383, 7544, 7480, 7474, 7298, 7543, 7528, 7472, 7527, - 7471, 7514, 7384, 7532, 7537, 7568, 7557, 7284, 7367, 7156, 7376, 7375, - 7378, 7377, 7168, 7310, 7295, 7448, 7489, 7380, 7163, 7461, 7551, 7371, - 7510, 7457, 7312, 7567, 7450, 7511, 7509, 7515, 7266, 7160, 7290, 7526, - 7276, 7275, 7281, 7282, 7291, 7277, 7288, 7399, 7407, 7412, 7420, 7423, - 7405, 7437, 7439, 7441, 7426, 7429, 7444, 7445, 13480, 13744, 13375, - 13611, 13562, 13558, 13469, 13726, 35536, 35536, 13801, 13751, 13752, - 13750, 13806, 13483, 35536, 35536, 35536, 35536, 13766, 13496, 13373, - 13349, 13406, 13396, 13420, 35536, 13452, 35536, 13467, 13442, 13658, - 13352, 13479, 13477, 13475, 13397, 13481, 13376, 13473, 13407, 13476, - 13482, 13484, 13485, 13486, 13443, 13472, 13453, 35536, 13455, 13474, - 13458, 13470, 13478, 13471, 13422, 13412, 13463, 13608, 13623, 13648, - 13667, 13678, 13583, 13743, 13741, 13613, 13614, 13745, 13624, 13738, - 13649, 13689, 13746, 13747, 13748, 13749, 13716, 13729, 13730, 13740, - 13736, 13739, 13669, 13727, 13742, 13728, 13691, 13654, 13674, 13725, - 13687, 13715, 13491, 13803, 13762, 13770, 13768, 13769, 13578, 13579, - 13543, 13554, 13610, 13553, 13735, 13556, 13612, 13555, 13690, 13552, - 13733, 7646, 7740, 7624, 7718, 7620, 7714, 7618, 7712, 7616, 7710, 7645, - 7739, 7615, 7709, 13542, 13581, 13559, 13557, 13492, 13560, 13582, 13457, - 13737, 13487, 13456, 13734, 13580, 13489, 13490, 13488, 9336, 9338, 9285, - 9324, 9260, 9289, 9276, 9395, 9408, 9231, 9234, 9248, 9363, 9333, 9376, - 9293, 9261, 9277, 9409, 9318, 9297, 9335, 9402, 9398, 9331, 9374, 9348, - 9299, 9315, 9304, 9367, 9235, 9310, 9313, 9245, 9255, 9317, 9325, 9251, - 9278, 9381, 9379, 9329, 9392, 9384, 9298, 9397, 9389, 9420, 9436, 9610, - 9477, 9456, 9494, 9603, 9599, 9490, 9552, 9507, 9458, 9474, 9463, 9533, - 9538, 9469, 9472, 9570, 9581, 9476, 9484, 9576, 9437, 9559, 9557, 9488, - 9593, 9562, 9457, 9598, 9590, 9495, 9497, 9444, 9483, 9586, 9448, 9435, - 9596, 9609, 9526, 9532, 9573, 9522, 9492, 9554, 9452, 9368, 9534, 9391, - 9592, 9344, 9503, 9230, 9524, 9340, 9499, 9273, 9432, 9341, 9500, 9364, - 9523, 9238, 9542, 9407, 9608, 9346, 9505, 9347, 9506, 9259, 9585, 9239, - 9547, 9369, 9535, 9371, 9537, 9361, 9520, 9641, 7231, 7225, 7228, 7226, - 7227, 7181, 7234, 9375, 9553, 9388, 9566, 9311, 9470, 9320, 9479, 9322, - 9481, 9319, 9478, 9404, 9605, 9400, 9601, 9349, 9508, 9351, 9510, 9352, - 9511, 9271, 9430, 9306, 9465, 9414, 9614, 9236, 9539, 9267, 9426, 9314, - 9473, 9247, 9572, 9386, 9564, 9387, 9565, 9326, 9485, 9413, 9613, 9280, - 9439, 9281, 9440, 9377, 9555, 9264, 9423, 9265, 9424, 9417, 9405, 9606, - 9350, 9509, 9302, 9461, 9309, 9468, 9308, 9467, 9362, 9521, 9316, 9475, - 9541, 9263, 9422, 9262, 9421, 9412, 9612, 9337, 9496, 9372, 9550, 9373, - 9551, 9403, 9604, 9399, 9600, 9266, 9425, 9334, 9493, 9332, 9491, 9370, - 9536, 9269, 9428, 9270, 9429, 9312, 9471, 9258, 9584, 9257, 9583, 9256, - 9582, 9279, 9438, 9321, 9480, 9393, 9594, 9323, 9482, 9327, 9486, 9328, - 9487, 9355, 9514, 9354, 9513, 9360, 9519, 9353, 9512, 9356, 9515, 9357, - 9516, 9358, 9517, 9359, 9518, 9243, 9546, 9303, 9462, 9232, 9527, 9244, - 9549, 9390, 9591, 9411, 9611, 9410, 9589, 9268, 9427, 9300, 9459, 9305, - 9464, 9237, 9540, 9378, 9556, 9307, 9466, 9291, 9450, 9295, 9454, 9301, - 9460, 35536, 2488, 2495, 2479, 2501, 2475, 2499, 2476, 2477, 2466, 2498, - 2494, 2491, 2493, 2471, 2483, 2500, 2481, 2478, 2469, 2496, 2467, 2497, - 2486, 2490, 2470, 2485, 2480, 2474, 2487, 2489, 2465, 2473, 2472, 2468, - 2484, 2482, 2502, 2492, 35536, 35536, 2552, 2464, 2505, 2504, 2503, 2556, - 2463, 2525, 2528, 2538, 2516, 2544, 2512, 2542, 2513, 2514, 2527, 2541, - 2537, 2534, 2536, 2508, 2520, 2543, 2518, 2515, 2506, 2539, 2531, 2540, - 2523, 2530, 2507, 2522, 2517, 2511, 2524, 2529, 2526, 2510, 2509, 2533, - 2521, 2519, 2545, 2535, 2546, 2532, 2555, 2553, 35536, 35536, 26327, - 18864, 2554, 35536, 14954, 14957, 14958, 14965, 14966, 14962, 14969, - 14967, 14952, 14964, 14961, 14945, 14946, 14947, 14955, 14960, 14953, - 14942, 14950, 14951, 14948, 14949, 14944, 14956, 14959, 14963, 14970, - 14971, 14943, 14968, 15049, 15064, 15053, 15051, 15052, 15054, 15066, - 15062, 15057, 15058, 15055, 15056, 15060, 15050, 15068, 15074, 15061, - 15071, 15063, 15065, 15072, 15048, 15047, 15073, 15059, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 14972, 14979, 15022, 15020, - 14997, 15028, 15002, 14999, 15014, 15039, 14988, 14982, 15024, 14994, - 15026, 14993, 15000, 15004, 14978, 14990, 14985, 14992, 15018, 14995, - 15012, 15006, 15016, 35536, 35536, 35536, 35536, 15075, 15043, 15046, - 15044, 15070, 15069, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 2306, 2340, 1099, 2341, 2342, 2305, 2451, - 2452, 2317, 2449, 2450, 2644, 1067, 1080, 2312, 2346, 2339, 2345, 2337, - 2338, 2347, 2365, 2353, 2382, 2349, 2401, 2400, 2333, 1387, 1089, 2439, - 2447, 1342, 1294, 1157, 1147, 1577, 1150, 1593, 1129, 1171, 1519, 1518, - 1541, 1320, 1279, 1361, 1196, 1536, 1440, 1620, 1474, 1487, 1466, 1212, - 1496, 1615, 1119, 1266, 1348, 1345, 1241, 1240, 1239, 2427, 1246, 1431, - 1331, 1366, 1379, 1403, 1296, 1572, 1165, 1584, 1097, 1078, 1109, 1091, - 1074, 1105, 2334, 2404, 2159, 1104, 1103, 2403, 2323, 2160, 2448, 2443, - 2442, 2444, 2318, 1092, 2446, 2459, 2461, 2458, 2457, 2454, 2453, 2456, - 2455, 2462, 2460, 2310, 1085, 2441, 1100, 1224, 1226, 1493, 1162, 1154, - 1153, 1316, 1317, 1319, 1558, 1318, 1546, 1552, 1191, 1527, 1526, 1419, - 1531, 1186, 1289, 1287, 1398, 1227, 1286, 1506, 1513, 1221, 1206, 1203, - 1204, 1209, 1218, 1232, 1199, 1205, 1457, 1443, 1454, 1451, 1444, 1452, - 1447, 1328, 1450, 1475, 1478, 1479, 1469, 1468, 1500, 1122, 1225, 1249, - 1247, 1565, 1251, 1426, 1434, 1435, 1343, 1495, 1337, 1336, 1388, 1334, - 1257, 1260, 1389, 1259, 1273, 1258, 1370, 1368, 1372, 1371, 1414, 1404, - 1460, 1412, 1409, 1307, 1508, 1304, 1297, 1298, 1522, 1581, 1355, 1612, - 1557, 1609, 1358, 1580, 1564, 1235, 1603, 1598, 1574, 1624, 1602, 1585, - 1588, 1101, 1170, 2356, 2355, 2358, 2357, 2384, 2364, 2362, 1090, 2426, - 2381, 2380, 2350, 2359, 2399, 2360, 2402, 2387, 2376, 2378, 2314, 1088, - 1087, 2322, 2398, 1198, 1448, 12501, 12503, 12500, 12499, 12496, 12495, - 12498, 12497, 12504, 12502, 1488, 1213, 1268, 2344, 2343, 1303, 29191, - 29265, 29262, 29263, 29259, 29200, 29187, 29188, 29264, 29261, 29186, - 29196, 29195, 29194, 35536, 29184, 29232, 29228, 29242, 29238, 29239, - 29202, 29201, 29203, 29245, 29243, 29204, 29235, 29236, 29240, 29241, - 29233, 29205, 29217, 29244, 29224, 29231, 29246, 29218, 29222, 29230, - 29234, 29223, 29229, 29237, 29219, 29221, 29220, 29251, 29250, 29249, - 29254, 29253, 29252, 29256, 29255, 29190, 29189, 29199, 29198, 29197, - 29193, 29192, 29257, 29271, 29272, 29258, 29269, 29268, 29267, 29266, - 29248, 29247, 29270, 29185, 35536, 35536, 29225, 29226, 29227, 1177, - 1180, 1175, 1176, 1178, 1179, 1173, 1288, 1285, 1202, 1197, 1445, 1481, - 1124, 1120, 1123, 1252, 1250, 1350, 1346, 1344, 1382, 1381, 1410, 1407, - 1408, 1373, 1446, 1449, 1480, 1284, 1282, 1477, 1441, 1283, 1156, 1155, - 1238, 1237, 1236, 1576, 1575, 1587, 1586, 1280, 1482, 1476, 1333, 31385, - 31398, 31394, 31411, 31410, 31389, 31386, 31374, 31405, 31390, 31379, - 31378, 31401, 31388, 31381, 31382, 31399, 31377, 31407, 31400, 31412, - 31393, 31392, 31391, 31403, 31384, 31387, 31402, 31408, 31397, 31396, - 31376, 31404, 31409, 31375, 31383, 31380, 31406, 31370, 31369, 31416, - 31372, 31417, 31415, 31371, 31373, 31414, 31413, 31418, 31395, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 24006, 24008, 24005, 24004, 24001, 24000, 24003, - 24002, 24009, 24007, 24041, 24028, 24042, 24027, 24043, 24025, 24024, - 24012, 24017, 24030, 24036, 24038, 24016, 24026, 24011, 24023, 24022, - 24037, 24029, 24031, 24033, 24034, 24019, 24035, 24020, 24018, 24032, - 24039, 24040, 24021, 24014, 24013, 24015, 23994, 23995, 23996, 23992, - 23989, 23990, 23991, 23993, 23988, 24045, 24044, 24047, 24046, 23997, - 24048, 24010, 35536, 35536, 23998, 23999, 24049, 26699, 26686, 26700, - 26688, 26691, 26687, 26702, 26690, 26697, 26706, 26692, 26693, 26703, - 26705, 26694, 26689, 26707, 26698, 26704, 26701, 26695, 26696, 26709, - 26710, 26713, 26708, 26714, 26711, 26733, 26743, 26738, 26732, 26742, - 26737, 26731, 26741, 26715, 26739, 26735, 26745, 26716, 26734, 26744, - 26736, 26740, 26712, 35536, 35536, 26723, 26717, 26719, 26722, 26720, - 26724, 26746, 26729, 26727, 26730, 26726, 26728, 26721, 26725, 26718, - 35536, 20299, 20286, 20288, 20287, 20289, 20298, 20296, 20301, 20281, - 20279, 20278, 20290, 20291, 20292, 20282, 20300, 20293, 20284, 20294, - 20295, 20283, 20280, 20297, 20302, 20285, 20277, 20303, 20304, 35536, - 35536, 20305, 35536, 29210, 29215, 29211, 29213, 29209, 29208, 29212, - 29216, 29207, 29206, 29214, 35536, 35536, 35536, 35536, 35536, 1143, - 1133, 1144, 1160, 1142, 1130, 1139, 1136, 1140, 1138, 1161, 1135, 1146, - 1132, 1134, 1145, 1131, 1137, 1141, 2428, 2429, 2431, 1539, 1064, 2316, - 1411, 1281, 1501, 1499, 1347, 2445, 1413, 2313, 2315, 35536, 35536, - 35536, 35536, 35536, 2311, 2366, 2392, 2391, 2394, 2158, 2408, 1084, - 1102, 1174, 1181, 1321, 1498, 1248, 1432, 1367, 1380, 1599, 1601, 1453, - 1573, 1465, 1378, 1200, 1467, 1261, 1494, 1623, 1121, 1335, 1433, 1172, - 1420, 1524, 1442, 1600, 1117, 1115, 1118, 1421, 1525, 1547, 1507, 1349, - 1267, 1116, 1323, 1322, 1369, 1278, 2348, 2351, 2377, 2372, 2383, 1113, - 1112, 2407, 1114, 1111, 2397, 2367, 2363, 2386, 2385, 2379, 2390, 2368, - 2370, 2369, 2371, 2374, 2373, 2352, 2361, 1086, 2440, 1070, 1068, 1072, - 1071, 1069, 1073, 2434, 2436, 2438, 2433, 2435, 2437, 2309, 2308, 2307, - 2375, 1094, 1093, 1106, 1630, 2319, 1629, 2321, 1081, 1082, 2320, 1077, - 2161, 9891, 9881, 9895, 9900, 9816, 9790, 9791, 9860, 9861, 9836, 9837, - 9855, 9857, 9798, 9817, 9868, 9792, 9799, 9818, 9831, 9793, 9827, 9826, - 9811, 9809, 9842, 9796, 9800, 9847, 9845, 9843, 9852, 9851, 9804, 9803, - 9841, 9854, 9853, 9806, 9805, 9844, 9840, 9863, 9862, 9824, 9823, 9814, - 9835, 9830, 9829, 9850, 9849, 9848, 9859, 9819, 9820, 9821, 9813, 9913, - 9912, 9893, 9894, 9903, 9925, 9926, 9915, 9916, 9921, 9922, 9909, 9919, - 9927, 9904, 9910, 9920, 9911, 9905, 9899, 9914, 9906, 9941, 9902, 9901, - 9785, 9782, 9908, 9918, 9917, 9867, 9825, 9808, 9865, 9801, 9828, 9866, - 9834, 9856, 9858, 9923, 9924, 9929, 9928, 9936, 9938, 9935, 9934, 9931, - 9930, 9933, 9932, 9939, 9937, 9783, 9898, 9797, 9833, 9832, 9794, 9839, - 9838, 9815, 9864, 9812, 9810, 9846, 9807, 9802, 9822, 3599, 3667, 3670, - 3672, 35536, 3623, 3624, 3637, 3638, 3635, 3636, 3617, 3619, 35536, - 35536, 3659, 3625, 35536, 35536, 3660, 3626, 3610, 3607, 3651, 3650, - 3639, 3649, 3648, 3653, 3652, 3641, 3632, 3631, 3628, 3627, 3640, 3634, - 3633, 3630, 3629, 3642, 35536, 3655, 3654, 3647, 3646, 3658, 3622, 3611, - 35536, 3657, 35536, 35536, 35536, 3643, 3644, 3645, 3656, 35536, 35536, - 3668, 3669, 3674, 3683, 3684, 3677, 3678, 3679, 3680, 35536, 35536, 3685, - 3675, 35536, 35536, 3686, 3676, 3671, 3608, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 3600, 35536, 35536, 35536, 35536, 3615, 3614, - 35536, 3621, 3618, 3620, 3681, 3682, 35536, 35536, 3693, 3695, 3692, - 3691, 3688, 3687, 3690, 3689, 3696, 3694, 3613, 3612, 3662, 3661, 3601, - 3605, 3604, 3603, 3602, 3606, 3673, 3697, 3616, 3598, 3666, 35536, 35536, - 14035, 14036, 14041, 35536, 13987, 13988, 14003, 14004, 14001, 14002, - 35536, 35536, 35536, 35536, 14022, 13989, 35536, 35536, 14021, 13990, - 13986, 13985, 13983, 13982, 14007, 14014, 14013, 14016, 14015, 14009, - 13998, 13997, 13992, 13991, 14008, 14000, 13999, 13994, 13993, 14010, - 35536, 14018, 14017, 14012, 14011, 14025, 14027, 13996, 35536, 14006, - 14005, 35536, 14026, 14019, 35536, 14020, 14024, 35536, 35536, 14038, - 35536, 14042, 14047, 14048, 14045, 14046, 35536, 35536, 35536, 35536, - 14050, 14043, 35536, 35536, 14049, 14044, 14040, 35536, 35536, 35536, - 14037, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 13984, 13981, - 14028, 13995, 35536, 14023, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 14060, 14062, 14059, 14058, 14055, 14054, 14057, 14056, 14063, - 14061, 14051, 13980, 14052, 14064, 14053, 14039, 13979, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 13875, 13883, - 13885, 35536, 13825, 13826, 13844, 13845, 13842, 13843, 13837, 13839, - 13901, 35536, 13872, 13827, 13902, 35536, 13873, 13828, 13865, 13864, - 13861, 13860, 13849, 13859, 13858, 13863, 13862, 13851, 13834, 13833, - 13830, 13829, 13850, 13836, 13835, 13832, 13831, 13852, 35536, 13867, - 13866, 13857, 13856, 13869, 13871, 13870, 35536, 13847, 13846, 35536, - 13841, 13853, 13854, 13855, 13868, 35536, 35536, 13881, 13882, 13888, - 13897, 13898, 13891, 13892, 13893, 13894, 13886, 35536, 13899, 13889, - 13887, 35536, 13900, 13890, 13884, 35536, 35536, 13915, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 13838, 13840, 13895, 13896, 35536, 35536, 13911, - 13913, 13910, 13909, 13906, 13905, 13908, 13907, 13914, 13912, 13903, - 13904, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 13848, 13880, - 13879, 13876, 13878, 13874, 13877, 35536, 24926, 24929, 24932, 35536, - 24877, 24878, 24896, 24897, 24894, 24895, 24889, 24891, 35536, 35536, - 24922, 24879, 35536, 35536, 24923, 24880, 24916, 24915, 24912, 24911, - 24900, 24910, 24909, 24914, 24913, 24902, 24886, 24885, 24882, 24881, - 24901, 24888, 24887, 24884, 24883, 24903, 35536, 24918, 24917, 24908, - 24907, 24920, 24876, 24874, 35536, 24899, 24898, 35536, 24893, 24904, - 24905, 24906, 24919, 35536, 35536, 24927, 24928, 24933, 24942, 24943, - 24936, 24937, 24938, 24939, 35536, 35536, 24944, 24934, 35536, 35536, - 24945, 24935, 24931, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 24930, 24863, 24864, 35536, 35536, 35536, 35536, 24873, 24872, 35536, - 24875, 24890, 24892, 24940, 24941, 35536, 35536, 24952, 24954, 24951, - 24950, 24947, 24946, 24949, 24948, 24955, 24953, 24871, 24921, 24868, - 24867, 24870, 24865, 24866, 24869, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 29884, 29901, 35536, 29847, 29848, - 29860, 29861, 29856, 29857, 35536, 35536, 35536, 29865, 29866, 29849, - 35536, 29858, 29859, 29850, 29870, 35536, 35536, 35536, 29842, 29867, - 35536, 29869, 35536, 29843, 29845, 35536, 35536, 35536, 29841, 29846, - 35536, 35536, 35536, 29844, 29840, 29872, 35536, 35536, 35536, 29871, - 29874, 29855, 29854, 29853, 29852, 29851, 29873, 29862, 29863, 29864, - 29868, 35536, 35536, 35536, 35536, 30174, 30181, 30182, 30177, 30178, - 35536, 35536, 35536, 30183, 30184, 30175, 35536, 30179, 30180, 30176, - 29900, 35536, 35536, 30187, 35536, 35536, 35536, 35536, 35536, 35536, - 29776, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 29813, 29815, 29812, 29811, 29808, - 29807, 29810, 29809, 29816, 29814, 29878, 29876, 29877, 29806, 30186, - 30185, 29805, 29803, 29775, 29881, 29879, 35536, 35536, 35536, 35536, - 35536, 31250, 31251, 31256, 31258, 31249, 31210, 31211, 31226, 31227, - 31222, 31223, 31217, 31219, 35536, 31243, 31244, 31212, 35536, 31224, - 31225, 31213, 31240, 31239, 31236, 31235, 31199, 31234, 31233, 31238, - 31237, 31201, 31206, 31205, 31193, 31192, 31200, 31209, 31207, 31196, - 31194, 31197, 35536, 31242, 31241, 31232, 31231, 31246, 31247, 31204, - 31203, 31216, 31215, 31214, 31221, 31228, 31229, 31230, 31245, 35536, - 35536, 31254, 31255, 31259, 31270, 31271, 31262, 31263, 31264, 31265, - 35536, 31272, 31273, 31260, 35536, 31268, 31269, 31261, 31257, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 31248, 31184, 35536, 31208, - 31195, 31202, 35536, 31183, 31198, 35536, 35536, 31218, 31220, 31266, - 31267, 35536, 35536, 31280, 31282, 31279, 31278, 31275, 31274, 31277, - 31276, 31283, 31281, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 31252, 31191, 31189, 31187, 31185, 31190, 31188, 31186, 31253, 16427, - 16426, 16431, 16435, 16428, 16375, 16376, 16401, 16402, 16397, 16398, - 16392, 16394, 35536, 16418, 16419, 16377, 35536, 16399, 16400, 16378, - 16415, 16414, 16411, 16410, 16372, 16409, 16408, 16413, 16412, 16374, - 16389, 16388, 16380, 16379, 16373, 16391, 16390, 16382, 16381, 16370, - 35536, 16417, 16416, 16407, 16406, 16422, 16423, 16387, 16386, 16385, - 16384, 35536, 16396, 16403, 16404, 16405, 16421, 35536, 35536, 16429, - 16430, 16438, 16449, 16450, 16441, 16442, 16443, 16444, 35536, 16451, - 16452, 16439, 35536, 16447, 16448, 16440, 16434, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 16424, 16437, 35536, 35536, 35536, 35536, - 35536, 16436, 16371, 16420, 35536, 16393, 16395, 16445, 16446, 35536, - 35536, 16459, 16461, 16458, 16457, 16454, 16453, 16456, 16455, 16462, - 16460, 35536, 16432, 16433, 16425, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 20239, 20241, 20246, - 20244, 20196, 20170, 20172, 20216, 20217, 20212, 20213, 20197, 20199, - 35536, 20231, 20232, 20173, 35536, 20214, 20215, 20174, 20228, 20227, - 20224, 20223, 20204, 20185, 20184, 20226, 20225, 20205, 20193, 20191, - 20188, 20187, 20203, 20195, 20194, 20190, 20189, 20206, 20202, 20230, - 20229, 20222, 20221, 20234, 20235, 20211, 20210, 20209, 20208, 20207, - 20201, 20218, 20219, 20220, 20233, 20192, 20242, 20240, 20245, 20248, - 20259, 20260, 20251, 20252, 20253, 20254, 35536, 20261, 20262, 20249, - 35536, 20257, 20258, 20250, 20243, 20186, 20247, 35536, 35536, 35536, - 35536, 20182, 20183, 20177, 20263, 20162, 20160, 20167, 20157, 20158, - 20168, 20161, 20171, 20198, 20200, 20255, 20256, 35536, 35536, 20153, - 20155, 20152, 20151, 20148, 20147, 20150, 20149, 20156, 20154, 20238, - 20236, 20237, 20165, 20164, 20169, 20159, 20163, 20166, 20146, 20179, - 20178, 20180, 20175, 20176, 20181, 35536, 28083, 28082, 28084, 35536, - 28028, 28025, 28013, 28012, 28036, 28035, 28038, 28037, 28034, 28033, - 28032, 28031, 28030, 28029, 28026, 28057, 28056, 28027, 35536, 35536, - 35536, 28022, 28047, 28020, 28045, 28070, 28060, 28019, 28044, 28021, - 28046, 28067, 28068, 28061, 28014, 28039, 28016, 28041, 28051, 28058, - 28015, 28040, 28017, 28042, 28054, 35536, 28059, 28023, 28048, 28018, - 28043, 28049, 28024, 28066, 28064, 35536, 28053, 35536, 35536, 28065, - 28069, 28052, 28055, 28063, 28050, 28062, 35536, 35536, 35536, 28081, - 35536, 35536, 35536, 35536, 28101, 28093, 28088, 28094, 28089, 28095, - 35536, 28090, 35536, 28091, 28096, 28087, 28100, 28097, 28098, 28099, - 28092, 35536, 35536, 35536, 35536, 35536, 35536, 28077, 28079, 28076, - 28075, 28072, 28071, 28074, 28073, 28080, 28078, 35536, 35536, 28085, - 28086, 28102, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 31437, 31434, 31432, 31431, 31433, 31435, - 31451, 31420, 31422, 31421, 31480, 31423, 31492, 31424, 31489, 31485, - 31482, 31483, 31453, 31425, 31488, 31487, 31484, 31486, 31454, 31419, - 31460, 31457, 31426, 31458, 31427, 31459, 31449, 31493, 31461, 31462, - 31439, 31441, 31490, 31478, 31477, 31479, 31430, 31438, 31494, 31429, - 31455, 31463, 31443, 31466, 31468, 31473, 31474, 31470, 31471, 31469, - 31472, 31456, 35536, 35536, 35536, 35536, 31495, 31475, 31467, 31476, - 31465, 31464, 31440, 31448, 31447, 31446, 31444, 31445, 31442, 31481, - 31452, 31491, 31428, 31502, 31504, 31501, 31500, 31497, 31496, 31499, - 31498, 31505, 31503, 31450, 31436, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 17263, 17261, 35536, 17262, 35536, 17276, 17291, 17295, - 17275, 17285, 35536, 17277, 17292, 17273, 17271, 17270, 17268, 17267, - 17272, 17296, 17288, 17286, 17287, 17269, 17293, 17294, 17281, 17279, - 17258, 17280, 17257, 17274, 17297, 17300, 17265, 35536, 17266, 35536, - 17299, 17282, 17283, 17284, 17289, 17278, 17301, 17290, 17327, 17309, - 17314, 17310, 17312, 17322, 17323, 17316, 17317, 17318, 17319, 17304, - 17315, 17303, 17302, 35536, 35536, 17320, 17321, 17324, 17313, 17311, - 35536, 17325, 35536, 17308, 17305, 17306, 17307, 17338, 17339, 17326, - 35536, 17334, 17336, 17333, 17332, 17329, 17328, 17331, 17330, 17337, - 17335, 35536, 35536, 17254, 17253, 17260, 17259, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 31729, - 31636, 31634, 31635, 31644, 31632, 31629, 31633, 31653, 31624, 31622, - 31645, 31660, 31654, 31650, 31657, 31649, 31652, 31651, 31628, 31637, - 31620, 31619, 31547, 31548, 31546, 31668, 31669, 31670, 31672, 31673, - 31671, 31569, 31571, 31568, 31567, 31564, 31563, 31566, 31565, 31572, - 31570, 31561, 31558, 31557, 31554, 31553, 31556, 31555, 31562, 31560, - 31559, 31625, 31647, 31627, 31646, 31630, 31656, 31638, 31639, 31640, - 31641, 31679, 31665, 31578, 31576, 31606, 31605, 31588, 31604, 31603, - 31613, 35536, 31590, 31598, 31597, 31583, 31582, 31589, 31600, 31599, - 31587, 31586, 31591, 31608, 31607, 31602, 31601, 31615, 31596, 31595, - 31585, 31584, 31616, 31609, 31610, 31611, 31617, 31580, 31614, 31592, - 31593, 31594, 31612, 31618, 31575, 31581, 31577, 31579, 35536, 35536, - 35536, 35536, 31753, 31749, 31750, 31741, 31742, 31743, 31744, 31745, - 31746, 31751, 31752, 31747, 31748, 31676, 31677, 31739, 31740, 31667, - 31681, 31642, 31659, 31663, 31678, 31664, 31666, 31661, 31662, 31680, - 31728, 31727, 31726, 31693, 31692, 31712, 31711, 31694, 31710, 31709, - 31719, 35536, 31696, 31704, 31703, 31686, 31685, 31695, 31706, 31705, - 31690, 31689, 31697, 31714, 31713, 31708, 31707, 31721, 31702, 31701, - 31688, 31687, 31723, 31715, 31716, 31717, 31724, 31722, 31720, 31698, - 31699, 31700, 31718, 31725, 31691, 31683, 31684, 31682, 35536, 31573, - 31574, 31550, 31551, 31552, 31549, 31730, 31737, 31735, 31738, 31736, - 31731, 31734, 31733, 31732, 35536, 31675, 31674, 31623, 31626, 31648, - 31643, 31631, 26332, 18869, 26333, 18870, 31658, 31655, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 23282, 23261, 23260, 23259, 23291, - 23359, 23358, 23361, 23360, 23292, 23289, 23337, 23336, 23343, 23342, - 23290, 23321, 23338, 23345, 23344, 23293, 23363, 23362, 23357, 23356, - 23288, 23365, 23295, 23355, 23341, 23320, 23364, 23354, 23251, 23315, - 23352, 23353, 23346, 23347, 23254, 23287, 23366, 23253, 23458, 23442, - 23465, 23466, 23459, 23460, 23454, 23439, 23447, 23448, 23455, 23383, - 23402, 23407, 23406, 23382, 23246, 23244, 23245, 23243, 23258, 23483, - 23485, 23482, 23481, 23478, 23477, 23480, 23479, 23486, 23484, 23405, - 23394, 23412, 23416, 23411, 23415, 23296, 23319, 23348, 23349, 23350, - 23351, 23461, 23462, 23463, 23464, 23286, 23285, 23283, 23284, 23249, - 23248, 23247, 23318, 23453, 23427, 23428, 23340, 23339, 23456, 23457, - 23397, 23398, 23399, 23400, 23401, 23257, 23256, 23255, 23443, 23445, - 23446, 23444, 23310, 23309, 23308, 23306, 23314, 23298, 23311, 23299, - 23301, 23312, 23304, 23302, 23313, 23250, 23452, 23449, 23450, 23451, - 23389, 23390, 23391, 23392, 23387, 23388, 23386, 23294, 23403, 23378, - 23380, 23377, 23376, 23373, 23372, 23375, 23374, 23381, 23379, 23384, - 23385, 23440, 23441, 23414, 23413, 12876, 12902, 12887, 12908, 12909, - 12907, 12897, 12898, 12910, 12891, 12900, 12903, 12905, 12911, 12893, - 12896, 12901, 12895, 12899, 12912, 12892, 12890, 12886, 12906, 12894, - 12882, 12885, 12889, 12884, 12883, 12904, 12888, 12877, 12881, 12879, - 12914, 12878, 12880, 35536, 12913, 35536, 35536, 35536, 35536, 35536, - 12875, 35536, 35536, 12959, 12990, 12967, 12996, 12965, 12995, 12988, - 12985, 12997, 12977, 12979, 12991, 12993, 12998, 12981, 12987, 12989, - 12983, 12986, 12956, 12980, 12976, 12966, 12994, 12982, 12960, 12963, - 12975, 12962, 12961, 12992, 12974, 12970, 12973, 12971, 13000, 12968, - 12972, 13001, 12999, 12964, 12984, 12958, 13048, 22495, 12957, 12969, - 12978, 14296, 14370, 14304, 14375, 14368, 14332, 14299, 14314, 14372, - 14346, 14364, 14278, 14276, 14362, 14263, 14298, 14382, 14311, 14385, - 14306, 14371, 14308, 14307, 14379, 14342, 14366, 14345, 14291, 14301, - 14295, 14324, 14329, 14328, 14315, 14319, 14317, 14320, 14321, 14318, - 14326, 14325, 14327, 14322, 14293, 14294, 14353, 14359, 14358, 14351, - 14356, 14347, 14348, 14350, 14361, 14355, 14354, 14352, 14357, 14349, - 14360, 14268, 14267, 14273, 14272, 14331, 14288, 14287, 14285, 14280, - 14290, 14281, 14374, 14284, 14283, 14286, 14279, 14383, 14277, 14270, - 14266, 14275, 14271, 14264, 14265, 14269, 14274, 14312, 14292, 14373, - 14384, 14297, 14310, 14305, 14309, 14376, 14387, 14625, 14531, 14541, - 14589, 14593, 14543, 14542, 14595, 14594, 14570, 14622, 14623, 14580, - 14601, 14581, 14621, 14620, 14624, 14610, 14547, 14599, 14554, 14539, - 14540, 14591, 14590, 14545, 14546, 14544, 14597, 14598, 14578, 14577, - 14573, 14571, 14579, 14602, 14603, 14604, 14609, 14608, 14586, 14587, - 14585, 14582, 14588, 14615, 14614, 14613, 14612, 14611, 14619, 14617, - 14553, 14550, 14600, 14555, 14557, 14564, 14568, 14566, 14556, 14532, - 14534, 14537, 14536, 14569, 14538, 14592, 14596, 14575, 14576, 14407, - 14508, 14410, 14430, 14433, 14437, 14512, 14458, 14459, 14464, 14468, - 14477, 14480, 14473, 14485, 14417, 14447, 14450, 14486, 14503, 14399, - 14390, 14393, 14416, 14521, 14443, 14394, 14409, 14411, 14436, 14435, - 14439, 14438, 14434, 14519, 14513, 14461, 14484, 14478, 14479, 14498, - 14465, 14467, 14472, 14471, 14462, 14476, 14474, 14463, 14481, 14427, - 14424, 14418, 14423, 14422, 14420, 14425, 14429, 14406, 14448, 14452, - 14457, 14405, 14488, 14496, 14489, 14492, 14440, 14401, 14402, 14511, - 14400, 14522, 14526, 14529, 14445, 14404, 14397, 14395, 14396, 14398, - 14530, 14413, 14414, 14412, 14408, 14415, 14509, 12146, 12153, 12152, - 12147, 12151, 12150, 12148, 12149, 12373, 12381, 12380, 12374, 12378, - 12377, 12375, 12379, 12139, 12145, 12143, 12140, 12142, 12141, 12144, - 12130, 12190, 12198, 12197, 12191, 12195, 12194, 12192, 12188, 12302, - 12309, 12307, 12303, 12305, 12304, 12308, 12306, 12277, 12286, 12285, - 12278, 12282, 12281, 12279, 12283, 12317, 12323, 12322, 12318, 12292, - 12287, 12319, 12321, 12293, 12301, 12300, 12294, 12298, 12297, 12295, - 12299, 12269, 12276, 12275, 12270, 12274, 12273, 12271, 12272, 12257, - 35536, 12261, 12258, 12260, 12259, 35536, 35536, 12250, 12256, 12254, - 12251, 12253, 12252, 12255, 35536, 12245, 35536, 12249, 12246, 12248, - 12247, 35536, 35536, 11980, 11987, 11986, 11981, 11985, 11984, 11982, - 11971, 12442, 12449, 12447, 12443, 12445, 12444, 12448, 12446, 12355, - 12363, 12362, 12356, 12360, 12359, 12357, 12361, 12018, 12026, 12025, - 12019, 12023, 12022, 12020, 12024, 12410, 12417, 12416, 12411, 12415, - 12414, 12412, 12413, 12398, 35536, 12402, 12399, 12401, 12400, 35536, - 35536, 12208, 12216, 12215, 12209, 12213, 12212, 12210, 12214, 12199, - 12207, 12206, 12200, 12204, 12203, 12201, 12205, 12100, 12108, 12107, - 12101, 12105, 12104, 12102, 12106, 12178, 12185, 12184, 12179, 12183, - 12182, 12180, 12181, 12166, 35536, 12170, 12167, 12169, 12168, 35536, - 35536, 12159, 12165, 12163, 12160, 12162, 12161, 12164, 35536, 12154, - 35536, 12158, 12155, 12157, 12156, 35536, 35536, 12382, 12389, 12388, - 12383, 12387, 12386, 12384, 12385, 12218, 12224, 12222, 12219, 12221, - 12220, 12223, 35536, 12433, 12441, 12440, 12434, 12438, 12437, 12435, - 12439, 12418, 12425, 12423, 12419, 12421, 12420, 12424, 12422, 12390, - 12397, 12396, 12391, 12395, 12394, 12392, 12393, 12048, 12056, 12055, - 12049, 12053, 12052, 12050, 12054, 12033, 12041, 12040, 12034, 12038, - 12037, 12035, 12039, 12364, 12372, 12371, 12365, 12369, 12368, 12366, - 12370, 12121, 12069, 12127, 12122, 12126, 12125, 12123, 12124, 12109, - 35536, 12113, 12110, 12112, 12111, 35536, 35536, 12093, 12099, 12097, - 12094, 12096, 12095, 12098, 12089, 12324, 12332, 12331, 12325, 12329, - 12328, 12326, 12330, 12009, 12017, 12016, 12010, 12014, 12013, 12011, - 12015, 12217, 12232, 12231, 12225, 12229, 12228, 12226, 12230, 12347, - 12354, 12352, 12348, 12350, 12349, 12353, 12351, 12339, 12346, 12345, - 12340, 12344, 12343, 12341, 12342, 12061, 12068, 12066, 12062, 12064, - 12063, 12067, 12059, 12237, 12244, 12243, 12238, 12242, 12241, 12239, - 12235, 12284, 12196, 12065, 35536, 35536, 11949, 11951, 11950, 11968, - 12471, 12469, 11952, 11967, 11953, 11966, 12470, 11965, 12467, 12465, - 12464, 12461, 12460, 12463, 12462, 12468, 12466, 11954, 11957, 11956, - 11961, 11960, 11964, 11963, 11959, 11962, 11958, 11955, 35536, 35536, - 35536, 12290, 12189, 12187, 12186, 12288, 11972, 11970, 11969, 12289, - 12060, 12058, 12057, 12291, 12236, 12234, 12233, 12459, 12450, 12456, - 12457, 12452, 12454, 12458, 12453, 12451, 12455, 35536, 35536, 35536, - 35536, 35536, 35536, 6484, 6485, 6486, 6487, 6488, 6489, 6447, 6483, - 6448, 6449, 6450, 6451, 6452, 6412, 6413, 6414, 6415, 6416, 6417, 6453, - 6454, 6455, 6456, 6457, 6458, 6459, 6460, 6461, 6462, 6463, 6418, 6411, - 6419, 6420, 6421, 6422, 6423, 6424, 6465, 6466, 6467, 6468, 6469, 6470, - 6426, 6425, 6427, 6428, 6429, 6430, 6431, 6405, 6444, 6406, 6445, 6407, - 6446, 6408, 6409, 6410, 6404, 6432, 6433, 6434, 6435, 6436, 6437, 6438, - 6439, 6440, 6441, 6442, 6443, 6471, 6472, 6473, 6474, 6475, 6476, 6477, - 6478, 6479, 6480, 6481, 6482, 6464, 35536, 35536, 6564, 6565, 6566, 6567, - 6568, 6550, 35536, 35536, 5626, 5598, 5371, 5628, 5629, 5778, 5792, 6075, - 5582, 5442, 5369, 5370, 5952, 6042, 6062, 6040, 6063, 6041, 6044, 6038, - 6045, 6039, 5707, 6059, 6036, 6060, 6037, 5708, 5373, 6076, 6094, 5615, - 5614, 5616, 5617, 5609, 5610, 5607, 5606, 5619, 5613, 5618, 5608, 5600, - 5630, 5791, 5377, 5812, 5805, 5810, 5811, 5807, 5808, 6066, 5440, 5441, - 5803, 5804, 5802, 5981, 5800, 5979, 5801, 5980, 5795, 5977, 5796, 5978, - 5798, 5975, 5799, 5976, 6065, 5794, 5974, 5433, 5951, 5934, 5949, 5950, - 5947, 5948, 6073, 5404, 5417, 5932, 5933, 5942, 6034, 5940, 6032, 5941, - 6033, 5938, 6030, 5939, 6031, 5936, 6028, 5937, 6029, 5713, 5894, 5929, - 5930, 5931, 5928, 5649, 5643, 5647, 5648, 5645, 5646, 6068, 5641, 5642, - 5640, 6026, 5638, 6024, 5639, 6025, 5636, 6022, 5637, 6023, 5633, 6020, - 5634, 6021, 5710, 5631, 5632, 5874, 5875, 5876, 5873, 5597, 5584, 5595, - 5596, 5593, 5594, 6067, 5401, 5583, 5591, 6019, 5589, 6017, 5590, 6018, - 5587, 6015, 5588, 6016, 5585, 6013, 5586, 6014, 5709, 5400, 5850, 5675, - 5683, 5692, 5693, 5678, 5679, 6070, 5681, 5682, 5691, 5973, 5689, 5971, - 5690, 5972, 5687, 5969, 5688, 5970, 5685, 5967, 5686, 5968, 5711, 5674, - 5966, 5694, 5375, 5851, 5767, 5728, 5765, 5766, 5755, 5756, 6071, 5699, - 5727, 5764, 5992, 5758, 5990, 5759, 5991, 5712, 5695, 5473, 5768, 5673, - 5660, 5671, 5672, 5669, 5670, 6069, 5658, 5659, 5668, 5960, 5666, 5958, - 5667, 5959, 5664, 5956, 5665, 5957, 5662, 5954, 5663, 5955, 5650, 5953, - 5676, 5893, 5853, 5891, 5892, 5872, 5877, 6072, 5833, 5852, 5886, 6012, - 5884, 6010, 5885, 6011, 5882, 6008, 5883, 6009, 5880, 6006, 5881, 6007, - 5705, 5832, 5376, 5879, 5396, 5680, 5703, 5706, 5701, 5702, 5704, 5700, - 5871, 5869, 5870, 5863, 5864, 5866, 5867, 5862, 6005, 5860, 6003, 5861, - 6004, 5855, 6001, 5856, 6002, 5858, 5999, 5859, 6000, 5854, 6093, 6079, - 6091, 6092, 6081, 6082, 6074, 6077, 6078, 6090, 5989, 6088, 5987, 6089, - 5988, 6086, 5985, 6087, 5986, 6084, 5983, 6085, 5984, 5714, 6064, 5397, - 5982, 5849, 5831, 5815, 5965, 5825, 5829, 5830, 5827, 5828, 5963, 5823, - 5824, 5961, 5817, 5994, 5813, 5993, 5677, 5625, 5604, 5605, 5620, 5622, - 5623, 5602, 5603, 5624, 6035, 5601, 5913, 5698, 5911, 5696, 5912, 5697, - 5909, 5910, 5907, 5908, 5905, 6027, 5895, 5926, 5927, 5923, 5921, 5920, - 5944, 5945, 5946, 5943, 5753, 5751, 5752, 5749, 5750, 5747, 5748, 5746, - 5754, 5627, 5772, 5776, 5777, 5774, 5775, 5770, 5771, 5769, 5918, 5919, - 5914, 5917, 5996, 5997, 5998, 5995, 5733, 5737, 5738, 5735, 5736, 5731, - 5732, 5730, 5739, 5847, 5848, 5843, 5846, 6055, 6056, 6057, 6054, 6046, - 5656, 5657, 5654, 5655, 5652, 5653, 5651, 5903, 5901, 5902, 5899, 5900, - 5897, 5898, 5896, 5374, 5393, 5394, 5395, 5392, 5381, 5382, 5383, 5380, - 5389, 5390, 5391, 5388, 5385, 5386, 5387, 5384, 5838, 5839, 5835, 5837, - 5423, 5422, 5418, 5419, 5421, 5420, 5569, 5568, 5564, 5565, 5567, 5566, - 5575, 5574, 5570, 5571, 5573, 5572, 5439, 5438, 5434, 5435, 5437, 5436, - 5533, 5532, 5528, 5529, 5531, 5530, 5527, 5526, 5522, 5523, 5525, 5524, - 5496, 5495, 5491, 5492, 5494, 5493, 5490, 5432, 5431, 5428, 5429, 5430, - 5426, 5469, 5468, 5464, 5465, 5467, 5466, 5463, 5462, 5458, 5459, 5461, - 5460, 5457, 5476, 5475, 5470, 5471, 5474, 5472, 5563, 5562, 5558, 5559, - 5561, 5560, 5581, 5580, 5576, 5577, 5579, 5578, 5456, 5840, 5455, 5450, - 5451, 5454, 5842, 5453, 5449, 5448, 5444, 5445, 5447, 5446, 5551, 5550, - 5546, 5547, 5549, 5548, 5410, 5409, 5405, 5406, 5408, 5407, 5545, 5544, - 5540, 5541, 5543, 5542, 5509, 5508, 5504, 5505, 5507, 5506, 5515, 5514, - 5510, 5511, 5513, 5512, 5503, 5502, 5498, 5499, 5501, 5500, 5497, 5443, - 5416, 5415, 5411, 5412, 5414, 5413, 5489, 5488, 5484, 5485, 5487, 5486, - 5483, 5482, 5478, 5479, 5481, 5480, 5477, 5539, 5538, 5534, 5535, 5537, - 5536, 5557, 5556, 5552, 5553, 5555, 5554, 5521, 5520, 5516, 5517, 5519, - 5518, 5592, 5621, 5773, 5734, 5744, 5745, 5742, 5743, 5740, 5741, 6053, - 6051, 6052, 6049, 6050, 6047, 6048, 6058, 5379, 24281, 24256, 24267, - 24263, 24273, 24270, 24276, 24279, 24280, 24259, 24258, 24278, 24264, - 24269, 24274, 24268, 24255, 24271, 24277, 24261, 24265, 24260, 24272, - 24275, 24266, 24262, 24257, 24253, 24254, 35536, 35536, 35536, 26606, - 26662, 26656, 26660, 26659, 26654, 26652, 26599, 26584, 26630, 26583, - 26582, 26627, 26642, 26629, 26633, 26634, 26636, 26622, 26588, 26621, - 26607, 26600, 26608, 26610, 26655, 26612, 26611, 26625, 26639, 26651, - 26641, 26593, 26615, 26596, 26619, 26609, 26624, 26645, 26616, 26658, - 26585, 26648, 26647, 26643, 26586, 26664, 26653, 26644, 26591, 26650, - 26638, 26594, 26632, 26597, 26657, 26626, 26640, 26623, 26592, 26614, - 26613, 26595, 26631, 26598, 26618, 26590, 26589, 26587, 26649, 26628, - 26646, 26617, 26661, 26663, 26665, 26666, 26581, 26667, 26668, 26580, - 26620, 26637, 26635, 26604, 26603, 26605, 26602, 26601, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 29374, 29391, 29392, 29382, 29380, - 29376, 29388, 29379, 29377, 29385, 29378, 29384, 29390, 29386, 29383, - 29389, 29387, 29381, 29395, 29396, 29394, 29393, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 29375, 14797, 14798, 14799, - 14788, 14786, 14782, 14794, 14785, 14783, 14791, 14784, 14790, 14796, - 14792, 14789, 14795, 14793, 14787, 14801, 14802, 14800, 25736, 25737, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 5092, - 5093, 5094, 5083, 5081, 5077, 5089, 5080, 5078, 5086, 5079, 5085, 5091, - 5087, 5084, 5090, 5088, 5082, 5095, 5096, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 29410, 29411, - 29412, 29402, 29401, 29397, 29407, 29400, 29398, 29405, 29399, 29404, - 29409, 35536, 29403, 29408, 29406, 35536, 29413, 29414, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 16913, 16911, 16914, 16912, 16915, 16909, 16907, 16910, 16908, 16917, - 16931, 16927, 16932, 16928, 16916, 16929, 16925, 16930, 16926, 16918, - 16939, 16919, 16921, 16920, 16935, 16938, 16936, 16934, 16937, 16923, - 16922, 16924, 16940, 16933, 16941, 16888, 16886, 16896, 16897, 16892, - 16895, 16893, 16894, 16905, 16906, 16903, 16904, 16898, 16887, 16891, - 16890, 16889, 17008, 17007, 17009, 17014, 17016, 17020, 17022, 17024, - 17026, 17025, 17017, 17021, 17015, 17027, 17011, 17012, 17019, 17013, - 16962, 16956, 16961, 16963, 16957, 16947, 16955, 16958, 16952, 16944, - 16945, 16964, 16951, 16946, 16953, 16948, 16950, 16959, 16949, 16960, - 16954, 16885, 16942, 16943, 35536, 35536, 17034, 17036, 17033, 17032, - 17029, 17028, 17031, 17030, 17037, 17035, 35536, 35536, 35536, 35536, - 35536, 35536, 16986, 16985, 16982, 16984, 16983, 16977, 16980, 16981, - 16979, 16978, 35536, 35536, 35536, 35536, 35536, 35536, 22862, 22874, - 22870, 22719, 22869, 22720, 22867, 22858, 22871, 22872, 22873, 22718, - 22717, 22716, 22868, 22715, 22711, 22713, 22710, 22709, 22706, 22705, - 22708, 22707, 22714, 22712, 35536, 35536, 35536, 35536, 35536, 35536, - 22723, 22837, 22854, 22839, 22841, 22840, 22842, 22838, 22848, 22751, - 22843, 22849, 22850, 22846, 22755, 22836, 22798, 22797, 22828, 22844, - 22752, 22847, 22853, 22851, 22852, 22845, 22834, 22833, 22827, 22831, - 22832, 22830, 22835, 22829, 22754, 22807, 22825, 22826, 22814, 22816, - 22815, 22817, 22801, 22818, 22821, 22822, 22808, 22820, 22811, 22803, - 22812, 22805, 22810, 22824, 22823, 22819, 22809, 22813, 22804, 22806, - 22802, 22796, 22781, 22782, 22790, 22789, 22786, 22794, 22775, 22777, - 22795, 22784, 22780, 22791, 22793, 22792, 22776, 22778, 22779, 22788, - 22785, 22783, 22787, 22774, 22772, 22773, 22771, 22770, 22753, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 22725, 22727, 22729, 22736, - 22735, 22743, 22739, 22724, 22734, 22750, 22737, 22749, 22741, 22740, - 22731, 22738, 22742, 22728, 22745, 22744, 22748, 22746, 22747, 22726, - 22800, 22799, 22763, 22768, 22759, 22764, 22760, 22756, 22761, 22757, - 22769, 22758, 22766, 22767, 22733, 22732, 22762, 22730, 22765, 35536, - 35536, 35536, 35536, 35536, 5793, 5378, 5372, 6061, 5809, 5806, 5797, - 5935, 5644, 5635, 5684, 5757, 5729, 5661, 5878, 5834, 5865, 5868, 5857, - 6083, 6080, 5826, 5762, 5782, 5763, 5783, 5760, 5780, 5761, 5781, 5822, - 5820, 5821, 5818, 5819, 5816, 5789, 5790, 5787, 5786, 5788, 5779, 5784, - 5785, 5599, 6043, 5612, 5611, 5814, 5964, 5962, 5906, 5904, 5925, 5924, - 5922, 5916, 5915, 5845, 5844, 5836, 5425, 5402, 5427, 5424, 5841, 5452, - 5398, 5399, 5403, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 19167, 19134, 19133, 19114, 19113, 19120, 19128, 19127, - 19132, 19131, 19119, 19117, 19115, 19130, 19129, 19121, 19136, 19135, - 19126, 19125, 19139, 19118, 19140, 19138, 19141, 19122, 19123, 19124, - 19137, 19112, 19116, 35536, 19158, 19165, 19166, 19164, 19159, 19162, - 19160, 19163, 19161, 19157, 19155, 19156, 35536, 35536, 35536, 35536, - 19149, 19146, 19148, 19154, 19147, 19152, 19151, 19153, 19150, 19143, - 19142, 19144, 35536, 35536, 35536, 35536, 19145, 35536, 35536, 35536, - 19168, 19169, 19176, 19178, 19175, 19174, 19171, 19170, 19173, 19172, - 19179, 19177, 29435, 29447, 29430, 29427, 29445, 29448, 29429, 29428, - 29442, 29437, 29436, 29443, 29440, 29446, 29441, 29444, 29434, 29426, - 29431, 29415, 29449, 29419, 29420, 29438, 29433, 29432, 29439, 29418, - 29416, 29417, 35536, 35536, 29421, 29422, 29423, 29424, 29425, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 23820, 23842, 23802, 23804, 23807, 23824, 23826, 23829, 23810, 23806, - 23822, 23832, 23828, 23844, 23811, 23809, 23808, 23833, 23831, 23830, - 23813, 23812, 23819, 23835, 23834, 23841, 23816, 23821, 23818, 23838, - 23843, 23840, 23817, 23815, 23814, 23839, 23837, 23836, 23801, 23803, - 23823, 23825, 23805, 23827, 35536, 35536, 35536, 35536, 23865, 23850, - 23854, 23860, 23863, 23866, 23852, 23856, 23857, 23861, 23853, 23851, - 23864, 23859, 23858, 23862, 23855, 23800, 23795, 23794, 23799, 23798, - 23797, 23796, 23847, 23848, 35536, 35536, 35536, 35536, 35536, 35536, - 23873, 23875, 23872, 23871, 23868, 23867, 23870, 23869, 23876, 23874, - 23849, 35536, 35536, 35536, 23845, 23846, 16987, 17006, 16999, 17002, - 17004, 16997, 16995, 16993, 16989, 16991, 16976, 16974, 16966, 16970, - 16972, 16968, 17000, 17005, 16998, 17001, 17003, 16996, 16994, 16992, - 16988, 16990, 16975, 16973, 16965, 16969, 16971, 16967, 5061, 5058, 5050, - 5049, 5063, 5055, 5048, 5047, 5066, 5057, 5054, 5053, 5056, 5060, 5052, - 5051, 5068, 5064, 5062, 5067, 5065, 5069, 5059, 5072, 5074, 5071, 5073, - 5070, 35536, 35536, 5076, 5075, 29483, 29481, 29482, 29499, 29498, 29497, - 29523, 29489, 29488, 29502, 29509, 29501, 29524, 29517, 29484, 29529, - 29500, 29516, 29493, 29492, 29506, 29505, 29525, 29528, 29491, 29490, - 29494, 29504, 29507, 29503, 29530, 29510, 29496, 29515, 29518, 29511, - 29513, 29531, 29485, 29486, 29487, 29495, 29514, 29532, 29508, 29521, - 29522, 29519, 29520, 29527, 29526, 29512, 29480, 29455, 29454, 29452, - 29543, 29450, 29451, 29453, 29456, 29457, 29458, 35536, 29551, 29558, - 29562, 29559, 29568, 29574, 29575, 29573, 29572, 29570, 29571, 29563, - 29564, 29567, 29576, 29560, 29566, 29561, 29569, 29565, 29542, 29555, - 29556, 29535, 29536, 29537, 29546, 29545, 29538, 35536, 35536, 29459, - 29466, 29468, 29465, 29464, 29461, 29460, 29463, 29462, 29469, 29467, - 35536, 35536, 35536, 35536, 35536, 35536, 29476, 29478, 29475, 29474, - 29471, 29470, 29473, 29472, 29479, 29477, 35536, 35536, 35536, 35536, - 35536, 35536, 29552, 29553, 29550, 29541, 29534, 29554, 29547, 29544, - 29539, 29540, 29548, 29549, 29533, 29557, 35536, 35536, 7299, 7263, 7388, - 7302, 7547, 7566, 7565, 7495, 7283, 7469, 7534, 7501, 7287, 7500, 7499, - 7436, 7430, 7454, 7517, 7455, 7518, 7531, 7488, 7387, 7504, 7286, 7285, - 7545, 7414, 7415, 7416, 7279, 7558, 7368, 7560, 7151, 7562, 7481, 7559, - 7561, 7483, 7530, 7314, 7301, 7262, 7269, 35536, 35536, 7460, 7520, 7487, - 7385, 7533, 7538, 7272, 7273, 7311, 7447, 7552, 7289, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 2762, 2761, 2763, - 2760, 2764, 2671, 2672, 2688, 2689, 2692, 2693, 2710, 2711, 2701, 2702, - 2685, 2675, 2690, 2691, 2696, 2698, 2686, 2687, 2705, 2678, 2679, 2694, - 2695, 2706, 2717, 2716, 2682, 2681, 2704, 2715, 2718, 2680, 2683, 2703, - 2707, 2708, 2676, 2677, 2723, 2725, 2709, 2700, 2724, 2713, 2714, 2712, - 2722, 2765, 2776, 2779, 2780, 2770, 2771, 2768, 2769, 2766, 2767, 2772, - 2773, 2775, 2774, 2777, 2778, 2781, 2697, 2699, 2719, 2684, 2720, 2721, - 2673, 2674, 35536, 2670, 2669, 2789, 2791, 2788, 2787, 2784, 2783, 2786, - 2785, 2792, 2790, 2757, 2754, 2782, 2667, 2668, 2666, 2756, 2743, 2741, - 2744, 2735, 2736, 2742, 2738, 2740, 2739, 2737, 2733, 2732, 2728, 2726, - 2730, 2729, 2727, 2731, 2734, 2753, 2752, 2751, 2750, 2745, 2747, 2748, - 2749, 2746, 2758, 2755, 2759, 28982, 28980, 28981, 28933, 28968, 28970, - 28935, 28969, 28945, 28946, 28953, 28961, 28956, 28947, 28954, 28958, - 28967, 28948, 28962, 28955, 28949, 28960, 28938, 28963, 28951, 28959, - 28966, 28942, 28940, 28964, 28944, 28965, 28957, 28928, 28929, 28930, - 28988, 28987, 28989, 28986, 28984, 28985, 28979, 28983, 28931, 28932, - 28952, 28943, 28996, 28998, 28995, 28994, 28991, 28990, 28993, 28992, - 28999, 28997, 28927, 28941, 28939, 28950, 28936, 28937, 3557, 3543, 3551, - 3535, 3523, 3547, 3546, 3532, 3538, 3531, 3524, 3555, 3541, 3533, 3550, - 3534, 3552, 3549, 3554, 3539, 3522, 3537, 3544, 3527, 3545, 3540, 3525, - 3556, 3542, 3529, 3553, 3536, 3530, 3548, 3528, 3526, 3558, 3559, 3566, - 3572, 3569, 3573, 3574, 3570, 3575, 3571, 3567, 3568, 3520, 3521, 3560, - 3561, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 3565, 3563, - 3564, 3562, 18996, 18995, 18994, 19008, 19007, 19013, 19023, 19022, - 19026, 19014, 19021, 19020, 19002, 19015, 18999, 18998, 18997, 19006, - 19005, 19004, 19003, 19012, 19011, 19017, 19016, 19001, 19031, 19028, - 19027, 19010, 19009, 19029, 19025, 19024, 19030, 19032, 19041, 19040, - 19046, 19048, 19044, 19045, 19042, 19043, 19047, 18985, 18990, 18989, - 18987, 18991, 18992, 18993, 18988, 18986, 19039, 19038, 35536, 35536, - 35536, 19033, 19036, 19037, 19035, 19034, 19055, 19057, 19054, 19053, - 19050, 19049, 19052, 19051, 19058, 19056, 35536, 35536, 35536, 19019, - 19018, 19000, 24327, 24329, 24326, 24325, 24322, 24321, 24324, 24323, - 24330, 24328, 24300, 24291, 24289, 24288, 24290, 24301, 24285, 24284, - 24286, 24287, 24303, 24299, 24297, 24296, 24298, 24305, 24311, 24312, - 24310, 24313, 24302, 24295, 24292, 24294, 24293, 24304, 24306, 24307, - 24309, 24308, 24315, 24316, 24314, 24320, 24319, 24331, 24318, 24317, - 9548, 9525, 9531, 9588, 9569, 9577, 9567, 9568, 9587, 9253, 9579, 35536, - 35536, 35536, 35536, 35536, 13004, 13035, 13012, 13041, 13010, 13040, - 13033, 13030, 13042, 13022, 13024, 13036, 13038, 13043, 13026, 13032, - 13034, 13028, 13031, 13044, 13025, 13021, 13011, 13039, 13027, 13005, - 13008, 13020, 13007, 13006, 13037, 13019, 13015, 13018, 13016, 13046, - 13013, 13017, 13047, 13045, 13009, 13029, 13003, 35536, 35536, 13002, - 13014, 13023, 28978, 28976, 28977, 28975, 28974, 28973, 28972, 28971, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 33381, 33394, - 33383, 33361, 33375, 33389, 33390, 33391, 33376, 33392, 33379, 33387, - 33382, 33380, 33388, 33386, 33385, 33393, 33374, 33372, 33363, 33370, - 33362, 33373, 33371, 33352, 33353, 33355, 33356, 33368, 33366, 33367, - 33365, 33354, 33358, 33364, 33377, 33360, 33369, 33357, 33384, 33378, - 33359, 35536, 35536, 35536, 35536, 35536, 17959, 17960, 18567, 17956, - 17961, 17962, 17933, 17932, 18552, 18545, 17965, 17966, 17939, 17967, - 17945, 17940, 17941, 18502, 18503, 18504, 18547, 17943, 18539, 18058, - 17969, 17946, 17954, 17949, 17972, 18507, 18506, 18505, 17973, 17974, - 17976, 17934, 17986, 17920, 13548, 13551, 13547, 13550, 13546, 9418, - 22400, 22401, 22391, 22392, 22403, 22404, 22394, 22406, 22396, 22407, - 22408, 22409, 22410, 22411, 22412, 22395, 22398, 22399, 22413, 22393, - 22416, 22417, 22419, 22550, 22657, 22551, 22659, 22554, 22579, 22593, - 22647, 22632, 22662, 22600, 22670, 22681, 22610, 22597, 22630, 22633, - 22654, 22556, 22634, 22649, 22674, 22648, 22660, 22678, 22552, 22558, - 22601, 22584, 22602, 22578, 18708, 18716, 18718, 18719, 13757, 13753, - 13756, 13755, 13754, 18628, 18044, 18093, 18179, 18322, 18342, 18419, - 18447, 18440, 18486, 18522, 18690, 18574, 22468, 18250, 18532, 17988, - 18257, 18415, 17989, 18627, 18045, 18097, 18180, 18193, 18276, 18303, - 18323, 18348, 18420, 18450, 18487, 18166, 18635, 18662, 18691, 18007, - 18033, 18096, 18156, 18408, 18457, 18495, 18247, 18404, 18168, 18614, - 18174, 22658, 22559, 22577, 22595, 22641, 22598, 22585, 22646, 22669, - 22612, 22613, 22560, 22562, 22615, 22619, 22621, 22565, 22611, 22661, - 22629, 22628, 22571, 22555, 22635, 22645, 22594, 22650, 22676, 22677, - 22573, 22680, 22671, 22590, 22592, 22591, 22596, 22673, 7271, 7270, 7536, - 7535, 7482, 7370, 7484, 7153, 7369, 7152, 7428, 7165, 7485, 7280, 7497, - 7525, 7389, 7553, 7554, 7411, 7402, 7403, 7404, 7406, 7413, 7409, 7438, - 7394, 7440, 7417, 7395, 7396, 7442, 7397, 7398, 7427, 7431, 7419, 7446, - 7401, 7433, 7434, 7432, 7410, 7418, 7422, 7443, 7408, 7425, 7435, 7400, - 7421, 7424, 7550, 7393, 7392, 7265, 7563, 7268, 7259, 7278, 7162, 7451, - 7508, 17441, 18005, 17477, 18047, 17476, 18046, 17475, 18043, 17484, - 18062, 17509, 18099, 17508, 18098, 17507, 18094, 17503, 18088, 17504, - 18089, 17537, 18142, 17538, 18143, 17526, 18130, 17535, 18140, 17517, - 18121, 17562, 18182, 17570, 18192, 17589, 18212, 17588, 18211, 17586, - 18209, 17583, 18206, 17582, 18205, 17606, 18239, 17600, 18227, 17637, - 18274, 17634, 18271, 17638, 18275, 17645, 18288, 17646, 18289, 17656, - 18298, 17652, 18285, 17662, 18320, 17664, 18325, 17663, 18324, 17682, - 18347, 17681, 18346, 17676, 18339, 17672, 18334, 17713, 18383, 17712, - 18382, 17690, 18375, 17691, 18376, 17741, 18418, 17743, 18422, 17753, - 18437, 17751, 18435, 17752, 18436, 17758, 18442, 17779, 18480, 17777, - 18478, 17776, 18471, 17771, 18473, 17778, 18479, 17800, 18520, 17799, - 18519, 17801, 18523, 17795, 18513, 17831, 18595, 17852, 18618, 17824, - 18588, 17851, 18617, 17843, 18607, 17864, 18638, 17863, 18634, 17877, - 18651, 17878, 18652, 17874, 18648, 17876, 18650, 17875, 18649, 17883, - 18657, 17882, 18656, 17888, 18667, 17899, 18681, 17903, 18685, 17905, - 18687, 18213, 18518, 18653, 18677, 18006, 18313, 18312, 18314, 17789, - 18103, 17435, 17999, 17451, 18017, 17447, 18013, 17446, 18012, 17445, - 18011, 17449, 18015, 17448, 18014, 17430, 17994, 17429, 17993, 17428, - 17992, 17432, 17996, 17431, 17995, 17531, 18135, 17542, 18148, 17534, - 18139, 17522, 18126, 17521, 18125, 17520, 18124, 17525, 18129, 17524, - 18128, 17607, 18240, 17597, 18231, 17704, 18368, 17724, 18394, 17696, - 18360, 17695, 18359, 17694, 18358, 17698, 18362, 17697, 18361, 17721, - 18391, 17720, 18390, 17719, 18389, 17723, 18393, 17722, 18392, 17834, - 18598, 17841, 18605, 17838, 18602, 17837, 18601, 17836, 18600, 17840, - 18604, 17839, 18603, 17889, 18668, 17887, 18666, 17891, 18670, 17895, - 18676, 17667, 18328, 17668, 18329, 17892, 18671, 13595, 13587, 13600, - 13592, 13596, 13588, 13598, 13590, 13361, 13353, 13364, 13356, 13362, - 13354, 13366, 13358, 13618, 13615, 13620, 13617, 13619, 13616, 35536, - 35536, 13401, 13398, 13403, 13400, 13402, 13399, 35536, 35536, 13633, - 13625, 13638, 13630, 13634, 13626, 13636, 13628, 13385, 13377, 13388, - 13380, 13386, 13378, 13390, 13382, 13659, 13650, 13662, 13653, 13661, - 13652, 13660, 13651, 13413, 13408, 13416, 13411, 13415, 13410, 13414, - 13409, 13720, 13717, 13722, 13719, 13721, 13718, 35536, 35536, 13447, - 13444, 13449, 13446, 13448, 13445, 35536, 35536, 13679, 13670, 13682, - 13673, 13681, 13672, 13680, 13671, 35536, 13459, 35536, 13462, 35536, - 13461, 35536, 13460, 13700, 13692, 13705, 13697, 13701, 13693, 13703, - 13695, 13431, 13423, 13434, 13426, 13432, 13424, 13436, 13428, 13585, - 13605, 13622, 13621, 13645, 13643, 13665, 13666, 13724, 13723, 13685, - 13686, 13712, 13710, 35536, 35536, 13602, 13594, 13601, 13593, 13597, - 13589, 13599, 13591, 13368, 13360, 13365, 13357, 13363, 13355, 13367, - 13359, 13640, 13632, 13639, 13631, 13635, 13627, 13637, 13629, 13392, - 13384, 13389, 13381, 13387, 13379, 13391, 13383, 13707, 13699, 13706, - 13698, 13702, 13694, 13704, 13696, 13438, 13430, 13435, 13427, 13433, - 13425, 13437, 13429, 13584, 13609, 13586, 13607, 13606, 35536, 13603, - 13604, 13370, 13374, 13371, 13372, 13369, 13544, 13572, 13573, 13577, - 13493, 13646, 13647, 13644, 35536, 13641, 13642, 13405, 13404, 13395, - 13394, 13393, 13576, 13575, 13574, 13664, 13668, 13657, 13656, 35536, - 35536, 13663, 13655, 13417, 13421, 13418, 13419, 35536, 13501, 13500, - 13499, 13684, 13688, 13677, 13676, 13732, 13731, 13683, 13675, 13464, - 13468, 13465, 13466, 13454, 13495, 13494, 13771, 35536, 35536, 13713, - 13714, 13711, 35536, 13708, 13709, 13451, 13450, 13441, 13440, 13439, - 13569, 13498, 35536, 11889, 11886, 11891, 11888, 31540, 12641, 28108, - 12566, 26028, 31513, 14126, 35342, 35341, 35343, 18877, 26357, 15608, - 24061, 12565, 11890, 11887, 15552, 10369, 10343, 18800, 26287, 27983, - 27981, 18753, 26252, 10342, 10337, 9647, 10336, 5097, 32125, 24830, - 32272, 15575, 15611, 19185, 25369, 18876, 26356, 25902, 18875, 26355, - 23662, 25605, 25606, 25988, 10351, 32139, 26195, 26189, 26203, 6109, - 27982, 27984, 26212, 10373, 15950, 25183, 32323, 6395, 6110, 2572, 15610, - 12645, 18808, 26298, 10374, 26052, 12480, 31914, 26194, 3956, 3998, - 19854, 26200, 7136, 32284, 7569, 29091, 15968, 12605, 31520, 26048, - 12634, 12591, 32273, 12635, 10315, 32150, 33402, 21670, 33948, 12768, - 15970, 15972, 15971, 35536, 18874, 26354, 12584, 25901, 15864, 7, 15863, - 6, 23657, 24059, 29062, 29050, 35536, 35536, 29057, 29056, 29059, 29058, - 29049, 29063, 29053, 29055, 29048, 29052, 29054, 29051, 28892, 28894, - 28891, 28890, 28887, 28886, 28889, 28888, 28882, 28893, 28883, 28885, - 28881, 28880, 28884, 35536, 18705, 18706, 18714, 18720, 18704, 18707, - 18710, 18711, 18712, 18713, 18715, 18703, 18717, 35536, 35536, 35536, - 12476, 7149, 7815, 12652, 19793, 22285, 23590, 25629, 26677, 33952, - 23793, 10309, 12477, 17238, 32160, 10491, 13049, 25630, 13821, 2585, - 15616, 6228, 19794, 28444, 31285, 15854, 32242, 24111, 20359, 26546, - 17422, 3862, 28424, 26838, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 7458, 7516, 7473, - 7529, 7158, 7174, 7453, 7513, 7522, 7173, 7157, 7539, 7313, 7303, 7306, - 7309, 7304, 7462, 7305, 7307, 7308, 7505, 7294, 7159, 7546, 7564, 7464, - 7470, 7521, 7463, 7452, 7512, 7161, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 0, - 100, 10385, 9671, 6232, 6111, 5362, 12479, 26866, 9673, 26863, 26855, - 4046, 10386, 25791, 25792, 26856, 4047, 26857, 26864, 20031, 10387, - 24155, 28340, 26859, 10383, 10388, 26860, 4048, 10389, 25964, 26173, - 26969, 31179, 32110, 33395, 10390, 25177, 25187, 15967, 4049, 32265, - 16764, 963, 26852, 4045, 11946, 26862, 26853, 26854, 32249, 26858, 26865, - 348, 3753, 13052, 9660, 15861, 26534, 12545, 10397, 10396, 10382, 10384, - 10398, 32258, 32259, 26199, 32260, 10395, 10391, 10392, 10393, 10394, - 25992, 32244, 25607, 2643, 32262, 29170, 33546, 33544, 33548, 33549, - 33554, 33542, 33553, 33552, 33540, 33547, 33539, 33541, 33550, 33538, - 33555, 12646, 26502, 26513, 26514, 26501, 26498, 26507, 26509, 26517, - 26518, 26510, 26516, 26512, 26495, 26503, 26499, 26505, 28170, 28174, - 28175, 28169, 28166, 28178, 28177, 28165, 28179, 28176, 28164, 28173, - 28168, 28171, 28167, 28172, 26506, 26500, 26511, 26515, 18463, 26508, - 26497, 26496, 26504, 33556, 32253, 32252, 35536, 35536, 35536, 35536, - 18878, 32474, 26359, 10427, 18782, 32345, 24092, 24065, 28312, 28327, - 18898, 26383, 18962, 26460, 18959, 32524, 26459, 10463, 18901, 26386, - 18909, 32487, 26366, 10441, 32346, 18907, 26392, 18892, 26378, 18790, - 18785, 10467, 32484, 32485, 10436, 10437, 26374, 10428, 974, 7120, 24094, - 18889, 979, 7122, 18928, 18922, 32501, 32498, 26419, 26413, 10478, 10475, - 26394, 32476, 18912, 18974, 32527, 26426, 10486, 18929, 26420, 18965, - 18789, 26402, 18963, 32491, 26400, 10468, 18787, 32348, 24105, 24078, - 28324, 28337, 18949, 26450, 18978, 26430, 32477, 10429, 18969, 32492, - 26406, 10469, 18888, 26373, 18960, 32528, 26461, 10465, 32533, 32529, - 32531, 32530, 32535, 32536, 26462, 24093, 28315, 32350, 26239, 10439, - 31528, 18908, 26393, 18784, 18894, 26376, 18783, 18973, 26425, 18792, - 12630, 7574, 25515, 31507, 31506, 11879, 15782, 23546, 11828, 24114, - 28150, 7582, 10135, 28143, 11893, 23505, 23493, 23497, 22289, 22296, - 10310, 10117, 26974, 2571, 26471, 5098, 28671, 7821, 12640, 25991, 15855, - 26229, 959, 21544, 28447, 10121, 10136, 25374, 24119, 19808, 19815, - 15943, 32325, 15928, 10340, 32149, 7588, 29084, 33534, 7123, 7114, 976, - 31508, 3754, 26083, 25990, 10311, 12482, 12874, 15596, 31818, 26201, - 15964, 28103, 33956, 24124, 22295, 2578, 24115, 1058, 1061, 23749, 364, - 24116, 366, 32140, 361, 11932, 12872, 10127, 1062, 12873, 1059, 15745, - 7148, 11930, 26469, 26470, 7767, 11947, 11933, 28836, 9676, 11915, 21555, - 26054, 24126, 15621, 24127, 28873, 19078, 13285, 19080, 13288, 19069, - 13278, 23242, 23241, 3752, 24125, 24129, 24128, 23754, 23751, 19077, - 13284, 23753, 23750, 19079, 13286, 23755, 23752, 25965, 28910, 25974, - 28919, 25973, 28918, 10138, 10141, 28898, 29070, 24112, 24113, 28904, - 29076, 23747, 23748, 28903, 29075, 22995, 22996, 22997, 28544, 28633, - 28546, 28635, 28479, 28486, 6909, 6855, 6914, 6647, 6660, 6910, 6636, - 6919, 6661, 28804, 28797, 28818, 28752, 26316, 18826, 10404, 32354, 2579, - 22304, 32157, 12631, 32143, 10367, 10140, 24123, 10143, 23746, 25975, - 28920, 24109, 7583, 24110, 7584, 24862, 15744, 22998, 15367, 15951, - 33977, 23591, 24064, 26235, 26312, 23502, 23503, 23504, 23498, 9955, - 10312, 28838, 10119, 4474, 18840, 26274, 18798, 26285, 26202, 9064, 9063, - 10361, 10360, 10339, 10364, 25785, 11916, 19083, 13294, 33445, 33444, - 19067, 13289, 11914, 11913, 11911, 11912, 10139, 10142, 24120, 24121, - 28545, 28634, 19068, 13277, 25972, 28917, 24117, 10133, 24118, 10134, - 33401, 22281, 32353, 10407, 11829, 11831, 28151, 11834, 11833, 28152, - 11832, 11830, 7585, 7586, 28144, 7587, 28145, 35254, 9956, 11826, 15590, - 32337, 10408, 25989, 25624, 33720, 18749, 26247, 18837, 26256, 4457, - 4454, 32058, 32054, 26192, 28577, 2567, 26876, 26872, 31177, 25910, - 33458, 25788, 32256, 33711, 15588, 32053, 32057, 4453, 4456, 32047, 4451, - 12656, 28210, 32338, 24852, 11943, 33961, 16766, 18847, 26337, 11942, - 3700, 9642, 362, 29180, 32074, 10128, 7593, 28135, 7769, 7770, 1004, - 1042, 1028, 1016, 1017, 1033, 1014, 984, 989, 1039, 1044, 1030, 1029, - 1024, 1031, 1012, 1036, 1025, 1032, 987, 996, 995, 1018, 1021, 997, 1050, - 1023, 1047, 993, 1022, 1020, 1048, 1000, 1019, 1035, 994, 1001, 1010, - 988, 1049, 1034, 985, 1015, 1046, 991, 1040, 1009, 986, 998, 1011, 1052, - 1051, 990, 992, 1053, 1041, 1038, 1027, 1026, 999, 1045, 1002, 1037, - 1007, 1006, 1043, 1003, 1008, 1005, 24130, 26234, 27165, 3595, 33417, - 15927, 7591, 10042, 11885, 7573, 33865, 11907, 367, 15078, 6691, 6913, - 5038, 32324, 22878, 15614, 24848, 24849, 25529, 25530, 10037, 28228, - 1013, 9667, 25976, 23978, 25978, 7143, 18843, 18844, 18842, 26281, 26282, - 26280, 18805, 18812, 18804, 26295, 26302, 26294, 18747, 18745, 18746, - 9066, 26245, 26243, 26244, 15938, 15556, 32406, 32445, 28923, 28921, - 32061, 4460, 4461, 26063, 18846, 26318, 15565, 15566, 15567, 15568, 9689, - 9687, 9691, 9680, 9684, 9692, 9681, 9685, 9690, 9679, 9683, 9678, 9682, - 9688, 9686, 28512, 26174, 12509, 33412, 22117, 22109, 22116, 22110, - 22114, 22115, 22113, 22112, 22111, 10658, 12772, 32049, 4464, 32031, - 4463, 32062, 4467, 33874, 3701, 28864, 12596, 8, 11827, 9668, 3987, 3949, - 4030, 3926, 3988, 3950, 3990, 230, 28862, 31826, 15589, 3966, 3969, 3971, - 3963, 10365, 4009, 3871, 25924, 25921, 25922, 25923, 24237, 29165, 29173, - 29174, 29154, 29152, 29155, 29166, 29137, 29138, 29159, 29161, 29160, - 29158, 29139, 29171, 29172, 29141, 29150, 29149, 29148, 29147, 29163, - 29177, 29153, 29140, 29151, 29175, 29156, 29157, 29168, 29167, 29169, - 29178, 29142, 4053, 24835, 29164, 29145, 29176, 29144, 29143, 29146, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 24249, 24244, 24247, 24248, 24241, 24242, 24240, 24239, - 24246, 24243, 24245, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 6657, 6654, 6653, 6650, 6649, 6652, 6651, - 6658, 6656, 6878, 6858, 6903, 6891, 6873, 6861, 6877, 6875, 6857, 6904, - 6892, 25461, 25459, 25458, 25455, 25454, 25457, 25456, 25462, 25460, - 25453, 25444, 25452, 25450, 25445, 25446, 25448, 25449, 25443, 25447, - 25451, 9977, 9989, 9986, 9971, 9968, 9983, 9980, 9995, 9974, 24151, - 24144, 24152, 24150, 24145, 24146, 24147, 24149, 24143, 24154, 24153, - 25489, 25490, 25491, 25492, 25493, 25494, 25495, 25496, 25497, 25498, - 25499, 25500, 25501, 25502, 25503, 25504, 25505, 25506, 25507, 25508, - 25509, 25510, 25511, 25512, 25513, 25514, 6801, 6802, 6803, 6804, 6805, - 6806, 6807, 6808, 6809, 6810, 6811, 6812, 6813, 6814, 6815, 6816, 6817, - 6818, 6819, 6820, 6821, 6822, 6823, 6824, 6825, 6826, 6827, 6828, 6829, - 6830, 6831, 6832, 6833, 6834, 6835, 6836, 6837, 6838, 6839, 6840, 6841, - 6842, 6843, 6844, 6845, 6846, 6847, 6848, 6849, 6850, 6851, 6852, 6655, - 23671, 23669, 23667, 23672, 23673, 23675, 23676, 23670, 23674, 23668, - 10331, 10329, 10328, 10325, 10324, 10327, 10326, 10332, 10330, 10323, - 23666, 4586, 4532, 4602, 4518, 4595, 4531, 4594, 4530, 4593, 4529, 4592, - 4528, 4583, 4502, 4496, 4525, 4582, 4500, 4494, 4524, 4601, 4630, 4624, - 4517, 4600, 4628, 4622, 4515, 4609, 4646, 4623, 4495, 4643, 4501, 4629, - 4521, 4608, 4645, 4621, 4493, 4642, 4499, 4627, 4520, 4581, 4536, 4614, - 4504, 4498, 4617, 4539, 4523, 4599, 4535, 4613, 4631, 4625, 4616, 4538, - 4516, 4607, 4537, 4615, 4644, 4620, 4497, 4641, 4541, 4619, 4534, 4612, - 4503, 4626, 4618, 4540, 4519, 4585, 4527, 4584, 4526, 4492, 4488, 4509, - 4506, 4484, 4508, 4505, 4483, 4636, 4633, 4487, 4635, 4632, 4486, 4648, - 4639, 4491, 4647, 4638, 4490, 4510, 4507, 4482, 4637, 4634, 4485, 4649, - 4640, 4489, 4543, 4542, 4544, 4545, 4574, 4568, 4578, 4590, 4597, 4611, - 4580, 4511, 4513, 4533, 4522, 4591, 4598, 4512, 4514, 32383, 19955, - 19954, 19957, 19865, 19947, 19960, 19956, 12663, 18799, 18822, 18835, - 18763, 18823, 18778, 18779, 26260, 19099, 21671, 9654, 32431, 26277, - 26045, 26046, 26037, 26038, 26039, 26040, 26041, 26042, 26043, 26044, - 4007, 33852, 33861, 33855, 28690, 28699, 28689, 28696, 28698, 28688, - 4004, 33849, 4000, 33837, 4037, 33884, 3981, 33833, 4032, 33881, 4031, - 33880, 3989, 33841, 3994, 33840, 3993, 33839, 3928, 33796, 3927, 33795, - 3954, 33822, 3953, 33821, 3952, 33820, 3918, 33785, 33786, 12588, 19962, - 33771, 10314, 6630, 5101, 3867, 6622, 6631, 6623, 6628, 6627, 6629, - 18761, 26258, 15955, 15959, 32387, 19859, 32411, 32447, 19909, 19889, - 32392, 19866, 3961, 3960, 4033, 4034, 33735, 28693, 28700, 28695, 28692, - 33864, 33882, 32369, 32370, 17419, 33862, 33858, 33859, 33863, 33778, - 33776, 33777, 33779, 32409, 32464, 19900, 33829, 3976, 33828, 3975, - 19923, 4011, 7137, 32318, 28218, 7576, 4020, 33871, 19109, 31545, 28924, - 2568, 9697, 7594, 24856, 4026, 33873, 2795, 2801, 2802, 26684, 32320, - 15584, 33846, 4018, 27137, 26197, 3959, 3986, 33819, 33878, 33843, 33794, - 28114, 6225, 26061, 3864, 5361, 983, 24958, 6585, 7802, 7801, 28839, - 12555, 102, 14253, 25595, 35252, 32128, 32129, 32134, 32131, 32133, - 32132, 32130, 32127, 33731, 33806, 33850, 4006, 33869, 12581, 17423, - 22106, 12561, 10654, 20267, 16084, 26754, 32537, 23980, 25890, 2566, - 31166, 12855, 6099, 18983, 33460, 19797, 26848, 26682, 6105, 2646, 25783, - 33743, 33759, 33762, 33737, 33746, 33756, 3889, 3905, 3908, 3883, 3892, - 3902, 4019, 33809, 33790, 3917, 33851, 3938, 3923, 33780, 15585, 26050, - 11782, 3581, 3582, 23003, 23001, 23002, 33729, 10659, 32334, 26091, - 26092, 26093, 26094, 26095, 26096, 26097, 26098, 4036, 26090, 25520, - 25627, 33732, 9959, 9960, 9961, 9962, 9963, 9964, 33773, 33775, 3868, - 3870, 22875, 22876, 9999, 10002, 10001, 10000, 33800, 3934, 14254, 981, - 7810, 28833, 26843, 347, 12604, 12851, 28834, 2581, 12601, 25164, 31522, - 31521, 33705, 15435, 10400, 10401, 15942, 20266, 20265, 20264, 33418, - 15576, 21682, 21658, 21675, 20433, 10122, 32336, 7793, 12769, 23790, - 6235, 25329, 16085, 33447, 6588, 3977, 26976, 26888, 26056, 26971, 28223, - 3518, 28766, 33797, 33798, 3931, 3932, 28219, 28926, 26066, 4013, 31544, - 32248, 32247, 33791, 7811, 10041, 24855, 25768, 6167, 15077, 6643, 6236, - 24052, 368, 4027, 33876, 3957, 33817, 10500, 14934, 18750, 28809, 12549, - 4024, 26170, 26171, 2575, 14860, 25602, 26336, 18873, 15965, 3880, 27142, - 6620, 6227, 15540, 12852, 12853, 20362, 22894, 32319, 12642, 12598, - 12563, 26839, 28511, 28112, 15620, 25614, 31286, 15982, 14836, 12771, - 9059, 33801, 4014, 32376, 4017, 19941, 33844, 33810, 31178, 31165, 226, - 11904, 26079, 26071, 33451, 33959, 19940, 25604, 32446, 33832, 3979, - 6401, 14858, 22994, 14894, 2805, 14850, 25166, 14941, 24839, 14896, - 17912, 26981, 25163, 20268, 28837, 12638, 12636, 14879, 12632, 3935, - 33805, 28432, 28867, 6916, 24837, 3881, 25165, 14898, 25780, 26980, - 14849, 24838, 11781, 11776, 11774, 28106, 11775, 14872, 32268, 28109, - 31171, 24836, 14924, 28104, 3933, 33802, 11777, 6905, 14923, 28221, - 31816, 14857, 28431, 14917, 2794, 11780, 14874, 7807, 26979, 23738, - 19939, 32443, 19921, 32461, 4044, 33836, 33799, 3920, 14876, 19106, - 21679, 14940, 14907, 14908, 14868, 14869, 14891, 14890, 9071, 14877, - 14883, 14853, 26531, 12603, 26530, 21665, 21668, 21659, 21660, 21666, - 21669, 14887, 14900, 14886, 14899, 19098, 19096, 21664, 21667, 10024, - 10022, 10021, 10018, 10017, 10020, 10019, 10025, 10023, 10016, 10035, - 10032, 10031, 10028, 10027, 10030, 10029, 10036, 10034, 10026, 10014, - 10011, 10010, 10007, 10006, 10009, 10008, 10015, 10013, 10005, 14936, - 14939, 14895, 14865, 14913, 14901, 14920, 10492, 14904, 32122, 14926, - 9657, 14864, 3995, 31536, 31539, 3996, 14851, 14852, 28827, 14863, 26352, - 18863, 2658, 12654, 14892, 14931, 24132, 9065, 24134, 6693, 33888, 4050, - 4052, 4051, 14854, 14856, 14855, 31172, 14925, 33725, 14937, 24850, - 10333, 31519, 33875, 25608, 24846, 24845, 18797, 26284, 24960, 26181, - 29081, 33399, 21130, 19823, 20951, 28794, 28795, 33789, 982, 11836, - 19937, 32404, 18781, 26275, 12662, 17411, 17410, 18728, 18727, 18777, - 19845, 19828, 32355, 19963, 33781, 33782, 33783, 33857, 33860, 21131, - 21125, 21134, 21128, 21133, 21127, 21132, 21126, 21135, 21129, 32505, - 10482, 978, 7116, 26238, 19831, 19835, 19825, 19829, 19840, 19827, 19832, - 19839, 19830, 19841, 19844, 5027, 4772, 4900, 4773, 4964, 4837, 4901, - 4774, 4996, 4869, 4933, 4806, 4965, 4838, 4902, 4775, 5012, 4885, 4949, - 4822, 4981, 4854, 4918, 4791, 4997, 4870, 4934, 4807, 4966, 4839, 4903, - 4776, 5020, 4893, 4957, 4830, 4989, 4862, 4926, 4799, 5005, 4878, 4942, - 4815, 4974, 4847, 4911, 4784, 5013, 4886, 4950, 4823, 4982, 4855, 4919, - 4792, 4998, 4871, 4935, 4808, 4967, 4840, 4904, 4777, 5024, 4897, 4961, - 4834, 4993, 4866, 4930, 4803, 5009, 4882, 4946, 4819, 4978, 4851, 4915, - 4788, 5017, 4890, 4954, 4827, 4986, 4859, 4923, 4796, 5002, 4875, 4939, - 4812, 4971, 4844, 4908, 4781, 5021, 4894, 4958, 4831, 4990, 4863, 4927, - 4800, 5006, 4879, 4943, 4816, 4975, 4848, 4912, 4785, 5014, 4887, 4951, - 4824, 4983, 4856, 4920, 4793, 4999, 4872, 4936, 4809, 4968, 4841, 4905, - 4778, 5026, 4899, 4963, 4836, 4995, 4868, 4932, 4805, 5011, 4884, 4948, - 4821, 4980, 4853, 4917, 4790, 5019, 4892, 4956, 4829, 4988, 4861, 4925, - 4798, 5004, 4877, 4941, 4814, 4973, 4846, 4910, 4783, 5023, 4896, 4960, - 4833, 4992, 4865, 4929, 4802, 5008, 4881, 4945, 4818, 4977, 4850, 4914, - 4787, 5016, 4889, 4953, 4826, 4985, 4858, 4922, 4795, 5001, 4874, 4938, - 4811, 4970, 4843, 4907, 4780, 5025, 4898, 4962, 4835, 4994, 4867, 4931, - 4804, 5010, 4883, 4947, 4820, 4979, 4852, 4916, 4789, 5018, 4891, 4955, - 4828, 4987, 4860, 4924, 4797, 5003, 4876, 4940, 4813, 4972, 4845, 4909, - 4782, 5022, 4895, 4959, 4832, 4991, 4864, 4928, 4801, 5007, 4880, 4944, - 4817, 4976, 4849, 4913, 4786, 5015, 4888, 4952, 4825, 4984, 4857, 4921, - 4794, 5000, 4873, 4937, 4810, 4969, 4842, 4906, 4779, 26456, 26455, - 18964, 26401, 18788, 26457, 18966, 26403, 10438, 32486, 32523, 10462, - 18968, 26405, 18948, 26449, 26458, 26375, 32488, 10442, 26388, 26387, - 26451, 26453, 26452, 18913, 26395, 18967, 26404, 18890, 26372, 18910, - 26367, 24091, 24071, 24097, 24069, 28316, 28329, 24096, 24068, 28313, - 28328, 26475, 12547, 28314, 24066, 12548, 26476, 24067, 24095, 33714, - 2559, 2558, 2561, 2562, 26353, 18862, 32028, 4462, 32030, 32029, 19919, - 19883, 975, 7113, 26362, 18879, 27152, 26380, 18895, 26371, 18786, 32526, - 18740, 18739, 32343, 32342, 18741, 32344, 18738, 32341, 18927, 26418, - 32500, 10477, 18921, 26412, 32497, 10474, 18926, 26417, 32499, 10476, - 18920, 26411, 32496, 10473, 18923, 32495, 26416, 10471, 18925, 18919, - 26414, 26409, 18924, 18918, 26415, 26410, 32494, 10472, 26250, 11921, - 31820, 18883, 26364, 26363, 19064, 18886, 13273, 28897, 18885, 29067, - 18836, 26255, 32352, 10406, 32142, 35265, 35266, 18828, 26321, 18830, - 26323, 35260, 35256, 35261, 35257, 18809, 26299, 18807, 26296, 18806, - 26297, 18734, 26231, 18735, 26237, 10346, 10371, 18743, 26241, 10321, - 33432, 21553, 26236, 21554, 960, 5, 28448, 28449, 32245, 26187, 961, - 26188, 24235, 24234, 21552, 21551, 21546, 21545, 21550, 21548, 21549, - 21547, 26209, 11883, 11882, 11880, 11881, 6632, 6920, 6907, 6911, 6908, - 6633, 6625, 6634, 32340, 6915, 6638, 6853, 6921, 6624, 6626, 28758, - 28753, 28824, 28810, 28811, 32278, 32121, 32119, 26679, 32118, 26313, - 18814, 33396, 4475, 4476, 4043, 31827, 31828, 33814, 3942, 18833, 26326, - 18751, 26251, 15779, 31754, 15856, 10399, 28701, 15781, 27172, 11922, - 11923, 15622, 13157, 31510, 10419, 10420, 3921, 3962, 33774, 3869, 11936, - 11939, 11935, 11938, 11934, 11937, 26548, 26182, 28275, 26183, 3857, - 3856, 10353, 32138, 18850, 26339, 31829, 22297, 23492, 23490, 23491, - 23500, 23499, 23495, 23496, 32280, 32279, 23494, 22700, 28922, 26047, - 12574, 15937, 15929, 6925, 980, 19181, 19182, 19183, 15930, 26049, 15934, - 15931, 15935, 15933, 15936, 15932, 16082, 17412, 35262, 35263, 35264, - 25882, 25887, 25885, 25881, 25884, 25883, 25886, 22290, 22291, 22293, - 22292, 25878, 25879, 33449, 22993, 22992, 26887, 28195, 22988, 22989, - 6854, 22990, 6648, 25880, 22294, 22991, 15952, 26358, 35258, 374, 15948, - 32329, 32330, 15947, 15946, 32331, 32327, 15945, 32326, 15944, 32328, - 15949, 7129, 7135, 10354, 10355, 7130, 19811, 19819, 10344, 10345, 32276, - 32277, 28134, 28133, 19816, 19813, 19821, 19812, 19820, 19810, 19814, - 19809, 28185, 19818, 19817, 35259, 35255, 11928, 15623, 32136, 32137, - 31822, 31821, 27978, 7595, 11929, 365, 1060, 11918, 25888, 11919, 10334, - 32271, 31530, 11927, 11931, 19081, 13292, 19082, 13293, 19073, 13279, - 19076, 13282, 19074, 13280, 19075, 13281, 19072, 13283, 19066, 13275, - 19065, 13274, 19063, 13271, 19061, 13269, 19060, 13268, 19059, 13272, - 19062, 13270, 28119, 28117, 28120, 28118, 10381, 10380, 10377, 10376, - 27977, 27976, 27975, 27974, 10347, 10349, 10348, 13287, 13276, 19070, - 13290, 19071, 13291, 28193, 17420, 28194, 17421, 11924, 25968, 28913, - 25969, 28914, 25971, 28916, 25967, 28912, 25970, 28915, 25966, 28911, - 10350, 10359, 28908, 29080, 28907, 29079, 28906, 29078, 28905, 29077, - 28900, 29072, 28901, 29073, 28899, 29071, 28902, 29074, 28579, 28666, - 7124, 7126, 7125, 7127, 28895, 29066, 28896, 29065, 29069, 29068, 11835, - 25786, 32114, 12626, 24063, 27151, 27157, 27154, 25609, 33398, 10368, - 33397, 10366, 19822, 27158, 27156, 27155, 10335, 10363, 10357, 26191, - 10137, 33414, 33413, 10405, 25373, 25372, 32141, 32144, 32135, 32148, - 32147, 10379, 10378, 32145, 17409, 10362, 33886, 23501, 24080, 24107, - 28326, 28339, 18791, 18917, 32490, 10444, 24077, 24104, 28323, 28336, - 18793, 32347, 26384, 26385, 18899, 18900, 28694, 28687, 28697, 28691, - 9951, 9952, 9950, 9949, 10317, 3948, 33815, 4041, 33887, 3982, 33834, - 33812, 3939, 15551, 3943, 3965, 33826, 3968, 33830, 4001, 4002, 33847, - 3941, 33813, 4038, 33883, 18737, 31523, 18736, 19833, 18956, 18955, - 18957, 18958, 18893, 18903, 18902, 18951, 18953, 18952, 18887, 33713, - 11920, 26184, 18880, 26370, 26369, 18982, 26465, 26185, 26360, 31819, - 18882, 18881, 26361, 10458, 27149, 27147, 33827, 4003, 33848, 3992, - 33838, 14884, 14897, 14861, 14859, 14862, 28121, 2656, 28122, 2655, 3698, - 27148, 18933, 32509, 26434, 10447, 18795, 32351, 24102, 24075, 28321, - 28334, 18945, 32520, 26446, 10459, 7121, 973, 18944, 32511, 26445, 10449, - 35536, 35536, 24103, 24076, 28322, 28335, 18935, 32519, 26436, 10457, - 15572, 33427, 18934, 32510, 26435, 10448, 18946, 32521, 26447, 10460, - 18916, 32489, 26398, 10446, 970, 971, 969, 972, 26175, 26176, 23975, - 23976, 12633, 26399, 11926, 29179, 31534, 31538, 31535, 31537, 3955, - 4035, 3997, 3929, 10451, 10452, 32513, 32514, 18938, 26439, 18937, 26438, - 3872, 3873, 3874, 3875, 3876, 3878, 3877, 3879, 26222, 26223, 26220, - 26221, 26217, 26219, 26216, 26218, 32534, 32339, 25181, 25180, 25182, - 2800, 6923, 6637, 4008, 3919, 32246, 15550, 4042, 3972, 3964, 3967, 3970, - 23981, 32046, 4450, 19094, 26532, 33804, 26533, 28651, 32322, 13819, - 25894, 25893, 25892, 25891, 32113, 25993, 2576, 15606, 25767, 23758, - 33831, 3922, 32158, 9061, 14834, 35344, 17245, 1055, 97, 33537, 25905, - 18762, 26259, 28840, 28841, 18954, 32525, 26454, 10464, 11941, 11940, - 26977, 26674, 26672, 26673, 26671, 26675, 26676, 11925, 32333, 26968, - 10402, 25528, 26198, 15079, 13057, 13059, 13093, 13067, 13063, 13094, - 13101, 13064, 13100, 13073, 13069, 13068, 13062, 13104, 13075, 13076, - 13077, 13078, 13080, 13082, 13086, 13090, 13103, 13065, 13102, 13079, - 13081, 13083, 13092, 13061, 13085, 13096, 13095, 13097, 13087, 13099, - 13088, 13089, 13098, 13071, 13058, 13070, 13066, 13072, 13084, 13091, - 13074, 13060, 13105, 13107, 13141, 13115, 13111, 13142, 13149, 13112, - 13148, 13121, 13117, 13116, 13110, 13152, 13123, 13124, 13125, 13126, - 13128, 13130, 13134, 13138, 13151, 13113, 13150, 13127, 13129, 13131, - 13140, 13109, 13133, 13144, 13143, 13145, 13135, 13147, 13136, 13137, - 13146, 13119, 13106, 13118, 13114, 13120, 13132, 13139, 13122, 13108, - 17644, 18291, 17647, 17738, 17756, 18025, 18517, 17587, 18210, 17633, - 18270, 17902, 18684, 17465, 17666, 17806, 17807, 18637, 17879, 18654, - 18636, 17592, 18217, 18582, 18138, 18558, 18372, 17950, 18709, 22418, - 17782, 17906, 7603, 7697, 7653, 7747, 7617, 7711, 7614, 7708, 7658, 7752, - 7648, 7742, 7652, 7746, 7619, 7713, 7650, 7744, 7656, 7750, 7622, 7716, - 7627, 7721, 7659, 7753, 7660, 7754, 7623, 7717, 7628, 7722, 7655, 7749, - 7657, 7751, 7649, 7743, 7651, 7745, 7661, 7755, 7625, 7719, 7621, 7715, - 7654, 7748, 7644, 7738, 7611, 7705, 7639, 7733, 7607, 7701, 7612, 7706, - 7613, 7707, 7608, 7702, 7637, 7731, 7647, 7741, 7609, 7703, 7635, 7729, - 7638, 7732, 7602, 7696, 7610, 7704, 7630, 7724, 7631, 7725, 7626, 7720, - 7633, 7727, 7632, 7726, 7629, 7723, 7636, 7730, 7634, 7728, 7642, 7736, - 7640, 7734, 7641, 7735, 7643, 7737, 7757, 7758, 7759, 7761, 7762, 7756, - 7760, 7605, 7699, 7606, 7700, 7601, 7600, 7599, 7604, 7698, 35536, 35536, - 35536, 35536, 35536, 7695, 7692, 7693, 7694, 7690, 7691, 7763, 12916, - 12942, 12927, 12948, 12949, 12947, 12937, 12938, 12950, 12931, 12940, - 12943, 12945, 12951, 12933, 12936, 12941, 12935, 12939, 12952, 12932, - 12930, 12926, 12946, 12934, 12922, 12925, 12929, 12924, 12923, 12944, - 12928, 12917, 12921, 12919, 12954, 12918, 12920, 35536, 12953, 35536, - 35536, 35536, 35536, 35536, 12915, 35536, 35536, 31769, 31789, 31790, - 31770, 31772, 31759, 31798, 31785, 31788, 31786, 31787, 31808, 31797, - 31773, 31763, 31775, 31791, 31758, 31767, 31792, 31796, 31774, 31764, - 31803, 31768, 31809, 31783, 31757, 31765, 31799, 31800, 31801, 31762, - 31766, 31802, 31811, 31793, 31794, 31771, 31761, 31756, 31776, 31778, - 31777, 31779, 31780, 31795, 31781, 31804, 31805, 31806, 31782, 31760, - 31784, 31807, 31810, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 31812, 31813, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 31755, 12376, 12193, 12280, - 12320, 12296, 11983, 12358, 12021, 12211, 12202, 12103, 12436, 12051, - 12036, 12367, 12327, 12012, 12227, 12240, 12088, 12092, 12091, 12090, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 12310, - 12316, 12314, 12311, 12313, 12312, 12315, 35536, 12002, 12008, 12006, - 12003, 12005, 12004, 12007, 35536, 12426, 12432, 12430, 12427, 12429, - 12428, 12431, 35536, 11995, 12001, 11999, 11996, 11998, 11997, 12000, - 35536, 12262, 12268, 12266, 12263, 12265, 12264, 12267, 35536, 12171, - 12177, 12175, 12172, 12174, 12173, 12176, 35536, 12403, 12409, 12407, - 12404, 12406, 12405, 12408, 35536, 12114, 12120, 12118, 12115, 12117, - 12116, 12119, 35536, 7183, 7221, 7218, 7185, 7215, 7216, 7222, 7189, - 7190, 7191, 7198, 7220, 7192, 7186, 7214, 7211, 7213, 7217, 7201, 7200, - 7219, 7187, 7223, 7197, 7184, 7210, 7206, 7208, 7195, 7209, 7182, 7194, - 26233, 26232, 18813, 26303, 18755, 26248, 26070, 26069, 10320, 18816, - 26311, 26078, 18796, 26283, 10661, 25371, 12625, 26193, 15613, 10319, - 10443, 32473, 10322, 10370, 15961, 25330, 15609, 31825, 18776, 26273, - 31824, 31823, 18845, 26317, 32055, 32059, 4455, 4458, 18801, 26288, - 18754, 26253, 32274, 24829, 28754, 12592, 26208, 33430, 26468, 33947, - 32250, 26068, 26080, 32261, 9648, 9649, 32251, 32044, 32286, 31541, - 28854, 33433, 33930, 6104, 10338, 26207, 10341, 9655, 10358, 15962, - 15963, 19855, 19856, 10356, 10316, 32146, 21655, 25370, 26027, 7766, - 7803, 7804, 31913, 21654, 21656, 18811, 26301, 18810, 26300, 32036, - 32040, 4441, 4445, 24236, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 7007, 6960, 7010, - 7009, 7008, 7003, 6931, 7028, 7042, 7041, 6964, 7011, 7024, 7023, 6993, - 6992, 6991, 6990, 7020, 7029, 7019, 7018, 6979, 6978, 6982, 7006, 35536, - 6963, 7026, 7000, 6965, 6998, 6958, 7034, 7033, 6972, 7002, 7001, 7012, - 6962, 6966, 6987, 6929, 6971, 7022, 7021, 6934, 7017, 6945, 7040, 7039, - 7038, 7037, 6995, 7025, 7005, 6970, 7043, 6933, 6932, 6994, 6999, 6976, - 6975, 6974, 7030, 6961, 7036, 7035, 6949, 7013, 6981, 6948, 6947, 6973, - 6957, 7014, 7032, 7031, 6959, 6941, 6989, 6988, 6944, 6942, 6997, 6996, - 7004, 6935, 6951, 6943, 6953, 6939, 6969, 6968, 6967, 6937, 6980, 6956, - 6930, 6977, 6938, 6955, 6946, 7015, 7016, 6940, 6986, 6936, 6984, 6952, - 6985, 6954, 7027, 6983, 6950, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 16281, 16263, 16197, 16317, - 16305, 16249, 16349, 16264, 16277, 16260, 16212, 16216, 16201, 16186, - 16252, 16338, 16284, 16255, 16289, 16366, 16323, 16294, 16246, 16351, - 16195, 16306, 16182, 16286, 16157, 16275, 16211, 16209, 16304, 16232, - 16234, 16214, 16164, 16363, 16189, 16297, 16251, 16333, 16256, 16184, - 16322, 16273, 16295, 16364, 16282, 16347, 16207, 16312, 16198, 16266, - 16350, 16313, 16172, 16331, 16173, 16325, 16243, 16240, 16203, 16241, - 16174, 16292, 16303, 16196, 16159, 16334, 16279, 16336, 16302, 16276, - 16346, 16257, 16326, 16191, 16357, 16202, 16185, 16231, 16180, 16324, - 16356, 16223, 16181, 16218, 16200, 16239, 16318, 16220, 16188, 16204, - 16287, 16253, 16267, 16341, 16330, 16262, 16368, 16221, 16168, 16314, - 16199, 16359, 16335, 16194, 16217, 16319, 16155, 16328, 16321, 16345, - 16235, 16179, 16329, 16160, 16296, 16315, 16254, 16280, 16310, 16229, - 16285, 16158, 16288, 16208, 16175, 16268, 16269, 16307, 16156, 16271, - 16342, 16283, 16169, 16327, 16187, 16236, 16340, 16250, 16165, 16355, - 16183, 16358, 16308, 16248, 16320, 16352, 16176, 16290, 16161, 16309, - 16299, 16298, 16230, 16171, 16178, 16162, 16272, 16354, 16190, 16362, - 16193, 16353, 16233, 16265, 16238, 16274, 16316, 16311, 16291, 16167, - 16365, 16219, 16258, 16337, 16261, 16332, 16259, 16361, 16226, 16210, - 16244, 16227, 16247, 16170, 16339, 16242, 16222, 16300, 16177, 16237, - 16224, 16163, 16301, 16192, 16360, 16245, 16367, 16270, 16166, 16215, - 16228, 16344, 16206, 16293, 16278, 16213, 16343, 16205, 16348, 16225, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 15646, 15644, 15645, 15643, - 15658, 15654, 15653, 15650, 15651, 15652, 15648, 15647, 15655, 15649, - 15659, 15657, 15743, 15642, 15741, 10126, 15981, 15742, 15641, 15661, - 18733, 26230, 18752, 26249, 18748, 26246, 18827, 26320, 18742, 26240, - 25907, 13050, 18824, 26315, 18829, 26322, 18832, 26325, 18831, 26324, - 33712, 26190, 10352, 19853, 25908, 14730, 14723, 14720, 14726, 14725, - 14728, 14727, 14731, 14729, 15739, 15738, 15660, 15737, 14389, 14388, - 33718, 33405, 33408, 33406, 33409, 33407, 6906, 15735, 14724, 14722, - 14721, 33404, 20512, 25525, 15740, 15736, 35536, 15455, 15441, 15457, - 15535, 15459, 15537, 15456, 15534, 15458, 15536, 15496, 15486, 15498, - 15488, 15500, 15490, 15497, 15487, 15499, 15489, 15460, 15521, 15462, - 15523, 15464, 15525, 15461, 15522, 15463, 15524, 15516, 15481, 15518, - 15483, 15454, 15520, 15485, 15517, 15482, 15519, 15484, 15476, 15478, - 15480, 15477, 15479, 15491, 15471, 15506, 15493, 15465, 15508, 15495, - 15474, 15510, 15492, 15472, 15507, 15494, 15473, 15509, 15501, 15503, - 15505, 15502, 15504, 15448, 15530, 15450, 15532, 15449, 15531, 15511, - 15513, 15515, 15512, 15514, 15444, 15526, 15528, 15527, 15529, 15475, - 15533, 15451, 15452, 35536, 35536, 7391, 7390, 16607, 16606, 15539, - 15538, 15440, 16604, 16534, 16463, 16536, 16597, 16538, 16599, 16535, - 16596, 16537, 16598, 16559, 16549, 16561, 16551, 16563, 16553, 16560, - 16550, 16562, 16552, 16539, 16584, 16541, 16586, 16543, 16588, 16540, - 16585, 16542, 16587, 16574, 16544, 16576, 16546, 16521, 16578, 16548, - 16575, 16545, 16577, 16547, 16501, 16503, 16505, 16502, 16504, 16554, - 16478, 16564, 16556, 16472, 16566, 16558, 16481, 16568, 16555, 16479, - 16565, 16557, 16480, 16567, 16496, 16482, 16499, 16497, 16498, 16526, - 16593, 16528, 16595, 16527, 16594, 16569, 16571, 16573, 16570, 16572, - 16522, 16589, 16591, 16590, 16592, 16500, 16583, 16516, 16517, 16579, - 16581, 16580, 16582, 16603, 16605, 16602, 16600, 16601, 35536, 35536, - 35536, 35536, 35536, 4422, 4430, 4429, 4427, 4426, 4433, 4398, 4418, - 4386, 4414, 4428, 4424, 4431, 4435, 4411, 4417, 4421, 4432, 4410, 4416, - 4420, 4366, 4402, 4378, 4383, 4367, 4384, 4369, 4409, 4371, 4379, 4372, - 4380, 4385, 4391, 4376, 4397, 4434, 4399, 4388, 4394, 4405, 4401, 35536, - 14642, 14686, 14643, 14648, 14649, 14651, 14678, 14689, 14664, 14665, - 14667, 14669, 14676, 14672, 14668, 14675, 14644, 14654, 14688, 14655, - 14679, 14691, 14636, 14631, 14685, 14630, 14641, 14677, 14662, 14715, - 14626, 14629, 14712, 14713, 14633, 14632, 14699, 14698, 14716, 14695, - 14696, 14717, 14704, 14718, 14694, 14693, 14697, 14708, 14634, 14714, - 14635, 14719, 14687, 14650, 14653, 14652, 14666, 14673, 14670, 14671, - 14674, 14645, 14647, 14646, 14640, 14661, 14659, 14656, 14657, 14660, - 14658, 14638, 14639, 14681, 14682, 14684, 14683, 14680, 14663, 14692, - 14701, 14703, 14702, 14637, 14690, 14700, 14705, 14706, 14707, 14710, - 14709, 14711, 14627, 14628, 35536, 15635, 15638, 15637, 15633, 15631, - 15627, 15634, 15629, 15625, 15628, 15636, 15632, 15626, 15639, 15640, - 15630, 4423, 4412, 4425, 4389, 4382, 4381, 4408, 4404, 4396, 4373, 4392, - 4377, 4395, 4400, 4368, 4370, 4375, 4407, 4403, 4393, 4364, 4365, 4363, - 4362, 4387, 4419, 4413, 4361, 4390, 4415, 4406, 4374, 7074, 7077, 7078, - 7076, 7064, 7050, 7056, 7045, 7055, 7068, 7057, 7053, 7046, 7054, 7051, - 7080, 7044, 7063, 7059, 7072, 7079, 7049, 7058, 7067, 7066, 7073, 7071, - 7060, 7062, 7075, 7070, 7065, 7047, 7052, 7061, 7081, 7048, 7069, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 15656, 16519, - 16531, 16532, 16520, 16530, 16506, 16508, 16510, 16507, 16509, 16533, - 16511, 16513, 16515, 16512, 16514, 25385, 25389, 25401, 25395, 25387, - 25393, 25397, 25403, 25378, 25376, 25383, 25399, 25391, 25381, 25386, - 25390, 25402, 25396, 25388, 25394, 25398, 25404, 25379, 25377, 25384, - 25400, 25392, 25382, 25380, 25442, 25441, 35536, 25440, 25436, 25434, - 25415, 25413, 25433, 25425, 25410, 25419, 25435, 25418, 25412, 25438, - 25437, 25417, 25409, 25432, 25430, 25439, 25427, 25420, 25428, 25411, - 25406, 25416, 25423, 25407, 25429, 25431, 25408, 25421, 25405, 25414, - 25422, 25426, 25424, 6725, 6713, 6735, 6714, 6879, 6893, 6881, 6863, - 6860, 6876, 6874, 6856, 25524, 6894, 6900, 6899, 6896, 6895, 6898, 6897, - 6902, 6901, 6880, 6882, 6888, 6887, 6884, 6883, 6673, 6677, 6689, 6683, - 6675, 6681, 6685, 6666, 6664, 6662, 6671, 6687, 6679, 6669, 6674, 6678, - 6690, 6684, 6676, 6682, 6686, 6667, 6665, 6663, 6672, 6688, 6680, 6670, - 6800, 6799, 6668, 17243, 6748, 6744, 6742, 6710, 6708, 6740, 6731, 6705, - 6723, 6743, 6721, 6707, 6746, 6745, 6719, 6703, 6734, 6739, 6712, 6736, - 6724, 6737, 6706, 6699, 6715, 6730, 6720, 6709, 6733, 6704, 6741, 6696, - 6747, 6727, 6700, 6698, 6711, 6701, 6716, 6717, 6729, 6718, 6728, 6738, - 6732, 6702, 6726, 6694, 6722, 6886, 6885, 6890, 6889, 6862, 6864, 6870, - 6869, 6866, 6865, 6868, 6867, 6872, 6871, 6859, 15726, 15729, 15730, - 15668, 15731, 15727, 15728, 15667, 15733, 15734, 15732, 15700, 28539, - 28505, 28507, 19180, 6794, 6796, 6798, 6795, 6797, 6757, 6759, 6761, - 6758, 6760, 6777, 6779, 6781, 6778, 6780, 6782, 6784, 6786, 6783, 6785, - 6767, 6769, 6771, 6768, 6770, 6752, 6754, 6756, 6753, 6755, 6762, 6764, - 6766, 6763, 6765, 6791, 6793, 6792, 6772, 6774, 6776, 6773, 6775, 6787, - 6789, 6788, 6790, 28503, 28464, 28466, 28465, 28467, 28542, 28543, 28706, - 28506, 28499, 28632, 28636, 28551, 28549, 28550, 28514, 28515, 28519, - 28518, 28565, 28517, 28552, 28555, 28553, 28554, 28520, 28521, 28562, - 28563, 28564, 28561, 28560, 28672, 28673, 28680, 28674, 28675, 28490, - 28494, 28495, 28685, 28625, 28626, 28527, 28639, 28640, 28471, 28648, - 28646, 28647, 28474, 28534, 28533, 28473, 28535, 28528, 28645, 28643, - 28529, 28644, 28642, 28476, 28649, 28475, 28532, 28650, 28530, 28531, - 28589, 28590, 28593, 28592, 28591, 28599, 28600, 28601, 28596, 28597, - 28598, 28704, 28703, 28705, 28667, 28668, 28670, 28669, 28665, 28664, - 28686, 15724, 15725, 15707, 15709, 15716, 15715, 15722, 15720, 15711, - 15718, 15710, 15713, 15706, 15708, 15717, 15714, 15723, 15721, 15712, - 15719, 15701, 15705, 15704, 15703, 15702, 28537, 28489, 28469, 28472, - 28637, 28653, 28491, 28493, 28492, 28547, 28500, 28504, 28501, 28502, - 28481, 28641, 28624, 28606, 28588, 28548, 28570, 28594, 28524, 28478, - 28567, 28654, 28627, 28607, 28608, 28621, 28571, 28540, 28566, 28618, - 28522, 28684, 28609, 28622, 28498, 28573, 28513, 28628, 28610, 28603, - 28482, 28556, 28605, 28484, 28587, 28559, 28604, 28483, 28586, 28558, - 28583, 28584, 28638, 28569, 28620, 28523, 28661, 28662, 28663, 28658, - 28629, 28611, 28623, 28659, 28630, 28612, 28614, 28575, 28615, 28660, - 28631, 28613, 28616, 28576, 28617, 28568, 28585, 28468, 28477, 28487, - 28488, 28485, 28480, 28496, 28525, 28526, 28536, 28541, 28572, 28557, - 28574, 28580, 28581, 28578, 28582, 28595, 28602, 28619, 28655, 28656, - 28652, 28657, 28681, 28682, 28702, 28470, 28462, 15699, 15684, 15672, - 15691, 15690, 15697, 15695, 15686, 15693, 15685, 15688, 15683, 15671, - 15692, 15689, 15698, 15696, 15687, 15694, 15673, 15681, 15679, 15678, - 15675, 15674, 15677, 15676, 15682, 15680, 15669, 15670, 28516, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 15417, 15420, 15381, - 15431, 15428, 15376, 15414, 15393, 15410, 15427, 15405, 15411, 15386, - 15388, 15398, 15432, 15385, 15429, 15369, 15375, 15373, 15392, 15412, - 15406, 15394, 15391, 15399, 15390, 15415, 15418, 15397, 15383, 15407, - 15389, 15404, 15384, 15419, 15402, 15400, 15379, 15378, 15396, 15374, - 15377, 15387, 15403, 15401, 15421, 15408, 15416, 15413, 15425, 15380, - 15423, 15371, 15422, 15424, 15426, 15382, 15430, 15395, 15409, 15370, - 15372, 34469, 34476, 34468, 34475, 34473, 34474, 34471, 34472, 35244, - 35245, 35242, 35243, 35241, 35239, 35240, 35248, 35249, 35246, 35247, - 35251, 35250, 35116, 34136, 34137, 34130, 34135, 34133, 34134, 34131, - 34132, 34140, 34141, 34138, 34139, 34121, 34119, 34120, 34144, 34145, - 34142, 34143, 34129, 34127, 34128, 34125, 34126, 34118, 34124, 34123, - 34122, 34150, 34151, 34146, 34149, 34148, 34147, 34848, 34849, 34843, - 34847, 34846, 34844, 34845, 34852, 34853, 34850, 34851, 34837, 34835, - 34836, 34856, 34857, 34854, 34855, 34841, 34842, 34834, 34840, 34839, - 34838, 34862, 34863, 34858, 34861, 34860, 34859, 34104, 34105, 34098, - 34103, 34101, 34102, 34099, 34100, 34108, 34109, 34106, 34107, 34089, - 34087, 34088, 34112, 34113, 34110, 34111, 34097, 34095, 34096, 34093, - 34094, 34086, 34092, 34091, 34090, 34116, 34117, 34114, 34115, 34651, - 34652, 34646, 34650, 34649, 34647, 34648, 34655, 34656, 34653, 34654, - 34659, 34660, 34657, 34658, 34665, 34666, 34661, 34664, 34663, 34662, - 34671, 34672, 34667, 34670, 34669, 34668, 34394, 34395, 34389, 34393, - 34392, 34390, 34391, 34398, 34399, 34396, 34397, 34383, 34381, 34382, - 34402, 34403, 34400, 34401, 34387, 34388, 34380, 34386, 34385, 34384, - 34408, 34404, 34407, 34406, 34405, 34630, 34631, 34625, 34629, 34628, - 34626, 34627, 34634, 34635, 34632, 34633, 34618, 34619, 34616, 34617, - 34638, 34639, 34636, 34637, 34645, 34644, 34623, 34624, 34615, 34622, - 34621, 34620, 34642, 34643, 34640, 34641, 34275, 34276, 34273, 34274, - 34271, 34272, 34269, 34270, 34268, 34266, 34267, 34285, 34286, 34281, - 34284, 34283, 34282, 34279, 34280, 34277, 34278, 35094, 35095, 35088, - 35093, 35091, 35092, 35089, 35090, 35098, 35099, 35096, 35097, 35102, - 35103, 35100, 35101, 35087, 35086, 35108, 35109, 35104, 35107, 35106, - 35105, 35114, 35115, 35110, 35113, 35112, 35111, 34253, 34254, 34248, - 34252, 34251, 34249, 34250, 34260, 34261, 34258, 34259, 34242, 34241, - 34264, 34265, 34262, 34263, 34257, 34255, 34256, 34246, 34247, 34240, - 34245, 34244, 34243, 35073, 35074, 35068, 35072, 35071, 35069, 35070, - 35080, 35081, 35078, 35079, 35061, 35062, 35059, 35060, 35084, 35085, - 35082, 35083, 35077, 35075, 35076, 35066, 35067, 35058, 35065, 35064, - 35063, 34227, 34228, 34222, 34226, 34225, 34223, 34224, 34234, 34235, - 34232, 34233, 34216, 34214, 34215, 34238, 34239, 34236, 34237, 34231, - 34229, 34230, 34220, 34221, 34213, 34219, 34218, 34217, 34677, 34678, - 34673, 34676, 34675, 34674, 34684, 34685, 34682, 34683, 34688, 34689, - 34686, 34687, 34681, 34679, 34680, 34694, 34695, 34690, 34693, 34692, - 34691, 34424, 34425, 34418, 34423, 34421, 34422, 34419, 34420, 34428, - 34429, 34426, 34427, 34413, 34412, 34410, 34411, 34409, 34417, 34415, - 34416, 34414, 34822, 34823, 34817, 34821, 34820, 34818, 34819, 34826, - 34824, 34825, 34811, 34809, 34810, 34832, 34833, 34830, 34831, 34829, - 34827, 34828, 34815, 34816, 34808, 34814, 34813, 34812, 34362, 34363, - 34357, 34361, 34360, 34358, 34359, 34372, 34373, 34370, 34371, 34351, - 34349, 34350, 34369, 34367, 34368, 34366, 34364, 34365, 34355, 34356, - 34348, 34354, 34353, 34352, 34378, 34379, 34374, 34377, 34376, 34375, - 34577, 34578, 34571, 34576, 34574, 34575, 34572, 34573, 34581, 34582, - 34579, 34580, 34561, 34562, 34559, 34560, 34585, 34586, 34583, 34584, - 34570, 34568, 34569, 34566, 34567, 34558, 34565, 34564, 34563, 34591, - 34592, 34587, 34590, 34589, 34588, 34331, 34332, 34325, 34330, 34328, - 34329, 34326, 34327, 34335, 34336, 34333, 34334, 34318, 34319, 34316, - 34317, 34343, 34344, 34341, 34342, 34339, 34340, 34337, 34338, 34323, - 34324, 34315, 34322, 34321, 34320, 34544, 34545, 34539, 34543, 34542, - 34540, 34541, 34548, 34549, 34546, 34547, 34533, 34531, 34532, 34556, - 34557, 34554, 34555, 34552, 34553, 34550, 34551, 34537, 34538, 34530, - 34536, 34535, 34534, 34291, 34292, 34287, 34290, 34288, 34289, 34305, - 34306, 34303, 34304, 34296, 34297, 34294, 34295, 34313, 34314, 34311, - 34312, 34309, 34310, 34307, 34308, 34301, 34302, 34293, 34300, 34299, - 34298, 34614, 34613, 34607, 34608, 34605, 34606, 34596, 34594, 34595, - 34611, 34612, 34609, 34610, 34604, 34602, 34603, 34600, 34601, 34593, - 34599, 34598, 34597, 34443, 34444, 34437, 34442, 34440, 34441, 34438, - 34439, 34447, 34448, 34445, 34446, 34432, 34433, 34430, 34431, 34451, - 34452, 34449, 34450, 34436, 34434, 34435, 34704, 34702, 34703, 34707, - 34708, 34705, 34706, 34697, 34698, 34696, 34711, 34712, 34709, 34710, - 34701, 34699, 34700, 34347, 34346, 34345, 34462, 34463, 34460, 34461, - 34455, 34456, 34453, 34454, 34466, 34467, 34464, 34465, 34459, 34457, - 34458, 35128, 35129, 35126, 35127, 35119, 35117, 35118, 35125, 35123, - 35124, 35122, 35120, 35121, 35191, 35192, 35186, 35190, 35189, 35187, - 35188, 35227, 35228, 35225, 35226, 35180, 35178, 35179, 35231, 35232, - 35229, 35230, 35224, 35222, 35223, 35184, 35185, 35177, 35183, 35182, - 35181, 35237, 35238, 35233, 35236, 35235, 35234, 34197, 34198, 34191, - 34196, 34194, 34195, 34192, 34193, 34201, 34202, 34199, 34200, 34182, - 34180, 34181, 34205, 34206, 34203, 34204, 34190, 34188, 34189, 34186, - 34187, 34179, 34185, 34184, 34183, 34211, 34212, 34207, 34210, 34209, - 34208, 35205, 35206, 35199, 35204, 35202, 35203, 35200, 35201, 35209, - 35210, 35207, 35208, 35198, 35196, 35197, 35195, 35193, 35194, 35215, - 35211, 35214, 35213, 35212, 35220, 35221, 35216, 35219, 35218, 35217, - 34794, 34795, 34789, 34793, 34792, 34790, 34791, 34798, 34799, 34796, - 34797, 34782, 34781, 34788, 34787, 34807, 34806, 34786, 34780, 34785, - 34784, 34783, 34804, 34805, 34800, 34803, 34802, 34801, 35039, 35040, - 35034, 35038, 35037, 35035, 35036, 35046, 35047, 35044, 35045, 35028, - 35026, 35027, 35050, 35051, 35048, 35049, 35043, 35041, 35042, 35032, - 35033, 35025, 35031, 35030, 35029, 35056, 35057, 35052, 35055, 35054, - 35053, 34975, 34976, 34970, 34974, 34973, 34971, 34972, 34982, 34983, - 34980, 34981, 34986, 34987, 34984, 34985, 34979, 34977, 34978, 34990, - 34991, 34988, 34989, 34996, 34997, 34992, 34995, 34994, 34993, 35161, - 35162, 35159, 35160, 35153, 35151, 35152, 35169, 35170, 35167, 35168, - 35165, 35166, 35163, 35164, 35157, 35158, 35150, 35156, 35155, 35154, - 35175, 35176, 35171, 35174, 35173, 35172, 34163, 34164, 34161, 34162, - 34155, 34156, 34153, 34154, 34171, 34172, 34169, 34170, 34167, 34168, - 34165, 34166, 34160, 34152, 34159, 34158, 34157, 34177, 34178, 34173, - 34176, 34175, 34174, 34943, 34942, 34922, 34921, 34934, 34935, 34932, - 34933, 34930, 34931, 34928, 34929, 34926, 34927, 34920, 34925, 34924, - 34923, 34940, 34941, 34936, 34939, 34938, 34937, 34743, 34744, 34741, - 34742, 34740, 34738, 34739, 34747, 34748, 34745, 34746, 34753, 34754, - 34749, 34752, 34751, 34750, 34759, 34760, 34755, 34758, 34757, 34756, - 35009, 35010, 35007, 35008, 35001, 34999, 35000, 35017, 35018, 35015, - 35016, 35013, 35014, 35011, 35012, 35005, 35006, 34998, 35004, 35003, - 35002, 35023, 35024, 35019, 35022, 35021, 35020, 34958, 34959, 34956, - 34957, 34947, 34945, 34946, 34962, 34963, 34960, 34961, 34955, 34953, - 34954, 34951, 34952, 34944, 34950, 34949, 34948, 34968, 34969, 34964, - 34967, 34966, 34965, 34518, 34519, 34512, 34517, 34515, 34516, 34513, - 34514, 34505, 34506, 34503, 34504, 34522, 34523, 34520, 34521, 34510, - 34511, 34502, 34509, 34508, 34507, 34528, 34529, 34524, 34527, 34526, - 34525, 34880, 34881, 34874, 34879, 34877, 34878, 34875, 34876, 34867, - 34868, 34865, 34866, 34884, 34885, 34882, 34883, 34872, 34873, 34864, - 34871, 34870, 34869, 34890, 34891, 34886, 34889, 34888, 34887, 34492, - 34493, 34486, 34491, 34489, 34490, 34487, 34488, 34480, 34478, 34479, - 34496, 34497, 34494, 34495, 34484, 34485, 34477, 34483, 34482, 34481, - 34500, 34501, 34498, 34499, 34726, 34727, 34720, 34725, 34723, 34724, - 34721, 34722, 34715, 34714, 34730, 34731, 34728, 34729, 34719, 34713, - 34718, 34717, 34716, 34736, 34737, 34732, 34735, 34734, 34733, 34774, - 34775, 34768, 34773, 34771, 34772, 34769, 34770, 34764, 34762, 34763, - 34778, 34779, 34776, 34777, 34766, 34767, 34761, 34765, 35136, 35137, - 35130, 35135, 35133, 35134, 35131, 35132, 35149, 35148, 35140, 35141, - 35138, 35139, 35146, 35147, 35142, 35145, 35144, 35143, 34908, 34909, - 34902, 34907, 34905, 34906, 34903, 34904, 34895, 34896, 34893, 34894, - 34912, 34913, 34910, 34911, 34900, 34901, 34892, 34899, 34898, 34897, - 34918, 34919, 34914, 34917, 34916, 34915, 35536, 35536, 35536, 34083, - 34056, 34054, 34061, 34035, 34071, 34042, 34044, 34060, 34047, 34058, - 34031, 34059, 34077, 34065, 34046, 34072, 34045, 34078, 34036, 34039, - 34032, 34041, 34062, 34073, 34085, 34050, 34081, 34066, 34049, 34076, - 34074, 34070, 34075, 34082, 34053, 34063, 34052, 34043, 34051, 34084, - 34040, 34067, 34057, 34034, 34033, 34038, 34048, 34068, 34079, 34069, - 34037, 34080, 34064, 34055, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 19783, 19772, 19771, 19755, 19753, 19752, 19766, - 19770, 19769, 19785, 19764, 19763, 19754, 19751, 19750, 19787, 19760, - 19786, 19774, 19777, 19778, 19759, 19768, 19789, 19767, 19784, 19788, - 19773, 19776, 19765, 19779, 19780, 19761, 19762, 19790, 19781, 19756, - 19757, 19758, 19782, 19746, 19749, 19747, 19745, 19748, 19744, 19791, - 19792, 32803, 32804, 32640, 32789, 32790, 32763, 32566, 32573, 32676, - 32649, 32683, 32623, 32749, 32777, 32601, 32594, 32552, 32545, 32667, - 32770, 32559, 32702, 32587, 32580, 32615, 32608, 32742, 32756, 32721, - 32784, 32662, 32708, 32629, 32690, 32735, 32728, 32812, 32813, 32644, - 32645, 32798, 32799, 32765, 32568, 32575, 32678, 32655, 32685, 32626, - 32751, 32779, 32603, 32596, 32554, 32547, 32671, 32772, 32561, 32704, - 32589, 32582, 32617, 32610, 32744, 32758, 32723, 32786, 32663, 32713, - 32634, 32692, 32737, 32730, 32810, 32811, 32715, 32642, 32643, 32796, - 32797, 32764, 32567, 32574, 32677, 32653, 32654, 32684, 32625, 32750, - 32778, 32602, 32595, 32553, 32546, 32670, 32771, 32560, 32703, 32588, - 32581, 32616, 32609, 32743, 32757, 32722, 32785, 32659, 32660, 32712, - 32633, 32691, 32736, 32729, 32807, 32808, 32638, 32793, 32794, 32761, - 32564, 32571, 32674, 32652, 32681, 32621, 32747, 32775, 32599, 32592, - 32550, 32543, 32669, 32768, 32557, 32700, 32585, 32578, 32613, 32606, - 32740, 32754, 32719, 32782, 32658, 32711, 32632, 32688, 32733, 32726, - 32814, 32815, 32646, 32647, 32800, 32801, 32766, 32569, 32576, 32679, - 32656, 32686, 32627, 32752, 32780, 32604, 32597, 32555, 32548, 32672, - 32773, 32562, 32705, 32590, 32583, 32618, 32611, 32745, 32759, 32724, - 32787, 32664, 32714, 32635, 32693, 32738, 32731, 32806, 32809, 32717, - 32636, 32637, 32792, 32795, 32760, 32563, 32570, 32673, 32651, 32680, - 32619, 32620, 32746, 32774, 32598, 32591, 32549, 32542, 32668, 32767, - 32556, 32694, 32584, 32577, 32612, 32605, 32739, 32753, 32718, 32781, - 32657, 32710, 32631, 32687, 32732, 32725, 32802, 32805, 32716, 32639, - 32641, 32788, 32791, 32762, 32565, 32572, 32675, 32648, 32650, 32682, - 32622, 32624, 32748, 32776, 32600, 32593, 32551, 32544, 32665, 32769, - 32558, 32701, 32586, 32579, 32614, 32607, 32741, 32755, 32720, 32783, - 32661, 32707, 32709, 32628, 32630, 32689, 32734, 32727, 32706, 32666, - 32539, 32540, 32541, 32697, 32698, 32695, 32819, 32822, 32825, 32824, - 32828, 32820, 32827, 32818, 32816, 32823, 32826, 32817, 32821, 32835, - 32837, 32834, 32833, 32830, 32829, 32832, 32831, 32838, 32836, 32699, - 32696, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 9401, 9602, 9290, 9449, 9240, 9543, 9345, 9504, 9286, 9445, 9366, - 9529, 9274, 9433, 9233, 9530, 9394, 9595, 9342, 9501, 9242, 9545, 9343, - 9502, 9282, 9441, 9275, 9434, 9339, 9498, 9396, 9597, 9241, 9544, 9385, - 9563, 9382, 9560, 9383, 9561, 9365, 9528, 9272, 9431, 9287, 9446, 9416, - 7237, 7229, 7180, 7230, 28123, 7204, 7193, 7207, 7203, 7212, 7205, 7202, - 7199, 7235, 7224, 9415, 9419, 9296, 9455, 9294, 9453, 9406, 9607, 9284, - 9443, 9292, 9451, 9246, 9571, 9254, 9580, 9250, 9575, 9249, 9574, 9252, - 9578, 9330, 9489, 9380, 9558, 9288, 9447, 9283, 9442, 22430, 22467, 7188, - 7196, 3462, 2824, 3465, 2826, 3461, 3437, 3454, 3464, 2853, 3463, 2829, - 3434, 3440, 3439, 2827, 2833, 3453, 2852, 2846, 2832, 3449, 2840, 3444, - 3450, 3443, 3447, 2822, 2818, 2850, 2849, 2844, 3456, 3446, 3457, 3458, - 2851, 2816, 3430, 2845, 2848, 3433, 3459, 3431, 2813, 3442, 2831, 2838, - 2855, 3436, 3441, 2817, 2841, 2842, 2843, 3445, 3432, 2815, 2814, 3460, - 2854, 2830, 3435, 2828, 2819, 2835, 3438, 2834, 2837, 3455, 2825, 2839, - 2836, 3452, 2823, 3451, 2847, 3448, 2812, 2820, 2821, 2809, 2808, 3466, - 3468, 2811, 2810, 3467, 3469, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 22427, 22423, 22426, 22422, 22428, 22424, 22429, 22425, - 22482, 22497, 22525, 22504, 22487, 22481, 22496, 22524, 22503, 22486, - 22483, 22498, 22526, 22508, 22488, 22474, 22473, 22475, 22519, 22538, - 22535, 22537, 22536, 22516, 22686, 22687, 17554, 18158, 17555, 18159, - 17594, 18220, 17821, 18583, 17820, 18540, 17494, 18080, 17495, 18081, - 17963, 17971, 17468, 18036, 17469, 18037, 17470, 18038, 17466, 18034, - 17467, 18035, 17471, 18039, 17765, 18464, 17635, 18272, 17632, 18269, - 17636, 18273, 17480, 18057, 17654, 18296, 17687, 18371, 17688, 18373, - 17734, 18411, 17739, 18416, 17737, 18414, 17740, 18417, 17747, 18429, - 17746, 18426, 17762, 18454, 17767, 18467, 17862, 18633, 17871, 18645, - 17866, 18640, 17815, 18534, 17816, 18535, 17870, 18644, 17556, 18176, - 17623, 18259, 17496, 18082, 22695, 18118, 18317, 18331, 18354, 18466, - 17948, 18578, 18630, 17616, 18248, 17617, 18249, 17618, 17805, 18546, - 17810, 18576, 17619, 18251, 17620, 18252, 17621, 18253, 22502, 22471, - 22548, 17788, 18490, 17808, 18301, 17979, 17680, 18345, 17490, 18070, - 18067, 18214, 17474, 18042, 17563, 18183, 17867, 18641, 17868, 18642, - 17869, 18643, 17571, 18194, 17639, 18277, 17683, 18350, 17760, 18451, - 17784, 18488, 17590, 17764, 17791, 17642, 17787, 17970, 17809, 17812, - 17626, 17497, 17481, 18059, 17732, 18409, 17858, 18621, 17576, 18199, - 17577, 18200, 17578, 18201, 17729, 18400, 17463, 18031, 17488, 17785, - 17908, 17501, 18084, 17781, 18482, 17768, 17780, 18481, 17744, 18423, - 17493, 18076, 17514, 18111, 17513, 18108, 17669, 18330, 17790, 18508, - 17658, 18306, 17659, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 22415, 22402, 22405, 22414, 17763, 18455, 17918, - 22397, 22627, 17953, 17916, 17917, 17914, 17915, 17913, 29119, 29121, - 29131, 29123, 29120, 29122, 29130, 29111, 29110, 29107, 29106, 29129, - 29105, 29104, 29109, 29108, 29099, 29098, 29093, 29092, 29101, 29100, - 29095, 29094, 29117, 29113, 29112, 29103, 29102, 29116, 29097, 29115, - 29096, 29118, 29114, 29133, 29135, 29136, 29134, 29132, 29124, 29125, - 29126, 29127, 29128, 35536, 35536, 35536, 24088, 24087, 24090, 24085, - 24086, 24089, 24082, 24081, 24084, 24083, 35536, 35536, 35536, 35536, - 35536, 35536, 25661, 25660, 25649, 25650, 25637, 25639, 25671, 25652, - 25659, 25658, 25642, 25653, 25663, 25662, 25668, 25673, 25655, 25654, - 25641, 25676, 25664, 25665, 25643, 25678, 25675, 25672, 25644, 25645, - 25670, 25634, 25679, 25681, 25666, 25680, 25674, 25677, 25669, 25648, - 25667, 25686, 25687, 25657, 25656, 25640, 25651, 25635, 25647, 25646, - 25636, 25685, 25688, 25638, 25684, 25689, 25683, 25682, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 26806, 26808, 26755, 26756, - 26776, 26777, 26772, 26773, 26767, 26768, 26769, 26770, 26799, 26800, - 26757, 26774, 26775, 26758, 26796, 26795, 26792, 26791, 26780, 26790, - 26789, 26794, 26793, 26782, 26764, 26763, 26760, 26759, 26781, 26766, - 26765, 26762, 26761, 26783, 26798, 26797, 26788, 26787, 26802, 26804, - 26803, 26779, 26771, 26784, 26785, 26786, 26801, 26778, 26821, 26822, - 26833, 26834, 26825, 26826, 26827, 26828, 26829, 26830, 26835, 26836, - 26823, 26831, 26832, 26824, 26807, 26805, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 26810, 26809, 26817, 26819, 26816, 26815, - 26812, 26811, 26814, 26813, 26820, 26818, 35536, 35536, 35536, 35536, - 35536, 35536, 7255, 7257, 7254, 7253, 7250, 7249, 7252, 7251, 7258, 7256, - 7246, 7247, 7242, 7243, 7244, 7245, 7241, 7248, 9889, 9883, 9896, 9885, - 9884, 9882, 9897, 9786, 9784, 9789, 9890, 9940, 9795, 9907, 16739, 16741, - 16738, 16737, 16734, 16733, 16736, 16735, 16742, 16740, 16703, 16702, - 16713, 16699, 16707, 16706, 16720, 16700, 16709, 16697, 16701, 16705, - 16704, 16715, 16712, 16710, 16716, 16719, 16714, 16718, 16708, 16698, - 16717, 16711, 16721, 16695, 16722, 16696, 16731, 16728, 16730, 16729, - 16732, 16727, 16725, 16726, 16723, 16724, 26148, 26145, 26137, 26153, - 26144, 26139, 26150, 26142, 26141, 26143, 26147, 26135, 26152, 26151, - 26149, 26155, 26154, 26146, 26140, 26136, 26138, 26134, 26156, 26163, - 26165, 26158, 26161, 26164, 26162, 26160, 26159, 26131, 26130, 26133, - 26132, 26166, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 26157, 14377, 14380, 14381, 14378, 14335, 14336, - 14344, 14338, 14340, 14343, 14337, 14333, 14339, 14341, 14334, 14300, - 14302, 14303, 14316, 14323, 14330, 14365, 14282, 14289, 14363, 14367, - 14313, 14386, 14369, 35536, 35536, 35536, 16058, 16054, 16057, 16056, - 16028, 15996, 15995, 15997, 16037, 16016, 16002, 16003, 16035, 16029, - 16036, 15998, 15999, 16000, 16012, 16013, 16001, 16010, 16011, 16026, - 16005, 16027, 16004, 16024, 16025, 15991, 15992, 16007, 16022, 16023, - 15993, 15994, 16006, 16014, 16015, 16008, 16009, 16032, 16034, 16017, - 16018, 16031, 16033, 16020, 16021, 16019, 16030, 16055, 16061, 16063, - 16064, 16065, 16059, 16060, 16062, 16067, 16066, 15987, 15988, 15989, - 16052, 15990, 16038, 16041, 16050, 16043, 16048, 16046, 16044, 16042, - 16039, 16040, 16045, 16053, 35536, 16051, 16074, 16076, 16073, 16072, - 16069, 16068, 16071, 16070, 16077, 16075, 35536, 35536, 35536, 35536, - 16047, 16049, 23307, 23305, 23300, 23297, 23303, 23393, 23371, 23323, - 23335, 23331, 23330, 23333, 23332, 23325, 23324, 23322, 23435, 23437, - 23434, 23433, 23430, 23429, 23432, 23431, 23438, 23436, 23334, 23327, - 23326, 23329, 23328, 35536, 6347, 6365, 6367, 6364, 6348, 6366, 6356, - 6355, 6352, 6351, 6327, 6328, 6350, 6349, 6354, 6353, 6329, 6331, 6330, - 6358, 6357, 6344, 6343, 6332, 6333, 6342, 6338, 6337, 6336, 6341, 6340, - 6334, 6335, 6339, 6363, 6361, 6360, 6362, 6345, 6346, 6359, 6372, 6375, - 6376, 6381, 6379, 6378, 6377, 6373, 6374, 6380, 6315, 6313, 6312, 6314, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 6321, - 6320, 6317, 6309, 6319, 6325, 6316, 6323, 6326, 6324, 6322, 6318, 6311, - 6310, 35536, 35536, 6388, 6390, 6387, 6386, 6383, 6382, 6385, 6384, 6391, - 6389, 35536, 35536, 6368, 6370, 6369, 6371, 23277, 23270, 23269, 23274, - 23273, 23267, 23266, 23265, 23263, 23262, 23264, 23268, 23279, 23272, - 23271, 23276, 23370, 23280, 23281, 23278, 23367, 23368, 23369, 23408, - 23410, 23409, 23252, 23404, 23395, 23396, 23316, 23317, 29603, 29579, - 29602, 29578, 29601, 29577, 29616, 29592, 29610, 29586, 29605, 29581, - 29604, 29580, 29621, 29597, 29611, 29587, 29614, 29590, 29609, 29585, - 29608, 29584, 29612, 29588, 29613, 29589, 29607, 29583, 29606, 29582, - 29615, 29591, 29619, 29595, 29623, 29599, 29620, 29596, 29618, 29594, - 29622, 29598, 29617, 29593, 29624, 29600, 29625, 29637, 29645, 29642, - 29641, 29647, 29648, 29626, 29646, 29643, 29644, 29636, 29640, 29639, - 29638, 29635, 29632, 29633, 29634, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 29628, - 29629, 29631, 29630, 29627, 21734, 21735, 21693, 21710, 21721, 21720, - 21697, 21696, 21709, 21715, 21716, 21748, 21750, 21740, 21742, 21741, - 21688, 21685, 21687, 21737, 21738, 21752, 21753, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 12338, 12336, 12335, - 12334, 12333, 12337, 35536, 35536, 12032, 12030, 12029, 12028, 12027, - 12031, 35536, 35536, 12047, 12045, 12044, 12043, 12042, 12046, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 11988, 11994, - 11992, 11989, 11991, 11990, 11993, 35536, 11973, 11979, 11977, 11974, - 11976, 11975, 11978, 35536, 18050, 18026, 18056, 18051, 18147, 18310, - 18500, 18299, 18290, 18293, 18321, 18335, 18161, 18054, 18055, 18405, - 18255, 18549, 18548, 18550, 18551, 18510, 17947, 18453, 18109, 18433, - 18110, 18497, 18498, 18053, 18620, 18586, 18629, 18572, 18625, 18073, - 18074, 18075, 18661, 18658, 18659, 18660, 18672, 22384, 22608, 22617, - 22618, 22675, 18491, 18258, 18406, 18631, 18254, 13549, 18116, 18581, - 18554, 22672, 22521, 22545, 35536, 35536, 35536, 35536, 6570, 6571, 6572, - 6573, 6574, 6575, 6533, 6569, 6534, 6535, 6536, 6537, 6538, 6498, 6499, - 6500, 6501, 6502, 6503, 6539, 6540, 6541, 6542, 6543, 6544, 6545, 6546, - 6547, 6548, 6549, 6504, 6497, 6505, 6506, 6507, 6508, 6509, 6510, 6551, - 6552, 6553, 6554, 6555, 6556, 6512, 6511, 6513, 6514, 6515, 6516, 6517, - 6491, 6530, 6492, 6531, 6493, 6532, 6494, 6495, 6496, 6490, 6518, 6519, - 6520, 6521, 6522, 6523, 6524, 6525, 6526, 6527, 6528, 6529, 6557, 6558, - 6559, 6560, 6561, 6562, 6563, 21702, 21714, 21724, 21726, 21711, 21705, - 21692, 21717, 21704, 21707, 21719, 21730, 21732, 21728, 21733, 21722, - 21713, 21731, 21699, 21700, 21729, 21691, 21701, 21695, 21698, 21694, - 21690, 21703, 21725, 21727, 21712, 21706, 21718, 21708, 21723, 21744, - 21747, 21739, 21746, 21745, 21749, 21743, 21751, 21689, 21736, 21686, - 35536, 35536, 21760, 21762, 21759, 21758, 21755, 21754, 21757, 21756, - 21763, 21761, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 14574, 14572, 14605, 14606, 14607, 14583, - 14584, 14616, 14618, 14551, 14549, 14548, 14552, 14558, 14559, 14561, - 14560, 14565, 14562, 14563, 14567, 14535, 14533, 35536, 35536, 35536, - 35536, 14431, 14432, 14500, 14501, 14520, 14514, 14515, 14518, 14517, - 14516, 14475, 14460, 14499, 14466, 14470, 14469, 14483, 14482, 14403, - 14428, 14421, 14506, 14419, 14426, 14456, 14449, 14455, 14510, 14451, - 14454, 14453, 14494, 14487, 14504, 14505, 14493, 14491, 14490, 14495, - 14497, 14442, 14441, 14527, 14528, 14392, 14391, 14507, 14446, 14444, - 35536, 35536, 35536, 35536, 18694, 18697, 18698, 18695, 18696, 18700, - 18701, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 2549, 2550, 2548, 2551, 2547, 35536, 35536, 35536, - 35536, 35536, 15040, 15067, 15045, 14976, 15032, 15035, 15037, 15036, - 15031, 15038, 15034, 15033, 14977, 15010, 15011, 15008, 15009, 14974, - 14975, 14973, 14981, 15023, 15021, 14998, 15030, 15003, 35536, 15015, - 15041, 14989, 14984, 15025, 35536, 15027, 35536, 15001, 15005, 35536, - 14991, 14987, 35536, 15019, 14996, 15013, 15007, 15017, 15029, 14980, - 14983, 14986, 15042, 1164, 1163, 1194, 1192, 1193, 1195, 1424, 1422, - 1423, 1425, 1189, 1187, 1188, 1190, 1555, 1553, 1554, 1556, 1534, 1532, - 1533, 1535, 1550, 1548, 1549, 1551, 1568, 1566, 1567, 1569, 1429, 1427, - 1428, 1430, 1230, 1228, 1229, 1231, 1401, 1399, 1400, 1402, 1511, 1509, - 1510, 1512, 1516, 1514, 1515, 1517, 1220, 1219, 1211, 1210, 1234, 1233, - 1223, 1222, 1330, 1329, 1459, 1458, 1353, 1351, 1352, 1354, 1264, 1262, - 1263, 1265, 1276, 1274, 1275, 1277, 1392, 1390, 1391, 1393, 1406, 1405, - 1463, 1461, 1462, 1464, 1306, 1305, 1301, 1299, 1300, 1302, 1310, 1308, - 1309, 1311, 1592, 1591, 1590, 1589, 2411, 2410, 2419, 2418, 2415, 2414, - 2413, 2412, 2423, 2422, 2409, 2417, 2416, 2425, 2421, 2420, 2424, 1756, - 1704, 1933, 1930, 1931, 1926, 1927, 1928, 1920, 1733, 1734, 1731, 1732, - 1956, 1645, 1649, 1396, 1394, 1395, 1397, 1561, 1560, 1614, 1613, 1611, - 1610, 1559, 1571, 1570, 1357, 1356, 1360, 1359, 1627, 1625, 1626, 1628, - 1562, 1563, 2100, 2099, 2102, 2101, 2121, 2120, 2129, 2128, 2119, 2118, - 2125, 2124, 2105, 2103, 2104, 2154, 2152, 2153, 1244, 1242, 1243, 1245, - 2111, 2109, 2115, 2098, 2123, 1675, 1666, 1671, 1678, 1673, 1684, 2063, - 2051, 2058, 2071, 2074, 2079, 2081, 2086, 2083, 2092, 1760, 1766, 1743, - 1738, 1799, 1795, 1801, 1970, 1963, 1975, 1983, 1940, 1944, 1697, 1689, - 1693, 1699, 2044, 2039, 2156, 1640, 1636, 1728, 1724, 1712, 1717, 1708, - 1715, 1710, 1719, 1905, 1901, 1903, 1907, 1774, 1776, 1784, 1782, 1779, - 1790, 1772, 1793, 1827, 1819, 1831, 1837, 1811, 1840, 1858, 1847, 1852, - 1862, 1841, 1863, 1879, 1869, 1891, 1884, 1887, 1894, 1753, 1749, 1750, - 1751, 2139, 2132, 2141, 2147, 2096, 2151, 2080, 1935, 1658, 1991, 1994, - 1998, 1992, 1995, 1997, 2127, 2126, 2113, 2117, 2097, 2122, 1682, 1681, - 1676, 1680, 1672, 1683, 2077, 2076, 2069, 2075, 2073, 2078, 2090, 2089, - 2084, 2088, 2082, 2091, 1709, 1718, 1902, 1906, 1773, 1777, 1788, 1771, - 1792, 1835, 1810, 1839, 1842, 1860, 1892, 1889, 1882, 1888, 1886, 1893, - 1657, 2149, 2136, 2145, 2135, 2095, 2150, 2110, 2108, 2112, 2114, 2106, - 1674, 1665, 1670, 1677, 1667, 2062, 2050, 2057, 2070, 2052, 2085, 1759, - 1765, 1742, 1737, 1798, 1800, 1969, 1962, 1974, 1982, 1939, 1947, 1943, - 1696, 1688, 1692, 1698, 2043, 2155, 1639, 1635, 1727, 1723, 1711, 1716, - 1707, 1714, 1904, 1900, 1775, 1783, 1781, 1778, 1789, 1826, 1818, 1830, - 1836, 1820, 1857, 1846, 1851, 1861, 1878, 1868, 1890, 1883, 1870, 1752, - 1748, 1754, 2138, 2131, 2140, 2146, 2133, 2116, 2107, 1679, 1668, 2072, - 2053, 2087, 2093, 1984, 1966, 2021, 2001, 1780, 1791, 1838, 1885, 1871, - 2148, 2134, 1999, 1993, 1996, 2042, 2046, 1642, 1644, 1726, 1730, 1986, - 1990, 2023, 2031, 1740, 1745, 1768, 1770, 1797, 1803, 1946, 1951, 1695, - 1703, 2012, 2007, 2026, 2020, 2029, 1988, 1949, 1701, 2041, 2045, 1641, - 1643, 1725, 1729, 1985, 1989, 2022, 2030, 1739, 1744, 1767, 1769, 1796, - 1802, 1945, 1950, 1694, 1702, 2010, 2005, 2024, 2018, 2028, 1987, 1948, - 1700, 2011, 2006, 2025, 2019, 1965, 2000, 2038, 1971, 1964, 1976, 2013, - 2008, 2027, 2040, 2157, 1659, 1660, 24956, 24957, 1923, 1914, 1918, 1915, - 1916, 1917, 1957, 1648, 1653, 1651, 1647, 1912, 1959, 1655, 2033, 1925, - 2060, 2049, 2048, 2047, 2055, 2065, 2067, 2066, 1762, 1761, 1736, 1735, - 1961, 1968, 1967, 1978, 1977, 1979, 1981, 1980, 1937, 1936, 1942, 2003, - 2002, 2009, 2015, 2014, 2017, 2016, 1686, 1691, 1690, 2035, 2034, 2036, - 2037, 1638, 1633, 1632, 1631, 1720, 1722, 1721, 1706, 1705, 1898, 1896, - 1816, 1817, 1814, 1821, 1822, 1829, 1828, 1833, 1832, 1843, 1844, 1845, - 1855, 1853, 1848, 1849, 1929, 1932, 1854, 1746, 1747, 1866, 1865, 1876, - 1875, 1874, 1881, 1880, 2143, 2142, 1669, 2061, 2059, 2056, 2054, 2068, - 2064, 1764, 1757, 1763, 1972, 1938, 2004, 1687, 1825, 1834, 2130, 2137, - 2144, 1859, 1899, 1867, 1897, 1815, 1634, 1787, 1872, 1850, 1823, 1786, - 1824, 1873, 1758, 1741, 1856, 1713, 1664, 1785, 1637, 1941, 1973, 1877, - 1924, 1919, 1922, 1921, 1958, 1646, 1794, 1953, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 1954, - 1908, 1661, 1662, 1864, 1952, 1934, 1656, 2094, 1955, 1960, 1755, 26477, - 1685, 2032, 1663, 32839, 32950, 33018, 33029, 33040, 33051, 33062, 33073, - 33084, 32840, 32851, 32862, 32873, 32884, 32895, 32906, 25931, 25936, - 25937, 25930, 25961, 25932, 25963, 25939, 25953, 25935, 35536, 35536, - 35536, 35536, 35536, 35536, 7465, 7467, 7292, 7293, 7476, 7478, 7178, - 7466, 7468, 7541, 7542, 7477, 7479, 7179, 7232, 7233, 25962, 25933, - 25934, 25948, 25960, 25945, 25957, 25943, 25955, 25947, 25959, 25940, - 25949, 25941, 25950, 25944, 25956, 25942, 25954, 25938, 25951, 26972, - 33845, 25946, 25958, 9659, 6231, 33721, 10375, 9658, 6230, 33719, 28147, - 28156, 28191, 35536, 28181, 28148, 28192, 28154, 28155, 28158, 28162, - 28157, 28161, 28159, 28163, 28190, 28138, 28140, 28189, 28187, 28160, - 28186, 28153, 35536, 28180, 28149, 28188, 28146, 35536, 35536, 35536, - 35536, 1098, 2430, 1079, 2432, 1110, 35536, 1095, 1096, 1075, 1076, 1107, - 1108, 2335, 2336, 2405, 2406, 1295, 1159, 1158, 1149, 1148, 1579, 1578, - 1152, 1151, 1596, 1594, 1595, 1597, 1169, 1168, 1184, 1182, 1183, 1185, - 1521, 1520, 1530, 1528, 1529, 1523, 1544, 1542, 1543, 1545, 1326, 1324, - 1325, 1327, 1292, 1290, 1291, 1293, 1364, 1362, 1363, 1365, 1208, 1207, - 1538, 1537, 1456, 1455, 1622, 1621, 1485, 1483, 1484, 1486, 1491, 1489, - 1490, 1492, 1472, 1470, 1471, 1473, 1216, 1214, 1215, 1217, 1504, 1502, - 1503, 1505, 1618, 1616, 1617, 1619, 1127, 1125, 1126, 1128, 1271, 1269, - 1270, 1272, 1255, 1253, 1254, 1256, 1438, 1436, 1437, 1439, 1340, 1338, - 1339, 1341, 1376, 1374, 1375, 1377, 1385, 1383, 1384, 1386, 1417, 1415, - 1416, 1418, 1314, 1312, 1313, 1315, 1583, 1582, 1167, 1166, 1607, 1605, - 1606, 1608, 1809, 1808, 1805, 1804, 1807, 1806, 1813, 1812, 35536, 35536, - 35340, 35536, 12757, 12761, 12729, 12745, 12731, 12743, 12742, 12672, - 12735, 12744, 12732, 12667, 12760, 12765, 12739, 12752, 12754, 12751, - 12750, 12747, 12746, 12749, 12748, 12755, 12753, 12668, 12738, 12674, - 12756, 12759, 12762, 12666, 12675, 12676, 12677, 12678, 12679, 12680, - 12681, 12682, 12683, 12684, 12685, 12686, 12687, 12688, 12689, 12690, - 12691, 12692, 12693, 12694, 12695, 12696, 12697, 12698, 12699, 12700, - 12673, 12737, 12736, 12665, 12727, 12758, 12701, 12702, 12703, 12704, - 12705, 12706, 12707, 12708, 12709, 12710, 12711, 12712, 12713, 12714, - 12715, 12716, 12717, 12718, 12719, 12720, 12721, 12722, 12723, 12724, - 12725, 12726, 12671, 12767, 12734, 12764, 12670, 12733, 14247, 14240, - 14242, 14246, 14238, 14230, 14185, 14187, 14189, 14186, 14188, 14181, - 14183, 14182, 14184, 14239, 14231, 14233, 14235, 14232, 14234, 14206, - 14208, 14210, 14207, 14209, 14190, 14192, 14194, 14191, 14193, 14221, - 14223, 14225, 14222, 14224, 14196, 14198, 14200, 14197, 14199, 14201, - 14203, 14205, 14202, 14204, 14211, 14213, 14215, 14212, 14214, 14226, - 14228, 14227, 14216, 14218, 14220, 14217, 14219, 14229, 14195, 14237, - 14236, 14180, 14130, 14147, 14131, 14132, 14133, 14134, 14168, 14149, - 14138, 14143, 14142, 14141, 14145, 14139, 14140, 14144, 14166, 14136, - 14148, 14137, 14151, 14150, 14165, 14160, 14146, 14159, 14129, 14167, - 14135, 14174, 35536, 35536, 35536, 14175, 14176, 14154, 14155, 14162, - 14161, 35536, 35536, 14153, 14152, 14177, 14171, 14172, 14178, 35536, - 35536, 14157, 14179, 14170, 14169, 14173, 14158, 35536, 35536, 14163, - 14156, 14164, 35536, 35536, 35536, 12669, 12730, 12728, 12741, 12766, - 12740, 12763, 35536, 14244, 14241, 14245, 14243, 14250, 14248, 14249, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 15939, 15941, 15940, 24238, 26169, 35536, 35536, 19657, 19683, 19676, - 19709, 19667, 19658, 19687, 19653, 19665, 19695, 19698, 19692, 35536, - 19681, 19708, 19712, 19691, 19706, 19713, 19720, 19723, 19668, 19719, - 19666, 19669, 19652, 19675, 19678, 19701, 19702, 19660, 19717, 19682, - 19663, 19699, 19661, 19718, 19677, 19685, 35536, 19710, 19674, 19694, - 19659, 19670, 19684, 19655, 19689, 19664, 19696, 19697, 19654, 19680, - 19656, 19707, 19700, 19714, 19688, 19690, 35536, 19662, 19716, 35536, - 19673, 19672, 19686, 19722, 19715, 19725, 19693, 19671, 19703, 19711, - 19679, 19704, 19705, 19721, 19724, 35536, 35536, 19735, 19736, 19738, - 19737, 19726, 19727, 19734, 19728, 19729, 19739, 19730, 19731, 19732, - 19733, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 19541, 19540, 19542, 19529, 19530, - 19531, 19532, 19533, 19534, 19535, 19537, 19536, 19539, 19538, 19547, - 19544, 19545, 19543, 19546, 19646, 19647, 19549, 19548, 19550, 19649, - 19648, 19552, 19553, 19554, 19551, 19555, 19558, 19557, 19559, 19560, - 19561, 19650, 19562, 19563, 19556, 19566, 19567, 19565, 19564, 19568, - 19569, 19570, 19571, 19572, 19573, 19576, 19577, 19578, 19575, 19579, - 19574, 19580, 19581, 19582, 19583, 19584, 19585, 19586, 19587, 19588, - 19589, 19591, 19590, 19592, 19593, 19595, 19596, 19597, 19594, 19598, - 19599, 19600, 19601, 19603, 19602, 19604, 19605, 19651, 19606, 19607, - 19609, 19610, 19611, 19608, 19612, 19613, 19614, 19615, 19616, 19644, - 19624, 19625, 19626, 19627, 19628, 19629, 19630, 19631, 19632, 19633, - 19634, 19635, 19636, 19637, 19638, 19639, 19640, 19641, 19642, 19643, - 19617, 19618, 19619, 19620, 19621, 19622, 19623, 19645, 35536, 35536, - 35536, 35536, 35536, 112, 113, 159, 35536, 35536, 35536, 35536, 156, 151, - 146, 126, 121, 139, 134, 114, 129, 154, 149, 144, 124, 119, 140, 135, - 115, 130, 157, 152, 147, 127, 122, 142, 137, 117, 132, 158, 153, 148, - 128, 123, 143, 138, 118, 133, 155, 150, 145, 125, 120, 141, 136, 116, - 131, 35536, 35536, 35536, 111, 107, 109, 110, 108, 103, 104, 105, 106, - 13314, 13311, 13315, 13301, 13296, 13302, 13305, 13297, 13307, 13316, - 13299, 13309, 13303, 13312, 13306, 13308, 13318, 13300, 13310, 13304, - 13313, 13317, 13298, 13319, 13331, 13340, 13330, 13326, 13339, 13321, - 13327, 13343, 13347, 13348, 13329, 13332, 13338, 13337, 13345, 13346, - 13328, 13335, 13341, 13336, 13325, 13344, 13333, 13320, 13322, 13342, - 13334, 13323, 13324, 13566, 13567, 13765, 13761, 13802, 13767, 13497, - 13571, 13764, 13760, 13503, 13502, 13563, 13545, 13561, 13570, 13565, - 13351, 13350, 13804, 13763, 13805, 13568, 13759, 13541, 24060, 35536, - 26521, 26524, 26519, 26522, 26493, 26523, 26491, 26494, 26520, 26492, - 26525, 26490, 2569, 35536, 35536, 35536, 13758, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 25714, 25715, 25726, 25695, 25698, 25729, - 25707, 25706, 25727, 25734, 25693, 25720, 25699, 25712, 25713, 25722, - 25711, 25692, 25696, 25703, 25701, 25723, 25700, 25691, 25721, 25708, - 25709, 25694, 25697, 25719, 25733, 25704, 25728, 25690, 25716, 25735, - 25717, 25718, 25710, 25732, 25731, 25705, 25724, 25725, 25730, 25702, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 19979, 19981, 19977, 19978, 19986, 19985, 19988, 19996, 19998, 19975, - 19989, 19972, 19992, 19990, 19970, 19983, 19971, 19984, 19995, 19991, - 19973, 19993, 19994, 19974, 19976, 19980, 19982, 19987, 19997, 35536, - 35536, 35536, 6141, 6152, 6143, 6114, 6137, 6153, 6115, 6142, 6159, 6157, - 6117, 6158, 6144, 6132, 6127, 6128, 6126, 6112, 6135, 6125, 6160, 6122, - 6134, 6151, 6131, 6155, 6145, 6140, 6149, 6150, 6123, 6136, 6147, 6148, - 6129, 6130, 6124, 6156, 6113, 6133, 6138, 6154, 6118, 6119, 6120, 6121, - 6116, 6146, 6139, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 7689, 7687, 7685, 7684, - 7681, 7680, 7683, 7682, 7688, 7686, 7679, 7678, 7676, 7667, 7665, 7674, - 7672, 7663, 7669, 7670, 7677, 7675, 7666, 7664, 7673, 7671, 7662, 7668, - 35536, 35536, 35536, 35536, 24519, 24513, 24499, 24514, 24486, 24516, - 24518, 24515, 24510, 24506, 24498, 24494, 24495, 24496, 24488, 24520, - 24509, 24502, 24500, 24490, 24487, 24511, 24504, 24492, 24508, 24497, - 24493, 24491, 24512, 24507, 24505, 24489, 24524, 24522, 24523, 24521, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 24517, - 24503, 24501, 13161, 13177, 13185, 13179, 13160, 13170, 13164, 13163, - 13172, 13181, 13186, 13182, 13180, 13168, 13184, 13175, 13169, 13167, - 13171, 13183, 13173, 13174, 13176, 13165, 13162, 13178, 13166, 35536, - 35536, 35536, 35536, 35536, 24591, 24590, 24587, 24560, 24561, 24583, - 24558, 24584, 24559, 24563, 24592, 24585, 24566, 24567, 24574, 24568, - 24586, 24571, 24573, 24594, 24557, 24570, 24569, 24581, 24578, 24588, - 24589, 24562, 24593, 24572, 24575, 24576, 24577, 24580, 24565, 24582, - 24579, 24564, 7494, 7492, 7490, 7491, 7493, 35536, 35536, 35536, 35536, - 35536, 32287, 32290, 32294, 32298, 32291, 32295, 32313, 32309, 32296, - 32306, 32308, 32297, 32303, 32299, 32314, 32292, 32311, 32310, 32302, - 32288, 32312, 32301, 32289, 32300, 32305, 32293, 32307, 32315, 32316, - 32304, 35536, 32317, 24600, 24642, 24643, 24623, 24624, 24621, 24622, - 24620, 24635, 24612, 24613, 24617, 24618, 24607, 24610, 24611, 24616, - 24639, 24604, 24636, 24625, 24626, 24629, 24630, 24631, 24640, 24614, - 24615, 24627, 24628, 24638, 24634, 24641, 24632, 24633, 24637, 35536, - 35536, 35536, 35536, 24601, 24602, 24603, 24619, 24608, 24609, 24605, - 24606, 24644, 24599, 24596, 24597, 24595, 24598, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 9713, - 9712, 9708, 9709, 9710, 9711, 9719, 9718, 9714, 9715, 9716, 9717, 9736, - 9721, 9735, 9732, 9737, 9730, 9727, 9723, 9728, 9726, 9729, 9734, 9733, - 9703, 9731, 9702, 9722, 9698, 9725, 9699, 9724, 9706, 9704, 9705, 9700, - 9701, 9720, 9707, 9753, 9752, 9748, 9749, 9750, 9751, 9759, 9758, 9754, - 9755, 9756, 9757, 9776, 9761, 9775, 9772, 9777, 9770, 9767, 9763, 9768, - 9766, 9769, 9774, 9773, 9743, 9771, 9742, 9762, 9738, 9765, 9739, 9764, - 9746, 9744, 9745, 9740, 9741, 9760, 9747, 27116, 27122, 27133, 27130, - 27120, 27119, 27118, 27097, 27125, 27103, 27132, 27128, 27131, 27134, - 27121, 27129, 27108, 27127, 27124, 27102, 27107, 27109, 27106, 27101, - 27095, 27092, 27114, 27123, 27112, 27096, 27117, 27135, 27099, 27093, - 27105, 27136, 27113, 27110, 27111, 27094, 27090, 27115, 27091, 27100, - 27089, 27098, 27104, 27126, 25034, 25052, 25058, 25056, 25059, 25040, - 25037, 25057, 25042, 25041, 25038, 25036, 25054, 25053, 25044, 25039, - 25047, 25043, 25048, 25049, 25055, 25060, 25033, 25050, 25061, 25045, - 25062, 25035, 25051, 25046, 35536, 35536, 25069, 25071, 25068, 25067, - 25064, 25063, 25066, 25065, 25072, 25070, 35536, 35536, 35536, 35536, - 35536, 35536, 24961, 24962, 24963, 24964, 24989, 24982, 24968, 24965, - 24971, 24981, 24980, 24995, 24974, 24969, 24973, 24990, 24991, 24992, - 24975, 24976, 24993, 24970, 24986, 24985, 24979, 24967, 24978, 24966, - 24977, 24983, 24996, 24994, 24972, 24984, 24988, 24987, 35536, 35536, - 35536, 35536, 24997, 24998, 24999, 25000, 25025, 25018, 25004, 25001, - 25007, 25017, 25016, 25031, 25010, 25005, 25009, 25026, 25027, 25028, - 25011, 25012, 25029, 25006, 25022, 25021, 25015, 25003, 25014, 25002, - 25013, 25019, 25032, 25030, 25008, 25020, 25024, 25023, 35536, 35536, - 35536, 35536, 11818, 11809, 11798, 11797, 11800, 11789, 11799, 11796, - 11795, 11810, 11786, 11785, 11811, 11819, 11812, 11802, 11788, 11787, - 11813, 11792, 11791, 11790, 11820, 11814, 11815, 11794, 11793, 11804, - 11803, 11806, 11805, 11821, 11816, 11817, 11822, 11808, 11807, 11784, - 11783, 11801, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 6173, 6222, 6189, 6185, 6187, 6212, 6186, 6210, 6207, 6176, 6209, 6211, - 6190, 6201, 6197, 6192, 6220, 6184, 6175, 6193, 6196, 6198, 6223, 6214, - 6172, 6178, 6179, 6181, 6215, 6213, 6218, 6182, 6202, 6194, 6221, 6206, - 6217, 6183, 6177, 6200, 6188, 6219, 6204, 6216, 6205, 6203, 6191, 6180, - 6174, 6208, 6199, 6195, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 6224, 33492, 33461, 33462, 33472, 33471, - 33474, 33473, 33464, 33463, 33481, 33489, 35536, 33480, 33479, 33465, - 33466, 33482, 33490, 33468, 33467, 33483, 33470, 33469, 33493, 33484, - 33491, 33485, 35536, 33476, 33475, 33478, 33477, 33494, 33486, 33487, - 35536, 33495, 33488, 35536, 33527, 33496, 33497, 33507, 33506, 33509, - 33508, 33499, 33498, 33516, 33524, 35536, 33515, 33514, 33500, 33501, - 33517, 33525, 33503, 33502, 33518, 33505, 33504, 33528, 33519, 33526, - 33520, 35536, 33511, 33510, 33513, 33512, 33529, 33521, 33522, 35536, - 33530, 33523, 35536, 35536, 35536, 31948, 31949, 31962, 31922, 31951, - 31950, 31953, 31929, 31952, 31945, 31944, 31963, 31919, 31925, 31918, - 31924, 31932, 31931, 31966, 31920, 31955, 31947, 31946, 31923, 31930, - 31926, 31942, 31934, 31964, 31941, 31940, 31939, 31936, 31935, 31957, - 31956, 31967, 31965, 31959, 31928, 31958, 31927, 31968, 31921, 31961, - 31960, 31917, 31938, 31937, 31954, 31933, 31943, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 19508, - 19509, 19510, 19511, 19512, 19513, 19514, 19515, 19516, 19447, 19448, - 19449, 19450, 19451, 19460, 19452, 19453, 19454, 19455, 19456, 19457, - 19458, 19459, 19461, 19462, 19463, 19464, 19528, 19465, 19466, 19467, - 19468, 19469, 19470, 19471, 19472, 19473, 19474, 19475, 19476, 19477, - 19478, 19479, 19480, 19481, 19482, 19483, 19484, 19485, 19486, 19487, - 19488, 19489, 19490, 19491, 19492, 19493, 19494, 19495, 19496, 19497, - 19498, 19499, 19500, 19501, 19502, 19503, 19504, 19505, 19506, 19507, - 19188, 19524, 19517, 19189, 19518, 19519, 19520, 19521, 19190, 19525, - 19526, 19522, 19523, 19527, 19194, 19195, 19196, 19197, 19198, 19199, - 19200, 19201, 19191, 19192, 19193, 19205, 19206, 19207, 19202, 19203, - 19204, 19208, 19209, 19210, 19211, 19212, 19213, 19216, 19217, 19218, - 19219, 19220, 19221, 19222, 19223, 19224, 19225, 19226, 19227, 19228, - 19229, 19230, 19231, 19232, 19233, 19234, 19235, 19236, 19237, 19238, - 19239, 19240, 19241, 19242, 19243, 19244, 19245, 19246, 19247, 19248, - 19249, 19250, 19251, 19252, 19253, 19254, 19255, 19256, 19257, 19258, - 19259, 19260, 19261, 19262, 19263, 19264, 19265, 19214, 19215, 19266, - 19267, 19268, 19269, 19270, 19271, 19272, 19273, 19274, 19275, 19276, - 19277, 19278, 19279, 19280, 19281, 19282, 19283, 19284, 19285, 19286, - 19287, 19288, 19289, 19290, 19291, 19292, 19293, 19294, 19295, 19296, - 19297, 19298, 19330, 19331, 19332, 19333, 19334, 19335, 19336, 19337, - 19338, 19299, 19300, 19301, 19302, 19303, 19304, 19305, 19306, 19307, - 19308, 19309, 19310, 19311, 19312, 19313, 19314, 19315, 19316, 19317, - 19318, 19319, 19320, 19321, 19322, 19323, 19324, 19325, 19326, 19327, - 19328, 19329, 19345, 19346, 19347, 19348, 19349, 19350, 19351, 19352, - 19353, 19354, 19355, 19356, 19357, 19358, 19359, 19360, 19361, 19362, - 19363, 19364, 19339, 19340, 19341, 19342, 19343, 19344, 19365, 19366, - 19367, 19368, 19369, 19370, 19371, 19372, 19407, 19408, 19409, 19410, - 19411, 19412, 19413, 19414, 19415, 19416, 19373, 19374, 19375, 19376, - 19377, 19378, 19379, 19380, 19381, 19382, 19383, 19384, 19385, 19386, - 19387, 19388, 19389, 19390, 19391, 19392, 19398, 19399, 19400, 19401, - 19402, 19403, 19404, 19405, 19406, 19393, 19394, 19395, 19396, 19397, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 19428, - 19423, 19426, 19425, 19429, 19424, 19422, 19427, 19421, 19417, 19420, - 19419, 19418, 19435, 19433, 19434, 19430, 19431, 19432, 19436, 19438, - 19437, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 19439, 19440, 19441, 19442, 19443, 19444, 19445, 19446, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 22568, 22689, 22688, 22553, 22569, 22557, 35536, - 22587, 22589, 22588, 22583, 22582, 22580, 22581, 22642, 22575, 22599, - 22639, 22563, 22603, 22564, 22607, 22570, 22609, 22586, 22623, 22624, - 22622, 22566, 22620, 22625, 22626, 22667, 22668, 22631, 22567, 22576, - 22682, 22664, 22665, 22638, 22637, 22572, 22652, 22655, 22656, 22653, - 22651, 22679, 35536, 22574, 22494, 22541, 22388, 22472, 22501, 22385, - 22543, 22644, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 9126, 9127, 9128, 9129, 9130, 9120, 35536, 35536, 9121, 35536, - 9076, 9077, 9078, 9079, 9080, 9081, 9082, 9083, 9084, 9085, 9086, 9087, - 9088, 9089, 9090, 9091, 9092, 9093, 9094, 9095, 9096, 9097, 9098, 9099, - 9100, 9101, 9102, 9103, 9104, 9105, 9106, 9107, 9108, 9109, 9110, 9111, - 9112, 9113, 9114, 9115, 9116, 9117, 9118, 9119, 35536, 9124, 9125, 35536, - 35536, 35536, 9122, 35536, 35536, 9123, 15761, 15772, 15763, 15757, - 15769, 15774, 15764, 15770, 15755, 15768, 15771, 15758, 15776, 15773, - 15765, 15762, 15775, 15766, 15759, 15760, 15767, 15756, 35536, 15777, - 15752, 15748, 15751, 15749, 15747, 15753, 15754, 15750, 25342, 25353, - 25344, 25338, 25350, 25355, 25345, 25351, 25336, 25349, 25352, 25339, - 25357, 25335, 25354, 25346, 25343, 25356, 25347, 25340, 25341, 25348, - 25337, 25334, 25358, 25365, 25360, 25361, 25364, 25363, 25362, 25359, - 23506, 23521, 23511, 23532, 23523, 23517, 23513, 23529, 23534, 23524, - 23530, 23515, 23509, 23528, 23510, 23531, 23507, 23518, 23514, 23536, - 23512, 23533, 23525, 23522, 23535, 23526, 23519, 23520, 23508, 23527, - 23516, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 23541, - 23538, 23539, 23544, 23545, 23543, 23540, 23537, 23542, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 14807, 14823, 14815, 14814, - 14820, 14825, 14809, 14821, 14810, 14819, 14822, 14812, 14827, 14824, - 14816, 14808, 14826, 14817, 14813, 35536, 14818, 14811, 35536, 35536, - 35536, 35536, 35536, 14828, 14832, 14831, 14830, 14829, 25738, 25757, - 25753, 25740, 25741, 25749, 25750, 25742, 25748, 25751, 25754, 25756, - 25759, 25755, 25746, 25739, 25758, 25744, 25743, 25752, 25745, 25747, - 25764, 25763, 25760, 25765, 25761, 25762, 35536, 35536, 35536, 25766, - 20005, 20011, 20015, 20013, 20007, 20023, 20016, 20024, 20017, 20001, - 20018, 20009, 20019, 20021, 20004, 19999, 20022, 20014, 20020, 20003, - 20000, 20006, 20008, 20002, 20010, 20012, 35536, 35536, 35536, 35536, - 35536, 20025, 27274, 27275, 27276, 27277, 27278, 27279, 27280, 27281, - 27282, 27283, 27284, 27285, 27286, 27287, 27288, 27289, 27290, 27291, - 27292, 27267, 27268, 27269, 27270, 27271, 27272, 27273, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 22100, 22101, 22102, 22103, - 22099, 22098, 22074, 22075, 22096, 22095, 22078, 22079, 22080, 22081, - 22076, 22077, 22094, 22091, 22090, 22082, 22083, 22084, 22092, 22097, - 22085, 22086, 22087, 22088, 22089, 22093, 22104, 22105, 21996, 22017, - 22018, 22019, 22016, 22015, 22008, 22012, 22011, 22001, 22002, 22014, - 22010, 22006, 22005, 22003, 21997, 22004, 22007, 22013, 21998, 21999, - 22000, 22009, 35536, 35536, 35536, 35536, 21984, 21989, 22021, 22020, - 22070, 22062, 22056, 22033, 22027, 22050, 22044, 22022, 22039, 22068, - 22066, 22060, 22037, 22031, 22054, 22048, 35536, 35536, 22071, 22063, - 22057, 22034, 22028, 22051, 22045, 22024, 22041, 22073, 22065, 22059, - 22036, 22030, 22053, 22047, 22026, 22043, 22069, 22067, 22061, 22038, - 22032, 22055, 22049, 22023, 22040, 22072, 22064, 22058, 22035, 22029, - 22052, 22046, 22025, 22042, 21988, 21994, 21993, 21987, 21986, 21991, - 21990, 21985, 21995, 21992, 16822, 16844, 16846, 16842, 35536, 16843, - 16845, 35536, 35536, 35536, 35536, 35536, 16847, 16838, 16841, 16840, - 16788, 16786, 16810, 16809, 35536, 16808, 16807, 16816, 35536, 16796, - 16792, 16791, 16799, 16798, 16795, 16794, 16793, 16801, 16800, 16797, - 16812, 16811, 16806, 16805, 16818, 16820, 16819, 16817, 16814, 16802, - 16803, 16804, 16821, 16815, 16787, 16789, 16790, 16813, 35536, 35536, - 16836, 16837, 16839, 35536, 35536, 35536, 35536, 16848, 16785, 16784, - 16783, 16782, 16824, 16823, 16825, 16826, 16849, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 16830, 16835, 16828, 16827, 16834, 16832, - 16831, 16829, 16833, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 24709, 24705, 24710, 24715, 24706, 24713, 24699, 24707, 24711, 24703, - 24698, 24694, 24712, 24695, 24697, 24696, 24714, 24687, 24688, 24690, - 24693, 24691, 24692, 24702, 24704, 24689, 24708, 24701, 24700, 24717, - 24716, 24718, 24530, 24548, 24529, 24539, 24551, 24552, 24541, 24545, - 24543, 24536, 24540, 24532, 24547, 24531, 24553, 24542, 24544, 24525, - 24526, 24549, 24528, 24550, 24527, 24535, 24537, 24533, 24546, 24534, - 24538, 24556, 24555, 24554, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 20306, 20310, 20309, 20314, - 20313, 20311, 20335, 20338, 20354, 20318, 20317, 20316, 20315, 20336, - 20328, 20334, 20320, 20330, 20319, 20332, 20312, 20327, 20341, 20337, - 20324, 20308, 20307, 20340, 20339, 20325, 20322, 20331, 20321, 20333, - 20326, 20323, 20329, 20356, 20355, 35536, 35536, 35536, 35536, 20342, - 20346, 20345, 20344, 20343, 20353, 20351, 20349, 20348, 20347, 20352, - 20350, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 2587, 2588, 2594, 2590, 2593, 2589, 2591, 2592, 2630, 2631, 2620, 2621, - 2622, 2623, 2618, 2619, 2635, 2608, 2607, 2606, 2597, 2595, 2596, 2632, - 2634, 2617, 2615, 2627, 2626, 2616, 2638, 2633, 2625, 2624, 2602, 2601, - 2600, 2605, 2604, 2603, 2637, 2598, 2613, 2614, 2640, 2639, 2636, 2612, - 2629, 2610, 2628, 2609, 2611, 2599, 35536, 35536, 35536, 2641, 31830, - 28182, 17352, 17347, 17353, 17348, 15903, 15914, 15905, 15899, 15911, - 15916, 15906, 15912, 15897, 15910, 15913, 15900, 15918, 15915, 15907, - 15904, 15917, 15908, 15901, 15902, 15909, 15898, 35536, 35536, 15923, - 15920, 15921, 15926, 15922, 15919, 15924, 15925, 15872, 15886, 15877, - 15873, 15883, 15876, 15878, 15884, 15870, 15882, 15885, 15874, 15875, - 15887, 15879, 15888, 15880, 15881, 15871, 35536, 35536, 35536, 35536, - 35536, 15893, 15890, 15891, 15896, 15892, 15889, 15894, 15895, 25999, - 26013, 26004, 26000, 26010, 26003, 26005, 26011, 26009, 26012, 26001, - 26002, 26014, 26006, 26016, 26007, 26008, 26015, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 26024, 26025, 25997, 25998, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 26021, 26018, 26019, 26023, 26020, 26017, 26022, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 24719, 24761, 24762, - 24751, 24787, 24780, 24754, 24755, 24789, 24732, 24772, 24720, 24765, - 24734, 24774, 24722, 24766, 24733, 24773, 24721, 24750, 24786, 24740, - 24779, 24729, 24769, 24723, 24767, 24756, 24790, 24735, 24775, 24724, - 24745, 24748, 24736, 24725, 24763, 24743, 24782, 24741, 24781, 24744, - 24783, 24771, 24742, 24764, 24749, 24757, 24752, 24747, 24785, 24737, - 24776, 24753, 24788, 24758, 24791, 24738, 24777, 24726, 24730, 24727, - 24731, 24770, 24746, 24784, 24739, 24778, 24728, 24768, 24759, 24760, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 24378, 24381, 24404, 24379, 24393, - 24389, 24395, 24405, 24380, 24383, 24426, 24406, 24407, 24396, 24397, - 24408, 24427, 24428, 24409, 24410, 24382, 24423, 24398, 24399, 24384, - 24386, 24390, 24418, 24420, 24414, 24416, 24419, 24411, 24385, 24412, - 24421, 24391, 24392, 24400, 24387, 24401, 24394, 24422, 24425, 24415, - 24417, 24413, 24402, 24403, 24388, 24424, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 24429, - 24432, 24455, 24430, 24444, 24440, 24446, 24456, 24431, 24434, 24477, - 24457, 24458, 24447, 24448, 24459, 24478, 24479, 24460, 24461, 24433, - 24474, 24449, 24450, 24435, 24437, 24441, 24469, 24471, 24465, 24467, - 24470, 24462, 24436, 24463, 24472, 24442, 24443, 24451, 24438, 24452, - 24445, 24473, 24476, 24466, 24468, 24464, 24453, 24454, 24439, 24475, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 24482, 24481, 24485, - 24480, 24483, 24484, 14760, 14747, 14755, 14739, 14738, 14752, 14748, - 14751, 14736, 14749, 14733, 14732, 14741, 14740, 14759, 14746, 14745, - 14737, 14750, 14753, 14754, 14744, 14757, 14734, 14758, 14735, 14742, - 14743, 14756, 14767, 14769, 14771, 14768, 14770, 14762, 14761, 14766, - 14763, 14765, 14764, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 14778, 14780, 14777, 14776, 14773, 14772, 14775, 14774, 14781, - 14779, 35536, 35536, 35536, 35536, 35536, 35536, 12845, 12847, 12844, - 12843, 12840, 12839, 12842, 12841, 12848, 12846, 12831, 12832, 12833, - 12830, 12834, 12828, 12805, 12789, 12797, 12795, 12788, 12794, 12800, - 12802, 12796, 12792, 12790, 12803, 12804, 12801, 12799, 12786, 12791, - 12787, 12798, 12793, 12784, 12785, 35536, 35536, 35536, 12829, 12783, - 12781, 12780, 12782, 12836, 12835, 12827, 12811, 12819, 12817, 12810, - 12816, 12822, 12824, 12818, 12814, 12812, 12825, 12826, 12823, 12821, - 12808, 12813, 12809, 12820, 12815, 12806, 12807, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 12837, 12838, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 26578, 26576, 26575, 26572, 26571, - 26574, 26573, 26579, 26577, 26570, 26569, 26567, 26558, 26556, 26565, - 26563, 26554, 26560, 26561, 26568, 26566, 26557, 26555, 26564, 26562, - 26553, 26559, 26550, 26551, 26549, 26552, 35536, 33993, 34027, 34007, - 34006, 34012, 34011, 33989, 33988, 33987, 33998, 34019, 33992, 34023, - 34026, 34025, 34022, 34030, 34009, 34008, 34010, 33991, 34013, 34024, - 33994, 34018, 34029, 34014, 34015, 34002, 34000, 33999, 34001, 34003, - 33990, 34005, 34028, 34016, 34017, 33996, 33997, 34020, 33995, 35536, - 33985, 33984, 33986, 35536, 35536, 34004, 34021, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 1201, 1497, 1332, 2388, 1540, 1604, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 1065, 1654, 1652, 1650, 1909, - 1910, 1911, 1913, 1895, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 1083, 2389, 1066, 2395, 2396, - 2393, 24649, 24657, 24671, 24658, 24662, 24668, 24659, 24674, 24663, - 24669, 24667, 24670, 24661, 24676, 24672, 24651, 24652, 24664, 24650, - 24648, 24675, 24665, 24653, 24654, 24660, 24666, 24673, 24655, 24656, - 24683, 24681, 24678, 24686, 24685, 24682, 24680, 24679, 24684, 24647, - 24677, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 28242, - 28256, 28244, 28253, 28260, 28248, 28254, 28252, 28255, 28245, 28262, - 28258, 28249, 28243, 28261, 28250, 28247, 28251, 28259, 28257, 28246, - 28241, 28236, 28234, 28237, 28235, 28240, 28239, 28231, 28230, 28232, - 28238, 28233, 28263, 28266, 28265, 28264, 28269, 28270, 28267, 28271, - 28268, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 24796, 24808, 24806, 24811, 24800, 24805, 24804, - 24807, 24798, 24813, 24809, 24801, 24812, 24802, 24797, 24803, 24810, - 24799, 24795, 24794, 24793, 24792, 24817, 24814, 24815, 24816, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 6596, 6590, 6604, 6598, - 6593, 6601, 6607, 6589, 6599, 6602, 6600, 6603, 6594, 6609, 6605, 6591, - 6597, 6608, 6595, 6592, 6606, 6614, 6611, 6612, 6616, 6613, 6610, 6615, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 11845, 11856, 11847, 11841, 11853, 11858, 11848, 11854, 11839, 11852, - 11855, 11842, 11860, 11857, 11849, 11846, 11859, 11850, 11843, 11844, - 11851, 11840, 11861, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 4737, 4742, 4740, 4739, 4741, 4664, 4665, 4683, 4684, 4681, - 4682, 4676, 4677, 4678, 4679, 4710, 4666, 4657, 4667, 4703, 4702, 4699, - 4698, 4687, 4697, 4696, 4701, 4700, 4689, 4673, 4672, 4669, 4668, 4688, - 4675, 4674, 4671, 4670, 4690, 4705, 4704, 4695, 4694, 4707, 4709, 4708, - 4686, 4680, 4691, 4692, 4693, 4706, 4685, 4658, 4663, 4662, 4747, 4746, - 4756, 4757, 4750, 4751, 4752, 4753, 4754, 4755, 4758, 4748, 4743, 4749, - 4759, 4761, 4760, 4735, 4734, 4733, 4736, 4732, 35536, 35536, 35536, - 35536, 4728, 4726, 4723, 4714, 4716, 4721, 4719, 4711, 4717, 4727, 4725, - 4724, 4713, 4715, 4722, 4720, 4712, 4718, 4729, 4730, 4768, 4770, 4767, - 4766, 4763, 4762, 4765, 4764, 4771, 4769, 4738, 4660, 4661, 4744, 4745, - 4659, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 4731, 16132, 16134, 16136, 16092, 16093, 16102, 16103, 16100, 16101, - 16130, 16094, 16131, 16095, 16120, 16119, 16116, 16115, 16104, 16114, - 16113, 16118, 16117, 16106, 16097, 16096, 16089, 16087, 16088, 16123, - 16105, 16099, 16098, 16091, 16090, 16107, 16122, 16121, 16112, 16111, - 16127, 16129, 16124, 16126, 16128, 16108, 16109, 16110, 16125, 16142, - 16147, 16148, 16145, 16146, 16149, 16143, 16150, 16144, 16135, 16133, - 16153, 16154, 16151, 16137, 16138, 16140, 16139, 16141, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 16152, 35536, - 35536, 28294, 28295, 28284, 28285, 28286, 28287, 28280, 28281, 28291, - 28283, 28296, 28292, 28297, 28293, 28288, 28290, 28289, 28282, 28298, - 28277, 28299, 28301, 28300, 28278, 28279, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 28308, 28310, 28307, 28306, 28303, 28302, 28305, - 28304, 28311, 28309, 35536, 35536, 35536, 35536, 35536, 35536, 6276, - 6278, 6277, 6272, 6274, 6275, 6273, 6261, 6260, 6257, 6256, 6242, 6255, - 6254, 6259, 6258, 6244, 6247, 6246, 6239, 6238, 6243, 6249, 6248, 6241, - 6240, 6245, 6265, 6264, 6253, 6252, 6267, 6250, 6251, 6268, 6263, 6271, - 6269, 6266, 6280, 6288, 6289, 6284, 6285, 6286, 6282, 6290, 6283, 6291, - 6308, 6307, 6292, 6306, 35536, 6301, 6303, 6300, 6299, 6296, 6295, 6298, - 6297, 6304, 6302, 6279, 6294, 6293, 6305, 6262, 6281, 6287, 6270, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 20067, 20069, 20071, - 20068, 20070, 20059, 20058, 20055, 20054, 20053, 20052, 20057, 20056, - 20038, 20047, 20046, 20041, 20040, 20037, 20049, 20048, 20043, 20042, - 20039, 20061, 20060, 20051, 20050, 20064, 20045, 20063, 20066, 20065, - 20062, 20044, 20074, 20075, 20073, 20072, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 27052, 27055, 27059, 26998, 26999, - 27017, 27018, 27015, 27016, 27010, 27011, 27012, 27013, 27044, 27000, - 27045, 27001, 27037, 27036, 27033, 27032, 27021, 27031, 27030, 27035, - 27034, 27023, 27007, 27006, 27003, 27002, 27022, 27009, 27008, 27005, - 27004, 27024, 27039, 27038, 27029, 27028, 27041, 27043, 27042, 27020, - 27019, 27014, 27025, 27026, 27027, 27040, 27074, 27081, 27082, 27068, - 27069, 27077, 27078, 27079, 27080, 27083, 27075, 27064, 27076, 27058, - 27054, 27056, 27057, 27086, 26984, 26983, 27084, 27049, 27046, 27053, - 27061, 26995, 27060, 27067, 27050, 26991, 26993, 26990, 26989, 26986, - 26985, 26988, 26987, 26994, 26992, 26996, 27051, 26997, 27085, 27047, - 27048, 35536, 27996, 27994, 27993, 27990, 27989, 27992, 27991, 27997, - 27995, 28008, 28007, 28006, 28002, 28001, 28005, 28004, 28000, 28003, - 27998, 27999, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 17056, 17057, 17083, 17085, 17082, 17058, 17084, - 17059, 17073, 17072, 17048, 17046, 17047, 17066, 17071, 17070, 17055, - 17054, 35536, 17068, 17061, 17060, 17051, 17050, 17067, 17063, 17062, - 17053, 17049, 17052, 17069, 17075, 17074, 17045, 17043, 17044, 17077, - 17081, 17079, 17065, 17080, 17042, 17076, 17064, 17093, 17096, 17097, - 17100, 17098, 17094, 17099, 17095, 17090, 17089, 17088, 17086, 17040, - 17039, 17101, 17091, 17038, 17102, 17087, 17078, 17041, 17092, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 22981, 22983, 22984, 22982, 22972, 22971, 22970, 35536, 22969, - 35536, 22968, 22967, 22960, 22959, 35536, 22954, 22962, 22961, 22950, - 22948, 22949, 22953, 22964, 22963, 22952, 22951, 22955, 22974, 22973, - 22966, 35536, 22965, 22977, 22980, 22958, 22976, 22979, 22978, 22975, - 22957, 22956, 22985, 35536, 35536, 35536, 35536, 35536, 35536, 17117, - 17118, 17129, 17130, 17127, 17128, 17148, 17119, 17149, 17120, 17138, - 17137, 17108, 17106, 17107, 17131, 17136, 17135, 17116, 17115, 17114, - 17133, 17124, 17123, 17111, 17109, 17121, 17110, 17132, 17126, 17125, - 17113, 17112, 17134, 17140, 17139, 17105, 17103, 17104, 17145, 17147, - 17122, 17144, 17146, 17141, 17142, 17143, 17152, 17153, 17158, 17159, - 17156, 17157, 17160, 17154, 17161, 17155, 17150, 17151, 35536, 35536, - 35536, 35536, 35536, 17168, 17170, 17167, 17166, 17163, 17162, 17165, - 17164, 17171, 17169, 35536, 35536, 35536, 35536, 35536, 35536, 13243, - 13244, 13247, 13250, 35536, 13200, 13201, 13214, 13215, 13212, 13213, - 13195, 13197, 35536, 35536, 13238, 13202, 35536, 35536, 13237, 13203, - 13234, 13233, 13230, 13229, 13218, 13228, 13227, 13232, 13231, 13220, - 13209, 13208, 13205, 13204, 13219, 13211, 13210, 13207, 13206, 13221, - 35536, 13236, 13235, 13226, 13225, 13240, 13242, 13241, 35536, 13217, - 13216, 35536, 13199, 13222, 13223, 13224, 13239, 35536, 7169, 13245, - 13246, 13252, 13261, 13262, 13255, 13256, 13257, 13258, 35536, 35536, - 13264, 13253, 35536, 35536, 13263, 13254, 13249, 35536, 35536, 13265, - 35536, 35536, 35536, 35536, 35536, 35536, 13251, 35536, 35536, 35536, - 35536, 35536, 13248, 13194, 13193, 13196, 13198, 13259, 13260, 35536, - 35536, 7358, 7359, 7357, 7356, 7355, 7354, 7353, 35536, 35536, 35536, - 7364, 7361, 7362, 7360, 7363, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 32166, 32167, 32190, 32191, 32188, - 32189, 32183, 32184, 32185, 32186, 35536, 32212, 35536, 35536, 32168, - 35536, 32211, 32169, 32208, 32207, 32204, 32203, 32192, 32202, 32201, - 32206, 32205, 32194, 32180, 32179, 32171, 32170, 32193, 32182, 32181, - 32173, 32172, 32195, 32210, 32209, 32200, 32199, 32214, 32215, 32178, - 32176, 32187, 32196, 32197, 32198, 32213, 32175, 32177, 32174, 35536, - 32217, 32228, 32237, 32238, 32231, 32232, 32233, 32234, 32235, 32236, - 35536, 32240, 35536, 35536, 32229, 35536, 32239, 32230, 32161, 32222, - 35536, 32218, 32225, 32224, 32219, 32162, 32216, 32165, 32223, 32164, - 32163, 35536, 32220, 32221, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 32227, 32226, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 23904, 23905, 23918, 23919, 23916, 23917, 23900, - 23901, 23902, 23903, 23944, 23906, 23945, 23907, 23932, 23931, 23928, - 23927, 23893, 23892, 23926, 23925, 23930, 23929, 23895, 23894, 23913, - 23912, 23909, 23908, 23897, 23915, 23914, 23911, 23910, 23898, 23896, - 23938, 23937, 23924, 23923, 23936, 23935, 23943, 23940, 23939, 23934, - 23933, 23942, 23920, 23921, 23922, 23941, 23958, 23967, 23968, 23961, - 23962, 23963, 23964, 23965, 23966, 23969, 23959, 23970, 23960, 23953, - 23946, 23949, 23954, 23947, 23948, 23951, 23974, 23955, 23880, 23878, - 23973, 23891, 23971, 23887, 23889, 23886, 23885, 23882, 23881, 23884, - 23883, 23890, 23888, 23879, 23957, 35536, 23972, 23956, 23899, 23950, - 23952, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 31832, 31833, 31834, 31852, 31853, 31850, 31851, 31845, 31846, - 31847, 31848, 31878, 31835, 31879, 31836, 31870, 31869, 31866, 31865, - 31854, 31864, 31863, 31868, 31867, 31856, 31842, 31841, 31838, 31837, - 31855, 31844, 31843, 31840, 31839, 31857, 31872, 31871, 31862, 31861, - 31875, 31877, 31876, 31874, 31849, 31858, 31859, 31860, 31873, 31888, - 31897, 31898, 31891, 31892, 31893, 31894, 31895, 31896, 31899, 31886, - 31889, 31900, 31887, 31890, 31880, 31883, 31885, 31884, 31881, 31882, - 31911, 31831, 31912, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 31907, 31909, 31906, 31905, 31902, 31901, 31904, 31903, 31910, - 31908, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 27176, 27178, 27199, - 27200, 27197, 27198, 27192, 27193, 27194, 27195, 27225, 27179, 27226, - 27180, 27217, 27216, 27213, 27212, 27201, 27211, 27210, 27215, 27214, - 27203, 27186, 27185, 27189, 27188, 27202, 27187, 27182, 27191, 27190, - 27204, 27219, 27218, 27209, 27208, 27222, 27224, 27223, 27221, 27196, - 27205, 27206, 27207, 27220, 27254, 27261, 27262, 27259, 27260, 27257, - 27258, 35536, 35536, 27263, 27255, 27264, 27256, 27247, 27249, 27251, - 27250, 27248, 27246, 27266, 27265, 27245, 27244, 27227, 27228, 27229, - 27175, 27242, 27241, 27239, 27237, 27238, 27230, 27231, 27240, 27243, - 27235, 27236, 27234, 27233, 27232, 27181, 27183, 27184, 27177, 27252, - 27253, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 22335, 22336, 22354, 22355, 22352, - 22353, 22347, 22348, 22349, 22350, 22381, 22337, 22382, 22338, 22374, - 22373, 22370, 22369, 22358, 22368, 22367, 22372, 22371, 22360, 22344, - 22343, 22340, 22339, 22359, 22346, 22345, 22342, 22341, 22361, 22376, - 22375, 22366, 22365, 22378, 22380, 22379, 22357, 22351, 22362, 22363, - 22364, 22377, 22356, 22310, 22319, 22320, 22313, 22314, 22315, 22316, - 22317, 22318, 22321, 22311, 22322, 22312, 22306, 22309, 22308, 22305, - 22324, 22323, 22383, 22307, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 22331, 22333, 22330, 22329, 22326, - 22325, 22328, 22327, 22334, 22332, 35536, 35536, 35536, 35536, 35536, - 35536, 22864, 22859, 22704, 22865, 22863, 22861, 22860, 22721, 22722, - 22855, 22857, 22856, 22866, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 29705, 29707, 29722, 29723, 29720, 29721, 29747, - 29708, 29748, 29709, 29737, 29736, 29733, 29732, 29724, 29731, 29730, - 29735, 29734, 29726, 29717, 29716, 29711, 29710, 29725, 29719, 29718, - 29713, 29712, 29727, 29739, 29738, 29729, 29728, 29744, 29746, 29715, - 29743, 29745, 29740, 29741, 29742, 29714, 29750, 29752, 29753, 29758, - 29759, 29756, 29757, 29760, 29754, 29761, 29755, 29751, 29749, 29706, - 29704, 35536, 35536, 35536, 35536, 35536, 35536, 29768, 29770, 29767, - 29766, 29763, 29762, 29765, 29764, 29771, 29769, 35536, 35536, 35536, - 35536, 35536, 35536, 23473, 23475, 23472, 23471, 23468, 23467, 23470, - 23469, 23476, 23474, 23423, 23425, 23422, 23421, 23418, 23417, 23420, - 23419, 23426, 23424, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 191, 190, 178, 181, 175, 167, 193, 192, 183, 195, 189, 184, 174, - 196, 177, 197, 180, 194, 164, 171, 170, 187, 166, 186, 182, 188, 165, - 35536, 35536, 162, 163, 161, 203, 204, 210, 211, 208, 209, 212, 207, 213, - 205, 206, 200, 35536, 35536, 35536, 35536, 222, 224, 221, 220, 217, 216, - 219, 218, 225, 223, 215, 214, 198, 199, 201, 202, 185, 173, 172, 169, - 168, 179, 176, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 10145, 10146, 10161, - 10162, 10159, 10160, 10187, 10147, 10188, 10148, 10179, 10178, 10175, - 10174, 10163, 10173, 10172, 10177, 10176, 10165, 10156, 10155, 10150, - 10149, 10164, 10158, 10157, 10152, 10151, 10166, 10181, 10180, 10171, - 10170, 10184, 10186, 10154, 10183, 10185, 10167, 10168, 10169, 10182, - 10153, 10191, 10196, 10197, 10194, 10195, 10189, 10190, 10198, 10192, - 10199, 10193, 10202, 10204, 10203, 10201, 10200, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 33632, 33621, 33650, - 33640, 33642, 33643, 33649, 33639, 33625, 33634, 33622, 33652, 33648, - 33627, 33641, 33638, 33626, 33635, 33644, 33633, 33651, 33624, 33623, - 33646, 33647, 33630, 33629, 33628, 33631, 33636, 33637, 33645, 33664, - 33653, 33682, 33672, 33674, 33675, 33681, 33671, 33657, 33666, 33654, - 33684, 33680, 33659, 33673, 33670, 33658, 33667, 33676, 33665, 33683, - 33656, 33655, 33678, 33679, 33662, 33661, 33660, 33663, 33668, 33669, - 33677, 33691, 33693, 33690, 33689, 33686, 33685, 33688, 33687, 33694, - 33692, 33703, 33702, 33701, 33697, 33696, 33700, 33699, 33695, 33698, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 33704, 10061, 10062, 10069, 10070, 10067, 10068, 10096, - 35536, 35536, 10097, 35536, 35536, 10087, 10086, 10085, 10084, 10073, - 10083, 10082, 10091, 35536, 10075, 10057, 35536, 10064, 10063, 10074, - 10058, 10056, 10066, 10065, 10076, 10089, 10088, 10081, 10080, 10092, - 10060, 10059, 10093, 10072, 10094, 10077, 10078, 10079, 10090, 10071, - 10095, 10102, 10106, 10107, 10104, 10105, 10108, 35536, 10103, 10109, - 35536, 35536, 10101, 10099, 10098, 10110, 10115, 10112, 10116, 10111, - 10100, 10045, 10113, 10114, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 10052, 10054, 10051, 10050, 10047, 10046, 10049, - 10048, 10055, 10053, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 23595, 23596, 23611, 23612, 23609, 23610, 23592, - 23593, 35536, 35536, 23637, 23597, 23638, 23598, 23631, 23630, 23627, - 23626, 23615, 23625, 23624, 23629, 23628, 23617, 23606, 23605, 23600, - 23599, 23616, 23608, 23607, 23602, 23601, 23618, 23633, 23632, 23623, - 23622, 23635, 23636, 23604, 23614, 23594, 23619, 23620, 23621, 23634, - 23613, 23603, 23647, 23652, 23653, 23650, 23651, 23645, 23646, 35536, - 35536, 23654, 23648, 23655, 23649, 23641, 23643, 23642, 23640, 23639, - 23656, 23644, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35317, - 35338, 35335, 35334, 35337, 35333, 35332, 35330, 35331, 35336, 35329, - 35285, 35284, 35304, 35303, 35286, 35302, 35301, 35311, 35288, 35296, - 35295, 35278, 35277, 35287, 35298, 35297, 35282, 35281, 35289, 35306, - 35305, 35300, 35299, 35313, 35294, 35293, 35280, 35279, 35307, 35308, - 35309, 35316, 35314, 35312, 35315, 35290, 35291, 35292, 35310, 35283, - 35276, 35326, 35323, 35324, 35325, 35322, 35327, 35273, 35272, 35270, - 35269, 35271, 35275, 35268, 35321, 35319, 35318, 35320, 35274, 35267, - 35328, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 28400, - 28421, 28419, 28418, 28420, 28416, 28417, 28414, 28415, 28413, 28412, - 28422, 28367, 28366, 28386, 28385, 28368, 28384, 28383, 28388, 28387, - 28370, 28378, 28377, 28361, 28360, 28369, 28380, 28379, 28364, 28362, - 28371, 28390, 28389, 28382, 28381, 28396, 28376, 28375, 28363, 28391, - 28392, 28393, 28399, 28397, 28395, 28398, 28372, 28373, 28374, 28394, - 28365, 28405, 28407, 28344, 28343, 28341, 28342, 28352, 28353, 28348, - 28351, 28347, 28350, 28355, 28356, 28354, 28346, 28345, 28349, 28408, - 28406, 28423, 28409, 28404, 28403, 28402, 28401, 28359, 28358, 28357, - 28410, 28411, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 5719, 5720, 5717, 5718, 5715, 5716, - 5725, 5726, 5723, 5724, 5721, 5722, 5888, 5889, 5890, 5887, 25556, 25554, - 25563, 25564, 25560, 25568, 25567, 25549, 25562, 25561, 25553, 25566, - 25559, 25552, 25558, 25557, 25550, 25555, 25565, 25544, 25551, 25569, - 25570, 25545, 25571, 25547, 25548, 25546, 25540, 25537, 25541, 25539, - 25535, 25538, 25542, 25536, 25543, 25577, 25576, 25587, 25578, 25579, - 25588, 25584, 25583, 25585, 25586, 25580, 25534, 25581, 25582, 25573, - 25572, 25532, 25574, 25575, 25533, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 9787, 9788, 9877, 9878, 9879, 9880, 9887, 9886, 9888, 9892, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 27066, 27065, 27071, 27070, - 27072, 27073, 27062, 27063, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 29007, 29026, 29033, 29030, 29020, 29017, 29012, 29034, - 29002, 29019, 29029, 29009, 29006, 29015, 29032, 29010, 29028, 29016, - 29021, 29027, 29031, 29004, 29003, 29008, 29024, 29018, 29014, 29013, - 29022, 29005, 29023, 29025, 29011, 29035, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 29042, 29044, 29041, 29040, 29037, 29036, 29039, 29038, 29045, 29043, - 35536, 35536, 35536, 35536, 35536, 35536, 3761, 3762, 3775, 3776, 3773, - 3774, 3757, 3758, 3759, 35536, 3801, 3763, 3802, 3764, 3793, 3792, 3789, - 3788, 3777, 3787, 3786, 3791, 3790, 3779, 3770, 3769, 3766, 3765, 3778, - 3772, 3771, 3768, 3767, 3780, 3795, 3794, 3785, 3784, 3798, 3800, 3799, - 3797, 3760, 3781, 3782, 3783, 3796, 3829, 3834, 3835, 3832, 3833, 3826, - 3827, 3828, 35536, 3836, 3830, 3837, 3831, 3821, 3823, 3825, 3824, 3822, - 3839, 3838, 3850, 3851, 3852, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 3846, 3848, 3845, 3844, 3841, 3840, 3843, - 3842, 3849, 3847, 3820, 3818, 3815, 3806, 3808, 3813, 3811, 3803, 3809, - 3819, 3817, 3816, 3805, 3807, 3814, 3812, 3804, 3810, 3853, 35536, 35536, - 35536, 20431, 20432, 20377, 20376, 20386, 20371, 20375, 20374, 20388, - 20372, 20368, 20367, 20370, 20373, 20379, 20378, 20385, 20390, 20366, - 20365, 20369, 20392, 20382, 20383, 20384, 20393, 20391, 20389, 20380, - 20381, 20387, 20394, 35536, 35536, 20409, 20408, 20417, 20403, 20407, - 20406, 20419, 20404, 20400, 20399, 20402, 20405, 20411, 20410, 20416, - 20421, 20398, 20397, 20401, 20423, 20414, 20415, 35536, 20424, 20422, - 20420, 20412, 20413, 20418, 20425, 20426, 20428, 20430, 20427, 20429, - 20396, 20395, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 20443, 20444, 20453, 20454, 20451, - 20452, 20480, 35536, 20445, 20481, 35536, 20446, 20459, 20458, 20472, - 20471, 20460, 20470, 20469, 20437, 20436, 20462, 20439, 20438, 20448, - 20447, 20461, 20442, 20440, 20450, 20449, 20463, 20474, 20473, 20468, - 20467, 20476, 20479, 20477, 20456, 20478, 20464, 20465, 20466, 20475, - 20455, 20457, 20435, 20441, 20490, 20495, 20496, 20493, 20494, 20489, - 35536, 35536, 35536, 20497, 35536, 20491, 20498, 35536, 20492, 20488, - 20487, 20486, 20484, 20485, 20499, 20483, 20482, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 20506, 20508, 20505, 20504, 20501, - 20500, 20503, 20502, 20509, 20507, 35536, 35536, 35536, 35536, 35536, - 35536, 13918, 13919, 13932, 13933, 13930, 13931, 35536, 13949, 13920, - 35536, 13948, 13921, 13955, 13954, 13937, 13936, 13951, 13945, 13944, - 13929, 13928, 13935, 13941, 13940, 13925, 13924, 13917, 13939, 13938, - 13927, 13926, 13934, 13943, 13942, 13923, 13922, 13916, 13947, 13946, - 13950, 13952, 13953, 13958, 13963, 13964, 13961, 13962, 35536, 13966, - 13959, 35536, 13965, 13960, 13957, 13956, 13967, 13978, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 13974, 13976, 13973, 13972, 13969, - 13968, 13971, 13970, 13977, 13975, 35536, 35536, 35536, 35536, 35536, - 35536, 32001, 31999, 32006, 32004, 31969, 31970, 31997, 31998, 31987, - 31988, 32003, 31983, 31986, 31971, 31974, 31975, 31984, 31985, 31972, - 31973, 31976, 31989, 31990, 31993, 31994, 31979, 31995, 31996, 31991, - 31992, 31978, 32009, 31980, 32002, 32007, 31977, 32005, 32000, 32008, - 31981, 31982, 32010, 32011, 32012, 35536, 35536, 35536, 35536, 32019, - 32021, 32018, 32017, 32014, 32013, 32016, 32015, 32022, 32020, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 20129, 20127, 20121, 20132, 20124, - 20131, 20135, 20126, 20123, 20125, 20128, 20122, 20137, 20133, 20130, - 20136, 20134, 20138, 20144, 20141, 20143, 20140, 20142, 20139, 20120, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 16667, 16671, 16669, - 16670, 16608, 16609, 16628, 16629, 16622, 16623, 16624, 16625, 16626, - 16627, 16653, 16610, 16654, 35536, 16644, 16643, 16642, 16641, 16630, - 16640, 16639, 16613, 16612, 16632, 16619, 16618, 16615, 16614, 16631, - 16621, 16620, 16617, 16616, 16633, 16646, 16645, 16638, 16637, 16649, - 16652, 16650, 16648, 16651, 16634, 16635, 16636, 16647, 16611, 16673, - 16672, 16680, 16681, 16678, 16679, 16675, 35536, 35536, 35536, 16676, - 16674, 16677, 16666, 16694, 16683, 16682, 16661, 16664, 16660, 16662, - 16658, 16657, 16665, 16656, 16659, 16663, 16655, 16690, 16692, 16689, - 16688, 16685, 16684, 16687, 16686, 16693, 16691, 16668, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 19775, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 29828, - 29824, 29818, 29827, 29820, 29829, 29833, 29835, 29830, 29825, 29826, - 29831, 29819, 29836, 29834, 29821, 29832, 29822, 29823, 29837, 29838, - 29902, 29885, 29883, 29892, 29891, 29887, 29893, 29889, 29888, 29895, - 29896, 29897, 29894, 29886, 29899, 29817, 29804, 29875, 29882, 30172, - 30173, 29802, 29777, 29903, 30171, 29839, 29904, 29890, 29898, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 29880, 7938, 7946, 7944, 7940, 7945, 7941, 7939, 7942, - 7943, 8007, 7947, 7956, 7955, 7949, 7948, 7960, 7950, 7951, 7959, 7953, - 7954, 7961, 7962, 7967, 7964, 7963, 7965, 7966, 7969, 7971, 7973, 7972, - 7974, 7980, 7977, 7978, 7982, 7975, 7976, 7981, 7979, 7984, 7983, 7985, - 7987, 7988, 7992, 7991, 7989, 7990, 7993, 8006, 7994, 7995, 7996, 8005, - 7997, 8001, 8002, 8000, 7998, 7999, 8004, 8003, 8008, 8009, 8020, 8011, - 8015, 8016, 8017, 8018, 8019, 8021, 8024, 8023, 8022, 8025, 8027, 8028, - 8029, 8030, 8031, 8032, 8033, 8034, 8035, 8036, 8037, 8038, 8039, 8040, - 8041, 8042, 8043, 8044, 8059, 8045, 8046, 8056, 8050, 8047, 8048, 8049, - 8057, 8054, 8058, 8055, 8051, 8053, 8066, 8062, 8063, 8064, 8067, 8078, - 8068, 8071, 8072, 8074, 8075, 8076, 8079, 8082, 8080, 8081, 8083, 8084, - 8086, 8087, 8116, 8123, 8117, 8118, 8119, 8120, 8121, 8122, 8124, 8126, - 8125, 8127, 8130, 8131, 8134, 8128, 8129, 8135, 8180, 8179, 8181, 8136, - 8139, 8140, 8141, 8137, 8138, 8142, 8145, 8143, 8146, 8148, 8157, 8158, - 8159, 8160, 8178, 8161, 8162, 8175, 8176, 8174, 8163, 8164, 8165, 8166, - 8167, 8168, 8169, 8172, 8173, 8182, 8272, 8183, 8184, 8186, 8185, 8192, - 8187, 8189, 8191, 8195, 8194, 8196, 8197, 8204, 8198, 8199, 8203, 8207, - 8208, 8205, 8206, 8214, 8211, 8215, 8216, 8217, 8218, 8219, 8221, 8222, - 8224, 8223, 8226, 8225, 8228, 8227, 8229, 8230, 8232, 8233, 8237, 8239, - 8243, 8244, 8257, 8249, 8250, 8245, 8246, 8247, 8251, 8255, 8252, 8253, - 8254, 8258, 8259, 8261, 8262, 8263, 8264, 8265, 8266, 8276, 8267, 8268, - 8271, 8270, 8269, 8273, 8274, 8275, 8277, 8278, 8281, 8282, 8283, 8284, - 8285, 8287, 8286, 8303, 8294, 8295, 8288, 8289, 8291, 8292, 8290, 8293, - 8302, 8296, 8301, 8299, 8298, 8300, 8305, 8324, 8306, 8307, 8308, 8311, - 8310, 8312, 8313, 8315, 8316, 8317, 8325, 8318, 8319, 8320, 8323, 8322, - 8321, 8326, 8327, 8329, 8330, 8331, 8332, 8334, 8338, 8335, 8339, 8337, - 8336, 8340, 8341, 8342, 8343, 8347, 8346, 8344, 8345, 8348, 8349, 8351, - 8370, 8372, 8352, 8354, 8353, 8355, 8356, 8359, 8360, 8358, 8357, 8361, - 8362, 8363, 8364, 8367, 8365, 8366, 8368, 8369, 8373, 8374, 8371, 8375, - 8376, 8377, 8378, 8380, 8383, 8382, 8384, 8385, 8387, 8388, 8389, 8393, - 8392, 8390, 8391, 8394, 8398, 8397, 8396, 8399, 8400, 8402, 8403, 8407, - 8404, 8405, 8410, 8408, 8411, 8412, 8414, 8413, 8415, 8416, 8438, 8437, - 8440, 8441, 8422, 8423, 8420, 8421, 8419, 8417, 8425, 8424, 8426, 8428, - 8434, 8435, 8432, 8433, 8442, 8443, 8444, 8462, 8447, 8448, 8449, 8445, - 8446, 8450, 8451, 8452, 8453, 8454, 8456, 8457, 8458, 8459, 8460, 8485, - 8463, 8466, 8464, 8465, 8471, 8472, 8469, 8470, 8467, 8468, 8473, 8474, - 8482, 8475, 8476, 8483, 8480, 8481, 8484, 8477, 8478, 8479, 8486, 8487, - 8488, 8489, 8490, 8491, 8492, 8494, 8495, 8493, 8496, 8497, 8538, 8539, - 8500, 8501, 8498, 8499, 8504, 8505, 8503, 8509, 8506, 8508, 8507, 8513, - 8514, 8512, 8510, 8511, 8515, 8516, 8517, 8518, 8519, 8520, 8521, 8540, - 8526, 8522, 8523, 8524, 8525, 8527, 8529, 8528, 8530, 8531, 8533, 8532, - 8534, 8536, 8535, 8541, 8542, 8545, 8546, 8543, 8544, 8620, 8615, 8616, - 8617, 8618, 8619, 8621, 8624, 8622, 8623, 8625, 8667, 8626, 8656, 8657, - 8633, 8635, 8652, 8636, 8658, 8640, 8638, 8639, 8641, 8642, 8643, 8644, - 8653, 8654, 8647, 8648, 8650, 8659, 8627, 8628, 8632, 8630, 8668, 8660, - 8662, 8661, 8663, 8669, 8670, 8664, 8665, 8666, 8671, 8672, 8673, 8676, - 8677, 8678, 8674, 8675, 8679, 8680, 8682, 8684, 8685, 8703, 8701, 8702, - 8705, 8704, 8686, 8693, 8691, 8692, 8687, 8688, 8694, 8695, 8696, 8697, - 8698, 8700, 8706, 8715, 8707, 8709, 8710, 8708, 8711, 8713, 8712, 8714, - 8717, 8719, 8718, 8720, 8721, 8754, 8756, 8722, 8724, 8723, 8726, 8729, - 8727, 8728, 8732, 8736, 8739, 8738, 8741, 8744, 8742, 8743, 8747, 8749, - 8755, 8757, 8758, 8762, 8769, 8767, 8765, 8766, 8768, 8771, 8770, 8763, - 8764, 8772, 8775, 8781, 8776, 8779, 8774, 8773, 8782, 8780, 8777, 8778, - 8783, 8784, 8785, 8786, 8787, 8788, 8789, 8791, 8794, 8795, 8798, 8799, - 8800, 8796, 8797, 8792, 8793, 8801, 8802, 8803, 8804, 8805, 8806, 8808, - 8809, 8810, 8811, 8812, 8816, 8813, 8837, 8830, 8831, 8836, 8819, 8818, - 8832, 8835, 8833, 8822, 8821, 8824, 8826, 8827, 8828, 8829, 8825, 8838, - 8814, 8839, 8840, 8841, 8842, 8843, 8844, 8852, 8850, 8848, 8851, 8847, - 8849, 8845, 8846, 8853, 8855, 8856, 8857, 8864, 8859, 8860, 8868, 8869, - 8865, 8867, 8866, 8870, 8872, 8871, 8873, 8884, 8875, 8874, 8883, 8881, - 8876, 8877, 8878, 8880, 8879, 8882, 8888, 8885, 8887, 8886, 8889, 8890, - 8891, 8892, 8895, 8896, 8898, 8899, 8900, 8901, 8903, 8902, 8904, 8911, - 8905, 8906, 8912, 8907, 8908, 8909, 8910, 8913, 8917, 8914, 8915, 8916, - 8918, 8919, 8920, 8921, 8927, 8925, 8923, 8924, 8922, 8926, 8928, 8930, - 8947, 8948, 8931, 8936, 8938, 8932, 8935, 8933, 8934, 8939, 8945, 8946, - 8940, 8943, 8944, 8949, 8955, 8954, 8950, 8952, 8951, 9036, 9037, 8956, - 8957, 8962, 8963, 8960, 8961, 8964, 8958, 8959, 8965, 8968, 8969, 8971, - 8972, 8973, 8977, 8974, 8975, 8976, 8966, 8967, 8978, 8980, 8979, 8981, - 8983, 8984, 8985, 8991, 8990, 8986, 8987, 8988, 9023, 8992, 8993, 8994, - 8995, 8996, 9015, 8998, 8999, 9001, 9000, 9002, 9003, 9019, 9004, 9006, - 9005, 9018, 9008, 9016, 9020, 9011, 9010, 9017, 9012, 9014, 9013, 9021, - 9022, 9024, 9028, 9026, 9027, 9025, 9031, 9030, 9029, 9035, 9032, 9033, - 9034, 9038, 9040, 9039, 9043, 9041, 9058, 9044, 9047, 9049, 9045, 9046, - 9050, 9048, 9051, 9053, 9055, 9056, 9057, 8461, 7957, 7968, 7986, 8052, - 8061, 8077, 8085, 8177, 8170, 8188, 8190, 8280, 8304, 8350, 8379, 8381, - 8395, 8401, 8436, 8409, 8439, 8418, 8427, 8431, 8502, 8631, 8634, 8649, - 8681, 8699, 8716, 8725, 8753, 8751, 8730, 8761, 8790, 8807, 8817, 8937, - 8970, 8953, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 7922, 7917, 7854, 7840, 7901, 7897, 7829, - 7874, 7921, 7862, 7846, 7907, 7896, 7828, 7873, 7860, 7844, 7903, 7893, - 7823, 7870, 7883, 7927, 7919, 7856, 7842, 7905, 7895, 7825, 7872, 7884, - 7928, 7920, 7857, 7843, 7929, 7911, 7912, 7858, 7834, 7900, 7892, 7822, - 7869, 7887, 7930, 7913, 7914, 7859, 7835, 7898, 7899, 7882, 7925, 7908, - 7909, 7849, 7839, 7915, 7916, 7850, 7853, 7851, 7852, 7906, 7891, 7889, - 7890, 7826, 7827, 7865, 7867, 7868, 7866, 7923, 7918, 7855, 7841, 7902, - 7881, 7924, 7910, 7847, 7848, 7837, 7838, 7864, 7863, 7877, 7926, 7886, - 7932, 7836, 7885, 7931, 7878, 7879, 7875, 7876, 7880, 7888, 7830, 7833, - 7832, 7831, 7861, 7845, 7904, 7894, 7824, 7871, 35536, 7937, 7936, 7935, - 7933, 7934, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 7958, 7952, 7970, 8010, 8012, 8013, 8014, 8026, - 8065, 8060, 8070, 8069, 8073, 8090, 8088, 8089, 8091, 8092, 8110, 8096, - 8093, 8094, 8095, 8112, 8113, 8111, 8100, 8099, 8097, 8098, 8103, 8101, - 8102, 8104, 8105, 8106, 8107, 8114, 8115, 8109, 8108, 8133, 8132, 8144, - 8147, 8152, 8156, 8149, 8153, 8154, 8150, 8151, 8155, 8171, 8193, 8200, - 8201, 8202, 8209, 8210, 8213, 8212, 8220, 8231, 8234, 8235, 8236, 8238, - 8240, 8241, 8242, 8248, 8256, 8260, 8279, 8297, 8309, 8314, 8328, 8333, - 8386, 8406, 8429, 8430, 8537, 8557, 8547, 8548, 8556, 8552, 8553, 8554, - 8551, 8550, 8549, 8555, 8559, 8558, 8565, 8566, 8560, 8561, 8562, 8567, - 8563, 8564, 8568, 8569, 8570, 8571, 8572, 8573, 8580, 8574, 8579, 8578, - 8576, 8575, 8577, 8581, 8582, 8587, 8588, 8583, 8584, 8585, 8586, 8614, - 8610, 8589, 8597, 8598, 8596, 8595, 8599, 8590, 8591, 8593, 8594, 8592, - 8611, 8600, 8607, 8609, 8604, 8605, 8608, 8603, 8606, 8602, 8601, 8612, - 8613, 8629, 8655, 8637, 8645, 8646, 8651, 8683, 8690, 8689, 8750, 8731, - 8733, 8752, 8734, 8735, 8737, 8740, 8745, 8746, 8748, 8815, 8834, 8820, - 8823, 8854, 8858, 8861, 8862, 8863, 8894, 8893, 8897, 8929, 8941, 8942, - 8982, 8989, 8997, 9009, 9007, 9042, 9052, 9054, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 9131, - 9132, 9133, 9134, 9135, 9136, 9137, 9138, 9141, 9142, 9139, 9140, 9143, - 9144, 9145, 9146, 9147, 9148, 9149, 9150, 9151, 9152, 9153, 9154, 9155, - 9156, 9157, 9158, 9159, 9160, 9161, 9162, 9163, 9164, 9165, 9166, 9167, - 9168, 9169, 9170, 9171, 9172, 9173, 9174, 9175, 9176, 9177, 9197, 9198, - 9199, 9200, 9201, 9202, 9203, 9204, 9205, 9180, 9181, 9182, 9183, 9184, - 9178, 9179, 9185, 9186, 9187, 9206, 9207, 9208, 9209, 9210, 9211, 9212, - 9213, 9214, 9215, 9188, 9189, 9190, 9191, 9192, 9193, 9194, 9195, 9196, - 9216, 9217, 9218, 9219, 9220, 9221, 9222, 9223, 9224, 9225, 9226, 9227, - 9228, 9229, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 10667, 10668, 10669, 10670, 10665, - 10666, 10662, 10663, 10664, 10671, 10672, 10673, 10678, 10679, 10680, - 10681, 10674, 10675, 10682, 10683, 10676, 10677, 10684, 10685, 10712, - 10713, 10714, 10715, 10716, 10717, 10718, 10719, 10720, 10721, 10702, - 10703, 10700, 10701, 10704, 10705, 10706, 10707, 10708, 10709, 10710, - 10686, 10687, 10694, 10688, 10689, 10690, 10691, 10695, 10692, 10693, - 10696, 10697, 10698, 10699, 10722, 10723, 10724, 10725, 10726, 10727, - 10728, 10729, 10730, 10731, 10732, 10733, 10734, 10735, 10736, 10737, - 10738, 10739, 10740, 10741, 10711, 10781, 10782, 10783, 10784, 10779, - 10780, 10785, 10786, 10787, 10788, 10793, 10789, 10790, 10791, 10792, - 10794, 10795, 10796, 10797, 10798, 10799, 10800, 10801, 10802, 10803, - 10804, 10805, 10806, 10807, 10808, 10809, 10810, 10811, 10812, 10813, - 10814, 10815, 10816, 10819, 10820, 10821, 10822, 10823, 10824, 10825, - 10817, 10818, 10826, 10899, 10900, 10901, 10902, 10903, 10904, 10905, - 10906, 10907, 10908, 10890, 10891, 10892, 10893, 10894, 10895, 10896, - 10888, 10889, 10897, 10898, 10831, 10827, 10828, 10832, 10833, 10829, - 10830, 10834, 10835, 10836, 10837, 10838, 10843, 10844, 10845, 10846, - 10847, 10848, 10839, 10840, 10849, 10841, 10842, 10850, 10851, 10852, - 10853, 10854, 10855, 10856, 10857, 10858, 10859, 10860, 10865, 10861, - 10862, 10866, 10863, 10864, 10867, 10868, 10869, 10870, 10871, 10881, - 10882, 10883, 10884, 10885, 10886, 10887, 10872, 10873, 10874, 10875, - 10876, 10877, 10878, 10879, 10880, 10913, 10914, 10915, 10916, 10917, - 10918, 10919, 10909, 10910, 10911, 10912, 10945, 10946, 10947, 10948, - 10949, 10950, 10941, 10942, 10943, 10944, 10951, 10952, 10920, 10921, - 10924, 10925, 10926, 10927, 10928, 10929, 10930, 10922, 10923, 10931, - 10934, 10935, 10936, 10937, 10932, 10933, 10938, 10939, 10940, 10956, - 10957, 10958, 10959, 10960, 10961, 10962, 10963, 10964, 10965, 10968, - 10969, 10970, 10966, 10967, 10971, 10972, 10973, 10974, 10975, 10976, - 11012, 11010, 11011, 11013, 11014, 11015, 11016, 11017, 11018, 11019, - 11020, 10983, 10977, 10978, 10984, 10985, 10986, 10987, 10988, 10979, - 10980, 10981, 10982, 10989, 10996, 10997, 10998, 10999, 11000, 10990, - 10991, 10992, 10993, 10994, 10995, 11001, 11002, 11007, 11003, 11004, - 11005, 11006, 11008, 11009, 11027, 11028, 11029, 11030, 11031, 11025, - 11026, 11022, 11023, 11024, 11032, 11033, 11036, 11034, 11035, 11037, - 11038, 11039, 11040, 11041, 11042, 11043, 11044, 11069, 11070, 11073, - 11074, 11075, 11076, 11077, 11071, 11072, 11078, 11079, 11080, 11049, - 11050, 11051, 11052, 11053, 11054, 11045, 11046, 11047, 11048, 11055, - 11056, 11061, 11062, 11063, 11057, 11058, 11064, 11059, 11060, 11065, - 11066, 11067, 11068, 11081, 11082, 11083, 11084, 11085, 11088, 11089, - 11090, 11091, 11092, 11086, 11087, 11093, 11094, 11102, 11103, 11104, - 11105, 11098, 11099, 11106, 11107, 11108, 11100, 11101, 11109, 11110, - 11111, 11112, 11113, 11114, 11115, 11116, 11757, 11758, 11759, 11760, - 11761, 11762, 11763, 11764, 11128, 11124, 11125, 11129, 11130, 11131, - 11126, 11127, 11132, 11133, 11135, 11136, 11137, 11140, 11138, 11139, - 11141, 11142, 11143, 11144, 11145, 11146, 11156, 11157, 11164, 11147, - 11148, 11149, 11150, 11151, 11152, 11153, 11154, 11155, 11165, 11166, - 11158, 11159, 11160, 11161, 11162, 11163, 11167, 11168, 11175, 11176, - 11169, 11170, 11177, 11171, 11172, 11178, 11179, 11180, 11173, 11174, - 11181, 11187, 11185, 11186, 11188, 11182, 11183, 11184, 11189, 11190, - 11191, 11192, 11193, 11194, 11195, 11196, 11197, 11198, 11199, 11200, - 11257, 11258, 11259, 11260, 11261, 11262, 11263, 11264, 11265, 11220, - 11221, 11222, 11223, 11224, 11225, 11226, 11227, 11217, 11218, 11219, - 11228, 11245, 11246, 11247, 11248, 11249, 11243, 11244, 11250, 11251, - 11252, 11253, 11237, 11238, 11239, 11229, 11230, 11231, 11232, 11233, - 11234, 11240, 11235, 11236, 11241, 11242, 11254, 11255, 11256, 11268, - 11269, 11270, 11271, 11266, 11267, 11272, 11273, 11274, 11275, 11278, - 11279, 11280, 11281, 11282, 11283, 11284, 11276, 11277, 11285, 11286, - 11287, 11305, 11306, 11307, 11308, 11309, 11310, 11311, 11312, 11313, - 11288, 11289, 11290, 11291, 11294, 11295, 11296, 11297, 11298, 11299, - 11292, 11293, 11300, 11303, 11304, 11301, 11302, 11321, 11322, 11325, - 11326, 11327, 11323, 11324, 11314, 11315, 11316, 11317, 11318, 11319, - 11320, 11328, 11329, 11330, 11331, 11332, 11333, 11334, 11337, 11338, - 11339, 11340, 11341, 11342, 11343, 11344, 11335, 11336, 11345, 11346, - 11353, 11354, 11355, 11347, 11348, 11349, 11350, 11356, 11357, 11358, - 11351, 11352, 11364, 11365, 11368, 11369, 11366, 11367, 11370, 11371, - 11359, 11360, 11361, 11362, 11363, 11372, 11373, 11374, 11379, 11380, - 11381, 11382, 11383, 11384, 11385, 11386, 11387, 11388, 11375, 11376, - 11377, 11378, 11390, 11391, 11394, 11392, 11393, 11395, 11396, 11397, - 11398, 11399, 11400, 11401, 11402, 11765, 11766, 11767, 11768, 11769, - 11770, 11771, 11408, 11406, 11407, 11403, 11404, 11405, 11409, 11410, - 11411, 11412, 11413, 11414, 11415, 11416, 11419, 11420, 11421, 11422, - 11423, 11417, 11418, 11424, 11425, 11426, 11427, 11428, 11429, 11430, - 11431, 11432, 11433, 11434, 11435, 11436, 11441, 11437, 11438, 11442, - 11443, 11444, 11439, 11440, 11445, 11446, 11447, 11453, 11454, 11455, - 11456, 11448, 11449, 11450, 11457, 11458, 11451, 11452, 11459, 11460, - 11464, 11465, 11466, 11467, 11468, 11469, 11461, 11462, 11463, 11470, - 11471, 11472, 11475, 11476, 11477, 11478, 11479, 11473, 11474, 11480, - 11481, 11482, 11483, 11484, 11485, 11486, 11487, 11488, 11489, 11490, - 11499, 11500, 11491, 11492, 11501, 11502, 11503, 11493, 11494, 11495, - 11496, 11497, 11498, 11508, 11504, 11505, 11509, 11510, 11511, 11512, - 11506, 11507, 11513, 11514, 11515, 11525, 11526, 11527, 11528, 11529, - 11530, 11531, 11532, 11533, 11534, 11520, 11521, 11516, 11517, 11518, - 11519, 11522, 11523, 11524, 11539, 11540, 11541, 11542, 11543, 11536, - 11537, 11538, 11544, 11545, 11546, 11573, 11574, 11575, 11576, 11577, - 11578, 11579, 11580, 11581, 11582, 11551, 11552, 11553, 11547, 11548, - 11554, 11555, 11556, 11557, 11558, 11549, 11550, 11561, 11562, 11559, - 11560, 11563, 11564, 11565, 11566, 11567, 11568, 11569, 11570, 11571, - 11572, 11586, 11587, 11588, 11589, 11590, 11591, 11592, 11593, 11594, - 11595, 11596, 11597, 11598, 11599, 11600, 11601, 11583, 11584, 11585, - 11602, 11603, 11612, 11604, 11605, 11606, 11607, 11609, 11610, 11611, - 11613, 11614, 11615, 11616, 11617, 11618, 11619, 11620, 11621, 11622, - 11623, 11624, 11625, 11626, 11627, 11628, 11629, 11630, 11631, 11632, - 11639, 11640, 11633, 11634, 11641, 11642, 11643, 11644, 11635, 11636, - 11637, 11638, 11645, 11646, 11647, 11648, 11653, 11649, 11650, 11654, - 11655, 11656, 11651, 11652, 11657, 11658, 11659, 11660, 11666, 11667, - 11662, 11663, 11668, 11669, 11670, 11671, 11672, 11664, 11665, 11673, - 11674, 11681, 11682, 11683, 11675, 11676, 11684, 11685, 11677, 11678, - 11679, 11680, 11686, 11689, 11690, 11691, 11692, 11687, 11688, 11693, - 11702, 11703, 11704, 11695, 11696, 11697, 11705, 11698, 11699, 11706, - 11700, 11701, 11707, 11708, 11709, 11710, 11711, 11712, 11713, 11714, - 11715, 11728, 11716, 11717, 11718, 11719, 11720, 11721, 11722, 11723, - 11724, 11725, 11726, 11727, 11729, 11730, 11731, 11732, 11752, 11753, - 11754, 11755, 11756, 11733, 11734, 11735, 11736, 11737, 11738, 11739, - 11740, 11741, 11742, 11743, 11744, 11745, 11746, 11747, 11748, 11749, - 11750, 11751, 10745, 10746, 10747, 10748, 10749, 10750, 10742, 10743, - 10744, 10751, 10752, 10756, 10757, 10758, 10759, 10760, 10761, 10762, - 10763, 10764, 10765, 10766, 10767, 10768, 10769, 10770, 10771, 10772, - 10773, 10774, 10775, 10753, 10754, 10755, 11608, 11661, 11097, 11122, - 11119, 11121, 11118, 11389, 10778, 10955, 11123, 11120, 11117, 10777, - 10954, 10776, 10953, 11216, 11021, 11095, 11134, 11096, 11535, 11694, - 11212, 11203, 11207, 11214, 11210, 11204, 11209, 11206, 11213, 11202, - 11208, 11215, 11211, 11205, 11201, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 447, 448, 449, 450, 451, 452, 453, - 454, 455, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 377, - 378, 379, 380, 381, 382, 375, 376, 383, 384, 385, 427, 428, 429, 430, - 431, 432, 433, 434, 435, 425, 426, 393, 389, 390, 394, 395, 396, 391, - 392, 386, 387, 388, 397, 398, 399, 456, 457, 458, 459, 460, 461, 462, - 463, 464, 465, 404, 405, 406, 407, 408, 409, 400, 401, 402, 403, 410, - 411, 412, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, - 478, 479, 480, 481, 482, 483, 484, 485, 417, 418, 419, 420, 421, 422, - 423, 413, 414, 415, 416, 424, 497, 498, 499, 500, 501, 502, 503, 486, - 487, 488, 489, 494, 495, 496, 504, 490, 491, 492, 493, 505, 506, 507, - 508, 509, 512, 513, 514, 515, 510, 511, 516, 517, 518, 519, 522, 523, - 524, 525, 526, 520, 521, 527, 528, 529, 530, 533, 534, 535, 536, 537, - 531, 532, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, - 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, - 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, - 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, - 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 609, 610, 602, 603, - 604, 611, 612, 613, 614, 605, 606, 615, 607, 608, 620, 621, 622, 623, - 624, 616, 617, 618, 619, 625, 626, 627, 653, 654, 655, 656, 657, 658, - 659, 651, 652, 660, 661, 673, 674, 675, 676, 677, 678, 679, 680, 681, - 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, - 696, 697, 698, 699, 700, 701, 702, 664, 665, 666, 667, 668, 669, 670, - 662, 663, 671, 672, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, - 642, 643, 644, 645, 646, 647, 648, 649, 650, 640, 641, 632, 633, 634, - 635, 628, 629, 636, 637, 638, 639, 630, 631, 715, 716, 717, 718, 719, - 720, 721, 722, 723, 713, 714, 807, 808, 809, 810, 811, 812, 813, 814, - 815, 816, 726, 727, 728, 729, 730, 731, 732, 733, 734, 724, 725, 753, - 754, 750, 751, 752, 755, 756, 757, 746, 747, 748, 749, 758, 759, 760, - 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 737, 738, 739, 740, - 741, 742, 743, 744, 745, 735, 736, 765, 766, 767, 768, 761, 762, 769, - 770, 771, 763, 764, 772, 798, 796, 797, 799, 800, 801, 802, 803, 804, - 805, 806, 779, 775, 776, 780, 773, 774, 781, 782, 777, 778, 783, 784, - 785, 787, 788, 789, 786, 790, 791, 792, 793, 794, 795, 858, 859, 860, - 861, 862, 863, 864, 865, 866, 867, 827, 828, 829, 830, 831, 832, 833, - 834, 835, 836, 837, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, - 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, - 892, 893, 894, 895, 896, 897, 838, 839, 842, 843, 844, 845, 846, 847, - 840, 841, 848, 849, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, - 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, - 922, 923, 924, 925, 926, 927, 850, 851, 852, 853, 854, 855, 856, 857, - 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, - 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, - 957, 928, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 14098, 14088, 14087, 14084, - 14083, 14069, 14082, 14081, 14086, 14085, 14091, 14076, 14075, 14072, - 14071, 14096, 14078, 14077, 14074, 14073, 14070, 14090, 14089, 14080, - 14079, 14093, 14097, 14094, 14092, 14095, 14101, 14108, 14109, 14104, - 14105, 14110, 14111, 14102, 14106, 14107, 14103, 14112, 14068, 14067, - 14065, 14099, 14066, 14100, 14119, 14121, 14118, 14117, 14114, 14113, - 14116, 14115, 14122, 14120, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 2892, 2858, 2917, 2918, 2888, 2925, 2936, 2907, 2924, 2919, - 2920, 2871, 2937, 2894, 2873, 2878, 2885, 2931, 2903, 2861, 2897, 2932, - 2893, 2868, 2869, 2901, 2875, 2916, 2857, 2915, 2884, 2908, 2939, 2856, - 2902, 2933, 2887, 2886, 2882, 2859, 2914, 2891, 2921, 2874, 2911, 2922, - 2938, 2866, 2928, 2935, 2876, 2862, 2890, 2864, 2883, 2926, 2867, 2941, - 2943, 2863, 2929, 2879, 2923, 2900, 2927, 2905, 2912, 2896, 2940, 2895, - 2877, 2909, 2880, 2906, 2934, 2930, 2913, 2898, 2870, 2904, 2860, 2899, - 2942, 2865, 2910, 2889, 2881, 2976, 2993, 2991, 2990, 2954, 2960, 2949, - 2997, 2959, 2951, 2984, 2996, 2953, 2980, 2981, 2944, 2986, 2994, 2988, - 2989, 2966, 2963, 2979, 2947, 2945, 2946, 2952, 2985, 3001, 2974, 2971, - 2998, 2987, 2995, 2965, 2969, 2970, 2967, 2992, 2962, 2968, 2978, 2983, - 2964, 2999, 2961, 3000, 2948, 2958, 2957, 2955, 2972, 2977, 2956, 2950, - 2975, 3053, 3073, 3095, 3091, 3052, 3041, 3054, 3002, 3030, 3004, 3074, - 3070, 3027, 3075, 3045, 3024, 3007, 3003, 3009, 3094, 3072, 3035, 3065, - 3033, 3096, 3014, 3015, 3079, 3046, 3084, 3061, 3088, 3083, 3048, 3090, - 3039, 3021, 3071, 3049, 3017, 3032, 3037, 3068, 3085, 3051, 3099, 3042, - 3067, 3064, 3098, 3089, 3029, 3100, 3057, 3016, 3087, 3062, 3059, 3011, - 3047, 3023, 3034, 3019, 3013, 3058, 3056, 3092, 3050, 3066, 3069, 3012, - 3063, 3043, 3020, 3097, 3044, 3081, 3078, 3031, 3022, 3026, 3008, 3028, - 3010, 3025, 3093, 3060, 3038, 3036, 3082, 3006, 3005, 3055, 3040, 3018, - 3076, 3077, 3086, 3128, 3212, 3161, 3135, 3162, 3121, 3160, 3166, 3148, - 3175, 3211, 3157, 3191, 3158, 3105, 3204, 3189, 3164, 3196, 3109, 3213, - 3111, 3198, 3133, 3143, 3124, 3130, 3200, 3217, 3159, 3106, 3154, 3206, - 3104, 3156, 3101, 3144, 3138, 3116, 3145, 3140, 3139, 3181, 3137, 3134, - 3122, 3167, 3126, 3114, 3173, 3202, 3201, 3214, 3107, 3188, 3205, 3153, - 3132, 3168, 3108, 3184, 3179, 3174, 3119, 3147, 3136, 3151, 3215, 3183, - 3216, 3146, 3170, 3195, 3112, 3150, 3155, 3207, 3129, 3113, 3169, 3203, - 3125, 3149, 3117, 3152, 3165, 3163, 3103, 3110, 3185, 3209, 3208, 3176, - 3187, 3118, 3131, 3123, 3197, 3142, 3193, 3190, 3115, 3178, 3194, 3171, - 3180, 3177, 3192, 3182, 3141, 3120, 3186, 3210, 3172, 3127, 3199, 3102, - 3271, 3349, 3258, 3245, 3356, 3248, 3312, 3338, 3328, 3298, 3274, 3323, - 3343, 3284, 3238, 3359, 3331, 3276, 3313, 3348, 3240, 3250, 3300, 3290, - 3255, 3287, 3291, 3299, 3330, 3297, 3316, 3339, 3279, 3262, 3232, 3286, - 3294, 3256, 3249, 3277, 3273, 3340, 3332, 3326, 3270, 3278, 3364, 3231, - 3353, 3360, 3320, 3352, 3235, 3337, 3346, 3354, 3357, 3244, 3322, 3342, - 3229, 3292, 3333, 3261, 3259, 3305, 3309, 3228, 3351, 3239, 3372, 3303, - 3365, 3260, 3272, 3318, 3368, 3247, 3221, 3227, 3289, 3237, 3254, 3285, - 3233, 3223, 3301, 3314, 3362, 3275, 3304, 3306, 3321, 3264, 3222, 3308, - 3265, 3230, 3220, 3268, 3324, 3288, 3241, 3319, 3302, 3361, 3280, 3310, - 3219, 3226, 3295, 3373, 3350, 3375, 3374, 3246, 3311, 3341, 3344, 3269, - 3336, 3363, 3282, 3369, 3366, 3367, 3371, 3370, 3236, 3315, 3296, 3325, - 3358, 3225, 3355, 3252, 3263, 3329, 3327, 3283, 3293, 3334, 3335, 3218, - 3307, 3317, 3251, 3243, 3266, 3253, 3257, 3345, 3242, 3267, 3347, 3224, - 3234, 3380, 3429, 3382, 3427, 3407, 3420, 3401, 3384, 3410, 3409, 3389, - 3419, 3399, 3395, 3386, 3417, 3412, 3418, 3415, 3378, 3377, 3397, 3396, - 3394, 3422, 3414, 3423, 3398, 3403, 3400, 3424, 3404, 3411, 3402, 3406, - 3376, 3392, 3393, 3413, 3405, 3428, 3425, 3385, 3383, 3381, 3387, 3408, - 3390, 3391, 3388, 3421, 3379, 3416, 3426, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 22919, 22911, 22932, 22909, 22933, 22920, 22935, - 22915, 22906, 22923, 22921, 22929, 22905, 22913, 22908, 22910, 22916, - 22914, 22912, 22925, 22926, 22917, 22931, 22934, 22930, 22907, 22928, - 22927, 22922, 22924, 22918, 35536, 22944, 22946, 22943, 22942, 22939, - 22938, 22941, 22940, 22947, 22945, 35536, 35536, 35536, 35536, 22937, - 22936, 30246, 30243, 30244, 30245, 30198, 30195, 30196, 30197, 30250, - 30247, 30248, 30249, 30238, 30235, 30236, 30237, 30242, 30239, 30240, - 30241, 30234, 30231, 30232, 30233, 30194, 30191, 30192, 30193, 30226, - 30223, 30224, 30225, 30199, 30204, 30215, 30216, 30227, 30230, 30228, - 30229, 30222, 30219, 30220, 30221, 30210, 30207, 30208, 30209, 30261, - 30260, 30259, 30211, 30218, 30268, 30266, 30263, 30213, 30262, 30264, - 30206, 30214, 30203, 30205, 30202, 30253, 30257, 30265, 30212, 30217, - 30255, 30252, 30258, 30201, 30251, 30267, 30200, 30256, 30254, 30269, - 35536, 30276, 30278, 30275, 30274, 30271, 30270, 30273, 30272, 30279, - 30277, 35536, 35536, 35536, 35536, 35536, 35536, 3490, 3495, 3511, 3513, - 3503, 3501, 3493, 3487, 3494, 3507, 3502, 3498, 3509, 3492, 3488, 3510, - 3497, 3508, 3512, 3506, 3500, 3514, 3499, 3515, 3504, 3505, 3496, 3491, - 3489, 3516, 35536, 35536, 3483, 3485, 3486, 3484, 3482, 3517, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 25301, - 25302, 25307, 25308, 25295, 25296, 25311, 25312, 25303, 25304, 25293, - 25294, 25313, 25314, 25297, 25298, 25309, 25310, 25315, 25316, 25305, - 25306, 25299, 25300, 25317, 25318, 25291, 25292, 25237, 25228, 25234, - 25225, 25230, 25236, 25229, 25233, 25239, 25223, 25235, 25221, 25226, - 25224, 25232, 25227, 25231, 25240, 25238, 25222, 25245, 25244, 25242, - 25241, 25243, 25247, 25246, 25277, 25278, 25256, 25276, 25274, 25282, - 25284, 25283, 25285, 25275, 25267, 25280, 25265, 25287, 25260, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 25325, - 25327, 25324, 25323, 25320, 25319, 25322, 25321, 25328, 25326, 35536, - 25252, 25249, 25251, 25254, 25248, 25250, 25253, 35536, 25279, 25286, - 25264, 25272, 25288, 25263, 25270, 25281, 25269, 25290, 25271, 25266, - 25273, 25289, 25268, 25262, 25255, 25258, 25259, 25261, 25257, 35536, - 35536, 35536, 35536, 35536, 25209, 25216, 25208, 25207, 25217, 25205, - 25202, 25220, 25212, 25210, 25218, 25204, 25203, 25213, 25219, 25215, - 25211, 25206, 25214, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 17208, - 17205, 17210, 17204, 17193, 17192, 17189, 17188, 17181, 17187, 17186, - 17191, 17190, 17182, 17178, 17177, 17174, 17173, 17180, 17179, 17176, - 17175, 17183, 17195, 17194, 17185, 17184, 17200, 17203, 17201, 17199, - 17202, 17197, 17196, 17198, 17211, 17217, 17214, 17215, 17216, 17212, - 17218, 17213, 17209, 17207, 17206, 17220, 17219, 17227, 17229, 17226, - 17225, 17222, 17221, 17224, 17223, 17230, 17228, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 21582, 21586, 21589, 21590, 21560, - 21592, 21568, 21583, 21587, 21578, 21577, 21579, 21567, 21559, 21580, - 21576, 21573, 21574, 21588, 21570, 21581, 21584, 21566, 21564, 21591, - 21575, 21572, 21562, 21585, 21571, 21561, 21569, 21640, 21644, 21647, - 21648, 21618, 21650, 21626, 21641, 21645, 21636, 21635, 21637, 21625, - 21617, 21638, 21634, 21631, 21632, 21646, 21628, 21639, 21642, 21624, - 21622, 21649, 21633, 21630, 21620, 21643, 21629, 21619, 21627, 21604, - 21598, 21596, 21594, 21601, 21600, 21603, 21602, 21606, 21605, 21609, - 21611, 21608, 21607, 21612, 21613, 21615, 21616, 21610, 21614, 21599, - 21597, 21595, 21593, 21653, 21651, 21652, 35536, 35536, 35536, 35536, - 35536, 3702, 3719, 3704, 3708, 3721, 3709, 3716, 3726, 3705, 3717, 3722, - 3715, 3711, 3710, 3712, 3723, 3724, 3706, 3707, 3714, 3713, 3718, 3725, - 3720, 3703, 35536, 35536, 3727, 3744, 3729, 3733, 3746, 3734, 3741, 3751, - 3730, 3742, 3747, 3740, 3736, 3735, 3737, 3748, 3749, 3731, 3732, 3739, - 3738, 3743, 3750, 3745, 3728, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 22201, 22127, - 22189, 22200, 22205, 22204, 22124, 22206, 22181, 22180, 22178, 22135, - 22184, 22185, 22177, 22134, 22143, 22151, 22187, 22123, 22148, 22147, - 22142, 22141, 22140, 22139, 22165, 22133, 22164, 22132, 22207, 22138, - 22188, 22199, 22198, 22146, 22145, 22122, 22203, 22209, 22137, 22136, - 22174, 22130, 22150, 22149, 22173, 22129, 22182, 22186, 22158, 22161, - 22162, 22196, 22194, 22175, 22131, 22183, 22163, 22197, 22195, 22193, - 22191, 22121, 22192, 22190, 22208, 22125, 22202, 22126, 22160, 22128, - 22179, 22176, 22159, 35536, 35536, 35536, 35536, 22213, 22144, 22212, - 22211, 22210, 22218, 22224, 22223, 22219, 22220, 22245, 22249, 22266, - 22265, 22227, 22230, 22231, 22247, 22234, 22235, 22236, 22237, 22238, - 22241, 22243, 22244, 22240, 22251, 22252, 22253, 22254, 22259, 22255, - 22256, 22260, 22262, 22221, 22222, 22229, 22264, 22228, 22263, 22225, - 22233, 22226, 22250, 22267, 22268, 22257, 22261, 22248, 22246, 22269, - 22242, 22232, 22239, 22258, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 22217, 22215, 22216, 22214, 22166, 22167, 22168, 22169, 22170, - 22171, 22172, 22152, 22153, 22154, 22155, 22156, 22157, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 31163, 24157, 24377, 24376, 17172, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 33457, 33456, - 6583, 6584, 33978, 33979, 33980, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 30280, 30281, 30282, 30283, 30284, 30285, - 30286, 30287, 30288, 30289, 30290, 30291, 30292, 30293, 30294, 30295, - 30296, 30297, 30298, 30299, 30300, 30301, 30302, 30303, 30304, 30305, - 30306, 30307, 30308, 30309, 30310, 30311, 30312, 30313, 30314, 30315, - 30316, 30317, 30318, 30319, 30320, 30321, 30322, 30323, 30324, 30325, - 30326, 30327, 30328, 30329, 30330, 30331, 30332, 30333, 30334, 30335, - 30336, 30337, 30338, 30339, 30340, 30341, 30342, 30343, 30344, 30345, - 30346, 30347, 30348, 30349, 30350, 30351, 30352, 30353, 30354, 30355, - 30356, 30357, 30358, 30359, 30360, 30361, 30362, 30363, 30364, 30365, - 30366, 30367, 30368, 30369, 30370, 30371, 30372, 30373, 30374, 30375, - 30376, 30377, 30378, 30379, 30380, 30381, 30382, 30383, 30384, 30385, - 30386, 30387, 30388, 30389, 30390, 30391, 30392, 30393, 30394, 30395, - 30396, 30397, 30398, 30399, 30400, 30401, 30402, 30403, 30404, 30405, - 30406, 30407, 30408, 30409, 30410, 30411, 30412, 30413, 30414, 30415, - 30416, 30417, 30418, 30419, 30420, 30421, 30422, 30423, 30424, 30425, - 30426, 30427, 30428, 30429, 30430, 30431, 30432, 30433, 30434, 30435, - 30436, 30437, 30438, 30439, 30440, 30441, 30442, 30443, 30444, 30445, - 30446, 30447, 30448, 30449, 30450, 30451, 30452, 30453, 30454, 30455, - 30456, 30457, 30458, 30459, 30460, 30461, 30462, 30463, 30464, 30465, - 30466, 30467, 30468, 30469, 30470, 30471, 30472, 30473, 30474, 30475, - 30476, 30477, 30478, 30479, 30480, 30481, 30482, 30483, 30484, 30485, - 30486, 30487, 30488, 30489, 30490, 30491, 30492, 30493, 30494, 30495, - 30496, 30497, 30498, 30499, 30500, 30501, 30502, 30503, 30504, 30505, - 30506, 30507, 30508, 30509, 30510, 30511, 30512, 30513, 30514, 30515, - 30516, 30517, 30518, 30519, 30520, 30521, 30522, 30523, 30524, 30525, - 30526, 30527, 30528, 30529, 30530, 30531, 30532, 30533, 30534, 30535, - 30536, 30537, 30538, 30539, 30540, 30541, 30542, 30543, 30544, 30545, - 30546, 30547, 30548, 30549, 30550, 30551, 30552, 30553, 30554, 30555, - 30556, 30557, 30558, 30559, 30560, 30561, 30562, 30563, 30564, 30565, - 30566, 30567, 30568, 30569, 30570, 30571, 30572, 30573, 30574, 30575, - 30576, 30577, 30578, 30579, 30580, 30581, 30582, 30583, 30584, 30585, - 30586, 30587, 30588, 30589, 30590, 30591, 30592, 30593, 30594, 30595, - 30596, 30597, 30598, 30599, 30600, 30601, 30602, 30603, 30604, 30605, - 30606, 30607, 30608, 30609, 30610, 30611, 30612, 30613, 30614, 30615, - 30616, 30617, 30618, 30619, 30620, 30621, 30622, 30623, 30624, 30625, - 30626, 30627, 30628, 30629, 30630, 30631, 30632, 30633, 30634, 30635, - 30636, 30637, 30638, 30639, 30640, 30641, 30642, 30643, 30644, 30645, - 30646, 30647, 30648, 30649, 30650, 30651, 30652, 30653, 30654, 30655, - 30656, 30657, 30658, 30659, 30660, 30661, 30662, 30663, 30664, 30665, - 30666, 30667, 30668, 30669, 30670, 30671, 30672, 30673, 30674, 30675, - 30676, 30677, 30678, 30679, 30680, 30681, 30682, 30683, 30684, 30685, - 30686, 30687, 30688, 30689, 30690, 30691, 30692, 30693, 30694, 30695, - 30696, 30697, 30698, 30699, 30700, 30701, 30702, 30703, 30704, 30705, - 30706, 30707, 30708, 30709, 30710, 30711, 30712, 30713, 30714, 30715, - 30716, 30717, 30718, 30719, 30720, 30721, 30722, 30723, 30724, 30725, - 30726, 30727, 30728, 30729, 30730, 30731, 30732, 30733, 30734, 30735, - 30736, 30737, 30738, 30739, 30740, 30741, 30742, 30743, 30744, 30745, - 30746, 30747, 30748, 30749, 30750, 30751, 30752, 30753, 30754, 30755, - 30756, 30757, 30758, 30759, 30760, 30761, 30762, 30763, 30764, 30765, - 30766, 30767, 30768, 30769, 30770, 30771, 30772, 30773, 30774, 30775, - 30776, 30777, 30778, 30779, 30780, 30781, 30782, 30783, 30784, 30785, - 30786, 30787, 30788, 30789, 30790, 30791, 30792, 30793, 30794, 30795, - 30796, 30797, 30798, 30799, 30800, 30801, 30802, 30803, 30804, 30805, - 30806, 30807, 30808, 30809, 30810, 30811, 30812, 30813, 30814, 30815, - 30816, 30817, 30818, 30819, 30820, 30821, 30822, 30823, 30824, 30825, - 30826, 30827, 30828, 30829, 30830, 30831, 30832, 30833, 30834, 30835, - 30836, 30837, 30838, 30839, 30840, 30841, 30842, 30843, 30844, 30845, - 30846, 30847, 30848, 30849, 30850, 30851, 30852, 30853, 30854, 30855, - 30856, 30857, 30858, 30859, 30860, 30861, 30862, 30863, 30864, 30865, - 30866, 30867, 30868, 30869, 30870, 30871, 30872, 30873, 30874, 30875, - 30876, 30877, 30878, 30879, 30880, 30881, 30882, 30883, 30884, 30885, - 30886, 30887, 30888, 30889, 30890, 30891, 30892, 30893, 30894, 30895, - 30896, 30897, 30898, 30899, 30900, 30901, 30902, 30903, 30904, 30905, - 30906, 30907, 30908, 30909, 30910, 30911, 30912, 30913, 30914, 30915, - 30916, 30917, 30918, 30919, 30920, 30921, 30922, 30923, 30924, 30925, - 30926, 30927, 30928, 30929, 30930, 30931, 30932, 30933, 30934, 30935, - 30936, 30937, 30938, 30939, 30940, 30941, 30942, 30943, 30944, 30945, - 30946, 30947, 30948, 30949, 30950, 30951, 30952, 30953, 30954, 30955, - 30956, 30957, 30958, 30959, 30960, 30961, 30962, 30963, 30964, 30965, - 30966, 30967, 30968, 30969, 30970, 30971, 30972, 30973, 30974, 30975, - 30976, 30977, 30978, 30979, 30980, 30981, 30982, 30983, 30984, 30985, - 30986, 30987, 30988, 30989, 30990, 30991, 30992, 30993, 30994, 30995, - 30996, 30997, 30998, 30999, 31000, 31001, 31002, 31003, 31004, 31005, - 31006, 31007, 31008, 31009, 31010, 31011, 31012, 31013, 31014, 31015, - 31016, 31017, 31018, 31019, 31020, 31021, 31022, 31023, 31024, 31025, - 31026, 31027, 31028, 31029, 31030, 31031, 31032, 31033, 31034, 31035, - 31036, 31037, 31038, 31039, 31040, 31041, 31042, 31043, 31044, 31045, - 31046, 31047, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 31048, 31049, 31050, 31051, 31052, 31053, 31054, 31055, 31056, 31057, - 31058, 31059, 31060, 31061, 31062, 31063, 31064, 31065, 31066, 31067, - 31068, 31069, 31070, 31071, 31072, 31073, 31074, 31075, 31076, 31077, - 31078, 31079, 31080, 31081, 31082, 31083, 31084, 31085, 31086, 31087, - 31088, 31089, 31090, 31091, 31092, 31093, 31094, 31095, 31096, 31097, - 31098, 31099, 31100, 31101, 31102, 31103, 31104, 31105, 31106, 31107, - 31108, 31109, 31110, 31111, 31112, 31113, 31114, 31115, 31116, 31117, - 31118, 31119, 31120, 31121, 31122, 31123, 31124, 31125, 31126, 31127, - 31128, 31129, 31130, 31131, 31132, 31133, 31134, 31135, 31136, 31137, - 31138, 31139, 31140, 31141, 31142, 31143, 31144, 31145, 31146, 31147, - 31148, 31149, 31150, 31151, 31152, 31153, 31154, 31155, 31156, 31157, - 31158, 31159, 31160, 31161, 31162, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 16490, 16491, - 16492, 16493, 35536, 16494, 16495, 16483, 16484, 16485, 16486, 16487, - 35536, 16488, 16489, 35536, 16471, 15443, 15082, 15083, 15084, 15081, - 15363, 15364, 15365, 15366, 15355, 15356, 15357, 15358, 15359, 15350, - 15351, 15352, 15353, 15354, 15360, 15361, 15362, 15121, 15125, 15126, - 15127, 15128, 15129, 15130, 15131, 15132, 15122, 15123, 15124, 15137, - 15138, 15139, 15140, 15141, 15142, 15143, 15144, 15151, 15152, 15153, - 15154, 15155, 15156, 15157, 15145, 15146, 15147, 15148, 15149, 15150, - 15134, 15135, 15136, 15133, 15246, 15247, 15248, 15249, 15250, 15251, - 15252, 15253, 15262, 15263, 15264, 15265, 15266, 15267, 15254, 15255, - 15256, 15257, 15258, 15259, 15260, 15261, 15268, 15269, 15270, 15271, - 15272, 15273, 15274, 15275, 15276, 15277, 15278, 15279, 15308, 15309, - 15310, 15311, 15301, 15302, 15303, 15304, 15305, 15306, 15307, 15297, - 15298, 15299, 15300, 15296, 15280, 15281, 15282, 15283, 15284, 15285, - 15286, 15287, 15288, 15290, 15291, 15292, 15293, 15294, 15295, 15289, - 15200, 15201, 15202, 15203, 15204, 15205, 15206, 15207, 15208, 15193, - 15194, 15195, 15196, 15197, 15198, 15199, 15192, 15214, 15215, 15216, - 15186, 15187, 15188, 15189, 15190, 15191, 15185, 15209, 15210, 15211, - 15212, 15213, 15093, 15096, 15097, 15098, 15099, 15100, 15101, 15102, - 15103, 15094, 15095, 15114, 15115, 15116, 15117, 15118, 15119, 15120, - 15104, 15105, 15106, 15107, 15108, 15109, 15110, 15111, 15112, 15113, - 15085, 15086, 15087, 15088, 15089, 15090, 15091, 15092, 15167, 15168, - 15169, 15170, 15171, 15172, 15173, 15174, 15175, 15176, 15177, 15178, - 15179, 15180, 15181, 15182, 15183, 15184, 15159, 15160, 15158, 15161, - 15162, 15163, 15164, 15165, 15166, 15334, 15335, 15336, 15337, 15338, - 15333, 15345, 15346, 15347, 15348, 15339, 15340, 15341, 15342, 15343, - 15344, 15238, 15239, 15240, 15241, 15231, 15232, 15233, 15234, 15235, - 15236, 15237, 15225, 15226, 15227, 15228, 15229, 15230, 15242, 15243, - 15244, 15245, 15219, 15220, 15221, 15222, 15223, 15224, 15312, 15313, - 15314, 15315, 15316, 15317, 15318, 15319, 15320, 15321, 15329, 15330, - 15331, 15332, 15322, 15323, 15324, 15325, 15326, 15327, 15328, 15217, - 15218, 15442, 16469, 16468, 16470, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 15453, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 15446, 15445, 15447, 35536, 35536, 16518, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 16524, 16523, 16525, 16529, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 10635, 10633, 10582, 10615, - 10542, 10555, 10559, 10640, 10536, 10623, 10544, 10586, 10585, 10537, - 10543, 10557, 10589, 10618, 10611, 10538, 10558, 10612, 10636, 10562, - 10590, 10563, 10568, 10546, 10591, 10564, 10569, 10549, 10592, 10566, - 10571, 10547, 10548, 10600, 10601, 10567, 10572, 10553, 10604, 10565, - 10570, 10550, 10593, 10554, 10551, 10552, 10598, 10599, 10596, 10597, - 10617, 10616, 10625, 10631, 10628, 10603, 10602, 10556, 10545, 10594, - 10595, 10534, 10609, 10579, 10577, 10535, 10637, 10539, 10638, 10614, - 10622, 10540, 10606, 10587, 10605, 10560, 10639, 10619, 10541, 10634, - 10620, 10561, 10588, 10621, 10613, 10578, 10581, 10580, 10630, 10626, - 10632, 10629, 10627, 10576, 10575, 10574, 10573, 10584, 10583, 10607, - 10610, 10608, 10624, 35536, 35536, 35536, 35536, 35536, 10519, 10532, - 10531, 10526, 10533, 10513, 10506, 10505, 10502, 10504, 10507, 10508, - 10503, 35536, 35536, 35536, 10515, 10511, 10514, 10509, 10518, 10517, - 10510, 10516, 10512, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 10520, 10524, 10527, 10522, 10530, 10529, 10523, 10528, 10525, 10521, - 35536, 35536, 10644, 10641, 10642, 10643, 27160, 27159, 27161, 27162, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 32371, 26351, 18859, 26348, 10409, 19867, 26319, 19925, - 967, 15578, 33426, 18817, 22276, 26304, 18852, 26341, 24231, 25897, - 26089, 15574, 33400, 19807, 19806, 19805, 19804, 19802, 19803, 4587, - 4588, 4596, 4610, 4480, 4479, 26890, 26898, 26891, 26902, 26895, 26899, - 26892, 26904, 26897, 26901, 26894, 26903, 26896, 26900, 26893, 32410, - 32378, 32380, 32465, 32427, 32423, 32459, 32429, 19951, 19898, 19918, - 19953, 19901, 19943, 19945, 19924, 28433, 28434, 24959, 9958, 9694, 9693, - 28445, 28446, 18865, 26328, 12612, 12613, 352, 351, 358, 357, 360, 359, - 355, 356, 353, 354, 18855, 32363, 26344, 10415, 32037, 32033, 32041, - 4442, 4440, 4446, 18848, 32358, 26338, 10411, 23000, 18858, 32366, 26347, - 10418, 11778, 11779, 3944, 3947, 3946, 3945, 3978, 18871, 32356, 26334, - 10421, 18872, 32357, 26335, 10422, 18861, 32360, 26350, 10413, 28678, - 28679, 28677, 28676, 28870, 28872, 28871, 28869, 33410, 15557, 33823, - 33824, 32283, 28510, 28509, 28508, 28463, 15953, 18731, 15954, 33415, - 15555, 18866, 26329, 18867, 26330, 12597, 18857, 32365, 26346, 10417, - 15577, 33425, 33403, 18860, 26349, 18854, 26343, 18856, 26345, 18765, - 26262, 32419, 32455, 32418, 32454, 19887, 19907, 19886, 19906, 19884, - 19904, 19885, 19905, 32422, 32458, 19897, 19917, 32420, 32456, 19896, - 19916, 32413, 32449, 19891, 19911, 32416, 32452, 19894, 19914, 32417, - 32453, 19895, 19915, 32412, 32448, 19890, 19910, 32414, 32450, 19892, - 19912, 32415, 32451, 19893, 19913, 32421, 32457, 19888, 19908, 25137, - 25138, 25139, 25140, 25141, 25142, 25143, 25144, 25145, 25146, 25147, - 25148, 25149, 25150, 25151, 25152, 25153, 25154, 25155, 25156, 25157, - 25158, 25159, 25160, 25161, 25162, 25173, 25175, 25172, 25171, 25168, - 25167, 25170, 25169, 25176, 25174, 28214, 12614, 24141, 35536, 35536, - 35536, 4239, 4183, 4054, 4269, 4140, 4081, 4240, 4121, 4184, 4230, 4156, - 4215, 4097, 4112, 4200, 4066, 4273, 4141, 4171, 4082, 4241, 4122, 4185, - 4055, 4236, 4164, 4223, 4105, 4262, 4118, 4208, 4074, 4149, 4177, 4090, - 4248, 4130, 4193, 4060, 4231, 4157, 4216, 4098, 4255, 4113, 4201, 4067, - 4274, 4142, 4172, 4083, 4242, 4123, 4186, 4168, 4227, 4109, 4266, 4137, - 4212, 4078, 4281, 4153, 4180, 4094, 4252, 4134, 4197, 4063, 4161, 4220, - 4102, 4259, 4205, 4071, 4278, 4146, 4087, 4245, 4127, 4190, 4237, 4165, - 4224, 4106, 4263, 4119, 4209, 4075, 4270, 4150, 4178, 4091, 4249, 4131, - 4194, 4061, 4232, 4158, 4217, 4099, 4256, 4114, 4202, 4068, 4275, 4143, - 4173, 4084, 4243, 4124, 4187, 4056, 4170, 4229, 4111, 4268, 4139, 4214, - 4080, 4283, 4155, 4182, 4096, 4254, 4136, 4199, 4065, 4235, 4163, 4222, - 4104, 4261, 4117, 4207, 4073, 4280, 4148, 4176, 4089, 4247, 4129, 4192, - 4059, 4167, 4226, 4108, 4265, 4211, 4077, 4272, 4152, 4093, 4251, 4133, - 4196, 4233, 4160, 4219, 4101, 4258, 4115, 4204, 4070, 4277, 4145, 4174, - 4086, 4244, 4126, 4189, 4057, 4169, 4228, 4110, 4267, 4138, 4213, 4079, - 4282, 4154, 4181, 4095, 4253, 4135, 4198, 4064, 4234, 4162, 4221, 4103, - 4260, 4116, 4206, 4072, 4279, 4147, 4175, 4088, 4246, 4128, 4191, 4058, - 4238, 4166, 4225, 4107, 4264, 4120, 4210, 4076, 4271, 4151, 4179, 4092, - 4250, 4132, 4195, 4062, 4159, 4218, 4100, 4257, 4203, 4069, 4276, 4144, - 4085, 4125, 4188, 32045, 4449, 32042, 4447, 32043, 4448, 32038, 4443, - 32039, 4444, 32032, 4436, 4437, 4438, 4439, 22884, 32034, 32035, 10412, - 18849, 28184, 32361, 10414, 12483, 12484, 12485, 26257, 19858, 12486, - 32385, 19860, 14933, 33885, 32056, 12770, 4481, 4478, 18769, 26266, - 18768, 26265, 15554, 18766, 26263, 15553, 19861, 32388, 33416, 4606, - 4604, 4605, 4603, 17403, 17402, 17407, 17401, 17379, 17358, 17359, 17399, - 17365, 17383, 17406, 17381, 17404, 17405, 17387, 17384, 17364, 17363, - 17366, 17382, 17367, 17355, 17376, 17400, 17356, 17357, 17354, 17380, - 17385, 17371, 17362, 17386, 17388, 17361, 17378, 17370, 17368, 17369, - 17360, 17408, 17377, 17372, 17375, 17373, 17374, 17396, 17394, 17395, - 17398, 17393, 17390, 17397, 17392, 17391, 17389, 26905, 26937, 26906, - 26953, 26922, 26938, 26907, 26961, 26930, 26946, 26915, 26954, 26923, - 26939, 26908, 26965, 26934, 26950, 26919, 26958, 26927, 26943, 26912, - 26962, 26931, 26947, 26916, 26955, 26924, 26940, 26909, 26967, 26936, - 26952, 26921, 26960, 26929, 26945, 26914, 26964, 26933, 26949, 26918, - 26957, 26926, 26942, 26911, 26966, 26935, 26951, 26920, 26959, 26928, - 26944, 26913, 26963, 26932, 26948, 26917, 26956, 26925, 26941, 26910, - 32405, 32377, 32379, 32444, 32426, 32424, 32425, 32428, 19950, 19948, - 19949, 19952, 19903, 19942, 19944, 19938, 26267, 26307, 18820, 18770, - 19863, 19958, 32468, 32390, 18771, 18821, 26308, 26268, 32391, 32469, - 19959, 19864, 15579, 16781, 24646, 3984, 35536, 35536, 35536, 35536, - 35536, 35536, 12650, 25186, 32117, 1057, 6577, 28866, 15076, 15975, - 12602, 22119, 25522, 33452, 11772, 15974, 12478, 26026, 31511, 21764, - 12628, 2574, 3597, 369, 19085, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 12869, - 12866, 12858, 12864, 12870, 12856, 12862, 12859, 12865, 12861, 12857, - 12867, 12863, 12868, 12860, 12871, 21676, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35352, 35357, 35391, 35354, 35359, 35387, 35381, 35375, 35398, - 35377, 35371, 35395, 35353, 35358, 35392, 35355, 35360, 35388, 35382, - 35376, 35399, 35378, 35372, 35396, 35393, 35379, 35386, 35373, 35374, - 35397, 35380, 35356, 35402, 35367, 35384, 35394, 35405, 35404, 35370, - 35403, 35364, 35363, 35401, 35385, 35383, 35362, 35536, 35536, 35407, - 35408, 35409, 35400, 35350, 35365, 35368, 35369, 35347, 35348, 35366, - 35389, 35390, 35351, 35406, 35349, 35361, 35346, 35528, 35529, 35526, - 35527, 35530, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35426, 35427, 35443, 35415, 35424, 35523, 35478, 35479, 35446, - 35447, 35480, 35410, 35444, 35524, 35422, 35419, 35421, 35420, 35418, - 35520, 35519, 35522, 35521, 35516, 35515, 35518, 35517, 35416, 35450, - 35412, 35423, 35411, 35448, 35461, 35462, 35460, 35459, 35413, 35457, - 35458, 35456, 35454, 35455, 35453, 35452, 35463, 35465, 35466, 35464, - 35428, 35451, 35417, 35425, 35525, 35467, 35472, 35469, 35473, 35470, - 35475, 35476, 35471, 35468, 35474, 35449, 35477, 35510, 35507, 35498, - 35508, 35509, 35499, 35487, 35486, 35514, 35484, 35483, 35481, 35485, - 35482, 35501, 35506, 35500, 35504, 35505, 35502, 35503, 35430, 35434, - 35433, 35432, 35431, 35513, 35511, 35512, 35437, 35442, 35441, 35440, - 35439, 35438, 35488, 35497, 35490, 35495, 35489, 35493, 35494, 35491, - 35492, 35496, 35429, 35436, 35414, 35435, 35445, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 5296, 5168, 5289, 5271, - 5272, 5340, 5341, 5221, 5318, 5278, 5352, 5353, 5244, 5123, 5174, 5321, - 5222, 5126, 5127, 5316, 5328, 5267, 5204, 5295, 5147, 5344, 5216, 5230, - 5226, 5319, 5281, 5310, 5274, 5343, 5129, 5131, 5231, 5297, 5282, 5339, - 5121, 5299, 5313, 5315, 5269, 5323, 5251, 5169, 5331, 5322, 5241, 5122, - 5181, 5212, 5333, 5219, 5287, 5291, 5234, 5145, 5298, 5276, 5279, 5218, - 5356, 5286, 5235, 5334, 5311, 5210, 5217, 5268, 5273, 5285, 5237, 5284, - 5242, 5288, 5225, 5229, 5355, 5128, 5124, 5354, 5243, 5177, 5148, 5266, - 5342, 5283, 5292, 5275, 5120, 5252, 5280, 5277, 5173, 5245, 5119, 5335, - 5176, 5314, 5317, 5146, 5175, 5300, 5357, 5337, 5293, 5332, 5336, 5290, - 5338, 5294, 5207, 5133, 5172, 5270, 5325, 5326, 5324, 5327, 5220, 5170, - 5345, 5346, 5309, 5233, 5166, 5238, 5239, 5240, 5130, 5132, 5165, 5330, - 5320, 5236, 5246, 5250, 5249, 5248, 5247, 5206, 5203, 5202, 5160, 5162, - 5163, 5161, 5329, 5134, 5214, 5153, 5117, 5111, 5112, 5115, 5116, 5114, - 5113, 5118, 5259, 5254, 5255, 5253, 5264, 5263, 5262, 5261, 5265, 5257, - 5215, 5125, 5180, 5179, 5178, 5260, 5258, 5256, 5208, 5209, 5171, 5213, - 5211, 5182, 5189, 5185, 5193, 5188, 5197, 5187, 5186, 5183, 5184, 5191, - 5192, 5199, 5196, 5194, 5143, 5144, 5142, 5190, 5198, 5351, 5156, 5154, - 5157, 5159, 5158, 5155, 5347, 5349, 5348, 5350, 5200, 5201, 5150, 5149, - 5151, 5152, 5305, 5308, 5306, 5307, 5301, 5304, 5302, 5303, 5164, 5167, - 5312, 5141, 5135, 5140, 5138, 5137, 5136, 5139, 5223, 5227, 5224, 5228, - 5232, 5205, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 23189, 23066, 23082, 23174, 23061, 23186, 23124, 23175, - 23173, 23062, 23058, 23185, 23052, 23170, 23171, 23172, 23077, 23078, - 23015, 23016, 23011, 23010, 23141, 23212, 23209, 23084, 23083, 23190, - 23191, 23085, 23094, 23095, 23096, 23055, 23087, 23088, 23089, 23068, - 23069, 35536, 35536, 23132, 23065, 23067, 23093, 23092, 23137, 23136, - 23188, 23187, 23164, 23165, 23051, 23057, 23153, 23154, 23168, 23169, - 23133, 23235, 23107, 23167, 23076, 23193, 23211, 23195, 23140, 23233, - 23156, 23056, 23196, 23197, 23220, 23221, 23224, 23225, 23222, 23223, - 23216, 23217, 23218, 23219, 23130, 23131, 23226, 23227, 23155, 23231, - 23138, 23135, 23019, 23020, 23014, 23234, 23106, 23166, 23075, 23192, - 23210, 23194, 23139, 23040, 23041, 23044, 23045, 23046, 23079, 23080, - 23081, 23023, 23030, 23031, 23032, 23033, 23034, 23008, 23073, 23009, - 23074, 23007, 23071, 23006, 23070, 23021, 23039, 23047, 23038, 23024, - 23025, 23022, 23049, 23104, 23103, 23028, 23050, 23035, 23042, 23048, - 23027, 23043, 23176, 23199, 23238, 23163, 23126, 23086, 23054, 23063, - 23100, 23099, 23215, 23228, 23237, 23229, 23230, 23142, 23145, 23146, - 23147, 23148, 23149, 23150, 23151, 23152, 23143, 23144, 23108, 23134, - 23072, 23064, 23026, 23029, 23036, 23037, 23158, 23157, 23105, 23098, - 23097, 23236, 23059, 23060, 23125, 23121, 23012, 23179, 23181, 23127, - 23129, 23182, 23184, 23090, 23091, 23123, 23122, 23013, 23180, 23128, - 23183, 23207, 23206, 23208, 23205, 23201, 23202, 23203, 23204, 23053, - 23101, 23102, 23198, 23232, 23160, 23018, 23177, 23017, 23213, 23161, - 23162, 23178, 23214, 23159, 23109, 23112, 23116, 23119, 23118, 23117, - 23113, 23114, 23110, 23111, 23115, 23200, 23120, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 13784, 13772, - 13795, 13796, 13778, 13797, 13798, 13799, 13800, 13785, 13786, 13787, - 13788, 13789, 13790, 13791, 13792, 13793, 13794, 13773, 13774, 13775, - 13776, 13777, 13779, 13780, 13781, 13782, 13783, 13504, 13512, 13525, - 13533, 13539, 13540, 13505, 13506, 13507, 13508, 13509, 13510, 13511, - 13513, 13514, 13515, 13516, 13517, 13518, 13519, 13520, 13521, 13522, - 13523, 13524, 13526, 13527, 13528, 13529, 13530, 13531, 13532, 13534, - 13535, 13536, 13537, 13538, 7373, 7372, 7374, 13564, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 16761, - 16762, 16759, 16757, 16748, 16747, 16754, 16752, 16743, 16750, 16760, - 16745, 16758, 16756, 16749, 16746, 16755, 16753, 16744, 16751, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 21540, 21541, 21538, 21536, 21527, 21526, 21533, 21531, 21522, - 21529, 21539, 21524, 21537, 21535, 21528, 21525, 21534, 21532, 21523, - 21530, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 22877, 10003, 10004, 9998, 9997, 9996, 31305, 31325, - 31346, 31294, 31339, 31303, 31289, 31348, 31293, 31307, 31313, 31336, - 31337, 31351, 31357, 31304, 31335, 31365, 31323, 31290, 31353, 31355, - 31322, 31368, 31302, 31317, 31314, 31295, 31309, 31292, 31350, 31343, - 31297, 31340, 31329, 31363, 31352, 31326, 31354, 31342, 31356, 31331, - 31319, 31362, 31332, 31318, 31349, 31358, 31328, 31364, 31301, 31345, - 31321, 31367, 31311, 31296, 31333, 31330, 31344, 31288, 31316, 31315, - 31366, 31360, 31338, 31308, 31306, 31312, 31320, 31359, 31361, 31334, - 31300, 31298, 31327, 31291, 31299, 31347, 31310, 31341, 31324, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 7787, 7785, 7784, - 7781, 7780, 7783, 7782, 7788, 7786, 7778, 7776, 7775, 7772, 7771, 7774, - 7773, 7779, 7777, 15666, 15665, 15664, 15663, 15662, 29774, 29773, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 20520, 20522, 20550, 20513, 20526, 20558, - 20529, 20559, 20531, 20560, 20533, 20535, 20552, 20554, 20537, 20540, - 20561, 20544, 20546, 20516, 20548, 20562, 20563, 20556, 20564, 20524, - 20568, 20570, 20603, 20565, 20574, 20577, 20579, 20611, 20581, 20612, - 20583, 20585, 20605, 20607, 20587, 20590, 20613, 20594, 20596, 20598, - 20601, 20614, 20615, 20609, 20616, 20572, 21008, 21010, 21040, 21014, - 21016, 21048, 21019, 21049, 21021, 21050, 21023, 21025, 21042, 21044, - 21027, 21030, 21051, 21034, 21036, 21004, 21038, 21052, 21053, 21046, - 21054, 21012, 20956, 20958, 20991, 20952, 20962, 20965, 20967, 35536, - 20969, 20999, 20971, 20973, 20993, 20995, 20975, 20978, 21000, 20982, - 20984, 20986, 20989, 21001, 21002, 20997, 21003, 20960, 20673, 20675, - 20705, 20679, 20681, 20713, 20684, 20714, 20686, 20715, 20688, 20690, - 20707, 20709, 20692, 20695, 20716, 20699, 20701, 20669, 20703, 20717, - 20718, 20711, 20719, 20677, 20727, 20729, 20764, 20733, 20735, 20738, - 20740, 20772, 20742, 20773, 20744, 20746, 20766, 20768, 20748, 20751, - 20774, 20755, 20757, 20759, 20762, 20775, 20776, 20770, 20777, 20731, - 21480, 35536, 21481, 21482, 35536, 35536, 21483, 35536, 35536, 21484, - 21485, 35536, 35536, 21486, 21487, 21488, 21489, 35536, 21490, 21491, - 21492, 21493, 21494, 21495, 21496, 21497, 21498, 21499, 21500, 21501, - 35536, 21502, 35536, 21503, 21504, 21505, 21506, 21507, 21508, 21509, - 35536, 21510, 21511, 21512, 21513, 21514, 21515, 21516, 21517, 21518, - 21519, 21520, 20617, 20618, 20619, 20620, 20621, 20622, 20623, 20624, - 20625, 20626, 20627, 20628, 20629, 20630, 20631, 20632, 20633, 20634, - 20635, 20636, 20637, 20638, 20639, 20640, 20641, 20642, 20643, 20644, - 20645, 20646, 20647, 20648, 20649, 20650, 20651, 20652, 20653, 20654, - 20655, 20656, 20657, 20658, 20659, 20660, 20661, 20662, 20663, 20664, - 20665, 20666, 20667, 20668, 20904, 20905, 35536, 20906, 20907, 20908, - 20909, 35536, 35536, 20910, 20911, 20912, 20913, 20914, 20915, 20916, - 20917, 35536, 20918, 20919, 20920, 20921, 20922, 20923, 20924, 35536, - 20925, 20926, 20927, 20928, 20929, 20930, 20931, 20932, 20933, 20934, - 20935, 20936, 20937, 20938, 20939, 20940, 20941, 20942, 20943, 20944, - 20945, 20946, 20947, 20948, 20949, 20950, 20849, 20850, 35536, 20851, - 20852, 20853, 20854, 35536, 20855, 20856, 20857, 20858, 20859, 35536, - 20860, 35536, 35536, 35536, 20861, 20862, 20863, 20864, 20865, 20866, - 20867, 35536, 20868, 20869, 20870, 20871, 20872, 20873, 20874, 20875, - 20876, 20877, 20878, 20879, 20880, 20881, 20882, 20883, 20884, 20885, - 20886, 20887, 20888, 20889, 20890, 20891, 20892, 20893, 20787, 20788, - 20789, 20790, 20791, 20792, 20793, 20794, 20795, 20796, 20797, 20798, - 20799, 20800, 20801, 20802, 20803, 20804, 20805, 20806, 20807, 20808, - 20809, 20810, 20811, 20812, 20813, 20814, 20815, 20816, 20817, 20818, - 20819, 20820, 20821, 20822, 20823, 20824, 20825, 20826, 20827, 20828, - 20829, 20830, 20831, 20832, 20833, 20834, 20835, 20836, 20837, 20838, - 21418, 21419, 21420, 21421, 21422, 21423, 21424, 21425, 21426, 21427, - 21428, 21429, 21430, 21431, 21432, 21433, 21434, 21435, 21436, 21437, - 21438, 21439, 21440, 21441, 21442, 21443, 21444, 21445, 21446, 21447, - 21448, 21449, 21450, 21451, 21452, 21453, 21454, 21455, 21456, 21457, - 21458, 21459, 21460, 21461, 21462, 21463, 21464, 21465, 21466, 21467, - 21468, 21469, 21250, 21252, 21282, 21256, 21258, 21290, 21261, 21291, - 21263, 21292, 21265, 21267, 21284, 21286, 21269, 21272, 21293, 21276, - 21278, 21246, 21280, 21294, 21295, 21288, 21296, 21254, 21304, 21306, - 21341, 21310, 21312, 21315, 21317, 21349, 21319, 21350, 21321, 21323, - 21343, 21345, 21325, 21328, 21351, 21332, 21334, 21336, 21339, 21352, - 21353, 21347, 21354, 21308, 21366, 21367, 21368, 21369, 21370, 21371, - 21372, 21373, 21374, 21375, 21376, 21377, 21378, 21379, 21380, 21381, - 21382, 21383, 21384, 21385, 21386, 21387, 21388, 21389, 21390, 21391, - 21392, 21393, 21394, 21395, 21396, 21397, 21398, 21399, 21400, 21401, - 21402, 21403, 21404, 21405, 21406, 21407, 21408, 21409, 21410, 21411, - 21412, 21413, 21414, 21415, 21416, 21417, 21140, 21142, 21172, 21146, - 21148, 21180, 21151, 21181, 21153, 21182, 21155, 21157, 21174, 21176, - 21159, 21162, 21183, 21166, 21168, 21136, 21170, 21184, 21185, 21178, - 21186, 21144, 21194, 21196, 21231, 21200, 21202, 21205, 21207, 21239, - 21209, 21240, 21211, 21213, 21233, 21235, 21215, 21218, 21241, 21222, - 21224, 21226, 21229, 21242, 21243, 21237, 21244, 21198, 21063, 21064, - 21065, 21066, 21067, 21068, 21069, 21070, 21071, 21072, 21073, 21074, - 21075, 21076, 21077, 21078, 21079, 21080, 21081, 21082, 21083, 21084, - 21085, 21086, 21087, 21088, 21089, 21090, 21091, 21092, 21093, 21094, - 21095, 21096, 21097, 21098, 21099, 21100, 21101, 21102, 21103, 21104, - 21105, 21106, 21107, 21108, 21109, 21110, 21111, 21112, 21113, 21114, - 20953, 20954, 35536, 35536, 20521, 20523, 20530, 20515, 20527, 20525, - 20528, 20517, 20532, 20534, 20536, 20553, 20555, 20557, 20538, 20543, - 20545, 20518, 20547, 20519, 20549, 20541, 20551, 20542, 20539, 20781, - 20569, 20571, 20580, 20567, 20575, 20573, 20576, 20599, 20582, 20584, - 20586, 20606, 20608, 20610, 20588, 20593, 20595, 20578, 20597, 20600, - 20602, 20591, 20604, 20592, 20589, 20783, 20779, 20786, 20780, 20782, - 20785, 20784, 21009, 21011, 21020, 21015, 21017, 21013, 21018, 21005, - 21022, 21024, 21026, 21043, 21045, 21047, 21028, 21033, 21035, 21006, - 21037, 21007, 21039, 21031, 21041, 21032, 21029, 21057, 20957, 20959, - 20968, 20955, 20963, 20961, 20964, 20987, 20970, 20972, 20974, 20994, - 20996, 20998, 20976, 20981, 20983, 20966, 20985, 20988, 20990, 20979, - 20992, 20980, 20977, 21059, 21055, 21062, 21056, 21058, 21061, 21060, - 20674, 20676, 20685, 20680, 20682, 20678, 20683, 20670, 20687, 20689, - 20691, 20708, 20710, 20712, 20693, 20698, 20700, 20671, 20702, 20672, - 20704, 20696, 20706, 20697, 20694, 20722, 20728, 20730, 20741, 20734, - 20736, 20732, 20737, 20760, 20743, 20745, 20747, 20767, 20769, 20771, - 20749, 20754, 20756, 20739, 20758, 20761, 20763, 20752, 20765, 20753, - 20750, 20724, 20720, 20778, 20721, 20723, 20726, 20725, 21251, 21253, - 21262, 21257, 21259, 21255, 21260, 21247, 21264, 21266, 21268, 21285, - 21287, 21289, 21270, 21275, 21277, 21248, 21279, 21249, 21281, 21273, - 21283, 21274, 21271, 21299, 21305, 21307, 21318, 21311, 21313, 21309, - 21314, 21337, 21320, 21322, 21324, 21344, 21346, 21348, 21326, 21331, - 21333, 21316, 21335, 21338, 21340, 21329, 21342, 21330, 21327, 21301, - 21297, 21355, 21298, 21300, 21303, 21302, 21141, 21143, 21152, 21147, - 21149, 21145, 21150, 21137, 21154, 21156, 21158, 21175, 21177, 21179, - 21160, 21165, 21167, 21138, 21169, 21139, 21171, 21163, 21173, 21164, - 21161, 21189, 21195, 21197, 21208, 21201, 21203, 21199, 21204, 21227, - 21210, 21212, 21214, 21234, 21236, 21238, 21216, 21221, 21223, 21206, - 21225, 21228, 21230, 21219, 21232, 21220, 21217, 21191, 21187, 21245, - 21188, 21190, 21193, 21192, 20514, 20566, 35536, 35536, 20845, 20847, - 20844, 20843, 20840, 20839, 20842, 20841, 20848, 20846, 20900, 20902, - 20899, 20898, 20895, 20894, 20897, 20896, 20903, 20901, 21476, 21478, - 21475, 21474, 21471, 21470, 21473, 21472, 21479, 21477, 21362, 21364, - 21361, 21360, 21357, 21356, 21359, 21358, 21365, 21363, 21121, 21123, - 21120, 21119, 21116, 21115, 21118, 21117, 21124, 21122, 27439, 27395, - 27420, 27636, 27591, 27377, 27440, 27404, 27553, 27505, 27481, 27442, - 27445, 27402, 27446, 27396, 27447, 27469, 27464, 27502, 27443, 27449, - 27458, 27459, 27450, 27456, 27460, 27398, 27532, 27441, 27470, 27399, - 27479, 27448, 27478, 27465, 27504, 27503, 27444, 27463, 27473, 27474, - 27477, 27476, 27544, 27452, 27453, 27454, 27526, 27494, 27457, 27461, - 27455, 27451, 27525, 27486, 27524, 27523, 27483, 27482, 27485, 27475, - 27472, 27471, 27521, 27520, 27522, 27493, 27569, 27573, 27572, 27570, - 27571, 27414, 27560, 27590, 27562, 27575, 27567, 27576, 27568, 27577, - 27566, 27424, 27425, 27589, 27630, 27563, 27564, 27565, 27561, 27587, - 27574, 27585, 27578, 27586, 27584, 27582, 27579, 27580, 27581, 27583, - 27411, 27417, 27415, 27416, 27620, 27619, 27427, 27419, 27430, 27433, - 27428, 27431, 27429, 27432, 27437, 27434, 27394, 27629, 27635, 27632, - 27634, 27608, 27610, 27588, 27618, 27611, 27615, 27609, 27617, 27616, - 27614, 27376, 27466, 27401, 27593, 27379, 27602, 27468, 27467, 27594, - 27507, 27510, 27509, 27508, 27517, 27557, 27406, 27631, 27388, 27513, - 27516, 27511, 27512, 27605, 27515, 27604, 27387, 27386, 27514, 27405, - 27603, 27385, 27480, 27400, 27595, 27612, 27378, 27462, 27397, 27533, - 27613, 27389, 27541, 27537, 27539, 27410, 27633, 27390, 27534, 27536, - 27535, 27540, 27538, 27628, 27506, 27403, 27435, 27622, 27623, 27621, - 27423, 27601, 27381, 27380, 27530, 27606, 27528, 27409, 27518, 27529, - 27627, 27527, 27531, 27519, 27407, 27436, 27426, 27607, 27392, 27393, - 27391, 27408, 27412, 27413, 27625, 27626, 27624, 27592, 27495, 27597, - 27498, 27499, 27500, 27497, 27501, 27496, 27490, 27491, 27492, 27489, - 27487, 27418, 27488, 27484, 27421, 27422, 27599, 27600, 27596, 27598, - 27383, 27384, 27382, 27542, 27547, 27550, 27551, 27552, 27558, 27543, - 27545, 27546, 27554, 27549, 27555, 27556, 27548, 27438, 27559, 27950, - 27949, 27948, 27970, 27969, 27968, 27925, 27924, 27923, 27309, 27308, - 27307, 27911, 27910, 27909, 27921, 27922, 27917, 27920, 27916, 27919, - 27918, 27366, 27369, 27365, 27368, 27367, 27915, 27785, 27786, 27787, - 27788, 27783, 27784, 27789, 27829, 27734, 27847, 27846, 27844, 27845, - 27848, 27823, 27826, 27824, 27825, 27822, 27853, 27852, 27850, 27851, - 27799, 27798, 27797, 27803, 27802, 27801, 27800, 27821, 27820, 27819, - 27796, 27795, 27794, 27869, 27868, 27867, 27843, 27842, 27841, 27966, - 27965, 27964, 27963, 27962, 27961, 27967, 27960, 27959, 27958, 27703, - 27702, 27700, 27701, 27707, 27706, 27704, 27705, 27695, 27694, 27692, - 27693, 27699, 27698, 27696, 27697, 27757, 27756, 27754, 27755, 27758, - 27772, 27775, 27773, 27774, 27731, 27762, 27761, 27760, 27759, 27717, - 27730, 27729, 27728, 27718, 27716, 27715, 27714, 27781, 27780, 27779, - 27778, 27777, 27776, 27953, 27952, 27951, 27956, 27955, 27954, 27957, - 27816, 27815, 27813, 27814, 27807, 27806, 27804, 27805, 27812, 27811, - 27834, 27833, 27830, 27835, 27840, 27837, 27836, 27856, 27855, 27854, - 27859, 27858, 27857, 27810, 27818, 27817, 27906, 27903, 27902, 27849, - 27808, 27831, 27838, 27863, 27907, 27904, 27900, 27809, 27832, 27839, - 27864, 27908, 27905, 27901, 27862, 27861, 27860, 27721, 27720, 27738, - 27736, 27737, 27735, 27747, 27745, 27746, 27744, 27764, 27763, 27895, - 27892, 27898, 27723, 27722, 27739, 27740, 27742, 27741, 27751, 27749, - 27750, 27748, 27766, 27765, 27896, 27893, 27899, 27727, 27726, 27724, - 27725, 27719, 27743, 27752, 27767, 27768, 27769, 27894, 27891, 27897, - 27753, 27793, 27791, 27792, 27790, 27713, 27711, 27709, 27712, 27710, - 27708, 27866, 27865, 27771, 27770, 27828, 27827, 27733, 27732, 27325, - 27324, 27320, 27323, 27327, 27326, 27321, 27322, 27319, 27328, 27638, - 27645, 27643, 27642, 27640, 27641, 27639, 27644, 27358, 27356, 27357, - 27334, 27333, 27332, 27317, 27315, 27316, 27318, 27373, 27372, 27371, - 27352, 27353, 27349, 27330, 27329, 27348, 27350, 27347, 27351, 27331, - 27346, 27344, 27345, 27341, 27343, 27342, 27335, 27337, 27336, 27339, - 27338, 27340, 27312, 27311, 27310, 27935, 27934, 27936, 27355, 27872, - 27871, 27873, 27874, 27302, 27304, 27301, 27303, 27306, 27305, 27667, - 27665, 27666, 27672, 27674, 27673, 27669, 27671, 27670, 27686, 27685, - 27684, 27678, 27679, 27680, 27681, 27682, 27683, 27675, 27677, 27676, - 27687, 27688, 27689, 27656, 27654, 27655, 27668, 27691, 27690, 27943, - 27942, 27940, 27941, 27939, 27944, 27938, 27937, 27927, 27932, 27930, - 27931, 27928, 27929, 27933, 27870, 27782, 27875, 27637, 27354, 27913, - 27912, 27375, 27370, 27914, 27946, 27945, 27947, 27971, 27646, 27647, - 27648, 27649, 27650, 27651, 27652, 27653, 27364, 27664, 27663, 27658, - 27661, 27660, 27657, 27659, 27662, 27314, 27374, 27926, 27313, 27972, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 27359, 27360, 27361, 27362, 27363, - 35536, 27883, 27884, 27885, 27886, 27887, 27888, 27889, 27890, 27876, - 27877, 27878, 27879, 27880, 27881, 27882, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 18185, 18460, 17951, 18465, - 17938, 18309, 18571, 18462, 18557, 18526, 17931, 18164, 18165, 18561, - 17925, 17978, 17952, 18302, 18101, 18282, 18162, 18555, 18441, 18530, - 18173, 18102, 18246, 18399, 18531, 18068, 18477, 35536, 35536, 35536, - 35536, 35536, 35536, 18092, 18295, 18341, 18446, 18485, 18521, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 7328, 7330, 7340, 7334, 7316, 7341, 7348, 35536, 7347, - 7321, 7318, 7317, 7315, 7352, 7336, 7335, 7337, 7351, 7338, 7339, 7323, - 7326, 7350, 7332, 7349, 35536, 35536, 7324, 7327, 7331, 7325, 7343, 7342, - 7344, 35536, 7346, 7322, 35536, 7345, 7320, 7329, 7319, 7333, 35536, - 35536, 35536, 35536, 35536, 22464, 22433, 22461, 22459, 22435, 22457, - 22454, 22455, 22456, 22463, 22440, 22441, 22465, 22444, 22442, 22437, - 22450, 22466, 22439, 22462, 22449, 22458, 22448, 22451, 22436, 22453, - 22434, 22447, 22431, 22460, 22432, 22445, 22443, 9638, 9616, 9636, 9623, - 9619, 9633, 9630, 9631, 9632, 9637, 9621, 9639, 9635, 9622, 9640, 9620, - 9625, 9629, 9634, 9628, 9626, 9627, 9624, 9615, 9618, 9617, 22438, 22452, - 22446, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 7236, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 24187, 24171, 24162, - 24173, 24178, 24170, 24175, 24166, 24192, 24196, 24198, 24201, 24165, - 24160, 24195, 24185, 24169, 24168, 24199, 24161, 24172, 24193, 24181, - 24197, 24200, 24167, 24189, 24174, 24164, 24184, 24163, 24179, 24186, - 24188, 24194, 24180, 24176, 24177, 24202, 24203, 24182, 24183, 24190, - 24191, 24204, 35536, 35536, 35536, 24213, 24217, 24216, 24219, 24218, - 24215, 24214, 24210, 24207, 24206, 24209, 24208, 24211, 24212, 35536, - 35536, 24227, 24229, 24226, 24225, 24222, 24221, 24224, 24223, 24230, - 24228, 35536, 35536, 35536, 35536, 24205, 24220, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 32097, 32080, 32100, - 32090, 32094, 32091, 32096, 32082, 32081, 32099, 32087, 32102, 32101, - 32093, 32092, 32098, 32095, 32083, 32075, 32084, 32076, 32104, 32085, - 32077, 32086, 32078, 32103, 32089, 32079, 32088, 32105, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 33559, 33558, 33590, 33591, 33592, - 33594, 33583, 33586, 33572, 33575, 33587, 33579, 33576, 33593, 33589, - 33588, 33596, 33601, 33600, 33599, 33585, 33564, 33563, 33598, 33597, - 33584, 33595, 33567, 33569, 33573, 33580, 33571, 33578, 33577, 33566, - 33561, 33562, 33570, 33565, 33568, 33560, 33574, 33581, 33582, 33605, - 33606, 33603, 33604, 33613, 33615, 33612, 33611, 33608, 33607, 33610, - 33609, 33616, 33614, 35536, 35536, 35536, 35536, 35536, 33602, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 23564, 23567, 23566, - 23568, 23565, 23547, 23551, 23549, 23548, 23550, 23559, 23562, 23560, - 23563, 23561, 23569, 23570, 23571, 23572, 23573, 23552, 23554, 23557, - 23558, 23553, 23556, 23555, 23577, 23574, 23578, 23576, 23575, 23585, - 23587, 23584, 23583, 23580, 23579, 23582, 23581, 23588, 23586, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 24350, 24353, 24352, 24351, 24354, 24355, 24332, - 24334, 24333, 24335, 24336, 24337, 24344, 24345, 24349, 24346, 24347, - 24348, 24356, 24360, 24357, 24359, 24358, 24361, 24338, 24343, 24342, - 24340, 24339, 24341, 24364, 24362, 24363, 24372, 24374, 24371, 24370, - 24367, 24366, 24369, 24368, 24375, 24373, 35536, 35536, 35536, 35536, - 24365, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 29660, 29669, 29658, 29667, 29691, 29676, 29689, - 29666, 29675, 29661, 29670, 29690, 29665, 29674, 29683, 29677, 29688, - 29664, 29673, 29682, 29662, 29671, 29692, 29695, 29657, 29694, 29663, - 29672, 29693, 29659, 29668, 35536, 29650, 29684, 29679, 29700, 29678, - 29651, 29698, 29686, 29696, 29685, 29680, 29681, 29687, 29649, 29699, - 29697, 29654, 29653, 29652, 29656, 29655, 29701, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 29702, 29703, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 12132, 12138, 12136, 12133, 12135, 12134, 12137, 35536, 12087, - 12131, 12129, 12128, 35536, 12075, 12074, 35536, 12086, 12085, 12084, - 12071, 12070, 12083, 12082, 12081, 12080, 12079, 12078, 12073, 12072, - 12077, 12076, 35536, 21774, 21775, 21776, 21842, 21863, 21851, 21815, - 21951, 21777, 21778, 21782, 21901, 21886, 21891, 21814, 21969, 21918, - 21840, 21820, 21912, 21781, 21779, 21780, 21827, 21871, 21924, 21964, - 21787, 21783, 21791, 21928, 21866, 21876, 21903, 21792, 21789, 21788, - 21941, 21879, 21939, 21917, 21908, 21906, 21907, 21970, 21949, 21786, - 21801, 21793, 21940, 21885, 21910, 21845, 21971, 21797, 21798, 21799, - 21855, 21847, 21831, 21932, 21883, 21784, 21790, 21785, 21858, 21955, - 21956, 21794, 21795, 21796, 21869, 21824, 21874, 21841, 21802, 21800, - 21803, 21927, 21884, 21933, 21835, 21947, 21804, 21808, 21812, 21881, - 21853, 21921, 21902, 21805, 21809, 21810, 21852, 21844, 21909, 21862, - 21972, 21873, 21811, 21806, 21807, 21889, 21942, 21950, 21819, 21962, - 21813, 21872, 21822, 21919, 21859, 21897, 21829, 21911, 21861, 21828, - 21968, 21817, 21864, 21821, 21860, 21888, 21915, 21926, 21896, 21931, - 21898, 21857, 21877, 21958, 21925, 21892, 21935, 21965, 21938, 21936, - 21961, 21832, 21948, 21838, 21867, 21823, 21854, 21830, 21878, 21834, - 21914, 21833, 21893, 21818, 21959, 21849, 21944, 21945, 21963, 21934, - 21875, 21913, 21905, 21868, 21843, 21816, 21882, 21890, 21929, 21895, - 21825, 21920, 21865, 21880, 21846, 21848, 21954, 21894, 21900, 21899, - 21966, 21887, 21836, 21837, 21923, 21967, 21916, 21904, 21957, 21960, - 21930, 21952, 21856, 21922, 21850, 21937, 21826, 21953, 21870, 21839, - 35536, 35536, 21980, 21978, 21977, 21974, 21973, 21976, 21975, 21981, - 21979, 21769, 21768, 21772, 21770, 21767, 21771, 21773, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 27, 9, 24, - 14, 29, 21, 34, 28, 37, 39, 35, 40, 41, 10, 30, 32, 18, 15, 31, 42, 13, - 25, 36, 23, 12, 20, 33, 19, 38, 17, 11, 26, 16, 22, 62, 44, 59, 49, 64, - 56, 69, 63, 72, 74, 70, 75, 76, 45, 65, 67, 53, 50, 66, 77, 48, 60, 71, - 58, 47, 55, 68, 54, 73, 52, 46, 61, 51, 57, 85, 86, 79, 84, 43, 78, 83, - 82, 35536, 35536, 35536, 35536, 93, 95, 92, 91, 88, 87, 90, 89, 96, 94, - 35536, 35536, 35536, 35536, 80, 81, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 15849, 15835, - 15830, 15810, 15805, 15823, 15818, 15798, 15813, 15838, 15833, 15828, - 15808, 15803, 15824, 15819, 15799, 15814, 15850, 15836, 15831, 15811, - 15806, 15826, 15821, 15801, 15816, 15851, 15837, 15832, 15812, 15807, - 15827, 15822, 15802, 15817, 15839, 15834, 15829, 15809, 15804, 15825, - 15820, 15800, 15815, 15796, 15797, 15787, 15794, 15795, 15847, 15845, - 15844, 15841, 15840, 15843, 15842, 15848, 15846, 15853, 15789, 15788, - 15790, 15852, 15793, 15792, 15791, 15786, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 25132, 25127, 25122, 25102, 25097, 25115, 25110, 25090, - 25105, 25130, 25125, 25120, 25100, 25095, 25116, 25111, 25091, 25106, - 25133, 25128, 25123, 25103, 25098, 25118, 25113, 25093, 25108, 25134, - 25129, 25124, 25104, 25099, 25119, 25114, 25094, 25109, 25131, 25126, - 25121, 25101, 25096, 25117, 25112, 25092, 25107, 25089, 25082, 25084, - 25074, 25076, 25077, 25079, 25086, 25085, 25080, 25075, 25078, 25083, - 25081, 25088, 25087, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 2288, 2296, 2294, 2192, - 35536, 2304, 2292, 2300, 2284, 2299, 2291, 2240, 2295, 2302, 2267, 2289, - 2297, 2268, 2303, 2298, 2266, 2287, 2286, 2290, 2285, 2191, 2293, 2301, - 2162, 2164, 2163, 2165, 35536, 2204, 2202, 35536, 2199, 35536, 35536, - 2198, 35536, 2206, 2201, 2209, 2203, 2208, 2196, 2211, 2205, 2197, 2210, - 35536, 2195, 2194, 2193, 2200, 35536, 2212, 35536, 2207, 35536, 35536, - 35536, 35536, 35536, 35536, 2276, 35536, 35536, 35536, 35536, 2278, - 35536, 2277, 35536, 2281, 35536, 2280, 2273, 2283, 35536, 2274, 2282, - 35536, 2272, 35536, 35536, 2275, 35536, 2271, 35536, 2279, 35536, 2269, - 35536, 2270, 35536, 2258, 2256, 35536, 2253, 35536, 35536, 2252, 2247, - 2260, 2255, 35536, 2257, 2263, 2250, 2265, 2259, 2251, 2264, 35536, 2249, - 2248, 2246, 2254, 35536, 2245, 2261, 2262, 2243, 35536, 2244, 35536, - 2217, 2229, 2227, 2237, 2220, 2239, 2225, 2219, 2223, 2232, 35536, 2235, - 2228, 2234, 2214, 2218, 2230, 2215, 2238, 2231, 2213, 2224, 2222, 2216, - 2221, 2236, 2226, 2233, 35536, 35536, 35536, 35536, 35536, 2178, 2176, - 2187, 35536, 2190, 2174, 2182, 2172, 2181, 35536, 2185, 2177, 2184, 2167, - 2189, 2179, 2168, 2188, 2180, 2166, 2173, 2171, 2169, 2170, 2186, 2175, - 2183, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 2241, 2242, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 20081, - 20097, 20112, 20088, 20116, 20115, 20113, 20093, 20110, 20107, 20086, - 20083, 20102, 20099, 20079, 20090, 20094, 20111, 20108, 20087, 20084, - 20103, 20100, 20080, 20091, 20092, 20109, 20106, 20085, 20082, 20101, - 20098, 20078, 20089, 20096, 20095, 20076, 20119, 20105, 20104, 20117, - 20114, 20118, 20077, 35536, 35536, 35536, 35536, 10257, 10208, 10209, - 10210, 10211, 10212, 10213, 10214, 10215, 10216, 10217, 10218, 10219, - 10220, 10221, 10222, 10223, 10224, 10225, 10226, 10227, 10228, 10229, - 10230, 10231, 10232, 10233, 10234, 10235, 10236, 10237, 10238, 10239, - 10240, 10241, 10242, 10243, 10244, 10245, 10246, 10247, 10248, 10249, - 10250, 10251, 10252, 10253, 10254, 10255, 10256, 10307, 10258, 10259, - 10260, 10261, 10262, 10263, 10264, 10265, 10266, 10267, 10268, 10269, - 10270, 10271, 10272, 10273, 10274, 10275, 10276, 10277, 10278, 10279, - 10280, 10281, 10282, 10283, 10284, 10285, 10286, 10287, 10288, 10289, - 10290, 10291, 10292, 10293, 10294, 10295, 10296, 10297, 10298, 10299, - 10300, 10301, 10302, 10303, 10304, 10305, 10306, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 25795, - 25865, 25840, 25836, 25799, 25804, 25824, 25820, 25816, 25869, 25832, - 25873, 25808, 25828, 25812, 35536, 35536, 25866, 25841, 25837, 25800, - 25805, 25825, 25821, 25817, 25870, 25833, 25874, 25809, 25829, 25813, - 25796, 35536, 25867, 25842, 25838, 25801, 25806, 25826, 25822, 25818, - 25871, 25834, 25875, 25810, 25830, 25814, 25794, 35536, 25864, 25839, - 25835, 25798, 25803, 25823, 25819, 25815, 25868, 25831, 25872, 25807, - 25827, 25811, 25797, 25802, 25846, 25843, 25857, 25858, 25859, 25860, - 25861, 25862, 25863, 25847, 25848, 25849, 25850, 25851, 25852, 25853, - 25854, 25855, 25856, 25844, 25845, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 9992, 9991, 9976, 9988, 9985, 9970, - 9967, 9982, 9979, 9994, 9973, 10033, 10012, 6918, 6635, 6659, 25463, - 25464, 25465, 25466, 25467, 25468, 25469, 25470, 25471, 25472, 25473, - 25474, 25475, 25476, 25477, 25478, 25479, 25480, 25481, 25482, 25483, - 25484, 25485, 25486, 25487, 25488, 32073, 6749, 6750, 6646, 6917, 7764, - 28768, 28769, 28770, 28771, 28772, 28773, 28774, 28775, 28776, 28777, - 28778, 28779, 28780, 28781, 28782, 28783, 28784, 28785, 28786, 28787, - 28788, 28789, 28790, 28791, 28792, 28793, 28762, 28798, 28813, 28814, - 28803, 28825, 23677, 23678, 23679, 23680, 23681, 23682, 23683, 23684, - 23685, 23686, 23687, 23688, 23689, 23690, 23691, 23692, 23693, 23694, - 23695, 23696, 23697, 23698, 23699, 23700, 23701, 23702, 26074, 26075, - 26076, 6645, 6644, 6692, 23708, 23709, 23710, 23711, 23712, 23713, 23714, - 23715, 23716, 23717, 23718, 23719, 23720, 23721, 23722, 23723, 23724, - 23725, 23726, 23727, 23728, 23729, 23730, 23731, 23732, 23733, 7808, - 23740, 23743, 23744, 23739, 23741, 28497, 28751, 28750, 28757, 28826, - 28799, 28800, 28802, 28812, 28820, 28823, 28815, 28805, 28817, 28755, - 28819, 28756, 28806, 28816, 28808, 28801, 28767, 28761, 28760, 28759, - 28796, 28807, 28821, 28822, 20511, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 26104, 26105, 26106, 26107, 26108, 26109, 26110, 26111, 26112, - 26113, 26114, 26115, 26116, 26117, 26118, 26119, 26120, 26121, 26122, - 26123, 26124, 26125, 26126, 26127, 26128, 26129, 28538, 28763, 28765, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 28729, 28724, 28716, 28764, 28710, 28722, 28745, - 28721, 28709, 28734, 28742, 28733, 28714, 28725, 28726, 28732, 28713, - 28743, 28740, 28747, 28723, 28718, 28737, 28727, 28730, 28707, 28708, - 28749, 28720, 28711, 28715, 28731, 28746, 28728, 28741, 28744, 28717, - 28738, 28736, 28735, 28739, 28712, 28719, 28748, 35536, 35536, 35536, - 35536, 32070, 32064, 32065, 32067, 32071, 32068, 32072, 32066, 32069, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 6697, 6695, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 26540, 26541, 26538, 26542, 26537, 26539, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 9643, 12618, 7128, 23987, 29001, 29000, 6928, 29046, - 26067, 5033, 33707, 33532, 22284, 10657, 10655, 10656, 13154, 23792, - 33619, 12583, 33620, 12661, 33618, 17425, 33617, 7798, 23791, 12582, - 17424, 12660, 28925, 13155, 27144, 31509, 3930, 33866, 33870, 33867, - 33868, 7141, 7140, 7139, 7138, 12617, 33933, 15586, 31167, 5109, 6579, - 26874, 12510, 9669, 25331, 6226, 15583, 32241, 6576, 26528, 15543, 29047, - 4344, 10651, 10652, 15368, 12637, 20363, 12550, 18722, 22999, 32023, - 2586, 13267, 21766, 33710, 30190, 19088, 3475, 25779, 26101, 13807, - 25599, 25596, 6578, 28865, 14257, 28130, 21556, 25915, 26224, 26225, - 7598, 9070, 28853, 28429, 5031, 12651, 26544, 9652, 25189, 29087, 12659, - 12589, 28226, 27088, 15617, 10403, 7597, 6618, 6101, 19966, 9073, 15549, - 27163, 3699, 25913, 7596, 12623, 31169, 26841, 33935, 7145, 32154, 3589, - 7087, 2650, 12624, 4468, 25903, 26215, 33955, 3860, 15978, 6619, 12556, - 12579, 12578, 2793, 25521, 7577, 30189, 7809, 25778, 15983, 6163, 33932, - 22882, 26846, 13192, 14838, 4470, 22283, 26168, 23005, 28874, 19087, - 7589, 3579, 3580, 12572, 98, 6161, 12562, 26486, 12587, 22273, 22904, - 6621, 14837, 2565, 32048, 6926, 31916, 7083, 25628, 33454, 10038, 28136, - 3859, 12850, 4473, 12606, 23240, 22986, 26840, 13823, 23004, 32159, - 33459, 23239, 26669, 31284, 28111, 3481, 6580, 28220, 26670, 29085, - 28460, 32156, 15581, 372, 26547, 29090, 33728, 13191, 26057, 26058, 7800, - 33533, 12593, 15619, 29278, 28217, 5367, 3585, 5108, 15593, 6927, 9696, - 7084, 9778, 9779, 23658, 28851, 15592, 15591, 25185, 15980, 12475, 15594, - 3470, 2583, 15587, 19850, 7592, 26845, 9695, 12546, 15976, 15979, 12474, - 33835, 3983, 33716, 33715, 26529, 3999, 17247, 2661, 4477, 370, 11868, - 11869, 11870, 11871, 11872, 26082, 22899, 25192, 33708, 7791, 31814, - 18984, 26084, 6168, 10493, 7812, 33889, 28215, 28213, 15580, 26087, - 13159, 27169, 22880, 26527, 6587, 10144, 25770, 4655, 11837, 24251, - 28454, 5046, 966, 15548, 17249, 12586, 32155, 4345, 32266, 14806, 2649, - 12655, 3861, 25600, 17244, 25925, 10495, 2659, 10206, 22901, 7792, 31815, - 26085, 6169, 10494, 28459, 15582, 22881, 10205, 25772, 12658, 14255, - 33954, 3584, 25368, 25771, 25589, 6586, 12507, 12505, 10650, 24140, - 22902, 32024, 33877, 33792, 33818, 33842, 12590, 33717, 25188, 31542, - 31543, 7082, 24842, 7814, 33945, 12506, 23982, 29275, 16080, 10501, - 17239, 3865, 33943, 26030, 14261, 25920, 20357, 2580, 15439, 33944, - 33942, 12622, 5104, 5103, 4653, 13054, 20270, 33940, 12554, 20276, 32281, - 32282, 25900, 33941, 5034, 25613, 20273, 20274, 24821, 24819, 2648, 7580, - 25982, 15986, 15985, 14123, 2651, 12494, 350, 15746, 28113, 15862, 13822, - 9651, 19743, 23589, 12542, 14128, 3479, 29273, 25775, 17236, 19849, - 26466, 12854, 17231, 4469, 7790, 33726, 3586, 5040, 32275, 28430, 13820, - 14840, 4347, 13809, 33982, 26029, 14839, 26211, 14841, 9954, 11825, 964, - 4652, 28125, 7150, 28455, 10497, 9656, 25773, 12600, 10124, 28443, 31517, - 33803, 15603, 22702, 9068, 14870, 7797, 3472, 3474, 3473, 3471, 22701, - 6397, 26870, 25623, 5035, 22286, 12607, 24853, 10648, 12568, 24840, - 25196, 25198, 5364, 31170, 6106, 6396, 6398, 3477, 7088, 26032, 26535, - 25591, 28863, 32124, 4358, 19086, 24138, 24139, 7134, 24834, 13808, 4346, - 24857, 4359, 23660, 26867, 22120, 31175, 25199, 12553, 26753, 26033, - 6403, 25136, 15973, 25590, 12508, 15778, 11906, 7131, 7132, 24844, 24843, - 25909, 25906, 23977, 22300, 22301, 33450, 22302, 24057, 968, 5365, 5366, - 33453, 31182, 26060, 33455, 12571, 25904, 25996, 32269, 7118, 7119, 7115, - 977, 19851, 15434, 28438, 28437, 28439, 28440, 3578, 11823, 18853, 26342, - 19801, 7133, 16765, 19798, 24847, 3592, 3594, 4357, 19741, 26062, 2653, - 11901, 24823, 28276, 32063, 24056, 16780, 15865, 15866, 15869, 15868, - 15867, 12575, 11824, 33958, 14251, 24156, 15595, 25784, 22272, 31181, - 7819, 28107, 15984, 32126, 4010, 33853, 17415, 17342, 17350, 17343, - 28142, 28141, 32364, 10416, 32368, 10410, 19920, 32460, 6642, 7806, 7805, - 24131, 24133, 29162, 33816, 14885, 6234, 25190, 10488, 16763, 22888, - 29183, 21982, 4471, 7099, 7109, 7111, 7095, 7093, 7103, 7101, 7091, 7097, - 7105, 7089, 7107, 7100, 7110, 7112, 7096, 7094, 7104, 7102, 7092, 7098, - 7106, 7090, 7108, 26289, 26290, 26291, 5099, 5100, 26474, 4356, 6100, - 20360, 4012, 24055, 15547, 20271, 28128, 9653, 28450, 28451, 16081, - 20275, 18774, 31176, 26270, 33872, 4025, 31180, 7085, 2654, 28835, 11905, - 12616, 25603, 19740, 3980, 19882, 19868, 19880, 19881, 19902, 18834, - 32257, 26072, 26196, 26204, 26205, 26210, 26206, 26073, 33793, 27298, - 27297, 27294, 27293, 3958, 3985, 27300, 27299, 27296, 27295, 4028, 3924, - 3937, 9780, 16767, 31533, 25979, 25926, 3940, 33807, 28227, 31164, 33938, - 24831, 32270, 31529, 32108, 24645, 14804, 26851, 25980, 12552, 24854, - 10130, 10131, 10132, 12647, 12649, 12648, 3936, 12620, 24841, 6107, 6108, - 12569, 11873, 11874, 11875, 24135, 24136, 24137, 11884, 11877, 11878, - 10129, 25195, 25200, 33722, 28453, 28452, 9781, 22287, 21542, 25179, - 7117, 6098, 15780, 9670, 7572, 24818, 26485, 25197, 28861, 9650, 19742, - 28441, 31525, 31524, 31526, 31527, 18802, 26292, 32285, 31531, 18819, - 26306, 18732, 26228, 22885, 19111, 19110, 2798, 2804, 2799, 2803, 2796, - 19108, 2797, 33949, 22898, 32107, 28848, 28110, 22903, 13812, 13815, - 12532, 28201, 28203, 28202, 28204, 28200, 28199, 33936, 28205, 12512, - 26167, 28198, 28208, 28211, 23789, 12487, 32321, 12515, 25601, 7578, - 7579, 17232, 12543, 17233, 17234, 12529, 12530, 12531, 10040, 33950, 965, - 25918, 7818, 25625, 12537, 10039, 12657, 962, 12558, 33724, 28127, 31915, - 13817, 19965, 12520, 15602, 12522, 12513, 2573, 12608, 28126, 10125, - 12540, 12517, 13816, 6170, 28197, 28196, 6171, 17235, 25917, 7817, 33723, - 28132, 28131, 32472, 12536, 12525, 12519, 25622, 26875, 14843, 28436, - 14803, 25620, 25619, 25615, 25617, 24100, 28332, 24073, 28319, 32255, - 32264, 32254, 32263, 24099, 28331, 24072, 28318, 14921, 14914, 14918, - 14911, 24101, 28333, 24074, 28320, 14922, 14915, 14919, 14912, 15545, - 15546, 28272, 28273, 18977, 32506, 26429, 10483, 26861, 14916, 19090, - 14893, 14848, 29088, 26747, 26748, 26749, 14938, 26750, 14905, 33440, - 33437, 6399, 26177, 26484, 15080, 28852, 26065, 15437, 15438, 32115, - 22118, 19097, 28849, 32111, 32112, 5102, 24828, 32152, 5105, 22288, 373, - 12576, 25898, 24827, 31168, 24826, 2582, 24824, 26100, 9675, 2564, 32109, - 22879, 22895, 29086, 22896, 160, 27143, 26543, 28442, 15573, 33431, 7581, - 25899, 32123, 10489, 24053, 28212, 24058, 26031, 10487, 25911, 24062, - 3855, 24051, 3854, 22897, 25632, 24054, 6582, 21983, 33946, 26172, 2652, - 32106, 33706, 27168, 3576, 3577, 25531, 9072, 2665, 18775, 32120, 25994, - 6751, 4654, 13055, 7789, 28124, 27146, 3596, 3756, 25789, 24250, 27145, - 28876, 25201, 15541, 15605, 11838, 17251, 35536, 35536, 35536, 33939, - 25793, 33730, 26467, 14252, 27139, 24283, 22893, 26064, 22890, 32362, - 32359, 32367, 28139, 24108, 227, 228, 35536, 35536, 35536, 26752, 24825, - 9965, 25527, 26849, 22891, 6103, 28129, 12611, 28116, 2584, 25769, 26487, - 35536, 35536, 35536, 297, 245, 345, 344, 341, 239, 237, 238, 235, 236, - 334, 336, 337, 323, 290, 252, 283, 284, 285, 267, 311, 288, 338, 339, - 309, 310, 272, 325, 278, 279, 261, 302, 258, 280, 321, 259, 260, 257, - 312, 319, 340, 331, 281, 240, 320, 313, 318, 335, 300, 301, 299, 303, - 304, 305, 232, 233, 286, 314, 242, 306, 307, 243, 248, 328, 329, 298, - 249, 250, 251, 234, 346, 324, 330, 273, 342, 291, 256, 333, 255, 327, - 254, 332, 315, 282, 326, 343, 276, 244, 293, 253, 292, 241, 316, 317, - 322, 296, 270, 268, 269, 295, 294, 262, 263, 264, 265, 266, 231, 246, - 247, 308, 277, 289, 271, 287, 275, 274, 19847, 24252, 19968, 33448, 2577, - 15607, 25523, 14833, 20145, 13189, 26051, 24860, 3951, 4029, 3991, 3925, - 4015, 21657, 4353, 14935, 33441, 12491, 33772, 26536, 4023, 4016, 19105, - 21683, 4354, 14932, 33442, 12492, 33854, 33856, 28683, 4021, 4039, 3973, - 33787, 33788, 9953, 4022, 4040, 3974, 33825, 31514, 19107, 21684, 4355, - 33446, 33443, 12493, 31512, 19100, 21674, 4349, 14906, 33438, 12488, - 19093, 21663, 4352, 14881, 33436, 12490, 19101, 21673, 4350, 14910, - 33439, 12489, 19091, 21681, 4351, 14875, 33435, 19103, 21678, 31532, - 21677, 19095, 21662, 12639, 21661, 26178, 19092, 14880, 21672, 14909, - 28105, 21680, 14873, 33434, 14871, 19102, 14928, 14927, 6912, 23703, - 6922, 23704, 23985, 35536, 35536, 35536, 35536, 35536, 35536, 17349, - 17417, 17345, 17413, 17340, 17416, 17344, 17351, 17418, 17346, 17414, - 17341, 35536, 35536, 35536, 35536, 14878, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 18897, 32482, 26382, 10434, 18904, 32479, 26389, 10431, 18891, - 32478, 26379, 10430, 35536, 35536, 35536, 35536, 18896, 32481, 26381, - 10433, 18906, 32483, 26391, 10435, 14889, 14930, 14903, 14867, 14888, - 14929, 14902, 14866, 18941, 32516, 26442, 10454, 18940, 32515, 26441, - 10453, 18939, 32512, 26440, 10450, 18943, 32518, 26444, 10456, 18942, - 32517, 26443, 10455, 18971, 32493, 26408, 10470, 18979, 32508, 26431, - 10485, 18981, 32504, 26464, 10481, 18931, 32502, 26422, 10479, 18932, - 32503, 26423, 10480, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 18980, 32507, 26432, 10484, 24106, 24079, 28325, 28338, 18794, - 32349, 35536, 35536, 35536, 35536, 35536, 35536, 33892, 33907, 33897, - 33902, 33917, 33912, 33922, 33927, 33894, 33909, 33899, 33904, 33919, - 33914, 33924, 33929, 33893, 33908, 33898, 33903, 33918, 33913, 33923, - 33928, 33890, 33905, 33895, 33900, 33915, 33910, 33920, 33925, 33891, - 33906, 33896, 33901, 33916, 33911, 33921, 33926, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 18947, 32522, 26448, 10461, 18961, - 32532, 26463, 10466, 18905, 32480, 26390, 10432, 14844, 14847, 14846, - 14845, 18915, 26397, 18950, 26433, 18972, 26428, 18976, 26424, 18914, - 26396, 18970, 26407, 33734, 33733, 35536, 35536, 2560, 2557, 26377, - 10445, 23734, 23735, 23742, 23736, 24098, 24070, 28317, 28330, 35536, - 35536, 35536, 35536, 18911, 26368, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 19838, - 19842, 19843, 27153, 19834, 27150, 19836, 19837, 19826, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 6640, 6641, 6639, 18759, - 18757, 18758, 18760, 18756, 10423, 10425, 10424, 10426, 25776, 33808, - 5042, 25777, 35345, 22703, 12533, 23983, 31515, 12516, 26545, 15604, - 27973, 5363, 26081, 18868, 26331, 14262, 14258, 15977, 12514, 7142, - 23659, 26489, 10498, 20026, 12541, 28216, 12524, 13814, 13813, 12535, - 26970, 28206, 12521, 27166, 25927, 5030, 25366, 26978, 25981, 20272, - 22889, 27171, 25610, 16083, 12564, 22303, 33957, 33709, 14260, 10120, - 33931, 10499, 7086, 32267, 28458, 13158, 26478, 12585, 26873, 31516, - 4650, 20434, 9067, 17248, 28229, 12615, 7813, 2642, 9074, 2660, 25912, - 6166, 2663, 13810, 26982, 28875, 11773, 13153, 25597, 17237, 25367, - 10645, 12627, 29772, 6617, 4472, 9060, 7146, 5041, 25787, 25977, 9075, - 26751, 6102, 18723, 20361, 22883, 2664, 28207, 33981, 28209, 12526, - 12539, 25178, 12653, 23986, 10044, 12544, 12528, 26842, 17246, 13188, - 15542, 12594, 7820, 19795, 26847, 32243, 32335, 10660, 10646, 3519, - 27087, 25191, 12644, 5107, 9948, 13187, 19796, 26213, 27170, 28828, - 13056, 35339, 15433, 26837, 29276, 7799, 16369, 20032, 25594, 15544, - 25526, 26059, 19964, 22887, 22275, 2662, 29089, 20269, 10490, 28137, - 25135, 24859, 28115, 12599, 25184, 3587, 3866, 26869, 13824, 25995, - 11864, 11865, 11867, 11866, 4656, 19089, 12621, 32025, 29082, 29083, - 26680, 10653, 22892, 20358, 21557, 21558, 6402, 9062, 26683, 3755, 12849, - 24833, 12551, 33557, 5106, 21521, 15618, 5044, 32151, 28850, 17241, 9947, - 12518, 101, 6581, 24820, 3583, 25618, 25612, 25621, 25611, 20036, 12557, - 33095, 22107, 11862, 13051, 35531, 5028, 24858, 3858, 26844, 13156, 7795, - 28224, 26102, 12580, 16086, 31287, 25631, 10647, 7575, 2645, 12577, - 32027, 5037, 20035, 19967, 19846, 28457, 2806, 26681, 31174, 5043, 3480, - 26488, 3478, 28461, 26088, 23661, 23766, 23777, 23780, 23769, 23759, - 23774, 33747, 3893, 23760, 33744, 33760, 33763, 33738, 33752, 33757, - 3890, 3906, 3909, 3884, 3898, 3903, 23767, 23778, 23781, 23770, 23765, - 23775, 33748, 3894, 23761, 33766, 33769, 33770, 33765, 33767, 33768, - 3912, 3915, 3916, 3911, 3913, 3914, 23784, 23787, 23788, 23783, 23785, - 23786, 33749, 3895, 23762, 33745, 33761, 33764, 33739, 33750, 33758, - 3891, 3907, 3910, 3885, 3896, 3904, 23768, 23779, 23782, 23771, 23763, - 23776, 33751, 3897, 23764, 33740, 3886, 23772, 33741, 3887, 23773, 33754, - 33755, 33753, 3900, 3901, 3899, 33742, 33736, 3888, 3882, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 33973, 33976, 33972, 33974, - 33971, 33970, 33975, 33966, 33969, 33965, 33967, 33964, 33963, 33968, - 35536, 35536, 2807, 24832, 5036, 27164, 31518, 19104, 13811, 25781, - 10496, 99, 28855, 33962, 7816, 35536, 35536, 35536, 35253, 17240, 25375, - 4360, 20034, 25782, 23756, 20364, 12609, 14805, 32153, 35536, 35536, - 35536, 32116, 27167, 26473, 6237, 26086, 2647, 10123, 3476, 22282, 1, - 19824, 7794, 6164, 26850, 17250, 15597, 22298, 33934, 25895, 26975, - 17242, 5110, 22900, 32026, 14835, 25790, 26483, 22299, 15624, 19852, - 14256, 12619, 14125, 16850, 12610, 33951, 3590, 7144, 25914, 33953, - 12559, 19848, 7768, 11876, 23757, 15615, 16079, 33937, 18721, 13190, 958, - 19969, 25633, 25929, 25928, 25616, 12573, 35536, 14127, 35536, 35536, - 35536, 35536, 24861, 22886, 10308, 4348, 3593, 24822, 12595, 30188, - 12643, 31173, 25916, 3588, 16078, 13053, 25598, 26526, 35536, 35536, - 28456, 21765, 26685, 12523, 12527, 12538, 10318, 3863, 5045, 27138, - 12534, 10043, 35536, 35536, 35536, 35536, 12567, 14259, 26421, 18930, - 25332, 25333, 15785, 14842, 18975, 26427, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 4284, 4314, 4285, 4329, 4300, 4318, 4286, 4337, - 4307, 4315, 4293, 4330, 4301, 4319, 4287, 4341, 4311, 4326, 4297, 4334, - 4323, 4290, 4338, 4308, 4316, 4294, 4331, 4302, 4320, 4288, 4343, 4313, - 4328, 4299, 4336, 4306, 4325, 4292, 4340, 4310, 4296, 4333, 4304, 4322, - 4289, 4342, 4312, 4327, 4298, 4335, 4305, 4324, 4291, 4339, 4309, 4317, - 4295, 4332, 4303, 4321, 19869, 19870, 19877, 19879, 19874, 19935, 19936, - 19932, 19934, 19930, 19933, 19926, 19929, 19927, 19931, 19928, 19873, - 19876, 19871, 19875, 19872, 19878, 32432, 32433, 32440, 32442, 32437, - 32402, 32403, 32399, 32401, 32397, 32400, 32393, 32396, 32394, 32398, - 32395, 32436, 32439, 32434, 32438, 32435, 32441, 32375, 18724, 32372, - 18729, 18815, 32471, 26314, 19961, 33419, 33420, 33421, 33422, 33423, - 33424, 15559, 15560, 15561, 15562, 15563, 15564, 18725, 18730, 26227, - 26226, 32374, 15558, 32430, 32467, 32382, 32470, 32466, 26276, 26310, - 26254, 26309, 26286, 18773, 26269, 32389, 19862, 15960, 32384, 32386, - 35536, 18772, 6400, 15956, 14882, 32407, 32462, 32373, 18726, 32408, - 32463, 19922, 19899, 4556, 4560, 4548, 4554, 4557, 4562, 4549, 4551, - 4559, 4561, 4563, 4558, 4552, 4553, 4579, 4589, 2563, 15957, 18767, - 26264, 15958, 18884, 26365, 10440, 32475, 18764, 26261, 33531, 26278, - 23706, 23705, 23707, 33811, 18818, 22277, 26305, 23737, 28856, 28857, - 28859, 28860, 28858, 33879, 33784, 26077, 4005, 18825, 18780, 4555, 4576, - 4571, 4550, 4566, 4565, 4573, 4564, 4569, 4575, 4546, 4570, 4567, 4577, - 4547, 4572, 32051, 26272, 4466, 18839, 32381, 19946, 22278, 22279, 32050, - 26271, 4465, 18838, 32060, 4452, 4459, 32052, 26883, 26885, 26882, 26881, - 26878, 26877, 26880, 26879, 26886, 26884, 229, 35536, 35536, 35536, - 35536, 35536, 35536, 17252, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 29369, 29298, 29361, 29370, 29286, 29359, - 29280, 29279, 29356, 29364, 29281, 29360, 29284, 29301, 29372, 29368, - 29293, 29295, 29292, 29291, 29288, 29287, 29290, 29289, 29296, 29294, - 29285, 29367, 29354, 29297, 29300, 29362, 29283, 29302, 29303, 29304, - 29305, 29306, 29307, 29308, 29309, 29310, 29311, 29312, 29313, 29314, - 29315, 29316, 29317, 29318, 29319, 29320, 29321, 29322, 29323, 29324, - 29325, 29326, 29327, 29357, 29366, 29365, 29282, 29358, 29299, 29328, - 29329, 29330, 29331, 29332, 29333, 29334, 29335, 29336, 29337, 29338, - 29339, 29340, 29341, 29342, 29343, 29344, 29345, 29346, 29347, 29348, - 29349, 29350, 29351, 29352, 29353, 29355, 29373, 29363, 29371, 6097, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 32917, 32928, - 32939, 32951, 32962, 32973, 32984, 32995, 33006, 33014, 33015, 33016, - 33017, 33019, 33020, 33021, 33022, 33023, 33024, 33025, 33026, 33027, - 33028, 33030, 33031, 33032, 33033, 33034, 33035, 33036, 33037, 33038, - 33039, 33041, 33042, 33043, 33044, 33045, 33046, 33047, 33048, 33049, - 33050, 33052, 33053, 33054, 33055, 33056, 33057, 33058, 33059, 33060, - 33061, 33063, 33064, 33065, 33066, 33067, 33068, 33069, 33070, 33071, - 33072, 33074, 33075, 33076, 33077, 33078, 33079, 33080, 33081, 33082, - 33083, 33085, 33086, 33087, 33088, 33089, 33090, 33091, 33092, 33093, - 33094, 32841, 32842, 32843, 32844, 32845, 32846, 32847, 32848, 32849, - 32850, 32852, 32853, 32854, 32855, 32856, 32857, 32858, 32859, 32860, - 32861, 32863, 32864, 32865, 32866, 32867, 32868, 32869, 32870, 32871, - 32872, 32874, 32875, 32876, 32877, 32878, 32879, 32880, 32881, 32882, - 32883, 32885, 32886, 32887, 32888, 32889, 32890, 32891, 32892, 32893, - 32894, 32896, 32897, 32898, 32899, 32900, 32901, 32902, 32903, 32904, - 32905, 32907, 32908, 32909, 32910, 32911, 32912, 32913, 32914, 32915, - 32916, 32918, 32919, 32920, 32921, 32922, 32923, 32924, 32925, 32926, - 32927, 32929, 32930, 32931, 32932, 32933, 32934, 32935, 32936, 32937, - 32938, 32940, 32941, 32942, 32943, 32944, 32945, 32946, 32947, 32948, - 32949, 32952, 32953, 32954, 32955, 32956, 32957, 32958, 32959, 32960, - 32961, 32963, 32964, 32965, 32966, 32967, 32968, 32969, 32970, 32971, - 32972, 32974, 32975, 32976, 32977, 32978, 32979, 32980, 32981, 32982, - 32983, 32985, 32986, 32987, 32988, 32989, 32990, 32991, 32992, 32993, - 32994, 32996, 32997, 32998, 32999, 33000, 33001, 33002, 33003, 33004, - 33005, 33007, 33008, 33009, 33010, 33011, 33012, 33013, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 24159, 24158, 28846, 28425, 28847, 28878, - 11899, 12473, 11897, 11910, 11903, 11902, 3, 2, 349, 3591, 2657, 5360, - 6392, 15569, 15599, 29277, 19184, 23877, 11900, 20033, 24233, 11908, - 19186, 33428, 33535, 12629, 12779, 6165, 7796, 27140, 19800, 28222, - 27141, 19799, 27174, 9661, 10649, 9946, 9662, 9945, 9663, 9944, 9664, - 9942, 9665, 23745, 23663, 29182, 29181, 11898, 12472, 6095, 5368, 11896, - 11909, 11863, 28909, 28879, 11945, 11944, 15857, 12570, 12777, 15858, - 13818, 14124, 15859, 26099, 26678, 15860, 32332, 32538, 28427, 9677, - 9674, 25194, 25193, 15436, 15598, 5029, 5359, 24050, 23665, 15784, 15783, - 23979, 23984, 28843, 28831, 11895, 11948, 6394, 15571, 15601, 6393, - 15570, 15600, 19187, 33429, 33536, 25517, 25516, 25896, 25518, 25519, - 25876, 26179, 26186, 26214, 27986, 27987, 28829, 27985, 27988, 28830, - 9943, 9666, 25985, 25986, 26034, 25984, 25987, 26035, 26973, 28877, 6096, - 9646, 22108, 23489, 28842, 28845, 28428, 11894, 11892, 12511, 28844, - 28426, 27980, 29274, 27979, 26868, 7590, 9645, 28868, 28832, 24851, - 25073, 25983, 26036, 1056, 1063, 23664, 27173, 17580, 18203, 9644, 2354, - 363, 29260, 16383, 17255, 17256, 17298, 17264, 31621, 14524, 14525, - 14502, 14523, 12773, 12774, 12775, 23487, 12776, 28934, 35534, 35533, - 35535, 20029, 26481, 20027, 26479, 25592, 20030, 26482, 24232, 23488, - 33960, 20028, 26480, 12778, 25593, 33727, 22270, 22271, 18936, 26437, - 34470, 23275, 33096, 33207, 33275, 33286, 33297, 33308, 33319, 33330, - 33341, 33097, 33108, 33119, 33130, 33141, 33152, 33163, 25952, 5358, - 4651, 35532, 8760, 8759, 8455, 2872, 2982, 2973, 3080, 3281, 21565, - 21563, 21623, 21621, 15349, 5195, 21943, 21946, 33174, 33185, 33196, - 33208, 33219, 33230, 33241, 33252, 33263, 33271, 33272, 33273, 33274, - 33276, 33277, 33278, 33279, 33280, 33281, 33282, 33283, 33284, 33285, - 33287, 33288, 33289, 33290, 33291, 33292, 33293, 33294, 33295, 33296, - 33298, 33299, 33300, 33301, 33302, 33303, 33304, 33305, 33306, 33307, - 33309, 33310, 33311, 33312, 33313, 33314, 33315, 33316, 33317, 33318, - 33320, 33321, 33322, 33323, 33324, 33325, 33326, 33327, 33328, 33329, - 33331, 33332, 33333, 33334, 33335, 33336, 33337, 33338, 33339, 33340, - 33342, 33343, 33344, 33345, 33346, 33347, 33348, 33349, 33350, 33351, - 33098, 33099, 33100, 33101, 33102, 33103, 33104, 33105, 33106, 33107, - 33109, 33110, 33111, 33112, 33113, 33114, 33115, 33116, 33117, 33118, - 33120, 33121, 33122, 33123, 33124, 33125, 33126, 33127, 33128, 33129, - 33131, 33132, 33133, 33134, 33135, 33136, 33137, 33138, 33139, 33140, - 33142, 33143, 33144, 33145, 33146, 33147, 33148, 33149, 33150, 33151, - 33153, 33154, 33155, 33156, 33157, 33158, 33159, 33160, 33161, 33162, - 33164, 33165, 33166, 33167, 33168, 33169, 33170, 33171, 33172, 33173, - 33175, 33176, 33177, 33178, 33179, 33180, 33181, 33182, 33183, 33184, - 33186, 33187, 33188, 33189, 33190, 33191, 33192, 33193, 33194, 33195, - 33197, 33198, 33199, 33200, 33201, 33202, 33203, 33204, 33205, 33206, - 33209, 33210, 33211, 33212, 33213, 33214, 33215, 33216, 33217, 33218, - 33220, 33221, 33222, 33223, 33224, 33225, 33226, 33227, 33228, 33229, - 33231, 33232, 33233, 33234, 33235, 33236, 33237, 33238, 33239, 33240, - 33242, 33243, 33244, 33245, 33246, 33247, 33248, 33249, 33250, 33251, - 33253, 33254, 33255, 33256, 33257, 33258, 33259, 33260, 33261, 33262, - 33264, 33265, 33266, 33267, 33268, 33269, 33270, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 16768, 16769, - 16776, 16778, 16775, 16774, 16771, 16770, 16773, 16772, 16779, 16777, - 17443, 18009, 17604, 18234, 17844, 18608, 17539, 18144, 17540, 18145, - 17541, 18146, 17715, 18385, 17716, 18386, 17717, 18387, 17783, 18484, - 17523, 18127, 17519, 18123, 18229, 18353, 17453, 18019, 17454, 18020, - 17544, 18150, 17545, 18151, 17529, 18133, 17530, 18134, 18228, 18230, - 17609, 18236, 17610, 18237, 17627, 18264, 17657, 18304, 17665, 18326, - 17755, 18444, 17848, 18612, 17849, 18613, 17845, 18609, 17846, 18610, - 18028, 18402, 18403, 18563, 18564, 18493, 18494, 18218, 18219, 2324, - 2327, 2325, 2329, 2331, 2328, 2330, 2326, 2332, 9875, 9870, 9869, 9876, - 9871, 9872, 9874, 9873, 3664, 3663, 3665, 14032, 14031, 14030, 14029, - 14034, 14033, 24925, 24924, 3609, 29778, 29786, 29795, 29787, 29789, - 29784, 29788, 29783, 29799, 29798, 29801, 29793, 29780, 29800, 29782, - 29781, 29794, 29785, 29797, 29791, 29792, 29790, 29796, 29779, 29917, - 29924, 29925, 29920, 29921, 29926, 29927, 29918, 29922, 29923, 29919, - 29983, 29990, 29991, 29986, 29987, 29992, 29993, 29984, 29988, 29989, - 29985, 30094, 30101, 30102, 30097, 30098, 30103, 30104, 30095, 30099, - 30100, 30096, 29994, 30001, 30002, 29997, 29998, 30003, 30004, 29995, - 29999, 30000, 29996, 30072, 30079, 30080, 30075, 30076, 30081, 30082, - 30073, 30077, 30078, 30074, 29972, 29979, 29980, 29975, 29976, 29981, - 29982, 29973, 29977, 29978, 29974, 30083, 30090, 30091, 30086, 30087, - 30092, 30093, 30084, 30088, 30089, 30085, 30005, 30012, 30013, 30008, - 30009, 30014, 30015, 30006, 30010, 30011, 30007, 30138, 30145, 30146, - 30141, 30142, 30147, 30148, 30139, 30143, 30144, 30140, 30127, 30134, - 30135, 30130, 30131, 30136, 30137, 30128, 30132, 30133, 30129, 30160, - 30167, 30168, 30163, 30164, 30169, 30170, 30161, 30165, 30166, 30162, - 30027, 30034, 30035, 30030, 30031, 30036, 30037, 30028, 30032, 30033, - 30029, 29950, 29957, 29958, 29953, 29954, 29959, 29960, 29951, 29955, - 29956, 29952, 30149, 30156, 30157, 30152, 30153, 30158, 30159, 30150, - 30154, 30155, 30151, 29928, 29935, 29936, 29931, 29932, 29937, 29938, - 29929, 29933, 29934, 29930, 29939, 29946, 29947, 29942, 29943, 29948, - 29949, 29940, 29944, 29945, 29941, 30016, 30023, 30024, 30019, 30020, - 30025, 30026, 30017, 30021, 30022, 30018, 29961, 29968, 29969, 29964, - 29965, 29970, 29971, 29962, 29966, 29967, 29963, 30116, 30123, 30124, - 30119, 30120, 30125, 30126, 30117, 30121, 30122, 30118, 30038, 30046, - 30047, 30041, 30042, 30048, 30049, 30039, 30043, 30044, 30040, 30050, - 30057, 30058, 30053, 30054, 30059, 30060, 30051, 30055, 30056, 30052, - 30061, 30068, 30069, 30064, 30065, 30070, 30071, 30062, 30066, 30067, - 30063, 30105, 30112, 30113, 30108, 30109, 30114, 30115, 30106, 30110, - 30111, 30107, 29905, 29906, 29913, 29914, 29909, 29910, 29915, 29916, - 29907, 29911, 29912, 29908, 30045, 28011, 28009, 28010, 12955, 16861, - 16859, 16862, 16860, 16851, 16857, 16855, 16858, 16856, 16852, 16872, - 16868, 16873, 16869, 16853, 16870, 16866, 16871, 16867, 16854, 16883, - 16863, 16865, 16864, 16879, 16882, 16880, 16875, 16881, 16876, 16877, - 16878, 16884, 16874, 17023, 16900, 16901, 16902, 16899, 17018, 17010, - 15466, 15468, 15470, 15467, 15469, 16473, 16475, 16477, 16474, 16476, - 16466, 16465, 16464, 16467, 22480, 22485, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, 35536, - 35536, 35536, 35536, 35536, 35536, 35536, 35536, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 29178, 12867, 26790, 24879, 10591, 26360, 374, 1058, 19405, + 27016, 2613, 26612, 7630, 16004, 13051, 29017, 10374, 10359, 10371, + 10368, 10353, 10350, 10365, 10362, 10377, 10356, 7197, 27632, 19673, + 12302, 13682, 26788, 7627, 17881, 17928, 17943, 17961, 17978, 18024, + 18028, 18045, 18059, 18088, 18093, 18105, 18125, 18134, 18150, 18201, + 18214, 18217, 18241, 18267, 18297, 18338, 18349, 18358, 18361, 18375, + 19367, 26915, 27031, 6974, 20447, 13653, 18473, 18523, 18559, 18587, + 18630, 18691, 18699, 18719, 18740, 18779, 18785, 18799, 18841, 18854, + 18878, 18939, 18956, 18963, 19008, 19055, 19137, 19187, 19202, 19212, + 19220, 19237, 19307, 34163, 26978, 32563, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 24873, + 16367, 6281, 26654, 9451, 34740, 5085, 27615, 10341, 7824, 12947, 19416, + 24853, 28968, 26838, 22136, 10055, 26624, 29807, 29806, 4, 22871, 26509, + 22877, 6277, 29810, 21102, 27078, 34297, 34295, 34303, 16366, 17912, + 17913, 17890, 17883, 17901, 17903, 17916, 17944, 18011, 18012, 17983, + 17998, 18075, 18076, 18065, 18063, 18021, 18148, 18190, 18191, 18157, + 18183, 18165, 23644, 18181, 18330, 18331, 18298, 18301, 18370, 18289, + 19040, 18504, 18505, 18480, 18507, 18491, 18493, 18510, 18560, 18663, + 18664, 18633, 18648, 18758, 18759, 18741, 18743, 18682, 18873, 18918, + 18919, 18879, 18911, 18887, 10502, 18909, 19174, 19177, 19140, 19143, + 19232, 19079, 19222, 17906, 18498, 17884, 18474, 17909, 18501, 17948, + 18569, 17946, 18562, 17952, 18573, 17947, 18564, 17968, 18598, 17965, + 18592, 18001, 18652, 17980, 18666, 17993, 18643, 18008, 18660, 17992, + 18642, 18030, 18701, 18033, 18706, 18037, 18711, 18029, 18700, 18048, + 18722, 18055, 18728, 18069, 18755, 18067, 18750, 18078, 18761, 18072, + 18752, 18062, 18617, 18387, 19259, 18089, 18780, 18094, 18786, 18798, + 18117, 18816, 18113, 18803, 18115, 18806, 18110, 18813, 18112, 18824, + 18143, 18866, 18135, 18855, 18137, 18859, 18874, 18023, 18671, 18153, + 18904, 18193, 18921, 18171, 18893, 18388, 19261, 18228, 18984, 18222, + 18966, 18223, 18968, 18247, 19009, 18246, 19015, 18244, 19013, 18242, + 19011, 18268, 19056, 18271, 19060, 18278, 19072, 18327, 19171, 18318, + 19160, 18333, 19179, 18334, 19170, 18308, 19150, 18324, 19166, 18350, + 19203, 18363, 19221, 18364, 18378, 19238, 18381, 19244, 18377, 19241, + 18831, 18532, 17934, 17929, 18524, 18292, 19084, 18196, 17950, 18571, + 17920, 17973, 17969, 18593, 19093, 18237, 18261, 18195, 18025, 18694, + 18036, 18043, 18739, 18086, 18079, 18104, 18797, 18802, 18826, 18286, + 18141, 18861, 18156, 18172, 18894, 18198, 18923, 18207, 18947, 18470, + 18294, 19086, 18022, 18407, 19070, 18277, 19068, 18276, 18312, 19154, + 18337, 18342, 18368, 19226, 18384, 19247, 18015, 18017, 18685, 18690, + 18468, 18293, 19085, 18406, 18463, 18466, 18467, 18396, 18409, 17975, + 17963, 18623, 18124, 18111, 18840, 18149, 18138, 18877, 17896, 18486, + 18066, 18742, 18164, 18886, 18300, 19142, 18305, 19147, 18304, 19146, + 18302, 19144, 18303, 19145, 19127, 17902, 18492, 17898, 18488, 17918, + 18513, 18038, 18703, 18031, 18702, 18095, 18787, 18179, 18907, 18180, + 18908, 18016, 18687, 18782, 17974, 17962, 18622, 18032, 18705, 18057, + 18357, 18142, 18865, 17904, 18494, 17917, 18512, 18182, 18910, 17900, + 18490, 17914, 18506, 17997, 18647, 18013, 18665, 18060, 18749, 18077, + 18760, 18170, 18892, 18192, 18920, 18227, 18972, 18229, 18985, 18307, + 19149, 18332, 19178, 18245, 19014, 18270, 19058, 18374, 19236, 18049, + 18723, 18140, 18597, 18200, 18925, 18386, 19251, 17897, 18487, 17981, + 18631, 18166, 18888, 18186, 18914, 18167, 18889, 18168, 18890, 18371, + 19233, 18805, 18858, 19059, 18614, 18628, 18962, 17915, 17953, 18574, + 18120, 18272, 19022, 19246, 18039, 18714, 17935, 18336, 18288, 18014, + 18668, 18092, 18784, 18262, 18959, 18231, 18988, 18373, 19231, 19116, + 18515, 19117, 18531, 18928, 18563, 18594, 18588, 18998, 19031, 19035, + 18934, 18991, 18993, 18583, 18615, 18710, 19036, 18417, 18712, 19007, + 19119, 18732, 18738, 18762, 18774, 18420, 18811, 18800, 18819, 18827, + 19122, 19123, 18849, 18862, 18871, 18451, 18535, 18428, 18580, 18950, + 19102, 19105, 19109, 18977, 18979, 18973, 18997, 18430, 18421, 19028, + 18674, 18616, 19054, 18677, 19111, 19071, 19138, 19181, 19190, 19113, + 19131, 19124, 18458, 19250, 19240, 18684, 18686, 18401, 18464, 18404, + 18460, 18399, 18411, 18582, 18419, 18447, 18781, 19129, 18423, 18958, + 18403, 18408, 18624, 18609, 18625, 19089, 19073, 19134, 18697, 18838, + 18839, 18398, 18400, 19120, 19121, 23225, 23227, 23237, 23270, 23311, + 23315, 23168, 23337, 23339, 23135, 23077, 23347, 22987, 23143, 23145, + 23121, 23093, 23141, 23123, 23147, 23349, 23079, 23069, 6209, 23353, + 23124, 22986, 23092, 23119, 23110, 23116, 23115, 23346, 23101, 23021, + 23020, 23348, 23078, 23134, 23132, 5078, 10697, 27211, 25013, 28926, + 10757, 23148, 23070, 23224, 23240, 23279, 23338, 23275, 23084, 23099, + 23128, 23113, 23089, 23355, 23354, 23352, 23350, 23076, 23106, 23118, + 23108, 23111, 23112, 23131, 23130, 23129, 23114, 23140, 22989, 23090, + 22990, 23091, 23150, 23133, 23107, 7420, 7204, 7289, 7596, 7531, 7554, + 7214, 7315, 7311, 7435, 7580, 7324, 7220, 7612, 7352, 7328, 7223, 7438, + 7604, 7226, 7562, 7227, 7421, 7205, 7515, 7575, 7505, 7437, 7512, 7605, + 7355, 7559, 7542, 7558, 7563, 7318, 7312, 7579, 7228, 7291, 7552, 7611, + 7217, 7442, 7222, 7290, 7216, 7439, 7600, 7536, 7530, 7353, 7599, 7584, + 7528, 7583, 7527, 7570, 7440, 7588, 7593, 7625, 7613, 7340, 7422, 7206, + 7432, 7431, 7434, 7433, 7218, 7365, 7351, 7504, 7545, 7436, 7213, 7517, + 7607, 7427, 7566, 7513, 7369, 7624, 7506, 7567, 7565, 7571, 7317, 7210, + 7346, 7582, 7331, 7330, 7337, 7338, 7347, 7332, 7344, 7455, 7463, 7468, + 7476, 7479, 7461, 7493, 7495, 7497, 7482, 7485, 7500, 7501, 13867, 14131, + 13762, 13998, 13949, 13945, 13856, 14113, 36293, 36293, 14188, 14138, + 14139, 14137, 14193, 13870, 36293, 36293, 36293, 36293, 14153, 13883, + 13760, 13736, 13793, 13783, 13807, 36293, 13839, 36293, 13854, 13829, + 14045, 13739, 13866, 13864, 13862, 13784, 13868, 13763, 13860, 13794, + 13863, 13869, 13871, 13872, 13873, 13830, 13859, 13840, 36293, 13842, + 13861, 13845, 13857, 13865, 13858, 13809, 13799, 13850, 13995, 14010, + 14035, 14054, 14065, 13970, 14130, 14128, 14000, 14001, 14132, 14011, + 14125, 14036, 14076, 14133, 14134, 14135, 14136, 14103, 14116, 14117, + 14127, 14123, 14126, 14056, 14114, 14129, 14115, 14078, 14041, 14061, + 14112, 14074, 14102, 13879, 14190, 14149, 14157, 14155, 14156, 13965, + 13966, 13930, 13941, 13997, 13940, 14122, 13943, 13999, 13942, 14077, + 13939, 14120, 7705, 7799, 7683, 7777, 7679, 7773, 7677, 7771, 7675, 7769, + 7704, 7798, 7674, 7768, 13929, 13968, 13946, 13944, 13878, 13947, 13969, + 13844, 14124, 13874, 13843, 14121, 13967, 13876, 13877, 13875, 9719, + 9721, 9668, 9707, 9643, 9672, 9659, 9778, 9791, 9614, 9617, 9631, 9746, + 9716, 9759, 9676, 9644, 9660, 9792, 9701, 9680, 9718, 9785, 9781, 9714, + 9757, 9731, 9682, 9698, 9687, 9750, 9618, 9693, 9696, 9628, 9638, 9700, + 9708, 9634, 9661, 9764, 9762, 9712, 9775, 9767, 9681, 9780, 9772, 9803, + 9819, 9993, 9860, 9839, 9877, 9986, 9982, 9873, 9935, 9890, 9841, 9857, + 9846, 9916, 9921, 9852, 9855, 9953, 9964, 9859, 9867, 9959, 9820, 9942, + 9940, 9871, 9976, 9945, 9840, 9981, 9973, 9878, 9880, 9827, 9866, 9969, + 9831, 9818, 9979, 9992, 9909, 9915, 9956, 9905, 9875, 9937, 9835, 9751, + 9917, 9774, 9975, 9727, 9886, 9613, 9907, 9723, 9882, 9656, 9815, 9724, + 9883, 9747, 9906, 9621, 9925, 9790, 9991, 9729, 9888, 9730, 9889, 9642, + 9968, 9626, 9930, 9752, 9918, 9754, 9920, 9744, 9903, 10024, 7282, 7276, + 7279, 7277, 7278, 7232, 7285, 9758, 9936, 9771, 9949, 9694, 9853, 9703, + 9862, 9705, 9864, 9702, 9861, 9787, 9988, 9783, 9984, 9732, 9891, 9734, + 9893, 9735, 9894, 9654, 9813, 9689, 9848, 9797, 9997, 9619, 9922, 9650, + 9809, 9697, 9856, 9630, 9955, 9769, 9947, 9770, 9948, 9709, 9868, 9796, + 9996, 9663, 9822, 9664, 9823, 9760, 9938, 9647, 9806, 9648, 9807, 9800, + 9788, 9989, 9733, 9892, 9685, 9844, 9692, 9851, 9691, 9850, 9745, 9904, + 9699, 9858, 9924, 9646, 9805, 9645, 9804, 9795, 9995, 9720, 9879, 9755, + 9933, 9756, 9934, 9786, 9987, 9782, 9983, 9649, 9808, 9717, 9876, 9715, + 9874, 9753, 9919, 9652, 9811, 9653, 9812, 9695, 9854, 9641, 9967, 9640, + 9966, 9639, 9965, 9662, 9821, 9704, 9863, 9776, 9977, 9706, 9865, 9710, + 9869, 9711, 9870, 9738, 9897, 9737, 9896, 9743, 9902, 9736, 9895, 9739, + 9898, 9740, 9899, 9741, 9900, 9742, 9901, 9625, 9929, 9686, 9845, 9615, + 9910, 9627, 9932, 9773, 9974, 9794, 9994, 9793, 9972, 9651, 9810, 9683, + 9842, 9688, 9847, 9620, 9923, 9761, 9939, 9690, 9849, 9674, 9833, 9678, + 9837, 9684, 9843, 36293, 2531, 2538, 2522, 2544, 2518, 2542, 2519, 2520, + 2509, 2541, 2537, 2534, 2536, 2514, 2526, 2543, 2524, 2521, 2512, 2539, + 2510, 2540, 2529, 2533, 2513, 2528, 2523, 2517, 2530, 2532, 2508, 2516, + 2515, 2511, 2527, 2525, 2545, 2535, 36293, 22985, 2595, 2507, 2547, 2548, + 2546, 2599, 2506, 2568, 2571, 2581, 2559, 2587, 2555, 2585, 2556, 2557, + 2570, 2584, 2580, 2577, 2579, 2551, 2563, 2586, 2561, 2558, 2549, 2582, + 2574, 2583, 2566, 2573, 2550, 2565, 2560, 2554, 2567, 2572, 2569, 2553, + 2552, 2576, 2564, 2562, 2588, 2578, 2589, 2575, 2598, 2596, 22983, 22984, + 27065, 19429, 2597, 36293, 15341, 15344, 15345, 15352, 15353, 15349, + 15356, 15354, 15339, 15351, 15348, 15332, 15333, 15334, 15342, 15346, + 15340, 15329, 15337, 15338, 15335, 15336, 15331, 15343, 15347, 15350, + 15357, 15358, 15330, 15355, 15436, 15451, 15441, 15439, 15440, 15442, + 15455, 15450, 15445, 15446, 15443, 15444, 15448, 15437, 15457, 15463, + 15449, 15460, 15453, 15454, 15461, 15435, 15434, 15462, 15447, 15452, + 15438, 36293, 36293, 36293, 36293, 36293, 36293, 15359, 15366, 15409, + 15407, 15384, 15415, 15389, 15386, 15401, 15426, 15375, 15369, 15411, + 15381, 15413, 15380, 15387, 15391, 15365, 15377, 15372, 15379, 15405, + 15382, 15399, 15393, 15403, 36293, 36293, 36293, 36293, 15464, 15430, + 15433, 15431, 15459, 15458, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 2337, 2371, 1127, 2372, 2373, 2336, + 2495, 2494, 2348, 2492, 2493, 2687, 1071, 1106, 2343, 2377, 2370, 2376, + 2368, 2369, 2378, 2399, 2387, 2419, 2382, 2441, 2440, 2364, 1415, 1115, + 2482, 2490, 1370, 1322, 1185, 1175, 1605, 1178, 1621, 1157, 1199, 1547, + 1546, 1569, 1348, 1307, 1389, 1224, 1564, 1468, 1648, 1502, 1515, 1494, + 1240, 1524, 1643, 1147, 1294, 1376, 1373, 1269, 1268, 1267, 2470, 1274, + 1459, 1359, 1394, 1407, 1431, 1324, 1600, 1193, 1612, 1123, 1104, 1136, + 1117, 1100, 1132, 2365, 2446, 2187, 1131, 1130, 2445, 2354, 2188, 2491, + 2486, 2485, 2487, 2349, 1118, 2489, 2502, 2504, 2501, 2500, 2497, 2496, + 2499, 2498, 2505, 2503, 2341, 1111, 2484, 1126, 1252, 1254, 1521, 1190, + 1182, 1181, 1344, 1345, 1347, 1586, 1346, 1574, 1580, 1219, 1555, 1554, + 1447, 1559, 1214, 1317, 1315, 1426, 1255, 1314, 1534, 1541, 1249, 1234, + 1231, 1232, 1237, 1246, 1260, 1227, 1233, 1485, 1471, 1482, 1480, 1472, + 1481, 1475, 1356, 1478, 1503, 1506, 1507, 1497, 1496, 1528, 1150, 1253, + 1277, 1275, 1593, 1279, 1454, 1462, 1463, 1371, 1523, 1365, 1364, 1416, + 1362, 1285, 1288, 1417, 1287, 1301, 1286, 1398, 1396, 1400, 1399, 1442, + 1432, 1488, 1440, 1437, 1335, 1536, 1332, 1325, 1326, 1550, 1609, 1383, + 1640, 1585, 1637, 1386, 1608, 1592, 1263, 1631, 1626, 1602, 1652, 1630, + 1613, 1616, 1128, 1198, 2390, 2389, 2392, 2391, 2421, 2398, 2396, 1116, + 2469, 2418, 2417, 2383, 2393, 2439, 2394, 2443, 2424, 2411, 2413, 2345, + 1114, 1113, 2353, 2438, 1226, 1476, 12887, 12889, 12886, 12885, 12882, + 12881, 12884, 12883, 12890, 12888, 1516, 1241, 1296, 2375, 2374, 1331, + 29937, 30011, 30008, 30009, 30005, 29946, 29933, 29934, 30010, 30007, + 29932, 29942, 29941, 29940, 36293, 29930, 29978, 29974, 29988, 29984, + 29985, 29948, 29947, 29949, 29991, 29989, 29950, 29981, 29982, 29986, + 29987, 29979, 29951, 29963, 29990, 29970, 29977, 29992, 29964, 29968, + 29976, 29980, 29969, 29975, 29983, 29965, 29967, 29966, 29997, 29996, + 29995, 30000, 29999, 29998, 30002, 30001, 29936, 29935, 29945, 29944, + 29943, 29939, 29938, 30003, 30017, 30018, 30004, 30015, 30014, 30013, + 30012, 29994, 29993, 30016, 29931, 36293, 36293, 29971, 29972, 29973, + 1205, 1208, 1203, 1204, 1206, 1207, 1201, 1316, 1313, 1230, 1225, 1473, + 1509, 1152, 1148, 1151, 1280, 1278, 1378, 1374, 1372, 1410, 1409, 1438, + 1435, 1436, 1401, 1474, 1477, 1508, 1312, 1310, 1505, 1469, 1311, 1184, + 1183, 1266, 1265, 1264, 1604, 1603, 1615, 1614, 1308, 1510, 1504, 1361, + 32131, 32144, 32140, 32157, 32156, 32135, 32132, 32120, 32151, 32136, + 32125, 32124, 32147, 32134, 32127, 32128, 32145, 32123, 32153, 32146, + 32158, 32139, 32138, 32137, 32149, 32130, 32133, 32148, 32154, 32143, + 32142, 32122, 32150, 32155, 32121, 32129, 32126, 32152, 32116, 32115, + 32162, 32118, 32163, 32161, 32117, 32119, 32160, 32159, 32164, 32141, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 24737, 24739, 24736, 24735, 24732, 24731, + 24734, 24733, 24740, 24738, 24772, 24759, 24773, 24758, 24774, 24756, + 24755, 24743, 24748, 24761, 24767, 24769, 24747, 24757, 24742, 24754, + 24753, 24768, 24760, 24762, 24764, 24765, 24750, 24766, 24751, 24749, + 24763, 24770, 24771, 24752, 24745, 24744, 24746, 24724, 24725, 24726, + 24722, 24719, 24720, 24721, 24723, 24727, 24776, 24775, 24778, 24777, + 24728, 24780, 24741, 36293, 36293, 24729, 24730, 24779, 27439, 27426, + 27440, 27428, 27431, 27427, 27442, 27430, 27437, 27446, 27432, 27433, + 27443, 27445, 27434, 27429, 27447, 27438, 27444, 27441, 27435, 27436, + 27449, 27450, 27453, 27448, 27454, 27451, 27473, 27483, 27478, 27472, + 27482, 27477, 27471, 27481, 27455, 27479, 27475, 27485, 27456, 27474, + 27484, 27476, 27480, 27452, 36293, 36293, 27463, 27457, 27459, 27462, + 27460, 27464, 27486, 27469, 27467, 27470, 27466, 27468, 27461, 27465, + 27458, 36293, 20891, 20878, 20880, 20879, 20881, 20890, 20888, 20893, + 20873, 20871, 20870, 20882, 20883, 20884, 20874, 20892, 20885, 20876, + 20886, 20887, 20875, 20872, 20889, 20894, 20877, 20869, 20895, 20896, + 36293, 36293, 20897, 36293, 29956, 29961, 29957, 29959, 29955, 29954, + 29958, 29962, 29953, 29952, 29960, 36293, 36293, 36293, 36293, 36293, + 1171, 1161, 1172, 1188, 1170, 1158, 1167, 1164, 1168, 1166, 1189, 1163, + 1174, 1160, 1162, 1173, 1159, 1165, 1169, 2471, 2472, 2474, 1567, 1068, + 2347, 1439, 1309, 1529, 1527, 1375, 2488, 1441, 2344, 2346, 36293, 36293, + 36293, 36293, 36293, 2342, 2400, 2432, 2431, 2434, 2186, 2450, 1110, + 1129, 1202, 1209, 1349, 1526, 1276, 1460, 1395, 1408, 1627, 1629, 1479, + 1601, 1493, 1406, 1228, 1495, 1289, 1522, 1651, 1149, 1363, 1461, 1200, + 1448, 1552, 1470, 1628, 1145, 1143, 1146, 1449, 1553, 1575, 1535, 1377, + 1295, 1144, 1351, 1350, 1397, 1306, 2381, 2384, 2412, 2406, 2420, 1140, + 1139, 2449, 1141, 1138, 2437, 2401, 2397, 2423, 2422, 2414, 2427, 2402, + 2404, 2403, 2405, 2409, 2408, 2385, 2395, 1112, 2483, 1096, 1094, 1098, + 1097, 1095, 1099, 2477, 2479, 2481, 2476, 2478, 2480, 2340, 2339, 2338, + 2410, 1120, 1119, 1133, 1658, 2350, 1657, 2352, 1107, 1108, 2351, 1103, + 2189, 10275, 10265, 10279, 10284, 10200, 10173, 10175, 10244, 10245, + 10220, 10221, 10239, 10241, 10182, 10201, 10252, 10176, 10183, 10202, + 10215, 10177, 10211, 10210, 10195, 10193, 10226, 10180, 10184, 10231, + 10229, 10227, 10236, 10235, 10188, 10187, 10225, 10238, 10237, 10190, + 10189, 10228, 10224, 10247, 10246, 10208, 10207, 10198, 10219, 10214, + 10213, 10234, 10233, 10232, 10243, 10203, 10204, 10205, 10197, 10297, + 10296, 10277, 10278, 10287, 10309, 10310, 10299, 10300, 10305, 10306, + 10293, 10303, 10311, 10288, 10294, 10304, 10295, 10289, 10283, 10298, + 10290, 10325, 10286, 10285, 10168, 10165, 10292, 10302, 10301, 10251, + 10209, 10192, 10249, 10185, 10212, 10250, 10218, 10240, 10242, 10307, + 10308, 10313, 10312, 10320, 10322, 10319, 10318, 10315, 10314, 10317, + 10316, 10323, 10321, 10166, 10282, 10181, 10217, 10216, 10178, 10223, + 10222, 10199, 10248, 10196, 10194, 10230, 10191, 10186, 10206, 3642, + 3711, 3714, 3716, 36293, 3650, 3652, 3681, 3682, 3679, 3680, 3665, 3667, + 36293, 36293, 3703, 3653, 36293, 36293, 3704, 3654, 3658, 3655, 3695, + 3694, 3683, 3693, 3692, 3697, 3696, 3685, 3676, 3675, 3672, 3671, 3684, + 3678, 3677, 3674, 3673, 3686, 36293, 3699, 3698, 3691, 3690, 3702, 3670, + 3659, 36293, 3701, 36293, 36293, 36293, 3687, 3688, 3689, 3700, 36293, + 36293, 3712, 3713, 3719, 3728, 3729, 3722, 3723, 3724, 3725, 36293, + 36293, 3730, 3720, 36293, 36293, 3731, 3721, 3715, 3656, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 3643, 36293, 36293, 36293, + 36293, 3663, 3662, 36293, 3669, 3666, 3668, 3726, 3727, 36293, 36293, + 3738, 3740, 3737, 3736, 3733, 3732, 3735, 3734, 3741, 3739, 3661, 3660, + 3706, 3705, 3644, 3648, 3647, 3646, 3645, 3649, 3718, 3742, 3664, 3641, + 3717, 36293, 36293, 14422, 14423, 14428, 36293, 14374, 14375, 14390, + 14391, 14388, 14389, 36293, 36293, 36293, 36293, 14409, 14376, 36293, + 36293, 14408, 14377, 14373, 14372, 14370, 14369, 14394, 14401, 14400, + 14403, 14402, 14396, 14385, 14384, 14379, 14378, 14395, 14387, 14386, + 14381, 14380, 14397, 36293, 14405, 14404, 14399, 14398, 14412, 14414, + 14383, 36293, 14393, 14392, 36293, 14413, 14406, 36293, 14407, 14411, + 36293, 36293, 14425, 36293, 14429, 14434, 14435, 14432, 14433, 36293, + 36293, 36293, 36293, 14437, 14430, 36293, 36293, 14436, 14431, 14427, + 36293, 36293, 36293, 14424, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 14371, 14368, 14415, 14382, 36293, 14410, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 14447, 14449, 14446, 14445, 14442, 14441, + 14444, 14443, 14450, 14448, 14438, 14367, 14439, 14451, 14440, 14426, + 14366, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 14262, 14270, 14272, 36293, 14212, 14213, 14231, 14232, 14229, + 14230, 14224, 14226, 14288, 36293, 14259, 14214, 14289, 36293, 14260, + 14215, 14252, 14251, 14248, 14247, 14236, 14246, 14245, 14250, 14249, + 14238, 14221, 14220, 14217, 14216, 14237, 14223, 14222, 14219, 14218, + 14239, 36293, 14254, 14253, 14244, 14243, 14256, 14258, 14257, 36293, + 14234, 14233, 36293, 14228, 14240, 14241, 14242, 14255, 36293, 36293, + 14268, 14269, 14275, 14284, 14285, 14278, 14279, 14280, 14281, 14273, + 36293, 14286, 14276, 14274, 36293, 14287, 14277, 14271, 36293, 36293, + 14302, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 14225, 14227, 14282, 14283, + 36293, 36293, 14298, 14300, 14297, 14296, 14293, 14292, 14295, 14294, + 14301, 14299, 14290, 14291, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 14235, 14267, 14266, 14263, 14265, 14261, 14264, 36293, 25661, + 25664, 25667, 36293, 25610, 25611, 25629, 25630, 25627, 25628, 25622, + 25624, 36293, 36293, 25655, 25612, 36293, 36293, 25656, 25613, 25649, + 25648, 25645, 25644, 25633, 25643, 25642, 25647, 25646, 25635, 25619, + 25618, 25615, 25614, 25634, 25621, 25620, 25617, 25616, 25636, 36293, + 25651, 25650, 25641, 25640, 25653, 25609, 25607, 36293, 25632, 25631, + 36293, 25626, 25637, 25638, 25639, 25652, 36293, 36293, 25662, 25663, + 25668, 25677, 25678, 25671, 25672, 25673, 25674, 36293, 36293, 25679, + 25669, 36293, 36293, 25680, 25670, 25666, 36293, 36293, 36293, 36293, + 36293, 25660, 25659, 25665, 25596, 25597, 36293, 36293, 36293, 36293, + 25606, 25605, 36293, 25608, 25623, 25625, 25675, 25676, 36293, 36293, + 25687, 25689, 25686, 25685, 25682, 25681, 25684, 25683, 25690, 25688, + 25604, 25654, 25601, 25600, 25603, 25598, 25599, 25602, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 30630, 30647, + 36293, 30593, 30594, 30606, 30607, 30602, 30603, 36293, 36293, 36293, + 30611, 30612, 30595, 36293, 30604, 30605, 30596, 30616, 36293, 36293, + 36293, 30588, 30613, 36293, 30615, 36293, 30589, 30591, 36293, 36293, + 36293, 30587, 30592, 36293, 36293, 36293, 30590, 30586, 30618, 36293, + 36293, 36293, 30617, 30620, 30601, 30600, 30599, 30598, 30597, 30619, + 30608, 30609, 30610, 30614, 36293, 36293, 36293, 36293, 30920, 30927, + 30928, 30923, 30924, 36293, 36293, 36293, 30929, 30930, 30921, 36293, + 30925, 30926, 30922, 30646, 36293, 36293, 30933, 36293, 36293, 36293, + 36293, 36293, 36293, 30522, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 30559, 30561, + 30558, 30557, 30554, 30553, 30556, 30555, 30562, 30560, 30624, 30622, + 30623, 30552, 30932, 30931, 30551, 30549, 30521, 30627, 30625, 36293, + 36293, 36293, 36293, 36293, 31996, 31997, 32002, 32004, 31995, 31956, + 31957, 31972, 31973, 31968, 31969, 31963, 31965, 36293, 31989, 31990, + 31958, 36293, 31970, 31971, 31959, 31986, 31985, 31982, 31981, 31945, + 31980, 31979, 31984, 31983, 31947, 31952, 31951, 31939, 31938, 31946, + 31955, 31953, 31942, 31940, 31943, 36293, 31988, 31987, 31978, 31977, + 31992, 31993, 31950, 31949, 31962, 31961, 31960, 31967, 31974, 31975, + 31976, 31991, 36293, 36293, 32000, 32001, 32005, 32016, 32017, 32008, + 32009, 32010, 32011, 36293, 32018, 32019, 32006, 36293, 32014, 32015, + 32007, 32003, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 31994, + 31930, 36293, 31954, 31941, 31948, 36293, 31929, 31944, 36293, 36293, + 31964, 31966, 32012, 32013, 36293, 36293, 32026, 32028, 32025, 32024, + 32021, 32020, 32023, 32022, 32029, 32027, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 31998, 31937, 31935, 31933, 31931, 31936, 31934, + 31932, 31999, 16876, 16875, 16880, 16884, 16877, 16824, 16825, 16850, + 16851, 16846, 16847, 16841, 16843, 36293, 16867, 16868, 16826, 36293, + 16848, 16849, 16827, 16864, 16863, 16860, 16859, 16821, 16858, 16857, + 16862, 16861, 16823, 16838, 16837, 16829, 16828, 16822, 16840, 16839, + 16831, 16830, 16819, 36293, 16866, 16865, 16856, 16855, 16871, 16872, + 16836, 16835, 16834, 16833, 36293, 16845, 16852, 16853, 16854, 16870, + 36293, 36293, 16878, 16879, 16887, 16898, 16899, 16890, 16891, 16892, + 16893, 36293, 16900, 16901, 16888, 36293, 16896, 16897, 16889, 16883, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 16873, 16886, 36293, + 36293, 36293, 36293, 36293, 16885, 16820, 16869, 36293, 16842, 16844, + 16894, 16895, 36293, 36293, 16908, 16910, 16907, 16906, 16903, 16902, + 16905, 16904, 16911, 16909, 36293, 16881, 16882, 16874, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 20831, 20833, 20838, 20836, 20788, 20762, 20764, 20808, 20809, 20804, + 20805, 20789, 20791, 36293, 20823, 20824, 20765, 36293, 20806, 20807, + 20766, 20820, 20819, 20816, 20815, 20796, 20777, 20776, 20818, 20817, + 20797, 20785, 20783, 20780, 20779, 20795, 20787, 20786, 20782, 20781, + 20798, 20794, 20822, 20821, 20814, 20813, 20826, 20827, 20803, 20802, + 20801, 20800, 20799, 20793, 20810, 20811, 20812, 20825, 20784, 20834, + 20832, 20837, 20840, 20851, 20852, 20843, 20844, 20845, 20846, 36293, + 20853, 20854, 20841, 36293, 20849, 20850, 20842, 20835, 20778, 20839, + 36293, 36293, 36293, 36293, 20774, 20775, 20769, 20855, 20754, 20752, + 20759, 20749, 20750, 20760, 20753, 20763, 20790, 20792, 20847, 20848, + 36293, 36293, 20745, 20747, 20744, 20743, 20740, 20739, 20742, 20741, + 20748, 20746, 20830, 20828, 20829, 20757, 20756, 20761, 20751, 20755, + 20758, 20738, 20771, 20770, 20772, 20767, 20768, 20773, 36293, 28826, + 28825, 28827, 36293, 28771, 28768, 28756, 28755, 28779, 28778, 28781, + 28780, 28777, 28776, 28775, 28774, 28773, 28772, 28769, 28800, 28799, + 28770, 36293, 36293, 36293, 28765, 28790, 28763, 28788, 28813, 28803, + 28762, 28787, 28764, 28789, 28810, 28811, 28804, 28757, 28782, 28759, + 28784, 28794, 28801, 28758, 28783, 28760, 28785, 28797, 36293, 28802, + 28766, 28791, 28761, 28786, 28792, 28767, 28809, 28807, 36293, 28796, + 36293, 36293, 28808, 28812, 28795, 28798, 28806, 28793, 28805, 36293, + 36293, 36293, 28824, 36293, 36293, 36293, 36293, 28844, 28836, 28831, + 28837, 28832, 28838, 36293, 28833, 36293, 28834, 28839, 28830, 28843, + 28840, 28841, 28842, 28835, 36293, 36293, 36293, 36293, 36293, 36293, + 28820, 28822, 28819, 28818, 28815, 28814, 28817, 28816, 28823, 28821, + 36293, 36293, 28828, 28829, 28845, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 32183, 32180, 32178, + 32177, 32179, 32181, 32197, 32166, 32168, 32167, 32226, 32169, 32238, + 32170, 32235, 32231, 32228, 32229, 32199, 32171, 32234, 32233, 32230, + 32232, 32200, 32165, 32206, 32203, 32172, 32204, 32173, 32205, 32195, + 32239, 32207, 32208, 32185, 32187, 32236, 32224, 32223, 32225, 32176, + 32184, 32240, 32175, 32201, 32209, 32189, 32212, 32214, 32219, 32220, + 32216, 32217, 32215, 32218, 32202, 36293, 36293, 36293, 36293, 32241, + 32221, 32213, 32222, 32211, 32210, 32186, 32194, 32193, 32192, 32190, + 32191, 32188, 32227, 32198, 32237, 32174, 32248, 32250, 32247, 32246, + 32243, 32242, 32245, 32244, 32251, 32249, 32196, 32182, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 17718, 17716, 36293, 17717, 36293, + 17731, 17746, 17750, 17730, 17740, 36293, 17732, 17747, 17728, 17726, + 17725, 17723, 17722, 17727, 17751, 17743, 17741, 17742, 17724, 17748, + 17749, 17736, 17734, 17713, 17735, 17712, 17729, 17752, 17755, 17720, + 36293, 17721, 36293, 17754, 17737, 17738, 17739, 17744, 17733, 17756, + 17745, 17782, 17764, 17769, 17765, 17767, 17777, 17778, 17771, 17772, + 17773, 17774, 17759, 17770, 17758, 17757, 36293, 36293, 17775, 17776, + 17779, 17768, 17766, 36293, 17780, 36293, 17763, 17760, 17761, 17762, + 17793, 17794, 17781, 36293, 17789, 17791, 17788, 17787, 17784, 17783, + 17786, 17785, 17792, 17790, 36293, 36293, 17709, 17708, 17715, 17714, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 32475, 32382, 32380, 32381, 32390, 32378, 32375, 32379, + 32399, 32370, 32368, 32391, 32406, 32400, 32396, 32403, 32395, 32398, + 32397, 32374, 32383, 32366, 32365, 32293, 32294, 32292, 32414, 32415, + 32416, 32418, 32419, 32417, 32315, 32317, 32314, 32313, 32310, 32309, + 32312, 32311, 32318, 32316, 32307, 32304, 32303, 32300, 32299, 32302, + 32301, 32308, 32306, 32305, 32371, 32393, 32373, 32392, 32376, 32402, + 32384, 32385, 32386, 32387, 32425, 32411, 32324, 32322, 32352, 32351, + 32334, 32350, 32349, 32359, 36293, 32336, 32344, 32343, 32329, 32328, + 32335, 32346, 32345, 32333, 32332, 32337, 32354, 32353, 32348, 32347, + 32361, 32342, 32341, 32331, 32330, 32362, 32355, 32356, 32357, 32363, + 32326, 32360, 32338, 32339, 32340, 32358, 32364, 32321, 32327, 32323, + 32325, 36293, 36293, 36293, 36293, 32499, 32495, 32496, 32487, 32488, + 32489, 32490, 32491, 32492, 32497, 32498, 32493, 32494, 32422, 32423, + 32485, 32486, 32413, 32427, 32388, 32405, 32409, 32424, 32410, 32412, + 32407, 32408, 32426, 32474, 32473, 32472, 32439, 32438, 32458, 32457, + 32440, 32456, 32455, 32465, 36293, 32442, 32450, 32449, 32432, 32431, + 32441, 32452, 32451, 32436, 32435, 32443, 32460, 32459, 32454, 32453, + 32467, 32448, 32447, 32434, 32433, 32469, 32461, 32462, 32463, 32470, + 32468, 32466, 32444, 32445, 32446, 32464, 32471, 32437, 32429, 32430, + 32428, 36293, 32319, 32320, 32296, 32297, 32298, 32295, 32476, 32483, + 32481, 32484, 32482, 32477, 32480, 32479, 32478, 36293, 32421, 32420, + 32369, 32372, 32394, 32389, 32377, 27070, 19434, 27071, 19435, 32404, + 32401, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 24012, 23991, + 23990, 23989, 24021, 24089, 24088, 24091, 24090, 24022, 24019, 24067, + 24066, 24073, 24072, 24020, 24051, 24068, 24075, 24074, 24023, 24093, + 24092, 24087, 24086, 24018, 24095, 24025, 24085, 24071, 24050, 24094, + 24084, 23981, 24045, 24082, 24083, 24076, 24077, 23984, 24017, 24096, + 23983, 24188, 24172, 24195, 24196, 24189, 24190, 24184, 24169, 24177, + 24178, 24185, 24113, 24132, 24137, 24136, 24112, 23976, 23974, 23975, + 23973, 23988, 24213, 24215, 24212, 24211, 24208, 24207, 24210, 24209, + 24216, 24214, 24135, 24124, 24142, 24146, 24141, 24145, 24026, 24049, + 24078, 24079, 24080, 24081, 24191, 24192, 24193, 24194, 24016, 24015, + 24013, 24014, 23979, 23978, 23977, 24048, 24183, 24157, 24158, 24070, + 24069, 24186, 24187, 24127, 24128, 24129, 24130, 24131, 23987, 23986, + 23985, 24173, 24175, 24176, 24174, 24040, 24039, 24038, 24036, 24044, + 24028, 24041, 24029, 24031, 24042, 24034, 24032, 24043, 23980, 24182, + 24179, 24180, 24181, 24119, 24120, 24121, 24122, 24117, 24118, 24116, + 24024, 24133, 24108, 24110, 24107, 24106, 24103, 24102, 24105, 24104, + 24111, 24109, 24114, 24115, 24170, 24171, 24144, 24143, 13263, 13289, + 13274, 13295, 13296, 13294, 13284, 13285, 13297, 13278, 13287, 13290, + 13292, 13298, 13280, 13283, 13288, 13282, 13286, 13299, 13279, 13277, + 13273, 13293, 13281, 13269, 13272, 13276, 13271, 13270, 13291, 13275, + 13264, 13268, 13266, 13301, 13265, 13267, 36293, 13300, 36293, 36293, + 36293, 36293, 36293, 13262, 36293, 36293, 13346, 13377, 13354, 13383, + 13352, 13382, 13375, 13372, 13384, 13364, 13366, 13378, 13380, 13385, + 13368, 13374, 13376, 13370, 13373, 13343, 13367, 13363, 13353, 13381, + 13369, 13347, 13350, 13362, 13349, 13348, 13379, 13361, 13357, 13360, + 13358, 13387, 13355, 13359, 13388, 13386, 13351, 13371, 13345, 13435, + 23095, 13344, 13356, 13365, 14683, 14757, 14691, 14762, 14755, 14719, + 14686, 14701, 14759, 14733, 14751, 14665, 14663, 14749, 14650, 14685, + 14769, 14698, 14772, 14693, 14758, 14695, 14694, 14766, 14729, 14753, + 14732, 14678, 14688, 14682, 14711, 14716, 14715, 14702, 14706, 14704, + 14707, 14708, 14705, 14713, 14712, 14714, 14709, 14680, 14681, 14740, + 14746, 14745, 14738, 14743, 14734, 14735, 14737, 14748, 14742, 14741, + 14739, 14744, 14736, 14747, 14655, 14654, 14660, 14659, 14718, 14675, + 14674, 14672, 14667, 14677, 14668, 14761, 14671, 14670, 14673, 14666, + 14770, 14664, 14657, 14653, 14662, 14658, 14651, 14652, 14656, 14661, + 14699, 14679, 14760, 14771, 14684, 14697, 14692, 14696, 14763, 14774, + 15012, 14918, 14928, 14976, 14980, 14930, 14929, 14982, 14981, 14957, + 15009, 15010, 14967, 14988, 14968, 15008, 15007, 15011, 14997, 14934, + 14986, 14941, 14926, 14927, 14978, 14977, 14932, 14933, 14931, 14984, + 14985, 14965, 14964, 14960, 14958, 14966, 14989, 14990, 14991, 14996, + 14995, 14973, 14974, 14972, 14969, 14975, 15002, 15001, 15000, 14999, + 14998, 15006, 15004, 14940, 14937, 14987, 14942, 14944, 14951, 14955, + 14953, 14943, 14919, 14921, 14924, 14923, 14956, 14925, 14979, 14983, + 14962, 14963, 14794, 14895, 14797, 14817, 14820, 14824, 14899, 14845, + 14846, 14851, 14855, 14864, 14867, 14860, 14872, 14804, 14834, 14837, + 14873, 14890, 14786, 14777, 14780, 14803, 14908, 14830, 14781, 14796, + 14798, 14823, 14822, 14826, 14825, 14821, 14906, 14900, 14848, 14871, + 14865, 14866, 14885, 14852, 14854, 14859, 14858, 14849, 14863, 14861, + 14850, 14868, 14814, 14811, 14805, 14810, 14809, 14807, 14812, 14816, + 14793, 14835, 14839, 14844, 14792, 14875, 14883, 14876, 14879, 14827, + 14788, 14789, 14898, 14787, 14909, 14913, 14916, 14832, 14791, 14784, + 14782, 14783, 14785, 14917, 14800, 14801, 14799, 14795, 14802, 14896, + 12532, 12539, 12538, 12533, 12537, 12536, 12534, 12535, 12759, 12767, + 12766, 12760, 12764, 12763, 12761, 12765, 12525, 12531, 12529, 12526, + 12528, 12527, 12530, 12516, 12576, 12584, 12583, 12577, 12581, 12580, + 12578, 12574, 12688, 12695, 12693, 12689, 12691, 12690, 12694, 12692, + 12663, 12672, 12671, 12664, 12668, 12667, 12665, 12669, 12703, 12709, + 12708, 12704, 12678, 12673, 12705, 12707, 12679, 12687, 12686, 12680, + 12684, 12683, 12681, 12685, 12655, 12662, 12661, 12656, 12660, 12659, + 12657, 12658, 12643, 36293, 12647, 12644, 12646, 12645, 36293, 36293, + 12636, 12642, 12640, 12637, 12639, 12638, 12641, 36293, 12631, 36293, + 12635, 12632, 12634, 12633, 36293, 36293, 12366, 12373, 12372, 12367, + 12371, 12370, 12368, 12357, 12828, 12835, 12833, 12829, 12831, 12830, + 12834, 12832, 12741, 12749, 12748, 12742, 12746, 12745, 12743, 12747, + 12404, 12412, 12411, 12405, 12409, 12408, 12406, 12410, 12796, 12803, + 12802, 12797, 12801, 12800, 12798, 12799, 12784, 36293, 12788, 12785, + 12787, 12786, 36293, 36293, 12594, 12602, 12601, 12595, 12599, 12598, + 12596, 12600, 12585, 12593, 12592, 12586, 12590, 12589, 12587, 12591, + 12486, 12494, 12493, 12487, 12491, 12490, 12488, 12492, 12564, 12571, + 12570, 12565, 12569, 12568, 12566, 12567, 12552, 36293, 12556, 12553, + 12555, 12554, 36293, 36293, 12545, 12551, 12549, 12546, 12548, 12547, + 12550, 36293, 12540, 36293, 12544, 12541, 12543, 12542, 36293, 36293, + 12768, 12775, 12774, 12769, 12773, 12772, 12770, 12771, 12604, 12610, + 12608, 12605, 12607, 12606, 12609, 36293, 12819, 12827, 12826, 12820, + 12824, 12823, 12821, 12825, 12804, 12811, 12809, 12805, 12807, 12806, + 12810, 12808, 12776, 12783, 12782, 12777, 12781, 12780, 12778, 12779, + 12434, 12442, 12441, 12435, 12439, 12438, 12436, 12440, 12419, 12427, + 12426, 12420, 12424, 12423, 12421, 12425, 12750, 12758, 12757, 12751, + 12755, 12754, 12752, 12756, 12507, 12455, 12513, 12508, 12512, 12511, + 12509, 12510, 12495, 36293, 12499, 12496, 12498, 12497, 36293, 36293, + 12479, 12485, 12483, 12480, 12482, 12481, 12484, 12475, 12710, 12718, + 12717, 12711, 12715, 12714, 12712, 12716, 12395, 12403, 12402, 12396, + 12400, 12399, 12397, 12401, 12603, 12618, 12617, 12611, 12615, 12614, + 12612, 12616, 12733, 12740, 12738, 12734, 12736, 12735, 12739, 12737, + 12725, 12732, 12731, 12726, 12730, 12729, 12727, 12728, 12447, 12454, + 12452, 12448, 12450, 12449, 12453, 12445, 12623, 12630, 12629, 12624, + 12628, 12627, 12625, 12621, 12670, 12582, 12451, 36293, 36293, 12335, + 12337, 12336, 12354, 12857, 12855, 12338, 12353, 12339, 12352, 12856, + 12351, 12853, 12851, 12850, 12847, 12846, 12849, 12848, 12854, 12852, + 12340, 12343, 12342, 12347, 12346, 12350, 12349, 12345, 12348, 12344, + 12341, 36293, 36293, 36293, 12676, 12575, 12573, 12572, 12674, 12358, + 12356, 12355, 12675, 12446, 12444, 12443, 12677, 12622, 12620, 12619, + 12845, 12836, 12842, 12843, 12838, 12840, 12844, 12839, 12837, 12841, + 36293, 36293, 36293, 36293, 36293, 36293, 6532, 6533, 6534, 6535, 6536, + 6537, 6495, 6531, 6496, 6497, 6498, 6499, 6500, 6460, 6461, 6462, 6463, + 6464, 6465, 6501, 6502, 6503, 6504, 6505, 6506, 6507, 6508, 6509, 6510, + 6511, 6466, 6459, 6467, 6468, 6469, 6470, 6471, 6472, 6513, 6514, 6515, + 6516, 6517, 6518, 6474, 6473, 6475, 6476, 6477, 6478, 6479, 6453, 6492, + 6454, 6493, 6455, 6494, 6456, 6457, 6458, 6452, 6480, 6481, 6482, 6483, + 6484, 6485, 6486, 6487, 6488, 6489, 6490, 6491, 6519, 6520, 6521, 6522, + 6523, 6524, 6525, 6526, 6527, 6528, 6529, 6530, 6512, 36293, 36293, 6612, + 6613, 6614, 6615, 6616, 6598, 36293, 36293, 5673, 5645, 5418, 5675, 5676, + 5825, 5839, 6122, 5629, 5489, 5416, 5417, 5999, 6089, 6109, 6087, 6110, + 6088, 6091, 6085, 6092, 6086, 5754, 6106, 6083, 6107, 6084, 5755, 5420, + 6123, 6141, 5662, 5661, 5663, 5664, 5656, 5657, 5654, 5653, 5666, 5660, + 5665, 5655, 5647, 5677, 5838, 5424, 5859, 5852, 5857, 5858, 5854, 5855, + 6113, 5487, 5488, 5850, 5851, 5849, 6028, 5847, 6026, 5848, 6027, 5842, + 6024, 5843, 6025, 5845, 6022, 5846, 6023, 6112, 5841, 6021, 5480, 5998, + 5981, 5996, 5997, 5994, 5995, 6120, 5451, 5464, 5979, 5980, 5989, 6081, + 5987, 6079, 5988, 6080, 5985, 6077, 5986, 6078, 5983, 6075, 5984, 6076, + 5760, 5941, 5976, 5977, 5978, 5975, 5696, 5690, 5694, 5695, 5692, 5693, + 6115, 5688, 5689, 5687, 6073, 5685, 6071, 5686, 6072, 5683, 6069, 5684, + 6070, 5680, 6067, 5681, 6068, 5757, 5678, 5679, 5921, 5922, 5923, 5920, + 5644, 5631, 5642, 5643, 5640, 5641, 6114, 5448, 5630, 5638, 6066, 5636, + 6064, 5637, 6065, 5634, 6062, 5635, 6063, 5632, 6060, 5633, 6061, 5756, + 5447, 5897, 5722, 5730, 5739, 5740, 5725, 5726, 6117, 5728, 5729, 5738, + 6020, 5736, 6018, 5737, 6019, 5734, 6016, 5735, 6017, 5732, 6014, 5733, + 6015, 5758, 5721, 6013, 5741, 5422, 5898, 5814, 5775, 5812, 5813, 5802, + 5803, 6118, 5746, 5774, 5811, 6039, 5805, 6037, 5806, 6038, 5759, 5742, + 5520, 5815, 5720, 5707, 5718, 5719, 5716, 5717, 6116, 5705, 5706, 5715, + 6007, 5713, 6005, 5714, 6006, 5711, 6003, 5712, 6004, 5709, 6001, 5710, + 6002, 5697, 6000, 5723, 5940, 5900, 5938, 5939, 5919, 5924, 6119, 5880, + 5899, 5933, 6059, 5931, 6057, 5932, 6058, 5929, 6055, 5930, 6056, 5927, + 6053, 5928, 6054, 5752, 5879, 5423, 5926, 5443, 5727, 5750, 5753, 5748, + 5749, 5751, 5747, 5918, 5916, 5917, 5910, 5911, 5913, 5914, 5909, 6052, + 5907, 6050, 5908, 6051, 5902, 6048, 5903, 6049, 5905, 6046, 5906, 6047, + 5901, 6140, 6126, 6138, 6139, 6128, 6129, 6121, 6124, 6125, 6137, 6036, + 6135, 6034, 6136, 6035, 6133, 6032, 6134, 6033, 6131, 6030, 6132, 6031, + 5761, 6111, 5444, 6029, 5896, 5878, 5862, 6012, 5872, 5876, 5877, 5874, + 5875, 6010, 5870, 5871, 6008, 5864, 6041, 5860, 6040, 5724, 5672, 5651, + 5652, 5667, 5669, 5670, 5649, 5650, 5671, 6082, 5648, 5960, 5745, 5958, + 5743, 5959, 5744, 5956, 5957, 5954, 5955, 5952, 6074, 5942, 5973, 5974, + 5970, 5968, 5967, 5991, 5992, 5993, 5990, 5800, 5798, 5799, 5796, 5797, + 5794, 5795, 5793, 5801, 5674, 5819, 5823, 5824, 5821, 5822, 5817, 5818, + 5816, 5965, 5966, 5961, 5964, 6043, 6044, 6045, 6042, 5780, 5784, 5785, + 5782, 5783, 5778, 5779, 5777, 5786, 5894, 5895, 5890, 5893, 6102, 6103, + 6104, 6101, 6093, 5703, 5704, 5701, 5702, 5699, 5700, 5698, 5950, 5948, + 5949, 5946, 5947, 5944, 5945, 5943, 5421, 5440, 5441, 5442, 5439, 5428, + 5429, 5430, 5427, 5436, 5437, 5438, 5435, 5432, 5433, 5434, 5431, 5885, + 5886, 5882, 5884, 5470, 5469, 5465, 5466, 5468, 5467, 5616, 5615, 5611, + 5612, 5614, 5613, 5622, 5621, 5617, 5618, 5620, 5619, 5486, 5485, 5481, + 5482, 5484, 5483, 5580, 5579, 5575, 5576, 5578, 5577, 5574, 5573, 5569, + 5570, 5572, 5571, 5543, 5542, 5538, 5539, 5541, 5540, 5537, 5479, 5478, + 5475, 5476, 5477, 5473, 5516, 5515, 5511, 5512, 5514, 5513, 5510, 5509, + 5505, 5506, 5508, 5507, 5504, 5523, 5522, 5517, 5518, 5521, 5519, 5610, + 5609, 5605, 5606, 5608, 5607, 5628, 5627, 5623, 5624, 5626, 5625, 5503, + 5887, 5502, 5497, 5498, 5501, 5889, 5500, 5496, 5495, 5491, 5492, 5494, + 5493, 5598, 5597, 5593, 5594, 5596, 5595, 5457, 5456, 5452, 5453, 5455, + 5454, 5592, 5591, 5587, 5588, 5590, 5589, 5556, 5555, 5551, 5552, 5554, + 5553, 5562, 5561, 5557, 5558, 5560, 5559, 5550, 5549, 5545, 5546, 5548, + 5547, 5544, 5490, 5463, 5462, 5458, 5459, 5461, 5460, 5536, 5535, 5531, + 5532, 5534, 5533, 5530, 5529, 5525, 5526, 5528, 5527, 5524, 5586, 5585, + 5581, 5582, 5584, 5583, 5604, 5603, 5599, 5600, 5602, 5601, 5568, 5567, + 5563, 5564, 5566, 5565, 5639, 5668, 5820, 5781, 5791, 5792, 5789, 5790, + 5787, 5788, 6100, 6098, 6099, 6096, 6097, 6094, 6095, 6105, 5426, 25012, + 24987, 24998, 24994, 25004, 25001, 25007, 25010, 25011, 24990, 24989, + 25009, 24995, 25000, 25005, 24999, 24986, 25002, 25008, 24992, 24996, + 24991, 25003, 25006, 24997, 24993, 24988, 24984, 24985, 36293, 36293, + 36293, 27345, 27401, 27395, 27399, 27398, 27393, 27391, 27338, 27323, + 27369, 27322, 27321, 27366, 27381, 27368, 27372, 27373, 27375, 27361, + 27327, 27360, 27346, 27339, 27347, 27349, 27394, 27351, 27350, 27364, + 27378, 27390, 27380, 27332, 27354, 27335, 27358, 27348, 27363, 27384, + 27355, 27397, 27324, 27387, 27386, 27382, 27325, 27403, 27392, 27383, + 27330, 27389, 27377, 27333, 27371, 27336, 27396, 27365, 27379, 27362, + 27331, 27353, 27352, 27334, 27370, 27337, 27357, 27329, 27328, 27326, + 27388, 27367, 27385, 27356, 27400, 27402, 27404, 27405, 27320, 27406, + 27407, 27319, 27359, 27376, 27374, 27343, 27342, 27344, 27341, 27340, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 30120, 30137, 30138, + 30128, 30126, 30122, 30134, 30125, 30123, 30131, 30124, 30130, 30136, + 30132, 30129, 30135, 30133, 30127, 30141, 30142, 30140, 30139, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 30121, 15184, + 15185, 15186, 15175, 15173, 15169, 15181, 15172, 15170, 15178, 15171, + 15177, 15183, 15179, 15176, 15182, 15180, 15174, 15188, 15189, 15187, + 26470, 26471, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 5138, 5139, 5140, 5129, 5127, 5123, 5135, 5126, 5124, 5132, 5125, + 5131, 5137, 5133, 5130, 5136, 5134, 5128, 5141, 5142, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 30156, 30157, 30158, 30148, 30147, 30143, 30153, 30146, 30144, 30151, + 30145, 30150, 30155, 36293, 30149, 30154, 30152, 36293, 30159, 30160, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 17368, 17366, 17369, 17367, 17370, 17364, 17362, 17365, + 17363, 17372, 17386, 17382, 17387, 17383, 17371, 17384, 17380, 17385, + 17381, 17373, 17394, 17374, 17376, 17375, 17390, 17393, 17391, 17389, + 17392, 17378, 17377, 17379, 17395, 17388, 17396, 17343, 17341, 17351, + 17352, 17347, 17350, 17348, 17349, 17360, 17361, 17358, 17359, 17353, + 17342, 17346, 17345, 17344, 17463, 17462, 17464, 17469, 17471, 17475, + 17477, 17479, 17481, 17480, 17472, 17476, 17470, 17482, 17466, 17467, + 17474, 17468, 17417, 17411, 17416, 17418, 17412, 17402, 17410, 17413, + 17407, 17399, 17400, 17419, 17406, 17401, 17408, 17403, 17405, 17414, + 17404, 17415, 17409, 17340, 17397, 17398, 36293, 36293, 17489, 17491, + 17488, 17487, 17484, 17483, 17486, 17485, 17492, 17490, 36293, 36293, + 36293, 36293, 36293, 36293, 17441, 17440, 17437, 17439, 17438, 17432, + 17435, 17436, 17434, 17433, 36293, 36293, 36293, 36293, 36293, 36293, + 23518, 23530, 23526, 23375, 23525, 23376, 23523, 23514, 23527, 23528, + 23529, 23374, 23373, 23372, 23524, 23371, 23367, 23369, 23366, 23365, + 23362, 23361, 23364, 23363, 23370, 23368, 36293, 36293, 36293, 36293, + 36293, 36293, 23379, 23493, 23510, 23495, 23497, 23496, 23498, 23494, + 23504, 23407, 23499, 23505, 23506, 23502, 23411, 23492, 23454, 23453, + 23484, 23500, 23408, 23503, 23509, 23507, 23508, 23501, 23490, 23489, + 23483, 23487, 23488, 23486, 23491, 23485, 23410, 23463, 23481, 23482, + 23470, 23472, 23471, 23473, 23457, 23474, 23477, 23478, 23464, 23476, + 23467, 23459, 23468, 23461, 23466, 23480, 23479, 23475, 23465, 23469, + 23460, 23462, 23458, 23452, 23437, 23438, 23446, 23445, 23442, 23450, + 23431, 23433, 23451, 23440, 23436, 23447, 23449, 23448, 23432, 23434, + 23435, 23444, 23441, 23439, 23443, 23430, 23428, 23429, 23427, 23426, + 23409, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 23381, 23383, + 23385, 23392, 23391, 23399, 23395, 23380, 23390, 23406, 23393, 23405, + 23397, 23396, 23387, 23394, 23398, 23384, 23401, 23400, 23404, 23402, + 23403, 23382, 23456, 23455, 23419, 23424, 23415, 23420, 23416, 23412, + 23417, 23413, 23425, 23414, 23422, 23423, 23389, 23388, 23418, 23386, + 23421, 36293, 36293, 36293, 36293, 36293, 5840, 5425, 5419, 6108, 5856, + 5853, 5844, 5982, 5691, 5682, 5731, 5804, 5776, 5708, 5925, 5881, 5912, + 5915, 5904, 6130, 6127, 5873, 5809, 5829, 5810, 5830, 5807, 5827, 5808, + 5828, 5869, 5867, 5868, 5865, 5866, 5863, 5836, 5837, 5834, 5833, 5835, + 5826, 5831, 5832, 5646, 6090, 5659, 5658, 5861, 6011, 6009, 5953, 5951, + 5972, 5971, 5969, 5963, 5962, 5892, 5891, 5883, 5472, 5449, 5474, 5471, + 5888, 5499, 5445, 5446, 5450, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 19757, 19724, 19723, 19704, 19703, 19710, + 19718, 19717, 19722, 19721, 19709, 19707, 19705, 19720, 19719, 19711, + 19726, 19725, 19716, 19715, 19729, 19708, 19730, 19728, 19731, 19712, + 19713, 19714, 19727, 19702, 19706, 36293, 19748, 19755, 19756, 19754, + 19749, 19752, 19750, 19753, 19751, 19747, 19745, 19746, 36293, 36293, + 36293, 36293, 19739, 19736, 19738, 19744, 19737, 19742, 19741, 19743, + 19740, 19733, 19732, 19734, 36293, 36293, 36293, 36293, 19735, 36293, + 36293, 36293, 19769, 19758, 19765, 19767, 19764, 19763, 19760, 19759, + 19762, 19761, 19768, 19766, 30181, 30193, 30176, 30173, 30191, 30194, + 30175, 30174, 30188, 30183, 30182, 30189, 30186, 30192, 30187, 30190, + 30180, 30172, 30177, 30161, 30195, 30165, 30166, 30184, 30179, 30178, + 30185, 30164, 30162, 30163, 36293, 36293, 30167, 30168, 30169, 30170, + 30171, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 24550, 24572, 24532, 24534, 24537, 24554, 24556, 24559, + 24540, 24536, 24552, 24562, 24558, 24574, 24541, 24539, 24538, 24563, + 24561, 24560, 24543, 24542, 24549, 24565, 24564, 24571, 24546, 24551, + 24548, 24568, 24573, 24570, 24547, 24545, 24544, 24569, 24567, 24566, + 24531, 24533, 24553, 24555, 24535, 24557, 36293, 36293, 36293, 36293, + 24595, 24580, 24584, 24590, 24593, 24596, 24582, 24586, 24587, 24591, + 24583, 24581, 24594, 24589, 24588, 24592, 24585, 24530, 24525, 24524, + 24529, 24528, 24527, 24526, 24577, 24578, 36293, 36293, 36293, 36293, + 36293, 36293, 24603, 24605, 24602, 24601, 24598, 24597, 24600, 24599, + 24606, 24604, 24579, 36293, 36293, 36293, 24575, 24576, 17442, 17461, + 17454, 17457, 17459, 17452, 17450, 17448, 17444, 17446, 17431, 17429, + 17421, 17425, 17427, 17423, 17455, 17460, 17453, 17456, 17458, 17451, + 17449, 17447, 17443, 17445, 17430, 17428, 17420, 17424, 17426, 17422, + 5107, 5104, 5096, 5095, 5109, 5101, 5094, 5093, 5112, 5103, 5100, 5099, + 5102, 5106, 5098, 5097, 5114, 5110, 5108, 5113, 5111, 5115, 5105, 5118, + 5120, 5117, 5119, 5116, 36293, 36293, 5122, 5121, 30229, 30227, 30228, + 30245, 30244, 30243, 30269, 30235, 30234, 30248, 30255, 30247, 30270, + 30263, 30230, 30275, 30246, 30262, 30239, 30238, 30252, 30251, 30271, + 30274, 30237, 30236, 30240, 30250, 30253, 30249, 30276, 30256, 30242, + 30261, 30264, 30257, 30259, 30277, 30231, 30232, 30233, 30241, 30260, + 30278, 30254, 30267, 30268, 30265, 30266, 30273, 30272, 30258, 30226, + 30201, 30200, 30198, 30289, 30196, 30197, 30199, 30202, 30203, 30204, + 36293, 30297, 30304, 30308, 30305, 30314, 30320, 30321, 30319, 30318, + 30316, 30317, 30309, 30310, 30313, 30322, 30306, 30312, 30307, 30315, + 30311, 30288, 30301, 30302, 30281, 30282, 30283, 30292, 30291, 30284, + 36293, 36293, 30205, 30212, 30214, 30211, 30210, 30207, 30206, 30209, + 30208, 30215, 30213, 36293, 36293, 36293, 36293, 36293, 36293, 30222, + 30224, 30221, 30220, 30217, 30216, 30219, 30218, 30225, 30223, 36293, + 36293, 36293, 36293, 36293, 36293, 30298, 30299, 30296, 30287, 30280, + 30300, 30293, 30290, 30285, 30286, 30294, 30295, 30279, 30303, 36293, + 36293, 7354, 7314, 7444, 7357, 7603, 7623, 7622, 7551, 7339, 7525, 7590, + 7557, 7343, 7556, 7555, 7492, 7486, 7510, 7573, 7511, 7574, 7587, 7544, + 7443, 7560, 7342, 7341, 7601, 7470, 7471, 7472, 7335, 7614, 7423, 7617, + 7201, 7619, 7537, 7615, 7618, 7539, 7586, 7368, 7356, 7313, 7320, 7426, + 7321, 7516, 7576, 7543, 7441, 7589, 7594, 7326, 7327, 7366, 7503, 7608, + 7345, 7221, 7616, 7329, 7325, 7334, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 2805, 2804, 2806, 2803, 2807, 2714, 2715, 2731, 2732, 2735, 2736, 2753, + 2754, 2744, 2745, 2728, 2718, 2733, 2734, 2739, 2741, 2729, 2730, 2748, + 2721, 2722, 2737, 2738, 2749, 2760, 2759, 2725, 2724, 2747, 2758, 2761, + 2723, 2726, 2746, 2750, 2751, 2719, 2720, 2766, 2768, 2752, 2743, 2767, + 2756, 2757, 2755, 2765, 2808, 2819, 2822, 2823, 2813, 2814, 2811, 2812, + 2809, 2810, 2815, 2816, 2818, 2817, 2820, 2821, 2824, 2740, 2742, 2762, + 2727, 2763, 2764, 2716, 2717, 36293, 2713, 2712, 2832, 2834, 2831, 2830, + 2827, 2826, 2829, 2828, 2835, 2833, 2800, 2797, 2825, 2710, 2711, 2709, + 2799, 2786, 2784, 2787, 2778, 2779, 2785, 2781, 2783, 2782, 2780, 2776, + 2775, 2771, 2769, 2773, 2772, 2770, 2774, 2777, 2796, 2795, 2794, 2793, + 2788, 2790, 2791, 2792, 2789, 2801, 2798, 2802, 29728, 29726, 29727, + 29679, 29714, 29716, 29681, 29715, 29691, 29692, 29699, 29707, 29702, + 29693, 29700, 29704, 29713, 29694, 29708, 29701, 29695, 29706, 29684, + 29709, 29697, 29705, 29712, 29688, 29686, 29710, 29690, 29711, 29703, + 29674, 29675, 29676, 29734, 29733, 29735, 29732, 29730, 29731, 29725, + 29729, 29677, 29678, 29698, 29689, 29742, 29744, 29741, 29740, 29737, + 29736, 29739, 29738, 29745, 29743, 29673, 29687, 29685, 29696, 29682, + 29683, 3600, 3586, 3594, 3578, 3566, 3590, 3589, 3575, 3581, 3574, 3567, + 3598, 3584, 3576, 3593, 3577, 3595, 3592, 3597, 3582, 3565, 3580, 3587, + 3570, 3588, 3583, 3568, 3599, 3585, 3572, 3596, 3579, 3573, 3591, 3571, + 3569, 3601, 3602, 3609, 3615, 3612, 3616, 3617, 3613, 3618, 3614, 3610, + 3611, 3563, 3564, 3603, 3604, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 3608, 3606, 3607, 3605, 19585, 19584, 19583, 19597, 19596, + 19602, 19612, 19611, 19615, 19603, 19610, 19609, 19591, 19604, 19588, + 19587, 19586, 19595, 19594, 19593, 19592, 19601, 19600, 19606, 19605, + 19590, 19620, 19617, 19616, 19599, 19598, 19618, 19614, 19613, 19619, + 19621, 19630, 19629, 19635, 19637, 19633, 19634, 19631, 19632, 19636, + 19574, 19579, 19578, 19576, 19580, 19581, 19582, 19577, 19575, 19628, + 19627, 36293, 36293, 36293, 19622, 19625, 19626, 19624, 19623, 19644, + 19646, 19643, 19642, 19639, 19638, 19641, 19640, 19647, 19645, 36293, + 36293, 36293, 19608, 19607, 19589, 25058, 25060, 25057, 25056, 25053, + 25052, 25055, 25054, 25061, 25059, 25031, 25022, 25020, 25019, 25021, + 25032, 25016, 25015, 25017, 25018, 25034, 25030, 25028, 25027, 25029, + 25036, 25042, 25043, 25041, 25044, 25033, 25026, 25023, 25025, 25024, + 25035, 25037, 25038, 25040, 25039, 25046, 25047, 25045, 25051, 25050, + 25062, 25049, 25048, 9931, 9908, 9914, 9971, 9952, 9960, 9950, 9951, + 9970, 9636, 9962, 36293, 36293, 36293, 36293, 36293, 13391, 13422, 13399, + 13428, 13397, 13427, 13420, 13417, 13429, 13409, 13411, 13423, 13425, + 13430, 13413, 13419, 13421, 13415, 13418, 13431, 13412, 13408, 13398, + 13426, 13414, 13392, 13395, 13407, 13394, 13393, 13424, 13406, 13402, + 13405, 13403, 13433, 13400, 13404, 13434, 13432, 13396, 13416, 13390, + 36293, 36293, 13389, 13401, 13410, 29724, 29722, 29723, 29721, 29720, + 29719, 29718, 29717, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 34132, 34145, 34134, 34112, 34126, 34140, 34141, 34142, 34127, + 34143, 34130, 34138, 34133, 34131, 34139, 34137, 34136, 34144, 34125, + 34123, 34114, 34121, 34113, 34124, 34122, 34103, 34104, 34106, 34107, + 34119, 34117, 34118, 34116, 34105, 34109, 34115, 34128, 34111, 34120, + 34108, 34135, 34129, 34110, 36293, 36293, 36293, 36293, 36293, 18442, + 18443, 19118, 18412, 18444, 18445, 18415, 18414, 19099, 19094, 18448, + 18449, 18425, 18450, 18433, 18426, 18427, 19041, 19042, 19043, 19096, + 18429, 19087, 18558, 18452, 18434, 18441, 18436, 18455, 19046, 19045, + 19044, 18456, 18457, 18459, 18416, 18469, 18397, 13935, 13938, 13934, + 13937, 13933, 9801, 23000, 23001, 22991, 22992, 23003, 23004, 22994, + 23006, 22996, 23007, 23008, 23009, 23010, 23011, 23012, 22995, 22998, + 22999, 23013, 22993, 23016, 23017, 23019, 23151, 23302, 23152, 23304, + 23155, 23188, 23205, 23284, 23261, 23310, 23217, 23319, 23231, 23233, + 23214, 23260, 23262, 23299, 23159, 23264, 23289, 23325, 23285, 23308, + 23330, 23153, 23162, 23220, 23198, 23221, 23187, 19268, 19276, 19278, + 19279, 14144, 14140, 14143, 14142, 14141, 19183, 18527, 18599, 18692, + 18844, 18863, 18945, 18982, 18974, 19024, 19065, 19248, 19128, 23068, + 18768, 19077, 18471, 18775, 18941, 18472, 19182, 18528, 18602, 18693, + 18708, 18795, 18822, 18845, 18870, 18946, 18986, 19026, 18678, 19194, + 19219, 19249, 18497, 18516, 18590, 18667, 18935, 18992, 19034, 18764, + 18931, 18679, 19169, 18689, 23303, 23163, 23164, 23213, 23277, 23215, + 23199, 23283, 23305, 23235, 23236, 23166, 23167, 23238, 23245, 23248, + 23171, 23234, 23309, 23256, 23259, 23180, 23157, 23266, 23282, 23206, + 23293, 23327, 23328, 23183, 23332, 23322, 23333, 23336, 23334, 23210, + 23324, 7323, 7322, 7592, 7591, 7538, 7425, 7540, 7203, 7424, 7202, 7484, + 7215, 7541, 7336, 7553, 7581, 7445, 7609, 7610, 7467, 7458, 7459, 7460, + 7462, 7469, 7465, 7494, 7450, 7496, 7473, 7451, 7452, 7498, 7453, 7454, + 7483, 7487, 7475, 7502, 7457, 7489, 7490, 7488, 7466, 7474, 7478, 7499, + 7464, 7481, 7491, 7456, 7477, 7480, 7606, 7449, 7448, 7316, 7620, 7319, + 7310, 7333, 7212, 7507, 7564, 17905, 18495, 17933, 18530, 17932, 18529, + 17931, 18526, 17945, 18561, 17972, 18604, 17971, 18603, 17970, 18601, + 17966, 18595, 17967, 18596, 18002, 18653, 18003, 18654, 17991, 18641, + 18000, 18651, 17982, 18632, 18026, 18695, 18034, 18707, 18053, 18727, + 18052, 18726, 18050, 18724, 18047, 18721, 18046, 18720, 18070, 18756, + 18064, 18744, 18101, 18793, 18098, 18790, 18102, 18794, 18106, 18807, + 18107, 18808, 18118, 18817, 18114, 18804, 18126, 18842, 18128, 18847, + 18127, 18846, 18146, 18869, 18145, 18868, 18139, 18860, 18136, 18856, + 18185, 18913, 18184, 18912, 18154, 18905, 18155, 18906, 18206, 18944, + 18208, 18948, 18226, 18971, 18224, 18969, 18225, 18970, 18218, 18976, + 18251, 19019, 18249, 19017, 18248, 19010, 18243, 19012, 18250, 19018, + 18274, 19064, 18273, 19063, 18275, 19067, 18269, 19057, 18306, 19148, + 18329, 19173, 18299, 19141, 18328, 19172, 18319, 19161, 18341, 19195, + 18340, 19189, 18354, 19207, 18355, 19208, 18351, 19204, 18353, 19206, + 18352, 19205, 18360, 19214, 18359, 19213, 18366, 19224, 18376, 19239, + 18380, 19243, 18382, 19245, 18730, 19062, 19209, 19235, 18496, 18833, + 18832, 18834, 18265, 18613, 17899, 18489, 17908, 18500, 17893, 18483, + 17892, 18482, 17891, 18481, 17895, 18485, 17894, 18484, 17887, 18477, + 17886, 18476, 17885, 18475, 17889, 18479, 17888, 18478, 17996, 18646, + 18007, 18659, 17999, 18650, 17987, 18637, 17986, 18636, 17985, 18635, + 17990, 18640, 17989, 18639, 18071, 18757, 18061, 18748, 18169, 18891, + 18178, 18900, 18160, 18882, 18159, 18881, 18158, 18880, 18162, 18884, + 18161, 18883, 18175, 18897, 18174, 18896, 18173, 18895, 18177, 18899, + 18176, 18898, 18309, 19151, 18311, 19153, 18315, 19157, 18314, 19156, + 18313, 19155, 18317, 19159, 18316, 19158, 18367, 19225, 18365, 19223, + 18369, 19227, 18372, 19234, 18131, 18850, 18132, 18851, 18362, 19229, + 13982, 13974, 13987, 13979, 13983, 13975, 13985, 13977, 13748, 13740, + 13751, 13743, 13749, 13741, 13753, 13745, 14005, 14002, 14007, 14004, + 14006, 14003, 36293, 36293, 13788, 13785, 13790, 13787, 13789, 13786, + 36293, 36293, 14020, 14012, 14025, 14017, 14021, 14013, 14023, 14015, + 13772, 13764, 13775, 13767, 13773, 13765, 13777, 13769, 14046, 14037, + 14049, 14040, 14048, 14039, 14047, 14038, 13800, 13795, 13803, 13798, + 13802, 13797, 13801, 13796, 14107, 14104, 14109, 14106, 14108, 14105, + 36293, 36293, 13834, 13831, 13836, 13833, 13835, 13832, 36293, 36293, + 14066, 14057, 14069, 14060, 14068, 14059, 14067, 14058, 36293, 13846, + 36293, 13849, 36293, 13848, 36293, 13847, 14087, 14079, 14092, 14084, + 14088, 14080, 14090, 14082, 13818, 13810, 13821, 13813, 13819, 13811, + 13823, 13815, 13972, 13992, 14009, 14008, 14032, 14030, 14052, 14053, + 14111, 14110, 14072, 14073, 14099, 14097, 36293, 36293, 13989, 13981, + 13988, 13980, 13984, 13976, 13986, 13978, 13755, 13747, 13752, 13744, + 13750, 13742, 13754, 13746, 14027, 14019, 14026, 14018, 14022, 14014, + 14024, 14016, 13779, 13771, 13776, 13768, 13774, 13766, 13778, 13770, + 14094, 14086, 14093, 14085, 14089, 14081, 14091, 14083, 13825, 13817, + 13822, 13814, 13820, 13812, 13824, 13816, 13971, 13996, 13973, 13994, + 13993, 36293, 13990, 13991, 13757, 13761, 13758, 13759, 13756, 13931, + 13959, 13960, 13964, 13880, 14033, 14034, 14031, 36293, 14028, 14029, + 13792, 13791, 13782, 13781, 13780, 13963, 13962, 13961, 14051, 14055, + 14044, 14043, 36293, 36293, 14050, 14042, 13804, 13808, 13805, 13806, + 36293, 13888, 13887, 13886, 14071, 14075, 14064, 14063, 14119, 14118, + 14070, 14062, 13851, 13855, 13852, 13853, 13841, 13882, 13881, 14158, + 36293, 36293, 14100, 14101, 14098, 36293, 14095, 14096, 13838, 13837, + 13828, 13827, 13826, 13956, 13885, 36293, 12274, 12271, 12276, 12273, + 32286, 13028, 28851, 12953, 26763, 32259, 14513, 36099, 36098, 36100, + 19442, 27095, 16000, 24792, 12952, 12275, 12272, 15942, 10754, 10728, + 19364, 27025, 28726, 28724, 19316, 26988, 10727, 10722, 10030, 10721, + 5143, 32873, 25563, 33020, 15966, 16003, 19775, 26103, 19441, 27094, + 26637, 19440, 27093, 24392, 26339, 26340, 26723, 10736, 32887, 26930, + 26924, 26938, 6156, 28725, 28727, 26947, 10760, 16344, 25918, 33074, + 6443, 6157, 2615, 16002, 13032, 19372, 27036, 10758, 26787, 12866, 32660, + 26929, 4002, 4044, 20444, 26935, 7186, 33032, 7626, 29837, 16365, 12992, + 32266, 26783, 13021, 12978, 33021, 13022, 10699, 32898, 34154, 22266, + 34705, 13155, 16368, 16370, 16369, 36293, 19439, 27092, 12971, 26636, + 16258, 7, 16257, 6, 24387, 24790, 29808, 29796, 36293, 36293, 29803, + 29802, 29805, 29804, 29795, 29809, 29799, 29801, 29794, 29798, 29800, + 29797, 29638, 29640, 29637, 29636, 29633, 29632, 29635, 29634, 29628, + 29639, 29629, 29631, 29627, 29626, 29630, 23100, 19265, 19266, 19274, + 19281, 19263, 19267, 19270, 19271, 19272, 19273, 19275, 19262, 19277, + 19280, 19282, 19283, 12862, 7199, 7876, 13039, 20383, 22882, 24320, + 26363, 27416, 34709, 24523, 10693, 12863, 17693, 32908, 10876, 13436, + 26364, 14208, 2628, 16008, 6276, 20384, 29187, 32031, 16248, 32990, + 24842, 20951, 27285, 17877, 3907, 29167, 27578, 27417, 33037, 25554, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 7514, 7572, 7529, 7585, 7208, 7225, 7509, 7569, 7578, 7224, 7207, + 7595, 7367, 7358, 7361, 7364, 7359, 7518, 7360, 7362, 7363, 7561, 7350, + 7209, 7602, 7621, 7520, 7526, 7577, 7519, 7508, 7568, 7211, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 0, 100, 10770, 10054, 6280, 6158, 5409, 12865, + 27606, 10056, 27603, 27595, 4092, 10771, 26526, 26527, 27596, 4093, + 27597, 27604, 20623, 10772, 24886, 29083, 27599, 10768, 10773, 27600, + 4094, 10774, 26699, 26908, 27712, 31925, 32857, 34146, 10775, 25912, + 25923, 16364, 4095, 33013, 17219, 967, 27592, 4091, 12332, 27602, 27593, + 27594, 32997, 27598, 27605, 351, 3798, 13439, 10043, 16255, 27273, 12931, + 10782, 10781, 10767, 10769, 10783, 33006, 33007, 26934, 33008, 10780, + 10776, 10777, 10778, 10779, 26727, 32992, 26341, 2686, 33010, 29916, + 34298, 34296, 34300, 34301, 34306, 34294, 34305, 34304, 34292, 34299, + 34291, 34293, 34302, 34290, 34307, 13033, 27241, 27252, 27253, 27240, + 27237, 27246, 27248, 27256, 27257, 27249, 27255, 27251, 27234, 27242, + 27238, 27244, 28913, 28917, 28918, 28912, 28909, 28921, 28920, 28908, + 28922, 28919, 28907, 28916, 28911, 28914, 28910, 28915, 27245, 27239, + 27250, 27254, 19000, 27247, 27236, 27235, 27243, 34308, 33001, 33000, + 36293, 36293, 36293, 36293, 19443, 33225, 27097, 10812, 19346, 33096, + 24823, 24796, 29055, 29070, 19463, 27121, 19528, 27199, 19525, 33275, + 27198, 10848, 19466, 27124, 19474, 33238, 27104, 10826, 33097, 19472, + 27130, 19457, 27116, 19354, 19349, 10852, 33235, 33236, 10821, 10822, + 27112, 10813, 978, 7170, 24825, 19454, 983, 7172, 19493, 19487, 33252, + 33249, 27157, 27151, 10863, 10860, 27132, 33227, 19477, 19540, 33278, + 27164, 10871, 19494, 27158, 19531, 19353, 27140, 19529, 33242, 27138, + 10853, 19351, 33099, 24836, 24809, 29067, 29080, 19514, 27189, 19544, + 27168, 33228, 10814, 19535, 33243, 27144, 10854, 19453, 27111, 19526, + 33279, 27200, 10850, 33284, 33280, 33282, 33281, 33286, 33287, 27201, + 24824, 29058, 33101, 26975, 10824, 32274, 19473, 27131, 19348, 19459, + 27114, 19347, 19539, 27163, 19356, 13017, 7633, 26249, 32253, 32252, + 12264, 16176, 24276, 12213, 24845, 28893, 7641, 10519, 28886, 12278, + 24235, 24223, 24227, 22886, 22893, 10694, 10501, 27717, 2614, 27210, + 5145, 29412, 9457, 13027, 26726, 16249, 26965, 962, 22137, 29190, 10505, + 10520, 26108, 24850, 20398, 20405, 16337, 33076, 16322, 10725, 32897, + 7647, 29830, 34286, 7173, 7164, 980, 32254, 3799, 26818, 26725, 10695, + 12868, 13261, 15987, 32564, 26936, 16356, 28846, 34713, 24855, 22892, + 2621, 24846, 1062, 1065, 24479, 367, 24847, 369, 32888, 364, 12317, + 13259, 10511, 1066, 13260, 1063, 16137, 7198, 12315, 27208, 27209, 7826, + 12333, 12318, 29582, 10059, 12300, 22151, 26789, 24857, 16013, 24858, + 29619, 19667, 13672, 19669, 13675, 19658, 13665, 23972, 23971, 3797, + 24856, 24860, 24859, 24484, 24481, 19666, 13671, 24483, 24480, 19668, + 13673, 24485, 24482, 26700, 29656, 26709, 29665, 26708, 29664, 10522, + 10525, 29644, 29816, 24843, 24844, 29650, 29822, 24477, 24478, 29649, + 29821, 23652, 23653, 23654, 29287, 29376, 29289, 29378, 29222, 29229, + 6959, 6905, 6964, 6697, 6710, 6960, 6685, 6969, 6711, 29550, 29543, + 29564, 29498, 27054, 19390, 10789, 33105, 2622, 22901, 32905, 13018, + 32891, 10752, 10524, 24854, 10527, 24476, 26710, 29666, 24840, 7642, + 24841, 7643, 25595, 16136, 23655, 15756, 16345, 34734, 24321, 24795, + 26971, 27050, 24232, 24233, 24234, 24228, 10339, 10696, 29584, 10503, + 4520, 19404, 27011, 19362, 27023, 26937, 9446, 9445, 10746, 10745, 10724, + 10749, 26520, 12301, 19672, 13681, 34197, 34196, 19656, 13676, 12299, + 12298, 12296, 12297, 10523, 10526, 24851, 24852, 29288, 29377, 19657, + 13664, 26707, 29663, 24848, 10517, 24849, 10518, 34153, 22878, 33104, + 10792, 12214, 12216, 28894, 12219, 12218, 28895, 12217, 12215, 7644, + 7645, 28887, 7646, 28888, 36011, 10340, 12211, 15981, 33088, 10793, + 26724, 26358, 34472, 19312, 26983, 19401, 26992, 4503, 4500, 32805, + 32801, 26927, 29321, 2610, 27619, 27611, 31923, 26645, 34210, 26523, + 33004, 34463, 15979, 32800, 32804, 4499, 4502, 32794, 4497, 13043, 28953, + 33089, 25585, 12320, 34718, 17221, 19412, 27075, 12319, 3745, 10025, 365, + 29926, 32821, 10512, 7652, 28878, 7828, 7829, 1008, 1046, 1032, 1020, + 1021, 1037, 1018, 988, 993, 1043, 1048, 1034, 1033, 1028, 1035, 1016, + 1040, 1029, 1036, 991, 1000, 999, 1022, 1025, 1001, 1054, 1027, 1051, + 997, 1026, 1024, 1052, 1004, 1023, 1039, 998, 1005, 1014, 992, 1053, + 1038, 989, 1019, 1050, 995, 1044, 1013, 990, 1002, 1015, 1056, 1055, 994, + 996, 1057, 1045, 1042, 1031, 1030, 1003, 1049, 1006, 1041, 1011, 1010, + 1047, 1007, 1012, 1009, 24861, 26970, 27908, 3638, 34169, 16321, 7650, + 10426, 12270, 7632, 34612, 12292, 370, 15467, 6741, 6963, 5084, 33075, + 23534, 16006, 25581, 25582, 26263, 26264, 10421, 28971, 1017, 10050, + 26711, 24708, 26713, 7193, 19407, 19409, 19406, 27018, 27020, 27017, + 19369, 19376, 19368, 27033, 27040, 27032, 19310, 19308, 19309, 9448, + 26981, 26979, 26980, 16332, 15946, 33157, 33196, 29669, 29667, 32808, + 4506, 4507, 26798, 19411, 27056, 15955, 15956, 15957, 15958, 10072, + 10070, 10074, 10063, 10067, 10075, 10064, 10068, 10073, 10062, 10066, + 10061, 10065, 10071, 10069, 29255, 26909, 12895, 34164, 22713, 22705, + 22712, 22706, 22710, 22711, 22709, 22708, 22707, 11043, 13159, 32796, + 4510, 32778, 4509, 32809, 4513, 34630, 3746, 29610, 12983, 8, 12212, + 10051, 4033, 3995, 4076, 3972, 4034, 3996, 4036, 230, 29608, 32572, + 15980, 4012, 4015, 4017, 4009, 10750, 4055, 3917, 26659, 26656, 26657, + 26658, 24968, 29911, 29919, 29920, 29900, 29898, 29901, 29912, 29883, + 29884, 29905, 29907, 29906, 29904, 29885, 29917, 29918, 29887, 29896, + 29895, 29894, 29893, 29909, 29923, 29899, 29886, 29897, 29921, 29902, + 29903, 29914, 29913, 29915, 29924, 29888, 4099, 25568, 29910, 29891, + 29922, 29890, 29889, 29892, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 24980, 24975, 24978, 24979, + 24973, 24971, 24972, 24970, 24977, 24974, 24976, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 6707, 6704, 6703, + 6700, 6699, 6702, 6701, 6708, 6706, 6928, 6908, 6953, 6941, 6923, 6911, + 6927, 6925, 6907, 6954, 6942, 26195, 26193, 26192, 26189, 26188, 26191, + 26190, 26196, 26194, 26187, 26178, 26186, 26184, 26179, 26180, 26182, + 26183, 26177, 26181, 26185, 10361, 10373, 10370, 10355, 10352, 10367, + 10364, 10379, 10358, 24882, 24875, 24883, 24881, 24876, 24877, 24878, + 24880, 24874, 24885, 24884, 26223, 26224, 26225, 26226, 26227, 26228, + 26229, 26230, 26231, 26232, 26233, 26234, 26235, 26236, 26237, 26238, + 26239, 26240, 26241, 26242, 26243, 26244, 26245, 26246, 26247, 26248, + 6851, 6852, 6853, 6854, 6855, 6856, 6857, 6858, 6859, 6860, 6861, 6862, + 6863, 6864, 6865, 6866, 6867, 6868, 6869, 6870, 6871, 6872, 6873, 6874, + 6875, 6876, 6877, 6878, 6879, 6880, 6881, 6882, 6883, 6884, 6885, 6886, + 6887, 6888, 6889, 6890, 6891, 6892, 6893, 6894, 6895, 6896, 6897, 6898, + 6899, 6900, 6901, 6902, 6705, 24401, 24399, 24397, 24402, 24403, 24405, + 24406, 24400, 24404, 24398, 10716, 10714, 10713, 10710, 10709, 10712, + 10711, 10717, 10715, 10708, 24396, 4632, 4578, 4648, 4564, 4641, 4577, + 4640, 4576, 4639, 4575, 4638, 4574, 4629, 4548, 4542, 4571, 4628, 4546, + 4540, 4570, 4647, 4676, 4670, 4563, 4646, 4674, 4668, 4561, 4655, 4692, + 4669, 4541, 4689, 4547, 4675, 4567, 4654, 4691, 4667, 4539, 4688, 4545, + 4673, 4566, 4627, 4582, 4660, 4550, 4544, 4663, 4585, 4569, 4645, 4581, + 4659, 4677, 4671, 4662, 4584, 4562, 4653, 4583, 4661, 4690, 4666, 4543, + 4687, 4587, 4665, 4580, 4658, 4549, 4672, 4664, 4586, 4565, 4631, 4573, + 4630, 4572, 4538, 4534, 4555, 4552, 4530, 4554, 4551, 4529, 4682, 4679, + 4533, 4681, 4678, 4532, 4694, 4685, 4537, 4693, 4684, 4536, 4556, 4553, + 4528, 4683, 4680, 4531, 4695, 4686, 4535, 4589, 4588, 4590, 4591, 4620, + 4614, 4624, 4636, 4643, 4657, 4626, 4557, 4559, 4579, 4568, 4637, 4644, + 4558, 4560, 33134, 20547, 20546, 20549, 20455, 20539, 20552, 20548, + 13050, 19363, 19386, 19399, 19326, 19387, 19342, 19343, 26996, 19688, + 22267, 10037, 33182, 27014, 26780, 26781, 26772, 26773, 26774, 26775, + 26776, 26777, 26778, 26779, 4053, 34605, 34618, 34608, 29436, 29445, + 29435, 29442, 29444, 29434, 4050, 34602, 4046, 34590, 4083, 34640, 4027, + 34586, 4078, 34637, 4077, 34636, 4035, 34594, 4040, 34593, 4039, 34592, + 3974, 34549, 3973, 34548, 4000, 34575, 3999, 34574, 3998, 34573, 3964, + 34538, 34539, 12975, 20554, 34523, 10698, 6679, 5148, 3912, 6670, 6680, + 6671, 6676, 6675, 6677, 19324, 26994, 16349, 16353, 33138, 20449, 33162, + 33198, 20501, 20480, 33143, 20456, 4007, 4006, 4079, 4080, 34487, 29439, + 29446, 29441, 29438, 34621, 34638, 33120, 33121, 17874, 34619, 34615, + 34616, 34620, 34530, 34528, 34529, 34531, 33160, 33215, 20491, 34582, + 4022, 34581, 4021, 20515, 4057, 7187, 33069, 28961, 7635, 4066, 34627, + 19698, 32291, 29670, 2611, 10080, 7653, 25589, 4072, 34629, 2838, 2844, + 2845, 27424, 33071, 15975, 34599, 4064, 27880, 26932, 4005, 4032, 34572, + 34634, 34596, 34547, 28857, 6273, 26796, 3909, 5408, 987, 25693, 6633, + 7863, 7862, 29585, 12944, 102, 14640, 26329, 36009, 32876, 32877, 32882, + 32879, 32881, 32880, 32878, 32875, 34483, 34559, 34603, 4052, 34625, + 12968, 17878, 22702, 12948, 11039, 20859, 16533, 27494, 33288, 24710, + 26625, 2609, 31912, 13242, 6146, 19572, 34212, 20387, 27588, 27422, 6152, + 2689, 26518, 34495, 34511, 34514, 34489, 34498, 34508, 3935, 3951, 3954, + 3929, 3938, 3948, 4065, 34562, 34544, 3963, 34604, 3984, 3969, 34532, + 15976, 26785, 12167, 3624, 3625, 23660, 23658, 23659, 34481, 11044, + 33085, 26826, 26827, 26828, 26829, 26830, 26831, 26832, 26833, 4082, + 26825, 26254, 26361, 34484, 10343, 10344, 10345, 10346, 10347, 10348, + 34525, 34527, 3913, 3916, 23531, 23532, 10383, 10386, 10385, 10384, + 34553, 3980, 14641, 985, 7871, 29579, 27583, 350, 12991, 13238, 29580, + 2624, 12988, 25899, 32268, 32267, 34457, 15824, 10785, 10786, 16336, + 20858, 20857, 20856, 34170, 15967, 22278, 22254, 22271, 21025, 10506, + 33087, 7852, 13156, 24520, 6283, 26063, 16534, 34199, 6636, 4023, 27719, + 27631, 26791, 27714, 28966, 3561, 29512, 34550, 34551, 3977, 3978, 28962, + 29672, 26801, 4059, 32290, 32996, 32995, 34542, 7872, 10425, 25588, + 26502, 6215, 15466, 6693, 6284, 24783, 371, 4073, 34632, 4003, 34570, + 10885, 15321, 19313, 29555, 12936, 4070, 26905, 26906, 2618, 15247, + 26336, 27074, 19438, 16362, 3926, 27885, 6668, 6275, 15930, 13239, 13240, + 20954, 23551, 33070, 13029, 12985, 12950, 27579, 29254, 28855, 16012, + 26348, 32032, 16380, 15223, 13158, 9441, 34554, 4060, 33127, 4063, 20533, + 34597, 34563, 31924, 31911, 226, 12289, 26814, 26806, 34203, 34716, + 20532, 26338, 33197, 34585, 4025, 6449, 15245, 23651, 15281, 2848, 15237, + 25901, 15328, 25572, 15283, 18389, 27724, 25898, 20860, 29583, 13025, + 13023, 15266, 13019, 3981, 34558, 29175, 29613, 6966, 25570, 3927, 25900, + 15285, 26515, 27723, 15236, 25571, 12166, 12161, 12159, 28849, 12160, + 15259, 33016, 28852, 31917, 25569, 15311, 28847, 3979, 34555, 12162, + 6955, 15310, 28964, 32562, 15244, 29174, 15304, 2837, 12165, 15261, 7868, + 27722, 24468, 20531, 33194, 20513, 33212, 4090, 34589, 34552, 3966, + 15263, 19695, 22275, 15327, 15294, 15295, 15254, 15255, 15278, 15277, + 9453, 15264, 15270, 15240, 27270, 12990, 27269, 22261, 22264, 22255, + 22256, 22262, 22265, 15274, 15287, 15273, 15286, 19687, 19685, 22260, + 22263, 10408, 10406, 10405, 10402, 10401, 10404, 10403, 10409, 10407, + 10400, 10419, 10416, 10415, 10412, 10411, 10414, 10413, 10420, 10418, + 10410, 10398, 10395, 10394, 10391, 10390, 10393, 10392, 10399, 10397, + 10389, 15323, 15326, 15282, 15257, 15300, 15288, 15307, 10877, 15291, + 32870, 15313, 10040, 15251, 4041, 32282, 32285, 4042, 15238, 15239, + 29573, 15250, 27090, 19428, 2701, 13041, 15279, 15318, 24863, 9447, + 24865, 6743, 34644, 4096, 4098, 4097, 15241, 15243, 15242, 31918, 15312, + 34477, 15324, 25583, 10718, 32265, 34631, 26342, 25579, 25578, 19361, + 27022, 25695, 26916, 29827, 34150, 21723, 20413, 21543, 29540, 29541, + 34543, 986, 12221, 20529, 33155, 19345, 27012, 13049, 17866, 17865, + 19291, 19290, 19341, 20435, 20418, 33106, 20555, 34533, 34534, 34535, + 34614, 34617, 21724, 21718, 21727, 21721, 21726, 21720, 21725, 21719, + 21728, 21722, 33256, 10867, 982, 7166, 26974, 20421, 20425, 20415, 20419, + 20430, 20417, 20422, 20429, 20420, 20431, 20434, 5073, 4818, 4946, 4819, + 5010, 4883, 4947, 4820, 5042, 4915, 4979, 4852, 5011, 4884, 4948, 4821, + 5058, 4931, 4995, 4868, 5027, 4900, 4964, 4837, 5043, 4916, 4980, 4853, + 5012, 4885, 4949, 4822, 5066, 4939, 5003, 4876, 5035, 4908, 4972, 4845, + 5051, 4924, 4988, 4861, 5020, 4893, 4957, 4830, 5059, 4932, 4996, 4869, + 5028, 4901, 4965, 4838, 5044, 4917, 4981, 4854, 5013, 4886, 4950, 4823, + 5070, 4943, 5007, 4880, 5039, 4912, 4976, 4849, 5055, 4928, 4992, 4865, + 5024, 4897, 4961, 4834, 5063, 4936, 5000, 4873, 5032, 4905, 4969, 4842, + 5048, 4921, 4985, 4858, 5017, 4890, 4954, 4827, 5067, 4940, 5004, 4877, + 5036, 4909, 4973, 4846, 5052, 4925, 4989, 4862, 5021, 4894, 4958, 4831, + 5060, 4933, 4997, 4870, 5029, 4902, 4966, 4839, 5045, 4918, 4982, 4855, + 5014, 4887, 4951, 4824, 5072, 4945, 5009, 4882, 5041, 4914, 4978, 4851, + 5057, 4930, 4994, 4867, 5026, 4899, 4963, 4836, 5065, 4938, 5002, 4875, + 5034, 4907, 4971, 4844, 5050, 4923, 4987, 4860, 5019, 4892, 4956, 4829, + 5069, 4942, 5006, 4879, 5038, 4911, 4975, 4848, 5054, 4927, 4991, 4864, + 5023, 4896, 4960, 4833, 5062, 4935, 4999, 4872, 5031, 4904, 4968, 4841, + 5047, 4920, 4984, 4857, 5016, 4889, 4953, 4826, 5071, 4944, 5008, 4881, + 5040, 4913, 4977, 4850, 5056, 4929, 4993, 4866, 5025, 4898, 4962, 4835, + 5064, 4937, 5001, 4874, 5033, 4906, 4970, 4843, 5049, 4922, 4986, 4859, + 5018, 4891, 4955, 4828, 5068, 4941, 5005, 4878, 5037, 4910, 4974, 4847, + 5053, 4926, 4990, 4863, 5022, 4895, 4959, 4832, 5061, 4934, 4998, 4871, + 5030, 4903, 4967, 4840, 5046, 4919, 4983, 4856, 5015, 4888, 4952, 4825, + 27195, 27194, 19530, 27139, 19352, 27196, 19532, 27141, 10823, 33237, + 33274, 10847, 19534, 27143, 19513, 27188, 27197, 27113, 33239, 10827, + 27126, 27125, 27190, 27192, 27191, 19478, 27133, 19533, 27142, 19455, + 27110, 19475, 27105, 24822, 24802, 24828, 24800, 29059, 29072, 24827, + 24799, 29056, 29071, 27214, 12934, 29057, 24797, 12935, 27215, 24798, + 24826, 34466, 2602, 2601, 2604, 2605, 27091, 19427, 32775, 4508, 32777, + 32776, 20511, 20474, 979, 7163, 27100, 19444, 27895, 27118, 19460, 27109, + 19350, 33277, 19303, 19302, 33094, 33093, 19304, 33095, 19301, 33092, + 19492, 27156, 33251, 10862, 19486, 27150, 33248, 10859, 19491, 27155, + 33250, 10861, 19485, 27149, 33247, 10858, 19488, 33246, 27154, 10856, + 19490, 19484, 27152, 27147, 19489, 19483, 27153, 27148, 33245, 10857, + 26986, 12306, 32566, 19448, 27102, 27101, 19653, 19451, 13660, 29643, + 19450, 29813, 19400, 26991, 33103, 10791, 32890, 36022, 36023, 19392, + 27059, 19394, 27061, 36017, 36013, 36018, 36014, 19373, 27037, 19371, + 27034, 19370, 27035, 19297, 26967, 19298, 26973, 10731, 10756, 19306, + 26977, 10705, 34184, 22149, 26972, 22150, 963, 5, 29191, 29192, 32993, + 26922, 964, 26923, 24966, 24965, 22148, 22147, 22142, 22141, 22146, + 22144, 22145, 22143, 26943, 12268, 12267, 12265, 12266, 6681, 6970, 6957, + 6961, 6958, 6682, 6673, 6683, 33091, 6965, 6688, 6903, 6971, 6672, 6674, + 29504, 29499, 29570, 29556, 29557, 33026, 32869, 32867, 27419, 32866, + 27051, 19378, 34147, 4521, 4522, 4089, 32573, 32574, 34567, 3988, 19397, + 27064, 19314, 26987, 16173, 32500, 16250, 10784, 29447, 16175, 27915, + 12307, 12308, 16014, 13544, 32256, 10804, 10805, 3967, 4008, 34526, 3915, + 12324, 12327, 12323, 12326, 12322, 12325, 27287, 26917, 29018, 26918, + 3902, 3901, 10738, 32886, 19415, 27077, 32575, 22894, 24222, 24220, + 24221, 24230, 24229, 24225, 24226, 33028, 33027, 24224, 23356, 29668, + 26782, 12961, 16331, 16323, 6975, 984, 19771, 19772, 19773, 16324, 26784, + 16328, 16325, 16329, 16327, 16330, 16326, 16480, 17867, 36019, 36020, + 36021, 26617, 26622, 26620, 26616, 26619, 26618, 26621, 22887, 22888, + 22890, 22889, 26613, 26614, 34201, 23650, 23649, 27630, 28938, 23646, + 23647, 6904, 23645, 6698, 26615, 22891, 23648, 16346, 27096, 36015, 377, + 16342, 33080, 33081, 16341, 16340, 33082, 33078, 16339, 33077, 16338, + 33079, 16343, 7179, 7185, 10739, 10740, 7180, 20401, 20409, 10729, 10730, + 33024, 33025, 28877, 28876, 20406, 20403, 20411, 20402, 20410, 20400, + 20404, 20399, 28928, 20408, 20407, 36016, 36012, 12313, 16015, 32884, + 32885, 32568, 32567, 28721, 7654, 12314, 368, 1064, 12303, 26623, 12304, + 10719, 33019, 32276, 12312, 12316, 19670, 13679, 19671, 13680, 19662, + 13666, 19665, 13669, 19663, 13667, 19664, 13668, 19661, 13670, 19655, + 13662, 19654, 13661, 19652, 13658, 19650, 13656, 19649, 13655, 19648, + 13659, 19651, 13657, 28862, 28860, 28863, 28861, 10766, 10765, 10762, + 10761, 28720, 28719, 28718, 28717, 10732, 10734, 10733, 13674, 13663, + 19659, 13677, 19660, 13678, 28936, 17875, 28937, 17876, 12309, 26703, + 29659, 26704, 29660, 26706, 29662, 26702, 29658, 26705, 29661, 26701, + 29657, 10735, 10744, 29654, 29826, 29653, 29825, 29652, 29824, 29651, + 29823, 29646, 29818, 29647, 29819, 29645, 29817, 29648, 29820, 29320, + 29409, 7174, 7176, 7175, 7177, 29641, 29812, 29642, 29811, 29815, 29814, + 12220, 26521, 32862, 13013, 24794, 27894, 27900, 27897, 26343, 34149, + 10753, 34148, 10751, 20412, 27901, 27899, 27898, 10720, 10748, 10742, + 26926, 10521, 34166, 34165, 10790, 26107, 26106, 32889, 32892, 32883, + 32896, 32895, 10764, 10763, 32893, 17864, 10747, 34642, 24231, 24811, + 24838, 29069, 29082, 19355, 19482, 33241, 10829, 24808, 24835, 29066, + 29079, 19357, 33098, 27122, 27123, 19464, 19465, 29440, 29433, 29443, + 29437, 10335, 10336, 10334, 10333, 10701, 3994, 34568, 4087, 34643, 4028, + 34587, 34565, 3985, 15941, 3989, 4011, 34579, 4014, 34583, 4047, 4048, + 34600, 3987, 34566, 4084, 34639, 19300, 32269, 19299, 20423, 19522, + 19521, 19523, 19524, 19458, 19468, 19467, 19517, 19519, 19518, 19452, + 34465, 12305, 26919, 19445, 27108, 27107, 19548, 27204, 26920, 27098, + 32565, 19447, 19446, 27099, 10843, 27892, 27890, 34580, 4049, 34601, + 4038, 34591, 15271, 15284, 15248, 15246, 15249, 28864, 2699, 28865, 2698, + 3743, 27891, 19498, 33260, 27173, 10832, 19359, 33102, 24833, 24806, + 29064, 29077, 19510, 33271, 27185, 10844, 7171, 977, 19509, 33262, 27184, + 10834, 36293, 36293, 24834, 24807, 29065, 29078, 19500, 33270, 27175, + 10842, 15962, 34179, 19499, 33261, 27174, 10833, 19511, 33272, 27186, + 10845, 19481, 33240, 27136, 10831, 974, 975, 973, 976, 26910, 26911, + 24705, 24706, 13020, 27137, 12311, 29925, 32280, 32284, 32281, 32283, + 4001, 4081, 4043, 3975, 10836, 10837, 33264, 33265, 19503, 27178, 19502, + 27177, 3918, 3919, 3920, 3921, 3922, 3924, 3923, 3925, 26958, 26959, + 26956, 26957, 26953, 26955, 26952, 26954, 33285, 33090, 25916, 25915, + 25917, 2843, 6973, 6686, 4054, 3965, 32994, 15940, 4088, 4018, 4010, + 4013, 4016, 24711, 32793, 4496, 19683, 27271, 34557, 27272, 29394, 33073, + 14206, 26629, 26628, 26627, 26626, 32861, 26728, 2619, 15997, 26501, + 24488, 34584, 3968, 32906, 9443, 15221, 36101, 17700, 1059, 97, 34289, + 26640, 19325, 26995, 29586, 29587, 19520, 33276, 27193, 10849, 12329, + 12328, 27720, 27413, 27411, 27412, 27410, 27414, 27415, 12310, 33084, + 27711, 10787, 26262, 26933, 15468, 13444, 13446, 13480, 13454, 13450, + 13481, 13488, 13451, 13487, 13460, 13456, 13455, 13449, 13491, 13462, + 13463, 13464, 13465, 13467, 13469, 13473, 13477, 13490, 13452, 13489, + 13466, 13468, 13470, 13479, 13448, 13472, 13483, 13482, 13484, 13474, + 13486, 13475, 13476, 13485, 13458, 13445, 13457, 13453, 13459, 13471, + 13478, 13461, 13447, 13492, 13494, 13528, 13502, 13498, 13529, 13536, + 13499, 13535, 13508, 13504, 13503, 13497, 13539, 13510, 13511, 13512, + 13513, 13515, 13517, 13521, 13525, 13538, 13500, 13537, 13514, 13516, + 13518, 13527, 13496, 13520, 13531, 13530, 13532, 13522, 13534, 13523, + 13524, 13533, 13506, 13493, 13505, 13501, 13507, 13519, 13526, 13509, + 13495, 18108, 18810, 18109, 18203, 18221, 18508, 19061, 18051, 18725, + 18097, 18789, 18379, 19242, 17921, 18130, 18281, 18282, 19192, 18356, + 19210, 19193, 18056, 18734, 19135, 18649, 19108, 18902, 18437, 19269, + 23018, 18254, 18383, 7662, 7756, 7711, 7805, 7676, 7770, 7673, 7767, + 7717, 7811, 7707, 7801, 7715, 7809, 7678, 7772, 7709, 7803, 7714, 7808, + 7681, 7775, 7686, 7780, 7718, 7812, 7719, 7813, 7682, 7776, 7687, 7781, + 7713, 7807, 7716, 7810, 7708, 7802, 7710, 7804, 7720, 7814, 7684, 7778, + 7680, 7774, 7712, 7806, 7703, 7797, 7670, 7764, 7698, 7792, 7666, 7760, + 7671, 7765, 7672, 7766, 7667, 7761, 7696, 7790, 7706, 7800, 7668, 7762, + 7694, 7788, 7697, 7791, 7661, 7755, 7669, 7763, 7689, 7783, 7690, 7784, + 7685, 7779, 7692, 7786, 7691, 7785, 7688, 7782, 7695, 7789, 7693, 7787, + 7701, 7795, 7699, 7793, 7700, 7794, 7702, 7796, 7816, 7817, 7818, 7820, + 7821, 7815, 7819, 7664, 7758, 7665, 7759, 7660, 7659, 7658, 7663, 7757, + 36293, 36293, 36293, 36293, 36293, 7754, 7751, 7752, 7753, 7749, 7750, + 7822, 13303, 13329, 13314, 13335, 13336, 13334, 13324, 13325, 13337, + 13318, 13327, 13330, 13332, 13338, 13320, 13323, 13328, 13322, 13326, + 13339, 13319, 13317, 13313, 13333, 13321, 13309, 13312, 13316, 13311, + 13310, 13331, 13315, 13304, 13308, 13306, 13341, 13305, 13307, 36293, + 13340, 36293, 36293, 36293, 36293, 36293, 13302, 36293, 36293, 32515, + 32535, 32536, 32516, 32518, 32505, 32544, 32531, 32534, 32532, 32533, + 32554, 32543, 32519, 32509, 32521, 32537, 32504, 32513, 32538, 32542, + 32520, 32510, 32549, 32514, 32555, 32529, 32503, 32511, 32545, 32546, + 32547, 32508, 32512, 32548, 32557, 32539, 32540, 32517, 32507, 32502, + 32522, 32524, 32523, 32525, 32526, 32541, 32527, 32550, 32551, 32552, + 32528, 32506, 32530, 32553, 32556, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 32558, 32559, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 32501, 12762, + 12579, 12666, 12706, 12682, 12369, 12744, 12407, 12597, 12588, 12489, + 12822, 12437, 12422, 12753, 12713, 12398, 12613, 12626, 12474, 12478, + 12477, 12476, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 12696, 12702, 12700, 12697, 12699, 12698, 12701, 36293, 12388, + 12394, 12392, 12389, 12391, 12390, 12393, 36293, 12812, 12818, 12816, + 12813, 12815, 12814, 12817, 36293, 12381, 12387, 12385, 12382, 12384, + 12383, 12386, 36293, 12648, 12654, 12652, 12649, 12651, 12650, 12653, + 36293, 12557, 12563, 12561, 12558, 12560, 12559, 12562, 36293, 12789, + 12795, 12793, 12790, 12792, 12791, 12794, 36293, 12500, 12506, 12504, + 12501, 12503, 12502, 12505, 36293, 7234, 7272, 7269, 7236, 7266, 7267, + 7273, 7240, 7241, 7242, 7249, 7271, 7243, 7237, 7265, 7262, 7264, 7268, + 7252, 7251, 7270, 7238, 7274, 7248, 7235, 7261, 7257, 7259, 7246, 7260, + 7233, 7245, 26969, 26968, 19377, 27041, 19318, 26984, 26805, 26804, + 10704, 19380, 27049, 26813, 19360, 27021, 11046, 26105, 13012, 26928, + 16005, 10703, 10828, 33224, 10706, 10755, 16355, 26064, 16001, 32571, + 19340, 27010, 32570, 32569, 19410, 27055, 32802, 32806, 4501, 4504, + 19365, 27026, 19317, 26989, 33022, 25562, 29500, 12979, 26942, 34182, + 27207, 34704, 32998, 26803, 26815, 33009, 10031, 10032, 32999, 32791, + 33034, 32287, 29600, 34185, 34687, 6151, 10723, 26941, 10726, 10038, + 10743, 16358, 16359, 20445, 20446, 10741, 10700, 32894, 22250, 26104, + 26762, 7825, 7864, 7865, 32659, 22252, 22251, 19375, 27039, 19374, 27038, + 32783, 32787, 4487, 4491, 24967, 36293, 36293, 34686, 16363, 19408, + 27019, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 7057, + 7010, 7060, 7059, 7058, 7053, 6981, 7078, 7092, 7091, 7014, 7061, 7074, + 7073, 7043, 7042, 7041, 7040, 7070, 7079, 7069, 7068, 7029, 7028, 7032, + 7056, 36293, 7013, 7076, 7050, 7015, 7048, 7008, 7084, 7083, 7022, 7052, + 7051, 7062, 7012, 7016, 7037, 6979, 7021, 7072, 7071, 6984, 7067, 6995, + 7090, 7089, 7088, 7087, 7045, 7075, 7055, 7020, 7093, 6983, 6982, 7044, + 7049, 7026, 7025, 7024, 7080, 7011, 7086, 7085, 6999, 7063, 7031, 6998, + 6997, 7023, 7007, 7064, 7082, 7081, 7009, 6991, 7039, 7038, 6994, 6992, + 7047, 7046, 7054, 6985, 7001, 6993, 7003, 6989, 7019, 7018, 7017, 6987, + 7030, 7006, 6980, 7027, 6988, 7005, 6996, 7065, 7066, 6990, 7036, 6986, + 7034, 7002, 7035, 7004, 7077, 7033, 7000, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 16730, 16712, + 16646, 16766, 16754, 16698, 16798, 16713, 16726, 16709, 16661, 16665, + 16650, 16635, 16701, 16787, 16733, 16704, 16738, 16815, 16772, 16743, + 16695, 16800, 16644, 16755, 16631, 16735, 16606, 16724, 16660, 16658, + 16753, 16681, 16683, 16663, 16613, 16812, 16638, 16746, 16700, 16782, + 16705, 16633, 16771, 16722, 16744, 16813, 16731, 16796, 16656, 16761, + 16647, 16715, 16799, 16762, 16621, 16780, 16622, 16774, 16692, 16689, + 16652, 16690, 16623, 16741, 16752, 16645, 16608, 16783, 16728, 16785, + 16751, 16725, 16795, 16706, 16775, 16640, 16806, 16651, 16634, 16680, + 16629, 16773, 16805, 16672, 16630, 16667, 16649, 16688, 16767, 16669, + 16637, 16653, 16736, 16702, 16716, 16790, 16779, 16711, 16817, 16670, + 16617, 16763, 16648, 16808, 16784, 16643, 16666, 16768, 16604, 16777, + 16770, 16794, 16684, 16628, 16778, 16609, 16745, 16764, 16703, 16729, + 16759, 16678, 16734, 16607, 16737, 16657, 16624, 16717, 16718, 16756, + 16605, 16720, 16791, 16732, 16618, 16776, 16636, 16685, 16789, 16699, + 16614, 16804, 16632, 16807, 16757, 16697, 16769, 16801, 16625, 16739, + 16610, 16758, 16748, 16747, 16679, 16620, 16627, 16611, 16721, 16803, + 16639, 16811, 16642, 16802, 16682, 16714, 16687, 16723, 16765, 16760, + 16740, 16616, 16814, 16668, 16707, 16786, 16710, 16781, 16708, 16810, + 16675, 16659, 16693, 16676, 16696, 16619, 16788, 16691, 16671, 16749, + 16626, 16686, 16673, 16612, 16750, 16641, 16809, 16694, 16816, 16719, + 16615, 16664, 16677, 16793, 16655, 16742, 16727, 16662, 16792, 16654, + 16797, 16674, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 16038, 16036, + 16037, 16035, 16050, 16046, 16045, 16042, 16043, 16044, 16040, 16039, + 16047, 16041, 16051, 16049, 16135, 16034, 16133, 10510, 16379, 16134, + 16033, 16053, 19296, 26966, 19315, 26985, 19311, 26982, 19391, 27058, + 19305, 26976, 26642, 13437, 19388, 27053, 19393, 27060, 19396, 27063, + 19395, 27062, 34464, 26925, 10737, 20443, 26643, 15117, 15110, 15107, + 15113, 15112, 15115, 15114, 15118, 15116, 16131, 16130, 16052, 16129, + 14776, 14775, 34470, 34157, 34160, 34158, 34161, 34159, 6956, 16127, + 15111, 15109, 15108, 34156, 21104, 26259, 16132, 16128, 36293, 15845, + 15831, 15847, 15925, 15849, 15927, 15846, 15924, 15848, 15926, 15886, + 15876, 15888, 15878, 15890, 15880, 15887, 15877, 15889, 15879, 15850, + 15911, 15852, 15913, 15854, 15915, 15851, 15912, 15853, 15914, 15906, + 15871, 15908, 15873, 15844, 15910, 15875, 15907, 15872, 15909, 15874, + 15866, 15868, 15870, 15867, 15869, 15881, 15861, 15896, 15883, 15855, + 15898, 15885, 15864, 15900, 15882, 15862, 15897, 15884, 15863, 15899, + 15891, 15893, 15895, 15892, 15894, 15838, 15920, 15840, 15922, 15839, + 15921, 15901, 15903, 15905, 15902, 15904, 15834, 15916, 15918, 15917, + 15919, 15865, 15923, 15841, 15842, 36293, 36293, 7447, 7446, 17062, + 17061, 15929, 15928, 15830, 17059, 16961, 16916, 16992, 17053, 16994, + 17055, 16991, 17052, 16993, 17054, 17015, 17005, 17017, 17007, 17019, + 17009, 17016, 17006, 17018, 17008, 16995, 17040, 16997, 17042, 16999, + 17044, 16996, 17041, 16998, 17043, 17030, 17000, 17032, 17002, 16985, + 17034, 17004, 17031, 17001, 17033, 17003, 16956, 16958, 16960, 16957, + 16959, 17010, 16933, 17020, 17012, 16927, 17022, 17014, 16936, 17024, + 17011, 16934, 17021, 17013, 16935, 17023, 16951, 16937, 16954, 16952, + 16953, 16981, 17049, 16983, 17051, 16982, 17050, 17025, 17027, 17029, + 17026, 17028, 16977, 17045, 17047, 17046, 17048, 16955, 17039, 16973, + 16974, 17035, 17037, 17036, 17038, 17058, 17060, 17057, 17056, 16912, + 36293, 36293, 36293, 36293, 36293, 4468, 4476, 4475, 4473, 4472, 4479, + 4444, 4464, 4432, 4460, 4474, 4470, 4477, 4481, 4457, 4463, 4467, 4478, + 4456, 4462, 4466, 4412, 4448, 4424, 4429, 4413, 4430, 4415, 4455, 4417, + 4425, 4418, 4426, 4431, 4437, 4422, 4443, 4480, 4445, 4434, 4440, 4451, + 4447, 36293, 15029, 15073, 15030, 15035, 15036, 15038, 15065, 15076, + 15051, 15052, 15054, 15056, 15063, 15059, 15055, 15062, 15031, 15041, + 15075, 15042, 15066, 15078, 15023, 15018, 15072, 15017, 15028, 15064, + 15049, 15102, 15013, 15016, 15099, 15100, 15020, 15019, 15086, 15085, + 15103, 15082, 15083, 15104, 15091, 15105, 15081, 15080, 15084, 15095, + 15021, 15101, 15022, 15106, 15074, 15037, 15040, 15039, 15053, 15060, + 15057, 15058, 15061, 15032, 15034, 15033, 15027, 15048, 15046, 15043, + 15044, 15047, 15045, 15025, 15026, 15068, 15069, 15071, 15070, 15067, + 15050, 15079, 15088, 15090, 15089, 15024, 15077, 15087, 15092, 15093, + 15094, 15097, 15096, 15098, 15014, 15015, 36293, 16027, 16030, 16029, + 16025, 16023, 16019, 16026, 16021, 16017, 16020, 16028, 16024, 16018, + 16031, 16032, 16022, 4469, 4458, 4471, 4435, 4428, 4427, 4454, 4450, + 4442, 4419, 4438, 4423, 4441, 4446, 4414, 4416, 4421, 4453, 4449, 4439, + 4410, 4411, 4409, 4408, 4433, 4465, 4459, 4407, 4436, 4461, 4452, 4420, + 7124, 7127, 7128, 7126, 7114, 7100, 7106, 7095, 7105, 7118, 7107, 7103, + 7096, 7104, 7101, 7130, 7094, 7113, 7109, 7122, 7129, 7099, 7108, 7117, + 7116, 7123, 7121, 7110, 7112, 7125, 7120, 7115, 7097, 7102, 7111, 7131, + 7098, 7119, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 16048, 16976, 16988, 16989, 16984, 16987, 16963, 16965, 16967, + 16964, 16966, 16990, 16968, 16970, 16972, 16969, 16971, 26119, 26123, + 26135, 26129, 26121, 26127, 26131, 26137, 26112, 26110, 26117, 26133, + 26125, 26115, 26120, 26124, 26136, 26130, 26122, 26128, 26132, 26138, + 26113, 26111, 26118, 26134, 26126, 26116, 26114, 26176, 26175, 36293, + 26174, 26170, 26168, 26149, 26147, 26167, 26159, 26144, 26153, 26169, + 26152, 26146, 26172, 26171, 26151, 26143, 26166, 26164, 26173, 26161, + 26154, 26162, 26145, 26140, 26150, 26157, 26141, 26163, 26165, 26142, + 26155, 26139, 26148, 26156, 26160, 26158, 6775, 6763, 6785, 6764, 6929, + 6943, 6931, 6913, 6910, 6926, 6924, 6906, 26258, 6944, 6950, 6949, 6946, + 6945, 6948, 6947, 6952, 6951, 6930, 6932, 6938, 6937, 6934, 6933, 6723, + 6727, 6739, 6733, 6725, 6731, 6735, 6716, 6714, 6712, 6721, 6737, 6729, + 6719, 6724, 6728, 6740, 6734, 6726, 6732, 6736, 6717, 6715, 6713, 6722, + 6738, 6730, 6720, 6850, 6849, 6718, 17698, 6798, 6794, 6792, 6760, 6758, + 6790, 6781, 6755, 6773, 6793, 6771, 6757, 6796, 6795, 6769, 6753, 6784, + 6789, 6762, 6786, 6774, 6787, 6756, 6749, 6765, 6780, 6770, 6759, 6783, + 6754, 6791, 6746, 6797, 6777, 6750, 6748, 6761, 6751, 6766, 6767, 6779, + 6768, 6778, 6788, 6782, 6752, 6776, 6744, 6772, 6936, 6935, 6940, 6939, + 6912, 6914, 6920, 6919, 6916, 6915, 6918, 6917, 6922, 6921, 6909, 16118, + 16121, 16122, 16060, 16123, 16119, 16120, 16059, 16125, 16126, 16124, + 16092, 29282, 29248, 29250, 19770, 6844, 6846, 6848, 6845, 6847, 6807, + 6809, 6811, 6808, 6810, 6827, 6829, 6831, 6828, 6830, 6832, 6834, 6836, + 6833, 6835, 6817, 6819, 6821, 6818, 6820, 6802, 6804, 6806, 6803, 6805, + 6812, 6814, 6816, 6813, 6815, 6841, 6843, 6842, 6822, 6824, 6826, 6823, + 6825, 6837, 6839, 6838, 6840, 29246, 29206, 29209, 29208, 29210, 29285, + 29286, 29452, 29249, 29242, 29375, 29379, 29294, 29292, 29293, 29257, + 29258, 29262, 29261, 29308, 29260, 29295, 29298, 29296, 29297, 29263, + 29264, 29305, 29306, 29307, 29304, 29303, 29418, 29419, 29426, 29420, + 29421, 29233, 29237, 29238, 29431, 29368, 29369, 29270, 29382, 29383, + 29214, 29391, 29389, 29390, 29217, 29277, 29276, 29216, 29278, 29271, + 29388, 29386, 29272, 29387, 29385, 29219, 29392, 29218, 29275, 29393, + 29273, 29274, 29332, 29333, 29336, 29335, 29334, 29342, 29343, 29344, + 29339, 29340, 29341, 29450, 29449, 29451, 29410, 29411, 29417, 29416, + 29408, 29407, 29432, 16116, 16117, 16099, 16101, 16108, 16107, 16114, + 16112, 16103, 16110, 16102, 16105, 16098, 16100, 16109, 16106, 16115, + 16113, 16104, 16111, 16093, 16097, 16096, 16095, 16094, 29280, 29232, + 29212, 29215, 29380, 29396, 29234, 29236, 29235, 29290, 29243, 29247, + 29244, 29245, 29224, 29384, 29367, 29349, 29331, 29291, 29313, 29337, + 29267, 29221, 29310, 29397, 29370, 29350, 29351, 29364, 29314, 29283, + 29309, 29361, 29265, 29430, 29352, 29365, 29241, 29316, 29256, 29371, + 29353, 29346, 29225, 29299, 29348, 29227, 29330, 29302, 29347, 29226, + 29329, 29301, 29326, 29327, 29381, 29312, 29363, 29266, 29404, 29405, + 29406, 29401, 29372, 29354, 29366, 29402, 29373, 29355, 29357, 29318, + 29358, 29403, 29374, 29356, 29359, 29319, 29360, 29311, 29328, 29211, + 29220, 29230, 29231, 29228, 29223, 29239, 29268, 29269, 29279, 29284, + 29315, 29300, 29317, 29323, 29324, 29322, 29325, 29338, 29345, 29362, + 29398, 29399, 29395, 29400, 29427, 29428, 29448, 29213, 29205, 16091, + 16076, 16064, 16083, 16082, 16089, 16087, 16078, 16085, 16077, 16080, + 16075, 16063, 16084, 16081, 16090, 16088, 16079, 16086, 16065, 16073, + 16071, 16070, 16067, 16066, 16069, 16068, 16074, 16072, 16061, 16062, + 29259, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 15806, + 15809, 15770, 15820, 15817, 15765, 15803, 15782, 15799, 15816, 15794, + 15800, 15775, 15777, 15787, 15821, 15774, 15818, 15758, 15764, 15762, + 15781, 15801, 15795, 15783, 15780, 15788, 15779, 15804, 15807, 15786, + 15772, 15796, 15778, 15793, 15773, 15808, 15791, 15789, 15768, 15767, + 15785, 15763, 15766, 15776, 15792, 15790, 15810, 15797, 15805, 15802, + 15814, 15769, 15812, 15760, 15811, 15813, 15815, 15771, 15819, 15784, + 15798, 15759, 15761, 35226, 35233, 35225, 35232, 35230, 35231, 35228, + 35229, 36001, 36002, 35999, 36000, 35998, 35996, 35997, 36005, 36006, + 36003, 36004, 36008, 36007, 35873, 34893, 34894, 34887, 34892, 34890, + 34891, 34888, 34889, 34897, 34898, 34895, 34896, 34878, 34876, 34877, + 34901, 34902, 34899, 34900, 34886, 34884, 34885, 34882, 34883, 34875, + 34881, 34880, 34879, 34907, 34908, 34903, 34906, 34905, 34904, 35605, + 35606, 35600, 35604, 35603, 35601, 35602, 35609, 35610, 35607, 35608, + 35594, 35592, 35593, 35613, 35614, 35611, 35612, 35598, 35599, 35591, + 35597, 35596, 35595, 35619, 35620, 35615, 35618, 35617, 35616, 34861, + 34862, 34855, 34860, 34858, 34859, 34856, 34857, 34865, 34866, 34863, + 34864, 34846, 34844, 34845, 34869, 34870, 34867, 34868, 34854, 34852, + 34853, 34850, 34851, 34843, 34849, 34848, 34847, 34873, 34874, 34871, + 34872, 35408, 35409, 35403, 35407, 35406, 35404, 35405, 35412, 35413, + 35410, 35411, 35416, 35417, 35414, 35415, 35422, 35423, 35418, 35421, + 35420, 35419, 35428, 35429, 35424, 35427, 35426, 35425, 35151, 35152, + 35146, 35150, 35149, 35147, 35148, 35155, 35156, 35153, 35154, 35140, + 35138, 35139, 35159, 35160, 35157, 35158, 35144, 35145, 35137, 35143, + 35142, 35141, 35165, 35161, 35164, 35163, 35162, 35387, 35388, 35382, + 35386, 35385, 35383, 35384, 35391, 35392, 35389, 35390, 35375, 35376, + 35373, 35374, 35395, 35396, 35393, 35394, 35402, 35401, 35380, 35381, + 35372, 35379, 35378, 35377, 35399, 35400, 35397, 35398, 35032, 35033, + 35030, 35031, 35028, 35029, 35026, 35027, 35025, 35023, 35024, 35042, + 35043, 35038, 35041, 35040, 35039, 35036, 35037, 35034, 35035, 35851, + 35852, 35845, 35850, 35848, 35849, 35846, 35847, 35855, 35856, 35853, + 35854, 35859, 35860, 35857, 35858, 35844, 35843, 35865, 35866, 35861, + 35864, 35863, 35862, 35871, 35872, 35867, 35870, 35869, 35868, 35010, + 35011, 35005, 35009, 35008, 35006, 35007, 35017, 35018, 35015, 35016, + 34999, 34998, 35021, 35022, 35019, 35020, 35014, 35012, 35013, 35003, + 35004, 34997, 35002, 35001, 35000, 35830, 35831, 35825, 35829, 35828, + 35826, 35827, 35837, 35838, 35835, 35836, 35818, 35819, 35816, 35817, + 35841, 35842, 35839, 35840, 35834, 35832, 35833, 35823, 35824, 35815, + 35822, 35821, 35820, 34984, 34985, 34979, 34983, 34982, 34980, 34981, + 34991, 34992, 34989, 34990, 34973, 34971, 34972, 34995, 34996, 34993, + 34994, 34988, 34986, 34987, 34977, 34978, 34970, 34976, 34975, 34974, + 35434, 35435, 35430, 35433, 35432, 35431, 35441, 35442, 35439, 35440, + 35445, 35446, 35443, 35444, 35438, 35436, 35437, 35451, 35452, 35447, + 35450, 35449, 35448, 35181, 35182, 35175, 35180, 35178, 35179, 35176, + 35177, 35185, 35186, 35183, 35184, 35170, 35169, 35167, 35168, 35166, + 35174, 35172, 35173, 35171, 35579, 35580, 35574, 35578, 35577, 35575, + 35576, 35583, 35581, 35582, 35568, 35566, 35567, 35589, 35590, 35587, + 35588, 35586, 35584, 35585, 35572, 35573, 35565, 35571, 35570, 35569, + 35119, 35120, 35114, 35118, 35117, 35115, 35116, 35129, 35130, 35127, + 35128, 35108, 35106, 35107, 35126, 35124, 35125, 35123, 35121, 35122, + 35112, 35113, 35105, 35111, 35110, 35109, 35135, 35136, 35131, 35134, + 35133, 35132, 35334, 35335, 35328, 35333, 35331, 35332, 35329, 35330, + 35338, 35339, 35336, 35337, 35318, 35319, 35316, 35317, 35342, 35343, + 35340, 35341, 35327, 35325, 35326, 35323, 35324, 35315, 35322, 35321, + 35320, 35348, 35349, 35344, 35347, 35346, 35345, 35088, 35089, 35082, + 35087, 35085, 35086, 35083, 35084, 35092, 35093, 35090, 35091, 35075, + 35076, 35073, 35074, 35100, 35101, 35098, 35099, 35096, 35097, 35094, + 35095, 35080, 35081, 35072, 35079, 35078, 35077, 35301, 35302, 35296, + 35300, 35299, 35297, 35298, 35305, 35306, 35303, 35304, 35290, 35288, + 35289, 35313, 35314, 35311, 35312, 35309, 35310, 35307, 35308, 35294, + 35295, 35287, 35293, 35292, 35291, 35048, 35049, 35044, 35047, 35045, + 35046, 35062, 35063, 35060, 35061, 35053, 35054, 35051, 35052, 35070, + 35071, 35068, 35069, 35066, 35067, 35064, 35065, 35058, 35059, 35050, + 35057, 35056, 35055, 35371, 35370, 35364, 35365, 35362, 35363, 35353, + 35351, 35352, 35368, 35369, 35366, 35367, 35361, 35359, 35360, 35357, + 35358, 35350, 35356, 35355, 35354, 35200, 35201, 35194, 35199, 35197, + 35198, 35195, 35196, 35204, 35205, 35202, 35203, 35189, 35190, 35187, + 35188, 35208, 35209, 35206, 35207, 35193, 35191, 35192, 35461, 35459, + 35460, 35464, 35465, 35462, 35463, 35454, 35455, 35453, 35468, 35469, + 35466, 35467, 35458, 35456, 35457, 35104, 35103, 35102, 35219, 35220, + 35217, 35218, 35212, 35213, 35210, 35211, 35223, 35224, 35221, 35222, + 35216, 35214, 35215, 35885, 35886, 35883, 35884, 35876, 35874, 35875, + 35882, 35880, 35881, 35879, 35877, 35878, 35948, 35949, 35943, 35947, + 35946, 35944, 35945, 35984, 35985, 35982, 35983, 35937, 35935, 35936, + 35988, 35989, 35986, 35987, 35981, 35979, 35980, 35941, 35942, 35934, + 35940, 35939, 35938, 35994, 35995, 35990, 35993, 35992, 35991, 34954, + 34955, 34948, 34953, 34951, 34952, 34949, 34950, 34958, 34959, 34956, + 34957, 34939, 34937, 34938, 34962, 34963, 34960, 34961, 34947, 34945, + 34946, 34943, 34944, 34936, 34942, 34941, 34940, 34968, 34969, 34964, + 34967, 34966, 34965, 35962, 35963, 35956, 35961, 35959, 35960, 35957, + 35958, 35966, 35967, 35964, 35965, 35955, 35953, 35954, 35952, 35950, + 35951, 35972, 35968, 35971, 35970, 35969, 35977, 35978, 35973, 35976, + 35975, 35974, 35551, 35552, 35546, 35550, 35549, 35547, 35548, 35555, + 35556, 35553, 35554, 35539, 35538, 35545, 35544, 35564, 35563, 35543, + 35537, 35542, 35541, 35540, 35561, 35562, 35557, 35560, 35559, 35558, + 35796, 35797, 35791, 35795, 35794, 35792, 35793, 35803, 35804, 35801, + 35802, 35785, 35783, 35784, 35807, 35808, 35805, 35806, 35800, 35798, + 35799, 35789, 35790, 35782, 35788, 35787, 35786, 35813, 35814, 35809, + 35812, 35811, 35810, 35732, 35733, 35727, 35731, 35730, 35728, 35729, + 35739, 35740, 35737, 35738, 35743, 35744, 35741, 35742, 35736, 35734, + 35735, 35747, 35748, 35745, 35746, 35753, 35754, 35749, 35752, 35751, + 35750, 35918, 35919, 35916, 35917, 35910, 35908, 35909, 35926, 35927, + 35924, 35925, 35922, 35923, 35920, 35921, 35914, 35915, 35907, 35913, + 35912, 35911, 35932, 35933, 35928, 35931, 35930, 35929, 34920, 34921, + 34918, 34919, 34912, 34913, 34910, 34911, 34928, 34929, 34926, 34927, + 34924, 34925, 34922, 34923, 34917, 34909, 34916, 34915, 34914, 34934, + 34935, 34930, 34933, 34932, 34931, 35700, 35699, 35679, 35678, 35691, + 35692, 35689, 35690, 35687, 35688, 35685, 35686, 35683, 35684, 35677, + 35682, 35681, 35680, 35697, 35698, 35693, 35696, 35695, 35694, 35500, + 35501, 35498, 35499, 35497, 35495, 35496, 35504, 35505, 35502, 35503, + 35510, 35511, 35506, 35509, 35508, 35507, 35516, 35517, 35512, 35515, + 35514, 35513, 35766, 35767, 35764, 35765, 35758, 35756, 35757, 35774, + 35775, 35772, 35773, 35770, 35771, 35768, 35769, 35762, 35763, 35755, + 35761, 35760, 35759, 35780, 35781, 35776, 35779, 35778, 35777, 35715, + 35716, 35713, 35714, 35704, 35702, 35703, 35719, 35720, 35717, 35718, + 35712, 35710, 35711, 35708, 35709, 35701, 35707, 35706, 35705, 35725, + 35726, 35721, 35724, 35723, 35722, 35275, 35276, 35269, 35274, 35272, + 35273, 35270, 35271, 35262, 35263, 35260, 35261, 35279, 35280, 35277, + 35278, 35267, 35268, 35259, 35266, 35265, 35264, 35285, 35286, 35281, + 35284, 35283, 35282, 35637, 35638, 35631, 35636, 35634, 35635, 35632, + 35633, 35624, 35625, 35622, 35623, 35641, 35642, 35639, 35640, 35629, + 35630, 35621, 35628, 35627, 35626, 35647, 35648, 35643, 35646, 35645, + 35644, 35249, 35250, 35243, 35248, 35246, 35247, 35244, 35245, 35237, + 35235, 35236, 35253, 35254, 35251, 35252, 35241, 35242, 35234, 35240, + 35239, 35238, 35257, 35258, 35255, 35256, 35483, 35484, 35477, 35482, + 35480, 35481, 35478, 35479, 35472, 35471, 35487, 35488, 35485, 35486, + 35476, 35470, 35475, 35474, 35473, 35493, 35494, 35489, 35492, 35491, + 35490, 35531, 35532, 35525, 35530, 35528, 35529, 35526, 35527, 35521, + 35519, 35520, 35535, 35536, 35533, 35534, 35523, 35524, 35518, 35522, + 35893, 35894, 35887, 35892, 35890, 35891, 35888, 35889, 35906, 35905, + 35897, 35898, 35895, 35896, 35903, 35904, 35899, 35902, 35901, 35900, + 35665, 35666, 35659, 35664, 35662, 35663, 35660, 35661, 35652, 35653, + 35650, 35651, 35669, 35670, 35667, 35668, 35657, 35658, 35649, 35656, + 35655, 35654, 35675, 35676, 35671, 35674, 35673, 35672, 36293, 36293, + 36293, 34840, 34813, 34811, 34818, 34792, 34828, 34799, 34801, 34817, + 34804, 34815, 34788, 34816, 34834, 34822, 34803, 34829, 34802, 34835, + 34793, 34796, 34789, 34798, 34819, 34830, 34842, 34807, 34838, 34823, + 34806, 34833, 34831, 34827, 34832, 34839, 34810, 34820, 34809, 34800, + 34808, 34841, 34797, 34824, 34814, 34791, 34790, 34795, 34805, 34825, + 34836, 34826, 34794, 34837, 34821, 34812, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 20373, 20362, 20361, 20345, 20343, + 20342, 20356, 20360, 20359, 20375, 20354, 20353, 20344, 20341, 20340, + 20377, 20350, 20376, 20364, 20367, 20368, 20349, 20358, 20379, 20357, + 20374, 20378, 20363, 20366, 20355, 20369, 20370, 20351, 20352, 20380, + 20371, 20346, 20347, 20348, 20372, 20336, 20339, 20337, 20335, 20338, + 20334, 20381, 20382, 33554, 33555, 33391, 33540, 33541, 33514, 33317, + 33324, 33427, 33400, 33434, 33374, 33500, 33528, 33352, 33345, 33303, + 33296, 33418, 33521, 33310, 33453, 33338, 33331, 33366, 33359, 33493, + 33507, 33472, 33535, 33413, 33459, 33380, 33441, 33486, 33479, 33563, + 33564, 33395, 33396, 33549, 33550, 33516, 33319, 33326, 33429, 33406, + 33436, 33377, 33502, 33530, 33354, 33347, 33305, 33298, 33422, 33523, + 33312, 33455, 33340, 33333, 33368, 33361, 33495, 33509, 33474, 33537, + 33414, 33464, 33385, 33443, 33488, 33481, 33561, 33562, 33466, 33393, + 33394, 33547, 33548, 33515, 33318, 33325, 33428, 33404, 33405, 33435, + 33376, 33501, 33529, 33353, 33346, 33304, 33297, 33421, 33522, 33311, + 33454, 33339, 33332, 33367, 33360, 33494, 33508, 33473, 33536, 33410, + 33411, 33463, 33384, 33442, 33487, 33480, 33558, 33559, 33389, 33544, + 33545, 33512, 33315, 33322, 33425, 33403, 33432, 33372, 33498, 33526, + 33350, 33343, 33301, 33294, 33420, 33519, 33308, 33451, 33336, 33329, + 33364, 33357, 33491, 33505, 33470, 33533, 33409, 33462, 33383, 33439, + 33484, 33477, 33565, 33566, 33397, 33398, 33551, 33552, 33517, 33320, + 33327, 33430, 33407, 33437, 33378, 33503, 33531, 33355, 33348, 33306, + 33299, 33423, 33524, 33313, 33456, 33341, 33334, 33369, 33362, 33496, + 33510, 33475, 33538, 33415, 33465, 33386, 33444, 33489, 33482, 33557, + 33560, 33468, 33387, 33388, 33543, 33546, 33511, 33314, 33321, 33424, + 33402, 33431, 33370, 33371, 33497, 33525, 33349, 33342, 33300, 33293, + 33419, 33518, 33307, 33445, 33335, 33328, 33363, 33356, 33490, 33504, + 33469, 33532, 33408, 33461, 33382, 33438, 33483, 33476, 33553, 33556, + 33467, 33390, 33392, 33539, 33542, 33513, 33316, 33323, 33426, 33399, + 33401, 33433, 33373, 33375, 33499, 33527, 33351, 33344, 33302, 33295, + 33416, 33520, 33309, 33452, 33337, 33330, 33365, 33358, 33492, 33506, + 33471, 33534, 33412, 33458, 33460, 33379, 33381, 33440, 33485, 33478, + 33457, 33417, 33290, 33291, 33292, 33448, 33449, 33446, 33570, 33573, + 33576, 33575, 33579, 33571, 33578, 33569, 33567, 33574, 33577, 33568, + 33572, 33586, 33588, 33585, 33584, 33581, 33580, 33583, 33582, 33589, + 33587, 33450, 33447, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 9784, 9985, 9673, 9832, 9622, 9926, 9728, 9887, + 9669, 9828, 9749, 9912, 9658, 9817, 9616, 9913, 9777, 9978, 9725, 9884, + 9624, 9928, 9726, 9885, 9665, 9824, 9657, 9816, 9722, 9881, 9779, 9980, + 9623, 9927, 9768, 9946, 9765, 9943, 9766, 9944, 9748, 9911, 9655, 9814, + 9670, 9829, 9799, 7288, 7280, 7231, 7281, 28866, 7255, 7244, 7258, 7254, + 7263, 7256, 7253, 7250, 7286, 7275, 9798, 9802, 9679, 9838, 9677, 9836, + 9789, 9990, 9667, 9826, 9675, 9834, 9629, 9954, 9637, 9963, 9633, 9958, + 9632, 9957, 9635, 9961, 9713, 9872, 9763, 9941, 9671, 9830, 9666, 9825, + 23030, 23067, 7239, 7247, 3505, 2867, 3508, 2869, 3504, 3480, 3497, 3507, + 2896, 3506, 2872, 3477, 3483, 3482, 2870, 2876, 3496, 2895, 2889, 2875, + 3492, 2883, 3487, 3493, 3486, 3490, 2865, 2861, 2893, 2892, 2887, 3499, + 3489, 3500, 3501, 2894, 2859, 3473, 2888, 2891, 3476, 3502, 3474, 2856, + 3485, 2874, 2881, 2898, 3479, 3484, 2860, 2884, 2885, 2886, 3488, 3475, + 2858, 2857, 3503, 2897, 2873, 3478, 2871, 2862, 2878, 3481, 2877, 2880, + 3498, 2868, 2882, 2879, 3495, 2866, 3494, 2890, 3491, 2855, 2863, 2864, + 2852, 2851, 3509, 3511, 2854, 2853, 3510, 3512, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 23027, 23023, 23026, 23022, 23028, + 23024, 23029, 23025, 23082, 23097, 23126, 23105, 23087, 23081, 23096, + 23125, 23104, 23086, 23083, 23098, 23127, 23109, 23088, 23074, 23073, + 23075, 23120, 23138, 23136, 23139, 23137, 23117, 23340, 23341, 18018, + 18669, 18019, 18670, 18058, 18737, 18296, 19136, 18295, 19088, 17957, + 18584, 17958, 18585, 18446, 18454, 17924, 18519, 17925, 18520, 17926, + 18521, 17922, 18517, 17923, 18518, 17927, 18522, 18236, 19001, 18099, + 18791, 18096, 18788, 18100, 18792, 17941, 18555, 18116, 18815, 18151, + 18901, 18152, 18903, 18199, 18938, 18204, 18942, 18202, 18940, 18205, + 18943, 18216, 18960, 18215, 18957, 18232, 18964, 18239, 19006, 18339, + 19188, 18348, 19201, 18343, 19196, 18290, 19080, 18291, 19081, 18347, + 19200, 18020, 18681, 18087, 18778, 17959, 18586, 23351, 18629, 18837, + 18853, 18876, 19005, 18435, 19132, 19185, 18080, 18766, 18081, 18767, + 18082, 18279, 19095, 18285, 19130, 18083, 18769, 18084, 18770, 18085, + 18771, 23103, 23071, 23149, 18264, 19029, 18283, 18820, 18462, 18144, + 18867, 17951, 18572, 18570, 18731, 17930, 18525, 18027, 18696, 18344, + 19197, 18345, 19198, 18346, 19199, 18035, 18709, 18103, 18796, 18147, + 18872, 18230, 18987, 18256, 19027, 18054, 18234, 18260, 18119, 18263, + 18453, 18284, 18287, 18090, 17960, 17942, 18556, 18197, 18936, 18335, + 19176, 18040, 18715, 18041, 18716, 18042, 18717, 18194, 18927, 17919, + 18514, 17949, 18257, 18385, 17964, 18591, 18253, 19021, 18240, 18252, + 19020, 18209, 18949, 17954, 18579, 17977, 18621, 17976, 18618, 18133, + 18852, 18266, 19047, 18122, 18825, 18123, 17955, 36293, 36293, 36293, + 36293, 18219, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 23015, 23002, 23005, 23014, + 18233, 18990, 18395, 22997, 23254, 18440, 18393, 18394, 18391, 18392, + 18390, 29865, 29867, 29877, 29869, 29866, 29868, 29876, 29857, 29856, + 29853, 29852, 29875, 29851, 29850, 29855, 29854, 29845, 29844, 29839, + 29838, 29847, 29846, 29841, 29840, 29863, 29859, 29858, 29849, 29848, + 29862, 29843, 29861, 29842, 29864, 29860, 29879, 29881, 29882, 29880, + 29878, 29870, 29871, 29872, 29873, 29874, 36293, 36293, 36293, 24819, + 24818, 24821, 24816, 24817, 24820, 24813, 24812, 24815, 24814, 36293, + 36293, 36293, 36293, 36293, 36293, 26395, 26394, 26383, 26384, 26371, + 26373, 26405, 26386, 26393, 26392, 26376, 26387, 26397, 26396, 26402, + 26407, 26389, 26388, 26375, 26410, 26398, 26399, 26377, 26412, 26409, + 26406, 26378, 26379, 26404, 26368, 26413, 26415, 26400, 26414, 26408, + 26411, 26403, 26382, 26401, 26420, 26421, 26391, 26390, 26374, 26385, + 26369, 26381, 26380, 26370, 26419, 26422, 26372, 26418, 26423, 26417, + 26416, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 27546, + 27548, 27495, 27496, 27516, 27517, 27512, 27513, 27507, 27508, 27509, + 27510, 27539, 27540, 27497, 27514, 27515, 27498, 27536, 27535, 27532, + 27531, 27520, 27530, 27529, 27534, 27533, 27522, 27504, 27503, 27500, + 27499, 27521, 27506, 27505, 27502, 27501, 27523, 27538, 27537, 27528, + 27527, 27542, 27544, 27543, 27519, 27511, 27524, 27525, 27526, 27541, + 27518, 27561, 27562, 27573, 27574, 27565, 27566, 27567, 27568, 27569, + 27570, 27575, 27576, 27563, 27571, 27572, 27564, 27547, 27545, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 27550, 27549, 27557, + 27559, 27556, 27555, 27552, 27551, 27554, 27553, 27560, 27558, 36293, + 36293, 36293, 36293, 36293, 36293, 7306, 7308, 7305, 7304, 7301, 7300, + 7303, 7302, 7309, 7307, 7297, 7298, 7293, 7294, 7295, 7296, 7292, 7299, + 10273, 10267, 10280, 10269, 10268, 10266, 10281, 10169, 10167, 10172, + 10274, 10324, 10179, 10291, 17194, 17196, 17193, 17192, 17189, 17188, + 17191, 17190, 17197, 17195, 17158, 17157, 17168, 17154, 17162, 17161, + 17175, 17155, 17164, 17152, 17156, 17160, 17159, 17170, 17167, 17165, + 17171, 17174, 17169, 17173, 17163, 17153, 17172, 17166, 17176, 17150, + 17177, 17151, 17186, 17183, 17185, 17184, 17187, 17182, 17180, 17181, + 17178, 17179, 26883, 26880, 26872, 26888, 26879, 26874, 26885, 26877, + 26876, 26878, 26882, 26870, 26887, 26886, 26884, 26890, 26889, 26881, + 26875, 26871, 26873, 26869, 26891, 26898, 26900, 26893, 26896, 26899, + 26897, 26895, 26894, 26866, 26865, 26868, 26867, 26901, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 26892, + 14764, 14767, 14768, 14765, 14722, 14723, 14731, 14725, 14727, 14730, + 14724, 14720, 14726, 14728, 14721, 14687, 14689, 14690, 14703, 14710, + 14717, 14752, 14669, 14676, 14750, 14754, 14700, 14773, 14756, 36293, + 36293, 36293, 16456, 16452, 16455, 16454, 16426, 16394, 16393, 16395, + 16435, 16414, 16400, 16401, 16433, 16427, 16434, 16396, 16397, 16398, + 16410, 16411, 16399, 16408, 16409, 16424, 16403, 16425, 16402, 16422, + 16423, 16389, 16390, 16405, 16420, 16421, 16391, 16392, 16404, 16412, + 16413, 16406, 16407, 16430, 16432, 16415, 16416, 16429, 16431, 16418, + 16419, 16417, 16428, 16453, 16459, 16461, 16462, 16463, 16457, 16458, + 16460, 16465, 16464, 16385, 16386, 16387, 16450, 16388, 16436, 16439, + 16448, 16441, 16446, 16444, 16442, 16440, 16437, 16438, 16443, 16451, + 36293, 16449, 16472, 16474, 16471, 16470, 16467, 16466, 16469, 16468, + 16475, 16473, 36293, 36293, 36293, 36293, 16445, 16447, 24037, 24035, + 24030, 24027, 24033, 24123, 24101, 24053, 24065, 24061, 24060, 24063, + 24062, 24055, 24054, 24052, 24165, 24167, 24164, 24163, 24160, 24159, + 24162, 24161, 24168, 24166, 24064, 24057, 24056, 24059, 24058, 36293, + 6395, 6413, 6415, 6412, 6396, 6414, 6404, 6403, 6400, 6399, 6375, 6376, + 6398, 6397, 6402, 6401, 6377, 6379, 6378, 6406, 6405, 6392, 6391, 6380, + 6381, 6390, 6386, 6385, 6384, 6389, 6388, 6382, 6383, 6387, 6411, 6409, + 6408, 6410, 6393, 6394, 6407, 6420, 6423, 6424, 6429, 6427, 6426, 6425, + 6421, 6422, 6428, 6363, 6361, 6360, 6362, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 6369, 6368, 6365, 6357, 6367, 6373, + 6364, 6371, 6374, 6372, 6370, 6366, 6359, 6358, 36293, 36293, 6436, 6438, + 6435, 6434, 6431, 6430, 6433, 6432, 6439, 6437, 36293, 36293, 6416, 6418, + 6417, 6419, 24007, 24000, 23999, 24004, 24003, 23997, 23996, 23995, + 23993, 23992, 23994, 23998, 24009, 24002, 24001, 24006, 24100, 24010, + 24011, 24008, 24097, 24098, 24099, 24138, 24140, 24139, 23982, 24134, + 24125, 24126, 24046, 24047, 30349, 30325, 30348, 30324, 30347, 30323, + 30362, 30338, 30356, 30332, 30351, 30327, 30350, 30326, 30367, 30343, + 30357, 30333, 30360, 30336, 30355, 30331, 30354, 30330, 30358, 30334, + 30359, 30335, 30353, 30329, 30352, 30328, 30361, 30337, 30365, 30341, + 30369, 30345, 30366, 30342, 30364, 30340, 30368, 30344, 30363, 30339, + 30370, 30346, 30371, 30383, 30391, 30388, 30387, 30393, 30394, 30372, + 30392, 30389, 30390, 30382, 30386, 30385, 30384, 30381, 30378, 30379, + 30380, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 30374, 30375, 30377, 30376, 30373, + 22330, 22331, 22289, 22306, 22317, 22316, 22293, 22292, 22305, 22311, + 22312, 22344, 22346, 22336, 22338, 22337, 22284, 22281, 22283, 22333, + 22334, 22348, 22349, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 12724, 12722, 12721, 12720, 12719, 12723, 36293, + 36293, 12418, 12416, 12415, 12414, 12413, 12417, 36293, 36293, 12433, + 12431, 12430, 12429, 12428, 12432, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 12374, 12380, 12378, 12375, 12377, 12376, + 12379, 36293, 12359, 12365, 12363, 12360, 12362, 12361, 12364, 36293, + 18539, 18509, 18554, 18545, 18658, 18830, 19037, 18818, 18809, 18812, + 18843, 18857, 18672, 18552, 18553, 18932, 18773, 19098, 19097, 19100, + 19101, 19051, 18431, 18989, 18619, 18967, 18620, 19038, 19039, 18551, + 19175, 19139, 19184, 19126, 19180, 18575, 18576, 18577, 19218, 19215, + 19216, 19217, 19230, 22981, 23229, 23243, 23244, 23326, 19030, 18776, + 18933, 19186, 18772, 13936, 18627, 19091, 19103, 23323, 23122, 23146, + 18258, 18259, 36293, 36293, 6618, 6619, 6620, 6621, 6622, 6623, 6581, + 6617, 6582, 6583, 6584, 6585, 6586, 6546, 6547, 6548, 6549, 6550, 6551, + 6587, 6588, 6589, 6590, 6591, 6592, 6593, 6594, 6595, 6596, 6597, 6552, + 6545, 6553, 6554, 6555, 6556, 6557, 6558, 6599, 6600, 6601, 6602, 6603, + 6604, 6560, 6559, 6561, 6562, 6563, 6564, 6565, 6539, 6578, 6540, 6579, + 6541, 6580, 6542, 6543, 6544, 6538, 6566, 6567, 6568, 6569, 6570, 6571, + 6572, 6573, 6574, 6575, 6576, 6577, 6605, 6606, 6607, 6608, 6609, 6610, + 6611, 22298, 22310, 22320, 22322, 22307, 22301, 22288, 22313, 22300, + 22303, 22315, 22326, 22328, 22324, 22329, 22318, 22309, 22327, 22295, + 22296, 22325, 22287, 22297, 22291, 22294, 22290, 22286, 22299, 22321, + 22323, 22308, 22302, 22314, 22304, 22319, 22340, 22343, 22335, 22342, + 22341, 22345, 22339, 22347, 22285, 22332, 22282, 36293, 36293, 22356, + 22358, 22355, 22354, 22351, 22350, 22353, 22352, 22359, 22357, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 14961, 14959, 14992, 14993, 14994, 14970, 14971, 15003, 15005, + 14938, 14936, 14935, 14939, 14945, 14946, 14948, 14947, 14952, 14949, + 14950, 14954, 14922, 14920, 36293, 36293, 36293, 36293, 14818, 14819, + 14887, 14888, 14907, 14901, 14902, 14905, 14904, 14903, 14862, 14847, + 14886, 14853, 14857, 14856, 14870, 14869, 14790, 14815, 14808, 14893, + 14806, 14813, 14843, 14836, 14842, 14897, 14838, 14841, 14840, 14881, + 14874, 14891, 14892, 14880, 14878, 14877, 14882, 14884, 14829, 14828, + 14914, 14915, 14779, 14778, 14894, 14833, 14831, 36293, 36293, 36293, + 36293, 19252, 19255, 19256, 19253, 19254, 19258, 19260, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 2592, 2593, 2591, 2594, 2590, 36293, 36293, 36293, 36293, 36293, 15427, + 15456, 15432, 15363, 15419, 15422, 15424, 15423, 15418, 15425, 15421, + 15420, 15364, 15397, 15398, 15395, 15396, 15361, 15362, 15360, 15368, + 15410, 15408, 15385, 15417, 15390, 36293, 15402, 15428, 15376, 15371, + 15412, 36293, 15414, 36293, 15388, 15392, 36293, 15378, 15374, 36293, + 15406, 15383, 15400, 15394, 15404, 15416, 15367, 15370, 15373, 15429, + 1192, 1191, 1222, 1220, 1221, 1223, 1452, 1450, 1451, 1453, 1217, 1215, + 1216, 1218, 1583, 1581, 1582, 1584, 1562, 1560, 1561, 1563, 1578, 1576, + 1577, 1579, 1596, 1594, 1595, 1597, 1457, 1455, 1456, 1458, 1258, 1256, + 1257, 1259, 1429, 1427, 1428, 1430, 1539, 1537, 1538, 1540, 1544, 1542, + 1543, 1545, 1248, 1247, 1239, 1238, 1262, 1261, 1251, 1250, 1358, 1357, + 1487, 1486, 1381, 1379, 1380, 1382, 1292, 1290, 1291, 1293, 1304, 1302, + 1303, 1305, 1420, 1418, 1419, 1421, 1434, 1433, 1491, 1489, 1490, 1492, + 1334, 1333, 1329, 1327, 1328, 1330, 1338, 1336, 1337, 1339, 1620, 1619, + 1618, 1617, 2453, 2452, 2461, 2460, 2457, 2456, 2455, 2454, 2465, 2464, + 2451, 2459, 2458, 2467, 2463, 2462, 2466, 1784, 1732, 1961, 1958, 1959, + 1954, 1955, 1956, 1948, 1761, 1762, 1759, 1760, 1984, 1673, 1677, 1424, + 1422, 1423, 1425, 1589, 1588, 1642, 1641, 1639, 1638, 1587, 1599, 1598, + 1385, 1384, 1388, 1387, 1655, 1653, 1654, 1656, 1590, 1591, 2128, 2127, + 2130, 2129, 2149, 2148, 2157, 2156, 2147, 2146, 2153, 2152, 2133, 2131, + 2132, 2182, 2180, 2181, 1272, 1270, 1271, 1273, 2139, 2137, 2143, 2126, + 2151, 1703, 1694, 1699, 1706, 1701, 1712, 2091, 2079, 2086, 2099, 2102, + 2107, 2109, 2114, 2111, 2120, 1788, 1794, 1771, 1766, 1827, 1823, 1829, + 1998, 1991, 2003, 2011, 1968, 1972, 1725, 1717, 1721, 1727, 2072, 2067, + 2184, 1668, 1664, 1756, 1752, 1740, 1745, 1736, 1743, 1738, 1747, 1933, + 1929, 1931, 1935, 1802, 1804, 1812, 1810, 1807, 1818, 1800, 1821, 1855, + 1847, 1859, 1865, 1839, 1868, 1886, 1875, 1880, 1890, 1869, 1891, 1907, + 1897, 1919, 1912, 1915, 1922, 1781, 1777, 1778, 1779, 2167, 2160, 2169, + 2175, 2124, 2179, 2108, 1963, 1686, 2019, 2022, 2026, 2020, 2023, 2025, + 2155, 2154, 2141, 2145, 2125, 2150, 1710, 1709, 1704, 1708, 1700, 1711, + 2105, 2104, 2097, 2103, 2101, 2106, 2118, 2117, 2112, 2116, 2110, 2119, + 1737, 1746, 1930, 1934, 1801, 1805, 1816, 1799, 1820, 1863, 1838, 1867, + 1870, 1888, 1920, 1917, 1910, 1916, 1914, 1921, 1685, 2177, 2164, 2173, + 2163, 2123, 2178, 2138, 2136, 2140, 2142, 2134, 1702, 1693, 1698, 1705, + 1695, 2090, 2078, 2085, 2098, 2080, 2113, 1787, 1793, 1770, 1765, 1826, + 1828, 1997, 1990, 2002, 2010, 1967, 1975, 1971, 1724, 1716, 1720, 1726, + 2071, 2183, 1667, 1663, 1755, 1751, 1739, 1744, 1735, 1742, 1932, 1928, + 1803, 1811, 1809, 1806, 1817, 1854, 1846, 1858, 1864, 1848, 1885, 1874, + 1879, 1889, 1906, 1896, 1918, 1911, 1898, 1780, 1776, 1782, 2166, 2159, + 2168, 2174, 2161, 2144, 2135, 1707, 1696, 2100, 2081, 2115, 2121, 2012, + 1994, 2049, 2029, 1808, 1819, 1866, 1913, 1899, 2176, 2162, 2027, 2021, + 2024, 2070, 2074, 1670, 1672, 1754, 1758, 2014, 2018, 2051, 2059, 1768, + 1773, 1796, 1798, 1825, 1831, 1974, 1979, 1723, 1731, 2040, 2035, 2054, + 2048, 2057, 2016, 1977, 1729, 2069, 2073, 1669, 1671, 1753, 1757, 2013, + 2017, 2050, 2058, 1767, 1772, 1795, 1797, 1824, 1830, 1973, 1978, 1722, + 1730, 2038, 2033, 2052, 2046, 2056, 2015, 1976, 1728, 2039, 2034, 2053, + 2047, 1993, 2028, 2066, 1999, 1992, 2004, 2041, 2036, 2055, 2068, 2185, + 1687, 1688, 25691, 25692, 1951, 1942, 1946, 1943, 1944, 1945, 1985, 1676, + 1681, 1679, 1675, 1940, 1987, 1683, 2061, 1953, 2088, 2076, 2077, 2075, + 2083, 2093, 2095, 2094, 1789, 1790, 1764, 1763, 1989, 1996, 1995, 2005, + 2006, 2007, 2008, 2009, 1964, 1965, 1969, 2030, 2031, 2037, 2042, 2043, + 2044, 2045, 1714, 1718, 1719, 2062, 2063, 2064, 2065, 1665, 1660, 1661, + 1659, 1748, 1750, 1749, 1733, 1734, 1925, 1924, 1843, 1845, 1842, 1850, + 1849, 1856, 1857, 1860, 1861, 1871, 1872, 1873, 1883, 1881, 1876, 1877, + 1957, 1960, 1882, 1774, 1775, 1894, 1893, 1903, 1904, 1902, 1909, 1908, + 2170, 2171, 1697, 2089, 2087, 2084, 2082, 2096, 2092, 1792, 1785, 1791, + 2000, 1966, 2032, 1715, 1853, 1862, 2158, 2165, 2172, 1887, 1927, 1895, + 1926, 1844, 1662, 1815, 1901, 1878, 1852, 1813, 1851, 1900, 1786, 1769, + 1884, 1741, 1692, 1814, 1666, 1970, 2001, 1905, 1952, 1947, 1950, 1949, + 1986, 1674, 1822, 1981, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 1982, 1936, 1689, 1690, 1892, 1980, + 1962, 1684, 2122, 1983, 1988, 1783, 27216, 1713, 2060, 1691, 33590, + 33701, 33769, 33780, 33791, 33802, 33813, 33824, 33835, 33591, 33602, + 33613, 33624, 33635, 33646, 33657, 26666, 26671, 26672, 26665, 26696, + 26669, 26698, 26674, 26688, 26670, 36293, 36293, 36293, 36293, 36293, + 36293, 7521, 7523, 7348, 7349, 7532, 7534, 7229, 7522, 7524, 7597, 7598, + 7533, 7535, 7230, 7283, 7284, 26697, 26667, 26668, 26683, 26695, 26680, + 26692, 26678, 26690, 26682, 26694, 26675, 26684, 26676, 26685, 26679, + 26691, 26677, 26689, 26673, 26686, 27715, 34598, 26681, 26693, 10042, + 6279, 34473, 10759, 10041, 6278, 34471, 28890, 28899, 28934, 36293, + 28924, 28891, 28935, 28898, 28897, 28901, 28905, 28900, 28904, 28902, + 28906, 28933, 28881, 28883, 28932, 28930, 28903, 28929, 28896, 36293, + 28923, 28892, 28931, 28889, 36293, 36293, 36293, 36293, 1124, 2473, 1105, + 2475, 1137, 36293, 1121, 1122, 1101, 1102, 1134, 1135, 2366, 2367, 2447, + 2448, 1323, 1187, 1186, 1177, 1176, 1607, 1606, 1180, 1179, 1624, 1622, + 1623, 1625, 1197, 1196, 1212, 1210, 1211, 1213, 1549, 1548, 1558, 1556, + 1557, 1551, 1572, 1570, 1571, 1573, 1354, 1352, 1353, 1355, 1320, 1318, + 1319, 1321, 1392, 1390, 1391, 1393, 1236, 1235, 1566, 1565, 1484, 1483, + 1650, 1649, 1513, 1511, 1512, 1514, 1519, 1517, 1518, 1520, 1500, 1498, + 1499, 1501, 1244, 1242, 1243, 1245, 1532, 1530, 1531, 1533, 1646, 1644, + 1645, 1647, 1155, 1153, 1154, 1156, 1299, 1297, 1298, 1300, 1283, 1281, + 1282, 1284, 1466, 1464, 1465, 1467, 1368, 1366, 1367, 1369, 1404, 1402, + 1403, 1405, 1413, 1411, 1412, 1414, 1445, 1443, 1444, 1446, 1342, 1340, + 1341, 1343, 1611, 1610, 1195, 1194, 1635, 1633, 1634, 1636, 1837, 1836, + 1833, 1832, 1835, 1834, 1841, 1840, 36293, 36293, 36097, 36293, 13144, + 13148, 13116, 13132, 13118, 13130, 13129, 13059, 13122, 13131, 13119, + 13054, 13147, 13152, 13126, 13139, 13141, 13138, 13137, 13134, 13133, + 13136, 13135, 13142, 13140, 13055, 13125, 13061, 13143, 13146, 13149, + 13053, 13062, 13063, 13064, 13065, 13066, 13067, 13068, 13069, 13070, + 13071, 13072, 13073, 13074, 13075, 13076, 13077, 13078, 13079, 13080, + 13081, 13082, 13083, 13084, 13085, 13086, 13087, 13060, 13124, 13123, + 13052, 13114, 13145, 13088, 13089, 13090, 13091, 13092, 13093, 13094, + 13095, 13096, 13097, 13098, 13099, 13100, 13101, 13102, 13103, 13104, + 13105, 13106, 13107, 13108, 13109, 13110, 13111, 13112, 13113, 13058, + 13154, 13121, 13151, 13057, 13120, 14634, 14627, 14629, 14633, 14625, + 14617, 14572, 14574, 14576, 14573, 14575, 14568, 14570, 14569, 14571, + 14626, 14618, 14620, 14622, 14619, 14621, 14593, 14595, 14597, 14594, + 14596, 14577, 14579, 14581, 14578, 14580, 14608, 14610, 14612, 14609, + 14611, 14583, 14585, 14587, 14584, 14586, 14588, 14590, 14592, 14589, + 14591, 14598, 14600, 14602, 14599, 14601, 14613, 14615, 14614, 14603, + 14605, 14607, 14604, 14606, 14616, 14582, 14624, 14623, 14567, 14517, + 14534, 14518, 14519, 14520, 14521, 14555, 14536, 14525, 14530, 14529, + 14528, 14532, 14526, 14527, 14531, 14553, 14523, 14535, 14524, 14538, + 14537, 14552, 14547, 14533, 14546, 14516, 14554, 14522, 14561, 36293, + 36293, 36293, 14562, 14563, 14541, 14542, 14549, 14548, 36293, 36293, + 14540, 14539, 14564, 14558, 14559, 14565, 36293, 36293, 14544, 14566, + 14557, 14556, 14560, 14545, 36293, 36293, 14550, 14543, 14551, 36293, + 36293, 36293, 13056, 13117, 13115, 13128, 13153, 13127, 13150, 36293, + 14631, 14628, 14632, 14630, 14637, 14635, 14636, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 16333, 16335, 16334, + 24969, 26904, 36293, 36293, 20247, 20273, 20266, 20299, 20257, 20248, + 20277, 20243, 20255, 20285, 20288, 20282, 36293, 20271, 20298, 20302, + 20281, 20296, 20303, 20310, 20313, 20258, 20309, 20256, 20259, 20242, + 20265, 20268, 20291, 20292, 20250, 20307, 20272, 20253, 20289, 20251, + 20308, 20267, 20275, 36293, 20300, 20264, 20284, 20249, 20260, 20274, + 20245, 20279, 20254, 20286, 20287, 20244, 20270, 20246, 20297, 20290, + 20304, 20278, 20280, 36293, 20252, 20306, 36293, 20263, 20262, 20276, + 20312, 20305, 20315, 20283, 20261, 20293, 20301, 20269, 20294, 20295, + 20311, 20314, 36293, 36293, 20325, 20326, 20328, 20327, 20316, 20317, + 20324, 20318, 20319, 20329, 20320, 20321, 20322, 20323, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 20131, 20130, 20132, 20119, 20120, 20121, 20122, 20123, + 20124, 20125, 20127, 20126, 20129, 20128, 20137, 20134, 20135, 20133, + 20136, 20236, 20237, 20139, 20138, 20140, 20239, 20238, 20142, 20143, + 20144, 20141, 20145, 20148, 20147, 20149, 20150, 20151, 20240, 20152, + 20153, 20146, 20156, 20157, 20155, 20154, 20158, 20159, 20160, 20161, + 20162, 20163, 20166, 20167, 20168, 20165, 20169, 20164, 20170, 20171, + 20172, 20173, 20174, 20175, 20176, 20177, 20178, 20179, 20181, 20180, + 20182, 20183, 20185, 20186, 20187, 20184, 20188, 20189, 20190, 20191, + 20193, 20192, 20194, 20195, 20241, 20196, 20197, 20199, 20200, 20201, + 20198, 20202, 20203, 20204, 20205, 20206, 20234, 20214, 20215, 20216, + 20217, 20218, 20219, 20220, 20221, 20222, 20223, 20224, 20225, 20226, + 20227, 20228, 20229, 20230, 20231, 20232, 20233, 20207, 20208, 20209, + 20210, 20211, 20212, 20213, 20235, 36293, 36293, 36293, 36293, 36293, + 112, 113, 159, 36293, 36293, 36293, 36293, 156, 151, 146, 126, 121, 139, + 134, 114, 129, 154, 149, 144, 124, 119, 140, 135, 115, 130, 157, 152, + 147, 127, 122, 142, 137, 117, 132, 158, 153, 148, 128, 123, 143, 138, + 118, 133, 155, 150, 145, 125, 120, 141, 136, 116, 131, 36293, 36293, + 36293, 111, 107, 109, 110, 108, 103, 104, 105, 106, 13701, 13698, 13702, + 13688, 13683, 13689, 13692, 13684, 13694, 13703, 13686, 13696, 13690, + 13699, 13693, 13695, 13705, 13687, 13697, 13691, 13700, 13704, 13685, + 13706, 13718, 13727, 13717, 13713, 13726, 13708, 13714, 13730, 13734, + 13735, 13716, 13719, 13725, 13724, 13732, 13733, 13715, 13722, 13728, + 13723, 13712, 13731, 13720, 13707, 13709, 13729, 13721, 13710, 13711, + 13953, 13954, 14152, 14148, 14189, 14154, 13884, 13958, 14151, 14147, + 13890, 13889, 13950, 13932, 13948, 13957, 13952, 13738, 13737, 14191, + 14150, 14192, 13955, 14146, 13928, 24791, 36293, 27260, 27263, 27258, + 27261, 27232, 27262, 27230, 27233, 27259, 27231, 27264, 27229, 2612, + 36293, 36293, 36293, 14145, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 26448, 26449, 26460, 26429, 26432, 26463, 26441, 26440, 26461, + 26468, 26427, 26454, 26433, 26446, 26447, 26456, 26445, 26426, 26430, + 26437, 26435, 26457, 26434, 26425, 26455, 26442, 26443, 26428, 26431, + 26453, 26467, 26438, 26462, 26424, 26450, 26469, 26451, 26452, 26444, + 26466, 26465, 26439, 26458, 26459, 26464, 26436, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 20571, 20573, 20569, + 20570, 20578, 20577, 20580, 20588, 20590, 20567, 20581, 20564, 20584, + 20582, 20562, 20575, 20563, 20576, 20587, 20583, 20565, 20585, 20586, + 20566, 20568, 20572, 20574, 20579, 20589, 36293, 36293, 36293, 6188, + 6199, 6190, 6161, 6184, 6200, 6162, 6189, 6206, 6204, 6164, 6205, 6191, + 6179, 6174, 6175, 6173, 6159, 6182, 6172, 6207, 6169, 6181, 6198, 6178, + 6202, 6192, 6187, 6196, 6197, 6170, 6183, 6194, 6195, 6176, 6177, 6171, + 6203, 6160, 6180, 6185, 6201, 6165, 6166, 6167, 6168, 6163, 6193, 6186, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 7748, 7746, 7744, 7743, 7740, 7739, + 7742, 7741, 7747, 7745, 7738, 7737, 7735, 7726, 7724, 7733, 7731, 7722, + 7728, 7729, 7736, 7734, 7725, 7723, 7732, 7730, 7721, 7727, 36293, 36293, + 36293, 36293, 25250, 25244, 25230, 25245, 25217, 25247, 25249, 25246, + 25241, 25237, 25229, 25225, 25226, 25227, 25219, 25251, 25240, 25233, + 25231, 25221, 25218, 25242, 25235, 25223, 25239, 25228, 25224, 25222, + 25243, 25238, 25236, 25220, 25255, 25253, 25254, 25252, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 25248, 25234, 25232, + 13548, 13564, 13572, 13566, 13547, 13557, 13551, 13550, 13559, 13568, + 13573, 13569, 13567, 13555, 13571, 13562, 13556, 13554, 13558, 13570, + 13560, 13561, 13563, 13552, 13549, 13565, 13553, 36293, 36293, 36293, + 36293, 36293, 25322, 25321, 25318, 25291, 25292, 25314, 25289, 25315, + 25290, 25294, 25323, 25316, 25297, 25298, 25305, 25299, 25317, 25302, + 25304, 25325, 25288, 25301, 25300, 25312, 25309, 25319, 25320, 25293, + 25324, 25303, 25306, 25307, 25308, 25311, 25296, 25313, 25310, 25295, + 7550, 7548, 7546, 7547, 7549, 36293, 36293, 36293, 36293, 36293, 33038, + 33041, 33045, 33049, 33042, 33046, 33064, 33060, 33047, 33057, 33059, + 33048, 33054, 33050, 33065, 33043, 33062, 33061, 33053, 33039, 33063, + 33052, 33040, 33051, 33056, 33044, 33058, 33066, 33067, 33055, 36293, + 33068, 25331, 25373, 25374, 25354, 25355, 25352, 25353, 25351, 25366, + 25343, 25344, 25348, 25349, 25338, 25341, 25342, 25347, 25370, 25335, + 25367, 25356, 25357, 25360, 25361, 25362, 25371, 25345, 25346, 25358, + 25359, 25369, 25365, 25372, 25363, 25364, 25368, 36293, 36293, 36293, + 36293, 25332, 25333, 25334, 25350, 25339, 25340, 25336, 25337, 25375, + 25330, 25327, 25328, 25326, 25329, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 10096, 10095, 10091, + 10092, 10093, 10094, 10102, 10101, 10097, 10098, 10099, 10100, 10119, + 10104, 10118, 10115, 10120, 10113, 10110, 10106, 10111, 10109, 10112, + 10117, 10116, 10086, 10114, 10085, 10105, 10081, 10108, 10082, 10107, + 10089, 10087, 10088, 10083, 10084, 10103, 10090, 10136, 10135, 10131, + 10132, 10133, 10134, 10142, 10141, 10137, 10138, 10139, 10140, 10159, + 10144, 10158, 10155, 10160, 10153, 10150, 10146, 10151, 10149, 10152, + 10157, 10156, 10126, 10154, 10125, 10145, 10121, 10148, 10122, 10147, + 10129, 10127, 10128, 10123, 10124, 10143, 10130, 27859, 27865, 27876, + 27873, 27863, 27862, 27861, 27840, 27868, 27846, 27875, 27871, 27874, + 27877, 27864, 27872, 27851, 27870, 27867, 27845, 27850, 27852, 27849, + 27844, 27838, 27835, 27857, 27866, 27855, 27839, 27860, 27878, 27842, + 27836, 27848, 27879, 27856, 27853, 27854, 27837, 27833, 27858, 27834, + 27843, 27832, 27841, 27847, 27869, 25769, 25787, 25793, 25791, 25794, + 25775, 25772, 25792, 25777, 25776, 25773, 25771, 25789, 25788, 25779, + 25774, 25782, 25778, 25783, 25784, 25790, 25795, 25768, 25785, 25796, + 25780, 25797, 25770, 25786, 25781, 36293, 36293, 25804, 25806, 25803, + 25802, 25799, 25798, 25801, 25800, 25807, 25805, 36293, 36293, 36293, + 36293, 36293, 36293, 25696, 25697, 25698, 25699, 25724, 25717, 25703, + 25700, 25706, 25716, 25715, 25730, 25709, 25704, 25708, 25725, 25726, + 25727, 25710, 25711, 25728, 25705, 25721, 25720, 25714, 25702, 25713, + 25701, 25712, 25718, 25731, 25729, 25707, 25719, 25723, 25722, 36293, + 36293, 36293, 36293, 25732, 25733, 25734, 25735, 25760, 25753, 25739, + 25736, 25742, 25752, 25751, 25766, 25745, 25740, 25744, 25761, 25762, + 25763, 25746, 25747, 25764, 25741, 25757, 25756, 25750, 25738, 25749, + 25737, 25748, 25754, 25767, 25765, 25743, 25755, 25759, 25758, 36293, + 36293, 36293, 36293, 12203, 12194, 12183, 12182, 12185, 12174, 12184, + 12181, 12180, 12195, 12171, 12170, 12196, 12204, 12197, 12187, 12173, + 12172, 12198, 12177, 12176, 12175, 12205, 12199, 12200, 12179, 12178, + 12189, 12188, 12191, 12190, 12206, 12201, 12202, 12207, 12193, 12192, + 12169, 12168, 12186, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 6221, 6270, 6237, 6233, 6235, 6260, 6234, 6258, 6255, 6224, 6257, + 6259, 6238, 6249, 6245, 6240, 6268, 6232, 6223, 6241, 6244, 6246, 6271, + 6262, 6220, 6226, 6227, 6229, 6263, 6261, 6266, 6230, 6250, 6242, 6269, + 6254, 6265, 6231, 6225, 6248, 6236, 6267, 6252, 6264, 6253, 6251, 6239, + 6228, 6222, 6256, 6247, 6243, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 6272, 34244, 34213, 34214, 34224, + 34223, 34226, 34225, 34216, 34215, 34233, 34241, 36293, 34232, 34231, + 34217, 34218, 34234, 34242, 34220, 34219, 34235, 34222, 34221, 34245, + 34236, 34243, 34237, 36293, 34228, 34227, 34230, 34229, 34246, 34238, + 34239, 36293, 34247, 34240, 36293, 34279, 34248, 34249, 34259, 34258, + 34261, 34260, 34251, 34250, 34268, 34276, 36293, 34267, 34266, 34252, + 34253, 34269, 34277, 34255, 34254, 34270, 34257, 34256, 34280, 34271, + 34278, 34272, 36293, 34263, 34262, 34265, 34264, 34281, 34273, 34274, + 36293, 34282, 34275, 36293, 36293, 36293, 32694, 32695, 32708, 32668, + 32697, 32696, 32699, 32675, 32698, 32691, 32690, 32709, 32665, 32671, + 32664, 32670, 32678, 32677, 32712, 32666, 32701, 32693, 32692, 32669, + 32676, 32672, 32688, 32680, 32710, 32687, 32686, 32685, 32682, 32681, + 32703, 32702, 32713, 32711, 32705, 32674, 32704, 32673, 32714, 32667, + 32707, 32706, 32663, 32684, 32683, 32700, 32679, 32689, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 20098, 20099, 20100, 20101, 20102, 20103, 20104, 20105, 20106, 20037, + 20038, 20039, 20040, 20041, 20050, 20042, 20043, 20044, 20045, 20046, + 20047, 20048, 20049, 20051, 20052, 20053, 20054, 20118, 20055, 20056, + 20057, 20058, 20059, 20060, 20061, 20062, 20063, 20064, 20065, 20066, + 20067, 20068, 20069, 20070, 20071, 20072, 20073, 20074, 20075, 20076, + 20077, 20078, 20079, 20080, 20081, 20082, 20083, 20084, 20085, 20086, + 20087, 20088, 20089, 20090, 20091, 20092, 20093, 20094, 20095, 20096, + 20097, 19778, 20114, 20107, 19779, 20108, 20109, 20110, 20111, 19780, + 20115, 20116, 20112, 20113, 20117, 19784, 19785, 19786, 19787, 19788, + 19789, 19790, 19791, 19781, 19782, 19783, 19795, 19796, 19797, 19792, + 19793, 19794, 19798, 19799, 19800, 19801, 19802, 19803, 19806, 19807, + 19808, 19809, 19810, 19811, 19812, 19813, 19814, 19815, 19816, 19817, + 19818, 19819, 19820, 19821, 19822, 19823, 19824, 19825, 19826, 19827, + 19828, 19829, 19830, 19831, 19832, 19833, 19834, 19835, 19836, 19837, + 19838, 19839, 19840, 19841, 19842, 19843, 19844, 19845, 19846, 19847, + 19848, 19849, 19850, 19851, 19852, 19853, 19854, 19855, 19804, 19805, + 19856, 19857, 19858, 19859, 19860, 19861, 19862, 19863, 19864, 19865, + 19866, 19867, 19868, 19869, 19870, 19871, 19872, 19873, 19874, 19875, + 19876, 19877, 19878, 19879, 19880, 19881, 19882, 19883, 19884, 19885, + 19886, 19887, 19888, 19920, 19921, 19922, 19923, 19924, 19925, 19926, + 19927, 19928, 19889, 19890, 19891, 19892, 19893, 19894, 19895, 19896, + 19897, 19898, 19899, 19900, 19901, 19902, 19903, 19904, 19905, 19906, + 19907, 19908, 19909, 19910, 19911, 19912, 19913, 19914, 19915, 19916, + 19917, 19918, 19919, 19935, 19936, 19937, 19938, 19939, 19940, 19941, + 19942, 19943, 19944, 19945, 19946, 19947, 19948, 19949, 19950, 19951, + 19952, 19953, 19954, 19929, 19930, 19931, 19932, 19933, 19934, 19955, + 19956, 19957, 19958, 19959, 19960, 19961, 19962, 19997, 19998, 19999, + 20000, 20001, 20002, 20003, 20004, 20005, 20006, 19963, 19964, 19965, + 19966, 19967, 19968, 19969, 19970, 19971, 19972, 19973, 19974, 19975, + 19976, 19977, 19978, 19979, 19980, 19981, 19982, 19988, 19989, 19990, + 19991, 19992, 19993, 19994, 19995, 19996, 19983, 19984, 19985, 19986, + 19987, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 20018, 20013, 20016, 20015, 20019, 20014, 20012, 20017, 20011, 20007, + 20010, 20009, 20008, 20025, 20023, 20024, 20020, 20021, 20022, 20026, + 20028, 20027, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 20029, 20030, 20031, 20032, 20033, 20034, 20035, 20036, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 23174, 23344, 23343, 23154, 23176, 23160, + 36293, 23202, 23204, 23203, 23195, 23193, 23189, 23190, 23278, 23185, + 23216, 23274, 23169, 23218, 23170, 23228, 23179, 23230, 23200, 23250, + 23251, 23241, 23172, 23246, 23252, 23253, 23317, 23318, 23263, 23175, + 23186, 23267, 23312, 23313, 23273, 23271, 23182, 23295, 23300, 23301, + 23296, 23294, 23331, 36293, 23184, 23094, 23142, 22988, 23072, 23102, + 22982, 23144, 23280, 23321, 23345, 23342, 23320, 23207, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 9509, 9510, 9511, 9512, 9513, 9503, 36293, 36293, 9504, + 36293, 9459, 9460, 9461, 9462, 9463, 9464, 9465, 9466, 9467, 9468, 9469, + 9470, 9471, 9472, 9473, 9474, 9475, 9476, 9477, 9478, 9479, 9480, 9481, + 9482, 9483, 9484, 9485, 9486, 9487, 9488, 9489, 9490, 9491, 9492, 9493, + 9494, 9495, 9496, 9497, 9498, 9499, 9500, 9501, 9502, 36293, 9507, 9508, + 36293, 36293, 36293, 9505, 36293, 36293, 9506, 16153, 16164, 16155, + 16149, 16161, 16166, 16156, 16162, 16147, 16160, 16163, 16150, 16168, + 16165, 16157, 16154, 16167, 16158, 16151, 16152, 16159, 16148, 36293, + 16169, 16144, 16140, 16143, 16141, 16139, 16145, 16146, 16142, 26076, + 26087, 26078, 26072, 26084, 26089, 26079, 26085, 26070, 26083, 26086, + 26073, 26091, 26069, 26088, 26080, 26077, 26090, 26081, 26074, 26075, + 26082, 26071, 26068, 26092, 26099, 26094, 26095, 26098, 26097, 26096, + 26093, 24236, 24251, 24241, 24262, 24253, 24247, 24243, 24259, 24264, + 24254, 24260, 24245, 24239, 24258, 24240, 24261, 24237, 24248, 24244, + 24266, 24242, 24263, 24255, 24252, 24265, 24256, 24249, 24250, 24238, + 24257, 24246, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 24271, 24268, 24269, 24274, 24275, 24273, 24270, 24267, 24272, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 15194, 15210, 15202, + 15201, 15207, 15212, 15196, 15208, 15197, 15206, 15209, 15199, 15214, + 15211, 15203, 15195, 15213, 15204, 15200, 36293, 15205, 15198, 36293, + 36293, 36293, 36293, 36293, 15215, 15219, 15218, 15217, 15216, 26472, + 26491, 26487, 26474, 26475, 26483, 26484, 26476, 26482, 26485, 26488, + 26490, 26493, 26489, 26480, 26473, 26492, 26478, 26477, 26486, 26479, + 26481, 26498, 26497, 26494, 26499, 26495, 26496, 36293, 36293, 36293, + 26500, 20597, 20603, 20607, 20605, 20599, 20615, 20608, 20616, 20609, + 20593, 20610, 20601, 20611, 20613, 20596, 20591, 20614, 20606, 20612, + 20595, 20592, 20598, 20600, 20594, 20602, 20604, 36293, 36293, 36293, + 36293, 36293, 20617, 28017, 28018, 28019, 28020, 28021, 28022, 28023, + 28024, 28025, 28026, 28027, 28028, 28029, 28030, 28031, 28032, 28033, + 28034, 28035, 28010, 28011, 28012, 28013, 28014, 28015, 28016, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 22696, 22697, 22698, + 22699, 22695, 22694, 22670, 22671, 22692, 22691, 22674, 22675, 22676, + 22677, 22672, 22673, 22690, 22687, 22686, 22678, 22679, 22680, 22688, + 22693, 22681, 22682, 22683, 22684, 22685, 22689, 22700, 22701, 22592, + 22613, 22614, 22615, 22612, 22611, 22604, 22608, 22607, 22597, 22598, + 22610, 22606, 22602, 22601, 22599, 22593, 22600, 22603, 22609, 22594, + 22595, 22596, 22605, 36293, 36293, 36293, 36293, 22580, 22585, 22617, + 22616, 22666, 22658, 22652, 22629, 22623, 22646, 22640, 22618, 22635, + 22664, 22662, 22656, 22633, 22627, 22650, 22644, 36293, 36293, 22667, + 22659, 22653, 22630, 22624, 22647, 22641, 22620, 22637, 22669, 22661, + 22655, 22632, 22626, 22649, 22643, 22622, 22639, 22665, 22663, 22657, + 22634, 22628, 22651, 22645, 22619, 22636, 22668, 22660, 22654, 22631, + 22625, 22648, 22642, 22621, 22638, 22584, 22590, 22589, 22583, 22582, + 22587, 22586, 22581, 22591, 22588, 17277, 17299, 17301, 17297, 36293, + 17298, 17300, 36293, 36293, 36293, 36293, 36293, 17302, 17293, 17296, + 17295, 17243, 17241, 17265, 17264, 36293, 17263, 17262, 17271, 36293, + 17251, 17247, 17246, 17254, 17253, 17250, 17249, 17248, 17256, 17255, + 17252, 17267, 17266, 17261, 17260, 17273, 17275, 17274, 17272, 17269, + 17257, 17258, 17259, 17276, 17270, 17242, 17244, 17245, 17268, 36293, + 36293, 17291, 17292, 17294, 36293, 36293, 36293, 36293, 17303, 17240, + 17239, 17238, 17237, 17279, 17278, 17280, 17281, 17304, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 17285, 17290, 17283, 17282, 17289, + 17287, 17286, 17284, 17288, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 25440, 25436, 25441, 25446, 25437, 25444, 25430, 25438, 25442, + 25434, 25429, 25425, 25443, 25426, 25428, 25427, 25445, 25418, 25419, + 25421, 25424, 25422, 25423, 25433, 25435, 25420, 25439, 25432, 25431, + 25448, 25447, 25449, 25261, 25279, 25260, 25270, 25282, 25283, 25272, + 25276, 25274, 25267, 25271, 25263, 25278, 25262, 25284, 25273, 25275, + 25256, 25257, 25280, 25259, 25281, 25258, 25266, 25268, 25264, 25277, + 25265, 25269, 25287, 25286, 25285, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 20898, 20902, 20901, + 20906, 20905, 20903, 20927, 20930, 20946, 20910, 20909, 20908, 20907, + 20928, 20920, 20926, 20912, 20922, 20911, 20924, 20904, 20919, 20933, + 20929, 20916, 20900, 20899, 20932, 20931, 20917, 20914, 20923, 20913, + 20925, 20918, 20915, 20921, 20948, 20947, 36293, 36293, 36293, 36293, + 20934, 20938, 20937, 20936, 20935, 20945, 20943, 20941, 20940, 20939, + 20944, 20942, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 2630, 2631, 2637, 2633, 2636, 2632, 2634, 2635, 2673, 2674, 2663, + 2664, 2665, 2666, 2661, 2662, 2678, 2651, 2650, 2649, 2640, 2638, 2639, + 2675, 2677, 2660, 2658, 2670, 2669, 2659, 2681, 2676, 2668, 2667, 2645, + 2644, 2643, 2648, 2647, 2646, 2680, 2641, 2656, 2657, 2683, 2682, 2679, + 2655, 2672, 2653, 2671, 2652, 2654, 2642, 36293, 36293, 36293, 2684, + 32576, 28925, 17807, 17802, 17808, 17803, 16297, 16308, 16299, 16293, + 16305, 16310, 16300, 16306, 16291, 16304, 16307, 16294, 16312, 16309, + 16301, 16298, 16311, 16302, 16295, 16296, 16303, 16292, 36293, 36293, + 16317, 16314, 16315, 16320, 16316, 16313, 16318, 16319, 16266, 16280, + 16271, 16267, 16277, 16270, 16272, 16278, 16264, 16276, 16279, 16268, + 16269, 16281, 16273, 16282, 16274, 16275, 16265, 36293, 36293, 36293, + 36293, 36293, 16287, 16284, 16285, 16290, 16286, 16283, 16288, 16289, + 26734, 26748, 26739, 26735, 26745, 26738, 26740, 26746, 26744, 26747, + 26736, 26737, 26749, 26741, 26751, 26742, 26743, 26750, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 26759, 26760, 26732, 26733, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 26756, 26753, 26754, 26758, 26755, 26752, 26757, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 25450, 25492, + 25493, 25482, 25518, 25511, 25485, 25486, 25520, 25463, 25503, 25451, + 25496, 25465, 25505, 25453, 25497, 25464, 25504, 25452, 25481, 25517, + 25471, 25510, 25460, 25500, 25454, 25498, 25487, 25521, 25466, 25506, + 25455, 25476, 25479, 25467, 25456, 25494, 25474, 25513, 25472, 25512, + 25475, 25514, 25502, 25473, 25495, 25480, 25488, 25483, 25478, 25516, + 25468, 25507, 25484, 25519, 25489, 25522, 25469, 25508, 25457, 25461, + 25458, 25462, 25501, 25477, 25515, 25470, 25509, 25459, 25499, 25490, + 25491, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 25109, 25112, 25135, 25110, + 25124, 25120, 25126, 25136, 25111, 25114, 25157, 25137, 25138, 25127, + 25128, 25139, 25158, 25159, 25140, 25141, 25113, 25154, 25129, 25130, + 25115, 25117, 25121, 25149, 25151, 25145, 25147, 25150, 25142, 25116, + 25143, 25152, 25122, 25123, 25131, 25118, 25132, 25125, 25153, 25156, + 25146, 25148, 25144, 25133, 25134, 25119, 25155, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 25160, 25163, 25186, 25161, 25175, 25171, 25177, 25187, 25162, 25165, + 25208, 25188, 25189, 25178, 25179, 25190, 25209, 25210, 25191, 25192, + 25164, 25205, 25180, 25181, 25166, 25168, 25172, 25200, 25202, 25196, + 25198, 25201, 25193, 25167, 25194, 25203, 25173, 25174, 25182, 25169, + 25183, 25176, 25204, 25207, 25197, 25199, 25195, 25184, 25185, 25170, + 25206, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 25213, 25212, + 25216, 25211, 25214, 25215, 15147, 15134, 15142, 15126, 15125, 15139, + 15135, 15138, 15123, 15136, 15120, 15119, 15128, 15127, 15146, 15133, + 15132, 15124, 15137, 15140, 15141, 15131, 15144, 15121, 15145, 15122, + 15129, 15130, 15143, 15154, 15156, 15158, 15155, 15157, 15149, 15148, + 15153, 15150, 15152, 15151, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 15165, 15167, 15164, 15163, 15160, 15159, 15162, 15161, + 15168, 15166, 36293, 36293, 36293, 36293, 36293, 36293, 13232, 13234, + 13231, 13230, 13227, 13226, 13229, 13228, 13235, 13233, 13218, 13219, + 13220, 13217, 13221, 13215, 13192, 13176, 13184, 13182, 13175, 13181, + 13187, 13189, 13183, 13179, 13177, 13190, 13191, 13188, 13186, 13173, + 13178, 13174, 13185, 13180, 13171, 13172, 36293, 36293, 36293, 13216, + 13168, 13170, 13169, 13167, 13223, 13222, 13214, 13198, 13206, 13204, + 13197, 13203, 13209, 13211, 13205, 13201, 13199, 13212, 13213, 13210, + 13208, 13195, 13200, 13196, 13207, 13202, 13193, 13194, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 13224, 13225, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 27317, 27315, 27314, 27311, + 27310, 27313, 27312, 27318, 27316, 27309, 27308, 27306, 27297, 27295, + 27304, 27302, 27293, 27299, 27300, 27307, 27305, 27296, 27294, 27303, + 27301, 27292, 27298, 27289, 27290, 27288, 27291, 36293, 34750, 34784, + 34764, 34763, 34769, 34768, 34746, 34745, 34744, 34755, 34776, 34749, + 34780, 34783, 34782, 34779, 34787, 34766, 34765, 34767, 34748, 34770, + 34781, 34751, 34775, 34786, 34771, 34772, 34759, 34757, 34756, 34758, + 34760, 34747, 34762, 34785, 34773, 34774, 34753, 34754, 34777, 34752, + 36293, 34742, 34741, 34743, 36293, 36293, 34761, 34778, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 1229, 1525, 1360, 2425, 1568, 1632, 36293, + 2380, 2379, 2335, 2334, 2468, 2442, 1142, 1069, 1682, 1680, 1678, 1937, + 1938, 1939, 1941, 1923, 1084, 1086, 1074, 1072, 1082, 1078, 1080, 1076, + 1075, 1077, 1093, 1073, 1088, 1092, 1089, 1085, 1091, 1081, 1083, 1090, + 1079, 1087, 36293, 2430, 2444, 1125, 2416, 2429, 2415, 2428, 2386, 2407, + 2190, 1109, 2426, 1070, 2435, 2436, 2433, 25380, 25388, 25402, 25389, + 25393, 25399, 25390, 25405, 25394, 25400, 25398, 25401, 25392, 25407, + 25403, 25382, 25383, 25395, 25381, 25379, 25406, 25396, 25384, 25385, + 25391, 25397, 25404, 25386, 25387, 25414, 25412, 25409, 25417, 25416, + 25413, 25411, 25410, 25415, 25378, 25408, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 28985, 28999, 28987, 28996, 29003, 28991, + 28997, 28995, 28998, 28988, 29005, 29001, 28992, 28986, 29004, 28993, + 28990, 28994, 29002, 29000, 28989, 28984, 28979, 28977, 28980, 28978, + 28983, 28982, 28974, 28973, 28975, 28981, 28976, 29006, 29009, 29008, + 29007, 29012, 29013, 29010, 29014, 29011, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 25527, 25539, + 25537, 25542, 25531, 25536, 25535, 25538, 25529, 25544, 25540, 25532, + 25543, 25533, 25528, 25534, 25541, 25530, 25526, 25525, 25524, 25523, + 25548, 25545, 25546, 25547, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 6644, 6638, 6652, 6646, 6641, 6649, 6655, 6637, 6647, 6650, + 6648, 6651, 6642, 6657, 6653, 6639, 6645, 6656, 6643, 6640, 6654, 6662, + 6659, 6660, 6664, 6661, 6658, 6663, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 12230, 12241, 12232, 12226, 12238, + 12243, 12233, 12239, 12224, 12237, 12240, 12227, 12245, 12242, 12234, + 12231, 12244, 12235, 12228, 12229, 12236, 12225, 12246, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 4783, 4788, 4786, 4785, + 4787, 4710, 4711, 4729, 4730, 4727, 4728, 4722, 4723, 4724, 4725, 4756, + 4712, 4703, 4713, 4749, 4748, 4745, 4744, 4733, 4743, 4742, 4747, 4746, + 4735, 4719, 4718, 4715, 4714, 4734, 4721, 4720, 4717, 4716, 4736, 4751, + 4750, 4741, 4740, 4753, 4755, 4754, 4732, 4726, 4737, 4738, 4739, 4752, + 4731, 4704, 4709, 4708, 4793, 4792, 4802, 4803, 4796, 4797, 4798, 4799, + 4800, 4801, 4804, 4794, 4789, 4795, 4805, 4807, 4806, 4781, 4780, 4779, + 4782, 4778, 36293, 36293, 36293, 36293, 4774, 4772, 4769, 4760, 4762, + 4767, 4765, 4757, 4763, 4773, 4771, 4770, 4759, 4761, 4768, 4766, 4758, + 4764, 4775, 4776, 4814, 4816, 4813, 4812, 4809, 4808, 4811, 4810, 4817, + 4815, 4784, 4706, 4707, 4790, 4791, 4705, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 4777, 16581, 16583, 16585, 16541, + 16542, 16551, 16552, 16549, 16550, 16579, 16543, 16580, 16544, 16569, + 16568, 16565, 16564, 16553, 16563, 16562, 16567, 16566, 16555, 16546, + 16545, 16538, 16536, 16537, 16572, 16554, 16548, 16547, 16540, 16539, + 16556, 16571, 16570, 16561, 16560, 16576, 16578, 16573, 16575, 16577, + 16557, 16558, 16559, 16574, 16591, 16596, 16597, 16594, 16595, 16598, + 16592, 16599, 16593, 16584, 16582, 16602, 16603, 16600, 16586, 16587, + 16589, 16588, 16590, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 16601, 36293, 36293, 29037, 29038, 29027, 29028, + 29029, 29030, 29023, 29024, 29034, 29026, 29039, 29035, 29040, 29036, + 29031, 29033, 29032, 29025, 29041, 29020, 29042, 29044, 29043, 29021, + 29022, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 29051, 29053, + 29050, 29049, 29046, 29045, 29048, 29047, 29054, 29052, 36293, 36293, + 36293, 36293, 36293, 36293, 6324, 6326, 6325, 6320, 6322, 6323, 6321, + 6309, 6308, 6305, 6304, 6290, 6303, 6302, 6307, 6306, 6292, 6295, 6294, + 6287, 6286, 6291, 6297, 6296, 6289, 6288, 6293, 6313, 6312, 6301, 6300, + 6315, 6298, 6299, 6316, 6311, 6319, 6317, 6314, 6328, 6336, 6337, 6332, + 6333, 6334, 6330, 6338, 6331, 6339, 6356, 6355, 6340, 6354, 36293, 6349, + 6351, 6348, 6347, 6344, 6343, 6346, 6345, 6352, 6350, 6327, 6342, 6341, + 6353, 6310, 6329, 6335, 6318, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 20659, 20661, 20663, 20660, 20662, 20651, 20650, 20647, + 20646, 20645, 20644, 20649, 20648, 20630, 20639, 20638, 20633, 20632, + 20629, 20641, 20640, 20635, 20634, 20631, 20653, 20652, 20643, 20642, + 20656, 20637, 20655, 20658, 20657, 20654, 20636, 20666, 20667, 20665, + 20664, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 27795, 27798, 27802, 27741, 27742, 27760, 27761, 27758, 27759, 27753, + 27754, 27755, 27756, 27787, 27743, 27788, 27744, 27780, 27779, 27776, + 27775, 27764, 27774, 27773, 27778, 27777, 27766, 27750, 27749, 27746, + 27745, 27765, 27752, 27751, 27748, 27747, 27767, 27782, 27781, 27772, + 27771, 27784, 27786, 27785, 27763, 27762, 27757, 27768, 27769, 27770, + 27783, 27817, 27824, 27825, 27811, 27812, 27820, 27821, 27822, 27823, + 27826, 27818, 27807, 27819, 27801, 27797, 27799, 27800, 27829, 27727, + 27726, 27827, 27792, 27789, 27796, 27804, 27738, 27803, 27810, 27793, + 27734, 27736, 27733, 27732, 27729, 27728, 27731, 27730, 27737, 27735, + 27739, 27794, 27740, 27828, 27790, 27791, 36293, 28739, 28737, 28736, + 28733, 28732, 28735, 28734, 28740, 28738, 28751, 28750, 28749, 28745, + 28744, 28748, 28747, 28743, 28746, 28741, 28742, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 17511, 17512, + 17538, 17540, 17537, 17513, 17539, 17514, 17528, 17527, 17503, 17501, + 17502, 17521, 17526, 17525, 17510, 17509, 36293, 17523, 17516, 17515, + 17506, 17505, 17522, 17518, 17517, 17508, 17504, 17507, 17524, 17530, + 17529, 17500, 17498, 17499, 17532, 17536, 17534, 17520, 17535, 17497, + 17531, 17519, 17548, 17551, 17552, 17555, 17553, 17549, 17554, 17550, + 17545, 17544, 17543, 17541, 17495, 17494, 17556, 17546, 17493, 17557, + 17542, 17533, 17496, 17547, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 23638, 23640, 23641, 23639, + 23629, 23628, 23627, 36293, 23626, 36293, 23625, 23624, 23617, 23616, + 36293, 23611, 23619, 23618, 23607, 23605, 23606, 23610, 23621, 23620, + 23609, 23608, 23612, 23631, 23630, 23623, 36293, 23622, 23634, 23637, + 23615, 23633, 23636, 23635, 23632, 23614, 23613, 23642, 36293, 36293, + 36293, 36293, 36293, 36293, 17572, 17573, 17584, 17585, 17582, 17583, + 17603, 17574, 17604, 17575, 17593, 17592, 17563, 17561, 17562, 17586, + 17591, 17590, 17571, 17570, 17569, 17588, 17579, 17578, 17566, 17564, + 17576, 17565, 17587, 17581, 17580, 17568, 17567, 17589, 17595, 17594, + 17560, 17558, 17559, 17600, 17602, 17577, 17599, 17601, 17596, 17597, + 17598, 17607, 17608, 17613, 17614, 17611, 17612, 17615, 17609, 17616, + 17610, 17605, 17606, 36293, 36293, 36293, 36293, 36293, 17623, 17625, + 17622, 17621, 17618, 17617, 17620, 17619, 17626, 17624, 36293, 36293, + 36293, 36293, 36293, 36293, 13630, 13631, 13634, 13637, 36293, 13587, + 13588, 13601, 13602, 13599, 13600, 13582, 13584, 36293, 36293, 13625, + 13589, 36293, 36293, 13624, 13590, 13621, 13620, 13617, 13616, 13605, + 13615, 13614, 13619, 13618, 13607, 13596, 13595, 13592, 13591, 13606, + 13598, 13597, 13594, 13593, 13608, 36293, 13623, 13622, 13613, 13612, + 13627, 13629, 13628, 36293, 13604, 13603, 36293, 13586, 13609, 13610, + 13611, 13626, 36293, 7219, 13632, 13633, 13639, 13648, 13649, 13642, + 13643, 13644, 13645, 36293, 36293, 13651, 13640, 36293, 36293, 13650, + 13641, 13636, 36293, 36293, 13652, 36293, 36293, 36293, 36293, 36293, + 36293, 13638, 36293, 36293, 36293, 36293, 36293, 13635, 13581, 13580, + 13583, 13585, 13646, 13647, 36293, 36293, 7413, 7414, 7412, 7411, 7410, + 7409, 7408, 36293, 36293, 36293, 7419, 7416, 7417, 7415, 7418, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 32914, 32915, 32938, 32939, 32936, 32937, 32931, 32932, 32933, 32934, + 36293, 32960, 36293, 36293, 32916, 36293, 32959, 32917, 32956, 32955, + 32952, 32951, 32940, 32950, 32949, 32954, 32953, 32942, 32928, 32927, + 32919, 32918, 32941, 32930, 32929, 32921, 32920, 32943, 32958, 32957, + 32948, 32947, 32962, 32963, 32926, 32924, 32935, 32944, 32945, 32946, + 32961, 32923, 32925, 32922, 36293, 32965, 32976, 32985, 32986, 32979, + 32980, 32981, 32982, 32983, 32984, 36293, 32988, 36293, 36293, 32977, + 36293, 32987, 32978, 32909, 32970, 36293, 32966, 32973, 32972, 32967, + 32910, 32964, 32913, 32971, 32912, 32911, 36293, 32968, 32969, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 32975, 32974, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 24634, 24635, + 24648, 24649, 24646, 24647, 24630, 24631, 24632, 24633, 24674, 24636, + 24675, 24637, 24662, 24661, 24658, 24657, 24623, 24622, 24656, 24655, + 24660, 24659, 24625, 24624, 24643, 24642, 24639, 24638, 24627, 24645, + 24644, 24641, 24640, 24628, 24626, 24668, 24667, 24654, 24653, 24666, + 24665, 24673, 24670, 24669, 24664, 24663, 24672, 24650, 24651, 24652, + 24671, 24688, 24697, 24698, 24691, 24692, 24693, 24694, 24695, 24696, + 24699, 24689, 24700, 24690, 24683, 24676, 24679, 24684, 24677, 24678, + 24681, 24704, 24685, 24610, 24608, 24703, 24621, 24701, 24617, 24619, + 24616, 24615, 24612, 24611, 24614, 24613, 24620, 24618, 24609, 24687, + 36293, 24702, 24686, 24629, 24680, 24682, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 32578, 32579, 32580, 32598, + 32599, 32596, 32597, 32591, 32592, 32593, 32594, 32624, 32581, 32625, + 32582, 32616, 32615, 32612, 32611, 32600, 32610, 32609, 32614, 32613, + 32602, 32588, 32587, 32584, 32583, 32601, 32590, 32589, 32586, 32585, + 32603, 32618, 32617, 32608, 32607, 32621, 32623, 32622, 32620, 32595, + 32604, 32605, 32606, 32619, 32634, 32643, 32644, 32637, 32638, 32639, + 32640, 32641, 32642, 32645, 32632, 32635, 32646, 32633, 32636, 32626, + 32629, 32631, 32630, 32627, 32628, 32657, 32577, 32658, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 32653, 32655, 32652, 32651, + 32648, 32647, 32650, 32649, 32656, 32654, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 27919, 27921, 27942, 27943, 27940, 27941, 27935, 27936, + 27937, 27938, 27968, 27922, 27969, 27923, 27960, 27959, 27956, 27955, + 27944, 27954, 27953, 27958, 27957, 27946, 27929, 27928, 27932, 27931, + 27945, 27930, 27925, 27934, 27933, 27947, 27962, 27961, 27952, 27951, + 27965, 27967, 27966, 27964, 27939, 27948, 27949, 27950, 27963, 27997, + 28004, 28005, 28002, 28003, 28000, 28001, 36293, 36293, 28006, 27998, + 28007, 27999, 27990, 27992, 27994, 27993, 27991, 27989, 28009, 28008, + 27988, 27987, 27970, 27971, 27972, 27918, 27985, 27984, 27982, 27980, + 27981, 27973, 27974, 27983, 27986, 27978, 27979, 27977, 27976, 27975, + 27924, 27926, 27927, 27920, 27995, 27996, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 22932, 22933, 22951, 22952, 22949, 22950, 22944, 22945, 22946, 22947, + 22978, 22934, 22979, 22935, 22971, 22970, 22967, 22966, 22955, 22965, + 22964, 22969, 22968, 22957, 22941, 22940, 22937, 22936, 22956, 22943, + 22942, 22939, 22938, 22958, 22973, 22972, 22963, 22962, 22975, 22977, + 22976, 22954, 22948, 22959, 22960, 22961, 22974, 22953, 22907, 22916, + 22917, 22910, 22911, 22912, 22913, 22914, 22915, 22918, 22908, 22919, + 22909, 22903, 22906, 22905, 22902, 22921, 22920, 22980, 22904, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 22928, 22930, 22927, 22926, 22923, 22922, 22925, 22924, 22931, 22929, + 36293, 36293, 36293, 36293, 36293, 36293, 23520, 23515, 23360, 23521, + 23519, 23517, 23516, 23377, 23378, 23511, 23513, 23512, 23522, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 30451, 30453, + 30468, 30469, 30466, 30467, 30493, 30454, 30494, 30455, 30483, 30482, + 30479, 30478, 30470, 30477, 30476, 30481, 30480, 30472, 30463, 30462, + 30457, 30456, 30471, 30465, 30464, 30459, 30458, 30473, 30485, 30484, + 30475, 30474, 30490, 30492, 30461, 30489, 30491, 30486, 30487, 30488, + 30460, 30496, 30498, 30499, 30504, 30505, 30502, 30503, 30506, 30500, + 30507, 30501, 30497, 30495, 30452, 30450, 36293, 36293, 36293, 36293, + 36293, 36293, 30514, 30516, 30513, 30512, 30509, 30508, 30511, 30510, + 30517, 30515, 36293, 36293, 36293, 36293, 36293, 36293, 24203, 24205, + 24202, 24201, 24198, 24197, 24200, 24199, 24206, 24204, 24153, 24155, + 24152, 24151, 24148, 24147, 24150, 24149, 24156, 24154, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 191, 190, 178, 181, 175, 167, + 193, 192, 183, 195, 189, 184, 174, 196, 177, 197, 180, 194, 164, 171, + 170, 187, 166, 186, 182, 188, 165, 36293, 36293, 162, 163, 161, 203, 204, + 210, 211, 208, 209, 212, 207, 213, 205, 206, 200, 36293, 36293, 36293, + 36293, 222, 224, 221, 220, 217, 216, 219, 218, 225, 223, 215, 214, 198, + 199, 201, 202, 185, 173, 172, 169, 168, 179, 176, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 10529, 10530, 10545, 10546, 10543, 10544, 10571, 10531, + 10572, 10532, 10563, 10562, 10559, 10558, 10547, 10557, 10556, 10561, + 10560, 10549, 10540, 10539, 10534, 10533, 10548, 10542, 10541, 10536, + 10535, 10550, 10565, 10564, 10555, 10554, 10568, 10570, 10538, 10567, + 10569, 10551, 10552, 10553, 10566, 10537, 10575, 10580, 10581, 10578, + 10579, 10573, 10574, 10582, 10576, 10583, 10577, 10586, 10588, 10587, + 10585, 10584, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 34384, 34373, 34402, 34392, 34394, 34395, 34401, 34391, + 34377, 34386, 34374, 34404, 34400, 34379, 34393, 34390, 34378, 34387, + 34396, 34385, 34403, 34376, 34375, 34398, 34399, 34382, 34381, 34380, + 34383, 34388, 34389, 34397, 34416, 34405, 34434, 34424, 34426, 34427, + 34433, 34423, 34409, 34418, 34406, 34436, 34432, 34411, 34425, 34422, + 34410, 34419, 34428, 34417, 34435, 34408, 34407, 34430, 34431, 34414, + 34413, 34412, 34415, 34420, 34421, 34429, 34443, 34445, 34442, 34441, + 34438, 34437, 34440, 34439, 34446, 34444, 34455, 34454, 34453, 34449, + 34448, 34452, 34451, 34447, 34450, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 34456, 10445, 10446, + 10453, 10454, 10451, 10452, 10480, 36293, 36293, 10481, 36293, 36293, + 10471, 10470, 10469, 10468, 10457, 10467, 10466, 10475, 36293, 10459, + 10441, 36293, 10448, 10447, 10458, 10442, 10440, 10450, 10449, 10460, + 10473, 10472, 10465, 10464, 10476, 10444, 10443, 10477, 10456, 10478, + 10461, 10462, 10463, 10474, 10455, 10479, 10486, 10490, 10491, 10488, + 10489, 10492, 36293, 10487, 10493, 36293, 36293, 10485, 10483, 10482, + 10494, 10499, 10496, 10500, 10495, 10484, 10429, 10497, 10498, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 10436, 10438, + 10435, 10434, 10431, 10430, 10433, 10432, 10439, 10437, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 24325, 24326, + 24341, 24342, 24339, 24340, 24322, 24323, 36293, 36293, 24367, 24327, + 24368, 24328, 24361, 24360, 24357, 24356, 24345, 24355, 24354, 24359, + 24358, 24347, 24336, 24335, 24330, 24329, 24346, 24338, 24337, 24332, + 24331, 24348, 24363, 24362, 24353, 24352, 24365, 24366, 24334, 24344, + 24324, 24349, 24350, 24351, 24364, 24343, 24333, 24377, 24382, 24383, + 24380, 24381, 24375, 24376, 36293, 36293, 24384, 24378, 24385, 24379, + 24371, 24373, 24372, 24370, 24369, 24386, 24374, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36074, 36095, 36092, 36091, 36094, 36090, + 36089, 36087, 36088, 36093, 36086, 36042, 36041, 36061, 36060, 36043, + 36059, 36058, 36068, 36045, 36053, 36052, 36035, 36034, 36044, 36055, + 36054, 36039, 36038, 36046, 36063, 36062, 36057, 36056, 36070, 36051, + 36050, 36037, 36036, 36064, 36065, 36066, 36073, 36071, 36069, 36072, + 36047, 36048, 36049, 36067, 36040, 36033, 36083, 36080, 36081, 36082, + 36079, 36084, 36030, 36029, 36027, 36026, 36028, 36032, 36025, 36078, + 36076, 36075, 36077, 36031, 36024, 36085, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 29143, 29164, 29162, 29161, 29163, 29159, + 29160, 29157, 29158, 29156, 29155, 29165, 29110, 29109, 29129, 29128, + 29111, 29127, 29126, 29131, 29130, 29113, 29121, 29120, 29104, 29103, + 29112, 29123, 29122, 29107, 29105, 29114, 29133, 29132, 29125, 29124, + 29139, 29119, 29118, 29106, 29134, 29135, 29136, 29142, 29140, 29138, + 29141, 29115, 29116, 29117, 29137, 29108, 29148, 29150, 29087, 29086, + 29084, 29085, 29095, 29096, 29091, 29094, 29090, 29093, 29098, 29099, + 29097, 29089, 29088, 29092, 29151, 29149, 29166, 29152, 29147, 29146, + 29145, 29144, 29102, 29101, 29100, 29153, 29154, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 5766, 5767, 5764, 5765, 5762, 5763, 5772, 5773, 5770, 5771, 5768, 5769, + 5935, 5936, 5937, 5934, 26290, 26288, 26297, 26298, 26294, 26302, 26301, + 26283, 26296, 26295, 26287, 26300, 26293, 26286, 26292, 26291, 26284, + 26289, 26299, 26278, 26285, 26303, 26304, 26279, 26305, 26281, 26282, + 26280, 26274, 26271, 26275, 26273, 26269, 26272, 26276, 26270, 26277, + 26311, 26310, 26321, 26312, 26313, 26322, 26318, 26317, 26319, 26320, + 26314, 26268, 26315, 26316, 26307, 26306, 26266, 26308, 26309, 26267, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 10170, 10171, 10261, + 10262, 10263, 10264, 10271, 10270, 10272, 10276, 10174, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 27809, 27808, 27814, 27813, 27815, 27816, 27805, + 27806, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 29753, + 29772, 29779, 29776, 29766, 29763, 29758, 29780, 29748, 29765, 29775, + 29755, 29752, 29761, 29778, 29756, 29774, 29762, 29767, 29773, 29777, + 29750, 29749, 29754, 29770, 29764, 29760, 29759, 29768, 29751, 29769, + 29771, 29757, 29781, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 29788, 29790, 29787, + 29786, 29783, 29782, 29785, 29784, 29791, 29789, 36293, 36293, 36293, + 36293, 36293, 36293, 3806, 3807, 3820, 3821, 3818, 3819, 3802, 3803, + 3804, 36293, 3846, 3808, 3847, 3809, 3838, 3837, 3834, 3833, 3822, 3832, + 3831, 3836, 3835, 3824, 3815, 3814, 3811, 3810, 3823, 3817, 3816, 3813, + 3812, 3825, 3840, 3839, 3830, 3829, 3843, 3845, 3844, 3842, 3805, 3826, + 3827, 3828, 3841, 3874, 3879, 3880, 3877, 3878, 3871, 3872, 3873, 36293, + 3881, 3875, 3882, 3876, 3866, 3868, 3870, 3869, 3867, 3884, 3883, 3895, + 3896, 3897, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 3891, 3893, 3890, 3889, 3886, 3885, 3888, 3887, 3894, 3892, + 3865, 3863, 3860, 3851, 3853, 3858, 3856, 3848, 3854, 3864, 3862, 3861, + 3850, 3852, 3859, 3857, 3849, 3855, 3898, 36293, 36293, 36293, 21023, + 21024, 20969, 20968, 20978, 20963, 20967, 20966, 20980, 20964, 20960, + 20959, 20962, 20965, 20971, 20970, 20977, 20982, 20958, 20957, 20961, + 20984, 20974, 20975, 20976, 20985, 20983, 20981, 20972, 20973, 20979, + 20986, 36293, 36293, 21001, 21000, 21009, 20995, 20999, 20998, 21011, + 20996, 20992, 20991, 20994, 20997, 21003, 21002, 21008, 21013, 20990, + 20989, 20993, 21015, 21006, 21007, 36293, 21016, 21014, 21012, 21004, + 21005, 21010, 21017, 21018, 21020, 21022, 21019, 21021, 20988, 20987, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 21035, 21036, 21045, 21046, 21043, 21044, 21072, + 36293, 21037, 21073, 36293, 21038, 21051, 21050, 21064, 21063, 21052, + 21062, 21061, 21029, 21028, 21054, 21031, 21030, 21040, 21039, 21053, + 21034, 21032, 21042, 21041, 21055, 21066, 21065, 21060, 21059, 21068, + 21071, 21069, 21048, 21070, 21056, 21057, 21058, 21067, 21047, 21049, + 21027, 21033, 21082, 21087, 21088, 21085, 21086, 21081, 36293, 36293, + 36293, 21089, 36293, 21083, 21090, 36293, 21084, 21080, 21079, 21078, + 21076, 21077, 21091, 21075, 21074, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 21098, 21100, 21097, 21096, 21093, 21092, 21095, + 21094, 21101, 21099, 36293, 36293, 36293, 36293, 36293, 36293, 14305, + 14306, 14319, 14320, 14317, 14318, 36293, 14336, 14307, 36293, 14335, + 14308, 14342, 14341, 14324, 14323, 14338, 14332, 14331, 14316, 14315, + 14322, 14328, 14327, 14312, 14311, 14304, 14326, 14325, 14314, 14313, + 14321, 14330, 14329, 14310, 14309, 14303, 14334, 14333, 14337, 14339, + 14340, 14345, 14350, 14351, 14348, 14349, 36293, 14353, 14346, 36293, + 14352, 14347, 14344, 14343, 14354, 14365, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 14361, 14363, 14360, 14359, 14356, 14355, 14358, + 14357, 14364, 14362, 36293, 36293, 36293, 36293, 36293, 36293, 32747, + 32745, 32752, 32750, 32715, 32716, 32743, 32744, 32733, 32734, 32749, + 32729, 32732, 32717, 32720, 32721, 32730, 32731, 32718, 32719, 32722, + 32735, 32736, 32739, 32740, 32725, 32741, 32742, 32737, 32738, 32724, + 32755, 32726, 32748, 32753, 32723, 32751, 32746, 32754, 32727, 32728, + 32756, 32757, 32758, 36293, 36293, 36293, 36293, 32765, 32767, 32764, + 32763, 32760, 32759, 32762, 32761, 32768, 32766, 36293, 36293, 36293, + 36293, 36293, 36293, 3710, 3651, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 20721, 20719, 20713, 20724, 20716, 20723, 20727, + 20718, 20715, 20717, 20720, 20714, 20729, 20725, 20722, 20728, 20726, + 20730, 20736, 20733, 20735, 20732, 20734, 20731, 20712, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 17122, 17126, 17124, 17125, 17063, + 17064, 17083, 17084, 17077, 17078, 17079, 17080, 17081, 17082, 17108, + 17065, 17109, 36293, 17099, 17098, 17097, 17096, 17085, 17095, 17094, + 17068, 17067, 17087, 17074, 17073, 17070, 17069, 17086, 17076, 17075, + 17072, 17071, 17088, 17101, 17100, 17093, 17092, 17104, 17107, 17105, + 17103, 17106, 17089, 17090, 17091, 17102, 17066, 17128, 17127, 17135, + 17136, 17133, 17134, 17130, 36293, 36293, 36293, 17131, 17129, 17132, + 17121, 17149, 17138, 17137, 17116, 17119, 17115, 17117, 17113, 17112, + 17120, 17111, 17114, 17118, 17110, 17145, 17147, 17144, 17143, 17140, + 17139, 17142, 17141, 17148, 17146, 17123, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 20365, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 30574, 30570, 30564, + 30573, 30566, 30575, 30579, 30581, 30576, 30571, 30572, 30577, 30565, + 30582, 30580, 30567, 30578, 30568, 30569, 30583, 30584, 30648, 30631, + 30629, 30638, 30637, 30633, 30639, 30635, 30634, 30641, 30642, 30643, + 30640, 30632, 30645, 30563, 30550, 30621, 30628, 30918, 30919, 30548, + 30523, 30649, 30917, 30585, 30650, 30636, 30644, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 30626, 8320, 8328, 8326, 8322, 8327, 8323, 8321, 8324, 8325, 8389, 8329, + 8338, 8337, 8331, 8330, 8342, 8332, 8333, 8341, 8335, 8336, 8343, 8344, + 8349, 8346, 8345, 8347, 8348, 8351, 8353, 8355, 8354, 8356, 8362, 8359, + 8360, 8364, 8357, 8358, 8363, 8361, 8366, 8365, 8367, 8369, 8370, 8374, + 8373, 8371, 8372, 8375, 8388, 8376, 8377, 8378, 8387, 8379, 8383, 8384, + 8382, 8380, 8381, 8386, 8385, 8390, 8391, 8402, 8393, 8397, 8398, 8399, + 8400, 8401, 8403, 8406, 8405, 8404, 8407, 8409, 8410, 8411, 8412, 8413, + 8414, 8415, 8416, 8417, 8418, 8419, 8420, 8421, 8422, 8423, 8424, 8425, + 8426, 8441, 8427, 8428, 8438, 8432, 8429, 8430, 8431, 8439, 8436, 8440, + 8437, 8433, 8435, 8448, 8444, 8445, 8446, 8449, 8460, 8450, 8453, 8454, + 8456, 8457, 8458, 8461, 8464, 8462, 8463, 8465, 8466, 8468, 8469, 8498, + 8505, 8499, 8500, 8501, 8502, 8503, 8504, 8506, 8508, 8507, 8509, 8512, + 8513, 8516, 8510, 8511, 8517, 8562, 8561, 8563, 8518, 8521, 8522, 8523, + 8519, 8520, 8524, 8527, 8525, 8528, 8530, 8539, 8540, 8541, 8542, 8560, + 8543, 8544, 8557, 8558, 8556, 8545, 8546, 8547, 8548, 8549, 8550, 8551, + 8554, 8555, 8564, 8654, 8565, 8566, 8568, 8567, 8574, 8569, 8571, 8573, + 8577, 8576, 8578, 8579, 8586, 8580, 8581, 8585, 8589, 8590, 8587, 8588, + 8596, 8593, 8597, 8598, 8599, 8600, 8601, 8603, 8604, 8606, 8605, 8608, + 8607, 8610, 8609, 8611, 8612, 8614, 8615, 8619, 8621, 8625, 8626, 8639, + 8631, 8632, 8627, 8628, 8629, 8633, 8637, 8634, 8635, 8636, 8640, 8641, + 8643, 8644, 8645, 8646, 8647, 8648, 8658, 8649, 8650, 8653, 8652, 8651, + 8655, 8656, 8657, 8659, 8660, 8663, 8664, 8665, 8666, 8667, 8669, 8668, + 8685, 8676, 8677, 8670, 8671, 8673, 8674, 8672, 8675, 8684, 8678, 8683, + 8681, 8680, 8682, 8687, 8706, 8688, 8689, 8690, 8693, 8692, 8694, 8695, + 8697, 8698, 8699, 8707, 8700, 8701, 8702, 8705, 8704, 8703, 8708, 8709, + 8711, 8712, 8713, 8714, 8716, 8720, 8717, 8721, 8719, 8718, 8722, 8723, + 8724, 8725, 8729, 8728, 8726, 8727, 8730, 8731, 8733, 8752, 8754, 8734, + 8736, 8735, 8737, 8738, 8741, 8742, 8740, 8739, 8743, 8744, 8745, 8746, + 8749, 8747, 8748, 8750, 8751, 8755, 8756, 8753, 8757, 8758, 8759, 8760, + 8762, 8765, 8764, 8766, 8767, 8769, 8770, 8771, 8775, 8774, 8772, 8773, + 8776, 8780, 8779, 8778, 8781, 8782, 8784, 8785, 8789, 8786, 8787, 8792, + 8790, 8793, 8794, 8796, 8795, 8797, 8798, 8820, 8819, 8822, 8823, 8804, + 8805, 8802, 8803, 8801, 8799, 8807, 8806, 8808, 8810, 8816, 8817, 8814, + 8815, 8824, 8825, 8826, 8844, 8829, 8830, 8831, 8827, 8828, 8832, 8833, + 8834, 8835, 8836, 8838, 8839, 8840, 8841, 8842, 8867, 8845, 8848, 8846, + 8847, 8853, 8854, 8851, 8852, 8849, 8850, 8855, 8856, 8864, 8857, 8858, + 8865, 8862, 8863, 8866, 8859, 8860, 8861, 8868, 8869, 8870, 8871, 8872, + 8873, 8874, 8876, 8877, 8875, 8878, 8879, 8920, 8921, 8882, 8883, 8880, + 8881, 8886, 8887, 8885, 8891, 8888, 8890, 8889, 8895, 8896, 8894, 8892, + 8893, 8897, 8898, 8899, 8900, 8901, 8902, 8903, 8922, 8908, 8904, 8905, + 8906, 8907, 8909, 8911, 8910, 8912, 8913, 8915, 8914, 8916, 8918, 8917, + 8923, 8924, 8927, 8928, 8925, 8926, 9002, 8997, 8998, 8999, 9000, 9001, + 9003, 9006, 9004, 9005, 9007, 9049, 9008, 9038, 9039, 9015, 9017, 9034, + 9018, 9040, 9022, 9020, 9021, 9023, 9024, 9025, 9026, 9035, 9036, 9029, + 9030, 9032, 9041, 9009, 9010, 9014, 9012, 9050, 9042, 9044, 9043, 9045, + 9051, 9052, 9046, 9047, 9048, 9053, 9054, 9055, 9058, 9059, 9060, 9056, + 9057, 9061, 9062, 9064, 9066, 9067, 9085, 9083, 9084, 9087, 9086, 9068, + 9075, 9073, 9074, 9069, 9070, 9076, 9077, 9078, 9079, 9080, 9082, 9088, + 9097, 9089, 9092, 9091, 9090, 9093, 9095, 9094, 9096, 9099, 9101, 9100, + 9102, 9103, 9136, 9138, 9104, 9106, 9105, 9108, 9111, 9109, 9110, 9114, + 9118, 9121, 9120, 9123, 9126, 9124, 9125, 9129, 9131, 9137, 9139, 9140, + 9144, 9151, 9149, 9147, 9148, 9150, 9153, 9152, 9145, 9146, 9154, 9157, + 9163, 9158, 9161, 9156, 9155, 9164, 9162, 9159, 9160, 9165, 9166, 9167, + 9168, 9169, 9170, 9171, 9173, 9176, 9177, 9180, 9181, 9182, 9178, 9179, + 9174, 9175, 9183, 9184, 9185, 9186, 9187, 9188, 9190, 9191, 9192, 9193, + 9194, 9198, 9195, 9219, 9212, 9213, 9218, 9201, 9200, 9214, 9217, 9215, + 9204, 9203, 9206, 9208, 9209, 9210, 9211, 9207, 9220, 9196, 9221, 9222, + 9223, 9224, 9225, 9226, 9234, 9232, 9230, 9233, 9229, 9231, 9227, 9228, + 9235, 9237, 9238, 9239, 9246, 9241, 9242, 9250, 9251, 9247, 9249, 9248, + 9252, 9254, 9253, 9255, 9266, 9257, 9256, 9265, 9263, 9258, 9259, 9260, + 9262, 9261, 9264, 9270, 9267, 9269, 9268, 9271, 9272, 9273, 9274, 9277, + 9278, 9280, 9281, 9282, 9283, 9285, 9284, 9286, 9293, 9287, 9288, 9294, + 9289, 9290, 9291, 9292, 9295, 9299, 9296, 9297, 9298, 9300, 9301, 9302, + 9303, 9309, 9307, 9305, 9306, 9304, 9308, 9310, 9312, 9329, 9330, 9313, + 9318, 9320, 9314, 9317, 9315, 9316, 9321, 9327, 9328, 9322, 9325, 9326, + 9331, 9337, 9336, 9332, 9334, 9333, 9418, 9419, 9338, 9339, 9344, 9345, + 9342, 9343, 9346, 9340, 9341, 9347, 9350, 9351, 9353, 9354, 9355, 9359, + 9356, 9357, 9358, 9348, 9349, 9360, 9362, 9361, 9363, 9364, 9365, 9366, + 9372, 9371, 9367, 9368, 9369, 9405, 9374, 9375, 9376, 9377, 9378, 9397, + 9380, 9381, 9383, 9382, 9384, 9385, 9401, 9386, 9388, 9387, 9400, 9390, + 9398, 9402, 9393, 9392, 9399, 9394, 9396, 9395, 9403, 9404, 9406, 9410, + 9408, 9409, 9407, 9413, 9412, 9411, 9417, 9414, 9415, 9416, 9420, 9422, + 9421, 9425, 9423, 9440, 9426, 9429, 9431, 9427, 9428, 9432, 9430, 9433, + 9435, 9437, 9438, 9439, 8843, 8339, 8350, 8368, 8434, 8443, 8459, 8467, + 8559, 8552, 8570, 8572, 8662, 8686, 8732, 8761, 8763, 8777, 8783, 8818, + 8791, 8821, 8800, 8809, 8813, 8884, 9013, 9016, 9031, 9063, 9081, 9098, + 9107, 9135, 9133, 9112, 9143, 9172, 9189, 9199, 9319, 9352, 9335, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 8257, 8252, 8008, 7957, 8197, 8170, 7909, 8044, 8256, 8016, 7963, + 8203, 8175, 7916, 8049, 8014, 7961, 8199, 8172, 7911, 8046, 8143, 8264, + 8254, 8010, 7959, 8201, 8174, 7913, 8048, 8144, 8265, 8255, 8011, 7960, + 8311, 8246, 8247, 8012, 7949, 8196, 8169, 7908, 8043, 8147, 8312, 8248, + 8249, 8013, 7950, 8176, 8177, 8141, 8261, 8204, 8205, 7967, 7955, 8250, + 8251, 8004, 8007, 8005, 8006, 8202, 8150, 8148, 8149, 7914, 7915, 8021, + 8023, 8024, 8022, 8258, 8253, 8009, 7958, 8198, 8139, 8259, 8207, 7964, + 7965, 7952, 7953, 8018, 8017, 8055, 8263, 8146, 8314, 7951, 8145, 8313, + 8054, 8137, 8050, 8051, 8138, 8057, 7917, 7920, 7919, 7918, 8015, 7962, + 8200, 8173, 7912, 8047, 8171, 8319, 8318, 8317, 8315, 8316, 7910, 8045, + 7884, 7888, 7887, 7882, 7881, 7886, 7885, 7889, 7883, 8340, 8334, 8352, + 8392, 8394, 8395, 8396, 8408, 8447, 8442, 8452, 8451, 8455, 8472, 8470, + 8471, 8473, 8474, 8492, 8478, 8475, 8476, 8477, 8494, 8495, 8493, 8482, + 8481, 8479, 8480, 8485, 8483, 8484, 8486, 8487, 8488, 8489, 8496, 8497, + 8491, 8490, 8515, 8514, 8526, 8529, 8534, 8538, 8531, 8535, 8536, 8532, + 8533, 8537, 8553, 8575, 8582, 8583, 8584, 8591, 8592, 8595, 8594, 8602, + 8613, 8616, 8617, 8618, 8620, 8622, 8623, 8624, 8630, 8638, 8642, 8661, + 8679, 8691, 8696, 8710, 8715, 8768, 8788, 8811, 8812, 8919, 8939, 8929, + 8930, 8938, 8934, 8935, 8936, 8933, 8932, 8931, 8937, 8941, 8940, 8947, + 8948, 8942, 8943, 8944, 8949, 8945, 8946, 8950, 8951, 8952, 8953, 8954, + 8955, 8962, 8956, 8961, 8960, 8958, 8957, 8959, 8963, 8964, 8969, 8970, + 8965, 8966, 8967, 8968, 8996, 8992, 8971, 8979, 8980, 8978, 8977, 8981, + 8972, 8973, 8975, 8976, 8974, 8993, 8982, 8989, 8991, 8986, 8987, 8990, + 8985, 8988, 8984, 8983, 8994, 8995, 9011, 9037, 9019, 9027, 9028, 9033, + 9065, 9072, 9071, 9132, 9113, 9115, 9134, 9116, 9117, 9119, 9122, 9127, + 9128, 9130, 9197, 9216, 9202, 9205, 9236, 9240, 9243, 9244, 9245, 9276, + 9275, 9279, 9311, 9323, 9324, 9373, 9370, 9379, 9391, 9389, 9424, 9434, + 9436, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 8058, 8266, 8227, 7969, 7927, 8178, 8151, 7890, + 8025, 8063, 8276, 8237, 7977, 7935, 8182, 8155, 7894, 8029, 8072, 8277, + 8238, 7996, 7941, 8183, 8156, 7895, 8030, 8104, 8287, 8209, 7978, 7921, + 8188, 8161, 7900, 8035, 8127, 8303, 8220, 7989, 7926, 8117, 8294, 8219, + 7988, 7925, 8194, 8167, 7906, 8041, 8131, 8307, 8224, 7993, 7938, 8052, + 8053, 8059, 8136, 8056, 8087, 8283, 8142, 8262, 8206, 7968, 7956, 8140, + 8260, 8208, 7966, 7954, 8019, 8020, 8129, 8305, 8222, 7991, 7936, 8191, + 8164, 7903, 8038, 8133, 8309, 8226, 7995, 7940, 8134, 8310, 8091, 8089, + 8084, 8080, 8083, 8098, 8100, 8102, 8103, 8111, 8112, 8113, 8109, 8289, + 8211, 7980, 8110, 8290, 8212, 7981, 8067, 8272, 8233, 7973, 7931, 8180, + 8153, 7892, 8027, 8078, 8281, 8242, 8000, 7945, 8114, 8291, 8213, 7982, + 7923, 8070, 8275, 8236, 7976, 7934, 8181, 8154, 7893, 8028, 8095, 8286, + 8245, 8003, 7948, 8116, 8132, 8308, 8225, 7994, 7939, 8193, 8166, 7905, + 8040, 8135, 8092, 8124, 8300, 8217, 7986, 8068, 8273, 8234, 7974, 7932, + 8079, 8282, 8243, 8001, 7946, 8187, 8160, 7899, 8034, 8119, 8093, 8090, + 8085, 8081, 8125, 8301, 8218, 7987, 8061, 8268, 8229, 7971, 7929, 8074, + 8279, 8240, 7998, 7943, 8185, 8158, 7897, 8032, 8120, 8296, 8107, 8292, + 8214, 7983, 7924, 8190, 8163, 7902, 8037, 8128, 8304, 8221, 7990, 8096, + 8097, 8086, 8082, 8099, 8101, 8122, 8298, 8215, 7984, 8123, 8299, 8216, + 7985, 8069, 8274, 8235, 7975, 7933, 8094, 8285, 8244, 8002, 7947, 8195, + 8168, 7907, 8042, 8126, 8302, 8115, 8293, 8071, 8076, 8077, 8065, 8270, + 8231, 8066, 8271, 8232, 8060, 8267, 8228, 7970, 7928, 8179, 8152, 7891, + 8026, 8064, 8073, 8278, 8239, 7997, 7942, 8184, 8157, 7896, 8031, 8105, + 8288, 8210, 7979, 7922, 8189, 8162, 7901, 8036, 8118, 8295, 8088, 8284, + 8130, 8306, 8223, 7992, 7937, 8192, 8165, 7904, 8039, 8106, 8062, 8269, + 8230, 7972, 7930, 8075, 8280, 8241, 7999, 7944, 8186, 8159, 7898, 8033, + 8121, 8297, 8108, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 9514, 9515, 9516, 9517, + 9518, 9519, 9520, 9521, 9524, 9525, 9522, 9523, 9526, 9527, 9528, 9529, + 9530, 9531, 9532, 9533, 9534, 9535, 9536, 9537, 9538, 9539, 9540, 9541, + 9542, 9543, 9544, 9545, 9546, 9547, 9548, 9549, 9550, 9551, 9552, 9553, + 9554, 9555, 9556, 9557, 9558, 9559, 9560, 9580, 9581, 9582, 9583, 9584, + 9585, 9586, 9587, 9588, 9563, 9564, 9565, 9566, 9567, 9561, 9562, 9568, + 9569, 9570, 9589, 9590, 9591, 9592, 9593, 9594, 9595, 9596, 9597, 9598, + 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9599, 9600, 9601, + 9602, 9603, 9604, 9605, 9606, 9607, 9608, 9609, 9610, 9611, 9612, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 11052, 11053, 11054, 11055, 11050, 11051, 11047, 11048, + 11049, 11056, 11057, 11058, 11063, 11064, 11065, 11066, 11059, 11060, + 11067, 11068, 11061, 11062, 11069, 11070, 11097, 11098, 11099, 11100, + 11101, 11102, 11103, 11104, 11105, 11106, 11087, 11088, 11085, 11086, + 11089, 11090, 11091, 11092, 11093, 11094, 11095, 11071, 11072, 11079, + 11073, 11074, 11075, 11076, 11080, 11077, 11078, 11081, 11082, 11083, + 11084, 11107, 11108, 11109, 11110, 11111, 11112, 11113, 11114, 11115, + 11116, 11117, 11118, 11119, 11120, 11121, 11122, 11123, 11124, 11125, + 11126, 11096, 11166, 11167, 11168, 11169, 11164, 11165, 11170, 11171, + 11172, 11173, 11178, 11174, 11175, 11176, 11177, 11179, 11180, 11181, + 11182, 11183, 11184, 11185, 11186, 11187, 11188, 11189, 11190, 11191, + 11192, 11193, 11194, 11195, 11196, 11197, 11198, 11199, 11200, 11201, + 11204, 11205, 11206, 11207, 11208, 11209, 11210, 11202, 11203, 11211, + 11284, 11285, 11286, 11287, 11288, 11289, 11290, 11291, 11292, 11293, + 11275, 11276, 11277, 11278, 11279, 11280, 11281, 11273, 11274, 11282, + 11283, 11216, 11212, 11213, 11217, 11218, 11214, 11215, 11219, 11220, + 11221, 11222, 11223, 11228, 11229, 11230, 11231, 11232, 11233, 11224, + 11225, 11234, 11226, 11227, 11235, 11236, 11237, 11238, 11239, 11240, + 11241, 11242, 11243, 11244, 11245, 11250, 11246, 11247, 11251, 11248, + 11249, 11252, 11253, 11254, 11255, 11256, 11266, 11267, 11268, 11269, + 11270, 11271, 11272, 11257, 11258, 11259, 11260, 11261, 11262, 11263, + 11264, 11265, 11298, 11299, 11300, 11301, 11302, 11303, 11304, 11294, + 11295, 11296, 11297, 11330, 11331, 11332, 11333, 11334, 11335, 11326, + 11327, 11328, 11329, 11336, 11337, 11305, 11306, 11309, 11310, 11311, + 11312, 11313, 11314, 11315, 11307, 11308, 11316, 11319, 11320, 11321, + 11322, 11317, 11318, 11323, 11324, 11325, 11341, 11342, 11343, 11344, + 11345, 11346, 11347, 11348, 11349, 11350, 11353, 11354, 11355, 11351, + 11352, 11356, 11357, 11358, 11359, 11360, 11361, 11397, 11395, 11396, + 11398, 11399, 11400, 11401, 11402, 11403, 11404, 11405, 11368, 11362, + 11363, 11369, 11370, 11371, 11372, 11373, 11364, 11365, 11366, 11367, + 11374, 11381, 11382, 11383, 11384, 11385, 11375, 11376, 11377, 11378, + 11379, 11380, 11386, 11387, 11392, 11388, 11389, 11390, 11391, 11393, + 11394, 11412, 11413, 11414, 11415, 11416, 11410, 11411, 11407, 11408, + 11409, 11417, 11418, 11421, 11419, 11420, 11422, 11423, 11424, 11425, + 11426, 11427, 11428, 11429, 11454, 11455, 11458, 11459, 11460, 11461, + 11462, 11456, 11457, 11463, 11464, 11465, 11434, 11435, 11436, 11437, + 11438, 11439, 11430, 11431, 11432, 11433, 11440, 11441, 11446, 11447, + 11448, 11442, 11443, 11449, 11444, 11445, 11450, 11451, 11452, 11453, + 11466, 11467, 11468, 11469, 11470, 11473, 11474, 11475, 11476, 11477, + 11471, 11472, 11478, 11479, 11487, 11488, 11489, 11490, 11483, 11484, + 11491, 11492, 11493, 11485, 11486, 11494, 11495, 11496, 11497, 11498, + 11499, 11500, 11501, 12142, 12143, 12144, 12145, 12146, 12147, 12148, + 12149, 11513, 11509, 11510, 11514, 11515, 11516, 11511, 11512, 11517, + 11518, 11520, 11521, 11522, 11525, 11523, 11524, 11526, 11527, 11528, + 11529, 11530, 11531, 11541, 11542, 11549, 11532, 11533, 11534, 11535, + 11536, 11537, 11538, 11539, 11540, 11550, 11551, 11543, 11544, 11545, + 11546, 11547, 11548, 11552, 11553, 11560, 11561, 11554, 11555, 11562, + 11556, 11557, 11563, 11564, 11565, 11558, 11559, 11566, 11572, 11570, + 11571, 11573, 11567, 11568, 11569, 11574, 11575, 11576, 11577, 11578, + 11579, 11580, 11581, 11582, 11583, 11584, 11585, 11642, 11643, 11644, + 11645, 11646, 11647, 11648, 11649, 11650, 11605, 11606, 11607, 11608, + 11609, 11610, 11611, 11612, 11602, 11603, 11604, 11613, 11630, 11631, + 11632, 11633, 11634, 11628, 11629, 11635, 11636, 11637, 11638, 11622, + 11623, 11624, 11614, 11615, 11616, 11617, 11618, 11619, 11625, 11620, + 11621, 11626, 11627, 11639, 11640, 11641, 11653, 11654, 11655, 11656, + 11651, 11652, 11657, 11658, 11659, 11660, 11663, 11664, 11665, 11666, + 11667, 11668, 11669, 11661, 11662, 11670, 11671, 11672, 11690, 11691, + 11692, 11693, 11694, 11695, 11696, 11697, 11698, 11673, 11674, 11675, + 11676, 11679, 11680, 11681, 11682, 11683, 11684, 11677, 11678, 11685, + 11688, 11689, 11686, 11687, 11706, 11707, 11710, 11711, 11712, 11708, + 11709, 11699, 11700, 11701, 11702, 11703, 11704, 11705, 11713, 11714, + 11715, 11716, 11717, 11718, 11719, 11722, 11723, 11724, 11725, 11726, + 11727, 11728, 11729, 11720, 11721, 11730, 11731, 11738, 11739, 11740, + 11732, 11733, 11734, 11735, 11741, 11742, 11743, 11736, 11737, 11749, + 11750, 11753, 11754, 11751, 11752, 11755, 11756, 11744, 11745, 11746, + 11747, 11748, 11757, 11758, 11759, 11764, 11765, 11766, 11767, 11768, + 11769, 11770, 11771, 11772, 11773, 11760, 11761, 11762, 11763, 11775, + 11776, 11779, 11777, 11778, 11780, 11781, 11782, 11783, 11784, 11785, + 11786, 11787, 12150, 12151, 12152, 12153, 12154, 12155, 12156, 11793, + 11791, 11792, 11788, 11789, 11790, 11794, 11795, 11796, 11797, 11798, + 11799, 11800, 11801, 11804, 11805, 11806, 11807, 11808, 11802, 11803, + 11809, 11810, 11811, 11812, 11813, 11814, 11815, 11816, 11817, 11818, + 11819, 11820, 11821, 11826, 11822, 11823, 11827, 11828, 11829, 11824, + 11825, 11830, 11831, 11832, 11838, 11839, 11840, 11841, 11833, 11834, + 11835, 11842, 11843, 11836, 11837, 11844, 11845, 11849, 11850, 11851, + 11852, 11853, 11854, 11846, 11847, 11848, 11855, 11856, 11857, 11860, + 11861, 11862, 11863, 11864, 11858, 11859, 11865, 11866, 11867, 11868, + 11869, 11870, 11871, 11872, 11873, 11874, 11875, 11884, 11885, 11876, + 11877, 11886, 11887, 11888, 11878, 11879, 11880, 11881, 11882, 11883, + 11893, 11889, 11890, 11894, 11895, 11896, 11897, 11891, 11892, 11898, + 11899, 11900, 11910, 11911, 11912, 11913, 11914, 11915, 11916, 11917, + 11918, 11919, 11905, 11906, 11901, 11902, 11903, 11904, 11907, 11908, + 11909, 11924, 11925, 11926, 11927, 11928, 11921, 11922, 11923, 11929, + 11930, 11931, 11958, 11959, 11960, 11961, 11962, 11963, 11964, 11965, + 11966, 11967, 11936, 11937, 11938, 11932, 11933, 11939, 11940, 11941, + 11942, 11943, 11934, 11935, 11946, 11947, 11944, 11945, 11948, 11949, + 11950, 11951, 11952, 11953, 11954, 11955, 11956, 11957, 11971, 11972, + 11973, 11974, 11975, 11976, 11977, 11978, 11979, 11980, 11981, 11982, + 11983, 11984, 11985, 11986, 11968, 11969, 11970, 11987, 11988, 11997, + 11989, 11990, 11991, 11992, 11994, 11995, 11996, 11998, 11999, 12000, + 12001, 12002, 12003, 12004, 12005, 12006, 12007, 12008, 12009, 12010, + 12011, 12012, 12013, 12014, 12015, 12016, 12017, 12024, 12025, 12018, + 12019, 12026, 12027, 12028, 12029, 12020, 12021, 12022, 12023, 12030, + 12031, 12032, 12033, 12038, 12034, 12035, 12039, 12040, 12041, 12036, + 12037, 12042, 12043, 12044, 12045, 12051, 12052, 12047, 12048, 12053, + 12054, 12055, 12056, 12057, 12049, 12050, 12058, 12059, 12066, 12067, + 12068, 12060, 12061, 12069, 12070, 12062, 12063, 12064, 12065, 12071, + 12074, 12075, 12076, 12077, 12072, 12073, 12078, 12087, 12088, 12089, + 12080, 12081, 12082, 12090, 12083, 12084, 12091, 12085, 12086, 12092, + 12093, 12094, 12095, 12096, 12097, 12098, 12099, 12100, 12113, 12101, + 12102, 12103, 12104, 12105, 12106, 12107, 12108, 12109, 12110, 12111, + 12112, 12114, 12115, 12116, 12117, 12137, 12138, 12139, 12140, 12141, + 12118, 12119, 12120, 12121, 12122, 12123, 12124, 12125, 12126, 12127, + 12128, 12129, 12130, 12131, 12132, 12133, 12134, 12135, 12136, 11130, + 11131, 11132, 11133, 11134, 11135, 11127, 11128, 11129, 11136, 11137, + 11141, 11142, 11143, 11144, 11145, 11146, 11147, 11148, 11149, 11150, + 11151, 11152, 11153, 11154, 11155, 11156, 11157, 11158, 11159, 11160, + 11138, 11139, 11140, 11993, 12046, 11482, 11507, 11504, 11506, 11503, + 11774, 11163, 11340, 11508, 11505, 11502, 11162, 11339, 11161, 11338, + 11601, 11406, 11480, 11519, 11481, 11920, 12079, 11597, 11588, 11592, + 11599, 11595, 11589, 11594, 11591, 11598, 11587, 11593, 11600, 11596, + 11590, 11586, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 450, 451, 452, 453, 454, 455, 456, 457, 458, 439, 440, 441, + 442, 443, 444, 445, 446, 447, 448, 449, 380, 381, 382, 383, 384, 385, + 378, 379, 386, 387, 388, 430, 431, 432, 433, 434, 435, 436, 437, 438, + 428, 429, 396, 392, 393, 397, 398, 399, 394, 395, 389, 390, 391, 400, + 401, 402, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 407, 408, + 409, 410, 411, 412, 403, 404, 405, 406, 413, 414, 415, 469, 470, 471, + 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, + 486, 487, 488, 420, 421, 422, 423, 424, 425, 426, 416, 417, 418, 419, + 427, 500, 501, 502, 503, 504, 505, 506, 489, 490, 491, 492, 497, 498, + 499, 507, 493, 494, 495, 496, 508, 509, 510, 511, 512, 515, 516, 517, + 518, 513, 514, 519, 520, 521, 522, 525, 526, 527, 528, 529, 523, 524, + 530, 531, 532, 533, 536, 537, 538, 539, 540, 534, 535, 541, 542, 543, + 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, + 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, + 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, + 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, + 600, 601, 602, 603, 604, 612, 613, 605, 606, 607, 614, 615, 616, 617, + 608, 609, 618, 610, 611, 623, 624, 625, 626, 627, 619, 620, 621, 622, + 628, 629, 630, 656, 657, 658, 659, 660, 661, 662, 654, 655, 663, 664, + 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, + 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, + 704, 705, 667, 668, 669, 670, 671, 672, 673, 665, 666, 674, 675, 706, + 707, 708, 709, 710, 711, 712, 713, 714, 715, 645, 646, 647, 648, 649, + 650, 651, 652, 653, 643, 644, 635, 636, 637, 638, 631, 632, 639, 640, + 641, 642, 633, 634, 718, 719, 720, 721, 722, 723, 724, 725, 726, 716, + 717, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 729, 730, 731, + 732, 733, 734, 735, 736, 737, 727, 728, 756, 757, 753, 754, 755, 758, + 759, 760, 749, 750, 751, 752, 761, 762, 763, 820, 821, 822, 823, 824, + 825, 826, 827, 828, 829, 740, 741, 742, 743, 744, 745, 746, 747, 748, + 738, 739, 768, 769, 770, 771, 764, 765, 772, 773, 774, 766, 767, 775, + 801, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 782, 778, 779, + 783, 776, 777, 784, 785, 780, 781, 786, 787, 788, 790, 791, 792, 789, + 793, 794, 795, 796, 797, 798, 861, 862, 863, 864, 865, 866, 867, 868, + 869, 870, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 871, + 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, + 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, + 900, 841, 842, 845, 846, 847, 848, 849, 850, 843, 844, 851, 852, 901, + 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, + 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, + 930, 853, 854, 855, 856, 857, 858, 859, 860, 932, 933, 934, 935, 936, + 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, + 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 931, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 14485, 14475, 14474, 14471, 14470, 14456, 14469, + 14468, 14473, 14472, 14478, 14463, 14462, 14459, 14458, 14483, 14465, + 14464, 14461, 14460, 14457, 14477, 14476, 14467, 14466, 14480, 14484, + 14481, 14479, 14482, 14488, 14495, 14496, 14491, 14492, 14497, 14498, + 14489, 14493, 14494, 14490, 14499, 14455, 14454, 14452, 14486, 14453, + 14487, 14506, 14508, 14505, 14504, 14501, 14500, 14503, 14502, 14509, + 14507, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 2935, + 2901, 2960, 2961, 2931, 2968, 2979, 2950, 2967, 2962, 2963, 2914, 2980, + 2937, 2916, 2921, 2928, 2974, 2946, 2904, 2940, 2975, 2936, 2911, 2912, + 2944, 2918, 2959, 2900, 2958, 2927, 2951, 2982, 2899, 2945, 2976, 2930, + 2929, 2925, 2902, 2957, 2934, 2964, 2917, 2954, 2965, 2981, 2909, 2971, + 2978, 2919, 2905, 2933, 2907, 2926, 2969, 2910, 2984, 2986, 2906, 2972, + 2922, 2966, 2943, 2970, 2948, 2955, 2939, 2983, 2938, 2920, 2952, 2923, + 2949, 2977, 2973, 2956, 2941, 2913, 2947, 2903, 2942, 2985, 2908, 2953, + 2932, 2924, 3019, 3036, 3034, 3033, 2997, 3003, 2992, 3040, 3002, 2994, + 3027, 3039, 2996, 3023, 3024, 2987, 3029, 3037, 3031, 3032, 3009, 3006, + 3022, 2990, 2988, 2989, 2995, 3028, 3044, 3017, 3014, 3041, 3030, 3038, + 3008, 3012, 3013, 3010, 3035, 3005, 3011, 3021, 3026, 3007, 3042, 3004, + 3043, 2991, 3001, 3000, 2998, 3015, 3020, 2999, 2993, 3018, 3096, 3116, + 3138, 3134, 3095, 3084, 3097, 3045, 3073, 3047, 3117, 3113, 3070, 3118, + 3088, 3067, 3050, 3046, 3052, 3137, 3115, 3078, 3108, 3076, 3139, 3057, + 3058, 3122, 3089, 3127, 3104, 3131, 3126, 3091, 3133, 3082, 3064, 3114, + 3092, 3060, 3075, 3080, 3111, 3128, 3094, 3142, 3085, 3110, 3107, 3141, + 3132, 3072, 3143, 3100, 3059, 3130, 3105, 3102, 3054, 3090, 3066, 3077, + 3062, 3056, 3101, 3099, 3135, 3093, 3109, 3112, 3055, 3106, 3086, 3063, + 3140, 3087, 3124, 3121, 3074, 3065, 3069, 3051, 3071, 3053, 3068, 3136, + 3103, 3081, 3079, 3125, 3049, 3048, 3098, 3083, 3061, 3119, 3120, 3129, + 3171, 3255, 3204, 3178, 3205, 3164, 3203, 3209, 3191, 3218, 3254, 3200, + 3234, 3201, 3148, 3247, 3232, 3207, 3239, 3152, 3256, 3154, 3241, 3176, + 3186, 3167, 3173, 3243, 3260, 3202, 3149, 3197, 3249, 3147, 3199, 3144, + 3187, 3181, 3159, 3188, 3183, 3182, 3224, 3180, 3177, 3165, 3210, 3169, + 3157, 3216, 3245, 3244, 3257, 3150, 3231, 3248, 3196, 3175, 3211, 3151, + 3227, 3222, 3217, 3162, 3190, 3179, 3194, 3258, 3226, 3259, 3189, 3213, + 3238, 3155, 3193, 3198, 3250, 3172, 3156, 3212, 3246, 3168, 3192, 3160, + 3195, 3208, 3206, 3146, 3153, 3228, 3252, 3251, 3219, 3230, 3161, 3174, + 3166, 3240, 3185, 3236, 3233, 3158, 3221, 3237, 3214, 3223, 3220, 3235, + 3225, 3184, 3163, 3229, 3253, 3215, 3170, 3242, 3145, 3314, 3392, 3301, + 3288, 3399, 3291, 3355, 3381, 3371, 3341, 3317, 3366, 3386, 3327, 3281, + 3402, 3374, 3319, 3356, 3391, 3283, 3293, 3343, 3333, 3298, 3330, 3334, + 3342, 3373, 3340, 3359, 3382, 3322, 3305, 3275, 3329, 3337, 3299, 3292, + 3320, 3316, 3383, 3375, 3369, 3313, 3321, 3407, 3274, 3396, 3403, 3363, + 3395, 3278, 3380, 3389, 3397, 3400, 3287, 3365, 3385, 3272, 3335, 3376, + 3304, 3302, 3348, 3352, 3271, 3394, 3282, 3415, 3346, 3408, 3303, 3315, + 3361, 3411, 3290, 3264, 3270, 3332, 3280, 3297, 3328, 3276, 3266, 3344, + 3357, 3405, 3318, 3347, 3349, 3364, 3307, 3265, 3351, 3308, 3273, 3263, + 3311, 3367, 3331, 3284, 3362, 3345, 3404, 3323, 3353, 3262, 3269, 3338, + 3416, 3393, 3418, 3417, 3289, 3354, 3384, 3387, 3312, 3379, 3406, 3325, + 3412, 3409, 3410, 3414, 3413, 3279, 3358, 3339, 3368, 3401, 3268, 3398, + 3295, 3306, 3372, 3370, 3326, 3336, 3377, 3378, 3261, 3350, 3360, 3294, + 3286, 3309, 3296, 3300, 3388, 3285, 3310, 3390, 3267, 3277, 3423, 3472, + 3425, 3470, 3450, 3463, 3444, 3427, 3453, 3452, 3432, 3462, 3442, 3438, + 3429, 3460, 3455, 3461, 3458, 3421, 3420, 3440, 3439, 3437, 3465, 3457, + 3466, 3441, 3446, 3443, 3467, 3447, 3454, 3445, 3449, 3419, 3435, 3436, + 3456, 3448, 3471, 3468, 3428, 3426, 3424, 3430, 3451, 3433, 3434, 3431, + 3464, 3422, 3459, 3469, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 23576, 23568, 23589, 23566, 23590, 23577, 23592, 23572, 23563, 23580, + 23578, 23586, 23562, 23570, 23565, 23567, 23573, 23571, 23569, 23582, + 23583, 23574, 23588, 23591, 23587, 23564, 23585, 23584, 23579, 23581, + 23575, 36293, 23601, 23603, 23600, 23599, 23596, 23595, 23598, 23597, + 23604, 23602, 36293, 36293, 36293, 36293, 23594, 23593, 30992, 30989, + 30990, 30991, 30944, 30941, 30942, 30943, 30996, 30993, 30994, 30995, + 30984, 30981, 30982, 30983, 30988, 30985, 30986, 30987, 30980, 30977, + 30978, 30979, 30940, 30937, 30938, 30939, 30972, 30969, 30970, 30971, + 30945, 30950, 30961, 30962, 30973, 30976, 30974, 30975, 30968, 30965, + 30966, 30967, 30956, 30953, 30954, 30955, 31007, 31006, 31005, 30957, + 30964, 31014, 31012, 31009, 30959, 31008, 31010, 30952, 30960, 30949, + 30951, 30948, 30999, 31003, 31011, 30958, 30963, 31001, 30998, 31004, + 30947, 30997, 31013, 30946, 31002, 31000, 31015, 36293, 31022, 31024, + 31021, 31020, 31017, 31016, 31019, 31018, 31025, 31023, 36293, 36293, + 36293, 36293, 36293, 36293, 3533, 3538, 3554, 3556, 3548, 3544, 3536, + 3530, 3537, 3550, 3545, 3541, 3552, 3535, 3531, 3553, 3540, 3551, 3555, + 3549, 3543, 3557, 3542, 3558, 3546, 3547, 3539, 3534, 3532, 3559, 36293, + 36293, 3526, 3528, 3529, 3527, 3525, 3560, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 26035, 26036, 26041, 26042, + 26029, 26030, 26045, 26046, 26037, 26038, 26027, 26028, 26047, 26048, + 26031, 26032, 26043, 26044, 26049, 26050, 26039, 26040, 26033, 26034, + 26051, 26052, 26025, 26026, 25971, 25962, 25968, 25959, 25964, 25970, + 25963, 25967, 25973, 25957, 25969, 25955, 25960, 25958, 25966, 25961, + 25965, 25974, 25972, 25956, 25979, 25978, 25976, 25975, 25977, 25981, + 25980, 26011, 26012, 25990, 26010, 26008, 26016, 26018, 26017, 26019, + 26009, 26001, 26014, 25999, 26021, 25994, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 26059, 26061, 26058, 26057, + 26054, 26053, 26056, 26055, 26062, 26060, 36293, 25986, 25983, 25985, + 25988, 25982, 25984, 25987, 36293, 26013, 26020, 25998, 26006, 26022, + 25997, 26004, 26015, 26003, 26024, 26005, 26000, 26007, 26023, 26002, + 25996, 25989, 25992, 25993, 25995, 25991, 36293, 36293, 36293, 36293, + 36293, 25943, 25950, 25942, 25941, 25951, 25939, 25936, 25954, 25946, + 25944, 25952, 25938, 25937, 25947, 25953, 25949, 25945, 25940, 25948, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 17663, 17660, 17665, 17659, + 17648, 17647, 17644, 17643, 17636, 17642, 17641, 17646, 17645, 17637, + 17633, 17632, 17629, 17628, 17635, 17634, 17631, 17630, 17638, 17650, + 17649, 17640, 17639, 17655, 17658, 17656, 17654, 17657, 17652, 17651, + 17653, 17666, 17672, 17669, 17670, 17671, 17667, 17673, 17668, 17664, + 17662, 17661, 17675, 17674, 17682, 17684, 17681, 17680, 17677, 17676, + 17679, 17678, 17685, 17683, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 22178, 22182, 22185, 22186, 22156, 22188, 22164, 22179, + 22183, 22174, 22173, 22175, 22163, 22155, 22176, 22172, 22169, 22170, + 22184, 22166, 22177, 22180, 22162, 22160, 22187, 22171, 22168, 22158, + 22181, 22167, 22157, 22165, 22236, 22240, 22243, 22244, 22214, 22246, + 22222, 22237, 22241, 22232, 22231, 22233, 22221, 22213, 22234, 22230, + 22227, 22228, 22242, 22224, 22235, 22238, 22220, 22218, 22245, 22229, + 22226, 22216, 22239, 22225, 22215, 22223, 22200, 22194, 22192, 22190, + 22197, 22196, 22199, 22198, 22202, 22201, 22205, 22207, 22204, 22203, + 22208, 22209, 22211, 22212, 22206, 22210, 22195, 22193, 22191, 22189, + 22249, 22247, 22248, 36293, 36293, 36293, 36293, 36293, 3747, 3764, 3749, + 3753, 3766, 3754, 3761, 3771, 3750, 3762, 3767, 3760, 3756, 3755, 3757, + 3768, 3769, 3751, 3752, 3759, 3758, 3763, 3770, 3765, 3748, 36293, 36293, + 3772, 3789, 3774, 3778, 3791, 3779, 3786, 3796, 3775, 3787, 3792, 3785, + 3781, 3780, 3782, 3793, 3794, 3776, 3777, 3784, 3783, 3788, 3795, 3790, + 3773, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 22798, 22724, 22786, 22797, 22802, + 22801, 22721, 22803, 22778, 22777, 22775, 22732, 22781, 22782, 22774, + 22731, 22740, 22748, 22784, 22720, 22745, 22744, 22739, 22738, 22737, + 22736, 22762, 22730, 22761, 22729, 22804, 22735, 22785, 22796, 22795, + 22743, 22742, 22719, 22800, 22806, 22734, 22733, 22771, 22727, 22747, + 22746, 22770, 22726, 22779, 22783, 22755, 22758, 22759, 22793, 22791, + 22772, 22728, 22780, 22760, 22794, 22792, 22790, 22788, 22718, 22789, + 22787, 22805, 22722, 22799, 22723, 22757, 22725, 22776, 22773, 22756, + 36293, 36293, 36293, 36293, 22810, 22741, 22809, 22808, 22807, 22815, + 22821, 22820, 22816, 22817, 22842, 22846, 22863, 22862, 22824, 22827, + 22828, 22844, 22831, 22832, 22833, 22834, 22835, 22838, 22840, 22841, + 22837, 22848, 22849, 22850, 22851, 22856, 22852, 22853, 22857, 22859, + 22818, 22819, 22826, 22861, 22825, 22860, 22822, 22830, 22823, 22847, + 22864, 22865, 22854, 22858, 22845, 22843, 22866, 22839, 22829, 22836, + 22855, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 22814, 22812, + 22813, 22811, 22763, 22764, 22765, 22766, 22767, 22768, 22769, 22749, + 22750, 22751, 22752, 22753, 22754, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 31909, + 24888, 25108, 25107, 17627, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 34209, 34208, 6631, 6632, 34735, + 34736, 34737, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 31026, 31027, 31028, 31029, 31030, 31031, 31032, 31033, 31034, + 31035, 31036, 31037, 31038, 31039, 31040, 31041, 31042, 31043, 31044, + 31045, 31046, 31047, 31048, 31049, 31050, 31051, 31052, 31053, 31054, + 31055, 31056, 31057, 31058, 31059, 31060, 31061, 31062, 31063, 31064, + 31065, 31066, 31067, 31068, 31069, 31070, 31071, 31072, 31073, 31074, + 31075, 31076, 31077, 31078, 31079, 31080, 31081, 31082, 31083, 31084, + 31085, 31086, 31087, 31088, 31089, 31090, 31091, 31092, 31093, 31094, + 31095, 31096, 31097, 31098, 31099, 31100, 31101, 31102, 31103, 31104, + 31105, 31106, 31107, 31108, 31109, 31110, 31111, 31112, 31113, 31114, + 31115, 31116, 31117, 31118, 31119, 31120, 31121, 31122, 31123, 31124, + 31125, 31126, 31127, 31128, 31129, 31130, 31131, 31132, 31133, 31134, + 31135, 31136, 31137, 31138, 31139, 31140, 31141, 31142, 31143, 31144, + 31145, 31146, 31147, 31148, 31149, 31150, 31151, 31152, 31153, 31154, + 31155, 31156, 31157, 31158, 31159, 31160, 31161, 31162, 31163, 31164, + 31165, 31166, 31167, 31168, 31169, 31170, 31171, 31172, 31173, 31174, + 31175, 31176, 31177, 31178, 31179, 31180, 31181, 31182, 31183, 31184, + 31185, 31186, 31187, 31188, 31189, 31190, 31191, 31192, 31193, 31194, + 31195, 31196, 31197, 31198, 31199, 31200, 31201, 31202, 31203, 31204, + 31205, 31206, 31207, 31208, 31209, 31210, 31211, 31212, 31213, 31214, + 31215, 31216, 31217, 31218, 31219, 31220, 31221, 31222, 31223, 31224, + 31225, 31226, 31227, 31228, 31229, 31230, 31231, 31232, 31233, 31234, + 31235, 31236, 31237, 31238, 31239, 31240, 31241, 31242, 31243, 31244, + 31245, 31246, 31247, 31248, 31249, 31250, 31251, 31252, 31253, 31254, + 31255, 31256, 31257, 31258, 31259, 31260, 31261, 31262, 31263, 31264, + 31265, 31266, 31267, 31268, 31269, 31270, 31271, 31272, 31273, 31274, + 31275, 31276, 31277, 31278, 31279, 31280, 31281, 31282, 31283, 31284, + 31285, 31286, 31287, 31288, 31289, 31290, 31291, 31292, 31293, 31294, + 31295, 31296, 31297, 31298, 31299, 31300, 31301, 31302, 31303, 31304, + 31305, 31306, 31307, 31308, 31309, 31310, 31311, 31312, 31313, 31314, + 31315, 31316, 31317, 31318, 31319, 31320, 31321, 31322, 31323, 31324, + 31325, 31326, 31327, 31328, 31329, 31330, 31331, 31332, 31333, 31334, + 31335, 31336, 31337, 31338, 31339, 31340, 31341, 31342, 31343, 31344, + 31345, 31346, 31347, 31348, 31349, 31350, 31351, 31352, 31353, 31354, + 31355, 31356, 31357, 31358, 31359, 31360, 31361, 31362, 31363, 31364, + 31365, 31366, 31367, 31368, 31369, 31370, 31371, 31372, 31373, 31374, + 31375, 31376, 31377, 31378, 31379, 31380, 31381, 31382, 31383, 31384, + 31385, 31386, 31387, 31388, 31389, 31390, 31391, 31392, 31393, 31394, + 31395, 31396, 31397, 31398, 31399, 31400, 31401, 31402, 31403, 31404, + 31405, 31406, 31407, 31408, 31409, 31410, 31411, 31412, 31413, 31414, + 31415, 31416, 31417, 31418, 31419, 31420, 31421, 31422, 31423, 31424, + 31425, 31426, 31427, 31428, 31429, 31430, 31431, 31432, 31433, 31434, + 31435, 31436, 31437, 31438, 31439, 31440, 31441, 31442, 31443, 31444, + 31445, 31446, 31447, 31448, 31449, 31450, 31451, 31452, 31453, 31454, + 31455, 31456, 31457, 31458, 31459, 31460, 31461, 31462, 31463, 31464, + 31465, 31466, 31467, 31468, 31469, 31470, 31471, 31472, 31473, 31474, + 31475, 31476, 31477, 31478, 31479, 31480, 31481, 31482, 31483, 31484, + 31485, 31486, 31487, 31488, 31489, 31490, 31491, 31492, 31493, 31494, + 31495, 31496, 31497, 31498, 31499, 31500, 31501, 31502, 31503, 31504, + 31505, 31506, 31507, 31508, 31509, 31510, 31511, 31512, 31513, 31514, + 31515, 31516, 31517, 31518, 31519, 31520, 31521, 31522, 31523, 31524, + 31525, 31526, 31527, 31528, 31529, 31530, 31531, 31532, 31533, 31534, + 31535, 31536, 31537, 31538, 31539, 31540, 31541, 31542, 31543, 31544, + 31545, 31546, 31547, 31548, 31549, 31550, 31551, 31552, 31553, 31554, + 31555, 31556, 31557, 31558, 31559, 31560, 31561, 31562, 31563, 31564, + 31565, 31566, 31567, 31568, 31569, 31570, 31571, 31572, 31573, 31574, + 31575, 31576, 31577, 31578, 31579, 31580, 31581, 31582, 31583, 31584, + 31585, 31586, 31587, 31588, 31589, 31590, 31591, 31592, 31593, 31594, + 31595, 31596, 31597, 31598, 31599, 31600, 31601, 31602, 31603, 31604, + 31605, 31606, 31607, 31608, 31609, 31610, 31611, 31612, 31613, 31614, + 31615, 31616, 31617, 31618, 31619, 31620, 31621, 31622, 31623, 31624, + 31625, 31626, 31627, 31628, 31629, 31630, 31631, 31632, 31633, 31634, + 31635, 31636, 31637, 31638, 31639, 31640, 31641, 31642, 31643, 31644, + 31645, 31646, 31647, 31648, 31649, 31650, 31651, 31652, 31653, 31654, + 31655, 31656, 31657, 31658, 31659, 31660, 31661, 31662, 31663, 31664, + 31665, 31666, 31667, 31668, 31669, 31670, 31671, 31672, 31673, 31674, + 31675, 31676, 31677, 31678, 31679, 31680, 31681, 31682, 31683, 31684, + 31685, 31686, 31687, 31688, 31689, 31690, 31691, 31692, 31693, 31694, + 31695, 31696, 31697, 31698, 31699, 31700, 31701, 31702, 31703, 31704, + 31705, 31706, 31707, 31708, 31709, 31710, 31711, 31712, 31713, 31714, + 31715, 31716, 31717, 31718, 31719, 31720, 31721, 31722, 31723, 31724, + 31725, 31726, 31727, 31728, 31729, 31730, 31731, 31732, 31733, 31734, + 31735, 31736, 31737, 31738, 31739, 31740, 31741, 31742, 31743, 31744, + 31745, 31746, 31747, 31748, 31749, 31750, 31751, 31752, 31753, 31754, + 31755, 31756, 31757, 31758, 31759, 31760, 31761, 31762, 31763, 31764, + 31765, 31766, 31767, 31768, 31769, 31770, 31771, 31772, 31773, 31774, + 31775, 31776, 31777, 31778, 31779, 31780, 31781, 31782, 31783, 31784, + 31785, 31786, 31787, 31788, 31789, 31790, 31791, 31792, 31793, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 31794, 31795, 31796, + 31797, 31798, 31799, 31800, 31801, 31802, 31803, 31804, 31805, 31806, + 31807, 31808, 31809, 31810, 31811, 31812, 31813, 31814, 31815, 31816, + 31817, 31818, 31819, 31820, 31821, 31822, 31823, 31824, 31825, 31826, + 31827, 31828, 31829, 31830, 31831, 31832, 31833, 31834, 31835, 31836, + 31837, 31838, 31839, 31840, 31841, 31842, 31843, 31844, 31845, 31846, + 31847, 31848, 31849, 31850, 31851, 31852, 31853, 31854, 31855, 31856, + 31857, 31858, 31859, 31860, 31861, 31862, 31863, 31864, 31865, 31866, + 31867, 31868, 31869, 31870, 31871, 31872, 31873, 31874, 31875, 31876, + 31877, 31878, 31879, 31880, 31881, 31882, 31883, 31884, 31885, 31886, + 31887, 31888, 31889, 31890, 31891, 31892, 31893, 31894, 31895, 31896, + 31897, 31898, 31899, 31900, 31901, 31902, 31903, 31904, 31905, 31906, + 31907, 31908, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 16483, 16484, 16485, 16486, 16487, + 16488, 16489, 16490, 16491, 16492, 16493, 16494, 16495, 16496, 16497, + 16498, 16499, 16500, 16501, 16502, 16503, 16504, 16505, 16506, 16507, + 16508, 16509, 16510, 16511, 16512, 16513, 16514, 16515, 16516, 16517, + 16518, 16519, 16520, 16521, 16522, 16523, 16524, 16525, 16526, 16527, + 16528, 16529, 16530, 16531, 16481, 16482, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 16945, 16946, 16947, 16948, 36293, 16949, 16950, 16938, 16939, + 16940, 16941, 16942, 36293, 16943, 16944, 36293, 16926, 15833, 15471, + 15472, 15473, 15470, 15752, 15753, 15754, 15755, 15744, 15745, 15746, + 15747, 15748, 15739, 15740, 15741, 15742, 15743, 15749, 15750, 15751, + 15510, 15514, 15515, 15516, 15517, 15518, 15519, 15520, 15521, 15511, + 15512, 15513, 15532, 15533, 15534, 15535, 15536, 15537, 15538, 15539, + 15540, 15541, 15542, 15543, 15544, 15545, 15546, 15526, 15527, 15528, + 15529, 15530, 15531, 15523, 15524, 15525, 15522, 15641, 15642, 15643, + 15644, 15645, 15646, 15647, 15648, 15635, 15636, 15637, 15638, 15639, + 15640, 15649, 15650, 15651, 15652, 15653, 15654, 15655, 15656, 15657, + 15658, 15659, 15660, 15661, 15662, 15663, 15664, 15665, 15666, 15667, + 15668, 15697, 15698, 15699, 15700, 15690, 15691, 15692, 15693, 15694, + 15695, 15696, 15686, 15687, 15688, 15689, 15685, 15669, 15670, 15671, + 15672, 15673, 15674, 15675, 15676, 15677, 15679, 15680, 15681, 15682, + 15683, 15684, 15678, 15589, 15590, 15591, 15592, 15593, 15594, 15595, + 15596, 15597, 15582, 15583, 15584, 15585, 15586, 15587, 15588, 15581, + 15603, 15604, 15605, 15575, 15576, 15577, 15578, 15579, 15580, 15574, + 15598, 15599, 15600, 15601, 15602, 15482, 15485, 15486, 15487, 15488, + 15489, 15490, 15491, 15492, 15483, 15484, 15503, 15504, 15505, 15506, + 15507, 15508, 15509, 15493, 15494, 15495, 15496, 15497, 15498, 15499, + 15500, 15501, 15502, 15474, 15475, 15476, 15477, 15478, 15479, 15480, + 15481, 15556, 15557, 15558, 15559, 15560, 15561, 15562, 15563, 15564, + 15565, 15566, 15567, 15568, 15569, 15570, 15571, 15572, 15573, 15548, + 15549, 15547, 15550, 15551, 15552, 15553, 15554, 15555, 15723, 15724, + 15725, 15726, 15727, 15722, 15734, 15735, 15736, 15737, 15728, 15729, + 15730, 15731, 15732, 15733, 15627, 15628, 15629, 15630, 15620, 15621, + 15622, 15623, 15624, 15625, 15626, 15614, 15615, 15616, 15617, 15618, + 15619, 15631, 15632, 15633, 15634, 15608, 15609, 15610, 15611, 15612, + 15613, 15701, 15702, 15703, 15704, 15705, 15706, 15707, 15708, 15709, + 15710, 15718, 15719, 15720, 15721, 15711, 15712, 15713, 15714, 15715, + 15716, 15717, 15606, 15607, 15832, 16924, 16923, 16925, 15829, 16914, + 16913, 16915, 16921, 16922, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 15843, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 15836, 15835, 15837, 36293, 36293, 16975, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 16979, 16978, 16980, 16986, 16962, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 11020, + 11018, 10967, 11000, 10927, 10940, 10944, 11025, 10921, 11008, 10929, + 10971, 10970, 10922, 10928, 10942, 10974, 11003, 10996, 10923, 10943, + 10997, 11021, 10947, 10975, 10948, 10953, 10931, 10976, 10949, 10954, + 10934, 10977, 10951, 10956, 10932, 10933, 10985, 10986, 10952, 10957, + 10938, 10989, 10950, 10955, 10935, 10978, 10939, 10936, 10937, 10983, + 10984, 10981, 10982, 11002, 11001, 11010, 11016, 11013, 10988, 10987, + 10941, 10930, 10979, 10980, 10919, 10994, 10964, 10962, 10920, 11022, + 10924, 11023, 10999, 11007, 10925, 10991, 10972, 10990, 10945, 11024, + 11004, 10926, 11019, 11005, 10946, 10973, 11006, 10998, 10963, 10966, + 10965, 11015, 11011, 11017, 11014, 11012, 10961, 10960, 10959, 10958, + 10969, 10968, 10992, 10995, 10993, 11009, 36293, 36293, 36293, 36293, + 36293, 10904, 10917, 10916, 10911, 10918, 10898, 10891, 10890, 10887, + 10889, 10892, 10893, 10888, 36293, 36293, 36293, 10900, 10896, 10899, + 10894, 10903, 10902, 10895, 10901, 10897, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 10905, 10909, 10912, 10907, 10915, 10914, 10908, + 10913, 10910, 10906, 36293, 36293, 11029, 11026, 11027, 11028, 27903, + 27902, 27904, 27905, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 33122, 27089, 19424, 27086, 10794, + 20457, 27057, 20517, 971, 15969, 34178, 19381, 22873, 27042, 19417, + 27079, 24962, 26632, 26824, 15964, 34151, 20397, 20396, 20395, 20394, + 20392, 20393, 4633, 4634, 4642, 4656, 4526, 4525, 27633, 27641, 27634, + 27645, 27638, 27642, 27635, 27647, 27640, 27644, 27637, 27646, 27639, + 27643, 27636, 33161, 33129, 33131, 33216, 33178, 33174, 33210, 33180, + 20543, 20489, 20510, 20545, 20492, 20535, 20537, 20516, 29176, 29177, + 25694, 10342, 10077, 10076, 29188, 29189, 19430, 27066, 12999, 13000, + 355, 354, 361, 360, 363, 362, 358, 359, 356, 357, 19420, 33114, 27082, + 10800, 32784, 32780, 32788, 4488, 4486, 4492, 19413, 33109, 27076, 10796, + 23657, 19423, 33117, 27085, 10803, 12163, 12164, 3990, 3993, 3992, 3991, + 4024, 19436, 33107, 27072, 10806, 19437, 33108, 27073, 10807, 19426, + 33111, 27088, 10798, 29424, 29425, 29423, 29422, 29616, 29618, 29617, + 29615, 34162, 15947, 34576, 34577, 33031, 29253, 29252, 29251, 29207, + 16347, 19294, 16348, 34167, 15945, 19431, 27067, 19432, 27068, 12984, + 19422, 33116, 27084, 10802, 15968, 34177, 34155, 19425, 27087, 19419, + 27081, 19421, 27083, 19328, 26998, 33170, 33206, 33169, 33205, 20478, + 20499, 20477, 20498, 20475, 20496, 20476, 20497, 33173, 33209, 20488, + 20509, 33171, 33207, 20487, 20508, 33164, 33200, 20482, 20503, 33167, + 33203, 20485, 20506, 33168, 33204, 20486, 20507, 33163, 33199, 20481, + 20502, 33165, 33201, 20483, 20504, 33166, 33202, 20484, 20505, 33172, + 33208, 20479, 20500, 25872, 25873, 25874, 25875, 25876, 25877, 25878, + 25879, 25880, 25881, 25882, 25883, 25884, 25885, 25886, 25887, 25888, + 25889, 25890, 25891, 25892, 25893, 25894, 25895, 25896, 25897, 25908, + 25910, 25907, 25906, 25903, 25902, 25905, 25904, 25911, 25909, 28957, + 13001, 24872, 36293, 36293, 36293, 4285, 4229, 4100, 4315, 4186, 4127, + 4286, 4167, 4230, 4276, 4202, 4261, 4143, 4158, 4246, 4112, 4319, 4187, + 4217, 4128, 4287, 4168, 4231, 4101, 4282, 4210, 4269, 4151, 4308, 4164, + 4254, 4120, 4195, 4223, 4136, 4294, 4176, 4239, 4106, 4277, 4203, 4262, + 4144, 4301, 4159, 4247, 4113, 4320, 4188, 4218, 4129, 4288, 4169, 4232, + 4214, 4273, 4155, 4312, 4183, 4258, 4124, 4327, 4199, 4226, 4140, 4298, + 4180, 4243, 4109, 4207, 4266, 4148, 4305, 4251, 4117, 4324, 4192, 4133, + 4291, 4173, 4236, 4283, 4211, 4270, 4152, 4309, 4165, 4255, 4121, 4316, + 4196, 4224, 4137, 4295, 4177, 4240, 4107, 4278, 4204, 4263, 4145, 4302, + 4160, 4248, 4114, 4321, 4189, 4219, 4130, 4289, 4170, 4233, 4102, 4216, + 4275, 4157, 4314, 4185, 4260, 4126, 4329, 4201, 4228, 4142, 4300, 4182, + 4245, 4111, 4281, 4209, 4268, 4150, 4307, 4163, 4253, 4119, 4326, 4194, + 4222, 4135, 4293, 4175, 4238, 4105, 4213, 4272, 4154, 4311, 4257, 4123, + 4318, 4198, 4139, 4297, 4179, 4242, 4279, 4206, 4265, 4147, 4304, 4161, + 4250, 4116, 4323, 4191, 4220, 4132, 4290, 4172, 4235, 4103, 4215, 4274, + 4156, 4313, 4184, 4259, 4125, 4328, 4200, 4227, 4141, 4299, 4181, 4244, + 4110, 4280, 4208, 4267, 4149, 4306, 4162, 4252, 4118, 4325, 4193, 4221, + 4134, 4292, 4174, 4237, 4104, 4284, 4212, 4271, 4153, 4310, 4166, 4256, + 4122, 4317, 4197, 4225, 4138, 4296, 4178, 4241, 4108, 4205, 4264, 4146, + 4303, 4249, 4115, 4322, 4190, 4131, 4171, 4234, 32792, 4495, 32789, 4493, + 32790, 4494, 32785, 4489, 32786, 4490, 32779, 4482, 4483, 4484, 4485, + 23541, 32781, 32782, 10797, 19414, 28927, 33112, 10799, 12869, 12870, + 12871, 26993, 20448, 12872, 33136, 20450, 15320, 34641, 32803, 13157, + 4527, 4524, 19333, 27003, 19331, 27001, 15944, 19329, 26999, 15943, + 20451, 33139, 34168, 4652, 4650, 4651, 4649, 17858, 17857, 17862, 17856, + 17834, 17813, 17814, 17854, 17820, 17838, 17861, 17836, 17859, 17860, + 17842, 17839, 17819, 17818, 17821, 17837, 17822, 17810, 17831, 17855, + 17811, 17812, 17809, 17835, 17840, 17826, 17817, 17841, 17843, 17816, + 17833, 17825, 17823, 17824, 17815, 17863, 17832, 17827, 17830, 17828, + 17829, 17851, 17849, 17850, 17853, 17848, 17845, 17852, 17847, 17846, + 17844, 27648, 27680, 27649, 27696, 27665, 27681, 27650, 27704, 27673, + 27689, 27658, 27697, 27666, 27682, 27651, 27708, 27677, 27693, 27662, + 27701, 27670, 27686, 27655, 27705, 27674, 27690, 27659, 27698, 27667, + 27683, 27652, 27710, 27679, 27695, 27664, 27703, 27672, 27688, 27657, + 27707, 27676, 27692, 27661, 27700, 27669, 27685, 27654, 27709, 27678, + 27694, 27663, 27702, 27671, 27687, 27656, 27706, 27675, 27691, 27660, + 27699, 27668, 27684, 27653, 33156, 33128, 33130, 33195, 33177, 33175, + 33176, 33179, 20542, 20540, 20541, 20544, 20494, 20534, 20536, 20530, + 27004, 27045, 19384, 19334, 20453, 20550, 33219, 33141, 19335, 19385, + 27046, 27005, 33142, 33220, 20551, 20454, 15970, 17236, 25377, 4030, + 36293, 36293, 36293, 36293, 36293, 36293, 13037, 25921, 32865, 1061, + 6625, 29612, 15465, 16373, 12989, 22715, 26256, 34204, 12157, 16372, + 12864, 26761, 32257, 22360, 13015, 2617, 3640, 372, 19674, 36293, 292, + 286, 317, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 29413, + 29414, 29415, 13256, 13253, 13245, 13251, 13257, 13243, 13249, 13246, + 13252, 13248, 13244, 13254, 13250, 13255, 13247, 13258, 22272, 19556, + 19567, 19566, 19570, 19571, 27612, 27614, 27613, 22139, 22140, 22138, + 965, 15999, 36293, 36293, 36109, 36114, 36148, 36111, 36116, 36144, + 36138, 36132, 36155, 36134, 36128, 36152, 36110, 36115, 36149, 36112, + 36117, 36145, 36139, 36133, 36156, 36135, 36129, 36153, 36150, 36136, + 36143, 36130, 36131, 36154, 36137, 36113, 36159, 36124, 36141, 36151, + 36162, 36161, 36127, 36160, 36121, 36120, 36158, 36142, 36140, 36119, + 36293, 36293, 36164, 36165, 36166, 36157, 36107, 36122, 36125, 36126, + 36104, 36105, 36123, 36146, 36147, 36108, 36163, 36106, 36118, 36103, + 36285, 36286, 36283, 36284, 36287, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36183, 36184, 36200, 36172, 36181, 36280, + 36235, 36236, 36203, 36204, 36237, 36167, 36201, 36281, 36179, 36176, + 36178, 36177, 36175, 36277, 36276, 36279, 36278, 36273, 36272, 36275, + 36274, 36173, 36207, 36169, 36180, 36168, 36205, 36218, 36219, 36217, + 36216, 36170, 36214, 36215, 36213, 36211, 36212, 36210, 36209, 36220, + 36222, 36223, 36221, 36185, 36208, 36174, 36182, 36282, 36224, 36229, + 36226, 36230, 36227, 36232, 36233, 36228, 36225, 36231, 36206, 36234, + 36267, 36264, 36255, 36265, 36266, 36256, 36244, 36243, 36271, 36241, + 36240, 36238, 36242, 36239, 36258, 36263, 36257, 36261, 36262, 36259, + 36260, 36187, 36191, 36190, 36189, 36188, 36270, 36268, 36269, 36194, + 36199, 36198, 36197, 36196, 36195, 36245, 36254, 36247, 36252, 36246, + 36250, 36251, 36248, 36249, 36253, 36186, 36193, 36171, 36192, 36202, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 5343, 5215, 5336, 5318, 5319, 5387, 5388, 5268, 5365, 5325, 5399, 5400, + 5291, 5170, 5221, 5368, 5269, 5173, 5174, 5363, 5375, 5314, 5251, 5342, + 5194, 5391, 5263, 5277, 5273, 5366, 5328, 5357, 5321, 5390, 5176, 5178, + 5278, 5344, 5329, 5386, 5168, 5346, 5360, 5362, 5316, 5370, 5298, 5216, + 5378, 5369, 5288, 5169, 5228, 5259, 5380, 5266, 5334, 5338, 5281, 5192, + 5345, 5323, 5326, 5265, 5403, 5333, 5282, 5381, 5358, 5257, 5264, 5315, + 5320, 5332, 5284, 5331, 5289, 5335, 5272, 5276, 5402, 5175, 5171, 5401, + 5290, 5224, 5195, 5313, 5389, 5330, 5339, 5322, 5167, 5299, 5327, 5324, + 5220, 5292, 5166, 5382, 5223, 5361, 5364, 5193, 5222, 5347, 5404, 5384, + 5340, 5379, 5383, 5337, 5385, 5341, 5254, 5180, 5219, 5317, 5372, 5373, + 5371, 5374, 5267, 5217, 5392, 5393, 5356, 5280, 5213, 5285, 5286, 5287, + 5177, 5179, 5212, 5377, 5367, 5283, 5293, 5297, 5296, 5295, 5294, 5253, + 5250, 5249, 5207, 5209, 5210, 5208, 5376, 5181, 5261, 5200, 5164, 5158, + 5159, 5162, 5163, 5161, 5160, 5165, 5306, 5301, 5302, 5300, 5311, 5310, + 5309, 5308, 5312, 5304, 5262, 5172, 5227, 5226, 5225, 5307, 5305, 5303, + 5255, 5256, 5218, 5260, 5258, 5229, 5236, 5232, 5240, 5235, 5244, 5234, + 5233, 5230, 5231, 5238, 5239, 5246, 5243, 5241, 5190, 5191, 5189, 5237, + 5245, 5398, 5203, 5201, 5204, 5206, 5205, 5202, 5394, 5396, 5395, 5397, + 5247, 5248, 5197, 5196, 5198, 5199, 5352, 5355, 5353, 5354, 5348, 5351, + 5349, 5350, 5211, 5214, 5359, 5188, 5182, 5187, 5185, 5184, 5183, 5186, + 5271, 5275, 5270, 5274, 5279, 5252, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 23911, 23754, 23779, 23889, 23735, + 23910, 23832, 23896, 23888, 23736, 23732, 23906, 23725, 23885, 23886, + 23887, 23772, 23773, 23675, 23679, 23671, 23670, 23854, 23960, 23936, + 23787, 23781, 23912, 23913, 23788, 23792, 23796, 23794, 23676, 23767, + 23771, 23770, 23758, 23759, 23711, 23721, 23840, 23752, 23757, 23786, + 23785, 23845, 23844, 23909, 23908, 23879, 23880, 23724, 23729, 23869, + 23868, 23884, 23883, 23841, 23965, 23811, 23882, 23766, 23915, 23938, + 23917, 23849, 23963, 23871, 23731, 23918, 23919, 23946, 23947, 23950, + 23951, 23948, 23949, 23942, 23943, 23944, 23945, 23838, 23839, 23952, + 23953, 23870, 23961, 23846, 23843, 23682, 23683, 23674, 23964, 23810, + 23881, 23765, 23914, 23937, 23916, 23848, 23708, 23705, 23714, 23715, + 23716, 23774, 23775, 23776, 23686, 23694, 23695, 23696, 23697, 23698, + 23668, 23763, 23669, 23764, 23667, 23761, 23666, 23760, 23684, 23707, + 23719, 23706, 23687, 23688, 23685, 23722, 23663, 23665, 23693, 23723, + 23702, 23712, 23690, 23691, 23713, 23897, 23922, 23968, 23878, 23834, + 23789, 23727, 23737, 23800, 23799, 23941, 23956, 23967, 23957, 23958, + 23857, 23860, 23861, 23862, 23863, 23864, 23865, 23866, 23867, 23858, + 23859, 23812, 23842, 23762, 23739, 23692, 23720, 23703, 23704, 23873, + 23872, 23805, 23804, 23803, 23966, 23733, 23734, 23833, 23828, 23672, + 23900, 23902, 23835, 23837, 23903, 23905, 23790, 23791, 23830, 23829, + 23673, 23901, 23836, 23904, 23934, 23933, 23935, 23932, 23928, 23929, + 23930, 23931, 23726, 23801, 23802, 23921, 23962, 23875, 23681, 23898, + 23680, 23939, 23876, 23877, 23899, 23940, 23874, 23823, 23818, 23822, + 23826, 23825, 23824, 23819, 23820, 23816, 23817, 23821, 23924, 23827, + 23806, 23850, 23890, 23891, 23809, 23808, 23852, 23851, 23895, 23894, + 23893, 23892, 23750, 23746, 23745, 23749, 23748, 23751, 23744, 23747, + 23831, 14171, 14159, 14182, 14183, 14165, 14184, 14185, 14186, 14187, + 14172, 14173, 14174, 14175, 14176, 14177, 14178, 14179, 14180, 14181, + 14160, 14161, 14162, 14163, 14164, 14166, 14167, 14168, 14169, 14170, + 13891, 13899, 13912, 13920, 13926, 13927, 13892, 13893, 13894, 13895, + 13896, 13897, 13898, 13900, 13901, 13902, 13903, 13904, 13905, 13906, + 13907, 13908, 13909, 13910, 13911, 13913, 13914, 13915, 13916, 13917, + 13918, 13919, 13921, 13922, 13923, 13924, 13925, 7429, 7428, 7430, 13951, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 23699, 23700, 23701, 23959, 23780, 23853, 23784, 23782, 23783, 23807, + 23907, 23717, 23718, 23777, 23778, 23689, 23955, 23923, 23815, 23925, + 23847, 23728, 23738, 23741, 23740, 23743, 23742, 23954, 23756, 23920, + 23753, 23813, 23814, 23730, 23926, 23855, 23856, 23793, 23755, 23795, + 23677, 23798, 23797, 23769, 23768, 23678, 23927, 23664, 23709, 23710, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 17216, 17217, 17214, 17212, 17203, 17202, 17209, 17207, + 17198, 17205, 17215, 17200, 17213, 17211, 17204, 17201, 17210, 17208, + 17199, 17206, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 22133, 22134, 22131, 22129, 22120, 22119, + 22126, 22124, 22115, 22122, 22132, 22117, 22130, 22128, 22121, 22118, + 22127, 22125, 22116, 22123, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 23533, 10387, 10388, 10382, + 10381, 10380, 32050, 32070, 32091, 32039, 32084, 32048, 32034, 32093, + 32038, 32052, 32058, 32081, 32082, 32096, 32102, 32049, 32080, 32110, + 32068, 32035, 32098, 32100, 32067, 32113, 32047, 32062, 32059, 32040, + 32054, 32037, 32095, 32088, 32042, 32085, 32074, 32108, 32097, 32071, + 32099, 32087, 32101, 32076, 32064, 32107, 32077, 32063, 32094, 32103, + 32073, 32109, 32046, 32090, 32066, 32112, 32056, 32041, 32078, 32075, + 32089, 32033, 32061, 32060, 32111, 32105, 32083, 32053, 32051, 32057, + 32065, 32104, 32106, 32079, 32045, 32043, 32072, 32036, 32044, 32092, + 32055, 32086, 32069, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 7846, 7844, 7843, 7840, 7839, 7842, 7841, 7847, 7845, 7837, + 7835, 7834, 7831, 7830, 7833, 7832, 7838, 7836, 16058, 16057, 16056, + 16055, 16054, 30520, 30519, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 21112, + 21114, 21118, 21105, 21120, 21150, 21123, 21151, 21125, 21152, 21127, + 21129, 21144, 21146, 21131, 21134, 21153, 21138, 21140, 21108, 21142, + 21154, 21155, 21148, 21156, 21116, 21160, 21162, 21166, 21157, 21168, + 21171, 21173, 21203, 21175, 21204, 21177, 21179, 21197, 21199, 21181, + 21184, 21205, 21188, 21190, 21192, 21195, 21206, 21207, 21201, 21208, + 21164, 21601, 21603, 21607, 21609, 21611, 21641, 21614, 21642, 21616, + 21643, 21618, 21620, 21635, 21637, 21622, 21625, 21644, 21629, 21631, + 21597, 21633, 21645, 21646, 21639, 21647, 21605, 21551, 21553, 21557, + 21544, 21559, 21562, 21564, 36293, 21566, 21592, 21568, 21548, 21586, + 21588, 21570, 21573, 21593, 21577, 21579, 21581, 21584, 21594, 21595, + 21590, 21596, 21555, 21265, 21267, 21271, 21273, 21275, 21305, 21278, + 21306, 21280, 21307, 21282, 21284, 21299, 21301, 21286, 21289, 21308, + 21293, 21295, 21261, 21297, 21309, 21310, 21303, 21311, 21269, 21319, + 21321, 21325, 21327, 21329, 21332, 21334, 21364, 21336, 21365, 21338, + 21340, 21358, 21360, 21342, 21345, 21366, 21349, 21351, 21353, 21356, + 21367, 21368, 21362, 21369, 21323, 22073, 36293, 22074, 22075, 36293, + 36293, 22076, 36293, 36293, 22077, 22078, 36293, 36293, 22079, 22080, + 22081, 22082, 36293, 22083, 22084, 22085, 22086, 22087, 22088, 22089, + 22090, 22091, 22092, 22093, 22094, 36293, 22095, 36293, 22096, 22097, + 22098, 22099, 22100, 22101, 22102, 36293, 22103, 22104, 22105, 22106, + 22107, 22108, 22109, 22110, 22111, 22112, 22113, 21209, 21210, 21211, + 21212, 21213, 21214, 21215, 21216, 21217, 21218, 21219, 21220, 21221, + 21222, 21223, 21224, 21225, 21226, 21227, 21228, 21229, 21230, 21231, + 21232, 21233, 21234, 21235, 21236, 21237, 21238, 21239, 21240, 21241, + 21242, 21243, 21244, 21245, 21246, 21247, 21248, 21249, 21250, 21251, + 21252, 21253, 21254, 21255, 21256, 21257, 21258, 21259, 21260, 21496, + 21497, 36293, 21498, 21499, 21500, 21501, 36293, 36293, 21502, 21503, + 21504, 21505, 21506, 21507, 21508, 21509, 36293, 21510, 21511, 21512, + 21513, 21514, 21515, 21516, 36293, 21517, 21518, 21519, 21520, 21521, + 21522, 21523, 21524, 21525, 21526, 21527, 21528, 21529, 21530, 21531, + 21532, 21533, 21534, 21535, 21536, 21537, 21538, 21539, 21540, 21541, + 21542, 21441, 21442, 36293, 21443, 21444, 21445, 21446, 36293, 21447, + 21448, 21449, 21450, 21451, 36293, 21452, 36293, 36293, 36293, 21453, + 21454, 21455, 21456, 21457, 21458, 21459, 36293, 21460, 21461, 21462, + 21463, 21464, 21465, 21466, 21467, 21468, 21469, 21470, 21471, 21472, + 21473, 21474, 21475, 21476, 21477, 21478, 21479, 21480, 21481, 21482, + 21483, 21484, 21485, 21379, 21380, 21381, 21382, 21383, 21384, 21385, + 21386, 21387, 21388, 21389, 21390, 21391, 21392, 21393, 21394, 21395, + 21396, 21397, 21398, 21399, 21400, 21401, 21402, 21403, 21404, 21405, + 21406, 21407, 21408, 21409, 21410, 21411, 21412, 21413, 21414, 21415, + 21416, 21417, 21418, 21419, 21420, 21421, 21422, 21423, 21424, 21425, + 21426, 21427, 21428, 21429, 21430, 22011, 22012, 22013, 22014, 22015, + 22016, 22017, 22018, 22019, 22020, 22021, 22022, 22023, 22024, 22025, + 22026, 22027, 22028, 22029, 22030, 22031, 22032, 22033, 22034, 22035, + 22036, 22037, 22038, 22039, 22040, 22041, 22042, 22043, 22044, 22045, + 22046, 22047, 22048, 22049, 22050, 22051, 22052, 22053, 22054, 22055, + 22056, 22057, 22058, 22059, 22060, 22061, 22062, 21843, 21845, 21849, + 21851, 21853, 21883, 21856, 21884, 21858, 21885, 21860, 21862, 21877, + 21879, 21864, 21867, 21886, 21871, 21873, 21839, 21875, 21887, 21888, + 21881, 21889, 21847, 21897, 21899, 21903, 21905, 21907, 21910, 21912, + 21942, 21914, 21943, 21916, 21918, 21936, 21938, 21920, 21923, 21944, + 21927, 21929, 21931, 21934, 21945, 21946, 21940, 21947, 21901, 21959, + 21960, 21961, 21962, 21963, 21964, 21965, 21966, 21967, 21968, 21969, + 21970, 21971, 21972, 21973, 21974, 21975, 21976, 21977, 21978, 21979, + 21980, 21981, 21982, 21983, 21984, 21985, 21986, 21987, 21988, 21989, + 21990, 21991, 21992, 21993, 21994, 21995, 21996, 21997, 21998, 21999, + 22000, 22001, 22002, 22003, 22004, 22005, 22006, 22007, 22008, 22009, + 22010, 21733, 21735, 21739, 21741, 21743, 21773, 21746, 21774, 21748, + 21775, 21750, 21752, 21767, 21769, 21754, 21757, 21776, 21761, 21763, + 21729, 21765, 21777, 21778, 21771, 21779, 21737, 21787, 21789, 21793, + 21795, 21797, 21800, 21802, 21832, 21804, 21833, 21806, 21808, 21826, + 21828, 21810, 21813, 21834, 21817, 21819, 21821, 21824, 21835, 21836, + 21830, 21837, 21791, 21656, 21657, 21658, 21659, 21660, 21661, 21662, + 21663, 21664, 21665, 21666, 21667, 21668, 21669, 21670, 21671, 21672, + 21673, 21674, 21675, 21676, 21677, 21678, 21679, 21680, 21681, 21682, + 21683, 21684, 21685, 21686, 21687, 21688, 21689, 21690, 21691, 21692, + 21693, 21694, 21695, 21696, 21697, 21698, 21699, 21700, 21701, 21702, + 21703, 21704, 21705, 21706, 21707, 21545, 21546, 21549, 36293, 21113, + 21115, 21124, 21107, 21121, 21117, 21122, 21109, 21126, 21128, 21130, + 21145, 21147, 21149, 21132, 21137, 21139, 21110, 21141, 21111, 21143, + 21135, 21119, 21136, 21133, 21373, 21161, 21163, 21174, 21159, 21169, + 21165, 21170, 21193, 21176, 21178, 21180, 21198, 21200, 21202, 21182, + 21187, 21189, 21172, 21191, 21194, 21196, 21185, 21167, 21186, 21183, + 21374, 21371, 21378, 21372, 21375, 21377, 21376, 21602, 21604, 21615, + 21610, 21612, 21606, 21613, 21598, 21617, 21619, 21621, 21636, 21638, + 21640, 21623, 21628, 21630, 21599, 21632, 21600, 21634, 21626, 21608, + 21627, 21624, 21650, 21552, 21554, 21565, 21547, 21560, 21556, 21561, + 21582, 21567, 21569, 21550, 21587, 21589, 21591, 21571, 21576, 21578, + 21563, 21580, 21583, 21585, 21574, 21558, 21575, 21572, 21651, 21648, + 21655, 21649, 21652, 21654, 21653, 21266, 21268, 21279, 21274, 21276, + 21270, 21277, 21262, 21281, 21283, 21285, 21300, 21302, 21304, 21287, + 21292, 21294, 21263, 21296, 21264, 21298, 21290, 21272, 21291, 21288, + 21314, 21320, 21322, 21335, 21328, 21330, 21324, 21331, 21354, 21337, + 21339, 21341, 21359, 21361, 21363, 21343, 21348, 21350, 21333, 21352, + 21355, 21357, 21346, 21326, 21347, 21344, 21315, 21312, 21370, 21313, + 21316, 21318, 21317, 21844, 21846, 21857, 21852, 21854, 21848, 21855, + 21840, 21859, 21861, 21863, 21878, 21880, 21882, 21865, 21870, 21872, + 21841, 21874, 21842, 21876, 21868, 21850, 21869, 21866, 21892, 21898, + 21900, 21913, 21906, 21908, 21902, 21909, 21932, 21915, 21917, 21919, + 21937, 21939, 21941, 21921, 21926, 21928, 21911, 21930, 21933, 21935, + 21924, 21904, 21925, 21922, 21893, 21890, 21948, 21891, 21894, 21896, + 21895, 21734, 21736, 21747, 21742, 21744, 21738, 21745, 21730, 21749, + 21751, 21753, 21768, 21770, 21772, 21755, 21760, 21762, 21731, 21764, + 21732, 21766, 21758, 21740, 21759, 21756, 21782, 21788, 21790, 21803, + 21796, 21798, 21792, 21799, 21822, 21805, 21807, 21809, 21827, 21829, + 21831, 21811, 21816, 21818, 21801, 21820, 21823, 21825, 21814, 21794, + 21815, 21812, 21783, 21780, 21838, 21781, 21784, 21786, 21785, 21106, + 21158, 36293, 36293, 21437, 21439, 21436, 21435, 21432, 21431, 21434, + 21433, 21440, 21438, 21492, 21494, 21491, 21490, 21487, 21486, 21489, + 21488, 21495, 21493, 22069, 22071, 22068, 22067, 22064, 22063, 22066, + 22065, 22072, 22070, 21955, 21957, 21954, 21953, 21950, 21949, 21952, + 21951, 21958, 21956, 21714, 21716, 21713, 21712, 21709, 21708, 21711, + 21710, 21717, 21715, 28182, 28138, 28163, 28379, 28334, 28120, 28183, + 28147, 28296, 28248, 28224, 28185, 28188, 28145, 28189, 28139, 28190, + 28212, 28207, 28245, 28186, 28192, 28201, 28202, 28193, 28199, 28203, + 28141, 28275, 28184, 28213, 28142, 28222, 28191, 28221, 28208, 28247, + 28246, 28187, 28206, 28216, 28217, 28220, 28219, 28287, 28195, 28196, + 28197, 28269, 28237, 28200, 28204, 28198, 28194, 28268, 28229, 28267, + 28266, 28226, 28225, 28228, 28218, 28215, 28214, 28264, 28263, 28265, + 28236, 28312, 28316, 28315, 28313, 28314, 28157, 28303, 28333, 28305, + 28318, 28310, 28319, 28311, 28320, 28309, 28167, 28168, 28332, 28373, + 28306, 28307, 28308, 28304, 28330, 28317, 28328, 28321, 28329, 28327, + 28325, 28322, 28323, 28324, 28326, 28154, 28160, 28158, 28159, 28363, + 28362, 28170, 28162, 28173, 28176, 28171, 28174, 28172, 28175, 28180, + 28177, 28137, 28372, 28378, 28375, 28377, 28351, 28353, 28331, 28361, + 28354, 28358, 28352, 28360, 28359, 28357, 28119, 28209, 28144, 28336, + 28122, 28345, 28211, 28210, 28337, 28250, 28253, 28252, 28251, 28260, + 28300, 28149, 28374, 28131, 28256, 28259, 28254, 28255, 28348, 28258, + 28347, 28130, 28129, 28257, 28148, 28346, 28128, 28223, 28143, 28338, + 28355, 28121, 28205, 28140, 28276, 28356, 28132, 28284, 28280, 28282, + 28153, 28376, 28133, 28277, 28279, 28278, 28283, 28281, 28371, 28249, + 28146, 28178, 28365, 28366, 28364, 28166, 28344, 28124, 28123, 28273, + 28349, 28271, 28152, 28261, 28272, 28370, 28270, 28274, 28262, 28150, + 28179, 28169, 28350, 28135, 28136, 28134, 28151, 28155, 28156, 28368, + 28369, 28367, 28335, 28238, 28340, 28241, 28242, 28243, 28240, 28244, + 28239, 28233, 28234, 28235, 28232, 28230, 28161, 28231, 28227, 28164, + 28165, 28342, 28343, 28339, 28341, 28126, 28127, 28125, 28285, 28290, + 28293, 28294, 28295, 28301, 28286, 28288, 28289, 28297, 28292, 28298, + 28299, 28291, 28181, 28302, 28693, 28692, 28691, 28713, 28712, 28711, + 28668, 28667, 28666, 28052, 28051, 28050, 28654, 28653, 28652, 28664, + 28665, 28660, 28663, 28659, 28662, 28661, 28109, 28112, 28108, 28111, + 28110, 28658, 28528, 28529, 28530, 28531, 28526, 28527, 28532, 28572, + 28477, 28590, 28589, 28587, 28588, 28591, 28566, 28569, 28567, 28568, + 28565, 28596, 28595, 28593, 28594, 28542, 28541, 28540, 28546, 28545, + 28544, 28543, 28564, 28563, 28562, 28539, 28538, 28537, 28612, 28611, + 28610, 28586, 28585, 28584, 28709, 28708, 28707, 28706, 28705, 28704, + 28710, 28703, 28702, 28701, 28446, 28445, 28443, 28444, 28450, 28449, + 28447, 28448, 28438, 28437, 28435, 28436, 28442, 28441, 28439, 28440, + 28500, 28499, 28497, 28498, 28501, 28515, 28518, 28516, 28517, 28474, + 28505, 28504, 28503, 28502, 28460, 28473, 28472, 28471, 28461, 28459, + 28458, 28457, 28524, 28523, 28522, 28521, 28520, 28519, 28696, 28695, + 28694, 28699, 28698, 28697, 28700, 28559, 28558, 28556, 28557, 28550, + 28549, 28547, 28548, 28555, 28554, 28577, 28576, 28573, 28578, 28583, + 28580, 28579, 28599, 28598, 28597, 28602, 28601, 28600, 28553, 28561, + 28560, 28649, 28646, 28645, 28592, 28551, 28574, 28581, 28606, 28650, + 28647, 28643, 28552, 28575, 28582, 28607, 28651, 28648, 28644, 28605, + 28604, 28603, 28464, 28463, 28481, 28479, 28480, 28478, 28490, 28488, + 28489, 28487, 28507, 28506, 28638, 28635, 28641, 28466, 28465, 28482, + 28483, 28485, 28484, 28494, 28492, 28493, 28491, 28509, 28508, 28639, + 28636, 28642, 28470, 28469, 28467, 28468, 28462, 28486, 28495, 28510, + 28511, 28512, 28637, 28634, 28640, 28496, 28536, 28534, 28535, 28533, + 28456, 28454, 28452, 28455, 28453, 28451, 28609, 28608, 28514, 28513, + 28571, 28570, 28476, 28475, 28068, 28067, 28063, 28066, 28070, 28069, + 28064, 28065, 28062, 28071, 28381, 28388, 28386, 28385, 28383, 28384, + 28382, 28387, 28101, 28099, 28100, 28077, 28076, 28075, 28060, 28058, + 28059, 28061, 28116, 28115, 28114, 28095, 28096, 28092, 28073, 28072, + 28091, 28093, 28090, 28094, 28074, 28089, 28087, 28088, 28084, 28086, + 28085, 28078, 28080, 28079, 28082, 28081, 28083, 28055, 28054, 28053, + 28678, 28677, 28679, 28098, 28615, 28614, 28616, 28617, 28045, 28047, + 28044, 28046, 28049, 28048, 28410, 28408, 28409, 28415, 28417, 28416, + 28412, 28414, 28413, 28429, 28428, 28427, 28421, 28422, 28423, 28424, + 28425, 28426, 28418, 28420, 28419, 28430, 28431, 28432, 28399, 28397, + 28398, 28411, 28434, 28433, 28686, 28685, 28683, 28684, 28682, 28687, + 28681, 28680, 28670, 28675, 28673, 28674, 28671, 28672, 28676, 28613, + 28525, 28618, 28380, 28097, 28656, 28655, 28118, 28113, 28657, 28689, + 28688, 28690, 28714, 28389, 28390, 28391, 28392, 28393, 28394, 28395, + 28396, 28107, 28407, 28406, 28401, 28404, 28403, 28400, 28402, 28405, + 28057, 28117, 28669, 28056, 28715, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 28102, 28103, 28104, 28105, 28106, 36293, 28626, 28627, 28628, 28629, + 28630, 28631, 28632, 28633, 28619, 28620, 28621, 28622, 28623, 28624, + 28625, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 19558, 19560, 19559, 19561, 19564, 19563, 19565, 19562, 16360, + 16361, 33035, 33036, 7628, 16170, 7629, 16171, 6214, 19549, 19550, 19551, + 19552, 19554, 19553, 19555, 16357, 19568, 19569, 19557, 12932, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 18698, 18994, 18438, 19002, + 18424, 18829, 19125, 18999, 19106, 19069, 18410, 18675, 18676, 19112, + 18405, 18461, 18439, 18821, 18611, 18801, 18673, 19107, 18975, 19075, + 18688, 18612, 18763, 18922, 19076, 18568, 19016, 18606, 18607, 18608, + 19083, 19082, 19133, 18600, 18814, 18864, 18983, 19025, 19066, 18610, + 19074, 18589, 18626, 18683, 18418, 18713, 18729, 18951, 18961, 18432, + 18422, 18980, 19090, 19191, 18465, 18557, 19078, 18578, 18540, 18550, + 17936, 18538, 18537, 18413, 18536, 18704, 18541, 18542, 17937, 18547, + 17938, 18543, 18544, 17939, 18548, 18546, 19110, 17940, 18549, 18533, + 18534, 19228, 18402, 19104, 19052, 19053, 18733, 19048, 18836, 18777, + 18924, 18926, 18937, 18978, 18680, 19049, 18996, 19211, 19004, 18828, + 18212, 18954, 18211, 18953, 18235, 18995, 18210, 18952, 18765, 19050, + 18163, 18885, 17956, 18581, 18280, 19092, 18213, 18955, 18310, 19152, + 18323, 19165, 18238, 19003, 17882, 17979, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 18566, 18565, 18567, 18605, 18965, 19257, 18835, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 23314, 23286, 23287, 19264, 23181, 23161, 23194, 23219, 23249, + 23242, 23316, 23156, 23239, 23329, 23158, 23255, 23272, 23201, 23269, + 23196, 23197, 23208, 23209, 23297, 23298, 23211, 23212, 23177, 23173, + 23178, 23276, 23288, 23306, 23307, 23191, 23247, 23257, 23292, 23222, + 23223, 23192, 23226, 23258, 23281, 23335, 23165, 23232, 23265, 23268, + 23290, 23291, 7383, 7385, 7395, 7389, 7371, 7396, 7403, 36293, 7402, + 7376, 7373, 7372, 7370, 7407, 7391, 7390, 7392, 7406, 7393, 7394, 7378, + 7381, 7405, 7387, 7404, 36293, 36293, 7379, 7382, 7386, 7380, 7398, 7397, + 7399, 36293, 7401, 7377, 36293, 7400, 7375, 7384, 7374, 7388, 36293, + 36293, 36293, 36293, 36293, 23064, 23033, 23061, 23059, 23035, 23057, + 23054, 23055, 23056, 23063, 23040, 23041, 23065, 23044, 23042, 23037, + 23050, 23066, 23039, 23062, 23049, 23058, 23048, 23051, 23036, 23053, + 23034, 23047, 23032, 23060, 23031, 23045, 23043, 10021, 9999, 10019, + 10006, 10002, 10016, 10013, 10014, 10015, 10020, 10004, 10022, 10018, + 10005, 10023, 10003, 10008, 10012, 10017, 10011, 10009, 10010, 10007, + 9998, 10001, 10000, 23038, 23052, 23046, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 7287, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 24918, 24902, 24893, 24904, 24909, 24901, 24906, 24897, + 24923, 24927, 24929, 24932, 24896, 24891, 24926, 24916, 24900, 24899, + 24930, 24892, 24903, 24924, 24912, 24928, 24931, 24898, 24920, 24905, + 24895, 24915, 24894, 24910, 24917, 24919, 24925, 24911, 24907, 24908, + 24933, 24934, 24913, 24914, 24921, 24922, 24935, 36293, 36293, 36293, + 24944, 24948, 24947, 24950, 24949, 24946, 24945, 24941, 24938, 24937, + 24940, 24939, 24942, 24943, 36293, 36293, 24958, 24960, 24957, 24956, + 24953, 24952, 24955, 24954, 24961, 24959, 36293, 36293, 36293, 36293, + 24936, 24951, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 32844, 32827, 32847, 32837, 32841, 32838, 32843, 32829, + 32828, 32846, 32834, 32849, 32848, 32840, 32839, 32845, 32842, 32830, + 32822, 32831, 32823, 32851, 32832, 32824, 32833, 32825, 32850, 32836, + 32826, 32835, 32852, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 34311, 34310, 34342, 34343, 34344, 34346, 34335, 34338, 34324, 34327, + 34339, 34331, 34328, 34345, 34341, 34340, 34348, 34353, 34352, 34351, + 34337, 34316, 34315, 34350, 34349, 34336, 34347, 34319, 34321, 34325, + 34332, 34323, 34330, 34329, 34318, 34313, 34314, 34322, 34317, 34320, + 34312, 34326, 34333, 34334, 34357, 34358, 34355, 34356, 34365, 34367, + 34364, 34363, 34360, 34359, 34362, 34361, 34368, 34366, 36293, 36293, + 36293, 36293, 36293, 34354, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 24294, 24297, 24296, 24298, 24295, 24277, 24281, 24279, + 24278, 24280, 24289, 24292, 24290, 24293, 24291, 24299, 24300, 24301, + 24302, 24303, 24282, 24284, 24287, 24288, 24283, 24286, 24285, 24307, + 24304, 24308, 24306, 24305, 24315, 24317, 24314, 24313, 24310, 24309, + 24312, 24311, 24318, 24316, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 25081, 25084, + 25083, 25082, 25085, 25086, 25063, 25065, 25064, 25066, 25067, 25068, + 25075, 25076, 25080, 25077, 25078, 25079, 25087, 25091, 25088, 25090, + 25089, 25092, 25069, 25074, 25073, 25071, 25070, 25072, 25095, 25093, + 25094, 25103, 25105, 25102, 25101, 25098, 25097, 25100, 25099, 25106, + 25104, 36293, 36293, 36293, 36293, 25096, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 30406, 30415, + 30404, 30413, 30437, 30422, 30435, 30412, 30421, 30407, 30416, 30436, + 30411, 30420, 30429, 30423, 30434, 30410, 30419, 30428, 30408, 30417, + 30438, 30441, 30403, 30440, 30409, 30418, 30439, 30405, 30414, 36293, + 30396, 30430, 30425, 30446, 30424, 30397, 30444, 30432, 30442, 30431, + 30426, 30427, 30433, 30395, 30445, 30443, 30400, 30399, 30398, 30402, + 30401, 30447, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 30448, 30449, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 12518, 12524, 12522, 12519, + 12521, 12520, 12523, 36293, 12473, 12517, 12515, 12514, 36293, 12461, + 12460, 36293, 12472, 12471, 12470, 12457, 12456, 12469, 12468, 12467, + 12466, 12465, 12464, 12459, 12458, 12463, 12462, 36293, 22370, 22371, + 22372, 22438, 22459, 22447, 22411, 22547, 22373, 22374, 22378, 22497, + 22482, 22487, 22410, 22565, 22514, 22436, 22416, 22508, 22377, 22375, + 22376, 22423, 22467, 22520, 22560, 22383, 22379, 22387, 22524, 22466, + 22472, 22499, 22388, 22385, 22384, 22531, 22475, 22536, 22513, 22504, + 22502, 22503, 22566, 22545, 22382, 22397, 22389, 22537, 22481, 22506, + 22441, 22567, 22393, 22394, 22395, 22451, 22443, 22427, 22528, 22479, + 22380, 22386, 22381, 22454, 22551, 22552, 22390, 22391, 22392, 22464, + 22420, 22470, 22437, 22398, 22396, 22399, 22523, 22480, 22529, 22431, + 22543, 22400, 22404, 22408, 22476, 22449, 22517, 22498, 22401, 22405, + 22406, 22448, 22440, 22505, 22458, 22568, 22469, 22407, 22402, 22403, + 22485, 22538, 22546, 22415, 22558, 22409, 22468, 22418, 22515, 22455, + 22493, 22425, 22507, 22457, 22424, 22564, 22413, 22460, 22417, 22456, + 22484, 22511, 22522, 22492, 22527, 22494, 22453, 22473, 22554, 22521, + 22488, 22532, 22561, 22535, 22533, 22557, 22428, 22544, 22434, 22462, + 22419, 22450, 22426, 22474, 22430, 22510, 22429, 22489, 22414, 22555, + 22445, 22540, 22541, 22559, 22530, 22471, 22509, 22501, 22463, 22439, + 22412, 22478, 22486, 22525, 22491, 22421, 22516, 22461, 22477, 22442, + 22444, 22550, 22490, 22496, 22495, 22562, 22483, 22432, 22433, 22519, + 22563, 22512, 22500, 22553, 22556, 22526, 22548, 22452, 22518, 22446, + 22534, 22422, 22549, 22465, 22435, 36293, 36293, 22576, 22574, 22573, + 22570, 22569, 22572, 22571, 22577, 22575, 22365, 22364, 22368, 22366, + 22363, 22367, 22369, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 27, 9, 24, 14, 29, 21, 34, 28, 37, 39, 35, + 40, 41, 10, 30, 32, 18, 15, 31, 42, 13, 25, 36, 23, 12, 20, 33, 19, 38, + 17, 11, 26, 16, 22, 62, 44, 59, 49, 64, 56, 69, 63, 72, 74, 70, 75, 76, + 45, 65, 67, 53, 50, 66, 77, 48, 60, 71, 58, 47, 55, 68, 54, 73, 52, 46, + 61, 51, 57, 85, 86, 79, 84, 43, 78, 83, 82, 36293, 36293, 36293, 36293, + 93, 95, 92, 91, 88, 87, 90, 89, 96, 94, 36293, 36293, 36293, 36293, 81, + 80, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 16243, 16229, 16224, 16204, 16199, 16217, 16212, + 16192, 16207, 16232, 16227, 16222, 16202, 16197, 16218, 16213, 16193, + 16208, 16244, 16230, 16225, 16205, 16200, 16220, 16215, 16195, 16210, + 16245, 16231, 16226, 16206, 16201, 16221, 16216, 16196, 16211, 16233, + 16228, 16223, 16203, 16198, 16219, 16214, 16194, 16209, 16190, 16191, + 16181, 16188, 16189, 16241, 16239, 16238, 16235, 16234, 16237, 16236, + 16242, 16240, 16247, 16183, 16182, 16184, 16246, 16187, 16186, 16185, + 16180, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 25867, 25862, 25857, + 25837, 25832, 25850, 25845, 25825, 25840, 25865, 25860, 25855, 25835, + 25830, 25851, 25846, 25826, 25841, 25868, 25863, 25858, 25838, 25833, + 25853, 25848, 25828, 25843, 25869, 25864, 25859, 25839, 25834, 25854, + 25849, 25829, 25844, 25866, 25861, 25856, 25836, 25831, 25852, 25847, + 25827, 25842, 25824, 25817, 25819, 25809, 25811, 25812, 25814, 25821, + 25820, 25815, 25810, 25813, 25818, 25816, 25823, 25822, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 2317, 2325, 2323, 2221, 36293, 2333, 2321, 2329, 2313, + 2328, 2320, 2269, 2324, 2331, 2296, 2318, 2326, 2297, 2332, 2327, 2295, + 2316, 2315, 2319, 2314, 2220, 2322, 2330, 2191, 2193, 2192, 2194, 36293, + 2233, 2231, 36293, 2228, 36293, 36293, 2227, 36293, 2235, 2230, 2238, + 2232, 2237, 2225, 2240, 2234, 2226, 2239, 36293, 2224, 2223, 2222, 2229, + 36293, 2241, 36293, 2236, 36293, 36293, 36293, 36293, 36293, 36293, 2305, + 36293, 36293, 36293, 36293, 2307, 36293, 2306, 36293, 2310, 36293, 2309, + 2302, 2312, 36293, 2303, 2311, 36293, 2301, 36293, 36293, 2304, 36293, + 2300, 36293, 2308, 36293, 2298, 36293, 2299, 36293, 2287, 2285, 36293, + 2282, 36293, 36293, 2281, 2276, 2289, 2284, 36293, 2286, 2292, 2279, + 2294, 2288, 2280, 2293, 36293, 2278, 2277, 2275, 2283, 36293, 2274, 2290, + 2291, 2272, 36293, 2273, 36293, 2246, 2258, 2256, 2266, 2249, 2268, 2254, + 2248, 2252, 2261, 36293, 2264, 2257, 2263, 2243, 2247, 2259, 2244, 2267, + 2260, 2242, 2253, 2251, 2245, 2250, 2265, 2255, 2262, 36293, 36293, + 36293, 36293, 36293, 2207, 2205, 2216, 36293, 2219, 2203, 2211, 2201, + 2210, 36293, 2214, 2206, 2213, 2196, 2218, 2208, 2197, 2217, 2209, 2195, + 2202, 2200, 2198, 2199, 2215, 2204, 2212, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 2270, 2271, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 20673, 20689, 20704, 20680, 20708, 20707, + 20705, 20685, 20702, 20699, 20678, 20675, 20694, 20691, 20671, 20682, + 20686, 20703, 20700, 20679, 20676, 20695, 20692, 20672, 20683, 20684, + 20701, 20698, 20677, 20674, 20693, 20690, 20670, 20681, 20688, 20687, + 20668, 20711, 20697, 20696, 20709, 20706, 20710, 20669, 36293, 36293, + 36293, 36293, 10641, 10592, 10593, 10594, 10595, 10596, 10597, 10598, + 10599, 10600, 10601, 10602, 10603, 10604, 10605, 10606, 10607, 10608, + 10609, 10610, 10611, 10612, 10613, 10614, 10615, 10616, 10617, 10618, + 10619, 10620, 10621, 10622, 10623, 10624, 10625, 10626, 10627, 10628, + 10629, 10630, 10631, 10632, 10633, 10634, 10635, 10636, 10637, 10638, + 10639, 10640, 10691, 10642, 10643, 10644, 10645, 10646, 10647, 10648, + 10649, 10650, 10651, 10652, 10653, 10654, 10655, 10656, 10657, 10658, + 10659, 10660, 10661, 10662, 10663, 10664, 10665, 10666, 10667, 10668, + 10669, 10670, 10671, 10672, 10673, 10674, 10675, 10676, 10677, 10678, + 10679, 10680, 10681, 10682, 10683, 10684, 10685, 10686, 10687, 10688, + 10689, 10690, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 26530, 26600, 26575, 26571, 26534, 26539, + 26559, 26555, 26551, 26604, 26567, 26608, 26543, 26563, 26547, 36293, + 36293, 26601, 26576, 26572, 26535, 26540, 26560, 26556, 26552, 26605, + 26568, 26609, 26544, 26564, 26548, 26531, 36293, 26602, 26577, 26573, + 26536, 26541, 26561, 26557, 26553, 26606, 26569, 26610, 26545, 26565, + 26549, 26529, 36293, 26599, 26574, 26570, 26533, 26538, 26558, 26554, + 26550, 26603, 26566, 26607, 26542, 26562, 26546, 26532, 26537, 26581, + 26578, 26592, 26593, 26594, 26595, 26596, 26597, 26598, 26582, 26583, + 26584, 26585, 26586, 26587, 26588, 26589, 26590, 26591, 26579, 26580, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 10376, 10375, 10360, 10372, 10369, 10354, 10351, 10366, 10363, 10378, + 10357, 10417, 10396, 6968, 6684, 6709, 26197, 26198, 26199, 26200, 26201, + 26202, 26203, 26204, 26205, 26206, 26207, 26208, 26209, 26210, 26211, + 26212, 26213, 26214, 26215, 26216, 26217, 26218, 26219, 26220, 26221, + 26222, 32820, 6799, 6800, 6696, 6967, 7823, 29514, 29515, 29516, 29517, + 29518, 29519, 29520, 29521, 29522, 29523, 29524, 29525, 29526, 29527, + 29528, 29529, 29530, 29531, 29532, 29533, 29534, 29535, 29536, 29537, + 29538, 29539, 29508, 29544, 29559, 29560, 29549, 29571, 24407, 24408, + 24409, 24410, 24411, 24412, 24413, 24414, 24415, 24416, 24417, 24418, + 24419, 24420, 24421, 24422, 24423, 24424, 24425, 24426, 24427, 24428, + 24429, 24430, 24431, 24432, 26809, 26810, 26811, 6695, 6694, 6742, 24438, + 24439, 24440, 24441, 24442, 24443, 24444, 24445, 24446, 24447, 24448, + 24449, 24450, 24451, 24452, 24453, 24454, 24455, 24456, 24457, 24458, + 24459, 24460, 24461, 24462, 24463, 7869, 24470, 24473, 24474, 24469, + 24471, 29240, 29497, 29496, 29503, 29572, 29545, 29546, 29548, 29558, + 29566, 29569, 29561, 29551, 29563, 29501, 29565, 29502, 29552, 29562, + 29554, 29547, 29513, 29507, 29506, 29505, 29542, 29553, 29567, 29568, + 21103, 32769, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 26839, 26840, 26841, + 26842, 26843, 26844, 26845, 26846, 26847, 26848, 26849, 26850, 26851, + 26852, 26853, 26854, 26855, 26856, 26857, 26858, 26859, 26860, 26861, + 26862, 26863, 26864, 29281, 29509, 29511, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 29475, + 29470, 29462, 29510, 29456, 29468, 29491, 29467, 29455, 29480, 29488, + 29479, 29460, 29471, 29472, 29478, 29459, 29489, 29486, 29493, 29469, + 29464, 29483, 29473, 29476, 29453, 29454, 29495, 29466, 29457, 29461, + 29477, 29492, 29474, 29487, 29490, 29463, 29484, 29482, 29481, 29485, + 29458, 29465, 29494, 36293, 36293, 36293, 36293, 32817, 32811, 32812, + 32814, 32818, 32815, 32819, 32813, 32816, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 6747, 6745, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 27279, + 27280, 27277, 27281, 27276, 27278, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 10026, + 13005, 7178, 24718, 29747, 29746, 6978, 29792, 26802, 5079, 34459, 34284, + 22881, 11042, 11040, 11041, 13541, 24522, 34371, 12970, 34372, 13048, + 34370, 17880, 34369, 7859, 24521, 12969, 17879, 13047, 29671, 13542, + 27887, 32255, 3976, 34622, 34626, 34623, 34624, 7191, 7190, 7189, 7188, + 13004, 34690, 15977, 31913, 5156, 6627, 27617, 12896, 10052, 26065, 6274, + 15974, 32989, 6624, 27267, 15933, 29793, 4390, 11036, 11037, 15757, + 13024, 20955, 12937, 19285, 23656, 32770, 2629, 13654, 22362, 34462, + 30936, 19677, 3518, 26514, 26836, 14194, 26333, 26330, 6626, 29611, + 14644, 28873, 22152, 26650, 26960, 26961, 7657, 9452, 29599, 29172, 5077, + 13038, 27283, 10035, 25924, 29833, 13046, 12976, 28969, 27831, 16009, + 10788, 7656, 6666, 6148, 20558, 9455, 15939, 27906, 3744, 26648, 7655, + 13010, 31915, 27581, 34692, 7195, 32902, 3632, 7137, 2693, 13011, 4514, + 26638, 26951, 34712, 3905, 16376, 6667, 12942, 12966, 12965, 2836, 26255, + 7636, 30935, 7870, 26513, 16381, 6210, 34689, 23539, 27586, 13579, 15225, + 4516, 22880, 26903, 23662, 29620, 19676, 7648, 3622, 3623, 12959, 98, + 6208, 12949, 27225, 12974, 22870, 23561, 6669, 15224, 2608, 32795, 6976, + 32662, 7133, 26362, 34206, 10422, 28879, 3904, 13237, 4519, 12993, 23970, + 23643, 27580, 14210, 23661, 32907, 34211, 23969, 27408, 32030, 28854, + 3524, 6628, 28963, 27409, 29831, 29203, 32904, 15972, 375, 27286, 29836, + 34480, 13578, 26792, 26793, 7861, 34285, 12980, 16011, 30024, 28960, + 5414, 3628, 5155, 15984, 6977, 10079, 7134, 10161, 10162, 24388, 29597, + 15983, 15982, 25920, 16378, 12861, 15985, 3513, 2626, 15978, 20440, 7651, + 27585, 10078, 12933, 16374, 16377, 12860, 34588, 4029, 34468, 34467, + 27268, 4045, 17702, 2704, 4523, 373, 12253, 12254, 12255, 12256, 12257, + 26817, 23556, 25926, 34460, 7850, 32560, 19573, 26819, 6216, 10878, 7873, + 34645, 28958, 28956, 15971, 26822, 13546, 27912, 23536, 27266, 6635, + 10528, 26505, 4701, 12222, 24982, 29197, 5092, 970, 15938, 17704, 12973, + 32903, 4391, 33014, 15193, 2692, 13042, 3906, 26334, 17699, 26660, 10880, + 2702, 10590, 23558, 7851, 32561, 26820, 6217, 10879, 29202, 15973, 23537, + 10589, 26507, 13045, 14642, 34711, 3627, 26102, 26506, 26323, 6634, + 12893, 12891, 11035, 24871, 23559, 32771, 34633, 34545, 34571, 34595, + 12977, 34469, 25922, 32288, 32289, 7132, 25575, 7875, 34702, 12892, + 24713, 30021, 16478, 10886, 17694, 3910, 34700, 26765, 14648, 26655, + 20949, 2623, 15828, 34701, 34699, 13009, 5151, 5150, 4699, 13440, 20862, + 34697, 12941, 20868, 33029, 33030, 26635, 34698, 5080, 26347, 20865, + 20866, 25552, 25550, 2691, 7639, 26717, 16384, 16383, 14510, 2694, 12880, + 353, 16138, 28856, 16256, 14209, 10034, 20333, 24319, 12928, 14515, 3522, + 30019, 26510, 17691, 20439, 27205, 13241, 17686, 4515, 7849, 34478, 3629, + 5086, 33023, 29173, 14207, 15227, 4393, 14196, 34739, 26764, 15226, + 26946, 15228, 10338, 12210, 968, 4698, 28868, 7200, 29198, 10882, 10039, + 26508, 12987, 10508, 29186, 32263, 34556, 15994, 23358, 9450, 15256, + 7858, 3515, 3517, 3516, 3514, 23357, 6445, 27610, 26357, 5081, 22883, + 12994, 25586, 11033, 12955, 25573, 25931, 25930, 5411, 31916, 6153, 6444, + 6446, 3520, 7138, 26767, 27274, 26325, 29609, 32872, 4404, 19675, 24869, + 24870, 7184, 25567, 14195, 4392, 25590, 4405, 24390, 27607, 22717, 31921, + 25933, 12940, 27493, 26768, 6451, 25871, 16371, 26324, 12894, 16172, + 12291, 7181, 7182, 25577, 25576, 26644, 26641, 24707, 22897, 22898, + 34202, 22899, 24788, 972, 5412, 5413, 34205, 31928, 26795, 34207, 12958, + 26639, 26731, 33017, 7168, 7169, 7165, 981, 20441, 15823, 29181, 29180, + 29182, 29183, 3621, 12208, 19418, 27080, 20391, 7183, 17220, 20388, + 25580, 3635, 3637, 4403, 20331, 26797, 2696, 12286, 25556, 29019, 32810, + 24787, 17235, 16259, 16260, 16263, 16262, 16261, 12962, 12209, 34715, + 14638, 24887, 15986, 26519, 22869, 31927, 7880, 28850, 16382, 32874, + 4056, 34606, 17870, 17797, 17805, 17798, 28885, 28884, 33115, 10801, + 33119, 10795, 20512, 33211, 6692, 7867, 7866, 24862, 24864, 29908, 34569, + 15272, 6282, 25555, 10873, 17218, 23545, 29929, 22578, 4517, 7149, 7159, + 7161, 7145, 7143, 7153, 7151, 7141, 7147, 7155, 7139, 7157, 7150, 7160, + 7162, 7146, 7144, 7154, 7152, 7142, 7148, 7156, 7140, 7158, 27027, 27028, + 27029, 5146, 5147, 27213, 4402, 6147, 20952, 4058, 24786, 15937, 20863, + 28871, 10036, 29193, 29194, 16479, 20867, 19338, 31922, 27007, 34628, + 4071, 31926, 7135, 2697, 29581, 12290, 13003, 26337, 20330, 4026, 20473, + 20458, 20470, 20472, 20493, 19398, 33005, 26807, 26931, 26939, 26940, + 26945, 26944, 26808, 34546, 28041, 28040, 28037, 28036, 4004, 4031, + 28043, 28042, 28039, 28038, 4074, 3970, 3983, 10163, 17222, 32279, 26714, + 26661, 3986, 34560, 28970, 31910, 34695, 25564, 33018, 32275, 32855, + 25376, 15191, 27591, 26715, 12939, 25587, 10514, 10515, 10516, 13034, + 13036, 13035, 3982, 13007, 25574, 6154, 6155, 12956, 12258, 12259, 12260, + 24866, 24867, 24868, 12269, 12262, 12263, 10513, 25929, 25934, 34474, + 29196, 29195, 10164, 22884, 22135, 25914, 7167, 6145, 16174, 10053, 7631, + 25549, 27224, 25932, 29607, 10033, 20332, 29184, 32271, 32270, 32272, + 32273, 19366, 27030, 33033, 32277, 19383, 27044, 19295, 26964, 23542, + 19700, 19699, 2841, 2847, 2842, 2846, 2839, 19697, 2840, 34706, 23555, + 32854, 29594, 28853, 23560, 14199, 14202, 12918, 28944, 28946, 28945, + 28947, 28943, 28942, 34693, 28948, 12898, 26902, 28941, 28951, 28954, + 24519, 12873, 33072, 12901, 26335, 7637, 7638, 17687, 12929, 17688, + 17689, 12915, 12916, 12917, 10424, 34707, 969, 26653, 7879, 26359, 12923, + 10423, 13044, 966, 12945, 34476, 28870, 32661, 14204, 20557, 12906, + 15993, 12908, 12899, 2616, 12995, 28869, 10509, 12926, 12903, 14203, + 6218, 28940, 28939, 6219, 17690, 26652, 7878, 34475, 28875, 28874, 33223, + 12922, 12911, 12905, 26356, 27618, 15230, 29179, 15190, 26354, 26353, + 26350, 26351, 24831, 29075, 24804, 29062, 33003, 33012, 33002, 33011, + 24830, 29074, 24803, 29061, 15308, 15301, 15305, 15298, 24832, 29076, + 24805, 29063, 15309, 15302, 15306, 15299, 15935, 15936, 29015, 29016, + 19543, 33257, 27167, 10868, 27601, 15303, 19679, 15280, 15235, 29834, + 27487, 27488, 27489, 15325, 27490, 15292, 34192, 34189, 6447, 26912, + 27223, 15469, 29598, 26800, 15826, 15827, 32863, 22714, 19686, 29595, + 32858, 32859, 5149, 25561, 32900, 5152, 22885, 376, 12963, 26633, 25560, + 31914, 25559, 2625, 25557, 26835, 10058, 2607, 32856, 23535, 23552, + 29832, 23553, 160, 27886, 27282, 29185, 15963, 34183, 7640, 26634, 32871, + 10874, 24784, 28955, 24789, 26766, 10872, 26646, 24793, 3900, 24782, + 3899, 23554, 26366, 24785, 6630, 22579, 34703, 26907, 2695, 32853, 34458, + 27911, 3619, 3620, 26265, 9454, 2708, 19339, 32868, 26729, 6801, 4700, + 13441, 7848, 28867, 27889, 3639, 3801, 26524, 24981, 27888, 29622, 25935, + 15931, 15996, 12223, 17706, 19701, 36293, 36293, 34696, 26528, 34482, + 27206, 14639, 27882, 25014, 23550, 26799, 23547, 33113, 33110, 33118, + 28882, 24839, 227, 228, 36293, 36293, 36293, 27492, 25558, 10349, 26261, + 27589, 23548, 6150, 28872, 12998, 28859, 2627, 26503, 27226, 36293, + 36293, 36293, 300, 245, 349, 348, 345, 239, 237, 238, 235, 236, 338, 340, + 341, 327, 293, 252, 283, 284, 285, 267, 314, 289, 342, 343, 312, 313, + 272, 329, 278, 279, 261, 305, 258, 280, 325, 259, 260, 257, 315, 323, + 344, 335, 281, 240, 324, 316, 322, 339, 303, 304, 302, 306, 307, 308, + 232, 233, 288, 318, 242, 309, 310, 243, 248, 332, 333, 301, 249, 250, + 251, 234, 291, 328, 334, 273, 346, 294, 256, 337, 255, 331, 254, 336, + 319, 282, 330, 347, 276, 244, 296, 253, 295, 241, 320, 321, 326, 299, + 270, 268, 269, 298, 297, 262, 263, 264, 265, 266, 231, 246, 247, 311, + 277, 290, 271, 287, 275, 274, 20437, 24983, 20560, 34200, 2620, 15998, + 26257, 15220, 20737, 13576, 26786, 25593, 3997, 4075, 4037, 3971, 4061, + 22253, 4399, 15322, 34193, 12877, 34524, 27275, 4069, 4062, 19694, 22279, + 4400, 15319, 34194, 12878, 34607, 34609, 29429, 4067, 4085, 4019, 34540, + 34541, 10337, 4068, 4086, 4020, 34578, 32260, 19696, 22280, 4401, 34198, + 34195, 12879, 32258, 19689, 22270, 4395, 15293, 34190, 12874, 19682, + 22259, 4398, 15268, 34188, 12876, 19690, 22269, 4396, 15297, 34191, + 12875, 19680, 22277, 4397, 15262, 34187, 19692, 22274, 32278, 22273, + 19684, 22258, 13026, 22257, 26913, 19681, 15267, 22268, 15296, 28848, + 22276, 15260, 34186, 15258, 19691, 15315, 15314, 6962, 24433, 6972, + 24434, 24716, 3914, 5144, 36293, 36293, 36293, 36293, 17804, 17872, + 17800, 17868, 17795, 17871, 17799, 17806, 17873, 17801, 17869, 17796, + 36293, 36293, 36293, 36293, 15265, 6678, 10707, 6687, 19332, 27002, + 32860, 34537, 15965, 34152, 34610, 34611, 34613, 20471, 20495, 26949, + 19462, 33233, 27120, 10819, 19469, 33230, 27127, 10816, 19456, 33229, + 27117, 10815, 36293, 36293, 36293, 36293, 19461, 33232, 27119, 10818, + 19471, 33234, 27129, 10820, 15276, 15317, 15290, 15253, 15275, 15316, + 15289, 15252, 19506, 33267, 27181, 10839, 19505, 33266, 27180, 10838, + 19504, 33263, 27179, 10835, 19508, 33269, 27183, 10841, 19507, 33268, + 27182, 10840, 19537, 33244, 27146, 10855, 19545, 33259, 27169, 10870, + 19547, 33255, 27203, 10866, 19496, 33253, 27160, 10864, 19497, 33254, + 27161, 10865, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 19546, 33258, 27170, 10869, 24837, 24810, 29068, 29081, 19358, 33100, + 36293, 36293, 36293, 36293, 36293, 36293, 34648, 34663, 34653, 34658, + 34673, 34668, 34678, 34683, 34650, 34665, 34655, 34660, 34675, 34670, + 34680, 34685, 34649, 34664, 34654, 34659, 34674, 34669, 34679, 34684, + 34646, 34661, 34651, 34656, 34671, 34666, 34676, 34681, 34647, 34662, + 34652, 34657, 34672, 34667, 34677, 34682, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 19512, 33273, 27187, 10846, 19527, 33283, + 27202, 10851, 19470, 33231, 27128, 10817, 15231, 15234, 15233, 15232, + 19480, 27135, 19516, 27172, 19538, 27166, 19542, 27162, 19479, 27134, + 19536, 27145, 34486, 34485, 36293, 36293, 2603, 2600, 27115, 10830, + 24464, 24465, 24472, 24466, 24829, 24801, 29060, 29073, 36293, 36293, + 36293, 36293, 19476, 27106, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 20428, 20432, + 20433, 27896, 20424, 27893, 20426, 20427, 20416, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 6690, 6691, 6689, 19322, 19320, + 19321, 19323, 19319, 10808, 10810, 10809, 10811, 26511, 34561, 5088, + 26512, 36102, 23359, 12919, 24714, 32261, 12902, 27284, 15995, 28716, + 5410, 26816, 19433, 27069, 14649, 14645, 16375, 12900, 7192, 24389, + 27228, 10883, 20618, 12927, 28959, 12910, 14201, 14200, 12921, 27713, + 28949, 12907, 27909, 26662, 5076, 26100, 27721, 26716, 20864, 23546, + 27914, 26344, 16532, 12951, 22900, 34714, 34461, 14647, 10504, 34688, + 10884, 7136, 33015, 29201, 13545, 27217, 12972, 27616, 32262, 4696, + 21026, 9449, 17703, 28972, 13002, 7874, 2685, 9456, 2703, 26647, 6213, + 2706, 14197, 27725, 29621, 12158, 13540, 26331, 17692, 26101, 11030, + 13014, 30518, 6665, 4518, 9442, 7196, 5087, 26522, 26712, 9458, 27491, + 6149, 19286, 20953, 23540, 2707, 28950, 34738, 28952, 12912, 12925, + 25913, 13040, 24717, 10428, 12930, 12914, 27582, 17701, 13575, 15932, + 12981, 7857, 20385, 27587, 32991, 33086, 11045, 11031, 3562, 27830, + 25925, 13031, 5154, 10332, 13574, 20386, 26948, 27913, 29574, 13442, + 36096, 15822, 27577, 30022, 7860, 16818, 20624, 26328, 15934, 26260, + 26794, 20556, 23544, 22872, 2705, 29835, 20861, 10875, 28880, 25870, + 25592, 28858, 12986, 25919, 3630, 3911, 27609, 14211, 26730, 12249, + 12250, 12252, 12251, 4702, 19678, 13008, 32772, 29828, 29829, 27420, + 11038, 23549, 20950, 22153, 22154, 6450, 9444, 27423, 3800, 13236, 25566, + 12938, 34309, 5153, 22114, 16010, 5090, 32899, 29596, 17696, 10331, + 12904, 101, 6629, 25551, 3626, 26352, 26346, 26355, 26345, 20628, 12943, + 33846, 22703, 12247, 13438, 36288, 5074, 25591, 3903, 27584, 13543, 7854, + 28967, 26837, 12967, 16535, 32114, 26365, 11032, 7634, 2688, 12964, + 32774, 5083, 20627, 20559, 20436, 29200, 2849, 27421, 31920, 5089, 3523, + 27227, 3521, 29204, 26823, 24391, 24496, 24507, 24510, 24499, 24489, + 24504, 34499, 3939, 24490, 34496, 34512, 34515, 34490, 34504, 34509, + 3936, 3952, 3955, 3930, 3944, 3949, 24497, 24508, 24511, 24500, 24495, + 24505, 34500, 3940, 24491, 34518, 34521, 34522, 34517, 34519, 34520, + 3958, 3961, 3962, 3957, 3959, 3960, 24514, 24517, 24518, 24513, 24515, + 24516, 34501, 3941, 24492, 34497, 34513, 34516, 34491, 34502, 34510, + 3937, 3953, 3956, 3931, 3942, 3950, 24498, 24509, 24512, 24501, 24493, + 24506, 34503, 3943, 24494, 34492, 3932, 24502, 34493, 3933, 24503, 34506, + 34507, 34505, 3946, 3947, 3945, 34494, 34488, 3934, 3928, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 34730, 34733, 34729, 34731, + 34728, 34727, 34732, 34723, 34726, 34722, 34724, 34721, 34720, 34725, + 36293, 36293, 2850, 25565, 5082, 27907, 32264, 19693, 14198, 26516, + 10881, 99, 29601, 34719, 7877, 36293, 36293, 36293, 36010, 17695, 26109, + 4406, 20626, 26517, 24486, 20956, 12996, 15192, 32901, 22716, 12321, + 24712, 32864, 27910, 27212, 6285, 26821, 2690, 10507, 3519, 22879, 1, + 20414, 7853, 6211, 27590, 17705, 15988, 22895, 34691, 26630, 27718, + 17697, 5157, 23557, 32773, 15222, 26525, 27222, 22896, 16016, 20442, + 14643, 13006, 14512, 17305, 12997, 34708, 3633, 7194, 26649, 34710, + 12946, 20438, 7827, 12261, 24487, 16007, 16477, 34694, 19284, 13577, 961, + 20561, 26367, 26664, 26663, 26349, 12960, 36293, 14514, 36293, 36293, + 36293, 23538, 25594, 23543, 10692, 4394, 3636, 25553, 12982, 30934, + 13030, 31919, 26651, 3631, 16476, 13443, 26332, 27265, 26504, 36293, + 29199, 22361, 27425, 12909, 12913, 12924, 10702, 3908, 5091, 27881, + 12920, 10427, 7856, 36293, 36293, 36293, 12954, 14646, 27159, 19495, + 26066, 26067, 16179, 15229, 19541, 27165, 19515, 27171, 36293, 36293, + 36293, 36293, 36293, 4330, 4360, 4331, 4375, 4346, 4364, 4332, 4383, + 4353, 4361, 4339, 4376, 4347, 4365, 4333, 4387, 4357, 4372, 4343, 4380, + 4369, 4336, 4384, 4354, 4362, 4340, 4377, 4348, 4366, 4334, 4389, 4359, + 4374, 4345, 4382, 4352, 4371, 4338, 4386, 4356, 4342, 4379, 4350, 4368, + 4335, 4388, 4358, 4373, 4344, 4381, 4351, 4370, 4337, 4385, 4355, 4363, + 4341, 4378, 4349, 4367, 20459, 20460, 20467, 20469, 20464, 20527, 20528, + 20524, 20526, 20522, 20525, 20518, 20521, 20519, 20523, 20520, 20463, + 20466, 20461, 20465, 20462, 20468, 33183, 33184, 33191, 33193, 33188, + 33153, 33154, 33150, 33152, 33148, 33151, 33144, 33147, 33145, 33149, + 33146, 33187, 33190, 33185, 33189, 33186, 33192, 33126, 19287, 33123, + 19292, 19379, 33222, 27052, 20553, 34171, 34172, 34173, 34174, 34175, + 34176, 15949, 15950, 15951, 15952, 15953, 15954, 19288, 19293, 26963, + 26962, 33125, 15948, 33181, 33218, 33133, 33221, 33217, 27013, 27048, + 26990, 27047, 27024, 19337, 27006, 33140, 20452, 16354, 33135, 33137, + 36293, 19336, 6448, 16350, 15269, 33158, 33213, 33124, 19289, 33159, + 33214, 20514, 20490, 4602, 4606, 4594, 4600, 4603, 4608, 4595, 4597, + 4605, 4607, 4609, 4604, 4598, 4599, 4625, 4635, 2606, 16351, 19330, + 27000, 16352, 19449, 27103, 10825, 33226, 19327, 26997, 34283, 27015, + 24436, 24435, 24437, 34564, 19382, 22874, 27043, 24467, 29602, 29603, + 29605, 29606, 29604, 34635, 34536, 26812, 4051, 19389, 19344, 4601, 4622, + 4617, 4596, 4612, 4611, 4619, 4610, 4615, 4621, 4592, 4616, 4613, 4623, + 4593, 4618, 32798, 27009, 4512, 19403, 33132, 20538, 22875, 22876, 32797, + 27008, 4511, 19402, 32807, 4498, 4505, 32799, 27626, 27628, 27625, 27624, + 27621, 27620, 27623, 27622, 27629, 27627, 229, 36293, 36293, 36293, + 36293, 36293, 36293, 17707, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 30115, 30044, 30107, 30116, 30032, 30105, + 30026, 30025, 30102, 30110, 30027, 30106, 30030, 30047, 30118, 30114, + 30039, 30041, 30038, 30037, 30034, 30033, 30036, 30035, 30042, 30040, + 30031, 30113, 30100, 30043, 30046, 30108, 30029, 30048, 30049, 30050, + 30051, 30052, 30053, 30054, 30055, 30056, 30057, 30058, 30059, 30060, + 30061, 30062, 30063, 30064, 30065, 30066, 30067, 30068, 30069, 30070, + 30071, 30072, 30073, 30103, 30112, 30111, 30028, 30104, 30045, 30074, + 30075, 30076, 30077, 30078, 30079, 30080, 30081, 30082, 30083, 30084, + 30085, 30086, 30087, 30088, 30089, 30090, 30091, 30092, 30093, 30094, + 30095, 30096, 30097, 30098, 30099, 30101, 30119, 30109, 30117, 6144, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 33668, 33679, + 33690, 33702, 33713, 33724, 33735, 33746, 33757, 33765, 33766, 33767, + 33768, 33770, 33771, 33772, 33773, 33774, 33775, 33776, 33777, 33778, + 33779, 33781, 33782, 33783, 33784, 33785, 33786, 33787, 33788, 33789, + 33790, 33792, 33793, 33794, 33795, 33796, 33797, 33798, 33799, 33800, + 33801, 33803, 33804, 33805, 33806, 33807, 33808, 33809, 33810, 33811, + 33812, 33814, 33815, 33816, 33817, 33818, 33819, 33820, 33821, 33822, + 33823, 33825, 33826, 33827, 33828, 33829, 33830, 33831, 33832, 33833, + 33834, 33836, 33837, 33838, 33839, 33840, 33841, 33842, 33843, 33844, + 33845, 33592, 33593, 33594, 33595, 33596, 33597, 33598, 33599, 33600, + 33601, 33603, 33604, 33605, 33606, 33607, 33608, 33609, 33610, 33611, + 33612, 33614, 33615, 33616, 33617, 33618, 33619, 33620, 33621, 33622, + 33623, 33625, 33626, 33627, 33628, 33629, 33630, 33631, 33632, 33633, + 33634, 33636, 33637, 33638, 33639, 33640, 33641, 33642, 33643, 33644, + 33645, 33647, 33648, 33649, 33650, 33651, 33652, 33653, 33654, 33655, + 33656, 33658, 33659, 33660, 33661, 33662, 33663, 33664, 33665, 33666, + 33667, 33669, 33670, 33671, 33672, 33673, 33674, 33675, 33676, 33677, + 33678, 33680, 33681, 33682, 33683, 33684, 33685, 33686, 33687, 33688, + 33689, 33691, 33692, 33693, 33694, 33695, 33696, 33697, 33698, 33699, + 33700, 33703, 33704, 33705, 33706, 33707, 33708, 33709, 33710, 33711, + 33712, 33714, 33715, 33716, 33717, 33718, 33719, 33720, 33721, 33722, + 33723, 33725, 33726, 33727, 33728, 33729, 33730, 33731, 33732, 33733, + 33734, 33736, 33737, 33738, 33739, 33740, 33741, 33742, 33743, 33744, + 33745, 33747, 33748, 33749, 33750, 33751, 33752, 33753, 33754, 33755, + 33756, 33758, 33759, 33760, 33761, 33762, 33763, 33764, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 24890, 24889, 29592, 29168, 29593, 29624, + 12284, 12859, 12282, 12295, 12288, 12287, 3, 2, 352, 3634, 2700, 5407, + 6440, 15959, 15990, 30023, 19774, 24607, 12285, 20625, 24964, 12293, + 19776, 34180, 34287, 13016, 13166, 6212, 7855, 27883, 20390, 28965, + 27884, 20389, 27917, 10044, 11034, 10330, 10045, 10329, 10046, 10328, + 10047, 10326, 10048, 24475, 24393, 29928, 29927, 12283, 12858, 6142, + 5415, 12281, 12294, 12248, 29655, 29625, 12331, 12330, 16251, 12957, + 13164, 16252, 14205, 14511, 16253, 26834, 27418, 16254, 33083, 33289, + 29170, 10060, 10057, 25928, 25927, 15825, 15989, 5075, 5406, 24781, + 24395, 16178, 16177, 24709, 24715, 29589, 29577, 12280, 12334, 6442, + 15961, 15992, 6441, 15960, 15991, 19777, 34181, 34288, 26251, 26250, + 26631, 26252, 26253, 26611, 26914, 26921, 26950, 28729, 28730, 29575, + 28728, 28731, 29576, 10327, 10049, 26720, 26721, 26769, 26719, 26722, + 26770, 27716, 29623, 6143, 10029, 22704, 24219, 29588, 29591, 29171, + 12279, 12277, 12897, 29590, 29169, 28723, 30020, 28722, 27608, 7649, + 10028, 29614, 29578, 25584, 25808, 26718, 26771, 1060, 1067, 24394, + 27916, 18044, 18718, 10027, 2388, 366, 30006, 16832, 17710, 17711, 17753, + 17719, 32367, 14911, 14912, 14889, 14910, 13160, 13161, 13162, 24217, + 13163, 29680, 36291, 36290, 36292, 20621, 27220, 20619, 27218, 26326, + 20622, 27221, 24963, 24218, 34717, 20620, 27219, 13165, 26327, 34479, + 22867, 22868, 19501, 27176, 35227, 24005, 33847, 33958, 34026, 34037, + 34048, 34059, 34070, 34081, 34092, 33848, 33859, 33870, 33881, 33892, + 33903, 33914, 26687, 5405, 4697, 36289, 9142, 9141, 8837, 2915, 3025, + 3016, 3123, 3324, 22161, 22159, 22219, 22217, 15738, 5242, 22539, 22542, + 33925, 33936, 33947, 33959, 33970, 33981, 33992, 34003, 34014, 34022, + 34023, 34024, 34025, 34027, 34028, 34029, 34030, 34031, 34032, 34033, + 34034, 34035, 34036, 34038, 34039, 34040, 34041, 34042, 34043, 34044, + 34045, 34046, 34047, 34049, 34050, 34051, 34052, 34053, 34054, 34055, + 34056, 34057, 34058, 34060, 34061, 34062, 34063, 34064, 34065, 34066, + 34067, 34068, 34069, 34071, 34072, 34073, 34074, 34075, 34076, 34077, + 34078, 34079, 34080, 34082, 34083, 34084, 34085, 34086, 34087, 34088, + 34089, 34090, 34091, 34093, 34094, 34095, 34096, 34097, 34098, 34099, + 34100, 34101, 34102, 33849, 33850, 33851, 33852, 33853, 33854, 33855, + 33856, 33857, 33858, 33860, 33861, 33862, 33863, 33864, 33865, 33866, + 33867, 33868, 33869, 33871, 33872, 33873, 33874, 33875, 33876, 33877, + 33878, 33879, 33880, 33882, 33883, 33884, 33885, 33886, 33887, 33888, + 33889, 33890, 33891, 33893, 33894, 33895, 33896, 33897, 33898, 33899, + 33900, 33901, 33902, 33904, 33905, 33906, 33907, 33908, 33909, 33910, + 33911, 33912, 33913, 33915, 33916, 33917, 33918, 33919, 33920, 33921, + 33922, 33923, 33924, 33926, 33927, 33928, 33929, 33930, 33931, 33932, + 33933, 33934, 33935, 33937, 33938, 33939, 33940, 33941, 33942, 33943, + 33944, 33945, 33946, 33948, 33949, 33950, 33951, 33952, 33953, 33954, + 33955, 33956, 33957, 33960, 33961, 33962, 33963, 33964, 33965, 33966, + 33967, 33968, 33969, 33971, 33972, 33973, 33974, 33975, 33976, 33977, + 33978, 33979, 33980, 33982, 33983, 33984, 33985, 33986, 33987, 33988, + 33989, 33990, 33991, 33993, 33994, 33995, 33996, 33997, 33998, 33999, + 34000, 34001, 34002, 34004, 34005, 34006, 34007, 34008, 34009, 34010, + 34011, 34012, 34013, 34015, 34016, 34017, 34018, 34019, 34020, 34021, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 17223, 17224, 17231, 17233, 17230, 17229, 17226, 17225, 17228, + 17227, 17234, 17232, 17907, 18499, 18068, 18751, 18320, 19162, 18004, + 18655, 18005, 18656, 18006, 18657, 18187, 18915, 18188, 18916, 18189, + 18917, 18255, 19023, 17988, 18638, 17984, 18634, 18746, 18875, 17910, + 18502, 17911, 18503, 18009, 18661, 18010, 18662, 17994, 18644, 17995, + 18645, 18745, 18747, 18073, 18753, 18074, 18754, 18091, 18783, 18121, + 18823, 18129, 18848, 18220, 18981, 18325, 19167, 18326, 19168, 18321, + 19163, 18322, 19164, 18511, 18929, 18930, 19114, 19115, 19032, 19033, + 18735, 18736, 2355, 2358, 2356, 2360, 2362, 2359, 2361, 2357, 2363, + 10259, 10254, 10253, 10260, 10255, 10256, 10258, 10257, 3708, 3707, 3709, + 14419, 14418, 14417, 14416, 14421, 14420, 25658, 25657, 3657, 30524, + 30532, 30541, 30533, 30535, 30530, 30534, 30529, 30545, 30544, 30547, + 30539, 30526, 30546, 30528, 30527, 30540, 30531, 30543, 30537, 30538, + 30536, 30542, 30525, 30663, 30670, 30671, 30666, 30667, 30672, 30673, + 30664, 30668, 30669, 30665, 30729, 30736, 30737, 30732, 30733, 30738, + 30739, 30730, 30734, 30735, 30731, 30840, 30847, 30848, 30843, 30844, + 30849, 30850, 30841, 30845, 30846, 30842, 30740, 30747, 30748, 30743, + 30744, 30749, 30750, 30741, 30745, 30746, 30742, 30818, 30825, 30826, + 30821, 30822, 30827, 30828, 30819, 30823, 30824, 30820, 30718, 30725, + 30726, 30721, 30722, 30727, 30728, 30719, 30723, 30724, 30720, 30829, + 30836, 30837, 30832, 30833, 30838, 30839, 30830, 30834, 30835, 30831, + 30751, 30758, 30759, 30754, 30755, 30760, 30761, 30752, 30756, 30757, + 30753, 30884, 30891, 30892, 30887, 30888, 30893, 30894, 30885, 30889, + 30890, 30886, 30873, 30880, 30881, 30876, 30877, 30882, 30883, 30874, + 30878, 30879, 30875, 30906, 30913, 30914, 30909, 30910, 30915, 30916, + 30907, 30911, 30912, 30908, 30773, 30780, 30781, 30776, 30777, 30782, + 30783, 30774, 30778, 30779, 30775, 30696, 30703, 30704, 30699, 30700, + 30705, 30706, 30697, 30701, 30702, 30698, 30895, 30902, 30903, 30898, + 30899, 30904, 30905, 30896, 30900, 30901, 30897, 30674, 30681, 30682, + 30677, 30678, 30683, 30684, 30675, 30679, 30680, 30676, 30685, 30692, + 30693, 30688, 30689, 30694, 30695, 30686, 30690, 30691, 30687, 30762, + 30769, 30770, 30765, 30766, 30771, 30772, 30763, 30767, 30768, 30764, + 30707, 30714, 30715, 30710, 30711, 30716, 30717, 30708, 30712, 30713, + 30709, 30862, 30869, 30870, 30865, 30866, 30871, 30872, 30863, 30867, + 30868, 30864, 30784, 30792, 30793, 30787, 30788, 30794, 30795, 30785, + 30789, 30790, 30786, 30796, 30803, 30804, 30799, 30800, 30805, 30806, + 30797, 30801, 30802, 30798, 30807, 30814, 30815, 30810, 30811, 30816, + 30817, 30808, 30812, 30813, 30809, 30851, 30858, 30859, 30854, 30855, + 30860, 30861, 30852, 30856, 30857, 30853, 30651, 30652, 30659, 30660, + 30655, 30656, 30661, 30662, 30653, 30657, 30658, 30654, 30791, 28754, + 28752, 28753, 13342, 17316, 17314, 17317, 17315, 17306, 17312, 17310, + 17313, 17311, 17307, 17327, 17323, 17328, 17324, 17308, 17325, 17321, + 17326, 17322, 17309, 17338, 17318, 17320, 17319, 17334, 17337, 17335, + 17330, 17336, 17331, 17332, 17333, 17339, 17329, 17478, 17355, 17356, + 17357, 17354, 17473, 17465, 15856, 15858, 15860, 15857, 15859, 16928, + 16930, 16932, 16929, 16931, 16919, 16918, 16917, 16920, 23080, 23085, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, 36293, + 36293, }; @@ -18472,29 +18849,33 @@ static const derived_name_range derived_name_ranges[] = { {0x3400, 0x4DBF, 1}, {0x4E00, 0x9FFF, 1}, {0xAC00, 0xD7A3, 0}, - {0xF900, 0xFA6D, 3}, - {0xFA70, 0xFAD9, 3}, - {0x13460, 0x143FA, 4}, + {0xF900, 0xFA6D, 5}, + {0xFA70, 0xFAD9, 5}, + {0x13460, 0x143FA, 6}, {0x17000, 0x187FF, 2}, - {0x18B00, 0x18CD5, 5}, - {0x18CFF, 0x18CFF, 5}, - {0x18D00, 0x18D1E, 2}, - {0x1B170, 0x1B2FB, 6}, + {0x18B00, 0x18CDA, 7}, + {0x18CFF, 0x18CFF, 7}, + {0x18D00, 0x18D20, 2}, + {0x18E00, 0x19191, 3}, + {0x1B170, 0x1B2FB, 8}, {0x20000, 0x2A6DF, 1}, {0x2A700, 0x2B73F, 1}, - {0x2B740, 0x2B81D, 1}, + {0x2B740, 0x2B81E, 1}, {0x2B820, 0x2CEAD, 1}, {0x2CEB0, 0x2EBE0, 1}, {0x2EBF0, 0x2EE5D, 1}, - {0x2F800, 0x2FA1D, 3}, + {0x2F800, 0x2FA1D, 5}, {0x30000, 0x3134A, 1}, {0x31350, 0x323AF, 1}, {0x323B0, 0x33479, 1}, + {0x3D000, 0x3FC3F, 4}, }; static const char * const derived_name_prefixes[] = { "HANGUL SYLLABLE ", "CJK UNIFIED IDEOGRAPH-", "TANGUT IDEOGRAPH-", + "JURCHEN CHARACTER-", + "SMALL SEAL CHARACTER-", "CJK COMPATIBILITY IDEOGRAPH-", "EGYPTIAN HIEROGLYPH-", "KHITAN SMALL SCRIPT CHARACTER-", diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index 0a6732835eb51f5..31533fa047af0b6 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -838,6 +838,7 @@ save_unconsumed_input(compobject *self, Py_buffer *data, int err) return -1; } Py_SETREF(self->unused_data, new_unused_data); + self->zst.next_in += left_size; self->zst.avail_in = 0; } } @@ -1271,6 +1272,13 @@ zlib_Decompress_flush_impl(compobject *self, PyTypeObject *cls, PyMutex_Lock(&self->mutex); + /* A previous flush() already reached the end of the stream and freed the + decompression state, so there is nothing left to process. */ + if (!self->is_initialised) { + PyMutex_Unlock(&self->mutex); + return Py_GetConstant(Py_CONSTANT_EMPTY_BYTES); + } + if (PyObject_GetBuffer(self->unconsumed_tail, &data, PyBUF_SIMPLE) == -1) { PyMutex_Unlock(&self->mutex); return NULL; @@ -1328,6 +1336,10 @@ zlib_Decompress_flush_impl(compobject *self, PyTypeObject *cls, goto abort; } } + else if (err != Z_OK && err != Z_BUF_ERROR) { + zlib_error(state, self->zst, err, "while decompressing data"); + goto abort; + } return_value = OutputBuffer_WindowFinish(&buffer, &window, self->zst.avail_out); if (return_value != NULL) { @@ -1948,7 +1960,10 @@ zlib_adler32_combine_impl(PyObject *module, unsigned int adler1, #else z_off_t len = convert_to_z_off_t(len2); #endif - if (PyErr_Occurred()) { + if (len < 0) { + if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ValueError, "len2 must be non-negative"); + } return (unsigned int)-1; } return adler32_combine(adler1, adler2, len); @@ -2033,7 +2048,10 @@ zlib_crc32_combine_impl(PyObject *module, unsigned int crc1, #else z_off_t len = convert_to_z_off_t(len2); #endif - if (PyErr_Occurred()) { + if (len < 0) { + if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ValueError, "len2 must be non-negative"); + } return (unsigned int)-1; } return crc32_combine(crc1, crc2, len); @@ -2060,6 +2078,77 @@ zlib_getattr(PyObject *self, PyObject *args) return NULL; } +PyDoc_STRVAR(zlib_version_info__doc__, +"zlib.zlib_version_info\n\ +\n\ +Zlib version information as a named tuple."); + +static PyStructSequence_Field zlib_version_info_fields[] = { + {"major", "Major release number"}, + {"minor", "Minor release number"}, + {"revision", "Revision release number"}, + {"subversion", "Subversion release number"}, + {0} +}; + +static PyStructSequence_Desc zlib_version_info_desc = { + "zlib.zlib_version_info", /* name */ + zlib_version_info__doc__, /* doc */ + zlib_version_info_fields, /* fields */ + 4 +}; + +#ifdef ZLIBNG_VERSION +PyDoc_STRVAR(zlibng_version_info__doc__, +"zlib.zlibng_version_info\n\ +\n\ +Zlib-ng version information as a named tuple."); + +static PyStructSequence_Field zlibng_version_info_fields[] = { + {"major", "Major release number"}, + {"minor", "Minor release number"}, + {"revision", "Revision release number"}, + {0} +}; + +static PyStructSequence_Desc zlibng_version_info_desc = { + "zlib.zlibng_version_info", /* name */ + zlibng_version_info__doc__, /* doc */ + zlibng_version_info_fields, /* fields */ + 3 +}; +#endif // ZLIBNG_VERSION + +/* Create a named tuple from the first *size* components of a version string + like "1.2.11" or "1.2.11.1". sscanf() is expected to fail on trailing + garbage and on versions with fewer components (for example "1.2.0.f" or + "1.3.1.zlib-ng"); the components which were not parsed are left zero. + This is deliberate -- a zero is more useful here than a hard error. */ +static PyObject * +make_version_info(PyTypeObject *type, const char *string, Py_ssize_t size) +{ + unsigned int components[4] = {0, 0, 0, 0}; + assert(size <= (Py_ssize_t)Py_ARRAY_LENGTH(components)); + + sscanf(string, "%u.%u.%u.%u", + &components[0], &components[1], &components[2], &components[3]); + + PyObject *version = PyStructSequence_New(type); + if (version == NULL) { + return NULL; + } + for (Py_ssize_t i = 0; i < size; i++) { + PyObject *item = PyLong_FromUnsignedLong(components[i]); + if (item == NULL) { + Py_DECREF(version); + return NULL; + } + PyStructSequence_SET_ITEM(version, i, item); + } + return version; +} + + static PyMethodDef zlib_methods[] = { ZLIB_ADLER32_METHODDEF @@ -2255,10 +2344,16 @@ zlib_exec(PyObject *mod) #ifdef Z_TREES // 1.2.3.4, only for inflate ZLIB_ADD_INT_MACRO(Z_TREES); #endif + + /* zlib_version */ if (PyModule_Add(mod, "ZLIB_VERSION", PyUnicode_FromString(ZLIB_VERSION)) < 0) { return -1; } + if (PyModule_Add(mod, "zlib_version", + PyUnicode_FromString(zlibVersion())) < 0) { + return -1; + } if (PyModule_Add(mod, "ZLIB_RUNTIME_VERSION", PyUnicode_FromString(zlibVersion())) < 0) { return -1; @@ -2268,6 +2363,37 @@ zlib_exec(PyObject *mod) PyUnicode_FromString(ZLIBNG_VERSION)) < 0) { return -1; } +#endif + PyTypeObject *version_type; + version_type = PyStructSequence_NewType(&zlib_version_info_desc); + if (version_type == NULL) { + return -1; + } + if (PyModule_Add(mod, "ZLIB_VERSION_INFO", + make_version_info(version_type, ZLIB_VERSION, 4)) < 0) + { + Py_DECREF(version_type); + return -1; + } + if (PyModule_Add(mod, "zlib_version_info", + make_version_info(version_type, zlibVersion(), 4)) < 0) + { + Py_DECREF(version_type); + return -1; + } + Py_DECREF(version_type); +#ifdef ZLIBNG_VERSION + version_type = PyStructSequence_NewType(&zlibng_version_info_desc); + if (version_type == NULL) { + return -1; + } + if (PyModule_Add(mod, "ZLIBNG_VERSION_INFO", + make_version_info(version_type, ZLIBNG_VERSION, 3)) < 0) + { + Py_DECREF(version_type); + return -1; + } + Py_DECREF(version_type); #endif return 0; } diff --git a/Objects/abstract.c b/Objects/abstract.c index 28f751965f36b94..635e1e927f23370 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -9,6 +9,7 @@ #include "pycore_list.h" // _PyList_AppendTakeRef() #include "pycore_long.h" // _PyLong_IsNegative() #include "pycore_object.h" // _Py_CheckSlotResult() +#include "pycore_stackref.h" // _PyStackRef #include "pycore_pybuffer.h" // _PyBuffer_ReleaseInInterpreterAndRawFree() #include "pycore_pyerrors.h" // _PyErr_Occurred() #include "pycore_pystate.h" // _PyThreadState_GET() @@ -852,7 +853,6 @@ _PyBuffer_ReleaseInInterpreterAndRawFree(PyInterpreterState *interp, PyObject * PyObject_Format(PyObject *obj, PyObject *format_spec) { - PyObject *meth; PyObject *empty = NULL; PyObject *result = NULL; @@ -879,21 +879,32 @@ PyObject_Format(PyObject *obj, PyObject *format_spec) format_spec = empty; } - /* Find the (unbound!) __format__ method */ - meth = _PyObject_LookupSpecial(obj, &_Py_ID(__format__)); - if (meth == NULL) { - PyThreadState *tstate = _PyThreadState_GET(); - if (!_PyErr_Occurred(tstate)) { - _PyErr_Format(tstate, PyExc_TypeError, - "Type %.100s doesn't define __format__", - Py_TYPE(obj)->tp_name); + /* Find the __format__ method and call it, without creating + a temporary bound method where possible. */ + PyThreadState *tstate = _PyThreadState_GET(); + _PyCStackRef cref; + _PyThreadState_PushCStackRef(tstate, &cref); + _PyStackRef self = PyStackRef_FromPyObjectBorrow(obj); + int found = _PyObject_LookupSpecialMethod(&_Py_ID(__format__), + &cref.ref, &self); + if (found > 0) { + PyObject *meth = PyStackRef_AsPyObjectBorrow(cref.ref); + PyObject *args[2] = {PyStackRef_AsPyObjectBorrow(self), format_spec}; + if (args[0] != NULL) { + /* Unbound method: prepend self. */ + result = PyObject_Vectorcall(meth, args, 2, NULL); + } + else { + result = PyObject_Vectorcall(meth, args + 1, 1, NULL); } - goto done; } - - /* And call it. */ - result = PyObject_CallOneArg(meth, format_spec); - Py_DECREF(meth); + else if (found == 0) { + _PyErr_Format(tstate, PyExc_TypeError, + "Type %.100s doesn't define __format__", + Py_TYPE(obj)->tp_name); + } + PyStackRef_XCLOSE(self); + _PyThreadState_PopCStackRef(tstate, &cref); if (result && !PyUnicode_Check(result)) { PyErr_Format(PyExc_TypeError, @@ -1343,7 +1354,7 @@ PyNumber_InPlaceMultiply(PyObject *v, PyObject *w) if (f != NULL) return sequence_repeat(f, v, w); } - else if (mw != NULL) { + if (mw != NULL) { /* Note that the right hand operand should not be * mutated in this case so sq_inplace_repeat is not * used. */ @@ -2599,6 +2610,28 @@ check_class(PyObject *cls, const char *error) return -1; } +/* Return 1 if inst.__class__ would resolve to object's own getset descriptor, + i.e. evaluate to Py_TYPE(inst). Types with a custom tp_getattro or an + overridden __class__ return 0 and take the generic lookup. */ +static inline int +class_attr_is_type(PyObject *inst) +{ + PyTypeObject *tp = Py_TYPE(inst); + if (tp->tp_getattro != PyObject_GenericGetAttr) { + return 0; + } + _PyStackRef cref; + _PyType_LookupStackRefAndVersion(tp, &_Py_ID(__class__), &cref); + if (PyStackRef_IsNull(cref)) { + return 0; + } + PyObject *descr = PyStackRef_AsPyObjectBorrow(cref); + int res = (Py_IS_TYPE(descr, &PyGetSetDescr_Type) + && PyDescr_TYPE(descr) == &PyBaseObject_Type); + PyStackRef_CLOSE(cref); + return res; +} + static int object_isinstance(PyObject *inst, PyObject *cls) { @@ -2607,6 +2640,9 @@ object_isinstance(PyObject *inst, PyObject *cls) if (PyType_Check(cls)) { retval = PyObject_TypeCheck(inst, (PyTypeObject *)cls); if (retval == 0) { + if (class_attr_is_type(inst)) { + return 0; + } retval = PyObject_GetOptionalAttr(inst, &_Py_ID(__class__), &icls); if (icls != NULL) { if (icls != (PyObject *)(Py_TYPE(inst)) && PyType_Check(icls)) { @@ -2635,6 +2671,37 @@ object_isinstance(PyObject *inst, PyObject *cls) return retval; } +static int +call_special_method(PyThreadState *tstate, PyObject *cls, PyObject *name, + const char *where, PyObject *arg, PyObject **res) +{ + _PyCStackRef cref; + _PyThreadState_PushCStackRef(tstate, &cref); + _PyStackRef self = PyStackRef_FromPyObjectBorrow(cls); + int found = _PyObject_LookupSpecialMethod(name, &cref.ref, &self); + if (found > 0) { + *res = NULL; + if (!_Py_EnterRecursiveCallTstate(tstate, where)) { + PyObject *method = PyStackRef_AsPyObjectBorrow(cref.ref); + PyObject *args[2] = {PyStackRef_AsPyObjectBorrow(self), arg}; + if (args[0] != NULL) { + /* Unbound method: prepend self. */ + *res = PyObject_Vectorcall(method, args, 2, NULL); + } + else { + *res = PyObject_Vectorcall(method, args + 1, 1, NULL); + } + _Py_LeaveRecursiveCallTstate(tstate); + } + if (*res == NULL) { + found = -1; + } + } + PyStackRef_XCLOSE(self); + _PyThreadState_PopCStackRef(tstate, &cref); + return found; +} + static int object_recursive_isinstance(PyThreadState *tstate, PyObject *inst, PyObject *cls) { @@ -2672,26 +2739,16 @@ object_recursive_isinstance(PyThreadState *tstate, PyObject *inst, PyObject *cls return r; } - PyObject *checker = _PyObject_LookupSpecial(cls, &_Py_ID(__instancecheck__)); - if (checker != NULL) { - if (_Py_EnterRecursiveCallTstate(tstate, " in __instancecheck__")) { - Py_DECREF(checker); - return -1; - } - - PyObject *res = PyObject_CallOneArg(checker, inst); - _Py_LeaveRecursiveCallTstate(tstate); - Py_DECREF(checker); - - if (res == NULL) { - return -1; - } + PyObject *res; + int found = call_special_method(tstate, cls, &_Py_ID(__instancecheck__), + " in __instancecheck__", inst, &res); + if (found > 0) { int ok = PyObject_IsTrue(res); Py_DECREF(res); return ok; } - else if (_PyErr_Occurred(tstate)) { + else if (found < 0) { return -1; } @@ -2731,8 +2788,6 @@ recursive_issubclass(PyObject *derived, PyObject *cls) static int object_issubclass(PyThreadState *tstate, PyObject *derived, PyObject *cls) { - PyObject *checker; - /* We know what type's __subclasscheck__ does. */ if (PyType_CheckExact(cls)) { /* Quick test for an exact match */ @@ -2763,23 +2818,15 @@ object_issubclass(PyThreadState *tstate, PyObject *derived, PyObject *cls) return r; } - checker = _PyObject_LookupSpecial(cls, &_Py_ID(__subclasscheck__)); - if (checker != NULL) { - int ok = -1; - if (_Py_EnterRecursiveCallTstate(tstate, " in __subclasscheck__")) { - Py_DECREF(checker); - return ok; - } - PyObject *res = PyObject_CallOneArg(checker, derived); - _Py_LeaveRecursiveCallTstate(tstate); - Py_DECREF(checker); - if (res != NULL) { - ok = PyObject_IsTrue(res); - Py_DECREF(res); - } + PyObject *res; + int found = call_special_method(tstate, cls, &_Py_ID(__subclasscheck__), + " in __subclasscheck__", derived, &res); + if (found > 0) { + int ok = PyObject_IsTrue(res); + Py_DECREF(res); return ok; } - else if (_PyErr_Occurred(tstate)) { + else if (found < 0) { return -1; } diff --git a/Objects/boolobject.c b/Objects/boolobject.c index b694691ae4d0d1e..b709e0934b7872c 100644 --- a/Objects/boolobject.c +++ b/Objects/boolobject.c @@ -2,12 +2,18 @@ #include "Python.h" #include "pycore_long.h" // FALSE_TAG TRUE_TAG -#include "pycore_modsupport.h" // _PyArg_NoKwnames() #include "pycore_object.h" // _Py_FatalRefcountError() #include "pycore_runtime.h" // _Py_ID() #include +/*[clinic input] +class bool "PyObject *" "&PyBool_Type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=ee492546880a882f]*/ + +#include "clinic/boolobject.c.h" + /* We define bool_repr to return "False" or "True" */ static PyObject * @@ -23,45 +29,28 @@ PyObject *PyBool_FromLong(long ok) return ok ? Py_True : Py_False; } -/* We define bool_new to always return either Py_True or Py_False */ +/*[clinic input] +@vectorcall +@classmethod +bool.__new__ as bool_new + object as x: object = False + / -static PyObject * -bool_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *x = Py_False; - long ok; +Returns True when the argument is true, False otherwise. - if (!_PyArg_NoKeywords("bool", kwds)) - return NULL; - if (!PyArg_UnpackTuple(args, "bool", 0, 1, &x)) - return NULL; - ok = PyObject_IsTrue(x); - if (ok < 0) - return NULL; - return PyBool_FromLong(ok); -} +The builtins True and False are the only two instances of the class +bool. The class bool is a subclass of the class int, and cannot be +subclassed. +[clinic start generated code]*/ static PyObject * -bool_vectorcall(PyObject *type, PyObject * const*args, - size_t nargsf, PyObject *kwnames) +bool_new_impl(PyTypeObject *type, PyObject *x) +/*[clinic end generated code: output=ec434408d43a3773 input=d96e25fce5a04f73]*/ { - long ok = 0; - if (!_PyArg_NoKwnames("bool", kwnames)) { - return NULL; - } - - Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); - if (!_PyArg_CheckPositional("bool", nargs, 0, 1)) { + int ok = PyObject_IsTrue(x); + if (ok < 0) { return NULL; } - - assert(PyType_Check(type)); - if (nargs) { - ok = PyObject_IsTrue(args[0]); - if (ok < 0) { - return NULL; - } - } return PyBool_FromLong(ok); } @@ -107,16 +96,6 @@ bool_xor(PyObject *a, PyObject *b) return PyBool_FromLong((a == Py_True) ^ (b == Py_True)); } -/* Doc string */ - -PyDoc_STRVAR(bool_doc, -"bool(object=False, /)\n\ ---\n\ -\n\ -Returns True when the argument is true, False otherwise.\n\ -The builtins True and False are the only two instances of the class bool.\n\ -The class bool is a subclass of the class int, and cannot be subclassed."); - /* Arithmetic methods -- only so we can override &, |, ^. */ static PyNumberMethods bool_as_number = { @@ -189,7 +168,7 @@ PyTypeObject PyBool_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ - bool_doc, /* tp_doc */ + bool_new__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 696ddad8efaae55..b9d547575bd2eba 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -43,9 +43,29 @@ _getbytevalue(PyObject* arg, int *value) return 1; } +static inline void +bytearray_write_trailing_null_byte(PyByteArrayObject *self) +{ + char *data = PyByteArray_AS_STRING(self); + Py_ssize_t size = PyByteArray_GET_SIZE(self); + data[size] = '\0'; +} + + static void -bytearray_reinit_from_bytes(PyByteArrayObject *self, Py_ssize_t size, - Py_ssize_t alloc) { +bytearray_reinit_from_bytes(PyByteArrayObject *self, Py_ssize_t size) +{ + Py_ssize_t alloc = PyBytes_GET_SIZE(self->ob_bytes_object); + assert(0 <= size && size <= alloc); + + if (alloc != 0) { + assert(_PyBytes_IsMutable(self->ob_bytes_object)); + } + else { + // Use the empty bytes string singleton for an empty bytearray + assert(_Py_IsImmortal(self->ob_bytes_object)); + } + self->ob_bytes = self->ob_start = PyBytes_AS_STRING(self->ob_bytes_object); Py_SET_SIZE(self, size); FT_ATOMIC_STORE_SSIZE_RELAXED(self->ob_alloc, alloc); @@ -182,7 +202,7 @@ PyByteArray_FromStringAndSize(const char *bytes, Py_ssize_t size) Py_DECREF(new); return NULL; } - bytearray_reinit_from_bytes(new, size, size); + bytearray_reinit_from_bytes(new, size); if (bytes != NULL && size > 0) { memcpy(new->ob_bytes, bytes, size); } @@ -208,33 +228,76 @@ PyByteArray_AsString(PyObject *self) return PyByteArray_AS_STRING(self); } + static int -bytearray_resize_lock_held(PyObject *self, Py_ssize_t requested_size) +bytearray_resize_storage(PyByteArrayObject *self, + Py_ssize_t new_size, Py_ssize_t alloc) { _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self); - PyByteArrayObject *obj = ((PyByteArrayObject *)self); + assert(1 <= new_size && new_size <= alloc); + + Py_ssize_t size = Py_SIZE(self); + + /* Re-align data to the start of the allocation. */ + char *old_start = self->ob_start; + if (self->ob_start != self->ob_bytes) { + /* optimization tradeoff: This is faster than a new allocation when + the number of bytes being removed in a resize is small; for + large size changes it may be better to just make a new bytes + object as _PyBytes_Resize will do a malloc + memcpy internally. + */ + Py_ssize_t move = Py_MIN(new_size, size); + memmove(self->ob_bytes, self->ob_start, move); + self->ob_start = self->ob_bytes; + } + + if (_PyBytes_ResizeKeepOnError(&self->ob_bytes_object, alloc) < 0) { + if (old_start != self->ob_bytes && new_size < size) { + // Move remaining bytes + Py_ssize_t moved = new_size; + Py_ssize_t remaining = size - moved; + memmove(self->ob_bytes + moved, old_start + moved, remaining); + } + bytearray_write_trailing_null_byte(self); + return -1; + } + assert(_PyBytes_IsMutable(self->ob_bytes_object)); + return 0; +} + + +/* Resize without the checks of bytearray_resize_lock_held(): the caller must + have checked that the bytearray can be resized. + + Unlike bytearray_resize_lock_held(), this does not return early if + requested_size is already the size of the bytearray. A caller which + removed bytes by advancing ob_start and reducing the size uses that to + release the memory. */ +static int +bytearray_resize_unchecked(PyByteArrayObject *obj, Py_ssize_t requested_size) +{ + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(obj); + PyObject *self = (PyObject *)obj; + + assert(obj->ob_bytes_object != NULL); + assert(requested_size >= 0); + assert(obj->ob_exports == 0); + /* All computations are done unsigned to avoid integer overflows (see issue #22335). */ size_t alloc = (size_t) obj->ob_alloc; size_t logical_offset = (size_t) (obj->ob_start - obj->ob_bytes); size_t size = (size_t) requested_size; - assert(self != NULL); - assert(PyByteArray_Check(self)); assert(logical_offset <= alloc); - if (requested_size < 0) { - PyErr_Format(PyExc_ValueError, - "Can only resize to positive sizes, got %zd", requested_size); - return -1; - } - - if (requested_size == Py_SIZE(self)) { + /* Resize to 0 resets to empty bytes (see issue #153419). */ + if (requested_size == 0) { + Py_SETREF(obj->ob_bytes_object, + Py_GetConstant(Py_CONSTANT_EMPTY_BYTES)); + bytearray_reinit_from_bytes(obj, 0); return 0; } - if (!_canresize(obj)) { - return -1; - } if (size + logical_offset <= alloc) { /* Current buffer is large enough to host the requested size, @@ -247,7 +310,7 @@ bytearray_resize_lock_held(PyObject *self, Py_ssize_t requested_size) /* Minor downsize; quick exit */ Py_SET_SIZE(self, size); /* Add mid-buffer null; end provided by bytes. */ - PyByteArray_AS_STRING(self)[size] = '\0'; /* Trailing null */ + bytearray_write_trailing_null_byte(_PyByteArray_CAST(self)); return 0; } } @@ -267,28 +330,40 @@ bytearray_resize_lock_held(PyObject *self, Py_ssize_t requested_size) return -1; } - /* Re-align data to the start of the allocation. */ - if (logical_offset > 0) { - /* optimization tradeoff: This is faster than a new allocation when - the number of bytes being removed in a resize is small; for large - size changes it may be better to just make a new bytes object as - _PyBytes_Resize will do a malloc + memcpy internally. */ - memmove(obj->ob_bytes, obj->ob_start, - Py_MIN(requested_size, Py_SIZE(self))); + if (bytearray_resize_storage(obj, requested_size, (Py_ssize_t)alloc) < 0) { + return -1; } - int ret = _PyBytes_Resize(&obj->ob_bytes_object, alloc); - if (ret == -1) { - obj->ob_bytes_object = Py_GetConstant(Py_CONSTANT_EMPTY_BYTES); - size = alloc = 0; - } - bytearray_reinit_from_bytes(obj, size, alloc); + bytearray_reinit_from_bytes(obj, size); if (alloc != size) { /* Add mid-buffer null; end provided by bytes. */ - obj->ob_bytes[size] = '\0'; + bytearray_write_trailing_null_byte(obj); + } + return 0; +} + +static int +bytearray_resize_lock_held(PyObject *self, Py_ssize_t requested_size) +{ + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self); + PyByteArrayObject *obj = ((PyByteArrayObject *)self); + + assert(self != NULL); + assert(PyByteArray_Check(self)); + + if (requested_size < 0) { + PyErr_Format(PyExc_ValueError, + "Can only resize to positive sizes, got %zd", requested_size); + return -1; } - return ret; + if (requested_size == Py_SIZE(self)) { + return 0; + } + if (!_canresize(obj)) { + return -1; + } + return bytearray_resize_unchecked(obj, requested_size); } int @@ -346,11 +421,19 @@ bytearray_length(PyObject *op) return PyByteArray_GET_SIZE(op); } +/*[clinic input] +@critical_section +bytearray.__iadd__ as bytearray_iconcat + + other: object + / +[clinic start generated code]*/ + static PyObject * -bytearray_iconcat_lock_held(PyObject *op, PyObject *other) +bytearray_iconcat_impl(PyByteArrayObject *self, PyObject *other) +/*[clinic end generated code: output=ba172f2db8f7a8dd input=5b6fb07ab387084d]*/ { - _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op); - PyByteArrayObject *self = _PyByteArray_CAST(op); + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self); Py_buffer vo; if (PyObject_GetBuffer(other, &vo, PyBUF_SIMPLE) != 0) { @@ -375,21 +458,19 @@ bytearray_iconcat_lock_held(PyObject *op, PyObject *other) return Py_NewRef(self); } -static PyObject * -bytearray_iconcat(PyObject *op, PyObject *other) -{ - PyObject *ret; - Py_BEGIN_CRITICAL_SECTION(op); - ret = bytearray_iconcat_lock_held(op, other); - Py_END_CRITICAL_SECTION(); - return ret; -} +/*[clinic input] +@critical_section +bytearray.__mul__ as bytearray_repeat + + count: Py_ssize_t + / +[clinic start generated code]*/ static PyObject * -bytearray_repeat_lock_held(PyObject *op, Py_ssize_t count) +bytearray_repeat_impl(PyByteArrayObject *self, Py_ssize_t count) +/*[clinic end generated code: output=0889e9ebbe61890a input=3363528e6db1f39b]*/ { - _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op); - PyByteArrayObject *self = _PyByteArray_CAST(op); + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self); if (count < 0) { count = 0; } @@ -407,21 +488,19 @@ bytearray_repeat_lock_held(PyObject *op, Py_ssize_t count) return (PyObject *)result; } -static PyObject * -bytearray_repeat(PyObject *op, Py_ssize_t count) -{ - PyObject *ret; - Py_BEGIN_CRITICAL_SECTION(op); - ret = bytearray_repeat_lock_held(op, count); - Py_END_CRITICAL_SECTION(); - return ret; -} +/*[clinic input] +@critical_section +bytearray.__imul__ as bytearray_irepeat + + count: Py_ssize_t + / +[clinic start generated code]*/ static PyObject * -bytearray_irepeat_lock_held(PyObject *op, Py_ssize_t count) +bytearray_irepeat_impl(PyByteArrayObject *self, Py_ssize_t count) +/*[clinic end generated code: output=4cfee919b3489219 input=e12991c89153490b]*/ { - _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op); - PyByteArrayObject *self = _PyByteArray_CAST(op); + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self); if (count < 0) { count = 0; } @@ -444,21 +523,18 @@ bytearray_irepeat_lock_held(PyObject *op, Py_ssize_t count) return Py_NewRef(self); } -static PyObject * -bytearray_irepeat(PyObject *op, Py_ssize_t count) -{ - PyObject *ret; - Py_BEGIN_CRITICAL_SECTION(op); - ret = bytearray_irepeat_lock_held(op, count); - Py_END_CRITICAL_SECTION(); - return ret; -} +/*[clinic input] +@critical_section +bytearray.__getitem__ as bytearray_getitem + i: Py_ssize_t + / +[clinic start generated code]*/ static PyObject * -bytearray_getitem_lock_held(PyObject *op, Py_ssize_t i) +bytearray_getitem_impl(PyByteArrayObject *self, Py_ssize_t i) +/*[clinic end generated code: output=743cb7a5f892f7ed input=f90e2c70f80e2917]*/ { - _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op); - PyByteArrayObject *self = _PyByteArray_CAST(op); + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self); if (i < 0 || i >= Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "bytearray index out of range"); return NULL; @@ -466,16 +542,6 @@ bytearray_getitem_lock_held(PyObject *op, Py_ssize_t i) return _PyLong_FromUnsignedChar((unsigned char)(self->ob_start[i])); } -static PyObject * -bytearray_getitem(PyObject *op, Py_ssize_t i) -{ - PyObject *ret; - Py_BEGIN_CRITICAL_SECTION(op); - ret = bytearray_getitem_lock_held(op, i); - Py_END_CRITICAL_SECTION(); - return ret; -} - static PyObject * bytearray_subscript_lock_held(PyObject *op, PyObject *index) { @@ -564,14 +630,22 @@ bytearray_setslice_linear(PyByteArrayObject *self, return -1; if (lo == 0) { - /* Shrink the buffer by advancing its logical start */ + /* Shrink the buffer by advancing its logical start. The bytes + are removed at this point; the resize below only releases + memory. */ self->ob_start -= growth; + Py_SET_SIZE(self, Py_SIZE(self) + growth); /* 0 lo hi old_size | |<----avail----->|<-----tail------>| | |<-bytes_len->|<-----tail------>| 0 new_lo new_hi new_size */ + if (bytearray_resize_unchecked(self, Py_SIZE(self)) < 0) { + /* The operation is completed, but a MemoryError is still + raised and the memory block is not shrunk. */ + res = -1; + } } else { /* @@ -582,26 +656,17 @@ bytearray_setslice_linear(PyByteArrayObject *self, */ memmove(buf + lo + bytes_len, buf + hi, Py_SIZE(self) - hi); - } - if (bytearray_resize_lock_held((PyObject *)self, - Py_SIZE(self) + growth) < 0) { - /* Issue #19578: Handling the memory allocation failure here is - tricky here because the bytearray object has already been - modified. Depending on growth and lo, the behaviour is - different. - - If growth < 0 and lo != 0, the operation is completed, but a - MemoryError is still raised and the memory block is not - shrunk. Otherwise, the bytearray is restored in its previous - state and a MemoryError is raised. */ - if (lo == 0) { - self->ob_start += growth; - return -1; + if (bytearray_resize_lock_held((PyObject *)self, + Py_SIZE(self) + growth) < 0) { + /* Issue #19578: memmove() removed bytes, the bytearray + object cannot be restored in its previous state. + + The operation is completed, but a MemoryError is still + raised and the memory block is not shrunk. */ + Py_SET_SIZE(self, Py_SIZE(self) + growth); + bytearray_write_trailing_null_byte(self); + res = -1; } - /* memmove() removed bytes, the bytearray object cannot be - restored in its previous state. */ - Py_SET_SIZE(self, Py_SIZE(self) + growth); - res = -1; } buf = PyByteArray_AS_STRING(self); } @@ -670,8 +735,11 @@ bytearray_setslice(PyByteArrayObject *self, Py_ssize_t lo, Py_ssize_t hi, bytes = vbytes.buf; } + // gh-153578: __buffer__() may have resized self; re-clamp both bounds. if (lo < 0) lo = 0; + else if (lo > Py_SIZE(self)) + lo = Py_SIZE(self); if (hi < lo) hi = lo; if (hi > Py_SIZE(self)) @@ -683,11 +751,21 @@ bytearray_setslice(PyByteArrayObject *self, Py_ssize_t lo, Py_ssize_t hi, return res; } +/*[clinic input] +@critical_section +bytearray.__setitem__ as bytearray_setitem + + i: Py_ssize_t + value: object + / +[clinic start generated code]*/ + static int -bytearray_setitem_lock_held(PyObject *op, Py_ssize_t i, PyObject *value) +bytearray_setitem_impl(PyByteArrayObject *self, Py_ssize_t i, + PyObject *value) +/*[clinic end generated code: output=c8e973819dd58098 input=460a77c3d8b7268f]*/ { - _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op); - PyByteArrayObject *self = _PyByteArray_CAST(op); + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self); // GH-91153: We need to do this *before* the size check, in case value has a // nasty __index__ method that changes the size of the bytearray: @@ -714,16 +792,6 @@ bytearray_setitem_lock_held(PyObject *op, Py_ssize_t i, PyObject *value) return 0; } -static int -bytearray_setitem(PyObject *op, Py_ssize_t i, PyObject *value) -{ - int ret; - Py_BEGIN_CRITICAL_SECTION(op); - ret = bytearray_setitem_lock_held(op, i, value); - Py_END_CRITICAL_SECTION(); - return ret; -} - static int bytearray_ass_subscript_lock_held(PyObject *op, PyObject *index, PyObject *values) { @@ -902,7 +970,22 @@ bytearray_ass_subscript(PyObject *op, PyObject *index, PyObject *values) return ret; } +static PyObject * +bytearray_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *op = PyType_GenericNew(type, args, kwds); + if (op == NULL) { + return NULL; + } + PyByteArrayObject *self = _PyByteArray_CAST(op); + self->ob_bytes_object = Py_GetConstant(Py_CONSTANT_EMPTY_BYTES); + bytearray_reinit_from_bytes(self, 0); + self->ob_exports = 0; + return op; +} + /*[clinic input] +@vectorcall bytearray.__init__ source as arg: object = NULL @@ -914,26 +997,22 @@ bytearray.__init__ static int bytearray___init___impl(PyByteArrayObject *self, PyObject *arg, const char *encoding, const char *errors) -/*[clinic end generated code: output=4ce1304649c2f8b3 input=1141a7122eefd7b9]*/ +/*[clinic end generated code: output=4ce1304649c2f8b3 input=24ddb84055f432dd]*/ { Py_ssize_t count; PyObject *it; PyObject *(*iternext)(PyObject *); - /* First __init__; set ob_bytes_object so ob_bytes is always non-null. */ - if (self->ob_bytes_object == NULL) { - self->ob_bytes_object = Py_GetConstant(Py_CONSTANT_EMPTY_BYTES); - bytearray_reinit_from_bytes(self, 0, 0); - self->ob_exports = 0; + /* Disallow any __init__ call if the object is not resizable (has exports) + to make the handling of non-null `source` init values simpler. */ + if (!_canresize(self)) { + return -1; } - if (Py_SIZE(self) != 0) { - /* Empty previous contents (yes, do this first of all!) */ - if (PyByteArray_Resize((PyObject *)self, 0) < 0) - return -1; + /* Empty any previous contents (do this first of all!). */ + if (PyByteArray_Resize((PyObject *)self, 0) < 0) { + return -1; } - - /* Should be caused by first init or the resize to 0. */ assert(self->ob_bytes_object == Py_GetConstantBorrowed(Py_CONSTANT_EMPTY_BYTES)); assert(self->ob_exports == 0); @@ -965,11 +1044,12 @@ bytearray___init___impl(PyByteArrayObject *self, PyObject *arg, /* Most encodes return a new unique bytes, just use it as buffer. */ if (_PyObject_IsUniquelyReferenced(encoded) - && PyBytes_CheckExact(encoded)) + && PyBytes_CheckExact(encoded) + && _PyBytes_GET_CACHED_HASH((PyBytesObject*)encoded) == -1) { - Py_ssize_t size = Py_SIZE(encoded); + Py_ssize_t size = PyBytes_GET_SIZE(encoded); self->ob_bytes_object = encoded; - bytearray_reinit_from_bytes(self, size, size); + bytearray_reinit_from_bytes(self, size); return 0; } new = bytearray_iconcat((PyObject*)self, encoded); @@ -1021,7 +1101,11 @@ bytearray___init___impl(PyByteArrayObject *self, PyObject *arg, if (PyByteArray_Resize((PyObject *)self, size) < 0) goto fail; if (PyBuffer_ToContiguous(PyByteArray_AS_STRING(self), &view, size, 'C') < 0) + { + /* Don't expose the uninitialized bytes: reset to empty */ + (void)PyByteArray_Resize((PyObject *)self, 0); goto fail; + } PyBuffer_Release(&view); return 0; fail: @@ -1049,6 +1133,8 @@ bytearray___init___impl(PyByteArrayObject *self, PyObject *arg, } int rc = _getbytevalue(items[i], &value); if (!rc) { + /* Don't expose the uninitialized bytes: reset to empty */ + (void)PyByteArray_Resize((PyObject *)self, 0); return -1; } s[i] = value; @@ -1087,17 +1173,26 @@ bytearray___init___impl(PyByteArrayObject *self, PyObject *arg, /* Interpret it as an int (__index__) */ rc = _getbytevalue(item, &value); Py_DECREF(item); - if (!rc) + if (!rc) { goto error; + } - /* Append the byte */ - if (Py_SIZE(self) + 1 < self->ob_alloc) { + /* Append the byte. + + gh-158928: Iterators are arbitrary code which could modify the + bytearray so this must re-calculate if there is enough space(). */ + Py_ssize_t needed = + self->ob_start - self->ob_bytes + Py_SIZE(self) + 1; + if (needed < self->ob_alloc) { Py_SET_SIZE(self, Py_SIZE(self) + 1); - PyByteArray_AS_STRING(self)[Py_SIZE(self)] = '\0'; + bytearray_write_trailing_null_byte(self); } - else if (PyByteArray_Resize((PyObject *)self, Py_SIZE(self)+1) < 0) + else if (PyByteArray_Resize((PyObject *)self, Py_SIZE(self)+1) < 0) { goto error; + } PyByteArray_AS_STRING(self)[Py_SIZE(self)-1] = value; + assert(self->ob_start - self->ob_bytes + Py_SIZE(self) <= + self->ob_alloc); } /* Clean up and return success */ @@ -1110,8 +1205,16 @@ bytearray___init___impl(PyByteArrayObject *self, PyObject *arg, return -1; } +/*[clinic input] +@critical_section +bytearray.__repr__ + + op: self(type="PyObject *") +[clinic start generated code]*/ + static PyObject * -bytearray_repr_lock_held(PyObject *op) +bytearray_repr_impl(PyObject *op) +/*[clinic end generated code: output=4086ab6928ebab1d input=d46ad3c1f3071b27]*/ { _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op); const char *className = _PyType_Name(Py_TYPE(op)); @@ -1126,16 +1229,6 @@ bytearray_repr_lock_held(PyObject *op) return res; } -static PyObject * -bytearray_repr(PyObject *op) -{ - PyObject *ret; - Py_BEGIN_CRITICAL_SECTION(op); - ret = bytearray_repr_lock_held(op); - Py_END_CRITICAL_SECTION(); - return ret; -} - static PyObject * bytearray_str(PyObject *op) { @@ -1207,6 +1300,12 @@ static void bytearray_dealloc(PyObject *op) { PyByteArrayObject *self = _PyByteArray_CAST(op); +#ifdef Py_DEBUG + if (self->ob_bytes_object != NULL) { + _PyBytes_CheckOverflow(self->ob_bytes_object, op, "bytearray"); + } +#endif + if (self->ob_exports > 0) { PyErr_SetString(PyExc_SystemError, "deallocated bytearray object has exported buffers"); @@ -1555,6 +1654,8 @@ bytearray_take_bytes_impl(PyByteArrayObject *self, PyObject *n) if (to_take == -1 && PyErr_Occurred()) { return NULL; } + // n.__index__() may have resized self; use the current size. + size = Py_SIZE(self); if (to_take < 0) { to_take += size; } @@ -1581,6 +1682,7 @@ bytearray_take_bytes_impl(PyByteArrayObject *self, PyObject *n) } Py_ssize_t remaining_length = size - to_take; + // optimization: If taking less than leaving, just copy the small to_take // portion out and move ob_start. if (to_take < remaining_length) { @@ -1593,20 +1695,16 @@ bytearray_take_bytes_impl(PyByteArrayObject *self, PyObject *n) return ret; } - // Copy remaining bytes to a new bytes. - PyObject *remaining = PyBytes_FromStringAndSize(self->ob_start + to_take, - remaining_length); + // Copy remaining bytes to a new bytes. Allocate and then copy + // so we don't get a shared immortal one-character singleton! + PyObject *remaining = PyBytes_FromStringAndSize(NULL, remaining_length); if (remaining == NULL) { return NULL; } + memcpy(PyBytes_AS_STRING(remaining), self->ob_start + to_take, + remaining_length); - // If the bytes are offset inside the buffer must first align. - if (self->ob_start != self->ob_bytes) { - memmove(self->ob_bytes, self->ob_start, to_take); - self->ob_start = self->ob_bytes; - } - - if (_PyBytes_Resize(&self->ob_bytes_object, to_take) == -1) { + if (bytearray_resize_storage(self, to_take, to_take) < 0) { Py_DECREF(remaining); return NULL; } @@ -1614,7 +1712,7 @@ bytearray_take_bytes_impl(PyByteArrayObject *self, PyObject *n) // Point the bytearray towards the buffer with the remaining data. PyObject *result = self->ob_bytes_object; self->ob_bytes_object = remaining; - bytearray_reinit_from_bytes(self, remaining_length, remaining_length); + bytearray_reinit_from_bytes(self, remaining_length); return result; } @@ -2523,7 +2621,19 @@ bytearray_decode_impl(PyByteArrayObject *self, const char *encoding, { if (encoding == NULL) encoding = PyUnicode_GetDefaultEncoding(); - return PyUnicode_FromEncodedObject((PyObject*)self, encoding, errors); + if (Py_TYPE(self)->tp_as_buffer->bf_getbuffer != bytearray_getbuffer) { + /* A subclass may export a different buffer. */ + return PyUnicode_FromEncodedObject((PyObject*)self, encoding, errors); + } + + /* Decode the storage directly instead of exporting a buffer, which + would re-acquire the critical section we already hold. Increase + exports to prevent the storage from changing during the decode. */ + self->ob_exports++; + PyObject *res = PyUnicode_Decode(PyByteArray_AS_STRING(self), + Py_SIZE(self), encoding, errors); + self->ob_exports--; + return res; } PyDoc_STRVAR(alloc_doc, @@ -2937,8 +3047,9 @@ PyTypeObject PyByteArray_Type = { 0, /* tp_dictoffset */ bytearray___init__, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ + bytearray_new, /* tp_new */ PyObject_Free, /* tp_free */ + .tp_vectorcall = bytearray_vectorcall, .tp_version_tag = _Py_TYPE_VERSION_BYTEARRAY, }; diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c index 414afeb7bb003c7..4021a0e82236942 100644 --- a/Objects/bytes_methods.c +++ b/Objects/bytes_methods.c @@ -377,6 +377,7 @@ _Py_bytes_maketrans(Py_buffer *frm, Py_buffer *to) } #define FASTSEARCH fastsearch +#define STRINGLIB_IS_UNICODE 0 #define STRINGLIB(F) stringlib_##F #define STRINGLIB_CHAR char #define STRINGLIB_SIZEOF_CHAR 1 diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index f63185e14284b1a..e9264f765a08e6d 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -6,6 +6,7 @@ #include "pycore_bytesobject.h" // _PyBytes_Find(), _PyBytes_RepeatBuffer() #include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_ceval.h" // _PyEval_GetBuiltin() +#include "pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST() #include "pycore_format.h" // F_LJUST #include "pycore_freelist.h" // _Py_FREELIST_FREE() #include "pycore_global_objects.h"// _Py_GET_GLOBAL_OBJECT() @@ -31,17 +32,18 @@ class bytes "PyBytesObject *" "&PyBytes_Type" /* Forward declaration */ static void* _PyBytesWriter_ResizeAndUpdatePointer(PyBytesWriter *writer, Py_ssize_t size, void *data); -static Py_ssize_t _PyBytesWriter_GetAllocated(PyBytesWriter *writer); +static Py_ssize_t _PyBytesWriter_ResizeToAllocated(PyBytesWriter *writer); #define CHARACTERS _Py_SINGLETON(bytes_characters) #define CHARACTER(ch) \ - ((PyBytesObject *)&(CHARACTERS[ch])); + ((PyBytesObject *)&(CHARACTERS[ch])) #define EMPTY (&_Py_SINGLETON(bytes_empty)) // Return a reference to the immortal empty bytes string singleton. -static inline PyObject* bytes_get_empty(void) +static inline PyObject* +bytes_get_empty(void) { PyObject *empty = &EMPTY->ob_base.ob_base; assert(_Py_IsImmortal(empty)); @@ -49,6 +51,16 @@ static inline PyObject* bytes_get_empty(void) } +// The function cannot fail +static inline PyObject* +bytes_get_char(uint8_t ch) +{ + PyObject *obj = (PyObject*)CHARACTER(ch); + assert(_Py_IsImmortal(obj)); + return obj; +} + + static inline void set_ob_shash(PyBytesObject *a, Py_hash_t hash) { @@ -62,19 +74,23 @@ _Py_COMP_DIAG_IGNORE_DEPR_DECLS _Py_COMP_DIAG_POP } -static inline Py_hash_t -get_ob_shash(PyBytesObject *a) +// Similar to set_ob_shash() but don't use an atomic operation on Free +// Threading. This function must only be used on newly allocated bytes objects. +static inline void +set_ob_shash_unsafe(PyBytesObject *a, Py_hash_t hash) { + // Don't test _PyObject_IsUniquelyReferenced(), so the function can be + // called by bytes_resize_inplace(). + assert(Py_REFCNT(a) == 1); + _Py_COMP_DIAG_PUSH _Py_COMP_DIAG_IGNORE_DEPR_DECLS -#ifdef Py_GIL_DISABLED - return _Py_atomic_load_ssize_relaxed(&a->ob_shash); -#else - return a->ob_shash; -#endif + a->ob_shash = hash; _Py_COMP_DIAG_POP } +#define get_ob_shash(op) _PyBytes_GET_CACHED_HASH(op) + /* For PyBytes_FromString(), the parameter 'str' points to a null-terminated @@ -98,8 +114,36 @@ _Py_COMP_DIAG_POP PyBytes_FromStringAndSize()) or the length of the string in the 'str' parameter (for PyBytes_FromString()). */ + +// Allocate a new bytes object with contents left uninitialized. The caller is +// responsible to fill the contents. size must be greater than 0. +static PyObject * +bytes_alloc(Py_ssize_t size) +{ + assert(size >= 1); + + if ((size_t)size > (size_t)PY_SSIZE_T_MAX - PyBytesObject_SIZE) { + PyErr_SetString(PyExc_OverflowError, + "byte string is too large"); + return NULL; + } + size_t alloc = PyBytesObject_SIZE + size; + + /* Inline PyObject_NewVar */ + PyBytesObject *op = (PyBytesObject *)PyObject_Malloc(alloc); + if (op == NULL) { + return PyErr_NoMemory(); + } + + _PyObject_InitVar(_PyVarObject_CAST(op), &PyBytes_Type, size); + set_ob_shash_unsafe(op, -1); + op->ob_sval[size] = '\0'; + return (PyObject *) op; +} + +// Create a new bytes object with contents initialized to zero. size can be 0. static PyObject * -_PyBytes_FromSize(Py_ssize_t size, int use_calloc) +_PyBytes_FromSizeZero(Py_ssize_t size) { PyBytesObject *op; assert(size >= 0); @@ -113,81 +157,77 @@ _PyBytes_FromSize(Py_ssize_t size, int use_calloc) "byte string is too large"); return NULL; } + size_t alloc = PyBytesObject_SIZE + size; /* Inline PyObject_NewVar */ - if (use_calloc) - op = (PyBytesObject *)PyObject_Calloc(1, PyBytesObject_SIZE + size); - else - op = (PyBytesObject *)PyObject_Malloc(PyBytesObject_SIZE + size); + op = (PyBytesObject *)PyObject_Calloc(1, alloc); if (op == NULL) { return PyErr_NoMemory(); } _PyObject_InitVar((PyVarObject*)op, &PyBytes_Type, size); - set_ob_shash(op, -1); - if (!use_calloc) { - op->ob_sval[size] = '\0'; + set_ob_shash_unsafe(op, -1); + // op->ob_sval[size] is equal to '\0' + return (PyObject *) op; +} + +// Similar to PyBytes_FromStringAndSize(), but str must not be NULL. +static PyObject * +_PyBytes_FromStringAndSize(const char *str, Py_ssize_t size) +{ + assert(str != NULL); + assert(size >= 0); + + if (size == 0) { + return bytes_get_empty(); } + if (size == 1) { + return bytes_get_char((uint8_t)str[0]); + } + + PyBytesObject *op = (PyBytesObject *)bytes_alloc(size); + if (op == NULL) { + return NULL; + } + memcpy(op->ob_sval, str, size); return (PyObject *) op; } PyObject * PyBytes_FromStringAndSize(const char *str, Py_ssize_t size) { - PyBytesObject *op; if (size < 0) { PyErr_SetString(PyExc_SystemError, "Negative size passed to PyBytes_FromStringAndSize"); return NULL; } - if (size == 1 && str != NULL) { - op = CHARACTER(*str & 255); - assert(_Py_IsImmortal(op)); - return (PyObject *)op; + + if (str != NULL) { + return _PyBytes_FromStringAndSize(str, size); } - if (size == 0) { - return bytes_get_empty(); + else { + if (size == 0) { + return bytes_get_empty(); + } + return bytes_alloc(size); } - - op = (PyBytesObject *)_PyBytes_FromSize(size, 0); - if (op == NULL) - return NULL; - if (str == NULL) - return (PyObject *) op; - - memcpy(op->ob_sval, str, size); - return (PyObject *) op; } PyObject * PyBytes_FromString(const char *str) { - size_t size; - PyBytesObject *op; - assert(str != NULL); - size = strlen(str); - if (size > PY_SSIZE_T_MAX - PyBytesObject_SIZE) { - PyErr_SetString(PyExc_OverflowError, - "byte string is too long"); - return NULL; - } - + size_t size = strlen(str); if (size == 0) { return bytes_get_empty(); } - else if (size == 1) { - op = CHARACTER(*str & 255); - assert(_Py_IsImmortal(op)); - return (PyObject *)op; + if (size == 1) { + return bytes_get_char((uint8_t)str[0]); } - /* Inline PyObject_NewVar */ - op = (PyBytesObject *)PyObject_Malloc(PyBytesObject_SIZE + size); + PyBytesObject *op = (PyBytesObject *)bytes_alloc(size); if (op == NULL) { return PyErr_NoMemory(); } - _PyObject_InitVar((PyVarObject*)op, &PyBytes_Type, size); - set_ob_shash(op, -1); memcpy(op->ob_sval, str, size+1); return (PyObject *) op; } @@ -197,73 +237,77 @@ static char* bytes_fromformat(PyBytesWriter *writer, Py_ssize_t writer_pos, const char *format, va_list vargs) { - const char *f; - const char *p; - Py_ssize_t prec; - int longflag; - int size_tflag; /* Longest 64-bit formatted numbers: - "18446744073709551615\0" (21 bytes) - "-9223372036854775808\0" (21 bytes) Decimal takes the most space (it isn't enough for octal.) Longest 64-bit pointer representation: - "0xffffffffffffffff\0" (19 bytes). */ + "0xffffffffffffffff\0" (19 bytes). + + Longest 64-bit "%p" with "0x" prefix: len(hex(2**64-1)+'\0') = 19. + */ char buffer[21]; char *s = (char*)PyBytesWriter_GetData(writer) + writer_pos; -#define WRITE_BYTES_LEN(str, len_expr) \ +#define WRITE_BYTES(str, len_expr) \ do { \ - size_t len = (len_expr); \ - s = PyBytesWriter_GrowAndUpdatePointer(writer, len, s); \ - if (s == NULL) { \ - goto error; \ + size_t _len = (len_expr); \ + size_t _prealloc = (f - p + 1); \ + if (_len > _prealloc) { \ + s = PyBytesWriter_GrowAndUpdatePointer(writer, _len - _prealloc, s); \ + if (s == NULL) { \ + return NULL; \ + } \ } \ - memcpy(s, (str), len); \ - s += len; \ + memcpy(s, (str), _len); \ + s += _len; \ } while (0) -#define WRITE_BYTES(str) WRITE_BYTES_LEN(str, strlen(str)) - for (f = format; *f; f++) { + for (const char *f = format; *f; f++) { if (*f != '%') { *s++ = *f; continue; } - p = f++; + const char *p = f++; /* ignore the width (ex: 10 in "%10s") */ while (Py_ISDIGIT(*f)) f++; /* parse the precision (ex: 10 in "%.10s") */ - prec = 0; + Py_ssize_t prec = 0; if (*f == '.') { f++; for (; Py_ISDIGIT(*f); f++) { prec = (prec * 10) + (*f - '0'); } } + assert(prec >= 0); - while (*f && *f != '%' && !Py_ISALPHA(*f)) + while (*f && *f != '%' && !Py_ISALPHA(*f)) { f++; + } /* handle the long flag ('l'), but only for %ld and %lu. others can be added when necessary. */ - longflag = 0; + int longflag = 0; if (*f == 'l' && (f[1] == 'd' || f[1] == 'u')) { longflag = 1; ++f; } /* handle the size_t flag ('z'). */ - size_tflag = 0; + int size_tflag = 0; if (*f == 'z' && (f[1] == 'd' || f[1] == 'u')) { size_tflag = 1; ++f; } + Py_ssize_t len; + switch (*f) { case 'c': { @@ -272,7 +316,7 @@ bytes_fromformat(PyBytesWriter *writer, Py_ssize_t writer_pos, PyErr_SetString(PyExc_OverflowError, "PyBytes_FromFormatV(): %c format " "expects an integer in range [0; 255]"); - goto error; + return NULL; } *s++ = (unsigned char)c; break; @@ -280,74 +324,77 @@ bytes_fromformat(PyBytesWriter *writer, Py_ssize_t writer_pos, case 'd': if (longflag) { - sprintf(buffer, "%ld", va_arg(vargs, long)); + len = sprintf(buffer, "%ld", va_arg(vargs, long)); } else if (size_tflag) { - sprintf(buffer, "%zd", va_arg(vargs, Py_ssize_t)); + len = sprintf(buffer, "%zd", va_arg(vargs, Py_ssize_t)); } else { - sprintf(buffer, "%d", va_arg(vargs, int)); + len = sprintf(buffer, "%d", va_arg(vargs, int)); } - assert(strlen(buffer) < sizeof(buffer)); - WRITE_BYTES(buffer); + assert(1 <= len && len < (Py_ssize_t)sizeof(buffer)); + WRITE_BYTES(buffer, len); break; case 'u': if (longflag) { - sprintf(buffer, "%lu", va_arg(vargs, unsigned long)); + len = sprintf(buffer, "%lu", va_arg(vargs, unsigned long)); } else if (size_tflag) { - sprintf(buffer, "%zu", va_arg(vargs, size_t)); + len = sprintf(buffer, "%zu", va_arg(vargs, size_t)); } else { - sprintf(buffer, "%u", va_arg(vargs, unsigned int)); + len = sprintf(buffer, "%u", va_arg(vargs, unsigned int)); } - assert(strlen(buffer) < sizeof(buffer)); - WRITE_BYTES(buffer); + assert(1 <= len && len < (Py_ssize_t)sizeof(buffer)); + WRITE_BYTES(buffer, len); break; case 'i': - sprintf(buffer, "%i", va_arg(vargs, int)); - assert(strlen(buffer) < sizeof(buffer)); - WRITE_BYTES(buffer); + len = sprintf(buffer, "%i", va_arg(vargs, int)); + assert(1 <= len && len < (Py_ssize_t)sizeof(buffer)); + WRITE_BYTES(buffer, len); break; case 'x': - sprintf(buffer, "%x", va_arg(vargs, int)); - assert(strlen(buffer) < sizeof(buffer)); - WRITE_BYTES(buffer); + len = sprintf(buffer, "%x", va_arg(vargs, int)); + assert(1 <= len && len < (Py_ssize_t)sizeof(buffer)); + WRITE_BYTES(buffer, len); break; case 's': { - Py_ssize_t i; - - p = va_arg(vargs, const char*); - if (prec <= 0) { - i = strlen(p); + const char *str = va_arg(vargs, const char*); + if (prec == 0) { + len = strlen(str); } else { - i = 0; - while (i < prec && p[i]) { - i++; + const char *end = memchr(str, 0, prec); + if (end != NULL) { + len = (end - str); + } + else { + len = (size_t)prec; } } - WRITE_BYTES_LEN(p, i); + WRITE_BYTES(str, len); break; } case 'p': - sprintf(buffer, "%p", va_arg(vargs, void*)); - assert(strlen(buffer) < sizeof(buffer)); + len = sprintf(buffer, "%p", va_arg(vargs, void*)); + assert(1 <= len && len < (Py_ssize_t)sizeof(buffer)); /* %p is ill-defined: ensure leading 0x. */ - if (buffer[1] == 'X') + if (buffer[1] == 'X') { buffer[1] = 'x'; + } else if (buffer[1] != 'x') { - memmove(buffer+2, buffer, strlen(buffer)+1); + memmove(buffer + 2, buffer, len + 1); buffer[0] = '0'; buffer[1] = 'x'; + len += 2; } - WRITE_BYTES(buffer); + WRITE_BYTES(buffer, len); break; case '%': @@ -355,19 +402,19 @@ bytes_fromformat(PyBytesWriter *writer, Py_ssize_t writer_pos, break; default: - /* invalid format string: copy unformatted string and exit */ - WRITE_BYTES(p); + // Invalid format string: copy unformatted string and exit. + // No need to grow the writer buffer, we already preallocated + // enough bytes. + len = strlen(p); + memcpy(s, p, len); + s += len; return s; } } -#undef WRITE_BYTES -#undef WRITE_BYTES_LEN - return s; - error: - return NULL; +#undef WRITE_BYTES } @@ -485,7 +532,7 @@ formatfloat(PyObject *v, Py_ssize_t argidx, PyObject *key, return str; } - result = PyBytes_FromStringAndSize(p, len); + result = _PyBytes_FromStringAndSize(p, len); PyMem_Free(p); *p_result = result; return result != NULL ? str : NULL; @@ -605,6 +652,9 @@ format_obj(PyObject *v, Py_ssize_t argidx, PyObject *key, *plen = PyBytes_GET_SIZE(result); return result; } + else if (PyErr_Occurred()) { + return NULL; + } /* does it support buffer protocol? */ if (PyObject_CheckBuffer(v)) { /* maybe we can avoid making a copy of the buffer object here? */ @@ -700,6 +750,7 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len, char onechar; /* For byte_converter() */ Py_ssize_t alloc; + const char *start = fmt; fmt++; if (*fmt == '%') { *res++ = '%'; @@ -739,8 +790,7 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len, (Py_ssize_t)(fmtstart - format - 1)); goto error; } - key = PyBytes_FromStringAndSize(keystart, - keylen); + key = _PyBytes_FromStringAndSize(keystart, keylen); if (key == NULL) goto error; if (args_owned) { @@ -802,6 +852,10 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len, goto error; } if (width < 0) { + if (width == PY_SSIZE_T_MIN) { + FORMAT_ERROR(PyExc_OverflowError, "too big for width%s", ""); + goto error; + } flags |= F_LJUST; width = -width; } @@ -1062,9 +1116,10 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len, alloc = width; if (sign != 0 && len == width) alloc++; - /* 2: size preallocated for %s */ - if (alloc > 2) { - res = PyBytesWriter_GrowAndUpdatePointer(writer, alloc - 2, res); + /* size preallocated for the format */ + Py_ssize_t prealloc = fmt - start; + if (alloc > prealloc) { + res = PyBytesWriter_GrowAndUpdatePointer(writer, alloc - prealloc, res); if (res == NULL) { Py_XDECREF(temp); goto error; @@ -1568,10 +1623,15 @@ _PyBytes_Concat(PyObject *a, PyObject *b) goto done; } - result = PyBytes_FromStringAndSize(NULL, va.len + vb.len); - if (result != NULL) { - memcpy(PyBytes_AS_STRING(result), va.buf, va.len); - memcpy(PyBytes_AS_STRING(result) + va.len, vb.buf, vb.len); + if ((va.len + vb.len) != 0) { + result = bytes_alloc(va.len + vb.len); + if (result != NULL) { + memcpy(PyBytes_AS_STRING(result), va.buf, va.len); + memcpy(PyBytes_AS_STRING(result) + va.len, vb.buf, vb.len); + } + } + else { + result = bytes_get_empty(); } done: @@ -1596,26 +1656,22 @@ _PyBytes_Repeat(PyObject *self, Py_ssize_t n) "repeated bytes are too long"); return NULL; } - Py_ssize_t size = Py_SIZE(a) * n; - if (size == Py_SIZE(a) && PyBytes_CheckExact(a)) { + Py_ssize_t old_size = Py_SIZE(a); + Py_ssize_t new_size = old_size * n; + if (new_size == old_size && PyBytes_CheckExact(a)) { return Py_NewRef(a); } - size_t nbytes = (size_t)size; - if (nbytes + PyBytesObject_SIZE <= nbytes) { - PyErr_SetString(PyExc_OverflowError, - "repeated bytes are too long"); - return NULL; + + if (new_size == 0) { + return bytes_get_empty(); } - PyBytesObject *op = PyObject_Malloc(PyBytesObject_SIZE + nbytes); + + PyBytesObject *op = (PyBytesObject *)bytes_alloc(new_size); if (op == NULL) { return PyErr_NoMemory(); } - _PyObject_InitVar((PyVarObject*)op, &PyBytes_Type, size); - set_ob_shash(op, -1); - op->ob_sval[size] = '\0'; - - _PyBytes_RepeatBuffer(op->ob_sval, size, a->ob_sval, Py_SIZE(a)); + _PyBytes_RepeatBuffer(op->ob_sval, new_size, a->ob_sval, old_size); return (PyObject *) op; } @@ -1751,7 +1807,6 @@ bytes_subscript(PyObject *op, PyObject* item) size_t cur; const char* source_buf; char* result_buf; - PyObject* result; if (PySlice_Unpack(item, &start, &stop, &step) < 0) { return NULL; @@ -1768,22 +1823,22 @@ bytes_subscript(PyObject *op, PyObject* item) return Py_NewRef(self); } else if (step == 1) { - return PyBytes_FromStringAndSize( + return _PyBytes_FromStringAndSize( PyBytes_AS_STRING(self) + start, slicelength); } else { source_buf = PyBytes_AS_STRING(self); - result = PyBytes_FromStringAndSize(NULL, slicelength); - if (result == NULL) + PyObject* result = bytes_alloc(slicelength); + if (result == NULL) { return NULL; + } result_buf = PyBytes_AS_STRING(result); for (cur = start, i = 0; i < slicelength; cur += step, i++) { result_buf[i] = source_buf[cur]; } - return result; } } @@ -1839,7 +1894,7 @@ bytes___bytes___impl(PyBytesObject *self) return Py_NewRef(self); } else { - return PyBytes_FromStringAndSize(self->ob_sval, Py_SIZE(self)); + return _PyBytes_FromStringAndSize(self->ob_sval, Py_SIZE(self)); } } @@ -2130,7 +2185,7 @@ do_xstrip(PyBytesObject *self, int striptype, PyObject *sepobj) return Py_NewRef(self); } else - return PyBytes_FromStringAndSize(s+i, j-i); + return _PyBytes_FromStringAndSize(s+i, j-i); } @@ -2159,7 +2214,7 @@ do_strip(PyBytesObject *self, int striptype) return Py_NewRef(self); } else - return PyBytes_FromStringAndSize(s+i, j-i); + return _PyBytes_FromStringAndSize(s+i, j-i); } @@ -2275,7 +2330,6 @@ bytes_translate_impl(PyBytesObject *self, PyObject *table, PyObject *input_obj = (PyObject*)self; const char *output_start, *del_table_chars=NULL; Py_ssize_t inlen, tablen, dellen = 0; - PyObject *result; int trans_table[256]; if (PyBytes_Check(table)) { @@ -2320,13 +2374,13 @@ bytes_translate_impl(PyBytesObject *self, PyObject *table, } inlen = PyBytes_GET_SIZE(input_obj); - result = PyBytes_FromStringAndSize((char *)NULL, inlen); - if (result == NULL) { + PyBytesWriter *writer = PyBytesWriter_Create(inlen); + if (writer == NULL) { PyBuffer_Release(&del_table_view); PyBuffer_Release(&table_view); return NULL; } - output_start = output = PyBytes_AS_STRING(result); + output_start = output = PyBytesWriter_GetData(writer); input = PyBytes_AS_STRING(input_obj); if (dellen == 0 && table_chars != NULL) { @@ -2335,14 +2389,21 @@ bytes_translate_impl(PyBytesObject *self, PyObject *table, c = Py_CHARMASK(*input++); *output++ = table_chars[c]; } + /* Check if anything changed (for returning original object) */ /* We save this check until the end so that the compiler will */ /* unroll the loop above leading to MUCH faster code. */ - if (PyBytes_CheckExact(input_obj)) { - if (memcmp(PyBytes_AS_STRING(input_obj), output_start, inlen) == 0) { - Py_SETREF(result, Py_NewRef(input_obj)); - } + PyObject *result; + if (PyBytes_CheckExact(input_obj) + && memcmp(PyBytes_AS_STRING(input_obj), output_start, inlen) == 0) + { + PyBytesWriter_Discard(writer); + result = Py_NewRef(input_obj); + } + else { + result = PyBytesWriter_Finish(writer); } + PyBuffer_Release(&del_table_view); PyBuffer_Release(&table_view); return result; @@ -2369,13 +2430,11 @@ bytes_translate_impl(PyBytesObject *self, PyObject *table, changed = 1; } if (!changed && PyBytes_CheckExact(input_obj)) { - Py_DECREF(result); + PyBytesWriter_Discard(writer); return Py_NewRef(input_obj); } /* Fix the size of the resulting byte string */ - if (inlen > 0) - _PyBytes_Resize(&result, output - output_start); - return result; + return PyBytesWriter_FinishWithPointer(writer, output); } @@ -2460,15 +2519,15 @@ bytes_removeprefix_impl(PyBytesObject *self, Py_buffer *prefix) && prefix_len > 0 && memcmp(self_start, prefix_start, prefix_len) == 0) { - return PyBytes_FromStringAndSize(self_start + prefix_len, - self_len - prefix_len); + return _PyBytes_FromStringAndSize(self_start + prefix_len, + self_len - prefix_len); } if (PyBytes_CheckExact(self)) { return Py_NewRef(self); } - return PyBytes_FromStringAndSize(self_start, self_len); + return _PyBytes_FromStringAndSize(self_start, self_len); } /*[clinic input] @@ -2499,15 +2558,15 @@ bytes_removesuffix_impl(PyBytesObject *self, Py_buffer *suffix) && memcmp(self_start + self_len - suffix_len, suffix_start, suffix_len) == 0) { - return PyBytes_FromStringAndSize(self_start, - self_len - suffix_len); + return _PyBytes_FromStringAndSize(self_start, + self_len - suffix_len); } if (PyBytes_CheckExact(self)) { return Py_NewRef(self); } - return PyBytes_FromStringAndSize(self_start, self_len); + return _PyBytes_FromStringAndSize(self_start, self_len); } /*[clinic input] @@ -2694,9 +2753,10 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray) if (Py_ISSPACE(*str)) { do { str++; + if (str >= end) { + goto done; + } } while (Py_ISSPACE(*str)); - if (str >= end) - break; } top = _PyLong_DigitValue[*str]; @@ -2704,16 +2764,16 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray) invalid_char = str - start; goto error; } + str++; + if (str >= end) { + invalid_char = -1; + goto error; + } bot = _PyLong_DigitValue[*str]; if (bot >= 16) { - /* Check if we had a second digit */ - if (str >= end){ - invalid_char = -1; - } else { - invalid_char = str - start; - } + invalid_char = str - start; goto error; } str++; @@ -2721,6 +2781,7 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray) *buf++ = (unsigned char)((top << 4) + bot); } + done: if (view.obj != NULL) { PyBuffer_Release(&view); } @@ -2864,6 +2925,7 @@ static PyObject * bytes_subtype_new(PyTypeObject *, PyObject *); /*[clinic input] +@vectorcall @classmethod bytes.__new__ as bytes_new @@ -2876,7 +2938,7 @@ bytes.__new__ as bytes_new static PyObject * bytes_new_impl(PyTypeObject *type, PyObject *x, const char *encoding, const char *errors) -/*[clinic end generated code: output=1e0c471be311a425 input=f0a966d19b7262b4]*/ +/*[clinic end generated code: output=1e0c471be311a425 input=b0248d22e221a095]*/ { PyObject *bytes; PyObject *func; @@ -2945,7 +3007,7 @@ bytes_new_impl(PyTypeObject *type, PyObject *x, const char *encoding, PyErr_SetString(PyExc_ValueError, "negative count"); return NULL; } - bytes = _PyBytes_FromSize(size, 1); + bytes = _PyBytes_FromSizeZero(size); } } else { @@ -2985,80 +3047,39 @@ _PyBytes_FromBuffer(PyObject *x) return NULL; } -static PyObject* -_PyBytes_FromList(PyObject *x) +/* Fast path for a list or tuple of ints. + Return 1 on success (*result set to the new bytes object), + 0 to fall back to the slow path, or -1 on error (with an exception set). */ +static int +_PyBytes_FromSequence_lock_held(PyObject *x, PyObject **result) { - Py_ssize_t size = PyList_GET_SIZE(x); + *result = NULL; + Py_ssize_t size = PySequence_Fast_GET_SIZE(x); PyBytesWriter *writer = PyBytesWriter_Create(size); if (writer == NULL) { - return NULL; + return -1; } char *str = PyBytesWriter_GetData(writer); - size = _PyBytesWriter_GetAllocated(writer); - for (Py_ssize_t i = 0; i < PyList_GET_SIZE(x); i++) { - PyObject *item = _PyList_GetItemRef((PyListObject *)x, i); - if (item == NULL) { - goto error; + PyObject *const *items = PySequence_Fast_ITEMS(x); + for (Py_ssize_t i = 0; i < size; i++) { + Py_ssize_t value = PyLong_AsSsize_t(items[i]); + if (value == -1 && PyErr_Occurred()) { + PyBytesWriter_Discard(writer); + PyErr_Clear(); + return 0; } - Py_ssize_t value = PyNumber_AsSsize_t(item, NULL); - Py_DECREF(item); - if (value == -1 && PyErr_Occurred()) - goto error; if (value < 0 || value >= 256) { PyErr_SetString(PyExc_ValueError, "bytes must be in range(0, 256)"); - goto error; - } - - if (i >= size) { - str = _PyBytesWriter_ResizeAndUpdatePointer(writer, size + 1, str); - if (str == NULL) { - goto error; - } - size = _PyBytesWriter_GetAllocated(writer); - } - *str++ = (char) value; - } - return PyBytesWriter_FinishWithPointer(writer, str); - -error: - PyBytesWriter_Discard(writer); - return NULL; -} - -static PyObject* -_PyBytes_FromTuple(PyObject *x) -{ - Py_ssize_t i, size = PyTuple_GET_SIZE(x); - Py_ssize_t value; - PyObject *item; - - PyBytesWriter *writer = PyBytesWriter_Create(size); - if (writer == NULL) { - return NULL; - } - char *str = PyBytesWriter_GetData(writer); - - for (i = 0; i < size; i++) { - item = PyTuple_GET_ITEM(x, i); - value = PyNumber_AsSsize_t(item, NULL); - if (value == -1 && PyErr_Occurred()) - goto error; - - if (value < 0 || value >= 256) { - PyErr_SetString(PyExc_ValueError, - "bytes must be in range(0, 256)"); - goto error; + PyBytesWriter_Discard(writer); + return -1; } *str++ = (char) value; } - return PyBytesWriter_Finish(writer); - - error: - PyBytesWriter_Discard(writer); - return NULL; + *result = PyBytesWriter_Finish(writer); + return *result != NULL ? 1 : -1; } static PyObject * @@ -3075,8 +3096,8 @@ _PyBytes_FromIterator(PyObject *it, PyObject *x) if (writer == NULL) { return NULL; } + size = _PyBytesWriter_ResizeToAllocated(writer); char *str = PyBytesWriter_GetData(writer); - size = _PyBytesWriter_GetAllocated(writer); /* Run the iterator to exhaustion */ for (i = 0; ; i++) { @@ -3110,7 +3131,9 @@ _PyBytes_FromIterator(PyObject *it, PyObject *x) if (str == NULL) { goto error; } - size = _PyBytesWriter_GetAllocated(writer); + + // Set the writer size to its allocated size + size = _PyBytesWriter_ResizeToAllocated(writer); } *str++ = (char) value; } @@ -3139,11 +3162,15 @@ PyBytes_FromObject(PyObject *x) if (PyObject_CheckBuffer(x)) return _PyBytes_FromBuffer(x); - if (PyList_CheckExact(x)) - return _PyBytes_FromList(x); - - if (PyTuple_CheckExact(x)) - return _PyBytes_FromTuple(x); + if (PyList_CheckExact(x) || PyTuple_CheckExact(x)) { + int rc; + Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST(x); + rc = _PyBytes_FromSequence_lock_held(x, &result); + Py_END_CRITICAL_SECTION_SEQUENCE_FAST(); + if (rc != 0) { + return result; + } + } if (!PyUnicode_Check(x)) { it = PyObject_GetIter(x); @@ -3169,13 +3196,14 @@ PyBytes_FromObject(PyObject *x) * This allocator will be removed when ob_shash is removed. */ static PyObject * -bytes_alloc(PyTypeObject *self, Py_ssize_t nitems) +bytes_type_alloc(PyTypeObject *self, Py_ssize_t nitems) { + // Initialize memory to zero PyBytesObject *obj = (PyBytesObject*)PyType_GenericAlloc(self, nitems); if (obj == NULL) { return NULL; } - set_ob_shash(obj, -1); + set_ob_shash_unsafe(obj, -1); return (PyObject*)obj; } @@ -3190,10 +3218,9 @@ bytes_subtype_new(PyTypeObject *type, PyObject *tmp) n = PyBytes_GET_SIZE(tmp); pnew = type->tp_alloc(type, n); if (pnew != NULL) { - memcpy(PyBytes_AS_STRING(pnew), - PyBytes_AS_STRING(tmp), n+1); - set_ob_shash((PyBytesObject *)pnew, - get_ob_shash((PyBytesObject *)tmp)); + memcpy(PyBytes_AS_STRING(pnew), PyBytes_AS_STRING(tmp), n+1); + set_ob_shash_unsafe((PyBytesObject*)pnew, + get_ob_shash((PyBytesObject *)tmp)); } return pnew; } @@ -3225,12 +3252,42 @@ bytes_iteritem(PyObject *obj, Py_ssize_t index) return (_PyObjectIndexPair) { .object = l, .index = index + 1 }; } +#ifdef Py_DEBUG +void +_PyBytes_CheckOverflow(PyObject *self, void *addr, const char *type_name) +{ + // Make sure that the trailing null byte was not modified + char *data = PyBytes_AS_STRING(self); + Py_ssize_t size = PyBytes_GET_SIZE(self); + if (data[size] != '\0') { + _Py_FatalErrorFormat(__func__, + "Buffer overflow detected in %s object %p " + "at position %zd", + type_name, addr, size); + } +} + + +static void +bytes_dealloc(PyObject *op) +{ + PyBytesObject *self = _PyBytes_CAST(op); + _PyBytes_CheckOverflow(op, op, "bytes"); + Py_TYPE(self)->tp_free((PyObject *)self); +} +#endif + + PyTypeObject PyBytes_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "bytes", PyBytesObject_SIZE, sizeof(char), +#ifdef Py_DEBUG + bytes_dealloc, /* tp_dealloc */ +#else 0, /* tp_dealloc */ +#endif 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ @@ -3264,9 +3321,10 @@ PyTypeObject PyBytes_Type = { 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ - bytes_alloc, /* tp_alloc */ + bytes_type_alloc, /* tp_alloc */ bytes_new, /* tp_new */ PyObject_Free, /* tp_free */ + .tp_vectorcall = bytes_vectorcall, .tp_version_tag = _Py_TYPE_VERSION_BYTES, ._tp_iteritem = bytes_iteritem, }; @@ -3328,6 +3386,86 @@ PyBytes_ConcatAndDel(PyObject **pv, PyObject *w) } +#ifndef NDEBUG +// Make sure that a bytes object can still be mutated. +// +// Usage: assert(_PyBytes_IsMutable(obj)). +int +_PyBytes_IsMutable(PyObject *self) +{ + assert(PyBytes_Check(self)); + // Do not use _PyObject_IsUniquelyReferenced(): this function is called + // by bytearray and PyBytesWriter which can be used by multiple threads. + assert(Py_REFCNT(self) == 1); + assert(!_Py_IsImmortal(self)); + + // Check that the object is not a singleton + Py_ssize_t size = PyBytes_GET_SIZE(self); + if (size == 0) { + assert(self != bytes_get_empty()); + } + else if (size == 1) { + unsigned char ch = PyBytes_AS_STRING(self)[0]; + assert(self != (PyObject*)CHARACTER(ch)); + } + + // gh-158219: The hash value must not be cached yet. Otherwise, it means + // that the bytes object was already used in Python somehow (ex: as a + // dictionary key). + assert(get_ob_shash((PyBytesObject *)self) == -1); + + return 1; +} +#endif + + +static inline int +bytes_resize_inplace(PyObject **pv, Py_ssize_t newsize) +{ + PyObject *v = *pv; + // Do not test _PyObject_IsUniquelyReferenced(). The function is used by + // PyBytesWriter_FinishWithSize() and its caller can have its own lock. + assert(Py_REFCNT(v) == 1); + assert(PyBytes_GET_SIZE(v) >= 1); + assert(newsize >= 1); + assert(get_ob_shash((PyBytesObject *)v) == -1); + + // Only mutable bytes can be resized in-place + assert(_PyBytes_IsMutable(v)); + + if ((size_t)newsize > (size_t)PY_SSIZE_T_MAX - PyBytesObject_SIZE) { + PyErr_SetString(PyExc_OverflowError, + "byte string is too large"); + return -1; + } + +#ifdef Py_TRACE_REFS + _Py_ForgetReference(v); +#endif + _PyReftracerTrack(v, PyRefTracer_DESTROY); + + PyObject *result = PyObject_Realloc(v, PyBytesObject_SIZE + newsize); + if (result == NULL) { +#ifdef Py_TRACE_REFS + _Py_AddToAllObjects(v); +#endif + _PyReftracerTrack(v, PyRefTracer_CREATE); + + PyErr_NoMemory(); + return -1; + } + + *pv = result; + v = result; + _Py_NewReferenceNoTotal(v); + PyBytesObject *sv = (PyBytesObject *)v; + Py_SET_SIZE(sv, newsize); + sv->ob_sval[newsize] = '\0'; + assert(_PyBytes_IsMutable(*pv)); + return 0; +} + + /* The following function breaks the notion that bytes are immutable: it changes the size of a bytes object. You can think of it as creating a new bytes object and destroying the old one, only @@ -3340,67 +3478,76 @@ PyBytes_ConcatAndDel(PyObject **pv, PyObject *w) does *not* include that), and a trailing \0 byte is stored. */ +// Similar to _PyBytes_Resize(), but leaves the object unchanged on error. int -_PyBytes_Resize(PyObject **pv, Py_ssize_t newsize) +_PyBytes_ResizeKeepOnError(PyObject **pv, Py_ssize_t newsize) { - PyObject *v; - PyBytesObject *sv; - v = *pv; + PyObject *v = *pv; + if (!PyBytes_Check(v) || newsize < 0) { - *pv = 0; - Py_DECREF(v); PyErr_BadInternalCall(); return -1; } + Py_ssize_t oldsize = PyBytes_GET_SIZE(v); if (oldsize == newsize) { - /* return early if newsize equals to v->ob_size */ + // Leave the object unchanged if the new size is the same as the old + // size, even if the object is not uniquely referenced or if the hash + // value was already computed. return 0; } + if (oldsize == 0) { - *pv = _PyBytes_FromSize(newsize, 0); + assert(newsize >= 1); + PyObject *result = bytes_alloc(newsize); + if (result == NULL) { + return -1; + } + *pv = result; Py_DECREF(v); - return (*pv == NULL) ? -1 : 0; + assert(_PyBytes_IsMutable(*pv)); + return 0; } + if (newsize == 0) { - *pv = bytes_get_empty(); + *pv = bytes_get_empty(); // cannot fail Py_DECREF(v); return 0; } - if (!_PyObject_IsUniquelyReferenced(v)) { - if (oldsize < newsize) { - *pv = _PyBytes_FromSize(newsize, 0); - if (*pv) { - memcpy(PyBytes_AS_STRING(*pv), PyBytes_AS_STRING(v), oldsize); - } - } - else { - *pv = PyBytes_FromStringAndSize(PyBytes_AS_STRING(v), newsize); + + if (!_PyObject_IsUniquelyReferenced(v) + // Return a copy if the hash value was already computed + || get_ob_shash((PyBytesObject *)v) != -1) + { + // Allocate and then copy so we don't get a shared immortal + // one-character singleton! + PyObject *result = bytes_alloc(newsize); + if (!result) { + return -1; } + + memcpy(PyBytes_AS_STRING(result), PyBytes_AS_STRING(v), + Py_MIN(oldsize, newsize)); + *pv = result; Py_DECREF(v); - return (*pv == NULL) ? -1 : 0; + assert(_PyBytes_IsMutable(*pv)); + return 0; } -#ifdef Py_TRACE_REFS - _Py_ForgetReference(v); -#endif - _PyReftracerTrack(v, PyRefTracer_DESTROY); - *pv = (PyObject *) - PyObject_Realloc(v, PyBytesObject_SIZE + newsize); - if (*pv == NULL) { -#ifdef Py_REF_DEBUG - _Py_DecRefTotal(_PyThreadState_GET()); -#endif - PyObject_Free(v); - PyErr_NoMemory(); - return -1; + return bytes_resize_inplace(pv, newsize); +} + + +int +_PyBytes_Resize(PyObject **pv, Py_ssize_t newsize) +{ + int res = _PyBytes_ResizeKeepOnError(pv, newsize); + if (res < 0) { + PyObject *v = *pv; + *pv = NULL; + Py_DECREF(v); } - _Py_NewReferenceNoTotal(*pv); - sv = (PyBytesObject *) *pv; - Py_SET_SIZE(sv, newsize); - sv->ob_sval[newsize] = '\0'; - set_ob_shash(sv, -1); /* invalidate cached hash value */ - return 0; + return res; } @@ -3588,18 +3735,20 @@ _PyBytes_RepeatBuffer(char* dest, Py_ssize_t len_dest, // --- PyBytesWriter API ----------------------------------------------------- -static inline char* -byteswriter_data(PyBytesWriter *writer) -{ - return _PyBytesWriter_GetData(writer); -} +// Byte pattern to fill newly allocated bytes +#define PyBytesWrite_NEW_BYTE 0xff + +// Use a value different than NUL (0) to be able to detect overflow writing +// one extra NUL byte which is a common error. +#define PyBytesWriter_CANARY_BYTE PYMEM_DEADBYTE static inline Py_ssize_t byteswriter_allocated(PyBytesWriter *writer) { if (writer->obj == NULL) { - return sizeof(writer->small_buffer); + // Reserve the last byte for the canary byte + return sizeof(writer->small_buffer) - 1; } else if (writer->use_bytearray) { return PyByteArray_GET_SIZE(writer->obj); @@ -3610,6 +3759,67 @@ byteswriter_allocated(PyBytesWriter *writer) } +#ifdef Py_DEBUG +static void +byteswriter_write_canary_byte(PyBytesWriter *writer) +{ + unsigned char *data = (unsigned char*)_PyBytesWriter_GetData(writer); + data[writer->size] = PyBytesWriter_CANARY_BYTE; +} + + +static void +byteswriter_reset_trailing_byte(PyBytesWriter *writer) +{ + // PyBytesWriter writes non-zero canary byte as the last byte. + // bytes/bytearray expects the last byte to be a null byte. + // Reset the last byte to null for bytes/bytearray. + Py_ssize_t allocated = byteswriter_allocated(writer); + char *data = _PyBytesWriter_GetData(writer); + data[allocated] = '\0'; +} +#endif + + +#ifndef NDEBUG +static int +byteswriter_check_consistency(PyBytesWriter *writer) +{ + PyObject *obj = writer->obj; + if (obj != NULL) { + if (writer->use_bytearray) { + assert(PyByteArray_CheckExact(obj)); + // Do not use _PyObject_IsUniquelyReferenced(): the caller can have + // its own lock to prevent a writer from being used by two threads + // at the same time. + assert(Py_REFCNT(obj) == 1); + PyByteArrayObject *bytearray = (PyByteArrayObject*)obj; + obj = bytearray->ob_bytes_object; + assert(obj != NULL); + } + + // Code adapted from _PyBytes_IsMutable() + assert(PyBytes_CheckExact(obj)); + assert(_PyBytes_IsMutable(obj)); + // -1 since the last small buffer byte is used as the canary byte + assert((size_t)PyBytes_GET_SIZE(obj) > (sizeof(writer->small_buffer) - 1)); + } + +#ifdef Py_DEBUG + const unsigned char *data = (const unsigned char*)_PyBytesWriter_GetData(writer); + unsigned char canary = data[writer->size]; + if (canary != PyBytesWriter_CANARY_BYTE) { + _Py_FatalErrorFormat(__func__, + "Buffer overflow detected in PyBytesWriter %p " + "at position %zd", + writer, writer->size); + } +#endif + return 1; +} +#endif + + #ifdef MS_WINDOWS /* On Windows, overallocate by 50% is the best factor */ # define OVERALLOCATE_FACTOR 2 @@ -3619,64 +3829,79 @@ byteswriter_allocated(PyBytesWriter *writer) #endif static inline int -byteswriter_resize(PyBytesWriter *writer, Py_ssize_t size, int resize) +byteswriter_resize(PyBytesWriter *writer, Py_ssize_t new_size, int resize) { - assert(size >= 0); + assert(new_size >= 1); Py_ssize_t old_allocated = byteswriter_allocated(writer); - if (size <= old_allocated) { + if (new_size <= old_allocated) { + // Do not shrink the buffer before PyBytesWriter_FinishWithSize() return 0; } - if (resize & writer->overallocate) { - if (size <= (PY_SSIZE_T_MAX - size / OVERALLOCATE_FACTOR)) { - size += size / OVERALLOCATE_FACTOR; + Py_ssize_t alloc = new_size; + if (resize && writer->overallocate) { + if (alloc <= (PY_SSIZE_T_MAX - alloc / OVERALLOCATE_FACTOR)) { + alloc += alloc / OVERALLOCATE_FACTOR; } } if (writer->obj != NULL) { if (writer->use_bytearray) { - if (PyByteArray_Resize(writer->obj, size)) { + if (PyByteArray_Resize(writer->obj, alloc)) { +#ifdef Py_DEBUG + // bytearray can override the canary byte on error + byteswriter_write_canary_byte(writer); +#endif + assert(byteswriter_check_consistency(writer)); return -1; } } else { - if (_PyBytes_Resize(&writer->obj, size)) { + // Can raise MemoryError or OverflowError + if (_PyBytes_ResizeKeepOnError(&writer->obj, alloc)) { + assert(writer->obj != NULL); + assert(byteswriter_check_consistency(writer)); return -1; } + assert(_PyBytes_IsMutable(writer->obj)); } assert(writer->obj != NULL); } - else if (writer->use_bytearray) { - writer->obj = PyByteArray_FromStringAndSize(NULL, size); - if (writer->obj == NULL) { - return -1; - } - if (resize) { - assert((size_t)size > sizeof(writer->small_buffer)); - memcpy(PyByteArray_AS_STRING(writer->obj), - writer->small_buffer, - sizeof(writer->small_buffer)); - } - } else { - writer->obj = PyBytes_FromStringAndSize(NULL, size); - if (writer->obj == NULL) { - return -1; + char *data; + if (writer->use_bytearray) { + writer->obj = PyByteArray_FromStringAndSize(NULL, alloc); + if (writer->obj == NULL) { + return -1; + } + data = PyByteArray_AS_STRING(writer->obj); + } + else { + writer->obj = bytes_alloc(alloc); + if (writer->obj == NULL) { + return -1; + } + assert(_PyBytes_IsMutable(writer->obj)); + data = PyBytes_AS_STRING(writer->obj); } + if (resize) { - assert((size_t)size > sizeof(writer->small_buffer)); - memcpy(PyBytes_AS_STRING(writer->obj), - writer->small_buffer, - sizeof(writer->small_buffer)); + // Copy data from the small buffer + Py_ssize_t old_size = writer->size; + assert((size_t)old_size <= sizeof(writer->small_buffer)); + assert(old_size <= alloc); + memcpy(data, writer->small_buffer, old_size); } } #ifdef Py_DEBUG Py_ssize_t allocated = byteswriter_allocated(writer); - if (resize && allocated > old_allocated) { - memset(byteswriter_data(writer) + old_allocated, 0xff, - allocated - old_allocated); + if (resize) { + Py_ssize_t old_size = writer->size; + assert(allocated > old_size); + memset(_PyBytesWriter_GetData(writer) + old_size, PyBytesWrite_NEW_BYTE, + allocated - old_size); } #endif @@ -3701,20 +3926,29 @@ byteswriter_create(Py_ssize_t size, int use_bytearray) } } writer->obj = NULL; - writer->size = 0; + writer->size = size; writer->use_bytearray = use_bytearray; writer->overallocate = !use_bytearray; - if (size >= 1) { + Py_ssize_t allocated = sizeof(writer->small_buffer) - 1; + if (size > allocated) { if (byteswriter_resize(writer, size, 0) < 0) { +#ifdef Py_DEBUG + // Write the canary byte so byteswriter_check_consistency() + // doesn't fail in PyBytesWriter_Discard() + writer->size = 0; + byteswriter_write_canary_byte(writer); +#endif PyBytesWriter_Discard(writer); return NULL; } - writer->size = size; } #ifdef Py_DEBUG - memset(byteswriter_data(writer), 0xff, byteswriter_allocated(writer)); + memset(_PyBytesWriter_GetData(writer), PyBytesWrite_NEW_BYTE, + byteswriter_allocated(writer)); + byteswriter_write_canary_byte(writer); #endif + assert(byteswriter_check_consistency(writer)); return writer; } @@ -3738,43 +3972,83 @@ PyBytesWriter_Discard(PyBytesWriter *writer) return; } - Py_XDECREF(writer->obj); + assert(byteswriter_check_consistency(writer)); + if (writer->obj != NULL) { +#ifdef Py_DEBUG + byteswriter_reset_trailing_byte(writer); +#endif + Py_DECREF(writer->obj); + } _Py_FREELIST_FREE(bytes_writers, writer, PyMem_Free); } -PyObject* -PyBytesWriter_FinishWithSize(PyBytesWriter *writer, Py_ssize_t size) +static inline PyObject* +byteswriter_finish_with_size(PyBytesWriter *writer, Py_ssize_t final_size) { + assert(byteswriter_check_consistency(writer)); + PyObject *result; - if (size == 0) { + if (final_size == 0 && !writer->use_bytearray) { result = bytes_get_empty(); + if (writer->obj != NULL) { +#ifdef Py_DEBUG + byteswriter_reset_trailing_byte(writer); +#endif + Py_DECREF(writer->obj); + writer->obj = NULL; + } } else if (writer->obj != NULL) { + // Truncate the bytes/bytearray object if needed +#ifdef Py_DEBUG + byteswriter_reset_trailing_byte(writer); +#endif + if (writer->use_bytearray) { - if (size != PyByteArray_GET_SIZE(writer->obj)) { - if (PyByteArray_Resize(writer->obj, size)) { + if (final_size != PyByteArray_GET_SIZE(writer->obj)) { + if (PyByteArray_Resize(writer->obj, final_size)) { goto error; } } } else { - if (size != PyBytes_GET_SIZE(writer->obj)) { - if (_PyBytes_Resize(&writer->obj, size)) { + if (final_size == 1) { + unsigned char ch = PyBytes_AS_STRING(writer->obj)[0]; + Py_SETREF(writer->obj, bytes_get_char(ch)); + } + else if (final_size != PyBytes_GET_SIZE(writer->obj)) { + if (bytes_resize_inplace(&writer->obj, final_size)) { goto error; } } } + result = writer->obj; writer->obj = NULL; } - else if (writer->use_bytearray) { - result = PyByteArray_FromStringAndSize(writer->small_buffer, size); - } else { - result = PyBytes_FromStringAndSize(writer->small_buffer, size); + // Create an object from the small buffer + const char *buffer = (const char *)writer->small_buffer; + if (writer->use_bytearray) { + result = PyByteArray_FromStringAndSize(buffer, final_size); + } + else { + if (final_size == 1) { + result = bytes_get_char((uint8_t)buffer[0]); + } + else { + result = bytes_alloc(final_size); + if (result == NULL) { + goto error; + } + memcpy(PyBytes_AS_STRING(result), buffer, final_size); + } + } } - PyBytesWriter_Discard(writer); + + assert(writer->obj == NULL); + _Py_FREELIST_FREE(bytes_writers, writer, PyMem_Free); return result; error: @@ -3782,23 +4056,36 @@ PyBytesWriter_FinishWithSize(PyBytesWriter *writer, Py_ssize_t size) return NULL; } +PyObject* +PyBytesWriter_FinishWithSize(PyBytesWriter *writer, Py_ssize_t size) +{ + if (size < 0) { + PyErr_Format(PyExc_ValueError, "size must be positive"); + goto error; + } + if (size > writer->size) { + PyErr_SetString(PyExc_ValueError, "size larger than allocated size"); + goto error; + } + return byteswriter_finish_with_size(writer, size); + +error: + PyBytesWriter_Discard(writer); + return NULL; +} + PyObject* PyBytesWriter_Finish(PyBytesWriter *writer) { - return PyBytesWriter_FinishWithSize(writer, writer->size); + return byteswriter_finish_with_size(writer, writer->size); } PyObject* PyBytesWriter_FinishWithPointer(PyBytesWriter *writer, void *buf) { - Py_ssize_t size = (char*)buf - byteswriter_data(writer); - if (size < 0 || size > byteswriter_allocated(writer)) { - PyBytesWriter_Discard(writer); - PyErr_SetString(PyExc_ValueError, "invalid end pointer"); - return NULL; - } - + Py_ssize_t size = (char*)buf - _PyBytesWriter_GetData(writer); + // Call PyBytesWriter_FinishWithSize() to check size return PyBytesWriter_FinishWithSize(writer, size); } @@ -3806,35 +4093,44 @@ PyBytesWriter_FinishWithPointer(PyBytesWriter *writer, void *buf) void* PyBytesWriter_GetData(PyBytesWriter *writer) { - return byteswriter_data(writer); + assert(byteswriter_check_consistency(writer)); + + return _PyBytesWriter_GetData(writer); } Py_ssize_t PyBytesWriter_GetSize(PyBytesWriter *writer) { - return _PyBytesWriter_GetSize(writer); -} + assert(byteswriter_check_consistency(writer)); - -static Py_ssize_t -_PyBytesWriter_GetAllocated(PyBytesWriter *writer) -{ - return byteswriter_allocated(writer); + return _PyBytesWriter_GetSize(writer); } int -PyBytesWriter_Resize(PyBytesWriter *writer, Py_ssize_t size) +PyBytesWriter_Resize(PyBytesWriter *writer, Py_ssize_t new_size) { - if (size < 0) { + assert(byteswriter_check_consistency(writer)); + + if (new_size < 0) { PyErr_SetString(PyExc_ValueError, "size must be >= 0"); return -1; } - if (byteswriter_resize(writer, size, 1) < 0) { - return -1; + if (writer->size < new_size) { + if (byteswriter_resize(writer, new_size, 1) < 0) { + return -1; + } } - writer->size = size; + else { + // The buffer is already large enough. Never shrink the buffer. + } + + writer->size = new_size; +#ifdef Py_DEBUG + byteswriter_write_canary_byte(writer); +#endif + assert(byteswriter_check_consistency(writer)); return 0; } @@ -3843,31 +4139,49 @@ static void* _PyBytesWriter_ResizeAndUpdatePointer(PyBytesWriter *writer, Py_ssize_t size, void *data) { - Py_ssize_t pos = (char*)data - byteswriter_data(writer); + Py_ssize_t pos = (char*)data - _PyBytesWriter_GetData(writer); if (PyBytesWriter_Resize(writer, size) < 0) { return NULL; } - return byteswriter_data(writer) + pos; + return _PyBytesWriter_GetData(writer) + pos; } int -PyBytesWriter_Grow(PyBytesWriter *writer, Py_ssize_t size) +PyBytesWriter_Grow(PyBytesWriter *writer, Py_ssize_t grow) { - if (size < 0 && writer->size + size < 0) { - PyErr_SetString(PyExc_ValueError, "invalid size"); - return -1; - } - if (size > PY_SSIZE_T_MAX - writer->size) { - PyErr_NoMemory(); - return -1; + assert(byteswriter_check_consistency(writer)); + + if (grow == 0) { + // Nothing to do + return 0; } - size = writer->size + size; - if (byteswriter_resize(writer, size, 1) < 0) { - return -1; + if (grow > 0) { + if (grow > PY_SSIZE_T_MAX - writer->size) { + PyErr_NoMemory(); + return -1; + } + Py_ssize_t new_size = writer->size + grow; + + if (byteswriter_resize(writer, new_size, 1) < 0) { + return -1; + } + writer->size = new_size; } - writer->size = size; + else { + if (writer->size + grow < 0) { + PyErr_SetString(PyExc_ValueError, "invalid size"); + return -1; + } + // The buffer is already large enough. Never shrink the buffer. + writer->size = writer->size + grow; + } + +#ifdef Py_DEBUG + byteswriter_write_canary_byte(writer); +#endif + assert(byteswriter_check_consistency(writer)); return 0; } @@ -3876,11 +4190,11 @@ void* PyBytesWriter_GrowAndUpdatePointer(PyBytesWriter *writer, Py_ssize_t size, void *buf) { - Py_ssize_t pos = (char*)buf - byteswriter_data(writer); + Py_ssize_t pos = (char*)buf - _PyBytesWriter_GetData(writer); if (PyBytesWriter_Grow(writer, size) < 0) { return NULL; } - return byteswriter_data(writer) + pos; + return _PyBytesWriter_GetData(writer) + pos; } @@ -3901,8 +4215,10 @@ PyBytesWriter_WriteBytes(PyBytesWriter *writer, if (PyBytesWriter_Grow(writer, size) < 0) { return -1; } - char *buf = byteswriter_data(writer); + char *buf = _PyBytesWriter_GetData(writer); memcpy(buf + pos, bytes, size); + + assert(byteswriter_check_consistency(writer)); return 0; } @@ -3911,6 +4227,7 @@ int PyBytesWriter_Format(PyBytesWriter *writer, const char *format, ...) { Py_ssize_t pos = writer->size; + Py_ssize_t old_pos = pos; if (PyBytesWriter_Grow(writer, strlen(format)) < 0) { return -1; } @@ -3920,6 +4237,32 @@ PyBytesWriter_Format(PyBytesWriter *writer, const char *format, ...) char *buf = bytes_fromformat(writer, pos, format, vargs); va_end(vargs); - Py_ssize_t size = buf - byteswriter_data(writer); + if (buf == NULL) { + // On error, reset the writer to its previous state (undo any write) + writer->size = old_pos; +#ifdef Py_DEBUG + byteswriter_write_canary_byte(writer); +#endif + return -1; + } + + Py_ssize_t size = buf - _PyBytesWriter_GetData(writer); return PyBytesWriter_Resize(writer, size); } + + +// Resize the writer to its allocated size. +// Return the new size. +// The function cannot fail. +static Py_ssize_t +_PyBytesWriter_ResizeToAllocated(PyBytesWriter *writer) +{ + Py_ssize_t allocated = byteswriter_allocated(writer); + writer->size = allocated; +#ifdef Py_DEBUG + byteswriter_write_canary_byte(writer); +#endif + + assert(byteswriter_check_consistency(writer)); + return allocated; +} diff --git a/Objects/call.c b/Objects/call.c index 9718642473103cf..a79f167aacc8c06 100644 --- a/Objects/call.c +++ b/Objects/call.c @@ -612,18 +612,70 @@ _PyObject_CallFunction_SizeT(PyObject *callable, const char *format, ...) } -static PyObject* -callmethod(PyThreadState *tstate, PyObject* callable, const char *format, va_list va) +static PyObject * +callmethod(PyThreadState *tstate, PyObject *obj, PyObject *name, + const char *format, va_list va) { - assert(callable != NULL); + PyObject *result = NULL; + + _PyCStackRef self, method; + _PyThreadState_PushCStackRef(tstate, &self); + _PyThreadState_PushCStackRef(tstate, &method); + self.ref = PyStackRef_FromPyObjectBorrow(obj); + + int res = _PyObject_GetMethodStackRef(tstate, &self.ref, name, &method.ref); + if (res < 0) { + goto exit; + } + + PyObject *callable = PyStackRef_AsPyObjectBorrow(method.ref); + PyObject *self_obj = PyStackRef_AsPyObjectBorrow(self.ref); + if (!PyCallable_Check(callable)) { _PyErr_Format(tstate, PyExc_TypeError, "attribute of type '%.200s' is not callable", Py_TYPE(callable)->tp_name); - return NULL; + goto exit; } - return _PyObject_CallFunctionVa(tstate, callable, format, va); + /* Build the positional arguments from the format string. */ + PyObject *small_stack[_PY_FASTCALL_SMALL_STACK]; + Py_ssize_t nargs = 0; + PyObject **built = NULL; + if (format != NULL && *format != '\0') { + built = _Py_VaBuildStack(small_stack, _PY_FASTCALL_SMALL_STACK, + format, va, &nargs); + if (built == NULL) { + goto exit; + } + } + + /* Backward compat: a single tuple from "O" is unpacked. */ + PyObject *const *args = built; + Py_ssize_t n = nargs; + if (nargs == 1 && PyTuple_Check(built[0])) { + args = _PyTuple_ITEMS(built[0]); + n = PyTuple_GET_SIZE(built[0]); + } + + if (self_obj != NULL) { + result = _PyObject_VectorcallPrepend(tstate, callable, self_obj, args, n, NULL); + } + else { + result = _PyObject_VectorcallTstate(tstate, callable, args, n, NULL); + } + + for (Py_ssize_t i = 0; i < nargs; i++) { + Py_DECREF(built[i]); + } + if (built != small_stack) { + PyMem_Free(built); + } + +exit: + _PyThreadState_PopCStackRef(tstate, &method); + _PyThreadState_PopCStackRef(tstate, &self); + return result; } PyObject * @@ -635,17 +687,17 @@ PyObject_CallMethod(PyObject *obj, const char *name, const char *format, ...) return null_error(tstate); } - PyObject *callable = PyObject_GetAttrString(obj, name); - if (callable == NULL) { + PyObject *name_obj = PyUnicode_FromString(name); + if (name_obj == NULL) { return NULL; } va_list va; va_start(va, format); - PyObject *retval = callmethod(tstate, callable, format, va); + PyObject *retval = callmethod(tstate, obj, name_obj, format, va); va_end(va); - Py_DECREF(callable); + Py_DECREF(name_obj); return retval; } @@ -660,17 +712,17 @@ PyEval_CallMethod(PyObject *obj, const char *name, const char *format, ...) return null_error(tstate); } - PyObject *callable = PyObject_GetAttrString(obj, name); - if (callable == NULL) { + PyObject *name_obj = PyUnicode_FromString(name); + if (name_obj == NULL) { return NULL; } va_list va; va_start(va, format); - PyObject *retval = callmethod(tstate, callable, format, va); + PyObject *retval = callmethod(tstate, obj, name_obj, format, va); va_end(va); - Py_DECREF(callable); + Py_DECREF(name_obj); return retval; } @@ -684,17 +736,11 @@ _PyObject_CallMethod(PyObject *obj, PyObject *name, return null_error(tstate); } - PyObject *callable = PyObject_GetAttr(obj, name); - if (callable == NULL) { - return NULL; - } - va_list va; va_start(va, format); - PyObject *retval = callmethod(tstate, callable, format, va); + PyObject *retval = callmethod(tstate, obj, name, format, va); va_end(va); - Py_DECREF(callable); return retval; } @@ -710,30 +756,17 @@ _PyObject_CallMethodId(PyObject *obj, _Py_Identifier *name, _Py_COMP_DIAG_PUSH _Py_COMP_DIAG_IGNORE_DEPR_DECLS - PyObject *callable = _PyObject_GetAttrId(obj, name); + PyObject *name_obj = _PyUnicode_FromId(name); /* borrowed */ _Py_COMP_DIAG_POP - if (callable == NULL) { + if (name_obj == NULL) { return NULL; } va_list va; va_start(va, format); - PyObject *retval = callmethod(tstate, callable, format, va); + PyObject *retval = callmethod(tstate, obj, name_obj, format, va); va_end(va); - Py_DECREF(callable); - return retval; -} - - -PyObject * _PyObject_CallMethodFormat(PyThreadState *tstate, PyObject *callable, - const char *format, ...) -{ - assert(callable != NULL); - va_list va; - va_start(va, format); - PyObject *retval = callmethod(tstate, callable, format, va); - va_end(va); return retval; } @@ -749,17 +782,17 @@ _PyObject_CallMethod_SizeT(PyObject *obj, const char *name, return null_error(tstate); } - PyObject *callable = PyObject_GetAttrString(obj, name); - if (callable == NULL) { + PyObject *name_obj = PyUnicode_FromString(name); + if (name_obj == NULL) { return NULL; } va_list va; va_start(va, format); - PyObject *retval = callmethod(tstate, callable, format, va); + PyObject *retval = callmethod(tstate, obj, name_obj, format, va); va_end(va); - Py_DECREF(callable); + Py_DECREF(name_obj); return retval; } diff --git a/Objects/capsule.c b/Objects/capsule.c index 16ae65905ef5ac0..bd90cb25f78862e 100644 --- a/Objects/capsule.c +++ b/Objects/capsule.c @@ -4,6 +4,7 @@ #include "pycore_capsule.h" // export _PyCapsule_SetTraverse() #include "pycore_gc.h" // _PyObject_GC_IS_TRACKED() #include "pycore_object.h" // _PyObject_GC_TRACK() +#include "pycore_pymem.h" // _PyMem_Strdup() /* Internal structure of PyCapsule */ @@ -227,58 +228,58 @@ _PyCapsule_SetTraverse(PyObject *op, traverseproc traverse_func, inquiry clear_f void * -PyCapsule_Import(const char *name, int no_block) +PyCapsule_Import(const char *name, int Py_UNUSED(no_block)) { PyObject *object = NULL; void *return_value = NULL; - char *trace; - size_t name_length = (strlen(name) + 1) * sizeof(char); - char *name_dup = (char *)PyMem_Malloc(name_length); + char *name_dup = _PyMem_Strdup(name); if (!name_dup) { return PyErr_NoMemory(); } - memcpy(name_dup, name, name_length); - - trace = name_dup; - while (trace) { + char *trace = name_dup; + while (1) { char *dot = strchr(trace, '.'); if (dot) { - *dot++ = '\0'; + *dot = '\0'; } - - if (object == NULL) { - object = PyImport_ImportModule(trace); - if (!object) { - PyErr_Format(PyExc_ImportError, "PyCapsule_Import could not import module \"%s\"", trace); + if (object) { + PyObject *attr; + if (PyObject_GetOptionalAttrString(object, trace, &attr) < 0) { + Py_CLEAR(object); + break; } - } else { - PyObject *object2 = PyObject_GetAttrString(object, trace); - Py_SETREF(object, object2); + Py_SETREF(object, attr); } - if (!object) { - goto EXIT; + if (!dot) { + // We are done + break; } - trace = dot; + if (!object) { + object = PyImport_ImportModule(name_dup); + if (!object) { + break; + } + } + *dot = '.'; + trace = dot + 1; } /* compare attribute name to module.name by hand */ if (PyCapsule_IsValid(object, name)) { PyCapsule *capsule = (PyCapsule *)object; return_value = capsule->pointer; - } else { + } + else if (!PyErr_Occurred()) { PyErr_Format(PyExc_AttributeError, "PyCapsule_Import \"%s\" is not valid", name); } -EXIT: Py_XDECREF(object); - if (name_dup) { - PyMem_Free(name_dup); - } + PyMem_Free(name_dup); return return_value; } diff --git a/Objects/cellobject.c b/Objects/cellobject.c index ec2eeb1a855b633..a1c7dd42912bcc7 100644 --- a/Objects/cellobject.c +++ b/Objects/cellobject.c @@ -2,11 +2,17 @@ #include "Python.h" #include "pycore_cell.h" // PyCell_GetRef() -#include "pycore_modsupport.h" // _PyArg_NoKeywords() #include "pycore_object.h" +#include "clinic/cellobject.c.h" + #define _PyCell_CAST(op) _Py_CAST(PyCellObject*, (op)) +/*[clinic input] +class cell "PyCellObject *" "&PyCell_Type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=3d6baba8cf810af0]*/ + PyObject * PyCell_New(PyObject *obj) { @@ -21,35 +27,28 @@ PyCell_New(PyObject *obj) return (PyObject *)op; } -PyDoc_STRVAR(cell_new_doc, -"cell([contents])\n" -"--\n" -"\n" -"Create a new cell object.\n" -"\n" -" contents\n" -" the contents of the cell. If not specified, the cell will be empty,\n" -" and \n further attempts to access its cell_contents attribute will\n" -" raise a ValueError."); +/*[clinic input] +@vectorcall +@classmethod +@text_signature "([contents])" +cell.__new__ as cell_new + contents: object = NULL + / -static PyObject * -cell_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - PyObject *obj = NULL; +Create a new cell object. - if (!_PyArg_NoKeywords("cell", kwargs)) { - goto exit; - } - /* min = 0: we allow the cell to be empty */ - if (!PyArg_UnpackTuple(args, "cell", 0, 1, &obj)) { - goto exit; - } - return_value = PyCell_New(obj); + contents + the contents of the cell. If not specified, the cell will be empty, + and further attempts to access its cell_contents attribute will + raise a ValueError. +[clinic start generated code]*/ -exit: - return return_value; +static PyObject * +cell_new_impl(PyTypeObject *type, PyObject *contents) +/*[clinic end generated code: output=0b7db264f0621bb4 input=4460339a82243798]*/ +{ + return PyCell_New(contents); } PyObject * @@ -190,7 +189,7 @@ PyTypeObject PyCell_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - cell_new_doc, /* tp_doc */ + cell_new__doc__, /* tp_doc */ cell_traverse, /* tp_traverse */ cell_clear, /* tp_clear */ cell_richcompare, /* tp_richcompare */ @@ -209,4 +208,5 @@ PyTypeObject PyCell_Type = { 0, /* tp_alloc */ cell_new, /* tp_new */ 0, /* tp_free */ + .tp_vectorcall = cell_vectorcall, }; diff --git a/Objects/classobject.c b/Objects/classobject.c index 238f1c1dad7d866..dbfdc9262cf0202 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -182,8 +182,9 @@ method_getattro(PyObject *obj, PyObject *name) } /*[clinic input] +@vectorcall @classmethod -method.__new__ as method_new +method.__new__ as method_type_new function: object instance: object / @@ -192,8 +193,9 @@ Create a bound instance method object. [clinic start generated code]*/ static PyObject * -method_new_impl(PyTypeObject *type, PyObject *function, PyObject *instance) -/*[clinic end generated code: output=d33ef4ebf702e1f7 input=4e32facc3c3108ae]*/ +method_type_new_impl(PyTypeObject *type, PyObject *function, + PyObject *instance) +/*[clinic end generated code: output=e9877864a8bfdf70 input=70c1e0da5d6267f5]*/ { if (!PyCallable_Check(function)) { PyErr_SetString(PyExc_TypeError, @@ -323,7 +325,7 @@ PyTypeObject PyMethod_Type = { .tp_setattro = PyObject_GenericSetAttr, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_VECTORCALL, - .tp_doc = method_new__doc__, + .tp_doc = method_type_new__doc__, .tp_traverse = method_traverse, .tp_richcompare = method_richcompare, .tp_weaklistoffset = offsetof(PyMethodObject, im_weakreflist), @@ -331,7 +333,8 @@ PyTypeObject PyMethod_Type = { .tp_members = method_memberlist, .tp_getset = method_getset, .tp_descr_get = method_descr_get, - .tp_new = method_new, + .tp_new = method_type_new, + .tp_vectorcall = method_type_vectorcall, }; /* ------------------------------------------------------------------------ diff --git a/Objects/clinic/boolobject.c.h b/Objects/clinic/boolobject.c.h new file mode 100644 index 000000000000000..610b87e420d6269 --- /dev/null +++ b/Objects/clinic/boolobject.c.h @@ -0,0 +1,73 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#include "pycore_modsupport.h" // _PyArg_CheckPositional() + +PyDoc_STRVAR(bool_new__doc__, +"bool(object=False, /)\n" +"--\n" +"\n" +"Returns True when the argument is true, False otherwise.\n" +"\n" +"The builtins True and False are the only two instances of the class\n" +"bool. The class bool is a subclass of the class int, and cannot be\n" +"subclassed."); + +static PyObject * +bool_new_impl(PyTypeObject *type, PyObject *x); + +static PyObject * +bool_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyTypeObject *base_tp = &PyBool_Type; + PyObject *x = Py_False; + + if ((type == base_tp || type->tp_init == base_tp->tp_init) && + !_PyArg_NoKeywords("bool", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("bool", PyTuple_GET_SIZE(args), 0, 1)) { + goto exit; + } + if (PyTuple_GET_SIZE(args) < 1) { + goto skip_optional; + } + x = PyTuple_GET_ITEM(args, 0); +skip_optional: + return_value = bool_new_impl(type, x); + +exit: + return return_value; +} + +static PyObject * +bool_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *x = Py_False; + + assert(_PyType_CAST(type)->tp_new == bool_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("bool", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("bool", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + x = args[0]; +skip_optional: + return_value = bool_new_impl(_PyType_CAST(type), x); + +exit: + return return_value; +} +/*[clinic end generated code: output=c7be32f9d1f3e07a input=a9049054013a1b77]*/ diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h index 41ce82c05c57d97..5445aa0166967a2 100644 --- a/Objects/clinic/bytearrayobject.c.h +++ b/Objects/clinic/bytearrayobject.c.h @@ -4,18 +4,96 @@ preserve #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) # include "pycore_gc.h" // PyGC_Head -# include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_runtime.h" // _Py_SINGLETON() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() + +static PyObject * +bytearray_iconcat_impl(PyByteArrayObject *self, PyObject *other); + +static PyObject * +bytearray_iconcat(PyObject *self, PyObject *other) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = bytearray_iconcat_impl((PyByteArrayObject *)self, other); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static PyObject * +bytearray_repeat_impl(PyByteArrayObject *self, Py_ssize_t count); + +static PyObject * +bytearray_repeat(PyObject *self, Py_ssize_t count) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = bytearray_repeat_impl((PyByteArrayObject *)self, count); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static PyObject * +bytearray_irepeat_impl(PyByteArrayObject *self, Py_ssize_t count); + +static PyObject * +bytearray_irepeat(PyObject *self, Py_ssize_t count) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = bytearray_irepeat_impl((PyByteArrayObject *)self, count); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static PyObject * +bytearray_getitem_impl(PyByteArrayObject *self, Py_ssize_t i); + +static PyObject * +bytearray_getitem(PyObject *self, Py_ssize_t i) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = bytearray_getitem_impl((PyByteArrayObject *)self, i); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static int +bytearray_setitem_impl(PyByteArrayObject *self, Py_ssize_t i, + PyObject *value); + +static int +bytearray_setitem(PyObject *self, Py_ssize_t i, PyObject *value) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = bytearray_setitem_impl((PyByteArrayObject *)self, i, value); + Py_END_CRITICAL_SECTION(); + + return return_value; +} static int bytearray___init___impl(PyByteArrayObject *self, PyObject *arg, const char *encoding, const char *errors); static int -bytearray___init__(PyObject *self, PyObject *args, PyObject *kwargs) +bytearray___init___helper(PyObject *self, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { int return_value = -1; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -47,13 +125,12 @@ bytearray___init__(PyObject *self, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[3]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; + Py_ssize_t noptargs = nargs + nkw - 0; PyObject *arg = NULL; const char *encoding = NULL; const char *errors = NULL; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 0, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -72,15 +149,10 @@ bytearray___init__(PyObject *self, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("bytearray", "argument 'encoding'", "str", fastargs[1]); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(fastargs[1]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_pos; } @@ -89,15 +161,10 @@ bytearray___init__(PyObject *self, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("bytearray", "argument 'errors'", "str", fastargs[2]); goto exit; } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(fastargs[2], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(fastargs[2]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } skip_optional_pos: return_value = bytearray___init___impl((PyByteArrayObject *)self, arg, encoding, errors); @@ -105,6 +172,104 @@ bytearray___init__(PyObject *self, PyObject *args, PyObject *kwargs) return return_value; } +static int +bytearray___init__(PyObject *self, PyObject *args, PyObject *kwargs) +{ + return bytearray___init___helper(self, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +bytearray_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *self; + int _result; + PyObject *arg = NULL; + const char *encoding = NULL; + const char *errors = NULL; + + assert(_PyType_CAST(type)->tp_init == bytearray___init__); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs > 3) { + self = _PyType_CAST(type)->tp_new(_PyType_CAST(type), + (PyObject *)&_Py_SINGLETON(tuple_empty), NULL); + if (self == NULL) { + return NULL; + } + _result = bytearray___init___helper(self, args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + if (_result != 0) { + Py_DECREF(self); + return NULL; + } + return self; + } + if (nargs < 1) { + goto skip_optional; + } + arg = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("bytearray", "argument 'encoding'", "str", args[1]); + goto exit; + } + encoding = _PyUnicode_AsUTF8NoNUL(args[1]); + if (encoding == NULL) { + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("bytearray", "argument 'errors'", "str", args[2]); + goto exit; + } + errors = _PyUnicode_AsUTF8NoNUL(args[2]); + if (errors == NULL) { + goto exit; + } +skip_optional: + self = _PyType_CAST(type)->tp_new(_PyType_CAST(type), + (PyObject *)&_Py_SINGLETON(tuple_empty), NULL); + if (self == NULL) { + goto exit; + } + _result = bytearray___init___impl((PyByteArrayObject *)self, arg, encoding, errors); + if (_result != 0) { + Py_DECREF(self); + goto exit; + } + return_value = self; + +exit: + return return_value; +} + +static PyObject * +bytearray_repr_impl(PyObject *op); + +static PyObject * +bytearray_repr(PyObject *op) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(op); + return_value = bytearray_repr_impl(op); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(bytearray_find__doc__, "find($self, sub[, start[, end]], /)\n" "--\n" @@ -1542,15 +1707,10 @@ bytearray_decode(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje _PyArg_BadArgument("decode", "argument 'encoding'", "str", args[0]); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(args[0]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_pos; } @@ -1559,15 +1719,10 @@ bytearray_decode(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje _PyArg_BadArgument("decode", "argument 'errors'", "str", args[1]); goto exit; } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } skip_optional_pos: Py_BEGIN_CRITICAL_SECTION(self); return_value = bytearray_decode_impl((PyByteArrayObject *)self, encoding, errors); @@ -1882,4 +2037,4 @@ bytearray_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored)) { return bytearray_sizeof_impl((PyByteArrayObject *)self); } -/*[clinic end generated code: output=6dc315d35de3e670 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b8e659fe4b2f770e input=a9049054013a1b77]*/ diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h index ee2b737f9e63f97..c96cd94425c1d18 100644 --- a/Objects/clinic/bytesobject.c.h +++ b/Objects/clinic/bytesobject.c.h @@ -8,6 +8,7 @@ preserve #endif #include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(bytes___bytes____doc__, "__bytes__($self, /)\n" @@ -1136,15 +1137,10 @@ bytes_decode(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject * _PyArg_BadArgument("decode", "argument 'encoding'", "str", args[0]); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(args[0]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_pos; } @@ -1153,15 +1149,10 @@ bytes_decode(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject * _PyArg_BadArgument("decode", "argument 'errors'", "str", args[1]); goto exit; } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } skip_optional_pos: return_value = bytes_decode_impl((PyBytesObject *)self, encoding, errors); @@ -1366,7 +1357,8 @@ bytes_new_impl(PyTypeObject *type, PyObject *x, const char *encoding, const char *errors); static PyObject * -bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +bytes_new_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -1398,13 +1390,12 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[3]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; + Py_ssize_t noptargs = nargs + nkw - 0; PyObject *x = NULL; const char *encoding = NULL; const char *errors = NULL; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 0, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -1423,15 +1414,10 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("bytes", "argument 'encoding'", "str", fastargs[1]); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(fastargs[1]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_pos; } @@ -1440,19 +1426,75 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("bytes", "argument 'errors'", "str", fastargs[2]); goto exit; } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(fastargs[2], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(fastargs[2]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } skip_optional_pos: return_value = bytes_new_impl(type, x, encoding, errors); exit: return return_value; } -/*[clinic end generated code: output=c20458db7a2123db input=a9049054013a1b77]*/ + +static PyObject * +bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return bytes_new_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +bytes_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *x = NULL; + const char *encoding = NULL; + const char *errors = NULL; + + assert(_PyType_CAST(type)->tp_new == bytes_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs > 3) { + return bytes_new_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + if (nargs < 1) { + goto skip_optional; + } + x = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("bytes", "argument 'encoding'", "str", args[1]); + goto exit; + } + encoding = _PyUnicode_AsUTF8NoNUL(args[1]); + if (encoding == NULL) { + goto exit; + } + if (nargs < 3) { + goto skip_optional; + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("bytes", "argument 'errors'", "str", args[2]); + goto exit; + } + errors = _PyUnicode_AsUTF8NoNUL(args[2]); + if (errors == NULL) { + goto exit; + } +skip_optional: + return_value = bytes_new_impl(_PyType_CAST(type), x, encoding, errors); + +exit: + return return_value; +} +/*[clinic end generated code: output=0d49a97b9e2eef5b input=a9049054013a1b77]*/ diff --git a/Objects/clinic/cellobject.c.h b/Objects/clinic/cellobject.c.h new file mode 100644 index 000000000000000..bf2b21d5dc44372 --- /dev/null +++ b/Objects/clinic/cellobject.c.h @@ -0,0 +1,74 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#include "pycore_modsupport.h" // _PyArg_CheckPositional() + +PyDoc_STRVAR(cell_new__doc__, +"cell([contents])\n" +"--\n" +"\n" +"Create a new cell object.\n" +"\n" +" contents\n" +" the contents of the cell. If not specified, the cell will be empty,\n" +" and further attempts to access its cell_contents attribute will\n" +" raise a ValueError."); + +static PyObject * +cell_new_impl(PyTypeObject *type, PyObject *contents); + +static PyObject * +cell_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyTypeObject *base_tp = &PyCell_Type; + PyObject *contents = NULL; + + if ((type == base_tp || type->tp_init == base_tp->tp_init) && + !_PyArg_NoKeywords("cell", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("cell", PyTuple_GET_SIZE(args), 0, 1)) { + goto exit; + } + if (PyTuple_GET_SIZE(args) < 1) { + goto skip_optional; + } + contents = PyTuple_GET_ITEM(args, 0); +skip_optional: + return_value = cell_new_impl(type, contents); + +exit: + return return_value; +} + +static PyObject * +cell_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *contents = NULL; + + assert(_PyType_CAST(type)->tp_new == cell_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("cell", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("cell", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + contents = args[0]; +skip_optional: + return_value = cell_new_impl(_PyType_CAST(type), contents); + +exit: + return return_value; +} +/*[clinic end generated code: output=687470647f1a75f8 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/classobject.c.h b/Objects/clinic/classobject.c.h index 5934f1c2a41669f..1b96cc2212a826f 100644 --- a/Objects/clinic/classobject.c.h +++ b/Objects/clinic/classobject.c.h @@ -21,17 +21,18 @@ method___reduce__(PyObject *self, PyObject *Py_UNUSED(ignored)) return method___reduce___impl((PyMethodObject *)self); } -PyDoc_STRVAR(method_new__doc__, +PyDoc_STRVAR(method_type_new__doc__, "method(function, instance, /)\n" "--\n" "\n" "Create a bound instance method object."); static PyObject * -method_new_impl(PyTypeObject *type, PyObject *function, PyObject *instance); +method_type_new_impl(PyTypeObject *type, PyObject *function, + PyObject *instance); static PyObject * -method_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +method_type_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; PyTypeObject *base_tp = &PyMethod_Type; @@ -47,7 +48,34 @@ method_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } function = PyTuple_GET_ITEM(args, 0); instance = PyTuple_GET_ITEM(args, 1); - return_value = method_new_impl(type, function, instance); + return_value = method_type_new_impl(type, function, instance); + +exit: + return return_value; +} + +static PyObject * +method_type_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *function; + PyObject *instance; + + assert(_PyType_CAST(type)->tp_new == method_type_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("method", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("method", nargs, 2, 2)) { + goto exit; + } + function = args[0]; + instance = args[1]; + return_value = method_type_new_impl(_PyType_CAST(type), function, instance); exit: return return_value; @@ -82,4 +110,4 @@ instancemethod_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=ab546abf90aac94e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=fd5c214ee6e55e88 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/descrobject.c.h b/Objects/clinic/descrobject.c.h index a0cfbeca84db124..879b872d9b3ae61 100644 --- a/Objects/clinic/descrobject.c.h +++ b/Objects/clinic/descrobject.c.h @@ -18,7 +18,8 @@ static PyObject * mappingproxy_new_impl(PyTypeObject *type, PyObject *mapping); static PyObject * -mappingproxy_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +mappingproxy_new_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -50,10 +51,9 @@ mappingproxy_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[1]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *mapping; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -65,6 +65,69 @@ mappingproxy_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +mappingproxy_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return mappingproxy_new_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +mappingproxy_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *mapping; + + assert(_PyType_CAST(type)->tp_new == mappingproxy_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs < 1 || nargs > 1) { + return mappingproxy_new_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + mapping = args[0]; + return_value = mappingproxy_new_impl(_PyType_CAST(type), mapping); + + return return_value; +} + +PyDoc_STRVAR(property___set_name____doc__, +"__set_name__($self, owner, name, /)\n" +"--\n" +"\n" +"Method to set name of a property."); + +#define PROPERTY___SET_NAME___METHODDEF \ + {"__set_name__", _PyCFunction_CAST(property___set_name__), METH_FASTCALL, property___set_name____doc__}, + +static PyObject * +property___set_name___impl(propertyobject *self, PyObject *owner, + PyObject *name); + +static PyObject * +property___set_name__(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *owner; + PyObject *name; + + if (!_PyArg_CheckPositional("__set_name__", nargs, 2, 2)) { + goto exit; + } + owner = args[0]; + name = args[1]; + return_value = property___set_name___impl((propertyobject *)self, owner, name); + +exit: + return return_value; +} + PyDoc_STRVAR(property_init__doc__, "property(fget=None, fset=None, fdel=None, doc=None)\n" "--\n" @@ -179,4 +242,4 @@ property_init(PyObject *self, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=2e8df497abc4f915 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=41ae2d4147b31052 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/dictobject.c.h b/Objects/clinic/dictobject.c.h index 15b8705d9c78e3c..038f56d62b6d8c5 100644 --- a/Objects/clinic/dictobject.c.h +++ b/Objects/clinic/dictobject.c.h @@ -5,6 +5,21 @@ preserve #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_modsupport.h" // _PyArg_CheckPositional() +static PyObject * +dict_repr_impl(PyObject *self); + +static PyObject * +dict_repr(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = dict_repr_impl(self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(dict_fromkeys__doc__, "fromkeys($type, iterable, value=None, /)\n" "--\n" @@ -341,4 +356,4 @@ frozendict_copy(PyObject *self, PyObject *Py_UNUSED(ignored)) { return frozendict_copy_impl((PyFrozenDictObject *)self); } -/*[clinic end generated code: output=f4c88a3464928ae3 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=46d2d00147dd7917 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/enumobject.c.h b/Objects/clinic/enumobject.c.h index 1bda482f4955aea..9b8a25a60b571ea 100644 --- a/Objects/clinic/enumobject.c.h +++ b/Objects/clinic/enumobject.c.h @@ -27,7 +27,8 @@ static PyObject * enum_new_impl(PyTypeObject *type, PyObject *iterable, PyObject *start); static PyObject * -enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +enum_new_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -59,12 +60,11 @@ enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[2]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + Py_ssize_t noptargs = nargs + nkw - 1; PyObject *iterable; PyObject *start = 0; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -81,6 +81,44 @@ enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return enum_new_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +enum_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *iterable; + PyObject *start = 0; + + assert(_PyType_CAST(type)->tp_new == enum_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs < 1 || nargs > 2) { + return enum_new_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + iterable = args[0]; + if (nargs < 2) { + goto skip_optional; + } + start = args[1]; +skip_optional: + return_value = enum_new_impl(_PyType_CAST(type), iterable, start); + + return return_value; +} + PyDoc_STRVAR(reversed_new__doc__, "reversed(object, /)\n" "--\n" @@ -110,4 +148,29 @@ reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=155cc9483d5f9eab input=a9049054013a1b77]*/ + +static PyObject * +reversed_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *seq; + + assert(_PyType_CAST(type)->tp_new == reversed_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("reversed", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("reversed", nargs, 1, 1)) { + goto exit; + } + seq = args[0]; + return_value = reversed_new_impl(_PyType_CAST(type), seq); + +exit: + return return_value; +} +/*[clinic end generated code: output=b97e8b89ca97ba64 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/exceptions.c.h b/Objects/clinic/exceptions.c.h index 5047a673e579c66..b77606c3c7a8c76 100644 --- a/Objects/clinic/exceptions.c.h +++ b/Objects/clinic/exceptions.c.h @@ -2,8 +2,42 @@ preserve [clinic start generated code]*/ +#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) +# include "pycore_gc.h" // PyGC_Head +#endif #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_modsupport.h" // _PyArg_BadArgument() +#include "pycore_runtime.h" // _Py_SINGLETON() + +static PyObject * +BaseException_str_impl(PyBaseExceptionObject *self); + +static PyObject * +BaseException_str(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = BaseException_str_impl((PyBaseExceptionObject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static PyObject * +BaseException_repr_impl(PyBaseExceptionObject *self); + +static PyObject * +BaseException_repr(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = BaseException_repr_impl((PyBaseExceptionObject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} PyDoc_STRVAR(BaseException___reduce____doc__, "__reduce__($self, /)\n" @@ -106,16 +140,6 @@ BaseException_add_note(PyObject *self, PyObject *arg) return return_value; } -#if !defined(BaseException_args_DOCSTR) -# define BaseException_args_DOCSTR NULL -#endif -#if defined(BASEEXCEPTION_ARGS_GETSETDEF) -# undef BASEEXCEPTION_ARGS_GETSETDEF -# define BASEEXCEPTION_ARGS_GETSETDEF {"args", (getter)BaseException_args_get, (setter)BaseException_args_set, BaseException_args_DOCSTR}, -#else -# define BASEEXCEPTION_ARGS_GETSETDEF {"args", (getter)BaseException_args_get, NULL, BaseException_args_DOCSTR}, -#endif - static PyObject * BaseException_args_get_impl(PyBaseExceptionObject *self); @@ -131,24 +155,22 @@ BaseException_args_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(BaseException_args_DOCSTR) -# define BaseException_args_DOCSTR NULL -#endif -#if defined(BASEEXCEPTION_ARGS_GETSETDEF) -# undef BASEEXCEPTION_ARGS_GETSETDEF -# define BASEEXCEPTION_ARGS_GETSETDEF {"args", (getter)BaseException_args_get, (setter)BaseException_args_set, BaseException_args_DOCSTR}, -#else -# define BASEEXCEPTION_ARGS_GETSETDEF {"args", NULL, (setter)BaseException_args_set, NULL}, -#endif - static int BaseException_args_set_impl(PyBaseExceptionObject *self, PyObject *value); static int -BaseException_args_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +BaseException_args_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; - + int return_value = -1; + PyObject *value; + + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'args' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = BaseException_args_set_impl((PyBaseExceptionObject *)self, value); Py_END_CRITICAL_SECTION(); @@ -156,16 +178,6 @@ BaseException_args_set(PyObject *self, PyObject *value, void *Py_UNUSED(context) return return_value; } -#if !defined(BaseException___traceback___DOCSTR) -# define BaseException___traceback___DOCSTR NULL -#endif -#if defined(BASEEXCEPTION___TRACEBACK___GETSETDEF) -# undef BASEEXCEPTION___TRACEBACK___GETSETDEF -# define BASEEXCEPTION___TRACEBACK___GETSETDEF {"__traceback__", (getter)BaseException___traceback___get, (setter)BaseException___traceback___set, BaseException___traceback___DOCSTR}, -#else -# define BASEEXCEPTION___TRACEBACK___GETSETDEF {"__traceback__", (getter)BaseException___traceback___get, NULL, BaseException___traceback___DOCSTR}, -#endif - static PyObject * BaseException___traceback___get_impl(PyBaseExceptionObject *self); @@ -181,25 +193,23 @@ BaseException___traceback___get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(BaseException___traceback___DOCSTR) -# define BaseException___traceback___DOCSTR NULL -#endif -#if defined(BASEEXCEPTION___TRACEBACK___GETSETDEF) -# undef BASEEXCEPTION___TRACEBACK___GETSETDEF -# define BASEEXCEPTION___TRACEBACK___GETSETDEF {"__traceback__", (getter)BaseException___traceback___get, (setter)BaseException___traceback___set, BaseException___traceback___DOCSTR}, -#else -# define BASEEXCEPTION___TRACEBACK___GETSETDEF {"__traceback__", NULL, (setter)BaseException___traceback___set, NULL}, -#endif - static int BaseException___traceback___set_impl(PyBaseExceptionObject *self, PyObject *value); static int -BaseException___traceback___set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +BaseException___traceback___set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; - + int return_value = -1; + PyObject *value; + + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute '__traceback__' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = BaseException___traceback___set_impl((PyBaseExceptionObject *)self, value); Py_END_CRITICAL_SECTION(); @@ -207,16 +217,6 @@ BaseException___traceback___set(PyObject *self, PyObject *value, void *Py_UNUSED return return_value; } -#if !defined(BaseException___context___DOCSTR) -# define BaseException___context___DOCSTR NULL -#endif -#if defined(BASEEXCEPTION___CONTEXT___GETSETDEF) -# undef BASEEXCEPTION___CONTEXT___GETSETDEF -# define BASEEXCEPTION___CONTEXT___GETSETDEF {"__context__", (getter)BaseException___context___get, (setter)BaseException___context___set, BaseException___context___DOCSTR}, -#else -# define BASEEXCEPTION___CONTEXT___GETSETDEF {"__context__", (getter)BaseException___context___get, NULL, BaseException___context___DOCSTR}, -#endif - static PyObject * BaseException___context___get_impl(PyBaseExceptionObject *self); @@ -232,25 +232,23 @@ BaseException___context___get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(BaseException___context___DOCSTR) -# define BaseException___context___DOCSTR NULL -#endif -#if defined(BASEEXCEPTION___CONTEXT___GETSETDEF) -# undef BASEEXCEPTION___CONTEXT___GETSETDEF -# define BASEEXCEPTION___CONTEXT___GETSETDEF {"__context__", (getter)BaseException___context___get, (setter)BaseException___context___set, BaseException___context___DOCSTR}, -#else -# define BASEEXCEPTION___CONTEXT___GETSETDEF {"__context__", NULL, (setter)BaseException___context___set, NULL}, -#endif - static int BaseException___context___set_impl(PyBaseExceptionObject *self, PyObject *value); static int -BaseException___context___set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +BaseException___context___set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; - + int return_value = -1; + PyObject *value; + + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute '__context__' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = BaseException___context___set_impl((PyBaseExceptionObject *)self, value); Py_END_CRITICAL_SECTION(); @@ -258,16 +256,6 @@ BaseException___context___set(PyObject *self, PyObject *value, void *Py_UNUSED(c return return_value; } -#if !defined(BaseException___cause___DOCSTR) -# define BaseException___cause___DOCSTR NULL -#endif -#if defined(BASEEXCEPTION___CAUSE___GETSETDEF) -# undef BASEEXCEPTION___CAUSE___GETSETDEF -# define BASEEXCEPTION___CAUSE___GETSETDEF {"__cause__", (getter)BaseException___cause___get, (setter)BaseException___cause___set, BaseException___cause___DOCSTR}, -#else -# define BASEEXCEPTION___CAUSE___GETSETDEF {"__cause__", (getter)BaseException___cause___get, NULL, BaseException___cause___DOCSTR}, -#endif - static PyObject * BaseException___cause___get_impl(PyBaseExceptionObject *self); @@ -283,25 +271,23 @@ BaseException___cause___get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(BaseException___cause___DOCSTR) -# define BaseException___cause___DOCSTR NULL -#endif -#if defined(BASEEXCEPTION___CAUSE___GETSETDEF) -# undef BASEEXCEPTION___CAUSE___GETSETDEF -# define BASEEXCEPTION___CAUSE___GETSETDEF {"__cause__", (getter)BaseException___cause___get, (setter)BaseException___cause___set, BaseException___cause___DOCSTR}, -#else -# define BASEEXCEPTION___CAUSE___GETSETDEF {"__cause__", NULL, (setter)BaseException___cause___set, NULL}, -#endif - static int BaseException___cause___set_impl(PyBaseExceptionObject *self, PyObject *value); static int -BaseException___cause___set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +BaseException___cause___set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; - + int return_value = -1; + PyObject *value; + + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute '__cause__' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = BaseException___cause___set_impl((PyBaseExceptionObject *)self, value); Py_END_CRITICAL_SECTION(); @@ -380,4 +366,335 @@ BaseExceptionGroup_subgroup(PyObject *self, PyObject *matcher_value) return return_value; } -/*[clinic end generated code: output=e63b88d0443b4f92 input=a9049054013a1b77]*/ + +static int +ImportError_init_impl(PyImportErrorObject *self, PyObject *args, + PyObject *name, PyObject *path, PyObject *name_from); + +static int +ImportError_init_helper(PyObject *self, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) +{ + int return_value = -1; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 3 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(name), &_Py_ID(path), &_Py_ID(name_from), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"name", "path", "name_from", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "ImportError", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[3]; + PyObject * const *fastargs; + Py_ssize_t noptargs = 0 + nkw - 0; + PyObject *__clinic_args = NULL; + PyObject *name = NULL; + PyObject *path = NULL; + PyObject *name_from = NULL; + + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, + /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 1, argsbuf); + if (!fastargs) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (fastargs[0]) { + name = fastargs[0]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[1]) { + path = fastargs[1]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + name_from = fastargs[2]; +skip_optional_kwonly: + __clinic_args = PyTuple_FromArray(args, nargs); + if (__clinic_args == NULL) { + goto exit; + } + return_value = ImportError_init_impl((PyImportErrorObject *)self, __clinic_args, name, path, name_from); + +exit: + /* Cleanup for args */ + Py_XDECREF(__clinic_args); + + return return_value; +} + +static int +ImportError_init(PyObject *self, PyObject *args, PyObject *kwargs) +{ + return ImportError_init_helper(self, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +ImportError_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *self; + int _result; + + assert(_PyType_CAST(type)->tp_init == ImportError_init); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + self = _PyType_CAST(type)->tp_new(_PyType_CAST(type), + (PyObject *)&_Py_SINGLETON(tuple_empty), NULL); + if (self == NULL) { + return NULL; + } + _result = ImportError_init_helper(self, args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + if (_result != 0) { + Py_DECREF(self); + return NULL; + } + return self; +} + +static int +NameError_init_impl(PyNameErrorObject *self, PyObject *args, PyObject *name); + +static int +NameError_init_helper(PyObject *self, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) +{ + int return_value = -1; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(name), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"name", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "NameError", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t noptargs = 0 + nkw - 0; + PyObject *__clinic_args = NULL; + PyObject *name = NULL; + + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, + /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 1, argsbuf); + if (!fastargs) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + name = fastargs[0]; +skip_optional_kwonly: + __clinic_args = PyTuple_FromArray(args, nargs); + if (__clinic_args == NULL) { + goto exit; + } + return_value = NameError_init_impl((PyNameErrorObject *)self, __clinic_args, name); + +exit: + /* Cleanup for args */ + Py_XDECREF(__clinic_args); + + return return_value; +} + +static int +NameError_init(PyObject *self, PyObject *args, PyObject *kwargs) +{ + return NameError_init_helper(self, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +NameError_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *self; + int _result; + + assert(_PyType_CAST(type)->tp_init == NameError_init); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + self = _PyType_CAST(type)->tp_new(_PyType_CAST(type), + (PyObject *)&_Py_SINGLETON(tuple_empty), NULL); + if (self == NULL) { + return NULL; + } + _result = NameError_init_helper(self, args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + if (_result != 0) { + Py_DECREF(self); + return NULL; + } + return self; +} + +static int +AttributeError_init_impl(PyAttributeErrorObject *self, PyObject *args, + PyObject *name, PyObject *obj); + +static int +AttributeError_init_helper(PyObject *self, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) +{ + int return_value = -1; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 2 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(name), &_Py_ID(obj), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"name", "obj", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "AttributeError", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t noptargs = 0 + nkw - 0; + PyObject *__clinic_args = NULL; + PyObject *name = NULL; + PyObject *obj = NULL; + + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, + /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 1, argsbuf); + if (!fastargs) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (fastargs[0]) { + name = fastargs[0]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + obj = fastargs[1]; +skip_optional_kwonly: + __clinic_args = PyTuple_FromArray(args, nargs); + if (__clinic_args == NULL) { + goto exit; + } + return_value = AttributeError_init_impl((PyAttributeErrorObject *)self, __clinic_args, name, obj); + +exit: + /* Cleanup for args */ + Py_XDECREF(__clinic_args); + + return return_value; +} + +static int +AttributeError_init(PyObject *self, PyObject *args, PyObject *kwargs) +{ + return AttributeError_init_helper(self, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +AttributeError_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *self; + int _result; + + assert(_PyType_CAST(type)->tp_init == AttributeError_init); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + self = _PyType_CAST(type)->tp_new(_PyType_CAST(type), + (PyObject *)&_Py_SINGLETON(tuple_empty), NULL); + if (self == NULL) { + return NULL; + } + _result = AttributeError_init_helper(self, args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + if (_result != 0) { + Py_DECREF(self); + return NULL; + } + return self; +} +#define BASEEXCEPTION_ARGS_GETSETDEF {"args", (getter)BaseException_args_get, (setter)BaseException_args_set, NULL}, + +#define BASEEXCEPTION___TRACEBACK___GETSETDEF {"__traceback__", (getter)BaseException___traceback___get, (setter)BaseException___traceback___set, NULL}, + +#define BASEEXCEPTION___CONTEXT___GETSETDEF {"__context__", (getter)BaseException___context___get, (setter)BaseException___context___set, NULL}, + +#define BASEEXCEPTION___CAUSE___GETSETDEF {"__cause__", (getter)BaseException___cause___get, (setter)BaseException___cause___set, NULL}, + +/*[clinic end generated code: output=c8eaffee13bc041d input=a9049054013a1b77]*/ diff --git a/Objects/clinic/fileobject.c.h b/Objects/clinic/fileobject.c.h new file mode 100644 index 000000000000000..8eb05b4f5a5d851 --- /dev/null +++ b/Objects/clinic/fileobject.c.h @@ -0,0 +1,35 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#include "pycore_modsupport.h" // _PyArg_BadArgument() + +PyDoc_STRVAR(stdprinter_write__doc__, +"write($self, text, /)\n" +"--\n" +"\n" +"Write the text to the stream."); + +#define STDPRINTER_WRITE_METHODDEF \ + {"write", (PyCFunction)stdprinter_write, METH_O, stdprinter_write__doc__}, + +static PyObject * +stdprinter_write_impl(PyStdPrinter_Object *self, PyObject *unicode); + +static PyObject * +stdprinter_write(PyObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + PyObject *unicode; + + if (!PyUnicode_Check(arg)) { + _PyArg_BadArgument("write", "argument", "str", arg); + goto exit; + } + unicode = arg; + return_value = stdprinter_write_impl((PyStdPrinter_Object *)self, unicode); + +exit: + return return_value; +} +/*[clinic end generated code: output=7cf7d4c181518bbb input=a9049054013a1b77]*/ diff --git a/Objects/clinic/floatobject.c.h b/Objects/clinic/floatobject.c.h index 8768555c909257a..9c71663a1503ac4 100644 --- a/Objects/clinic/floatobject.c.h +++ b/Objects/clinic/floatobject.c.h @@ -3,6 +3,7 @@ preserve [clinic start generated code]*/ #include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(float_is_integer__doc__, "is_integer($self, /)\n" @@ -240,6 +241,35 @@ float_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +float_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *x = NULL; + + assert(_PyType_CAST(type)->tp_new == float_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("float", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("float", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + x = args[0]; +skip_optional: + return_value = float_new_impl(_PyType_CAST(type), x); + +exit: + return return_value; +} + PyDoc_STRVAR(float_from_number__doc__, "from_number($type, number, /)\n" "--\n" @@ -310,15 +340,10 @@ float___getformat__(PyObject *type, PyObject *arg) _PyArg_BadArgument("__getformat__", "argument", "str", arg); goto exit; } - Py_ssize_t typestr_length; - typestr = PyUnicode_AsUTF8AndSize(arg, &typestr_length); + typestr = _PyUnicode_AsUTF8NoNUL(arg); if (typestr == NULL) { goto exit; } - if (strlen(typestr) != (size_t)typestr_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = float___getformat___impl((PyTypeObject *)type, typestr); exit: @@ -353,4 +378,4 @@ float___format__(PyObject *self, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=5d7b0bf9e47ff997 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d1198594a76a4638 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/frameobject.c.h b/Objects/clinic/frameobject.c.h index 327896f4b97c684..9ea0eaa662a164f 100644 --- a/Objects/clinic/frameobject.c.h +++ b/Objects/clinic/frameobject.c.h @@ -3,23 +3,68 @@ preserve [clinic start generated code]*/ #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() +#include "pycore_modsupport.h" // _PyArg_CheckPositional() + +PyDoc_STRVAR(framelocalsproxy_new__doc__, +"FrameLocalsProxy(frame, /)\n" +"--\n" +"\n" +"Create a write-through view of the locals dictionary for a frame.\n" +"\n" +" frame\n" +" the frame object to wrap."); + +static PyObject * +framelocalsproxy_new_impl(PyTypeObject *type, PyObject *frame); + +static PyObject * +framelocalsproxy_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyTypeObject *base_tp = &PyFrameLocalsProxy_Type; + PyObject *frame; + + if ((type == base_tp || type->tp_init == base_tp->tp_init) && + !_PyArg_NoKeywords("FrameLocalsProxy", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("FrameLocalsProxy", PyTuple_GET_SIZE(args), 1, 1)) { + goto exit; + } + frame = PyTuple_GET_ITEM(args, 0); + return_value = framelocalsproxy_new_impl(type, frame); + +exit: + return return_value; +} + +static PyObject * +framelocalsproxy_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *frame; + + assert(_PyType_CAST(type)->tp_new == framelocalsproxy_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("FrameLocalsProxy", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("FrameLocalsProxy", nargs, 1, 1)) { + goto exit; + } + frame = args[0]; + return_value = framelocalsproxy_new_impl(_PyType_CAST(type), frame); + +exit: + return return_value; +} PyDoc_STRVAR(frame_locals__doc__, "Return the mapping used by the frame to look up local variables."); -#if defined(frame_locals_DOCSTR) -# undef frame_locals_DOCSTR -#endif -#define frame_locals_DOCSTR frame_locals__doc__ - -#if !defined(frame_locals_DOCSTR) -# define frame_locals_DOCSTR NULL -#endif -#if defined(FRAME_LOCALS_GETSETDEF) -# undef FRAME_LOCALS_GETSETDEF -# define FRAME_LOCALS_GETSETDEF {"f_locals", (getter)frame_locals_get, (setter)frame_locals_set, frame_locals_DOCSTR}, -#else -# define FRAME_LOCALS_GETSETDEF {"f_locals", (getter)frame_locals_get, NULL, frame_locals_DOCSTR}, -#endif static PyObject * frame_locals_get_impl(PyFrameObject *self); @@ -38,20 +83,6 @@ frame_locals_get(PyObject *self, void *Py_UNUSED(context)) PyDoc_STRVAR(frame_lineno__doc__, "Return the current line number in the frame."); -#if defined(frame_lineno_DOCSTR) -# undef frame_lineno_DOCSTR -#endif -#define frame_lineno_DOCSTR frame_lineno__doc__ - -#if !defined(frame_lineno_DOCSTR) -# define frame_lineno_DOCSTR NULL -#endif -#if defined(FRAME_LINENO_GETSETDEF) -# undef FRAME_LINENO_GETSETDEF -# define FRAME_LINENO_GETSETDEF {"f_lineno", (getter)frame_lineno_get, (setter)frame_lineno_set, frame_lineno_DOCSTR}, -#else -# define FRAME_LINENO_GETSETDEF {"f_lineno", (getter)frame_lineno_get, NULL, frame_lineno_DOCSTR}, -#endif static PyObject * frame_lineno_get_impl(PyFrameObject *self); @@ -70,20 +101,6 @@ frame_lineno_get(PyObject *self, void *Py_UNUSED(context)) PyDoc_STRVAR(frame_lasti__doc__, "Return the index of the last attempted instruction in the frame."); -#if defined(frame_lasti_DOCSTR) -# undef frame_lasti_DOCSTR -#endif -#define frame_lasti_DOCSTR frame_lasti__doc__ - -#if !defined(frame_lasti_DOCSTR) -# define frame_lasti_DOCSTR NULL -#endif -#if defined(FRAME_LASTI_GETSETDEF) -# undef FRAME_LASTI_GETSETDEF -# define FRAME_LASTI_GETSETDEF {"f_lasti", (getter)frame_lasti_get, (setter)frame_lasti_set, frame_lasti_DOCSTR}, -#else -# define FRAME_LASTI_GETSETDEF {"f_lasti", (getter)frame_lasti_get, NULL, frame_lasti_DOCSTR}, -#endif static PyObject * frame_lasti_get_impl(PyFrameObject *self); @@ -102,20 +119,6 @@ frame_lasti_get(PyObject *self, void *Py_UNUSED(context)) PyDoc_STRVAR(frame_globals__doc__, "Return the global variables in the frame."); -#if defined(frame_globals_DOCSTR) -# undef frame_globals_DOCSTR -#endif -#define frame_globals_DOCSTR frame_globals__doc__ - -#if !defined(frame_globals_DOCSTR) -# define frame_globals_DOCSTR NULL -#endif -#if defined(FRAME_GLOBALS_GETSETDEF) -# undef FRAME_GLOBALS_GETSETDEF -# define FRAME_GLOBALS_GETSETDEF {"f_globals", (getter)frame_globals_get, (setter)frame_globals_set, frame_globals_DOCSTR}, -#else -# define FRAME_GLOBALS_GETSETDEF {"f_globals", (getter)frame_globals_get, NULL, frame_globals_DOCSTR}, -#endif static PyObject * frame_globals_get_impl(PyFrameObject *self); @@ -134,20 +137,6 @@ frame_globals_get(PyObject *self, void *Py_UNUSED(context)) PyDoc_STRVAR(frame_builtins__doc__, "Return the built-in variables in the frame."); -#if defined(frame_builtins_DOCSTR) -# undef frame_builtins_DOCSTR -#endif -#define frame_builtins_DOCSTR frame_builtins__doc__ - -#if !defined(frame_builtins_DOCSTR) -# define frame_builtins_DOCSTR NULL -#endif -#if defined(FRAME_BUILTINS_GETSETDEF) -# undef FRAME_BUILTINS_GETSETDEF -# define FRAME_BUILTINS_GETSETDEF {"f_builtins", (getter)frame_builtins_get, (setter)frame_builtins_set, frame_builtins_DOCSTR}, -#else -# define FRAME_BUILTINS_GETSETDEF {"f_builtins", (getter)frame_builtins_get, NULL, frame_builtins_DOCSTR}, -#endif static PyObject * frame_builtins_get_impl(PyFrameObject *self); @@ -166,20 +155,6 @@ frame_builtins_get(PyObject *self, void *Py_UNUSED(context)) PyDoc_STRVAR(frame_code__doc__, "Return the code object being executed in this frame."); -#if defined(frame_code_DOCSTR) -# undef frame_code_DOCSTR -#endif -#define frame_code_DOCSTR frame_code__doc__ - -#if !defined(frame_code_DOCSTR) -# define frame_code_DOCSTR NULL -#endif -#if defined(FRAME_CODE_GETSETDEF) -# undef FRAME_CODE_GETSETDEF -# define FRAME_CODE_GETSETDEF {"f_code", (getter)frame_code_get, (setter)frame_code_set, frame_code_DOCSTR}, -#else -# define FRAME_CODE_GETSETDEF {"f_code", (getter)frame_code_get, NULL, frame_code_DOCSTR}, -#endif static PyObject * frame_code_get_impl(PyFrameObject *self); @@ -190,16 +165,6 @@ frame_code_get(PyObject *self, void *Py_UNUSED(context)) return frame_code_get_impl((PyFrameObject *)self); } -#if !defined(frame_back_DOCSTR) -# define frame_back_DOCSTR NULL -#endif -#if defined(FRAME_BACK_GETSETDEF) -# undef FRAME_BACK_GETSETDEF -# define FRAME_BACK_GETSETDEF {"f_back", (getter)frame_back_get, (setter)frame_back_set, frame_back_DOCSTR}, -#else -# define FRAME_BACK_GETSETDEF {"f_back", (getter)frame_back_get, NULL, frame_back_DOCSTR}, -#endif - static PyObject * frame_back_get_impl(PyFrameObject *self); @@ -217,20 +182,6 @@ frame_back_get(PyObject *self, void *Py_UNUSED(context)) PyDoc_STRVAR(frame_trace_opcodes__doc__, "Return True if opcode tracing is enabled, False otherwise."); -#if defined(frame_trace_opcodes_DOCSTR) -# undef frame_trace_opcodes_DOCSTR -#endif -#define frame_trace_opcodes_DOCSTR frame_trace_opcodes__doc__ - -#if !defined(frame_trace_opcodes_DOCSTR) -# define frame_trace_opcodes_DOCSTR NULL -#endif -#if defined(FRAME_TRACE_OPCODES_GETSETDEF) -# undef FRAME_TRACE_OPCODES_GETSETDEF -# define FRAME_TRACE_OPCODES_GETSETDEF {"f_trace_opcodes", (getter)frame_trace_opcodes_get, (setter)frame_trace_opcodes_set, frame_trace_opcodes_DOCSTR}, -#else -# define FRAME_TRACE_OPCODES_GETSETDEF {"f_trace_opcodes", (getter)frame_trace_opcodes_get, NULL, frame_trace_opcodes_DOCSTR}, -#endif static PyObject * frame_trace_opcodes_get_impl(PyFrameObject *self); @@ -247,24 +198,22 @@ frame_trace_opcodes_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(frame_trace_opcodes_DOCSTR) -# define frame_trace_opcodes_DOCSTR NULL -#endif -#if defined(FRAME_TRACE_OPCODES_GETSETDEF) -# undef FRAME_TRACE_OPCODES_GETSETDEF -# define FRAME_TRACE_OPCODES_GETSETDEF {"f_trace_opcodes", (getter)frame_trace_opcodes_get, (setter)frame_trace_opcodes_set, frame_trace_opcodes_DOCSTR}, -#else -# define FRAME_TRACE_OPCODES_GETSETDEF {"f_trace_opcodes", NULL, (setter)frame_trace_opcodes_set, NULL}, -#endif - static int frame_trace_opcodes_set_impl(PyFrameObject *self, PyObject *value); static int -frame_trace_opcodes_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +frame_trace_opcodes_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; - + int return_value = -1; + PyObject *value; + + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'f_trace_opcodes' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = frame_trace_opcodes_set_impl((PyFrameObject *)self, value); Py_END_CRITICAL_SECTION(); @@ -272,24 +221,22 @@ frame_trace_opcodes_set(PyObject *self, PyObject *value, void *Py_UNUSED(context return return_value; } -#if !defined(frame_lineno_DOCSTR) -# define frame_lineno_DOCSTR NULL -#endif -#if defined(FRAME_LINENO_GETSETDEF) -# undef FRAME_LINENO_GETSETDEF -# define FRAME_LINENO_GETSETDEF {"f_lineno", (getter)frame_lineno_get, (setter)frame_lineno_set, frame_lineno_DOCSTR}, -#else -# define FRAME_LINENO_GETSETDEF {"f_lineno", NULL, (setter)frame_lineno_set, NULL}, -#endif - static int frame_lineno_set_impl(PyFrameObject *self, PyObject *value); static int -frame_lineno_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +frame_lineno_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; - + int return_value = -1; + PyObject *value; + + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'f_lineno' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = frame_lineno_set_impl((PyFrameObject *)self, value); Py_END_CRITICAL_SECTION(); @@ -299,20 +246,6 @@ frame_lineno_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) PyDoc_STRVAR(frame_trace__doc__, "Return the trace function for this frame, or None if no trace function is set."); -#if defined(frame_trace_DOCSTR) -# undef frame_trace_DOCSTR -#endif -#define frame_trace_DOCSTR frame_trace__doc__ - -#if !defined(frame_trace_DOCSTR) -# define frame_trace_DOCSTR NULL -#endif -#if defined(FRAME_TRACE_GETSETDEF) -# undef FRAME_TRACE_GETSETDEF -# define FRAME_TRACE_GETSETDEF {"f_trace", (getter)frame_trace_get, (setter)frame_trace_set, frame_trace_DOCSTR}, -#else -# define FRAME_TRACE_GETSETDEF {"f_trace", (getter)frame_trace_get, NULL, frame_trace_DOCSTR}, -#endif static PyObject * frame_trace_get_impl(PyFrameObject *self); @@ -329,24 +262,18 @@ frame_trace_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(frame_trace_DOCSTR) -# define frame_trace_DOCSTR NULL -#endif -#if defined(FRAME_TRACE_GETSETDEF) -# undef FRAME_TRACE_GETSETDEF -# define FRAME_TRACE_GETSETDEF {"f_trace", (getter)frame_trace_get, (setter)frame_trace_set, frame_trace_DOCSTR}, -#else -# define FRAME_TRACE_GETSETDEF {"f_trace", NULL, (setter)frame_trace_set, NULL}, -#endif - static int frame_trace_set_impl(PyFrameObject *self, PyObject *value); static int -frame_trace_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +frame_trace_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + PyObject *value = NULL; + if (arg != NULL) { + value = arg; + } Py_BEGIN_CRITICAL_SECTION(self); return_value = frame_trace_set_impl((PyFrameObject *)self, value); Py_END_CRITICAL_SECTION(); @@ -356,20 +283,6 @@ frame_trace_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) PyDoc_STRVAR(frame_generator__doc__, "Return the generator or coroutine associated with this frame, or None."); -#if defined(frame_generator_DOCSTR) -# undef frame_generator_DOCSTR -#endif -#define frame_generator_DOCSTR frame_generator__doc__ - -#if !defined(frame_generator_DOCSTR) -# define frame_generator_DOCSTR NULL -#endif -#if defined(FRAME_GENERATOR_GETSETDEF) -# undef FRAME_GENERATOR_GETSETDEF -# define FRAME_GENERATOR_GETSETDEF {"f_generator", (getter)frame_generator_get, (setter)frame_generator_set, frame_generator_DOCSTR}, -#else -# define FRAME_GENERATOR_GETSETDEF {"f_generator", (getter)frame_generator_get, NULL, frame_generator_DOCSTR}, -#endif static PyObject * frame_generator_get_impl(PyFrameObject *self); @@ -433,4 +346,39 @@ frame___sizeof__(PyObject *self, PyObject *Py_UNUSED(ignored)) return return_value; } -/*[clinic end generated code: output=74abf652547c0c11 input=a9049054013a1b77]*/ + +static PyObject * +frame_repr_impl(PyFrameObject *self); + +static PyObject * +frame_repr(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = frame_repr_impl((PyFrameObject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} +#define FRAME_F_LOCALS_GETSETDEF {"f_locals", (getter)frame_locals_get, (setter)NULL, frame_locals__doc__}, + +#define FRAME_F_LINENO_GETSETDEF {"f_lineno", (getter)frame_lineno_get, (setter)frame_lineno_set, frame_lineno__doc__}, + +#define FRAME_F_LASTI_GETSETDEF {"f_lasti", (getter)frame_lasti_get, (setter)NULL, frame_lasti__doc__}, + +#define FRAME_F_GLOBALS_GETSETDEF {"f_globals", (getter)frame_globals_get, (setter)NULL, frame_globals__doc__}, + +#define FRAME_F_BUILTINS_GETSETDEF {"f_builtins", (getter)frame_builtins_get, (setter)NULL, frame_builtins__doc__}, + +#define FRAME_F_CODE_GETSETDEF {"f_code", (getter)frame_code_get, (setter)NULL, frame_code__doc__}, + +#define FRAME_F_BACK_GETSETDEF {"f_back", (getter)frame_back_get, (setter)NULL, NULL}, + +#define FRAME_F_TRACE_OPCODES_GETSETDEF {"f_trace_opcodes", (getter)frame_trace_opcodes_get, (setter)frame_trace_opcodes_set, frame_trace_opcodes__doc__}, + +#define FRAME_F_TRACE_GETSETDEF {"f_trace", (getter)frame_trace_get, (setter)frame_trace_set, frame_trace__doc__}, + +#define FRAME_F_GENERATOR_GETSETDEF {"f_generator", (getter)frame_generator_get, (setter)NULL, frame_generator__doc__}, + +/*[clinic end generated code: output=e6d74bb87e4b1a95 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/funcobject.c.h b/Objects/clinic/funcobject.c.h index fec743146466a45..8bf0a8a855f1721 100644 --- a/Objects/clinic/funcobject.c.h +++ b/Objects/clinic/funcobject.c.h @@ -11,20 +11,6 @@ preserve PyDoc_STRVAR(function___annotate____doc__, "Get the code object for a function."); -#if defined(function___annotate___DOCSTR) -# undef function___annotate___DOCSTR -#endif -#define function___annotate___DOCSTR function___annotate____doc__ - -#if !defined(function___annotate___DOCSTR) -# define function___annotate___DOCSTR NULL -#endif -#if defined(FUNCTION___ANNOTATE___GETSETDEF) -# undef FUNCTION___ANNOTATE___GETSETDEF -# define FUNCTION___ANNOTATE___GETSETDEF {"__annotate__", (getter)function___annotate___get, (setter)function___annotate___set, function___annotate___DOCSTR}, -#else -# define FUNCTION___ANNOTATE___GETSETDEF {"__annotate__", (getter)function___annotate___get, NULL, function___annotate___DOCSTR}, -#endif static PyObject * function___annotate___get_impl(PyFunctionObject *self); @@ -41,24 +27,22 @@ function___annotate___get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(function___annotate___DOCSTR) -# define function___annotate___DOCSTR NULL -#endif -#if defined(FUNCTION___ANNOTATE___GETSETDEF) -# undef FUNCTION___ANNOTATE___GETSETDEF -# define FUNCTION___ANNOTATE___GETSETDEF {"__annotate__", (getter)function___annotate___get, (setter)function___annotate___set, function___annotate___DOCSTR}, -#else -# define FUNCTION___ANNOTATE___GETSETDEF {"__annotate__", NULL, (setter)function___annotate___set, NULL}, -#endif - static int function___annotate___set_impl(PyFunctionObject *self, PyObject *value); static int -function___annotate___set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +function___annotate___set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; - + int return_value = -1; + PyObject *value; + + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute '__annotate__' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = function___annotate___set_impl((PyFunctionObject *)self, value); Py_END_CRITICAL_SECTION(); @@ -68,20 +52,6 @@ function___annotate___set(PyObject *self, PyObject *value, void *Py_UNUSED(conte PyDoc_STRVAR(function___annotations____doc__, "Dict of annotations in a function object."); -#if defined(function___annotations___DOCSTR) -# undef function___annotations___DOCSTR -#endif -#define function___annotations___DOCSTR function___annotations____doc__ - -#if !defined(function___annotations___DOCSTR) -# define function___annotations___DOCSTR NULL -#endif -#if defined(FUNCTION___ANNOTATIONS___GETSETDEF) -# undef FUNCTION___ANNOTATIONS___GETSETDEF -# define FUNCTION___ANNOTATIONS___GETSETDEF {"__annotations__", (getter)function___annotations___get, (setter)function___annotations___set, function___annotations___DOCSTR}, -#else -# define FUNCTION___ANNOTATIONS___GETSETDEF {"__annotations__", (getter)function___annotations___get, NULL, function___annotations___DOCSTR}, -#endif static PyObject * function___annotations___get_impl(PyFunctionObject *self); @@ -98,24 +68,18 @@ function___annotations___get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(function___annotations___DOCSTR) -# define function___annotations___DOCSTR NULL -#endif -#if defined(FUNCTION___ANNOTATIONS___GETSETDEF) -# undef FUNCTION___ANNOTATIONS___GETSETDEF -# define FUNCTION___ANNOTATIONS___GETSETDEF {"__annotations__", (getter)function___annotations___get, (setter)function___annotations___set, function___annotations___DOCSTR}, -#else -# define FUNCTION___ANNOTATIONS___GETSETDEF {"__annotations__", NULL, (setter)function___annotations___set, NULL}, -#endif - static int function___annotations___set_impl(PyFunctionObject *self, PyObject *value); static int -function___annotations___set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +function___annotations___set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; + int return_value = -1; + PyObject *value = NULL; + if (arg != NULL) { + value = arg; + } Py_BEGIN_CRITICAL_SECTION(self); return_value = function___annotations___set_impl((PyFunctionObject *)self, value); Py_END_CRITICAL_SECTION(); @@ -125,20 +89,6 @@ function___annotations___set(PyObject *self, PyObject *value, void *Py_UNUSED(co PyDoc_STRVAR(function___type_params____doc__, "Get the declared type parameters for a function."); -#if defined(function___type_params___DOCSTR) -# undef function___type_params___DOCSTR -#endif -#define function___type_params___DOCSTR function___type_params____doc__ - -#if !defined(function___type_params___DOCSTR) -# define function___type_params___DOCSTR NULL -#endif -#if defined(FUNCTION___TYPE_PARAMS___GETSETDEF) -# undef FUNCTION___TYPE_PARAMS___GETSETDEF -# define FUNCTION___TYPE_PARAMS___GETSETDEF {"__type_params__", (getter)function___type_params___get, (setter)function___type_params___set, function___type_params___DOCSTR}, -#else -# define FUNCTION___TYPE_PARAMS___GETSETDEF {"__type_params__", (getter)function___type_params___get, NULL, function___type_params___DOCSTR}, -#endif static PyObject * function___type_params___get_impl(PyFunctionObject *self); @@ -155,28 +105,31 @@ function___type_params___get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(function___type_params___DOCSTR) -# define function___type_params___DOCSTR NULL -#endif -#if defined(FUNCTION___TYPE_PARAMS___GETSETDEF) -# undef FUNCTION___TYPE_PARAMS___GETSETDEF -# define FUNCTION___TYPE_PARAMS___GETSETDEF {"__type_params__", (getter)function___type_params___get, (setter)function___type_params___set, function___type_params___DOCSTR}, -#else -# define FUNCTION___TYPE_PARAMS___GETSETDEF {"__type_params__", NULL, (setter)function___type_params___set, NULL}, -#endif - static int function___type_params___set_impl(PyFunctionObject *self, PyObject *value); static int -function___type_params___set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +function___type_params___set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; - + int return_value = -1; + PyObject *value; + + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute '__type_params__' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + if (!PyTuple_Check(arg)) { + PyErr_Format(PyExc_TypeError, "attribute '__type_params__' must be tuple, not %T", arg); + goto exit; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = function___type_params___set_impl((PyFunctionObject *)self, value); Py_END_CRITICAL_SECTION(); +exit: return return_value; } @@ -206,7 +159,8 @@ func_new_impl(PyTypeObject *type, PyCodeObject *code, PyObject *globals, PyObject *kwdefaults); static PyObject * -func_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +func_new_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -238,8 +192,7 @@ func_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[6]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2; + Py_ssize_t noptargs = nargs + nkw - 2; PyCodeObject *code; PyObject *globals; PyObject *name = Py_None; @@ -247,7 +200,7 @@ func_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *closure = Py_None; PyObject *kwdefaults = Py_None; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 2, /*maxpos*/ 6, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -290,4 +243,74 @@ func_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=12cb900088d41bdb input=a9049054013a1b77]*/ + +static PyObject * +func_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return func_new_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +func_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyCodeObject *code; + PyObject *globals; + PyObject *name = Py_None; + PyObject *defaults = Py_None; + PyObject *closure = Py_None; + PyObject *kwdefaults = Py_None; + + assert(_PyType_CAST(type)->tp_new == func_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs < 2 || nargs > 6) { + return func_new_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + if (!PyObject_TypeCheck(args[0], &PyCode_Type)) { + _PyArg_BadArgument("function", "argument 'code'", (&PyCode_Type)->tp_name, args[0]); + goto exit; + } + code = (PyCodeObject *)args[0]; + if (!PyDict_Check(args[1])) { + _PyArg_BadArgument("function", "argument 'globals'", "dict", args[1]); + goto exit; + } + globals = args[1]; + if (nargs < 3) { + goto skip_optional; + } + name = args[2]; + if (nargs < 4) { + goto skip_optional; + } + defaults = args[3]; + if (nargs < 5) { + goto skip_optional; + } + closure = args[4]; + if (nargs < 6) { + goto skip_optional; + } + kwdefaults = args[5]; +skip_optional: + return_value = func_new_impl(_PyType_CAST(type), code, globals, name, defaults, closure, kwdefaults); + +exit: + return return_value; +} +#define FUNCTION___ANNOTATE___GETSETDEF {"__annotate__", (getter)function___annotate___get, (setter)function___annotate___set, function___annotate____doc__}, + +#define FUNCTION___ANNOTATIONS___GETSETDEF {"__annotations__", (getter)function___annotations___get, (setter)function___annotations___set, function___annotations____doc__}, + +#define FUNCTION___TYPE_PARAMS___GETSETDEF {"__type_params__", (getter)function___type_params___get, (setter)function___type_params___set, function___type_params____doc__}, + +/*[clinic end generated code: output=3cd73f64e8bd846e input=a9049054013a1b77]*/ diff --git a/Objects/clinic/interpolationobject.c.h b/Objects/clinic/interpolationobject.c.h index 2030e17e49e47a7..665f00462fe2c61 100644 --- a/Objects/clinic/interpolationobject.c.h +++ b/Objects/clinic/interpolationobject.c.h @@ -14,7 +14,8 @@ interpolation_new_impl(PyTypeObject *type, PyObject *value, PyObject *format_spec); static PyObject * -interpolation_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +interpolation_new_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -46,14 +47,13 @@ interpolation_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[4]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + Py_ssize_t noptargs = nargs + nkw - 1; PyObject *value; PyObject *expression = &_Py_STR(empty); PyObject *conversion = Py_None; PyObject *format_spec = &_Py_STR(empty); - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 4, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -91,4 +91,63 @@ interpolation_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=2391391e2d7708c0 input=a9049054013a1b77]*/ + +static PyObject * +interpolation_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return interpolation_new_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +interpolation_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *value; + PyObject *expression = &_Py_STR(empty); + PyObject *conversion = Py_None; + PyObject *format_spec = &_Py_STR(empty); + + assert(_PyType_CAST(type)->tp_new == interpolation_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs < 1 || nargs > 4) { + return interpolation_new_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + value = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("Interpolation", "argument 'expression'", "str", args[1]); + goto exit; + } + expression = args[1]; + if (nargs < 3) { + goto skip_optional; + } + if (!_conversion_converter(args[2], &conversion)) { + goto exit; + } + if (nargs < 4) { + goto skip_optional; + } + if (!PyUnicode_Check(args[3])) { + _PyArg_BadArgument("Interpolation", "argument 'format_spec'", "str", args[3]); + goto exit; + } + format_spec = args[3]; +skip_optional: + return_value = interpolation_new_impl(_PyType_CAST(type), value, expression, conversion, format_spec); + +exit: + return return_value; +} +/*[clinic end generated code: output=d07caaaa0e78ca15 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/listobject.c.h b/Objects/clinic/listobject.c.h index f3821ef5f70c21c..359b9c202694472 100644 --- a/Objects/clinic/listobject.c.h +++ b/Objects/clinic/listobject.c.h @@ -10,6 +10,66 @@ preserve #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_modsupport.h" // _PyArg_CheckPositional() +static PyObject * +list_repr_impl(PyListObject *v); + +static PyObject * +list_repr(PyObject *v) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(v); + return_value = list_repr_impl((PyListObject *)v); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static PyObject * +list_repeat_impl(PyListObject *a, Py_ssize_t n); + +static PyObject * +list_repeat(PyObject *a, Py_ssize_t n) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(a); + return_value = list_repeat_impl((PyListObject *)a, n); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static PyObject * +list_inplace_repeat_impl(PyListObject *self, Py_ssize_t n); + +static PyObject * +list_inplace_repeat(PyObject *self, Py_ssize_t n) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = list_inplace_repeat_impl((PyListObject *)self, n); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +static int +list_ass_item_impl(PyListObject *a, Py_ssize_t i, PyObject *v); + +static int +list_ass_item(PyObject *a, Py_ssize_t i, PyObject *v) +{ + int return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(a); + return_value = list_ass_item_impl((PyListObject *)a, i, v); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(list_insert__doc__, "insert($self, index, object, /)\n" "--\n" @@ -468,4 +528,4 @@ list___reversed__(PyObject *self, PyObject *Py_UNUSED(ignored)) { return list___reversed___impl((PyListObject *)self); } -/*[clinic end generated code: output=06c21b0bffbe8d84 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=9eab9551fc4cea1c input=a9049054013a1b77]*/ diff --git a/Objects/clinic/memoryobject.c.h b/Objects/clinic/memoryobject.c.h index a0cf3243edc08a0..bb81e11e9a0ce20 100644 --- a/Objects/clinic/memoryobject.c.h +++ b/Objects/clinic/memoryobject.c.h @@ -8,6 +8,7 @@ preserve #endif #include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(memoryview__doc__, "memoryview(object)\n" @@ -19,7 +20,8 @@ static PyObject * memoryview_impl(PyTypeObject *type, PyObject *object); static PyObject * -memoryview(PyTypeObject *type, PyObject *args, PyObject *kwargs) +memoryview_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) @@ -51,10 +53,9 @@ memoryview(PyTypeObject *type, PyObject *args, PyObject *kwargs) #undef KWTUPLE PyObject *argsbuf[1]; PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *object; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!fastargs) { goto exit; @@ -66,6 +67,38 @@ memoryview(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +memoryview(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return memoryview_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +memoryview_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *object; + + assert(_PyType_CAST(type)->tp_new == memoryview); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (kwnames != NULL || nargs < 1 || nargs > 1) { + return memoryview_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); + } + object = args[0]; + return_value = memoryview_impl(_PyType_CAST(type), object); + + return return_value; +} + PyDoc_STRVAR(memoryview__from_flags__doc__, "_from_flags($type, /, object, flags)\n" "--\n" @@ -147,18 +180,50 @@ memoryview_release(PyObject *self, PyObject *Py_UNUSED(ignored)) return memoryview_release_impl((PyMemoryViewObject *)self); } +PyDoc_STRVAR(memoryview___exit____doc__, +"__exit__($self, /, *exc_info)\n" +"--\n" +"\n" +"Release the underlying buffer exposed by the memoryview object."); + +#define MEMORYVIEW___EXIT___METHODDEF \ + {"__exit__", _PyCFunction_CAST(memoryview___exit__), METH_FASTCALL, memoryview___exit____doc__}, + +static PyObject * +memoryview___exit___impl(PyMemoryViewObject *self, + PyObject * const *exc_info, + Py_ssize_t exc_info_length); + +static PyObject * +memoryview___exit__(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject * const *exc_info; + Py_ssize_t exc_info_length; + + exc_info = args; + exc_info_length = nargs; + return_value = memoryview___exit___impl((PyMemoryViewObject *)self, exc_info, exc_info_length); + + return return_value; +} + PyDoc_STRVAR(memoryview_cast__doc__, -"cast($self, /, format, shape=)\n" +"cast($self, /, format, shape=, *, order=\'C\')\n" "--\n" "\n" -"Cast a memoryview to a new format or shape."); +"Cast a memoryview to a new format or shape.\n" +"\n" +"With a multidimensional *shape*, *order* selects the result\n" +"layout: \'C\' for C-contiguous (row-major, the default) or \'F\'\n" +"for Fortran-contiguous (column-major)."); #define MEMORYVIEW_CAST_METHODDEF \ {"cast", _PyCFunction_CAST(memoryview_cast), METH_FASTCALL|METH_KEYWORDS, memoryview_cast__doc__}, static PyObject * memoryview_cast_impl(PyMemoryViewObject *self, PyObject *format, - PyObject *shape); + PyObject *shape, int order); static PyObject * memoryview_cast(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) @@ -166,7 +231,7 @@ memoryview_cast(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObjec PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - #define NUM_KEYWORDS 2 + #define NUM_KEYWORDS 3 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD @@ -175,7 +240,7 @@ memoryview_cast(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObjec } _kwtuple = { .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) .ob_hash = -1, - .ob_item = { &_Py_ID(format), &_Py_ID(shape), }, + .ob_item = { &_Py_ID(format), &_Py_ID(shape), &_Py_ID(order), }, }; #undef NUM_KEYWORDS #define KWTUPLE (&_kwtuple.ob_base.ob_base) @@ -184,17 +249,18 @@ memoryview_cast(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObjec # define KWTUPLE NULL #endif // !Py_BUILD_CORE - static const char * const _keywords[] = {"format", "shape", NULL}; + static const char * const _keywords[] = {"format", "shape", "order", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, .fname = "cast", .kwtuple = KWTUPLE, }; #undef KWTUPLE - PyObject *argsbuf[2]; + PyObject *argsbuf[3]; Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *format; PyObject *shape = NULL; + int order = 'C'; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); @@ -209,9 +275,30 @@ memoryview_cast(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObjec if (!noptargs) { goto skip_optional_pos; } - shape = args[1]; + if (args[1]) { + shape = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } skip_optional_pos: - return_value = memoryview_cast_impl((PyMemoryViewObject *)self, format, shape); + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("cast", "argument 'order'", "a unicode character", args[2]); + goto exit; + } + if (PyUnicode_GET_LENGTH(args[2]) != 1) { + PyErr_Format(PyExc_TypeError, + "cast(): argument 'order' must be a unicode character, " + "not a string of length %zd", + PyUnicode_GET_LENGTH(args[2])); + goto exit; + } + order = PyUnicode_READ_CHAR(args[2], 0); +skip_optional_kwonly: + return_value = memoryview_cast_impl((PyMemoryViewObject *)self, format, shape, order); exit: return return_value; @@ -319,15 +406,10 @@ memoryview_tobytes(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb order = NULL; } else if (PyUnicode_Check(args[0])) { - Py_ssize_t order_length; - order = PyUnicode_AsUTF8AndSize(args[0], &order_length); + order = _PyUnicode_AsUTF8NoNUL(args[0]); if (order == NULL) { goto exit; } - if (strlen(order) != (size_t)order_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } } else { _PyArg_BadArgument("tobytes", "argument 'order'", "str or None", args[0]); @@ -506,4 +588,4 @@ memoryview_index(PyObject *self, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=3abf9c80cd49229a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=cdca13a132752f15 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/namespaceobject.c.h b/Objects/clinic/namespaceobject.c.h new file mode 100644 index 000000000000000..9f6301592d2c84c --- /dev/null +++ b/Objects/clinic/namespaceobject.c.h @@ -0,0 +1,37 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#include "pycore_modsupport.h" // _PyArg_NoPositional() + +PyDoc_STRVAR(namespace___replace____doc__, +"__replace__($self, /, **changes)\n" +"--\n" +"\n" +"Return a copy with the specified attributes replaced."); + +#define NAMESPACE___REPLACE___METHODDEF \ + {"__replace__", _PyCFunction_CAST(namespace___replace__), METH_VARARGS|METH_KEYWORDS, namespace___replace____doc__}, + +static PyObject * +namespace___replace___impl(_PyNamespaceObject *self, PyObject *changes); + +static PyObject * +namespace___replace__(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *changes = NULL; + + if (!_PyArg_NoPositional("__replace__", args)) { + goto exit; + } + changes = Py_XNewRef(kwargs); + return_value = namespace___replace___impl((_PyNamespaceObject *)self, changes); + +exit: + /* Cleanup for changes */ + Py_XDECREF(changes); + + return return_value; +} +/*[clinic end generated code: output=1b1c015f14360d64 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/odictobject.c.h b/Objects/clinic/odictobject.c.h index 92129e6444810f4..ebef5dad597c548 100644 --- a/Objects/clinic/odictobject.c.h +++ b/Objects/clinic/odictobject.c.h @@ -452,4 +452,19 @@ OrderedDict_move_to_end(PyObject *self, PyObject *const *args, Py_ssize_t nargs, exit: return return_value; } -/*[clinic end generated code: output=89f7e92de998f9a4 input=a9049054013a1b77]*/ + +static PyObject * +odictiter_iternext_impl(PyObject *self); + +static PyObject * +odictiter_iternext(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = odictiter_iternext_impl(self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} +/*[clinic end generated code: output=b729b3f1d40afcd9 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/picklebufobject.c.h b/Objects/clinic/picklebufobject.c.h new file mode 100644 index 000000000000000..e694942191a0fef --- /dev/null +++ b/Objects/clinic/picklebufobject.c.h @@ -0,0 +1,61 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#include "pycore_modsupport.h" // _PyArg_CheckPositional() + +PyDoc_STRVAR(picklebuf_new__doc__, +"PickleBuffer(buffer, /)\n" +"--\n" +"\n" +"Wrapper for potentially out-of-band buffers."); + +static PyObject * +picklebuf_new_impl(PyTypeObject *type, PyObject *base); + +static PyObject * +picklebuf_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyTypeObject *base_tp = &PyPickleBuffer_Type; + PyObject *base; + + if ((type == base_tp || type->tp_init == base_tp->tp_init) && + !_PyArg_NoKeywords("PickleBuffer", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("PickleBuffer", PyTuple_GET_SIZE(args), 1, 1)) { + goto exit; + } + base = PyTuple_GET_ITEM(args, 0); + return_value = picklebuf_new_impl(type, base); + +exit: + return return_value; +} + +static PyObject * +picklebuf_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *base; + + assert(_PyType_CAST(type)->tp_new == picklebuf_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("PickleBuffer", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("PickleBuffer", nargs, 1, 1)) { + goto exit; + } + base = args[0]; + return_value = picklebuf_new_impl(_PyType_CAST(type), base); + +exit: + return return_value; +} +/*[clinic end generated code: output=4c32a9c4ea5b9bfe input=a9049054013a1b77]*/ diff --git a/Objects/clinic/rangeobject.c.h b/Objects/clinic/rangeobject.c.h index d9142eddde4b176..1cdc2e43b50dbc0 100644 --- a/Objects/clinic/rangeobject.c.h +++ b/Objects/clinic/rangeobject.c.h @@ -147,4 +147,19 @@ longrange_iterator___setstate__(PyObject *r, PyObject *state) return return_value; } -/*[clinic end generated code: output=719c0e4c81fe0f4a input=a9049054013a1b77]*/ + +static PyObject * +longrangeiter_next_impl(longrangeiterobject *self); + +static PyObject * +longrangeiter_next(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = longrangeiter_next_impl((longrangeiterobject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} +/*[clinic end generated code: output=e31cc65008f9db4f input=a9049054013a1b77]*/ diff --git a/Objects/clinic/setobject.c.h b/Objects/clinic/setobject.c.h index 098c4bcb53d3fb1..8c9beaadccde866 100644 --- a/Objects/clinic/setobject.c.h +++ b/Objects/clinic/setobject.c.h @@ -4,6 +4,21 @@ preserve #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() +static PyObject * +set_repr_impl(PySetObject *so); + +static PyObject * +set_repr(PyObject *so) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(so); + return_value = set_repr_impl((PySetObject *)so); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + PyDoc_STRVAR(set_pop__doc__, "pop($self, /)\n" "--\n" @@ -552,4 +567,4 @@ set___sizeof__(PyObject *so, PyObject *Py_UNUSED(ignored)) return return_value; } -/*[clinic end generated code: output=5800c0bf136a5a0a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=5d794137d2614aaf input=a9049054013a1b77]*/ diff --git a/Objects/clinic/sliceobject.c.h b/Objects/clinic/sliceobject.c.h new file mode 100644 index 000000000000000..20df083f27458ef --- /dev/null +++ b/Objects/clinic/sliceobject.c.h @@ -0,0 +1,78 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#include "pycore_modsupport.h" // _PyArg_CheckPositional() + +static PyObject * +slice_new_impl(PyTypeObject *type, PyObject *start, PyObject *stop, + PyObject *step); + +static PyObject * +slice_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyTypeObject *base_tp = &PySlice_Type; + PyObject *start; + PyObject *stop = NULL; + PyObject *step = NULL; + + if ((type == base_tp || type->tp_init == base_tp->tp_init) && + !_PyArg_NoKeywords("slice", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("slice", PyTuple_GET_SIZE(args), 1, 3)) { + goto exit; + } + start = PyTuple_GET_ITEM(args, 0); + if (PyTuple_GET_SIZE(args) < 2) { + goto skip_optional; + } + stop = PyTuple_GET_ITEM(args, 1); + if (PyTuple_GET_SIZE(args) < 3) { + goto skip_optional; + } + step = PyTuple_GET_ITEM(args, 2); +skip_optional: + return_value = slice_new_impl(type, start, stop, step); + +exit: + return return_value; +} + +static PyObject * +slice_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *start; + PyObject *stop = NULL; + PyObject *step = NULL; + + assert(_PyType_CAST(type)->tp_new == slice_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("slice", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("slice", nargs, 1, 3)) { + goto exit; + } + start = args[0]; + if (nargs < 2) { + goto skip_optional; + } + stop = args[1]; + if (nargs < 3) { + goto skip_optional; + } + step = args[2]; +skip_optional: + return_value = slice_new_impl(_PyType_CAST(type), start, stop, step); + +exit: + return return_value; +} +/*[clinic end generated code: output=62159046029c6bdf input=a9049054013a1b77]*/ diff --git a/Objects/clinic/structseq.c.h b/Objects/clinic/structseq.c.h index 9642b480fa18b9c..ce5014311f4cca7 100644 --- a/Objects/clinic/structseq.c.h +++ b/Objects/clinic/structseq.c.h @@ -65,4 +65,35 @@ structseq_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=112d59f5e98d652b input=a9049054013a1b77]*/ + +PyDoc_STRVAR(structseq___replace____doc__, +"__replace__($self, /, **changes)\n" +"--\n" +"\n" +"Return a copy with new values for the specified fields."); + +#define STRUCTSEQ___REPLACE___METHODDEF \ + {"__replace__", _PyCFunction_CAST(structseq___replace__), METH_VARARGS|METH_KEYWORDS, structseq___replace____doc__}, + +static PyObject * +structseq___replace___impl(PyStructSequence *self, PyObject *changes); + +static PyObject * +structseq___replace__(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *changes = NULL; + + if (!_PyArg_NoPositional("__replace__", args)) { + goto exit; + } + changes = Py_XNewRef(kwargs); + return_value = structseq___replace___impl((PyStructSequence *)self, changes); + +exit: + /* Cleanup for changes */ + Py_XDECREF(changes); + + return return_value; +} +/*[clinic end generated code: output=f0231faecca9248b input=a9049054013a1b77]*/ diff --git a/Objects/clinic/templateobject.c.h b/Objects/clinic/templateobject.c.h new file mode 100644 index 000000000000000..7719fcf47bb80e6 --- /dev/null +++ b/Objects/clinic/templateobject.c.h @@ -0,0 +1,55 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#include "pycore_modsupport.h" // _PyArg_NoKeywords() +#include "pycore_tuple.h" // _PyTuple_ITEMS() + +static PyObject * +template_new_impl(PyTypeObject *type, PyObject * const *args, + Py_ssize_t args_length); + +static PyObject * +template_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyTypeObject *base_tp = &_PyTemplate_Type; + PyObject * const *__clinic_args; + Py_ssize_t args_length; + + if ((type == base_tp || type->tp_init == base_tp->tp_init) && + !_PyArg_NoKeywords("Template", kwargs)) { + goto exit; + } + __clinic_args = _PyTuple_ITEMS(args); + args_length = PyTuple_GET_SIZE(args); + return_value = template_new_impl(type, __clinic_args, args_length); + +exit: + return return_value; +} + +static PyObject * +template_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject * const *__clinic_args; + Py_ssize_t args_length; + + assert(_PyType_CAST(type)->tp_new == template_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("Template", kwnames)) { + goto exit; + } + __clinic_args = args; + args_length = nargs; + return_value = template_new_impl(_PyType_CAST(type), __clinic_args, args_length); + +exit: + return return_value; +} +/*[clinic end generated code: output=38d45f3b38a21517 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/tupleobject.c.h b/Objects/clinic/tupleobject.c.h index 1c12706c0bb43bc..9d6a3edf60bb24b 100644 --- a/Objects/clinic/tupleobject.c.h +++ b/Objects/clinic/tupleobject.c.h @@ -111,6 +111,35 @@ tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +static PyObject * +tuple_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *iterable = NULL; + + assert(_PyType_CAST(type)->tp_new == tuple_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("tuple", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("tuple", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + iterable = args[0]; +skip_optional: + return_value = tuple_new_impl(_PyType_CAST(type), iterable); + +exit: + return return_value; +} + PyDoc_STRVAR(tuple___getnewargs____doc__, "__getnewargs__($self, /)\n" "--\n" @@ -127,4 +156,4 @@ tuple___getnewargs__(PyObject *self, PyObject *Py_UNUSED(ignored)) { return tuple___getnewargs___impl((PyTupleObject *)self); } -/*[clinic end generated code: output=bd11662d62d973c2 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1bc2bfc233992933 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/typevarobject.c.h b/Objects/clinic/typevarobject.c.h index d2f350a3487f08b..95f09faceba0b59 100644 --- a/Objects/clinic/typevarobject.c.h +++ b/Objects/clinic/typevarobject.c.h @@ -727,7 +727,7 @@ typealias_reduce(PyObject *self, PyObject *Py_UNUSED(ignored)) } PyDoc_STRVAR(typealias_new__doc__, -"typealias(name, value, *, type_params=, qualname=None)\n" +"typealias(name, value, *, type_params=(), qualname=None)\n" "--\n" "\n" "Create a TypeAliasType."); @@ -803,4 +803,4 @@ typealias_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=2e7dd170924d92e5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=310ab79d0f3a4b5c input=a9049054013a1b77]*/ diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h index d0753b38843fccf..f214fa42fa1a594 100644 --- a/Objects/clinic/unicodeobject.c.h +++ b/Objects/clinic/unicodeobject.c.h @@ -8,6 +8,7 @@ preserve #endif #include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_modsupport.h" // _PyArg_CheckPositional() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(EncodingMap_size__doc__, "size($self, /)\n" @@ -263,15 +264,10 @@ unicode_encode(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject _PyArg_BadArgument("encode", "argument 'encoding'", "str", args[0]); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(args[0]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_pos; } @@ -280,15 +276,10 @@ unicode_encode(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject _PyArg_BadArgument("encode", "argument 'errors'", "str", args[1]); goto exit; } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(args[1]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } skip_optional_pos: return_value = unicode_encode_impl(self, encoding, errors); @@ -1884,15 +1875,10 @@ unicode_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("str", "argument 'encoding'", "str", fastargs[1]); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(fastargs[1]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!--noptargs) { goto skip_optional_pos; } @@ -1901,19 +1887,14 @@ unicode_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("str", "argument 'errors'", "str", fastargs[2]); goto exit; } - Py_ssize_t errors_length; - errors = PyUnicode_AsUTF8AndSize(fastargs[2], &errors_length); + errors = _PyUnicode_AsUTF8NoNUL(fastargs[2]); if (errors == NULL) { goto exit; } - if (strlen(errors) != (size_t)errors_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } skip_optional_pos: return_value = unicode_new_impl(type, x, encoding, errors); exit: return return_value; } -/*[clinic end generated code: output=9d243c63e951e31d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=80d039a395f835c3 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/weakrefobject.c.h b/Objects/clinic/weakrefobject.c.h new file mode 100644 index 000000000000000..b014b14217c96c1 --- /dev/null +++ b/Objects/clinic/weakrefobject.c.h @@ -0,0 +1,126 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() +#include "pycore_modsupport.h" // _PyArg_CheckPositional() + +static Py_hash_t +weakref_hash_impl(PyWeakReference *self); + +static Py_hash_t +weakref_hash(PyObject *self) +{ + Py_hash_t return_value = -1; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = weakref_hash_impl((PyWeakReference *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} + +PyDoc_STRVAR(weakref_ref_new__doc__, +"ReferenceType(object, callback=None, /)\n" +"--\n" +"\n" +"Create a weak reference to object.\n" +"\n" +"Calling the reference returns object, or None once it has been garbage\n" +"collected. If callback is given, it is called with the reference as\n" +"its only argument when object is about to be finalized."); + +static PyObject * +weakref_ref_new_impl(PyTypeObject *type, PyObject *object, + PyObject *callback); + +static PyObject * +weakref_ref_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyTypeObject *base_tp = &_PyWeakref_RefType; + PyObject *object; + PyObject *callback = NULL; + + if ((type == base_tp || type->tp_init == base_tp->tp_init) && + !_PyArg_NoKeywords("ReferenceType", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("ReferenceType", PyTuple_GET_SIZE(args), 1, 2)) { + goto exit; + } + object = PyTuple_GET_ITEM(args, 0); + if (PyTuple_GET_SIZE(args) < 2) { + goto skip_optional; + } + callback = PyTuple_GET_ITEM(args, 1); +skip_optional: + return_value = weakref_ref_new_impl(type, object, callback); + +exit: + return return_value; +} + +static PyObject * +weakref_ref_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *object; + PyObject *callback = NULL; + + assert(_PyType_CAST(type)->tp_new == weakref_ref_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("ReferenceType", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("ReferenceType", nargs, 1, 2)) { + goto exit; + } + object = args[0]; + if (nargs < 2) { + goto skip_optional; + } + callback = args[1]; +skip_optional: + return_value = weakref_ref_new_impl(_PyType_CAST(type), object, callback); + +exit: + return return_value; +} + +static int +weakref_ref_init_impl(PyWeakReference *self, PyObject *object, + PyObject *callback); + +static int +weakref_ref_init(PyObject *self, PyObject *args, PyObject *kwargs) +{ + int return_value = -1; + PyTypeObject *base_tp = &_PyWeakref_RefType; + PyObject *object; + PyObject *callback = Py_None; + + if ((Py_IS_TYPE(self, base_tp) || + Py_TYPE(self)->tp_new == base_tp->tp_new) && + !_PyArg_NoKeywords("ReferenceType", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("ReferenceType", PyTuple_GET_SIZE(args), 1, 2)) { + goto exit; + } + object = PyTuple_GET_ITEM(args, 0); + if (PyTuple_GET_SIZE(args) < 2) { + goto skip_optional; + } + callback = PyTuple_GET_ITEM(args, 1); +skip_optional: + return_value = weakref_ref_init_impl((PyWeakReference *)self, object, callback); + +exit: + return return_value; +} +/*[clinic end generated code: output=774282aa1017bab5 input=a9049054013a1b77]*/ diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 03036020b1cb1ae..2255220bec3d307 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -113,8 +113,8 @@ PyCode_ClearWatcher(int watcher_id) #define _PyCodeObject_CAST(op) (assert(PyCode_Check(op)), (PyCodeObject *)(op)) -static int -should_intern_string(PyObject *o) +int +_PyCode_ShouldInternString(PyObject *o) { #ifdef Py_GIL_DISABLED // The free-threaded build interns (and immortalizes) all string constants @@ -173,8 +173,16 @@ should_immortalize_constant(PyObject *v) _Py_IsImmortal(slice->stop) && _Py_IsImmortal(slice->step)); } - return (PyLong_CheckExact(v) || PyFloat_CheckExact(v) || - PyComplex_Check(v) || PyBytes_CheckExact(v)); + // The hash of a NaN depends on its address, so the table would keep every + // NaN object it gets (and merging them would shrink frozensets). + if (PyFloat_CheckExact(v)) { + return !isnan(PyFloat_AS_DOUBLE(v)); + } + if (PyComplex_CheckExact(v)) { + Py_complex c = ((PyComplexObject *)v)->cval; + return !isnan(c.real) && !isnan(c.imag); + } + return PyLong_CheckExact(v) || PyBytes_CheckExact(v); } #endif @@ -206,7 +214,7 @@ intern_constants(PyObject *tuple, int *modified) for (Py_ssize_t i = PyTuple_GET_SIZE(tuple); --i >= 0; ) { PyObject *v = PyTuple_GET_ITEM(tuple, i); if (PyUnicode_CheckExact(v)) { - if (should_intern_string(v)) { + if (_PyCode_ShouldInternString(v)) { PyObject *w = v; _PyUnicode_InternMortal(interp, &v); if (w != v) { @@ -647,19 +655,19 @@ remove_column_info(PyObject *locations) { Py_ssize_t offset = 0; const uint8_t *data = (const uint8_t *)PyBytes_AS_STRING(locations); - PyObject *res = PyBytes_FromStringAndSize(NULL, 32); + PyBytesWriter *res = PyBytesWriter_Create(32); if (res == NULL) { - PyErr_NoMemory(); return NULL; } - uint8_t *output = (uint8_t *)PyBytes_AS_STRING(res); + uint8_t *output = (uint8_t *)PyBytesWriter_GetData(res); while (offset < PyBytes_GET_SIZE(locations)) { - Py_ssize_t write_offset = output - (uint8_t *)PyBytes_AS_STRING(res); - if (write_offset + 16 >= PyBytes_GET_SIZE(res)) { - if (_PyBytes_Resize(&res, PyBytes_GET_SIZE(res) * 2) < 0) { + Py_ssize_t write_offset = output - (uint8_t *)PyBytesWriter_GetData(res); + if (write_offset + 16 >= PyBytesWriter_GetSize(res)) { + if (PyBytesWriter_Resize(res, PyBytesWriter_GetSize(res) * 2) < 0) { + PyBytesWriter_Discard(res); return NULL; } - output = (uint8_t *)PyBytes_AS_STRING(res) + write_offset; + output = (uint8_t *)PyBytesWriter_GetData(res) + write_offset; } int code = (data[offset] >> 3) & 15; if (code == PY_CODE_LOCATION_INFO_NONE) { @@ -678,11 +686,7 @@ remove_column_info(PyObject *locations) offset++; } } - Py_ssize_t write_offset = output - (uint8_t *)PyBytes_AS_STRING(res); - if (_PyBytes_Resize(&res, write_offset)) { - return NULL; - } - return res; + return PyBytesWriter_FinishWithPointer(res, output); } static int @@ -748,6 +752,7 @@ _PyCode_New(struct _PyCodeConstructor *con) #endif if (init_code(co, con) < 0) { + Py_XDECREF(replacement_locations); Py_DECREF(co); return NULL; } @@ -3313,14 +3318,20 @@ _Py_ReserveTLBCIndex(PyInterpreterState *interp) } void -_Py_ClearTLBCIndex(_PyThreadStateImpl *tstate) +_Py_UnreserveTLBCIndex(PyInterpreterState *interp, int32_t index) { - PyInterpreterState *interp = ((PyThreadState *)tstate)->interp; if (interp->config.tlbc_enabled) { - _PyIndexPool_FreeIndex(&interp->tlbc_indices, tstate->tlbc_index); + _PyIndexPool_FreeIndex(&interp->tlbc_indices, index); } } +void +_Py_ClearTLBCIndex(_PyThreadStateImpl *tstate) +{ + PyInterpreterState *interp = ((PyThreadState *)tstate)->interp; + _Py_UnreserveTLBCIndex(interp, tstate->tlbc_index); +} + static _PyCodeArray * _PyCodeArray_New(Py_ssize_t size) { diff --git a/Objects/complexobject.c b/Objects/complexobject.c index 3612c2699a557db..8a8fc240dd80baf 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -26,8 +26,6 @@ class complex "PyComplexObject *" "&PyComplex_Type" /* elementary operations on complex numbers */ -static Py_complex c_1 = {1., 0.}; - Py_complex _Py_c_sum(Py_complex a, Py_complex b) { @@ -333,23 +331,36 @@ _Py_c_pow(Py_complex a, Py_complex b) r.real = len*cos(phase); r.imag = len*sin(phase); - _Py_ADJUST_ERANGE2(r.real, r.imag); + /* Don't rely on errno set by the math functions above, for + example cos() and sin() set EDOM for an infinite phase. */ + errno = 0; + if (isfinite(a.real) && isfinite(a.imag) + && isfinite(b.real) && isfinite(b.imag)) + { + _Py_ADJUST_ERANGE2(r.real, r.imag); + } } return r; } +#define INT_EXP_CUTOFF 100 + static Py_complex c_powu(Py_complex x, long n) { - Py_complex r, p; - long mask = 1; - r = c_1; - p = x; - while (mask > 0 && n >= mask) { - if (n & mask) - r = _Py_c_prod(r,p); - mask <<= 1; - p = _Py_c_prod(p,p); + assert(0 < n && n <= INT_EXP_CUTOFF); + while ((n & 1) == 0) { + x = _Py_c_prod(x, x); + n >>= 1; + } + Py_complex r = x; + n >>= 1; + while (n) { + x = _Py_c_prod(x, x); + if (n & 1) { + r = _Py_c_prod(r, x); + } + n >>= 1; } return r; } @@ -358,17 +369,19 @@ static Py_complex c_powi(Py_complex x, long n) { if (n > 0) - return c_powu(x,n); + return c_powu(x, n); + else if (n < 0) + return _Py_rc_quot(1.0, c_powu(x, -n)); else - return _Py_c_quot(c_1, c_powu(x,-n)); - + return (Py_complex){1., 0.}; } double _Py_c_abs(Py_complex z) { - /* sets errno = ERANGE on overflow; otherwise errno = 0 */ + /* sets errno = ERANGE on overflow */ double result; + int saved_errno = errno; if (!isfinite(z.real) || !isfinite(z.imag)) { /* C99 rules: if either the real or the imaginary part is an @@ -376,23 +389,24 @@ _Py_c_abs(Py_complex z) NaN. */ if (isinf(z.real)) { result = fabs(z.real); - errno = 0; + errno = saved_errno; return result; } if (isinf(z.imag)) { result = fabs(z.imag); - errno = 0; + errno = saved_errno; return result; } /* either the real or imaginary part is a NaN, and neither is infinite. Result should be NaN. */ + errno = saved_errno; return Py_NAN; } result = hypot(z.real, z.imag); if (!isfinite(result)) errno = ERANGE; else - errno = 0; + errno = saved_errno; return result; } @@ -401,6 +415,9 @@ complex_subtype_from_c_complex(PyTypeObject *type, Py_complex cval) { PyObject *op; + if (type == &PyComplex_Type) { + return PyComplex_FromCComplex(cval); + } op = type->tp_alloc(type, 0); if (op != NULL) ((PyComplexObject *)op)->cval = cval; @@ -751,9 +768,13 @@ complex_pow(PyObject *v, PyObject *w, PyObject *z) errno = 0; // Check whether the exponent has a small integer value, and if so use // a faster and more accurate algorithm. - if (b.imag == 0.0 && b.real == floor(b.real) && fabs(b.real) <= 100.0) { + if (b.imag == 0.0 && b.real == floor(b.real) + && fabs(b.real) <= INT_EXP_CUTOFF) + { p = c_powi(a, (long)b.real); - _Py_ADJUST_ERANGE2(p.real, p.imag); + if (isfinite(a.real) && isfinite(a.imag)) { + _Py_ADJUST_ERANGE2(p.real, p.imag); + } } else { p = _Py_c_pow(a, b); @@ -796,7 +817,10 @@ static PyObject * complex_abs(PyObject *op) { PyComplexObject *v = _PyComplexObject_CAST(op); - double result = _Py_c_abs(v->cval); + double result; + + errno = 0; + result = _Py_c_abs(v->cval); if (errno == ERANGE) { PyErr_SetString(PyExc_OverflowError, "absolute value too large"); diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 568d978d27d12f9..6f3be87e0ca753b 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -4,7 +4,7 @@ #include "pycore_abstract.h" // _PyObject_RealIsSubclass() #include "pycore_call.h" // _PyStack_AsDict() #include "pycore_ceval.h" // _Py_EnterRecursiveCallTstate() -#include "pycore_emscripten_trampoline.h" // descr_set_trampoline_call(), descr_get_trampoline_call() +#include "pycore_wasm_trampoline.h" // descr_set_trampoline_call(), descr_get_trampoline_call() #include "pycore_descrobject.h" // _PyMethodWrapper_Type #include "pycore_modsupport.h" // _PyArg_UnpackStack() #include "pycore_object.h" // _PyObject_GC_UNTRACK() @@ -19,6 +19,8 @@ class property "propertyobject *" "&PyProperty_Type" [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=556352653fd4c02e]*/ +#include "clinic/descrobject.c.h" + static void descr_dealloc(PyObject *self) { @@ -621,9 +623,17 @@ static PyObject * descr_get_qualname(PyObject *self, void *Py_UNUSED(ignored)) { PyDescrObject *descr = (PyDescrObject *)self; - if (descr->d_qualname == NULL) - descr->d_qualname = calculate_qualname(descr); - return Py_XNewRef(descr->d_qualname); + PyObject *qualname; + Py_BEGIN_CRITICAL_SECTION(self); + if (descr->d_qualname == NULL) { + PyObject *new_qualname = calculate_qualname(descr); + if (new_qualname != NULL) { + Py_XSETREF(descr->d_qualname, new_qualname); + } + } + qualname = Py_XNewRef(descr->d_qualname); + Py_END_CRITICAL_SECTION(); + return qualname; } static PyObject * @@ -928,8 +938,7 @@ PyDescr_NewMethod(PyTypeObject *type, PyMethodDef *method) { /* Figure out correct vectorcall function to use */ vectorcallfunc vectorcall; - switch (method->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | - METH_O | METH_KEYWORDS | METH_METHOD)) + switch (method->ml_flags & _Py_METH_CALL_FLAGS) { case METH_VARARGS: vectorcall = method_vectorcall_VARARGS; @@ -1291,6 +1300,7 @@ PyDictProxy_New(PyObject *mapping) } /*[clinic input] +@vectorcall @classmethod mappingproxy.__new__ as mappingproxy_new @@ -1301,7 +1311,7 @@ Read-only proxy of a mapping. static PyObject * mappingproxy_new_impl(PyTypeObject *type, PyObject *mapping) -/*[clinic end generated code: output=65f27f02d5b68fa7 input=c156df096ef7590c]*/ +/*[clinic end generated code: output=65f27f02d5b68fa7 input=7388846480c052d2]*/ { return PyDictProxy_New(mapping); } @@ -1610,26 +1620,22 @@ property_deleter(PyObject *self, PyObject *deleter) } -PyDoc_STRVAR(set_name_doc, - "__set_name__($self, owner, name, /)\n" - "--\n" - "\n" - "Method to set name of a property."); +/*[clinic input] +property.__set_name__ -static PyObject * -property_set_name(PyObject *self, PyObject *args) { - if (PyTuple_GET_SIZE(args) != 2) { - PyErr_Format( - PyExc_TypeError, - "__set_name__() takes 2 positional arguments but %zd were given", - PyTuple_GET_SIZE(args)); - return NULL; - } + owner: object + name: object + / - propertyobject *prop = (propertyobject *)self; - PyObject *name = PyTuple_GET_ITEM(args, 1); +Method to set name of a property. +[clinic start generated code]*/ - Py_XSETREF(prop->prop_name, Py_XNewRef(name)); +static PyObject * +property___set_name___impl(propertyobject *self, PyObject *owner, + PyObject *name) +/*[clinic end generated code: output=959e301a91f7fb85 input=0211b5b7ace099c5]*/ +{ + Py_XSETREF(self->prop_name, Py_XNewRef(name)); Py_RETURN_NONE; } @@ -1638,7 +1644,7 @@ static PyMethodDef property_methods[] = { {"getter", property_getter, METH_O, getter_doc}, {"setter", property_setter, METH_O, setter_doc}, {"deleter", property_deleter, METH_O, deleter_doc}, - {"__set_name__", property_set_name, METH_VARARGS, set_name_doc}, + PROPERTY___SET_NAME___METHODDEF {0} }; @@ -2002,11 +2008,14 @@ static int property_clear(PyObject *self) { propertyobject *pp = (propertyobject *)self; + Py_CLEAR(pp->prop_get); + Py_CLEAR(pp->prop_set); + Py_CLEAR(pp->prop_del); Py_CLEAR(pp->prop_doc); + Py_CLEAR(pp->prop_name); return 0; } -#include "clinic/descrobject.c.h" PyTypeObject PyDictProxy_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) @@ -2049,6 +2058,7 @@ PyTypeObject PyDictProxy_Type = { 0, /* tp_init */ 0, /* tp_alloc */ mappingproxy_new, /* tp_new */ + .tp_vectorcall = mappingproxy_vectorcall, }; PyTypeObject PyProperty_Type = { diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 246ffe6c18e9b51..c9cc5d8c566fc6f 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -99,7 +99,7 @@ dk_nentries to achieve amortized O(1). Since there are DKIX_DUMMY remains in dk_indices, we can't increment dk_usable even though dk_nentries is decremented. -To preserve the order in a split table, a bit vector is used to record the +To preserve the order in a split table, a bit vector is used to record the insertion order. When a key is inserted the bit vector is shifted up by 4 bits and the index of the key is stored in the low 4 bits. As a consequence of this, split keys have a maximum size of 16. @@ -1041,6 +1041,10 @@ clone_combined_dict_keys(PyDictObject *orig) memcpy(keys, orig->ma_keys, keys_size); + /* The keys version must be unique per keys object: the specializer + and the JIT optimizer rely on it to identify a dict's keys. */ + keys->dk_version = 0; + /* After copying key/value pairs, we need to incref all keys and values and they are about to be co-owned by a new dict object. */ @@ -2009,6 +2013,35 @@ _PyDict_InsertSplitValue(PyDictObject *mp, PyObject *key, PyObject *value, Py_ss ASSERT_CONSISTENT(mp); } +// Replace a value at an existing entry. Steals the new value reference. +static void +replace_value(PyDictObject *mp, PyObject *key, Py_ssize_t ix, + PyObject *old_value, PyObject *value) +{ + assert(can_modify_dict(mp)); + assert(old_value != NULL); + + if (old_value != value) { + _PyDict_NotifyEvent(PyDict_EVENT_MODIFIED, mp, key, value); + if (DK_IS_UNICODE(mp->ma_keys)) { + if (_PyDict_HasSplitTable(mp)) { + STORE_SPLIT_VALUE(mp, ix, value); + } + else { + PyDictUnicodeEntry *ep = &DK_UNICODE_ENTRIES(mp->ma_keys)[ix]; + STORE_VALUE(ep, value); + } + } + else { + PyDictKeyEntry *ep = &DK_ENTRIES(mp->ma_keys)[ix]; + STORE_VALUE(ep, value); + } + } + Py_DECREF(old_value); /* which **CAN** re-enter (see gh-66843) */ + + ASSERT_CONSISTENT(mp); +} + /* Internal routine to insert a new item into the table. Used both by the internal resize routine and by the public insert routine. @@ -2056,25 +2089,7 @@ insertdict(PyDictObject *mp, return 0; } - if (old_value != value) { - _PyDict_NotifyEvent(PyDict_EVENT_MODIFIED, mp, key, value); - assert(old_value != NULL); - if (DK_IS_UNICODE(mp->ma_keys)) { - if (_PyDict_HasSplitTable(mp)) { - STORE_SPLIT_VALUE(mp, ix, value); - } - else { - PyDictUnicodeEntry *ep = &DK_UNICODE_ENTRIES(mp->ma_keys)[ix]; - STORE_VALUE(ep, value); - } - } - else { - PyDictKeyEntry *ep = &DK_ENTRIES(mp->ma_keys)[ix]; - STORE_VALUE(ep, value); - } - } - Py_XDECREF(old_value); /* which **CAN** re-enter (see issue #22653) */ - ASSERT_CONSISTENT(mp); + replace_value(mp, key, ix, old_value, value); Py_DECREF(key); return 0; @@ -2261,7 +2276,6 @@ dictresize(PyDictObject *mp, UNLOCK_KEYS(oldkeys); set_keys(mp, newkeys); dictkeys_decref(oldkeys, IS_DICT_SHARED(mp)); - set_values(mp, NULL); if (oldvalues->embedded) { assert(oldvalues->embedded == 1); assert(oldvalues->valid == 1); @@ -2270,6 +2284,7 @@ dictresize(PyDictObject *mp, else { free_values(oldvalues, IS_DICT_SHARED(mp)); } + set_values(mp, NULL); } else { // oldkeys is combined. if (oldkeys->dk_kind == DICT_KEYS_GENERAL) { @@ -2616,6 +2631,81 @@ PyDict_GetItemRef(PyObject *op, PyObject *key, PyObject **result) return _PyDict_GetItemRef_KnownHash((PyDictObject *)op, key, hash, result); } +static inline int +compare_generic_exact_unicode(PyDictObject *mp, PyDictKeysObject *dk, + void *ep0, Py_ssize_t ix, PyObject *key, + Py_hash_t hash) +{ + PyDictKeyEntry *ep = &((PyDictKeyEntry *)ep0)[ix]; + assert(ep->me_key != NULL); + if (ep->me_key == key) { + return 1; + } + return (ep->me_hash == hash && PyUnicode_CheckExact(ep->me_key) && + unicode_eq(ep->me_key, key)); +} + +// Look up an exact str key, without comparing it to keys that are not exact +// str: those are skipped, so no user code can run. Returns a borrowed +// reference, or NULL (without an exception) if the key is not found. The +// caller must hold the dict lock or have the world stopped. +PyObject * +_PyDict_GetItem_ExactUnicode(PyDictObject *mp, PyObject *key) +{ + assert(PyUnicode_CheckExact(key)); + Py_hash_t hash = hash_unicode_key(key); + PyDictKeysObject *dk = mp->ma_keys; + Py_ssize_t ix; + if (dk->dk_kind == DICT_KEYS_GENERAL) { + ix = do_lookup(mp, dk, key, hash, compare_generic_exact_unicode); + } + else { + ix = unicodekeys_lookup_unicode(dk, key, hash); + } + if (ix < 0) { + return NULL; + } + if (dk->dk_kind == DICT_KEYS_SPLIT) { + return mp->ma_values->values[ix]; + } + if (dk->dk_kind == DICT_KEYS_GENERAL) { + return DK_ENTRIES(dk)[ix].me_value; + } + return DK_UNICODE_ENTRIES(dk)[ix].me_value; +} + +// Like _PyDict_GetItem_ExactUnicode() but safe to call without holding the +// dict lock. Stores a new reference (or NULL) in *value_addr. Returns 1 if +// the key was found and 0 if not. +int +_PyDict_GetItemStackRef_ExactUnicode(PyDictObject *mp, PyObject *key, + _PyStackRef *value_addr) +{ + assert(PyUnicode_CheckExact(key)); + PyObject *value; +#ifdef Py_GIL_DISABLED + ensure_shared_on_read(mp); + PyDictKeysObject *dk = _Py_atomic_load_ptr_acquire(&mp->ma_keys); + if (dk->dk_kind == DICT_KEYS_UNICODE) { + // All keys are exact str, so the lock-free lookup cannot run user + // code. + Py_hash_t hash = hash_unicode_key(key); + Py_ssize_t ix = lookup_threadsafe_unicode(dk, key, hash, value_addr); + if (ix != DKIX_KEY_CHANGED) { + return !PyStackRef_IsNull(*value_addr); + } + } + Py_BEGIN_CRITICAL_SECTION(mp); + value = _PyDict_GetItem_ExactUnicode(mp, key); + *value_addr = value ? PyStackRef_FromPyObjectNew(value) : PyStackRef_NULL; + Py_END_CRITICAL_SECTION(); +#else + value = _PyDict_GetItem_ExactUnicode(mp, key); + *value_addr = value ? PyStackRef_FromPyObjectNew(value) : PyStackRef_NULL; +#endif + return value != NULL; +} + int _PyDict_GetItemRef_Unicode_LockHeld(PyDictObject *op, PyObject *key, PyObject **result) { @@ -2700,44 +2790,7 @@ _PyDict_GetItemStringWithError(PyObject *v, const char *key) return rv; } -/* Fast version of global value lookup (LOAD_GLOBAL). - * Lookup in globals, then builtins. - * - * - * - * - * Raise an exception and return NULL if an error occurred (ex: computing the - * key hash failed, key comparison failed, ...). Return NULL if the key doesn't - * exist. Return the value if the key exists. - * - * Returns a new reference. - */ PyObject * -_PyDict_LoadGlobal(PyDictObject *globals, PyDictObject *builtins, PyObject *key) -{ - Py_ssize_t ix; - Py_hash_t hash; - PyObject *value; - - hash = _PyObject_HashDictKey(key); - if (hash == -1) { - return NULL; - } - - /* namespace 1: globals */ - ix = _Py_dict_lookup_threadsafe(globals, key, hash, &value); - if (ix == DKIX_ERROR) - return NULL; - if (ix != DKIX_EMPTY && value != NULL) - return value; - - /* namespace 2: builtins */ - ix = _Py_dict_lookup_threadsafe(builtins, key, hash, &value); - assert(ix >= 0 || value == NULL); - return value; -} - -void _PyDict_LoadGlobalStackRef(PyDictObject *globals, PyDictObject *builtins, PyObject *key, _PyStackRef *res) { Py_ssize_t ix; @@ -2746,21 +2799,22 @@ _PyDict_LoadGlobalStackRef(PyDictObject *globals, PyDictObject *builtins, PyObje hash = _PyObject_HashDictKey(key); if (hash == -1) { *res = PyStackRef_NULL; - return; + return NULL; } /* namespace 1: globals */ ix = _Py_dict_lookup_threadsafe_stackref(globals, key, hash, res); if (ix == DKIX_ERROR) { - return; + return NULL; } if (ix != DKIX_EMPTY && !PyStackRef_IsNull(*res)) { - return; + return (PyObject *)globals; } /* namespace 2: builtins */ ix = _Py_dict_lookup_threadsafe_stackref(builtins, key, hash, res); assert(ix >= 0 || PyStackRef_IsNull(*res)); + return PyStackRef_IsNull(*res) ? NULL : (PyObject *)builtins; } PyObject * @@ -2946,9 +3000,9 @@ delete_index_from_values(PyDictValues *values, Py_ssize_t ix) assert(i < size); size--; for (; i < size; i++) { - array[i] = array[i+1]; + FT_ATOMIC_STORE_UINT8_RELAXED(array[i], array[i+1]); } - values->size = size; + FT_ATOMIC_STORE_UINT8_RELEASE(values->size, size); } static void @@ -2959,9 +3013,6 @@ delitem_common(PyDictObject *mp, Py_hash_t hash, Py_ssize_t ix, PyObject *old_key; - Py_ssize_t hashpos = lookdict_index(mp->ma_keys, hash, ix); - assert(hashpos >= 0); - STORE_USED(mp, mp->ma_used - 1); if (_PyDict_HasSplitTable(mp)) { assert(old_value == mp->ma_values->values[ix]); @@ -2972,6 +3023,9 @@ delitem_common(PyDictObject *mp, Py_hash_t hash, Py_ssize_t ix, ASSERT_CONSISTENT(mp); } else { + Py_ssize_t hashpos = lookdict_index(mp->ma_keys, hash, ix); + assert(hashpos >= 0); + FT_ATOMIC_STORE_UINT32_RELAXED(mp->ma_keys->dk_version, 0); dictkeys_set_index(mp->ma_keys, hashpos, DKIX_DUMMY); if (DK_IS_UNICODE(mp->ma_keys)) { @@ -3105,6 +3159,35 @@ _PyDict_DelItemIf(PyObject *op, PyObject *key, return res; } +int +_PyDict_ReplaceItemIf(PyObject *op, PyObject *key, + PyObject *expected, PyObject *replacement) +{ + assert(PyDict_Check(op)); + assert(expected != NULL); + assert(replacement != NULL); + + Py_hash_t hash = PyObject_Hash(key); + if (hash == -1) { + return -1; + } + int result = 0; + Py_BEGIN_CRITICAL_SECTION(op); + PyDictObject *mp = (PyDictObject *)op; + PyObject *current; + Py_ssize_t ix = _Py_dict_lookup(mp, key, hash, ¤t); + if (ix == DKIX_ERROR) { + result = -1; + } + else if (current == expected) { + // Do not look up the key again: equality can execute Python code. + replace_value(mp, key, ix, current, Py_NewRef(replacement)); + result = 1; + } + Py_END_CRITICAL_SECTION(); + return result; +} + static void clear_embedded_values(PyDictValues *values, Py_ssize_t nentries) { @@ -3114,12 +3197,23 @@ clear_embedded_values(PyDictValues *values, Py_ssize_t nentries) refs[i] = values->values[i]; FT_ATOMIC_STORE_PTR_RELEASE(values->values[i], NULL); } - values->size = 0; + FT_ATOMIC_STORE_UINT8_RELEASE(values->size, 0); for (Py_ssize_t i = 0; i < nentries; i++) { Py_XDECREF(refs[i]); } } +// This function is used in both `PyDict_Clear` +// and `PyDict_AsFrozenDictAndClear`, place all the common parts here. +static void +clear_common(PyDictObject *mp) +{ + _PyDict_NotifyEvent(PyDict_EVENT_CLEARED, mp, NULL, NULL); + // We don't inc ref empty keys because they're immortal + ensure_shared_on_resize(mp); + STORE_USED(mp, 0); +} + static void clear_lock_held(PyObject *op) { @@ -3139,10 +3233,7 @@ clear_lock_held(PyObject *op) return; } /* Empty the dict... */ - _PyDict_NotifyEvent(PyDict_EVENT_CLEARED, mp, NULL, NULL); - // We don't inc ref empty keys because they're immortal - ensure_shared_on_resize(mp); - STORE_USED(mp, 0); + clear_common(mp); if (oldvalues == NULL) { set_keys(mp, Py_EMPTY_KEYS); assert(oldkeys->dk_refcnt == 1); @@ -3412,9 +3503,8 @@ dict_dict_fromkeys(PyDictObject *mp, PyObject *iterable, PyObject *value) PyObject *key; Py_hash_t hash; int unicode = DK_IS_UNICODE(((PyDictObject*)iterable)->ma_keys); - uint8_t new_size = Py_MAX( - estimate_log2_keysize(PyDict_GET_SIZE(iterable)), - DK_LOG_SIZE(mp->ma_keys)); + uint8_t log2_keysize = estimate_log2_keysize(PyDict_GET_SIZE(iterable)); + uint8_t new_size = Py_MAX(log2_keysize, DK_LOG_SIZE(mp->ma_keys)); if (dictresize(mp, new_size, unicode)) { Py_DECREF(mp); return NULL; @@ -3437,9 +3527,8 @@ dict_set_fromkeys(PyDictObject *mp, PyObject *iterable, PyObject *value) Py_ssize_t pos = 0; PyObject *key; Py_hash_t hash; - uint8_t new_size = Py_MAX( - estimate_log2_keysize(PySet_GET_SIZE(iterable)), - DK_LOG_SIZE(mp->ma_keys)); + uint8_t log2_keysize = estimate_log2_keysize(PySet_GET_SIZE(iterable)); + uint8_t new_size = Py_MAX(log2_keysize, DK_LOG_SIZE(mp->ma_keys)); if (dictresize(mp, new_size, 0)) { Py_DECREF(mp); return NULL; @@ -3766,23 +3855,21 @@ anydict_repr_impl(PyObject *self) return NULL; } +/*[clinic input] +@critical_section +dict.__repr__ + + self: self(type="PyObject *") +[clinic start generated code]*/ + static PyObject * -dict_repr_lock_held(PyObject *self) +dict_repr_impl(PyObject *self) +/*[clinic end generated code: output=059263af818a321d input=f9c423cbdf534674]*/ { ASSERT_DICT_LOCKED((PyDictObject *)self); return anydict_repr_impl(self); } -static PyObject * -dict_repr(PyObject *self) -{ - PyObject *res; - Py_BEGIN_CRITICAL_SECTION(self); - res = dict_repr_lock_held(self); - Py_END_CRITICAL_SECTION(); - return res; -} - static Py_ssize_t dict_length(PyObject *self) { @@ -4109,7 +4196,7 @@ merge_from_seq2_lock_held(PyObject *d, PyObject *seq2, int override) return -1; for (i = 0; ; ++i) { - PyObject *key, *value; + PyObject *key = NULL, *value = NULL; Py_ssize_t n; fast = NULL; @@ -4131,7 +4218,13 @@ merge_from_seq2_lock_held(PyObject *d, PyObject *seq2, int override) } goto Fail; } + Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST(item); n = PySequence_Fast_GET_SIZE(fast); + if (n == 2) { + key = Py_NewRef(PySequence_Fast_GET_ITEM(fast, 0)); + value = Py_NewRef(PySequence_Fast_GET_ITEM(fast, 1)); + } + Py_END_CRITICAL_SECTION_SEQUENCE_FAST(); if (n != 2) { PyErr_Format(PyExc_ValueError, "dictionary update sequence element #%zd " @@ -4141,10 +4234,6 @@ merge_from_seq2_lock_held(PyObject *d, PyObject *seq2, int override) } /* Update/merge with this (key, value) pair. */ - key = PySequence_Fast_GET_ITEM(fast, 0); - value = PySequence_Fast_GET_ITEM(fast, 1); - Py_INCREF(key); - Py_INCREF(value); if (override) { if (setitem_lock_held((PyDictObject *)d, key, value) < 0) { Py_DECREF(key); @@ -4211,7 +4300,9 @@ static int dict_dict_merge(PyDictObject *mp, PyDictObject *other, int override, PyObject **dupkey) { assert(can_modify_dict(mp)); - ASSERT_DICT_LOCKED(other); + if (!PyFrozenDict_Check(other)) { + ASSERT_DICT_LOCKED(other); + } if (other == mp || other->ma_used == 0) /* a.update(a) or a.update({}); nothing to do */ @@ -4263,12 +4354,12 @@ dict_dict_merge(PyDictObject *mp, PyDictObject *other, int override, PyObject ** while (_PyDict_Next((PyObject*)other, &pos, &key, &value, &hash)) { int err = 0; - Py_INCREF(key); - Py_INCREF(value); if (override == 1) { err = insertdict(mp, Py_NewRef(key), hash, Py_NewRef(value)); } else { + Py_INCREF(key); + Py_INCREF(value); err = _PyDict_Contains_KnownHash((PyObject *)mp, key, hash); if (err == 0) { err = insertdict(mp, Py_NewRef(key), hash, Py_NewRef(value)); @@ -4281,9 +4372,9 @@ dict_dict_merge(PyDictObject *mp, PyDictObject *other, int override, PyObject ** } err = 0; } + Py_DECREF(value); + Py_DECREF(key); } - Py_DECREF(value); - Py_DECREF(key); if (err != 0) return -1; @@ -4491,7 +4582,7 @@ copy_lock_held_untracked(PyObject *o, int as_frozendict) else { d = dict_new_untracked(&PyDict_Type); } - assert(!_PyObject_GC_IS_TRACKED(d)); + assert(d == NULL || !_PyObject_GC_IS_TRACKED(d)); return d; } @@ -4577,7 +4668,14 @@ copy_lock_held_untracked(PyObject *o, int as_frozendict) } if (copy == NULL) return NULL; - if (dict_merge(copy, o, 1, NULL) < 0) { + int res; + if (Py_TYPE(mp)->tp_iter == dict_iter) { + res = dict_dict_merge((PyDictObject *)copy, mp, 1, NULL); + } + else { + res = dict_merge(copy, o, 1, NULL); + } + if (res < 0) { Py_DECREF(copy); return NULL; } @@ -4881,7 +4979,7 @@ dict_setdefault_ref_lock_held(PyObject *d, PyObject *key, PyObject *default_valu } } - if (ix == DKIX_EMPTY) { + if (ix == DKIX_EMPTY || value == NULL) { value = default_value; // See comment to this function in insertdict. @@ -5409,7 +5507,8 @@ dict_vectorcall(PyObject *type, PyObject * const*args, return NULL; } - PyObject *self = dict_new(_PyType_CAST(type), NULL, NULL); + assert(type == (PyObject *)&PyDict_Type); + PyObject *self = PyDict_New(); if (self == NULL) { return NULL; } @@ -5606,7 +5705,10 @@ PyDict_DelItemString(PyObject *v, const char *key) typedef struct { PyObject_HEAD - PyDictObject *di_dict; /* Set to NULL when iterator is exhausted */ + /* Set to NULL when the iterator is exhausted, except in the free-threaded + build, where the reference is kept until the iterator is deallocated + (see dictiter_set_exhausted()). */ + PyDictObject *di_dict; Py_ssize_t di_used; Py_ssize_t di_pos; PyObject* di_result; /* reusable result tuple for iteritems */ @@ -5626,6 +5728,7 @@ dictiter_new(PyDictObject *dict, PyTypeObject *itertype) used = GET_USED(dict); di->di_used = used; di->len = used; + di->di_result = NULL; if (itertype == &PyDictRevIterKey_Type || itertype == &PyDictRevIterItem_Type || itertype == &PyDictRevIterValue_Type) { @@ -5639,6 +5742,10 @@ dictiter_new(PyDictObject *dict, PyTypeObject *itertype) else { di->di_pos = 0; } + /* gh-152107: track before allocating di_result. A dictiter with a NULL + di_result is a valid state for dictiter_traverse()/dictiter_dealloc(), + so a failure of the allocation below can safely DECREF a tracked di. */ + _PyObject_GC_TRACK(di); if (itertype == &PyDictIterItem_Type || itertype == &PyDictRevIterItem_Type) { di->di_result = _PyTuple_FromPairSteal(Py_None, Py_None); @@ -5647,10 +5754,6 @@ dictiter_new(PyDictObject *dict, PyTypeObject *itertype) return NULL; } } - else { - di->di_result = NULL; - } - _PyObject_GC_TRACK(di); return (PyObject *)di; } @@ -5700,6 +5803,28 @@ static PyMethodDef dictiter_methods[] = { {NULL, NULL} /* sentinel */ }; +/* Mark the iterator as exhausted. In the free-threaded build an iterator + may be advanced by several threads at once, each holding a borrowed + pointer to di_dict, so the iterator keeps its reference to the dict until + it is deallocated (as list and tuple iterators do) and records exhaustion + by setting di_pos to DICTITER_EXHAUSTED. This is distinct from -1, the + starting position of a reverse iterator over an empty dict. */ +#ifdef Py_GIL_DISABLED +#define DICTITER_EXHAUSTED PY_SSIZE_T_MIN +#endif + +static void +dictiter_set_exhausted(dictiterobject *di, PyDictObject *d) +{ +#ifdef Py_GIL_DISABLED + _Py_atomic_store_ssize_relaxed(&di->di_pos, DICTITER_EXHAUSTED); + _Py_atomic_store_ssize_relaxed(&di->len, 0); +#else + di->di_dict = NULL; + Py_DECREF(d); +#endif +} + #ifdef Py_GIL_DISABLED static int @@ -5965,6 +6090,11 @@ dictiter_iternextitem_lock_held(PyDictObject *d, PyObject *self, assert (PyAnyDict_Check(d)); ASSERT_DICT_LOCKED(d); + i = FT_ATOMIC_LOAD_SSIZE_RELAXED(di->di_pos); + if (i < 0) { + return -1; /* exhausted */ + } + if (di->di_used != d->ma_used) { PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration"); @@ -5972,9 +6102,6 @@ dictiter_iternextitem_lock_held(PyDictObject *d, PyObject *self, return -1; } - i = FT_ATOMIC_LOAD_SSIZE_RELAXED(di->di_pos); - - assert(i >= 0); if (_PyDict_HasSplitTable(d)) { if (i >= d->ma_used) goto fail; @@ -6025,8 +6152,7 @@ dictiter_iternextitem_lock_held(PyDictObject *d, PyObject *self, return 0; fail: - di->di_dict = NULL; - Py_DECREF(d); + dictiter_set_exhausted(di, d); return -1; } @@ -6070,6 +6196,11 @@ dictiter_iternext_threadsafe(PyDictObject *d, PyObject *self, assert (PyAnyDict_Check(d)); + i = _Py_atomic_load_ssize_relaxed(&di->di_pos); + if (i == DICTITER_EXHAUSTED) { + return -1; + } + if (di->di_used != _Py_atomic_load_ssize_relaxed(&d->ma_used)) { PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration"); @@ -6079,9 +6210,7 @@ dictiter_iternext_threadsafe(PyDictObject *d, PyObject *self, ensure_shared_on_read(d); - i = _Py_atomic_load_ssize_relaxed(&di->di_pos); k = _Py_atomic_load_ptr_acquire(&d->ma_keys); - assert(i >= 0); if (_PyDict_HasSplitTable(d)) { PyDictValues *values = _Py_atomic_load_ptr_consume(&d->ma_values); if (values == NULL) { @@ -6096,9 +6225,14 @@ dictiter_iternext_threadsafe(PyDictObject *d, PyObject *self, // We're racing against writes to the order from delete_index_from_values, but // single threaded can suffer from concurrent modification to those as well and // can have either duplicated or skipped attributes, so we strive to do no better - // here. - int index = get_index_from_order(d, i); + // here. Use the same values snapshot as the size load above. + uint8_t *order = get_insertion_order_array(values); + int index = _Py_atomic_load_uint8_relaxed(&order[i]); PyObject *value = _Py_atomic_load_ptr(&values->values[index]); + if (value == NULL) { + // Deletion clears the slot before decrementing values->size. + goto try_locked; + } if (acquire_key_value(&DK_UNICODE_ENTRIES(k)[index].me_key, value, &values->values[index], out_key, out_value) < 0) { goto try_locked; @@ -6155,8 +6289,7 @@ dictiter_iternext_threadsafe(PyDictObject *d, PyObject *self, "dictionary keys changed during iteration"); fail: - di->di_dict = NULL; - Py_DECREF(d); + dictiter_set_exhausted(di, d); return -1; try_locked: @@ -6258,6 +6391,12 @@ dictreviter_iter_lock_held(PyDictObject *d, PyObject *self) assert (PyAnyDict_Check(d)); ASSERT_DICT_LOCKED(d); +#ifdef Py_GIL_DISABLED + if (di->di_pos == DICTITER_EXHAUSTED) { + return NULL; + } +#endif + if (di->di_used != d->ma_used) { PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration"); @@ -6276,9 +6415,12 @@ dictreviter_iter_lock_held(PyDictObject *d, PyObject *self) int index = get_index_from_order(d, i); key = LOAD_SHARED_KEY(DK_UNICODE_ENTRIES(k)[index].me_key); value = d->ma_values->values[index]; - assert (value != NULL); + assert(value != NULL); } else { + if (i >= k->dk_nentries) { + goto fail; + } if (DK_IS_UNICODE(k)) { PyDictUnicodeEntry *entry_ptr = &DK_UNICODE_ENTRIES(k)[i]; while (entry_ptr->me_value == NULL) { @@ -6302,6 +6444,12 @@ dictreviter_iter_lock_held(PyDictObject *d, PyObject *self) value = entry_ptr->me_value; } } + // We found an element, but did not expect it + if (di->len == 0) { + PyErr_SetString(PyExc_RuntimeError, + "dictionary keys changed during iteration"); + goto fail; + } di->di_pos = i-1; di->len--; @@ -6335,8 +6483,7 @@ dictreviter_iter_lock_held(PyDictObject *d, PyObject *self) } fail: - di->di_dict = NULL; - Py_DECREF(d); + dictiter_set_exhausted(di, d); return NULL; } @@ -7283,6 +7430,11 @@ _PyDict_NewKeysForClass(PyHeapTypeObject *cls) PyObject *key = PyTuple_GET_ITEM(attrs, i); Py_hash_t hash; if (PyUnicode_CheckExact(key) && (hash = unicode_get_hash(key)) != -1) { + /* An attribute stored in a slot never uses the dict. */ + PyObject *descr = _PyType_Lookup((PyTypeObject *)cls, key); + if (descr != NULL && Py_IS_TYPE(descr, &PyMemberDescr_Type)) { + continue; + } if (insert_split_key(keys, key, hash) == DKIX_EMPTY) { break; } @@ -7553,17 +7705,25 @@ _PyObject_StoreInstanceAttribute(PyObject *obj, PyObject *name, PyObject *value) { PyDictValues *values = _PyObject_InlineValues(obj); if (!FT_ATOMIC_LOAD_UINT8(values->valid)) { - PyDictObject *dict = _PyObject_GetManagedDict(obj); + PyDictObject *dict; + int res; +#ifdef Py_GIL_DISABLED + Py_BEGIN_CRITICAL_SECTION(obj); +#endif + dict = _PyObject_GetManagedDict(obj); + Py_XINCREF(dict); +#ifdef Py_GIL_DISABLED + Py_END_CRITICAL_SECTION(); +#endif if (dict == NULL) { dict = (PyDictObject *)PyObject_GenericGetDict(obj, NULL); if (dict == NULL) { return -1; } - int res = store_instance_attr_dict(obj, dict, name, value); - Py_DECREF(dict); - return res; } - return store_instance_attr_dict(obj, dict, name, value); + res = store_instance_attr_dict(obj, dict, name, value); + Py_DECREF(dict); + return res; } #ifdef Py_GIL_DISABLED @@ -7722,7 +7882,7 @@ _PyObject_IsInstanceDictEmpty(PyObject *obj) PyDictValues *values = _PyObject_InlineValues(obj); if (FT_ATOMIC_LOAD_UINT8(values->valid)) { PyDictKeysObject *keys = CACHED_KEYS(tp); - for (Py_ssize_t i = 0; i < keys->dk_nentries; i++) { + for (Py_ssize_t i = 0; i < LOAD_KEYS_NENTRIES(keys); i++) { if (FT_ATOMIC_LOAD_PTR_RELAXED(values->values[i]) != NULL) { return 0; } @@ -7775,7 +7935,11 @@ clear_inline_values(PyDictValues *values) if (values->valid) { FT_ATOMIC_STORE_UINT8(values->valid, 0); for (Py_ssize_t i = 0; i < values->capacity; i++) { - Py_CLEAR(values->values[i]); + PyObject *value = values->values[i]; + // The attribute read fast-path may read these without holding the + // per-object lock. + FT_ATOMIC_STORE_PTR_RELEASE(values->values[i], NULL); + Py_XDECREF(value); } } } @@ -7997,7 +8161,7 @@ PyObject_ClearManagedDict(PyObject *obj) clear_inline_values(_PyObject_InlineValues(obj)); return; } - else if (FT_ATOMIC_LOAD_PTR_RELAXED(dict->ma_values) == + if (FT_ATOMIC_LOAD_PTR_ACQUIRE(dict->ma_values) == _PyObject_InlineValues(obj)) { // We have a materialized object which points at the inline // values. We need to materialize the keys. Nothing can modify @@ -8015,6 +8179,7 @@ PyObject_ClearManagedDict(PyObject *obj) /* Clear the dict */ Py_BEGIN_CRITICAL_SECTION(dict); PyDictKeysObject *oldkeys = dict->ma_keys; + ensure_shared_on_resize(dict); set_keys(dict, Py_EMPTY_KEYS); dict->ma_values = NULL; dictkeys_decref(oldkeys, IS_DICT_SHARED(dict)); @@ -8455,16 +8620,26 @@ frozendict_hash(PyObject *op) PyDictObject *mp = _PyAnyDict_CAST(op); Py_uhash_t hash = 0; + /* Hashing a value recurses back into frozendict_hash() when that value + is itself a frozendict, so guard the descent to raise RecursionError + rather than overflow the C stack on a deeply nested frozendict. Keys + are safe: their hashes are already computed at construction time. */ + if (_Py_EnterRecursiveCall(" while hashing a frozendict")) { + return -1; + } + PyObject *value; // borrowed ref Py_ssize_t pos = 0; Py_hash_t key_hash; while (_PyDict_Next(op, &pos, NULL, &value, &key_hash)) { Py_hash_t pair_hash = frozendict_pair_hash(key_hash, value); if (pair_hash == -1) { + _Py_LeaveRecursiveCall(); return -1; } hash ^= _shuffle_bits(pair_hash); } + _Py_LeaveRecursiveCall(); /* Factor in the number of active entries */ hash ^= ((Py_uhash_t)mp->ma_used + 1) * 1927868237UL; @@ -8521,6 +8696,69 @@ frozendict_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return d; } +static int +transfer_keys_and_values_lock_held(PyObject *res, PyObject *dict) +{ + PyDictObject *new = (PyDictObject *)res; + PyDictObject *old = (PyDictObject *)dict; + assert(can_modify_dict(old)); + + if (old->ma_values && old->ma_values->embedded) { + PyErr_SetString(PyExc_ValueError, + "can't convert dict with embedded values"); + return -1; + } + + // Fast path: do nothing on an empty dict: + if (old->ma_keys == Py_EMPTY_KEYS) { + return 0; + } + + Py_ssize_t used = old->ma_used; + PyDictKeysObject *keys = old->ma_keys; + PyDictValues *values = old->ma_values; + + // Clear the old dict keys and values, but do not decref them: + clear_common(old); + set_keys(old, Py_EMPTY_KEYS); + set_values(old, NULL); + ASSERT_CONSISTENT(old); + + // Transfer keys and values from dict to frozendict: + new->ma_used = used; + new->ma_keys = keys; + new->ma_values = values; + ASSERT_CONSISTENT(new); + return 0; +} + +PyObject * +PyDict_AsFrozenDictAndClear(PyObject *dict) +{ + if (dict == NULL || !PyDict_Check(dict)) { + PyErr_BadInternalCall(); + return NULL; + } + + PyObject *res = frozendict_new_untracked(&PyFrozenDict_Type); + if (res == NULL) { + return NULL; + } + + int transfer; + Py_BEGIN_CRITICAL_SECTION(dict); + transfer = transfer_keys_and_values_lock_held(res, dict); + Py_END_CRITICAL_SECTION(); + if (transfer < 0) { + Py_DECREF(res); + return NULL; + } + + _PyObject_GC_TRACK(res); + assert(_PyFrozenDictObject_CAST(res)->ma_hash == -1); + return res; +} + PyObject* PyFrozenDict_New(PyObject *iterable) @@ -8568,6 +8806,17 @@ frozendict_copy_impl(PyFrozenDictObject *self) return copy; } +PyDoc_STRVAR(frozendict_doc, +"frozendict() -> new empty immutable dictionary\n" +"frozendict(mapping) -> new immutable dictionary initialized from a mapping\n" +" object's (key, value) pairs\n" +"frozendict(iterable) -> new immutable dictionary initialized as if via:\n" +" d = {}\n" +" for k, v in iterable:\n" +" d[k] = v\n" +" d = frozendict(d)\n" +"frozendict(**kwargs) -> new immutable dictionary initialized with the name=value\n" +" pairs in the keyword argument list. For example: frozendict(one=1, two=2)"); PyTypeObject PyFrozenDict_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) @@ -8583,7 +8832,7 @@ PyTypeObject PyFrozenDict_Type = { .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE | _Py_TPFLAGS_MATCH_SELF | Py_TPFLAGS_MAPPING, - .tp_doc = dictionary_doc, + .tp_doc = frozendict_doc, .tp_traverse = dict_traverse, .tp_clear = dict_tp_clear, .tp_richcompare = dict_richcompare, diff --git a/Objects/enumobject.c b/Objects/enumobject.c index fc53f1bfee8dde4..4353d7196f005b3 100644 --- a/Objects/enumobject.c +++ b/Objects/enumobject.c @@ -28,6 +28,7 @@ typedef struct { #define _enumobject_CAST(op) ((enumobject *)(op)) /*[clinic input] +@vectorcall @classmethod enumerate.__new__ as enum_new @@ -46,7 +47,7 @@ enumerate is useful for obtaining an indexed list: static PyObject * enum_new_impl(PyTypeObject *type, PyObject *iterable, PyObject *start) -/*[clinic end generated code: output=e95e6e439f812c10 input=782e4911efcb8acf]*/ +/*[clinic end generated code: output=e95e6e439f812c10 input=a139e88889360e8f]*/ { enumobject *en; @@ -87,71 +88,6 @@ enum_new_impl(PyTypeObject *type, PyObject *iterable, PyObject *start) return (PyObject *)en; } -static int check_keyword(PyObject *kwnames, int index, - const char *name) -{ - PyObject *kw = PyTuple_GET_ITEM(kwnames, index); - if (!_PyUnicode_EqualToASCIIString(kw, name)) { - PyErr_Format(PyExc_TypeError, - "'%S' is an invalid keyword argument for enumerate()", kw); - return 0; - } - return 1; -} - -// TODO: Use AC when bpo-43447 is supported -static PyObject * -enumerate_vectorcall(PyObject *type, PyObject *const *args, - size_t nargsf, PyObject *kwnames) -{ - PyTypeObject *tp = _PyType_CAST(type); - Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); - Py_ssize_t nkwargs = 0; - if (kwnames != NULL) { - nkwargs = PyTuple_GET_SIZE(kwnames); - } - - // Manually implement enumerate(iterable, start=...) - if (nargs + nkwargs == 2) { - if (nkwargs == 1) { - if (!check_keyword(kwnames, 0, "start")) { - return NULL; - } - } else if (nkwargs == 2) { - PyObject *kw0 = PyTuple_GET_ITEM(kwnames, 0); - if (_PyUnicode_EqualToASCIIString(kw0, "start")) { - if (!check_keyword(kwnames, 1, "iterable")) { - return NULL; - } - return enum_new_impl(tp, args[1], args[0]); - } - if (!check_keyword(kwnames, 0, "iterable") || - !check_keyword(kwnames, 1, "start")) { - return NULL; - } - - } - return enum_new_impl(tp, args[0], args[1]); - } - - if (nargs + nkwargs == 1) { - if (nkwargs == 1 && !check_keyword(kwnames, 0, "iterable")) { - return NULL; - } - return enum_new_impl(tp, args[0], NULL); - } - - if (nargs == 0) { - PyErr_SetString(PyExc_TypeError, - "enumerate() missing required argument 'iterable'"); - return NULL; - } - - PyErr_Format(PyExc_TypeError, - "enumerate() takes at most 2 arguments (%zd given)", nargs + nkwargs); - return NULL; -} - static void enum_dealloc(PyObject *op) { @@ -277,10 +213,13 @@ enum_reduce(PyObject *op, PyObject *Py_UNUSED(ignored)) enumobject *en = _enumobject_CAST(op); PyObject *result; Py_BEGIN_CRITICAL_SECTION(en); - if (en->en_longindex != NULL) + if (en->en_longindex != NULL) { result = Py_BuildValue("O(OO)", Py_TYPE(en), en->en_sit, en->en_longindex); - else - result = Py_BuildValue("O(On)", Py_TYPE(en), en->en_sit, en->en_index); + } + else { + Py_ssize_t en_index = FT_ATOMIC_LOAD_SSIZE_RELAXED(en->en_index); + result = Py_BuildValue("O(On)", Py_TYPE(en), en->en_sit, en_index); + } Py_END_CRITICAL_SECTION(); return result; } @@ -336,7 +275,7 @@ PyTypeObject PyEnum_Type = { PyType_GenericAlloc, /* tp_alloc */ enum_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ - .tp_vectorcall = enumerate_vectorcall + .tp_vectorcall = enum_vectorcall }; /* Reversed Object ***************************************************************/ @@ -350,6 +289,7 @@ typedef struct { #define _reversedobject_CAST(op) ((reversedobject *)(op)) /*[clinic input] +@vectorcall @classmethod reversed.__new__ as reversed_new @@ -361,7 +301,7 @@ Return a reverse iterator over the values of the given sequence. static PyObject * reversed_new_impl(PyTypeObject *type, PyObject *seq) -/*[clinic end generated code: output=f7854cc1df26f570 input=4781869729e3ba50]*/ +/*[clinic end generated code: output=f7854cc1df26f570 input=7db568182ab28c59]*/ { Py_ssize_t n; PyObject *reversed_meth; @@ -403,22 +343,6 @@ reversed_new_impl(PyTypeObject *type, PyObject *seq) return (PyObject *)ro; } -static PyObject * -reversed_vectorcall(PyObject *type, PyObject * const*args, - size_t nargsf, PyObject *kwnames) -{ - if (!_PyArg_NoKwnames("reversed", kwnames)) { - return NULL; - } - - Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); - if (!_PyArg_CheckPositional("reversed", nargs, 1, 1)) { - return NULL; - } - - return reversed_new_impl(_PyType_CAST(type), args[0]); -} - static void reversed_dealloc(PyObject *op) { diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 149595e64cec144..dc0ba0d7e533dda 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -11,9 +11,11 @@ #include "pycore_exceptions.h" // struct _Py_exc_state #include "pycore_initconfig.h" #include "pycore_modsupport.h" // _PyArg_NoKeywords() +#include "pycore_moduleobject.h" // _PyModule_CAST() #include "pycore_object.h" #include "pycore_pyerrors.h" // struct _PyErr_SetRaisedException #include "pycore_tuple.h" // _PyTuple_FromPair +#include "pycore_unicodeobject.h" // _PyUnicode_Equal() #include "osdefs.h" // SEP #include "clinic/exceptions.c.h" @@ -22,8 +24,11 @@ /*[clinic input] class BaseException "PyBaseExceptionObject *" "&PyExc_BaseException" class BaseExceptionGroup "PyBaseExceptionGroupObject *" "&PyExc_BaseExceptionGroup" +class ImportError "PyImportErrorObject *" "&PyExc_ImportError" +class NameError "PyNameErrorObject *" "&PyExc_NameError" +class AttributeError "PyAttributeErrorObject *" "&PyExc_AttributeError" [clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b7c45e78cff8edc3]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=fce4682940ab8948]*/ static struct _Py_exc_state* @@ -159,46 +164,40 @@ BaseException_traverse(PyObject *op, visitproc visit, void *arg) return 0; } +/*[clinic input] +@critical_section +BaseException.__str__ +[clinic start generated code]*/ + static PyObject * -BaseException_str(PyObject *op) +BaseException_str_impl(PyBaseExceptionObject *self) +/*[clinic end generated code: output=f9cf63c6d14a73fe input=cd946062d6786776]*/ { - PyBaseExceptionObject *self = PyBaseExceptionObject_CAST(op); - - PyObject *res; - Py_BEGIN_CRITICAL_SECTION(self); switch (PyTuple_GET_SIZE(self->args)) { case 0: - res = Py_GetConstant(Py_CONSTANT_EMPTY_STR); - break; + return Py_GetConstant(Py_CONSTANT_EMPTY_STR); case 1: - res = PyObject_Str(PyTuple_GET_ITEM(self->args, 0)); - break; + return PyObject_Str(PyTuple_GET_ITEM(self->args, 0)); default: - res = PyObject_Str(self->args); - break; + return PyObject_Str(self->args); } - Py_END_CRITICAL_SECTION(); - return res; } +/*[clinic input] +@critical_section +BaseException.__repr__ +[clinic start generated code]*/ + static PyObject * -BaseException_repr(PyObject *op) +BaseException_repr_impl(PyBaseExceptionObject *self) +/*[clinic end generated code: output=c885549a153a6007 input=20941168ad0ab577]*/ { - - PyBaseExceptionObject *self = PyBaseExceptionObject_CAST(op); - - PyObject *res; - Py_BEGIN_CRITICAL_SECTION(self); const char *name = _PyType_Name(Py_TYPE(self)); if (PyTuple_GET_SIZE(self->args) == 1) { - res = PyUnicode_FromFormat("%s(%R)", name, + return PyUnicode_FromFormat("%s(%R)", name, PyTuple_GET_ITEM(self->args, 0)); } - else { - res = PyUnicode_FromFormat("%s%R", name, self->args); - } - Py_END_CRITICAL_SECTION(); - return res; + return PyUnicode_FromFormat("%s%R", name, self->args); } /* Pickling support */ @@ -352,10 +351,6 @@ BaseException_args_set_impl(PyBaseExceptionObject *self, PyObject *value) /*[clinic end generated code: output=331137e11d8f9e80 input=2400047ea5970a84]*/ { PyObject *seq; - if (value == NULL) { - PyErr_SetString(PyExc_TypeError, "args may not be deleted"); - return -1; - } seq = PySequence_Tuple(value); if (!seq) return -1; @@ -391,10 +386,6 @@ BaseException___traceback___set_impl(PyBaseExceptionObject *self, PyObject *value) /*[clinic end generated code: output=a82c86d9f29f48f0 input=12676035676badad]*/ { - if (value == NULL) { - PyErr_SetString(PyExc_TypeError, "__traceback__ may not be deleted"); - return -1; - } if (PyTraceBack_Check(value)) { Py_XSETREF(self->traceback, Py_NewRef(value)); } @@ -436,10 +427,7 @@ BaseException___context___set_impl(PyBaseExceptionObject *self, PyObject *value) /*[clinic end generated code: output=b4cb52dcca1da3bd input=c0971adf47fa1858]*/ { - if (value == NULL) { - PyErr_SetString(PyExc_TypeError, "__context__ may not be deleted"); - return -1; - } else if (value == Py_None) { + if (value == Py_None) { value = NULL; } else if (!PyExceptionInstance_Check(value)) { PyErr_SetString(PyExc_TypeError, "exception context must be None " @@ -479,10 +467,7 @@ BaseException___cause___set_impl(PyBaseExceptionObject *self, PyObject *value) /*[clinic end generated code: output=6161315398aaf541 input=e1b403c0bde3f62a]*/ { - if (value == NULL) { - PyErr_SetString(PyExc_TypeError, "__cause__ may not be deleted"); - return -1; - } else if (value == Py_None) { + if (value == Py_None) { value = NULL; } else if (!PyExceptionInstance_Check(value)) { PyErr_SetString(PyExc_TypeError, "exception cause must be None " @@ -986,11 +971,11 @@ BaseExceptionGroup_new(PyTypeObject *type, PyObject *args, PyObject *kwds) */ cls = (PyTypeObject*)PyExc_BaseExceptionGroup; } - PyBaseExceptionGroupObject *self = - PyBaseExceptionGroupObject_CAST(BaseException_new(cls, args, kwds)); - if (!self) { + PyObject *op = BaseException_new(cls, args, kwds); + if (!op) { goto error; } + PyBaseExceptionGroupObject *self = PyBaseExceptionGroupObject_CAST(op); self->msg = Py_NewRef(message); self->excs = exceptions; @@ -1796,29 +1781,27 @@ PyImportErrorObject_CAST(PyObject *self) return (PyImportErrorObject *)self; } +/*[clinic input] +@vectorcall +ImportError.__init__ as ImportError_init + + *args: tuple + name: object = NULL + path: object = NULL + name_from: object = NULL + +[clinic start generated code]*/ + static int -ImportError_init(PyObject *op, PyObject *args, PyObject *kwds) +ImportError_init_impl(PyImportErrorObject *self, PyObject *args, + PyObject *name, PyObject *path, PyObject *name_from) +/*[clinic end generated code: output=4917add0f9473bd2 input=4e94a3b530f9be97]*/ { - static char *kwlist[] = {"name", "path", "name_from", 0}; - PyObject *empty_tuple; PyObject *msg = NULL; - PyObject *name = NULL; - PyObject *path = NULL; - PyObject *name_from = NULL; - - if (BaseException_init(op, args, NULL) == -1) - return -1; - PyImportErrorObject *self = PyImportErrorObject_CAST(op); - empty_tuple = PyTuple_New(0); - if (!empty_tuple) - return -1; - if (!PyArg_ParseTupleAndKeywords(empty_tuple, kwds, "|$OOO:ImportError", kwlist, - &name, &path, &name_from)) { - Py_DECREF(empty_tuple); + if (BaseException_init((PyObject *)self, args, NULL) == -1) { return -1; } - Py_DECREF(empty_tuple); Py_XSETREF(self->name, Py_XNewRef(name)); Py_XSETREF(self->path, Py_XNewRef(path)); @@ -1832,6 +1815,7 @@ ImportError_init(PyObject *op, PyObject *args, PyObject *kwds) return 0; } + static int ImportError_clear(PyObject *op) { @@ -2343,46 +2327,70 @@ static PyObject * OSError_str(PyObject *op) { PyOSErrorObject *self = PyOSErrorObject_CAST(op); + PyObject *res; + /* Hold strong references: formatting may run arbitrary code + which modifies the attributes. */ + PyObject *myerrno = Py_XNewRef(self->myerrno); + PyObject *strerror = Py_XNewRef(self->strerror); + PyObject *filename = Py_XNewRef(self->filename); + PyObject *filename2 = Py_XNewRef(self->filename2); +#ifdef MS_WINDOWS + PyObject *winerror = Py_XNewRef(self->winerror); +#endif #define OR_NONE(x) ((x)?(x):Py_None) #ifdef MS_WINDOWS /* If available, winerror has the priority over myerrno */ - if (self->winerror && self->filename) { - if (self->filename2) { - return PyUnicode_FromFormat("[WinError %S] %S: %R -> %R", - OR_NONE(self->winerror), - OR_NONE(self->strerror), - self->filename, - self->filename2); + if (winerror && filename) { + if (filename2) { + res = PyUnicode_FromFormat("[WinError %S] %S: %R -> %R", + OR_NONE(winerror), + OR_NONE(strerror), + filename, + filename2); } else { - return PyUnicode_FromFormat("[WinError %S] %S: %R", - OR_NONE(self->winerror), - OR_NONE(self->strerror), - self->filename); + res = PyUnicode_FromFormat("[WinError %S] %S: %R", + OR_NONE(winerror), + OR_NONE(strerror), + filename); } + goto done; + } + if (winerror && strerror) { + res = PyUnicode_FromFormat("[WinError %S] %S", + winerror, strerror); + goto done; } - if (self->winerror && self->strerror) - return PyUnicode_FromFormat("[WinError %S] %S", - self->winerror ? self->winerror: Py_None, - self->strerror ? self->strerror: Py_None); #endif - if (self->filename) { - if (self->filename2) { - return PyUnicode_FromFormat("[Errno %S] %S: %R -> %R", - OR_NONE(self->myerrno), - OR_NONE(self->strerror), - self->filename, - self->filename2); + if (filename) { + if (filename2) { + res = PyUnicode_FromFormat("[Errno %S] %S: %R -> %R", + OR_NONE(myerrno), + OR_NONE(strerror), + filename, + filename2); } else { - return PyUnicode_FromFormat("[Errno %S] %S: %R", - OR_NONE(self->myerrno), - OR_NONE(self->strerror), - self->filename); + res = PyUnicode_FromFormat("[Errno %S] %S: %R", + OR_NONE(myerrno), + OR_NONE(strerror), + filename); } + goto done; } - if (self->myerrno && self->strerror) - return PyUnicode_FromFormat("[Errno %S] %S", - self->myerrno, self->strerror); - return BaseException_str(op); + if (myerrno && strerror) { + res = PyUnicode_FromFormat("[Errno %S] %S", + myerrno, strerror); + goto done; + } + res = BaseException_str(op); +done: + Py_XDECREF(myerrno); + Py_XDECREF(strerror); + Py_XDECREF(filename); + Py_XDECREF(filename2); +#ifdef MS_WINDOWS + Py_XDECREF(winerror); +#endif + return res; } static PyObject * @@ -2573,33 +2581,29 @@ PyNameErrorObject_CAST(PyObject *self) return (PyNameErrorObject *)self; } -static int -NameError_init(PyObject *op, PyObject *args, PyObject *kwds) -{ - static char *kwlist[] = {"name", NULL}; - PyObject *name = NULL; +/*[clinic input] +@vectorcall +NameError.__init__ as NameError_init - if (BaseException_init(op, args, NULL) == -1) { - return -1; - } + *args: tuple + name: object = NULL - PyObject *empty_tuple = PyTuple_New(0); - if (!empty_tuple) { - return -1; - } - if (!PyArg_ParseTupleAndKeywords(empty_tuple, kwds, "|$O:NameError", kwlist, - &name)) { - Py_DECREF(empty_tuple); +[clinic start generated code]*/ + +static int +NameError_init_impl(PyNameErrorObject *self, PyObject *args, PyObject *name) +/*[clinic end generated code: output=f15305075d9aa272 input=2e2b7e781ae146b1]*/ +{ + if (BaseException_init((PyObject *)self, args, NULL) == -1) { return -1; } - Py_DECREF(empty_tuple); - PyNameErrorObject *self = PyNameErrorObject_CAST(op); Py_XSETREF(self->name, Py_XNewRef(name)); return 0; } + static int NameError_clear(PyObject *op) { @@ -2656,35 +2660,32 @@ PyAttributeErrorObject_CAST(PyObject *self) return (PyAttributeErrorObject *)self; } -static int -AttributeError_init(PyObject *op, PyObject *args, PyObject *kwds) -{ - static char *kwlist[] = {"name", "obj", NULL}; - PyObject *name = NULL; - PyObject *obj = NULL; +/*[clinic input] +@vectorcall +AttributeError.__init__ as AttributeError_init - if (BaseException_init(op, args, NULL) == -1) { - return -1; - } + *args: tuple + name: object = NULL + obj: object = NULL - PyObject *empty_tuple = PyTuple_New(0); - if (!empty_tuple) { - return -1; - } - if (!PyArg_ParseTupleAndKeywords(empty_tuple, kwds, "|$OO:AttributeError", kwlist, - &name, &obj)) { - Py_DECREF(empty_tuple); +[clinic start generated code]*/ + +static int +AttributeError_init_impl(PyAttributeErrorObject *self, PyObject *args, + PyObject *name, PyObject *obj) +/*[clinic end generated code: output=3d346f9a389f60fa input=bed43aafea47f1a0]*/ +{ + if (BaseException_init((PyObject *)self, args, NULL) == -1) { return -1; } - Py_DECREF(empty_tuple); - PyAttributeErrorObject *self = PyAttributeErrorObject_CAST(op); Py_XSETREF(self->name, Py_XNewRef(name)); Py_XSETREF(self->obj, Py_XNewRef(obj)); return 0; } + static int AttributeError_clear(PyObject *op) { @@ -2702,6 +2703,65 @@ AttributeError_dealloc(PyObject *self) Py_TYPE(self)->tp_free(self); } +static PyObject * +AttributeError_str(PyObject *op) +{ + PyAttributeErrorObject *self = PyAttributeErrorObject_CAST(op); + PyObject *arg; // borrowed ref + PyObject *obj = NULL, *name = NULL; + + /* .name and .obj are set automatically when attribute lookup fails, so + synthesize a more informative message from them when the caller + didn't supply a meaningful one of their own -- that is, when args is + empty, or contains only the attribute name. Otherwise, use the + message the caller gave. */ + + Py_BEGIN_CRITICAL_SECTION(self); + if ( + self->obj && self->name && PyUnicode_Check(self->name) + && ((PyTuple_GET_SIZE(self->args) == 1 + && PyUnicode_Check(arg = PyTuple_GET_ITEM(self->args, 0)) + && _PyUnicode_Equal(arg, self->name)) + || PyTuple_GET_SIZE(self->args) == 0) + ) { + obj = Py_NewRef(self->obj); + name = Py_NewRef(self->name); + } + Py_END_CRITICAL_SECTION(); + + if (!obj) { + assert(!name); + return BaseException_str(op); /* re-acquires lock */ + } + + PyObject *result = NULL; + if (PyModule_Check(obj)) { + PyModuleObject *mod = _PyModule_CAST(obj); + PyObject *modname; + if (PyDict_GetItemRef(mod->md_dict, &_Py_ID(__name__), &modname) < 0) { + goto done; + } + if (modname && PyUnicode_Check(modname)) { + result = PyUnicode_FromFormat("module %R has no attribute %R", + modname, name); + Py_DECREF(modname); + } else { + Py_XDECREF(modname); + result = PyUnicode_FromFormat("module has no attribute %R", name); + } + } else if (PyType_Check(obj)) { + result = PyUnicode_FromFormat("type object '%N' has no attribute %R", + obj, name); + } else { + result = PyUnicode_FromFormat("'%T' object has no attribute %R", + obj, name); + } +done: + Py_DECREF(obj); + Py_DECREF(name); + return result; +} + static int AttributeError_traverse(PyObject *op, visitproc visit, void *arg) { @@ -2770,7 +2830,7 @@ static PyMethodDef AttributeError_methods[] = { ComplexExtendsException(PyExc_Exception, AttributeError, AttributeError, 0, AttributeError_methods, AttributeError_members, - 0, BaseException_str, 0, "Attribute not found."); + 0, AttributeError_str, 0, "Attribute not found."); /* * SyntaxError extends Exception @@ -4500,6 +4560,15 @@ _PyExc_InitTypes(PyInterpreterState *interp) { exc->tp_vectorcall = BaseException_vectorcall; } + else if (exc->tp_init == ImportError_init) { + exc->tp_vectorcall = ImportError_vectorcall; + } + else if (exc->tp_init == NameError_init) { + exc->tp_vectorcall = NameError_vectorcall; + } + else if (exc->tp_init == AttributeError_init) { + exc->tp_vectorcall = AttributeError_vectorcall; + } } return 0; } diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 05c3e75b4642ee5..d018a0257726e47 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -106,27 +106,20 @@ PyFile_GetLine(PyObject *f, int n) int PyFile_WriteObject(PyObject *v, PyObject *f, int flags) { - PyObject *writer, *value, *result; - if (f == NULL) { PyErr_SetString(PyExc_TypeError, "writeobject with NULL file"); return -1; } - writer = PyObject_GetAttr(f, &_Py_ID(write)); - if (writer == NULL) - return -1; - if (flags & Py_PRINT_RAW) { - value = PyObject_Str(v); - } - else - value = PyObject_Repr(v); + + Py_INCREF(f); + PyObject *value = (flags & Py_PRINT_RAW) ? PyObject_Str(v) : PyObject_Repr(v); if (value == NULL) { - Py_DECREF(writer); + Py_DECREF(f); return -1; } - result = PyObject_CallOneArg(writer, value); + PyObject *result = PyObject_CallMethodOneArg(f, &_Py_ID(write), value); Py_DECREF(value); - Py_DECREF(writer); + Py_DECREF(f); if (result == NULL) return -1; Py_DECREF(result); @@ -216,6 +209,17 @@ PyObject_AsFileDescriptor(PyObject *o) return fd; } +int +_Py_Off_t_Converter(PyObject *arg, void *addr) +{ +#ifdef HAVE_LARGEFILE_SUPPORT + *((Py_off_t *)addr) = PyLong_AsLongLong(arg); +#else + *((Py_off_t *)addr) = PyLong_AsLong(arg); +#endif + return PyErr_Occurred() ? 0 : 1; +} + int _PyLong_FileDescriptor_Converter(PyObject *o, void *ptr) { @@ -286,6 +290,13 @@ typedef struct { int fd; } PyStdPrinter_Object; +/*[clinic input] +class stdprinter "PyStdPrinter_Object *" "&PyStdPrinter_Type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=031bf557c18c5df5]*/ + +#include "clinic/fileobject.c.h" + PyObject * PyFile_NewStdPrinter(int fd) { @@ -304,11 +315,19 @@ PyFile_NewStdPrinter(int fd) return (PyObject*)self; } +/*[clinic input] +stdprinter.write + + text as unicode: unicode + / + +Write the text to the stream. +[clinic start generated code]*/ + static PyObject * -stdprinter_write(PyObject *op, PyObject *args) +stdprinter_write_impl(PyStdPrinter_Object *self, PyObject *unicode) +/*[clinic end generated code: output=069c9645803fe8ad input=65041d6d7a23aff4]*/ { - PyStdPrinter_Object *self = (PyStdPrinter_Object*)op; - PyObject *unicode; PyObject *bytes = NULL; const char *str; Py_ssize_t n; @@ -325,10 +344,6 @@ stdprinter_write(PyObject *op, PyObject *args) Py_RETURN_NONE; } - if (!PyArg_ParseTuple(args, "U", &unicode)) { - return NULL; - } - /* Encode Unicode to UTF-8/backslashreplace */ str = PyUnicode_AsUTF8AndSize(unicode, &n); if (str == NULL) { @@ -399,7 +414,7 @@ static PyMethodDef stdprinter_methods[] = { {"flush", stdprinter_noop, METH_NOARGS, ""}, {"fileno", stdprinter_fileno, METH_NOARGS, ""}, {"isatty", stdprinter_isatty, METH_NOARGS, ""}, - {"write", stdprinter_write, METH_VARARGS, ""}, + STDPRINTER_WRITE_METHODDEF {NULL, NULL} /*sentinel */ }; diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 17e6a729dcd83fc..e7b904c9b213b87 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -5,6 +5,7 @@ #include "Python.h" #include "pycore_abstract.h" // _PyNumber_Index() +#include "pycore_bitutils.h" // _Py_bswap16() #include "pycore_dtoa.h" // _Py_dg_dtoa() #include "pycore_floatobject.h" // _PyFloat_FormatAdvancedWriter() #include "pycore_freelist.h" // _Py_FREELIST_FREE(), _Py_FREELIST_POP() @@ -259,6 +260,11 @@ PyFloat_AsDouble(PyObject *op) return PyFloat_AS_DOUBLE(op); } + // int subclass can override __float__() method + if (PyLong_CheckExact(op)) { + return PyLong_AsDouble(op); + } + nb = Py_TYPE(op)->tp_as_number; if (nb == NULL || nb->nb_float == NULL) { if (nb && nb->nb_index) { @@ -941,11 +947,16 @@ double_round(double x, int ndigits) { _Py_SET_53BIT_PRECISION_START; rounded = _Py_dg_strtod(mybuf, NULL); _Py_SET_53BIT_PRECISION_END; - if (errno == ERANGE && fabs(rounded) >= 1.) + if (errno == ENOMEM) { + PyErr_NoMemory(); + } + else if (errno == ERANGE && fabs(rounded) >= 1.) { PyErr_SetString(PyExc_OverflowError, "rounded value too large to represent"); - else + } + else { result = PyFloat_FromDouble(rounded); + } /* done computing value; now clean up */ if (mybuf != shortbuf) @@ -1555,6 +1566,7 @@ static PyObject * float_subtype_new(PyTypeObject *type, PyObject *x); /*[clinic input] +@vectorcall @classmethod float.__new__ as float_new x: object(c_default="NULL") = 0 @@ -1565,7 +1577,7 @@ Convert a string or number to a floating-point number, if possible. static PyObject * float_new_impl(PyTypeObject *type, PyObject *x) -/*[clinic end generated code: output=ccf1e8dc460ba6ba input=55909f888aa0c8a6]*/ +/*[clinic end generated code: output=ccf1e8dc460ba6ba input=39b40d663c372a91]*/ { if (type != &PyFloat_Type) { if (x == NULL) { @@ -1609,23 +1621,6 @@ float_subtype_new(PyTypeObject *type, PyObject *x) return newobj; } -static PyObject * -float_vectorcall(PyObject *type, PyObject *const *args, - size_t nargsf, PyObject *kwnames) -{ - if (!_PyArg_NoKwnames("float", kwnames)) { - return NULL; - } - - Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); - if (!_PyArg_CheckPositional("float", nargs, 0, 1)) { - return NULL; - } - - PyObject *x = nargs >= 1 ? args[0] : NULL; - return float_new_impl(_PyType_CAST(type), x); -} - /*[clinic input] @classmethod @@ -1894,12 +1889,43 @@ _PyFloat_DebugMallocStats(FILE *out) int PyFloat_Pack2(double x, char *data, int le) { - unsigned char *p = (unsigned char *)data; +#if _Py_HAVE_FLOAT16 + /* Conversion can change NaNs type or alter payload. Here we + just fallback to the generic code, instead of providing + workarounds as for single/double precision. */ + if (!isnan(x)) { + _Float16 y = (_Float16)x; + + if (isinf(y) && !isinf(x)) { + goto Overflow; + } + + if ((_PY_FLOAT_LITTLE_ENDIAN && !le) || (_PY_FLOAT_BIG_ENDIAN && le)) { +#if defined(__s390x__) && defined(__GNUC__) + // gh-158567: Workaround GCC crash on s390x. + // Avoid __builtin_bswap16() with _Float16. + // https://bugzilla.redhat.com/show_bug.cgi?id=2544649 + char buffer[2]; + memcpy(buffer, &y, 2); + data[0] = buffer[1]; + data[1] = buffer[0]; +#else + uint16_t word; + memcpy(&word, &y, 2); + word = _Py_bswap16(word); + memcpy(data, &word, 2); +#endif + } + else { + memcpy(data, &y, sizeof(_Float16)); + } + return 0; + } +#endif unsigned char sign; int e; double f; - unsigned short bits; - int incr = 1; + uint16_t bits; if (x == 0.0) { sign = (copysign(1.0, x) == -1.0); @@ -1979,18 +2005,10 @@ PyFloat_Pack2(double x, char *data, int le) bits |= (e << 10) | (sign << 15); /* Write out result. */ - if (le) { - p += 1; - incr = -1; + if ((_PY_FLOAT_LITTLE_ENDIAN && !le) || (_PY_FLOAT_BIG_ENDIAN && le)) { + bits = _Py_bswap16(bits); } - - /* First byte */ - *p = (unsigned char)((bits >> 8) & 0xFF); - p += incr; - - /* Second byte */ - *p = (unsigned char)(bits & 0xFF); - + memcpy(data, &bits, 2); return 0; Overflow: @@ -2002,10 +2020,7 @@ PyFloat_Pack2(double x, char *data, int le) int PyFloat_Pack4(double x, char *data, int le) { - unsigned char *p = (unsigned char *)data; float y = (float)x; - int i, incr = 1; - if (isinf(y) && !isinf(x)) { PyErr_SetString(PyExc_OverflowError, "float too large to pack with f format"); @@ -2029,8 +2044,8 @@ PyFloat_Pack4(double x, char *data, int le) } #else uint32_t u32; - memcpy(&u32, &y, 4); + /* Workaround RISC-V: "If a NaN value is converted to a * different floating-point type, the result is the * canonical NaN of the new type". The canonical NaN here @@ -2050,17 +2065,14 @@ PyFloat_Pack4(double x, char *data, int le) #endif } - unsigned char s[sizeof(float)]; - memcpy(s, &y, sizeof(float)); - if ((_PY_FLOAT_LITTLE_ENDIAN && !le) || (_PY_FLOAT_BIG_ENDIAN && le)) { - p += 3; - incr = -1; + uint32_t word; + memcpy(&word, &y, 4); + word = _Py_bswap32(word); + memcpy(data, &word, 4); } - - for (i = 0; i < 4; i++) { - *p = s[i]; - p += incr; + else { + memcpy(data, &y, sizeof(float)); } return 0; } @@ -2068,20 +2080,14 @@ PyFloat_Pack4(double x, char *data, int le) int PyFloat_Pack8(double x, char *data, int le) { - unsigned char *p = (unsigned char *)data; - unsigned char as_bytes[8]; - memcpy(as_bytes, &x, 8); - const unsigned char *s = as_bytes; - int i, incr = 1; - if ((_PY_FLOAT_LITTLE_ENDIAN && !le) || (_PY_FLOAT_BIG_ENDIAN && le)) { - p += 7; - incr = -1; + uint64_t word; + memcpy(&word, &x, 8); + word = _Py_bswap64(word); + memcpy(data, &word, 8); } - - for (i = 0; i < 8; i++) { - *p = *s++; - p += incr; + else { + memcpy(data, &x, 8); } return 0; } @@ -2090,6 +2096,24 @@ double PyFloat_Unpack2(const char *data, int le) { unsigned char *p = (unsigned char *)data; +#if _Py_HAVE_FLOAT16 + _Float16 x16; + + if ((_PY_FLOAT_LITTLE_ENDIAN && !le) || (_PY_FLOAT_BIG_ENDIAN && le)) { + char buf[2]; + + buf[1] = p[0]; + buf[0] = p[1]; + memcpy(&x16, buf, 2); + } + else { + memcpy(&x16, p, 2); + } + if (!isnan(x16)) { + return x16; + } + /* Fallback to the generic code for NaNs, see PyFloat_Pack2(). */ +#endif unsigned char sign; int e; unsigned int f; diff --git a/Objects/frameobject.c b/Objects/frameobject.c index c50cbeaada3c406..909e5b7a2700cda 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -14,6 +14,8 @@ #include "pycore_object.h" // _PyObject_GC_UNTRACK() #include "pycore_opcode_metadata.h" // _PyOpcode_Caches #include "pycore_optimizer.h" // _Py_Executors_InvalidateDependency() +#include "pycore_pystate.h" // _PyEval_StopTheWorld() +#include "pycore_tstate.h" // _PyThreadStateImpl #include "pycore_tuple.h" // _PyTuple_FromPair #include "pycore_unicodeobject.h" // _PyUnicode_Equal() #include "pycore_weakref.h" // FT_CLEAR_WEAKREFS() @@ -40,6 +42,85 @@ class frame "PyFrameObject *" "&PyFrame_Type" [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=2d1dbf2e06cf351f]*/ +/*[clinic input] +class FrameLocalsProxy "PyFrameLocalsProxyObject *" "&PyFrameLocalsProxy_Type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b877b1c7551e6925]*/ + + +#ifdef Py_GIL_DISABLED +// Returns 1 if the frame may be executing or resumed on another thread. +static int +_frame_is_on_other_thread(PyFrameObject *frame) +{ + _PyInterpreterFrame *iframe = frame->f_frame; + if (iframe->owner == FRAME_OWNED_BY_THREAD) { + PyThreadState *tstate = _PyThreadState_GET(); + int32_t our_tlbc = ((_PyThreadStateImpl *)tstate)->tlbc_index; + return iframe->tlbc_index != our_tlbc; + } + if (iframe->owner == FRAME_OWNED_BY_GENERATOR) { + // Another thread may be running or resume the generator. + return 1; + } + // FRAME_OWNED_BY_FRAME_OBJECT: the frame can no longer run. + return 0; +} +#endif + +// Evaluate CALL under the frame's critical section, or with the world +// stopped if the frame may be running on another thread. +#ifdef Py_GIL_DISABLED +#define FRAMELOCALSPROXY_LOCKED(FRAME, CALL, RESULT) \ + do { \ + int _stw; \ + Py_BEGIN_CRITICAL_SECTION(FRAME); \ + _stw = _frame_is_on_other_thread(FRAME); \ + if (!_stw) { \ + RESULT = CALL; \ + } \ + Py_END_CRITICAL_SECTION(); \ + if (_stw) { \ + PyInterpreterState *interp = _PyInterpreterState_GET(); \ + _PyEval_StopTheWorld(interp); \ + RESULT = CALL; \ + _PyEval_StartTheWorld(interp); \ + } \ + } while (0) +#else +#define FRAMELOCALSPROXY_LOCKED(FRAME, CALL, RESULT) \ + do { \ + RESULT = CALL; \ + } while (0) +#endif + + +// Returns a borrowed reference, the frame object keeps its code alive. +static PyCodeObject * +framelocalsproxy_getcode(PyFrameObject *frame) +{ + PyCodeObject *co; + Py_BEGIN_CRITICAL_SECTION(frame); + co = _PyFrame_GetCode(frame->f_frame); + Py_END_CRITICAL_SECTION(); + return co; +} + +// Returns a new reference to the extra locals dict or NULL. The running +// frame never touches it, so no stop the world is needed. +static PyObject * +framelocalsproxy_get_extra(PyFrameObject *frame, bool create) +{ + PyObject *extra; + Py_BEGIN_CRITICAL_SECTION(frame); + extra = frame->f_extra_locals; + if (extra == NULL && create) { + extra = frame->f_extra_locals = PyDict_New(); + } + Py_XINCREF(extra); + Py_END_CRITICAL_SECTION(); + return extra; +} // Returns new reference or NULL static PyObject * @@ -94,6 +175,22 @@ framelocalsproxy_hasval(_PyInterpreterFrame *frame, PyCodeObject *co, int i) return true; } +static int +framelocalsproxy_is_first_occurrence(PyObject *seen, PyObject *name) +{ + int found = PySet_Contains(seen, name); + if (found < 0) { + return -1; + } + if (found) { + return 0; + } + if (PySet_Add(seen, name) < 0) { + return -1; + } + return 1; +} + static int framelocalsproxy_getkeyindex(PyFrameObject *frame, PyObject *key, bool read, PyObject **value_ptr) { @@ -111,7 +208,7 @@ framelocalsproxy_getkeyindex(PyFrameObject *frame, PyObject *key, bool read, PyO // value_ptr should only be given if we are reading the value assert(read || value_ptr == NULL); - PyCodeObject *co = _PyFrame_GetCode(frame->f_frame); + PyCodeObject *co = framelocalsproxy_getcode(frame); // Ensure that the key is hashable. Py_hash_t key_hash = PyObject_Hash(key); @@ -127,7 +224,9 @@ framelocalsproxy_getkeyindex(PyFrameObject *frame, PyObject *key, bool read, PyO PyObject *name = PyTuple_GET_ITEM(co->co_localsplusnames, i); if (name == key) { if (read) { - PyObject *value = framelocalsproxy_getval(frame->f_frame, co, i); + PyObject *value; + FRAMELOCALSPROXY_LOCKED(frame, + framelocalsproxy_getval(frame->f_frame, co, i), value); if (value != NULL) { if (value_ptr != NULL) { *value_ptr = value; @@ -165,7 +264,9 @@ framelocalsproxy_getkeyindex(PyFrameObject *frame, PyObject *key, bool read, PyO } if (same) { if (read) { - PyObject *value = framelocalsproxy_getval(frame->f_frame, co, i); + PyObject *value; + FRAMELOCALSPROXY_LOCKED(frame, + framelocalsproxy_getval(frame->f_frame, co, i), value); if (value != NULL) { if (value_ptr != NULL) { *value_ptr = value; @@ -204,12 +305,11 @@ framelocalsproxy_getitem(PyObject *self, PyObject *key) // Okay not in the fast locals, try extra locals - PyObject *extra = frame->f_extra_locals; + PyObject *extra = framelocalsproxy_get_extra(frame, false); if (extra != NULL) { - if (PyDict_GetItemRef(extra, key, &value) < 0) { - return NULL; - } - if (value != NULL) { + int found = PyDict_GetItemRef(extra, key, &value); + Py_DECREF(extra); + if (found != 0) { return value; } } @@ -245,14 +345,55 @@ add_overwritten_fast_local(PyFrameObject *frame, PyObject *obj) return 0; } +// The replaced value is returned in `*old_value` so that it is decref'd +// outside stop the world. static int -framelocalsproxy_setitem(PyObject *self, PyObject *key, PyObject *value) +framelocalsproxy_setfast_lock_held(PyFrameObject *frame, int i, + PyObject *value, PyObject **old_value) { /* Merge locals into fast locals */ - PyFrameObject *frame = PyFrameLocalsProxyObject_CAST(self)->frame; _PyStackRef *fast = _PyFrame_GetLocalsArray(frame->f_frame); PyCodeObject *co = _PyFrame_GetCode(frame->f_frame); +#if _Py_TIER2 + _Py_Executors_InvalidateDependency(_PyInterpreterState_GET(), co, 1); +#endif + + _PyLocals_Kind kind = _PyLocals_GetKind(co->co_localspluskinds, i); + _PyStackRef oldvalue = fast[i]; + PyObject *cell = NULL; + if (kind == CO_FAST_FREE) { + // The cell was set when the frame was created from + // the function's closure, unless the frame has been cleared. + assert(PyStackRef_IsNull(oldvalue) || PyCell_Check(PyStackRef_AsPyObjectBorrow(oldvalue))); + cell = PyStackRef_AsPyObjectBorrow(oldvalue); + } else if (kind & CO_FAST_CELL && !PyStackRef_IsNull(oldvalue)) { + PyObject *as_obj = PyStackRef_AsPyObjectBorrow(oldvalue); + if (PyCell_Check(as_obj)) { + cell = as_obj; + } + } + if (cell != NULL) { + Py_XINCREF(value); + *old_value = PyCell_SwapTakeRef((PyCellObject *)cell, value); + } else if (value != PyStackRef_AsPyObjectBorrow(oldvalue)) { + PyObject *old_obj = PyStackRef_AsPyObjectBorrow(fast[i]); + if (old_obj != NULL && !_Py_IsImmortal(old_obj)) { + if (add_overwritten_fast_local(frame, old_obj) < 0) { + return -1; + } + PyStackRef_CLOSE(fast[i]); + } + fast[i] = PyStackRef_FromPyObjectNew(value); + } + return 0; +} + +static int +framelocalsproxy_setitem(PyObject *self, PyObject *key, PyObject *value) +{ + PyFrameObject *frame = PyFrameLocalsProxyObject_CAST(self)->frame; + int i = framelocalsproxy_getkeyindex(frame, key, false, NULL); if (i == -2) { return -1; @@ -262,64 +403,33 @@ framelocalsproxy_setitem(PyObject *self, PyObject *key, PyObject *value) PyErr_SetString(PyExc_ValueError, "cannot remove local variables from FrameLocalsProxy"); return -1; } - -#if _Py_TIER2 - _Py_Executors_InvalidateDependency(_PyInterpreterState_GET(), co, 1); -#endif - - _PyLocals_Kind kind = _PyLocals_GetKind(co->co_localspluskinds, i); - _PyStackRef oldvalue = fast[i]; - PyObject *cell = NULL; - if (kind == CO_FAST_FREE) { - // The cell was set when the frame was created from - // the function's closure. - assert(!PyStackRef_IsNull(oldvalue) && PyCell_Check(PyStackRef_AsPyObjectBorrow(oldvalue))); - cell = PyStackRef_AsPyObjectBorrow(oldvalue); - } else if (kind & CO_FAST_CELL && !PyStackRef_IsNull(oldvalue)) { - PyObject *as_obj = PyStackRef_AsPyObjectBorrow(oldvalue); - if (PyCell_Check(as_obj)) { - cell = as_obj; - } - } - if (cell != NULL) { - Py_XINCREF(value); - PyCell_SetTakeRef((PyCellObject *)cell, value); - } else if (value != PyStackRef_AsPyObjectBorrow(oldvalue)) { - PyObject *old_obj = PyStackRef_AsPyObjectBorrow(fast[i]); - if (old_obj != NULL && !_Py_IsImmortal(old_obj)) { - if (add_overwritten_fast_local(frame, old_obj) < 0) { - return -1; - } - PyStackRef_CLOSE(fast[i]); - } - fast[i] = PyStackRef_FromPyObjectNew(value); - } - return 0; + PyObject *old_value = NULL; + int result; + FRAMELOCALSPROXY_LOCKED(frame, + framelocalsproxy_setfast_lock_held(frame, i, value, &old_value), + result); + Py_XDECREF(old_value); + return result; } // Okay not in the fast locals, try extra locals - PyObject *extra = frame->f_extra_locals; - + PyObject *extra = framelocalsproxy_get_extra(frame, value != NULL); if (extra == NULL) { if (value == NULL) { _PyErr_SetKeyError(key); - return -1; - } - extra = PyDict_New(); - if (extra == NULL) { - return -1; } - frame->f_extra_locals = extra; + return -1; } - assert(PyDict_Check(extra)); - + int result; if (value == NULL) { - return PyDict_DelItem(extra, key); + result = PyDict_DelItem(extra, key); } else { - return PyDict_SetItem(extra, key, value); + result = PyDict_SetItem(extra, key, value); } + Py_DECREF(extra); + return result; } static int @@ -372,24 +482,35 @@ framelocalsproxy_merge(PyObject* self, PyObject* other) } static PyObject * -framelocalsproxy_keys(PyObject *self, PyObject *Py_UNUSED(ignored)) +framelocalsproxy_keys_lock_held(PyFrameObject *frame) { - PyFrameObject *frame = PyFrameLocalsProxyObject_CAST(self)->frame; PyCodeObject *co = _PyFrame_GetCode(frame->f_frame); PyObject *names = PyList_New(0); if (names == NULL) { return NULL; } + // An inlined comprehension cell can share a name with a free var. + PyObject *seen = PySet_New(NULL); + if (seen == NULL) { + Py_DECREF(names); + return NULL; + } for (int i = 0; i < co->co_nlocalsplus; i++) { if (framelocalsproxy_hasval(frame->f_frame, co, i)) { PyObject *name = PyTuple_GET_ITEM(co->co_localsplusnames, i); - if (PyList_Append(names, name) < 0) { - Py_DECREF(names); - return NULL; + int first = framelocalsproxy_is_first_occurrence(seen, name); + if (first < 0) { + goto error; + } + if (first) { + if (PyList_Append(names, name) < 0) { + goto error; + } } } } + Py_DECREF(seen); // Iterate through the extra locals if (frame->f_extra_locals) { @@ -398,16 +519,38 @@ framelocalsproxy_keys(PyObject *self, PyObject *Py_UNUSED(ignored)) Py_ssize_t i = 0; PyObject *key = NULL; PyObject *value = NULL; + int err = 0; + Py_BEGIN_CRITICAL_SECTION(frame->f_extra_locals); while (PyDict_Next(frame->f_extra_locals, &i, &key, &value)) { if (PyList_Append(names, key) < 0) { - Py_DECREF(names); - return NULL; + err = -1; + break; } } + Py_END_CRITICAL_SECTION(); + if (err < 0) { + Py_DECREF(names); + return NULL; + } } return names; + +error: + Py_DECREF(seen); + Py_DECREF(names); + return NULL; +} + +static PyObject * +framelocalsproxy_keys(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + PyFrameObject *frame = PyFrameLocalsProxyObject_CAST(self)->frame; + PyObject *result; + FRAMELOCALSPROXY_LOCKED(frame, + framelocalsproxy_keys_lock_held(frame), result); + return result; } static void @@ -419,36 +562,32 @@ framelocalsproxy_dealloc(PyObject *self) Py_TYPE(self)->tp_free(self); } +/*[clinic input] +@vectorcall +@classmethod +FrameLocalsProxy.__new__ as framelocalsproxy_new + frame: object + / + +Create a write-through view of the locals dictionary for a frame. + + frame + the frame object to wrap. +[clinic start generated code]*/ + static PyObject * -framelocalsproxy_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +framelocalsproxy_new_impl(PyTypeObject *type, PyObject *frame) +/*[clinic end generated code: output=803b377132a928b9 input=5ab4ffd26ec8e290]*/ { - if (PyTuple_GET_SIZE(args) != 1) { - PyErr_Format(PyExc_TypeError, - "FrameLocalsProxy expected 1 argument, got %zd", - PyTuple_GET_SIZE(args)); - return NULL; - } - PyObject *item = PyTuple_GET_ITEM(args, 0); - - if (!PyFrame_Check(item)) { - PyErr_Format(PyExc_TypeError, "expect frame, not %T", item); + if (!PyFrame_Check(frame)) { + PyErr_Format(PyExc_TypeError, "expect frame, not %T", frame); return NULL; } - PyFrameObject *frame = (PyFrameObject*)item; - - if (kwds != NULL && PyDict_Size(kwds) != 0) { - PyErr_SetString(PyExc_TypeError, - "FrameLocalsProxy takes no keyword arguments"); - return 0; - } - PyFrameLocalsProxyObject *self = (PyFrameLocalsProxyObject *)type->tp_alloc(type, 0); if (self == NULL) { return NULL; } - - ((PyFrameLocalsProxyObject*)self)->frame = (PyFrameObject*)Py_NewRef(frame); - + self->frame = (PyFrameObject *)Py_NewRef(frame); return (PyObject *)self; } @@ -581,97 +720,159 @@ framelocalsproxy_inplace_or(PyObject *self, PyObject *other) } static PyObject * -framelocalsproxy_values(PyObject *self, PyObject *Py_UNUSED(ignored)) +framelocalsproxy_values_lock_held(PyFrameObject *frame) { - PyFrameObject *frame = PyFrameLocalsProxyObject_CAST(self)->frame; PyCodeObject *co = _PyFrame_GetCode(frame->f_frame); PyObject *values = PyList_New(0); if (values == NULL) { return NULL; } + PyObject *seen = PySet_New(NULL); + if (seen == NULL) { + Py_DECREF(values); + return NULL; + } for (int i = 0; i < co->co_nlocalsplus; i++) { PyObject *value = framelocalsproxy_getval(frame->f_frame, co, i); if (value) { - if (PyList_Append(values, value) < 0) { - Py_DECREF(values); - Py_DECREF(value); - return NULL; + PyObject *name = PyTuple_GET_ITEM(co->co_localsplusnames, i); + int first = framelocalsproxy_is_first_occurrence(seen, name); + if (first == 1) { + if (PyList_Append(values, value) < 0) { + Py_DECREF(value); + goto error; + } } Py_DECREF(value); + if (first < 0) { + goto error; + } } } + Py_DECREF(seen); // Iterate through the extra locals if (frame->f_extra_locals) { Py_ssize_t j = 0; PyObject *key = NULL; PyObject *value = NULL; + int err = 0; + Py_BEGIN_CRITICAL_SECTION(frame->f_extra_locals); while (PyDict_Next(frame->f_extra_locals, &j, &key, &value)) { if (PyList_Append(values, value) < 0) { - Py_DECREF(values); - return NULL; + err = -1; + break; } } + Py_END_CRITICAL_SECTION(); + if (err < 0) { + Py_DECREF(values); + return NULL; + } } return values; + +error: + Py_DECREF(seen); + Py_DECREF(values); + return NULL; } static PyObject * -framelocalsproxy_items(PyObject *self, PyObject *Py_UNUSED(ignored)) +framelocalsproxy_values(PyObject *self, PyObject *Py_UNUSED(ignored)) { PyFrameObject *frame = PyFrameLocalsProxyObject_CAST(self)->frame; + PyObject *result; + FRAMELOCALSPROXY_LOCKED(frame, + framelocalsproxy_values_lock_held(frame), result); + return result; +} + +static PyObject * +framelocalsproxy_items_lock_held(PyFrameObject *frame) +{ PyCodeObject *co = _PyFrame_GetCode(frame->f_frame); PyObject *items = PyList_New(0); if (items == NULL) { return NULL; } + PyObject *seen = PySet_New(NULL); + if (seen == NULL) { + Py_DECREF(items); + return NULL; + } for (int i = 0; i < co->co_nlocalsplus; i++) { PyObject *name = PyTuple_GET_ITEM(co->co_localsplusnames, i); PyObject *value = framelocalsproxy_getval(frame->f_frame, co, i); if (value) { - PyObject *pair = _PyTuple_FromPairSteal(Py_NewRef(name), value); - if (pair == NULL) { - goto error; + int first = framelocalsproxy_is_first_occurrence(seen, name); + if (first == 1) { + PyObject *pair = _PyTuple_FromPairSteal(Py_NewRef(name), value); + if (pair == NULL) { + goto error; + } + if (_PyList_AppendTakeRef((PyListObject *)items, pair) < 0) { + goto error; + } } - - if (_PyList_AppendTakeRef((PyListObject *)items, pair) < 0) { - goto error; + else { + Py_DECREF(value); + if (first < 0) { + goto error; + } } } } + Py_DECREF(seen); + seen = NULL; // Iterate through the extra locals if (frame->f_extra_locals) { Py_ssize_t j = 0; PyObject *key = NULL; PyObject *value = NULL; + int err = 0; + Py_BEGIN_CRITICAL_SECTION(frame->f_extra_locals); while (PyDict_Next(frame->f_extra_locals, &j, &key, &value)) { PyObject *pair = _PyTuple_FromPair(key, value); - if (pair == NULL) { - goto error; - } - - if (_PyList_AppendTakeRef((PyListObject *)items, pair) < 0) { - goto error; + if (pair == NULL + || _PyList_AppendTakeRef((PyListObject *)items, pair) < 0) + { + err = -1; + break; } } + Py_END_CRITICAL_SECTION(); + if (err < 0) { + goto error; + } } return items; error: + Py_XDECREF(seen); Py_DECREF(items); return NULL; } -static Py_ssize_t -framelocalsproxy_length(PyObject *self) +static PyObject * +framelocalsproxy_items(PyObject *self, PyObject *Py_UNUSED(ignored)) { PyFrameObject *frame = PyFrameLocalsProxyObject_CAST(self)->frame; + PyObject *result; + FRAMELOCALSPROXY_LOCKED(frame, + framelocalsproxy_items_lock_held(frame), result); + return result; +} + +static Py_ssize_t +framelocalsproxy_length_lock_held(PyFrameObject *frame) +{ PyCodeObject *co = _PyFrame_GetCode(frame->f_frame); Py_ssize_t size = 0; @@ -680,14 +881,37 @@ framelocalsproxy_length(PyObject *self) size += PyDict_Size(frame->f_extra_locals); } + PyObject *seen = PySet_New(NULL); + if (seen == NULL) { + return -1; + } for (int i = 0; i < co->co_nlocalsplus; i++) { if (framelocalsproxy_hasval(frame->f_frame, co, i)) { - size++; + PyObject *name = PyTuple_GET_ITEM(co->co_localsplusnames, i); + int first = framelocalsproxy_is_first_occurrence(seen, name); + if (first < 0) { + Py_DECREF(seen); + return -1; + } + else if (first) { + size++; + } } } + Py_DECREF(seen); return size; } +static Py_ssize_t +framelocalsproxy_length(PyObject *self) +{ + PyFrameObject *frame = PyFrameLocalsProxyObject_CAST(self)->frame; + Py_ssize_t result; + FRAMELOCALSPROXY_LOCKED(frame, + framelocalsproxy_length_lock_held(frame), result); + return result; +} + static int framelocalsproxy_contains(PyObject *self, PyObject *key) { @@ -701,9 +925,11 @@ framelocalsproxy_contains(PyObject *self, PyObject *key) return 1; } - PyObject *extra = frame->f_extra_locals; + PyObject *extra = framelocalsproxy_get_extra(frame, false); if (extra != NULL) { - return PyDict_Contains(extra, key); + int result = PyDict_Contains(extra, key); + Py_DECREF(extra); + return result; } return 0; @@ -816,7 +1042,8 @@ framelocalsproxy_pop(PyObject* self, PyObject *const *args, Py_ssize_t nargs) PyObject *result = NULL; - if (frame->f_extra_locals == NULL) { + PyObject *extra = framelocalsproxy_get_extra(frame, false); + if (extra == NULL) { if (default_value != NULL) { return Py_XNewRef(default_value); } else { @@ -825,7 +1052,9 @@ framelocalsproxy_pop(PyObject* self, PyObject *const *args, Py_ssize_t nargs) } } - if (PyDict_Pop(frame->f_extra_locals, key, &result) < 0) { + int found = PyDict_Pop(extra, key, &result); + Py_DECREF(extra); + if (found < 0) { return NULL; } @@ -909,15 +1138,6 @@ static PyMethodDef framelocalsproxy_methods[] = { {NULL, NULL} /* sentinel */ }; -PyDoc_STRVAR(framelocalsproxy_doc, -"FrameLocalsProxy($frame)\n" -"--\n" -"\n" -"Create a write-through view of the locals dictionary for a frame.\n" -"\n" -" frame\n" -" the frame object to wrap."); - PyTypeObject PyFrameLocalsProxy_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) .tp_name = "FrameLocalsProxy", @@ -938,20 +1158,14 @@ PyTypeObject PyFrameLocalsProxy_Type = { .tp_alloc = PyType_GenericAlloc, .tp_new = framelocalsproxy_new, .tp_free = PyObject_GC_Del, - .tp_doc = framelocalsproxy_doc, + .tp_doc = framelocalsproxy_new__doc__, + .tp_vectorcall = framelocalsproxy_vectorcall, }; PyObject * _PyFrameLocalsProxy_New(PyFrameObject *frame) { - PyObject* args = PyTuple_Pack(1, frame); - if (args == NULL) { - return NULL; - } - - PyObject* proxy = framelocalsproxy_new(&PyFrameLocalsProxy_Type, args, NULL); - Py_DECREF(args); - return proxy; + return framelocalsproxy_new_impl(&PyFrameLocalsProxy_Type, (PyObject *)frame); } static PyMemberDef frame_memberlist[] = { @@ -1651,10 +1865,6 @@ frame_lineno_set_impl(PyFrameObject *self, PyObject *value) /*[clinic end generated code: output=e64c86ff6be64292 input=36ed3c896b27fb91]*/ { PyCodeObject *code = _PyFrame_GetCode(self->f_frame); - if (value == NULL) { - PyErr_SetString(PyExc_AttributeError, "cannot delete attribute"); - return -1; - } /* f_lineno must be an integer. */ if (!PyLong_CheckExact(value)) { PyErr_SetString(PyExc_ValueError, @@ -1868,12 +2078,13 @@ frame_trace_get_impl(PyFrameObject *self) @permit_long_summary @critical_section @setter +@deleter frame.f_trace as frame_trace [clinic start generated code]*/ static int frame_trace_set_impl(PyFrameObject *self, PyObject *value) -/*[clinic end generated code: output=d6fe08335cf76ae4 input=e57380734815dac5]*/ +/*[clinic end generated code: output=d6fe08335cf76ae4 input=9fb7a5805196eae2]*/ { if (value == Py_None) { value = NULL; @@ -1909,16 +2120,16 @@ frame_generator_get_impl(PyFrameObject *self) static PyGetSetDef frame_getsetlist[] = { - FRAME_BACK_GETSETDEF - FRAME_LOCALS_GETSETDEF - FRAME_LINENO_GETSETDEF - FRAME_TRACE_GETSETDEF - FRAME_LASTI_GETSETDEF - FRAME_GLOBALS_GETSETDEF - FRAME_BUILTINS_GETSETDEF - FRAME_CODE_GETSETDEF - FRAME_TRACE_OPCODES_GETSETDEF - FRAME_GENERATOR_GETSETDEF + FRAME_F_BACK_GETSETDEF + FRAME_F_LOCALS_GETSETDEF + FRAME_F_LINENO_GETSETDEF + FRAME_F_TRACE_GETSETDEF + FRAME_F_LASTI_GETSETDEF + FRAME_F_GLOBALS_GETSETDEF + FRAME_F_BUILTINS_GETSETDEF + FRAME_F_CODE_GETSETDEF + FRAME_F_TRACE_OPCODES_GETSETDEF + FRAME_F_GENERATOR_GETSETDEF {0} }; @@ -2045,19 +2256,20 @@ frame___sizeof___impl(PyFrameObject *self) return PyLong_FromSsize_t(res); } +/*[clinic input] +@critical_section +frame.__repr__ +[clinic start generated code]*/ + static PyObject * -frame_repr(PyObject *op) +frame_repr_impl(PyFrameObject *self) +/*[clinic end generated code: output=6dc361d24ba61076 input=cea0fd14e4749a55]*/ { - PyFrameObject *f = PyFrameObject_CAST(op); - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(f); - int lineno = PyFrame_GetLineNumber(f); - PyCodeObject *code = _PyFrame_GetCode(f->f_frame); - result = PyUnicode_FromFormat( + int lineno = PyFrame_GetLineNumber(self); + PyCodeObject *code = _PyFrame_GetCode(self->f_frame); + return PyUnicode_FromFormat( "", - f, code->co_filename, lineno, code->co_name); - Py_END_CRITICAL_SECTION(); - return result; + self, code->co_filename, lineno, code->co_name); } static PyMethodDef frame_methods[] = { @@ -2250,6 +2462,53 @@ frame_get_var(_PyInterpreterFrame *frame, PyCodeObject *co, int i, } +int +PyUnstable_InterpreterFrame_GetLocal(_PyInterpreterFrame *frame, + Py_ssize_t index, PyObject **result) +{ + PyCodeObject *co = _PyFrame_GetCode(frame); + *result = NULL; + if (index < 0 || index >= co->co_nlocalsplus) { + PyErr_Format( + PyExc_IndexError, + "PyUnstable_InterpreterFrame_GetLocal: index %zd out of range [0, %d)", + index, co->co_nlocalsplus); + return -1; + } + + int offset = PyUnstable_Code_GetFirstFree(co); // co_nlocalsplus - co_nfreevars + if (index < offset) { + // Local or cell variable. frame_get_var unboxes cells and copes with + // not-yet-started frames and arguments not yet promoted by MAKE_CELL. + if (_PyLocals_GetKind(co->co_localspluskinds, (int)index) & CO_FAST_HIDDEN) { + return 0; + } + PyObject *value = NULL; + frame_get_var(frame, co, (int)index, &value); + if (value == NULL) { + return 0; + } + *result = value; // strong reference + return 1; + } + + // Free variable: read from the function closure rather than localsplus. + if ((co->co_flags & CO_OPTIMIZED) + && PyStackRef_FunctionCheck(frame->f_funcobj)) + { + PyFunctionObject *func = _PyFrame_GetFunction(frame); + PyObject *cell = PyTuple_GET_ITEM(func->func_closure, index - offset); + PyObject *value = PyCell_GetRef((PyCellObject *)cell); + if (value == NULL) { + return 0; + } + *result = value; + return 1; + } + return 0; +} + + bool _PyFrame_HasHiddenLocals(_PyInterpreterFrame *frame) { @@ -2302,15 +2561,11 @@ _PyFrame_GetLocals(_PyInterpreterFrame *frame) } -PyObject * -PyFrame_GetVar(PyFrameObject *frame_obj, PyObject *name) +// Returns 1 if `name` is a bound fast local, storing its value in `*pvalue`. +static int +frame_getvar_lock_held(PyFrameObject *frame_obj, PyObject *name, + PyObject **pvalue) { - if (!PyUnicode_Check(name)) { - PyErr_Format(PyExc_TypeError, "name must be str, not %s", - Py_TYPE(name)->tp_name); - return NULL; - } - _PyInterpreterFrame *frame = frame_obj->f_frame; frame_init_get_vars(frame); @@ -2320,17 +2575,30 @@ PyFrame_GetVar(PyFrameObject *frame_obj, PyObject *name) if (!_PyUnicode_Equal(var_name, name)) { continue; } - - PyObject *value; - if (!frame_get_var(frame, co, i, &value)) { - break; - } - if (value == NULL) { - break; + if (!frame_get_var(frame, co, i, pvalue)) { + return 0; } - return value; + return *pvalue != NULL; + } + return 0; +} + +PyObject * +PyFrame_GetVar(PyFrameObject *frame_obj, PyObject *name) +{ + if (!PyUnicode_Check(name)) { + PyErr_Format(PyExc_TypeError, "name must be str, not %s", + Py_TYPE(name)->tp_name); + return NULL; } + PyObject *value = NULL; + int found; + FRAMELOCALSPROXY_LOCKED(frame_obj, + frame_getvar_lock_held(frame_obj, name, &value), found); + if (found) { + return value; + } PyErr_Format(PyExc_NameError, "variable %R does not exist", name); return NULL; } diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 0fffd36ad462dab..2e0bcd7853b9259 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -41,7 +41,8 @@ notify_func_watchers(PyInterpreterState *interp, PyFunction_WatchEvent event, if (cb(event, func, new_value) < 0) { PyErr_FormatUnraisable( "Exception ignored in %s watcher callback for function %U at %p", - func_event_name(event), func->func_qualname, func); + func_event_name(event), + FT_ATOMIC_LOAD_PTR_ACQUIRE(func->func_qualname), func); } } i++; @@ -349,20 +350,6 @@ func_clear_version(PyInterpreterState *interp, PyFunctionObject *func) func->func_version = FUNC_VERSION_CLEARED; } -// Called when any of the critical function attributes are changed -static void -_PyFunction_ClearVersion(PyFunctionObject *func) -{ - if (func->func_version < FUNC_VERSION_FIRST_VALID) { - // Version was never set or has already been cleared. - return; - } - PyInterpreterState *interp = _PyInterpreterState_GET(); - _PyEval_StopTheWorld(interp); - func_clear_version(interp, func); - _PyEval_StartTheWorld(interp); -} - void _PyFunction_ClearCodeByVersion(uint32_t version) { @@ -419,7 +406,7 @@ PyFunction_GetModule(PyObject *op) PyErr_BadInternalCall(); return NULL; } - return ((PyFunctionObject *) op) -> func_module; + return PyFunction_GET_MODULE(op); } PyObject * @@ -448,10 +435,15 @@ PyFunction_SetDefaults(PyObject *op, PyObject *defaults) PyErr_SetString(PyExc_SystemError, "non-tuple default args"); return -1; } - handle_func_event(PyFunction_EVENT_MODIFY_DEFAULTS, - (PyFunctionObject *) op, defaults); - _PyFunction_ClearVersion((PyFunctionObject *)op); - Py_XSETREF(((PyFunctionObject *)op)->func_defaults, defaults); + PyFunctionObject *func = (PyFunctionObject *)op; + handle_func_event(PyFunction_EVENT_MODIFY_DEFAULTS, func, defaults); + PyInterpreterState *interp = _PyInterpreterState_GET(); + _PyEval_StopTheWorld(interp); + func_clear_version(interp, func); + PyObject *old_defaults = func->func_defaults; + func->func_defaults = defaults; + _PyEval_StartTheWorld(interp); + Py_XDECREF(old_defaults); return 0; } @@ -459,8 +451,11 @@ void PyFunction_SetVectorcall(PyFunctionObject *func, vectorcallfunc vectorcall) { assert(func != NULL); - _PyFunction_ClearVersion(func); + PyInterpreterState *interp = _PyInterpreterState_GET(); + _PyEval_StopTheWorld(interp); + func_clear_version(interp, func); func->vectorcall = vectorcall; + _PyEval_StartTheWorld(interp); } PyObject * @@ -490,10 +485,15 @@ PyFunction_SetKwDefaults(PyObject *op, PyObject *defaults) "non-dict keyword only default args"); return -1; } - handle_func_event(PyFunction_EVENT_MODIFY_KWDEFAULTS, - (PyFunctionObject *) op, defaults); - _PyFunction_ClearVersion((PyFunctionObject *)op); - Py_XSETREF(((PyFunctionObject *)op)->func_kwdefaults, defaults); + PyFunctionObject *func = (PyFunctionObject *)op; + handle_func_event(PyFunction_EVENT_MODIFY_KWDEFAULTS, func, defaults); + PyInterpreterState *interp = _PyInterpreterState_GET(); + _PyEval_StopTheWorld(interp); + func_clear_version(interp, func); + PyObject *old_kwdefaults = func->func_kwdefaults; + func->func_kwdefaults = defaults; + _PyEval_StartTheWorld(interp); + Py_XDECREF(old_kwdefaults); return 0; } @@ -525,20 +525,53 @@ PyFunction_SetClosure(PyObject *op, PyObject *closure) Py_TYPE(closure)->tp_name); return -1; } - _PyFunction_ClearVersion((PyFunctionObject *)op); - Py_XSETREF(((PyFunctionObject *)op)->func_closure, closure); + PyFunctionObject *func = (PyFunctionObject *)op; + PyInterpreterState *interp = _PyInterpreterState_GET(); + _PyEval_StopTheWorld(interp); + func_clear_version(interp, func); + PyObject *old_closure = func->func_closure; + func->func_closure = closure; + _PyEval_StartTheWorld(interp); + Py_XDECREF(old_closure); return 0; } +static void +func_set_annotations_and_annotate(PyFunctionObject *op, PyObject *annotations, + PyObject *annotate) +{ + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op); + // Care is needed, finalizers can run when references are dropped. Store + // both new values before dropping references to the old. + PyObject *old_annotations = op->func_annotations; + PyObject *old_annotate = op->func_annotate; + FT_ATOMIC_STORE_PTR_RELEASE(op->func_annotations, annotations); + FT_ATOMIC_STORE_PTR_RELEASE(op->func_annotate, annotate); + if (old_annotations != NULL && !_Py_IsImmortal(old_annotations)) { + _PyObject_XDecRefDelayed(old_annotations); + } + if (old_annotate != NULL && !_Py_IsImmortal(old_annotate)) { + _PyObject_XDecRefDelayed(old_annotate); + } +} + static PyObject * func_get_annotation_dict(PyFunctionObject *op) { + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op); if (op->func_annotations == NULL) { - if (op->func_annotate == NULL || !PyCallable_Check(op->func_annotate)) { + PyObject *annotate = op->func_annotate; + if (annotate == NULL || !PyCallable_Check(annotate)) { Py_RETURN_NONE; } + // Calling __annotate__ can run arbitrary code which may replace + // func_annotate or func_annotations, either directly or from another + // thread while the critical section is suspended. Keep the callable + // alive during the call. + Py_INCREF(annotate); PyObject *one = _PyLong_GetOne(); - PyObject *ann_dict = _PyObject_CallOneArg(op->func_annotate, one); + PyObject *ann_dict = _PyObject_CallOneArg(annotate, one); + Py_DECREF(annotate); if (ann_dict == NULL) { return NULL; } @@ -549,13 +582,22 @@ func_get_annotation_dict(PyFunctionObject *op) Py_DECREF(ann_dict); return NULL; } - Py_XSETREF(op->func_annotations, ann_dict); + if (op->func_annotations != NULL) { + // Annotations were set during the call, keep them. + Py_DECREF(ann_dict); + assert(PyDict_Check(op->func_annotations)); + return op->func_annotations; + } + _PyObject_XSetRefDelayed(&op->func_annotations, ann_dict); return ann_dict; } if (PyTuple_CheckExact(op->func_annotations)) { - PyObject *ann_tuple = op->func_annotations; + // Keep the tuple alive while building the dict, since it can be + // replaced if the critical section is suspended. + PyObject *ann_tuple = Py_NewRef(op->func_annotations); PyObject *ann_dict = PyDict_New(); if (ann_dict == NULL) { + Py_DECREF(ann_tuple); return NULL; } @@ -568,10 +610,12 @@ func_get_annotation_dict(PyFunctionObject *op) if (err < 0) { Py_DECREF(ann_dict); + Py_DECREF(ann_tuple); return NULL; } } - Py_SETREF(op->func_annotations, ann_dict); + _PyObject_XSetRefDelayed(&op->func_annotations, ann_dict); + _PyObject_XDecRefDelayed(ann_tuple); } assert(PyDict_Check(op->func_annotations)); return op->func_annotations; @@ -584,7 +628,11 @@ PyFunction_GetAnnotations(PyObject *op) PyErr_BadInternalCall(); return NULL; } - return func_get_annotation_dict((PyFunctionObject *)op); + PyObject *d; + Py_BEGIN_CRITICAL_SECTION(op); + d = func_get_annotation_dict((PyFunctionObject *)op); + Py_END_CRITICAL_SECTION(); + return d; } int @@ -605,8 +653,9 @@ PyFunction_SetAnnotations(PyObject *op, PyObject *annotations) return -1; } PyFunctionObject *func = (PyFunctionObject *)op; - Py_XSETREF(func->func_annotations, annotations); - Py_CLEAR(func->func_annotate); + Py_BEGIN_CRITICAL_SECTION(func); + func_set_annotations_and_annotate(func, annotations, NULL); + Py_END_CRITICAL_SECTION(); return 0; } @@ -616,9 +665,7 @@ PyFunction_SetAnnotations(PyObject *op, PyObject *annotations) static PyMemberDef func_memberlist[] = { {"__closure__", _Py_T_OBJECT, OFF(func_closure), Py_READONLY}, - {"__doc__", _Py_T_OBJECT, OFF(func_doc), 0}, {"__globals__", _Py_T_OBJECT, OFF(func_globals), Py_READONLY}, - {"__module__", _Py_T_OBJECT, OFF(func_module), 0}, {"__builtins__", _Py_T_OBJECT, OFF(func_builtins), Py_READONLY}, {NULL} /* Sentinel */ }; @@ -663,11 +710,11 @@ func_set_code(PyObject *self, PyObject *value, void *Py_UNUSED(ignored)) Py_ssize_t nclosure = (op->func_closure == NULL ? 0 : PyTuple_GET_SIZE(op->func_closure)); if (nclosure != nfree) { + PyObject *name = FT_ATOMIC_LOAD_PTR_ACQUIRE(op->func_name); PyErr_Format(PyExc_ValueError, "%U() requires a code object with %zd free vars," " not %d", - op->func_name, - nclosure, nfree); + name, nclosure, nfree); return -1; } @@ -685,8 +732,13 @@ func_set_code(PyObject *self, PyObject *value, void *Py_UNUSED(ignored)) } handle_func_event(PyFunction_EVENT_MODIFY_CODE, op, value); - _PyFunction_ClearVersion(op); - Py_XSETREF(op->func_code, Py_NewRef(value)); + PyInterpreterState *interp = _PyInterpreterState_GET(); + _PyEval_StopTheWorld(interp); + func_clear_version(interp, op); + PyObject *old_code = op->func_code; + op->func_code = Py_NewRef(value); + _PyEval_StartTheWorld(interp); + Py_XDECREF(old_code); return 0; } @@ -694,7 +746,8 @@ static PyObject * func_get_name(PyObject *self, void *Py_UNUSED(ignored)) { PyFunctionObject *op = _PyFunction_CAST(self); - return Py_NewRef(op->func_name); + PyObject *name = FT_ATOMIC_LOAD_PTR_ACQUIRE(op->func_name); + return Py_NewRef(name); } static int @@ -708,7 +761,9 @@ func_set_name(PyObject *self, PyObject *value, void *Py_UNUSED(ignored)) "__name__ must be set to a string object"); return -1; } - Py_XSETREF(op->func_name, Py_NewRef(value)); + Py_BEGIN_CRITICAL_SECTION(op); + _PyObject_XSetRefDelayed(&op->func_name, Py_NewRef(value)); + Py_END_CRITICAL_SECTION(); return 0; } @@ -716,7 +771,8 @@ static PyObject * func_get_qualname(PyObject *self, void *Py_UNUSED(ignored)) { PyFunctionObject *op = _PyFunction_CAST(self); - return Py_NewRef(op->func_qualname); + PyObject *qualname = FT_ATOMIC_LOAD_PTR_ACQUIRE(op->func_qualname); + return Py_NewRef(qualname); } static int @@ -731,7 +787,53 @@ func_set_qualname(PyObject *self, PyObject *value, void *Py_UNUSED(ignored)) return -1; } handle_func_event(PyFunction_EVENT_MODIFY_QUALNAME, (PyFunctionObject *) op, value); - Py_XSETREF(op->func_qualname, Py_NewRef(value)); + Py_BEGIN_CRITICAL_SECTION(op); + _PyObject_XSetRefDelayed(&op->func_qualname, Py_NewRef(value)); + Py_END_CRITICAL_SECTION(); + return 0; +} + +static PyObject * +func_get_doc(PyObject *self, void *Py_UNUSED(ignored)) +{ + PyFunctionObject *op = _PyFunction_CAST(self); + PyObject *doc = FT_ATOMIC_LOAD_PTR_ACQUIRE(op->func_doc); + if (doc == NULL) { + doc = Py_None; + } + return Py_NewRef(doc); +} + +static int +func_set_doc(PyObject *self, PyObject *value, void *Py_UNUSED(ignored)) +{ + /* Legal to del f.__doc__ or to set it to any object. */ + PyFunctionObject *op = _PyFunction_CAST(self); + Py_BEGIN_CRITICAL_SECTION(op); + _PyObject_XSetRefDelayed(&op->func_doc, Py_XNewRef(value)); + Py_END_CRITICAL_SECTION(); + return 0; +} + +static PyObject * +func_get_module(PyObject *self, void *Py_UNUSED(ignored)) +{ + PyFunctionObject *op = _PyFunction_CAST(self); + PyObject *module = FT_ATOMIC_LOAD_PTR_ACQUIRE(op->func_module); + if (module == NULL) { + module = Py_None; + } + return Py_NewRef(module); +} + +static int +func_set_module(PyObject *self, PyObject *value, void *Py_UNUSED(ignored)) +{ + /* Legal to del f.__module__ or to set it to any object. */ + PyFunctionObject *op = _PyFunction_CAST(self); + Py_BEGIN_CRITICAL_SECTION(op); + _PyObject_XSetRefDelayed(&op->func_module, Py_XNewRef(value)); + Py_END_CRITICAL_SECTION(); return 0; } @@ -772,8 +874,13 @@ func_set_defaults(PyObject *self, PyObject *value, void *Py_UNUSED(ignored)) } handle_func_event(PyFunction_EVENT_MODIFY_DEFAULTS, op, value); - _PyFunction_ClearVersion(op); - Py_XSETREF(op->func_defaults, Py_XNewRef(value)); + PyInterpreterState *interp = _PyInterpreterState_GET(); + _PyEval_StopTheWorld(interp); + func_clear_version(interp, op); + PyObject *old_defaults = op->func_defaults; + op->func_defaults = Py_XNewRef(value); + _PyEval_StartTheWorld(interp); + Py_XDECREF(old_defaults); return 0; } @@ -815,8 +922,13 @@ func_set_kwdefaults(PyObject *self, PyObject *value, void *Py_UNUSED(ignored)) } handle_func_event(PyFunction_EVENT_MODIFY_KWDEFAULTS, op, value); - _PyFunction_ClearVersion(op); - Py_XSETREF(op->func_kwdefaults, Py_XNewRef(value)); + PyInterpreterState *interp = _PyInterpreterState_GET(); + _PyEval_StopTheWorld(interp); + func_clear_version(interp, op); + PyObject *old_kwdefaults = op->func_kwdefaults; + op->func_kwdefaults = Py_XNewRef(value); + _PyEval_StartTheWorld(interp); + Py_XDECREF(old_kwdefaults); return 0; } @@ -848,18 +960,12 @@ static int function___annotate___set_impl(PyFunctionObject *self, PyObject *value) /*[clinic end generated code: output=05b7dfc07ada66cd input=eb6225e358d97448]*/ { - if (value == NULL) { - PyErr_SetString(PyExc_TypeError, - "__annotate__ cannot be deleted"); - return -1; - } if (Py_IsNone(value)) { - Py_XSETREF(self->func_annotate, value); + _PyObject_XSetRefDelayed(&self->func_annotate, Py_NewRef(value)); return 0; } else if (PyCallable_Check(value)) { - Py_XSETREF(self->func_annotate, Py_XNewRef(value)); - Py_CLEAR(self->func_annotations); + func_set_annotations_and_annotate(self, NULL, Py_NewRef(value)); return 0; } else { @@ -884,9 +990,10 @@ function___annotations___get_impl(PyFunctionObject *self) PyObject *d = NULL; if (self->func_annotations == NULL && (self->func_annotate == NULL || !PyCallable_Check(self->func_annotate))) { - self->func_annotations = PyDict_New(); - if (self->func_annotations == NULL) + PyObject *ann_dict = PyDict_New(); + if (ann_dict == NULL) return NULL; + FT_ATOMIC_STORE_PTR_RELEASE(self->func_annotations, ann_dict); } d = func_get_annotation_dict(self); return Py_XNewRef(d); @@ -895,12 +1002,13 @@ function___annotations___get_impl(PyFunctionObject *self) /*[clinic input] @critical_section @setter +@deleter function.__annotations__ [clinic start generated code]*/ static int function___annotations___set_impl(PyFunctionObject *self, PyObject *value) -/*[clinic end generated code: output=a61795d4a95eede4 input=5302641f686f0463]*/ +/*[clinic end generated code: output=a61795d4a95eede4 input=71f6a58c00ac6745]*/ { if (value == Py_None) value = NULL; @@ -912,8 +1020,7 @@ function___annotations___set_impl(PyFunctionObject *self, PyObject *value) "__annotations__ must be set to a dict object"); return -1; } - Py_XSETREF(self->func_annotations, Py_XNewRef(value)); - Py_CLEAR(self->func_annotate); + func_set_annotations_and_annotate(self, Py_XNewRef(value), NULL); return 0; } @@ -941,19 +1048,13 @@ function___type_params___get_impl(PyFunctionObject *self) @critical_section @setter function.__type_params__ + value: object(subclass_of='&PyTuple_Type') [clinic start generated code]*/ static int function___type_params___set_impl(PyFunctionObject *self, PyObject *value) -/*[clinic end generated code: output=038b4cda220e56fb input=3862fbd4db2b70e8]*/ +/*[clinic end generated code: output=038b4cda220e56fb input=e848b79ec6fec497]*/ { - /* Not legal to del f.__type_params__ or to set it to anything - * other than a tuple object. */ - if (value == NULL || !PyTuple_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "__type_params__ must be set to a tuple"); - return -1; - } Py_XSETREF(self->func_typeparams, Py_NewRef(value)); return 0; } @@ -976,6 +1077,8 @@ static PyGetSetDef func_getsetlist[] = { FUNCTION___ANNOTATIONS___GETSETDEF FUNCTION___ANNOTATE___GETSETDEF {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict}, + {"__doc__", func_get_doc, func_set_doc}, + {"__module__", func_get_module, func_set_module}, {"__name__", func_get_name, func_set_name}, {"__qualname__", func_get_qualname, func_set_qualname}, FUNCTION___TYPE_PARAMS___GETSETDEF @@ -993,6 +1096,7 @@ static PyGetSetDef func_getsetlist[] = { */ /*[clinic input] +@vectorcall @classmethod function.__new__ as func_new code: object(type="PyCodeObject *", subclass_of="&PyCode_Type") @@ -1015,7 +1119,7 @@ static PyObject * func_new_impl(PyTypeObject *type, PyCodeObject *code, PyObject *globals, PyObject *name, PyObject *defaults, PyObject *closure, PyObject *kwdefaults) -/*[clinic end generated code: output=de72f4c22ac57144 input=20c9c9f04ad2d3f2]*/ +/*[clinic end generated code: output=de72f4c22ac57144 input=264767a5dc845c90]*/ { PyFunctionObject *newfunc; Py_ssize_t nclosure; @@ -1147,8 +1251,8 @@ static PyObject* func_repr(PyObject *self) { PyFunctionObject *op = _PyFunction_CAST(self); - return PyUnicode_FromFormat("", - op->func_qualname, op); + PyObject *qualname = FT_ATOMIC_LOAD_PTR_ACQUIRE(op->func_qualname); + return PyUnicode_FromFormat("", qualname, op); } static int @@ -1223,6 +1327,7 @@ PyTypeObject PyFunction_Type = { 0, /* tp_init */ 0, /* tp_alloc */ func_new, /* tp_new */ + .tp_vectorcall = func_vectorcall, }; @@ -1375,8 +1480,9 @@ descriptor_set_wrapped_attribute(PyObject *oobj, PyObject *name, PyObject *value return 0; } else { + int result = PyDict_SetItem(dict, name, value); Py_DECREF(dict); - return PyDict_SetItem(dict, name, value); + return result; } } diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c index 4e85927def7ea78..2633b9af81c5b90 100644 --- a/Objects/genericaliasobject.c +++ b/Objects/genericaliasobject.c @@ -2,6 +2,7 @@ #include "Python.h" #include "pycore_ceval.h" // _PyEval_GetBuiltin() +#include "pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION() #include "pycore_modsupport.h" // _PyArg_NoKeywords() #include "pycore_object.h" #include "pycore_typevarobject.h" // _Py_typing_type_repr @@ -186,20 +187,23 @@ PyObject * _Py_make_parameters(PyObject *args) { assert(PyTuple_Check(args) || PyList_Check(args)); + if (Py_EnterRecursiveCall(" in __parameter__ calculation")) { + return NULL; + } + const bool is_args_list = PyList_Check(args); PyObject *tuple_args = NULL; if (is_args_list) { args = tuple_args = PySequence_Tuple(args); if (args == NULL) { - return NULL; + goto cleanup; } } Py_ssize_t nargs = PyTuple_GET_SIZE(args); Py_ssize_t len = nargs; PyObject *parameters = PyTuple_New(len); if (parameters == NULL) { - Py_XDECREF(tuple_args); - return NULL; + goto error; } Py_ssize_t iparam = 0; for (Py_ssize_t iarg = 0; iarg < nargs; iarg++) { @@ -210,9 +214,7 @@ _Py_make_parameters(PyObject *args) } int rc = PyObject_HasAttrWithError(t, &_Py_ID(__typing_subst__)); if (rc < 0) { - Py_DECREF(parameters); - Py_XDECREF(tuple_args); - return NULL; + goto error; } if (rc) { iparam += tuple_add(parameters, iparam, t); @@ -221,18 +223,14 @@ _Py_make_parameters(PyObject *args) PyObject *subparams; if (PyObject_GetOptionalAttr(t, &_Py_ID(__parameters__), &subparams) < 0) { - Py_DECREF(parameters); - Py_XDECREF(tuple_args); - return NULL; + goto error; } if (!subparams && (PyTuple_Check(t) || PyList_Check(t))) { // Recursively call _Py_make_parameters for lists/tuples and // add the results to the current parameters. subparams = _Py_make_parameters(t); if (subparams == NULL) { - Py_DECREF(parameters); - Py_XDECREF(tuple_args); - return NULL; + goto error; } } if (subparams && PyTuple_Check(subparams)) { @@ -243,7 +241,7 @@ _Py_make_parameters(PyObject *args) if (_PyTuple_Resize(¶meters, len) < 0) { Py_DECREF(subparams); Py_XDECREF(tuple_args); - return NULL; + goto cleanup; } } for (Py_ssize_t j = 0; j < len2; j++) { @@ -256,13 +254,19 @@ _Py_make_parameters(PyObject *args) } if (iparam < len) { if (_PyTuple_Resize(¶meters, iparam) < 0) { - Py_XDECREF(parameters); - Py_XDECREF(tuple_args); - return NULL; + goto error; } } Py_XDECREF(tuple_args); + Py_LeaveRecursiveCall(); return parameters; + +error: + Py_XDECREF(parameters); + Py_XDECREF(tuple_args); +cleanup: + Py_LeaveRecursiveCall(); + return NULL; } /* If obj is a generic alias, substitute type variables params @@ -299,7 +303,7 @@ subs_tvars(PyObject *obj, PyObject *params, PyTuple_GET_SIZE(arg)); if (j < 0) { Py_DECREF(subparams); - Py_DECREF(subargs); + assert(subargs == NULL); return NULL; } continue; @@ -521,8 +525,18 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje } if (subst) { Py_ssize_t iparam = tuple_index(parameters, nparams, arg); - assert(iparam >= 0); - arg = PyObject_CallOneArg(subst, argitems[iparam]); + if (iparam < 0) { + // __parameters__ may be stale if an argument gained + // __typing_subst__ after the tuple was computed. + PyErr_Format(PyExc_TypeError, + "argument %R with __typing_subst__ was not found " + "in __parameters__", + arg); + arg = NULL; + } + else { + arg = PyObject_CallOneArg(subst, argitems[iparam]); + } Py_DECREF(subst); } else { @@ -536,13 +550,13 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje } if (unpack) { if (!PyTuple_Check(arg)) { - Py_DECREF(newargs); - Py_DECREF(item); - Py_XDECREF(tuple_args); PyObject *original = PyTuple_GET_ITEM(args, iarg); PyErr_Format(PyExc_TypeError, "expected __typing_subst__ of %T objects to return a tuple, not %T", original, arg); + Py_DECREF(newargs); + Py_DECREF(item); + Py_XDECREF(tuple_args); Py_DECREF(arg); return NULL; } @@ -575,19 +589,24 @@ PyDoc_STRVAR(genericalias__doc__, "For example, for t = list[int], t.__origin__ is list and t.__args__\n" "is (int,)."); +static PyObject * +ga_parameters_lock_held(PyObject *self); + static PyObject * ga_getitem(PyObject *self, PyObject *item) { gaobject *alias = (gaobject *)self; // Populate __parameters__ if needed. - if (alias->parameters == NULL) { - alias->parameters = _Py_make_parameters(alias->args); - if (alias->parameters == NULL) { - return NULL; - } + PyObject *parameters; + Py_BEGIN_CRITICAL_SECTION(self); + parameters = ga_parameters_lock_held(self); + Py_END_CRITICAL_SECTION(); + if (parameters == NULL) { + return NULL; } - PyObject *newargs = _Py_subs_parameters(self, alias->args, alias->parameters, item); + PyObject *newargs = _Py_subs_parameters(self, alias->args, parameters, item); + Py_DECREF(parameters); if (newargs == NULL) { return NULL; } @@ -843,6 +862,7 @@ static PyMemberDef ga_members[] = { static PyObject * ga_parameters_lock_held(PyObject *self) { + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self); gaobject *alias = (gaobject *)self; if (alias->parameters == NULL) { alias->parameters = _Py_make_parameters(alias->args); @@ -939,17 +959,22 @@ static PyObject * ga_iternext(PyObject *op) { gaiterobject *gi = (gaiterobject*)op; - if (gi->obj == NULL) { + PyObject *obj; + Py_BEGIN_CRITICAL_SECTION(gi); + obj = gi->obj; + gi->obj = NULL; + Py_END_CRITICAL_SECTION(); + if (obj == NULL) { PyErr_SetNone(PyExc_StopIteration); return NULL; } - gaobject *alias = (gaobject *)gi->obj; + gaobject *alias = (gaobject *)obj; PyObject *starred_alias = Py_GenericAlias(alias->origin, alias->args); + Py_DECREF(obj); if (starred_alias == NULL) { return NULL; } ((gaobject *)starred_alias)->starred = true; - Py_SETREF(gi->obj, NULL); return starred_alias; } @@ -988,10 +1013,19 @@ ga_iter_reduce(PyObject *self, PyObject *Py_UNUSED(ignored)) * call must be before access of iterator pointers. * see issue #101765 */ - if (gi->obj) - return Py_BuildValue("N(O)", iter, gi->obj); - else + PyObject *obj; + Py_BEGIN_CRITICAL_SECTION(gi); + obj = Py_XNewRef(gi->obj); + Py_END_CRITICAL_SECTION(); + + if (obj) { + PyObject *result = Py_BuildValue("N(O)", iter, obj); + Py_DECREF(obj); + return result; + } + else { return Py_BuildValue("N(())", iter); + } } static PyMethodDef ga_iter_methods[] = { diff --git a/Objects/genobject.c b/Objects/genobject.c index 3cdc06733363d3e..82a1bb1ff420682 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -170,7 +170,9 @@ gen_clear_frame(PyGenObject *gen) _PyInterpreterFrame *frame = &gen->gi_iframe; _PyThreadState_UpdateLastProfiledFrame(_PyThreadState_GET(), frame, frame->previous); frame->previous = NULL; + Py_BEGIN_CRITICAL_SECTION(gen); _PyFrame_ClearExceptCode(frame); + Py_END_CRITICAL_SECTION(); _PyErr_ClearExcState(&gen->gi_exc_state); } @@ -542,8 +544,8 @@ gen_close(PyObject *self, PyObject *args) // Set an exception for a gen.throw() call. // Return 0 on success, -1 on failure. -static int -gen_set_exception(PyObject *typ, PyObject *val, PyObject *tb) +int +_PyGen_SetException(PyObject *typ, PyObject *val, PyObject *tb) { /* First, check the traceback argument, replacing None with NULL. */ @@ -640,7 +642,7 @@ _gen_throw(PyGenObject *gen, int close_on_genexit, "cannot reuse already awaited coroutine"); return NULL; } - gen_set_exception(typ, val, tb); + _PyGen_SetException(typ, val, tb); return NULL; } @@ -718,7 +720,7 @@ _gen_throw(PyGenObject *gen, int close_on_genexit, throw_here: assert(FT_ATOMIC_LOAD_INT8_RELAXED(gen->gi_frame_state) == FRAME_EXECUTING); - if (gen_set_exception(typ, val, tb) < 0) { + if (_PyGen_SetException(typ, val, tb) < 0) { FT_ATOMIC_STORE_INT8_RELEASE(gen->gi_frame_state, frame_state); return NULL; } @@ -960,8 +962,17 @@ _gen_getframe(PyGenObject *gen, const char *const name) if (FRAME_STATE_FINISHED(frame_state)) { Py_RETURN_NONE; } - // TODO: still not thread-safe with free threading - return _Py_XNewRef((PyObject *)_PyFrame_GetFrameObject(&gen->gi_iframe)); + PyObject *frame = NULL; + Py_BEGIN_CRITICAL_SECTION(gen); + frame_state = FT_ATOMIC_LOAD_INT8_RELAXED(gen->gi_frame_state); + if (FRAME_STATE_FINISHED(frame_state)) { + frame = Py_None; + } + else { + frame = _Py_XNewRef((PyObject *)_PyFrame_GetFrameObject(&gen->gi_iframe)); + } + Py_END_CRITICAL_SECTION(); + return frame; } static PyObject * @@ -1106,10 +1117,12 @@ make_gen(PyTypeObject *type, PyFunctionObject *func) gen->gi_exc_state.exc_value = NULL; gen->gi_exc_state.previous_item = NULL; gen->gi_iframe.f_executable = PyStackRef_None; - assert(func->func_name != NULL); - gen->gi_name = Py_NewRef(func->func_name); - assert(func->func_qualname != NULL); - gen->gi_qualname = Py_NewRef(func->func_qualname); + PyObject *name = FT_ATOMIC_LOAD_PTR_ACQUIRE(func->func_name); + assert(name != NULL); + gen->gi_name = Py_NewRef(name); + PyObject *qualname = FT_ATOMIC_LOAD_PTR_ACQUIRE(func->func_qualname); + assert(qualname != NULL); + gen->gi_qualname = Py_NewRef(qualname); _PyObject_GC_TRACK(gen); return (PyObject *)gen; } @@ -1604,6 +1617,44 @@ typedef enum { AWAITABLE_STATE_CLOSED, /* closed */ } AwaitableState; +#ifdef Py_GIL_DISABLED +static bool +async_gen_try_set_state(int8_t *state, int8_t *expected, int8_t new_state) +{ + return _Py_atomic_compare_exchange_int8(state, expected, new_state); +} + +# define _Py_ASYNC_GEN_TRY_SET_STATE(state, expected, new_state) \ + async_gen_try_set_state(&(state), &(expected), (new_state)) +#else +# define _Py_ASYNC_GEN_TRY_SET_STATE(state, expected, new_state) \ + ((state) = (new_state), true) +#endif + +// Try to transition the async generator to the running state. +// Returns false if it is already running. +// +// There are two ways to concurrently iterate an async generator: by +// sharing a single asend()/athrow() object across threads, or with +// multiple asend()/athrow() objects sending to the same generator. +// The CAS on ags_state/agt_state handles the first case; the CAS on +// ag_running_async here handles the second. +static bool +async_gen_try_claim_running(PyAsyncGenObject *agen) +{ +#ifdef Py_GIL_DISABLED + int8_t expected = 0; + return _Py_atomic_compare_exchange_int8(&agen->ag_running_async, + &expected, 1); +#else + if (agen->ag_running_async) { + return false; + } + agen->ag_running_async = 1; + return true; +#endif +} + typedef struct PyAsyncGenASend { PyObject_HEAD @@ -1613,7 +1664,7 @@ typedef struct PyAsyncGenASend { (equivalent of "asend(None)") */ PyObject *ags_sendval; - AwaitableState ags_state; + int8_t ags_state; } PyAsyncGenASend; #define _PyAsyncGenASend_CAST(op) \ @@ -1630,7 +1681,7 @@ typedef struct PyAsyncGenAThrow { PyObject *agt_tb; PyObject *agt_val; - AwaitableState agt_state; + int8_t agt_state; } PyAsyncGenAThrow; @@ -1672,11 +1723,17 @@ async_gen_init_hooks(PyAsyncGenObject *o) PyObject *finalizer; PyObject *firstiter; +#ifdef Py_GIL_DISABLED + if (_Py_atomic_exchange_int8(&o->ag_hooks_inited, 1)) { + return 0; + } +#else if (o->ag_hooks_inited) { return 0; } o->ag_hooks_inited = 1; +#endif tstate = _PyThreadState_GET(); @@ -1908,8 +1965,10 @@ PyAsyncGen_New(PyFrameObject *f, PyObject *name, PyObject *qualname) return (PyObject*)ag; } -static PyObject * -async_gen_unwrap_value(PyAsyncGenObject *gen, PyObject *result) +// Report an async yield as PYGEN_RETURN with the yielded value. +static PySendResult +async_gen_unwrap_send(PyAsyncGenObject *gen, PyObject *result, + PyObject **presult) { if (result == NULL) { if (!PyErr_Occurred()) { @@ -1919,22 +1978,34 @@ async_gen_unwrap_value(PyAsyncGenObject *gen, PyObject *result) if (PyErr_ExceptionMatches(PyExc_StopAsyncIteration) || PyErr_ExceptionMatches(PyExc_GeneratorExit) ) { - gen->ag_closed = 1; + FT_ATOMIC_STORE_INT8_RELAXED(gen->ag_closed, 1); } - gen->ag_running_async = 0; - return NULL; + *presult = NULL; + return PYGEN_ERROR; } if (_PyAsyncGenWrappedValue_CheckExact(result)) { /* async yield */ - _PyGen_SetStopIterationValue(((_PyAsyncGenWrappedValue*)result)->agw_val); + *presult = Py_NewRef(((_PyAsyncGenWrappedValue*)result)->agw_val); Py_DECREF(result); - gen->ag_running_async = 0; - return NULL; + return PYGEN_RETURN; } - return result; + *presult = result; + return PYGEN_NEXT; +} + +static PyObject * +async_gen_unwrap_value(PyAsyncGenObject *gen, PyObject *result) +{ + PyObject *value; + if (async_gen_unwrap_send(gen, result, &value) == PYGEN_RETURN) { + _PyGen_SetStopIterationValue(value); + Py_DECREF(value); + return NULL; + } + return value; } @@ -1947,7 +2018,10 @@ async_gen_asend_dealloc(PyObject *self) assert(PyAsyncGenASend_CheckExact(self)); PyAsyncGenASend *ags = _PyAsyncGenASend_CAST(self); - if (PyObject_CallFinalizerFromDealloc(self)) { + // The finalizer only warns about an asend() that was never awaited. + if (ags->ags_state == AWAITABLE_STATE_INIT + && PyObject_CallFinalizerFromDealloc(self)) + { return; } @@ -1970,54 +2044,66 @@ async_gen_asend_traverse(PyObject *self, visitproc visit, void *arg) } -static PyObject * -async_gen_asend_send(PyObject *self, PyObject *arg) +PySendResult +_PyAsyncGenASend_Send(PyObject *self, PyObject *arg, PyObject **presult) { PyAsyncGenASend *o = _PyAsyncGenASend_CAST(self); - if (o->ags_state == AWAITABLE_STATE_CLOSED) { - PyErr_SetString( - PyExc_RuntimeError, - "cannot reuse already awaited __anext__()/asend()"); - return NULL; - } - if (o->ags_state == AWAITABLE_STATE_INIT) { - if (o->ags_gen->ag_running_async) { - o->ags_state = AWAITABLE_STATE_CLOSED; + *presult = NULL; + int8_t state = FT_ATOMIC_LOAD_INT8_RELAXED(o->ags_state); + do { + if (state == AWAITABLE_STATE_CLOSED) { PyErr_SetString( PyExc_RuntimeError, - "anext(): asynchronous generator is already running"); - return NULL; + "cannot reuse already awaited __anext__()/asend()"); + return PYGEN_ERROR; } - - if (arg == NULL || arg == Py_None) { - arg = o->ags_sendval; + if (state == AWAITABLE_STATE_ITER) { + goto do_send; } - o->ags_state = AWAITABLE_STATE_ITER; + assert(state == AWAITABLE_STATE_INIT); + } while (!_Py_ASYNC_GEN_TRY_SET_STATE(o->ags_state, state, + AWAITABLE_STATE_ITER)); + + // The transition above only guards this object, the generator may + // still be running through another asend()/athrow() object so + // try to claim it before running. + if (!async_gen_try_claim_running(o->ags_gen)) { + FT_ATOMIC_STORE_INT8_RELAXED(o->ags_state, AWAITABLE_STATE_CLOSED); + PyErr_SetString( + PyExc_RuntimeError, + "anext(): asynchronous generator is already running"); + return PYGEN_ERROR; } - o->ags_gen->ag_running_async = 1; - PyObject *result = gen_send((PyObject*)o->ags_gen, arg); - result = async_gen_unwrap_value(o->ags_gen, result); + if (arg == NULL || arg == Py_None) { + arg = o->ags_sendval; + } - if (result == NULL) { - o->ags_state = AWAITABLE_STATE_CLOSED; + PyObject *result; + PySendResult res; +do_send: + result = gen_send((PyObject*)o->ags_gen, arg); + res = async_gen_unwrap_send(o->ags_gen, result, presult); + + if (res != PYGEN_NEXT) { + FT_ATOMIC_STORE_INT8_RELAXED(o->ags_state, AWAITABLE_STATE_CLOSED); + FT_ATOMIC_STORE_INT8_RELEASE(o->ags_gen->ag_running_async, 0); } - return result; + return res; } -PySendResult -_PyAsyncGenASend_Send(PyObject *iter, PyObject *arg, PyObject **result) +static PyObject * +async_gen_asend_send(PyObject *self, PyObject *arg) { - *result = async_gen_asend_send(iter, arg); - if (*result != NULL) { - return PYGEN_NEXT; - } - if (_PyGen_FetchStopIterationValue(result) == 0) { - return PYGEN_RETURN; + PyObject *result; + if (_PyAsyncGenASend_Send(self, arg, &result) == PYGEN_RETURN) { + _PyGen_SetStopIterationValue(result); + Py_DECREF(result); + return NULL; } - return PYGEN_ERROR; + return result; } @@ -2033,32 +2119,40 @@ async_gen_asend_throw(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyAsyncGenASend *o = _PyAsyncGenASend_CAST(self); - if (o->ags_state == AWAITABLE_STATE_CLOSED) { - PyErr_SetString( - PyExc_RuntimeError, - "cannot reuse already awaited __anext__()/asend()"); - return NULL; - } - - if (o->ags_state == AWAITABLE_STATE_INIT) { - if (o->ags_gen->ag_running_async) { - o->ags_state = AWAITABLE_STATE_CLOSED; + int8_t state = FT_ATOMIC_LOAD_INT8_RELAXED(o->ags_state); + do { + if (state == AWAITABLE_STATE_CLOSED) { PyErr_SetString( PyExc_RuntimeError, - "anext(): asynchronous generator is already running"); + "cannot reuse already awaited __anext__()/asend()"); return NULL; } - - o->ags_state = AWAITABLE_STATE_ITER; - o->ags_gen->ag_running_async = 1; + if (state == AWAITABLE_STATE_ITER) { + goto do_throw; + } + assert(state == AWAITABLE_STATE_INIT); + } while (!_Py_ASYNC_GEN_TRY_SET_STATE(o->ags_state, state, + AWAITABLE_STATE_ITER)); + + // The transition above only guards this object, the generator may + // still be running through another asend()/athrow() object so + // try to claim it before running. + if (!async_gen_try_claim_running(o->ags_gen)) { + FT_ATOMIC_STORE_INT8_RELAXED(o->ags_state, AWAITABLE_STATE_CLOSED); + PyErr_SetString( + PyExc_RuntimeError, + "anext(): asynchronous generator is already running"); + return NULL; } - PyObject *result = gen_throw((PyObject*)o->ags_gen, args, nargs); + PyObject *result; +do_throw: + result = gen_throw((PyObject*)o->ags_gen, args, nargs); result = async_gen_unwrap_value(o->ags_gen, result); if (result == NULL) { - o->ags_gen->ag_running_async = 0; - o->ags_state = AWAITABLE_STATE_CLOSED; + FT_ATOMIC_STORE_INT8_RELAXED(o->ags_state, AWAITABLE_STATE_CLOSED); + FT_ATOMIC_STORE_INT8_RELEASE(o->ags_gen->ag_running_async, 0); } return result; @@ -2069,7 +2163,7 @@ static PyObject * async_gen_asend_close(PyObject *self, PyObject *args) { PyAsyncGenASend *o = _PyAsyncGenASend_CAST(self); - if (o->ags_state == AWAITABLE_STATE_CLOSED) { + if (FT_ATOMIC_LOAD_INT8_RELAXED(o->ags_state) == AWAITABLE_STATE_CLOSED) { Py_RETURN_NONE; } @@ -2094,11 +2188,17 @@ static void async_gen_asend_finalize(PyObject *self) { PyAsyncGenASend *ags = _PyAsyncGenASend_CAST(self); + // async_gen_asend_dealloc() calls this only in the INIT state. if (ags->ags_state == AWAITABLE_STATE_INIT) { _PyErr_WarnUnawaitedAgenMethod(ags->ags_gen, &_Py_ID(asend)); } } +static PyMemberDef async_gen_asend_memberlist[] = { + {"aga_gen", Py_T_OBJECT_EX, offsetof(PyAsyncGenASend, ags_gen), Py_READONLY}, + {NULL} /* Sentinel */ +}; + static PyMethodDef async_gen_asend_methods[] = { {"send", async_gen_asend_send, METH_O, send_doc}, {"throw", _PyCFunction_CAST(async_gen_asend_throw), METH_FASTCALL, throw_doc}, @@ -2143,7 +2243,7 @@ PyTypeObject _PyAsyncGenASend_Type = { PyObject_SelfIter, /* tp_iter */ async_gen_asend_iternext, /* tp_iternext */ async_gen_asend_methods, /* tp_methods */ - 0, /* tp_members */ + async_gen_asend_memberlist, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ @@ -2304,80 +2404,100 @@ async_gen_athrow_send(PyObject *self, PyObject *arg) PyGenObject *gen = _PyGen_CAST(o->agt_gen); PyObject *retval; - if (o->agt_state == AWAITABLE_STATE_CLOSED) { + int8_t state = FT_ATOMIC_LOAD_INT8_RELAXED(o->agt_state); + if (state == AWAITABLE_STATE_CLOSED) { PyErr_SetString( PyExc_RuntimeError, "cannot reuse already awaited aclose()/athrow()"); return NULL; } - if (FRAME_STATE_FINISHED(gen->gi_frame_state)) { - o->agt_state = AWAITABLE_STATE_CLOSED; + if (FRAME_STATE_FINISHED(FT_ATOMIC_LOAD_INT8_RELAXED(gen->gi_frame_state))) { + // Close the awaitable, unless another thread transitioned it + // to a different state in the meantime. + (void)_Py_ASYNC_GEN_TRY_SET_STATE(o->agt_state, state, + AWAITABLE_STATE_CLOSED); PyErr_SetNone(PyExc_StopIteration); return NULL; } - if (o->agt_state == AWAITABLE_STATE_INIT) { - if (o->agt_gen->ag_running_async) { - o->agt_state = AWAITABLE_STATE_CLOSED; - if (o->agt_typ == NULL) { - PyErr_SetString( - PyExc_RuntimeError, - "aclose(): asynchronous generator is already running"); - } - else { - PyErr_SetString( - PyExc_RuntimeError, - "athrow(): asynchronous generator is already running"); - } + do { + if (state == AWAITABLE_STATE_CLOSED) { + PyErr_SetString( + PyExc_RuntimeError, + "cannot reuse already awaited aclose()/athrow()"); return NULL; } - - if (o->agt_gen->ag_closed) { - o->agt_state = AWAITABLE_STATE_CLOSED; - PyErr_SetNone(PyExc_StopAsyncIteration); - return NULL; + if (state == AWAITABLE_STATE_ITER) { + goto do_send; } - + assert(state == AWAITABLE_STATE_INIT); if (arg != Py_None) { PyErr_SetString(PyExc_RuntimeError, NON_INIT_CORO_MSG); return NULL; } + } while (!_Py_ASYNC_GEN_TRY_SET_STATE(o->agt_state, state, + AWAITABLE_STATE_ITER)); + + // The transition above only guards this object, the generator may + // still be running through another asend()/athrow() object so + // try to claim it before running. + if (!async_gen_try_claim_running(o->agt_gen)) { + FT_ATOMIC_STORE_INT8_RELAXED(o->agt_state, AWAITABLE_STATE_CLOSED); + if (o->agt_typ == NULL) { + PyErr_SetString( + PyExc_RuntimeError, + "aclose(): asynchronous generator is already running"); + } + else { + PyErr_SetString( + PyExc_RuntimeError, + "athrow(): asynchronous generator is already running"); + } + return NULL; + } - o->agt_state = AWAITABLE_STATE_ITER; - o->agt_gen->ag_running_async = 1; + if (FT_ATOMIC_LOAD_INT8_RELAXED(o->agt_gen->ag_closed)) { + FT_ATOMIC_STORE_INT8_RELAXED(o->agt_state, AWAITABLE_STATE_CLOSED); + FT_ATOMIC_STORE_INT8_RELEASE(o->agt_gen->ag_running_async, 0); + PyErr_SetNone(PyExc_StopAsyncIteration); + return NULL; + } - if (o->agt_typ == NULL) { - /* aclose() mode */ - o->agt_gen->ag_closed = 1; + if (o->agt_typ == NULL) { + /* aclose() mode */ + FT_ATOMIC_STORE_INT8_RELAXED(o->agt_gen->ag_closed, 1); - retval = _gen_throw((PyGenObject *)gen, - 0, /* Do not close generator when - PyExc_GeneratorExit is passed */ - PyExc_GeneratorExit, NULL, NULL); + retval = _gen_throw((PyGenObject *)gen, + 0, /* Do not close generator when + PyExc_GeneratorExit is passed */ + PyExc_GeneratorExit, NULL, NULL); - if (retval && _PyAsyncGenWrappedValue_CheckExact(retval)) { - Py_DECREF(retval); - goto yield_close; - } - } else { - retval = _gen_throw((PyGenObject *)gen, - 0, /* Do not close generator when - PyExc_GeneratorExit is passed */ - o->agt_typ, o->agt_val, o->agt_tb); - retval = async_gen_unwrap_value(o->agt_gen, retval); - } - if (retval == NULL) { - goto check_error; + if (retval && _PyAsyncGenWrappedValue_CheckExact(retval)) { + Py_DECREF(retval); + goto yield_close; } - return retval; + } else { + retval = _gen_throw((PyGenObject *)gen, + 0, /* Do not close generator when + PyExc_GeneratorExit is passed */ + o->agt_typ, o->agt_val, o->agt_tb); + retval = async_gen_unwrap_value(o->agt_gen, retval); } + if (retval == NULL) { + goto check_error; + } + return retval; - assert(o->agt_state == AWAITABLE_STATE_ITER); - +do_send: retval = gen_send((PyObject *)gen, arg); if (o->agt_typ) { - return async_gen_unwrap_value(o->agt_gen, retval); + retval = async_gen_unwrap_value(o->agt_gen, retval); + if (retval == NULL) { + FT_ATOMIC_STORE_INT8_RELAXED(o->agt_state, AWAITABLE_STATE_CLOSED); + FT_ATOMIC_STORE_INT8_RELEASE(o->agt_gen->ag_running_async, 0); + } + return retval; } else { /* aclose() mode */ if (retval) { @@ -2395,15 +2515,15 @@ async_gen_athrow_send(PyObject *self, PyObject *arg) } yield_close: - o->agt_gen->ag_running_async = 0; - o->agt_state = AWAITABLE_STATE_CLOSED; + FT_ATOMIC_STORE_INT8_RELAXED(o->agt_state, AWAITABLE_STATE_CLOSED); + FT_ATOMIC_STORE_INT8_RELEASE(o->agt_gen->ag_running_async, 0); PyErr_SetString( PyExc_RuntimeError, ASYNC_GEN_IGNORED_EXIT_MSG); return NULL; check_error: - o->agt_gen->ag_running_async = 0; - o->agt_state = AWAITABLE_STATE_CLOSED; + FT_ATOMIC_STORE_INT8_RELAXED(o->agt_state, AWAITABLE_STATE_CLOSED); + FT_ATOMIC_STORE_INT8_RELEASE(o->agt_gen->ag_running_async, 0); if (PyErr_ExceptionMatches(PyExc_StopAsyncIteration) || PyErr_ExceptionMatches(PyExc_GeneratorExit)) { @@ -2426,54 +2546,62 @@ async_gen_athrow_throw(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { PyAsyncGenAThrow *o = _PyAsyncGenAThrow_CAST(self); - if (o->agt_state == AWAITABLE_STATE_CLOSED) { - PyErr_SetString( - PyExc_RuntimeError, - "cannot reuse already awaited aclose()/athrow()"); - return NULL; - } - - if (o->agt_state == AWAITABLE_STATE_INIT) { - if (o->agt_gen->ag_running_async) { - o->agt_state = AWAITABLE_STATE_CLOSED; - if (o->agt_typ == NULL) { - PyErr_SetString( - PyExc_RuntimeError, - "aclose(): asynchronous generator is already running"); - } - else { - PyErr_SetString( - PyExc_RuntimeError, - "athrow(): asynchronous generator is already running"); - } + int8_t state = FT_ATOMIC_LOAD_INT8_RELAXED(o->agt_state); + do { + if (state == AWAITABLE_STATE_CLOSED) { + PyErr_SetString( + PyExc_RuntimeError, + "cannot reuse already awaited aclose()/athrow()"); return NULL; } - - o->agt_state = AWAITABLE_STATE_ITER; - o->agt_gen->ag_running_async = 1; + if (state == AWAITABLE_STATE_ITER) { + goto do_throw; + } + assert(state == AWAITABLE_STATE_INIT); + } while (!_Py_ASYNC_GEN_TRY_SET_STATE(o->agt_state, state, + AWAITABLE_STATE_ITER)); + + // The transition above only guards this object, the generator may + // still be running through another asend()/athrow() object so + // try to claim it before running. + if (!async_gen_try_claim_running(o->agt_gen)) { + FT_ATOMIC_STORE_INT8_RELAXED(o->agt_state, AWAITABLE_STATE_CLOSED); + if (o->agt_typ == NULL) { + PyErr_SetString( + PyExc_RuntimeError, + "aclose(): asynchronous generator is already running"); + } + else { + PyErr_SetString( + PyExc_RuntimeError, + "athrow(): asynchronous generator is already running"); + } + return NULL; } - PyObject *retval = gen_throw((PyObject*)o->agt_gen, args, nargs); + PyObject *retval; +do_throw: + retval = gen_throw((PyObject*)o->agt_gen, args, nargs); if (o->agt_typ) { retval = async_gen_unwrap_value(o->agt_gen, retval); if (retval == NULL) { - o->agt_gen->ag_running_async = 0; - o->agt_state = AWAITABLE_STATE_CLOSED; + FT_ATOMIC_STORE_INT8_RELAXED(o->agt_state, AWAITABLE_STATE_CLOSED); + FT_ATOMIC_STORE_INT8_RELEASE(o->agt_gen->ag_running_async, 0); } return retval; } else { /* aclose() mode */ if (retval && _PyAsyncGenWrappedValue_CheckExact(retval)) { - o->agt_gen->ag_running_async = 0; - o->agt_state = AWAITABLE_STATE_CLOSED; + FT_ATOMIC_STORE_INT8_RELAXED(o->agt_state, AWAITABLE_STATE_CLOSED); + FT_ATOMIC_STORE_INT8_RELEASE(o->agt_gen->ag_running_async, 0); Py_DECREF(retval); PyErr_SetString(PyExc_RuntimeError, ASYNC_GEN_IGNORED_EXIT_MSG); return NULL; } if (retval == NULL) { - o->agt_gen->ag_running_async = 0; - o->agt_state = AWAITABLE_STATE_CLOSED; + FT_ATOMIC_STORE_INT8_RELAXED(o->agt_state, AWAITABLE_STATE_CLOSED); + FT_ATOMIC_STORE_INT8_RELEASE(o->agt_gen->ag_running_async, 0); } if (PyErr_ExceptionMatches(PyExc_StopAsyncIteration) || PyErr_ExceptionMatches(PyExc_GeneratorExit)) @@ -2502,7 +2630,7 @@ static PyObject * async_gen_athrow_close(PyObject *self, PyObject *args) { PyAsyncGenAThrow *agt = _PyAsyncGenAThrow_CAST(self); - if (agt->agt_state == AWAITABLE_STATE_CLOSED) { + if (FT_ATOMIC_LOAD_INT8_RELAXED(agt->agt_state) == AWAITABLE_STATE_CLOSED) { Py_RETURN_NONE; } PyObject *result = async_gen_athrow_throw((PyObject*)agt, @@ -2534,6 +2662,11 @@ async_gen_athrow_finalize(PyObject *op) } } +static PyMemberDef async_gen_athrow_memberlist[] = { + {"aga_gen", Py_T_OBJECT_EX, offsetof(PyAsyncGenAThrow, agt_gen), Py_READONLY}, + {NULL} /* Sentinel */ +}; + static PyMethodDef async_gen_athrow_methods[] = { {"send", async_gen_athrow_send, METH_O, send_doc}, {"throw", _PyCFunction_CAST(async_gen_athrow_throw), @@ -2581,7 +2714,7 @@ PyTypeObject _PyAsyncGenAThrow_Type = { PyObject_SelfIter, /* tp_iter */ async_gen_athrow_iternext, /* tp_iternext */ async_gen_athrow_methods, /* tp_methods */ - 0, /* tp_members */ + async_gen_athrow_memberlist, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ diff --git a/Objects/interpolationobject.c b/Objects/interpolationobject.c index e37724fb7852a27..96fabcf201bb971 100644 --- a/Objects/interpolationobject.c +++ b/Objects/interpolationobject.c @@ -50,6 +50,7 @@ typedef struct { (assert(_PyInterpolation_CheckExact(op)), _Py_CAST(interpolationobject*, (op))) /*[clinic input] +@vectorcall @classmethod Interpolation.__new__ as interpolation_new @@ -63,7 +64,7 @@ static PyObject * interpolation_new_impl(PyTypeObject *type, PyObject *value, PyObject *expression, PyObject *conversion, PyObject *format_spec) -/*[clinic end generated code: output=6488e288765bc1a9 input=fc5c285c1dd23d36]*/ +/*[clinic end generated code: output=6488e288765bc1a9 input=de7e890ea8f801e5]*/ { interpolationobject *self = PyObject_GC_New(interpolationobject, type); if (!self) { @@ -150,6 +151,7 @@ PyTypeObject _PyInterpolation_Type = { .tp_itemsize = 0, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, .tp_new = interpolation_new, + .tp_vectorcall = interpolation_vectorcall, .tp_alloc = PyType_GenericAlloc, .tp_dealloc = interpolation_dealloc, .tp_clear = interpolation_clear, diff --git a/Objects/iterobject.c b/Objects/iterobject.c index e323987601d5d4c..683683ceaa6600c 100644 --- a/Objects/iterobject.c +++ b/Objects/iterobject.c @@ -5,13 +5,18 @@ #include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_ceval.h" // _PyEval_GetBuiltin() #include "pycore_genobject.h" // _PyCoro_GetAwaitableIter() +#include "pycore_iterobject.h" // _PyCallIter_NewEx() #include "pycore_object.h" // _PyObject_GC_TRACK() +#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_SSIZE_RELAXED() +#include "pycore_pyerrors.h" // _PyErr_FormatFromCause() +#include "pycore_pystate.h" // _PyThreadState_GET() typedef struct { PyObject_HEAD - Py_ssize_t it_index; - PyObject *it_seq; /* Set to NULL when iterator is exhausted */ + Py_ssize_t it_index; /* -1 when iterator is exhausted */ + PyObject *it_seq; /* Set to NULL when iterator is exhausted + (in the default build) */ } seqiterobject; PyObject * @@ -58,26 +63,41 @@ iter_iternext(PyObject *iterator) assert(PySeqIter_Check(iterator)); it = (seqiterobject *)iterator; + Py_ssize_t index = FT_ATOMIC_LOAD_SSIZE_RELAXED(it->it_index); + if (index < 0) + return NULL; seq = it->it_seq; +#ifndef Py_GIL_DISABLED if (seq == NULL) return NULL; - if (it->it_index == PY_SSIZE_T_MAX) { +#endif + if (index == PY_SSIZE_T_MAX) { PyErr_SetString(PyExc_OverflowError, "iter index too large"); return NULL; } - result = PySequence_GetItem(seq, it->it_index); + result = PySequence_GetItem(seq, index); if (result != NULL) { - it->it_index++; + /* PySequence_GetItem() can exhaust the iterator re-entrantly. + * Preserve the exhaustion sentinel if it is observed. Concurrent + * exhaustion can still race with the store, but remains memory-safe + * because the sequence stays alive. */ + if (FT_ATOMIC_LOAD_SSIZE_RELAXED(it->it_index) >= 0) { + FT_ATOMIC_STORE_SSIZE_RELAXED(it->it_index, index + 1); + } return result; } if (PyErr_ExceptionMatches(PyExc_IndexError) || PyErr_ExceptionMatches(PyExc_StopIteration)) { + /* Mark the iterator exhausted before anything that can run + * arbitrary code. */ + FT_ATOMIC_STORE_SSIZE_RELAXED(it->it_index, -1); +#ifndef Py_GIL_DISABLED + Py_CLEAR(it->it_seq); +#endif PyErr_Clear(); - it->it_seq = NULL; - Py_DECREF(seq); } return NULL; } @@ -88,7 +108,8 @@ iter_len(PyObject *op, PyObject *Py_UNUSED(ignored)) seqiterobject *it = (seqiterobject*)op; Py_ssize_t seqsize, len; - if (it->it_seq) { + Py_ssize_t index = FT_ATOMIC_LOAD_SSIZE_RELAXED(it->it_index); + if (index >= 0 && it->it_seq != NULL) { if (_PyObject_HasLen(it->it_seq)) { seqsize = PySequence_Size(it->it_seq); if (seqsize == -1) @@ -97,7 +118,7 @@ iter_len(PyObject *op, PyObject *Py_UNUSED(ignored)) else { Py_RETURN_NOTIMPLEMENTED; } - len = seqsize - it->it_index; + len = seqsize - index; if (len >= 0) return PyLong_FromSsize_t(len); } @@ -116,8 +137,9 @@ iter_reduce(PyObject *op, PyObject *Py_UNUSED(ignored)) * call must be before access of iterator pointers. * see issue #101765 */ - if (it->it_seq != NULL) - return Py_BuildValue("N(O)n", iter, it->it_seq, it->it_index); + Py_ssize_t index = FT_ATOMIC_LOAD_SSIZE_RELAXED(it->it_index); + if (index >= 0 && it->it_seq != NULL) + return Py_BuildValue("N(O)n", iter, it->it_seq, index); else return Py_BuildValue("N(())", iter); } @@ -131,10 +153,10 @@ iter_setstate(PyObject *op, PyObject *state) Py_ssize_t index = PyLong_AsSsize_t(state); if (index == -1 && PyErr_Occurred()) return NULL; - if (it->it_seq != NULL) { - if (index < 0) - index = 0; - it->it_index = index; + if (index < 0) + index = 0; + if (it->it_seq && FT_ATOMIC_LOAD_SSIZE_RELAXED(it->it_index) >= 0) { + FT_ATOMIC_STORE_SSIZE_RELAXED(it->it_index, index); } Py_RETURN_NONE; } @@ -185,22 +207,66 @@ PyTypeObject PySeqIter_Type = { typedef struct { PyObject_HEAD - PyObject *it_callable; /* Set to NULL when iterator is exhausted */ - PyObject *it_sentinel; /* Set to NULL when iterator is exhausted */ + PyObject *it_callable; /* set to NULL when the iterator is exhausted */ + PyObject *it_sentinel; /* can be NULL, and is when exhausted */ + PyObject *it_stop_exc; /* never NULL */ } calliterobject; PyObject * -PyCallIter_New(PyObject *callable, PyObject *sentinel) +_PyCallIter_NewEx(PyObject *callable, PyObject *sentinel, PyObject *stop_exc) { calliterobject *it; + if (stop_exc == NULL) { + stop_exc = PyExc_StopIteration; + } + else if (_PyEval_CheckExceptTypeValid(_PyThreadState_GET(), stop_exc) < 0) { + return NULL; + } it = PyObject_GC_New(calliterobject, &PyCallIter_Type); if (it == NULL) return NULL; it->it_callable = Py_NewRef(callable); - it->it_sentinel = Py_NewRef(sentinel); + it->it_sentinel = Py_XNewRef(sentinel); + it->it_stop_exc = Py_NewRef(stop_exc); _PyObject_GC_TRACK(it); return (PyObject *)it; } + +PyObject * +PyCallIter_New(PyObject *callable, PyObject *sentinel) +{ + return _PyCallIter_NewEx(callable, sentinel, NULL); +} + +// Sharing a callable iterator between threads, or calling __setstate__() +// on an iterator that is in use, is not supported: the values produced are +// unspecified, but the interpreter must not crash. + +static inline PyObject * +calliter_swap(PyObject **field, PyObject *value) +{ +#ifdef Py_GIL_DISABLED + return _Py_atomic_exchange_ptr(field, value); +#else + PyObject *old = *field; + *field = value; + return old; +#endif +} + +static inline PyObject * +calliter_load(PyObject **field) +{ + return Py_XNewRef(FT_ATOMIC_LOAD_PTR_ACQUIRE(*field)); +} + +static void +calliter_exhaust(calliterobject *it) +{ + _PyObject_XDecRefDelayed(calliter_swap(&it->it_callable, NULL)); + _PyObject_XDecRefDelayed(calliter_swap(&it->it_sentinel, NULL)); +} + static void calliter_dealloc(PyObject *op) { @@ -208,6 +274,7 @@ calliter_dealloc(PyObject *op) _PyObject_GC_UNTRACK(it); Py_XDECREF(it->it_callable); Py_XDECREF(it->it_sentinel); + Py_XDECREF(it->it_stop_exc); PyObject_GC_Del(it); } @@ -217,6 +284,7 @@ calliter_traverse(PyObject *op, visitproc visit, void *arg) calliterobject *it = (calliterobject*)op; Py_VISIT(it->it_callable); Py_VISIT(it->it_sentinel); + Py_VISIT(it->it_stop_exc); return 0; } @@ -224,30 +292,47 @@ static PyObject * calliter_iternext(PyObject *op) { calliterobject *it = (calliterobject*)op; - PyObject *result; + PyObject *callable, *sentinel, *stop_exc, *result; - if (it->it_callable == NULL) { + callable = calliter_load(&it->it_callable); + if (callable == NULL) { return NULL; } + result = _PyObject_CallNoArgs(callable); + Py_DECREF(callable); - result = _PyObject_CallNoArgs(it->it_callable); - if (result != NULL && it->it_sentinel != NULL){ - int ok; - - ok = PyObject_RichCompareBool(it->it_sentinel, result, Py_EQ); + /* The call can exhaust the iterator re-entrantly. */ + if (result != NULL && + FT_ATOMIC_LOAD_PTR_RELAXED(it->it_callable) != NULL) + { + sentinel = calliter_load(&it->it_sentinel); + if (sentinel == NULL) { + return result; /* Common case, fast path */ + } + /* The comparison can run code that replaces the sentinel. */ + int ok = PyObject_RichCompareBool(sentinel, result, Py_EQ); + Py_DECREF(sentinel); if (ok == 0) { return result; /* Common case, fast path */ } if (ok > 0) { - Py_CLEAR(it->it_callable); - Py_CLEAR(it->it_sentinel); + calliter_exhaust(it); } } - else if (PyErr_ExceptionMatches(PyExc_StopIteration)) { - PyErr_Clear(); - Py_CLEAR(it->it_callable); - Py_CLEAR(it->it_sentinel); + else if (result == NULL) { + stop_exc = calliter_load(&it->it_stop_exc); + if (PyErr_ExceptionMatches(stop_exc)) { + PyErr_Clear(); + calliter_exhaust(it); + } + else if (PyErr_ExceptionMatches(PyExc_StopIteration)) { + /* It would be mistaken for the end of the iteration (see + PEP 479). */ + _PyErr_FormatFromCause(PyExc_RuntimeError, + "callable raised StopIteration"); + } + Py_DECREF(stop_exc); } Py_XDECREF(result); return NULL; @@ -263,249 +348,79 @@ calliter_reduce(PyObject *op, PyObject *Py_UNUSED(ignored)) * call must be before access of iterator pointers. * see issue #101765 */ - if (it->it_callable != NULL && it->it_sentinel != NULL) - return Py_BuildValue("N(OO)", iter, it->it_callable, it->it_sentinel); - else - return Py_BuildValue("N(())", iter); -} - -static PyMethodDef calliter_methods[] = { - {"__reduce__", calliter_reduce, METH_NOARGS, reduce_doc}, - {NULL, NULL} /* sentinel */ -}; - -PyTypeObject PyCallIter_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) - "callable_iterator", /* tp_name */ - sizeof(calliterobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - calliter_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_as_async */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - 0, /* tp_doc */ - calliter_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - calliter_iternext, /* tp_iternext */ - calliter_methods, /* tp_methods */ -}; - - -/* -------------------------------------- */ - -typedef struct { - PyObject_HEAD - PyObject *wrapped; - PyObject *default_value; -} anextawaitableobject; - -#define anextawaitableobject_CAST(op) ((anextawaitableobject *)(op)) - -static void -anextawaitable_dealloc(PyObject *op) -{ - anextawaitableobject *obj = anextawaitableobject_CAST(op); - _PyObject_GC_UNTRACK(obj); - Py_XDECREF(obj->wrapped); - Py_XDECREF(obj->default_value); - PyObject_GC_Del(obj); -} - -static int -anextawaitable_traverse(PyObject *op, visitproc visit, void *arg) -{ - anextawaitableobject *obj = anextawaitableobject_CAST(op); - Py_VISIT(obj->wrapped); - Py_VISIT(obj->default_value); - return 0; -} - -static PyObject * -anextawaitable_getiter(anextawaitableobject *obj) -{ - assert(obj->wrapped != NULL); - PyObject *awaitable = _PyCoro_GetAwaitableIter(obj->wrapped); - if (awaitable == NULL) { - return NULL; + PyObject *callable = calliter_load(&it->it_callable); + PyObject *sentinel = calliter_load(&it->it_sentinel); + PyObject *stop_exc = calliter_load(&it->it_stop_exc); + PyObject *res; + if (callable == NULL) { + res = Py_BuildValue("N(())", iter); } - if (Py_TYPE(awaitable)->tp_iternext == NULL) { - /* _PyCoro_GetAwaitableIter returns a Coroutine, a Generator, - * or an iterator. Of these, only coroutines lack tp_iternext. - */ - assert(PyCoro_CheckExact(awaitable)); - unaryfunc getter = Py_TYPE(awaitable)->tp_as_async->am_await; - PyObject *new_awaitable = getter(awaitable); - if (new_awaitable == NULL) { - Py_DECREF(awaitable); - return NULL; - } - Py_SETREF(awaitable, new_awaitable); - if (!PyIter_Check(awaitable)) { - PyErr_Format(PyExc_TypeError, - "%T.__await__() must return an iterable, not %T", - obj, awaitable); - Py_DECREF(awaitable); - return NULL; - } + /* Only the sentinel can be passed as an argument of iter(), so other + attributes are restored from the state (see calliter_setstate()). */ + else if (sentinel == NULL) { + res = Py_BuildValue("N(OO)(()O)", iter, callable, Py_None, stop_exc); } - return awaitable; -} - -static PyObject * -anextawaitable_iternext(PyObject *op) -{ - /* Consider the following class: - * - * class A: - * async def __anext__(self): - * ... - * a = A() - * - * Then `await anext(a)` should call - * a.__anext__().__await__().__next__() - * - * On the other hand, given - * - * async def agen(): - * yield 1 - * yield 2 - * gen = agen() - * - * Then `await anext(gen)` can just call - * gen.__anext__().__next__() - */ - anextawaitableobject *obj = anextawaitableobject_CAST(op); - PyObject *awaitable = anextawaitable_getiter(obj); - if (awaitable == NULL) { - return NULL; + else if (stop_exc == PyExc_StopIteration) { + res = Py_BuildValue("N(OO)", iter, callable, sentinel); } - PyObject *result = (*Py_TYPE(awaitable)->tp_iternext)(awaitable); - Py_DECREF(awaitable); - if (result != NULL) { - return result; - } - if (PyErr_ExceptionMatches(PyExc_StopAsyncIteration)) { - PyErr_Clear(); - _PyGen_SetStopIterationValue(obj->default_value); + else { + res = Py_BuildValue("N(OO)((O)O)", iter, callable, Py_None, + sentinel, stop_exc); } - return NULL; + Py_XDECREF(callable); + Py_XDECREF(sentinel); + Py_DECREF(stop_exc); + return res; } - static PyObject * -anextawaitable_proxy(anextawaitableobject *obj, char *meth, PyObject *arg) +calliter_setstate(PyObject *op, PyObject *state) { - PyObject *awaitable = anextawaitable_getiter(obj); - if (awaitable == NULL) { - return NULL; + calliterobject *it = (calliterobject*)op; + PyObject *sentinel, *stop_exc; + + if (!PyTuple_Check(state) || PyTuple_GET_SIZE(state) != 2) { + goto error; } - // When specified, 'arg' may be a tuple (if coming from a METH_VARARGS - // method) or a single object (if coming from a METH_O method). - PyObject *ret = arg == NULL - ? PyObject_CallMethod(awaitable, meth, NULL) - : PyObject_CallMethod(awaitable, meth, "O", arg); - Py_DECREF(awaitable); - if (ret != NULL) { - return ret; + sentinel = PyTuple_GET_ITEM(state, 0); + stop_exc = PyTuple_GET_ITEM(state, 1); + if (!PyTuple_Check(sentinel) || PyTuple_GET_SIZE(sentinel) > 1) { + goto error; } - if (PyErr_ExceptionMatches(PyExc_StopAsyncIteration)) { - /* `anextawaitableobject` is only used by `anext()` when - * a default value is provided. So when we have a StopAsyncIteration - * exception we replace it with a `StopIteration(default)`, as if - * it was the return value of `__anext__()` coroutine. - */ - PyErr_Clear(); - _PyGen_SetStopIterationValue(obj->default_value); + if (_PyEval_CheckExceptTypeValid(_PyThreadState_GET(), stop_exc) < 0) { + return NULL; } - return NULL; -} - - -static PyObject * -anextawaitable_send(PyObject *op, PyObject *arg) -{ - anextawaitableobject *obj = anextawaitableobject_CAST(op); - return anextawaitable_proxy(obj, "send", arg); -} - - -static PyObject * -anextawaitable_throw(PyObject *op, PyObject *args) -{ - anextawaitableobject *obj = anextawaitableobject_CAST(op); - return anextawaitable_proxy(obj, "throw", args); -} - + if (FT_ATOMIC_LOAD_PTR_RELAXED(it->it_callable) != NULL) { + PyObject *value = PyTuple_GET_SIZE(sentinel) ? + Py_NewRef(PyTuple_GET_ITEM(sentinel, 0)) : NULL; + _PyObject_XDecRefDelayed(calliter_swap(&it->it_sentinel, value)); + _PyObject_XDecRefDelayed(calliter_swap(&it->it_stop_exc, + Py_NewRef(stop_exc))); + } + Py_RETURN_NONE; -static PyObject * -anextawaitable_close(PyObject *op, PyObject *Py_UNUSED(dummy)) -{ - anextawaitableobject *obj = anextawaitableobject_CAST(op); - return anextawaitable_proxy(obj, "close", NULL); +error: + PyErr_SetString(PyExc_TypeError, "invalid state for callable_iterator"); + return NULL; } - -PyDoc_STRVAR(send_doc, -"send(arg) -> send 'arg' into the wrapped iterator,\n\ -return next yielded value or raise StopIteration."); - - -PyDoc_STRVAR(throw_doc, -"throw(value)\n\ -throw(typ[,val[,tb]])\n\ -\n\ -raise exception in the wrapped iterator, return next yielded value\n\ -or raise StopIteration.\n\ -the (type, val, tb) signature is deprecated, \n\ -and may be removed in a future version of Python."); - - -PyDoc_STRVAR(close_doc, -"close() -> raise GeneratorExit inside generator."); - - -static PyMethodDef anextawaitable_methods[] = { - {"send", anextawaitable_send, METH_O, send_doc}, - {"throw", anextawaitable_throw, METH_VARARGS, throw_doc}, - {"close", anextawaitable_close, METH_NOARGS, close_doc}, - {NULL, NULL} /* Sentinel */ -}; - - -static PyAsyncMethods anextawaitable_as_async = { - PyObject_SelfIter, /* am_await */ - 0, /* am_aiter */ - 0, /* am_anext */ - 0, /* am_send */ +static PyMethodDef calliter_methods[] = { + {"__reduce__", calliter_reduce, METH_NOARGS, reduce_doc}, + {"__setstate__", calliter_setstate, METH_O, setstate_doc}, + {NULL, NULL} /* sentinel */ }; -PyTypeObject _PyAnextAwaitable_Type = { +PyTypeObject PyCallIter_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "anext_awaitable", /* tp_name */ - sizeof(anextawaitableobject), /* tp_basicsize */ + "callable_iterator", /* tp_name */ + sizeof(calliterobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - anextawaitable_dealloc, /* tp_dealloc */ + calliter_dealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ - &anextawaitable_as_async, /* tp_as_async */ + 0, /* tp_as_async */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -518,25 +433,11 @@ PyTypeObject _PyAnextAwaitable_Type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ 0, /* tp_doc */ - anextawaitable_traverse, /* tp_traverse */ + calliter_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ PyObject_SelfIter, /* tp_iter */ - anextawaitable_iternext, /* tp_iternext */ - anextawaitable_methods, /* tp_methods */ + calliter_iternext, /* tp_iternext */ + calliter_methods, /* tp_methods */ }; - -PyObject * -PyAnextAwaitable_New(PyObject *awaitable, PyObject *default_value) -{ - anextawaitableobject *anext = PyObject_GC_New( - anextawaitableobject, &_PyAnextAwaitable_Type); - if (anext == NULL) { - return NULL; - } - anext->wrapped = Py_NewRef(awaitable); - anext->default_value = Py_NewRef(default_value); - _PyObject_GC_TRACK(anext); - return (PyObject *)anext; -} diff --git a/Objects/lazyimportobject.c b/Objects/lazyimportobject.c index fa1eb25047d9617..aafd2ce764a1cbc 100644 --- a/Objects/lazyimportobject.c +++ b/Objects/lazyimportobject.c @@ -2,20 +2,44 @@ #include "Python.h" #include "pycore_ceval.h" -#include "pycore_frame.h" +#include "pycore_dict.h" +#include "pycore_gc.h" #include "pycore_import.h" #include "pycore_interpframe.h" #include "pycore_lazyimportobject.h" -#include "pycore_modsupport.h" +#include "pycore_long.h" +#include "pycore_moduleobject.h" +#include "pycore_pyatomic_ft_wrappers.h" +#include "pycore_pyerrors.h" +#include "pycore_traceback.h" +#include "pycore_tstate.h" + +typedef struct { + PyObject_HEAD + PyObject *lz_builtins; // Roots own the mapping; projections retain the root. + // A root stores its absolute name (PyUnicode) in lz_from, and original + // fromlist in lz_attr. + // A projection stores its source placeholder (a PyLazyImportObject) + // in lz_from, and the attribute to import from (PyUnicode) it in lz_attr. + PyObject *lz_from; + PyObject *lz_attr; + // Declaration location. + PyCodeObject *lz_code; + int lz_instr_offset; + // The root was accessed, so its declared path requires import semantics. + int lz_active; +} PyLazyImportObject; #define PyLazyImportObject_CAST(op) ((PyLazyImportObject *)(op)) +static PyObject *lazy_import_name(PyLazyImportObject *m); + PyObject * -_PyLazyImport_New(_PyInterpreterFrame *frame, PyObject *builtins, PyObject *name, PyObject *fromlist) +_PyLazyImport_New(_PyInterpreterFrame *frame, PyObject *builtins, + PyObject *name, PyObject *fromlist) { - PyLazyImportObject *m; - if (!name || !PyUnicode_Check(name)) { - PyErr_SetString(PyExc_TypeError, "expected str for name"); + if (!name || !(PyUnicode_Check(name) || PyLazyImport_CheckExact(name))) { + PyErr_SetString(PyExc_TypeError, "expected str or lazy_import for name"); return NULL; } if (fromlist == Py_None || fromlist == NULL) { @@ -26,7 +50,20 @@ _PyLazyImport_New(_PyInterpreterFrame *frame, PyObject *builtins, PyObject *name "lazy_import: fromlist must be None, a string, or a tuple"); return NULL; } - m = PyObject_GC_New(PyLazyImportObject, &PyLazyImport_Type); +#ifndef NDEBUG + if (PyLazyImport_CheckExact(name)) { + // projection + assert(builtins == NULL); + assert(fromlist != NULL); + assert(PyUnicode_Check(fromlist)); + } + else { + // root + assert(builtins != NULL); + } +#endif + PyLazyImportObject *m = PyObject_GC_New( + PyLazyImportObject, &PyLazyImport_Type); if (m == NULL) { return NULL; } @@ -34,23 +71,84 @@ _PyLazyImport_New(_PyInterpreterFrame *frame, PyObject *builtins, PyObject *name m->lz_from = Py_NewRef(name); m->lz_attr = Py_XNewRef(fromlist); - // Capture frame information for the original import location. m->lz_code = NULL; m->lz_instr_offset = -1; + m->lz_active = 0; if (frame != NULL) { - PyCodeObject *code = _PyFrame_GetCode(frame); - if (code != NULL) { - m->lz_code = (PyCodeObject *)Py_NewRef(code); - // Calculate the instruction offset from the current frame. - m->lz_instr_offset = _PyInterpreterFrame_LASTI(frame); - } + m->lz_code = (PyCodeObject *)Py_NewRef(_PyFrame_GetCode(frame)); + m->lz_instr_offset = _PyInterpreterFrame_LASTI(frame); } _PyObject_GC_TRACK(m); return (PyObject *)m; } +// Reuse concrete attributes of initialized modules without waiting for imports +// or resolving lazy attributes. Failed cache lookups are retried at resolution. +// May return NULL with or without an exception set. +static PyObject * +lazy_import_get_loaded_attr(PyThreadState *tstate, PyObject *name, + PyObject *attr_name) +{ + PyObject *mod = NULL, *spec = NULL, *current = NULL, *attr = NULL; + PyObject *modules = Py_XNewRef(_PyImport_GetModules(tstate->interp)); + if (modules == NULL) { + return NULL; + } + int rc = PyMapping_GetOptionalItem(modules, name, &mod); + if (rc <= 0 || !PyModule_Check(mod)) { + goto done; + } + PyObject *dict = _PyModule_GetDict(mod); + if (PyObject_GetOptionalAttr(mod, &_Py_ID(__spec__), &spec) < 0 || + _PyModuleSpec_IsInitializing(spec) != 0) { + goto done; + } + // An initialization check can replace the module in sys.modules. + if (modules != _PyImport_GetModules(tstate->interp) || + PyMapping_GetOptionalItem(modules, name, ¤t) <= 0 || + current != mod) { + goto done; + } + if (PyDict_GetItemRef(dict, attr_name, &attr) < 0) { + goto done; + } + if (attr != NULL && PyLazyImport_CheckExact(attr)) { + Py_CLEAR(attr); + } + +done: + Py_XDECREF(current); + Py_XDECREF(spec); + Py_XDECREF(mod); + Py_DECREF(modules); + if (PyErr_ExceptionMatches(PyExc_Exception)) { + PyErr_Clear(); + } + return attr; +} + +PyObject * +_PyEval_LazyImportFrom(PyThreadState *tstate, _PyInterpreterFrame *frame, + PyObject *v, PyObject *name) +{ + assert(PyLazyImport_CheckExact(v)); + assert(name); + assert(PyUnicode_Check(name)); + PyLazyImportObject *lz = PyLazyImportObject_CAST(v); + // Only `from a import b` can take b off an already imported a; + // `import a.b as c` has to import a.b first. + if (lz->lz_attr != NULL && PyTuple_Check(lz->lz_attr) && + PyTuple_GET_SIZE(lz->lz_attr) > 0) { + PyObject *attr = lazy_import_get_loaded_attr(tstate, lz->lz_from, name); + if (attr != NULL || PyErr_Occurred()) { + return attr; + } + } + return _PyLazyImport_New(frame, NULL, v, name); +} + static int lazy_import_traverse(PyObject *op, visitproc visit, void *arg) { @@ -81,16 +179,69 @@ lazy_import_dealloc(PyObject *op) Py_TYPE(op)->tp_free(op); } +/* Specialize the error message for failed attribute lookups. */ static PyObject * -lazy_import_name(PyLazyImportObject *m) +lazy_import_getattro(PyObject *op, PyObject *name) +{ + PyObject *value = _PyObject_GenericGetAttrWithDict( + op, name, NULL, /* suppress */ 1); + if (value != NULL || PyErr_Occurred()) { + return value; + } + PyObject *lz_name = lazy_import_name(PyLazyImportObject_CAST(op)); + if (lz_name == NULL) { + return NULL; + } + PyErr_Format(PyExc_AttributeError, + "cannot access attribute %R on unresolved lazy import %R", + name, lz_name); + Py_DECREF(lz_name); + return NULL; +} + +// The dotted name of the object that resolving the placeholder returns. +static PyObject * +lazy_import_path(PyLazyImportObject *m) { - if (m->lz_attr != NULL) { - if (PyUnicode_Check(m->lz_attr)) { - return PyUnicode_FromFormat("%U.%U", m->lz_from, m->lz_attr); + if (PyLazyImport_CheckExact(m->lz_from)) { + if (_Py_EnterRecursiveCall(" while getting the name of a lazy import")) { + return NULL; } - else { - return PyUnicode_FromFormat("%U...", m->lz_from); + PyObject *base = lazy_import_path((PyLazyImportObject *)m->lz_from); + _Py_LeaveRecursiveCall(); + if (base == NULL) { + return NULL; } + PyObject *res = PyUnicode_FromFormat("%U.%U", base, m->lz_attr); + Py_DECREF(base); + return res; + } + if (m->lz_attr != NULL && + (!PyTuple_Check(m->lz_attr) || PyTuple_GET_SIZE(m->lz_attr) > 0)) { + return Py_NewRef(m->lz_from); + } + // __import__("a.b") returns the top-level package `a`. + Py_ssize_t dot = PyUnicode_FindChar( + m->lz_from, '.', 0, PyUnicode_GET_LENGTH(m->lz_from), 1 + ); + if (dot == -2) { + return NULL; + } + if (dot < 0) { + return Py_NewRef(m->lz_from); + } + return PyUnicode_Substring(m->lz_from, 0, dot); +} + +static PyObject * +lazy_import_name(PyLazyImportObject *m) +{ + if (PyLazyImport_CheckExact(m->lz_from)) { + return lazy_import_path(m); + } + if (m->lz_attr != NULL && + (!PyTuple_Check(m->lz_attr) || PyTuple_GET_SIZE(m->lz_attr) > 0)) { + return PyUnicode_FromFormat("%U...", m->lz_from); } return Py_NewRef(m->lz_from); } @@ -108,12 +259,455 @@ lazy_import_repr(PyObject *op) return res; } -PyObject * -_PyLazyImport_GetName(PyObject *op) +// Consume a result, resolving a placeholder returned by an import hook or +// an attribute lookup under the same cycle and recursion checks. +static PyObject * +lazy_import_resolve_result(PyThreadState *tstate, PyObject *obj) +{ + if (obj == NULL || !PyLazyImport_CheckExact(obj)) { + return obj; + } + PyObject *result = _PyImport_LoadLazyImportTstate(tstate, obj); + Py_DECREF(obj); + return result; +} + +// Look up, in order, the attributes recorded from the root placeholder to lz +// on the module the root's import returned. +static PyObject * +lazy_import_replay_from(PyThreadState *tstate, PyObject *mod, + PyLazyImportObject *lz) { - PyLazyImportObject *lazy_import = PyLazyImportObject_CAST(op); + if (!PyLazyImport_CheckExact(lz->lz_from)) { + return Py_NewRef(mod); + } + if (_Py_EnterRecursiveCallTstate(tstate, " while resolving a lazy import")) { + return NULL; + } + PyObject *from = lazy_import_replay_from( + tstate, mod, (PyLazyImportObject *)lz->lz_from); + _Py_LeaveRecursiveCallTstate(tstate); + if (from == NULL) { + return NULL; + } + PyObject *obj = _PyEval_ImportFrom(tstate, from, lz->lz_attr); + Py_DECREF(from); + return lazy_import_resolve_result(tstate, obj); +} + +// Preserve the resolution error and attach the import's declaration location. +static void +lazy_import_add_exception_cause(PyThreadState *tstate, PyLazyImportObject *lz) +{ + if (!PyErr_Occurred() || lz->lz_code == NULL || lz->lz_instr_offset < 0) { + return; + } + PyObject *exc = _PyErr_GetRaisedException(tstate); + PyObject *name = lazy_import_name(lz); + if (name == NULL) { + goto done; + } + int lineno = PyCode_Addr2Line(lz->lz_code, lz->lz_instr_offset * 2); + const char *filename = PyUnicode_AsUTF8(lz->lz_code->co_filename); + if (filename == NULL) { + goto done; + } + const char *funcname = PyUnicode_AsUTF8(lz->lz_code->co_name); + if (funcname == NULL) { + goto done; + } + PyBaseExceptionObject *base_exc = (PyBaseExceptionObject *)exc; + if (base_exc->cause != NULL || base_exc->context != NULL || + base_exc->suppress_context) { + // Preserve the original chain, including `raise ... from None`. + PyObject *note = PyUnicode_FromFormat( + "lazy import of '%U' declared in %s at %s:%d", + name, funcname, filename, lineno); + if (note != NULL) { + PyObject *notes; + if (PyObject_GetOptionalAttr(exc, &_Py_ID(__notes__), ¬es) >= 0) { + if (notes == NULL || PySequence_Contains(notes, note) == 0) { + (void)_PyException_AddNote(exc, note); + } + Py_XDECREF(notes); + } + Py_DECREF(note); + } + goto done; + } + PyObject *msg = PyUnicode_FromFormat( + "lazy import of '%U' raised an exception during resolution", name); + if (msg == NULL) { + goto done; + } + PyObject *cause = PyObject_CallOneArg(PyExc_ImportError, msg); + Py_DECREF(msg); + if (cause == NULL) { + goto done; + } + _PyErr_SetRaisedException(tstate, cause); + _PyTraceback_Add(funcname, filename, lineno); + PyException_SetCause(exc, _PyErr_GetRaisedException(tstate)); + +done: + Py_XDECREF(name); + _PyErr_SetRaisedException(tstate, exc); +} + +int +_PyLazyImport_IsResolving(PyThreadState *tstate, PyObject *op) +{ + _PyThreadStateImpl *ts = (_PyThreadStateImpl *)tstate; + assert(PyLazyImport_CheckExact(op)); + int active = ts->lazy_imports == NULL ? 0 : PySet_Contains(ts->lazy_imports, op); + assert(active >= 0); // Exact placeholders use identity hashing and equality. + return active; +} + +static PyObject * +lazy_import_resolve_impl(PyThreadState *tstate, PyObject *lazy_import, + PyObject **imported_module) +{ + PyObject *obj = NULL; + PyObject *fromlist = NULL; + PyObject *import_func = NULL; + PyObject *resolving = NULL; + assert(lazy_import != NULL); assert(PyLazyImport_CheckExact(lazy_import)); - return lazy_import_name(lazy_import); + + PyLazyImportObject *lz = (PyLazyImportObject *)lazy_import; + + // Walk back to the placeholder IMPORT_NAME left, and the first lookup on it. + PyLazyImportObject *root = lz, *first = NULL; + while (PyLazyImport_CheckExact(root->lz_from)) { + first = root; + root = (PyLazyImportObject *)root->lz_from; + } + + if (_PyLazyImport_IsResolving(tstate, lazy_import)) { + PyObject *name = lazy_import_name(lz); + if (name == NULL) { + return NULL; + } + PyObject *errmsg = PyUnicode_FromFormat( + "cannot import name %R (most likely due to a circular import)", + name); + Py_DECREF(name); + if (errmsg != NULL) { + PyErr_SetImportErrorSubclass(PyExc_ImportCycleError, errmsg, + root->lz_from, NULL); + Py_DECREF(errmsg); + } + return NULL; + } + if (_Py_EnterRecursiveCallTstate(tstate, " while resolving a lazy import")) { + return NULL; + } + _PyThreadStateImpl *ts = (_PyThreadStateImpl *)tstate; + if (ts->lazy_imports == NULL) { + ts->lazy_imports = PySet_New(NULL); + if (ts->lazy_imports == NULL) { + goto done; + } + } + resolving = ts->lazy_imports; + if (PySet_Add(resolving, lazy_import) < 0) { + goto done; + } + + // `from a import b, c`: import only the name being resolved. + // Keep an empty tuple intact for custom __import__ hooks. + if (first != NULL && root->lz_attr != NULL && + PyTuple_Check(root->lz_attr) && PyTuple_GET_SIZE(root->lz_attr) > 0) { + fromlist = PyTuple_Pack(1, first->lz_attr); + } + else { + fromlist = Py_NewRef(root->lz_attr != NULL ? root->lz_attr : Py_None); + } + if (fromlist == NULL) { + goto done; + } + + PyObject *globals = PyEval_GetGlobals(); + if (globals == NULL) { + globals = Py_None; + } + + if (PyMapping_GetOptionalItem(root->lz_builtins, &_Py_ID(__import__), + &import_func) < 0) { + goto done; + } + if (import_func == NULL) { + PyErr_SetString(PyExc_ImportError, "__import__ not found"); + goto done; + } + PyObject *name = Py_NewRef(root->lz_from); + if (first == NULL && + (fromlist == Py_None || + (PyTuple_Check(fromlist) && PyTuple_GET_SIZE(fromlist) == 0)) && + _PyImport_IsDefaultImportFunc(tstate->interp, import_func) && + root->lz_builtins == tstate->interp->builtins) { + // A plain import binds the root package. Its pending children are + // imported separately when their attributes are accessed. + Py_ssize_t dot = PyUnicode_FindChar( + name, '.', 0, PyUnicode_GET_LENGTH(name), 1); + if (dot >= 0) { + // Preserve eager traversal through aliased or non-package parents. + int regular = 1; + int complete = 1; + Py_ssize_t end = PyUnicode_GET_LENGTH(name); + for (Py_ssize_t i = dot; i >= 0 && regular; + i = PyUnicode_FindChar(name, '.', i + 1, end, 1)) { + PyObject *prefix = PyUnicode_Substring(name, 0, i); + PyObject *cached = prefix == NULL ? NULL : + lazy_import_get_loaded_attr(tstate, prefix, &_Py_ID(__name__)); + if (cached == NULL) { + complete = 0; + Py_XDECREF(prefix); + break; + } + PyObject *path = lazy_import_get_loaded_attr( + tstate, prefix, &_Py_ID(__path__)); + regular = path != NULL && PyUnicode_Check(cached) && + PyUnicode_Compare(cached, prefix) == 0; + Py_XDECREF(path); + Py_DECREF(cached); + Py_DECREF(prefix); + } + PyObject *loaded = lazy_import_get_loaded_attr( + tstate, name, &_Py_ID(__name__)); + if (regular && (!complete || loaded == NULL) && !PyErr_Occurred()) { + Py_SETREF(name, PyUnicode_Substring(name, 0, dot)); + } + Py_XDECREF(loaded); + if (PyErr_Occurred()) { + Py_CLEAR(name); + } + } + else if (dot == -2) { + Py_CLEAR(name); + } + if (name == NULL) { + goto done; + } + } + obj = _PyEval_ImportNameWithImport( + tstate, import_func, globals, globals, + name, fromlist, _PyLong_GetZero() + ); + if (obj != NULL && name != root->lz_from) { + FT_ATOMIC_STORE_INT_RELAXED(root->lz_active, 1); + FT_ATOMIC_STORE_INT_RELAXED(tstate->interp->imports.has_lazy_submodules, 1); + int package = PyModule_CheckExact(obj) ? + PyDict_Contains(_PyModule_GetDict(obj), &_Py_ID(__path__)) : 0; + if (package < 0) { + Py_CLEAR(obj); + } + else if (!package) { + Py_DECREF(obj); + obj = _PyEval_ImportNameWithImport( + tstate, import_func, globals, globals, + root->lz_from, fromlist, _PyLong_GetZero()); + } + } + if (obj != NULL && name == root->lz_from && + _PyImport_IsDefaultImportFunc(tstate->interp, import_func) && + _PyImport_ClearLazySubmodule(tstate, name, 0) < 0) { + Py_CLEAR(obj); + } + Py_DECREF(name); + obj = lazy_import_resolve_result(tstate, obj); + // The normal importer may publish this module on its parent. Custom + // hooks retain control of their own assignments to the parent. + if (imported_module != NULL && obj != NULL && PyModule_Check(obj) && + _PyImport_IsDefaultImportFunc(tstate->interp, import_func)) { + *imported_module = Py_NewRef(obj); + } + if (obj != NULL && first != NULL) { + // Keep the hook and root result alive until all attribute lookups finish. + PyObject *from = obj; + obj = lazy_import_replay_from(tstate, from, lz); + Py_DECREF(from); + } + +done: + if (obj == NULL) { + lazy_import_add_exception_cause(tstate, lz); + } + assert(obj == NULL || !PyLazyImport_CheckExact(obj)); + if (obj != NULL) { + PyObject *name = lazy_import_path(lz); + if (name == NULL || + _PyImport_DiscardLazyModule(tstate->interp, name) < 0) { + Py_CLEAR(obj); + } + Py_XDECREF(name); + } + if (resolving != NULL) { + // A failed set resize can leave the placeholder inserted. Removing by + // identity also permits greenlets to finish in a different order. + if (PySet_Discard(resolving, lazy_import) < 0) { + Py_CLEAR(obj); + } + if (PySet_GET_SIZE(resolving) == 0) { + // Keep the set, but release the capacity used by deep resolutions. + (void)PySet_Clear(resolving); + } + } + + Py_XDECREF(fromlist); + Py_XDECREF(import_func); + _Py_LeaveRecursiveCallTstate(tstate); + return obj; +} + +PyObject * +_PyImport_LoadLazyImportTstate(PyThreadState *tstate, PyObject *lazy_import) +{ + return lazy_import_resolve_impl(tstate, lazy_import, NULL); +} + +// Resolve a pending child as an aliased import, preserving its declaration. +PyObject * +_PyLazyImport_LoadChild(PyThreadState *tstate, PyObject *declaration, + PyObject *name) +{ + assert(PyLazyImport_CheckExact(declaration)); + PyLazyImportObject *source = PyLazyImportObject_CAST(declaration); + PyObject *lz = _PyLazyImport_New(NULL, source->lz_builtins, name, NULL); + Py_ssize_t end = PyUnicode_GET_LENGTH(name); + Py_ssize_t dot = PyUnicode_FindChar(name, '.', 0, end, 1); + if (dot == -2) { + Py_CLEAR(lz); + } + while (lz != NULL && dot >= 0) { + Py_ssize_t start = dot + 1; + dot = PyUnicode_FindChar(name, '.', start, end, 1); + if (dot == -2) { + Py_CLEAR(lz); + break; + } + PyObject *attr = PyUnicode_Substring(name, start, dot < 0 ? end : dot); + PyObject *next = attr == NULL ? NULL : + _PyLazyImport_New(NULL, NULL, lz, attr); + Py_XDECREF(attr); + Py_SETREF(lz, next); + } + if (lz == NULL) { + return NULL; + } + PyLazyImportObject *child = PyLazyImportObject_CAST(lz); + child->lz_code = (PyCodeObject *)Py_XNewRef(source->lz_code); + child->lz_instr_offset = source->lz_instr_offset; + PyObject *result = _PyImport_LoadLazyImportTstate(tstate, lz); + Py_DECREF(lz); + if (result != NULL && PyModule_Check(result) && + PyUnicode_Compare(source->lz_from, name) != 0 && + !PyDict_Contains(_PyModule_GetDict(result), &_Py_ID(__path__))) { + // Reaching a non-package must still reject an invalid dotted import. + Py_DECREF(result); + return _PyLazyImport_LoadChild(tstate, declaration, source->lz_from); + } + return result; +} + +int +_PyLazyImport_IsActive(PyObject *declaration) +{ + assert(PyLazyImport_CheckExact(declaration)); + return FT_ATOMIC_LOAD_INT_RELAXED( + PyLazyImportObject_CAST(declaration)->lz_active); +} + +// Loading pkg.child can replace a placeholder in pkg.child with the module +// before a from-import retrieves the value that belongs in that binding. +// This is an optimization that can be safely skipped. +static int +lazy_import_replace_child(PyThreadState *tstate, PyObject *placeholder, + PyObject *name, PyObject *namespace, + PyObject *child, PyObject *value) +{ + PyLazyImportObject *root = (PyLazyImportObject *)placeholder; + if (!PyLazyImport_CheckExact(root->lz_from)) { + return 0; + } + while (PyLazyImport_CheckExact(root->lz_from)) { + root = (PyLazyImportObject *)root->lz_from; + } + Py_ssize_t end = PyUnicode_GET_LENGTH(root->lz_from); + Py_ssize_t dot = PyUnicode_FindChar(root->lz_from, '.', 0, end, -1); + if (dot < 0) { + return dot == -1 ? 0 : -1; + } + if (end - dot - 1 != PyUnicode_GET_LENGTH(name)) { + return 0; + } + Py_ssize_t matches = PyUnicode_Tailmatch(root->lz_from, name, dot + 1, end, 1); + if (matches <= 0) { + return matches ? -1 : 0; + } + PyObject *parent_name = PyUnicode_Substring(root->lz_from, 0, dot); + if (parent_name == NULL) { + return -1; + } + PyObject *modules = Py_XNewRef(_PyImport_GetModules(tstate->interp)); + PyObject *parent = NULL; + int rc = 0; + if (modules != NULL) { + rc = PyMapping_GetOptionalItem(modules, parent_name, &parent); + if (rc > 0 && PyModule_Check(parent) && + _PyModule_GetDict(parent) == namespace) { + rc = _PyDict_ReplaceItemIf(namespace, name, child, value); + } + } + Py_XDECREF(parent); + Py_XDECREF(modules); + Py_DECREF(parent_name); + return rc; +} + +PyObject * +_PyLazyImport_Reify(PyThreadState *tstate, PyObject *placeholder, + PyObject *name, PyObject *namespace) +{ + PyObject *imported_module = NULL; + PyObject *value = lazy_import_resolve_impl( + tstate, placeholder, &imported_module); + if (value == NULL) { + Py_XDECREF(imported_module); + return NULL; + } + int rc; + if (PyDict_CheckExact(namespace)) { + rc = _PyDict_ReplaceItemIf(namespace, name, placeholder, value); + if (rc == 0 && imported_module != NULL) { + rc = lazy_import_replace_child( + tstate, placeholder, name, namespace, imported_module, value); + } + } + else if (Py_TYPE(namespace)->tp_as_mapping == NULL || + Py_TYPE(namespace)->tp_as_mapping->mp_ass_subscript == NULL) { + // Read-only namespaces can resolve a value without caching it. + Py_XDECREF(imported_module); + return value; + } + else { + // Custom namespaces retain their mapping protocol. Atomic replacement + // is only available for exact dictionaries. + PyObject *current; + rc = PyMapping_GetOptionalItem(namespace, name, ¤t); + if (rc > 0) { + if (current == placeholder) { + rc = PyObject_SetItem(namespace, name, value); + } + Py_DECREF(current); + } + } + if (rc < 0) { + Py_CLEAR(value); + } + Py_XDECREF(imported_module); + return value; } static PyObject * @@ -125,7 +719,7 @@ lazy_import_resolve(PyObject *self, PyObject *args) static PyMethodDef lazy_import_methods[] = { { "resolve", lazy_import_resolve, METH_NOARGS, - PyDoc_STR("resolves the lazy import and returns the actual object") + PyDoc_STR("Resolve the lazy import and return the imported object.") }, {NULL, NULL} }; @@ -149,6 +743,7 @@ PyTypeObject PyLazyImport_Type = { .tp_repr = lazy_import_repr, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, .tp_doc = lazy_import_doc, + .tp_getattro = lazy_import_getattro, .tp_traverse = lazy_import_traverse, .tp_clear = lazy_import_clear, .tp_methods = lazy_import_methods, diff --git a/Objects/listobject.c b/Objects/listobject.c index 8a9c9bda68269b8..c5fe704df0e23de 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -91,6 +91,10 @@ ensure_shared_on_resize(PyListObject *self) #endif } +#define LIST_SMALL_ALLOCATED 32 + +static int py_list_resize(PyListObject *self, Py_ssize_t newsize); + /* Ensure ob_item has room for at least newsize elements, and set * ob_size to newsize. If newsize > ob_size on entry, the content * of the new slots at exit is undefined heap trash; it's the caller's @@ -99,22 +103,37 @@ ensure_shared_on_resize(PyListObject *self) * Failure is impossible if newsize <= self.allocated on entry. * Note that self->ob_item may change, and even if newsize is less * than ob_size on entry. + * + * Always inlining list_resize() makes the fast path a few instructions + * in each caller instead of a function call. */ -static int +static inline Py_ALWAYS_INLINE int list_resize(PyListObject *self, Py_ssize_t newsize) { - size_t new_allocated, target_bytes; Py_ssize_t allocated = self->allocated; /* Bypass realloc() when a previous overallocation is large enough to accommodate the newsize. If the newsize falls lower than half the allocated size, then proceed with the realloc() to shrink the list. + gh-158592: do not shrink a small list, the realloc() cost is bigger + than the memory we get back. */ - if (allocated >= newsize && newsize >= (allocated >> 1)) { + if (allocated >= newsize + && (newsize >= (allocated >> 1) || allocated <= LIST_SMALL_ALLOCATED)) + { assert(self->ob_item != NULL || newsize == 0); Py_SET_SIZE(self, newsize); return 0; } + return py_list_resize(self, newsize); +} + +/* Slow path of list_resize(): allocate or reallocate ob_item. */ +static int +py_list_resize(PyListObject *self, Py_ssize_t newsize) +{ + size_t new_allocated, target_bytes; + Py_ssize_t allocated = self->allocated; /* This over-allocates proportional to the list size, making room * for additional growth. The over-allocation is mild, but is @@ -136,6 +155,8 @@ list_resize(PyListObject *self, Py_ssize_t newsize) if (newsize == 0) new_allocated = 0; + assert(newsize > allocated || new_allocated < (size_t)allocated); + ensure_shared_on_resize(self); #ifdef Py_GIL_DISABLED @@ -252,10 +273,11 @@ PyList_New(Py_ssize_t size) return NULL; } } - if (size <= 0) { - op->ob_item = NULL; - } - else { + op->ob_item = NULL; + op->allocated = 0; + Py_SET_SIZE(op, size); + + if (size > 0) { #ifdef Py_GIL_DISABLED _PyListArray *array = list_allocate_array(size); if (array == NULL) { @@ -272,7 +294,7 @@ PyList_New(Py_ssize_t size) return PyErr_NoMemory(); } } - Py_SET_SIZE(op, size); + op->allocated = size; _PyObject_GC_TRACK(op); return (PyObject *) op; @@ -478,10 +500,43 @@ end:; return ret; } +static void ptr_wise_atomic_memmove(PyListObject *a, PyObject **dest, + PyObject **src, Py_ssize_t n); + +static inline void +list_shift_items_right_lock_held(PyListObject *self, Py_ssize_t first, + Py_ssize_t last) +{ +#ifdef Py_GIL_DISABLED + ptr_wise_atomic_memmove(self, &self->ob_item[first + 1], + &self->ob_item[first], last - first); +#else + PyObject **items = self->ob_item; + for (Py_ssize_t i = last; --i >= first; ) { + items[i + 1] = items[i]; + } +#endif +} + +static inline void +list_shift_items_left_lock_held(PyListObject *self, Py_ssize_t first, + Py_ssize_t last) +{ +#ifdef Py_GIL_DISABLED + ptr_wise_atomic_memmove(self, &self->ob_item[first], + &self->ob_item[first + 1], last - first); +#else + PyObject **items = self->ob_item; + for (Py_ssize_t i = first; i < last; i++) { + items[i] = items[i + 1]; + } +#endif +} + static int ins1(PyListObject *self, Py_ssize_t where, PyObject *v) { - Py_ssize_t i, n = Py_SIZE(self); + Py_ssize_t n = Py_SIZE(self); PyObject **items; if (v == NULL) { PyErr_BadInternalCall(); @@ -500,8 +555,9 @@ ins1(PyListObject *self, Py_ssize_t where, PyObject *v) if (where > n) where = n; items = self->ob_item; - for (i = n; --i >= where; ) - FT_ATOMIC_STORE_PTR_RELEASE(items[i+1], items[i]); + if (where < n) { + list_shift_items_right_lock_held(self, where, n); + } FT_ATOMIC_STORE_PTR_RELEASE(items[where], Py_NewRef(v)); return 0; } @@ -577,9 +633,21 @@ list_dealloc(PyObject *self) } } +/*[clinic input] +@critical_section +list.__repr__ + + v: self(type="PyListObject *") +[clinic start generated code]*/ + static PyObject * list_repr_impl(PyListObject *v) +/*[clinic end generated code: output=c5ffe3b9cfee36ce input=f4b85c550d11de32]*/ { + if (PyList_GET_SIZE(v) == 0) { + return PyUnicode_FromString("[]"); + } + int res = Py_ReprEnter((PyObject*)v); if (res != 0) { return (res > 0 ? PyUnicode_FromString("[...]") : NULL); @@ -632,20 +700,6 @@ list_repr_impl(PyListObject *v) return NULL; } -static PyObject * -list_repr(PyObject *self) -{ - if (PyList_GET_SIZE(self) == 0) { - return PyUnicode_FromString("[]"); - } - PyListObject *v = (PyListObject *)self; - PyObject *ret = NULL; - Py_BEGIN_CRITICAL_SECTION(v); - ret = list_repr_impl(v); - Py_END_CRITICAL_SECTION(); - return ret; -} - static Py_ssize_t list_length(PyObject *a) { @@ -816,8 +870,18 @@ _PyList_Concat(PyObject *aa, PyObject *bb) return ret; } +/*[clinic input] +@critical_section +list.__mul__ as list_repeat + + a: self(type="PyListObject *") + n: Py_ssize_t + / +[clinic start generated code]*/ + static PyObject * -list_repeat_lock_held(PyListObject *a, Py_ssize_t n) +list_repeat_impl(PyListObject *a, Py_ssize_t n) +/*[clinic end generated code: output=65bb40ed76d3e733 input=dfef16e067b2abb6]*/ { const Py_ssize_t input_size = Py_SIZE(a); if (input_size == 0 || n <= 0) @@ -858,17 +922,6 @@ list_repeat_lock_held(PyListObject *a, Py_ssize_t n) return (PyObject *) np; } -static PyObject * -list_repeat(PyObject *aa, Py_ssize_t n) -{ - PyObject *ret; - PyListObject *a = (PyListObject *)aa; - Py_BEGIN_CRITICAL_SECTION(a); - ret = list_repeat_lock_held(a, n); - Py_END_CRITICAL_SECTION(); - return ret; -} - static void list_clear_impl(PyListObject *a, bool is_resize) { @@ -1118,24 +1171,37 @@ list_inplace_repeat_lock_held(PyListObject *self, Py_ssize_t n) return 0; } +/*[clinic input] +@critical_section +list.__imul__ as list_inplace_repeat + + n: Py_ssize_t + / +[clinic start generated code]*/ + static PyObject * -list_inplace_repeat(PyObject *_self, Py_ssize_t n) +list_inplace_repeat_impl(PyListObject *self, Py_ssize_t n) +/*[clinic end generated code: output=d318a9f047b4fcaf input=530d74de0e4a61f0]*/ { - PyObject *ret; - PyListObject *self = (PyListObject *) _self; - Py_BEGIN_CRITICAL_SECTION(self); if (list_inplace_repeat_lock_held(self, n) < 0) { - ret = NULL; - } - else { - ret = Py_NewRef(self); + return NULL; } - Py_END_CRITICAL_SECTION(); - return ret; + return Py_NewRef(self); } +/*[clinic input] +@critical_section +list.__setitem__ as list_ass_item + + a: self(type="PyListObject *") + i: Py_ssize_t + v: object + / +[clinic start generated code]*/ + static int -list_ass_item_lock_held(PyListObject *a, Py_ssize_t i, PyObject *v) +list_ass_item_impl(PyListObject *a, Py_ssize_t i, PyObject *v) +/*[clinic end generated code: output=51d8b4f1790b67db input=0ba2adeaf8b3d5a0]*/ { if (!valid_index(i, Py_SIZE(a))) { PyErr_SetString(PyExc_IndexError, @@ -1145,10 +1211,10 @@ list_ass_item_lock_held(PyListObject *a, Py_ssize_t i, PyObject *v) PyObject *tmp = a->ob_item[i]; if (v == NULL) { Py_ssize_t size = Py_SIZE(a); - for (Py_ssize_t idx = i; idx < size - 1; idx++) { - FT_ATOMIC_STORE_PTR_RELEASE(a->ob_item[idx], a->ob_item[idx + 1]); + if (i < size - 1) { + list_shift_items_left_lock_held(a, i, size - 1); } - Py_SET_SIZE(a, size - 1); + list_resize(a, size - 1); // NB: shrinking a list can't fail } else { FT_ATOMIC_STORE_PTR_RELEASE(a->ob_item[i], Py_NewRef(v)); @@ -1157,17 +1223,6 @@ list_ass_item_lock_held(PyListObject *a, Py_ssize_t i, PyObject *v) return 0; } -static int -list_ass_item(PyObject *aa, Py_ssize_t i, PyObject *v) -{ - int ret; - PyListObject *a = (PyListObject *)aa; - Py_BEGIN_CRITICAL_SECTION(a); - ret = list_ass_item_lock_held(a, i, v); - Py_END_CRITICAL_SECTION(); - return ret; -} - /*[clinic input] @critical_section list.insert @@ -2263,7 +2318,7 @@ merge_init(MergeState *ms, Py_ssize_t list_size, int has_keyfunc, while (list_size >> ms->mr_e >= MAX_MINRUN) { ++ms->mr_e; } - ms->mr_mask = (1 << ms->mr_e) - 1; + ms->mr_mask = ((Py_ssize_t)1 << ms->mr_e) - 1; ms->mr_current = 0; } @@ -2810,6 +2865,26 @@ unsafe_object_compare(PyObject *v, PyObject *w, MergeState *ms) return res; } +#ifndef NDEBUG +static void +assert_compare_consistent(PyObject *v, PyObject *w, int res) +{ + int cmp = PyObject_RichCompareBool(v, w, Py_LT); + if (cmp < 0) { + /* This debug-only cross-check can hit the C stack guard even when + * the specialized comparison itself is safe. Keep the optimized path + * side-effect free by discarding that exception. + */ + assert(PyErr_ExceptionMatches(PyExc_RecursionError)); + PyErr_Clear(); + return; + } + assert(res == cmp); +} +#else +# define assert_compare_consistent(v, w, res) ((void)0) +#endif + /* Latin string compare: safe for any two latin (one byte per char) strings. */ static int unsafe_latin_compare(PyObject *v, PyObject *w, MergeState *ms) @@ -2830,7 +2905,7 @@ unsafe_latin_compare(PyObject *v, PyObject *w, MergeState *ms) res < 0 : PyUnicode_GET_LENGTH(v) < PyUnicode_GET_LENGTH(w)); - assert(res == PyObject_RichCompareBool(v, w, Py_LT));; + assert_compare_consistent(v, w, res); return res; } @@ -2855,7 +2930,7 @@ unsafe_long_compare(PyObject *v, PyObject *w, MergeState *ms) w0 = _PyLong_CompactValue(wl); res = v0 < w0; - assert(res == PyObject_RichCompareBool(v, w, Py_LT)); + assert_compare_consistent(v, w, res); return res; } @@ -2870,7 +2945,7 @@ unsafe_float_compare(PyObject *v, PyObject *w, MergeState *ms) assert(Py_IS_TYPE(w, &PyFloat_Type)); res = PyFloat_AS_DOUBLE(v) < PyFloat_AS_DOUBLE(w); - assert(res == PyObject_RichCompareBool(v, w, Py_LT)); + assert_compare_consistent(v, w, res); return res; } @@ -3454,7 +3529,10 @@ list_richcompare_impl(PyObject *v, PyObject *w, int op) Py_RETURN_TRUE; } - /* Search for the first index where items are different */ + /* Search for the first index where items are different. + * We incref vitem/witem before calling PyObject_RichCompareBool, which may + * release the GIL and allow the list to be mutated in the meantime. + */ for (i = 0; i < Py_SIZE(vl) && i < Py_SIZE(wl); i++) { PyObject *vitem = vl->ob_item[i]; PyObject *witem = wl->ob_item[i]; @@ -3465,36 +3543,36 @@ list_richcompare_impl(PyObject *v, PyObject *w, int op) Py_INCREF(vitem); Py_INCREF(witem); int k = PyObject_RichCompareBool(vitem, witem, Py_EQ); - Py_DECREF(vitem); - Py_DECREF(witem); - if (k < 0) + if (k < 0) { + Py_DECREF(vitem); + Py_DECREF(witem); return NULL; - if (!k) - break; - } - - if (i >= Py_SIZE(vl) || i >= Py_SIZE(wl)) { - /* No more items to compare -- compare sizes */ - Py_RETURN_RICHCOMPARE(Py_SIZE(vl), Py_SIZE(wl), op); - } + } + if (!k) { + /* We have a differing item -- shortcuts for EQ/NE */ + if (op == Py_EQ) { + Py_DECREF(vitem); + Py_DECREF(witem); + Py_RETURN_FALSE; + } + if (op == Py_NE) { + Py_DECREF(vitem); + Py_DECREF(witem); + Py_RETURN_TRUE; + } + /* Compare the differing items using the proper operator */ + PyObject *result = PyObject_RichCompare(vitem, witem, op); + Py_DECREF(vitem); + Py_DECREF(witem); + return result; + } - /* We have an item that differs -- shortcuts for EQ/NE */ - if (op == Py_EQ) { - Py_RETURN_FALSE; - } - if (op == Py_NE) { - Py_RETURN_TRUE; + Py_DECREF(vitem); + Py_DECREF(witem); } - /* Compare the final item again using the proper operator */ - PyObject *vitem = vl->ob_item[i]; - PyObject *witem = wl->ob_item[i]; - Py_INCREF(vitem); - Py_INCREF(witem); - PyObject *result = PyObject_RichCompare(vl->ob_item[i], wl->ob_item[i], op); - Py_DECREF(vitem); - Py_DECREF(witem); - return result; + /* All compared elements were equal -- compare sizes */ + Py_RETURN_RICHCOMPARE(Py_SIZE(vl), Py_SIZE(wl), op); } static PyObject * @@ -3523,7 +3601,7 @@ static int list___init___impl(PyListObject *self, PyObject *iterable) /*[clinic end generated code: output=0f3c21379d01de48 input=b3f3fe7206af8f6b]*/ { - /* Verify list invariants established by PyType_GenericAlloc() */ + /* Verify list invariants */ assert(0 <= Py_SIZE(self)); assert(Py_SIZE(self) <= self->allocated || self->allocated == -1); assert(self->ob_item != NULL || @@ -3555,7 +3633,10 @@ list_vectorcall(PyObject *type, PyObject * const*args, return NULL; } - PyObject *list = PyType_GenericAlloc(_PyType_CAST(type), 0); + /* use PyList_New() to make exact lists from the freelist. */ + PyObject *list = (type == (PyObject *)&PyList_Type + ? PyList_New(0) + : PyType_GenericAlloc(_PyType_CAST(type), 0)); if (list == NULL) { return NULL; } @@ -3581,10 +3662,12 @@ list___sizeof___impl(PyListObject *self) { size_t res = _PyObject_SIZE(Py_TYPE(self)); #ifdef Py_GIL_DISABLED - PyObject **ob_item = _Py_atomic_load_ptr(&self->ob_item); + Py_BEGIN_CRITICAL_SECTION(self); + PyObject **ob_item = self->ob_item; if (ob_item != NULL) { res += list_capacity(ob_item) * sizeof(PyObject *); } + Py_END_CRITICAL_SECTION(); #else res += (size_t)self->allocated * sizeof(PyObject *); #endif @@ -3738,7 +3821,7 @@ list_ass_subscript_lock_held(PyObject *_self, PyObject *item, PyObject *value) return -1; if (i < 0) i += PyList_GET_SIZE(self); - return list_ass_item_lock_held(self, i, value); + return list_ass_item_impl(self, i, value); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step; diff --git a/Objects/longobject.c b/Objects/longobject.c index 7a38ae8ea5a36f0..b48328efa2f1b7c 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -1905,15 +1905,15 @@ static digit v_lshift(digit *z, digit *a, Py_ssize_t m, int d) { Py_ssize_t i; - digit carry = 0; + twodigits carry = 0; assert(0 <= d && d < PyLong_SHIFT); for (i=0; i < m; i++) { twodigits acc = (twodigits)a[i] << d | carry; z[i] = (digit)acc & PyLong_MASK; - carry = (digit)(acc >> PyLong_SHIFT); + carry = acc >> PyLong_SHIFT; } - return carry; + return (digit)carry; } /* Shift digit vector a[0:m] d bits right, with 0 <= d < PyLong_SHIFT. Put @@ -1923,16 +1923,16 @@ static digit v_rshift(digit *z, digit *a, Py_ssize_t m, int d) { Py_ssize_t i; - digit carry = 0; - digit mask = ((digit)1 << d) - 1U; + twodigits carry = 0; + twodigits mask = ((twodigits)1 << d) - 1U; assert(0 <= d && d < PyLong_SHIFT); for (i=m; i-- > 0;) { - twodigits acc = (twodigits)carry << PyLong_SHIFT | a[i]; - carry = (digit)acc & mask; + twodigits acc = carry << PyLong_SHIFT | a[i]; + carry = acc & mask; z[i] = (digit)(acc >> d); } - return carry; + return (digit)carry; } /* Divide long pin, w/ size digits, by non-zero digit n, storing quotient @@ -2045,10 +2045,6 @@ pylong_int_to_decimal_string(PyObject *aa, goto error; } if (writer) { - Py_ssize_t size = PyUnicode_GET_LENGTH(s); - if (_PyUnicodeWriter_Prepare(writer, size, '9') == -1) { - goto error; - } if (_PyUnicodeWriter_WriteStr(writer, s) < 0) { goto error; } @@ -2216,10 +2212,11 @@ long_to_decimal_string_internal(PyObject *aa, } } if (writer) { - if (_PyUnicodeWriter_Prepare(writer, strlen, '9') == -1) { + if (_PyUnicodeWriter_Prepare(writer, strlen, 127) == -1) { Py_DECREF(scratch); return -1; } + assert(_PyUnicodeWriter_CanWrite(writer)); } else if (bytes_writer) { *bytes_str = PyBytesWriter_GrowAndUpdatePointer(bytes_writer, strlen, @@ -2230,7 +2227,7 @@ long_to_decimal_string_internal(PyObject *aa, } } else { - str = PyUnicode_New(strlen, '9'); + str = PyUnicode_New(strlen, 127); if (str == NULL) { Py_DECREF(scratch); return -1; @@ -2388,10 +2385,13 @@ long_format_binary(PyObject *aa, int base, int alternate, /* 2 characters for prefix */ sz += 2; } + assert(sz >= 1); if (writer) { - if (_PyUnicodeWriter_Prepare(writer, sz, 'x') == -1) + if (_PyUnicodeWriter_Prepare(writer, sz, 127) == -1) { return -1; + } + assert(_PyUnicodeWriter_CanWrite(writer)); } else if (bytes_writer) { *bytes_str = PyBytesWriter_GrowAndUpdatePointer(bytes_writer, sz, @@ -3325,8 +3325,7 @@ x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem) int d; digit wm1, wm2, carry, q, r, vtop, *v0, *vk, *w0, *ak; twodigits vv; - sdigit zhi; - stwodigits z; + stwodigits z, zhi; /* We follow Knuth [The Art of Computer Programming, Vol. 2 (3rd edn.), section 4.3.1, Algorithm D], except that we don't explicitly @@ -3416,16 +3415,15 @@ x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem) for (i = 0; i < size_w; ++i) { /* invariants: -PyLong_BASE <= -q <= zhi <= 0; -PyLong_BASE * q <= z < PyLong_BASE */ - z = (sdigit)vk[i] + zhi - + z = (stwodigits)vk[i] + zhi - (stwodigits)q * (stwodigits)w0[i]; vk[i] = (digit)z & PyLong_MASK; - zhi = (sdigit)Py_ARITHMETIC_RIGHT_SHIFT(stwodigits, - z, PyLong_SHIFT); + zhi = Py_ARITHMETIC_RIGHT_SHIFT(stwodigits, z, PyLong_SHIFT); } /* add w back if q was too large (this branch taken rarely) */ - assert((sdigit)vtop + zhi == -1 || (sdigit)vtop + zhi == 0); - if ((sdigit)vtop + zhi < 0) { + assert((stwodigits)vtop + zhi == -1 || (stwodigits)vtop + zhi == 0); + if ((stwodigits)vtop + zhi < 0) { carry = 0; for (i = 0; i < size_w; ++i) { carry += vk[i] + w0[i]; @@ -3757,7 +3755,13 @@ x_add(PyLongObject *a, PyLongObject *b) size_a = size_b; size_b = size_temp; } } - z = long_alloc(size_a+1); + assert(size_a >= 1); + /* A carry out of the top digit is only possible if the top digits sum + to at least PyLong_MASK; only then allocate a digit for it. */ + digit top_sum = a->long_value.ob_digit[size_a - 1] + + (size_b == size_a ? b->long_value.ob_digit[size_b - 1] : 0); + int extra_digit = top_sum >= PyLong_MASK; + z = long_alloc(size_a + extra_digit); if (z == NULL) return NULL; for (i = 0; i < size_b; ++i) { @@ -3770,8 +3774,13 @@ x_add(PyLongObject *a, PyLongObject *b) z->long_value.ob_digit[i] = carry & PyLong_MASK; carry >>= PyLong_SHIFT; } - z->long_value.ob_digit[i] = carry; - return long_normalize(z); + if (extra_digit) { + z->long_value.ob_digit[i] = carry; + return long_normalize(z); + } + assert(carry == 0); + assert(z->long_value.ob_digit[i - 1] != 0); + return z; } /* Subtract the absolute values of two integers. */ @@ -4196,6 +4205,12 @@ k_mul(PyLongObject *a, PyLongObject *b) if (a == b) { t2 = (PyLongObject*)Py_NewRef(t1); } + else if (_PyLong_IsZero(bh)) { + /* b can be an unnormalized slice made by k_lopsided_mul(), so bh + * (and bl too) can be zero, and x_add() needs a nonzero operand. + */ + t2 = (PyLongObject*)Py_NewRef(bl); + } else if ((t2 = x_add(bh, bl)) == NULL) { Py_DECREF(t1); goto fail; @@ -4564,6 +4579,14 @@ l_mod(PyLongObject *v, PyLongObject *w, PyLongObject **pmod) *pmod = (PyLongObject *)fast_mod(v, w); return -(*pmod == NULL); } +#if WITH_PYLONG_MODULE + Py_ssize_t size_v = _PyLong_DigitCount(v); /* digits in numerator */ + Py_ssize_t size_w = _PyLong_DigitCount(w); /* digits in denominator */ + if (size_w > 300 && (size_v - size_w) > 150) { + /* Switch to _pylong.int_divmod(). See comments in l_divmod(). */ + return pylong_int_divmod(v, w, NULL, pmod); + } +#endif if (long_rem(v, w, &mod) < 0) return -1; if ((_PyLong_IsNegative(mod) && _PyLong_IsPositive(w)) || @@ -5527,7 +5550,9 @@ long_lshift_int64(PyLongObject *a, int64_t shiftby) return PyLong_FromLong(0); } #if PY_SSIZE_T_MAX <= INT64_MAX / PyLong_SHIFT - if (shiftby > (int64_t)PY_SSIZE_T_MAX * PyLong_SHIFT) { + /* Keep wordshift <= MAX_LONG_DIGITS, so that oldsize + wordshift + cannot overflow Py_ssize_t in long_lshift1(). */ + if (shiftby > (int64_t)MAX_LONG_DIGITS * PyLong_SHIFT) { PyErr_SetString(PyExc_OverflowError, "too many digits in integer"); return NULL; @@ -5552,14 +5577,20 @@ _PyLong_Lshift(PyObject *a, int64_t shiftby) static void v_complement(digit *z, digit *a, Py_ssize_t m) { - Py_ssize_t i; - digit carry = 1; - for (i = 0; i < m; ++i) { - carry += a[i] ^ PyLong_MASK; - z[i] = carry & PyLong_MASK; - carry >>= PyLong_SHIFT; + Py_ssize_t i = 0; + + /* -a is ~a + 1, and the +1 only carries through the trailing zero + digits: they stay zero, the first nonzero digit is negated, and the + digits above it are just inverted. No carry is passed between + iterations of the last loop, so it can be vectorized. */ + while (i < m && a[i] == 0) { + z[i++] = 0; + } + assert(i < m); + z[i] = (0U - a[i]) & PyLong_MASK; + for (++i; i < m; ++i) { + z[i] = a[i] ^ PyLong_MASK; } - assert(carry == 0); } /* Bitwise and/xor/or operations */ @@ -6269,9 +6300,10 @@ static Py_ssize_t int___sizeof___impl(PyObject *self) /*[clinic end generated code: output=3303f008eaa6a0a5 input=9b51620c76fc4507]*/ { + Py_ssize_t ndigits = _PyLong_DigitCount((PyLongObject *)self); /* using Py_MAX(..., 1) because we always allocate space for at least one digit, even though the integer zero has a digit count of 0 */ - Py_ssize_t ndigits = Py_MAX(_PyLong_DigitCount((PyLongObject *)self), 1); + ndigits = Py_MAX(ndigits, 1); return Py_TYPE(self)->tp_basicsize + Py_TYPE(self)->tp_itemsize * ndigits; } @@ -6800,58 +6832,62 @@ PyObject* PyLong_FromUInt64(uint64_t value) PYLONG_FROM_UINT(uint64_t, value); } -#define LONG_TO_INT(obj, value, type_name) \ +#define LONG_TO_INT(type, obj, result) \ do { \ + type value; \ int flags = (Py_ASNATIVEBYTES_NATIVE_ENDIAN \ | Py_ASNATIVEBYTES_ALLOW_INDEX); \ - Py_ssize_t bytes = PyLong_AsNativeBytes(obj, value, sizeof(*value), flags); \ + Py_ssize_t bytes = PyLong_AsNativeBytes(obj, &value, sizeof(value), flags); \ if (bytes < 0) { \ return -1; \ } \ - if ((size_t)bytes > sizeof(*value)) { \ + if ((size_t)bytes > sizeof(value)) { \ PyErr_SetString(PyExc_OverflowError, \ - "Python int too large to convert to " type_name); \ + "Python int too large to convert to C " #type); \ return -1; \ } \ + *result = value; \ return 0; \ } while (0) -int PyLong_AsInt32(PyObject *obj, int32_t *value) +int PyLong_AsInt32(PyObject *obj, int32_t *result) { - LONG_TO_INT(obj, value, "C int32_t"); + LONG_TO_INT(int32_t, obj, result); } -int PyLong_AsInt64(PyObject *obj, int64_t *value) +int PyLong_AsInt64(PyObject *obj, int64_t *result) { - LONG_TO_INT(obj, value, "C int64_t"); + LONG_TO_INT(int64_t, obj, result); } -#define LONG_TO_UINT(obj, value, type_name) \ +#define LONG_TO_UINT(type, obj, result) \ do { \ + type value; \ int flags = (Py_ASNATIVEBYTES_NATIVE_ENDIAN \ | Py_ASNATIVEBYTES_UNSIGNED_BUFFER \ | Py_ASNATIVEBYTES_REJECT_NEGATIVE \ | Py_ASNATIVEBYTES_ALLOW_INDEX); \ - Py_ssize_t bytes = PyLong_AsNativeBytes(obj, value, sizeof(*value), flags); \ + Py_ssize_t bytes = PyLong_AsNativeBytes(obj, &value, sizeof(value), flags); \ if (bytes < 0) { \ return -1; \ } \ - if ((size_t)bytes > sizeof(*value)) { \ + if ((size_t)bytes > sizeof(value)) { \ PyErr_SetString(PyExc_OverflowError, \ - "Python int too large to convert to " type_name); \ + "Python int too large to convert to C " #type); \ return -1; \ } \ + *result = value; \ return 0; \ } while (0) -int PyLong_AsUInt32(PyObject *obj, uint32_t *value) +int PyLong_AsUInt32(PyObject *obj, uint32_t *result) { - LONG_TO_UINT(obj, value, "C uint32_t"); + LONG_TO_UINT(uint32_t, obj, result); } -int PyLong_AsUInt64(PyObject *obj, uint64_t *value) +int PyLong_AsUInt64(PyObject *obj, uint64_t *result) { - LONG_TO_UINT(obj, value, "C uint64_t"); + LONG_TO_UINT(uint64_t, obj, result); } diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index d92c7daff15dbf3..d695d8cac2fedab 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -103,13 +103,63 @@ _PyManagedBuffer_FromObject(PyObject *base, int flags) return (PyObject *)mbuf; } +static inline int +flags_set_released(int *flags, int released) +{ +#ifdef Py_GIL_DISABLED + int prev = _Py_atomic_load_int_relaxed(flags); + if (prev & released) { + return 1; + } + if (!_Py_atomic_compare_exchange_int(flags, &prev, prev | released)) { + // RELEASED is the only flag that can change concurrently. + assert(prev & released); + return 1; + } + return 0; +#else + int prev = *flags; + *flags = prev | released; + return (prev & released) != 0; +#endif +} + +static inline int +mv_get_flags(PyMemoryViewObject *mv) +{ + return FT_ATOMIC_LOAD_INT_RELAXED(mv->flags); +} + +static inline int +mv_has_flag(PyMemoryViewObject *mv, int bits) +{ + return (mv_get_flags(mv) & bits) != 0; +} + +static inline int +mv_set_released(PyMemoryViewObject *mv) +{ + return flags_set_released(&mv->flags, _Py_MEMORYVIEW_RELEASED); +} + +static inline int +mbuf_has_flag(_PyManagedBufferObject *mbuf, int bits) +{ + return (FT_ATOMIC_LOAD_INT(mbuf->flags) & bits) != 0; +} + +static inline int +mbuf_set_released(_PyManagedBufferObject *mbuf) +{ + return flags_set_released(&mbuf->flags, _Py_MANAGED_BUFFER_RELEASED); +} + static void mbuf_release(_PyManagedBufferObject *self) { - if (self->flags&_Py_MANAGED_BUFFER_RELEASED) + if (mbuf_set_released(self)) { return; - - self->flags |= _Py_MANAGED_BUFFER_RELEASED; + } /* PyBuffer_Release() decrements master->obj and sets it to NULL. */ _PyObject_GC_UNTRACK(self); @@ -120,9 +170,9 @@ static void mbuf_dealloc(PyObject *_self) { _PyManagedBufferObject *self = (_PyManagedBufferObject *)_self; - assert(self->exports == 0); + assert(FT_ATOMIC_LOAD_SSIZE_RELAXED(self->exports) == 0); mbuf_release(self); - if (self->flags&_Py_MANAGED_BUFFER_FREE_FORMAT) + if (mbuf_has_flag(self, _Py_MANAGED_BUFFER_FREE_FORMAT)) PyMem_Free(self->master.format); PyObject_GC_Del(self); } @@ -139,7 +189,7 @@ static int mbuf_clear(PyObject *_self) { _PyManagedBufferObject *self = (_PyManagedBufferObject *)_self; - assert(self->exports >= 0); + assert(FT_ATOMIC_LOAD_SSIZE_RELAXED(self->exports) >= 0); mbuf_release(self); return 0; } @@ -178,8 +228,8 @@ PyTypeObject _PyManagedBuffer_Type = { /* In the process of breaking reference cycles mbuf_release() can be called before memory_release(). */ #define BASE_INACCESSIBLE(mv) \ - (((PyMemoryViewObject *)mv)->flags&_Py_MEMORYVIEW_RELEASED || \ - ((PyMemoryViewObject *)mv)->mbuf->flags&_Py_MANAGED_BUFFER_RELEASED) + (mv_has_flag(_PyMemoryView_CAST(mv), _Py_MEMORYVIEW_RELEASED) || \ + mbuf_has_flag(_PyMemoryView_CAST(mv)->mbuf, _Py_MANAGED_BUFFER_RELEASED)) #define CHECK_RELEASED(mv) \ if (BASE_INACCESSIBLE(mv)) { \ @@ -196,17 +246,17 @@ PyTypeObject _PyManagedBuffer_Type = { } #define CHECK_RESTRICTED(mv) \ - if (((PyMemoryViewObject *)(mv))->flags & _Py_MEMORYVIEW_RESTRICTED) { \ - PyErr_SetString(PyExc_ValueError, \ - "cannot create new view on restricted memoryview"); \ - return NULL; \ + if (mv_has_flag(_PyMemoryView_CAST(mv), _Py_MEMORYVIEW_RESTRICTED)) { \ + PyErr_SetString(PyExc_ValueError, \ + "cannot create new view on restricted memoryview"); \ + return NULL; \ } #define CHECK_RESTRICTED_INT(mv) \ - if (((PyMemoryViewObject *)(mv))->flags & _Py_MEMORYVIEW_RESTRICTED) { \ - PyErr_SetString(PyExc_ValueError, \ - "cannot create new view on restricted memoryview"); \ - return -1; \ + if (mv_has_flag(_PyMemoryView_CAST(mv), _Py_MEMORYVIEW_RESTRICTED)) { \ + PyErr_SetString(PyExc_ValueError, \ + "cannot create new view on restricted memoryview"); \ + return -1; \ } /* See gh-92888. These macros signal that we need to check the memoryview @@ -699,7 +749,7 @@ mbuf_add_view(_PyManagedBufferObject *mbuf, const Py_buffer *src) init_flags(mv); mv->mbuf = (_PyManagedBufferObject*)Py_NewRef(mbuf); - mbuf->exports++; + FT_ATOMIC_ADD_SSIZE(mbuf->exports, 1); return (PyObject *)mv; } @@ -729,11 +779,79 @@ mbuf_add_incomplete_view(_PyManagedBufferObject *mbuf, const Py_buffer *src, init_shared_values(dest, src); mv->mbuf = (_PyManagedBufferObject*)Py_NewRef(mbuf); - mbuf->exports++; + FT_ATOMIC_ADD_SSIZE(mbuf->exports, 1); return (PyObject *)mv; } +#ifdef Py_GIL_DISABLED +static int +memoryview_add_export(PyMemoryViewObject *self) +{ + int result = 0; + + Py_BEGIN_CRITICAL_SECTION(self); + if (BASE_INACCESSIBLE(self)) { + PyErr_SetString(PyExc_ValueError, + "operation forbidden on released memoryview object"); + result = -1; + } + else { + FT_ATOMIC_ADD_SSIZE(self->exports, 1); + } + Py_END_CRITICAL_SECTION(); + + return result; +} +#endif + +static void +mbuf_drop_export(_PyManagedBufferObject *mbuf) +{ +#ifdef Py_GIL_DISABLED + Py_ssize_t prev_exports = _Py_atomic_add_ssize(&mbuf->exports, -1); +#else + Py_ssize_t prev_exports = mbuf->exports--; +#endif + assert(prev_exports > 0); + if (prev_exports == 1) { + mbuf_release(mbuf); + } +} + +/* Pin the managed buffer for the duration of an operation that reads + self->view. The pin is an export on the managed buffer, so a concurrent + or re-entrant release of this memoryview (or a tp_clear of it) cannot + free the underlying buffer while the operation is running. The pin does + not hold a reference to the managed buffer: the memoryview's own + reference is kept until memory_dealloc(), and the caller holds a + reference to the memoryview through memoryview_unpin(self). Return 0 + on success and -1 with an exception on failure. */ +static inline int +memoryview_pin(PyMemoryViewObject *self) +{ + if (mv_has_flag(self, _Py_MEMORYVIEW_RELEASED)) { + PyErr_SetString(PyExc_ValueError, + "operation forbidden on released memoryview object"); + return -1; + } + _PyManagedBufferObject *mbuf = self->mbuf; + FT_ATOMIC_ADD_SSIZE(mbuf->exports, 1); + if (BASE_INACCESSIBLE(self)) { + mbuf_drop_export(mbuf); + PyErr_SetString(PyExc_ValueError, + "operation forbidden on released memoryview object"); + return -1; + } + return 0; +} + +static inline void +memoryview_unpin(PyMemoryViewObject *self) +{ + mbuf_drop_export(self->mbuf); +} + /* Expose a raw memory area as a view of contiguous bytes. flags can be PyBUF_READ or PyBUF_WRITE. view->format is set to "B" (unsigned bytes). The memoryview has complete buffer information. */ @@ -804,9 +922,20 @@ PyMemoryView_FromObjectAndFlags(PyObject *v, int flags) if (PyMemoryView_Check(v)) { PyMemoryViewObject *mv = (PyMemoryViewObject *)v; - CHECK_RELEASED(mv); - CHECK_RESTRICTED(mv); - return mbuf_add_view(mv->mbuf, &mv->view); + if (memoryview_pin(mv) < 0) { + return NULL; + } + PyObject *result; + if (mv_has_flag(mv, _Py_MEMORYVIEW_RESTRICTED)) { + PyErr_SetString(PyExc_ValueError, + "cannot create new view on restricted memoryview"); + result = NULL; + } + else { + result = mbuf_add_view(mv->mbuf, &mv->view); + } + memoryview_unpin(mv); + return result; } else if (PyObject_CheckBuffer(v)) { PyObject *ret; @@ -1002,6 +1131,7 @@ PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char order) /*[clinic input] +@vectorcall @classmethod memoryview.__new__ @@ -1012,7 +1142,7 @@ Create a new memoryview object which references the given object. static PyObject * memoryview_impl(PyTypeObject *type, PyObject *object) -/*[clinic end generated code: output=7de78e184ed66db8 input=f04429eb0bdf8c6e]*/ +/*[clinic end generated code: output=7de78e184ed66db8 input=8e10a66aebe8e657]*/ { return PyMemoryView_FromObject(object); } @@ -1089,11 +1219,7 @@ PyBuffer_ToContiguous(void *buf, const Py_buffer *src, Py_ssize_t len, char orde static inline Py_ssize_t get_exports(PyMemoryViewObject *buf) { -#ifdef Py_GIL_DISABLED - return _Py_atomic_load_ssize_relaxed(&buf->exports); -#else - return buf->exports; -#endif + return FT_ATOMIC_LOAD_SSIZE_RELAXED(buf->exports); } @@ -1109,14 +1235,11 @@ static void _memory_release(PyMemoryViewObject *self) { assert(get_exports(self) == 0); - if (self->flags & _Py_MEMORYVIEW_RELEASED) + if (mv_set_released(self)) { return; - - self->flags |= _Py_MEMORYVIEW_RELEASED; - assert(self->mbuf->exports > 0); - if (--self->mbuf->exports == 0) { - mbuf_release(self->mbuf); } + + mbuf_drop_export(self->mbuf); } /*[clinic input] @@ -1129,22 +1252,26 @@ static PyObject * memoryview_release_impl(PyMemoryViewObject *self) /*[clinic end generated code: output=d0b7e3ba95b7fcb9 input=bc71d1d51f4a52f0]*/ { + PyObject *result = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); Py_ssize_t exports = get_exports(self); if (exports == 0) { _memory_release(self); - Py_RETURN_NONE; + result = Py_None; } - - if (exports > 0) { + else if (exports > 0) { PyErr_Format(PyExc_BufferError, "memoryview has %zd exported buffer%s", exports, - exports==1 ? "" : "s"); - return NULL; + exports == 1 ? "" : "s"); } + else { + PyErr_SetString(PyExc_SystemError, + "memoryview: negative export count"); + } + Py_END_CRITICAL_SECTION(); - PyErr_SetString(PyExc_SystemError, - "memoryview: negative export count"); - return NULL; + return result; } static void @@ -1174,8 +1301,11 @@ memory_clear(PyObject *_self) PyMemoryViewObject *self = (PyMemoryViewObject *)_self; if (get_exports(self) == 0) { _memory_release(self); - Py_CLEAR(self->mbuf); } + /* Keep the reference to self->mbuf until memory_dealloc(): an operation + that pinned the managed buffer may still be running (see + memoryview_pin()), and mbuf_clear() already breaks the managed + buffer's own reference cycle through the exporter. */ return 0; } @@ -1186,10 +1316,21 @@ memory_enter(PyObject *self, PyObject *args) return Py_NewRef(self); } +/*[clinic input] +memoryview.__exit__ + + *exc_info: array + +Release the underlying buffer exposed by the memoryview object. +[clinic start generated code]*/ + static PyObject * -memory_exit(PyObject *self, PyObject *args) +memoryview___exit___impl(PyMemoryViewObject *self, + PyObject * const *exc_info, + Py_ssize_t exc_info_length) +/*[clinic end generated code: output=c055c4c69baf495d input=881969146ff4d413]*/ { - return memoryview_release_impl((PyMemoryViewObject *)self); + return memoryview_release_impl(self); } @@ -1400,11 +1541,12 @@ copy_shape(Py_ssize_t *shape, const PyObject *seq, Py_ssize_t ndim, return len; } -/* Cast a 1-D array to a new shape. The result array will be C-contiguous. - If the result array does not have exactly the same byte length as the - input array, raise ValueError. */ +/* Cast a 1-D array to a new shape. The result array will be C-contiguous + ('C') or Fortran-contiguous ('F') according to 'order'. If the result + array does not have exactly the same byte length as the input array, raise + TypeError. */ static int -cast_to_ND(PyMemoryViewObject *mv, const PyObject *shape, int ndim) +cast_to_ND(PyMemoryViewObject *mv, const PyObject *shape, int ndim, char order) { Py_buffer *view = &mv->view; Py_ssize_t len; @@ -1425,7 +1567,10 @@ cast_to_ND(PyMemoryViewObject *mv, const PyObject *shape, int ndim) len = copy_shape(view->shape, shape, ndim, view->itemsize); if (len < 0) return -1; - init_strides_from_shape(view); + if (order == 'F') + init_fortran_strides_from_shape(view); + else + init_strides_from_shape(view); } if (view->len != len) { @@ -1464,19 +1609,9 @@ zero_in_shape(PyMemoryViewObject *mv) All casts must result in views that will have the exact byte size of the original input. Otherwise, an error is raised. */ -/*[clinic input] -memoryview.cast - - format: unicode - shape: object = NULL - -Cast a memoryview to a new format or shape. -[clinic start generated code]*/ - static PyObject * -memoryview_cast_impl(PyMemoryViewObject *self, PyObject *format, - PyObject *shape) -/*[clinic end generated code: output=bae520b3a389cbab input=138936cc9041b1a3]*/ +memoryview_cast_pinned(PyMemoryViewObject *self, PyObject *format, + PyObject *shape, int order) { PyMemoryViewObject *mv = NULL; Py_ssize_t ndim = 1; @@ -1484,11 +1619,19 @@ memoryview_cast_impl(PyMemoryViewObject *self, PyObject *format, CHECK_RELEASED(self); CHECK_RESTRICTED(self); - if (!MV_C_CONTIGUOUS(self->flags)) { - PyErr_SetString(PyExc_TypeError, - "memoryview: casts are restricted to C-contiguous views"); + if (order != 'C' && order != 'F') { + PyErr_SetString(PyExc_ValueError, "order must be 'C' or 'F'"); return NULL; } + + int self_flags = mv_get_flags(self); + if (!MV_C_CONTIGUOUS(self_flags)) { + if (shape || !MV_F_CONTIGUOUS(self_flags)) { + PyErr_SetString(PyExc_TypeError, + "memoryview: casts are restricted to contiguous views"); + return NULL; + } + } if ((shape || self->view.ndim != 1) && zero_in_shape(self)) { PyErr_SetString(PyExc_TypeError, "memoryview: cannot cast view with zeros in shape or strides"); @@ -1517,7 +1660,7 @@ memoryview_cast_impl(PyMemoryViewObject *self, PyObject *format, if (cast_to_1D(mv, format) < 0) goto error; - if (shape && cast_to_ND(mv, shape, (int)ndim) < 0) + if (shape && cast_to_ND(mv, shape, (int)ndim, (char)order) < 0) goto error; return (PyObject *)mv; @@ -1528,14 +1671,35 @@ memoryview_cast_impl(PyMemoryViewObject *self, PyObject *format, } /*[clinic input] -memoryview.toreadonly +memoryview.cast -Return a readonly version of the memoryview. + format: unicode + shape: object = NULL + * + order: int(accept={str}) = 'C' + +Cast a memoryview to a new format or shape. + +With a multidimensional *shape*, *order* selects the result +layout: 'C' for C-contiguous (row-major, the default) or 'F' +for Fortran-contiguous (column-major). [clinic start generated code]*/ static PyObject * -memoryview_toreadonly_impl(PyMemoryViewObject *self) -/*[clinic end generated code: output=2c7e056f04c99e62 input=dc06d20f19ba236f]*/ +memoryview_cast_impl(PyMemoryViewObject *self, PyObject *format, + PyObject *shape, int order) +/*[clinic end generated code: output=6410d87141f6bb56 input=4a1a2326c59caeb3]*/ +{ + if (memoryview_pin(self) < 0) { + return NULL; + } + PyObject *result = memoryview_cast_pinned(self, format, shape, order); + memoryview_unpin(self); + return result; +} + +static PyObject * +memoryview_toreadonly_pinned(PyMemoryViewObject *self) { CHECK_RELEASED(self); CHECK_RESTRICTED(self); @@ -1549,6 +1713,24 @@ memoryview_toreadonly_impl(PyMemoryViewObject *self) return (PyObject *) self; } +/*[clinic input] +memoryview.toreadonly + +Return a readonly version of the memoryview. +[clinic start generated code]*/ + +static PyObject * +memoryview_toreadonly_impl(PyMemoryViewObject *self) +/*[clinic end generated code: output=2c7e056f04c99e62 input=dc06d20f19ba236f]*/ +{ + if (memoryview_pin(self) < 0) { + return NULL; + } + PyObject *result = memoryview_toreadonly_pinned(self); + memoryview_unpin(self); + return result; +} + /**************************************************************************/ /* getbuffer */ @@ -1559,7 +1741,7 @@ memory_getbuf(PyObject *_self, Py_buffer *view, int flags) { PyMemoryViewObject *self = (PyMemoryViewObject *)_self; Py_buffer *base = &self->view; - int baseflags = self->flags; + int baseflags = mv_get_flags(self); CHECK_RELEASED_INT(self); CHECK_RESTRICTED_INT(self); @@ -1627,10 +1809,16 @@ memory_getbuf(PyObject *_self, Py_buffer *view, int flags) view->shape = NULL; } +#ifdef Py_GIL_DISABLED + /* memoryview_add_export() keeps the buffer alive or fails. */ + if (memoryview_add_export(self) < 0) { + return -1; + } +#else + self->exports++; +#endif view->obj = Py_NewRef(self); - FT_ATOMIC_ADD_SSIZE(self->exports, 1); - return 0; } @@ -2020,7 +2208,9 @@ pack_single(PyMemoryViewObject *self, char *ptr, PyObject *item, const char *fmt goto err_occurred; CHECK_RELEASED_INT_AGAIN(self); if (fmt[0] == 'f') { - PACK_SINGLE(ptr, d, float); + if (PyFloat_Pack4(d, ptr, endian) < 0) { + goto err_occurred; + } } else if (fmt[0] == 'd') { PACK_SINGLE(ptr, d, double); @@ -2047,9 +2237,15 @@ pack_single(PyMemoryViewObject *self, char *ptr, PyObject *item, const char *fmt memcpy(ptr, &x, sizeof(x)); } else { - float x[2] = {(float)c.real, (float)c.imag}; - - memcpy(ptr, &x, sizeof(x)); + char tmp[8]; + + if (PyFloat_Pack4(c.real, tmp, endian) < 0) { + goto err_occurred; + } + if (PyFloat_Pack4(c.imag, tmp + 4, endian) < 0) { + goto err_occurred; + } + memcpy(ptr, tmp, 8); } break; @@ -2305,15 +2501,8 @@ tolist_rec(PyMemoryViewObject *self, const char *ptr, Py_ssize_t ndim, const Py_ /* Return a list representation of the memoryview. Currently only buffers with native format strings are supported. */ -/*[clinic input] -memoryview.tolist - -Return the data in the buffer as a list of elements. -[clinic start generated code]*/ - static PyObject * -memoryview_tolist_impl(PyMemoryViewObject *self) -/*[clinic end generated code: output=a6cda89214fd5a1b input=21e7d0c1860b211a]*/ +memoryview_tolist_pinned(PyMemoryViewObject *self) { const Py_buffer *view = &self->view; const char *fmt; @@ -2339,23 +2528,26 @@ memoryview_tolist_impl(PyMemoryViewObject *self) } /*[clinic input] -memoryview.tobytes +memoryview.tolist - order: str(accept={str, NoneType}, c_default="NULL") = 'C' +Return the data in the buffer as a list of elements. +[clinic start generated code]*/ -Return the data in the buffer as a byte string. +static PyObject * +memoryview_tolist_impl(PyMemoryViewObject *self) +/*[clinic end generated code: output=a6cda89214fd5a1b input=21e7d0c1860b211a]*/ +{ + if (memoryview_pin(self) < 0) { + return NULL; + } + PyObject *result = memoryview_tolist_pinned(self); + memoryview_unpin(self); + return result; +} -Order can be {'C', 'F', 'A'}. When order is 'C' or 'F', the data of -the original array is converted to C or Fortran order. For -contiguous views, 'A' returns an exact copy of the physical memory. -In particular, in-memory Fortran order is preserved. For -non-contiguous views, the data is converted to C first. order=None -is the same as order='C'. -[clinic start generated code]*/ static PyObject * -memoryview_tobytes_impl(PyMemoryViewObject *self, const char *order) -/*[clinic end generated code: output=1288b62560a32a23 input=119c70aa91791dc8]*/ +memoryview_tobytes_pinned(PyMemoryViewObject *self, const char *order) { Py_buffer *src = VIEW_ADDR(self); char ord = 'C'; @@ -2390,6 +2582,75 @@ memoryview_tobytes_impl(PyMemoryViewObject *self, const char *order) return PyBytesWriter_Finish(writer); } +/*[clinic input] +memoryview.tobytes + + order: str(accept={str, NoneType}, c_default="NULL") = 'C' + +Return the data in the buffer as a byte string. + +Order can be {'C', 'F', 'A'}. When order is 'C' or 'F', the data of +the original array is converted to C or Fortran order. For +contiguous views, 'A' returns an exact copy of the physical memory. +In particular, in-memory Fortran order is preserved. For +non-contiguous views, the data is converted to C first. order=None +is the same as order='C'. +[clinic start generated code]*/ + +static PyObject * +memoryview_tobytes_impl(PyMemoryViewObject *self, const char *order) +/*[clinic end generated code: output=1288b62560a32a23 input=119c70aa91791dc8]*/ +{ + if (memoryview_pin(self) < 0) { + return NULL; + } + PyObject *result = memoryview_tobytes_pinned(self, order); + memoryview_unpin(self); + return result; +} + + +static PyObject * +memoryview_hex_pinned(PyMemoryViewObject *self, PyObject *sep, + Py_ssize_t bytes_per_sep) +{ + Py_buffer *src = VIEW_ADDR(self); + + CHECK_RELEASED(self); + + if (MV_C_CONTIGUOUS(mv_get_flags(self))) { + // Prevent 'self' from being freed if computing len(sep) mutates 'self' + // in _Py_strhex_with_sep(). + // See: https://github.com/python/cpython/issues/143195. +#ifdef Py_GIL_DISABLED + if (memoryview_add_export(self) < 0) { + return NULL; + } +#else + self->exports++; +#endif + PyObject *ret = _Py_strhex_with_sep(src->buf, src->len, sep, bytes_per_sep); + FT_ATOMIC_ADD_SSIZE(self->exports, -1); + return ret; + } + + char *buffer = PyMem_Malloc(src->len); + if (buffer == NULL) { + PyErr_NoMemory(); + return NULL; + } + + if (PyBuffer_ToContiguous(buffer, src, src->len, 'C') < 0) { + PyMem_Free(buffer); + return NULL; + } + + PyObject *ret = _Py_strhex_with_sep(buffer, src->len, sep, bytes_per_sep); + PyMem_Free(buffer); + + return ret; +} + /*[clinic input] memoryview.hex @@ -2418,45 +2679,20 @@ memoryview_hex_impl(PyMemoryViewObject *self, PyObject *sep, Py_ssize_t bytes_per_sep) /*[clinic end generated code: output=c9bb00c7a8e86056 input=3f1c5d08906e3b70]*/ { - Py_buffer *src = VIEW_ADDR(self); - - CHECK_RELEASED(self); - - if (MV_C_CONTIGUOUS(self->flags)) { - // Prevent 'self' from being freed if computing len(sep) mutates 'self' - // in _Py_strhex_with_sep(). - // See: https://github.com/python/cpython/issues/143195. - FT_ATOMIC_ADD_SSIZE(self->exports, 1); - PyObject *ret = _Py_strhex_with_sep(src->buf, src->len, sep, bytes_per_sep); - FT_ATOMIC_ADD_SSIZE(self->exports, -1); - return ret; - } - - PyBytesWriter *writer = PyBytesWriter_Create(src->len); - if (writer == NULL) { - return NULL; - } - - if (PyBuffer_ToContiguous(PyBytesWriter_GetData(writer), - src, src->len, 'C') < 0) { - PyBytesWriter_Discard(writer); + if (memoryview_pin(self) < 0) { return NULL; } - - PyObject *ret = _Py_strhex_with_sep( - PyBytesWriter_GetData(writer), - PyBytesWriter_GetSize(writer), - sep, bytes_per_sep); - PyBytesWriter_Discard(writer); - - return ret; + PyObject *result = memoryview_hex_pinned(self, sep, bytes_per_sep); + memoryview_unpin(self); + return result; } + static PyObject * memory_repr(PyObject *_self) { PyMemoryViewObject *self = (PyMemoryViewObject *)_self; - if (self->flags & _Py_MEMORYVIEW_RELEASED) + if (mv_has_flag(self, _Py_MEMORYVIEW_RELEASED)) return PyUnicode_FromFormat("", self); else return PyUnicode_FromFormat("", self); @@ -2529,9 +2765,9 @@ ptr_from_tuple(const Py_buffer *view, PyObject *tup) /* Return the item at index. In a one-dimensional view, this is an object with the type specified by view->format. Otherwise, the item is a sub-view. - The function is used in memory_subscript() and memory_as_sequence. */ + The function is used in memory_subscript_pinned() and by sq_item. */ static PyObject * -memory_item(PyObject *_self, Py_ssize_t index) +memory_item_pinned(PyObject *_self, Py_ssize_t index) { PyMemoryViewObject *self = (PyMemoryViewObject *)_self; Py_buffer *view = &(self->view); @@ -2657,7 +2893,7 @@ is_multiindex(PyObject *key) 0-d memoryview objects can be referenced using mv[...] or mv[()] but not with anything else. */ static PyObject * -memory_subscript(PyObject *_self, PyObject *key) +memory_subscript_pinned(PyObject *_self, PyObject *key) { PyMemoryViewObject *self = (PyMemoryViewObject *)_self; Py_buffer *view; @@ -2687,7 +2923,7 @@ memory_subscript(PyObject *_self, PyObject *key) index = PyNumber_AsSsize_t(key, PyExc_IndexError); if (index == -1 && PyErr_Occurred()) return NULL; - return memory_item((PyObject *)self, index); + return memory_item_pinned((PyObject *)self, index); } else if (PySlice_Check(key)) { CHECK_RESTRICTED(self); @@ -2720,7 +2956,7 @@ memory_subscript(PyObject *_self, PyObject *key) } static int -memory_ass_sub(PyObject *_self, PyObject *key, PyObject *value) +memory_ass_sub_pinned(PyObject *_self, PyObject *key, PyObject *value) { PyMemoryViewObject *self = (PyMemoryViewObject *)_self; Py_buffer *view = &(self->view); @@ -2810,7 +3046,7 @@ memory_ass_sub(PyObject *_self, PyObject *key, PyObject *value) return pack_single(self, ptr, value, fmt); } if (PySlice_Check(key) || is_multislice(key)) { - /* Call memory_subscript() to produce a sliced lvalue, then copy + /* Call memory_subscript_pinned() to produce a sliced lvalue, then copy rvalue into lvalue. This is already implemented in _testbuffer.c. */ PyErr_SetString(PyExc_NotImplementedError, "memoryview slice assignments are currently restricted " @@ -2834,6 +3070,42 @@ memory_length(PyObject *_self) return self->view.shape[0]; } +static PyObject * +memory_item(PyObject *_self, Py_ssize_t index) +{ + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; + if (memoryview_pin(self) < 0) { + return NULL; + } + PyObject *result = memory_item_pinned(_self, index); + memoryview_unpin(self); + return result; +} + +static PyObject * +memory_subscript(PyObject *_self, PyObject *key) +{ + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; + if (memoryview_pin(self) < 0) { + return NULL; + } + PyObject *result = memory_subscript_pinned(_self, key); + memoryview_unpin(self); + return result; +} + +static int +memory_ass_sub(PyObject *_self, PyObject *key, PyObject *value) +{ + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; + if (memoryview_pin(self) < 0) { + return -1; + } + int result = memory_ass_sub_pinned(_self, key, value); + memoryview_unpin(self); + return result; +} + /* As mapping */ static PyMappingMethods memory_as_mapping = { memory_length, /* mp_length */ @@ -2854,18 +3126,8 @@ static PySequenceMethods memory_as_sequence = { /* Counting */ /****************************************************************************/ -/*[clinic input] -memoryview.count - - value: object - / - -Count the number of occurrences of a value. -[clinic start generated code]*/ - static PyObject * -memoryview_count_impl(PyMemoryViewObject *self, PyObject *value) -/*[clinic end generated code: output=a15cb19311985063 input=e3036ce1ed7d1823]*/ +memoryview_count_pinned(PyMemoryViewObject *self, PyObject *value) { PyObject *iter = PyObject_GetIter(_PyObject_CAST(self)); if (iter == NULL) { @@ -2898,28 +3160,36 @@ memoryview_count_impl(PyMemoryViewObject *self, PyObject *value) return PyLong_FromSsize_t(count); } - -/**************************************************************************/ -/* Lookup */ -/**************************************************************************/ - /*[clinic input] -memoryview.index +memoryview.count value: object - start: slice_index(accept={int}) = 0 - stop: slice_index(accept={int}, c_default="PY_SSIZE_T_MAX") = sys.maxsize / -Return the index of the first occurrence of a value. - -Raises ValueError if the value is not present. +Count the number of occurrences of a value. [clinic start generated code]*/ static PyObject * -memoryview_index_impl(PyMemoryViewObject *self, PyObject *value, - Py_ssize_t start, Py_ssize_t stop) -/*[clinic end generated code: output=e0185e3819e549df input=0697a0165bf90b5a]*/ +memoryview_count_impl(PyMemoryViewObject *self, PyObject *value) +/*[clinic end generated code: output=a15cb19311985063 input=e3036ce1ed7d1823]*/ +{ + if (memoryview_pin(self) < 0) { + return NULL; + } + PyObject *result = memoryview_count_pinned(self, value); + memoryview_unpin(self); + return result; +} + + + +/**************************************************************************/ +/* Lookup */ +/**************************************************************************/ + +static PyObject * +memoryview_index_pinned(PyMemoryViewObject *self, PyObject *value, + Py_ssize_t start, Py_ssize_t stop) { const Py_buffer *view = &self->view; CHECK_RELEASED(self); @@ -2956,7 +3226,7 @@ memoryview_index_impl(PyMemoryViewObject *self, PyObject *value, // entire loop. assert(index < n); - PyObject *item = memory_item(obj, index); + PyObject *item = memory_item_pinned(obj, index); if (item == NULL) { return NULL; } @@ -2984,6 +3254,32 @@ memoryview_index_impl(PyMemoryViewObject *self, PyObject *value, } +/*[clinic input] +memoryview.index + + value: object + start: slice_index(accept={int}) = 0 + stop: slice_index(accept={int}, c_default="PY_SSIZE_T_MAX") = sys.maxsize + / + +Return the index of the first occurrence of a value. + +Raises ValueError if the value is not present. +[clinic start generated code]*/ + +static PyObject * +memoryview_index_impl(PyMemoryViewObject *self, PyObject *value, + Py_ssize_t start, Py_ssize_t stop) +/*[clinic end generated code: output=e0185e3819e549df input=0697a0165bf90b5a]*/ +{ + if (memoryview_pin(self) < 0) { + return NULL; + } + PyObject *result = memoryview_index_pinned(self, value, start, stop); + memoryview_unpin(self); + return result; +} + /**************************************************************************/ /* Comparisons */ @@ -3199,7 +3495,7 @@ cmp_rec(const char *p, const char *q, } static PyObject * -memory_richcompare(PyObject *v, PyObject *w, int op) +memory_richcompare_pinned(PyObject *v, PyObject *w, int op) { PyObject *res; Py_buffer wbuf, *vv; @@ -3325,15 +3621,44 @@ memory_richcompare(PyObject *v, PyObject *w, int op) return Py_XNewRef(res); } +static PyObject * +memory_richcompare(PyObject *v, PyObject *w, int op) +{ + PyMemoryViewObject *self = (PyMemoryViewObject *)v; + if (memoryview_pin(self) < 0) { + /* Released memoryviews still compare by identity. */ + PyErr_Clear(); + return memory_richcompare_pinned(v, w, op); + } + + PyMemoryViewObject *other = NULL; + if (PyMemoryView_Check(w) && w != v) { + other = (PyMemoryViewObject *)w; + if (memoryview_pin(other) < 0) { + PyErr_Clear(); + memoryview_unpin(self); + return memory_richcompare_pinned(v, w, op); + } + } + + PyObject *result = memory_richcompare_pinned(v, w, op); + if (other != NULL) { + memoryview_unpin(other); + } + memoryview_unpin(self); + return result; +} + /**************************************************************************/ /* Hash */ /**************************************************************************/ static Py_hash_t -memory_hash(PyObject *_self) +memory_hash_pinned(PyObject *_self) { PyMemoryViewObject *self = (PyMemoryViewObject *)_self; - if (self->hash == -1) { + Py_hash_t hash = FT_ATOMIC_LOAD_SSIZE_RELAXED(self->hash); + if (hash == -1) { Py_buffer *view = &self->view; char *mem = view->buf; Py_ssize_t ret; @@ -3355,7 +3680,13 @@ memory_hash(PyObject *_self) if (view->obj != NULL) { // Prevent 'self' from being freed when computing the item's hash. // See https://github.com/python/cpython/issues/142664. - FT_ATOMIC_ADD_SSIZE(self->exports, 1); +#ifdef Py_GIL_DISABLED + if (memoryview_add_export(self) < 0) { + return -1; + } +#else + self->exports++; +#endif Py_hash_t h = PyObject_Hash(view->obj); FT_ATOMIC_ADD_SSIZE(self->exports, -1); if (h == -1) { @@ -3364,7 +3695,7 @@ memory_hash(PyObject *_self) } } - if (!MV_C_CONTIGUOUS(self->flags)) { + if (!MV_C_CONTIGUOUS(mv_get_flags(self))) { mem = PyMem_Malloc(view->len); if (mem == NULL) { PyErr_NoMemory(); @@ -3377,13 +3708,30 @@ memory_hash(PyObject *_self) } /* Can't fail */ - self->hash = Py_HashBuffer(mem, view->len); + hash = Py_HashBuffer(mem, view->len); + FT_ATOMIC_STORE_SSIZE_RELAXED(self->hash, hash); if (mem != view->buf) PyMem_Free(mem); } - return self->hash; + return hash; +} + +static Py_hash_t +memory_hash(PyObject *_self) +{ + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; + Py_hash_t hash = FT_ATOMIC_LOAD_SSIZE_RELAXED(self->hash); + if (hash != -1) { + return hash; + } + if (memoryview_pin(self) < 0) { + return -1; + } + Py_hash_t result = memory_hash_pinned(_self); + memoryview_unpin(self); + return result; } @@ -3416,7 +3764,7 @@ _IntTupleFromSsizet(int len, Py_ssize_t *vals) } static PyObject * -memory_obj_get(PyObject *_self, void *Py_UNUSED(ignored)) +memory_obj_get_pinned(PyObject *_self, void *Py_UNUSED(ignored)) { PyMemoryViewObject *self = (PyMemoryViewObject *)_self; Py_buffer *view = &self->view; @@ -3437,7 +3785,7 @@ memory_nbytes_get(PyObject *_self, void *Py_UNUSED(ignored)) } static PyObject * -memory_format_get(PyObject *_self, void *Py_UNUSED(ignored)) +memory_format_get_pinned(PyObject *_self, void *Py_UNUSED(ignored)) { PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED(self); @@ -3497,7 +3845,7 @@ memory_c_contiguous(PyObject *_self, void *Py_UNUSED(ignored)) { PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED(self); - return PyBool_FromLong(MV_C_CONTIGUOUS(self->flags)); + return PyBool_FromLong(MV_C_CONTIGUOUS(mv_get_flags(self))); } static PyObject * @@ -3505,7 +3853,7 @@ memory_f_contiguous(PyObject *_self, void *Py_UNUSED(ignored)) { PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED(self); - return PyBool_FromLong(MV_F_CONTIGUOUS(self->flags)); + return PyBool_FromLong(MV_F_CONTIGUOUS(mv_get_flags(self))); } static PyObject * @@ -3513,9 +3861,27 @@ memory_contiguous(PyObject *_self, void *Py_UNUSED(ignored)) { PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED(self); - return PyBool_FromLong(MV_ANY_CONTIGUOUS(self->flags)); + return PyBool_FromLong(MV_ANY_CONTIGUOUS(mv_get_flags(self))); } +#define MEMORYVIEW_PINNED_GETTER(name) \ + static PyObject * \ + name(PyObject *_self, void *ignored) \ + { \ + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; \ + if (memoryview_pin(self) < 0) { \ + return NULL; \ + } \ + PyObject *result = name##_pinned(_self, ignored); \ + memoryview_unpin(self); \ + return result; \ + } + +MEMORYVIEW_PINNED_GETTER(memory_obj_get) +MEMORYVIEW_PINNED_GETTER(memory_format_get) + +#undef MEMORYVIEW_PINNED_GETTER + PyDoc_STRVAR(memory_obj_doc, "The underlying object of the memoryview."); PyDoc_STRVAR(memory_nbytes_doc, @@ -3545,11 +3911,6 @@ PyDoc_STRVAR(memory_f_contiguous_doc, "A bool indicating whether the memory is Fortran contiguous."); PyDoc_STRVAR(memory_contiguous_doc, "A bool indicating whether the memory is contiguous."); -PyDoc_STRVAR(memory_exit_doc, - "__exit__($self, /, *exc_info)\n--\n\n" - "Release the underlying buffer exposed by the memoryview object."); - - static PyGetSetDef memory_getsetlist[] = { {"obj", memory_obj_get, NULL, memory_obj_doc}, {"nbytes", memory_nbytes_get, NULL, memory_nbytes_doc}, @@ -3578,7 +3939,7 @@ static PyMethodDef memory_methods[] = { MEMORYVIEW_COUNT_METHODDEF MEMORYVIEW_INDEX_METHODDEF {"__enter__", memory_enter, METH_NOARGS, NULL}, - {"__exit__", memory_exit, METH_VARARGS, memory_exit_doc}, + MEMORYVIEW___EXIT___METHODDEF {"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("memoryviews are generic over the type of their underlying data")}, {NULL, NULL} @@ -3620,31 +3981,61 @@ memoryiter_next(PyObject *self) { memoryiterobject *it = (memoryiterobject *)self; PyMemoryViewObject *seq; + Py_ssize_t index; + + Py_BEGIN_CRITICAL_SECTION(it); seq = it->it_seq; - if (seq == NULL) { + index = it->it_index; + if (seq != NULL) { + if (index >= it->it_length) { + /* Transfer the iterator's reference to seq before clearing it. */ + it->it_seq = NULL; + } + else { + Py_INCREF(seq); + } + } + Py_END_CRITICAL_SECTION(); + + if (seq == NULL || index >= it->it_length) { + Py_XDECREF(seq); return NULL; } - if (it->it_index < it->it_length) { - CHECK_RELEASED(seq); - Py_buffer *view = &(seq->view); - char *ptr = (char *)seq->view.buf; + /* Pin outside the iterator lock: a failed pin may release the buffer. */ + if (memoryview_pin(seq) < 0) { + Py_DECREF(seq); + return NULL; + } - ptr += view->strides[0] * it->it_index++; - ptr = ADJUST_PTR(ptr, view->suboffsets, 0); - if (ptr == NULL) { - return NULL; - } - return unpack_single(seq, ptr, it->it_fmt); + Py_BEGIN_CRITICAL_SECTION(it); + index = it->it_index; + if (index < it->it_length) { + it->it_index = index + 1; + } + Py_END_CRITICAL_SECTION(); + if (index >= it->it_length) { + memoryview_unpin(seq); + Py_DECREF(seq); + return NULL; } - it->it_seq = NULL; + Py_buffer *view = &seq->view; + char *ptr = (char *)view->buf; + + ptr += view->strides[0] * index; + ptr = ADJUST_PTR(ptr, view->suboffsets, 0); + PyObject *result = NULL; + if (ptr != NULL) { + result = unpack_single(seq, ptr, it->it_fmt); + } + memoryview_unpin(seq); Py_DECREF(seq); - return NULL; + return result; } static PyObject * -memory_iter(PyObject *seq) +memory_iter_pinned(PyObject *seq) { if (!PyMemoryView_Check(seq)) { PyErr_BadInternalCall(); @@ -3681,6 +4072,18 @@ memory_iter(PyObject *seq) return (PyObject *)it; } +static PyObject * +memory_iter(PyObject *seq) +{ + PyMemoryViewObject *self = (PyMemoryViewObject *)seq; + if (memoryview_pin(self) < 0) { + return NULL; + } + PyObject *result = memory_iter_pinned(seq); + memoryview_unpin(self); + return result; +} + PyTypeObject _PyMemoryIter_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) .tp_name = "memory_iterator", @@ -3734,4 +4137,5 @@ PyTypeObject PyMemoryView_Type = { 0, /* tp_init */ 0, /* tp_alloc */ memoryview, /* tp_new */ + .tp_vectorcall = memoryview_vectorcall, }; diff --git a/Objects/methodobject.c b/Objects/methodobject.c index e6e469ca270ac96..9b37b1da95bb501 100644 --- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -48,8 +48,7 @@ PyCMethod_New(PyMethodDef *ml, PyObject *self, PyObject *module, PyTypeObject *c { /* Figure out correct vectorcall function to use */ vectorcallfunc vectorcall; - switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | - METH_O | METH_KEYWORDS | METH_METHOD)) + switch (ml->ml_flags & _Py_METH_CALL_FLAGS) { case METH_VARARGS: case METH_VARARGS | METH_KEYWORDS: diff --git a/Objects/mimalloc/alloc-aligned.c b/Objects/mimalloc/alloc-aligned.c index 4c15f4043ec117f..56210bfb28469ad 100644 --- a/Objects/mimalloc/alloc-aligned.c +++ b/Objects/mimalloc/alloc-aligned.c @@ -15,118 +15,208 @@ terms of the MIT license. A copy of the license can be found in the file // Aligned Allocation // ------------------------------------------------------ -// Fallback primitive aligned allocation -- split out for better codegen -static mi_decl_noinline void* mi_heap_malloc_zero_aligned_at_fallback(mi_heap_t* const heap, const size_t size, const size_t alignment, const size_t offset, const bool zero) mi_attr_noexcept -{ - mi_assert_internal(size <= PTRDIFF_MAX); - mi_assert_internal(alignment != 0 && _mi_is_power_of_two(alignment)); - - const uintptr_t align_mask = alignment - 1; // for any x, `(x & align_mask) == (x % alignment)` - const size_t padsize = size + MI_PADDING_SIZE; +static bool mi_malloc_is_naturally_aligned( size_t size, size_t alignment ) { + // objects up to `MI_MAX_ALIGN_GUARANTEE` are allocated aligned to their size (see `segment.c:_mi_segment_page_start`). + mi_assert_internal(mi_alignment_is_valid(alignment)); + if (alignment > size) return false; + if (alignment <= MI_MAX_ALIGN_SIZE) return true; + const size_t bsize = mi_good_size(size); + return (bsize <= MI_MAX_ALIGN_GUARANTEE && (bsize & (alignment-1)) == 0); +} - // use regular allocation if it is guaranteed to fit the alignment constraints - if (offset==0 && alignment<=padsize && padsize<=MI_MAX_ALIGN_GUARANTEE && (padsize&align_mask)==0) { - void* p = _mi_heap_malloc_zero(heap, size, zero); - mi_assert_internal(p == NULL || ((uintptr_t)p % alignment) == 0); - return p; +#if MI_GUARDED +static mi_decl_noinline mi_decl_restrict void* mi_heap_malloc_guarded_aligned(mi_heap_t* heap, size_t size, size_t alignment, bool zero, mi_page_t** ppage) mi_attr_noexcept { + // use over allocation for guarded blocksl + mi_assert_internal(alignment > 0 && alignment < MI_BLOCK_ALIGNMENT_MAX); + if mi_unlikely(alignment >= MI_BLOCK_ALIGNMENT_MAX || size > (MI_MAX_ALLOC_SIZE - MI_PADDING_SIZE - alignment)) { + _mi_error_message(EOVERFLOW, "(guarded) aligned allocation request is too large (size %zu, alignment %zu)\n", size, alignment); + return NULL; } + const size_t oversize = size + alignment - 1; + void* const base = _mi_heap_malloc_guarded(heap, oversize, zero, ppage); + if (base==NULL) return NULL; + void* const p = _mi_align_up_ptr(base, alignment); + mi_track_align(base, p, (uint8_t*)p - (uint8_t*)base, size); + mi_assert_internal(mi_usable_size(p) >= size); + mi_assert_internal(_mi_is_aligned(p, alignment)); + return p; +} + +static void* mi_heap_malloc_zero_no_guarded(mi_heap_t* heap, size_t size, bool zero, mi_page_t** ppage) { + const size_t rate = heap->guarded_sample_rate; + // only write if `rate!=0` so we don't write to the constant `_mi_heap_empty` + if (rate != 0) { heap->guarded_sample_rate = 0; } + void* p = _mi_heap_malloc_zero_ex(heap, size, zero, 0, ppage); + if (rate != 0) { heap->guarded_sample_rate = rate; } + return p; +} +#else +static void* mi_heap_malloc_zero_no_guarded(mi_heap_t* heap, size_t size, bool zero, mi_page_t** ppage) { + return _mi_heap_malloc_zero_ex(heap, size, zero, 0, ppage); +} +#endif + +// Fallback aligned allocation that over-allocates -- split out for better codegen +static mi_decl_noinline void* mi_heap_malloc_zero_aligned_at_overalloc(mi_heap_t* const heap, const size_t size, const size_t alignment, const size_t offset, const bool zero, mi_page_t** ppage) mi_attr_noexcept +{ + mi_assert_internal(size <= (MI_MAX_ALLOC_SIZE - MI_PADDING_SIZE)); + mi_assert_internal(mi_alignment_is_valid(alignment)); void* p; size_t oversize; - if mi_unlikely(alignment > MI_ALIGNMENT_MAX) { + mi_page_t* page; + if mi_unlikely(alignment > MI_BLOCK_ALIGNMENT_MAX) { // use OS allocation for very large alignment and allocate inside a huge page (dedicated segment with 1 page) // This can support alignments >= MI_SEGMENT_SIZE by ensuring the object can be aligned at a point in the // first (and single) page such that the segment info is `MI_SEGMENT_SIZE` bytes before it (so it can be found by aligning the pointer down) if mi_unlikely(offset != 0) { // todo: cannot support offset alignment for very large alignments yet - #if MI_DEBUG > 0 _mi_error_message(EOVERFLOW, "aligned allocation with a very large alignment cannot be used with an alignment offset (size %zu, alignment %zu, offset %zu)\n", size, alignment, offset); - #endif return NULL; } oversize = (size <= MI_SMALL_SIZE_MAX ? MI_SMALL_SIZE_MAX + 1 /* ensure we use generic malloc path */ : size); - p = _mi_heap_malloc_zero_ex(heap, oversize, false, alignment); // the page block size should be large enough to align in the single huge page block + // note: no guarded as alignment > 0 + p = _mi_heap_malloc_zero_ex(heap, oversize, false, alignment, &page); // the page block size should be large enough to align in the single huge page block // zero afterwards as only the area from the aligned_p may be committed! if (p == NULL) return NULL; } else { // otherwise over-allocate - oversize = size + alignment - 1; - p = _mi_heap_malloc_zero(heap, oversize, zero); + mi_assert_internal(size <= (MI_MAX_ALLOC_SIZE - MI_PADDING_SIZE) && alignment <= MI_BLOCK_ALIGNMENT_MAX); + mi_assert_internal(size < SIZE_MAX - alignment); // `oversize` cannot overflow + oversize = (size < MI_MAX_ALIGN_SIZE ? MI_MAX_ALIGN_SIZE : size) + alignment - 1; // adjust for size <= 16; with size 0 and alignment 64k, we would allocate a 64k block and pointing just beyond that. + p = mi_heap_malloc_zero_no_guarded(heap, oversize, zero, &page); if (p == NULL) return NULL; } + mi_assert_internal(page == _mi_ptr_page(p)); + if (ppage!=NULL) { *ppage = page; } // .. and align within the allocation + const uintptr_t align_mask = alignment - 1; // for any x, `(x & align_mask) == (x % alignment)` const uintptr_t poffset = ((uintptr_t)p + offset) & align_mask; const uintptr_t adjust = (poffset == 0 ? 0 : alignment - poffset); mi_assert_internal(adjust < alignment); void* aligned_p = (void*)((uintptr_t)p + adjust); if (aligned_p != p) { - mi_page_t* page = _mi_ptr_page(p); mi_page_set_has_aligned(page, true); + // if (pblock_size!=NULL) { + // mi_assert_internal(*pblock_size > adjust); + // if (*pblock_size > adjust) { *pblock_size = *pblock_size - adjust; } + // mi_assert_internal(*pblock_size >= size); + // } + #if MI_GUARDED + // set tag to aligned so mi_usable_size works with guard pages + if (adjust >= sizeof(mi_block_t)) { + mi_block_t* const block = (mi_block_t*)p; + block->next = MI_BLOCK_TAG_ALIGNED; + } + #endif _mi_padding_shrink(page, (mi_block_t*)p, adjust + size); } // todo: expand padding if overallocated ? - mi_assert_internal(mi_page_usable_block_size(_mi_ptr_page(p)) >= adjust + size); - mi_assert_internal(p == _mi_page_ptr_unalign(_mi_ptr_segment(aligned_p), _mi_ptr_page(aligned_p), aligned_p)); + mi_assert_internal(mi_page_usable_block_size(page) >= adjust + size); mi_assert_internal(((uintptr_t)aligned_p + offset) % alignment == 0); mi_assert_internal(mi_usable_size(aligned_p)>=size); mi_assert_internal(mi_usable_size(p) == mi_usable_size(aligned_p)+adjust); + #if MI_DEBUG > 1 + mi_page_t* const apage = _mi_ptr_page(aligned_p); + void* unalign_p = _mi_page_ptr_unalign(apage, aligned_p); + mi_assert_internal(p == unalign_p); + #endif // now zero the block if needed - if (alignment > MI_ALIGNMENT_MAX) { - // for the tracker, on huge aligned allocations only from the start of the large block is defined + if (alignment > MI_BLOCK_ALIGNMENT_MAX) { + // for the tracker, on huge aligned allocations only the memory from the start of the large block is defined mi_track_mem_undefined(aligned_p, size); if (zero) { - _mi_memzero_aligned(aligned_p, mi_usable_size(aligned_p)); + _mi_memzero(aligned_p, mi_usable_size(aligned_p)); // cannot be aligned due to abitrary offset... (todo: require offset to be a multiple of sizeof(void*)?) } } if (p != aligned_p) { mi_track_align(p,aligned_p,adjust,mi_usable_size(aligned_p)); + #if MI_GUARDED + mi_track_mem_defined(p, sizeof(mi_block_t)); + #endif } return aligned_p; } +// Generic primitive aligned allocation -- split out for better codegen +static mi_decl_noinline void* mi_heap_malloc_zero_aligned_at_generic(mi_heap_t* const heap, const size_t size, const size_t alignment, const size_t offset, const bool zero, mi_page_t** ppage) mi_attr_noexcept +{ + mi_assert_internal(mi_alignment_is_valid(alignment)); + // we don't allocate more than MI_MAX_ALLOC_SIZE (see ) + if mi_unlikely(size > (MI_MAX_ALLOC_SIZE - MI_PADDING_SIZE)) { + _mi_error_message(EINVAL, "aligned allocation request is too large (size %zu, alignment %zu)\n", size, alignment); + return NULL; + } + + // use regular allocation if it is guaranteed to fit the alignment constraints. + // this is important to try as the fast path in `mi_heap_malloc_zero_aligned` only works when there exist + // a page with the right block size, and if we always use the over-alloc fallback that would never happen. + if (offset == 0 && mi_malloc_is_naturally_aligned(size,alignment)) { + void* p = mi_heap_malloc_zero_no_guarded(heap, size, zero, ppage); + mi_assert_internal(p == NULL || ((uintptr_t)p % alignment) == 0); + const bool is_aligned_or_null = (((uintptr_t)p) & (alignment-1))==0; + if mi_likely(is_aligned_or_null) { + return p; + } + else { + // this should never happen if the `mi_malloc_is_naturally_aligned` check is correct.. + mi_assert(false); + mi_free(p); + } + } + + // fall back to over-allocation + return mi_heap_malloc_zero_aligned_at_overalloc(heap,size,alignment,offset,zero,ppage); +} + + +static mi_decl_cold mi_decl_noinline void* mi_error_bad_alignment(size_t size, size_t alignment, size_t offset) { + _mi_error_message(EINVAL, "aligned allocation requires the alignment to be a power-of-two (size %zu, alignment %zu, offset %zu)\n", size, alignment, offset); + return NULL; +} + // Primitive aligned allocation -static void* mi_heap_malloc_zero_aligned_at(mi_heap_t* const heap, const size_t size, const size_t alignment, const size_t offset, const bool zero) mi_attr_noexcept +static void* mi_heap_malloc_zero_aligned_at(mi_heap_t* const heap, const size_t size, + const size_t alignment, const size_t offset, const bool zero, + mi_page_t** ppage) mi_attr_noexcept { // note: we don't require `size > offset`, we just guarantee that the address at offset is aligned regardless of the allocated size. - if mi_unlikely(alignment == 0 || !_mi_is_power_of_two(alignment)) { // require power-of-two (see ) - #if MI_DEBUG > 0 - _mi_error_message(EOVERFLOW, "aligned allocation requires the alignment to be a power-of-two (size %zu, alignment %zu)\n", size, alignment); - #endif - return NULL; + if mi_unlikely(!mi_alignment_is_valid(alignment)) { // require power-of-two and multiple of void* (see ) + return mi_error_bad_alignment(size, alignment, offset); } - if mi_unlikely(size > PTRDIFF_MAX) { // we don't allocate more than PTRDIFF_MAX (see ) - #if MI_DEBUG > 0 - _mi_error_message(EOVERFLOW, "aligned allocation request is too large (size %zu, alignment %zu)\n", size, alignment); - #endif - return NULL; + #if MI_GUARDED + if (offset==0 && alignment < MI_BLOCK_ALIGNMENT_MAX && mi_heap_malloc_use_guarded(heap,size)) { + return mi_heap_malloc_guarded_aligned(heap, size, alignment, zero, ppage); } - const uintptr_t align_mask = alignment-1; // for any x, `(x & align_mask) == (x % alignment)` - const size_t padsize = size + MI_PADDING_SIZE; // note: cannot overflow due to earlier size > PTRDIFF_MAX check + #endif // try first if there happens to be a small block available with just the right alignment - if mi_likely(padsize <= MI_SMALL_SIZE_MAX && alignment <= padsize) { + if mi_likely(size <= MI_SMALL_SIZE_MAX && alignment <= size) { + const uintptr_t align_mask = alignment-1; // for any x, `(x & align_mask) == (x % alignment)` + const size_t padsize = size + MI_PADDING_SIZE; mi_page_t* page = _mi_heap_get_free_small_page(heap, padsize); - const bool is_aligned = (((uintptr_t)page->free+offset) & align_mask)==0; - if mi_likely(page->free != NULL && is_aligned) - { - #if MI_STAT>1 - mi_heap_stat_increase(heap, malloc, size); - #endif - void* p = _mi_page_malloc(heap, page, padsize, zero); // TODO: inline _mi_page_malloc - mi_assert_internal(p != NULL); - mi_assert_internal(((uintptr_t)p + offset) % alignment == 0); - mi_track_malloc(p,size,zero); - return p; + if mi_likely(page->free != NULL) { + const bool is_aligned = (((uintptr_t)page->free + offset) & align_mask)==0; + if mi_likely(is_aligned) + { + if (ppage!=NULL) { *ppage = page; } + void* p = (zero ? _mi_page_malloc_zeroed(heap,page,padsize) : _mi_page_malloc(heap,page,padsize)); // call specific page malloc for better codegen + mi_assert_internal(p != NULL); + mi_assert_internal(((uintptr_t)p + offset) % alignment == 0); + mi_track_malloc(p,size,zero); + return p; + } } } - // fallback - return mi_heap_malloc_zero_aligned_at_fallback(heap, size, alignment, offset, zero); + + // fallback to generic aligned allocation + return mi_heap_malloc_zero_aligned_at_generic(heap, size, alignment, offset, zero, ppage); } @@ -135,31 +225,16 @@ static void* mi_heap_malloc_zero_aligned_at(mi_heap_t* const heap, const size_t // ------------------------------------------------------ mi_decl_nodiscard mi_decl_restrict void* mi_heap_malloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset) mi_attr_noexcept { - return mi_heap_malloc_zero_aligned_at(heap, size, alignment, offset, false); + return mi_heap_malloc_zero_aligned_at(heap, size, alignment, offset, false, NULL); } mi_decl_nodiscard mi_decl_restrict void* mi_heap_malloc_aligned(mi_heap_t* heap, size_t size, size_t alignment) mi_attr_noexcept { - if mi_unlikely(alignment == 0 || !_mi_is_power_of_two(alignment)) return NULL; - #if !MI_PADDING - // without padding, any small sized allocation is naturally aligned (see also `_mi_segment_page_start`) - if mi_likely(_mi_is_power_of_two(size) && size >= alignment && size <= MI_SMALL_SIZE_MAX) - #else - // with padding, we can only guarantee this for fixed alignments - if mi_likely((alignment == sizeof(void*) || (alignment == MI_MAX_ALIGN_SIZE && size > (MI_MAX_ALIGN_SIZE/2))) - && size <= MI_SMALL_SIZE_MAX) - #endif - { - // fast path for common alignment and size - return mi_heap_malloc_small(heap, size); - } - else { - return mi_heap_malloc_aligned_at(heap, size, alignment, 0); - } + return mi_heap_malloc_aligned_at(heap, size, alignment, 0); } // ensure a definition is emitted #if defined(__cplusplus) -static void* _mi_heap_malloc_aligned = (void*)&mi_heap_malloc_aligned; +void* _mi_extern_heap_malloc_aligned = (void*)&mi_heap_malloc_aligned; #endif // ------------------------------------------------------ @@ -167,7 +242,7 @@ static void* _mi_heap_malloc_aligned = (void*)&mi_heap_malloc_aligned; // ------------------------------------------------------ mi_decl_nodiscard mi_decl_restrict void* mi_heap_zalloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset) mi_attr_noexcept { - return mi_heap_malloc_zero_aligned_at(heap, size, alignment, offset, true); + return mi_heap_malloc_zero_aligned_at(heap, size, alignment, offset, true, NULL); } mi_decl_nodiscard mi_decl_restrict void* mi_heap_zalloc_aligned(mi_heap_t* heap, size_t size, size_t alignment) mi_attr_noexcept { @@ -192,6 +267,13 @@ mi_decl_nodiscard mi_decl_restrict void* mi_malloc_aligned(size_t size, size_t a return mi_heap_malloc_aligned(mi_prim_get_default_heap(), size, alignment); } +mi_decl_nodiscard mi_decl_restrict void* mi_umalloc_aligned(size_t size, size_t alignment, size_t* pblock_size) mi_attr_noexcept { + mi_page_t* page; + void* p = mi_heap_malloc_zero_aligned_at(mi_prim_get_default_heap(), size, alignment, 0, false, &page); + if (p!=NULL && pblock_size!=NULL) { *pblock_size = mi_page_block_size(page); } + return p; +} + mi_decl_nodiscard mi_decl_restrict void* mi_zalloc_aligned_at(size_t size, size_t alignment, size_t offset) mi_attr_noexcept { return mi_heap_zalloc_aligned_at(mi_prim_get_default_heap(), size, alignment, offset); } @@ -200,6 +282,13 @@ mi_decl_nodiscard mi_decl_restrict void* mi_zalloc_aligned(size_t size, size_t a return mi_heap_zalloc_aligned(mi_prim_get_default_heap(), size, alignment); } +mi_decl_nodiscard mi_decl_restrict void* mi_uzalloc_aligned(size_t size, size_t alignment, size_t* pblock_size) mi_attr_noexcept { + mi_page_t* page; + void* p = mi_heap_malloc_zero_aligned_at(mi_prim_get_default_heap(), size, alignment, 0, true, &page); + if (p!=NULL && pblock_size!=NULL) { *pblock_size = mi_page_block_size(page); } + return p; +} + mi_decl_nodiscard mi_decl_restrict void* mi_calloc_aligned_at(size_t count, size_t size, size_t alignment, size_t offset) mi_attr_noexcept { return mi_heap_calloc_aligned_at(mi_prim_get_default_heap(), count, size, alignment, offset); } @@ -214,24 +303,30 @@ mi_decl_nodiscard mi_decl_restrict void* mi_calloc_aligned(size_t count, size_t // ------------------------------------------------------ static void* mi_heap_realloc_zero_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset, bool zero) mi_attr_noexcept { - mi_assert(alignment > 0); - if (alignment <= sizeof(uintptr_t)) return _mi_heap_realloc_zero(heap,p,newsize,zero); - if (p == NULL) return mi_heap_malloc_zero_aligned_at(heap,newsize,alignment,offset,zero); - size_t size = mi_usable_size(p); - if (newsize <= size && newsize >= (size - (size / 2)) - && (((uintptr_t)p + offset) % alignment) == 0) { + mi_assert(mi_alignment_is_valid(alignment)); + if mi_unlikely(!mi_alignment_is_valid(alignment)) { // require power-of-two (see ) + return mi_error_bad_alignment(newsize,alignment,offset); + } + if (alignment <= sizeof(uintptr_t) && offset==0) return _mi_heap_realloc_zero(heap,p,newsize,zero,NULL,NULL); + if (p == NULL) return mi_heap_malloc_zero_aligned_at(heap,newsize,alignment,offset,zero,NULL); + const size_t size = mi_usable_size(p); + if (newsize <= size && newsize >= (size - (size / 2)) && (((uintptr_t)p + offset) & (alignment-1)) == 0) { return p; // reallocation still fits, is aligned and not more than 50% waste } else { - // note: we don't zero allocate upfront so we only zero initialize the expanded part - void* newp = mi_heap_malloc_aligned_at(heap,newsize,alignment,offset); + // note: we don't zero allocate upfront so we only zero initialize the expanded part (at the cost of calling mi_usable_size) + mi_page_t* newpage; + void* const newp = mi_heap_malloc_zero_aligned_at(heap,newsize,alignment,offset,false /* no zero*/, &newpage); if (newp != NULL) { - if (zero && newsize > size) { + const size_t copy_size = (newsize > size ? size : newsize); + const size_t zero_start = (copy_size >= sizeof(intptr_t) ? copy_size - sizeof(intptr_t) : 0); // also set last word in the previous allocation to zero to ensure any padding is zero-initialized + const size_t usable = _mi_page_usable_size(newpage,newp); + mi_assert_internal(usable >= newsize); // use usable for zero'ing, issue #763 + if (zero && usable > zero_start) { // also set last word in the previous allocation to zero to ensure any padding is zero-initialized - size_t start = (size >= sizeof(intptr_t) ? size - sizeof(intptr_t) : 0); - _mi_memzero((uint8_t*)newp + start, newsize - start); + _mi_memzero((uint8_t*)newp + zero_start, usable - zero_start); } - _mi_memcpy_aligned(newp, p, (newsize > size ? size : newsize)); + _mi_memcpy(newp, p, copy_size); // cannot be aligned due to abitrary offset... (todo: require offset to be a multiple of sizeof(void*)?) mi_free(p); // only free if successful } return newp; @@ -240,9 +335,8 @@ static void* mi_heap_realloc_zero_aligned_at(mi_heap_t* heap, void* p, size_t ne static void* mi_heap_realloc_zero_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, bool zero) mi_attr_noexcept { mi_assert(alignment > 0); - if (alignment <= sizeof(uintptr_t)) return _mi_heap_realloc_zero(heap,p,newsize,zero); - size_t offset = ((uintptr_t)p % alignment); // use offset of previous allocation (p can be NULL) - return mi_heap_realloc_zero_aligned_at(heap,p,newsize,alignment,offset,zero); + if (alignment <= sizeof(uintptr_t)) return _mi_heap_realloc_zero(heap,p,newsize,zero,NULL,NULL); + return mi_heap_realloc_zero_aligned_at(heap,p,newsize,alignment,0,zero); } mi_decl_nodiscard void* mi_heap_realloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset) mi_attr_noexcept { @@ -296,3 +390,5 @@ mi_decl_nodiscard void* mi_recalloc_aligned_at(void* p, size_t newcount, size_t mi_decl_nodiscard void* mi_recalloc_aligned(void* p, size_t newcount, size_t size, size_t alignment) mi_attr_noexcept { return mi_heap_recalloc_aligned(mi_prim_get_default_heap(), p, newcount, size, alignment); } + + diff --git a/Objects/mimalloc/alloc-override.c b/Objects/mimalloc/alloc-override.c index 873065dc63495c8..481c08700b70221 100644 --- a/Objects/mimalloc/alloc-override.c +++ b/Objects/mimalloc/alloc-override.c @@ -1,5 +1,5 @@ /* ---------------------------------------------------------------------------- -Copyright (c) 2018-2021, Microsoft Research, Daan Leijen +Copyright (c) 2018-2026, Microsoft Research, Daan Leijen This is free software; you can redistribute it and/or modify it under the terms of the MIT license. A copy of the license can be found in the file "LICENSE" at the root of this distribution. @@ -9,11 +9,8 @@ terms of the MIT license. A copy of the license can be found in the file #error "this file should be included from 'alloc.c' (so aliases can work)" #endif -#if defined(MI_MALLOC_OVERRIDE) && defined(_WIN32) && !(defined(MI_SHARED_LIB) && defined(_DLL)) -#error "It is only possible to override "malloc" on Windows when building as a DLL (and linking the C runtime as a DLL)" -#endif -#if defined(MI_MALLOC_OVERRIDE) && !(defined(_WIN32)) +#if defined(MI_MALLOC_OVERRIDE) && !defined(_DLL) #if defined(__APPLE__) #include @@ -23,7 +20,7 @@ mi_decl_externc size_t malloc_good_size(size_t size); #endif // helper definition for C override of C++ new -typedef struct mi_nothrow_s { int _tag; } mi_nothrow_t; +typedef void* mi_nothrow_t; // ------------------------------------------------------ // Override system malloc @@ -71,22 +68,20 @@ typedef struct mi_nothrow_s { int _tag; } mi_nothrow_t; #define MI_INTERPOSE_FUN(oldfun,newfun) { (const void*)&newfun, (const void*)&oldfun } #define MI_INTERPOSE_MI(fun) MI_INTERPOSE_FUN(fun,mi_##fun) - __attribute__((used)) static struct mi_interpose_s _mi_interposes[] __attribute__((section("__DATA, __interpose"))) = + #define MI_INTERPOSE_DECLS(name) __attribute__((used)) static struct mi_interpose_s name[] __attribute__((section("__DATA, __interpose"))) + + MI_INTERPOSE_DECLS(_mi_interposes) = { MI_INTERPOSE_MI(malloc), MI_INTERPOSE_MI(calloc), MI_INTERPOSE_MI(realloc), MI_INTERPOSE_MI(strdup), - MI_INTERPOSE_MI(strndup), MI_INTERPOSE_MI(realpath), MI_INTERPOSE_MI(posix_memalign), MI_INTERPOSE_MI(reallocf), MI_INTERPOSE_MI(valloc), MI_INTERPOSE_FUN(malloc_size,mi_malloc_size_checked), MI_INTERPOSE_MI(malloc_good_size), - #if defined(MAC_OS_X_VERSION_10_15) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_15 - MI_INTERPOSE_MI(aligned_alloc), - #endif #ifdef MI_OSX_ZONE // we interpose malloc_default_zone in alloc-override-osx.c so we can use mi_free safely MI_INTERPOSE_MI(free), @@ -97,6 +92,12 @@ typedef struct mi_nothrow_s { int _tag; } mi_nothrow_t; MI_INTERPOSE_FUN(vfree,mi_cfree), #endif }; + #if defined(MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) + MI_INTERPOSE_DECLS(_mi_interposes_10_7) = { MI_INTERPOSE_MI(strndup) }; + #endif + #if defined(MAC_OS_X_VERSION_10_15) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_15) + MI_INTERPOSE_DECLS(_mi_interposes_10_15) = { MI_INTERPOSE_MI(aligned_alloc) }; + #endif #ifdef __cplusplus extern "C" { @@ -125,14 +126,104 @@ typedef struct mi_nothrow_s { int _tag; } mi_nothrow_t; }; #elif defined(_MSC_VER) - // cannot override malloc unless using a dll. - // we just override new/delete which does work in a static library. + _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) _ACRTIMP _CRTALLOCATOR _CRT_HYBRIDPATCHABLE + void* __cdecl _expand(_Pre_notnull_ void* _Block, _In_ _CRT_GUARDOVERFLOW size_t _Size) { + return mi__expand(_Block, _Size); + } + _Check_return_ _ACRTIMP + size_t __cdecl _msize_base(_Pre_notnull_ void* _Block) _CRT_NOEXCEPT { + return mi_malloc_size(_Block); + } + _Check_return_ _ACRTIMP _CRT_HYBRIDPATCHABLE + size_t __cdecl _msize(_Pre_notnull_ void* _Block) { + return mi_malloc_size(_Block); + } + _ACRTIMP + void __cdecl _free_base(_Pre_maybenull_ _Post_invalid_ void* _Block) { + mi_free(_Block); + } + _ACRTIMP _CRT_HYBRIDPATCHABLE + void __cdecl free(_Pre_maybenull_ _Post_invalid_ void* _Block) { + mi_free(_Block); + } + _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) _ACRTIMP _CRTALLOCATOR _CRT_JIT_INTRINSIC _CRTRESTRICT _CRT_HYBRIDPATCHABLE + void* __cdecl malloc(_In_ _CRT_GUARDOVERFLOW size_t _Size) { + return mi_malloc(_Size); + } + _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) _ACRTIMP _CRTALLOCATOR _CRTRESTRICT + void* __cdecl _malloc_base(_In_ size_t _Size) { + return mi_malloc(_Size); + } + _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) _ACRTIMP _CRTALLOCATOR _CRTRESTRICT + void* __cdecl _realloc_base(_Pre_maybenull_ _Post_invalid_ void* _Block, _In_ size_t _Size) { + return mi_realloc(_Block, _Size); + } + _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) _ACRTIMP _CRTALLOCATOR _CRTRESTRICT _CRT_HYBRIDPATCHABLE + void* __cdecl realloc(_Pre_maybenull_ _Post_invalid_ void* _Block, _In_ _CRT_GUARDOVERFLOW size_t _Size) { + return mi_realloc(_Block, _Size); + } + _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Count * _Size) _ACRTIMP _CRTALLOCATOR _CRTRESTRICT + void* __cdecl _calloc_base(_In_ size_t _Count, _In_ size_t _Size) { + return mi_calloc(_Count, _Size); + } + _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Count * _Size) _ACRTIMP _CRT_JIT_INTRINSIC _CRTALLOCATOR _CRTRESTRICT + void* __cdecl calloc(_In_ _CRT_GUARDOVERFLOW size_t _Count, _In_ _CRT_GUARDOVERFLOW size_t _Size) { + return mi_calloc(_Count, _Size); + } + _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Count * _Size) _ACRTIMP _CRTALLOCATOR _CRTRESTRICT + void* __cdecl _recalloc_base(_Pre_maybenull_ _Post_invalid_ void* _Block, _In_ size_t _Count, _In_ size_t _Size) { + return mi_recalloc(_Block, _Count, _Size); + } + _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Count * _Size) _ACRTIMP _CRTALLOCATOR _CRTRESTRICT + void* __cdecl _recalloc(_Pre_maybenull_ _Post_invalid_ void* _Block, _In_ _CRT_GUARDOVERFLOW size_t _Count, _In_ _CRT_GUARDOVERFLOW size_t _Size) { + return mi_recalloc(_Block, _Count, _Size); + } + _ACRTIMP + void __cdecl _aligned_free(_Pre_maybenull_ _Post_invalid_ void* _Block) { + mi_free(_Block); + } + _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) _ACRTIMP _CRTALLOCATOR _CRTRESTRICT + void* __cdecl _aligned_malloc(_In_ _CRT_GUARDOVERFLOW size_t _Size, _In_ size_t _Alignment) { + return mi_malloc_aligned(_Size, _Alignment); + } + _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) _ACRTIMP _CRTALLOCATOR _CRTRESTRICT + void* __cdecl _aligned_offset_malloc(_In_ _CRT_GUARDOVERFLOW size_t _Size, _In_ size_t _Alignment, _In_ size_t _Offset) { + return mi_malloc_aligned_at(_Size, _Alignment, _Offset); + } + _Check_return_ _ACRTIMP + size_t __cdecl _aligned_msize(_Pre_notnull_ void* _Block, _In_ size_t _Alignment, _In_ size_t _Offset) { + MI_UNUSED(_Alignment); MI_UNUSED(_Offset); return mi_malloc_size(_Block); + } + _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) _ACRTIMP _CRTALLOCATOR _CRTRESTRICT + void* __cdecl _aligned_offset_realloc(_Pre_maybenull_ _Post_invalid_ void* _Block, _In_ _CRT_GUARDOVERFLOW size_t _Size, _In_ size_t _Alignment, _In_ size_t _Offset) { + return mi_realloc_aligned_at(_Block, _Size, _Alignment, _Offset); + } + _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Count * _Size) _ACRTIMP _CRTALLOCATOR _CRTRESTRICT + void* __cdecl _aligned_offset_recalloc(_Pre_maybenull_ _Post_invalid_ void* _Block, _In_ _CRT_GUARDOVERFLOW size_t _Count, _In_ _CRT_GUARDOVERFLOW size_t _Size, _In_ size_t _Alignment, _In_ size_t _Offset) { + return mi_recalloc_aligned_at(_Block, _Count, _Size, _Alignment, _Offset); + } + _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size) _ACRTIMP _CRTALLOCATOR _CRTRESTRICT + void* __cdecl _aligned_realloc(_Pre_maybenull_ _Post_invalid_ void* _Block, _In_ _CRT_GUARDOVERFLOW size_t _Size, _In_ size_t _Alignment) { + return mi_realloc_aligned(_Block, _Size, _Alignment); + } + _Success_(return != 0) _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Count * _Size) _ACRTIMP _CRTALLOCATOR _CRTRESTRICT + void* __cdecl _aligned_recalloc(_Pre_maybenull_ _Post_invalid_ void* _Block, _In_ _CRT_GUARDOVERFLOW size_t _Count, _In_ _CRT_GUARDOVERFLOW size_t _Size, _In_ size_t _Alignment) { + return mi_recalloc_aligned(_Block, _Count, _Size, _Alignment); + } #else - // On all other systems forward to our API + // On all other systems forward allocation primitives to our API mi_decl_export void* malloc(size_t size) MI_FORWARD1(mi_malloc, size) mi_decl_export void* calloc(size_t size, size_t n) MI_FORWARD2(mi_calloc, size, n) mi_decl_export void* realloc(void* p, size_t newsize) MI_FORWARD2(mi_realloc, p, newsize) mi_decl_export void free(void* p) MI_FORWARD0(mi_free, p) + // In principle we do not need to forward `strdup`/`strndup` but on some systems these do not use `malloc` internally (but a more primitive call) + // We only override if `strdup` is not a macro (as on some older libc's, see issue #885) + #if !defined(strdup) + mi_decl_export char* strdup(const char* str) MI_FORWARD1(mi_strdup, str) + #endif + #if !defined(strndup) && (!defined(__APPLE__) || (defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)) + mi_decl_export char* strndup(const char* str, size_t n) MI_FORWARD2(mi_strndup, str, n) + #endif #endif #if (defined(__GNUC__) || defined(__clang__)) && !defined(__APPLE__) @@ -192,12 +283,18 @@ typedef struct mi_nothrow_s { int _tag; } mi_nothrow_t; void _ZdaPv(void* p) MI_FORWARD0(mi_free,p) // delete[] void _ZdlPvm(void* p, size_t n) MI_FORWARD02(mi_free_size,p,n) void _ZdaPvm(void* p, size_t n) MI_FORWARD02(mi_free_size,p,n) + void _ZdlPvSt11align_val_t(void* p, size_t al) { mi_free_aligned(p,al); } void _ZdaPvSt11align_val_t(void* p, size_t al) { mi_free_aligned(p,al); } void _ZdlPvmSt11align_val_t(void* p, size_t n, size_t al) { mi_free_size_aligned(p,n,al); } void _ZdaPvmSt11align_val_t(void* p, size_t n, size_t al) { mi_free_size_aligned(p,n,al); } - #if (MI_INTPTR_SIZE==8) + void _ZdlPvRKSt9nothrow_t(void* p, mi_nothrow_t tag) { MI_UNUSED(tag); mi_free(p); } // operator delete(void*, std::nothrow_t const&) + void _ZdaPvRKSt9nothrow_t(void* p, mi_nothrow_t tag) { MI_UNUSED(tag); mi_free(p); } // operator delete[](void*, std::nothrow_t const&) + void _ZdlPvSt11align_val_tRKSt9nothrow_t(void* p, size_t al, mi_nothrow_t tag) { MI_UNUSED(tag); mi_free_aligned(p,al); } // operator delete(void*, std::align_val_t, std::nothrow_t const&) + void _ZdaPvSt11align_val_tRKSt9nothrow_t(void* p, size_t al, mi_nothrow_t tag) { MI_UNUSED(tag); mi_free_aligned(p,al); } // operator delete[](void*, std::align_val_t, std::nothrow_t const&) + + #if (MI_INTPTR_SIZE==8) || (MI_INTPTR_SIZE==4 && defined(__EMSCRIPTEN__)) // pr #1257 void* _Znwm(size_t n) MI_FORWARD1(mi_new,n) // new 64-bit void* _Znam(size_t n) MI_FORWARD1(mi_new,n) // new[] 64-bit void* _ZnwmRKSt9nothrow_t(size_t n, mi_nothrow_t tag) { MI_UNUSED(tag); return mi_new_nothrow(n); } @@ -228,14 +325,25 @@ typedef struct mi_nothrow_s { int _tag; } mi_nothrow_t; extern "C" { #endif +// defined here instead alloc-posix so we can alias it +mi_decl_nodiscard size_t mi_malloc_size(const void* p) mi_attr_noexcept { + // if (!mi_is_in_heap_region(p)) return 0; + return mi_usable_size(p); +} + +mi_decl_nodiscard size_t mi_malloc_usable_size(const void *p) mi_attr_noexcept { + // if (!mi_is_in_heap_region(p)) return 0; + return mi_usable_size(p); +} + #ifndef MI_OSX_IS_INTERPOSED // Forward Posix/Unix calls as well void* reallocf(void* p, size_t newsize) MI_FORWARD2(mi_reallocf,p,newsize) - size_t malloc_size(const void* p) MI_FORWARD1(mi_usable_size,p) - #if !defined(__ANDROID__) && !defined(__FreeBSD__) - size_t malloc_usable_size(void *p) MI_FORWARD1(mi_usable_size,p) + size_t malloc_size(const void* p) MI_FORWARD1(mi_malloc_size,p) + #if !defined(__ANDROID__) && !defined(__FreeBSD__) && !defined(__DragonFly__) + size_t malloc_usable_size(void *p) MI_FORWARD1(mi_malloc_usable_size,p) #else - size_t malloc_usable_size(const void *p) MI_FORWARD1(mi_usable_size,p) + size_t malloc_usable_size(const void *p) MI_FORWARD1(mi_malloc_usable_size,p) #endif // No forwarding here due to aliasing/name mangling issues @@ -259,10 +367,13 @@ extern "C" { // no forwarding here due to aliasing/name mangling issues void cfree(void* p) { mi_free(p); } void* pvalloc(size_t size) { return mi_pvalloc(size); } -void* reallocarray(void* p, size_t count, size_t size) { return mi_reallocarray(p, count, size); } -int reallocarr(void* p, size_t count, size_t size) { return mi_reallocarr(p, count, size); } void* memalign(size_t alignment, size_t size) { return mi_memalign(alignment, size); } -void* _aligned_malloc(size_t alignment, size_t size) { return mi_aligned_alloc(alignment, size); } +#if !defined(_WIN32) +void* _aligned_malloc(size_t size, size_t alignment) { return mi_malloc_aligned(size,alignment); } +#endif +void* reallocarray(void* p, size_t count, size_t size) { return mi_reallocarray(p, count, size); } +// some systems define reallocarr so mark it as a weak symbol (#751) +mi_decl_weak int reallocarr(void* p, size_t count, size_t size) { return mi_reallocarr(p, count, size); } #if defined(__wasi__) // forward __libc interface (see PR #667) @@ -272,8 +383,8 @@ void* _aligned_malloc(size_t alignment, size_t size) { return mi_aligned_allo void __libc_free(void* p) MI_FORWARD0(mi_free, p) void* __libc_memalign(size_t alignment, size_t size) { return mi_memalign(alignment, size); } -#elif defined(__GLIBC__) && defined(__linux__) - // forward __libc interface (needed for glibc-based Linux distributions) +#elif defined(__linux__) + // forward __libc interface (needed for glibc-based and musl-based Linux distributions) void* __libc_malloc(size_t size) MI_FORWARD1(mi_malloc,size) void* __libc_calloc(size_t count, size_t size) MI_FORWARD2(mi_calloc,count,size) void* __libc_realloc(void* p, size_t size) MI_FORWARD2(mi_realloc,p,size) @@ -294,4 +405,4 @@ void* _aligned_malloc(size_t alignment, size_t size) { return mi_aligned_allo #pragma GCC visibility pop #endif -#endif // MI_MALLOC_OVERRIDE && !_WIN32 +#endif // MI_MALLOC_OVERRIDE diff --git a/Objects/mimalloc/alloc-posix.c b/Objects/mimalloc/alloc-posix.c index 225752fd8707fe3..3499ec569ddfe9d 100644 --- a/Objects/mimalloc/alloc-posix.c +++ b/Objects/mimalloc/alloc-posix.c @@ -31,17 +31,6 @@ terms of the MIT license. A copy of the license can be found in the file #define ENOMEM 12 #endif - -mi_decl_nodiscard size_t mi_malloc_size(const void* p) mi_attr_noexcept { - // if (!mi_is_in_heap_region(p)) return 0; - return mi_usable_size(p); -} - -mi_decl_nodiscard size_t mi_malloc_usable_size(const void *p) mi_attr_noexcept { - // if (!mi_is_in_heap_region(p)) return 0; - return mi_usable_size(p); -} - mi_decl_nodiscard size_t mi_malloc_good_size(size_t size) mi_attr_noexcept { return mi_good_size(size); } @@ -52,23 +41,22 @@ void mi_cfree(void* p) mi_attr_noexcept { } } -int mi_posix_memalign(void** p, size_t alignment, size_t size) mi_attr_noexcept { +int mi_posix_memalign(void** p, size_t alignment, size_t size) { // mi_attr_noexcept (issue #794) // Note: The spec dictates we should not modify `*p` on an error. (issue#27) // if (p == NULL) return EINVAL; - if ((alignment % sizeof(void*)) != 0) return EINVAL; // natural alignment - // it is also required that alignment is a power of 2 and > 0; this is checked in `mi_malloc_aligned` - if (alignment==0 || !_mi_is_power_of_two(alignment)) return EINVAL; // not a power of 2 + // it is required that alignment is a power of 2 and a multiple of sizeof(void*) + if (alignment 0) which is checked in mi_malloc_aligned void* p = mi_malloc_aligned(size, alignment); - mi_assert_internal(((uintptr_t)p % alignment) == 0); + mi_assert_internal(_mi_is_aligned(p,alignment)); return p; } -mi_decl_nodiscard void* mi_reallocarray( void* p, size_t count, size_t size ) mi_attr_noexcept { // BSD - void* newp = mi_reallocn(p,count,size); +mi_decl_nodiscard void* mi_reallocarray( void* p, size_t count, size_t size ) mi_attr_noexcept { // BSD + size_t total; + if mi_unlikely(mi_count_size_overflow(count, size, &total)) { + errno = EOVERFLOW; + return NULL; + } + void* newp = mi_realloc(p,total); if (newp==NULL) { errno = ENOMEM; } return newp; } -mi_decl_nodiscard int mi_reallocarr( void* p, size_t count, size_t size ) mi_attr_noexcept { // NetBSD - mi_assert(p != NULL); - if (p == NULL) { - errno = EINVAL; - return EINVAL; +mi_decl_nodiscard int mi_reallocarr( void* ptrp, size_t count, size_t size ) mi_attr_noexcept { // NetBSD + mi_assert(size != 0); + mi_assert(ptrp != NULL); + if (ptrp == NULL || size == 0) { + return (errno = EINVAL); + } + size_t total; + if mi_unlikely(mi_count_size_overflow(count, size, &total)) { + return (errno = EOVERFLOW); + } + void** op = (void**)ptrp; + if (total == 0) { + mi_free(*op); + *op = NULL; + return 0; + } + else { + void* newp = mi_realloc(*op,total); + if (newp == NULL) { return (errno = ENOMEM); } + *op = newp; + return 0; } - void** op = (void**)p; - void* newp = mi_reallocarray(*op, count, size); - if mi_unlikely(newp == NULL) { return errno; } - *op = newp; - return 0; } void* mi__expand(void* p, size_t newsize) mi_attr_noexcept { // Microsoft @@ -124,12 +128,13 @@ void* mi__expand(void* p, size_t newsize) mi_attr_noexcept { // Microsoft return res; } -mi_decl_nodiscard mi_decl_restrict unsigned short* mi_wcsdup(const unsigned short* s) mi_attr_noexcept { +mi_decl_nodiscard mi_decl_restrict wchar_t* mi_wcsdup(const wchar_t* s) mi_attr_noexcept { if (s==NULL) return NULL; - size_t len; - for(len = 0; s[len] != 0; len++) { } - size_t size = (len+1)*sizeof(unsigned short); - unsigned short* p = (unsigned short*)mi_malloc(size); + size_t wlen; + for(wlen = 0; s[wlen] != 0 && wlen < PTRDIFF_MAX; wlen++) { } // prevent overflow on wlen+1 + size_t size; + if (mi_mul_overflow(wlen+1, sizeof(wchar_t), &size) || size > PTRDIFF_MAX) return NULL; + wchar_t* p = (wchar_t*)mi_malloc(size); if (p != NULL) { _mi_memcpy(p,s,size); } @@ -141,36 +146,36 @@ mi_decl_nodiscard mi_decl_restrict unsigned char* mi_mbsdup(const unsigned char* } int mi_dupenv_s(char** buf, size_t* size, const char* name) mi_attr_noexcept { - if (buf==NULL || name==NULL) return EINVAL; if (size != NULL) *size = 0; - char* p = getenv(name); // mscver warning 4996 + if (buf==NULL || name==NULL) return EINVAL; + char* p = getenv(name); if (p==NULL) { *buf = NULL; } else { *buf = mi_strdup(p); if (*buf==NULL) return ENOMEM; - if (size != NULL) *size = _mi_strlen(p); + if (size != NULL) { *size = _mi_strlen(p) + 1; } // cannot overflow as mi_strdup is limited to PTRDIFF_MAX } return 0; } -int mi_wdupenv_s(unsigned short** buf, size_t* size, const unsigned short* name) mi_attr_noexcept { - if (buf==NULL || name==NULL) return EINVAL; +int mi_wdupenv_s(wchar_t** buf, size_t* size, const wchar_t* name) mi_attr_noexcept { if (size != NULL) *size = 0; + if (buf==NULL || name==NULL) return EINVAL; #if !defined(_WIN32) || (defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP)) // not supported *buf = NULL; return EINVAL; #else - unsigned short* p = (unsigned short*)_wgetenv((const wchar_t*)name); // msvc warning 4996 + wchar_t* p = (wchar_t*)_wgetenv(name); if (p==NULL) { *buf = NULL; } else { *buf = mi_wcsdup(p); if (*buf==NULL) return ENOMEM; - if (size != NULL) *size = wcslen((const wchar_t*)p); + if (size != NULL) { *size = wcslen(p) + 1; } // cannot overflow as wcsdup is limited to PTRDIFF_MAX } return 0; #endif diff --git a/Objects/mimalloc/alloc.c b/Objects/mimalloc/alloc.c index 44c84cf1931717b..7d93547970b7971 100644 --- a/Objects/mimalloc/alloc.c +++ b/Objects/mimalloc/alloc.c @@ -1,5 +1,5 @@ /* ---------------------------------------------------------------------------- -Copyright (c) 2018-2022, Microsoft Research, Daan Leijen +Copyright (c) 2018-2024, Microsoft Research, Daan Leijen This is free software; you can redistribute it and/or modify it under the terms of the MIT license. A copy of the license can be found in the file "LICENSE" at the root of this distribution. @@ -16,17 +16,12 @@ terms of the MIT license. A copy of the license can be found in the file #include // memset, strlen (for mi_strdup) #include // malloc, abort +// CPython: don't export the weak C++ `std::get_new_handler` symbol from libpython #define _ZSt15get_new_handlerv _Py__ZSt15get_new_handlerv -#define MI_IN_ALLOC_C -#include "alloc-override.c" -#undef MI_IN_ALLOC_C - -// ------------------------------------------------------ -// Allocation -// ------------------------------------------------------ - #if (MI_DEBUG>0) +// CPython: fill freed or uninitialized memory but preserve the first `page->debug_offset` +// bytes (e.g. `ob_tid` and the reference count fields that lock-free readers may still access) static inline void mi_debug_fill(mi_page_t* page, mi_block_t* block, int c, size_t size) { size_t offset = (size_t)page->debug_offset; if (offset < size) { @@ -35,21 +30,38 @@ static inline void mi_debug_fill(mi_page_t* page, mi_block_t* block, int c, size } #endif +#define MI_IN_ALLOC_C +#include "alloc-override.c" +#include "free.c" +#undef MI_IN_ALLOC_C + +// ------------------------------------------------------ +// Allocation +// ------------------------------------------------------ + // Fast allocation in a page: just pop from the free list. // Fall back to generic allocation only if the list is empty. -extern inline void* _mi_page_malloc(mi_heap_t* heap, mi_page_t* page, size_t size, bool zero) mi_attr_noexcept { - mi_assert_internal(page->xblock_size==0||mi_page_block_size(page) >= size); +// Note: in release mode the (inlined) routine is about 7 instructions with a single test. +extern inline void* _mi_page_malloc_zero(mi_heap_t* heap, mi_page_t* page, size_t size, bool zero, mi_page_t** ppage) mi_attr_noexcept +{ + mi_assert_internal(size >= MI_PADDING_SIZE); + mi_assert_internal(page->block_size == 0 /* empty heap */ || mi_page_block_size(page) >= size); + + // check the free list mi_block_t* const block = page->free; if mi_unlikely(block == NULL) { - return _mi_malloc_generic(heap, size, zero, 0); + return _mi_malloc_generic(heap, size, zero, 0, ppage); } mi_assert_internal(block != NULL && _mi_ptr_page(block) == page); + if (ppage != NULL) { *ppage = page; }; // pop from the free list - page->used++; page->free = mi_block_next(page, block); + page->used++; mi_assert_internal(page->free == NULL || _mi_ptr_page(page->free) == page); + mi_assert_internal(page->block_size < MI_MAX_ALIGN_SIZE || _mi_is_aligned(block, MI_MAX_ALIGN_SIZE)); + #if MI_DEBUG>3 - if (page->free_is_zero) { + if (page->free_is_zero && size > sizeof(*block)) { mi_assert_expensive(mi_mem_is_zero(block+1,size - sizeof(*block))); } #endif @@ -61,77 +73,90 @@ extern inline void* _mi_page_malloc(mi_heap_t* heap, mi_page_t* page, size_t siz // zero the block? note: we need to zero the full block size (issue #63) if mi_unlikely(zero) { - mi_assert_internal(page->xblock_size != 0); // do not call with zero'ing for huge blocks (see _mi_malloc_generic) - mi_assert_internal(page->xblock_size >= MI_PADDING_SIZE); + mi_assert_internal(page->block_size != 0); // do not call with zero'ing for huge blocks (see _mi_malloc_generic) + #if MI_PADDING + mi_assert_internal(page->block_size >= MI_PADDING_SIZE); + #endif if (page->free_is_zero) { block->next = 0; - mi_track_mem_defined(block, page->xblock_size - MI_PADDING_SIZE); + mi_track_mem_defined(block, page->block_size - MI_PADDING_SIZE); } else { - _mi_memzero_aligned(block, page->xblock_size - MI_PADDING_SIZE); + _mi_memzero_aligned(block, page->block_size - MI_PADDING_SIZE); } } -#if (MI_DEBUG>0) && !MI_TRACK_ENABLED && !MI_TSAN + #if (MI_DEBUG>0) && !MI_TRACK_ENABLED && !MI_TSAN if (!zero && !mi_page_is_huge(page)) { mi_debug_fill(page, block, MI_DEBUG_UNINIT, mi_page_usable_block_size(page)); } -#elif (MI_SECURE!=0) + #elif (MI_SECURE!=0) if (!zero) { block->next = 0; } // don't leak internal data -#endif + #endif -#if (MI_STAT>0) + #if (MI_STAT>0) const size_t bsize = mi_page_usable_block_size(page); if (bsize <= MI_MEDIUM_OBJ_SIZE_MAX) { - mi_heap_stat_increase(heap, normal, bsize); - mi_heap_stat_counter_increase(heap, normal_count, 1); -#if (MI_STAT>1) + mi_heap_stat_increase(heap, malloc_normal, bsize); + mi_heap_stat_counter_increase(heap, malloc_normal_count, 1); + #if (MI_STAT>1) const size_t bin = _mi_bin(bsize); - mi_heap_stat_increase(heap, normal_bins[bin], 1); -#endif + mi_heap_stat_increase(heap, malloc_bins[bin], 1); + mi_heap_stat_increase(heap, malloc_requested, size - MI_PADDING_SIZE); + #endif } -#endif - -#if MI_PADDING // && !MI_TRACK_ENABLED - mi_padding_t* const padding = (mi_padding_t*)((uint8_t*)block + mi_page_usable_block_size(page)); - ptrdiff_t delta = ((uint8_t*)padding - (uint8_t*)block - (size - MI_PADDING_SIZE)); - #if (MI_DEBUG>=2) - mi_assert_internal(delta >= 0 && mi_page_usable_block_size(page) >= (size - MI_PADDING_SIZE + delta)); #endif - mi_track_mem_defined(padding,sizeof(mi_padding_t)); // note: re-enable since mi_page_usable_block_size may set noaccess - padding->canary = (uint32_t)(mi_ptr_encode(page,block,page->keys)); - padding->delta = (uint32_t)(delta); - #if MI_PADDING_CHECK - if (!mi_page_is_huge(page)) { - uint8_t* fill = (uint8_t*)padding - delta; - const size_t maxpad = (delta > MI_MAX_ALIGN_SIZE ? MI_MAX_ALIGN_SIZE : delta); // set at most N initial padding bytes - for (size_t i = 0; i < maxpad; i++) { fill[i] = MI_DEBUG_PADDING; } - } + + #if MI_PADDING // && !MI_TRACK_ENABLED + mi_padding_t* const padding = (mi_padding_t*)((uint8_t*)block + mi_page_usable_block_size(page)); + ptrdiff_t delta = ((uint8_t*)padding - (uint8_t*)block - (size - MI_PADDING_SIZE)); + #if (MI_DEBUG>=2) + mi_assert_internal(delta >= 0 && mi_page_usable_block_size(page) >= (size - MI_PADDING_SIZE + delta)); + #endif + mi_track_mem_defined(padding,sizeof(mi_padding_t)); // note: re-enable since mi_page_usable_block_size may set noaccess + padding->canary = mi_ptr_encode_canary(page,block,page->keys); + padding->delta = (uint32_t)(delta); + #if MI_PADDING_CHECK + if (!mi_page_is_huge(page)) { + uint8_t* fill = (uint8_t*)padding - delta; + const size_t maxpad = (delta > MI_MAX_ALIGN_SIZE ? MI_MAX_ALIGN_SIZE : delta); // set at most N initial padding bytes + for (size_t i = 0; i < maxpad; i++) { fill[i] = MI_DEBUG_PADDING; } + } + #endif #endif -#endif return block; } -static inline mi_decl_restrict void* mi_heap_malloc_small_zero(mi_heap_t* heap, size_t size, bool zero) mi_attr_noexcept { +// extra entries for improved efficiency in `alloc-aligned.c`. +extern void* _mi_page_malloc(mi_heap_t* heap, mi_page_t* page, size_t size) mi_attr_noexcept { + return _mi_page_malloc_zero(heap,page,size,false,NULL); +} +extern void* _mi_page_malloc_zeroed(mi_heap_t* heap, mi_page_t* page, size_t size) mi_attr_noexcept { + return _mi_page_malloc_zero(heap,page,size,true,NULL); +} + +static inline mi_decl_restrict void* mi_heap_malloc_small_zero(mi_heap_t* heap, size_t size, bool zero, mi_page_t** ppage) mi_attr_noexcept { mi_assert(heap != NULL); + mi_assert(size <= MI_SMALL_SIZE_MAX); #if MI_DEBUG const uintptr_t tid = _mi_thread_id(); mi_assert(heap->thread_id == 0 || heap->thread_id == tid); // heaps are thread local #endif - mi_assert(size <= MI_SMALL_SIZE_MAX); - #if (MI_PADDING) + #if (MI_PADDING || MI_GUARDED) if (size == 0) { size = sizeof(void*); } #endif - mi_page_t* page = _mi_heap_get_free_small_page(heap, size + MI_PADDING_SIZE); - void* const p = _mi_page_malloc(heap, page, size + MI_PADDING_SIZE, zero); - mi_track_malloc(p,size,zero); - #if MI_STAT>1 - if (p != NULL) { - if (!mi_heap_is_initialized(heap)) { heap = mi_prim_get_default_heap(); } - mi_heap_stat_increase(heap, malloc, mi_usable_size(p)); + #if MI_GUARDED + if (mi_heap_malloc_use_guarded(heap,size)) { + return _mi_heap_malloc_guarded(heap, size, zero, ppage); } #endif + + // get page in constant time, and allocate from it + mi_page_t* page = _mi_heap_get_free_small_page(heap, size + MI_PADDING_SIZE); + void* const p = _mi_page_malloc_zero(heap, page, size + MI_PADDING_SIZE, zero, ppage); + mi_track_malloc(p,size,zero); + #if MI_DEBUG>3 if (p != NULL && zero) { mi_assert_expensive(mi_mem_is_zero(p, size)); @@ -142,7 +167,11 @@ static inline mi_decl_restrict void* mi_heap_malloc_small_zero(mi_heap_t* heap, // allocate a small block mi_decl_nodiscard extern inline mi_decl_restrict void* mi_heap_malloc_small(mi_heap_t* heap, size_t size) mi_attr_noexcept { - return mi_heap_malloc_small_zero(heap, size, false); + return mi_heap_malloc_small_zero(heap, size, false, NULL); +} + +mi_decl_nodiscard extern inline mi_decl_restrict void* mi_heap_zalloc_small(mi_heap_t* heap, size_t size) mi_attr_noexcept { + return mi_heap_malloc_small_zero(heap, size, true, NULL); } mi_decl_nodiscard extern inline mi_decl_restrict void* mi_malloc_small(size_t size) mi_attr_noexcept { @@ -150,22 +179,24 @@ mi_decl_nodiscard extern inline mi_decl_restrict void* mi_malloc_small(size_t si } // The main allocation function -extern inline void* _mi_heap_malloc_zero_ex(mi_heap_t* heap, size_t size, bool zero, size_t huge_alignment) mi_attr_noexcept { +extern inline void* _mi_heap_malloc_zero_ex(mi_heap_t* heap, size_t size, bool zero, size_t huge_alignment, mi_page_t** ppage) mi_attr_noexcept { + // fast path for small objects if mi_likely(size <= MI_SMALL_SIZE_MAX) { mi_assert_internal(huge_alignment == 0); - return mi_heap_malloc_small_zero(heap, size, zero); + return mi_heap_malloc_small_zero(heap, size, zero, ppage); } + #if MI_GUARDED + else if (huge_alignment==0 && mi_heap_malloc_use_guarded(heap,size)) { + return _mi_heap_malloc_guarded(heap, size, zero, ppage); + } + #endif else { + // regular allocation mi_assert(heap!=NULL); mi_assert(heap->thread_id == 0 || heap->thread_id == _mi_thread_id()); // heaps are thread local - void* const p = _mi_malloc_generic(heap, size + MI_PADDING_SIZE, zero, huge_alignment); // note: size can overflow but it is detected in malloc_generic + void* const p = _mi_malloc_generic(heap, size + MI_PADDING_SIZE, zero, huge_alignment, ppage); // note: size can overflow but it is detected in malloc_generic mi_track_malloc(p,size,zero); - #if MI_STAT>1 - if (p != NULL) { - if (!mi_heap_is_initialized(heap)) { heap = mi_prim_get_default_heap(); } - mi_heap_stat_increase(heap, malloc, mi_usable_size(p)); - } - #endif + #if MI_DEBUG>3 if (p != NULL && zero) { mi_assert_expensive(mi_mem_is_zero(p, size)); @@ -176,7 +207,7 @@ extern inline void* _mi_heap_malloc_zero_ex(mi_heap_t* heap, size_t size, bool z } extern inline void* _mi_heap_malloc_zero(mi_heap_t* heap, size_t size, bool zero) mi_attr_noexcept { - return _mi_heap_malloc_zero_ex(heap, size, zero, 0); + return _mi_heap_malloc_zero_ex(heap, size, zero, 0, NULL); } mi_decl_nodiscard extern inline mi_decl_restrict void* mi_heap_malloc(mi_heap_t* heap, size_t size) mi_attr_noexcept { @@ -189,7 +220,7 @@ mi_decl_nodiscard extern inline mi_decl_restrict void* mi_malloc(size_t size) mi // zero initialized small block mi_decl_nodiscard mi_decl_restrict void* mi_zalloc_small(size_t size) mi_attr_noexcept { - return mi_heap_malloc_small_zero(mi_prim_get_default_heap(), size, true); + return mi_heap_zalloc_small(mi_prim_get_default_heap(), size); } mi_decl_nodiscard extern inline mi_decl_restrict void* mi_heap_zalloc(mi_heap_t* heap, size_t size) mi_attr_noexcept { @@ -201,495 +232,57 @@ mi_decl_nodiscard mi_decl_restrict void* mi_zalloc(size_t size) mi_attr_noexcept } -// ------------------------------------------------------ -// Check for double free in secure and debug mode -// This is somewhat expensive so only enabled for secure mode 4 -// ------------------------------------------------------ - -#if (MI_ENCODE_FREELIST && (MI_SECURE>=4 || MI_DEBUG!=0)) -// linear check if the free list contains a specific element -static bool mi_list_contains(const mi_page_t* page, const mi_block_t* list, const mi_block_t* elem) { - while (list != NULL) { - if (elem==list) return true; - list = mi_block_next(page, list); - } - return false; -} - -static mi_decl_noinline bool mi_check_is_double_freex(const mi_page_t* page, const mi_block_t* block) { - // The decoded value is in the same page (or NULL). - // Walk the free lists to verify positively if it is already freed - if (mi_list_contains(page, page->free, block) || - mi_list_contains(page, page->local_free, block) || - mi_list_contains(page, mi_page_thread_free(page), block)) - { - _mi_error_message(EAGAIN, "double free detected of block %p with size %zu\n", block, mi_page_block_size(page)); - return true; - } - return false; -} - -#define mi_track_page(page,access) { size_t psize; void* pstart = _mi_page_start(_mi_page_segment(page),page,&psize); mi_track_mem_##access( pstart, psize); } - -static inline bool mi_check_is_double_free(const mi_page_t* page, const mi_block_t* block) { - bool is_double_free = false; - mi_block_t* n = mi_block_nextx(page, block, page->keys); // pretend it is freed, and get the decoded first field - if (((uintptr_t)n & (MI_INTPTR_SIZE-1))==0 && // quick check: aligned pointer? - (n==NULL || mi_is_in_same_page(block, n))) // quick check: in same page or NULL? - { - // Suspicious: decoded value a in block is in the same page (or NULL) -- maybe a double free? - // (continue in separate function to improve code generation) - is_double_free = mi_check_is_double_freex(page, block); - } - return is_double_free; -} -#else -static inline bool mi_check_is_double_free(const mi_page_t* page, const mi_block_t* block) { - MI_UNUSED(page); - MI_UNUSED(block); - return false; -} -#endif - -// --------------------------------------------------------------------------- -// Check for heap block overflow by setting up padding at the end of the block -// --------------------------------------------------------------------------- - -#if MI_PADDING // && !MI_TRACK_ENABLED -static bool mi_page_decode_padding(const mi_page_t* page, const mi_block_t* block, size_t* delta, size_t* bsize) { - *bsize = mi_page_usable_block_size(page); - const mi_padding_t* const padding = (mi_padding_t*)((uint8_t*)block + *bsize); - mi_track_mem_defined(padding,sizeof(mi_padding_t)); - *delta = padding->delta; - uint32_t canary = padding->canary; - uintptr_t keys[2]; - keys[0] = page->keys[0]; - keys[1] = page->keys[1]; - bool ok = ((uint32_t)mi_ptr_encode(page,block,keys) == canary && *delta <= *bsize); - mi_track_mem_noaccess(padding,sizeof(mi_padding_t)); - return ok; -} - -// Return the exact usable size of a block. -static size_t mi_page_usable_size_of(const mi_page_t* page, const mi_block_t* block) { - size_t bsize; - size_t delta; - bool ok = mi_page_decode_padding(page, block, &delta, &bsize); - mi_assert_internal(ok); mi_assert_internal(delta <= bsize); - return (ok ? bsize - delta : 0); -} - -// When a non-thread-local block is freed, it becomes part of the thread delayed free -// list that is freed later by the owning heap. If the exact usable size is too small to -// contain the pointer for the delayed list, then shrink the padding (by decreasing delta) -// so it will later not trigger an overflow error in `mi_free_block`. -void _mi_padding_shrink(const mi_page_t* page, const mi_block_t* block, const size_t min_size) { - size_t bsize; - size_t delta; - bool ok = mi_page_decode_padding(page, block, &delta, &bsize); - mi_assert_internal(ok); - if (!ok || (bsize - delta) >= min_size) return; // usually already enough space - mi_assert_internal(bsize >= min_size); - if (bsize < min_size) return; // should never happen - size_t new_delta = (bsize - min_size); - mi_assert_internal(new_delta < bsize); - mi_padding_t* padding = (mi_padding_t*)((uint8_t*)block + bsize); - mi_track_mem_defined(padding,sizeof(mi_padding_t)); - padding->delta = (uint32_t)new_delta; - mi_track_mem_noaccess(padding,sizeof(mi_padding_t)); -} -#else -static size_t mi_page_usable_size_of(const mi_page_t* page, const mi_block_t* block) { - MI_UNUSED(block); - return mi_page_usable_block_size(page); -} - -void _mi_padding_shrink(const mi_page_t* page, const mi_block_t* block, const size_t min_size) { - MI_UNUSED(page); - MI_UNUSED(block); - MI_UNUSED(min_size); -} -#endif - -#if MI_PADDING && MI_PADDING_CHECK - -static bool mi_verify_padding(const mi_page_t* page, const mi_block_t* block, size_t* size, size_t* wrong) { - size_t bsize; - size_t delta; - bool ok = mi_page_decode_padding(page, block, &delta, &bsize); - *size = *wrong = bsize; - if (!ok) return false; - mi_assert_internal(bsize >= delta); - *size = bsize - delta; - if (!mi_page_is_huge(page)) { - uint8_t* fill = (uint8_t*)block + bsize - delta; - const size_t maxpad = (delta > MI_MAX_ALIGN_SIZE ? MI_MAX_ALIGN_SIZE : delta); // check at most the first N padding bytes - mi_track_mem_defined(fill, maxpad); - for (size_t i = 0; i < maxpad; i++) { - if (fill[i] != MI_DEBUG_PADDING) { - *wrong = bsize - delta + i; - ok = false; - break; - } - } - mi_track_mem_noaccess(fill, maxpad); - } - return ok; -} - -static void mi_check_padding(const mi_page_t* page, const mi_block_t* block) { - size_t size; - size_t wrong; - if (!mi_verify_padding(page,block,&size,&wrong)) { - _mi_error_message(EFAULT, "buffer overflow in heap block %p of size %zu: write after %zu bytes\n", block, size, wrong ); - } -} - -#else - -static void mi_check_padding(const mi_page_t* page, const mi_block_t* block) { - MI_UNUSED(page); - MI_UNUSED(block); -} - -#endif - -// only maintain stats for smaller objects if requested -#if (MI_STAT>0) -static void mi_stat_free(const mi_page_t* page, const mi_block_t* block) { - #if (MI_STAT < 2) - MI_UNUSED(block); - #endif - mi_heap_t* const heap = mi_heap_get_default(); - const size_t bsize = mi_page_usable_block_size(page); - #if (MI_STAT>1) - const size_t usize = mi_page_usable_size_of(page, block); - mi_heap_stat_decrease(heap, malloc, usize); - #endif - if (bsize <= MI_MEDIUM_OBJ_SIZE_MAX) { - mi_heap_stat_decrease(heap, normal, bsize); - #if (MI_STAT > 1) - mi_heap_stat_decrease(heap, normal_bins[_mi_bin(bsize)], 1); - #endif - } - else if (bsize <= MI_LARGE_OBJ_SIZE_MAX) { - mi_heap_stat_decrease(heap, large, bsize); - } - else { - mi_heap_stat_decrease(heap, huge, bsize); - } -} -#else -static void mi_stat_free(const mi_page_t* page, const mi_block_t* block) { - MI_UNUSED(page); MI_UNUSED(block); -} -#endif - -#if MI_HUGE_PAGE_ABANDON -#if (MI_STAT>0) -// maintain stats for huge objects -static void mi_stat_huge_free(const mi_page_t* page) { - mi_heap_t* const heap = mi_heap_get_default(); - const size_t bsize = mi_page_block_size(page); // to match stats in `page.c:mi_page_huge_alloc` - if (bsize <= MI_LARGE_OBJ_SIZE_MAX) { - mi_heap_stat_decrease(heap, large, bsize); - } - else { - mi_heap_stat_decrease(heap, huge, bsize); - } -} -#else -static void mi_stat_huge_free(const mi_page_t* page) { - MI_UNUSED(page); -} -#endif -#endif - -// ------------------------------------------------------ -// Free -// ------------------------------------------------------ - -// multi-threaded free (or free in huge block if compiled with MI_HUGE_PAGE_ABANDON) -static mi_decl_noinline void _mi_free_block_mt(mi_page_t* page, mi_block_t* block) -{ - // The padding check may access the non-thread-owned page for the key values. - // that is safe as these are constant and the page won't be freed (as the block is not freed yet). - mi_check_padding(page, block); - _mi_padding_shrink(page, block, sizeof(mi_block_t)); // for small size, ensure we can fit the delayed thread pointers without triggering overflow detection - - // huge page segments are always abandoned and can be freed immediately - mi_segment_t* segment = _mi_page_segment(page); - if (segment->kind == MI_SEGMENT_HUGE) { - #if MI_HUGE_PAGE_ABANDON - // huge page segments are always abandoned and can be freed immediately - mi_stat_huge_free(page); - _mi_segment_huge_page_free(segment, page, block); - return; - #else - // huge pages are special as they occupy the entire segment - // as these are large we reset the memory occupied by the page so it is available to other threads - // (as the owning thread needs to actually free the memory later). - _mi_segment_huge_page_reset(segment, page, block); - #endif - } - - #if (MI_DEBUG>0) && !MI_TRACK_ENABLED && !MI_TSAN // note: when tracking, cannot use mi_usable_size with multi-threading - if (segment->kind != MI_SEGMENT_HUGE) { // not for huge segments as we just reset the content - mi_debug_fill(page, block, MI_DEBUG_FREED, mi_usable_size(block)); - } - #endif - - // Try to put the block on either the page-local thread free list, or the heap delayed free list. - mi_thread_free_t tfreex; - bool use_delayed; - mi_thread_free_t tfree = mi_atomic_load_relaxed(&page->xthread_free); - do { - use_delayed = (mi_tf_delayed(tfree) == MI_USE_DELAYED_FREE); - if mi_unlikely(use_delayed) { - // unlikely: this only happens on the first concurrent free in a page that is in the full list - tfreex = mi_tf_set_delayed(tfree,MI_DELAYED_FREEING); - } - else { - // usual: directly add to page thread_free list - mi_block_set_next(page, block, mi_tf_block(tfree)); - tfreex = mi_tf_set_block(tfree,block); - } - } while (!mi_atomic_cas_weak_release(&page->xthread_free, &tfree, tfreex)); - - if mi_unlikely(use_delayed) { - // racy read on `heap`, but ok because MI_DELAYED_FREEING is set (see `mi_heap_delete` and `mi_heap_collect_abandon`) - mi_heap_t* const heap = (mi_heap_t*)(mi_atomic_load_acquire(&page->xheap)); //mi_page_heap(page); - mi_assert_internal(heap != NULL); - if (heap != NULL) { - // add to the delayed free list of this heap. (do this atomically as the lock only protects heap memory validity) - mi_block_t* dfree = mi_atomic_load_ptr_relaxed(mi_block_t, &heap->thread_delayed_free); - do { - mi_block_set_nextx(heap,block,dfree, heap->keys); - } while (!mi_atomic_cas_ptr_weak_release(mi_block_t,&heap->thread_delayed_free, &dfree, block)); - } - - // and reset the MI_DELAYED_FREEING flag - tfree = mi_atomic_load_relaxed(&page->xthread_free); - do { - tfreex = tfree; - mi_assert_internal(mi_tf_delayed(tfree) == MI_DELAYED_FREEING); - tfreex = mi_tf_set_delayed(tfree,MI_NO_DELAYED_FREE); - } while (!mi_atomic_cas_weak_release(&page->xthread_free, &tfree, tfreex)); - } -} - -// regular free -static inline void _mi_free_block(mi_page_t* page, bool local, mi_block_t* block) -{ - // and push it on the free list - //const size_t bsize = mi_page_block_size(page); - if mi_likely(local) { - // owning thread can free a block directly - if mi_unlikely(mi_check_is_double_free(page, block)) return; - mi_check_padding(page, block); - #if (MI_DEBUG>0) && !MI_TRACK_ENABLED && !MI_TSAN - if (!mi_page_is_huge(page)) { // huge page content may be already decommitted - mi_debug_fill(page, block, MI_DEBUG_FREED, mi_page_block_size(page)); - } - #endif - mi_block_set_next(page, block, page->local_free); - page->local_free = block; - page->used--; - if mi_unlikely(mi_page_all_free(page)) { - _mi_page_retire(page); - } - else if mi_unlikely(mi_page_is_in_full(page)) { - _mi_page_unfull(page); - } - } - else { - _mi_free_block_mt(page,block); - } -} - - -// Adjust a block that was allocated aligned, to the actual start of the block in the page. -mi_block_t* _mi_page_ptr_unalign(const mi_segment_t* segment, const mi_page_t* page, const void* p) { - mi_assert_internal(page!=NULL && p!=NULL); - const size_t diff = (uint8_t*)p - _mi_page_start(segment, page, NULL); - const size_t adjust = (diff % mi_page_block_size(page)); - return (mi_block_t*)((uintptr_t)p - adjust); -} - - -void mi_decl_noinline _mi_free_generic(const mi_segment_t* segment, mi_page_t* page, bool is_local, void* p) mi_attr_noexcept { - mi_block_t* const block = (mi_page_has_aligned(page) ? _mi_page_ptr_unalign(segment, page, p) : (mi_block_t*)p); - mi_stat_free(page, block); // stat_free may access the padding - mi_track_free_size(block, mi_page_usable_size_of(page,block)); - _mi_free_block(page, is_local, block); -} - -// Get the segment data belonging to a pointer -// This is just a single `and` in assembly but does further checks in debug mode -// (and secure mode) if this was a valid pointer. -static inline mi_segment_t* mi_checked_ptr_segment(const void* p, const char* msg) -{ - MI_UNUSED(msg); - mi_assert(p != NULL); - -#if (MI_DEBUG>0) - if mi_unlikely(((uintptr_t)p & (MI_INTPTR_SIZE - 1)) != 0) { - _mi_error_message(EINVAL, "%s: invalid (unaligned) pointer: %p\n", msg, p); - return NULL; - } -#endif - - mi_segment_t* const segment = _mi_ptr_segment(p); - mi_assert_internal(segment != NULL); - -#if 0 && (MI_DEBUG>0) - if mi_unlikely(!mi_is_in_heap_region(p)) { - #if (MI_INTPTR_SIZE == 8 && defined(__linux__)) - if (((uintptr_t)p >> 40) != 0x7F) { // linux tends to align large blocks above 0x7F000000000 (issue #640) - #else - { - #endif - _mi_warning_message("%s: pointer might not point to a valid heap region: %p\n" - "(this may still be a valid very large allocation (over 64MiB))\n", msg, p); - if mi_likely(_mi_ptr_cookie(segment) == segment->cookie) { - _mi_warning_message("(yes, the previous pointer %p was valid after all)\n", p); - } - } - } -#endif -#if (MI_DEBUG>0 || MI_SECURE>=4) - if mi_unlikely(_mi_ptr_cookie(segment) != segment->cookie) { - _mi_error_message(EINVAL, "%s: pointer does not point to a valid heap space: %p\n", msg, p); - return NULL; - } -#endif - - return segment; +mi_decl_nodiscard extern inline mi_decl_restrict void* mi_heap_calloc(mi_heap_t* heap, size_t count, size_t size) mi_attr_noexcept { + size_t total; + if (mi_count_size_overflow(count,size,&total)) return NULL; + return mi_heap_zalloc(heap,total); } -// Free a block -// fast path written carefully to prevent spilling on the stack -void mi_free(void* p) mi_attr_noexcept -{ - if mi_unlikely(p == NULL) return; - mi_segment_t* const segment = mi_checked_ptr_segment(p,"mi_free"); - const bool is_local= (_mi_prim_thread_id() == mi_atomic_load_relaxed(&segment->thread_id)); - mi_page_t* const page = _mi_segment_page_of(segment, p); - - if mi_likely(is_local) { // thread-local free? - if mi_likely(page->flags.full_aligned == 0) // and it is not a full page (full pages need to move from the full bin), nor has aligned blocks (aligned blocks need to be unaligned) - { - mi_block_t* const block = (mi_block_t*)p; - if mi_unlikely(mi_check_is_double_free(page, block)) return; - mi_check_padding(page, block); - mi_stat_free(page, block); - #if (MI_DEBUG>0) && !MI_TRACK_ENABLED && !MI_TSAN - mi_debug_fill(page, block, MI_DEBUG_FREED, mi_page_block_size(page)); - #endif - mi_track_free_size(p, mi_page_usable_size_of(page,block)); // faster then mi_usable_size as we already know the page and that p is unaligned - mi_block_set_next(page, block, page->local_free); - page->local_free = block; - if mi_unlikely(--page->used == 0) { // using this expression generates better code than: page->used--; if (mi_page_all_free(page)) - _mi_page_retire(page); - } - } - else { - // page is full or contains (inner) aligned blocks; use generic path - _mi_free_generic(segment, page, true, p); - } - } - else { - // not thread-local; use generic path - _mi_free_generic(segment, page, false, p); - } +mi_decl_nodiscard mi_decl_restrict void* mi_calloc(size_t count, size_t size) mi_attr_noexcept { + return mi_heap_calloc(mi_prim_get_default_heap(),count,size); } -// return true if successful -bool _mi_free_delayed_block(mi_block_t* block) { - // get segment and page - const mi_segment_t* const segment = _mi_ptr_segment(block); - mi_assert_internal(_mi_ptr_cookie(segment) == segment->cookie); -#ifndef Py_GIL_DISABLED - // The GC traverses heaps of other threads, which can trigger this assert. - mi_assert_internal(_mi_thread_id() == segment->thread_id); -#endif - mi_page_t* const page = _mi_segment_page_of(segment, block); - - // Clear the no-delayed flag so delayed freeing is used again for this page. - // This must be done before collecting the free lists on this page -- otherwise - // some blocks may end up in the page `thread_free` list with no blocks in the - // heap `thread_delayed_free` list which may cause the page to be never freed! - // (it would only be freed if we happen to scan it in `mi_page_queue_find_free_ex`) - if (!_mi_page_try_use_delayed_free(page, MI_USE_DELAYED_FREE, false /* dont overwrite never delayed */)) { - return false; +static void* mi_ublock_size( void* p, mi_page_t* page, size_t* pblock_size ) { + mi_assert_internal(page == _mi_ptr_page(p)); + if (pblock_size!=NULL) { + if (p!=NULL) { *pblock_size = mi_page_block_size(page); } } - - // collect all other non-local frees to ensure up-to-date `used` count - _mi_page_free_collect(page, false); - - // and free the block (possibly freeing the page as well since used is updated) - _mi_free_block(page, true, block); - return true; -} - -// Bytes available in a block -mi_decl_noinline static size_t mi_page_usable_aligned_size_of(const mi_segment_t* segment, const mi_page_t* page, const void* p) mi_attr_noexcept { - const mi_block_t* block = _mi_page_ptr_unalign(segment, page, p); - const size_t size = mi_page_usable_size_of(page, block); - const ptrdiff_t adjust = (uint8_t*)p - (uint8_t*)block; - mi_assert_internal(adjust >= 0 && (size_t)adjust <= size); - return (size - adjust); + return p; } -static inline size_t _mi_usable_size(const void* p, const char* msg) mi_attr_noexcept { - if (p == NULL) return 0; - const mi_segment_t* const segment = mi_checked_ptr_segment(p, msg); - const mi_page_t* const page = _mi_segment_page_of(segment, p); - if mi_likely(!mi_page_has_aligned(page)) { - const mi_block_t* block = (const mi_block_t*)p; - return mi_page_usable_size_of(page, block); - } - else { - // split out to separate routine for improved code generation - return mi_page_usable_aligned_size_of(segment, page, p); - } +// Return the block size +mi_decl_nodiscard mi_decl_restrict void* mi_umalloc_small(size_t size, size_t* pblock_size) mi_attr_noexcept { + mi_page_t* page; + void* p = mi_heap_malloc_small_zero(mi_prim_get_default_heap(), size, false, &page); + return mi_ublock_size(p,page,pblock_size); } -mi_decl_nodiscard size_t mi_usable_size(const void* p) mi_attr_noexcept { - return _mi_usable_size(p, "mi_usable_size"); +mi_decl_nodiscard mi_decl_restrict void* mi_uzalloc_small(size_t size, size_t* pblock_size) mi_attr_noexcept { + mi_page_t* page; + void* p = mi_heap_malloc_small_zero(mi_prim_get_default_heap(), size, true, &page); + return mi_ublock_size(p,page,pblock_size); } - -// ------------------------------------------------------ -// Allocation extensions -// ------------------------------------------------------ - -void mi_free_size(void* p, size_t size) mi_attr_noexcept { - MI_UNUSED_RELEASE(size); - mi_assert(p == NULL || size <= _mi_usable_size(p,"mi_free_size")); - mi_free(p); +mi_decl_nodiscard mi_decl_restrict void* mi_heap_umalloc(mi_heap_t* heap, size_t size, size_t* pblock_size) mi_attr_noexcept { + mi_page_t* page; + void* p = _mi_heap_malloc_zero_ex(heap, size, false, 0, &page); + return mi_ublock_size(p,page,pblock_size); } -void mi_free_size_aligned(void* p, size_t size, size_t alignment) mi_attr_noexcept { - MI_UNUSED_RELEASE(alignment); - mi_assert(((uintptr_t)p % alignment) == 0); - mi_free_size(p,size); +mi_decl_nodiscard mi_decl_restrict void* mi_umalloc(size_t size, size_t* pblock_size) mi_attr_noexcept { + return mi_heap_umalloc(mi_prim_get_default_heap(), size, pblock_size); } -void mi_free_aligned(void* p, size_t alignment) mi_attr_noexcept { - MI_UNUSED_RELEASE(alignment); - mi_assert(((uintptr_t)p % alignment) == 0); - mi_free(p); +mi_decl_nodiscard mi_decl_restrict void* mi_uzalloc(size_t size, size_t* pblock_size) mi_attr_noexcept { + mi_page_t* page; + void* p = _mi_heap_malloc_zero_ex(mi_prim_get_default_heap(), size, true, 0, &page); + return mi_ublock_size(p,page,pblock_size); } -mi_decl_nodiscard extern inline mi_decl_restrict void* mi_heap_calloc(mi_heap_t* heap, size_t count, size_t size) mi_attr_noexcept { +mi_decl_nodiscard mi_decl_restrict void* mi_ucalloc(size_t count, size_t size, size_t* pblock_size) mi_attr_noexcept { size_t total; if (mi_count_size_overflow(count,size,&total)) return NULL; - return mi_heap_zalloc(heap,total); -} - -mi_decl_nodiscard mi_decl_restrict void* mi_calloc(size_t count, size_t size) mi_attr_noexcept { - return mi_heap_calloc(mi_prim_get_default_heap(),count,size); + return mi_uzalloc(total, pblock_size); } // Uninitialized `calloc` @@ -711,38 +304,60 @@ void* mi_expand(void* p, size_t newsize) mi_attr_noexcept { return NULL; #else if (p == NULL) return NULL; - const size_t size = _mi_usable_size(p,"mi_expand"); + const mi_page_t* const page = mi_validate_ptr_page(p,"mi_expand"); + const size_t size = _mi_page_usable_size(page,p); if (newsize > size) return NULL; return p; // it fits #endif } -void* _mi_heap_realloc_zero(mi_heap_t* heap, void* p, size_t newsize, bool zero) mi_attr_noexcept { +void* _mi_heap_realloc_zero(mi_heap_t* heap, void* p, size_t newsize, bool zero, size_t* pblock_size_pre, size_t* pblock_size_post) mi_attr_noexcept { // if p == NULL then behave as malloc. // else if size == 0 then reallocate to a zero-sized block (and don't return NULL, just as mi_malloc(0)). // (this means that returning NULL always indicates an error, and `p` will not have been freed in that case.) - const size_t size = _mi_usable_size(p,"mi_realloc"); // also works if p == NULL (with size 0) + const mi_page_t* page; + size_t size; + if (p==NULL) { + page = NULL; + size = 0; + if (pblock_size_pre!=NULL) { *pblock_size_pre = 0; } + } + else { + page = mi_validate_ptr_page(p,"mi_realloc"); + if mi_unlikely(page==NULL) { // invalid pointer + if (pblock_size_pre!=NULL) { *pblock_size_pre = 0; } + if (pblock_size_post!=NULL) { *pblock_size_post = 0; } + return NULL; + } + size = _mi_page_usable_size(page,p); + if (pblock_size_pre!=NULL) { *pblock_size_pre = mi_page_block_size(page); } + } if mi_unlikely(newsize <= size && newsize >= (size / 2) && newsize > 0) { // note: newsize must be > 0 or otherwise we return NULL for realloc(NULL,0) mi_assert_internal(p!=NULL); // todo: do not track as the usable size is still the same in the free; adjust potential padding? // mi_track_resize(p,size,newsize) // if (newsize < size) { mi_track_mem_noaccess((uint8_t*)p + newsize, size - newsize); } + if (pblock_size_post!=NULL) { *pblock_size_post = mi_page_block_size(page); } return p; // reallocation still fits and not more than 50% waste } - void* newp = mi_heap_malloc(heap,newsize); + // note: we don't zero allocate upfront so we only zero initialize the expanded part + mi_page_t* newpage; // use block_size for zero-ing, issue #763 + void* const newp = _mi_heap_malloc_zero_ex(heap,newsize,false /* no zero */,0,&newpage); if mi_likely(newp != NULL) { - if (zero && newsize > size) { - // also set last word in the previous allocation to zero to ensure any padding is zero-initialized - const size_t start = (size >= sizeof(intptr_t) ? size - sizeof(intptr_t) : 0); - _mi_memzero((uint8_t*)newp + start, newsize - start); + if (pblock_size_post!=NULL) { *pblock_size_post = mi_page_block_size(newpage); } + const size_t copy_size = (newsize > size ? size : newsize); + const size_t zero_start = _mi_align_down( (copy_size >= sizeof(intptr_t) ? copy_size - sizeof(intptr_t) : 0), sizeof(intptr_t)); // also set last word in the previous allocation to zero to ensure any padding is zero-initialized + const size_t usable = _mi_page_usable_size(newpage,newp); + mi_assert_internal(usable >= newsize); + if (zero && usable > zero_start) { + _mi_memzero_aligned((uint8_t*)newp + zero_start, usable - zero_start); } else if (newsize == 0) { ((uint8_t*)newp)[0] = 0; // work around for applications that expect zero-reallocation to be zero initialized (issue #725) } if mi_likely(p != NULL) { - const size_t copysize = (newsize > size ? size : newsize); - mi_track_mem_defined(p,copysize); // _mi_useable_size may be too large for byte precise memory tracking.. - _mi_memcpy(newp, p, copysize); + mi_track_mem_defined(p,copy_size); // _mi_useable_size may be too large for byte precise memory tracking.. + _mi_memcpy_aligned(newp, p, copy_size); mi_free(p); // only free the original pointer if successful } } @@ -750,7 +365,7 @@ void* _mi_heap_realloc_zero(mi_heap_t* heap, void* p, size_t newsize, bool zero) } mi_decl_nodiscard void* mi_heap_realloc(mi_heap_t* heap, void* p, size_t newsize) mi_attr_noexcept { - return _mi_heap_realloc_zero(heap, p, newsize, false); + return _mi_heap_realloc_zero(heap, p, newsize, false, NULL, NULL); } mi_decl_nodiscard void* mi_heap_reallocn(mi_heap_t* heap, void* p, size_t count, size_t size) mi_attr_noexcept { @@ -768,7 +383,7 @@ mi_decl_nodiscard void* mi_heap_reallocf(mi_heap_t* heap, void* p, size_t newsiz } mi_decl_nodiscard void* mi_heap_rezalloc(mi_heap_t* heap, void* p, size_t newsize) mi_attr_noexcept { - return _mi_heap_realloc_zero(heap, p, newsize, true); + return _mi_heap_realloc_zero(heap, p, newsize, true, NULL, NULL); } mi_decl_nodiscard void* mi_heap_recalloc(mi_heap_t* heap, void* p, size_t count, size_t size) mi_attr_noexcept { @@ -786,6 +401,10 @@ mi_decl_nodiscard void* mi_reallocn(void* p, size_t count, size_t size) mi_attr_ return mi_heap_reallocn(mi_prim_get_default_heap(),p,count,size); } +mi_decl_nodiscard void* mi_urealloc(void* p, size_t newsize, size_t* pblock_size_pre, size_t* pblock_size_post) mi_attr_noexcept { + return _mi_heap_realloc_zero(mi_prim_get_default_heap(),p,newsize, false, pblock_size_pre, pblock_size_post); +} + // Reallocate but free `p` on errors mi_decl_nodiscard void* mi_reallocf(void* p, size_t newsize) mi_attr_noexcept { return mi_heap_reallocf(mi_prim_get_default_heap(),p,newsize); @@ -808,11 +427,12 @@ mi_decl_nodiscard void* mi_recalloc(void* p, size_t count, size_t size) mi_attr_ // `strdup` using mi_malloc mi_decl_nodiscard mi_decl_restrict char* mi_heap_strdup(mi_heap_t* heap, const char* s) mi_attr_noexcept { if (s == NULL) return NULL; - size_t n = strlen(s); - char* t = (char*)mi_heap_malloc(heap,n+1); + size_t len = _mi_strlen(s); + if (len > MI_MAX_ALLOC_SIZE - 1) return NULL; // prevent overflow on len+1 + char* t = (char*)mi_heap_malloc(heap,len+1); if (t == NULL) return NULL; - _mi_memcpy(t, s, n); - t[n] = 0; + _mi_memcpy(t, s, len); + t[len] = 0; return t; } @@ -823,13 +443,12 @@ mi_decl_nodiscard mi_decl_restrict char* mi_strdup(const char* s) mi_attr_noexce // `strndup` using mi_malloc mi_decl_nodiscard mi_decl_restrict char* mi_heap_strndup(mi_heap_t* heap, const char* s, size_t n) mi_attr_noexcept { if (s == NULL) return NULL; - const char* end = (const char*)memchr(s, 0, n); // find end of string in the first `n` characters (returns NULL if not found) - const size_t m = (end != NULL ? (size_t)(end - s) : n); // `m` is the minimum of `n` or the end-of-string - mi_assert_internal(m <= n); - char* t = (char*)mi_heap_malloc(heap, m+1); + const size_t len = _mi_strnlen(s,n); // len <= n + if (len > MI_MAX_ALLOC_SIZE - 1) return NULL; // prevent overflow on len+1 + char* t = (char*)mi_heap_malloc(heap, len+1); if (t == NULL) return NULL; - _mi_memcpy(t, s, m); - t[m] = 0; + _mi_memcpy(t, s, len); + t[len] = 0; return t; } @@ -843,16 +462,33 @@ mi_decl_nodiscard mi_decl_restrict char* mi_strndup(const char* s, size_t n) mi_ #ifndef PATH_MAX #define PATH_MAX MAX_PATH #endif -#include + mi_decl_nodiscard mi_decl_restrict char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name) mi_attr_noexcept { // todo: use GetFullPathNameW to allow longer file names + if (fname==NULL || *fname==0) { + errno = EINVAL; + return NULL; + } char buf[PATH_MAX]; DWORD res = GetFullPathNameA(fname, PATH_MAX, (resolved_name == NULL ? buf : resolved_name), NULL); if (res == 0) { - errno = GetLastError(); return NULL; + DWORD err = GetLastError(); + switch (err) { + case ERROR_LOCK_VIOLATION: + case ERROR_SHARING_VIOLATION: + case ERROR_INVALID_ACCESS: errno = EACCES; break; + case ERROR_INVALID_HANDLE: + case ERROR_INVALID_FUNCTION: errno = EINVAL; break; + case ERROR_PATH_NOT_FOUND: errno = ENOTDIR; break; + case ERROR_FILE_NOT_FOUND: errno = ENOENT; break; + case ERROR_NOT_ENOUGH_MEMORY: errno = ENOMEM; break; + default: errno = EIO; + } + return NULL; } else if (res > PATH_MAX) { - errno = EINVAL; return NULL; + errno = ENAMETOOLONG; + return NULL; } else if (resolved_name != NULL) { return resolved_name; @@ -861,34 +497,44 @@ mi_decl_nodiscard mi_decl_restrict char* mi_heap_realpath(mi_heap_t* heap, const return mi_heap_strndup(heap, buf, PATH_MAX); } } + #else -/* + #include // pathconf + static size_t mi_path_max(void) { - static size_t path_max = 0; - if (path_max <= 0) { - long m = pathconf("/",_PC_PATH_MAX); - if (m <= 0) path_max = 4096; // guess - else if (m < 256) path_max = 256; // at least 256 - else path_max = m; + static _Atomic(size_t) path_max = 0; + size_t pmax = mi_atomic_load_acquire(&path_max); + if (pmax == 0) { + long m = 0; + #ifdef _PC_PATH_MAX + m = pathconf("/",_PC_PATH_MAX); + #endif + if (m <= 0) pmax = 4096; // guess + else if (m < 256) pmax = 256; // at least 256 + else if (m > 64*1024) pmax = 64*1024; // at most 64 KiB + else pmax = m; + size_t expected = 0; + mi_atomic_cas_strong_acq_rel(&path_max, &expected, pmax); } - return path_max; + return pmax; } -*/ + char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name) mi_attr_noexcept { if (resolved_name != NULL) { return realpath(fname,resolved_name); } else { + /* char* rname = realpath(fname, NULL); if (rname == NULL) return NULL; char* result = mi_heap_strdup(heap, rname); - free(rname); // use regular free! (which may be redirected to our free but that's ok) + mi_cfree(rname); // note: may leak the original pointer if allocated internally with the system allocator + // note: with ASAN realpath is intercepted and mi_cfree may leak the returned pointer :-( return result; - } - /* + */ const size_t n = mi_path_max(); - char* buf = (char*)mi_malloc(n+1); + char* const buf = (char*)mi_zalloc(n+1); if (buf == NULL) { errno = ENOMEM; return NULL; @@ -898,7 +544,6 @@ char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name) mi_free(buf); return result; } - */ } #endif @@ -913,8 +558,11 @@ The standard requires calling into `get_new_handler` and throwing the bad_alloc exception on failure. If we compile with a C++ compiler we can implement this precisely. If we use a C compiler we cannot throw a `bad_alloc` exception -but we call `exit` instead (i.e. not returning). +but we call `abort` instead (i.e. not returning). +Also, the standard requires calling the new handler until +it returns false, but we limit the total calls. -------------------------------------------------------*/ +#define MI_TRY_NEW_MAX (4) #ifdef __cplusplus #include @@ -927,15 +575,28 @@ static bool mi_try_new_handler(bool nothrow) { #endif if (h==NULL) { _mi_error_message(ENOMEM, "out of memory in 'new'"); + #if defined(_CPPUNWIND) || defined(__cpp_exceptions) // exceptions are not always enabled if (!nothrow) { throw std::bad_alloc(); } + #else + MI_UNUSED(nothrow); + #endif return false; } - else { + else if (!nothrow) { h(); return true; } + else { + try { + h(); + } + catch(...) { // swallow std::bad_alloc + return false; // stop trying + } + return true; + } } #else typedef void (*std_new_handler_t)(void); @@ -949,7 +610,7 @@ static std_new_handler_t mi_get_new_handler(void) { } #else // note: on windows we could dynamically link to `?get_new_handler@std@@YAP6AXXZXZ`. -static std_new_handler_t mi_get_new_handler() { +static std_new_handler_t mi_get_new_handler(void) { return NULL; } #endif @@ -972,7 +633,8 @@ static bool mi_try_new_handler(bool nothrow) { mi_decl_export mi_decl_noinline void* mi_heap_try_new(mi_heap_t* heap, size_t size, bool nothrow ) { void* p = NULL; - while(p == NULL && mi_try_new_handler(nothrow)) { + for(int i = 0; i < MI_TRY_NEW_MAX && p == NULL && mi_try_new_handler(nothrow); i++) { + if (size > MI_MAX_ALLOC_SIZE) return NULL; // call try_new_handler at least once p = mi_heap_malloc(heap,size); } return p; @@ -982,7 +644,6 @@ static mi_decl_noinline void* mi_try_new(size_t size, bool nothrow) { return mi_heap_try_new(mi_prim_get_default_heap(), size, nothrow); } - mi_decl_nodiscard mi_decl_restrict void* mi_heap_alloc_new(mi_heap_t* heap, size_t size) { void* p = mi_heap_malloc(heap,size); if mi_unlikely(p == NULL) return mi_heap_try_new(heap, size, false); @@ -993,7 +654,6 @@ mi_decl_nodiscard mi_decl_restrict void* mi_new(size_t size) { return mi_heap_alloc_new(mi_prim_get_default_heap(), size); } - mi_decl_nodiscard mi_decl_restrict void* mi_heap_alloc_new_n(mi_heap_t* heap, size_t count, size_t size) { size_t total; if mi_unlikely(mi_count_size_overflow(count, size, &total)) { @@ -1006,46 +666,55 @@ mi_decl_nodiscard mi_decl_restrict void* mi_heap_alloc_new_n(mi_heap_t* heap, si } mi_decl_nodiscard mi_decl_restrict void* mi_new_n(size_t count, size_t size) { - return mi_heap_alloc_new_n(mi_prim_get_default_heap(), size, count); + return mi_heap_alloc_new_n(mi_prim_get_default_heap(), count, size); } - mi_decl_nodiscard mi_decl_restrict void* mi_new_nothrow(size_t size) mi_attr_noexcept { void* p = mi_malloc(size); if mi_unlikely(p == NULL) return mi_try_new(size, true); return p; } -mi_decl_nodiscard mi_decl_restrict void* mi_new_aligned(size_t size, size_t alignment) { - void* p; - do { - p = mi_malloc_aligned(size, alignment); +static mi_decl_noinline void* mi_try_new_aligned(size_t size, size_t alignment, bool nothrow) { + void* p = NULL; + for(int i = 0; i < MI_TRY_NEW_MAX && p==NULL && mi_try_new_handler(nothrow); i++) { + if (!mi_alignment_is_valid(alignment)) return NULL; + p = mi_malloc_aligned(size,alignment); } - while(p == NULL && mi_try_new_handler(false)); + return p; +} + +mi_decl_nodiscard mi_decl_restrict void* mi_new_aligned(size_t size, size_t alignment) { + void* p = mi_malloc_aligned(size, alignment); + if mi_unlikely(p==NULL) return mi_try_new_aligned(size,alignment,false); return p; } mi_decl_nodiscard mi_decl_restrict void* mi_new_aligned_nothrow(size_t size, size_t alignment) mi_attr_noexcept { - void* p; - do { - p = mi_malloc_aligned(size, alignment); - } - while(p == NULL && mi_try_new_handler(true)); + void* p = mi_malloc_aligned(size, alignment); + if mi_unlikely(p==NULL) return mi_try_new_aligned(size,alignment,true); return p; } +static mi_decl_noinline void* mi_try_new_realloc(void* p, size_t newsize) { + void* q = NULL; + for(int i = 0; i < MI_TRY_NEW_MAX && q==NULL && mi_try_new_handler(false); i++) { + if (newsize > MI_MAX_ALLOC_SIZE) return NULL; + q = mi_realloc(p,newsize); + } + return q; +} + mi_decl_nodiscard void* mi_new_realloc(void* p, size_t newsize) { - void* q; - do { - q = mi_realloc(p, newsize); - } while (q == NULL && mi_try_new_handler(false)); + void* q = mi_realloc(p, newsize); + if (q == NULL) return mi_try_new_realloc(p,newsize); return q; } mi_decl_nodiscard void* mi_new_reallocn(void* p, size_t newcount, size_t size) { size_t total; if mi_unlikely(mi_count_size_overflow(newcount, size, &total)) { - mi_try_new_handler(false); // on overflow we invoke the try_new_handler once to potentially throw std::bad_alloc + mi_try_new_handler(false); return NULL; } else { @@ -1053,6 +722,93 @@ mi_decl_nodiscard void* mi_new_reallocn(void* p, size_t newcount, size_t size) { } } +#if MI_GUARDED +// We always allocate a guarded allocation at an offset (`mi_page_has_aligned` will be true). +// We then set the first word of the block to `0` for regular offset aligned allocations (in `alloc-aligned.c`) +// and the first word to `~0` for guarded allocations to have a correct `mi_usable_size` + +static void* mi_block_ptr_set_guarded(mi_block_t* block, size_t obj_size, size_t* usable_size) { + // TODO: we can still make padding work by moving it out of the guard page area + mi_page_t* const page = _mi_ptr_page(block); + mi_page_set_has_aligned(page, true); + block->next = MI_BLOCK_TAG_GUARDED; + + // set guard page at the end of the block + mi_segment_t* const segment = _mi_page_segment(page); + const size_t block_size = mi_page_block_size(page); // must use `block_size` to match `mi_free_local` + const size_t os_page_size = _mi_os_page_size(); + mi_assert_internal(block_size >= obj_size + os_page_size + sizeof(mi_block_t)); + if (block_size < obj_size + os_page_size + sizeof(mi_block_t)) { + // should never happen + mi_free(block); + return NULL; + } + uint8_t* guard_page = (uint8_t*)block + block_size - os_page_size; + mi_assert_internal(_mi_is_aligned(guard_page, os_page_size)); + if mi_likely(segment->allow_decommit && _mi_is_aligned(guard_page, os_page_size)) { + const bool ok = _mi_os_protect(guard_page, os_page_size); + if mi_unlikely(!ok) { + _mi_warning_message("failed to set a guard page behind an object (object %p of size %zu)\n", block, block_size); + } + } + else { + _mi_warning_message("unable to set a guard page behind an object due to pinned memory (large OS pages?) (object %p of size %zu)\n", block, block_size); + } + + // align pointer just in front of the guard page + size_t offset = block_size - os_page_size - obj_size; + mi_assert_internal(offset > sizeof(mi_block_t)); + if (offset > MI_BLOCK_ALIGNMENT_MAX) { + // give up to place it right in front of the guard page if the offset is too large for unalignment + offset = MI_BLOCK_ALIGNMENT_MAX; + } + uint8_t* const p = (uint8_t*)block + offset; + mi_assert_internal(p == guard_page - obj_size || offset == MI_BLOCK_ALIGNMENT_MAX); + if (usable_size != NULL) { *usable_size = (guard_page - p); mi_assert_internal(mi_usable_size(p)==*usable_size); } + mi_track_align(block, p, offset, obj_size); + mi_track_mem_defined(block, sizeof(mi_block_t)); + return p; +} + +mi_decl_restrict void* _mi_heap_malloc_guarded(mi_heap_t* heap, size_t size, bool zero, mi_page_t** ppage) mi_attr_noexcept +{ + // allocate multiple of page size ending in a guard page + // ensure minimal alignment requirement? + if mi_unlikely(size >= MI_MAX_ALLOC_SIZE - MI_PADDING_SIZE) { // check up front so the `req_size` won't overflow + _mi_error_message(EOVERFLOW, "(guarded) allocation request is too large (%zu bytes)\n", size); + return NULL; + } + const size_t os_page_size = _mi_os_page_size(); + const size_t obj_size = (mi_option_is_enabled(mi_option_guarded_precise) ? size : _mi_align_up(size, MI_MAX_ALIGN_SIZE)); + const size_t bsize = _mi_align_up(_mi_align_up(obj_size, MI_MAX_ALIGN_SIZE) + sizeof(mi_block_t), MI_MAX_ALIGN_SIZE); + const size_t req_size = _mi_align_up(bsize + os_page_size, os_page_size); + mi_block_t* const block = (mi_block_t*)_mi_malloc_generic(heap, req_size, false /* don't zero */, 0 /* huge_alignment */, ppage); + if (block==NULL) return NULL; + size_t usable_size = 0; + void* const p = mi_block_ptr_set_guarded(block, obj_size, &usable_size); + if (p == NULL) return NULL; + if (zero) { + _mi_memzero(p,obj_size); // we have to zero afterwards as padding might have written inside the block (if the `blocksize > reqsize + os_page_size`) + } + + // stats + mi_track_malloc(p, usable_size, zero); + if (!mi_heap_is_initialized(heap)) { heap = mi_prim_get_default_heap(); } + _mi_stat_counter_increase(&heap->tld->stats.malloc_guarded_count, 1); + #if MI_STAT>1 + // adjust stats to only count the allocated size of the block (and not the guard page) + mi_heap_stat_adjust_decrease(heap, malloc_requested, req_size); + mi_heap_stat_increase(heap, malloc_requested, size); + #endif + #if MI_DEBUG>3 + if (zero) { + mi_assert_expensive(mi_mem_is_zero(p, size)); + } + #endif + return p; +} +#endif + // ------------------------------------------------------ // ensure explicit external inline definitions are emitted! // ------------------------------------------------------ @@ -1060,6 +816,7 @@ mi_decl_nodiscard void* mi_new_reallocn(void* p, size_t newcount, size_t size) { #ifdef __cplusplus void* _mi_externs[] = { (void*)&_mi_page_malloc, + (void*)&_mi_page_malloc_zero, (void*)&_mi_heap_malloc_zero, (void*)&_mi_heap_malloc_zero_ex, (void*)&mi_malloc, diff --git a/Objects/mimalloc/arena-abandon.c b/Objects/mimalloc/arena-abandon.c new file mode 100644 index 000000000000000..fdc2a4a902a1daa --- /dev/null +++ b/Objects/mimalloc/arena-abandon.c @@ -0,0 +1,349 @@ +/* ---------------------------------------------------------------------------- +Copyright (c) 2019-2024, Microsoft Research, Daan Leijen +This is free software; you can redistribute it and/or modify it under the +terms of the MIT license. A copy of the license can be found in the file +"LICENSE" at the root of this distribution. +-----------------------------------------------------------------------------*/ + +#if !defined(MI_IN_ARENA_C) +#error "this file should be included from 'arena.c' (so mi_arena_t is visible)" +// add includes help an IDE +#include "mimalloc.h" +#include "mimalloc/internal.h" +#include "bitmap.h" +#endif + +// Minimal exports for arena-abandoned. +size_t mi_arena_id_index(mi_arena_id_t id); +mi_arena_t* mi_arena_from_index(size_t idx); +size_t mi_arena_get_count(void); +void* mi_arena_block_start(mi_arena_t* arena, mi_bitmap_index_t bindex); +bool mi_arena_memid_indices(mi_memid_t memid, size_t* arena_index, mi_bitmap_index_t* bitmap_index); + +/* ----------------------------------------------------------- + Abandoned blocks/segments: + + _mi_arena_segment_clear_abandoned + _mi_arena_segment_mark_abandoned + + This is used to atomically abandon/reclaim segments + (and crosses the arena API but it is convenient to have here). + + Abandoned segments still have live blocks; they get reclaimed + when a thread frees a block in it, or when a thread needs a fresh + segment. + + Abandoned segments are atomically marked in the `block_abandoned` + bitmap of arenas. Any segments allocated outside arenas are put + in the sub-process `abandoned_os_list`. This list is accessed + using locks but this should be uncommon and generally uncontended. + Reclaim and visiting either scan through the `block_abandoned` + bitmaps of the arena's, or visit the `abandoned_os_list` + + A potentially nicer design is to use arena's for everything + and perhaps have virtual arena's to map OS allocated memory + but this would lack the "density" of our current arena's. TBC. +----------------------------------------------------------- */ + + +// reclaim a specific OS abandoned segment; `true` on success. +// sets the thread_id. +static bool mi_arena_segment_os_clear_abandoned(mi_segment_t* segment, bool take_lock) { + mi_assert(segment->memid.memkind != MI_MEM_ARENA); + // not in an arena, remove from list of abandoned os segments + mi_subproc_t* const subproc = segment->subproc; + if (take_lock && !mi_lock_try_acquire(&subproc->abandoned_os_lock)) { + return false; // failed to acquire the lock, we just give up + } + // remove atomically from the abandoned os list (if possible!) + bool reclaimed = false; + mi_segment_t* const next = segment->abandoned_os_next; + mi_segment_t* const prev = segment->abandoned_os_prev; + if (next != NULL || prev != NULL || subproc->abandoned_os_list == segment) { + #if MI_DEBUG>3 + // find ourselves in the abandoned list (and check the count) + bool found = false; + size_t count = 0; + for (mi_segment_t* current = subproc->abandoned_os_list; current != NULL; current = current->abandoned_os_next) { + if (current == segment) { found = true; } + count++; + } + mi_assert_internal(found); + mi_assert_internal(count == mi_atomic_load_relaxed(&subproc->abandoned_os_list_count)); + #endif + // remove (atomically) from the list and reclaim + if (prev != NULL) { prev->abandoned_os_next = next; } + else { subproc->abandoned_os_list = next; } + if (next != NULL) { next->abandoned_os_prev = prev; } + else { subproc->abandoned_os_list_tail = prev; } + segment->abandoned_os_next = NULL; + segment->abandoned_os_prev = NULL; + mi_atomic_decrement_relaxed(&subproc->abandoned_count); + mi_atomic_decrement_relaxed(&subproc->abandoned_os_list_count); + if (take_lock) { // don't reset the thread_id when iterating + mi_atomic_store_release(&segment->thread_id, _mi_thread_id()); + } + reclaimed = true; + } + if (take_lock) { mi_lock_release(&segment->subproc->abandoned_os_lock); } + return reclaimed; +} + +// reclaim a specific abandoned segment; `true` on success. +// sets the thread_id. +bool _mi_arena_segment_clear_abandoned(mi_segment_t* segment) { + if mi_unlikely(segment->memid.memkind != MI_MEM_ARENA) { + return mi_arena_segment_os_clear_abandoned(segment, true /* take lock */); + } + // arena segment: use the blocks_abandoned bitmap. + size_t arena_idx; + size_t bitmap_idx; + mi_arena_memid_indices(segment->memid, &arena_idx, &bitmap_idx); + mi_arena_t* arena = mi_arena_from_index(arena_idx); + mi_assert_internal(arena != NULL); + // reclaim atomically + bool was_marked = _mi_bitmap_unclaim(arena->blocks_abandoned, arena->field_count, 1, bitmap_idx); + if (was_marked) { + mi_assert_internal(mi_atomic_load_acquire(&segment->thread_id) == 0); + mi_atomic_decrement_relaxed(&segment->subproc->abandoned_count); + mi_atomic_store_release(&segment->thread_id, _mi_thread_id()); + } + // mi_assert_internal(was_marked); + mi_assert_internal(!was_marked || _mi_bitmap_is_claimed(arena->blocks_inuse, arena->field_count, 1, bitmap_idx)); + //mi_assert_internal(arena->blocks_committed == NULL || _mi_bitmap_is_claimed(arena->blocks_committed, arena->field_count, 1, bitmap_idx)); + return was_marked; +} + + +// mark a specific OS segment as abandoned +static void mi_arena_segment_os_mark_abandoned(mi_segment_t* segment) { + mi_assert(segment->memid.memkind != MI_MEM_ARENA); + // not in an arena; we use a list of abandoned segments + mi_subproc_t* const subproc = segment->subproc; + mi_lock(&subproc->abandoned_os_lock) { + // push on the tail of the list (important for the visitor) + mi_segment_t* prev = subproc->abandoned_os_list_tail; + mi_assert_internal(prev == NULL || prev->abandoned_os_next == NULL); + mi_assert_internal(segment->abandoned_os_prev == NULL); + mi_assert_internal(segment->abandoned_os_next == NULL); + if (prev != NULL) { prev->abandoned_os_next = segment; } + else { subproc->abandoned_os_list = segment; } + subproc->abandoned_os_list_tail = segment; + segment->abandoned_os_prev = prev; + segment->abandoned_os_next = NULL; + mi_atomic_increment_relaxed(&subproc->abandoned_os_list_count); + mi_atomic_increment_relaxed(&subproc->abandoned_count); + // and release the lock + } + return; +} + +// mark a specific segment as abandoned +// clears the thread_id. +void _mi_arena_segment_mark_abandoned(mi_segment_t* segment) +{ + mi_assert_internal(segment->used == segment->abandoned); + mi_atomic_store_release(&segment->thread_id, (uintptr_t)0); // mark as abandoned for multi-thread free's + if mi_unlikely(segment->memid.memkind != MI_MEM_ARENA) { + mi_arena_segment_os_mark_abandoned(segment); + return; + } + // segment is in an arena, mark it in the arena `blocks_abandoned` bitmap + size_t arena_idx; + size_t bitmap_idx; + mi_arena_memid_indices(segment->memid, &arena_idx, &bitmap_idx); + mi_arena_t* arena = mi_arena_from_index(arena_idx); + mi_assert_internal(arena != NULL); + // set abandonment atomically + mi_subproc_t* const subproc = segment->subproc; // don't access the segment after setting it abandoned + const bool was_unmarked = _mi_bitmap_claim(arena->blocks_abandoned, arena->field_count, 1, bitmap_idx, NULL); + if (was_unmarked) { mi_atomic_increment_relaxed(&subproc->abandoned_count); } + mi_assert_internal(was_unmarked); + mi_assert_internal(_mi_bitmap_is_claimed(arena->blocks_inuse, arena->field_count, 1, bitmap_idx)); +} + + +/* ----------------------------------------------------------- + Iterate through the abandoned blocks/segments using a cursor. + This is used for reclaiming and abandoned block visiting. +----------------------------------------------------------- */ + +// start a cursor at a randomized arena +void _mi_arena_field_cursor_init(mi_heap_t* heap, mi_subproc_t* subproc, bool visit_all, mi_arena_field_cursor_t* current) { + mi_assert_internal(heap == NULL || heap->tld->segments.subproc == subproc); + current->bitmap_idx = 0; + current->subproc = subproc; + current->visit_all = visit_all; + current->hold_visit_lock = false; + const size_t abandoned_count = mi_atomic_load_relaxed(&subproc->abandoned_count); + const size_t abandoned_list_count = mi_atomic_load_relaxed(&subproc->abandoned_os_list_count); + const size_t max_arena = mi_arena_get_count(); + if (heap != NULL && heap->arena_id != _mi_arena_id_none()) { + // for a heap that is bound to one arena, only visit that arena + current->start = mi_arena_id_index(heap->arena_id); + current->end = current->start + 1; + current->os_list_count = 0; + } + else { + // otherwise visit all starting at a random location + if (abandoned_count > abandoned_list_count && max_arena > 0) { + current->start = (heap == NULL || max_arena == 0 ? 0 : (mi_arena_id_t)(_mi_heap_random_next(heap) % max_arena)); + current->end = current->start + max_arena; + } + else { + current->start = 0; + current->end = 0; + } + current->os_list_count = abandoned_list_count; // max entries to visit in the os abandoned list + } + mi_assert_internal(current->start <= max_arena); +} + +void _mi_arena_field_cursor_done(mi_arena_field_cursor_t* current) { + if (current->hold_visit_lock) { + mi_lock_release(¤t->subproc->abandoned_os_visit_lock); + current->hold_visit_lock = false; + } +} + +static mi_segment_t* mi_arena_segment_clear_abandoned_at(mi_arena_t* arena, mi_subproc_t* subproc, mi_bitmap_index_t bitmap_idx) { + // try to reclaim an abandoned segment in the arena atomically + if (!_mi_bitmap_unclaim(arena->blocks_abandoned, arena->field_count, 1, bitmap_idx)) return NULL; + mi_assert_internal(_mi_bitmap_is_claimed(arena->blocks_inuse, arena->field_count, 1, bitmap_idx)); + mi_segment_t* segment = (mi_segment_t*)mi_arena_block_start(arena, bitmap_idx); + mi_assert_internal(mi_atomic_load_relaxed(&segment->thread_id) == 0); + // check that the segment belongs to our sub-process + // note: this is the reason we need the `abandoned_visit` lock in the case abandoned visiting is enabled. + // without the lock an abandoned visit may otherwise fail to visit all abandoned segments in the sub-process. + // for regular reclaim it is fine to miss one sometimes so without abandoned visiting we don't need the `abandoned_visit` lock. + if (segment->subproc != subproc) { + // it is from another sub-process, re-mark it and continue searching + const bool was_zero = _mi_bitmap_claim(arena->blocks_abandoned, arena->field_count, 1, bitmap_idx, NULL); + mi_assert_internal(was_zero); MI_UNUSED(was_zero); + return NULL; + } + else { + // success, we unabandoned a segment in our sub-process + mi_atomic_decrement_relaxed(&subproc->abandoned_count); + return segment; + } +} + +static mi_segment_t* mi_arena_segment_clear_abandoned_next_field(mi_arena_field_cursor_t* previous) { + const size_t max_arena = mi_arena_get_count(); + size_t field_idx = mi_bitmap_index_field(previous->bitmap_idx); + size_t bit_idx = mi_bitmap_index_bit_in_field(previous->bitmap_idx); + // visit arena's (from the previous cursor) + for (; previous->start < previous->end; previous->start++, field_idx = 0, bit_idx = 0) { + // index wraps around + size_t arena_idx = (previous->start >= max_arena ? previous->start % max_arena : previous->start); + mi_arena_t* arena = mi_arena_from_index(arena_idx); + if (arena != NULL) { + bool has_lock = false; + // CPython: gh-161751: for a full visit, take the lock before reading the bitmap. + // A reclaim from another sub-process can clear our bit for a short time. + if (previous->visit_all && mi_option_is_enabled(mi_option_visit_abandoned)) { + mi_lock_acquire(&arena->abandoned_visit_lock); + has_lock = true; + } + // visit the abandoned fields (starting at previous_idx) + for (; field_idx < arena->field_count; field_idx++, bit_idx = 0) { + size_t field = mi_atomic_load_relaxed(&arena->blocks_abandoned[field_idx]); + if mi_unlikely(field != 0) { // skip zero fields quickly + // a reclaim tries to take the lock only when the field has abandoned segments + if (!has_lock && mi_option_is_enabled(mi_option_visit_abandoned)) { + has_lock = mi_lock_try_acquire(&arena->abandoned_visit_lock); + if (!has_lock) { + // skip to next arena + break; + } + } + mi_assert_internal(has_lock || !mi_option_is_enabled(mi_option_visit_abandoned)); + // visit each set bit in the field (todo: maybe use `ctz` here?) + for (; bit_idx < MI_BITMAP_FIELD_BITS; bit_idx++) { + // pre-check if the bit is set + size_t mask = ((size_t)1 << bit_idx); + if mi_unlikely((field & mask) == mask) { + mi_bitmap_index_t bitmap_idx = mi_bitmap_index_create(field_idx, bit_idx); + mi_segment_t* const segment = mi_arena_segment_clear_abandoned_at(arena, previous->subproc, bitmap_idx); + if (segment != NULL) { + //mi_assert_internal(arena->blocks_committed == NULL || _mi_bitmap_is_claimed(arena->blocks_committed, arena->field_count, 1, bitmap_idx)); + if (has_lock) { mi_lock_release(&arena->abandoned_visit_lock); } + previous->bitmap_idx = mi_bitmap_index_create_ex(field_idx, bit_idx + 1); // start at next one for the next iteration + return segment; + } + } + } + } + } + if (has_lock) { mi_lock_release(&arena->abandoned_visit_lock); } + } + } + return NULL; +} + +static mi_segment_t* mi_arena_segment_clear_abandoned_next_list(mi_arena_field_cursor_t* previous) { + // go through the abandoned_os_list + // we only allow one thread per sub-process to do to visit guarded by the `abandoned_os_visit_lock`. + // The lock is released when the cursor is released. + if (!previous->hold_visit_lock) { + previous->hold_visit_lock = (previous->visit_all ? (mi_lock_acquire(&previous->subproc->abandoned_os_visit_lock),true) + : mi_lock_try_acquire(&previous->subproc->abandoned_os_visit_lock)); + if (!previous->hold_visit_lock) { + if (previous->visit_all) { + _mi_error_message(EFAULT, "internal error: failed to visit all abandoned segments due to failure to acquire the OS visitor lock"); + } + return NULL; // we cannot get the lock, give up + } + } + // One list entry at a time + while (previous->os_list_count > 0) { + previous->os_list_count--; + mi_lock_acquire(&previous->subproc->abandoned_os_lock); // this could contend with concurrent OS block abandonment and reclaim from `free` + mi_segment_t* segment = previous->subproc->abandoned_os_list; + // pop from head of the list, a subsequent mark will push at the end (and thus we iterate through os_list_count entries) + if (segment == NULL || mi_arena_segment_os_clear_abandoned(segment, false /* we already have the lock */)) { + mi_lock_release(&previous->subproc->abandoned_os_lock); + return segment; + } + // already abandoned, try again + mi_lock_release(&previous->subproc->abandoned_os_lock); + } + // done + mi_assert_internal(previous->os_list_count == 0); + return NULL; +} + + +// reclaim abandoned segments +// this does not set the thread id (so it appears as still abandoned) +mi_segment_t* _mi_arena_segment_clear_abandoned_next(mi_arena_field_cursor_t* previous) { + if (previous->start < previous->end) { + // walk the arena + mi_segment_t* segment = mi_arena_segment_clear_abandoned_next_field(previous); + if (segment != NULL) { return segment; } + } + // no entries in the arena's anymore, walk the abandoned OS list + mi_assert_internal(previous->start == previous->end); + return mi_arena_segment_clear_abandoned_next_list(previous); +} + + +bool mi_abandoned_visit_blocks(mi_subproc_id_t subproc_id, int heap_tag, bool visit_blocks, mi_block_visit_fun* visitor, void* arg) { + // (unfortunately) the visit_abandoned option must be enabled from the start. + // This is to avoid taking locks if abandoned list visiting is not required (as for most programs) + if (!mi_option_is_enabled(mi_option_visit_abandoned)) { + _mi_error_message(EFAULT, "internal error: can only visit abandoned blocks when MIMALLOC_VISIT_ABANDONED=ON"); + return false; + } + mi_arena_field_cursor_t current; + _mi_arena_field_cursor_init(NULL, _mi_subproc_from_id(subproc_id), true /* visit all (blocking) */, ¤t); + mi_segment_t* segment; + bool ok = true; + while (ok && (segment = _mi_arena_segment_clear_abandoned_next(¤t)) != NULL) { + ok = _mi_segment_visit_blocks(segment, heap_tag, visit_blocks, visitor, arg); + _mi_arena_segment_mark_abandoned(segment); + } + _mi_arena_field_cursor_done(¤t); + return ok; +} diff --git a/Objects/mimalloc/arena.c b/Objects/mimalloc/arena.c index 5db5d950c43b683..9b98ea77e57ceb4 100644 --- a/Objects/mimalloc/arena.c +++ b/Objects/mimalloc/arena.c @@ -1,5 +1,5 @@ /* ---------------------------------------------------------------------------- -Copyright (c) 2019-2023, Microsoft Research, Daan Leijen +Copyright (c) 2019-2024, Microsoft Research, Daan Leijen This is free software; you can redistribute it and/or modify it under the terms of the MIT license. A copy of the license can be found in the file "LICENSE" at the root of this distribution. @@ -11,67 +11,68 @@ large blocks (>= MI_ARENA_MIN_BLOCK_SIZE, 4MiB). In contrast to the rest of mimalloc, the arenas are shared between threads and need to be accessed using atomic operations. -Arenas are used to for huge OS page (1GiB) reservations or for reserving +Arenas are also used to for huge OS page (1GiB) reservations or for reserving OS memory upfront which can be improve performance or is sometimes needed on embedded devices. We can also employ this with WASI or `sbrk` systems to reserve large arenas upfront and be able to reuse the memory more effectively. The arena allocation needs to be thread safe and we use an atomic bitmap to allocate. -----------------------------------------------------------------------------*/ + #include "mimalloc.h" #include "mimalloc/internal.h" #include "mimalloc/atomic.h" +#include "bitmap.h" -#include // memset -#include // ENOMEM - -#include "bitmap.h" // atomic bitmap /* ----------------------------------------------------------- Arena allocation ----------------------------------------------------------- */ -// Block info: bit 0 contains the `in_use` bit, the upper bits the -// size in count of arena blocks. -typedef uintptr_t mi_block_info_t; -#define MI_ARENA_BLOCK_SIZE (MI_SEGMENT_SIZE) // 64MiB (must be at least MI_SEGMENT_ALIGN) -#define MI_ARENA_MIN_OBJ_SIZE (MI_ARENA_BLOCK_SIZE/2) // 32MiB -#define MI_MAX_ARENAS (112) // not more than 126 (since we use 7 bits in the memid and an arena index + 1) - // A memory arena descriptor typedef struct mi_arena_s { - mi_arena_id_t id; // arena id; 0 for non-specific - mi_memid_t memid; // memid of the memory area - _Atomic(uint8_t*) start; // the start of the memory area - size_t block_count; // size of the area in arena blocks (of `MI_ARENA_BLOCK_SIZE`) - size_t field_count; // number of bitmap fields (where `field_count * MI_BITMAP_FIELD_BITS >= block_count`) - size_t meta_size; // size of the arena structure itself (including its bitmaps) - mi_memid_t meta_memid; // memid of the arena structure itself (OS or static allocation) - int numa_node; // associated NUMA node - bool exclusive; // only allow allocations if specifically for this arena - bool is_large; // memory area consists of large- or huge OS pages (always committed) - _Atomic(size_t) search_idx; // optimization to start the search for free blocks - _Atomic(mi_msecs_t) purge_expire; // expiration time when blocks should be decommitted from `blocks_decommit`. - mi_bitmap_field_t* blocks_dirty; // are the blocks potentially non-zero? - mi_bitmap_field_t* blocks_committed; // are the blocks committed? (can be NULL for memory that cannot be decommitted) - mi_bitmap_field_t* blocks_purge; // blocks that can be (reset) decommitted. (can be NULL for memory that cannot be (reset) decommitted) - mi_bitmap_field_t blocks_inuse[1]; // in-place bitmap of in-use blocks (of size `field_count`) + mi_arena_id_t id; // arena id; 0 for non-specific + mi_memid_t memid; // memid of the memory area + _Atomic(uint8_t*) start; // the start of the memory area + size_t block_count; // size of the area in arena blocks (of `MI_ARENA_BLOCK_SIZE`) + size_t field_count; // number of bitmap fields (where `field_count * MI_BITMAP_FIELD_BITS >= block_count`) + size_t meta_size; // size of the arena structure itself (including its bitmaps) + mi_memid_t meta_memid; // memid of the arena structure itself (OS or static allocation) + int numa_node; // associated NUMA node + bool exclusive; // only allow allocations if specifically for this arena + bool is_large; // memory area consists of large- or huge OS pages (always committed) + mi_lock_t abandoned_visit_lock; // lock is only used when abandoned segments are being visited + _Atomic(size_t) search_idx; // optimization to start the search for free blocks + _Atomic(mi_msecs_t) purge_expire; // expiration time when blocks should be purged from `blocks_purge`. + + mi_bitmap_field_t* blocks_dirty; // are the blocks potentially non-zero? + mi_bitmap_field_t* blocks_committed; // are the blocks committed? (can be NULL for memory that cannot be decommitted) + mi_bitmap_field_t* blocks_purge; // blocks that can be (reset) decommitted. (can be NULL for memory that cannot be (reset) decommitted) + mi_bitmap_field_t* blocks_abandoned; // blocks that start with an abandoned segment. (This crosses API's but it is convenient to have here) + mi_bitmap_field_t blocks_inuse[1]; // in-place bitmap of in-use blocks (of size `field_count`) + // do not add further fields here as the dirty, committed, purged, and abandoned bitmaps follow the inuse bitmap fields. } mi_arena_t; +#define MI_ARENA_BLOCK_SIZE (MI_SEGMENT_SIZE) // 64MiB (must be at least MI_SEGMENT_ALIGN) +#define MI_ARENA_MIN_OBJ_SIZE (MI_ARENA_BLOCK_SIZE/2) // 32MiB +#define MI_MAX_ARENAS (132) // Limited as the reservation exponentially increases (and takes up .bss) + // The available arenas static mi_decl_cache_align _Atomic(mi_arena_t*) mi_arenas[MI_MAX_ARENAS]; static mi_decl_cache_align _Atomic(size_t) mi_arena_count; // = 0 +static mi_decl_cache_align _Atomic(int64_t) mi_arenas_purge_expire; // set if there exist purgeable arenas - -//static bool mi_manage_os_memory_ex2(void* start, size_t size, bool is_large, int numa_node, bool exclusive, mi_memid_t memid, mi_arena_id_t* arena_id) mi_attr_noexcept; +#define MI_IN_ARENA_C +#include "arena-abandon.c" +#undef MI_IN_ARENA_C /* ----------------------------------------------------------- Arena id's id = arena_index + 1 ----------------------------------------------------------- */ -static size_t mi_arena_id_index(mi_arena_id_t id) { +size_t mi_arena_id_index(mi_arena_id_t id) { return (size_t)(id <= 0 ? MI_MAX_ARENAS : id - 1); } @@ -94,7 +95,7 @@ bool _mi_arena_memid_is_suitable(mi_memid_t memid, mi_arena_id_t request_arena_i return mi_arena_id_is_suitable(memid.mem.arena.id, memid.mem.arena.is_exclusive, request_arena_id); } else { - return mi_arena_id_is_suitable(0, false, request_arena_id); + return mi_arena_id_is_suitable(_mi_arena_id_none(), false, request_arena_id); } } @@ -102,6 +103,16 @@ bool _mi_arena_memid_is_os_allocated(mi_memid_t memid) { return (memid.memkind == MI_MEM_OS); } +size_t mi_arena_get_count(void) { + return mi_atomic_load_relaxed(&mi_arena_count); +} + +mi_arena_t* mi_arena_from_index(size_t idx) { + mi_assert_internal(idx < mi_arena_get_count()); + return mi_atomic_load_ptr_acquire(mi_arena_t, &mi_arenas[idx]); +} + + /* ----------------------------------------------------------- Arena allocations get a (currently) 16-bit memory id where the lower 8 bits are the arena id, and the upper bits the block index. @@ -127,7 +138,7 @@ static mi_memid_t mi_memid_create_arena(mi_arena_id_t id, bool is_exclusive, mi_ return memid; } -static bool mi_arena_memid_indices(mi_memid_t memid, size_t* arena_index, mi_bitmap_index_t* bitmap_index) { +bool mi_arena_memid_indices(mi_memid_t memid, size_t* arena_index, mi_bitmap_index_t* bitmap_index) { mi_assert_internal(memid.memkind == MI_MEM_ARENA); *arena_index = mi_arena_id_index(memid.mem.arena.id); *bitmap_index = memid.mem.arena.block_index; @@ -138,23 +149,24 @@ static bool mi_arena_memid_indices(mi_memid_t memid, size_t* arena_index, mi_bit /* ----------------------------------------------------------- Special static area for mimalloc internal structures - to avoid OS calls (for example, for the arena metadata) + to avoid OS calls (for example, for the arena metadata (~= 256b)) ----------------------------------------------------------- */ -#define MI_ARENA_STATIC_MAX (MI_INTPTR_SIZE*MI_KiB) // 8 KiB on 64-bit +#define MI_ARENA_STATIC_MAX ((MI_INTPTR_SIZE/2)*MI_KiB) // 4 KiB on 64-bit -static uint8_t mi_arena_static[MI_ARENA_STATIC_MAX]; -static _Atomic(size_t) mi_arena_static_top; +static mi_decl_cache_align uint8_t mi_arena_static[MI_ARENA_STATIC_MAX]; // must be cache aligned, see issue #895 +static mi_decl_cache_align _Atomic(size_t) mi_arena_static_top; static void* mi_arena_static_zalloc(size_t size, size_t alignment, mi_memid_t* memid) { *memid = _mi_memid_none(); if (size == 0 || size > MI_ARENA_STATIC_MAX) return NULL; - if ((mi_atomic_load_relaxed(&mi_arena_static_top) + size) > MI_ARENA_STATIC_MAX) return NULL; + const size_t toplow = mi_atomic_load_relaxed(&mi_arena_static_top); + if ((toplow + size) > MI_ARENA_STATIC_MAX) return NULL; // try to claim space - if (alignment == 0) { alignment = 1; } + if (alignment < MI_MAX_ALIGN_SIZE) { alignment = MI_MAX_ALIGN_SIZE; } const size_t oversize = size + alignment - 1; - if (oversize > MI_ARENA_STATIC_MAX) return NULL; + if (toplow + oversize > MI_ARENA_STATIC_MAX) return NULL; const size_t oldtop = mi_atomic_add_acq_rel(&mi_arena_static_top, oversize); size_t top = oldtop + oversize; if (top > MI_ARENA_STATIC_MAX) { @@ -165,33 +177,37 @@ static void* mi_arena_static_zalloc(size_t size, size_t alignment, mi_memid_t* m // success *memid = _mi_memid_create(MI_MEM_STATIC); + memid->initially_zero = true; const size_t start = _mi_align_up(oldtop, alignment); uint8_t* const p = &mi_arena_static[start]; - _mi_memzero(p, size); + _mi_memzero_aligned(p, size); return p; } -static void* mi_arena_meta_zalloc(size_t size, mi_memid_t* memid, mi_stats_t* stats) { +void* _mi_arena_meta_zalloc(size_t size, mi_memid_t* memid) { *memid = _mi_memid_none(); // try static - void* p = mi_arena_static_zalloc(size, MI_ALIGNMENT_MAX, memid); + void* p = mi_arena_static_zalloc(size, MI_MAX_ALIGN_SIZE, memid); if (p != NULL) return p; // or fall back to the OS - return _mi_os_alloc(size, memid, stats); + p = _mi_os_zalloc(size, memid); + if (p == NULL) return NULL; + + return p; } -static void mi_arena_meta_free(void* p, mi_memid_t memid, size_t size, mi_stats_t* stats) { +void _mi_arena_meta_free(void* p, mi_memid_t memid, size_t size) { if (mi_memkind_is_os(memid.memkind)) { - _mi_os_free(p, size, memid, stats); + _mi_os_free(p, size, memid); } else { mi_assert(memid.memkind == MI_MEM_STATIC); } } -static void* mi_arena_block_start(mi_arena_t* arena, mi_bitmap_index_t bindex) { +void* mi_arena_block_start(mi_arena_t* arena, mi_bitmap_index_t bindex) { return (arena->start + mi_arena_block_size(mi_bitmap_index_bit(bindex))); } @@ -217,7 +233,7 @@ static bool mi_arena_try_claim(mi_arena_t* arena, size_t blocks, mi_bitmap_index ----------------------------------------------------------- */ static mi_decl_noinline void* mi_arena_try_alloc_at(mi_arena_t* arena, size_t arena_index, size_t needed_bcount, - bool commit, mi_memid_t* memid, mi_os_tld_t* tld) + bool commit, mi_memid_t* memid) { MI_UNUSED(arena_index); mi_assert_internal(mi_arena_id_index(arena->id) == arena_index); @@ -238,7 +254,7 @@ static mi_decl_noinline void* mi_arena_try_alloc_at(mi_arena_t* arena, size_t ar // set the dirty bits (todo: no need for an atomic op here?) if (arena->memid.initially_zero && arena->blocks_dirty != NULL) { - memid->initially_zero = _mi_bitmap_claim_across(arena->blocks_dirty, arena->field_count, needed_bcount, bitmap_index, NULL); + memid->initially_zero = _mi_bitmap_claim_across(arena->blocks_dirty, arena->field_count, needed_bcount, bitmap_index, NULL, NULL); } // set commit state @@ -249,21 +265,38 @@ static mi_decl_noinline void* mi_arena_try_alloc_at(mi_arena_t* arena, size_t ar else if (commit) { // commit requested, but the range may not be committed as a whole: ensure it is committed now memid->initially_committed = true; + const size_t commit_size = mi_arena_block_size(needed_bcount); bool any_uncommitted; - _mi_bitmap_claim_across(arena->blocks_committed, arena->field_count, needed_bcount, bitmap_index, &any_uncommitted); + size_t already_committed = 0; + _mi_bitmap_claim_across(arena->blocks_committed, arena->field_count, needed_bcount, bitmap_index, &any_uncommitted, &already_committed); if (any_uncommitted) { + mi_assert_internal(already_committed < needed_bcount); + const size_t stat_commit_size = commit_size - mi_arena_block_size(already_committed); bool commit_zero = false; - if (!_mi_os_commit(p, mi_arena_block_size(needed_bcount), &commit_zero, tld->stats)) { + if (!_mi_os_commit_ex(p, commit_size, &commit_zero, stat_commit_size)) { + // set all as uncommitted on commit failure + _mi_bitmap_unclaim_across(arena->blocks_committed, arena->field_count, needed_bcount, bitmap_index); memid->initially_committed = false; } else { if (commit_zero) { memid->initially_zero = true; } } } + else { + // all are already committed: signal that we are reusing memory in case it was purged before + _mi_os_reuse( p, commit_size ); + } } else { // no need to commit, but check if already fully committed - memid->initially_committed = _mi_bitmap_is_claimed_across(arena->blocks_committed, arena->field_count, needed_bcount, bitmap_index); + size_t already_committed = 0; + memid->initially_committed = _mi_bitmap_is_claimed_across(arena->blocks_committed, arena->field_count, needed_bcount, bitmap_index, &already_committed); + if (!memid->initially_committed && already_committed > 0) { + // partially committed: as it will be committed at some time, adjust the stats and pretend the range is fully uncommitted. + mi_assert_internal(already_committed < needed_bcount); + _mi_stat_decrease(&_mi_stats_main.committed, mi_arena_block_size(already_committed)); + _mi_bitmap_unclaim_across(arena->blocks_committed, arena->field_count, needed_bcount, bitmap_index); + } } return p; @@ -271,17 +304,17 @@ static mi_decl_noinline void* mi_arena_try_alloc_at(mi_arena_t* arena, size_t ar // allocate in a specific arena static void* mi_arena_try_alloc_at_id(mi_arena_id_t arena_id, bool match_numa_node, int numa_node, size_t size, size_t alignment, - bool commit, bool allow_large, mi_arena_id_t req_arena_id, mi_memid_t* memid, mi_os_tld_t* tld ) + bool commit, bool allow_large, mi_arena_id_t req_arena_id, mi_memid_t* memid ) { MI_UNUSED_RELEASE(alignment); - mi_assert_internal(alignment <= MI_SEGMENT_ALIGN); + mi_assert(alignment <= MI_SEGMENT_ALIGN); const size_t bcount = mi_block_count_of_size(size); const size_t arena_index = mi_arena_id_index(arena_id); mi_assert_internal(arena_index < mi_atomic_load_relaxed(&mi_arena_count)); mi_assert_internal(size <= mi_arena_block_size(bcount)); // Check arena suitability - mi_arena_t* arena = mi_atomic_load_ptr_acquire(mi_arena_t, &mi_arenas[arena_index]); + mi_arena_t* arena = mi_arena_from_index(arena_index); if (arena == NULL) return NULL; if (!allow_large && arena->is_large) return NULL; if (!mi_arena_id_is_suitable(arena->id, arena->exclusive, req_arena_id)) return NULL; @@ -292,7 +325,7 @@ static void* mi_arena_try_alloc_at_id(mi_arena_id_t arena_id, bool match_numa_no } // try to allocate - void* p = mi_arena_try_alloc_at(arena, arena_index, bcount, commit, memid, tld); + void* p = mi_arena_try_alloc_at(arena, arena_index, bcount, commit, memid); mi_assert_internal(p == NULL || _mi_is_aligned(p, alignment)); return p; } @@ -301,7 +334,7 @@ static void* mi_arena_try_alloc_at_id(mi_arena_id_t arena_id, bool match_numa_no // allocate from an arena with fallback to the OS static mi_decl_noinline void* mi_arena_try_alloc(int numa_node, size_t size, size_t alignment, bool commit, bool allow_large, - mi_arena_id_t req_arena_id, mi_memid_t* memid, mi_os_tld_t* tld ) + mi_arena_id_t req_arena_id, mi_memid_t* memid ) { MI_UNUSED(alignment); mi_assert_internal(alignment <= MI_SEGMENT_ALIGN); @@ -311,21 +344,21 @@ static mi_decl_noinline void* mi_arena_try_alloc(int numa_node, size_t size, siz if (req_arena_id != _mi_arena_id_none()) { // try a specific arena if requested if (mi_arena_id_index(req_arena_id) < max_arena) { - void* p = mi_arena_try_alloc_at_id(req_arena_id, true, numa_node, size, alignment, commit, allow_large, req_arena_id, memid, tld); + void* p = mi_arena_try_alloc_at_id(req_arena_id, true, numa_node, size, alignment, commit, allow_large, req_arena_id, memid); if (p != NULL) return p; } } else { // try numa affine allocation for (size_t i = 0; i < max_arena; i++) { - void* p = mi_arena_try_alloc_at_id(mi_arena_id_create(i), true, numa_node, size, alignment, commit, allow_large, req_arena_id, memid, tld); + void* p = mi_arena_try_alloc_at_id(mi_arena_id_create(i), true, numa_node, size, alignment, commit, allow_large, req_arena_id, memid); if (p != NULL) return p; } // try from another numa node instead.. if (numa_node >= 0) { // if numa_node was < 0 (no specific affinity requested), all arena's have been tried already for (size_t i = 0; i < max_arena; i++) { - void* p = mi_arena_try_alloc_at_id(mi_arena_id_create(i), false /* only proceed if not numa local */, numa_node, size, alignment, commit, allow_large, req_arena_id, memid, tld); + void* p = mi_arena_try_alloc_at_id(mi_arena_id_create(i), false /* only proceed if not numa local */, numa_node, size, alignment, commit, allow_large, req_arena_id, memid); if (p != NULL) return p; } } @@ -334,10 +367,9 @@ static mi_decl_noinline void* mi_arena_try_alloc(int numa_node, size_t size, siz } // try to reserve a fresh arena space -static bool mi_arena_reserve(size_t req_size, bool allow_large, mi_arena_id_t req_arena_id, mi_arena_id_t *arena_id) +static bool mi_arena_reserve(size_t req_size, bool allow_large, mi_arena_id_t *arena_id) { if (_mi_preloading()) return false; // use OS only while pre loading - if (req_arena_id != _mi_arena_id_none()) return false; const size_t arena_count = mi_atomic_load_acquire(&mi_arena_count); if (arena_count > (MI_MAX_ARENAS - 4)) return false; @@ -346,67 +378,76 @@ static bool mi_arena_reserve(size_t req_size, bool allow_large, mi_arena_id_t re if (arena_reserve == 0) return false; if (!_mi_os_has_virtual_reserve()) { - arena_reserve = arena_reserve/4; // be conservative if virtual reserve is not supported (for some embedded systems for example) + arena_reserve = arena_reserve/4; // be conservative if virtual reserve is not supported (for WASM for example) } arena_reserve = _mi_align_up(arena_reserve, MI_ARENA_BLOCK_SIZE); + arena_reserve = _mi_align_up(arena_reserve, MI_SEGMENT_SIZE); if (arena_count >= 8 && arena_count <= 128) { - arena_reserve = ((size_t)1<<(arena_count/8)) * arena_reserve; // scale up the arena sizes exponentially + // scale up the arena sizes exponentially every 8 entries (128 entries get to 589TiB) + const size_t multiplier = (size_t)1 << _mi_clamp(arena_count/8, 0, 16 ); + size_t reserve = 0; + if (!mi_mul_overflow(multiplier, arena_reserve, &reserve)) { + arena_reserve = reserve; + } } if (arena_reserve < req_size) return false; // should be able to at least handle the current allocation size // commit eagerly? bool arena_commit = false; - if (mi_option_get(mi_option_arena_eager_commit) == 2) { arena_commit = _mi_os_has_overcommit(); } + if (mi_option_get(mi_option_arena_eager_commit) == 2) { arena_commit = _mi_os_has_overcommit() || mi_option_is_enabled(mi_option_allow_large_os_pages); } else if (mi_option_get(mi_option_arena_eager_commit) == 1) { arena_commit = true; } - return (mi_reserve_os_memory_ex(arena_reserve, arena_commit, allow_large, false /* exclusive */, arena_id) == 0); + return (mi_reserve_os_memory_ex(arena_reserve, arena_commit, allow_large, false /* exclusive? */, arena_id) == 0); } void* _mi_arena_alloc_aligned(size_t size, size_t alignment, size_t align_offset, bool commit, bool allow_large, - mi_arena_id_t req_arena_id, mi_memid_t* memid, mi_os_tld_t* tld) + mi_arena_id_t req_arena_id, mi_memid_t* memid) { - mi_assert_internal(memid != NULL && tld != NULL); + mi_assert_internal(memid != NULL); mi_assert_internal(size > 0); *memid = _mi_memid_none(); - const int numa_node = _mi_os_numa_node(tld); // current numa node + const int numa_node = _mi_os_numa_node(); // current numa node // try to allocate in an arena if the alignment is small enough and the object is not too small (as for heap meta data) - if (size >= MI_ARENA_MIN_OBJ_SIZE && alignment <= MI_SEGMENT_ALIGN && align_offset == 0) { - void* p = mi_arena_try_alloc(numa_node, size, alignment, commit, allow_large, req_arena_id, memid, tld); - if (p != NULL) return p; - - // otherwise, try to first eagerly reserve a new arena - if (req_arena_id == _mi_arena_id_none()) { - mi_arena_id_t arena_id = 0; - if (mi_arena_reserve(size, allow_large, req_arena_id, &arena_id)) { - // and try allocate in there - mi_assert_internal(req_arena_id == _mi_arena_id_none()); - p = mi_arena_try_alloc_at_id(arena_id, true, numa_node, size, alignment, commit, allow_large, req_arena_id, memid, tld); - if (p != NULL) return p; + if (!mi_option_is_enabled(mi_option_disallow_arena_alloc)) { // is arena allocation allowed? + if (size >= MI_ARENA_MIN_OBJ_SIZE && alignment <= MI_SEGMENT_ALIGN && align_offset == 0) + { + void* p = mi_arena_try_alloc(numa_node, size, alignment, commit, allow_large, req_arena_id, memid); + if (p != NULL) return p; + + // otherwise, try to first eagerly reserve a new arena + if (req_arena_id == _mi_arena_id_none()) { + mi_arena_id_t arena_id = 0; + if (mi_arena_reserve(size, allow_large, &arena_id)) { + // and try allocate in there + mi_assert_internal(req_arena_id == _mi_arena_id_none()); + p = mi_arena_try_alloc_at_id(arena_id, true, numa_node, size, alignment, commit, allow_large, req_arena_id, memid); + if (p != NULL) return p; + } } } } // if we cannot use OS allocation, return NULL - if (mi_option_is_enabled(mi_option_limit_os_alloc) || req_arena_id != _mi_arena_id_none()) { + if (mi_option_is_enabled(mi_option_disallow_os_alloc) || req_arena_id != _mi_arena_id_none()) { errno = ENOMEM; return NULL; } // finally, fall back to the OS if (align_offset > 0) { - return _mi_os_alloc_aligned_at_offset(size, alignment, align_offset, commit, allow_large, memid, tld->stats); + return _mi_os_alloc_aligned_at_offset(size, alignment, align_offset, commit, allow_large, memid); } else { - return _mi_os_alloc_aligned(size, alignment, commit, allow_large, memid, tld->stats); + return _mi_os_alloc_aligned(size, alignment, commit, allow_large, memid); } } -void* _mi_arena_alloc(size_t size, bool commit, bool allow_large, mi_arena_id_t req_arena_id, mi_memid_t* memid, mi_os_tld_t* tld) +void* _mi_arena_alloc(size_t size, bool commit, bool allow_large, mi_arena_id_t req_arena_id, mi_memid_t* memid) { - return _mi_arena_alloc_aligned(size, MI_ARENA_BLOCK_SIZE, 0, commit, allow_large, req_arena_id, memid, tld); + return _mi_arena_alloc_aligned(size, MI_ARENA_BLOCK_SIZE, 0, commit, allow_large, req_arena_id, memid); } @@ -432,25 +473,26 @@ static long mi_arena_purge_delay(void) { // reset or decommit in an arena and update the committed/decommit bitmaps // assumes we own the area (i.e. blocks_in_use is claimed by us) -static void mi_arena_purge(mi_arena_t* arena, size_t bitmap_idx, size_t blocks, mi_stats_t* stats) { +static void mi_arena_purge(mi_arena_t* arena, size_t bitmap_idx, size_t blocks) { mi_assert_internal(arena->blocks_committed != NULL); mi_assert_internal(arena->blocks_purge != NULL); mi_assert_internal(!arena->memid.is_pinned); const size_t size = mi_arena_block_size(blocks); void* const p = mi_arena_block_start(arena, bitmap_idx); bool needs_recommit; - if (_mi_bitmap_is_claimed_across(arena->blocks_committed, arena->field_count, blocks, bitmap_idx)) { + size_t already_committed = 0; + if (_mi_bitmap_is_claimed_across(arena->blocks_committed, arena->field_count, blocks, bitmap_idx, &already_committed)) { // all blocks are committed, we can purge freely - needs_recommit = _mi_os_purge(p, size, stats); + mi_assert_internal(already_committed == blocks); + needs_recommit = _mi_os_purge(p, size); } else { // some blocks are not committed -- this can happen when a partially committed block is freed // in `_mi_arena_free` and it is conservatively marked as uncommitted but still scheduled for a purge - // we need to ensure we do not try to reset (as that may be invalid for uncommitted memory), - // and also undo the decommit stats (as it was already adjusted) + // we need to ensure we do not try to reset (as that may be invalid for uncommitted memory). + mi_assert_internal(already_committed < blocks); mi_assert_internal(mi_option_is_enabled(mi_option_purge_decommits)); - needs_recommit = _mi_os_purge_ex(p, size, false /* allow reset? */, stats); - _mi_stat_increase(&stats->committed, size); + needs_recommit = _mi_os_purge_ex(p, size, false /* allow reset? */, mi_arena_block_size(already_committed)); } // clear the purged blocks @@ -463,32 +505,35 @@ static void mi_arena_purge(mi_arena_t* arena, size_t bitmap_idx, size_t blocks, // Schedule a purge. This is usually delayed to avoid repeated decommit/commit calls. // Note: assumes we (still) own the area as we may purge immediately -static void mi_arena_schedule_purge(mi_arena_t* arena, size_t bitmap_idx, size_t blocks, mi_stats_t* stats) { +static void mi_arena_schedule_purge(mi_arena_t* arena, size_t bitmap_idx, size_t blocks) { mi_assert_internal(arena->blocks_purge != NULL); const long delay = mi_arena_purge_delay(); if (delay < 0) return; // is purging allowed at all? if (_mi_preloading() || delay == 0) { // decommit directly - mi_arena_purge(arena, bitmap_idx, blocks, stats); + mi_arena_purge(arena, bitmap_idx, blocks); } else { - // schedule decommit - mi_msecs_t expire = mi_atomic_loadi64_relaxed(&arena->purge_expire); - if (expire != 0) { - mi_atomic_addi64_acq_rel(&arena->purge_expire, delay/10); // add smallish extra delay + // schedule purge + const mi_msecs_t expire = _mi_clock_now() + delay; + mi_msecs_t expire0 = 0; + if (mi_atomic_casi64_strong_acq_rel(&arena->purge_expire, &expire0, expire)) { + // expiration was not yet set + // maybe set the global arenas expire as well (if it wasn't set already) + mi_atomic_casi64_strong_acq_rel(&mi_arenas_purge_expire, &expire0, expire); } else { - mi_atomic_storei64_release(&arena->purge_expire, _mi_clock_now() + delay); + // already an expiration was set } - _mi_bitmap_claim_across(arena->blocks_purge, arena->field_count, blocks, bitmap_idx, NULL); + _mi_bitmap_claim_across(arena->blocks_purge, arena->field_count, blocks, bitmap_idx, NULL, NULL); } } // purge a range of blocks // return true if the full range was purged. // assumes we own the area (i.e. blocks_in_use is claimed by us) -static bool mi_arena_purge_range(mi_arena_t* arena, size_t idx, size_t startidx, size_t bitlen, size_t purge, mi_stats_t* stats) { +static bool mi_arena_purge_range(mi_arena_t* arena, size_t idx, size_t startidx, size_t bitlen, size_t purge) { const size_t endidx = startidx + bitlen; size_t bitidx = startidx; bool all_purged = false; @@ -501,7 +546,7 @@ static bool mi_arena_purge_range(mi_arena_t* arena, size_t idx, size_t startidx, if (count > 0) { // found range to be purged const mi_bitmap_index_t range_idx = mi_bitmap_index_create(idx, bitidx); - mi_arena_purge(arena, range_idx, count, stats); + mi_arena_purge(arena, range_idx, count); if (count == bitlen) { all_purged = true; } @@ -511,16 +556,25 @@ static bool mi_arena_purge_range(mi_arena_t* arena, size_t idx, size_t startidx, return all_purged; } -// returns true if anything was purged -static bool mi_arena_try_purge(mi_arena_t* arena, mi_msecs_t now, bool force, mi_stats_t* stats) +// returns +// -1 = nothing was purged +// 0 = nothing was purged yet because have not yet reached the expire time +// 1 = some pages in the arena were purged +static int mi_arena_try_purge(mi_arena_t* arena, mi_msecs_t now, bool force) { - if (arena->memid.is_pinned || arena->blocks_purge == NULL) return false; + // check pre-conditions + if (arena->memid.is_pinned) return -1; + + // expired yet? mi_msecs_t expire = mi_atomic_loadi64_relaxed(&arena->purge_expire); - if (expire == 0) return false; - if (!force && expire > now) return false; + if (!force) { + if (expire == 0) return -1; + if (expire > now) return 0; + } // reset expire (if not already set concurrently) - mi_atomic_casi64_strong_acq_rel(&arena->purge_expire, &expire, 0); + mi_atomic_casi64_strong_acq_rel(&arena->purge_expire, &expire, (mi_msecs_t)0); + _mi_stat_counter_increase(&_mi_stats_main.arena_purges, 1); // potential purges scheduled, walk through the bitmap bool any_purged = false; @@ -535,6 +589,7 @@ static bool mi_arena_try_purge(mi_arena_t* arena, mi_msecs_t now, bool force, mi while (bitidx + bitlen < MI_BITMAP_FIELD_BITS && (purge & ((size_t)1 << (bitidx + bitlen))) != 0) { bitlen++; } + // temporarily claim the purge range as "in-use" to be thread-safe with allocation // try to claim the longest range of corresponding in_use bits const mi_bitmap_index_t bitmap_index = mi_bitmap_index_create(i, bitidx); while( bitlen > 0 ) { @@ -547,7 +602,7 @@ static bool mi_arena_try_purge(mi_arena_t* arena, mi_msecs_t now, bool force, mi if (bitlen > 0) { // read purge again now that we have the in_use bits purge = mi_atomic_load_acquire(&arena->blocks_purge[i]); - if (!mi_arena_purge_range(arena, i, bitidx, bitlen, purge, stats)) { + if (!mi_arena_purge_range(arena, i, bitidx, bitlen, purge)) { full_purge = false; } any_purged = true; @@ -564,12 +619,18 @@ static bool mi_arena_try_purge(mi_arena_t* arena, mi_msecs_t now, bool force, mi mi_msecs_t expected = 0; mi_atomic_casi64_strong_acq_rel(&arena->purge_expire,&expected,_mi_clock_now() + delay); } - return any_purged; + return (any_purged ? 1 : -1); } -static void mi_arenas_try_purge( bool force, bool visit_all, mi_stats_t* stats ) { +static void mi_arenas_try_purge( bool force, bool visit_all ) +{ if (_mi_preloading() || mi_arena_purge_delay() <= 0) return; // nothing will be scheduled + // check if any arena needs purging? + const mi_msecs_t now = _mi_clock_now(); + mi_msecs_t arenas_expire = mi_atomic_loadi64_acquire(&mi_arenas_purge_expire); + if (!force && (arenas_expire == 0 || arenas_expire > now)) return; + const size_t max_arena = mi_atomic_load_acquire(&mi_arena_count); if (max_arena == 0) return; @@ -577,17 +638,31 @@ static void mi_arenas_try_purge( bool force, bool visit_all, mi_stats_t* stats ) static mi_atomic_guard_t purge_guard; mi_atomic_guard(&purge_guard) { - mi_msecs_t now = _mi_clock_now(); - size_t max_purge_count = (visit_all ? max_arena : 1); + // increase global expire: at most one purge per delay cycle + mi_atomic_storei64_release(&mi_arenas_purge_expire, now + mi_arena_purge_delay()); + size_t max_purge_count = (visit_all ? max_arena : 2); + bool all_visited = true; + bool any_purged = false; for (size_t i = 0; i < max_arena; i++) { mi_arena_t* arena = mi_atomic_load_ptr_acquire(mi_arena_t, &mi_arenas[i]); if (arena != NULL) { - if (mi_arena_try_purge(arena, now, force, stats)) { - if (max_purge_count <= 1) break; - max_purge_count--; + int purged = mi_arena_try_purge(arena, now, force); + if (purged >= 0) { // purged, or not yet the expire-time reached + any_purged = true; + if (purged >= 1) { // purged at least one page + if (max_purge_count <= 1) { + all_visited = false; + break; + } + max_purge_count--; + } } } } + if (all_visited && !any_purged) { + // all arena's were visited and nothing needed to be purged: reset global expire + mi_atomic_storei64_release(&mi_arenas_purge_expire, (mi_msecs_t)0); + } } } @@ -596,20 +671,24 @@ static void mi_arenas_try_purge( bool force, bool visit_all, mi_stats_t* stats ) Arena free ----------------------------------------------------------- */ -void _mi_arena_free(void* p, size_t size, size_t committed_size, mi_memid_t memid, mi_stats_t* stats) { - mi_assert_internal(size > 0 && stats != NULL); +void _mi_arena_free(void* p, size_t size, size_t committed_size, mi_memid_t memid) { + mi_assert_internal(size > 0); mi_assert_internal(committed_size <= size); if (p==NULL) return; if (size==0) return; const bool all_committed = (committed_size == size); + const size_t decommitted_size = (committed_size <= size ? size - committed_size : 0); + + // need to set all memory to undefined as some parts may still be marked as no_access (like padding etc.) + mi_track_mem_undefined(p,size); if (mi_memkind_is_os(memid.memkind)) { // was a direct OS allocation, pass through - if (!all_committed && committed_size > 0) { - // if partially committed, adjust the committed stats (as `_mi_os_free` will increase decommit by the full size) - _mi_stat_decrease(&stats->committed, committed_size); + if (!all_committed && decommitted_size > 0) { + // if partially committed, adjust the committed stats (as `_mi_os_free` will decrease commit by the full size) + _mi_stat_increase(&_mi_stats_main.committed, decommitted_size); } - _mi_os_free(p, size, memid, stats); + _mi_os_free(p, size, memid); } else if (memid.memkind == MI_MEM_ARENA) { // allocated in an arena @@ -623,18 +702,15 @@ void _mi_arena_free(void* p, size_t size, size_t committed_size, mi_memid_t memi // checks if (arena == NULL) { - _mi_error_message(EINVAL, "trying to free from non-existent arena: %p, size %zu, memid: 0x%zx\n", p, size, memid); + _mi_error_message(EINVAL, "trying to free from an invalid arena: %p, size %zu, memkind: 0x%x\n", p, size, memid.memkind); return; } mi_assert_internal(arena->field_count > mi_bitmap_index_field(bitmap_idx)); if (arena->field_count <= mi_bitmap_index_field(bitmap_idx)) { - _mi_error_message(EINVAL, "trying to free from non-existent arena block: %p, size %zu, memid: 0x%zx\n", p, size, memid); + _mi_error_message(EINVAL, "trying to free from an invalid arena block: %p, size %zu, memid: 0x%x\n", p, size, memid.memkind); return; } - // need to set all memory to undefined as some parts may still be marked as no_access (like padding etc.) - mi_track_mem_undefined(p,size); - // potentially decommit if (arena->memid.is_pinned || arena->blocks_committed == NULL) { mi_assert_internal(all_committed); @@ -644,20 +720,20 @@ void _mi_arena_free(void* p, size_t size, size_t committed_size, mi_memid_t memi mi_assert_internal(arena->blocks_purge != NULL); if (!all_committed) { - // mark the entire range as no longer committed (so we recommit the full range when re-using) + // mark the entire range as no longer committed (so we will recommit the full range when re-using) _mi_bitmap_unclaim_across(arena->blocks_committed, arena->field_count, blocks, bitmap_idx); mi_track_mem_noaccess(p,size); - if (committed_size > 0) { + //if (committed_size > 0) { // if partially committed, adjust the committed stats (is it will be recommitted when re-using) - // in the delayed purge, we now need to not count a decommit if the range is not marked as committed. - _mi_stat_decrease(&stats->committed, committed_size); - } + // in the delayed purge, we do no longer decrease the commit if the range is not marked entirely as committed. + _mi_stat_decrease(&_mi_stats_main.committed, committed_size); + //} // note: if not all committed, it may be that the purge will reset/decommit the entire range // that contains already decommitted parts. Since purge consistently uses reset or decommit that // works (as we should never reset decommitted parts). } // (delay) purge the entire range - mi_arena_schedule_purge(arena, bitmap_idx, blocks, stats); + mi_arena_schedule_purge(arena, bitmap_idx, blocks); } // and make it available to others again @@ -673,7 +749,7 @@ void _mi_arena_free(void* p, size_t size, size_t committed_size, mi_memid_t memi } // purge expired decommits - mi_arenas_try_purge(false, false, stats); + mi_arenas_try_purge(false, false); } // destroy owned arenas; this is unsafe and should only be done using `mi_option_destroy_on_exit` @@ -684,14 +760,15 @@ static void mi_arenas_unsafe_destroy(void) { for (size_t i = 0; i < max_arena; i++) { mi_arena_t* arena = mi_atomic_load_ptr_acquire(mi_arena_t, &mi_arenas[i]); if (arena != NULL) { + mi_lock_done(&arena->abandoned_visit_lock); if (arena->start != NULL && mi_memkind_is_os(arena->memid.memkind)) { mi_atomic_store_ptr_release(mi_arena_t, &mi_arenas[i], NULL); - _mi_os_free(arena->start, mi_arena_size(arena), arena->memid, &_mi_stats_main); + _mi_os_free(arena->start, mi_arena_size(arena), arena->memid); } else { new_max_arena = i; } - mi_arena_meta_free(arena, arena->meta_memid, arena->meta_size, &_mi_stats_main); + _mi_arena_meta_free(arena, arena->meta_memid, arena->meta_size); } } @@ -701,22 +778,22 @@ static void mi_arenas_unsafe_destroy(void) { } // Purge the arenas; if `force_purge` is true, amenable parts are purged even if not yet expired -void _mi_arena_collect(bool force_purge, mi_stats_t* stats) { - mi_arenas_try_purge(force_purge, true /* visit all */, stats); +void _mi_arenas_collect(bool force_purge) { + mi_arenas_try_purge(force_purge, force_purge /* visit all? */); } // destroy owned arenas; this is unsafe and should only be done using `mi_option_destroy_on_exit` // for dynamic libraries that are unloaded and need to release all their allocated memory. -void _mi_arena_unsafe_destroy_all(mi_stats_t* stats) { +void _mi_arena_unsafe_destroy_all(void) { mi_arenas_unsafe_destroy(); - _mi_arena_collect(true /* force purge */, stats); // purge non-owned arenas + _mi_arenas_collect(true /* force purge */); // purge non-owned arenas } // Is a pointer inside any of our arenas? bool _mi_arena_contains(const void* p) { const size_t max_arena = mi_atomic_load_relaxed(&mi_arena_count); for (size_t i = 0; i < max_arena; i++) { - mi_arena_t* arena = mi_atomic_load_ptr_acquire(mi_arena_t, &mi_arenas[i]); + mi_arena_t* arena = mi_atomic_load_ptr_relaxed(mi_arena_t, &mi_arenas[i]); if (arena != NULL && arena->start <= (const uint8_t*)p && arena->start + mi_arena_block_size(arena->block_count) > (const uint8_t*)p) { return true; } @@ -724,46 +801,64 @@ bool _mi_arena_contains(const void* p) { return false; } - /* ----------------------------------------------------------- Add an arena. ----------------------------------------------------------- */ -static bool mi_arena_add(mi_arena_t* arena, mi_arena_id_t* arena_id) { +static bool mi_arena_add(mi_arena_t* arena, mi_arena_id_t* arena_id, mi_stats_t* stats) { mi_assert_internal(arena != NULL); mi_assert_internal((uintptr_t)mi_atomic_load_ptr_relaxed(uint8_t,&arena->start) % MI_SEGMENT_ALIGN == 0); mi_assert_internal(arena->block_count > 0); if (arena_id != NULL) { *arena_id = -1; } - size_t i = mi_atomic_increment_acq_rel(&mi_arena_count); - if (i >= MI_MAX_ARENAS) { - mi_atomic_decrement_acq_rel(&mi_arena_count); - return false; + size_t i = mi_atomic_load_relaxed(&mi_arena_count); + while (i < MI_MAX_ARENAS) { + if (mi_atomic_cas_strong_acq_rel(&mi_arena_count, &i, i+1)) { + _mi_stat_counter_increase(&stats->arena_count, 1); + arena->id = mi_arena_id_create(i); + mi_atomic_store_ptr_release(mi_arena_t, &mi_arenas[i], arena); + if (arena_id != NULL) { *arena_id = arena->id; } + return true; + } } - arena->id = mi_arena_id_create(i); - mi_atomic_store_ptr_release(mi_arena_t,&mi_arenas[i], arena); - if (arena_id != NULL) { *arena_id = arena->id; } - return true; + + return false; } static bool mi_manage_os_memory_ex2(void* start, size_t size, bool is_large, int numa_node, bool exclusive, mi_memid_t memid, mi_arena_id_t* arena_id) mi_attr_noexcept { if (arena_id != NULL) *arena_id = _mi_arena_id_none(); - if (size < MI_ARENA_BLOCK_SIZE) return false; - + if (size < MI_ARENA_BLOCK_SIZE) { + _mi_warning_message("the arena size is too small (memory at %p with size %zu)\n", start, size); + return false; + } + if (size > MI_MAX_ALLOC_SIZE) { + _mi_error_message(EOVERFLOW, "the arena size is too large (memory at %p with size %zu)\n", start, size); + return false; + } if (is_large) { mi_assert_internal(memid.initially_committed && memid.is_pinned); } + if (!_mi_is_aligned(start, MI_SEGMENT_ALIGN)) { + void* const aligned_start = _mi_align_up_ptr(start, MI_SEGMENT_ALIGN); + const size_t diff = (uint8_t*)aligned_start - (uint8_t*)start; + if (diff >= size || (size - diff) < MI_ARENA_BLOCK_SIZE) { + _mi_warning_message("after alignment, the size of the arena becomes too small (memory at %p with size %zu)\n", start, size); + return false; + } + start = aligned_start; + size = size - diff; + } const size_t bcount = size / MI_ARENA_BLOCK_SIZE; const size_t fields = _mi_divide_up(bcount, MI_BITMAP_FIELD_BITS); - const size_t bitmaps = (memid.is_pinned ? 2 : 4); + const size_t bitmaps = (memid.is_pinned ? 3 : 5); const size_t asize = sizeof(mi_arena_t) + (bitmaps*fields*sizeof(mi_bitmap_field_t)); mi_memid_t meta_memid; - mi_arena_t* arena = (mi_arena_t*)mi_arena_meta_zalloc(asize, &meta_memid, &_mi_stats_main); // TODO: can we avoid allocating from the OS? + mi_arena_t* arena = (mi_arena_t*)_mi_arena_meta_zalloc(asize, &meta_memid); if (arena == NULL) return false; - // already zero'd due to os_alloc + // already zero'd due to zalloc // _mi_memzero(arena, asize); arena->id = _mi_arena_id_none(); arena->memid = memid; @@ -777,9 +872,12 @@ static bool mi_manage_os_memory_ex2(void* start, size_t size, bool is_large, int arena->is_large = is_large; arena->purge_expire = 0; arena->search_idx = 0; - arena->blocks_dirty = &arena->blocks_inuse[fields]; // just after inuse bitmap - arena->blocks_committed = (arena->memid.is_pinned ? NULL : &arena->blocks_inuse[2*fields]); // just after dirty bitmap - arena->blocks_purge = (arena->memid.is_pinned ? NULL : &arena->blocks_inuse[3*fields]); // just after committed bitmap + mi_lock_init(&arena->abandoned_visit_lock); + // consecutive bitmaps + arena->blocks_dirty = &arena->blocks_inuse[fields]; // just after inuse bitmap + arena->blocks_abandoned = &arena->blocks_inuse[2 * fields]; // just after dirty bitmap + arena->blocks_committed = (arena->memid.is_pinned ? NULL : &arena->blocks_inuse[3*fields]); // just after abandoned bitmap + arena->blocks_purge = (arena->memid.is_pinned ? NULL : &arena->blocks_inuse[4*fields]); // just after committed bitmap // initialize committed bitmap? if (arena->blocks_committed != NULL && arena->memid.initially_committed) { memset((void*)arena->blocks_committed, 0xFF, fields*sizeof(mi_bitmap_field_t)); // cast to void* to avoid atomic warning @@ -793,7 +891,7 @@ static bool mi_manage_os_memory_ex2(void* start, size_t size, bool is_large, int mi_bitmap_index_t postidx = mi_bitmap_index_create(fields - 1, MI_BITMAP_FIELD_BITS - post); _mi_bitmap_claim(arena->blocks_inuse, fields, post, postidx, NULL); } - return mi_arena_add(arena, arena_id); + return mi_arena_add(arena, arena_id, &_mi_stats_main); } @@ -808,14 +906,20 @@ bool mi_manage_os_memory_ex(void* start, size_t size, bool is_committed, bool is // Reserve a range of regular OS memory int mi_reserve_os_memory_ex(size_t size, bool commit, bool allow_large, bool exclusive, mi_arena_id_t* arena_id) mi_attr_noexcept { if (arena_id != NULL) *arena_id = _mi_arena_id_none(); - size = _mi_align_up(size, MI_ARENA_BLOCK_SIZE); // at least one block + if (size < MI_MAX_ALLOC_SIZE) { + size = _mi_align_up(size, MI_ARENA_BLOCK_SIZE); // at least one block + } + if (size > MI_MAX_ALLOC_SIZE) { + _mi_error_message(EOVERFLOW, "memory reservation request is too large (size %zu)\n", size); + return ENOMEM; + } mi_memid_t memid; - void* start = _mi_os_alloc_aligned(size, MI_SEGMENT_ALIGN, commit, allow_large, &memid, &_mi_stats_main); + void* start = _mi_os_alloc_aligned(size, MI_SEGMENT_ALIGN, commit, allow_large, &memid); if (start == NULL) return ENOMEM; const bool is_large = memid.is_pinned; // todo: use separate is_large field? if (!mi_manage_os_memory_ex2(start, size, is_large, -1 /* numa node */, exclusive, memid, arena_id)) { - _mi_os_free_ex(start, size, commit, memid, &_mi_stats_main); - _mi_verbose_message("failed to reserve %zu k memory\n", _mi_divide_up(size, 1024)); + _mi_os_free_ex(start, size, commit, memid); + _mi_verbose_message("failed to reserve %zu KiB memory\n", _mi_divide_up(size, 1024)); return ENOMEM; } _mi_verbose_message("reserved %zu KiB memory%s\n", _mi_divide_up(size, 1024), is_large ? " (in large os pages)" : ""); @@ -838,32 +942,61 @@ int mi_reserve_os_memory(size_t size, bool commit, bool allow_large) mi_attr_noe Debugging ----------------------------------------------------------- */ -static size_t mi_debug_show_bitmap(const char* prefix, mi_bitmap_field_t* fields, size_t field_count ) { +static size_t mi_debug_show_bitmap(const char* prefix, const char* header, size_t block_count, mi_bitmap_field_t* fields, size_t field_count ) { + _mi_message("%s%s:\n", prefix, header); + size_t bcount = 0; size_t inuse_count = 0; for (size_t i = 0; i < field_count; i++) { char buf[MI_BITMAP_FIELD_BITS + 1]; uintptr_t field = mi_atomic_load_relaxed(&fields[i]); - for (size_t bit = 0; bit < MI_BITMAP_FIELD_BITS; bit++) { - bool inuse = ((((uintptr_t)1 << bit) & field) != 0); - if (inuse) inuse_count++; - buf[MI_BITMAP_FIELD_BITS - 1 - bit] = (inuse ? 'x' : '.'); + for (size_t bit = 0; bit < MI_BITMAP_FIELD_BITS; bit++, bcount++) { + if (bcount < block_count) { + bool inuse = ((((uintptr_t)1 << bit) & field) != 0); + if (inuse) inuse_count++; + buf[bit] = (inuse ? 'x' : '.'); + } + else { + buf[bit] = ' '; + } } buf[MI_BITMAP_FIELD_BITS] = 0; - _mi_verbose_message("%s%s\n", prefix, buf); + _mi_message("%s %s\n", prefix, buf); } + _mi_message("%s total ('x'): %zu\n", prefix, inuse_count); return inuse_count; } void mi_debug_show_arenas(void) mi_attr_noexcept { + const bool show_inuse = true; size_t max_arenas = mi_atomic_load_relaxed(&mi_arena_count); + size_t inuse_total = 0; + //size_t abandoned_total = 0; + //size_t purge_total = 0; for (size_t i = 0; i < max_arenas; i++) { mi_arena_t* arena = mi_atomic_load_ptr_relaxed(mi_arena_t, &mi_arenas[i]); if (arena == NULL) break; - size_t inuse_count = 0; - _mi_verbose_message("arena %zu: %zu blocks with %zu fields\n", i, arena->block_count, arena->field_count); - inuse_count += mi_debug_show_bitmap(" ", arena->blocks_inuse, arena->field_count); - _mi_verbose_message(" blocks in use ('x'): %zu\n", inuse_count); + _mi_message("arena %zu: %zu blocks of size %zuMiB (in %zu fields) %s\n", i, arena->block_count, (size_t)(MI_ARENA_BLOCK_SIZE / MI_MiB), arena->field_count, (arena->memid.is_pinned ? ", pinned" : "")); + if (show_inuse) { + inuse_total += mi_debug_show_bitmap(" ", "inuse blocks", arena->block_count, arena->blocks_inuse, arena->field_count); + } + if (arena->blocks_committed != NULL) { + mi_debug_show_bitmap(" ", "committed blocks", arena->block_count, arena->blocks_committed, arena->field_count); + } + //if (show_abandoned) { + // abandoned_total += mi_debug_show_bitmap(" ", "abandoned blocks", arena->block_count, arena->blocks_abandoned, arena->field_count); + //} + //if (show_purge && arena->blocks_purge != NULL) { + // purge_total += mi_debug_show_bitmap(" ", "purgeable blocks", arena->block_count, arena->blocks_purge, arena->field_count); + //} } + if (show_inuse) _mi_message("total inuse blocks : %zu\n", inuse_total); + //if (show_abandoned) _mi_message("total abandoned blocks: %zu\n", abandoned_total); + //if (show_purge) _mi_message("total purgeable blocks: %zu\n", purge_total); +} + + +void mi_arenas_print(void) mi_attr_noexcept { + mi_debug_show_arenas(); } @@ -887,7 +1020,7 @@ int mi_reserve_huge_os_pages_at_ex(size_t pages, int numa_node, size_t timeout_m _mi_verbose_message("numa node %i: reserved %zu GiB huge pages (of the %zu GiB requested)\n", numa_node, pages_reserved, pages); if (!mi_manage_os_memory_ex2(p, hsize, true, numa_node, exclusive, memid, arena_id)) { - _mi_os_free(p, hsize, memid, &_mi_stats_main); + _mi_os_free(p, hsize, memid); return ENOMEM; } return 0; @@ -902,17 +1035,17 @@ int mi_reserve_huge_os_pages_interleave(size_t pages, size_t numa_nodes, size_t if (pages == 0) return 0; // pages per numa node - size_t numa_count = (numa_nodes > 0 ? numa_nodes : _mi_os_numa_node_count()); - if (numa_count <= 0) numa_count = 1; + int numa_count = (numa_nodes > 0 && numa_nodes <= INT_MAX ? (int)numa_nodes : _mi_os_numa_node_count()); + if (numa_count == 0) numa_count = 1; const size_t pages_per = pages / numa_count; const size_t pages_mod = pages % numa_count; const size_t timeout_per = (timeout_msecs==0 ? 0 : (timeout_msecs / numa_count) + 50); // reserve evenly among numa nodes - for (size_t numa_node = 0; numa_node < numa_count && pages > 0; numa_node++) { + for (int numa_node = 0; numa_node < numa_count && pages > 0; numa_node++) { size_t node_pages = pages_per; // can be 0 - if (numa_node < pages_mod) node_pages++; - int err = mi_reserve_huge_os_pages_at(node_pages, (int)numa_node, timeout_per); + if ((size_t)numa_node < pages_mod) node_pages++; + int err = mi_reserve_huge_os_pages_at(node_pages, numa_node, timeout_per); if (err) return err; if (pages < node_pages) { pages = 0; diff --git a/Objects/mimalloc/bitmap.c b/Objects/mimalloc/bitmap.c index 31830756f58c7c0..7057d87461ea84a 100644 --- a/Objects/mimalloc/bitmap.c +++ b/Objects/mimalloc/bitmap.c @@ -81,7 +81,7 @@ inline bool _mi_bitmap_try_find_claim_field(mi_bitmap_t bitmap, size_t idx, cons // on to the next bit range #ifdef MI_HAVE_FAST_BITSCAN mi_assert_internal(mapm != 0); - const size_t shift = (count == 1 ? 1 : (MI_INTPTR_BITS - mi_clz(mapm) - bitidx)); + const size_t shift = (count == 1 ? 1 : (MI_SIZE_BITS - mi_clz(mapm) - bitidx)); mi_assert_internal(shift > 0 && shift <= count); #else const size_t shift = 1; @@ -108,7 +108,7 @@ bool _mi_bitmap_try_find_from_claim(mi_bitmap_t bitmap, const size_t bitmap_fiel return false; } -// Like _mi_bitmap_try_find_from_claim but with an extra predicate that must be fulfilled +// Like _mi_bitmap_try_find_from_claim but with an extra predicate that must be fullfilled bool _mi_bitmap_try_find_from_claim_pred(mi_bitmap_t bitmap, const size_t bitmap_fields, const size_t start_field_idx, const size_t count, mi_bitmap_pred_fun_t pred_fun, void* pred_arg, @@ -279,6 +279,7 @@ static bool mi_bitmap_try_find_claim_field_across(mi_bitmap_t bitmap, size_t bit newmap = (map & ~initial_mask); } while (!mi_atomic_cas_strong_acq_rel(field, &map, newmap)); } + mi_stat_counter_increase(_mi_stats_main.arena_rollback_count,1); // retry? (we make a recursive call instead of goto to be able to use const declarations) if (retries <= 2) { return mi_bitmap_try_find_claim_field_across(bitmap, bitmap_fields, idx, count, retries+1, bitmap_idx); @@ -366,7 +367,7 @@ bool _mi_bitmap_unclaim_across(mi_bitmap_t bitmap, size_t bitmap_fields, size_t // Set `count` bits at `bitmap_idx` to 1 atomically // Returns `true` if all `count` bits were 0 previously. `any_zero` is `true` if there was at least one zero bit. -bool _mi_bitmap_claim_across(mi_bitmap_t bitmap, size_t bitmap_fields, size_t count, mi_bitmap_index_t bitmap_idx, bool* pany_zero) { +bool _mi_bitmap_claim_across(mi_bitmap_t bitmap, size_t bitmap_fields, size_t count, mi_bitmap_index_t bitmap_idx, bool* pany_zero, size_t* already_set) { size_t idx = mi_bitmap_index_field(bitmap_idx); size_t pre_mask; size_t mid_mask; @@ -374,28 +375,31 @@ bool _mi_bitmap_claim_across(mi_bitmap_t bitmap, size_t bitmap_fields, size_t co size_t mid_count = mi_bitmap_mask_across(bitmap_idx, bitmap_fields, count, &pre_mask, &mid_mask, &post_mask); bool all_zero = true; bool any_zero = false; + size_t one_count = 0; _Atomic(size_t)*field = &bitmap[idx]; size_t prev = mi_atomic_or_acq_rel(field++, pre_mask); - if ((prev & pre_mask) != 0) all_zero = false; + if ((prev & pre_mask) != 0) { all_zero = false; one_count += mi_popcount(prev & pre_mask); } if ((prev & pre_mask) != pre_mask) any_zero = true; while (mid_count-- > 0) { prev = mi_atomic_or_acq_rel(field++, mid_mask); - if ((prev & mid_mask) != 0) all_zero = false; + if ((prev & mid_mask) != 0) { all_zero = false; one_count += mi_popcount(prev & mid_mask); } if ((prev & mid_mask) != mid_mask) any_zero = true; } if (post_mask!=0) { prev = mi_atomic_or_acq_rel(field, post_mask); - if ((prev & post_mask) != 0) all_zero = false; + if ((prev & post_mask) != 0) { all_zero = false; one_count += mi_popcount(prev & post_mask); } if ((prev & post_mask) != post_mask) any_zero = true; } if (pany_zero != NULL) { *pany_zero = any_zero; } + if (already_set != NULL) { *already_set = one_count; }; + mi_assert_internal(all_zero ? one_count == 0 : one_count <= count); return all_zero; } // Returns `true` if all `count` bits were 1. // `any_ones` is `true` if there was at least one bit set to one. -static bool mi_bitmap_is_claimedx_across(mi_bitmap_t bitmap, size_t bitmap_fields, size_t count, mi_bitmap_index_t bitmap_idx, bool* pany_ones) { +static bool mi_bitmap_is_claimedx_across(mi_bitmap_t bitmap, size_t bitmap_fields, size_t count, mi_bitmap_index_t bitmap_idx, bool* pany_ones, size_t* already_set) { size_t idx = mi_bitmap_index_field(bitmap_idx); size_t pre_mask; size_t mid_mask; @@ -403,30 +407,33 @@ static bool mi_bitmap_is_claimedx_across(mi_bitmap_t bitmap, size_t bitmap_field size_t mid_count = mi_bitmap_mask_across(bitmap_idx, bitmap_fields, count, &pre_mask, &mid_mask, &post_mask); bool all_ones = true; bool any_ones = false; + size_t one_count = 0; mi_bitmap_field_t* field = &bitmap[idx]; size_t prev = mi_atomic_load_relaxed(field++); if ((prev & pre_mask) != pre_mask) all_ones = false; - if ((prev & pre_mask) != 0) any_ones = true; + if ((prev & pre_mask) != 0) { any_ones = true; one_count += mi_popcount(prev & pre_mask); } while (mid_count-- > 0) { prev = mi_atomic_load_relaxed(field++); if ((prev & mid_mask) != mid_mask) all_ones = false; - if ((prev & mid_mask) != 0) any_ones = true; + if ((prev & mid_mask) != 0) { any_ones = true; one_count += mi_popcount(prev & mid_mask); } } if (post_mask!=0) { prev = mi_atomic_load_relaxed(field); if ((prev & post_mask) != post_mask) all_ones = false; - if ((prev & post_mask) != 0) any_ones = true; + if ((prev & post_mask) != 0) { any_ones = true; one_count += mi_popcount(prev & post_mask); } } if (pany_ones != NULL) { *pany_ones = any_ones; } + if (already_set != NULL) { *already_set = one_count; } + mi_assert_internal(all_ones ? one_count == count : one_count < count); return all_ones; } -bool _mi_bitmap_is_claimed_across(mi_bitmap_t bitmap, size_t bitmap_fields, size_t count, mi_bitmap_index_t bitmap_idx) { - return mi_bitmap_is_claimedx_across(bitmap, bitmap_fields, count, bitmap_idx, NULL); +bool _mi_bitmap_is_claimed_across(mi_bitmap_t bitmap, size_t bitmap_fields, size_t count, mi_bitmap_index_t bitmap_idx, size_t* already_set) { + return mi_bitmap_is_claimedx_across(bitmap, bitmap_fields, count, bitmap_idx, NULL, already_set); } bool _mi_bitmap_is_any_claimed_across(mi_bitmap_t bitmap, size_t bitmap_fields, size_t count, mi_bitmap_index_t bitmap_idx) { bool any_ones; - mi_bitmap_is_claimedx_across(bitmap, bitmap_fields, count, bitmap_idx, &any_ones); + mi_bitmap_is_claimedx_across(bitmap, bitmap_fields, count, bitmap_idx, &any_ones, NULL); return any_ones; } diff --git a/Objects/mimalloc/bitmap.h b/Objects/mimalloc/bitmap.h index d60f6dd3cb8e274..ccfd0ddf375ebcd 100644 --- a/Objects/mimalloc/bitmap.h +++ b/Objects/mimalloc/bitmap.h @@ -35,9 +35,13 @@ typedef mi_bitmap_field_t* mi_bitmap_t; typedef size_t mi_bitmap_index_t; // Create a bit index. +static inline mi_bitmap_index_t mi_bitmap_index_create_ex(size_t idx, size_t bitidx) { + mi_assert_internal(bitidx <= MI_BITMAP_FIELD_BITS); + return (idx*MI_BITMAP_FIELD_BITS) + bitidx; +} static inline mi_bitmap_index_t mi_bitmap_index_create(size_t idx, size_t bitidx) { mi_assert_internal(bitidx < MI_BITMAP_FIELD_BITS); - return (idx*MI_BITMAP_FIELD_BITS) + bitidx; + return mi_bitmap_index_create_ex(idx,bitidx); } // Create a bit index. @@ -72,7 +76,7 @@ bool _mi_bitmap_try_find_claim_field(mi_bitmap_t bitmap, size_t idx, const size_ // For now, `count` can be at most MI_BITMAP_FIELD_BITS and will never cross fields. bool _mi_bitmap_try_find_from_claim(mi_bitmap_t bitmap, const size_t bitmap_fields, const size_t start_field_idx, const size_t count, mi_bitmap_index_t* bitmap_idx); -// Like _mi_bitmap_try_find_from_claim but with an extra predicate that must be fulfilled +// Like _mi_bitmap_try_find_from_claim but with an extra predicate that must be fullfilled typedef bool (mi_cdecl *mi_bitmap_pred_fun_t)(mi_bitmap_index_t bitmap_idx, void* pred_arg); bool _mi_bitmap_try_find_from_claim_pred(mi_bitmap_t bitmap, const size_t bitmap_fields, const size_t start_field_idx, const size_t count, mi_bitmap_pred_fun_t pred_fun, void* pred_arg, mi_bitmap_index_t* bitmap_idx); @@ -107,9 +111,9 @@ bool _mi_bitmap_unclaim_across(mi_bitmap_t bitmap, size_t bitmap_fields, size_t // Set `count` bits at `bitmap_idx` to 1 atomically // Returns `true` if all `count` bits were 0 previously. `any_zero` is `true` if there was at least one zero bit. -bool _mi_bitmap_claim_across(mi_bitmap_t bitmap, size_t bitmap_fields, size_t count, mi_bitmap_index_t bitmap_idx, bool* pany_zero); +bool _mi_bitmap_claim_across(mi_bitmap_t bitmap, size_t bitmap_fields, size_t count, mi_bitmap_index_t bitmap_idx, bool* pany_zero, size_t* already_set); -bool _mi_bitmap_is_claimed_across(mi_bitmap_t bitmap, size_t bitmap_fields, size_t count, mi_bitmap_index_t bitmap_idx); +bool _mi_bitmap_is_claimed_across(mi_bitmap_t bitmap, size_t bitmap_fields, size_t count, mi_bitmap_index_t bitmap_idx, size_t* already_set); bool _mi_bitmap_is_any_claimed_across(mi_bitmap_t bitmap, size_t bitmap_fields, size_t count, mi_bitmap_index_t bitmap_idx); #endif diff --git a/Objects/mimalloc/free.c b/Objects/mimalloc/free.c new file mode 100644 index 000000000000000..ba8d7682414ba99 --- /dev/null +++ b/Objects/mimalloc/free.c @@ -0,0 +1,646 @@ +/* ---------------------------------------------------------------------------- +Copyright (c) 2018-2024, Microsoft Research, Daan Leijen +This is free software; you can redistribute it and/or modify it under the +terms of the MIT license. A copy of the license can be found in the file +"LICENSE" at the root of this distribution. +-----------------------------------------------------------------------------*/ +#if !defined(MI_IN_ALLOC_C) +#error "this file should be included from 'alloc.c' (so aliases can work from alloc-override)" +// add includes help an IDE +#include "mimalloc.h" +#include "mimalloc/internal.h" +#include "mimalloc/prim.h" // _mi_prim_thread_id() +#endif + +// forward declarations +static void mi_check_padding(const mi_page_t* page, const mi_block_t* block); +static bool mi_check_is_double_free(const mi_page_t* page, const mi_block_t* block); +static size_t mi_page_usable_size_of(const mi_page_t* page, const mi_block_t* block, bool was_guarded); +static void mi_stat_free(const mi_page_t* page, const mi_block_t* block); + + +// ------------------------------------------------------ +// Free +// ------------------------------------------------------ + +// forward declaration of multi-threaded free (`_mt`) (or free in huge block if compiled with MI_HUGE_PAGE_ABANDON) +static mi_decl_noinline void mi_free_block_mt(mi_page_t* page, mi_segment_t* segment, mi_block_t* block, void* p, bool was_guarded); + +// regular free of a (thread local) block pointer +// fast path written carefully to prevent spilling on the stack +static inline void mi_free_block_local(mi_page_t* page, mi_block_t* block, bool was_guarded, bool track_stats, bool check_full) +{ + MI_UNUSED(was_guarded); + // checks + if mi_unlikely(mi_check_is_double_free(page, block)) return; + if (!was_guarded) { mi_check_padding(page, block); } + if (track_stats) { mi_stat_free(page, block); } + #if (MI_DEBUG>0) && !MI_TRACK_ENABLED && !MI_TSAN + if (!mi_page_is_huge(page)) { // huge page content may be already decommitted + size_t dbgsize = mi_page_block_size(page); if (dbgsize > 1*MI_MiB) { dbgsize = 1*MI_MiB; } + mi_debug_fill(page, block, MI_DEBUG_FREED, dbgsize); + } + #endif + if (track_stats) { mi_track_free_size(block, mi_page_usable_size_of(page, block, was_guarded)); } // faster then mi_usable_size as we already know the page and that p is unaligned + + // actual free: push on the local free list + mi_block_set_next(page, block, page->local_free); + page->local_free = block; + if mi_unlikely(--page->used == 0) { + _mi_page_retire(page); + } + else if mi_unlikely(check_full && mi_page_is_in_full(page)) { + _mi_page_unfull(page); + } +} + +// Adjust a block that was allocated aligned, to the actual start of the block in the page. +// note: this can be called from `mi_free_generic_mt` where a non-owning thread accesses the +// `page_start` and `block_size` fields; however these are constant and the page won't be +// deallocated (as the block we are freeing keeps it alive) and thus safe to read concurrently. +mi_block_t* _mi_page_ptr_unalign(const mi_page_t* page, const void* p) { + mi_assert_internal(page!=NULL && p!=NULL); + + size_t diff = (uint8_t*)p - page->page_start; + size_t adjust = 0; + if mi_likely(page->block_size_shift != 0) { + adjust = diff & (((size_t)1 << page->block_size_shift) - 1); + } + else { + const size_t block_size = page->block_size; + if mi_likely(block_size != 0) { + adjust = diff % block_size; + } + else { + _mi_error_message(EFAULT, "reading from invalid page, possibly corrupted meta-data (address=%p, page=%p)\n", p, page); + } + } + + return (mi_block_t*)((uintptr_t)p - adjust); +} + +static inline mi_block_t* mi_validate_block_from_ptr( const mi_page_t* page, const void* p ) { + mi_assert(_mi_page_ptr_unalign(page,p) == (mi_block_t*)p); // should never be an interior pointer + #if MI_SECURE > 0 + // in secure mode we always unalign to guard against free-ing interior pointers + return _mi_page_ptr_unalign(page,p); + #else + MI_UNUSED(page); + return (mi_block_t*)p; + #endif +} + +// forward declaration for a MI_GUARDED build +#if MI_GUARDED +static void mi_block_unguard(mi_page_t* page, mi_block_t* block, void* p); // forward declaration +static inline bool mi_block_check_unguard(mi_page_t* page, mi_block_t* block, void* p) { + if (mi_block_ptr_is_guarded(block, p)) { + mi_block_unguard(page, block, p); + return true; + } + else { + return false; + } +} +#else +static inline bool mi_block_check_unguard(mi_page_t* page, mi_block_t* block, void* p) { + MI_UNUSED(page); MI_UNUSED(block); MI_UNUSED(p); + return false; +} +#endif + +// free a local pointer (page parameter comes first for better codegen) +static void mi_decl_noinline mi_free_generic_local(mi_page_t* page, mi_segment_t* segment, void* p) mi_attr_noexcept { + MI_UNUSED(segment); + mi_block_t* const block = (mi_page_has_aligned(page) ? _mi_page_ptr_unalign(page, p) : mi_validate_block_from_ptr(page,p)); + const bool was_guarded = mi_block_check_unguard(page, block, p); + mi_free_block_local(page, block, was_guarded, true /* track stats */, true /* check for a full page */); +} + +// free a pointer owned by another thread (page parameter comes first for better codegen) +static void mi_decl_noinline mi_free_generic_mt(mi_page_t* page, mi_segment_t* segment, void* p) mi_attr_noexcept { + mi_block_t* const block = _mi_page_ptr_unalign(page, p); // don't check `has_aligned` flag to avoid a race (issue #865) + const bool was_guarded = mi_block_check_unguard(page, block, p); + mi_free_block_mt(page, segment, block, p, was_guarded); +} + +// generic free (for runtime integration) +void mi_decl_noinline _mi_free_generic(mi_segment_t* segment, mi_page_t* page, bool is_local, void* p) mi_attr_noexcept { + if (is_local) mi_free_generic_local(page,segment,p); + else mi_free_generic_mt(page,segment,p); +} + +// Get the segment data belonging to a pointer +// This is just a single `and` in release mode but does further checks in debug mode +// (and secure mode) to see if this was a valid pointer. +static inline mi_segment_t* mi_checked_ptr_segment(const void* p, const char* msg) +{ + MI_UNUSED(msg); + + #if (MI_DEBUG>0) + if mi_unlikely(((uintptr_t)p & (MI_INTPTR_SIZE - 1)) != 0 && !mi_option_is_enabled(mi_option_guarded_precise)) { + _mi_error_message(EINVAL, "%s: invalid (unaligned) pointer: %p\n", msg, p); + return NULL; + } + #endif + + mi_segment_t* const segment = _mi_ptr_segment(p); + if mi_unlikely(segment==NULL) return segment; + + #if 0 && (MI_DEBUG>0) // CPython: disabled, the warning is noisy and not actionable for Python allocations + if mi_unlikely(!mi_is_in_heap_region(p)) { + #if (MI_INTPTR_SIZE == 8 && defined(__linux__)) + if (((uintptr_t)p >> 40) != 0x7F) { // linux tends to align large blocks above 0x7F000000000 (issue #640) + #else + { + #endif + _mi_warning_message("%s: pointer might not point to a valid heap region: %p\n" + "(this may still be a valid very large allocation (over 64MiB))\n", msg, p); + if mi_likely(_mi_ptr_cookie(segment) == segment->cookie) { + _mi_warning_message("(yes, the previous pointer %p was valid after all)\n", p); + } + } + } + #endif + #if (MI_DEBUG>0 || MI_SECURE>=3) + if mi_unlikely(_mi_ptr_cookie(segment) != segment->cookie) { + _mi_error_message(EINVAL, "%s: pointer does not point to a valid heap space: %p\n", msg, p); + return NULL; + } + #endif + + return segment; +} + +// Free a block +// Fast path written carefully to prevent register spilling on the stack +static inline void mi_free_ex(void* p, size_t* pblock_size) mi_attr_noexcept +{ + mi_segment_t* const segment = mi_checked_ptr_segment(p,"mi_free"); + if mi_unlikely(segment==NULL) { + if (pblock_size!=NULL) { *pblock_size = 0; } + return; + } + + const bool is_local = (_mi_prim_thread_id() == mi_atomic_load_relaxed(&segment->thread_id)); + mi_page_t* const page = _mi_segment_page_of(segment, p); + if (pblock_size!=NULL) { *pblock_size = mi_page_block_size(page); } + + if mi_likely(is_local) { // thread-local free? + if mi_likely(page->flags.full_aligned == 0) { // and it is not a full page (full pages need to move from the full bin), nor has aligned blocks (aligned blocks need to be unaligned) + // thread-local, aligned, and not a full page + mi_block_t* const block = mi_validate_block_from_ptr(page,p); + mi_free_block_local(page, block, false /* is guarded */, true /* track stats */, false /* no need to check if the page is full */); + } + else { + // page is full or contains (inner) aligned blocks; use generic path + mi_free_generic_local(page, segment, p); + } + } + else { + // not thread-local; use generic path + mi_free_generic_mt(page, segment, p); + } +} + +void mi_free(void* p) mi_attr_noexcept { + mi_free_ex(p,NULL); +} + +void mi_ufree(void* p, size_t* pblock_size) mi_attr_noexcept { + mi_free_ex(p,pblock_size); +} + +void mi_free_small(void* p) mi_attr_noexcept { + mi_free(p); +} + + +// return true if successful +bool _mi_free_delayed_block(mi_block_t* block) { + // get segment and page + mi_assert_internal(block!=NULL); + const mi_segment_t* const segment = _mi_ptr_segment(block); + mi_assert_internal(_mi_ptr_cookie(segment) == segment->cookie); +#ifndef Py_GIL_DISABLED + // CPython: the GC traverses heaps of other threads, which can trigger this assert. + mi_assert_internal(_mi_thread_id() == segment->thread_id); +#endif + mi_page_t* const page = _mi_segment_page_of(segment, block); + + // Clear the no-delayed flag so delayed freeing is used again for this page. + // This must be done before collecting the free lists on this page -- otherwise + // some blocks may end up in the page `thread_free` list with no blocks in the + // heap `thread_delayed_free` list which may cause the page to be never freed! + // (it would only be freed if we happen to scan it in `mi_page_queue_find_free_ex`) + if (!_mi_page_try_use_delayed_free(page, MI_USE_DELAYED_FREE, false /* dont overwrite never delayed */)) { + return false; + } + + // collect all other non-local frees (move from `thread_free` to `free`) to ensure up-to-date `used` count + _mi_page_free_collect(page, false); + + // and free the block (possibly freeing the page as well since `used` is updated) + mi_free_block_local(page, block, false /* is guarded */, false /* stats have already been adjusted */, true /* check for a full page */); + return true; +} + +// ------------------------------------------------------ +// Multi-threaded Free (`_mt`) +// ------------------------------------------------------ + +// Push a block that is owned by another thread on its page-local thread free +// list or it's heap delayed free list. Such blocks are later collected by +// the owning thread in `_mi_free_delayed_block`. +static void mi_decl_noinline mi_free_block_delayed_mt( mi_page_t* page, mi_block_t* block ) +{ + // Try to put the block on either the page-local thread free list, + // or the heap delayed free list (if this is the first non-local free in that page) + mi_thread_free_t tfreex; + bool use_delayed; + mi_thread_free_t tfree = mi_atomic_load_relaxed(&page->xthread_free); + do { + use_delayed = (mi_tf_delayed(tfree) == MI_USE_DELAYED_FREE); + if mi_unlikely(use_delayed) { + // unlikely: this only happens on the first concurrent free in a page that is in the full list + tfreex = mi_tf_set_delayed(tfree,MI_DELAYED_FREEING); + } + else { + // usual: directly add to page thread_free list + mi_block_set_next(page, block, mi_tf_block(tfree)); + tfreex = mi_tf_set_block(tfree,block); + } + } while (!mi_atomic_cas_weak_release(&page->xthread_free, &tfree, tfreex)); + + // If this was the first non-local free, we need to push it on the heap delayed free list instead + if mi_unlikely(use_delayed) { + // racy read on `heap`, but ok because MI_DELAYED_FREEING is set (see `mi_heap_delete` and `mi_heap_collect_abandon`) + mi_heap_t* const heap = (mi_heap_t*)(mi_atomic_load_acquire(&page->xheap)); //mi_page_heap(page); + mi_assert_internal(heap != NULL); + if (heap != NULL) { + // add to the delayed free list of this heap. (do this atomically as the lock only protects heap memory validity) + mi_block_t* dfree = mi_atomic_load_ptr_relaxed(mi_block_t, &heap->thread_delayed_free); + do { + mi_block_set_nextx(heap,block,dfree, heap->keys); + } while (!mi_atomic_cas_ptr_weak_release(mi_block_t,&heap->thread_delayed_free, &dfree, block)); + } + + // and reset the MI_DELAYED_FREEING flag + tfree = mi_atomic_load_relaxed(&page->xthread_free); + do { + tfreex = tfree; + mi_assert_internal(mi_tf_delayed(tfree) == MI_DELAYED_FREEING); + tfreex = mi_tf_set_delayed(tfree,MI_NO_DELAYED_FREE); + } while (!mi_atomic_cas_weak_release(&page->xthread_free, &tfree, tfreex)); + } +} + +// Multi-threaded free (`_mt`) (or free in huge block if compiled with MI_HUGE_PAGE_ABANDON) +static void mi_decl_noinline mi_free_block_mt(mi_page_t* page, mi_segment_t* segment, mi_block_t* block, void* p, bool was_guarded) +{ + MI_UNUSED(was_guarded); + + // first see if the segment was abandoned and if we can reclaim it into our thread + if (_mi_option_get_fast(mi_option_abandoned_reclaim_on_free) != 0 && + #if MI_HUGE_PAGE_ABANDON + segment->page_kind != MI_PAGE_HUGE && + #endif + mi_atomic_load_relaxed(&segment->thread_id) == 0 && // segment is abandoned? + mi_prim_get_default_heap() != (mi_heap_t*)&_mi_heap_empty) // and we did not already exit this thread (without this check, a fresh heap will be initalized (issue #944)) + { + // the segment is abandoned, try to reclaim it into our heap + if (_mi_segment_attempt_reclaim(mi_heap_get_default(), segment)) { + mi_assert_internal(_mi_thread_id() == mi_atomic_load_relaxed(&segment->thread_id)); + mi_assert_internal(mi_heap_get_default()->tld->segments.subproc == segment->subproc); + mi_free(p); // recursively free as now it will be a local free in our heap + return; + } + } + + // The padding check may access the non-thread-owned page for the key values. + // that is safe as these are constant and the page won't be freed (as the block is not freed yet). + if (!was_guarded) { mi_check_padding(page, block); } + + // adjust stats (after padding check and potentially recursive `mi_free` above) + mi_stat_free(page, block); // stat_free may access the padding + mi_track_free_size(block, mi_page_usable_size_of(page,block,was_guarded)); + + // for small size, ensure we can fit the delayed thread pointers without triggering overflow detection + _mi_padding_shrink(page, block, sizeof(mi_block_t)); + + if (segment->kind == MI_SEGMENT_HUGE) { + #if MI_HUGE_PAGE_ABANDON + // huge page segments are always abandoned and can be freed immediately + _mi_segment_huge_page_free(segment, page, block); + return; + #else + // huge pages are special as they occupy the entire segment + // as these are large we reset the memory occupied by the page so it is available to other threads + // (as the owning thread needs to actually free the memory later). + _mi_segment_huge_page_reset(segment, page, block); + #endif + } + else { + #if (MI_DEBUG>0) && !MI_TRACK_ENABLED && !MI_TSAN // note: when tracking, cannot use mi_usable_size with multi-threading + size_t dbgsize = mi_usable_size(block); if (dbgsize > 1*MI_MiB) { dbgsize = 1*MI_MiB; } + mi_debug_fill(page, block, MI_DEBUG_FREED, dbgsize); + #endif + } + + // and finally free the actual block by pushing it on the owning heap + // thread_delayed free list (or heap delayed free list) + mi_free_block_delayed_mt(page,block); +} + + +// ------------------------------------------------------ +// Usable size +// ------------------------------------------------------ + +// Bytes available in a block +static size_t mi_decl_noinline mi_page_usable_aligned_size_of(const mi_page_t* page, const void* p) mi_attr_noexcept { + const mi_block_t* block = _mi_page_ptr_unalign(page, p); + const bool is_guarded = mi_block_ptr_is_guarded(block,p); + const size_t size = mi_page_usable_size_of(page, block, is_guarded); + mi_assert_internal((void*)p >= (void*)block); + const size_t adjust = (uint8_t*)p - (uint8_t*)block; + mi_assert_internal(adjust <= size); + const size_t aligned_size = (adjust <= size ? size - adjust : 0); // size can be zero if the padding is corrupted + return aligned_size; +} + +static inline mi_page_t* mi_validate_ptr_page(const void* p, const char* msg) { + const mi_segment_t* const segment = mi_checked_ptr_segment(p, msg); + if mi_unlikely(segment==NULL) return NULL; + mi_page_t* const page = _mi_segment_page_of(segment, p); + return page; +} + +size_t _mi_page_usable_size(const mi_page_t* page, const void* p) mi_attr_noexcept { + if mi_unlikely(page==NULL) return 0; + mi_assert_internal(mi_validate_ptr_page(p,"_mi_page_usable_size") == page); + if mi_likely(!mi_page_has_aligned(page)) { + const mi_block_t* block = mi_validate_block_from_ptr(page,p); + return mi_page_usable_size_of(page, block, false /* is guarded */); + } + else { + // split out to separate routine for improved code generation + return mi_page_usable_aligned_size_of(page, p); + } +} + +mi_decl_nodiscard size_t mi_usable_size(const void* p) mi_attr_noexcept { + const mi_page_t* const page = mi_validate_ptr_page(p,"mi_usable_size"); + return _mi_page_usable_size(page,p); +} + + +// ------------------------------------------------------ +// Free variants +// ------------------------------------------------------ + +void mi_free_size(void* p, size_t size) mi_attr_noexcept { + MI_UNUSED_RELEASE(size); + #if MI_DEBUG + const mi_page_t* const page = mi_validate_ptr_page(p,"mi_free_size"); + const size_t available = _mi_page_usable_size(page,p); + mi_assert(p == NULL || size <= available || available == 0 /* invalid pointer */ ); + #endif + mi_free(p); +} + +void mi_free_size_aligned(void* p, size_t size, size_t alignment) mi_attr_noexcept { + MI_UNUSED_RELEASE(alignment); + mi_assert(((uintptr_t)p % alignment) == 0); + mi_free_size(p,size); +} + +void mi_free_aligned(void* p, size_t alignment) mi_attr_noexcept { + MI_UNUSED_RELEASE(alignment); + mi_assert(((uintptr_t)p % alignment) == 0); + mi_free(p); +} + + +// ------------------------------------------------------ +// Check for double free in secure and debug mode +// This is somewhat expensive so only enabled for secure mode 4 +// ------------------------------------------------------ + +#if MI_CHECK_DOUBLE_FREE +// linear check if the free list contains a specific element +static bool mi_list_contains(const mi_page_t* page, const mi_block_t* list, const mi_block_t* elem, const char* list_kind) { + const size_t max_count = page->capacity; // can never hold more blocks than the capacity + size_t count = 0; + while (list != NULL && count <= max_count) { // double-free can create cycles so we limit the number of iterations + if (elem==list) return true; + list = mi_block_next(page, list); + count++; + } + if mi_unlikely(count > max_count) { + _mi_error_message(EFAULT, "corrupted %s list (possibly due to a double free)\n", list_kind); + } + return false; +} + +static mi_decl_noinline bool mi_check_is_double_freex(const mi_page_t* page, const mi_block_t* block) { + // The decoded value is in the same page (or NULL). + // Walk the free lists to verify positively if it is already freed + if (mi_list_contains(page, page->free, block, "free") || + mi_list_contains(page, page->local_free, block, "local free") || + mi_list_contains(page, mi_page_thread_free(page), block, "thread free")) + { + _mi_error_message(EAGAIN, "double free detected of block %p with size %zu\n", block, mi_page_block_size(page)); + return true; + } + return false; +} + +#define mi_track_page(page,access) { size_t psize; void* pstart = _mi_page_start(_mi_page_segment(page),page,&psize); mi_track_mem_##access( pstart, psize); } + +// Used for double free checking to avoid checking free lists too frequently +static inline bool mi_block_could_be_double_free(const mi_page_t* page, const mi_block_t* block) { + mi_block_t* n = mi_block_nextx(page,block,page->keys); + return (((uintptr_t)n & (MI_INTPTR_SIZE-1))==0 && // quick check: aligned pointer? + (n==NULL || mi_is_in_same_page(block,n))); // quick check: in the same page or NULL? +} + +static inline bool mi_check_is_double_free(const mi_page_t* page, const mi_block_t* block) { + if mi_unlikely(mi_block_could_be_double_free(page,block)) // quick check: next field is aligned in the same page or NULL? + { + // Suspicious: decoded value a in block is in the same page (or NULL) -- maybe a double free? + // (continue in separate function to improve code generation) + return mi_check_is_double_freex(page, block); + } + else return false; +} +#else +static inline bool mi_check_is_double_free(const mi_page_t* page, const mi_block_t* block) { + MI_UNUSED(page); + MI_UNUSED(block); + return false; +} +#endif + + +// --------------------------------------------------------------------------- +// Check for heap block overflow by setting up padding at the end of the block +// --------------------------------------------------------------------------- + +#if MI_PADDING // && !MI_TRACK_ENABLED +static bool mi_page_decode_padding(const mi_page_t* page, const mi_block_t* block, size_t* delta, size_t* bsize) { + *bsize = mi_page_usable_block_size(page); + const mi_padding_t* const padding = (mi_padding_t*)((uint8_t*)block + *bsize); + mi_track_mem_defined(padding,sizeof(mi_padding_t)); + *delta = padding->delta; + uint32_t canary = padding->canary; + uintptr_t keys[2]; + keys[0] = page->keys[0]; + keys[1] = page->keys[1]; + bool ok = (mi_ptr_encode_canary(page,block,keys) == canary && *delta <= *bsize); + mi_track_mem_noaccess(padding,sizeof(mi_padding_t)); + return ok; +} + +// Return the exact usable size of a block. +static size_t mi_page_usable_size_of(const mi_page_t* page, const mi_block_t* block, bool is_guarded) { + if (is_guarded) { + const size_t bsize = mi_page_block_size(page); + return (bsize - _mi_os_page_size()); + } + else { + size_t bsize; + size_t delta; + bool ok = mi_page_decode_padding(page, block, &delta, &bsize); + mi_assert_internal(ok); mi_assert_internal(delta <= bsize); + return (ok ? bsize - delta : 0); + } +} + +// When a non-thread-local block is freed, it becomes part of the thread delayed free +// list that is freed later by the owning heap. If the exact usable size is too small to +// contain the pointer for the delayed list, then shrink the padding (by decreasing delta) +// so it will later not trigger an overflow error in `mi_free_block`. +void _mi_padding_shrink(const mi_page_t* page, const mi_block_t* block, const size_t min_size) { + size_t bsize; + size_t delta; + bool ok = mi_page_decode_padding(page, block, &delta, &bsize); + mi_assert_internal(ok); + if (!ok || (bsize - delta) >= min_size) return; // usually already enough space + mi_assert_internal(bsize >= min_size); + if (bsize < min_size) return; // should never happen + size_t new_delta = (bsize - min_size); + mi_assert_internal(new_delta < bsize); + mi_padding_t* padding = (mi_padding_t*)((uint8_t*)block + bsize); + mi_track_mem_defined(padding,sizeof(mi_padding_t)); + padding->delta = (uint32_t)new_delta; + mi_track_mem_noaccess(padding,sizeof(mi_padding_t)); +} +#else +static size_t mi_page_usable_size_of(const mi_page_t* page, const mi_block_t* block, bool is_guarded) { + MI_UNUSED(block); + if (is_guarded) { + const size_t bsize = mi_page_block_size(page); + return (bsize - _mi_os_page_size()); + } + else { + return mi_page_usable_block_size(page); + } +} + +void _mi_padding_shrink(const mi_page_t* page, const mi_block_t* block, const size_t min_size) { + MI_UNUSED(page); MI_UNUSED(block); MI_UNUSED(min_size); +} +#endif + +#if MI_PADDING && MI_PADDING_CHECK + +static bool mi_verify_padding(const mi_page_t* page, const mi_block_t* block, size_t* size, size_t* wrong) { + size_t bsize; + size_t delta; + bool ok = mi_page_decode_padding(page, block, &delta, &bsize); + *size = *wrong = bsize; + if (!ok) return false; + mi_assert_internal(bsize >= delta); + *size = bsize - delta; + if (!mi_page_is_huge(page)) { + uint8_t* fill = (uint8_t*)block + bsize - delta; + const size_t maxpad = (delta > MI_MAX_ALIGN_SIZE ? MI_MAX_ALIGN_SIZE : delta); // check at most the first N padding bytes + mi_track_mem_defined(fill, maxpad); + for (size_t i = 0; i < maxpad; i++) { + if (fill[i] != MI_DEBUG_PADDING) { + *wrong = bsize - delta + i; + ok = false; + break; + } + } + mi_track_mem_noaccess(fill, maxpad); + } + return ok; +} + +static void mi_check_padding(const mi_page_t* page, const mi_block_t* block) { + size_t size; + size_t wrong; + if (!mi_verify_padding(page,block,&size,&wrong)) { + _mi_error_message(EFAULT, "buffer overflow in heap block %p of size %zu: write after %zu bytes\n", block, size, wrong ); + } +} + +#else + +static void mi_check_padding(const mi_page_t* page, const mi_block_t* block) { + MI_UNUSED(page); + MI_UNUSED(block); +} + +#endif + +// only maintain stats for smaller objects if requested +#if (MI_STAT>0) +static void mi_stat_free(const mi_page_t* page, const mi_block_t* block) { + MI_UNUSED(block); + mi_heap_t* const heap = mi_heap_get_default(); + const size_t bsize = mi_page_usable_block_size(page); + // #if (MI_STAT>1) + // const size_t usize = mi_page_usable_size_of(page, block); + // mi_heap_stat_decrease(heap, malloc_requested, usize); + // #endif + if (bsize <= MI_MEDIUM_OBJ_SIZE_MAX) { + mi_heap_stat_decrease(heap, malloc_normal, bsize); + #if (MI_STAT > 1) + mi_heap_stat_decrease(heap, malloc_bins[_mi_bin(bsize)], 1); + #endif + } + //else if (bsize <= MI_LARGE_OBJ_SIZE_MAX) { + // mi_heap_stat_decrease(heap, malloc_large, bsize); + //} + else { + mi_heap_stat_decrease(heap, malloc_huge, bsize); + } +} +#else +static void mi_stat_free(const mi_page_t* page, const mi_block_t* block) { + MI_UNUSED(page); MI_UNUSED(block); +} +#endif + + +// Remove guard page when building with MI_GUARDED +#if MI_GUARDED +static void mi_block_unguard(mi_page_t* page, mi_block_t* block, void* p) { + MI_UNUSED(p); + mi_assert_internal(mi_block_ptr_is_guarded(block, p)); + mi_assert_internal(mi_page_has_aligned(page)); + mi_assert_internal((uint8_t*)p - (uint8_t*)block >= (ptrdiff_t)sizeof(mi_block_t)); + mi_assert_internal(block->next == MI_BLOCK_TAG_GUARDED); + + const size_t bsize = mi_page_block_size(page); + const size_t psize = _mi_os_page_size(); + mi_assert_internal(bsize > psize); + mi_assert_internal(_mi_page_segment(page)->allow_decommit); + void* gpage = (uint8_t*)block + bsize - psize; + mi_assert_internal(_mi_is_aligned(gpage, psize)); + _mi_os_unprotect(gpage, psize); +} +#endif diff --git a/Objects/mimalloc/heap.c b/Objects/mimalloc/heap.c index 5fbfb82baa02040..3d77a6afd10b36c 100644 --- a/Objects/mimalloc/heap.c +++ b/Objects/mimalloc/heap.c @@ -24,7 +24,7 @@ terms of the MIT license. A copy of the license can be found in the file typedef bool (heap_page_visitor_fun)(mi_heap_t* heap, mi_page_queue_t* pq, mi_page_t* page, void* arg1, void* arg2); // Visit all pages in a heap; returns `false` if break was called. -static bool mi_heap_visit_pages(mi_heap_t* heap, heap_page_visitor_fun* fn, void* arg1, void* arg2) +static bool mi_heap_visit_pages(mi_heap_t* heap, heap_page_visitor_fun* fn, bool include_full, void* arg1, void* arg2) { if (heap==NULL || heap->page_count==0) return true; @@ -34,7 +34,8 @@ static bool mi_heap_visit_pages(mi_heap_t* heap, heap_page_visitor_fun* fn, void size_t count = 0; #endif - for (size_t i = 0; i <= MI_BIN_FULL; i++) { + const size_t max_bin = (include_full ? MI_BIN_FULL : MI_BIN_FULL - 1); + for (size_t i = 0; i <= max_bin; i++) { mi_page_queue_t* pq = &heap->pages[i]; mi_page_t* page = pq->first; while(page != NULL) { @@ -47,7 +48,7 @@ static bool mi_heap_visit_pages(mi_heap_t* heap, heap_page_visitor_fun* fn, void page = next; // and continue } } - mi_assert_internal(count == total); + mi_assert_internal(!include_full || count == total); return true; } @@ -59,7 +60,7 @@ static bool mi_heap_page_is_valid(mi_heap_t* heap, mi_page_queue_t* pq, mi_page_ MI_UNUSED(pq); mi_assert_internal(mi_page_heap(page) == heap); mi_segment_t* segment = _mi_page_segment(page); - mi_assert_internal(segment->thread_id == heap->thread_id); + mi_assert_internal(mi_atomic_load_relaxed(&segment->thread_id) == heap->thread_id); mi_assert_expensive(_mi_page_is_valid(page)); return true; } @@ -67,7 +68,7 @@ static bool mi_heap_page_is_valid(mi_heap_t* heap, mi_page_queue_t* pq, mi_page_ #if MI_DEBUG>=3 static bool mi_heap_is_valid(mi_heap_t* heap) { mi_assert_internal(heap!=NULL); - mi_heap_visit_pages(heap, &mi_heap_page_is_valid, NULL, NULL); + mi_heap_visit_pages(heap, &mi_heap_page_is_valid, true, NULL, NULL); return true; } #endif @@ -95,14 +96,19 @@ static bool mi_heap_page_collect(mi_heap_t* heap, mi_page_queue_t* pq, mi_page_t mi_assert_internal(mi_heap_page_is_valid(heap, pq, page, NULL, NULL)); mi_collect_t collect = *((mi_collect_t*)arg_collect); _mi_page_free_collect(page, collect >= MI_FORCE); + if (collect == MI_FORCE) { + // note: call before a potential `_mi_page_free` as the segment may be freed if this was the last used page in that segment. + mi_segment_t* segment = _mi_page_segment(page); + _mi_segment_collect(segment, true /* force? */); + } if (mi_page_all_free(page)) { // no more used blocks, free the page. // note: this will free retired pages as well. bool freed = _PyMem_mi_page_maybe_free(page, pq, collect >= MI_FORCE); if (!freed && collect == MI_ABANDON) { - // _PyMem_mi_page_maybe_free may have moved the page to a different + // CPython: _PyMem_mi_page_maybe_free may have moved the page to a different // page queue, so we need to re-fetch the correct queue. - uint8_t bin = (mi_page_is_in_full(page) ? MI_BIN_FULL : _mi_bin(page->xblock_size)); + size_t bin = (mi_page_is_in_full(page) ? MI_BIN_FULL : _mi_bin(mi_page_block_size(page))); _mi_page_abandon(page, &heap->pages[bin]); } } @@ -126,11 +132,11 @@ static void mi_heap_collect_ex(mi_heap_t* heap, mi_collect_t collect) { if (heap==NULL || !mi_heap_is_initialized(heap)) return; - const bool force = collect >= MI_FORCE; + const bool force = (collect >= MI_FORCE); _mi_deferred_free(heap, force); - // gh-112532: we may be called from a thread that is not the owner of the heap - bool is_main_thread = _mi_is_main_thread() && heap->thread_id == _mi_thread_id(); + // python/cpython#112532: we may be called from a thread that is not the owner of the heap + const bool is_main_thread = (_mi_is_main_thread() && heap->thread_id == _mi_thread_id()); // note: never reclaim on collect but leave it to threads that need storage to reclaim const bool force_main = @@ -144,42 +150,47 @@ static void mi_heap_collect_ex(mi_heap_t* heap, mi_collect_t collect) if (force_main) { // the main thread is abandoned (end-of-program), try to reclaim all abandoned segments. // if all memory is freed by now, all segments should be freed. + // note: this only collects in the current subprocess _mi_abandoned_reclaim_all(heap, &heap->tld->segments); } // if abandoning, mark all pages to no longer add to delayed_free if (collect == MI_ABANDON) { - mi_heap_visit_pages(heap, &mi_heap_page_never_delayed_free, NULL, NULL); + mi_heap_visit_pages(heap, &mi_heap_page_never_delayed_free, true, NULL, NULL); } // free all current thread delayed blocks. // (if abandoning, after this there are no more thread-delayed references into the pages.) - _mi_heap_delayed_free_all(heap); + if (collect >= MI_ABANDON) { + _mi_heap_delayed_free_all(heap); // free all + } else { + _mi_heap_delayed_free_partial(heap); // best-effort; contended blocks are retried next time + } // collect retired pages _mi_heap_collect_retired(heap, force); - // free pages that were delayed with QSBR + // CPython: free pages that were delayed with QSBR _PyMem_mi_heap_collect_qsbr(heap); // collect all pages owned by this thread - mi_heap_visit_pages(heap, &mi_heap_page_collect, &collect, NULL); + mi_heap_visit_pages(heap, &mi_heap_page_collect, (collect!=MI_NORMAL), &collect, NULL); // normally don't visit full pages, issue #1220 mi_assert_internal( collect != MI_ABANDON || mi_atomic_load_ptr_acquire(mi_block_t,&heap->thread_delayed_free) == NULL ); // collect abandoned segments (in particular, purge expired parts of segments in the abandoned segment list) // note: forced purge can be quite expensive if many threads are created/destroyed so we do not force on abandonment _mi_abandoned_collect(heap, collect == MI_FORCE /* force? */, &heap->tld->segments); - // collect segment local caches - if (force) { - _mi_segment_thread_collect(&heap->tld->segments); - } - - // collect regions on program-exit (or shared library unload) + // if forced, collect thread data cache on program-exit (or shared library unload) if (force && is_main_thread && mi_heap_is_backing(heap)) { _mi_thread_data_collect(); // collect thread data cache - _mi_arena_collect(true /* force purge */, &heap->tld->stats); } + + // collect arenas (this is program wide so don't force purges on abandonment of threads) + _mi_arenas_collect(collect == MI_FORCE /* force purge? */); + + // merge statistics + if (collect <= MI_FORCE) { _mi_stats_merge_thread(heap->tld); } } void _mi_heap_collect_abandon(mi_heap_t* heap) { @@ -218,39 +229,48 @@ mi_heap_t* mi_heap_get_backing(void) { return bheap; } -void _mi_heap_init_ex(mi_heap_t* heap, mi_tld_t* tld, mi_arena_id_t arena_id, bool no_reclaim, uint8_t tag) -{ +void _mi_heap_init(mi_heap_t* heap, mi_tld_t* tld, mi_arena_id_t arena_id, bool noreclaim, uint8_t tag) { _mi_memcpy_aligned(heap, &_mi_heap_empty, sizeof(mi_heap_t)); heap->tld = tld; - heap->thread_id = _mi_thread_id(); - heap->arena_id = arena_id; + heap->thread_id = _mi_thread_id(); + heap->arena_id = arena_id; + heap->no_reclaim = noreclaim; + heap->tag = tag; if (heap == tld->heap_backing) { - _mi_random_init(&heap->random); + #if defined(_WIN32) && !defined(MI_SHARED_LIB) + _mi_random_init_weak(&heap->random); // prevent allocation failure during bcrypt dll initialization with static linking (issue #1185) + #else + _mi_random_init(&heap->random); + #endif } else { _mi_random_split(&tld->heap_backing->random, &heap->random); } - heap->cookie = _mi_heap_random_next(heap) | 1; + heap->cookie = _mi_heap_random_next(heap) | 1; heap->keys[0] = _mi_heap_random_next(heap); heap->keys[1] = _mi_heap_random_next(heap); - heap->no_reclaim = no_reclaim; - heap->tag = tag; + _mi_heap_guarded_init(heap); // push on the thread local heaps list heap->next = heap->tld->heaps; heap->tld->heaps = heap; } -mi_decl_nodiscard mi_heap_t* mi_heap_new_in_arena(mi_arena_id_t arena_id) { +mi_decl_nodiscard mi_heap_t* mi_heap_new_ex(int heap_tag, bool allow_destroy, mi_arena_id_t arena_id) { mi_heap_t* bheap = mi_heap_get_backing(); mi_heap_t* heap = mi_heap_malloc_tp(bheap, mi_heap_t); // todo: OS allocate in secure mode? if (heap == NULL) return NULL; - // don't reclaim abandoned pages or otherwise destroy is unsafe - _mi_heap_init_ex(heap, bheap->tld, arena_id, true, 0); + mi_assert(heap_tag >= 0 && heap_tag < 256); + _mi_heap_init(heap, bheap->tld, arena_id, allow_destroy /* no reclaim? */, (uint8_t)heap_tag /* heap tag */); return heap; } +mi_decl_nodiscard mi_heap_t* mi_heap_new_in_arena(mi_arena_id_t arena_id) { + return mi_heap_new_ex(0 /* default heap tag */, false /* don't allow `mi_heap_destroy` */, arena_id); +} + mi_decl_nodiscard mi_heap_t* mi_heap_new(void) { - return mi_heap_new_in_arena(_mi_arena_id_none()); + // don't reclaim abandoned memory or otherwise destroy is unsafe + return mi_heap_new_ex(0 /* default heap tag */, true /* no reclaim */, _mi_arena_id_none()); } bool _mi_heap_memid_is_suitable(mi_heap_t* heap, mi_memid_t memid) { @@ -303,6 +323,18 @@ static void mi_heap_free(mi_heap_t* heap) { mi_free(heap); } +// return a heap on the same thread as `heap` specialized for the specified tag (if it exists) +mi_heap_t* _mi_heap_by_tag(mi_heap_t* heap, uint8_t tag) { + if (heap->tag == tag) { + return heap; + } + for (mi_heap_t *curr = heap->tld->heaps; curr != NULL; curr = curr->next) { + if (curr->tag == tag) { + return curr; + } + } + return NULL; +} /* ----------------------------------------------------------- Heap destroy @@ -320,24 +352,25 @@ static bool _mi_heap_page_destroy(mi_heap_t* heap, mi_page_queue_t* pq, mi_page_ // stats const size_t bsize = mi_page_block_size(page); if (bsize > MI_MEDIUM_OBJ_SIZE_MAX) { - if (bsize <= MI_LARGE_OBJ_SIZE_MAX) { - mi_heap_stat_decrease(heap, large, bsize); - } - else { - mi_heap_stat_decrease(heap, huge, bsize); + //if (bsize <= MI_LARGE_OBJ_SIZE_MAX) { + // mi_heap_stat_decrease(heap, malloc_large, bsize); + //} + //else + { + mi_heap_stat_decrease(heap, malloc_huge, bsize); } } -#if (MI_STAT) + #if (MI_STAT>0) _mi_page_free_collect(page, false); // update used count const size_t inuse = page->used; if (bsize <= MI_LARGE_OBJ_SIZE_MAX) { - mi_heap_stat_decrease(heap, normal, bsize * inuse); -#if (MI_STAT>1) - mi_heap_stat_decrease(heap, normal_bins[_mi_bin(bsize)], inuse); -#endif + mi_heap_stat_decrease(heap, malloc_normal, bsize * inuse); + #if (MI_STAT>1) + mi_heap_stat_decrease(heap, malloc_bins[_mi_bin(bsize)], inuse); + #endif } - mi_heap_stat_decrease(heap, malloc, bsize * inuse); // todo: off for aligned blocks... -#endif + // mi_heap_stat_decrease(heap, malloc_requested, bsize * inuse); // todo: off for aligned blocks... + #endif /// pretend it is all free now mi_assert_internal(mi_page_thread_free(page) == NULL); @@ -353,7 +386,7 @@ static bool _mi_heap_page_destroy(mi_heap_t* heap, mi_page_queue_t* pq, mi_page_ } void _mi_heap_destroy_pages(mi_heap_t* heap) { - mi_heap_visit_pages(heap, &_mi_heap_page_destroy, NULL, NULL); + mi_heap_visit_pages(heap, &_mi_heap_page_destroy, true, NULL, NULL); mi_heap_reset_pages(heap); } @@ -371,7 +404,13 @@ void mi_heap_destroy(mi_heap_t* heap) { mi_assert(heap->no_reclaim); mi_assert_expensive(mi_heap_is_valid(heap)); if (heap==NULL || !mi_heap_is_initialized(heap)) return; + #if MI_GUARDED + // _mi_warning_message("'mi_heap_destroy' called but MI_GUARDED is enabled -- using `mi_heap_delete` instead (heap at %p)\n", heap); + mi_heap_delete(heap); + return; + #else if (!heap->no_reclaim) { + _mi_warning_message("'mi_heap_destroy' called but ignored as the heap was not created with 'allow_destroy' (heap at %p)\n", heap); // don't free in case it may contain reclaimed pages mi_heap_delete(heap); } @@ -384,12 +423,14 @@ void mi_heap_destroy(mi_heap_t* heap) { _mi_heap_destroy_pages(heap); mi_heap_free(heap); } + #endif } // forcefully destroy all heaps in the current thread -void _mi_heap_unsafe_destroy_all(void) { - mi_heap_t* bheap = mi_heap_get_backing(); - mi_heap_t* curr = bheap->tld->heaps; +void _mi_heap_unsafe_destroy_all(mi_heap_t* heap) { + mi_assert_internal(heap != NULL); + if (heap == NULL) return; + mi_heap_t* curr = heap->tld->heaps; while (curr != NULL) { mi_heap_t* next = curr->next; if (curr->no_reclaim) { @@ -440,6 +481,12 @@ static void mi_heap_absorb(mi_heap_t* heap, mi_heap_t* from) { mi_heap_reset_pages(from); } +// are two heaps compatible with respect to heap-tag, exclusive arena etc. +static bool mi_heaps_are_compatible(mi_heap_t* heap1, mi_heap_t* heap2) { + return (heap1->tag == heap2->tag && // store same kind of objects + heap1->arena_id == heap2->arena_id); // same arena preference +} + // Safe delete a heap without freeing any still allocated blocks in that heap. void mi_heap_delete(mi_heap_t* heap) { @@ -448,9 +495,10 @@ void mi_heap_delete(mi_heap_t* heap) mi_assert_expensive(mi_heap_is_valid(heap)); if (heap==NULL || !mi_heap_is_initialized(heap)) return; - if (!mi_heap_is_backing(heap)) { + mi_heap_t* bheap = heap->tld->heap_backing; + if (bheap != heap && mi_heaps_are_compatible(bheap,heap)) { // transfer still used pages to the backing heap - mi_heap_absorb(heap->tld->heap_backing, heap); + mi_heap_absorb(bheap, heap); } else { // the backing heap abandons its pages @@ -498,8 +546,7 @@ static bool mi_heap_page_check_owned(mi_heap_t* heap, mi_page_queue_t* pq, mi_pa MI_UNUSED(heap); MI_UNUSED(pq); bool* found = (bool*)vfound; - mi_segment_t* segment = _mi_page_segment(page); - void* start = _mi_page_start(segment, page, NULL); + void* start = mi_page_start(page); void* end = (uint8_t*)start + (page->capacity * mi_page_block_size(page)); *found = (p >= start && p < end); return (!*found); // continue if not found @@ -510,7 +557,7 @@ bool mi_heap_check_owned(mi_heap_t* heap, const void* p) { if (heap==NULL || !mi_heap_is_initialized(heap)) return false; if (((uintptr_t)p & (MI_INTPTR_SIZE - 1)) != 0) return false; // only aligned pointers bool found = false; - mi_heap_visit_pages(heap, &mi_heap_page_check_owned, (void*)p, &found); + mi_heap_visit_pages(heap, &mi_heap_page_check_owned, true, (void*)p, &found); return found; } @@ -524,50 +571,61 @@ bool mi_check_owned(const void* p) { enable visiting all blocks of all heaps across threads ----------------------------------------------------------- */ -// Separate struct to keep `mi_page_t` out of the public interface -typedef struct mi_heap_area_ex_s { - mi_heap_area_t area; - mi_page_t* page; -} mi_heap_area_ex_t; +void _mi_heap_area_init(mi_heap_area_t* area, mi_page_t* page) { + const size_t bsize = mi_page_block_size(page); + const size_t ubsize = mi_page_usable_block_size(page); + area->reserved = page->reserved * bsize; + area->committed = page->capacity * bsize; + area->blocks = mi_page_start(page); + area->used = page->used; // number of blocks in use (#553) + area->block_size = ubsize; + area->full_block_size = bsize; + area->heap_tag = page->heap_tag; +} -static void mi_fast_divisor(size_t divisor, size_t* magic, size_t* shift) { + +static void mi_get_fast_divisor(size_t divisor, uint64_t* magic, size_t* shift) { mi_assert_internal(divisor > 0 && divisor <= UINT32_MAX); - *shift = MI_INTPTR_BITS - mi_clz(divisor - 1); - *magic = (size_t)(((1ULL << 32) * ((1ULL << *shift) - divisor)) / divisor + 1); + *shift = MI_SIZE_BITS - mi_clz(divisor - 1); + *magic = ((((uint64_t)1 << 32) * (((uint64_t)1 << *shift) - divisor)) / divisor + 1); } -static size_t mi_fast_divide(size_t n, size_t magic, size_t shift) { +static size_t mi_fast_divide(size_t n, uint64_t magic, size_t shift) { mi_assert_internal(n <= UINT32_MAX); - return ((((uint64_t) n * magic) >> 32) + n) >> shift; + const uint64_t hi = ((uint64_t)n * magic) >> 32; + return (size_t)((hi + n) >> shift); } -bool _mi_heap_area_visit_blocks(const mi_heap_area_t* area, mi_page_t *page, mi_block_visit_fun* visitor, void* arg) { +bool _mi_heap_area_visit_blocks(const mi_heap_area_t* area, mi_page_t* page, mi_block_visit_fun* visitor, void* arg) { mi_assert(area != NULL); if (area==NULL) return true; mi_assert(page != NULL); if (page == NULL) return true; + // collect early so the page used count is reported correctly + // _mi_page_free_collect(page,true); // collect both thread_delayed and local_free mi_assert_internal(page->local_free == NULL); if (page->used == 0) return true; - const size_t bsize = mi_page_block_size(page); - const size_t ubsize = mi_page_usable_block_size(page); // without padding - size_t psize; - uint8_t* pstart = _mi_page_start(_mi_page_segment(page), page, &psize); - mi_heap_t* heap = mi_page_heap(page); + size_t psize; + uint8_t* const pstart = _mi_segment_page_start(_mi_page_segment(page), page, &psize); + mi_heap_t* const heap = mi_page_heap(page); + const size_t bsize = mi_page_block_size(page); + const size_t ubsize = mi_page_usable_block_size(page); // without padding + // optimize page with one block if (page->capacity == 1) { - // optimize page with one block mi_assert_internal(page->used == 1 && page->free == NULL); - return visitor(heap, area, pstart, ubsize, arg); + return visitor(mi_page_heap(page), area, pstart, ubsize, arg); } + mi_assert(bsize <= UINT32_MAX); + // optimize full pages if (page->used == page->capacity) { - // optimize full pages uint8_t* block = pstart; for (size_t i = 0; i < page->capacity; i++) { - if (!visitor(heap, area, block, ubsize, arg)) return false; - block += bsize; + if (!visitor(heap, area, block, ubsize, arg)) return false; + block += bsize; } return true; } @@ -575,29 +633,31 @@ bool _mi_heap_area_visit_blocks(const mi_heap_area_t* area, mi_page_t *page, mi_ // create a bitmap of free blocks. #define MI_MAX_BLOCKS (MI_SMALL_PAGE_SIZE / sizeof(void*)) uintptr_t free_map[MI_MAX_BLOCKS / MI_INTPTR_BITS]; - size_t bmapsize = (page->capacity + MI_INTPTR_BITS - 1) / MI_INTPTR_BITS; - memset(free_map, 0, bmapsize * sizeof(uintptr_t)); - + const uintptr_t bmapsize = _mi_divide_up(page->capacity, MI_INTPTR_BITS); + memset(free_map, 0, bmapsize * sizeof(intptr_t)); if (page->capacity % MI_INTPTR_BITS != 0) { - size_t shift = (page->capacity % MI_INTPTR_BITS); + // mark left-over bits at the end as free + size_t shift = (page->capacity % MI_INTPTR_BITS); uintptr_t mask = (UINTPTR_MAX << shift); - free_map[bmapsize-1] = mask; + free_map[bmapsize - 1] = mask; } // fast repeated division by the block size - size_t magic, shift; - mi_fast_divisor(bsize, &magic, &shift); + uint64_t magic; + size_t shift; + mi_get_fast_divisor(bsize, &magic, &shift); #if MI_DEBUG>1 size_t free_count = 0; #endif - for (mi_block_t* block = page->free; block != NULL; block = mi_block_next(page,block)) { + for (mi_block_t* block = page->free; block != NULL; block = mi_block_next(page, block)) { #if MI_DEBUG>1 free_count++; #endif mi_assert_internal((uint8_t*)block >= pstart && (uint8_t*)block < (pstart + psize)); size_t offset = (uint8_t*)block - pstart; mi_assert_internal(offset % bsize == 0); + mi_assert_internal(offset <= UINT32_MAX); size_t blockidx = mi_fast_divide(offset, magic, shift); mi_assert_internal(blockidx == offset / bsize); mi_assert_internal(blockidx < MI_MAX_BLOCKS); @@ -624,14 +684,15 @@ bool _mi_heap_area_visit_blocks(const mi_heap_area_t* area, mi_page_t *page, mi_ } } else { + // visit the used blocks in the mask uintptr_t m = ~free_map[i]; - while (m) { + while (m != 0) { #if MI_DEBUG>1 used_count++; #endif size_t bitidx = mi_ctz(m); if (!visitor(heap, area, block + (bitidx * bsize), ubsize, arg)) return false; - m &= m - 1; + m &= m - 1; // clear least significant bit } block += bsize * MI_INTPTR_BITS; } @@ -640,26 +701,24 @@ bool _mi_heap_area_visit_blocks(const mi_heap_area_t* area, mi_page_t *page, mi_ return true; } -typedef bool (mi_heap_area_visit_fun)(const mi_heap_t* heap, const mi_heap_area_ex_t* area, void* arg); -void _mi_heap_area_init(mi_heap_area_t* area, mi_page_t* page) { - _mi_page_free_collect(page,true); - const size_t bsize = mi_page_block_size(page); - const size_t ubsize = mi_page_usable_block_size(page); - area->reserved = page->reserved * bsize; - area->committed = page->capacity * bsize; - area->blocks = _mi_page_start(_mi_page_segment(page), page, NULL); - area->used = page->used; // number of blocks in use (#553) - area->block_size = ubsize; - area->full_block_size = bsize; -} + +// Separate struct to keep `mi_page_t` out of the public interface +typedef struct mi_heap_area_ex_s { + mi_heap_area_t area; + mi_page_t* page; +} mi_heap_area_ex_t; + +typedef bool (mi_heap_area_visit_fun)(const mi_heap_t* heap, const mi_heap_area_ex_t* area, void* arg); static bool mi_heap_visit_areas_page(mi_heap_t* heap, mi_page_queue_t* pq, mi_page_t* page, void* vfun, void* arg) { MI_UNUSED(heap); MI_UNUSED(pq); + if (page==NULL) return true; mi_heap_area_visit_fun* fun = (mi_heap_area_visit_fun*)vfun; mi_heap_area_ex_t xarea; xarea.page = page; + _mi_page_free_collect(page,true); // collect early so the page->used is accurate _mi_heap_area_init(&xarea.area, page); return fun(heap, &xarea, arg); } @@ -667,7 +726,7 @@ static bool mi_heap_visit_areas_page(mi_heap_t* heap, mi_page_queue_t* pq, mi_pa // Visit all heap pages as areas static bool mi_heap_visit_areas(const mi_heap_t* heap, mi_heap_area_visit_fun* visitor, void* arg) { if (visitor == NULL) return false; - return mi_heap_visit_pages((mi_heap_t*)heap, &mi_heap_visit_areas_page, (void*)(visitor), arg); // note: function pointer to void* :-{ + return mi_heap_visit_pages((mi_heap_t*)heap, &mi_heap_visit_areas_page, true, (void*)(visitor), arg); // note: function pointer to void* :-{ } // Just to pass arguments @@ -691,6 +750,40 @@ static bool mi_heap_area_visitor(const mi_heap_t* heap, const mi_heap_area_ex_t* // Visit all blocks in a heap bool mi_heap_visit_blocks(const mi_heap_t* heap, bool visit_blocks, mi_block_visit_fun* visitor, void* arg) { mi_visit_blocks_args_t args = { visit_blocks, visitor, arg }; - _mi_heap_delayed_free_partial((mi_heap_t *)heap); + _mi_heap_delayed_free_partial((mi_heap_t *)heap); // CPython: gh-112532 return mi_heap_visit_areas(heap, &mi_heap_area_visitor, &args); } + + + +static const mi_page_t* mi_safe_ptr_page(void* p) { + const mi_segment_t* const segment = _mi_ptr_segment(p); + if mi_unlikely(segment==NULL) return NULL; + #ifndef NDEBUG + if mi_unlikely(!mi_is_in_heap_region(p)) return NULL; + #endif + if mi_unlikely(_mi_ptr_cookie(segment) != segment->cookie) return NULL; + return _mi_segment_page_of(segment, p); +} + +// unsafe heap utilization function for DragonFly (see issue #1258) +// If the page of pointer `p` belongs to `heap` (or `heap==NULL`) and has less than `perc_threshold` used blocks in its used area return `true`. +// This function is unsafe in general as it assumes we are the only thread accessing the page of `p`. +bool mi_unsafe_heap_page_is_under_utilized(mi_heap_t* heap, void* p, size_t perc_threshold) mi_attr_noexcept { + if (p==NULL) return false; + const mi_page_t* const page = mi_safe_ptr_page(p); // Get the page containing this pointer + if (page==NULL || page->used==page->capacity || page->capacity < page->reserved) return false; + // If the page is the head of the queue, it is currently being used for + // allocations; we skip it to avoid immediate thrashing. + if (page->prev == NULL) return false; + + // match heap? + const mi_heap_t* const page_heap = mi_page_heap(page); + if (page_heap==NULL) return false; + if (heap!=NULL && page_heap!=heap) return false; + + // check utilization + if (page->capacity==0) return false; + if (perc_threshold>=100) return true; + return (perc_threshold >= ((100UL*page->used) / page->capacity)); +} diff --git a/Objects/mimalloc/init.c b/Objects/mimalloc/init.c index 7711c827a58b1ca..d5157351d99eaad 100644 --- a/Objects/mimalloc/init.c +++ b/Objects/mimalloc/init.c @@ -13,7 +13,7 @@ terms of the MIT license. A copy of the license can be found in the file // Empty page used to initialize the small free pages array -const mi_page_t _mi_page_empty; +const mi_page_t _mi_page_empty; // CPython: zero-initialized since mi_page_t has extra fields #define MI_PAGE_EMPTY() ((mi_page_t*)&_mi_page_empty) @@ -45,27 +45,26 @@ const mi_page_t _mi_page_empty; QNULL(MI_MEDIUM_OBJ_WSIZE_MAX + 1 /* 655360, Huge queue */), \ QNULL(MI_MEDIUM_OBJ_WSIZE_MAX + 2) /* Full queue */ } -#define MI_STAT_COUNT_NULL() {0,0,0,0} +#define MI_STAT_COUNT_NULL() {0,0,0} // Empty statistics -#if MI_STAT>1 -#define MI_STAT_COUNT_END_NULL() , { MI_STAT_COUNT_NULL(), MI_INIT32(MI_STAT_COUNT_NULL) } -#else -#define MI_STAT_COUNT_END_NULL() -#endif - #define MI_STATS_NULL \ - MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), \ - MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), \ - MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), \ - MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), \ - MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), \ - MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), \ - MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), \ - MI_STAT_COUNT_NULL(), \ - { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \ - { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } \ - MI_STAT_COUNT_END_NULL() + MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), \ + { 0 }, { 0 }, \ + MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), \ + MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), \ + { 0 }, { 0 }, { 0 }, { 0 }, \ + { 0 }, { 0 }, { 0 }, { 0 }, \ + \ + { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, \ + MI_INIT4(MI_STAT_COUNT_NULL), \ + { 0 }, { 0 }, { 0 }, { 0 }, \ + \ + { MI_INIT4(MI_STAT_COUNT_NULL) }, \ + { { 0 }, { 0 }, { 0 }, { 0 } }, \ + \ + { MI_INIT74(MI_STAT_COUNT_NULL) }, \ + { MI_INIT74(MI_STAT_COUNT_NULL) } // Empty slice span queues for every bin @@ -90,8 +89,6 @@ const mi_page_t _mi_page_empty; mi_decl_cache_align const mi_heap_t _mi_heap_empty = { NULL, - MI_SMALL_PAGES_EMPTY, - MI_PAGE_QUEUES_EMPTY, MI_ATOMIC_VAR_INIT(NULL), 0, // tid 0, // cookie @@ -100,45 +97,52 @@ mi_decl_cache_align const mi_heap_t _mi_heap_empty = { { {0}, {0}, 0, true }, // random 0, // page count MI_BIN_FULL, 0, // page retired min/max + 0, // pages_full_size + 0, 0, // generic count NULL, // next - false, - 0, - 0 + false, // can reclaim + 0, // tag + 0, // debug_offset (CPython) + false, // page_use_qsbr (CPython) + #if MI_GUARDED + 0, 0, 0, 1, // rate is 0 and count is 1 so we never write to it (see `internal.h:mi_heap_malloc_use_guarded`) + #endif + MI_SMALL_PAGES_EMPTY, + MI_PAGE_QUEUES_EMPTY }; +static mi_decl_cache_align mi_subproc_t mi_subproc_default; + #define tld_empty_stats ((mi_stats_t*)((uint8_t*)&tld_empty + offsetof(mi_tld_t,stats))) -#define tld_empty_os ((mi_os_tld_t*)((uint8_t*)&tld_empty + offsetof(mi_tld_t,os))) mi_decl_cache_align static const mi_tld_t tld_empty = { 0, false, NULL, NULL, - { MI_SEGMENT_SPAN_QUEUES_EMPTY, 0, 0, 0, 0, tld_empty_stats, tld_empty_os, &_mi_abandoned_default }, // segments - { 0, tld_empty_stats }, // os - { MI_STATS_NULL } // stats + { MI_SEGMENT_SPAN_QUEUES_EMPTY, 0, 0, 0, 0, 0, &mi_subproc_default, tld_empty_stats }, // segments + { sizeof(mi_stats_t), MI_STAT_VERSION, MI_STATS_NULL } // stats }; mi_threadid_t _mi_thread_id(void) mi_attr_noexcept { - return _mi_prim_thread_id(); + mi_threadid_t tid = _mi_prim_thread_id(); + mi_assert_internal( (tid & 0x03) == 0 ); // mimalloc reserves the bottom 2 bits + return tid; } // the thread-local default heap for allocation mi_decl_thread mi_heap_t* _mi_heap_default = (mi_heap_t*)&_mi_heap_empty; -extern mi_heap_t _mi_heap_main; +extern mi_decl_hidden mi_heap_t _mi_heap_main; -static mi_tld_t tld_main = { +static mi_decl_cache_align mi_tld_t tld_main = { 0, false, &_mi_heap_main, & _mi_heap_main, - { MI_SEGMENT_SPAN_QUEUES_EMPTY, 0, 0, 0, 0, &tld_main.stats, &tld_main.os, &_mi_abandoned_default }, // segments - { 0, &tld_main.stats }, // os - { MI_STATS_NULL } // stats + { MI_SEGMENT_SPAN_QUEUES_EMPTY, 0, 0, 0, 0, 0, &mi_subproc_default, &tld_main.stats }, // segments + { sizeof(mi_stats_t), MI_STAT_VERSION, MI_STATS_NULL } // stats }; -mi_heap_t _mi_heap_main = { +mi_decl_cache_align mi_heap_t _mi_heap_main = { &tld_main, - MI_SMALL_PAGES_EMPTY, - MI_PAGE_QUEUES_EMPTY, MI_ATOMIC_VAR_INIT(NULL), 0, // thread id 0, // initial cookie @@ -147,13 +151,61 @@ mi_heap_t _mi_heap_main = { { {0x846ca68b}, {0}, 0, true }, // random 0, // page count MI_BIN_FULL, 0, // page retired min/max + 0, // pages_full_size + 0, 0, // generic count NULL, // next heap - false // can reclaim + false, // can reclaim + 0, // tag + 0, // debug_offset (CPython) + false, // page_use_qsbr (CPython) + #if MI_GUARDED + 0, 0, 0, 0, + #endif + MI_SMALL_PAGES_EMPTY, + MI_PAGE_QUEUES_EMPTY }; bool _mi_process_is_initialized = false; // set to `true` in `mi_process_init`. -mi_stats_t _mi_stats_main = { MI_STATS_NULL }; +mi_stats_t _mi_stats_main = { sizeof(mi_stats_t), MI_STAT_VERSION, MI_STATS_NULL }; + +#if MI_GUARDED +mi_decl_export void mi_heap_guarded_set_sample_rate(mi_heap_t* heap, size_t sample_rate, size_t seed) { + heap->guarded_sample_rate = sample_rate; + heap->guarded_sample_count = sample_rate; // count down samples + if (heap->guarded_sample_rate > 1) { + if (seed == 0) { + seed = _mi_heap_random_next(heap); + } + heap->guarded_sample_count = (seed % heap->guarded_sample_rate) + 1; // start at random count between 1 and `sample_rate` + } +} + +mi_decl_export void mi_heap_guarded_set_size_bound(mi_heap_t* heap, size_t min, size_t max) { + heap->guarded_size_min = min; + heap->guarded_size_max = (min > max ? min : max); +} + +void _mi_heap_guarded_init(mi_heap_t* heap) { + mi_heap_guarded_set_sample_rate(heap, + (size_t)mi_option_get_clamp(mi_option_guarded_sample_rate, 0, LONG_MAX), + (size_t)mi_option_get(mi_option_guarded_sample_seed)); + mi_heap_guarded_set_size_bound(heap, + (size_t)mi_option_get_clamp(mi_option_guarded_min, 0, LONG_MAX), + (size_t)mi_option_get_clamp(mi_option_guarded_max, 0, LONG_MAX) ); +} +#else +mi_decl_export void mi_heap_guarded_set_sample_rate(mi_heap_t* heap, size_t sample_rate, size_t seed) { + MI_UNUSED(heap); MI_UNUSED(sample_rate); MI_UNUSED(seed); +} + +mi_decl_export void mi_heap_guarded_set_size_bound(mi_heap_t* heap, size_t min, size_t max) { + MI_UNUSED(heap); MI_UNUSED(min); MI_UNUSED(max); +} +void _mi_heap_guarded_init(mi_heap_t* heap) { + MI_UNUSED(heap); +} +#endif static void mi_heap_main_init(void) { @@ -168,6 +220,9 @@ static void mi_heap_main_init(void) { _mi_heap_main.cookie = _mi_heap_random_next(&_mi_heap_main); _mi_heap_main.keys[0] = _mi_heap_random_next(&_mi_heap_main); _mi_heap_main.keys[1] = _mi_heap_random_next(&_mi_heap_main); + mi_lock_init(&mi_subproc_default.abandoned_os_lock); + mi_lock_init(&mi_subproc_default.abandoned_os_visit_lock); + _mi_heap_guarded_init(&_mi_heap_main); } } @@ -176,6 +231,57 @@ mi_heap_t* _mi_heap_main_get(void) { return &_mi_heap_main; } +/* ----------------------------------------------------------- + Sub process +----------------------------------------------------------- */ + +mi_subproc_id_t mi_subproc_main(void) { + return NULL; +} + +mi_subproc_id_t mi_subproc_new(void) { + mi_memid_t memid = _mi_memid_none(); + mi_subproc_t* subproc = (mi_subproc_t*)_mi_arena_meta_zalloc(sizeof(mi_subproc_t), &memid); + if (subproc == NULL) return NULL; + subproc->memid = memid; + subproc->abandoned_os_list = NULL; + mi_lock_init(&subproc->abandoned_os_lock); + mi_lock_init(&subproc->abandoned_os_visit_lock); + return subproc; +} + +mi_subproc_t* _mi_subproc_from_id(mi_subproc_id_t subproc_id) { + return (subproc_id == NULL ? &mi_subproc_default : (mi_subproc_t*)subproc_id); +} + +void mi_subproc_delete(mi_subproc_id_t subproc_id) { + if (subproc_id == NULL) return; + mi_subproc_t* subproc = _mi_subproc_from_id(subproc_id); + if (subproc==NULL) return; + // check if there are no abandoned segments still.. + bool safe_to_delete = false; + mi_lock(&subproc->abandoned_os_lock) { + if (subproc->abandoned_os_list == NULL) { + safe_to_delete = true; + } + } + if (!safe_to_delete) return; + // safe to release + // todo: should we refcount subprocesses? + mi_lock_done(&subproc->abandoned_os_lock); + mi_lock_done(&subproc->abandoned_os_visit_lock); + _mi_arena_meta_free(subproc, subproc->memid, sizeof(mi_subproc_t)); +} + +void mi_subproc_add_current_thread(mi_subproc_id_t subproc_id) { + mi_heap_t* heap = mi_heap_get_default(); + if (heap == NULL) return; + mi_assert(heap->tld->segments.subproc == &mi_subproc_default); + if (heap->tld->segments.subproc != &mi_subproc_default) return; + heap->tld->segments.subproc = _mi_subproc_from_id(subproc_id); +} + + /* ----------------------------------------------------------- Initialization and freeing of the thread local heaps @@ -194,12 +300,11 @@ typedef struct mi_thread_data_s { // destroy many OS threads, this may causes too much overhead // per thread so we maintain a small cache of recently freed metadata. -#define TD_CACHE_SIZE (16) +#define TD_CACHE_SIZE (32) static _Atomic(mi_thread_data_t*) td_cache[TD_CACHE_SIZE]; static mi_thread_data_t* mi_thread_data_zalloc(void) { // try to find thread metadata in the cache - bool is_zero = false; mi_thread_data_t* td = NULL; for (int i = 0; i < TD_CACHE_SIZE; i++) { td = mi_atomic_load_ptr_relaxed(mi_thread_data_t, &td_cache[i]); @@ -207,32 +312,25 @@ static mi_thread_data_t* mi_thread_data_zalloc(void) { // found cached allocation, try use it td = mi_atomic_exchange_ptr_acq_rel(mi_thread_data_t, &td_cache[i], NULL); if (td != NULL) { - break; + _mi_memzero(td, offsetof(mi_thread_data_t,memid)); + return td; } } } // if that fails, allocate as meta data + mi_memid_t memid; + td = (mi_thread_data_t*)_mi_os_zalloc(sizeof(mi_thread_data_t), &memid); if (td == NULL) { - mi_memid_t memid; - td = (mi_thread_data_t*)_mi_os_alloc(sizeof(mi_thread_data_t), &memid, &_mi_stats_main); + // if this fails, try once more. (issue #257) + td = (mi_thread_data_t*)_mi_os_zalloc(sizeof(mi_thread_data_t), &memid); if (td == NULL) { - // if this fails, try once more. (issue #257) - td = (mi_thread_data_t*)_mi_os_alloc(sizeof(mi_thread_data_t), &memid, &_mi_stats_main); - if (td == NULL) { - // really out of memory - _mi_error_message(ENOMEM, "unable to allocate thread local heap metadata (%zu bytes)\n", sizeof(mi_thread_data_t)); - } - } - if (td != NULL) { - td->memid = memid; - is_zero = memid.initially_zero; + // really out of memory + _mi_error_message(ENOMEM, "unable to allocate thread local heap metadata (%zu bytes)\n", sizeof(mi_thread_data_t)); + return NULL; } } - - if (td != NULL && !is_zero) { - _mi_memzero_aligned(td, offsetof(mi_thread_data_t,memid)); - } + td->memid = memid; return td; } @@ -248,7 +346,7 @@ static void mi_thread_data_free( mi_thread_data_t* tdfree ) { } } // if that fails, just free it directly - _mi_os_free(tdfree, sizeof(mi_thread_data_t), tdfree->memid, &_mi_stats_main); + _mi_os_free(tdfree, sizeof(mi_thread_data_t), tdfree->memid); } void _mi_thread_data_collect(void) { @@ -258,14 +356,14 @@ void _mi_thread_data_collect(void) { if (td != NULL) { td = mi_atomic_exchange_ptr_acq_rel(mi_thread_data_t, &td_cache[i], NULL); if (td != NULL) { - _mi_os_free(td, sizeof(mi_thread_data_t), td->memid, &_mi_stats_main); + _mi_os_free(td, sizeof(mi_thread_data_t), td->memid); } } } } // Initialize the thread local default heap, called from `mi_thread_init` -static bool _mi_heap_init(void) { +static bool _mi_thread_heap_init(void) { if (mi_heap_is_initialized(mi_prim_get_default_heap())) return true; if (_mi_is_main_thread()) { // mi_assert_internal(_mi_heap_main.thread_id != 0); // can happen on freeBSD where alloc is called before any initialization @@ -279,24 +377,26 @@ static bool _mi_heap_init(void) { mi_thread_data_t* td = mi_thread_data_zalloc(); if (td == NULL) return false; - _mi_tld_init(&td->tld, &td->heap); - _mi_heap_init_ex(&td->heap, &td->tld, _mi_arena_id_none(), false, 0); - _mi_heap_set_default_direct(&td->heap); + mi_tld_t* tld = &td->tld; + mi_heap_t* heap = &td->heap; + _mi_tld_init(tld, heap); // must be before `_mi_heap_init` + _mi_heap_init(heap, tld, _mi_arena_id_none(), false /* can reclaim */, 0 /* default tag */); + _mi_heap_set_default_direct(heap); } return false; } +// initialize thread local data void _mi_tld_init(mi_tld_t* tld, mi_heap_t* bheap) { - _mi_memcpy_aligned(tld, &tld_empty, sizeof(*tld)); - tld->segments.stats = &tld->stats; - tld->segments.os = &tld->os; - tld->segments.abandoned = &_mi_abandoned_default; - tld->os.stats = &tld->stats; - tld->heap_backing = bheap; + _mi_memcpy_aligned(tld, &tld_empty, sizeof(mi_tld_t)); + tld->heap_backing = bheap; + tld->heaps = NULL; + tld->segments.subproc = &mi_subproc_default; + tld->segments.stats = &tld->stats; } // Free the thread local default heap (called from `mi_thread_done`) -static bool _mi_heap_done(mi_heap_t* heap) { +static bool _mi_thread_heap_done(mi_heap_t* heap) { if (!mi_heap_is_initialized(heap)) return true; // reset default heap @@ -330,7 +430,7 @@ static bool _mi_heap_done(mi_heap_t* heap) { // free if not the main thread if (heap != &_mi_heap_main) { // the following assertion does not always hold for huge segments as those are always treated - // as abondened: one may allocate it in one thread, but deallocate in another in which case + // as abandoned: one may allocate it in one thread, but deallocate in another in which case // the count can be too large or negative. todo: perhaps not count huge segments? see issue #363 // mi_assert_internal(heap->tld->segments.count == 0 || heap->thread_id != _mi_thread_id()); mi_thread_data_free((mi_thread_data_t*)heap); @@ -366,11 +466,10 @@ static bool _mi_heap_done(mi_heap_t* heap) { // Set up handlers so `mi_thread_done` is called automatically static void mi_process_setup_auto_thread_done(void) { - static bool tls_initialized = false; // fine if it races - if (tls_initialized) return; - tls_initialized = true; - _mi_prim_thread_init_auto_done(); - _mi_heap_set_default_direct(&_mi_heap_main); + mi_atomic_do_once { + _mi_prim_thread_init_auto_done(); + _mi_heap_set_default_direct(&_mi_heap_main); + } } @@ -393,7 +492,7 @@ void mi_thread_init(void) mi_attr_noexcept // initialize the thread local default heap // (this will call `_mi_heap_set_default_direct` and thus set the // fiber/pthread key to a non-zero value, ensuring `_mi_thread_done` is called) - if (_mi_heap_init()) return; // returns true if already initialized + if (_mi_thread_heap_init()) return; // returns true if already initialized _mi_stat_increase(&_mi_stats_main.threads, 1); mi_atomic_increment_relaxed(&thread_count); @@ -425,7 +524,7 @@ void _mi_thread_done(mi_heap_t* heap) if (heap->thread_id != _mi_thread_id()) return; // abandon the thread local heap - if (_mi_heap_done(heap)) return; // returns true if already ran + if (_mi_thread_heap_done(heap)) return; // returns true if already ran } void _mi_heap_set_default_direct(mi_heap_t* heap) { @@ -433,7 +532,7 @@ void _mi_heap_set_default_direct(mi_heap_t* heap) { #if defined(MI_TLS_SLOT) mi_prim_tls_slot_set(MI_TLS_SLOT,heap); #elif defined(MI_TLS_PTHREAD_SLOT_OFS) - *mi_tls_pthread_heap_slot() = heap; + *mi_prim_tls_pthread_heap_slot() = heap; #elif defined(MI_TLS_PTHREAD) // we use _mi_heap_default_key #else @@ -445,58 +544,27 @@ void _mi_heap_set_default_direct(mi_heap_t* heap) { _mi_prim_thread_associate_default_heap(heap); } +void mi_thread_set_in_threadpool(void) mi_attr_noexcept { + // nothing +} // -------------------------------------------------------- // Run functions on process init/done, and thread init/done // -------------------------------------------------------- -static void mi_cdecl mi_process_done(void); - static bool os_preloading = true; // true until this module is initialized -static bool mi_redirected = false; // true if malloc redirects to mi_malloc // Returns true if this module has not been initialized; Don't use C runtime routines until it returns false. bool mi_decl_noinline _mi_preloading(void) { return os_preloading; } +// Returns true if mimalloc was redirected mi_decl_nodiscard bool mi_is_redirected(void) mi_attr_noexcept { - return mi_redirected; -} - -// Communicate with the redirection module on Windows -#if defined(_WIN32) && defined(MI_SHARED_LIB) && !defined(MI_WIN_NOREDIRECT) -#ifdef __cplusplus -extern "C" { -#endif -mi_decl_export void _mi_redirect_entry(DWORD reason) { - // called on redirection; careful as this may be called before DllMain - if (reason == DLL_PROCESS_ATTACH) { - mi_redirected = true; - } - else if (reason == DLL_PROCESS_DETACH) { - mi_redirected = false; - } - else if (reason == DLL_THREAD_DETACH) { - mi_thread_done(); - } -} -__declspec(dllimport) bool mi_cdecl mi_allocator_init(const char** message); -__declspec(dllimport) void mi_cdecl mi_allocator_done(void); -#ifdef __cplusplus -} -#endif -#else -static bool mi_allocator_init(const char** message) { - if (message != NULL) *message = NULL; - return true; -} -static void mi_allocator_done(void) { - // nothing to do + return _mi_is_redirected(); } -#endif -// Called once by the process loader -static void mi_process_load(void) { +// Called once by the process loader from `src/prim/prim.c` +void _mi_auto_process_init(void) { mi_heap_main_init(); #if defined(__APPLE__) || defined(MI_TLS_RECURSE_GUARD) volatile mi_heap_t* dummy = _mi_heap_default; // access TLS to allocate it before setting tls_initialized to true; @@ -504,17 +572,14 @@ static void mi_process_load(void) { #endif os_preloading = false; mi_assert_internal(_mi_is_main_thread()); - #if !(defined(_WIN32) && defined(MI_SHARED_LIB)) // use Dll process detach (see below) instead of atexit (issue #521) - atexit(&mi_process_done); - #endif _mi_options_init(); mi_process_setup_auto_thread_done(); mi_process_init(); - if (mi_redirected) _mi_verbose_message("malloc is redirected.\n"); + if (_mi_is_redirected()) _mi_verbose_message("malloc is redirected.\n"); // show message from the redirector (if present) const char* msg = NULL; - mi_allocator_init(&msg); + _mi_allocator_init(&msg); if (msg != NULL && (mi_option_is_enabled(mi_option_verbose) || mi_option_is_enabled(mi_option_show_errors))) { _mi_fputs(NULL,NULL,NULL,msg); } @@ -526,12 +591,15 @@ static void mi_process_load(void) { #if defined(_WIN32) && (defined(_M_IX86) || defined(_M_X64)) #include mi_decl_cache_align bool _mi_cpu_has_fsrm = false; +mi_decl_cache_align bool _mi_cpu_has_erms = false; static void mi_detect_cpu_features(void) { - // FSRM for fast rep movsb support (AMD Zen3+ (~2020) or Intel Ice Lake+ (~2017)) + // FSRM for fast short rep movsb/stosb support (AMD Zen3+ (~2020) or Intel Ice Lake+ (~2017)) + // EMRS for fast enhanced rep movsb/stosb support int32_t cpu_info[4]; __cpuid(cpu_info, 7); _mi_cpu_has_fsrm = ((cpu_info[3] & (1 << 4)) != 0); // bit 4 of EDX : see + _mi_cpu_has_erms = ((cpu_info[1] & (1 << 9)) != 0); // bit 9 of EBX : see } #else static void mi_detect_cpu_features(void) { @@ -540,13 +608,7 @@ static void mi_detect_cpu_features(void) { #endif // Initialize the process; called by thread_init or the process loader -void mi_process_init(void) mi_attr_noexcept { - // ensure we are called once - static mi_atomic_once_t process_init; - #if _MSC_VER < 1920 - mi_heap_main_init(); // vs2017 can dynamically re-initialize _mi_heap_main - #endif - if (!mi_atomic_once(&process_init)) return; +static void mi_process_init_once(void) mi_attr_noexcept { _mi_process_is_initialized = true; _mi_verbose_message("process init: 0x%zx\n", _mi_thread_id()); mi_process_setup_auto_thread_done(); @@ -554,14 +616,6 @@ void mi_process_init(void) mi_attr_noexcept { mi_detect_cpu_features(); _mi_os_init(); mi_heap_main_init(); - #if MI_DEBUG - _mi_verbose_message("debug level : %d\n", MI_DEBUG); - #endif - _mi_verbose_message("secure level: %d\n", MI_SECURE); - _mi_verbose_message("mem tracking: %s\n", MI_TRACK_TOOL); - #if MI_TSAN - _mi_verbose_message("thread sanitizer enabled\n"); - #endif mi_thread_init(); #if defined(_WIN32) @@ -576,7 +630,7 @@ void mi_process_init(void) mi_attr_noexcept { if (mi_option_is_enabled(mi_option_reserve_huge_os_pages)) { size_t pages = mi_option_get_clamp(mi_option_reserve_huge_os_pages, 0, 128*1024); - long reserve_at = mi_option_get(mi_option_reserve_huge_os_pages_at); + int reserve_at = (int)mi_option_get_clamp(mi_option_reserve_huge_os_pages_at, -1, INT_MAX); if (reserve_at != -1) { mi_reserve_huge_os_pages_at(pages, reserve_at, pages*500); } else { @@ -591,8 +645,19 @@ void mi_process_init(void) mi_attr_noexcept { } } -// Called when the process is done (through `at_exit`) -static void mi_cdecl mi_process_done(void) { +// Initialize the process; called by thread_init or the process loader +void mi_process_init(void) mi_attr_noexcept { + #if _MSC_VER < 1920 + mi_heap_main_init(); // vs2017 can dynamically re-initialize _mi_heap_main + #endif + mi_atomic_do_once { + mi_process_init_once(); + } +} + + +// Called when the process is done +static void mi_process_done_once(void) { // only shutdown if we were initialized if (!_mi_process_is_initialized) return; // ensure we are called once @@ -600,88 +665,53 @@ static void mi_cdecl mi_process_done(void) { if (process_done) return; process_done = true; + // get the default heap so we don't need to acces thread locals anymore + mi_heap_t* heap = mi_prim_get_default_heap(); // use prim to not initialize any heap + mi_assert_internal(heap != NULL); + // release any thread specific resources and ensure _mi_thread_done is called on all but the main thread _mi_prim_thread_done_auto_done(); + #ifndef MI_SKIP_COLLECT_ON_EXIT #if (MI_DEBUG || !defined(MI_SHARED_LIB)) // free all memory if possible on process exit. This is not needed for a stand-alone process // but should be done if mimalloc is statically linked into another shared library which // is repeatedly loaded/unloaded, see issue #281. - mi_collect(true /* force */ ); + mi_heap_collect(heap, true /* force */ ); #endif #endif + // done with tracking tools + mi_track_done(); + // Forcefully release all retained memory; this can be dangerous in general if overriding regular malloc/free // since after process_done there might still be other code running that calls `free` (like at_exit routines, // or C-runtime termination code. if (mi_option_is_enabled(mi_option_destroy_on_exit)) { - mi_collect(true /* force */); - _mi_heap_unsafe_destroy_all(); // forcefully release all memory held by all heaps (of this thread only!) - _mi_arena_unsafe_destroy_all(& _mi_heap_main_get()->tld->stats); + mi_heap_collect(heap, true /* force */); + _mi_heap_unsafe_destroy_all(heap); // forcefully release all memory held by all heaps (of this thread only!) + _mi_arena_unsafe_destroy_all(); + _mi_segment_map_unsafe_destroy(); } if (mi_option_is_enabled(mi_option_show_stats) || mi_option_is_enabled(mi_option_verbose)) { mi_stats_print(NULL); } - mi_allocator_done(); + _mi_allocator_done(); _mi_verbose_message("process done: 0x%zx\n", _mi_heap_main.thread_id); os_preloading = true; // don't call the C runtime anymore } - -#if defined(_WIN32) && defined(MI_SHARED_LIB) - // Windows DLL: easy to hook into process_init and thread_done - __declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) { - MI_UNUSED(reserved); - MI_UNUSED(inst); - if (reason==DLL_PROCESS_ATTACH) { - mi_process_load(); - } - else if (reason==DLL_PROCESS_DETACH) { - mi_process_done(); - } - else if (reason==DLL_THREAD_DETACH) { - if (!mi_is_redirected()) { - mi_thread_done(); - } - } - return TRUE; - } - -#elif defined(_MSC_VER) - // MSVC: use data section magic for static libraries - // See - static int _mi_process_init(void) { - mi_process_load(); - return 0; - } - typedef int(*_mi_crt_callback_t)(void); - #if defined(_M_X64) || defined(_M_ARM64) - __pragma(comment(linker, "/include:" "_mi_msvc_initu")) - #pragma section(".CRT$XIU", long, read) - #else - __pragma(comment(linker, "/include:" "__mi_msvc_initu")) - #endif - #pragma data_seg(".CRT$XIU") - mi_decl_externc _mi_crt_callback_t _mi_msvc_initu[] = { &_mi_process_init }; - #pragma data_seg() - -#elif defined(__cplusplus) - // C++: use static initialization to detect process start - static bool _mi_process_init(void) { - mi_process_load(); - return (_mi_heap_main.thread_id != 0); - } - static bool mi_initialized = _mi_process_init(); - -#elif defined(__GNUC__) || defined(__clang__) - // GCC,Clang: use the constructor attribute - static void __attribute__((constructor)) _mi_process_init(void) { - mi_process_load(); +// Called when the process is done (cdecl as it is used with `at_exit` on some platforms) +void mi_cdecl mi_process_done(void) mi_attr_noexcept { + mi_atomic_do_once { + mi_process_done_once(); } +} -#else -#pragma message("define a way to call mi_process_load on your platform") -#endif +void mi_cdecl _mi_auto_process_done(void) mi_attr_noexcept { + if (_mi_option_get_fast(mi_option_destroy_on_exit)>1) return; + mi_process_done(); +} diff --git a/Objects/mimalloc/libc.c b/Objects/mimalloc/libc.c new file mode 100644 index 000000000000000..9dff88c5a4c189c --- /dev/null +++ b/Objects/mimalloc/libc.c @@ -0,0 +1,383 @@ +/* ---------------------------------------------------------------------------- +Copyright (c) 2018-2023, Microsoft Research, Daan Leijen +This is free software; you can redistribute it and/or modify it under the +terms of the MIT license. A copy of the license can be found in the file +"LICENSE" at the root of this distribution. +-----------------------------------------------------------------------------*/ + +// -------------------------------------------------------- +// This module defines various std libc functions to reduce +// the dependency on libc, and also prevent errors caused +// by some libc implementations when called before `main` +// executes (due to malloc redirection) +// -------------------------------------------------------- + +#include "mimalloc.h" +#include "mimalloc/internal.h" +#include "mimalloc/prim.h" // mi_prim_getenv + +char _mi_toupper(char c) { + if (c >= 'a' && c <= 'z') return (c - 'a' + 'A'); + else return c; +} + +int _mi_strnicmp(const char* s, const char* t, size_t n) { + mi_assert_internal(s!=NULL && t!=NULL); + if (n == 0) return 0; + for (; *s != 0 && *t != 0 && n > 0; s++, t++, n--) { + if (_mi_toupper(*s) != _mi_toupper(*t)) break; + } + return (n == 0 ? 0 : *s - *t); +} + +bool _mi_streq(const char* s, const char* t) { + if (s==NULL && t==NULL) return true; + if (s==NULL || t==NULL) return false; + for (; *s != 0 && *t != 0; s++, t++) { + if (*s != *t) break; + } + return (*s == *t); +} + +bool _mi_strlcpy(char* dest, const char* src, size_t dest_size) { + if (dest==NULL || src==NULL || dest_size == 0) return (src==NULL || *src==0); + // copy until end of src, or when dest is (almost) full + while (*src != 0 && dest_size > 1) { + *dest++ = *src++; + dest_size--; + } + // always zero terminate + *dest = 0; + return (*src == 0); +} + +bool _mi_strlcat(char* dest, const char* src, size_t dest_size) { + if (dest==NULL || src==NULL || dest_size == 0) return (src==NULL || *src==0); + // find end of string in the dest buffer + while (*dest != 0 && dest_size > 1) { + dest++; + dest_size--; + } + // and catenate + return _mi_strlcpy(dest, src, dest_size); +} + +size_t _mi_strnlen(const char* s, size_t max_len) { + if (s==NULL) return 0; + size_t len = 0; + while(len < max_len && s[len] != 0) { len++; } + return len; +} + +size_t _mi_strlen(const char* s) { + return _mi_strnlen(s,PTRDIFF_MAX); +} + +#ifdef MI_NO_GETENV +int _mi_getenv(const char* name, char* result, size_t result_size) { + MI_UNUSED(name); + MI_UNUSED(result); + MI_UNUSED(result_size); + return ENOENT; +} +#else +int _mi_getenv(const char* name, char* result, size_t result_size) { + if (name==NULL || result == NULL || result_size < 64) return ENOENT; + // change the result of _mi_prim_getenv to an errno result + const int res = _mi_prim_getenv(name,result,result_size); + return (res > 0 ? 0 : (res == 0 ? ENOENT : EAGAIN)); +} +#endif + + +// -------------------------------------------------------- +// Define our own primitives for doing an action once +// -------------------------------------------------------- + +// Returns `true` only on the first invocation, signifying we can execute an action once. +// If it returns `true`, the caller should call `_mi_atomic_once_release` after performing the action. +// Other threads (than the initial thread that entered) will block until `_mi_atomic_once_release` has been called. +bool _mi_atomic_once_enter(mi_atomic_once_t* once) { + const uintptr_t once_tid = mi_atomic_load_acquire(&once->tid); + if mi_likely(once_tid == 1) { + return false; // already executed + } + const mi_threadid_t current_tid = _mi_thread_id(); + if (once_tid == current_tid) { + return false; // recursive invocation; we need this for process_init for example + } + + mi_lock_acquire(&once->lock); + uintptr_t expected = 0; + if (mi_atomic_cas_strong_acq_rel(&once->tid, &expected, current_tid)) { // could use atomic_load/store as well + return true; // should execute and release + } + else { + mi_lock_release(&once->lock); + return false; // already another thread entered and released + } +} + +void _mi_atomic_once_release(mi_atomic_once_t* once) { + if (mi_atomic_load_acquire(&once->tid)>1) { // paranoia + mi_atomic_store_release(&once->tid,1); // done executing + mi_lock_release(&once->lock); + } +} + + +// -------------------------------------------------------- +// Define our own limited `_mi_vsnprintf` and `_mi_snprintf` +// This is mostly to avoid calling these when libc is not yet +// initialized (and to reduce dependencies) +// +// format: d i, p x u, s +// prec: z l ll L +// width: 10 +// align-left: - +// fill: 0 +// plus: + +// -------------------------------------------------------- + +static void mi_outc(char c, char** out, char* end) { + char* p = *out; + if (p >= end) return; + *p = c; + *out = p + 1; +} + +static void mi_outs(const char* s, char** out, char* end) { + if (s == NULL) return; + char* p = *out; + while (*s != 0 && p < end) { + *p++ = *s++; + } + *out = p; +} + +static void mi_out_fill(char fill, size_t len, char** out, char* end) { + char* p = *out; + for (size_t i = 0; i < len && p < end; i++) { + *p++ = fill; + } + *out = p; +} + +static void mi_out_alignright(char fill, char* start, size_t len, size_t extra, char* end) { + if (len == 0 || extra == 0) return; + if (start + len + extra >= end) return; + // move `len` characters to the right (in reverse since it can overlap) + for (size_t i = 1; i <= len; i++) { + start[len + extra - i] = start[len - i]; + } + // and fill the start + for (size_t i = 0; i < extra; i++) { + start[i] = fill; + } +} + + +static void mi_out_num(uintmax_t x, size_t base, char prefix, char** out, char* end) +{ + if (x == 0 || base == 0 || base > 16) { + if (prefix != 0) { mi_outc(prefix, out, end); } + mi_outc('0',out,end); + } + else { + #define MI_MAX_OUT_DIGITS (160) /* a 512 bit number has 155 digits */ + char num[MI_MAX_OUT_DIGITS]; + int dcount = 0; + while(x>0 && dcount < MI_MAX_OUT_DIGITS) { + char digit = (char)(x % base); + num[dcount++] = (digit <= 9 ? '0' + digit : 'A' + digit - 10); + x = x / base; + } + if (dcount>=MI_MAX_OUT_DIGITS) return; // don't output anything? + if (prefix != 0) { + mi_outc(prefix, out, end); + } + while(dcount-- > 0) { + mi_outc(num[dcount], out, end); + } + } +} + + +#define MI_NEXTC() c = *in; if (c==0) break; in++; + +int _mi_vsnprintf(char* buf, size_t bufsize, const char* fmt, va_list args) { + if (buf == NULL || bufsize == 0 || fmt == NULL) return 0; + buf[bufsize - 1] = 0; + char* const end = buf + (bufsize - 1); + const char* in = fmt; + char* out = buf; + while (true) { + if (out >= end) break; + char c; + MI_NEXTC(); + if (c != '%') { + if ((c >= ' ' && c <= '~') || c=='\n' || c=='\r' || c=='\t') { // output visible ascii or standard control only + mi_outc(c, &out, end); + } + } + else { + MI_NEXTC(); + char fill = ' '; + size_t width = 0; + char numtype = 'd'; + char numplus = 0; + bool alignright = true; + if (c == '+' || c == ' ') { numplus = c; MI_NEXTC(); } + if (c == '-') { alignright = false; MI_NEXTC(); } + if (c == '0') { fill = '0'; MI_NEXTC(); } + if (c >= '1' && c <= '9') { + width = (c - '0'); MI_NEXTC(); + while (c >= '0' && c <= '9') { + if (width < SIZE_MAX/1024) { // no overflow + width = (10 * width) + (c - '0'); + } + MI_NEXTC(); + } + if (c == 0) break; // extra check due to while + } + if (c == 'z' || c == 't' || c == 'L') { numtype = c; MI_NEXTC(); } + else if (c == 'l') { + numtype = c; MI_NEXTC(); + if (c == 'l') { numtype = 'L'; MI_NEXTC(); } + } + + char* start = out; + if (c == 's') { + // string + const char* s = va_arg(args, const char*); + mi_outs(s, &out, end); + } + else if (c == 'p' || c == 'x' || c == 'u') { + // unsigned + uintmax_t x = 0; + if (c == 'x' || c == 'u') { + if (numtype == 'z') x = va_arg(args, size_t); + else if (numtype == 't') x = va_arg(args, uintptr_t); // unsigned ptrdiff_t + else if (numtype == 'L') x = va_arg(args, unsigned long long); + else if (numtype == 'l') x = va_arg(args, unsigned long); + else x = va_arg(args, unsigned int); + } + else if (c == 'p') { + void* const p = va_arg(args, void*); + x = (uintptr_t)p; + mi_outs("0x", &out, end); + start = out; + width = (width >= 2 ? width - 2 : 0); + } + if (width == 0 && (c == 'x' || c == 'p')) { + if (c == 'p') { width = 2 * (x <= UINT32_MAX ? 4 : ((x >> 16) <= UINT32_MAX ? 6 : sizeof(void*))); } + if (width == 0) { width = 2; } + if (alignright) { fill = '0'; } + } + mi_out_num(x, (c == 'x' || c == 'p' ? 16 : 10), numplus, &out, end); + } + else if (c == 'i' || c == 'd') { + // signed + intmax_t x = 0; + if (numtype == 'z') x = va_arg(args, intptr_t ); + else if (numtype == 't') x = va_arg(args, ptrdiff_t); + else if (numtype == 'L') x = va_arg(args, long long); + else if (numtype == 'l') x = va_arg(args, long); + else x = va_arg(args, int); + char pre = 0; + if (x < 0) { + pre = '-'; + if (x > INTMAX_MIN) { x = -x; } + } + else if (numplus != 0) { + pre = numplus; + } + mi_out_num((uintmax_t)x, 10, pre, &out, end); + } + else if (c >= ' ' && c <= '~') { + // unknown format + mi_outc('%', &out, end); + mi_outc(c, &out, end); + } + + // fill & align + mi_assert_internal(out <= end); + mi_assert_internal(out >= start); + const size_t len = out - start; + if (len < width) { + mi_out_fill(fill, width - len, &out, end); + if (alignright && out <= end) { + mi_out_alignright(fill, start, len, width - len, end); + } + } + } + } + mi_assert_internal(out <= end); + *out = 0; + return (int)(out - buf); +} + +int _mi_snprintf(char* buf, size_t buflen, const char* fmt, ...) { + va_list args; + va_start(args, fmt); + const int written = _mi_vsnprintf(buf, buflen, fmt, args); + va_end(args); + return written; +} + + +#if MI_SIZE_SIZE == 4 +#define mi_mask_even_bits32 (0x55555555) +#define mi_mask_even_pairs32 (0x33333333) +#define mi_mask_even_nibbles32 (0x0F0F0F0F) + +// sum of all the bytes in `x` if it is guaranteed that the sum < 256! +static size_t mi_byte_sum32(uint32_t x) { + // perform `x * 0x01010101`: the highest byte contains the sum of all bytes. + x += (x << 8); + x += (x << 16); + return (size_t)(x >> 24); +} + +static size_t mi_popcount_generic32(uint32_t x) { + // first count each 2-bit group `a`, where: a==0b00 -> 00, a==0b01 -> 01, a==0b10 -> 01, a==0b11 -> 10 + // in other words, `a - (a>>1)`; to do this in parallel, we need to mask to prevent spilling a bit pair + // into the lower bit-pair: + x = x - ((x >> 1) & mi_mask_even_bits32); + // add the 2-bit pair results + x = (x & mi_mask_even_pairs32) + ((x >> 2) & mi_mask_even_pairs32); + // add the 4-bit nibble results + x = (x + (x >> 4)) & mi_mask_even_nibbles32; + // each byte now has a count of its bits, we can sum them now: + return mi_byte_sum32(x); +} + +mi_decl_noinline size_t _mi_popcount_generic(size_t x) { + return mi_popcount_generic32(x); +} + +#else +#define mi_mask_even_bits64 (0x5555555555555555) +#define mi_mask_even_pairs64 (0x3333333333333333) +#define mi_mask_even_nibbles64 (0x0F0F0F0F0F0F0F0F) + +// sum of all the bytes in `x` if it is guaranteed that the sum < 256! +static size_t mi_byte_sum64(uint64_t x) { + x += (x << 8); + x += (x << 16); + x += (x << 32); + return (size_t)(x >> 56); +} + +static size_t mi_popcount_generic64(uint64_t x) { + x = x - ((x >> 1) & mi_mask_even_bits64); + x = (x & mi_mask_even_pairs64) + ((x >> 2) & mi_mask_even_pairs64); + x = (x + (x >> 4)) & mi_mask_even_nibbles64; + return mi_byte_sum64(x); +} + +mi_decl_noinline size_t _mi_popcount_generic(size_t x) { + return mi_popcount_generic64(x); +} +#endif + diff --git a/Objects/mimalloc/options.c b/Objects/mimalloc/options.c index 2a8f481d569e1ed..d139e57f2c8f9cd 100644 --- a/Objects/mimalloc/options.c +++ b/Objects/mimalloc/options.c @@ -9,9 +9,9 @@ terms of the MIT license. A copy of the license can be found in the file #include "mimalloc/atomic.h" #include "mimalloc/prim.h" // mi_prim_out_stderr -#include // FILE +#include // stdin/stdout #include // abort -#include + static long mi_max_error_count = 16; // stop outputting errors after this (use < 0 for no limit) @@ -47,6 +47,67 @@ typedef struct mi_option_desc_s { #define MI_OPTION(opt) mi_option_##opt, #opt, NULL #define MI_OPTION_LEGACY(opt,legacy) mi_option_##opt, #opt, #legacy +// Some options can be set at build time for statically linked libraries +// (use `-DMI_EXTRA_CPPDEFS="opt1=val1;opt2=val2"`) +// +// This is useful if we cannot pass them as environment variables +// (and setting them programmatically would be too late) + +#ifndef MI_DEFAULT_VERBOSE +#define MI_DEFAULT_VERBOSE 0 +#endif + +#ifndef MI_DEFAULT_EAGER_COMMIT +#define MI_DEFAULT_EAGER_COMMIT 1 +#endif + +#ifndef MI_DEFAULT_ARENA_EAGER_COMMIT +#define MI_DEFAULT_ARENA_EAGER_COMMIT 2 +#endif + +// in KiB +#ifndef MI_DEFAULT_ARENA_RESERVE + #if (MI_INTPTR_SIZE>4) + #define MI_DEFAULT_ARENA_RESERVE 1024L*1024L + #else + #define MI_DEFAULT_ARENA_RESERVE 128L*1024L + #endif +#endif + +#ifndef MI_DEFAULT_DISALLOW_ARENA_ALLOC +#define MI_DEFAULT_DISALLOW_ARENA_ALLOC 0 +#endif + +#ifndef MI_DEFAULT_ALLOW_LARGE_OS_PAGES +#define MI_DEFAULT_ALLOW_LARGE_OS_PAGES 0 +#endif + +#ifndef MI_DEFAULT_RESERVE_HUGE_OS_PAGES +#define MI_DEFAULT_RESERVE_HUGE_OS_PAGES 0 +#endif + +#ifndef MI_DEFAULT_RESERVE_OS_MEMORY +#define MI_DEFAULT_RESERVE_OS_MEMORY 0 +#endif + +#ifndef MI_DEFAULT_GUARDED_SAMPLE_RATE +#if MI_GUARDED && !MI_DEBUG +#define MI_DEFAULT_GUARDED_SAMPLE_RATE 4000 +#else +#define MI_DEFAULT_GUARDED_SAMPLE_RATE 0 +#endif +#endif + + +#ifndef MI_DEFAULT_ALLOW_THP +#if defined(__ANDROID__) +#define MI_DEFAULT_ALLOW_THP 0 +#else +#define MI_DEFAULT_ALLOW_THP 1 +#endif +#endif + +// Static options static mi_option_desc_t options[_mi_option_last] = { // stable options @@ -56,16 +117,21 @@ static mi_option_desc_t options[_mi_option_last] = { 0, UNINIT, MI_OPTION(show_errors) }, #endif { 0, UNINIT, MI_OPTION(show_stats) }, - { 0, UNINIT, MI_OPTION(verbose) }, + { MI_DEFAULT_VERBOSE, UNINIT, MI_OPTION(verbose) }, - // the following options are experimental and not all combinations make sense. - { 1, UNINIT, MI_OPTION(eager_commit) }, // commit per segment directly (4MiB) (but see also `eager_commit_delay`) - { 2, UNINIT, MI_OPTION_LEGACY(arena_eager_commit,eager_region_commit) }, // eager commit arena's? 2 is used to enable this only on an OS that has overcommit (i.e. linux) + // some of the following options are experimental and not all combinations are allowed. + { MI_DEFAULT_EAGER_COMMIT, + UNINIT, MI_OPTION(eager_commit) }, // commit per segment directly (4MiB) (but see also `eager_commit_delay`) + { MI_DEFAULT_ARENA_EAGER_COMMIT, + UNINIT, MI_OPTION_LEGACY(arena_eager_commit,eager_region_commit) }, // eager commit arena's? 2 is used to enable this only on an OS that has overcommit (i.e. linux) { 1, UNINIT, MI_OPTION_LEGACY(purge_decommits,reset_decommits) }, // purge decommits memory (instead of reset) (note: on linux this uses MADV_DONTNEED for decommit) - { 0, UNINIT, MI_OPTION_LEGACY(allow_large_os_pages,large_os_pages) }, // use large OS pages, use only with eager commit to prevent fragmentation of VMA's - { 0, UNINIT, MI_OPTION(reserve_huge_os_pages) }, // per 1GiB huge pages + { MI_DEFAULT_ALLOW_LARGE_OS_PAGES, + UNINIT, MI_OPTION_LEGACY(allow_large_os_pages,large_os_pages) }, // use large OS pages, use only with eager commit to prevent fragmentation of VMA's + { MI_DEFAULT_RESERVE_HUGE_OS_PAGES, + UNINIT, MI_OPTION(reserve_huge_os_pages) }, // per 1GiB huge pages {-1, UNINIT, MI_OPTION(reserve_huge_os_pages_at) }, // reserve huge pages at node N - { 0, UNINIT, MI_OPTION(reserve_os_memory) }, + { MI_DEFAULT_RESERVE_OS_MEMORY, + UNINIT, MI_OPTION(reserve_os_memory) }, // reserve N KiB OS memory in advance (use `option_get_size`) { 0, UNINIT, MI_OPTION(deprecated_segment_cache) }, // cache N segments per thread { 0, UNINIT, MI_OPTION(deprecated_page_reset) }, // reset page memory on free { 0, UNINIT, MI_OPTION_LEGACY(abandoned_page_purge,abandoned_page_reset) }, // reset free page memory when a thread terminates @@ -77,40 +143,113 @@ static mi_option_desc_t options[_mi_option_last] = #endif { 10, UNINIT, MI_OPTION_LEGACY(purge_delay,reset_delay) }, // purge delay in milli-seconds { 0, UNINIT, MI_OPTION(use_numa_nodes) }, // 0 = use available numa nodes, otherwise use at most N nodes. - { 0, UNINIT, MI_OPTION(limit_os_alloc) }, // 1 = do not use OS memory for allocation (but only reserved arenas) + { 0, UNINIT, MI_OPTION_LEGACY(disallow_os_alloc,limit_os_alloc) }, // 1 = do not use OS memory for allocation (but only reserved arenas) { 100, UNINIT, MI_OPTION(os_tag) }, // only apple specific for now but might serve more or less related purpose - { 16, UNINIT, MI_OPTION(max_errors) }, // maximum errors that are output - { 16, UNINIT, MI_OPTION(max_warnings) }, // maximum warnings that are output - { 8, UNINIT, MI_OPTION(max_segment_reclaim)}, // max. number of segment reclaims from the abandoned segments per try. + { 32, UNINIT, MI_OPTION(max_errors) }, // maximum errors that are output + { 32, UNINIT, MI_OPTION(max_warnings) }, // maximum warnings that are output + { 10, UNINIT, MI_OPTION(max_segment_reclaim)}, // max. percentage of the abandoned segments to be reclaimed per try. { 0, UNINIT, MI_OPTION(destroy_on_exit)}, // release all OS memory on process exit; careful with dangling pointer or after-exit frees! - #if (MI_INTPTR_SIZE>4) - { 1024L * 1024L, UNINIT, MI_OPTION(arena_reserve) }, // reserve memory N KiB at a time - #else - { 128L * 1024L, UNINIT, MI_OPTION(arena_reserve) }, - #endif - { 10, UNINIT, MI_OPTION(arena_purge_mult) }, // purge delay multiplier for arena's + { MI_DEFAULT_ARENA_RESERVE, UNINIT, MI_OPTION(arena_reserve) }, // reserve memory N KiB at a time (=1GiB) (use `option_get_size`) + { 10, UNINIT, MI_OPTION(arena_purge_mult) }, // purge delay multiplier for arena's { 1, UNINIT, MI_OPTION_LEGACY(purge_extend_delay, decommit_extend_delay) }, + { 0, UNINIT, MI_OPTION(abandoned_reclaim_on_free) },// reclaim an abandoned segment on a free + { MI_DEFAULT_DISALLOW_ARENA_ALLOC, UNINIT, MI_OPTION(disallow_arena_alloc) }, // 1 = do not use arena's for allocation (except if using specific arena id's) + { 400, UNINIT, MI_OPTION(retry_on_oom) }, // windows only: retry on out-of-memory for N milli seconds (=400), set to 0 to disable retries. +#if defined(MI_VISIT_ABANDONED) + { 1, INITIALIZED, MI_OPTION(visit_abandoned) }, // allow visiting heap blocks in abandoned segments; requires taking locks during reclaim. +#else + { 0, UNINIT, MI_OPTION(visit_abandoned) }, +#endif + { 0, UNINIT, MI_OPTION(guarded_min) }, // only used when building with MI_GUARDED: minimal rounded object size for guarded objects + { MI_GiB, UNINIT, MI_OPTION(guarded_max) }, // only used when building with MI_GUARDED: maximal rounded object size for guarded objects + { 0, UNINIT, MI_OPTION(guarded_precise) }, // disregard minimal alignment requirement to always place guarded blocks exactly in front of a guard page (=0) + { MI_DEFAULT_GUARDED_SAMPLE_RATE, + UNINIT, MI_OPTION(guarded_sample_rate)}, // 1 out of N allocations in the min/max range will be guarded (=4000) + { 0, UNINIT, MI_OPTION(guarded_sample_seed)}, + { 0, UNINIT, MI_OPTION(target_segments_per_thread) }, // abandon segments beyond this point, or 0 to disable. + { 10000, UNINIT, MI_OPTION(generic_collect) }, // collect heaps every N (=10000) generic allocation calls + { MI_DEFAULT_ALLOW_THP, + UNINIT, MI_OPTION(allow_thp) } // allow transparent huge pages? }; static void mi_option_init(mi_option_desc_t* desc); +static bool mi_option_has_size_in_kib(mi_option_t option) { + return (option == mi_option_reserve_os_memory || option == mi_option_arena_reserve); +} + void _mi_options_init(void) { - // called on process load; should not be called before the CRT is initialized! - // (e.g. do not call this from process_init as that may run before CRT initialization) + // called on process load mi_add_stderr_output(); // now it safe to use stderr for output for(int i = 0; i < _mi_option_last; i++ ) { mi_option_t option = (mi_option_t)i; long l = mi_option_get(option); MI_UNUSED(l); // initialize - // if (option != mi_option_verbose) - { - mi_option_desc_t* desc = &options[option]; - _mi_verbose_message("option '%s': %ld\n", desc->name, desc->value); - } } mi_max_error_count = mi_option_get(mi_option_max_errors); mi_max_warning_count = mi_option_get(mi_option_max_warnings); + #if MI_GUARDED + if (mi_option_get(mi_option_guarded_sample_rate) > 0) { + if (mi_option_is_enabled(mi_option_allow_large_os_pages)) { + mi_option_disable(mi_option_allow_large_os_pages); + _mi_warning_message("option 'allow_large_os_pages' is disabled to allow for guarded objects\n"); + } + } + #endif + if (mi_option_is_enabled(mi_option_verbose)) { mi_options_print(); } } +#define mi_stringifyx(str) #str // and stringify +#define mi_stringify(str) mi_stringifyx(str) // expand + +void mi_options_print(void) mi_attr_noexcept +{ + // show version + const int vermajor = MI_MALLOC_VERSION/10000; + const int verminor = (MI_MALLOC_VERSION%10000)/100; + const int verpatch = (MI_MALLOC_VERSION%100); + _mi_message("v%i.%i.%i%s%s\n", vermajor, verminor, verpatch, + #if defined(MI_CMAKE_BUILD_TYPE) + ", " mi_stringify(MI_CMAKE_BUILD_TYPE) + #else + "" + #endif + , + #if defined(MI_GIT_DESCRIBE) + ", git " mi_stringify(MI_GIT_DESCRIBE) + #else + "" + #endif + ); + + // show options + for (int i = 0; i < _mi_option_last; i++) { + mi_option_t option = (mi_option_t)i; + long l = mi_option_get(option); MI_UNUSED(l); // possibly initialize + mi_option_desc_t* desc = &options[option]; + _mi_message("option '%s': %ld %s\n", desc->name, desc->value, (mi_option_has_size_in_kib(option) ? "KiB" : "")); + } + + // show build configuration + _mi_message("debug level : %d\n", MI_DEBUG ); + _mi_message("secure level: %d\n", MI_SECURE ); + _mi_message("mem tracking: %s\n", MI_TRACK_TOOL); + #if MI_GUARDED + _mi_message("guarded build: %s\n", mi_option_get(mi_option_guarded_sample_rate) != 0 ? "enabled" : "disabled"); + #endif + #if MI_TSAN + _mi_message("thread santizer enabled\n"); + #endif +} + +long _mi_option_get_fast(mi_option_t option) { + mi_assert(option >= 0 && option < _mi_option_last); + mi_option_desc_t* desc = &options[option]; + mi_assert(desc->option == option); // index should match the option + //mi_assert(desc->init != UNINIT); + return desc->value; +} + + mi_decl_nodiscard long mi_option_get(mi_option_t option) { mi_assert(option >= 0 && option < _mi_option_last); if (option < 0 || option >= _mi_option_last) return 0; @@ -128,9 +267,14 @@ mi_decl_nodiscard long mi_option_get_clamp(mi_option_t option, long min, long ma } mi_decl_nodiscard size_t mi_option_get_size(mi_option_t option) { - mi_assert_internal(option == mi_option_reserve_os_memory || option == mi_option_arena_reserve); - long x = mi_option_get(option); - return (x < 0 ? 0 : (size_t)x * MI_KiB); + const long x = mi_option_get(option); + size_t size = (x < 0 ? 0 : (size_t)x); + if (mi_option_has_size_in_kib(option)) { + if (mi_mul_overflow(size, MI_KiB, &size)) { + size = MI_MAX_ALLOC_SIZE; + } + } + return size; } void mi_option_set(mi_option_t option, long value) { @@ -140,6 +284,13 @@ void mi_option_set(mi_option_t option, long value) { mi_assert(desc->option == option); // index should match the option desc->value = value; desc->init = INITIALIZED; + // ensure min/max range; be careful to not recurse. + if (desc->option == mi_option_guarded_min && _mi_option_get_fast(mi_option_guarded_max) < value) { + mi_option_set(mi_option_guarded_max, value); + } + else if (desc->option == mi_option_guarded_max && _mi_option_get_fast(mi_option_guarded_min) > value) { + mi_option_set(mi_option_guarded_min, value); + } } void mi_option_set_default(mi_option_t option, long value) { @@ -183,37 +334,43 @@ static void mi_cdecl mi_out_stderr(const char* msg, void* arg) { // an output function is registered it is called immediately with // the output up to that point. #ifndef MI_MAX_DELAY_OUTPUT -#define MI_MAX_DELAY_OUTPUT ((size_t)(32*1024)) +#define MI_MAX_DELAY_OUTPUT ((size_t)(16*1024)) #endif static char out_buf[MI_MAX_DELAY_OUTPUT+1]; static _Atomic(size_t) out_len; +static mi_lock_t out_buf_lock = MI_LOCK_INITIALIZER; static void mi_cdecl mi_out_buf(const char* msg, void* arg) { MI_UNUSED(arg); if (msg==NULL) return; - if (mi_atomic_load_relaxed(&out_len)>=MI_MAX_DELAY_OUTPUT) return; + if (mi_atomic_load_acquire(&out_len)>=MI_MAX_DELAY_OUTPUT) return; size_t n = _mi_strlen(msg); - if (n==0) return; - // claim space - size_t start = mi_atomic_add_acq_rel(&out_len, n); - if (start >= MI_MAX_DELAY_OUTPUT) return; - // check bound - if (start+n >= MI_MAX_DELAY_OUTPUT) { - n = MI_MAX_DELAY_OUTPUT-start-1; + if (n==0 || n >= MI_MAX_DELAY_OUTPUT) return; + // copy msg into the buffer + mi_lock(&out_buf_lock) { + const size_t start = mi_atomic_add_acq_rel(&out_len, n); + if (start < MI_MAX_DELAY_OUTPUT) { + // check bound + if (start+n >= MI_MAX_DELAY_OUTPUT) { + n = MI_MAX_DELAY_OUTPUT-start-1; + } + _mi_memcpy(&out_buf[start], msg, n); + } } - _mi_memcpy(&out_buf[start], msg, n); } static void mi_out_buf_flush(mi_output_fun* out, bool no_more_buf, void* arg) { if (out==NULL) return; // claim (if `no_more_buf == true`, no more output will be added after this point) - size_t count = mi_atomic_add_acq_rel(&out_len, (no_more_buf ? MI_MAX_DELAY_OUTPUT : 1)); - // and output the current contents - if (count>MI_MAX_DELAY_OUTPUT) count = MI_MAX_DELAY_OUTPUT; - out_buf[count] = 0; - out(out_buf,arg); - if (!no_more_buf) { - out_buf[count] = '\n'; // if continue with the buffer, insert a newline + mi_lock(&out_buf_lock) { + size_t count = mi_atomic_add_acq_rel(&out_len, (no_more_buf ? MI_MAX_DELAY_OUTPUT : 1)); + // and output the current contents + if (count>MI_MAX_DELAY_OUTPUT) count = MI_MAX_DELAY_OUTPUT; + out_buf[count] = 0; + out(out_buf,arg); + if (!no_more_buf) { + out_buf[count] = '\n'; // if continue with the buffer, insert a newline + } } } @@ -231,28 +388,29 @@ static void mi_cdecl mi_out_buf_stderr(const char* msg, void* arg) { // Default output handler // -------------------------------------------------------- -// Should be atomic but gives errors on many platforms as generally we cannot cast a function pointer to a uintptr_t. -// For now, don't register output from multiple threads. -static mi_output_fun* volatile mi_out_default; // = NULL +// The program should only install a single output handler from a single thread +// since otherwise the argument and output function may not match. +static _Atomic(void*) mi_out_default; // = // is `mi_output_fun*` (but some platforms don't support atomic function pointers) static _Atomic(void*) mi_out_arg; // = NULL static mi_output_fun* mi_out_get_default(void** parg) { + mi_output_fun* const out = (mi_output_fun*)mi_atomic_load_ptr_acquire(void,&mi_out_default); if (parg != NULL) { *parg = mi_atomic_load_ptr_acquire(void,&mi_out_arg); } - mi_output_fun* out = mi_out_default; return (out == NULL ? &mi_out_buf : out); } void mi_register_output(mi_output_fun* out, void* arg) mi_attr_noexcept { - mi_out_default = (out == NULL ? &mi_out_stderr : out); // stop using the delayed output buffer + mi_atomic_store_ptr_release(void,&mi_out_default, (void*)(out == NULL ? &mi_out_stderr : out)); // stop using the delayed output buffer mi_atomic_store_ptr_release(void,&mi_out_arg, arg); - if (out!=NULL) mi_out_buf_flush(out,true,arg); // output all the delayed output now + if (out!=NULL) { mi_out_buf_flush(out,true,arg); } // output all the delayed output now } // add stderr to the delayed output after the module is loaded static void mi_add_stderr_output(void) { mi_assert_internal(mi_out_default == NULL); mi_out_buf_flush(&mi_out_stderr, false, NULL); // flush current contents to stderr - mi_out_default = &mi_out_buf_stderr; // and add stderr to the delayed output + mi_atomic_store_ptr_release(void,&mi_out_default,(void*)&mi_out_buf_stderr); // and add stderr to the delayed output + mi_atomic_store_ptr_release(void,&mi_out_arg,NULL); } // -------------------------------------------------------- @@ -283,14 +441,14 @@ static mi_decl_noinline void mi_recurse_exit_prim(void) { } static bool mi_recurse_enter(void) { - #if defined(__APPLE__) || defined(MI_TLS_RECURSE_GUARD) + #if defined(__APPLE__) || defined(__ANDROID__) || defined(MI_TLS_RECURSE_GUARD) if (_mi_preloading()) return false; #endif return mi_recurse_enter_prim(); } static void mi_recurse_exit(void) { - #if defined(__APPLE__) || defined(MI_TLS_RECURSE_GUARD) + #if defined(__APPLE__) || defined(__ANDROID__) || defined(MI_TLS_RECURSE_GUARD) if (_mi_preloading()) return; #endif mi_recurse_exit_prim(); @@ -311,12 +469,12 @@ void _mi_fputs(mi_output_fun* out, void* arg, const char* prefix, const char* me } // Define our own limited `fprintf` that avoids memory allocation. -// We do this using `snprintf` with a limited buffer. +// We do this using `_mi_vsnprintf` with a limited buffer. static void mi_vfprintf( mi_output_fun* out, void* arg, const char* prefix, const char* fmt, va_list args ) { char buf[512]; if (fmt==NULL) return; if (!mi_recurse_enter()) return; - vsnprintf(buf,sizeof(buf)-1,fmt,args); + _mi_vsnprintf(buf, sizeof(buf)-1, fmt, args); mi_recurse_exit(); _mi_fputs(out,arg,prefix,buf); } @@ -331,7 +489,7 @@ void _mi_fprintf( mi_output_fun* out, void* arg, const char* fmt, ... ) { static void mi_vfprintf_thread(mi_output_fun* out, void* arg, const char* prefix, const char* fmt, va_list args) { if (prefix != NULL && _mi_strnlen(prefix,33) <= 32 && !_mi_is_main_thread()) { char tprefix[64]; - snprintf(tprefix, sizeof(tprefix), "%sthread 0x%llx: ", prefix, (unsigned long long)_mi_thread_id()); + _mi_snprintf(tprefix, sizeof(tprefix), "%sthread 0x%tx: ", prefix, (uintptr_t)_mi_thread_id()); mi_vfprintf(out, arg, tprefix, fmt, args); } else { @@ -339,6 +497,13 @@ static void mi_vfprintf_thread(mi_output_fun* out, void* arg, const char* prefix } } +void _mi_message(const char* fmt, ...) { + va_list args; + va_start(args, fmt); + mi_vfprintf_thread(NULL, NULL, "mimalloc: ", fmt, args); + va_end(args); +} + void _mi_trace_message(const char* fmt, ...) { if (mi_option_get(mi_option_verbose) <= 1) return; // only with verbose level 2 or higher va_list args; @@ -376,7 +541,7 @@ void _mi_warning_message(const char* fmt, ...) { #if MI_DEBUG -void _mi_assert_fail(const char* assertion, const char* fname, unsigned line, const char* func ) { +mi_decl_noreturn mi_decl_cold void _mi_assert_fail(const char* assertion, const char* fname, unsigned line, const char* func ) mi_attr_noexcept { _mi_fprintf(NULL, NULL, "mimalloc: assertion failed: at \"%s\":%u, %s\n assertion: \"%s\"\n", fname, line, (func==NULL?"":func), assertion); abort(); } @@ -391,24 +556,27 @@ static _Atomic(void*) mi_error_arg; // = NULL static void mi_error_default(int err) { MI_UNUSED(err); -#if (MI_DEBUG>0) - if (err==EFAULT) { - #ifdef _MSC_VER - __debugbreak(); - #endif - abort(); - } -#endif -#if (MI_SECURE>0) - if (err==EFAULT) { // abort on serious errors in secure mode (corrupted meta-data) - abort(); - } -#endif -#if defined(MI_XMALLOC) - if (err==ENOMEM || err==EOVERFLOW) { // abort on memory allocation fails in xmalloc mode - abort(); + #if (MI_DEBUG>0) + if (err==EFAULT) { + #ifdef _MSC_VER + __debugbreak(); + #endif + abort(); + } + #endif + #if (MI_SECURE>0) + if (err==EFAULT) { // abort on serious errors in secure mode (corrupted meta-data) + abort(); + } + #endif + #if defined(MI_XMALLOC) + if (err==ENOMEM || err==EOVERFLOW || err==EINVAL) { // abort on memory allocation fails in xmalloc mode + abort(); + } + #endif + if (errno==0) { + errno = (err==EINVAL ? EINVAL : ENOMEM /* compatibility */ ); } -#endif } void mi_register_error(mi_error_fun* fun, void* arg) { @@ -422,7 +590,7 @@ void _mi_error_message(int err, const char* fmt, ...) { va_start(args, fmt); mi_show_error_message(fmt, args); va_end(args); - // and call the error handler which may abort (or return normally) + // and call the error handler which may abort (or return normally, potentially setting errno) if (mi_error_handler != NULL) { mi_error_handler(err, mi_atomic_load_ptr_acquire(void,&mi_error_arg)); } @@ -434,68 +602,6 @@ void _mi_error_message(int err, const char* fmt, ...) { // -------------------------------------------------------- // Initialize options by checking the environment // -------------------------------------------------------- -char _mi_toupper(char c) { - if (c >= 'a' && c <= 'z') return (c - 'a' + 'A'); - else return c; -} - -int _mi_strnicmp(const char* s, const char* t, size_t n) { - if (n == 0) return 0; - for (; *s != 0 && *t != 0 && n > 0; s++, t++, n--) { - if (_mi_toupper(*s) != _mi_toupper(*t)) break; - } - return (n == 0 ? 0 : *s - *t); -} - -void _mi_strlcpy(char* dest, const char* src, size_t dest_size) { - if (dest==NULL || src==NULL || dest_size == 0) return; - // copy until end of src, or when dest is (almost) full - while (*src != 0 && dest_size > 1) { - *dest++ = *src++; - dest_size--; - } - // always zero terminate - *dest = 0; -} - -void _mi_strlcat(char* dest, const char* src, size_t dest_size) { - if (dest==NULL || src==NULL || dest_size == 0) return; - // find end of string in the dest buffer - while (*dest != 0 && dest_size > 1) { - dest++; - dest_size--; - } - // and catenate - _mi_strlcpy(dest, src, dest_size); -} - -size_t _mi_strlen(const char* s) { - if (s==NULL) return 0; - size_t len = 0; - while(s[len] != 0) { len++; } - return len; -} - -size_t _mi_strnlen(const char* s, size_t max_len) { - if (s==NULL) return 0; - size_t len = 0; - while(s[len] != 0 && len < max_len) { len++; } - return len; -} - -#ifdef MI_NO_GETENV -static bool mi_getenv(const char* name, char* result, size_t result_size) { - MI_UNUSED(name); - MI_UNUSED(result); - MI_UNUSED(result_size); - return false; -} -#else -static bool mi_getenv(const char* name, char* result, size_t result_size) { - if (name==NULL || result == NULL || result_size < 64) return false; - return _mi_prim_getenv(name,result,result_size); -} -#endif // TODO: implement ourselves to reduce dependencies on the C runtime #include // strtol @@ -508,45 +614,51 @@ static void mi_option_init(mi_option_desc_t* desc) { char buf[64+1]; _mi_strlcpy(buf, "mimalloc_", sizeof(buf)); _mi_strlcat(buf, desc->name, sizeof(buf)); - bool found = mi_getenv(buf, s, sizeof(s)); - if (!found && desc->legacy_name != NULL) { + int err = _mi_getenv(buf, s, sizeof(s)); + if (err==ENOENT && desc->legacy_name != NULL) { _mi_strlcpy(buf, "mimalloc_", sizeof(buf)); _mi_strlcat(buf, desc->legacy_name, sizeof(buf)); - found = mi_getenv(buf, s, sizeof(s)); - if (found) { + err = _mi_getenv(buf, s, sizeof(s)); + if (err==0) { _mi_warning_message("environment option \"mimalloc_%s\" is deprecated -- use \"mimalloc_%s\" instead.\n", desc->legacy_name, desc->name); } } - if (found) { + if (err==0) { size_t len = _mi_strnlen(s, sizeof(buf) - 1); for (size_t i = 0; i < len; i++) { buf[i] = _mi_toupper(s[i]); } buf[len] = 0; - if (buf[0] == 0 || strstr("1;TRUE;YES;ON", buf) != NULL) { + if (buf[0] == 0 || _mi_streq(buf,"1") || _mi_streq(buf,"TRUE") || _mi_streq(buf,"YES") || _mi_streq(buf,"ON")) { desc->value = 1; desc->init = INITIALIZED; } - else if (strstr("0;FALSE;NO;OFF", buf) != NULL) { + else if (_mi_streq(buf,"0") || _mi_streq(buf,"FALSE") || _mi_streq(buf,"NO") || _mi_streq(buf,"OFF")) { desc->value = 0; desc->init = INITIALIZED; } else { char* end = buf; + errno = 0; long value = strtol(buf, &end, 10); - if (desc->option == mi_option_reserve_os_memory || desc->option == mi_option_arena_reserve) { - // this option is interpreted in KiB to prevent overflow of `long` + if (errno==0 && mi_option_has_size_in_kib(desc->option)) { + // this option is interpreted in KiB to prevent overflow of `long` for large allocations + // (long is 32-bit on 64-bit windows, which allows for 4TiB max.) + size_t size = (value < 0 ? 0 : (size_t)value); + bool overflow = false; if (*end == 'K') { end++; } - else if (*end == 'M') { value *= MI_KiB; end++; } - else if (*end == 'G') { value *= MI_MiB; end++; } - else { value = (value + MI_KiB - 1) / MI_KiB; } - if (end[0] == 'I' && end[1] == 'B') { end += 2; } - else if (*end == 'B') { end++; } + else if (*end == 'M') { overflow = mi_mul_overflow(size,MI_KiB,&size); end++; } + else if (*end == 'G') { overflow = mi_mul_overflow(size,MI_MiB,&size); end++; } + else if (*end == 'T') { overflow = mi_mul_overflow(size,MI_GiB,&size); end++; } + else { size = (size + MI_KiB - 1) / MI_KiB; } + if (end[0] == 'I' && end[1] == 'B') { end += 2; } // KiB, MiB, GiB, TiB + else if (*end == 'B') { end++; } // Kb, Mb, Gb, Tb + if (overflow || size > (MI_MAX_ALLOC_SIZE / MI_KiB)) { size = (MI_MAX_ALLOC_SIZE / MI_KiB); } + value = (size > LONG_MAX ? LONG_MAX : (long)size); } - if (*end == 0) { - desc->value = value; - desc->init = INITIALIZED; + if (errno==0 && *end == 0) { + mi_option_set(desc->option, value); } else { // set `init` first to avoid recursion through _mi_warning_message on mimalloc_verbose. @@ -565,7 +677,8 @@ static void mi_option_init(mi_option_desc_t* desc) { } mi_assert_internal(desc->init != UNINIT); } - else if (!_mi_preloading()) { + else if (err==ENOENT) { desc->init = DEFAULTED; } + // and on another error, keep unitialized to try again (can happen during preloading if getenv is not available) } diff --git a/Objects/mimalloc/os.c b/Objects/mimalloc/os.c index c9103168c125077..b6e2ecbbd080e2d 100644 --- a/Objects/mimalloc/os.c +++ b/Objects/mimalloc/os.c @@ -1,5 +1,5 @@ /* ---------------------------------------------------------------------------- -Copyright (c) 2018-2023, Microsoft Research, Daan Leijen +Copyright (c) 2018-2025, Microsoft Research, Daan Leijen This is free software; you can redistribute it and/or modify it under the terms of the MIT license. A copy of the license can be found in the file "LICENSE" at the root of this distribution. @@ -9,20 +9,38 @@ terms of the MIT license. A copy of the license can be found in the file #include "mimalloc/atomic.h" #include "mimalloc/prim.h" +#define mi_os_stat_increase(stat,amount) _mi_stat_increase(&_mi_stats_main.stat, amount) +#define mi_os_stat_decrease(stat,amount) _mi_stat_decrease(&_mi_stats_main.stat, amount) +#define mi_os_stat_counter_increase(stat,inc) _mi_stat_counter_increase(&_mi_stats_main.stat, inc) /* ----------------------------------------------------------- Initialization. - On windows initializes support for aligned allocation and - large OS pages (if MIMALLOC_LARGE_OS_PAGES is true). ----------------------------------------------------------- */ +#ifndef MI_DEFAULT_VIRTUAL_ADDRESS_BITS +#if MI_INTPTR_SIZE < 8 +#define MI_DEFAULT_VIRTUAL_ADDRESS_BITS 32 +#else +#define MI_DEFAULT_VIRTUAL_ADDRESS_BITS 48 +#endif +#endif + +#ifndef MI_DEFAULT_PHYSICAL_MEMORY_IN_KIB +#if MI_INTPTR_SIZE < 8 +#define MI_DEFAULT_PHYSICAL_MEMORY_IN_KIB 4*MI_MiB // 4 GiB +#else +#define MI_DEFAULT_PHYSICAL_MEMORY_IN_KIB 32*MI_MiB // 32 GiB +#endif +#endif static mi_os_mem_config_t mi_os_mem_config = { - 4096, // page size - 0, // large page size (usually 2MiB) - 4096, // allocation granularity - true, // has overcommit? (if true we use MAP_NORESERVE on mmap systems) - false, // must free whole? (on mmap systems we can free anywhere in a mapped range, but on Windows we must free the entire span) - true // has virtual reserve? (if true we can reserve virtual address space without using commit or physical memory) + 4096, // page size + 0, // large page size (usually 2MiB) + 4096, // allocation granularity + MI_DEFAULT_PHYSICAL_MEMORY_IN_KIB, + MI_DEFAULT_VIRTUAL_ADDRESS_BITS, + true, // has overcommit? (if true we use MAP_NORESERVE on mmap systems) + false, // can we partially free allocated blocks? (on mmap systems we can free anywhere in a mapped range, but on Windows we must free the entire span) + true // has virtual reserve? (if true we can reserve virtual address space without using commit or physical memory) }; bool _mi_os_has_overcommit(void) { @@ -44,9 +62,9 @@ size_t _mi_os_large_page_size(void) { return (mi_os_mem_config.large_page_size != 0 ? mi_os_mem_config.large_page_size : _mi_os_page_size()); } -bool _mi_os_use_large_page(size_t size, size_t alignment) { +bool _mi_os_canuse_large_page(size_t size, size_t alignment) { // if we have access, check the size and alignment requirements - if (mi_os_mem_config.large_page_size == 0 || !mi_option_is_enabled(mi_option_allow_large_os_pages)) return false; + if (mi_os_mem_config.large_page_size == 0) return false; return ((size % mi_os_mem_config.large_page_size) == 0 && (alignment % mi_os_mem_config.large_page_size) == 0); } @@ -70,46 +88,39 @@ void _mi_os_init(void) { /* ----------------------------------------------------------- Util -------------------------------------------------------------- */ -bool _mi_os_decommit(void* addr, size_t size, mi_stats_t* stats); -bool _mi_os_commit(void* addr, size_t size, bool* is_zero, mi_stats_t* tld_stats); - -static void* mi_align_up_ptr(void* p, size_t alignment) { - return (void*)_mi_align_up((uintptr_t)p, alignment); -} - -static void* mi_align_down_ptr(void* p, size_t alignment) { - return (void*)_mi_align_down((uintptr_t)p, alignment); -} - +bool _mi_os_decommit(void* addr, size_t size); +bool _mi_os_commit(void* addr, size_t size, bool* is_zero); /* ----------------------------------------------------------- aligned hinting -------------------------------------------------------------- */ -// On 64-bit systems, we can do efficient aligned allocation by using -// the 2TiB to 30TiB area to allocate those. -#if (MI_INTPTR_SIZE >= 8) +// On systems with enough virtual address bits, we can do efficient aligned allocation by using +// the 2TiB to 30TiB area to allocate those. If we have at least 46 bits of virtual address +// space (64TiB) we use this technique. (but see issue #939) +#if (MI_INTPTR_SIZE >= 8) && !defined(MI_NO_ALIGNED_HINT) static mi_decl_cache_align _Atomic(uintptr_t)aligned_base; // Return a MI_SEGMENT_SIZE aligned address that is probably available. // If this returns NULL, the OS will determine the address but on some OS's that may not be // properly aligned which can be more costly as it needs to be adjusted afterwards. -// For a size > 1GiB this always returns NULL in order to guarantee good ASLR randomization; +// In secure mode, for a size > 1GiB this always returns NULL in order to guarantee good ASLR randomization. // (otherwise an initial large allocation of say 2TiB has a 50% chance to include (known) addresses // in the middle of the 2TiB - 6TiB address range (see issue #372)) #define MI_HINT_BASE ((uintptr_t)2 << 40) // 2TiB start -#define MI_HINT_AREA ((uintptr_t)4 << 40) // upto 6TiB (since before win8 there is "only" 8TiB available to processes) +#define MI_HINT_AREA ((uintptr_t)4 << 40) // upto (2+4) 6TiB (since before win8 there is "only" 8TiB available to processes) #define MI_HINT_MAX ((uintptr_t)30 << 40) // wrap after 30TiB (area after 32TiB is used for huge OS pages) void* _mi_os_get_aligned_hint(size_t try_alignment, size_t size) { if (try_alignment <= 1 || try_alignment > MI_SEGMENT_SIZE) return NULL; + if (mi_os_mem_config.virtual_address_bits < 46) return NULL; // < 64TiB virtual address space size = _mi_align_up(size, MI_SEGMENT_SIZE); - if (size > 1*MI_GiB) return NULL; // guarantee the chance of fixed valid address is at most 1/(MI_HINT_AREA / 1<<30) = 1/4096. #if (MI_SECURE>0) - size += MI_SEGMENT_SIZE; // put in `MI_SEGMENT_SIZE` virtual gaps between hinted blocks; this splits VLA's but increases guarded areas. + if (size > 1*MI_GiB) return NULL; // guarantee the chance of fixed valid address is at most 1/(MI_HINT_AREA / 1<<30) = 1/4096. #endif + size += MI_SEGMENT_SIZE; // put in `MI_SEGMENT_SIZE` virtual gaps between hinted blocks; this splits VLA's but increases guarded areas. uintptr_t hint = mi_atomic_add_acq_rel(&aligned_base, size); if (hint == 0 || hint > MI_HINT_MAX) { // wrap or initialize @@ -136,44 +147,51 @@ void* _mi_os_get_aligned_hint(size_t try_alignment, size_t size) { } #endif - /* ----------------------------------------------------------- Free memory -------------------------------------------------------------- */ -static void mi_os_free_huge_os_pages(void* p, size_t size, mi_stats_t* stats); +static void mi_os_free_huge_os_pages(void* p, size_t size); -static void mi_os_prim_free(void* addr, size_t size, bool still_committed, mi_stats_t* tld_stats) { - MI_UNUSED(tld_stats); +static void mi_os_prim_free(void* addr, size_t size, size_t commit_size) { mi_assert_internal((size % _mi_os_page_size()) == 0); - if (addr == NULL || size == 0) return; // || _mi_os_is_huge_reserved(addr) - int err = _mi_prim_free(addr, size); + if (addr == NULL) return; // || _mi_os_is_huge_reserved(addr) + int err = _mi_prim_free(addr, size); // allow size==0 (issue #1041) if (err != 0) { _mi_warning_message("unable to free OS memory (error: %d (0x%x), size: 0x%zx bytes, address: %p)\n", err, err, size, addr); } - mi_stats_t* stats = &_mi_stats_main; - if (still_committed) { _mi_stat_decrease(&stats->committed, size); } - _mi_stat_decrease(&stats->reserved, size); + if (commit_size > 0) { + mi_os_stat_decrease(committed, commit_size); + } + mi_os_stat_decrease(reserved, size); } -void _mi_os_free_ex(void* addr, size_t size, bool still_committed, mi_memid_t memid, mi_stats_t* tld_stats) { +void _mi_os_free_ex(void* addr, size_t size, bool still_committed, mi_memid_t memid) { if (mi_memkind_is_os(memid.memkind)) { - size_t csize = _mi_os_good_alloc_size(size); + size_t csize = memid.mem.os.size; + if (csize==0) { csize = _mi_os_good_alloc_size(size); } + mi_assert_internal(csize >= size); + size_t commit_size = (still_committed ? csize : 0); void* base = addr; // different base? (due to alignment) - if (memid.mem.os.base != NULL) { + if (memid.mem.os.base != base) { mi_assert(memid.mem.os.base <= addr); - mi_assert((uint8_t*)memid.mem.os.base + memid.mem.os.alignment >= (uint8_t*)addr); base = memid.mem.os.base; - csize += ((uint8_t*)addr - (uint8_t*)memid.mem.os.base); + const size_t diff = (uint8_t*)addr - (uint8_t*)memid.mem.os.base; + if (memid.mem.os.size==0) { + csize += diff; + } + if (still_committed) { + commit_size -= diff; // the (addr-base) part was already un-committed + } } // free it if (memid.memkind == MI_MEM_OS_HUGE) { mi_assert(memid.is_pinned); - mi_os_free_huge_os_pages(base, csize, tld_stats); + mi_os_free_huge_os_pages(base, csize); } else { - mi_os_prim_free(base, csize, still_committed, tld_stats); + mi_os_prim_free(base, csize, (still_committed ? commit_size : 0)); } } else { @@ -182,8 +200,8 @@ void _mi_os_free_ex(void* addr, size_t size, bool still_committed, mi_memid_t me } } -void _mi_os_free(void* p, size_t size, mi_memid_t memid, mi_stats_t* tld_stats) { - _mi_os_free_ex(p, size, true, memid, tld_stats); +void _mi_os_free(void* p, size_t size, mi_memid_t memid) { + _mi_os_free_ex(p, size, true, memid); } @@ -192,7 +210,8 @@ void _mi_os_free(void* p, size_t size, mi_memid_t memid, mi_stats_t* tld_stats) -------------------------------------------------------------- */ // Note: the `try_alignment` is just a hint and the returned pointer is not guaranteed to be aligned. -static void* mi_os_prim_alloc(size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large, bool* is_zero, mi_stats_t* stats) { +// Also `hint_addr` is a hint and may be ignored. +static void* mi_os_prim_alloc_at(void* hint_addr, size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large, bool* is_zero) { mi_assert_internal(size > 0 && (size % _mi_os_page_size()) == 0); mi_assert_internal(is_zero != NULL); mi_assert_internal(is_large != NULL); @@ -200,17 +219,26 @@ static void* mi_os_prim_alloc(size_t size, size_t try_alignment, bool commit, bo if (!commit) { allow_large = false; } if (try_alignment == 0) { try_alignment = 1; } // avoid 0 to ensure there will be no divide by zero when aligning + // try to align along large OS page size for larger allocations + const size_t large_page_size = mi_os_mem_config.large_page_size; + if (large_page_size > 0 && hint_addr == NULL && size >= 8*large_page_size && _mi_is_power_of_two(try_alignment) && try_alignment < large_page_size) { + try_alignment = large_page_size; + } + *is_zero = false; void* p = NULL; - int err = _mi_prim_alloc(size, try_alignment, commit, allow_large, is_large, is_zero, &p); + int err = _mi_prim_alloc(hint_addr, size, try_alignment, commit, allow_large, is_large, is_zero, &p); if (err != 0) { - _mi_warning_message("unable to allocate OS memory (error: %d (0x%x), size: 0x%zx bytes, align: 0x%zx, commit: %d, allow large: %d)\n", err, err, size, try_alignment, commit, allow_large); + _mi_warning_message("unable to allocate OS memory (error: %d (0x%x), addr: %p, size: 0x%zx bytes, align: 0x%zx, commit: %d, allow large: %d)\n", err, err, hint_addr, size, try_alignment, commit, allow_large); } - mi_stat_counter_increase(stats->mmap_calls, 1); + + + + mi_os_stat_counter_increase(mmap_calls, 1); if (p != NULL) { - _mi_stat_increase(&stats->reserved, size); + mi_os_stat_increase(reserved, size); if (commit) { - _mi_stat_increase(&stats->committed, size); + mi_os_stat_increase(committed, size); // seems needed for asan (or `mimalloc-test-api` fails) #ifdef MI_TRACK_ASAN if (*is_zero) { mi_track_mem_defined(p,size); } @@ -221,71 +249,87 @@ static void* mi_os_prim_alloc(size_t size, size_t try_alignment, bool commit, bo return p; } +static void* mi_os_prim_alloc(size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large, bool* is_zero) { + return mi_os_prim_alloc_at(NULL, size, try_alignment, commit, allow_large, is_large, is_zero); +} + // Primitive aligned allocation from the OS. // This function guarantees the allocated memory is aligned. -static void* mi_os_prim_alloc_aligned(size_t size, size_t alignment, bool commit, bool allow_large, bool* is_large, bool* is_zero, void** base, mi_stats_t* stats) { +static void* mi_os_prim_alloc_aligned(size_t size, size_t alignment, bool commit, bool allow_large, mi_memid_t* memid) { + mi_assert_internal(memid!=NULL); mi_assert_internal(alignment >= _mi_os_page_size() && ((alignment & (alignment - 1)) == 0)); mi_assert_internal(size > 0 && (size % _mi_os_page_size()) == 0); - mi_assert_internal(is_large != NULL); - mi_assert_internal(is_zero != NULL); - mi_assert_internal(base != NULL); + _mi_memzero(memid,sizeof(*memid)); if (!commit) allow_large = false; if (!(alignment >= _mi_os_page_size() && ((alignment & (alignment - 1)) == 0))) return NULL; size = _mi_align_up(size, _mi_os_page_size()); - // try first with a hint (this will be aligned directly on Win 10+ or BSD) - void* p = mi_os_prim_alloc(size, alignment, commit, allow_large, is_large, is_zero, stats); + // try first with a requested alignment hint (this will usually be aligned directly on Win 10+ or BSD) + bool os_is_large = false; + bool os_is_zero = false; + void* os_base = NULL; + size_t os_size = size; + void* p = mi_os_prim_alloc(size, alignment, commit, allow_large, &os_is_large, &os_is_zero); if (p == NULL) return NULL; // aligned already? if (((uintptr_t)p % alignment) == 0) { - *base = p; + os_base = p; } else { // if not aligned, free it, overallocate, and unmap around it - // NOTE(sgross): this warning causes issues in Python tests - // _mi_warning_message("unable to allocate aligned OS memory directly, fall back to over-allocation (size: 0x%zx bytes, address: %p, alignment: 0x%zx, commit: %d)\n", size, p, alignment, commit); - mi_os_prim_free(p, size, commit, stats); + #if !MI_TRACK_ASAN + // CPython: downgraded from _mi_warning_message, the warning is noisy in the test suite (gh-112027) + _mi_verbose_message("unable to allocate aligned OS memory directly, fall back to over-allocation (size: 0x%zx bytes, address: %p, alignment: 0x%zx, commit: %d)\n", size, p, alignment, commit); + #endif + if (p != NULL) { mi_os_prim_free(p, size, (commit ? size : 0)); } if (size >= (SIZE_MAX - alignment)) return NULL; // overflow const size_t over_size = size + alignment; - if (mi_os_mem_config.must_free_whole) { // win32 virtualAlloc cannot free parts of an allocate block + if (!mi_os_mem_config.has_partial_free) { // win32 virtualAlloc cannot free parts of an allocated block // over-allocate uncommitted (virtual) memory - p = mi_os_prim_alloc(over_size, 1 /*alignment*/, false /* commit? */, false /* allow_large */, is_large, is_zero, stats); + p = mi_os_prim_alloc(over_size, 1 /*alignment*/, false /* commit? */, false /* allow_large */, &os_is_large, &os_is_zero); if (p == NULL) return NULL; // set p to the aligned part in the full region // note: this is dangerous on Windows as VirtualFree needs the actual base pointer // this is handled though by having the `base` field in the memid's - *base = p; // remember the base - p = mi_align_up_ptr(p, alignment); + os_base = p; // remember the base + os_size = size; // not over_size as otherwise we over-decrement commit stats on free + p = _mi_align_up_ptr(p, alignment); // explicitly commit only the aligned part if (commit) { - _mi_os_commit(p, size, NULL, stats); + if (!_mi_os_commit(p, size, NULL)) { + mi_os_prim_free(os_base, over_size, 0); + return NULL; + } } } else { // mmap can free inside an allocation // overallocate... - p = mi_os_prim_alloc(over_size, 1, commit, false, is_large, is_zero, stats); + p = mi_os_prim_alloc(over_size, 1, commit, false, &os_is_large, &os_is_zero); if (p == NULL) return NULL; - // and selectively unmap parts around the over-allocated area. (noop on sbrk) - void* aligned_p = mi_align_up_ptr(p, alignment); - size_t pre_size = (uint8_t*)aligned_p - (uint8_t*)p; - size_t mid_size = _mi_align_up(size, _mi_os_page_size()); - size_t post_size = over_size - pre_size - mid_size; + // and selectively unmap parts around the over-allocated area. + void* const aligned_p = _mi_align_up_ptr(p, alignment); + const size_t pre_size = (uint8_t*)aligned_p - (uint8_t*)p; + const size_t mid_size = _mi_align_up(size, _mi_os_page_size()); + const size_t post_size = over_size - pre_size - mid_size; mi_assert_internal(pre_size < over_size&& post_size < over_size&& mid_size >= size); - if (pre_size > 0) { mi_os_prim_free(p, pre_size, commit, stats); } - if (post_size > 0) { mi_os_prim_free((uint8_t*)aligned_p + mid_size, post_size, commit, stats); } - // we can return the aligned pointer on `mmap` (and sbrk) systems + if (pre_size > 0) { mi_os_prim_free(p, pre_size, (commit ? pre_size : 0)); } + if (post_size > 0) { mi_os_prim_free((uint8_t*)aligned_p + mid_size, post_size, (commit ? post_size : 0)); } + // we can return the aligned pointer on `mmap` systems p = aligned_p; - *base = aligned_p; // since we freed the pre part, `*base == p`. + os_base = aligned_p; // since we freed the pre part, `*base == p`. + os_size = mid_size; } } - mi_assert_internal(p == NULL || (p != NULL && *base != NULL && ((uintptr_t)p % alignment) == 0)); + mi_assert_internal(p != NULL && os_base != NULL && _mi_is_aligned(p,alignment)); + mi_assert_internal(os_base <= p && size <= os_size); + *memid = _mi_memid_create_os(os_base,os_size,commit,os_is_zero,os_is_large); return p; } @@ -294,72 +338,94 @@ static void* mi_os_prim_alloc_aligned(size_t size, size_t alignment, bool commit OS API: alloc and alloc_aligned ----------------------------------------------------------- */ -void* _mi_os_alloc(size_t size, mi_memid_t* memid, mi_stats_t* tld_stats) { - MI_UNUSED(tld_stats); +void* _mi_os_alloc(size_t size, mi_memid_t* memid) { *memid = _mi_memid_none(); - mi_stats_t* stats = &_mi_stats_main; if (size == 0) return NULL; size = _mi_os_good_alloc_size(size); bool os_is_large = false; bool os_is_zero = false; - void* p = mi_os_prim_alloc(size, 0, true, false, &os_is_large, &os_is_zero, stats); - if (p != NULL) { - *memid = _mi_memid_create_os(true, os_is_zero, os_is_large); - } + void* p = mi_os_prim_alloc(size, 0, true, false, &os_is_large, &os_is_zero); + if (p == NULL) return NULL; + + *memid = _mi_memid_create_os(p, size, true, os_is_zero, os_is_large); + mi_assert_internal(memid->mem.os.size >= size); + mi_assert_internal(memid->initially_committed); return p; } -void* _mi_os_alloc_aligned(size_t size, size_t alignment, bool commit, bool allow_large, mi_memid_t* memid, mi_stats_t* tld_stats) +void* _mi_os_alloc_aligned(size_t size, size_t alignment, bool commit, bool allow_large, mi_memid_t* memid) { MI_UNUSED(&_mi_os_get_aligned_hint); // suppress unused warnings - MI_UNUSED(tld_stats); *memid = _mi_memid_none(); if (size == 0) return NULL; size = _mi_os_good_alloc_size(size); alignment = _mi_align_up(alignment, _mi_os_page_size()); - bool os_is_large = false; - bool os_is_zero = false; - void* os_base = NULL; - void* p = mi_os_prim_alloc_aligned(size, alignment, commit, allow_large, &os_is_large, &os_is_zero, &os_base, &_mi_stats_main /*tld->stats*/ ); - if (p != NULL) { - *memid = _mi_memid_create_os(commit, os_is_zero, os_is_large); - memid->mem.os.base = os_base; - memid->mem.os.alignment = alignment; + void* p = mi_os_prim_alloc_aligned(size, alignment, commit, allow_large, memid ); + if (p == NULL) return NULL; + + mi_assert_internal(memid->mem.os.size >= size); + mi_assert_internal(_mi_is_aligned(p,alignment)); + if (commit) { mi_assert_internal(memid->initially_committed); } + return p; +} + + +mi_decl_nodiscard static void* mi_os_ensure_zero(void* p, size_t size, mi_memid_t* memid) { + if (p==NULL || size==0) return p; + // ensure committed + if (!memid->initially_committed) { + bool is_zero = false; + if (!_mi_os_commit(p, size, &is_zero)) { + _mi_os_free(p, size, *memid); + return NULL; + } + memid->initially_committed = true; } + // ensure zero'd + if (memid->initially_zero) return p; + _mi_memzero_aligned(p,size); + memid->initially_zero = true; return p; } +void* _mi_os_zalloc(size_t size, mi_memid_t* memid) { + void* p = _mi_os_alloc(size,memid); + return mi_os_ensure_zero(p, size, memid); +} + /* ----------------------------------------------------------- OS aligned allocation with an offset. This is used - for large alignments > MI_ALIGNMENT_MAX. We use a large mimalloc + for large alignments > MI_BLOCK_ALIGNMENT_MAX. We use a large mimalloc page where the object can be aligned at an offset from the start of the segment. As we may need to overallocate, we need to free such pointers using `mi_free_aligned` to use the actual start of the memory region. ----------------------------------------------------------- */ -void* _mi_os_alloc_aligned_at_offset(size_t size, size_t alignment, size_t offset, bool commit, bool allow_large, mi_memid_t* memid, mi_stats_t* tld_stats) { +void* _mi_os_alloc_aligned_at_offset(size_t size, size_t alignment, size_t offset, bool commit, bool allow_large, mi_memid_t* memid) { mi_assert(offset <= MI_SEGMENT_SIZE); mi_assert(offset <= size); mi_assert((alignment % _mi_os_page_size()) == 0); *memid = _mi_memid_none(); - if (offset > MI_SEGMENT_SIZE) return NULL; + if (offset > MI_SEGMENT_SIZE || offset > size) return NULL; if (offset == 0) { // regular aligned allocation - return _mi_os_alloc_aligned(size, alignment, commit, allow_large, memid, tld_stats); + return _mi_os_alloc_aligned(size, alignment, commit, allow_large, memid); } else { // overallocate to align at an offset const size_t extra = _mi_align_up(offset, alignment) - offset; + if (size >= SIZE_MAX - extra) return NULL; // too large const size_t oversize = size + extra; - void* const start = _mi_os_alloc_aligned(oversize, alignment, commit, allow_large, memid, tld_stats); + void* const start = _mi_os_alloc_aligned(oversize, alignment, commit, allow_large, memid); if (start == NULL) return NULL; void* const p = (uint8_t*)start + extra; mi_assert(_mi_is_aligned((uint8_t*)p + offset, alignment)); // decommit the overallocation at the start - if (commit && extra > _mi_os_page_size()) { - _mi_os_decommit(start, extra, tld_stats); + // note: this double counts the decommit when freeing `memid`. Should we keep commit size in the memid as well? + if (commit && extra >= _mi_os_page_size()) { + _mi_os_decommit(start, extra); } return p; } @@ -377,10 +443,10 @@ static void* mi_os_page_align_areax(bool conservative, void* addr, size_t size, if (size == 0 || addr == NULL) return NULL; // page align conservatively within the range - void* start = (conservative ? mi_align_up_ptr(addr, _mi_os_page_size()) - : mi_align_down_ptr(addr, _mi_os_page_size())); - void* end = (conservative ? mi_align_down_ptr((uint8_t*)addr + size, _mi_os_page_size()) - : mi_align_up_ptr((uint8_t*)addr + size, _mi_os_page_size())); + void* start = (conservative ? _mi_align_up_ptr(addr, _mi_os_page_size()) + : _mi_align_down_ptr(addr, _mi_os_page_size())); + void* end = (conservative ? _mi_align_down_ptr((uint8_t*)addr + size, _mi_os_page_size()) + : _mi_align_up_ptr((uint8_t*)addr + size, _mi_os_page_size())); ptrdiff_t diff = (uint8_t*)end - (uint8_t*)start; if (diff <= 0) return NULL; @@ -393,12 +459,9 @@ static void* mi_os_page_align_area_conservative(void* addr, size_t size, size_t* return mi_os_page_align_areax(true, addr, size, newsize); } -bool _mi_os_commit(void* addr, size_t size, bool* is_zero, mi_stats_t* tld_stats) { - MI_UNUSED(tld_stats); - mi_stats_t* stats = &_mi_stats_main; +bool _mi_os_commit_ex(void* addr, size_t size, bool* is_zero, size_t stat_size) { if (is_zero != NULL) { *is_zero = false; } - _mi_stat_increase(&stats->committed, size); // use size for precise commit vs. decommit - _mi_stat_counter_increase(&stats->commit_calls, 1); + mi_os_stat_counter_increase(commit_calls, 1); // page align range size_t csize; @@ -421,14 +484,16 @@ bool _mi_os_commit(void* addr, size_t size, bool* is_zero, mi_stats_t* tld_stats if (os_is_zero) { mi_track_mem_defined(start,csize); } else { mi_track_mem_undefined(start,csize); } #endif + mi_os_stat_increase(committed, stat_size); // use size for precise commit vs. decommit return true; } -static bool mi_os_decommit_ex(void* addr, size_t size, bool* needs_recommit, mi_stats_t* tld_stats) { - MI_UNUSED(tld_stats); - mi_stats_t* stats = &_mi_stats_main; +bool _mi_os_commit(void* addr, size_t size, bool* is_zero) { + return _mi_os_commit_ex(addr, size, is_zero, size); +} + +static bool mi_os_decommit_ex(void* addr, size_t size, bool* needs_recommit, size_t stat_size) { mi_assert_internal(needs_recommit!=NULL); - _mi_stat_decrease(&stats->committed, size); // page align size_t csize; @@ -441,13 +506,16 @@ static bool mi_os_decommit_ex(void* addr, size_t size, bool* needs_recommit, mi_ if (err != 0) { _mi_warning_message("cannot decommit OS memory (error: %d (0x%x), address: %p, size: 0x%zx bytes)\n", err, err, start, csize); } + else if (*needs_recommit) { + mi_os_stat_decrease(committed, stat_size); + } mi_assert_internal(err == 0); return (err == 0); } -bool _mi_os_decommit(void* addr, size_t size, mi_stats_t* tld_stats) { +bool _mi_os_decommit(void* addr, size_t size) { bool needs_recommit; - return mi_os_decommit_ex(addr, size, &needs_recommit, tld_stats); + return mi_os_decommit_ex(addr, size, &needs_recommit, size); } @@ -455,13 +523,13 @@ bool _mi_os_decommit(void* addr, size_t size, mi_stats_t* tld_stats) { // but may be used later again. This will release physical memory // pages and reduce swapping while keeping the memory committed. // We page align to a conservative area inside the range to reset. -bool _mi_os_reset(void* addr, size_t size, mi_stats_t* stats) { +bool _mi_os_reset(void* addr, size_t size) { // page align conservatively within the range size_t csize; void* start = mi_os_page_align_area_conservative(addr, size, &csize); if (csize == 0) return true; // || _mi_os_is_huge_reserved(addr) - _mi_stat_increase(&stats->reset, csize); - _mi_stat_counter_increase(&stats->reset_calls, 1); + mi_os_stat_counter_increase(reset, csize); + mi_os_stat_counter_increase(reset_calls, 1); #if (MI_DEBUG>1) && !MI_SECURE && !MI_TRACK_ENABLED // && !MI_TSAN memset(start, 0, csize); // pretend it is eagerly reset @@ -475,24 +543,35 @@ bool _mi_os_reset(void* addr, size_t size, mi_stats_t* stats) { } +void _mi_os_reuse( void* addr, size_t size ) { + // page align conservatively within the range + size_t csize = 0; + void* const start = mi_os_page_align_area_conservative(addr, size, &csize); + if (csize == 0) return; + const int err = _mi_prim_reuse(start, csize); + if (err != 0) { + _mi_warning_message("cannot reuse OS memory (error: %d (0x%x), address: %p, size: 0x%zx bytes)\n", err, err, start, csize); + } +} + // either resets or decommits memory, returns true if the memory needs // to be recommitted if it is to be re-used later on. -bool _mi_os_purge_ex(void* p, size_t size, bool allow_reset, mi_stats_t* stats) +bool _mi_os_purge_ex(void* p, size_t size, bool allow_reset, size_t stat_size) { if (mi_option_get(mi_option_purge_delay) < 0) return false; // is purging allowed? - _mi_stat_counter_increase(&stats->purge_calls, 1); - _mi_stat_increase(&stats->purged, size); + mi_os_stat_counter_increase(purge_calls, 1); + mi_os_stat_counter_increase(purged, size); if (mi_option_is_enabled(mi_option_purge_decommits) && // should decommit? !_mi_preloading()) // don't decommit during preloading (unsafe) { bool needs_recommit = true; - mi_os_decommit_ex(p, size, &needs_recommit, stats); + mi_os_decommit_ex(p, size, &needs_recommit, stat_size); return needs_recommit; } else { if (allow_reset) { // this can sometimes be not allowed if the range is not fully committed - _mi_os_reset(p, size, stats); + _mi_os_reset(p, size); } return false; // needs no recommit } @@ -500,8 +579,8 @@ bool _mi_os_purge_ex(void* p, size_t size, bool allow_reset, mi_stats_t* stats) // either resets or decommits memory, returns true if the memory needs // to be recommitted if it is to be re-used later on. -bool _mi_os_purge(void* p, size_t size, mi_stats_t * stats) { - return _mi_os_purge_ex(p, size, true, stats); +bool _mi_os_purge(void* p, size_t size) { + return _mi_os_purge_ex(p, size, true, size); } // Protect a region in memory to be not accessible. @@ -512,7 +591,7 @@ static bool mi_os_protectx(void* addr, size_t size, bool protect) { if (csize == 0) return false; /* if (_mi_os_is_huge_reserved(addr)) { - _mi_warning_message("cannot mprotect memory allocated in huge OS pages\n"); + _mi_warning_message("cannot mprotect memory allocated in huge OS pages\n"); } */ int err = _mi_prim_protect(start,csize,protect); @@ -546,7 +625,11 @@ static mi_decl_cache_align _Atomic(uintptr_t) mi_huge_start; // = 0 // Claim an aligned address range for huge pages static uint8_t* mi_os_claim_huge_pages(size_t pages, size_t* total_size) { if (total_size != NULL) *total_size = 0; - const size_t size = pages * MI_HUGE_OS_PAGE_SIZE; + size_t size = 0; + if (mi_mul_overflow(pages,MI_HUGE_OS_PAGE_SIZE,&size)) { + _mi_warning_message("too many huge pages requested: %zu\n", pages); + return NULL; + } uintptr_t start = 0; uintptr_t end = 0; @@ -556,14 +639,14 @@ static uint8_t* mi_os_claim_huge_pages(size_t pages, size_t* total_size) { if (start == 0) { // Initialize the start address after the 32TiB area start = ((uintptr_t)32 << 40); // 32TiB virtual start address - #if (MI_SECURE>0 || MI_DEBUG==0) // security: randomize start of huge pages unless in debug mode + #if (MI_SECURE>0 || MI_DEBUG==0) // security: randomize start of huge pages unless in debug mode mi_heap_t* heap = mi_prim_get_default_heap(); // gh-123022: default heap may not be initialized in CPython in background threads if (mi_heap_is_initialized(heap)) { uintptr_t r = _mi_heap_random_next(heap); start = start + ((uintptr_t)MI_HUGE_OS_PAGE_SIZE * ((r>>17) & 0x0FFF)); // (randomly 12bits)*1GiB == between 0 to 4TiB } - #endif + #endif } end = start + size; mi_assert_internal(end % MI_SEGMENT_SIZE == 0); @@ -586,7 +669,7 @@ void* _mi_os_alloc_huge_os_pages(size_t pages, int numa_node, mi_msecs_t max_mse if (psize != NULL) *psize = 0; if (pages_reserved != NULL) *pages_reserved = 0; size_t size = 0; - uint8_t* start = mi_os_claim_huge_pages(pages, &size); + uint8_t* const start = mi_os_claim_huge_pages(pages, &size); if (start == NULL) return NULL; // or 32-bit systems // Allocate one page at the time but try to place them contiguously @@ -612,21 +695,21 @@ void* _mi_os_alloc_huge_os_pages(size_t pages, int numa_node, mi_msecs_t max_mse // no success, issue a warning and break if (p != NULL) { _mi_warning_message("could not allocate contiguous huge OS page %zu at %p\n", page, addr); - mi_os_prim_free(p, MI_HUGE_OS_PAGE_SIZE, true, &_mi_stats_main); + mi_os_prim_free(p, MI_HUGE_OS_PAGE_SIZE, MI_HUGE_OS_PAGE_SIZE); } break; } // success, record it page++; // increase before timeout check (see issue #711) - _mi_stat_increase(&_mi_stats_main.committed, MI_HUGE_OS_PAGE_SIZE); - _mi_stat_increase(&_mi_stats_main.reserved, MI_HUGE_OS_PAGE_SIZE); + mi_os_stat_increase(committed, MI_HUGE_OS_PAGE_SIZE); + mi_os_stat_increase(reserved, MI_HUGE_OS_PAGE_SIZE); // check for timeout if (max_msecs > 0) { mi_msecs_t elapsed = _mi_clock_end(start_t); if (page >= 1) { - mi_msecs_t estimate = ((elapsed / (page+1)) * pages); + mi_msecs_t estimate = ((elapsed / (page==0 ? 1 : page)) * pages); if (estimate > 2*max_msecs) { // seems like we are going to timeout, break elapsed = max_msecs + 1; } @@ -637,16 +720,17 @@ void* _mi_os_alloc_huge_os_pages(size_t pages, int numa_node, mi_msecs_t max_mse } } } - mi_assert_internal(page*MI_HUGE_OS_PAGE_SIZE <= size); + const size_t allocated = page * MI_HUGE_OS_PAGE_SIZE; + mi_assert_internal(allocated <= size); if (pages_reserved != NULL) { *pages_reserved = page; } - if (psize != NULL) { *psize = page * MI_HUGE_OS_PAGE_SIZE; } + if (psize != NULL) { *psize = allocated; } if (page != 0) { mi_assert(start != NULL); - *memid = _mi_memid_create_os(true /* is committed */, all_zero, true /* is_large */); + *memid = _mi_memid_create_os(start, allocated, true /* is committed */, all_zero, true /* is_large */); memid->memkind = MI_MEM_OS_HUGE; mi_assert(memid->is_pinned); #ifdef MI_TRACK_ASAN - if (all_zero) { mi_track_mem_defined(start,size); } + if (all_zero) { mi_track_mem_defined(start,allocated); } #endif } return (page == 0 ? NULL : start); @@ -654,45 +738,57 @@ void* _mi_os_alloc_huge_os_pages(size_t pages, int numa_node, mi_msecs_t max_mse // free every huge page in a range individually (as we allocated per page) // note: needed with VirtualAlloc but could potentially be done in one go on mmap'd systems. -static void mi_os_free_huge_os_pages(void* p, size_t size, mi_stats_t* stats) { +static void mi_os_free_huge_os_pages(void* p, size_t size) { if (p==NULL || size==0) return; uint8_t* base = (uint8_t*)p; while (size >= MI_HUGE_OS_PAGE_SIZE) { - mi_os_prim_free(base, MI_HUGE_OS_PAGE_SIZE, true, stats); + mi_os_prim_free(base, MI_HUGE_OS_PAGE_SIZE, MI_HUGE_OS_PAGE_SIZE); size -= MI_HUGE_OS_PAGE_SIZE; base += MI_HUGE_OS_PAGE_SIZE; } } + /* ---------------------------------------------------------------------------- Support NUMA aware allocation -----------------------------------------------------------------------------*/ -_Atomic(size_t) _mi_numa_node_count; // = 0 // cache the node count +static _Atomic(size_t) mi_numa_node_count; // = 0 // cache the node count -size_t _mi_os_numa_node_count_get(void) { - size_t count = mi_atomic_load_acquire(&_mi_numa_node_count); - if (count <= 0) { +int _mi_os_numa_node_count(void) { + size_t count = mi_atomic_load_acquire(&mi_numa_node_count); + if mi_unlikely(count == 0) { long ncount = mi_option_get(mi_option_use_numa_nodes); // given explicitly? - if (ncount > 0) { + if (ncount > 0 && ncount < INT_MAX) { count = (size_t)ncount; } else { - count = _mi_prim_numa_node_count(); // or detect dynamically - if (count == 0) count = 1; + const size_t n = _mi_prim_numa_node_count(); // or detect dynamically + if (n == 0 || n > INT_MAX) { count = 1; } + else { count = n; } } - mi_atomic_store_release(&_mi_numa_node_count, count); // save it + mi_atomic_store_release(&mi_numa_node_count, count); // save it _mi_verbose_message("using %zd numa regions\n", count); } - return count; + mi_assert_internal(count > 0 && count <= INT_MAX); + return (int)count; } -int _mi_os_numa_node_get(mi_os_tld_t* tld) { - MI_UNUSED(tld); - size_t numa_count = _mi_os_numa_node_count(); +static int mi_os_numa_node_get(void) { + int numa_count = _mi_os_numa_node_count(); if (numa_count<=1) return 0; // optimize on single numa node systems: always node 0 // never more than the node count and >= 0 - size_t numa_node = _mi_prim_numa_node(); + const size_t n = _mi_prim_numa_node(); + int numa_node = (n < INT_MAX ? (int)n : 0); if (numa_node >= numa_count) { numa_node = numa_node % numa_count; } - return (int)numa_node; + return numa_node; +} + +int _mi_os_numa_node(void) { + if mi_likely(mi_atomic_load_relaxed(&mi_numa_node_count) == 1) { + return 0; + } + else { + return mi_os_numa_node_get(); + } } diff --git a/Objects/mimalloc/page-queue.c b/Objects/mimalloc/page-queue.c index cb54b3740196e97..bfa69870c968e54 100644 --- a/Objects/mimalloc/page-queue.c +++ b/Objects/mimalloc/page-queue.c @@ -1,5 +1,5 @@ /*---------------------------------------------------------------------------- -Copyright (c) 2018-2020, Microsoft Research, Daan Leijen +Copyright (c) 2018-2024, Microsoft Research, Daan Leijen This is free software; you can redistribute it and/or modify it under the terms of the MIT license. A copy of the license can be found in the file "LICENSE" at the root of this distribution. @@ -11,6 +11,10 @@ terms of the MIT license. A copy of the license can be found in the file #ifndef MI_IN_PAGE_C #error "this file should be included from 'page.c'" +// include to help an IDE +#include "mimalloc.h" +#include "mimalloc/internal.h" +#include "mimalloc/atomic.h" #endif /* ----------------------------------------------------------- @@ -53,27 +57,23 @@ static inline bool mi_page_queue_is_special(const mi_page_queue_t* pq) { // Returns MI_BIN_HUGE if the size is too large. // We use `wsize` for the size in "machine word sizes", // i.e. byte size == `wsize*sizeof(void*)`. -static inline uint8_t mi_bin(size_t size) { +static inline size_t mi_bin(size_t size) { size_t wsize = _mi_wsize_from_size(size); - uint8_t bin; - if (wsize <= 1) { - bin = 1; +#if defined(MI_ALIGN4W) + if mi_likely(wsize <= 4) { + return (wsize <= 1 ? 1 : (wsize+1)&~1); // round to double word sizes } - #if defined(MI_ALIGN4W) - else if (wsize <= 4) { - bin = (uint8_t)((wsize+1)&~1); // round to double word sizes +#elif defined(MI_ALIGN2W) + if mi_likely(wsize <= 8) { + return (wsize <= 1 ? 1 : (wsize+1)&~1); // round to double word sizes } - #elif defined(MI_ALIGN2W) - else if (wsize <= 8) { - bin = (uint8_t)((wsize+1)&~1); // round to double word sizes - } - #else - else if (wsize <= 8) { - bin = (uint8_t)wsize; +#else + if mi_likely(wsize <= 8) { + return (wsize == 0 ? 1 : wsize); } - #endif - else if (wsize > MI_MEDIUM_OBJ_WSIZE_MAX) { - bin = MI_BIN_HUGE; +#endif + else if mi_unlikely(wsize > MI_MEDIUM_OBJ_WSIZE_MAX) { + return MI_BIN_HUGE; } else { #if defined(MI_ALIGN4W) @@ -81,15 +81,14 @@ static inline uint8_t mi_bin(size_t size) { #endif wsize--; // find the highest bit - uint8_t b = (uint8_t)mi_bsr(wsize); // note: wsize != 0 + const size_t b = (MI_SIZE_BITS - 1 - mi_clz(wsize)); // note: wsize != 0 // and use the top 3 bits to determine the bin (~12.5% worst internal fragmentation). // - adjust with 3 because we use do not round the first 8 sizes // which each get an exact bin - bin = ((b << 2) + (uint8_t)((wsize >> (b - 2)) & 0x03)) - 3; - mi_assert_internal(bin < MI_BIN_HUGE); + const size_t bin = ((b << 2) + ((wsize >> (b - 2)) & 0x03)) - 3; + mi_assert_internal(bin > 0 && bin < MI_BIN_HUGE); + return bin; } - mi_assert_internal(bin > 0 && bin <= MI_BIN_HUGE); - return bin; } @@ -98,21 +97,24 @@ static inline uint8_t mi_bin(size_t size) { Queue of pages with free blocks ----------------------------------------------------------- */ -uint8_t _mi_bin(size_t size) { +size_t _mi_bin(size_t size) { return mi_bin(size); } -size_t _mi_bin_size(uint8_t bin) { +size_t _mi_bin_size(size_t bin) { return _mi_heap_empty.pages[bin].block_size; } // Good size for allocation size_t mi_good_size(size_t size) mi_attr_noexcept { - if (size <= MI_MEDIUM_OBJ_SIZE_MAX) { - return _mi_bin_size(mi_bin(size)); + if (size <= MI_MEDIUM_OBJ_SIZE_MAX - MI_PADDING_SIZE) { + return _mi_bin_size(mi_bin(size + MI_PADDING_SIZE)); + } + else if (size <= MI_MAX_ALLOC_SIZE - MI_PADDING_SIZE) { + return _mi_align_up(size + MI_PADDING_SIZE,_mi_os_page_size()); } else { - return _mi_align_up(size,_mi_os_page_size()); + return size; } } @@ -137,21 +139,37 @@ static bool mi_heap_contains_queue(const mi_heap_t* heap, const mi_page_queue_t* } #endif -static mi_page_queue_t* mi_page_queue_of(const mi_page_t* page) { - uint8_t bin = (mi_page_is_in_full(page) ? MI_BIN_FULL : mi_bin(page->xblock_size)); - mi_heap_t* heap = mi_page_heap(page); - mi_assert_internal(heap != NULL && bin <= MI_BIN_FULL); - mi_page_queue_t* pq = &heap->pages[bin]; - mi_assert_internal(bin >= MI_BIN_HUGE || page->xblock_size == pq->block_size); - mi_assert_expensive(mi_page_queue_contains(pq, page)); - return pq; +static inline bool mi_page_is_large_or_huge(const mi_page_t* page) { + return (mi_page_block_size(page) > MI_MEDIUM_OBJ_SIZE_MAX || mi_page_is_huge(page)); } -static mi_page_queue_t* mi_heap_page_queue_of(mi_heap_t* heap, const mi_page_t* page) { - uint8_t bin = (mi_page_is_in_full(page) ? MI_BIN_FULL : mi_bin(page->xblock_size)); +static size_t mi_page_bin(const mi_page_t* page) { + const size_t bin = (mi_page_is_in_full(page) ? MI_BIN_FULL : (mi_page_is_huge(page) ? MI_BIN_HUGE : mi_bin(mi_page_block_size(page)))); mi_assert_internal(bin <= MI_BIN_FULL); + return bin; +} + +// returns the page bin without using MI_BIN_FULL for statistics +size_t _mi_page_stats_bin(const mi_page_t* page) { + const size_t bin = (mi_page_is_huge(page) ? MI_BIN_HUGE : mi_bin(mi_page_block_size(page))); + mi_assert_internal(bin <= MI_BIN_HUGE); + return bin; +} + +static mi_page_queue_t* mi_heap_page_queue_of(mi_heap_t* heap, const mi_page_t* page) { + mi_assert_internal(heap!=NULL); + const size_t bin = mi_page_bin(page); mi_page_queue_t* pq = &heap->pages[bin]; - mi_assert_internal(mi_page_is_in_full(page) || page->xblock_size == pq->block_size); + mi_assert_internal((mi_page_block_size(page) == pq->block_size) || + (mi_page_is_large_or_huge(page) && mi_page_queue_is_huge(pq)) || + (mi_page_is_in_full(page) && mi_page_queue_is_full(pq))); + return pq; +} + +static mi_page_queue_t* mi_page_queue_of(const mi_page_t* page) { + mi_heap_t* heap = mi_page_heap(page); + mi_page_queue_t* pq = mi_heap_page_queue_of(heap, page); + mi_assert_expensive(mi_page_queue_contains(pq, page)); return pq; } @@ -162,26 +180,26 @@ static mi_page_queue_t* mi_heap_page_queue_of(mi_heap_t* heap, const mi_page_t* // range of entries in `_mi_page_small_free`. static inline void mi_heap_queue_first_update(mi_heap_t* heap, const mi_page_queue_t* pq) { mi_assert_internal(mi_heap_contains_queue(heap,pq)); - size_t size = pq->block_size; + const size_t size = pq->block_size; if (size > MI_SMALL_SIZE_MAX) return; mi_page_t* page = pq->first; if (pq->first == NULL) page = (mi_page_t*)&_mi_page_empty; // find index in the right direct page array - size_t start; - size_t idx = _mi_wsize_from_size(size); - mi_page_t** pages_free = heap->pages_free_direct; - + const size_t idx = _mi_wsize_from_size(size); + mi_page_t** const pages_free = heap->pages_free_direct; if (pages_free[idx] == page) return; // already set // find start slot + size_t start; if (idx<=1) { start = 0; } else { // find previous size; due to minimal alignment upto 3 previous bins may need to be skipped - uint8_t bin = mi_bin(size); + mi_assert_internal(pq > &heap->pages[0]); // since idx > 1 + size_t bin = mi_bin(size); const mi_page_queue_t* prev = pq - 1; while( bin == mi_bin(prev->block_size) && prev > &heap->pages[0]) { prev--; @@ -206,7 +224,9 @@ static bool mi_page_queue_is_empty(mi_page_queue_t* queue) { static void mi_page_queue_remove(mi_page_queue_t* queue, mi_page_t* page) { mi_assert_internal(page != NULL); mi_assert_expensive(mi_page_queue_contains(queue, page)); - mi_assert_internal(page->xblock_size == queue->block_size || (page->xblock_size > MI_MEDIUM_OBJ_SIZE_MAX && mi_page_queue_is_huge(queue)) || (mi_page_is_in_full(page) && mi_page_queue_is_full(queue))); + mi_assert_internal(mi_page_block_size(page) == queue->block_size || + (mi_page_is_large_or_huge(page) && mi_page_queue_is_huge(queue)) || + (mi_page_is_in_full(page) && mi_page_queue_is_full(queue))); mi_heap_t* heap = mi_page_heap(page); if (page->prev != NULL) page->prev->next = page->next; @@ -226,14 +246,18 @@ static void mi_page_queue_remove(mi_page_queue_t* queue, mi_page_t* page) { } +#if MI_DEBUG >= 3 +static bool mi_page_queue_is_consistent(const mi_page_queue_t* queue); +#endif + static void mi_page_queue_push(mi_heap_t* heap, mi_page_queue_t* queue, mi_page_t* page) { mi_assert_internal(mi_page_heap(page) == heap); mi_assert_internal(!mi_page_queue_contains(queue, page)); #if MI_HUGE_PAGE_ABANDON mi_assert_internal(_mi_page_segment(page)->kind != MI_SEGMENT_HUGE); #endif - mi_assert_internal(page->xblock_size == queue->block_size || - (page->xblock_size > MI_MEDIUM_OBJ_SIZE_MAX) || + mi_assert_internal(mi_page_block_size(page) == queue->block_size || + (mi_page_is_large_or_huge(page) && mi_page_queue_is_huge(queue)) || (mi_page_is_in_full(page) && mi_page_queue_is_full(queue))); mi_page_set_in_full(page, mi_page_queue_is_full(queue)); @@ -252,21 +276,59 @@ static void mi_page_queue_push(mi_heap_t* heap, mi_page_queue_t* queue, mi_page_ // update direct mi_heap_queue_first_update(heap, queue); heap->page_count++; + + // [specbot Q-NEW-1] first/last must be both null or both non-null (L1, O(1)) + mi_assert_internal((queue->first == NULL) == (queue->last == NULL)); + // [specbot Q-NEW-2] last element must have no next (L1, O(1)) + mi_assert_internal(queue->last == NULL || queue->last->next == NULL); + mi_assert_expensive(mi_page_queue_is_consistent(queue)); } +#if MI_DEBUG >= 3 +// [specbot Q-NEW-3] Verify doubly-linked list forward/backward consistency (L2, O(n)) +static bool mi_page_queue_is_consistent(const mi_page_queue_t* queue) { + if (queue->first == NULL) return (queue->last == NULL); + if (queue->last == NULL) return false; + // forward: first -> ... -> last + const mi_page_t* p = queue->first; + const mi_page_t* prev = NULL; + size_t count = 0; + while (p != NULL) { + mi_assert_internal(p->prev == prev); + prev = p; + p = p->next; + count++; + if (count > 100000) return false; // cycle guard + } + mi_assert_internal(prev == queue->last); + return true; +} +#endif -static void mi_page_queue_enqueue_from(mi_page_queue_t* to, mi_page_queue_t* from, mi_page_t* page) { +static void mi_page_queue_move_to_front(mi_heap_t* heap, mi_page_queue_t* queue, mi_page_t* page) { + mi_assert_internal(mi_page_heap(page) == heap); + mi_assert_internal(mi_page_queue_contains(queue, page)); + if (queue->first == page) return; + mi_page_queue_remove(queue, page); + mi_page_queue_push(heap, queue, page); + mi_assert_internal(queue->first == page); +} + +static void mi_page_queue_enqueue_from_ex(mi_page_queue_t* to, mi_page_queue_t* from, bool enqueue_at_end, mi_page_t* page) { mi_assert_internal(page != NULL); mi_assert_expensive(mi_page_queue_contains(from, page)); mi_assert_expensive(!mi_page_queue_contains(to, page)); - - mi_assert_internal((page->xblock_size == to->block_size && page->xblock_size == from->block_size) || - (page->xblock_size == to->block_size && mi_page_queue_is_full(from)) || - (page->xblock_size == from->block_size && mi_page_queue_is_full(to)) || - (page->xblock_size > MI_LARGE_OBJ_SIZE_MAX && mi_page_queue_is_huge(to)) || - (page->xblock_size > MI_LARGE_OBJ_SIZE_MAX && mi_page_queue_is_full(to))); + const size_t bsize = mi_page_block_size(page); + MI_UNUSED(bsize); + mi_assert_internal((bsize == to->block_size && bsize == from->block_size) || + (bsize == to->block_size && mi_page_queue_is_full(from)) || + (bsize == from->block_size && mi_page_queue_is_full(to)) || + (mi_page_is_large_or_huge(page) && mi_page_queue_is_huge(to)) || + (mi_page_is_large_or_huge(page) && mi_page_queue_is_full(to))); mi_heap_t* heap = mi_page_heap(page); + + // delete from `from` if (page->prev != NULL) page->prev->next = page->next; if (page->next != NULL) page->next->prev = page->prev; if (page == from->last) from->last = page->prev; @@ -277,22 +339,59 @@ static void mi_page_queue_enqueue_from(mi_page_queue_t* to, mi_page_queue_t* fro mi_heap_queue_first_update(heap, from); } - page->prev = to->last; - page->next = NULL; - if (to->last != NULL) { - mi_assert_internal(heap == mi_page_heap(to->last)); - to->last->next = page; - to->last = page; + // insert into `to` + if (enqueue_at_end) { + // enqueue at the end + page->prev = to->last; + page->next = NULL; + if (to->last != NULL) { + mi_assert_internal(heap == mi_page_heap(to->last)); + to->last->next = page; + to->last = page; + } + else { + to->first = page; + to->last = page; + mi_heap_queue_first_update(heap, to); + } } else { - to->first = page; - to->last = page; - mi_heap_queue_first_update(heap, to); + if (to->first != NULL) { + // enqueue at 2nd place + mi_assert_internal(heap == mi_page_heap(to->first)); + mi_page_t* next = to->first->next; + page->prev = to->first; + page->next = next; + to->first->next = page; + if (next != NULL) { + next->prev = page; + } + else { + to->last = page; + } + } + else { + // enqueue at the head (singleton list) + page->prev = NULL; + page->next = NULL; + to->first = page; + to->last = page; + mi_heap_queue_first_update(heap, to); + } } mi_page_set_in_full(page, mi_page_queue_is_full(to)); } +static void mi_page_queue_enqueue_from(mi_page_queue_t* to, mi_page_queue_t* from, mi_page_t* page) { + mi_page_queue_enqueue_from_ex(to, from, true /* enqueue at the end */, page); +} + +static void mi_page_queue_enqueue_from_full(mi_page_queue_t* to, mi_page_queue_t* from, mi_page_t* page) { + // note: we could insert at the front to increase reuse, but it slows down certain benchmarks (like `alloc-test`) + mi_page_queue_enqueue_from_ex(to, from, true /* enqueue at the end of the `to` queue? */, page); +} + // Only called from `mi_heap_absorb`. size_t _mi_page_queue_append(mi_heap_t* heap, mi_page_queue_t* pq, mi_page_queue_t* append) { mi_assert_internal(mi_heap_contains_queue(heap,pq)); diff --git a/Objects/mimalloc/page.c b/Objects/mimalloc/page.c index ded59f8eb1ccaac..2f26d04aaaa4d87 100644 --- a/Objects/mimalloc/page.c +++ b/Objects/mimalloc/page.c @@ -1,5 +1,5 @@ /*---------------------------------------------------------------------------- -Copyright (c) 2018-2020, Microsoft Research, Daan Leijen +Copyright (c) 2018-2024, Microsoft Research, Daan Leijen This is free software; you can redistribute it and/or modify it under the terms of the MIT license. A copy of the license can be found in the file "LICENSE" at the root of this distribution. @@ -37,7 +37,7 @@ static inline mi_block_t* mi_page_block_at(const mi_page_t* page, void* page_sta } static void mi_page_init(mi_heap_t* heap, mi_page_t* page, size_t size, mi_tld_t* tld); -static void mi_page_extend_free(mi_heap_t* heap, mi_page_t* page, mi_tld_t* tld); +static bool mi_page_extend_free(mi_heap_t* heap, mi_page_t* page, mi_tld_t* tld); #if (MI_DEBUG>=3) static size_t mi_page_list_count(mi_page_t* page, mi_block_t* head) { @@ -59,7 +59,7 @@ static inline uint8_t* mi_page_area(const mi_page_t* page) { static bool mi_page_list_is_valid(mi_page_t* page, mi_block_t* p) { size_t psize; - uint8_t* page_area = _mi_page_start(_mi_page_segment(page), page, &psize); + uint8_t* page_area = _mi_segment_page_start(_mi_page_segment(page), page, &psize); mi_block_t* start = (mi_block_t*)page_area; mi_block_t* end = (mi_block_t*)(page_area + psize); while(p != NULL) { @@ -78,19 +78,38 @@ static bool mi_page_list_is_valid(mi_page_t* page, mi_block_t* p) { } static bool mi_page_is_valid_init(mi_page_t* page) { - mi_assert_internal(page->xblock_size > 0); + mi_assert_internal(mi_page_block_size(page) > 0); + mi_assert_internal(page->used <= page->capacity); mi_assert_internal(page->capacity <= page->reserved); - mi_segment_t* segment = _mi_page_segment(page); - uint8_t* start = _mi_page_start(segment,page,NULL); - mi_assert_internal(start == _mi_segment_page_start(segment,page,NULL)); - //const size_t bsize = mi_page_block_size(page); + // [specbot P-NEW-1] block_size_shift must be consistent with block_size (L1, O(1)) + mi_assert_internal(page->block_size_shift == 0 || (mi_page_block_size(page) == ((size_t)1 << page->block_size_shift))); + // [specbot P-NEW-2] capacity must be nonzero when blocks are in use (L1, O(1)) + mi_assert_internal(page->used == 0 || page->capacity > 0); + // [specbot P-NEW-4] page_start must be non-null when capacity > 0 (L1, O(1)) + mi_assert_internal(page->capacity == 0 || mi_page_start(page) != NULL); + + uint8_t* start = mi_page_start(page); + mi_assert_internal(start == _mi_segment_page_start(_mi_page_segment(page), page, NULL)); + mi_assert_internal(page->is_huge == (_mi_page_segment(page)->kind == MI_SEGMENT_HUGE)); //mi_assert_internal(start + page->capacity*page->block_size == page->top); mi_assert_internal(mi_page_list_is_valid(page,page->free)); mi_assert_internal(mi_page_list_is_valid(page,page->local_free)); + // [specbot P-NEW-7] All free list blocks are aligned to block_size (L2, O(n)) + { + size_t bsize = mi_page_block_size(page); + uint8_t* pstart = mi_page_start(page); + for (mi_block_t* b = page->free; b != NULL; b = mi_block_next(page, b)) { + mi_assert_internal(((uint8_t*)b - pstart) % bsize == 0); + } + for (mi_block_t* b = page->local_free; b != NULL; b = mi_block_next(page, b)) { + mi_assert_internal(((uint8_t*)b - pstart) % bsize == 0); + } + } + #if MI_DEBUG>3 // generally too expensive to check this if (page->free_is_zero) { const size_t ubsize = mi_page_usable_block_size(page); @@ -113,7 +132,7 @@ static bool mi_page_is_valid_init(mi_page_t* page) { return true; } -extern bool _mi_process_is_initialized; // has mi_process_init been called? +extern mi_decl_hidden bool _mi_process_is_initialized; // has mi_process_init been called? bool _mi_page_is_valid(mi_page_t* page) { mi_assert_internal(mi_page_is_valid_init(page)); @@ -123,6 +142,9 @@ bool _mi_page_is_valid(mi_page_t* page) { if (mi_page_heap(page)!=NULL) { mi_segment_t* segment = _mi_page_segment(page); + // [specbot P-NEW-6] heap_tag must match owning heap's tag (L1, O(1)) + mi_assert_internal(page->heap_tag == mi_page_heap(page)->tag); + mi_assert_internal(!_mi_process_is_initialized || segment->thread_id==0 || segment->thread_id == mi_page_heap(page)->thread_id); #if MI_HUGE_PAGE_ABANDON if (segment->kind != MI_SEGMENT_HUGE) @@ -139,8 +161,9 @@ bool _mi_page_is_valid(mi_page_t* page) { #endif void _mi_page_use_delayed_free(mi_page_t* page, mi_delayed_t delay, bool override_never) { + size_t ticks = 0; while (!_mi_page_try_use_delayed_free(page, delay, override_never)) { - mi_atomic_yield(); + mi_atomic_yield_sleep(&ticks,10); } } @@ -193,8 +216,8 @@ static void _mi_page_thread_free_collect(mi_page_t* page) if (head == NULL) return; // find the tail -- also to get a proper count (without data races) - uint32_t max_count = page->capacity; // cannot collect more than capacity - uint32_t count = 1; + size_t max_count = page->capacity; // cannot collect more than capacity + size_t count = 1; mi_block_t* tail = head; mi_block_t* next; while ((next = mi_block_next(page,tail)) != NULL && count <= max_count) { @@ -202,8 +225,13 @@ static void _mi_page_thread_free_collect(mi_page_t* page) tail = next; } // if `count > max_count` there was a memory corruption (possibly infinite list due to double multi-threaded free) - if (count > max_count) { - _mi_error_message(EFAULT, "corrupted thread-free list\n"); + if mi_unlikely(count > max_count) { + _mi_error_message(EFAULT, "corrupted thread-free list (possibly due to a cross-thread double free)\n"); + return; // the thread-free items cannot be freed + } + // if `count > page->used` there was another kind memory corruption (either in the page meta-data or in the linked list) + else if mi_unlikely(count > page->used) { + _mi_error_message(EFAULT, "corrupted meta-data in thread-free list\n"); return; // the thread-free items cannot be freed } @@ -212,10 +240,12 @@ static void _mi_page_thread_free_collect(mi_page_t* page) page->local_free = head; // update counts now - page->used -= count; + mi_assert_internal(count <= UINT16_MAX); + mi_assert_internal(page->used >= (uint16_t)count); + page->used = page->used - (uint16_t)count; if (page->used == 0) { - // The page may have had a QSBR goal set from a previous point when it + // CPython: the page may have had a QSBR goal set from a previous point when it // was all-free. That goal is no longer valid because the page was // allocated from and then freed again by other threads. _PyMem_mi_page_clear_qsbr(page); @@ -285,19 +315,22 @@ static mi_page_t* mi_page_fresh_alloc(mi_heap_t* heap, mi_page_queue_t* pq, size mi_assert_internal(mi_heap_contains_queue(heap, pq)); mi_assert_internal(page_alignment > 0 || block_size > MI_MEDIUM_OBJ_SIZE_MAX || block_size == pq->block_size); #endif - mi_page_t* page = _mi_segment_page_alloc(heap, block_size, page_alignment, &heap->tld->segments, &heap->tld->os); + mi_page_t* page = _mi_segment_page_alloc(heap, block_size, page_alignment, &heap->tld->segments); if (page == NULL) { // this may be out-of-memory, or an abandoned page was reclaimed (and in our queue) return NULL; } + #if MI_HUGE_PAGE_ABANDON + mi_assert_internal(pq==NULL || _mi_page_segment(page)->page_kind != MI_PAGE_HUGE); + #endif mi_assert_internal(page_alignment >0 || block_size > MI_MEDIUM_OBJ_SIZE_MAX || _mi_page_segment(page)->kind != MI_SEGMENT_HUGE); - mi_assert_internal(pq!=NULL || page->xblock_size != 0); mi_assert_internal(pq!=NULL || mi_page_block_size(page) >= block_size); // a fresh page was found, initialize it - const size_t full_block_size = ((pq == NULL || mi_page_queue_is_huge(pq)) ? mi_page_block_size(page) : block_size); // see also: mi_segment_huge_page_alloc + const size_t full_block_size = (pq == NULL || mi_page_is_huge(page) ? mi_page_block_size(page) : block_size); // see also: mi_segment_huge_page_alloc mi_assert_internal(full_block_size >= block_size); mi_page_init(heap, page, full_block_size, heap->tld); - mi_heap_stat_increase(heap, pages, 1); + _mi_stat_increase(&heap->tld->stats.pages, 1); + _mi_stat_increase(&heap->tld->stats.page_bins[_mi_page_stats_bin(page)], 1); if (pq != NULL) { mi_page_queue_push(heap, pq, page); } mi_assert_expensive(_mi_page_is_valid(page)); return page; @@ -318,8 +351,9 @@ static mi_page_t* mi_page_fresh(mi_heap_t* heap, mi_page_queue_t* pq) { (put there by other threads if they deallocated in a full page) ----------------------------------------------------------- */ void _mi_heap_delayed_free_all(mi_heap_t* heap) { + size_t ticks = 0; while (!_mi_heap_delayed_free_partial(heap)) { - mi_atomic_yield(); + mi_atomic_yield_sleep(&ticks,10); } } @@ -365,7 +399,7 @@ void _mi_page_unfull(mi_page_t* page) { mi_page_set_in_full(page, false); // to get the right queue mi_page_queue_t* pq = mi_heap_page_queue_of(heap, page); mi_page_set_in_full(page, true); - mi_page_queue_enqueue_from(pq, pqfull, page); + mi_page_queue_enqueue_from_full(pq, pqfull, page); } static void mi_page_to_full(mi_page_t* page, mi_page_queue_t* pq) { @@ -393,7 +427,7 @@ void _mi_page_abandon(mi_page_t* page, mi_page_queue_t* pq) { #ifdef Py_GIL_DISABLED if (page->qsbr_node.next != NULL) { - // remove from QSBR queue, but keep the goal + // CPython: remove from the QSBR queue, but keep the goal llist_remove(&page->qsbr_node); } #endif @@ -418,6 +452,32 @@ void _mi_page_abandon(mi_page_t* page, mi_page_queue_t* pq) { _mi_segment_page_abandon(page,segments_tld); } +// force abandon a page +void _mi_page_force_abandon(mi_page_t* page) { + mi_heap_t* heap = mi_page_heap(page); + // mark page as not using delayed free + _mi_page_use_delayed_free(page, MI_NEVER_DELAYED_FREE, false); + + // ensure this page is no longer in the heap delayed free list + _mi_heap_delayed_free_all(heap); + // We can still access the page meta-info even if it is freed as we ensure + // in `mi_segment_force_abandon` that the segment is not freed (yet) + if (page->capacity == 0) return; // it may have been freed now + + // and now unlink it from the page queue and abandon (or free) + mi_page_queue_t* pq = mi_heap_page_queue_of(heap, page); + if (mi_page_all_free(page)) { + // CPython: keep the page if it is still waiting for QSBR. + if (!_PyMem_mi_page_maybe_free(page, pq, false)) { + pq = mi_heap_page_queue_of(heap, page); + _mi_page_abandon(page, pq); + } + } + else { + _mi_page_abandon(page, pq); + } +} + // Free a page with no more free blocks void _mi_page_free(mi_page_t* page, mi_page_queue_t* pq, bool force) { @@ -447,8 +507,6 @@ void _mi_page_free(mi_page_t* page, mi_page_queue_t* pq, bool force) { _mi_segment_page_free(page, force, segments_tld); } -// Retire parameters -#define MI_MAX_RETIRE_SIZE (MI_MEDIUM_OBJ_SIZE_MAX) #define MI_RETIRE_CYCLES (16) // Retire a page with no more used blocks @@ -464,7 +522,7 @@ void _mi_page_retire(mi_page_t* page) mi_attr_noexcept { mi_page_set_has_aligned(page, false); - // any previous QSBR goals are no longer valid because we reused the page + // CPython: any previous QSBR goals are no longer valid because we reused the page _PyMem_mi_page_clear_qsbr(page); // don't retire too often.. @@ -474,10 +532,12 @@ void _mi_page_retire(mi_page_t* page) mi_attr_noexcept { // how to check this efficiently though... // for now, we don't retire if it is the only page left of this size class. mi_page_queue_t* pq = mi_page_queue_of(page); - if mi_likely(page->xblock_size <= MI_MAX_RETIRE_SIZE && !mi_page_queue_is_special(pq)) { // not too large && not full or huge queue? + #if MI_RETIRE_CYCLES > 0 + const size_t bsize = mi_page_block_size(page); + if mi_likely( /* bsize < MI_MAX_RETIRE_SIZE && */ !mi_page_queue_is_special(pq)) { // not full or huge queue? if (pq->last==page && pq->first==page) { // the only page in the queue? - mi_stat_counter_increase(_mi_stats_main.page_no_retire,1); - page->retire_expire = 1 + (page->xblock_size <= MI_SMALL_OBJ_SIZE_MAX ? MI_RETIRE_CYCLES : MI_RETIRE_CYCLES/4); + mi_stat_counter_increase(_mi_stats_main.pages_retire,1); + page->retire_expire = (bsize <= MI_SMALL_OBJ_SIZE_MAX ? MI_RETIRE_CYCLES : MI_RETIRE_CYCLES/4); mi_heap_t* heap = mi_page_heap(page); mi_assert_internal(pq >= heap->pages); const size_t index = pq - heap->pages; @@ -488,6 +548,7 @@ void _mi_page_retire(mi_page_t* page) mi_attr_noexcept { return; // don't free after all } } + #endif _PyMem_mi_page_maybe_free(page, pq, false); } @@ -536,13 +597,13 @@ void _mi_heap_collect_retired(mi_heap_t* heap, bool force) { static void mi_page_free_list_extend_secure(mi_heap_t* const heap, mi_page_t* const page, const size_t bsize, const size_t extend, mi_stats_t* const stats) { MI_UNUSED(stats); - #if (MI_SECURE<=2) + #if (MI_SECURE < 2) mi_assert_internal(page->free == NULL); mi_assert_internal(page->local_free == NULL); #endif mi_assert_internal(page->capacity + extend <= page->reserved); mi_assert_internal(bsize == mi_page_block_size(page)); - void* const page_area = _mi_page_start(_mi_page_segment(page), page, NULL); + void* const page_area = mi_page_start(page); // initialize a randomized free list // set up `slice_count` slices to alternate between @@ -594,13 +655,13 @@ static void mi_page_free_list_extend_secure(mi_heap_t* const heap, mi_page_t* co static mi_decl_noinline void mi_page_free_list_extend( mi_page_t* const page, const size_t bsize, const size_t extend, mi_stats_t* const stats) { MI_UNUSED(stats); - #if (MI_SECURE <= 2) + #if (MI_SECURE < 2) mi_assert_internal(page->free == NULL); mi_assert_internal(page->local_free == NULL); #endif mi_assert_internal(page->capacity + extend <= page->reserved); mi_assert_internal(bsize == mi_page_block_size(page)); - void* const page_area = _mi_page_start(_mi_page_segment(page), page, NULL ); + void* const page_area = mi_page_start(page); mi_block_t* const start = mi_page_block_at(page, page_area, bsize, page->capacity); @@ -622,8 +683,8 @@ static mi_decl_noinline void mi_page_free_list_extend( mi_page_t* const page, co ----------------------------------------------------------- */ #define MI_MAX_EXTEND_SIZE (4*1024) // heuristic, one OS page seems to work well. -#if (MI_SECURE>0) -#define MI_MIN_EXTEND (8*MI_SECURE) // extend at least by this many +#if (MI_SECURE>=2) +#define MI_MIN_EXTEND (8*MI_SECURE) // extend at least by this many blocks #else #define MI_MIN_EXTEND (4) #endif @@ -633,26 +694,23 @@ static mi_decl_noinline void mi_page_free_list_extend( mi_page_t* const page, co // Note: we also experimented with "bump" allocation on the first // allocations but this did not speed up any benchmark (due to an // extra test in malloc? or cache effects?) -static void mi_page_extend_free(mi_heap_t* heap, mi_page_t* page, mi_tld_t* tld) { - MI_UNUSED(tld); +static bool mi_page_extend_free(mi_heap_t* heap, mi_page_t* page, mi_tld_t* tld) { mi_assert_expensive(mi_page_is_valid_init(page)); - #if (MI_SECURE<=2) + #if (MI_SECURE < 2) mi_assert(page->free == NULL); mi_assert(page->local_free == NULL); - if (page->free != NULL) return; + if (page->free != NULL) return true; #endif - if (page->capacity >= page->reserved) return; + if (page->capacity >= page->reserved) return true; - size_t page_size; - _mi_page_start(_mi_page_segment(page), page, &page_size); mi_stat_counter_increase(tld->stats.pages_extended, 1); // calculate the extend count - const size_t bsize = (page->xblock_size < MI_HUGE_BLOCK_SIZE ? page->xblock_size : page_size); + const size_t bsize = mi_page_block_size(page); size_t extend = page->reserved - page->capacity; mi_assert_internal(extend > 0); - size_t max_extend = (bsize >= MI_MAX_EXTEND_SIZE ? MI_MIN_EXTEND : MI_MAX_EXTEND_SIZE/(uint32_t)bsize); + size_t max_extend = (bsize >= MI_MAX_EXTEND_SIZE ? MI_MIN_EXTEND : MI_MAX_EXTEND_SIZE/bsize); if (max_extend < MI_MIN_EXTEND) { max_extend = MI_MIN_EXTEND; } mi_assert_internal(max_extend > 0); @@ -666,7 +724,7 @@ static void mi_page_extend_free(mi_heap_t* heap, mi_page_t* page, mi_tld_t* tld) mi_assert_internal(extend < (1UL<<16)); // and append the extend the free list - if (extend < MI_MIN_SLICES || MI_SECURE==0) { //!mi_option_is_enabled(mi_option_secure)) { + if (extend < MI_MIN_SLICES || MI_SECURE<2) { //!mi_option_is_enabled(mi_option_secure)) { mi_page_free_list_extend(page, bsize, extend, &tld->stats ); } else { @@ -674,8 +732,9 @@ static void mi_page_extend_free(mi_heap_t* heap, mi_page_t* page, mi_tld_t* tld) } // enable the new free list page->capacity += (uint16_t)extend; - mi_stat_increase(tld->stats.page_committed, extend * bsize); + _mi_stat_increase(&tld->stats.page_committed, extend * bsize); mi_assert_expensive(mi_page_is_valid_init(page)); + return true; } // Initialize a fresh page @@ -686,14 +745,12 @@ static void mi_page_init(mi_heap_t* heap, mi_page_t* page, size_t block_size, mi mi_assert_internal(block_size > 0); // set fields mi_page_set_heap(page, heap); - page->tag = heap->tag; - page->use_qsbr = heap->page_use_qsbr; - page->debug_offset = heap->debug_offset; - page->xblock_size = (block_size < MI_HUGE_BLOCK_SIZE ? (uint32_t)block_size : MI_HUGE_BLOCK_SIZE); // initialize before _mi_segment_page_start + page->use_qsbr = heap->page_use_qsbr; // CPython + page->debug_offset = heap->debug_offset; // CPython + page->block_size = block_size; size_t page_size; - const void* page_start = _mi_segment_page_start(segment, page, &page_size); - MI_UNUSED(page_start); - mi_track_mem_noaccess(page_start,page_size); + page->page_start = _mi_segment_page_start(segment, page, &page_size); + mi_track_mem_noaccess(page->page_start,page_size); mi_assert_internal(mi_page_block_size(page) <= page_size); mi_assert_internal(page_size <= page->slice_count*MI_SEGMENT_SLICE_SIZE); mi_assert_internal(page_size / block_size < (1L<<16)); @@ -706,12 +763,18 @@ static void mi_page_init(mi_heap_t* heap, mi_page_t* page, size_t block_size, mi page->free_is_zero = page->is_zero_init; #if MI_DEBUG>2 if (page->is_zero_init) { - mi_track_mem_defined(page_start, page_size); - mi_assert_expensive(mi_mem_is_zero(page_start, page_size)); + mi_track_mem_defined(page->page_start, page_size); + mi_assert_expensive(mi_mem_is_zero(page->page_start, page_size)); } #endif - mi_assert_internal(page->is_committed); + if (block_size > 0 && _mi_is_power_of_two(block_size)) { + page->block_size_shift = (uint8_t)(mi_ctz((uintptr_t)block_size)); + } + else { + page->block_size_shift = 0; + } + mi_assert_internal(page->capacity == 0); mi_assert_internal(page->free == NULL); mi_assert_internal(page->used == 0); @@ -728,11 +791,14 @@ static void mi_page_init(mi_heap_t* heap, mi_page_t* page, size_t block_size, mi mi_assert_internal(page->keys[0] != 0); mi_assert_internal(page->keys[1] != 0); #endif + mi_assert_internal(page->block_size_shift == 0 || (block_size == ((size_t)1 << page->block_size_shift))); mi_assert_expensive(mi_page_is_valid_init(page)); // initialize an initial free list - mi_page_extend_free(heap,page,tld); - mi_assert(mi_page_immediate_available(page)); + if (mi_page_extend_free(heap,page,tld)) { + mi_assert(mi_page_immediate_available(page)); + } + return; } @@ -740,6 +806,17 @@ static void mi_page_init(mi_heap_t* heap, mi_page_t* page, size_t block_size, mi Find pages with free blocks -------------------------------------------------------------*/ +// search for a best next page to use for at most N pages (often cut short if immediate blocks are available) +#define MI_MAX_CANDIDATE_SEARCH (4) + +// is the page not yet used up to its reserved space? +static bool mi_page_is_expandable(const mi_page_t* page) { + mi_assert_internal(page != NULL); + mi_assert_internal(page->capacity <= page->reserved); + return (page->capacity < page->reserved); +} + + // Find a page with free blocks of `page->block_size`. static mi_page_t* mi_page_queue_find_free_ex(mi_heap_t* heap, mi_page_queue_t* pq, bool first_try) { @@ -747,41 +824,85 @@ static mi_page_t* mi_page_queue_find_free_ex(mi_heap_t* heap, mi_page_queue_t* p #if MI_STAT size_t count = 0; #endif + size_t candidate_count = 0; // we reset this on the first candidate to limit the search + mi_page_t* page_candidate = NULL; // a page with free space mi_page_t* page = pq->first; + while (page != NULL) { mi_page_t* next = page->next; // remember next #if MI_STAT count++; #endif + candidate_count++; - // 0. collect freed blocks by us and other threads + // collect freed blocks by us and other threads _mi_page_free_collect(page, false); - // 1. if the page contains free blocks, we are done - if (mi_page_immediate_available(page)) { - break; // pick this one - } + #if MI_MAX_CANDIDATE_SEARCH > 1 + // search up to N pages for a best candidate - // 2. Try to extend - if (page->capacity < page->reserved) { - mi_page_extend_free(heap, page, heap->tld); - mi_assert_internal(mi_page_immediate_available(page)); - break; + // is the local free list non-empty? + const bool immediate_available = mi_page_immediate_available(page); + + // if the page is completely full, move it to the `mi_pages_full` + // queue so we don't visit long-lived pages too often. + if (!immediate_available && !mi_page_is_expandable(page)) { + mi_assert_internal(!mi_page_is_in_full(page) && !mi_page_immediate_available(page)); + mi_page_to_full(page, pq); + } + else { + // the page has free space, make it a candidate + // we prefer non-expandable pages with high usage as candidates (to reduce commit, and increase chances of free-ing up pages) + if (page_candidate == NULL) { + page_candidate = page; + candidate_count = 0; + } + // prefer to reuse fuller pages (in the hope the less used page gets freed) + else if (page->used >= page_candidate->used && !mi_page_is_mostly_used(page) && !mi_page_is_expandable(page)) { + page_candidate = page; + } + // if we find a non-expandable candidate, or searched for N pages, return with the best candidate + if (immediate_available || candidate_count > MI_MAX_CANDIDATE_SEARCH) { + mi_assert_internal(page_candidate!=NULL); + break; + } + } + #else + // first-fit algorithm + // If the page contains free blocks, we are done + if (mi_page_immediate_available(page) || mi_page_is_expandable(page)) { + break; // pick this one } - // 3. If the page is completely full, move it to the `mi_pages_full` + // If the page is completely full, move it to the `mi_pages_full` // queue so we don't visit long-lived pages too often. mi_assert_internal(!mi_page_is_in_full(page) && !mi_page_immediate_available(page)); mi_page_to_full(page, pq); + #endif page = next; } // for each page - mi_heap_stat_counter_increase(heap, searches, count); + mi_heap_stat_counter_increase(heap, page_searches, count); + mi_heap_stat_counter_increase(heap, page_searches_count, 1); + + // set the page to the best candidate + if (page_candidate != NULL) { + page = page_candidate; + } + if (page != NULL) { + if (!mi_page_immediate_available(page)) { + mi_assert_internal(mi_page_is_expandable(page)); + if (!mi_page_extend_free(heap, page, heap->tld)) { + page = NULL; // failed to extend + } + } + mi_assert_internal(page == NULL || mi_page_immediate_available(page)); + } if (page == NULL) { - _PyMem_mi_heap_collect_qsbr(heap); // some pages might be safe to free now + _PyMem_mi_heap_collect_qsbr(heap); // CPython: some pages might be safe to free now _mi_heap_collect_retired(heap, false); // perhaps make a page available? page = mi_page_fresh(heap, pq); if (page == NULL && first_try) { @@ -790,11 +911,15 @@ static mi_page_t* mi_page_queue_find_free_ex(mi_heap_t* heap, mi_page_queue_t* p } } else { - mi_assert(pq->first == page); + // move the page to the front of the queue + mi_page_queue_move_to_front(heap, pq, page); page->retire_expire = 0; _PyMem_mi_page_clear_qsbr(page); + // _mi_heap_collect_retired(heap, false); // update retire counts; note: increases rss on MemoryLoad bench so don't do this } mi_assert_internal(page == NULL || mi_page_immediate_available(page)); + + return page; } @@ -802,10 +927,12 @@ static mi_page_t* mi_page_queue_find_free_ex(mi_heap_t* heap, mi_page_queue_t* p // Find a page with free blocks of `size`. static inline mi_page_t* mi_find_free_page(mi_heap_t* heap, size_t size) { - mi_page_queue_t* pq = mi_page_queue(heap,size); + mi_page_queue_t* pq = mi_page_queue(heap, size); + + // check the first page: we even do this with candidate search or otherwise we re-search every time mi_page_t* page = pq->first; if (page != NULL) { - #if (MI_SECURE>=3) // in secure mode, we extend half the time to increase randomness + #if (MI_SECURE>=2) // in secure mode, we extend half the time to increase randomness if (page->capacity < page->reserved && ((_mi_heap_random_next(heap) & 1) == 1)) { mi_page_extend_free(heap, page, heap->tld); mi_assert_internal(mi_page_immediate_available(page)); @@ -822,6 +949,7 @@ static inline mi_page_t* mi_find_free_page(mi_heap_t* heap, size_t size) { return page; // fast path } } + return mi_page_queue_find_free_ex(heap, pq, true); } @@ -833,21 +961,24 @@ static inline mi_page_t* mi_find_free_page(mi_heap_t* heap, size_t size) { a certain number of allocations. ----------------------------------------------------------- */ -static mi_deferred_free_fun* volatile deferred_free = NULL; -static _Atomic(void*) deferred_arg; // = NULL +// The program should only install a single deferred free handler before doing allocation. +static _Atomic(void*) deferred_free; // is `mi_deferred_free_fun*` (but some platforms don't support atomic function pointers) +static _Atomic(void*) deferred_arg; void _mi_deferred_free(mi_heap_t* heap, bool force) { heap->tld->heartbeat++; - if (deferred_free != NULL && !heap->tld->recurse) { + mi_deferred_free_fun* const fun = (mi_deferred_free_fun*)mi_atomic_load_ptr_acquire(void,&deferred_free); + if (fun != NULL && !heap->tld->recurse) { heap->tld->recurse = true; - deferred_free(force, heap->tld->heartbeat, mi_atomic_load_ptr_relaxed(void,&deferred_arg)); + void* const arg = mi_atomic_load_ptr_acquire(void,&deferred_arg); + fun(force, heap->tld->heartbeat, arg); heap->tld->recurse = false; } } void mi_register_deferred_free(mi_deferred_free_fun* fn, void* arg) mi_attr_noexcept { - deferred_free = fn; mi_atomic_store_ptr_release(void,&deferred_arg, arg); + mi_atomic_store_ptr_release(void,&deferred_free, (void*)fn); } @@ -856,11 +987,9 @@ void mi_register_deferred_free(mi_deferred_free_fun* fn, void* arg) mi_attr_noex ----------------------------------------------------------- */ // Large and huge page allocation. -// Huge pages are allocated directly without being in a queue. -// Because huge pages contain just one block, and the segment contains -// just that page, we always treat them as abandoned and any thread -// that frees the block can free the whole page and segment directly. -// Huge pages are also use if the requested alignment is very large (> MI_ALIGNMENT_MAX). +// Huge pages contain just one block, and the segment contains just that page (as `MI_SEGMENT_HUGE`). +// Huge pages are also use if the requested alignment is very large (> MI_BLOCK_ALIGNMENT_MAX) +// so their size is not always `> MI_LARGE_OBJ_SIZE_MAX`. static mi_page_t* mi_large_huge_page_alloc(mi_heap_t* heap, size_t size, size_t page_alignment) { size_t block_size = _mi_os_good_alloc_size(size); mi_assert_internal(mi_bin(block_size) == MI_BIN_HUGE || page_alignment > 0); @@ -868,7 +997,7 @@ static mi_page_t* mi_large_huge_page_alloc(mi_heap_t* heap, size_t size, size_t #if MI_HUGE_PAGE_ABANDON mi_page_queue_t* pq = (is_huge ? NULL : mi_page_queue(heap, block_size)); #else - mi_page_queue_t* pq = mi_page_queue(heap, is_huge ? MI_HUGE_BLOCK_SIZE : block_size); // not block_size as that can be low if the page_alignment > 0 + mi_page_queue_t* pq = mi_page_queue(heap, is_huge ? MI_LARGE_OBJ_SIZE_MAX+1 : block_size); mi_assert_internal(!is_huge || mi_page_queue_is_huge(pq)); #endif mi_page_t* page = mi_page_fresh_alloc(heap, pq, block_size, page_alignment); @@ -876,6 +1005,7 @@ static mi_page_t* mi_large_huge_page_alloc(mi_heap_t* heap, size_t size, size_t mi_assert_internal(mi_page_immediate_available(page)); if (is_huge) { + mi_assert_internal(mi_page_is_huge(page)); mi_assert_internal(_mi_page_segment(page)->kind == MI_SEGMENT_HUGE); mi_assert_internal(_mi_page_segment(page)->used==1); #if MI_HUGE_PAGE_ABANDON @@ -884,17 +1014,18 @@ static mi_page_t* mi_large_huge_page_alloc(mi_heap_t* heap, size_t size, size_t #endif } else { - mi_assert_internal(_mi_page_segment(page)->kind != MI_SEGMENT_HUGE); + mi_assert_internal(!mi_page_is_huge(page)); } const size_t bsize = mi_page_usable_block_size(page); // note: not `mi_page_block_size` to account for padding - if (bsize <= MI_LARGE_OBJ_SIZE_MAX) { - mi_heap_stat_increase(heap, large, bsize); - mi_heap_stat_counter_increase(heap, large_count, 1); + /*if (bsize <= MI_LARGE_OBJ_SIZE_MAX) { + mi_heap_stat_increase(heap, malloc_large, bsize); + mi_heap_stat_counter_increase(heap, malloc_large_count, 1); } - else { - mi_heap_stat_increase(heap, huge, bsize); - mi_heap_stat_counter_increase(heap, huge_count, 1); + else */ + { + _mi_stat_increase(&heap->tld->stats.malloc_huge, bsize); + _mi_stat_counter_increase(&heap->tld->stats.malloc_huge_count, 1); } } return page; @@ -907,12 +1038,12 @@ static mi_page_t* mi_find_page(mi_heap_t* heap, size_t size, size_t huge_alignme // huge allocation? const size_t req_size = size - MI_PADDING_SIZE; // correct for padding_size in case of an overflow on `size` if mi_unlikely(req_size > (MI_MEDIUM_OBJ_SIZE_MAX - MI_PADDING_SIZE) || huge_alignment > 0) { - if mi_unlikely(req_size > PTRDIFF_MAX) { // we don't allocate more than PTRDIFF_MAX (see ) + if mi_unlikely(req_size > MI_MAX_ALLOC_SIZE) { _mi_error_message(EOVERFLOW, "allocation request is too large (%zu bytes)\n", req_size); return NULL; } else { - _PyMem_mi_heap_collect_qsbr(heap); + _PyMem_mi_heap_collect_qsbr(heap); // CPython return mi_large_huge_page_alloc(heap,size,huge_alignment); } } @@ -927,9 +1058,9 @@ static mi_page_t* mi_find_page(mi_heap_t* heap, size_t size, size_t huge_alignme // Generic allocation routine if the fast path (`alloc.c:mi_page_malloc`) does not succeed. // Note: in debug mode the size includes MI_PADDING_SIZE and might have overflowed. -// The `huge_alignment` is normally 0 but is set to a multiple of MI_SEGMENT_SIZE for -// very large requested alignments in which case we use a huge segment. -void* _mi_malloc_generic(mi_heap_t* heap, size_t size, bool zero, size_t huge_alignment) mi_attr_noexcept +// The `huge_alignment` is normally 0 but is set to a multiple of MI_SLICE_SIZE for +// very large requested alignments in which case we use a huge singleton page. +void* _mi_malloc_generic(mi_heap_t* heap, size_t size, bool zero, size_t huge_alignment, mi_page_t** ppage) mi_attr_noexcept { mi_assert_internal(heap != NULL); @@ -940,12 +1071,27 @@ void* _mi_malloc_generic(mi_heap_t* heap, size_t size, bool zero, size_t huge_al } mi_assert_internal(mi_heap_is_initialized(heap)); - // call potential deferred free routines - _mi_deferred_free(heap, false); - - // free delayed frees from other threads (but skip contended ones) + // Process delayed frees from other threads (but skip contended ones). + // CPython: gh-161420 showed that calling _mi_heap_delayed_free_partial only + // once every 100 generic malloc calls led to high memory usage. + // To avoid this, we now process delayed frees on every generic malloc call again. _mi_heap_delayed_free_partial(heap); + // do administrative tasks every N generic mallocs + if mi_unlikely(++heap->generic_count >= 100) { + heap->generic_collect_count += heap->generic_count; + heap->generic_count = 0; + // call potential deferred free routines + _mi_deferred_free(heap, false); + + // collect every once in a while (10000 by default) + const long generic_collect = mi_option_get_clamp(mi_option_generic_collect, 1, 1000000L); + if (heap->generic_collect_count >= generic_collect) { + heap->generic_collect_count = 0; + mi_heap_collect(heap, false /* force? */); + } + } + // find (or allocate) a page of the right size mi_page_t* page = mi_find_page(heap, size, huge_alignment); if mi_unlikely(page == NULL) { // first time out of memory, try to collect and retry the allocation once more @@ -963,14 +1109,12 @@ void* _mi_malloc_generic(mi_heap_t* heap, size_t size, bool zero, size_t huge_al mi_assert_internal(mi_page_block_size(page) >= size); // and try again, this time succeeding! (i.e. this should never recurse through _mi_page_malloc) - if mi_unlikely(zero && page->xblock_size == 0) { - // note: we cannot call _mi_page_malloc with zeroing for huge blocks; we zero it afterwards in that case. - void* p = _mi_page_malloc(heap, page, size, false); - mi_assert_internal(p != NULL); - _mi_memzero_aligned(p, mi_page_usable_block_size(page)); - return p; - } - else { - return _mi_page_malloc(heap, page, size, zero); + void* const p = _mi_page_malloc_zero(heap, page, size, zero, ppage); + mi_assert_internal(p != NULL); + + // move singleton pages to the full queue + if (page->reserved == page->used) { + mi_page_to_full(page, mi_page_queue_of(page)); } + return p; } diff --git a/Objects/mimalloc/prim/emscripten/prim.c b/Objects/mimalloc/prim/emscripten/prim.c new file mode 100644 index 000000000000000..fc46108e10f08aa --- /dev/null +++ b/Objects/mimalloc/prim/emscripten/prim.c @@ -0,0 +1,253 @@ +/* ---------------------------------------------------------------------------- +Copyright (c) 2018-2025, Microsoft Research, Daan Leijen, Alon Zakai +This is free software; you can redistribute it and/or modify it under the +terms of the MIT license. A copy of the license can be found in the file +"LICENSE" at the root of this distribution. +-----------------------------------------------------------------------------*/ + +// This file is included in `src/prim/prim.c` + +#include "mimalloc.h" +#include "mimalloc/internal.h" +#include "mimalloc/atomic.h" +#include "mimalloc/prim.h" + +#include // getentropy + +// Design +// ====== +// +// mimalloc is built on top of emmalloc. emmalloc is a minimal allocator on top +// of sbrk. The reason for having three layers here is that we want mimalloc to +// be able to allocate and release system memory properly, the same way it would +// when using VirtualAlloc on Windows or mmap on POSIX, and sbrk is too limited. +// Specifically, sbrk can only go up and down, and not "skip" over regions, and +// so we end up either never freeing memory to the system, or we can get stuck +// with holes. +// +// Atm wasm generally does *not* free memory back the system: once grown, we do +// not shrink back down (https://github.com/WebAssembly/design/issues/1397). +// However, that is expected to improve +// (https://github.com/WebAssembly/memory-control/blob/main/proposals/memory-control/Overview.md) +// and so we do not want to bake those limitations in here. +// +// Even without that issue, we want our system allocator to handle holes, that +// is, it should merge freed regions and allow allocating new content there of +// the full size, etc., so that we do not waste space. That means that the +// system allocator really does need to handle the general problem of allocating +// and freeing variable-sized chunks of memory in a random order, like malloc/ +// free do. And so it makes sense to layer mimalloc on top of such an +// implementation. +// +// emmalloc makes sense for the lower level because it is small and simple while +// still fully handling merging of holes etc. It is not the most efficient +// allocator, but our assumption is that mimalloc needs to be fast while the +// system allocator underneath it is called much less frequently. +// + +//--------------------------------------------- +// init +//--------------------------------------------- + +void _mi_prim_mem_init( mi_os_mem_config_t* config) { + config->page_size = 64*MI_KiB; // WebAssembly has a fixed page size: 64KiB + config->alloc_granularity = 16; + config->has_overcommit = false; + config->has_partial_free = false; + config->has_virtual_reserve = false; +} + +extern void emmalloc_free(void*); + +int _mi_prim_free(void* addr, size_t size) { + emmalloc_free(addr); + return 0; +} + + +//--------------------------------------------- +// Allocation +//--------------------------------------------- + +extern void* emmalloc_memalign(size_t alignment, size_t size); + +// Note: the `try_alignment` is just a hint and the returned pointer is not guaranteed to be aligned. +int _mi_prim_alloc(void* hint_addr, size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large, bool* is_zero, void** addr) { + MI_UNUSED(try_alignment); MI_UNUSED(allow_large); MI_UNUSED(commit); MI_UNUSED(hint_addr); + *is_large = false; + // TODO: Track the highest address ever seen; first uses of it are zeroes. + // That assumes no one else uses sbrk but us (they could go up, + // scribble, and then down), but we could assert on that perhaps. + *is_zero = false; + // emmalloc has a minimum alignment size. + #define MIN_EMMALLOC_ALIGN 8 + if (try_alignment < MIN_EMMALLOC_ALIGN) { + try_alignment = MIN_EMMALLOC_ALIGN; + } + void* p = emmalloc_memalign(try_alignment, size); + *addr = p; + if (p == 0) { + return ENOMEM; + } + return 0; +} + + +//--------------------------------------------- +// Commit/Reset +//--------------------------------------------- + +int _mi_prim_commit(void* addr, size_t size, bool* is_zero) { + MI_UNUSED(addr); MI_UNUSED(size); + // See TODO above. + *is_zero = false; + return 0; +} + +int _mi_prim_decommit(void* addr, size_t size, bool* needs_recommit) { + MI_UNUSED(addr); MI_UNUSED(size); + *needs_recommit = false; + return 0; +} + +int _mi_prim_reset(void* addr, size_t size) { + MI_UNUSED(addr); MI_UNUSED(size); + return 0; +} + +int _mi_prim_reuse(void* addr, size_t size) { + MI_UNUSED(addr); MI_UNUSED(size); + return 0; +} + +int _mi_prim_protect(void* addr, size_t size, bool protect) { + MI_UNUSED(addr); MI_UNUSED(size); MI_UNUSED(protect); + return 0; +} + + +//--------------------------------------------- +// Huge pages and NUMA nodes +//--------------------------------------------- + +int _mi_prim_alloc_huge_os_pages(void* hint_addr, size_t size, int numa_node, bool* is_zero, void** addr) { + MI_UNUSED(hint_addr); MI_UNUSED(size); MI_UNUSED(numa_node); + *is_zero = true; + *addr = NULL; + return ENOSYS; +} + +size_t _mi_prim_numa_node(void) { + return 0; +} + +size_t _mi_prim_numa_node_count(void) { + return 1; +} + + +//---------------------------------------------------------------- +// Clock +//---------------------------------------------------------------- + +#include + +mi_msecs_t _mi_prim_clock_now(void) { + // todo: use a monotonic clock instead + return emscripten_date_now(); +} + + +//---------------------------------------------------------------- +// Process info +//---------------------------------------------------------------- + +void _mi_prim_process_info(mi_process_info_t* pinfo) +{ + // use defaults + MI_UNUSED(pinfo); +} + + +//---------------------------------------------------------------- +// Output +//---------------------------------------------------------------- + +#include + +void _mi_prim_out_stderr( const char* msg) { + emscripten_console_error(msg); +} + + +//---------------------------------------------------------------- +// Environment +//---------------------------------------------------------------- + +int _mi_prim_getenv(const char* name, char* result, size_t result_size) { + // For code size reasons, do not support environ customization for now. + MI_UNUSED(name); + MI_UNUSED(result); + MI_UNUSED(result_size); + return 0; // not found +} + + +//---------------------------------------------------------------- +// Random +//---------------------------------------------------------------- + +bool _mi_prim_random_buf(void* buf, size_t buf_len) { + int err = getentropy(buf, buf_len); + return !err; +} + + +//---------------------------------------------------------------- +// Thread init/done +//---------------------------------------------------------------- + +#if defined(MI_USE_PTHREADS) + +// use pthread local storage keys to detect thread ending +// (and used with MI_TLS_PTHREADS for the default heap) +pthread_key_t _mi_heap_default_key = (pthread_key_t)(-1); + +static void mi_pthread_done(void* value) { + if (value!=NULL) { + _mi_thread_done((mi_heap_t*)value); + } +} + +void _mi_prim_thread_init_auto_done(void) { + mi_assert_internal(_mi_heap_default_key == (pthread_key_t)(-1)); + pthread_key_create(&_mi_heap_default_key, &mi_pthread_done); +} + +void _mi_prim_thread_done_auto_done(void) { + if (_mi_heap_default_key != (pthread_key_t)(-1)) { // do not leak the key, see issue #809 + pthread_key_delete(_mi_heap_default_key); + } +} + +void _mi_prim_thread_associate_default_heap(mi_heap_t* heap) { + if (_mi_heap_default_key != (pthread_key_t)(-1)) { // can happen during recursive invocation on freeBSD + pthread_setspecific(_mi_heap_default_key, heap); + } +} + +#else + +void _mi_prim_thread_init_auto_done(void) { + // nothing +} + +void _mi_prim_thread_done_auto_done(void) { + // nothing +} + +void _mi_prim_thread_associate_default_heap(mi_heap_t* heap) { + MI_UNUSED(heap); + +} +#endif diff --git a/Objects/mimalloc/prim/osx/alloc-override-zone.c b/Objects/mimalloc/prim/osx/alloc-override-zone.c index 0e0a99d9388c8ac..9c14048602e4c10 100644 --- a/Objects/mimalloc/prim/osx/alloc-override-zone.c +++ b/Objects/mimalloc/prim/osx/alloc-override-zone.c @@ -41,10 +41,19 @@ extern malloc_zone_t* malloc_default_purgeable_zone(void) __attribute__((weak_im malloc zone members ------------------------------------------------------ */ +static bool is_mimalloc_zone( malloc_zone_t* zone ); + static size_t zone_size(malloc_zone_t* zone, const void* p) { MI_UNUSED(zone); - if (!mi_is_in_heap_region(p)){ return 0; } // not our pointer, bail out - return mi_usable_size(p); + if (mi_is_in_heap_region(p)) { + return mi_usable_size(p); + } + else if (!is_mimalloc_zone(zone)) { // can happen due to interpose + return zone->size(zone,p); + } + else { + return 0; + } } static void* zone_malloc(malloc_zone_t* zone, size_t size) { @@ -63,13 +72,24 @@ static void* zone_valloc(malloc_zone_t* zone, size_t size) { } static void zone_free(malloc_zone_t* zone, void* p) { - MI_UNUSED(zone); - mi_cfree(p); + if (mi_is_in_heap_region(p)) { + mi_free(p); + } + else if (!is_mimalloc_zone(zone)) { // can happen due to interpose + zone->free(zone,p); + } } static void* zone_realloc(malloc_zone_t* zone, void* p, size_t newsize) { - MI_UNUSED(zone); - return mi_realloc(p, newsize); + if (p == NULL || mi_is_in_heap_region(p)) { + return mi_realloc(p, newsize); + } + else if (!is_mimalloc_zone(zone)) { // can happen due to interpose + return zone->realloc(zone,p,newsize); + } + else { + return NULL; + } } static void* zone_memalign(malloc_zone_t* zone, size_t alignment, size_t size) { @@ -78,12 +98,13 @@ static void* zone_memalign(malloc_zone_t* zone, size_t alignment, size_t size) { } static void zone_destroy(malloc_zone_t* zone) { - MI_UNUSED(zone); - // todo: ignore for now? + if (!is_mimalloc_zone(zone)) { + zone->destroy(zone); + } } static unsigned zone_batch_malloc(malloc_zone_t* zone, size_t size, void** ps, unsigned count) { - size_t i; + unsigned i; for (i = 0; i < count; i++) { ps[i] = zone_malloc(zone, size); if (ps[i] == NULL) break; @@ -114,7 +135,6 @@ static boolean_t zone_claimed_address(malloc_zone_t* zone, void* p) { return mi_is_in_heap_region(p); } - /* ------------------------------------------------------ Introspection members ------------------------------------------------------ */ @@ -174,6 +194,14 @@ static boolean_t intro_zone_locked(malloc_zone_t* zone) { return false; } +// Required whenever the zone advertises version >= 9: macOS calls this from the +// atfork_child handler (_malloc_fork_child) without a NULL check. mimalloc keeps +// no zone-level locks that need reinitializing after fork, so a no-op is safe. +// Leaving it NULL makes the forked child jump to address 0 and crash in fork(). +static void intro_reinit_lock(malloc_zone_t* zone) { + MI_UNUSED(zone); +} + /* ------------------------------------------------------ At process start, override the default allocator @@ -199,6 +227,9 @@ static malloc_introspection_t mi_introspect = { .statistics = &intro_statistics, .zone_locked = &intro_zone_locked, #endif +#if defined(MAC_OS_X_VERSION_10_12) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12) && !defined(__ppc__) + .reinit_lock = &intro_reinit_lock, +#endif }; static malloc_zone_t mi_malloc_zone = { @@ -225,7 +256,9 @@ static malloc_zone_t mi_malloc_zone = { // switch to version 9+ on OSX 10.6 to support memalign. .memalign = &zone_memalign, .free_definite_size = &zone_free_definite_size, + #if defined(MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) .pressure_relief = &zone_pressure_relief, + #endif #if defined(MAC_OS_X_VERSION_10_14) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14) .claimed_address = &zone_claimed_address, #endif @@ -234,6 +267,11 @@ static malloc_zone_t mi_malloc_zone = { #endif }; +static bool is_mimalloc_zone( malloc_zone_t* zone ) { + return (zone==NULL || zone==&mi_malloc_zone); +} + + #ifdef __cplusplus } #endif @@ -251,11 +289,8 @@ static malloc_zone_t mi_malloc_zone = { // `malloc_zone_calloc` etc. see // ------------------------------------------------------ -static inline malloc_zone_t* mi_get_default_zone(void) -{ - static bool init; - if mi_unlikely(!init) { - init = true; +static inline malloc_zone_t* mi_get_default_zone(void) { + mi_atomic_do_once { malloc_zone_register(&mi_malloc_zone); // by calling register we avoid a zone error on free (see ) } return &mi_malloc_zone; @@ -326,7 +361,7 @@ static bool zone_check(malloc_zone_t* zone) { static malloc_zone_t* zone_from_ptr(const void* p) { MI_UNUSED(p); - return mi_get_default_zone(); + return (mi_is_in_heap_region(p) ? mi_get_default_zone() : NULL); } static void zone_log(malloc_zone_t* zone, void* p) { @@ -416,10 +451,11 @@ static inline malloc_zone_t* mi_get_default_zone(void) } #if defined(__clang__) -__attribute__((constructor(0))) +__attribute__((constructor(101))) // highest priority #else -__attribute__((constructor)) // seems not supported by g++-11 on the M1 +__attribute__((constructor)) // priority level is not supported by gcc #endif +__attribute__((used)) static void _mi_macos_override_malloc(void) { malloc_zone_t* purgeable_zone = NULL; diff --git a/Objects/mimalloc/prim/prim.c b/Objects/mimalloc/prim/prim.c index 9a597d8eb603e9d..b7a5af94e4fb4e6 100644 --- a/Objects/mimalloc/prim/prim.c +++ b/Objects/mimalloc/prim/prim.c @@ -18,7 +18,60 @@ terms of the MIT license. A copy of the license can be found in the file #define MI_USE_SBRK #include "wasi/prim.c" // memory-grow or sbrk (Wasm) +// CPython: use the unix prim on Emscripten (emmalloc is not linked) +#elif defined(__EMSCRIPTEN__) && 0 +#include "emscripten/prim.c" // emmalloc_*, + pthread support + #else #include "unix/prim.c" // mmap() (Linux, macOSX, BSD, Illumnos, Haiku, DragonFly, etc.) #endif + +// Generic process initialization +#ifndef MI_PRIM_HAS_PROCESS_ATTACH +#if defined(__GNUC__) || defined(__clang__) + // gcc,clang: use the constructor/destructor attribute + // which for both seem to run before regular constructors/destructors + #if defined(__clang__) + #define mi_attr_constructor __attribute__((constructor(101))) + #define mi_attr_destructor __attribute__((destructor(101))) + #else + #define mi_attr_constructor __attribute__((constructor)) + #define mi_attr_destructor __attribute__((destructor)) + #endif + static void mi_attr_constructor mi_process_attach(void) { + _mi_auto_process_init(); + } + static void mi_attr_destructor mi_process_detach(void) { + _mi_auto_process_done(); + } +#elif defined(__cplusplus) + // C++: use static initialization to detect process start/end + // This is not guaranteed to be first/last but the best we can generally do? + struct mi_init_done_t { + mi_init_done_t() { + _mi_auto_process_init(); + } + ~mi_init_done_t() { + _mi_auto_process_done(); + } + }; + static mi_init_done_t mi_init_done; + #else + #pragma message("define a way to call _mi_auto_process_init/done on your platform") +#endif +#endif + +// Generic allocator init/done callback +#ifndef MI_PRIM_HAS_ALLOCATOR_INIT +bool _mi_is_redirected(void) { + return false; +} +bool _mi_allocator_init(const char** message) { + if (message != NULL) { *message = NULL; } + return true; +} +void _mi_allocator_done(void) { + // nothing to do +} +#endif diff --git a/Objects/mimalloc/prim/unix/prim.c b/Objects/mimalloc/prim/unix/prim.c index 6f78eb72789e8e5..477e2d8b2274c46 100644 --- a/Objects/mimalloc/prim/unix/prim.c +++ b/Objects/mimalloc/prim/unix/prim.c @@ -1,5 +1,5 @@ /* ---------------------------------------------------------------------------- -Copyright (c) 2018-2023, Microsoft Research, Daan Leijen +Copyright (c) 2018-2025, Microsoft Research, Daan Leijen This is free software; you can redistribute it and/or modify it under the terms of the MIT license. A copy of the license can be found in the file "LICENSE" at the root of this distribution. @@ -22,26 +22,35 @@ terms of the MIT license. A copy of the license can be found in the file #include "mimalloc.h" #include "mimalloc/internal.h" -#include "mimalloc/atomic.h" #include "mimalloc/prim.h" #include // mmap #include // sysconf #include // open, close, read, access +#include // getenv, arc4random_buf #if defined(__linux__) #include - #include + #include // THP disable, PR_SET_VMA + #include // sysinfo + #if defined(__GLIBC__) && !defined(PR_SET_VMA) + #include + #endif #if defined(__GLIBC__) - #include // linux mmap flags + #include // linux mmap flags #else #include #endif #elif defined(__APPLE__) + #include #include - #if !TARGET_IOS_IPHONE && !TARGET_IOS_SIMULATOR - #include + #if !defined(TARGET_OS_OSX) || TARGET_OS_OSX // see issue #879, used to be (!TARGET_IOS_IPHONE && !TARGET_IOS_SIMULATOR) + #include // VM_MAKE_TAG, VM_FLAGS_SUPERPAGE_SIZE_2MB, etc. + #endif + #if !defined(MAC_OS_X_VERSION_10_7) + #define MAC_OS_X_VERSION_10_7 1070 #endif + #include #elif defined(__FreeBSD__) || defined(__DragonFly__) #include #if __FreeBSD_version >= 1200000 @@ -51,44 +60,55 @@ terms of the MIT license. A copy of the license can be found in the file #include #endif -#if !defined(__HAIKU__) && !defined(__APPLE__) && !defined(__CYGWIN__) && !defined(_AIX) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__sun) && !defined(__NetBSD__) +#if (defined(__linux__) && !defined(__ANDROID__)) || defined(__FreeBSD__) #define MI_HAS_SYSCALL_H #include #endif +#if !defined(MADV_DONTNEED) && defined(POSIX_MADV_DONTNEED) // QNX +#define MADV_DONTNEED POSIX_MADV_DONTNEED +#endif +#if !defined(MADV_FREE) && defined(POSIX_MADV_FREE) // QNX +#define MADV_FREE POSIX_MADV_FREE +#endif + +#define MI_UNIX_LARGE_PAGE_SIZE (2*MI_MiB) // TODO: can we query the OS for this? + //------------------------------------------------------------------------------------ // Use syscalls for some primitives to allow for libraries that override open/read/close etc. // and do allocation themselves; using syscalls prevents recursion when mimalloc is // still initializing (issue #713) +// Not used on Android, see issue python/cpython/pull/158530 +// Declare inline to avoid unused function warnings. //------------------------------------------------------------------------------------ -#if defined(MI_HAS_SYSCALL_H) && defined(SYS_open) && defined(SYS_close) && defined(SYS_read) && defined(SYS_access) +#if defined(MI_HAS_SYSCALL_H) && defined(SYS_open) && defined(SYS_close) && defined(SYS_read) && defined(SYS_access) && !defined(__ANDROID__) -static int mi_prim_open(const char* fpath, int open_flags) { +static inline int mi_prim_open(const char* fpath, int open_flags) { return syscall(SYS_open,fpath,open_flags,0); } -static ssize_t mi_prim_read(int fd, void* buf, size_t bufsize) { +static inline ssize_t mi_prim_read(int fd, void* buf, size_t bufsize) { return syscall(SYS_read,fd,buf,bufsize); } -static int mi_prim_close(int fd) { +static inline int mi_prim_close(int fd) { return syscall(SYS_close,fd); } -static int mi_prim_access(const char *fpath, int mode) { +static inline int mi_prim_access(const char *fpath, int mode) { return syscall(SYS_access,fpath,mode); } -#elif !defined(__APPLE__) && !defined(_AIX) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__sun) && !defined(__NetBSD__) // avoid unused warnings +#else -static int mi_prim_open(const char* fpath, int open_flags) { +static inline int mi_prim_open(const char* fpath, int open_flags) { return open(fpath,open_flags); } -static ssize_t mi_prim_read(int fd, void* buf, size_t bufsize) { +static inline ssize_t mi_prim_read(int fd, void* buf, size_t bufsize) { return read(fd,buf,bufsize); } -static int mi_prim_close(int fd) { +static inline int mi_prim_close(int fd) { return close(fd); } -static int mi_prim_access(const char *fpath, int mode) { +static inline int mi_prim_access(const char *fpath, int mode) { return access(fpath,mode); } @@ -102,40 +122,96 @@ static int mi_prim_access(const char *fpath, int mode) { static bool unix_detect_overcommit(void) { bool os_overcommit = true; -#if defined(__linux__) - int fd = mi_prim_open("/proc/sys/vm/overcommit_memory", O_RDONLY); - if (fd >= 0) { - char buf[32] = {0}; - ssize_t nread = mi_prim_read(fd, &buf, sizeof(buf)); - mi_prim_close(fd); - // - // 0: heuristic overcommit, 1: always overcommit, 2: never overcommit (ignore NORESERVE) - if (nread >= 1) { - os_overcommit = (buf[0] == '0' || buf[0] == '1'); + #if defined(__linux__) + int fd = mi_prim_open("/proc/sys/vm/overcommit_memory", O_RDONLY); + if (fd >= 0) { + char buf[32] = {0}; // CPython: zero-initialize to avoid an MSAN report + ssize_t nread = mi_prim_read(fd, &buf, sizeof(buf)); + mi_prim_close(fd); + // + // 0: heuristic overcommit, 1: always overcommit, 2: never overcommit (ignore NORESERVE) + if (nread >= 1) { + os_overcommit = (buf[0] == '0' || buf[0] == '1'); + } } - } -#elif defined(__FreeBSD__) - int val = 0; - size_t olen = sizeof(val); - if (sysctlbyname("vm.overcommit", &val, &olen, NULL, 0) == 0) { - os_overcommit = (val != 0); - } -#else - // default: overcommit is true -#endif + #elif defined(__FreeBSD__) + int val = 0; + size_t olen = sizeof(val); + if (sysctlbyname("vm.overcommit", &val, &olen, NULL, 0) == 0) { + os_overcommit = (val != 0); + } + #else + // default: overcommit is true + #endif return os_overcommit; } -void _mi_prim_mem_init( mi_os_mem_config_t* config ) { +// try to detect the physical memory dynamically (if possible) +static void unix_detect_physical_memory( size_t page_size, size_t* physical_memory_in_kib ) { + #if defined(CTL_HW) && (defined(HW_PHYSMEM64) || defined(HW_MEMSIZE)) // freeBSD, macOS + MI_UNUSED(page_size); + int64_t physical_memory = 0; + size_t length = sizeof(int64_t); + #if defined(HW_PHYSMEM64) + int mib[2] = { CTL_HW, HW_PHYSMEM64 }; + #else + int mib[2] = { CTL_HW, HW_MEMSIZE }; + #endif + const int err = sysctl(mib, 2, &physical_memory, &length, NULL, 0); + if (err==0 && physical_memory > 0) { + const int64_t phys_in_kib = physical_memory / MI_KiB; + if (phys_in_kib > 0 && (uint64_t)phys_in_kib <= SIZE_MAX) { + *physical_memory_in_kib = (size_t)phys_in_kib; + } + } + #elif defined(__linux__) + MI_UNUSED(page_size); + struct sysinfo info; _mi_memzero_var(info); + const int err = sysinfo(&info); + if (err==0 && info.mem_unit > 0 && info.totalram <= SIZE_MAX) { + if (info.mem_unit==MI_KiB) { + *physical_memory_in_kib = (size_t)info.totalram; + } + else { + size_t total = 0; + if (!mi_mul_overflow((size_t)info.totalram, (size_t)info.mem_unit, &total)) { + *physical_memory_in_kib = (total / MI_KiB); + } + } + } + #elif defined(_SC_PHYS_PAGES) // do not use by default as it might cause allocation (by using `fopen` to parse /proc/meminfo) (issue #1100) + const long pphys = sysconf(_SC_PHYS_PAGES); + const size_t psize_in_kib = page_size / MI_KiB; + if (psize_in_kib > 0 && pphys > 0 && (unsigned long)pphys <= SIZE_MAX && (size_t)pphys <= (SIZE_MAX/psize_in_kib)) { + *physical_memory_in_kib = (size_t)pphys * psize_in_kib; + } + #endif +} + +void _mi_prim_mem_init( mi_os_mem_config_t* config ) +{ long psize = sysconf(_SC_PAGESIZE); - if (psize > 0) { + if (psize > 0 && (unsigned long)psize < SIZE_MAX) { config->page_size = (size_t)psize; config->alloc_granularity = (size_t)psize; + unix_detect_physical_memory(config->page_size, &config->physical_memory_in_kib); } - config->large_page_size = 2*MI_MiB; // TODO: can we query the OS for this? + config->large_page_size = MI_UNIX_LARGE_PAGE_SIZE; config->has_overcommit = unix_detect_overcommit(); - config->must_free_whole = false; // mmap can free in parts + config->has_partial_free = true; // mmap can free in parts config->has_virtual_reserve = true; // todo: check if this true for NetBSD? (for anonymous mmap with PROT_NONE) + + // disable transparent huge pages for this process? + #if (defined(__linux__) || defined(__ANDROID__)) && defined(PR_GET_THP_DISABLE) + if (!mi_option_is_enabled(mi_option_allow_thp)) // disable THP if requested through an option + { + if (prctl(PR_GET_THP_DISABLE, 0, 0, 0, 0) == 0) { // -1 on error, 1 if already disabled + // Most likely since distros often come with always/madvise settings. + // Disabling only for mimalloc process rather than touching system wide settings + (void)prctl(PR_SET_THP_DISABLE, 1, 0, 0, 0); + } + } + #endif } @@ -144,6 +220,7 @@ void _mi_prim_mem_init( mi_os_mem_config_t* config ) { //--------------------------------------------- int _mi_prim_free(void* addr, size_t size ) { + if (size==0) return 0; bool err = (munmap(addr, size) == -1); return (err ? errno : 0); } @@ -153,25 +230,40 @@ int _mi_prim_free(void* addr, size_t size ) { // mmap //--------------------------------------------- +// return errno on failure static int unix_madvise(void* addr, size_t size, int advice) { - #if defined(__sun) - return madvise((caddr_t)addr, size, advice); // Solaris needs cast (issue #520) + #if defined(__sun) || defined(_AIX) + const int res = madvise((caddr_t)addr, size, advice); // Solaris needs cast (issue #520) + return (res==0 ? 0 : errno); + #elif defined(__QNX__) + return posix_madvise(addr, size, advice); // posix returns errno #else - return madvise(addr, size, advice); + const int res = madvise(addr, size, advice); // linux returns -1 on failure and sets errno + return (res==0 ? 0 : errno); #endif } -static void* unix_mmap_prim(void* addr, size_t size, size_t try_alignment, int protect_flags, int flags, int fd) { +static void* unix_mmap_prim(void* addr, size_t size, int protect_flags, int flags, int fd) { + void* p = mmap(addr, size, protect_flags, flags, fd, 0 /* offset */); + #if defined(__linux__) && defined(PR_SET_VMA) + if (p!=MAP_FAILED && p!=NULL) { + prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, p, size, "mimalloc"); + } + #endif + return p; +} + +static void* unix_mmap_prim_aligned(void* addr, size_t size, size_t try_alignment, int protect_flags, int flags, int fd) { MI_UNUSED(try_alignment); void* p = NULL; #if defined(MAP_ALIGNED) // BSD if (addr == NULL && try_alignment > 1 && (try_alignment % _mi_os_page_size()) == 0) { size_t n = mi_bsr(try_alignment); if (((size_t)1 << n) == try_alignment && n >= 12 && n <= 30) { // alignment is a power of 2 and 4096 <= alignment <= 1GiB - p = mmap(addr, size, protect_flags, flags | MAP_ALIGNED(n), fd, 0); + p = unix_mmap_prim(addr, size, protect_flags, flags | MAP_ALIGNED(n), fd); if (p==MAP_FAILED || !_mi_is_aligned(p,try_alignment)) { int err = errno; - _mi_verbose_message("unable to directly request aligned OS memory (error: %d (0x%x), size: 0x%zx bytes, alignment: 0x%zx, hint address: %p)\n", err, err, size, try_alignment, addr); + _mi_trace_message("unable to directly request aligned OS memory (error: %d (0x%x), size: 0x%zx bytes, alignment: 0x%zx, hint address: %p)\n", err, err, size, try_alignment, addr); } if (p!=MAP_FAILED) return p; // fall back to regular mmap @@ -179,7 +271,7 @@ static void* unix_mmap_prim(void* addr, size_t size, size_t try_alignment, int p } #elif defined(MAP_ALIGN) // Solaris if (addr == NULL && try_alignment > 1 && (try_alignment % _mi_os_page_size()) == 0) { - p = mmap((void*)try_alignment, size, protect_flags, flags | MAP_ALIGN, fd, 0); // addr parameter is the required alignment + p = unix_mmap_prim((void*)try_alignment, size, protect_flags, flags | MAP_ALIGN, fd); // addr parameter is the required alignment if (p!=MAP_FAILED) return p; // fall back to regular mmap } @@ -189,14 +281,14 @@ static void* unix_mmap_prim(void* addr, size_t size, size_t try_alignment, int p if (addr == NULL) { void* hint = _mi_os_get_aligned_hint(try_alignment, size); if (hint != NULL) { - p = mmap(hint, size, protect_flags, flags, fd, 0); + p = unix_mmap_prim(hint, size, protect_flags, flags, fd); if (p==MAP_FAILED || !_mi_is_aligned(p,try_alignment)) { #if MI_TRACK_ENABLED // asan sometimes does not instrument errno correctly? int err = 0; #else int err = errno; #endif - _mi_verbose_message("unable to directly request hinted aligned OS memory (error: %d (0x%x), size: 0x%zx bytes, alignment: 0x%zx, hint address: %p)\n", err, err, size, try_alignment, hint); + _mi_trace_message("unable to directly request hinted aligned OS memory (error: %d (0x%x), size: 0x%zx bytes, alignment: 0x%zx, hint address: %p)\n", err, err, size, try_alignment, hint); } if (p!=MAP_FAILED) return p; // fall back to regular mmap @@ -204,7 +296,7 @@ static void* unix_mmap_prim(void* addr, size_t size, size_t try_alignment, int p } #endif // regular mmap - p = mmap(addr, size, protect_flags, flags, fd, 0); + p = unix_mmap_prim(addr, size, protect_flags, flags, fd); if (p!=MAP_FAILED) return p; // failed to allocate return NULL; @@ -214,13 +306,17 @@ static int unix_mmap_fd(void) { #if defined(VM_MAKE_TAG) // macOS: tracking anonymous page with a specific ID. (All up to 98 are taken officially but LLVM sanitizers had taken 99) int os_tag = (int)mi_option_get(mi_option_os_tag); - if (os_tag < 100 || os_tag > 255) { os_tag = 100; } + if (os_tag < 100 || os_tag > 255) { os_tag = 254; } return VM_MAKE_TAG(os_tag); #else return -1; #endif } +#if defined(MAP_ALIGNED_SUPER) || defined(MAP_HUGETLB) || defined(MAP_HUGE_1GB) || defined(MAP_HUGE_2MB) || defined(VM_FLAGS_SUPERPAGE_SIZE_2MB) +#define MI_OS_HAS_HUGE_PAGES 1 +#endif + static void* unix_mmap(void* addr, size_t size, size_t try_alignment, int protect_flags, bool large_only, bool allow_large, bool* is_large) { #if !defined(MAP_ANONYMOUS) #define MAP_ANONYMOUS MAP_ANON @@ -238,7 +334,8 @@ static void* unix_mmap(void* addr, size_t size, size_t try_alignment, int protec protect_flags |= PROT_MAX(PROT_READ | PROT_WRITE); // BSD #endif // huge page allocation - if ((large_only || _mi_os_use_large_page(size, try_alignment)) && allow_large) { + #if MI_OS_HAS_HUGE_PAGES + if (allow_large && (large_only || (_mi_os_canuse_large_page(size, try_alignment) && mi_option_is_enabled(mi_option_allow_large_os_pages)))) { static _Atomic(size_t) large_page_try_ok; // = 0; size_t try_ok = mi_atomic_load_acquire(&large_page_try_ok); if (!large_only && try_ok > 0) { @@ -258,8 +355,8 @@ static void* unix_mmap(void* addr, size_t size, size_t try_alignment, int protec lflags |= MAP_HUGETLB; #endif #ifdef MAP_HUGE_1GB - static bool mi_huge_pages_available = true; - if ((size % MI_GiB) == 0 && mi_huge_pages_available) { + static _Atomic(size_t) mi_huge_1gib_pages_unavailable; + if (large_only && (size % MI_GiB) == 0 && (mi_atomic_load_relaxed(&mi_huge_1gib_pages_unavailable)==0)) { lflags |= MAP_HUGE_1GB; } else @@ -275,13 +372,15 @@ static void* unix_mmap(void* addr, size_t size, size_t try_alignment, int protec if (large_only || lflags != flags) { // try large OS page allocation *is_large = true; - p = unix_mmap_prim(addr, size, try_alignment, protect_flags, lflags, lfd); + p = unix_mmap_prim_aligned(addr, size, try_alignment, protect_flags, lflags, lfd); #ifdef MAP_HUGE_1GB - if (p == NULL && (lflags & MAP_HUGE_1GB) != 0) { - mi_huge_pages_available = false; // don't try huge 1GiB pages again - _mi_warning_message("unable to allocate huge (1GiB) page, trying large (2MiB) pages instead (errno: %i)\n", errno); + if (p == NULL && (lflags & MAP_HUGE_1GB) == MAP_HUGE_1GB) { + mi_atomic_store_relaxed(&mi_huge_1gib_pages_unavailable,1); // don't try huge 1GiB pages again + if (large_only) { + _mi_warning_message("unable to allocate huge (1GiB) page, trying large (2MiB) pages instead (errno: %i)\n", errno); + } lflags = ((lflags & ~MAP_HUGE_1GB) | MAP_HUGE_2MB); - p = unix_mmap_prim(addr, size, try_alignment, protect_flags, lflags, lfd); + p = unix_mmap_prim_aligned(addr, size, try_alignment, protect_flags, lflags, lfd); } #endif if (large_only) return p; @@ -290,12 +389,14 @@ static void* unix_mmap(void* addr, size_t size, size_t try_alignment, int protec } } } - } + } // huge pages + #endif // regular allocation if (p == NULL) { *is_large = false; - p = unix_mmap_prim(addr, size, try_alignment, protect_flags, flags, fd); - if (p != NULL) { + p = unix_mmap_prim_aligned(addr, size, try_alignment, protect_flags, flags, fd); + #if !defined(MI_NO_THP) + if (p != NULL && mi_option_is_enabled(mi_option_allow_thp) && _mi_os_canuse_large_page(size, try_alignment)) { #if defined(MADV_HUGEPAGE) // Many Linux systems don't allow MAP_HUGETLB but they support instead // transparent huge pages (THP). Generally, it is not required to call `madvise` with MADV_HUGE @@ -303,35 +404,31 @@ static void* unix_mmap(void* addr, size_t size, size_t try_alignment, int protec // in that case -- in particular for our large regions (in `memory.c`). // However, some systems only allow THP if called with explicit `madvise`, so // when large OS pages are enabled for mimalloc, we call `madvise` anyways. - if (allow_large && _mi_os_use_large_page(size, try_alignment)) { - if (unix_madvise(p, size, MADV_HUGEPAGE) == 0) { - *is_large = true; // possibly - }; - } + if (unix_madvise(p, size, MADV_HUGEPAGE) == 0) { + // *is_large = true; // possibly + }; #elif defined(__sun) - if (allow_large && _mi_os_use_large_page(size, try_alignment)) { - struct memcntl_mha cmd = {0}; - cmd.mha_pagesize = 2*MI_MiB; - cmd.mha_cmd = MHA_MAPSIZE_VA; - if (memcntl((caddr_t)p, size, MC_HAT_ADVISE, (caddr_t)&cmd, 0, 0) == 0) { - *is_large = true; - } + struct memcntl_mha cmd = {0}; + cmd.mha_pagesize = _mi_os_large_page_size(); + cmd.mha_cmd = MHA_MAPSIZE_VA; + if (memcntl((caddr_t)p, size, MC_HAT_ADVISE, (caddr_t)&cmd, 0, 0) == 0) { + // *is_large = true; // possibly } #endif } + #endif } return p; } // Note: the `try_alignment` is just a hint and the returned pointer is not guaranteed to be aligned. -int _mi_prim_alloc(size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large, bool* is_zero, void** addr) { +int _mi_prim_alloc(void* hint_addr, size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large, bool* is_zero, void** addr) { mi_assert_internal(size > 0 && (size % _mi_os_page_size()) == 0); mi_assert_internal(commit || !allow_large); mi_assert_internal(try_alignment > 0); - *is_zero = true; int protect_flags = (commit ? (PROT_WRITE | PROT_READ) : PROT_NONE); - *addr = unix_mmap(NULL, size, try_alignment, protect_flags, false, allow_large, is_large); + *addr = unix_mmap(hint_addr, size, try_alignment, protect_flags, false, allow_large, is_large); return (*addr != NULL ? 0 : errno); } @@ -341,7 +438,7 @@ int _mi_prim_alloc(size_t size, size_t try_alignment, bool commit, bool allow_la //--------------------------------------------- static void unix_mprotect_hint(int err) { - #if defined(__linux__) && (MI_SECURE>=2) // guard page around every mimalloc page + #if defined(__linux__) && (MI_SECURE>=5) // guard page around every mimalloc page if (err == ENOMEM) { _mi_warning_message("The next warning may be caused by a low memory map limit.\n" " On Linux this is controlled by the vm.max_map_count -- maybe increase it?\n" @@ -367,11 +464,25 @@ int _mi_prim_commit(void* start, size_t size, bool* is_zero) { return err; } +int _mi_prim_reuse(void* start, size_t size) { + MI_UNUSED(start); MI_UNUSED(size); + #if defined(__APPLE__) && defined(MADV_FREE_REUSE) + return unix_madvise(start, size, MADV_FREE_REUSE); + #endif + return 0; +} + int _mi_prim_decommit(void* start, size_t size, bool* needs_recommit) { int err = 0; - // decommit: use MADV_DONTNEED as it decreases rss immediately (unlike MADV_FREE) - err = unix_madvise(start, size, MADV_DONTNEED); - #if !MI_DEBUG && !MI_SECURE + #if defined(__APPLE__) && defined(MADV_FREE_REUSABLE) + // decommit on macOS: use MADV_FREE_REUSABLE as it does immediate rss accounting (issue #1097) + err = unix_madvise(start, size, MADV_FREE_REUSABLE); + if (err) { err = unix_madvise(start, size, MADV_DONTNEED); } + #else + // decommit: use MADV_DONTNEED as it decreases rss immediately (unlike MADV_FREE) + err = unix_madvise(start, size, MADV_DONTNEED); + #endif + #if !MI_DEBUG && MI_SECURE<=2 *needs_recommit = false; #else *needs_recommit = true; @@ -388,22 +499,30 @@ int _mi_prim_decommit(void* start, size_t size, bool* needs_recommit) { } int _mi_prim_reset(void* start, size_t size) { - // We try to use `MADV_FREE` as that is the fastest. A drawback though is that it + int err = 0; + + // on macOS can use MADV_FREE_REUSABLE (but we disable this for now as it seems slower) + #if 0 && defined(__APPLE__) && defined(MADV_FREE_REUSABLE) + err = unix_madvise(start, size, MADV_FREE_REUSABLE); + if (err==0) return 0; + // fall through + #endif + + #if defined(MADV_FREE) + // Otherwise, we try to use `MADV_FREE` as that is the fastest. A drawback though is that it // will not reduce the `rss` stats in tools like `top` even though the memory is available // to other processes. With the default `MIMALLOC_PURGE_DECOMMITS=1` we ensure that by // default `MADV_DONTNEED` is used though. - #if defined(MADV_FREE) static _Atomic(size_t) advice = MI_ATOMIC_VAR_INIT(MADV_FREE); int oadvice = (int)mi_atomic_load_relaxed(&advice); - int err; - while ((err = unix_madvise(start, size, oadvice)) != 0 && errno == EAGAIN) { errno = 0; }; - if (err != 0 && errno == EINVAL && oadvice == MADV_FREE) { + while ((err = unix_madvise(start, size, oadvice)) != 0 && err == EAGAIN) { /* try again */ }; + if (err == EINVAL && oadvice == MADV_FREE) { // if MADV_FREE is not supported, fall back to MADV_DONTNEED from now on mi_atomic_store_release(&advice, (size_t)MADV_DONTNEED); err = unix_madvise(start, size, MADV_DONTNEED); } #else - int err = unix_madvise(start, size, MADV_DONTNEED); + err = unix_madvise(start, size, MADV_DONTNEED); #endif return err; } @@ -442,7 +561,7 @@ int _mi_prim_alloc_huge_os_pages(void* hint_addr, size_t size, int numa_node, bo bool is_large = true; *is_zero = true; *addr = unix_mmap(hint_addr, size, MI_SEGMENT_SIZE, PROT_READ | PROT_WRITE, true, true, &is_large); - if (*addr != NULL && numa_node >= 0 && numa_node < 8*MI_INTPTR_SIZE) { // at most 64 nodes + if (*addr != NULL && numa_node >= 0 && numa_node < (8*MI_INTPTR_SIZE - 1)) { // at most 63 nodes unsigned long numa_mask = (1UL << numa_node); // TODO: does `mbind` work correctly for huge OS pages? should we // use `set_mempolicy` before calling mmap instead? @@ -450,7 +569,7 @@ int _mi_prim_alloc_huge_os_pages(void* hint_addr, size_t size, int numa_node, bo long err = mi_prim_mbind(*addr, size, MPOL_PREFERRED, &numa_mask, 8*MI_INTPTR_SIZE, 0); if (err != 0) { err = errno; - _mi_warning_message("failed to bind huge (1GiB) pages to numa node %d (error: %d (0x%x))\n", numa_node, err, err); + _mi_warning_message("failed to bind huge (1GiB) pages to numa node %d (error: %ld (0x%lx))\n", numa_node, err, err); } } return (*addr != NULL ? 0 : errno); @@ -473,13 +592,11 @@ int _mi_prim_alloc_huge_os_pages(void* hint_addr, size_t size, int numa_node, bo #if defined(__linux__) -#include // snprintf - size_t _mi_prim_numa_node(void) { #if defined(MI_HAS_SYSCALL_H) && defined(SYS_getcpu) - unsigned long node = 0; - unsigned long ncpu = 0; - long err = syscall(SYS_getcpu, &ncpu, &node, NULL); + unsigned int node = 0; + unsigned int ncpu = 0; + int err = syscall(SYS_getcpu, &ncpu, &node, NULL); if (err != 0) return 0; return node; #else @@ -489,13 +606,16 @@ size_t _mi_prim_numa_node(void) { size_t _mi_prim_numa_node_count(void) { char buf[128]; - unsigned node = 0; - for(node = 0; node < 256; node++) { + unsigned last_found = 0; + for(unsigned node = 1; node < 256; node++) { // enumerate node entries -- todo: it there a more efficient way to do this? (but ensure there is no allocation) - snprintf(buf, 127, "/sys/devices/system/node/node%u", node + 1); - if (mi_prim_access(buf,R_OK) != 0) break; + _mi_snprintf(buf, 127, "/sys/devices/system/node/node%u", node); + if (mi_prim_access(buf,R_OK) != 0) { + if (node - last_found > 4) break; // allow some sparseness of nodes but not more than 4 + } + else { last_found = node; } // highest found node } - return (node+1); + return last_found + 1; } #elif defined(__FreeBSD__) && __FreeBSD_version >= 1200000 @@ -551,35 +671,39 @@ size_t _mi_prim_numa_node_count(void) { #include -#if defined(CLOCK_REALTIME) || defined(CLOCK_MONOTONIC) - -mi_msecs_t _mi_prim_clock_now(void) { - struct timespec t; - #ifdef CLOCK_MONOTONIC - clock_gettime(CLOCK_MONOTONIC, &t); +// low resolution timer +static mi_msecs_t mi_prim_clock_now_lowres(void) { + const int64_t ticks = (int64_t)clock(); + #if !defined(CLOCKS_PER_SEC) + return ticks; #else - clock_gettime(CLOCK_REALTIME, &t); + if (CLOCKS_PER_SEC <= 0 || CLOCKS_PER_SEC == 1000) { + return ticks; + } + else if (CLOCKS_PER_SEC > 0 && CLOCKS_PER_SEC < 1000) { + return ticks * (1000 / (mi_msecs_t)CLOCKS_PER_SEC); + } + else { + return ticks / ((mi_msecs_t)CLOCKS_PER_SEC / 1000); + } #endif - return ((mi_msecs_t)t.tv_sec * 1000) + ((mi_msecs_t)t.tv_nsec / 1000000); } -#else - -// low resolution timer mi_msecs_t _mi_prim_clock_now(void) { - #if !defined(CLOCKS_PER_SEC) || (CLOCKS_PER_SEC == 1000) || (CLOCKS_PER_SEC == 0) - return (mi_msecs_t)clock(); - #elif (CLOCKS_PER_SEC < 1000) - return (mi_msecs_t)clock() * (1000 / (mi_msecs_t)CLOCKS_PER_SEC); - #else - return (mi_msecs_t)clock() / ((mi_msecs_t)CLOCKS_PER_SEC / 1000); + #if defined(CLOCK_REALTIME) || defined(CLOCK_MONOTONIC) + #ifdef CLOCK_MONOTONIC + const clockid_t clockid = CLOCK_MONOTONIC; + #else + const clockid_t clockid = CLOCK_REALTIME; + #endif + struct timespec t; + if (clock_gettime(clockid,&t) == 0) { + return ((mi_msecs_t)t.tv_sec * 1000) + ((mi_msecs_t)t.tv_nsec / 1000000L); + } #endif + return mi_prim_clock_now_lowres(); } -#endif - - - //---------------------------------------------------------------- // Process info @@ -605,41 +729,46 @@ static mi_msecs_t timeval_secs(const struct timeval* tv) { void _mi_prim_process_info(mi_process_info_t* pinfo) { struct rusage rusage; - getrusage(RUSAGE_SELF, &rusage); - pinfo->utime = timeval_secs(&rusage.ru_utime); - pinfo->stime = timeval_secs(&rusage.ru_stime); -#if !defined(__HAIKU__) - pinfo->page_faults = rusage.ru_majflt; -#endif -#if defined(__HAIKU__) - // Haiku does not have (yet?) a way to - // get these stats per process - thread_info tid; - area_info mem; - ssize_t c; - get_thread_info(find_thread(0), &tid); - while (get_next_area_info(tid.team, &c, &mem) == B_OK) { - pinfo->peak_rss += mem.ram_size; - } - pinfo->page_faults = 0; -#elif defined(__APPLE__) - pinfo->peak_rss = rusage.ru_maxrss; // macos reports in bytes - #ifdef MACH_TASK_BASIC_INFO - struct mach_task_basic_info info; - mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT; - if (task_info(mach_task_self(), MACH_TASK_BASIC_INFO, (task_info_t)&info, &infoCount) == KERN_SUCCESS) { - pinfo->current_rss = (size_t)info.resident_size; - } - #else - struct task_basic_info info; - mach_msg_type_number_t infoCount = TASK_BASIC_INFO_COUNT; - if (task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &infoCount) == KERN_SUCCESS) { - pinfo->current_rss = (size_t)info.resident_size; + if (getrusage(RUSAGE_SELF, &rusage) == 0) { + pinfo->utime = timeval_secs(&rusage.ru_utime); + pinfo->stime = timeval_secs(&rusage.ru_stime); + #if !defined(__HAIKU__) + pinfo->page_faults = rusage.ru_majflt; + #endif + #if defined(__APPLE__) + pinfo->peak_rss = rusage.ru_maxrss; // macos reports in bytes + #else + pinfo->peak_rss = rusage.ru_maxrss * 1024; // Linux/BSD report in KiB + #endif } + + #if defined(__HAIKU__) + // Haiku does not have (yet?) a way to + // get these stats per process + thread_info tid; + if (get_thread_info(find_thread(0), &tid) == B_OK) { + area_info mem; + ssize_t c; + while (get_next_area_info(tid.team, &c, &mem) == B_OK) { + pinfo->peak_rss += mem.ram_size; + } + } + pinfo->page_faults = 0; + #elif defined(__APPLE__) + #ifdef MACH_TASK_BASIC_INFO + struct mach_task_basic_info info; + mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT; + if (task_info(mach_task_self(), MACH_TASK_BASIC_INFO, (task_info_t)&info, &infoCount) == KERN_SUCCESS) { + pinfo->current_rss = (size_t)info.resident_size; + } + #else + struct task_basic_info info; + mach_msg_type_number_t infoCount = TASK_BASIC_INFO_COUNT; + if (task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &infoCount) == KERN_SUCCESS) { + pinfo->current_rss = (size_t)info.resident_size; + } + #endif #endif -#else - pinfo->peak_rss = rusage.ru_maxrss * 1024; // Linux/BSD report in KiB -#endif // use defaults for commit } @@ -686,28 +815,28 @@ static char** mi_get_environ(void) { return environ; } #endif -bool _mi_prim_getenv(const char* name, char* result, size_t result_size) { - if (name==NULL) return false; +int _mi_prim_getenv(const char* name, char* result, size_t result_size) { + if (name==NULL) return -1; const size_t len = _mi_strlen(name); - if (len == 0) return false; + if (len == 0) return -1; char** env = mi_get_environ(); - if (env == NULL) return false; + if (env == NULL) return -1; // compare up to 10000 entries for (int i = 0; i < 10000 && env[i] != NULL; i++) { const char* s = env[i]; if (_mi_strnicmp(name, s, len) == 0 && s[len] == '=') { // case insensitive // found it - _mi_strlcpy(result, s + len + 1, result_size); - return true; + if (!_mi_strlcpy(result, s + len + 1, result_size)) return -1; + return 1; // success } } - return false; + return 0; // not found } #else // fallback: use standard C `getenv` but this cannot be used while initializing the C runtime -bool _mi_prim_getenv(const char* name, char* result, size_t result_size) { +int _mi_prim_getenv(const char* name, char* result, size_t result_size) { // cannot call getenv() when still initializing the C runtime. - if (_mi_preloading()) return false; + if (_mi_preloading()) return -1; // error, try again later const char* s = getenv(name); if (s == NULL) { // we check the upper case name too. @@ -719,9 +848,9 @@ bool _mi_prim_getenv(const char* name, char* result, size_t result_size) { buf[len] = 0; s = getenv(buf); } - if (s == NULL || _mi_strnlen(s,result_size) >= result_size) return false; - _mi_strlcpy(result, s, result_size); - return true; + if (s == NULL || _mi_strnlen(s,result_size) >= result_size) return 0; // not found + if (!_mi_strlcpy(result, s, result_size)) return -1; + return 1; // success } #endif // !MI_USE_ENVIRON @@ -730,40 +859,31 @@ bool _mi_prim_getenv(const char* name, char* result, size_t result_size) { // Random //---------------------------------------------------------------- -#if defined(__APPLE__) - -#include -#if defined(MAC_OS_X_VERSION_10_10) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10 +#if defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_15) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15) #include #include -#endif + bool _mi_prim_random_buf(void* buf, size_t buf_len) { - #if defined(MAC_OS_X_VERSION_10_15) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_15 - // We prefer CCRandomGenerateBytes as it returns an error code while arc4random_buf - // may fail silently on macOS. See PR #390, and - return (CCRandomGenerateBytes(buf, buf_len) == kCCSuccess); - #else - // fall back on older macOS - arc4random_buf(buf, buf_len); - return true; - #endif + // We prefer CCRandomGenerateBytes as it returns an error code while arc4random_buf + // may fail silently on macOS. See PR #390, and + return (CCRandomGenerateBytes(buf, buf_len) == kCCSuccess); } #elif defined(__ANDROID__) || defined(__DragonFly__) || \ defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ - defined(__sun) || defined(__CYGWIN__) + defined(__sun) || \ + defined(__CYGWIN__) /* CPython: gh-148461 */ || \ + (defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7)) -#include bool _mi_prim_random_buf(void* buf, size_t buf_len) { arc4random_buf(buf, buf_len); return true; } -#elif defined(__linux__) || defined(__HAIKU__) +#elif defined(__APPLE__) || defined(__linux__) || defined(__HAIKU__) // also for old apple versions < 10.7 (issue #829) #include #include -#include #include bool _mi_prim_random_buf(void* buf, size_t buf_len) { @@ -792,7 +912,10 @@ bool _mi_prim_random_buf(void* buf, size_t buf_len) { size_t count = 0; while(count < buf_len) { ssize_t ret = mi_prim_read(fd, (char*)buf + count, buf_len - count); - if (ret<=0) { + if (ret==0) { + break; + } + else if (ret<0) { if (errno!=EAGAIN && errno!=EINTR) break; } else { @@ -830,11 +953,17 @@ static void mi_pthread_done(void* value) { void _mi_prim_thread_init_auto_done(void) { mi_assert_internal(_mi_heap_default_key == (pthread_key_t)(-1)); - pthread_key_create(&_mi_heap_default_key, &mi_pthread_done); + const int err = pthread_key_create(&_mi_heap_default_key, &mi_pthread_done); + if (err!=0) { + _mi_error_message(err,"unable to create a pthread thread local key (error %d (0x%x))", err, err); + _mi_heap_default_key = (pthread_key_t)(-1); + }; } void _mi_prim_thread_done_auto_done(void) { - // nothing to do + if (_mi_heap_default_key != (pthread_key_t)(-1)) { // do not leak the key, see issue #809 + pthread_key_delete(_mi_heap_default_key); + } } void _mi_prim_thread_associate_default_heap(mi_heap_t* heap) { diff --git a/Objects/mimalloc/prim/wasi/prim.c b/Objects/mimalloc/prim/wasi/prim.c index 640dac0493f5732..1e8f0ea0132a640 100644 --- a/Objects/mimalloc/prim/wasi/prim.c +++ b/Objects/mimalloc/prim/wasi/prim.c @@ -9,9 +9,10 @@ terms of the MIT license. A copy of the license can be found in the file #include "mimalloc.h" #include "mimalloc/internal.h" -#include "mimalloc/atomic.h" #include "mimalloc/prim.h" -#include // sbrk() + +#include // fputs +#include // getenv //--------------------------------------------- // Initialize @@ -21,7 +22,7 @@ void _mi_prim_mem_init( mi_os_mem_config_t* config ) { config->page_size = 64*MI_KiB; // WebAssembly has a fixed page size: 64KiB config->alloc_granularity = 16; config->has_overcommit = false; - config->must_free_whole = true; + config->has_partial_free = false; config->has_virtual_reserve = false; } @@ -41,6 +42,8 @@ int _mi_prim_free(void* addr, size_t size ) { //--------------------------------------------- #if defined(MI_USE_SBRK) + #include // for sbrk + static void* mi_memory_grow( size_t size ) { void* p = sbrk(size); if (p == (void*)(-1)) return NULL; @@ -86,7 +89,7 @@ static void* mi_prim_mem_grow(size_t size, size_t try_alignment) { { void* current = mi_memory_grow(0); // get current size if (current != NULL) { - void* aligned_current = mi_align_up_ptr(current, try_alignment); // and align from there to minimize wasted space + void* aligned_current = _mi_align_up_ptr(current, try_alignment); // and align from there to minimize wasted space alloc_size = _mi_align_up( ((uint8_t*)aligned_current - (uint8_t*)current) + size, _mi_os_page_size()); base = mi_memory_grow(alloc_size); } @@ -95,7 +98,7 @@ static void* mi_prim_mem_grow(size_t size, size_t try_alignment) { pthread_mutex_unlock(&mi_heap_grow_mutex); #endif if (base != NULL) { - p = mi_align_up_ptr(base, try_alignment); + p = _mi_align_up_ptr(base, try_alignment); if ((uint8_t*)p + size > (uint8_t*)base + alloc_size) { // another thread used wasm_memory_grow/sbrk in-between and we do not have enough // space after alignment. Give up (and waste the space as we cannot shrink :-( ) @@ -116,8 +119,8 @@ static void* mi_prim_mem_grow(size_t size, size_t try_alignment) { } // Note: the `try_alignment` is just a hint and the returned pointer is not guaranteed to be aligned. -int _mi_prim_alloc(size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large, bool* is_zero, void** addr) { - MI_UNUSED(allow_large); MI_UNUSED(commit); +int _mi_prim_alloc(void* hint_addr, size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large, bool* is_zero, void** addr) { + MI_UNUSED(allow_large); MI_UNUSED(commit); MI_UNUSED(hint_addr); *is_large = false; *is_zero = false; *addr = mi_prim_mem_grow(size, try_alignment); @@ -146,6 +149,11 @@ int _mi_prim_reset(void* addr, size_t size) { return 0; } +int _mi_prim_reuse(void* addr, size_t size) { + MI_UNUSED(addr); MI_UNUSED(size); + return 0; +} + int _mi_prim_protect(void* addr, size_t size, bool protect) { MI_UNUSED(addr); MI_UNUSED(size); MI_UNUSED(protect); return 0; @@ -178,33 +186,39 @@ size_t _mi_prim_numa_node_count(void) { #include -#if defined(CLOCK_REALTIME) || defined(CLOCK_MONOTONIC) - -mi_msecs_t _mi_prim_clock_now(void) { - struct timespec t; - #ifdef CLOCK_MONOTONIC - clock_gettime(CLOCK_MONOTONIC, &t); +// low resolution timer +static mi_msecs_t mi_prim_clock_now_lowres(void) { + const int64_t ticks = (int64_t)clock(); + #if !defined(CLOCKS_PER_SEC) + return ticks; #else - clock_gettime(CLOCK_REALTIME, &t); + if (CLOCKS_PER_SEC <= 0 || CLOCKS_PER_SEC == 1000) { + return ticks; + } + else if (CLOCKS_PER_SEC > 0 && CLOCKS_PER_SEC < 1000) { + return ticks * (1000 / (mi_msecs_t)CLOCKS_PER_SEC); + } + else { + return ticks / ((mi_msecs_t)CLOCKS_PER_SEC / 1000); + } #endif - return ((mi_msecs_t)t.tv_sec * 1000) + ((mi_msecs_t)t.tv_nsec / 1000000); } -#else - -// low resolution timer mi_msecs_t _mi_prim_clock_now(void) { - #if !defined(CLOCKS_PER_SEC) || (CLOCKS_PER_SEC == 1000) || (CLOCKS_PER_SEC == 0) - return (mi_msecs_t)clock(); - #elif (CLOCKS_PER_SEC < 1000) - return (mi_msecs_t)clock() * (1000 / (mi_msecs_t)CLOCKS_PER_SEC); - #else - return (mi_msecs_t)clock() / ((mi_msecs_t)CLOCKS_PER_SEC / 1000); + #if defined(CLOCK_REALTIME) || defined(CLOCK_MONOTONIC) + #ifdef CLOCK_MONOTONIC + const clockid_t clockid = CLOCK_MONOTONIC; + #else + const clockid_t clockid = CLOCK_REALTIME; + #endif + struct timespec t; + if (clock_gettime(clockid,&t) == 0) { + return ((mi_msecs_t)t.tv_sec * 1000) + ((mi_msecs_t)t.tv_nsec / 1000000L); + } #endif + return mi_prim_clock_now_lowres(); } -#endif - //---------------------------------------------------------------- // Process info @@ -230,9 +244,9 @@ void _mi_prim_out_stderr( const char* msg ) { // Environment //---------------------------------------------------------------- -bool _mi_prim_getenv(const char* name, char* result, size_t result_size) { +int _mi_prim_getenv(const char* name, char* result, size_t result_size) { // cannot call getenv() when still initializing the C runtime. - if (_mi_preloading()) return false; + if (_mi_preloading()) return -1; // error, try again later const char* s = getenv(name); if (s == NULL) { // we check the upper case name too. @@ -244,9 +258,9 @@ bool _mi_prim_getenv(const char* name, char* result, size_t result_size) { buf[len] = 0; s = getenv(buf); } - if (s == NULL || _mi_strnlen(s,result_size) >= result_size) return false; + if (s == NULL || _mi_strnlen(s,result_size) >= result_size) return 0; // not found _mi_strlcpy(result, s, result_size); - return true; + return 1; // found } diff --git a/Objects/mimalloc/prim/windows/etw.h b/Objects/mimalloc/prim/windows/etw.h index e9ec35fc9ed7ebc..4e0a092a10f4ba9 100644 --- a/Objects/mimalloc/prim/windows/etw.h +++ b/Objects/mimalloc/prim/windows/etw.h @@ -136,7 +136,7 @@ extern "C" { // - MCGEN_EVENTSETINFORMATION // - MCGEN_EVENTWRITETRANSFER // -// If the macro is undefined, the MC implementation will default to the +// If the the macro is undefined, the MC implementation will default to the // corresponding ETW APIs. For example, if the MCGEN_EVENTREGISTER macro is // undefined, the EventRegister[MyProviderName] macro will use EventRegister // in user mode and will use EtwRegister in kernel mode. diff --git a/Objects/mimalloc/prim/windows/prim.c b/Objects/mimalloc/prim/windows/prim.c index a038277ad21cb04..5d531de50ef420d 100644 --- a/Objects/mimalloc/prim/windows/prim.c +++ b/Objects/mimalloc/prim/windows/prim.c @@ -9,10 +9,14 @@ terms of the MIT license. A copy of the license can be found in the file #include "mimalloc.h" #include "mimalloc/internal.h" -#include "mimalloc/atomic.h" #include "mimalloc/prim.h" #include // fputs, stderr +#include // atexit +// xbox has no console IO and cannot use LoadLibrary or GetModuleHandle +#if !defined(WINAPI_FAMILY_PARTITION) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) +#define MI_WIN_DESKTOP 1 +#endif //--------------------------------------------- // Dynamically bind Windows API points for portability @@ -46,32 +50,70 @@ typedef struct MI_MEM_ADDRESS_REQUIREMENTS_S { #define MI_MEM_EXTENDED_PARAMETER_NONPAGED_HUGE 0x00000010 #include -typedef PVOID (__stdcall *PVirtualAlloc2)(HANDLE, PVOID, SIZE_T, ULONG, ULONG, MI_MEM_EXTENDED_PARAMETER*, ULONG); -typedef NTSTATUS (__stdcall *PNtAllocateVirtualMemoryEx)(HANDLE, PVOID*, SIZE_T*, ULONG, ULONG, MI_MEM_EXTENDED_PARAMETER*, ULONG); +typedef PVOID (__stdcall *PVirtualAlloc2)(HANDLE, PVOID, SIZE_T, ULONG, ULONG, MI_MEM_EXTENDED_PARAMETER*, ULONG); +typedef LONG (__stdcall *PNtAllocateVirtualMemoryEx)(HANDLE, PVOID*, SIZE_T*, ULONG, ULONG, MI_MEM_EXTENDED_PARAMETER*, ULONG); // avoid NTSTATUS as it is not defined on xbox (pr #1084) static PVirtualAlloc2 pVirtualAlloc2 = NULL; static PNtAllocateVirtualMemoryEx pNtAllocateVirtualMemoryEx = NULL; -// Similarly, GetNumaProcesorNodeEx is only supported since Windows 7 +// Similarly, GetNumaProcessorNodeEx is only supported since Windows 7 (and GetNumaNodeProcessorMask is not supported on xbox) typedef struct MI_PROCESSOR_NUMBER_S { WORD Group; BYTE Number; BYTE Reserved; } MI_PROCESSOR_NUMBER; typedef VOID (__stdcall *PGetCurrentProcessorNumberEx)(MI_PROCESSOR_NUMBER* ProcNumber); typedef BOOL (__stdcall *PGetNumaProcessorNodeEx)(MI_PROCESSOR_NUMBER* Processor, PUSHORT NodeNumber); typedef BOOL (__stdcall* PGetNumaNodeProcessorMaskEx)(USHORT Node, PGROUP_AFFINITY ProcessorMask); typedef BOOL (__stdcall *PGetNumaProcessorNode)(UCHAR Processor, PUCHAR NodeNumber); +typedef BOOL (__stdcall* PGetNumaNodeProcessorMask)(UCHAR Node, PULONGLONG ProcessorMask); +typedef BOOL (__stdcall* PGetNumaHighestNodeNumber)(PULONG Node); static PGetCurrentProcessorNumberEx pGetCurrentProcessorNumberEx = NULL; static PGetNumaProcessorNodeEx pGetNumaProcessorNodeEx = NULL; static PGetNumaNodeProcessorMaskEx pGetNumaNodeProcessorMaskEx = NULL; static PGetNumaProcessorNode pGetNumaProcessorNode = NULL; +static PGetNumaNodeProcessorMask pGetNumaNodeProcessorMask = NULL; +static PGetNumaHighestNodeNumber pGetNumaHighestNodeNumber = NULL; + +// Not available on xbox +typedef SIZE_T(__stdcall* PGetLargePageMinimum)(VOID); +static PGetLargePageMinimum pGetLargePageMinimum = NULL; + +// Available after Windows XP +typedef BOOL (__stdcall *PGetPhysicallyInstalledSystemMemory)( PULONGLONG TotalMemoryInKilobytes ); + +// Load a library +static HMODULE mi_win_loadlibrary(const TCHAR* library) { + #if MI_WIN_DESKTOP + return LoadLibrary(library); + #else + return LoadPackagedLibrary(library, 0); + #endif +} + +// Get a library handle (and possibly load it) +static HMODULE mi_win_getlibrary(const TCHAR* library, bool* should_free) { + #if MI_WIN_DESKTOP + // avoid calling LoadLibrary for "kernel32", "ntdll", and "kernelbase" (also to avoid hitting the loader lock) + HMODULE mod = GetModuleHandle(library); + if (mod!=NULL) { + *should_free = false; + return mod; + } + #endif + *should_free = true; + return mi_win_loadlibrary(library); +} + +static void mi_win_freelibrary(HMODULE mod, bool should_free) { + if (should_free) { + FreeLibrary(mod); + } +} //--------------------------------------------- // Enable large page support dynamically (if possible) //--------------------------------------------- -static bool win_enable_large_os_pages(size_t* large_page_size) +static bool win_enable_large_os_pages_once(size_t* large_page_size) { - static bool large_initialized = false; - if (large_initialized) return (_mi_os_large_page_size() > 0); - large_initialized = true; + if (pGetLargePageMinimum==NULL) return false; // no large page support (xbox etc.) // Try to see if large OS pages are supported // To use large pages on Windows, we first need access permission @@ -80,30 +122,41 @@ static bool win_enable_large_os_pages(size_t* large_page_size) unsigned long err = 0; HANDLE token = NULL; BOOL ok = OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token); + err = GetLastError(); if (ok) { TOKEN_PRIVILEGES tp; ok = LookupPrivilegeValue(NULL, TEXT("SeLockMemoryPrivilege"), &tp.Privileges[0].Luid); + err = GetLastError(); if (ok) { tp.PrivilegeCount = 1; tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; ok = AdjustTokenPrivileges(token, FALSE, &tp, 0, (PTOKEN_PRIVILEGES)NULL, 0); + err = GetLastError(); if (ok) { - err = GetLastError(); ok = (err == ERROR_SUCCESS); - if (ok && large_page_size != NULL) { - *large_page_size = GetLargePageMinimum(); + if (ok && large_page_size != NULL && pGetLargePageMinimum != NULL) { + *large_page_size = (*pGetLargePageMinimum)(); } } } CloseHandle(token); } if (!ok) { - if (err == 0) err = GetLastError(); + if (err == 0) { err = GetLastError(); } _mi_warning_message("cannot enable large OS page support, error %lu\n", err); } return (ok!=0); } +static bool win_enable_large_os_pages(size_t* large_page_size) { + static size_t win_large_page_size = 0; + mi_atomic_do_once { + win_enable_large_os_pages_once(&win_large_page_size); + } + if (large_page_size != NULL) { *large_page_size = win_large_page_size; } + return (win_large_page_size > 0); +} + //--------------------------------------------- // Initialize @@ -112,37 +165,57 @@ static bool win_enable_large_os_pages(size_t* large_page_size) void _mi_prim_mem_init( mi_os_mem_config_t* config ) { config->has_overcommit = false; - config->must_free_whole = true; + config->has_partial_free = false; config->has_virtual_reserve = true; // get the page size SYSTEM_INFO si; GetSystemInfo(&si); if (si.dwPageSize > 0) { config->page_size = si.dwPageSize; } if (si.dwAllocationGranularity > 0) { config->alloc_granularity = si.dwAllocationGranularity; } + // get virtual address bits + if ((uintptr_t)si.lpMaximumApplicationAddress > 0) { + const size_t vbits = MI_SIZE_BITS - mi_clz((uintptr_t)si.lpMaximumApplicationAddress); + config->virtual_address_bits = vbits; + } + // get the VirtualAlloc2 function - HINSTANCE hDll; - hDll = LoadLibrary(TEXT("kernelbase.dll")); + bool hDllFree; + HINSTANCE hDll = mi_win_getlibrary(TEXT("kernelbase.dll"), &hDllFree); if (hDll != NULL) { // use VirtualAlloc2FromApp if possible as it is available to Windows store apps pVirtualAlloc2 = (PVirtualAlloc2)(void (*)(void))GetProcAddress(hDll, "VirtualAlloc2FromApp"); if (pVirtualAlloc2==NULL) pVirtualAlloc2 = (PVirtualAlloc2)(void (*)(void))GetProcAddress(hDll, "VirtualAlloc2"); - FreeLibrary(hDll); + mi_win_freelibrary(hDll, hDllFree); } // NtAllocateVirtualMemoryEx is used for huge page allocation - hDll = LoadLibrary(TEXT("ntdll.dll")); + hDll = mi_win_getlibrary(TEXT("ntdll.dll"), &hDllFree); if (hDll != NULL) { pNtAllocateVirtualMemoryEx = (PNtAllocateVirtualMemoryEx)(void (*)(void))GetProcAddress(hDll, "NtAllocateVirtualMemoryEx"); - FreeLibrary(hDll); + mi_win_freelibrary(hDll, hDllFree); } // Try to use Win7+ numa API - hDll = LoadLibrary(TEXT("kernel32.dll")); + hDll = mi_win_getlibrary(TEXT("kernel32.dll"), &hDllFree); if (hDll != NULL) { pGetCurrentProcessorNumberEx = (PGetCurrentProcessorNumberEx)(void (*)(void))GetProcAddress(hDll, "GetCurrentProcessorNumberEx"); pGetNumaProcessorNodeEx = (PGetNumaProcessorNodeEx)(void (*)(void))GetProcAddress(hDll, "GetNumaProcessorNodeEx"); pGetNumaNodeProcessorMaskEx = (PGetNumaNodeProcessorMaskEx)(void (*)(void))GetProcAddress(hDll, "GetNumaNodeProcessorMaskEx"); pGetNumaProcessorNode = (PGetNumaProcessorNode)(void (*)(void))GetProcAddress(hDll, "GetNumaProcessorNode"); - FreeLibrary(hDll); + pGetNumaNodeProcessorMask = (PGetNumaNodeProcessorMask)(void (*)(void))GetProcAddress(hDll, "GetNumaNodeProcessorMask"); + pGetNumaHighestNodeNumber = (PGetNumaHighestNodeNumber)(void (*)(void))GetProcAddress(hDll, "GetNumaHighestNodeNumber"); + pGetLargePageMinimum = (PGetLargePageMinimum)(void (*)(void))GetProcAddress(hDll, "GetLargePageMinimum"); + // Get physical memory (not available on XP, so check dynamically) + PGetPhysicallyInstalledSystemMemory pGetPhysicallyInstalledSystemMemory = (PGetPhysicallyInstalledSystemMemory)(void (*)(void))GetProcAddress(hDll,"GetPhysicallyInstalledSystemMemory"); + if (pGetPhysicallyInstalledSystemMemory != NULL) { + ULONGLONG memInKiB = 0; + if ((*pGetPhysicallyInstalledSystemMemory)(&memInKiB)) { + if (memInKiB > 0 && memInKiB <= SIZE_MAX) { + config->physical_memory_in_kib = (size_t)memInKiB; + } + } + } + mi_win_freelibrary(hDll, hDllFree); } + // Enable large/huge OS page support? if (mi_option_is_enabled(mi_option_allow_large_os_pages) || mi_option_is_enabled(mi_option_reserve_huge_os_pages)) { win_enable_large_os_pages(&config->large_page_size); } @@ -162,9 +235,10 @@ int _mi_prim_free(void* addr, size_t size ) { // In mi_os_mem_alloc_aligned the fallback path may have returned a pointer inside // the memory region returned by VirtualAlloc; in that case we need to free using // the start of the region. - MEMORY_BASIC_INFORMATION info = { 0 }; - VirtualQuery(addr, &info, sizeof(info)); - if (info.AllocationBase < addr && ((uint8_t*)addr - (uint8_t*)info.AllocationBase) < (ptrdiff_t)MI_SEGMENT_SIZE) { + MEMORY_BASIC_INFORMATION info; _mi_memzero_var(info); + err = (VirtualQuery(addr, &info, sizeof(info)) == 0); + if (err) { errcode = GetLastError(); } + if (!err && info.AllocationBase < addr && ((uint8_t*)addr - (uint8_t*)info.AllocationBase) < (ptrdiff_t)MI_SEGMENT_SIZE) { errcode = 0; err = (VirtualFree(info.AllocationBase, 0, MEM_RELEASE) == 0); if (err) { errcode = GetLastError(); } @@ -178,7 +252,7 @@ int _mi_prim_free(void* addr, size_t size ) { // VirtualAlloc //--------------------------------------------- -static void* win_virtual_alloc_prim(void* addr, size_t size, size_t try_alignment, DWORD flags) { +static void* win_virtual_alloc_prim_once(void* addr, size_t size, size_t try_alignment, DWORD flags) { #if (MI_INTPTR_SIZE >= 8) // on 64-bit systems, try to use the virtual address area after 2TiB for 4MiB aligned allocations if (addr == NULL) { @@ -192,7 +266,7 @@ static void* win_virtual_alloc_prim(void* addr, size_t size, size_t try_alignmen } #endif // on modern Windows try use VirtualAlloc2 for aligned allocation - if (try_alignment > 1 && (try_alignment % _mi_os_page_size()) == 0 && pVirtualAlloc2 != NULL) { + if (addr == NULL && try_alignment > 1 && (try_alignment % _mi_os_page_size()) == 0 && pVirtualAlloc2 != NULL) { MI_MEM_ADDRESS_REQUIREMENTS reqs = { 0, 0, 0 }; reqs.Alignment = try_alignment; MI_MEM_EXTENDED_PARAMETER param = { {0, 0}, {0} }; @@ -200,20 +274,61 @@ static void* win_virtual_alloc_prim(void* addr, size_t size, size_t try_alignmen param.Arg.Pointer = &reqs; void* p = (*pVirtualAlloc2)(GetCurrentProcess(), addr, size, flags, PAGE_READWRITE, ¶m, 1); if (p != NULL) return p; - _mi_warning_message("unable to allocate aligned OS memory (%zu bytes, error code: 0x%x, address: %p, alignment: %zu, flags: 0x%x)\n", size, GetLastError(), addr, try_alignment, flags); + _mi_warning_message("unable to allocate aligned OS memory (0x%zx bytes, error code: 0x%x, address: %p, alignment: 0x%zx, flags: 0x%x)\n", size, GetLastError(), addr, try_alignment, flags); // fall through on error } // last resort return VirtualAlloc(addr, size, flags, PAGE_READWRITE); } +static bool win_is_out_of_memory_error(DWORD err) { + switch (err) { + case ERROR_COMMITMENT_MINIMUM: + case ERROR_COMMITMENT_LIMIT: + case ERROR_PAGEFILE_QUOTA: + case ERROR_NOT_ENOUGH_MEMORY: + return true; + default: + return false; + } +} + +static void* win_virtual_alloc_prim(void* addr, size_t size, size_t try_alignment, DWORD flags) { + long max_retry_msecs = mi_option_get_clamp(mi_option_retry_on_oom, 0, 2000); // at most 2 seconds + if (max_retry_msecs == 1) { max_retry_msecs = 100; } // if one sets the option to "true" + for (long tries = 1; tries <= 10; tries++) { // try at most 10 times (=2200ms) + void* p = win_virtual_alloc_prim_once(addr, size, try_alignment, flags); + if (p != NULL) { + // success, return the address + return p; + } + else if (max_retry_msecs > 0 && (try_alignment <= 2*MI_SEGMENT_ALIGN) && + (flags&MEM_COMMIT) != 0 && (flags&MEM_LARGE_PAGES) == 0 && + win_is_out_of_memory_error(GetLastError())) { + // if committing regular memory and being out-of-memory, + // keep trying for a bit in case memory frees up after all. See issue #894 + _mi_warning_message("out-of-memory on OS allocation, try again... (attempt %lu, 0x%zx bytes, error code: 0x%x, address: %p, alignment: 0x%zx, flags: 0x%x)\n", tries, size, GetLastError(), addr, try_alignment, flags); + long sleep_msecs = tries*40; // increasing waits + if (sleep_msecs > max_retry_msecs) { sleep_msecs = max_retry_msecs; } + max_retry_msecs -= sleep_msecs; + Sleep(sleep_msecs); + } + else { + // otherwise return with an error + break; + } + } + return NULL; +} + static void* win_virtual_alloc(void* addr, size_t size, size_t try_alignment, DWORD flags, bool large_only, bool allow_large, bool* is_large) { mi_assert_internal(!(large_only && !allow_large)); static _Atomic(size_t) large_page_try_ok; // = 0; void* p = NULL; // Try to allocate large OS pages (2MiB) if allowed or required. - if ((large_only || _mi_os_use_large_page(size, try_alignment)) - && allow_large && (flags&MEM_COMMIT)!=0 && (flags&MEM_RESERVE)!=0) { + if ((large_only || (_mi_os_canuse_large_page(size, try_alignment) && mi_option_is_enabled(mi_option_allow_large_os_pages))) + && allow_large && (flags&MEM_COMMIT)!=0 && (flags&MEM_RESERVE)!=0) + { size_t try_ok = mi_atomic_load_acquire(&large_page_try_ok); if (!large_only && try_ok > 0) { // if a large page allocation fails, it seems the calls to VirtualAlloc get very expensive. @@ -240,14 +355,14 @@ static void* win_virtual_alloc(void* addr, size_t size, size_t try_alignment, DW return p; } -int _mi_prim_alloc(size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large, bool* is_zero, void** addr) { +int _mi_prim_alloc(void* hint_addr, size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large, bool* is_zero, void** addr) { mi_assert_internal(size > 0 && (size % _mi_os_page_size()) == 0); mi_assert_internal(commit || !allow_large); mi_assert_internal(try_alignment > 0); *is_zero = true; int flags = MEM_RESERVE; if (commit) { flags |= MEM_COMMIT; } - *addr = win_virtual_alloc(NULL, size, try_alignment, flags, false, allow_large, is_large); + *addr = win_virtual_alloc(hint_addr, size, try_alignment, flags, false, allow_large, is_large); return (*addr != NULL ? 0 : (int)GetLastError()); } @@ -293,6 +408,11 @@ int _mi_prim_reset(void* addr, size_t size) { return (p != NULL ? 0 : (int)GetLastError()); } +int _mi_prim_reuse(void* addr, size_t size) { + MI_UNUSED(addr); MI_UNUSED(size); + return 0; +} + int _mi_prim_protect(void* addr, size_t size, bool protect) { DWORD oldprotect = 0; BOOL ok = VirtualProtect(addr, size, protect ? PAGE_NOACCESS : PAGE_READWRITE, &oldprotect); @@ -312,8 +432,8 @@ static void* _mi_prim_alloc_huge_os_pagesx(void* hint_addr, size_t size, int num MI_MEM_EXTENDED_PARAMETER params[3] = { {{0,0},{0}},{{0,0},{0}},{{0,0},{0}} }; // on modern Windows try use NtAllocateVirtualMemoryEx for 1GiB huge pages - static bool mi_huge_pages_available = true; - if (pNtAllocateVirtualMemoryEx != NULL && mi_huge_pages_available) { + static _Atomic(size_t) mi_huge_pages_available = MI_ATOMIC_VAR_INIT(1); + if (pNtAllocateVirtualMemoryEx != NULL && mi_atomic_load_acquire(&mi_huge_pages_available) != 0) { params[0].Type.Type = MiMemExtendedParameterAttributeFlags; params[0].Arg.ULong64 = MI_MEM_EXTENDED_PARAMETER_NONPAGED_HUGE; ULONG param_count = 1; @@ -324,13 +444,13 @@ static void* _mi_prim_alloc_huge_os_pagesx(void* hint_addr, size_t size, int num } SIZE_T psize = size; void* base = hint_addr; - NTSTATUS err = (*pNtAllocateVirtualMemoryEx)(GetCurrentProcess(), &base, &psize, flags, PAGE_READWRITE, params, param_count); + LONG err = (*pNtAllocateVirtualMemoryEx)(GetCurrentProcess(), &base, &psize, flags, PAGE_READWRITE, params, param_count); if (err == 0 && base != NULL) { return base; } else { // fall back to regular large pages - mi_huge_pages_available = false; // don't try further huge pages + mi_atomic_store_release(&mi_huge_pages_available,0); // don't try further huge pages _mi_warning_message("unable to allocate using huge (1GiB) pages, trying large (2MiB) pages instead (status 0x%lx)\n", err); } } @@ -378,9 +498,11 @@ size_t _mi_prim_numa_node(void) { size_t _mi_prim_numa_node_count(void) { ULONG numa_max = 0; - GetNumaHighestNodeNumber(&numa_max); + if (pGetNumaHighestNodeNumber!=NULL) { + (*pGetNumaHighestNodeNumber)(&numa_max); + } // find the highest node number that has actual processors assigned to it. Issue #282 - while(numa_max > 0) { + while (numa_max > 0) { if (pGetNumaNodeProcessorMaskEx != NULL) { // Extended API is supported GROUP_AFFINITY affinity; @@ -391,8 +513,10 @@ size_t _mi_prim_numa_node_count(void) { else { // Vista or earlier, use older API that is limited to 64 processors. ULONGLONG mask; - if (GetNumaNodeProcessorMask((UCHAR)numa_max, &mask)) { - if (mask != 0) break; // found the maximum non-empty node + if (pGetNumaNodeProcessorMask != NULL) { + if ((*pGetNumaNodeProcessorMask)((UCHAR)numa_max, &mask)) { + if (mask != 0) break; // found the maximum non-empty node + } }; } // max node was invalid or had no processor assigned, try again @@ -410,8 +534,9 @@ static mi_msecs_t mi_to_msecs(LARGE_INTEGER t) { static LARGE_INTEGER mfreq; // = 0 if (mfreq.QuadPart == 0LL) { LARGE_INTEGER f; - QueryPerformanceFrequency(&f); - mfreq.QuadPart = f.QuadPart/1000LL; + if (QueryPerformanceFrequency(&f)) { + mfreq.QuadPart = f.QuadPart/1000LL; + } if (mfreq.QuadPart == 0) mfreq.QuadPart = 1; } return (mi_msecs_t)(t.QuadPart / mfreq.QuadPart); @@ -419,8 +544,12 @@ static mi_msecs_t mi_to_msecs(LARGE_INTEGER t) { mi_msecs_t _mi_prim_clock_now(void) { LARGE_INTEGER t; - QueryPerformanceCounter(&t); - return mi_to_msecs(t); + if (QueryPerformanceCounter(&t)) { + return mi_to_msecs(t); + } + else { + return 0; + } } @@ -428,7 +557,6 @@ mi_msecs_t _mi_prim_clock_now(void) { // Process Info //---------------------------------------------------------------- -#include #include static mi_msecs_t filetime_msecs(const FILETIME* ftime) { @@ -448,29 +576,31 @@ void _mi_prim_process_info(mi_process_info_t* pinfo) FILETIME ut; FILETIME st; FILETIME et; - GetProcessTimes(GetCurrentProcess(), &ct, &et, &st, &ut); - pinfo->utime = filetime_msecs(&ut); - pinfo->stime = filetime_msecs(&st); + if (GetProcessTimes(GetCurrentProcess(), &ct, &et, &st, &ut)) { + pinfo->utime = filetime_msecs(&ut); + pinfo->stime = filetime_msecs(&st); + } // load psapi on demand - if (pGetProcessMemoryInfo == NULL) { - HINSTANCE hDll = LoadLibrary(TEXT("psapi.dll")); + mi_atomic_do_once{ + HINSTANCE hDll = mi_win_loadlibrary(TEXT("psapi.dll")); if (hDll != NULL) { pGetProcessMemoryInfo = (PGetProcessMemoryInfo)(void (*)(void))GetProcAddress(hDll, "GetProcessMemoryInfo"); + // mi_win_freelibrary(hDll, true); // don't free } } // get process info - PROCESS_MEMORY_COUNTERS info; - memset(&info, 0, sizeof(info)); if (pGetProcessMemoryInfo != NULL) { - pGetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info)); + PROCESS_MEMORY_COUNTERS info; _mi_memzero_var(info); + if (pGetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info))) { + pinfo->current_rss = (size_t)info.WorkingSetSize; + pinfo->peak_rss = (size_t)info.PeakWorkingSetSize; + pinfo->current_commit = (size_t)info.PagefileUsage; + pinfo->peak_commit = (size_t)info.PeakPagefileUsage; + pinfo->page_faults = (size_t)info.PageFaultCount; + } } - pinfo->current_rss = (size_t)info.WorkingSetSize; - pinfo->peak_rss = (size_t)info.PeakWorkingSetSize; - pinfo->current_commit = (size_t)info.PagefileUsage; - pinfo->peak_commit = (size_t)info.PeakPagefileUsage; - pinfo->page_faults = (size_t)info.PageFaultCount; } //---------------------------------------------------------------- @@ -482,28 +612,37 @@ void _mi_prim_out_stderr( const char* msg ) // on windows with redirection, the C runtime cannot handle locale dependent output // after the main thread closes so we use direct console output. if (!_mi_preloading()) { - // _cputs(msg); // _cputs cannot be used at is aborts if it fails to lock the console static HANDLE hcon = INVALID_HANDLE_VALUE; - static bool hconIsConsole; + #if MI_WIN_DESKTOP + static bool hconIsConsole = false; + #endif if (hcon == INVALID_HANDLE_VALUE) { + hcon = GetStdHandle(STD_ERROR_HANDLE); // returns NULL if no stderr is available + #if MI_WIN_DESKTOP + if (hcon==NULL) { + AttachConsole(ATTACH_PARENT_PROCESS); // if started from a parent console, try to attach to that + hcon = GetStdHandle(STD_ERROR_HANDLE); + } CONSOLE_SCREEN_BUFFER_INFO sbi; - hcon = GetStdHandle(STD_ERROR_HANDLE); - hconIsConsole = ((hcon != INVALID_HANDLE_VALUE) && GetConsoleScreenBufferInfo(hcon, &sbi)); + hconIsConsole = ((hcon != NULL && hcon != INVALID_HANDLE_VALUE) && GetConsoleScreenBufferInfo(hcon, &sbi)); + #endif } const size_t len = _mi_strlen(msg); if (len > 0 && len < UINT32_MAX) { DWORD written = 0; - if (hconIsConsole) { - WriteConsoleA(hcon, msg, (DWORD)len, &written, NULL); - } - else if (hcon != INVALID_HANDLE_VALUE) { - // use direct write if stderr was redirected - WriteFile(hcon, msg, (DWORD)len, &written, NULL); - } - else { - // finally fall back to fputs after all - fputs(msg, stderr); + if (hcon != NULL && hcon != INVALID_HANDLE_VALUE) { + #if MI_WIN_DESKTOP + if (hconIsConsole) { + WriteConsoleA(hcon, msg, (DWORD)len, &written, NULL); + } + else + #endif + { + // use direct write in case stderr was redirected + WriteFile(hcon, msg, (DWORD)len, &written, NULL); + } } + // don't fall back to fputs or _cputs as the crt can have it locked } } } @@ -517,14 +656,13 @@ void _mi_prim_out_stderr( const char* msg ) // reliably even when this is invoked before the C runtime is initialized. // i.e. when `_mi_preloading() == true`. // Note: on windows, environment names are not case sensitive. -bool _mi_prim_getenv(const char* name, char* result, size_t result_size) { +int _mi_prim_getenv(const char* name, char* result, size_t result_size) { result[0] = 0; - size_t len = GetEnvironmentVariableA(name, result, (DWORD)result_size); - return (len > 0 && len < result_size); + const size_t len = GetEnvironmentVariableA(name, result, (DWORD)result_size); + return (len < result_size ? (len > 0 ? 1 /* success */ : 0 /* not found */) : -1 /* error */); } - //---------------------------------------------------------------- // Random //---------------------------------------------------------------- @@ -553,70 +691,496 @@ typedef LONG (NTAPI *PBCryptGenRandom)(HANDLE, PUCHAR, ULONG, ULONG); static PBCryptGenRandom pBCryptGenRandom = NULL; bool _mi_prim_random_buf(void* buf, size_t buf_len) { - if (pBCryptGenRandom == NULL) { - HINSTANCE hDll = LoadLibrary(TEXT("bcrypt.dll")); + mi_assert(buf_len <= ULONG_MAX); + if (buf_len > ULONG_MAX) return false; + mi_atomic_do_once { + HINSTANCE hDll = mi_win_loadlibrary(TEXT("bcrypt.dll")); if (hDll != NULL) { pBCryptGenRandom = (PBCryptGenRandom)(void (*)(void))GetProcAddress(hDll, "BCryptGenRandom"); + // mi_win_freelibrary(hDll); // don't free } - if (pBCryptGenRandom == NULL) return false; } + if (pBCryptGenRandom == NULL) return false; return (pBCryptGenRandom(NULL, (PUCHAR)buf, (ULONG)buf_len, BCRYPT_USE_SYSTEM_PREFERRED_RNG) >= 0); } #endif // MI_USE_RTLGENRANDOM + + //---------------------------------------------------------------- -// Thread init/done +// Process & Thread Init/Done //---------------------------------------------------------------- -#if !defined(MI_SHARED_LIB) - -// use thread local storage keys to detect thread ending -#include -#if (_WIN32_WINNT < 0x600) // before Windows Vista -WINBASEAPI DWORD WINAPI FlsAlloc( _In_opt_ PFLS_CALLBACK_FUNCTION lpCallback ); -WINBASEAPI PVOID WINAPI FlsGetValue( _In_ DWORD dwFlsIndex ); -WINBASEAPI BOOL WINAPI FlsSetValue( _In_ DWORD dwFlsIndex, _In_opt_ PVOID lpFlsData ); -WINBASEAPI BOOL WINAPI FlsFree(_In_ DWORD dwFlsIndex); +#if MI_WIN_USE_FIXED_TLS==1 +mi_decl_cache_align size_t _mi_win_tls_offset = 0; #endif -static DWORD mi_fls_key = (DWORD)(-1); - -static void NTAPI mi_fls_done(PVOID value) { - mi_heap_t* heap = (mi_heap_t*)value; - if (heap != NULL) { - _mi_thread_done(heap); - FlsSetValue(mi_fls_key, NULL); // prevent recursion as _mi_thread_done may set it back to the main heap, issue #672 +//static void mi_debug_out(const char* s) { +// HANDLE h = GetStdHandle(STD_ERROR_HANDLE); +// WriteConsole(h, s, (DWORD)_mi_strlen(s), NULL, NULL); +//} + +static void mi_win_tls_init(DWORD reason) { + if (reason==DLL_PROCESS_ATTACH || reason==DLL_THREAD_ATTACH) { + #if MI_WIN_USE_FIXED_TLS==1 // we must allocate a TLS slot dynamically + if (_mi_win_tls_offset == 0 && reason == DLL_PROCESS_ATTACH) { + const DWORD tls_slot = TlsAlloc(); // usually returns slot 1 + if (tls_slot == TLS_OUT_OF_INDEXES) { + _mi_error_message(EFAULT, "unable to allocate the a TLS slot (rebuild without MI_WIN_USE_FIXED_TLS?)\n"); + } + _mi_win_tls_offset = (size_t)tls_slot * sizeof(void*); + } + #endif + #if MI_HAS_TLS_SLOT >= 2 // we must initialize the TLS slot before any allocation + if (mi_prim_get_default_heap() == NULL) { + _mi_heap_set_default_direct((mi_heap_t*)&_mi_heap_empty); + #if MI_DEBUG && MI_WIN_USE_FIXED_TLS==1 + void* const p = TlsGetValue((DWORD)(_mi_win_tls_offset / sizeof(void*))); + mi_assert_internal(p == (void*)&_mi_heap_empty); + #endif + } + #endif } } -void _mi_prim_thread_init_auto_done(void) { - mi_fls_key = FlsAlloc(&mi_fls_done); +mi_decl_maybe_unused +static void NTAPI mi_win_main(PVOID module, DWORD reason, LPVOID reserved) { + MI_UNUSED(reserved); + MI_UNUSED(module); + mi_win_tls_init(reason); + if (reason==DLL_PROCESS_ATTACH) { + _mi_auto_process_init(); + } + else if (reason==DLL_PROCESS_DETACH) { + _mi_auto_process_done(); + } + else if (reason==DLL_THREAD_DETACH && !_mi_is_redirected()) { + _mi_thread_done(NULL); + } } -void _mi_prim_thread_done_auto_done(void) { - // call thread-done on all threads (except the main thread) to prevent - // dangling callback pointer if statically linked with a DLL; Issue #208 - FlsFree(mi_fls_key); -} -void _mi_prim_thread_associate_default_heap(mi_heap_t* heap) { - mi_assert_internal(mi_fls_key != (DWORD)(-1)); - FlsSetValue(mi_fls_key, heap); -} +/* ----------------------------------------------------------------------- + Auto initialize and finalize mimalloc on process and thread start/end. + By default we use a combination of CRT init and TLS sections for + both static and dynamic linkage (`MI_WIN_INIT_USE_CRT_TLS`). +------------------------------------------------------------------------- */ +#if !defined(MI_WIN_INIT_USE_CRT_TLS) && !defined(MI_WIN_INIT_USE_RAW_DLLMAIN) && !defined(MI_WIN_INIT_USE_TLS_DLLMAIN) && !defined(MI_WIN_INIT_USE_FLS) + #if defined(__INTEL_LLVM_COMPILER) || defined(__INTEL_COMPILER) + #define MI_WIN_INIT_USE_TLS_DLLMAIN 1 /* needed for Intel ICX, see issue #1268 */ + #else + #define MI_WIN_INIT_USE_CRT_TLS 1 /* default */ + #endif +#endif -#else +#if defined(MI_WIN_INIT_USE_CRT_TLS) + #if !defined(__MINGW32__) || defined(MI_MINGW_UCRT64) // on mingw without UCRT use the constructor attribute (in `src/prim/prim.c`) + #define MI_PRIM_HAS_PROCESS_ATTACH 1 + #endif -// Dll; nothing to do as in that case thread_done is handled through the DLL_THREAD_DETACH event. + // nothing to do since `_mi_thread_done` is handled through the DLL_THREAD_DETACH event. + void _mi_prim_thread_init_auto_done(void) {} + void _mi_prim_thread_done_auto_done(void) {} + void _mi_prim_thread_associate_default_heap(mi_heap_t* heap) { + MI_UNUSED(heap); + } -void _mi_prim_thread_init_auto_done(void) { -} + static bool mi_module_is_dll(PVOID mod) { + if (mod==NULL) return false; + PIMAGE_DOS_HEADER imageDosHeader = (PIMAGE_DOS_HEADER)mod; + PIMAGE_NT_HEADERS imageNtHeaders = (PIMAGE_NT_HEADERS)((unsigned char*)imageDosHeader + imageDosHeader->e_lfanew); + return ((imageNtHeaders->FileHeader.Characteristics & IMAGE_FILE_DLL) == IMAGE_FILE_DLL); + } -void _mi_prim_thread_done_auto_done(void) { -} + static bool mi_current_module_is_dll(void) { + HMODULE mod = NULL; + const BOOL ok = GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR)mi_current_module_is_dll, &mod); + return (ok && mi_module_is_dll(mod)); + } -void _mi_prim_thread_associate_default_heap(mi_heap_t* heap) { - MI_UNUSED(heap); -} + // Hook into CRT initialization and finalization. + static void mi_cdecl mi_crt_done(void) { + // mi_debug_out(mi_current_module_is_dll() ? "crt dll done\n" : "crt exe done\n"); + mi_win_main(NULL, DLL_PROCESS_DETACH, 0); + } + + static int mi_cdecl mi_crt_init(void) { + // mi_debug_out(mi_current_module_is_dll() ? "crt dll init\n" : "crt exe init\n"); + if (mi_current_module_is_dll()) { + // in a dll, atexit (crt_done) is called after tls process detach + atexit(&mi_crt_done); + } + return 0; + } + + // We also hook into the Windows loader TLS initialization and finalization. + static void NTAPI mi_tls_attach(PVOID module, DWORD reason, LPVOID reserved) { + if (reason == DLL_THREAD_ATTACH) { + //mi_debug_out("tls thread attach\n"); + mi_win_main(module, reason, reserved); + } + else if (reason == DLL_PROCESS_ATTACH) { + // mi_debug_out(mi_module_is_dll(module) ? "tls dll process attach\n" : "tls exe process attach\n"); + // tls process attach is always called before crt init + mi_win_main(module, reason, reserved); + } + } + + static void NTAPI mi_tls_detach(PVOID module, DWORD reason, LPVOID reserved) { + if (reason == DLL_THREAD_DETACH) { + //mi_debug_out("tls thread detach\n"); + mi_win_main(module, reason, reserved); + } + else if (reason == DLL_PROCESS_DETACH) { + // mi_debug_out(mi_module_is_dll(module) ? "tls dll process detach\n" : "tls exe process detach\n"); + if (!mi_module_is_dll(module)) { + // in an exe, tls process detach is called after atexit (mi_crt_done) + mi_win_main(module, reason, reserved); + } + } + } + + // Set up TLS callbacks in a statically linked library by using special data sections. + // See + // We use 2 entries to ensure we call attach events before constructors + // are called, and detach events after destructors are called. + // We also set up a CRT initialization callback. + #if defined(__cplusplus) + extern "C" { + #endif + + typedef int (mi_cdecl* mi_crt_callback_t)(void); + + #if defined(_WIN64) && defined(_MSC_VER) // 64-bit + #pragma comment(linker, "/INCLUDE:_tls_used") + #pragma comment(linker, "/INCLUDE:_mi_tls_callback_pre") + #pragma comment(linker, "/INCLUDE:_mi_tls_callback_post") + #pragma comment(linker, "/INCLUDE:_mi_crt_callback_init") + #pragma const_seg(".CRT$XLB") + extern const PIMAGE_TLS_CALLBACK _mi_tls_callback_pre[]; + const PIMAGE_TLS_CALLBACK _mi_tls_callback_pre[] = { &mi_tls_attach }; + #pragma const_seg() + #pragma const_seg(".CRT$XLY") + extern const PIMAGE_TLS_CALLBACK _mi_tls_callback_post[]; + const PIMAGE_TLS_CALLBACK _mi_tls_callback_post[] = { &mi_tls_detach }; + #pragma const_seg() + #pragma const_seg(".CRT$XIB") + extern const mi_crt_callback_t _mi_crt_callback_init[]; + const mi_crt_callback_t _mi_crt_callback_init[] = { &mi_crt_init }; + #pragma const_seg() + #elif defined(_MSC_VER) // 32-bit + #pragma comment(linker, "/INCLUDE:__tls_used") + #pragma comment(linker, "/INCLUDE:__mi_tls_callback_pre") + #pragma comment(linker, "/INCLUDE:__mi_tls_callback_post") + #pragma comment(linker, "/INCLUDE:__mi_crt_callback_init") + #pragma data_seg(".CRT$XLB") + PIMAGE_TLS_CALLBACK _mi_tls_callback_pre[] = { &mi_tls_attach }; + #pragma data_seg() + #pragma data_seg(".CRT$XLY") + PIMAGE_TLS_CALLBACK _mi_tls_callback_post[] = { &mi_tls_detach }; + #pragma data_seg() + #pragma data_seg(".CRT$XIB") + mi_crt_callback_t _mi_crt_callback_init[] = { &mi_crt_init }; + #pragma data_seg() + #elif defined(__MINGW32__) + extern const IMAGE_TLS_DIRECTORY _tls_used; + __attribute__((used)) static const void* const mi_tls_used_ref = &_tls_used; // pull in the CRT tls + __attribute__((used, section(".CRT$XLB"))) PIMAGE_TLS_CALLBACK _mi_tls_callback_pre = &mi_tls_attach; + __attribute__((used, section(".CRT$XLY"))) PIMAGE_TLS_CALLBACK _mi_tls_callback_post = &mi_tls_detach; + __attribute__((used, section(".CRT$XIB"))) mi_crt_callback_t _mi_crt_callback_init = &mi_crt_init; + #endif + + #if defined(__cplusplus) + } + #endif + +/* ---------------------------------------------------------------- + Here we use a combination of the raw DLL main and TLS sections for + both static and dynamic linkage. This is perhaps the most robust as + the raw DLL main ensure we can close mimalloc latest possible. + However, it can lead to link errors with on `_pRawDllMain` if other + libraries also try to hook into this (like Boost). +*/ +#elif defined(MI_WIN_INIT_USE_RAW_DLLMAIN) + #define MI_PRIM_HAS_PROCESS_ATTACH 1 + // nothing to do since `_mi_thread_done` is handled through the DLL_THREAD_DETACH event. + void _mi_prim_thread_init_auto_done(void) {} + void _mi_prim_thread_done_auto_done(void) {} + void _mi_prim_thread_associate_default_heap(mi_heap_t* heap) { + MI_UNUSED(heap); + } + + // If linked into a DLL module, this raw entry is called before the CRT attach and + // after the CRT detach through the CRT _pRawDllMain pointer. + static BOOL NTAPI mi_dll_main_raw(PVOID module, DWORD reason, LPVOID reserved) { + mi_win_main(module, reason, reserved); + return TRUE; + } + + // Set the value of the CRT _pRawDllMain pointer + #if defined(__cplusplus) + extern "C" + #endif + PVOID _pRawDllMain = (PVOID)&mi_dll_main_raw; + + // We also hook into the Windows loader TLS initialization and finalization. + // If we are linked into an EXE module we rely on these as `mi_dll_main_raw` + // is not called (and otherwise we ignore the TLS callbacks by checking if we are in a DLL). + static bool mi_module_is_dll(PVOID mod) { + if (mod==NULL) return false; + PIMAGE_DOS_HEADER imageDosHeader = (PIMAGE_DOS_HEADER)mod; + PIMAGE_NT_HEADERS imageNtHeaders = (PIMAGE_NT_HEADERS)((unsigned char*)imageDosHeader + imageDosHeader->e_lfanew); + return ((imageNtHeaders->FileHeader.Characteristics & IMAGE_FILE_DLL) == IMAGE_FILE_DLL); + } + + static void NTAPI mi_tls_attach(PVOID module, DWORD reason, LPVOID reserved) { + if (reason == DLL_PROCESS_ATTACH || reason == DLL_THREAD_ATTACH) { + if (!mi_module_is_dll(module)) { + mi_win_main(module, reason, reserved); + } + } + } + + static void NTAPI mi_tls_detach(PVOID module, DWORD reason, LPVOID reserved) { + if (reason == DLL_PROCESS_DETACH || reason == DLL_THREAD_DETACH) { + if (!mi_module_is_dll(module)) { + mi_win_main(module, reason, reserved); + } + } + } + + // Set up TLS callbacks in a statically linked library by using special data sections. + // See + // We use 2 entries to ensure we call attach events before constructors + // are called, and detach events after destructors are called. + #if defined(__cplusplus) + extern "C" { + #endif + + #if defined(_WIN64) && defined(_MSC_VER) // 64-bit + #pragma comment(linker, "/INCLUDE:_tls_used") + #pragma comment(linker, "/INCLUDE:_mi_tls_callback_pre") + #pragma comment(linker, "/INCLUDE:_mi_tls_callback_post") + #pragma const_seg(".CRT$XLB") + extern const PIMAGE_TLS_CALLBACK _mi_tls_callback_pre[]; + const PIMAGE_TLS_CALLBACK _mi_tls_callback_pre[] = { &mi_tls_attach }; + #pragma const_seg() + #pragma const_seg(".CRT$XLY") + extern const PIMAGE_TLS_CALLBACK _mi_tls_callback_post[]; + const PIMAGE_TLS_CALLBACK _mi_tls_callback_post[] = { &mi_tls_detach }; + #pragma const_seg() + #elif defined(_MSC_VER) // 32-bit + #pragma comment(linker, "/INCLUDE:__tls_used") + #pragma comment(linker, "/INCLUDE:__mi_tls_callback_pre") + #pragma comment(linker, "/INCLUDE:__mi_tls_callback_post") + #pragma data_seg(".CRT$XLB") + PIMAGE_TLS_CALLBACK _mi_tls_callback_pre[] = { &mi_tls_attach }; + #pragma data_seg() + #pragma data_seg(".CRT$XLY") + PIMAGE_TLS_CALLBACK _mi_tls_callback_post[] = { &mi_tls_detach }; + #pragma data_seg() + #elif defined(__MINGW32__) + extern const IMAGE_TLS_DIRECTORY _tls_used; + __attribute__((used)) static const void* const mi_tls_used_ref = &_tls_used; // pull in the CRT tls + __attribute__((used, section(".CRT$XLB"))) PIMAGE_TLS_CALLBACK _mi_tls_callback_pre = &mi_tls_attach; + __attribute__((used, section(".CRT$XLY"))) PIMAGE_TLS_CALLBACK _mi_tls_callback_post = &mi_tls_detach; + #endif + + #if defined(__cplusplus) + } + #endif + +/* -------------------------------------------------------------------- + Legacy options: DllMain, TLS, and FLS + --------------------------------------------------------------------*/ +#elif defined(MI_WIN_INIT_USE_TLS_DLLMAIN) && defined(MI_SHARED_LIB) + #define MI_PRIM_HAS_PROCESS_ATTACH 1 + + // Windows DLL: easy to hook into process_init and thread_done + BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) { + mi_win_main((PVOID)inst,reason,reserved); + return TRUE; + } + + // nothing to do since `_mi_thread_done` is handled through the DLL_THREAD_DETACH event. + void _mi_prim_thread_init_auto_done(void) { } + void _mi_prim_thread_done_auto_done(void) { } + void _mi_prim_thread_associate_default_heap(mi_heap_t* heap) { + MI_UNUSED(heap); + } + +#elif defined(MI_WIN_INIT_USE_TLS_DLLMAIN) + #define MI_PRIM_HAS_PROCESS_ATTACH 1 + + static void NTAPI mi_win_main_attach(PVOID module, DWORD reason, LPVOID reserved) { + if (reason == DLL_PROCESS_ATTACH || reason == DLL_THREAD_ATTACH) { + mi_win_main(module, reason, reserved); + } + } + static void NTAPI mi_win_main_detach(PVOID module, DWORD reason, LPVOID reserved) { + if (reason == DLL_PROCESS_DETACH || reason == DLL_THREAD_DETACH) { + mi_win_main(module, reason, reserved); + } + } + + // Set up TLS callbacks in a statically linked library by using special data sections. + // See + // We use 2 entries to ensure we call attach events before constructors + // are called, and detach events after destructors are called. + #if defined(__cplusplus) + extern "C" { + #endif + #if defined(_WIN64) && defined(_MSC_VER) // 64-bit + #pragma comment(linker, "/INCLUDE:_tls_used") + #pragma comment(linker, "/INCLUDE:_mi_tls_callback_pre") + #pragma comment(linker, "/INCLUDE:_mi_tls_callback_post") + #pragma const_seg(".CRT$XLB") + extern const PIMAGE_TLS_CALLBACK _mi_tls_callback_pre[]; + const PIMAGE_TLS_CALLBACK _mi_tls_callback_pre[] = { &mi_win_main_attach }; + #pragma const_seg() + #pragma const_seg(".CRT$XLY") + extern const PIMAGE_TLS_CALLBACK _mi_tls_callback_post[]; + const PIMAGE_TLS_CALLBACK _mi_tls_callback_post[] = { &mi_win_main_detach }; + #pragma const_seg() + #elif defined(_MSC_VER) // 32-bit + #pragma comment(linker, "/INCLUDE:__tls_used") + #pragma comment(linker, "/INCLUDE:__mi_tls_callback_pre") + #pragma comment(linker, "/INCLUDE:__mi_tls_callback_post") + #pragma data_seg(".CRT$XLB") + PIMAGE_TLS_CALLBACK _mi_tls_callback_pre[] = { &mi_win_main_attach }; + #pragma data_seg() + #pragma data_seg(".CRT$XLY") + PIMAGE_TLS_CALLBACK _mi_tls_callback_post[] = { &mi_win_main_detach }; + #pragma data_seg() + #elif defined(__MINGW32__) + extern const IMAGE_TLS_DIRECTORY _tls_used; + __attribute__((used)) static const void* const mi_tls_used_ref = &_tls_used; // pull in the CRT tls + __attribute__((used, section(".CRT$XLB"))) PIMAGE_TLS_CALLBACK _mi_tls_callback_pre = &mi_tls_attach; + __attribute__((used, section(".CRT$XLY"))) PIMAGE_TLS_CALLBACK _mi_tls_callback_post = &mi_tls_detach; + #endif + + #if defined(__cplusplus) + } + #endif + + // nothing to do since `_mi_thread_done` is handled through the DLL_THREAD_DETACH event. + void _mi_prim_thread_init_auto_done(void) { } + void _mi_prim_thread_done_auto_done(void) { } + void _mi_prim_thread_associate_default_heap(mi_heap_t* heap) { + MI_UNUSED(heap); + } + +#elif defined(MI_WIN_INIT_USE_FLS) // deprecated: statically linked, use fiber api + + #if defined(_MSC_VER) // on clang/gcc use the constructor attribute (in `src/prim/prim.c`) + // MSVC: use data section magic for static libraries + // See + #define MI_PRIM_HAS_PROCESS_ATTACH 1 + + static int mi_cdecl mi_crt_init(void) { + mi_win_main(NULL,DLL_PROCESS_ATTACH,NULL); + atexit(&_mi_auto_process_done); + return 0; + } + + #if defined(__cplusplus) + extern "C" { + #endif + typedef int (mi_cdecl* mi_crt_callback_t)(void); + #if defined(_WIN64) // 64-bit + #pragma comment(linker, "/INCLUDE:_mi_crt_callback_init") + #pragma const_seg(".CRT$XIU") + extern const mi_crt_callback_t _mi_crt_callback_init[]; + const mi_crt_callback_t _mi_crt_callback_init[] = { &mi_crt_init }; + #pragma const_seg() + #else // 32-bit + #pragma comment(linker, "/INCLUDE:__mi_crt_callback_init") + #pragma data_seg(".CRT$XIU") + mi_crt_callback_t _mi_crt_callback_init[] = { &mi_crt_init }; + #pragma data_seg() + #endif + #if defined(__cplusplus) + } + #endif + #endif + + // use the fiber api for calling `_mi_thread_done`. + #include + #if (_WIN32_WINNT < 0x600) // before Windows Vista + WINBASEAPI DWORD WINAPI FlsAlloc( _In_opt_ PFLS_CALLBACK_FUNCTION lpCallback ); + WINBASEAPI PVOID WINAPI FlsGetValue( _In_ DWORD dwFlsIndex ); + WINBASEAPI BOOL WINAPI FlsSetValue( _In_ DWORD dwFlsIndex, _In_opt_ PVOID lpFlsData ); + WINBASEAPI BOOL WINAPI FlsFree(_In_ DWORD dwFlsIndex); + #endif + + static DWORD mi_fls_key = (DWORD)(-1); + + static void NTAPI mi_fls_done(PVOID value) { + mi_heap_t* heap = (mi_heap_t*)value; + if (heap != NULL) { + _mi_thread_done(heap); + FlsSetValue(mi_fls_key, NULL); // prevent recursion as _mi_thread_done may set it back to the main heap, issue #672 + } + } + + void _mi_prim_thread_init_auto_done(void) { + mi_fls_key = FlsAlloc(&mi_fls_done); + } + + void _mi_prim_thread_done_auto_done(void) { + // call thread-done on all threads (except the main thread) to prevent + // dangling callback pointer if statically linked with a DLL; Issue #208 + FlsFree(mi_fls_key); + } + + void _mi_prim_thread_associate_default_heap(mi_heap_t* heap) { + mi_assert_internal(mi_fls_key != (DWORD)(-1)); + FlsSetValue(mi_fls_key, heap); + } +#else +#error "define windows process and thread auto initialization" +#endif + +// ---------------------------------------------------- +// Communicate with the redirection module on Windows +// ---------------------------------------------------- +#if defined(MI_SHARED_LIB) && !defined(MI_WIN_NOREDIRECT) + #define MI_PRIM_HAS_ALLOCATOR_INIT 1 + + static bool mi_redirected = false; // true if malloc redirects to mi_malloc + + bool _mi_is_redirected(void) { + return mi_redirected; + } + + #ifdef __cplusplus + extern "C" { + #endif + mi_decl_export void _mi_redirect_entry(DWORD reason) { + // called on redirection; careful as this may be called before DllMain + mi_win_tls_init(reason); + if (reason == DLL_PROCESS_ATTACH) { + mi_redirected = true; + } + else if (reason == DLL_PROCESS_DETACH) { + mi_redirected = false; + } + else if (reason == DLL_THREAD_DETACH) { + // mi_debug_out("redirect thread detach\n"); + _mi_thread_done(NULL); + } + } + __declspec(dllimport) bool mi_cdecl mi_allocator_init(const char** message); + __declspec(dllimport) void mi_cdecl mi_allocator_done(void); + #ifdef __cplusplus + } + #endif + bool _mi_allocator_init(const char** message) { + return mi_allocator_init(message); + } + void _mi_allocator_done(void) { + mi_allocator_done(); + } #endif diff --git a/Objects/mimalloc/random.c b/Objects/mimalloc/random.c index 35a0633a800d6c6..f19520d930cb995 100644 --- a/Objects/mimalloc/random.c +++ b/Objects/mimalloc/random.c @@ -99,7 +99,8 @@ static void chacha_init(mi_random_ctx_t* ctx, const uint8_t key[32], uint64_t no // since we only use chacha for randomness (and not encryption) we // do not _need_ to read 32-bit values as little endian but we do anyways // just for being compatible :-) - memset(ctx, 0, sizeof(*ctx)); + ctx->output_available = 0; + _mi_memzero(ctx->output,sizeof(ctx->output)); for (size_t i = 0; i < 4; i++) { const uint8_t* sigma = (uint8_t*)"expand 32-byte k"; ctx->input[i] = read32(sigma,i); @@ -114,7 +115,8 @@ static void chacha_init(mi_random_ctx_t* ctx, const uint8_t key[32], uint64_t no } static void chacha_split(mi_random_ctx_t* ctx, uint64_t nonce, mi_random_ctx_t* ctx_new) { - memset(ctx_new, 0, sizeof(*ctx_new)); + _mi_memzero(ctx_new, sizeof(*ctx_new)); + ctx_new->weak = ctx->weak; _mi_memcpy(ctx_new->input, ctx->input, sizeof(ctx_new->input)); ctx_new->input[12] = 0; ctx_new->input[13] = 0; @@ -138,18 +140,23 @@ static bool mi_random_is_initialized(mi_random_ctx_t* ctx) { void _mi_random_split(mi_random_ctx_t* ctx, mi_random_ctx_t* ctx_new) { mi_assert_internal(mi_random_is_initialized(ctx)); mi_assert_internal(ctx != ctx_new); - chacha_split(ctx, (uintptr_t)ctx_new /*nonce*/, ctx_new); + const uintptr_t nonce_rnd = _mi_random_next(ctx); + chacha_split(ctx, (uintptr_t)ctx_new ^ nonce_rnd /*nonce*/, ctx_new); } uintptr_t _mi_random_next(mi_random_ctx_t* ctx) { mi_assert_internal(mi_random_is_initialized(ctx)); - #if MI_INTPTR_SIZE <= 4 - return chacha_next32(ctx); - #elif MI_INTPTR_SIZE == 8 - return (((uintptr_t)chacha_next32(ctx) << 32) | chacha_next32(ctx)); - #else - # error "define mi_random_next for this platform" - #endif + uintptr_t r; + do { + #if MI_INTPTR_SIZE <= 4 + r = chacha_next32(ctx); + #elif MI_INTPTR_SIZE == 8 + r = (((uintptr_t)chacha_next32(ctx) << 32) | chacha_next32(ctx)); + #else + # error "define mi_random_next for this platform" + #endif + } while (r==0); + return r; } @@ -163,7 +170,7 @@ uintptr_t _mi_os_random_weak(uintptr_t extra_seed) { x ^= _mi_prim_clock_now(); // and do a few randomization steps uintptr_t max = ((x ^ (x >> 17)) & 0x0F) + 1; - for (uintptr_t i = 0; i < max; i++) { + for (uintptr_t i = 0; i < max || x==0; i++, x++) { x = _mi_random_shuffle(x); } mi_assert_internal(x != 0); @@ -171,7 +178,7 @@ uintptr_t _mi_os_random_weak(uintptr_t extra_seed) { } static void mi_random_init_ex(mi_random_ctx_t* ctx, bool use_weak) { - uint8_t key[32] = {0}; + uint8_t key[32] = {0}; // CPython: zero-initialize to avoid an MSAN report if (use_weak || !_mi_prim_random_buf(key, sizeof(key))) { // if we fail to get random data from the OS, we fall back to a // weak random source based on the current time @@ -179,9 +186,12 @@ static void mi_random_init_ex(mi_random_ctx_t* ctx, bool use_weak) { if (!use_weak) { _mi_warning_message("unable to use secure randomness\n"); } #endif uintptr_t x = _mi_os_random_weak(0); - for (size_t i = 0; i < 8; i++) { // key is eight 32-bit words. + for (size_t i = 0; i < 32; i+=4, x++) { x = _mi_random_shuffle(x); - ((uint32_t*)key)[i] = (uint32_t)x; + key[i] = (uint8_t)(x); + key[i+1] = (uint8_t)(x>>8); + key[i+2] = (uint8_t)(x>>16); + key[i+3] = (uint8_t)(x>>24); } ctx->weak = true; } diff --git a/Objects/mimalloc/segment-map.c b/Objects/mimalloc/segment-map.c index 5141f2e1b1dffa9..a40c3fe1bf4773c 100644 --- a/Objects/mimalloc/segment-map.c +++ b/Objects/mimalloc/segment-map.c @@ -16,138 +16,132 @@ terms of the MIT license. A copy of the license can be found in the file #include "mimalloc/internal.h" #include "mimalloc/atomic.h" -#if (MI_INTPTR_SIZE==8) -#define MI_MAX_ADDRESS ((size_t)40 << 40) // 40TB (to include huge page areas) +// Reduce total address space to reduce .bss (due to the `mi_segment_map`) +#if (MI_INTPTR_SIZE > 4) && MI_TRACK_ASAN +#define MI_SEGMENT_MAP_MAX_ADDRESS (128*1024ULL*MI_GiB) // 128 TiB (see issue #881) +#elif (MI_INTPTR_SIZE > 4) +#define MI_SEGMENT_MAP_MAX_ADDRESS (48*1024ULL*MI_GiB) // 48 TiB #else -#define MI_MAX_ADDRESS ((size_t)2 << 30) // 2Gb +#define MI_SEGMENT_MAP_MAX_ADDRESS (UINT32_MAX) #endif -#define MI_SEGMENT_MAP_BITS (MI_MAX_ADDRESS / MI_SEGMENT_SIZE) -#define MI_SEGMENT_MAP_SIZE (MI_SEGMENT_MAP_BITS / 8) -#define MI_SEGMENT_MAP_WSIZE (MI_SEGMENT_MAP_SIZE / MI_INTPTR_SIZE) +#define MI_SEGMENT_MAP_PART_SIZE (MI_INTPTR_SIZE*MI_KiB - 128) // 128 > sizeof(mi_memid_t) ! +#define MI_SEGMENT_MAP_PART_BITS (8*MI_SEGMENT_MAP_PART_SIZE) +#define MI_SEGMENT_MAP_PART_ENTRIES (MI_SEGMENT_MAP_PART_SIZE / MI_INTPTR_SIZE) +#define MI_SEGMENT_MAP_PART_BIT_SPAN (MI_SEGMENT_ALIGN) // memory area covered by 1 bit -static _Atomic(uintptr_t) mi_segment_map[MI_SEGMENT_MAP_WSIZE + 1]; // 2KiB per TB with 64MiB segments +#if (MI_SEGMENT_MAP_PART_BITS < (MI_SEGMENT_MAP_MAX_ADDRESS / MI_SEGMENT_MAP_PART_BIT_SPAN)) // prevent overflow on 32-bit (issue #1017) +#define MI_SEGMENT_MAP_PART_SPAN (MI_SEGMENT_MAP_PART_BITS * MI_SEGMENT_MAP_PART_BIT_SPAN) +#else +#define MI_SEGMENT_MAP_PART_SPAN MI_SEGMENT_MAP_MAX_ADDRESS +#endif + +#define MI_SEGMENT_MAP_MAX_PARTS ((MI_SEGMENT_MAP_MAX_ADDRESS / MI_SEGMENT_MAP_PART_SPAN) + 1) + +// A part of the segment map. +typedef struct mi_segmap_part_s { + mi_memid_t memid; + _Atomic(uintptr_t) map[MI_SEGMENT_MAP_PART_ENTRIES]; +} mi_segmap_part_t; -static size_t mi_segment_map_index_of(const mi_segment_t* segment, size_t* bitidx) { +// Allocate parts on-demand to reduce .bss footprint +static _Atomic(mi_segmap_part_t*) mi_segment_map[MI_SEGMENT_MAP_MAX_PARTS]; // = { NULL, .. } + +static mi_segmap_part_t* mi_segment_map_index_of(const mi_segment_t* segment, bool create_on_demand, size_t* idx, size_t* bitidx) { + // note: segment can be invalid or NULL. mi_assert_internal(_mi_ptr_segment(segment + 1) == segment); // is it aligned on MI_SEGMENT_SIZE? - if ((uintptr_t)segment >= MI_MAX_ADDRESS) { - *bitidx = 0; - return MI_SEGMENT_MAP_WSIZE; - } - else { - const uintptr_t segindex = ((uintptr_t)segment) / MI_SEGMENT_SIZE; - *bitidx = segindex % MI_INTPTR_BITS; - const size_t mapindex = segindex / MI_INTPTR_BITS; - mi_assert_internal(mapindex < MI_SEGMENT_MAP_WSIZE); - return mapindex; + *idx = 0; + *bitidx = 0; + if ((uintptr_t)segment >= MI_SEGMENT_MAP_MAX_ADDRESS) return NULL; + const uintptr_t segindex = ((uintptr_t)segment) / MI_SEGMENT_MAP_PART_SPAN; + if (segindex >= MI_SEGMENT_MAP_MAX_PARTS) return NULL; + mi_segmap_part_t* part = mi_atomic_load_ptr_relaxed(mi_segmap_part_t, &mi_segment_map[segindex]); + + // allocate on demand to reduce .bss footprint + if mi_unlikely(part == NULL) { + if (!create_on_demand) return NULL; + mi_memid_t memid; + part = (mi_segmap_part_t*)_mi_os_zalloc(sizeof(mi_segmap_part_t), &memid); + if (part == NULL) return NULL; + part->memid = memid; + mi_segmap_part_t* expected = NULL; + if (!mi_atomic_cas_ptr_strong_release(mi_segmap_part_t, &mi_segment_map[segindex], &expected, part)) { + _mi_os_free(part, sizeof(mi_segmap_part_t), memid); + part = expected; + if (part == NULL) return NULL; + } } + mi_assert(part != NULL); + const uintptr_t offset = ((uintptr_t)segment) % MI_SEGMENT_MAP_PART_SPAN; + const uintptr_t bitofs = offset / MI_SEGMENT_MAP_PART_BIT_SPAN; + *idx = bitofs / MI_INTPTR_BITS; + *bitidx = bitofs % MI_INTPTR_BITS; + return part; } void _mi_segment_map_allocated_at(const mi_segment_t* segment) { + if (segment->memid.memkind == MI_MEM_ARENA) return; // we lookup segments first in the arena's and don't need the segment map + size_t index; size_t bitidx; - size_t index = mi_segment_map_index_of(segment, &bitidx); - mi_assert_internal(index <= MI_SEGMENT_MAP_WSIZE); - if (index==MI_SEGMENT_MAP_WSIZE) return; - uintptr_t mask = mi_atomic_load_relaxed(&mi_segment_map[index]); + mi_segmap_part_t* part = mi_segment_map_index_of(segment, true /* alloc map if needed */, &index, &bitidx); + if (part == NULL) return; // outside our address range.. + uintptr_t mask = mi_atomic_load_relaxed(&part->map[index]); uintptr_t newmask; do { newmask = (mask | ((uintptr_t)1 << bitidx)); - } while (!mi_atomic_cas_weak_release(&mi_segment_map[index], &mask, newmask)); + } while (!mi_atomic_cas_weak_release(&part->map[index], &mask, newmask)); } void _mi_segment_map_freed_at(const mi_segment_t* segment) { + if (segment->memid.memkind == MI_MEM_ARENA) return; + size_t index; size_t bitidx; - size_t index = mi_segment_map_index_of(segment, &bitidx); - mi_assert_internal(index <= MI_SEGMENT_MAP_WSIZE); - if (index == MI_SEGMENT_MAP_WSIZE) return; - uintptr_t mask = mi_atomic_load_relaxed(&mi_segment_map[index]); + mi_segmap_part_t* part = mi_segment_map_index_of(segment, false /* don't alloc if not present */, &index, &bitidx); + if (part == NULL) return; // outside our address range.. + uintptr_t mask = mi_atomic_load_relaxed(&part->map[index]); uintptr_t newmask; do { newmask = (mask & ~((uintptr_t)1 << bitidx)); - } while (!mi_atomic_cas_weak_release(&mi_segment_map[index], &mask, newmask)); + } while (!mi_atomic_cas_weak_release(&part->map[index], &mask, newmask)); } // Determine the segment belonging to a pointer or NULL if it is not in a valid segment. static mi_segment_t* _mi_segment_of(const void* p) { if (p == NULL) return NULL; - mi_segment_t* segment = _mi_ptr_segment(p); - mi_assert_internal(segment != NULL); + mi_segment_t* segment = _mi_ptr_segment(p); // segment can be NULL + size_t index; size_t bitidx; - size_t index = mi_segment_map_index_of(segment, &bitidx); - // fast path: for any pointer to valid small/medium/large object or first MI_SEGMENT_SIZE in huge - const uintptr_t mask = mi_atomic_load_relaxed(&mi_segment_map[index]); + mi_segmap_part_t* part = mi_segment_map_index_of(segment, false /* dont alloc if not present */, &index, &bitidx); + if (part == NULL) return NULL; + const uintptr_t mask = mi_atomic_load_relaxed(&part->map[index]); if mi_likely((mask & ((uintptr_t)1 << bitidx)) != 0) { - return segment; // yes, allocated by us + // yes, allocated by us + const bool cookie_ok = (_mi_ptr_cookie(segment) == segment->cookie); + if mi_likely(cookie_ok) { + return segment; // yes, allocated by us and valid + } + else { + _mi_error_message(EFAULT, "segment map found an invalid segment, possibly corrupted meta-data (address=%p, segment=%p)\n", p, segment); + } } - if (index==MI_SEGMENT_MAP_WSIZE) return NULL; - - // TODO: maintain max/min allocated range for efficiency for more efficient rejection of invalid pointers? - - // search downwards for the first segment in case it is an interior pointer - // could be slow but searches in MI_INTPTR_SIZE * MI_SEGMENT_SIZE (512MiB) steps through - // valid huge objects - // note: we could maintain a lowest index to speed up the path for invalid pointers? - size_t lobitidx; - size_t loindex; - uintptr_t lobits = mask & (((uintptr_t)1 << bitidx) - 1); - if (lobits != 0) { - loindex = index; - lobitidx = mi_bsr(lobits); // lobits != 0 - } - else if (index == 0) { - return NULL; - } - else { - mi_assert_internal(index > 0); - uintptr_t lomask = mask; - loindex = index; - do { - loindex--; - lomask = mi_atomic_load_relaxed(&mi_segment_map[loindex]); - } while (lomask != 0 && loindex > 0); - if (lomask == 0) return NULL; - lobitidx = mi_bsr(lomask); // lomask != 0 - } - mi_assert_internal(loindex < MI_SEGMENT_MAP_WSIZE); - // take difference as the addresses could be larger than the MAX_ADDRESS space. - size_t diff = (((index - loindex) * (8*MI_INTPTR_SIZE)) + bitidx - lobitidx) * MI_SEGMENT_SIZE; - segment = (mi_segment_t*)((uint8_t*)segment - diff); - - if (segment == NULL) return NULL; - mi_assert_internal((void*)segment < p); - bool cookie_ok = (_mi_ptr_cookie(segment) == segment->cookie); - mi_assert_internal(cookie_ok); - if mi_unlikely(!cookie_ok) return NULL; - if (((uint8_t*)segment + mi_segment_size(segment)) <= (uint8_t*)p) return NULL; // outside the range - mi_assert_internal(p >= (void*)segment && (uint8_t*)p < (uint8_t*)segment + mi_segment_size(segment)); - return segment; + return NULL; } // Is this a valid pointer in our heap? -static bool mi_is_valid_pointer(const void* p) { - return ((_mi_segment_of(p) != NULL) || (_mi_arena_contains(p))); +static bool mi_is_valid_pointer(const void* p) { + // first check if it is in an arena, then check if it is OS allocated + return (_mi_arena_contains(p) || _mi_segment_of(p) != NULL); } mi_decl_nodiscard mi_decl_export bool mi_is_in_heap_region(const void* p) mi_attr_noexcept { return mi_is_valid_pointer(p); } -/* -// Return the full segment range belonging to a pointer -static void* mi_segment_range_of(const void* p, size_t* size) { - mi_segment_t* segment = _mi_segment_of(p); - if (segment == NULL) { - if (size != NULL) *size = 0; - return NULL; - } - else { - if (size != NULL) *size = segment->segment_size; - return segment; +void _mi_segment_map_unsafe_destroy(void) { + for (size_t i = 0; i < MI_SEGMENT_MAP_MAX_PARTS; i++) { + mi_segmap_part_t* part = mi_atomic_exchange_ptr_relaxed(mi_segmap_part_t, &mi_segment_map[i], NULL); + if (part != NULL) { + _mi_os_free(part, sizeof(mi_segmap_part_t), part->memid); + } } - mi_assert_expensive(page == NULL || mi_segment_is_valid(_mi_page_segment(page),tld)); - mi_assert_internal(page == NULL || (mi_segment_page_size(_mi_page_segment(page)) - (MI_SECURE == 0 ? 0 : _mi_os_page_size())) >= block_size); - mi_reset_delayed(tld); - mi_assert_internal(page == NULL || mi_page_not_in_queue(page, tld)); - return page; } -*/ diff --git a/Objects/mimalloc/segment.c b/Objects/mimalloc/segment.c index 9dad69c995e7a05..660beb325ee8f8f 100644 --- a/Objects/mimalloc/segment.c +++ b/Objects/mimalloc/segment.c @@ -1,5 +1,5 @@ /* ---------------------------------------------------------------------------- -Copyright (c) 2018-2020, Microsoft Research, Daan Leijen +Copyright (c) 2018-2024, Microsoft Research, Daan Leijen This is free software; you can redistribute it and/or modify it under the terms of the MIT license. A copy of the license can be found in the file "LICENSE" at the root of this distribution. @@ -11,9 +11,13 @@ terms of the MIT license. A copy of the license can be found in the file #include // memset #include -#define MI_PAGE_HUGE_ALIGN (256*1024) +// ------------------------------------------------------------------- +// Segments +// mimalloc pages reside in segments. See `mi_segment_valid` for invariants. +// ------------------------------------------------------------------- + -static void mi_segment_try_purge(mi_segment_t* segment, bool force, mi_stats_t* stats); +static void mi_segment_try_purge(mi_segment_t* segment, bool force); // ------------------------------------------------------------------- @@ -88,9 +92,7 @@ size_t _mi_commit_mask_committed_size(const mi_commit_mask_t* cm, size_t total) count += MI_COMMIT_MASK_FIELD_BITS; } else { - for (; mask != 0; mask >>= 1) { // todo: use popcount - if ((mask&1)!=0) count++; - } + count += mi_popcount(mask); } } // we use total since for huge segments each commit bit may represent a larger size @@ -146,10 +148,23 @@ size_t _mi_commit_mask_next_run(const mi_commit_mask_t* cm, size_t* idx) { /* -------------------------------------------------------------------------------- Segment allocation - - If a thread ends, it "abandons" pages with used blocks - and there is an abandoned segment list whose segments can - be reclaimed by still running threads, much like work-stealing. + We allocate pages inside bigger "segments" (32 MiB on 64-bit). This is to avoid + splitting VMA's on Linux and reduce fragmentation on other OS's. + Each thread owns its own segments. + + Currently we have: + - small pages (64KiB) + - medium pages (512KiB) + - large pages (4MiB), + - huge segments have 1 page in one segment that can be larger than `MI_SEGMENT_SIZE`. + it is used for blocks `> MI_LARGE_OBJ_SIZE_MAX` or with alignment `> MI_BLOCK_ALIGNMENT_MAX`. + + The memory for a segment is usually committed on demand. + (i.e. we are careful to not touch the memory until we actually allocate a block there) + + If a thread ends, it "abandons" pages that still contain live blocks. + Such segments are abandoned and these can be reclaimed by still running threads, + (much like work-stealing). -------------------------------------------------------------------------------- */ @@ -212,7 +227,7 @@ static void mi_span_queue_push(mi_span_queue_t* sq, mi_slice_t* slice) { sq->first = slice; if (slice->next != NULL) slice->next->prev = slice; else sq->last = slice; - slice->xblock_size = 0; // free + slice->block_size = 0; // free } static mi_span_queue_t* mi_span_queue_for(size_t slice_count, mi_segments_tld_t* tld) { @@ -223,7 +238,7 @@ static mi_span_queue_t* mi_span_queue_for(size_t slice_count, mi_segments_tld_t* } static void mi_span_queue_delete(mi_span_queue_t* sq, mi_slice_t* slice) { - mi_assert_internal(slice->xblock_size==0 && slice->slice_count>0 && slice->slice_offset==0); + mi_assert_internal(slice->block_size==0 && slice->slice_count>0 && slice->slice_offset==0); // should work too if the queue does not contain slice (which can happen during reclaim) if (slice->prev != NULL) slice->prev->next = slice->next; if (slice == sq->first) sq->first = slice->next; @@ -231,7 +246,7 @@ static void mi_span_queue_delete(mi_span_queue_t* sq, mi_slice_t* slice) { if (slice == sq->last) sq->last = slice->prev; slice->prev = NULL; slice->next = NULL; - slice->xblock_size = 1; // no more free + slice->block_size = 1; // no more free } @@ -240,7 +255,7 @@ static void mi_span_queue_delete(mi_span_queue_t* sq, mi_slice_t* slice) { ----------------------------------------------------------- */ static bool mi_slice_is_used(const mi_slice_t* slice) { - return (slice->xblock_size > 0); + return (slice->block_size > 0); } @@ -258,29 +273,40 @@ static bool mi_segment_is_valid(mi_segment_t* segment, mi_segments_tld_t* tld) { mi_assert_internal(segment->abandoned <= segment->used); mi_assert_internal(segment->thread_id == 0 || segment->thread_id == _mi_thread_id()); mi_assert_internal(mi_commit_mask_all_set(&segment->commit_mask, &segment->purge_mask)); // can only decommit committed blocks + + // [specbot S-NEW-1] segment must have at least one slice (L1, O(1)) + mi_assert_internal(segment->segment_slices > 0); + // [specbot S-NEW-2] info slices must leave room for at least one data slice (L1, O(1)) + mi_assert_internal(segment->segment_info_slices < segment->segment_slices); + // [specbot S-NEW-3] slice_entries must not exceed array bounds (L1, O(1)) + mi_assert_internal(segment->slice_entries <= MI_SLICES_PER_SEGMENT); + //mi_assert_internal(segment->segment_info_size % MI_SEGMENT_SLICE_SIZE == 0); mi_slice_t* slice = &segment->slices[0]; const mi_slice_t* end = mi_segment_slices_end(segment); size_t used_count = 0; + size_t total_slice_count = 0; mi_span_queue_t* sq; while(slice < end) { mi_assert_internal(slice->slice_count > 0); + total_slice_count += slice->slice_count; mi_assert_internal(slice->slice_offset == 0); size_t index = mi_slice_index(slice); size_t maxindex = (index + slice->slice_count >= segment->slice_entries ? segment->slice_entries : index + slice->slice_count) - 1; - if (mi_slice_is_used(slice)) { // a page in use, we need at least MAX_SLICE_OFFSET valid back offsets + if (mi_slice_is_used(slice)) { // a page in use, we need at least MAX_SLICE_OFFSET_COUNT valid back offsets used_count++; - for (size_t i = 0; i <= MI_MAX_SLICE_OFFSET && index + i <= maxindex; i++) { + mi_assert_internal(slice->is_huge == (segment->kind == MI_SEGMENT_HUGE)); + for (size_t i = 0; i <= MI_MAX_SLICE_OFFSET_COUNT && index + i <= maxindex; i++) { mi_assert_internal(segment->slices[index + i].slice_offset == i*sizeof(mi_slice_t)); mi_assert_internal(i==0 || segment->slices[index + i].slice_count == 0); - mi_assert_internal(i==0 || segment->slices[index + i].xblock_size == 1); + mi_assert_internal(i==0 || segment->slices[index + i].block_size == 1); } // and the last entry as well (for coalescing) const mi_slice_t* last = slice + slice->slice_count - 1; if (last > slice && last < mi_segment_slices_end(segment)) { mi_assert_internal(last->slice_offset == (slice->slice_count-1)*sizeof(mi_slice_t)); mi_assert_internal(last->slice_count == 0); - mi_assert_internal(last->xblock_size == 1); + mi_assert_internal(last->block_size == 1); } } else { // free range of slices; only last slice needs a valid back offset @@ -289,7 +315,7 @@ static bool mi_segment_is_valid(mi_segment_t* segment, mi_segments_tld_t* tld) { mi_assert_internal((uint8_t*)slice == (uint8_t*)last - last->slice_offset); } mi_assert_internal(slice == last || last->slice_count == 0 ); - mi_assert_internal(last->xblock_size == 0 || (segment->kind==MI_SEGMENT_HUGE && last->xblock_size==1)); + mi_assert_internal(last->block_size == 0 || (segment->kind==MI_SEGMENT_HUGE && last->block_size==1)); if (segment->kind != MI_SEGMENT_HUGE && segment->thread_id != 0) { // segment is not huge or abandoned sq = mi_span_queue_for(slice->slice_count,tld); mi_assert_internal(mi_span_queue_contains(sq,slice)); @@ -298,6 +324,8 @@ static bool mi_segment_is_valid(mi_segment_t* segment, mi_segments_tld_t* tld) { slice = &segment->slices[maxindex+1]; } mi_assert_internal(slice == end); + // [specbot S-NEW-5] Total slice counts must sum to segment_slices (L2, O(n)) + mi_assert_internal(total_slice_count == segment->segment_slices); mi_assert_internal(used_count == segment->used + 1); return true; } @@ -311,34 +339,45 @@ static size_t mi_segment_info_size(mi_segment_t* segment) { return segment->segment_info_slices * MI_SEGMENT_SLICE_SIZE; } -static uint8_t* _mi_segment_page_start_from_slice(const mi_segment_t* segment, const mi_slice_t* slice, size_t xblock_size, size_t* page_size) +static uint8_t* _mi_segment_page_start_from_slice(const mi_segment_t* segment, const mi_slice_t* slice, size_t block_size, size_t* page_size) { - ptrdiff_t idx = slice - segment->slices; - size_t psize = (size_t)slice->slice_count * MI_SEGMENT_SLICE_SIZE; + const ptrdiff_t idx = slice - segment->slices; + const size_t psize = (size_t)slice->slice_count * MI_SEGMENT_SLICE_SIZE; + uint8_t* const pstart = (uint8_t*)segment + (idx*MI_SEGMENT_SLICE_SIZE); // make the start not OS page aligned for smaller blocks to avoid page/cache effects - // note: the offset must always be an xblock_size multiple since we assume small allocations + // note: the offset must always be a block_size multiple since we assume small allocations // are aligned (see `mi_heap_malloc_aligned`). size_t start_offset = 0; - if (xblock_size >= MI_INTPTR_SIZE) { - if (xblock_size <= 64) { start_offset = 3*xblock_size; } - else if (xblock_size <= 512) { start_offset = xblock_size; } + if (block_size > 0 && block_size <= MI_MAX_ALIGN_GUARANTEE) { + // for small objects, ensure the page start is aligned with the block size (PR#66 by kickunderscore) + const size_t adjust = block_size - ((uintptr_t)pstart % block_size); + if (adjust < block_size && psize >= block_size + adjust) { + start_offset += adjust; + } } + if (block_size >= MI_INTPTR_SIZE) { + if (block_size <= 64) { start_offset += 3*block_size; } + else if (block_size <= 512) { start_offset += block_size; } + } + start_offset = _mi_align_up(start_offset, MI_MAX_ALIGN_SIZE); + mi_assert_internal(_mi_is_aligned(pstart + start_offset, MI_MAX_ALIGN_SIZE)); + mi_assert_internal(block_size == 0 || block_size > MI_MAX_ALIGN_GUARANTEE || _mi_is_aligned(pstart + start_offset,block_size)); if (page_size != NULL) { *page_size = psize - start_offset; } - return (uint8_t*)segment + ((idx*MI_SEGMENT_SLICE_SIZE) + start_offset); + return (pstart + start_offset); } // Start of the page available memory; can be used on uninitialized pages uint8_t* _mi_segment_page_start(const mi_segment_t* segment, const mi_page_t* page, size_t* page_size) { const mi_slice_t* slice = mi_page_to_slice((mi_page_t*)page); - uint8_t* p = _mi_segment_page_start_from_slice(segment, slice, page->xblock_size, page_size); - mi_assert_internal(page->xblock_size > 0 || _mi_ptr_page(p) == page); + uint8_t* p = _mi_segment_page_start_from_slice(segment, slice, mi_page_block_size(page), page_size); + mi_assert_internal(mi_page_block_size(page) > 0 || _mi_ptr_page(p) == page); mi_assert_internal(_mi_ptr_segment(p) == segment); return p; } -static size_t mi_segment_calculate_slices(size_t required, size_t* pre_size, size_t* info_slices) { +static size_t mi_segment_calculate_slices(size_t required, size_t* info_slices) { size_t page_size = _mi_os_page_size(); size_t isize = _mi_align_up(sizeof(mi_segment_t), page_size); size_t guardsize = 0; @@ -352,7 +391,6 @@ static size_t mi_segment_calculate_slices(size_t required, size_t* pre_size, siz } } - if (pre_size != NULL) *pre_size = isize; isize = _mi_align_up(isize + guardsize, MI_SEGMENT_SLICE_SIZE); if (info_slices != NULL) *info_slices = isize / MI_SEGMENT_SLICE_SIZE; size_t segment_size = (required==0 ? MI_SEGMENT_SIZE : _mi_align_up( required + isize + guardsize, MI_SEGMENT_SLICE_SIZE) ); @@ -380,6 +418,10 @@ static void mi_segment_os_free(mi_segment_t* segment, mi_segments_tld_t* tld) { segment->thread_id = 0; _mi_segment_map_freed_at(segment); mi_segments_track_size(-((long)mi_segment_size(segment)),tld); + if (segment->was_reclaimed) { + tld->reclaim_count--; + segment->was_reclaimed = false; + } if (MI_SECURE>0) { // _mi_os_unprotect(segment, mi_segment_size(segment)); // ensure no more guard pages are set // unprotect the guard pages; we cannot just unprotect the whole segment size as part may be decommitted @@ -395,17 +437,9 @@ static void mi_segment_os_free(mi_segment_t* segment, mi_segments_tld_t* tld) { const size_t size = mi_segment_size(segment); const size_t csize = _mi_commit_mask_committed_size(&segment->commit_mask, size); - _mi_abandoned_await_readers(tld->abandoned); // wait until safe to free - _mi_arena_free(segment, mi_segment_size(segment), csize, segment->memid, tld->stats); + _mi_arena_free(segment, mi_segment_size(segment), csize, segment->memid); } -// called by threads that are terminating -void _mi_segment_thread_collect(mi_segments_tld_t* tld) { - MI_UNUSED(tld); - // nothing to do -} - - /* ----------------------------------------------------------- Commit/Decommit ranges ----------------------------------------------------------- */ @@ -460,7 +494,7 @@ static void mi_segment_commit_mask(mi_segment_t* segment, bool conservative, uin mi_commit_mask_create(bitidx, bitcount, cm); } -static bool mi_segment_commit(mi_segment_t* segment, uint8_t* p, size_t size, mi_stats_t* stats) { +static bool mi_segment_commit(mi_segment_t* segment, uint8_t* p, size_t size) { mi_assert_internal(mi_commit_mask_all_set(&segment->commit_mask, &segment->purge_mask)); // commit liberal @@ -476,7 +510,7 @@ static bool mi_segment_commit(mi_segment_t* segment, uint8_t* p, size_t size, mi mi_commit_mask_t cmask; mi_commit_mask_create_intersect(&segment->commit_mask, &mask, &cmask); _mi_stat_decrease(&_mi_stats_main.committed, _mi_commit_mask_committed_size(&cmask, MI_SEGMENT_SIZE)); // adjust for overlap - if (!_mi_os_commit(start, full_size, &is_zero, stats)) return false; + if (!_mi_os_commit(start, full_size, &is_zero)) return false; mi_commit_mask_set(&segment->commit_mask, &mask); } @@ -490,15 +524,15 @@ static bool mi_segment_commit(mi_segment_t* segment, uint8_t* p, size_t size, mi return true; } -static bool mi_segment_ensure_committed(mi_segment_t* segment, uint8_t* p, size_t size, mi_stats_t* stats) { +static bool mi_segment_ensure_committed(mi_segment_t* segment, uint8_t* p, size_t size) { mi_assert_internal(mi_commit_mask_all_set(&segment->commit_mask, &segment->purge_mask)); // note: assumes commit_mask is always full for huge segments as otherwise the commit mask bits can overflow if (mi_commit_mask_is_full(&segment->commit_mask) && mi_commit_mask_is_empty(&segment->purge_mask)) return true; // fully committed mi_assert_internal(segment->kind != MI_SEGMENT_HUGE); - return mi_segment_commit(segment, p, size, stats); + return mi_segment_commit(segment, p, size); } -static bool mi_segment_purge(mi_segment_t* segment, uint8_t* p, size_t size, mi_stats_t* stats) { +static bool mi_segment_purge(mi_segment_t* segment, uint8_t* p, size_t size) { mi_assert_internal(mi_commit_mask_all_set(&segment->commit_mask, &segment->purge_mask)); if (!segment->allow_purge) return true; @@ -513,7 +547,7 @@ static bool mi_segment_purge(mi_segment_t* segment, uint8_t* p, size_t size, mi_ // purging mi_assert_internal((void*)start != (void*)segment); mi_assert_internal(segment->allow_decommit); - const bool decommitted = _mi_os_purge(start, full_size, stats); // reset or decommit + const bool decommitted = _mi_os_purge(start, full_size); // reset or decommit if (decommitted) { mi_commit_mask_t cmask; mi_commit_mask_create_intersect(&segment->commit_mask, &mask, &cmask); @@ -527,11 +561,11 @@ static bool mi_segment_purge(mi_segment_t* segment, uint8_t* p, size_t size, mi_ return true; } -static void mi_segment_schedule_purge(mi_segment_t* segment, uint8_t* p, size_t size, mi_stats_t* stats) { +static void mi_segment_schedule_purge(mi_segment_t* segment, uint8_t* p, size_t size) { if (!segment->allow_purge) return; if (mi_option_get(mi_option_purge_delay) == 0) { - mi_segment_purge(segment, p, size, stats); + mi_segment_purge(segment, p, size); } else { // register for future purge in the purge mask @@ -554,7 +588,7 @@ static void mi_segment_schedule_purge(mi_segment_t* segment, uint8_t* p, size_t else if (segment->purge_expire <= now) { // previous purge mask already expired if (segment->purge_expire + mi_option_get(mi_option_purge_extend_delay) <= now) { - mi_segment_try_purge(segment, true, stats); + mi_segment_try_purge(segment, true); } else { segment->purge_expire = now + mi_option_get(mi_option_purge_extend_delay); // (mi_option_get(mi_option_purge_delay) / 8); // wait a tiny bit longer in case there is a series of free's @@ -567,8 +601,8 @@ static void mi_segment_schedule_purge(mi_segment_t* segment, uint8_t* p, size_t } } -static void mi_segment_try_purge(mi_segment_t* segment, bool force, mi_stats_t* stats) { - if (!segment->allow_purge || mi_commit_mask_is_empty(&segment->purge_mask)) return; +static void mi_segment_try_purge(mi_segment_t* segment, bool force) { + if (!segment->allow_purge || segment->purge_expire == 0 || mi_commit_mask_is_empty(&segment->purge_mask)) return; mi_msecs_t now = _mi_clock_now(); if (!force && now < segment->purge_expire) return; @@ -583,20 +617,25 @@ static void mi_segment_try_purge(mi_segment_t* segment, bool force, mi_stats_t* if (count > 0) { uint8_t* p = (uint8_t*)segment + (idx*MI_COMMIT_SIZE); size_t size = count * MI_COMMIT_SIZE; - mi_segment_purge(segment, p, size, stats); + mi_segment_purge(segment, p, size); } } mi_commit_mask_foreach_end() mi_assert_internal(mi_commit_mask_is_empty(&segment->purge_mask)); } +// called from `mi_heap_collect_ex` +// this can be called per-page so it is important that try_purge has fast exit path +void _mi_segment_collect(mi_segment_t* segment, bool force) { + mi_segment_try_purge(segment, force); +} /* ----------------------------------------------------------- Span free ----------------------------------------------------------- */ static bool mi_segment_is_abandoned(mi_segment_t* segment) { - return (segment->thread_id == 0); + return (mi_atomic_load_relaxed(&segment->thread_id) == 0); } // note: can be called on abandoned segments @@ -613,20 +652,22 @@ static void mi_segment_span_free(mi_segment_t* segment, size_t slice_index, size mi_assert_internal(slice->slice_count == slice_count); // no overflow? slice->slice_offset = 0; if (slice_count > 1) { - mi_slice_t* last = &segment->slices[slice_index + slice_count - 1]; + mi_slice_t* last = slice + slice_count - 1; + mi_slice_t* end = (mi_slice_t*)mi_segment_slices_end(segment); + if (last > end) { last = end; } last->slice_count = 0; last->slice_offset = (uint32_t)(sizeof(mi_page_t)*(slice_count - 1)); - last->xblock_size = 0; + last->block_size = 0; } // perhaps decommit if (allow_purge) { - mi_segment_schedule_purge(segment, mi_slice_start(slice), slice_count * MI_SEGMENT_SLICE_SIZE, tld->stats); + mi_segment_schedule_purge(segment, mi_slice_start(slice), slice_count * MI_SEGMENT_SLICE_SIZE); } // and push it on the free page queue (if it was not a huge page) if (sq != NULL) mi_span_queue_push( sq, slice ); - else slice->xblock_size = 0; // mark huge page as free anyways + else slice->block_size = 0; // mark huge page as free anyways } /* @@ -640,7 +681,7 @@ static void mi_segment_span_add_free(mi_slice_t* slice, mi_segments_tld_t* tld) */ static void mi_segment_span_remove_from_queue(mi_slice_t* slice, mi_segments_tld_t* tld) { - mi_assert_internal(slice->slice_count > 0 && slice->slice_offset==0 && slice->xblock_size==0); + mi_assert_internal(slice->slice_count > 0 && slice->slice_offset==0 && slice->block_size==0); mi_assert_internal(_mi_ptr_segment(slice)->kind != MI_SEGMENT_HUGE); mi_span_queue_t* sq = mi_span_queue_for(slice->slice_count, tld); mi_span_queue_delete(sq, slice); @@ -649,24 +690,24 @@ static void mi_segment_span_remove_from_queue(mi_slice_t* slice, mi_segments_tld // note: can be called on abandoned segments static mi_slice_t* mi_segment_span_free_coalesce(mi_slice_t* slice, mi_segments_tld_t* tld) { mi_assert_internal(slice != NULL && slice->slice_count > 0 && slice->slice_offset == 0); - mi_segment_t* segment = _mi_ptr_segment(slice); - bool is_abandoned = mi_segment_is_abandoned(segment); + mi_segment_t* const segment = _mi_ptr_segment(slice); // for huge pages, just mark as free but don't add to the queues if (segment->kind == MI_SEGMENT_HUGE) { // issue #691: segment->used can be 0 if the huge page block was freed while abandoned (reclaim will get here in that case) - mi_assert_internal((segment->used==0 && slice->xblock_size==0) || segment->used == 1); // decreased right after this call in `mi_segment_page_clear` - slice->xblock_size = 0; // mark as free anyways + mi_assert_internal((segment->used==0 && slice->block_size==0) || segment->used == 1); // decreased right after this call in `mi_segment_page_clear` + slice->block_size = 0; // mark as free anyways // we should mark the last slice `xblock_size=0` now to maintain invariants but we skip it to // avoid a possible cache miss (and the segment is about to be freed) return slice; } // otherwise coalesce the span and add to the free span queues + const bool is_abandoned = mi_segment_is_abandoned(segment); size_t slice_count = slice->slice_count; mi_slice_t* next = slice + slice->slice_count; mi_assert_internal(next <= mi_segment_slices_end(segment)); - if (next < mi_segment_slices_end(segment) && next->xblock_size==0) { + if (next < mi_segment_slices_end(segment) && next->block_size==0) { // free next block -- remove it from free and merge mi_assert_internal(next->slice_count > 0 && next->slice_offset==0); slice_count += next->slice_count; // extend @@ -675,10 +716,12 @@ static mi_slice_t* mi_segment_span_free_coalesce(mi_slice_t* slice, mi_segments_ if (slice > segment->slices) { mi_slice_t* prev = mi_slice_first(slice - 1); mi_assert_internal(prev >= segment->slices); - if (prev->xblock_size==0) { + if (prev->block_size==0) { // free previous slice -- remove it from free and merge mi_assert_internal(prev->slice_count > 0 && prev->slice_offset==0); slice_count += prev->slice_count; + slice->slice_count = 0; + slice->slice_offset = (uint32_t)((uint8_t*)slice - (uint8_t*)prev); // set the slice offset for `segment_force_abandon` (in case the previous free block is very large). if (!is_abandoned) { mi_segment_span_remove_from_queue(prev, tld); } slice = prev; } @@ -696,13 +739,13 @@ static mi_slice_t* mi_segment_span_free_coalesce(mi_slice_t* slice, mi_segments_ ----------------------------------------------------------- */ // Note: may still return NULL if committing the memory failed -static mi_page_t* mi_segment_span_allocate(mi_segment_t* segment, size_t slice_index, size_t slice_count, mi_segments_tld_t* tld) { +static mi_page_t* mi_segment_span_allocate(mi_segment_t* segment, size_t slice_index, size_t slice_count) { mi_assert_internal(slice_index < segment->slice_entries); mi_slice_t* const slice = &segment->slices[slice_index]; - mi_assert_internal(slice->xblock_size==0 || slice->xblock_size==1); + mi_assert_internal(slice->block_size==0 || slice->block_size==1); // commit before changing the slice data - if (!mi_segment_ensure_committed(segment, _mi_segment_page_start_from_slice(segment, slice, 0, NULL), slice_count * MI_SEGMENT_SLICE_SIZE, tld->stats)) { + if (!mi_segment_ensure_committed(segment, _mi_segment_page_start_from_slice(segment, slice, 0, NULL), slice_count * MI_SEGMENT_SLICE_SIZE)) { return NULL; // commit failed! } @@ -711,20 +754,20 @@ static mi_page_t* mi_segment_span_allocate(mi_segment_t* segment, size_t slice_i slice->slice_count = (uint32_t)slice_count; mi_assert_internal(slice->slice_count == slice_count); const size_t bsize = slice_count * MI_SEGMENT_SLICE_SIZE; - slice->xblock_size = (uint32_t)(bsize >= MI_HUGE_BLOCK_SIZE ? MI_HUGE_BLOCK_SIZE : bsize); + slice->block_size = bsize; mi_page_t* page = mi_slice_to_page(slice); mi_assert_internal(mi_page_block_size(page) == bsize); - // set slice back pointers for the first MI_MAX_SLICE_OFFSET entries + // set slice back pointers for the first MI_MAX_SLICE_OFFSET_COUNT entries size_t extra = slice_count-1; - if (extra > MI_MAX_SLICE_OFFSET) extra = MI_MAX_SLICE_OFFSET; - if (slice_index + extra >= segment->slice_entries) extra = segment->slice_entries - slice_index - 1; // huge objects may have more slices than available entries in the segment->slices + if (extra > MI_MAX_SLICE_OFFSET_COUNT) extra = MI_MAX_SLICE_OFFSET_COUNT; + if (slice_index + extra >= segment->slice_entries) extra = segment->slice_entries - slice_index - 1; // huge objects may have more slices than avaiable entries in the segment->slices mi_slice_t* slice_next = slice + 1; for (size_t i = 1; i <= extra; i++, slice_next++) { slice_next->slice_offset = (uint32_t)(sizeof(mi_slice_t)*i); slice_next->slice_count = 0; - slice_next->xblock_size = 1; + slice_next->block_size = 1; } // and also for the last one (if not set already) (the last one is needed for coalescing and for large alignments) @@ -735,11 +778,13 @@ static mi_page_t* mi_segment_span_allocate(mi_segment_t* segment, size_t slice_i if (last > slice) { last->slice_offset = (uint32_t)(sizeof(mi_slice_t) * (last - slice)); last->slice_count = 0; - last->xblock_size = 1; + last->block_size = 1; } // and initialize the page page->is_committed = true; + page->is_zero_init = segment->free_is_zero; + page->is_huge = (segment->kind == MI_SEGMENT_HUGE); segment->used++; return page; } @@ -747,7 +792,7 @@ static mi_page_t* mi_segment_span_allocate(mi_segment_t* segment, size_t slice_i static void mi_segment_slice_split(mi_segment_t* segment, mi_slice_t* slice, size_t slice_count, mi_segments_tld_t* tld) { mi_assert_internal(_mi_ptr_segment(slice) == segment); mi_assert_internal(slice->slice_count >= slice_count); - mi_assert_internal(slice->xblock_size > 0); // no more in free queue + mi_assert_internal(slice->block_size > 0); // no more in free queue if (slice->slice_count <= slice_count) return; mi_assert_internal(segment->kind != MI_SEGMENT_HUGE); size_t next_index = mi_slice_index(slice) + slice_count; @@ -773,8 +818,8 @@ static mi_page_t* mi_segments_page_find_and_allocate(size_t slice_count, mi_aren if (slice->slice_count > slice_count) { mi_segment_slice_split(segment, slice, slice_count, tld); } - mi_assert_internal(slice != NULL && slice->slice_count == slice_count && slice->xblock_size > 0); - mi_page_t* page = mi_segment_span_allocate(segment, mi_slice_index(slice), slice->slice_count, tld); + mi_assert_internal(slice != NULL && slice->slice_count == slice_count && slice->block_size > 0); + mi_page_t* page = mi_segment_span_allocate(segment, mi_slice_index(slice), slice->slice_count); if (page == NULL) { // commit failed; return NULL but first restore the slice mi_segment_span_free_coalesce(slice, tld); @@ -796,8 +841,8 @@ static mi_page_t* mi_segments_page_find_and_allocate(size_t slice_count, mi_aren ----------------------------------------------------------- */ static mi_segment_t* mi_segment_os_alloc( size_t required, size_t page_alignment, bool eager_delayed, mi_arena_id_t req_arena_id, - size_t* psegment_slices, size_t* ppre_size, size_t* pinfo_slices, - bool commit, mi_segments_tld_t* tld, mi_os_tld_t* os_tld) + size_t* psegment_slices, size_t* pinfo_slices, + bool commit, mi_segments_tld_t* tld) { mi_memid_t memid; @@ -813,14 +858,12 @@ static mi_segment_t* mi_segment_os_alloc( size_t required, size_t page_alignment align_offset = _mi_align_up( info_size, MI_SEGMENT_ALIGN ); const size_t extra = align_offset - info_size; // recalculate due to potential guard pages - *psegment_slices = mi_segment_calculate_slices(required + extra, ppre_size, pinfo_slices); - - // mi_page_t.slice_count type is uint32_t - if (*psegment_slices > (size_t)UINT32_MAX) return NULL; + *psegment_slices = mi_segment_calculate_slices(required + extra, pinfo_slices); + mi_assert_internal(*psegment_slices > 0 && *psegment_slices <= UINT32_MAX); } const size_t segment_size = (*psegment_slices) * MI_SEGMENT_SLICE_SIZE; - mi_segment_t* segment = (mi_segment_t*)_mi_arena_alloc_aligned(segment_size, alignment, align_offset, commit, allow_large, req_arena_id, &memid, os_tld); + mi_segment_t* segment = (mi_segment_t*)_mi_arena_alloc_aligned(segment_size, alignment, align_offset, commit, allow_large, req_arena_id, &memid); if (segment == NULL) { return NULL; // failed to allocate } @@ -830,14 +873,19 @@ static mi_segment_t* mi_segment_os_alloc( size_t required, size_t page_alignment if (memid.initially_committed) { mi_commit_mask_create_full(&commit_mask); } + else if (required > 0) { + // huge segments must be fully committed + _mi_arena_free(segment, segment_size, 0, memid); + return NULL; + } else { // at least commit the info slices const size_t commit_needed = _mi_divide_up((*pinfo_slices)*MI_SEGMENT_SLICE_SIZE, MI_COMMIT_SIZE); mi_assert_internal(commit_needed>0); mi_commit_mask_create(0, commit_needed, &commit_mask); mi_assert_internal(commit_needed*MI_COMMIT_SIZE >= (*pinfo_slices)*MI_SEGMENT_SLICE_SIZE); - if (!_mi_os_commit(segment, commit_needed*MI_COMMIT_SIZE, NULL, tld->stats)) { - _mi_arena_free(segment,segment_size,0,memid,tld->stats); + if (!_mi_os_commit(segment, commit_needed*MI_COMMIT_SIZE, NULL)) { + _mi_arena_free(segment,segment_size,0,memid); return NULL; } } @@ -847,10 +895,11 @@ static mi_segment_t* mi_segment_os_alloc( size_t required, size_t page_alignment segment->allow_decommit = !memid.is_pinned; segment->allow_purge = segment->allow_decommit && (mi_option_get(mi_option_purge_delay) >= 0); segment->segment_size = segment_size; + segment->subproc = tld->subproc; segment->commit_mask = commit_mask; segment->purge_expire = 0; + segment->free_is_zero = memid.initially_zero; mi_commit_mask_create_empty(&segment->purge_mask); - mi_atomic_store_ptr_release(mi_segment_t, &segment->abandoned_next, NULL); // tsan mi_segments_track_size((long)(segment_size), tld); _mi_segment_map_allocated_at(segment); @@ -859,40 +908,37 @@ static mi_segment_t* mi_segment_os_alloc( size_t required, size_t page_alignment // Allocate a segment from the OS aligned to `MI_SEGMENT_SIZE` . -static mi_segment_t* mi_segment_alloc(size_t required, size_t page_alignment, mi_arena_id_t req_arena_id, mi_segments_tld_t* tld, mi_os_tld_t* os_tld, mi_page_t** huge_page) +static mi_segment_t* mi_segment_alloc(size_t required, size_t page_alignment, mi_arena_id_t req_arena_id, mi_segments_tld_t* tld, mi_page_t** huge_page) { mi_assert_internal((required==0 && huge_page==NULL) || (required>0 && huge_page != NULL)); // calculate needed sizes first size_t info_slices; - size_t pre_size; - size_t segment_slices = mi_segment_calculate_slices(required, &pre_size, &info_slices); - - // mi_page_t.slice_count type is uint32_t - if (segment_slices > (size_t)UINT32_MAX) return NULL; + size_t segment_slices = mi_segment_calculate_slices(required, &info_slices); + mi_assert_internal(segment_slices > 0 && segment_slices <= UINT32_MAX); // Commit eagerly only if not the first N lazy segments (to reduce impact of many threads that allocate just a little) const bool eager_delay = (// !_mi_os_has_overcommit() && // never delay on overcommit systems _mi_current_thread_count() > 1 && // do not delay for the first N threads - tld->count < (size_t)mi_option_get(mi_option_eager_commit_delay)); + tld->peak_count < (size_t)mi_option_get(mi_option_eager_commit_delay)); const bool eager = !eager_delay && mi_option_is_enabled(mi_option_eager_commit); bool commit = eager || (required > 0); // Allocate the segment from the OS mi_segment_t* segment = mi_segment_os_alloc(required, page_alignment, eager_delay, req_arena_id, - &segment_slices, &pre_size, &info_slices, commit, tld, os_tld); + &segment_slices, &info_slices, commit, tld); if (segment == NULL) return NULL; // zero the segment info? -- not always needed as it may be zero initialized from the OS + const size_t slice_entries = (segment_slices > MI_SLICES_PER_SEGMENT ? MI_SLICES_PER_SEGMENT : segment_slices); if (!segment->memid.initially_zero) { ptrdiff_t ofs = offsetof(mi_segment_t, next); size_t prefix = offsetof(mi_segment_t, slices) - ofs; - size_t zsize = prefix + (sizeof(mi_slice_t) * (segment_slices + 1)); // one more + size_t zsize = prefix + (sizeof(mi_slice_t) * (slice_entries + 1)); // one more _mi_memzero((uint8_t*)segment + ofs, zsize); } // initialize the rest of the segment info - const size_t slice_entries = (segment_slices > MI_SLICES_PER_SEGMENT ? MI_SLICES_PER_SEGMENT : segment_slices); segment->segment_slices = segment_slices; segment->segment_info_slices = info_slices; segment->thread_id = _mi_thread_id(); @@ -909,17 +955,16 @@ static mi_segment_t* mi_segment_alloc(size_t required, size_t page_alignment, mi // in secure mode, we set up a protected page in between the segment info // and the page data, and at the end of the segment. size_t os_pagesize = _mi_os_page_size(); - mi_assert_internal(mi_segment_info_size(segment) - os_pagesize >= pre_size); _mi_os_protect((uint8_t*)segment + mi_segment_info_size(segment) - os_pagesize, os_pagesize); uint8_t* end = (uint8_t*)segment + mi_segment_size(segment) - os_pagesize; - mi_segment_ensure_committed(segment, end, os_pagesize, tld->stats); + mi_segment_ensure_committed(segment, end, os_pagesize); _mi_os_protect(end, os_pagesize); if (slice_entries == segment_slices) segment->slice_entries--; // don't use the last slice :-( guard_slices = 1; } // reserve first slices for segment info - mi_page_t* page0 = mi_segment_span_allocate(segment, 0, info_slices, tld); + mi_page_t* page0 = mi_segment_span_allocate(segment, 0, info_slices); mi_assert_internal(page0!=NULL); if (page0==NULL) return NULL; // cannot fail as we always commit in advance mi_assert_internal(segment->used == 1); segment->used = 0; // don't count our internal slices towards usage @@ -933,7 +978,7 @@ static mi_segment_t* mi_segment_alloc(size_t required, size_t page_alignment, mi mi_assert_internal(huge_page!=NULL); mi_assert_internal(mi_commit_mask_is_empty(&segment->purge_mask)); mi_assert_internal(mi_commit_mask_is_full(&segment->commit_mask)); - *huge_page = mi_segment_span_allocate(segment, info_slices, segment_slices - info_slices - guard_slices, tld); + *huge_page = mi_segment_span_allocate(segment, info_slices, segment_slices - info_slices - guard_slices); mi_assert_internal(*huge_page != NULL); // cannot fail as we commit in advance } @@ -948,6 +993,9 @@ static void mi_segment_free(mi_segment_t* segment, bool force, mi_segments_tld_t mi_assert_internal(segment->next == NULL); mi_assert_internal(segment->used == 0); + // in `mi_segment_force_abandon` we set this to true to ensure the segment's memory stays valid + if (segment->dont_free) return; + // Remove the free pages mi_slice_t* slice = &segment->slices[0]; const mi_slice_t* end = mi_segment_slices_end(segment); @@ -957,8 +1005,8 @@ static void mi_segment_free(mi_segment_t* segment, bool force, mi_segments_tld_t while (slice < end) { mi_assert_internal(slice->slice_count > 0); mi_assert_internal(slice->slice_offset == 0); - mi_assert_internal(mi_slice_index(slice)==0 || slice->xblock_size == 0); // no more used pages .. - if (slice->xblock_size == 0 && segment->kind != MI_SEGMENT_HUGE) { + mi_assert_internal(mi_slice_index(slice)==0 || slice->block_size == 0); // no more used pages .. + if (slice->block_size == 0 && segment->kind != MI_SEGMENT_HUGE) { mi_segment_span_remove_from_queue(slice, tld); } #if MI_DEBUG>1 @@ -969,7 +1017,7 @@ static void mi_segment_free(mi_segment_t* segment, bool force, mi_segments_tld_t mi_assert_internal(page_count == 2); // first page is allocated by the segment itself // stats - _mi_stat_decrease(&tld->stats->page_committed, mi_segment_info_size(segment)); + // _mi_stat_decrease(&tld->stats->page_committed, mi_segment_info_size(segment)); // return it to the OS mi_segment_os_free(segment, tld); @@ -984,35 +1032,36 @@ static void mi_segment_abandon(mi_segment_t* segment, mi_segments_tld_t* tld); // note: can be called on abandoned pages static mi_slice_t* mi_segment_page_clear(mi_page_t* page, mi_segments_tld_t* tld) { - mi_assert_internal(page->xblock_size > 0); + mi_assert_internal(page->block_size > 0); mi_assert_internal(mi_page_all_free(page)); mi_segment_t* segment = _mi_ptr_segment(page); mi_assert_internal(segment->used > 0); -#ifdef Py_GIL_DISABLED - mi_assert_internal(page->qsbr_goal == 0); - mi_assert_internal(page->qsbr_node.next == NULL); -#endif size_t inuse = page->capacity * mi_page_block_size(page); _mi_stat_decrease(&tld->stats->page_committed, inuse); _mi_stat_decrease(&tld->stats->pages, 1); + _mi_stat_decrease(&tld->stats->page_bins[_mi_page_stats_bin(page)], 1); // reset the page memory to reduce memory pressure? if (segment->allow_decommit && mi_option_is_enabled(mi_option_deprecated_page_reset)) { size_t psize; - uint8_t* start = _mi_page_start(segment, page, &psize); - _mi_os_reset(start, psize, tld->stats); + uint8_t* start = _mi_segment_page_start(segment, page, &psize); + _mi_os_reset(start, psize); } - // zero the page data, but not the segment fields + // zero the page data, but not the segment fields and heap tag page->is_zero_init = false; + uint8_t heap_tag = page->heap_tag; ptrdiff_t ofs = offsetof(mi_page_t, capacity); _mi_memzero((uint8_t*)page + ofs, sizeof(*page) - ofs); - page->xblock_size = 1; + page->block_size = 1; + page->heap_tag = heap_tag; // and free it mi_slice_t* slice = mi_segment_span_free_coalesce(mi_page_to_slice(page), tld); segment->used--; + segment->free_is_zero = false; + // cannot assert segment valid as it is called during reclaim // mi_assert_expensive(mi_segment_is_valid(segment, tld)); return slice; @@ -1021,7 +1070,6 @@ static mi_slice_t* mi_segment_page_clear(mi_page_t* page, mi_segments_tld_t* tld void _mi_segment_page_free(mi_page_t* page, bool force, mi_segments_tld_t* tld) { mi_assert(page != NULL); - mi_segment_t* segment = _mi_page_segment(page); mi_assert_expensive(mi_segment_is_valid(segment,tld)); @@ -1037,6 +1085,10 @@ void _mi_segment_page_free(mi_page_t* page, bool force, mi_segments_tld_t* tld) // only abandoned pages; remove from free list and abandon mi_segment_abandon(segment,tld); } + else { + // perform delayed purges + mi_segment_try_purge(segment, false /* force? */); + } } @@ -1046,157 +1098,17 @@ Abandonment When threads terminate, they can leave segments with live blocks (reachable through other threads). Such segments are "abandoned" and will be reclaimed by other threads to -reuse their pages and/or free them eventually - -We maintain a global list of abandoned segments that are -reclaimed on demand. Since this is shared among threads -the implementation needs to avoid the A-B-A problem on -popping abandoned segments: -We use tagged pointers to avoid accidentally identifying -reused segments, much like stamped references in Java. -Secondly, we maintain a reader counter to avoid resetting -or decommitting segments that have a pending read operation. - -Note: the current implementation is one possible design; -another way might be to keep track of abandoned segments -in the arenas/segment_cache's. This would have the advantage of keeping -all concurrent code in one place and not needing to deal -with ABA issues. The drawback is that it is unclear how to -scan abandoned segments efficiently in that case as they -would be spread among all other segments in the arenas. ------------------------------------------------------------ */ - -// Use the bottom 20-bits (on 64-bit) of the aligned segment pointers -// to put in a tag that increments on update to avoid the A-B-A problem. -#define MI_TAGGED_MASK MI_SEGMENT_MASK - -static mi_segment_t* mi_tagged_segment_ptr(mi_tagged_segment_t ts) { - return (mi_segment_t*)(ts & ~MI_TAGGED_MASK); -} - -static mi_tagged_segment_t mi_tagged_segment(mi_segment_t* segment, mi_tagged_segment_t ts) { - mi_assert_internal(((uintptr_t)segment & MI_TAGGED_MASK) == 0); - uintptr_t tag = ((ts & MI_TAGGED_MASK) + 1) & MI_TAGGED_MASK; - return ((uintptr_t)segment | tag); -} - -mi_abandoned_pool_t _mi_abandoned_default; +reuse their pages and/or free them eventually. The +`thread_id` of such segments is 0. -// Push on the visited list -static void mi_abandoned_visited_push(mi_abandoned_pool_t *pool, mi_segment_t* segment) { - mi_assert_internal(segment->thread_id == 0); - mi_assert_internal(mi_atomic_load_ptr_relaxed(mi_segment_t,&segment->abandoned_next) == NULL); - mi_assert_internal(segment->next == NULL); - mi_assert_internal(segment->used > 0); - mi_segment_t* anext = mi_atomic_load_ptr_relaxed(mi_segment_t, &pool->abandoned_visited); - do { - mi_atomic_store_ptr_release(mi_segment_t, &segment->abandoned_next, anext); - } while (!mi_atomic_cas_ptr_weak_release(mi_segment_t, &pool->abandoned_visited, &anext, segment)); - mi_atomic_increment_relaxed(&pool->abandoned_visited_count); -} - -// Move the visited list to the abandoned list. -static bool mi_abandoned_visited_revisit(mi_abandoned_pool_t *pool) -{ - // quick check if the visited list is empty - if (mi_atomic_load_ptr_relaxed(mi_segment_t, &pool->abandoned_visited) == NULL) return false; - - // grab the whole visited list - mi_segment_t* first = mi_atomic_exchange_ptr_acq_rel(mi_segment_t, &pool->abandoned_visited, NULL); - if (first == NULL) return false; - - // first try to swap directly if the abandoned list happens to be NULL - mi_tagged_segment_t afirst; - mi_tagged_segment_t ts = mi_atomic_load_relaxed(&pool->abandoned); - if (mi_tagged_segment_ptr(ts)==NULL) { - size_t count = mi_atomic_load_relaxed(&pool->abandoned_visited_count); - afirst = mi_tagged_segment(first, ts); - if (mi_atomic_cas_strong_acq_rel(&pool->abandoned, &ts, afirst)) { - mi_atomic_add_relaxed(&pool->abandoned_count, count); - mi_atomic_sub_relaxed(&pool->abandoned_visited_count, count); - return true; - } - } - - // find the last element of the visited list: O(n) - mi_segment_t* last = first; - mi_segment_t* next; - while ((next = mi_atomic_load_ptr_relaxed(mi_segment_t, &last->abandoned_next)) != NULL) { - last = next; - } - - // and atomically prepend to the abandoned list - // (no need to increase the readers as we don't access the abandoned segments) - mi_tagged_segment_t anext = mi_atomic_load_relaxed(&pool->abandoned); - size_t count; - do { - count = mi_atomic_load_relaxed(&pool->abandoned_visited_count); - mi_atomic_store_ptr_release(mi_segment_t, &last->abandoned_next, mi_tagged_segment_ptr(anext)); - afirst = mi_tagged_segment(first, anext); - } while (!mi_atomic_cas_weak_release(&pool->abandoned, &anext, afirst)); - mi_atomic_add_relaxed(&pool->abandoned_count, count); - mi_atomic_sub_relaxed(&pool->abandoned_visited_count, count); - return true; -} - -// Push on the abandoned list. -static void mi_abandoned_push(mi_abandoned_pool_t* pool, mi_segment_t* segment) { - mi_assert_internal(segment->thread_id == 0); - mi_assert_internal(mi_atomic_load_ptr_relaxed(mi_segment_t, &segment->abandoned_next) == NULL); - mi_assert_internal(segment->next == NULL); - mi_assert_internal(segment->used > 0); - mi_tagged_segment_t next; - mi_tagged_segment_t ts = mi_atomic_load_relaxed(&pool->abandoned); - do { - mi_atomic_store_ptr_release(mi_segment_t, &segment->abandoned_next, mi_tagged_segment_ptr(ts)); - next = mi_tagged_segment(segment, ts); - } while (!mi_atomic_cas_weak_release(&pool->abandoned, &ts, next)); - mi_atomic_increment_relaxed(&pool->abandoned_count); -} - -// Wait until there are no more pending reads on segments that used to be in the abandoned list -// called for example from `arena.c` before decommitting -void _mi_abandoned_await_readers(mi_abandoned_pool_t* pool) { - size_t n; - do { - n = mi_atomic_load_acquire(&pool->abandoned_readers); - if (n != 0) mi_atomic_yield(); - } while (n != 0); -} - -// Pop from the abandoned list -static mi_segment_t* mi_abandoned_pop(mi_abandoned_pool_t* pool) { - mi_segment_t* segment; - // Check efficiently if it is empty (or if the visited list needs to be moved) - mi_tagged_segment_t ts = mi_atomic_load_relaxed(&pool->abandoned); - segment = mi_tagged_segment_ptr(ts); - if mi_likely(segment == NULL) { - if mi_likely(!mi_abandoned_visited_revisit(pool)) { // try to swap in the visited list on NULL - return NULL; - } - } +When a block is freed in an abandoned segment, the segment +is reclaimed into that thread. - // Do a pop. We use a reader count to prevent - // a segment to be decommitted while a read is still pending, - // and a tagged pointer to prevent A-B-A link corruption. - // (this is called from `region.c:_mi_mem_free` for example) - mi_atomic_increment_relaxed(&pool->abandoned_readers); // ensure no segment gets decommitted - mi_tagged_segment_t next = 0; - ts = mi_atomic_load_acquire(&pool->abandoned); - do { - segment = mi_tagged_segment_ptr(ts); - if (segment != NULL) { - mi_segment_t* anext = mi_atomic_load_ptr_relaxed(mi_segment_t, &segment->abandoned_next); - next = mi_tagged_segment(anext, ts); // note: reads the segment's `abandoned_next` field so should not be decommitted - } - } while (segment != NULL && !mi_atomic_cas_weak_acq_rel(&pool->abandoned, &ts, next)); - mi_atomic_decrement_relaxed(&pool->abandoned_readers); // release reader lock - if (segment != NULL) { - mi_atomic_store_ptr_release(mi_segment_t, &segment->abandoned_next, NULL); - mi_atomic_decrement_relaxed(&pool->abandoned_count); - } - return segment; -} +Moreover, if threads are looking for a fresh segment, they +will first consider abandoned segments -- these can be found +by scanning the arena memory +(segments outside arena memoryare only reclaimed by a free). +----------------------------------------------------------- */ /* ----------------------------------------------------------- Abandon segment/page @@ -1205,7 +1117,6 @@ static mi_segment_t* mi_abandoned_pop(mi_abandoned_pool_t* pool) { static void mi_segment_abandon(mi_segment_t* segment, mi_segments_tld_t* tld) { mi_assert_internal(segment->used == segment->abandoned); mi_assert_internal(segment->used > 0); - mi_assert_internal(mi_atomic_load_ptr_relaxed(mi_segment_t, &segment->abandoned_next) == NULL); mi_assert_internal(segment->abandoned_visits == 0); mi_assert_expensive(mi_segment_is_valid(segment,tld)); @@ -1215,23 +1126,29 @@ static void mi_segment_abandon(mi_segment_t* segment, mi_segments_tld_t* tld) { while (slice < end) { mi_assert_internal(slice->slice_count > 0); mi_assert_internal(slice->slice_offset == 0); - if (slice->xblock_size == 0) { // a free page + if (slice->block_size == 0) { // a free page mi_segment_span_remove_from_queue(slice,tld); - slice->xblock_size = 0; // but keep it free + slice->block_size = 0; // but keep it free } slice = slice + slice->slice_count; } // perform delayed decommits (forcing is much slower on mstress) - mi_segment_try_purge(segment, mi_option_is_enabled(mi_option_abandoned_page_purge) /* force? */, tld->stats); + // Only abandoned segments in arena memory can be reclaimed without a free + // so if a segment is not from an arena we force purge here to be conservative. + const bool force_purge = (segment->memid.memkind != MI_MEM_ARENA) || mi_option_is_enabled(mi_option_abandoned_page_purge); + mi_segment_try_purge(segment, force_purge); // all pages in the segment are abandoned; add it to the abandoned list _mi_stat_increase(&tld->stats->segments_abandoned, 1); mi_segments_track_size(-((long)mi_segment_size(segment)), tld); segment->thread_id = 0; - mi_atomic_store_ptr_release(mi_segment_t, &segment->abandoned_next, NULL); segment->abandoned_visits = 1; // from 0 to 1 to signify it is abandoned - mi_abandoned_push(tld->abandoned, segment); + if (segment->was_reclaimed) { + tld->reclaim_count--; + segment->was_reclaimed = false; + } + _mi_arena_segment_mark_abandoned(segment); } void _mi_segment_page_abandon(mi_page_t* page, mi_segments_tld_t* tld) { @@ -1258,7 +1175,7 @@ void _mi_segment_page_abandon(mi_page_t* page, mi_segments_tld_t* tld) { static mi_slice_t* mi_slices_start_iterate(mi_segment_t* segment, const mi_slice_t** end) { mi_slice_t* slice = &segment->slices[0]; *end = mi_segment_slices_end(segment); - mi_assert_internal(slice->slice_count>0 && slice->xblock_size>0); // segment allocated page + mi_assert_internal(slice->slice_count>0 && slice->block_size>0); // segment allocated page slice = slice + slice->slice_count; // skip the first segment allocated page return slice; } @@ -1266,7 +1183,6 @@ static mi_slice_t* mi_slices_start_iterate(mi_segment_t* segment, const mi_slice // Possibly free pages and check if free space is available static bool mi_segment_check_free(mi_segment_t* segment, size_t slices_needed, size_t block_size, mi_segments_tld_t* tld) { - mi_assert_internal(block_size < MI_HUGE_BLOCK_SIZE); mi_assert_internal(mi_segment_is_abandoned(segment)); bool has_page = false; @@ -1295,11 +1211,9 @@ static bool mi_segment_check_free(mi_segment_t* segment, size_t slices_needed, s has_page = true; } } - else { - if (page->xblock_size == block_size && mi_page_has_any_available(page)) { - // a page has available free blocks of the right size - has_page = true; - } + else if (mi_page_block_size(page) == block_size && mi_page_has_any_available(page)) { + // a page has available free blocks of the right size + has_page = true; } } else { @@ -1313,27 +1227,17 @@ static bool mi_segment_check_free(mi_segment_t* segment, size_t slices_needed, s return has_page; } -static mi_heap_t* mi_heap_by_tag(mi_heap_t* heap, uint8_t tag) { - if (heap->tag == tag) { - return heap; - } - for (mi_heap_t *curr = heap->tld->heaps; curr != NULL; curr = curr->next) { - if (curr->tag == tag) { - return curr; - } - } - return NULL; -} - // Reclaim an abandoned segment; returns NULL if the segment was freed // set `right_page_reclaimed` to `true` if it reclaimed a page of the right `block_size` that was not full. static mi_segment_t* mi_segment_reclaim(mi_segment_t* segment, mi_heap_t* heap, size_t requested_block_size, bool* right_page_reclaimed, mi_segments_tld_t* tld) { - mi_assert_internal(mi_atomic_load_ptr_relaxed(mi_segment_t, &segment->abandoned_next) == NULL); - mi_assert_expensive(mi_segment_is_valid(segment, tld)); if (right_page_reclaimed != NULL) { *right_page_reclaimed = false; } - - segment->thread_id = _mi_thread_id(); + // can be 0 still with abandoned_next, or already a thread id for segments outside an arena that are reclaimed on a free. + mi_assert_internal(mi_atomic_load_relaxed(&segment->thread_id) == 0 || mi_atomic_load_relaxed(&segment->thread_id) == _mi_thread_id()); + mi_assert_internal(segment->subproc == heap->tld->segments.subproc); // only reclaim within the same subprocess + mi_atomic_store_release(&segment->thread_id, _mi_thread_id()); segment->abandoned_visits = 0; + segment->was_reclaimed = true; + tld->reclaim_count++; mi_segments_track_size((long)mi_segment_size(segment), tld); mi_assert_internal(segment->next == NULL); _mi_stat_decrease(&tld->stats->segments_abandoned, 1); @@ -1347,14 +1251,19 @@ static mi_segment_t* mi_segment_reclaim(mi_segment_t* segment, mi_heap_t* heap, if (mi_slice_is_used(slice)) { // in use: reclaim the page in our heap mi_page_t* page = mi_slice_to_page(slice); - mi_heap_t* target_heap = mi_heap_by_tag(heap, page->tag); mi_assert_internal(page->is_committed); mi_assert_internal(mi_page_thread_free_flag(page)==MI_NEVER_DELAYED_FREE); mi_assert_internal(mi_page_heap(page) == NULL); mi_assert_internal(page->next == NULL && page->prev==NULL); _mi_stat_decrease(&tld->stats->pages_abandoned, 1); segment->abandoned--; - // set the heap again and allow delayed free again + // get the target heap for this thread which has a matching heap tag (so we reclaim into a matching heap) + mi_heap_t* target_heap = _mi_heap_by_tag(heap, page->heap_tag); // allow custom heaps to separate objects + if (target_heap == NULL) { + target_heap = heap; + _mi_error_message(EFAULT, "page with tag %u cannot be reclaimed by a heap with the same tag (using heap tag %u instead)\n", page->heap_tag, heap->tag ); + } + // associate the heap with this page, and allow heap thread delayed free again. mi_page_set_heap(page, target_heap); _mi_page_use_delayed_free(page, MI_USE_DELAYED_FREE, true); // override never (after heap is set) _mi_page_free_collect(page, false); // ensure used count is up to date @@ -1369,8 +1278,8 @@ static mi_segment_t* mi_segment_reclaim(mi_segment_t* segment, mi_heap_t* heap, else { // otherwise reclaim it into the heap _mi_page_reclaim(target_heap, page); - if (requested_block_size == page->xblock_size && mi_page_has_any_available(page) && - requested_block_size <= MI_MEDIUM_OBJ_SIZE_MAX && heap == target_heap) { + if (requested_block_size == mi_page_block_size(page) && mi_page_has_any_available(page) && + requested_block_size <= MI_MEDIUM_OBJ_SIZE_MAX && heap == target_heap) { // CPython: gh-115103 if (right_page_reclaimed != NULL) { *right_page_reclaimed = true; } } } @@ -1384,6 +1293,7 @@ static mi_segment_t* mi_segment_reclaim(mi_segment_t* segment, mi_heap_t* heap, } mi_assert(segment->abandoned == 0); + mi_assert_expensive(mi_segment_is_valid(segment, tld)); if (segment->used == 0) { // due to page_clear mi_assert_internal(right_page_reclaimed == NULL || !(*right_page_reclaimed)); mi_segment_free(segment, false, tld); @@ -1395,22 +1305,74 @@ static mi_segment_t* mi_segment_reclaim(mi_segment_t* segment, mi_heap_t* heap, } +// attempt to reclaim a particular segment (called from multi threaded free `alloc.c:mi_free_block_mt`) +bool _mi_segment_attempt_reclaim(mi_heap_t* heap, mi_segment_t* segment) { + if (mi_atomic_load_relaxed(&segment->thread_id) != 0) return false; // it is not abandoned + if (segment->subproc != heap->tld->segments.subproc) return false; // only reclaim within the same subprocess + if (!_mi_heap_memid_is_suitable(heap,segment->memid)) return false; // don't reclaim between exclusive and non-exclusive arena's + const long target = _mi_option_get_fast(mi_option_target_segments_per_thread); + if (target > 0 && (size_t)target <= heap->tld->segments.count) return false; // don't reclaim if going above the target count + + // don't reclaim more from a `free` call than half the current segments + // this is to prevent a pure free-ing thread to start owning too many segments + // (but not for out-of-arena segments as that is the main way to be reclaimed for those) + if (segment->memid.memkind == MI_MEM_ARENA && heap->tld->segments.reclaim_count * 2 > heap->tld->segments.count) { + return false; + } + if (_mi_arena_segment_clear_abandoned(segment)) { // atomically unabandon + mi_segment_t* res = mi_segment_reclaim(segment, heap, 0, NULL, &heap->tld->segments); + mi_assert_internal(res == segment); + return (res != NULL); + } + return false; +} + void _mi_abandoned_reclaim_all(mi_heap_t* heap, mi_segments_tld_t* tld) { mi_segment_t* segment; - while ((segment = mi_abandoned_pop(tld->abandoned)) != NULL) { + mi_arena_field_cursor_t current; + _mi_arena_field_cursor_init(heap, tld->subproc, true /* visit all, blocking */, ¤t); + while ((segment = _mi_arena_segment_clear_abandoned_next(¤t)) != NULL) { mi_segment_reclaim(segment, heap, 0, NULL, tld); } + _mi_arena_field_cursor_done(¤t); +} + + +static bool segment_count_is_within_target(mi_segments_tld_t* tld, size_t* ptarget) { + const size_t target = (size_t)mi_option_get_clamp(mi_option_target_segments_per_thread, 0, 1024); + if (ptarget != NULL) { *ptarget = target; } + return (target == 0 || tld->count < target); +} + +static long mi_segment_get_reclaim_tries(mi_segments_tld_t* tld) { + // limit the tries to 10% (default) of the abandoned segments with at least 8 and at most 1024 tries. + const size_t perc = (size_t)mi_option_get_clamp(mi_option_max_segment_reclaim, 0, 100); + if (perc <= 0) return 0; + const size_t total_count = mi_atomic_load_relaxed(&tld->subproc->abandoned_count); + if (total_count == 0) return 0; + const size_t relative_count = (total_count > 10000 ? (total_count / 100) * perc : (total_count * perc) / 100); // avoid overflow + long max_tries = (long)(relative_count <= 1 ? 1 : (relative_count > 1024 ? 1024 : relative_count)); + if (max_tries < 8 && total_count > 8) { max_tries = 8; } + return max_tries; } static mi_segment_t* mi_segment_try_reclaim(mi_heap_t* heap, size_t needed_slices, size_t block_size, bool* reclaimed, mi_segments_tld_t* tld) { *reclaimed = false; - mi_segment_t* segment; - long max_tries = mi_option_get_clamp(mi_option_max_segment_reclaim, 8, 1024); // limit the work to bound allocation times - while ((max_tries-- > 0) && ((segment = mi_abandoned_pop(tld->abandoned)) != NULL)) { + long max_tries = mi_segment_get_reclaim_tries(tld); + if (max_tries <= 0) return NULL; + + mi_segment_t* result = NULL; + mi_segment_t* segment = NULL; + mi_arena_field_cursor_t current; + _mi_arena_field_cursor_init(heap, tld->subproc, false /* non-blocking */, ¤t); + while (segment_count_is_within_target(tld,NULL) && (max_tries-- > 0) && ((segment = _mi_arena_segment_clear_abandoned_next(¤t)) != NULL)) + { + mi_assert(segment->subproc == heap->tld->segments.subproc); // cursor only visits segments in our sub-process segment->abandoned_visits++; - // todo: an arena exclusive heap will potentially visit many abandoned unsuitable segments - // and push them into the visited list and use many tries. Perhaps we can skip non-suitable ones in a better way? + // todo: should we respect numa affinity for abandoned reclaim? perhaps only for the first visit? + // todo: an arena exclusive heap will potentially visit many abandoned unsuitable segments and use many tries + // Perhaps we can skip non-suitable ones in a better way? bool is_suitable = _mi_heap_memid_is_suitable(heap, segment->memid); bool has_page = mi_segment_check_free(segment,needed_slices,block_size,tld); // try to free up pages (due to concurrent frees) if (segment->used == 0) { @@ -1425,31 +1387,31 @@ static mi_segment_t* mi_segment_try_reclaim(mi_heap_t* heap, size_t needed_slice // found a large enough free span, or a page of the right block_size with free space // we return the result of reclaim (which is usually `segment`) as it might free // the segment due to concurrent frees (in which case `NULL` is returned). - return mi_segment_reclaim(segment, heap, block_size, reclaimed, tld); + result = mi_segment_reclaim(segment, heap, block_size, reclaimed, tld); + break; } else if (segment->abandoned_visits > 3 && is_suitable) { - // always reclaim on 3rd visit to limit the abandoned queue length. + // always reclaim on 3rd visit to limit the abandoned segment count. mi_segment_reclaim(segment, heap, 0, NULL, tld); } else { // otherwise, push on the visited list so it gets not looked at too quickly again - mi_segment_try_purge(segment, true /* force? */, tld->stats); // force purge if needed as we may not visit soon again - mi_abandoned_visited_push(tld->abandoned, segment); + max_tries++; // don't count this as a try since it was not suitable + mi_segment_try_purge(segment, false /* true force? */); // force purge if needed as we may not visit soon again + _mi_arena_segment_mark_abandoned(segment); } } - return NULL; + _mi_arena_field_cursor_done(¤t); + return result; } - +// collect abandoned segments void _mi_abandoned_collect(mi_heap_t* heap, bool force, mi_segments_tld_t* tld) { mi_segment_t* segment; - mi_abandoned_pool_t* pool = tld->abandoned; - int max_tries = (force ? 16*1024 : 1024); // limit latency - if (force) { - mi_abandoned_visited_revisit(pool); - } - while ((max_tries-- > 0) && ((segment = mi_abandoned_pop(pool)) != NULL)) { + mi_arena_field_cursor_t current; _mi_arena_field_cursor_init(heap, tld->subproc, force /* blocking? */, ¤t); + long max_tries = (force ? (long)mi_atomic_load_relaxed(&tld->subproc->abandoned_count) : 1024); // limit latency + while ((max_tries-- > 0) && ((segment = _mi_arena_segment_clear_abandoned_next(¤t)) != NULL)) { mi_segment_check_free(segment,0,0,tld); // try to free up pages (due to concurrent frees) if (segment->used == 0) { // free the segment (by forced reclaim) to make it available to other threads. @@ -1460,21 +1422,121 @@ void _mi_abandoned_collect(mi_heap_t* heap, bool force, mi_segments_tld_t* tld) else { // otherwise, purge if needed and push on the visited list // note: forced purge can be expensive if many threads are destroyed/created as in mstress. - mi_segment_try_purge(segment, force, tld->stats); - mi_abandoned_visited_push(pool, segment); + mi_segment_try_purge(segment, force); + _mi_arena_segment_mark_abandoned(segment); + } + } + _mi_arena_field_cursor_done(¤t); +} + +/* ----------------------------------------------------------- + Force abandon a segment that is in use by our thread +----------------------------------------------------------- */ + +// force abandon a segment +static void mi_segment_force_abandon(mi_segment_t* segment, mi_segments_tld_t* tld) +{ + mi_assert_internal(!mi_segment_is_abandoned(segment)); + mi_assert_internal(!segment->dont_free); + + // ensure the segment does not get free'd underneath us (so we can check if a page has been freed in `mi_page_force_abandon`) + segment->dont_free = true; + + // for all slices + const mi_slice_t* end; + mi_slice_t* slice = mi_slices_start_iterate(segment, &end); + while (slice < end) { + mi_assert_internal(slice->slice_count > 0); + mi_assert_internal(slice->slice_offset == 0); + if (mi_slice_is_used(slice)) { + // ensure used count is up to date and collect potential concurrent frees + mi_page_t* const page = mi_slice_to_page(slice); + _mi_page_free_collect(page, false); + { + // abandon the page if it is still in-use (this will free it if possible as well) + mi_assert_internal(segment->used > 0); + if (segment->used == segment->abandoned+1) { + // the last page.. abandon and return as the segment will be abandoned after this + // and we should no longer access it. + segment->dont_free = false; + _mi_page_force_abandon(page); + return; + } + else { + // abandon and continue + _mi_page_force_abandon(page); + // it might be freed, reset the slice (note: relies on coalesce setting the slice_offset) + slice = mi_slice_first(slice); + } + } + } + slice = slice + slice->slice_count; + } + segment->dont_free = false; + mi_assert(segment->used == segment->abandoned); + mi_assert(segment->used == 0); + if (segment->used == 0) { // paranoia + // all free now + mi_segment_free(segment, false, tld); + } + else { + // perform delayed purges + mi_segment_try_purge(segment, false /* force? */); + } +} + + +// try abandon segments. +// this should be called from `reclaim_or_alloc` so we know all segments are (about) fully in use. +static void mi_segments_try_abandon_to_target(mi_heap_t* heap, size_t target, mi_segments_tld_t* tld) { + if (target <= 1) return; + const size_t min_target = (target > 4 ? (target*3)/4 : target); // 75% + // todo: we should maintain a list of segments per thread; for now, only consider segments from the heap full pages + for (int i = 0; i < 64 && tld->count >= min_target; i++) { + mi_page_t* page = heap->pages[MI_BIN_FULL].first; + while (page != NULL && mi_page_block_size(page) > MI_LARGE_OBJ_SIZE_MAX) { + page = page->next; } + if (page==NULL) { + break; + } + mi_segment_t* segment = _mi_page_segment(page); + mi_segment_force_abandon(segment, tld); + mi_assert_internal(page != heap->pages[MI_BIN_FULL].first); // as it is just abandoned } } +// try abandon segments. +// this should be called from `reclaim_or_alloc` so we know all segments are (about) fully in use. +static void mi_segments_try_abandon(mi_heap_t* heap, mi_segments_tld_t* tld) { + // we call this when we are about to add a fresh segment so we should be under our target segment count. + size_t target = 0; + if (segment_count_is_within_target(tld, &target)) return; + mi_segments_try_abandon_to_target(heap, target, tld); +} + +void mi_collect_reduce(size_t target_size) mi_attr_noexcept { + mi_collect(true); + mi_heap_t* heap = mi_heap_get_default(); + mi_segments_tld_t* tld = &heap->tld->segments; + size_t target = target_size / MI_SEGMENT_SIZE; + if (target == 0) { + target = (size_t)mi_option_get_clamp(mi_option_target_segments_per_thread, 1, 1024); + } + mi_segments_try_abandon_to_target(heap, target, tld); +} + /* ----------------------------------------------------------- Reclaim or allocate ----------------------------------------------------------- */ -static mi_segment_t* mi_segment_reclaim_or_alloc(mi_heap_t* heap, size_t needed_slices, size_t block_size, mi_segments_tld_t* tld, mi_os_tld_t* os_tld) +static mi_segment_t* mi_segment_reclaim_or_alloc(mi_heap_t* heap, size_t needed_slices, size_t block_size, mi_segments_tld_t* tld) { - mi_assert_internal(block_size < MI_HUGE_BLOCK_SIZE); mi_assert_internal(block_size <= MI_LARGE_OBJ_SIZE_MAX); + // try to abandon some segments to increase reuse between threads + mi_segments_try_abandon(heap,tld); + // 1. try to reclaim an abandoned segment bool reclaimed; mi_segment_t* segment = mi_segment_try_reclaim(heap, needed_slices, block_size, &reclaimed, tld); @@ -1488,7 +1550,7 @@ static mi_segment_t* mi_segment_reclaim_or_alloc(mi_heap_t* heap, size_t needed_ return segment; } // 2. otherwise allocate a fresh segment - return mi_segment_alloc(0, 0, heap->arena_id, tld, os_tld, NULL); + return mi_segment_alloc(0, 0, heap->arena_id, tld, NULL); } @@ -1496,7 +1558,7 @@ static mi_segment_t* mi_segment_reclaim_or_alloc(mi_heap_t* heap, size_t needed_ Page allocation ----------------------------------------------------------- */ -static mi_page_t* mi_segments_page_alloc(mi_heap_t* heap, mi_page_kind_t page_kind, size_t required, size_t block_size, mi_segments_tld_t* tld, mi_os_tld_t* os_tld) +static mi_page_t* mi_segments_page_alloc(mi_heap_t* heap, mi_page_kind_t page_kind, size_t required, size_t block_size, mi_segments_tld_t* tld) { mi_assert_internal(required <= MI_LARGE_OBJ_SIZE_MAX && page_kind <= MI_PAGE_LARGE); @@ -1507,18 +1569,18 @@ static mi_page_t* mi_segments_page_alloc(mi_heap_t* heap, mi_page_kind_t page_ki mi_page_t* page = mi_segments_page_find_and_allocate(slices_needed, heap->arena_id, tld); //(required <= MI_SMALL_SIZE_MAX ? 0 : slices_needed), tld); if (page==NULL) { // no free page, allocate a new segment and try again - if (mi_segment_reclaim_or_alloc(heap, slices_needed, block_size, tld, os_tld) == NULL) { + if (mi_segment_reclaim_or_alloc(heap, slices_needed, block_size, tld) == NULL) { // OOM or reclaimed a good page in the heap return NULL; } else { // otherwise try again - return mi_segments_page_alloc(heap, page_kind, required, block_size, tld, os_tld); + return mi_segments_page_alloc(heap, page_kind, required, block_size, tld); } } mi_assert_internal(page != NULL && page->slice_count*MI_SEGMENT_SLICE_SIZE == page_size); mi_assert_internal(_mi_ptr_segment(page)->thread_id == _mi_thread_id()); - mi_segment_try_purge(_mi_ptr_segment(page), false, tld->stats); + mi_segment_try_purge(_mi_ptr_segment(page), false); return page; } @@ -1528,10 +1590,10 @@ static mi_page_t* mi_segments_page_alloc(mi_heap_t* heap, mi_page_kind_t page_ki Huge page allocation ----------------------------------------------------------- */ -static mi_page_t* mi_segment_huge_page_alloc(size_t size, size_t page_alignment, mi_arena_id_t req_arena_id, mi_segments_tld_t* tld, mi_os_tld_t* os_tld) +static mi_page_t* mi_segment_huge_page_alloc(size_t size, size_t page_alignment, mi_arena_id_t req_arena_id, mi_segments_tld_t* tld) { mi_page_t* page = NULL; - mi_segment_t* segment = mi_segment_alloc(size,page_alignment,req_arena_id,tld,os_tld,&page); + mi_segment_t* segment = mi_segment_alloc(size,page_alignment,req_arena_id,tld,&page); if (segment == NULL || page==NULL) return NULL; mi_assert_internal(segment->used==1); mi_assert_internal(mi_page_block_size(page) >= size); @@ -1539,20 +1601,24 @@ static mi_page_t* mi_segment_huge_page_alloc(size_t size, size_t page_alignment, segment->thread_id = 0; // huge segments are immediately abandoned #endif - // for huge pages we initialize the xblock_size as we may + // for huge pages we initialize the block_size as we may // overallocate to accommodate large alignments. size_t psize; uint8_t* start = _mi_segment_page_start(segment, page, &psize); - page->xblock_size = (psize > MI_HUGE_BLOCK_SIZE ? MI_HUGE_BLOCK_SIZE : (uint32_t)psize); + page->block_size = psize; + mi_assert_internal(page->is_huge); // decommit the part of the prefix of a page that will not be used; this can be quite large (close to MI_SEGMENT_SIZE) if (page_alignment > 0 && segment->allow_decommit) { uint8_t* aligned_p = (uint8_t*)_mi_align_up((uintptr_t)start, page_alignment); mi_assert_internal(_mi_is_aligned(aligned_p, page_alignment)); + mi_assert_internal(aligned_p >= start); mi_assert_internal(psize - (aligned_p - start) >= size); uint8_t* decommit_start = start + sizeof(mi_block_t); // for the free list - ptrdiff_t decommit_size = aligned_p - decommit_start; - _mi_os_reset(decommit_start, decommit_size, &_mi_stats_main); // note: cannot use segment_decommit on huge segments + if (aligned_p > decommit_start) { + size_t decommit_size = (size_t)(aligned_p - decommit_start); + _mi_os_reset(decommit_start, decommit_size); // note: cannot use segment_decommit on huge segments + } } return page; @@ -1574,7 +1640,7 @@ void _mi_segment_huge_page_free(mi_segment_t* segment, mi_page_t* page, mi_block mi_block_set_next(page, block, page->free); page->free = block; page->used--; - page->is_zero = false; + page->is_zero_init = false; mi_assert(page->used == 0); mi_tld_t* tld = heap->tld; _mi_segment_page_free(page, true, &tld->segments); @@ -1599,7 +1665,7 @@ void _mi_segment_huge_page_reset(mi_segment_t* segment, mi_page_t* page, mi_bloc if (csize > sizeof(mi_block_t)) { csize = csize - sizeof(mi_block_t); uint8_t* p = (uint8_t*)block + sizeof(mi_block_t); - _mi_os_reset(p, csize, &_mi_stats_main); // note: cannot use segment_decommit on huge segments + _mi_os_reset(p, csize); // note: cannot use segment_decommit on huge segments } } } @@ -1608,38 +1674,40 @@ void _mi_segment_huge_page_reset(mi_segment_t* segment, mi_page_t* page, mi_bloc /* ----------------------------------------------------------- Page allocation and free ----------------------------------------------------------- */ -mi_page_t* _mi_segment_page_alloc(mi_heap_t* heap, size_t block_size, size_t page_alignment, mi_segments_tld_t* tld, mi_os_tld_t* os_tld) { +mi_page_t* _mi_segment_page_alloc(mi_heap_t* heap, size_t block_size, size_t page_alignment, mi_segments_tld_t* tld) { mi_page_t* page; - if mi_unlikely(page_alignment > MI_ALIGNMENT_MAX) { + if mi_unlikely(page_alignment > MI_BLOCK_ALIGNMENT_MAX) { mi_assert_internal(_mi_is_power_of_two(page_alignment)); mi_assert_internal(page_alignment >= MI_SEGMENT_SIZE); if (page_alignment < MI_SEGMENT_SIZE) { page_alignment = MI_SEGMENT_SIZE; } - page = mi_segment_huge_page_alloc(block_size,page_alignment,heap->arena_id,tld,os_tld); + page = mi_segment_huge_page_alloc(block_size,page_alignment,heap->arena_id,tld); } else if (block_size <= MI_SMALL_OBJ_SIZE_MAX) { - page = mi_segments_page_alloc(heap,MI_PAGE_SMALL,block_size,block_size,tld,os_tld); + page = mi_segments_page_alloc(heap,MI_PAGE_SMALL,block_size,block_size,tld); } else if (block_size <= MI_MEDIUM_OBJ_SIZE_MAX) { - page = mi_segments_page_alloc(heap,MI_PAGE_MEDIUM,MI_MEDIUM_PAGE_SIZE,block_size,tld, os_tld); + page = mi_segments_page_alloc(heap,MI_PAGE_MEDIUM,MI_MEDIUM_PAGE_SIZE,block_size,tld); } else if (block_size <= MI_LARGE_OBJ_SIZE_MAX) { - page = mi_segments_page_alloc(heap,MI_PAGE_LARGE,block_size,block_size,tld, os_tld); + page = mi_segments_page_alloc(heap,MI_PAGE_LARGE,block_size,block_size,tld); } else { - page = mi_segment_huge_page_alloc(block_size,page_alignment,heap->arena_id,tld,os_tld); + page = mi_segment_huge_page_alloc(block_size,page_alignment,heap->arena_id,tld); } mi_assert_internal(page == NULL || _mi_heap_memid_is_suitable(heap, _mi_page_segment(page)->memid)); mi_assert_expensive(page == NULL || mi_segment_is_valid(_mi_page_segment(page),tld)); + mi_assert_internal(page == NULL || _mi_page_segment(page)->subproc == tld->subproc); return page; } + /* ----------------------------------------------------------- - Visit blocks in abandoned segments + Visit blocks in a segment (only used for abandoned segments) ----------------------------------------------------------- */ -static bool mi_segment_visit_page(mi_segment_t* segment, mi_page_t* page, bool visit_blocks, mi_block_visit_fun* visitor, void* arg) -{ +static bool mi_segment_visit_page(mi_page_t* page, bool visit_blocks, mi_block_visit_fun* visitor, void* arg) { mi_heap_area_t area; + _mi_page_free_collect(page,true); // CPython: collect first so the used count is accurate _mi_heap_area_init(&area, page); if (!visitor(NULL, &area, NULL, area.block_size, arg)) return false; if (visit_blocks) { @@ -1650,35 +1718,17 @@ static bool mi_segment_visit_page(mi_segment_t* segment, mi_page_t* page, bool v } } -static bool mi_segment_visit_pages(mi_segment_t* segment, uint8_t page_tag, bool visit_blocks, mi_block_visit_fun* visitor, void* arg) { +bool _mi_segment_visit_blocks(mi_segment_t* segment, int heap_tag, bool visit_blocks, mi_block_visit_fun* visitor, void* arg) { const mi_slice_t* end; mi_slice_t* slice = mi_slices_start_iterate(segment, &end); while (slice < end) { if (mi_slice_is_used(slice)) { mi_page_t* const page = mi_slice_to_page(slice); - if (page->tag == page_tag) { - if (!mi_segment_visit_page(segment, page, visit_blocks, visitor, arg)) return false; + if (heap_tag < 0 || (int)page->heap_tag == heap_tag) { + if (!mi_segment_visit_page(page, visit_blocks, visitor, arg)) return false; } } slice = slice + slice->slice_count; } return true; } - -// Visit all blocks in a abandoned segments -bool _mi_abandoned_pool_visit_blocks(mi_abandoned_pool_t* pool, uint8_t page_tag, bool visit_blocks, mi_block_visit_fun* visitor, void* arg) { - // Note: this is not safe in any other thread is abandoning or claiming segments from the pool - mi_segment_t* segment = mi_tagged_segment_ptr(pool->abandoned); - while (segment != NULL) { - if (!mi_segment_visit_pages(segment, page_tag, visit_blocks, visitor, arg)) return false; - segment = segment->abandoned_next; - } - - segment = pool->abandoned_visited; - while (segment != NULL) { - if (!mi_segment_visit_pages(segment, page_tag, visit_blocks, visitor, arg)) return false; - segment = segment->abandoned_next; - } - - return true; -} diff --git a/Objects/mimalloc/static.c b/Objects/mimalloc/static.c index 98c4aa18e450cd7..9e06ce05aaa5bbc 100644 --- a/Objects/mimalloc/static.c +++ b/Objects/mimalloc/static.c @@ -27,6 +27,7 @@ terms of the MIT license. A copy of the license can be found in the file #include "bitmap.c" #include "heap.c" #include "init.c" +#include "libc.c" #include "options.c" #include "os.c" #include "page.c" // includes page-queue.c diff --git a/Objects/mimalloc/stats.c b/Objects/mimalloc/stats.c index e7ea397ec4c384e..70d366e26c074ef 100644 --- a/Objects/mimalloc/stats.c +++ b/Objects/mimalloc/stats.c @@ -9,7 +9,6 @@ terms of the MIT license. A copy of the license can be found in the file #include "mimalloc/atomic.h" #include "mimalloc/prim.h" -#include // snprintf #include // memset #if defined(_MSC_VER) && (_MSC_VER < 1920) @@ -27,38 +26,29 @@ static bool mi_is_in_main(void* stat) { static void mi_stat_update(mi_stat_count_t* stat, int64_t amount) { if (amount == 0) return; - if (mi_is_in_main(stat)) + if mi_unlikely(mi_is_in_main(stat)) { // add atomically (for abandoned pages) int64_t current = mi_atomic_addi64_relaxed(&stat->current, amount); + // if (stat == &_mi_stats_main.committed) { mi_assert_internal(current + amount >= 0); }; mi_atomic_maxi64_relaxed(&stat->peak, current + amount); if (amount > 0) { - mi_atomic_addi64_relaxed(&stat->allocated,amount); - } - else { - mi_atomic_addi64_relaxed(&stat->freed, -amount); + mi_atomic_addi64_relaxed(&stat->total,amount); } } else { // add thread local stat->current += amount; - if (stat->current > stat->peak) stat->peak = stat->current; - if (amount > 0) { - stat->allocated += amount; - } - else { - stat->freed += -amount; - } + if (stat->current > stat->peak) { stat->peak = stat->current; } + if (amount > 0) { stat->total += amount; } } } void _mi_stat_counter_increase(mi_stat_counter_t* stat, size_t amount) { if (mi_is_in_main(stat)) { - mi_atomic_addi64_relaxed( &stat->count, 1 ); mi_atomic_addi64_relaxed( &stat->total, (int64_t)amount ); } else { - stat->count++; stat->total += amount; } } @@ -71,64 +61,70 @@ void _mi_stat_decrease(mi_stat_count_t* stat, size_t amount) { mi_stat_update(stat, -((int64_t)amount)); } + +static void mi_stat_adjust(mi_stat_count_t* stat, int64_t amount) { + if (amount == 0) return; + if mi_unlikely(mi_is_in_main(stat)) + { + // adjust atomically + mi_atomic_addi64_relaxed(&stat->current, amount); + mi_atomic_addi64_relaxed(&stat->total,amount); + } + else { + // adjust local + stat->current += amount; + stat->total += amount; + } +} + +void _mi_stat_adjust_decrease(mi_stat_count_t* stat, size_t amount) { + mi_stat_adjust(stat, -((int64_t)amount)); +} + + // must be thread safe as it is called from stats_merge -static void mi_stat_add(mi_stat_count_t* stat, const mi_stat_count_t* src, int64_t unit) { +static void mi_stat_count_add_mt(mi_stat_count_t* stat, const mi_stat_count_t* src) { if (stat==src) return; - if (src->allocated==0 && src->freed==0) return; - mi_atomic_addi64_relaxed( &stat->allocated, src->allocated * unit); - mi_atomic_addi64_relaxed( &stat->current, src->current * unit); - mi_atomic_addi64_relaxed( &stat->freed, src->freed * unit); - // peak scores do not work across threads.. - mi_atomic_addi64_relaxed( &stat->peak, src->peak * unit); + mi_atomic_void_addi64_relaxed(&stat->total, &src->total); + const int64_t prev_current = mi_atomic_addi64_relaxed(&stat->current, src->current); + + // Global current plus thread peak approximates new global peak + // note: peak scores do really not work across threads. + // we used to just add them together but that often overestimates in practice. + // similarly, max does not seem to work well. The current approach + // by Artem Kharytoniuk (@artem-lunarg) seems to work better, see PR#1112 + // for a longer description. + mi_atomic_maxi64_relaxed(&stat->peak, prev_current + src->peak); } -static void mi_stat_counter_add(mi_stat_counter_t* stat, const mi_stat_counter_t* src, int64_t unit) { +static void mi_stat_counter_add_mt(mi_stat_counter_t* stat, const mi_stat_counter_t* src) { if (stat==src) return; - mi_atomic_addi64_relaxed( &stat->total, src->total * unit); - mi_atomic_addi64_relaxed( &stat->count, src->count * unit); + mi_atomic_void_addi64_relaxed(&stat->total, &src->total); } +#define MI_STAT_COUNT(stat) mi_stat_count_add_mt(&stats->stat, &src->stat); +#define MI_STAT_COUNTER(stat) mi_stat_counter_add_mt(&stats->stat, &src->stat); + // must be thread safe as it is called from stats_merge static void mi_stats_add(mi_stats_t* stats, const mi_stats_t* src) { if (stats==src) return; - mi_stat_add(&stats->segments, &src->segments,1); - mi_stat_add(&stats->pages, &src->pages,1); - mi_stat_add(&stats->reserved, &src->reserved, 1); - mi_stat_add(&stats->committed, &src->committed, 1); - mi_stat_add(&stats->reset, &src->reset, 1); - mi_stat_add(&stats->purged, &src->purged, 1); - mi_stat_add(&stats->page_committed, &src->page_committed, 1); - - mi_stat_add(&stats->pages_abandoned, &src->pages_abandoned, 1); - mi_stat_add(&stats->segments_abandoned, &src->segments_abandoned, 1); - mi_stat_add(&stats->threads, &src->threads, 1); - - mi_stat_add(&stats->malloc, &src->malloc, 1); - mi_stat_add(&stats->segments_cache, &src->segments_cache, 1); - mi_stat_add(&stats->normal, &src->normal, 1); - mi_stat_add(&stats->huge, &src->huge, 1); - mi_stat_add(&stats->large, &src->large, 1); - - mi_stat_counter_add(&stats->pages_extended, &src->pages_extended, 1); - mi_stat_counter_add(&stats->mmap_calls, &src->mmap_calls, 1); - mi_stat_counter_add(&stats->commit_calls, &src->commit_calls, 1); - mi_stat_counter_add(&stats->reset_calls, &src->reset_calls, 1); - mi_stat_counter_add(&stats->purge_calls, &src->purge_calls, 1); - - mi_stat_counter_add(&stats->page_no_retire, &src->page_no_retire, 1); - mi_stat_counter_add(&stats->searches, &src->searches, 1); - mi_stat_counter_add(&stats->normal_count, &src->normal_count, 1); - mi_stat_counter_add(&stats->huge_count, &src->huge_count, 1); - mi_stat_counter_add(&stats->large_count, &src->large_count, 1); -#if MI_STAT>1 + + // copy all fields + MI_STAT_FIELDS() + + #if MI_STAT>1 for (size_t i = 0; i <= MI_BIN_HUGE; i++) { - if (src->normal_bins[i].allocated > 0 || src->normal_bins[i].freed > 0) { - mi_stat_add(&stats->normal_bins[i], &src->normal_bins[i], 1); - } + mi_stat_count_add_mt(&stats->malloc_bins[i], &src->malloc_bins[i]); + } + #endif + for (size_t i = 0; i <= MI_BIN_HUGE; i++) { + mi_stat_count_add_mt(&stats->page_bins[i], &src->page_bins[i]); } -#endif } +#undef MI_STAT_COUNT +#undef MI_STAT_COUNTER + /* ----------------------------------------------------------- Display statistics ----------------------------------------------------------- */ @@ -136,7 +132,7 @@ static void mi_stats_add(mi_stats_t* stats, const mi_stats_t* src) { // unit > 0 : size in binary bytes // unit == 0: count as decimal // unit < 0 : count in binary -static void mi_printf_amount(int64_t n, int64_t unit, mi_output_fun* out, void* arg, const char* fmt) { +static void mi_printf_amount(int64_t n, int64_t unit, mi_output_fun* out, void* arg, bool limitwidth) { char buf[32]; buf[0] = 0; int len = 32; const char* suffix = (unit <= 0 ? " " : "B"); @@ -146,7 +142,7 @@ static void mi_printf_amount(int64_t n, int64_t unit, mi_output_fun* out, void* const int64_t pos = (n < 0 ? -n : n); if (pos < base) { if (n!=1 || suffix[0] != 'B') { // skip printing 1 B for the unit column - snprintf(buf, len, "%d %-3s", (int)n, (n==0 ? "" : suffix)); + _mi_snprintf(buf, len, "%lld %-3s", (long long)n, (n==0 ? "" : suffix)); } } else { @@ -158,15 +154,20 @@ static void mi_printf_amount(int64_t n, int64_t unit, mi_output_fun* out, void* const long whole = (long)(tens/10); const long frac1 = (long)(tens%10); char unitdesc[8]; - snprintf(unitdesc, 8, "%s%s%s", magnitude, (base==1024 ? "i" : ""), suffix); - snprintf(buf, len, "%ld.%ld %-3s", whole, (frac1 < 0 ? -frac1 : frac1), unitdesc); + _mi_snprintf(unitdesc, 8, "%s%s%s", magnitude, (base==1024 ? "i" : ""), suffix); + _mi_snprintf(buf, len, "%ld.%ld %-3s", whole, (frac1 < 0 ? -frac1 : frac1), unitdesc); + } + if (limitwidth) { + _mi_fprintf(out, arg, "%12s", buf); + } + else { + _mi_fprintf(out, arg, "%s", buf); } - _mi_fprintf(out, arg, (fmt==NULL ? "%12s" : fmt), buf); } static void mi_print_amount(int64_t n, int64_t unit, mi_output_fun* out, void* arg) { - mi_printf_amount(n,unit,out,arg,NULL); + mi_printf_amount(n,unit,out,arg,true); } static void mi_print_count(int64_t n, int64_t unit, mi_output_fun* out, void* arg) { @@ -176,44 +177,41 @@ static void mi_print_count(int64_t n, int64_t unit, mi_output_fun* out, void* ar static void mi_stat_print_ex(const mi_stat_count_t* stat, const char* msg, int64_t unit, mi_output_fun* out, void* arg, const char* notok ) { _mi_fprintf(out, arg,"%10s:", msg); - if (unit > 0) { - mi_print_amount(stat->peak, unit, out, arg); - mi_print_amount(stat->allocated, unit, out, arg); - mi_print_amount(stat->freed, unit, out, arg); - mi_print_amount(stat->current, unit, out, arg); - mi_print_amount(unit, 1, out, arg); - mi_print_count(stat->allocated, unit, out, arg); - if (stat->allocated > stat->freed) { - _mi_fprintf(out, arg, " "); - _mi_fprintf(out, arg, (notok == NULL ? "not all freed" : notok)); - _mi_fprintf(out, arg, "\n"); + if (unit != 0) { + if (unit > 0) { + mi_print_amount(stat->peak, unit, out, arg); + mi_print_amount(stat->total, unit, out, arg); + // mi_print_amount(stat->freed, unit, out, arg); + mi_print_amount(stat->current, unit, out, arg); + mi_print_amount(unit, 1, out, arg); + mi_print_count(stat->total, unit, out, arg); } else { - _mi_fprintf(out, arg, " ok\n"); + mi_print_amount(stat->peak, -1, out, arg); + mi_print_amount(stat->total, -1, out, arg); + // mi_print_amount(stat->freed, -1, out, arg); + mi_print_amount(stat->current, -1, out, arg); + if (unit == -1) { + _mi_fprintf(out, arg, "%24s", ""); + } + else { + mi_print_amount(-unit, 1, out, arg); + mi_print_count((stat->total / -unit), 0, out, arg); + } } - } - else if (unit<0) { - mi_print_amount(stat->peak, -1, out, arg); - mi_print_amount(stat->allocated, -1, out, arg); - mi_print_amount(stat->freed, -1, out, arg); - mi_print_amount(stat->current, -1, out, arg); - if (unit==-1) { - _mi_fprintf(out, arg, "%24s", ""); + if (stat->current != 0) { + _mi_fprintf(out, arg, " "); + _mi_fprintf(out, arg, "%s", (notok == NULL ? "not all freed" : notok)); + _mi_fprintf(out, arg, "\n"); } else { - mi_print_amount(-unit, 1, out, arg); - mi_print_count((stat->allocated / -unit), 0, out, arg); - } - if (stat->allocated > stat->freed) - _mi_fprintf(out, arg, " not all freed!\n"); - else _mi_fprintf(out, arg, " ok\n"); + } } else { - mi_print_amount(stat->peak, 1, out, arg); - mi_print_amount(stat->allocated, 1, out, arg); - _mi_fprintf(out, arg, "%11s", " "); // no freed - mi_print_amount(stat->current, 1, out, arg); + mi_print_amount(stat->peak, 0, out, arg); + mi_print_amount(stat->total, 0, out, arg); + mi_print_amount(stat->current, 0, out, arg); _mi_fprintf(out, arg, "\n"); } } @@ -222,29 +220,37 @@ static void mi_stat_print(const mi_stat_count_t* stat, const char* msg, int64_t mi_stat_print_ex(stat, msg, unit, out, arg, NULL); } -static void mi_stat_peak_print(const mi_stat_count_t* stat, const char* msg, int64_t unit, mi_output_fun* out, void* arg) { +#if MI_STAT>1 +static void mi_stat_total_print(const mi_stat_count_t* stat, const char* msg, int64_t unit, mi_output_fun* out, void* arg) { _mi_fprintf(out, arg, "%10s:", msg); - mi_print_amount(stat->peak, unit, out, arg); + _mi_fprintf(out, arg, "%12s", " "); // no peak + mi_print_amount(stat->total, unit, out, arg); _mi_fprintf(out, arg, "\n"); } +#endif static void mi_stat_counter_print(const mi_stat_counter_t* stat, const char* msg, mi_output_fun* out, void* arg ) { _mi_fprintf(out, arg, "%10s:", msg); - mi_print_amount(stat->total, -1, out, arg); + mi_print_amount(stat->total, 0, out, arg); _mi_fprintf(out, arg, "\n"); } +static void mi_stat_counter_print_size(const mi_stat_counter_t* stat, const char* msg, mi_output_fun* out, void* arg ) { + _mi_fprintf(out, arg, "%10s:", msg); + mi_print_amount(stat->total, 1, out, arg); + _mi_fprintf(out, arg, "\n"); +} -static void mi_stat_counter_print_avg(const mi_stat_counter_t* stat, const char* msg, mi_output_fun* out, void* arg) { - const int64_t avg_tens = (stat->count == 0 ? 0 : (stat->total*10 / stat->count)); - const long avg_whole = (long)(avg_tens/10); - const long avg_frac1 = (long)(avg_tens%10); - _mi_fprintf(out, arg, "%10s: %5ld.%ld avg\n", msg, avg_whole, avg_frac1); +static void mi_stat_average_print(int64_t count, int64_t total, const char* msg, mi_output_fun* out, void* arg) { + const int64_t avg_tens = (count == 0 ? 0 : (total*10 / count)); + const int64_t avg_whole = avg_tens/10; + const int64_t avg_frac1 = avg_tens%10; + _mi_fprintf(out, arg, "%10s: %5lld.%lld avg\n", msg, avg_whole, avg_frac1); } static void mi_print_header(mi_output_fun* out, void* arg ) { - _mi_fprintf(out, arg, "%10s: %11s %11s %11s %11s %11s %11s\n", "heap stats", "peak ", "total ", "freed ", "current ", "unit ", "count "); + _mi_fprintf(out, arg, "%10s: %11s %11s %11s %11s %11s\n", "heap stats", "peak ", "total ", "current ", "block ", "total# "); } #if MI_STAT>1 @@ -252,10 +258,10 @@ static void mi_stats_print_bins(const mi_stat_count_t* bins, size_t max, const c bool found = false; char buf[64]; for (size_t i = 0; i <= max; i++) { - if (bins[i].allocated > 0) { + if (bins[i].total > 0) { found = true; int64_t unit = _mi_bin_size((uint8_t)i); - snprintf(buf, 64, "%s %3lu", fmt, (long)i); + _mi_snprintf(buf, 64, "%s %3lu", fmt, (long)i); mi_stat_print(&bins[i], buf, unit, out, arg); } } @@ -313,41 +319,44 @@ static void _mi_stats_print(mi_stats_t* stats, mi_output_fun* out0, void* arg0) // and print using that mi_print_header(out,arg); #if MI_STAT>1 - mi_stats_print_bins(stats->normal_bins, MI_BIN_HUGE, "normal",out,arg); + mi_stats_print_bins(stats->malloc_bins, MI_BIN_HUGE, "bin",out,arg); #endif #if MI_STAT - mi_stat_print(&stats->normal, "normal", (stats->normal_count.count == 0 ? 1 : -(stats->normal.allocated / stats->normal_count.count)), out, arg); - mi_stat_print(&stats->large, "large", (stats->large_count.count == 0 ? 1 : -(stats->large.allocated / stats->large_count.count)), out, arg); - mi_stat_print(&stats->huge, "huge", (stats->huge_count.count == 0 ? 1 : -(stats->huge.allocated / stats->huge_count.count)), out, arg); - mi_stat_count_t total = { 0,0,0,0 }; - mi_stat_add(&total, &stats->normal, 1); - mi_stat_add(&total, &stats->large, 1); - mi_stat_add(&total, &stats->huge, 1); - mi_stat_print(&total, "total", 1, out, arg); + mi_stat_print(&stats->malloc_normal, "binned", (stats->malloc_normal_count.total == 0 ? -1 : 1), out, arg); + mi_stat_print(&stats->malloc_huge, "huge", (stats->malloc_huge_count.total == 0 ? -1 : 1), out, arg); + mi_stat_count_t total = { 0,0,0 }; + mi_stat_count_add_mt(&total, &stats->malloc_normal); + // mi_stat_count_add(&total, &stats->malloc_large); + mi_stat_count_add_mt(&total, &stats->malloc_huge); + mi_stat_print_ex(&total, "total", 1, out, arg, ""); #endif #if MI_STAT>1 - mi_stat_print(&stats->malloc, "malloc req", 1, out, arg); + mi_stat_total_print(&stats->malloc_requested, "malloc req", 1, out, arg); _mi_fprintf(out, arg, "\n"); #endif mi_stat_print_ex(&stats->reserved, "reserved", 1, out, arg, ""); mi_stat_print_ex(&stats->committed, "committed", 1, out, arg, ""); - mi_stat_peak_print(&stats->reset, "reset", 1, out, arg ); - mi_stat_peak_print(&stats->purged, "purged", 1, out, arg ); - mi_stat_print(&stats->page_committed, "touched", 1, out, arg); - mi_stat_print(&stats->segments, "segments", -1, out, arg); - mi_stat_print(&stats->segments_abandoned, "-abandoned", -1, out, arg); - mi_stat_print(&stats->segments_cache, "-cached", -1, out, arg); - mi_stat_print(&stats->pages, "pages", -1, out, arg); - mi_stat_print(&stats->pages_abandoned, "-abandoned", -1, out, arg); + mi_stat_counter_print_size(&stats->reset, "reset", out, arg ); + mi_stat_counter_print_size(&stats->purged, "purged", out, arg ); + mi_stat_print_ex(&stats->page_committed, "touched", 1, out, arg, ""); + mi_stat_print(&stats->segments, "segments", 0, out, arg); + mi_stat_print(&stats->segments_abandoned, "-abandoned", 0, out, arg); + mi_stat_print(&stats->segments_cache, "-cached", 0, out, arg); + mi_stat_print(&stats->pages, "pages", 0, out, arg); + mi_stat_print(&stats->pages_abandoned, "-abandoned", 0, out, arg); mi_stat_counter_print(&stats->pages_extended, "-extended", out, arg); - mi_stat_counter_print(&stats->page_no_retire, "-noretire", out, arg); + mi_stat_counter_print(&stats->pages_retire, "-retire", out, arg); + mi_stat_counter_print(&stats->arena_count, "arenas", out, arg); + // mi_stat_counter_print(&stats->arena_crossover_count, "-crossover", out, arg); + mi_stat_counter_print(&stats->arena_rollback_count, "-rollback", out, arg); mi_stat_counter_print(&stats->mmap_calls, "mmaps", out, arg); mi_stat_counter_print(&stats->commit_calls, "commits", out, arg); mi_stat_counter_print(&stats->reset_calls, "resets", out, arg); mi_stat_counter_print(&stats->purge_calls, "purges", out, arg); - mi_stat_print(&stats->threads, "threads", -1, out, arg); - mi_stat_counter_print_avg(&stats->searches, "searches", out, arg); - _mi_fprintf(out, arg, "%10s: %5zu\n", "numa nodes", _mi_os_numa_node_count()); + mi_stat_counter_print(&stats->malloc_guarded_count, "guarded", out, arg); + mi_stat_print(&stats->threads, "threads", 0, out, arg); + mi_stat_average_print(stats->page_searches_count.total, stats->page_searches.total, "searches", out, arg); + _mi_fprintf(out, arg, "%10s: %5i\n", "numa nodes", _mi_os_numa_node_count()); size_t elapsed; size_t user_time; @@ -358,13 +367,13 @@ static void _mi_stats_print(mi_stats_t* stats, mi_output_fun* out0, void* arg0) size_t peak_commit; size_t page_faults; mi_process_info(&elapsed, &user_time, &sys_time, ¤t_rss, &peak_rss, ¤t_commit, &peak_commit, &page_faults); - _mi_fprintf(out, arg, "%10s: %5ld.%03ld s\n", "elapsed", elapsed/1000, elapsed%1000); - _mi_fprintf(out, arg, "%10s: user: %ld.%03ld s, system: %ld.%03ld s, faults: %lu, rss: ", "process", - user_time/1000, user_time%1000, sys_time/1000, sys_time%1000, (unsigned long)page_faults ); - mi_printf_amount((int64_t)peak_rss, 1, out, arg, "%s"); + _mi_fprintf(out, arg, "%10s: %5zu.%03zu s\n", "elapsed", elapsed/1000, elapsed%1000); + _mi_fprintf(out, arg, "%10s: user: %zu.%03zu s, system: %zu.%03zu s, faults: %zu, peak rss: ", "process", + user_time/1000, user_time%1000, sys_time/1000, sys_time%1000, page_faults ); + mi_printf_amount((int64_t)peak_rss, 1, out, arg, false); if (peak_commit > 0) { - _mi_fprintf(out, arg, ", commit: "); - mi_printf_amount((int64_t)peak_commit, 1, out, arg, "%s"); + _mi_fprintf(out, arg, ", peak commit: "); + mi_printf_amount((int64_t)peak_commit, 1, out, arg, false); } _mi_fprintf(out, arg, "\n"); } @@ -394,6 +403,10 @@ void mi_stats_merge(void) mi_attr_noexcept { mi_stats_merge_from( mi_stats_get_default() ); } +void _mi_stats_merge_thread(mi_tld_t* tld) { + mi_stats_merge_from( &tld->stats ); +} + void _mi_stats_done(mi_stats_t* stats) { // called from `mi_thread_done` mi_stats_merge_from(stats); } @@ -465,3 +478,170 @@ mi_decl_export void mi_process_info(size_t* elapsed_msecs, size_t* user_msecs, s if (peak_commit!=NULL) *peak_commit = pinfo.peak_commit; if (page_faults!=NULL) *page_faults = pinfo.page_faults; } + + +// -------------------------------------------------------- +// Return statistics +// -------------------------------------------------------- + +bool mi_stats_get(mi_stats_t* stats) mi_attr_noexcept { + if (stats == NULL || stats->size != sizeof(mi_stats_t) || stats->version != MI_STAT_VERSION) return false; + _mi_memzero(stats,stats->size); + _mi_memcpy(stats, &_mi_stats_main, sizeof(mi_stats_t)); + return true; +} + + +// -------------------------------------------------------- +// Statics in json format +// -------------------------------------------------------- + +typedef struct mi_heap_buf_s { + char* buf; + size_t size; + size_t used; + bool can_realloc; +} mi_heap_buf_t; + +static bool mi_heap_buf_expand(mi_heap_buf_t* hbuf) { + if (hbuf==NULL) return false; + if (hbuf->buf != NULL && hbuf->size>0) { + hbuf->buf[hbuf->size-1] = 0; + } + if (hbuf->size > SIZE_MAX/2 || !hbuf->can_realloc) return false; + const size_t newsize = (hbuf->size == 0 ? mi_good_size(12*MI_KiB) : 2*hbuf->size); + char* const newbuf = (char*)mi_rezalloc(hbuf->buf, newsize); + if (newbuf == NULL) return false; + hbuf->buf = newbuf; + hbuf->size = newsize; + return true; +} + +static void mi_heap_buf_print(mi_heap_buf_t* hbuf, const char* msg) { + if (msg==NULL || hbuf==NULL) return; + if (hbuf->used + 1 >= hbuf->size && !hbuf->can_realloc) return; + for (const char* src = msg; *src != 0; src++) { + char c = *src; + if (hbuf->used + 1 >= hbuf->size) { + if (!mi_heap_buf_expand(hbuf)) return; + } + mi_assert_internal(hbuf->used < hbuf->size); + hbuf->buf[hbuf->used++] = c; + } + mi_assert_internal(hbuf->used < hbuf->size); + hbuf->buf[hbuf->used] = 0; +} + +static void mi_heap_buf_print_count_bin(mi_heap_buf_t* hbuf, const char* prefix, mi_stat_count_t* stat, size_t bin, bool add_comma) { + const size_t binsize = _mi_bin_size(bin); + const size_t pagesize = (binsize <= MI_SMALL_OBJ_SIZE_MAX ? MI_SMALL_PAGE_SIZE : + (binsize <= MI_MEDIUM_OBJ_SIZE_MAX ? MI_MEDIUM_PAGE_SIZE : + #if MI_LARGE_PAGE_SIZE + (binsize <= MI_LARGE_OBJ_SIZE_MAX ? MI_LARGE_PAGE_SIZE : 0) + #else + 0 + #endif + )); + char buf[128]; + _mi_snprintf(buf, 128, "%s{ \"total\": %lld, \"peak\": %lld, \"current\": %lld, \"block_size\": %zu, \"page_size\": %zu }%s\n", prefix, stat->total, stat->peak, stat->current, binsize, pagesize, (add_comma ? "," : "")); + buf[127] = 0; + mi_heap_buf_print(hbuf, buf); +} + +static void mi_heap_buf_print_count(mi_heap_buf_t* hbuf, const char* prefix, mi_stat_count_t* stat, bool add_comma) { + char buf[128]; + _mi_snprintf(buf, 128, "%s{ \"total\": %lld, \"peak\": %lld, \"current\": %lld }%s\n", prefix, stat->total, stat->peak, stat->current, (add_comma ? "," : "")); + buf[127] = 0; + mi_heap_buf_print(hbuf, buf); +} + +static void mi_heap_buf_print_count_value(mi_heap_buf_t* hbuf, const char* name, mi_stat_count_t* stat) { + char buf[128]; + _mi_snprintf(buf, 128, " \"%s\": ", name); + buf[127] = 0; + mi_heap_buf_print(hbuf, buf); + mi_heap_buf_print_count(hbuf, "", stat, true); +} + +static void mi_heap_buf_print_value(mi_heap_buf_t* hbuf, const char* name, int64_t val) { + char buf[128]; + _mi_snprintf(buf, 128, " \"%s\": %lld,\n", name, val); + buf[127] = 0; + mi_heap_buf_print(hbuf, buf); +} + +static void mi_heap_buf_print_size(mi_heap_buf_t* hbuf, const char* name, size_t val, bool add_comma) { + char buf[128]; + _mi_snprintf(buf, 128, " \"%s\": %zu%s\n", name, val, (add_comma ? "," : "")); + buf[127] = 0; + mi_heap_buf_print(hbuf, buf); +} + +static void mi_heap_buf_print_counter_value(mi_heap_buf_t* hbuf, const char* name, mi_stat_counter_t* stat) { + mi_heap_buf_print_value(hbuf, name, stat->total); +} + +#define MI_STAT_COUNT(stat) mi_heap_buf_print_count_value(&hbuf, #stat, &stats->stat); +#define MI_STAT_COUNTER(stat) mi_heap_buf_print_counter_value(&hbuf, #stat, &stats->stat); + +char* mi_stats_get_json(size_t output_size, char* output_buf) mi_attr_noexcept { + mi_heap_buf_t hbuf = { NULL, 0, 0, true }; + if (output_size > 0 && output_buf != NULL) { + _mi_memzero(output_buf, output_size); + hbuf.buf = output_buf; + hbuf.size = output_size; + hbuf.can_realloc = false; + } + else { + if (!mi_heap_buf_expand(&hbuf)) return NULL; + } + mi_heap_buf_print(&hbuf, "{\n"); + mi_heap_buf_print_value(&hbuf, "stat_version", MI_STAT_VERSION); + mi_heap_buf_print_value(&hbuf, "mimalloc_version", MI_MALLOC_VERSION); + + // process info + mi_heap_buf_print(&hbuf, " \"process\": {\n"); + size_t elapsed; + size_t user_time; + size_t sys_time; + size_t current_rss; + size_t peak_rss; + size_t current_commit; + size_t peak_commit; + size_t page_faults; + mi_process_info(&elapsed, &user_time, &sys_time, ¤t_rss, &peak_rss, ¤t_commit, &peak_commit, &page_faults); + mi_heap_buf_print_size(&hbuf, "elapsed_msecs", elapsed, true); + mi_heap_buf_print_size(&hbuf, "user_msecs", user_time, true); + mi_heap_buf_print_size(&hbuf, "system_msecs", sys_time, true); + mi_heap_buf_print_size(&hbuf, "page_faults", page_faults, true); + mi_heap_buf_print_size(&hbuf, "rss_current", current_rss, true); + mi_heap_buf_print_size(&hbuf, "rss_peak", peak_rss, true); + mi_heap_buf_print_size(&hbuf, "commit_current", current_commit, true); + mi_heap_buf_print_size(&hbuf, "commit_peak", peak_commit, false); + mi_heap_buf_print(&hbuf, " },\n"); + + // statistics + mi_stats_t* stats = &_mi_stats_main; + MI_STAT_FIELDS() + + // size bins + mi_heap_buf_print(&hbuf, " \"malloc_bins\": [\n"); + for (size_t i = 0; i <= MI_BIN_HUGE; i++) { + mi_heap_buf_print_count_bin(&hbuf, " ", &stats->malloc_bins[i], i, i!=MI_BIN_HUGE); + } + mi_heap_buf_print(&hbuf, " ],\n"); + mi_heap_buf_print(&hbuf, " \"page_bins\": [\n"); + for (size_t i = 0; i <= MI_BIN_HUGE; i++) { + mi_heap_buf_print_count_bin(&hbuf, " ", &stats->page_bins[i], i, i!=MI_BIN_HUGE); + } + mi_heap_buf_print(&hbuf, " ]\n"); + mi_heap_buf_print(&hbuf, "}\n"); + if (hbuf.used >= hbuf.size) { + // failed + if (hbuf.can_realloc) { mi_free(hbuf.buf); } + return NULL; + } + else { + return hbuf.buf; + } +} diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index f447403ef31b43a..568711149a8aeb6 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -7,7 +7,7 @@ #include "pycore_fileutils.h" // _Py_wgetcwd #include "pycore_import.h" // _PyImport_GetNextModuleIndex() #include "pycore_interp.h" // PyInterpreterState.importlib -#include "pycore_lazyimportobject.h" // _PyLazyImportObject_Check() +#include "pycore_lazyimportobject.h" // PyLazyImport_CheckExact() #include "pycore_long.h" // _PyLong_GetOne() #include "pycore_modsupport.h" // _PyModule_CreateInitialized() #include "pycore_moduleobject.h" // _PyModule_GetDefOrNull() @@ -409,7 +409,7 @@ module_from_slots_and_spec( createfunc_t create = NULL; PyObject *nameobj; PyObject *m = NULL; - uint64_t multiple_interpreters = (uint64_t)Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED; + uint64_t multiple_interpreters = (uint64_t)(uintptr_t)Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED; bool requires_gil = true; const char *name; int ret; @@ -471,7 +471,7 @@ module_from_slots_and_spec( case Py_mod_gil: { uint64_t val = it.current.sl_uint64; - requires_gil = (val != (uint64_t)Py_MOD_GIL_NOT_USED); + requires_gil = (val != (uint64_t)(uintptr_t)Py_MOD_GIL_NOT_USED); } break; case Py_mod_abi: @@ -992,6 +992,10 @@ _PyModule_GetFilenameUTF8(PyObject *mod, char *buffer, Py_ssize_t maxlen) } else { const char *filename = PyUnicode_AsUTF8AndSize(filenameobj, &size); + if (filename == NULL) { + Py_DECREF(filenameobj); + return -1; + } assert(size >= 0); if (size > maxlen) { size = -1; @@ -1238,6 +1242,10 @@ _PyModuleSpec_GetFileOrigin(PyObject *spec, PyObject **p_origin) int _PyModule_IsPossiblyShadowing(PyObject *origin) { + int result = 0; + wchar_t *root = NULL; + wchar_t *sys_path_0_buf = NULL; + // origin must be a unicode subtype // Returns 1 if the module at origin could be shadowing a module of the // same name later in the module search path. The condition we check is basically: @@ -1256,24 +1264,21 @@ _PyModule_IsPossiblyShadowing(PyObject *origin) } // root = os.path.dirname(origin.removesuffix(os.sep + "__init__.py")) - wchar_t root[MAXPATHLEN + 1]; - Py_ssize_t size = PyUnicode_AsWideChar(origin, root, MAXPATHLEN); - if (size < 0) { + root = PyUnicode_AsWideCharString(origin, NULL); + if (root == NULL) { return -1; } - assert(size <= MAXPATHLEN); - root[size] = L'\0'; wchar_t *sep = wcsrchr(root, SEP); if (sep == NULL) { - return 0; + goto done; } // If it's a package then we need to look one directory further up if (wcscmp(sep + 1, L"__init__.py") == 0) { *sep = L'\0'; sep = wcsrchr(root, SEP); if (sep == NULL) { - return 0; + goto done; } } *sep = L'\0'; @@ -1281,49 +1286,48 @@ _PyModule_IsPossiblyShadowing(PyObject *origin) // sys.path[0] or os.getcwd() wchar_t *sys_path_0 = config->sys_path_0; if (!sys_path_0) { - return 0; + goto done; } - wchar_t sys_path_0_buf[MAXPATHLEN]; if (sys_path_0[0] == L'\0') { // if sys.path[0] == "", treat it as if it were the current directory + sys_path_0_buf = PyMem_Malloc(MAXPATHLEN * sizeof(wchar_t)); + if (sys_path_0_buf == NULL) { + PyErr_NoMemory(); + result = -1; + goto done; + } if (!_Py_wgetcwd(sys_path_0_buf, MAXPATHLEN)) { // If we failed to getcwd, don't raise an exception and instead // let the caller proceed assuming no shadowing - return 0; + goto done; } sys_path_0 = sys_path_0_buf; } - int result = wcscmp(sys_path_0, root) == 0; + result = (wcscmp(sys_path_0, root) == 0); + +done: + PyMem_Free(root); + PyMem_Free(sys_path_0_buf); return result; } -// Check if `name` is a lazily pending submodule of module `m`. -// Returns a new reference on success, or NULL with no error set. -static PyObject * -try_load_lazy_submodule(PyModuleObject *m, PyObject *name) +static int +module_get_resolved_dict_item(PyObject *dict, PyObject *name, PyObject **result) { - PyObject *mod_name; - int rc = PyDict_GetItemRef(m->md_dict, &_Py_ID(__name__), &mod_name); - if (rc <= 0) { - return NULL; - } - if (!PyUnicode_Check(mod_name)) { - Py_DECREF(mod_name); - return NULL; - } - PyObject *result = _PyImport_TryLoadLazySubmodule(mod_name, name); - Py_DECREF(mod_name); - if (result == NULL) { - PyErr_Clear(); - return NULL; + int rc = PyDict_GetItemRef(dict, name, result); + if (rc <= 0 || !PyLazyImport_CheckExact(*result)) { + return rc; } - if (PyDict_SetItem(m->md_dict, name, result) < 0) { - Py_DECREF(result); - return NULL; + PyThreadState *tstate = PyThreadState_GET(); + if (_PyLazyImport_IsResolving(tstate, *result)) { + Py_CLEAR(*result); + return 0; } - return result; + PyObject *value = _PyLazyImport_Reify(tstate, *result, name, dict); + Py_SETREF(*result, value); + return value == NULL ? -1 : 1; } PyObject* @@ -1332,72 +1336,61 @@ _Py_module_getattro_impl(PyModuleObject *m, PyObject *name, int suppress) // When suppress=1, this function suppresses AttributeError. PyObject *attr, *mod_name, *getattr; attr = _PyObject_GenericGetAttrWithDict((PyObject *)m, name, NULL, suppress); - if (attr) { - if (PyLazyImport_CheckExact(attr)) { - // gh-144957: Module __getattr__ should get a chance to provide - // the attribute before resolving a lazy import placeholder. - if (PyDict_GetItemRef(m->md_dict, &_Py_ID(__getattr__), &getattr) < 0) { - Py_DECREF(attr); + if (attr == NULL) { + if (suppress == 1) { + if (PyErr_Occurred()) { + // pass up non-AttributeError exception return NULL; } - if (getattr) { - PyObject *result = PyObject_CallOneArg(getattr, name); - Py_DECREF(getattr); - if (result != NULL) { - Py_DECREF(attr); - return result; - } - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { - Py_DECREF(attr); - return NULL; - } - PyErr_Clear(); + } + else { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { + // pass up non-AttributeError exception + return NULL; } - PyObject *new_value = _PyImport_LoadLazyImportTstate( - PyThreadState_GET(), attr); - if (new_value == NULL) { - if (suppress && - PyErr_ExceptionMatches(PyExc_ImportCycleError)) { - // ImportCycleError is raised when a lazy object tries - // to import itself. In this case, the error should not - // propagate to the caller and instead treated as if the - // attribute doesn't exist. - PyErr_Clear(); + PyErr_Clear(); + } + assert(m->md_dict != NULL); + int recheck_dict; + attr = _PyImport_TryLoadLazySubmodule((PyObject *)m, name, suppress, + &recheck_dict); + if (attr != NULL || PyErr_Occurred()) { + return attr; + } + // A concurrent load may have bound the child and removed its pending + // registration after our initial dictionary lookup. + if (recheck_dict) { + if (Py_TYPE(m) != &PyModule_Type) { + PyObject *descr = _PyType_LookupRef(Py_TYPE(m), name); + if (descr != NULL) { + // Preserve the fallback after a descriptor raised. + recheck_dict = Py_TYPE(descr)->tp_descr_get == NULL; + Py_DECREF(descr); } - Py_DECREF(attr); + } + if (recheck_dict && + PyDict_GetItemRef(m->md_dict, name, &attr) < 0) { return NULL; } - - if (PyDict_SetItem(m->md_dict, name, new_value) < 0) { - Py_CLEAR(new_value); + } + } + if (attr) { + if (PyLazyImport_CheckExact(attr)) { + PyThreadState *tstate = PyThreadState_GET(); + if (suppress && _PyLazyImport_IsResolving(tstate, attr)) { + // Only direct reentry means this attribute is unavailable. + Py_DECREF(attr); + return NULL; } + PyObject *new_value = _PyLazyImport_Reify( + tstate, attr, name, m->md_dict); Py_DECREF(attr); return new_value; } return attr; } - if (suppress == 1) { - if (PyErr_Occurred()) { - // pass up non-AttributeError exception - return NULL; - } - } - else { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { - // pass up non-AttributeError exception - return NULL; - } - PyErr_Clear(); - } - assert(m->md_dict != NULL); - attr = try_load_lazy_submodule(m, name); - if (attr != NULL) { - return attr; - } - if (PyErr_Occurred()) { - return NULL; - } - if (PyDict_GetItemRef(m->md_dict, &_Py_ID(__getattr__), &getattr) < 0) { + if (module_get_resolved_dict_item( + m->md_dict, &_Py_ID(__getattr__), &getattr) < 0) { return NULL; } if (getattr) { @@ -1588,11 +1581,14 @@ module_dir(PyObject *self, PyObject *args) if (dict != NULL) { if (PyDict_Check(dict)) { - PyObject *dirfunc = PyDict_GetItemWithError(dict, &_Py_ID(__dir__)); - if (dirfunc) { + PyObject *dirfunc; + int rc = module_get_resolved_dict_item( + dict, &_Py_ID(__dir__), &dirfunc); + if (rc > 0) { result = _PyObject_CallNoArgs(dirfunc); + Py_DECREF(dirfunc); } - else if (!PyErr_Occurred()) { + else if (rc == 0) { result = PyDict_Keys(dict); } } diff --git a/Objects/namespaceobject.c b/Objects/namespaceobject.c index 3803c41027dd854..6d5fced0ed73b35 100644 --- a/Objects/namespaceobject.c +++ b/Objects/namespaceobject.c @@ -4,6 +4,11 @@ #include "pycore_modsupport.h" // _PyArg_NoPositional() #include "pycore_namespace.h" // _PyNamespace_Type +/*[clinic input] +class namespace "_PyNamespaceObject *" "&_PyNamespace_Type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=0c19150c7306c8cf]*/ + #include // offsetof() @@ -15,6 +20,8 @@ typedef struct { #define _PyNamespace_CAST(op) _Py_CAST(_PyNamespaceObject*, (op)) #define _PyNamespace_Check(op) PyObject_TypeCheck((op), &_PyNamespace_Type) +#include "clinic/namespaceobject.c.h" + static PyMemberDef namespace_members[] = { {"__dict__", _Py_T_OBJECT, offsetof(_PyNamespaceObject, ns_dict), Py_READONLY}, @@ -224,13 +231,18 @@ namespace_reduce(PyObject *op, PyObject *Py_UNUSED(ignored)) } +/*[clinic input] +namespace.__replace__ + + **changes: dict + +Return a copy with the specified attributes replaced. +[clinic start generated code]*/ + static PyObject * -namespace_replace(PyObject *self, PyObject *args, PyObject *kwargs) +namespace___replace___impl(_PyNamespaceObject *self, PyObject *changes) +/*[clinic end generated code: output=16bc56d7900c95ba input=c34d09667d34e300]*/ { - if (!_PyArg_NoPositional("__replace__", args)) { - return NULL; - } - PyObject *result = PyObject_CallNoArgs((PyObject *)Py_TYPE(self)); if (!result) { return NULL; @@ -249,11 +261,11 @@ namespace_replace(PyObject *self, PyObject *args, PyObject *kwargs) Py_DECREF(result); return NULL; } - if (kwargs) { - if (PyDict_Update(((_PyNamespaceObject*)result)->ns_dict, kwargs) < 0) { - Py_DECREF(result); - return NULL; - } + if (changes != NULL + && PyDict_Update(((_PyNamespaceObject*)result)->ns_dict, changes) < 0) + { + Py_DECREF(result); + return NULL; } return result; } @@ -262,9 +274,7 @@ namespace_replace(PyObject *self, PyObject *args, PyObject *kwargs) static PyMethodDef namespace_methods[] = { {"__reduce__", namespace_reduce, METH_NOARGS, namespace_reduce__doc__}, - {"__replace__", _PyCFunction_CAST(namespace_replace), METH_VARARGS|METH_KEYWORDS, - PyDoc_STR("__replace__($self, /, **changes)\n--\n\n" - "Return a copy of the namespace object with new values for the specified attributes.")}, + NAMESPACE___REPLACE___METHODDEF {NULL, NULL} // sentinel }; diff --git a/Objects/object.c b/Objects/object.c index bd23c2e23881949..1589e3523e62053 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -198,10 +198,11 @@ refchain_init(PyInterpreterState *interp) return 0; } _Py_hashtable_allocator_t alloc = { - // Don't use default PyMem_Malloc() and PyMem_Free() which - // require the caller to hold the GIL. - .malloc = PyMem_RawMalloc, - .free = PyMem_RawFree, + // Use directly malloc() and free() of the C library. Using + // PyMem_RawMalloc() and PyMem_RawFree() prevents testing + // _testcapi.set_nomemory(). + .malloc = malloc, + .free = free, }; REFCHAIN(interp) = _Py_hashtable_new_full( _Py_hashtable_hash_ptr, _Py_hashtable_compare_direct, @@ -467,7 +468,12 @@ _Py_MergeZeroLocalRefcount(PyObject *op) Py_ssize_t _Py_ExplicitMergeRefcount(PyObject *op, Py_ssize_t extra) { - assert(!_Py_IsImmortal(op)); + if (_Py_IsImmortal(op)) { + // The object may have become immortal after it was queued to be + // merged (for example, by sys.intern()). There is nothing to merge + // and the reference total no longer includes the object. + return _Py_IMMORTAL_INITIAL_REFCNT; + } #ifdef Py_REF_DEBUG _Py_AddRefTotal(_PyThreadState_GET(), extra); @@ -582,13 +588,13 @@ PyObject_CallFinalizer(PyObject *self) if (tp->tp_finalize == NULL) return; /* tp_finalize should only be called once. */ - if (_PyType_IS_GC(tp) && _PyGC_FINALIZED(self)) - return; - - tp->tp_finalize(self); if (_PyType_IS_GC(tp)) { + if (_PyGC_FINALIZED(self)) + return; + _PyGC_SET_FINALIZED(self); } + tp->tp_finalize(self); } int @@ -955,6 +961,7 @@ _PyObject_ClearFreeLists(struct _Py_freelists *freelists, int is_finalization) clear_freelist(&freelists->pycfunctionobject, is_finalization, PyObject_GC_Del); clear_freelist(&freelists->pycmethodobject, is_finalization, PyObject_GC_Del); clear_freelist(&freelists->pymethodobjects, is_finalization, free_object); + clear_freelist(&freelists->tracebacks, is_finalization, PyObject_GC_Del); } /* @@ -1923,6 +1930,19 @@ _PyObject_GenericGetAttrWithDict(PyObject *obj, PyObject *name, if (descr != NULL) { f = Py_TYPE(descr)->tp_descr_get; if (f != NULL && PyDescr_IsData(descr)) { + // gh-157840: We special-case member descriptors here to avoid + // allocating an extra AttributeError + if (suppress && Py_IS_TYPE(descr, &PyMemberDescr_Type)) { + PyMemberDef *member = ((PyMemberDescrObject *)descr)->d_member; + if (member->type == Py_T_OBJECT_EX + && !(member->flags & Py_AUDIT_READ) + && PyObject_TypeCheck(obj, PyDescr_TYPE(descr))) { + PyObject **addr = _PyMember_GetOffset(obj, member); + if (FT_ATOMIC_LOAD_PTR(*addr) == NULL) { + goto done; + } + } + } res = f(descr, obj, (PyObject *)Py_TYPE(obj)); if (res == NULL && suppress && PyErr_ExceptionMatches(PyExc_AttributeError)) { @@ -2519,7 +2539,6 @@ _PyObject_FiniState(PyInterpreterState *interp) } -extern PyTypeObject _PyAnextAwaitable_Type; extern PyTypeObject _PyLegacyEventHandler_Type; extern PyTypeObject _PyLineIterator; extern PyTypeObject _PyMemoryIter_Type; @@ -2612,7 +2631,6 @@ static PyTypeObject* static_types[_Py_NUM_MANAGED_PREINITIALIZED_TYPES] = { &PyWrapperDescr_Type, &PyZip_Type, &Py_GenericAliasType, - &_PyAnextAwaitable_Type, &_PyAsyncGenASend_Type, &_PyAsyncGenAThrow_Type, &_PyAsyncGenWrappedValue_Type, @@ -3224,6 +3242,10 @@ _PyTrash_thread_destroy_chain(PyThreadState *tstate) * up distorting allocation statistics. */ _PyObject_ASSERT(op, Py_REFCNT(op) == 0); +#ifdef Py_TRACE_REFS + _Py_ForgetReference(op); +#endif + _PyReftracerTrack(op, PyRefTracer_DESTROY); (*dealloc)(op); } } @@ -3286,19 +3308,26 @@ next" object in the chain to 0. This can easily lead to stack overflows. To avoid that, if the C stack is nearing its limit, instead of calling dealloc on the object, it is added to a queue to be freed later when the stack is shallower */ -void -_Py_Dealloc(PyObject *op) +static Py_NO_INLINE void +py_dealloc(PyObject *op) { PyTypeObject *type = Py_TYPE(op); unsigned long gc_flag = type->tp_flags & Py_TPFLAGS_HAVE_GC; destructor dealloc = type->tp_dealloc; - PyThreadState *tstate = _PyThreadState_GET(); - intptr_t margin = _Py_RecursionLimit_GetMargin(tstate); - if (margin < 2 && gc_flag) { - _PyTrash_thread_deposit_object(tstate, (PyObject *)op); - return; + PyThreadState *tstate = NULL; + intptr_t margin = 0; + if (gc_flag) { + tstate = _PyThreadState_GET(); + margin = _Py_RecursionLimit_GetMargin(tstate); + if (margin < 2) { + _PyTrash_thread_deposit_object(tstate, (PyObject *)op); + return; + } } #ifdef Py_DEBUG + if (tstate == NULL) { + tstate = _PyThreadState_GET(); + } #if !defined(Py_GIL_DISABLED) && !defined(Py_STACKREF_DEBUG) /* This assertion doesn't hold for the free-threading build, as * PyStackRef_CLOSE_SPECIALIZED is not implemented */ @@ -3340,11 +3369,33 @@ _Py_Dealloc(PyObject *op) Py_XDECREF(old_exc); Py_DECREF(type); #endif - if (tstate->delete_later && margin >= 4 && gc_flag) { + if (gc_flag && tstate->delete_later && margin >= 4) { _PyTrash_thread_destroy_chain(tstate); } } +/* + * gh-130706: Keep the GC/reftracer path in the non-inlined py_dealloc(). + * Inlining it makes the compiler save callee-saved registers at entry, + * so the non-GC objects path would have unnecessary register spills. + */ +void +_Py_Dealloc(PyObject *op) +{ +#if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) + // gh-130706: Avoid unnecessary register spills for non-GC objects. + PyTypeObject *type = Py_TYPE(op); + if (_PyRuntime.ref_tracer.tracer_func == NULL + && !(type->tp_flags & Py_TPFLAGS_HAVE_GC)) + { + type->tp_dealloc(op); + return; + } +#endif + // GC objects (trashcan), reftracer set, or debug builds. + py_dealloc(op); +} + PyObject ** PyObject_GET_WEAKREFS_LISTPTR(PyObject *op) @@ -3450,7 +3501,7 @@ _Py_GetConstant_Init(void) constants[Py_CONSTANT_ZERO] = _PyLong_GetZero(); constants[Py_CONSTANT_ONE] = _PyLong_GetOne(); constants[Py_CONSTANT_EMPTY_STR] = PyUnicode_New(0, 0); - constants[Py_CONSTANT_EMPTY_BYTES] = PyBytes_FromStringAndSize(NULL, 0); + constants[Py_CONSTANT_EMPTY_BYTES] = PyBytes_FromStringAndSize("", 0); constants[Py_CONSTANT_EMPTY_TUPLE] = PyTuple_New(0); #ifndef NDEBUG for (size_t i=0; i < Py_ARRAY_LENGTH(constants); i++) { diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index 0947d47c8a55582..66931dc396fa95a 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -1,6 +1,7 @@ /* Python's malloc wrappers (see pymem.h) */ #include "Python.h" +#include "pycore_ceval.h" #include "pycore_interp.h" // _PyInterpreterState_HasFeature #include "pycore_mmap.h" // _PyAnnotateMemoryMap() #include "pycore_object.h" // _PyDebugAllocatorStats() definition @@ -212,7 +213,10 @@ _PyMem_mi_page_reclaimed(mi_page_t *page) if (mi_page_all_free(page)) { assert(page->qsbr_node.next == NULL); _PyThreadStateImpl *tstate = tstate_from_heap(mi_page_heap(page)); - assert(tstate == (_PyThreadStateImpl *)_PyThreadState_GET()); + // gh-159462: the owning tstate may differ from the current + // one, but the heap is always owned by the current OS thread, + // so the page list is not shared with other OS threads. + assert(mi_page_heap(page)->thread_id == _Py_ThreadId()); page->retire_expire = 0; llist_insert_tail(&tstate->mimalloc.page_list, &page->qsbr_node); } @@ -433,6 +437,12 @@ void* _PyObject_Realloc(void *ctx, void *ptr, size_t size); # define PYRAW_ALLOC MIMALLOC_RAWALLOC # define PYMEM_ALLOC MIMALLOC_ALLOC # define PYOBJ_ALLOC MIMALLOC_OBJALLOC +#elif defined(_Py_ADDRESS_SANITIZER) || defined(_Py_MEMORY_SANITIZER) +// ASan and MSan do not track pymalloc blocks, so use malloc by default. +// pymalloc can still be selected at runtime. +# define PYRAW_ALLOC MALLOC_ALLOC +# define PYMEM_ALLOC MALLOC_ALLOC +# define PYOBJ_ALLOC MALLOC_ALLOC #elif defined(WITH_PYMALLOC) # define PYRAW_ALLOC MALLOC_ALLOC # define PYMEM_ALLOC PYMALLOC_ALLOC @@ -1378,6 +1388,10 @@ free_work_item(uintptr_t ptr, delayed_dealloc_cb cb, void *state) return; } assert(_PyInterpreterState_GET()->stoptheworld.world_stopped); + if (_Py_IsImmortal(obj)) { + // The object may have become immortal after it was queued. + return; + } Py_ssize_t refcount = _Py_ExplicitMergeRefcount(obj, -1); if (refcount == 0) { cb(obj, state); @@ -1411,7 +1425,7 @@ should_advance_qsbr_for_free(struct _qsbr_thread_state *qsbr, size_t size) if (size > QSBR_FREE_MEM_LIMIT) { qsbr->deferred_count = 0; qsbr->deferred_memory = 0; - qsbr->should_process = true; + _Py_set_eval_breaker_bit(qsbr->tstate, _PY_EVAL_PROCESS_DELAYED_BIT); return true; } qsbr->deferred_count++; @@ -1420,7 +1434,7 @@ should_advance_qsbr_for_free(struct _qsbr_thread_state *qsbr, size_t size) qsbr->deferred_memory > QSBR_FREE_MEM_LIMIT) { qsbr->deferred_count = 0; qsbr->deferred_memory = 0; - qsbr->should_process = true; + _Py_set_eval_breaker_bit(qsbr->tstate, _PY_EVAL_PROCESS_DELAYED_BIT); return true; } return false; @@ -1470,9 +1484,11 @@ free_delayed(uintptr_t ptr, size_t size) _PyEval_StopTheWorld(tstate->base.interp); if (work_item_should_decref(ptr)) { PyObject *obj = (PyObject *)(ptr - 1); - Py_ssize_t refcount = _Py_ExplicitMergeRefcount(obj, -1); - if (refcount == 0) { - to_dealloc = obj; + if (!_Py_IsImmortal(obj)) { + Py_ssize_t refcount = _Py_ExplicitMergeRefcount(obj, -1); + if (refcount == 0) { + to_dealloc = obj; + } } } else { @@ -1496,13 +1512,6 @@ free_delayed(uintptr_t ptr, size_t size) buf->array[buf->wr_idx].ptr = ptr; buf->array[buf->wr_idx].qsbr_goal = seq; buf->wr_idx++; - - if (buf->wr_idx == WORK_ITEMS_PER_CHUNK) { - // Normally the processing of delayed items is done from the eval - // breaker. Processing here is a safety measure to ensure too much - // work does not accumulate. - _PyMem_ProcessDelayed((PyThreadState *)tstate); - } #endif } @@ -1520,7 +1529,7 @@ void _PyObject_XDecRefDelayed(PyObject *ptr) { assert(!((uintptr_t)ptr & 0x01)); - if (ptr != NULL) { + if (ptr != NULL && !_Py_IsImmortal(ptr)) { // We use 0 as the size since we don't have an easy way to know the // actual size. If we are freeing many objects, the write sequence // will be advanced due to QSBR_DEFERRED_LIMIT. @@ -1535,12 +1544,7 @@ _PyObject_XSetRefDelayed(PyObject **ptr, PyObject *value) { PyObject *old = *ptr; FT_ATOMIC_STORE_PTR_RELEASE(*ptr, value); - if (old == NULL) { - return; - } - if (!_Py_IsImmortal(old)) { - _PyObject_XDecRefDelayed(old); - } + _PyObject_XDecRefDelayed(old); } #endif @@ -1615,7 +1619,7 @@ _PyMem_ProcessDelayed(PyThreadState *tstate) PyInterpreterState *interp = tstate->interp; _PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate; - tstate_impl->qsbr->should_process = false; + _Py_unset_eval_breaker_bit(tstate, _PY_EVAL_PROCESS_DELAYED_BIT); // Process thread-local work process_queue(&tstate_impl->mem_free_queue, tstate_impl, true, NULL, NULL); @@ -1817,10 +1821,10 @@ get_mimalloc_allocated_blocks(PyInterpreterState *interp) } } - mi_abandoned_pool_t *pool = &interp->mimalloc.abandoned_pool; - for (uint8_t tag = 0; tag < _Py_MIMALLOC_HEAP_COUNT; tag++) { - _mi_abandoned_pool_visit_blocks(pool, tag, false, &count_blocks, - &allocated_blocks); + mi_subproc_t *subproc = interp->mimalloc.subproc; + for (int tag = 0; tag < _Py_MIMALLOC_HEAP_COUNT; tag++) { + mi_abandoned_visit_blocks(subproc, tag, false, &count_blocks, + &allocated_blocks); } #else // TODO(sgross): this only counts the current thread's blocks. @@ -3255,10 +3259,10 @@ _PyMem_DebugRawRealloc(void *ctx, void *p, size_t nbytes) } else { size_t i = original_nbytes - ERASED_SIZE; - memcpy(data, save, Py_MIN(nbytes, ERASED_SIZE)); + memcpy(data, save, Py_MIN(nbytes, (size_t)ERASED_SIZE)); if (nbytes > i) { memcpy(data + i, &save[ERASED_SIZE], - Py_MIN(nbytes - i, ERASED_SIZE)); + Py_MIN(nbytes - i, (size_t)ERASED_SIZE)); } } #endif diff --git a/Objects/odictobject.c b/Objects/odictobject.c index c51fd4b7195da42..4b3b3237e82476b 100644 --- a/Objects/odictobject.c +++ b/Objects/odictobject.c @@ -478,8 +478,9 @@ Potential Optimizations /*[clinic input] class OrderedDict "PyODictObject *" "&PyODict_Type" +class odictiter "PyObject *" "&PyODictIter_Type" [clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=ca0641cf6143d4af]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=ae5599eeb14d29ae]*/ typedef struct _odictnode _ODictNode; @@ -1804,10 +1805,16 @@ odictiter_nextkey(odictiterobject *di) return res; } +/*[clinic input] +@critical_section +odictiter.__next__ as odictiter_iternext +[clinic start generated code]*/ + static PyObject * -odictiter_iternext_lock_held(PyObject *op) +odictiter_iternext_impl(PyObject *self) +/*[clinic end generated code: output=71aef8eec9e1a133 input=bc8bec6c85481b93]*/ { - odictiterobject *di = (odictiterobject*)op; + odictiterobject *di = (odictiterobject*)self; PyObject *result, *value; PyObject *key = odictiter_nextkey(di); /* new reference */ @@ -1862,16 +1869,6 @@ odictiter_iternext_lock_held(PyObject *op) return NULL; } -static PyObject * -odictiter_iternext(PyObject *op) -{ - PyObject *res; - Py_BEGIN_CRITICAL_SECTION(op); - res = odictiter_iternext_lock_held(op); - Py_END_CRITICAL_SECTION(); - return res; -} - /* No need for tp_clear because odictiterobject is not mutable. */ @@ -1941,28 +1938,29 @@ odictiter_new(PyODictObject *od, int kind) odictiterobject *di; _ODictNode *node; int reversed = kind & _odict_ITER_REVERSED; - - di = PyObject_GC_New(odictiterobject, &PyODictIter_Type); - if (di == NULL) - return NULL; + PyObject *result = NULL; if ((kind & _odict_ITER_ITEMS) == _odict_ITER_ITEMS) { - di->di_result = _PyTuple_FromPairSteal(Py_None, Py_None); - if (di->di_result == NULL) { - Py_DECREF(di); + result = _PyTuple_FromPairSteal(Py_None, Py_None); + if (result == NULL) { return NULL; } } - else { - di->di_result = NULL; + di = PyObject_GC_New(odictiterobject, &PyODictIter_Type); + if (di == NULL) { + Py_XDECREF(result); + return NULL; } + di->di_result = result; di->kind = kind; + Py_BEGIN_CRITICAL_SECTION(od); node = reversed ? _odict_LAST(od) : _odict_FIRST(od); di->di_current = node ? Py_NewRef(_odictnode_KEY(node)) : NULL; di->di_size = PyODict_SIZE(od); di->di_state = od->od_state; di->di_odict = (PyODictObject*)Py_NewRef(od); + Py_END_CRITICAL_SECTION(); _PyObject_GC_TRACK(di); return (PyObject *)di; diff --git a/Objects/picklebufobject.c b/Objects/picklebufobject.c index 50f17687bc43650..18cfe9f9f645943 100644 --- a/Objects/picklebufobject.c +++ b/Objects/picklebufobject.c @@ -4,6 +4,18 @@ #include "pycore_weakref.h" // FT_CLEAR_WEAKREFS() #include +#include "clinic/picklebufobject.c.h" + +/*[clinic input] +module pickle +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=6165c351cde067ba]*/ + +/*[clinic input] +class pickle.PickleBuffer "PyPickleBufferObject *" "&PyPickleBuffer_Type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b334ecd891c9cbc2]*/ + typedef struct { PyObject_HEAD /* The view exported by the original object */ @@ -66,19 +78,22 @@ PyPickleBuffer_Release(PyObject *obj) return 0; } -static PyObject * -picklebuf_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyPickleBufferObject *self; - PyObject *base; - char *keywords[] = {"", NULL}; +/*[clinic input] +@vectorcall +@classmethod +pickle.PickleBuffer.__new__ as picklebuf_new - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:PickleBuffer", - keywords, &base)) { - return NULL; - } + buffer as base: object + / - self = (PyPickleBufferObject *) type->tp_alloc(type, 0); +Wrapper for potentially out-of-band buffers. +[clinic start generated code]*/ + +static PyObject * +picklebuf_new_impl(PyTypeObject *type, PyObject *base) +/*[clinic end generated code: output=b8269110aace6998 input=616fff5fc36c22d4]*/ +{ + PyPickleBufferObject *self = (PyPickleBufferObject *) type->tp_alloc(type, 0); if (self == NULL) { return NULL; } @@ -211,10 +226,11 @@ static PyMethodDef picklebuf_methods[] = { PyTypeObject PyPickleBuffer_Type = { PyVarObject_HEAD_INIT(NULL, 0) .tp_name = "pickle.PickleBuffer", - .tp_doc = PyDoc_STR("Wrapper for potentially out-of-band buffers"), + .tp_doc = picklebuf_new__doc__, .tp_basicsize = sizeof(PyPickleBufferObject), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, .tp_new = picklebuf_new, + .tp_vectorcall = picklebuf_vectorcall, .tp_dealloc = picklebuf_dealloc, .tp_traverse = picklebuf_traverse, .tp_clear = picklebuf_clear, diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index 55b7f108730728d..f9347e9563961be 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -259,6 +259,14 @@ compute_range_length(PyObject *start, PyObject *stop, PyObject *step) assert(PyLong_Check(stop)); assert(PyLong_Check(step)); + /* fast path for start == 0 and step == 1: length is max(stop, 0) */ + if (start == zero && step == one) { + if (_PyLong_IsPositive((const PyLongObject *)stop)) { + return Py_NewRef(stop); + } + return zero; + } + /* fast path when all arguments fit into a long integer */ long len = compute_range_length_long(start, stop, step); if (len >= 0) { @@ -1158,10 +1166,16 @@ longrangeiter_dealloc(PyObject *op) PyObject_Free(r); } +/*[clinic input] +@critical_section +longrange_iterator.__next__ as longrangeiter_next +[clinic start generated code]*/ + static PyObject * -longrangeiter_next_lock_held(PyObject *op) +longrangeiter_next_impl(longrangeiterobject *self) +/*[clinic end generated code: output=49bf9a9b89c07ba5 input=2c4ac537c23a92d3]*/ { - longrangeiterobject *r = (longrangeiterobject*)op; + longrangeiterobject *r = self; if (PyObject_RichCompareBool(r->len, _PyLong_GetZero(), Py_GT) != 1) return NULL; @@ -1180,16 +1194,6 @@ longrangeiter_next_lock_held(PyObject *op) return result; } -static PyObject * -longrangeiter_next(PyObject *op) -{ - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(op); - result = longrangeiter_next_lock_held(op); - Py_END_CRITICAL_SECTION(); - return result; -} - PyTypeObject PyLongRangeIter_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "longrange_iterator", /* tp_name */ diff --git a/Objects/setobject.c b/Objects/setobject.c index 8fdd1eb26118c0a..6ba6e611d9448dc 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -753,8 +753,16 @@ set_dealloc(PyObject *self) Py_TYPE(so)->tp_free(so); } +/*[clinic input] +@critical_section +set.__repr__ + + so: setobject +[clinic start generated code]*/ + static PyObject * -set_repr_lock_held(PySetObject *so) +set_repr_impl(PySetObject *so) +/*[clinic end generated code: output=5dfbb5e7f7c947ad input=f6743ec76163d7b3]*/ { PyObject *result=NULL, *keys, *listrepr, *tmp; int status = Py_ReprEnter((PyObject*)so); @@ -807,17 +815,6 @@ set_repr_lock_held(PySetObject *so) return result; } -static PyObject * -set_repr(PyObject *self) -{ - PySetObject *so = _PySet_CAST(self); - PyObject *result; - Py_BEGIN_CRITICAL_SECTION(so); - result = set_repr_lock_held(so); - Py_END_CRITICAL_SECTION(); - return result; -} - static Py_ssize_t set_len(PyObject *self) { @@ -1030,7 +1027,10 @@ frozenset_hash(PyObject *self) typedef struct { PyObject_HEAD - PySetObject *si_set; /* Set to NULL when iterator is exhausted */ + /* Set to NULL when the iterator is exhausted, except in the free-threaded + build, where the reference is kept until the iterator is deallocated + (see setiter_set_exhausted()). */ + PySetObject *si_set; Py_ssize_t si_used; Py_ssize_t si_pos; Py_ssize_t len; @@ -1059,8 +1059,14 @@ setiter_len(PyObject *op, PyObject *Py_UNUSED(ignored)) { setiterobject *si = (setiterobject*)op; Py_ssize_t len = 0; - if (si->si_set != NULL && si->si_used == si->si_set->used) - len = si->len; + PySetObject *so = si->si_set; + if (so != NULL) { + Py_ssize_t so_used = FT_ATOMIC_LOAD_SSIZE_RELAXED(so->used); + Py_ssize_t si_used = FT_ATOMIC_LOAD_SSIZE_RELAXED(si->si_used); + if (si_used == so_used) { + len = FT_ATOMIC_LOAD_SSIZE_RELAXED(si->len); + } + } return PyLong_FromSsize_t(len); } @@ -1092,6 +1098,25 @@ static PyMethodDef setiter_methods[] = { {NULL, NULL} /* sentinel */ }; +/* Mark the iterator as exhausted. In the free-threaded build an iterator + may be advanced by several threads at once, each holding a borrowed + pointer to si_set, so the iterator keeps its reference to the set until + it is deallocated (as list and tuple iterators do) and records exhaustion + by setting si_pos to SETITER_EXHAUSTED. */ +#define SETITER_EXHAUSTED (-1) + +static void +setiter_set_exhausted(setiterobject *si, PySetObject *so) +{ +#ifdef Py_GIL_DISABLED + FT_ATOMIC_STORE_SSIZE_RELAXED(si->si_pos, SETITER_EXHAUSTED); + FT_ATOMIC_STORE_SSIZE_RELAXED(si->len, 0); +#else + si->si_set = NULL; + Py_DECREF(so); +#endif +} + static PyObject *setiter_iternext(PyObject *self) { setiterobject *si = (setiterobject*)self; @@ -1104,34 +1129,43 @@ static PyObject *setiter_iternext(PyObject *self) return NULL; assert (PyAnySet_Check(so)); +#ifdef Py_GIL_DISABLED + if (FT_ATOMIC_LOAD_SSIZE_RELAXED(si->si_pos) == SETITER_EXHAUSTED) { + return NULL; + } +#endif + Py_ssize_t so_used = FT_ATOMIC_LOAD_SSIZE_RELAXED(so->used); Py_ssize_t si_used = FT_ATOMIC_LOAD_SSIZE_RELAXED(si->si_used); if (si_used != so_used) { PyErr_SetString(PyExc_RuntimeError, "Set changed size during iteration"); - si->si_used = -1; /* Make this state sticky */ + /* Make this state sticky */ + FT_ATOMIC_STORE_SSIZE_RELAXED(si->si_used, -1); return NULL; } + /* si_pos and len are only written with the set locked, so that an + iterator marked as exhausted by another thread stays exhausted. */ Py_BEGIN_CRITICAL_SECTION(so); i = si->si_pos; - assert(i>=0); - entry = so->table; - mask = so->mask; - while (i <= mask && (entry[i].key == NULL || entry[i].key == dummy)) { - i++; - } - if (i <= mask) { - key = Py_NewRef(entry[i].key); + if (i != SETITER_EXHAUSTED) { + assert(i >= 0); + entry = so->table; + mask = so->mask; + while (i <= mask && (entry[i].key == NULL || entry[i].key == dummy)) { + i++; + } + if (i <= mask) { + key = Py_NewRef(entry[i].key); + FT_ATOMIC_STORE_SSIZE_RELAXED(si->si_pos, i + 1); + FT_ATOMIC_STORE_SSIZE_RELAXED(si->len, si->len - 1); + } + else { + setiter_set_exhausted(si, so); + } } Py_END_CRITICAL_SECTION(); - si->si_pos = i+1; - if (key == NULL) { - si->si_set = NULL; - Py_DECREF(so); - return NULL; - } - si->len--; return key; } @@ -1351,19 +1385,20 @@ static PyObject * make_new_set_untracked(PyTypeObject *type, PyObject *iterable) { assert(PyType_Check(type)); - PySetObject *so; - so = (PySetObject *)_PyType_AllocNoTrack(type, 0); - if (so == NULL) + // fields are zero-initialized by _PyType_AllocNoTrack + PySetObject *so = (PySetObject *)_PyType_AllocNoTrack(type, 0); + if (so == NULL) { return NULL; + } - so->fill = 0; - so->used = 0; + assert(so->fill == 0); + assert(so->used == 0); so->mask = PySet_MINSIZE - 1; so->table = so->smalltable; so->hash = -1; - so->finger = 0; - so->weakreflist = NULL; + assert(so->finger == 0); + assert(so->weakreflist == NULL); if (iterable != NULL) { if (set_update_local(so, iterable)) { @@ -1574,6 +1609,7 @@ _PySet_Freeze(PyObject *set) assert(PySet_CheckExact(set)); assert(_PyObject_IsUniquelyReferenced(set)); set->ob_type = &PyFrozenSet_Type; + _PyFrozenSet_MaybeUntrack(set); return Py_NewRef(set); } diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c index 91d1753b822fc13..5ab7e42d9e7b76e 100644 --- a/Objects/sliceobject.c +++ b/Objects/sliceobject.c @@ -21,6 +21,13 @@ this type and there is exactly one in existence. #include "pycore_object.h" // _PyObject_GC_TRACK() #include "pycore_sliceobject.h" // _PyBuildSlice_ConsumeRefs +#include "clinic/sliceobject.c.h" + +/*[clinic input] +class slice "PySliceObject *" "&PySlice_Type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=857b514967456ef4]*/ + #define _PySlice_CAST(op) _Py_CAST(PySliceObject*, (op)) @@ -308,19 +315,22 @@ PySlice_GetIndicesEx(PyObject *_r, Py_ssize_t length, return 0; } -static PyObject * -slice_new(PyTypeObject *type, PyObject *args, PyObject *kw) -{ - PyObject *start, *stop, *step; +/*[clinic input] +@classmethod +@vectorcall +slice.__new__ as slice_new - start = stop = step = NULL; - - if (!_PyArg_NoKeywords("slice", kw)) - return NULL; - - if (!PyArg_UnpackTuple(args, "slice", 1, 3, &start, &stop, &step)) - return NULL; + start: object + stop: object(c_default="NULL") = None + step: object(c_default="NULL") = None + / +[clinic start generated code]*/ +static PyObject * +slice_new_impl(PyTypeObject *type, PyObject *start, PyObject *stop, + PyObject *step) +/*[clinic end generated code: output=35a6e86397efb677 input=cf5c572a0d2caa22]*/ +{ /* This swapping of stop and start is to maintain similarity with range(). */ if (stop == NULL) { @@ -702,4 +712,5 @@ PyTypeObject PySlice_Type = { 0, /* tp_init */ 0, /* tp_alloc */ slice_new, /* tp_new */ + .tp_vectorcall = slice_vectorcall, }; diff --git a/Objects/stringlib/codecs.h b/Objects/stringlib/codecs.h index 9e53fab842909a0..aa3de5e34eaaae0 100644 --- a/Objects/stringlib/codecs.h +++ b/Objects/stringlib/codecs.h @@ -350,8 +350,6 @@ STRINGLIB(utf8_encoder)(PyObject *unicode, break; case _Py_ERROR_BACKSLASHREPLACE: - /* subtract preallocated bytes */ - writer->size -= max_char_size * (endpos - startpos); p = backslashreplace(writer, p, unicode, startpos, endpos); if (p == NULL) @@ -360,8 +358,6 @@ STRINGLIB(utf8_encoder)(PyObject *unicode, break; case _Py_ERROR_XMLCHARREFREPLACE: - /* subtract preallocated bytes */ - writer->size -= max_char_size * (endpos - startpos); p = xmlcharrefreplace(writer, p, unicode, startpos, endpos); if (p == NULL) @@ -400,13 +396,18 @@ STRINGLIB(utf8_encoder)(PyObject *unicode, } } else { - /* subtract preallocated bytes */ - writer->size -= max_char_size * (newpos - startpos); /* Only overallocate the buffer if it's not the last write */ writer->overallocate = (newpos < size); + + /* subtract preallocated bytes */ + Py_ssize_t prealloc = max_char_size * (newpos - startpos); + p = PyBytesWriter_GrowAndUpdatePointer(writer, -prealloc, p); + if (p == NULL) { + goto error; + } } - char *rep_str; + const char *rep_str; Py_ssize_t rep_len; if (PyBytes_Check(rep)) { rep_str = PyBytes_AS_STRING(rep); diff --git a/Objects/stringlib/find_max_char.h b/Objects/stringlib/find_max_char.h index 7ab3fc88b331b14..8c7da7b7fad38ee 100644 --- a/Objects/stringlib/find_max_char.h +++ b/Objects/stringlib/find_max_char.h @@ -5,123 +5,157 @@ # error "find_max_char.h is specific to Unicode" #endif -/* Mask to quickly check whether a C 'size_t' contains a - non-ASCII, UTF8-encoded char. */ -#if (SIZEOF_SIZE_T == 8) -# define UCS1_ASCII_CHAR_MASK 0x8080808080808080ULL -#elif (SIZEOF_SIZE_T == 4) -# define UCS1_ASCII_CHAR_MASK 0x80808080U -#else -# error C 'size_t' size should be either 4 or 8! -#endif +#define MAX_CHAR_ASCII 0x7f +#define MAX_CHAR_UCS1 0xff +#define MAX_CHAR_UCS2 0xffff +#define MAX_CHAR_UCS4 0x10ffff +/* Masks selecting the bits that are set in a C 'size_t' holding several + characters when at least one of them is wider than ASCII, UCS1 or UCS2. */ #if STRINGLIB_SIZEOF_CHAR == 1 +# if SIZEOF_SIZE_T == 8 +# define MASK_ASCII 0x8080808080808080ULL +# elif SIZEOF_SIZE_T == 4 +# define MASK_ASCII 0x80808080U +# else +# error C 'size_t' size should be either 4 or 8! +# endif +# define MASK_MAX_CHAR MASK_ASCII +# define MAX_CHAR MAX_CHAR_UCS1 +#elif STRINGLIB_SIZEOF_CHAR == 2 +# if SIZEOF_SIZE_T == 8 +# define MASK_ASCII 0xFF80FF80FF80FF80ULL +# define MASK_UCS1 0xFF00FF00FF00FF00ULL +# elif SIZEOF_SIZE_T == 4 +# define MASK_ASCII 0xFF80FF80U +# define MASK_UCS1 0xFF00FF00U +# else +# error C 'size_t' size should be either 4 or 8! +# endif +# define MASK_MAX_CHAR MASK_UCS1 +# define MAX_CHAR MAX_CHAR_UCS2 +#elif STRINGLIB_SIZEOF_CHAR == 4 +# if SIZEOF_SIZE_T == 8 +# define MASK_ASCII 0xFFFFFF80FFFFFF80ULL +# define MASK_UCS1 0xFFFFFF00FFFFFF00ULL +# define MASK_UCS2 0xFFFF0000FFFF0000ULL +# elif SIZEOF_SIZE_T == 4 +# define MASK_ASCII 0xFFFFFF80U +# define MASK_UCS1 0xFFFFFF00U +# define MASK_UCS2 0xFFFF0000U +# else +# error C 'size_t' size should be either 4 or 8! +# endif +# define MASK_MAX_CHAR MASK_UCS2 +# define MAX_CHAR MAX_CHAR_UCS4 +#else +# error Invalid STRINGLIB_SIZEOF_CHAR (must be 1, 2 or 4) +#endif +/* OR all characters into a single size_t accumulator and test the high bits + at the end, instead of comparing each character. The accumulation loop has + no branches, so compilers vectorize it. The start is first read in pieces + until the pointer is aligned, so the loops can use plain word loads on + every platform. Every 16 words, check whether the widest kind is already + known and exit early. */ Py_LOCAL_INLINE(Py_UCS4) STRINGLIB(find_max_char)(const STRINGLIB_CHAR *begin, const STRINGLIB_CHAR *end) { - const unsigned char *p = (const unsigned char *) begin; + const unsigned char *p = (const unsigned char *)begin; const unsigned char *_end = (const unsigned char *)end; + size_t value = 0; - while (p < _end) { - if (_Py_IS_ALIGNED(p, ALIGNOF_SIZE_T)) { - /* Help register allocation */ - const unsigned char *_p = p; - while (_p + SIZEOF_SIZE_T <= _end) { - size_t value = *(const size_t *) _p; - if (value & UCS1_ASCII_CHAR_MASK) - return 255; - _p += SIZEOF_SIZE_T; + if (p + SIZEOF_SIZE_T <= _end) { + if (!_Py_IS_ALIGNED(p, ALIGNOF_SIZE_T)) { +#if STRINGLIB_SIZEOF_CHAR == 1 + if (!_Py_IS_ALIGNED(p, sizeof(uint16_t))) { + value |= *p++; } - p = _p; - if (p == _end) - break; - } - if (*p++ & 0x80) - return 255; - } - return 127; -} - -#undef ASCII_CHAR_MASK - -#else /* STRINGLIB_SIZEOF_CHAR == 1 */ - -#define MASK_ASCII 0xFFFFFF80 -#define MASK_UCS1 0xFFFFFF00 -#define MASK_UCS2 0xFFFF0000 - -#define MAX_CHAR_ASCII 0x7f -#define MAX_CHAR_UCS1 0xff -#define MAX_CHAR_UCS2 0xffff -#define MAX_CHAR_UCS4 0x10ffff - -Py_LOCAL_INLINE(Py_UCS4) -STRINGLIB(find_max_char)(const STRINGLIB_CHAR *begin, const STRINGLIB_CHAR *end) -{ -#if STRINGLIB_SIZEOF_CHAR == 2 - const Py_UCS4 mask_limit = MASK_UCS1; - const Py_UCS4 max_char_limit = MAX_CHAR_UCS2; -#elif STRINGLIB_SIZEOF_CHAR == 4 - const Py_UCS4 mask_limit = MASK_UCS2; - const Py_UCS4 max_char_limit = MAX_CHAR_UCS4; -#else -#error Invalid STRINGLIB_SIZEOF_CHAR (must be 1, 2 or 4) #endif - Py_UCS4 mask; - Py_ssize_t n = end - begin; - const STRINGLIB_CHAR *p = begin; - const STRINGLIB_CHAR *unrolled_end = begin + _Py_SIZE_ROUND_DOWN(n, 4); - Py_UCS4 max_char; - - max_char = MAX_CHAR_ASCII; - mask = MASK_ASCII; - while (p < unrolled_end) { - STRINGLIB_CHAR bits = p[0] | p[1] | p[2] | p[3]; - if (bits & mask) { - if (mask == mask_limit) { - /* Limit reached */ - return max_char_limit; +#if STRINGLIB_SIZEOF_CHAR <= 2 + if (!_Py_IS_ALIGNED(p, sizeof(uint32_t))) { + value |= *(const uint16_t *)p; + p += sizeof(uint16_t); } - if (mask == MASK_ASCII) { - max_char = MAX_CHAR_UCS1; - mask = MASK_UCS1; +#endif +#if SIZEOF_SIZE_T == 8 + if (!_Py_IS_ALIGNED(p, SIZEOF_SIZE_T)) { + value |= *(const uint32_t *)p; + p += sizeof(uint32_t); } - else { - /* mask can't be MASK_UCS2 because of mask_limit above */ - assert(mask == MASK_UCS1); - max_char = MAX_CHAR_UCS2; - mask = MASK_UCS2; +#endif + if (value & MASK_MAX_CHAR) { + return MAX_CHAR; } - /* We check the new mask on the same chars in the next iteration */ - continue; + assert(_Py_IS_ALIGNED(p, ALIGNOF_SIZE_T)); } - p += 4; - } - while (p < end) { - if (p[0] & mask) { - if (mask == mask_limit) { - /* Limit reached */ - return max_char_limit; - } - if (mask == MASK_ASCII) { - max_char = MAX_CHAR_UCS1; - mask = MASK_UCS1; + + for (; p + SIZEOF_SIZE_T * 16 <= _end; p += SIZEOF_SIZE_T * 16) { + /* Four independent accumulators so the loop does not serialize on + one register when the compiler does not vectorize it. */ + size_t v0 = 0, v1 = 0, v2 = 0, v3 = 0; + for (int i = 0; i < 16 * SIZEOF_SIZE_T; i += 4 * SIZEOF_SIZE_T) { + const size_t *w = (const size_t *)(p + i); + v0 |= w[0]; + v1 |= w[1]; + v2 |= w[2]; + v3 |= w[3]; } - else { - /* mask can't be MASK_UCS2 because of mask_limit above */ - assert(mask == MASK_UCS1); - max_char = MAX_CHAR_UCS2; - mask = MASK_UCS2; + size_t block = v0 | v1 | v2 | v3; + if (block & MASK_MAX_CHAR) { + return MAX_CHAR; } - /* We check the new mask on the same chars in the next iteration */ - continue; + value |= block; + } + + for (; p + SIZEOF_SIZE_T <= _end; p += SIZEOF_SIZE_T) { + value |= *(const size_t *)p; } - p++; } - return max_char; + + /* Fewer than SIZEOF_SIZE_T bytes are left. Read them as two overlapping + pieces, one from each end. OR does not mind seeing a byte twice. */ + if (p < _end) { + size_t n = (size_t)(_end - p); + if (n >= 4) { + uint32_t a, b; + memcpy(&a, p, 4); + memcpy(&b, _end - 4, 4); + value |= a | b; + } +#if STRINGLIB_SIZEOF_CHAR <= 2 + else if (n >= 2) { + uint16_t a, b; + memcpy(&a, p, 2); + memcpy(&b, _end - 2, 2); + value |= a | b; + } +#endif +#if STRINGLIB_SIZEOF_CHAR == 1 + else { + value |= *p; + } +#endif + } + +#ifdef MASK_UCS2 + if (value & MASK_UCS2) { + return MAX_CHAR_UCS4; + } +#endif +#ifdef MASK_UCS1 + if (value & MASK_UCS1) { + return MAX_CHAR_UCS2; + } +#endif + if (value & MASK_ASCII) { + return MAX_CHAR_UCS1; + } + return MAX_CHAR_ASCII; } +#undef MASK_MAX_CHAR +#undef MAX_CHAR #undef MASK_ASCII #undef MASK_UCS1 #undef MASK_UCS2 @@ -129,6 +163,3 @@ STRINGLIB(find_max_char)(const STRINGLIB_CHAR *begin, const STRINGLIB_CHAR *end) #undef MAX_CHAR_UCS1 #undef MAX_CHAR_UCS2 #undef MAX_CHAR_UCS4 - -#endif /* STRINGLIB_SIZEOF_CHAR == 1 */ - diff --git a/Objects/stringlib/join.h b/Objects/stringlib/join.h index fe460d41f6700f8..4764baac181b2ad 100644 --- a/Objects/stringlib/join.h +++ b/Objects/stringlib/join.h @@ -5,7 +5,7 @@ #endif Py_LOCAL_INLINE(PyObject *) -STRINGLIB(bytes_join)(PyObject *sep, PyObject *iterable) +STRINGLIB(bytes_join_lock_held)(PyObject *sep, PyObject *seq) { const char *sepstr = STRINGLIB_STR(sep); Py_ssize_t seplen = STRINGLIB_LEN(sep); @@ -14,7 +14,7 @@ STRINGLIB(bytes_join)(PyObject *sep, PyObject *iterable) Py_ssize_t seqlen = 0; Py_ssize_t sz = 0; Py_ssize_t i, nbufs; - PyObject *seq, *item; + PyObject *item; Py_buffer *buffers = NULL; #define NB_STATIC_BUFFERS 10 Py_buffer static_buffers[NB_STATIC_BUFFERS]; @@ -22,30 +22,21 @@ STRINGLIB(bytes_join)(PyObject *sep, PyObject *iterable) int drop_gil = 1; PyThreadState *save = NULL; - seq = PySequence_Fast(iterable, "can only join an iterable"); - if (seq == NULL) { - return NULL; - } - seqlen = PySequence_Fast_GET_SIZE(seq); if (seqlen == 0) { - Py_DECREF(seq); return STRINGLIB_NEW(NULL, 0); } #if !STRINGLIB_MUTABLE if (seqlen == 1) { item = PySequence_Fast_GET_ITEM(seq, 0); if (STRINGLIB_CHECK_EXACT(item)) { - Py_INCREF(item); - Py_DECREF(seq); - return item; + return Py_NewRef(item); } } #endif if (seqlen > NB_STATIC_BUFFERS) { buffers = PyMem_NEW(Py_buffer, seqlen); if (buffers == NULL) { - Py_DECREF(seq); PyErr_NoMemory(); return NULL; } @@ -134,13 +125,15 @@ STRINGLIB(bytes_join)(PyObject *sep, PyObject *iterable) } } else { - for (i = 0; i < nbufs; i++) { - Py_ssize_t n; - char *q; - if (i) { - memcpy(p, sepstr, seplen); - p += seplen; - } + Py_ssize_t n = buffers[0].len; + char *q = buffers[0].buf; + memcpy(p, q, n); + p += n; + + for (i = 1; i < nbufs; i++) { + memcpy(p, sepstr, seplen); + p += seplen; + n = buffers[i].len; q = buffers[i].buf; memcpy(p, q, n); @@ -155,7 +148,6 @@ STRINGLIB(bytes_join)(PyObject *sep, PyObject *iterable) error: res = NULL; done: - Py_DECREF(seq); for (i = 0; i < nbufs; i++) PyBuffer_Release(&buffers[i]); if (buffers != static_buffers) @@ -163,5 +155,23 @@ STRINGLIB(bytes_join)(PyObject *sep, PyObject *iterable) return res; } +Py_LOCAL_INLINE(PyObject *) +STRINGLIB(bytes_join)(PyObject *sep, PyObject *iterable) +{ + PyObject *seq, *res; + + seq = PySequence_Fast(iterable, "can only join an iterable"); + if (seq == NULL) { + return NULL; + } + + Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST(iterable); + res = STRINGLIB(bytes_join_lock_held)(sep, seq); + Py_END_CRITICAL_SECTION_SEQUENCE_FAST(); + + Py_DECREF(seq); + return res; +} + #undef NB_STATIC_BUFFERS #undef GIL_THRESHOLD diff --git a/Objects/stringlib/split.h b/Objects/stringlib/split.h index 0c11b7214e9b0b8..0b23b6430c8d636 100644 --- a/Objects/stringlib/split.h +++ b/Objects/stringlib/split.h @@ -4,6 +4,8 @@ #error must include "stringlib/fastsearch.h" before including this module #endif +#include "pycore_list.h" // _PyList_AppendTakeRef() + /* Overallocate the initial list to reduce the number of reallocs for small split sizes. Eg, "A A A A A A A A A A".split() (10 elements) has three resizes, to sizes 4, 8, then 16. Most observed string splits are for human @@ -22,12 +24,8 @@ (right) - (left)); \ if (sub == NULL) \ goto onError; \ - if (PyList_Append(list, sub)) { \ - Py_DECREF(sub); \ - goto onError; \ - } \ - else \ - Py_DECREF(sub); + if (_PyList_AppendTakeRef((PyListObject *)list, sub)) \ + goto onError; #define SPLIT_ADD(data, left, right) { \ sub = STRINGLIB_NEW((data) + (left), \ @@ -37,12 +35,8 @@ if (count < MAX_PREALLOC) { \ PyList_SET_ITEM(list, count, sub); \ } else { \ - if (PyList_Append(list, sub)) { \ - Py_DECREF(sub); \ + if (_PyList_AppendTakeRef((PyListObject *)list, sub)) \ goto onError; \ - } \ - else \ - Py_DECREF(sub); \ } \ count++; } diff --git a/Objects/structseq.c b/Objects/structseq.c index 9130fe6a133b1e4..949790e6f416e95 100644 --- a/Objects/structseq.c +++ b/Objects/structseq.c @@ -385,17 +385,21 @@ structseq_reduce(PyObject *op, PyObject *Py_UNUSED(ignored)) } +/*[clinic input] +structseq.__replace__ + + **changes: dict + +Return a copy with new values for the specified fields. +[clinic start generated code]*/ + static PyObject * -structseq_replace(PyObject *op, PyObject *args, PyObject *kwargs) +structseq___replace___impl(PyStructSequence *self, PyObject *changes) +/*[clinic end generated code: output=d90566015d93695f input=bf709d26db77afd6]*/ { - PyStructSequence *self = (PyStructSequence*)op; PyStructSequence *result = NULL; Py_ssize_t n_fields, n_unnamed_fields, i; - if (!_PyArg_NoPositional("__replace__", args)) { - return NULL; - } - n_fields = REAL_SIZE(self); if (n_fields < 0) { return NULL; @@ -417,36 +421,28 @@ structseq_replace(PyObject *op, PyObject *args, PyObject *kwargs) return NULL; } - if (kwargs != NULL) { - // We do not support types with unnamed fields, so we can iterate over - // i >= n_visible_fields case without slicing with (i - n_unnamed_fields). - for (i = 0; i < n_fields; ++i) { - PyObject *ob; - if (PyDict_PopString(kwargs, Py_TYPE(self)->tp_members[i].name, - &ob) < 0) { - goto error; - } - if (ob == NULL) { - ob = Py_NewRef(self->ob_item[i]); - } - result->ob_item[i] = ob; - } - // Check if there are any unexpected fields. - if (PyDict_GET_SIZE(kwargs) > 0) { - PyObject *names = PyDict_Keys(kwargs); - if (names) { - PyErr_Format(PyExc_TypeError, "Got unexpected field name(s): %R", names); - Py_DECREF(names); - } + // We do not support types with unnamed fields, so we can iterate over + // i >= n_visible_fields case without slicing with (i - n_unnamed_fields). + for (i = 0; i < n_fields; ++i) { + PyObject *ob = NULL; + if (changes != NULL + && PyDict_PopString(changes, Py_TYPE(self)->tp_members[i].name, + &ob) < 0) { goto error; } - } - else - { - // Just create a copy of the original. - for (i = 0; i < n_fields; ++i) { - result->ob_item[i] = Py_NewRef(self->ob_item[i]); + if (ob == NULL) { + ob = Py_NewRef(self->ob_item[i]); } + result->ob_item[i] = ob; + } + // Check if there are any unexpected fields. + if (changes != NULL && PyDict_GET_SIZE(changes) > 0) { + PyObject *names = PyDict_Keys(changes); + if (names) { + PyErr_Format(PyExc_TypeError, "Got unexpected field name(s): %R", names); + Py_DECREF(names); + } + goto error; } _PyObject_GC_TRACK(result); @@ -459,9 +455,7 @@ structseq_replace(PyObject *op, PyObject *args, PyObject *kwargs) static PyMethodDef structseq_methods[] = { {"__reduce__", structseq_reduce, METH_NOARGS, NULL}, - {"__replace__", _PyCFunction_CAST(structseq_replace), METH_VARARGS | METH_KEYWORDS, - PyDoc_STR("__replace__($self, /, **changes)\n--\n\n" - "Return a copy of the structure with new values for the specified fields.")}, + STRUCTSEQ___REPLACE___METHODDEF {NULL, NULL} // sentinel }; diff --git a/Objects/templateobject.c b/Objects/templateobject.c index 1609e82b444516c..de7448ae882e143 100644 --- a/Objects/templateobject.c +++ b/Objects/templateobject.c @@ -5,6 +5,13 @@ #include "pycore_runtime.h" // _Py_STR() #include "pycore_template.h" +#include "clinic/templateobject.c.h" + +/*[clinic input] +class Template "templateobject *" "&_PyTemplate_Type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=ee41f8d8c49f0271]*/ + typedef struct { PyObject_HEAD PyObject *stringsiter; @@ -89,21 +96,24 @@ typedef struct { #define templateobject_CAST(op) \ (assert(_PyTemplate_CheckExact(op)), _Py_CAST(templateobject*, (op))) +/*[clinic input] +@vectorcall +@classmethod +Template.__new__ as template_new + *args: array +[clinic start generated code]*/ + static PyObject * -template_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +template_new_impl(PyTypeObject *type, PyObject * const *args, + Py_ssize_t args_length) +/*[clinic end generated code: output=5831a1056a1a68d5 input=65f04e91969ffccd]*/ { - if (kwds != NULL) { - PyErr_SetString(PyExc_TypeError, "Template.__new__ only accepts *args arguments"); - return NULL; - } - - Py_ssize_t argslen = PyTuple_GET_SIZE(args); Py_ssize_t stringslen = 0; Py_ssize_t interpolationslen = 0; int last_was_str = 0; - for (Py_ssize_t i = 0; i < argslen; i++) { - PyObject *item = PyTuple_GET_ITEM(args, i); + for (Py_ssize_t i = 0; i < args_length; i++) { + PyObject *item = args[i]; if (PyUnicode_Check(item)) { if (!last_was_str) { stringslen++; @@ -142,8 +152,8 @@ template_new(PyTypeObject *type, PyObject *args, PyObject *kwds) last_was_str = 0; Py_ssize_t stringsidx = 0, interpolationsidx = 0; - for (Py_ssize_t i = 0; i < argslen; i++) { - PyObject *item = PyTuple_GET_ITEM(args, i); + for (Py_ssize_t i = 0; i < args_length; i++) { + PyObject *item = args[i]; if (PyUnicode_Check(item)) { if (last_was_str) { PyObject *laststring = PyTuple_GET_ITEM(strings, stringsidx - 1); @@ -226,6 +236,8 @@ template_iter(PyObject *op) if (iter == NULL) { return NULL; } + iter->stringsiter = NULL; + iter->interpolationsiter = NULL; PyObject *stringsiter = PyObject_GetIter(self->strings); if (stringsiter == NULL) { @@ -389,6 +401,7 @@ PyTypeObject _PyTemplate_Type = { .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, .tp_as_sequence = &template_as_sequence, .tp_new = template_new, + .tp_vectorcall = template_vectorcall, .tp_alloc = PyType_GenericAlloc, .tp_dealloc = template_dealloc, .tp_clear = template_clear, diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index bb5e18cb790acf0..4b096d209fd92eb 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -8,6 +8,7 @@ #include "pycore_list.h" // _Py_memory_repeat() #include "pycore_modsupport.h" // _PyArg_NoKwnames() #include "pycore_object.h" // _PyObject_GC_TRACK() +#include "pycore_pyerrors.h" // _PyException_AddNote() #include "pycore_stackref.h" // PyStackRef_AsPyObjectSteal() #include "pycore_tuple.h" // _PyTupleIterObject @@ -49,11 +50,6 @@ tuple_alloc(Py_ssize_t size) return op; } } - /* Check for overflow */ - if ((size_t)size > ((size_t)PY_SSIZE_T_MAX - (sizeof(PyTupleObject) - - sizeof(PyObject *))) / sizeof(PyObject *)) { - return (PyTupleObject *)PyErr_NoMemory(); - } PyTupleObject *result = PyObject_GC_NewVar(PyTupleObject, &PyTuple_Type, size); if (result != NULL) { _PyTuple_RESET_HASH_CACHE(result); @@ -380,16 +376,43 @@ tuple_hash(PyObject *op) Py_ssize_t len = Py_SIZE(v); PyObject **item = v->ob_item; + + /* Hashing an item recurses back into tuple_hash() when that item is + itself a tuple, so guard the descent to raise RecursionError rather + than overflow the C stack on a deeply nested tuple. */ + if (_Py_EnterRecursiveCall(" while hashing a tuple")) { + return -1; + } + acc = _PyTuple_HASH_XXPRIME_5; for (Py_ssize_t i = 0; i < len; i++) { Py_uhash_t lane = PyObject_Hash(item[i]); if (lane == (Py_uhash_t)-1) { + if (PyErr_ExceptionMatches(PyExc_TypeError)) { + /* Preserve the original error while providing context for + the element that could not be hashed. */ + PyObject *exc = PyErr_GetRaisedException(); + PyObject *note = PyUnicode_FromFormat( + "when hashing tuple item %zd", i); + if (note != NULL) { + if (_PyException_AddNote(exc, note) < 0) { + PyErr_Clear(); + } + Py_DECREF(note); + } + else { + PyErr_Clear(); + } + PyErr_SetRaisedException(exc); + } + _Py_LeaveRecursiveCall(); return -1; } acc += lane * _PyTuple_HASH_XXPRIME_2; acc = _PyTuple_HASH_XXROTATE(acc); acc *= _PyTuple_HASH_XXPRIME_1; } + _Py_LeaveRecursiveCall(); /* Add input length, mangled to keep the historical value of hash(()). */ acc += len ^ (_PyTuple_HASH_XXPRIME_5 ^ 3527539UL); @@ -781,6 +804,7 @@ static PyObject * tuple_subtype_new(PyTypeObject *type, PyObject *iterable); /*[clinic input] +@vectorcall @classmethod tuple.__new__ as tuple_new iterable: object(c_default="NULL") = () @@ -796,7 +820,7 @@ If the argument is a tuple, the return value is the same object. static PyObject * tuple_new_impl(PyTypeObject *type, PyObject *iterable) -/*[clinic end generated code: output=4546d9f0d469bce7 input=86963bcde633b5a2]*/ +/*[clinic end generated code: output=4546d9f0d469bce7 input=8fdda913493ebe48]*/ { if (type != &PyTuple_Type) return tuple_subtype_new(type, iterable); @@ -809,27 +833,6 @@ tuple_new_impl(PyTypeObject *type, PyObject *iterable) } } -static PyObject * -tuple_vectorcall(PyObject *type, PyObject * const*args, - size_t nargsf, PyObject *kwnames) -{ - if (!_PyArg_NoKwnames("tuple", kwnames)) { - return NULL; - } - - Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); - if (!_PyArg_CheckPositional("tuple", nargs, 0, 1)) { - return NULL; - } - - if (nargs) { - return tuple_new_impl(_PyType_CAST(type), args[0]); - } - else { - return tuple_get_empty(); - } -} - static PyObject * tuple_subtype_new(PyTypeObject *type, PyObject *iterable) { @@ -1041,8 +1044,11 @@ _PyTuple_Resize(PyObject **pv, Py_ssize_t newsize) Py_ssize_t oldsize; v = (PyTupleObject *) *pv; - if (v == NULL || !Py_IS_TYPE(v, &PyTuple_Type) || - (Py_SIZE(v) != 0 && !_PyObject_IsUniquelyReferenced(*pv))) { + if (v == NULL || !Py_IS_TYPE(v, &PyTuple_Type) || newsize < 0 + || (Py_SIZE(v) != 0 && !_PyObject_IsUniquelyReferenced(*pv)) + // gh-161226: Disallow resizing a tuple if the hash value is cached + || (Py_SIZE(v) != 0 && v->ob_hash != -1)) + { *pv = 0; Py_XDECREF(v); PyErr_BadInternalCall(); @@ -1086,6 +1092,11 @@ _PyTuple_Resize(PyObject **pv, Py_ssize_t newsize) #ifdef Py_REF_DEBUG _Py_DecRefTotal(_PyThreadState_GET()); #endif + /* The failed reallocation leaves the original items owned by v. */ + i = oldsize; + while (--i >= 0) { + Py_XDECREF(v->ob_item[i]); + } PyObject_GC_Del(v); return -1; } @@ -1291,12 +1302,13 @@ maybe_freelist_push(PyTupleObject *op) void _PyTuple_DebugMallocStats(FILE *out) { + PyTypeObject *type = &PyTuple_Type; for (int i = 0; i < PyTuple_MAXSAVESIZE; i++) { int len = i + 1; char buf[128]; PyOS_snprintf(buf, sizeof(buf), "free %d-sized PyTupleObject", len); - _PyDebugAllocatorStats(out, buf, _Py_FREELIST_SIZE(tuples[i]), - _PyType_PreHeaderSize(&PyTuple_Type) + _PyObject_VAR_SIZE(&PyTuple_Type, len)); + size_t size = _PyType_PreHeaderSize(type) + _PyObject_VAR_SIZE(type, len); + _PyDebugAllocatorStats(out, buf, _Py_FREELIST_SIZE(tuples[i]), size); } } diff --git a/Objects/typeobject.c b/Objects/typeobject.c index ffa20ccaf3dfb87..68908c3f0bae626 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -8,7 +8,6 @@ #include "pycore_dict.h" // _PyDict_KeysSize() #include "pycore_function.h" // _PyFunction_GetVersionForCurrentState() #include "pycore_interpframe.h" // _PyInterpreterFrame -#include "pycore_lock.h" // _PySeqLock_* #include "pycore_long.h" // _PyLong_IsNegative(), _PyLong_GetOne() #include "pycore_memoryobject.h" // _PyMemoryView_FromBufferProc() #include "pycore_modsupport.h" // _PyArg_NoKwnames() @@ -21,7 +20,8 @@ #include "pycore_slots.h" // _PySlotIterator_Init #include "pycore_symtable.h" // _Py_Mangle() #include "pycore_tuple.h" // _PyTuple_FromPair -#include "pycore_typeobject.h" // struct type_cache +#include "pycore_typecache.h" // _PyTypeCache_Lookup() +#include "pycore_typeobject.h" // _PyTypes_InitTypes() #include "pycore_unicodeobject.h" // _PyUnicode_Copy #include "pycore_unionobject.h" // _Py_union_type_or #include "pycore_weakref.h" // _PyWeakref_GET_REF() @@ -41,21 +41,7 @@ class object "PyObject *" "&PyBaseObject_Type" /* Support type attribute lookup cache */ -/* The cache can keep references to the names alive for longer than - they normally would. This is why the maximum size is limited to - MCACHE_MAX_ATTR_SIZE, since it might be a problem if very large - strings are used as attribute names. */ -#define MCACHE_MAX_ATTR_SIZE 100 -#define MCACHE_HASH(version, name_hash) \ - (((unsigned int)(version) ^ (unsigned int)(name_hash)) \ - & ((1 << MCACHE_SIZE_EXP) - 1)) - -#define MCACHE_HASH_METHOD(type, name) \ - MCACHE_HASH(FT_ATOMIC_LOAD_UINT_RELAXED((type)->tp_version_tag), \ - ((Py_ssize_t)(name)) >> 3) -#define MCACHE_CACHEABLE_NAME(name) \ - (PyUnicode_CheckExact(name) && \ - (PyUnicode_GET_LENGTH(name) <= MCACHE_MAX_ATTR_SIZE)) +#define MCACHE_CACHEABLE_NAME(name) (PyUnicode_CheckExact(name) && PyUnicode_CHECK_INTERNED(name)) #define NEXT_VERSION_TAG(interp) \ (interp)->types.next_version_tag @@ -84,7 +70,6 @@ class object "PyObject *" "&PyBaseObject_Type" #define END_TYPE_DICT_LOCK() Py_END_CRITICAL_SECTION2() -#if !defined(NDEBUG) || defined(Py_DEBUG) // Return true if the world is currently stopped. static bool types_world_is_stopped(void) @@ -92,7 +77,6 @@ types_world_is_stopped(void) PyInterpreterState *interp = _PyInterpreterState_GET(); return interp->stoptheworld.world_stopped; } -#endif // Checks that the type has not yet been revealed (exposed) to other // threads. The _Py_TYPE_REVEALED_FLAG flag is set by type_new() and @@ -138,47 +122,6 @@ types_start_world(void) assert(!types_world_is_stopped()); } -// This is used to temporarily prevent the TYPE_LOCK from being suspended -// when held by the topmost critical section. -static void -type_lock_prevent_release(void) -{ - PyThreadState *tstate = _PyThreadState_GET(); - uintptr_t *tagptr = &tstate->critical_section; - PyCriticalSection *c = (PyCriticalSection *)(*tagptr & ~_Py_CRITICAL_SECTION_MASK); - if (!(*tagptr & _Py_CRITICAL_SECTION_TWO_MUTEXES)) { - assert(c->_cs_mutex == TYPE_LOCK); - c->_cs_mutex = NULL; - } - else { - PyCriticalSection2 *c2 = (PyCriticalSection2 *)c; - if (c->_cs_mutex == TYPE_LOCK) { - c->_cs_mutex = c2->_cs_mutex2; - c2->_cs_mutex2 = NULL; - } else { - assert(c2->_cs_mutex2 == TYPE_LOCK); - c2->_cs_mutex2 = NULL; - } - } -} - -static void -type_lock_allow_release(void) -{ - PyThreadState *tstate = _PyThreadState_GET(); - uintptr_t *tagptr = &tstate->critical_section; - PyCriticalSection *c = (PyCriticalSection *)(*tagptr & ~_Py_CRITICAL_SECTION_MASK); - if (!(*tagptr & _Py_CRITICAL_SECTION_TWO_MUTEXES)) { - assert(c->_cs_mutex == NULL); - c->_cs_mutex = TYPE_LOCK; - } - else { - PyCriticalSection2 *c2 = (PyCriticalSection2 *)c; - assert(c2->_cs_mutex2 == NULL); - c2->_cs_mutex2 = TYPE_LOCK; - } -} - #else #define BEGIN_TYPE_LOCK() @@ -192,8 +135,6 @@ type_lock_allow_release(void) #define types_world_is_stopped() 1 #define types_stop_world() #define types_start_world() -#define type_lock_prevent_release() -#define type_lock_allow_release() #endif @@ -596,7 +537,7 @@ _PyType_GetBases(PyTypeObject *self) } static inline void -set_tp_bases(PyTypeObject *self, PyObject *bases, int initial) +set_tp_bases(PyTypeObject *self, PyObject *bases) { assert(PyTuple_Check(bases)); ASSERT_NEW_TYPE_OR_LOCKED(self); @@ -604,7 +545,6 @@ set_tp_bases(PyTypeObject *self, PyObject *bases, int initial) // XXX tp_bases can probably be statically allocated for each // static builtin type. assert(PyTuple_CheckExact(bases)); - assert(initial); assert(self->tp_bases == NULL); if (PyTuple_GET_SIZE(bases) == 0) { assert(self->tp_base == NULL); @@ -620,6 +560,28 @@ set_tp_bases(PyTypeObject *self, PyObject *bases, int initial) self->tp_bases = bases; } +// Replace tp_bases and tp_base of a type with the world stopped. Returns true +// on success and false if tp_bases is no longer 'expected'. In the latter case +// the caller still owns 'bases' and 'base'. +static bool +try_set_tp_bases(PyTypeObject *self, PyObject *expected, + PyObject *bases, PyTypeObject *base) +{ + ASSERT_TYPE_LOCK_HELD(); + assert(PyTuple_Check(bases)); + assert(!(self->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN)); + bool res = false; + types_stop_world(); + if (self->tp_bases == expected) { + self->tp_bases = bases; + self->tp_base = base; + res = true; + } + types_start_world(); + ASSERT_TYPE_LOCK_HELD(); + return res; +} + static inline void clear_tp_bases(PyTypeObject *self, int final) { @@ -648,14 +610,13 @@ lookup_tp_mro(PyTypeObject *self) } static inline void -set_tp_mro(PyTypeObject *self, PyObject *mro, int initial) +set_tp_mro(PyTypeObject *self, PyObject *mro) { if (mro != NULL) { assert(PyTuple_CheckExact(mro)); if (self->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN) { // XXX tp_mro can probably be statically allocated for each // static builtin type. - assert(initial); assert(self->tp_mro == NULL); /* Other checks are done via set_tp_bases. */ _Py_SetImmortal(mro); @@ -664,15 +625,30 @@ set_tp_mro(PyTypeObject *self, PyObject *mro, int initial) PyUnstable_Object_EnableDeferredRefcount(mro); } } - if (!initial) { - type_lock_prevent_release(); - types_stop_world(); - } self->tp_mro = mro; - if (!initial) { - types_start_world(); - type_lock_allow_release(); +} + +// Replace tp_mro of a type with the world stopped. Returns true on success and +// false if tp_mro is no longer 'expected'. In the latter case the caller still +// owns 'mro'. +static bool +try_set_tp_mro(PyTypeObject *self, PyObject *expected, PyObject *mro) +{ + ASSERT_TYPE_LOCK_HELD(); + assert(!(self->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN)); + assert(mro == NULL || PyTuple_CheckExact(mro)); + bool res = false; + types_stop_world(); + if (self->tp_mro == expected) { + if (mro != NULL) { + PyUnstable_Object_EnableDeferredRefcount(mro); + } + self->tp_mro = mro; + res = true; } + types_start_world(); + ASSERT_TYPE_LOCK_HELD(); + return res; } static inline void @@ -772,17 +748,14 @@ _PyType_HasSubclasses(PyTypeObject *self) return 1; } -PyObject* -_PyType_GetSubclasses(PyTypeObject *self) +static int +get_subclasses_unlocked(PyTypeObject *self, PyObject *list) { - PyObject *list = PyList_New(0); - if (list == NULL) { - return NULL; - } + ASSERT_TYPE_LOCK_HELD(); PyObject *subclasses = lookup_tp_subclasses(self); // borrowed ref if (subclasses == NULL) { - return list; + return 0; } assert(PyDict_CheckExact(subclasses)); // The loop cannot modify tp_subclasses, there is no need @@ -796,12 +769,33 @@ _PyType_GetSubclasses(PyTypeObject *self) continue; } - if (PyList_Append(list, _PyObject_CAST(subclass)) < 0) { - Py_DECREF(list); - Py_DECREF(subclass); - return NULL; - } + int res = PyList_Append(list, _PyObject_CAST(subclass)); Py_DECREF(subclass); + if (res < 0) { + return -1; + } + } + return 0; +} + +PyObject* +_PyType_GetSubclasses(PyTypeObject *self) +{ + PyObject *list = PyList_New(0); + if (list == NULL) { + return NULL; + } + + // The type lock protects tp_subclasses from being mutated while we + // iterate over it (e.g. by add_subclass() or by remove_subclass() when a + // subclass is deallocated). + int res; + BEGIN_TYPE_LOCK(); + res = get_subclasses_unlocked(self, list); + END_TYPE_LOCK(); + + if (res < 0) { + Py_CLEAR(list); } return list; } @@ -969,75 +963,17 @@ _PyType_GetTextSignatureFromInternalDoc(const char *name, const char *internal_d } -static struct type_cache* -get_type_cache(void) -{ - PyInterpreterState *interp = _PyInterpreterState_GET(); - return &interp->types.type_cache; -} - - -static void -type_cache_clear(struct type_cache *cache, PyObject *value) -{ - for (Py_ssize_t i = 0; i < (1 << MCACHE_SIZE_EXP); i++) { - struct type_cache_entry *entry = &cache->hashtable[i]; -#ifdef Py_GIL_DISABLED - _PySeqLock_LockWrite(&entry->sequence); -#endif - entry->version = 0; - Py_XSETREF(entry->name, _Py_XNewRef(value)); - entry->value = NULL; -#ifdef Py_GIL_DISABLED - _PySeqLock_UnlockWrite(&entry->sequence); -#endif - } -} - - -void -_PyType_InitCache(PyInterpreterState *interp) -{ - struct type_cache *cache = &interp->types.type_cache; - for (Py_ssize_t i = 0; i < (1 << MCACHE_SIZE_EXP); i++) { - struct type_cache_entry *entry = &cache->hashtable[i]; - assert(entry->name == NULL); - - entry->version = 0; - // Set to None so _PyType_LookupRef() can use Py_SETREF(), - // rather than using slower Py_XSETREF(). - entry->name = Py_None; - entry->value = NULL; - } -} - - -static unsigned int -_PyType_ClearCache(PyInterpreterState *interp) -{ - struct type_cache *cache = &interp->types.type_cache; - // Set to None, rather than NULL, so _PyType_LookupRef() can - // use Py_SETREF() rather than using slower Py_XSETREF(). - type_cache_clear(cache, Py_None); - - return NEXT_VERSION_TAG(interp) - 1; -} - - unsigned int PyType_ClearCache(void) { PyInterpreterState *interp = _PyInterpreterState_GET(); - return _PyType_ClearCache(interp); + return NEXT_VERSION_TAG(interp) - 1; } void _PyTypes_Fini(PyInterpreterState *interp) { - struct type_cache *cache = &interp->types.type_cache; - type_cache_clear(cache, NULL); - // All the managed static types should have been finalized already. assert(interp->types.for_extensions.num_initialized == 0); for (size_t i = 0; i < _Py_MAX_MANAGED_STATIC_EXT_TYPES; i++) { @@ -1231,6 +1167,7 @@ _PyType_Modified_Unlocked(PyTypeObject *type) } set_version_unlocked(type, 0); /* 0 is not a valid version tag */ + _PyTypeCache_Invalidate(type); if (PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)) { // This field *must* be invalidated if the type is modified (see the // comment on struct _specialization_cache): @@ -1314,6 +1251,7 @@ type_mro_modified(PyTypeObject *type, PyObject *bases) clear: assert(!(type->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN)); set_version_unlocked(type, 0); /* 0 is not a valid version tag */ + _PyTypeCache_Invalidate(type); type->tp_versions_used = _Py_ATTR_CACHE_UNUSED; if (PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)) { // This field *must* be invalidated if the type is modified (see the @@ -1741,14 +1679,16 @@ type_set_abstractmethods(PyObject *tp, PyObject *value, void *Py_UNUSED(closure) } BEGIN_TYPE_LOCK(); - _PyType_Modified_Unlocked(type); types_stop_world(); if (abstract) type_add_flags(type, Py_TPFLAGS_IS_ABSTRACT); else type_clear_flags(type, Py_TPFLAGS_IS_ABSTRACT); types_start_world(); + // Invalidate the version tag after update, while TYPE_LOCK is + // still held. ASSERT_TYPE_LOCK_HELD(); + _PyType_Modified_Unlocked(type); END_TYPE_LOCK(); return 0; @@ -1779,12 +1719,14 @@ type_get_mro(PyObject *tp, void *Py_UNUSED(closure)) static PyTypeObject *find_best_base(PyObject *); static int mro_internal(PyTypeObject *, int, PyObject **); static int type_is_subtype_base_chain(PyTypeObject *, PyTypeObject *); -static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, const char *, int); +static int compatible_layout(PyTypeObject *, PyTypeObject *, int); +static void raise_layout_differs(const char *, PyTypeObject *, PyTypeObject *); +static int update_best_base(PyTypeObject *, PyTypeObject **, PyTypeObject **); static int add_subclass(PyTypeObject*, PyTypeObject*); static int add_all_subclasses(PyTypeObject *type, PyObject *bases); static void remove_subclass(PyTypeObject *, PyTypeObject *); static void remove_all_subclasses(PyTypeObject *type, PyObject *bases); -static int update_all_slots(PyTypeObject *); +static void update_all_slots(PyTypeObject *); typedef int (*update_callback)(PyTypeObject *, void *); static int update_subclasses(PyTypeObject *type, PyObject *attr_name, @@ -1825,8 +1767,13 @@ mro_hierarchy_for_complete_type(PyTypeObject *type, PyObject *temp) Py_XDECREF(tuple); if (res < 0) { - set_tp_mro(type, old_mro, 0); - Py_DECREF(new_mro); + // Roll back, unless tp_mro has already been replaced again. + if (try_set_tp_mro(type, new_mro, old_mro)) { + Py_DECREF(new_mro); + } + else { + Py_XDECREF(old_mro); + } return -1; } Py_XDECREF(old_mro); @@ -1862,8 +1809,10 @@ mro_hierarchy_for_complete_type(PyTypeObject *type, PyObject *temp) return res; } +// Checks on the new __bases__ value that do not depend on mutable type +// state. Done once per assignment. static int -type_check_new_bases(PyTypeObject *type, PyObject *new_bases, PyTypeObject **best_base) +type_check_new_bases(PyTypeObject *type, PyObject *new_bases) { // Check arguments, this is re-entrant due to the PySys_Audit() call if (!check_set_special_type_attr(type, new_bases, "__bases__")) { @@ -1892,7 +1841,42 @@ type_check_new_bases(PyTypeObject *type, PyObject *new_bases, PyTypeObject **bes type->tp_name, Py_TYPE(ob)->tp_name); return -1; } - PyTypeObject *base = (PyTypeObject*)ob; + PyTypeObject *base = (PyTypeObject *)ob; + if (!_PyType_IsReady(base)) { + if (PyType_Ready(base) < 0) { + return -1; + } + } + if (!_PyType_HasFeature(base, Py_TPFLAGS_BASETYPE)) { + PyErr_Format(PyExc_TypeError, + "type '%.100s' is not an acceptable base type", + base->tp_name); + return -1; + } + } + return 0; +} + +typedef enum { + NEW_BASES_OK, + NEW_BASES_CYCLE, + NEW_BASES_LAYOUT_CONFLICT, + NEW_BASES_LAYOUT_DIFFERS, +} new_bases_check_t; + +// Checks on the new __bases__ value that depend on the current state of the +// type hierarchy (inheritance cycles, layout compatibility). This is called +// with the world stopped and does not raise; see raise_new_bases_error(). +// On success, *best_base is set to the new tp_base (a borrowed reference +// from new_bases). +static new_bases_check_t +type_validate_new_bases(PyTypeObject *type, PyObject *new_bases, + PyTypeObject **best_base) +{ + assert(types_world_is_stopped()); + Py_ssize_t n = PyTuple_GET_SIZE(new_bases); + for (Py_ssize_t i = 0; i < n; i++) { + PyTypeObject *base = (PyTypeObject *)PyTuple_GET_ITEM(new_bases, i); if (is_subtype_with_mro(lookup_tp_mro(base), base, type) || /* In case of reentering here again through a custom mro() @@ -1907,40 +1891,81 @@ type_check_new_bases(PyTypeObject *type, PyObject *new_bases, PyTypeObject **bes (lookup_tp_mro(base) != NULL && type_is_subtype_base_chain(base, type))) { - PyErr_SetString(PyExc_TypeError, - "a __bases__ item causes an inheritance cycle"); - return -1; + return NEW_BASES_CYCLE; } } - // Compute the new MRO and the new base class - *best_base = find_best_base(new_bases); - if (*best_base == NULL) - return -1; + // Compute the new base class. The bases are known to be ready and + // acceptable as base types (see type_check_new_bases()). + PyTypeObject *winner = NULL; + *best_base = NULL; + for (Py_ssize_t i = 0; i < n; i++) { + PyTypeObject *base = (PyTypeObject *)PyTuple_GET_ITEM(new_bases, i); + if (update_best_base(base, best_base, &winner) < 0) { + return NEW_BASES_LAYOUT_CONFLICT; + } + } - if (!compatible_for_assignment(type, *best_base, "__bases__", 0)) { - return -1; + if (!compatible_layout(type, *best_base, 0)) { + return NEW_BASES_LAYOUT_DIFFERS; } - return 0; + return NEW_BASES_OK; } +// Raise the error for a failed type_validate_new_bases() check. 'old_base' +// is the tp_base of the type when the check was done. +static void +raise_new_bases_error(new_bases_check_t check, PyTypeObject *best_base, + PyTypeObject *old_base) +{ + switch (check) { + case NEW_BASES_CYCLE: + PyErr_SetString(PyExc_TypeError, + "a __bases__ item causes an inheritance cycle"); + break; + case NEW_BASES_LAYOUT_CONFLICT: + PyErr_SetString(PyExc_TypeError, + "multiple bases have instance lay-out conflict"); + break; + case NEW_BASES_LAYOUT_DIFFERS: + raise_layout_differs("__bases__", best_base, old_base); + break; + default: + Py_UNREACHABLE(); + } +} + +// Returns 0 on success and -1 on error. static int -type_set_bases_unlocked(PyTypeObject *type, PyObject *new_bases, PyTypeObject *best_base) +type_set_bases_unlocked(PyTypeObject *type, PyObject *new_bases) { ASSERT_TYPE_LOCK_HELD(); + // Validate and store the new bases with the world stopped, so that the + // hierarchy cannot change in between. Py_ssize_t n; + PyTypeObject *best_base; + types_stop_world(); PyObject *old_bases = lookup_tp_bases(type); assert(old_bases != NULL); PyTypeObject *old_base = type->tp_base; - - type_lock_prevent_release(); - types_stop_world(); - set_tp_bases(type, Py_NewRef(new_bases), 0); - type->tp_base = (PyTypeObject *)Py_NewRef(best_base); + new_bases_check_t check = type_validate_new_bases(type, new_bases, + &best_base); + if (check == NEW_BASES_OK) { + type->tp_bases = Py_NewRef(new_bases); + type->tp_base = (PyTypeObject *)Py_NewRef(best_base); + } + else { + // Keep old_base alive for the error message. + Py_INCREF(old_base); + } types_start_world(); - type_lock_allow_release(); + if (check != NEW_BASES_OK) { + raise_new_bases_error(check, best_base, old_base); + Py_DECREF(old_base); + return -1; + } PyObject *temp = PyList_New(0); if (temp == NULL) { @@ -1964,11 +1989,9 @@ type_set_bases_unlocked(PyTypeObject *type, PyObject *new_bases, PyTypeObject *b add to all new_bases */ remove_all_subclasses(type, old_bases); res = add_all_subclasses(type, new_bases); - if (update_all_slots(type) < 0) { - goto bail; - } - /* Clear the VALID_VERSION flag of 'type' and all its subclasses. */ - _PyType_Modified_Unlocked(type); + /* This also clears the VALID_VERSION flag of 'type' and all its + subclasses. */ + update_all_slots(type); } else { res = 0; @@ -1990,24 +2013,19 @@ type_set_bases_unlocked(PyTypeObject *type, PyObject *new_bases, PyTypeObject *b PyArg_UnpackTuple(PyList_GET_ITEM(temp, i), "", 2, 3, &cls, &new_mro, &old_mro); /* Do not rollback if cls has a newer version of MRO. */ - if (lookup_tp_mro(cls) == new_mro) { - set_tp_mro(cls, Py_XNewRef(old_mro), 0); + old_mro = Py_XNewRef(old_mro); + if (try_set_tp_mro(cls, new_mro, old_mro)) { Py_DECREF(new_mro); } + else { + Py_XDECREF(old_mro); + } } Py_DECREF(temp); bail: - if (lookup_tp_bases(type) == new_bases) { - assert(type->tp_base == best_base); - - type_lock_prevent_release(); - types_stop_world(); - set_tp_bases(type, old_bases, 0); - type->tp_base = old_base; - types_start_world(); - type_lock_allow_release(); - + /* Restore the old bases, unless tp_bases has been replaced again. */ + if (try_set_tp_bases(type, new_bases, old_bases, old_base)) { Py_DECREF(new_bases); Py_DECREF(best_base); } @@ -2024,14 +2042,22 @@ static int type_set_bases(PyObject *tp, PyObject *new_bases, void *Py_UNUSED(closure)) { PyTypeObject *type = PyTypeObject_CAST(tp); - PyTypeObject *best_base; int res; - BEGIN_TYPE_LOCK(); - res = type_check_new_bases(type, new_bases, &best_base); - if (res == 0) { - res = type_set_bases_unlocked(type, new_bases, best_base); + if (type_check_new_bases(type, new_bases) < 0) { + return -1; + } + // Create a fresh bases tuple to store. Its identity tells whether + // tp_bases was replaced again while TYPE_LOCK was released or due to + // re-entrancy from the mro() call. + Py_ssize_t n = PyTuple_GET_SIZE(new_bases); + PyObject *bases = PyTuple_FromArray(((PyTupleObject *)new_bases)->ob_item, n); + if (bases == NULL) { + return -1; } + BEGIN_TYPE_LOCK(); + res = type_set_bases_unlocked(type, bases); END_TYPE_LOCK(); + Py_DECREF(bases); return res; } @@ -2511,25 +2537,43 @@ _PyType_NewManagedObject(PyTypeObject *type) PyObject * _PyType_AllocNoTrack(PyTypeObject *type, Py_ssize_t nitems) { - PyObject *obj; +#ifdef Py_DEBUG + if (nitems < 0) { + PyErr_BadInternalCall(); + return NULL; + } +#endif + /* The +1 on nitems is needed for most types but not all. We could save a * bit of space by allocating one less item in certain cases, depending on * the type. However, given the extra complexity (e.g. an additional type * flag to indicate when that is safe) it does not seem worth the memory * savings. An example type that doesn't need the +1 is a subclass of * tuple. See GH-100659 and GH-81381. */ + if (nitems > PY_SSIZE_T_MAX - 1) { + return PyErr_NoMemory(); + } size_t size = _PyObject_VAR_SIZE(type, nitems+1); - const size_t presize = _PyType_PreHeaderSize(type); if (type->tp_flags & Py_TPFLAGS_INLINE_VALUES) { assert(type->tp_itemsize == 0); - size += _PyInlineValuesSize(type); + size_t inline_values_size = _PyInlineValuesSize(type); + if (size > (size_t)PY_SSIZE_T_MAX - inline_values_size) { + return PyErr_NoMemory(); + } + size += inline_values_size; } + + const size_t presize = _PyType_PreHeaderSize(type); + if (size > (size_t)PY_SSIZE_T_MAX - presize) { + return PyErr_NoMemory(); + } + char *alloc = _PyObject_MallocWithType(type, size + presize); - if (alloc == NULL) { + if (alloc == NULL) { return PyErr_NoMemory(); } - obj = (PyObject *)(alloc + presize); + PyObject *obj = (PyObject *)(alloc + presize); if (presize) { ((PyObject **)alloc)[0] = NULL; ((PyObject **)alloc)[1] = NULL; @@ -2801,6 +2845,10 @@ subtype_dealloc(PyObject *self) } _PyObject_GC_UNTRACK(self); } + + /* Extract the type again; tp_finalize may have changed it */ + type = Py_TYPE(self); + /* If we added a weaklist, we clear it. Do this *before* calling tp_del, clearing slots, or clearing the instance dict. @@ -2961,17 +3009,22 @@ _PyObject_LookupSpecial(PyObject *self, PyObject *attr) return res; } -// Lookup the method name `attr` on `self`. On entry, `method_and_self[0]` -// is null and `method_and_self[1]` is `self`. On exit, `method_and_self[0]` -// is the method object and `method_and_self[1]` is `self` if the method is -// not bound. +// Lookup the method name `attr` on `*self`. On entry, `*method` is null. +// On exit, `*method` is the method object and `*self` is cleared if the +// method is bound. // Return 1 on success, -1 on error, and 0 if the method is missing. +// +// `method` must point to a location that the garbage collector can see, +// such as the `ref` field of a `_PyCStackRef` or a slot on the interpreter +// stack. A descriptor may be invoked while `*method` holds the only +// reference to the method object, and that can trigger a collection. int -_PyObject_LookupSpecialMethod(PyObject *attr, _PyStackRef *method_and_self) +_PyObject_LookupSpecialMethod(PyObject *attr, _PyStackRef *method, + _PyStackRef *self) { - PyObject *self = PyStackRef_AsPyObjectBorrow(method_and_self[1]); - _PyType_LookupStackRefAndVersion(Py_TYPE(self), attr, &method_and_self[0]); - PyObject *method_o = PyStackRef_AsPyObjectBorrow(method_and_self[0]); + PyObject *self_o = PyStackRef_AsPyObjectBorrow(*self); + _PyType_LookupStackRefAndVersion(Py_TYPE(self_o), attr, method); + PyObject *method_o = PyStackRef_AsPyObjectBorrow(*method); if (method_o == NULL) { return 0; } @@ -2983,14 +3036,14 @@ _PyObject_LookupSpecialMethod(PyObject *attr, _PyStackRef *method_and_self) descrgetfunc f = Py_TYPE(method_o)->tp_descr_get; if (f != NULL) { - PyObject *func = f(method_o, self, (PyObject *)(Py_TYPE(self))); + PyObject *func = f(method_o, self_o, (PyObject *)(Py_TYPE(self_o))); if (func == NULL) { return -1; } - PyStackRef_CLEAR(method_and_self[0]); // clear method - method_and_self[0] = PyStackRef_FromPyObjectSteal(func); + PyStackRef_CLEAR(*method); // clear method + *method = PyStackRef_FromPyObjectSteal(func); } - PyStackRef_CLEAR(method_and_self[1]); // clear self + PyStackRef_CLEAR(*self); // clear self return 1; } @@ -3657,25 +3710,45 @@ mro_internal(PyTypeObject *type, int initial, PyObject **p_old_mro) ASSERT_TYPE_LOCK_HELD(); PyObject *new_mro, *old_mro; - int reent; /* Keep a reference to be able to do a reentrancy check below. Don't let old_mro be GC'ed and its address be reused for another object, like (suddenly!) a new tp_mro. */ old_mro = Py_XNewRef(lookup_tp_mro(type)); new_mro = mro_invoke(type); /* might cause reentrance */ - reent = (lookup_tp_mro(type) != old_mro); - Py_XDECREF(old_mro); if (new_mro == NULL) { + Py_XDECREF(old_mro); return -1; } - - if (reent) { + int res; + if (initial) { + // The type has not been revealed to other threads yet, so only + // same-thread reentrance can have replaced tp_mro. + if (lookup_tp_mro(type) == old_mro) { + set_tp_mro(type, new_mro); + res = 1; + } + else { + res = 0; + } + } + else { + // Store with the world stopped. TYPE_LOCK may have been released + // while mro_invoke() ran, so check for reentrance inside the + // stop-the-world. mro() can itself update types (assign a slot, + // for example) and the result is stored anyway, as on the default + // build. + res = try_set_tp_mro(type, old_mro, new_mro); + } + if (res == 0) { + /* reentrance: tp_mro was replaced by someone else */ Py_DECREF(new_mro); + Py_XDECREF(old_mro); return 0; } - - set_tp_mro(type, new_mro, initial); + /* Drop our temporary reference. The reference previously owned by + the type is now owned by this function and transferred below. */ + Py_XDECREF(old_mro); type_mro_modified(type, new_mro); /* corner case: the super class might have been hidden @@ -3700,6 +3773,30 @@ mro_internal(PyTypeObject *type, int initial, PyObject **p_old_mro) return 1; } +/* Update the best base candidate '*base' (with solid base '*winner') for + the next base 'base_i'. Returns -1 if the instance layouts conflict. + Does not raise. */ +static int +update_best_base(PyTypeObject *base_i, PyTypeObject **base, + PyTypeObject **winner) +{ + PyTypeObject *candidate = solid_base(base_i); + if (*winner == NULL) { + *winner = candidate; + *base = base_i; + } + else if (PyType_IsSubtype(*winner, candidate)) + ; + else if (PyType_IsSubtype(candidate, *winner)) { + *winner = candidate; + *base = base_i; + } + else { + return -1; + } + return 0; +} + /* Calculate the best base amongst multiple base classes. This is the first one that's on the path to the "solid base". */ @@ -3707,7 +3804,7 @@ static PyTypeObject * find_best_base(PyObject *bases) { Py_ssize_t i, n; - PyTypeObject *base, *winner, *candidate; + PyTypeObject *base, *winner; assert(PyTuple_Check(bases)); n = PyTuple_GET_SIZE(bases); @@ -3734,18 +3831,7 @@ find_best_base(PyObject *bases) base_i->tp_name); return NULL; } - candidate = solid_base(base_i); - if (winner == NULL) { - winner = candidate; - base = base_i; - } - else if (PyType_IsSubtype(winner, candidate)) - ; - else if (PyType_IsSubtype(candidate, winner)) { - winner = candidate; - base = base_i; - } - else { + if (update_best_base(base_i, &base, &winner) < 0) { PyErr_SetString( PyExc_TypeError, "multiple bases have " @@ -3786,164 +3872,31 @@ solid_base(PyTypeObject *type) } } -#ifdef Py_GIL_DISABLED - -// The structures and functions below are used in the free-threaded build -// to safely make updates to type slots, on type_setattro() for a slot -// or when __bases__ is re-assigned. Since the slots are read without atomic -// operations and without locking, we can only safely update them while the -// world is stopped. However, with the world stopped, we are very limited on -// which APIs can be safely used. For example, calling _PyObject_HashDictKey() -// or _PyDict_GetItemRef_KnownHash() are not safe and can potentially cause -// deadlocks. Hashing can be re-entrant and _PyDict_GetItemRef_KnownHash can -// acquire a lock if the dictionary is not owned by the current thread, to -// mark it shared on reading. -// -// We do the slot updates in two steps. First, with TYPE_LOCK held, we lookup -// the descriptor for each slot, for each subclass. We build a queue of -// updates to perform but don't actually update the type structures. After we -// are finished the lookups, we stop-the-world and apply all of the updates. -// The apply_slot_updates() code is simple and easy to confirm that it is -// safe. - -typedef struct { - PyTypeObject *type; - void **slot_ptr; - void *slot_value; -} slot_update_item_t; - -// The number of slot updates performed is based on the number of changed -// slots and the number of subclasses. It's possible there are many updates -// required if there are many subclasses (potentially an unbounded amount). -// Usually the number of slot updates is small, most often zero or one. When -// running the unit tests, we don't exceed 20. The chunk size is set to -// handle the common case with a single chunk and to not require too many -// chunk allocations if there are many subclasses. -#define SLOT_UPDATE_CHUNK_SIZE 30 - -typedef struct _slot_update { - struct _slot_update *prev; - Py_ssize_t n; - slot_update_item_t updates[SLOT_UPDATE_CHUNK_SIZE]; -} slot_update_chunk_t; - -// a queue of updates to be performed -typedef struct { - slot_update_chunk_t *head; -} slot_update_t; - -static slot_update_chunk_t * -slot_update_new_chunk(void) -{ - slot_update_chunk_t *chunk = PyMem_Malloc(sizeof(slot_update_chunk_t)); - if (chunk == NULL) { - PyErr_NoMemory(); - return NULL; - } - chunk->prev = NULL; - chunk->n = 0; - return chunk; -} - -static void -slot_update_free_chunks(slot_update_t *updates) -{ - slot_update_chunk_t *chunk = updates->head; - while (chunk != NULL) { - slot_update_chunk_t *prev = chunk->prev; - PyMem_Free(chunk); - chunk = prev; - } -} - -static int -queue_slot_update(slot_update_t *updates, PyTypeObject *type, - void **slot_ptr, void *slot_value) -{ - if (*slot_ptr == slot_value) { - return 0; // slot pointer not actually changed, don't queue update - } - if (updates->head == NULL || updates->head->n == SLOT_UPDATE_CHUNK_SIZE) { - slot_update_chunk_t *chunk = slot_update_new_chunk(); - if (chunk == NULL) { - return -1; // out-of-memory - } - chunk->prev = updates->head; - updates->head = chunk; - } - slot_update_item_t *item = &updates->head->updates[updates->head->n]; - item->type = type; - item->slot_ptr = slot_ptr; - item->slot_value = slot_value; - updates->head->n++; - assert(updates->head->n <= SLOT_UPDATE_CHUNK_SIZE); - return 0; -} - -static void -apply_slot_updates(slot_update_t *updates) -{ - assert(types_world_is_stopped()); - slot_update_chunk_t *chunk = updates->head; - while (chunk != NULL) { - for (Py_ssize_t i = 0; i < chunk->n; i++) { - slot_update_item_t *item = &chunk->updates[i]; - *(item->slot_ptr) = item->slot_value; - if (item->slot_value == slot_tp_call) { - /* A generic __call__ is incompatible with vectorcall */ - type_clear_flags(item->type, Py_TPFLAGS_HAVE_VECTORCALL); - } - } - chunk = chunk->prev; - } -} - -static void -apply_type_slot_updates(slot_update_t *updates) -{ - // This must be done carefully to avoid data races and deadlocks. We - // have just updated the type __dict__, while holding TYPE_LOCK. We have - // collected all of the required type slot updates into the 'updates' - // queue. Note that those updates can apply to multiple types since - // subclasses might also be affected by the dict change. - // - // We need to prevent other threads from writing to the dict before we can - // finish updating the slots. The actual stores to the slots are done - // with the world stopped. If we block on the stop-the-world mutex then - // we could release TYPE_LOCK mutex and potentially allow other threads - // to update the dict. That's because TYPE_LOCK was acquired using a - // critical section. - // - // The type_lock_prevent_release() call prevents the TYPE_LOCK mutex from - // being released even if we block on the STM mutex. We need to take care - // that we do not deadlock because of that. It is safe because we always - // acquire locks in the same order: first the TYPE_LOCK mutex and then the - // STM mutex. - type_lock_prevent_release(); - types_stop_world(); - apply_slot_updates(updates); - types_start_world(); - type_lock_allow_release(); -} - -#else - -// dummy definition, this parameter is only NULL in the default build -typedef void slot_update_t; - -#endif +// In the free-threaded build, type slots and tp_flags are read without +// atomics and without locking, so they can only be updated with the world +// stopped (or before the type is revealed to other threads). When a slot +// name is assigned with type_setattro() or __bases__ is re-assigned, the +// descriptor lookups for the type and its subclasses and the slot stores are +// all done within one stop-the-world. The new slots therefore agree with +// the type dicts as they are when the world is stopped, whatever happened +// while TYPE_LOCK was released waiting for it. With the world stopped, no +// other thread runs, so dicts and the subclass lists can be read without +// locking and with borrowed references. Nothing that can run user code, +// block or deallocate is allowed; see find_slot_name_in_mro() and +// recurse_down_subclasses(). /// data passed to update_slots_callback() typedef struct { - slot_update_t *queued_updates; pytype_slotdef **defs; } update_callback_data_t; static void object_dealloc(PyObject *); static PyObject *object_new(PyTypeObject *, PyObject *, PyObject *); static int object_init(PyObject *, PyObject *, PyObject *); -static int update_slot(PyTypeObject *, PyObject *, slot_update_t *update); +static int update_slot(PyTypeObject *, PyObject *); static void fixup_slot_dispatchers(PyTypeObject *); +static int type_ready(PyTypeObject *, int, int); +static int type_ready_publish(PyTypeObject *, int); static int type_new_set_names(PyTypeObject *); static int type_new_init_subclass(PyTypeObject *, PyObject *); static bool has_slotdef(PyObject *); @@ -4075,12 +4028,24 @@ subtype_getweakref(PyObject *obj, void *context) _PyObject_ASSERT((PyObject *)type, ((type->tp_weaklistoffset + (Py_ssize_t)sizeof(PyObject *)) <= type->tp_basicsize)); + + /* Synchronize with weakref creation/destruction so the list head cannot + * be removed and freed between loading it and taking a reference. */ + LOCK_WEAKREFS(obj); weaklistptr = (PyObject **)((char *)obj + type->tp_weaklistoffset); - if (*weaklistptr == NULL) - result = Py_None; - else + if (*weaklistptr == NULL) { + result = Py_NewRef(Py_None); + } + else if (_Py_TryIncref(*weaklistptr)) { result = *weaklistptr; - return Py_NewRef(result); + } + else { + result = Py_NewRef(Py_None); + } + + UNLOCK_WEAKREFS(obj); + + return result; } /* getset definitions for common descriptors */ @@ -4429,7 +4394,7 @@ type_new_alloc(type_new_ctx *ctx) type->tp_as_mapping = &et->as_mapping; type->tp_as_buffer = &et->as_buffer; - set_tp_bases(type, Py_NewRef(ctx->bases), 1); + set_tp_bases(type, Py_NewRef(ctx->bases)); type->tp_base = (PyTypeObject *)Py_NewRef(ctx->base); type->tp_dealloc = subtype_dealloc; @@ -4894,10 +4859,72 @@ type_new_get_slots(type_new_ctx *ctx, PyObject *dict) } +/* Copy the class namespace. Keys that are str subclasses are replaced by + exact str copies so that the type dict only holds exact str keys (see + type_setattro() which does the same for assigned names). Lookups in a + dict with exact str keys cannot run user __eq__ methods, which the slot + update code relies on. Non-str keys are left alone; type_new_impl() + warns about them. */ +static PyObject * +type_new_copy_dict(PyObject *orig_dict) +{ + PyObject *dict = _PyDict_CopyAsDict(orig_dict); + if (dict == NULL) { + return NULL; + } + if (((PyDictObject *)dict)->ma_keys->dk_kind != DICT_KEYS_GENERAL) { + // Only exact str keys are possible, nothing to do. + return dict; + } + Py_ssize_t pos = 0; + PyObject *key, *value; + int rebuild = 0; + while (PyDict_Next(dict, &pos, &key, &value)) { + if (PyUnicode_Check(key) && !PyUnicode_CheckExact(key)) { + rebuild = 1; + break; + } + } + if (!rebuild) { + return dict; + } + // Rebuild rather than delete/insert so that the key order is kept. + PyObject *newdict = PyDict_New(); + if (newdict == NULL) { + Py_DECREF(dict); + return NULL; + } + pos = 0; + while (PyDict_Next(dict, &pos, &key, &value)) { + PyObject *newkey; + if (PyUnicode_Check(key) && !PyUnicode_CheckExact(key)) { + newkey = _PyUnicode_Copy(key); + if (newkey == NULL) { + goto error; + } + } + else { + newkey = Py_NewRef(key); + } + int err = PyDict_SetItem(newdict, newkey, value); + Py_DECREF(newkey); + if (err < 0) { + goto error; + } + } + Py_DECREF(dict); + return newdict; + +error: + Py_DECREF(dict); + Py_DECREF(newdict); + return NULL; +} + static PyTypeObject* type_new_init(type_new_ctx *ctx) { - PyObject *dict = _PyDict_CopyAsDict(ctx->orig_dict); + PyObject *dict = type_new_copy_dict(ctx->orig_dict); if (dict == NULL) { goto error; } @@ -4950,13 +4977,10 @@ type_new_impl(type_new_ctx *ctx) } /* Initialize the rest */ - if (PyType_Ready(type) < 0) { + if (type_ready_publish(type, 1) < 0) { goto error; } - // Put the proper slots in place - fixup_slot_dispatchers(type); - if (!_PyDict_HasOnlyStringKeys(type->tp_dict)) { if (PyErr_WarnFormat( PyExc_RuntimeWarning, @@ -4977,10 +5001,6 @@ type_new_impl(type_new_ctx *ctx) } assert(_PyType_CheckConsistency(type)); -#if defined(Py_GIL_DISABLED) && defined(Py_DEBUG) && SIZEOF_VOID_P > 4 - // After this point, other threads can potentally use this type. - ((PyObject*)type)->ob_flags |= _Py_TYPE_REVEALED_FLAG; -#endif return (PyObject *)type; @@ -5642,7 +5662,7 @@ type_from_slots_or_spec( /* Set slots we have prepared */ type->tp_base = (PyTypeObject *)Py_NewRef(base); - set_tp_bases(type, bases, 1); + set_tp_bases(type, bases); bases = NULL; // We give our reference to bases to the type type->tp_doc = tp_doc; @@ -5721,8 +5741,7 @@ type_from_slots_or_spec( * After this call we should generally only touch up what's * accessible to Python code, like __dict__. */ - - if (PyType_Ready(type) < 0) { + if (type_ready_publish(type, 0) < 0) { goto finally; } @@ -5782,10 +5801,6 @@ type_from_slots_or_spec( } assert(_PyType_CheckConsistency(type)); -#if defined(Py_GIL_DISABLED) && defined(Py_DEBUG) && SIZEOF_VOID_P > 4 - // After this point, other threads can potentally use this type. - ((PyObject*)type)->ob_flags |= _Py_TYPE_REVEALED_FLAG; -#endif finally: if (PyErr_Occurred()) { @@ -6194,6 +6209,52 @@ find_name_in_mro(PyTypeObject *type, PyObject *name, _PyStackRef *out) return res; } +#ifdef Py_GIL_DISABLED +/* Variant of find_name_in_mro() used to compute slots. 'name' must be an + exact str. Keys of the MRO dicts that are not exact str are skipped + without being compared, so no user code runs. This can be called with the + world stopped; the result is then a borrowed reference since no other + thread can drop it. Returns 0 if the name was not found and 1 if it was. */ +static int +find_slot_name_in_mro(PyTypeObject *type, PyObject *name, _PyStackRef *out) +{ + assert(PyUnicode_CheckExact(name)); + *out = PyStackRef_NULL; + PyObject *mro = lookup_tp_mro(type); + if (mro == NULL) { + return 0; + } + int res = 0; + int world_stopped = types_world_is_stopped(); + if (!world_stopped) { + // tp_mro can be replaced while the dict locks are released. + Py_INCREF(mro); + } + Py_ssize_t n = PyTuple_GET_SIZE(mro); + for (Py_ssize_t i = 0; i < n; i++) { + PyObject *base = PyTuple_GET_ITEM(mro, i); + PyDictObject *dict = (PyDictObject *)lookup_tp_dict(_PyType_CAST(base)); + assert(dict && PyDict_Check(dict)); + if (world_stopped) { + PyObject *value = _PyDict_GetItem_ExactUnicode(dict, name); + if (value != NULL) { + *out = PyStackRef_FromPyObjectBorrow(value); + res = 1; + break; + } + } + else if (_PyDict_GetItemStackRef_ExactUnicode(dict, name, out)) { + res = 1; + break; + } + } + if (!world_stopped) { + Py_DECREF(mro); + } + return res; +} +#endif + /* Check if the "readied" PyUnicode name is a double-underscore special name. */ static int @@ -6212,69 +6273,6 @@ is_dunder_name(PyObject *name) return 0; } -static PyObject * -update_cache(struct type_cache_entry *entry, PyObject *name, unsigned int version_tag, PyObject *value) -{ - _Py_atomic_store_ptr_relaxed(&entry->value, value); /* borrowed */ - assert(PyUnstable_Unicode_GET_CACHED_HASH(name) != -1); - OBJECT_STAT_INC_COND(type_cache_collisions, entry->name != Py_None && entry->name != name); - // We're releasing this under the lock for simplicity sake because it's always a - // exact unicode object or Py_None so it's safe to do so. - PyObject *old_name = entry->name; - _Py_atomic_store_ptr_relaxed(&entry->name, Py_NewRef(name)); - // We must write the version last to avoid _Py_TryXGetStackRef() - // operating on an invalid (already deallocated) value inside - // _PyType_LookupRefAndVersion(). If we write the version first then a - // reader could pass the "entry_version == type_version" check but could - // be using the old entry value. - _Py_atomic_store_uint32_release(&entry->version, version_tag); - return old_name; -} - -#if Py_GIL_DISABLED - -static void -update_cache_gil_disabled(struct type_cache_entry *entry, PyObject *name, - unsigned int version_tag, PyObject *value) -{ - _PySeqLock_LockWrite(&entry->sequence); - - // update the entry - if (entry->name == name && - entry->value == value && - entry->version == version_tag) { - // We raced with another update, bail and restore previous sequence. - _PySeqLock_AbandonWrite(&entry->sequence); - return; - } - - PyObject *old_value = update_cache(entry, name, version_tag, value); - - // Then update sequence to the next valid value - _PySeqLock_UnlockWrite(&entry->sequence); - - Py_DECREF(old_value); -} - -#endif - -void -_PyTypes_AfterFork(void) -{ -#ifdef Py_GIL_DISABLED - struct type_cache *cache = get_type_cache(); - for (Py_ssize_t i = 0; i < (1 << MCACHE_SIZE_EXP); i++) { - struct type_cache_entry *entry = &cache->hashtable[i]; - if (_PySeqLock_AfterFork(&entry->sequence)) { - // Entry was in the process of updating while forking, clear it... - entry->value = NULL; - Py_SETREF(entry->name, Py_None); - entry->version = 0; - } - } -#endif -} - /* Internal API to look for a name through the MRO. This returns a strong reference, and doesn't set an exception! If nonzero, version is set to the value of type->tp_version at the time of @@ -6305,45 +6303,16 @@ should_assign_version_tag(PyTypeObject *type, PyObject *name, unsigned int versi unsigned int _PyType_LookupStackRefAndVersion(PyTypeObject *type, PyObject *name, _PyStackRef *out) { - unsigned int h = MCACHE_HASH_METHOD(type, name); - struct type_cache *cache = get_type_cache(); - struct type_cache_entry *entry = &cache->hashtable[h]; -#ifdef Py_GIL_DISABLED - // synchronize-with other writing threads by doing an acquire load on the sequence - while (1) { - uint32_t sequence = _PySeqLock_BeginRead(&entry->sequence); - uint32_t entry_version = _Py_atomic_load_uint32_acquire(&entry->version); - uint32_t type_version = _Py_atomic_load_uint32_acquire(&type->tp_version_tag); - if (entry_version == type_version && - _Py_atomic_load_ptr_relaxed(&entry->name) == name) { + int cacheable = MCACHE_CACHEABLE_NAME(name); + if (cacheable) { + struct _PyTypeCacheLookupResult r = _PyTypeCache_Lookup(type, name); + if (r.cache_hit) { OBJECT_STAT_INC_COND(type_cache_hits, !is_dunder_name(name)); OBJECT_STAT_INC_COND(type_cache_dunder_hits, is_dunder_name(name)); - if (_Py_TryXGetStackRef(&entry->value, out)) { - // If the sequence is still valid then we're done - if (_PySeqLock_EndRead(&entry->sequence, sequence)) { - return entry_version; - } - PyStackRef_XCLOSE(*out); - } - else { - // If we can't incref the object we need to fallback to locking - break; - } - } - else { - // cache miss - break; + *out = r.value; + return r.version_tag; } } -#else - if (entry->version == type->tp_version_tag && entry->name == name) { - assert(type->tp_version_tag); - OBJECT_STAT_INC_COND(type_cache_hits, !is_dunder_name(name)); - OBJECT_STAT_INC_COND(type_cache_dunder_hits, is_dunder_name(name)); - *out = entry->value ? PyStackRef_FromPyObjectNew(entry->value) : PyStackRef_NULL; - return entry->version; - } -#endif OBJECT_STAT_INC_COND(type_cache_misses, !is_dunder_name(name)); OBJECT_STAT_INC_COND(type_cache_dunder_misses, is_dunder_name(name)); @@ -6354,14 +6323,25 @@ _PyType_LookupStackRefAndVersion(PyTypeObject *type, PyObject *name, _PyStackRef PyInterpreterState *interp = _PyInterpreterState_GET(); unsigned int version_tag = FT_ATOMIC_LOAD_UINT(type->tp_version_tag); - if (should_assign_version_tag(type, name, version_tag)) { + if (cacheable && + (version_tag != 0 || should_assign_version_tag(type, name, version_tag))) + { BEGIN_TYPE_LOCK(); - assign_version_tag(interp, type); version_tag = type->tp_version_tag; + if (version_tag == 0) { + assign_version_tag(interp, type); + version_tag = type->tp_version_tag; + } res = find_name_in_mro(type, name, out); + // find_name_in_mro can release the type lock and another thread can + // modify the type, so we need to check version tag again before caching the result. + if (res >= 0 && version_tag != 0 && version_tag == type->tp_version_tag) { + _PyTypeCache_Insert(type, name, PyStackRef_AsPyObjectBorrow(*out)); + } END_TYPE_LOCK(); } else { + version_tag = 0; res = find_name_in_mro(type, name, out); } @@ -6371,17 +6351,6 @@ _PyType_LookupStackRefAndVersion(PyTypeObject *type, PyObject *name, _PyStackRef return 0; } - if (version_tag == 0 || !MCACHE_CACHEABLE_NAME(name)) { - return 0; - } - - PyObject *res_obj = PyStackRef_AsPyObjectBorrow(*out); -#if Py_GIL_DISABLED - update_cache_gil_disabled(entry, name, version_tag, res_obj); -#else - PyObject *old_value = update_cache(entry, name, version_tag, res_obj); - Py_DECREF(old_value); -#endif return version_tag; } @@ -6506,23 +6475,19 @@ void _PyType_SetFlagsRecursive(PyTypeObject *self, unsigned long mask, unsigned long flags) { BEGIN_TYPE_LOCK(); - /* Ideally, changing flags and invalidating the old version tag would - happen in one step. But _PyType_Modified_Unlocked() is re-entrant and - cannot run with the world stopped, so we must invalidate first. - Immutable/static-builtin types are skipped because - set_flags_recursive() does not modify them. */ - if (!PyType_HasFeature(self, Py_TPFLAGS_IMMUTABLETYPE) && - (self->tp_flags & mask) != flags) - { - _PyType_Modified_Unlocked(self); - } - /* Keep TYPE_LOCK held while waiting for stop-the-world so no thread - can reassign a version tag before the flag update. */ - type_lock_prevent_release(); + // Immutable/static-builtin types are skipped because + // set_flags_recursive() does not modify them. + int modified = (!PyType_HasFeature(self, Py_TPFLAGS_IMMUTABLETYPE) && + (self->tp_flags & mask) != flags); types_stop_world(); set_flags_recursive(self, mask, flags); types_start_world(); - type_lock_allow_release(); + // Invalidate the version tags after update, while TYPE_LOCK is + // still held. + ASSERT_TYPE_LOCK_HELD(); + if (modified) { + _PyType_Modified_Unlocked(self); + } END_TYPE_LOCK(); } @@ -6697,9 +6662,11 @@ type_update_dict(PyTypeObject *type, PyDictObject *dict, PyObject *name, // We don't want any re-entrancy between when we update the dict // and call _PyType_Modified_Unlocked, including running the destructor // of the current value as it can observe the cache in an inconsistent - // state. Because we have an exact unicode and our dict has exact - // unicodes we know that this will all complete without releasing - // the locks. + // state. The name is an exact unicode (see type_setattro()) and + // str subclass keys are copied to exact str by type_new_copy_dict() + // and type_setattro(). The type dict can still hold non-str keys + // (type_new_impl() only warns about them) and comparing with one of + // those can run user code that releases the locks. if (_PyDict_GetItemRef_Unicode_LockHeld(dict, name, old_value) < 0) { return -1; } @@ -6725,25 +6692,19 @@ type_update_dict(PyTypeObject *type, PyDictObject *dict, PyObject *name, static int update_slot_after_setattr(PyTypeObject *type, PyObject *name) { + types_stop_world(); + int res = update_slot(type, name); + types_start_world(); #ifdef Py_GIL_DISABLED - // stack allocate one chunk since that's all we need - assert(SLOT_UPDATE_CHUNK_SIZE >= MAX_EQUIV); - slot_update_chunk_t chunk = {0}; - slot_update_t queued_updates = {&chunk}; - - if (update_slot(type, name, &queued_updates) < 0) { - return -1; - } - if (queued_updates.head->n > 0) { - apply_type_slot_updates(&queued_updates); - ASSERT_TYPE_LOCK_HELD(); - // should never allocate another chunk - assert(chunk.prev == NULL); - } -#else - update_slot(type, name, NULL); + // Invalidate again, after the slots are updated and while TYPE_LOCK is + // still held. Other threads may have assigned new version tags while + // the lock was released waiting for the stop-the-world and cached + // decisions based on the old slots. This is a no-op if the tags are + // still invalid. + ASSERT_TYPE_LOCK_HELD(); + _PyType_Modified_Unlocked(type); #endif - return 0; + return res; } static int @@ -6840,7 +6801,8 @@ type_setattro(PyObject *self, PyObject *name, PyObject *value) done: Py_DECREF(name); Py_XDECREF(descr); - Py_XDECREF(old_value); + // delay decref of the old value as lock-free type cache readers may access it + _PyObject_XDecRefDelayed(old_value); return res; } @@ -6851,7 +6813,9 @@ type_dealloc_common(PyTypeObject *type) PyObject *bases = lookup_tp_bases(type); if (bases != NULL) { PyObject *exc = PyErr_GetRaisedException(); + BEGIN_TYPE_LOCK(); remove_all_subclasses(type, bases); + END_TYPE_LOCK(); PyErr_SetRaisedException(exc); } } @@ -6912,6 +6876,7 @@ clear_static_type_objects(PyInterpreterState *interp, PyTypeObject *type, if (final) { Py_CLEAR(type->tp_cache); } + _PyTypeCache_Invalidate(type); clear_tp_dict(type); clear_tp_bases(type, final); clear_tp_mro(type, final); @@ -7022,6 +6987,7 @@ type_dealloc(PyObject *self) Py_XDECREF(type->tp_mro); Py_XDECREF(type->tp_cache); clear_tp_subclasses(type); + _PyTypeCache_Invalidate(type); /* A type's tp_doc is heap allocated, unlike the tp_doc slots * of most other objects. It's okay to cast it to char *. @@ -7570,7 +7536,9 @@ _Py_BaseObject_RichCompare(PyObject* self, PyObject* other, int op) static PyObject * object_get_class(PyObject *self, void *closure) { - return Py_NewRef(Py_TYPE(self)); + PyTypeObject *type = Py_TYPE(self); + _Py_INCREF_TYPE(type); + return (PyObject *)type; } static int @@ -7584,6 +7552,24 @@ compatible_with_tp_base(PyTypeObject *child) child->tp_dealloc == parent->tp_dealloc)); } +// Compare two ht_slots tuples by string content, without calling a user +// __eq__, since this can be called with the world stopped. +static int +same_slot_names(PyObject *slots_a, PyObject *slots_b) +{ + Py_ssize_t n = PyTuple_GET_SIZE(slots_a); + if (n != PyTuple_GET_SIZE(slots_b)) { + return 0; + } + for (Py_ssize_t i = 0; i < n; i++) { + if (!_PyUnicode_Equal(PyTuple_GET_ITEM(slots_a, i), + PyTuple_GET_ITEM(slots_b, i))) { + return 0; + } + } + return 1; +} + static int same_slots_added(PyTypeObject *a, PyTypeObject *b) { @@ -7606,7 +7592,7 @@ same_slots_added(PyTypeObject *a, PyTypeObject *b) slots_a = ((PyHeapTypeObject *)a)->ht_slots; slots_b = ((PyHeapTypeObject *)b)->ht_slots; if (slots_a && slots_b) { - if (PyObject_RichCompareBool(slots_a, slots_b, Py_EQ) != 1) + if (!same_slot_names(slots_a, slots_b)) return 0; size += sizeof(PyObject *) * PyTuple_GET_SIZE(slots_a); } @@ -7624,28 +7610,21 @@ compatible_flags(int setclass, PyTypeObject *origto, PyTypeObject *newto, unsign : !(~(origto->tp_flags & flags) & (newto->tp_flags & flags)); } +// Return 1 if the object layout of 'newto' is compatible with 'origto' (for +// __class__ assignment) or with the base of 'origto' (for __bases__ +// assignment), else 0. Does not raise and does not run user code. static int -compatible_for_assignment(PyTypeObject *origto, PyTypeObject *newto, - const char *attr, int setclass) +compatible_layout(PyTypeObject *origto, PyTypeObject *newto, int setclass) { PyTypeObject *newbase, *oldbase; PyTypeObject *oldto = setclass ? origto : origto->tp_base; - if (setclass && newto->tp_free != oldto->tp_free) { - PyErr_Format(PyExc_TypeError, - "%s assignment: " - "'%s' deallocator differs from '%s'", - attr, - newto->tp_name, - oldto->tp_name); - return 0; - } if (!compatible_flags(setclass, origto, newto, Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_INLINE_VALUES | Py_TPFLAGS_PREHEADER)) { - goto differs; + return 0; } /* For __class__ assignment, tp_dictoffset and tp_weaklistoffset should be the same for old and new types. @@ -7655,12 +7634,12 @@ compatible_for_assignment(PyTypeObject *origto, PyTypeObject *newto, if ((setclass || newto->tp_dictoffset) && origto->tp_dictoffset != newto->tp_dictoffset) { - goto differs; + return 0; } if ((setclass || newto->tp_weaklistoffset) && origto->tp_weaklistoffset != newto->tp_weaklistoffset) { - goto differs; + return 0; } /* It's tricky to tell if two arbitrary types are sufficiently compatible as @@ -7681,17 +7660,43 @@ compatible_for_assignment(PyTypeObject *origto, PyTypeObject *newto, if (newbase != oldbase && (newbase->tp_base != oldbase->tp_base || !same_slots_added(newbase, oldbase))) { - goto differs; + return 0; } return 1; -differs: +} + +static void +raise_layout_differs(const char *attr, PyTypeObject *newto, + PyTypeObject *oldto) +{ PyErr_Format(PyExc_TypeError, "%s assignment: " "'%s' object layout differs from '%s'", attr, newto->tp_name, oldto->tp_name); - return 0; +} + +static int +compatible_for_assignment(PyTypeObject *origto, PyTypeObject *newto, + const char *attr, int setclass) +{ + PyTypeObject *oldto = setclass ? origto : origto->tp_base; + + if (setclass && newto->tp_free != oldto->tp_free) { + PyErr_Format(PyExc_TypeError, + "%s assignment: " + "'%s' deallocator differs from '%s'", + attr, + newto->tp_name, + oldto->tp_name); + return 0; + } + if (!compatible_layout(origto, newto, setclass)) { + raise_layout_differs(attr, newto, oldto); + return 0; + } + return 1; } @@ -8811,10 +8816,23 @@ overrides_hash(PyTypeObject *type) PyObject *dict = lookup_tp_dict(type); assert(dict != NULL); +#ifdef Py_GIL_DISABLED + // Ignore non-str keys, consistent with find_slot_name_in_mro(). + _PyStackRef ref; + int r = _PyDict_GetItemStackRef_ExactUnicode( + (PyDictObject *)dict, &_Py_ID(__eq__), &ref); + PyStackRef_XCLOSE(ref); + if (r == 0) { + r = _PyDict_GetItemStackRef_ExactUnicode( + (PyDictObject *)dict, &_Py_ID(__hash__), &ref); + PyStackRef_XCLOSE(ref); + } +#else int r = PyDict_Contains(dict, &_Py_ID(__eq__)); if (r == 0) { r = PyDict_Contains(dict, &_Py_ID(__hash__)); } +#endif return r; } @@ -9119,7 +9137,7 @@ type_ready_set_bases(PyTypeObject *type, int initial) if (bases == NULL) { return -1; } - set_tp_bases(type, bases, 1); + set_tp_bases(type, bases); } return 0; } @@ -9525,7 +9543,7 @@ type_ready_post_checks(PyTypeObject *type) static int -type_ready(PyTypeObject *type, int initial) +type_ready(PyTypeObject *type, int initial, int add_subclasses) { ASSERT_TYPE_LOCK_HELD(); @@ -9536,6 +9554,8 @@ type_ready(PyTypeObject *type, int initial) goto error; } + _PyTypeCache_InitType(type); + #ifdef Py_TRACE_REFS /* PyType_Ready is the closest thing we have to a choke point * for type objects, so is the best place I can think of to try @@ -9578,8 +9598,10 @@ type_ready(PyTypeObject *type, int initial) if (type_ready_set_hash(type) < 0) { goto error; } - if (type_ready_add_subclasses(type) < 0) { - goto error; + if (add_subclasses) { + if (type_ready_add_subclasses(type) < 0) { + goto error; + } } if (initial) { if (type_ready_managed_dict(type) < 0) { @@ -9590,11 +9612,13 @@ type_ready(PyTypeObject *type, int initial) } } - /* All done -- set the ready flag */ - if (initial) { - type_add_flags(type, Py_TPFLAGS_READY); - } else { - assert(type->tp_flags & Py_TPFLAGS_READY); + if (add_subclasses) { + /* All done -- set the ready flag */ + if (initial) { + type_add_flags(type, Py_TPFLAGS_READY); + } else { + assert(type->tp_flags & Py_TPFLAGS_READY); + } } stop_readying(type); @@ -9607,6 +9631,46 @@ type_ready(PyTypeObject *type, int initial) return -1; } +static int +type_ready_publish(PyTypeObject *type, int fix_slots) +{ + int res; + BEGIN_TYPE_LOCK(); + res = type_ready(type, 1, 0); + if (res == 0) { + assert(!(type->tp_flags & Py_TPFLAGS_READY)); + assert(!is_readying(type)); + + if (fix_slots) { + // Put the proper slots in place and only then publish the type as + // a subclass of its bases. Since the type is not reachable by + // other threads before it is published, the slots can be updated + // without stopping the world. This step is skipped for + // type_from_slots_or_spec(). + fixup_slot_dispatchers(type); + } + + // Set the ready flag before revealing the type since type_add_flags() + // may only be used on types that are not yet revealed. + type_add_flags(type, Py_TPFLAGS_READY); + +#if defined(Py_GIL_DISABLED) && defined(Py_DEBUG) && SIZEOF_VOID_P > 4 + // Mark the type as revealed while still holding the type lock. + // Threads can only find the type through the subclasses of its bases, + // which is done below with the lock held. So, they cannot see the + // type before the flag is set. + ((PyObject*)type)->ob_flags |= _Py_TYPE_REVEALED_FLAG; +#endif + + res = type_ready_add_subclasses(type); + if (res == 0) { + assert(_PyType_CheckConsistency(type)); + } + } + END_TYPE_LOCK(); + return res; +} + int PyType_Ready(PyTypeObject *type) { @@ -9626,7 +9690,7 @@ PyType_Ready(PyTypeObject *type) int res; BEGIN_TYPE_LOCK(); if (!(type->tp_flags & Py_TPFLAGS_READY)) { - res = type_ready(type, 1); + res = type_ready(type, 1, 1); } else { res = 0; assert(_PyType_CheckConsistency(type)); @@ -9667,7 +9731,7 @@ init_static_type(PyInterpreterState *interp, PyTypeObject *self, int res; BEGIN_TYPE_LOCK(); - res = type_ready(self, initial); + res = type_ready(self, initial, 1); END_TYPE_LOCK(); if (res < 0) { _PyStaticType_ClearWeakRefs(interp, self); @@ -11786,6 +11850,62 @@ static pytype_slotdef slotdefs[] = { interpreter starts. */ static uint8_t slotdefs_dups[Py_ARRAY_LENGTH(slotdefs)][1 + MAX_EQUIV]; +/* Open-addressing hash table: slot name -> index of the first slotdef with + that name (slotdefs_dups[] lists the others). Entry 0 means "empty". + Built by _PyType_InitSlotDefs(). */ +#define SLOTNAME_TABLE_SIZE 512 +static uint16_t slotname_table[SLOTNAME_TABLE_SIZE]; +#ifndef NDEBUG +static bool slotname_table_initialized = false; +#endif + +static size_t +slotname_probe(PyObject *key, Py_hash_t hash) +{ + size_t i = (size_t)hash & (SLOTNAME_TABLE_SIZE - 1); + while (slotname_table[i] != 0) { + PyObject *name = slotdefs[slotname_table[i] - 1].name_strobj; + if (name == key + || (PyUnstable_Unicode_GET_CACHED_HASH(name) == hash + && _PyUnicode_Equal(name, key))) { + break; + } + i = (i + 1) & (SLOTNAME_TABLE_SIZE - 1); + } + return i; +} + +static void +init_slotname_table(void) +{ +#ifndef NDEBUG + slotname_table_initialized = true; +#endif + memset(slotname_table, 0, sizeof(slotname_table)); + for (size_t idx = 0; slotdefs[idx].name != NULL; idx++) { + PyObject *name = slotdefs[idx].name_strobj; + /* Computes and caches the hash of name_strobj if not done yet. */ + Py_hash_t hash = _PyObject_HashDictKey(name); + size_t i = slotname_probe(name, hash); + if (slotname_table[i] == 0) { + slotname_table[i] = (uint16_t)(idx + 1); + } + } + /* Keep the load factor low so probe sequences stay short. */ + Py_BUILD_ASSERT(4 * Py_ARRAY_LENGTH(slotdefs) <= SLOTNAME_TABLE_SIZE); +} + +/* Return the index of the first slotdef named 'key' (a str with hash + 'hash'), or -1 if 'key' is not a slot name. */ +static Py_ssize_t +slotname_lookup(PyObject *key, Py_hash_t hash) +{ + assert(slotname_table_initialized); + assert(hash != -1); + size_t i = slotname_probe(key, hash); + return slotname_table[i] ? slotname_table[i] - 1 : -1; +} + /* Given a type pointer and an offset gotten from a slotdef entry, return a pointer to the actual slot. This is not quite the same as simply adding the offset to the type pointer, since it takes care to indirect through the @@ -11833,12 +11953,84 @@ slotptr(PyTypeObject *type, int ioffset) static bool has_slotdef(PyObject *name) { - for (pytype_slotdef *p = slotdefs; p->name_strobj; p++) { - if (p->name_strobj == name) { - return true; + return slotname_lookup(name, _PyObject_HashDictKey(name)) >= 0; +} + +#define SLOT_SCAN_MAX_DICT_SIZE 1000 + +static void +clear_slot_descrs(PyObject **descrs) +{ + for (size_t i = 0; i < Py_ARRAY_LENGTH(slotdefs) - 1; i++) { + Py_CLEAR(descrs[i]); + } +} + +/* Scan the dicts along the MRO once and set descrs[i] to a strong reference + to what find_name_in_mro() (find_slot_name_in_mro() in the free-threaded + build) would return for slotdefs[i].name, or NULL. Dicts with keys that + are not exact str are not scanned. + Return -1 (descrs[] all NULL) if some dict cannot be scanned. */ +static int +collect_slot_descrs(PyTypeObject *type, PyObject **descrs) +{ + ASSERT_NEW_TYPE_OR_LOCKED(type); + PyObject *mro = lookup_tp_mro(type); + assert(mro != NULL && PyTuple_CheckExact(mro)); + memset(descrs, 0, sizeof(PyObject *) * (Py_ARRAY_LENGTH(slotdefs) - 1)); + Py_ssize_t mro_size = PyTuple_GET_SIZE(mro); + for (Py_ssize_t m = 0; m < mro_size; m++) { + PyObject *base = PyTuple_GET_ITEM(mro, m); + assert(PyType_Check(base)); + PyObject *dict = lookup_tp_dict(_PyType_CAST(base)); + assert(dict != NULL && PyDict_Check(dict)); +#ifdef Py_GIL_DISABLED + /* _PyDict_Next() needs the dict mutex, but we must not block for it: + blocking detaches the thread, which releases TYPE_LOCK and lets + another thread change a dict scanned earlier. Fall back instead. */ + PyMutex *mutex = &dict->ob_mutex; + if (!PyMutex_LockFast(mutex)) { + goto fail; + } +#endif + int ok = 1; + if (!DK_IS_UNICODE(((PyDictObject *)dict)->ma_keys) + || PyDict_GET_SIZE(dict) > SLOT_SCAN_MAX_DICT_SIZE) { + ok = 0; + } + else { + Py_ssize_t pos = 0; + PyObject *key, *value; + Py_hash_t hash; + while (_PyDict_Next(dict, &pos, &key, &value, &hash)) { + if (!is_dunder_name(key)) { + continue; + } + Py_ssize_t idx = slotname_lookup(key, hash); + if (idx < 0) { + continue; + } + /* First class in the MRO wins. */ + const uint8_t *dups = slotdefs_dups[idx]; + for (uint8_t k = 1; k <= dups[0]; k++) { + if (descrs[dups[k]] == NULL) { + descrs[dups[k]] = Py_NewRef(value); + } + } + } + } +#ifdef Py_GIL_DISABLED + PyMutex_Unlock(mutex); +#endif + if (!ok) { + goto fail; } } - return false; + return 0; + +fail: + clear_slot_descrs(descrs); + return -1; } /* Common code for update_slots_callback() and fixup_slot_dispatchers(). @@ -11895,17 +12087,18 @@ has_slotdef(PyObject *name) * When done, next_p is set to the next slotdef with a different offset, * because that's convenient for fixup_slot_dispatchers(). * - * If the queued_updates pointer is provided, the actual updates to the slot - * pointers are queued, rather than being immediately performed. That argument - * is only used for the free-threaded build since those updates need to be - * done while the world is stopped. + * In the free-threaded build, this is called with the world stopped for a + * type that has been revealed to other threads. The descriptors are looked + * up with find_slot_name_in_mro(), which ignores non-str dict keys. * - * This function will only return an error if the queued_updates argument is - * provided and allocating memory for the queue fails. Other exceptions that - * occur internally are ignored, such as when looking up descriptors. */ -static int + * If descrs is not NULL, it holds the descriptors found by + * collect_slot_descrs() and no lookups are done. + * + * Exceptions that occur internally are ignored, such as when looking up + * descriptors. */ +static void update_one_slot(PyTypeObject *type, pytype_slotdef *p, pytype_slotdef **next_p, - slot_update_t *queued_updates) + PyObject **descrs) { ASSERT_NEW_TYPE_OR_LOCKED(type); @@ -11932,14 +12125,27 @@ update_one_slot(PyTypeObject *type, pytype_slotdef *p, pytype_slotdef **next_p, if (next_p != NULL) { *next_p = p; } - return 0; + return; } /* We may end up clearing live exceptions below, so make sure it's ours. */ assert(!PyErr_Occurred()); do { - /* Use faster uncached lookup as we won't get any cache hits during type setup. */ _PyStackRef descr_ref; - int res = find_name_in_mro(type, p->name_strobj, &descr_ref); + int res; + if (descrs != NULL) { + /* Precomputed by collect_slot_descrs(), which owns the refs. */ + PyObject *found = descrs[p - slotdefs]; + res = (found != NULL); + descr_ref = res ? PyStackRef_FromPyObjectBorrow(found) : PyStackRef_NULL; + } + else { +#ifdef Py_GIL_DISABLED + res = find_slot_name_in_mro(type, p->name_strobj, &descr_ref); +#else + /* Use faster uncached lookup as we won't get any cache hits during type setup. */ + res = find_name_in_mro(type, p->name_strobj, &descr_ref); +#endif + } if (res <= 0) { if (ptr == (void**)&type->tp_iternext) { specific = (void *)_PyObject_NextNotImplemented; @@ -12030,9 +12236,7 @@ update_one_slot(PyTypeObject *type, pytype_slotdef *p, pytype_slotdef **next_p, } if (p->function == slot_tp_call) { /* A generic __call__ is incompatible with vectorcall */ - if (queued_updates == NULL) { - type_clear_flags(type, Py_TPFLAGS_HAVE_VECTORCALL); - } + type_clear_flags(type, Py_TPFLAGS_HAVE_VECTORCALL); } } PyStackRef_CLOSE(descr_ref); @@ -12045,26 +12249,12 @@ update_one_slot(PyTypeObject *type, pytype_slotdef *p, pytype_slotdef **next_p, slot_value = generic; } -#ifdef Py_GIL_DISABLED - if (queued_updates != NULL) { - // queue the update to perform later, while world is stopped - if (queue_slot_update(queued_updates, type, ptr, slot_value) < 0) { - return -1; - } - } else { - // do the update to the type structure now - *ptr = slot_value; - } -#else - // always do the update immediately - assert(queued_updates == NULL); + ASSERT_WORLD_STOPPED_OR_NEW_TYPE(type); *ptr = slot_value; -#endif if (next_p != NULL) { *next_p = p; } - return 0; } /* In the type, update the slots whose slotdefs are gathered in the pp array. @@ -12077,16 +12267,15 @@ update_slots_callback(PyTypeObject *type, void *data) update_callback_data_t *update_data = (update_callback_data_t *)data; pytype_slotdef **pp = update_data->defs; for (; *pp; pp++) { - if (update_one_slot(type, *pp, NULL, update_data->queued_updates) < 0) { - return -1; - } + update_one_slot(type, *pp, NULL, NULL); } return 0; } -/* Update the slots after assignment to a class (type) attribute. */ +/* Update the slots after assignment to a class (type) attribute. In the + free-threaded build, this is called with the world stopped. */ static int -update_slot(PyTypeObject *type, PyObject *name, slot_update_t *queued_updates) +update_slot(PyTypeObject *type, PyObject *name) { pytype_slotdef *ptrs[MAX_EQUIV]; pytype_slotdef *p; @@ -12097,158 +12286,97 @@ update_slot(PyTypeObject *type, PyObject *name, slot_update_t *queued_updates) assert(PyUnicode_CheckExact(name)); assert(PyUnicode_CHECK_INTERNED(name)); - pp = ptrs; - for (p = slotdefs; p->name; p++) { - assert(PyUnicode_CheckExact(p->name_strobj)); - assert(PyUnicode_CHECK_INTERNED(p->name_strobj)); - assert(PyUnicode_CheckExact(name)); - /* bpo-40521: Using interned strings. */ - if (p->name_strobj == name) { - *pp++ = p; - } + Py_ssize_t idx = slotname_lookup(name, _PyObject_HashDictKey(name)); + if (idx < 0) { + return 0; /* Not an attribute that affects any slots */ } - *pp = NULL; - for (pp = ptrs; *pp; pp++) { - p = *pp; + /* All slotdefs with this name, in slotdefs order. */ + const uint8_t *dups = slotdefs_dups[idx]; + pp = ptrs; + for (uint8_t k = 1; k <= dups[0]; k++) { + p = &slotdefs[dups[k]]; offset = p->offset; while (p > slotdefs && (p-1)->offset == offset) --p; - *pp = p; + *pp++ = p; } - if (ptrs[0] == NULL) - return 0; /* Not an attribute that affects any slots */ + *pp = NULL; update_callback_data_t callback_data; callback_data.defs = ptrs; - callback_data.queued_updates = queued_updates; return update_subclasses(type, name, update_slots_callback, (void *)&callback_data); } /* Store the proper functions in the slot dispatches at class (type) definition time, based upon which operations the class overrides in its - dict. */ + dict. The type must not be revealed to other threads yet, so that the + slots can be updated directly rather than with the world stopped. */ static void fixup_slot_dispatchers(PyTypeObject *type) { + ASSERT_TYPE_LOCK_HELD(); + ASSERT_WORLD_STOPPED_OR_NEW_TYPE(type); assert(!PyErr_Occurred()); - for (pytype_slotdef *p = slotdefs; p->name; ) { - update_one_slot(type, p, &p, NULL); + PyObject *descrs_buf[Py_ARRAY_LENGTH(slotdefs) - 1]; + PyObject **descrs = descrs_buf; + if (collect_slot_descrs(type, descrs_buf) < 0) { + descrs = NULL; } -} - -#ifdef Py_GIL_DISABLED - -// Called when __bases__ is re-assigned. -static int -update_all_slots(PyTypeObject* type) -{ - // Note that update_slot() can fail due to out-of-memory when allocating - // the queue chunks to hold the updates. That's unlikely since the number - // of updates is normally small but we handle that case. update_slot() - // can fail internally for other reasons (a lookup fails) but those - // errors are suppressed. - slot_update_t queued_updates = {0}; - for (pytype_slotdef *p = slotdefs; p->name; p++) { - if (update_slot(type, p->name_strobj, &queued_updates) < 0) { - if (queued_updates.head) { - slot_update_free_chunks(&queued_updates); - } - return -1; - } + for (pytype_slotdef *p = slotdefs; p->name; ) { + update_one_slot(type, p, &p, descrs); } - if (queued_updates.head != NULL) { - apply_type_slot_updates(&queued_updates); - ASSERT_TYPE_LOCK_HELD(); - slot_update_free_chunks(&queued_updates); + if (descrs != NULL) { + clear_slot_descrs(descrs); } - return 0; } -#else - -// Called when __bases__ is re-assigned. -static int +// Called when __bases__ is re-assigned. Also clears the VALID_VERSION +// flag of 'type' and all its subclasses. +static void update_all_slots(PyTypeObject* type) { - pytype_slotdef *p; - for (p = slotdefs; p->name; p++) { + types_stop_world(); + for (pytype_slotdef *p = slotdefs; p->name; p++) { /* update_slot returns int but can't actually fail in this case*/ - update_slot(type, p->name_strobj, NULL); + update_slot(type, p->name_strobj); } - return 0; + types_start_world(); + // Invalidate the version tags after the slots are updated, while + // TYPE_LOCK is still held: see update_slot_after_setattr(). + _PyType_Modified_Unlocked(type); } -#endif - int _PyType_InitSlotDefs(PyInterpreterState *interp) { if (!_Py_IsMainInterpreter(interp)) { return 0; } - PyObject *bytearray = NULL; - PyObject *cache = PyDict_New(); - if (!cache) { - return -1; - } + init_slotname_table(); - pytype_slotdef *p; - Py_ssize_t idx = 0; - for (p = slotdefs; p->name_strobj; p++, idx++) { + /* Group the slotdefs by name: slotdefs_dups[i] lists the indices of + all slotdefs with the same name as slotdefs[i], in slotdefs order. */ + memset(slotdefs_dups, 0, sizeof(slotdefs_dups)); + for (Py_ssize_t idx = 0; slotdefs[idx].name_strobj != NULL; idx++) { assert(idx < 255); - - if (PyDict_GetItemRef(cache, p->name_strobj, &bytearray) < 0) { - goto error; - } - - if (!bytearray) { - Py_ssize_t size = sizeof(uint8_t) * (1 + MAX_EQUIV); - bytearray = PyByteArray_FromStringAndSize(NULL, size); - if (!bytearray) { - goto error; - } - - uint8_t *data = (uint8_t *)PyByteArray_AS_STRING(bytearray); - data[0] = 0; - - if (PyDict_SetItem(cache, p->name_strobj, bytearray) < 0) { - goto error; - } - } - - assert(PyByteArray_CheckExact(bytearray)); - uint8_t *data = (uint8_t *)PyByteArray_AS_STRING(bytearray); - + PyObject *name = slotdefs[idx].name_strobj; + Py_ssize_t first = slotname_lookup(name, _PyObject_HashDictKey(name)); + assert(first >= 0 && first <= idx); + uint8_t *data = slotdefs_dups[first]; data[0] += 1; assert(data[0] < MAX_EQUIV); - data[data[0]] = (uint8_t)idx; - - Py_CLEAR(bytearray); } - - memset(slotdefs_dups, -1, sizeof(slotdefs_dups)); - - Py_ssize_t pos = 0; - PyObject *key = NULL; - PyObject *value = NULL; - while (PyDict_Next(cache, &pos, &key, &value)) { - uint8_t *data = (uint8_t *)PyByteArray_AS_STRING(value); - uint8_t n = data[0]; - for (uint8_t i = 0; i < n; i++) { - uint8_t idx = data[i + 1]; - memcpy(&slotdefs_dups[idx], data, sizeof(uint8_t) * (n + 1)); + for (Py_ssize_t idx = 0; slotdefs[idx].name_strobj != NULL; idx++) { + PyObject *name = slotdefs[idx].name_strobj; + Py_ssize_t first = slotname_lookup(name, _PyObject_HashDictKey(name)); + if (first != idx) { + memcpy(slotdefs_dups[idx], slotdefs_dups[first], + sizeof(slotdefs_dups[idx])); } } - - Py_DECREF(cache); return 0; - -error: - Py_XDECREF(bytearray); - Py_DECREF(cache); - return -1; } @@ -12375,6 +12503,31 @@ recurse_down_subclasses(PyTypeObject *type, PyObject *attr_name, Py_ssize_t i = 0; PyObject *ref; while (PyDict_Next(subclasses, &i, NULL, &ref)) { +#ifdef Py_GIL_DISABLED + // With the world stopped, use borrowed references to the subclasses, + // so that dropping a reference cannot run type_dealloc(). Look up + // attr_name without calling __eq__ of non-str keys, consistent with + // find_slot_name_in_mro(). + assert(types_world_is_stopped()); + if (_PyWeakref_IS_DEAD(ref)) { + continue; + } + PyTypeObject *subclass = + _PyType_CAST(((PyWeakReference *)ref)->wr_object); + + /* Avoid recursing down into unaffected classes */ + PyObject *dict = lookup_tp_dict(subclass); + if (dict != NULL && PyDict_Check(dict) && + _PyDict_GetItem_ExactUnicode((PyDictObject *)dict, + attr_name) != NULL) + { + continue; + } + + if (update_subclasses(subclass, attr_name, callback, data) < 0) { + return -1; + } +#else PyTypeObject *subclass = type_from_ref(ref); if (subclass == NULL) { continue; @@ -12399,6 +12552,7 @@ recurse_down_subclasses(PyTypeObject *type, PyObject *attr_name, return -1; } Py_DECREF(subclass); +#endif } return 0; } diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index b2c3c79c93ff195..11ff8320fd9a487 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -958,6 +958,7 @@ paramspecattr_dealloc(PyObject *self) _PyObject_GC_UNTRACK(self); Py_XDECREF(psa->__origin__); + PyObject_ClearWeakRefs(self); Py_TYPE(self)->tp_free(self); Py_DECREF(tp); @@ -1898,14 +1899,23 @@ typealias_dealloc(PyObject *self) static PyObject * typealias_get_value(typealiasobject *ta) { - if (ta->value != NULL) { - return Py_NewRef(ta->value); + PyObject *result; + Py_BEGIN_CRITICAL_SECTION(ta); + result = Py_XNewRef(ta->value); + Py_END_CRITICAL_SECTION(); + if (result != NULL) { + return result; } - PyObject *result = PyObject_CallNoArgs(ta->compute_value); + result = PyObject_CallNoArgs(ta->compute_value); if (result == NULL) { return NULL; } + PyObject *old_value; + Py_BEGIN_CRITICAL_SECTION(ta); + old_value = ta->value; ta->value = Py_NewRef(result); + Py_END_CRITICAL_SECTION(); + Py_XDECREF(old_value); return result; } @@ -2145,7 +2155,7 @@ typealias.__new__ as typealias_new name: object(subclass_of="&PyUnicode_Type") value: object * - type_params: object = NULL + type_params: object(c_default="NULL") = () qualname: object(c_default="NULL") = None Create a TypeAliasType. @@ -2154,7 +2164,7 @@ Create a TypeAliasType. static PyObject * typealias_new_impl(PyTypeObject *type, PyObject *name, PyObject *value, PyObject *type_params, PyObject *qualname) -/*[clinic end generated code: output=b7f6d9f1c577cd9c input=cbec290f8c4886ef]*/ +/*[clinic end generated code: output=b7f6d9f1c577cd9c input=6516623275f87b5e]*/ { if (type_params != NULL && !PyTuple_Check(type_params)) { PyErr_SetString(PyExc_TypeError, "type_params must be a tuple"); @@ -2358,6 +2368,9 @@ _Py_subscript_generic(PyThreadState* unused, PyObject *params) return NULL; } params = unpack_typevartuples(params); + if (params == NULL) { + return NULL; + } PyObject *args[2] = {(PyObject *)interp->cached_objects.generic_type, params}; PyObject *result = call_typing_func_object("_GenericAlias", args, 2); Py_DECREF(params); diff --git a/Objects/unicode_format.c b/Objects/unicode_format.c index 1d6f3f7d9a6f6a0..b090a68d2bda9f7 100644 --- a/Objects/unicode_format.c +++ b/Objects/unicode_format.c @@ -564,6 +564,10 @@ unicode_format_arg_parse(struct unicode_formatter_t *ctx, return -1; } if (arg->width < 0) { + if (arg->width == PY_SSIZE_T_MIN) { + FORMAT_ERROR(PyExc_OverflowError, "too big for width%s", ""); + return -1; + } arg->flags |= F_LJUST; arg->width = -arg->width; } @@ -571,6 +575,7 @@ unicode_format_arg_parse(struct unicode_formatter_t *ctx, arg->ch = FORMAT_READ(ctx); ctx->fmtpos++; } + assert(arg->width >= 0); } else if (arg->ch >= '0' && arg->ch <= '9') { arg->width = arg->ch - '0'; @@ -590,6 +595,7 @@ unicode_format_arg_parse(struct unicode_formatter_t *ctx, } arg->width = arg->width*10 + (arg->ch - '0'); } + assert(arg->width >= 0); } /* Parse precision. Example: "%.3f" => prec=3 */ @@ -645,6 +651,7 @@ unicode_format_arg_parse(struct unicode_formatter_t *ctx, arg->prec = arg->prec*10 + (arg->ch - '0'); } } + assert(arg->prec >= 0); } /* Ignore "h", "l" and "L" format prefix (ex: "%hi" or "%ls") */ @@ -701,24 +708,27 @@ unicode_format_arg_format(struct unicode_formatter_t *ctx, case 's': case 'r': case 'a': - if (PyLong_CheckExact(v) && arg->width == -1 && arg->prec == -1) { - /* Fast path */ - if (_PyLong_FormatWriter(writer, v, 10, arg->flags & F_ALT) == -1) - return -1; - return 1; + if (arg->width < 0 && arg->prec < 0) { + if (arg->ch == 's') { + if (PyUnicodeWriter_WriteStr((PyUnicodeWriter*)writer, v) < 0) { + return -1; + } + return 1; + } + else if (arg->ch == 'r') { + if (PyUnicodeWriter_WriteRepr((PyUnicodeWriter*)writer, v) < 0) { + return -1; + } + return 1; + } } - if (PyUnicode_CheckExact(v) && arg->ch == 's') { - *p_str = Py_NewRef(v); - } - else { - if (arg->ch == 's') - *p_str = PyObject_Str(v); - else if (arg->ch == 'r') - *p_str = PyObject_Repr(v); - else - *p_str = PyObject_ASCII(v); - } + if (arg->ch == 's') + *p_str = PyObject_Str(v); + else if (arg->ch == 'r') + *p_str = PyObject_Repr(v); + else + *p_str = PyObject_ASCII(v); break; case 'i': diff --git a/Objects/unicode_formatter.c b/Objects/unicode_formatter.c index b8604d1355940a5..7f0e0584f3813f3 100644 --- a/Objects/unicode_formatter.c +++ b/Objects/unicode_formatter.c @@ -892,8 +892,10 @@ calc_number_widths(NumberFieldWidths *spec, Py_ssize_t n_prefix, if (spec->n_lpadding || spec->n_spadding || spec->n_rpadding) *maxchar = Py_MAX(*maxchar, format->fill_char); - if (spec->n_decimal) - *maxchar = Py_MAX(*maxchar, PyUnicode_MAX_CHAR_VALUE(locale->decimal_point)); + if (spec->n_decimal) { + Py_UCS4 point_maxchar = PyUnicode_MAX_CHAR_VALUE(locale->decimal_point); + *maxchar = Py_MAX(*maxchar, point_maxchar); + } return spec->n_lpadding + spec->n_sign + spec->n_prefix + spec->n_spadding + spec->n_grouped_digits + spec->n_decimal + @@ -1256,6 +1258,9 @@ format_long_internal(PyObject *value, const InternalFormatSpec *format, goto done; } tmp = PyUnicode_FromOrdinal(x); + if (tmp == NULL) { + goto done; + } inumeric_chars = 0; n_digits = 1; maxchar = Py_MAX(maxchar, (Py_UCS4)x); @@ -1347,6 +1352,7 @@ format_long_internal(PyObject *value, const InternalFormatSpec *format, if (n_total == -1) { goto done; } + assert(n_total >= 1); /* Allocate the memory. */ if (_PyUnicodeWriter_Prepare(writer, n_total, maxchar) == -1) @@ -1501,6 +1507,7 @@ format_float_internal(PyObject *value, if (n_total == -1) { goto done; } + assert(n_total >= 1); /* Allocate the memory. */ if (_PyUnicodeWriter_Prepare(writer, n_total, maxchar) == -1) @@ -1712,6 +1719,7 @@ format_complex_internal(PyObject *value, /* Add 1 for the 'j', and optionally 2 for parens. */ calc_padding(n_re_total + n_im_total + 1 + add_parens * 2, format->width, format->align, &lpad, &rpad, &total); + assert(total >= 1); if (lpad || rpad) maxchar = Py_MAX(maxchar, format->fill_char); diff --git a/Objects/unicode_writer.c b/Objects/unicode_writer.c index a753c9b971c702c..8046accfd7e2abb 100644 --- a/Objects/unicode_writer.c +++ b/Objects/unicode_writer.c @@ -62,83 +62,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "stringlib/undef.h" -/* Copy an ASCII or latin1 char* string into a Python Unicode string. - - WARNING: The function doesn't copy the terminating null character and - doesn't check the maximum character (may write a latin1 character in an - ASCII string). */ -static void -unicode_write_cstr(PyObject *unicode, Py_ssize_t index, - const char *str, Py_ssize_t len) -{ - int kind = PyUnicode_KIND(unicode); - const void *data = PyUnicode_DATA(unicode); - const char *end = str + len; - - assert(index + len <= PyUnicode_GET_LENGTH(unicode)); - switch (kind) { - case PyUnicode_1BYTE_KIND: { -#ifdef Py_DEBUG - if (PyUnicode_IS_ASCII(unicode)) { - Py_UCS4 maxchar = ucs1lib_find_max_char( - (const Py_UCS1*)str, - (const Py_UCS1*)str + len); - assert(maxchar < 128); - } -#endif - memcpy((char *) data + index, str, len); - break; - } - case PyUnicode_2BYTE_KIND: { - Py_UCS2 *start = (Py_UCS2 *)data + index; - Py_UCS2 *ucs2 = start; - - for (; str < end; ++ucs2, ++str) - *ucs2 = (Py_UCS2)*str; - - assert((ucs2 - start) <= PyUnicode_GET_LENGTH(unicode)); - break; - } - case PyUnicode_4BYTE_KIND: { - Py_UCS4 *start = (Py_UCS4 *)data + index; - Py_UCS4 *ucs4 = start; - - for (; str < end; ++ucs4, ++str) - *ucs4 = (Py_UCS4)*str; - - assert((ucs4 - start) <= PyUnicode_GET_LENGTH(unicode)); - break; - } - default: - Py_UNREACHABLE(); - } -} - - -static inline void -_PyUnicodeWriter_Update(_PyUnicodeWriter *writer) -{ - writer->maxchar = PyUnicode_MAX_CHAR_VALUE(writer->buffer); - writer->data = PyUnicode_DATA(writer->buffer); - - if (!writer->readonly) { - writer->kind = PyUnicode_KIND(writer->buffer); - writer->size = PyUnicode_GET_LENGTH(writer->buffer); - } - else { - /* use a value smaller than PyUnicode_1BYTE_KIND() so - _PyUnicodeWriter_PrepareKind() will copy the buffer. */ - writer->kind = 0; - assert(writer->kind <= PyUnicode_1BYTE_KIND); - - /* Copy-on-write mode: set buffer size to 0 so - * _PyUnicodeWriter_Prepare() will copy (and enlarge) the buffer on - * next write. */ - writer->size = 0; - } -} - - void _PyUnicodeWriter_Init(_PyUnicodeWriter *writer) { @@ -175,17 +98,17 @@ PyUnicodeWriter_Create(Py_ssize_t length) _PyUnicodeWriter *writer = (_PyUnicodeWriter *)pub_writer; _PyUnicodeWriter_Init(writer); - if (_PyUnicodeWriter_Prepare(writer, length, 127) < 0) { - PyUnicodeWriter_Discard(pub_writer); - return NULL; - } + // The buffer is created lazily at the first write, except if + // the read-only optimization is used. + writer->min_length = length; writer->overallocate = 1; return pub_writer; } -void PyUnicodeWriter_Discard(PyUnicodeWriter *writer) +void +PyUnicodeWriter_Discard(PyUnicodeWriter *writer) { if (writer == NULL) { return; @@ -199,10 +122,12 @@ void PyUnicodeWriter_Discard(PyUnicodeWriter *writer) void _PyUnicodeWriter_InitWithBuffer(_PyUnicodeWriter *writer, PyObject *buffer) { + assert(PyUnstable_Object_IsUniquelyReferenced(buffer)); + memset(writer, 0, sizeof(*writer)); - writer->buffer = buffer; - _PyUnicodeWriter_Update(writer); + _PyUnicodeWriter_SetBuffer(writer, buffer); writer->min_length = writer->size; + assert(_PyUnicodeWriter_CanWrite(writer)); } @@ -210,75 +135,80 @@ int _PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer, Py_ssize_t length, Py_UCS4 maxchar) { - Py_ssize_t newlen; - PyObject *newbuffer; - assert(length >= 0); assert(maxchar <= _Py_MAX_UNICODE); - /* ensure that the _PyUnicodeWriter_Prepare macro was used */ - assert((maxchar > writer->maxchar && length >= 0) - || length > 0); + // Check that _PyUnicodeWriter_Prepare() or _PyUnicodeWriter_PrepareKind() + // was used + assert(maxchar > writer->maxchar + || (length > (writer->size - writer->pos) && length >= 1)); if (length > PY_SSIZE_T_MAX - writer->pos) { PyErr_NoMemory(); return -1; } - newlen = writer->pos + length; + Py_ssize_t alloc = writer->pos + length; maxchar = Py_MAX(maxchar, writer->min_char); + PyObject *new_buffer; if (writer->buffer == NULL) { assert(!writer->readonly); - if (writer->overallocate - && newlen <= (PY_SSIZE_T_MAX - newlen / OVERALLOCATE_FACTOR)) { - /* overallocate to limit the number of realloc() */ - newlen += newlen / OVERALLOCATE_FACTOR; + + // Do not overallocate at the first allocation, but use min_length + if (alloc < writer->min_length) { + alloc = writer->min_length; } - if (newlen < writer->min_length) - newlen = writer->min_length; - writer->buffer = PyUnicode_New(newlen, maxchar); - if (writer->buffer == NULL) + new_buffer = PyUnicode_New(alloc, maxchar); + if (new_buffer == NULL) { return -1; + } } - else if (newlen > writer->size) { - if (writer->overallocate - && newlen <= (PY_SSIZE_T_MAX - newlen / OVERALLOCATE_FACTOR)) { + else if (alloc > writer->size) { + // Do not overallocate at the first allocation, but use min_length + int overallocate = (writer->overallocate && !writer->readonly); + if (overallocate + && alloc <= (PY_SSIZE_T_MAX - alloc / OVERALLOCATE_FACTOR)) { /* overallocate to limit the number of realloc() */ - newlen += newlen / OVERALLOCATE_FACTOR; + alloc += alloc / OVERALLOCATE_FACTOR; + } + if (alloc < writer->min_length) { + alloc = writer->min_length; } - if (newlen < writer->min_length) - newlen = writer->min_length; if (maxchar > writer->maxchar || writer->readonly) { /* resize + widen */ maxchar = Py_MAX(maxchar, writer->maxchar); - newbuffer = PyUnicode_New(newlen, maxchar); - if (newbuffer == NULL) + new_buffer = PyUnicode_New(alloc, maxchar); + if (new_buffer == NULL) { return -1; - _PyUnicode_FastCopyCharacters(newbuffer, 0, + } + _PyUnicode_FastCopyCharacters(new_buffer, 0, writer->buffer, 0, writer->pos); - Py_DECREF(writer->buffer); - writer->readonly = 0; } else { - newbuffer = _PyUnicode_ResizeCompact(writer->buffer, newlen); - if (newbuffer == NULL) + new_buffer = _PyUnicode_ResizeCompact(writer->buffer, alloc); + if (new_buffer == NULL) { return -1; + } + // Do not DECREF the old buffer + writer->buffer = NULL; } - writer->buffer = newbuffer; } - else if (maxchar > writer->maxchar) { + else { + assert(maxchar > writer->maxchar); assert(!writer->readonly); - newbuffer = PyUnicode_New(writer->size, maxchar); - if (newbuffer == NULL) + + new_buffer = PyUnicode_New(writer->size, maxchar); + if (new_buffer == NULL) { return -1; - _PyUnicode_FastCopyCharacters(newbuffer, 0, + } + _PyUnicode_FastCopyCharacters(new_buffer, 0, writer->buffer, 0, writer->pos); - Py_SETREF(writer->buffer, newbuffer); } - _PyUnicodeWriter_Update(writer); + + _PyUnicodeWriter_SetBuffer(writer, new_buffer); return 0; #undef OVERALLOCATE_FACTOR @@ -331,25 +261,23 @@ _PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer, PyObject *str) { assert(PyUnicode_Check(str)); - Py_UCS4 maxchar; - Py_ssize_t len; - - len = PyUnicode_GET_LENGTH(str); - if (len == 0) + Py_ssize_t len = PyUnicode_GET_LENGTH(str); + if (len == 0) { return 0; - maxchar = PyUnicode_MAX_CHAR_VALUE(str); + } + Py_UCS4 maxchar = PyUnicode_MAX_CHAR_VALUE(str); + if (maxchar > writer->maxchar || len > writer->size - writer->pos) { - if (writer->buffer == NULL && !writer->overallocate) { + if (writer->buffer == NULL && PyUnicode_CheckExact(str)) { assert(_PyUnicode_CheckConsistency(str, 1)); - writer->readonly = 1; - writer->buffer = Py_NewRef(str); - _PyUnicodeWriter_Update(writer); - writer->pos += len; + _PyUnicodeWriter_SetReadOnly(writer, Py_NewRef(str), len); return 0; } if (_PyUnicodeWriter_PrepareInternal(writer, len, maxchar) == -1) return -1; } + + assert(_PyUnicodeWriter_CanWrite(writer)); _PyUnicode_FastCopyCharacters(writer->buffer, writer->pos, str, 0, len); writer->pos += len; @@ -358,15 +286,16 @@ _PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer, PyObject *str) int -PyUnicodeWriter_WriteStr(PyUnicodeWriter *writer, PyObject *obj) +PyUnicodeWriter_WriteStr(PyUnicodeWriter *pub_writer, PyObject *obj) { + _PyUnicodeWriter *writer = (_PyUnicodeWriter*)pub_writer; PyTypeObject *type = Py_TYPE(obj); if (type == &PyUnicode_Type) { - return _PyUnicodeWriter_WriteStr((_PyUnicodeWriter*)writer, obj); + return _PyUnicodeWriter_WriteStr(writer, obj); } if (type == &PyLong_Type) { - return _PyLong_FormatWriter((_PyUnicodeWriter*)writer, obj, 10, 0); + return _PyLong_FormatWriter(writer, obj, 10, 0); } PyObject *str = PyObject_Str(obj); @@ -374,21 +303,26 @@ PyUnicodeWriter_WriteStr(PyUnicodeWriter *writer, PyObject *obj) return -1; } - int res = _PyUnicodeWriter_WriteStr((_PyUnicodeWriter*)writer, str); + int res = _PyUnicodeWriter_WriteStr(writer, str); Py_DECREF(str); return res; } int -PyUnicodeWriter_WriteRepr(PyUnicodeWriter *writer, PyObject *obj) +PyUnicodeWriter_WriteRepr(PyUnicodeWriter *pub_writer, PyObject *obj) { + _PyUnicodeWriter *writer = (_PyUnicodeWriter*)pub_writer; if (obj == NULL) { - return _PyUnicodeWriter_WriteASCIIString((_PyUnicodeWriter*)writer, "", 6); + return _PyUnicodeWriter_WriteASCIIString(writer, "", 6); } if (Py_TYPE(obj) == &PyLong_Type) { - return _PyLong_FormatWriter((_PyUnicodeWriter*)writer, obj, 10, 0); + return _PyLong_FormatWriter(writer, obj, 10, 0); + } + // Fast path for None; see gh-159813 for the rationale. + if (obj == Py_None) { + return _PyUnicodeWriter_WriteASCIIString(writer, "None", 4); } PyObject *repr = PyObject_Repr(obj); @@ -396,7 +330,7 @@ PyUnicodeWriter_WriteRepr(PyUnicodeWriter *writer, PyObject *obj) return -1; } - int res = _PyUnicodeWriter_WriteStr((_PyUnicodeWriter*)writer, repr); + int res = _PyUnicodeWriter_WriteStr(writer, repr); Py_DECREF(repr); return res; } @@ -407,11 +341,12 @@ _PyUnicodeWriter_WriteSubstring(_PyUnicodeWriter *writer, PyObject *str, Py_ssize_t start, Py_ssize_t end) { assert(0 <= start); - assert(end <= PyUnicode_GET_LENGTH(str)); assert(start <= end); + assert(end <= PyUnicode_GET_LENGTH(str)); - if (start == 0 && end == PyUnicode_GET_LENGTH(str)) + if (start == 0 && end == PyUnicode_GET_LENGTH(str)) { return _PyUnicodeWriter_WriteStr(writer, str); + } Py_ssize_t len = end - start; if (len == 0) { @@ -428,6 +363,7 @@ _PyUnicodeWriter_WriteSubstring(_PyUnicodeWriter *writer, PyObject *str, if (_PyUnicodeWriter_Prepare(writer, len, maxchar) < 0) { return -1; } + assert(_PyUnicodeWriter_CanWrite(writer)); _PyUnicode_FastCopyCharacters(writer->buffer, writer->pos, str, start, len); @@ -469,24 +405,12 @@ _PyUnicodeWriter_WriteASCIIString(_PyUnicodeWriter *writer, return 0; } - assert(ucs1lib_find_max_char((const Py_UCS1*)ascii, (const Py_UCS1*)ascii + len) < 128); - - if (writer->buffer == NULL && !writer->overallocate) { - PyObject *str; - - str = _PyUnicode_FromASCII(ascii, len); - if (str == NULL) - return -1; - - writer->readonly = 1; - writer->buffer = str; - _PyUnicodeWriter_Update(writer); - writer->pos += len; - return 0; - } + assert(ucs1lib_find_max_char((const Py_UCS1*)ascii, (const Py_UCS1*)ascii + len) <= 127); - if (_PyUnicodeWriter_Prepare(writer, len, 127) == -1) + if (_PyUnicodeWriter_Prepare(writer, len, 127) == -1) { return -1; + } + assert(_PyUnicodeWriter_CanWrite(writer)); switch (writer->kind) { @@ -531,8 +455,7 @@ PyUnicodeWriter_WriteASCII(PyUnicodeWriter *writer, assert(writer != NULL); _Py_AssertHoldsTstate(); - _PyUnicodeWriter *priv_writer = (_PyUnicodeWriter*)writer; - return _PyUnicodeWriter_WriteASCIIString(priv_writer, str, size); + return _PyUnicodeWriter_WriteASCIIString((_PyUnicodeWriter*)writer, str, size); } @@ -545,40 +468,25 @@ PyUnicodeWriter_WriteUTF8(PyUnicodeWriter *writer, size = strlen(str); } - _PyUnicodeWriter *_writer = (_PyUnicodeWriter*)writer; - Py_ssize_t old_pos = _writer->pos; - int res = _PyUnicode_DecodeUTF8Writer(_writer, str, size, - _Py_ERROR_STRICT, NULL, NULL); - if (res < 0) { - _writer->pos = old_pos; - } - return res; + return _PyUnicode_DecodeUTF8Writer((_PyUnicodeWriter*)writer, str, size, + _Py_ERROR_STRICT, NULL, NULL); } int PyUnicodeWriter_DecodeUTF8Stateful(PyUnicodeWriter *writer, - const char *string, - Py_ssize_t length, + const char *str, + Py_ssize_t size, const char *errors, Py_ssize_t *consumed) { - if (length < 0) { - length = strlen(string); - } - - _PyUnicodeWriter *_writer = (_PyUnicodeWriter*)writer; - Py_ssize_t old_pos = _writer->pos; - int res = _PyUnicode_DecodeUTF8Writer(_writer, string, length, - _Py_ERROR_UNKNOWN, errors, - consumed); - if (res < 0) { - _writer->pos = old_pos; - if (consumed) { - *consumed = 0; - } + if (size < 0) { + size = strlen(str); } - return res; + + return _PyUnicode_DecodeUTF8Writer((_PyUnicodeWriter*)writer, str, size, + _Py_ERROR_UNKNOWN, errors, + consumed); } @@ -586,12 +494,43 @@ int _PyUnicodeWriter_WriteLatin1String(_PyUnicodeWriter *writer, const char *str, Py_ssize_t len) { - Py_UCS4 maxchar; + if (len == 0) { + return 0; + } - maxchar = ucs1lib_find_max_char((const Py_UCS1*)str, (const Py_UCS1*)str + len); - if (_PyUnicodeWriter_Prepare(writer, len, maxchar) == -1) + const Py_UCS1 *ucs1 = (const Py_UCS1 *)str; + Py_UCS4 maxchar = ucs1lib_find_max_char(ucs1, ucs1 + len); + if (_PyUnicodeWriter_Prepare(writer, len, maxchar) < 0) { return -1; - unicode_write_cstr(writer->buffer, writer->pos, str, len); + } + assert(_PyUnicodeWriter_CanWrite(writer)); + + Py_ssize_t index = writer->pos; + switch (writer->kind) { + case PyUnicode_1BYTE_KIND: { + memcpy((Py_UCS1 *)writer->data + index, ucs1, len); + break; + } + case PyUnicode_2BYTE_KIND: { + Py_UCS2 *ucs2 = (Py_UCS2 *)writer->data + index; + const Py_UCS1 *end = ucs1 + len; + for (; ucs1 < end; ++ucs2, ++ucs1) { + *ucs2 = (Py_UCS2)*ucs1; + } + break; + } + case PyUnicode_4BYTE_KIND: { + Py_UCS4 *ucs4 = (Py_UCS4 *)writer->data + index; + const Py_UCS1 *end = ucs1 + len; + for (; ucs1 < end; ++ucs4, ++ucs1) { + *ucs4 = (Py_UCS4)*ucs1; + } + break; + } + default: + Py_UNREACHABLE(); + } + writer->pos += len; return 0; } @@ -600,33 +539,96 @@ _PyUnicodeWriter_WriteLatin1String(_PyUnicodeWriter *writer, PyObject * _PyUnicodeWriter_Finish(_PyUnicodeWriter *writer) { - PyObject *str; - - if (writer->pos == 0) { - Py_CLEAR(writer->buffer); - return _PyUnicode_GetEmpty(); +#ifdef Py_DEBUG + // Check for buffer overflow + if (writer->buffer != NULL) { + Py_ssize_t pos = PyUnicode_GET_LENGTH(writer->buffer); + Py_UCS4 ch = PyUnicode_READ_CHAR(writer->buffer, pos); + if (ch != 0) { + _Py_FatalErrorFormat(__func__, + "Buffer overflow detected in " + "PyUnicodeWriter %p at position %zd", + writer, pos); + } } +#endif - str = writer->buffer; + PyObject *str = writer->buffer; writer->buffer = NULL; + Py_ssize_t final_size = writer->pos; + if (final_size == 0) { + // Get the empty string singleton + PyObject *empty = _PyUnicode_GetEmpty(); + Py_XDECREF(str); // writer->buffer can be NULL if the position is 0 + return empty; + } + if (writer->readonly) { - assert(PyUnicode_GET_LENGTH(str) == writer->pos); - return str; + assert(final_size == PyUnicode_GET_LENGTH(str)); + goto done; + } + assert(final_size <= PyUnicode_GET_LENGTH(str)); + + if (final_size == 1 && PyUnicode_KIND(str) == PyUnicode_1BYTE_KIND) { + // Get the single character singleton + assert(PyUnicode_GET_LENGTH(str) >= 1); + const Py_UCS1 *data = PyUnicode_1BYTE_DATA(str); + Py_UCS1 ch = data[0]; + Py_DECREF(str); + str = _Py_LATIN1_CHR(ch); + goto done; + } + + if (writer->recheck_maxchar) { + Py_UCS4 maxchar = _PyUnicode_FindMaxChar(str, 0, final_size); + if (maxchar != writer->maxchar) { + // Adjust the string kind + PyObject *str2 = PyUnicode_New(final_size, maxchar); + if (str2 == NULL) { + Py_DECREF(str); + return NULL; + } + _PyUnicode_FastCopyCharacters(str2, 0, str, 0, final_size); + Py_SETREF(str, str2); + goto done; + } } - if (PyUnicode_GET_LENGTH(str) != writer->pos) { - PyObject *str2; - str2 = _PyUnicode_ResizeCompact(str, writer->pos); + if (PyUnicode_GET_LENGTH(str) != final_size) { + // Truncate the string + PyObject *str2 = _PyUnicode_ResizeCompact(str, final_size); if (str2 == NULL) { Py_DECREF(str); return NULL; } str = str2; + goto done; } +done: assert(_PyUnicode_CheckConsistency(str, 1)); - return _PyUnicode_Result(str); + return str; +} + + +PyObject * +_PyUnicodeWriter_FinishWithSize(_PyUnicodeWriter *writer, Py_ssize_t size) +{ + assert(0 <= size); + if (writer->buffer != NULL) { + assert(size <= writer->pos); + assert(size <= PyUnicode_GET_LENGTH(writer->buffer)); + if (size < writer->pos) { + // Truncate the string: we may need to adjust the string kind + writer->recheck_maxchar = 1; + } + } + else { + assert(size == 0); + } + writer->pos = size; + return _PyUnicodeWriter_Finish(writer); } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 6562546ae2f9ccb..309621acdaa3c8c 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -67,7 +67,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #endif -#ifdef HAVE_ICONV +#ifdef _Py_HAVE_ICONV #include // iconv_open() #endif @@ -114,11 +114,6 @@ NOTE: In the interpreter's initialization phase, some globals are currently # define _PyUnicode_CHECK(op) PyUnicode_Check(op) #endif -static inline char* _PyUnicode_UTF8(PyObject *op) -{ - return FT_ATOMIC_LOAD_PTR_ACQUIRE(_PyCompactUnicodeObject_CAST(op)->utf8); -} - static inline char* PyUnicode_UTF8(PyObject *op) { assert(_PyUnicode_CHECK(op)); @@ -175,15 +170,6 @@ static inline int _PyUnicode_SHARE_UTF8(PyObject *op) return (_PyUnicode_UTF8(op) == PyUnicode_DATA(op)); } -/* true if the Unicode object has an allocated UTF-8 memory block - (not shared with other data) */ -static inline int _PyUnicode_HAS_UTF8_MEMORY(PyObject *op) -{ - return (!PyUnicode_IS_COMPACT_ASCII(op) - && _PyUnicode_UTF8(op) != NULL - && _PyUnicode_UTF8(op) != PyUnicode_DATA(op)); -} - #define LATIN1 _Py_LATIN1_CHR @@ -601,7 +587,6 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content) # define CHECK_IF_FT(expr) (void)(expr) #endif - assert(op != NULL); CHECK(PyUnicode_Check(op)); @@ -647,13 +632,12 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content) } /* check that the best kind is used: O(n) operation */ + const void *data = PyUnicode_DATA(ascii); if (check_content) { Py_ssize_t i; Py_UCS4 maxchar = 0; - const void *data; Py_UCS4 ch; - data = PyUnicode_DATA(ascii); for (i=0; i < ascii->length; i++) { ch = PyUnicode_READ(kind, data, i); @@ -676,9 +660,12 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content) CHECK(maxchar >= 0x10000); CHECK(maxchar <= MAX_UNICODE); } - CHECK(PyUnicode_READ(kind, data, ascii->length) == 0); } + // Detect buffer overflow: check if the trailing null character + // has been overridden + CHECK(PyUnicode_READ(kind, data, ascii->length) == 0); + /* Check interning state */ #ifdef Py_DEBUG // Note that we do not check `_Py_IsImmortal(op)` in the GIL-enabled build @@ -796,6 +783,8 @@ backslashreplace(PyBytesWriter *writer, char *str, } size += incr; } + /* subtract preallocated bytes */ + size -= (collend - collstart); str = PyBytesWriter_GrowAndUpdatePointer(writer, size, str); if (str == NULL) { @@ -871,6 +860,8 @@ xmlcharrefreplace(PyBytesWriter *writer, char *str, } size += incr; } + /* subtract preallocated bytes */ + size -= (collend - collstart); str = PyBytesWriter_GrowAndUpdatePointer(writer, size, str); if (str == NULL) { @@ -879,10 +870,16 @@ xmlcharrefreplace(PyBytesWriter *writer, char *str, /* generate replacement */ for (i = collstart; i < collend; ++i) { - size = sprintf(str, "&#%d;", PyUnicode_READ(kind, data, i)); - if (size < 0) { - return NULL; - } + // Use snprintf() with a temporary buffer to not write the trailing + // NUL byte in the writer buffer. + Py_BUILD_ASSERT(_Py_MAX_UNICODE <= 0x10ffff); + // len('􏿿\0') is 11 bytes. + char buffer[11]; + Py_UCS4 ch = PyUnicode_READ(kind, data, i); + size = snprintf(buffer, sizeof(buffer), "&#%d;", ch); + assert(4 <= size && (size_t)size <= (sizeof(buffer) - 1)); + + memcpy(str, buffer, size); str += size; } return str; @@ -1240,8 +1237,10 @@ const void *_PyUnicode_data(void *unicode_raw) { printf("compact %d\n", PyUnicode_IS_COMPACT(unicode)); printf("compact ascii %d\n", PyUnicode_IS_COMPACT_ASCII(unicode)); printf("ascii op %p\n", (void*)(_PyASCIIObject_CAST(unicode) + 1)); - printf("compact op %p\n", (void*)(_PyCompactUnicodeObject_CAST(unicode) + 1)); - printf("compact data %p\n", _PyUnicode_COMPACT_DATA(unicode)); + if (!PyUnicode_IS_COMPACT_ASCII(unicode)) { + printf("compact op %p\n", (void*)(_PyCompactUnicodeObject_CAST(unicode) + 1)); + printf("compact data %p\n", _PyUnicode_COMPACT_DATA(unicode)); + } return PyUnicode_DATA(unicode); } @@ -1249,25 +1248,21 @@ void _PyUnicode_Dump(PyObject *op) { PyASCIIObject *ascii = _PyASCIIObject_CAST(op); - PyCompactUnicodeObject *compact = _PyCompactUnicodeObject_CAST(op); - PyUnicodeObject *unicode = _PyUnicodeObject_CAST(op); - const void *data; - if (ascii->state.compact) - { - if (ascii->state.ascii) - data = (ascii + 1); - else - data = (compact + 1); - } - else - data = unicode->data.any; - printf("%s: len=%zu, ", unicode_kind_name(op), ascii->length); + printf("%s: len=%zu", unicode_kind_name(op), ascii->length); if (!ascii->state.ascii) { - printf("utf8=%p (%zu)", (void *)compact->utf8, compact->utf8_length); + PyCompactUnicodeObject *compact = _PyCompactUnicodeObject_CAST(op); + if (compact->utf8 == NULL) { + printf(", utf8=NULL"); + } + else { + printf(", utf8=%p", (void *)compact->utf8); + } + printf(" (%zu)", compact->utf8_length); } - printf(", data=%p\n", data); + printf(", data=%p\n", PyUnicode_DATA(op)); + fflush(stdout); } #endif @@ -1581,6 +1576,16 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start, return how_many; } + +static void +unicode_invalid_character(PyObject *exc, Py_UCS4 ch) +{ + PyErr_Format(exc, + "character U+%x is not in range [U+0000; U+%x]", + ch, MAX_UNICODE); +} + + /* Find the maximum code point and count the number of surrogate pairs so a correct string length can be computed before converting a string to UCS4. This function counts single surrogates as a character and not as a pair. @@ -1616,9 +1621,7 @@ find_maxchar_surrogates(const wchar_t *begin, const wchar_t *end, if (ch > *maxchar) { *maxchar = ch; if (*maxchar > MAX_UNICODE) { - PyErr_Format(PyExc_ValueError, - "character U+%x is not in range [U+0000; U+%x]", - ch, MAX_UNICODE); + unicode_invalid_character(PyExc_ValueError, ch); return -1; } } @@ -1733,18 +1736,24 @@ unicode_is_singleton(PyObject *unicode) } #endif +// If this function is updated, update also _PyUnicodeWriter_CanWrite(). int _PyUnicode_IsModifiable(PyObject *unicode) { assert(_PyUnicode_CHECK(unicode)); + if (!PyUnicode_CheckExact(unicode)) + return 0; + // On Free Threading, this test fails if called from a thread other + // than the one which created the str object. if (!_PyObject_IsUniquelyReferenced(unicode)) return 0; if (PyUnicode_HASH(unicode) != -1) return 0; if (PyUnicode_CHECK_INTERNED(unicode)) return 0; - if (!PyUnicode_CheckExact(unicode)) + if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) { return 0; + } #ifdef Py_DEBUG /* singleton refcount is greater than 1 */ assert(!unicode_is_singleton(unicode)); @@ -1820,17 +1829,15 @@ get_latin1_char(Py_UCS1 ch) static PyObject* unicode_char(Py_UCS4 ch) { - PyObject *unicode; - - assert(ch <= MAX_UNICODE); - if (ch < 256) { return get_latin1_char(ch); } - unicode = PyUnicode_New(1, ch); - if (unicode == NULL) + // Raise SystemError if the character is not in range [U+0000; MAX_UNICODE] + PyObject *unicode = PyUnicode_New(1, ch); + if (unicode == NULL) { return NULL; + } assert(PyUnicode_KIND(unicode) != PyUnicode_1BYTE_KIND); if (PyUnicode_KIND(unicode) == PyUnicode_2BYTE_KIND) { @@ -1998,6 +2005,7 @@ PyUnicodeWriter_WriteWideChar(PyUnicodeWriter *pub_writer, if (_PyUnicodeWriter_Prepare(writer, size - num_surrogates, maxchar) < 0) { return -1; } + assert(_PyUnicodeWriter_CanWrite(writer)); int kind = writer->kind; void *data = (Py_UCS1*)writer->data + writer->pos * kind; @@ -2209,15 +2217,36 @@ static PyObject* _PyUnicode_FromUCS4(const Py_UCS4 *u, Py_ssize_t size) { PyObject *res; - Py_UCS4 max_char; if (size == 0) _Py_RETURN_UNICODE_EMPTY(); assert(size > 0); - if (size == 1) + + if (size == 1) { + // Raise SystemError if the character is invalid return unicode_char(u[0]); + } + +#ifdef Py_DEBUG + // Check for invalid characters in debug mode + Py_UCS4 max_char = 127; + for (Py_ssize_t i = 0; i < size; i++) { + Py_UCS4 ch = u[i]; + if (ch > max_char) { + if (ch > MAX_UNICODE) { + unicode_invalid_character(PyExc_SystemError, ch); + return NULL; + } + max_char = ch; + } + } +#else + // gh-158445: Return MAX_UNICODE even if the string contains invalid + // characters. Checking for invalid characters would make the function + // slower whereas it's unlikely in practice. + Py_UCS4 max_char = ucs4lib_find_max_char(u, u + size); +#endif - max_char = ucs4lib_find_max_char(u, u + size); res = PyUnicode_New(size, max_char); if (!res) return NULL; @@ -2251,11 +2280,30 @@ PyUnicodeWriter_WriteUCS4(PyUnicodeWriter *pub_writer, return 0; } - Py_UCS4 max_char = ucs4lib_find_max_char(str, str + size); +#ifdef Py_DEBUG + // Check for invalid characters in debug mode + Py_UCS4 maxchar = 127; + for (Py_ssize_t i = 0; i < size; i++) { + Py_UCS4 ch = str[i]; + if (ch > maxchar) { + if (ch > MAX_UNICODE) { + unicode_invalid_character(PyExc_SystemError, ch); + return -1; + } + maxchar = ch; + } + } +#else + // gh-158445: Return MAX_UNICODE even if the string contains invalid + // characters. Checking for invalid characters would make the function + // slower whereas it's unlikely in practice. + Py_UCS4 maxchar = ucs4lib_find_max_char(str, str + size); +#endif - if (_PyUnicodeWriter_Prepare(writer, size, max_char) < 0) { + if (_PyUnicodeWriter_Prepare(writer, size, maxchar) < 0) { return -1; } + assert(_PyUnicodeWriter_CanWrite(writer)); int kind = writer->kind; void *data = (Py_UCS1*)writer->data + writer->pos * kind; @@ -2529,9 +2577,9 @@ unicode_fromformat_write_str(_PyUnicodeWriter *writer, PyObject *str, Py_UCS4 maxchar; length = PyUnicode_GET_LENGTH(str); - if ((precision == -1 || precision >= length) - && width <= length) + if ((precision == -1 || precision >= length) && width <= length) { return _PyUnicodeWriter_WriteStr(writer, str); + } if (precision != -1) length = Py_MIN(precision, length); @@ -2542,8 +2590,10 @@ unicode_fromformat_write_str(_PyUnicodeWriter *writer, PyObject *str, else maxchar = writer->maxchar; - if (_PyUnicodeWriter_Prepare(writer, arglen, maxchar) == -1) + if (_PyUnicodeWriter_Prepare(writer, arglen, maxchar) == -1) { return -1; + } + assert(_PyUnicodeWriter_CanWrite(writer)); fill = Py_MAX(width - length, 0); if (fill && !(flags & F_LJUST)) { @@ -2819,7 +2869,7 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer, #undef SPRINT #undef DO_SPRINTS - assert(len >= 0); + assert(len >= 1); int sign = (buffer[0] == '-'); len -= sign; @@ -2833,8 +2883,10 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer, Py_ssize_t spacepad = Py_MAX(width - precision - sign, 0); Py_ssize_t zeropad = Py_MAX(precision - len, 0); - if (_PyUnicodeWriter_Prepare(writer, width, 127) == -1) + if (_PyUnicodeWriter_Prepare(writer, width, 127) == -1) { return NULL; + } + assert(_PyUnicodeWriter_CanWrite(writer)); if (spacepad && !(flags & F_LJUST)) { if (PyUnicode_Fill(writer->buffer, writer->pos, spacepad, ' ') == -1) @@ -3146,16 +3198,21 @@ PyUnicodeWriter_Format(PyUnicodeWriter *writer, const char *format, ...) } int -_PyUnicodeWriter_FormatV(PyUnicodeWriter *writer, const char *format, +_PyUnicodeWriter_FormatV(PyUnicodeWriter *pub_writer, const char *format, va_list vargs) { - _PyUnicodeWriter *_writer = (_PyUnicodeWriter*)writer; - Py_ssize_t old_pos = _writer->pos; + _PyUnicodeWriter *writer = (_PyUnicodeWriter*)pub_writer; + Py_ssize_t old_pos = writer->pos; + Py_UCS4 old_maxchar = writer->maxchar; - int res = unicode_from_format(_writer, format, vargs); + int res = unicode_from_format(writer, format, vargs); if (res < 0) { - _writer->pos = old_pos; + writer->pos = old_pos; + if (writer->maxchar > old_maxchar) { + // _PyUnicodeWriter_Finish() will check maxchar + writer->recheck_maxchar = 1; + } } return res; } @@ -3694,35 +3751,37 @@ unicode_encode_locale(PyObject *unicode, _Py_error_handler error_handler, } char *str; + size_t str_len; size_t error_pos; - const char *reason; - int res = _Py_EncodeLocaleEx(wstr, &str, &error_pos, &reason, - current_locale, error_handler); + int res = _Py_EncodeLocale(wstr, &str, &str_len, &error_pos, + current_locale, error_handler); PyMem_Free(wstr); if (res != 0) { - if (res == -2) { + if (res == _Py_CODEC_ENCODE_ERROR) { PyObject *exc; + assert(error_pos <= (size_t)(PY_SSIZE_T_MAX - 1)); exc = PyObject_CallFunction(PyExc_UnicodeEncodeError, "sOnns", "locale", unicode, (Py_ssize_t)error_pos, (Py_ssize_t)(error_pos+1), - reason); + "encode error"); if (exc != NULL) { PyCodec_StrictErrors(exc); Py_DECREF(exc); } } - else if (res == -3) { + else if (res == _Py_CODEC_UNSUPPORTED_ERROR_HANDLER) { PyErr_SetString(PyExc_ValueError, "unsupported error handler"); } else { + assert(res == _Py_CODEC_MEMORY_ERROR); PyErr_NoMemory(); } return NULL; } - PyObject *bytes = PyBytes_FromString(str); + PyObject *bytes = PyBytes_FromStringAndSize(str, str_len); PyMem_RawFree(str); return bytes; } @@ -3913,26 +3972,26 @@ unicode_decode_locale(const char *str, Py_ssize_t len, wchar_t *wstr; size_t wlen; - const char *reason; - int res = _Py_DecodeLocaleEx(str, &wstr, &wlen, &reason, - current_locale, errors); + int res = _Py_DecodeLocale(str, &wstr, &wlen, current_locale, errors); if (res != 0) { - if (res == -2) { + if (res == _Py_CODEC_DECODE_ERROR) { PyObject *exc; + assert(wlen <= (size_t)(PY_SSIZE_T_MAX - 1)); exc = PyObject_CallFunction(PyExc_UnicodeDecodeError, "sy#nns", "locale", str, len, (Py_ssize_t)wlen, (Py_ssize_t)(wlen + 1), - reason); + "decode error"); if (exc != NULL) { PyCodec_StrictErrors(exc); Py_DECREF(exc); } } - else if (res == -3) { + else if (res == _Py_CODEC_UNSUPPORTED_ERROR_HANDLER) { PyErr_SetString(PyExc_ValueError, "unsupported error handler"); } else { + assert(res == _Py_CODEC_MEMORY_ERROR); PyErr_NoMemory(); } return NULL; @@ -4736,15 +4795,10 @@ PyUnicode_DecodeUTF7Stateful(const char *s, if (consumed) { if (inShift) { *consumed = startinpos; - if (writer.pos != shiftOutStart && writer.maxchar > 127) { - PyObject *result = PyUnicode_FromKindAndData( - writer.kind, writer.data, shiftOutStart); - Py_XDECREF(errorHandler); - Py_XDECREF(exc); - _PyUnicodeWriter_Dealloc(&writer); - return result; - } - writer.pos = shiftOutStart; /* back off output */ + + Py_XDECREF(errorHandler); + Py_XDECREF(exc); + return _PyUnicodeWriter_FinishWithSize(&writer, shiftOutStart); } else { *consumed = s-starts; @@ -4813,7 +4867,7 @@ _PyUnicode_EncodeUTF7(PyObject *str, else { /* not in a shift sequence */ if (ch == '+') { *out++ = '+'; - *out++ = '-'; + *out++ = '-'; } else if (ENCODE_DIRECT(ch)) { *out++ = (char) ch; @@ -5009,6 +5063,16 @@ find_first_nonascii(const unsigned char *start, const unsigned char *end) } #endif + // Long ASCII runs: test eight words per branch. + for (; end - p >= 8 * SIZEOF_SIZE_T; p += 8 * SIZEOF_SIZE_T) { + const size_t *w = (const size_t *)p; + if ((w[0] | w[1] | w[2] | w[3] | + w[4] | w[5] | w[6] | w[7]) & ASCII_CHAR_MASK) + { + break; + } + } + const unsigned char *e = end - SIZEOF_SIZE_T; while (p <= e) { size_t u = (*(const size_t *)p) & ASCII_CHAR_MASK; @@ -5210,6 +5274,7 @@ unicode_decode_utf8_impl(_PyUnicodeWriter *writer, if (_PyUnicodeWriter_PrepareKind(writer, PyUnicode_2BYTE_KIND) < 0) goto onError; + assert(_PyUnicodeWriter_CanWrite(writer)); for (i=startinpos; ikind, writer->data, writer->pos, @@ -5343,7 +5408,7 @@ unicode_decode_utf8(const char *s, Py_ssize_t size, } -// Used by PyUnicodeWriter_WriteUTF8() implementation +// Used by PyUnicodeWriter_WriteUTF8() and PyUnicodeWriter_DecodeUTF8Stateful() int _PyUnicode_DecodeUTF8Writer(_PyUnicodeWriter *writer, const char *s, Py_ssize_t size, @@ -5357,17 +5422,20 @@ _PyUnicode_DecodeUTF8Writer(_PyUnicodeWriter *writer, return 0; } + Py_ssize_t old_pos = writer->pos; + Py_UCS4 old_maxchar = writer->maxchar; + // fast path: try ASCII string. if (_PyUnicodeWriter_Prepare(writer, size, 127) < 0) { - return -1; + goto error; } + assert(_PyUnicodeWriter_CanWrite(writer)); const char *starts = s; const char *end = s + size; - Py_ssize_t decoded = 0; - Py_UCS1 *dest = (Py_UCS1*)writer->data + writer->pos * writer->kind; if (writer->kind == PyUnicode_1BYTE_KIND) { - decoded = ascii_decode(s, end, dest); + Py_UCS1 *dest = (Py_UCS1*)writer->data + writer->pos * writer->kind; + Py_ssize_t decoded = ascii_decode(s, end, dest); writer->pos += decoded; if (decoded == size) { @@ -5379,8 +5447,24 @@ _PyUnicode_DecodeUTF8Writer(_PyUnicodeWriter *writer, s += decoded; } - return unicode_decode_utf8_impl(writer, starts, s, end, - error_handler, errors, consumed); + int res = unicode_decode_utf8_impl(writer, starts, s, end, + error_handler, errors, consumed); + if (res < 0) { + goto error; + } + return 0; + +error: + // Restore the writer to its previous state + writer->pos = old_pos; + if (writer->maxchar > old_maxchar) { + // _PyUnicodeWriter_Finish() will check maxchar + writer->recheck_maxchar = 1; + } + if (consumed) { + *consumed = 0; + } + return -1; } @@ -5396,26 +5480,31 @@ PyUnicode_DecodeUTF8Stateful(const char *s, } -/* UTF-8 decoder: use surrogateescape error handler if 'surrogateescape' is - non-zero, use strict error handler otherwise. - - On success, write a pointer to a newly allocated wide character string into - *wstr (use PyMem_RawFree() to free the memory) and write the output length - (in number of wchar_t units) into *wlen (if wlen is set). - - On memory allocation failure, return -1. - - On decoding error (if surrogateescape is zero), return -2. If wlen is - non-NULL, write the start of the illegal byte sequence into *wlen. If reason - is not NULL, write the decoding error message into *reason. */ +// UTF-8 decoder. +// +// Supported error handlers: "strict", "surrogateescape" and "surrogatepass". +// +// On success, write a pointer to a newly allocated wide character string into +// *wstr (use PyMem_RawFree() to free the memory), write the output length +// (in number of wchar_t units) into *wlen (if wlen is set), and return 0. +// +// On error, return a negative number. +// +// On memory allocation failure, return _Py_CODEC_MEMORY_ERROR. +// +// On decoding error (if errors is "strict"), return _Py_CODEC_DECODE_ERROR. +// If wlen is non-NULL, write the start of the illegal byte sequence into +// *wlen. +// +// Return _Py_CODEC_UNSUPPORTED_ERROR_HANDLER if errors error handler is not +// supported. int -_Py_DecodeUTF8Ex(const char *s, Py_ssize_t size, wchar_t **wstr, size_t *wlen, - const char **reason, _Py_error_handler errors) +_Py_DecodeUTF8(const char *s, Py_ssize_t size, wchar_t **wstr, size_t *wlen, + _Py_error_handler errors) { - const char *orig_s = s; - const char *e; - wchar_t *unicode; - Py_ssize_t outpos; + assert(0 <= size); + assert(s != NULL); + assert(wstr != NULL); int surrogateescape = 0; int surrogatepass = 0; @@ -5430,23 +5519,23 @@ _Py_DecodeUTF8Ex(const char *s, Py_ssize_t size, wchar_t **wstr, size_t *wlen, surrogatepass = 1; break; default: - return -3; + return _Py_CODEC_UNSUPPORTED_ERROR_HANDLER; } /* Note: size will always be longer than the resulting Unicode character count */ - if (PY_SSIZE_T_MAX / (Py_ssize_t)sizeof(wchar_t) - 1 < size) { - return -1; + if ((size_t)PY_SSIZE_T_MAX / sizeof(wchar_t) - 1 < (size_t)size) { + return _Py_CODEC_MEMORY_ERROR; } - - unicode = PyMem_RawMalloc((size + 1) * sizeof(wchar_t)); + wchar_t *unicode = PyMem_RawMalloc((size + 1) * sizeof(wchar_t)); if (!unicode) { - return -1; + return _Py_CODEC_MEMORY_ERROR; } /* Unpack UTF-8 encoded data */ - e = s + size; - outpos = 0; + const char *orig_s = s; + const char *e = s + size; + Py_ssize_t outpos = 0; while (s < e) { Py_UCS4 ch; #if SIZEOF_WCHAR_T == 4 @@ -5486,24 +5575,10 @@ _Py_DecodeUTF8Ex(const char *s, Py_ssize_t size, wchar_t **wstr, size_t *wlen, } else { PyMem_RawFree(unicode ); - if (reason != NULL) { - switch (ch) { - case 0: - *reason = "unexpected end of data"; - break; - case 1: - *reason = "invalid start byte"; - break; - /* 2, 3, 4 */ - default: - *reason = "invalid continuation byte"; - break; - } - } if (wlen != NULL) { *wlen = s - orig_s; } - return -2; + return _Py_CODEC_DECODE_ERROR; } } } @@ -5517,17 +5592,20 @@ _Py_DecodeUTF8Ex(const char *s, Py_ssize_t size, wchar_t **wstr, size_t *wlen, } +// Decode from UTF-8 with the "surrogateescape" error handler. +// On success, set *wlen and return a newly allocated string. +// On error, set *wlen to the error (_Py_CODEC_MEMORY_ERROR or +// _Py_CODEC_DECODE_ERROR) and the return NULL wchar_t* _Py_DecodeUTF8_surrogateescape(const char *arg, Py_ssize_t arglen, size_t *wlen) { wchar_t *wstr; - int res = _Py_DecodeUTF8Ex(arg, arglen, - &wstr, wlen, - NULL, _Py_ERROR_SURROGATEESCAPE); + int res = _Py_DecodeUTF8(arg, arglen, &wstr, wlen, + _Py_ERROR_SURROGATEESCAPE); if (res != 0) { - /* _Py_DecodeUTF8Ex() must support _Py_ERROR_SURROGATEESCAPE */ - assert(res != -3); + /* _Py_DecodeUTF8() must support _Py_ERROR_SURROGATEESCAPE */ + assert(res != _Py_CODEC_UNSUPPORTED_ERROR_HANDLER); if (wlen) { *wlen = (size_t)res; } @@ -5542,19 +5620,24 @@ _Py_DecodeUTF8_surrogateescape(const char *arg, Py_ssize_t arglen, On success, return 0 and write the newly allocated character string (use PyMem_Free() to free the memory) into *str. - On encoding failure, return -2 and write the position of the invalid - surrogate character into *error_pos (if error_pos is set) and the decoding - error message into *reason (if reason is set). + On encoding failure, return _Py_CODEC_ENCODE_ERROR (-2) and write the + position of the invalid surrogate character into *error_pos (if error_pos is + set). + + On memory allocation failure, return _Py_CODEC_MEMORY_ERROR (-1). - On memory allocation failure, return -1. */ + str and output_length must not be NULL +*/ int -_Py_EncodeUTF8Ex(const wchar_t *text, char **str, size_t *error_pos, - const char **reason, int raw_malloc, _Py_error_handler errors) +_Py_EncodeUTF8(const wchar_t *text, char **str, size_t *output_length, + size_t *error_pos, int raw_malloc, _Py_error_handler errors) { - const Py_ssize_t max_char_size = 4; - Py_ssize_t len = wcslen(text); + assert(str != NULL); + assert(output_length != NULL); - assert(len >= 0); + // U+10ffff encoded to UTF-8 takes 4 bytes + const size_t max_char_size = 4; + size_t len = wcslen(text); int surrogateescape = 0; int surrogatepass = 0; @@ -5569,11 +5652,11 @@ _Py_EncodeUTF8Ex(const wchar_t *text, char **str, size_t *error_pos, surrogatepass = 1; break; default: - return -3; + return _Py_CODEC_UNSUPPORTED_ERROR_HANDLER; } - if (len > PY_SSIZE_T_MAX / max_char_size - 1) { - return -1; + if (len > (size_t)PY_SSIZE_T_MAX / max_char_size - 1) { + return _Py_CODEC_MEMORY_ERROR; } char *bytes; if (raw_malloc) { @@ -5583,12 +5666,11 @@ _Py_EncodeUTF8Ex(const wchar_t *text, char **str, size_t *error_pos, bytes = PyMem_Malloc((len + 1) * max_char_size); } if (bytes == NULL) { - return -1; + return _Py_CODEC_MEMORY_ERROR; } char *p = bytes; - Py_ssize_t i; - for (i = 0; i < len; ) { + for (size_t i = 0; i < len; ) { Py_ssize_t ch_pos = i; Py_UCS4 ch = text[i]; i++; @@ -5604,7 +5686,6 @@ _Py_EncodeUTF8Ex(const wchar_t *text, char **str, size_t *error_pos, if (ch < 0x80) { /* Encode ASCII */ *p++ = (char) ch; - } else if (ch < 0x0800) { /* Encode Latin-1 */ @@ -5617,16 +5698,13 @@ _Py_EncodeUTF8Ex(const wchar_t *text, char **str, size_t *error_pos, if (error_pos != NULL) { *error_pos = (size_t)ch_pos; } - if (reason != NULL) { - *reason = "encoding error"; - } if (raw_malloc) { PyMem_RawFree(bytes); } else { PyMem_Free(bytes); } - return -2; + return _Py_CODEC_ENCODE_ERROR; } *p++ = (char)(ch & 0xff); } @@ -5644,29 +5722,29 @@ _Py_EncodeUTF8Ex(const wchar_t *text, char **str, size_t *error_pos, *p++ = (char)(0x80 | (ch & 0x3f)); } } - *p++ = '\0'; + *p++ = '\0'; // trailing NUL byte size_t final_size = (p - bytes); - char *bytes2; + assert(final_size >= 1); + *output_length = final_size - 1; // -1 for the trailing NUL byte + + char *result; if (raw_malloc) { - bytes2 = PyMem_RawRealloc(bytes, final_size); + result = PyMem_RawRealloc(bytes, final_size); } else { - bytes2 = PyMem_Realloc(bytes, final_size); + result = PyMem_Realloc(bytes, final_size); } - if (bytes2 == NULL) { - if (error_pos != NULL) { - *error_pos = (size_t)-1; - } + if (result == NULL) { if (raw_malloc) { PyMem_RawFree(bytes); } else { PyMem_Free(bytes); } - return -1; + return _Py_CODEC_MEMORY_ERROR; } - *str = bytes2; + *str = result; return 0; } @@ -7256,8 +7334,6 @@ unicode_encode_ucs1(PyObject *unicode, break; case _Py_ERROR_BACKSLASHREPLACE: - /* subtract preallocated bytes */ - writer->size -= (collend - collstart); str = backslashreplace(writer, str, unicode, collstart, collend); if (str == NULL) @@ -7266,8 +7342,6 @@ unicode_encode_ucs1(PyObject *unicode, break; case _Py_ERROR_XMLCHARREFREPLACE: - /* subtract preallocated bytes */ - writer->size -= (collend - collstart); str = xmlcharrefreplace(writer, str, unicode, collstart, collend); if (str == NULL) @@ -7308,13 +7382,16 @@ unicode_encode_ucs1(PyObject *unicode, } } else { - /* subtract preallocated bytes */ - writer->size -= newpos - collstart; /* Only overallocate the buffer if it's not the last write */ writer->overallocate = (newpos < size); + + /* subtract preallocated bytes */ + if (PyBytesWriter_Grow(writer, -(newpos - collstart)) < 0) { + goto onError; + } } - char *rep_str; + const char *rep_str; Py_ssize_t rep_len; if (PyBytes_Check(rep)) { /* Directly copy bytes result to output. */ @@ -7452,6 +7529,7 @@ PyUnicode_DecodeASCII(const char *s, but we may switch to UCS2 at the first write */ if (_PyUnicodeWriter_PrepareKind(&writer, PyUnicode_2BYTE_KIND) < 0) goto onError; + assert(_PyUnicodeWriter_CanWrite(&writer)); kind = writer.kind; data = writer.data; @@ -8198,7 +8276,7 @@ PyUnicode_AsMBCSString(PyObject *unicode) /* --- iconv Codec -------------------------------------------------------- */ -#ifdef HAVE_ICONV +#ifdef _Py_HAVE_ICONV /* iconv pivot: native-endian UTF-32, a raw array of Py_UCS4. One input unit is one code point, so error handlers get the exact position. A platform whose @@ -8279,7 +8357,10 @@ _PyUnicode_DecodeIconv(const char *encoding, char *outptr = (char *)chunk; size_t outleft = sizeof(chunk); - size_t ret = iconv(cd, &inptr, &inleft, &outptr, &outleft); + /* Cast the input buffer through void*: iconv() declares its second + argument as "char **" on most systems but "const char **" on some + (e.g. illumos), and void* converts to either without a warning. */ + size_t ret = iconv(cd, (void *)&inptr, &inleft, &outptr, &outleft); int err = errno; in = inptr; @@ -8452,12 +8533,16 @@ _PyUnicode_EncodeIconv(const char *encoding, PyObject *unicode, size_t outleft = (size_t)(outend - out); /* When the whole string is converted, a final iconv() call with a NULL input flushes any pending shift sequence (e.g. ISO-2022). */ - size_t ret = iconv(cd, flushing ? NULL : &inptr, &inleft, &out, &outleft); + /* See the note above on the void* cast of the iconv() input buffer. */ + size_t ret = iconv(cd, flushing ? NULL : (void *)&inptr, &inleft, &out, &outleft); if (!flushing) { up = inptr; } if (ret != (size_t)-1) { + if (flushing) { + break; + } /* A positive result counts nonreversible conversions: iconv() substituted an unencodable character instead of failing with EILSEQ (musl and *BSD citrus do this). Treat it as unencodable @@ -8475,9 +8560,6 @@ _PyUnicode_EncodeIconv(const char *encoding, PyObject *unicode, out = out_before; up -= unit; } - else if (flushing) { - break; - } else if (careful && up < uend) { continue; } @@ -8516,11 +8598,19 @@ _PyUnicode_EncodeIconv(const char *encoding, PyObject *unicode, replen = PyBytes_GET_SIZE(rep); } else { - /* A str replacement is encoded through the same codec. */ + /* A str replacement is encoded through the same codec, but + strictly: handling its errors in turn could never terminate. */ assert(PyUnicode_Check(rep)); - repbytes = _PyUnicode_EncodeIconv(encoding, rep, errors); + repbytes = _PyUnicode_EncodeIconv(encoding, rep, NULL); Py_DECREF(rep); if (repbytes == NULL) { + if (PyErr_ExceptionMatches(PyExc_UnicodeEncodeError)) { + /* Report the input the caller knows about, not the + replacement. */ + PyErr_Clear(); + raise_encode_exception(&exc, encoding, unicode, pos, pos + 1, + "unable to encode error handler result"); + } goto done; } repdata = PyBytes_AS_STRING(repbytes); @@ -8551,10 +8641,7 @@ _PyUnicode_EncodeIconv(const char *encoding, PyObject *unicode, iconv(cd, NULL, NULL, NULL, NULL); } - if (PyBytesWriter_Resize(writer, out - (char *)PyBytesWriter_GetData(writer)) < 0) { - goto done; - } - result = PyBytesWriter_Finish(writer); + result = PyBytesWriter_FinishWithPointer(writer, out); writer = NULL; done: @@ -8568,7 +8655,7 @@ _PyUnicode_EncodeIconv(const char *encoding, PyObject *unicode, return result; } -#endif /* HAVE_ICONV */ +#endif /* _Py_HAVE_ICONV */ /* --- Character Mapping Codec -------------------------------------------- */ @@ -10367,10 +10454,10 @@ _PyUnicode_JoinArray(PyObject *separator, PyObject *const *items, Py_ssize_t seq PyObject *item; Py_ssize_t sz, i, res_offset; Py_UCS4 maxchar; - Py_UCS4 item_maxchar; + /* kinds is the bitwise OR of the PyUnicode_KIND() values (1, 2, 4). */ + unsigned int kinds = 0, all_ascii = 1; int use_memcpy; unsigned char *res_data = NULL, *sep_data = NULL; - PyObject *last_obj; int kind = 0; /* If empty sequence, return u"". */ @@ -10379,14 +10466,12 @@ _PyUnicode_JoinArray(PyObject *separator, PyObject *const *items, Py_ssize_t seq } /* If singleton sequence with an exact Unicode, return that. */ - last_obj = NULL; if (seqlen == 1) { if (PyUnicode_CheckExact(items[0])) { res = items[0]; return Py_NewRef(res); } seplen = 0; - maxchar = 0; } else { /* Set up sep and seplen */ @@ -10396,7 +10481,6 @@ _PyUnicode_JoinArray(PyObject *separator, PyObject *const *items, Py_ssize_t seq if (!sep) goto onError; seplen = 1; - maxchar = 32; } else { if (!PyUnicode_Check(separator)) { @@ -10408,12 +10492,12 @@ _PyUnicode_JoinArray(PyObject *separator, PyObject *const *items, Py_ssize_t seq } sep = separator; seplen = PyUnicode_GET_LENGTH(separator); - maxchar = PyUnicode_MAX_CHAR_VALUE(separator); /* inc refcount to keep this code path symmetric with the above case of a blank separator */ Py_INCREF(sep); } - last_obj = sep; + kinds = PyUnicode_KIND(sep); + all_ascii = PyUnicode_IS_ASCII(sep); } /* There are at least two things to join, or else we have a subclass @@ -10437,23 +10521,34 @@ _PyUnicode_JoinArray(PyObject *separator, PyObject *const *items, Py_ssize_t seq i, Py_TYPE(item)->tp_name); goto onError; } - add_sz = PyUnicode_GET_LENGTH(item); - item_maxchar = PyUnicode_MAX_CHAR_VALUE(item); - maxchar = Py_MAX(maxchar, item_maxchar); - if (i != 0) { - add_sz += seplen; - } + /* Count one separator per item; the extra one is removed below. */ + add_sz = (size_t)PyUnicode_GET_LENGTH(item) + (size_t)seplen; + kinds |= PyUnicode_KIND(item); + all_ascii &= PyUnicode_IS_ASCII(item); if (add_sz > (size_t)(PY_SSIZE_T_MAX - sz)) { PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string"); goto onError; } sz += add_sz; - if (use_memcpy && last_obj != NULL) { - if (PyUnicode_KIND(last_obj) != PyUnicode_KIND(item)) - use_memcpy = 0; - } - last_obj = item; + } + sz -= seplen; + /* memcpy() can be used if the separator and all items have the same + kind: the result then has that kind too. */ + if (kinds & (kinds - 1)) { + use_memcpy = 0; + } + if (all_ascii) { + maxchar = 0x7f; + } + else if (kinds & PyUnicode_4BYTE_KIND) { + maxchar = MAX_UNICODE; + } + else if (kinds & PyUnicode_2BYTE_KIND) { + maxchar = 0xffff; + } + else { + maxchar = 0xff; } res = PyUnicode_New(sz, maxchar); @@ -14443,6 +14538,7 @@ PyTypeObject PyUnicode_Type = { 0, /* tp_alloc */ unicode_new, /* tp_new */ PyObject_Free, /* tp_free */ + .tp_version_tag = _Py_TYPE_VERSION_STR, .tp_vectorcall = unicode_vectorcall, ._tp_iteritem = unicode_iteritem, }; @@ -14553,7 +14649,7 @@ intern_static(PyInterpreterState *interp, PyObject *s /* stolen */) return Py_NewRef(r); } - if (_Py_hashtable_set(INTERNED_STRINGS, s, s) < -1) { + if (_Py_hashtable_set(INTERNED_STRINGS, s, s) < 0) { Py_FatalError("failed to intern static string"); } @@ -14649,7 +14745,7 @@ intern_common(PyInterpreterState *interp, PyObject *s /* stolen */, /* Statically allocated strings must be already interned. */ assert(!_PyUnicode_STATE(s).statically_allocated); -#if Py_GIL_DISABLED +#ifdef Py_GIL_DISABLED /* In the free-threaded build, all interned strings are immortal */ immortalize = 1; #endif @@ -14722,6 +14818,15 @@ intern_common(PyInterpreterState *interp, PyObject *s /* stolen */, } #endif + // Why _Py_LOCK_DONT_DETACH is used here: waiting for the interned mutex + // must not detach the thread state. Extension code is expected to + // detach before blocking on opaque external synchronization. However, + // the lock used for C++ static initialization is hidden, making + // that difficult, and it is common for C++ extensions to call + // PyUnicode_InternFromString() from static initializers. Detaching here + // can therefore deadlock: a stop-the-world pause may prevent the lock + // owner from reattaching while the pause waits for another attached + // thread blocked on the hidden lock. FT_MUTEX_LOCK_FLAGS(INTERN_MUTEX, _Py_LOCK_DONT_DETACH); PyObject *t; { @@ -15122,8 +15227,11 @@ unicode_iter(PyObject *seq) static int encode_wstr_utf8(wchar_t *wstr, char **str, const char *name) { - int res; - res = _Py_EncodeUTF8Ex(wstr, str, NULL, NULL, 1, _Py_ERROR_STRICT); + assert(str != NULL); + + size_t unused_output_length; + int res = _Py_EncodeUTF8(wstr, str, &unused_output_length, + NULL, 1, _Py_ERROR_STRICT); if (res == -2) { PyErr_Format(PyExc_RuntimeError, "cannot encode %s", name); return -1; @@ -15188,6 +15296,10 @@ init_stdio_encoding(PyInterpreterState *interp) { /* Update the stdio encoding to the normalized Python codec name. */ PyConfig *config = (PyConfig*)_PyInterpreterState_GetConfig(interp); + if (config->stdio_encoding == NULL) { + /* gh-86427: The encoding is determined for every stream. */ + return _PyStatus_OK(); + } if (config_get_codec_name(&config->stdio_encoding) < 0) { return _PyStatus_ERR("failed to get the Python codec name " "of the stdio encoding"); diff --git a/Objects/unicodetype_db.h b/Objects/unicodetype_db.h index 536f51324aeee83..f96f1e90d8350bb 100644 --- a/Objects/unicodetype_db.h +++ b/Objects/unicodetype_db.h @@ -95,6 +95,7 @@ const _PyUnicode_TypeRecord _PyUnicode_TypeRecords[] = { {10749, 0, 10749, 0, 0, 9993}, {-213, 0, -213, 0, 0, 9993}, {-214, 0, -214, 0, 0, 9993}, + {42342, 0, 42342, 0, 0, 9993}, {10727, 0, 10727, 0, 0, 9993}, {-218, 0, -218, 0, 0, 9993}, {42307, 0, 42307, 0, 0, 9993}, @@ -409,7 +410,10 @@ const _PyUnicode_TypeRecord _PyUnicode_TypeRecords[] = { {0, -35384, 0, 0, 0, 10113}, {0, -42343, 0, 0, 0, 10113}, {0, -42561, 0, 0, 0, 10113}, + {0, -42342, 0, 0, 0, 10113}, + {33, 0, 33, 0, 0, 9993}, {-928, 0, -928, 0, 0, 9993}, + {0, -33, 0, 0, 0, 10113}, {16778124, 17826698, 16778124, 0, 0, 26377}, {16778127, 17826701, 16778127, 0, 0, 26377}, {16778130, 17826704, 16778130, 0, 0, 26377}, @@ -510,6 +514,7 @@ const _PyUnicode_TypeRecord _PyUnicode_TypeRecords[] = { {-39, 0, -39, 0, 0, 9993}, {0, 27, 0, 0, 0, 10113}, {-27, 0, -27, 0, 0, 9993}, + {33555671, 18875604, 33555673, 0, 0, 26377}, {0, 34, 0, 0, 0, 10113}, {-34, 0, -34, 0, 0, 9993}, {0, 0, 0, 0, 0, 9344}, @@ -1754,615 +1759,1224 @@ const Py_UCS4 _PyUnicode_ExtendedCase[] = { 1341, 1348, 1389, + 122773, + 115, + 115, + 83, + 83, + 83, + 115, }; /* type indexes */ -#define SHIFT 7 +#define SHIFT 6 static const unsigned short index1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 34, 35, 36, 37, - 38, 39, 34, 34, 34, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 64, 64, 64, 65, 66, 64, - 64, 64, 64, 67, 68, 64, 64, 64, 64, 64, 64, 69, 64, 70, 71, 72, 73, 74, - 75, 64, 76, 77, 78, 79, 80, 81, 82, 64, 64, 83, 84, 34, 34, 34, 34, 34, - 34, 85, 34, 34, 34, 34, 34, 86, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 87, 88, 89, 90, 91, 92, 34, 93, 34, 34, - 34, 94, 95, 34, 34, 34, 34, 34, 96, 34, 34, 34, 97, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 98, 99, 100, 34, 34, 34, 34, 34, 34, 101, 102, 34, - 34, 34, 34, 34, 34, 34, 34, 103, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 104, 34, 34, 34, 92, 34, 34, 34, 34, 34, 34, 34, 34, 105, 34, 34, 34, 34, - 106, 107, 34, 34, 34, 34, 34, 108, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 92, 34, 34, 34, 34, 34, 34, 109, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 110, 111, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 112, 34, 34, 34, 34, 113, 34, 34, 114, 115, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 116, 34, 34, 34, - 34, 34, 34, 34, 34, 117, 34, 34, 118, 119, 120, 121, 122, 123, 124, 125, - 126, 127, 128, 129, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 130, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 132, 133, - 134, 135, 136, 137, 138, 34, 139, 140, 141, 142, 143, 144, 145, 146, 147, - 148, 131, 149, 150, 151, 152, 153, 154, 155, 34, 34, 156, 157, 158, 159, - 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, - 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 131, 184, 185, 186, - 187, 131, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - 131, 200, 201, 202, 203, 34, 34, 34, 204, 34, 205, 206, 207, 34, 208, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 209, 34, 34, 34, 34, 34, 34, 34, 34, 210, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 146, 34, 34, 34, 34, 211, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 212, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 34, 34, 34, 34, - 213, 214, 215, 216, 131, 131, 217, 131, 218, 219, 220, 221, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 222, 223, 224, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 225, 34, 34, 226, 34, 34, 227, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 228, 229, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 64, - 230, 64, 64, 64, 231, 232, 233, 64, 234, 235, 236, 237, 238, 239, 131, - 240, 241, 242, 243, 244, 245, 246, 247, 64, 64, 64, 64, 248, 249, 131, - 131, 131, 131, 131, 131, 131, 131, 250, 131, 251, 252, 253, 131, 131, - 254, 131, 131, 131, 255, 131, 256, 131, 257, 131, 258, 34, 259, 260, 131, - 131, 131, 131, 131, 261, 262, 263, 131, 264, 265, 131, 131, 266, 267, - 268, 269, 270, 131, 64, 271, 64, 64, 64, 64, 64, 272, 64, 273, 274, 275, - 64, 64, 276, 277, 64, 278, 131, 131, 131, 131, 131, 131, 131, 131, 279, - 280, 281, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 85, - 282, 34, 283, 284, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 285, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 286, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 287, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 108, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 288, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 289, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 290, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 291, 34, 34, 34, 34, 292, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 34, 285, 34, - 34, 293, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 294, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 295, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 296, 131, 297, 298, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, - 131, 131, 131, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 26, 26, 26, 26, 26, 68, 69, + 70, 71, 72, 73, 74, 75, 26, 26, 26, 26, 26, 26, 26, 26, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, + 98, 99, 100, 101, 102, 103, 104, 105, 12, 106, 106, 107, 106, 108, 109, + 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 120, 121, 122, 123, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 124, 125, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 126, 119, 119, 127, 128, 106, 129, 130, 131, + 132, 133, 134, 135, 136, 137, 119, 119, 119, 138, 139, 140, 141, 142, + 143, 26, 144, 145, 146, 147, 148, 119, 119, 119, 119, 119, 149, 26, 150, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 151, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 152, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 119, 153, 154, 155, 156, 152, + 157, 26, 158, 159, 26, 26, 26, 160, 161, 26, 26, 26, 26, 26, 26, 26, 162, + 26, 163, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 164, 26, 26, 26, 26, + 26, 26, 26, 165, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 166, 26, 167, 168, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 169, 26, 170, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 171, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 172, 26, 26, 26, 26, + 26, 26, 26, 159, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 173, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 174, 175, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 176, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 159, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 177, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 178, 26, 157, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 179, 26, 26, 26, 26, 26, 26, 26, 26, 26, 158, 26, 26, 26, 26, 26, 180, + 181, 26, 182, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 183, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 184, 185, 26, 26, 26, 26, 186, 187, 188, 189, 190, 191, 192, + 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, + 207, 208, 209, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 210, 211, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 26, 213, 214, 215, 26, 216, 26, 217, 218, + 219, 220, 221, 26, 222, 26, 26, 223, 224, 225, 226, 227, 228, 26, 229, + 230, 231, 232, 233, 234, 235, 26, 236, 237, 238, 239, 240, 212, 212, 241, + 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 26, 26, + 26, 26, 255, 256, 257, 212, 258, 259, 260, 261, 262, 217, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 212, 26, 272, 273, 274, 275, 276, 277, 212, + 212, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, + 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 212, 212, 305, 306, 307, 308, 309, 310, 311, 312, 212, 212, 313, 212, + 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 212, 326, + 327, 328, 329, 212, 330, 331, 332, 333, 212, 212, 212, 334, 335, 336, + 337, 338, 339, 340, 26, 26, 26, 26, 26, 26, 341, 26, 26, 26, 342, 26, + 343, 212, 344, 345, 26, 26, 26, 346, 344, 344, 344, 344, 347, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 348, 349, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 350, 351, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 236, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 312, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 352, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 26, 26, 26, 26, 26, 26, 26, 26, 323, 353, 354, 355, 356, 357, 358, + 212, 212, 212, 212, 212, 212, 359, 212, 212, 212, 360, 361, 362, 26, 363, + 364, 365, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 366, 367, 212, 26, 368, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 369, 370, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 371, 26, 26, 26, 26, 372, 373, 26, 26, 26, 26, 26, 374, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 26, 375, 376, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 119, 119, 119, 377, 119, 119, 119, 119, 119, 119, 378, 379, 380, + 381, 119, 382, 119, 119, 119, 383, 384, 385, 386, 119, 119, 387, 388, + 389, 119, 390, 212, 212, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 401, 402, 403, 404, 405, 406, 119, 119, 119, 119, 119, 119, 119, + 119, 407, 408, 409, 212, 410, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 411, 412, 413, 414, 415, 416, 417, + 212, 418, 419, 212, 212, 212, 212, 420, 421, 212, 212, 212, 212, 212, + 212, 212, 422, 212, 212, 212, 423, 212, 212, 212, 424, 212, 212, 212, + 425, 26, 26, 26, 426, 427, 428, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 429, 430, 212, 431, 212, 212, 212, 432, 433, 434, 435, + 212, 212, 212, 212, 436, 119, 437, 438, 439, 440, 441, 442, 443, 444, + 212, 212, 119, 119, 119, 445, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 446, 119, 119, 119, 447, 448, 449, 450, 451, 119, 119, + 119, 119, 119, 452, 119, 453, 119, 119, 454, 455, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 456, 457, 26, + 458, 180, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 151, 26, 459, + 26, 26, 26, 26, 460, 461, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 462, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 463, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 164, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 176, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 464, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 465, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 216, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 466, 26, 26, 26, 26, 26, 26, 26, 26, 26, 467, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 26, 26, 462, 26, 26, 26, 26, 26, + 467, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 468, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 150, 26, 26, 469, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 470, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 471, 472, 212, 212, 12, 12, 12, 473, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, + 212, 212, 212, 212, 212, 212, }; static const unsigned short index2[] = { @@ -2399,88 +3013,88 @@ static const unsigned short index2[] = { 29, 30, 66, 67, 68, 68, 29, 30, 69, 70, 71, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 72, 73, 74, 75, 76, 19, 77, 77, 19, 78, 19, 79, 80, 19, 19, 19, 77, 81, 19, 82, 83, 84, 85, 19, 86, 87, 85, 88, 89, 19, 19, 87, 19, - 90, 91, 19, 19, 92, 19, 19, 19, 19, 19, 19, 19, 93, 19, 19, 94, 19, 95, - 94, 19, 19, 19, 96, 94, 97, 98, 98, 99, 19, 19, 19, 19, 19, 100, 19, 55, - 55, 19, 19, 19, 19, 19, 19, 19, 101, 102, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 104, 104, 104, 104, 104, 104, 104, 103, 103, 5, 5, 5, 5, 104, - 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 103, 103, 103, 103, 103, 5, 5, 5, 5, 5, 5, 5, - 104, 5, 104, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 24, 24, + 90, 91, 19, 19, 92, 19, 93, 19, 19, 19, 19, 93, 94, 19, 19, 95, 19, 96, + 95, 19, 19, 19, 97, 95, 98, 99, 99, 100, 19, 19, 19, 19, 19, 101, 19, 55, + 55, 19, 19, 19, 19, 19, 19, 19, 102, 103, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 105, 105, 105, 105, 105, 105, 105, 104, 104, 5, 5, 5, 5, 105, + 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 104, 104, 104, 104, 104, 5, 5, 5, 5, 5, 5, 5, + 105, 5, 105, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 105, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 106, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 29, 30, 29, 30, 104, 5, 29, 30, 0, 0, 106, 50, 50, 50, 4, 107, 0, - 0, 0, 0, 5, 5, 108, 24, 109, 109, 109, 0, 110, 0, 111, 111, 112, 16, 16, + 24, 24, 29, 30, 29, 30, 105, 5, 29, 30, 0, 0, 107, 50, 50, 50, 4, 108, 0, + 0, 0, 0, 5, 5, 109, 24, 110, 110, 110, 0, 111, 0, 112, 112, 113, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 113, 114, 114, 114, 115, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 116, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 117, 118, 118, 119, 120, 121, 122, 122, 122, 123, 124, - 125, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 126, 127, 128, 129, 130, 131, 4, 29, 30, 132, - 29, 30, 19, 64, 64, 64, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, - 133, 133, 133, 133, 133, 133, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 114, 115, 115, 115, 116, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 117, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 118, 119, 119, 120, 121, 122, 123, 123, 123, 124, 125, + 126, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, + 30, 29, 30, 29, 30, 29, 30, 127, 128, 129, 130, 131, 132, 4, 29, 30, 133, + 29, 30, 19, 64, 64, 64, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 134, 134, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 134, - 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - 134, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 135, + 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, + 135, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 4, 24, 24, 24, 24, 24, 5, 5, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, - 29, 30, 29, 30, 29, 30, 135, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 136, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, + 29, 30, 29, 30, 29, 30, 136, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, + 30, 29, 30, 137, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, - 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 0, 137, 137, 137, 137, 137, 137, - 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, - 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, - 137, 137, 137, 137, 0, 0, 104, 4, 4, 4, 4, 4, 5, 19, 138, 138, 138, 138, + 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 0, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 138, 139, 19, 4, 4, 0, 0, 4, 4, 4, 0, 24, 24, + 138, 138, 138, 138, 0, 104, 105, 4, 4, 4, 4, 4, 5, 19, 139, 139, 139, + 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + 139, 139, 139, 139, 139, 139, 139, 140, 19, 4, 4, 104, 104, 4, 4, 4, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 4, 24, 4, 24, 24, 4, 24, 24, 4, 24, 0, 0, 0, - 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 55, 55, - 55, 55, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 20, 20, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 4, - 20, 4, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 104, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 4, 4, 4, 4, 55, 55, 24, 55, 55, 55, 55, 55, 55, 55, 55, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 4, 24, 4, 24, 24, 4, 24, 24, 4, 24, + 24, 24, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, + 55, 55, 55, 55, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, + 20, 20, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 4, 20, 4, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 105, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 4, 4, 4, 4, 55, 55, 24, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 4, 55, 24, 24, 24, 24, 24, 24, 24, 20, 4, 24, 24, 24, 24, 24, 24, - 104, 104, 24, 24, 4, 24, 24, 24, 24, 55, 55, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 55, 55, 55, 4, 4, 55, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 0, 20, 55, 24, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 4, 55, 24, 24, 24, 24, 24, 24, 24, 20, 4, 24, 24, 24, 24, + 24, 24, 105, 105, 24, 24, 4, 24, 24, 24, 24, 55, 55, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 55, 55, 55, 4, 4, 55, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 0, 20, 55, 24, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 104, 104, 4, 4, 4, 4, 104, 0, 0, 24, 4, - 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 24, 24, 24, 24, 104, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 104, 24, 24, 24, 104, 24, 24, 24, 24, 24, 0, 0, 4, 4, 4, 4, 4, 4, 4, + 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 105, 105, 4, 4, 4, 4, 105, 0, 0, 24, + 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 24, 24, 24, 24, 105, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 105, 24, 24, 24, 105, 24, 24, 24, 24, 24, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 0, 0, 4, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 55, 55, @@ -2488,7 +3102,7 @@ static const unsigned short index2[] = { 55, 55, 55, 55, 5, 55, 55, 55, 55, 55, 55, 55, 20, 20, 0, 0, 0, 0, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 104, 24, 24, 24, 24, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 105, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 20, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 17, @@ -2497,7 +3111,7 @@ static const unsigned short index2[] = { 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 17, 24, 55, 17, 17, 17, 24, 24, 24, 24, 24, 24, 24, 24, 17, 17, 17, 17, 24, 17, 17, 55, 24, 24, 24, 24, 24, 24, 24, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 24, 24, 4, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 4, 104, + 55, 55, 55, 55, 24, 24, 4, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 4, 105, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 17, 17, 0, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, @@ -2522,7 +3136,7 @@ static const unsigned short index2[] = { 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 0, 55, 55, 55, 55, 55, 0, 0, 24, 55, 17, 24, 17, 24, 24, 24, 24, 0, 0, 17, 17, 0, 0, 17, - 17, 24, 0, 0, 0, 0, 0, 0, 0, 24, 24, 17, 0, 0, 0, 0, 55, 55, 0, 55, 55, + 17, 24, 0, 0, 0, 0, 0, 24, 24, 24, 24, 17, 0, 0, 0, 0, 55, 55, 0, 55, 55, 55, 24, 24, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 4, 55, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 55, 0, 55, 55, 55, 55, 55, 55, 0, 0, 0, 55, 55, 55, 0, 55, 55, 55, 55, 0, 0, 0, 55, 55, 0, 55, 0, @@ -2559,15 +3173,15 @@ static const unsigned short index2[] = { 9, 10, 11, 12, 13, 14, 15, 0, 0, 17, 17, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 55, 140, 24, 24, - 24, 24, 24, 24, 24, 0, 0, 0, 0, 4, 55, 55, 55, 55, 55, 55, 104, 24, 24, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 55, 141, 24, 24, + 24, 24, 24, 24, 24, 0, 0, 0, 0, 4, 55, 55, 55, 55, 55, 55, 105, 24, 24, 24, 24, 24, 24, 24, 24, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 0, 55, 0, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 24, 55, 140, 24, 24, 24, 24, 24, 24, 24, 24, 24, 55, 0, 0, 55, 55, - 55, 55, 55, 0, 104, 0, 24, 24, 24, 24, 24, 24, 24, 0, 6, 7, 8, 9, 10, 11, + 55, 24, 55, 141, 24, 24, 24, 24, 24, 24, 24, 24, 24, 55, 0, 0, 55, 55, + 55, 55, 55, 0, 105, 0, 24, 24, 24, 24, 24, 24, 24, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 24, 24, 4, 4, @@ -2591,331 +3205,280 @@ static const unsigned short index2[] = { 17, 17, 17, 17, 17, 17, 17, 55, 55, 55, 24, 24, 24, 24, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 17, 17, 24, 24, 17, 17, 17, 17, 17, 17, 24, 55, 17, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 17, 17, 24, - 4, 4, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, - 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, - 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 0, 141, 0, 0, 0, - 0, 0, 141, 0, 0, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, + 4, 4, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, - 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, - 142, 142, 142, 142, 4, 103, 142, 142, 142, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, - 55, 0, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 0, 55, 55, 55, 55, 0, 0, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 0, 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, - 55, 55, 0, 55, 0, 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 0, 0, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 24, 24, 24, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 143, 144, 145, 146, 147, 148, 149, 150, 151, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, - 0, 0, 0, 0, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, - 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, - 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, - 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, - 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, - 234, 235, 236, 237, 0, 0, 238, 239, 240, 241, 242, 243, 0, 0, 4, 55, 55, + 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 0, 142, 0, 0, 0, + 0, 0, 142, 0, 0, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 4, 104, 143, 143, 143, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 0, 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 0, + 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 0, + 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 0, 55, 55, 55, 55, 0, 0, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, + 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 0, 0, 24, 24, 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 144, 145, 146, 147, 148, + 149, 150, 151, 152, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, + 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, + 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, + 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, + 230, 231, 232, 233, 234, 235, 236, 237, 238, 0, 0, 239, 240, 241, 242, + 243, 244, 0, 0, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 1, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 1, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 4, - 244, 244, 244, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, - 24, 24, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 17, 4, 4, 0, 0, 0, 0, + 55, 55, 55, 4, 4, 4, 245, 245, 245, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 0, 24, 24, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 24, 24, 24, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, + 17, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, + 0, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 24, 24, 17, 24, 24, 24, 24, 24, 24, 24, 17, 17, 17, - 17, 17, 17, 17, 17, 24, 17, 17, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 4, 4, 4, 104, 4, 4, 4, 4, 55, 24, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, - 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 24, 24, 24, 20, 24, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 17, 24, 24, 24, 24, 24, + 24, 24, 17, 17, 17, 17, 17, 17, 17, 17, 24, 17, 17, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 4, 4, 4, 105, 4, 4, 4, 4, 55, 24, 0, 0, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 24, 24, + 24, 20, 24, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 104, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 105, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, - 55, 55, 245, 245, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, + 0, 0, 0, 55, 55, 55, 55, 55, 246, 246, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 24, 55, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 24, 55, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 24, 24, 24, + 17, 17, 17, 17, 24, 24, 17, 17, 17, 0, 0, 0, 0, 17, 17, 24, 17, 17, 17, + 17, 17, 17, 24, 24, 24, 0, 0, 0, 0, 4, 0, 0, 0, 4, 4, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 55, + 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 0, 24, 24, 24, 17, 17, 17, 17, 24, 24, - 17, 17, 17, 0, 0, 0, 0, 17, 17, 24, 17, 17, 17, 17, 17, 17, 24, 24, 24, - 0, 0, 0, 0, 4, 0, 0, 0, 4, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 144, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 24, 24, 17, 17, 24, 0, 0, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, 143, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 24, 17, 24, 24, + 24, 24, 24, 24, 24, 0, 24, 17, 24, 17, 17, 24, 24, 24, 24, 24, 24, 24, + 24, 17, 17, 17, 17, 17, 17, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, + 24, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 105, 4, 4, 4, + 4, 4, 4, 0, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 5, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 17, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 24, 24, 17, 17, 24, 0, 0, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 24, 17, 24, 24, 24, 24, 24, 17, 24, 17, 17, 17, 17, + 17, 24, 17, 17, 55, 55, 55, 55, 55, 55, 55, 55, 0, 4, 4, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 24, 24, 17, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 24, 24, + 24, 24, 17, 17, 24, 24, 17, 24, 24, 24, 55, 55, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 17, 24, 24, 17, 17, 17, + 24, 17, 24, 24, 24, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 17, 24, 17, 24, 24, 24, 24, 24, 24, 24, 0, - 24, 17, 24, 17, 17, 24, 24, 24, 24, 24, 24, 24, 24, 17, 17, 17, 17, 17, - 17, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 24, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, - 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 104, 4, 4, 4, 4, 4, 4, 0, 0, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 5, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 24, 24, 24, 24, 17, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 17, - 24, 24, 24, 24, 24, 17, 24, 17, 17, 17, 17, 17, 24, 17, 17, 55, 55, 55, - 55, 55, 55, 55, 55, 0, 4, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 24, 24, 17, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 17, 24, 24, 24, 24, 17, 17, 24, 24, 17, 24, - 24, 24, 55, 55, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 24, 17, 24, 24, 17, 17, 17, 24, 17, 24, 24, 24, 17, 17, 0, 0, - 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 17, 17, 17, 17, 17, 17, 17, 17, 24, 24, 24, - 24, 24, 24, 24, 24, 17, 17, 24, 24, 0, 0, 0, 4, 4, 4, 4, 4, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 0, 0, 0, 55, 55, 55, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 104, 104, 104, - 104, 104, 104, 4, 4, 246, 247, 248, 249, 250, 251, 252, 253, 254, 29, 30, - 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 0, 0, 255, 255, 255, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 24, 24, 24, 4, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 17, 24, 24, 24, 24, 24, 24, 24, 55, 55, 55, 55, 24, 55, 55, 55, - 55, 55, 55, 24, 55, 55, 17, 24, 24, 55, 0, 0, 0, 0, 0, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, + 17, 17, 17, 17, 17, 17, 24, 24, 24, 24, 24, 24, 24, 24, 17, 17, 24, 24, + 0, 0, 0, 4, 4, 4, 4, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 55, + 55, 55, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 105, 105, 105, 105, 105, 105, 4, 4, 247, 248, 249, + 250, 251, 252, 253, 254, 255, 29, 30, 0, 0, 0, 0, 0, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 0, 0, 256, 256, + 256, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 24, 24, 24, 4, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 17, 24, 24, 24, 24, 24, + 24, 24, 55, 55, 55, 55, 24, 55, 55, 55, 55, 55, 55, 24, 55, 55, 17, 24, + 24, 55, 0, 0, 0, 0, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 103, 256, 19, 19, 19, 257, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 258, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 29, 30, 29, 30, 29, 30, 29, 30, 29, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 104, 257, 19, 19, 19, 258, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 259, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 259, 260, - 261, 262, 263, 264, 19, 19, 265, 19, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 266, 266, - 266, 266, 266, 266, 266, 266, 267, 267, 267, 267, 267, 267, 267, 267, - 266, 266, 266, 266, 266, 266, 0, 0, 267, 267, 267, 267, 267, 267, 0, 0, - 266, 266, 266, 266, 266, 266, 266, 266, 267, 267, 267, 267, 267, 267, - 267, 267, 266, 266, 266, 266, 266, 266, 266, 266, 267, 267, 267, 267, - 267, 267, 267, 267, 266, 266, 266, 266, 266, 266, 0, 0, 267, 267, 267, - 267, 267, 267, 0, 0, 268, 266, 269, 266, 270, 266, 271, 266, 0, 267, 0, - 267, 0, 267, 0, 267, 266, 266, 266, 266, 266, 266, 266, 266, 267, 267, - 267, 267, 267, 267, 267, 267, 272, 272, 273, 273, 273, 273, 274, 274, - 275, 275, 276, 276, 277, 277, 0, 0, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, - 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, - 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 266, - 266, 326, 327, 328, 0, 329, 330, 267, 267, 331, 331, 332, 5, 333, 5, 5, - 5, 334, 335, 336, 0, 337, 338, 339, 339, 339, 339, 340, 5, 5, 5, 266, - 266, 341, 342, 0, 0, 343, 344, 267, 267, 345, 345, 0, 5, 5, 5, 266, 266, - 346, 347, 348, 128, 349, 350, 267, 267, 351, 351, 132, 5, 5, 5, 0, 0, - 352, 353, 354, 0, 355, 356, 357, 357, 358, 358, 359, 5, 5, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 20, 360, 360, 20, 20, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, + 30, 29, 30, 29, 30, 29, 30, 260, 261, 262, 263, 264, 265, 19, 19, 266, + 19, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, + 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 267, 267, + 267, 267, 267, 267, 267, 267, 268, 268, 268, 268, 268, 268, 268, 268, + 267, 267, 267, 267, 267, 267, 0, 0, 268, 268, 268, 268, 268, 268, 0, 0, + 267, 267, 267, 267, 267, 267, 267, 267, 268, 268, 268, 268, 268, 268, + 268, 268, 267, 267, 267, 267, 267, 267, 267, 267, 268, 268, 268, 268, + 268, 268, 268, 268, 267, 267, 267, 267, 267, 267, 0, 0, 268, 268, 268, + 268, 268, 268, 0, 0, 269, 267, 270, 267, 271, 267, 272, 267, 0, 268, 0, + 268, 0, 268, 0, 268, 267, 267, 267, 267, 267, 267, 267, 267, 268, 268, + 268, 268, 268, 268, 268, 268, 273, 273, 274, 274, 274, 274, 275, 275, + 276, 276, 277, 277, 278, 278, 0, 0, 279, 280, 281, 282, 283, 284, 285, + 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, + 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 267, + 267, 327, 328, 329, 0, 330, 331, 268, 268, 332, 332, 333, 5, 334, 5, 5, + 5, 335, 336, 337, 0, 338, 339, 340, 340, 340, 340, 341, 5, 5, 5, 267, + 267, 342, 343, 0, 0, 344, 345, 268, 268, 346, 346, 0, 5, 5, 5, 267, 267, + 347, 348, 349, 129, 350, 351, 268, 268, 352, 352, 133, 5, 5, 5, 0, 0, + 353, 354, 355, 0, 356, 357, 358, 358, 359, 359, 360, 5, 5, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 20, 361, 361, 20, 20, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 2, 2, 20, 20, 20, 20, 20, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 17, 17, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 17, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 20, - 20, 20, 20, 20, 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 361, 103, 0, - 0, 362, 363, 364, 365, 366, 367, 4, 4, 4, 4, 4, 103, 361, 25, 21, 22, - 362, 363, 364, 365, 366, 367, 4, 4, 4, 4, 4, 0, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, + 20, 20, 20, 20, 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 362, 104, 0, + 0, 363, 364, 365, 366, 367, 368, 4, 4, 4, 4, 4, 104, 362, 25, 21, 22, + 363, 364, 365, 366, 367, 368, 4, 4, 4, 4, 4, 105, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 5, 5, 5, 5, 24, 5, 5, 5, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 4, 122, 4, 4, 4, 4, 122, 4, 4, 19, 122, 122, 122, 19, 19, 122, 122, - 122, 19, 4, 122, 4, 4, 368, 122, 122, 122, 122, 122, 4, 4, 4, 4, 4, 4, - 122, 4, 369, 4, 122, 4, 370, 371, 122, 122, 368, 19, 122, 122, 372, 122, - 19, 55, 55, 55, 55, 19, 4, 4, 19, 19, 122, 122, 4, 4, 4, 4, 4, 122, 19, - 19, 19, 19, 4, 4, 4, 4, 373, 4, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, - 374, 374, 374, 374, 374, 374, 375, 375, 375, 375, 375, 375, 375, 375, - 375, 375, 375, 375, 375, 375, 375, 375, 244, 244, 244, 29, 30, 244, 244, - 244, 244, 26, 4, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 5, 5, 5, 5, 24, 5, 5, 5, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 4, 4, 123, 4, 4, 4, 4, 123, 4, 4, 19, 123, 123, 123, 19, 19, + 123, 123, 123, 19, 4, 123, 4, 4, 369, 123, 123, 123, 123, 123, 4, 4, 4, + 4, 4, 4, 123, 4, 370, 4, 123, 4, 371, 372, 123, 123, 369, 19, 123, 123, + 373, 123, 19, 55, 55, 55, 55, 19, 4, 4, 19, 19, 123, 123, 4, 4, 4, 4, 4, + 123, 19, 19, 19, 19, 4, 4, 4, 4, 374, 4, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 375, 375, 375, 375, 375, 375, 375, 375, + 375, 375, 375, 375, 375, 375, 375, 375, 376, 376, 376, 376, 376, 376, + 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 245, 245, 245, 29, 30, + 245, 245, 245, 245, 26, 4, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 21, 22, 362, 363, 364, 365, 366, 367, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 25, 21, 22, 362, 363, 364, - 365, 366, 367, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 25, 21, 22, - 362, 363, 364, 365, 366, 367, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, - 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 377, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 25, 21, 22, 363, 364, 365, 366, 367, 368, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 25, 21, 22, 363, 364, 365, 366, 367, 368, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 25, 21, 22, 363, 364, 365, + 366, 367, 368, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, - 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 361, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 25, 21, 22, 362, 363, 364, 365, 366, 367, 26, - 361, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 378, 378, 378, 378, + 378, 378, 378, 378, 378, 378, 378, 378, 378, 378, 378, 378, 378, 378, + 378, 378, 378, 378, 378, 378, 378, 378, 362, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 25, 21, 22, 363, 364, 365, 366, 367, 368, 26, 362, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 25, - 21, 22, 362, 363, 364, 365, 366, 367, 26, 25, 21, 22, 362, 363, 364, 365, - 366, 367, 26, 25, 21, 22, 362, 363, 364, 365, 366, 367, 26, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 25, 21, 22, 363, 364, 365, 366, 367, 368, 26, 25, 21, 22, 363, + 364, 365, 366, 367, 368, 26, 25, 21, 22, 363, 364, 365, 366, 367, 368, + 26, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 137, 137, 137, 137, 137, - 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, - 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, - 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, - 137, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, + 4, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 138, 138, 29, 30, 378, 379, 380, 381, 382, 29, - 30, 29, 30, 29, 30, 383, 384, 385, 386, 19, 29, 30, 19, 29, 30, 19, 19, - 19, 19, 19, 103, 103, 387, 387, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, - 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, - 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, - 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, - 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, - 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, - 19, 4, 4, 4, 4, 4, 4, 29, 30, 29, 30, 24, 24, 24, 29, 30, 0, 0, 0, 0, 0, - 4, 4, 4, 4, 26, 4, 4, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, - 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 0, - 388, 0, 0, 0, 0, 0, 388, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 139, + 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, + 139, 139, 139, 139, 139, 29, 30, 379, 380, 381, 382, 383, 29, 30, 29, 30, + 29, 30, 384, 385, 386, 387, 19, 29, 30, 19, 29, 30, 19, 19, 19, 19, 19, + 104, 104, 388, 388, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, + 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, + 30, 29, 30, 29, 30, 19, 4, 4, 4, 4, 4, 4, 29, 30, 29, 30, 24, 24, 24, 29, + 30, 0, 0, 0, 0, 0, 4, 4, 4, 4, 26, 4, 4, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, 389, + 389, 389, 389, 389, 0, 389, 0, 0, 0, 0, 0, 389, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 104, 4, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, - 55, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, + 0, 0, 0, 105, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, - 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 0, 24, 24, 24, 24, 24, 24, 24, + 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, + 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 389, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 390, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 4, 4, 4, 4, 104, 55, 244, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 244, 244, 244, - 244, 244, 244, 244, 244, 244, 24, 24, 24, 24, 17, 17, 4, 104, 104, 104, - 104, 104, 4, 4, 244, 244, 244, 104, 55, 4, 4, 4, 0, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 24, 24, 5, 5, 104, 104, 55, 4, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 1, 4, 4, 4, 4, 105, 55, 245, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 24, 24, 24, 24, 17, 17, 4, 105, 105, 105, 105, 105, 4, 4, 245, 245, + 245, 105, 55, 4, 4, 4, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 17, 104, 104, 104, 55, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 0, 0, 24, 24, 5, 5, 105, 105, 55, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 105, 105, 105, 55, 0, 0, + 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 0, 4, 4, 26, 26, 26, 26, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 55, + 55, 55, 55, 55, 0, 4, 4, 26, 26, 26, 26, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 4, 4, 4, 4, 4, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 55, 55, 55, 55, 55, + 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, @@ -2925,468 +3488,325 @@ static const unsigned short index2[] = { 4, 4, 4, 4, 4, 4, 4, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 55, 55, - 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 26, 26, 26, 26, 26, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 391, 55, 55, 55, 391, + 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 391, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 391, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 391, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 390, 55, 55, 390, 55, 55, 55, 390, - 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 391, 55, 391, 55, 391, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 391, 391, + 391, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 391, 391, 391, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 390, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 390, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 390, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, + 391, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 391, 391, + 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 390, 55, 390, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, - 55, 390, 390, 390, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 390, 390, 390, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, + 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 390, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 105, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 105, 105, 105, + 105, 105, 105, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 105, + 4, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, + 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, + 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 55, + 24, 5, 5, 5, 4, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 4, 105, 29, 30, + 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, + 29, 30, 29, 30, 29, 30, 29, 30, 104, 104, 24, 24, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 24, 24, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 105, + 105, 105, 105, 105, 105, 105, 105, 105, 5, 5, 29, 30, 29, 30, 29, 30, 29, + 30, 29, 30, 29, 30, 29, 30, 19, 19, 29, 30, 29, 30, 29, 30, 29, 30, 29, + 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, + 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, + 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 104, + 19, 19, 19, 19, 19, 19, 19, 19, 29, 30, 29, 30, 392, 29, 30, 29, 30, 29, + 30, 29, 30, 29, 30, 105, 5, 5, 29, 30, 393, 19, 55, 29, 30, 29, 30, 394, + 19, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, + 30, 29, 30, 395, 396, 397, 398, 395, 19, 399, 400, 401, 402, 29, 30, 29, + 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 403, 404, 405, 29, + 30, 29, 30, 406, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, + 29, 30, 407, 408, 0, 0, 0, 0, 408, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 104, 104, 104, 104, 29, 30, 55, 104, 104, 19, 55, 55, 55, 55, 55, 55, + 55, 24, 55, 55, 55, 24, 55, 55, 55, 55, 24, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, + 24, 24, 17, 4, 4, 4, 4, 24, 0, 0, 0, 26, 26, 26, 26, 26, 26, 4, 4, 4, 4, + 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 55, 55, 55, 55, 55, 55, + 4, 4, 4, 55, 4, 55, 55, 24, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 24, 24, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 390, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 390, 390, - 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 17, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 0, 0, 0, 24, 24, 24, 17, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, + 17, 17, 24, 24, 24, 24, 17, 17, 24, 24, 17, 17, 17, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 0, 105, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, + 4, 4, 55, 55, 55, 55, 55, 24, 105, 55, 55, 55, 55, 55, 55, 55, 55, 55, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 24, 24, 24, 24, 24, 24, 17, 17, 24, 24, 17, 17, 24, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 55, 55, 55, 24, 55, 55, 55, 55, 55, 55, 55, 55, 24, 17, 0, + 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 4, 4, 4, 4, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 105, 55, 55, 55, 55, 55, + 55, 4, 4, 4, 55, 17, 24, 17, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 24, 55, 24, 24, 24, 55, 55, 24, 24, 55, 55, 55, 55, 55, 24, + 24, 55, 24, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 55, 55, 105, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 17, 24, 24, 17, 17, 4, 4, 55, 105, 105, 17, 24, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 55, 55, 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, 0, 0, 55, + 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, + 55, 0, 55, 55, 55, 55, 55, 55, 55, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 409, 409, 19, 19, 19, 19, 19, 19, 410, 19, 19, 19, 19, 19, 19, 19, 5, + 104, 104, 104, 104, 19, 19, 19, 19, 19, 19, 19, 19, 19, 104, 5, 5, 411, + 411, 0, 0, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, + 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, + 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, + 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, + 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, + 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 24, 17, + 17, 24, 17, 17, 4, 17, 24, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, + 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, + 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 492, + 493, 494, 495, 496, 497, 498, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 499, + 500, 501, 502, 503, 0, 0, 0, 0, 0, 55, 24, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, + 55, 55, 55, 55, 0, 55, 0, 55, 55, 0, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 504, 504, 504, 504, 504, 504, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, + 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 504, 504, 4, 4, 4, 4, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 4, 4, 4, 17, + 17, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 17, 17, 17, 4, 4, 5, 0, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 0, 4, 4, 4, 4, 0, 0, 0, 0, 504, 55, 504, 55, 504, 0, 504, 55, + 504, 55, 504, 55, 504, 55, 504, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 20, + 0, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 5, 4, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 5, 4, 4, 4, 4, 4, 4, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 4, 4, 4, + 5, 17, 5, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 17, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 105, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 505, 505, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, + 0, 55, 55, 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, 0, 0, 55, 55, + 55, 55, 55, 55, 0, 0, 55, 55, 55, 0, 0, 0, 4, 4, 4, 5, 4, 4, 4, 0, 4, 4, + 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 4, 4, 0, 0, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 0, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 4, 4, + 4, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 26, + 26, 26, 26, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 26, 26, 4, + 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 4, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 24, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, - 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 390, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 104, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 104, 104, 104, - 104, 104, 104, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 104, - 4, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 55, - 24, 5, 5, 5, 4, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 4, 104, 29, 30, - 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, - 29, 30, 29, 30, 29, 30, 29, 30, 103, 103, 24, 24, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 244, 244, 244, 244, 244, 244, - 244, 244, 244, 244, 24, 24, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 104, - 104, 104, 104, 104, 104, 104, 104, 104, 5, 5, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 19, 19, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 103, - 19, 19, 19, 19, 19, 19, 19, 19, 29, 30, 29, 30, 391, 29, 30, 29, 30, 29, - 30, 29, 30, 29, 30, 104, 5, 5, 29, 30, 392, 19, 55, 29, 30, 29, 30, 393, - 19, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, - 30, 29, 30, 394, 395, 396, 397, 394, 19, 398, 399, 400, 401, 29, 30, 29, - 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 402, 403, 404, 29, - 30, 29, 30, 405, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, - 29, 30, 406, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 103, 103, 103, 103, 29, 30, 55, 103, 103, 19, 55, 55, 55, 55, 55, 55, 55, - 24, 55, 55, 55, 24, 55, 55, 55, 55, 24, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 24, - 24, 17, 4, 4, 4, 4, 24, 0, 0, 0, 26, 26, 26, 26, 26, 26, 4, 4, 4, 4, 0, - 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 55, 55, 55, 55, 55, 55, - 4, 4, 4, 55, 4, 55, 55, 24, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 24, 24, 4, 4, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 17, 17, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 0, 0, 0, 24, 24, 24, 17, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, - 17, 17, 24, 24, 24, 24, 17, 17, 24, 24, 17, 17, 17, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 0, 104, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, - 4, 4, 55, 55, 55, 55, 55, 24, 104, 55, 55, 55, 55, 55, 55, 55, 55, 55, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 24, 24, 24, 24, 24, 24, 17, 17, 24, 24, 17, 17, 24, 24, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 55, 55, 55, 24, 55, 55, 55, 55, 55, 55, 55, 55, 24, 17, 0, - 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 4, 4, 4, 4, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 104, 55, 55, 55, 55, 55, - 55, 4, 4, 4, 55, 17, 24, 17, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 24, 55, 24, 24, 24, 55, 55, 24, 24, 55, 55, 55, 55, 55, 24, - 24, 55, 24, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 55, 55, 104, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 17, 24, 24, 17, 17, 4, 4, 55, 104, 104, 17, 24, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 55, 55, 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, 0, 0, 55, - 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, - 55, 0, 55, 55, 55, 55, 55, 55, 55, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 407, 19, 19, 19, 19, 19, 19, 19, 5, 103, - 103, 103, 103, 19, 19, 19, 19, 19, 19, 19, 19, 19, 103, 5, 5, 0, 0, 0, 0, - 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, - 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, - 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, - 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, - 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, - 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 24, 17, 17, 24, 17, - 17, 4, 17, 24, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, - 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 390, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, - 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 488, 489, 490, 491, 492, 493, 494, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 495, 496, 497, 498, 499, 0, 0, 0, 0, 0, 55, 24, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 0, 55, 55, 55, 55, 55, 0, 55, 0, 55, 55, 0, 55, 55, 0, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 500, - 500, 500, 500, 500, 500, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 4, 4, 4, 4, 4, 4, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 500, 500, - 4, 4, 4, 4, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 4, 4, 4, 17, 17, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 17, 17, 17, - 4, 4, 5, 0, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, - 4, 4, 4, 4, 0, 0, 0, 0, 500, 55, 500, 55, 500, 0, 500, 55, 500, 55, 500, - 55, 500, 55, 500, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 0, 0, 20, 0, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 5, 4, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 4, 4, 4, 4, 4, 4, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 4, 4, 4, 5, 17, 5, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 17, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 104, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 501, 501, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 0, 0, 0, 55, 55, 55, 55, 55, 55, 0, 0, 55, 55, - 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, 0, 0, 55, 55, 55, 0, 0, 0, - 4, 4, 4, 5, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 20, 20, 20, 4, 4, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 0, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 4, 4, - 4, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, - 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, - 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, - 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 26, - 26, 26, 26, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 26, 26, 4, - 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 4, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 24, 0, 0, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 26, 26, @@ -3395,44 +3815,44 @@ static const unsigned short index2[] = { 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 244, 55, 55, 55, 55, 55, 55, 55, 55, 244, 0, 0, 0, 0, 0, 55, 55, 55, + 55, 245, 55, 55, 55, 55, 55, 55, 55, 55, 245, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 4, 244, 244, 244, - 244, 244, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 502, 502, - 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, - 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, - 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 503, 503, 503, 503, - 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, - 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, - 503, 503, 503, 503, 503, 503, 503, 503, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 4, 245, 245, 245, + 245, 245, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 506, 506, + 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, + 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, + 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 502, 502, 502, 502, - 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, - 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, - 502, 502, 502, 502, 0, 0, 0, 0, 503, 503, 503, 503, 503, 503, 503, 503, - 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, - 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 0, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 506, 506, 506, 506, + 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, + 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, + 506, 506, 506, 506, 0, 0, 0, 0, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, 0, 504, 504, - 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, 0, 504, - 504, 504, 504, 504, 504, 504, 0, 504, 504, 0, 505, 505, 505, 505, 505, - 505, 505, 505, 505, 505, 505, 0, 505, 505, 505, 505, 505, 505, 505, 505, - 505, 505, 505, 505, 505, 505, 505, 0, 505, 505, 505, 505, 505, 505, 505, - 0, 505, 505, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 4, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 0, 508, 508, + 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 0, 508, + 508, 508, 508, 508, 508, 508, 0, 508, 508, 0, 509, 509, 509, 509, 509, + 509, 509, 509, 509, 509, 509, 0, 509, 509, 509, 509, 509, 509, 509, 509, + 509, 509, 509, 509, 509, 509, 509, 0, 509, 509, 509, 509, 509, 509, 509, + 0, 509, 509, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, @@ -3442,678 +3862,575 @@ static const unsigned short index2[] = { 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 103, 104, 104, 103, 103, 103, 0, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 0, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 55, 55, 55, 55, 55, 55, 0, 0, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 0, 0, 104, 105, 105, 104, 104, 104, 0, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 0, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 55, 55, 55, 55, 55, 55, 0, 0, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, - 55, 55, 0, 0, 0, 55, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 4, 26, 26, 26, 26, 26, - 26, 26, 26, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 26, 26, 26, 26, 26, 26, 26, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 0, 0, 0, 0, 0, 26, 26, 26, 26, - 26, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 26, 26, 26, 26, 26, 26, 0, 0, 0, 4, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 0, 0, 0, 55, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 0, 0, 0, 0, 0, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, + 55, 55, 0, 4, 26, 26, 26, 26, 26, 26, 26, 26, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 26, + 26, 26, 26, 26, 26, 26, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 0, 0, 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, + 55, 55, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 26, 26, 26, + 26, 26, 26, 0, 0, 0, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 26, 26, 55, 55, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 26, 26, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 0, 0, 0, 0, 26, 26, 55, 55, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 55, 24, 24, 24, 0, 24, 24, 0, 0, 0, 0, 0, - 24, 24, 24, 24, 55, 55, 55, 55, 0, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, + 55, 24, 24, 24, 0, 24, 24, 0, 0, 0, 0, 0, 24, 24, 24, 24, 55, 55, 55, 55, + 0, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 24, 24, + 24, 0, 0, 0, 0, 24, 25, 21, 22, 363, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, + 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 0, 0, 24, 24, 24, 0, 0, 0, 0, 24, 25, 21, 22, 362, - 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, - 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 26, 26, 4, + 55, 55, 55, 55, 55, 55, 26, 26, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 26, 26, 26, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 4, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, + 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 0, 0, 0, 0, 26, 26, + 26, 26, 26, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 24, 24, 0, 0, 0, 0, 26, 26, 26, 26, 26, 4, 4, 4, 4, 4, 4, 4, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 4, + 4, 4, 4, 4, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, - 26, 26, 26, 26, 26, 26, 26, 26, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, - 26, 26, 26, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 4, + 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 111, 111, 111, 111, 111, 111, 111, + 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, + 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, + 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, + 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 0, 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 0, 0, 0, - 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, - 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 55, 55, 55, 55, 104, 55, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 24, - 24, 24, 24, 24, 4, 104, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, + 24, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, + 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 55, 55, 55, 55, 105, 55, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 0, 0, 0, 24, 24, 24, 24, 24, 4, 105, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 0, 0, 0, + 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 21, 22, 362, 363, 364, - 365, 366, 367, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 21, 22, 363, 364, 365, + 366, 367, 368, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 24, 24, 4, 0, 0, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, - 104, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 24, 24, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 55, 0, 0, 0, 0, 0, 0, - 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 26, 26, - 26, 26, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 24, 24, 24, 24, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 17, 24, 17, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 25, 21, 22, 362, 363, 364, - 365, 366, 367, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 24, 55, 55, 24, 24, 55, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 24, 24, 24, 17, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 17, 24, - 24, 24, 24, 17, 17, 24, 24, 4, 4, 20, 4, 4, 4, 4, 24, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 20, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 24, 24, 24, 55, 55, + 105, 55, 55, 0, 5, 5, 24, 24, 24, 24, 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 55, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, - 24, 24, 24, 17, 24, 24, 24, 24, 24, 24, 24, 24, 0, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 4, 4, 4, 4, 55, 17, 17, 55, 0, 0, 0, 0, 0, 0, 0, 0, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 4, 4, - 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 24, 17, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 17, 17, 17, 24, 24, 24, 24, 24, 24, 24, 24, 24, 17, - 17, 55, 55, 55, 55, 4, 4, 4, 4, 24, 24, 24, 24, 4, 17, 24, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 55, 4, 55, 4, 4, 4, 0, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 17, 24, 24, 24, - 17, 17, 24, 17, 24, 24, 4, 4, 4, 4, 4, 4, 24, 55, 55, 24, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 0, 55, 55, - 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 0, 0, 0, 0, 0, 0, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 24, 17, 17, 17, 24, 24, 24, 24, 24, 24, - 24, 24, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, - 0, 24, 24, 17, 17, 0, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 55, 55, 0, 0, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 0, 55, 55, 55, - 55, 55, 0, 24, 24, 55, 17, 17, 24, 17, 17, 17, 17, 0, 0, 17, 17, 0, 0, - 17, 17, 17, 0, 0, 55, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 55, 55, 55, - 55, 55, 17, 17, 0, 0, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 24, 24, 24, - 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 0, 55, 0, 0, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 17, 17, 17, 24, 24, 24, 24, - 24, 24, 0, 17, 0, 0, 17, 0, 17, 17, 17, 17, 0, 17, 17, 24, 17, 24, 55, - 24, 55, 4, 4, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 24, 24, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, - 17, 24, 24, 24, 24, 24, 24, 24, 24, 17, 17, 24, 24, 24, 17, 24, 55, 55, - 55, 55, 4, 4, 4, 4, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 4, 4, 0, 4, - 24, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 17, 17, 17, 24, 24, 24, 24, 24, 24, 17, 24, 17, 17, 17, 17, 24, - 24, 17, 24, 24, 55, 55, 4, 55, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 26, 26, 26, 26, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 17, 24, 24, 24, 24, 0, 0, 17, 17, - 17, 17, 24, 24, 17, 24, 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 55, 55, 55, 55, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 17, 24, 24, - 24, 24, 24, 24, 24, 24, 17, 17, 24, 17, 24, 24, 4, 4, 4, 55, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, - 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 17, 24, 17, - 17, 24, 24, 24, 24, 24, 24, 17, 24, 55, 4, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 0, 0, 24, 17, 24, 17, 17, 24, 24, 24, 24, 17, 24, 24, 24, - 24, 24, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 26, 26, 4, 4, 4, - 4, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, + 24, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 26, + 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 24, 17, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 17, 17, 17, 24, 24, 24, 24, 24, 24, 24, 24, 24, 17, 24, - 24, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 55, 0, 0, 55, 55, - 55, 55, 55, 55, 55, 55, 0, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 17, - 17, 17, 17, 0, 17, 17, 0, 0, 24, 24, 17, 24, 55, 17, 55, 17, 24, 4, 4, 4, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, - 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 17, 24, 24, 24, 24, 0, 0, 24, 24, - 17, 17, 17, 17, 24, 55, 4, 55, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 4, 4, 4, 4, 4, 4, + 4, 0, 0, 0, 0, 25, 21, 22, 363, 364, 365, 366, 367, 368, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 24, 55, + 55, 24, 24, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 24, 24, 17, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 17, 55, 24, 24, 24, - 24, 4, 4, 4, 4, 4, 4, 4, 4, 24, 0, 0, 0, 0, 0, 0, 0, 0, 55, 24, 24, 24, - 24, 24, 24, 17, 17, 24, 24, 24, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 17, 17, 17, 24, 24, 24, 24, 17, 17, 24, 24, 4, 4, + 20, 4, 4, 4, 4, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 17, 24, 24, 4, 4, 4, - 55, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, + 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 0, 0, 0, 0, 0, 0, 24, 24, 24, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, 17, 24, 24, 24, 24, 24, + 24, 24, 24, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 4, 4, 4, 4, 55, 17, + 17, 55, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 24, 4, 4, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, + 24, 17, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, - 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 24, 17, 24, 24, 24, 17, 24, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 17, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 17, 17, 55, 55, 55, 55, 4, 4, 4, 4, 24, + 24, 24, 24, 4, 17, 24, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 55, 4, 55, 4, + 4, 4, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 17, 17, 17, 24, 24, 24, 17, 17, 24, 17, 24, 24, 4, 4, 4, 4, 4, 4, + 24, 55, 55, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, + 55, 55, 55, 0, 55, 0, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, + 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 17, 24, 24, 24, 24, 24, 24, 24, 0, 24, 24, 24, 24, 24, 24, 17, 24, 55, 4, - 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 0, 0, 0, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 17, 17, + 17, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 24, 24, 17, 17, 0, 55, 55, 55, 55, 55, + 55, 55, 55, 0, 0, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, + 55, 55, 0, 55, 55, 0, 55, 55, 55, 55, 55, 0, 24, 24, 55, 17, 17, 24, 17, + 17, 17, 17, 0, 0, 17, 17, 0, 0, 17, 17, 17, 0, 0, 55, 0, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 17, 17, 0, 0, 24, 24, 24, 24, 24, + 24, 24, 0, 0, 0, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 0, 0, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 0, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 0, 17, 24, 24, 24, 24, 24, 24, 24, 17, 24, 24, 17, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, + 17, 17, 17, 24, 24, 24, 24, 24, 24, 0, 17, 0, 0, 17, 0, 17, 17, 17, 17, + 0, 17, 17, 24, 17, 24, 55, 24, 55, 4, 4, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 0, 55, 55, 55, 55, 55, + 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, - 24, 24, 24, 0, 0, 0, 24, 0, 24, 24, 0, 24, 24, 24, 24, 24, 24, 24, 55, - 24, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, - 0, 0, 0, 55, 55, 55, 55, 55, 55, 0, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 17, 17, 17, 0, 24, 24, 0, 17, 17, - 24, 17, 24, 55, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 17, 17, 17, 24, 24, 24, 24, 24, 24, 24, 24, 17, 17, 24, + 24, 24, 17, 24, 55, 55, 55, 55, 4, 4, 4, 4, 4, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 4, 4, 0, 4, 24, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 104, 55, 55, 0, 0, 0, 0, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 24, 24, 17, 17, 4, 4, 0, 0, 0, 0, 0, 0, 0, 24, 24, - 55, 17, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 24, 24, - 24, 24, 24, 0, 0, 0, 17, 17, 24, 17, 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 17, 24, 24, 24, 24, 24, 24, 17, + 24, 17, 17, 17, 17, 24, 24, 17, 24, 24, 55, 55, 4, 55, 0, 0, 0, 0, 0, 0, + 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 55, 55, 55, 55, + 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 17, 24, + 24, 24, 24, 0, 0, 17, 17, 17, 17, 24, 24, 17, 24, 24, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 55, 55, 55, 55, 24, + 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 17, 17, 17, 24, 24, 24, 24, 24, 24, 24, 24, 17, 17, 24, 17, 24, + 24, 4, 4, 4, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 24, 17, 24, 17, 17, 24, 24, 24, 24, 24, 24, 17, 24, 55, 4, 0, 0, + 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 24, 17, 24, 17, 17, 24, 24, + 24, 24, 17, 24, 24, 24, 24, 24, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 26, 26, 4, 4, 4, 4, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 17, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 17, 24, 24, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, + 55, 55, 55, 55, 55, 55, 55, 0, 0, 55, 0, 0, 55, 55, 55, 55, 55, 55, 55, + 55, 0, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 17, 17, 17, 17, 0, 17, + 17, 0, 0, 24, 24, 17, 24, 55, 17, 55, 17, 24, 4, 4, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 0, + 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 17, 17, 17, 24, 24, 24, 24, 0, 0, 24, 24, 17, 17, 17, 17, + 24, 55, 4, 55, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 390, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 17, 55, 24, 24, 24, 24, 4, 4, 4, + 4, 4, 4, 4, 4, 24, 0, 0, 0, 0, 0, 0, 0, 0, 55, 24, 24, 24, 24, 24, 24, + 17, 17, 24, 24, 24, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 17, 24, 24, 4, 4, 4, 55, 4, 4, 4, + 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 390, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, + 17, 24, 24, 24, 17, 24, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 17, 24, 24, 24, 24, 24, 24, 24, 0, 24, 24, 24, 24, 24, 24, + 17, 24, 55, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 0, 0, 0, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 0, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 17, 24, 24, 24, 24, 24, 24, 24, + 17, 24, 24, 17, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, + 55, 55, 0, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 0, 0, 0, 24, 0, 24, + 24, 0, 24, 24, 24, 24, 24, 24, 24, 55, 24, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, + 0, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, + 17, 17, 17, 17, 0, 24, 24, 0, 17, 17, 24, 17, 24, 55, 0, 0, 0, 0, 0, 0, + 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 105, 55, 55, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, + 0, 0, 0, 24, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 24, 24, 17, 17, 4, 4, 0, 0, 0, 0, 0, 0, 0, 24, 24, 55, 17, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 17, 17, 24, 24, 24, 24, + 24, 0, 0, 0, 17, 17, 24, 17, 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, 244, 244, - 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, - 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, - 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, - 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, - 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, - 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, - 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, - 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, 0, 4, 4, 4, 4, 4, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, + 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 391, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 24, 55, - 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 391, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 4, 4, 4, + 4, 4, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 55, 55, 55, + 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 17, 17, - 17, 24, 24, 24, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 4, 4, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, - 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 24, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, + 55, 55, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 17, 17, 17, 24, + 24, 24, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 0, 0, 24, 24, 24, 24, 24, 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 0, 0, 0, 0, 4, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, - 24, 24, 24, 24, 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 104, 104, 104, 104, 4, 4, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 26, - 26, 26, 26, 26, 26, 26, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 104, 104, 104, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 104, 104, 4, 4, 4, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 4, 4, 4, 4, 0, 0, 0, 0, 0, 506, 506, 506, 506, 506, 506, 506, - 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, - 506, 506, 506, 506, 0, 0, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 0, 0, 24, 24, 24, 24, 24, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 0, 0, 0, 0, 24, 55, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 104, - 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 24, 24, + 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 105, 105, 105, 105, 4, 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 26, 26, 26, 26, 26, + 26, 26, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 104, 104, 4, 104, 24, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 17, 17, 104, 104, 244, 244, 244, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 105, 105, 105, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, + 105, 105, 4, 4, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 4, 4, 4, 4, + 0, 0, 0, 0, 0, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, + 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 0, + 0, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, + 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 0, 0, 0, 0, 24, 55, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, + 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 105, 105, 4, 105, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 17, 17, 105, 105, 245, 245, 245, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 104, - 104, 104, 104, 0, 104, 104, 104, 104, 104, 104, 104, 0, 104, 104, 0, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 0, 0, - 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 0, 0, 0, 0, - 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 105, 105, + 105, 105, 0, 105, 105, 105, 105, 105, 105, 105, 0, 105, 105, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, - 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 0, + 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 0, + 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 4, 24, 24, 4, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 4, 4, 4, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 4, 4, 4, - 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, + 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 0, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 4, 0, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 0, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 24, 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 17, 17, 24, 24, 24, 4, 4, 4, - 17, 17, 17, 17, 17, 17, 20, 20, 20, 20, 20, 20, 20, 20, 24, 24, 24, 24, - 24, 24, 24, 24, 4, 4, 24, 24, 24, 24, 24, 24, 24, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 24, 24, - 24, 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 17, 17, + 24, 24, 24, 4, 4, 4, 17, 17, 17, 17, 17, 17, 20, 20, 20, 20, 20, 20, 20, + 20, 24, 24, 24, 24, 24, 24, 24, 24, 4, 4, 24, 24, 24, 24, 24, 24, 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 24, 24, 24, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 24, 24, 24, 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 24, 24, 24, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, + 17, 4, 4, 4, 4, 4, 4, 4, 4, 24, 24, 4, 4, 17, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 17, + 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 0, 0, 0, 0, 0, 0, 0, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 19, 19, 19, 19, 19, 19, 19, 0, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 19, 19, 19, 19, 19, 19, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 122, 0, 122, 122, 0, 0, 122, 0, 0, 122, 122, 0, 0, 122, 122, 122, - 122, 0, 122, 122, 122, 122, 122, 122, 122, 122, 19, 19, 19, 19, 0, 19, 0, - 19, 19, 19, 19, 19, 19, 19, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 19, 19, 19, + 19, 19, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 19, 19, + 19, 19, 19, 19, 19, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 123, 0, 123, 123, 0, 0, 123, 0, + 0, 123, 123, 0, 0, 123, 123, 123, 123, 0, 123, 123, 123, 123, 123, 123, + 123, 123, 19, 19, 19, 19, 0, 19, 0, 19, 19, 19, 19, 19, 19, 19, 0, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 123, 123, 0, + 123, 123, 123, 123, 0, 0, 123, 123, 123, 123, 123, 123, 123, 123, 0, 123, + 123, 123, 123, 123, 123, 123, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 123, 123, + 0, 123, 123, 123, 123, 0, 123, 123, 123, 123, 123, 0, 123, 0, 0, 0, 123, + 123, 123, 123, 123, 123, 123, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 122, 122, 0, 122, 122, 122, 122, 0, 0, 122, 122, 122, - 122, 122, 122, 122, 122, 0, 122, 122, 122, 122, 122, 122, 122, 0, 19, 19, + 19, 19, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 122, 122, 0, 122, 122, 122, 122, 0, 122, 122, - 122, 122, 122, 0, 122, 0, 0, 0, 122, 122, 122, 122, 122, 122, 122, 0, 19, + 19, 19, 19, 19, 19, 19, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 19, 19, 19, 19, + 19, 19, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 0, 0, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 4, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 0, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 4, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 4, 19, 19, 19, 19, + 19, 19, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 4, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 4, 19, 19, 19, 19, 19, 19, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 4, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 4, 19, 19, 19, 19, 19, 19, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 4, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 4, 19, 19, + 19, 19, 19, 19, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 4, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 4, 19, 19, 19, 19, 19, 19, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 4, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 4, 19, 19, 19, 19, 19, 19, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 4, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 4, 19, 19, 19, 19, 19, 19, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 4, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 4, 19, 19, 19, 19, 19, 19, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 4, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 4, 19, 19, 19, 19, - 19, 19, 122, 19, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 24, 24, 24, + 4, 19, 19, 19, 19, 19, 19, 123, 19, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 4, 4, 4, - 4, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 4, 4, 4, 4, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 4, 4, 4, 4, - 4, 4, 4, 4, 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 24, 4, 4, 4, 4, - 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 24, - 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 55, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 0, 0, - 0, 0, 0, 0, 19, 19, 19, 19, 19, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 24, 24, 24, 24, 24, 24, 24, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 0, 0, 24, 24, 24, 24, 24, 24, 24, 0, 24, 24, - 0, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 4, 4, 4, 4, 4, 4, 4, 4, 24, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 24, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, + 24, 24, 24, 24, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 55, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 29, + 30, 19, 19, 19, 19, 19, 19, 29, 30, 29, 30, 19, 29, 30, 19, 19, 29, 30, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 29, 30, 29, 30, 29, 30, 29, 30, 19, 19, 29, 30, 29, 30, 29, + 30, 29, 30, 29, 30, 29, 30, 29, 30, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 19, 19, 19, 19, 19, 512, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 24, 24, 24, 24, 24, 24, 24, 104, - 104, 104, 104, 104, 104, 104, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 0, 0, 0, 0, 55, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 24, 24, 24, 24, 24, 24, 24, 0, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 24, 24, 24, + 24, 24, 24, 24, 0, 24, 24, 0, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 104, 24, 24, 24, 24, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 55, 55, 55, 55, 0, 0, 0, 24, 24, 24, 24, 24, 24, 24, 105, 105, 105, 105, + 105, 105, 105, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 55, + 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 55, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, - 24, 55, 55, 24, 55, 55, 55, 55, 55, 55, 55, 24, 24, 55, 55, 55, 55, 55, - 24, 0, 0, 0, 0, 0, 0, 0, 0, 55, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, - 55, 55, 55, 0, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 24, 24, 24, 24, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 105, 24, 24, 24, 24, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 24, 24, 55, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 4, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 24, 24, 24, 24, 24, 24, 24, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 508, 508, 508, 508, - 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, - 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, - 508, 508, 509, 509, 509, 509, 509, 509, 509, 509, 509, 509, 509, 509, - 509, 509, 509, 509, 509, 509, 509, 509, 509, 509, 509, 509, 509, 509, - 509, 509, 509, 509, 509, 509, 509, 509, 24, 24, 24, 24, 24, 24, 24, 104, - 0, 0, 0, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 4, 4, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 24, 55, + 55, 24, 55, 55, 55, 55, 55, 55, 55, 24, 24, 55, 55, 55, 55, 55, 24, 0, 0, + 0, 0, 0, 0, 0, 0, 55, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, + 55, 55, 0, 55, 55, 55, 55, 0, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 0, 0, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 513, 513, 513, 513, 513, 513, 513, 513, 513, + 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, + 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, 514, 514, 514, + 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, + 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, 514, + 514, 514, 514, 24, 24, 24, 24, 24, 24, 24, 105, 0, 0, 0, 0, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, @@ -4121,239 +4438,141 @@ static const unsigned short index2[] = { 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 4, 26, 26, 26, 4, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 4, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, - 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 0, 55, 0, - 0, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 0, - 55, 0, 55, 0, 0, 0, 0, 0, 0, 55, 0, 0, 0, 0, 55, 0, 55, 0, 55, 0, 55, 55, - 55, 0, 55, 55, 0, 55, 0, 0, 55, 0, 55, 0, 55, 0, 55, 0, 55, 0, 55, 55, 0, - 55, 0, 0, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, - 55, 0, 55, 55, 55, 55, 0, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, - 0, 0, 0, 0, 55, 55, 55, 0, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 4, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 55, 55, 55, 55, 0, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 0, 55, 0, 0, 55, 0, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 0, 55, 0, 55, 0, 0, 0, 0, + 0, 0, 55, 0, 0, 0, 0, 55, 0, 55, 0, 55, 0, 55, 55, 55, 0, 55, 55, 0, 55, + 0, 0, 55, 0, 55, 0, 55, 0, 55, 0, 55, 0, 55, 55, 0, 55, 0, 0, 55, 55, 55, + 55, 0, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 0, 55, 55, 55, 55, + 0, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 55, 55, + 55, 0, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 361, 361, 25, 21, 22, 362, 363, 364, 365, 366, 367, 26, 26, 4, 4, + 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 362, 362, 25, 21, 22, 363, 364, 365, 366, 367, 368, 26, 26, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 510, 510, 510, 510, 510, 510, 510, 510, 510, - 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, - 510, 510, 510, 4, 4, 4, 4, 4, 4, 510, 510, 510, 510, 510, 510, 510, 510, - 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, - 510, 510, 510, 510, 4, 4, 4, 4, 4, 4, 510, 510, 510, 510, 510, 510, 510, - 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, - 510, 510, 510, 510, 510, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 515, 515, 515, 515, 515, 515, 515, 515, + 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, + 515, 515, 515, 515, 4, 4, 4, 4, 4, 4, 515, 515, 515, 515, 515, 515, 515, + 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, + 515, 515, 515, 515, 515, 4, 4, 4, 4, 4, 4, 515, 515, 515, 515, 515, 515, + 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, + 515, 515, 515, 515, 515, 515, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 4, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, - 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 0, 4, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 4, 0, 0, 0, 0, 0, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 4, 4, 4, 4, 4, 4, 4, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 4, 0, 0, 0, + 0, 0, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, - 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, + 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 390, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 391, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 0, 0, + 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, + 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, }; /* Returns the numeric value as double for Unicode characters @@ -4588,6 +4807,86 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0x12434: case 0x1244F: case 0x12458: + case 0x12477: + case 0x12550: + case 0x12559: + case 0x12562: + case 0x1256B: + case 0x12574: + case 0x12579: + case 0x12582: + case 0x1258C: + case 0x1258E: + case 0x12593: + case 0x1259A: + case 0x125A3: + case 0x125A8: + case 0x125AA: + case 0x125AB: + case 0x125AC: + case 0x125AD: + case 0x125AE: + case 0x125AF: + case 0x125B0: + case 0x125B1: + case 0x125B2: + case 0x125B3: + case 0x125B4: + case 0x125B5: + case 0x125B6: + case 0x125BA: + case 0x125BE: + case 0x125C7: + case 0x125CC: + case 0x125D1: + case 0x125DA: + case 0x125DF: + case 0x125E0: + case 0x125E9: + case 0x125EA: + case 0x125EB: + case 0x125EF: + case 0x125F4: + case 0x125FD: + case 0x125FE: + case 0x125FF: + case 0x12600: + case 0x12601: + case 0x12602: + case 0x12606: + case 0x1260B: + case 0x12614: + case 0x12616: + case 0x1261F: + case 0x12623: + case 0x12624: + case 0x12625: + case 0x12626: + case 0x12627: + case 0x12628: + case 0x12629: + case 0x1262D: + case 0x12631: + case 0x12636: + case 0x1263F: + case 0x12641: + case 0x12643: + case 0x12644: + case 0x12645: + case 0x12646: + case 0x12649: + case 0x1264C: + case 0x12655: + case 0x12656: + case 0x1265F: + case 0x12668: + case 0x1266A: + case 0x1266C: + case 0x12675: + case 0x12676: + case 0x1267B: + case 0x12684: + case 0x12686: case 0x16131: case 0x16A61: case 0x16AC1: @@ -4654,6 +4953,7 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0x11FD2: case 0x12226: case 0x12464: + case 0x1258B: case 0x1ECAE: case 0x1ED3C: return (double) 1.0/2.0; @@ -4665,6 +4965,7 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0x1245A: case 0x1245D: case 0x12465: + case 0x12598: return (double) 1.0/3.0; case 0x11FC5: return (double) 1.0/32.0; @@ -4683,6 +4984,8 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0x12460: case 0x12462: case 0x12463: + case 0x12589: + case 0x1258A: case 0x1ECAD: return (double) 1.0/4.0; case 0x0D59: @@ -4707,6 +5010,8 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0xA834: case 0x11FCC: case 0x1245F: + case 0x12587: + case 0x12588: return (double) 1.0/8.0; case 0x11FC2: return (double) 1.0/80.0; @@ -5090,6 +5395,54 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0x12450: case 0x12456: case 0x12459: + case 0x12478: + case 0x12551: + case 0x1255A: + case 0x12563: + case 0x1256C: + case 0x12575: + case 0x1257A: + case 0x12583: + case 0x1258D: + case 0x1258F: + case 0x12594: + case 0x1259B: + case 0x125A4: + case 0x125A9: + case 0x125B7: + case 0x125BB: + case 0x125BF: + case 0x125C8: + case 0x125CD: + case 0x125D2: + case 0x125DB: + case 0x125E1: + case 0x125EC: + case 0x125F0: + case 0x125F5: + case 0x12603: + case 0x12607: + case 0x1260C: + case 0x12615: + case 0x12617: + case 0x12620: + case 0x1262A: + case 0x1262E: + case 0x12632: + case 0x12637: + case 0x12640: + case 0x12642: + case 0x12647: + case 0x1264A: + case 0x1264D: + case 0x12657: + case 0x12660: + case 0x12669: + case 0x1266B: + case 0x1266D: + case 0x12677: + case 0x1267C: + case 0x12685: case 0x16132: case 0x16A62: case 0x16AC2: @@ -5131,6 +5484,7 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0x1245B: case 0x1245E: case 0x12466: + case 0x12599: return (double) 2.0/3.0; case 0x2156: return (double) 2.0/5.0; @@ -5178,6 +5532,7 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0x10E73: case 0x1EC84: case 0x1ED14: + case 0x32403: return (double) 200.0; case 0x10123: case 0x109DC: @@ -5336,6 +5691,46 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0x1244B: case 0x12451: case 0x12457: + case 0x12479: + case 0x12552: + case 0x1255B: + case 0x12564: + case 0x1256D: + case 0x12576: + case 0x1257B: + case 0x12584: + case 0x12590: + case 0x12595: + case 0x1259C: + case 0x125A5: + case 0x125B8: + case 0x125BC: + case 0x125C0: + case 0x125C9: + case 0x125CE: + case 0x125D3: + case 0x125DC: + case 0x125E2: + case 0x125ED: + case 0x125F1: + case 0x125F6: + case 0x12604: + case 0x12608: + case 0x1260D: + case 0x12618: + case 0x12621: + case 0x1262B: + case 0x1262F: + case 0x12633: + case 0x12638: + case 0x12648: + case 0x1264B: + case 0x1264E: + case 0x12658: + case 0x12661: + case 0x1266E: + case 0x12678: + case 0x1267D: case 0x16133: case 0x16A63: case 0x16AC3: @@ -5573,6 +5968,44 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0x12452: case 0x12453: case 0x12469: + case 0x1247A: + case 0x12553: + case 0x1255C: + case 0x12565: + case 0x1256E: + case 0x12577: + case 0x1257C: + case 0x12585: + case 0x12591: + case 0x12596: + case 0x1259D: + case 0x125A6: + case 0x125B9: + case 0x125BD: + case 0x125C1: + case 0x125CA: + case 0x125CF: + case 0x125D4: + case 0x125DD: + case 0x125E3: + case 0x125EE: + case 0x125F2: + case 0x125F7: + case 0x12605: + case 0x12609: + case 0x1260E: + case 0x12619: + case 0x12622: + case 0x1262C: + case 0x12630: + case 0x12634: + case 0x12639: + case 0x1264F: + case 0x12659: + case 0x12662: + case 0x1266F: + case 0x12679: + case 0x1267E: case 0x16134: case 0x16A64: case 0x16AC4: @@ -5780,6 +6213,37 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0x12454: case 0x12455: case 0x1246A: + case 0x1247B: + case 0x12554: + case 0x1255D: + case 0x12566: + case 0x1256F: + case 0x12578: + case 0x1257D: + case 0x12586: + case 0x12592: + case 0x12597: + case 0x1259E: + case 0x125A7: + case 0x125C2: + case 0x125CB: + case 0x125D0: + case 0x125D5: + case 0x125DE: + case 0x125E4: + case 0x125F3: + case 0x125F8: + case 0x1260A: + case 0x1260F: + case 0x1261A: + case 0x12635: + case 0x1263A: + case 0x12650: + case 0x1265A: + case 0x12663: + case 0x12670: + case 0x1267A: + case 0x1267F: case 0x16135: case 0x16A65: case 0x16AC5: @@ -5849,6 +6313,7 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0x1D36D: case 0x1EC7E: case 0x1ED0E: + case 0x324DF: return (double) 50.0; case 0x216E: case 0x217E: @@ -5984,6 +6449,25 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0x12440: case 0x1244E: case 0x1246B: + case 0x1247C: + case 0x12555: + case 0x1255E: + case 0x12567: + case 0x12570: + case 0x1257E: + case 0x1259F: + case 0x125C3: + case 0x125D6: + case 0x125E5: + case 0x125F9: + case 0x12610: + case 0x1261B: + case 0x1263B: + case 0x12651: + case 0x1265B: + case 0x12664: + case 0x12671: + case 0x12680: case 0x16136: case 0x16A66: case 0x16AC6: @@ -6147,6 +6631,26 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0x12442: case 0x12443: case 0x1246C: + case 0x1246F: + case 0x1247D: + case 0x12556: + case 0x1255F: + case 0x12568: + case 0x12571: + case 0x1257F: + case 0x125A0: + case 0x125C4: + case 0x125D7: + case 0x125E6: + case 0x125FA: + case 0x12611: + case 0x1261C: + case 0x1263C: + case 0x12652: + case 0x1265C: + case 0x12665: + case 0x12672: + case 0x12681: case 0x16137: case 0x16A67: case 0x16AC7: @@ -6309,6 +6813,26 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0x12444: case 0x12445: case 0x1246D: + case 0x12475: + case 0x1247E: + case 0x12557: + case 0x12560: + case 0x12569: + case 0x12572: + case 0x12580: + case 0x125A1: + case 0x125C5: + case 0x125D8: + case 0x125E7: + case 0x125FB: + case 0x12612: + case 0x1261D: + case 0x1263D: + case 0x12653: + case 0x1265D: + case 0x12666: + case 0x12673: + case 0x12682: case 0x16138: case 0x16A68: case 0x16AC8: @@ -6470,6 +6994,26 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) case 0x12448: case 0x12449: case 0x1246E: + case 0x12476: + case 0x1247F: + case 0x12558: + case 0x12561: + case 0x1256A: + case 0x12573: + case 0x12581: + case 0x125A2: + case 0x125C6: + case 0x125D9: + case 0x125E8: + case 0x125FC: + case 0x12613: + case 0x1261E: + case 0x1263E: + case 0x12654: + case 0x1265E: + case 0x12667: + case 0x12674: + case 0x12683: case 0x16139: case 0x16A69: case 0x16AC9: diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index daeba5368b21660..0156d0165b34892 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -7,6 +7,14 @@ #include "pycore_pystate.h" #include "pycore_weakref.h" // _PyWeakref_GET_REF() +/*[clinic input] +module weakref +class weakref.ReferenceType "PyWeakReference *" "&_PyWeakref_RefType" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=25211e4a7d687f3f]*/ + +#include "clinic/weakrefobject.c.h" + #ifdef Py_GIL_DISABLED /* * Thread-safety for free-threaded builds @@ -84,9 +92,9 @@ clear_weakref_lock_held(PyWeakReference *self, PyObject **callback) /* If 'self' is the end of the list (and thus self->wr_next == NULL) then the weakref list itself (and thus the value of *list) will end up being set to NULL. */ - FT_ATOMIC_STORE_PTR(*list, self->wr_next); + FT_ATOMIC_STORE_PTR_RELEASE(*list, self->wr_next); } - FT_ATOMIC_STORE_PTR(self->wr_object, Py_None); + FT_ATOMIC_STORE_PTR_RELEASE(self->wr_object, Py_None); if (self->wr_prev != NULL) { self->wr_prev->wr_next = self->wr_next; } @@ -186,8 +194,14 @@ weakref_vectorcall(PyObject *self, PyObject *const *args, return obj; } +/*[clinic input] +@critical_section +weakref.ReferenceType.__hash__ as weakref_hash +[clinic start generated code]*/ + static Py_hash_t -weakref_hash_lock_held(PyWeakReference *self) +weakref_hash_impl(PyWeakReference *self) +/*[clinic end generated code: output=4904eacaabf902c9 input=f248ec0b25c064e0]*/ { if (self->hash != -1) return self->hash; @@ -201,17 +215,6 @@ weakref_hash_lock_held(PyWeakReference *self) return self->hash; } -static Py_hash_t -weakref_hash(PyObject *op) -{ - PyWeakReference *self = _PyWeakref_CAST(op); - Py_hash_t hash; - Py_BEGIN_CRITICAL_SECTION(self); - hash = weakref_hash_lock_held(self); - Py_END_CRITICAL_SECTION(); - return hash; -} - static PyObject * weakref_repr(PyObject *self) { @@ -221,6 +224,10 @@ weakref_repr(PyObject *self) } PyObject *name = _PyObject_LookupSpecial(obj, &_Py_ID(__name__)); + if (name == NULL && PyErr_Occurred()) { + Py_DECREF(obj); + return NULL; + } PyObject *repr; if (name == NULL || !PyUnicode_Check(name)) { repr = PyUnicode_FromFormat( @@ -459,35 +466,45 @@ get_or_create_weakref(PyTypeObject *type, PyObject *obj, PyObject *callback) } } -static int -parse_weakref_init_args(const char *funcname, PyObject *args, PyObject *kwargs, - PyObject **obp, PyObject **callbackp) -{ - return PyArg_UnpackTuple(args, funcname, 1, 2, obp, callbackp); -} +/*[clinic input] +@classmethod +@vectorcall +weakref.ReferenceType.__new__ as weakref_ref_new + + object: object + callback: object(c_default="NULL") = None + / + +Create a weak reference to object. + +Calling the reference returns object, or None once it has been garbage +collected. If callback is given, it is called with the reference as +its only argument when object is about to be finalized. +[clinic start generated code]*/ static PyObject * -weakref___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs) +weakref_ref_new_impl(PyTypeObject *type, PyObject *object, + PyObject *callback) +/*[clinic end generated code: output=0b84aee8668f4c2f input=0cd09b468ebb6371]*/ { - PyObject *ob, *callback = NULL; - if (parse_weakref_init_args("__new__", args, kwargs, &ob, &callback)) { - return (PyObject *)get_or_create_weakref(type, ob, callback); - } - return NULL; + return (PyObject *)get_or_create_weakref(type, object, callback); } -static int -weakref___init__(PyObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *tmp; +/*[clinic input] +weakref.ReferenceType.__init__ as weakref_ref_init - if (!_PyArg_NoKeywords("ref", kwargs)) - return -1; + object: object + callback: object = None + / +[clinic start generated code]*/ - if (parse_weakref_init_args("__init__", args, kwargs, &tmp, &tmp)) - return 0; - else - return -1; +static int +weakref_ref_init_impl(PyWeakReference *self, PyObject *object, + PyObject *callback) +/*[clinic end generated code: output=d36cfa9ccd36856e input=373a3e3f2841a4fa]*/ +{ + /* The arguments were already used by __new__; only validate them. */ + return 0; } @@ -508,6 +525,7 @@ _PyWeakref_RefType = { PyVarObject_HEAD_INIT(&PyType_Type, 0) .tp_name = "weakref.ReferenceType", .tp_basicsize = sizeof(PyWeakReference), + .tp_doc = weakref_ref_new__doc__, .tp_dealloc = weakref_dealloc, .tp_vectorcall_offset = offsetof(PyWeakReference, vectorcall), .tp_call = PyVectorcall_Call, @@ -520,10 +538,11 @@ _PyWeakref_RefType = { .tp_richcompare = weakref_richcompare, .tp_methods = weakref_methods, .tp_members = weakref_members, - .tp_init = weakref___init__, + .tp_init = weakref_ref_init, .tp_alloc = PyType_GenericAlloc, - .tp_new = weakref___new__, + .tp_new = weakref_ref_new, .tp_free = PyObject_GC_Del, + .tp_vectorcall = weakref_ref_vectorcall, }; @@ -539,19 +558,26 @@ proxy_check_ref(PyObject *obj) } -/* If a parameter is a proxy, check that it is still "live" and wrap it, - * replacing the original value with the raw object. Raises ReferenceError - * if the param is a dead proxy. +/* Return a new reference to a live proxy's referent, or to the object itself + * if it is not a proxy. Raise ReferenceError for a dead proxy. */ +static PyObject * +proxy_unwrap(PyObject *obj) +{ + if (PyWeakref_CheckProxy(obj)) { + PyObject *referent = _PyWeakref_GET_REF(obj); + if (!proxy_check_ref(referent)) { + return NULL; + } + return referent; + } + return Py_NewRef(obj); +} + #define UNWRAP(o) \ - if (PyWeakref_CheckProxy(o)) { \ - o = _PyWeakref_GET_REF(o); \ - if (!proxy_check_ref(o)) { \ - return NULL; \ - } \ - } \ - else { \ - Py_INCREF(o); \ + o = proxy_unwrap(o); \ + if (o == NULL) { \ + return NULL; \ } #define WRAP_UNARY(method, generic) \ @@ -567,7 +593,11 @@ proxy_check_ref(PyObject *obj) static PyObject * \ method(PyObject *x, PyObject *y) { \ UNWRAP(x); \ - UNWRAP(y); \ + y = proxy_unwrap(y); \ + if (y == NULL) { \ + Py_DECREF(x); \ + return NULL; \ + } \ PyObject* res = generic(x, y); \ Py_DECREF(x); \ Py_DECREF(y); \ @@ -581,9 +611,18 @@ proxy_check_ref(PyObject *obj) static PyObject * \ method(PyObject *proxy, PyObject *v, PyObject *w) { \ UNWRAP(proxy); \ - UNWRAP(v); \ + v = proxy_unwrap(v); \ + if (v == NULL) { \ + Py_DECREF(proxy); \ + return NULL; \ + } \ if (w != NULL) { \ - UNWRAP(w); \ + w = proxy_unwrap(w); \ + if (w == NULL) { \ + Py_DECREF(proxy); \ + Py_DECREF(v); \ + return NULL; \ + } \ } \ PyObject* res = generic(proxy, v, w); \ Py_DECREF(proxy); \ @@ -644,7 +683,11 @@ static PyObject * proxy_richcompare(PyObject *proxy, PyObject *v, int op) { UNWRAP(proxy); - UNWRAP(v); + v = proxy_unwrap(v); + if (v == NULL) { + Py_DECREF(proxy); + return NULL; + } PyObject* res = PyObject_RichCompare(proxy, v, op); Py_DECREF(proxy); Py_DECREF(v); diff --git a/PC/_testconsole.c b/PC/_testconsole.c index 2538ae3ceba643d..76a4033bbbb1381 100644 --- a/PC/_testconsole.c +++ b/PC/_testconsole.c @@ -35,21 +35,6 @@ PyModuleDef_Slot testconsole_slots[] = { {0, NULL}, }; -/*[python input] -class HANDLE_converter(CConverter): - type = 'void *' - format_unit = '"_Py_PARSE_UINTPTR"' - - def parse_arg(self, argname, displayname, *, limited_capi): - return self.format_code(""" - {paramname} = PyLong_AsVoidPtr({argname}); - if (!{paramname} && PyErr_Occurred()) {{{{ - goto exit; - }}}} - """, - argname=argname) -[python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=380aa5c91076742b]*/ /*[python end generated code:]*/ /*[clinic input] diff --git a/PC/_wmimodule.cpp b/PC/_wmimodule.cpp index b9a229b1398ec8d..a546313529fd1b1 100644 --- a/PC/_wmimodule.cpp +++ b/PC/_wmimodule.cpp @@ -67,7 +67,7 @@ _query_thread(LPVOID param) } if (SUCCEEDED(hr)) { - hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); } if (FAILED(hr)) { diff --git a/PC/classicAppCompat.can.xml b/PC/classicAppCompat.can.xml deleted file mode 100644 index df361f8e3e2cd32..000000000000000 --- a/PC/classicAppCompat.can.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/PC/classicAppCompat.cat b/PC/classicAppCompat.cat deleted file mode 100644 index 3d213596accffa2..000000000000000 Binary files a/PC/classicAppCompat.cat and /dev/null differ diff --git a/PC/classicAppCompat.sccd b/PC/classicAppCompat.sccd deleted file mode 100644 index d7a70cdd0533c3d..000000000000000 --- a/PC/classicAppCompat.sccd +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MIIucgYJKoZIhvcNAQcCoIIuYzCCLl8CAQExDzANBglghkgBZQMEAgEFADCCARAGCSsGAQQBgjcKAaCCAQEwgf4wDAYKKwYBBAGCNwwBAQQQ293slyDTMUOmVyeQqmcNSBcNMjIwMjA0MDkwNjU2WjAOBgorBgEEAYI3DAEDBQAwgbwwKgQUdgFpbn9QXi/ly4CZFKA2Eimoq6YxEjAQBgorBgEEAYI3DAIDMQKCADCBjQQg3YHMbvV3unL0mx/RJ8ihTJd1C/SYSnMHbN0yMrWijuQxaTAQBgorBgEEAYI3DAIDMQKCADBVBgorBgEEAYI3AgEEMUcwRTAQBgorBgEEAYI3AgEZogKAADAxMA0GCWCGSAFlAwQCAQUABCDdgcxu9Xe6cvSbH9EnyKFMl3UL9JhKcwds3TIytaKO5KCCE8owggYEMIID7KADAgECAhMzAA/d9uEraWrDsxZGAAAAD932MA0GCSqGSIb3DQEBCwUAMIGLMQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMQwwCgYDVQQLEwNBT0MxJzAlBgNVBAMTHk1pY3Jvc29mdCBNYXJrZXRwbGFjZSBDQSBHIDAyMjAeFw0yMjAyMDQwODU5MzZaFw0yMjAyMDcwODU5MzZaMC8xLTArBgNVBAMTJDQ2ZTIwYzY2LTUxNTEtNDNhOS05MWQ4LTMwNDY0ZGZhMDg4ZjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALaMR5Ajlp2POidTxT0N47z5sukiE9fqMuI1QimTXIfB2/gPdMsNUbVCD57ha8J1DUJQpO5nuunbk3SONwfDTdWKx9u7zWubpEmgG7hZ8LTKFlF+xhS6lS/FBSSHyXpdScWPg62BMnDysqHMH/AjLw26HNPRWK8A0vx9jsalFwLg15u4MPuKN3Bpawr/OL0B+7eh/dGO3PutAqJ4aZs2lUCIyODg0q3Tzhgi7SIvFacFWJ8Qj6+D3AfasOv8oanfpNLLPhPlxXGEK9sMKHOOb8mTU9V/ibERqEKTHkJ24Vu+BwrXq5eVedtwmHT2WWR7teaIvrUT9AiPmMhx4hIF/0MCAwEAAaOCAbowggG2MBgGA1UdJQEB/wQOMAwGCisGAQQBgjdMHAEwHQYDVR0OBBYEFB4NpkpeSLk/j691tPw97rB4XKDJMA0GA1UdEQQGMASCAlVTMB8GA1UdIwQYMBaAFPeC7EkBPjJR1eFAcP4hAMeQ72IPMF8GA1UdHwRYMFYwVKBSoFCGTmh0dHA6Ly93d3cubWljcm9zb2Z0LmNvbS9wa2lvcHMvY3JsL01pY3Jvc29mdCUyME1hcmtldHBsYWNlJTIwQ0ElMjBHJTIwMDIyLmNybDBsBggrBgEFBQcBAQRgMF4wXAYIKwYBBQUHMAKGUGh0dHA6Ly93d3cubWljcm9zb2Z0LmNvbS9wa2lvcHMvY2VydHMvTWljcm9zb2Z0JTIwTWFya2V0cGxhY2UlMjBDQSUyMEclMjAwMjIuY3J0MAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgXgMDwGCSsGAQQBgjcVBwQvMC0GJSsGAQQBgjcVCIOS9kTqrxCDkY0wgqzgLIKinDE0g+6NOIaE7wACAWQCARcwIAYJKwYBBAGCNxUKAQH/BBAwDjAMBgorBgEEAYI3TBwBMA0GCSqGSIb3DQEBCwUAA4ICAQBAiJuIJeMS+PMrxG+kwPWT7yy7A6P8trchwtXyYep/WXu7xT2tH2ys3wuP4DYG5CY4nKekjTKraQhZGuYj4r4KrUviShe8ZWMIcK4MRduXAU81UOd/fsCq5djQ6NDN4Bzq1TxjwZKiEMEWmXaunj6XAlDSX3SgyyMb/ywmur8VVKO+xFVkOxAqCjNo1VaCv3zEvr3Y6dUwO9gYQui1bAQVQzdxRYUPEJlsFBmbNL1AnZ39r4/9K/6orxavU4qwkj4cXnhtMYKDjTIIbTBrfD4glP6mnmkcZpN0ItfEAVgU9rGpXg84hQLeP83nBs2Y8DrF3bBF9867dJCl90c5rK1DMcelmH3oUAwqZ3U+jIIj3HGyfefAQ6HPL0yiY9OYLXQZUxcZF13m92l5s7dy2C21cIh0W0iTcWPIhNn9cia4Hr7FabTC0RoQkO1bg0PKvPMnoe0AqEVmPKImNDncg538AjPy2qeUxn7+0kcuZWEdKVAPwWfzh5qvSAmYKk4XNBfN2E40GQ0ruRdvMVMFeYBLXKm4SJR6zoiBa5v7qzt1uQqZf6GD4BNFZivBp0P2B9lTubEAU6SmUsazRnEVmekIO+x7gDuXbMS8tv6mb1pbGCtIV/wRcIYNcDkHKTHMbW5xR/OmGTM3mPRxoMQtaWtxIeagZkU2nl+pElA/0h7pIjCCBtcwggS/oAMCAQICCmESRKIAAAAAAAIwDQYJKoZIhvcNAQELBQAwgYgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xMjAwBgNVBAMTKU1pY3Jvc29mdCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAyMDExMB4XDTExMDMyODIxMDkzOVoXDTMxMDMyODIxMTkzOVowfTELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEnMCUGA1UEAxMeTWljcm9zb2Z0IE1hcmtldFBsYWNlIFBDQSAyMDExMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAubUaSwGYVsE3MAnPfvmozUhAB3qxBABgJRW1vDp4+tVinXxD32f7k1K89JQ6zDOgS/iDgULC+yFK1K/1Qjac/0M7P6c8v5LSjnWGlERLa/qY32j46S7SLQcit3g2jgoTTO03eUG+9yHZUTGV/FJdRYB8uXhrznJBa+Y+yGwiQKF+m6XFeBH/KORoKFx+dmMoy9EWJ/m/o9IiUj2kzm9C691+vZ/I2w0Bj93W9SPPkV2PCNHlzgfIAoeajWpHmi38Wi3xZHonkzAVBHxPsCBppOoNsWvmAfUM7eBthkSPvFruekyDCPNEYhfGqgqtqLkoBebXLZCOVybF7wTQaLvse60//3P003icRcCoQYgY4NAqrF7j80o5U7DkeXxcB0xvengsaKgiAaV1DKkRbpe98wCqr1AASvm5rAJUYMU+mXmOieV2EelY2jGrenWe9FQpNXYV1NoWBh0WKoFxttoWYAnF705bIWtSZsz08ZfK6WLX4GXNLcPBlgCzfTm1sdKYASWdBbH2haaNhPapFhQQBJHKwnVW2iXErImhuPi45W3MVTZ5D9ASshZx69cLYY6xAdIa+89Kf/uRrsGOVZfahDuDw+NI183iAyzC8z/QRt2P32LYxP0xrCdqVh+DJo2i4NoE8Uk1usCdbVRuBMBQl/AwpOTq7IMvHGElf65CqzUCAwEAAaOCAUswggFHMBAGCSsGAQQBgjcVAQQDAgEAMB0GA1UdDgQWBBQPU8s/FmEl/mCJHdO5fOiQrbOU0TAZBgkrBgEEAYI3FAIEDB4KAFMAdQBiAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBRyLToCMZBDuRQFTuHqp8cx0SOJNDBaBgNVHR8EUzBRME+gTaBLhklodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpL2NybC9wcm9kdWN0cy9NaWNSb29DZXJBdXQyMDExXzIwMTFfMDNfMjIuY3JsMF4GCCsGAQUFBwEBBFIwUDBOBggrBgEFBQcwAoZCaHR0cDovL3d3dy5taWNyb3NvZnQuY29tL3BraS9jZXJ0cy9NaWNSb29DZXJBdXQyMDExXzIwMTFfMDNfMjIuY3J0MA0GCSqGSIb3DQEBCwUAA4ICAQCjuZmM8ZVNDgp9wHsL4RY8KJ8nLinvxFTphNGCrxaLknkYG5pmMhVlX+UB/tSiW8W13W60nggz9u5xwMx7v/1t/Tgm6g2brVyOKI5A7u6/2SIJwkJKFw953K0YIKVT28w9zl8dSJnmRnyR0G86ncWbF6CLQ6A6lBQ9o2mTGVqDr4m35WKAnc6YxUUM1y74mbzFFZr63VHsCcOp3pXWnUqAY1rb6Q6NX1b3clncKqLFm0EjKHcQ56grTbwuuB7pMdh/IFCJR01MQzQbDtpEisbOeZUi43YVAAHKqI1EO9bRwg3frCjwAbml9MmI4utMW94gWFgvrMxIX+n42RBDIjf3Ot3jkT6gt3XeTTmO9bptgblZimhERdkFRUFpVtkocJeLoGuuzP93uH/Yp032wzRH+XmMgujfZv+vnfllJqxdowoQLx55FxLLeTeYfwi/xMSjZO2gNven3U/3KeSCd1kUOFS3AOrwZ0UNOXJeW5JQC6Vfd1BavFZ6FAta1fMLu3WFvNB+FqeHUaU3ya7rmtxJnzk29DeSqXgGNmVSywBS4NajI5jJIKAA6UhNJlsg8CHYwUOKf5ej8OoQCkbadUxXygAfxCfW2YBbujtI+PoyejRFxWUjYFWO5LeTI62UMyqfOEiqugoYjNxmQZla2s4YHVuqIC34R85FQlg9pKQBsDCCBuMwggTLoAMCAQICEzMAAABLZz0Eed1JFCkAAAAAAEswDQYJKoZIhvcNAQELBQAwfTELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEnMCUGA1UEAxMeTWljcm9zb2Z0IE1hcmtldFBsYWNlIFBDQSAyMDExMB4XDTE5MDQxODIwNDUwNFoXDTI0MDQxODIwNDUwNFowgYsxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xDDAKBgNVBAsTA0FPQzEnMCUGA1UEAxMeTWljcm9zb2Z0IE1hcmtldHBsYWNlIENBIEcgMDIyMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAzGfV5tDxZ3oPG8aq2OwrBLSRFC61lYvWtkqOdKswlBHVncuoOIzekLIFNsMwluoK0plNZ5w/JPmwkGTGIrt9ftbWQz0k7XRfacXvQQfhCaBgjkybvvDx7CTL0UDEUiXfEEkylUcQKOdm9LApPDP4oO/V8RS4ugkqkjsuVaOyfYv0TytjVVQon72W+wR/AyrBAXgfwzzEb85403GTJRzQMlTw1YqdgS/o9SCsvH9dRZTGlWCatIl+a00eTG5zgeu0xCtqwgERhw9UT6mlPqmp6RqJ8XMgKylh9Ss+jI53EmraAFlelph16kuqF6n3vNnRBfhQ+gmNdtKi9s3jI8Di7ip8hYGPHGGhtcw0AYUg5r/VQhIfXxO45zO7SFvjujX0ji0b3WKB/xD9Sg1KO1fiTpj82ifyPqHvL+iwn5dV98C4ru0dQ0hfK7tA4K5qkW+2gym0fBjGYWq81/smrj6LbPdNqCotgTMU4dCMBhmSJOD9fSiPUybrbHJrHGR5YNs5VJbHH5u1ia8UrgsSrGTb1bh38Tb10matJpBI7NwDWTkV7kMvgNRQsGO/1+dg47PLW3X7TbiZniTPC+oAqOh1CiF+ODnem4Nw1iRw854LN3yqibLHgTi093mCBtPGWZxg2sTcHUX4fo/UHNbSh8bERJznnennm4gEJXAYtpnEFSUCAwEAAaOCAUswggFHMA4GA1UdDwEB/wQEAwIBhjAQBgkrBgEEAYI3FQEEAwIBADAdBgNVHQ4EFgQU94LsSQE+MlHV4UBw/iEAx5DvYg8wGQYJKwYBBAGCNxQCBAweCgBTAHUAYgBDAEEwEgYDVR0TAQH/BAgwBgEB/wIBADAfBgNVHSMEGDAWgBQPU8s/FmEl/mCJHdO5fOiQrbOU0TBXBgNVHR8EUDBOMEygSqBIhkZodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpL2NybC9wcm9kdWN0cy9NaWNNYXJQQ0EyMDExXzIwMTEtMDMtMjguY3JsMFsGCCsGAQUFBwEBBE8wTTBLBggrBgEFBQcwAoY/aHR0cDovL3d3dy5taWNyb3NvZnQuY29tL3BraS9jZXJ0cy9NaWNNYXJQQ0EyMDExXzIwMTEtMDMtMjguY3J0MA0GCSqGSIb3DQEBCwUAA4ICAQAbTWps31OnBv77EVpCaU68drubToSKtpw9fYt4MvAhorXGRrRRfS6qou5o45QZAKjwzbOrr33dWxF4P3gCGqZxCotW32p6hlXGP7BnYlVw6242nlX0PahgpyWVWBmi0ElKH8N6HYhJqAW74tUNCzY7ALNMwk/JVEMKpWq+5XqutAEmtP0SdoSZPRwPtdiRjMLS8yyjP4HVAiKJ+m0wV3bLBtCG20BttEGkly7fYa2/E0ps41PLeX3T2yKRgmnGjhD16NUcMDdRpBh7MCXktwpISDEanB8QySJNdErU+NaKukgOW68+Oyk7lGiiZcG3boCGNec9JkM7dQdpA4tneQg0FI/o0mkDZR5aVItbAjRfMgAXpm6Hfu9DqOP+/R0K9v+CwyhwEjF3+SeL8YBAijXHD5YaiWzwZzBDtNQpuOXc91NmF7ifdHVy9IE1EhuIIQsMio3l0Uo87vGdwQ50po8o1F72zi1vfvKfDmszVezk6fF7cy7fZYh8I0ceVbZ4XY4xJ76TdYMItUAoPkvVdDq5B/d4oI7/xHfomRsEw08fuLxCRE8/BcvzSlDpnxu4wL6IULqVwHE+fbQ82Lr5ZDLxa1dYUw8zBGgCnx/ObVPj1RO1CaVi13wCxm8yaHeflKJWw7ZHOLeOGQyMRT+f9cFFk+5fzCA9GcwiSlEyYj4ilzGCGWUwghlhAgEBMIGjMIGLMQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMQwwCgYDVQQLEwNBT0MxJzAlBgNVBAMTHk1pY3Jvc29mdCBNYXJrZXRwbGFjZSBDQSBHIDAyMgITMwAP3fbhK2lqw7MWRgAAAA/d9jANBglghkgBZQMEAgEFAKCBjzAYBgkqhkiG9w0BCQMxCwYJKwYBBAGCNwoBMC8GCSqGSIb3DQEJBDEiBCBDgOMhvMousTIzk/P1eC2qGiSJLdSm3brGanFMLa41+DBCBgorBgEEAYI3AgEMMTQwMqAUgBIATQBpAGMAcgBvAHMAbwBmAHShGoAYaHR0cDovL3d3dy5taWNyb3NvZnQuY29tMA0GCSqGSIb3DQEBAQUABIIBAJ8LEwzLh2rDfLOOOodKT10yXoCzHPaQLv9sMwei+650mqV0iHaw9bUolBZAdBnF7JBRjY+yb9AIF7M/Av9pHRKvuLHWDntlo49RrfvNucHaJqPjCMm81h/GAuimPSBMpRtTCW+HHDWrw+HoGbRWQ+N/Vpt//pzj9gAzOzs8W9gU0RMz3ub4Hfgunm/CGACjFu5Hi2sjJbgigNlyRnxjI4+h3J7dGVOfR8hlhRB9YjXDB700F0bzaKqxC9LH7kZbAjiHPgLLCWz7OQ/rTo7wV5/e6v9GCKpamydPy/0MObq4TDi0fn75aVHTJJrzlwt1BJKyVPdAsOhiFUH3Mq4WheKhghcAMIIW/AYKKwYBBAGCNwMDATGCFuwwghboBgkqhkiG9w0BBwKgghbZMIIW1QIBAzEPMA0GCWCGSAFlAwQCAQUAMIIBUQYLKoZIhvcNAQkQAQSgggFABIIBPDCCATgCAQEGCisGAQQBhFkKAwEwMTANBglghkgBZQMEAgEFAAQgr34HNu5gF3j5DAITqq38vc6sNxs6ZqLz9i9zU2oQDtoCBmH66bcTCRgTMjAyMjAyMDQwOTA5NDkuNTkxWjAEgAIB9KCB0KSBzTCByjELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjElMCMGA1UECxMcTWljcm9zb2Z0IEFtZXJpY2EgT3BlcmF0aW9uczEmMCQGA1UECxMdVGhhbGVzIFRTUyBFU046REQ4Qy1FMzM3LTJGQUUxJTAjBgNVBAMTHE1pY3Jvc29mdCBUaW1lLVN0YW1wIFNlcnZpY2WgghFXMIIHDDCCBPSgAwIBAgITMwAAAZwPpk1h0p5LKAABAAABnDANBgkqhkiG9w0BAQsFADB8MQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSYwJAYDVQQDEx1NaWNyb3NvZnQgVGltZS1TdGFtcCBQQ0EgMjAxMDAeFw0yMTEyMDIxOTA1MTlaFw0yMzAyMjgxOTA1MTlaMIHKMQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSUwIwYDVQQLExxNaWNyb3NvZnQgQW1lcmljYSBPcGVyYXRpb25zMSYwJAYDVQQLEx1UaGFsZXMgVFNTIEVTTjpERDhDLUUzMzctMkZBRTElMCMGA1UEAxMcTWljcm9zb2Z0IFRpbWUtU3RhbXAgU2VydmljZTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANtSKgwZXUkWP6zrXazTaYq7bco9Q2zvU6MN4ka3GRMX2tJZOK4DxeBiQACL/n7YV/sKTslwpD0f9cPU4rCDX9sfcTWo7XPxdHLQ+WkaGbKKWATsqw69bw8hkJ/bjcp2V2A6vGsvwcqJCh07BK3JPmUtZikyy5PZ8fyTyiKGN7hOWlaIU9oIoucUNoAHQJzLq8h20eNgHUh7eI5k+Kyq4v6810LHuA6EHyKJOZN2xTw5JSkLy0FN5Mhg/OaFrFBl3iag2Tqp4InKLt+Jbh/Jd0etnei2aDHFrmlfPmlRSv5wSNX5zAhgEyRpjmQcz1zp0QaSAefRkMm923/ngU51IbrVbAeHj569SHC9doHgsIxkh0K3lpw582+0ONXcIfIU6nkBT+qADAZ+0dT1uu/gRTBy614QAofjo258TbSX9aOU1SHuAC+3bMoyM7jNdHEJROH+msFDBcmJRl4VKsReI5+S69KUGeLIBhhmnmQ6drF8Ip0ZiO+vhAsD3e9AnqnY7Hcge850I9oKvwuwpVwWnKnwwSGElMz7UvCocmoUMXk7Vn2aNti+bdH28+GQb5EMsqhOmvuZOCRpOWN33G+b3g5unwEP0eTiY+LnWa2AuK43z/pplURJVle29K42QPkOcglB6sjLmNpEpb9basJ72eA0Mlp1LtH3oYZGXsggTfuXAgMBAAGjggE2MIIBMjAdBgNVHQ4EFgQUu2kJZ1Ndjl2112SynL6jGMID+rIwHwYDVR0jBBgwFoAUn6cVXQBeYl2D9OXSZacbUzUZ6XIwXwYDVR0fBFgwVjBUoFKgUIZOaHR0cDovL3d3dy5taWNyb3NvZnQuY29tL3BraW9wcy9jcmwvTWljcm9zb2Z0JTIwVGltZS1TdGFtcCUyMFBDQSUyMDIwMTAoMSkuY3JsMGwGCCsGAQUFBwEBBGAwXjBcBggrBgEFBQcwAoZQaHR0cDovL3d3dy5taWNyb3NvZnQuY29tL3BraW9wcy9jZXJ0cy9NaWNyb3NvZnQlMjBUaW1lLVN0YW1wJTIwUENBJTIwMjAxMCgxKS5jcnQwDAYDVR0TAQH/BAIwADATBgNVHSUEDDAKBggrBgEFBQcDCDANBgkqhkiG9w0BAQsFAAOCAgEApwAqpiMYRzNNYyz3PSbtijbeyCpUXcvIrqA4zPtMIcAk34W9u9mRDndWS+tlR3WwTpr1OgaV1wmc6YFzqK6EGWm903UEsFE7xBJMPXjfdVOPhcJB3vfvA0PX56oobcF2OvNsOSwTB8bi/ns+Cs39Puzs+QSNQZd8iAVBCSvxNCL78dln2RGU1xyB4AKqV9vi4Y/Gfmx2FA+jF0y+YLeob0M40nlSxL0q075t7L6iFRMNr0u8ROhzhDPLl+4ePYfUmyYJoobvydel9anAEsHFlhKl+aXb2ic3yNwbsoPycZJL/vo8OVvYYxCy+/5FrQmAvoW0ZEaBiYcKkzrNWt/hX9r5KgdwL61x0ZiTZopTko6W/58UTefTbhX7Pni0MApH3Pvyt6N0IFap+/LlwFRD1zn7e6ccPTwESnuo/auCmgPznq80OATA7vufsRZPvqeX8jKtsraSNscvNQymEWlcqdXV9hYkjb4T/Qse9cUYaoXg68wFHFuslWfTdPYPLl1vqzlPMnNJpC8KtdioDgcq+y1BaSqSm8EdNfwzT37+/JFtVc3Gs915fDqgPZDgOSzKQIV+fw3aPYt2LET3AbmKKW/r13Oy8cg3+D0D362GQBAJVv0NRI5NowgaCw6oNgWOFPrN72WSEcca/8QQiTGP2XpLiGpRDJZ6sWRpRYNdydkwggdxMIIFWaADAgECAhMzAAAAFcXna54Cm0mZAAAAAAAVMA0GCSqGSIb3DQEBCwUAMIGIMQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTIwMAYDVQQDEylNaWNyb3NvZnQgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgMjAxMDAeFw0yMTA5MzAxODIyMjVaFw0zMDA5MzAxODMyMjVaMHwxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xJjAkBgNVBAMTHU1pY3Jvc29mdCBUaW1lLVN0YW1wIFBDQSAyMDEwMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA5OGmTOe0ciELeaLL1yR5vQ7VgtP97pwHB9KpbE51yMo1V/YBf2xK4OK9uT4XYDP/XE/HZveVU3Fa4n5KWv64NmeFRiMMtY0Tz3cywBAY6GB9alKDRLemjkZrBxTzxXb1hlDcwUTIcVxRMTegCjhuje3XD9gmU3w5YQJ6xKr9cmmvHaus9ja+NSZk2pg7uhp7M62AW36MEBydUv626GIl3GoPz130/o5Tz9bshVZN7928jaTjkY+yOSxRnOlwaQ3KNi1wjjHINSi947SHJMPgyY9+tVSP3PoFVZhtaDuaRr3tpK56KTesy+uDRedGbsoy1cCGMFxPLOJiss254o2I5JasAUq7vnGpF1tnYN74kpEeHT39IM9zfUGaRnXNxF803RKJ1v2lIH1+/NmeRd+2ci/bfV+AutuqfjbsNkz2K26oElHovwUDo9Fzpk03dJQcNIIP8BDyt0cY7afomXw/TNuvXsLz1dhzPUNOwTM5TI4CvEJoLhDqhFFG4tG9ahhaYQFzymeiXtcodgLiMxhy16cg8ML6EgrXY28MyTZki1ugpoMhXV8wdJGUlNi5UPkLiWHzNgY1GIRH29wb0f2y1BzFa/ZcUlFdEtsluq9QBXpsxREdcu+N+VLEhReTwDwV2xo3xwgVGD94q0W29R6HXtqPnhZyacaue7e3PmriLq0CAwEAAaOCAd0wggHZMBIGCSsGAQQBgjcVAQQFAgMBAAEwIwYJKwYBBAGCNxUCBBYEFCqnUv5kxJq+gpE8RjUpzxD/LwTuMB0GA1UdDgQWBBSfpxVdAF5iXYP05dJlpxtTNRnpcjBcBgNVHSAEVTBTMFEGDCsGAQQBgjdMg30BATBBMD8GCCsGAQUFBwIBFjNodHRwOi8vd3d3Lm1pY3Jvc29mdC5jb20vcGtpb3BzL0RvY3MvUmVwb3NpdG9yeS5odG0wEwYDVR0lBAwwCgYIKwYBBQUHAwgwGQYJKwYBBAGCNxQCBAweCgBTAHUAYgBDAEEwCwYDVR0PBAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAU1fZWy4/oolxiaNE9lJBb186aGMQwVgYDVR0fBE8wTTBLoEmgR4ZFaHR0cDovL2NybC5taWNyb3NvZnQuY29tL3BraS9jcmwvcHJvZHVjdHMvTWljUm9vQ2VyQXV0XzIwMTAtMDYtMjMuY3JsMFoGCCsGAQUFBwEBBE4wTDBKBggrBgEFBQcwAoY+aHR0cDovL3d3dy5taWNyb3NvZnQuY29tL3BraS9jZXJ0cy9NaWNSb29DZXJBdXRfMjAxMC0wNi0yMy5jcnQwDQYJKoZIhvcNAQELBQADggIBAJ1VffwqreEsH2cBMSRb4Z5yS/ypb+pcFLY+TkdkeLEGk5c9MTO1OdfCcTY/2mRsfNB1OW27DzHkwo/7bNGhlBgi7ulmZzpTTd2YurYeeNg2LpypglYAA7AFvonoaeC6Ce5732pvvinLbtg/SHUB2RjebYIM9W0jVOR4U3UkV7ndn/OOPcbzaN9l9qRWqveVtihVJ9AkvUCgvxm2EhIRXT0n4ECWOKz3+SmJw7wXsFSFQrP8DJ6LGYnn8AtqgcKBGUIZUnWKNsIdw2FzLixre24/LAl4FOmRsqlb30mjdAy87JGA0j3mSj5mO0+7hvoyGtmW9I/2kQH2zsZ0/fZMcm8Qq3UwxTSwethQ/gpY3UA8x1RtnWN0SCyxTkctwRQEcb9k+SS+c23Kjgm9swFXSVRk2XPXfx5bRAGOWhmRaw2fpCjcZxkoJLo4S5pu+yFUa2pFEUep8beuyOiJXk+d0tBMdrVXVAmxaQFEfnyhYWxz/gq77EFmPWn9y8FBSX5+k77L+DvktxW/tM4+pTFRhLy/AsGConsXHRWJjXD+57XQKBqJC4822rpM+Zv/Cuk0+CQ1ZyvgDbjmjJnW4SLq8CdCPSWU5nR0W2rRnj7tfqAxM328y+l7vzhwRNGQ8cirOoo6CGJ/2XBjU02N7oJtpQUQwXEGahC0HVUzWLOhcGbyoYICzjCCAjcCAQEwgfihgdCkgc0wgcoxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xJTAjBgNVBAsTHE1pY3Jvc29mdCBBbWVyaWNhIE9wZXJhdGlvbnMxJjAkBgNVBAsTHVRoYWxlcyBUU1MgRVNOOkREOEMtRTMzNy0yRkFFMSUwIwYDVQQDExxNaWNyb3NvZnQgVGltZS1TdGFtcCBTZXJ2aWNloiMKAQEwBwYFKw4DAhoDFQDN2Wnq3fCz9ucStub1zQz7129TQKCBgzCBgKR+MHwxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xJjAkBgNVBAMTHU1pY3Jvc29mdCBUaW1lLVN0YW1wIFBDQSAyMDEwMA0GCSqGSIb3DQEBBQUAAgUA5adiZjAiGA8yMDIyMDIwNDE2MjkyNloYDzIwMjIwMjA1MTYyOTI2WjB3MD0GCisGAQQBhFkKBAExLzAtMAoCBQDlp2JmAgEAMAoCAQACAh92AgH/MAcCAQACAhFfMAoCBQDlqLPmAgEAMDYGCisGAQQBhFkKBAIxKDAmMAwGCisGAQQBhFkKAwKgCjAIAgEAAgMHoSChCjAIAgEAAgMBhqAwDQYJKoZIhvcNAQEFBQADgYEAbKzHReDTwgAKGSkgO/zxCAV/RcxwGpZK4M2bWgwqHVIi+/xiAKdQOSKeMz3UwRO4LI4EN4BjeK+ATpruzOtVGkyA8yzwdJFPv99j4O/Hc5kJSvovfECah62tBB3siNIFaAYNK+BF76k3j4+y9q9lF5yjQ8ZylVYbOfOjlJ2uevsxggQNMIIECQIBATCBkzB8MQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSYwJAYDVQQDEx1NaWNyb3NvZnQgVGltZS1TdGFtcCBQQ0EgMjAxMAITMwAAAZwPpk1h0p5LKAABAAABnDANBglghkgBZQMEAgEFAKCCAUowGgYJKoZIhvcNAQkDMQ0GCyqGSIb3DQEJEAEEMC8GCSqGSIb3DQEJBDEiBCD10XWSucJFd8jLe5PaC9h9/GHXK7ZZ0kb4BGFNqgWk9DCB+gYLKoZIhvcNAQkQAi8xgeowgecwgeQwgb0EIDcPRYUgjSzKOhF39d4QgbRZQgrPO7Lo/qE5GtvSeqa8MIGYMIGApH4wfDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEmMCQGA1UEAxMdTWljcm9zb2Z0IFRpbWUtU3RhbXAgUENBIDIwMTACEzMAAAGcD6ZNYdKeSygAAQAAAZwwIgQgPTEmgx6rn5xpH+xmlpYkcn0dL16GyYRqyG8uRajrfTYwDQYJKoZIhvcNAQELBQAEggIAxmSLisdd5cs+7liXX7vsF8zX3Y1rbtyPZ0M466WBaVULlfeuu9RMzOhWha7bkfYmKs5hXOQNBJrIHxnHbWeDu/V7EVF80IQ7/6qWiVPNcLtMnS8+uyw3Tby2gEhshO/HHOJRqllrgtUGuPl8FoAAPbPKV7X7jrg1kqOWoqpwyiSzt5cN/qijwfTcTIaPeON5wMd8wRT2l5F9e/JDBSq0WuzYb2r0kifv9wq21orm4sQkbg5GgDa/oCr3PQVCNSvPb2G7HANcqJXHeRKyoCeVhX5UaFrCQbdxGFytOc5GzptQKNn18yGg4VYrFpigUcglLbuREqqlPabwZh/QfgKdp4b4uVA6On5HIV5e9XdJ9TXhvDArEQ+Kgyao5xlgb4MkvPO9Thh9UIbw9r3JhQ+uKnCvXyiE2SpTLq1OXTjt/RrLZb+qsZW4nrDRBlBswa4G5OVW/svvI8N2/+YYrSdaCWt4unWSnSxeVUWZkugBmWdeoEJpfs5Qy8NwC+g1TyXcMjolOFTfBB6JYpHCbk6Euh2gKxq5weBb7puxVN4cvawYY2zorp6ZXtAmQGflZTl02nWld+nvDoF/zi6IUmP7PTKvbEVs8T+QkCiIM7cpLMs4NFK29f33lu1iZeGwJAxCYsV/P7geuRfA++bpDutTXjLKMqUTgf00sqJ/5HGuwLE= diff --git a/PC/clinic/msvcrtmodule.c.h b/PC/clinic/msvcrtmodule.c.h index 647aadfa46bbed4..7a43daa987b2066 100644 --- a/PC/clinic/msvcrtmodule.c.h +++ b/PC/clinic/msvcrtmodule.c.h @@ -133,13 +133,13 @@ PyDoc_STRVAR(msvcrt_open_osfhandle__doc__, {"open_osfhandle", _PyCFunction_CAST(msvcrt_open_osfhandle), METH_FASTCALL, msvcrt_open_osfhandle__doc__}, static long -msvcrt_open_osfhandle_impl(PyObject *module, void *handle, int flags); +msvcrt_open_osfhandle_impl(PyObject *module, HANDLE handle, int flags); static PyObject * msvcrt_open_osfhandle(PyObject *module, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; - void *handle; + HANDLE handle; int flags; long _return_value; @@ -531,14 +531,14 @@ PyDoc_STRVAR(msvcrt_CrtSetReportFile__doc__, {"CrtSetReportFile", _PyCFunction_CAST(msvcrt_CrtSetReportFile), METH_FASTCALL, msvcrt_CrtSetReportFile__doc__}, static void * -msvcrt_CrtSetReportFile_impl(PyObject *module, int type, void *file); +msvcrt_CrtSetReportFile_impl(PyObject *module, int type, HANDLE file); static PyObject * msvcrt_CrtSetReportFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; int type; - void *file; + HANDLE file; void *_return_value; if (!_PyArg_CheckPositional("CrtSetReportFile", nargs, 2, 2)) { @@ -743,4 +743,4 @@ msvcrt_SetErrorMode(PyObject *module, PyObject *arg) #ifndef MSVCRT_GETERRORMODE_METHODDEF #define MSVCRT_GETERRORMODE_METHODDEF #endif /* !defined(MSVCRT_GETERRORMODE_METHODDEF) */ -/*[clinic end generated code: output=f67eaf745685429d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=58c1771c8b9a209b input=a9049054013a1b77]*/ diff --git a/PC/invalid_parameter_handler.c b/PC/invalid_parameter_handler.c index d634710cbec7143..09d26b94de0bc1b 100644 --- a/PC/invalid_parameter_handler.c +++ b/PC/invalid_parameter_handler.c @@ -2,10 +2,8 @@ #include -#if _MSC_VER >= 1900 -/* pyconfig.h uses this function in the _Py_BEGIN/END_SUPPRESS_IPH - * macros. It does not need to be defined when building using MSVC - * earlier than 14.0 (_MSC_VER == 1900). +/* pycore_fileutils.h uses this function in the _Py_BEGIN/END_SUPPRESS_IPH + * macros. */ static void __cdecl _silent_invalid_parameter_handler( @@ -18,5 +16,3 @@ static void __cdecl _silent_invalid_parameter_handler( _invalid_parameter_handler _Py_silent_invalid_parameter_handler = _silent_invalid_parameter_handler; #endif - -#endif diff --git a/PC/launcher-usage.txt b/PC/launcher-usage.txt deleted file mode 100644 index aad103509daa283..000000000000000 --- a/PC/launcher-usage.txt +++ /dev/null @@ -1,31 +0,0 @@ -Python Launcher for Windows Version %s - -usage: -%s [launcher-args] [python-args] [script [script-args]] - -Launcher arguments: --2 : Launch the latest Python 2.x version --3 : Launch the latest Python 3.x version --X.Y : Launch the specified Python version - -The above default to an architecture native runtime, but will select any -available. Add a "-32" to the argument to only launch 32-bit runtimes, -or add "-64" to omit 32-bit runtimes (this latter option is deprecated). - -To select a specific runtime, use the -V: options. - --V:TAG : Launch a Python runtime with the specified tag --V:COMPANY/TAG : Launch a Python runtime from the specified company and - with the specified tag - --0 --list : List the available pythons --0p --list-paths : List with paths - -If no options are given but a script is specified, the script is checked for a -shebang line. Otherwise, an active virtual environment or global default will -be selected. - -See https://docs.python.org/using/windows.html#python-launcher-for-windows for -additional configuration. - -The following help text is from Python: diff --git a/PC/launcher.c b/PC/launcher.c deleted file mode 100644 index 5667fc851aa5904..000000000000000 --- a/PC/launcher.c +++ /dev/null @@ -1,2047 +0,0 @@ -/* - * Copyright (C) 2011-2013 Vinay Sajip. - * Licensed to PSF under a contributor agreement. - * - * Based on the work of: - * - * Mark Hammond (original author of Python version) - * Curt Hagenlocher (job management) - */ - -#include -#include -#include -#include - -#define BUFSIZE 256 -#define MSGSIZE 1024 - -/* Build options. */ -#define SKIP_PREFIX -#define SEARCH_PATH - -/* Error codes */ - -#define RC_NO_STD_HANDLES 100 -#define RC_CREATE_PROCESS 101 -#define RC_BAD_VIRTUAL_PATH 102 -#define RC_NO_PYTHON 103 -#define RC_NO_MEMORY 104 -/* - * SCRIPT_WRAPPER is used to choose one of the variants of an executable built - * from this source file. If not defined, the PEP 397 Python launcher is built; - * if defined, a script launcher of the type used by setuptools is built, which - * looks for a script name related to the executable name and runs that script - * with the appropriate Python interpreter. - * - * SCRIPT_WRAPPER should be undefined in the source, and defined in a VS project - * which builds the setuptools-style launcher. - */ -#if defined(SCRIPT_WRAPPER) -#define RC_NO_SCRIPT 105 -#endif -/* - * VENV_REDIRECT is used to choose the variant that looks for an adjacent or - * one-level-higher pyvenv.cfg, and uses its "home" property to locate and - * launch the original python.exe. - */ -#if defined(VENV_REDIRECT) -#define RC_NO_VENV_CFG 106 -#define RC_BAD_VENV_CFG 107 -#endif - -/* Just for now - static definition */ - -static FILE * log_fp = NULL; - -static wchar_t * -skip_whitespace(wchar_t * p) -{ - while (*p && isspace(*p)) - ++p; - return p; -} - -static void -debug(wchar_t * format, ...) -{ - va_list va; - - if (log_fp != NULL) { - va_start(va, format); - vfwprintf_s(log_fp, format, va); - va_end(va); - } -} - -static void -winerror(int rc, wchar_t * message, int size) -{ - FormatMessageW( - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, rc, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - message, size, NULL); -} - -static void -error(int rc, wchar_t * format, ... ) -{ - va_list va; - wchar_t message[MSGSIZE]; - wchar_t win_message[MSGSIZE]; - int len; - - va_start(va, format); - len = _vsnwprintf_s(message, MSGSIZE, _TRUNCATE, format, va); - va_end(va); - - if (rc == 0) { /* a Windows error */ - winerror(GetLastError(), win_message, MSGSIZE); - if (len >= 0) { - _snwprintf_s(&message[len], MSGSIZE - len, _TRUNCATE, L": %ls", - win_message); - } - } - -#if !defined(_WINDOWS) - fwprintf(stderr, L"%ls\n", message); -#else - MessageBoxW(NULL, message, L"Python Launcher is sorry to say ...", - MB_OK); -#endif - exit(rc); -} - -/* - * This function is here to simplify memory management - * and to treat blank values as if they are absent. - */ -static wchar_t * get_env(wchar_t * key) -{ - /* This is not thread-safe, just like getenv */ - static wchar_t buf[BUFSIZE]; - DWORD result = GetEnvironmentVariableW(key, buf, BUFSIZE); - - if (result >= BUFSIZE) { - /* Large environment variable. Accept some leakage */ - wchar_t *buf2 = (wchar_t*)malloc(sizeof(wchar_t) * (result+1)); - if (buf2 == NULL) { - error(RC_NO_MEMORY, L"Could not allocate environment buffer"); - } - GetEnvironmentVariableW(key, buf2, result); - return buf2; - } - - if (result == 0) - /* Either some error, e.g. ERROR_ENVVAR_NOT_FOUND, - or an empty environment variable. */ - return NULL; - - return buf; -} - -#if defined(Py_DEBUG) -/* Do not define EXECUTABLEPATH_VALUE in debug builds as it'll - never point to the debug build. */ -#if defined(_WINDOWS) - -#define PYTHON_EXECUTABLE L"pythonw_d.exe" - -#else - -#define PYTHON_EXECUTABLE L"python_d.exe" - -#endif -#else -#if defined(_WINDOWS) - -#define PYTHON_EXECUTABLE L"pythonw.exe" -#define EXECUTABLEPATH_VALUE L"WindowedExecutablePath" - -#else - -#define PYTHON_EXECUTABLE L"python.exe" -#define EXECUTABLEPATH_VALUE L"ExecutablePath" - -#endif -#endif - -#define MAX_VERSION_SIZE 8 - -typedef struct { - wchar_t version[MAX_VERSION_SIZE]; /* m.n */ - int bits; /* 32 or 64 */ - wchar_t executable[MAX_PATH]; - wchar_t exe_display[MAX_PATH]; -} INSTALLED_PYTHON; - -/* - * To avoid messing about with heap allocations, just assume we can allocate - * statically and never have to deal with more versions than this. - */ -#define MAX_INSTALLED_PYTHONS 100 - -static INSTALLED_PYTHON installed_pythons[MAX_INSTALLED_PYTHONS]; - -static size_t num_installed_pythons = 0; - -/* - * To hold SOFTWARE\Python\PythonCore\X.Y...\InstallPath - * The version name can be longer than MAX_VERSION_SIZE, but will be - * truncated to just X.Y for comparisons. - */ -#define IP_BASE_SIZE 80 -#define IP_VERSION_SIZE 8 -#define IP_SIZE (IP_BASE_SIZE + IP_VERSION_SIZE) -#define CORE_PATH L"SOFTWARE\\Python\\PythonCore" -/* - * Installations from the Microsoft Store will set the same registry keys, - * but because of a limitation in Windows they cannot be enumerated normally - * (unless you have no other Python installations... which is probably false - * because that's the most likely way to get this launcher!) - * This key is under HKEY_LOCAL_MACHINE - */ -#define LOOKASIDE_PATH L"SOFTWARE\\Microsoft\\AppModel\\Lookaside\\user\\Software\\Python\\PythonCore" - -static wchar_t * location_checks[] = { - L"\\", - L"\\PCbuild\\win32\\", - L"\\PCbuild\\amd64\\", - /* To support early 32bit versions of Python that stuck the build binaries - * directly in PCbuild... */ - L"\\PCbuild\\", - NULL -}; - -static INSTALLED_PYTHON * -find_existing_python(const wchar_t * path) -{ - INSTALLED_PYTHON * result = NULL; - size_t i; - INSTALLED_PYTHON * ip; - - for (i = 0, ip = installed_pythons; i < num_installed_pythons; i++, ip++) { - if (_wcsicmp(path, ip->executable) == 0) { - result = ip; - break; - } - } - return result; -} - -static INSTALLED_PYTHON * -find_existing_python2(int bits, const wchar_t * version) -{ - INSTALLED_PYTHON * result = NULL; - size_t i; - INSTALLED_PYTHON * ip; - - for (i = 0, ip = installed_pythons; i < num_installed_pythons; i++, ip++) { - if (bits == ip->bits && _wcsicmp(version, ip->version) == 0) { - result = ip; - break; - } - } - return result; -} - -static void -_locate_pythons_for_key(HKEY root, LPCWSTR subkey, REGSAM flags, int bits, - int display_name_only) -{ - HKEY core_root, ip_key; - LSTATUS status = RegOpenKeyExW(root, subkey, 0, flags, &core_root); - wchar_t message[MSGSIZE]; - DWORD i; - size_t n; - BOOL ok, append_name; - DWORD type, data_size, attrs; - INSTALLED_PYTHON * ip, * pip; - wchar_t ip_version[IP_VERSION_SIZE]; - wchar_t ip_path[IP_SIZE]; - wchar_t * check; - wchar_t ** checkp; - wchar_t *key_name = (root == HKEY_LOCAL_MACHINE) ? L"HKLM" : L"HKCU"; - - if (status != ERROR_SUCCESS) - debug(L"locate_pythons_for_key: unable to open PythonCore key in %ls\n", - key_name); - else { - ip = &installed_pythons[num_installed_pythons]; - for (i = 0; num_installed_pythons < MAX_INSTALLED_PYTHONS; i++) { - status = RegEnumKeyW(core_root, i, ip_version, IP_VERSION_SIZE); - if (status != ERROR_SUCCESS) { - if (status != ERROR_NO_MORE_ITEMS) { - /* unexpected error */ - winerror(status, message, MSGSIZE); - debug(L"Can't enumerate registry key for version %ls: %ls\n", - ip_version, message); - } - break; - } - else { - wcsncpy_s(ip->version, MAX_VERSION_SIZE, ip_version, - MAX_VERSION_SIZE-1); - /* Still treating version as "x.y" rather than sys.winver - * When PEP 514 tags are properly used, we shouldn't need - * to strip this off here. - */ - check = wcsrchr(ip->version, L'-'); - if (check && !wcscmp(check, L"-32")) { - *check = L'\0'; - } - _snwprintf_s(ip_path, IP_SIZE, _TRUNCATE, - L"%ls\\%ls\\InstallPath", subkey, ip_version); - status = RegOpenKeyExW(root, ip_path, 0, flags, &ip_key); - if (status != ERROR_SUCCESS) { - winerror(status, message, MSGSIZE); - /* Note: 'message' already has a trailing \n*/ - debug(L"%ls\\%ls: %ls", key_name, ip_path, message); - continue; - } - data_size = sizeof(ip->executable) - 1; - append_name = FALSE; -#ifdef EXECUTABLEPATH_VALUE - status = RegQueryValueExW(ip_key, EXECUTABLEPATH_VALUE, NULL, &type, - (LPBYTE)ip->executable, &data_size); -#else - status = ERROR_FILE_NOT_FOUND; /* actual error doesn't matter */ -#endif - if (status != ERROR_SUCCESS || type != REG_SZ || !data_size) { - append_name = TRUE; - data_size = sizeof(ip->executable) - 1; - status = RegQueryValueExW(ip_key, NULL, NULL, &type, - (LPBYTE)ip->executable, &data_size); - if (status != ERROR_SUCCESS) { - winerror(status, message, MSGSIZE); - debug(L"%ls\\%ls: %ls\n", key_name, ip_path, message); - RegCloseKey(ip_key); - continue; - } - } - RegCloseKey(ip_key); - if (type != REG_SZ) { - continue; - } - - data_size = data_size / sizeof(wchar_t) - 1; /* for NUL */ - if (ip->executable[data_size - 1] == L'\\') - --data_size; /* reg value ended in a backslash */ - /* ip->executable is data_size long */ - for (checkp = location_checks; *checkp; ++checkp) { - check = *checkp; - if (append_name) { - _snwprintf_s(&ip->executable[data_size], - MAX_PATH - data_size, - MAX_PATH - data_size, - L"%ls%ls", check, PYTHON_EXECUTABLE); - } - attrs = GetFileAttributesW(ip->executable); - if (attrs == INVALID_FILE_ATTRIBUTES) { - winerror(GetLastError(), message, MSGSIZE); - debug(L"locate_pythons_for_key: %ls: %ls", - ip->executable, message); - } - else if (attrs & FILE_ATTRIBUTE_DIRECTORY) { - debug(L"locate_pythons_for_key: '%ls' is a directory\n", - ip->executable); - } - else if (find_existing_python(ip->executable)) { - debug(L"locate_pythons_for_key: %ls: already found\n", - ip->executable); - } - else { - /* check the executable type. */ - if (bits) { - ip->bits = bits; - } else { - ok = GetBinaryTypeW(ip->executable, &attrs); - if (!ok) { - debug(L"Failure getting binary type: %ls\n", - ip->executable); - } - else { - if (attrs == SCS_64BIT_BINARY) - ip->bits = 64; - else if (attrs == SCS_32BIT_BINARY) - ip->bits = 32; - else - ip->bits = 0; - } - } - if (ip->bits == 0) { - debug(L"locate_pythons_for_key: %ls: \ -invalid binary type: %X\n", - ip->executable, attrs); - } - else { - if (display_name_only) { - /* display just the executable name. This is - * primarily for the Store installs */ - const wchar_t *name = wcsrchr(ip->executable, L'\\'); - if (name) { - wcscpy_s(ip->exe_display, MAX_PATH, name+1); - } - } - if (wcschr(ip->executable, L' ') != NULL) { - /* has spaces, so quote, and set original as - * the display name */ - if (!ip->exe_display[0]) { - wcscpy_s(ip->exe_display, MAX_PATH, ip->executable); - } - n = wcslen(ip->executable); - memmove(&ip->executable[1], - ip->executable, n * sizeof(wchar_t)); - ip->executable[0] = L'\"'; - ip->executable[n + 1] = L'\"'; - ip->executable[n + 2] = L'\0'; - } - debug(L"locate_pythons_for_key: %ls \ -is a %dbit executable\n", - ip->executable, ip->bits); - if (find_existing_python2(ip->bits, ip->version)) { - debug(L"locate_pythons_for_key: %ls-%i: already \ -found\n", ip->version, ip->bits); - } - else { - ++num_installed_pythons; - pip = ip++; - if (num_installed_pythons >= - MAX_INSTALLED_PYTHONS) - break; - } - } - } - } - } - } - RegCloseKey(core_root); - } -} - -static int -compare_pythons(const void * p1, const void * p2) -{ - INSTALLED_PYTHON * ip1 = (INSTALLED_PYTHON *) p1; - INSTALLED_PYTHON * ip2 = (INSTALLED_PYTHON *) p2; - /* note reverse sorting on version */ - int result = CompareStringW(LOCALE_INVARIANT, SORT_DIGITSASNUMBERS, - ip2->version, -1, ip1->version, -1); - switch (result) { - case 0: - error(0, L"CompareStringW failed"); - return 0; - case CSTR_LESS_THAN: - return -1; - case CSTR_EQUAL: - return ip2->bits - ip1->bits; /* 64 before 32 */ - case CSTR_GREATER_THAN: - return 1; - default: - return 0; // This should never be reached. - } -} - -static void -locate_pythons_for_key(HKEY root, REGSAM flags) -{ - _locate_pythons_for_key(root, CORE_PATH, flags, 0, FALSE); -} - -static void -locate_store_pythons(void) -{ -#if defined(_M_X64) - /* 64bit process, so look in native registry */ - _locate_pythons_for_key(HKEY_LOCAL_MACHINE, LOOKASIDE_PATH, - KEY_READ, 64, TRUE); -#else - /* 32bit process, so check that we're on 64bit OS */ - BOOL f64 = FALSE; - if (IsWow64Process(GetCurrentProcess(), &f64) && f64) { - _locate_pythons_for_key(HKEY_LOCAL_MACHINE, LOOKASIDE_PATH, - KEY_READ | KEY_WOW64_64KEY, 64, TRUE); - } -#endif -} - -static void -locate_venv_python(void) -{ - static wchar_t venv_python[MAX_PATH]; - INSTALLED_PYTHON * ip; - wchar_t *virtual_env = get_env(L"VIRTUAL_ENV"); - DWORD attrs; - - /* Check for VIRTUAL_ENV environment variable */ - if (virtual_env == NULL || virtual_env[0] == L'\0') { - return; - } - - /* Check for a python executable in the venv */ - debug(L"Checking for Python executable in virtual env '%ls'\n", virtual_env); - _snwprintf_s(venv_python, MAX_PATH, _TRUNCATE, - L"%ls\\Scripts\\%ls", virtual_env, PYTHON_EXECUTABLE); - attrs = GetFileAttributesW(venv_python); - if (attrs == INVALID_FILE_ATTRIBUTES) { - debug(L"Python executable %ls missing from virtual env\n", venv_python); - return; - } - - ip = &installed_pythons[num_installed_pythons++]; - wcscpy_s(ip->executable, MAX_PATH, venv_python); - ip->bits = 0; - wcscpy_s(ip->version, MAX_VERSION_SIZE, L"venv"); -} - -static void -locate_all_pythons(void) -{ - /* venv Python is highest priority */ - locate_venv_python(); -#if defined(_M_X64) - /* If we are a 64bit process, first hit the 32bit keys. */ - debug(L"locating Pythons in 32bit registry\n"); - locate_pythons_for_key(HKEY_CURRENT_USER, KEY_READ | KEY_WOW64_32KEY); - locate_pythons_for_key(HKEY_LOCAL_MACHINE, KEY_READ | KEY_WOW64_32KEY); -#else - /* If we are a 32bit process on a 64bit Windows, first hit the 64bit keys.*/ - BOOL f64 = FALSE; - if (IsWow64Process(GetCurrentProcess(), &f64) && f64) { - debug(L"locating Pythons in 64bit registry\n"); - locate_pythons_for_key(HKEY_CURRENT_USER, KEY_READ | KEY_WOW64_64KEY); - locate_pythons_for_key(HKEY_LOCAL_MACHINE, KEY_READ | KEY_WOW64_64KEY); - } -#endif - /* now hit the "native" key for this process bittedness. */ - debug(L"locating Pythons in native registry\n"); - locate_pythons_for_key(HKEY_CURRENT_USER, KEY_READ); - locate_pythons_for_key(HKEY_LOCAL_MACHINE, KEY_READ); - /* Store-installed Python is lowest priority */ - locate_store_pythons(); - qsort(installed_pythons, num_installed_pythons, sizeof(INSTALLED_PYTHON), - compare_pythons); -} - -static INSTALLED_PYTHON * -find_python_by_version(wchar_t const * wanted_ver) -{ - INSTALLED_PYTHON * result = NULL; - INSTALLED_PYTHON * ip = installed_pythons; - size_t i, n; - size_t wlen = wcslen(wanted_ver); - int bits = 0; - - if (wcsstr(wanted_ver, L"-32")) { - bits = 32; - wlen -= wcslen(L"-32"); - } - else if (wcsstr(wanted_ver, L"-64")) { /* Added option to select 64 bit explicitly */ - bits = 64; - wlen -= wcslen(L"-64"); - } - for (i = 0; i < num_installed_pythons; i++, ip++) { - n = wcslen(ip->version); - /* - * If wlen is greater than 1, we're probably trying to find a specific - * version and thus want an exact match: 3.1 != 3.10. Otherwise, we - * just want a prefix match. - */ - if ((wlen > 1) && (n != wlen)) { - continue; - } - if (n > wlen) { - n = wlen; - } - if ((wcsncmp(ip->version, wanted_ver, n) == 0) && - /* bits == 0 => don't care */ - ((bits == 0) || (ip->bits == bits))) { - result = ip; - break; - } - } - return result; -} - - -static wchar_t appdata_ini_path[MAX_PATH]; -static wchar_t launcher_ini_path[MAX_PATH]; - -/* - * Get a value either from the environment or a configuration file. - * The key passed in will either be "python", "python2" or "python3". - */ -static wchar_t * -get_configured_value(wchar_t * key) -{ -/* - * Note: this static value is used to return a configured value - * obtained either from the environment or configuration file. - * This should be OK since there wouldn't be any concurrent calls. - */ - static wchar_t configured_value[MSGSIZE]; - wchar_t * result = NULL; - wchar_t * found_in = L"environment"; - DWORD size; - - /* First, search the environment. */ - _snwprintf_s(configured_value, MSGSIZE, _TRUNCATE, L"py_%ls", key); - result = get_env(configured_value); - if (result == NULL && appdata_ini_path[0]) { - /* Not in environment: check local configuration. */ - size = GetPrivateProfileStringW(L"defaults", key, NULL, - configured_value, MSGSIZE, - appdata_ini_path); - if (size > 0) { - result = configured_value; - found_in = appdata_ini_path; - } - } - if (result == NULL && launcher_ini_path[0]) { - /* Not in environment or local: check global configuration. */ - size = GetPrivateProfileStringW(L"defaults", key, NULL, - configured_value, MSGSIZE, - launcher_ini_path); - if (size > 0) { - result = configured_value; - found_in = launcher_ini_path; - } - } - if (result) { - debug(L"found configured value '%ls=%ls' in %ls\n", - key, result, found_in ? found_in : L"(unknown)"); - } else { - debug(L"found no configured value for '%ls'\n", key); - } - return result; -} - -static INSTALLED_PYTHON * -locate_python(wchar_t * wanted_ver, BOOL from_shebang) -{ - static wchar_t config_key [] = { L"pythonX" }; - static wchar_t * last_char = &config_key[sizeof(config_key) / - sizeof(wchar_t) - 2]; - INSTALLED_PYTHON * result = NULL; - size_t n = wcslen(wanted_ver); - wchar_t * configured_value; - - if (num_installed_pythons == 0) - locate_all_pythons(); - - if (n == 1) { /* just major version specified */ - *last_char = *wanted_ver; - configured_value = get_configured_value(config_key); - if (configured_value != NULL) - wanted_ver = configured_value; - } - if (*wanted_ver) { - result = find_python_by_version(wanted_ver); - debug(L"search for Python version '%ls' found ", wanted_ver); - if (result) { - debug(L"'%ls'\n", result->executable); - } else { - debug(L"no interpreter\n"); - } - } - else { - *last_char = L'\0'; /* look for an overall default */ - result = find_python_by_version(L"venv"); - if (result == NULL) { - configured_value = get_configured_value(config_key); - if (configured_value) - result = find_python_by_version(configured_value); - } - /* Not found a value yet - try by major version. - * If we're looking for an interpreter specified in a shebang line, - * we want to try Python 2 first, then Python 3 (for Unix and backward - * compatibility). If we're being called interactively, assume the user - * wants the latest version available, so try Python 3 first, then - * Python 2. - */ - if (result == NULL) - result = find_python_by_version(from_shebang ? L"2" : L"3"); - if (result == NULL) - result = find_python_by_version(from_shebang ? L"3" : L"2"); - debug(L"search for default Python found "); - if (result) { - debug(L"version %ls at '%ls'\n", - result->version, result->executable); - } else { - debug(L"no interpreter\n"); - } - } - return result; -} - -#if defined(SCRIPT_WRAPPER) -/* - * Check for a script located alongside the executable - */ - -#if defined(_WINDOWS) -#define SCRIPT_SUFFIX L"-script.pyw" -#else -#define SCRIPT_SUFFIX L"-script.py" -#endif - -static wchar_t wrapped_script_path[MAX_PATH]; - -/* Locate the script being wrapped. - * - * This code should store the name of the wrapped script in - * wrapped_script_path, or terminate the program with an error if there is no - * valid wrapped script file. - */ -static void -locate_wrapped_script(void) -{ - wchar_t * p; - size_t plen; - DWORD attrs; - - plen = GetModuleFileNameW(NULL, wrapped_script_path, MAX_PATH); - p = wcsrchr(wrapped_script_path, L'.'); - if (p == NULL) { - debug(L"GetModuleFileNameW returned value has no extension: %ls\n", - wrapped_script_path); - error(RC_NO_SCRIPT, L"Wrapper name '%ls' is not valid.", wrapped_script_path); - } - - wcsncpy_s(p, MAX_PATH - (p - wrapped_script_path) + 1, SCRIPT_SUFFIX, _TRUNCATE); - attrs = GetFileAttributesW(wrapped_script_path); - if (attrs == INVALID_FILE_ATTRIBUTES) { - debug(L"File '%ls' non-existent\n", wrapped_script_path); - error(RC_NO_SCRIPT, L"Script file '%ls' is not present.", wrapped_script_path); - } - - debug(L"Using wrapped script file '%ls'\n", wrapped_script_path); -} -#endif - -/* - * Process creation code - */ - -static BOOL -safe_duplicate_handle(HANDLE in, HANDLE * pout) -{ - BOOL ok; - HANDLE process = GetCurrentProcess(); - DWORD rc; - - *pout = NULL; - ok = DuplicateHandle(process, in, process, pout, 0, TRUE, - DUPLICATE_SAME_ACCESS); - if (!ok) { - rc = GetLastError(); - if (rc == ERROR_INVALID_HANDLE) { - debug(L"DuplicateHandle returned ERROR_INVALID_HANDLE\n"); - ok = TRUE; - } - else { - debug(L"DuplicateHandle returned %d\n", rc); - } - } - return ok; -} - -static BOOL WINAPI -ctrl_c_handler(DWORD code) -{ - return TRUE; /* We just ignore all control events. */ -} - -static void -run_child(wchar_t * cmdline) -{ - HANDLE job; - JOBOBJECT_EXTENDED_LIMIT_INFORMATION info; - DWORD rc; - BOOL ok; - STARTUPINFOW si; - PROCESS_INFORMATION pi; - -#if defined(_WINDOWS) - /* - When explorer launches a Windows (GUI) application, it displays - the "app starting" (the "pointer + hourglass") cursor for a number - of seconds, or until the app does something UI-ish (eg, creating a - window, or fetching a message). As this launcher doesn't do this - directly, that cursor remains even after the child process does these - things. We avoid that by doing a simple post+get message. - See http://bugs.python.org/issue17290 - */ - MSG msg; - - PostMessage(0, 0, 0, 0); - GetMessage(&msg, 0, 0, 0); -#endif - - debug(L"run_child: about to run '%ls'\n", cmdline); - job = CreateJobObject(NULL, NULL); - ok = QueryInformationJobObject(job, JobObjectExtendedLimitInformation, - &info, sizeof(info), &rc); - if (!ok || (rc != sizeof(info)) || !job) - error(RC_CREATE_PROCESS, L"Job information querying failed"); - info.BasicLimitInformation.LimitFlags |= JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | - JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK; - ok = SetInformationJobObject(job, JobObjectExtendedLimitInformation, &info, - sizeof(info)); - if (!ok) - error(RC_CREATE_PROCESS, L"Job information setting failed"); - memset(&si, 0, sizeof(si)); - GetStartupInfoW(&si); - ok = safe_duplicate_handle(GetStdHandle(STD_INPUT_HANDLE), &si.hStdInput); - if (!ok) - error(RC_NO_STD_HANDLES, L"stdin duplication failed"); - ok = safe_duplicate_handle(GetStdHandle(STD_OUTPUT_HANDLE), &si.hStdOutput); - if (!ok) - error(RC_NO_STD_HANDLES, L"stdout duplication failed"); - ok = safe_duplicate_handle(GetStdHandle(STD_ERROR_HANDLE), &si.hStdError); - if (!ok) - error(RC_NO_STD_HANDLES, L"stderr duplication failed"); - - ok = SetConsoleCtrlHandler(ctrl_c_handler, TRUE); - if (!ok) - error(RC_CREATE_PROCESS, L"control handler setting failed"); - - si.dwFlags = STARTF_USESTDHANDLES; - ok = CreateProcessW(NULL, cmdline, NULL, NULL, TRUE, - 0, NULL, NULL, &si, &pi); - if (!ok) - error(RC_CREATE_PROCESS, L"Unable to create process using '%ls'", cmdline); - AssignProcessToJobObject(job, pi.hProcess); - CloseHandle(pi.hThread); - WaitForSingleObjectEx(pi.hProcess, INFINITE, FALSE); - ok = GetExitCodeProcess(pi.hProcess, &rc); - if (!ok) - error(RC_CREATE_PROCESS, L"Failed to get exit code of process"); - debug(L"child process exit code: %d\n", rc); - exit(rc); -} - -static void -invoke_child(wchar_t * executable, wchar_t * suffix, wchar_t * cmdline) -{ - wchar_t * child_command; - size_t child_command_size; - BOOL no_suffix = (suffix == NULL) || (*suffix == L'\0'); - BOOL no_cmdline = (*cmdline == L'\0'); - - if (no_suffix && no_cmdline) - run_child(executable); - else { - if (no_suffix) { - /* add 2 for space separator + terminating NUL. */ - child_command_size = wcslen(executable) + wcslen(cmdline) + 2; - } - else { - /* add 3 for 2 space separators + terminating NUL. */ - child_command_size = wcslen(executable) + wcslen(suffix) + - wcslen(cmdline) + 3; - } - child_command = calloc(child_command_size, sizeof(wchar_t)); - if (child_command == NULL) - error(RC_CREATE_PROCESS, L"unable to allocate %zd bytes for child command.", - child_command_size); - if (no_suffix) - _snwprintf_s(child_command, child_command_size, - child_command_size - 1, L"%ls %ls", - executable, cmdline); - else - _snwprintf_s(child_command, child_command_size, - child_command_size - 1, L"%ls %ls %ls", - executable, suffix, cmdline); - run_child(child_command); - free(child_command); - } -} - -typedef struct { - wchar_t *shebang; - BOOL search; -} SHEBANG; - -static SHEBANG builtin_virtual_paths [] = { - { L"/usr/bin/env python", TRUE }, - { L"/usr/bin/python", FALSE }, - { L"/usr/local/bin/python", FALSE }, - { L"python", FALSE }, - { NULL, FALSE }, -}; - -/* For now, a static array of commands. */ - -#define MAX_COMMANDS 100 - -typedef struct { - wchar_t key[MAX_PATH]; - wchar_t value[MSGSIZE]; -} COMMAND; - -static COMMAND commands[MAX_COMMANDS]; -static int num_commands = 0; - -#if defined(SKIP_PREFIX) - -static wchar_t * builtin_prefixes [] = { - /* These must be in an order that the longest matches should be found, - * i.e. if the prefix is "/usr/bin/env ", it should match that entry - * *before* matching "/usr/bin/". - */ - L"/usr/bin/env ", - L"/usr/bin/", - L"/usr/local/bin/", - NULL -}; - -static wchar_t * skip_prefix(wchar_t * name) -{ - wchar_t ** pp = builtin_prefixes; - wchar_t * result = name; - wchar_t * p; - size_t n; - - for (; p = *pp; pp++) { - n = wcslen(p); - if (_wcsnicmp(p, name, n) == 0) { - result += n; /* skip the prefix */ - if (p[n - 1] == L' ') /* No empty strings in table, so n > 1 */ - result = skip_whitespace(result); - break; - } - } - return result; -} - -#endif - -#if defined(SEARCH_PATH) - -static COMMAND path_command; - -static COMMAND * find_on_path(wchar_t * name) -{ - wchar_t * pathext; - size_t varsize; - wchar_t * context = NULL; - wchar_t * extension; - COMMAND * result = NULL; - DWORD len; - errno_t rc; - - wcscpy_s(path_command.key, MAX_PATH, name); - if (wcschr(name, L'.') != NULL) { - /* assume it has an extension. */ - len = SearchPathW(NULL, name, NULL, MSGSIZE, path_command.value, NULL); - if (len) { - result = &path_command; - } - } - else { - /* No extension - search using registered extensions. */ - rc = _wdupenv_s(&pathext, &varsize, L"PATHEXT"); - if (rc == 0) { - extension = wcstok_s(pathext, L";", &context); - while (extension) { - len = SearchPathW(NULL, name, extension, MSGSIZE, path_command.value, NULL); - if (len) { - result = &path_command; - break; - } - extension = wcstok_s(NULL, L";", &context); - } - free(pathext); - } - } - return result; -} - -#endif - -static COMMAND * find_command(wchar_t * name) -{ - COMMAND * result = NULL; - COMMAND * cp = commands; - int i; - - for (i = 0; i < num_commands; i++, cp++) { - if (_wcsicmp(cp->key, name) == 0) { - result = cp; - break; - } - } -#if defined(SEARCH_PATH) - if (result == NULL) - result = find_on_path(name); -#endif - return result; -} - -static void -update_command(COMMAND * cp, wchar_t * name, wchar_t * cmdline) -{ - wcsncpy_s(cp->key, MAX_PATH, name, _TRUNCATE); - wcsncpy_s(cp->value, MSGSIZE, cmdline, _TRUNCATE); -} - -static void -add_command(wchar_t * name, wchar_t * cmdline) -{ - if (num_commands >= MAX_COMMANDS) { - debug(L"can't add %ls = '%ls': no room\n", name, cmdline); - } - else { - COMMAND * cp = &commands[num_commands++]; - - update_command(cp, name, cmdline); - } -} - -static void -read_config_file(wchar_t * config_path) -{ - wchar_t keynames[MSGSIZE]; - wchar_t value[MSGSIZE]; - DWORD read; - wchar_t * key; - COMMAND * cp; - wchar_t * cmdp; - - read = GetPrivateProfileStringW(L"commands", NULL, NULL, keynames, MSGSIZE, - config_path); - if (read == MSGSIZE - 1) { - debug(L"read_commands: %ls: not enough space for names\n", config_path); - } - key = keynames; - while (*key) { - read = GetPrivateProfileStringW(L"commands", key, NULL, value, MSGSIZE, - config_path); - if (read == MSGSIZE - 1) { - debug(L"read_commands: %ls: not enough space for %ls\n", - config_path, key); - } - cmdp = skip_whitespace(value); - if (*cmdp) { - cp = find_command(key); - if (cp == NULL) - add_command(key, value); - else - update_command(cp, key, value); - } - key += wcslen(key) + 1; - } -} - -static void read_commands(void) -{ - if (launcher_ini_path[0]) - read_config_file(launcher_ini_path); - if (appdata_ini_path[0]) - read_config_file(appdata_ini_path); -} - -static BOOL -parse_shebang(wchar_t * shebang_line, int nchars, wchar_t ** command, - wchar_t ** suffix, BOOL *search) -{ - BOOL rc = FALSE; - SHEBANG * vpp; - size_t plen; - wchar_t * p; - wchar_t zapped; - wchar_t * endp = shebang_line + nchars - 1; - COMMAND * cp; - wchar_t * skipped; - - *command = NULL; /* failure return */ - *suffix = NULL; - *search = FALSE; - - if ((*shebang_line++ == L'#') && (*shebang_line++ == L'!')) { - shebang_line = skip_whitespace(shebang_line); - if (*shebang_line) { - *command = shebang_line; - for (vpp = builtin_virtual_paths; vpp->shebang; ++vpp) { - plen = wcslen(vpp->shebang); - if (wcsncmp(shebang_line, vpp->shebang, plen) == 0) { - rc = TRUE; - *search = vpp->search; - /* We can do this because all builtin commands contain - * "python". - */ - *command = wcsstr(shebang_line, L"python"); - break; - } - } - if (vpp->shebang == NULL) { - /* - * Not found in builtins - look in customized commands. - * - * We can't permanently modify the shebang line in case - * it's not a customized command, but we can temporarily - * stick a NUL after the command while searching for it, - * then put back the char we zapped. - */ -#if defined(SKIP_PREFIX) - skipped = skip_prefix(shebang_line); -#else - skipped = shebang_line; -#endif - p = wcspbrk(skipped, L" \t\r\n"); - if (p != NULL) { - zapped = *p; - *p = L'\0'; - } - cp = find_command(skipped); - if (p != NULL) - *p = zapped; - if (cp != NULL) { - *command = cp->value; - if (p != NULL) - *suffix = skip_whitespace(p); - } - } - /* remove trailing whitespace */ - while ((endp > shebang_line) && isspace(*endp)) - --endp; - if (endp > shebang_line) - endp[1] = L'\0'; - } - } - return rc; -} - -/* #define CP_UTF8 65001 defined in winnls.h */ -#define CP_UTF16LE 1200 -#define CP_UTF16BE 1201 -#define CP_UTF32LE 12000 -#define CP_UTF32BE 12001 - -typedef struct { - int length; - char sequence[4]; - UINT code_page; -} BOM; - -/* - * Strictly, we don't need to handle UTF-16 and UTF-32, since Python itself - * doesn't. Never mind, one day it might - there's no harm leaving it in. - */ -static BOM BOMs[] = { - { 3, { 0xEF, 0xBB, 0xBF }, CP_UTF8 }, /* UTF-8 - keep first */ - /* Test UTF-32LE before UTF-16LE since UTF-16LE BOM is a prefix - * of UTF-32LE BOM. */ - { 4, { 0xFF, 0xFE, 0x00, 0x00 }, CP_UTF32LE }, /* UTF-32LE */ - { 4, { 0x00, 0x00, 0xFE, 0xFF }, CP_UTF32BE }, /* UTF-32BE */ - { 2, { 0xFF, 0xFE }, CP_UTF16LE }, /* UTF-16LE */ - { 2, { 0xFE, 0xFF }, CP_UTF16BE }, /* UTF-16BE */ - { 0 } /* sentinel */ -}; - -static BOM * -find_BOM(char * buffer) -{ -/* - * Look for a BOM in the input and return a pointer to the - * corresponding structure, or NULL if not found. - */ - BOM * result = NULL; - BOM *bom; - - for (bom = BOMs; bom->length; bom++) { - if (strncmp(bom->sequence, buffer, bom->length) == 0) { - result = bom; - break; - } - } - return result; -} - -static char * -find_terminator(char * buffer, int len, BOM *bom) -{ - char * result = NULL; - char * end = buffer + len; - char * p; - char c; - int cp; - - for (p = buffer; p < end; p++) { - c = *p; - if (c == '\r') { - result = p; - break; - } - if (c == '\n') { - result = p; - break; - } - } - if (result != NULL) { - cp = bom->code_page; - - /* adjustments to include all bytes of the char */ - /* no adjustment needed for UTF-8 or big endian */ - if (cp == CP_UTF16LE) - ++result; - else if (cp == CP_UTF32LE) - result += 3; - ++result; /* point just past terminator */ - } - return result; -} - -static BOOL -validate_version(wchar_t * p) -{ - /* - Version information should start with the major version, - Optionally followed by a period and a minor version, - Optionally followed by a minus and one of 32 or 64. - Valid examples: - 2 - 3 - 2.7 - 3.6 - 2.7-32 - The intent is to add to the valid patterns: - 3.10 - 3-32 - 3.6-64 - 3-64 - */ - BOOL result = (p != NULL); /* Default to False if null pointer. */ - - result = result && iswdigit(*p); /* Result = False if first string element is not a digit. */ - - while (result && iswdigit(*p)) /* Require a major version */ - ++p; /* Skip all leading digit(s) */ - if (result && (*p == L'.')) /* Allow . for major minor separator.*/ - { - result = iswdigit(*++p); /* Must be at least one digit */ - while (result && iswdigit(*++p)) ; /* Skip any more Digits */ - } - if (result && (*p == L'-')) { /* Allow - for Bits Separator */ - switch(*++p){ - case L'3': /* 3 is OK */ - result = (*++p == L'2') && !*++p; /* only if followed by 2 and ended.*/ - break; - case L'6': /* 6 is OK */ - result = (*++p == L'4') && !*++p; /* only if followed by 4 and ended.*/ - break; - default: - result = FALSE; - break; - } - } - result = result && !*p; /* Must have reached EOS */ - return result; - -} - -typedef struct { - unsigned short min; - unsigned short max; - wchar_t version[MAX_VERSION_SIZE]; -} PYC_MAGIC; - -static PYC_MAGIC magic_values[] = { - { 50823, 50823, L"2.0" }, - { 60202, 60202, L"2.1" }, - { 60717, 60717, L"2.2" }, - { 62011, 62021, L"2.3" }, - { 62041, 62061, L"2.4" }, - { 62071, 62131, L"2.5" }, - { 62151, 62161, L"2.6" }, - { 62171, 62211, L"2.7" }, - { 3000, 3131, L"3.0" }, - { 3141, 3151, L"3.1" }, - { 3160, 3180, L"3.2" }, - { 3190, 3230, L"3.3" }, - { 3250, 3310, L"3.4" }, - { 3320, 3351, L"3.5" }, - { 3360, 3379, L"3.6" }, - { 3390, 3399, L"3.7" }, - { 3400, 3419, L"3.8" }, - { 3420, 3429, L"3.9" }, - { 3430, 3449, L"3.10" }, - /* Allow 50 magic numbers per version from here on */ - { 3450, 3499, L"3.11" }, - { 3500, 3549, L"3.12" }, - { 3550, 3599, L"3.13" }, - { 3600, 3649, L"3.14" }, - { 3650, 3699, L"3.15" }, - { 3700, 3749, L"3.16" }, - { 0 } -}; - -static INSTALLED_PYTHON * -find_by_magic(unsigned short magic) -{ - INSTALLED_PYTHON * result = NULL; - PYC_MAGIC * mp; - - for (mp = magic_values; mp->min; mp++) { - if ((magic >= mp->min) && (magic <= mp->max)) { - result = locate_python(mp->version, FALSE); - if (result != NULL) - break; - } - } - return result; -} - -static void -maybe_handle_shebang(wchar_t ** argv, wchar_t * cmdline) -{ -/* - * Look for a shebang line in the first argument. If found - * and we spawn a child process, this never returns. If it - * does return then we process the args "normally". - * - * argv[0] might be a filename with a shebang. - */ - FILE * fp; - errno_t rc = _wfopen_s(&fp, *argv, L"rb"); - char buffer[BUFSIZE]; - wchar_t shebang_line[BUFSIZE + 1]; - size_t read; - char *p; - char * start; - char * shebang_alias = (char *) shebang_line; - BOM* bom; - int i, j, nchars = 0; - int header_len; - BOOL is_virt; - BOOL search; - wchar_t * command; - wchar_t * suffix; - COMMAND *cmd = NULL; - INSTALLED_PYTHON * ip; - - if (rc == 0) { - read = fread(buffer, sizeof(char), BUFSIZE, fp); - debug(L"maybe_handle_shebang: read %zd bytes\n", read); - fclose(fp); - - if ((read >= 4) && (buffer[3] == '\n') && (buffer[2] == '\r')) { - ip = find_by_magic((((unsigned char)buffer[1]) << 8 | - (unsigned char)buffer[0]) & 0xFFFF); - if (ip != NULL) { - debug(L"script file is compiled against Python %ls\n", - ip->version); - invoke_child(ip->executable, NULL, cmdline); - } - } - /* Look for BOM */ - bom = find_BOM(buffer); - if (bom == NULL) { - start = buffer; - debug(L"maybe_handle_shebang: BOM not found, using UTF-8\n"); - bom = BOMs; /* points to UTF-8 entry - the default */ - } - else { - debug(L"maybe_handle_shebang: BOM found, code page %u\n", - bom->code_page); - start = &buffer[bom->length]; - } - p = find_terminator(start, BUFSIZE, bom); - /* - * If no CR or LF was found in the heading, - * we assume it's not a shebang file. - */ - if (p == NULL) { - debug(L"maybe_handle_shebang: No line terminator found\n"); - } - else { - /* - * Found line terminator - parse the shebang. - * - * Strictly, we don't need to handle UTF-16 anf UTF-32, - * since Python itself doesn't. - * Never mind, one day it might. - */ - header_len = (int) (p - start); - switch(bom->code_page) { - case CP_UTF8: - nchars = MultiByteToWideChar(bom->code_page, - 0, - start, header_len, shebang_line, - BUFSIZE); - break; - case CP_UTF16BE: - if (header_len % 2 != 0) { - debug(L"maybe_handle_shebang: UTF-16BE, but an odd number \ -of bytes: %d\n", header_len); - /* nchars = 0; Not needed - initialised to 0. */ - } - else { - for (i = header_len; i > 0; i -= 2) { - shebang_alias[i - 1] = start[i - 2]; - shebang_alias[i - 2] = start[i - 1]; - } - nchars = header_len / sizeof(wchar_t); - } - break; - case CP_UTF16LE: - if ((header_len % 2) != 0) { - debug(L"UTF-16LE, but an odd number of bytes: %d\n", - header_len); - /* nchars = 0; Not needed - initialised to 0. */ - } - else { - /* no actual conversion needed. */ - memcpy(shebang_line, start, header_len); - nchars = header_len / sizeof(wchar_t); - } - break; - case CP_UTF32BE: - if (header_len % 4 != 0) { - debug(L"UTF-32BE, but not divisible by 4: %d\n", - header_len); - /* nchars = 0; Not needed - initialised to 0. */ - } - else { - for (i = header_len, j = header_len / 2; i > 0; i -= 4, - j -= 2) { - shebang_alias[j - 1] = start[i - 2]; - shebang_alias[j - 2] = start[i - 1]; - } - nchars = header_len / sizeof(wchar_t); - } - break; - case CP_UTF32LE: - if (header_len % 4 != 0) { - debug(L"UTF-32LE, but not divisible by 4: %d\n", - header_len); - /* nchars = 0; Not needed - initialised to 0. */ - } - else { - for (i = header_len, j = header_len / 2; i > 0; i -= 4, - j -= 2) { - shebang_alias[j - 1] = start[i - 3]; - shebang_alias[j - 2] = start[i - 4]; - } - nchars = header_len / sizeof(wchar_t); - } - break; - } - if (nchars > 0) { - shebang_line[--nchars] = L'\0'; - is_virt = parse_shebang(shebang_line, nchars, &command, - &suffix, &search); - if (command != NULL) { - debug(L"parse_shebang: found command: %ls\n", command); - if (!is_virt) { - invoke_child(command, suffix, cmdline); - } - else { - suffix = wcschr(command, L' '); - if (suffix != NULL) { - *suffix++ = L'\0'; - suffix = skip_whitespace(suffix); - } - if (wcsncmp(command, L"python", 6)) - error(RC_BAD_VIRTUAL_PATH, L"Unknown virtual \ -path '%ls'", command); - command += 6; /* skip past "python" */ - if (search && ((*command == L'\0') || isspace(*command))) { - /* Command is eligible for path search, and there - * is no version specification. - */ - debug(L"searching PATH for python executable\n"); - cmd = find_on_path(PYTHON_EXECUTABLE); - debug(L"Python on path: %ls\n", cmd ? cmd->value : L""); - if (cmd) { - debug(L"located python on PATH: %ls\n", cmd->value); - invoke_child(cmd->value, suffix, cmdline); - /* Exit here, as we have found the command */ - return; - } - /* FALL THROUGH: No python found on PATH, so fall - * back to locating the correct installed python. - */ - } - if (*command && !validate_version(command)) - error(RC_BAD_VIRTUAL_PATH, L"Invalid version \ -specification: '%ls'.\nIn the first line of the script, 'python' needs to be \ -followed by a valid version specifier.\nPlease check the documentation.", - command); - /* TODO could call validate_version(command) */ - ip = locate_python(command, TRUE); - if (ip == NULL) { - error(RC_NO_PYTHON, L"Requested Python version \ -(%ls) is not installed", command); - } - else { - invoke_child(ip->executable, suffix, cmdline); - } - } - } - } - } - } -} - -static wchar_t * -skip_me(wchar_t * cmdline) -{ - BOOL quoted; - wchar_t c; - wchar_t * result = cmdline; - - quoted = cmdline[0] == L'\"'; - if (!quoted) - c = L' '; - else { - c = L'\"'; - ++result; - } - result = wcschr(result, c); - if (result == NULL) /* when, for example, just exe name on command line */ - result = L""; - else { - ++result; /* skip past space or closing quote */ - result = skip_whitespace(result); - } - return result; -} - -static DWORD version_high = 0; -static DWORD version_low = 0; - -static void -get_version_info(wchar_t * version_text, size_t size) -{ - WORD maj, min, rel, bld; - - if (!version_high && !version_low) - wcsncpy_s(version_text, size, L"0.1", _TRUNCATE); /* fallback */ - else { - maj = HIWORD(version_high); - min = LOWORD(version_high); - rel = HIWORD(version_low); - bld = LOWORD(version_low); - _snwprintf_s(version_text, size, _TRUNCATE, L"%d.%d.%d.%d", maj, - min, rel, bld); - } -} - -static void -show_help_text(wchar_t ** argv) -{ - wchar_t version_text [MAX_PATH]; -#if defined(_M_X64) - BOOL canDo64bit = TRUE; -#else - /* If we are a 32bit process on a 64bit Windows, first hit the 64bit keys. */ - BOOL canDo64bit = FALSE; - IsWow64Process(GetCurrentProcess(), &canDo64bit); -#endif - - get_version_info(version_text, MAX_PATH); - fwprintf(stdout, L"\ -Python Launcher for Windows Version %ls\n\n", version_text); - fwprintf(stdout, L"\ -usage:\n\ -%ls [launcher-args] [python-args] [script [script-args]]\n\n", argv[0]); - fputws(L"\ -Launcher arguments:\n\n\ --2 : Launch the latest Python 2.x version\n\ --3 : Launch the latest Python 3.x version\n\ --X.Y : Launch the specified Python version\n", stdout); - if (canDo64bit) { - fputws(L"\ - The above all default to 64 bit if a matching 64 bit python is present.\n\ --X.Y-32: Launch the specified 32bit Python version\n\ --X-32 : Launch the latest 32bit Python X version\n\ --X.Y-64: Launch the specified 64bit Python version\n\ --X-64 : Launch the latest 64bit Python X version", stdout); - } - fputws(L"\n-0 --list : List the available pythons", stdout); - fputws(L"\n-0p --list-paths : List with paths", stdout); - fputws(L"\n\n If no script is specified the specified interpreter is opened.", stdout); - fputws(L"\nIf an exact version is not given, using the latest version can be overridden by", stdout); - fputws(L"\nany of the following, (in priority order):", stdout); - fputws(L"\n An active virtual environment", stdout); - fputws(L"\n A shebang line in the script (if present)", stdout); - fputws(L"\n With -2 or -3 flag a matching PY_PYTHON2 or PY_PYTHON3 Environment variable", stdout); - fputws(L"\n A PY_PYTHON Environment variable", stdout); - fputws(L"\n From [defaults] in py.ini in your %LOCALAPPDATA%\\py.ini", stdout); - fputws(L"\n From [defaults] in py.ini beside py.exe (use `where py` to locate)", stdout); - fputws(L"\n\nThe following help text is from Python:\n\n", stdout); - fflush(stdout); -} - -static BOOL -show_python_list(wchar_t ** argv) -{ - /* - * Display options -0 - */ - INSTALLED_PYTHON * result = NULL; - INSTALLED_PYTHON * ip = installed_pythons; /* List of installed pythons */ - INSTALLED_PYTHON * defpy = locate_python(L"", FALSE); - size_t i = 0; - wchar_t *p = argv[1]; - wchar_t *ver_fmt = L"-%ls-%d"; - wchar_t *fmt = L"\n %ls"; - wchar_t *defind = L" *"; /* Default indicator */ - - /* - * Output informational messages to stderr to keep output - * clean for use in pipes, etc. - */ - fwprintf(stderr, - L"Installed Pythons found by %s Launcher for Windows", argv[0]); - if (!_wcsicmp(p, L"-0p") || !_wcsicmp(p, L"--list-paths")) - fmt = L"\n %-15ls%ls"; /* include path */ - - if (num_installed_pythons == 0) /* We have somehow got here without searching for pythons */ - locate_all_pythons(); /* Find them, Populates installed_pythons */ - - if (num_installed_pythons == 0) /* No pythons found */ - fwprintf(stderr, L"\nNo Installed Pythons Found!"); - else - { - for (i = 0; i < num_installed_pythons; i++, ip++) { - wchar_t version[BUFSIZ]; - if (wcscmp(ip->version, L"venv") == 0) { - wcscpy_s(version, BUFSIZ, L"(venv)"); - } - else { - swprintf_s(version, BUFSIZ, ver_fmt, ip->version, ip->bits); - } - - if (ip->exe_display[0]) { - fwprintf(stdout, fmt, version, ip->exe_display); - } - else { - fwprintf(stdout, fmt, version, ip->executable); - } - /* If there is a default indicate it */ - if (defpy == ip) - fwprintf(stderr, defind); - } - } - - if ((defpy == NULL) && (num_installed_pythons > 0)) - /* We have pythons but none is the default */ - fwprintf(stderr, L"\n\nCan't find a Default Python.\n\n"); - else - fwprintf(stderr, L"\n\n"); /* End with a blank line */ - return FALSE; /* If this has been called we cannot continue */ -} - -#if defined(VENV_REDIRECT) - -static int -find_home_value(const char *buffer, const char **start, DWORD *length) -{ - for (const char *s = strstr(buffer, "home"); s; s = strstr(s + 1, "\nhome")) { - if (*s == '\n') { - ++s; - } - for (int i = 4; i > 0 && *s; --i, ++s); - - while (*s && iswspace(*s)) { - ++s; - } - if (*s != L'=') { - continue; - } - - do { - ++s; - } while (*s && iswspace(*s)); - - *start = s; - char *nl = strchr(s, '\n'); - if (nl) { - *length = (DWORD)((ptrdiff_t)nl - (ptrdiff_t)s); - } else { - *length = (DWORD)strlen(s); - } - return 1; - } - return 0; -} -#endif - -static wchar_t * -wcsdup_pad(const wchar_t *s, int padding, int *newlen) -{ - size_t len = wcslen(s); - len += 1 + padding; - wchar_t *r = (wchar_t *)malloc(len * sizeof(wchar_t)); - if (!r) { - return NULL; - } - if (wcscpy_s(r, len, s)) { - free(r); - return NULL; - } - *newlen = len < MAXINT ? (int)len : MAXINT; - return r; -} - -static wchar_t * -get_process_name(void) -{ - DWORD bufferLen = MAX_PATH; - DWORD len = bufferLen; - wchar_t *r = NULL; - - while (!r) { - r = (wchar_t *)malloc(bufferLen * sizeof(wchar_t)); - if (!r) { - error(RC_NO_MEMORY, L"out of memory"); - return NULL; - } - len = GetModuleFileNameW(NULL, r, bufferLen); - if (len == 0) { - free(r); - error(0, L"Failed to get module name"); - return NULL; - } else if (len == bufferLen && - GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - free(r); - r = NULL; - bufferLen *= 2; - } - } - - return r; -} - -static int -process(int argc, wchar_t ** argv) -{ - wchar_t * wp; - wchar_t * command; - wchar_t * executable; - wchar_t * p; - wchar_t * argv0; - int rc = 0; - INSTALLED_PYTHON * ip; - BOOL valid; - DWORD size, attrs; - wchar_t message[MSGSIZE]; - void * version_data; - VS_FIXEDFILEINFO * file_info; - UINT block_size; -#if defined(VENV_REDIRECT) - wchar_t * venv_cfg_path; - int newlen; -#elif defined(SCRIPT_WRAPPER) - wchar_t * newcommand; - wchar_t * av[2]; - int newlen; - HRESULT hr; - int index; -#else - HRESULT hr; - int index; -#endif - - setvbuf(stderr, (char *)NULL, _IONBF, 0); - wp = get_env(L"PYLAUNCH_DEBUG"); - if ((wp != NULL) && (*wp != L'\0')) - log_fp = stderr; - -#if defined(_M_X64) - debug(L"launcher build: 64bit\n"); -#else - debug(L"launcher build: 32bit\n"); -#endif -#if defined(_WINDOWS) - debug(L"launcher executable: Windows\n"); -#else - debug(L"launcher executable: Console\n"); -#endif -#if !defined(VENV_REDIRECT) - /* Get the local appdata folder (non-roaming) */ - hr = SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, - NULL, 0, appdata_ini_path); - if (hr != S_OK) { - debug(L"SHGetFolderPath failed: %X\n", hr); - appdata_ini_path[0] = L'\0'; - } - else { - wcsncat_s(appdata_ini_path, MAX_PATH, L"\\py.ini", _TRUNCATE); - attrs = GetFileAttributesW(appdata_ini_path); - if (attrs == INVALID_FILE_ATTRIBUTES) { - debug(L"File '%ls' non-existent\n", appdata_ini_path); - appdata_ini_path[0] = L'\0'; - } else { - debug(L"Using local configuration file '%ls'\n", appdata_ini_path); - } - } -#endif - argv0 = get_process_name(); - size = GetFileVersionInfoSizeW(argv0, &size); - if (size == 0) { - winerror(GetLastError(), message, MSGSIZE); - debug(L"GetFileVersionInfoSize failed: %ls\n", message); - } - else { - version_data = malloc(size); - if (version_data) { - valid = GetFileVersionInfoW(argv0, 0, size, - version_data); - if (!valid) - debug(L"GetFileVersionInfo failed: %X\n", GetLastError()); - else { - valid = VerQueryValueW(version_data, L"\\", - (LPVOID *) &file_info, &block_size); - if (!valid) - debug(L"VerQueryValue failed: %X\n", GetLastError()); - else { - version_high = file_info->dwFileVersionMS; - version_low = file_info->dwFileVersionLS; - } - } - free(version_data); - } - } - -#if defined(VENV_REDIRECT) - /* Allocate some extra space for new filenames */ - venv_cfg_path = wcsdup_pad(argv0, 32, &newlen); - if (!venv_cfg_path) { - error(RC_NO_MEMORY, L"Failed to copy module name"); - } - p = wcsrchr(venv_cfg_path, L'\\'); - - if (p == NULL) { - error(RC_NO_VENV_CFG, L"No pyvenv.cfg file"); - } - p[0] = L'\0'; - wcscat_s(venv_cfg_path, newlen, L"\\pyvenv.cfg"); - attrs = GetFileAttributesW(venv_cfg_path); - if (attrs == INVALID_FILE_ATTRIBUTES) { - debug(L"File '%ls' non-existent\n", venv_cfg_path); - p[0] = '\0'; - p = wcsrchr(venv_cfg_path, L'\\'); - if (p != NULL) { - p[0] = '\0'; - wcscat_s(venv_cfg_path, newlen, L"\\pyvenv.cfg"); - attrs = GetFileAttributesW(venv_cfg_path); - if (attrs == INVALID_FILE_ATTRIBUTES) { - debug(L"File '%ls' non-existent\n", venv_cfg_path); - error(RC_NO_VENV_CFG, L"No pyvenv.cfg file"); - } - } - } - debug(L"Using venv configuration file '%ls'\n", venv_cfg_path); -#else - /* Allocate some extra space for new filenames */ - if (wcscpy_s(launcher_ini_path, MAX_PATH, argv0)) { - error(RC_NO_MEMORY, L"Failed to copy module name"); - } - p = wcsrchr(launcher_ini_path, L'\\'); - - if (p == NULL) { - debug(L"GetModuleFileNameW returned value has no backslash: %ls\n", - launcher_ini_path); - launcher_ini_path[0] = L'\0'; - } - else { - p[0] = L'\0'; - wcscat_s(launcher_ini_path, MAX_PATH, L"\\py.ini"); - attrs = GetFileAttributesW(launcher_ini_path); - if (attrs == INVALID_FILE_ATTRIBUTES) { - debug(L"File '%ls' non-existent\n", launcher_ini_path); - launcher_ini_path[0] = L'\0'; - } else { - debug(L"Using global configuration file '%ls'\n", launcher_ini_path); - } - } -#endif - - command = skip_me(GetCommandLineW()); - debug(L"Called with command line: %ls\n", command); - -#if !defined(VENV_REDIRECT) - /* bpo-35811: The __PYVENV_LAUNCHER__ variable is used to - * override sys.executable and locate the original prefix path. - * However, if it is silently inherited by a non-venv Python - * process, that process will believe it is running in the venv - * still. This is the only place where *we* can clear it (that is, - * when py.exe is being used to launch Python), so we do. - */ - SetEnvironmentVariableW(L"__PYVENV_LAUNCHER__", NULL); -#endif - -#if defined(SCRIPT_WRAPPER) - /* The launcher is being used in "script wrapper" mode. - * There should therefore be a Python script named -script.py in - * the same directory as the launcher executable. - * Put the script name into argv as the first (script name) argument. - */ - - /* Get the wrapped script name - if the script is not present, this will - * terminate the program with an error. - */ - locate_wrapped_script(); - - /* Add the wrapped script to the start of command */ - newlen = wcslen(wrapped_script_path) + wcslen(command) + 2; /* ' ' + NUL */ - newcommand = malloc(sizeof(wchar_t) * newlen); - if (!newcommand) { - error(RC_NO_MEMORY, L"Could not allocate new command line"); - } - else { - wcscpy_s(newcommand, newlen, wrapped_script_path); - wcscat_s(newcommand, newlen, L" "); - wcscat_s(newcommand, newlen, command); - debug(L"Running wrapped script with command line '%ls'\n", newcommand); - read_commands(); - av[0] = wrapped_script_path; - av[1] = NULL; - maybe_handle_shebang(av, newcommand); - /* Returns if no shebang line - pass to default processing */ - command = newcommand; - valid = FALSE; - } -#elif defined(VENV_REDIRECT) - { - FILE *f; - char buffer[4096]; /* 4KB should be enough for anybody */ - char *start; - DWORD len, cch, cch_actual; - size_t cb; - if (_wfopen_s(&f, venv_cfg_path, L"r")) { - error(RC_BAD_VENV_CFG, L"Cannot read '%ls'", venv_cfg_path); - } - cb = fread_s(buffer, sizeof(buffer), sizeof(buffer[0]), - sizeof(buffer) / sizeof(buffer[0]), f); - fclose(f); - - if (!find_home_value(buffer, &start, &len)) { - error(RC_BAD_VENV_CFG, L"Cannot find home in '%ls'", - venv_cfg_path); - } - - cch = MultiByteToWideChar(CP_UTF8, 0, start, len, NULL, 0); - if (!cch) { - error(0, L"Cannot determine memory for home path"); - } - cch += (DWORD)wcslen(PYTHON_EXECUTABLE) + 4; /* include sep, null and quotes */ - executable = (wchar_t *)malloc(cch * sizeof(wchar_t)); - if (executable == NULL) { - error(RC_NO_MEMORY, L"A memory allocation failed"); - } - /* start with a quote - we'll skip this ahead, but want it for the final string */ - executable[0] = L'"'; - cch_actual = MultiByteToWideChar(CP_UTF8, 0, start, len, &executable[1], cch - 1); - if (!cch_actual) { - error(RC_BAD_VENV_CFG, L"Cannot decode home path in '%ls'", - venv_cfg_path); - } - cch_actual += 1; /* account for the first quote */ - executable[cch_actual] = L'\0'; - if (executable[cch_actual - 1] != L'\\') { - executable[cch_actual++] = L'\\'; - executable[cch_actual] = L'\0'; - } - if (wcscat_s(&executable[1], cch - 1, PYTHON_EXECUTABLE)) { - error(RC_BAD_VENV_CFG, L"Cannot create executable path from '%ls'", - venv_cfg_path); - } - /* there's no trailing quote, so we only have to skip one character for the test */ - if (GetFileAttributesW(&executable[1]) == INVALID_FILE_ATTRIBUTES) { - error(RC_NO_PYTHON, L"No Python at '%ls'", executable); - } - /* now append the final quote */ - wcscat_s(executable, cch, L"\""); - /* smuggle our original path through */ - if (!SetEnvironmentVariableW(L"__PYVENV_LAUNCHER__", argv0)) { - error(0, L"Failed to set launcher environment"); - } - valid = 1; - } -#else - if (argc <= 1) { - valid = FALSE; - p = NULL; - } - else { - p = argv[1]; - if ((argc == 2) && // list version args - (!wcsncmp(p, L"-0", wcslen(L"-0")) || - !wcsncmp(p, L"--list", wcslen(L"--list")))) - { - show_python_list(argv); - return rc; - } - valid = valid && (*p == L'-') && validate_version(&p[1]); - if (valid) { - ip = locate_python(&p[1], FALSE); - if (ip == NULL) - { - fwprintf(stdout, \ - L"Python %ls not found!\n", &p[1]); - valid = show_python_list(argv); - error(RC_NO_PYTHON, L"Requested Python version (%ls) not \ -installed, use -0 for available pythons", &p[1]); - } - executable = ip->executable; - command += wcslen(p); - command = skip_whitespace(command); - } - else { - for (index = 1; index < argc; ++index) { - if (*argv[index] != L'-') - break; - } - if (index < argc) { - read_commands(); - maybe_handle_shebang(&argv[index], command); - } - } - } -#endif - - if (!valid) { - if ((argc == 2) && (!_wcsicmp(p, L"-h") || !_wcsicmp(p, L"--help"))) - show_help_text(argv); - if ((argc == 2) && - (!_wcsicmp(p, L"-0") || !_wcsicmp(p, L"--list") || - !_wcsicmp(p, L"-0p") || !_wcsicmp(p, L"--list-paths"))) - { - executable = NULL; /* Info call only */ - } - else { - /* look for the default Python */ - ip = locate_python(L"", FALSE); - if (ip == NULL) - error(RC_NO_PYTHON, L"Can't find a default Python."); - executable = ip->executable; - } - } - if (executable != NULL) - invoke_child(executable, NULL, command); - else - rc = RC_NO_PYTHON; - return rc; -} - -#if defined(_WINDOWS) - -int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPWSTR lpstrCmd, int nShow) -{ - return process(__argc, __wargv); -} - -#else - -int cdecl wmain(int argc, wchar_t ** argv) -{ - return process(argc, argv); -} - -#endif diff --git a/PC/launcher2.c b/PC/launcher2.c deleted file mode 100644 index 4dd18c8eb5462e9..000000000000000 --- a/PC/launcher2.c +++ /dev/null @@ -1,2858 +0,0 @@ -/* - * Rewritten Python launcher for Windows - * - * This new rewrite properly handles PEP 514 and allows any registered Python - * runtime to be launched. It also enables auto-install of versions when they - * are requested but no installation can be found. - */ - -#define __STDC_WANT_LIB_EXT1__ 1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define MS_WINDOWS -#include "patchlevel.h" - -#define MAXLEN PATHCCH_MAX_CCH -#define MSGSIZE 1024 - -#define RC_NO_STD_HANDLES 100 -#define RC_CREATE_PROCESS 101 -#define RC_BAD_VIRTUAL_PATH 102 -#define RC_NO_PYTHON 103 -#define RC_NO_MEMORY 104 -#define RC_NO_SCRIPT 105 -#define RC_NO_VENV_CFG 106 -#define RC_BAD_VENV_CFG 107 -#define RC_NO_COMMANDLINE 108 -#define RC_INTERNAL_ERROR 109 -#define RC_DUPLICATE_ITEM 110 -#define RC_INSTALLING 111 -#define RC_NO_PYTHON_AT_ALL 112 -#define RC_NO_SHEBANG 113 -#define RC_RECURSIVE_SHEBANG 114 - -static FILE * log_fp = NULL; - -void -debug(wchar_t * format, ...) -{ - va_list va; - - if (log_fp != NULL) { - wchar_t buffer[MAXLEN]; - int r = 0; - va_start(va, format); - r = vswprintf_s(buffer, MAXLEN, format, va); - va_end(va); - - if (r <= 0) { - return; - } - fputws(buffer, log_fp); - while (r && isspace(buffer[r])) { - buffer[r--] = L'\0'; - } - if (buffer[0]) { - OutputDebugStringW(buffer); - } - } -} - - -void -formatWinerror(int rc, wchar_t * message, int size) -{ - FormatMessageW( - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, rc, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - message, size, NULL); -} - - -void -winerror(int err, wchar_t * format, ... ) -{ - va_list va; - wchar_t message[MSGSIZE]; - wchar_t win_message[MSGSIZE]; - int len; - - if (err == 0) { - err = GetLastError(); - } - - va_start(va, format); - len = _vsnwprintf_s(message, MSGSIZE, _TRUNCATE, format, va); - va_end(va); - - formatWinerror(err, win_message, MSGSIZE); - if (len >= 0) { - _snwprintf_s(&message[len], MSGSIZE - len, _TRUNCATE, L": %s", - win_message); - } - -#if !defined(_WINDOWS) - fwprintf(stderr, L"%s\n", message); -#else - MessageBoxW(NULL, message, L"Python Launcher is sorry to say ...", - MB_OK); -#endif -} - - -void -error(wchar_t * format, ... ) -{ - va_list va; - wchar_t message[MSGSIZE]; - - va_start(va, format); - _vsnwprintf_s(message, MSGSIZE, _TRUNCATE, format, va); - va_end(va); - -#if !defined(_WINDOWS) - fwprintf(stderr, L"%s\n", message); -#else - MessageBoxW(NULL, message, L"Python Launcher is sorry to say ...", - MB_OK); -#endif -} - - -typedef BOOL (*PIsWow64Process2)(HANDLE, USHORT*, USHORT*); - - -USHORT -_getNativeMachine(void) -{ - static USHORT _nativeMachine = IMAGE_FILE_MACHINE_UNKNOWN; - if (_nativeMachine == IMAGE_FILE_MACHINE_UNKNOWN) { - USHORT processMachine; - HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll"); - PIsWow64Process2 IsWow64Process2 = kernel32 ? - (PIsWow64Process2)GetProcAddress(kernel32, "IsWow64Process2") : - NULL; - if (!IsWow64Process2) { - BOOL wow64Process; - if (!IsWow64Process(NULL, &wow64Process)) { - winerror(0, L"Checking process type"); - } else if (wow64Process) { - // We should always be a 32-bit executable, so if running - // under emulation, it must be a 64-bit host. - _nativeMachine = IMAGE_FILE_MACHINE_AMD64; - } else { - // Not running under emulation, and an old enough OS to not - // have IsWow64Process2, so assume it's x86. - _nativeMachine = IMAGE_FILE_MACHINE_I386; - } - } else if (!IsWow64Process2(NULL, &processMachine, &_nativeMachine)) { - winerror(0, L"Checking process type"); - } - } - return _nativeMachine; -} - - -bool -isAMD64Host(void) -{ - return _getNativeMachine() == IMAGE_FILE_MACHINE_AMD64; -} - - -bool -isARM64Host(void) -{ - return _getNativeMachine() == IMAGE_FILE_MACHINE_ARM64; -} - - -bool -isEnvVarSet(const wchar_t *name) -{ - /* only looking for non-empty, which means at least one character - and the null terminator */ - return GetEnvironmentVariableW(name, NULL, 0) >= 2; -} - - -bool -join(wchar_t *buffer, size_t bufferLength, const wchar_t *fragment) -{ - if (SUCCEEDED(PathCchCombineEx(buffer, bufferLength, buffer, fragment, PATHCCH_ALLOW_LONG_PATHS))) { - return true; - } - return false; -} - - -bool -split_parent(wchar_t *buffer, size_t bufferLength) -{ - return SUCCEEDED(PathCchRemoveFileSpec(buffer, bufferLength)); -} - - -int -_compare(const wchar_t *x, int xLen, const wchar_t *y, int yLen) -{ - // Empty strings sort first - if (!x || !xLen) { - return (!y || !yLen) ? 0 : -1; - } else if (!y || !yLen) { - return 1; - } - switch (CompareStringEx( - LOCALE_NAME_INVARIANT, NORM_IGNORECASE | SORT_DIGITSASNUMBERS, - x, xLen, y, yLen, - NULL, NULL, 0 - )) { - case CSTR_LESS_THAN: - return -1; - case CSTR_EQUAL: - return 0; - case CSTR_GREATER_THAN: - return 1; - default: - winerror(0, L"Error comparing '%.*s' and '%.*s' (compare)", xLen, x, yLen, y); - return -1; - } -} - - -int -_compareArgument(const wchar_t *x, int xLen, const wchar_t *y, int yLen) -{ - // Empty strings sort first - if (!x || !xLen) { - return (!y || !yLen) ? 0 : -1; - } else if (!y || !yLen) { - return 1; - } - switch (CompareStringEx( - LOCALE_NAME_INVARIANT, 0, - x, xLen, y, yLen, - NULL, NULL, 0 - )) { - case CSTR_LESS_THAN: - return -1; - case CSTR_EQUAL: - return 0; - case CSTR_GREATER_THAN: - return 1; - default: - winerror(0, L"Error comparing '%.*s' and '%.*s' (compareArgument)", xLen, x, yLen, y); - return -1; - } -} - -int -_comparePath(const wchar_t *x, int xLen, const wchar_t *y, int yLen) -{ - // Empty strings sort first - if (!x || !xLen) { - return !y || !yLen ? 0 : -1; - } else if (!y || !yLen) { - return 1; - } - switch (CompareStringOrdinal(x, xLen, y, yLen, TRUE)) { - case CSTR_LESS_THAN: - return -1; - case CSTR_EQUAL: - return 0; - case CSTR_GREATER_THAN: - return 1; - default: - winerror(0, L"Error comparing '%.*s' and '%.*s' (comparePath)", xLen, x, yLen, y); - return -1; - } -} - - -bool -_startsWith(const wchar_t *x, int xLen, const wchar_t *y, int yLen) -{ - if (!x || !y) { - return false; - } - yLen = yLen < 0 ? (int)wcsnlen_s(y, MAXLEN) : yLen; - xLen = xLen < 0 ? (int)wcsnlen_s(x, MAXLEN) : xLen; - return xLen >= yLen && 0 == _compare(x, yLen, y, yLen); -} - - -bool -_startsWithArgument(const wchar_t *x, int xLen, const wchar_t *y, int yLen) -{ - if (!x || !y) { - return false; - } - yLen = yLen < 0 ? (int)wcsnlen_s(y, MAXLEN) : yLen; - xLen = xLen < 0 ? (int)wcsnlen_s(x, MAXLEN) : xLen; - return xLen >= yLen && 0 == _compareArgument(x, yLen, y, yLen); -} - - -// Unlike regular startsWith, this function requires that the following -// character is either NULL (that is, the entire string matches) or is one of -// the characters in 'separators'. -bool -_startsWithSeparated(const wchar_t *x, int xLen, const wchar_t *y, int yLen, const wchar_t *separators) -{ - if (!x || !y) { - return false; - } - yLen = yLen < 0 ? (int)wcsnlen_s(y, MAXLEN) : yLen; - xLen = xLen < 0 ? (int)wcsnlen_s(x, MAXLEN) : xLen; - if (xLen < yLen) { - return false; - } - if (xLen == yLen) { - return 0 == _compare(x, xLen, y, yLen); - } - return separators && - 0 == _compare(x, yLen, y, yLen) && - wcschr(separators, x[yLen]) != NULL; -} - - - -/******************************************************************************\ - *** HELP TEXT *** -\******************************************************************************/ - - -int -showHelpText(wchar_t ** argv) -{ - // The help text is stored in launcher-usage.txt, which is compiled into - // the launcher and loaded at runtime if needed. - // - // The file must be UTF-8. There are two substitutions: - // %ls - PY_VERSION (as wchar_t*) - // %ls - argv[0] (as wchar_t*) - HRSRC res = FindResourceExW(NULL, L"USAGE", MAKEINTRESOURCE(1), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)); - HGLOBAL resData = res ? LoadResource(NULL, res) : NULL; - const char *usage = resData ? (const char*)LockResource(resData) : NULL; - if (usage == NULL) { - winerror(0, L"Unable to load usage text"); - return RC_INTERNAL_ERROR; - } - - DWORD cbData = SizeofResource(NULL, res); - DWORD cchUsage = MultiByteToWideChar(CP_UTF8, 0, usage, cbData, NULL, 0); - if (!cchUsage) { - winerror(0, L"Unable to preprocess usage text"); - return RC_INTERNAL_ERROR; - } - - cchUsage += 1; - wchar_t *wUsage = (wchar_t*)malloc(cchUsage * sizeof(wchar_t)); - cchUsage = MultiByteToWideChar(CP_UTF8, 0, usage, cbData, wUsage, cchUsage); - if (!cchUsage) { - winerror(0, L"Unable to preprocess usage text"); - free((void *)wUsage); - return RC_INTERNAL_ERROR; - } - // Ensure null termination - wUsage[cchUsage] = L'\0'; - - fwprintf(stdout, wUsage, (L"" PY_VERSION), argv[0]); - fflush(stdout); - - free((void *)wUsage); - - return 0; -} - - -/******************************************************************************\ - *** SEARCH INFO *** -\******************************************************************************/ - - -struct _SearchInfoBuffer { - struct _SearchInfoBuffer *next; - wchar_t buffer[0]; -}; - - -typedef struct { - // the original string, managed by the OS - const wchar_t *originalCmdLine; - // pointer into the cmdline to mark what we've consumed - const wchar_t *restOfCmdLine; - // if known/discovered, the full executable path of our runtime - const wchar_t *executablePath; - // pointer and length into cmdline for the file to check for a - // shebang line, if any. Length can be -1 if the string is null - // terminated. - const wchar_t *scriptFile; - int scriptFileLength; - // pointer and length into cmdline or a static string with the - // name of the target executable. Length can be -1 if the string - // is null terminated. - const wchar_t *executable; - int executableLength; - // pointer and length into a string with additional interpreter - // arguments to include before restOfCmdLine. Length can be -1 if - // the string is null terminated. - const wchar_t *executableArgs; - int executableArgsLength; - // pointer and length into cmdline or a static string with the - // company name for PEP 514 lookup. Length can be -1 if the string - // is null terminated. - const wchar_t *company; - int companyLength; - // pointer and length into cmdline or a static string with the - // tag for PEP 514 lookup. Length can be -1 if the string is - // null terminated. - const wchar_t *tag; - int tagLength; - // if true, treats 'tag' as a non-PEP 514 filter - bool oldStyleTag; - // if true, ignores 'tag' when a high priority environment is found - // gh-92817: This is currently set when a tag is read from configuration, - // the environment, or a shebang, rather than the command line, and the - // only currently possible high priority environment is an active virtual - // environment - bool lowPriorityTag; - // if true, allow PEP 514 lookup to override 'executable' - bool allowExecutableOverride; - // if true, allow a nearby pyvenv.cfg to locate the executable - bool allowPyvenvCfg; - // if true, allow defaults (env/py.ini) to clarify/override tags - bool allowDefaults; - // if true, prefer windowed (console-less) executable - bool windowed; - // if true, only list detected runtimes without launching - bool list; - // if true, only list detected runtimes with paths without launching - bool listPaths; - // if true, display help message before continuing - bool help; - // if set, limits search to registry keys with the specified Company - // This is intended for debugging and testing only - const wchar_t *limitToCompany; - // dynamically allocated buffers to free later - struct _SearchInfoBuffer *_buffer; -} SearchInfo; - - -wchar_t * -allocSearchInfoBuffer(SearchInfo *search, int wcharCount) -{ - struct _SearchInfoBuffer *buffer = (struct _SearchInfoBuffer*)malloc( - sizeof(struct _SearchInfoBuffer) + - wcharCount * sizeof(wchar_t) - ); - if (!buffer) { - return NULL; - } - buffer->next = search->_buffer; - search->_buffer = buffer; - return buffer->buffer; -} - - -void -freeSearchInfo(SearchInfo *search) -{ - struct _SearchInfoBuffer *b = search->_buffer; - search->_buffer = NULL; - while (b) { - struct _SearchInfoBuffer *nextB = b->next; - free((void *)b); - b = nextB; - } -} - - -void -_debugStringAndLength(const wchar_t *s, int len, const wchar_t *name) -{ - if (!s) { - debug(L"%s: (null)\n", name); - } else if (len == 0) { - debug(L"%s: (empty)\n", name); - } else if (len < 0) { - debug(L"%s: %s\n", name, s); - } else { - debug(L"%s: %.*ls\n", name, len, s); - } -} - - -void -dumpSearchInfo(SearchInfo *search) -{ - if (!log_fp) { - return; - } - -#ifdef __clang__ -#define DEBUGNAME(s) L # s -#else -#define DEBUGNAME(s) # s -#endif -#define DEBUG(s) debug(L"SearchInfo." DEBUGNAME(s) L": %s\n", (search->s) ? (search->s) : L"(null)") -#define DEBUG_2(s, sl) _debugStringAndLength((search->s), (search->sl), L"SearchInfo." DEBUGNAME(s)) -#define DEBUG_BOOL(s) debug(L"SearchInfo." DEBUGNAME(s) L": %s\n", (search->s) ? L"True" : L"False") - DEBUG(originalCmdLine); - DEBUG(restOfCmdLine); - DEBUG(executablePath); - DEBUG_2(scriptFile, scriptFileLength); - DEBUG_2(executable, executableLength); - DEBUG_2(executableArgs, executableArgsLength); - DEBUG_2(company, companyLength); - DEBUG_2(tag, tagLength); - DEBUG_BOOL(oldStyleTag); - DEBUG_BOOL(lowPriorityTag); - DEBUG_BOOL(allowDefaults); - DEBUG_BOOL(allowExecutableOverride); - DEBUG_BOOL(windowed); - DEBUG_BOOL(list); - DEBUG_BOOL(listPaths); - DEBUG_BOOL(help); - DEBUG(limitToCompany); -#undef DEBUG_BOOL -#undef DEBUG_2 -#undef DEBUG -#undef DEBUGNAME -} - - -int -findArgv0Length(const wchar_t *buffer, int bufferLength) -{ - // Note: this implements semantics that are only valid for argv0. - // Specifically, there is no escaping of quotes, and quotes within - // the argument have no effect. A quoted argv0 must start and end - // with a double quote character; otherwise, it ends at the first - // ' ' or '\t'. - int quoted = buffer[0] == L'"'; - for (int i = 1; bufferLength < 0 || i < bufferLength; ++i) { - switch (buffer[i]) { - case L'\0': - return i; - case L' ': - case L'\t': - if (!quoted) { - return i; - } - break; - case L'"': - if (quoted) { - return i + 1; - } - break; - } - } - return bufferLength; -} - - -const wchar_t * -findArgv0End(const wchar_t *buffer, int bufferLength) -{ - return &buffer[findArgv0Length(buffer, bufferLength)]; -} - - -/******************************************************************************\ - *** COMMAND-LINE PARSING *** -\******************************************************************************/ - -// Adapted from https://stackoverflow.com/a/65583702 -typedef struct AppExecLinkFile { // For tag IO_REPARSE_TAG_APPEXECLINK - DWORD reparseTag; - WORD reparseDataLength; - WORD reserved; - ULONG version; - wchar_t stringList[MAX_PATH * 4]; // Multistring (Consecutive UTF-16 strings each ending with a NUL) - /* There are normally 4 strings here. Ex: - Package ID: L"Microsoft.DesktopAppInstaller_8wekyb3d8bbwe" - Entry Point: L"Microsoft.DesktopAppInstaller_8wekyb3d8bbwe!PythonRedirector" - Executable: L"C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.17.106910_x64__8wekyb3d8bbwe\AppInstallerPythonRedirector.exe" - Applic. Type: L"0" // Integer as ASCII. "0" = Desktop bridge application; Else sandboxed UWP application - */ -} AppExecLinkFile; - - -int -parseCommandLine(SearchInfo *search) -{ - if (!search || !search->originalCmdLine) { - return RC_NO_COMMANDLINE; - } - - const wchar_t *argv0End = findArgv0End(search->originalCmdLine, -1); - const wchar_t *tail = argv0End; // will be start of the executable name - const wchar_t *end = argv0End; // will be end of the executable name - search->restOfCmdLine = argv0End; // will be first space after argv0 - while (--tail != search->originalCmdLine) { - if (*tail == L'"' && end == argv0End) { - // Move the "end" up to the quote, so we also allow moving for - // a period later on. - end = argv0End = tail; - } else if (*tail == L'.' && end == argv0End) { - end = tail; - } else if (*tail == L'\\' || *tail == L'/') { - ++tail; - break; - } - } - if (tail == search->originalCmdLine && tail[0] == L'"') { - ++tail; - } - // Without special cases, we can now fill in the search struct - int tailLen = (int)(end ? (end - tail) : wcsnlen_s(tail, MAXLEN)); - search->executableLength = -1; - - // Our special cases are as follows -#define MATCHES(s) (0 == _comparePath(tail, tailLen, (s), -1)) -#define STARTSWITH(s) _startsWith(tail, tailLen, (s), -1) - if (MATCHES(L"py")) { - search->executable = L"python.exe"; - search->allowExecutableOverride = true; - search->allowDefaults = true; - } else if (MATCHES(L"pyw")) { - search->executable = L"pythonw.exe"; - search->allowExecutableOverride = true; - search->allowDefaults = true; - search->windowed = true; - } else if (MATCHES(L"py_d")) { - search->executable = L"python_d.exe"; - search->allowExecutableOverride = true; - search->allowDefaults = true; - } else if (MATCHES(L"pyw_d")) { - search->executable = L"pythonw_d.exe"; - search->allowExecutableOverride = true; - search->allowDefaults = true; - search->windowed = true; - } else if (STARTSWITH(L"python3")) { - search->executable = L"python.exe"; - search->tag = &tail[6]; - search->tagLength = tailLen - 6; - search->allowExecutableOverride = true; - search->oldStyleTag = true; - search->allowPyvenvCfg = true; - } else if (STARTSWITH(L"pythonw3")) { - search->executable = L"pythonw.exe"; - search->tag = &tail[7]; - search->tagLength = tailLen - 7; - search->allowExecutableOverride = true; - search->oldStyleTag = true; - search->allowPyvenvCfg = true; - search->windowed = true; - } else { - search->executable = tail; - search->executableLength = tailLen; - search->allowPyvenvCfg = true; - } -#undef STARTSWITH -#undef MATCHES - - // First argument might be one of our options. If so, consume it, - // update flags and then set restOfCmdLine. - const wchar_t *arg = search->restOfCmdLine; - while(*arg && isspace(*arg)) { ++arg; } -#define MATCHES(s) (0 == _compareArgument(arg, argLen, (s), -1)) -#define STARTSWITH(s) _startsWithArgument(arg, argLen, (s), -1) - if (*arg && *arg == L'-' && *++arg) { - tail = arg; - while (*tail && !isspace(*tail)) { ++tail; } - int argLen = (int)(tail - arg); - if (argLen > 0) { - if (STARTSWITH(L"2") || STARTSWITH(L"3")) { - // All arguments starting with 2 or 3 are assumed to be version tags - search->tag = arg; - search->tagLength = argLen; - search->oldStyleTag = true; - search->restOfCmdLine = tail; - } else if (STARTSWITH(L"V:") || STARTSWITH(L"-version:")) { - // Arguments starting with 'V:' specify company and/or tag - const wchar_t *argStart = wcschr(arg, L':') + 1; - const wchar_t *tagStart = wcschr(argStart, L'/') ; - if (tagStart) { - search->company = argStart; - search->companyLength = (int)(tagStart - argStart); - search->tag = tagStart + 1; - } else { - search->tag = argStart; - } - search->tagLength = (int)(tail - search->tag); - search->allowDefaults = false; - search->restOfCmdLine = tail; - } else if (MATCHES(L"0") || MATCHES(L"-list")) { - search->list = true; - search->restOfCmdLine = tail; - } else if (MATCHES(L"0p") || MATCHES(L"-list-paths")) { - search->listPaths = true; - search->restOfCmdLine = tail; - } else if (MATCHES(L"h") || MATCHES(L"-help")) { - search->help = true; - // Do not update restOfCmdLine so that we trigger the help - // message from whichever interpreter we select - } - } - } -#undef STARTSWITH -#undef MATCHES - - // Might have a script filename. If it looks like a filename, add - // it to the SearchInfo struct for later reference. - arg = search->restOfCmdLine; - while(*arg && isspace(*arg)) { ++arg; } - if (*arg && *arg != L'-') { - search->scriptFile = arg; - if (*arg == L'"') { - ++search->scriptFile; - while (*++arg && *arg != L'"') { } - } else { - while (*arg && !isspace(*arg)) { ++arg; } - } - search->scriptFileLength = (int)(arg - search->scriptFile); - } - - return 0; -} - - -int -_decodeShebang(SearchInfo *search, const char *buffer, int bufferLength, bool onlyUtf8, wchar_t **decoded, int *decodedLength) -{ - DWORD cp = CP_UTF8; - int wideLen = MultiByteToWideChar(cp, MB_ERR_INVALID_CHARS, buffer, bufferLength, NULL, 0); - if (!wideLen) { - cp = CP_ACP; - wideLen = MultiByteToWideChar(cp, MB_ERR_INVALID_CHARS, buffer, bufferLength, NULL, 0); - if (!wideLen) { - debug(L"# Failed to decode shebang line (0x%08X)\n", GetLastError()); - return RC_BAD_VIRTUAL_PATH; - } - } - wchar_t *b = allocSearchInfoBuffer(search, wideLen + 1); - if (!b) { - return RC_NO_MEMORY; - } - wideLen = MultiByteToWideChar(cp, 0, buffer, bufferLength, b, wideLen + 1); - if (!wideLen) { - debug(L"# Failed to decode shebang line (0x%08X)\n", GetLastError()); - return RC_BAD_VIRTUAL_PATH; - } - b[wideLen] = L'\0'; - *decoded = b; - *decodedLength = wideLen; - return 0; -} - - -bool -_shebangStartsWith(const wchar_t *buffer, int bufferLength, const wchar_t *prefix, const wchar_t **rest, int *firstArgumentLength) -{ - int prefixLength = (int)wcsnlen_s(prefix, MAXLEN); - if (bufferLength < prefixLength || !_startsWithArgument(buffer, bufferLength, prefix, prefixLength)) { - return false; - } - if (rest) { - *rest = &buffer[prefixLength]; - } - if (firstArgumentLength) { - int i = prefixLength; - while (i < bufferLength && !isspace(buffer[i])) { - i += 1; - } - *firstArgumentLength = i - prefixLength; - } - return true; -} - - -int -ensure_no_redirector_stub(wchar_t* filename, wchar_t* buffer) -{ - // Make sure we didn't find a reparse point that will open the Microsoft Store - // If we did, pretend there was no shebang and let normal handling take over - WIN32_FIND_DATAW findData; - HANDLE hFind = FindFirstFileW(buffer, &findData); - if (!hFind) { - // Let normal handling take over - debug(L"# Did not find %s on PATH\n", filename); - return RC_NO_SHEBANG; - } - - FindClose(hFind); - - if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && - findData.dwReserved0 & IO_REPARSE_TAG_APPEXECLINK)) { - return 0; - } - - HANDLE hReparsePoint = CreateFileW(buffer, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT, NULL); - if (!hReparsePoint) { - // Let normal handling take over - debug(L"# Did not find %s on PATH\n", filename); - return RC_NO_SHEBANG; - } - - AppExecLinkFile appExecLink; - - if (!DeviceIoControl(hReparsePoint, FSCTL_GET_REPARSE_POINT, NULL, 0, &appExecLink, sizeof(appExecLink), NULL, NULL)) { - // Let normal handling take over - debug(L"# Did not find %s on PATH\n", filename); - CloseHandle(hReparsePoint); - return RC_NO_SHEBANG; - } - - CloseHandle(hReparsePoint); - - const wchar_t* redirectorPackageId = L"Microsoft.DesktopAppInstaller_8wekyb3d8bbwe"; - - if (0 == wcscmp(appExecLink.stringList, redirectorPackageId)) { - debug(L"# ignoring redirector that would launch store\n"); - return RC_NO_SHEBANG; - } - - return 0; -} - - -int -searchPath(SearchInfo *search, const wchar_t *shebang, int shebangLength) -{ - if (isEnvVarSet(L"PYLAUNCHER_NO_SEARCH_PATH")) { - return RC_NO_SHEBANG; - } - - wchar_t *command; - int commandLength; - if (!_shebangStartsWith(shebang, shebangLength, L"/usr/bin/env ", &command, &commandLength)) { - return RC_NO_SHEBANG; - } - - if (!commandLength || commandLength == MAXLEN) { - return RC_BAD_VIRTUAL_PATH; - } - - int lastDot = commandLength; - while (lastDot > 0 && command[lastDot] != L'.') { - lastDot -= 1; - } - if (!lastDot) { - lastDot = commandLength; - } - - wchar_t filename[MAXLEN]; - if (wcsncpy_s(filename, MAXLEN, command, commandLength)) { - return RC_BAD_VIRTUAL_PATH; - } - - const wchar_t *ext = L".exe"; - // If the command already has an extension, we do not want to add it again - if (!lastDot || _comparePath(&filename[lastDot], -1, ext, -1)) { - if (wcscat_s(filename, MAXLEN, L".exe")) { - return RC_BAD_VIRTUAL_PATH; - } - } - - debug(L"# Search PATH for %s\n", filename); - - wchar_t pathVariable[MAXLEN]; - int n = GetEnvironmentVariableW(L"PATH", pathVariable, MAXLEN); - if (!n) { - if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) { - return RC_NO_SHEBANG; - } - winerror(0, L"Failed to read PATH\n", filename); - return RC_INTERNAL_ERROR; - } - - wchar_t buffer[MAXLEN]; - n = SearchPathW(pathVariable, filename, NULL, MAXLEN, buffer, NULL); - if (!n) { - if (GetLastError() == ERROR_FILE_NOT_FOUND) { - debug(L"# Did not find %s on PATH\n", filename); - // If we didn't find it on PATH, let normal handling take over - return RC_NO_SHEBANG; - } - // Other errors should cause us to break - winerror(0, L"Failed to find %s on PATH\n", filename); - return RC_BAD_VIRTUAL_PATH; - } - - int result = ensure_no_redirector_stub(filename, buffer); - if (result) { - return result; - } - - // Check that we aren't going to call ourselves again - // If we are, pretend there was no shebang and let normal handling take over - if (GetModuleFileNameW(NULL, filename, MAXLEN) && - 0 == _comparePath(filename, -1, buffer, -1)) { - debug(L"# ignoring recursive shebang command\n"); - return RC_RECURSIVE_SHEBANG; - } - - wchar_t *buf = allocSearchInfoBuffer(search, n + 1); - if (!buf || wcscpy_s(buf, n + 1, buffer)) { - return RC_NO_MEMORY; - } - - search->executablePath = buf; - search->executableArgs = &command[commandLength]; - search->executableArgsLength = shebangLength - commandLength; - debug(L"# Found %s on PATH\n", buf); - - return 0; -} - - -int -_readIni(const wchar_t *section, const wchar_t *settingName, wchar_t *buffer, int bufferLength) -{ - wchar_t iniPath[MAXLEN]; - int n; - // Check for _PYLAUNCHER_INIDIR override (used for test isolation) - DWORD len = GetEnvironmentVariableW(L"_PYLAUNCHER_INIDIR", iniPath, MAXLEN); - if (len && len < MAXLEN) { - if (join(iniPath, MAXLEN, L"py.ini")) { - debug(L"# Reading from %s for %s/%s\n", iniPath, section, settingName); - n = GetPrivateProfileStringW(section, settingName, NULL, buffer, bufferLength, iniPath); - if (n) { - debug(L"# Found %s in %s\n", settingName, iniPath); - return n; - } - } - // When _PYLAUNCHER_INIDIR is set, skip the default locations - return 0; - } - if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, iniPath)) && - join(iniPath, MAXLEN, L"py.ini")) { - debug(L"# Reading from %s for %s/%s\n", iniPath, section, settingName); - n = GetPrivateProfileStringW(section, settingName, NULL, buffer, bufferLength, iniPath); - if (n) { - debug(L"# Found %s in %s\n", settingName, iniPath); - return n; - } else if (GetLastError() == ERROR_FILE_NOT_FOUND) { - debug(L"# Did not find file %s\n", iniPath); - } else { - winerror(0, L"Failed to read from %s\n", iniPath); - } - } - if (GetModuleFileNameW(NULL, iniPath, MAXLEN) && - SUCCEEDED(PathCchRemoveFileSpec(iniPath, MAXLEN)) && - join(iniPath, MAXLEN, L"py.ini")) { - debug(L"# Reading from %s for %s/%s\n", iniPath, section, settingName); - n = GetPrivateProfileStringW(section, settingName, NULL, buffer, MAXLEN, iniPath); - if (n) { - debug(L"# Found %s in %s\n", settingName, iniPath); - return n; - } else if (GetLastError() == ERROR_FILE_NOT_FOUND) { - debug(L"# Did not find file %s\n", iniPath); - } else { - winerror(0, L"Failed to read from %s\n", iniPath); - } - } - return 0; -} - - -bool -_findCommand(SearchInfo *search, const wchar_t *command, int commandLength) -{ - wchar_t commandBuffer[MAXLEN]; - wchar_t buffer[MAXLEN]; - wcsncpy_s(commandBuffer, MAXLEN, command, commandLength); - int n = _readIni(L"commands", commandBuffer, buffer, MAXLEN); - if (!n) { - return false; - } - wchar_t *path = allocSearchInfoBuffer(search, n + 1); - if (!path) { - return false; - } - wcscpy_s(path, n + 1, buffer); - search->executablePath = path; - return true; -} - - -int -_useShebangAsExecutable(SearchInfo *search, const wchar_t *shebang, int shebangLength) -{ - wchar_t buffer[MAXLEN]; - wchar_t script[MAXLEN]; - wchar_t command[MAXLEN]; - - int commandLength = 0; - int inQuote = 0; - - if (!shebang || !shebangLength) { - return 0; - } - - wchar_t *pC = command; - for (int i = 0; i < shebangLength; ++i) { - wchar_t c = shebang[i]; - if (isspace(c) && !inQuote) { - commandLength = i; - break; - } else if (c == L'"') { - inQuote = !inQuote; - } else if (c == L'/' || c == L'\\') { - *pC++ = L'\\'; - } else { - *pC++ = c; - } - } - *pC = L'\0'; - - if (!GetCurrentDirectoryW(MAXLEN, buffer) || - wcsncpy_s(script, MAXLEN, search->scriptFile, search->scriptFileLength) || - FAILED(PathCchCombineEx(buffer, MAXLEN, buffer, script, - PATHCCH_ALLOW_LONG_PATHS)) || - FAILED(PathCchRemoveFileSpec(buffer, MAXLEN)) || - FAILED(PathCchCombineEx(buffer, MAXLEN, buffer, command, - PATHCCH_ALLOW_LONG_PATHS)) - ) { - return RC_NO_MEMORY; - } - - int n = (int)wcsnlen(buffer, MAXLEN); - wchar_t *path = allocSearchInfoBuffer(search, n + 1); - if (!path) { - return RC_NO_MEMORY; - } - wcscpy_s(path, n + 1, buffer); - search->executablePath = path; - if (commandLength) { - search->executableArgs = &shebang[commandLength]; - search->executableArgsLength = shebangLength - commandLength; - } - return 0; -} - - -int -checkShebang(SearchInfo *search) -{ - // Do not check shebang if a tag was provided or if no script file - // was found on the command line. - if (search->tag || !search->scriptFile) { - return 0; - } - - if (search->scriptFileLength < 0) { - search->scriptFileLength = (int)wcsnlen_s(search->scriptFile, MAXLEN); - } - - wchar_t *scriptFile = (wchar_t*)malloc(sizeof(wchar_t) * (search->scriptFileLength + 1)); - if (!scriptFile) { - return RC_NO_MEMORY; - } - - wcsncpy_s(scriptFile, search->scriptFileLength + 1, - search->scriptFile, search->scriptFileLength); - - HANDLE hFile = CreateFileW(scriptFile, GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, OPEN_EXISTING, 0, NULL); - - if (hFile == INVALID_HANDLE_VALUE) { - debug(L"# Failed to open %s for shebang parsing (0x%08X)\n", - scriptFile, GetLastError()); - free(scriptFile); - return RC_NO_SCRIPT; - } - - DWORD bytesRead = 0; - unsigned char buffer[4096]; - if (!ReadFile(hFile, buffer, sizeof(buffer), &bytesRead, NULL)) { - debug(L"# Failed to read %s for shebang parsing (0x%08X)\n", - scriptFile, GetLastError()); - free(scriptFile); - return 0; - } - - CloseHandle(hFile); - debug(L"# Read %d bytes from %s to find shebang line\n", bytesRead, scriptFile); - free(scriptFile); - - - unsigned char *b = buffer; - bool onlyUtf8 = false; - if (bytesRead > 3 && *b == 0xEF) { - if (*++b == 0xBB && *++b == 0xBF) { - // Allow a UTF-8 BOM - ++b; - bytesRead -= 3; - onlyUtf8 = true; - } else { - debug(L"# Invalid BOM in shebang line"); - return 0; - } - } - if (bytesRead <= 2 || b[0] != '#' || b[1] != '!') { - // No shebang (#!) at start of line - debug(L"# No valid shebang line"); - return 0; - } - ++b; - --bytesRead; - while (--bytesRead > 0 && isspace(*++b)) { } - const unsigned char *start = b; - while (--bytesRead > 0 && *++b != '\r' && *b != '\n') { } - wchar_t *shebang; - int shebangLength; - // We add 1 when bytesRead==0, as in that case we hit EOF and b points - // to the last character in the file, not the newline - int exitCode = _decodeShebang(search, (const char*)start, (int)(b - start + (bytesRead == 0)), onlyUtf8, &shebang, &shebangLength); - if (exitCode) { - return exitCode; - } - debug(L"Shebang: %s\n", shebang); - - // Handle shebangs that we should search PATH for - int executablePathWasSetByUsrBinEnv = 0; - exitCode = searchPath(search, shebang, shebangLength); - if (exitCode == 0) { - executablePathWasSetByUsrBinEnv = 1; - } else if (exitCode != RC_NO_SHEBANG) { - return exitCode; - } - - // Handle some known, case-sensitive shebangs - const wchar_t *command; - int commandLength; - // Each template must end with "python" - static const wchar_t *shebangTemplates[] = { - L"/usr/bin/env python", - L"/usr/bin/python", - L"/usr/local/bin/python", - L"python", - NULL - }; - - for (const wchar_t **tmpl = shebangTemplates; *tmpl; ++tmpl) { - // Just to make sure we don't mess this up in the future - assert(0 == wcscmp(L"python", (*tmpl) + wcslen(*tmpl) - 6)); - - if (_shebangStartsWith(shebang, shebangLength, *tmpl, &command, &commandLength)) { - // Search for "python{command}" overrides. All templates end with - // "python", so we prepend it by jumping back 6 characters - if (_findCommand(search, &command[-6], commandLength + 6)) { - search->executableArgs = &command[commandLength]; - search->executableArgsLength = shebangLength - commandLength; - debug(L"# Treating shebang command '%.*s' as %s\n", - commandLength + 6, &command[-6], search->executablePath); - return 0; - } - - search->tag = command; - search->tagLength = commandLength; - // If we had 'python3.12.exe' then we want to strip the suffix - // off of the tag - if (search->tagLength >= 4) { - const wchar_t *suffix = &search->tag[search->tagLength - 4]; - if (0 == _comparePath(suffix, 4, L".exe", -1)) { - search->tagLength -= 4; - } - } - // If we had 'python3_d' then we want to strip the '_d' (any - // '.exe' is already gone) - if (search->tagLength >= 2) { - const wchar_t *suffix = &search->tag[search->tagLength - 2]; - if (0 == _comparePath(suffix, 2, L"_d", -1)) { - search->tagLength -= 2; - } - } - search->oldStyleTag = true; - search->lowPriorityTag = true; - search->executableArgs = &command[commandLength]; - search->executableArgsLength = shebangLength - commandLength; - if (search->tag && search->tagLength) { - debug(L"# Treating shebang command '%.*s' as 'py -%.*s'\n", - commandLength, command, search->tagLength, search->tag); - } else { - debug(L"# Treating shebang command '%.*s' as 'py'\n", - commandLength, command); - } - return 0; - } - } - - // Didn't match a template, but we found it on PATH - if (executablePathWasSetByUsrBinEnv) { - return 0; - } - - // Unrecognised executables are first tried as command aliases - commandLength = 0; - while (commandLength < shebangLength && !isspace(shebang[commandLength])) { - commandLength += 1; - } - if (_findCommand(search, shebang, commandLength)) { - search->executableArgs = &shebang[commandLength]; - search->executableArgsLength = shebangLength - commandLength; - debug(L"# Treating shebang command '%.*s' as %s\n", - commandLength, shebang, search->executablePath); - return 0; - } - - // Unrecognised commands are joined to the script's directory and treated - // as the executable path - return _useShebangAsExecutable(search, shebang, shebangLength); -} - - -int -checkDefaults(SearchInfo *search) -{ - if (!search->allowDefaults) { - return 0; - } - - // Only resolve old-style (or absent) tags to defaults - if (search->tag && search->tagLength && !search->oldStyleTag) { - return 0; - } - - // If tag is only a major version number, expand it from the environment - // or an ini file - const wchar_t *iniSettingName = NULL; - const wchar_t *envSettingName = NULL; - if (!search->tag || !search->tagLength) { - iniSettingName = L"python"; - envSettingName = L"py_python"; - } else if (0 == wcsncmp(search->tag, L"3", search->tagLength)) { - iniSettingName = L"python3"; - envSettingName = L"py_python3"; - } else if (0 == wcsncmp(search->tag, L"2", search->tagLength)) { - iniSettingName = L"python2"; - envSettingName = L"py_python2"; - } else { - debug(L"# Cannot select defaults for tag '%.*s'\n", search->tagLength, search->tag); - return 0; - } - - // First, try to read an environment variable - wchar_t buffer[MAXLEN]; - int n = GetEnvironmentVariableW(envSettingName, buffer, MAXLEN); - - // If none found, check in our two .ini files instead - if (!n) { - n = _readIni(L"defaults", iniSettingName, buffer, MAXLEN); - } - - if (n) { - wchar_t *tag = allocSearchInfoBuffer(search, n + 1); - if (!tag) { - return RC_NO_MEMORY; - } - wcscpy_s(tag, n + 1, buffer); - wchar_t *slash = wcschr(tag, L'/'); - if (!slash) { - search->tag = tag; - search->tagLength = n; - search->oldStyleTag = true; - } else { - search->company = tag; - search->companyLength = (int)(slash - tag); - search->tag = slash + 1; - search->tagLength = n - (search->companyLength + 1); - search->oldStyleTag = false; - } - // gh-92817: allow a high priority env to be selected even if it - // doesn't match the tag - search->lowPriorityTag = true; - } - - return 0; -} - -/******************************************************************************\ - *** ENVIRONMENT SEARCH *** -\******************************************************************************/ - -typedef struct EnvironmentInfo { - /* We use a binary tree and sort on insert */ - struct EnvironmentInfo *prev; - struct EnvironmentInfo *next; - /* parent is only used when constructing */ - struct EnvironmentInfo *parent; - const wchar_t *company; - const wchar_t *tag; - int internalSortKey; - const wchar_t *installDir; - const wchar_t *executablePath; - const wchar_t *executableArgs; - const wchar_t *architecture; - const wchar_t *displayName; - bool highPriority; -} EnvironmentInfo; - - -int -copyWstr(const wchar_t **dest, const wchar_t *src) -{ - if (!dest) { - return RC_NO_MEMORY; - } - if (!src) { - *dest = NULL; - return 0; - } - size_t n = wcsnlen_s(src, MAXLEN - 1) + 1; - wchar_t *buffer = (wchar_t*)malloc(n * sizeof(wchar_t)); - if (!buffer) { - return RC_NO_MEMORY; - } - wcsncpy_s(buffer, n, src, n - 1); - *dest = (const wchar_t*)buffer; - return 0; -} - - -EnvironmentInfo * -newEnvironmentInfo(const wchar_t *company, const wchar_t *tag) -{ - EnvironmentInfo *env = (EnvironmentInfo *)malloc(sizeof(EnvironmentInfo)); - if (!env) { - return NULL; - } - memset(env, 0, sizeof(EnvironmentInfo)); - int exitCode = copyWstr(&env->company, company); - if (exitCode) { - free((void *)env); - return NULL; - } - exitCode = copyWstr(&env->tag, tag); - if (exitCode) { - free((void *)env->company); - free((void *)env); - return NULL; - } - return env; -} - - -void -freeEnvironmentInfo(EnvironmentInfo *env) -{ - if (env) { - free((void *)env->company); - free((void *)env->tag); - free((void *)env->installDir); - free((void *)env->executablePath); - free((void *)env->executableArgs); - free((void *)env->displayName); - freeEnvironmentInfo(env->prev); - env->prev = NULL; - freeEnvironmentInfo(env->next); - env->next = NULL; - free((void *)env); - } -} - - -/* Specific string comparisons for sorting the tree */ - -int -_compareCompany(const wchar_t *x, const wchar_t *y) -{ - if (!x && !y) { - return 0; - } else if (!x) { - return -1; - } else if (!y) { - return 1; - } - - bool coreX = 0 == _compare(x, -1, L"PythonCore", -1); - bool coreY = 0 == _compare(y, -1, L"PythonCore", -1); - if (coreX) { - return coreY ? 0 : -1; - } else if (coreY) { - return 1; - } - return _compare(x, -1, y, -1); -} - - -int -_compareTag(const wchar_t *x, const wchar_t *y) -{ - if (!x && !y) { - return 0; - } else if (!x) { - return -1; - } else if (!y) { - return 1; - } - - // Compare up to the first dash. If not equal, that's our sort order - const wchar_t *xDash = wcschr(x, L'-'); - const wchar_t *yDash = wcschr(y, L'-'); - int xToDash = xDash ? (int)(xDash - x) : -1; - int yToDash = yDash ? (int)(yDash - y) : -1; - int r = _compare(x, xToDash, y, yToDash); - if (r) { - return r; - } - // If we're equal up to the first dash, we want to sort one with - // no dash *after* one with a dash. Otherwise, a reversed compare. - // This works out because environments are sorted in descending tag - // order, so that higher versions (probably) come first. - // For PythonCore, our "X.Y" structure ensures that higher versions - // come first. Everyone else will just have to deal with it. - if (xDash && yDash) { - return _compare(yDash, -1, xDash, -1); - } else if (xDash) { - return -1; - } else if (yDash) { - return 1; - } - return 0; -} - - -int -addEnvironmentInfo(EnvironmentInfo **root, EnvironmentInfo* parent, EnvironmentInfo *node) -{ - EnvironmentInfo *r = *root; - if (!r) { - *root = node; - node->parent = parent; - return 0; - } - // Sort by company name - switch (_compareCompany(node->company, r->company)) { - case -1: - return addEnvironmentInfo(&r->prev, r, node); - case 1: - return addEnvironmentInfo(&r->next, r, node); - case 0: - break; - } - // Then by tag (descending) - switch (_compareTag(node->tag, r->tag)) { - case -1: - return addEnvironmentInfo(&r->next, r, node); - case 1: - return addEnvironmentInfo(&r->prev, r, node); - case 0: - break; - } - // Then keep the one with the lowest internal sort key - if (node->internalSortKey < r->internalSortKey) { - // Replace the current node - node->parent = r->parent; - if (node->parent) { - if (node->parent->prev == r) { - node->parent->prev = node; - } else if (node->parent->next == r) { - node->parent->next = node; - } else { - debug(L"# Inconsistent parent value in tree\n"); - freeEnvironmentInfo(node); - return RC_INTERNAL_ERROR; - } - } else { - // If node has no parent, then it is the root. - *root = node; - } - - node->next = r->next; - node->prev = r->prev; - - debug(L"# replaced %s/%s/%i in tree\n", node->company, node->tag, node->internalSortKey); - freeEnvironmentInfo(r); - } else { - debug(L"# not adding %s/%s/%i to tree\n", node->company, node->tag, node->internalSortKey); - return RC_DUPLICATE_ITEM; - } - return 0; -} - - -/******************************************************************************\ - *** REGISTRY SEARCH *** -\******************************************************************************/ - - -int -_registryReadString(const wchar_t **dest, HKEY root, const wchar_t *subkey, const wchar_t *value) -{ - // Note that this is bytes (hence 'cb'), not characters ('cch') - DWORD cbData = 0; - DWORD flags = RRF_RT_REG_SZ | RRF_RT_REG_EXPAND_SZ; - - if (ERROR_SUCCESS != RegGetValueW(root, subkey, value, flags, NULL, NULL, &cbData)) { - return 0; - } - - wchar_t *buffer = (wchar_t*)malloc(cbData); - if (!buffer) { - return RC_NO_MEMORY; - } - - if (ERROR_SUCCESS == RegGetValueW(root, subkey, value, flags, NULL, buffer, &cbData)) { - *dest = buffer; - } else { - free((void *)buffer); - } - return 0; -} - - -int -_combineWithInstallDir(const wchar_t **dest, const wchar_t *installDir, const wchar_t *fragment, int fragmentLength) -{ - wchar_t buffer[MAXLEN]; - wchar_t fragmentBuffer[MAXLEN]; - if (wcsncpy_s(fragmentBuffer, MAXLEN, fragment, fragmentLength)) { - return RC_NO_MEMORY; - } - - if (FAILED(PathCchCombineEx(buffer, MAXLEN, installDir, fragmentBuffer, PATHCCH_ALLOW_LONG_PATHS))) { - return RC_NO_MEMORY; - } - - return copyWstr(dest, buffer); -} - - -bool -_isLegacyVersion(EnvironmentInfo *env) -{ - // Check if backwards-compatibility is required. - // Specifically PythonCore versions 2.X and 3.0 - 3.5 do not implement PEP 514. - if (0 != _compare(env->company, -1, L"PythonCore", -1)) { - return false; - } - - int versionMajor, versionMinor; - int n = swscanf_s(env->tag, L"%d.%d", &versionMajor, &versionMinor); - if (n != 2) { - debug(L"# %s/%s has an invalid version tag\n", env->company, env->tag); - return false; - } - - return versionMajor == 2 - || (versionMajor == 3 && versionMinor >= 0 && versionMinor <= 5); -} - -int -_registryReadLegacyEnvironment(const SearchInfo *search, HKEY root, EnvironmentInfo *env, const wchar_t *fallbackArch) -{ - // Backwards-compatibility for PythonCore versions which do not implement PEP 514. - int exitCode = _combineWithInstallDir( - &env->executablePath, - env->installDir, - search->executable, - search->executableLength - ); - if (exitCode) { - return exitCode; - } - - if (search->windowed) { - exitCode = _registryReadString(&env->executableArgs, root, L"InstallPath", L"WindowedExecutableArguments"); - } - else { - exitCode = _registryReadString(&env->executableArgs, root, L"InstallPath", L"ExecutableArguments"); - } - if (exitCode) { - return exitCode; - } - - if (fallbackArch) { - copyWstr(&env->architecture, fallbackArch); - } else { - DWORD binaryType; - BOOL success = GetBinaryTypeW(env->executablePath, &binaryType); - if (!success) { - return RC_NO_PYTHON; - } - - switch (binaryType) { - case SCS_32BIT_BINARY: - copyWstr(&env->architecture, L"32bit"); - break; - case SCS_64BIT_BINARY: - copyWstr(&env->architecture, L"64bit"); - break; - default: - return RC_NO_PYTHON; - } - } - - if (0 == _compare(env->architecture, -1, L"32bit", -1)) { - size_t tagLength = wcslen(env->tag); - if (tagLength <= 3 || 0 != _compare(&env->tag[tagLength - 3], 3, L"-32", 3)) { - const wchar_t *rawTag = env->tag; - wchar_t *realTag = (wchar_t*) malloc(sizeof(wchar_t) * (tagLength + 4)); - if (!realTag) { - return RC_NO_MEMORY; - } - - int count = swprintf_s(realTag, tagLength + 4, L"%s-32", env->tag); - if (count == -1) { - debug(L"# Failed to generate 32bit tag\n"); - free(realTag); - return RC_INTERNAL_ERROR; - } - - env->tag = realTag; - free((void*)rawTag); - } - } - - wchar_t buffer[MAXLEN]; - if (swprintf_s(buffer, MAXLEN, L"Python %s", env->tag)) { - copyWstr(&env->displayName, buffer); - } - - return 0; -} - - -int -_registryReadEnvironment(const SearchInfo *search, HKEY root, EnvironmentInfo *env, const wchar_t *fallbackArch) -{ - int exitCode = _registryReadString(&env->installDir, root, L"InstallPath", NULL); - if (exitCode) { - return exitCode; - } - if (!env->installDir) { - return RC_NO_PYTHON; - } - - if (_isLegacyVersion(env)) { - return _registryReadLegacyEnvironment(search, root, env, fallbackArch); - } - - // If pythonw.exe requested, check specific value - if (search->windowed) { - exitCode = _registryReadString(&env->executablePath, root, L"InstallPath", L"WindowedExecutablePath"); - if (!exitCode && env->executablePath) { - exitCode = _registryReadString(&env->executableArgs, root, L"InstallPath", L"WindowedExecutableArguments"); - } - } - if (exitCode) { - return exitCode; - } - - // Missing windowed path or non-windowed request means we use ExecutablePath - if (!env->executablePath) { - exitCode = _registryReadString(&env->executablePath, root, L"InstallPath", L"ExecutablePath"); - if (!exitCode && env->executablePath) { - exitCode = _registryReadString(&env->executableArgs, root, L"InstallPath", L"ExecutableArguments"); - } - } - if (exitCode) { - return exitCode; - } - - if (!env->executablePath) { - debug(L"# %s/%s has no executable path\n", env->company, env->tag); - return RC_NO_PYTHON; - } - - exitCode = _registryReadString(&env->architecture, root, NULL, L"SysArchitecture"); - if (exitCode) { - return exitCode; - } - - exitCode = _registryReadString(&env->displayName, root, NULL, L"DisplayName"); - if (exitCode) { - return exitCode; - } - - return 0; -} - -int -_registrySearchTags(const SearchInfo *search, EnvironmentInfo **result, HKEY root, int sortKey, const wchar_t *company, const wchar_t *fallbackArch) -{ - wchar_t buffer[256]; - int err = 0; - int exitCode = 0; - for (int i = 0; exitCode == 0; ++i) { - DWORD cchBuffer = sizeof(buffer) / sizeof(buffer[0]); - err = RegEnumKeyExW(root, i, buffer, &cchBuffer, NULL, NULL, NULL, NULL); - if (err) { - if (err != ERROR_NO_MORE_ITEMS) { - winerror(0, L"Failed to read installs (tags) from the registry"); - } - break; - } - HKEY subkey; - if (ERROR_SUCCESS == RegOpenKeyExW(root, buffer, 0, KEY_READ, &subkey)) { - EnvironmentInfo *env = newEnvironmentInfo(company, buffer); - env->internalSortKey = sortKey; - exitCode = _registryReadEnvironment(search, subkey, env, fallbackArch); - RegCloseKey(subkey); - if (exitCode == RC_NO_PYTHON) { - freeEnvironmentInfo(env); - exitCode = 0; - } else if (!exitCode) { - exitCode = addEnvironmentInfo(result, NULL, env); - if (exitCode) { - freeEnvironmentInfo(env); - if (exitCode == RC_DUPLICATE_ITEM) { - exitCode = 0; - } - } - } - } - } - return exitCode; -} - - -int -registrySearch(const SearchInfo *search, EnvironmentInfo **result, HKEY root, int sortKey, const wchar_t *fallbackArch) -{ - wchar_t buffer[256]; - int err = 0; - int exitCode = 0; - for (int i = 0; exitCode == 0; ++i) { - DWORD cchBuffer = sizeof(buffer) / sizeof(buffer[0]); - err = RegEnumKeyExW(root, i, buffer, &cchBuffer, NULL, NULL, NULL, NULL); - if (err) { - if (err != ERROR_NO_MORE_ITEMS) { - winerror(0, L"Failed to read distributors (company) from the registry"); - } - break; - } - if (search->limitToCompany && 0 != _compare(search->limitToCompany, -1, buffer, cchBuffer)) { - debug(L"# Skipping %s due to PYLAUNCHER_LIMIT_TO_COMPANY\n", buffer); - continue; - } - HKEY subkey; - if (ERROR_SUCCESS == RegOpenKeyExW(root, buffer, 0, KEY_READ, &subkey)) { - exitCode = _registrySearchTags(search, result, subkey, sortKey, buffer, fallbackArch); - RegCloseKey(subkey); - } - } - return exitCode; -} - - -/******************************************************************************\ - *** APP PACKAGE SEARCH *** -\******************************************************************************/ - -int -appxSearch(const SearchInfo *search, EnvironmentInfo **result, const wchar_t *packageFamilyName, const wchar_t *tag, int sortKey) -{ - wchar_t realTag[32]; - wchar_t buffer[MAXLEN]; - const wchar_t *exeName = search->executable; - if (!exeName || search->allowExecutableOverride) { - exeName = search->windowed ? L"pythonw.exe" : L"python.exe"; - } - - // Failure to get LocalAppData may just mean we're running as a user who - // doesn't have a profile directory. - // In this case, return "not found", but don't fail. - // Chances are they can't launch Store installs anyway. - if (FAILED(SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, buffer))) { - return RC_NO_PYTHON; - } - - if (!join(buffer, MAXLEN, L"Microsoft\\WindowsApps") || - !join(buffer, MAXLEN, packageFamilyName) || - !join(buffer, MAXLEN, exeName)) { - debug(L"# Failed to construct App Execution Alias path\n"); - return RC_INTERNAL_ERROR; - } - - if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW(buffer)) { - return RC_NO_PYTHON; - } - - // Assume packages are native architecture, which means we need to append - // the '-arm64' on ARM64 host. - wcscpy_s(realTag, 32, tag); - if (isARM64Host()) { - wcscat_s(realTag, 32, L"-arm64"); - } - - EnvironmentInfo *env = newEnvironmentInfo(L"PythonCore", realTag); - if (!env) { - return RC_NO_MEMORY; - } - env->internalSortKey = sortKey; - if (isAMD64Host()) { - copyWstr(&env->architecture, L"64bit"); - } else if (isARM64Host()) { - copyWstr(&env->architecture, L"ARM64"); - } - - copyWstr(&env->executablePath, buffer); - - if (swprintf_s(buffer, MAXLEN, L"Python %s (Store)", tag)) { - copyWstr(&env->displayName, buffer); - } - - int exitCode = addEnvironmentInfo(result, NULL, env); - if (exitCode) { - freeEnvironmentInfo(env); - if (exitCode == RC_DUPLICATE_ITEM) { - exitCode = 0; - } - } - - - return exitCode; -} - - -/******************************************************************************\ - *** OVERRIDDEN EXECUTABLE PATH *** -\******************************************************************************/ - - -int -explicitOverrideSearch(const SearchInfo *search, EnvironmentInfo **result) -{ - if (!search->executablePath) { - return 0; - } - - EnvironmentInfo *env = newEnvironmentInfo(NULL, NULL); - if (!env) { - return RC_NO_MEMORY; - } - env->internalSortKey = 10; - int exitCode = copyWstr(&env->executablePath, search->executablePath); - if (exitCode) { - goto abort; - } - exitCode = copyWstr(&env->displayName, L"Explicit override"); - if (exitCode) { - goto abort; - } - exitCode = addEnvironmentInfo(result, NULL, env); - if (exitCode) { - goto abort; - } - return 0; - -abort: - freeEnvironmentInfo(env); - if (exitCode == RC_DUPLICATE_ITEM) { - exitCode = 0; - } - return exitCode; -} - - -/******************************************************************************\ - *** ACTIVE VIRTUAL ENVIRONMENT SEARCH *** -\******************************************************************************/ - -int -virtualenvSearch(const SearchInfo *search, EnvironmentInfo **result) -{ - int exitCode = 0; - EnvironmentInfo *env = NULL; - wchar_t buffer[MAXLEN]; - int n = GetEnvironmentVariableW(L"VIRTUAL_ENV", buffer, MAXLEN); - if (!n || !join(buffer, MAXLEN, L"Scripts") || !join(buffer, MAXLEN, search->executable)) { - return 0; - } - - DWORD attr = GetFileAttributesW(buffer); - if (INVALID_FILE_ATTRIBUTES == attr && search->lowPriorityTag) { - if (!split_parent(buffer, MAXLEN) || !join(buffer, MAXLEN, L"python.exe")) { - return 0; - } - attr = GetFileAttributesW(buffer); - } - - if (INVALID_FILE_ATTRIBUTES == attr) { - debug(L"Python executable %s missing from virtual env\n", buffer); - return 0; - } - - env = newEnvironmentInfo(NULL, NULL); - if (!env) { - return RC_NO_MEMORY; - } - env->highPriority = true; - env->internalSortKey = 20; - exitCode = copyWstr(&env->displayName, L"Active venv"); - if (exitCode) { - goto abort; - } - exitCode = copyWstr(&env->executablePath, buffer); - if (exitCode) { - goto abort; - } - exitCode = addEnvironmentInfo(result, NULL, env); - if (exitCode) { - goto abort; - } - return 0; - -abort: - freeEnvironmentInfo(env); - if (exitCode == RC_DUPLICATE_ITEM) { - return 0; - } - return exitCode; -} - -/******************************************************************************\ - *** COLLECT ENVIRONMENTS *** -\******************************************************************************/ - - -struct RegistrySearchInfo { - // Registry subkey to search - const wchar_t *subkey; - // Registry hive to search - HKEY hive; - // Flags to use when opening the subkey - DWORD flags; - // Internal sort key to select between "identical" environments discovered - // through different methods - int sortKey; - // Fallback value to assume for PythonCore entries missing a SysArchitecture value - const wchar_t *fallbackArch; -}; - - -struct RegistrySearchInfo REGISTRY_SEARCH[] = { - { - L"Software\\Python", - HKEY_CURRENT_USER, - KEY_READ, - 1, - NULL - }, - { - L"Software\\Python", - HKEY_LOCAL_MACHINE, - KEY_READ | KEY_WOW64_64KEY, - 3, - L"64bit" - }, - { - L"Software\\Python", - HKEY_LOCAL_MACHINE, - KEY_READ | KEY_WOW64_32KEY, - 4, - L"32bit" - }, - { NULL, 0, 0, 0, NULL } -}; - - -struct AppxSearchInfo { - // The package family name. Can be found for an installed package using the - // Powershell "Get-AppxPackage" cmdlet - const wchar_t *familyName; - // The tag to treat the installation as - const wchar_t *tag; - // Internal sort key to select between "identical" environments discovered - // through different methods - int sortKey; -}; - - -struct AppxSearchInfo APPX_SEARCH[] = { - // Releases made through the Store - { L"PythonSoftwareFoundation.Python.3.14_qbz5n2kfra8p0", L"3.14", 10 }, - { L"PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0", L"3.13", 10 }, - { L"PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0", L"3.12", 10 }, - { L"PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0", L"3.11", 10 }, - { L"PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0", L"3.10", 10 }, - { L"PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0", L"3.9", 10 }, - { L"PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0", L"3.8", 10 }, - - // Side-loadable releases. Note that the publisher ID changes whenever we - // change our code signing certificate subject, so the newer IDs have higher - // priorities (lower sortKey) - { L"PythonSoftwareFoundation.Python.3.14_3847v3x7pw1km", L"3.14", 11 }, - { L"PythonSoftwareFoundation.Python.3.13_3847v3x7pw1km", L"3.13", 11 }, - { L"PythonSoftwareFoundation.Python.3.12_3847v3x7pw1km", L"3.12", 11 }, - { L"PythonSoftwareFoundation.Python.3.11_3847v3x7pw1km", L"3.11", 11 }, - { L"PythonSoftwareFoundation.Python.3.11_hd69rhyc2wevp", L"3.11", 12 }, - { L"PythonSoftwareFoundation.Python.3.10_3847v3x7pw1km", L"3.10", 11 }, - { L"PythonSoftwareFoundation.Python.3.10_hd69rhyc2wevp", L"3.10", 12 }, - { L"PythonSoftwareFoundation.Python.3.9_3847v3x7pw1km", L"3.9", 11 }, - { L"PythonSoftwareFoundation.Python.3.9_hd69rhyc2wevp", L"3.9", 12 }, - { L"PythonSoftwareFoundation.Python.3.8_hd69rhyc2wevp", L"3.8", 12 }, - { NULL, NULL, 0 } -}; - - -int -collectEnvironments(const SearchInfo *search, EnvironmentInfo **result) -{ - int exitCode = 0; - HKEY root; - EnvironmentInfo *env = NULL; - - if (!result) { - debug(L"# collectEnvironments() was passed a NULL result\n"); - return RC_INTERNAL_ERROR; - } - *result = NULL; - - exitCode = explicitOverrideSearch(search, result); - if (exitCode) { - return exitCode; - } - - exitCode = virtualenvSearch(search, result); - if (exitCode) { - return exitCode; - } - - // If we aren't collecting all items to list them, we can exit now. - if (env && !(search->list || search->listPaths)) { - return 0; - } - - for (struct RegistrySearchInfo *info = REGISTRY_SEARCH; info->subkey; ++info) { - if (ERROR_SUCCESS == RegOpenKeyExW(info->hive, info->subkey, 0, info->flags, &root)) { - exitCode = registrySearch(search, result, root, info->sortKey, info->fallbackArch); - RegCloseKey(root); - } - if (exitCode) { - return exitCode; - } - } - - if (search->limitToCompany) { - debug(L"# Skipping APPX search due to PYLAUNCHER_LIMIT_TO_COMPANY\n"); - return 0; - } - - for (struct AppxSearchInfo *info = APPX_SEARCH; info->familyName; ++info) { - exitCode = appxSearch(search, result, info->familyName, info->tag, info->sortKey); - if (exitCode && exitCode != RC_NO_PYTHON) { - return exitCode; - } - } - - return 0; -} - - -/******************************************************************************\ - *** INSTALL ON DEMAND *** -\******************************************************************************/ - -struct StoreSearchInfo { - // The tag a user is looking for - const wchar_t *tag; - // The Store ID for a package if it can be installed from the Microsoft - // Store. These are obtained from the dashboard at - // https://partner.microsoft.com/dashboard - const wchar_t *storeId; -}; - - -struct StoreSearchInfo STORE_SEARCH[] = { - { L"3", /* 3.13 */ L"9PNRBTZXMB4Z" }, - { L"3.14", L"9NTRHQCBBPR8" }, - { L"3.13", L"9PNRBTZXMB4Z" }, - { L"3.12", L"9NCVDN91XZQP" }, - { L"3.11", L"9NRWMJP3717K" }, - { L"3.10", L"9PJPW5LDXLZ5" }, - { L"3.9", L"9P7QFQMJRFP7" }, - { L"3.8", L"9MSSZTT1N39L" }, - { NULL, NULL } -}; - - -int -_installEnvironment(const wchar_t *command, const wchar_t *arguments) -{ - SHELLEXECUTEINFOW siw = { - sizeof(SHELLEXECUTEINFOW), - SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NO_CONSOLE, - NULL, NULL, - command, arguments, NULL, - SW_SHOWNORMAL - }; - - debug(L"# Installing with %s %s\n", command, arguments); - if (isEnvVarSet(L"PYLAUNCHER_DRYRUN")) { - debug(L"# Exiting due to PYLAUNCHER_DRYRUN\n"); - fflush(stdout); - int mode = _setmode(_fileno(stdout), _O_U8TEXT); - if (arguments) { - fwprintf_s(stdout, L"\"%s\" %s\n", command, arguments); - } else { - fwprintf_s(stdout, L"\"%s\"\n", command); - } - fflush(stdout); - if (mode >= 0) { - _setmode(_fileno(stdout), mode); - } - return RC_INSTALLING; - } - - if (!ShellExecuteExW(&siw)) { - return RC_NO_PYTHON; - } - - if (!siw.hProcess) { - return RC_INSTALLING; - } - - WaitForSingleObjectEx(siw.hProcess, INFINITE, FALSE); - DWORD exitCode = 0; - if (GetExitCodeProcess(siw.hProcess, &exitCode) && exitCode == 0) { - return 0; - } - return RC_INSTALLING; -} - - -const wchar_t *WINGET_COMMAND = L"Microsoft\\WindowsApps\\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\\winget.exe"; -const wchar_t *WINGET_ARGUMENTS = L"install -q %s --exact --accept-package-agreements --source msstore"; - -const wchar_t *MSSTORE_COMMAND = L"ms-windows-store://pdp/?productid=%s"; - -int -installEnvironment(const SearchInfo *search) -{ - // No tag? No installing - if (!search->tag || !search->tagLength) { - debug(L"# Cannot install Python with no tag specified\n"); - return RC_NO_PYTHON; - } - - // PEP 514 tag but not PythonCore? No installing - if (!search->oldStyleTag && - search->company && search->companyLength && - 0 != _compare(search->company, search->companyLength, L"PythonCore", -1)) { - debug(L"# Cannot install for company %.*s\n", search->companyLength, search->company); - return RC_NO_PYTHON; - } - - const wchar_t *storeId = NULL; - for (struct StoreSearchInfo *info = STORE_SEARCH; info->tag; ++info) { - if (0 == _compare(search->tag, search->tagLength, info->tag, -1)) { - storeId = info->storeId; - break; - } - } - - if (!storeId) { - return RC_NO_PYTHON; - } - - int exitCode; - wchar_t command[MAXLEN]; - wchar_t arguments[MAXLEN]; - if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, command)) && - join(command, MAXLEN, WINGET_COMMAND) && - swprintf_s(arguments, MAXLEN, WINGET_ARGUMENTS, storeId)) { - if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW(command)) { - formatWinerror(GetLastError(), arguments, MAXLEN); - debug(L"# Skipping %s: %s\n", command, arguments); - } else { - fputws(L"Launching winget to install Python. The following output is from the install process\n\ -***********************************************************************\n", stdout); - exitCode = _installEnvironment(command, arguments); - if (exitCode == RC_INSTALLING) { - fputws(L"***********************************************************************\n\ -Please check the install status and run your command again.", stderr); - return exitCode; - } else if (exitCode) { - return exitCode; - } - fputws(L"***********************************************************************\n\ -Install appears to have succeeded. Searching for new matching installs.\n", stdout); - return 0; - } - } - - if (swprintf_s(command, MAXLEN, MSSTORE_COMMAND, storeId)) { - fputws(L"Opening the Microsoft Store to install Python. After installation, " - L"please run your command again.\n", stderr); - exitCode = _installEnvironment(command, NULL); - if (exitCode) { - return exitCode; - } - return 0; - } - - return RC_NO_PYTHON; -} - -/******************************************************************************\ - *** ENVIRONMENT SELECT *** -\******************************************************************************/ - -bool -_companyMatches(const SearchInfo *search, const EnvironmentInfo *env) -{ - if (!search->company || !search->companyLength) { - return true; - } - return 0 == _compare(env->company, -1, search->company, search->companyLength); -} - - -bool -_tagMatches(const SearchInfo *search, const EnvironmentInfo *env, int searchTagLength) -{ - if (searchTagLength < 0) { - searchTagLength = search->tagLength; - } - if (!search->tag || !searchTagLength) { - return true; - } - return _startsWithSeparated(env->tag, -1, search->tag, searchTagLength, L".-"); -} - - -bool -_is32Bit(const EnvironmentInfo *env) -{ - if (env->architecture) { - return 0 == _compare(env->architecture, -1, L"32bit", -1); - } - return false; -} - - -int -_selectEnvironment(const SearchInfo *search, EnvironmentInfo *env, EnvironmentInfo **best) -{ - int exitCode = 0; - while (env) { - exitCode = _selectEnvironment(search, env->prev, best); - - if (exitCode && exitCode != RC_NO_PYTHON) { - return exitCode; - } else if (!exitCode && *best) { - return 0; - } - - if (env->highPriority && search->lowPriorityTag) { - // This environment is marked high priority, and the search allows - // it to be selected even though a tag is specified, so select it - // gh-92817: this allows an active venv to be selected even when a - // default tag has been found in py.ini or the environment - *best = env; - return 0; - } - - if (!search->oldStyleTag) { - if (_companyMatches(search, env) && _tagMatches(search, env, -1)) { - // Because of how our sort tree is set up, we will walk up the - // "prev" side and implicitly select the "best" best. By - // returning straight after a match, we skip the entire "next" - // branch and won't ever select a "worse" best. - *best = env; - return 0; - } - } else if (0 == _compare(env->company, -1, L"PythonCore", -1)) { - // Old-style tags can only match PythonCore entries - - // If the tag ends with -64, we want to exclude 32-bit runtimes - // (If the tag ends with -32, it will be filtered later) - int tagLength = search->tagLength; - bool exclude32Bit = false, only32Bit = false; - if (tagLength > 3) { - if (0 == _compareArgument(&search->tag[tagLength - 3], 3, L"-64", 3)) { - tagLength -= 3; - exclude32Bit = true; - } else if (0 == _compareArgument(&search->tag[tagLength - 3], 3, L"-32", 3)) { - tagLength -= 3; - only32Bit = true; - } - } - - if (_tagMatches(search, env, tagLength)) { - if (exclude32Bit && _is32Bit(env)) { - debug(L"# Excluding %s/%s because it looks like 32bit\n", env->company, env->tag); - } else if (only32Bit && !_is32Bit(env)) { - debug(L"# Excluding %s/%s because it doesn't look 32bit\n", env->company, env->tag); - } else { - *best = env; - return 0; - } - } - } - - env = env->next; - } - return RC_NO_PYTHON; -} - -int -selectEnvironment(const SearchInfo *search, EnvironmentInfo *root, EnvironmentInfo **best) -{ - if (!best) { - debug(L"# selectEnvironment() was passed a NULL best\n"); - return RC_INTERNAL_ERROR; - } - if (!root) { - *best = NULL; - return RC_NO_PYTHON_AT_ALL; - } - - EnvironmentInfo *result = NULL; - int exitCode = _selectEnvironment(search, root, &result); - if (!exitCode) { - *best = result; - } - - return exitCode; -} - - -/******************************************************************************\ - *** LIST ENVIRONMENTS *** -\******************************************************************************/ - -#define TAGWIDTH 16 - -int -_printEnvironment(const EnvironmentInfo *env, FILE *out, bool showPath, const wchar_t *argument) -{ - if (showPath) { - if (env->executablePath && env->executablePath[0]) { - if (env->executableArgs && env->executableArgs[0]) { - fwprintf(out, L" %-*s %s %s\n", TAGWIDTH, argument, env->executablePath, env->executableArgs); - } else { - fwprintf(out, L" %-*s %s\n", TAGWIDTH, argument, env->executablePath); - } - } else if (env->installDir && env->installDir[0]) { - fwprintf(out, L" %-*s %s\n", TAGWIDTH, argument, env->installDir); - } else { - fwprintf(out, L" %s\n", argument); - } - } else if (env->displayName) { - fwprintf(out, L" %-*s %s\n", TAGWIDTH, argument, env->displayName); - } else { - fwprintf(out, L" %s\n", argument); - } - return 0; -} - - -int -_listAllEnvironments(EnvironmentInfo *env, FILE * out, bool showPath, EnvironmentInfo *defaultEnv) -{ - wchar_t buffer[256]; - const int bufferSize = 256; - while (env) { - int exitCode = _listAllEnvironments(env->prev, out, showPath, defaultEnv); - if (exitCode) { - return exitCode; - } - - if (!env->company || !env->tag) { - buffer[0] = L'\0'; - } else if (0 == _compare(env->company, -1, L"PythonCore", -1)) { - swprintf_s(buffer, bufferSize, L"-V:%s", env->tag); - } else { - swprintf_s(buffer, bufferSize, L"-V:%s/%s", env->company, env->tag); - } - - if (env == defaultEnv) { - wcscat_s(buffer, bufferSize, L" *"); - } - - if (buffer[0]) { - exitCode = _printEnvironment(env, out, showPath, buffer); - if (exitCode) { - return exitCode; - } - } - - env = env->next; - } - return 0; -} - - -int -listEnvironments(EnvironmentInfo *env, FILE * out, bool showPath, EnvironmentInfo *defaultEnv) -{ - if (!env) { - fwprintf_s(stdout, L"No installed Pythons found!\n"); - return 0; - } - - /* TODO: Do we want to display these? - In favour, helps users see that '-3' is a good option - Against, repeats the next line of output - SearchInfo majorSearch; - EnvironmentInfo *major; - int exitCode; - - if (showPath) { - memset(&majorSearch, 0, sizeof(majorSearch)); - majorSearch.company = L"PythonCore"; - majorSearch.companyLength = -1; - majorSearch.tag = L"3"; - majorSearch.tagLength = -1; - majorSearch.oldStyleTag = true; - major = NULL; - exitCode = selectEnvironment(&majorSearch, env, &major); - if (!exitCode && major) { - exitCode = _printEnvironment(major, out, showPath, L"-3 *"); - isDefault = false; - if (exitCode) { - return exitCode; - } - } - majorSearch.tag = L"2"; - major = NULL; - exitCode = selectEnvironment(&majorSearch, env, &major); - if (!exitCode && major) { - exitCode = _printEnvironment(major, out, showPath, L"-2"); - if (exitCode) { - return exitCode; - } - } - } - */ - - int mode = _setmode(_fileno(out), _O_U8TEXT); - int exitCode = _listAllEnvironments(env, out, showPath, defaultEnv); - fflush(out); - if (mode >= 0) { - _setmode(_fileno(out), mode); - } - return exitCode; -} - - -/******************************************************************************\ - *** INTERPRETER LAUNCH *** -\******************************************************************************/ - - -int -calculateCommandLine(const SearchInfo *search, const EnvironmentInfo *launch, wchar_t *buffer, int bufferLength) -{ - int exitCode = 0; - const wchar_t *executablePath = NULL; - - // Construct command line from a search override, or else the selected - // environment's executablePath - if (search->executablePath) { - executablePath = search->executablePath; - } else if (launch && launch->executablePath) { - executablePath = launch->executablePath; - } - - // If we have an executable path, put it at the start of the command, but - // only if the search allowed an override. - // Otherwise, use the environment's installDir and the search's default - // executable name. - if (executablePath && search->allowExecutableOverride) { - if (wcschr(executablePath, L' ') && executablePath[0] != L'"') { - buffer[0] = L'"'; - exitCode = wcscpy_s(&buffer[1], bufferLength - 1, executablePath); - if (!exitCode) { - exitCode = wcscat_s(buffer, bufferLength, L"\""); - } - } else { - exitCode = wcscpy_s(buffer, bufferLength, executablePath); - } - } else if (launch) { - if (!launch->installDir) { - fwprintf_s(stderr, L"Cannot launch %s %s because no install directory was specified", - launch->company, launch->tag); - exitCode = RC_NO_PYTHON; - } else if (!search->executable || !search->executableLength) { - fwprintf_s(stderr, L"Cannot launch %s %s because no executable name is available", - launch->company, launch->tag); - exitCode = RC_NO_PYTHON; - } else { - wchar_t executable[256]; - wcsncpy_s(executable, 256, search->executable, search->executableLength); - if ((wcschr(launch->installDir, L' ') && launch->installDir[0] != L'"') || - (wcschr(executable, L' ') && executable[0] != L'"')) { - buffer[0] = L'"'; - exitCode = wcscpy_s(&buffer[1], bufferLength - 1, launch->installDir); - if (!exitCode) { - exitCode = join(buffer, bufferLength, executable) ? 0 : RC_NO_MEMORY; - } - if (!exitCode) { - exitCode = wcscat_s(buffer, bufferLength, L"\""); - } - } else { - exitCode = wcscpy_s(buffer, bufferLength, launch->installDir); - if (!exitCode) { - exitCode = join(buffer, bufferLength, executable) ? 0 : RC_NO_MEMORY; - } - } - } - } else { - exitCode = RC_NO_PYTHON; - } - - if (!exitCode && launch && launch->executableArgs) { - exitCode = wcscat_s(buffer, bufferLength, L" "); - if (!exitCode) { - exitCode = wcscat_s(buffer, bufferLength, launch->executableArgs); - } - } - - if (!exitCode && search->executableArgs) { - if (search->executableArgsLength < 0) { - exitCode = wcscat_s(buffer, bufferLength, search->executableArgs); - } else if (search->executableArgsLength > 0) { - int end = (int)wcsnlen_s(buffer, MAXLEN); - if (end < bufferLength - (search->executableArgsLength + 1)) { - exitCode = wcsncpy_s(&buffer[end], bufferLength - end, - search->executableArgs, search->executableArgsLength); - } - } - } - - if (!exitCode && search->restOfCmdLine) { - exitCode = wcscat_s(buffer, bufferLength, search->restOfCmdLine); - } - - return exitCode; -} - - - -BOOL -_safeDuplicateHandle(HANDLE in, HANDLE * pout, const wchar_t *nameForError) -{ - BOOL ok; - HANDLE process = GetCurrentProcess(); - DWORD rc; - - *pout = NULL; - ok = DuplicateHandle(process, in, process, pout, 0, TRUE, - DUPLICATE_SAME_ACCESS); - if (!ok) { - rc = GetLastError(); - if (rc == ERROR_INVALID_HANDLE) { - debug(L"DuplicateHandle returned ERROR_INVALID_HANDLE\n"); - ok = TRUE; - } - else { - winerror(0, L"Failed to duplicate %s handle", nameForError); - } - } - return ok; -} - -BOOL WINAPI -ctrl_c_handler(DWORD code) -{ - return TRUE; /* We just ignore all control events. */ -} - - -int -launchEnvironment(const SearchInfo *search, const EnvironmentInfo *launch, wchar_t *launchCommand) -{ - HANDLE job; - JOBOBJECT_EXTENDED_LIMIT_INFORMATION info; - DWORD rc; - BOOL ok; - STARTUPINFOW si; - PROCESS_INFORMATION pi; - - // If this is a dryrun, do not actually launch - if (isEnvVarSet(L"PYLAUNCHER_DRYRUN")) { - debug(L"LaunchCommand: %s\n", launchCommand); - debug(L"# Exiting due to PYLAUNCHER_DRYRUN variable\n"); - fflush(stdout); - int mode = _setmode(_fileno(stdout), _O_U8TEXT); - fwprintf(stdout, L"%s\n", launchCommand); - fflush(stdout); - if (mode >= 0) { - _setmode(_fileno(stdout), mode); - } - return 0; - } - -#if defined(_WINDOWS) - /* - When explorer launches a Windows (GUI) application, it displays - the "app starting" (the "pointer + hourglass") cursor for a number - of seconds, or until the app does something UI-ish (eg, creating a - window, or fetching a message). As this launcher doesn't do this - directly, that cursor remains even after the child process does these - things. We avoid that by doing a simple post+get message. - See http://bugs.python.org/issue17290 - */ - MSG msg; - - PostMessage(0, 0, 0, 0); - GetMessage(&msg, 0, 0, 0); -#endif - - debug(L"# about to run: %s\n", launchCommand); - job = CreateJobObject(NULL, NULL); - ok = QueryInformationJobObject(job, JobObjectExtendedLimitInformation, - &info, sizeof(info), &rc); - if (!ok || (rc != sizeof(info)) || !job) { - winerror(0, L"Failed to query job information"); - return RC_CREATE_PROCESS; - } - info.BasicLimitInformation.LimitFlags |= JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | - JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK; - ok = SetInformationJobObject(job, JobObjectExtendedLimitInformation, &info, - sizeof(info)); - if (!ok) { - winerror(0, L"Failed to update job information"); - return RC_CREATE_PROCESS; - } - memset(&si, 0, sizeof(si)); - GetStartupInfoW(&si); - if (!_safeDuplicateHandle(GetStdHandle(STD_INPUT_HANDLE), &si.hStdInput, L"stdin") || - !_safeDuplicateHandle(GetStdHandle(STD_OUTPUT_HANDLE), &si.hStdOutput, L"stdout") || - !_safeDuplicateHandle(GetStdHandle(STD_ERROR_HANDLE), &si.hStdError, L"stderr")) { - return RC_NO_STD_HANDLES; - } - - ok = SetConsoleCtrlHandler(ctrl_c_handler, TRUE); - if (!ok) { - winerror(0, L"Failed to update Control-C handler"); - return RC_NO_STD_HANDLES; - } - - si.dwFlags = STARTF_USESTDHANDLES; - ok = CreateProcessW(NULL, launchCommand, NULL, NULL, TRUE, - 0, NULL, NULL, &si, &pi); - if (!ok) { - winerror(0, L"Unable to create process using '%s'", launchCommand); - return RC_CREATE_PROCESS; - } - AssignProcessToJobObject(job, pi.hProcess); - CloseHandle(pi.hThread); - WaitForSingleObjectEx(pi.hProcess, INFINITE, FALSE); - ok = GetExitCodeProcess(pi.hProcess, &rc); - if (!ok) { - winerror(0, L"Failed to get exit code of process"); - return RC_CREATE_PROCESS; - } - debug(L"child process exit code: %d\n", rc); - return rc; -} - - -/******************************************************************************\ - *** PROCESS CONTROLLER *** -\******************************************************************************/ - - -int -performSearch(SearchInfo *search, EnvironmentInfo **envs) -{ - // First parse the command line for options - int exitCode = parseCommandLine(search); - if (exitCode) { - return exitCode; - } - - // Check for a shebang line in our script file - // (or return quickly if no script file was specified) - exitCode = checkShebang(search); - switch (exitCode) { - case 0: - case RC_NO_SHEBANG: - case RC_RECURSIVE_SHEBANG: - break; - case RC_NO_SCRIPT: - if (!_comparePath(search->scriptFile, search->scriptFileLength, L"install", -1) || - !_comparePath(search->scriptFile, search->scriptFileLength, L"uninstall", -1) || - !_comparePath(search->scriptFile, search->scriptFileLength, L"list", -1) || - !_comparePath(search->scriptFile, search->scriptFileLength, L"help", -1)) { - fprintf( - stderr, - "WARNING: The '%.*ls' command is unavailable because this is the legacy py.exe command.\n" - "If you have already installed the Python install manager, open Installed Apps and " - "remove 'Python Launcher' to enable the new py.exe command.\n", - search->scriptFileLength, - search->scriptFile - ); - } - break; - default: - return exitCode; - } - - // Resolve old-style tags (possibly from a shebang) against py.ini entries - // and environment variables. - exitCode = checkDefaults(search); - if (exitCode) { - return exitCode; - } - - // If debugging is enabled, list our search criteria - dumpSearchInfo(search); - - // Find all matching environments - exitCode = collectEnvironments(search, envs); - if (exitCode) { - return exitCode; - } - - return 0; -} - - -int -process(int argc, wchar_t ** argv) -{ - int exitCode = 0; - int searchExitCode = 0; - SearchInfo search = {0}; - EnvironmentInfo *envs = NULL; - EnvironmentInfo *env = NULL; - wchar_t launchCommand[MAXLEN]; - - memset(launchCommand, 0, sizeof(launchCommand)); - - if (isEnvVarSet(L"PYLAUNCHER_DEBUG")) { - setvbuf(stderr, (char *)NULL, _IONBF, 0); - log_fp = stderr; - debug(L"argv0: %s\nversion: %S\n", argv[0], PY_VERSION); - } - - DWORD len = GetEnvironmentVariableW(L"PYLAUNCHER_LIMIT_TO_COMPANY", NULL, 0); - if (len > 1) { - wchar_t *limitToCompany = allocSearchInfoBuffer(&search, len); - if (!limitToCompany) { - exitCode = RC_NO_MEMORY; - winerror(0, L"Failed to allocate internal buffer"); - goto abort; - } - search.limitToCompany = limitToCompany; - if (0 == GetEnvironmentVariableW(L"PYLAUNCHER_LIMIT_TO_COMPANY", limitToCompany, len)) { - exitCode = RC_INTERNAL_ERROR; - winerror(0, L"Failed to read PYLAUNCHER_LIMIT_TO_COMPANY variable"); - goto abort; - } - } - - search.originalCmdLine = GetCommandLineW(); - - exitCode = performSearch(&search, &envs); - if (exitCode) { - goto abort; - } - - // Display the help text, but only exit on error - if (search.help) { - exitCode = showHelpText(argv); - if (exitCode) { - goto abort; - } - } - - // Select best environment - // This is early so that we can show the default when listing, but all - // responses to any errors occur later. - searchExitCode = selectEnvironment(&search, envs, &env); - - // List all environments, then exit - if (search.list || search.listPaths) { - exitCode = listEnvironments(envs, stdout, search.listPaths, env); - goto abort; - } - - // When debugging, list all discovered environments anyway - if (log_fp) { - exitCode = listEnvironments(envs, log_fp, true, NULL); - if (exitCode) { - goto abort; - } - } - - // We searched earlier, so if we didn't find anything, now we react - exitCode = searchExitCode; - // If none found, and if permitted, install it - if (((exitCode == RC_NO_PYTHON) && isEnvVarSet(L"PYLAUNCHER_ALLOW_INSTALL")) || - isEnvVarSet(L"PYLAUNCHER_ALWAYS_INSTALL")) { - exitCode = installEnvironment(&search); - if (!exitCode) { - // Successful install, so we need to re-scan and select again - env = NULL; - exitCode = performSearch(&search, &envs); - if (exitCode) { - goto abort; - } - exitCode = selectEnvironment(&search, envs, &env); - } - } - if (exitCode == RC_NO_PYTHON) { - fputws(L"No suitable Python runtime found\n", stderr); - fputws(L"Pass --list (-0) to see all detected environments on your machine\n", stderr); - if (!isEnvVarSet(L"PYLAUNCHER_ALLOW_INSTALL") && search.oldStyleTag) { - fputws(L"or set environment variable PYLAUNCHER_ALLOW_INSTALL to use winget\n" - L"or open the Microsoft Store to the requested version.\n", stderr); - } - goto abort; - } - if (exitCode == RC_NO_PYTHON_AT_ALL) { - fputws(L"No installed Python found!\n", stderr); - goto abort; - } - if (exitCode) { - goto abort; - } - - if (env) { - debug(L"env.company: %s\nenv.tag: %s\n", env->company, env->tag); - } else { - debug(L"env.company: (null)\nenv.tag: (null)\n"); - } - - exitCode = calculateCommandLine(&search, env, launchCommand, sizeof(launchCommand) / sizeof(launchCommand[0])); - if (exitCode) { - goto abort; - } - - // Launch selected runtime - exitCode = launchEnvironment(&search, env, launchCommand); - -abort: - freeSearchInfo(&search); - freeEnvironmentInfo(envs); - return exitCode; -} - - -#if defined(_WINDOWS) - -int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPWSTR lpstrCmd, int nShow) -{ - return process(__argc, __wargv); -} - -#else - -int cdecl wmain(int argc, wchar_t ** argv) -{ - return process(argc, argv); -} - -#endif diff --git a/PC/layout/README.md b/PC/layout/README.md new file mode 100644 index 000000000000000..086cc23194b1b96 --- /dev/null +++ b/PC/layout/README.md @@ -0,0 +1,341 @@ +# PC/layout script + +This document provides an overview of the `PC/layout` script, which is used to +convert from a build tree to a ready-to-run directory of files. It's the +equivalent of `make install` when using the Makefile. We use it for official +binary releases, but it also supports a lot of configuration and can be used for +whatever your custom scenario should look like. + +The script never builds anything. It reads files from an existing build tree +(`-b`) and the source tree (`-s`), then copies or zips them into a layout. It +does not require the Python being laid out to be runnable, and it can target a +different version from the one running the script (see [Build source +options](#build-source-options)). + +## Quick start + +Run the script as a directory with any Python 3 interpreter. From the +repository root: + +``` +python PC/layout --help +``` + +A useful invocation names an output directory and a preset. The build +directory is inferred from the running interpreter (`-b` overrides it), but a +`--preset-` (or explicit `--include-` options) is required; +otherwise the result is a bare, minimal layout that is rarely useful. + +``` +python PC/layout --copy dist --preset-default +``` + +### Output options + +The script produces one or both of the following outputs. At least one is +required for the run to do anything useful. + +* `--copy ` copies the layout into a directory. +* `--zip ` writes the layout into a ZIP file. + +Additional output-related options: + +* `--catalog ` writes a `.cdf` catalog definition for the non-binary + files, used later to produce a signed catalog. Compilation and signing are + separate steps. +* `--log ` writes all operations to a log file. +* `-t`, `--temp ` sets the temporary working directory used for generated + files (ZIP library, `._pth`, extracted pip, generated JSON). When omitted, a + temporary directory is created automatically. If `--copy` targets a Dev + Drive, an adjacent temp directory on the same drive is used for speed. +* `-v` increases verbosity. Repeat for more detail. + +### Layout options + +Optional components are selected with `--include-` flags. Presets group +these into the configurations we ship (see [Layouts](#layouts)). For a quick +throwaway layout, `-a`/`--include-all` turns on every option (except those +noted below as not affected by `--include-all`); it is intended for debugging +rather than for producing a real distribution, since it mixes components that +are never shipped together. The main component flags are: + +* `--include-stable` the stable ABI DLL (`python3.dll`). +* `--include-pip` pip, extracted from the bundled wheels in + `Lib/ensurepip/_bundled`. +* `--include-pip-user` a `pip.ini` defaulting to `--user` installs. +* `--include-tcltk` Tcl, Tk and tkinter. +* `--include-idle` IDLE. Implies `--include-tcltk`. +* `--include-tests` the test suite. +* `--include-tools` scripts from `Tools`. +* `--include-venv` venv and ensurepip, plus the venv launcher executables. +* `--include-dev` headers and `.lib` files. +* `--include-symbols` `.pdb` symbol files. +* `--include-underpth` a `python._pth` file. Not affected by + `--include-all`. +* `--include-launchers` extra launcher executables (used with + `--include-appxmanifest`). +* `--include-appxmanifest` an APPX/MSIX manifest. +* `--include-props` a `python.props` MSBuild file. +* `--include-nuspec` a `python.nuspec` NuGet spec. +* `--include-chm` the CHM documentation. +* `--include-html-doc` the HTML documentation. +* `--include-freethreaded` free-threaded binaries. Not affected by + `--include-all`. +* `--include-alias`, `--include-alias3`, `--include-alias3x` aliased + entry-point executables (`python.exe`, `python3.exe`, `python3.x.exe` and + their `w` variants). +* `--include-install-json`, `--include-install-embed-json`, + `--include-install-test-json` a PyManager `__install__.json` for the + respective distribution. +* `--include-builddetails-json` a [PEP 739](https://peps.python.org/pep-0739/) + `build-details.json`. + +Layout behavior flags: + +* `-d`, `--debug` lays out the debug build (files with the `_d` suffix). The + debug binaries must already have been built (for example with + `PCbuild/build.bat -d`); the script never builds them. +* `-p`, `--precompile` includes `.pyc` files (at optimization levels 0, 1 and + 2) instead of, or in addition to, `.py` files. The bytecode is compiled + during layout, in-process, using the `py_compile` module of the interpreter + running the script. It does not launch the laid-out runtime and does not check + its version, so it assumes the running interpreter matches the target version; + compiling with a mismatched version produces `.pyc` files the target cannot + use. +* `-z`, `--zip-lib` puts the standard library into `python.zip` rather than + a `Lib` directory. +* `--flat-dlls` places extension modules and DLLs next to the executables + rather than in a `DLLs` directory. +* `--include-cat ` includes an already-built `.cat` catalog file. This + only copies the named file into the layout; it does not build or sign the + catalog and requires no external tooling. Producing the `.cat` from a `.cdf` + (see `--catalog`) is a separate step. + +### Source options + +These options tell the script where to read from and what it is laying out. + +* `-s`, `--source ` the repository root. Defaults to the repository + containing the script. +* `-b`, `--build ` the build directory containing the compiled binaries. + Defaults to the directory containing the running interpreter. +* `--arch ` the target architecture. When omitted, it + is inferred by reading the PE header of a binary in the build directory. +* `--doc-build ` the documentation build directory. Defaults to + `/Doc/build`. + +The following environment variables are read when set: + +* `PYTHON_HEXVERSION` / `PYTHONINCLUDE` override version detection when the + target version cannot be inferred by reading `Include/patchlevel.h` from the + source tree. Set one of these when laying out a version other than the one + running the script (see below). +* `TCL_LIBRARY` locates the Tcl library when `--include-tcltk` is set. If + unset, the script falls back to `TCL_LIBRARY.env` in the build directory. +* `PYTHON_NUSPEC_VERSION`, `PYTHON_PROPS_PLATFORM` fill in the generated + `python.nuspec` and `python.props` files. When unset, the version falls back + to the detected version number and the platform falls back to a value derived + from the target architecture. +* `APPX_DATA_PUBLISHER`, `APPX_DATA_WINVER`, `APPX_DATA_SHA256` fill in the + generated APPX manifest. When unset, they fall back to defaults: a placeholder + publisher certificate name, a `MaxVersionTested` of `10.0.22000.0`, and no + SCCD hash. These defaults are fine for local use but are not suitable for a + signed, Store-ready package. + +## Layouts + +This section lists the common presets, which reflect our supported +configurations. Each is selected with `--preset-` and expands to a fixed +set of `--include-` options. They should help you understand which to use +for your scenario, and they are useful for figuring out where to put a new file +that you've just added to CPython. + +A preset can be combined with additional `--include-` options to add +components on top of it; the options are cumulative. + +### Development Kit (`--preset-default`) + +``` +python PC/layout --copy dist --preset-default +``` + +The development kit layout. This is the closest equivalent to a full install +and contains the interpreter, the standard library in `Lib`, extension modules +in `DLLs`, headers and import libraries (`--include-dev`), symbols, pip, tcltk, +IDLE, venv, the test suite, HTML docs, the stable ABI DLL, aliases and a +`build-details.json`. + +### Python install manager (`--preset-pymanager`, `--preset-pymanager-test`) + +Layouts for the [Python install manager](https://github.com/python/pymanager). +This is now the primary way upstream CPython is distributed on Windows. Both +resemble the development kit but add a PyManager `__install__.json`. + +`pymanager-test` additionally includes the test suite and symbols; +`--preset-pymanager-test` is what produces the `py install PythonTest\` +packages. + +### Embeddable package (`--preset-embed`) + +``` +python PC/layout --zip embed.zip --preset-embed +``` + +The embeddable package: a minimal, self-contained runtime intended to be +bundled inside another application. The standard library is placed in a ZIP +(`--zip-lib`), DLLs are flattened next to the executables (`--flat-dlls`), the +library is precompiled, and a `._pth` file (`--underpth`) is included to fix the +search path and isolate the runtime from user site directories. It omits pip, +tcltk, IDLE, the tests and development files. + +`--preset-embed --include-install-embed-json` is what produces the +`py install PythonEmbed\` packages. + +### NuGet package (`--preset-nuget`) + +The NuGet package layout. Includes development files, pip, the stable ABI, +venv, aliases, a `build-details.json`, and the `python.props` and +`python.nuspec` files that describe the package to MSBuild and NuGet. + +### APPX package (`--preset-appx`) + +The APPX/MSIX package layout for the Windows Store distribution. Includes the +stable ABI, pip, tcltk, IDLE, venv, development files, launchers, aliases and an +APPX manifest. This is no longer used for upstream CPython releases. + +### Windows IoT Core (`--preset-iot`) + +A minimal layout for Windows IoT Core: aliases, the stable ABI and pip. This is +not used for upstream CPython releases. + +## Build source options + +The `-b` and `-s` options let you lay out a build that is separate from the +interpreter running the script, including a different Python version. + +* `-b`/`--build` points at the build tree with the compiled binaries. It does + not need to match the interpreter running the script. +* `-s`/`--source` points at the source tree that supplies `Lib`, `Include`, + `Tools` and version information. + +The target version is normally read from `Include/patchlevel.h` in the source +tree. When laying out a version that differs from the running interpreter and +the source tree is not the matching one, set `PYTHON_HEXVERSION` (a hex version +such as `0x030f00a0`) or `PYTHONINCLUDE` (a directory containing +`patchlevel.h`) so the correct DLL names, suffixes and version numbers are used. +The script validates the inferred version against `patchlevel.h` and stops with +an error if they disagree. + +## Tool structure + +The script is a package under `PC/layout`. `main.py` drives argument parsing, +builds the file list (`get_layout`), generates derived files +(`generate_source_files`) and copies or zips the result (`copy_files`). Support +modules live in `PC/layout/support`: + +* `options.py` defines the `OPTIONS` and `PRESETS` tables and generates the + `--include-*` and `--preset-*` command-line arguments. Add new options and + presets here. +* `constants.py` derives version numbers, DLL names and related constants from + `patchlevel.h` or the version environment variables. +* `filesets.py` provides the file-matching helpers (`FileStemSet`, + `FileNameSet`, `FileSuffixSet`) and the `rglob` globbing helper used + throughout `main.py`. +* `arch.py` infers the target architecture from a binary's PE header. +* `logging.py` configures logging and tracks whether errors occurred. +* `pip.py` extracts pip from the bundled wheels and lists the pip files. +* `catalog.py` generates the `.cdf`/`.cat` catalog definitions for signing. +* `props.py` generates `python.props` (NuGet/MSBuild). +* `nuspec.py` generates `python.nuspec` (NuGet). +* `appxmanifest.py` generates APPX/MSIX manifests. +* `pymanager.py` generates the PyManager `__install__.json`. +* `builddetails.py` generates the PEP 739 `build-details.json`. + +### Classifying new files + +`main.py` collects files by globbing shared directories -- the build output +directory (`-b`) for binaries and the source `Lib`, `Include` and `Tools` +directories -- and then filters them. A new file added to any of these is +usually picked up with no change here: build extension modules (`*.pyd`) land in +`DLLs` (or alongside the executables under `--flat-dlls`), other build DLLs land +next to them, and files under `Lib` are mirrored into the layout's `Lib`. + +Changes are only needed when a new file belongs to an optional component, so it +must be routed to the right `--include-` option rather than always +copied. The routing is driven by a set of file-matching tables near the top of +`main.py` (built from the `FileStemSet`, `FileNameSet` and `FileSuffixSet` +helpers in `support/filesets.py`). To classify a new file, add its name or +pattern to the matching table. + +Tables that gate files on an optional component (the file is only included when +the corresponding option is set): + +* `TEST_PYDS_ONLY`, `TEST_DLLS_ONLY`, `TEST_DIRS_ONLY` -- test-only extension + modules, DLLs and `Lib` directories; gated on `--include-tests`. Extension + module names starting with `_test` are already matched; add any other + test-only build module here (see also the note in `PCbuild/readme.txt`). +* `TCLTK_PYDS_ONLY`, `TCLTK_DLLS_ONLY`, `TCLTK_DIRS_ONLY`, `TCLTK_FILES_ONLY` -- + Tcl/Tk/tkinter extension modules (`_tkinter`), DLLs (`tcl*`, `tk*`, `zlib1`), + `Lib` directories (`tkinter`, `turtledemo`) and files (`turtle.py`); gated on + `--include-tcltk`. +* `IDLE_DIRS_ONLY` -- IDLE's `Lib` directory (`idlelib`); gated on + `--include-idle`. +* `VENV_DIRS_ONLY` -- `venv` and `ensurepip` `Lib` directories; gated on + `--include-venv`. + +Tables that exclude files outright: + +* `EXCLUDE_FROM_DLLS` -- build DLLs that are handled elsewhere and must not be + copied by the generic DLL glob (`python*`, `pyshellext`, `vcruntime*`). +* `EXCLUDE_FROM_LIB` -- never copied into `Lib` (`*.pyc`, `__pycache__`, + `*.pickle`). +* `EXCLUDE_FROM_COMPILE` -- `Lib` files that must not be precompiled + (`badsyntax_*`, `bad_*`). +* `EXCLUDE_FROM_CATALOG` -- suffixes omitted from the signing catalog because + they are signed separately (`.exe`, `.pyd`, `.dll`). + +Special cases in the debug and binary handling: + +* `REQUIRED_DLLS` (`libcrypto*`, `libssl*`, `libffi*`) -- always copied from the + build directory even for a release layout. Most build DLLs are filtered by + their `_d` suffix to match the debug or release build being laid out; these + dependencies do not follow that naming and would otherwise be dropped, so they + are matched here to force inclusion. Add a new external dependency DLL here if + it does not use the `_d` debug-suffix convention. + +When deciding where a new file goes, match it to the component it belongs to and +add it to the corresponding table. If it belongs in every layout and follows the +normal conventions, no change is needed. + + +## Contributing guidelines + +Contributions are welcome. The script supports a broad range of scenarios, and +extending it for a new one is encouraged. Because the same code produces the +official releases across every supported version and architecture, additions +have to respect a few constraints so that existing configurations keep working. + +The script runs in an unusual context, and new code must hold to the following +assumptions: + +* Do not assume the Python being laid out can be launched. The script must run + correctly using only the interpreter running it, which may differ from the + target. +* Do not assume the layout version matches the version running the script. + Derive version-dependent behavior from the detected version rather than from + `sys.version` of the running interpreter. (Precompilation with `--precompile` + is the one deliberate exception, and it assumes a matching interpreter.) +* The script may be used to lay out an older version, so behavior changes have + to be preserved, either behind an option or gated on a version check, rather + than replaced outright. +* The script never builds anything. Everything it emits must already exist in + the build or source tree. + +When adding features, keep the surface area aligned with upstream: + +* New `--include-` options for further customization are fine. +* Do not add presets beyond those used by upstream. Presets describe the + configurations we ship, so a new one implies a new supported release + artifact. +* Route new files through the classification tables (see [Classifying new + files](#classifying-new-files)) rather than adding one-off special cases. diff --git a/PC/layout/support/appxmanifest.py b/PC/layout/support/appxmanifest.py index 53977beb8af8346..ba7f1335c7348d5 100644 --- a/PC/layout/support/appxmanifest.py +++ b/PC/layout/support/appxmanifest.py @@ -151,6 +151,8 @@ """ +# This file is no longer included in our repo, but we keep the logic here for +# building with older releases. We always .is_file() before using it. SCCD_FILENAME = "PC/classicAppCompat.sccd" SPECIAL_LOOKUP = object() diff --git a/PC/layout/support/pymanager.py b/PC/layout/support/pymanager.py index f6316e0295c74af..b3975ee9e914e37 100644 --- a/PC/layout/support/pymanager.py +++ b/PC/layout/support/pymanager.py @@ -41,6 +41,8 @@ def calculate_install_json(ns, *, for_embed=False, for_test=False): ALIAS_PREFIX = "python" ALIAS_WPREFIX = "pythonw" FILE_PREFIX = "python-" + # Notice that FILE_SUFFIX may have more bits added to it below, and these + # are sensitive to ordering (for compatibility), so don't change the order! FILE_SUFFIX = f"-{ns.arch}" DISPLAY_TAGS = [{ "win32": "32-bit", @@ -52,7 +54,7 @@ def calculate_install_json(ns, *, for_embed=False, for_test=False): # Packages with the test suite come under a different Company COMPANY = "PythonTest" DISPLAY_TAGS.append("with tests") - FILE_SUFFIX = f"-test-{ns.arch}" + FILE_SUFFIX = f"-test{FILE_SUFFIX}" if for_embed: # Embeddable distro comes under a different Company COMPANY = "PythonEmbed" @@ -62,15 +64,15 @@ def calculate_install_json(ns, *, for_embed=False, for_test=False): DISPLAY_TAGS.append("embeddable") # Deliberately name the file differently from the existing distro # so we can republish old versions without replacing files. - FILE_SUFFIX = f"-embeddable-{ns.arch}" + FILE_SUFFIX = f"-embeddable{FILE_SUFFIX}" if ns.include_freethreaded: # Free-threaded distro comes with a tag suffix TAG_SUFFIX = "t" if not ns.include_alias: TARGET = f"python{VER_MAJOR}.{VER_MINOR}t.exe" - TARGETW = f"pythonw{VER_MAJOR}.{VER_MINOR}t.exe" + TARGETW = f"pythonw{VER_MAJOR}.{VER_MINOR}t.exe" if TARGETW else None DISPLAY_TAGS.append("free-threaded") - FILE_SUFFIX = f"t-{ns.arch}" + FILE_SUFFIX = f"t{FILE_SUFFIX}" FULL_TAG = f"{VER_MAJOR}.{VER_MINOR}.{VER_MICRO}{VER_SUFFIX}{TAG_SUFFIX}" FULL_ARCH_TAG = f"{FULL_TAG}{TAG_ARCH}" diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c index 8826e7e85a7f5ab..868650dd31d9a1b 100644 --- a/PC/msvcrtmodule.c +++ b/PC/msvcrtmodule.c @@ -34,19 +34,6 @@ #endif /*[python input] -class HANDLE_converter(CConverter): - type = 'void *' - format_unit = '"_Py_PARSE_UINTPTR"' - - def parse_arg(self, argname, displayname, *, limited_capi): - return self.format_code(""" - {paramname} = PyLong_AsVoidPtr({argname}); - if (!{paramname} && PyErr_Occurred()) {{{{ - goto exit; - }}}} - """, - argname=argname) - class HANDLE_return_converter(CReturnConverter): type = 'void *' @@ -65,7 +52,7 @@ class byte_char_return_converter(CReturnConverter): data.declarations.append('char s[1];') data.return_value = 's[0]' data.return_conversion.append( - 'return_value = PyBytes_FromStringAndSize(s, 1);\n') + f'{data.parser_retval} = PyBytes_FromStringAndSize(s, 1);\n') class wchar_t_return_converter(CReturnConverter): type = 'wchar_t' @@ -73,9 +60,10 @@ class wchar_t_return_converter(CReturnConverter): def render(self, function, data): self.declare(data) data.return_conversion.append( - 'return_value = PyUnicode_FromOrdinal(_return_value);\n') + f'{data.parser_retval} = ' + f'PyUnicode_FromOrdinal({data.converter_retval});\n') [python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=ff031be44ab3250d]*/ +/*[python end generated code: output=da39a3ee5e6b4b0d input=f61ae699a69482ba]*/ /*[clinic input] module msvcrt @@ -184,8 +172,8 @@ to os.fdopen() to create a file object. [clinic start generated code]*/ static long -msvcrt_open_osfhandle_impl(PyObject *module, void *handle, int flags) -/*[clinic end generated code: output=b2fb97c4b515e4e6 input=d5db190a307cf4bb]*/ +msvcrt_open_osfhandle_impl(PyObject *module, HANDLE handle, int flags) +/*[clinic end generated code: output=646759b9fd02ca7b input=d5db190a307cf4bb]*/ { if (PySys_Audit("msvcrt.open_osfhandle", "Ki", handle, flags) < 0) { return -1; @@ -317,6 +305,22 @@ msvcrt_getwche_impl(PyObject *module) #endif /* MS_WINDOWS_DESKTOP */ +/* Raise an OSError for a failed _putch()/_putwch() call. + + These functions fail, for example, when the process has no console + attached, but the CRT reports the failure without setting errno (and + without setting the Windows last error either), so fall back to a + generic error message in that case. */ +static PyObject * +set_console_write_error(void) +{ + if (errno != 0) { + return PyErr_SetFromErrno(PyExc_OSError); + } + PyErr_SetString(PyExc_OSError, "write to console failed"); + return NULL; +} + /*[clinic input] msvcrt.putch @@ -330,9 +334,16 @@ static PyObject * msvcrt_putch_impl(PyObject *module, char char_value) /*[clinic end generated code: output=92ec9b81012d8f60 input=ec078dd10cb054d6]*/ { + int res; + _Py_BEGIN_SUPPRESS_IPH - _putch(char_value); + errno = 0; + res = _putch(char_value); _Py_END_SUPPRESS_IPH + + if (res == EOF) { + return set_console_write_error(); + } Py_RETURN_NONE; } @@ -351,11 +362,17 @@ static PyObject * msvcrt_putwch_impl(PyObject *module, int unicode_char) /*[clinic end generated code: output=a3bd1a8951d28eee input=996ccd0bbcbac4c3]*/ { + wint_t res; + _Py_BEGIN_SUPPRESS_IPH - _putwch(unicode_char); + errno = 0; + res = _putwch(unicode_char); _Py_END_SUPPRESS_IPH - Py_RETURN_NONE; + if (res == WEOF) { + return set_console_write_error(); + } + Py_RETURN_NONE; } #endif /* MS_WINDOWS_DESKTOP */ @@ -430,8 +447,8 @@ Only available on Debug builds. [clinic start generated code]*/ static void * -msvcrt_CrtSetReportFile_impl(PyObject *module, int type, void *file) -/*[clinic end generated code: output=9393e8c77088bbe9 input=290809b5f19e65b9]*/ +msvcrt_CrtSetReportFile_impl(PyObject *module, int type, HANDLE file) +/*[clinic end generated code: output=55858e446d583c5f input=290809b5f19e65b9]*/ { HANDLE res; diff --git a/PC/pyconfig.h b/PC/pyconfig.h index 2381ed3772b109e..9de3786a0c769b4 100644 --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -50,9 +50,7 @@ WIN32 is still required for the locale module. #define HAVE_IO_H #define HAVE_SYS_UTIME_H -#define HAVE_TEMPNAM #define HAVE_TMPFILE -#define HAVE_TMPNAM #define HAVE_CLOCK #define HAVE_STRERROR @@ -100,17 +98,15 @@ WIN32 is still required for the locale module. #endif /* Define to 1 when compiling for experimental free-threaded builds */ -#ifdef Py_GIL_DISABLED +#if defined(Py_GIL_DISABLED) && Py_GIL_DISABLED == 0 /* We undefine if it was set to zero because all later checks are #ifdef. * Note that non-Windows builds do not do this, and so every effort should * be made to avoid defining the variable at all when not desired. However, * sysconfig.get_config_var always returns a 1 or a 0, and so it seems likely * that a build backend will define it with the value. */ -#if Py_GIL_DISABLED == 0 #undef Py_GIL_DISABLED #endif -#endif /* Compiler specific defines */ @@ -148,17 +144,24 @@ WIN32 is still required for the locale module. #define MS_WIN64 #endif +#ifdef __clang__ +#define _Py_CLANG_COMPILER(platform) ( \ + "[Clang " _Py_STRINGIZE(__clang_major__) "." _Py_STRINGIZE(__clang_minor__) \ + "." _Py_STRINGIZE(__clang_patchlevel__) " " platform \ + " with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") +#endif + /* set the _Py_COMPILER and support tier * * win_amd64 MSVC (x86_64-pc-windows-msvc): 1 * win32 MSVC (i686-pc-windows-msvc): 1 - * win_arm64 MSVC (aarch64-pc-windows-msvc): 3 - * other archs and ICC: 0 + * win_arm64 MSVC (aarch64-pc-windows-msvc): 2 + * other archs and clang-cl/ICC: 0 */ #ifdef MS_WIN64 #if defined(_M_X64) || defined(_M_AMD64) #if defined(__clang__) -#define _Py_COMPILER ("[Clang " __clang_version__ "] 64 bit (AMD64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") +#define _Py_COMPILER _Py_CLANG_COMPILER("64 bit (AMD64)") #define PY_SUPPORT_TIER 0 #elif defined(__INTEL_COMPILER) #define _Py_COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") @@ -169,8 +172,13 @@ WIN32 is still required for the locale module. #endif /* __clang__ */ #define PYD_PLATFORM_TAG "win_amd64" #elif defined(_M_ARM64) +#if defined(__clang__) +#define _Py_COMPILER _Py_CLANG_COMPILER("64 bit (ARM64)") +#define PY_SUPPORT_TIER 0 +#else #define _Py_COMPILER _Py_PASTE_VERSION("64 bit (ARM64)") -#define PY_SUPPORT_TIER 3 +#define PY_SUPPORT_TIER 2 +#endif /* __clang__ */ #define PYD_PLATFORM_TAG "win_arm64" #else #define _Py_COMPILER _Py_PASTE_VERSION("64 bit (Unknown)") @@ -220,7 +228,7 @@ typedef _W64 int Py_ssize_t; #if defined(MS_WIN32) && !defined(MS_WIN64) #if defined(_M_IX86) #if defined(__clang__) -#define _Py_COMPILER ("[Clang " __clang_version__ "] 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") +#define _Py_COMPILER _Py_CLANG_COMPILER("32 bit (Intel)") #define PY_SUPPORT_TIER 0 #elif defined(__INTEL_COMPILER) #define _Py_COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") @@ -242,11 +250,7 @@ typedef _W64 int Py_ssize_t; typedef int pid_t; -/* define some ANSI types that are not defined in earlier Win headers */ -#if _MSC_VER >= 1200 -/* This file only exists in VC 6.0 or higher */ #include -#endif #endif /* _MSC_VER */ @@ -317,39 +321,33 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ /* All windows compilers that use this header support __declspec */ #define HAVE_DECLSPEC_DLL -/* For an MSVC DLL, we can nominate the .lib files used by extensions */ -#ifdef MS_COREDLL -# if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN) - /* not building the core - must be an ext */ -# if defined(_MSC_VER) && !defined(Py_NO_LINK_LIB) - /* So MSVC users need not specify the .lib - file in their Makefile */ - /* Define Py_NO_LINK_LIB to build extension disabling pragma - based auto-linking. - This is relevant when using build-system generator (e.g CMake) where - the linking is explicitly handled */ -# if defined(Py_GIL_DISABLED) -# if defined(Py_DEBUG) -# pragma comment(lib,"python316t_d.lib") -# elif defined(Py_LIMITED_API) || defined(Py_TARGET_ABI3T) -# pragma comment(lib,"python3t.lib") -# else -# pragma comment(lib,"python316t.lib") -# endif /* Py_DEBUG */ -# else /* Py_GIL_DISABLED */ -# if defined(Py_DEBUG) -# pragma comment(lib,"python316_d.lib") -# elif defined(Py_TARGET_ABI3T) -# pragma comment(lib,"python3t.lib") -# elif defined(Py_LIMITED_API) -# pragma comment(lib,"python3.lib") -# else -# pragma comment(lib,"python316.lib") -# endif /* Py_DEBUG */ -# endif /* Py_GIL_DISABLED */ -# endif /* _MSC_VER && !Py_NO_LINK_LIB */ -# endif /* Py_BUILD_CORE */ -#endif /* MS_COREDLL */ +/* Automatic linking of extension python3x.lib files for MSVC DLLs. + This lets MSVC users build extensions without manually specifying .lib files. + Define Py_NO_LINK_LIB to disable this behavior. */ +#if !defined(Py_NO_LINK_LIB) \ + && defined(_MSC_VER) && defined(Py_ENABLE_SHARED) \ + && !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN) + /* not building the core - must be an ext */ +# if defined(Py_GIL_DISABLED) +# if defined(Py_DEBUG) +# pragma comment(lib,"python316t_d.lib") +# elif defined(Py_LIMITED_API) || defined(Py_TARGET_ABI3T) +# pragma comment(lib,"python3t.lib") +# else +# pragma comment(lib,"python316t.lib") +# endif /* Py_DEBUG */ +# else +# if defined(Py_DEBUG) +# pragma comment(lib,"python316_d.lib") +# elif defined(Py_TARGET_ABI3T) +# pragma comment(lib,"python3t.lib") +# elif defined(Py_LIMITED_API) +# pragma comment(lib,"python3.lib") +# else +# pragma comment(lib,"python316.lib") +# endif /* Py_DEBUG */ +# endif /* Py_GIL_DISABLED */ +#endif #ifdef MS_WIN64 /* maintain "win32" sys.platform for backward compatibility of Python code, @@ -379,8 +377,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ # define SIZEOF_HKEY 4 # define SIZEOF_SIZE_T 4 # define ALIGNOF_SIZE_T 4 - /* MS VS2005 changes time_t to a 64-bit type on all platforms */ -# if defined(_MSC_VER) && _MSC_VER >= 1400 +# if defined(_MSC_VER) # define SIZEOF_TIME_T 8 # else # define SIZEOF_TIME_T 4 @@ -398,18 +395,9 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ #define SIZEOF_DOUBLE 8 #define SIZEOF_FLOAT 4 -/* VC 7.1 has them and VC 6.0 does not. VC 6.0 has a version number of 1200. - Microsoft eMbedded Visual C++ 4.0 has a version number of 1201 and doesn't - define these. - If some compiler does not provide them, modify the #if appropriately. */ #if defined(_MSC_VER) -#if _MSC_VER > 1300 #define HAVE_UINTPTR_T 1 #define HAVE_INTPTR_T 1 -#else -/* VC6, VS 2002 and eVC4 don't support the C99 LL suffix for 64-bit integer literals */ -#define Py_LL(x) x##I64 -#endif /* _MSC_VER > 1300 */ #endif /* _MSC_VER */ #endif @@ -516,11 +504,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ /* Define if you have the putenv function. */ #define HAVE_PUTENV -/* Define if your compiler supports function prototypes */ -#define HAVE_PROTOTYPES - -/* Define if you can safely include both and - (which you can't on SCO ODT 3.0). */ +/* Define if you can safely include both and */ /* #undef SYS_SELECT_WITH_SYS_TIME */ /* Define if you want build the _decimal module using a coroutine-local rather @@ -548,9 +532,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ /* Define when any dynamic module loading is enabled */ #define HAVE_DYNAMIC_LOADING -/* Define if you have ftime. */ -#define HAVE_FTIME - /* Define if you have getpeername. */ #define HAVE_GETPEERNAME @@ -563,9 +544,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ /* Define if you have gettimeofday. */ /* #undef HAVE_GETTIMEOFDAY */ -/* Define if you have getwd. */ -/* #undef HAVE_GETWD */ - /* Define if you have lstat. */ /* #undef HAVE_LSTAT */ @@ -618,7 +596,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ /* #undef HAVE_WAITPID */ /* Define to 1 if you have the `wcsftime' function. */ -#if defined(_MSC_VER) && _MSC_VER >= 1310 +#if defined(_MSC_VER) #define HAVE_WCSFTIME 1 #endif @@ -649,9 +627,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ /* Define if you have the header file. */ #define HAVE_STDDEF_H 1 -/* Define if you have the header file. */ -/* #undef HAVE_SYS_AUDIOIO_H */ - /* Define if you have the header file. */ /* #define HAVE_SYS_PARAM_H 1 */ diff --git a/PC/pylauncher.rc b/PC/pylauncher.rc deleted file mode 100644 index 11862643aa69893..000000000000000 --- a/PC/pylauncher.rc +++ /dev/null @@ -1,67 +0,0 @@ -#include - -#include "python_ver_rc.h" - -#ifndef RT_MANIFEST -// bpo-45220: Cannot reliably #include RT_MANIFEST from -// anywhere, so we hardcode it -#define RT_MANIFEST 24 -#endif -// Include the manifest file that indicates we support all -// current versions of Windows. -1 RT_MANIFEST "python.manifest" - -#if defined(PY_ICON) -1 ICON DISCARDABLE "icons\python.ico" -#elif defined(PYW_ICON) -1 ICON DISCARDABLE "icons\pythonw.ico" -#else -1 ICON DISCARDABLE "icons\launcher.ico" -2 ICON DISCARDABLE "icons\py.ico" -3 ICON DISCARDABLE "icons\pyc.ico" -4 ICON DISCARDABLE "icons\pyd.ico" -5 ICON DISCARDABLE "icons\python.ico" -6 ICON DISCARDABLE "icons\pythonw.ico" -7 ICON DISCARDABLE "icons\setup.ico" -#endif - -1 USAGE "launcher-usage.txt" - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION PYVERSION64 - PRODUCTVERSION PYVERSION64 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_APP - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName", PYTHON_COMPANY "\0" - VALUE "FileDescription", "Python\0" - VALUE "FileVersion", PYTHON_VERSION - VALUE "InternalName", "Python Launcher\0" - VALUE "LegalCopyright", PYTHON_COPYRIGHT "\0" - VALUE "OriginalFilename", "py" PYTHON_DEBUG_EXT ".exe\0" - VALUE "ProductName", "Python\0" - VALUE "ProductVersion", PYTHON_VERSION - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END \ No newline at end of file diff --git a/PC/pyshellext.cpp b/PC/pyshellext.cpp deleted file mode 100644 index d16de0b717151e5..000000000000000 --- a/PC/pyshellext.cpp +++ /dev/null @@ -1,603 +0,0 @@ -// Support back to Vista -#define _WIN32_WINNT _WIN32_WINNT_VISTA -#include - -// Use WRL to define a classic COM class -#define __WRL_CLASSIC_COM__ -#include - -#include -#include -#include -#include -#include - -#define DDWM_UPDATEWINDOW (WM_USER+3) - -static HINSTANCE hModule; -static CLIPFORMAT cfDropDescription; -static CLIPFORMAT cfDragWindow; - -#define CLASS_GUID "{BEA218D2-6950-497B-9434-61683EC065FE}" -static const LPCWSTR CLASS_SUBKEY = L"Software\\Classes\\CLSID\\" CLASS_GUID; -static const LPCWSTR DRAG_MESSAGE = L"Open with %1"; - -using namespace Microsoft::WRL; - -HRESULT FilenameListCchLengthA(LPCSTR pszSource, size_t cchMax, size_t *pcchLength, size_t *pcchCount) { - HRESULT hr = S_OK; - size_t count = 0; - size_t length = 0; - - while (pszSource && pszSource[0]) { - size_t oneLength; - hr = StringCchLengthA(pszSource, cchMax - length, &oneLength); - if (FAILED(hr)) { - return hr; - } - count += 1; - length += oneLength + (strchr(pszSource, ' ') ? 3 : 1); - pszSource = &pszSource[oneLength + 1]; - } - - *pcchCount = count; - *pcchLength = length; - return hr; -} - -HRESULT FilenameListCchLengthW(LPCWSTR pszSource, size_t cchMax, size_t *pcchLength, size_t *pcchCount) { - HRESULT hr = S_OK; - size_t count = 0; - size_t length = 0; - - while (pszSource && pszSource[0]) { - size_t oneLength; - hr = StringCchLengthW(pszSource, cchMax - length, &oneLength); - if (FAILED(hr)) { - return hr; - } - count += 1; - length += oneLength + (wcschr(pszSource, ' ') ? 3 : 1); - pszSource = &pszSource[oneLength + 1]; - } - - *pcchCount = count; - *pcchLength = length; - return hr; -} - -HRESULT FilenameListCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, LPCSTR pszSource, LPCSTR pszSeparator) { - HRESULT hr = S_OK; - - while (pszSource[0]) { - STRSAFE_LPSTR newDest; - - hr = StringCchCopyExA(pszDest, cchDest, pszSource, &newDest, &cchDest, 0); - if (FAILED(hr)) { - return hr; - } - pszSource += (newDest - pszDest) + 1; - pszDest = PathQuoteSpacesA(pszDest) ? newDest + 2 : newDest; - - if (pszSource[0]) { - hr = StringCchCopyExA(pszDest, cchDest, pszSeparator, &newDest, &cchDest, 0); - if (FAILED(hr)) { - return hr; - } - pszDest = newDest; - } - } - - return hr; -} - -HRESULT FilenameListCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, LPCWSTR pszSource, LPCWSTR pszSeparator) { - HRESULT hr = S_OK; - - while (pszSource[0]) { - STRSAFE_LPWSTR newDest; - - hr = StringCchCopyExW(pszDest, cchDest, pszSource, &newDest, &cchDest, 0); - if (FAILED(hr)) { - return hr; - } - pszSource += (newDest - pszDest) + 1; - pszDest = PathQuoteSpacesW(pszDest) ? newDest + 2 : newDest; - - if (pszSource[0]) { - hr = StringCchCopyExW(pszDest, cchDest, pszSeparator, &newDest, &cchDest, 0); - if (FAILED(hr)) { - return hr; - } - pszDest = newDest; - } - } - - return hr; -} - -class DECLSPEC_UUID(CLASS_GUID) PyShellExt : public RuntimeClass< - RuntimeClassFlags, - IDropTarget, - IPersistFile -> -{ - LPOLESTR target, target_dir; - DWORD target_mode; - - IDataObject *data_obj; - -public: - PyShellExt() : target(NULL), target_dir(NULL), target_mode(0), data_obj(NULL) { - OutputDebugString(L"PyShellExt::PyShellExt"); - } - - ~PyShellExt() { - if (target) { - CoTaskMemFree(target); - } - if (target_dir) { - CoTaskMemFree(target_dir); - } - if (data_obj) { - data_obj->Release(); - } - } - -private: - HRESULT UpdateDropDescription(IDataObject *pDataObj) { - STGMEDIUM medium; - FORMATETC fmt = { - cfDropDescription, - NULL, - DVASPECT_CONTENT, - -1, - TYMED_HGLOBAL - }; - - auto hr = pDataObj->GetData(&fmt, &medium); - if (FAILED(hr)) { - OutputDebugString(L"PyShellExt::UpdateDropDescription - failed to get DROPDESCRIPTION format"); - return hr; - } - if (!medium.hGlobal) { - OutputDebugString(L"PyShellExt::UpdateDropDescription - DROPDESCRIPTION format had NULL hGlobal"); - ReleaseStgMedium(&medium); - return E_FAIL; - } - auto dd = (DROPDESCRIPTION*)GlobalLock(medium.hGlobal); - if (!dd) { - OutputDebugString(L"PyShellExt::UpdateDropDescription - failed to lock DROPDESCRIPTION hGlobal"); - ReleaseStgMedium(&medium); - return E_FAIL; - } - StringCchCopy(dd->szMessage, sizeof(dd->szMessage) / sizeof(dd->szMessage[0]), DRAG_MESSAGE); - StringCchCopy(dd->szInsert, sizeof(dd->szInsert) / sizeof(dd->szInsert[0]), PathFindFileNameW(target)); - dd->type = DROPIMAGE_MOVE; - - GlobalUnlock(medium.hGlobal); - ReleaseStgMedium(&medium); - - return S_OK; - } - - HRESULT GetDragWindow(IDataObject *pDataObj, HWND *phWnd) { - HRESULT hr; - HWND *pMem; - STGMEDIUM medium; - FORMATETC fmt = { - cfDragWindow, - NULL, - DVASPECT_CONTENT, - -1, - TYMED_HGLOBAL - }; - - hr = pDataObj->GetData(&fmt, &medium); - if (FAILED(hr)) { - OutputDebugString(L"PyShellExt::GetDragWindow - failed to get DragWindow format"); - return hr; - } - if (!medium.hGlobal) { - OutputDebugString(L"PyShellExt::GetDragWindow - DragWindow format had NULL hGlobal"); - ReleaseStgMedium(&medium); - return E_FAIL; - } - - pMem = (HWND*)GlobalLock(medium.hGlobal); - if (!pMem) { - OutputDebugString(L"PyShellExt::GetDragWindow - failed to lock DragWindow hGlobal"); - ReleaseStgMedium(&medium); - return E_FAIL; - } - - *phWnd = *pMem; - - GlobalUnlock(medium.hGlobal); - ReleaseStgMedium(&medium); - - return S_OK; - } - - HRESULT GetArguments(IDataObject *pDataObj, LPCWSTR *pArguments) { - HRESULT hr; - DROPFILES *pdropfiles; - - STGMEDIUM medium; - FORMATETC fmt = { - CF_HDROP, - NULL, - DVASPECT_CONTENT, - -1, - TYMED_HGLOBAL - }; - - hr = pDataObj->GetData(&fmt, &medium); - if (FAILED(hr)) { - OutputDebugString(L"PyShellExt::GetArguments - failed to get CF_HDROP format"); - return hr; - } - if (!medium.hGlobal) { - OutputDebugString(L"PyShellExt::GetArguments - CF_HDROP format had NULL hGlobal"); - ReleaseStgMedium(&medium); - return E_FAIL; - } - - pdropfiles = (DROPFILES*)GlobalLock(medium.hGlobal); - if (!pdropfiles) { - OutputDebugString(L"PyShellExt::GetArguments - failed to lock CF_HDROP hGlobal"); - ReleaseStgMedium(&medium); - return E_FAIL; - } - - if (pdropfiles->fWide) { - LPCWSTR files = (LPCWSTR)((char*)pdropfiles + pdropfiles->pFiles); - size_t len, count; - hr = FilenameListCchLengthW(files, 32767, &len, &count); - if (SUCCEEDED(hr)) { - LPWSTR args = (LPWSTR)CoTaskMemAlloc(sizeof(WCHAR) * (len + 1)); - if (args) { - hr = FilenameListCchCopyW(args, 32767, files, L" "); - if (SUCCEEDED(hr)) { - *pArguments = args; - } else { - CoTaskMemFree(args); - } - } else { - hr = E_OUTOFMEMORY; - } - } - } else { - LPCSTR files = (LPCSTR)((char*)pdropfiles + pdropfiles->pFiles); - size_t len, count; - hr = FilenameListCchLengthA(files, 32767, &len, &count); - if (SUCCEEDED(hr)) { - LPSTR temp = (LPSTR)CoTaskMemAlloc(sizeof(CHAR) * (len + 1)); - if (temp) { - hr = FilenameListCchCopyA(temp, 32767, files, " "); - if (SUCCEEDED(hr)) { - int wlen = MultiByteToWideChar(CP_ACP, 0, temp, (int)len, NULL, 0); - if (wlen) { - LPWSTR args = (LPWSTR)CoTaskMemAlloc(sizeof(WCHAR) * (wlen + 1)); - if (MultiByteToWideChar(CP_ACP, 0, temp, (int)len, args, wlen + 1)) { - *pArguments = args; - } else { - OutputDebugString(L"PyShellExt::GetArguments - failed to convert multi-byte to wide-char path"); - CoTaskMemFree(args); - hr = E_FAIL; - } - } else { - OutputDebugString(L"PyShellExt::GetArguments - failed to get length of wide-char path"); - hr = E_FAIL; - } - } - CoTaskMemFree(temp); - } else { - hr = E_OUTOFMEMORY; - } - } - } - - GlobalUnlock(medium.hGlobal); - ReleaseStgMedium(&medium); - - return hr; - } - - HRESULT NotifyDragWindow(HWND hwnd) { - LRESULT res; - - if (!hwnd) { - return S_FALSE; - } - - res = SendMessage(hwnd, DDWM_UPDATEWINDOW, 0, NULL); - - if (res) { - OutputDebugString(L"PyShellExt::NotifyDragWindow - failed to post DDWM_UPDATEWINDOW"); - return E_FAIL; - } - - return S_OK; - } - -public: - // IDropTarget implementation - - STDMETHODIMP DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) { - HWND hwnd; - - OutputDebugString(L"PyShellExt::DragEnter"); - - pDataObj->AddRef(); - data_obj = pDataObj; - - *pdwEffect = DROPEFFECT_MOVE; - - if (FAILED(UpdateDropDescription(data_obj))) { - OutputDebugString(L"PyShellExt::DragEnter - failed to update drop description"); - } - if (FAILED(GetDragWindow(data_obj, &hwnd))) { - OutputDebugString(L"PyShellExt::DragEnter - failed to get drag window"); - } - if (FAILED(NotifyDragWindow(hwnd))) { - OutputDebugString(L"PyShellExt::DragEnter - failed to notify drag window"); - } - - return S_OK; - } - - STDMETHODIMP DragLeave() { - return S_OK; - } - - STDMETHODIMP DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) { - return S_OK; - } - - STDMETHODIMP Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) { - LPCWSTR args; - - OutputDebugString(L"PyShellExt::Drop"); - *pdwEffect = DROPEFFECT_NONE; - - if (pDataObj != data_obj) { - OutputDebugString(L"PyShellExt::Drop - unexpected data object"); - return E_FAIL; - } - - data_obj->Release(); - data_obj = NULL; - - if (SUCCEEDED(GetArguments(pDataObj, &args))) { - OutputDebugString(args); - ShellExecute(NULL, NULL, target, args, target_dir, SW_NORMAL); - - CoTaskMemFree((LPVOID)args); - } else { - OutputDebugString(L"PyShellExt::Drop - failed to get launch arguments"); - } - - return S_OK; - } - - // IPersistFile implementation - - STDMETHODIMP GetCurFile(LPOLESTR *ppszFileName) { - HRESULT hr; - size_t len; - - if (!ppszFileName) { - return E_POINTER; - } - - hr = StringCchLength(target, STRSAFE_MAX_CCH - 1, &len); - if (FAILED(hr)) { - return E_FAIL; - } - - *ppszFileName = (LPOLESTR)CoTaskMemAlloc(sizeof(WCHAR) * (len + 1)); - if (!*ppszFileName) { - return E_OUTOFMEMORY; - } - - hr = StringCchCopy(*ppszFileName, len + 1, target); - if (FAILED(hr)) { - CoTaskMemFree(*ppszFileName); - *ppszFileName = NULL; - return E_FAIL; - } - - return S_OK; - } - - STDMETHODIMP IsDirty() { - return S_FALSE; - } - - STDMETHODIMP Load(LPCOLESTR pszFileName, DWORD dwMode) { - HRESULT hr; - size_t len; - - OutputDebugString(L"PyShellExt::Load"); - OutputDebugString(pszFileName); - - hr = StringCchLength(pszFileName, STRSAFE_MAX_CCH - 1, &len); - if (FAILED(hr)) { - OutputDebugString(L"PyShellExt::Load - failed to get string length"); - return hr; - } - - if (target) { - CoTaskMemFree(target); - } - if (target_dir) { - CoTaskMemFree(target_dir); - } - - target = (LPOLESTR)CoTaskMemAlloc(sizeof(WCHAR) * (len + 1)); - if (!target) { - OutputDebugString(L"PyShellExt::Load - E_OUTOFMEMORY"); - return E_OUTOFMEMORY; - } - target_dir = (LPOLESTR)CoTaskMemAlloc(sizeof(WCHAR) * (len + 1)); - if (!target_dir) { - OutputDebugString(L"PyShellExt::Load - E_OUTOFMEMORY"); - return E_OUTOFMEMORY; - } - - hr = StringCchCopy(target, len + 1, pszFileName); - if (FAILED(hr)) { - OutputDebugString(L"PyShellExt::Load - failed to copy string"); - return hr; - } - - hr = StringCchCopy(target_dir, len + 1, pszFileName); - if (FAILED(hr)) { - OutputDebugString(L"PyShellExt::Load - failed to copy string"); - return hr; - } - if (!PathRemoveFileSpecW(target_dir)) { - OutputDebugStringW(L"PyShellExt::Load - failed to remove filespec from target"); - return E_FAIL; - } - - OutputDebugString(target); - target_mode = dwMode; - OutputDebugString(L"PyShellExt::Load - S_OK"); - return S_OK; - } - - STDMETHODIMP Save(LPCOLESTR pszFileName, BOOL fRemember) { - return E_NOTIMPL; - } - - STDMETHODIMP SaveCompleted(LPCOLESTR pszFileName) { - return E_NOTIMPL; - } - - STDMETHODIMP GetClassID(CLSID *pClassID) { - *pClassID = __uuidof(PyShellExt); - return S_OK; - } -}; - -CoCreatableClass(PyShellExt); - -STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, _COM_Outptr_ void** ppv) { - return Module::GetModule().GetClassObject(rclsid, riid, ppv); -} - -STDAPI DllCanUnloadNow() { - return Module::GetModule().Terminate() ? S_OK : S_FALSE; -} - -STDAPI DllRegisterServer() { - LONG res; - LPSECURITY_ATTRIBUTES psecattr = NULL; - HKEY key, ipsKey; - WCHAR modname[MAX_PATH]; - DWORD modname_len; - - OutputDebugString(L"PyShellExt::DllRegisterServer"); - if (!hModule) { - OutputDebugString(L"PyShellExt::DllRegisterServer - module handle was not set"); - return SELFREG_E_CLASS; - } - modname_len = GetModuleFileName(hModule, modname, MAX_PATH); - if (modname_len == 0 || - (modname_len == MAX_PATH && GetLastError() == ERROR_INSUFFICIENT_BUFFER)) { - OutputDebugString(L"PyShellExt::DllRegisterServer - failed to get module file name"); - return SELFREG_E_CLASS; - } - - DWORD disp; - res = RegCreateKeyEx(HKEY_LOCAL_MACHINE, CLASS_SUBKEY, 0, NULL, 0, - KEY_ALL_ACCESS, psecattr, &key, &disp); - if (res == ERROR_ACCESS_DENIED) { - OutputDebugString(L"PyShellExt::DllRegisterServer - failed to write per-machine registration. Attempting per-user instead."); - res = RegCreateKeyEx(HKEY_CURRENT_USER, CLASS_SUBKEY, 0, NULL, 0, - KEY_ALL_ACCESS, psecattr, &key, &disp); - } - if (res != ERROR_SUCCESS) { - OutputDebugString(L"PyShellExt::DllRegisterServer - failed to create class key"); - return SELFREG_E_CLASS; - } - - res = RegCreateKeyEx(key, L"InProcServer32", 0, NULL, 0, - KEY_ALL_ACCESS, psecattr, &ipsKey, NULL); - if (res != ERROR_SUCCESS) { - RegCloseKey(key); - OutputDebugString(L"PyShellExt::DllRegisterServer - failed to create InProcServer32 key"); - return SELFREG_E_CLASS; - } - - res = RegSetValueEx(ipsKey, NULL, 0, - REG_SZ, (LPBYTE)modname, modname_len * sizeof(modname[0])); - - if (res != ERROR_SUCCESS) { - RegCloseKey(ipsKey); - RegCloseKey(key); - OutputDebugString(L"PyShellExt::DllRegisterServer - failed to set server path"); - return SELFREG_E_CLASS; - } - - res = RegSetValueEx(ipsKey, L"ThreadingModel", 0, - REG_SZ, (LPBYTE)(L"Apartment"), sizeof(L"Apartment")); - - RegCloseKey(ipsKey); - RegCloseKey(key); - if (res != ERROR_SUCCESS) { - OutputDebugString(L"PyShellExt::DllRegisterServer - failed to set threading model"); - return SELFREG_E_CLASS; - } - - SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); - - OutputDebugString(L"PyShellExt::DllRegisterServer - S_OK"); - return S_OK; -} - -STDAPI DllUnregisterServer() { - LONG res_lm, res_cu; - - res_lm = RegDeleteTree(HKEY_LOCAL_MACHINE, CLASS_SUBKEY); - if (res_lm != ERROR_SUCCESS && res_lm != ERROR_FILE_NOT_FOUND) { - OutputDebugString(L"PyShellExt::DllUnregisterServer - failed to delete per-machine registration"); - return SELFREG_E_CLASS; - } - - res_cu = RegDeleteTree(HKEY_CURRENT_USER, CLASS_SUBKEY); - if (res_cu != ERROR_SUCCESS && res_cu != ERROR_FILE_NOT_FOUND) { - OutputDebugString(L"PyShellExt::DllUnregisterServer - failed to delete per-user registration"); - return SELFREG_E_CLASS; - } - - if (res_lm == ERROR_FILE_NOT_FOUND && res_cu == ERROR_FILE_NOT_FOUND) { - OutputDebugString(L"PyShellExt::DllUnregisterServer - extension was not registered"); - return SELFREG_E_CLASS; - } - - SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); - - OutputDebugString(L"PyShellExt::DllUnregisterServer - S_OK"); - return S_OK; -} - -STDAPI_(BOOL) DllMain(_In_opt_ HINSTANCE hinst, DWORD reason, _In_opt_ void*) { - if (reason == DLL_PROCESS_ATTACH) { - hModule = hinst; - - cfDropDescription = RegisterClipboardFormat(CFSTR_DROPDESCRIPTION); - if (!cfDropDescription) { - OutputDebugString(L"PyShellExt::DllMain - failed to get CFSTR_DROPDESCRIPTION format"); - } - cfDragWindow = RegisterClipboardFormat(L"DragWindow"); - if (!cfDragWindow) { - OutputDebugString(L"PyShellExt::DllMain - failed to get DragWindow format"); - } - - DisableThreadLibraryCalls(hinst); - } - return TRUE; -} diff --git a/PC/pyshellext.def b/PC/pyshellext.def deleted file mode 100644 index 288a9adf982f197..000000000000000 --- a/PC/pyshellext.def +++ /dev/null @@ -1,5 +0,0 @@ -EXPORTS - DllRegisterServer PRIVATE - DllUnregisterServer PRIVATE - DllGetClassObject PRIVATE - DllCanUnloadNow PRIVATE diff --git a/PC/pyshellext.rc b/PC/pyshellext.rc deleted file mode 100644 index af797ce95d5077e..000000000000000 --- a/PC/pyshellext.rc +++ /dev/null @@ -1,51 +0,0 @@ -#include - -#include "python_ver_rc.h" - -#ifndef RT_MANIFEST -// bpo-45220: Cannot reliably #include RT_MANIFEST from -// anywhere, so we hardcode it -#define RT_MANIFEST 24 -#endif - -// Include the manifest file that indicates we support all -// current versions of Windows. -1 RT_MANIFEST "python.manifest" - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION PYVERSION64 - PRODUCTVERSION PYVERSION64 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_APP - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName", PYTHON_COMPANY "\0" - VALUE "FileDescription", "Python\0" - VALUE "FileVersion", PYTHON_VERSION - VALUE "InternalName", "Python Launcher Shell Extension\0" - VALUE "LegalCopyright", PYTHON_COPYRIGHT "\0" - VALUE "OriginalFilename", "pyshellext" PYTHON_DEBUG_EXT ".dll\0" - VALUE "ProductName", "Python\0" - VALUE "ProductVersion", PYTHON_VERSION - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END \ No newline at end of file diff --git a/PC/python3dll.c b/PC/python3dll.c index e0be9d65a93cda6..412dd5ce66cbc30 100755 --- a/PC/python3dll.c +++ b/PC/python3dll.c @@ -67,6 +67,7 @@ EXPORT_FUNC(Py_GetProgramName) EXPORT_FUNC(Py_GetPythonHome) EXPORT_FUNC(Py_GetRecursionLimit) EXPORT_FUNC(Py_GetVersion) +EXPORT_FUNC(Py_HashBuffer) EXPORT_FUNC(Py_IncRef) EXPORT_FUNC(Py_Initialize) EXPORT_FUNC(Py_InitializeEx) @@ -826,6 +827,19 @@ EXPORT_FUNC(PyUnicodeTranslateError_GetStart) EXPORT_FUNC(PyUnicodeTranslateError_SetEnd) EXPORT_FUNC(PyUnicodeTranslateError_SetReason) EXPORT_FUNC(PyUnicodeTranslateError_SetStart) +EXPORT_FUNC(PyUnicodeWriter_Create) +EXPORT_FUNC(PyUnicodeWriter_DecodeUTF8Stateful) +EXPORT_FUNC(PyUnicodeWriter_Discard) +EXPORT_FUNC(PyUnicodeWriter_Finish) +EXPORT_FUNC(PyUnicodeWriter_Format) +EXPORT_FUNC(PyUnicodeWriter_WriteASCII) +EXPORT_FUNC(PyUnicodeWriter_WriteChar) +EXPORT_FUNC(PyUnicodeWriter_WriteRepr) +EXPORT_FUNC(PyUnicodeWriter_WriteStr) +EXPORT_FUNC(PyUnicodeWriter_WriteSubstring) +EXPORT_FUNC(PyUnicodeWriter_WriteUCS4) +EXPORT_FUNC(PyUnicodeWriter_WriteUTF8) +EXPORT_FUNC(PyUnicodeWriter_WriteWideChar) EXPORT_FUNC(PyVectorcall_Call) EXPORT_FUNC(PyVectorcall_NARGS) EXPORT_FUNC(PyWeakref_GetObject) diff --git a/PC/store_info.txt b/PC/store_info.txt deleted file mode 100644 index d150ba17cbe62dd..000000000000000 --- a/PC/store_info.txt +++ /dev/null @@ -1,156 +0,0 @@ -# Overview - -NOTE: This file requires more content. - -Since Python 3.7.2, releases have been made through the Microsoft Store -to allow easy installation on Windows 10.0.17763.0 and later. - -# Building - -To build the store package, the PC/layout script should be used. -Execute the directory with the build of Python to package, and pass -"-h" for full command-line options. - -To sideload test builds, you will need a local certificate. -Instructions are available at -https://docs.microsoft.com/windows/uwp/packaging/create-certificate-package-signing. - -After exporting your certificate, you will need the subject name and -SHA256 hash. The `certutil -dump ` command will display this -information. - -To build for sideloading, use these commands in PowerShell: - -``` -$env:APPX_DATA_PUBLISHER= -$env:APPX_DATA_SHA256= -$env:SigningCertificateFile= - -python PC/layout --copy --include-appxmanifest -Tools/msi/make_appx.ps1 python.msix -sign - -Add-AppxPackage python.msix -``` - -(Note that only the last command requires PowerShell, and the others -can be used from Command Prompt. You can also double-click to install -the final package.) - -To build for publishing to the Store, use these commands: - -``` -$env:APPX_DATA_PUBLISHER = $null -$env:APPX_DATA_SHA256 = $null - -python PC/layout --copy --preset-appxmanifest --precompile -Tools/msi/make_appx.ps1 python.msix -``` - -Note that this package cannot be installed locally. It may only be -added to a submission for the store. - - -# Submission Metadata - -This file contains the text that we use to fill out the store listing -for the Microsoft Store. It needs to be entered manually when creating -a new submission via the dashboard at -https://partner.microsoft.com/dashboard. - -We keep it here for convenience and to allow it to be updated via pull -requests. - -When submitting a new app, the HeadlessAppBypass waiver will be needed. -To request this, send an email to PartnerOps@microsoft.com with the app -ID (12 character token available from the dashboard). The waiver needs -to be applied *before* uploading the package (as of November 2019). - -Ensure that the new app is named "Python.3.X", where X is the minor -version of the release. If the name provided initially does not match -the name used when building the package, the upload will fail. The -display name shown to users can be set later. - -## Title - -Python 3.9 - -## Short Title - -Python - -## Description - -Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms. - -The Python interpreter and the extensive standard library are freely available in source or binary form for all major platforms from the Python web site, https://www.python.org/, and may be freely distributed. The same site also contains distributions of and pointers to many free third party Python modules, programs and tools, and additional documentation. - -The Python interpreter is easily extended with new functions and data types implemented in C or C++ (or other languages callable from C). Python is also suitable as an extension language for customizable applications. - -## ShortDescription - -The Python 3.9 interpreter and runtime. - -## Copyright Trademark Information - -(c) Python Software Foundation - -## Additional License Terms - -Visit https://docs.python.org/3.9/license.html for latest license terms. - -PSF LICENSE AGREEMENT FOR PYTHON 3.9 - -1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and - the Individual or Organization ("Licensee") accessing and otherwise using Python - 3.9 software in source or binary form and its associated documentation. - -2. Subject to the terms and conditions of this License Agreement, PSF hereby - grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, - analyze, test, perform and/or display publicly, prepare derivative works, - distribute, and otherwise use Python 3.9 alone or in any derivative - version, provided, however, that PSF's License Agreement and PSF's notice of - copyright, i.e., "Copyright © 2001 Python Software Foundation; All Rights - Reserved" are retained in Python 3.9 alone or in any derivative version - prepared by Licensee. - -3. In the event Licensee prepares a derivative work that is based on or - incorporates Python 3.9 or any part thereof, and wants to make the - derivative work available to others as provided herein, then Licensee hereby - agrees to include in any such work a brief summary of the changes made to Python - 3.9. - -4. PSF is making Python 3.9 available to Licensee on an "AS IS" basis. - PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF - EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR - WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE - USE OF PYTHON 3.9 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. - -5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 3.9 - FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF - MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 3.9, OR ANY DERIVATIVE - THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - -6. This License Agreement will automatically terminate upon a material breach of - its terms and conditions. - -7. Nothing in this License Agreement shall be deemed to create any relationship - of agency, partnership, or joint venture between PSF and Licensee. This License - Agreement does not grant permission to use PSF trademarks or trade name in a - trademark sense to endorse or promote products or services of Licensee, or any - third party. - -8. By copying, installing or otherwise using Python 3.9, Licensee agrees - to be bound by the terms and conditions of this License Agreement. - -## Features - -* Easy to install Python runtime -* Supported by core CPython team -* Find Python, Pip and Idle on PATH - -## Search Terms - -* Python -* Scripting -* Interpreter - diff --git a/PC/winreg.c b/PC/winreg.c index 26bcd259efd9879..417e9a9843375c5 100644 --- a/PC/winreg.c +++ b/PC/winreg.c @@ -238,9 +238,6 @@ class winreg.HKEYType "PyHKEYObject *" "&PyHKEY_Type" class REGSAM_converter(int_converter): type = 'REGSAM' -class DWORD_converter(unsigned_long_converter): - type = 'DWORD' - class HKEY_converter(CConverter): type = 'HKEY' converter = 'clinic_HKEY_converter' @@ -265,7 +262,7 @@ class HKEY_return_converter(CReturnConverter): data.return_conversion.append( 'return_value = PyHKEY_FromHKEY(_PyModule_GetState(module), _return_value);\n') [python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=b34c8217647f5fef]*/ +/*[python end generated code: output=da39a3ee5e6b4b0d input=e345501438d93fa2]*/ #include "clinic/winreg.c.h" @@ -903,6 +900,7 @@ winreg_CreateKey_impl(PyObject *module, HKEY key, const wchar_t *sub_key) } if (PySys_Audit("winreg.OpenKey/result", "n", (Py_ssize_t)retKey) < 0) { + RegCloseKey(retKey); return NULL; } return retKey; @@ -955,6 +953,7 @@ winreg_CreateKeyEx_impl(PyObject *module, HKEY key, const wchar_t *sub_key, } if (PySys_Audit("winreg.OpenKey/result", "n", (Py_ssize_t)retKey) < 0) { + RegCloseKey(retKey); return NULL; } return retKey; @@ -1401,6 +1400,7 @@ winreg_OpenKey_impl(PyObject *module, HKEY key, const wchar_t *sub_key, } if (PySys_Audit("winreg.OpenKey/result", "n", (Py_ssize_t)retKey) < 0) { + RegCloseKey(retKey); return NULL; } return retKey; diff --git a/PCbuild/_ctypes.vcxproj b/PCbuild/_ctypes.vcxproj index 63d5fa49cd4e17a..e56d812d78dcd80 100644 --- a/PCbuild/_ctypes.vcxproj +++ b/PCbuild/_ctypes.vcxproj @@ -98,6 +98,7 @@ /EXPORT:DllGetClassObject,PRIVATE /EXPORT:DllCanUnloadNow,PRIVATE %(AdditionalOptions) + ole32.dll diff --git a/PCbuild/_elementtree.vcxproj b/PCbuild/_elementtree.vcxproj index 46e34a5ea82d5d0..418954cd972675d 100644 --- a/PCbuild/_elementtree.vcxproj +++ b/PCbuild/_elementtree.vcxproj @@ -100,10 +100,12 @@ + + @@ -112,11 +114,13 @@ + + diff --git a/PCbuild/_elementtree.vcxproj.filters b/PCbuild/_elementtree.vcxproj.filters index f6b55d8ff82a68c..ead096bbd03ca5d 100644 --- a/PCbuild/_elementtree.vcxproj.filters +++ b/PCbuild/_elementtree.vcxproj.filters @@ -24,6 +24,9 @@ Header Files\expat + + Header Files\expat + Header Files\expat @@ -36,6 +39,9 @@ Header Files\expat + + Header Files\expat + Header Files\expat @@ -60,6 +66,9 @@ Header Files\expat + + Header Files\expat + Header Files\expat @@ -71,6 +80,9 @@ Source Files + + Source Files\expat + Source Files\expat diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj index 04bd36404366a57..bf430135e21ed55 100644 --- a/PCbuild/_freeze_module.vcxproj +++ b/PCbuild/_freeze_module.vcxproj @@ -175,25 +175,27 @@ + - + - - - - + + + + + @@ -284,6 +286,7 @@ + @@ -306,6 +309,11 @@ $(IntDir)zipimport.g.h $(GeneratedFrozenModulesDir)Python\frozen_modules\zipimport.h + + builtins + $(IntDir)builtins.g.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\builtins.h + abc $(IntDir)abc.g.h @@ -316,31 +324,6 @@ $(IntDir)codecs.g.h $(GeneratedFrozenModulesDir)Python\frozen_modules\codecs.h - - encodings - $(IntDir)encodings.g.h - $(GeneratedFrozenModulesDir)Python\frozen_modules\encodings.h - - - encodings.aliases - $(IntDir)encodings.aliases.g.h - $(GeneratedFrozenModulesDir)Python\frozen_modules\encodings.aliases.h - - - encodings.utf_8 - $(IntDir)encodings.utf_8.g.h - $(GeneratedFrozenModulesDir)Python\frozen_modules\encodings.utf_8.h - - - encodings._win_cp_codecs - $(IntDir)encodings._win_cp_codecs.g.h - $(GeneratedFrozenModulesDir)Python\frozen_modules\encodings._win_cp_codecs.h - - - encodings._iconv_codecs - $(IntDir)encodings._iconv_codecs.g.h - $(GeneratedFrozenModulesDir)Python\frozen_modules\encodings._iconv_codecs.h - io $(IntDir)io.g.h diff --git a/PCbuild/_freeze_module.vcxproj.filters b/PCbuild/_freeze_module.vcxproj.filters index 7710acf43b5137c..6ff943f89ade007 100644 --- a/PCbuild/_freeze_module.vcxproj.filters +++ b/PCbuild/_freeze_module.vcxproj.filters @@ -19,6 +19,9 @@ Source Files + + Source Files + Source Files @@ -331,6 +334,9 @@ Source Files + + Source Files + Source Files @@ -463,28 +469,28 @@ Source Files - + Source Files - + Source Files - + Source Files Source Files - + Source Files - + Source Files - + Source Files - + Source Files @@ -496,6 +502,9 @@ Source Files + + Source Files + Source Files @@ -549,25 +558,13 @@ Python Files - - Python Files - - - Python Files - - + Python Files - - Python Files - - - Python Files - - + Python Files - + Python Files diff --git a/PCbuild/_hashlib.vcxproj b/PCbuild/_hashlib.vcxproj index 2cd205224bc0891..e0110f32f201f16 100644 --- a/PCbuild/_hashlib.vcxproj +++ b/PCbuild/_hashlib.vcxproj @@ -97,6 +97,9 @@ ws2_32.lib;%(AdditionalDependencies) + + + diff --git a/PCbuild/_hashlib.vcxproj.filters b/PCbuild/_hashlib.vcxproj.filters index 7a0700c007f6442..d26954116bb5edc 100644 --- a/PCbuild/_hashlib.vcxproj.filters +++ b/PCbuild/_hashlib.vcxproj.filters @@ -4,6 +4,9 @@ {cc45963d-bd25-4eb8-bdba-a5507090bca4} + + {5abcdd3e-a8bc-4833-949c-9477609092b9} + {67630fa4-76e4-4035-bced-043a6df1e2e0} @@ -13,6 +16,11 @@ Source Files + + + Header Files + + Resource Files diff --git a/PCbuild/_ssl.vcxproj b/PCbuild/_ssl.vcxproj index ce21f992ff8510e..80e5fe470b2e191 100644 --- a/PCbuild/_ssl.vcxproj +++ b/PCbuild/_ssl.vcxproj @@ -97,6 +97,10 @@ ws2_32.lib;crypt32.lib;%(AdditionalDependencies) + + + + diff --git a/PCbuild/_ssl.vcxproj.filters b/PCbuild/_ssl.vcxproj.filters index 8aef9e03fcc429a..d6b9d4bdf36e84d 100644 --- a/PCbuild/_ssl.vcxproj.filters +++ b/PCbuild/_ssl.vcxproj.filters @@ -4,6 +4,9 @@ {695348f7-e9f6-4fe1-bc03-5f08ffc8095b} + + {7c1bd5da-8912-4107-b6ac-f3930f2d90c7} + {1b18a2e6-040d-46c7-a9ac-ac2ec64fb5d6} @@ -13,6 +16,14 @@ Source Files + + + Header Files + + + Header Files + + Resource Files diff --git a/PCbuild/_testcapi.vcxproj b/PCbuild/_testcapi.vcxproj index 64e50b67be46561..9b4473b877daf44 100644 --- a/PCbuild/_testcapi.vcxproj +++ b/PCbuild/_testcapi.vcxproj @@ -134,6 +134,8 @@ + + diff --git a/PCbuild/_testcapi.vcxproj.filters b/PCbuild/_testcapi.vcxproj.filters index a3b62e1df663e00..238819a1d3646fb 100644 --- a/PCbuild/_testcapi.vcxproj.filters +++ b/PCbuild/_testcapi.vcxproj.filters @@ -135,6 +135,12 @@ Source Files + + Source Files + + + Source Files + diff --git a/PCbuild/_testinternalcapi.vcxproj b/PCbuild/_testinternalcapi.vcxproj index f3e423fa04668ec..ae873f0e0267aca 100644 --- a/PCbuild/_testinternalcapi.vcxproj +++ b/PCbuild/_testinternalcapi.vcxproj @@ -100,7 +100,9 @@ + + diff --git a/PCbuild/_testinternalcapi.vcxproj.filters b/PCbuild/_testinternalcapi.vcxproj.filters index 7ab242c2c230b67..3290aee2fa4042d 100644 --- a/PCbuild/_testinternalcapi.vcxproj.filters +++ b/PCbuild/_testinternalcapi.vcxproj.filters @@ -27,9 +27,15 @@ Source Files + + Source Files + Source Files + + Source Files + diff --git a/PCbuild/_testlimitedcapi.vcxproj b/PCbuild/_testlimitedcapi.vcxproj index 7ddcee6d9735ce6..1a40cd0d2271f5f 100644 --- a/PCbuild/_testlimitedcapi.vcxproj +++ b/PCbuild/_testlimitedcapi.vcxproj @@ -97,6 +97,7 @@ + @@ -109,6 +110,7 @@ + @@ -119,6 +121,9 @@ + + + diff --git a/PCbuild/_testlimitedcapi.vcxproj.filters b/PCbuild/_testlimitedcapi.vcxproj.filters index 66a0a47d8e5548b..1b13da0ebca7ba2 100644 --- a/PCbuild/_testlimitedcapi.vcxproj.filters +++ b/PCbuild/_testlimitedcapi.vcxproj.filters @@ -12,6 +12,7 @@ + @@ -24,6 +25,7 @@ + @@ -35,6 +37,9 @@ + + + diff --git a/PCbuild/find_python.bat b/PCbuild/find_python.bat index 4824e89de41d690..8f813ea27aefdaa 100644 --- a/PCbuild/find_python.bat +++ b/PCbuild/find_python.bat @@ -47,7 +47,7 @@ @rem If py.exe finds a recent enough version, use that one @rem It is fine to add new versions to this list when they have released, @rem but we do not use prerelease builds here. -@for %%p in (3.14 3.13 3.12 3.11 3.10) do @py -%%p -EV >nul 2>&1 && (set PYTHON=py -%%p) && (set _Py_Python_Source=found %%p with py.exe) && goto :found +@for %%p in (3.15 3.14 3.13 3.12 3.11 3.10) do @py -%%p -EV >nul 2>&1 && (set PYTHON=py -%%p) && (set _Py_Python_Source=found %%p with py.exe) && goto :found @if NOT exist "%_Py_EXTERNALS_DIR%" mkdir "%_Py_EXTERNALS_DIR%" @set _Py_NUGET=%NUGET% diff --git a/PCbuild/get_externals.bat b/PCbuild/get_externals.bat index 47399fe65d1e542..36dfb7cc051c658 100644 --- a/PCbuild/get_externals.bat +++ b/PCbuild/get_externals.bat @@ -54,14 +54,14 @@ echo.Fetching external libraries... set libraries= set libraries=%libraries% bzip2-1.0.8 if NOT "%IncludeLibffiSrc%"=="false" set libraries=%libraries% libffi-3.4.4 -if NOT "%IncludeSSLSrc%"=="false" set libraries=%libraries% openssl-3.5.7 +if NOT "%IncludeSSLSrc%"=="false" set libraries=%libraries% openssl-3.5.9 set libraries=%libraries% mpdecimal-4.0.0 -set libraries=%libraries% sqlite-3.53.2.0 -if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tcl-9.0.3.0 -if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tk-9.0.3.1 +set libraries=%libraries% sqlite-3.53.4.0 +if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tcl-9.0.4.0 +if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tk-9.0.4.1 set libraries=%libraries% xz-5.8.1.1 -set libraries=%libraries% zlib-ng-2.2.4 -set libraries=%libraries% zstd-1.5.7 +set libraries=%libraries% zlib-ng-2.2.5 +set libraries=%libraries% zstd-1.6.0 for %%e in (%libraries%) do ( if exist "%EXTERNALS_DIR%\%%e" ( @@ -79,8 +79,8 @@ echo.Fetching external binaries... set binaries= if NOT "%IncludeLibffi%"=="false" set binaries=%binaries% libffi-3.4.4 -if NOT "%IncludeSSL%"=="false" set binaries=%binaries% openssl-bin-3.5.7 -if NOT "%IncludeTkinter%"=="false" set binaries=%binaries% tcltk-9.0.3.0 +if NOT "%IncludeSSL%"=="false" set binaries=%binaries% openssl-bin-3.5.9 +if NOT "%IncludeTkinter%"=="false" set binaries=%binaries% tcltk-9.0.4.0 if NOT "%IncludeSSLSrc%"=="false" set binaries=%binaries% nasm-2.11.06 if NOT "%IncludeLLVM%"=="false" set binaries=%binaries% llvm-21.1.4.0 diff --git a/PCbuild/pcbuild.proj b/PCbuild/pcbuild.proj index 9d077bbd3f0ba27..95e135705dac2ff 100644 --- a/PCbuild/pcbuild.proj +++ b/PCbuild/pcbuild.proj @@ -63,10 +63,6 @@ - - - - @@ -82,9 +78,9 @@ - - - + + + false diff --git a/PCbuild/pcbuild.sln b/PCbuild/pcbuild.sln index 09a989d38648df4..e2cac3158831eed 100644 --- a/PCbuild/pcbuild.sln +++ b/PCbuild/pcbuild.sln @@ -111,16 +111,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xxlimited", "xxlimited.vcxp EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_testbuffer", "_testbuffer.vcxproj", "{A2697BD3-28C1-4AEC-9106-8B748639FD16}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pylauncher", "pylauncher.vcxproj", "{7B2727B5-5A3F-40EE-A866-43A13CD31446}" - ProjectSection(ProjectDependencies) = postProject - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782} = {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pywlauncher", "pywlauncher.vcxproj", "{1D4B18D3-7C12-4ECB-9179-8531FF876CE6}" - ProjectSection(ProjectDependencies) = postProject - {7B2727B5-5A3F-40EE-A866-43A13CD31446} = {7B2727B5-5A3F-40EE-A866-43A13CD31446} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_freeze_module", "_freeze_module.vcxproj", "{19C0C13F-47CA-4432-AFF3-799A296A4DDC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_overlapped", "_overlapped.vcxproj", "{EB6E69DD-04BF-4543-9B92-49FAABCEAC2E}" @@ -131,8 +121,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_testmultiphase", "_testmul EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_testsinglephase", "_testsinglephase.vcxproj", "{2097F1C1-597C-4167-93E3-656A7D6339B2}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pyshellext", "pyshellext.vcxproj", "{0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_testconsole", "_testconsole.vcxproj", "{B244E787-C445-441C-BDF4-5A4F1A3A1E51}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_asyncio", "_asyncio.vcxproj", "{384C224A-7474-476E-A01B-750EA7DE918C}" @@ -1079,70 +1067,6 @@ Global {A2697BD3-28C1-4AEC-9106-8B748639FD16}.Release|Win32.Build.0 = Release|Win32 {A2697BD3-28C1-4AEC-9106-8B748639FD16}.Release|x64.ActiveCfg = Release|x64 {A2697BD3-28C1-4AEC-9106-8B748639FD16}.Release|x64.Build.0 = Release|x64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Debug|ARM.ActiveCfg = Debug|ARM - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Debug|ARM.Build.0 = Debug|ARM - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Debug|ARM64.Build.0 = Debug|ARM64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Debug|Win32.ActiveCfg = Debug|Win32 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Debug|Win32.Build.0 = Debug|Win32 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Debug|x64.ActiveCfg = Debug|x64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Debug|x64.Build.0 = Debug|x64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGInstrument|ARM.ActiveCfg = PGInstrument|ARM - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGInstrument|ARM.Build.0 = PGInstrument|ARM - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGInstrument|ARM64.ActiveCfg = PGInstrument|ARM64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGInstrument|ARM64.Build.0 = PGInstrument|ARM64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGInstrument|Win32.ActiveCfg = Release|Win32 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGInstrument|Win32.Build.0 = Release|Win32 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGInstrument|x64.ActiveCfg = Release|x64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGInstrument|x64.Build.0 = Release|x64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGUpdate|ARM.ActiveCfg = PGUpdate|ARM - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGUpdate|ARM.Build.0 = PGUpdate|ARM - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGUpdate|ARM64.ActiveCfg = PGUpdate|ARM64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGUpdate|ARM64.Build.0 = PGUpdate|ARM64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGUpdate|Win32.ActiveCfg = Release|Win32 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGUpdate|Win32.Build.0 = Release|Win32 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGUpdate|x64.ActiveCfg = Release|x64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.PGUpdate|x64.Build.0 = Release|x64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Release|ARM.ActiveCfg = Release|ARM - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Release|ARM.Build.0 = Release|ARM - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Release|ARM64.ActiveCfg = Release|ARM64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Release|ARM64.Build.0 = Release|ARM64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Release|Win32.ActiveCfg = Release|Win32 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Release|Win32.Build.0 = Release|Win32 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Release|x64.ActiveCfg = Release|x64 - {7B2727B5-5A3F-40EE-A866-43A13CD31446}.Release|x64.Build.0 = Release|x64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Debug|ARM.ActiveCfg = Debug|ARM - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Debug|ARM.Build.0 = Debug|ARM - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Debug|ARM64.Build.0 = Debug|ARM64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Debug|Win32.ActiveCfg = Debug|Win32 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Debug|Win32.Build.0 = Debug|Win32 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Debug|x64.ActiveCfg = Debug|x64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Debug|x64.Build.0 = Debug|x64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGInstrument|ARM.ActiveCfg = PGInstrument|ARM - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGInstrument|ARM.Build.0 = PGInstrument|ARM - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGInstrument|ARM64.ActiveCfg = PGInstrument|ARM64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGInstrument|ARM64.Build.0 = PGInstrument|ARM64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGInstrument|Win32.ActiveCfg = Release|Win32 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGInstrument|Win32.Build.0 = Release|Win32 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGInstrument|x64.ActiveCfg = Release|x64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGInstrument|x64.Build.0 = Release|x64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGUpdate|ARM.ActiveCfg = PGUpdate|ARM - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGUpdate|ARM.Build.0 = PGUpdate|ARM - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGUpdate|ARM64.ActiveCfg = PGUpdate|ARM64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGUpdate|ARM64.Build.0 = PGUpdate|ARM64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGUpdate|Win32.ActiveCfg = Release|Win32 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGUpdate|Win32.Build.0 = Release|Win32 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGUpdate|x64.ActiveCfg = Release|x64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.PGUpdate|x64.Build.0 = Release|x64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Release|ARM.ActiveCfg = Release|ARM - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Release|ARM.Build.0 = Release|ARM - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Release|ARM64.ActiveCfg = Release|ARM64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Release|ARM64.Build.0 = Release|ARM64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Release|Win32.ActiveCfg = Release|Win32 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Release|Win32.Build.0 = Release|Win32 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Release|x64.ActiveCfg = Release|x64 - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6}.Release|x64.Build.0 = Release|x64 {19C0C13F-47CA-4432-AFF3-799A296A4DDC}.Debug|ARM.ActiveCfg = Debug|ARM {19C0C13F-47CA-4432-AFF3-799A296A4DDC}.Debug|ARM.Build.0 = Debug|ARM {19C0C13F-47CA-4432-AFF3-799A296A4DDC}.Debug|ARM64.ActiveCfg = Debug|ARM64 @@ -1293,38 +1217,6 @@ Global {2097F1C1-597C-4167-93E3-656A7D6339B2}.Release|Win32.Build.0 = Release|Win32 {2097F1C1-597C-4167-93E3-656A7D6339B2}.Release|x64.ActiveCfg = Release|x64 {2097F1C1-597C-4167-93E3-656A7D6339B2}.Release|x64.Build.0 = Release|x64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Debug|ARM.ActiveCfg = Debug|ARM - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Debug|ARM.Build.0 = Debug|ARM - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Debug|ARM64.Build.0 = Debug|ARM64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Debug|Win32.ActiveCfg = Debug|Win32 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Debug|Win32.Build.0 = Debug|Win32 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Debug|x64.ActiveCfg = Debug|x64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Debug|x64.Build.0 = Debug|x64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGInstrument|ARM.ActiveCfg = PGInstrument|ARM - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGInstrument|ARM.Build.0 = PGInstrument|ARM - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGInstrument|ARM64.ActiveCfg = PGInstrument|ARM64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGInstrument|ARM64.Build.0 = PGInstrument|ARM64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGInstrument|x64.Build.0 = PGInstrument|x64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGUpdate|ARM.ActiveCfg = PGUpdate|ARM - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGUpdate|ARM.Build.0 = PGUpdate|ARM - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGUpdate|ARM64.ActiveCfg = PGUpdate|ARM64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGUpdate|ARM64.Build.0 = PGUpdate|ARM64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.PGUpdate|x64.Build.0 = PGUpdate|x64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Release|ARM.ActiveCfg = Release|ARM - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Release|ARM.Build.0 = Release|ARM - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Release|ARM64.ActiveCfg = Release|ARM64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Release|ARM64.Build.0 = Release|ARM64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Release|Win32.ActiveCfg = Release|Win32 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Release|Win32.Build.0 = Release|Win32 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Release|x64.ActiveCfg = Release|x64 - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782}.Release|x64.Build.0 = Release|x64 {B244E787-C445-441C-BDF4-5A4F1A3A1E51}.Debug|ARM.ActiveCfg = Debug|ARM {B244E787-C445-441C-BDF4-5A4F1A3A1E51}.Debug|ARM.Build.0 = Debug|ARM {B244E787-C445-441C-BDF4-5A4F1A3A1E51}.Debug|ARM64.ActiveCfg = Debug|ARM64 diff --git a/PCbuild/pyexpat.vcxproj b/PCbuild/pyexpat.vcxproj index 8a60ee15eb41bf8..15639930758da6b 100644 --- a/PCbuild/pyexpat.vcxproj +++ b/PCbuild/pyexpat.vcxproj @@ -95,13 +95,17 @@ + + + + diff --git a/PCbuild/pyexpat.vcxproj.filters b/PCbuild/pyexpat.vcxproj.filters index 230531033fccd87..096e4ad38895469 100644 --- a/PCbuild/pyexpat.vcxproj.filters +++ b/PCbuild/pyexpat.vcxproj.filters @@ -12,12 +12,21 @@ + + Header Files + Header Files + + Header Files + Header Files + + Header Files + Header Files @@ -29,6 +38,9 @@ Source Files + + Source Files + Source Files diff --git a/PCbuild/pylauncher.vcxproj b/PCbuild/pylauncher.vcxproj deleted file mode 100644 index ca422ef4d02e932..000000000000000 --- a/PCbuild/pylauncher.vcxproj +++ /dev/null @@ -1,114 +0,0 @@ - - - - - Debug - ARM - - - Debug - ARM64 - - - Debug - Win32 - - - Debug - x64 - - - PGInstrument - ARM - - - PGInstrument - ARM64 - - - PGInstrument - Win32 - - - PGInstrument - x64 - - - PGUpdate - ARM - - - PGUpdate - ARM64 - - - PGUpdate - Win32 - - - PGUpdate - x64 - - - Release - ARM - - - Release - ARM64 - - - Release - Win32 - - - Release - x64 - - - - {7B2727B5-5A3F-40EE-A866-43A13CD31446} - pylauncher - py - false - - - - - Application - Unicode - - - - - - ClCompile - - - - - - - - - _CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - shell32.lib;pathcch.lib;%(AdditionalDependencies) - Console - - - - - - - - - - - - - - - diff --git a/PCbuild/pylauncher.vcxproj.filters b/PCbuild/pylauncher.vcxproj.filters deleted file mode 100644 index f10f6d5669e283c..000000000000000 --- a/PCbuild/pylauncher.vcxproj.filters +++ /dev/null @@ -1,28 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/PCbuild/pyproject-clangcl.props b/PCbuild/pyproject-clangcl.props index 70a81ca7da306c3..14843f18823ca9b 100644 --- a/PCbuild/pyproject-clangcl.props +++ b/PCbuild/pyproject-clangcl.props @@ -50,6 +50,7 @@ -m32 %(AdditionalOptions) -m64 %(AdditionalOptions) -flto=thin %(AdditionalOptions) + %(AdditionalOptions) -Xclang -Og -fprofile-instr-generate=$(_CLANG_PROFILE_PATH)$(TargetName)_%m.profraw %(AdditionalOptions) -fprofile-instr-use=$(OutDir)instrumented\profdata.profdata -Wno-profile-instr-unprofiled %(AdditionalOptions) diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props index 7435c53e3fdcf9f..95998b6de2d866a 100644 --- a/PCbuild/pyproject.props +++ b/PCbuild/pyproject.props @@ -40,6 +40,8 @@ true true + + true @@ -50,7 +52,7 @@ <_DebugPreprocessorDefinition>NDEBUG; <_DebugPreprocessorDefinition Condition="$(Configuration) == 'Debug'">_DEBUG; <_PyStatsPreprocessorDefinition>PyStats; - <_PyStatsPreprocessorDefinition Condition="$(PySTATS) != ''">Py_STATS; + <_PyStatsPreprocessorDefinition Condition="$(PySTATS) != ''">Py_STATS=1; <_PlatformPreprocessorDefinition>_WIN32; <_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64'">_WIN64; <_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64' and $(PlatformToolset) != 'ClangCL'">_M_X64;$(_PlatformPreprocessorDefinition) diff --git a/PCbuild/pyshellext.vcxproj b/PCbuild/pyshellext.vcxproj deleted file mode 100644 index ea432d6bc9a3f33..000000000000000 --- a/PCbuild/pyshellext.vcxproj +++ /dev/null @@ -1,117 +0,0 @@ - - - - - Debug - ARM - - - Debug - ARM64 - - - Debug - Win32 - - - Debug - x64 - - - PGInstrument - ARM - - - PGInstrument - ARM64 - - - PGInstrument - Win32 - - - PGInstrument - x64 - - - PGUpdate - ARM - - - PGUpdate - ARM64 - - - PGUpdate - Win32 - - - PGUpdate - x64 - - - Release - ARM - - - Release - ARM64 - - - Release - Win32 - - - Release - x64 - - - - {0F6EE4A4-C75F-4578-B4B3-2D64F4B9B782} - pyshellext - pyshellext - false - - - - - DynamicLibrary - Unicode - - - - - - ClCompile - - - - - - - - - _CONSOLE;%(PreprocessorDefinitions) - - - version.lib;shlwapi.lib;%(AdditionalDependencies) - Console - ..\PC\pyshellext.def - - - true - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/PCbuild/pyshellext.vcxproj.filters b/PCbuild/pyshellext.vcxproj.filters deleted file mode 100644 index 77cd3060857a80b..000000000000000 --- a/PCbuild/pyshellext.vcxproj.filters +++ /dev/null @@ -1,28 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - Resource Files - - - - - Source Files - - - \ No newline at end of file diff --git a/PCbuild/python.props b/PCbuild/python.props index 8d931bba28a389a..3c8fe34da93b61f 100644 --- a/PCbuild/python.props +++ b/PCbuild/python.props @@ -98,20 +98,20 @@ - $(ExternalsDir)sqlite-3.53.2.0\ + $(ExternalsDir)sqlite-3.53.4.0\ $(ExternalsDir)bzip2-1.0.8\ $(ExternalsDir)xz-5.8.1.1\ $(ExternalsDir)libffi-3.4.4\ $(libffiDir)$(ArchName)\ $(libffiOutDir)include $(ExternalsDir)\mpdecimal-4.0.0\ - $(ExternalsDir)openssl-3.5.7\ - $(ExternalsDir)openssl-bin-3.5.7\$(ArchName)\ + $(ExternalsDir)openssl-3.5.9\ + $(ExternalsDir)openssl-bin-3.5.9\$(ArchName)\ $(opensslOutDir)include $(ExternalsDir)\nasm-2.11.06\ $(ExternalsDir)\zlib-1.3.1\ - $(ExternalsDir)\zlib-ng-2.2.4\ - $(ExternalsDir)\zstd-1.5.7\ + $(ExternalsDir)\zlib-ng-2.2.5\ + $(ExternalsDir)\zstd-1.6.0\ diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 47296a93424a8f6..d16aa7b4254b453 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -261,6 +261,7 @@ + @@ -276,6 +277,7 @@ + @@ -332,6 +334,7 @@ + @@ -355,6 +358,7 @@ + @@ -419,9 +423,11 @@ - - + + + + @@ -576,7 +582,10 @@ - + + + Disabled + @@ -585,19 +594,20 @@ + - - - - - + + + + + @@ -606,6 +616,7 @@ + @@ -703,6 +714,7 @@ + diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 124f6c7bb90de6c..99b2631b673a80d 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -321,16 +321,22 @@ Objects - - Parser - Parser Parser - + + Parser + + + Parser + + + Parser + + Parser @@ -690,6 +696,9 @@ Include\internal + + Include\internal + Include\internal @@ -735,6 +744,9 @@ Include\cpython + + Include\cpython + Include\internal @@ -897,6 +909,9 @@ Include\internal + + Include\internal + Include\internal @@ -927,6 +942,9 @@ Include\internal\mimalloc + + Include\internal\mimalloc + Include\internal\mimalloc @@ -1334,6 +1352,9 @@ Parser + + Parser + Parser @@ -1343,19 +1364,16 @@ Parser - - Parser - - + Parser - + Parser - + Parser - + Parser @@ -1379,6 +1397,9 @@ Python + + Python + Python @@ -1622,6 +1643,9 @@ Python + + Python + Python @@ -1691,6 +1715,9 @@ Parser + + Parser + Parser diff --git a/PCbuild/pywlauncher.vcxproj b/PCbuild/pywlauncher.vcxproj deleted file mode 100644 index 1694548935a1653..000000000000000 --- a/PCbuild/pywlauncher.vcxproj +++ /dev/null @@ -1,114 +0,0 @@ - - - - - Debug - ARM - - - Debug - ARM64 - - - Debug - Win32 - - - Debug - x64 - - - PGInstrument - ARM - - - PGInstrument - ARM64 - - - PGInstrument - Win32 - - - PGInstrument - x64 - - - PGUpdate - ARM - - - PGUpdate - ARM64 - - - PGUpdate - Win32 - - - PGUpdate - x64 - - - Release - ARM - - - Release - ARM64 - - - Release - Win32 - - - Release - x64 - - - - {1D4B18D3-7C12-4ECB-9179-8531FF876CE6} - pywlauncher - pyw - false - - - - - Application - Unicode - - - - - - ClCompile - - - - - - - - - _WINDOWS;%(PreprocessorDefinitions) - MultiThreaded - - - shell32.lib;pathcch.lib;%(AdditionalDependencies) - Windows - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/PCbuild/pywlauncher.vcxproj.filters b/PCbuild/pywlauncher.vcxproj.filters deleted file mode 100644 index f10f6d5669e283c..000000000000000 --- a/PCbuild/pywlauncher.vcxproj.filters +++ /dev/null @@ -1,28 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/PCbuild/readme.txt b/PCbuild/readme.txt index 7c5eab2eb75a1de..2f3e44646b643bf 100644 --- a/PCbuild/readme.txt +++ b/PCbuild/readme.txt @@ -23,7 +23,7 @@ external dependencies. To build, simply run the "build.bat" script without any arguments. After this succeeds, you can open the "pcbuild.sln" solution in Visual Studio to continue development. -To build an installer package, refer to the README in the Tools/msi folder. +To build an installer package, refer to PC/layout. The solution currently supports two platforms. The Win32 platform is used to build standard x86-compatible 32-bit binaries, output into the @@ -140,12 +140,6 @@ CPython in different ways: pythonw pythonw.exe, a variant of python.exe that doesn't open a Command Prompt window -pylauncher - py.exe, the Python Launcher for Windows, see - https://docs.python.org/3/using/windows.html#launcher -pywlauncher - pyw.exe, a variant of py.exe that doesn't open a Command Prompt - window _testembed _testembed.exe, a small program that embeds Python for testing purposes, used by test_capi.py @@ -156,8 +150,6 @@ _freeze_module _freeze_module.exe, used to regenerate frozen modules in Python after changes have been made to the corresponding source files (e.g. Lib\importlib\_bootstrap.py). -pyshellext - pyshellext.dll, the shell extension deployed with the launcher python3dll python3.dll, the PEP 384 Stable ABI dll (not installed on free-threaded builds) @@ -242,12 +234,12 @@ _ssl again when building. _sqlite3 - Wraps SQLite 3.53.2, which is itself built by sqlite3.vcxproj + Wraps SQLite 3.53.4, which is itself built by sqlite3.vcxproj Homepage: https://www.sqlite.org/ _tkinter - Wraps version 9.0.3 of the Tk windowing system, which is downloaded + Wraps version 9.0.4 of the Tk windowing system, which is downloaded from our binaries repository at https://github.com/python/cpython-bin-deps. @@ -268,24 +260,20 @@ _tkinter is able to load Tcl/Tk without having to change your PATH. _zstd - Python wrapper for version 1.5.7 of the zstd compression library + Python wrapper for version 1.6.0 of the zstd compression library Homepage: https://facebook.github.io/zstd/ zlib-ng Compiles zlib-ng as a static library, which is later included by pythoncore.vcxproj. This was generated using CMake against zlib-ng - version 2.2.4, and should be minimally updated as needed to adapt + version 2.2.5, and should be minimally updated as needed to adapt to changes in their source layout. The zbuild.h, zconf.h and zconf-ng.h file in the PC directory were likewise generated and vendored. Sources for zlib-ng are imported unmodified into our source repository at https://github.com/python/cpython-source-deps. -_zstd - Python wrapper for version 1.5.7 of the Zstandard compression library - Homepage: - https://facebook.github.io/zstd/ Getting External Sources @@ -420,8 +408,6 @@ _testclinic_limited extension, the file Modules/_testclinic_limited.c: * Save and exit Visual Studio. * Add `;_testclinic_limited` to `` in PCbuild\pcbuild.proj. -* Update "exts" in Tools\msi\lib\lib_files.wxs file or in - Tools\msi\test\test_files.wxs file (for tests). * PC\layout\main.py needs updating if you add a test-only extension whose name doesn't start with "_test". * Add the extension to PCbuild\readme.txt (this file). diff --git a/PCbuild/regen.targets b/PCbuild/regen.targets index 9552e73ef6a2eca..8f2717610bc66e4 100644 --- a/PCbuild/regen.targets +++ b/PCbuild/regen.targets @@ -1,8 +1,8 @@ - <_PegenSources Include="$(PySourcePath)Grammar\python.gram;$(PySourcePath)Grammar\Tokens" /> - <_PegenOutputs Include="$(PySourcePath)Parser\parser.c" /> + <_PegenSources Include="$(PySourcePath)Grammar\python.gram;$(PySourcePath)Grammar\invalid.gram;$(PySourcePath)Grammar\Tokens" /> + <_PegenOutputs Include="$(PySourcePath)Parser\parser.c;$(PySourcePath)Parser\parser_invalid.c" /> <_ASTSources Include="$(PySourcePath)Parser\Python.asdl" /> <_ASTOutputs Include="$(PySourcePath)Include\internal\pycore_ast.h"> -H @@ -26,7 +26,7 @@ <_TokenOutputs Include="$(PySourcePath)Lib\token.py"> py - <_KeywordSources Include="$(PySourcePath)Grammar\python.gram;$(PySourcePath)Grammar\Tokens" /> + <_KeywordSources Include="$(PySourcePath)Grammar\python.gram;$(PySourcePath)Grammar\invalid.gram;$(PySourcePath)Grammar\Tokens" /> <_KeywordOutputs Include="$(PySourcePath)Lib\keyword.py" /> <_JITSources Include="$(PySourcePath)Python\executor_cases.c.h;$(PySourcePath)PC\pyconfig.h;$(PySourcePath)Tools\jit\**"/> diff --git a/PCbuild/sqlite3.vcxproj b/PCbuild/sqlite3.vcxproj index f12ec348b37e297..0673e03a59fc1e1 100644 --- a/PCbuild/sqlite3.vcxproj +++ b/PCbuild/sqlite3.vcxproj @@ -98,7 +98,7 @@ $(sqlite3Dir);%(AdditionalIncludeDirectories) - SQLITE_ENABLE_MATH_FUNCTIONS;SQLITE_ENABLE_FTS4;SQLITE_ENABLE_FTS5;SQLITE_ENABLE_RTREE;SQLITE_OMIT_AUTOINIT;SQLITE_API=__declspec(dllexport);%(PreprocessorDefinitions) + SQLITE_ENABLE_MATH_FUNCTIONS;SQLITE_ENABLE_FTS4;SQLITE_ENABLE_FTS5;SQLITE_ENABLE_PERCENTILE;SQLITE_ENABLE_RTREE;SQLITE_OMIT_AUTOINIT;SQLITE_API=__declspec(dllexport);%(PreprocessorDefinitions) Level1 %(AdditionalOptions) -Wno-unused diff --git a/PCbuild/tcltk.props b/PCbuild/tcltk.props index 28e8c0db4d1eafd..1d6b4f57f09f747 100644 --- a/PCbuild/tcltk.props +++ b/PCbuild/tcltk.props @@ -2,7 +2,7 @@ - 9.0.3.0 + 9.0.4.0 $(TclVersion) $([System.Version]::Parse($(TclVersion)).Major) $([System.Version]::Parse($(TclVersion)).Minor) diff --git a/PCbuild/venvlauncher.vcxproj b/PCbuild/venvlauncher.vcxproj index a2e8ffa82b10eb7..7afe923406b1d18 100644 --- a/PCbuild/venvlauncher.vcxproj +++ b/PCbuild/venvlauncher.vcxproj @@ -110,10 +110,7 @@ - - - - + diff --git a/PCbuild/venvlauncher.vcxproj.filters b/PCbuild/venvlauncher.vcxproj.filters index bc98687a6da0d3e..62839fd6b8e863f 100644 --- a/PCbuild/venvlauncher.vcxproj.filters +++ b/PCbuild/venvlauncher.vcxproj.filters @@ -9,12 +9,7 @@ - - Resource Files - - - - + Resource Files diff --git a/PCbuild/venvwlauncher.vcxproj b/PCbuild/venvwlauncher.vcxproj index f2aaf83fe2b3785..3aa0bb2cdefeaa8 100644 --- a/PCbuild/venvwlauncher.vcxproj +++ b/PCbuild/venvwlauncher.vcxproj @@ -110,10 +110,7 @@ - - - - + diff --git a/PCbuild/venvwlauncher.vcxproj.filters b/PCbuild/venvwlauncher.vcxproj.filters index 5193c38b12d53d5..babded59633f1f1 100644 --- a/PCbuild/venvwlauncher.vcxproj.filters +++ b/PCbuild/venvwlauncher.vcxproj.filters @@ -14,12 +14,7 @@ - - Resource Files - - - - + Resource Files diff --git a/Parser/action_helpers.c b/Parser/action_helpers.c index 809f3c0a7b270e8..be9560a9124093c 100644 --- a/Parser/action_helpers.c +++ b/Parser/action_helpers.c @@ -6,6 +6,7 @@ #include "pegen.h" #include "string_parser.h" // _PyPegen_decode_string() +#include "lexer/state.h" // tok_state void * @@ -346,6 +347,20 @@ _PyPegen_set_expr_context(Parser *p, expr_ty expr, expr_context_ty ctx) return new; } +/* Invalid targets return NULL without raising, allowing parsing to backtrack. + Copy valid targets to preserve the memoized expression's context. */ +expr_ty +_PyPegen_make_target(Parser *p, expr_ty expr, TARGETS_TYPE targets_type) +{ + assert(expr != NULL); + assert(targets_type != FOR_TARGETS); + if (_PyPegen_get_invalid_target(expr, targets_type) != NULL) { + return NULL; + } + return _PyPegen_set_expr_context( + p, expr, targets_type == DEL_TARGETS ? Del : Store); +} + /* Constructs a KeyValuePair that is used when parsing a dict's key value pairs */ KeyValuePair * _PyPegen_key_value_pair(Parser *p, expr_ty key, expr_ty value) @@ -1001,6 +1016,25 @@ result_token_with_metadata(Parser *p, void *result, PyObject *metadata) return res; } +static char +formatted_string_prefix(const Parser *p) +{ + int nested = 0; + for (int i = p->mark - 1; i >= 0; i--) { + int type = p->tokens[i]->type; + if (type == FSTRING_END || type == TSTRING_END) { + nested++; + } + else if (type == FSTRING_START || type == TSTRING_START) { + if (nested == 0) { + return type == TSTRING_START ? 't' : 'f'; + } + nested--; + } + } + Py_UNREACHABLE(); +} + ResultTokenWithMetadata * _PyPegen_check_fstring_conversion(Parser *p, Token* conv_token, expr_ty conv) { @@ -1008,7 +1042,7 @@ _PyPegen_check_fstring_conversion(Parser *p, Token* conv_token, expr_ty conv) return RAISE_SYNTAX_ERROR_KNOWN_RANGE( conv_token, conv, "%c-string: conversion type must come right after the exclamation mark", - TOK_GET_STRING_PREFIX(p->tok) + formatted_string_prefix(p) ); } @@ -1017,7 +1051,7 @@ _PyPegen_check_fstring_conversion(Parser *p, Token* conv_token, expr_ty conv) !(first == 's' || first == 'r' || first == 'a')) { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(conv, "%c-string: invalid conversion character %R: expected 's', 'r', or 'a'", - TOK_GET_STRING_PREFIX(p->tok), + formatted_string_prefix(p), conv->v.Name.id); return NULL; } @@ -1217,6 +1251,14 @@ _PyPegen_get_invalid_target(expr_ty e, TARGETS_TYPE targets_type) return NULL; } + if (targets_type == SINGLE_TARGETS || + targets_type == ATTRIBUTE_OR_SUBSCRIPT_TARGETS) { + if (targets_type == SINGLE_TARGETS && e->kind == Name_kind) { + return NULL; + } + return e->kind == Attribute_kind || e->kind == Subscript_kind ? NULL : e; + } + #define VISIT_CONTAINER(CONTAINER, TYPE) do { \ Py_ssize_t len = asdl_seq_LEN((CONTAINER)->v.TYPE.elts);\ for (Py_ssize_t i = 0; i < len; i++) {\ @@ -1331,7 +1373,7 @@ _PyPegen_decode_fstring_part(Parser* p, int is_raw, expr_ty constant, Token* tok is_raw = is_raw || strchr(bstr, '\\') == NULL; PyObject *str = _PyPegen_decode_string(p, is_raw, bstr, len, token); if (str == NULL) { - _Pypegen_raise_decode_error(p); + _Pypegen_raise_decode_error_known_location(p, constant); return NULL; } if (_PyArena_AddPyObject(p->arena, str) < 0) { @@ -1344,7 +1386,8 @@ _PyPegen_decode_fstring_part(Parser* p, int is_raw, expr_ty constant, Token* tok } static asdl_expr_seq * -_get_resized_exprs(Parser *p, Token *a, asdl_expr_seq *raw_expressions, Token *b, enum string_kind_t string_kind) +_get_resized_exprs(Parser *p, Token *a, asdl_expr_seq *raw_expressions, + Token *b, int is_tstring) { Py_ssize_t n_items = asdl_seq_LEN(raw_expressions); Py_ssize_t total_items = n_items; @@ -1370,15 +1413,13 @@ _get_resized_exprs(Parser *p, Token *a, asdl_expr_seq *raw_expressions, Token *b for (Py_ssize_t i = 0; i < n_items; i++) { expr_ty item = asdl_seq_GET(raw_expressions, i); - // This should correspond to a JoinedStr node of two elements - // created _PyPegen_formatted_value. This situation can only be the result of - // a (f|t)-string debug expression where the first element is a constant with the text and the second - // a formatted value with the expression. + /* Debug expressions arrive as JoinedStr(text, value); flatten them + into the surrounding string. */ if (item->kind == JoinedStr_kind) { asdl_expr_seq *values = item->v.JoinedStr.values; if (asdl_seq_LEN(values) != 2) { PyErr_Format(PyExc_SystemError, - string_kind == TSTRING + is_tstring ? "unexpected TemplateStr node without debug data in t-string at line %d" : "unexpected JoinedStr node without debug data in f-string at line %d", item->lineno); @@ -1390,7 +1431,9 @@ _get_resized_exprs(Parser *p, Token *a, asdl_expr_seq *raw_expressions, Token *b asdl_seq_SET(seq, index++, first); expr_ty second = asdl_seq_GET(values, 1); - assert((string_kind == TSTRING && second->kind == Interpolation_kind) || second->kind == FormattedValue_kind); + assert((is_tstring && + second->kind == Interpolation_kind) || + second->kind == FormattedValue_kind); asdl_seq_SET(seq, index++, second); continue; @@ -1432,7 +1475,7 @@ _get_resized_exprs(Parser *p, Token *a, asdl_expr_seq *raw_expressions, Token *b expr_ty _PyPegen_template_str(Parser *p, Token *a, asdl_expr_seq *raw_expressions, Token *b) { - asdl_expr_seq *resized_exprs = _get_resized_exprs(p, a, raw_expressions, b, TSTRING); + asdl_expr_seq *resized_exprs = _get_resized_exprs(p, a, raw_expressions, b, 1); if (resized_exprs == NULL) { return NULL; } @@ -1444,7 +1487,7 @@ _PyPegen_template_str(Parser *p, Token *a, asdl_expr_seq *raw_expressions, Token expr_ty _PyPegen_joined_str(Parser *p, Token* a, asdl_expr_seq* raw_expressions, Token*b) { - asdl_expr_seq *resized_exprs = _get_resized_exprs(p, a, raw_expressions, b, FSTRING); + asdl_expr_seq *resized_exprs = _get_resized_exprs(p, a, raw_expressions, b, 0); if (resized_exprs == NULL) { return NULL; } @@ -1454,23 +1497,25 @@ _PyPegen_joined_str(Parser *p, Token* a, asdl_expr_seq* raw_expressions, Token*b } expr_ty _PyPegen_decoded_constant_from_token(Parser* p, Token* tok) { - Py_ssize_t bsize; - char* bstr; - if (PyBytes_AsStringAndSize(tok->bytes, &bstr, &bsize) == -1) { - return NULL; + if (tok->bytes == NULL) { + return _PyPegen_raise_incomplete_input(p); } + Py_ssize_t bsize = PyBytes_GET_SIZE(tok->bytes); + const char *bstr = PyBytes_AS_STRING(tok->bytes); - // Check if we're inside a raw f-string for format spec decoding - int is_raw = 0; - if (INSIDE_FSTRING(p->tok)) { - tokenizer_mode *mode = TOK_GET_MODE(p->tok); - is_raw = mode->raw; - } + int is_raw = tok->is_raw; PyObject* str = _PyPegen_decode_string(p, is_raw, bstr, bsize, tok); if (str == NULL) { + if ((p->flags & PyPARSE_ALLOW_INCOMPLETE_INPUT) || tok->is_incomplete) { + _Pypegen_raise_decode_error(p); + } return NULL; } + if (tok->is_incomplete) { + Py_DECREF(str); + return _PyPegen_raise_incomplete_input(p); + } if (_PyArena_AddPyObject(p->arena, str) < 0) { Py_DECREF(str); return NULL; @@ -1481,9 +1526,24 @@ expr_ty _PyPegen_decoded_constant_from_token(Parser* p, Token* tok) { } expr_ty _PyPegen_constant_from_token(Parser* p, Token* tok) { - char* bstr = PyBytes_AsString(tok->bytes); - if (bstr == NULL) { - return NULL; + if (tok->bytes == NULL) { + return _PyPegen_raise_incomplete_input(p); + } + const char *bstr = PyBytes_AS_STRING(tok->bytes); + Py_ssize_t bsize = PyBytes_GET_SIZE(tok->bytes); + if (((p->flags & PyPARSE_ALLOW_INCOMPLETE_INPUT) || tok->is_incomplete) && + !tok->is_raw && memchr(bstr, '\\', bsize) != NULL) { + // Check escapes before the string is complete, without emitting warnings. + PyObject *decoded = _PyPegen_decode_string( + p, 0, bstr, bsize, tok->is_incomplete ? tok : NULL); + if (decoded == NULL) { + _Pypegen_raise_decode_error(p); + return NULL; + } + Py_DECREF(decoded); + } + if (tok->is_incomplete) { + return _PyPegen_raise_incomplete_input(p); } PyObject* str = PyUnicode_FromString(bstr); if (str == NULL) { @@ -1499,10 +1559,10 @@ expr_ty _PyPegen_constant_from_token(Parser* p, Token* tok) { } expr_ty _PyPegen_constant_from_string(Parser* p, Token* tok) { - char* the_str = PyBytes_AsString(tok->bytes); - if (the_str == NULL) { - return NULL; + if (tok->bytes == NULL) { + return _PyPegen_raise_incomplete_input(p); } + const char *the_str = PyBytes_AS_STRING(tok->bytes); PyObject *s = _PyPegen_parse_string(p, tok); if (s == NULL) { _Pypegen_raise_decode_error(p); @@ -1540,21 +1600,38 @@ _get_interpolation_conversion(Parser *p, Token *debug, ResultTokenWithMetadata * } static PyObject * -_strip_interpolation_expr(PyObject *exprstr) +_strip_interpolation_debug_expr(PyObject *exprstr) { Py_ssize_t len = PyUnicode_GET_LENGTH(exprstr); - for (Py_ssize_t i = len - 1; i >= 0; i--) { - Py_UCS4 c = PyUnicode_READ_CHAR(exprstr, i); - if (_PyUnicode_IsWhitespace(c) || c == '=') { + /* Discard whitespace and explicit line continuations after the debug "=" + but preserve whitespace before it. */ + while (len > 0) { + int has_newline = 0; + while (len > 0) { + Py_UCS4 c = PyUnicode_READ_CHAR(exprstr, len - 1); + if (!_PyUnicode_IsWhitespace(c)) { + break; + } + if (c == '\r' || c == '\n') { + has_newline = 1; + } len--; } - else { + if (!has_newline || len == 0 || + PyUnicode_READ_CHAR(exprstr, len - 1) != '\\') + { break; } + len--; + } + + /* Preserve unexpected metadata instead of dropping source text. */ + if (len == 0 || PyUnicode_READ_CHAR(exprstr, len - 1) != '=') { + return Py_NewRef(exprstr); } - return PyUnicode_Substring(exprstr, 0, len); + return PyUnicode_Substring(exprstr, 0, len - 1); } expr_ty _PyPegen_interpolation(Parser *p, expr_ty expression, Token *debug, ResultTokenWithMetadata *conversion, @@ -1585,7 +1662,9 @@ expr_ty _PyPegen_interpolation(Parser *p, expr_ty expression, Token *debug, Resu } assert(exprstr != NULL); - PyObject *final_exprstr = _strip_interpolation_expr(exprstr); + PyObject *final_exprstr = debug + ? _strip_interpolation_debug_expr(exprstr) + : Py_NewRef(exprstr); if (!final_exprstr || _PyArena_AddPyObject(arena, final_exprstr) < 0) { Py_XDECREF(final_exprstr); return NULL; @@ -2047,13 +2126,14 @@ _warn_relative_import_of_lazy(Parser *p, asdl_seq *dots, expr_ty module) return -1; } + _PyTokenizer_Info info = _PyTokenizer_GetInfo(p->tok); int res = _PyErr_EmitSyntaxWarning(msg, - p->tok->filename, + info.filename, module->lineno, module->col_offset + 1, module->end_lineno, module->end_col_offset + 1, - p->tok->module); + info.module); Py_DECREF(msg); return res; } @@ -2076,6 +2156,7 @@ _PyPegen_checked_from_import(Parser *p, asdl_seq *dots, expr_ty module_name, alias_ty alias = asdl_seq_GET(names, i); if (PyUnicode_CompareWithASCIIString(alias->name, "barry_as_FLUFL") == 0) { p->flags |= PyPARSE_BARRY_AS_BDFL; + p->tok->barry_as_bdfl = 1; } } } diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index d53886866f54f86..edbb749f5ee231b 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -786,63 +786,124 @@ def visitConstructor(self, cons, name): class AnnotationsVisitor(PickleVisitor): def visitModule(self, mod): + self.nodes = [] + for dfn in mod.dfns: + self.visit(dfn) + builtins = list(dict.fromkeys(builtin_type_to_c_type.values())) self.file.write(textwrap.dedent(''' static int add_ast_annotations(struct ast_state *state) { - bool cond; + enum { + FIELD_OPTIONAL = 1, + FIELD_SEQUENCE = 2, + FIELD_BUILTIN = 4, + }; + PyTypeObject *const builtin_types[] = { ''')) - for dfn in mod.dfns: - self.visit(dfn) - self.file.write(textwrap.dedent(''' + for c_type in builtins: + self.emit(f"&{c_type},", 2) + self.file.write(textwrap.dedent('''\ + }; + // Offsets refer to this interpreter's AST state, not global types. + static_assert(sizeof(struct ast_state) <= UINT16_MAX, + "ast_state offsets must fit in uint16_t"); + static const struct { + uint16_t name_offset; + uint16_t type_offset; // An index into builtin_types for builtins. + uint8_t flags; + } fields[] = { + #''').removesuffix('#')) # Use d-string if it accepted. + for name, fields in self.nodes: + for field in fields: + flags = [] + if field.opt: + flags.append("FIELD_OPTIONAL") + elif field.seq: + flags.append("FIELD_SEQUENCE") + if field.type in builtin_type_to_c_type: + c_type = builtin_type_to_c_type[field.type] + type_offset = str(builtins.index(c_type)) + flags.append("FIELD_BUILTIN") + else: + type_offset = f"offsetof(struct ast_state, {field.type}_type)" + flags = " | ".join(flags) or "0" + self.emit(f"{{offsetof(struct ast_state, {field.name}),", 2) + self.emit(f" {type_offset}, {flags}}},", 2) + self.file.write(textwrap.dedent('''\ + }; + static const struct { + uint16_t type_offset; + uint16_t first_field; + uint16_t nfields; + } nodes[] = { + #''').removesuffix('#')) + start = 0 + for name, fields in self.nodes: + self.emit(f"{{offsetof(struct ast_state, {name}_type), " + f"{start}, {len(fields)}}},", 2) + start += len(fields) + self.file.write(textwrap.dedent('''\ + }; + char *base = (char *)state; + PyObject *annotations = NULL; + for (size_t i = 0; i < Py_ARRAY_LENGTH(nodes); i++) { + annotations = PyDict_New(); + if (annotations == NULL) { + goto error; + } + size_t end = nodes[i].first_field + nodes[i].nfields; + for (size_t j = nodes[i].first_field; j < end; j++) { + PyObject *name = *(PyObject **)(base + fields[j].name_offset); + PyObject *type; + if (fields[j].flags & FIELD_BUILTIN) { + type = (PyObject *)builtin_types[fields[j].type_offset]; + } + else { + type = *(PyObject **)(base + fields[j].type_offset); + } + if (fields[j].flags & FIELD_OPTIONAL) { + type = _Py_union_type_or(type, Py_None); + } + else if (fields[j].flags & FIELD_SEQUENCE) { + type = Py_GenericAlias((PyObject *)&PyList_Type, type); + } + else { + Py_INCREF(type); + } + if (type == NULL) { + goto error; + } + int res = PyDict_SetItem(annotations, name, type); + Py_DECREF(type); + if (res < 0) { + goto error; + } + } + PyObject *node = *(PyObject **)(base + nodes[i].type_offset); + if (PyObject_SetAttrString(node, "_field_types", annotations) < 0 || + PyObject_SetAttrString(node, "__annotations__", annotations) < 0) + { + goto error; + } + Py_CLEAR(annotations); + } return 1; + error: + Py_XDECREF(annotations); + return 0; } ''')) def visitProduct(self, prod, name): - self.emit_annotations(name, prod.fields) + self.nodes.append((name, prod.fields)) def visitSum(self, sum, name): for t in sum.types: self.visitConstructor(t, name) def visitConstructor(self, cons, name): - self.emit_annotations(cons.name, cons.fields) - - def emit_annotations(self, name, fields): - self.emit(f"PyObject *{name}_annotations = PyDict_New();", 1) - self.emit(f"if (!{name}_annotations) return 0;", 1) - for field in fields: - self.emit("{", 1) - if field.type in builtin_type_to_c_type: - self.emit(f"PyObject *type = (PyObject *)&{builtin_type_to_c_type[field.type]};", 2) - else: - self.emit(f"PyObject *type = state->{field.type}_type;", 2) - if field.opt: - self.emit("type = _Py_union_type_or(type, Py_None);", 2) - self.emit("cond = type != NULL;", 2) - self.emit_annotations_error(name, 2) - elif field.seq: - self.emit("type = Py_GenericAlias((PyObject *)&PyList_Type, type);", 2) - self.emit("cond = type != NULL;", 2) - self.emit_annotations_error(name, 2) - else: - self.emit("Py_INCREF(type);", 2) - self.emit(f"cond = PyDict_SetItemString({name}_annotations, \"{field.name}\", type) == 0;", 2) - self.emit("Py_DECREF(type);", 2) - self.emit_annotations_error(name, 2) - self.emit("}", 1) - self.emit(f'cond = PyObject_SetAttrString(state->{name}_type, "_field_types", {name}_annotations) == 0;', 1) - self.emit_annotations_error(name, 1) - self.emit(f'cond = PyObject_SetAttrString(state->{name}_type, "__annotations__", {name}_annotations) == 0;', 1) - self.emit_annotations_error(name, 1) - self.emit(f"Py_DECREF({name}_annotations);", 1) - - def emit_annotations_error(self, name, depth): - self.emit("if (!cond) {", depth) - self.emit(f"Py_DECREF({name}_annotations);", depth + 1) - self.emit("return 0;", depth + 1) - self.emit("}", depth) + self.nodes.append((cons.name, cons.fields)) class PyTypesVisitor(PickleVisitor): @@ -852,7 +913,6 @@ def visitModule(self, mod): typedef struct { PyObject_HEAD - PyObject *dict; } AST_object; static void @@ -862,7 +922,7 @@ def visitModule(self, mod): /* bpo-31095: UnTrack is needed before calling any callbacks */ PyTypeObject *tp = Py_TYPE(self); PyObject_GC_UnTrack(self); - Py_CLEAR(self->dict); + PyObject_ClearManagedDict(op); freefunc free_func = PyType_GetSlot(tp, Py_tp_free); assert(free_func != NULL); free_func(self); @@ -874,15 +934,13 @@ def visitModule(self, mod): { AST_object *self = (AST_object*)op; Py_VISIT(Py_TYPE(self)); - Py_VISIT(self->dict); - return 0; + return PyObject_VisitManagedDict(op, visit, arg); } static int ast_clear(PyObject *op) { - AST_object *self = (AST_object*)op; - Py_CLEAR(self->dict); + PyObject_ClearManagedDict(op); return 0; } @@ -1358,11 +1416,6 @@ def visitModule(self, mod): return result; } -static PyMemberDef ast_type_members[] = { - {"__dictoffset__", Py_T_PYSSIZET, offsetof(AST_object, dict), Py_READONLY}, - {NULL} /* Sentinel */ -}; - static PyMethodDef ast_type_methods[] = { {"__reduce__", ast_type_reduce, METH_NOARGS, NULL}, {"__replace__", _PyCFunction_CAST(ast_type_replace), METH_VARARGS | METH_KEYWORDS, @@ -1480,37 +1533,36 @@ def visitModule(self, mod): return NULL; } - if (depth <= 0) { - return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name); - } - - int status = Py_ReprEnter((PyObject *)self); - if (status != 0) { - if (status < 0) { - return NULL; - } - return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name); - } - - PyObject *fields; - if (PyObject_GetOptionalAttr((PyObject *)Py_TYPE(self), state->_fields, &fields) < 0) { - Py_ReprLeave((PyObject *)self); + PyObject *fields = PyObject_GetAttr((PyObject *)Py_TYPE(self), state->_fields); + if (!fields) { return NULL; } Py_ssize_t numfields = PySequence_Size(fields); if (numfields < 0) { - Py_ReprLeave((PyObject *)self); Py_DECREF(fields); return NULL; } if (numfields == 0) { - Py_ReprLeave((PyObject *)self); Py_DECREF(fields); return PyUnicode_FromFormat("%s()", Py_TYPE(self)->tp_name); } + if (depth <= 0) { + Py_DECREF(fields); + return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name); + } + + int status = Py_ReprEnter((PyObject *)self); + if (status != 0) { + Py_DECREF(fields); + if (status < 0) { + return NULL; + } + return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name); + } + const char* tp_name = Py_TYPE(self)->tp_name; PyUnicodeWriter *writer = PyUnicodeWriter_Create(0); if (writer == NULL) { @@ -1608,7 +1660,6 @@ def visitModule(self, mod): {Py_tp_setattro, PyObject_GenericSetAttr}, {Py_tp_traverse, ast_traverse}, {Py_tp_clear, ast_clear}, - {Py_tp_members, ast_type_members}, {Py_tp_methods, ast_type_methods}, {Py_tp_getset, ast_type_getsets}, {Py_tp_init, ast_type_init}, @@ -1622,7 +1673,8 @@ def visitModule(self, mod): "ast.AST", sizeof(AST_object), 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_MANAGED_DICT, AST_type_slots }; @@ -2122,22 +2174,25 @@ class PartingShots(StaticVisitor): return result; } -/* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */ +/* mode is 0 for "exec", 1 for "eval", 2 for "single" and 3 for "func_type" + input */ int PyAst_CheckMode(PyObject *ast, int mode) { - const char * const req_name[] = {"Module", "Expression", "Interactive"}; + const char * const req_name[] = {"Module", "Expression", "Interactive", + "FunctionType"}; struct ast_state *state = get_ast_state(); if (state == NULL) { return -1; } - PyObject *req_type[3]; + PyObject *req_type[4]; req_type[0] = state->Module_type; req_type[1] = state->Expression_type; req_type[2] = state->Interactive_type; + req_type[3] = state->FunctionType_type; - assert(0 <= mode && mode <= 2); + assert(0 <= mode && mode <= 3); int isinstance = PyObject_IsInstance(ast, req_type[mode]); if (isinstance == -1) { return -1; @@ -2210,9 +2265,15 @@ def generate_ast_fini(module_state, f): struct ast_state *state = &interp->ast; """)) + f.write(" static const size_t offsets[] = {\n") for s in module_state: - f.write(" Py_CLEAR(state->" + s + ');\n') + f.write(" offsetof(struct ast_state, " + s + "),\n") + f.write(" };\n") f.write(textwrap.dedent(""" + for (size_t i = 0; i < Py_ARRAY_LENGTH(offsets); i++) { + PyObject **field = (PyObject **)((char *)state + offsets[i]); + Py_CLEAR(*field); + } state->finalized = 1; state->once = (_PyOnceFlag){0}; } diff --git a/Parser/lexer/buffer.c b/Parser/lexer/buffer.c deleted file mode 100644 index e122fd0d9878ea2..000000000000000 --- a/Parser/lexer/buffer.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "Python.h" -#include "errcode.h" - -#include "state.h" - -/* Traverse and remember all f-string buffers, in order to be able to restore - them after reallocating tok->buf */ -void -_PyLexer_remember_fstring_buffers(struct tok_state *tok) -{ - int index; - tokenizer_mode *mode; - - for (index = tok->tok_mode_stack_index; index >= 0; --index) { - mode = &(tok->tok_mode_stack[index]); - mode->start_offset = mode->start == NULL ? -1 : mode->start - tok->buf; - mode->multi_line_start_offset = mode->multi_line_start == NULL ? -1 : mode->multi_line_start - tok->buf; - } -} - -/* Traverse and restore all f-string buffers after reallocating tok->buf */ -void -_PyLexer_restore_fstring_buffers(struct tok_state *tok) -{ - int index; - tokenizer_mode *mode; - - for (index = tok->tok_mode_stack_index; index >= 0; --index) { - mode = &(tok->tok_mode_stack[index]); - mode->start = mode->start_offset < 0 ? NULL : tok->buf + mode->start_offset; - mode->multi_line_start = mode->multi_line_start_offset < 0 ? NULL : tok->buf + mode->multi_line_start_offset; - } -} - -/* Read a line of text from TOK into S, using the stream in TOK. - Return NULL on failure, else S. - - On entry, tok->decoding_buffer will be one of: - 1) NULL: need to call tok->decoding_readline to get a new line - 2) PyUnicodeObject *: decoding_feof has called tok->decoding_readline and - stored the result in tok->decoding_buffer - 3) PyByteArrayObject *: previous call to tok_readline_recode did not have enough room - (in the s buffer) to copy entire contents of the line read - by tok->decoding_readline. tok->decoding_buffer has the overflow. - In this case, tok_readline_recode is called in a loop (with an expanded buffer) - until the buffer ends with a '\n' (or until the end of the file is - reached): see tok_nextc and its calls to tok_reserve_buf. -*/ -int -_PyLexer_tok_reserve_buf(struct tok_state *tok, Py_ssize_t size) -{ - Py_ssize_t cur = tok->cur - tok->buf; - Py_ssize_t oldsize = tok->inp - tok->buf; - Py_ssize_t newsize = oldsize + Py_MAX(size, oldsize >> 1); - if (newsize > tok->end - tok->buf) { - char *newbuf = tok->buf; - Py_ssize_t start = tok->start == NULL ? -1 : tok->start - tok->buf; - Py_ssize_t line_start = tok->start == NULL ? -1 : tok->line_start - tok->buf; - Py_ssize_t multi_line_start = tok->multi_line_start - tok->buf; - _PyLexer_remember_fstring_buffers(tok); - newbuf = (char *)PyMem_Realloc(newbuf, newsize); - if (newbuf == NULL) { - tok->done = E_NOMEM; - return 0; - } - tok->buf = newbuf; - tok->cur = tok->buf + cur; - tok->inp = tok->buf + oldsize; - tok->end = tok->buf + newsize; - tok->start = start < 0 ? NULL : tok->buf + start; - tok->line_start = line_start < 0 ? NULL : tok->buf + line_start; - tok->multi_line_start = multi_line_start < 0 ? NULL : tok->buf + multi_line_start; - _PyLexer_restore_fstring_buffers(tok); - } - return 1; -} diff --git a/Parser/lexer/buffer.h b/Parser/lexer/buffer.h deleted file mode 100644 index bb218162ff48453..000000000000000 --- a/Parser/lexer/buffer.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _LEXER_BUFFER_H_ -#define _LEXER_BUFFER_H_ - -#include "pyport.h" - -void _PyLexer_remember_fstring_buffers(struct tok_state *tok); -void _PyLexer_restore_fstring_buffers(struct tok_state *tok); -int _PyLexer_tok_reserve_buf(struct tok_state *tok, Py_ssize_t size); - -#endif diff --git a/Parser/lexer/layout.c b/Parser/lexer/layout.c new file mode 100644 index 000000000000000..f503f36f76ff14c --- /dev/null +++ b/Parser/lexer/layout.c @@ -0,0 +1,207 @@ +#include "Python.h" +#include "errcode.h" +#include "pycore_token.h" + +#include "lexer_internal.h" +#include "../tokenizer/helpers.h" +#include "../tokenizer/reader.h" + +#define TABSIZE 8 +#define ALTTABSIZE 1 + +int +_PyLexer_ContinueLine(struct tok_state *tok) +{ + int c = tok_nextc(tok); + if (c == '\r') { + c = tok_nextc(tok); + } + if (c != '\n') { + tok->done = E_LINECONT; + return -1; + } + c = tok_nextc(tok); + if (tok->implicit_newline == _PyTokenizer_APPEND_NEWLINE) { + tok->needs_newline |= _PyTokenizer_NEWLINE_CONTINUATION; + } + if (c == EOF) { + tok->done = E_EOF; + tok->cur = tok->inp; + return -1; + } else { + tok_backup(tok, c); + } + return c; +} + + +static int +update_indentation(struct tok_state *tok, int col, int altcol) +{ + lexer_layout_state *layout = &tok->layout; + if (col == layout->stack[layout->depth].column) { + if (altcol != layout->stack[layout->depth].alternate_column) { + _PyTokenizer_indenterror(tok); + return -1; + } + } + else if (col > layout->stack[layout->depth].column) { + if (layout->depth + 1 >= MAXINDENT) { + tok->done = E_TOODEEP; + tok->cur = tok->inp; + return -1; + } + if (altcol <= layout->stack[layout->depth].alternate_column) { + _PyTokenizer_indenterror(tok); + return -1; + } + layout->pending++; + layout->stack[++layout->depth] = (indentation_level){col, altcol}; + } + else { + while (layout->depth > 0 && + col < layout->stack[layout->depth].column) { + layout->pending--; + layout->depth--; + } + if (col != layout->stack[layout->depth].column) { + tok->done = E_DEDENT; + tok->cur = tok->inp; + return -1; + } + if (altcol != layout->stack[layout->depth].alternate_column) { + _PyTokenizer_indenterror(tok); + return -1; + } + } + return 0; +} + +int +_PyLexer_BeginLine(struct tok_state *tok) +{ + assert(tok->layout.at_bol); + int c; + int blankline = 0; + int col = 0; + int altcol = 0; + tok->layout.at_bol = 0; + int cont_line_col = 0; + for (;;) { + c = tok_nextc(tok); + if (c == ' ') { + col++, altcol++; + } + else if (c == '\t') { + col = (col / TABSIZE + 1) * TABSIZE; + altcol = (altcol / ALTTABSIZE + 1) * ALTTABSIZE; + } + else if (c == '\014') {/* Control-L (formfeed) */ + col = altcol = 0; /* For Emacs users */ + } + else if (c == '\\') { + // Indentation cannot be split over multiple physical lines + // using backslashes. This means that if we found a backslash + // preceded by whitespace, **the first one we find** determines + // the level of indentation of whatever comes next. + cont_line_col = cont_line_col ? cont_line_col : col; + if ((c = _PyLexer_ContinueLine(tok)) == -1) { + return -1; + } + } + else if (c == EOF && PyErr_Occurred()) { + return -1; + } + else { + break; + } + } + tok_backup(tok, c); + if (c == '\n' && tok->implicit_newline == _PyTokenizer_IMPLY_NEWLINE && + tok->level == 0 && (cont_line_col || col)) { + // Without the newline, a whitespace-only line affects indentation. + tok->needs_newline |= _PyTokenizer_NEWLINE_INDENT; + } + if (c == '#' || c == '\n' || c == '\r') { + int interactive = _PyTok_ReaderIsInteractive(tok); + /* Lines with only whitespace and/or comments + shouldn't affect the indentation and are + not passed to the parser as NEWLINE tokens, + except *totally* empty lines in interactive + mode, which signal the end of a command group. */ + if (col == 0 && c == '\n' && interactive) { + blankline = 0; /* Let it through */ + } + else if (interactive && tok->lineno == 1) { + /* In interactive mode, if the first line contains + only spaces and/or a comment, let it through. */ + blankline = 0; + col = altcol = 0; + } + else { + blankline = 1; /* Ignore completely */ + } + } + if (!blankline && tok->level == 0) { + col = cont_line_col ? cont_line_col : col; + altcol = cont_line_col ? cont_line_col : altcol; + if (update_indentation(tok, col, altcol) < 0) { + return -1; + } + } + return blankline; +} + +int +_PyLexer_IndentationToken(struct tok_state *tok, struct token *token) +{ + assert(tok->layout.pending != 0); + _PyTok_Off p_start = -1; + _PyTok_Off p_end = -1; + if (tok->layout.pending < 0) { + if (tok->tok_extra_tokens) { + p_start = tok->cur; + p_end = tok->cur; + } + tok->layout.pending++; + return _PyLexer_token_setup(tok, token, DEDENT, p_start, p_end); + } + else { + if (tok->tok_extra_tokens) { + p_start = tok->buf_offset; + p_end = tok->cur; + } + tok->layout.pending--; + return _PyLexer_token_setup(tok, token, INDENT, p_start, p_end); + } +} + +int +_PyLexer_Newline(struct tok_state *tok, struct token *token, int blankline) +{ + if (!blankline && tok->implicit_newline == _PyTokenizer_IMPLY_NEWLINE) { + // The statement's terminating newline was not in the input. + tok->needs_newline |= _PyTokenizer_NEWLINE_STATEMENT; + } + tok->layout.at_bol = 1; + if (blankline || tok->level > 0) { + if (!tok->tok_extra_tokens) { + return 0; + } + } + else if (!tok->layout.comment_newline || !tok->tok_extra_tokens) { + return _PyLexer_token_setup(tok, token, NEWLINE, + tok->start, tok->cur - 1); + } + tok->layout.comment_newline = 0; + return _PyLexer_token_setup(tok, token, NL, tok->start, tok->cur); +} + +void +_PyLexer_ImplyDedents(struct tok_state *tok) +{ + if (tok->layout.depth != 0) { + tok->layout.pending = -tok->layout.depth; + tok->layout.depth = 0; + } +} diff --git a/Parser/lexer/lexer.c b/Parser/lexer/lexer.c index 41f03a408cfc756..9049a0487c4ac20 100644 --- a/Parser/lexer/lexer.c +++ b/Parser/lexer/lexer.c @@ -5,63 +5,42 @@ #include "lexer_internal.h" #include "../tokenizer/helpers.h" - -/* Alternate tab spacing */ -#define ALTTABSIZE 1 - +#include "../tokenizer/reader.h" #define MAKE_TOKEN(token_type) _PyLexer_token_setup(tok, token, token_type, p_start, p_end) -#define MAKE_TYPE_COMMENT_TOKEN(token_type, col_offset, end_col_offset) (\ - _PyLexer_type_comment_token_setup(tok, token, token_type, col_offset, end_col_offset, p_start, p_end)) /* Spaces in this constant are treated as "zero or more spaces or tabs" when tokenizing. */ static const char* type_comment_prefix = "# type: "; -static inline int -contains_null_bytes(const char* str, size_t size) -{ - return memchr(str, 0, size) != NULL; -} - -/* Get next char, updating state; error code goes into tok->done */ int -_PyLexer_nextc(struct tok_state *tok) +_PyLexer_refill(struct tok_state *tok) { - int rc; - for (;;) { - if (tok->cur != tok->inp) { - if ((unsigned int) tok->col_offset >= (unsigned int) INT_MAX) { - tok->done = E_COLUMNOVERFLOW; - return EOF; - } - tok->col_offset++; - return Py_CHARMASK(*tok->cur++); /* Fast path */ - } - if (tok->done != E_OK) { - return EOF; - } - rc = tok->underflow(tok); + if (tok->done != E_OK) { + return 0; + } + int rc = _PyTok_ReaderUnderflow(tok); #if defined(Py_DEBUG) - if (tok->debug) { - fprintf(stderr, "line[%d] = ", tok->lineno); - _PyTokenizer_print_escape(stderr, tok->cur, tok->inp - tok->cur); - fprintf(stderr, " tok->done = %d\n", tok->done); - } + if (tok->debug) { + fprintf(stderr, "line[%d] = ", tok->lineno); + _PyTokenizer_print_escape( + stderr, _PyTok_SourcePointer(&tok->source, tok->cur), + tok->inp - tok->cur); + fprintf(stderr, " tok->done = %d\n", tok->done); + } #endif - if (!rc) { - tok->cur = tok->inp; - return EOF; - } - tok->line_start = tok->cur; - - if (contains_null_bytes(tok->line_start, tok->inp - tok->line_start)) { - _PyTokenizer_syntaxerror(tok, "source code cannot contain null bytes"); - tok->cur = tok->inp; - return EOF; - } + if (!rc) { + tok->cur = tok->inp; + return 0; } - Py_UNREACHABLE(); + tok->line_start = tok->cur; + _PyTok_Span line = {tok->line_start, tok->inp}; + if (_PyTok_SourceFindByte(&tok->source, line, '\0') >= 0) { + _PyTokenizer_syntaxerror(tok, "source code cannot contain null bytes"); + tok->cur = tok->inp; + return 0; + } + return 1; } /* Back-up one character */ @@ -69,13 +48,12 @@ void _PyLexer_backup(struct tok_state *tok, int c) { if (c != EOF) { - if (--tok->cur < tok->buf) { + if (--tok->cur < tok->buf_offset) { Py_FatalError("tokenizer beginning of buffer"); } - if ((int)(unsigned char)*tok->cur != Py_CHARMASK(c)) { + if (_PyTok_SourceByte(&tok->source, tok->cur) != Py_CHARMASK(c)) { Py_FatalError("tok_backup: wrong character"); } - tok->col_offset--; } } @@ -89,9 +67,10 @@ verify_identifier(struct tok_state *tok) return 1; } PyObject *s; - if (tok->decoding_erred) + if (tok_failed(tok)) return 0; - s = PyUnicode_DecodeUTF8(tok->start, tok->cur - tok->start, NULL); + s = PyUnicode_DecodeUTF8(_PyTok_SourcePointer(&tok->source, tok->start), + tok->cur - tok->start, NULL); if (s == NULL) { if (PyErr_ExceptionMatches(PyExc_UnicodeDecodeError)) { tok->done = E_DECODE; @@ -106,6 +85,7 @@ verify_identifier(struct tok_state *tok) assert(PyUnicode_GET_LENGTH(s) > 0); if (invalid < PyUnicode_GET_LENGTH(s)) { Py_UCS4 ch = PyUnicode_READ_CHAR(s, invalid); + _PyTok_Off error_cursor = tok->cur; if (invalid + 1 < PyUnicode_GET_LENGTH(s)) { /* Determine the offset in UTF-8 encoded input */ Py_SETREF(s, PyUnicode_Substring(s, 0, invalid + 1)); @@ -116,14 +96,20 @@ verify_identifier(struct tok_state *tok) tok->done = E_ERROR; return 0; } - tok->cur = (char *)tok->start + PyBytes_GET_SIZE(s); + error_cursor = tok->start + PyBytes_GET_SIZE(s); } Py_DECREF(s); if (Py_UNICODE_ISPRINTABLE(ch)) { - _PyTokenizer_syntaxerror(tok, "invalid character '%c' (U+%04X)", ch, ch); + _PyTokenizer_syntaxerror_at( + tok, _PyTok_SourcePointer(&tok->source, tok->line_start), + error_cursor - tok->line_start, tok->lineno, -1, -1, + "invalid character '%c' (U+%04X)", ch, ch); } else { - _PyTokenizer_syntaxerror(tok, "invalid non-printable character U+%04X", ch); + _PyTokenizer_syntaxerror_at( + tok, _PyTok_SourcePointer(&tok->source, tok->line_start), + error_cursor - tok->line_start, tok->lineno, -1, -1, + "invalid non-printable character U+%04X", ch); } return 0; } @@ -131,165 +117,36 @@ verify_identifier(struct tok_state *tok) return 1; } - - -static inline int -tok_continuation_line(struct tok_state *tok) { - int c = tok_nextc(tok); - if (c == '\r') { - c = tok_nextc(tok); - } - if (c != '\n') { - tok->done = E_LINECONT; - return -1; - } - c = tok_nextc(tok); - if (c == EOF) { - tok->done = E_EOF; - tok->cur = tok->inp; - return -1; - } else { - tok_backup(tok, c); - } - return c; -} - - - int -_PyLexer_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct token *token) +_PyLexer_get_normal(struct tok_state *tok, ftstring_state *current, struct token *token) { + assert(current == NULL || + (current->mode == FTSTRING_MODE_EXPRESSION && + current->replacement_depth > 0)); int c; int blankline, nonascii; - const char *p_start = NULL; - const char *p_end = NULL; + _PyTok_Off p_start = -1; + _PyTok_Off p_end = -1; nextline: - tok->start = NULL; - tok->starting_col_offset = -1; + tok->start = -1; + tok->start_loc = (_PyTok_Loc){tok->lineno, -1}; blankline = 0; - /* Get indentation level */ - if (tok->atbol) { - int col = 0; - int altcol = 0; - tok->atbol = 0; - int cont_line_col = 0; - for (;;) { - c = tok_nextc(tok); - if (c == ' ') { - col++, altcol++; - } - else if (c == '\t') { - col = (col / tok->tabsize + 1) * tok->tabsize; - altcol = (altcol / ALTTABSIZE + 1) * ALTTABSIZE; - } - else if (c == '\014') {/* Control-L (formfeed) */ - col = altcol = 0; /* For Emacs users */ - } - else if (c == '\\') { - // Indentation cannot be split over multiple physical lines - // using backslashes. This means that if we found a backslash - // preceded by whitespace, **the first one we find** determines - // the level of indentation of whatever comes next. - cont_line_col = cont_line_col ? cont_line_col : col; - if ((c = tok_continuation_line(tok)) == -1) { - return MAKE_TOKEN(ERRORTOKEN); - } - } - else if (c == EOF && PyErr_Occurred()) { - return MAKE_TOKEN(ERRORTOKEN); - } - else { - break; - } - } - tok_backup(tok, c); - if (c == '#' || c == '\n' || c == '\r') { - /* Lines with only whitespace and/or comments - shouldn't affect the indentation and are - not passed to the parser as NEWLINE tokens, - except *totally* empty lines in interactive - mode, which signal the end of a command group. */ - if (col == 0 && c == '\n' && tok->prompt != NULL) { - blankline = 0; /* Let it through */ - } - else if (tok->prompt != NULL && tok->lineno == 1) { - /* In interactive mode, if the first line contains - only spaces and/or a comment, let it through. */ - blankline = 0; - col = altcol = 0; - } - else { - blankline = 1; /* Ignore completely */ - } - /* We can't jump back right here since we still - may need to skip to the end of a comment */ - } - if (!blankline && tok->level == 0) { - col = cont_line_col ? cont_line_col : col; - altcol = cont_line_col ? cont_line_col : altcol; - if (col == tok->indstack[tok->indent]) { - /* No change */ - if (altcol != tok->altindstack[tok->indent]) { - return MAKE_TOKEN(_PyTokenizer_indenterror(tok)); - } - } - else if (col > tok->indstack[tok->indent]) { - /* Indent -- always one */ - if (tok->indent+1 >= MAXINDENT) { - tok->done = E_TOODEEP; - tok->cur = tok->inp; - return MAKE_TOKEN(ERRORTOKEN); - } - if (altcol <= tok->altindstack[tok->indent]) { - return MAKE_TOKEN(_PyTokenizer_indenterror(tok)); - } - tok->pendin++; - tok->indstack[++tok->indent] = col; - tok->altindstack[tok->indent] = altcol; - } - else /* col < tok->indstack[tok->indent] */ { - /* Dedent -- any number, must be consistent */ - while (tok->indent > 0 && - col < tok->indstack[tok->indent]) { - tok->pendin--; - tok->indent--; - } - if (col != tok->indstack[tok->indent]) { - tok->done = E_DEDENT; - tok->cur = tok->inp; - return MAKE_TOKEN(ERRORTOKEN); - } - if (altcol != tok->altindstack[tok->indent]) { - return MAKE_TOKEN(_PyTokenizer_indenterror(tok)); - } - } + if (tok->layout.at_bol) { + blankline = _PyLexer_BeginLine(tok); + if (blankline < 0) { + return MAKE_TOKEN(ERRORTOKEN); } } tok->start = tok->cur; - tok->starting_col_offset = tok->col_offset; + tok->start_loc = (_PyTok_Loc){ + tok->lineno, tok->line_start >= 0 ? _PyLexer_ByteColumn(tok) : -1}; - /* Return pending indents/dedents */ - if (tok->pendin != 0) { - if (tok->pendin < 0) { - if (tok->tok_extra_tokens) { - p_start = tok->cur; - p_end = tok->cur; - } - tok->pendin++; - return MAKE_TOKEN(DEDENT); - } - else { - if (tok->tok_extra_tokens) { - p_start = tok->buf; - p_end = tok->cur; - } - tok->pendin--; - return MAKE_TOKEN(INDENT); - } + if (tok->layout.pending != 0) { + return _PyLexer_IndentationToken(tok, token); } /* Peek ahead at the next character */ @@ -297,44 +154,50 @@ _PyLexer_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, str tok_backup(tok, c); again: - tok->start = NULL; + tok->start = -1; /* Skip spaces */ do { c = tok_nextc(tok); } while (c == ' ' || c == '\t' || c == '\014'); /* Set start of current token */ - tok->start = tok->cur == NULL ? NULL : tok->cur - 1; - tok->starting_col_offset = tok->col_offset - 1; + tok->start = tok->cur - 1; + tok->start_loc = (_PyTok_Loc){ + tok->lineno, tok->line_start >= 0 ? _PyLexer_ByteColumn(tok) - 1 : -1}; /* Skip comment, unless it's a type comment */ if (c == '#') { - const char* p = NULL; - const char *prefix, *type_start; - int current_starting_col_offset; - while (c != EOF && c != '\n' && c != '\r') { c = tok_nextc(tok); } - if (tok->tok_extra_tokens) { - p = tok->start; + if (current != NULL) { + _PyTok_Off comment_end = tok->cur; + if (c == '\n' || c == '\r') { + comment_end--; + } + if (_PyLexer_record_ftstring_comment( + tok, current, tok->start, comment_end) < 0) { + tok->done = E_NOMEM; + return MAKE_TOKEN(ERRORTOKEN); + } } + _PyTok_Off comment = tok->start; if (tok->type_comments) { - p = tok->start; - current_starting_col_offset = tok->starting_col_offset; - prefix = type_comment_prefix; - while (*prefix && p < tok->cur) { + const char *prefix = type_comment_prefix; + while (*prefix && comment < tok->cur) { if (*prefix == ' ') { - while (*p == ' ' || *p == '\t') { - p++; - current_starting_col_offset++; + while (comment < tok->cur) { + int ch = _PyTok_SourceByte(&tok->source, comment); + if (ch != ' ' && ch != '\t') { + break; + } + comment++; } - } else if (*prefix == *p) { - p++; - current_starting_col_offset++; + } else if (*prefix == _PyTok_SourceByte(&tok->source, comment)) { + comment++; } else { break; } @@ -344,43 +207,44 @@ _PyLexer_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, str /* This is a type comment if we matched all of type_comment_prefix. */ if (!*prefix) { - int is_type_ignore = 1; - // +6 in order to skip the word 'ignore' - const char *ignore_end = p + 6; - const int ignore_end_col_offset = current_starting_col_offset + 6; tok_backup(tok, c); /* don't eat the newline or EOF */ - - type_start = p; - /* A TYPE_IGNORE is "type: ignore" followed by the end of the token * or anything ASCII and non-alphanumeric. */ - is_type_ignore = ( - tok->cur >= ignore_end && memcmp(p, "ignore", 6) == 0 - && !(tok->cur > ignore_end - && ((unsigned char)ignore_end[0] >= 128 || Py_ISALNUM(ignore_end[0])))); - - if (is_type_ignore) { - p_start = ignore_end; - p_end = tok->cur; - - /* If this type ignore is the only thing on the line, consume the newline also. */ - if (blankline) { - tok_nextc(tok); - tok->atbol = 1; - } - return MAKE_TYPE_COMMENT_TOKEN(TYPE_IGNORE, ignore_end_col_offset, tok->col_offset); - } else { - p_start = type_start; - p_end = tok->cur; - return MAKE_TYPE_COMMENT_TOKEN(TYPE_COMMENT, current_starting_col_offset, tok->col_offset); + int is_type_ignore = tok->cur - comment >= 6 && + memcmp(_PyTok_SourcePointer(&tok->source, comment), + "ignore", 6) == 0; + if (is_type_ignore && comment + 6 < tok->cur) { + int ch = _PyTok_SourceByte(&tok->source, comment + 6); + is_type_ignore = ch < 128 && !Py_ISALNUM(ch); + } + + int type = is_type_ignore ? TYPE_IGNORE : TYPE_COMMENT; + p_start = comment + (is_type_ignore ? 6 : 0); + p_end = tok->cur; + int start_col_offset = tok->start_loc.byte_col + + (int)(p_start - tok->start); + /* Consume the newline after a standalone type ignore. */ + if (is_type_ignore && blankline) { + tok_nextc(tok); + tok->layout.at_bol = 1; } + _PyLexer_token_setup(tok, token, type, p_start, p_end); + token->start_loc = (_PyTok_Loc){tok->lineno, start_col_offset}; + token->end_loc = (_PyTok_Loc){tok->lineno, + _PyLexer_ByteColumn(tok)}; + return type; } } + if (tok->implicit_newline == _PyTokenizer_IMPLY_NEWLINE && + tok->layout.depth > 0) { + // Ending this comment lets the next line dedent the suite. + tok->needs_newline |= _PyTokenizer_NEWLINE_STATEMENT; + } if (tok->tok_extra_tokens) { tok_backup(tok, c); /* don't eat the newline or EOF */ - p_start = p; + p_start = comment; p_end = tok->cur; - tok->comment_newline = blankline; + tok->layout.comment_newline = blankline; return MAKE_TOKEN(COMMENT); } } @@ -435,7 +299,10 @@ _PyLexer_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, str // Handle valid f or t string creation: if (saw_f || saw_t) { - return _PyLexer_scan_fstring_start(tok, token, c); + ftstring_kind kind = saw_t + ? (saw_r ? RAW_TSTRING : TSTRING) + : (saw_r ? RAW_FSTRING : FSTRING); + return _PyLexer_scan_fstring_start(tok, token, c, kind); } return _PyLexer_scan_string(tok, token, c); } @@ -461,30 +328,12 @@ _PyLexer_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, str c = tok_nextc(tok); } - /* Newline */ if (c == '\n') { - tok->atbol = 1; - if (blankline || tok->level > 0) { - if (tok->tok_extra_tokens) { - if (tok->comment_newline) { - tok->comment_newline = 0; - } - p_start = tok->start; - p_end = tok->cur; - return MAKE_TOKEN(NL); - } + int type = _PyLexer_Newline(tok, token, blankline); + if (type == 0) { goto nextline; } - if (tok->comment_newline && tok->tok_extra_tokens) { - tok->comment_newline = 0; - p_start = tok->start; - p_end = tok->cur; - return MAKE_TOKEN(NL); - } - p_start = tok->start; - p_end = tok->cur - 1; /* Leave '\n' out of the string */ - tok->cont_line = 0; - return MAKE_TOKEN(NEWLINE); + return type; } /* Period or number starting with period? */ @@ -525,44 +374,30 @@ _PyLexer_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, str /* Line continuation */ if (c == '\\') { - if ((c = tok_continuation_line(tok)) == -1) { + if ((c = _PyLexer_ContinueLine(tok)) == -1) { return MAKE_TOKEN(ERRORTOKEN); } - tok->cont_line = 1; goto again; /* Read next line */ } /* Punctuation character */ - int is_punctuation = (c == ':' || c == '}' || c == '!' || c == '{'); - if (is_punctuation && INSIDE_FSTRING(tok) && INSIDE_FSTRING_EXPR(current_tok)) { - /* This code block gets executed before the curly_bracket_depth is incremented - * by the `{` case, so for ensuring that we are on the 0th level, we need - * to adjust it manually */ - int cursor = current_tok->curly_bracket_depth - (c != '{'); - int in_format_spec = current_tok->in_format_spec; - int cursor_in_format_with_debug = - cursor == 1 && (current_tok->in_debug || in_format_spec); - int cursor_valid = cursor == 0 || cursor_in_format_with_debug; - if ((cursor_valid) && !_PyLexer_update_ftstring_expr(tok, c)) { - return MAKE_TOKEN(ENDMARKER); - } - if ((cursor_valid) && c != '{' && _PyLexer_set_ftstring_expr(tok, token, c)) { + int is_punctuation = (c == ':' || c == '}' || c == '!'); + if (is_punctuation && current != NULL) { + int type = _PyLexer_ftstring_punctuation(tok, current, token, c); + if (type < 0) { return MAKE_TOKEN(ERRORTOKEN); } - - if (c == ':' && cursor == current_tok->curly_bracket_expr_start_depth) { - current_tok->kind = TOK_FSTRING_MODE; - current_tok->in_format_spec = 1; + if (type != 0) { p_start = tok->start; p_end = tok->cur; - return MAKE_TOKEN(_PyToken_OneChar(c)); + return MAKE_TOKEN(type); } } /* Check for two-character token */ { int c2 = tok_nextc(tok); - int current_token = _PyToken_TwoChars(c, c2); + int current_token = _PyToken_TwoChars(c, c2, tok->barry_as_bdfl); if (current_token != OP) { int c3 = tok_nextc(tok); int current_token3 = _PyToken_ThreeChars(c, c2, c3); @@ -591,16 +426,20 @@ _PyLexer_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, str tok->parenlinenostack[tok->level] = tok->lineno; tok->parencolstack[tok->level] = (int)(tok->start - tok->line_start); tok->level++; - if (INSIDE_FSTRING(tok)) { - current_tok->curly_bracket_depth++; - } break; case ')': case ']': case '}': - if (INSIDE_FSTRING(tok) && !current_tok->curly_bracket_depth && c == '}') { - return MAKE_TOKEN(_PyTokenizer_syntaxerror(tok, - "%c-string: single '}' is not allowed", TOK_GET_STRING_PREFIX(tok))); + if (current != NULL && + _PyLexer_FTStringBracketDepth(tok, current) == 0) { + if (c == '}') { + return MAKE_TOKEN(_PyTokenizer_syntaxerror(tok, + "%c-string: single '}' is not allowed", + _PyLexer_StringPrefix(current->kind))); + } + return MAKE_TOKEN(_PyTokenizer_syntaxerror( + tok, "%c-string: unmatched '%c'", + _PyLexer_StringPrefix(current->kind), c)); } if (!tok->tok_extra_tokens && !tok->level) { return MAKE_TOKEN(_PyTokenizer_syntaxerror(tok, "unmatched '%c'", c)); @@ -608,23 +447,25 @@ _PyLexer_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, str if (tok->level > 0) { tok->level--; int opening = tok->parenstack[tok->level]; - if (!tok->tok_extra_tokens && !((opening == '(' && c == ')') || - (opening == '[' && c == ']') || - (opening == '{' && c == '}'))) { - /* If the opening bracket belongs to an f-string's expression - part (e.g. f"{)}") and the closing bracket is an arbitrary - nested expression, then instead of matching a different - syntactical construct with it; we'll throw an unmatched - parentheses error. */ - if (INSIDE_FSTRING(tok) && opening == '{') { - assert(current_tok->curly_bracket_depth >= 0); - int previous_bracket = current_tok->curly_bracket_depth - 1; - if (previous_bracket == current_tok->curly_bracket_expr_start_depth) { + if (!((opening == '(' && c == ')') || + (opening == '[' && c == ']') || + (opening == '{' && c == '}'))) { + /* Do not match a closer against the brace that opened the + * current replacement field. The f-string state relies on + * that brace, so this is checked even with extra tokens. */ + if (current != NULL && opening == '{') { + int bracket_depth = + _PyLexer_FTStringBracketDepth(tok, current); + if (bracket_depth == current->replacement_depth - 1) { return MAKE_TOKEN(_PyTokenizer_syntaxerror(tok, - "%c-string: unmatched '%c'", TOK_GET_STRING_PREFIX(tok), c)); + "%c-string: unmatched '%c'", + _PyLexer_StringPrefix(current->kind), c)); } } - if (tok->parenlinenostack[tok->level] != tok->lineno) { + if (tok->tok_extra_tokens) { + /* Allow other mismatched brackets. */ + } + else if (tok->parenlinenostack[tok->level] != tok->lineno) { return MAKE_TOKEN(_PyTokenizer_syntaxerror(tok, "closing parenthesis '%c' does not match " "opening parenthesis '%c' on line %d", @@ -638,19 +479,9 @@ _PyLexer_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, str } } } - - if (INSIDE_FSTRING(tok)) { - current_tok->curly_bracket_depth--; - if (current_tok->curly_bracket_depth < 0) { - return MAKE_TOKEN(_PyTokenizer_syntaxerror(tok, "%c-string: unmatched '%c'", - TOK_GET_STRING_PREFIX(tok), c)); - } - if (c == '}' && current_tok->curly_bracket_depth == current_tok->curly_bracket_expr_start_depth) { - current_tok->curly_bracket_expr_start_depth--; - current_tok->kind = TOK_FSTRING_MODE; - current_tok->in_format_spec = 0; - current_tok->in_debug = 0; - } + if (current != NULL && + _PyLexer_close_ftstring_expr(tok, current, c) < 0) { + return MAKE_TOKEN(ERRORTOKEN); } break; default: @@ -661,8 +492,8 @@ _PyLexer_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, str return MAKE_TOKEN(_PyTokenizer_syntaxerror(tok, "invalid non-printable character U+%04X", c)); } - if( c == '=' && INSIDE_FSTRING_EXPR_AT_TOP(current_tok)) { - current_tok->in_debug = 1; + if (c == '=' && current != NULL) { + _PyLexer_mark_ftstring_debug(tok, current); } /* Punctuation character */ @@ -672,24 +503,30 @@ _PyLexer_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, str } -static int -tok_get(struct tok_state *tok, struct token *token) -{ - tokenizer_mode *current_tok = TOK_GET_MODE(tok); - if (current_tok->kind == TOK_REGULAR_MODE) { - return _PyLexer_get_normal_mode(tok, current_tok, token); - } else { - return _PyLexer_get_fstring_mode(tok, current_tok, token); - } -} - -int +void _PyTokenizer_Get(struct tok_state *tok, struct token *token) { - int result = tok_get(tok, token); - if (tok->decoding_erred) { + _PyToken_Free(token); + ftstring_state *current = _PyLexer_CurrentFTString(tok); + int result; + if (current == NULL) { + result = _PyLexer_get_normal(tok, NULL, token); + } + else { + switch (current->mode) { + case FTSTRING_MODE_EXPRESSION: + result = _PyLexer_get_normal(tok, current, token); + break; + case FTSTRING_MODE_MIDDLE: + case FTSTRING_MODE_FORMAT_SPEC: + result = _PyLexer_get_ftstring(tok, current, token); + break; + default: + Py_UNREACHABLE(); + } + } + if (tok_failed(tok) && tok->done != E_INCOMPLETE) { result = ERRORTOKEN; - tok->done = E_DECODE; } - return result; + token->type = result; } diff --git a/Parser/lexer/lexer.h b/Parser/lexer/lexer.h deleted file mode 100644 index 1d97ac57b745b09..000000000000000 --- a/Parser/lexer/lexer.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _PY_LEXER_LEXER_H_ -#define _PY_LEXER_LEXER_H_ - -#include "state.h" - -int _PyLexer_update_ftstring_expr(struct tok_state *tok, char cur); - -int _PyTokenizer_Get(struct tok_state *, struct token *); - -#endif diff --git a/Parser/lexer/lexer_internal.h b/Parser/lexer/lexer_internal.h index c6d3b9045c72921..922a23bd97ef620 100644 --- a/Parser/lexer/lexer_internal.h +++ b/Parser/lexer/lexer_internal.h @@ -1,7 +1,8 @@ #ifndef _PY_LEXER_INTERNAL_H_ #define _PY_LEXER_INTERNAL_H_ -#include "lexer.h" +#include "errcode.h" +#include "state.h" #define is_potential_identifier_start(c) (\ (c >= 'a' && c <= 'z')\ @@ -16,42 +17,56 @@ || c == '_'\ || (c >= 128)) -#ifdef Py_DEBUG -static inline tokenizer_mode * -TOK_GET_MODE(struct tok_state *tok) -{ - assert(tok->tok_mode_stack_index >= 0); - assert(tok->tok_mode_stack_index < MAXFSTRINGLEVEL); - return &tok->tok_mode_stack[tok->tok_mode_stack_index]; -} +#define FTSTRING_MIDDLE(state) \ + (_PyLexer_IsTString((state)->kind) ? TSTRING_MIDDLE : FSTRING_MIDDLE) +#define FTSTRING_END(state) \ + (_PyLexer_IsTString((state)->kind) ? TSTRING_END : FSTRING_END) +#define tok_backup _PyLexer_backup -static inline tokenizer_mode * -TOK_NEXT_MODE(struct tok_state *tok) +static inline int +tok_failed(const struct tok_state *tok) { - assert(tok->tok_mode_stack_index >= 0); - assert(tok->tok_mode_stack_index + 1 < MAXFSTRINGLEVEL); - return &tok->tok_mode_stack[++tok->tok_mode_stack_index]; + return tok->done != E_OK && tok->done != E_EOF && + tok->done != E_INTERACT_STOP; } -#else -#define TOK_GET_MODE(tok) (&(tok)->tok_mode_stack[(tok)->tok_mode_stack_index]) -#define TOK_NEXT_MODE(tok) (&(tok)->tok_mode_stack[++(tok)->tok_mode_stack_index]) -#endif -#define FTSTRING_MIDDLE(tok_mode) ((tok_mode)->string_kind == TSTRING ? TSTRING_MIDDLE : FSTRING_MIDDLE) -#define FTSTRING_END(tok_mode) ((tok_mode)->string_kind == TSTRING ? TSTRING_END : FSTRING_END) -#define TOK_GET_STRING_PREFIX(tok) (TOK_GET_MODE(tok)->string_kind == TSTRING ? 't' : 'f') +int _PyLexer_refill(struct tok_state *); -#define tok_nextc _PyLexer_nextc -#define tok_backup _PyLexer_backup +static inline int +tok_nextc(struct tok_state *tok) +{ + while (tok->cur == tok->inp) { + if (!_PyLexer_refill(tok)) { + return EOF; + } + } + if (tok->cur - tok->line_start >= INT_MAX) { + tok->done = E_COLUMNOVERFLOW; + return EOF; + } + return _PyTok_SourceByte(&tok->source, tok->cur++); +} -int _PyLexer_nextc(struct tok_state *); +/* Return -1 on error, otherwise whether the line is blank. */ +int _PyLexer_BeginLine(struct tok_state *); +int _PyLexer_ContinueLine(struct tok_state *); +int _PyLexer_IndentationToken(struct tok_state *, struct token *); +/* Return zero when the newline is suppressed, otherwise its token type. */ +int _PyLexer_Newline(struct tok_state *, struct token *, int); void _PyLexer_backup(struct tok_state *, int); -int _PyLexer_set_ftstring_expr(struct tok_state *, struct token *, char); +int _PyLexer_record_ftstring_comment( + struct tok_state *, ftstring_state *, _PyTok_Off, _PyTok_Off); +int _PyLexer_ftstring_punctuation( + struct tok_state *, ftstring_state *, struct token *, int); +int _PyLexer_close_ftstring_expr( + struct tok_state *, ftstring_state *, int); +void _PyLexer_mark_ftstring_debug(struct tok_state *, ftstring_state *); int _PyLexer_check_string_prefixes(struct tok_state *, int, int, int, int, int); int _PyLexer_scan_number(struct tok_state *, struct token *, int, int); -int _PyLexer_scan_fstring_start(struct tok_state *, struct token *, int); +int _PyLexer_scan_fstring_start( + struct tok_state *, struct token *, int, ftstring_kind); int _PyLexer_scan_string(struct tok_state *, struct token *, int); -int _PyLexer_get_normal_mode(struct tok_state *, tokenizer_mode *, struct token *); -int _PyLexer_get_fstring_mode(struct tok_state *, tokenizer_mode *, struct token *); +int _PyLexer_get_normal(struct tok_state *, ftstring_state *, struct token *); +int _PyLexer_get_ftstring(struct tok_state *, ftstring_state *, struct token *); #endif diff --git a/Parser/lexer/number.c b/Parser/lexer/number.c index 8bca8cbb9adfe5e..220952a69cd69e8 100644 --- a/Parser/lexer/number.c +++ b/Parser/lexer/number.c @@ -113,8 +113,8 @@ int _PyLexer_scan_number(struct tok_state *tok, struct token *token, int c, int leading_dot) { - const char *p_start = NULL; - const char *p_end = NULL; + _PyTok_Off p_start = -1; + _PyTok_Off p_end = -1; if (leading_dot) { goto fraction; @@ -214,7 +214,7 @@ _PyLexer_scan_number(struct tok_state *tok, struct token *token, int c, } c = tok_nextc(tok); } - char* zeros_end = tok->cur; + _PyTok_Off zeros_end = tok->cur; if (Py_ISDIGIT(c)) { nonzero = 1; c = tok_decimal_tail(tok); diff --git a/Parser/lexer/state.c b/Parser/lexer/state.c index 5cf9b4d768c3ebb..33d334f98fe3739 100644 --- a/Parser/lexer/state.c +++ b/Parser/lexer/state.c @@ -1,156 +1,100 @@ #include "Python.h" -#include "pycore_pystate.h" #include "pycore_token.h" #include "errcode.h" #include "state.h" +#include "../tokenizer/helpers.h" +#include "../tokenizer/reader.h" -/* Never change this */ -#define TABSIZE 8 - -/* Create and initialize a new tok_state structure */ -struct tok_state * -_PyTokenizer_tok_new(void) +ftstring_state * +_PyLexer_PushFTString(struct tok_state *tok) { - struct tok_state *tok = (struct tok_state *)PyMem_Calloc( - 1, - sizeof(struct tok_state)); - if (tok == NULL) { - PyErr_NoMemory(); + assert(tok->ftstring_depth >= 0 && tok->ftstring_depth <= tok->ftstring_capacity); + int next_depth = tok->ftstring_depth + 1; + if (next_depth >= MAXFTSTRINGLEVEL) { + _PyTokenizer_syntaxerror( + tok, "too many nested f-strings or t-strings"); return NULL; } - - tok->buf = tok->cur = tok->inp = NULL; - tok->fp_interactive = 0; - tok->interactive_src_start = NULL; - tok->interactive_src_end = NULL; - tok->start = NULL; - tok->end = NULL; - tok->done = E_OK; - tok->fp = NULL; - tok->input = NULL; - tok->tabsize = TABSIZE; - tok->indent = 0; - tok->indstack[0] = 0; - tok->atbol = 1; - tok->pendin = 0; - tok->prompt = tok->nextprompt = NULL; - tok->lineno = 0; - tok->starting_col_offset = -1; - tok->col_offset = -1; - tok->level = 0; - tok->altindstack[0] = 0; - tok->decoding_state = STATE_INIT; - tok->decoding_erred = 0; - tok->enc = NULL; - tok->encoding = NULL; - tok->cont_line = 0; - tok->filename = NULL; - tok->module = NULL; - tok->decoding_readline = NULL; - tok->decoding_buffer = NULL; - tok->readline = NULL; - tok->type_comments = 0; - tok->interactive_underflow = IUNDERFLOW_NORMAL; - tok->underflow = NULL; - tok->str = NULL; - tok->report_warnings = 1; - tok->tok_extra_tokens = 0; - tok->comment_newline = 0; - tok->implicit_newline = 0; - tok->tok_mode_stack[0] = (tokenizer_mode){.kind =TOK_REGULAR_MODE, .quote='\0', .quote_size = 0, .in_debug=0}; - tok->tok_mode_stack_index = 0; -#ifdef Py_DEBUG - tok->debug = _Py_GetConfig()->parser_debug; -#endif - return tok; + if (tok->ftstring_depth == tok->ftstring_capacity) { + int capacity = Py_MIN(Py_MAX(tok->ftstring_capacity * 2, 4), + MAXFTSTRINGLEVEL); + size_t size = (size_t)capacity * sizeof(*tok->ftstring_stack); + ftstring_state *stack; + if (tok->ftstring_stack == tok->ftstring_stack_inline) { + stack = PyMem_Malloc(size); + if (stack != NULL) { + memcpy(stack, tok->ftstring_stack, + (size_t)tok->ftstring_depth * sizeof(*stack)); + } + } + else { + stack = PyMem_Realloc(tok->ftstring_stack, size); + } + if (stack == NULL) { + PyErr_NoMemory(); + tok->done = E_NOMEM; + return NULL; + } + tok->ftstring_stack = stack; + tok->ftstring_capacity = capacity; + } + ftstring_state *state = &tok->ftstring_stack[tok->ftstring_depth]; + tok->ftstring_depth = next_depth; + *state = (ftstring_state){0}; + return state; } -static void -free_fstring_expressions(struct tok_state *tok) +void +_PyLexer_PopFTString(struct tok_state *tok) { - int index; - tokenizer_mode *mode; - - for (index = tok->tok_mode_stack_index; index >= 0; --index) { - mode = &(tok->tok_mode_stack[index]); - if (mode->last_expr_buffer != NULL) { - PyMem_Free(mode->last_expr_buffer); - mode->last_expr_buffer = NULL; - mode->last_expr_size = 0; - mode->last_expr_end = -1; - mode->in_format_spec = 0; - } - } + ftstring_state *state = _PyLexer_CurrentFTString(tok); + assert(state != NULL); + PyMem_Free(state->comments); + tok->ftstring_depth--; } /* Free a tok_state structure */ void _PyTokenizer_Free(struct tok_state *tok) { - if (tok->encoding != NULL) { - PyMem_Free(tok->encoding); - } - Py_XDECREF(tok->decoding_readline); - Py_XDECREF(tok->decoding_buffer); - Py_XDECREF(tok->readline); Py_XDECREF(tok->filename); Py_XDECREF(tok->module); - if ((tok->readline != NULL || tok->fp != NULL ) && tok->buf != NULL) { - PyMem_Free(tok->buf); - } - if (tok->input) { - PyMem_Free(tok->input); + _PyTok_ReaderFree(tok); + _PyTok_SourceClear(&tok->source); + for (int i = 0; i < tok->ftstring_depth; i++) { + PyMem_Free(tok->ftstring_stack[i].comments); } - if (tok->interactive_src_start != NULL) { - PyMem_Free(tok->interactive_src_start); + if (tok->ftstring_stack != tok->ftstring_stack_inline) { + PyMem_Free(tok->ftstring_stack); } - free_fstring_expressions(tok); PyMem_Free(tok); } -void -_PyToken_Free(struct token *token) { - Py_XDECREF(token->metadata); -} - void _PyToken_Init(struct token *token) { - token->metadata = NULL; + *token = (struct token){ + .type = -1, + .span = {-1, -1}, + .start_loc = {-1, -1}, + .end_loc = {-1, -1}, + }; } int -_PyLexer_type_comment_token_setup(struct tok_state *tok, struct token *token, int type, int col_offset, - int end_col_offset, const char *start, const char *end) +_PyLexer_token_setup(struct tok_state *tok, struct token *token, int type, _PyTok_Off start, _PyTok_Off end) { token->level = tok->level; - token->lineno = token->end_lineno = tok->lineno; - token->col_offset = col_offset; - token->end_col_offset = end_col_offset; - token->start = start; - token->end = end; - return type; -} - -int -_PyLexer_token_setup(struct tok_state *tok, struct token *token, int type, const char *start, const char *end) -{ - assert((start == NULL && end == NULL) || (start != NULL && end != NULL)); - token->level = tok->level; - if (ISSTRINGLIT(type)) { - token->lineno = tok->first_lineno; + token->is_raw = 0; + token->is_incomplete = 0; + assert((start == -1 && end == -1) || (start >= 0 && end >= start)); + token->span = (_PyTok_Span){start, end}; + if (start >= 0) { + token->start_loc = tok->start_loc; + token->end_loc = (_PyTok_Loc){tok->lineno, _PyLexer_ByteColumn(tok)}; } else { - token->lineno = tok->lineno; - } - token->end_lineno = tok->lineno; - token->col_offset = token->end_col_offset = -1; - token->start = start; - token->end = end; - - if (start != NULL && end != NULL) { - token->col_offset = tok->starting_col_offset; - token->end_col_offset = tok->col_offset; + token->start_loc = token->end_loc = (_PyTok_Loc){tok->lineno, -1}; } return type; } diff --git a/Parser/lexer/state.h b/Parser/lexer/state.h index 9cd196a114c7cb1..9c1475356b05353 100644 --- a/Parser/lexer/state.h +++ b/Parser/lexer/state.h @@ -2,100 +2,88 @@ #define _PY_LEXER_H_ #include "object.h" +#include "../tokenizer/source.h" +#include "../tokenizer/tokenizer.h" #define MAXINDENT 100 /* Max indentation level */ #define MAXLEVEL 200 /* Max parentheses level */ -#define MAXFSTRINGLEVEL 150 /* Max f-string nesting level */ +#define MAXFTSTRINGLEVEL 150 +#define FTSTRING_STACK_INLINE_CAPACITY 1 -#define INSIDE_FSTRING(tok) (tok->tok_mode_stack_index > 0) -#define INSIDE_FSTRING_EXPR(tok) (tok->curly_bracket_expr_start_depth >= 0) -#define INSIDE_FSTRING_EXPR_AT_TOP(tok) \ - (tok->curly_bracket_depth - tok->curly_bracket_expr_start_depth == 1) +typedef enum { + FTSTRING_MODE_MIDDLE, + FTSTRING_MODE_EXPRESSION, + FTSTRING_MODE_FORMAT_SPEC, +} ftstring_mode; -enum decoding_state { - STATE_INIT, - STATE_SEEK_CODING, - STATE_NORMAL -}; - -enum interactive_underflow_t { - /* Normal mode of operation: return a new token when asked in interactive mode */ - IUNDERFLOW_NORMAL, - /* Forcefully return ENDMARKER when asked for a new token in interactive mode. This - * can be used to prevent the tokenizer to prompt the user for new tokens */ - IUNDERFLOW_STOP, -}; - -struct token { - int level; - int lineno, col_offset, end_lineno, end_col_offset; - const char *start, *end; - PyObject *metadata; -}; - -enum tokenizer_mode_kind_t { - TOK_REGULAR_MODE, - TOK_FSTRING_MODE, -}; - -enum string_kind_t { +typedef enum { FSTRING, + RAW_FSTRING, TSTRING, -}; + RAW_TSTRING, +} ftstring_kind; #define MAX_EXPR_NESTING 3 -typedef struct _tokenizer_mode { - enum tokenizer_mode_kind_t kind; - - int curly_bracket_depth; - int curly_bracket_expr_start_depth; +typedef struct _tokenizer_comments { + Py_ssize_t count; + Py_ssize_t capacity; + _PyTok_Span spans[]; +} tokenizer_comments; +typedef struct _ftstring_state { + ftstring_mode mode; + ftstring_kind kind; char quote; - int quote_size; - int raw; - const char* start; - const char* multi_line_start; - int first_line; - - Py_ssize_t start_offset; - Py_ssize_t multi_line_start_offset; - - Py_ssize_t last_expr_size; - Py_ssize_t last_expr_end; - char* last_expr_buffer; - int in_debug; - int in_format_spec; - - enum string_kind_t string_kind; -} tokenizer_mode; + unsigned char quote_size; + unsigned char debug_expr; + unsigned char replacement_depth; + int paren_level; + _PyTok_Off start; + _PyTok_Loc start_loc; + _PyTok_Span expr_span; + tokenizer_comments *comments; +} ftstring_state; + +static inline int +_PyLexer_IsTString(ftstring_kind kind) +{ + return kind == TSTRING || kind == RAW_TSTRING; +} + +static inline int +_PyLexer_IsRawString(ftstring_kind kind) +{ + return kind == RAW_FSTRING || kind == RAW_TSTRING; +} + +typedef struct { + int column; + int alternate_column; +} indentation_level; + +typedef struct { + int depth; + int pending; + int at_bol; + int comment_newline; + indentation_level stack[MAXINDENT]; +} lexer_layout_state; /* Tokenizer state */ struct tok_state { - /* Input state; buf <= cur <= inp <= end */ - /* NB an entire line is held in the buffer */ - char *buf; /* Input buffer, or NULL; malloc'ed if fp != NULL or readline != NULL */ - char *cur; /* Next character in buffer */ - char *inp; /* End of data in buffer */ - int fp_interactive; /* If the file descriptor is interactive */ - char *interactive_src_start; /* The start of the source parsed so far in interactive mode */ - char *interactive_src_end; /* The end of the source parsed so far in interactive mode */ - const char *end; /* End of input buffer if buf != NULL */ - const char *start; /* Start of current token if not NULL */ + _PyTok_Off buf_offset; + _PyTok_Off cur; + _PyTok_Off inp; + _PyTok_Off start; + _PyTok_Off line_start; + _PyTok_SourceText source; int done; /* E_OK normally, E_EOF at EOF, otherwise error code */ /* NB If done != E_OK, cur must be == inp!!! */ - FILE *fp; /* Rest of input; NULL if tokenizing a string */ - int tabsize; /* Tab spacing */ - int indent; /* Current indentation index */ - int indstack[MAXINDENT]; /* Stack of indents */ - int atbol; /* Nonzero if at begin of new line */ - int pendin; /* Pending indents (if > 0) or dedents (if < 0) */ - const char *prompt, *nextprompt; /* For interactive prompting */ + lexer_layout_state layout; int lineno; /* Current line number */ - int first_lineno; /* First line of a single line or multi line string - expression (cf. issue 16806) */ - int starting_col_offset; /* The column offset at the beginning of a token */ - int col_offset; /* Current col offset */ + _PyTok_Loc start_loc; + _PyTokenizer_Diagnostic diagnostic; int level; /* () [] {} Parentheses nesting level */ /* Used to allow free continuations inside them */ char parenstack[MAXLEVEL]; @@ -103,50 +91,65 @@ struct tok_state { int parencolstack[MAXLEVEL]; PyObject *filename; PyObject *module; - /* Stuff for checking on different tab sizes */ - int altindstack[MAXINDENT]; /* Stack of alternate indents */ - /* Stuff for PEP 0263 */ - enum decoding_state decoding_state; - int decoding_erred; /* whether erred in decoding */ - char *encoding; /* Source encoding. */ - int cont_line; /* whether we are in a continuation line. */ - const char* line_start; /* pointer to start of current line */ - const char* multi_line_start; /* pointer to start of first line of - a single line or multi line string - expression (cf. issue 16806) */ - PyObject *decoding_readline; /* open(...).readline */ - PyObject *decoding_buffer; - PyObject *readline; /* readline() function */ - const char* enc; /* Encoding for the current str. */ - char* str; /* Source string being tokenized (if tokenizing from a string)*/ - char* input; /* Tokenizer's newline translated copy of the string. */ + struct _PyTok_Reader *reader; int type_comments; /* Whether to look for type comments */ - /* How to proceed when asked for a new token in interactive mode */ - enum interactive_underflow_t interactive_underflow; - int (*underflow)(struct tok_state *); /* Function to call when buffer is empty and we need to refill it*/ - - int report_warnings; - // TODO: Factor this into its own thing - tokenizer_mode tok_mode_stack[MAXFSTRINGLEVEL]; - int tok_mode_stack_index; + ftstring_state *ftstring_stack; + ftstring_state ftstring_stack_inline[FTSTRING_STACK_INLINE_CAPACITY]; + int ftstring_depth; + int ftstring_capacity; int tok_extra_tokens; - int comment_newline; int implicit_newline; #ifdef Py_DEBUG int debug; #endif + int barry_as_bdfl; + unsigned char allow_incomplete_input; + unsigned char needs_newline; }; -int _PyLexer_type_comment_token_setup(struct tok_state *tok, struct token *token, int type, int col_offset, - int end_col_offset, const char *start, const char *end); -int _PyLexer_token_setup(struct tok_state *tok, struct token *token, int type, const char *start, const char *end); +static inline ftstring_state * +_PyLexer_CurrentFTString(struct tok_state *tok) +{ + assert(tok->ftstring_stack != NULL); + assert(tok->ftstring_depth >= 0 && tok->ftstring_depth <= tok->ftstring_capacity); + if (tok->ftstring_depth == 0) { + return NULL; + } + return &tok->ftstring_stack[tok->ftstring_depth - 1]; +} + +static inline char +_PyLexer_StringPrefix(ftstring_kind kind) +{ + return _PyLexer_IsTString(kind) ? 't' : 'f'; +} + +static inline int +_PyLexer_FTStringBracketDepth(const struct tok_state *tok, + const ftstring_state *state) +{ + return tok->level - state->paren_level; +} + +static inline int +_PyLexer_ByteColumn(const struct tok_state *tok) +{ + assert(tok->line_start >= 0); + assert(tok->cur >= tok->line_start); + Py_ssize_t column = tok->cur - tok->line_start; + assert(column <= INT_MAX); + return (int)column; +} + +int _PyLexer_token_setup(struct tok_state *tok, struct token *token, int type, _PyTok_Off start, _PyTok_Off end); + +void _PyLexer_ImplyDedents(struct tok_state *); -struct tok_state *_PyTokenizer_tok_new(void); void _PyTokenizer_Free(struct tok_state *); -void _PyToken_Free(struct token *); -void _PyToken_Init(struct token *); +ftstring_state *_PyLexer_PushFTString(struct tok_state *); +void _PyLexer_PopFTString(struct tok_state *); #endif diff --git a/Parser/lexer/string.c b/Parser/lexer/string.c index e546954ba5c0d82..089ebc6f419ede2 100644 --- a/Parser/lexer/string.c +++ b/Parser/lexer/string.c @@ -7,110 +7,131 @@ #define MAKE_TOKEN(token_type) _PyLexer_token_setup(tok, token, token_type, p_start, p_end) -int -_PyLexer_set_ftstring_expr(struct tok_state* tok, struct token *token, char c) { - assert(token != NULL); - assert(c == '}' || c == ':' || c == '!'); - tokenizer_mode *tok_mode = TOK_GET_MODE(tok); +static int +string_error_token(struct tok_state *tok, struct token *token, + _PyTok_Off start, _PyTok_Loc location) +{ + tok->diagnostic = (_PyTokenizer_Diagnostic){ + .location = {location.lineno, location.byte_col + 1}, + .text_span = {start - location.byte_col, tok->inp}, + }; + int type = _PyLexer_token_setup(tok, token, ERRORTOKEN, -1, -1); + token->start_loc = location; + token->end_loc = (_PyTok_Loc){location.lineno, -1}; + return type; +} - if (!(tok_mode->in_debug || tok_mode->string_kind == TSTRING) || token->metadata) { +static int +incomplete_string_token(struct tok_state *tok, struct token *token, + int type, _PyTok_Off start, _PyTok_Loc location) +{ + string_error_token(tok, token, start, location); + tok->done = E_INCOMPLETE; + token->is_incomplete = 1; + return type; +} + +int +_PyLexer_record_ftstring_comment(struct tok_state *tok, ftstring_state *state, + _PyTok_Off start, _PyTok_Off end) +{ + assert(state == _PyLexer_CurrentFTString(tok) && state->mode == FTSTRING_MODE_EXPRESSION); + if (state->expr_span.end >= 0) { return 0; } - PyObject *res = NULL; - - // Look for a # character outside of string literals - int hash_detected = 0; - int in_string = 0; - char quote_char = 0; - - for (Py_ssize_t i = 0; i < tok_mode->last_expr_size - tok_mode->last_expr_end; i++) { - char ch = tok_mode->last_expr_buffer[i]; - - // Skip escaped characters - if (ch == '\\') { - i++; - continue; + assert(state->expr_span.start >= 0); + tokenizer_comments *comments = state->comments; + if (comments == NULL || comments->count == comments->capacity) { + Py_ssize_t max_capacity = (PY_SSIZE_T_MAX - + (Py_ssize_t)sizeof(*comments)) / + (Py_ssize_t)sizeof(*comments->spans); + if (comments != NULL && comments->capacity > max_capacity / 2) { + PyErr_NoMemory(); + return -1; } - - // Handle quotes - if (ch == '"' || ch == '\'') { - // The following if/else block works becase there is an off number - // of quotes in STRING tokens and the lexer only ever reaches this - // function with valid STRING tokens. - // For example: """hello""" - // First quote: in_string = 1 - // Second quote: in_string = 0 - // Third quote: in_string = 1 - if (!in_string) { - in_string = 1; - quote_char = ch; - } - else if (ch == quote_char) { - in_string = 0; - } - continue; + Py_ssize_t capacity = comments == NULL ? 4 : comments->capacity * 2; + size_t size = sizeof(*comments) + + (size_t)capacity * sizeof(*comments->spans); + tokenizer_comments *resized = PyMem_Realloc(comments, size); + if (resized == NULL) { + PyErr_NoMemory(); + return -1; } - - // Check for # outside strings - if (ch == '#' && !in_string) { - hash_detected = 1; - break; + comments = resized; + if (state->comments == NULL) { + comments->count = 0; } + comments->capacity = capacity; + state->comments = comments; } - // If we found a # character in the expression, we need to handle comments - if (hash_detected) { - // Allocate buffer for processed result - char *result = (char *)PyMem_Malloc((tok_mode->last_expr_size - tok_mode->last_expr_end + 1) * sizeof(char)); - if (!result) { - return -1; - } + comments->spans[comments->count++] = + (_PyTok_Span){start, end}; + return 0; +} - Py_ssize_t i = 0; // Input position - Py_ssize_t j = 0; // Output position - in_string = 0; // Whether we're in a string - quote_char = 0; // Current string quote char - - // Process each character - while (i < tok_mode->last_expr_size - tok_mode->last_expr_end) { - char ch = tok_mode->last_expr_buffer[i]; - - // Handle string quotes - if (ch == '"' || ch == '\'') { - // See comment above to understand this part - if (!in_string) { - in_string = 1; - quote_char = ch; - } else if (ch == quote_char) { - in_string = 0; - } - result[j++] = ch; - } - // Skip comments - else if (ch == '#' && !in_string) { - while (i < tok_mode->last_expr_size - tok_mode->last_expr_end && - tok_mode->last_expr_buffer[i] != '\n') { - i++; - } - if (i < tok_mode->last_expr_size - tok_mode->last_expr_end) { - result[j++] = '\n'; - } - } - // Copy other chars - else { - result[j++] = ch; +static int +finish_ftstring_expr(struct tok_state *tok, ftstring_state *state, + struct token *token) +{ + assert(token != NULL && state == _PyLexer_CurrentFTString(tok)); + assert(state->mode == FTSTRING_MODE_EXPRESSION && tok->start >= 0); + + if (state->expr_span.end >= 0) { + return 0; + } + assert(state->expr_span.start >= 0); + state->expr_span.end = tok->start; + int tstring_interpolation = _PyLexer_IsTString(state->kind) && + state->replacement_depth == 1; + if (!(state->debug_expr || tstring_interpolation) || token->metadata) { + return 0; + } + tokenizer_comments *comments = state->comments; + PyObject *res; + if (comments != NULL && comments->count > 0) { + Py_ssize_t stripped_size = + state->expr_span.end - state->expr_span.start; + Py_ssize_t comment_count = 0; + for (Py_ssize_t i = 0; i < comments->count; i++) { + _PyTok_Span comment = comments->spans[i]; + assert(_PyTok_SpanIsValid(comment)); + assert(comment.start >= (i == 0 ? state->expr_span.start + : comments->spans[i - 1].end)); + if (comment.start >= state->expr_span.end) { + break; } - i++; + assert(comment.end <= state->expr_span.end); + stripped_size -= comment.end - comment.start; + comment_count++; } - - result[j] = '\0'; // Null-terminate the result string - res = PyUnicode_DecodeUTF8(result, j, NULL); - PyMem_Free(result); - } else { - res = PyUnicode_DecodeUTF8( - tok_mode->last_expr_buffer, - tok_mode->last_expr_size - tok_mode->last_expr_end, - NULL - ); + char *stripped = PyMem_Malloc((size_t)stripped_size); + if (stripped == NULL) { + PyErr_NoMemory(); + return -1; + } + _PyTok_Span kept = {state->expr_span.start, state->expr_span.start}; + Py_ssize_t stripped_len = 0; + for (Py_ssize_t i = 0; i < comment_count; i++) { + kept.end = comments->spans[i].start; + Py_ssize_t length; + const char *text = _PyTok_SourceSpanView( + &tok->source, kept, &length); + memcpy(stripped + stripped_len, text, (size_t)length); + stripped_len += length; + kept.start = comments->spans[i].end; + } + kept.end = state->expr_span.end; + Py_ssize_t length; + const char *text = _PyTok_SourceSpanView(&tok->source, kept, &length); + memcpy(stripped + stripped_len, text, (size_t)length); + res = PyUnicode_DecodeUTF8(stripped, stripped_size, NULL); + PyMem_Free(stripped); + } + else { + Py_ssize_t expr_len; + const char *expr = _PyTok_SourceSpanView( + &tok->source, state->expr_span, &expr_len); + res = PyUnicode_DecodeUTF8(expr, expr_len, NULL); } if (!res) { @@ -120,61 +141,82 @@ _PyLexer_set_ftstring_expr(struct tok_state* tok, struct token *token, char c) { return 0; } -int -_PyLexer_update_ftstring_expr(struct tok_state *tok, char cur) +static int +begin_ftstring_expr(struct tok_state *tok, ftstring_state *state, + _PyTok_Off expr_start) { - assert(tok->cur != NULL); + assert(state->mode != FTSTRING_MODE_EXPRESSION); + state->expr_span = (_PyTok_Span){expr_start, -1}; + if (state->comments != NULL) { + state->comments->count = 0; + } + if (state->replacement_depth >= MAX_EXPR_NESTING) { + _PyTokenizer_syntaxerror( + tok, "%c-string: expressions nested too deeply", + _PyLexer_StringPrefix(state->kind)); + return -1; + } + state->replacement_depth++; + state->mode = FTSTRING_MODE_EXPRESSION; + state->debug_expr = 0; + return 0; +} - Py_ssize_t size = strlen(tok->cur); - tokenizer_mode *tok_mode = TOK_GET_MODE(tok); +int +_PyLexer_ftstring_punctuation(struct tok_state *tok, ftstring_state *state, + struct token *token, int c) +{ + assert(state->mode == FTSTRING_MODE_EXPRESSION); + assert(c == ':' || c == '}' || c == '!'); + if (_PyLexer_FTStringBracketDepth(tok, state) != state->replacement_depth) { + return 0; + } + if (c == '!') { + int next = tok_nextc(tok); + tok_backup(tok, next); + if (next == '=') { + return 0; + } + } + if (finish_ftstring_expr(tok, state, token) < 0) { + return -1; + } + if (c == ':') { + state->mode = FTSTRING_MODE_FORMAT_SPEC; + return COLON; + } + return 0; +} - switch (cur) { - case 0: - if (!tok_mode->last_expr_buffer || tok_mode->last_expr_end >= 0) { - return 1; - } - char *new_buffer = PyMem_Realloc( - tok_mode->last_expr_buffer, - tok_mode->last_expr_size + size - ); - if (new_buffer == NULL) { - PyMem_Free(tok_mode->last_expr_buffer); - goto error; - } - tok_mode->last_expr_buffer = new_buffer; - strncpy(tok_mode->last_expr_buffer + tok_mode->last_expr_size, tok->cur, size); - tok_mode->last_expr_size += size; - break; - case '{': - if (tok_mode->last_expr_buffer != NULL) { - PyMem_Free(tok_mode->last_expr_buffer); - } - tok_mode->last_expr_buffer = PyMem_Malloc(size); - if (tok_mode->last_expr_buffer == NULL) { - goto error; - } - tok_mode->last_expr_size = size; - tok_mode->last_expr_end = -1; - strncpy(tok_mode->last_expr_buffer, tok->cur, size); - break; - case '}': - case '!': - tok_mode->last_expr_end = strlen(tok->start); - break; - case ':': - if (tok_mode->last_expr_end == -1) { - tok_mode->last_expr_end = strlen(tok->start); - } - break; - default: - Py_UNREACHABLE(); +int +_PyLexer_close_ftstring_expr(struct tok_state *tok, ftstring_state *state, + int c) +{ + assert(state->mode == FTSTRING_MODE_EXPRESSION); + assert(c == ')' || c == ']' || c == '}'); + int depth = _PyLexer_FTStringBracketDepth(tok, state); + if (depth < 0) { + _PyTokenizer_syntaxerror(tok, "%c-string: unmatched '%c'", + _PyLexer_StringPrefix(state->kind), c); + return -1; + } + if (c == '}' && depth == state->replacement_depth - 1) { + state->replacement_depth--; + state->mode = FTSTRING_MODE_MIDDLE; + state->debug_expr = 0; } - return 1; -error: - tok->done = E_NOMEM; return 0; } +void +_PyLexer_mark_ftstring_debug(struct tok_state *tok, ftstring_state *state) +{ + assert(state->mode == FTSTRING_MODE_EXPRESSION); + if (_PyLexer_FTStringBracketDepth(tok, state) == state->replacement_depth) { + state->debug_expr = 1; + } +} + int _PyLexer_check_string_prefixes(struct tok_state *tok, int saw_b, int saw_r, int saw_u, @@ -221,21 +263,15 @@ _PyLexer_check_string_prefixes(struct tok_state *tok, } int -_PyLexer_scan_fstring_start(struct tok_state *tok, struct token *token, int c) +_PyLexer_scan_fstring_start(struct tok_state *tok, struct token *token, + int c, ftstring_kind kind) { - const char *p_start = NULL; - const char *p_end = NULL; + _PyTok_Off p_start = -1; + _PyTok_Off p_end = -1; int quote = c; int quote_size = 1; /* 1 or 3 */ - /* Nodes of type STRING, especially multi line strings - must be handled differently in order to get both - the starting line number and the column offset right. - (cf. issue 16806) */ - tok->first_lineno = tok->lineno; - tok->multi_line_start = tok->line_start; - /* Find the quote size and start of string */ int after_quote = tok_nextc(tok); if (after_quote == quote) { @@ -253,73 +289,36 @@ _PyLexer_scan_fstring_start(struct tok_state *tok, struct token *token, int c) tok_backup(tok, after_quote); } - p_start = tok->start; p_end = tok->cur; - if (tok->tok_mode_stack_index + 1 >= MAXFSTRINGLEVEL) { - return MAKE_TOKEN(_PyTokenizer_syntaxerror(tok, "too many nested f-strings or t-strings")); - } - tokenizer_mode *the_current_tok = TOK_NEXT_MODE(tok); - the_current_tok->kind = TOK_FSTRING_MODE; - the_current_tok->quote = quote; - the_current_tok->quote_size = quote_size; - the_current_tok->start = tok->start; - the_current_tok->multi_line_start = tok->line_start; - the_current_tok->first_line = tok->lineno; - the_current_tok->start_offset = -1; - the_current_tok->multi_line_start_offset = -1; - the_current_tok->last_expr_buffer = NULL; - the_current_tok->last_expr_size = 0; - the_current_tok->last_expr_end = -1; - the_current_tok->in_format_spec = 0; - the_current_tok->in_debug = 0; - - enum string_kind_t string_kind = FSTRING; - switch (*tok->start) { - case 'T': - case 't': - the_current_tok->raw = Py_TOLOWER(*(tok->start + 1)) == 'r'; - string_kind = TSTRING; - break; - case 'F': - case 'f': - the_current_tok->raw = Py_TOLOWER(*(tok->start + 1)) == 'r'; - break; - case 'R': - case 'r': - the_current_tok->raw = 1; - if (Py_TOLOWER(*(tok->start + 1)) == 't') { - string_kind = TSTRING; - } - break; - default: - Py_UNREACHABLE(); + ftstring_state *state = _PyLexer_PushFTString(tok); + if (state == NULL) { + return MAKE_TOKEN(ERRORTOKEN); } - - the_current_tok->string_kind = string_kind; - the_current_tok->curly_bracket_depth = 0; - the_current_tok->curly_bracket_expr_start_depth = -1; - return string_kind == TSTRING ? MAKE_TOKEN(TSTRING_START) : MAKE_TOKEN(FSTRING_START); + state->mode = FTSTRING_MODE_MIDDLE; + state->quote = quote; + state->quote_size = quote_size; + state->paren_level = tok->level; + state->start = tok->start; + state->start_loc = tok->start_loc; + state->expr_span = (_PyTok_Span){-1, -1}; + + state->kind = kind; + return _PyLexer_IsTString(kind) + ? MAKE_TOKEN(TSTRING_START) : MAKE_TOKEN(FSTRING_START); } int _PyLexer_scan_string(struct tok_state *tok, struct token *token, int c) { - const char *p_start = NULL; - const char *p_end = NULL; + _PyTok_Off p_start = -1; + _PyTok_Off p_end = -1; int quote = c; int quote_size = 1; /* 1 or 3 */ int end_quote_size = 0; int has_escaped_quote = 0; - /* Nodes of type STRING, especially multi line strings - must be handled differently in order to get both - the starting line number and the column offset right. - (cf. issue 16806) */ - tok->first_lineno = tok->lineno; - tok->multi_line_start = tok->line_start; - /* Find the quote size and start of string */ c = tok_nextc(tok); if (c == quote) { @@ -345,55 +344,73 @@ _PyLexer_scan_string(struct tok_state *tok, struct token *token, int c) break; } if (c == EOF || (quote_size == 1 && c == '\n')) { - assert(tok->multi_line_start != NULL); - // shift the tok_state's location into - // the start of string, and report the error - // from the initial quote character - tok->cur = (char *)tok->start; - tok->cur++; - tok->line_start = tok->multi_line_start; - int start = tok->lineno; - tok->lineno = tok->first_lineno; - - if (INSIDE_FSTRING(tok)) { - /* When we are in an f-string, before raising the - * unterminated string literal error, check whether - * does the initial quote matches with f-strings quotes - * and if it is, then this must be a missing '}' token - * so raise the proper error */ - tokenizer_mode *the_current_tok = TOK_GET_MODE(tok); - if (the_current_tok->quote == quote && - the_current_tok->quote_size == quote_size) { - return MAKE_TOKEN(_PyTokenizer_syntaxerror(tok, - "%c-string: expecting '}'", TOK_GET_STRING_PREFIX(tok))); + if (tok_failed(tok)) { + return MAKE_TOKEN(ERRORTOKEN); + } + if (c == EOF && tok->allow_incomplete_input) { + return incomplete_string_token(tok, token, STRING, + tok->start, tok->start_loc); + } + int end_lineno = tok->lineno; + _PyTok_Loc location = tok->start_loc; + const char *line = _PyTok_SourcePointer( + &tok->source, tok->start - location.byte_col); + Py_ssize_t cursor_offset = (Py_ssize_t)location.byte_col + 1; + + const ftstring_state *state = _PyLexer_CurrentFTString(tok); + if (state != NULL) { + /* A matching quote may have been intended to close the + * surrounding formatted string instead of opening a string + * inside a replacement field. */ + if (state->quote == quote && state->quote_size == quote_size) { + int level = state->paren_level + state->replacement_depth - 1; + assert(level >= 0 && level < tok->level); + assert(tok->parenstack[level] == '{'); + int lineno = tok->parenlinenostack[level]; + if (lineno != location.lineno) { + _PyTokenizer_syntaxerror_at( + tok, line, cursor_offset, location.lineno, -1, -1, + "%c-string: expecting '}' to close '{' on line %d", + _PyLexer_StringPrefix(state->kind), lineno); + } + else { + _PyTokenizer_syntaxerror_at( + tok, line, cursor_offset, location.lineno, -1, -1, + "%c-string: expecting '}'", + _PyLexer_StringPrefix(state->kind)); + } + return string_error_token(tok, token, tok->start, location); } } if (quote_size == 3) { - _PyTokenizer_syntaxerror(tok, "unterminated triple-quoted string literal" - " (detected at line %d)", start); + _PyTokenizer_syntaxerror_at( + tok, line, cursor_offset, location.lineno, -1, -1, + "unterminated triple-quoted string literal" + " (detected at line %d)", end_lineno); if (c != '\n') { tok->done = E_EOFS; } - return MAKE_TOKEN(ERRORTOKEN); + return string_error_token(tok, token, tok->start, location); } else { if (has_escaped_quote) { - _PyTokenizer_syntaxerror( - tok, + _PyTokenizer_syntaxerror_at( + tok, line, cursor_offset, location.lineno, -1, -1, "unterminated string literal (detected at line %d); " "perhaps you escaped the end quote?", - start + end_lineno ); } else { - _PyTokenizer_syntaxerror( - tok, "unterminated string literal (detected at line %d)", start + _PyTokenizer_syntaxerror_at( + tok, line, cursor_offset, location.lineno, -1, -1, + "unterminated string literal (detected at line %d)", end_lineno ); } if (c != '\n') { tok->done = E_EOLS; } - return MAKE_TOKEN(ERRORTOKEN); + return string_error_token(tok, token, tok->start, location); } } if (c == quote) { @@ -419,131 +436,86 @@ _PyLexer_scan_string(struct tok_state *tok, struct token *token, int c) } int -_PyLexer_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct token *token) +_PyLexer_get_ftstring(struct tok_state *tok, ftstring_state *current, struct token *token) { - const char *p_start = NULL; - const char *p_end = NULL; + assert(current == _PyLexer_CurrentFTString(tok) && current->mode != FTSTRING_MODE_EXPRESSION); + assert((current->quote_size == 1 || current->quote_size == 3) && + current->replacement_depth <= MAX_EXPR_NESTING); + _PyTok_Off p_start = -1; + _PyTok_Off p_end = -1; + int token_type; int end_quote_size = 0; int unicode_escape = 0; + int quote = current->quote; + int quote_size = current->quote_size; + int in_format_spec = current->mode == FTSTRING_MODE_FORMAT_SPEC; + int raw = _PyLexer_IsRawString(current->kind); tok->start = tok->cur; - tok->first_lineno = tok->lineno; - tok->starting_col_offset = tok->col_offset; - - // If we start with a bracket, we defer to the normal mode as there is nothing for us to tokenize - // before it. - int start_char = tok_nextc(tok); - if (start_char == '{') { - int peek1 = tok_nextc(tok); - tok_backup(tok, peek1); - tok_backup(tok, start_char); - if (peek1 != '{') { - current_tok->curly_bracket_expr_start_depth++; - if (current_tok->curly_bracket_expr_start_depth >= MAX_EXPR_NESTING) { - return MAKE_TOKEN(_PyTokenizer_syntaxerror(tok, - "%c-string: expressions nested too deeply", TOK_GET_STRING_PREFIX(tok))); - } - TOK_GET_MODE(tok)->kind = TOK_REGULAR_MODE; - return _PyLexer_get_normal_mode(tok, current_tok, token); - } - } - else { - tok_backup(tok, start_char); - } - - // Check if we are at the end of the string - for (int i = 0; i < current_tok->quote_size; i++) { - int quote = tok_nextc(tok); - if (quote != current_tok->quote) { - tok_backup(tok, quote); - goto f_string_middle; - } - } + tok->start_loc = (_PyTok_Loc){tok->lineno, _PyLexer_ByteColumn(tok)}; - if (current_tok->last_expr_buffer != NULL) { - PyMem_Free(current_tok->last_expr_buffer); - current_tok->last_expr_buffer = NULL; - current_tok->last_expr_size = 0; - current_tok->last_expr_end = -1; - } - - p_start = tok->start; - p_end = tok->cur; - tok->tok_mode_stack_index--; - return MAKE_TOKEN(FTSTRING_END(current_tok)); - -f_string_middle: - - // TODO: This is a bit of a hack, but it works for now. We need to find a better way to handle - // this. - tok->multi_line_start = tok->line_start; - while (end_quote_size != current_tok->quote_size) { + while (end_quote_size != quote_size) { int c = tok_nextc(tok); if (tok->done == E_ERROR || tok->done == E_DECODE) { return MAKE_TOKEN(ERRORTOKEN); } - int in_format_spec = ( - current_tok->in_format_spec - && - INSIDE_FSTRING_EXPR(current_tok) - ); - - if (c == EOF || (current_tok->quote_size == 1 && c == '\n')) { - if (tok->decoding_erred) { + + if (c == EOF || (quote_size == 1 && c == '\n')) { + if (tok_failed(tok)) { return MAKE_TOKEN(ERRORTOKEN); } + if (c == EOF && tok->allow_incomplete_input) { + int type = incomplete_string_token(tok, token, + FTSTRING_MIDDLE(current), current->start, current->start_loc); + // Preserve the actual prefix for incremental escape decoding. + _PyTok_Off end = tok->cur; + if (end > tok->start && tok->implicit_newline) { + end--; + } + token->span = (_PyTok_Span){tok->start, end}; + token->start_loc = tok->start_loc; + token->end_loc = (_PyTok_Loc){tok->lineno, (int)(end - tok->line_start)}; + token->is_raw = raw; + return type; + } - // If we are in a format spec and we found a newline, - // it means that the format spec ends here and we should - // return to the regular mode. if (in_format_spec && c == '\n') { - if (current_tok->quote_size == 1) { - return MAKE_TOKEN( - _PyTokenizer_syntaxerror( - tok, - "%c-string: newlines are not allowed in format specifiers for single quoted %c-strings", - TOK_GET_STRING_PREFIX(tok), TOK_GET_STRING_PREFIX(tok) - ) - ); - } - tok_backup(tok, c); - TOK_GET_MODE(tok)->kind = TOK_REGULAR_MODE; - current_tok->in_format_spec = 0; - p_start = tok->start; - p_end = tok->cur; - return MAKE_TOKEN(FTSTRING_MIDDLE(current_tok)); + return MAKE_TOKEN(_PyTokenizer_syntaxerror( + tok, + "%c-string: newlines are not allowed in format specifiers for single quoted %c-strings", + _PyLexer_StringPrefix(current->kind), + _PyLexer_StringPrefix(current->kind))); } - assert(tok->multi_line_start != NULL); - // shift the tok_state's location into - // the start of string, and report the error - // from the initial quote character - tok->cur = (char *)current_tok->start; - tok->cur++; - tok->line_start = current_tok->multi_line_start; - int start = tok->lineno; - - tokenizer_mode *the_current_tok = TOK_GET_MODE(tok); - tok->lineno = the_current_tok->first_line; - - if (current_tok->quote_size == 3) { - _PyTokenizer_syntaxerror(tok, - "unterminated triple-quoted %c-string literal" - " (detected at line %d)", - TOK_GET_STRING_PREFIX(tok), start); + int end_lineno = tok->lineno; + _PyTok_Loc location = current->start_loc; + const char *line = _PyTok_SourcePointer( + &tok->source, current->start - location.byte_col); + Py_ssize_t cursor_offset = (Py_ssize_t)location.byte_col + 1; + + if (quote_size == 3) { + _PyTokenizer_syntaxerror_at( + tok, line, cursor_offset, location.lineno, -1, -1, + "unterminated triple-quoted %c-string literal" + " (detected at line %d)", + _PyLexer_StringPrefix(current->kind), end_lineno); if (c != '\n') { tok->done = E_EOFS; } - return MAKE_TOKEN(ERRORTOKEN); + return string_error_token(tok, token, + current->start, location); } else { - return MAKE_TOKEN(_PyTokenizer_syntaxerror(tok, - "unterminated %c-string literal (detected at" - " line %d)", TOK_GET_STRING_PREFIX(tok), start)); + _PyTokenizer_syntaxerror_at( + tok, line, cursor_offset, location.lineno, -1, -1, + "unterminated %c-string literal (detected at line %d)", + _PyLexer_StringPrefix(current->kind), end_lineno); + return string_error_token(tok, token, + current->start, location); } } - if (c == current_tok->quote) { + if (c == quote) { end_quote_size += 1; continue; } else { @@ -551,62 +523,63 @@ _PyLexer_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, st } if (c == '{') { - if (!_PyLexer_update_ftstring_expr(tok, c)) { - return MAKE_TOKEN(ENDMARKER); - } int peek = tok_nextc(tok); if (peek != '{' || in_format_spec) { tok_backup(tok, peek); + _PyTok_Off expr_start = tok->cur; tok_backup(tok, c); - current_tok->curly_bracket_expr_start_depth++; - if (current_tok->curly_bracket_expr_start_depth >= MAX_EXPR_NESTING) { - return MAKE_TOKEN(_PyTokenizer_syntaxerror(tok, - "%c-string: expressions nested too deeply", TOK_GET_STRING_PREFIX(tok))); + if (begin_ftstring_expr(tok, current, expr_start) < 0) { + return MAKE_TOKEN(ERRORTOKEN); } - TOK_GET_MODE(tok)->kind = TOK_REGULAR_MODE; - current_tok->in_format_spec = 0; p_start = tok->start; p_end = tok->cur; + if (p_start == p_end) { + return _PyLexer_get_normal(tok, current, token); + } } else { p_start = tok->start; p_end = tok->cur - 1; } - return MAKE_TOKEN(FTSTRING_MIDDLE(current_tok)); + goto emit_middle; } else if (c == '}') { if (unicode_escape) { p_start = tok->start; p_end = tok->cur; - return MAKE_TOKEN(FTSTRING_MIDDLE(current_tok)); + goto emit_middle; } int peek = tok_nextc(tok); - // The tokenizer can only be in the format spec if we have already completed the expression - // scanning (indicated by the end of the expression being set) and we are not at the top level - // of the bracket stack (-1 is the top level). Since format specifiers can't legally use double - // brackets, we can bypass it here. - int cursor = current_tok->curly_bracket_depth; - if (peek == '}' && !in_format_spec && cursor == 0) { + int bracket_depth = _PyLexer_FTStringBracketDepth(tok, current); + if (peek == '}' && !in_format_spec && bracket_depth == 0) { p_start = tok->start; p_end = tok->cur - 1; - } else { + } + else { tok_backup(tok, peek); + if (!in_format_spec && bracket_depth == 0) { + if (tok->start == tok->cur - 1) { + return MAKE_TOKEN(_PyTokenizer_syntaxerror( + tok, "%c-string: single '}' is not allowed", + _PyLexer_StringPrefix(current->kind))); + } + tok_backup(tok, c); + p_start = tok->start; + p_end = tok->cur; + goto emit_middle; + } tok_backup(tok, c); - TOK_GET_MODE(tok)->kind = TOK_REGULAR_MODE; - current_tok->in_format_spec = 0; + current->mode = FTSTRING_MODE_EXPRESSION; p_start = tok->start; p_end = tok->cur; } - return MAKE_TOKEN(FTSTRING_MIDDLE(current_tok)); + goto emit_middle; } else if (c == '\\') { int peek = tok_nextc(tok); if (peek == '\r') { peek = tok_nextc(tok); } - // Special case when the backslash is right before a curly - // brace. We have to restore and return the control back - // to the loop for the next iteration. if (peek == '{' || peek == '}') { - if (!current_tok->raw) { + if (!raw) { if (_PyTokenizer_warn_invalid_escape_sequence(tok, peek)) { return MAKE_TOKEN(ERRORTOKEN); } @@ -615,7 +588,7 @@ _PyLexer_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, st continue; } - if (!current_tok->raw) { + if (!raw) { if (peek == 'N') { /* Handle named unicode escapes (\N{BULLET}) */ peek = tok_nextc(tok); @@ -625,18 +598,23 @@ _PyLexer_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, st tok_backup(tok, peek); } } - } /* else { - skip the escaped character - }*/ + } } } - // Backup the f-string quotes to emit a final FSTRING_MIDDLE and - // add the quotes to the FSTRING_END in the next tokenizer iteration. - for (int i = 0; i < current_tok->quote_size; i++) { - tok_backup(tok, current_tok->quote); - } p_start = tok->start; p_end = tok->cur; - return MAKE_TOKEN(FTSTRING_MIDDLE(current_tok)); + if (p_end - quote_size == p_start) { + int end_token = FTSTRING_END(current); + _PyLexer_PopFTString(tok); + return MAKE_TOKEN(end_token); + } + for (int i = 0; i < quote_size; i++) { + tok_backup(tok, quote); + } + p_end = tok->cur; +emit_middle: + token_type = MAKE_TOKEN(FTSTRING_MIDDLE(current)); + token->is_raw = raw; + return token_type; } diff --git a/Parser/myreadline.c b/Parser/myreadline.c index ee77479ba7bdccb..339f55afa0dcfaa 100644 --- a/Parser/myreadline.c +++ b/Parser/myreadline.c @@ -162,8 +162,8 @@ _PyOS_WindowsConsoleReadline(PyThreadState *tstate, HANDLE hStdIn) goto exit; err = 0; HANDLE hInterruptEvent = _PyOS_SigintEvent(); - if (WaitForSingleObjectEx(hInterruptEvent, 100, FALSE) - == WAIT_OBJECT_0) { + DWORD state = WaitForSingleObjectEx(hInterruptEvent, 100, FALSE); + if (state == WAIT_OBJECT_0) { ResetEvent(hInterruptEvent); PyEval_RestoreThread(tstate); s = PyErr_CheckSignals(); @@ -172,7 +172,13 @@ _PyOS_WindowsConsoleReadline(PyThreadState *tstate, HANDLE hStdIn) goto exit; } } - break; + else if (state != WAIT_TIMEOUT) { + err = GetLastError(); + goto exit; + } + /* The console cancelled the read and flushed its input buffer, + but no exception was raised. Start the read over. */ + continue; } total_read += n_read; @@ -366,8 +372,6 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt) char *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *) = NULL; -/* Interface used by file_tokenizer.c and bltinmodule.c */ - char * PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt) { diff --git a/Parser/parser.c b/Parser/parser.c index 4f4fd3ed46d1f02..2300314a77888fa 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -22,59 +22,59 @@ static KeywordToken *reserved_keywords[] = { (KeywordToken[]) {{NULL, -1}}, (KeywordToken[]) {{NULL, -1}}, (KeywordToken[]) { - {"if", 700}, - {"as", 698}, - {"in", 713}, - {"or", 589}, - {"is", 597}, + {"if", 514}, + {"as", 520}, + {"in", 523}, + {"or", 529}, + {"is", 532}, {NULL, -1}, }, (KeywordToken[]) { - {"del", 634}, - {"def", 717}, - {"for", 712}, - {"try", 674}, - {"and", 590}, - {"not", 721}, + {"del", 505}, + {"def", 512}, + {"for", 517}, + {"try", 518}, + {"and", 530}, + {"not", 531}, {NULL, -1}, }, (KeywordToken[]) { - {"from", 650}, - {"pass", 527}, - {"with", 665}, - {"elif", 705}, - {"else", 704}, - {"None", 628}, - {"True", 627}, + {"from", 501}, + {"pass", 504}, + {"with", 516}, + {"elif", 521}, + {"else", 522}, + {"None", 526}, + {"True", 527}, {NULL, -1}, }, (KeywordToken[]) { - {"raise", 632}, - {"yield", 588}, - {"break", 528}, - {"async", 716}, - {"class", 719}, - {"while", 707}, - {"False", 629}, - {"await", 598}, + {"raise", 503}, + {"yield", 506}, + {"break", 508}, + {"async", 513}, + {"class", 515}, + {"while", 519}, + {"False", 528}, + {"await", 533}, {NULL, -1}, }, (KeywordToken[]) { - {"import", 651}, - {"return", 522}, - {"assert", 638}, - {"global", 530}, - {"except", 695}, - {"lambda", 622}, + {"import", 500}, + {"return", 502}, + {"assert", 507}, + {"global", 510}, + {"except", 524}, + {"lambda", 534}, {NULL, -1}, }, (KeywordToken[]) { - {"finally", 691}, + {"finally", 525}, {NULL, -1}, }, (KeywordToken[]) { - {"continue", 529}, - {"nonlocal", 531}, + {"continue", 509}, + {"nonlocal", 511}, {NULL, -1}, }, }; @@ -201,350 +201,465 @@ static char *soft_keywords[] = { #define star_expressions_type 1112 #define star_expression_type 1113 #define star_named_expressions_type 1114 -#define star_named_expressions_sequence_type 1115 -#define star_named_expression_type 1116 -#define star_named_expression_sequence_type 1117 -#define assignment_expression_type 1118 -#define named_expression_type 1119 -#define disjunction_type 1120 -#define conjunction_type 1121 -#define inversion_type 1122 -#define comparison_type 1123 -#define compare_op_bitwise_or_pair_type 1124 -#define eq_bitwise_or_type 1125 -#define noteq_bitwise_or_type 1126 -#define lte_bitwise_or_type 1127 -#define lt_bitwise_or_type 1128 -#define gte_bitwise_or_type 1129 -#define gt_bitwise_or_type 1130 -#define notin_bitwise_or_type 1131 -#define in_bitwise_or_type 1132 -#define isnot_bitwise_or_type 1133 -#define is_bitwise_or_type 1134 -#define bitwise_or_type 1135 // Left-recursive -#define bitwise_xor_type 1136 // Left-recursive -#define bitwise_and_type 1137 // Left-recursive -#define shift_expr_type 1138 // Left-recursive -#define sum_type 1139 // Left-recursive -#define term_type 1140 // Left-recursive -#define factor_type 1141 -#define power_type 1142 -#define await_primary_type 1143 -#define primary_type 1144 // Left-recursive -#define slices_type 1145 -#define slice_type 1146 -#define atom_type 1147 -#define group_type 1148 -#define lambdef_type 1149 -#define lambda_params_type 1150 -#define lambda_parameters_type 1151 -#define lambda_slash_no_default_type 1152 -#define lambda_slash_with_default_type 1153 -#define lambda_star_etc_type 1154 -#define lambda_kwds_type 1155 -#define lambda_param_no_default_type 1156 -#define lambda_param_with_default_type 1157 -#define lambda_param_maybe_default_type 1158 -#define lambda_param_type 1159 -#define fstring_middle_type 1160 -#define fstring_replacement_field_type 1161 -#define fstring_conversion_type 1162 -#define fstring_full_format_spec_type 1163 -#define fstring_format_spec_type 1164 -#define fstring_type 1165 -#define tstring_format_spec_replacement_field_type 1166 -#define tstring_format_spec_type 1167 -#define tstring_full_format_spec_type 1168 -#define tstring_replacement_field_type 1169 -#define tstring_middle_type 1170 -#define tstring_type 1171 -#define string_type 1172 -#define strings_type 1173 -#define list_type 1174 -#define tuple_type 1175 -#define set_type 1176 -#define dict_type 1177 -#define double_starred_kvpairs_type 1178 -#define double_starred_kvpair_type 1179 -#define kvpair_type 1180 -#define for_if_clauses_type 1181 -#define for_if_clause_type 1182 -#define listcomp_type 1183 -#define setcomp_type 1184 -#define genexp_type 1185 -#define dictcomp_type 1186 -#define arguments_type 1187 -#define args_type 1188 -#define kwargs_type 1189 -#define starred_expression_type 1190 -#define kwarg_or_starred_type 1191 -#define kwarg_or_double_starred_type 1192 -#define star_targets_type 1193 -#define star_targets_list_seq_type 1194 -#define star_targets_tuple_seq_type 1195 -#define star_target_type 1196 -#define target_with_star_atom_type 1197 -#define star_atom_type 1198 -#define single_target_type 1199 -#define single_subscript_attribute_target_type 1200 -#define t_primary_type 1201 // Left-recursive -#define t_lookahead_type 1202 -#define del_targets_type 1203 -#define del_target_type 1204 -#define del_t_atom_type 1205 -#define type_expressions_type 1206 -#define func_type_comment_type 1207 -#define invalid_arguments_type 1208 -#define invalid_kwarg_type 1209 -#define expression_without_invalid_type 1210 -#define invalid_legacy_expression_type 1211 -#define invalid_type_param_type 1212 -#define invalid_expression_type 1213 -#define invalid_if_expression_type 1214 -#define invalid_named_expression_type 1215 -#define invalid_assignment_type 1216 -#define invalid_ann_assign_target_type 1217 -#define invalid_raise_stmt_type 1218 -#define invalid_del_stmt_type 1219 -#define invalid_assert_stmt_type 1220 -#define invalid_block_type 1221 -#define invalid_comprehension_type 1222 -#define invalid_parameters_type 1223 -#define invalid_default_type 1224 -#define invalid_star_etc_type 1225 -#define invalid_kwds_type 1226 -#define invalid_parameters_helper_type 1227 -#define invalid_lambda_parameters_type 1228 -#define invalid_lambda_parameters_helper_type 1229 -#define invalid_lambda_star_etc_type 1230 -#define invalid_lambda_kwds_type 1231 -#define invalid_double_type_comments_type 1232 -#define invalid_with_item_type 1233 -#define invalid_for_if_clause_type 1234 -#define invalid_for_target_type 1235 -#define invalid_group_type 1236 -#define invalid_import_type 1237 -#define invalid_dotted_as_name_type 1238 -#define invalid_import_from_as_name_type 1239 -#define invalid_import_from_type 1240 -#define invalid_import_from_targets_type 1241 -#define invalid_with_stmt_type 1242 -#define invalid_with_stmt_indent_type 1243 -#define invalid_try_stmt_type 1244 -#define invalid_except_stmt_type 1245 -#define invalid_except_star_stmt_type 1246 -#define invalid_finally_stmt_type 1247 -#define invalid_except_stmt_indent_type 1248 -#define invalid_except_star_stmt_indent_type 1249 -#define invalid_match_stmt_type 1250 -#define invalid_case_block_type 1251 -#define invalid_as_pattern_type 1252 -#define invalid_class_pattern_type 1253 -#define invalid_mapping_pattern_type 1254 -#define invalid_class_argument_pattern_type 1255 -#define invalid_if_stmt_type 1256 -#define invalid_elif_stmt_type 1257 -#define invalid_else_stmt_type 1258 -#define invalid_while_stmt_type 1259 -#define invalid_for_stmt_type 1260 -#define invalid_def_raw_type 1261 -#define invalid_class_def_raw_type 1262 -#define invalid_double_starred_kvpairs_type 1263 -#define invalid_kvpair_unpacking_type 1264 -#define invalid_kvpair_type 1265 -#define invalid_starred_expression_unpacking_type 1266 -#define invalid_starred_expression_unpacking_sequence_type 1267 -#define invalid_starred_expression_type 1268 -#define invalid_fstring_replacement_field_type 1269 -#define invalid_fstring_conversion_character_type 1270 -#define invalid_tstring_replacement_field_type 1271 -#define invalid_tstring_conversion_character_type 1272 -#define invalid_string_tstring_concat_type 1273 -#define invalid_arithmetic_type 1274 // Left-recursive -#define invalid_factor_type 1275 -#define invalid_type_params_type 1276 -#define invalid_bitwise_and_type 1277 // Left-recursive -#define invalid_bitwise_or_type 1278 // Left-recursive -#define _loop0_1_type 1279 -#define _loop1_2_type 1280 -#define _loop0_3_type 1281 -#define _gather_4_type 1282 -#define _tmp_5_type 1283 -#define _tmp_6_type 1284 -#define _tmp_7_type 1285 -#define _tmp_8_type 1286 -#define _tmp_9_type 1287 -#define _tmp_10_type 1288 -#define _tmp_11_type 1289 -#define _loop1_12_type 1290 -#define _loop0_13_type 1291 -#define _gather_14_type 1292 -#define _tmp_15_type 1293 -#define _tmp_16_type 1294 -#define _loop0_17_type 1295 -#define _loop1_18_type 1296 -#define _loop0_19_type 1297 -#define _gather_20_type 1298 -#define _tmp_21_type 1299 -#define _loop0_22_type 1300 -#define _gather_23_type 1301 -#define _loop1_24_type 1302 -#define _tmp_25_type 1303 -#define _tmp_26_type 1304 -#define _loop0_27_type 1305 -#define _loop0_28_type 1306 -#define _loop1_29_type 1307 -#define _loop1_30_type 1308 -#define _loop0_31_type 1309 -#define _loop1_32_type 1310 -#define _loop0_33_type 1311 -#define _gather_34_type 1312 -#define _tmp_35_type 1313 -#define _loop1_36_type 1314 -#define _loop1_37_type 1315 -#define _loop1_38_type 1316 -#define _loop0_39_type 1317 -#define _gather_40_type 1318 -#define _tmp_41_type 1319 -#define _tmp_42_type 1320 -#define _tmp_43_type 1321 -#define _loop0_44_type 1322 -#define _gather_45_type 1323 -#define _loop0_46_type 1324 -#define _gather_47_type 1325 -#define _tmp_48_type 1326 -#define _loop0_49_type 1327 -#define _gather_50_type 1328 -#define _loop0_51_type 1329 -#define _gather_52_type 1330 -#define _loop0_53_type 1331 -#define _gather_54_type 1332 -#define _loop1_55_type 1333 -#define _loop1_56_type 1334 -#define _loop0_57_type 1335 -#define _gather_58_type 1336 -#define _loop0_59_type 1337 -#define _gather_60_type 1338 -#define _loop1_61_type 1339 -#define _loop1_62_type 1340 -#define _loop1_63_type 1341 -#define _tmp_64_type 1342 -#define _loop0_65_type 1343 -#define _gather_66_type 1344 -#define _tmp_67_type 1345 -#define _tmp_68_type 1346 -#define _tmp_69_type 1347 -#define _tmp_70_type 1348 -#define _tmp_71_type 1349 -#define _loop0_72_type 1350 -#define _loop0_73_type 1351 -#define _loop1_74_type 1352 -#define _loop1_75_type 1353 -#define _loop0_76_type 1354 -#define _loop1_77_type 1355 -#define _loop0_78_type 1356 -#define _loop0_79_type 1357 -#define _loop0_80_type 1358 -#define _loop0_81_type 1359 -#define _loop1_82_type 1360 -#define _loop1_83_type 1361 -#define _tmp_84_type 1362 -#define _loop0_85_type 1363 -#define _gather_86_type 1364 -#define _loop1_87_type 1365 -#define _loop0_88_type 1366 -#define _tmp_89_type 1367 -#define _loop0_90_type 1368 -#define _gather_91_type 1369 -#define _tmp_92_type 1370 -#define _loop0_93_type 1371 -#define _gather_94_type 1372 -#define _loop0_95_type 1373 -#define _gather_96_type 1374 -#define _loop0_97_type 1375 -#define _loop0_98_type 1376 -#define _gather_99_type 1377 -#define _loop1_100_type 1378 -#define _tmp_101_type 1379 -#define _loop0_102_type 1380 -#define _gather_103_type 1381 -#define _loop0_104_type 1382 -#define _gather_105_type 1383 -#define _tmp_106_type 1384 -#define _tmp_107_type 1385 -#define _loop0_108_type 1386 -#define _gather_109_type 1387 -#define _tmp_110_type 1388 -#define _tmp_111_type 1389 -#define _tmp_112_type 1390 -#define _tmp_113_type 1391 -#define _tmp_114_type 1392 -#define _loop1_115_type 1393 -#define _tmp_116_type 1394 -#define _tmp_117_type 1395 -#define _tmp_118_type 1396 -#define _tmp_119_type 1397 -#define _tmp_120_type 1398 -#define _loop0_121_type 1399 -#define _loop0_122_type 1400 -#define _tmp_123_type 1401 -#define _tmp_124_type 1402 -#define _tmp_125_type 1403 -#define _tmp_126_type 1404 -#define _tmp_127_type 1405 -#define _tmp_128_type 1406 -#define _tmp_129_type 1407 -#define _tmp_130_type 1408 -#define _loop0_131_type 1409 -#define _gather_132_type 1410 -#define _tmp_133_type 1411 -#define _tmp_134_type 1412 -#define _tmp_135_type 1413 -#define _tmp_136_type 1414 -#define _loop0_137_type 1415 -#define _gather_138_type 1416 -#define _tmp_139_type 1417 -#define _loop0_140_type 1418 -#define _gather_141_type 1419 -#define _loop0_142_type 1420 -#define _gather_143_type 1421 -#define _tmp_144_type 1422 -#define _loop0_145_type 1423 -#define _tmp_146_type 1424 -#define _tmp_147_type 1425 -#define _tmp_148_type 1426 -#define _tmp_149_type 1427 -#define _tmp_150_type 1428 -#define _tmp_151_type 1429 -#define _tmp_152_type 1430 -#define _tmp_153_type 1431 -#define _tmp_154_type 1432 -#define _tmp_155_type 1433 -#define _tmp_156_type 1434 -#define _tmp_157_type 1435 -#define _tmp_158_type 1436 -#define _tmp_159_type 1437 -#define _tmp_160_type 1438 -#define _tmp_161_type 1439 -#define _tmp_162_type 1440 -#define _tmp_163_type 1441 -#define _tmp_164_type 1442 -#define _tmp_165_type 1443 -#define _tmp_166_type 1444 -#define _tmp_167_type 1445 -#define _tmp_168_type 1446 -#define _tmp_169_type 1447 -#define _tmp_170_type 1448 -#define _tmp_171_type 1449 -#define _tmp_172_type 1450 -#define _tmp_173_type 1451 -#define _loop0_174_type 1452 -#define _tmp_175_type 1453 -#define _tmp_176_type 1454 -#define _tmp_177_type 1455 -#define _tmp_178_type 1456 -#define _tmp_179_type 1457 -#define _tmp_180_type 1458 +#define star_named_expression_type 1115 +#define assignment_expression_type 1116 +#define named_expression_type 1117 +#define disjunction_type 1118 +#define conjunction_type 1119 +#define inversion_type 1120 +#define comparison_type 1121 +#define compare_op_bitwise_or_pair_type 1122 +#define bitwise_or_type 1123 // Left-recursive +#define bitwise_xor_type 1124 // Left-recursive +#define bitwise_and_type 1125 // Left-recursive +#define shift_expr_type 1126 // Left-recursive +#define sum_type 1127 // Left-recursive +#define term_type 1128 // Left-recursive +#define factor_type 1129 +#define power_type 1130 +#define await_primary_type 1131 +#define primary_type 1132 // Left-recursive +#define slices_type 1133 +#define slice_type 1134 +#define atom_type 1135 +#define group_type 1136 +#define lambdef_type 1137 +#define lambda_params_type 1138 +#define lambda_parameters_type 1139 +#define lambda_slash_no_default_type 1140 +#define lambda_slash_with_default_type 1141 +#define lambda_star_etc_type 1142 +#define lambda_kwds_type 1143 +#define lambda_param_no_default_type 1144 +#define lambda_param_with_default_type 1145 +#define lambda_param_maybe_default_type 1146 +#define lambda_param_type 1147 +#define fstring_middle_type 1148 +#define fstring_replacement_field_type 1149 +#define fstring_conversion_type 1150 +#define fstring_full_format_spec_type 1151 +#define fstring_format_spec_type 1152 +#define fstring_type 1153 +#define tstring_format_spec_replacement_field_type 1154 +#define tstring_format_spec_type 1155 +#define tstring_full_format_spec_type 1156 +#define tstring_replacement_field_type 1157 +#define tstring_middle_type 1158 +#define tstring_type 1159 +#define string_type 1160 +#define strings_type 1161 +#define display_items_type 1162 +#define display_item_type 1163 +#define list_type 1164 +#define tuple_type 1165 +#define set_type 1166 +#define dict_type 1167 +#define double_starred_kvpairs_type 1168 +#define double_starred_kvpair_type 1169 +#define kvpair_type 1170 +#define for_if_clauses_type 1171 +#define for_if_clause_type 1172 +#define listcomp_type 1173 +#define setcomp_type 1174 +#define genexp_type 1175 +#define dictcomp_type 1176 +#define arguments_type 1177 +#define args_type 1178 +#define kwargs_type 1179 +#define starred_expression_type 1180 +#define kwarg_or_starred_type 1181 +#define kwarg_or_double_starred_type 1182 +#define star_targets_type 1183 +#define star_target_type 1184 +#define target_type 1185 +#define single_target_type 1186 +#define attribute_or_subscript_target_type 1187 +#define target_value_type 1188 +#define del_targets_type 1189 +#define del_target_type 1190 +#define type_expressions_type 1191 +#define func_type_comment_type 1192 +#define _loop0_1_type 1265 +#define _loop1_2_type 1266 +#define _loop0_3_type 1267 +#define _gather_4_type 1268 +#define _tmp_5_type 1269 +#define _tmp_6_type 1270 +#define _tmp_7_type 1271 +#define _tmp_8_type 1272 +#define _tmp_9_type 1273 +#define _tmp_10_type 1274 +#define _tmp_11_type 1275 +#define _loop1_12_type 1276 +#define _loop0_13_type 1277 +#define _gather_14_type 1278 +#define _tmp_15_type 1279 +#define _tmp_16_type 1280 +#define _loop0_17_type 1281 +#define _loop1_18_type 1282 +#define _loop0_19_type 1283 +#define _gather_20_type 1284 +#define _tmp_21_type 1285 +#define _loop0_22_type 1286 +#define _gather_23_type 1287 +#define _loop1_24_type 1288 +#define _tmp_25_type 1289 +#define _tmp_26_type 1290 +#define _loop0_27_type 1291 +#define _loop0_28_type 1292 +#define _loop1_29_type 1293 +#define _loop1_30_type 1294 +#define _loop0_31_type 1295 +#define _loop1_32_type 1296 +#define _loop0_33_type 1297 +#define _gather_34_type 1298 +#define _tmp_35_type 1299 +#define _loop1_36_type 1300 +#define _loop1_37_type 1301 +#define _loop1_38_type 1302 +#define _loop0_39_type 1303 +#define _gather_40_type 1304 +#define _tmp_41_type 1305 +#define _tmp_42_type 1306 +#define _tmp_43_type 1307 +#define _loop0_44_type 1308 +#define _gather_45_type 1309 +#define _loop0_46_type 1310 +#define _gather_47_type 1311 +#define _tmp_48_type 1312 +#define _loop0_49_type 1313 +#define _gather_50_type 1314 +#define _loop0_51_type 1315 +#define _gather_52_type 1316 +#define _loop0_53_type 1317 +#define _gather_54_type 1318 +#define _loop1_55_type 1319 +#define _loop1_56_type 1320 +#define _loop0_57_type 1321 +#define _gather_58_type 1322 +#define _loop1_59_type 1323 +#define _loop1_60_type 1324 +#define _loop1_61_type 1325 +#define _tmp_62_type 1326 +#define _loop0_63_type 1327 +#define _gather_64_type 1328 +#define _tmp_65_type 1329 +#define _tmp_66_type 1330 +#define _tmp_67_type 1331 +#define _tmp_68_type 1332 +#define _tmp_69_type 1333 +#define _loop0_70_type 1334 +#define _loop0_71_type 1335 +#define _loop1_72_type 1336 +#define _loop1_73_type 1337 +#define _loop0_74_type 1338 +#define _loop1_75_type 1339 +#define _loop0_76_type 1340 +#define _loop0_77_type 1341 +#define _loop0_78_type 1342 +#define _loop0_79_type 1343 +#define _loop1_80_type 1344 +#define _loop1_81_type 1345 +#define _loop0_82_type 1346 +#define _gather_83_type 1347 +#define _tmp_84_type 1348 +#define _loop0_85_type 1349 +#define _gather_86_type 1350 +#define _loop1_87_type 1351 +#define _loop0_88_type 1352 +#define _tmp_89_type 1353 +#define _loop0_90_type 1354 +#define _gather_91_type 1355 +#define _tmp_92_type 1356 +#define _loop0_93_type 1357 +#define _gather_94_type 1358 +#define _tmp_95_type 1359 +#define _loop0_96_type 1360 +#define _gather_97_type 1361 +#define _loop0_98_type 1362 +#define _tmp_99_type 1363 +#define _tmp_100_type 1364 +#define _loop0_101_type 1365 +#define _gather_102_type 1366 +#define _loop0_103_type 1367 +#define _gather_104_type 1368 +#define _tmp_105_type 1369 +#define _tmp_178_type 1442 +#define _tmp_179_type 1443 +#define _tmp_180_type 1444 +#define _tmp_181_type 1445 +#define _tmp_182_type 1446 +#define _tmp_183_type 1447 +#define _tmp_184_type 1448 +#define _tmp_185_type 1449 +#define _tmp_186_type 1450 +#define _tmp_187_type 1451 +#define _tmp_188_type 1452 +#define _tmp_200_type 1464 + +// Rules shared between the C files of this parser +#define simple_stmt_rule _PyPegen_simple_stmt_rule +Py_LOCAL_SYMBOL stmt_ty simple_stmt_rule(Parser *p); +#define annotated_rhs_rule _PyPegen_annotated_rhs_rule +Py_LOCAL_SYMBOL expr_ty annotated_rhs_rule(Parser *p); +#define augassign_rule _PyPegen_augassign_rule +Py_LOCAL_SYMBOL AugOperator* augassign_rule(Parser *p); +#define pass_stmt_rule _PyPegen_pass_stmt_rule +Py_LOCAL_SYMBOL stmt_ty pass_stmt_rule(Parser *p); +#define break_stmt_rule _PyPegen_break_stmt_rule +Py_LOCAL_SYMBOL stmt_ty break_stmt_rule(Parser *p); +#define continue_stmt_rule _PyPegen_continue_stmt_rule +Py_LOCAL_SYMBOL stmt_ty continue_stmt_rule(Parser *p); +#define import_from_targets_rule _PyPegen_import_from_targets_rule +Py_LOCAL_SYMBOL asdl_alias_seq* import_from_targets_rule(Parser *p); +#define import_from_as_names_rule _PyPegen_import_from_as_names_rule +Py_LOCAL_SYMBOL asdl_alias_seq* import_from_as_names_rule(Parser *p); +#define dotted_name_rule _PyPegen_dotted_name_rule +Py_LOCAL_SYMBOL expr_ty dotted_name_rule(Parser *p); +#define block_rule _PyPegen_block_rule +Py_LOCAL_SYMBOL asdl_stmt_seq* block_rule(Parser *p); +#define params_rule _PyPegen_params_rule +Py_LOCAL_SYMBOL arguments_ty params_rule(Parser *p); +#define slash_no_default_rule _PyPegen_slash_no_default_rule +Py_LOCAL_SYMBOL asdl_arg_seq* slash_no_default_rule(Parser *p); +#define slash_with_default_rule _PyPegen_slash_with_default_rule +Py_LOCAL_SYMBOL SlashWithDefault* slash_with_default_rule(Parser *p); +#define param_no_default_rule _PyPegen_param_no_default_rule +Py_LOCAL_SYMBOL arg_ty param_no_default_rule(Parser *p); +#define param_with_default_rule _PyPegen_param_with_default_rule +Py_LOCAL_SYMBOL NameDefaultPair* param_with_default_rule(Parser *p); +#define param_maybe_default_rule _PyPegen_param_maybe_default_rule +Py_LOCAL_SYMBOL NameDefaultPair* param_maybe_default_rule(Parser *p); +#define param_rule _PyPegen_param_rule +Py_LOCAL_SYMBOL arg_ty param_rule(Parser *p); +#define except_block_rule _PyPegen_except_block_rule +Py_LOCAL_SYMBOL excepthandler_ty except_block_rule(Parser *p); +#define except_star_block_rule _PyPegen_except_star_block_rule +Py_LOCAL_SYMBOL excepthandler_ty except_star_block_rule(Parser *p); +#define subject_expr_rule _PyPegen_subject_expr_rule +Py_LOCAL_SYMBOL expr_ty subject_expr_rule(Parser *p); +#define guard_rule _PyPegen_guard_rule +Py_LOCAL_SYMBOL expr_ty guard_rule(Parser *p); +#define patterns_rule _PyPegen_patterns_rule +Py_LOCAL_SYMBOL pattern_ty patterns_rule(Parser *p); +#define or_pattern_rule _PyPegen_or_pattern_rule +Py_LOCAL_SYMBOL pattern_ty or_pattern_rule(Parser *p); +#define name_or_attr_rule _PyPegen_name_or_attr_rule +Py_LOCAL_SYMBOL expr_ty name_or_attr_rule(Parser *p); +#define items_pattern_rule _PyPegen_items_pattern_rule +Py_LOCAL_SYMBOL asdl_seq* items_pattern_rule(Parser *p); +#define double_star_pattern_rule _PyPegen_double_star_pattern_rule +Py_LOCAL_SYMBOL expr_ty double_star_pattern_rule(Parser *p); +#define positional_patterns_rule _PyPegen_positional_patterns_rule +Py_LOCAL_SYMBOL asdl_pattern_seq* positional_patterns_rule(Parser *p); +#define keyword_patterns_rule _PyPegen_keyword_patterns_rule +Py_LOCAL_SYMBOL asdl_seq* keyword_patterns_rule(Parser *p); +#define type_params_rule _PyPegen_type_params_rule +Py_LOCAL_SYMBOL asdl_type_param_seq* type_params_rule(Parser *p); +#define expressions_rule _PyPegen_expressions_rule +Py_LOCAL_SYMBOL expr_ty expressions_rule(Parser *p); +#define expression_rule _PyPegen_expression_rule +Py_LOCAL_SYMBOL expr_ty expression_rule(Parser *p); +#define if_expression_rule _PyPegen_if_expression_rule +Py_LOCAL_SYMBOL expr_ty if_expression_rule(Parser *p); +#define yield_expr_rule _PyPegen_yield_expr_rule +Py_LOCAL_SYMBOL expr_ty yield_expr_rule(Parser *p); +#define star_expressions_rule _PyPegen_star_expressions_rule +Py_LOCAL_SYMBOL expr_ty star_expressions_rule(Parser *p); +#define star_named_expressions_rule _PyPegen_star_named_expressions_rule +Py_LOCAL_SYMBOL asdl_expr_seq* star_named_expressions_rule(Parser *p); +#define star_named_expression_rule _PyPegen_star_named_expression_rule +Py_LOCAL_SYMBOL expr_ty star_named_expression_rule(Parser *p); +#define assignment_expression_rule _PyPegen_assignment_expression_rule +Py_LOCAL_SYMBOL expr_ty assignment_expression_rule(Parser *p); +#define named_expression_rule _PyPegen_named_expression_rule +Py_LOCAL_SYMBOL expr_ty named_expression_rule(Parser *p); +#define disjunction_rule _PyPegen_disjunction_rule +Py_LOCAL_SYMBOL expr_ty disjunction_rule(Parser *p); +#define inversion_rule _PyPegen_inversion_rule +Py_LOCAL_SYMBOL expr_ty inversion_rule(Parser *p); +#define bitwise_or_rule _PyPegen_bitwise_or_rule +Py_LOCAL_SYMBOL expr_ty bitwise_or_rule(Parser *p); +#define bitwise_and_rule _PyPegen_bitwise_and_rule +Py_LOCAL_SYMBOL expr_ty bitwise_and_rule(Parser *p); +#define sum_rule _PyPegen_sum_rule +Py_LOCAL_SYMBOL expr_ty sum_rule(Parser *p); +#define factor_rule _PyPegen_factor_rule +Py_LOCAL_SYMBOL expr_ty factor_rule(Parser *p); +#define lambdef_rule _PyPegen_lambdef_rule +Py_LOCAL_SYMBOL expr_ty lambdef_rule(Parser *p); +#define lambda_params_rule _PyPegen_lambda_params_rule +Py_LOCAL_SYMBOL arguments_ty lambda_params_rule(Parser *p); +#define lambda_slash_no_default_rule _PyPegen_lambda_slash_no_default_rule +Py_LOCAL_SYMBOL asdl_arg_seq* lambda_slash_no_default_rule(Parser *p); +#define lambda_slash_with_default_rule _PyPegen_lambda_slash_with_default_rule +Py_LOCAL_SYMBOL SlashWithDefault* lambda_slash_with_default_rule(Parser *p); +#define lambda_param_no_default_rule _PyPegen_lambda_param_no_default_rule +Py_LOCAL_SYMBOL arg_ty lambda_param_no_default_rule(Parser *p); +#define lambda_param_with_default_rule _PyPegen_lambda_param_with_default_rule +Py_LOCAL_SYMBOL NameDefaultPair* lambda_param_with_default_rule(Parser *p); +#define lambda_param_maybe_default_rule _PyPegen_lambda_param_maybe_default_rule +Py_LOCAL_SYMBOL NameDefaultPair* lambda_param_maybe_default_rule(Parser *p); +#define lambda_param_rule _PyPegen_lambda_param_rule +Py_LOCAL_SYMBOL arg_ty lambda_param_rule(Parser *p); +#define fstring_format_spec_rule _PyPegen_fstring_format_spec_rule +Py_LOCAL_SYMBOL expr_ty fstring_format_spec_rule(Parser *p); +#define fstring_rule _PyPegen_fstring_rule +Py_LOCAL_SYMBOL expr_ty fstring_rule(Parser *p); +#define tstring_rule _PyPegen_tstring_rule +Py_LOCAL_SYMBOL expr_ty tstring_rule(Parser *p); +#define string_rule _PyPegen_string_rule +Py_LOCAL_SYMBOL expr_ty string_rule(Parser *p); +#define list_rule _PyPegen_list_rule +Py_LOCAL_SYMBOL expr_ty list_rule(Parser *p); +#define tuple_rule _PyPegen_tuple_rule +Py_LOCAL_SYMBOL expr_ty tuple_rule(Parser *p); +#define double_starred_kvpair_rule _PyPegen_double_starred_kvpair_rule +Py_LOCAL_SYMBOL KeyValuePair* double_starred_kvpair_rule(Parser *p); +#define for_if_clauses_rule _PyPegen_for_if_clauses_rule +Py_LOCAL_SYMBOL asdl_comprehension_seq* for_if_clauses_rule(Parser *p); +#define genexp_rule _PyPegen_genexp_rule +Py_LOCAL_SYMBOL expr_ty genexp_rule(Parser *p); +#define arguments_rule _PyPegen_arguments_rule +Py_LOCAL_SYMBOL expr_ty arguments_rule(Parser *p); +#define args_rule _PyPegen_args_rule +Py_LOCAL_SYMBOL expr_ty args_rule(Parser *p); +#define kwargs_rule _PyPegen_kwargs_rule +Py_LOCAL_SYMBOL asdl_seq* kwargs_rule(Parser *p); +#define starred_expression_rule _PyPegen_starred_expression_rule +Py_LOCAL_SYMBOL expr_ty starred_expression_rule(Parser *p); +#define star_targets_rule _PyPegen_star_targets_rule +Py_LOCAL_SYMBOL expr_ty star_targets_rule(Parser *p); +#define star_target_rule _PyPegen_star_target_rule +Py_LOCAL_SYMBOL expr_ty star_target_rule(Parser *p); +#define func_type_comment_rule _PyPegen_func_type_comment_rule +Py_LOCAL_SYMBOL Token* func_type_comment_rule(Parser *p); +#define invalid_arguments_rule _PyPegen_invalid_arguments_rule +Py_LOCAL_SYMBOL void *invalid_arguments_rule(Parser *p); +#define invalid_kwarg_rule _PyPegen_invalid_kwarg_rule +Py_LOCAL_SYMBOL void *invalid_kwarg_rule(Parser *p); +#define invalid_legacy_expression_rule _PyPegen_invalid_legacy_expression_rule +Py_LOCAL_SYMBOL void *invalid_legacy_expression_rule(Parser *p); +#define invalid_type_param_rule _PyPegen_invalid_type_param_rule +Py_LOCAL_SYMBOL void *invalid_type_param_rule(Parser *p); +#define invalid_expression_rule _PyPegen_invalid_expression_rule +Py_LOCAL_SYMBOL void *invalid_expression_rule(Parser *p); +#define invalid_if_expression_rule _PyPegen_invalid_if_expression_rule +Py_LOCAL_SYMBOL void *invalid_if_expression_rule(Parser *p); +#define invalid_named_expression_rule _PyPegen_invalid_named_expression_rule +Py_LOCAL_SYMBOL void *invalid_named_expression_rule(Parser *p); +#define invalid_assignment_rule _PyPegen_invalid_assignment_rule +Py_LOCAL_SYMBOL void *invalid_assignment_rule(Parser *p); +#define invalid_raise_stmt_rule _PyPegen_invalid_raise_stmt_rule +Py_LOCAL_SYMBOL void *invalid_raise_stmt_rule(Parser *p); +#define invalid_del_stmt_rule _PyPegen_invalid_del_stmt_rule +Py_LOCAL_SYMBOL void *invalid_del_stmt_rule(Parser *p); +#define invalid_assert_stmt_rule _PyPegen_invalid_assert_stmt_rule +Py_LOCAL_SYMBOL void *invalid_assert_stmt_rule(Parser *p); +#define invalid_block_rule _PyPegen_invalid_block_rule +Py_LOCAL_SYMBOL void *invalid_block_rule(Parser *p); +#define invalid_comprehension_rule _PyPegen_invalid_comprehension_rule +Py_LOCAL_SYMBOL void *invalid_comprehension_rule(Parser *p); +#define invalid_parameters_rule _PyPegen_invalid_parameters_rule +Py_LOCAL_SYMBOL void *invalid_parameters_rule(Parser *p); +#define invalid_default_rule _PyPegen_invalid_default_rule +Py_LOCAL_SYMBOL void *invalid_default_rule(Parser *p); +#define invalid_star_etc_rule _PyPegen_invalid_star_etc_rule +Py_LOCAL_SYMBOL void *invalid_star_etc_rule(Parser *p); +#define invalid_kwds_rule _PyPegen_invalid_kwds_rule +Py_LOCAL_SYMBOL void *invalid_kwds_rule(Parser *p); +#define invalid_lambda_parameters_rule _PyPegen_invalid_lambda_parameters_rule +Py_LOCAL_SYMBOL void *invalid_lambda_parameters_rule(Parser *p); +#define invalid_lambda_star_etc_rule _PyPegen_invalid_lambda_star_etc_rule +Py_LOCAL_SYMBOL void *invalid_lambda_star_etc_rule(Parser *p); +#define invalid_lambda_kwds_rule _PyPegen_invalid_lambda_kwds_rule +Py_LOCAL_SYMBOL void *invalid_lambda_kwds_rule(Parser *p); +#define invalid_double_type_comments_rule _PyPegen_invalid_double_type_comments_rule +Py_LOCAL_SYMBOL void *invalid_double_type_comments_rule(Parser *p); +#define invalid_with_item_rule _PyPegen_invalid_with_item_rule +Py_LOCAL_SYMBOL void *invalid_with_item_rule(Parser *p); +#define invalid_for_if_clause_rule _PyPegen_invalid_for_if_clause_rule +Py_LOCAL_SYMBOL void *invalid_for_if_clause_rule(Parser *p); +#define invalid_for_target_rule _PyPegen_invalid_for_target_rule +Py_LOCAL_SYMBOL void *invalid_for_target_rule(Parser *p); +#define invalid_group_rule _PyPegen_invalid_group_rule +Py_LOCAL_SYMBOL void *invalid_group_rule(Parser *p); +#define invalid_import_rule _PyPegen_invalid_import_rule +Py_LOCAL_SYMBOL void *invalid_import_rule(Parser *p); +#define invalid_dotted_as_name_rule _PyPegen_invalid_dotted_as_name_rule +Py_LOCAL_SYMBOL void *invalid_dotted_as_name_rule(Parser *p); +#define invalid_import_from_as_name_rule _PyPegen_invalid_import_from_as_name_rule +Py_LOCAL_SYMBOL void *invalid_import_from_as_name_rule(Parser *p); +#define invalid_import_from_rule _PyPegen_invalid_import_from_rule +Py_LOCAL_SYMBOL void *invalid_import_from_rule(Parser *p); +#define invalid_import_from_targets_rule _PyPegen_invalid_import_from_targets_rule +Py_LOCAL_SYMBOL void *invalid_import_from_targets_rule(Parser *p); +#define invalid_with_stmt_rule _PyPegen_invalid_with_stmt_rule +Py_LOCAL_SYMBOL void *invalid_with_stmt_rule(Parser *p); +#define invalid_with_stmt_indent_rule _PyPegen_invalid_with_stmt_indent_rule +Py_LOCAL_SYMBOL void *invalid_with_stmt_indent_rule(Parser *p); +#define invalid_try_stmt_rule _PyPegen_invalid_try_stmt_rule +Py_LOCAL_SYMBOL void *invalid_try_stmt_rule(Parser *p); +#define invalid_except_stmt_rule _PyPegen_invalid_except_stmt_rule +Py_LOCAL_SYMBOL void *invalid_except_stmt_rule(Parser *p); +#define invalid_except_star_stmt_rule _PyPegen_invalid_except_star_stmt_rule +Py_LOCAL_SYMBOL void *invalid_except_star_stmt_rule(Parser *p); +#define invalid_finally_stmt_rule _PyPegen_invalid_finally_stmt_rule +Py_LOCAL_SYMBOL void *invalid_finally_stmt_rule(Parser *p); +#define invalid_except_stmt_indent_rule _PyPegen_invalid_except_stmt_indent_rule +Py_LOCAL_SYMBOL void *invalid_except_stmt_indent_rule(Parser *p); +#define invalid_except_star_stmt_indent_rule _PyPegen_invalid_except_star_stmt_indent_rule +Py_LOCAL_SYMBOL void *invalid_except_star_stmt_indent_rule(Parser *p); +#define invalid_match_stmt_rule _PyPegen_invalid_match_stmt_rule +Py_LOCAL_SYMBOL void *invalid_match_stmt_rule(Parser *p); +#define invalid_case_block_rule _PyPegen_invalid_case_block_rule +Py_LOCAL_SYMBOL void *invalid_case_block_rule(Parser *p); +#define invalid_as_pattern_rule _PyPegen_invalid_as_pattern_rule +Py_LOCAL_SYMBOL void *invalid_as_pattern_rule(Parser *p); +#define invalid_class_pattern_rule _PyPegen_invalid_class_pattern_rule +Py_LOCAL_SYMBOL void *invalid_class_pattern_rule(Parser *p); +#define invalid_mapping_pattern_rule _PyPegen_invalid_mapping_pattern_rule +Py_LOCAL_SYMBOL void *invalid_mapping_pattern_rule(Parser *p); +#define invalid_if_stmt_rule _PyPegen_invalid_if_stmt_rule +Py_LOCAL_SYMBOL void *invalid_if_stmt_rule(Parser *p); +#define invalid_elif_stmt_rule _PyPegen_invalid_elif_stmt_rule +Py_LOCAL_SYMBOL void *invalid_elif_stmt_rule(Parser *p); +#define invalid_else_stmt_rule _PyPegen_invalid_else_stmt_rule +Py_LOCAL_SYMBOL void *invalid_else_stmt_rule(Parser *p); +#define invalid_while_stmt_rule _PyPegen_invalid_while_stmt_rule +Py_LOCAL_SYMBOL void *invalid_while_stmt_rule(Parser *p); +#define invalid_for_stmt_rule _PyPegen_invalid_for_stmt_rule +Py_LOCAL_SYMBOL void *invalid_for_stmt_rule(Parser *p); +#define invalid_def_raw_rule _PyPegen_invalid_def_raw_rule +Py_LOCAL_SYMBOL void *invalid_def_raw_rule(Parser *p); +#define invalid_class_def_raw_rule _PyPegen_invalid_class_def_raw_rule +Py_LOCAL_SYMBOL void *invalid_class_def_raw_rule(Parser *p); +#define invalid_double_starred_kvpairs_rule _PyPegen_invalid_double_starred_kvpairs_rule +Py_LOCAL_SYMBOL void *invalid_double_starred_kvpairs_rule(Parser *p); +#define invalid_starred_expression_unpacking_rule _PyPegen_invalid_starred_expression_unpacking_rule +Py_LOCAL_SYMBOL void *invalid_starred_expression_unpacking_rule(Parser *p); +#define invalid_starred_expression_unpacking_sequence_rule _PyPegen_invalid_starred_expression_unpacking_sequence_rule +Py_LOCAL_SYMBOL void *invalid_starred_expression_unpacking_sequence_rule(Parser *p); +#define invalid_starred_expression_rule _PyPegen_invalid_starred_expression_rule +Py_LOCAL_SYMBOL void *invalid_starred_expression_rule(Parser *p); +#define invalid_fstring_replacement_field_rule _PyPegen_invalid_fstring_replacement_field_rule +Py_LOCAL_SYMBOL void *invalid_fstring_replacement_field_rule(Parser *p); +#define invalid_tstring_replacement_field_rule _PyPegen_invalid_tstring_replacement_field_rule +Py_LOCAL_SYMBOL void *invalid_tstring_replacement_field_rule(Parser *p); +#define invalid_string_tstring_concat_rule _PyPegen_invalid_string_tstring_concat_rule +Py_LOCAL_SYMBOL void *invalid_string_tstring_concat_rule(Parser *p); +#define invalid_arithmetic_rule _PyPegen_invalid_arithmetic_rule +Py_LOCAL_SYMBOL void *invalid_arithmetic_rule(Parser *p); +#define invalid_factor_rule _PyPegen_invalid_factor_rule +Py_LOCAL_SYMBOL void *invalid_factor_rule(Parser *p); +#define invalid_type_params_rule _PyPegen_invalid_type_params_rule +Py_LOCAL_SYMBOL void *invalid_type_params_rule(Parser *p); +#define invalid_bitwise_and_rule _PyPegen_invalid_bitwise_and_rule +Py_LOCAL_SYMBOL void *invalid_bitwise_and_rule(Parser *p); +#define invalid_bitwise_or_rule _PyPegen_invalid_bitwise_or_rule +Py_LOCAL_SYMBOL void *invalid_bitwise_or_rule(Parser *p); +#define invalid_noteq_rule _PyPegen_invalid_noteq_rule +Py_LOCAL_SYMBOL void *invalid_noteq_rule(Parser *p); static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -555,16 +670,10 @@ static asdl_stmt_seq* statement_rule(Parser *p); static asdl_stmt_seq* single_compound_stmt_rule(Parser *p); static asdl_stmt_seq* statement_newline_rule(Parser *p); static asdl_stmt_seq* simple_stmts_rule(Parser *p); -static stmt_ty simple_stmt_rule(Parser *p); static stmt_ty compound_stmt_rule(Parser *p); static stmt_ty assignment_rule(Parser *p); -static expr_ty annotated_rhs_rule(Parser *p); -static AugOperator* augassign_rule(Parser *p); static stmt_ty return_stmt_rule(Parser *p); static stmt_ty raise_stmt_rule(Parser *p); -static stmt_ty pass_stmt_rule(Parser *p); -static stmt_ty break_stmt_rule(Parser *p); -static stmt_ty continue_stmt_rule(Parser *p); static stmt_ty global_stmt_rule(Parser *p); static stmt_ty nonlocal_stmt_rule(Parser *p); static stmt_ty del_stmt_rule(Parser *p); @@ -573,29 +682,18 @@ static stmt_ty assert_stmt_rule(Parser *p); static stmt_ty import_stmt_rule(Parser *p); static stmt_ty import_name_rule(Parser *p); static stmt_ty import_from_rule(Parser *p); -static asdl_alias_seq* import_from_targets_rule(Parser *p); -static asdl_alias_seq* import_from_as_names_rule(Parser *p); static alias_ty import_from_as_name_rule(Parser *p); static asdl_alias_seq* dotted_as_names_rule(Parser *p); static alias_ty dotted_as_name_rule(Parser *p); -static expr_ty dotted_name_rule(Parser *p); -static asdl_stmt_seq* block_rule(Parser *p); static asdl_expr_seq* decorators_rule(Parser *p); static stmt_ty class_def_rule(Parser *p); static stmt_ty class_def_raw_rule(Parser *p); static stmt_ty function_def_rule(Parser *p); static stmt_ty function_def_raw_rule(Parser *p); -static arguments_ty params_rule(Parser *p); static arguments_ty parameters_rule(Parser *p); -static asdl_arg_seq* slash_no_default_rule(Parser *p); -static SlashWithDefault* slash_with_default_rule(Parser *p); static StarEtc* star_etc_rule(Parser *p); static arg_ty kwds_rule(Parser *p); -static arg_ty param_no_default_rule(Parser *p); static arg_ty param_no_default_star_annotation_rule(Parser *p); -static NameDefaultPair* param_with_default_rule(Parser *p); -static NameDefaultPair* param_maybe_default_rule(Parser *p); -static arg_ty param_rule(Parser *p); static arg_ty param_star_annotation_rule(Parser *p); static expr_ty annotation_rule(Parser *p); static expr_ty star_annotation_rule(Parser *p); @@ -608,17 +706,11 @@ static stmt_ty for_stmt_rule(Parser *p); static stmt_ty with_stmt_rule(Parser *p); static withitem_ty with_item_rule(Parser *p); static stmt_ty try_stmt_rule(Parser *p); -static excepthandler_ty except_block_rule(Parser *p); -static excepthandler_ty except_star_block_rule(Parser *p); static asdl_stmt_seq* finally_block_rule(Parser *p); static stmt_ty match_stmt_rule(Parser *p); -static expr_ty subject_expr_rule(Parser *p); static match_case_ty case_block_rule(Parser *p); -static expr_ty guard_rule(Parser *p); -static pattern_ty patterns_rule(Parser *p); static pattern_ty pattern_rule(Parser *p); static pattern_ty as_pattern_rule(Parser *p); -static pattern_ty or_pattern_rule(Parser *p); static pattern_ty closed_pattern_rule(Parser *p); static pattern_ty literal_pattern_rule(Parser *p); static expr_ty literal_expr_rule(Parser *p); @@ -632,7 +724,6 @@ static expr_ty pattern_capture_target_rule(Parser *p); static pattern_ty wildcard_pattern_rule(Parser *p); static pattern_ty value_pattern_rule(Parser *p); static expr_ty attr_rule(Parser *p); -static expr_ty name_or_attr_rule(Parser *p); static pattern_ty group_pattern_rule(Parser *p); static pattern_ty sequence_pattern_rule(Parser *p); static asdl_seq* open_sequence_pattern_rule(Parser *p); @@ -640,54 +731,22 @@ static asdl_seq* maybe_sequence_pattern_rule(Parser *p); static pattern_ty maybe_star_pattern_rule(Parser *p); static pattern_ty star_pattern_rule(Parser *p); static pattern_ty mapping_pattern_rule(Parser *p); -static asdl_seq* items_pattern_rule(Parser *p); static KeyPatternPair* key_value_pattern_rule(Parser *p); -static expr_ty double_star_pattern_rule(Parser *p); static pattern_ty class_pattern_rule(Parser *p); -static asdl_pattern_seq* positional_patterns_rule(Parser *p); -static asdl_seq* keyword_patterns_rule(Parser *p); static KeyPatternPair* keyword_pattern_rule(Parser *p); static stmt_ty type_alias_rule(Parser *p); -static asdl_type_param_seq* type_params_rule(Parser *p); static asdl_type_param_seq* type_param_seq_rule(Parser *p); static type_param_ty type_param_rule(Parser *p); static expr_ty type_param_bound_rule(Parser *p); static expr_ty type_param_default_rule(Parser *p); static expr_ty type_param_starred_default_rule(Parser *p); -static expr_ty expressions_rule(Parser *p); -static expr_ty expression_rule(Parser *p); -static expr_ty if_expression_rule(Parser *p); -static expr_ty yield_expr_rule(Parser *p); -static expr_ty star_expressions_rule(Parser *p); static expr_ty star_expression_rule(Parser *p); -static asdl_expr_seq* star_named_expressions_rule(Parser *p); -static asdl_expr_seq* star_named_expressions_sequence_rule(Parser *p); -static expr_ty star_named_expression_rule(Parser *p); -static expr_ty star_named_expression_sequence_rule(Parser *p); -static expr_ty assignment_expression_rule(Parser *p); -static expr_ty named_expression_rule(Parser *p); -static expr_ty disjunction_rule(Parser *p); static expr_ty conjunction_rule(Parser *p); -static expr_ty inversion_rule(Parser *p); static expr_ty comparison_rule(Parser *p); static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p); -static CmpopExprPair* eq_bitwise_or_rule(Parser *p); -static CmpopExprPair* noteq_bitwise_or_rule(Parser *p); -static CmpopExprPair* lte_bitwise_or_rule(Parser *p); -static CmpopExprPair* lt_bitwise_or_rule(Parser *p); -static CmpopExprPair* gte_bitwise_or_rule(Parser *p); -static CmpopExprPair* gt_bitwise_or_rule(Parser *p); -static CmpopExprPair* notin_bitwise_or_rule(Parser *p); -static CmpopExprPair* in_bitwise_or_rule(Parser *p); -static CmpopExprPair* isnot_bitwise_or_rule(Parser *p); -static CmpopExprPair* is_bitwise_or_rule(Parser *p); -static expr_ty bitwise_or_rule(Parser *p); static expr_ty bitwise_xor_rule(Parser *p); -static expr_ty bitwise_and_rule(Parser *p); static expr_ty shift_expr_rule(Parser *p); -static expr_ty sum_rule(Parser *p); static expr_ty term_rule(Parser *p); -static expr_ty factor_rule(Parser *p); static expr_ty power_rule(Parser *p); static expr_ty await_primary_rule(Parser *p); static expr_ty primary_rule(Parser *p); @@ -695,136 +754,38 @@ static expr_ty slices_rule(Parser *p); static expr_ty slice_rule(Parser *p); static expr_ty atom_rule(Parser *p); static expr_ty group_rule(Parser *p); -static expr_ty lambdef_rule(Parser *p); -static arguments_ty lambda_params_rule(Parser *p); static arguments_ty lambda_parameters_rule(Parser *p); -static asdl_arg_seq* lambda_slash_no_default_rule(Parser *p); -static SlashWithDefault* lambda_slash_with_default_rule(Parser *p); static StarEtc* lambda_star_etc_rule(Parser *p); static arg_ty lambda_kwds_rule(Parser *p); -static arg_ty lambda_param_no_default_rule(Parser *p); -static NameDefaultPair* lambda_param_with_default_rule(Parser *p); -static NameDefaultPair* lambda_param_maybe_default_rule(Parser *p); -static arg_ty lambda_param_rule(Parser *p); static expr_ty fstring_middle_rule(Parser *p); static expr_ty fstring_replacement_field_rule(Parser *p); static ResultTokenWithMetadata* fstring_conversion_rule(Parser *p); static ResultTokenWithMetadata* fstring_full_format_spec_rule(Parser *p); -static expr_ty fstring_format_spec_rule(Parser *p); -static expr_ty fstring_rule(Parser *p); static expr_ty tstring_format_spec_replacement_field_rule(Parser *p); static expr_ty tstring_format_spec_rule(Parser *p); static ResultTokenWithMetadata* tstring_full_format_spec_rule(Parser *p); static expr_ty tstring_replacement_field_rule(Parser *p); static expr_ty tstring_middle_rule(Parser *p); -static expr_ty tstring_rule(Parser *p); -static expr_ty string_rule(Parser *p); static expr_ty strings_rule(Parser *p); -static expr_ty list_rule(Parser *p); -static expr_ty tuple_rule(Parser *p); +static asdl_expr_seq* display_items_rule(Parser *p); +static expr_ty display_item_rule(Parser *p); static expr_ty set_rule(Parser *p); static expr_ty dict_rule(Parser *p); static asdl_seq* double_starred_kvpairs_rule(Parser *p); -static KeyValuePair* double_starred_kvpair_rule(Parser *p); static KeyValuePair* kvpair_rule(Parser *p); -static asdl_comprehension_seq* for_if_clauses_rule(Parser *p); static comprehension_ty for_if_clause_rule(Parser *p); static expr_ty listcomp_rule(Parser *p); static expr_ty setcomp_rule(Parser *p); -static expr_ty genexp_rule(Parser *p); static expr_ty dictcomp_rule(Parser *p); -static expr_ty arguments_rule(Parser *p); -static expr_ty args_rule(Parser *p); -static asdl_seq* kwargs_rule(Parser *p); -static expr_ty starred_expression_rule(Parser *p); static KeywordOrStarred* kwarg_or_starred_rule(Parser *p); static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p); -static expr_ty star_targets_rule(Parser *p); -static asdl_expr_seq* star_targets_list_seq_rule(Parser *p); -static asdl_expr_seq* star_targets_tuple_seq_rule(Parser *p); -static expr_ty star_target_rule(Parser *p); -static expr_ty target_with_star_atom_rule(Parser *p); -static expr_ty star_atom_rule(Parser *p); +static expr_ty target_rule(Parser *p); static expr_ty single_target_rule(Parser *p); -static expr_ty single_subscript_attribute_target_rule(Parser *p); -static expr_ty t_primary_rule(Parser *p); -static void *t_lookahead_rule(Parser *p); +static expr_ty attribute_or_subscript_target_rule(Parser *p); +static expr_ty target_value_rule(Parser *p); static asdl_expr_seq* del_targets_rule(Parser *p); static expr_ty del_target_rule(Parser *p); -static expr_ty del_t_atom_rule(Parser *p); static asdl_expr_seq* type_expressions_rule(Parser *p); -static Token* func_type_comment_rule(Parser *p); -static void *invalid_arguments_rule(Parser *p); -static void *invalid_kwarg_rule(Parser *p); -static expr_ty expression_without_invalid_rule(Parser *p); -static void *invalid_legacy_expression_rule(Parser *p); -static void *invalid_type_param_rule(Parser *p); -static void *invalid_expression_rule(Parser *p); -static void *invalid_if_expression_rule(Parser *p); -static void *invalid_named_expression_rule(Parser *p); -static void *invalid_assignment_rule(Parser *p); -static expr_ty invalid_ann_assign_target_rule(Parser *p); -static void *invalid_raise_stmt_rule(Parser *p); -static void *invalid_del_stmt_rule(Parser *p); -static void *invalid_assert_stmt_rule(Parser *p); -static void *invalid_block_rule(Parser *p); -static void *invalid_comprehension_rule(Parser *p); -static void *invalid_parameters_rule(Parser *p); -static void *invalid_default_rule(Parser *p); -static void *invalid_star_etc_rule(Parser *p); -static void *invalid_kwds_rule(Parser *p); -static void *invalid_parameters_helper_rule(Parser *p); -static void *invalid_lambda_parameters_rule(Parser *p); -static void *invalid_lambda_parameters_helper_rule(Parser *p); -static void *invalid_lambda_star_etc_rule(Parser *p); -static void *invalid_lambda_kwds_rule(Parser *p); -static void *invalid_double_type_comments_rule(Parser *p); -static void *invalid_with_item_rule(Parser *p); -static void *invalid_for_if_clause_rule(Parser *p); -static void *invalid_for_target_rule(Parser *p); -static void *invalid_group_rule(Parser *p); -static void *invalid_import_rule(Parser *p); -static void *invalid_dotted_as_name_rule(Parser *p); -static void *invalid_import_from_as_name_rule(Parser *p); -static void *invalid_import_from_rule(Parser *p); -static void *invalid_import_from_targets_rule(Parser *p); -static void *invalid_with_stmt_rule(Parser *p); -static void *invalid_with_stmt_indent_rule(Parser *p); -static void *invalid_try_stmt_rule(Parser *p); -static void *invalid_except_stmt_rule(Parser *p); -static void *invalid_except_star_stmt_rule(Parser *p); -static void *invalid_finally_stmt_rule(Parser *p); -static void *invalid_except_stmt_indent_rule(Parser *p); -static void *invalid_except_star_stmt_indent_rule(Parser *p); -static void *invalid_match_stmt_rule(Parser *p); -static void *invalid_case_block_rule(Parser *p); -static void *invalid_as_pattern_rule(Parser *p); -static void *invalid_class_pattern_rule(Parser *p); -static void *invalid_mapping_pattern_rule(Parser *p); -static asdl_pattern_seq* invalid_class_argument_pattern_rule(Parser *p); -static void *invalid_if_stmt_rule(Parser *p); -static void *invalid_elif_stmt_rule(Parser *p); -static void *invalid_else_stmt_rule(Parser *p); -static void *invalid_while_stmt_rule(Parser *p); -static void *invalid_for_stmt_rule(Parser *p); -static void *invalid_def_raw_rule(Parser *p); -static void *invalid_class_def_raw_rule(Parser *p); -static void *invalid_double_starred_kvpairs_rule(Parser *p); -static void *invalid_kvpair_unpacking_rule(Parser *p); -static void *invalid_kvpair_rule(Parser *p); -static void *invalid_starred_expression_unpacking_rule(Parser *p); -static void *invalid_starred_expression_unpacking_sequence_rule(Parser *p); -static void *invalid_starred_expression_rule(Parser *p); -static void *invalid_fstring_replacement_field_rule(Parser *p); -static void *invalid_fstring_conversion_character_rule(Parser *p); -static void *invalid_tstring_replacement_field_rule(Parser *p); -static void *invalid_tstring_conversion_character_rule(Parser *p); -static void *invalid_string_tstring_concat_rule(Parser *p); -static void *invalid_arithmetic_rule(Parser *p); -static void *invalid_factor_rule(Parser *p); -static void *invalid_type_params_rule(Parser *p); -static void *invalid_bitwise_and_rule(Parser *p); -static void *invalid_bitwise_or_rule(Parser *p); static asdl_seq *_loop0_1_rule(Parser *p); static asdl_seq *_loop1_2_rule(Parser *p); static asdl_seq *_loop0_3_rule(Parser *p); @@ -883,31 +844,31 @@ static asdl_seq *_loop1_55_rule(Parser *p); static asdl_seq *_loop1_56_rule(Parser *p); static asdl_seq *_loop0_57_rule(Parser *p); static asdl_seq *_gather_58_rule(Parser *p); -static asdl_seq *_loop0_59_rule(Parser *p); -static asdl_seq *_gather_60_rule(Parser *p); +static asdl_seq *_loop1_59_rule(Parser *p); +static asdl_seq *_loop1_60_rule(Parser *p); static asdl_seq *_loop1_61_rule(Parser *p); -static asdl_seq *_loop1_62_rule(Parser *p); -static asdl_seq *_loop1_63_rule(Parser *p); -static void *_tmp_64_rule(Parser *p); -static asdl_seq *_loop0_65_rule(Parser *p); -static asdl_seq *_gather_66_rule(Parser *p); +static void *_tmp_62_rule(Parser *p); +static asdl_seq *_loop0_63_rule(Parser *p); +static asdl_seq *_gather_64_rule(Parser *p); +static void *_tmp_65_rule(Parser *p); +static void *_tmp_66_rule(Parser *p); static void *_tmp_67_rule(Parser *p); static void *_tmp_68_rule(Parser *p); static void *_tmp_69_rule(Parser *p); -static void *_tmp_70_rule(Parser *p); -static void *_tmp_71_rule(Parser *p); -static asdl_seq *_loop0_72_rule(Parser *p); -static asdl_seq *_loop0_73_rule(Parser *p); -static asdl_seq *_loop1_74_rule(Parser *p); +static asdl_seq *_loop0_70_rule(Parser *p); +static asdl_seq *_loop0_71_rule(Parser *p); +static asdl_seq *_loop1_72_rule(Parser *p); +static asdl_seq *_loop1_73_rule(Parser *p); +static asdl_seq *_loop0_74_rule(Parser *p); static asdl_seq *_loop1_75_rule(Parser *p); static asdl_seq *_loop0_76_rule(Parser *p); -static asdl_seq *_loop1_77_rule(Parser *p); +static asdl_seq *_loop0_77_rule(Parser *p); static asdl_seq *_loop0_78_rule(Parser *p); static asdl_seq *_loop0_79_rule(Parser *p); -static asdl_seq *_loop0_80_rule(Parser *p); -static asdl_seq *_loop0_81_rule(Parser *p); -static asdl_seq *_loop1_82_rule(Parser *p); -static asdl_seq *_loop1_83_rule(Parser *p); +static asdl_seq *_loop1_80_rule(Parser *p); +static asdl_seq *_loop1_81_rule(Parser *p); +static asdl_seq *_loop0_82_rule(Parser *p); +static asdl_seq *_gather_83_rule(Parser *p); static void *_tmp_84_rule(Parser *p); static asdl_seq *_loop0_85_rule(Parser *p); static asdl_seq *_gather_86_rule(Parser *p); @@ -919,99 +880,36 @@ static asdl_seq *_gather_91_rule(Parser *p); static void *_tmp_92_rule(Parser *p); static asdl_seq *_loop0_93_rule(Parser *p); static asdl_seq *_gather_94_rule(Parser *p); -static asdl_seq *_loop0_95_rule(Parser *p); -static asdl_seq *_gather_96_rule(Parser *p); -static asdl_seq *_loop0_97_rule(Parser *p); +static void *_tmp_95_rule(Parser *p); +static asdl_seq *_loop0_96_rule(Parser *p); +static asdl_seq *_gather_97_rule(Parser *p); static asdl_seq *_loop0_98_rule(Parser *p); -static asdl_seq *_gather_99_rule(Parser *p); -static asdl_seq *_loop1_100_rule(Parser *p); -static void *_tmp_101_rule(Parser *p); -static asdl_seq *_loop0_102_rule(Parser *p); -static asdl_seq *_gather_103_rule(Parser *p); -static asdl_seq *_loop0_104_rule(Parser *p); -static asdl_seq *_gather_105_rule(Parser *p); -static void *_tmp_106_rule(Parser *p); -static void *_tmp_107_rule(Parser *p); -static asdl_seq *_loop0_108_rule(Parser *p); -static asdl_seq *_gather_109_rule(Parser *p); -static void *_tmp_110_rule(Parser *p); -static void *_tmp_111_rule(Parser *p); -static void *_tmp_112_rule(Parser *p); -static void *_tmp_113_rule(Parser *p); -static void *_tmp_114_rule(Parser *p); -static asdl_seq *_loop1_115_rule(Parser *p); -static void *_tmp_116_rule(Parser *p); -static void *_tmp_117_rule(Parser *p); -static void *_tmp_118_rule(Parser *p); -static void *_tmp_119_rule(Parser *p); -static void *_tmp_120_rule(Parser *p); -static asdl_seq *_loop0_121_rule(Parser *p); -static asdl_seq *_loop0_122_rule(Parser *p); -static void *_tmp_123_rule(Parser *p); -static void *_tmp_124_rule(Parser *p); -static void *_tmp_125_rule(Parser *p); -static void *_tmp_126_rule(Parser *p); -static void *_tmp_127_rule(Parser *p); -static void *_tmp_128_rule(Parser *p); -static void *_tmp_129_rule(Parser *p); -static void *_tmp_130_rule(Parser *p); -static asdl_seq *_loop0_131_rule(Parser *p); -static asdl_seq *_gather_132_rule(Parser *p); -static void *_tmp_133_rule(Parser *p); -static void *_tmp_134_rule(Parser *p); -static void *_tmp_135_rule(Parser *p); -static void *_tmp_136_rule(Parser *p); -static asdl_seq *_loop0_137_rule(Parser *p); -static asdl_seq *_gather_138_rule(Parser *p); -static void *_tmp_139_rule(Parser *p); -static asdl_seq *_loop0_140_rule(Parser *p); -static asdl_seq *_gather_141_rule(Parser *p); -static asdl_seq *_loop0_142_rule(Parser *p); -static asdl_seq *_gather_143_rule(Parser *p); -static void *_tmp_144_rule(Parser *p); -static asdl_seq *_loop0_145_rule(Parser *p); -static void *_tmp_146_rule(Parser *p); -static void *_tmp_147_rule(Parser *p); -static void *_tmp_148_rule(Parser *p); -static void *_tmp_149_rule(Parser *p); -static void *_tmp_150_rule(Parser *p); -static void *_tmp_151_rule(Parser *p); -static void *_tmp_152_rule(Parser *p); -static void *_tmp_153_rule(Parser *p); -static void *_tmp_154_rule(Parser *p); -static void *_tmp_155_rule(Parser *p); -static void *_tmp_156_rule(Parser *p); -static void *_tmp_157_rule(Parser *p); -static void *_tmp_158_rule(Parser *p); -static void *_tmp_159_rule(Parser *p); -static void *_tmp_160_rule(Parser *p); -static void *_tmp_161_rule(Parser *p); -static void *_tmp_162_rule(Parser *p); -static void *_tmp_163_rule(Parser *p); -static void *_tmp_164_rule(Parser *p); -static void *_tmp_165_rule(Parser *p); -static void *_tmp_166_rule(Parser *p); -static void *_tmp_167_rule(Parser *p); -static void *_tmp_168_rule(Parser *p); -static void *_tmp_169_rule(Parser *p); -static void *_tmp_170_rule(Parser *p); -static void *_tmp_171_rule(Parser *p); -static void *_tmp_172_rule(Parser *p); -static void *_tmp_173_rule(Parser *p); -static asdl_seq *_loop0_174_rule(Parser *p); -static void *_tmp_175_rule(Parser *p); -static void *_tmp_176_rule(Parser *p); -static void *_tmp_177_rule(Parser *p); +static void *_tmp_99_rule(Parser *p); +static void *_tmp_100_rule(Parser *p); +static asdl_seq *_loop0_101_rule(Parser *p); +static asdl_seq *_gather_102_rule(Parser *p); +static asdl_seq *_loop0_103_rule(Parser *p); +static asdl_seq *_gather_104_rule(Parser *p); +static void *_tmp_105_rule(Parser *p); static void *_tmp_178_rule(Parser *p); static void *_tmp_179_rule(Parser *p); static void *_tmp_180_rule(Parser *p); +static void *_tmp_181_rule(Parser *p); +static void *_tmp_182_rule(Parser *p); +static void *_tmp_183_rule(Parser *p); +static void *_tmp_184_rule(Parser *p); +static void *_tmp_185_rule(Parser *p); +static void *_tmp_186_rule(Parser *p); +static void *_tmp_187_rule(Parser *p); +static void *_tmp_188_rule(Parser *p); +static void *_tmp_200_rule(Parser *p); // file: statements? $ static mod_ty file_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -1057,7 +955,7 @@ file_rule(Parser *p) static mod_ty interactive_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -1100,7 +998,7 @@ interactive_rule(Parser *p) static mod_ty eval_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -1149,7 +1047,7 @@ eval_rule(Parser *p) static mod_ty func_type_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -1210,7 +1108,7 @@ func_type_rule(Parser *p) static asdl_stmt_seq* statements_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -1253,7 +1151,7 @@ statements_rule(Parser *p) static asdl_stmt_seq* statement_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -1320,7 +1218,7 @@ statement_rule(Parser *p) static asdl_stmt_seq* single_compound_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -1363,7 +1261,7 @@ single_compound_stmt_rule(Parser *p) static asdl_stmt_seq* statement_newline_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -1494,7 +1392,7 @@ statement_newline_rule(Parser *p) static asdl_stmt_seq* simple_stmts_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -1584,10 +1482,10 @@ simple_stmts_rule(Parser *p) // | &'continue' continue_stmt // | &'global' global_stmt // | &'nonlocal' nonlocal_stmt -static stmt_ty +Py_LOCAL_SYMBOL stmt_ty simple_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -1711,7 +1609,7 @@ simple_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt")); stmt_ty return_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 522) // token='return' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 502) // token='return' && (return_stmt_var = return_stmt_rule(p)) // return_stmt ) @@ -1732,7 +1630,7 @@ simple_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt")); stmt_ty raise_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 632) // token='raise' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503) // token='raise' && (raise_stmt_var = raise_stmt_rule(p)) // raise_stmt ) @@ -1753,7 +1651,7 @@ simple_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'pass' pass_stmt")); stmt_ty pass_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 527) // token='pass' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='pass' && (pass_stmt_var = pass_stmt_rule(p)) // pass_stmt ) @@ -1774,7 +1672,7 @@ simple_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt")); stmt_ty del_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 634) // token='del' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505) // token='del' && (del_stmt_var = del_stmt_rule(p)) // del_stmt ) @@ -1795,7 +1693,7 @@ simple_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt")); stmt_ty yield_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 588) // token='yield' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 506) // token='yield' && (yield_stmt_var = yield_stmt_rule(p)) // yield_stmt ) @@ -1816,7 +1714,7 @@ simple_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt")); stmt_ty assert_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 638) // token='assert' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 507) // token='assert' && (assert_stmt_var = assert_stmt_rule(p)) // assert_stmt ) @@ -1837,7 +1735,7 @@ simple_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'break' break_stmt")); stmt_ty break_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 528) // token='break' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='break' && (break_stmt_var = break_stmt_rule(p)) // break_stmt ) @@ -1858,7 +1756,7 @@ simple_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'continue' continue_stmt")); stmt_ty continue_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 529) // token='continue' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='continue' && (continue_stmt_var = continue_stmt_rule(p)) // continue_stmt ) @@ -1879,7 +1777,7 @@ simple_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt")); stmt_ty global_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 530) // token='global' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 510) // token='global' && (global_stmt_var = global_stmt_rule(p)) // global_stmt ) @@ -1900,7 +1798,7 @@ simple_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt")); stmt_ty nonlocal_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 531) // token='nonlocal' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 511) // token='nonlocal' && (nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt ) @@ -1932,7 +1830,7 @@ simple_stmt_rule(Parser *p) static stmt_ty compound_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -1970,7 +1868,7 @@ compound_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'if' if_stmt")); stmt_ty if_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 700) // token='if' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 514) // token='if' && (if_stmt_var = if_stmt_rule(p)) // if_stmt ) @@ -2054,7 +1952,7 @@ compound_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'try' try_stmt")); stmt_ty try_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 674) // token='try' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 518) // token='try' && (try_stmt_var = try_stmt_rule(p)) // try_stmt ) @@ -2075,7 +1973,7 @@ compound_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'while' while_stmt")); stmt_ty while_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 707) // token='while' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 519) // token='while' && (while_stmt_var = while_stmt_rule(p)) // while_stmt ) @@ -2115,14 +2013,14 @@ compound_stmt_rule(Parser *p) // assignment: // | NAME ':' expression ['=' annotated_rhs] -// | ('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs] +// | ('(' single_target ')' | attribute_or_subscript_target) ':' expression ['=' annotated_rhs] // | ((star_targets '='))+ annotated_rhs !'=' TYPE_COMMENT? // | single_target augassign ~ annotated_rhs // | invalid_assignment static stmt_ty assignment_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -2182,18 +2080,18 @@ assignment_rule(Parser *p) D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ':' expression ['=' annotated_rhs]")); } - { // ('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs] + { // ('(' single_target ')' | attribute_or_subscript_target) ':' expression ['=' annotated_rhs] if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]")); + D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('(' single_target ')' | attribute_or_subscript_target) ':' expression ['=' annotated_rhs]")); Token * _literal; void *a; expr_ty b; void *c; if ( - (a = _tmp_11_rule(p)) // '(' single_target ')' | single_subscript_attribute_target + (a = _tmp_11_rule(p)) // '(' single_target ')' | attribute_or_subscript_target && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -2202,7 +2100,7 @@ assignment_rule(Parser *p) (c = _tmp_10_rule(p), !p->error_indicator) // ['=' annotated_rhs] ) { - D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]")); + D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('(' single_target ')' | attribute_or_subscript_target) ':' expression ['=' annotated_rhs]")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -2222,7 +2120,7 @@ assignment_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('(' single_target ')' | attribute_or_subscript_target) ':' expression ['=' annotated_rhs]")); } { // ((star_targets '='))+ annotated_rhs !'=' TYPE_COMMENT? if (p->error_indicator) { @@ -2337,10 +2235,10 @@ assignment_rule(Parser *p) } // annotated_rhs: yield_expr | star_expressions -static expr_ty +Py_LOCAL_SYMBOL expr_ty annotated_rhs_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -2407,10 +2305,10 @@ annotated_rhs_rule(Parser *p) // | '>>=' // | '**=' // | '//=' -static AugOperator* +Py_LOCAL_SYMBOL AugOperator* augassign_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -2741,7 +2639,7 @@ augassign_rule(Parser *p) static stmt_ty return_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -2768,7 +2666,7 @@ return_stmt_rule(Parser *p) Token * _keyword; void *a; if ( - (_keyword = _PyPegen_expect_token(p, 522)) // token='return' + (_keyword = _PyPegen_expect_token(p, 502)) // token='return' && (a = star_expressions_rule(p), !p->error_indicator) // star_expressions? ) @@ -2809,7 +2707,7 @@ return_stmt_rule(Parser *p) static stmt_ty raise_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -2838,11 +2736,11 @@ raise_stmt_rule(Parser *p) expr_ty a; expr_ty b; if ( - (_keyword = _PyPegen_expect_token(p, 632)) // token='raise' + (_keyword = _PyPegen_expect_token(p, 503)) // token='raise' && (a = expression_rule(p)) // expression && - (_keyword_1 = _PyPegen_expect_token(p, 650)) // token='from' + (_keyword_1 = _PyPegen_expect_token(p, 501)) // token='from' && (b = expression_rule(p)) // expression ) @@ -2897,7 +2795,7 @@ raise_stmt_rule(Parser *p) Token * _keyword; expr_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 632)) // token='raise' + (_keyword = _PyPegen_expect_token(p, 503)) // token='raise' && (a = expression_rule(p)) // expression ) @@ -2932,7 +2830,7 @@ raise_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 632)) // token='raise' + (_keyword = _PyPegen_expect_token(p, 503)) // token='raise' ) { D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise'")); @@ -2964,10 +2862,10 @@ raise_stmt_rule(Parser *p) } // pass_stmt: 'pass' -static stmt_ty +Py_LOCAL_SYMBOL stmt_ty pass_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -2993,7 +2891,7 @@ pass_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> pass_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'pass'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 527)) // token='pass' + (_keyword = _PyPegen_expect_token(p, 504)) // token='pass' ) { D(fprintf(stderr, "%*c+ pass_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'pass'")); @@ -3025,10 +2923,10 @@ pass_stmt_rule(Parser *p) } // break_stmt: 'break' -static stmt_ty +Py_LOCAL_SYMBOL stmt_ty break_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -3054,7 +2952,7 @@ break_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> break_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'break'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 528)) // token='break' + (_keyword = _PyPegen_expect_token(p, 508)) // token='break' ) { D(fprintf(stderr, "%*c+ break_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'break'")); @@ -3086,10 +2984,10 @@ break_stmt_rule(Parser *p) } // continue_stmt: 'continue' -static stmt_ty +Py_LOCAL_SYMBOL stmt_ty continue_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -3115,7 +3013,7 @@ continue_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> continue_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'continue'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 529)) // token='continue' + (_keyword = _PyPegen_expect_token(p, 509)) // token='continue' ) { D(fprintf(stderr, "%*c+ continue_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'continue'")); @@ -3150,7 +3048,7 @@ continue_stmt_rule(Parser *p) static stmt_ty global_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -3177,7 +3075,7 @@ global_stmt_rule(Parser *p) Token * _keyword; asdl_expr_seq* a; if ( - (_keyword = _PyPegen_expect_token(p, 530)) // token='global' + (_keyword = _PyPegen_expect_token(p, 510)) // token='global' && (a = (asdl_expr_seq*)_gather_14_rule(p)) // ','.NAME+ ) @@ -3214,7 +3112,7 @@ global_stmt_rule(Parser *p) static stmt_ty nonlocal_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -3241,7 +3139,7 @@ nonlocal_stmt_rule(Parser *p) Token * _keyword; asdl_expr_seq* a; if ( - (_keyword = _PyPegen_expect_token(p, 531)) // token='nonlocal' + (_keyword = _PyPegen_expect_token(p, 511)) // token='nonlocal' && (a = (asdl_expr_seq*)_gather_14_rule(p)) // ','.NAME+ ) @@ -3278,7 +3176,7 @@ nonlocal_stmt_rule(Parser *p) static stmt_ty del_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -3305,7 +3203,7 @@ del_stmt_rule(Parser *p) Token * _keyword; asdl_expr_seq* a; if ( - (_keyword = _PyPegen_expect_token(p, 634)) // token='del' + (_keyword = _PyPegen_expect_token(p, 505)) // token='del' && (a = del_targets_rule(p)) // del_targets && @@ -3363,7 +3261,7 @@ del_stmt_rule(Parser *p) static stmt_ty yield_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -3424,7 +3322,7 @@ yield_stmt_rule(Parser *p) static stmt_ty assert_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -3471,7 +3369,7 @@ assert_stmt_rule(Parser *p) expr_ty a; void *b; if ( - (_keyword = _PyPegen_expect_token(p, 638)) // token='assert' + (_keyword = _PyPegen_expect_token(p, 507)) // token='assert' && (a = expression_rule(p)) // expression && @@ -3510,7 +3408,7 @@ assert_stmt_rule(Parser *p) static stmt_ty import_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -3587,11 +3485,11 @@ import_stmt_rule(Parser *p) return _res; } -// import_name: "lazy"? 'import' dotted_as_names +// import_name: "lazy" 'import' dotted_as_names | 'import' dotted_as_names static stmt_ty import_name_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -3609,24 +3507,60 @@ import_name_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // "lazy"? 'import' dotted_as_names + { // "lazy" 'import' dotted_as_names if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> import_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"lazy\"? 'import' dotted_as_names")); - Token * _keyword; + D(fprintf(stderr, "%*c> import_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"lazy\" 'import' dotted_as_names")); + expr_ty _keyword; + Token * _keyword_1; asdl_alias_seq* a; - void *lazy; if ( - (lazy = _PyPegen_expect_soft_keyword(p, "lazy"), !p->error_indicator) // "lazy"? + (_keyword = _PyPegen_expect_soft_keyword(p, "lazy")) // soft_keyword='"lazy"' + && + (_keyword_1 = _PyPegen_expect_token(p, 500)) // token='import' && - (_keyword = _PyPegen_expect_token(p, 651)) // token='import' + (a = dotted_as_names_rule(p)) // dotted_as_names + ) + { + D(fprintf(stderr, "%*c+ import_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"lazy\" 'import' dotted_as_names")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + p->level--; + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = CHECK_VERSION ( stmt_ty , 15 , "Lazy imports are" , _PyAST_Import ( a , 1 , EXTRA ) ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s import_name[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"lazy\" 'import' dotted_as_names")); + } + { // 'import' dotted_as_names + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> import_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import' dotted_as_names")); + Token * _keyword; + asdl_alias_seq* a; + if ( + (_keyword = _PyPegen_expect_token(p, 500)) // token='import' && (a = dotted_as_names_rule(p)) // dotted_as_names ) { - D(fprintf(stderr, "%*c+ import_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"lazy\"? 'import' dotted_as_names")); + D(fprintf(stderr, "%*c+ import_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import' dotted_as_names")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -3636,7 +3570,7 @@ import_name_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_Import ( a , lazy ? 1 : 0 , EXTRA ); + _res = _PyAST_Import ( a , 0 , EXTRA ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -3646,7 +3580,7 @@ import_name_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s import_name[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"lazy\"? 'import' dotted_as_names")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import' dotted_as_names")); } _res = NULL; done: @@ -3656,12 +3590,14 @@ import_name_rule(Parser *p) // import_from: // | invalid_import_from -// | "lazy"? 'from' (('.' | '...'))* dotted_name 'import' import_from_targets -// | "lazy"? 'from' (('.' | '...'))+ 'import' import_from_targets +// | "lazy" 'from' (('.' | '...'))* dotted_name 'import' import_from_targets +// | "lazy" 'from' (('.' | '...'))+ 'import' import_from_targets +// | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets +// | 'from' (('.' | '...'))+ 'import' import_from_targets static stmt_ty import_from_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -3698,33 +3634,33 @@ import_from_rule(Parser *p) D(fprintf(stderr, "%*c%s import_from[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_import_from")); } - { // "lazy"? 'from' (('.' | '...'))* dotted_name 'import' import_from_targets + { // "lazy" 'from' (('.' | '...'))* dotted_name 'import' import_from_targets if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"lazy\"? 'from' (('.' | '...'))* dotted_name 'import' import_from_targets")); + D(fprintf(stderr, "%*c> import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"lazy\" 'from' (('.' | '...'))* dotted_name 'import' import_from_targets")); Token * _keyword; Token * _keyword_1; asdl_seq * a; expr_ty b; asdl_alias_seq* c; - void *lazy; + expr_ty lazy; if ( - (lazy = _PyPegen_expect_soft_keyword(p, "lazy"), !p->error_indicator) // "lazy"? + (lazy = _PyPegen_expect_soft_keyword(p, "lazy")) // soft_keyword='"lazy"' && - (_keyword = _PyPegen_expect_token(p, 650)) // token='from' + (_keyword = _PyPegen_expect_token(p, 501)) // token='from' && (a = _loop0_17_rule(p)) // (('.' | '...'))* && (b = dotted_name_rule(p)) // dotted_name && - (_keyword_1 = _PyPegen_expect_token(p, 651)) // token='import' + (_keyword_1 = _PyPegen_expect_token(p, 500)) // token='import' && (c = import_from_targets_rule(p)) // import_from_targets ) { - D(fprintf(stderr, "%*c+ import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"lazy\"? 'from' (('.' | '...'))* dotted_name 'import' import_from_targets")); + D(fprintf(stderr, "%*c+ import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"lazy\" 'from' (('.' | '...'))* dotted_name 'import' import_from_targets")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -3734,7 +3670,7 @@ import_from_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyPegen_checked_from_import ( p , a , b , c , lazy , EXTRA ); + _res = CHECK_VERSION ( stmt_ty , 15 , "Lazy imports are" , _PyPegen_checked_from_import ( p , a , b , c , lazy , EXTRA ) ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -3744,32 +3680,119 @@ import_from_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s import_from[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"lazy\"? 'from' (('.' | '...'))* dotted_name 'import' import_from_targets")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"lazy\" 'from' (('.' | '...'))* dotted_name 'import' import_from_targets")); } - { // "lazy"? 'from' (('.' | '...'))+ 'import' import_from_targets + { // "lazy" 'from' (('.' | '...'))+ 'import' import_from_targets if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"lazy\"? 'from' (('.' | '...'))+ 'import' import_from_targets")); - Token * _keyword; + D(fprintf(stderr, "%*c> import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"lazy\" 'from' (('.' | '...'))+ 'import' import_from_targets")); + expr_ty _keyword; Token * _keyword_1; + Token * _keyword_2; asdl_seq * a; asdl_alias_seq* b; - void *lazy; if ( - (lazy = _PyPegen_expect_soft_keyword(p, "lazy"), !p->error_indicator) // "lazy"? + (_keyword = _PyPegen_expect_soft_keyword(p, "lazy")) // soft_keyword='"lazy"' + && + (_keyword_1 = _PyPegen_expect_token(p, 501)) // token='from' + && + (a = _loop1_18_rule(p)) // (('.' | '...'))+ + && + (_keyword_2 = _PyPegen_expect_token(p, 500)) // token='import' + && + (b = import_from_targets_rule(p)) // import_from_targets + ) + { + D(fprintf(stderr, "%*c+ import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"lazy\" 'from' (('.' | '...'))+ 'import' import_from_targets")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + p->level--; + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = CHECK_VERSION ( stmt_ty , 15 , "Lazy imports are" , _PyAST_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , 1 , EXTRA ) ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s import_from[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"lazy\" 'from' (('.' | '...'))+ 'import' import_from_targets")); + } + { // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))* dotted_name 'import' import_from_targets")); + Token * _keyword; + Token * _keyword_1; + asdl_seq * a; + expr_ty b; + asdl_alias_seq* c; + if ( + (_keyword = _PyPegen_expect_token(p, 501)) // token='from' && - (_keyword = _PyPegen_expect_token(p, 650)) // token='from' + (a = _loop0_17_rule(p)) // (('.' | '...'))* + && + (b = dotted_name_rule(p)) // dotted_name + && + (_keyword_1 = _PyPegen_expect_token(p, 500)) // token='import' + && + (c = import_from_targets_rule(p)) // import_from_targets + ) + { + D(fprintf(stderr, "%*c+ import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))* dotted_name 'import' import_from_targets")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + p->level--; + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _PyPegen_checked_from_import ( p , a , b , c , NULL , EXTRA ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s import_from[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' (('.' | '...'))* dotted_name 'import' import_from_targets")); + } + { // 'from' (('.' | '...'))+ 'import' import_from_targets + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))+ 'import' import_from_targets")); + Token * _keyword; + Token * _keyword_1; + asdl_seq * a; + asdl_alias_seq* b; + if ( + (_keyword = _PyPegen_expect_token(p, 501)) // token='from' && (a = _loop1_18_rule(p)) // (('.' | '...'))+ && - (_keyword_1 = _PyPegen_expect_token(p, 651)) // token='import' + (_keyword_1 = _PyPegen_expect_token(p, 500)) // token='import' && (b = import_from_targets_rule(p)) // import_from_targets ) { - D(fprintf(stderr, "%*c+ import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"lazy\"? 'from' (('.' | '...'))+ 'import' import_from_targets")); + D(fprintf(stderr, "%*c+ import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))+ 'import' import_from_targets")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -3779,7 +3802,7 @@ import_from_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , lazy ? 1 : 0 , EXTRA ); + _res = _PyAST_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , 0 , EXTRA ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -3789,7 +3812,7 @@ import_from_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s import_from[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"lazy\"? 'from' (('.' | '...'))+ 'import' import_from_targets")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' (('.' | '...'))+ 'import' import_from_targets")); } _res = NULL; done: @@ -3802,10 +3825,10 @@ import_from_rule(Parser *p) // | import_from_as_names !',' // | '*' // | invalid_import_from_targets -static asdl_alias_seq* +Py_LOCAL_SYMBOL asdl_alias_seq* import_from_targets_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -3937,10 +3960,10 @@ import_from_targets_rule(Parser *p) } // import_from_as_names: ','.import_from_as_name+ -static asdl_alias_seq* +Py_LOCAL_SYMBOL asdl_alias_seq* import_from_as_names_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -3983,7 +4006,7 @@ import_from_as_names_rule(Parser *p) static alias_ty import_from_as_name_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -4066,7 +4089,7 @@ import_from_as_name_rule(Parser *p) static asdl_alias_seq* dotted_as_names_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -4109,7 +4132,7 @@ dotted_as_names_rule(Parser *p) static alias_ty dotted_as_name_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -4191,10 +4214,10 @@ dotted_as_name_rule(Parser *p) // Left-recursive // dotted_name: dotted_name '.' NAME | NAME static expr_ty dotted_name_raw(Parser *); -static expr_ty +Py_LOCAL_SYMBOL expr_ty dotted_name_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } expr_ty _res = NULL; @@ -4204,12 +4227,14 @@ dotted_name_rule(Parser *p) } int _mark = p->mark; int _resmark = p->mark; + Memo *_memo = _PyPegen_insert_memo_direct(p, _mark, dotted_name_type); + if (_memo == NULL) { + p->level--; + return NULL; + } while (1) { - int tmpvar_0 = _PyPegen_update_memo(p, _mark, dotted_name_type, _res); - if (tmpvar_0) { - p->level--; - return _res; - } + _memo->node = _res; + _memo->mark = p->mark; p->mark = _mark; void *_raw = dotted_name_raw(p); if (p->error_indicator) { @@ -4228,7 +4253,7 @@ dotted_name_rule(Parser *p) static expr_ty dotted_name_raw(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -4293,10 +4318,10 @@ dotted_name_raw(Parser *p) } // block: NEWLINE INDENT statements DEDENT | simple_stmts | invalid_block -static asdl_stmt_seq* +Py_LOCAL_SYMBOL asdl_stmt_seq* block_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -4391,7 +4416,7 @@ block_rule(Parser *p) static asdl_expr_seq* decorators_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -4434,7 +4459,7 @@ decorators_rule(Parser *p) static stmt_ty class_def_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -4501,7 +4526,7 @@ class_def_rule(Parser *p) static stmt_ty class_def_raw_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -4551,7 +4576,7 @@ class_def_raw_rule(Parser *p) asdl_stmt_seq* c; void *t; if ( - (_keyword = _PyPegen_expect_token(p, 719)) // token='class' + (_keyword = _PyPegen_expect_token(p, 515)) // token='class' && (a = _PyPegen_name_token(p)) // NAME && @@ -4596,7 +4621,7 @@ class_def_raw_rule(Parser *p) static stmt_ty function_def_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -4664,7 +4689,7 @@ function_def_rule(Parser *p) static stmt_ty function_def_raw_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -4718,7 +4743,7 @@ function_def_raw_rule(Parser *p) void *t; void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 717)) // token='def' + (_keyword = _PyPegen_expect_token(p, 512)) // token='def' && (n = _PyPegen_name_token(p)) // NAME && @@ -4779,9 +4804,9 @@ function_def_raw_rule(Parser *p) void *t; void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 716)) // token='async' + (_keyword = _PyPegen_expect_token(p, 513)) // token='async' && - (_keyword_1 = _PyPegen_expect_token(p, 717)) // token='def' + (_keyword_1 = _PyPegen_expect_token(p, 512)) // token='def' && (n = _PyPegen_name_token(p)) // NAME && @@ -4831,10 +4856,10 @@ function_def_raw_rule(Parser *p) } // params: invalid_parameters | parameters -static arguments_ty +Py_LOCAL_SYMBOL arguments_ty params_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -4896,7 +4921,7 @@ params_rule(Parser *p) static arguments_ty parameters_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -5056,10 +5081,10 @@ parameters_rule(Parser *p) } // slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')' -static asdl_arg_seq* +Py_LOCAL_SYMBOL asdl_arg_seq* slash_no_default_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -5136,10 +5161,10 @@ slash_no_default_rule(Parser *p) // slash_with_default: // | param_no_default* param_with_default+ '/' ',' // | param_no_default* param_with_default+ '/' &')' -static SlashWithDefault* +Py_LOCAL_SYMBOL SlashWithDefault* slash_with_default_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -5228,7 +5253,7 @@ slash_with_default_rule(Parser *p) static StarEtc* star_etc_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -5389,7 +5414,7 @@ star_etc_rule(Parser *p) static arg_ty kwds_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -5451,10 +5476,10 @@ kwds_rule(Parser *p) } // param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')' -static arg_ty +Py_LOCAL_SYMBOL arg_ty param_no_default_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -5534,7 +5559,7 @@ param_no_default_rule(Parser *p) static arg_ty param_no_default_star_annotation_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -5609,10 +5634,10 @@ param_no_default_star_annotation_rule(Parser *p) } // param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')' -static NameDefaultPair* +Py_LOCAL_SYMBOL NameDefaultPair* param_with_default_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -5695,10 +5720,10 @@ param_with_default_rule(Parser *p) // param_maybe_default: // | param default? ',' TYPE_COMMENT? // | param default? TYPE_COMMENT? &')' -static NameDefaultPair* +Py_LOCAL_SYMBOL NameDefaultPair* param_maybe_default_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -5779,10 +5804,10 @@ param_maybe_default_rule(Parser *p) } // param: NAME annotation? -static arg_ty +Py_LOCAL_SYMBOL arg_ty param_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -5846,7 +5871,7 @@ param_rule(Parser *p) static arg_ty param_star_annotation_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -5910,7 +5935,7 @@ param_star_annotation_rule(Parser *p) static expr_ty annotation_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -5956,7 +5981,7 @@ annotation_rule(Parser *p) static expr_ty star_annotation_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -6002,7 +6027,7 @@ star_annotation_rule(Parser *p) static expr_ty default_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -6070,7 +6095,7 @@ default_rule(Parser *p) static stmt_ty if_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -6119,7 +6144,7 @@ if_stmt_rule(Parser *p) asdl_stmt_seq* b; stmt_ty c; if ( - (_keyword = _PyPegen_expect_token(p, 700)) // token='if' + (_keyword = _PyPegen_expect_token(p, 514)) // token='if' && (a = named_expression_rule(p)) // named_expression && @@ -6164,7 +6189,7 @@ if_stmt_rule(Parser *p) asdl_stmt_seq* b; void *c; if ( - (_keyword = _PyPegen_expect_token(p, 700)) // token='if' + (_keyword = _PyPegen_expect_token(p, 514)) // token='if' && (a = named_expression_rule(p)) // named_expression && @@ -6210,7 +6235,7 @@ if_stmt_rule(Parser *p) static stmt_ty elif_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -6259,7 +6284,7 @@ elif_stmt_rule(Parser *p) asdl_stmt_seq* b; stmt_ty c; if ( - (_keyword = _PyPegen_expect_token(p, 705)) // token='elif' + (_keyword = _PyPegen_expect_token(p, 521)) // token='elif' && (a = named_expression_rule(p)) // named_expression && @@ -6304,7 +6329,7 @@ elif_stmt_rule(Parser *p) asdl_stmt_seq* b; void *c; if ( - (_keyword = _PyPegen_expect_token(p, 705)) // token='elif' + (_keyword = _PyPegen_expect_token(p, 521)) // token='elif' && (a = named_expression_rule(p)) // named_expression && @@ -6347,7 +6372,7 @@ elif_stmt_rule(Parser *p) static asdl_stmt_seq* else_block_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -6385,7 +6410,7 @@ else_block_rule(Parser *p) Token * _literal; asdl_stmt_seq* b; if ( - (_keyword = _PyPegen_expect_token(p, 704)) // token='else' + (_keyword = _PyPegen_expect_token(p, 522)) // token='else' && (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' && @@ -6415,7 +6440,7 @@ else_block_rule(Parser *p) static stmt_ty while_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -6464,7 +6489,7 @@ while_stmt_rule(Parser *p) asdl_stmt_seq* b; void *c; if ( - (_keyword = _PyPegen_expect_token(p, 707)) // token='while' + (_keyword = _PyPegen_expect_token(p, 519)) // token='while' && (a = named_expression_rule(p)) // named_expression && @@ -6511,7 +6536,7 @@ while_stmt_rule(Parser *p) static stmt_ty for_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -6564,11 +6589,11 @@ for_stmt_rule(Parser *p) expr_ty t; void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 712)) // token='for' + (_keyword = _PyPegen_expect_token(p, 517)) // token='for' && (t = star_targets_rule(p)) // star_targets && - (_keyword_1 = _PyPegen_expect_token(p, 713)) // token='in' + (_keyword_1 = _PyPegen_expect_token(p, 523)) // token='in' && (_cut_var = 1) && @@ -6626,13 +6651,13 @@ for_stmt_rule(Parser *p) expr_ty t; void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 716)) // token='async' + (_keyword = _PyPegen_expect_token(p, 513)) // token='async' && - (_keyword_1 = _PyPegen_expect_token(p, 712)) // token='for' + (_keyword_1 = _PyPegen_expect_token(p, 517)) // token='for' && (t = star_targets_rule(p)) // star_targets && - (_keyword_2 = _PyPegen_expect_token(p, 713)) // token='in' + (_keyword_2 = _PyPegen_expect_token(p, 523)) // token='in' && (_cut_var = 1) && @@ -6708,7 +6733,7 @@ for_stmt_rule(Parser *p) static stmt_ty with_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -6761,7 +6786,7 @@ with_stmt_rule(Parser *p) asdl_stmt_seq* b; void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 665)) // token='with' + (_keyword = _PyPegen_expect_token(p, 516)) // token='with' && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && @@ -6812,7 +6837,7 @@ with_stmt_rule(Parser *p) asdl_stmt_seq* b; void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 665)) // token='with' + (_keyword = _PyPegen_expect_token(p, 516)) // token='with' && (a = (asdl_withitem_seq*)_gather_34_rule(p)) // ','.with_item+ && @@ -6861,9 +6886,9 @@ with_stmt_rule(Parser *p) asdl_withitem_seq* a; asdl_stmt_seq* b; if ( - (_keyword = _PyPegen_expect_token(p, 716)) // token='async' + (_keyword = _PyPegen_expect_token(p, 513)) // token='async' && - (_keyword_1 = _PyPegen_expect_token(p, 665)) // token='with' + (_keyword_1 = _PyPegen_expect_token(p, 516)) // token='with' && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && @@ -6913,9 +6938,9 @@ with_stmt_rule(Parser *p) asdl_stmt_seq* b; void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 716)) // token='async' + (_keyword = _PyPegen_expect_token(p, 513)) // token='async' && - (_keyword_1 = _PyPegen_expect_token(p, 665)) // token='with' + (_keyword_1 = _PyPegen_expect_token(p, 516)) // token='with' && (a = (asdl_withitem_seq*)_gather_34_rule(p)) // ','.with_item+ && @@ -6980,7 +7005,7 @@ with_stmt_rule(Parser *p) static withitem_ty with_item_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -7001,7 +7026,7 @@ with_item_rule(Parser *p) if ( (e = expression_rule(p)) // expression && - (_keyword = _PyPegen_expect_token(p, 698)) // token='as' + (_keyword = _PyPegen_expect_token(p, 520)) // token='as' && (t = star_target_rule(p)) // star_target && @@ -7078,7 +7103,7 @@ with_item_rule(Parser *p) static stmt_ty try_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -7126,7 +7151,7 @@ try_stmt_rule(Parser *p) asdl_stmt_seq* b; asdl_stmt_seq* f; if ( - (_keyword = _PyPegen_expect_token(p, 674)) // token='try' + (_keyword = _PyPegen_expect_token(p, 518)) // token='try' && (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' && @@ -7170,7 +7195,7 @@ try_stmt_rule(Parser *p) asdl_excepthandler_seq* ex; void *f; if ( - (_keyword = _PyPegen_expect_token(p, 674)) // token='try' + (_keyword = _PyPegen_expect_token(p, 518)) // token='try' && (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' && @@ -7218,7 +7243,7 @@ try_stmt_rule(Parser *p) asdl_excepthandler_seq* ex; void *f; if ( - (_keyword = _PyPegen_expect_token(p, 674)) // token='try' + (_keyword = _PyPegen_expect_token(p, 518)) // token='try' && (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' && @@ -7266,10 +7291,10 @@ try_stmt_rule(Parser *p) // | 'except' expressions ':' block // | 'except' ':' block // | invalid_except_stmt -static excepthandler_ty +Py_LOCAL_SYMBOL excepthandler_ty except_block_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -7317,7 +7342,7 @@ except_block_rule(Parser *p) asdl_stmt_seq* b; expr_ty e; if ( - (_keyword = _PyPegen_expect_token(p, 695)) // token='except' + (_keyword = _PyPegen_expect_token(p, 524)) // token='except' && (e = expression_rule(p)) // expression && @@ -7361,11 +7386,11 @@ except_block_rule(Parser *p) expr_ty e; expr_ty t; if ( - (_keyword = _PyPegen_expect_token(p, 695)) // token='except' + (_keyword = _PyPegen_expect_token(p, 524)) // token='except' && (e = expression_rule(p)) // expression && - (_keyword_1 = _PyPegen_expect_token(p, 698)) // token='as' + (_keyword_1 = _PyPegen_expect_token(p, 520)) // token='as' && (t = _PyPegen_name_token(p)) // NAME && @@ -7407,7 +7432,7 @@ except_block_rule(Parser *p) asdl_stmt_seq* b; expr_ty e; if ( - (_keyword = _PyPegen_expect_token(p, 695)) // token='except' + (_keyword = _PyPegen_expect_token(p, 524)) // token='except' && (e = expressions_rule(p)) // expressions && @@ -7448,7 +7473,7 @@ except_block_rule(Parser *p) Token * _literal; asdl_stmt_seq* b; if ( - (_keyword = _PyPegen_expect_token(p, 695)) // token='except' + (_keyword = _PyPegen_expect_token(p, 524)) // token='except' && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -7508,10 +7533,10 @@ except_block_rule(Parser *p) // | 'except' '*' expression 'as' NAME ':' block // | 'except' '*' expressions ':' block // | invalid_except_star_stmt -static excepthandler_ty +Py_LOCAL_SYMBOL excepthandler_ty except_star_block_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -7560,7 +7585,7 @@ except_star_block_rule(Parser *p) asdl_stmt_seq* b; expr_ty e; if ( - (_keyword = _PyPegen_expect_token(p, 695)) // token='except' + (_keyword = _PyPegen_expect_token(p, 524)) // token='except' && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && @@ -7607,13 +7632,13 @@ except_star_block_rule(Parser *p) expr_ty e; expr_ty t; if ( - (_keyword = _PyPegen_expect_token(p, 695)) // token='except' + (_keyword = _PyPegen_expect_token(p, 524)) // token='except' && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && (e = expression_rule(p)) // expression && - (_keyword_1 = _PyPegen_expect_token(p, 698)) // token='as' + (_keyword_1 = _PyPegen_expect_token(p, 520)) // token='as' && (t = _PyPegen_name_token(p)) // NAME && @@ -7656,7 +7681,7 @@ except_star_block_rule(Parser *p) asdl_stmt_seq* b; expr_ty e; if ( - (_keyword = _PyPegen_expect_token(p, 695)) // token='except' + (_keyword = _PyPegen_expect_token(p, 524)) // token='except' && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && @@ -7718,7 +7743,7 @@ except_star_block_rule(Parser *p) static asdl_stmt_seq* finally_block_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -7756,7 +7781,7 @@ finally_block_rule(Parser *p) Token * _literal; asdl_stmt_seq* a; if ( - (_keyword = _PyPegen_expect_token(p, 691)) // token='finally' + (_keyword = _PyPegen_expect_token(p, 525)) // token='finally' && (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' && @@ -7788,7 +7813,7 @@ finally_block_rule(Parser *p) static stmt_ty match_stmt_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -7883,10 +7908,10 @@ match_stmt_rule(Parser *p) } // subject_expr: star_named_expression ',' star_named_expressions? | named_expression -static expr_ty +Py_LOCAL_SYMBOL expr_ty subject_expr_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -7972,7 +7997,7 @@ subject_expr_rule(Parser *p) static match_case_ty case_block_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -8043,10 +8068,10 @@ case_block_rule(Parser *p) } // guard: 'if' named_expression -static expr_ty +Py_LOCAL_SYMBOL expr_ty guard_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -8064,7 +8089,7 @@ guard_rule(Parser *p) Token * _keyword; expr_ty guard; if ( - (_keyword = _PyPegen_expect_token(p, 700)) // token='if' + (_keyword = _PyPegen_expect_token(p, 514)) // token='if' && (guard = named_expression_rule(p)) // named_expression ) @@ -8089,10 +8114,10 @@ guard_rule(Parser *p) } // patterns: open_sequence_pattern | pattern -static pattern_ty +Py_LOCAL_SYMBOL pattern_ty patterns_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -8172,7 +8197,7 @@ patterns_rule(Parser *p) static pattern_ty pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -8229,7 +8254,7 @@ pattern_rule(Parser *p) static pattern_ty as_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -8259,7 +8284,7 @@ as_pattern_rule(Parser *p) if ( (pattern = or_pattern_rule(p)) // or_pattern && - (_keyword = _PyPegen_expect_token(p, 698)) // token='as' + (_keyword = _PyPegen_expect_token(p, 520)) // token='as' && (target = pattern_capture_target_rule(p)) // pattern_capture_target ) @@ -8312,10 +8337,10 @@ as_pattern_rule(Parser *p) } // or_pattern: '|'.closed_pattern+ -static pattern_ty +Py_LOCAL_SYMBOL pattern_ty or_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -8384,7 +8409,7 @@ or_pattern_rule(Parser *p) static pattern_ty closed_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -8566,7 +8591,7 @@ closed_pattern_rule(Parser *p) static pattern_ty literal_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -8693,7 +8718,7 @@ literal_pattern_rule(Parser *p) D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 628)) // token='None' + (_keyword = _PyPegen_expect_token(p, 526)) // token='None' ) { D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); @@ -8726,7 +8751,7 @@ literal_pattern_rule(Parser *p) D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 627)) // token='True' + (_keyword = _PyPegen_expect_token(p, 527)) // token='True' ) { D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); @@ -8759,7 +8784,7 @@ literal_pattern_rule(Parser *p) D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 629)) // token='False' + (_keyword = _PyPegen_expect_token(p, 528)) // token='False' ) { D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); @@ -8800,7 +8825,7 @@ literal_pattern_rule(Parser *p) static expr_ty literal_expr_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -8887,7 +8912,7 @@ literal_expr_rule(Parser *p) D(fprintf(stderr, "%*c> literal_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 628)) // token='None' + (_keyword = _PyPegen_expect_token(p, 526)) // token='None' ) { D(fprintf(stderr, "%*c+ literal_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); @@ -8920,7 +8945,7 @@ literal_expr_rule(Parser *p) D(fprintf(stderr, "%*c> literal_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 627)) // token='True' + (_keyword = _PyPegen_expect_token(p, 527)) // token='True' ) { D(fprintf(stderr, "%*c+ literal_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); @@ -8953,7 +8978,7 @@ literal_expr_rule(Parser *p) D(fprintf(stderr, "%*c> literal_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 629)) // token='False' + (_keyword = _PyPegen_expect_token(p, 528)) // token='False' ) { D(fprintf(stderr, "%*c+ literal_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); @@ -8990,7 +9015,7 @@ literal_expr_rule(Parser *p) static expr_ty complex_number_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -9096,7 +9121,7 @@ complex_number_rule(Parser *p) static expr_ty signed_number_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -9148,7 +9173,16 @@ signed_number_rule(Parser *p) ) { D(fprintf(stderr, "%*c+ signed_number[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+' NUMBER")); - _res = number; + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + p->level--; + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _PyAST_UnaryOp ( UAdd , number , EXTRA ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -9206,7 +9240,7 @@ signed_number_rule(Parser *p) static expr_ty signed_real_number_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -9258,7 +9292,16 @@ signed_real_number_rule(Parser *p) ) { D(fprintf(stderr, "%*c+ signed_real_number[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+' real_number")); - _res = real; + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + p->level--; + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _PyAST_UnaryOp ( UAdd , real , EXTRA ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -9316,7 +9359,7 @@ signed_real_number_rule(Parser *p) static expr_ty real_number_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -9355,11 +9398,11 @@ real_number_rule(Parser *p) return _res; } -// imaginary_number: NUMBER | '+' NUMBER +// imaginary_number: NUMBER static expr_ty imaginary_number_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -9392,33 +9435,6 @@ imaginary_number_rule(Parser *p) D(fprintf(stderr, "%*c%s imaginary_number[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER")); } - { // '+' NUMBER - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> imaginary_number[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+' NUMBER")); - Token * _literal; - expr_ty imag; - if ( - (_literal = _PyPegen_expect_token(p, 14)) // token='+' - && - (imag = _PyPegen_number_token(p)) // NUMBER - ) - { - D(fprintf(stderr, "%*c+ imaginary_number[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+' NUMBER")); - _res = _PyPegen_ensure_imaginary ( p , imag ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s imaginary_number[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+' NUMBER")); - } _res = NULL; done: p->level--; @@ -9429,7 +9445,7 @@ imaginary_number_rule(Parser *p) static pattern_ty capture_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -9490,7 +9506,7 @@ capture_pattern_rule(Parser *p) static expr_ty pattern_capture_target_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -9537,7 +9553,7 @@ pattern_capture_target_rule(Parser *p) static pattern_ty wildcard_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -9598,7 +9614,7 @@ wildcard_pattern_rule(Parser *p) static pattern_ty value_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -9663,7 +9679,7 @@ static expr_ty attr_raw(Parser *); static expr_ty attr_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } expr_ty _res = NULL; @@ -9673,12 +9689,14 @@ attr_rule(Parser *p) } int _mark = p->mark; int _resmark = p->mark; + Memo *_memo = _PyPegen_insert_memo_direct(p, _mark, attr_type); + if (_memo == NULL) { + p->level--; + return NULL; + } while (1) { - int tmpvar_1 = _PyPegen_update_memo(p, _mark, attr_type, _res); - if (tmpvar_1) { - p->level--; - return _res; - } + _memo->node = _res; + _memo->mark = p->mark; p->mark = _mark; void *_raw = attr_raw(p); if (p->error_indicator) { @@ -9697,7 +9715,7 @@ attr_rule(Parser *p) static expr_ty attr_raw(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -9762,10 +9780,10 @@ attr_raw(Parser *p) // Left-recursive // name_or_attr: attr | NAME -static expr_ty +Py_LOCAL_SYMBOL expr_ty name_or_attr_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -9822,7 +9840,7 @@ name_or_attr_rule(Parser *p) static pattern_ty group_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -9871,7 +9889,7 @@ group_pattern_rule(Parser *p) static pattern_ty sequence_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -9977,7 +9995,7 @@ sequence_pattern_rule(Parser *p) static asdl_seq* open_sequence_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -10026,7 +10044,7 @@ open_sequence_pattern_rule(Parser *p) static asdl_seq* maybe_sequence_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -10073,7 +10091,7 @@ maybe_sequence_pattern_rule(Parser *p) static pattern_ty maybe_star_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -10130,7 +10148,7 @@ maybe_star_pattern_rule(Parser *p) static pattern_ty star_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -10240,7 +10258,7 @@ star_pattern_rule(Parser *p) static pattern_ty mapping_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -10455,10 +10473,10 @@ mapping_pattern_rule(Parser *p) } // items_pattern: ','.key_value_pattern+ -static asdl_seq* +Py_LOCAL_SYMBOL asdl_seq* items_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -10496,7 +10514,7 @@ items_pattern_rule(Parser *p) static KeyPatternPair* key_value_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -10542,10 +10560,10 @@ key_value_pattern_rule(Parser *p) } // double_star_pattern: '**' pattern_capture_target -static expr_ty +Py_LOCAL_SYMBOL expr_ty double_star_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -10596,7 +10614,7 @@ double_star_pattern_rule(Parser *p) static pattern_ty class_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -10823,10 +10841,10 @@ class_pattern_rule(Parser *p) } // positional_patterns: ','.pattern+ -static asdl_pattern_seq* +Py_LOCAL_SYMBOL asdl_pattern_seq* positional_patterns_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -10866,10 +10884,10 @@ positional_patterns_rule(Parser *p) } // keyword_patterns: ','.keyword_pattern+ -static asdl_seq* +Py_LOCAL_SYMBOL asdl_seq* keyword_patterns_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -10907,7 +10925,7 @@ keyword_patterns_rule(Parser *p) static KeyPatternPair* keyword_pattern_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -10956,7 +10974,7 @@ keyword_pattern_rule(Parser *p) static stmt_ty type_alias_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -11026,10 +11044,10 @@ type_alias_rule(Parser *p) } // type_params: invalid_type_params | '[' type_param_seq ']' -static asdl_type_param_seq* +Py_LOCAL_SYMBOL asdl_type_param_seq* type_params_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -11097,7 +11115,7 @@ type_params_rule(Parser *p) static asdl_type_param_seq* type_param_seq_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -11148,7 +11166,7 @@ type_param_seq_rule(Parser *p) static type_param_ty type_param_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -11317,7 +11335,7 @@ type_param_rule(Parser *p) static expr_ty type_param_bound_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -11363,7 +11381,7 @@ type_param_bound_rule(Parser *p) static expr_ty type_param_default_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -11409,7 +11427,7 @@ type_param_default_rule(Parser *p) static expr_ty type_param_starred_default_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -11452,10 +11470,10 @@ type_param_starred_default_rule(Parser *p) } // expressions: expression ((',' expression))+ ','? | expression ',' | expression -static expr_ty +Py_LOCAL_SYMBOL expr_ty expressions_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -11464,6 +11482,8 @@ expressions_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; + expr_ty _prefix_0_result = NULL; + int _prefix_0_end = 0, _prefix_0_valid = 0; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; p->level--; @@ -11484,7 +11504,7 @@ expressions_rule(Parser *p) expr_ty a; asdl_seq * b; if ( - (a = expression_rule(p)) // expression + (a = ((!p->call_invalid_rules && _prefix_0_valid) ? (p->mark = _prefix_0_end, _prefix_0_result) : (_prefix_0_result = expression_rule(p), _prefix_0_end = p->mark, _prefix_0_valid = 1, _prefix_0_result))) // expression && (b = _loop1_55_rule(p)) // ((',' expression))+ && @@ -11522,7 +11542,7 @@ expressions_rule(Parser *p) Token * _literal; expr_ty a; if ( - (a = expression_rule(p)) // expression + (a = ((!p->call_invalid_rules && _prefix_0_valid) ? (p->mark = _prefix_0_end, _prefix_0_result) : (_prefix_0_result = expression_rule(p), _prefix_0_end = p->mark, _prefix_0_valid = 1, _prefix_0_result))) // expression && (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) @@ -11557,7 +11577,7 @@ expressions_rule(Parser *p) D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression")); expr_ty expression_var; if ( - (expression_var = expression_rule(p)) // expression + (expression_var = ((!p->call_invalid_rules && _prefix_0_valid) ? (p->mark = _prefix_0_end, _prefix_0_result) : (_prefix_0_result = expression_rule(p), _prefix_0_end = p->mark, _prefix_0_valid = 1, _prefix_0_result))) // expression ) { D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression")); @@ -11581,10 +11601,10 @@ expressions_rule(Parser *p) // | if_expression // | disjunction // | lambdef -static expr_ty +Py_LOCAL_SYMBOL expr_ty expression_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -11719,10 +11739,10 @@ expression_rule(Parser *p) } // if_expression: disjunction 'if' disjunction 'else' expression -static expr_ty +Py_LOCAL_SYMBOL expr_ty if_expression_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -11754,11 +11774,11 @@ if_expression_rule(Parser *p) if ( (a = disjunction_rule(p)) // disjunction && - (_keyword = _PyPegen_expect_token(p, 700)) // token='if' + (_keyword = _PyPegen_expect_token(p, 514)) // token='if' && (b = disjunction_rule(p)) // disjunction && - (_keyword_1 = _PyPegen_expect_token(p, 704)) // token='else' + (_keyword_1 = _PyPegen_expect_token(p, 522)) // token='else' && (c = expression_rule(p)) // expression ) @@ -11792,10 +11812,10 @@ if_expression_rule(Parser *p) } // yield_expr: 'yield' 'from' expression | 'yield' star_expressions? -static expr_ty +Py_LOCAL_SYMBOL expr_ty yield_expr_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -11823,9 +11843,9 @@ yield_expr_rule(Parser *p) Token * _keyword_1; expr_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 588)) // token='yield' + (_keyword = _PyPegen_expect_token(p, 506)) // token='yield' && - (_keyword_1 = _PyPegen_expect_token(p, 650)) // token='from' + (_keyword_1 = _PyPegen_expect_token(p, 501)) // token='from' && (a = expression_rule(p)) // expression ) @@ -11861,7 +11881,7 @@ yield_expr_rule(Parser *p) Token * _keyword; void *a; if ( - (_keyword = _PyPegen_expect_token(p, 588)) // token='yield' + (_keyword = _PyPegen_expect_token(p, 506)) // token='yield' && (a = star_expressions_rule(p), !p->error_indicator) // star_expressions? ) @@ -11898,10 +11918,10 @@ yield_expr_rule(Parser *p) // | star_expression ((',' star_expression))+ ','? // | star_expression ',' // | star_expression -static expr_ty +Py_LOCAL_SYMBOL expr_ty star_expressions_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -11910,6 +11930,8 @@ star_expressions_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; + expr_ty _prefix_1_result = NULL; + int _prefix_1_end = 0, _prefix_1_valid = 0; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; p->level--; @@ -11930,7 +11952,7 @@ star_expressions_rule(Parser *p) expr_ty a; asdl_seq * b; if ( - (a = star_expression_rule(p)) // star_expression + (a = ((!p->call_invalid_rules && _prefix_1_valid) ? (p->mark = _prefix_1_end, _prefix_1_result) : (_prefix_1_result = star_expression_rule(p), _prefix_1_end = p->mark, _prefix_1_valid = 1, _prefix_1_result))) // star_expression && (b = _loop1_56_rule(p)) // ((',' star_expression))+ && @@ -11968,7 +11990,7 @@ star_expressions_rule(Parser *p) Token * _literal; expr_ty a; if ( - (a = star_expression_rule(p)) // star_expression + (a = ((!p->call_invalid_rules && _prefix_1_valid) ? (p->mark = _prefix_1_end, _prefix_1_result) : (_prefix_1_result = star_expression_rule(p), _prefix_1_end = p->mark, _prefix_1_valid = 1, _prefix_1_result))) // star_expression && (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) @@ -12003,7 +12025,7 @@ star_expressions_rule(Parser *p) D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression")); expr_ty star_expression_var; if ( - (star_expression_var = star_expression_rule(p)) // star_expression + (star_expression_var = ((!p->call_invalid_rules && _prefix_1_valid) ? (p->mark = _prefix_1_end, _prefix_1_result) : (_prefix_1_result = star_expression_rule(p), _prefix_1_end = p->mark, _prefix_1_valid = 1, _prefix_1_result))) // star_expression ) { D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression")); @@ -12024,7 +12046,7 @@ star_expressions_rule(Parser *p) static expr_ty star_expression_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -12109,10 +12131,10 @@ star_expression_rule(Parser *p) } // star_named_expressions: ','.star_named_expression+ ','? -static asdl_expr_seq* +Py_LOCAL_SYMBOL asdl_expr_seq* star_named_expressions_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -12155,58 +12177,11 @@ star_named_expressions_rule(Parser *p) return _res; } -// star_named_expressions_sequence: ','.star_named_expression_sequence+ ','? -static asdl_expr_seq* -star_named_expressions_sequence_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_expr_seq* _res = NULL; - int _mark = p->mark; - { // ','.star_named_expression_sequence+ ','? - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> star_named_expressions_sequence[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_named_expression_sequence+ ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - asdl_expr_seq* a; - if ( - (a = (asdl_expr_seq*)_gather_60_rule(p)) // ','.star_named_expression_sequence+ - && - (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? - ) - { - D(fprintf(stderr, "%*c+ star_named_expressions_sequence[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_named_expression_sequence+ ','?")); - _res = a; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s star_named_expressions_sequence[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_named_expression_sequence+ ','?")); - } - _res = NULL; - done: - p->level--; - return _res; -} - // star_named_expression: '*' bitwise_or | named_expression -static expr_ty +Py_LOCAL_SYMBOL expr_ty star_named_expression_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -12285,13 +12260,11 @@ star_named_expression_rule(Parser *p) return _res; } -// star_named_expression_sequence: -// | invalid_starred_expression_unpacking_sequence -// | star_named_expression -static expr_ty -star_named_expression_sequence_rule(Parser *p) +// assignment_expression: NAME ':=' ~ expression +Py_LOCAL_SYMBOL expr_ty +assignment_expression_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -12300,82 +12273,25 @@ star_named_expression_sequence_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; - if (p->call_invalid_rules) { // invalid_starred_expression_unpacking_sequence + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + p->level--; + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // NAME ':=' ~ expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> star_named_expression_sequence[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_starred_expression_unpacking_sequence")); - void *invalid_starred_expression_unpacking_sequence_var; - if ( - (invalid_starred_expression_unpacking_sequence_var = invalid_starred_expression_unpacking_sequence_rule(p)) // invalid_starred_expression_unpacking_sequence - ) - { - D(fprintf(stderr, "%*c+ star_named_expression_sequence[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_starred_expression_unpacking_sequence")); - _res = invalid_starred_expression_unpacking_sequence_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s star_named_expression_sequence[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_starred_expression_unpacking_sequence")); - } - { // star_named_expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> star_named_expression_sequence[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression")); - expr_ty star_named_expression_var; - if ( - (star_named_expression_var = star_named_expression_rule(p)) // star_named_expression - ) - { - D(fprintf(stderr, "%*c+ star_named_expression_sequence[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression")); - _res = star_named_expression_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s star_named_expression_sequence[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// assignment_expression: NAME ':=' ~ expression -static expr_ty -assignment_expression_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - expr_ty _res = NULL; - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - p->level--; - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NAME ':=' ~ expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> assignment_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':=' ~ expression")); - int _cut_var = 0; - Token * _literal; - expr_ty a; - expr_ty b; + D(fprintf(stderr, "%*c> assignment_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':=' ~ expression")); + int _cut_var = 0; + Token * _literal; + expr_ty a; + expr_ty b; if ( (a = _PyPegen_name_token(p)) // NAME && @@ -12419,10 +12335,10 @@ assignment_expression_rule(Parser *p) } // named_expression: assignment_expression | invalid_named_expression | expression !':=' -static expr_ty +Py_LOCAL_SYMBOL expr_ty named_expression_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -12497,10 +12413,10 @@ named_expression_rule(Parser *p) } // disjunction: conjunction (('or' conjunction))+ | conjunction -static expr_ty +Py_LOCAL_SYMBOL expr_ty disjunction_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -12508,11 +12424,17 @@ disjunction_rule(Parser *p) return NULL; } expr_ty _res = NULL; + if (_PyPegen_atom_fast_path(p, &_res)) { + p->level--; + return _res; + } if (_PyPegen_is_memoized(p, disjunction_type, &_res)) { p->level--; return _res; } int _mark = p->mark; + expr_ty _prefix_2_result = NULL; + int _prefix_2_end = 0, _prefix_2_valid = 0; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; p->level--; @@ -12531,9 +12453,9 @@ disjunction_rule(Parser *p) expr_ty a; asdl_seq * b; if ( - (a = conjunction_rule(p)) // conjunction + (a = ((!p->call_invalid_rules && _prefix_2_valid) ? (p->mark = _prefix_2_end, _prefix_2_result) : (_prefix_2_result = conjunction_rule(p), _prefix_2_end = p->mark, _prefix_2_valid = 1, _prefix_2_result))) // conjunction && - (b = _loop1_61_rule(p)) // (('or' conjunction))+ + (b = _loop1_59_rule(p)) // (('or' conjunction))+ ) { D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); @@ -12566,7 +12488,7 @@ disjunction_rule(Parser *p) D(fprintf(stderr, "%*c> disjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "conjunction")); expr_ty conjunction_var; if ( - (conjunction_var = conjunction_rule(p)) // conjunction + (conjunction_var = ((!p->call_invalid_rules && _prefix_2_valid) ? (p->mark = _prefix_2_end, _prefix_2_result) : (_prefix_2_result = conjunction_rule(p), _prefix_2_end = p->mark, _prefix_2_valid = 1, _prefix_2_result))) // conjunction ) { D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction")); @@ -12588,7 +12510,7 @@ disjunction_rule(Parser *p) static expr_ty conjunction_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -12601,6 +12523,8 @@ conjunction_rule(Parser *p) return _res; } int _mark = p->mark; + expr_ty _prefix_3_result = NULL; + int _prefix_3_end = 0, _prefix_3_valid = 0; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; p->level--; @@ -12619,9 +12543,9 @@ conjunction_rule(Parser *p) expr_ty a; asdl_seq * b; if ( - (a = inversion_rule(p)) // inversion + (a = ((!p->call_invalid_rules && _prefix_3_valid) ? (p->mark = _prefix_3_end, _prefix_3_result) : (_prefix_3_result = inversion_rule(p), _prefix_3_end = p->mark, _prefix_3_valid = 1, _prefix_3_result))) // inversion && - (b = _loop1_62_rule(p)) // (('and' inversion))+ + (b = _loop1_60_rule(p)) // (('and' inversion))+ ) { D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); @@ -12654,7 +12578,7 @@ conjunction_rule(Parser *p) D(fprintf(stderr, "%*c> conjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "inversion")); expr_ty inversion_var; if ( - (inversion_var = inversion_rule(p)) // inversion + (inversion_var = ((!p->call_invalid_rules && _prefix_3_valid) ? (p->mark = _prefix_3_end, _prefix_3_result) : (_prefix_3_result = inversion_rule(p), _prefix_3_end = p->mark, _prefix_3_valid = 1, _prefix_3_result))) // inversion ) { D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion")); @@ -12673,10 +12597,10 @@ conjunction_rule(Parser *p) } // inversion: 'not' inversion | comparison -static expr_ty +Py_LOCAL_SYMBOL expr_ty inversion_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -12684,6 +12608,10 @@ inversion_rule(Parser *p) return NULL; } expr_ty _res = NULL; + if (_PyPegen_atom_fast_path(p, &_res)) { + p->level--; + return _res; + } if (_PyPegen_is_memoized(p, inversion_type, &_res)) { p->level--; return _res; @@ -12707,7 +12635,7 @@ inversion_rule(Parser *p) Token * _keyword; expr_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 721)) // token='not' + (_keyword = _PyPegen_expect_token(p, 531)) // token='not' && (a = inversion_rule(p)) // inversion ) @@ -12764,7 +12692,7 @@ inversion_rule(Parser *p) static expr_ty comparison_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -12773,6 +12701,8 @@ comparison_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; + expr_ty _prefix_4_result = NULL; + int _prefix_4_end = 0, _prefix_4_valid = 0; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; p->level--; @@ -12791,9 +12721,9 @@ comparison_rule(Parser *p) expr_ty a; asdl_seq * b; if ( - (a = bitwise_or_rule(p)) // bitwise_or + (a = ((!p->call_invalid_rules && _prefix_4_valid) ? (p->mark = _prefix_4_end, _prefix_4_result) : (_prefix_4_result = bitwise_or_rule(p), _prefix_4_end = p->mark, _prefix_4_valid = 1, _prefix_4_result))) // bitwise_or && - (b = _loop1_63_rule(p)) // compare_op_bitwise_or_pair+ + (b = _loop1_61_rule(p)) // compare_op_bitwise_or_pair+ ) { D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); @@ -12826,7 +12756,7 @@ comparison_rule(Parser *p) D(fprintf(stderr, "%*c> comparison[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or")); expr_ty bitwise_or_var; if ( - (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + (bitwise_or_var = ((!p->call_invalid_rules && _prefix_4_valid) ? (p->mark = _prefix_4_end, _prefix_4_result) : (_prefix_4_result = bitwise_or_rule(p), _prefix_4_end = p->mark, _prefix_4_valid = 1, _prefix_4_result))) // bitwise_or ) { D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or")); @@ -12844,20 +12774,21 @@ comparison_rule(Parser *p) } // compare_op_bitwise_or_pair: -// | eq_bitwise_or -// | noteq_bitwise_or -// | lte_bitwise_or -// | lt_bitwise_or -// | gte_bitwise_or -// | gt_bitwise_or -// | notin_bitwise_or -// | in_bitwise_or -// | isnot_bitwise_or -// | is_bitwise_or +// | '==' bitwise_or +// | ('!=') bitwise_or +// | '<=' bitwise_or +// | invalid_noteq +// | '<' bitwise_or +// | '>=' bitwise_or +// | '>' bitwise_or +// | 'not' 'in' bitwise_or +// | 'in' bitwise_or +// | 'is' 'not' bitwise_or +// | 'is' bitwise_or static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -12866,231 +12797,263 @@ compare_op_bitwise_or_pair_rule(Parser *p) } CmpopExprPair* _res = NULL; int _mark = p->mark; - { // eq_bitwise_or - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "eq_bitwise_or")); - CmpopExprPair* eq_bitwise_or_var; - if ( - (eq_bitwise_or_var = eq_bitwise_or_rule(p)) // eq_bitwise_or - ) - { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "eq_bitwise_or")); - _res = eq_bitwise_or_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "eq_bitwise_or")); - } - { // noteq_bitwise_or + { // '==' bitwise_or if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "noteq_bitwise_or")); - CmpopExprPair* noteq_bitwise_or_var; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or")); + Token * _literal; + expr_ty a; if ( - (noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) // noteq_bitwise_or + (_literal = _PyPegen_expect_token(p, 27)) // token='==' + && + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "noteq_bitwise_or")); - _res = noteq_bitwise_or_var; + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , Eq , a ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "noteq_bitwise_or")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'==' bitwise_or")); } - { // lte_bitwise_or + { // ('!=') bitwise_or if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lte_bitwise_or")); - CmpopExprPair* lte_bitwise_or_var; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); + void *_tmp_62_var; + expr_ty a; if ( - (lte_bitwise_or_var = lte_bitwise_or_rule(p)) // lte_bitwise_or + (_tmp_62_var = _tmp_62_rule(p)) // '!=' + && + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lte_bitwise_or")); - _res = lte_bitwise_or_var; + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , NotEq , a ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lte_bitwise_or")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('!=') bitwise_or")); } - { // lt_bitwise_or + { // '<=' bitwise_or if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lt_bitwise_or")); - CmpopExprPair* lt_bitwise_or_var; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or")); + Token * _literal; + expr_ty a; if ( - (lt_bitwise_or_var = lt_bitwise_or_rule(p)) // lt_bitwise_or + (_literal = _PyPegen_expect_token(p, 29)) // token='<=' + && + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lt_bitwise_or")); - _res = lt_bitwise_or_var; + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , LtE , a ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lt_bitwise_or")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<=' bitwise_or")); } - { // gte_bitwise_or + if (p->call_invalid_rules) { // invalid_noteq if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "gte_bitwise_or")); - CmpopExprPair* gte_bitwise_or_var; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_noteq")); + void *invalid_noteq_var; if ( - (gte_bitwise_or_var = gte_bitwise_or_rule(p)) // gte_bitwise_or + (invalid_noteq_var = invalid_noteq_rule(p)) // invalid_noteq ) { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "gte_bitwise_or")); - _res = gte_bitwise_or_var; + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_noteq")); + _res = invalid_noteq_var; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "gte_bitwise_or")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_noteq")); } - { // gt_bitwise_or + { // '<' bitwise_or if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "gt_bitwise_or")); - CmpopExprPair* gt_bitwise_or_var; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or")); + Token * _literal; + expr_ty a; if ( - (gt_bitwise_or_var = gt_bitwise_or_rule(p)) // gt_bitwise_or + (_literal = _PyPegen_expect_token(p, 20)) // token='<' + && + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "gt_bitwise_or")); - _res = gt_bitwise_or_var; + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , Lt , a ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "gt_bitwise_or")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<' bitwise_or")); } - { // notin_bitwise_or + { // '>=' bitwise_or if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "notin_bitwise_or")); - CmpopExprPair* notin_bitwise_or_var; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or")); + Token * _literal; + expr_ty a; if ( - (notin_bitwise_or_var = notin_bitwise_or_rule(p)) // notin_bitwise_or + (_literal = _PyPegen_expect_token(p, 30)) // token='>=' + && + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "notin_bitwise_or")); - _res = notin_bitwise_or_var; + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , GtE , a ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "notin_bitwise_or")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>=' bitwise_or")); } - { // in_bitwise_or + { // '>' bitwise_or if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "in_bitwise_or")); - CmpopExprPair* in_bitwise_or_var; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or")); + Token * _literal; + expr_ty a; if ( - (in_bitwise_or_var = in_bitwise_or_rule(p)) // in_bitwise_or + (_literal = _PyPegen_expect_token(p, 21)) // token='>' + && + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "in_bitwise_or")); - _res = in_bitwise_or_var; + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , Gt , a ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "in_bitwise_or")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>' bitwise_or")); } - { // isnot_bitwise_or + { // 'not' 'in' bitwise_or if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "isnot_bitwise_or")); - CmpopExprPair* isnot_bitwise_or_var; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or")); + Token * _keyword; + Token * _keyword_1; + expr_ty a; if ( - (isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) // isnot_bitwise_or + (_keyword = _PyPegen_expect_token(p, 531)) // token='not' + && + (_keyword_1 = _PyPegen_expect_token(p, 523)) // token='in' + && + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "isnot_bitwise_or")); - _res = isnot_bitwise_or_var; + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , NotIn , a ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "isnot_bitwise_or")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'not' 'in' bitwise_or")); } - { // is_bitwise_or + { // 'in' bitwise_or if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "is_bitwise_or")); - CmpopExprPair* is_bitwise_or_var; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or")); + Token * _keyword; + expr_ty a; if ( - (is_bitwise_or_var = is_bitwise_or_rule(p)) // is_bitwise_or + (_keyword = _PyPegen_expect_token(p, 523)) // token='in' + && + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "is_bitwise_or")); - _res = is_bitwise_or_var; + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , In , a ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "is_bitwise_or")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// eq_bitwise_or: '==' bitwise_or -static CmpopExprPair* -eq_bitwise_or_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'in' bitwise_or")); } - CmpopExprPair* _res = NULL; - int _mark = p->mark; - { // '==' bitwise_or + { // 'is' 'not' bitwise_or if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> eq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or")); - Token * _literal; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or")); + Token * _keyword; + Token * _keyword_1; expr_ty a; if ( - (_literal = _PyPegen_expect_token(p, 27)) // token='==' + (_keyword = _PyPegen_expect_token(p, 532)) // token='is' + && + (_keyword_1 = _PyPegen_expect_token(p, 531)) // token='not' && (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ eq_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , Eq , a ); + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , IsNot , a ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -13099,44 +13062,25 @@ eq_bitwise_or_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s eq_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'==' bitwise_or")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// noteq_bitwise_or: ('!=') bitwise_or -static CmpopExprPair* -noteq_bitwise_or_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; + D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' 'not' bitwise_or")); } - CmpopExprPair* _res = NULL; - int _mark = p->mark; - { // ('!=') bitwise_or + { // 'is' bitwise_or if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); - void *_tmp_64_var; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or")); + Token * _keyword; expr_ty a; if ( - (_tmp_64_var = _tmp_64_rule(p)) // '!=' + (_keyword = _PyPegen_expect_token(p, 532)) // token='is' && (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ noteq_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , NotEq , a ); + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , Is , a ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -13145,8 +13089,8 @@ noteq_bitwise_or_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s noteq_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('!=') bitwise_or")); + D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' bitwise_or")); } _res = NULL; done: @@ -13154,81 +13098,94 @@ noteq_bitwise_or_rule(Parser *p) return _res; } -// lte_bitwise_or: '<=' bitwise_or -static CmpopExprPair* -lte_bitwise_or_rule(Parser *p) +// Left-recursive +// bitwise_or: bitwise_or '|' bitwise_xor | invalid_bitwise_or | bitwise_xor +static expr_ty bitwise_or_raw(Parser *); +Py_LOCAL_SYMBOL expr_ty +bitwise_or_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } - if (p->error_indicator) { + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, bitwise_or_type, &_res)) { p->level--; - return NULL; + return _res; } - CmpopExprPair* _res = NULL; int _mark = p->mark; - { // '<=' bitwise_or - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> lte_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or")); - Token * _literal; - expr_ty a; - if ( - (_literal = _PyPegen_expect_token(p, 29)) // token='<=' - && - (a = bitwise_or_rule(p)) // bitwise_or - ) - { - D(fprintf(stderr, "%*c+ lte_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , LtE , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } + int _resmark = p->mark; + Memo *_memo = _PyPegen_insert_memo_direct(p, _mark, bitwise_or_type); + if (_memo == NULL) { + p->level--; + return NULL; + } + while (1) { + _memo->node = _res; + _memo->mark = p->mark; p->mark = _mark; - D(fprintf(stderr, "%*c%s lte_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<=' bitwise_or")); + void *_raw = bitwise_or_raw(p); + if (p->error_indicator) { + p->level--; + return NULL; + } + if (_raw == NULL || p->mark <= _resmark) + break; + _resmark = p->mark; + _res = _raw; } - _res = NULL; - done: + p->mark = _resmark; p->level--; return _res; } - -// lt_bitwise_or: '<' bitwise_or -static CmpopExprPair* -lt_bitwise_or_rule(Parser *p) +static expr_ty +bitwise_or_raw(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - CmpopExprPair* _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; - { // '<' bitwise_or + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + p->level--; + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // bitwise_or '|' bitwise_xor if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> lt_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or")); + D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor")); Token * _literal; expr_ty a; + expr_ty b; if ( - (_literal = _PyPegen_expect_token(p, 20)) // token='<' - && (a = bitwise_or_rule(p)) // bitwise_or + && + (_literal = _PyPegen_expect_token(p, 18)) // token='|' + && + (b = bitwise_xor_rule(p)) // bitwise_xor ) { - D(fprintf(stderr, "%*c+ lt_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , Lt , a ); + D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + p->level--; + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _PyAST_BinOp ( a , BitOr , b , EXTRA ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -13237,54 +13194,46 @@ lt_bitwise_or_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lt_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<' bitwise_or")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// gte_bitwise_or: '>=' bitwise_or -static CmpopExprPair* -gte_bitwise_or_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); + D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or '|' bitwise_xor")); } - if (p->error_indicator) { - p->level--; - return NULL; + if (p->call_invalid_rules) { // invalid_bitwise_or + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_bitwise_or")); + void *invalid_bitwise_or_var; + if ( + (invalid_bitwise_or_var = invalid_bitwise_or_rule(p)) // invalid_bitwise_or + ) + { + D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_bitwise_or")); + _res = invalid_bitwise_or_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_bitwise_or")); } - CmpopExprPair* _res = NULL; - int _mark = p->mark; - { // '>=' bitwise_or + { // bitwise_xor if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> gte_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or")); - Token * _literal; - expr_ty a; + D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor")); + expr_ty bitwise_xor_var; if ( - (_literal = _PyPegen_expect_token(p, 30)) // token='>=' - && - (a = bitwise_or_rule(p)) // bitwise_or + (bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor ) { - D(fprintf(stderr, "%*c+ gte_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , GtE , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor")); + _res = bitwise_xor_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s gte_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>=' bitwise_or")); + D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor")); } _res = NULL; done: @@ -13292,84 +13241,94 @@ gte_bitwise_or_rule(Parser *p) return _res; } -// gt_bitwise_or: '>' bitwise_or -static CmpopExprPair* -gt_bitwise_or_rule(Parser *p) +// Left-recursive +// bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and +static expr_ty bitwise_xor_raw(Parser *); +static expr_ty +bitwise_xor_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } - if (p->error_indicator) { + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, bitwise_xor_type, &_res)) { p->level--; - return NULL; + return _res; } - CmpopExprPair* _res = NULL; int _mark = p->mark; - { // '>' bitwise_or + int _resmark = p->mark; + Memo *_memo = _PyPegen_insert_memo_direct(p, _mark, bitwise_xor_type); + if (_memo == NULL) { + p->level--; + return NULL; + } + while (1) { + _memo->node = _res; + _memo->mark = p->mark; + p->mark = _mark; + void *_raw = bitwise_xor_raw(p); if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> gt_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or")); - Token * _literal; - expr_ty a; - if ( - (_literal = _PyPegen_expect_token(p, 21)) // token='>' - && - (a = bitwise_or_rule(p)) // bitwise_or - ) - { - D(fprintf(stderr, "%*c+ gt_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , Gt , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s gt_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>' bitwise_or")); + if (_raw == NULL || p->mark <= _resmark) + break; + _resmark = p->mark; + _res = _raw; } - _res = NULL; - done: + p->mark = _resmark; p->level--; return _res; } - -// notin_bitwise_or: 'not' 'in' bitwise_or -static CmpopExprPair* -notin_bitwise_or_rule(Parser *p) +static expr_ty +bitwise_xor_raw(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - CmpopExprPair* _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; - { // 'not' 'in' bitwise_or + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + p->level--; + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // bitwise_xor '^' bitwise_and if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> notin_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or")); - Token * _keyword; - Token * _keyword_1; + D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and")); + Token * _literal; expr_ty a; + expr_ty b; if ( - (_keyword = _PyPegen_expect_token(p, 721)) // token='not' + (a = bitwise_xor_rule(p)) // bitwise_xor && - (_keyword_1 = _PyPegen_expect_token(p, 713)) // token='in' + (_literal = _PyPegen_expect_token(p, 32)) // token='^' && - (a = bitwise_or_rule(p)) // bitwise_or + (b = bitwise_and_rule(p)) // bitwise_and ) { - D(fprintf(stderr, "%*c+ notin_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , NotIn , a ); + D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + p->level--; + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _PyAST_BinOp ( a , BitXor , b , EXTRA ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -13378,54 +13337,27 @@ notin_bitwise_or_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s notin_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'not' 'in' bitwise_or")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// in_bitwise_or: 'in' bitwise_or -static CmpopExprPair* -in_bitwise_or_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; + D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor '^' bitwise_and")); } - CmpopExprPair* _res = NULL; - int _mark = p->mark; - { // 'in' bitwise_or + { // bitwise_and if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> in_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or")); - Token * _keyword; - expr_ty a; + D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and")); + expr_ty bitwise_and_var; if ( - (_keyword = _PyPegen_expect_token(p, 713)) // token='in' - && - (a = bitwise_or_rule(p)) // bitwise_or + (bitwise_and_var = bitwise_and_rule(p)) // bitwise_and ) { - D(fprintf(stderr, "%*c+ in_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , In , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and")); + _res = bitwise_and_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s in_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'in' bitwise_or")); + D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and")); } _res = NULL; done: @@ -13433,125 +13365,32 @@ in_bitwise_or_rule(Parser *p) return _res; } -// isnot_bitwise_or: 'is' 'not' bitwise_or -static CmpopExprPair* -isnot_bitwise_or_rule(Parser *p) +// Left-recursive +// bitwise_and: bitwise_and '&' shift_expr | invalid_bitwise_and | shift_expr +static expr_ty bitwise_and_raw(Parser *); +Py_LOCAL_SYMBOL expr_ty +bitwise_and_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - CmpopExprPair* _res = NULL; - int _mark = p->mark; - { // 'is' 'not' bitwise_or - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> isnot_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or")); - Token * _keyword; - Token * _keyword_1; - expr_ty a; - if ( - (_keyword = _PyPegen_expect_token(p, 597)) // token='is' - && - (_keyword_1 = _PyPegen_expect_token(p, 721)) // token='not' - && - (a = bitwise_or_rule(p)) // bitwise_or - ) - { - D(fprintf(stderr, "%*c+ isnot_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , IsNot , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s isnot_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' 'not' bitwise_or")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// is_bitwise_or: 'is' bitwise_or -static CmpopExprPair* -is_bitwise_or_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - CmpopExprPair* _res = NULL; - int _mark = p->mark; - { // 'is' bitwise_or - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> is_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or")); - Token * _keyword; - expr_ty a; - if ( - (_keyword = _PyPegen_expect_token(p, 597)) // token='is' - && - (a = bitwise_or_rule(p)) // bitwise_or - ) - { - D(fprintf(stderr, "%*c+ is_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , Is , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s is_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' bitwise_or")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// Left-recursive -// bitwise_or: bitwise_or '|' bitwise_xor | invalid_bitwise_or | bitwise_xor -static expr_ty bitwise_or_raw(Parser *); -static expr_ty -bitwise_or_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, bitwise_or_type, &_res)) { + if (_PyPegen_is_memoized(p, bitwise_and_type, &_res)) { p->level--; return _res; } int _mark = p->mark; int _resmark = p->mark; + Memo *_memo = _PyPegen_insert_memo_direct(p, _mark, bitwise_and_type); + if (_memo == NULL) { + p->level--; + return NULL; + } while (1) { - int tmpvar_2 = _PyPegen_update_memo(p, _mark, bitwise_or_type, _res); - if (tmpvar_2) { - p->level--; - return _res; - } + _memo->node = _res; + _memo->mark = p->mark; p->mark = _mark; - void *_raw = bitwise_or_raw(p); + void *_raw = bitwise_and_raw(p); if (p->error_indicator) { p->level--; return NULL; @@ -13566,9 +13405,9 @@ bitwise_or_rule(Parser *p) return _res; } static expr_ty -bitwise_or_raw(Parser *p) +bitwise_and_raw(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -13586,24 +13425,24 @@ bitwise_or_raw(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // bitwise_or '|' bitwise_xor + { // bitwise_and '&' shift_expr if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor")); + D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr")); Token * _literal; expr_ty a; expr_ty b; if ( - (a = bitwise_or_rule(p)) // bitwise_or + (a = bitwise_and_rule(p)) // bitwise_and && - (_literal = _PyPegen_expect_token(p, 18)) // token='|' + (_literal = _PyPegen_expect_token(p, 19)) // token='&' && - (b = bitwise_xor_rule(p)) // bitwise_xor + (b = shift_expr_rule(p)) // shift_expr ) { - D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor")); + D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -13613,7 +13452,7 @@ bitwise_or_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_BinOp ( a , BitOr , b , EXTRA ); + _res = _PyAST_BinOp ( a , BitAnd , b , EXTRA ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -13622,46 +13461,46 @@ bitwise_or_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or '|' bitwise_xor")); + D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and '&' shift_expr")); } - if (p->call_invalid_rules) { // invalid_bitwise_or + if (p->call_invalid_rules) { // invalid_bitwise_and if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_bitwise_or")); - void *invalid_bitwise_or_var; + D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_bitwise_and")); + void *invalid_bitwise_and_var; if ( - (invalid_bitwise_or_var = invalid_bitwise_or_rule(p)) // invalid_bitwise_or + (invalid_bitwise_and_var = invalid_bitwise_and_rule(p)) // invalid_bitwise_and ) { - D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_bitwise_or")); - _res = invalid_bitwise_or_var; + D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_bitwise_and")); + _res = invalid_bitwise_and_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_bitwise_or")); + D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_bitwise_and")); } - { // bitwise_xor + { // shift_expr if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor")); - expr_ty bitwise_xor_var; + D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr")); + expr_ty shift_expr_var; if ( - (bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor + (shift_expr_var = shift_expr_rule(p)) // shift_expr ) { - D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor")); - _res = bitwise_xor_var; + D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr")); + _res = shift_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor")); + D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr")); } _res = NULL; done: @@ -13670,29 +13509,31 @@ bitwise_or_raw(Parser *p) } // Left-recursive -// bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and -static expr_ty bitwise_xor_raw(Parser *); +// shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum +static expr_ty shift_expr_raw(Parser *); static expr_ty -bitwise_xor_rule(Parser *p) +shift_expr_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, bitwise_xor_type, &_res)) { + if (_PyPegen_is_memoized(p, shift_expr_type, &_res)) { p->level--; return _res; } int _mark = p->mark; int _resmark = p->mark; + Memo *_memo = _PyPegen_insert_memo_direct(p, _mark, shift_expr_type); + if (_memo == NULL) { + p->level--; + return NULL; + } while (1) { - int tmpvar_3 = _PyPegen_update_memo(p, _mark, bitwise_xor_type, _res); - if (tmpvar_3) { - p->level--; - return _res; - } + _memo->node = _res; + _memo->mark = p->mark; p->mark = _mark; - void *_raw = bitwise_xor_raw(p); + void *_raw = shift_expr_raw(p); if (p->error_indicator) { p->level--; return NULL; @@ -13707,9 +13548,9 @@ bitwise_xor_rule(Parser *p) return _res; } static expr_ty -bitwise_xor_raw(Parser *p) +shift_expr_raw(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -13718,6 +13559,8 @@ bitwise_xor_raw(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; + expr_ty _prefix_5_result = NULL; + int _prefix_5_end = 0, _prefix_5_valid = 0; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; p->level--; @@ -13727,24 +13570,24 @@ bitwise_xor_raw(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // bitwise_xor '^' bitwise_and + { // shift_expr '<<' sum if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and")); + D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum")); Token * _literal; expr_ty a; expr_ty b; if ( - (a = bitwise_xor_rule(p)) // bitwise_xor + (a = ((!p->call_invalid_rules && _prefix_5_valid) ? (p->mark = _prefix_5_end, _prefix_5_result) : (_prefix_5_result = shift_expr_rule(p), _prefix_5_end = p->mark, _prefix_5_valid = 1, _prefix_5_result))) // shift_expr && - (_literal = _PyPegen_expect_token(p, 32)) // token='^' + (_literal = _PyPegen_expect_token(p, 33)) // token='<<' && - (b = bitwise_and_rule(p)) // bitwise_and + (b = sum_rule(p)) // sum ) { - D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and")); + D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -13754,7 +13597,7 @@ bitwise_xor_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_BinOp ( a , BitXor , b , EXTRA ); + _res = _PyAST_BinOp ( a , LShift , b , EXTRA ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -13763,27 +13606,66 @@ bitwise_xor_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor '^' bitwise_and")); + D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '<<' sum")); } - { // bitwise_and + { // shift_expr '>>' sum if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and")); - expr_ty bitwise_and_var; + D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum")); + Token * _literal; + expr_ty a; + expr_ty b; if ( - (bitwise_and_var = bitwise_and_rule(p)) // bitwise_and + (a = ((!p->call_invalid_rules && _prefix_5_valid) ? (p->mark = _prefix_5_end, _prefix_5_result) : (_prefix_5_result = shift_expr_rule(p), _prefix_5_end = p->mark, _prefix_5_valid = 1, _prefix_5_result))) // shift_expr + && + (_literal = _PyPegen_expect_token(p, 34)) // token='>>' + && + (b = sum_rule(p)) // sum ) { - D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and")); - _res = bitwise_and_var; + D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + p->level--; + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _PyAST_BinOp ( a , RShift , b , EXTRA ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and")); + D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '>>' sum")); + } + { // sum + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum")); + expr_ty sum_var; + if ( + (sum_var = sum_rule(p)) // sum + ) + { + D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum")); + _res = sum_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum")); } _res = NULL; done: @@ -13792,29 +13674,31 @@ bitwise_xor_raw(Parser *p) } // Left-recursive -// bitwise_and: bitwise_and '&' shift_expr | invalid_bitwise_and | shift_expr -static expr_ty bitwise_and_raw(Parser *); -static expr_ty -bitwise_and_rule(Parser *p) +// sum: sum '+' term | sum '-' term | invalid_arithmetic | term +static expr_ty sum_raw(Parser *); +Py_LOCAL_SYMBOL expr_ty +sum_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, bitwise_and_type, &_res)) { + if (_PyPegen_is_memoized(p, sum_type, &_res)) { p->level--; return _res; } int _mark = p->mark; int _resmark = p->mark; + Memo *_memo = _PyPegen_insert_memo_direct(p, _mark, sum_type); + if (_memo == NULL) { + p->level--; + return NULL; + } while (1) { - int tmpvar_4 = _PyPegen_update_memo(p, _mark, bitwise_and_type, _res); - if (tmpvar_4) { - p->level--; - return _res; - } + _memo->node = _res; + _memo->mark = p->mark; p->mark = _mark; - void *_raw = bitwise_and_raw(p); + void *_raw = sum_raw(p); if (p->error_indicator) { p->level--; return NULL; @@ -13829,9 +13713,9 @@ bitwise_and_rule(Parser *p) return _res; } static expr_ty -bitwise_and_raw(Parser *p) +sum_raw(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -13840,6 +13724,8 @@ bitwise_and_raw(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; + expr_ty _prefix_6_result = NULL; + int _prefix_6_end = 0, _prefix_6_valid = 0; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; p->level--; @@ -13849,24 +13735,24 @@ bitwise_and_raw(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // bitwise_and '&' shift_expr + { // sum '+' term if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr")); + D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '+' term")); Token * _literal; expr_ty a; expr_ty b; if ( - (a = bitwise_and_rule(p)) // bitwise_and + (a = ((!p->call_invalid_rules && _prefix_6_valid) ? (p->mark = _prefix_6_end, _prefix_6_result) : (_prefix_6_result = sum_rule(p), _prefix_6_end = p->mark, _prefix_6_valid = 1, _prefix_6_result))) // sum && - (_literal = _PyPegen_expect_token(p, 19)) // token='&' + (_literal = _PyPegen_expect_token(p, 14)) // token='+' && - (b = shift_expr_rule(p)) // shift_expr + (b = term_rule(p)) // term ) { - D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr")); + D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '+' term")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -13876,7 +13762,7 @@ bitwise_and_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_BinOp ( a , BitAnd , b , EXTRA ); + _res = _PyAST_BinOp ( a , Add , b , EXTRA ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -13885,46 +13771,85 @@ bitwise_and_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and '&' shift_expr")); + D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '+' term")); } - if (p->call_invalid_rules) { // invalid_bitwise_and + { // sum '-' term if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_bitwise_and")); - void *invalid_bitwise_and_var; + D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '-' term")); + Token * _literal; + expr_ty a; + expr_ty b; if ( - (invalid_bitwise_and_var = invalid_bitwise_and_rule(p)) // invalid_bitwise_and + (a = ((!p->call_invalid_rules && _prefix_6_valid) ? (p->mark = _prefix_6_end, _prefix_6_result) : (_prefix_6_result = sum_rule(p), _prefix_6_end = p->mark, _prefix_6_valid = 1, _prefix_6_result))) // sum + && + (_literal = _PyPegen_expect_token(p, 15)) // token='-' + && + (b = term_rule(p)) // term ) { - D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_bitwise_and")); - _res = invalid_bitwise_and_var; + D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '-' term")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + p->level--; + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _PyAST_BinOp ( a , Sub , b , EXTRA ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_bitwise_and")); + D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '-' term")); } - { // shift_expr + if (p->call_invalid_rules) { // invalid_arithmetic if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr")); - expr_ty shift_expr_var; + D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_arithmetic")); + void *invalid_arithmetic_var; if ( - (shift_expr_var = shift_expr_rule(p)) // shift_expr + (invalid_arithmetic_var = invalid_arithmetic_rule(p)) // invalid_arithmetic ) { - D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr")); - _res = shift_expr_var; + D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_arithmetic")); + _res = invalid_arithmetic_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr")); + D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_arithmetic")); + } + { // term + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term")); + expr_ty term_var; + if ( + (term_var = term_rule(p)) // term + ) + { + D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term")); + _res = term_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term")); } _res = NULL; done: @@ -13933,29 +13858,37 @@ bitwise_and_raw(Parser *p) } // Left-recursive -// shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum -static expr_ty shift_expr_raw(Parser *); +// term: +// | term '*' factor +// | term '/' factor +// | term '//' factor +// | term '%' factor +// | term '@' factor +// | factor +static expr_ty term_raw(Parser *); static expr_ty -shift_expr_rule(Parser *p) +term_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, shift_expr_type, &_res)) { + if (_PyPegen_is_memoized(p, term_type, &_res)) { p->level--; return _res; } int _mark = p->mark; int _resmark = p->mark; + Memo *_memo = _PyPegen_insert_memo_direct(p, _mark, term_type); + if (_memo == NULL) { + p->level--; + return NULL; + } while (1) { - int tmpvar_5 = _PyPegen_update_memo(p, _mark, shift_expr_type, _res); - if (tmpvar_5) { - p->level--; - return _res; - } + _memo->node = _res; + _memo->mark = p->mark; p->mark = _mark; - void *_raw = shift_expr_raw(p); + void *_raw = term_raw(p); if (p->error_indicator) { p->level--; return NULL; @@ -13970,9 +13903,9 @@ shift_expr_rule(Parser *p) return _res; } static expr_ty -shift_expr_raw(Parser *p) +term_raw(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -13981,6 +13914,8 @@ shift_expr_raw(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; + expr_ty _prefix_7_result = NULL; + int _prefix_7_end = 0, _prefix_7_valid = 0; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; p->level--; @@ -13990,24 +13925,24 @@ shift_expr_raw(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // shift_expr '<<' sum + { // term '*' factor if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum")); + D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '*' factor")); Token * _literal; expr_ty a; expr_ty b; if ( - (a = shift_expr_rule(p)) // shift_expr + (a = ((!p->call_invalid_rules && _prefix_7_valid) ? (p->mark = _prefix_7_end, _prefix_7_result) : (_prefix_7_result = term_rule(p), _prefix_7_end = p->mark, _prefix_7_valid = 1, _prefix_7_result))) // term && - (_literal = _PyPegen_expect_token(p, 33)) // token='<<' + (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (b = sum_rule(p)) // sum + (b = factor_rule(p)) // factor ) { - D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum")); + D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '*' factor")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -14017,7 +13952,7 @@ shift_expr_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_BinOp ( a , LShift , b , EXTRA ); + _res = _PyAST_BinOp ( a , Mult , b , EXTRA ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -14026,27 +13961,27 @@ shift_expr_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '<<' sum")); + D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '*' factor")); } - { // shift_expr '>>' sum + { // term '/' factor if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum")); + D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '/' factor")); Token * _literal; expr_ty a; expr_ty b; if ( - (a = shift_expr_rule(p)) // shift_expr + (a = ((!p->call_invalid_rules && _prefix_7_valid) ? (p->mark = _prefix_7_end, _prefix_7_result) : (_prefix_7_result = term_rule(p), _prefix_7_end = p->mark, _prefix_7_valid = 1, _prefix_7_result))) // term && - (_literal = _PyPegen_expect_token(p, 34)) // token='>>' + (_literal = _PyPegen_expect_token(p, 17)) // token='/' && - (b = sum_rule(p)) // sum + (b = factor_rule(p)) // factor ) { - D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum")); + D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '/' factor")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -14056,7 +13991,7 @@ shift_expr_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_BinOp ( a , RShift , b , EXTRA ); + _res = _PyAST_BinOp ( a , Div , b , EXTRA ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -14065,110 +14000,27 @@ shift_expr_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '>>' sum")); - } - { // sum - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum")); - expr_ty sum_var; - if ( - (sum_var = sum_rule(p)) // sum - ) - { - D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum")); - _res = sum_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// Left-recursive -// sum: sum '+' term | sum '-' term | invalid_arithmetic | term -static expr_ty sum_raw(Parser *); -static expr_ty -sum_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, sum_type, &_res)) { - p->level--; - return _res; - } - int _mark = p->mark; - int _resmark = p->mark; - while (1) { - int tmpvar_6 = _PyPegen_update_memo(p, _mark, sum_type, _res); - if (tmpvar_6) { - p->level--; - return _res; - } - p->mark = _mark; - void *_raw = sum_raw(p); - if (p->error_indicator) { - p->level--; - return NULL; - } - if (_raw == NULL || p->mark <= _resmark) - break; - _resmark = p->mark; - _res = _raw; - } - p->mark = _resmark; - p->level--; - return _res; -} -static expr_ty -sum_raw(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - expr_ty _res = NULL; - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - p->level--; - return NULL; + D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '/' factor")); } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // sum '+' term + { // term '//' factor if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '+' term")); + D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '//' factor")); Token * _literal; expr_ty a; expr_ty b; if ( - (a = sum_rule(p)) // sum + (a = ((!p->call_invalid_rules && _prefix_7_valid) ? (p->mark = _prefix_7_end, _prefix_7_result) : (_prefix_7_result = term_rule(p), _prefix_7_end = p->mark, _prefix_7_valid = 1, _prefix_7_result))) // term && - (_literal = _PyPegen_expect_token(p, 14)) // token='+' + (_literal = _PyPegen_expect_token(p, 47)) // token='//' && - (b = term_rule(p)) // term + (b = factor_rule(p)) // factor ) { - D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '+' term")); + D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '//' factor")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -14178,7 +14030,7 @@ sum_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_BinOp ( a , Add , b , EXTRA ); + _res = _PyAST_BinOp ( a , FloorDiv , b , EXTRA ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -14187,27 +14039,27 @@ sum_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '+' term")); + D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '//' factor")); } - { // sum '-' term + { // term '%' factor if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '-' term")); + D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '%' factor")); Token * _literal; expr_ty a; expr_ty b; if ( - (a = sum_rule(p)) // sum + (a = ((!p->call_invalid_rules && _prefix_7_valid) ? (p->mark = _prefix_7_end, _prefix_7_result) : (_prefix_7_result = term_rule(p), _prefix_7_end = p->mark, _prefix_7_valid = 1, _prefix_7_result))) // term && - (_literal = _PyPegen_expect_token(p, 15)) // token='-' + (_literal = _PyPegen_expect_token(p, 24)) // token='%' && - (b = term_rule(p)) // term + (b = factor_rule(p)) // factor ) { - D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '-' term")); + D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '%' factor")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -14217,7 +14069,7 @@ sum_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_BinOp ( a , Sub , b , EXTRA ); + _res = _PyAST_BinOp ( a , Mod , b , EXTRA ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -14226,284 +14078,20 @@ sum_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '-' term")); + D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '%' factor")); } - if (p->call_invalid_rules) { // invalid_arithmetic + { // term '@' factor if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_arithmetic")); - void *invalid_arithmetic_var; + D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '@' factor")); + Token * _literal; + expr_ty a; + expr_ty b; if ( - (invalid_arithmetic_var = invalid_arithmetic_rule(p)) // invalid_arithmetic - ) - { - D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_arithmetic")); - _res = invalid_arithmetic_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_arithmetic")); - } - { // term - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term")); - expr_ty term_var; - if ( - (term_var = term_rule(p)) // term - ) - { - D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term")); - _res = term_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// Left-recursive -// term: -// | term '*' factor -// | term '/' factor -// | term '//' factor -// | term '%' factor -// | term '@' factor -// | factor -static expr_ty term_raw(Parser *); -static expr_ty -term_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, term_type, &_res)) { - p->level--; - return _res; - } - int _mark = p->mark; - int _resmark = p->mark; - while (1) { - int tmpvar_7 = _PyPegen_update_memo(p, _mark, term_type, _res); - if (tmpvar_7) { - p->level--; - return _res; - } - p->mark = _mark; - void *_raw = term_raw(p); - if (p->error_indicator) { - p->level--; - return NULL; - } - if (_raw == NULL || p->mark <= _resmark) - break; - _resmark = p->mark; - _res = _raw; - } - p->mark = _resmark; - p->level--; - return _res; -} -static expr_ty -term_raw(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - expr_ty _res = NULL; - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - p->level--; - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // term '*' factor - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '*' factor")); - Token * _literal; - expr_ty a; - expr_ty b; - if ( - (a = term_rule(p)) // term - && - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (b = factor_rule(p)) // factor - ) - { - D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '*' factor")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_BinOp ( a , Mult , b , EXTRA ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '*' factor")); - } - { // term '/' factor - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '/' factor")); - Token * _literal; - expr_ty a; - expr_ty b; - if ( - (a = term_rule(p)) // term - && - (_literal = _PyPegen_expect_token(p, 17)) // token='/' - && - (b = factor_rule(p)) // factor - ) - { - D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '/' factor")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_BinOp ( a , Div , b , EXTRA ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '/' factor")); - } - { // term '//' factor - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '//' factor")); - Token * _literal; - expr_ty a; - expr_ty b; - if ( - (a = term_rule(p)) // term - && - (_literal = _PyPegen_expect_token(p, 47)) // token='//' - && - (b = factor_rule(p)) // factor - ) - { - D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '//' factor")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_BinOp ( a , FloorDiv , b , EXTRA ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '//' factor")); - } - { // term '%' factor - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '%' factor")); - Token * _literal; - expr_ty a; - expr_ty b; - if ( - (a = term_rule(p)) // term - && - (_literal = _PyPegen_expect_token(p, 24)) // token='%' - && - (b = factor_rule(p)) // factor - ) - { - D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '%' factor")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_BinOp ( a , Mod , b , EXTRA ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '%' factor")); - } - { // term '@' factor - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '@' factor")); - Token * _literal; - expr_ty a; - expr_ty b; - if ( - (a = term_rule(p)) // term + (a = ((!p->call_invalid_rules && _prefix_7_valid) ? (p->mark = _prefix_7_end, _prefix_7_result) : (_prefix_7_result = term_rule(p), _prefix_7_end = p->mark, _prefix_7_valid = 1, _prefix_7_result))) // term && (_literal = _PyPegen_expect_token(p, 49)) // token='@' && @@ -14558,10 +14146,10 @@ term_raw(Parser *p) } // factor: '+' factor | '-' factor | '~' factor | power | invalid_factor -static expr_ty +Py_LOCAL_SYMBOL expr_ty factor_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -14740,7 +14328,7 @@ factor_rule(Parser *p) static expr_ty power_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -14749,6 +14337,8 @@ power_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; + expr_ty _prefix_8_result = NULL; + int _prefix_8_end = 0, _prefix_8_valid = 0; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; p->level--; @@ -14768,7 +14358,7 @@ power_rule(Parser *p) expr_ty a; expr_ty b; if ( - (a = await_primary_rule(p)) // await_primary + (a = ((!p->call_invalid_rules && _prefix_8_valid) ? (p->mark = _prefix_8_end, _prefix_8_result) : (_prefix_8_result = await_primary_rule(p), _prefix_8_end = p->mark, _prefix_8_valid = 1, _prefix_8_result))) // await_primary && (_literal = _PyPegen_expect_token(p, 35)) // token='**' && @@ -14805,7 +14395,7 @@ power_rule(Parser *p) D(fprintf(stderr, "%*c> power[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "await_primary")); expr_ty await_primary_var; if ( - (await_primary_var = await_primary_rule(p)) // await_primary + (await_primary_var = ((!p->call_invalid_rules && _prefix_8_valid) ? (p->mark = _prefix_8_end, _prefix_8_result) : (_prefix_8_result = await_primary_rule(p), _prefix_8_end = p->mark, _prefix_8_valid = 1, _prefix_8_result))) // await_primary ) { D(fprintf(stderr, "%*c+ power[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "await_primary")); @@ -14826,7 +14416,7 @@ power_rule(Parser *p) static expr_ty await_primary_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -14857,7 +14447,7 @@ await_primary_rule(Parser *p) Token * _keyword; expr_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 598)) // token='await' + (_keyword = _PyPegen_expect_token(p, 533)) // token='await' && (a = primary_rule(p)) // primary ) @@ -14921,7 +14511,7 @@ static expr_ty primary_raw(Parser *); static expr_ty primary_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } expr_ty _res = NULL; @@ -14931,12 +14521,14 @@ primary_rule(Parser *p) } int _mark = p->mark; int _resmark = p->mark; - while (1) { - int tmpvar_8 = _PyPegen_update_memo(p, _mark, primary_type, _res); - if (tmpvar_8) { - p->level--; - return _res; - } + Memo *_memo = _PyPegen_insert_memo_direct(p, _mark, primary_type); + if (_memo == NULL) { + p->level--; + return NULL; + } + while (1) { + _memo->node = _res; + _memo->mark = p->mark; p->mark = _mark; void *_raw = primary_raw(p); if (p->error_indicator) { @@ -14955,7 +14547,7 @@ primary_rule(Parser *p) static expr_ty primary_raw(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -14964,6 +14556,8 @@ primary_raw(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; + expr_ty _prefix_9_result = NULL; + int _prefix_9_end = 0, _prefix_9_valid = 0; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; p->level--; @@ -14983,7 +14577,7 @@ primary_raw(Parser *p) expr_ty a; expr_ty b; if ( - (a = primary_rule(p)) // primary + (a = ((!p->call_invalid_rules && _prefix_9_valid) ? (p->mark = _prefix_9_end, _prefix_9_result) : (_prefix_9_result = primary_rule(p), _prefix_9_end = p->mark, _prefix_9_valid = 1, _prefix_9_result))) // primary && (_literal = _PyPegen_expect_token(p, 23)) // token='.' && @@ -15021,7 +14615,7 @@ primary_raw(Parser *p) expr_ty a; expr_ty b; if ( - (a = primary_rule(p)) // primary + (a = ((!p->call_invalid_rules && _prefix_9_valid) ? (p->mark = _prefix_9_end, _prefix_9_result) : (_prefix_9_result = primary_rule(p), _prefix_9_end = p->mark, _prefix_9_valid = 1, _prefix_9_result))) // primary && (b = genexp_rule(p)) // genexp ) @@ -15059,7 +14653,7 @@ primary_raw(Parser *p) expr_ty a; void *b; if ( - (a = primary_rule(p)) // primary + (a = ((!p->call_invalid_rules && _prefix_9_valid) ? (p->mark = _prefix_9_end, _prefix_9_result) : (_prefix_9_result = primary_rule(p), _prefix_9_end = p->mark, _prefix_9_valid = 1, _prefix_9_result))) // primary && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && @@ -15101,7 +14695,7 @@ primary_raw(Parser *p) expr_ty a; expr_ty b; if ( - (a = primary_rule(p)) // primary + (a = ((!p->call_invalid_rules && _prefix_9_valid) ? (p->mark = _prefix_9_end, _prefix_9_result) : (_prefix_9_result = primary_rule(p), _prefix_9_end = p->mark, _prefix_9_valid = 1, _prefix_9_result))) // primary && (_literal = _PyPegen_expect_token(p, 9)) // token='[' && @@ -15161,7 +14755,7 @@ primary_raw(Parser *p) static expr_ty slices_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -15215,7 +14809,7 @@ slices_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_66_rule(p)) // ','.(slice | starred_expression)+ + (a = (asdl_expr_seq*)_gather_64_rule(p)) // ','.(slice | starred_expression)+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -15252,7 +14846,7 @@ slices_rule(Parser *p) static expr_ty slice_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -15287,7 +14881,7 @@ slice_rule(Parser *p) && (b = expression_rule(p), !p->error_indicator) // expression? && - (c = _tmp_67_rule(p), !p->error_indicator) // [':' expression?] + (c = _tmp_65_rule(p), !p->error_indicator) // [':' expression?] ) { D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); @@ -15356,7 +14950,7 @@ slice_rule(Parser *p) static expr_ty atom_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -15401,7 +14995,7 @@ atom_rule(Parser *p) D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 627)) // token='True' + (_keyword = _PyPegen_expect_token(p, 527)) // token='True' ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); @@ -15434,7 +15028,7 @@ atom_rule(Parser *p) D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 629)) // token='False' + (_keyword = _PyPegen_expect_token(p, 528)) // token='False' ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); @@ -15467,7 +15061,7 @@ atom_rule(Parser *p) D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 628)) // token='None' + (_keyword = _PyPegen_expect_token(p, 526)) // token='None' ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); @@ -15538,15 +15132,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (genexp | tuple | group)")); - void *_tmp_68_var; + void *_tmp_66_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' && - (_tmp_68_var = _tmp_68_rule(p)) // genexp | tuple | group + (_tmp_66_var = _tmp_66_rule(p)) // genexp | tuple | group ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (genexp | tuple | group)")); - _res = _tmp_68_var; + _res = _tmp_66_var; goto done; } p->mark = _mark; @@ -15559,15 +15153,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (listcomp | list)")); - void *_tmp_69_var; + void *_tmp_67_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' && - (_tmp_69_var = _tmp_69_rule(p)) // listcomp | list + (_tmp_67_var = _tmp_67_rule(p)) // listcomp | list ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (listcomp | list)")); - _res = _tmp_69_var; + _res = _tmp_67_var; goto done; } p->mark = _mark; @@ -15580,15 +15174,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dictcomp | setcomp | dict | set)")); - void *_tmp_70_var; + void *_tmp_68_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' && - (_tmp_70_var = _tmp_70_rule(p)) // dictcomp | setcomp | dict | set + (_tmp_68_var = _tmp_68_rule(p)) // dictcomp | setcomp | dict | set ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dictcomp | setcomp | dict | set)")); - _res = _tmp_70_var; + _res = _tmp_68_var; goto done; } p->mark = _mark; @@ -15638,7 +15232,7 @@ atom_rule(Parser *p) static expr_ty group_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -15659,7 +15253,7 @@ group_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_71_rule(p)) // yield_expr | named_expression + (a = _tmp_69_rule(p)) // yield_expr | named_expression && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -15703,10 +15297,10 @@ group_rule(Parser *p) } // lambdef: 'lambda' lambda_params? ':' expression -static expr_ty +Py_LOCAL_SYMBOL expr_ty lambdef_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -15735,7 +15329,7 @@ lambdef_rule(Parser *p) void *a; expr_ty b; if ( - (_keyword = _PyPegen_expect_token(p, 622)) // token='lambda' + (_keyword = _PyPegen_expect_token(p, 534)) // token='lambda' && (a = lambda_params_rule(p), !p->error_indicator) // lambda_params? && @@ -15773,10 +15367,10 @@ lambdef_rule(Parser *p) } // lambda_params: invalid_lambda_parameters | lambda_parameters -static arguments_ty +Py_LOCAL_SYMBOL arguments_ty lambda_params_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -15838,7 +15432,7 @@ lambda_params_rule(Parser *p) static arguments_ty lambda_parameters_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -15860,9 +15454,9 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default && - (b = (asdl_arg_seq*)_loop0_72_rule(p)) // lambda_param_no_default* + (b = (asdl_arg_seq*)_loop0_70_rule(p)) // lambda_param_no_default* && - (c = _loop0_73_rule(p)) // lambda_param_with_default* + (c = _loop0_71_rule(p)) // lambda_param_with_default* && (d = lambda_star_etc_rule(p), !p->error_indicator) // lambda_star_etc? ) @@ -15892,7 +15486,7 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default && - (b = _loop0_73_rule(p)) // lambda_param_with_default* + (b = _loop0_71_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), !p->error_indicator) // lambda_star_etc? ) @@ -15920,9 +15514,9 @@ lambda_parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = (asdl_arg_seq*)_loop1_74_rule(p)) // lambda_param_no_default+ + (a = (asdl_arg_seq*)_loop1_72_rule(p)) // lambda_param_no_default+ && - (b = _loop0_73_rule(p)) // lambda_param_with_default* + (b = _loop0_71_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), !p->error_indicator) // lambda_star_etc? ) @@ -15949,7 +15543,7 @@ lambda_parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_75_rule(p)) // lambda_param_with_default+ + (a = _loop1_73_rule(p)) // lambda_param_with_default+ && (b = lambda_star_etc_rule(p), !p->error_indicator) // lambda_star_etc? ) @@ -16000,10 +15594,10 @@ lambda_parameters_rule(Parser *p) // lambda_slash_no_default: // | lambda_param_no_default+ '/' ',' // | lambda_param_no_default+ '/' &':' -static asdl_arg_seq* +Py_LOCAL_SYMBOL asdl_arg_seq* lambda_slash_no_default_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -16022,7 +15616,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal_1; asdl_arg_seq* a; if ( - (a = (asdl_arg_seq*)_loop1_74_rule(p)) // lambda_param_no_default+ + (a = (asdl_arg_seq*)_loop1_72_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -16051,7 +15645,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal; asdl_arg_seq* a; if ( - (a = (asdl_arg_seq*)_loop1_74_rule(p)) // lambda_param_no_default+ + (a = (asdl_arg_seq*)_loop1_72_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -16080,10 +15674,10 @@ lambda_slash_no_default_rule(Parser *p) // lambda_slash_with_default: // | lambda_param_no_default* lambda_param_with_default+ '/' ',' // | lambda_param_no_default* lambda_param_with_default+ '/' &':' -static SlashWithDefault* +Py_LOCAL_SYMBOL SlashWithDefault* lambda_slash_with_default_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -16103,9 +15697,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_72_rule(p)) // lambda_param_no_default* + (a = _loop0_70_rule(p)) // lambda_param_no_default* && - (b = _loop1_75_rule(p)) // lambda_param_with_default+ + (b = _loop1_73_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -16135,9 +15729,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_72_rule(p)) // lambda_param_no_default* + (a = _loop0_70_rule(p)) // lambda_param_no_default* && - (b = _loop1_75_rule(p)) // lambda_param_with_default+ + (b = _loop1_73_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -16171,7 +15765,7 @@ lambda_slash_with_default_rule(Parser *p) static StarEtc* lambda_star_etc_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -16214,7 +15808,7 @@ lambda_star_etc_rule(Parser *p) && (a = lambda_param_no_default_rule(p)) // lambda_param_no_default && - (b = _loop0_76_rule(p)) // lambda_param_maybe_default* + (b = _loop0_74_rule(p)) // lambda_param_maybe_default* && (c = lambda_kwds_rule(p), !p->error_indicator) // lambda_kwds? ) @@ -16247,7 +15841,7 @@ lambda_star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_77_rule(p)) // lambda_param_maybe_default+ + (b = _loop1_75_rule(p)) // lambda_param_maybe_default+ && (c = lambda_kwds_rule(p), !p->error_indicator) // lambda_kwds? ) @@ -16299,7 +15893,7 @@ lambda_star_etc_rule(Parser *p) static arg_ty lambda_kwds_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -16361,10 +15955,10 @@ lambda_kwds_rule(Parser *p) } // lambda_param_no_default: lambda_param ',' | lambda_param &':' -static arg_ty +Py_LOCAL_SYMBOL arg_ty lambda_param_no_default_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -16433,10 +16027,10 @@ lambda_param_no_default_rule(Parser *p) } // lambda_param_with_default: lambda_param default ',' | lambda_param default &':' -static NameDefaultPair* +Py_LOCAL_SYMBOL NameDefaultPair* lambda_param_with_default_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -16511,10 +16105,10 @@ lambda_param_with_default_rule(Parser *p) } // lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':' -static NameDefaultPair* +Py_LOCAL_SYMBOL NameDefaultPair* lambda_param_maybe_default_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -16589,10 +16183,10 @@ lambda_param_maybe_default_rule(Parser *p) } // lambda_param: NAME -static arg_ty +Py_LOCAL_SYMBOL arg_ty lambda_param_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -16653,7 +16247,7 @@ lambda_param_rule(Parser *p) static expr_ty fstring_middle_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -16717,7 +16311,7 @@ fstring_middle_rule(Parser *p) static expr_ty fstring_replacement_field_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -16812,7 +16406,7 @@ fstring_replacement_field_rule(Parser *p) static ResultTokenWithMetadata* fstring_conversion_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -16858,7 +16452,7 @@ fstring_conversion_rule(Parser *p) static ResultTokenWithMetadata* fstring_full_format_spec_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -16887,7 +16481,7 @@ fstring_full_format_spec_rule(Parser *p) if ( (colon = _PyPegen_expect_token(p, 11)) // token=':' && - (spec = _loop0_78_rule(p)) // fstring_format_spec* + (spec = _loop0_76_rule(p)) // fstring_format_spec* ) { D(fprintf(stderr, "%*c+ fstring_full_format_spec[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' fstring_format_spec*")); @@ -16919,10 +16513,10 @@ fstring_full_format_spec_rule(Parser *p) } // fstring_format_spec: FSTRING_MIDDLE | fstring_replacement_field -static expr_ty +Py_LOCAL_SYMBOL expr_ty fstring_format_spec_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -16981,10 +16575,10 @@ fstring_format_spec_rule(Parser *p) } // fstring: FSTRING_START fstring_middle* FSTRING_END -static expr_ty +Py_LOCAL_SYMBOL expr_ty fstring_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -17005,7 +16599,7 @@ fstring_rule(Parser *p) if ( (a = _PyPegen_expect_token(p, FSTRING_START)) // token='FSTRING_START' && - (b = _loop0_79_rule(p)) // fstring_middle* + (b = _loop0_77_rule(p)) // fstring_middle* && (c = _PyPegen_expect_token(p, FSTRING_END)) // token='FSTRING_END' ) @@ -17035,7 +16629,7 @@ fstring_rule(Parser *p) static expr_ty tstring_format_spec_replacement_field_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -17130,7 +16724,7 @@ tstring_format_spec_replacement_field_rule(Parser *p) static expr_ty tstring_format_spec_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -17192,7 +16786,7 @@ tstring_format_spec_rule(Parser *p) static ResultTokenWithMetadata* tstring_full_format_spec_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -17221,7 +16815,7 @@ tstring_full_format_spec_rule(Parser *p) if ( (colon = _PyPegen_expect_token(p, 11)) // token=':' && - (spec = _loop0_80_rule(p)) // tstring_format_spec* + (spec = _loop0_78_rule(p)) // tstring_format_spec* ) { D(fprintf(stderr, "%*c+ tstring_full_format_spec[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' tstring_format_spec*")); @@ -17258,7 +16852,7 @@ tstring_full_format_spec_rule(Parser *p) static expr_ty tstring_replacement_field_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -17353,7 +16947,7 @@ tstring_replacement_field_rule(Parser *p) static expr_ty tstring_middle_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -17412,10 +17006,10 @@ tstring_middle_rule(Parser *p) } // tstring: TSTRING_START tstring_middle* TSTRING_END -static expr_ty +Py_LOCAL_SYMBOL expr_ty tstring_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -17440,7 +17034,7 @@ tstring_rule(Parser *p) if ( (a = _PyPegen_expect_token(p, TSTRING_START)) // token='TSTRING_START' && - (b = _loop0_81_rule(p)) // tstring_middle* + (b = _loop0_79_rule(p)) // tstring_middle* && (c = _PyPegen_expect_token(p, TSTRING_END)) // token='TSTRING_END' ) @@ -17466,10 +17060,10 @@ tstring_rule(Parser *p) } // string: STRING -static expr_ty +Py_LOCAL_SYMBOL expr_ty string_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -17512,7 +17106,7 @@ string_rule(Parser *p) static expr_ty strings_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -17561,7 +17155,7 @@ strings_rule(Parser *p) D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((fstring | string))+")); asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_loop1_82_rule(p)) // ((fstring | string))+ + (a = (asdl_expr_seq*)_loop1_80_rule(p)) // ((fstring | string))+ ) { D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((fstring | string))+")); @@ -17594,7 +17188,7 @@ strings_rule(Parser *p) D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tstring+")); asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_loop1_83_rule(p)) // tstring+ + (a = (asdl_expr_seq*)_loop1_81_rule(p)) // tstring+ ) { D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tstring+")); @@ -17626,11 +17220,115 @@ strings_rule(Parser *p) return _res; } -// list: '[' star_named_expressions_sequence? ']' +// display_items: ','.display_item+ ','? +static asdl_expr_seq* +display_items_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + asdl_expr_seq* _res = NULL; + int _mark = p->mark; + { // ','.display_item+ ','? + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> display_items[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.display_item+ ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_expr_seq* a; + if ( + (a = (asdl_expr_seq*)_gather_83_rule(p)) // ','.display_item+ + && + (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? + ) + { + D(fprintf(stderr, "%*c+ display_items[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.display_item+ ','?")); + _res = a; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s display_items[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.display_item+ ','?")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// display_item: invalid_starred_expression_unpacking_sequence | star_named_expression static expr_ty +display_item_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + if (p->call_invalid_rules) { // invalid_starred_expression_unpacking_sequence + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> display_item[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_starred_expression_unpacking_sequence")); + void *invalid_starred_expression_unpacking_sequence_var; + if ( + (invalid_starred_expression_unpacking_sequence_var = invalid_starred_expression_unpacking_sequence_rule(p)) // invalid_starred_expression_unpacking_sequence + ) + { + D(fprintf(stderr, "%*c+ display_item[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_starred_expression_unpacking_sequence")); + _res = invalid_starred_expression_unpacking_sequence_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s display_item[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_starred_expression_unpacking_sequence")); + } + { // star_named_expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> display_item[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression")); + expr_ty star_named_expression_var; + if ( + (star_named_expression_var = star_named_expression_rule(p)) // star_named_expression + ) + { + D(fprintf(stderr, "%*c+ display_item[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression")); + _res = star_named_expression_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s display_item[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// list: '[' display_items? ']' +Py_LOCAL_SYMBOL expr_ty list_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -17648,24 +17346,24 @@ list_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '[' star_named_expressions_sequence? ']' + { // '[' display_items? ']' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> list[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' star_named_expressions_sequence? ']'")); + D(fprintf(stderr, "%*c> list[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' display_items? ']'")); Token * _literal; Token * _literal_1; void *a; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' && - (a = star_named_expressions_sequence_rule(p), !p->error_indicator) // star_named_expressions_sequence? + (a = display_items_rule(p), !p->error_indicator) // display_items? && (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' ) { - D(fprintf(stderr, "%*c+ list[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' star_named_expressions_sequence? ']'")); + D(fprintf(stderr, "%*c+ list[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' display_items? ']'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -17685,7 +17383,7 @@ list_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s list[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' star_named_expressions_sequence? ']'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' display_items? ']'")); } _res = NULL; done: @@ -17693,11 +17391,11 @@ list_rule(Parser *p) return _res; } -// tuple: '(' [star_named_expression_sequence ',' star_named_expressions_sequence?] ')' -static expr_ty +// tuple: '(' [display_item ',' display_items?] ')' +Py_LOCAL_SYMBOL expr_ty tuple_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -17715,24 +17413,24 @@ tuple_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '(' [star_named_expression_sequence ',' star_named_expressions_sequence?] ')' + { // '(' [display_item ',' display_items?] ')' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> tuple[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' [star_named_expression_sequence ',' star_named_expressions_sequence?] ')'")); + D(fprintf(stderr, "%*c> tuple[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' [display_item ',' display_items?] ')'")); Token * _literal; Token * _literal_1; void *a; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_84_rule(p), !p->error_indicator) // [star_named_expression_sequence ',' star_named_expressions_sequence?] + (a = _tmp_84_rule(p), !p->error_indicator) // [display_item ',' display_items?] && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ tuple[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' [star_named_expression_sequence ',' star_named_expressions_sequence?] ')'")); + D(fprintf(stderr, "%*c+ tuple[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' [display_item ',' display_items?] ')'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -17752,7 +17450,7 @@ tuple_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s tuple[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' [star_named_expression_sequence ',' star_named_expressions_sequence?] ')'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' [display_item ',' display_items?] ')'")); } _res = NULL; done: @@ -17760,11 +17458,11 @@ tuple_rule(Parser *p) return _res; } -// set: '{' star_named_expressions_sequence '}' +// set: '{' display_items '}' static expr_ty set_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -17782,24 +17480,24 @@ set_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '{' star_named_expressions_sequence '}' + { // '{' display_items '}' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> set[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' star_named_expressions_sequence '}'")); + D(fprintf(stderr, "%*c> set[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' display_items '}'")); Token * _literal; Token * _literal_1; asdl_expr_seq* a; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - (a = star_named_expressions_sequence_rule(p)) // star_named_expressions_sequence + (a = display_items_rule(p)) // display_items && (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' ) { - D(fprintf(stderr, "%*c+ set[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' star_named_expressions_sequence '}'")); + D(fprintf(stderr, "%*c+ set[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' display_items '}'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -17819,7 +17517,7 @@ set_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s set[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' star_named_expressions_sequence '}'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' display_items '}'")); } _res = NULL; done: @@ -17831,7 +17529,7 @@ set_rule(Parser *p) static expr_ty dict_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -17923,7 +17621,7 @@ dict_rule(Parser *p) static asdl_seq* double_starred_kvpairs_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -17967,10 +17665,10 @@ double_starred_kvpairs_rule(Parser *p) } // double_starred_kvpair: '**' bitwise_or | kvpair -static KeyValuePair* +Py_LOCAL_SYMBOL KeyValuePair* double_starred_kvpair_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -18035,7 +17733,7 @@ double_starred_kvpair_rule(Parser *p) static KeyValuePair* kvpair_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -18081,10 +17779,10 @@ kvpair_rule(Parser *p) } // for_if_clauses: for_if_clause+ -static asdl_comprehension_seq* +Py_LOCAL_SYMBOL asdl_comprehension_seq* for_if_clauses_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -18131,7 +17829,7 @@ for_if_clauses_rule(Parser *p) static comprehension_ty for_if_clause_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -18154,13 +17852,13 @@ for_if_clause_rule(Parser *p) expr_ty b; asdl_expr_seq* c; if ( - (_keyword = _PyPegen_expect_token(p, 716)) // token='async' + (_keyword = _PyPegen_expect_token(p, 513)) // token='async' && - (_keyword_1 = _PyPegen_expect_token(p, 712)) // token='for' + (_keyword_1 = _PyPegen_expect_token(p, 517)) // token='for' && (a = star_targets_rule(p)) // star_targets && - (_keyword_2 = _PyPegen_expect_token(p, 713)) // token='in' + (_keyword_2 = _PyPegen_expect_token(p, 523)) // token='in' && (_cut_var = 1) && @@ -18199,11 +17897,11 @@ for_if_clause_rule(Parser *p) expr_ty b; asdl_expr_seq* c; if ( - (_keyword = _PyPegen_expect_token(p, 712)) // token='for' + (_keyword = _PyPegen_expect_token(p, 517)) // token='for' && (a = star_targets_rule(p)) // star_targets && - (_keyword_1 = _PyPegen_expect_token(p, 713)) // token='in' + (_keyword_1 = _PyPegen_expect_token(p, 523)) // token='in' && (_cut_var = 1) && @@ -18277,7 +17975,7 @@ for_if_clause_rule(Parser *p) static expr_ty listcomp_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -18366,7 +18064,7 @@ listcomp_rule(Parser *p) static expr_ty setcomp_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -18454,10 +18152,10 @@ setcomp_rule(Parser *p) // genexp: // | '(' (assignment_expression | expression !':=' | starred_expression) for_if_clauses ')' // | invalid_comprehension -static expr_ty +Py_LOCAL_SYMBOL expr_ty genexp_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -18546,7 +18244,7 @@ genexp_rule(Parser *p) static expr_ty dictcomp_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -18658,10 +18356,10 @@ dictcomp_rule(Parser *p) } // arguments: args ','? &')' | invalid_arguments -static expr_ty +Py_LOCAL_SYMBOL expr_ty arguments_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -18733,10 +18431,10 @@ arguments_rule(Parser *p) // args: // | ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ [',' kwargs] // | kwargs -static expr_ty +Py_LOCAL_SYMBOL expr_ty args_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -18830,13 +18528,12 @@ args_rule(Parser *p) } // kwargs: -// | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ -// | ','.kwarg_or_starred+ +// | ','.kwarg_or_starred+ [',' ','.kwarg_or_double_starred+] // | ','.kwarg_or_double_starred+ -static asdl_seq* +Py_LOCAL_SYMBOL asdl_seq* kwargs_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -18845,25 +18542,22 @@ kwargs_rule(Parser *p) } asdl_seq* _res = NULL; int _mark = p->mark; - { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ + { // ','.kwarg_or_starred+ [',' ','.kwarg_or_double_starred+] if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); - Token * _literal; + D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ [',' ','.kwarg_or_double_starred+]")); asdl_seq * a; - asdl_seq * b; + void *b; if ( (a = _gather_94_rule(p)) // ','.kwarg_or_starred+ && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (b = _gather_96_rule(p)) // ','.kwarg_or_double_starred+ + (b = _tmp_95_rule(p), !p->error_indicator) // [',' ','.kwarg_or_double_starred+] ) { - D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); - _res = _PyPegen_join_sequences ( p , a , b ); + D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ [',' ','.kwarg_or_double_starred+]")); + _res = b ? _PyPegen_join_sequences ( p , a , b ) : a; if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -18873,26 +18567,7 @@ kwargs_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); - } - { // ','.kwarg_or_starred+ - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - asdl_seq * _gather_94_var; - if ( - (_gather_94_var = _gather_94_rule(p)) // ','.kwarg_or_starred+ - ) - { - D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - _res = _gather_94_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_starred+")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_starred+ [',' ','.kwarg_or_double_starred+]")); } { // ','.kwarg_or_double_starred+ if (p->error_indicator) { @@ -18900,13 +18575,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - asdl_seq * _gather_96_var; + asdl_seq * _gather_97_var; if ( - (_gather_96_var = _gather_96_rule(p)) // ','.kwarg_or_double_starred+ + (_gather_97_var = _gather_97_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - _res = _gather_96_var; + _res = _gather_97_var; goto done; } p->mark = _mark; @@ -18923,10 +18598,10 @@ kwargs_rule(Parser *p) // | invalid_starred_expression_unpacking // | '*' expression // | invalid_starred_expression -static expr_ty +Py_LOCAL_SYMBOL expr_ty starred_expression_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -19028,7 +18703,7 @@ starred_expression_rule(Parser *p) static KeywordOrStarred* kwarg_or_starred_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -19138,7 +18813,7 @@ kwarg_or_starred_rule(Parser *p) static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -19257,10 +18932,10 @@ kwarg_or_double_starred_rule(Parser *p) } // star_targets: star_target !',' | star_target ((',' star_target))* ','? -static expr_ty +Py_LOCAL_SYMBOL expr_ty star_targets_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -19269,6 +18944,8 @@ star_targets_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; + expr_ty _prefix_10_result = NULL; + int _prefix_10_end = 0, _prefix_10_valid = 0; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; p->level--; @@ -19286,7 +18963,7 @@ star_targets_rule(Parser *p) D(fprintf(stderr, "%*c> star_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target !','")); expr_ty a; if ( - (a = star_target_rule(p)) // star_target + (a = ((!p->call_invalid_rules && _prefix_10_valid) ? (p->mark = _prefix_10_end, _prefix_10_result) : (_prefix_10_result = star_target_rule(p), _prefix_10_end = p->mark, _prefix_10_valid = 1, _prefix_10_result))) // star_target && _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' ) @@ -19315,9 +18992,9 @@ star_targets_rule(Parser *p) expr_ty a; asdl_seq * b; if ( - (a = star_target_rule(p)) // star_target + (a = ((!p->call_invalid_rules && _prefix_10_valid) ? (p->mark = _prefix_10_end, _prefix_10_result) : (_prefix_10_result = star_target_rule(p), _prefix_10_end = p->mark, _prefix_10_valid = 1, _prefix_10_result))) // star_target && - (b = _loop0_97_rule(p)) // ((',' star_target))* + (b = _loop0_98_rule(p)) // ((',' star_target))* && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -19350,135 +19027,11 @@ star_targets_rule(Parser *p) return _res; } -// star_targets_list_seq: ','.star_target+ ','? -static asdl_expr_seq* -star_targets_list_seq_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_expr_seq* _res = NULL; - int _mark = p->mark; - { // ','.star_target+ ','? - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> star_targets_list_seq[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_target+ ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - asdl_expr_seq* a; - if ( - (a = (asdl_expr_seq*)_gather_99_rule(p)) // ','.star_target+ - && - (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? - ) - { - D(fprintf(stderr, "%*c+ star_targets_list_seq[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_target+ ','?")); - _res = a; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s star_targets_list_seq[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_target+ ','?")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// star_targets_tuple_seq: star_target ((',' star_target))+ ','? | star_target ',' -static asdl_expr_seq* -star_targets_tuple_seq_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_expr_seq* _res = NULL; - int _mark = p->mark; - { // star_target ((',' star_target))+ ','? - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> star_targets_tuple_seq[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))+ ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty a; - asdl_seq * b; - if ( - (a = star_target_rule(p)) // star_target - && - (b = _loop1_100_rule(p)) // ((',' star_target))+ - && - (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? - ) - { - D(fprintf(stderr, "%*c+ star_targets_tuple_seq[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))+ ','?")); - _res = ( asdl_expr_seq* ) _PyPegen_seq_insert_in_front ( p , a , b ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s star_targets_tuple_seq[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target ((',' star_target))+ ','?")); - } - { // star_target ',' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> star_targets_tuple_seq[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target ','")); - Token * _literal; - expr_ty a; - if ( - (a = star_target_rule(p)) // star_target - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ star_targets_tuple_seq[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target ','")); - _res = ( asdl_expr_seq* ) _PyPegen_singleton_seq ( p , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s star_targets_tuple_seq[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target ','")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// star_target: '*' (!'*' star_target) | target_with_star_atom -static expr_ty +// star_target: '*' (!'*' star_target) | target +Py_LOCAL_SYMBOL expr_ty star_target_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -19511,7 +19064,7 @@ star_target_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (a = _tmp_101_rule(p)) // !'*' star_target + (a = _tmp_99_rule(p)) // !'*' star_target ) { D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); @@ -19524,7 +19077,7 @@ star_target_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_Starred ( CHECK ( expr_ty , _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA ); + _res = _PyAST_Starred ( a , Store , EXTRA ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -19536,24 +19089,24 @@ star_target_rule(Parser *p) D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (!'*' star_target)")); } - { // target_with_star_atom + { // target if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target_with_star_atom")); - expr_ty target_with_star_atom_var; + D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target")); + expr_ty target_var; if ( - (target_with_star_atom_var = target_with_star_atom_rule(p)) // target_with_star_atom + (target_var = target_rule(p)) // target ) { - D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target_with_star_atom")); - _res = target_with_star_atom_var; + D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target")); + _res = target_var; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target_with_star_atom")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target")); } _res = NULL; done: @@ -19562,14 +19115,11 @@ star_target_rule(Parser *p) return _res; } -// target_with_star_atom: -// | t_primary '.' NAME !t_lookahead -// | t_primary '[' slices ']' !t_lookahead -// | star_atom +// target: target_value static expr_ty -target_with_star_atom_rule(Parser *p) +target_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -19577,50 +19127,24 @@ target_with_star_atom_rule(Parser *p) return NULL; } expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, target_with_star_atom_type, &_res)) { + if (_PyPegen_is_memoized(p, target_type, &_res)) { p->level--; return _res; } int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - p->level--; - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // t_primary '.' NAME !t_lookahead + { // target_value if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> target_with_star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); - Token * _literal; + D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target_value")); expr_ty a; - expr_ty b; if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 23)) // token='.' - && - (b = _PyPegen_name_token(p)) // NAME - && - _PyPegen_lookahead(0, t_lookahead_rule, p) + (a = target_value_rule(p)) // target_value ) { - D(fprintf(stderr, "%*c+ target_with_star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_Attribute ( a , b -> v . Name . id , Store , EXTRA ); + D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target_value")); + _res = _PyPegen_make_target ( p , a , STAR_TARGETS ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -19629,42 +19153,42 @@ target_with_star_atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s target_with_star_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); + D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target_value")); } - { // t_primary '[' slices ']' !t_lookahead + _res = NULL; + done: + _PyPegen_insert_memo(p, _mark, target_type, _res); + p->level--; + return _res; +} + +// single_target: target_value +static expr_ty +single_target_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + { // target_value if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> target_with_star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); - Token * _literal; - Token * _literal_1; + D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target_value")); expr_ty a; - expr_ty b; if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - && - (b = slices_rule(p)) // slices - && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' - && - _PyPegen_lookahead(0, t_lookahead_rule, p) + (a = target_value_rule(p)) // target_value ) { - D(fprintf(stderr, "%*c+ target_with_star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_Subscript ( a , b , Store , EXTRA ); + D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target_value")); + _res = _PyPegen_make_target ( p , a , SINGLE_TARGETS ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -19673,44 +19197,20 @@ target_with_star_atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s target_with_star_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); - } - { // star_atom - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> target_with_star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_atom")); - expr_ty star_atom_var; - if ( - (star_atom_var = star_atom_rule(p)) // star_atom - ) - { - D(fprintf(stderr, "%*c+ target_with_star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_atom")); - _res = star_atom_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s target_with_star_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_atom")); + D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target_value")); } _res = NULL; done: - _PyPegen_insert_memo(p, _mark, target_with_star_atom_type, _res); p->level--; return _res; } -// star_atom: -// | NAME -// | '(' target_with_star_atom ')' -// | '(' star_targets_tuple_seq? ')' -// | '[' star_targets_list_seq? ']' +// attribute_or_subscript_target: target_value static expr_ty -star_atom_rule(Parser *p) +attribute_or_subscript_target_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -19719,28 +19219,19 @@ star_atom_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - p->level--; - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NAME + { // target_value if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); + D(fprintf(stderr, "%*c> attribute_or_subscript_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target_value")); expr_ty a; if ( - (a = _PyPegen_name_token(p)) // NAME + (a = target_value_rule(p)) // target_value ) { - D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); - _res = _PyPegen_set_expr_context ( p , a , Store ); + D(fprintf(stderr, "%*c+ attribute_or_subscript_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target_value")); + _res = _PyPegen_make_target ( p , a , ATTRIBUTE_OR_SUBSCRIPT_TARGETS ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -19749,28 +19240,43 @@ star_atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); + D(fprintf(stderr, "%*c%s attribute_or_subscript_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target_value")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// target_value: primary !('(' | '[' | '.') +static expr_ty +target_value_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; } - { // '(' target_with_star_atom ')' + expr_ty _res = NULL; + int _mark = p->mark; + { // primary !('(' | '[' | '.') if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' target_with_star_atom ')'")); - Token * _literal; - Token * _literal_1; + D(fprintf(stderr, "%*c> target_value[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary !('(' | '[' | '.')")); expr_ty a; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (a = target_with_star_atom_rule(p)) // target_with_star_atom + (a = primary_rule(p)) // primary && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + _PyPegen_lookahead(0, _tmp_100_rule, p) ) { - D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' target_with_star_atom ')'")); - _res = _PyPegen_set_expr_context ( p , a , Store ); + D(fprintf(stderr, "%*c+ target_value[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary !('(' | '[' | '.')")); + _res = a; if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -19779,37 +19285,45 @@ star_atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' target_with_star_atom ')'")); + D(fprintf(stderr, "%*c%s target_value[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary !('(' | '[' | '.')")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// del_targets: ','.del_target+ ','? +static asdl_expr_seq* +del_targets_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); } - { // '(' star_targets_tuple_seq? ')' + if (p->error_indicator) { + p->level--; + return NULL; + } + asdl_expr_seq* _res = NULL; + int _mark = p->mark; + { // ','.del_target+ ','? if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' star_targets_tuple_seq? ')'")); - Token * _literal; - Token * _literal_1; - void *a; + D(fprintf(stderr, "%*c> del_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_expr_seq* a; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (a = star_targets_tuple_seq_rule(p), !p->error_indicator) // star_targets_tuple_seq? + (a = (asdl_expr_seq*)_gather_102_rule(p)) // ','.del_target+ && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) { - D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' star_targets_tuple_seq? ')'")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_Tuple ( a , Store , EXTRA ); + D(fprintf(stderr, "%*c+ del_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?")); + _res = a; if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -19818,37 +19332,45 @@ star_atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' star_targets_tuple_seq? ')'")); + D(fprintf(stderr, "%*c%s del_targets[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.del_target+ ','?")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// del_target: target_value +static expr_ty +del_target_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, del_target_type, &_res)) { + p->level--; + return _res; } - { // '[' star_targets_list_seq? ']' + int _mark = p->mark; + { // target_value if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' star_targets_list_seq? ']'")); - Token * _literal; - Token * _literal_1; - void *a; + D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target_value")); + expr_ty a; if ( - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - && - (a = star_targets_list_seq_rule(p), !p->error_indicator) // star_targets_list_seq? - && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + (a = target_value_rule(p)) // target_value ) { - D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' star_targets_list_seq? ']'")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_List ( a , Store , EXTRA ); + D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target_value")); + _res = _PyPegen_make_target ( p , a , DEL_TARGETS ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -19857,60 +19379,100 @@ star_atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' star_targets_list_seq? ']'")); + D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target_value")); } _res = NULL; done: + _PyPegen_insert_memo(p, _mark, del_target_type, _res); p->level--; return _res; } -// single_target: single_subscript_attribute_target | NAME | '(' single_target ')' -static expr_ty -single_target_rule(Parser *p) +// type_expressions: +// | ','.expression+ ',' '*' expression ',' '**' expression +// | ','.expression+ ',' '*' expression +// | ','.expression+ ',' '**' expression +// | '*' expression ',' '**' expression +// | '*' expression +// | '**' expression +// | ','.expression+ +static asdl_expr_seq* +type_expressions_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - expr_ty _res = NULL; + asdl_expr_seq* _res = NULL; int _mark = p->mark; - { // single_subscript_attribute_target + { // ','.expression+ ',' '*' expression ',' '**' expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); - expr_ty single_subscript_attribute_target_var; + D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression")); + Token * _literal; + Token * _literal_1; + Token * _literal_2; + Token * _literal_3; + asdl_seq * a; + expr_ty b; + expr_ty c; if ( - (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target + (a = _gather_104_rule(p)) // ','.expression+ + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' + && + (b = expression_rule(p)) // expression + && + (_literal_2 = _PyPegen_expect_token(p, 12)) // token=',' + && + (_literal_3 = _PyPegen_expect_token(p, 35)) // token='**' + && + (c = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); - _res = single_subscript_attribute_target_var; + D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression")); + _res = ( asdl_expr_seq* ) _PyPegen_seq_append_to_end ( p , CHECK ( asdl_seq* , _PyPegen_seq_append_to_end ( p , a , b ) ) , c ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_subscript_attribute_target")); + D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression")); } - { // NAME + { // ','.expression+ ',' '*' expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); - expr_ty a; + D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression")); + Token * _literal; + Token * _literal_1; + asdl_seq * a; + expr_ty b; if ( - (a = _PyPegen_name_token(p)) // NAME + (a = _gather_104_rule(p)) // ','.expression+ + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' + && + (b = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); - _res = _PyPegen_set_expr_context ( p , a , Store ); + D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression")); + _res = ( asdl_expr_seq* ) _PyPegen_seq_append_to_end ( p , a , b ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -19919,28 +19481,31 @@ single_target_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); + D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '*' expression")); } - { // '(' single_target ')' + { // ','.expression+ ',' '**' expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); + D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '**' expression")); Token * _literal; Token * _literal_1; - expr_ty a; + asdl_seq * a; + expr_ty b; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' + (a = _gather_104_rule(p)) // ','.expression+ && - (a = single_target_rule(p)) // single_target + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (_literal_1 = _PyPegen_expect_token(p, 35)) // token='**' + && + (b = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); - _res = a; + D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '**' expression")); + _res = ( asdl_expr_seq* ) _PyPegen_seq_append_to_end ( p , a , b ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -19949,69 +19514,34 @@ single_target_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' single_target ')'")); + D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '**' expression")); } - _res = NULL; - done: - p->level--; - return _res; -} - -// single_subscript_attribute_target: -// | t_primary '.' NAME !t_lookahead -// | t_primary '[' slices ']' !t_lookahead -static expr_ty -single_subscript_attribute_target_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - expr_ty _res = NULL; - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - p->level--; - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // t_primary '.' NAME !t_lookahead + { // '*' expression ',' '**' expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> single_subscript_attribute_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); + D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression ',' '**' expression")); Token * _literal; + Token * _literal_1; + Token * _literal_2; expr_ty a; expr_ty b; if ( - (a = t_primary_rule(p)) // t_primary + (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_literal = _PyPegen_expect_token(p, 23)) // token='.' + (a = expression_rule(p)) // expression && - (b = _PyPegen_name_token(p)) // NAME + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + && + (_literal_2 = _PyPegen_expect_token(p, 35)) // token='**' && - _PyPegen_lookahead(0, t_lookahead_rule, p) + (b = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ single_subscript_attribute_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_Attribute ( a , b -> v . Name . id , Store , EXTRA ); + D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression ',' '**' expression")); + _res = ( asdl_expr_seq* ) _PyPegen_seq_append_to_end ( p , CHECK ( asdl_seq* , _PyPegen_singleton_seq ( p , a ) ) , b ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -20020,42 +19550,25 @@ single_subscript_attribute_target_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s single_subscript_attribute_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); + D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression ',' '**' expression")); } - { // t_primary '[' slices ']' !t_lookahead + { // '*' expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> single_subscript_attribute_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression")); Token * _literal; - Token * _literal_1; expr_ty a; - expr_ty b; if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - && - (b = slices_rule(p)) // slices - && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - _PyPegen_lookahead(0, t_lookahead_rule, p) + (a = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ single_subscript_attribute_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_Subscript ( a , b , Store , EXTRA ); + D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression")); + _res = ( asdl_expr_seq* ) _PyPegen_singleton_seq ( p , a ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -20064,108 +19577,25 @@ single_subscript_attribute_target_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s single_subscript_attribute_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// Left-recursive -// t_primary: -// | t_primary '.' NAME &t_lookahead -// | t_primary '[' slices ']' &t_lookahead -// | t_primary genexp &t_lookahead -// | t_primary '(' arguments? ')' &t_lookahead -// | atom &t_lookahead -static expr_ty t_primary_raw(Parser *); -static expr_ty -t_primary_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, t_primary_type, &_res)) { - p->level--; - return _res; - } - int _mark = p->mark; - int _resmark = p->mark; - while (1) { - int tmpvar_9 = _PyPegen_update_memo(p, _mark, t_primary_type, _res); - if (tmpvar_9) { - p->level--; - return _res; - } - p->mark = _mark; - void *_raw = t_primary_raw(p); - if (p->error_indicator) { - p->level--; - return NULL; - } - if (_raw == NULL || p->mark <= _resmark) - break; - _resmark = p->mark; - _res = _raw; - } - p->mark = _resmark; - p->level--; - return _res; -} -static expr_ty -t_primary_raw(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - expr_ty _res = NULL; - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - p->level--; - return NULL; + D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression")); } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // t_primary '.' NAME &t_lookahead + { // '**' expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &t_lookahead")); + D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' expression")); Token * _literal; expr_ty a; - expr_ty b; if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 23)) // token='.' - && - (b = _PyPegen_name_token(p)) // NAME + (_literal = _PyPegen_expect_token(p, 35)) // token='**' && - _PyPegen_lookahead(1, t_lookahead_rule, p) + (a = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &t_lookahead")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_Attribute ( a , b -> v . Name . id , Load , EXTRA ); + D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' expression")); + _res = ( asdl_expr_seq* ) _PyPegen_singleton_seq ( p , a ); if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -20174,42 +19604,22 @@ t_primary_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME &t_lookahead")); + D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' expression")); } - { // t_primary '[' slices ']' &t_lookahead + { // ','.expression+ if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &t_lookahead")); - Token * _literal; - Token * _literal_1; - expr_ty a; - expr_ty b; + D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+")); + asdl_expr_seq* a; if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - && - (b = slices_rule(p)) // slices - && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' - && - _PyPegen_lookahead(1, t_lookahead_rule, p) + (a = (asdl_expr_seq*)_gather_104_rule(p)) // ','.expression+ ) { - D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &t_lookahead")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_Subscript ( a , b , Load , EXTRA ); + D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+")); + _res = a; if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -20218,36 +19628,49 @@ t_primary_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' &t_lookahead")); + D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// func_type_comment: +// | NEWLINE TYPE_COMMENT &(NEWLINE INDENT) +// | invalid_double_type_comments +// | TYPE_COMMENT +Py_LOCAL_SYMBOL Token* +func_type_comment_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; } - { // t_primary genexp &t_lookahead + Token* _res = NULL; + int _mark = p->mark; + { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT) if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary genexp &t_lookahead")); - expr_ty a; - expr_ty b; + D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); + Token * newline_var; + Token * t; if ( - (a = t_primary_rule(p)) // t_primary + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' && - (b = genexp_rule(p)) // genexp + (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' && - _PyPegen_lookahead(1, t_lookahead_rule, p) + _PyPegen_lookahead(1, _tmp_105_rule, p) ) { - D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary genexp &t_lookahead")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_Call ( a , CHECK ( asdl_expr_seq* , ( asdl_expr_seq* ) _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); + D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); + _res = t; if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -20256,78 +19679,46 @@ t_primary_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary genexp &t_lookahead")); + D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); } - { // t_primary '(' arguments? ')' &t_lookahead + if (p->call_invalid_rules) { // invalid_double_type_comments if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead")); - Token * _literal; - Token * _literal_1; - expr_ty a; - void *b; + D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments")); + void *invalid_double_type_comments_var; if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (b = arguments_rule(p), !p->error_indicator) // arguments? - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' - && - _PyPegen_lookahead(1, t_lookahead_rule, p) + (invalid_double_type_comments_var = invalid_double_type_comments_rule(p)) // invalid_double_type_comments ) { - D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments")); + _res = invalid_double_type_comments_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead")); + D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_double_type_comments")); } - { // atom &t_lookahead + { // TYPE_COMMENT if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "atom &t_lookahead")); - expr_ty a; - if ( - (a = atom_rule(p)) // atom - && - _PyPegen_lookahead(1, t_lookahead_rule, p) + D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT")); + Token * type_comment_var; + if ( + (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' ) { - D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "atom &t_lookahead")); - _res = a; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT")); + _res = type_comment_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "atom &t_lookahead")); + D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT")); } _res = NULL; done: @@ -20335,122 +19726,228 @@ t_primary_raw(Parser *p) return _res; } -// t_lookahead: '(' | '[' | '.' -static void * -t_lookahead_rule(Parser *p) +// _loop0_1: NEWLINE +static asdl_seq * +_loop0_1_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // '(' + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // NEWLINE if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' + D(fprintf(stderr, "%*c> _loop0_1[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + Token * newline_var; + while ( + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); - _res = _literal; - goto done; + _res = newline_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c%s _loop0_1[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); } - { // '[' + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop1_2: statement +static asdl_seq * +_loop1_2_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // statement if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 9)) // token='[' + D(fprintf(stderr, "%*c> _loop1_2[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement")); + asdl_stmt_seq* statement_var; + while ( + (statement_var = statement_rule(p)) // statement ) { - D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); - _res = _literal; - goto done; + _res = statement_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c%s _loop1_2[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement")); } - { // '.' + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop0_3: ';' simple_stmt +static asdl_seq * +_loop0_3_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ';' simple_stmt if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _loop0_3[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';' simple_stmt")); Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 23)) // token='.' + stmt_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 13)) // token=';' + && + (elem = simple_stmt_rule(p)) // simple_stmt ) { - D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); - _res = _literal; - goto done; + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c%s _loop0_3[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';' simple_stmt")); } - _res = NULL; - done: + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// del_targets: ','.del_target+ ','? -static asdl_expr_seq* -del_targets_rule(Parser *p) +// _gather_4: simple_stmt _loop0_3 +static asdl_seq * +_gather_4_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - asdl_expr_seq* _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // ','.del_target+ ','? + { // simple_stmt _loop0_3 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> del_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - asdl_expr_seq* a; + D(fprintf(stderr, "%*c> _gather_4[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt _loop0_3")); + stmt_ty elem; + asdl_seq * seq; if ( - (a = (asdl_expr_seq*)_gather_103_rule(p)) // ','.del_target+ + (elem = simple_stmt_rule(p)) // simple_stmt && - (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? + (seq = _loop0_3_rule(p)) // _loop0_3 ) { - D(fprintf(stderr, "%*c+ del_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?")); - _res = a; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ _gather_4[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt _loop0_3")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_targets[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.del_target+ ','?")); + D(fprintf(stderr, "%*c%s _gather_4[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt _loop0_3")); } _res = NULL; done: @@ -20458,299 +19955,208 @@ del_targets_rule(Parser *p) return _res; } -// del_target: -// | t_primary '.' NAME !t_lookahead -// | t_primary '[' slices ']' !t_lookahead -// | del_t_atom -static expr_ty -del_target_rule(Parser *p) +// _tmp_5: 'import' | 'from' | "lazy" +static void * +_tmp_5_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, del_target_type, &_res)) { - p->level--; - return _res; - } + void * _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - p->level--; - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // t_primary '.' NAME !t_lookahead + { // 'import' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); - Token * _literal; - expr_ty a; - expr_ty b; + D(fprintf(stderr, "%*c> _tmp_5[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import'")); + Token * _keyword; if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 23)) // token='.' - && - (b = _PyPegen_name_token(p)) // NAME - && - _PyPegen_lookahead(0, t_lookahead_rule, p) + (_keyword = _PyPegen_expect_token(p, 500)) // token='import' ) { - D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_Attribute ( a , b -> v . Name . id , Del , EXTRA ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; + D(fprintf(stderr, "%*c+ _tmp_5[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import'")); + _res = _keyword; + goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); + D(fprintf(stderr, "%*c%s _tmp_5[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import'")); } - { // t_primary '[' slices ']' !t_lookahead + { // 'from' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); - Token * _literal; - Token * _literal_1; - expr_ty a; - expr_ty b; + D(fprintf(stderr, "%*c> _tmp_5[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from'")); + Token * _keyword; if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - && - (b = slices_rule(p)) // slices - && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' - && - _PyPegen_lookahead(0, t_lookahead_rule, p) + (_keyword = _PyPegen_expect_token(p, 501)) // token='from' ) { - D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_Subscript ( a , b , Del , EXTRA ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_5[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from'")); + _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + D(fprintf(stderr, "%*c%s _tmp_5[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from'")); } - { // del_t_atom + { // "lazy" if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_t_atom")); - expr_ty del_t_atom_var; + D(fprintf(stderr, "%*c> _tmp_5[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"lazy\"")); + expr_ty _keyword; if ( - (del_t_atom_var = del_t_atom_rule(p)) // del_t_atom + (_keyword = _PyPegen_expect_soft_keyword(p, "lazy")) // soft_keyword='"lazy"' ) { - D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_t_atom")); - _res = del_t_atom_var; + D(fprintf(stderr, "%*c+ _tmp_5[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"lazy\"")); + _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_t_atom")); + D(fprintf(stderr, "%*c%s _tmp_5[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"lazy\"")); } _res = NULL; done: - _PyPegen_insert_memo(p, _mark, del_target_type, _res); p->level--; return _res; } -// del_t_atom: NAME | '(' del_target ')' | '(' del_targets? ')' | '[' del_targets? ']' -static expr_ty -del_t_atom_rule(Parser *p) +// _tmp_6: 'def' | '@' | 'async' +static void * +_tmp_6_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - expr_ty _res = NULL; + void * _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - p->level--; - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NAME + { // 'def' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); - expr_ty a; + D(fprintf(stderr, "%*c> _tmp_6[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def'")); + Token * _keyword; if ( - (a = _PyPegen_name_token(p)) // NAME + (_keyword = _PyPegen_expect_token(p, 512)) // token='def' ) { - D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); - _res = _PyPegen_set_expr_context ( p , a , Del ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_6[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def'")); + _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); + D(fprintf(stderr, "%*c%s _tmp_6[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def'")); } - { // '(' del_target ')' + { // '@' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' del_target ')'")); + D(fprintf(stderr, "%*c> _tmp_6[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'")); Token * _literal; - Token * _literal_1; - expr_ty a; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (a = del_target_rule(p)) // del_target - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (_literal = _PyPegen_expect_token(p, 49)) // token='@' ) { - D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' del_target ')'")); - _res = _PyPegen_set_expr_context ( p , a , Del ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_6[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' del_target ')'")); + D(fprintf(stderr, "%*c%s _tmp_6[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'")); } - { // '(' del_targets? ')' + { // 'async' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' del_targets? ')'")); - Token * _literal; - Token * _literal_1; - void *a; + D(fprintf(stderr, "%*c> _tmp_6[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'")); + Token * _keyword; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (a = del_targets_rule(p), !p->error_indicator) // del_targets? - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (_keyword = _PyPegen_expect_token(p, 513)) // token='async' ) { - D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' del_targets? ')'")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_Tuple ( a , Del , EXTRA ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_6[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'")); + _res = _keyword; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_6[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_7: 'class' | '@' +static void * +_tmp_7_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'class' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_7[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class'")); + Token * _keyword; + if ( + (_keyword = _PyPegen_expect_token(p, 515)) // token='class' + ) + { + D(fprintf(stderr, "%*c+ _tmp_7[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class'")); + _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' del_targets? ')'")); + D(fprintf(stderr, "%*c%s _tmp_7[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class'")); } - { // '[' del_targets? ']' + { // '@' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' del_targets? ']'")); + D(fprintf(stderr, "%*c> _tmp_7[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'")); Token * _literal; - Token * _literal_1; - void *a; if ( - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - && - (a = del_targets_rule(p), !p->error_indicator) // del_targets? - && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + (_literal = _PyPegen_expect_token(p, 49)) // token='@' ) { - D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' del_targets? ']'")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_List ( a , Del , EXTRA ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_7[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' del_targets? ']'")); + D(fprintf(stderr, "%*c%s _tmp_7[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'")); } _res = NULL; done: @@ -20758,237 +20164,149 @@ del_t_atom_rule(Parser *p) return _res; } -// type_expressions: -// | ','.expression+ ',' '*' expression ',' '**' expression -// | ','.expression+ ',' '*' expression -// | ','.expression+ ',' '**' expression -// | '*' expression ',' '**' expression -// | '*' expression -// | '**' expression -// | ','.expression+ -static asdl_expr_seq* -type_expressions_rule(Parser *p) +// _tmp_8: 'with' | 'async' +static void * +_tmp_8_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - asdl_expr_seq* _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // ','.expression+ ',' '*' expression ',' '**' expression + { // 'with' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression")); - Token * _literal; - Token * _literal_1; - Token * _literal_2; - Token * _literal_3; - asdl_seq * a; - expr_ty b; - expr_ty c; + D(fprintf(stderr, "%*c> _tmp_8[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with'")); + Token * _keyword; if ( - (a = _gather_105_rule(p)) // ','.expression+ - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' - && - (b = expression_rule(p)) // expression - && - (_literal_2 = _PyPegen_expect_token(p, 12)) // token=',' - && - (_literal_3 = _PyPegen_expect_token(p, 35)) // token='**' - && - (c = expression_rule(p)) // expression + (_keyword = _PyPegen_expect_token(p, 516)) // token='with' ) { - D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression")); - _res = ( asdl_expr_seq* ) _PyPegen_seq_append_to_end ( p , CHECK ( asdl_seq* , _PyPegen_seq_append_to_end ( p , a , b ) ) , c ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_8[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with'")); + _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression")); + D(fprintf(stderr, "%*c%s _tmp_8[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with'")); } - { // ','.expression+ ',' '*' expression + { // 'async' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression")); - Token * _literal; - Token * _literal_1; - asdl_seq * a; - expr_ty b; + D(fprintf(stderr, "%*c> _tmp_8[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'")); + Token * _keyword; if ( - (a = _gather_105_rule(p)) // ','.expression+ - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' - && - (b = expression_rule(p)) // expression + (_keyword = _PyPegen_expect_token(p, 513)) // token='async' ) { - D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression")); - _res = ( asdl_expr_seq* ) _PyPegen_seq_append_to_end ( p , a , b ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_8[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'")); + _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '*' expression")); + D(fprintf(stderr, "%*c%s _tmp_8[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'")); } - { // ','.expression+ ',' '**' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '**' expression")); - Token * _literal; - Token * _literal_1; - asdl_seq * a; - expr_ty b; - if ( - (a = _gather_105_rule(p)) // ','.expression+ - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (_literal_1 = _PyPegen_expect_token(p, 35)) // token='**' - && - (b = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '**' expression")); - _res = ( asdl_expr_seq* ) _PyPegen_seq_append_to_end ( p , a , b ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '**' expression")); + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_9: 'for' | 'async' +static void * +_tmp_9_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); } - { // '*' expression ',' '**' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'for' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression ',' '**' expression")); - Token * _literal; - Token * _literal_1; - Token * _literal_2; - expr_ty a; - expr_ty b; + D(fprintf(stderr, "%*c> _tmp_9[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for'")); + Token * _keyword; if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (a = expression_rule(p)) // expression - && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' - && - (_literal_2 = _PyPegen_expect_token(p, 35)) // token='**' - && - (b = expression_rule(p)) // expression + (_keyword = _PyPegen_expect_token(p, 517)) // token='for' ) { - D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression ',' '**' expression")); - _res = ( asdl_expr_seq* ) _PyPegen_seq_append_to_end ( p , CHECK ( asdl_seq* , _PyPegen_singleton_seq ( p , a ) ) , b ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_9[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for'")); + _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression ',' '**' expression")); + D(fprintf(stderr, "%*c%s _tmp_9[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for'")); } - { // '*' expression + { // 'async' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression")); - Token * _literal; - expr_ty a; + D(fprintf(stderr, "%*c> _tmp_9[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'")); + Token * _keyword; if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (a = expression_rule(p)) // expression + (_keyword = _PyPegen_expect_token(p, 513)) // token='async' ) { - D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression")); - _res = ( asdl_expr_seq* ) _PyPegen_singleton_seq ( p , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_9[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'")); + _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression")); + D(fprintf(stderr, "%*c%s _tmp_9[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'")); } - { // '**' expression + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_10: '=' annotated_rhs +static void * +_tmp_10_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '=' annotated_rhs if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' expression")); + D(fprintf(stderr, "%*c> _tmp_10[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); Token * _literal; - expr_ty a; + expr_ty d; if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' + (_literal = _PyPegen_expect_token(p, 22)) // token='=' && - (a = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' expression")); - _res = ( asdl_expr_seq* ) _PyPegen_singleton_seq ( p , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' expression")); - } - { // ','.expression+ - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+")); - asdl_expr_seq* a; - if ( - (a = (asdl_expr_seq*)_gather_105_rule(p)) // ','.expression+ + (d = annotated_rhs_rule(p)) // annotated_rhs ) { - D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+")); - _res = a; + D(fprintf(stderr, "%*c+ _tmp_10[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + _res = d; if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -20997,8 +20315,8 @@ type_expressions_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+")); + D(fprintf(stderr, "%*c%s _tmp_10[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); } _res = NULL; done: @@ -21006,40 +20324,38 @@ type_expressions_rule(Parser *p) return _res; } -// func_type_comment: -// | NEWLINE TYPE_COMMENT &(NEWLINE INDENT) -// | invalid_double_type_comments -// | TYPE_COMMENT -static Token* -func_type_comment_rule(Parser *p) +// _tmp_11: '(' single_target ')' | attribute_or_subscript_target +static void * +_tmp_11_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - Token* _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT) + { // '(' single_target ')' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); - Token * newline_var; - Token * t; + D(fprintf(stderr, "%*c> _tmp_11[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); + Token * _literal; + Token * _literal_1; + expr_ty b; if ( - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' + (b = single_target_rule(p)) // single_target && - _PyPegen_lookahead(1, _tmp_106_rule, p) + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); - _res = t; + D(fprintf(stderr, "%*c+ _tmp_11[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); + _res = b; if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -21048,46 +20364,27 @@ func_type_comment_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); - } - if (p->call_invalid_rules) { // invalid_double_type_comments - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments")); - void *invalid_double_type_comments_var; - if ( - (invalid_double_type_comments_var = invalid_double_type_comments_rule(p)) // invalid_double_type_comments - ) - { - D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments")); - _res = invalid_double_type_comments_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_double_type_comments")); + D(fprintf(stderr, "%*c%s _tmp_11[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' single_target ')'")); } - { // TYPE_COMMENT + { // attribute_or_subscript_target if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT")); - Token * type_comment_var; + D(fprintf(stderr, "%*c> _tmp_11[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "attribute_or_subscript_target")); + expr_ty attribute_or_subscript_target_var; if ( - (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' + (attribute_or_subscript_target_var = attribute_or_subscript_target_rule(p)) // attribute_or_subscript_target ) { - D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT")); - _res = type_comment_var; + D(fprintf(stderr, "%*c+ _tmp_11[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "attribute_or_subscript_target")); + _res = attribute_or_subscript_target_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT")); + D(fprintf(stderr, "%*c%s _tmp_11[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "attribute_or_subscript_target")); } _res = NULL; done: @@ -21095,12901 +20392,74 @@ func_type_comment_rule(Parser *p) return _res; } -// invalid_arguments: -// | ((','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs) ',' ','.(starred_expression !'=')+ -// | expression for_if_clauses ',' [args | expression for_if_clauses] -// | NAME '=' expression for_if_clauses -// | [(args ',')] NAME '=' &(',' | ')') -// | args for_if_clauses -// | args ',' expression for_if_clauses -// | args ',' args -static void * -invalid_arguments_rule(Parser *p) +// _loop1_12: (star_targets '=') +static asdl_seq * +_loop1_12_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // ((','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs) ',' ','.(starred_expression !'=')+ + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // (star_targets '=') if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs) ',' ','.(starred_expression !'=')+")); - asdl_seq * _gather_109_var; - void *_tmp_107_var; - Token * a; - if ( - (_tmp_107_var = _tmp_107_rule(p)) // (','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs - && - (a = _PyPegen_expect_token(p, 12)) // token=',' - && - (_gather_109_var = _gather_109_rule(p)) // ','.(starred_expression !'=')+ + D(fprintf(stderr, "%*c> _loop1_12[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); + void *_tmp_178_var; + while ( + (_tmp_178_var = _tmp_178_rule(p)) // star_targets '=' ) { - D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs) ',' ','.(starred_expression !'=')+")); - _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( a , "iterable argument unpacking follows keyword argument unpacking" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs) ',' ','.(starred_expression !'=')+")); - } - { // expression for_if_clauses ',' [args | expression for_if_clauses] - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty a; - asdl_comprehension_seq* b; - if ( - (a = expression_rule(p)) // expression - && - (b = for_if_clauses_rule(p)) // for_if_clauses - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (_opt_var = _tmp_110_rule(p), !p->error_indicator) // [args | expression for_if_clauses] - ) - { - D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , _PyPegen_get_last_comprehension_item ( PyPegen_last_item ( b , comprehension_ty ) ) , "Generator expression must be parenthesized" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); - } - { // NAME '=' expression for_if_clauses - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression for_if_clauses")); - expr_ty a; - Token * b; - expr_ty expression_var; - asdl_comprehension_seq* for_if_clauses_var; - if ( - (a = _PyPegen_name_token(p)) // NAME - && - (b = _PyPegen_expect_token(p, 22)) // token='=' - && - (expression_var = expression_rule(p)) // expression - && - (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses - ) - { - D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression for_if_clauses")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "invalid syntax. Maybe you meant '==' or ':=' instead of '='?" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression for_if_clauses")); - } - { // [(args ',')] NAME '=' &(',' | ')') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "[(args ',')] NAME '=' &(',' | ')')")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty a; - Token * b; - if ( - (_opt_var = _tmp_111_rule(p), !p->error_indicator) // [(args ',')] - && - (a = _PyPegen_name_token(p)) // NAME - && - (b = _PyPegen_expect_token(p, 22)) // token='=' - && - _PyPegen_lookahead(1, _tmp_112_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "[(args ',')] NAME '=' &(',' | ')')")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "expected argument value expression" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "[(args ',')] NAME '=' &(',' | ')')")); - } - { // args for_if_clauses - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args for_if_clauses")); - expr_ty a; - asdl_comprehension_seq* b; - if ( - (a = args_rule(p)) // args - && - (b = for_if_clauses_rule(p)) // for_if_clauses - ) - { - D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args for_if_clauses")); - _res = _PyPegen_nonparen_genexp_in_call ( p , a , b ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args for_if_clauses")); - } - { // args ',' expression for_if_clauses - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses")); - Token * _literal; - expr_ty a; - expr_ty args_var; - asdl_comprehension_seq* b; - if ( - (args_var = args_rule(p)) // args - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (a = expression_rule(p)) // expression - && - (b = for_if_clauses_rule(p)) // for_if_clauses - ) - { - D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , _PyPegen_get_last_comprehension_item ( PyPegen_last_item ( b , comprehension_ty ) ) , "Generator expression must be parenthesized" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' expression for_if_clauses")); - } - { // args ',' args - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' args")); - Token * _literal; - expr_ty a; - expr_ty args_var; - if ( - (a = args_rule(p)) // args - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (args_var = args_rule(p)) // args - ) - { - D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' args")); - _res = _PyPegen_arguments_parsing_error ( p , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' args")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_kwarg: -// | ('True' | 'False' | 'None') '=' -// | NAME '=' expression for_if_clauses -// | !(NAME '=') expression '=' -// | '**' expression '=' expression -static void * -invalid_kwarg_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // ('True' | 'False' | 'None') '=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('True' | 'False' | 'None') '='")); - Token* a; - Token * b; - if ( - (a = (Token*)_tmp_113_rule(p)) // 'True' | 'False' | 'None' - && - (b = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('True' | 'False' | 'None') '='")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot assign to %s" , PyBytes_AS_STRING ( a -> bytes ) ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kwarg[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('True' | 'False' | 'None') '='")); - } - { // NAME '=' expression for_if_clauses - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression for_if_clauses")); - expr_ty a; - Token * b; - expr_ty expression_var; - asdl_comprehension_seq* for_if_clauses_var; - if ( - (a = _PyPegen_name_token(p)) // NAME - && - (b = _PyPegen_expect_token(p, 22)) // token='=' - && - (expression_var = expression_rule(p)) // expression - && - (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses - ) - { - D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression for_if_clauses")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "invalid syntax. Maybe you meant '==' or ':=' instead of '='?" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kwarg[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression for_if_clauses")); - } - { // !(NAME '=') expression '=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!(NAME '=') expression '='")); - expr_ty a; - Token * b; - if ( - _PyPegen_lookahead(0, _tmp_114_rule, p) - && - (a = expression_rule(p)) // expression - && - (b = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!(NAME '=') expression '='")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "expression cannot contain assignment, perhaps you meant \"==\"?" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kwarg[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!(NAME '=') expression '='")); - } - { // '**' expression '=' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' expression '=' expression")); - Token * _literal; - Token * a; - expr_ty b; - expr_ty expression_var; - if ( - (a = _PyPegen_expect_token(p, 35)) // token='**' - && - (expression_var = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - && - (b = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' expression '=' expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot assign to keyword argument unpacking" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kwarg[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' expression '=' expression")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// expression_without_invalid: -// | disjunction 'if' disjunction 'else' expression -// | disjunction -// | lambdef -static expr_ty -expression_without_invalid_rule(Parser *p) -{ - int _prev_call_invalid = p->call_invalid_rules; - p->call_invalid_rules = 0; - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->call_invalid_rules = _prev_call_invalid; - p->level--; - return NULL; - } - expr_ty _res = NULL; - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - p->call_invalid_rules = _prev_call_invalid; - p->level--; - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // disjunction 'if' disjunction 'else' expression - if (p->error_indicator) { - p->call_invalid_rules = _prev_call_invalid; - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> expression_without_invalid[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); - Token * _keyword; - Token * _keyword_1; - expr_ty a; - expr_ty b; - expr_ty c; - if ( - (a = disjunction_rule(p)) // disjunction - && - (_keyword = _PyPegen_expect_token(p, 700)) // token='if' - && - (b = disjunction_rule(p)) // disjunction - && - (_keyword_1 = _PyPegen_expect_token(p, 704)) // token='else' - && - (c = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ expression_without_invalid[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - p->call_invalid_rules = _prev_call_invalid; - p->level--; - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyAST_IfExp ( b , a , c , EXTRA ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->call_invalid_rules = _prev_call_invalid; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s expression_without_invalid[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); - } - { // disjunction - if (p->error_indicator) { - p->call_invalid_rules = _prev_call_invalid; - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> expression_without_invalid[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction")); - expr_ty disjunction_var; - if ( - (disjunction_var = disjunction_rule(p)) // disjunction - ) - { - D(fprintf(stderr, "%*c+ expression_without_invalid[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction")); - _res = disjunction_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s expression_without_invalid[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction")); - } - { // lambdef - if (p->error_indicator) { - p->call_invalid_rules = _prev_call_invalid; - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> expression_without_invalid[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambdef")); - expr_ty lambdef_var; - if ( - (lambdef_var = lambdef_rule(p)) // lambdef - ) - { - D(fprintf(stderr, "%*c+ expression_without_invalid[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambdef")); - _res = lambdef_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s expression_without_invalid[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambdef")); - } - _res = NULL; - done: - p->call_invalid_rules = _prev_call_invalid; - p->level--; - return _res; -} - -// invalid_legacy_expression: NAME !'(' star_expressions -static void * -invalid_legacy_expression_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // NAME !'(' star_expressions - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_legacy_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME !'(' star_expressions")); - expr_ty a; - expr_ty b; - if ( - (a = _PyPegen_name_token(p)) // NAME - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 7) // token='(' - && - (b = star_expressions_rule(p)) // star_expressions - ) - { - D(fprintf(stderr, "%*c+ invalid_legacy_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME !'(' star_expressions")); - _res = _PyPegen_check_legacy_stmt ( p , a ) ? RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "Missing parentheses in call to '%U'. Did you mean %U(...)?" , a -> v . Name . id , a -> v . Name . id ) : NULL; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_legacy_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME !'(' star_expressions")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_type_param: '*' NAME ':' expression | '**' NAME ':' expression -static void * -invalid_type_param_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '*' NAME ':' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_type_param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' NAME ':' expression")); - Token * _literal; - expr_ty a; - Token * colon; - expr_ty e; - if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (a = _PyPegen_name_token(p)) // NAME - && - (colon = _PyPegen_expect_token(p, 11)) // token=':' - && - (e = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_type_param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' NAME ':' expression")); - _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( colon , e -> kind == Tuple_kind ? "cannot use constraints with TypeVarTuple" : "cannot use bound with TypeVarTuple" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_type_param[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' NAME ':' expression")); - } - { // '**' NAME ':' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_type_param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' NAME ':' expression")); - Token * _literal; - expr_ty a; - Token * colon; - expr_ty e; - if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' - && - (a = _PyPegen_name_token(p)) // NAME - && - (colon = _PyPegen_expect_token(p, 11)) // token=':' - && - (e = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_type_param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' NAME ':' expression")); - _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( colon , e -> kind == Tuple_kind ? "cannot use constraints with ParamSpec" : "cannot use bound with ParamSpec" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_type_param[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' NAME ':' expression")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_expression: -// | STRING ((!STRING expression_without_invalid))+ STRING -// | !(NAME STRING | SOFT_KEYWORD) disjunction expression_without_invalid -// | disjunction 'if' disjunction !('else' | ':') -// | disjunction 'if' disjunction 'else' !expression -// | (pass_stmt | break_stmt | continue_stmt) 'if' disjunction 'else' simple_stmt -// | 'lambda' lambda_params? ':' &FSTRING_MIDDLE -// | 'lambda' lambda_params? ':' &TSTRING_MIDDLE -static void * -invalid_expression_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // STRING ((!STRING expression_without_invalid))+ STRING - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING ((!STRING expression_without_invalid))+ STRING")); - asdl_seq * a; - expr_ty string_var; - expr_ty string_var_1; - if ( - (string_var = _PyPegen_string_token(p)) // STRING - && - (a = _loop1_115_rule(p)) // ((!STRING expression_without_invalid))+ - && - (string_var_1 = _PyPegen_string_token(p)) // STRING - ) - { - D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING ((!STRING expression_without_invalid))+ STRING")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( PyPegen_first_item ( a , expr_ty ) , PyPegen_last_item ( a , expr_ty ) , "invalid syntax. Is this intended to be part of the string?" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING ((!STRING expression_without_invalid))+ STRING")); - } - { // !(NAME STRING | SOFT_KEYWORD) disjunction expression_without_invalid - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!(NAME STRING | SOFT_KEYWORD) disjunction expression_without_invalid")); - expr_ty a; - expr_ty b; - if ( - _PyPegen_lookahead(0, _tmp_116_rule, p) - && - (a = disjunction_rule(p)) // disjunction - && - (b = expression_without_invalid_rule(p)) // expression_without_invalid - ) - { - D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!(NAME STRING | SOFT_KEYWORD) disjunction expression_without_invalid")); - _res = _PyPegen_raise_error_for_missing_comma ( p , a , b ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!(NAME STRING | SOFT_KEYWORD) disjunction expression_without_invalid")); - } - { // disjunction 'if' disjunction !('else' | ':') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction !('else' | ':')")); - Token * _keyword; - expr_ty a; - expr_ty b; - if ( - (a = disjunction_rule(p)) // disjunction - && - (_keyword = _PyPegen_expect_token(p, 700)) // token='if' - && - (b = disjunction_rule(p)) // disjunction - && - _PyPegen_lookahead(0, _tmp_117_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction !('else' | ':')")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "expected 'else' after 'if' expression" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction !('else' | ':')")); - } - { // disjunction 'if' disjunction 'else' !expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' !expression")); - Token * _keyword; - Token * _keyword_1; - expr_ty a; - expr_ty b; - if ( - (a = disjunction_rule(p)) // disjunction - && - (_keyword = _PyPegen_expect_token(p, 700)) // token='if' - && - (b = disjunction_rule(p)) // disjunction - && - (_keyword_1 = _PyPegen_expect_token(p, 704)) // token='else' - && - _PyPegen_lookahead_for_expr(0, expression_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' !expression")); - _res = RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "expected expression after 'else', but statement is given" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction 'else' !expression")); - } - { // (pass_stmt | break_stmt | continue_stmt) 'if' disjunction 'else' simple_stmt - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(pass_stmt | break_stmt | continue_stmt) 'if' disjunction 'else' simple_stmt")); - Token * _keyword; - Token * _keyword_1; - stmt_ty a; - expr_ty b; - stmt_ty c; - if ( - (a = (stmt_ty)_tmp_118_rule(p)) // pass_stmt | break_stmt | continue_stmt - && - (_keyword = _PyPegen_expect_token(p, 700)) // token='if' - && - (b = disjunction_rule(p)) // disjunction - && - (_keyword_1 = _PyPegen_expect_token(p, 704)) // token='else' - && - (c = simple_stmt_rule(p)) // simple_stmt - ) - { - D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(pass_stmt | break_stmt | continue_stmt) 'if' disjunction 'else' simple_stmt")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expected expression before 'if', but statement is given" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(pass_stmt | break_stmt | continue_stmt) 'if' disjunction 'else' simple_stmt")); - } - { // 'lambda' lambda_params? ':' &FSTRING_MIDDLE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' &FSTRING_MIDDLE")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * a; - Token * b; - if ( - (a = _PyPegen_expect_token(p, 622)) // token='lambda' - && - (_opt_var = lambda_params_rule(p), !p->error_indicator) // lambda_params? - && - (b = _PyPegen_expect_token(p, 11)) // token=':' - && - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, FSTRING_MIDDLE) // token=FSTRING_MIDDLE - ) - { - D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' &FSTRING_MIDDLE")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "f-string: lambda expressions are not allowed without parentheses" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'lambda' lambda_params? ':' &FSTRING_MIDDLE")); - } - { // 'lambda' lambda_params? ':' &TSTRING_MIDDLE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' &TSTRING_MIDDLE")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * a; - Token * b; - if ( - (a = _PyPegen_expect_token(p, 622)) // token='lambda' - && - (_opt_var = lambda_params_rule(p), !p->error_indicator) // lambda_params? - && - (b = _PyPegen_expect_token(p, 11)) // token=':' - && - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, TSTRING_MIDDLE) // token=TSTRING_MIDDLE - ) - { - D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' &TSTRING_MIDDLE")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "t-string: lambda expressions are not allowed without parentheses" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'lambda' lambda_params? ':' &TSTRING_MIDDLE")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_if_expression: -// | disjunction 'if' disjunction 'else' '*' -// | disjunction 'if' disjunction 'else' '**' -static void * -invalid_if_expression_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // disjunction 'if' disjunction 'else' '*' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_if_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' '*'")); - Token * _keyword; - Token * _keyword_1; - Token * a; - expr_ty b; - expr_ty disjunction_var; - if ( - (disjunction_var = disjunction_rule(p)) // disjunction - && - (_keyword = _PyPegen_expect_token(p, 700)) // token='if' - && - (b = disjunction_rule(p)) // disjunction - && - (_keyword_1 = _PyPegen_expect_token(p, 704)) // token='else' - && - (a = _PyPegen_expect_token(p, 16)) // token='*' - ) - { - D(fprintf(stderr, "%*c+ invalid_if_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' '*'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot unpack only part of a conditional expression" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_if_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction 'else' '*'")); - } - { // disjunction 'if' disjunction 'else' '**' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_if_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' '**'")); - Token * _keyword; - Token * _keyword_1; - Token * a; - expr_ty b; - expr_ty disjunction_var; - if ( - (disjunction_var = disjunction_rule(p)) // disjunction - && - (_keyword = _PyPegen_expect_token(p, 700)) // token='if' - && - (b = disjunction_rule(p)) // disjunction - && - (_keyword_1 = _PyPegen_expect_token(p, 704)) // token='else' - && - (a = _PyPegen_expect_token(p, 35)) // token='**' - ) - { - D(fprintf(stderr, "%*c+ invalid_if_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' '**'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use dict unpacking on only part of a conditional expression" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_if_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction 'else' '**'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_named_expression: -// | expression ':=' expression -// | NAME '=' bitwise_or !('=' | ':=') -// | !(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=') -static void * -invalid_named_expression_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - if (_PyPegen_is_memoized(p, invalid_named_expression_type, &_res)) { - p->level--; - return _res; - } - int _mark = p->mark; - { // expression ':=' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':=' expression")); - Token * _literal; - expr_ty a; - expr_ty expression_var; - if ( - (a = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 53)) // token=':=' - && - (expression_var = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':=' expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_named_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':=' expression")); - } - { // NAME '=' bitwise_or !('=' | ':=') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' bitwise_or !('=' | ':=')")); - Token * _literal; - expr_ty a; - expr_ty b; - if ( - (a = _PyPegen_name_token(p)) // NAME - && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - && - (b = bitwise_or_rule(p)) // bitwise_or - && - _PyPegen_lookahead(0, _tmp_119_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' bitwise_or !('=' | ':=')")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "invalid syntax. Maybe you meant '==' or ':=' instead of '='?" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_named_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' bitwise_or !('=' | ':=')")); - } - { // !(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=')")); - expr_ty a; - Token * b; - expr_ty bitwise_or_var; - if ( - _PyPegen_lookahead(0, _tmp_120_rule, p) - && - (a = bitwise_or_rule(p)) // bitwise_or - && - (b = _PyPegen_expect_token(p, 22)) // token='=' - && - (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or - && - _PyPegen_lookahead(0, _tmp_119_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=')")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot assign to %s here. Maybe you meant '==' instead of '='?" , _PyPegen_get_expr_name ( a ) ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_named_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=')")); - } - _res = NULL; - done: - _PyPegen_insert_memo(p, _mark, invalid_named_expression_type, _res); - p->level--; - return _res; -} - -// invalid_assignment: -// | invalid_ann_assign_target ':' expression -// | star_named_expression ',' star_named_expressions* ':' expression -// | expression ':' expression -// | ((star_targets '='))* star_expressions '=' -// | ((star_targets '='))* yield_expr '=' -// | star_expressions augassign annotated_rhs -static void * -invalid_assignment_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // invalid_ann_assign_target ':' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_ann_assign_target ':' expression")); - Token * _literal; - expr_ty a; - expr_ty expression_var; - if ( - (a = invalid_ann_assign_target_rule(p)) // invalid_ann_assign_target - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (expression_var = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_ann_assign_target ':' expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not %s) can be annotated" , _PyPegen_get_expr_name ( a ) ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_ann_assign_target ':' expression")); - } - { // star_named_expression ',' star_named_expressions* ':' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':' expression")); - Token * _literal; - Token * _literal_1; - asdl_seq * _loop0_121_var; - expr_ty a; - expr_ty expression_var; - if ( - (a = star_named_expression_rule(p)) // star_named_expression - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (_loop0_121_var = _loop0_121_rule(p)) // star_named_expressions* - && - (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' - && - (expression_var = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':' expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions* ':' expression")); - } - { // expression ':' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' expression")); - Token * _literal; - expr_ty a; - expr_ty expression_var; - if ( - (a = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (expression_var = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "illegal target for annotation" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' expression")); - } - { // ((star_targets '='))* star_expressions '=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='")); - Token * _literal; - asdl_seq * _loop0_122_var; - expr_ty a; - if ( - (_loop0_122_var = _loop0_122_rule(p)) // ((star_targets '='))* - && - (a = star_expressions_rule(p)) // star_expressions - && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='")); - _res = RAISE_SYNTAX_ERROR_INVALID_TARGET ( STAR_TARGETS , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))* star_expressions '='")); - } - { // ((star_targets '='))* yield_expr '=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='")); - Token * _literal; - asdl_seq * _loop0_122_var; - expr_ty a; - if ( - (_loop0_122_var = _loop0_122_rule(p)) // ((star_targets '='))* - && - (a = yield_expr_rule(p)) // yield_expr - && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "assignment to yield expression not possible" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))* yield_expr '='")); - } - { // star_expressions augassign annotated_rhs - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign annotated_rhs")); - expr_ty a; - expr_ty annotated_rhs_var; - AugOperator* augassign_var; - if ( - (a = star_expressions_rule(p)) // star_expressions - && - (augassign_var = augassign_rule(p)) // augassign - && - (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs - ) - { - D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign annotated_rhs")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "'%s' is an illegal expression for augmented assignment" , _PyPegen_get_expr_name ( a ) ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions augassign annotated_rhs")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_ann_assign_target: list | tuple | '(' invalid_ann_assign_target ')' -static expr_ty -invalid_ann_assign_target_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - expr_ty _res = NULL; - int _mark = p->mark; - { // list - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_ann_assign_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); - expr_ty list_var; - if ( - (list_var = list_rule(p)) // list - ) - { - D(fprintf(stderr, "%*c+ invalid_ann_assign_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); - _res = list_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_ann_assign_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); - } - { // tuple - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_ann_assign_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); - expr_ty tuple_var; - if ( - (tuple_var = tuple_rule(p)) // tuple - ) - { - D(fprintf(stderr, "%*c+ invalid_ann_assign_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); - _res = tuple_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_ann_assign_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); - } - { // '(' invalid_ann_assign_target ')' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_ann_assign_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' invalid_ann_assign_target ')'")); - Token * _literal; - Token * _literal_1; - expr_ty a; - if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (a = invalid_ann_assign_target_rule(p)) // invalid_ann_assign_target - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ invalid_ann_assign_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' invalid_ann_assign_target ')'")); - _res = a; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_ann_assign_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' invalid_ann_assign_target ')'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_raise_stmt: 'raise' 'from' | 'raise' expression 'from' -static void * -invalid_raise_stmt_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'raise' 'from' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise' 'from'")); - Token * a; - Token * b; - if ( - (a = _PyPegen_expect_token(p, 632)) // token='raise' - && - (b = _PyPegen_expect_token(p, 650)) // token='from' - ) - { - D(fprintf(stderr, "%*c+ invalid_raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' 'from'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "did you forget an expression between 'raise' and 'from'?" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise' 'from'")); - } - { // 'raise' expression 'from' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise' expression 'from'")); - Token * _keyword; - Token * a; - expr_ty expression_var; - if ( - (_keyword = _PyPegen_expect_token(p, 632)) // token='raise' - && - (expression_var = expression_rule(p)) // expression - && - (a = _PyPegen_expect_token(p, 650)) // token='from' - ) - { - D(fprintf(stderr, "%*c+ invalid_raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression 'from'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "did you forget an expression after 'from'?" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise' expression 'from'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_del_stmt: 'del' star_expressions -static void * -invalid_del_stmt_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'del' star_expressions - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_del_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'del' star_expressions")); - Token * _keyword; - expr_ty a; - if ( - (_keyword = _PyPegen_expect_token(p, 634)) // token='del' - && - (a = star_expressions_rule(p)) // star_expressions - ) - { - D(fprintf(stderr, "%*c+ invalid_del_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'del' star_expressions")); - _res = RAISE_SYNTAX_ERROR_INVALID_TARGET ( DEL_TARGETS , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_del_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'del' star_expressions")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_assert_stmt: -// | 'assert' expression '=' expression -// | 'assert' expression ',' expression '=' expression -// | 'assert' expression ':=' expression -// | 'assert' expression ',' expression ':=' expression -static void * -invalid_assert_stmt_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'assert' expression '=' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_assert_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'assert' expression '=' expression")); - Token * _keyword; - Token * _literal; - expr_ty a; - expr_ty b; - if ( - (_keyword = _PyPegen_expect_token(p, 638)) // token='assert' - && - (a = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - && - (b = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_assert_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'assert' expression '=' expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot assign to %s here. Maybe you meant '==' instead of '='?" , _PyPegen_get_expr_name ( a ) ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_assert_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'assert' expression '=' expression")); - } - { // 'assert' expression ',' expression '=' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_assert_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'assert' expression ',' expression '=' expression")); - Token * _keyword; - Token * _literal; - Token * _literal_1; - expr_ty a; - expr_ty b; - expr_ty expression_var; - if ( - (_keyword = _PyPegen_expect_token(p, 638)) // token='assert' - && - (expression_var = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (a = expression_rule(p)) // expression - && - (_literal_1 = _PyPegen_expect_token(p, 22)) // token='=' - && - (b = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_assert_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'assert' expression ',' expression '=' expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot assign to %s here. Maybe you meant '==' instead of '='?" , _PyPegen_get_expr_name ( a ) ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_assert_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'assert' expression ',' expression '=' expression")); - } - { // 'assert' expression ':=' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_assert_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'assert' expression ':=' expression")); - Token * _keyword; - Token * _literal; - expr_ty a; - expr_ty b; - if ( - (_keyword = _PyPegen_expect_token(p, 638)) // token='assert' - && - (a = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 53)) // token=':=' - && - (b = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_assert_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'assert' expression ':=' expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use named expression without parentheses here" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_assert_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'assert' expression ':=' expression")); - } - { // 'assert' expression ',' expression ':=' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_assert_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'assert' expression ',' expression ':=' expression")); - Token * _keyword; - Token * _literal; - Token * _literal_1; - expr_ty a; - expr_ty b; - expr_ty expression_var; - if ( - (_keyword = _PyPegen_expect_token(p, 638)) // token='assert' - && - (expression_var = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (a = expression_rule(p)) // expression - && - (_literal_1 = _PyPegen_expect_token(p, 53)) // token=':=' - && - (b = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_assert_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'assert' expression ',' expression ':=' expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use named expression without parentheses here" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_assert_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'assert' expression ',' expression ':=' expression")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_block: NEWLINE !INDENT -static void * -invalid_block_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT")); - Token * newline_var; - if ( - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_block[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE !INDENT")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_comprehension: -// | '[' '**' expression for_if_clauses -// | '(' '**' expression for_if_clauses -// | ('[' | '{') star_named_expression ',' star_named_expressions for_if_clauses -// | ('[' | '{') star_named_expression ',' for_if_clauses -static void * -invalid_comprehension_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '[' '**' expression for_if_clauses - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' '**' expression for_if_clauses")); - Token * _literal; - Token * a; - expr_ty b; - asdl_comprehension_seq* for_if_clauses_var; - if ( - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - && - (a = _PyPegen_expect_token(p, 35)) // token='**' - && - (b = expression_rule(p)) // expression - && - (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses - ) - { - D(fprintf(stderr, "%*c+ invalid_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' '**' expression for_if_clauses")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use dict unpacking in list comprehension" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_comprehension[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' '**' expression for_if_clauses")); - } - { // '(' '**' expression for_if_clauses - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' '**' expression for_if_clauses")); - Token * _literal; - Token * a; - expr_ty b; - asdl_comprehension_seq* for_if_clauses_var; - if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (a = _PyPegen_expect_token(p, 35)) // token='**' - && - (b = expression_rule(p)) // expression - && - (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses - ) - { - D(fprintf(stderr, "%*c+ invalid_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' '**' expression for_if_clauses")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use dict unpacking in generator expression" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_comprehension[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' '**' expression for_if_clauses")); - } - { // ('[' | '{') star_named_expression ',' star_named_expressions for_if_clauses - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '{') star_named_expression ',' star_named_expressions for_if_clauses")); - Token * _literal; - void *_tmp_123_var; - expr_ty a; - asdl_expr_seq* b; - asdl_comprehension_seq* for_if_clauses_var; - if ( - (_tmp_123_var = _tmp_123_rule(p)) // '[' | '{' - && - (a = star_named_expression_rule(p)) // star_named_expression - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (b = star_named_expressions_rule(p)) // star_named_expressions - && - (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses - ) - { - D(fprintf(stderr, "%*c+ invalid_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('[' | '{') star_named_expression ',' star_named_expressions for_if_clauses")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , PyPegen_last_item ( b , expr_ty ) , "did you forget parentheses around the comprehension target?" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_comprehension[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('[' | '{') star_named_expression ',' star_named_expressions for_if_clauses")); - } - { // ('[' | '{') star_named_expression ',' for_if_clauses - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '{') star_named_expression ',' for_if_clauses")); - void *_tmp_123_var; - expr_ty a; - Token * b; - asdl_comprehension_seq* for_if_clauses_var; - if ( - (_tmp_123_var = _tmp_123_rule(p)) // '[' | '{' - && - (a = star_named_expression_rule(p)) // star_named_expression - && - (b = _PyPegen_expect_token(p, 12)) // token=',' - && - (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses - ) - { - D(fprintf(stderr, "%*c+ invalid_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('[' | '{') star_named_expression ',' for_if_clauses")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "did you forget parentheses around the comprehension target?" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_comprehension[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('[' | '{') star_named_expression ',' for_if_clauses")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_parameters: -// | "/" ',' -// | (slash_no_default | slash_with_default) param_maybe_default* '/' -// | slash_no_default? param_no_default* invalid_parameters_helper param_no_default -// | param_no_default* '(' param_no_default+ ','? ')' -// | [(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/' -// | param_maybe_default+ '/' '*' -static void * -invalid_parameters_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // "/" ',' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"/\" ','")); - Token * _literal; - Token * a; - if ( - (a = _PyPegen_expect_token(p, 17)) // token='/' - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"/\" ','")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "at least one parameter must precede /" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"/\" ','")); - } - { // (slash_no_default | slash_with_default) param_maybe_default* '/' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(slash_no_default | slash_with_default) param_maybe_default* '/'")); - asdl_seq * _loop0_31_var; - void *_tmp_124_var; - Token * a; - if ( - (_tmp_124_var = _tmp_124_rule(p)) // slash_no_default | slash_with_default - && - (_loop0_31_var = _loop0_31_rule(p)) // param_maybe_default* - && - (a = _PyPegen_expect_token(p, 17)) // token='/' - ) - { - D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(slash_no_default | slash_with_default) param_maybe_default* '/'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "/ may appear only once" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(slash_no_default | slash_with_default) param_maybe_default* '/'")); - } - { // slash_no_default? param_no_default* invalid_parameters_helper param_no_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default? param_no_default* invalid_parameters_helper param_no_default")); - asdl_seq * _loop0_27_var; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - arg_ty a; - void *invalid_parameters_helper_var; - if ( - (_opt_var = slash_no_default_rule(p), !p->error_indicator) // slash_no_default? - && - (_loop0_27_var = _loop0_27_rule(p)) // param_no_default* - && - (invalid_parameters_helper_var = invalid_parameters_helper_rule(p)) // invalid_parameters_helper - && - (a = param_no_default_rule(p)) // param_no_default - ) - { - D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default? param_no_default* invalid_parameters_helper param_no_default")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "parameter without a default follows parameter with a default" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default? param_no_default* invalid_parameters_helper param_no_default")); - } - { // param_no_default* '(' param_no_default+ ','? ')' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* '(' param_no_default+ ','? ')'")); - asdl_seq * _loop0_27_var; - asdl_seq * _loop1_29_var; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * a; - Token * b; - if ( - (_loop0_27_var = _loop0_27_rule(p)) // param_no_default* - && - (a = _PyPegen_expect_token(p, 7)) // token='(' - && - (_loop1_29_var = _loop1_29_rule(p)) // param_no_default+ - && - (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? - && - (b = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* '(' param_no_default+ ','? ')'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "Function parameters cannot be parenthesized" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* '(' param_no_default+ ','? ')'")); - } - { // [(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "[(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/'")); - Token * _literal; - asdl_seq * _loop0_31_var; - asdl_seq * _loop0_31_var_1; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_tmp_125_var; - Token * a; - if ( - (_opt_var = _tmp_124_rule(p), !p->error_indicator) // [(slash_no_default | slash_with_default)] - && - (_loop0_31_var = _loop0_31_rule(p)) // param_maybe_default* - && - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_125_var = _tmp_125_rule(p)) // ',' | param_no_default - && - (_loop0_31_var_1 = _loop0_31_rule(p)) // param_maybe_default* - && - (a = _PyPegen_expect_token(p, 17)) // token='/' - ) - { - D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "[(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "/ must be ahead of *" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "[(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/'")); - } - { // param_maybe_default+ '/' '*' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default+ '/' '*'")); - Token * _literal; - asdl_seq * _loop1_32_var; - Token * a; - if ( - (_loop1_32_var = _loop1_32_rule(p)) // param_maybe_default+ - && - (_literal = _PyPegen_expect_token(p, 17)) // token='/' - && - (a = _PyPegen_expect_token(p, 16)) // token='*' - ) - { - D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_maybe_default+ '/' '*'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expected comma between / and *" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default+ '/' '*'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_default: '=' &(')' | ',') -static void * -invalid_default_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '=' &(')' | ',') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' &(')' | ',')")); - Token * a; - if ( - (a = _PyPegen_expect_token(p, 22)) // token='=' - && - _PyPegen_lookahead(1, _tmp_126_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' &(')' | ',')")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expected default value expression" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' &(')' | ',')")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_star_etc: -// | '*' (')' | ',' (')' | '**')) -// | '*' ',' TYPE_COMMENT -// | '*' param '=' -// | '*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',') -static void * -invalid_star_etc_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '*' (')' | ',' (')' | '**')) - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); - void *_tmp_127_var; - Token * a; - if ( - (a = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_127_var = _tmp_127_rule(p)) // ')' | ',' (')' | '**') - ) - { - D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "named parameters must follow bare *" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); - } - { // '*' ',' TYPE_COMMENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT")); - Token * _literal; - Token * _literal_1; - Token * type_comment_var; - if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' - && - (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' - ) - { - D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT")); - _res = RAISE_SYNTAX_ERROR ( "bare * has associated type comment" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' TYPE_COMMENT")); - } - { // '*' param '=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' param '='")); - Token * _literal; - Token * a; - arg_ty param_var; - if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (param_var = param_rule(p)) // param - && - (a = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' param '='")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "var-positional parameter cannot have default value" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' param '='")); - } - { // '*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',')")); - Token * _literal; - asdl_seq * _loop0_31_var; - void *_tmp_128_var; - void *_tmp_128_var_1; - Token * a; - if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_128_var = _tmp_128_rule(p)) // param_no_default | ',' - && - (_loop0_31_var = _loop0_31_rule(p)) // param_maybe_default* - && - (a = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_128_var_1 = _tmp_128_rule(p)) // param_no_default | ',' - ) - { - D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',')")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "* may appear only once" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',')")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_kwds: '**' param '=' | '**' param ',' param | '**' param ',' ('*' | '**' | '/') -static void * -invalid_kwds_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '**' param '=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' param '='")); - Token * _literal; - Token * a; - arg_ty param_var; - if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' - && - (param_var = param_rule(p)) // param - && - (a = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ invalid_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' param '='")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "var-keyword parameter cannot have default value" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kwds[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' param '='")); - } - { // '**' param ',' param - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' param ',' param")); - Token * _literal; - Token * _literal_1; - arg_ty a; - arg_ty param_var; - if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' - && - (param_var = param_rule(p)) // param - && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' - && - (a = param_rule(p)) // param - ) - { - D(fprintf(stderr, "%*c+ invalid_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' param ',' param")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "parameters cannot follow var-keyword parameter" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kwds[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' param ',' param")); - } - { // '**' param ',' ('*' | '**' | '/') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' param ',' ('*' | '**' | '/')")); - Token * _literal; - Token * _literal_1; - Token* a; - arg_ty param_var; - if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' - && - (param_var = param_rule(p)) // param - && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' - && - (a = (Token*)_tmp_129_rule(p)) // '*' | '**' | '/' - ) - { - D(fprintf(stderr, "%*c+ invalid_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' param ',' ('*' | '**' | '/')")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "parameters cannot follow var-keyword parameter" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kwds[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' param ',' ('*' | '**' | '/')")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_parameters_helper: slash_with_default | param_with_default+ -static void * -invalid_parameters_helper_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // slash_with_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); - SlashWithDefault* a; - if ( - (a = slash_with_default_rule(p)) // slash_with_default - ) - { - D(fprintf(stderr, "%*c+ invalid_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); - _res = _PyPegen_singleton_seq ( p , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_parameters_helper[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); - } - { // param_with_default+ - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - asdl_seq * _loop1_30_var; - if ( - (_loop1_30_var = _loop1_30_rule(p)) // param_with_default+ - ) - { - D(fprintf(stderr, "%*c+ invalid_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - _res = _loop1_30_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_parameters_helper[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_lambda_parameters: -// | "/" ',' -// | (lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/' -// | lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default -// | lambda_param_no_default* '(' ','.lambda_param+ ','? ')' -// | [(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/' -// | lambda_param_maybe_default+ '/' '*' -static void * -invalid_lambda_parameters_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // "/" ',' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"/\" ','")); - Token * _literal; - Token * a; - if ( - (a = _PyPegen_expect_token(p, 17)) // token='/' - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"/\" ','")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "at least one parameter must precede /" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"/\" ','")); - } - { // (lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'")); - asdl_seq * _loop0_76_var; - void *_tmp_130_var; - Token * a; - if ( - (_tmp_130_var = _tmp_130_rule(p)) // lambda_slash_no_default | lambda_slash_with_default - && - (_loop0_76_var = _loop0_76_rule(p)) // lambda_param_maybe_default* - && - (a = _PyPegen_expect_token(p, 17)) // token='/' - ) - { - D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "/ may appear only once" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'")); - } - { // lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default")); - asdl_seq * _loop0_72_var; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - arg_ty a; - void *invalid_lambda_parameters_helper_var; - if ( - (_opt_var = lambda_slash_no_default_rule(p), !p->error_indicator) // lambda_slash_no_default? - && - (_loop0_72_var = _loop0_72_rule(p)) // lambda_param_no_default* - && - (invalid_lambda_parameters_helper_var = invalid_lambda_parameters_helper_rule(p)) // invalid_lambda_parameters_helper - && - (a = lambda_param_no_default_rule(p)) // lambda_param_no_default - ) - { - D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "parameter without a default follows parameter with a default" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default")); - } - { // lambda_param_no_default* '(' ','.lambda_param+ ','? ')' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* '(' ','.lambda_param+ ','? ')'")); - asdl_seq * _gather_132_var; - asdl_seq * _loop0_72_var; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * a; - Token * b; - if ( - (_loop0_72_var = _loop0_72_rule(p)) // lambda_param_no_default* - && - (a = _PyPegen_expect_token(p, 7)) // token='(' - && - (_gather_132_var = _gather_132_rule(p)) // ','.lambda_param+ - && - (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? - && - (b = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* '(' ','.lambda_param+ ','? ')'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "Lambda expression parameters cannot be parenthesized" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* '(' ','.lambda_param+ ','? ')'")); - } - { // [(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "[(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/'")); - Token * _literal; - asdl_seq * _loop0_76_var; - asdl_seq * _loop0_76_var_1; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_tmp_133_var; - Token * a; - if ( - (_opt_var = _tmp_130_rule(p), !p->error_indicator) // [(lambda_slash_no_default | lambda_slash_with_default)] - && - (_loop0_76_var = _loop0_76_rule(p)) // lambda_param_maybe_default* - && - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_133_var = _tmp_133_rule(p)) // ',' | lambda_param_no_default - && - (_loop0_76_var_1 = _loop0_76_rule(p)) // lambda_param_maybe_default* - && - (a = _PyPegen_expect_token(p, 17)) // token='/' - ) - { - D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "[(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "/ must be ahead of *" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "[(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/'")); - } - { // lambda_param_maybe_default+ '/' '*' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default+ '/' '*'")); - Token * _literal; - asdl_seq * _loop1_77_var; - Token * a; - if ( - (_loop1_77_var = _loop1_77_rule(p)) // lambda_param_maybe_default+ - && - (_literal = _PyPegen_expect_token(p, 17)) // token='/' - && - (a = _PyPegen_expect_token(p, 16)) // token='*' - ) - { - D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default+ '/' '*'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expected comma between / and *" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default+ '/' '*'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_lambda_parameters_helper: -// | lambda_slash_with_default -// | lambda_param_with_default+ -static void * -invalid_lambda_parameters_helper_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // lambda_slash_with_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_lambda_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); - SlashWithDefault* a; - if ( - (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default - ) - { - D(fprintf(stderr, "%*c+ invalid_lambda_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); - _res = _PyPegen_singleton_seq ( p , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_lambda_parameters_helper[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default")); - } - { // lambda_param_with_default+ - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_lambda_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); - asdl_seq * _loop1_75_var; - if ( - (_loop1_75_var = _loop1_75_rule(p)) // lambda_param_with_default+ - ) - { - D(fprintf(stderr, "%*c+ invalid_lambda_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); - _res = _loop1_75_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_lambda_parameters_helper[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default+")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_lambda_star_etc: -// | '*' (':' | ',' (':' | '**')) -// | '*' lambda_param '=' -// | '*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',') -static void * -invalid_lambda_star_etc_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '*' (':' | ',' (':' | '**')) - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); - Token * _literal; - void *_tmp_134_var; - if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_134_var = _tmp_134_rule(p)) // ':' | ',' (':' | '**') - ) - { - D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); - _res = RAISE_SYNTAX_ERROR ( "named parameters must follow bare *" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); - } - { // '*' lambda_param '=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' lambda_param '='")); - Token * _literal; - Token * a; - arg_ty lambda_param_var; - if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (lambda_param_var = lambda_param_rule(p)) // lambda_param - && - (a = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' lambda_param '='")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "var-positional parameter cannot have default value" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' lambda_param '='")); - } - { // '*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',')")); - Token * _literal; - asdl_seq * _loop0_76_var; - void *_tmp_135_var; - void *_tmp_135_var_1; - Token * a; - if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_135_var = _tmp_135_rule(p)) // lambda_param_no_default | ',' - && - (_loop0_76_var = _loop0_76_rule(p)) // lambda_param_maybe_default* - && - (a = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_135_var_1 = _tmp_135_rule(p)) // lambda_param_no_default | ',' - ) - { - D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',')")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "* may appear only once" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',')")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_lambda_kwds: -// | '**' lambda_param '=' -// | '**' lambda_param ',' lambda_param -// | '**' lambda_param ',' ('*' | '**' | '/') -static void * -invalid_lambda_kwds_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '**' lambda_param '=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_lambda_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' lambda_param '='")); - Token * _literal; - Token * a; - arg_ty lambda_param_var; - if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' - && - (lambda_param_var = lambda_param_rule(p)) // lambda_param - && - (a = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ invalid_lambda_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' lambda_param '='")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "var-keyword parameter cannot have default value" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_lambda_kwds[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' lambda_param '='")); - } - { // '**' lambda_param ',' lambda_param - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_lambda_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' lambda_param ',' lambda_param")); - Token * _literal; - Token * _literal_1; - arg_ty a; - arg_ty lambda_param_var; - if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' - && - (lambda_param_var = lambda_param_rule(p)) // lambda_param - && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' - && - (a = lambda_param_rule(p)) // lambda_param - ) - { - D(fprintf(stderr, "%*c+ invalid_lambda_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' lambda_param ',' lambda_param")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "parameters cannot follow var-keyword parameter" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_lambda_kwds[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' lambda_param ',' lambda_param")); - } - { // '**' lambda_param ',' ('*' | '**' | '/') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_lambda_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' lambda_param ',' ('*' | '**' | '/')")); - Token * _literal; - Token * _literal_1; - Token* a; - arg_ty lambda_param_var; - if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' - && - (lambda_param_var = lambda_param_rule(p)) // lambda_param - && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' - && - (a = (Token*)_tmp_129_rule(p)) // '*' | '**' | '/' - ) - { - D(fprintf(stderr, "%*c+ invalid_lambda_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' lambda_param ',' ('*' | '**' | '/')")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "parameters cannot follow var-keyword parameter" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_lambda_kwds[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' lambda_param ',' ('*' | '**' | '/')")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT -static void * -invalid_double_type_comments_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_double_type_comments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); - Token * indent_var; - Token * newline_var; - Token * newline_var_1; - Token * type_comment_var; - Token * type_comment_var_1; - if ( - (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - (type_comment_var_1 = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' - && - (newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' - ) - { - D(fprintf(stderr, "%*c+ invalid_double_type_comments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); - _res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_double_type_comments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_with_item: expression 'as' expression &(',' | ')' | ':') -static void * -invalid_with_item_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // expression 'as' expression &(',' | ')' | ':') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_with_item[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression 'as' expression &(',' | ')' | ':')")); - Token * _keyword; - expr_ty a; - expr_ty expression_var; - if ( - (expression_var = expression_rule(p)) // expression - && - (_keyword = _PyPegen_expect_token(p, 698)) // token='as' - && - (a = expression_rule(p)) // expression - && - _PyPegen_lookahead(1, _tmp_35_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_with_item[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression 'as' expression &(',' | ')' | ':')")); - _res = RAISE_SYNTAX_ERROR_INVALID_TARGET ( STAR_TARGETS , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_with_item[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression 'as' expression &(',' | ')' | ':')")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_for_if_clause: 'async'? 'for' (bitwise_or ((',' bitwise_or))* ','?) !'in' -static void * -invalid_for_if_clause_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'async'? 'for' (bitwise_or ((',' bitwise_or))* ','?) !'in' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_for_if_clause[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'for' (bitwise_or ((',' bitwise_or))* ','?) !'in'")); - Token * _keyword; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_tmp_136_var; - if ( - (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator) // 'async'? - && - (_keyword = _PyPegen_expect_token(p, 712)) // token='for' - && - (_tmp_136_var = _tmp_136_rule(p)) // bitwise_or ((',' bitwise_or))* ','? - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 713) // token='in' - ) - { - D(fprintf(stderr, "%*c+ invalid_for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'for' (bitwise_or ((',' bitwise_or))* ','?) !'in'")); - _res = RAISE_SYNTAX_ERROR ( "'in' expected after for-loop variables" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_for_if_clause[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'for' (bitwise_or ((',' bitwise_or))* ','?) !'in'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_for_target: 'async'? 'for' star_expressions -static void * -invalid_for_target_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'async'? 'for' star_expressions - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_for_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'for' star_expressions")); - Token * _keyword; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty a; - if ( - (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator) // 'async'? - && - (_keyword = _PyPegen_expect_token(p, 712)) // token='for' - && - (a = star_expressions_rule(p)) // star_expressions - ) - { - D(fprintf(stderr, "%*c+ invalid_for_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'for' star_expressions")); - _res = RAISE_SYNTAX_ERROR_INVALID_TARGET ( FOR_TARGETS , a ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_for_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'for' star_expressions")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_group: '(' starred_expression ')' | '(' '**' expression ')' -static void * -invalid_group_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '(' starred_expression ')' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_group[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' starred_expression ')'")); - Token * _literal; - Token * _literal_1; - expr_ty a; - if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (a = starred_expression_rule(p)) // starred_expression - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ invalid_group[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' starred_expression ')'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use starred expression here" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_group[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' starred_expression ')'")); - } - { // '(' '**' expression ')' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_group[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' '**' expression ')'")); - Token * _literal; - Token * _literal_1; - Token * a; - expr_ty expression_var; - if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (a = _PyPegen_expect_token(p, 35)) // token='**' - && - (expression_var = expression_rule(p)) // expression - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ invalid_group[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' '**' expression ')'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use double starred expression here" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_group[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' '**' expression ')'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_import: 'import' ','.dotted_name+ 'from' dotted_name | 'import' NEWLINE -static void * -invalid_import_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'import' ','.dotted_name+ 'from' dotted_name - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_import[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import' ','.dotted_name+ 'from' dotted_name")); - asdl_seq * _gather_138_var; - Token * _keyword; - Token * a; - expr_ty dotted_name_var; - if ( - (a = _PyPegen_expect_token(p, 651)) // token='import' - && - (_gather_138_var = _gather_138_rule(p)) // ','.dotted_name+ - && - (_keyword = _PyPegen_expect_token(p, 650)) // token='from' - && - (dotted_name_var = dotted_name_rule(p)) // dotted_name - ) - { - D(fprintf(stderr, "%*c+ invalid_import[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import' ','.dotted_name+ 'from' dotted_name")); - _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( a , "Did you mean to use 'from ... import ...' instead?" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_import[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import' ','.dotted_name+ 'from' dotted_name")); - } - { // 'import' NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_import[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import' NEWLINE")); - Token * _keyword; - Token * token; - if ( - (_keyword = _PyPegen_expect_token(p, 651)) // token='import' - && - (token = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ invalid_import[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import' NEWLINE")); - _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( token , "Expected one or more names after 'import'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_import[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import' NEWLINE")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_dotted_as_name: dotted_name 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression -static void * -invalid_dotted_as_name_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // dotted_name 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_dotted_as_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_name 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression")); - Token * _keyword; - expr_ty a; - expr_ty dotted_name_var; - if ( - (dotted_name_var = dotted_name_rule(p)) // dotted_name - && - (_keyword = _PyPegen_expect_token(p, 698)) // token='as' - && - _PyPegen_lookahead(0, _tmp_139_rule, p) - && - (a = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_dotted_as_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_name 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use %s as import target" , _PyPegen_get_expr_name ( a ) ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_dotted_as_name[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_name 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_import_from_as_name: NAME 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression -static void * -invalid_import_from_as_name_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // NAME 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_import_from_as_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression")); - Token * _keyword; - expr_ty a; - expr_ty name_var; - if ( - (name_var = _PyPegen_name_token(p)) // NAME - && - (_keyword = _PyPegen_expect_token(p, 698)) // token='as' - && - _PyPegen_lookahead(0, _tmp_139_rule, p) - && - (a = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_import_from_as_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use %s as import target" , _PyPegen_get_expr_name ( a ) ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_import_from_as_name[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_import_from: -// | 'from' (('.' | '...'))* dotted_name "lazy" 'import' import_from_targets -static void * -invalid_import_from_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'from' (('.' | '...'))* dotted_name "lazy" 'import' import_from_targets - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))* dotted_name \"lazy\" 'import' import_from_targets")); - Token * _keyword; - Token * _keyword_1; - asdl_seq * _loop0_17_var; - expr_ty a; - expr_ty dotted_name_var; - asdl_alias_seq* import_from_targets_var; - if ( - (_keyword = _PyPegen_expect_token(p, 650)) // token='from' - && - (_loop0_17_var = _loop0_17_rule(p)) // (('.' | '...'))* - && - (dotted_name_var = dotted_name_rule(p)) // dotted_name - && - (a = _PyPegen_expect_soft_keyword(p, "lazy")) // soft_keyword='"lazy"' - && - (_keyword_1 = _PyPegen_expect_token(p, 651)) // token='import' - && - (import_from_targets_var = import_from_targets_rule(p)) // import_from_targets - ) - { - D(fprintf(stderr, "%*c+ invalid_import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))* dotted_name \"lazy\" 'import' import_from_targets")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "use 'lazy from ... ' instead of 'from ... lazy import'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_import_from[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' (('.' | '...'))* dotted_name \"lazy\" 'import' import_from_targets")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_import_from_targets: import_from_as_names ',' NEWLINE | NEWLINE -static void * -invalid_import_from_targets_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // import_from_as_names ',' NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_names ',' NEWLINE")); - Token * _literal; - asdl_alias_seq* import_from_as_names_var; - Token * newline_var; - if ( - (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ invalid_import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_names ',' NEWLINE")); - _res = RAISE_SYNTAX_ERROR ( "trailing comma not allowed without surrounding parentheses" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_names ',' NEWLINE")); - } - { // NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); - Token * token; - if ( - (token = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ invalid_import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); - _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( token , "Expected one or more names after 'import'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_with_stmt: -// | 'async'? 'with' ','.(expression ['as' star_target])+ ',' ':' -// | 'async'? 'with' ','.(expression ['as' star_target])+ NEWLINE -// | 'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE -static void * -invalid_with_stmt_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'async'? 'with' ','.(expression ['as' star_target])+ ',' ':' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ ',' ':'")); - asdl_seq * _gather_141_var; - Token * _keyword; - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * trailing; - if ( - (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator) // 'async'? - && - (_keyword = _PyPegen_expect_token(p, 665)) // token='with' - && - (_gather_141_var = _gather_141_rule(p)) // ','.(expression ['as' star_target])+ - && - (trailing = _PyPegen_expect_token(p, 12)) // token=',' - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ invalid_with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ ',' ':'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( trailing , "the last 'with' item has a trailing comma" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_with_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ ',' ':'")); - } - { // 'async'? 'with' ','.(expression ['as' star_target])+ NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ NEWLINE")); - asdl_seq * _gather_141_var; - Token * _keyword; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * newline_var; - if ( - (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator) // 'async'? - && - (_keyword = _PyPegen_expect_token(p, 665)) // token='with' - && - (_gather_141_var = _gather_141_rule(p)) // ','.(expression ['as' star_target])+ - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ invalid_with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ NEWLINE")); - _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_with_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ NEWLINE")); - } - { // 'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE")); - asdl_seq * _gather_143_var; - Token * _keyword; - Token * _literal; - Token * _literal_1; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_opt_var_1; - UNUSED(_opt_var_1); // Silence compiler warnings - Token * newline_var; - if ( - (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator) // 'async'? - && - (_keyword = _PyPegen_expect_token(p, 665)) // token='with' - && - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (_gather_143_var = _gather_143_rule(p)) // ','.(expressions ['as' star_target])+ - && - (_opt_var_1 = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ invalid_with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE")); - _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_with_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_with_stmt_indent: -// | 'async'? 'with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT -// | 'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' ':' NEWLINE !INDENT -static void * -invalid_with_stmt_indent_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'async'? 'with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_with_stmt_indent[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT")); - asdl_seq * _gather_141_var; - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * a; - Token * newline_var; - if ( - (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator) // 'async'? - && - (a = _PyPegen_expect_token(p, 665)) // token='with' - && - (_gather_141_var = _gather_141_rule(p)) // ','.(expression ['as' star_target])+ - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_with_stmt_indent[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'with' statement on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_with_stmt_indent[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT")); - } - { // 'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_with_stmt_indent[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' ':' NEWLINE !INDENT")); - asdl_seq * _gather_143_var; - Token * _literal; - Token * _literal_1; - Token * _literal_2; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_opt_var_1; - UNUSED(_opt_var_1); // Silence compiler warnings - Token * a; - Token * newline_var; - if ( - (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator) // 'async'? - && - (a = _PyPegen_expect_token(p, 665)) // token='with' - && - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (_gather_143_var = _gather_143_rule(p)) // ','.(expressions ['as' star_target])+ - && - (_opt_var_1 = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' - && - (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_with_stmt_indent[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'with' statement on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_with_stmt_indent[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' ':' NEWLINE !INDENT")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_try_stmt: -// | 'try' ':' NEWLINE !INDENT -// | 'try' ':' block !('except' | 'finally') -// | 'try' ':' block* except_block+ 'except' '*' expression ['as' NAME] ':' -// | 'try' ':' block* except_star_block+ 'except' [expression ['as' NAME]] ':' -static void * -invalid_try_stmt_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'try' ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_try_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'try' ':' NEWLINE !INDENT")); - Token * _literal; - Token * a; - Token * newline_var; - if ( - (a = _PyPegen_expect_token(p, 674)) // token='try' - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'try' statement on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_try_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' ':' NEWLINE !INDENT")); - } - { // 'try' ':' block !('except' | 'finally') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_try_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'try' ':' block !('except' | 'finally')")); - Token * _keyword; - Token * _literal; - asdl_stmt_seq* block_var; - if ( - (_keyword = _PyPegen_expect_token(p, 674)) // token='try' - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (block_var = block_rule(p)) // block - && - _PyPegen_lookahead(0, _tmp_144_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' ':' block !('except' | 'finally')")); - _res = RAISE_SYNTAX_ERROR ( "expected 'except' or 'finally' block" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_try_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' ':' block !('except' | 'finally')")); - } - { // 'try' ':' block* except_block+ 'except' '*' expression ['as' NAME] ':' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_try_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'try' ':' block* except_block+ 'except' '*' expression ['as' NAME] ':'")); - Token * _keyword; - Token * _literal; - Token * _literal_1; - asdl_seq * _loop0_145_var; - asdl_seq * _loop1_36_var; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * a; - Token * b; - expr_ty expression_var; - if ( - (_keyword = _PyPegen_expect_token(p, 674)) // token='try' - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (_loop0_145_var = _loop0_145_rule(p)) // block* - && - (_loop1_36_var = _loop1_36_rule(p)) // except_block+ - && - (a = _PyPegen_expect_token(p, 695)) // token='except' - && - (b = _PyPegen_expect_token(p, 16)) // token='*' - && - (expression_var = expression_rule(p)) // expression - && - (_opt_var = _tmp_21_rule(p), !p->error_indicator) // ['as' NAME] - && - (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ invalid_try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' ':' block* except_block+ 'except' '*' expression ['as' NAME] ':'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot have both 'except' and 'except*' on the same 'try'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_try_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' ':' block* except_block+ 'except' '*' expression ['as' NAME] ':'")); - } - { // 'try' ':' block* except_star_block+ 'except' [expression ['as' NAME]] ':' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_try_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'try' ':' block* except_star_block+ 'except' [expression ['as' NAME]] ':'")); - Token * _keyword; - Token * _literal; - Token * _literal_1; - asdl_seq * _loop0_145_var; - asdl_seq * _loop1_37_var; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * a; - if ( - (_keyword = _PyPegen_expect_token(p, 674)) // token='try' - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (_loop0_145_var = _loop0_145_rule(p)) // block* - && - (_loop1_37_var = _loop1_37_rule(p)) // except_star_block+ - && - (a = _PyPegen_expect_token(p, 695)) // token='except' - && - (_opt_var = _tmp_146_rule(p), !p->error_indicator) // [expression ['as' NAME]] - && - (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ invalid_try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' ':' block* except_star_block+ 'except' [expression ['as' NAME]] ':'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot have both 'except' and 'except*' on the same 'try'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_try_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' ':' block* except_star_block+ 'except' [expression ['as' NAME]] ':'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_except_stmt: -// | 'except' expression ',' expressions 'as' NAME ':' -// | 'except' expression ['as' NAME] NEWLINE -// | 'except' NEWLINE -// | 'except' expression 'as' expression ':' block -static void * -invalid_except_stmt_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'except' expression ',' expressions 'as' NAME ':' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_except_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' expression ',' expressions 'as' NAME ':'")); - Token * _keyword; - Token * _keyword_1; - Token * _literal; - Token * _literal_1; - expr_ty a; - expr_ty expressions_var; - expr_ty name_var; - if ( - (_keyword = _PyPegen_expect_token(p, 695)) // token='except' - && - (a = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (expressions_var = expressions_rule(p)) // expressions - && - (_keyword_1 = _PyPegen_expect_token(p, 698)) // token='as' - && - (name_var = _PyPegen_name_token(p)) // NAME - && - (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ invalid_except_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' expression ',' expressions 'as' NAME ':'")); - _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( a , "multiple exception types must be parenthesized when using 'as'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_except_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' expression ',' expressions 'as' NAME ':'")); - } - { // 'except' expression ['as' NAME] NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_except_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] NEWLINE")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * a; - expr_ty expression_var; - Token * newline_var; - if ( - (a = _PyPegen_expect_token(p, 695)) // token='except' - && - (expression_var = expression_rule(p)) // expression - && - (_opt_var = _tmp_21_rule(p), !p->error_indicator) // ['as' NAME] - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ invalid_except_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] NEWLINE")); - _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_except_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' expression ['as' NAME] NEWLINE")); - } - { // 'except' NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_except_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' NEWLINE")); - Token * a; - Token * newline_var; - if ( - (a = _PyPegen_expect_token(p, 695)) // token='except' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ invalid_except_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' NEWLINE")); - _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_except_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' NEWLINE")); - } - { // 'except' expression 'as' expression ':' block - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_except_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' expression 'as' expression ':' block")); - Token * _keyword; - Token * _keyword_1; - Token * _literal; - expr_ty a; - asdl_stmt_seq* block_var; - expr_ty expression_var; - if ( - (_keyword = _PyPegen_expect_token(p, 695)) // token='except' - && - (expression_var = expression_rule(p)) // expression - && - (_keyword_1 = _PyPegen_expect_token(p, 698)) // token='as' - && - (a = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (block_var = block_rule(p)) // block - ) - { - D(fprintf(stderr, "%*c+ invalid_except_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' expression 'as' expression ':' block")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use except statement with %s" , _PyPegen_get_expr_name ( a ) ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_except_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' expression 'as' expression ':' block")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_except_star_stmt: -// | 'except' '*' expression ',' expressions 'as' NAME ':' -// | 'except' '*' expression ['as' NAME] NEWLINE -// | 'except' '*' (NEWLINE | ':') -// | 'except' '*' expression 'as' expression ':' block -static void * -invalid_except_star_stmt_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'except' '*' expression ',' expressions 'as' NAME ':' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_except_star_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' '*' expression ',' expressions 'as' NAME ':'")); - Token * _keyword; - Token * _keyword_1; - Token * _literal; - Token * _literal_1; - Token * _literal_2; - expr_ty a; - expr_ty expressions_var; - expr_ty name_var; - if ( - (_keyword = _PyPegen_expect_token(p, 695)) // token='except' - && - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (a = expression_rule(p)) // expression - && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' - && - (expressions_var = expressions_rule(p)) // expressions - && - (_keyword_1 = _PyPegen_expect_token(p, 698)) // token='as' - && - (name_var = _PyPegen_name_token(p)) // NAME - && - (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ invalid_except_star_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' '*' expression ',' expressions 'as' NAME ':'")); - _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( a , "multiple exception types must be parenthesized when using 'as'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_except_star_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' '*' expression ',' expressions 'as' NAME ':'")); - } - { // 'except' '*' expression ['as' NAME] NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_except_star_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' '*' expression ['as' NAME] NEWLINE")); - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * a; - expr_ty expression_var; - Token * newline_var; - if ( - (a = _PyPegen_expect_token(p, 695)) // token='except' - && - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (expression_var = expression_rule(p)) // expression - && - (_opt_var = _tmp_21_rule(p), !p->error_indicator) // ['as' NAME] - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ invalid_except_star_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' '*' expression ['as' NAME] NEWLINE")); - _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_except_star_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' '*' expression ['as' NAME] NEWLINE")); - } - { // 'except' '*' (NEWLINE | ':') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_except_star_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' '*' (NEWLINE | ':')")); - Token * _literal; - void *_tmp_147_var; - Token * a; - if ( - (a = _PyPegen_expect_token(p, 695)) // token='except' - && - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_147_var = _tmp_147_rule(p)) // NEWLINE | ':' - ) - { - D(fprintf(stderr, "%*c+ invalid_except_star_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' '*' (NEWLINE | ':')")); - _res = RAISE_SYNTAX_ERROR ( "expected one or more exception types" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_except_star_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' '*' (NEWLINE | ':')")); - } - { // 'except' '*' expression 'as' expression ':' block - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_except_star_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' '*' expression 'as' expression ':' block")); - Token * _keyword; - Token * _keyword_1; - Token * _literal; - Token * _literal_1; - expr_ty a; - asdl_stmt_seq* block_var; - expr_ty expression_var; - if ( - (_keyword = _PyPegen_expect_token(p, 695)) // token='except' - && - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (expression_var = expression_rule(p)) // expression - && - (_keyword_1 = _PyPegen_expect_token(p, 698)) // token='as' - && - (a = expression_rule(p)) // expression - && - (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' - && - (block_var = block_rule(p)) // block - ) - { - D(fprintf(stderr, "%*c+ invalid_except_star_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' '*' expression 'as' expression ':' block")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use except* statement with %s" , _PyPegen_get_expr_name ( a ) ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_except_star_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' '*' expression 'as' expression ':' block")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_finally_stmt: 'finally' ':' NEWLINE !INDENT -static void * -invalid_finally_stmt_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'finally' ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_finally_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'finally' ':' NEWLINE !INDENT")); - Token * _literal; - Token * a; - Token * newline_var; - if ( - (a = _PyPegen_expect_token(p, 691)) // token='finally' - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_finally_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'finally' ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'finally' statement on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_finally_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'finally' ':' NEWLINE !INDENT")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_except_stmt_indent: -// | 'except' expression ['as' NAME] ':' NEWLINE !INDENT -// | 'except' ':' NEWLINE !INDENT -static void * -invalid_except_stmt_indent_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'except' expression ['as' NAME] ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_except_stmt_indent[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] ':' NEWLINE !INDENT")); - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * a; - expr_ty expression_var; - Token * newline_var; - if ( - (a = _PyPegen_expect_token(p, 695)) // token='except' - && - (expression_var = expression_rule(p)) // expression - && - (_opt_var = _tmp_21_rule(p), !p->error_indicator) // ['as' NAME] - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_except_stmt_indent[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'except' statement on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_except_stmt_indent[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' expression ['as' NAME] ':' NEWLINE !INDENT")); - } - { // 'except' ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_except_stmt_indent[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' ':' NEWLINE !INDENT")); - Token * _literal; - Token * a; - Token * newline_var; - if ( - (a = _PyPegen_expect_token(p, 695)) // token='except' - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_except_stmt_indent[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'except' statement on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_except_stmt_indent[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' ':' NEWLINE !INDENT")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_except_star_stmt_indent: -// | 'except' '*' expression ['as' NAME] ':' NEWLINE !INDENT -static void * -invalid_except_star_stmt_indent_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'except' '*' expression ['as' NAME] ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_except_star_stmt_indent[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' '*' expression ['as' NAME] ':' NEWLINE !INDENT")); - Token * _literal; - Token * _literal_1; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * a; - expr_ty expression_var; - Token * newline_var; - if ( - (a = _PyPegen_expect_token(p, 695)) // token='except' - && - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (expression_var = expression_rule(p)) // expression - && - (_opt_var = _tmp_21_rule(p), !p->error_indicator) // ['as' NAME] - && - (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_except_star_stmt_indent[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' '*' expression ['as' NAME] ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'except*' statement on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_except_star_stmt_indent[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' '*' expression ['as' NAME] ':' NEWLINE !INDENT")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_match_stmt: -// | "match" subject_expr NEWLINE -// | "match" subject_expr ':' NEWLINE !INDENT -// | "case" patterns guard? ':' block -static void * -invalid_match_stmt_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // "match" subject_expr NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"match\" subject_expr NEWLINE")); - expr_ty _keyword; - Token * newline_var; - expr_ty subject_expr_var; - if ( - (_keyword = _PyPegen_expect_soft_keyword(p, "match")) // soft_keyword='"match"' - && - (subject_expr_var = subject_expr_rule(p)) // subject_expr - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ invalid_match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"match\" subject_expr NEWLINE")); - _res = CHECK_VERSION ( void* , 10 , "Pattern matching is" , RAISE_SYNTAX_ERROR ( "expected ':'" ) ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_match_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"match\" subject_expr NEWLINE")); - } - { // "match" subject_expr ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"match\" subject_expr ':' NEWLINE !INDENT")); - Token * _literal; - expr_ty a; - Token * newline_var; - expr_ty subject; - if ( - (a = _PyPegen_expect_soft_keyword(p, "match")) // soft_keyword='"match"' - && - (subject = subject_expr_rule(p)) // subject_expr - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"match\" subject_expr ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'match' statement on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_match_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"match\" subject_expr ':' NEWLINE !INDENT")); - } - { // "case" patterns guard? ':' block - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? ':' block")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty a; - Token * b; - asdl_stmt_seq* block_var; - pattern_ty patterns_var; - if ( - (a = _PyPegen_expect_soft_keyword(p, "case")) // soft_keyword='"case"' - && - (patterns_var = patterns_rule(p)) // patterns - && - (_opt_var = guard_rule(p), !p->error_indicator) // guard? - && - (b = _PyPegen_expect_token(p, 11)) // token=':' - && - (block_var = block_rule(p)) // block - ) - { - D(fprintf(stderr, "%*c+ invalid_match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? ':' block")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "case statement must be inside match statement" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_match_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"case\" patterns guard? ':' block")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_case_block: -// | "case" patterns guard? NEWLINE -// | "case" patterns guard? ':' NEWLINE !INDENT -static void * -invalid_case_block_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // "case" patterns guard? NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_case_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? NEWLINE")); - expr_ty _keyword; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * newline_var; - pattern_ty patterns_var; - if ( - (_keyword = _PyPegen_expect_soft_keyword(p, "case")) // soft_keyword='"case"' - && - (patterns_var = patterns_rule(p)) // patterns - && - (_opt_var = guard_rule(p), !p->error_indicator) // guard? - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ invalid_case_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? NEWLINE")); - _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_case_block[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"case\" patterns guard? NEWLINE")); - } - { // "case" patterns guard? ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_case_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? ':' NEWLINE !INDENT")); - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty a; - Token * newline_var; - pattern_ty patterns_var; - if ( - (a = _PyPegen_expect_soft_keyword(p, "case")) // soft_keyword='"case"' - && - (patterns_var = patterns_rule(p)) // patterns - && - (_opt_var = guard_rule(p), !p->error_indicator) // guard? - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_case_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'case' statement on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_case_block[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"case\" patterns guard? ':' NEWLINE !INDENT")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_as_pattern: or_pattern 'as' "_" | or_pattern 'as' expression -static void * -invalid_as_pattern_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // or_pattern 'as' "_" - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_as_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' \"_\"")); - Token * _keyword; - expr_ty a; - pattern_ty or_pattern_var; - if ( - (or_pattern_var = or_pattern_rule(p)) // or_pattern - && - (_keyword = _PyPegen_expect_token(p, 698)) // token='as' - && - (a = _PyPegen_expect_soft_keyword(p, "_")) // soft_keyword='"_"' - ) - { - D(fprintf(stderr, "%*c+ invalid_as_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' \"_\"")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use '_' as a target" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_as_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "or_pattern 'as' \"_\"")); - } - { // or_pattern 'as' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_as_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' expression")); - Token * _keyword; - expr_ty a; - pattern_ty or_pattern_var; - if ( - (or_pattern_var = or_pattern_rule(p)) // or_pattern - && - (_keyword = _PyPegen_expect_token(p, 698)) // token='as' - && - (a = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_as_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use %s as pattern target" , _PyPegen_get_expr_name ( a ) ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_as_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "or_pattern 'as' expression")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_class_pattern: name_or_attr '(' invalid_class_argument_pattern -static void * -invalid_class_pattern_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // name_or_attr '(' invalid_class_argument_pattern - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' invalid_class_argument_pattern")); - Token * _literal; - asdl_pattern_seq* a; - expr_ty name_or_attr_var; - if ( - (name_or_attr_var = name_or_attr_rule(p)) // name_or_attr - && - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (a = invalid_class_argument_pattern_rule(p)) // invalid_class_argument_pattern - ) - { - D(fprintf(stderr, "%*c+ invalid_class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' invalid_class_argument_pattern")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( PyPegen_first_item ( a , pattern_ty ) , PyPegen_last_item ( a , pattern_ty ) , "positional patterns follow keyword patterns" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' invalid_class_argument_pattern")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_mapping_pattern: -// | '{' [(items_pattern ',')] double_star_pattern ',' items_pattern ','? '}' -static void * -invalid_mapping_pattern_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '{' [(items_pattern ',')] double_star_pattern ',' items_pattern ','? '}' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_mapping_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' [(items_pattern ',')] double_star_pattern ',' items_pattern ','? '}'")); - Token * _literal; - Token * _literal_1; - Token * _literal_2; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_opt_var_1; - UNUSED(_opt_var_1); // Silence compiler warnings - asdl_seq* items_pattern_var; - expr_ty rest; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (_opt_var = _tmp_148_rule(p), !p->error_indicator) // [(items_pattern ',')] - && - (rest = double_star_pattern_rule(p)) // double_star_pattern - && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' - && - (items_pattern_var = items_pattern_rule(p)) // items_pattern - && - (_opt_var_1 = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? - && - (_literal_2 = _PyPegen_expect_token(p, 26)) // token='}' - ) - { - D(fprintf(stderr, "%*c+ invalid_mapping_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' [(items_pattern ',')] double_star_pattern ',' items_pattern ','? '}'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( rest , "double star pattern must be the last (right-most) subpattern in the mapping pattern" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_mapping_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' [(items_pattern ',')] double_star_pattern ',' items_pattern ','? '}'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_class_argument_pattern: -// | [positional_patterns ','] keyword_patterns ',' positional_patterns -static asdl_pattern_seq* -invalid_class_argument_pattern_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_pattern_seq* _res = NULL; - int _mark = p->mark; - { // [positional_patterns ','] keyword_patterns ',' positional_patterns - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_class_argument_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "[positional_patterns ','] keyword_patterns ',' positional_patterns")); - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - asdl_pattern_seq* a; - asdl_seq* keyword_patterns_var; - if ( - (_opt_var = _tmp_149_rule(p), !p->error_indicator) // [positional_patterns ','] - && - (keyword_patterns_var = keyword_patterns_rule(p)) // keyword_patterns - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (a = positional_patterns_rule(p)) // positional_patterns - ) - { - D(fprintf(stderr, "%*c+ invalid_class_argument_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "[positional_patterns ','] keyword_patterns ',' positional_patterns")); - _res = a; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_class_argument_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "[positional_patterns ','] keyword_patterns ',' positional_patterns")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_if_stmt: -// | 'if' named_expression NEWLINE -// | 'if' named_expression ':' NEWLINE !INDENT -static void * -invalid_if_stmt_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'if' named_expression NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_if_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression NEWLINE")); - Token * _keyword; - expr_ty named_expression_var; - Token * newline_var; - if ( - (_keyword = _PyPegen_expect_token(p, 700)) // token='if' - && - (named_expression_var = named_expression_rule(p)) // named_expression - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ invalid_if_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression NEWLINE")); - _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_if_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression NEWLINE")); - } - { // 'if' named_expression ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_if_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' NEWLINE !INDENT")); - Token * _literal; - Token * a; - expr_ty a_1; - Token * newline_var; - if ( - (a = _PyPegen_expect_token(p, 700)) // token='if' - && - (a_1 = named_expression_rule(p)) // named_expression - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_if_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'if' statement on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_if_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression ':' NEWLINE !INDENT")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_elif_stmt: -// | 'elif' named_expression NEWLINE -// | 'elif' named_expression ':' NEWLINE !INDENT -static void * -invalid_elif_stmt_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'elif' named_expression NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_elif_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'elif' named_expression NEWLINE")); - Token * _keyword; - expr_ty named_expression_var; - Token * newline_var; - if ( - (_keyword = _PyPegen_expect_token(p, 705)) // token='elif' - && - (named_expression_var = named_expression_rule(p)) // named_expression - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ invalid_elif_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'elif' named_expression NEWLINE")); - _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_elif_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'elif' named_expression NEWLINE")); - } - { // 'elif' named_expression ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_elif_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' NEWLINE !INDENT")); - Token * _literal; - Token * a; - expr_ty named_expression_var; - Token * newline_var; - if ( - (a = _PyPegen_expect_token(p, 705)) // token='elif' - && - (named_expression_var = named_expression_rule(p)) // named_expression - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_elif_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'elif' statement on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_elif_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'elif' named_expression ':' NEWLINE !INDENT")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_else_stmt: 'else' ':' NEWLINE !INDENT | 'else' ':' block 'elif' -static void * -invalid_else_stmt_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'else' ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_else_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else' ':' NEWLINE !INDENT")); - Token * _literal; - Token * a; - Token * newline_var; - if ( - (a = _PyPegen_expect_token(p, 704)) // token='else' - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_else_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else' ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'else' statement on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_else_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'else' ':' NEWLINE !INDENT")); - } - { // 'else' ':' block 'elif' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_else_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else' ':' block 'elif'")); - Token * _keyword; - Token * _keyword_1; - Token * _literal; - asdl_stmt_seq* block_var; - if ( - (_keyword = _PyPegen_expect_token(p, 704)) // token='else' - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (block_var = block_rule(p)) // block - && - (_keyword_1 = _PyPegen_expect_token(p, 705)) // token='elif' - ) - { - D(fprintf(stderr, "%*c+ invalid_else_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else' ':' block 'elif'")); - _res = RAISE_SYNTAX_ERROR ( "'elif' block follows an 'else' block" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_else_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'else' ':' block 'elif'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_while_stmt: -// | 'while' named_expression NEWLINE -// | 'while' named_expression ':' NEWLINE !INDENT -static void * -invalid_while_stmt_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'while' named_expression NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_while_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'while' named_expression NEWLINE")); - Token * _keyword; - expr_ty named_expression_var; - Token * newline_var; - if ( - (_keyword = _PyPegen_expect_token(p, 707)) // token='while' - && - (named_expression_var = named_expression_rule(p)) // named_expression - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ invalid_while_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'while' named_expression NEWLINE")); - _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_while_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'while' named_expression NEWLINE")); - } - { // 'while' named_expression ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_while_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'while' named_expression ':' NEWLINE !INDENT")); - Token * _literal; - Token * a; - expr_ty named_expression_var; - Token * newline_var; - if ( - (a = _PyPegen_expect_token(p, 707)) // token='while' - && - (named_expression_var = named_expression_rule(p)) // named_expression - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_while_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'while' named_expression ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'while' statement on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_while_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'while' named_expression ':' NEWLINE !INDENT")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_for_stmt: -// | 'async'? 'for' star_targets 'in' star_expressions NEWLINE -// | 'async'? 'for' star_targets 'in' star_expressions ':' NEWLINE !INDENT -static void * -invalid_for_stmt_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'async'? 'for' star_targets 'in' star_expressions NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_for_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'for' star_targets 'in' star_expressions NEWLINE")); - Token * _keyword; - Token * _keyword_1; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * newline_var; - expr_ty star_expressions_var; - expr_ty star_targets_var; - if ( - (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator) // 'async'? - && - (_keyword = _PyPegen_expect_token(p, 712)) // token='for' - && - (star_targets_var = star_targets_rule(p)) // star_targets - && - (_keyword_1 = _PyPegen_expect_token(p, 713)) // token='in' - && - (star_expressions_var = star_expressions_rule(p)) // star_expressions - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ invalid_for_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'for' star_targets 'in' star_expressions NEWLINE")); - _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_for_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'for' star_targets 'in' star_expressions NEWLINE")); - } - { // 'async'? 'for' star_targets 'in' star_expressions ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_for_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'for' star_targets 'in' star_expressions ':' NEWLINE !INDENT")); - Token * _keyword; - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - Token * a; - Token * newline_var; - expr_ty star_expressions_var; - expr_ty star_targets_var; - if ( - (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator) // 'async'? - && - (a = _PyPegen_expect_token(p, 712)) // token='for' - && - (star_targets_var = star_targets_rule(p)) // star_targets - && - (_keyword = _PyPegen_expect_token(p, 713)) // token='in' - && - (star_expressions_var = star_expressions_rule(p)) // star_expressions - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_for_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'for' star_targets 'in' star_expressions ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'for' statement on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_for_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'for' star_targets 'in' star_expressions ':' NEWLINE !INDENT")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_def_raw: -// | 'async'? 'def' NAME type_params? '(' params? ')' ['->' expression] ':' NEWLINE !INDENT -// | 'async'? 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block -static void * -invalid_def_raw_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'async'? 'def' NAME type_params? '(' params? ')' ['->' expression] ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'def' NAME type_params? '(' params? ')' ['->' expression] ':' NEWLINE !INDENT")); - Token * _literal; - Token * _literal_1; - Token * _literal_2; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_opt_var_1; - UNUSED(_opt_var_1); // Silence compiler warnings - void *_opt_var_2; - UNUSED(_opt_var_2); // Silence compiler warnings - void *_opt_var_3; - UNUSED(_opt_var_3); // Silence compiler warnings - Token * a; - expr_ty name_var; - Token * newline_var; - if ( - (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator) // 'async'? - && - (a = _PyPegen_expect_token(p, 717)) // token='def' - && - (name_var = _PyPegen_name_token(p)) // NAME - && - (_opt_var_1 = type_params_rule(p), !p->error_indicator) // type_params? - && - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (_opt_var_2 = params_rule(p), !p->error_indicator) // params? - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' - && - (_opt_var_3 = _tmp_26_rule(p), !p->error_indicator) // ['->' expression] - && - (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'def' NAME type_params? '(' params? ')' ['->' expression] ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after function definition on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_def_raw[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'def' NAME type_params? '(' params? ')' ['->' expression] ':' NEWLINE !INDENT")); - } - { // 'async'? 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); - Token * _keyword; - Token * _literal; - Token * _literal_1; - Token * _literal_2; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_opt_var_1; - UNUSED(_opt_var_1); // Silence compiler warnings - void *_opt_var_2; - UNUSED(_opt_var_2); // Silence compiler warnings - void *_opt_var_3; - UNUSED(_opt_var_3); // Silence compiler warnings - void *_opt_var_4; - UNUSED(_opt_var_4); // Silence compiler warnings - asdl_stmt_seq* block_var; - expr_ty name_var; - if ( - (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator) // 'async'? - && - (_keyword = _PyPegen_expect_token(p, 717)) // token='def' - && - (name_var = _PyPegen_name_token(p)) // NAME - && - (_opt_var_1 = type_params_rule(p), !p->error_indicator) // type_params? - && - (_literal = _PyPegen_expect_forced_token(p, 7, "(")) // forced_token='(' - && - (_opt_var_2 = params_rule(p), !p->error_indicator) // params? - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' - && - (_opt_var_3 = _tmp_26_rule(p), !p->error_indicator) // ['->' expression] - && - (_literal_2 = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' - && - (_opt_var_4 = func_type_comment_rule(p), !p->error_indicator) // func_type_comment? - && - (block_var = block_rule(p)) // block - ) - { - D(fprintf(stderr, "%*c+ invalid_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); - _res = _PyPegen_dummy_name(p, _opt_var, _keyword, name_var, _opt_var_1, _literal, _opt_var_2, _literal_1, _opt_var_3, _literal_2, _opt_var_4, block_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_def_raw[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_class_def_raw: -// | 'class' NAME type_params? ['(' arguments? ')'] NEWLINE -// | 'class' NAME type_params? ['(' arguments? ')'] ':' NEWLINE !INDENT -static void * -invalid_class_def_raw_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'class' NAME type_params? ['(' arguments? ')'] NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_class_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class' NAME type_params? ['(' arguments? ')'] NEWLINE")); - Token * _keyword; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_opt_var_1; - UNUSED(_opt_var_1); // Silence compiler warnings - expr_ty name_var; - Token * newline_var; - if ( - (_keyword = _PyPegen_expect_token(p, 719)) // token='class' - && - (name_var = _PyPegen_name_token(p)) // NAME - && - (_opt_var = type_params_rule(p), !p->error_indicator) // type_params? - && - (_opt_var_1 = _tmp_25_rule(p), !p->error_indicator) // ['(' arguments? ')'] - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ invalid_class_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class' NAME type_params? ['(' arguments? ')'] NEWLINE")); - _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_class_def_raw[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class' NAME type_params? ['(' arguments? ')'] NEWLINE")); - } - { // 'class' NAME type_params? ['(' arguments? ')'] ':' NEWLINE !INDENT - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_class_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class' NAME type_params? ['(' arguments? ')'] ':' NEWLINE !INDENT")); - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_opt_var_1; - UNUSED(_opt_var_1); // Silence compiler warnings - Token * a; - expr_ty name_var; - Token * newline_var; - if ( - (a = _PyPegen_expect_token(p, 719)) // token='class' - && - (name_var = _PyPegen_name_token(p)) // NAME - && - (_opt_var = type_params_rule(p), !p->error_indicator) // type_params? - && - (_opt_var_1 = _tmp_25_rule(p), !p->error_indicator) // ['(' arguments? ')'] - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT - ) - { - D(fprintf(stderr, "%*c+ invalid_class_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class' NAME type_params? ['(' arguments? ')'] ':' NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block after class definition on line %d" , a -> lineno ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_class_def_raw[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class' NAME type_params? ['(' arguments? ')'] ':' NEWLINE !INDENT")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_double_starred_kvpairs: -// | invalid_kvpair_unpacking ','? -// | ','.double_starred_kvpair+ ',' (invalid_kvpair | invalid_kvpair_unpacking) -// | expression ':' &('}' | ',') -static void * -invalid_double_starred_kvpairs_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // invalid_kvpair_unpacking ','? - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kvpair_unpacking ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *invalid_kvpair_unpacking_var; - if ( - (invalid_kvpair_unpacking_var = invalid_kvpair_unpacking_rule(p)) // invalid_kvpair_unpacking - && - (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? - ) - { - D(fprintf(stderr, "%*c+ invalid_double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kvpair_unpacking ','?")); - _res = _PyPegen_dummy_name(p, invalid_kvpair_unpacking_var, _opt_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_double_starred_kvpairs[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kvpair_unpacking ','?")); - } - { // ','.double_starred_kvpair+ ',' (invalid_kvpair | invalid_kvpair_unpacking) - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ',' (invalid_kvpair | invalid_kvpair_unpacking)")); - asdl_seq * _gather_86_var; - Token * _literal; - void *_tmp_150_var; - if ( - (_gather_86_var = _gather_86_rule(p)) // ','.double_starred_kvpair+ - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (_tmp_150_var = _tmp_150_rule(p)) // invalid_kvpair | invalid_kvpair_unpacking - ) - { - D(fprintf(stderr, "%*c+ invalid_double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ',' (invalid_kvpair | invalid_kvpair_unpacking)")); - _res = _PyPegen_dummy_name(p, _gather_86_var, _literal, _tmp_150_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_double_starred_kvpairs[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.double_starred_kvpair+ ',' (invalid_kvpair | invalid_kvpair_unpacking)")); - } - { // expression ':' &('}' | ',') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' &('}' | ',')")); - Token * a; - expr_ty expression_var; - if ( - (expression_var = expression_rule(p)) // expression - && - (a = _PyPegen_expect_token(p, 11)) // token=':' - && - _PyPegen_lookahead(1, _tmp_151_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' &('}' | ',')")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expression expected after dictionary key and ':'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_double_starred_kvpairs[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' &('}' | ',')")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_kvpair_unpacking: -// | '**' if_expression -// | '*' bitwise_or ':' expression -// | '**' bitwise_or ':' expression -// | expression ':' '*' bitwise_or -// | expression ':' '**' bitwise_or -static void * -invalid_kvpair_unpacking_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '**' if_expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kvpair_unpacking[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' if_expression")); - Token * a; - expr_ty b; - if ( - (a = _PyPegen_expect_token(p, 35)) // token='**' - && - (b = if_expression_rule(p)) // if_expression - ) - { - D(fprintf(stderr, "%*c+ invalid_kvpair_unpacking[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' if_expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "invalid double starred expression. Did you forget to wrap the conditional expression in parentheses?" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kvpair_unpacking[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' if_expression")); - } - { // '*' bitwise_or ':' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kvpair_unpacking[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or ':' expression")); - Token * _literal; - Token * a; - expr_ty b; - expr_ty expression_var; - if ( - (a = _PyPegen_expect_token(p, 16)) // token='*' - && - (b = bitwise_or_rule(p)) // bitwise_or - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (expression_var = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_kvpair_unpacking[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or ':' expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use a starred expression in a dictionary key" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kvpair_unpacking[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' bitwise_or ':' expression")); - } - { // '**' bitwise_or ':' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kvpair_unpacking[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or ':' expression")); - Token * _literal; - Token * a; - expr_ty b; - expr_ty expression_var; - if ( - (a = _PyPegen_expect_token(p, 35)) // token='**' - && - (b = bitwise_or_rule(p)) // bitwise_or - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (expression_var = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_kvpair_unpacking[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or ':' expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use dict unpacking in a dictionary key" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kvpair_unpacking[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' bitwise_or ':' expression")); - } - { // expression ':' '*' bitwise_or - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kvpair_unpacking[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' '*' bitwise_or")); - Token * _literal; - Token * a; - expr_ty b; - expr_ty expression_var; - if ( - (expression_var = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (a = _PyPegen_expect_token(p, 16)) // token='*' - && - (b = bitwise_or_rule(p)) // bitwise_or - ) - { - D(fprintf(stderr, "%*c+ invalid_kvpair_unpacking[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' '*' bitwise_or")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use a starred expression in a dictionary value" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kvpair_unpacking[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' '*' bitwise_or")); - } - { // expression ':' '**' bitwise_or - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kvpair_unpacking[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' '**' bitwise_or")); - Token * _literal; - Token * a; - expr_ty b; - expr_ty expression_var; - if ( - (expression_var = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (a = _PyPegen_expect_token(p, 35)) // token='**' - && - (b = bitwise_or_rule(p)) // bitwise_or - ) - { - D(fprintf(stderr, "%*c+ invalid_kvpair_unpacking[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' '**' bitwise_or")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use dict unpacking in a dictionary value" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kvpair_unpacking[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' '**' bitwise_or")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_kvpair: -// | expression !(':') -// | expression ':' '*' bitwise_or -// | expression ':' '**' bitwise_or -// | expression ':' &('}' | ',') -static void * -invalid_kvpair_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // expression !(':') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !(':')")); - expr_ty a; - if ( - (a = expression_rule(p)) // expression - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 11) // token=(':') - ) - { - D(fprintf(stderr, "%*c+ invalid_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !(':')")); - _res = RAISE_ERROR_KNOWN_LOCATION ( p , PyExc_SyntaxError , a -> lineno , a -> end_col_offset - 1 , a -> end_lineno , - 1 , "':' expected after dictionary key" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kvpair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !(':')")); - } - { // expression ':' '*' bitwise_or - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' '*' bitwise_or")); - Token * _literal; - Token * a; - expr_ty bitwise_or_var; - expr_ty expression_var; - if ( - (expression_var = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (a = _PyPegen_expect_token(p, 16)) // token='*' - && - (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or - ) - { - D(fprintf(stderr, "%*c+ invalid_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' '*' bitwise_or")); - _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( a , "cannot use a starred expression in a dictionary value" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kvpair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' '*' bitwise_or")); - } - { // expression ':' '**' bitwise_or - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' '**' bitwise_or")); - Token * _literal; - Token * a; - expr_ty bitwise_or_var; - expr_ty expression_var; - if ( - (expression_var = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (a = _PyPegen_expect_token(p, 35)) // token='**' - && - (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or - ) - { - D(fprintf(stderr, "%*c+ invalid_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' '**' bitwise_or")); - _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( a , "cannot use dict unpacking in a dictionary value" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kvpair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' '**' bitwise_or")); - } - { // expression ':' &('}' | ',') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' &('}' | ',')")); - Token * a; - expr_ty expression_var; - if ( - (expression_var = expression_rule(p)) // expression - && - (a = _PyPegen_expect_token(p, 11)) // token=':' - && - _PyPegen_lookahead(1, _tmp_151_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' &('}' | ',')")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expression expected after dictionary key and ':'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kvpair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' &('}' | ',')")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_starred_expression_unpacking: '*' if_expression | '*' expression '=' expression -static void * -invalid_starred_expression_unpacking_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '*' if_expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_starred_expression_unpacking[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' if_expression")); - Token * a; - expr_ty b; - if ( - (a = _PyPegen_expect_token(p, 16)) // token='*' - && - (b = if_expression_rule(p)) // if_expression - ) - { - D(fprintf(stderr, "%*c+ invalid_starred_expression_unpacking[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' if_expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "invalid starred expression. Did you forget to wrap the conditional expression in parentheses?" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_starred_expression_unpacking[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' if_expression")); - } - { // '*' expression '=' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_starred_expression_unpacking[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression '=' expression")); - Token * _literal; - Token * a; - expr_ty b; - expr_ty expression_var; - if ( - (a = _PyPegen_expect_token(p, 16)) // token='*' - && - (expression_var = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - && - (b = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ invalid_starred_expression_unpacking[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression '=' expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot assign to iterable argument unpacking" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_starred_expression_unpacking[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression '=' expression")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_starred_expression_unpacking_sequence: -// | '**' bitwise_or -// | invalid_starred_expression_unpacking -static void * -invalid_starred_expression_unpacking_sequence_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '**' bitwise_or - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_starred_expression_unpacking_sequence[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or")); - Token * a; - expr_ty bitwise_or_var; - if ( - (a = _PyPegen_expect_token(p, 35)) // token='**' - && - (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or - ) - { - D(fprintf(stderr, "%*c+ invalid_starred_expression_unpacking_sequence[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use dict unpacking here" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_starred_expression_unpacking_sequence[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' bitwise_or")); - } - if (p->call_invalid_rules) { // invalid_starred_expression_unpacking - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_starred_expression_unpacking_sequence[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_starred_expression_unpacking")); - void *invalid_starred_expression_unpacking_var; - if ( - (invalid_starred_expression_unpacking_var = invalid_starred_expression_unpacking_rule(p)) // invalid_starred_expression_unpacking - ) - { - D(fprintf(stderr, "%*c+ invalid_starred_expression_unpacking_sequence[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_starred_expression_unpacking")); - _res = invalid_starred_expression_unpacking_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_starred_expression_unpacking_sequence[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_starred_expression_unpacking")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_starred_expression: '*' -static void * -invalid_starred_expression_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '*' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_starred_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - ) - { - D(fprintf(stderr, "%*c+ invalid_starred_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); - _res = RAISE_SYNTAX_ERROR ( "Invalid star expression" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_starred_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_fstring_replacement_field: -// | '{' '=' -// | '{' '!' -// | '{' ':' -// | '{' '}' -// | '{' !annotated_rhs -// | '{' annotated_rhs !('=' | '!' | ':' | '}') -// | '{' annotated_rhs '=' !('!' | ':' | '}') -// | '{' annotated_rhs '='? invalid_fstring_conversion_character -// | '{' annotated_rhs '='? ['!' NAME] !(':' | '}') -// | '{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}' -// | '{' annotated_rhs '='? ['!' NAME] !'}' -static void * -invalid_fstring_replacement_field_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '{' '=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '='")); - Token * _literal; - Token * a; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (a = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '='")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "f-string: valid expression required before '='" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '='")); - } - { // '{' '!' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '!'")); - Token * _literal; - Token * a; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (a = _PyPegen_expect_token(p, 54)) // token='!' - ) - { - D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '!'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "f-string: valid expression required before '!'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '!'")); - } - { // '{' ':' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' ':'")); - Token * _literal; - Token * a; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (a = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' ':'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "f-string: valid expression required before ':'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' ':'")); - } - { // '{' '}' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '}'")); - Token * _literal; - Token * a; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (a = _PyPegen_expect_token(p, 26)) // token='}' - ) - { - D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '}'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "f-string: valid expression required before '}'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '}'")); - } - { // '{' !annotated_rhs - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' !annotated_rhs")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - _PyPegen_lookahead_for_expr(0, annotated_rhs_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' !annotated_rhs")); - _res = RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting a valid expression after '{'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' !annotated_rhs")); - } - { // '{' annotated_rhs !('=' | '!' | ':' | '}') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs !('=' | '!' | ':' | '}')")); - Token * _literal; - expr_ty annotated_rhs_var; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs - && - _PyPegen_lookahead(0, _tmp_152_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs !('=' | '!' | ':' | '}')")); - _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting '=', or '!', or ':', or '}'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs !('=' | '!' | ':' | '}')")); - } - { // '{' annotated_rhs '=' !('!' | ':' | '}') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '=' !('!' | ':' | '}')")); - Token * _literal; - Token * _literal_1; - expr_ty annotated_rhs_var; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs - && - (_literal_1 = _PyPegen_expect_token(p, 22)) // token='=' - && - _PyPegen_lookahead(0, _tmp_153_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '=' !('!' | ':' | '}')")); - _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting '!', or ':', or '}'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '=' !('!' | ':' | '}')")); - } - { // '{' annotated_rhs '='? invalid_fstring_conversion_character - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? invalid_fstring_conversion_character")); - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty annotated_rhs_var; - void *invalid_fstring_conversion_character_var; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs - && - (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? - && - (invalid_fstring_conversion_character_var = invalid_fstring_conversion_character_rule(p)) // invalid_fstring_conversion_character - ) - { - D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? invalid_fstring_conversion_character")); - _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var, _opt_var, invalid_fstring_conversion_character_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? invalid_fstring_conversion_character")); - } - { // '{' annotated_rhs '='? ['!' NAME] !(':' | '}') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !(':' | '}')")); - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_opt_var_1; - UNUSED(_opt_var_1); // Silence compiler warnings - expr_ty annotated_rhs_var; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs - && - (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? - && - (_opt_var_1 = _tmp_154_rule(p), !p->error_indicator) // ['!' NAME] - && - _PyPegen_lookahead(0, _tmp_155_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !(':' | '}')")); - _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting ':' or '}'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !(':' | '}')")); - } - { // '{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}'")); - Token * _literal; - Token * _literal_1; - asdl_seq * _loop0_78_var; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_opt_var_1; - UNUSED(_opt_var_1); // Silence compiler warnings - expr_ty annotated_rhs_var; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs - && - (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? - && - (_opt_var_1 = _tmp_154_rule(p), !p->error_indicator) // ['!' NAME] - && - (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' - && - (_loop0_78_var = _loop0_78_rule(p)) // fstring_format_spec* - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 26) // token='}' - ) - { - D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}'")); - _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting '}', or format specs" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}'")); - } - { // '{' annotated_rhs '='? ['!' NAME] !'}' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !'}'")); - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_opt_var_1; - UNUSED(_opt_var_1); // Silence compiler warnings - expr_ty annotated_rhs_var; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs - && - (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? - && - (_opt_var_1 = _tmp_154_rule(p), !p->error_indicator) // ['!' NAME] - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 26) // token='}' - ) - { - D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !'}'")); - _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting '}'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !'}'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_fstring_conversion_character: '!' &(':' | '}') | '!' !NAME -static void * -invalid_fstring_conversion_character_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '!' &(':' | '}') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_fstring_conversion_character[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' &(':' | '}')")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 54)) // token='!' - && - _PyPegen_lookahead(1, _tmp_155_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_fstring_conversion_character[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' &(':' | '}')")); - _res = RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: missing conversion character" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_fstring_conversion_character[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!' &(':' | '}')")); - } - { // '!' !NAME - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_fstring_conversion_character[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' !NAME")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 54)) // token='!' - && - _PyPegen_lookahead_for_expr(0, _PyPegen_name_token, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_fstring_conversion_character[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' !NAME")); - _res = RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: invalid conversion character" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_fstring_conversion_character[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!' !NAME")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_tstring_replacement_field: -// | '{' '=' -// | '{' '!' -// | '{' ':' -// | '{' '}' -// | '{' !annotated_rhs -// | '{' annotated_rhs !('=' | '!' | ':' | '}') -// | '{' annotated_rhs '=' !('!' | ':' | '}') -// | '{' annotated_rhs '='? invalid_tstring_conversion_character -// | '{' annotated_rhs '='? ['!' NAME] !(':' | '}') -// | '{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}' -// | '{' annotated_rhs '='? ['!' NAME] !'}' -static void * -invalid_tstring_replacement_field_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '{' '=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '='")); - Token * _literal; - Token * a; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (a = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '='")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "t-string: valid expression required before '='" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '='")); - } - { // '{' '!' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '!'")); - Token * _literal; - Token * a; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (a = _PyPegen_expect_token(p, 54)) // token='!' - ) - { - D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '!'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "t-string: valid expression required before '!'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '!'")); - } - { // '{' ':' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' ':'")); - Token * _literal; - Token * a; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (a = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' ':'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "t-string: valid expression required before ':'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' ':'")); - } - { // '{' '}' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '}'")); - Token * _literal; - Token * a; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (a = _PyPegen_expect_token(p, 26)) // token='}' - ) - { - D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '}'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "t-string: valid expression required before '}'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '}'")); - } - { // '{' !annotated_rhs - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' !annotated_rhs")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - _PyPegen_lookahead_for_expr(0, annotated_rhs_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' !annotated_rhs")); - _res = RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: expecting a valid expression after '{'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' !annotated_rhs")); - } - { // '{' annotated_rhs !('=' | '!' | ':' | '}') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs !('=' | '!' | ':' | '}')")); - Token * _literal; - expr_ty annotated_rhs_var; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs - && - _PyPegen_lookahead(0, _tmp_152_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs !('=' | '!' | ':' | '}')")); - _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: expecting '=', or '!', or ':', or '}'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs !('=' | '!' | ':' | '}')")); - } - { // '{' annotated_rhs '=' !('!' | ':' | '}') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '=' !('!' | ':' | '}')")); - Token * _literal; - Token * _literal_1; - expr_ty annotated_rhs_var; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs - && - (_literal_1 = _PyPegen_expect_token(p, 22)) // token='=' - && - _PyPegen_lookahead(0, _tmp_153_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '=' !('!' | ':' | '}')")); - _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: expecting '!', or ':', or '}'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '=' !('!' | ':' | '}')")); - } - { // '{' annotated_rhs '='? invalid_tstring_conversion_character - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? invalid_tstring_conversion_character")); - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty annotated_rhs_var; - void *invalid_tstring_conversion_character_var; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs - && - (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? - && - (invalid_tstring_conversion_character_var = invalid_tstring_conversion_character_rule(p)) // invalid_tstring_conversion_character - ) - { - D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? invalid_tstring_conversion_character")); - _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var, _opt_var, invalid_tstring_conversion_character_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? invalid_tstring_conversion_character")); - } - { // '{' annotated_rhs '='? ['!' NAME] !(':' | '}') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !(':' | '}')")); - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_opt_var_1; - UNUSED(_opt_var_1); // Silence compiler warnings - expr_ty annotated_rhs_var; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs - && - (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? - && - (_opt_var_1 = _tmp_154_rule(p), !p->error_indicator) // ['!' NAME] - && - _PyPegen_lookahead(0, _tmp_155_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !(':' | '}')")); - _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: expecting ':' or '}'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !(':' | '}')")); - } - { // '{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}'")); - Token * _literal; - Token * _literal_1; - asdl_seq * _loop0_78_var; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_opt_var_1; - UNUSED(_opt_var_1); // Silence compiler warnings - expr_ty annotated_rhs_var; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs - && - (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? - && - (_opt_var_1 = _tmp_154_rule(p), !p->error_indicator) // ['!' NAME] - && - (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' - && - (_loop0_78_var = _loop0_78_rule(p)) // fstring_format_spec* - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 26) // token='}' - ) - { - D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}'")); - _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: expecting '}', or format specs" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}'")); - } - { // '{' annotated_rhs '='? ['!' NAME] !'}' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !'}'")); - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_opt_var_1; - UNUSED(_opt_var_1); // Silence compiler warnings - expr_ty annotated_rhs_var; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs - && - (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? - && - (_opt_var_1 = _tmp_154_rule(p), !p->error_indicator) // ['!' NAME] - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 26) // token='}' - ) - { - D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !'}'")); - _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: expecting '}'" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !'}'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_tstring_conversion_character: '!' &(':' | '}') | '!' !NAME -static void * -invalid_tstring_conversion_character_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '!' &(':' | '}') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_tstring_conversion_character[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' &(':' | '}')")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 54)) // token='!' - && - _PyPegen_lookahead(1, _tmp_155_rule, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_tstring_conversion_character[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' &(':' | '}')")); - _res = RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: missing conversion character" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_tstring_conversion_character[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!' &(':' | '}')")); - } - { // '!' !NAME - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_tstring_conversion_character[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' !NAME")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 54)) // token='!' - && - _PyPegen_lookahead_for_expr(0, _PyPegen_name_token, p) - ) - { - D(fprintf(stderr, "%*c+ invalid_tstring_conversion_character[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' !NAME")); - _res = RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: invalid conversion character" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_tstring_conversion_character[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!' !NAME")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_string_tstring_concat: -// | ((fstring | string))+ tstring -// | tstring+ (fstring | string) -static void * -invalid_string_tstring_concat_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // ((fstring | string))+ tstring - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_string_tstring_concat[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((fstring | string))+ tstring")); - asdl_seq * a; - expr_ty b; - if ( - (a = _loop1_82_rule(p)) // ((fstring | string))+ - && - (b = (expr_ty)tstring_rule(p)) // tstring - ) - { - D(fprintf(stderr, "%*c+ invalid_string_tstring_concat[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((fstring | string))+ tstring")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( PyPegen_last_item ( a , expr_ty ) , b , "cannot mix t-string literals with string or bytes literals" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_string_tstring_concat[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((fstring | string))+ tstring")); - } - { // tstring+ (fstring | string) - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_string_tstring_concat[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tstring+ (fstring | string)")); - asdl_seq * a; - expr_ty b; - if ( - (a = _loop1_83_rule(p)) // tstring+ - && - (b = (expr_ty)_tmp_156_rule(p)) // fstring | string - ) - { - D(fprintf(stderr, "%*c+ invalid_string_tstring_concat[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tstring+ (fstring | string)")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( PyPegen_last_item ( a , expr_ty ) , b , "cannot mix t-string literals with string or bytes literals" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_string_tstring_concat[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tstring+ (fstring | string)")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// Left-recursive -// invalid_arithmetic: sum ('+' | '-' | '*' | '/' | '%' | '//' | '@') 'not' inversion -static void * -invalid_arithmetic_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // sum ('+' | '-' | '*' | '/' | '%' | '//' | '@') 'not' inversion - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_arithmetic[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum ('+' | '-' | '*' | '/' | '%' | '//' | '@') 'not' inversion")); - void *_tmp_157_var; - Token * a; - expr_ty b; - expr_ty sum_var; - if ( - (sum_var = sum_rule(p)) // sum - && - (_tmp_157_var = _tmp_157_rule(p)) // '+' | '-' | '*' | '/' | '%' | '//' | '@' - && - (a = _PyPegen_expect_token(p, 721)) // token='not' - && - (b = inversion_rule(p)) // inversion - ) - { - D(fprintf(stderr, "%*c+ invalid_arithmetic[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum ('+' | '-' | '*' | '/' | '%' | '//' | '@') 'not' inversion")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "'not' after an operator must be parenthesized" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_arithmetic[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum ('+' | '-' | '*' | '/' | '%' | '//' | '@') 'not' inversion")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_factor: ('+' | '-' | '~') 'not' factor -static void * -invalid_factor_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // ('+' | '-' | '~') 'not' factor - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('+' | '-' | '~') 'not' factor")); - void *_tmp_158_var; - Token * a; - expr_ty b; - if ( - (_tmp_158_var = _tmp_158_rule(p)) // '+' | '-' | '~' - && - (a = _PyPegen_expect_token(p, 721)) // token='not' - && - (b = factor_rule(p)) // factor - ) - { - D(fprintf(stderr, "%*c+ invalid_factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('+' | '-' | '~') 'not' factor")); - _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "'not' after an operator must be parenthesized" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_factor[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('+' | '-' | '~') 'not' factor")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// invalid_type_params: '[' ']' -static void * -invalid_type_params_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '[' ']' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_type_params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' ']'")); - Token * _literal; - Token * token; - if ( - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - && - (token = _PyPegen_expect_token(p, 10)) // token=']' - ) - { - D(fprintf(stderr, "%*c+ invalid_type_params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' ']'")); - _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( token , "Type parameter list cannot be empty" ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_type_params[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' ']'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// Left-recursive -// invalid_bitwise_and: bitwise_and '&' '&' -static void * -invalid_bitwise_and_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // bitwise_and '&' '&' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' '&'")); - expr_ty a; - Token * b; - Token * c; - if ( - (a = bitwise_and_rule(p)) // bitwise_and - && - (b = _PyPegen_expect_token(p, 19)) // token='&' - && - (c = _PyPegen_expect_token(p, 19)) // token='&' - ) - { - D(fprintf(stderr, "%*c+ invalid_bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' '&'")); - _res = _PyPegen_tokens_are_adjacent ( b , c ) ? RAISE_SYNTAX_ERROR_KNOWN_RANGE ( b , c , "invalid syntax. Maybe you meant 'and' or '&' instead of '&&'?" ) : NULL; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and '&' '&'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// Left-recursive -// invalid_bitwise_or: bitwise_or '|' '|' -static void * -invalid_bitwise_or_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // bitwise_or '|' '|' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> invalid_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' '|'")); - expr_ty a; - Token * b; - Token * c; - if ( - (a = bitwise_or_rule(p)) // bitwise_or - && - (b = _PyPegen_expect_token(p, 18)) // token='|' - && - (c = _PyPegen_expect_token(p, 18)) // token='|' - ) - { - D(fprintf(stderr, "%*c+ invalid_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' '|'")); - _res = _PyPegen_tokens_are_adjacent ( b , c ) ? RAISE_SYNTAX_ERROR_KNOWN_RANGE ( b , c , "invalid syntax. Maybe you meant 'or' or '|' instead of '||'?" ) : NULL; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or '|' '|'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_1: NEWLINE -static asdl_seq * -_loop0_1_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_1[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); - Token * newline_var; - while ( - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - _res = newline_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_1[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_2: statement -static asdl_seq * -_loop1_2_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // statement - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_2[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement")); - asdl_stmt_seq* statement_var; - while ( - (statement_var = statement_rule(p)) // statement - ) - { - _res = statement_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_2[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_3: ';' simple_stmt -static asdl_seq * -_loop0_3_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ';' simple_stmt - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_3[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';' simple_stmt")); - Token * _literal; - stmt_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 13)) // token=';' - && - (elem = simple_stmt_rule(p)) // simple_stmt - ) - { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_3[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';' simple_stmt")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_4: simple_stmt _loop0_3 -static asdl_seq * -_gather_4_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // simple_stmt _loop0_3 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_4[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt _loop0_3")); - stmt_ty elem; - asdl_seq * seq; - if ( - (elem = simple_stmt_rule(p)) // simple_stmt - && - (seq = _loop0_3_rule(p)) // _loop0_3 - ) - { - D(fprintf(stderr, "%*c+ _gather_4[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt _loop0_3")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_4[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt _loop0_3")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_5: 'import' | 'from' | "lazy" -static void * -_tmp_5_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'import' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_5[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 651)) // token='import' - ) - { - D(fprintf(stderr, "%*c+ _tmp_5[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_5[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import'")); - } - { // 'from' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_5[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 650)) // token='from' - ) - { - D(fprintf(stderr, "%*c+ _tmp_5[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_5[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from'")); - } - { // "lazy" - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_5[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"lazy\"")); - expr_ty _keyword; - if ( - (_keyword = _PyPegen_expect_soft_keyword(p, "lazy")) // soft_keyword='"lazy"' - ) - { - D(fprintf(stderr, "%*c+ _tmp_5[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"lazy\"")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_5[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"lazy\"")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_6: 'def' | '@' | 'async' -static void * -_tmp_6_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'def' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_6[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 717)) // token='def' - ) - { - D(fprintf(stderr, "%*c+ _tmp_6[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_6[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def'")); - } - { // '@' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_6[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 49)) // token='@' - ) - { - D(fprintf(stderr, "%*c+ _tmp_6[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_6[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'")); - } - { // 'async' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_6[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 716)) // token='async' - ) - { - D(fprintf(stderr, "%*c+ _tmp_6[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_6[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_7: 'class' | '@' -static void * -_tmp_7_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'class' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_7[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 719)) // token='class' - ) - { - D(fprintf(stderr, "%*c+ _tmp_7[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_7[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class'")); - } - { // '@' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_7[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 49)) // token='@' - ) - { - D(fprintf(stderr, "%*c+ _tmp_7[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_7[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_8: 'with' | 'async' -static void * -_tmp_8_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'with' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_8[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 665)) // token='with' - ) - { - D(fprintf(stderr, "%*c+ _tmp_8[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_8[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with'")); - } - { // 'async' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_8[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 716)) // token='async' - ) - { - D(fprintf(stderr, "%*c+ _tmp_8[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_8[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_9: 'for' | 'async' -static void * -_tmp_9_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'for' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_9[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 712)) // token='for' - ) - { - D(fprintf(stderr, "%*c+ _tmp_9[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_9[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for'")); - } - { // 'async' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_9[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 716)) // token='async' - ) - { - D(fprintf(stderr, "%*c+ _tmp_9[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_9[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_10: '=' annotated_rhs -static void * -_tmp_10_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '=' annotated_rhs - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_10[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); - Token * _literal; - expr_ty d; - if ( - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - && - (d = annotated_rhs_rule(p)) // annotated_rhs - ) - { - D(fprintf(stderr, "%*c+ _tmp_10[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); - _res = d; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_10[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_11: '(' single_target ')' | single_subscript_attribute_target -static void * -_tmp_11_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '(' single_target ')' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_11[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); - Token * _literal; - Token * _literal_1; - expr_ty b; - if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (b = single_target_rule(p)) // single_target - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ _tmp_11[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); - _res = b; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_11[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' single_target ')'")); - } - { // single_subscript_attribute_target - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_11[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); - expr_ty single_subscript_attribute_target_var; - if ( - (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target - ) - { - D(fprintf(stderr, "%*c+ _tmp_11[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); - _res = single_subscript_attribute_target_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_11[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_subscript_attribute_target")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop1_12: (star_targets '=') -static asdl_seq * -_loop1_12_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // (star_targets '=') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_12[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_159_var; - while ( - (_tmp_159_var = _tmp_159_rule(p)) // star_targets '=' - ) - { - _res = _tmp_159_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_12[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_13: ',' NAME -static asdl_seq * -_loop0_13_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' NAME - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_13[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME")); - Token * _literal; - expr_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = _PyPegen_name_token(p)) // NAME - ) - { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_13[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_14: NAME _loop0_13 -static asdl_seq * -_gather_14_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // NAME _loop0_13 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_13")); - expr_ty elem; - asdl_seq * seq; - if ( - (elem = _PyPegen_name_token(p)) // NAME - && - (seq = _loop0_13_rule(p)) // _loop0_13 - ) - { - D(fprintf(stderr, "%*c+ _gather_14[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_13")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_14[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_13")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_15: ';' | NEWLINE -static void * -_tmp_15_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // ';' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 13)) // token=';' - ) - { - D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'")); - } - { // NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); - Token * newline_var; - if ( - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); - _res = newline_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_16: ',' expression -static void * -_tmp_16_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // ',' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_16[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); - Token * _literal; - expr_ty z; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (z = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ _tmp_16[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); - _res = z; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_16[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_17: ('.' | '...') -static asdl_seq * -_loop0_17_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ('.' | '...') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_17[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_160_var; - while ( - (_tmp_160_var = _tmp_160_rule(p)) // '.' | '...' - ) - { - _res = _tmp_160_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_17[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_18: ('.' | '...') -static asdl_seq * -_loop1_18_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ('.' | '...') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_18[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_160_var; - while ( - (_tmp_160_var = _tmp_160_rule(p)) // '.' | '...' - ) - { - _res = _tmp_160_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_18[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_19: ',' import_from_as_name -static asdl_seq * -_loop0_19_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' import_from_as_name - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_19[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' import_from_as_name")); - Token * _literal; - alias_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = import_from_as_name_rule(p)) // import_from_as_name - ) - { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_19[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' import_from_as_name")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_20: import_from_as_name _loop0_19 -static asdl_seq * -_gather_20_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // import_from_as_name _loop0_19 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_20[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_19")); - alias_ty elem; - asdl_seq * seq; - if ( - (elem = import_from_as_name_rule(p)) // import_from_as_name - && - (seq = _loop0_19_rule(p)) // _loop0_19 - ) - { - D(fprintf(stderr, "%*c+ _gather_20[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_19")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_20[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_name _loop0_19")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_21: 'as' NAME -static void * -_tmp_21_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'as' NAME - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_21[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - Token * _keyword; - expr_ty z; - if ( - (_keyword = _PyPegen_expect_token(p, 698)) // token='as' - && - (z = _PyPegen_name_token(p)) // NAME - ) - { - D(fprintf(stderr, "%*c+ _tmp_21[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - _res = z; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_21[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_22: ',' dotted_as_name -static asdl_seq * -_loop0_22_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' dotted_as_name - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_22[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' dotted_as_name")); - Token * _literal; - alias_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = dotted_as_name_rule(p)) // dotted_as_name - ) - { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_22[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' dotted_as_name")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_23: dotted_as_name _loop0_22 -static asdl_seq * -_gather_23_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // dotted_as_name _loop0_22 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_23[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_22")); - alias_ty elem; - asdl_seq * seq; - if ( - (elem = dotted_as_name_rule(p)) // dotted_as_name - && - (seq = _loop0_22_rule(p)) // _loop0_22 - ) - { - D(fprintf(stderr, "%*c+ _gather_23[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_22")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_23[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_as_name _loop0_22")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop1_24: ('@' named_expression NEWLINE) -static asdl_seq * -_loop1_24_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ('@' named_expression NEWLINE) - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); - void *_tmp_161_var; - while ( - (_tmp_161_var = _tmp_161_rule(p)) // '@' named_expression NEWLINE - ) - { - _res = _tmp_161_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_24[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('@' named_expression NEWLINE)")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _tmp_25: '(' arguments? ')' -static void * -_tmp_25_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '(' arguments? ')' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_25[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); - Token * _literal; - Token * _literal_1; - void *z; - if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (z = arguments_rule(p), !p->error_indicator) // arguments? - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ _tmp_25[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); - _res = z; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_25[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_26: '->' expression -static void * -_tmp_26_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '->' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_26[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); - Token * _literal; - expr_ty z; - if ( - (_literal = _PyPegen_expect_token(p, 51)) // token='->' - && - (z = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ _tmp_26[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); - _res = z; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_26[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_27: param_no_default -static asdl_seq * -_loop0_27_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // param_no_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_27[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); - arg_ty param_no_default_var; - while ( - (param_no_default_var = param_no_default_rule(p)) // param_no_default - ) - { - _res = param_no_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_27[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_28: param_with_default -static asdl_seq * -_loop0_28_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // param_with_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_28[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); - NameDefaultPair* param_with_default_var; - while ( - (param_with_default_var = param_with_default_rule(p)) // param_with_default - ) - { - _res = param_with_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_28[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_29: param_no_default -static asdl_seq * -_loop1_29_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // param_no_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_29[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); - arg_ty param_no_default_var; - while ( - (param_no_default_var = param_no_default_rule(p)) // param_no_default - ) - { - _res = param_no_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_29[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_30: param_with_default -static asdl_seq * -_loop1_30_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // param_with_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_30[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); - NameDefaultPair* param_with_default_var; - while ( - (param_with_default_var = param_with_default_rule(p)) // param_with_default - ) - { - _res = param_with_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_30[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_31: param_maybe_default -static asdl_seq * -_loop0_31_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // param_maybe_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); - NameDefaultPair* param_maybe_default_var; - while ( - (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default - ) - { - _res = param_maybe_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_31[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_32: param_maybe_default -static asdl_seq * -_loop1_32_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // param_maybe_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_32[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); - NameDefaultPair* param_maybe_default_var; - while ( - (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default - ) - { - _res = param_maybe_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_32[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_33: ',' with_item -static asdl_seq * -_loop0_33_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' with_item - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_33[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); - Token * _literal; - withitem_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = with_item_rule(p)) // with_item - ) - { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_33[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_34: with_item _loop0_33 -static asdl_seq * -_gather_34_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // with_item _loop0_33 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_34[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_33")); - withitem_ty elem; - asdl_seq * seq; - if ( - (elem = with_item_rule(p)) // with_item - && - (seq = _loop0_33_rule(p)) // _loop0_33 - ) - { - D(fprintf(stderr, "%*c+ _gather_34[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_33")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_34[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_33")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_35: ',' | ')' | ':' -static void * -_tmp_35_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // ',' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_35[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ _tmp_35[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_35[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); - } - { // ')' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_35[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ _tmp_35[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_35[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); - } - { // ':' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_35[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ _tmp_35[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_35[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop1_36: except_block -static asdl_seq * -_loop1_36_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // except_block - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_36[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block")); - excepthandler_ty except_block_var; - while ( - (except_block_var = except_block_rule(p)) // except_block - ) - { - _res = except_block_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_36[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_block")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_37: except_star_block -static asdl_seq * -_loop1_37_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // except_star_block - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_37[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_star_block")); - excepthandler_ty except_star_block_var; - while ( - (except_star_block_var = except_star_block_rule(p)) // except_star_block - ) - { - _res = except_star_block_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_37[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_star_block")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_38: case_block -static asdl_seq * -_loop1_38_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // case_block - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_38[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "case_block")); - match_case_ty case_block_var; - while ( - (case_block_var = case_block_rule(p)) // case_block - ) - { - _res = case_block_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_38[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "case_block")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_39: '|' closed_pattern -static asdl_seq * -_loop0_39_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // '|' closed_pattern - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_39[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|' closed_pattern")); - Token * _literal; - pattern_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 18)) // token='|' - && - (elem = closed_pattern_rule(p)) // closed_pattern - ) - { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_39[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|' closed_pattern")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_40: closed_pattern _loop0_39 -static asdl_seq * -_gather_40_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // closed_pattern _loop0_39 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_40[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "closed_pattern _loop0_39")); - pattern_ty elem; - asdl_seq * seq; - if ( - (elem = closed_pattern_rule(p)) // closed_pattern - && - (seq = _loop0_39_rule(p)) // _loop0_39 - ) - { - D(fprintf(stderr, "%*c+ _gather_40[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "closed_pattern _loop0_39")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_40[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "closed_pattern _loop0_39")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_41: '+' | '-' -static void * -_tmp_41_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '+' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_41[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 14)) // token='+' - ) - { - D(fprintf(stderr, "%*c+ _tmp_41[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_41[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+'")); - } - { // '-' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_41[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 15)) // token='-' - ) - { - D(fprintf(stderr, "%*c+ _tmp_41[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_41[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_42: STRING | FSTRING_START | TSTRING_START -static void * -_tmp_42_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // STRING - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_42[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); - expr_ty string_var; - if ( - (string_var = _PyPegen_string_token(p)) // STRING - ) - { - D(fprintf(stderr, "%*c+ _tmp_42[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING")); - _res = string_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_42[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); - } - { // FSTRING_START - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_42[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "FSTRING_START")); - Token * fstring_start_var; - if ( - (fstring_start_var = _PyPegen_expect_token(p, FSTRING_START)) // token='FSTRING_START' - ) - { - D(fprintf(stderr, "%*c+ _tmp_42[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "FSTRING_START")); - _res = fstring_start_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_42[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "FSTRING_START")); - } - { // TSTRING_START - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_42[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TSTRING_START")); - Token * tstring_start_var; - if ( - (tstring_start_var = _PyPegen_expect_token(p, TSTRING_START)) // token='TSTRING_START' - ) - { - D(fprintf(stderr, "%*c+ _tmp_42[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TSTRING_START")); - _res = tstring_start_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_42[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TSTRING_START")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_43: '.' | '(' | '=' -static void * -_tmp_43_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '.' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_43[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 23)) // token='.' - ) - { - D(fprintf(stderr, "%*c+ _tmp_43[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_43[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); - } - { // '(' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_43[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - ) - { - D(fprintf(stderr, "%*c+ _tmp_43[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_43[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); - } - { // '=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_43[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ _tmp_43[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_43[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_44: ',' maybe_star_pattern -static asdl_seq * -_loop0_44_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' maybe_star_pattern - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_44[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' maybe_star_pattern")); - Token * _literal; - pattern_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = maybe_star_pattern_rule(p)) // maybe_star_pattern - ) - { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_44[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' maybe_star_pattern")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_45: maybe_star_pattern _loop0_44 -static asdl_seq * -_gather_45_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // maybe_star_pattern _loop0_44 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_45[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "maybe_star_pattern _loop0_44")); - pattern_ty elem; - asdl_seq * seq; - if ( - (elem = maybe_star_pattern_rule(p)) // maybe_star_pattern - && - (seq = _loop0_44_rule(p)) // _loop0_44 - ) - { - D(fprintf(stderr, "%*c+ _gather_45[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "maybe_star_pattern _loop0_44")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_45[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "maybe_star_pattern _loop0_44")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_46: ',' key_value_pattern -static asdl_seq * -_loop0_46_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' key_value_pattern - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_46[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); - Token * _literal; - KeyPatternPair* elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = key_value_pattern_rule(p)) // key_value_pattern - ) - { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_46[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' key_value_pattern")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_47: key_value_pattern _loop0_46 -static asdl_seq * -_gather_47_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // key_value_pattern _loop0_46 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_47[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_46")); - KeyPatternPair* elem; - asdl_seq * seq; - if ( - (elem = key_value_pattern_rule(p)) // key_value_pattern - && - (seq = _loop0_46_rule(p)) // _loop0_46 - ) - { - D(fprintf(stderr, "%*c+ _gather_47[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_46")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_47[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_46")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_48: literal_expr | attr -static void * -_tmp_48_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // literal_expr - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_48[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_expr")); - expr_ty literal_expr_var; - if ( - (literal_expr_var = literal_expr_rule(p)) // literal_expr - ) - { - D(fprintf(stderr, "%*c+ _tmp_48[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_expr")); - _res = literal_expr_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_48[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_expr")); - } - { // attr - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_48[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "attr")); - expr_ty attr_var; - if ( - (attr_var = attr_rule(p)) // attr - ) - { - D(fprintf(stderr, "%*c+ _tmp_48[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "attr")); - _res = attr_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_48[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "attr")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_49: ',' pattern -static asdl_seq * -_loop0_49_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' pattern - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_49[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); - Token * _literal; - pattern_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = pattern_rule(p)) // pattern - ) - { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_49[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_50: pattern _loop0_49 -static asdl_seq * -_gather_50_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // pattern _loop0_49 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_50[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_49")); - pattern_ty elem; - asdl_seq * seq; - if ( - (elem = pattern_rule(p)) // pattern - && - (seq = _loop0_49_rule(p)) // _loop0_49 - ) - { - D(fprintf(stderr, "%*c+ _gather_50[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_49")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_50[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_49")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_51: ',' keyword_pattern -static asdl_seq * -_loop0_51_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' keyword_pattern - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_51[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); - Token * _literal; - KeyPatternPair* elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = keyword_pattern_rule(p)) // keyword_pattern - ) - { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_51[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_52: keyword_pattern _loop0_51 -static asdl_seq * -_gather_52_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // keyword_pattern _loop0_51 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_52[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_51")); - KeyPatternPair* elem; - asdl_seq * seq; - if ( - (elem = keyword_pattern_rule(p)) // keyword_pattern - && - (seq = _loop0_51_rule(p)) // _loop0_51 - ) - { - D(fprintf(stderr, "%*c+ _gather_52[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_51")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_52[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_51")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_53: ',' type_param -static asdl_seq * -_loop0_53_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' type_param - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' type_param")); - Token * _literal; - type_param_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = type_param_rule(p)) // type_param - ) - { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_53[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' type_param")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_54: type_param _loop0_53 -static asdl_seq * -_gather_54_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // type_param _loop0_53 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "type_param _loop0_53")); - type_param_ty elem; - asdl_seq * seq; - if ( - (elem = type_param_rule(p)) // type_param - && - (seq = _loop0_53_rule(p)) // _loop0_53 - ) - { - D(fprintf(stderr, "%*c+ _gather_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "type_param _loop0_53")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_54[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "type_param _loop0_53")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop1_55: (',' expression) -static asdl_seq * -_loop1_55_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // (',' expression) - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); - void *_tmp_16_var; - while ( - (_tmp_16_var = _tmp_16_rule(p)) // ',' expression - ) - { - _res = _tmp_16_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_55[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_56: (',' star_expression) -static asdl_seq * -_loop1_56_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // (',' star_expression) - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); - void *_tmp_162_var; - while ( - (_tmp_162_var = _tmp_162_rule(p)) // ',' star_expression - ) - { - _res = _tmp_162_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_56[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_57: ',' star_named_expression -static asdl_seq * -_loop0_57_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' star_named_expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); - Token * _literal; - expr_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = star_named_expression_rule(p)) // star_named_expression - ) - { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_57[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_58: star_named_expression _loop0_57 -static asdl_seq * -_gather_58_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // star_named_expression _loop0_57 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_57")); - expr_ty elem; - asdl_seq * seq; - if ( - (elem = star_named_expression_rule(p)) // star_named_expression - && - (seq = _loop0_57_rule(p)) // _loop0_57 - ) - { - D(fprintf(stderr, "%*c+ _gather_58[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_57")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_58[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_57")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_59: ',' star_named_expression_sequence -static asdl_seq * -_loop0_59_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' star_named_expression_sequence - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression_sequence")); - Token * _literal; - expr_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = star_named_expression_sequence_rule(p)) // star_named_expression_sequence - ) - { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_59[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression_sequence")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_60: star_named_expression_sequence _loop0_59 -static asdl_seq * -_gather_60_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // star_named_expression_sequence _loop0_59 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression_sequence _loop0_59")); - expr_ty elem; - asdl_seq * seq; - if ( - (elem = star_named_expression_sequence_rule(p)) // star_named_expression_sequence - && - (seq = _loop0_59_rule(p)) // _loop0_59 - ) - { - D(fprintf(stderr, "%*c+ _gather_60[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression_sequence _loop0_59")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_60[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression_sequence _loop0_59")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop1_61: ('or' conjunction) -static asdl_seq * -_loop1_61_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ('or' conjunction) - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); - void *_tmp_163_var; - while ( - (_tmp_163_var = _tmp_163_rule(p)) // 'or' conjunction - ) - { - _res = _tmp_163_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_61[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_62: ('and' inversion) -static asdl_seq * -_loop1_62_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ('and' inversion) - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); - void *_tmp_164_var; - while ( - (_tmp_164_var = _tmp_164_rule(p)) // 'and' inversion - ) - { - _res = _tmp_164_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_62[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_63: compare_op_bitwise_or_pair -static asdl_seq * -_loop1_63_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // compare_op_bitwise_or_pair - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); - CmpopExprPair* compare_op_bitwise_or_pair_var; - while ( - (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair - ) - { - _res = compare_op_bitwise_or_pair_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_63[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _tmp_64: '!=' -static void * -_tmp_64_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '!=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); - Token * tok; - if ( - (tok = _PyPegen_expect_token(p, 28)) // token='!=' - ) - { - D(fprintf(stderr, "%*c+ _tmp_64[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); - _res = _PyPegen_check_barry_as_flufl ( p , tok ) ? NULL : tok; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_64[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_65: ',' (slice | starred_expression) -static asdl_seq * -_loop0_65_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' (slice | starred_expression) - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (slice | starred_expression)")); - Token * _literal; - void *elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = _tmp_165_rule(p)) // slice | starred_expression - ) - { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_65[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (slice | starred_expression)")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_66: (slice | starred_expression) _loop0_65 -static asdl_seq * -_gather_66_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // (slice | starred_expression) _loop0_65 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(slice | starred_expression) _loop0_65")); - void *elem; - asdl_seq * seq; - if ( - (elem = _tmp_165_rule(p)) // slice | starred_expression - && - (seq = _loop0_65_rule(p)) // _loop0_65 - ) - { - D(fprintf(stderr, "%*c+ _gather_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(slice | starred_expression) _loop0_65")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_66[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(slice | starred_expression) _loop0_65")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_67: ':' expression? -static void * -_tmp_67_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // ':' expression? - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); - Token * _literal; - void *d; - if ( - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (d = expression_rule(p), !p->error_indicator) // expression? - ) - { - D(fprintf(stderr, "%*c+ _tmp_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); - _res = d; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_67[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_68: genexp | tuple | group -static void * -_tmp_68_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // genexp - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); - expr_ty genexp_var; - if ( - (genexp_var = genexp_rule(p)) // genexp - ) - { - D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); - _res = genexp_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); - } - { // tuple - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); - expr_ty tuple_var; - if ( - (tuple_var = tuple_rule(p)) // tuple - ) - { - D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); - _res = tuple_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); - } - { // group - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); - expr_ty group_var; - if ( - (group_var = group_rule(p)) // group - ) - { - D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); - _res = group_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_69: listcomp | list -static void * -_tmp_69_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // listcomp - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); - expr_ty listcomp_var; - if ( - (listcomp_var = listcomp_rule(p)) // listcomp - ) - { - D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); - _res = listcomp_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_69[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp")); - } - { // list - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); - expr_ty list_var; - if ( - (list_var = list_rule(p)) // list - ) - { - D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); - _res = list_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_69[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_70: dictcomp | setcomp | dict | set -static void * -_tmp_70_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // dictcomp - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); - expr_ty dictcomp_var; - if ( - (dictcomp_var = dictcomp_rule(p)) // dictcomp - ) - { - D(fprintf(stderr, "%*c+ _tmp_70[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); - _res = dictcomp_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_70[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp")); - } - { // setcomp - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); - expr_ty setcomp_var; - if ( - (setcomp_var = setcomp_rule(p)) // setcomp - ) - { - D(fprintf(stderr, "%*c+ _tmp_70[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); - _res = setcomp_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_70[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp")); - } - { // dict - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); - expr_ty dict_var; - if ( - (dict_var = dict_rule(p)) // dict - ) - { - D(fprintf(stderr, "%*c+ _tmp_70[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); - _res = dict_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_70[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict")); - } - { // set - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); - expr_ty set_var; - if ( - (set_var = set_rule(p)) // set - ) - { - D(fprintf(stderr, "%*c+ _tmp_70[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); - _res = set_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_70[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_71: yield_expr | named_expression -static void * -_tmp_71_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // yield_expr - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); - expr_ty yield_expr_var; - if ( - (yield_expr_var = yield_expr_rule(p)) // yield_expr - ) - { - D(fprintf(stderr, "%*c+ _tmp_71[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); - _res = yield_expr_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_71[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); - } - { // named_expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); - expr_ty named_expression_var; - if ( - (named_expression_var = named_expression_rule(p)) // named_expression - ) - { - D(fprintf(stderr, "%*c+ _tmp_71[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); - _res = named_expression_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_71[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_72: lambda_param_no_default -static asdl_seq * -_loop0_72_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // lambda_param_no_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); - arg_ty lambda_param_no_default_var; - while ( - (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default - ) - { - _res = lambda_param_no_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_72[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_73: lambda_param_with_default -static asdl_seq * -_loop0_73_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // lambda_param_with_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); - NameDefaultPair* lambda_param_with_default_var; - while ( - (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default - ) - { - _res = lambda_param_with_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_73[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_74: lambda_param_no_default -static asdl_seq * -_loop1_74_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // lambda_param_no_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); - arg_ty lambda_param_no_default_var; - while ( - (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default - ) - { - _res = lambda_param_no_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_74[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_75: lambda_param_with_default -static asdl_seq * -_loop1_75_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // lambda_param_with_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); - NameDefaultPair* lambda_param_with_default_var; - while ( - (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default - ) - { - _res = lambda_param_with_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_75[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_76: lambda_param_maybe_default -static asdl_seq * -_loop0_76_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // lambda_param_maybe_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); - NameDefaultPair* lambda_param_maybe_default_var; - while ( - (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default - ) - { - _res = lambda_param_maybe_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_76[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_77: lambda_param_maybe_default -static asdl_seq * -_loop1_77_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // lambda_param_maybe_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); - NameDefaultPair* lambda_param_maybe_default_var; - while ( - (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default - ) - { - _res = lambda_param_maybe_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_77[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_78: fstring_format_spec -static asdl_seq * -_loop0_78_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // fstring_format_spec - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring_format_spec")); - expr_ty fstring_format_spec_var; - while ( - (fstring_format_spec_var = fstring_format_spec_rule(p)) // fstring_format_spec - ) - { - _res = fstring_format_spec_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_78[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "fstring_format_spec")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_79: fstring_middle -static asdl_seq * -_loop0_79_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // fstring_middle - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring_middle")); - expr_ty fstring_middle_var; - while ( - (fstring_middle_var = fstring_middle_rule(p)) // fstring_middle - ) - { - _res = fstring_middle_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_79[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "fstring_middle")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_80: tstring_format_spec -static asdl_seq * -_loop0_80_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // tstring_format_spec - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tstring_format_spec")); - expr_ty tstring_format_spec_var; - while ( - (tstring_format_spec_var = tstring_format_spec_rule(p)) // tstring_format_spec - ) - { - _res = tstring_format_spec_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_80[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tstring_format_spec")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_81: tstring_middle -static asdl_seq * -_loop0_81_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // tstring_middle - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tstring_middle")); - expr_ty tstring_middle_var; - while ( - (tstring_middle_var = tstring_middle_rule(p)) // tstring_middle - ) - { - _res = tstring_middle_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_81[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tstring_middle")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_82: (fstring | string) -static asdl_seq * -_loop1_82_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // (fstring | string) - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(fstring | string)")); - void *_tmp_156_var; - while ( - (_tmp_156_var = _tmp_156_rule(p)) // fstring | string - ) - { - _res = _tmp_156_var; + _res = _tmp_178_var; if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_82[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(fstring | string)")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_83: tstring -static asdl_seq * -_loop1_83_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // tstring - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tstring")); - expr_ty tstring_var; - while ( - (tstring_var = tstring_rule(p)) // tstring - ) - { - _res = tstring_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tstring")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _tmp_84: star_named_expression_sequence ',' star_named_expressions_sequence? -static void * -_tmp_84_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // star_named_expression_sequence ',' star_named_expressions_sequence? - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression_sequence ',' star_named_expressions_sequence?")); - Token * _literal; - expr_ty y; - void *z; - if ( - (y = star_named_expression_sequence_rule(p)) // star_named_expression_sequence - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (z = star_named_expressions_sequence_rule(p), !p->error_indicator) // star_named_expressions_sequence? - ) - { - D(fprintf(stderr, "%*c+ _tmp_84[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression_sequence ',' star_named_expressions_sequence?")); - _res = _PyPegen_seq_insert_in_front ( p , y , z ); - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_84[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression_sequence ',' star_named_expressions_sequence?")); + D(fprintf(stderr, "%*c%s _loop1_12[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); } - _res = NULL; - done: + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _loop0_85: ',' double_starred_kvpair +// _loop0_13: ',' NAME static asdl_seq * -_loop0_85_rule(Parser *p) +_loop0_13_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -33998,27 +20468,21 @@ _loop0_85_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // ',' double_starred_kvpair + { // ',' NAME if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); + D(fprintf(stderr, "%*c> _loop0_13[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME")); Token * _literal; - KeyValuePair* elem; + expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair + (elem = _PyPegen_name_token(p)) // NAME ) { _res = elem; @@ -34029,29 +20493,26 @@ _loop0_85_rule(Parser *p) return NULL; } if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_85[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); + D(fprintf(stderr, "%*c%s _loop0_13[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -34061,11 +20522,11 @@ _loop0_85_rule(Parser *p) return _seq; } -// _gather_86: double_starred_kvpair _loop0_85 +// _gather_14: NAME _loop0_13 static asdl_seq * -_gather_86_rule(Parser *p) +_gather_14_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -34074,27 +20535,27 @@ _gather_86_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // double_starred_kvpair _loop0_85 + { // NAME _loop0_13 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_85")); - KeyValuePair* elem; + D(fprintf(stderr, "%*c> _gather_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_13")); + expr_ty elem; asdl_seq * seq; if ( - (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair + (elem = _PyPegen_name_token(p)) // NAME && - (seq = _loop0_85_rule(p)) // _loop0_85 + (seq = _loop0_13_rule(p)) // _loop0_13 ) { - D(fprintf(stderr, "%*c+ _gather_86[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_85")); + D(fprintf(stderr, "%*c+ _gather_14[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_13")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_86[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_85")); + D(fprintf(stderr, "%*c%s _gather_14[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_13")); } _res = NULL; done: @@ -34102,83 +20563,114 @@ _gather_86_rule(Parser *p) return _res; } -// _loop1_87: for_if_clause -static asdl_seq * -_loop1_87_rule(Parser *p) +// _tmp_15: ';' | NEWLINE +static void * +_tmp_15_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void *_res = NULL; + void * _res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; + { // ';' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 13)) // token=';' + ) + { + D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'")); } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // for_if_clause + { // NEWLINE if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); - comprehension_ty for_if_clause_var; - while ( - (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause + D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + Token * newline_var; + if ( + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - _res = for_if_clause_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; + D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + _res = newline_var; + goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); + D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_16: ',' expression +static void * +_tmp_16_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); + if (p->error_indicator) { p->level--; return NULL; } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); + void * _res = NULL; + int _mark = p->mark; + { // ',' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_16[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + Token * _literal; + expr_ty z; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (z = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ _tmp_16[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); + _res = z; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_16[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); + } + _res = NULL; + done: p->level--; - return _seq; + return _res; } -// _loop0_88: ('if' disjunction) +// _loop0_17: ('.' | '...') static asdl_seq * -_loop0_88_rule(Parser *p) +_loop0_17_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -34187,51 +20679,42 @@ _loop0_88_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // ('if' disjunction) + { // ('.' | '...') if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_166_var; + D(fprintf(stderr, "%*c> _loop0_17[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); + void *_tmp_179_var; while ( - (_tmp_166_var = _tmp_166_rule(p)) // 'if' disjunction + (_tmp_179_var = _tmp_179_rule(p)) // '.' | '...' ) { - _res = _tmp_166_var; + _res = _tmp_179_var; if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_88[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); + D(fprintf(stderr, "%*c%s _loop0_17[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -34241,89 +20724,74 @@ _loop0_88_rule(Parser *p) return _seq; } -// _tmp_89: assignment_expression | expression !':=' | starred_expression -static void * -_tmp_89_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // assignment_expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment_expression")); - expr_ty assignment_expression_var; - if ( - (assignment_expression_var = assignment_expression_rule(p)) // assignment_expression - ) - { - D(fprintf(stderr, "%*c+ _tmp_89[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment_expression")); - _res = assignment_expression_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_89[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment_expression")); - } - { // expression !':=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); - expr_ty expression_var; - if ( - (expression_var = expression_rule(p)) // expression - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' - ) - { - D(fprintf(stderr, "%*c+ _tmp_89[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); - _res = expression_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_89[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='")); +// _loop1_18: ('.' | '...') +static asdl_seq * +_loop1_18_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); } - { // starred_expression + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ('.' | '...') if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); - expr_ty starred_expression_var; - if ( - (starred_expression_var = starred_expression_rule(p)) // starred_expression + D(fprintf(stderr, "%*c> _loop1_18[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); + void *_tmp_179_var; + while ( + (_tmp_179_var = _tmp_179_rule(p)) // '.' | '...' ) { - D(fprintf(stderr, "%*c+ _tmp_89[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); - _res = starred_expression_var; - goto done; + _res = _tmp_179_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_89[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); + D(fprintf(stderr, "%*c%s _loop1_18[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); } - _res = NULL; - done: + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _loop0_90: ',' (starred_expression | (assignment_expression | expression !':=') !'=') +// _loop0_19: ',' import_from_as_name static asdl_seq * -_loop0_90_rule(Parser *p) +_loop0_19_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -34332,27 +20800,21 @@ _loop0_90_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // ',' (starred_expression | (assignment_expression | expression !':=') !'=') + { // ',' import_from_as_name if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (starred_expression | (assignment_expression | expression !':=') !'=')")); + D(fprintf(stderr, "%*c> _loop0_19[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' import_from_as_name")); Token * _literal; - void *elem; + alias_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_167_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' + (elem = import_from_as_name_rule(p)) // import_from_as_name ) { _res = elem; @@ -34363,29 +20825,26 @@ _loop0_90_rule(Parser *p) return NULL; } if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_90[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (starred_expression | (assignment_expression | expression !':=') !'=')")); + D(fprintf(stderr, "%*c%s _loop0_19[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' import_from_as_name")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -34395,12 +20854,11 @@ _loop0_90_rule(Parser *p) return _seq; } -// _gather_91: -// | (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_90 +// _gather_20: import_from_as_name _loop0_19 static asdl_seq * -_gather_91_rule(Parser *p) +_gather_20_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -34409,27 +20867,27 @@ _gather_91_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_90 + { // import_from_as_name _loop0_19 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_90")); - void *elem; + D(fprintf(stderr, "%*c> _gather_20[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_19")); + alias_ty elem; asdl_seq * seq; if ( - (elem = _tmp_167_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' + (elem = import_from_as_name_rule(p)) // import_from_as_name && - (seq = _loop0_90_rule(p)) // _loop0_90 + (seq = _loop0_19_rule(p)) // _loop0_19 ) { - D(fprintf(stderr, "%*c+ _gather_91[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_90")); + D(fprintf(stderr, "%*c+ _gather_20[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_19")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_91[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_90")); + D(fprintf(stderr, "%*c%s _gather_20[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_name _loop0_19")); } _res = NULL; done: @@ -34437,11 +20895,11 @@ _gather_91_rule(Parser *p) return _res; } -// _tmp_92: ',' kwargs +// _tmp_21: 'as' NAME static void * -_tmp_92_rule(Parser *p) +_tmp_21_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -34450,22 +20908,22 @@ _tmp_92_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ',' kwargs + { // 'as' NAME if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwargs")); - Token * _literal; - asdl_seq* k; + D(fprintf(stderr, "%*c> _tmp_21[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + Token * _keyword; + expr_ty z; if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (_keyword = _PyPegen_expect_token(p, 520)) // token='as' && - (k = kwargs_rule(p)) // kwargs + (z = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' kwargs")); - _res = k; + D(fprintf(stderr, "%*c+ _tmp_21[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + _res = z; if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -34474,8 +20932,8 @@ _tmp_92_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_92[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwargs")); + D(fprintf(stderr, "%*c%s _tmp_21[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; done: @@ -34483,11 +20941,11 @@ _tmp_92_rule(Parser *p) return _res; } -// _loop0_93: ',' kwarg_or_starred +// _loop0_22: ',' dotted_as_name static asdl_seq * -_loop0_93_rule(Parser *p) +_loop0_22_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -34496,27 +20954,21 @@ _loop0_93_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // ',' kwarg_or_starred + { // ',' dotted_as_name if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_22[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' dotted_as_name")); Token * _literal; - KeywordOrStarred* elem; + alias_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred + (elem = dotted_as_name_rule(p)) // dotted_as_name ) { _res = elem; @@ -34527,29 +20979,26 @@ _loop0_93_rule(Parser *p) return NULL; } if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_93[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c%s _loop0_22[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' dotted_as_name")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -34559,11 +21008,11 @@ _loop0_93_rule(Parser *p) return _seq; } -// _gather_94: kwarg_or_starred _loop0_93 +// _gather_23: dotted_as_name _loop0_22 static asdl_seq * -_gather_94_rule(Parser *p) +_gather_23_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -34572,27 +21021,27 @@ _gather_94_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_93 + { // dotted_as_name _loop0_22 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_93")); - KeywordOrStarred* elem; + D(fprintf(stderr, "%*c> _gather_23[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_22")); + alias_ty elem; asdl_seq * seq; if ( - (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred + (elem = dotted_as_name_rule(p)) // dotted_as_name && - (seq = _loop0_93_rule(p)) // _loop0_93 + (seq = _loop0_22_rule(p)) // _loop0_22 ) { - D(fprintf(stderr, "%*c+ _gather_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_93")); + D(fprintf(stderr, "%*c+ _gather_23[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_22")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_94[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_93")); + D(fprintf(stderr, "%*c%s _gather_23[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_as_name _loop0_22")); } _res = NULL; done: @@ -34600,11 +21049,11 @@ _gather_94_rule(Parser *p) return _res; } -// _loop0_95: ',' kwarg_or_double_starred +// _loop1_24: ('@' named_expression NEWLINE) static asdl_seq * -_loop0_95_rule(Parser *p) +_loop1_24_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -34613,60 +21062,47 @@ _loop0_95_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // ',' kwarg_or_double_starred + { // ('@' named_expression NEWLINE) if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); - Token * _literal; - KeywordOrStarred* elem; + D(fprintf(stderr, "%*c> _loop1_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); + void *_tmp_180_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred + (_tmp_180_var = _tmp_180_rule(p)) // '@' named_expression NEWLINE ) { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } + _res = _tmp_180_var; if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_95[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c%s _loop1_24[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('@' named_expression NEWLINE)")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -34676,40 +21112,94 @@ _loop0_95_rule(Parser *p) return _seq; } -// _gather_96: kwarg_or_double_starred _loop0_95 -static asdl_seq * -_gather_96_rule(Parser *p) +// _tmp_25: '(' arguments? ')' +static void * +_tmp_25_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - asdl_seq * _res = NULL; + void * _res = NULL; + int _mark = p->mark; + { // '(' arguments? ')' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_25[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + Token * _literal; + Token * _literal_1; + void *z; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (z = arguments_rule(p), !p->error_indicator) // arguments? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ _tmp_25[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + _res = z; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_25[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_26: '->' expression +static void * +_tmp_26_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_95 + { // '->' expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_95")); - KeywordOrStarred* elem; - asdl_seq * seq; + D(fprintf(stderr, "%*c> _tmp_26[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + Token * _literal; + expr_ty z; if ( - (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred + (_literal = _PyPegen_expect_token(p, 51)) // token='->' && - (seq = _loop0_95_rule(p)) // _loop0_95 + (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _gather_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_95")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); + D(fprintf(stderr, "%*c+ _tmp_26[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + _res = z; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_96[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_95")); + D(fprintf(stderr, "%*c%s _tmp_26[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; done: @@ -34717,11 +21207,11 @@ _gather_96_rule(Parser *p) return _res; } -// _loop0_97: (',' star_target) +// _loop0_27: param_no_default static asdl_seq * -_loop0_97_rule(Parser *p) +_loop0_27_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -34730,51 +21220,42 @@ _loop0_97_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // (',' star_target) + { // param_no_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_168_var; + D(fprintf(stderr, "%*c> _loop0_27[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + arg_ty param_no_default_var; while ( - (_tmp_168_var = _tmp_168_rule(p)) // ',' star_target + (param_no_default_var = param_no_default_rule(p)) // param_no_default ) { - _res = _tmp_168_var; + _res = param_no_default_var; if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_97[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); + D(fprintf(stderr, "%*c%s _loop0_27[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -34784,11 +21265,11 @@ _loop0_97_rule(Parser *p) return _seq; } -// _loop0_98: ',' star_target +// _loop0_28: param_with_default static asdl_seq * -_loop0_98_rule(Parser *p) +_loop0_28_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -34797,60 +21278,42 @@ _loop0_98_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // ',' star_target + { // param_with_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); - Token * _literal; - expr_ty elem; + D(fprintf(stderr, "%*c> _loop0_28[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + NameDefaultPair* param_with_default_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = star_target_rule(p)) // star_target + (param_with_default_var = param_with_default_rule(p)) // param_with_default ) { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } + _res = param_with_default_var; if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_98[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c%s _loop0_28[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -34860,52 +21323,74 @@ _loop0_98_rule(Parser *p) return _seq; } -// _gather_99: star_target _loop0_98 +// _loop1_29: param_no_default static asdl_seq * -_gather_99_rule(Parser *p) +_loop1_29_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - asdl_seq * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // star_target _loop0_98 + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // param_no_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_98")); - expr_ty elem; - asdl_seq * seq; - if ( - (elem = star_target_rule(p)) // star_target - && - (seq = _loop0_98_rule(p)) // _loop0_98 + D(fprintf(stderr, "%*c> _loop1_29[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + arg_ty param_no_default_var; + while ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default ) { - D(fprintf(stderr, "%*c+ _gather_99[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_98")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; + _res = param_no_default_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_99[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_98")); + D(fprintf(stderr, "%*c%s _loop1_29[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } - _res = NULL; - done: + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _loop1_100: (',' star_target) +// _loop1_30: param_with_default static asdl_seq * -_loop1_100_rule(Parser *p) +_loop1_30_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -34914,45 +21399,36 @@ _loop1_100_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // (',' star_target) + { // param_with_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_168_var; + D(fprintf(stderr, "%*c> _loop1_30[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + NameDefaultPair* param_with_default_var; while ( - (_tmp_168_var = _tmp_168_rule(p)) // ',' star_target + (param_with_default_var = param_with_default_rule(p)) // param_with_default ) { - _res = _tmp_168_var; + _res = param_with_default_var; if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_100[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); + D(fprintf(stderr, "%*c%s _loop1_30[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { PyMem_Free(_children); @@ -34961,9 +21437,9 @@ _loop1_100_rule(Parser *p) } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -34973,51 +21449,11 @@ _loop1_100_rule(Parser *p) return _seq; } -// _tmp_101: !'*' star_target -static void * -_tmp_101_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // !'*' star_target - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); - expr_ty star_target_var; - if ( - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' - && - (star_target_var = star_target_rule(p)) // star_target - ) - { - D(fprintf(stderr, "%*c+ _tmp_101[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); - _res = star_target_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_101[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_102: ',' del_target +// _loop0_31: param_maybe_default static asdl_seq * -_loop0_102_rule(Parser *p) +_loop0_31_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -35026,60 +21462,42 @@ _loop0_102_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // ',' del_target + { // param_maybe_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); - Token * _literal; - expr_ty elem; + D(fprintf(stderr, "%*c> _loop0_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + NameDefaultPair* param_maybe_default_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = del_target_rule(p)) // del_target + (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default ) { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } + _res = param_maybe_default_var; if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_102[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); + D(fprintf(stderr, "%*c%s _loop0_31[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -35089,52 +21507,74 @@ _loop0_102_rule(Parser *p) return _seq; } -// _gather_103: del_target _loop0_102 +// _loop1_32: param_maybe_default static asdl_seq * -_gather_103_rule(Parser *p) +_loop1_32_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - asdl_seq * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // del_target _loop0_102 + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // param_maybe_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_102")); - expr_ty elem; - asdl_seq * seq; - if ( - (elem = del_target_rule(p)) // del_target - && - (seq = _loop0_102_rule(p)) // _loop0_102 + D(fprintf(stderr, "%*c> _loop1_32[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + NameDefaultPair* param_maybe_default_var; + while ( + (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default ) { - D(fprintf(stderr, "%*c+ _gather_103[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_102")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; + _res = param_maybe_default_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_103[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_102")); + D(fprintf(stderr, "%*c%s _loop1_32[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } - _res = NULL; - done: + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _loop0_104: ',' expression +// _loop0_33: ',' with_item static asdl_seq * -_loop0_104_rule(Parser *p) +_loop0_33_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -35143,27 +21583,21 @@ _loop0_104_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // ',' expression + { // ',' with_item if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _loop0_33[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); Token * _literal; - expr_ty elem; + withitem_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = expression_rule(p)) // expression + (elem = with_item_rule(p)) // with_item ) { _res = elem; @@ -35174,29 +21608,26 @@ _loop0_104_rule(Parser *p) return NULL; } if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_104[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c%s _loop0_33[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -35206,11 +21637,11 @@ _loop0_104_rule(Parser *p) return _seq; } -// _gather_105: expression _loop0_104 +// _gather_34: with_item _loop0_33 static asdl_seq * -_gather_105_rule(Parser *p) +_gather_34_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -35219,27 +21650,27 @@ _gather_105_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // expression _loop0_104 + { // with_item _loop0_33 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_104")); - expr_ty elem; + D(fprintf(stderr, "%*c> _gather_34[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_33")); + withitem_ty elem; asdl_seq * seq; if ( - (elem = expression_rule(p)) // expression + (elem = with_item_rule(p)) // with_item && - (seq = _loop0_104_rule(p)) // _loop0_104 + (seq = _loop0_33_rule(p)) // _loop0_33 ) { - D(fprintf(stderr, "%*c+ _gather_105[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_104")); + D(fprintf(stderr, "%*c+ _gather_34[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_33")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_105[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_104")); + D(fprintf(stderr, "%*c%s _gather_34[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_33")); } _res = NULL; done: @@ -35247,11 +21678,11 @@ _gather_105_rule(Parser *p) return _res; } -// _tmp_106: NEWLINE INDENT +// _tmp_35: ',' | ')' | ':' static void * -_tmp_106_rule(Parser *p) +_tmp_35_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -35260,27 +21691,62 @@ _tmp_106_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // NEWLINE INDENT + { // ',' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); - Token * indent_var; - Token * newline_var; + D(fprintf(stderr, "%*c> _tmp_35[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + Token * _literal; if ( - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_106[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); - _res = _PyPegen_dummy_name(p, newline_var, indent_var); + D(fprintf(stderr, "%*c+ _tmp_35[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_106[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c%s _tmp_35[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + } + { // ')' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_35[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ _tmp_35[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_35[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); + } + { // ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_35[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ _tmp_35[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_35[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } _res = NULL; done: @@ -35288,70 +21754,137 @@ _tmp_106_rule(Parser *p) return _res; } -// _tmp_107: -// | (','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) -// | kwargs -static void * -_tmp_107_rule(Parser *p) +// _loop1_36: except_block +static asdl_seq * +_loop1_36_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // (','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // except_block if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs)")); - void *_tmp_169_var; - if ( - (_tmp_169_var = _tmp_169_rule(p)) // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs + D(fprintf(stderr, "%*c> _loop1_36[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block")); + excepthandler_ty except_block_var; + while ( + (except_block_var = except_block_rule(p)) // except_block ) { - D(fprintf(stderr, "%*c+ _tmp_107[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs)")); - _res = _tmp_169_var; - goto done; + _res = except_block_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_107[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs)")); + D(fprintf(stderr, "%*c%s _loop1_36[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_block")); } - { // kwargs + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop1_37: except_star_block +static asdl_seq * +_loop1_37_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // except_star_block if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwargs")); - asdl_seq* kwargs_var; - if ( - (kwargs_var = kwargs_rule(p)) // kwargs + D(fprintf(stderr, "%*c> _loop1_37[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_star_block")); + excepthandler_ty except_star_block_var; + while ( + (except_star_block_var = except_star_block_rule(p)) // except_star_block ) { - D(fprintf(stderr, "%*c+ _tmp_107[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwargs")); - _res = kwargs_var; - goto done; + _res = except_star_block_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_107[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwargs")); + D(fprintf(stderr, "%*c%s _loop1_37[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_star_block")); } - _res = NULL; - done: + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _loop0_108: ',' (starred_expression !'=') +// _loop1_38: case_block static asdl_seq * -_loop0_108_rule(Parser *p) +_loop1_38_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -35360,27 +21893,84 @@ _loop0_108_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // case_block + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop1_38[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "case_block")); + match_case_ty case_block_var; + while ( + (case_block_var = case_block_rule(p)) // case_block + ) + { + _res = case_block_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop1_38[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "case_block")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop0_39: '|' closed_pattern +static asdl_seq * +_loop0_39_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { p->level--; return NULL; } - Py_ssize_t _children_capacity = 1; + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // ',' (starred_expression !'=') + { // '|' closed_pattern if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (starred_expression !'=')")); + D(fprintf(stderr, "%*c> _loop0_39[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|' closed_pattern")); Token * _literal; - void *elem; + pattern_ty elem; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (_literal = _PyPegen_expect_token(p, 18)) // token='|' && - (elem = _tmp_170_rule(p)) // starred_expression !'=' + (elem = closed_pattern_rule(p)) // closed_pattern ) { _res = elem; @@ -35391,29 +21981,26 @@ _loop0_108_rule(Parser *p) return NULL; } if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_108[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (starred_expression !'=')")); + D(fprintf(stderr, "%*c%s _loop0_39[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|' closed_pattern")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -35423,11 +22010,11 @@ _loop0_108_rule(Parser *p) return _seq; } -// _gather_109: (starred_expression !'=') _loop0_108 +// _gather_40: closed_pattern _loop0_39 static asdl_seq * -_gather_109_rule(Parser *p) +_gather_40_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -35436,27 +22023,27 @@ _gather_109_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (starred_expression !'=') _loop0_108 + { // closed_pattern _loop0_39 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression !'=') _loop0_108")); - void *elem; + D(fprintf(stderr, "%*c> _gather_40[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "closed_pattern _loop0_39")); + pattern_ty elem; asdl_seq * seq; if ( - (elem = _tmp_170_rule(p)) // starred_expression !'=' + (elem = closed_pattern_rule(p)) // closed_pattern && - (seq = _loop0_108_rule(p)) // _loop0_108 + (seq = _loop0_39_rule(p)) // _loop0_39 ) { - D(fprintf(stderr, "%*c+ _gather_109[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression !'=') _loop0_108")); + D(fprintf(stderr, "%*c+ _gather_40[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "closed_pattern _loop0_39")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_109[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression !'=') _loop0_108")); + D(fprintf(stderr, "%*c%s _gather_40[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "closed_pattern _loop0_39")); } _res = NULL; done: @@ -35464,11 +22051,11 @@ _gather_109_rule(Parser *p) return _res; } -// _tmp_110: args | expression for_if_clauses +// _tmp_41: '+' | '-' static void * -_tmp_110_rule(Parser *p) +_tmp_41_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -35477,46 +22064,43 @@ _tmp_110_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // args + { // '+' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); - expr_ty args_var; + D(fprintf(stderr, "%*c> _tmp_41[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+'")); + Token * _literal; if ( - (args_var = args_rule(p)) // args + (_literal = _PyPegen_expect_token(p, 14)) // token='+' ) { - D(fprintf(stderr, "%*c+ _tmp_110[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); - _res = args_var; + D(fprintf(stderr, "%*c+ _tmp_41[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+'")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_110[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); + D(fprintf(stderr, "%*c%s _tmp_41[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+'")); } - { // expression for_if_clauses + { // '-' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); - expr_ty expression_var; - asdl_comprehension_seq* for_if_clauses_var; + D(fprintf(stderr, "%*c> _tmp_41[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-'")); + Token * _literal; if ( - (expression_var = expression_rule(p)) // expression - && - (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + (_literal = _PyPegen_expect_token(p, 15)) // token='-' ) { - D(fprintf(stderr, "%*c+ _tmp_110[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); - _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); + D(fprintf(stderr, "%*c+ _tmp_41[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-'")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_110[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c%s _tmp_41[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-'")); } _res = NULL; done: @@ -35524,11 +22108,11 @@ _tmp_110_rule(Parser *p) return _res; } -// _tmp_111: args ',' +// _tmp_42: STRING | FSTRING_START | TSTRING_START static void * -_tmp_111_rule(Parser *p) +_tmp_42_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -35537,84 +22121,62 @@ _tmp_111_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // args ',' + { // STRING if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ','")); - Token * _literal; - expr_ty args_var; + D(fprintf(stderr, "%*c> _tmp_42[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); + expr_ty string_var; if ( - (args_var = args_rule(p)) // args - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (string_var = _PyPegen_string_token(p)) // STRING ) { - D(fprintf(stderr, "%*c+ _tmp_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ','")); - _res = _PyPegen_dummy_name(p, args_var, _literal); + D(fprintf(stderr, "%*c+ _tmp_42[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING")); + _res = string_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_111[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ','")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_112: ',' | ')' -static void * -_tmp_112_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; + D(fprintf(stderr, "%*c%s _tmp_42[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); } - void * _res = NULL; - int _mark = p->mark; - { // ',' + { // FSTRING_START if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_42[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "FSTRING_START")); + Token * fstring_start_var; if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (fstring_start_var = _PyPegen_expect_token(p, FSTRING_START)) // token='FSTRING_START' ) { - D(fprintf(stderr, "%*c+ _tmp_112[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_42[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "FSTRING_START")); + _res = fstring_start_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_112[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + D(fprintf(stderr, "%*c%s _tmp_42[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "FSTRING_START")); } - { // ')' + { // TSTRING_START if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_42[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TSTRING_START")); + Token * tstring_start_var; if ( - (_literal = _PyPegen_expect_token(p, 8)) // token=')' + (tstring_start_var = _PyPegen_expect_token(p, TSTRING_START)) // token='TSTRING_START' ) { - D(fprintf(stderr, "%*c+ _tmp_112[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_42[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TSTRING_START")); + _res = tstring_start_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_112[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c%s _tmp_42[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TSTRING_START")); } _res = NULL; done: @@ -35622,11 +22184,11 @@ _tmp_112_rule(Parser *p) return _res; } -// _tmp_113: 'True' | 'False' | 'None' +// _tmp_43: '.' | '(' | '=' static void * -_tmp_113_rule(Parser *p) +_tmp_43_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -35635,103 +22197,62 @@ _tmp_113_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // 'True' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 627)) // token='True' - ) - { - D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); - } - { // 'False' + { // '.' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); - Token * _keyword; + D(fprintf(stderr, "%*c> _tmp_43[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + Token * _literal; if ( - (_keyword = _PyPegen_expect_token(p, 629)) // token='False' + (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); - _res = _keyword; + D(fprintf(stderr, "%*c+ _tmp_43[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'")); + D(fprintf(stderr, "%*c%s _tmp_43[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } - { // 'None' + { // '(' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); - Token * _keyword; + D(fprintf(stderr, "%*c> _tmp_43[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + Token * _literal; if ( - (_keyword = _PyPegen_expect_token(p, 628)) // token='None' + (_literal = _PyPegen_expect_token(p, 7)) // token='(' ) { - D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); - _res = _keyword; + D(fprintf(stderr, "%*c+ _tmp_43[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_114: NAME '=' -static void * -_tmp_114_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; + D(fprintf(stderr, "%*c%s _tmp_43[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); } - void * _res = NULL; - int _mark = p->mark; - { // NAME '=' + { // '=' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '='")); + D(fprintf(stderr, "%*c> _tmp_43[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); Token * _literal; - expr_ty name_var; if ( - (name_var = _PyPegen_name_token(p)) // NAME - && (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '='")); - _res = _PyPegen_dummy_name(p, name_var, _literal); + D(fprintf(stderr, "%*c+ _tmp_43[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_114[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '='")); + D(fprintf(stderr, "%*c%s _tmp_43[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); } _res = NULL; done: @@ -35739,11 +22260,11 @@ _tmp_114_rule(Parser *p) return _res; } -// _loop1_115: (!STRING expression_without_invalid) +// _loop0_44: ',' maybe_star_pattern static asdl_seq * -_loop1_115_rule(Parser *p) +_loop0_44_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -35752,56 +22273,51 @@ _loop1_115_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // (!STRING expression_without_invalid) + { // ',' maybe_star_pattern if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(!STRING expression_without_invalid)")); - void *_tmp_171_var; + D(fprintf(stderr, "%*c> _loop0_44[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' maybe_star_pattern")); + Token * _literal; + pattern_ty elem; while ( - (_tmp_171_var = _tmp_171_rule(p)) // !STRING expression_without_invalid + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = maybe_star_pattern_rule(p)) // maybe_star_pattern ) { - _res = _tmp_171_var; + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_115[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(!STRING expression_without_invalid)")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; + D(fprintf(stderr, "%*c%s _loop0_44[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' maybe_star_pattern")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -35811,116 +22327,40 @@ _loop1_115_rule(Parser *p) return _seq; } -// _tmp_116: NAME STRING | SOFT_KEYWORD -static void * -_tmp_116_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // NAME STRING - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME STRING")); - expr_ty name_var; - expr_ty string_var; - if ( - (name_var = _PyPegen_name_token(p)) // NAME - && - (string_var = _PyPegen_string_token(p)) // STRING - ) - { - D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME STRING")); - _res = _PyPegen_dummy_name(p, name_var, string_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME STRING")); - } - { // SOFT_KEYWORD - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "SOFT_KEYWORD")); - expr_ty soft_keyword_var; - if ( - (soft_keyword_var = _PyPegen_soft_keyword_token(p)) // SOFT_KEYWORD - ) - { - D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "SOFT_KEYWORD")); - _res = soft_keyword_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "SOFT_KEYWORD")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_117: 'else' | ':' -static void * -_tmp_117_rule(Parser *p) +// _gather_45: maybe_star_pattern _loop0_44 +static asdl_seq * +_gather_45_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // 'else' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 704)) // token='else' - ) - { - D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'else'")); - } - { // ':' + { // maybe_star_pattern _loop0_44 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); - Token * _literal; + D(fprintf(stderr, "%*c> _gather_45[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "maybe_star_pattern _loop0_44")); + pattern_ty elem; + asdl_seq * seq; if ( - (_literal = _PyPegen_expect_token(p, 11)) // token=':' + (elem = maybe_star_pattern_rule(p)) // maybe_star_pattern + && + (seq = _loop0_44_rule(p)) // _loop0_44 ) { - D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _gather_45[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "maybe_star_pattern _loop0_44")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c%s _gather_45[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "maybe_star_pattern _loop0_44")); } _res = NULL; done: @@ -35928,75 +22368,107 @@ _tmp_117_rule(Parser *p) return _res; } -// _tmp_118: pass_stmt | break_stmt | continue_stmt -static void * -_tmp_118_rule(Parser *p) +// _loop0_46: ',' key_value_pattern +static asdl_seq * +_loop0_46_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // pass_stmt + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' key_value_pattern if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pass_stmt")); - stmt_ty pass_stmt_var; - if ( - (pass_stmt_var = pass_stmt_rule(p)) // pass_stmt + D(fprintf(stderr, "%*c> _loop0_46[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); + Token * _literal; + KeyPatternPair* elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = key_value_pattern_rule(p)) // key_value_pattern ) { - D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pass_stmt")); - _res = pass_stmt_var; - goto done; + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pass_stmt")); + D(fprintf(stderr, "%*c%s _loop0_46[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' key_value_pattern")); } - { // break_stmt - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "break_stmt")); - stmt_ty break_stmt_var; - if ( - (break_stmt_var = break_stmt_rule(p)) // break_stmt - ) - { - D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "break_stmt")); - _res = break_stmt_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "break_stmt")); + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _gather_47: key_value_pattern _loop0_46 +static asdl_seq * +_gather_47_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; } - { // continue_stmt + asdl_seq * _res = NULL; + int _mark = p->mark; + { // key_value_pattern _loop0_46 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "continue_stmt")); - stmt_ty continue_stmt_var; + D(fprintf(stderr, "%*c> _gather_47[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_46")); + KeyPatternPair* elem; + asdl_seq * seq; if ( - (continue_stmt_var = continue_stmt_rule(p)) // continue_stmt + (elem = key_value_pattern_rule(p)) // key_value_pattern + && + (seq = _loop0_46_rule(p)) // _loop0_46 ) { - D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "continue_stmt")); - _res = continue_stmt_var; + D(fprintf(stderr, "%*c+ _gather_47[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_46")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "continue_stmt")); + D(fprintf(stderr, "%*c%s _gather_47[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_46")); } _res = NULL; done: @@ -36004,11 +22476,11 @@ _tmp_118_rule(Parser *p) return _res; } -// _tmp_119: '=' | ':=' +// _tmp_48: literal_expr | attr static void * -_tmp_119_rule(Parser *p) +_tmp_48_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -36017,43 +22489,43 @@ _tmp_119_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '=' + { // literal_expr if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_48[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_expr")); + expr_ty literal_expr_var; if ( - (_literal = _PyPegen_expect_token(p, 22)) // token='=' + (literal_expr_var = literal_expr_rule(p)) // literal_expr ) { - D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_48[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_expr")); + _res = literal_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); + D(fprintf(stderr, "%*c%s _tmp_48[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_expr")); } - { // ':=' + { // attr if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':='")); - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_48[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "attr")); + expr_ty attr_var; if ( - (_literal = _PyPegen_expect_token(p, 53)) // token=':=' + (attr_var = attr_rule(p)) // attr ) { - D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':='")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_48[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "attr")); + _res = attr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':='")); + D(fprintf(stderr, "%*c%s _tmp_48[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "attr")); } _res = NULL; done: @@ -36061,132 +22533,107 @@ _tmp_119_rule(Parser *p) return _res; } -// _tmp_120: list | tuple | genexp | 'True' | 'None' | 'False' -static void * -_tmp_120_rule(Parser *p) +// _loop0_49: ',' pattern +static asdl_seq * +_loop0_49_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // list - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); - expr_ty list_var; - if ( - (list_var = list_rule(p)) // list - ) - { - D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); - _res = list_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); - } - { // tuple + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' pattern if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); - expr_ty tuple_var; - if ( - (tuple_var = tuple_rule(p)) // tuple + D(fprintf(stderr, "%*c> _loop0_49[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + Token * _literal; + pattern_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = pattern_rule(p)) // pattern ) { - D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); - _res = tuple_var; - goto done; + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c%s _loop0_49[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } - { // genexp - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); - expr_ty genexp_var; - if ( - (genexp_var = genexp_rule(p)) // genexp - ) - { - D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); - _res = genexp_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; } - { // 'True' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 627)) // token='True' - ) - { - D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _gather_50: pattern _loop0_49 +static asdl_seq * +_gather_50_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); } - { // 'None' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 628)) // token='None' - ) - { - D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); + if (p->error_indicator) { + p->level--; + return NULL; } - { // 'False' + asdl_seq * _res = NULL; + int _mark = p->mark; + { // pattern _loop0_49 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); - Token * _keyword; + D(fprintf(stderr, "%*c> _gather_50[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_49")); + pattern_ty elem; + asdl_seq * seq; if ( - (_keyword = _PyPegen_expect_token(p, 629)) // token='False' + (elem = pattern_rule(p)) // pattern + && + (seq = _loop0_49_rule(p)) // _loop0_49 ) { - D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); - _res = _keyword; + D(fprintf(stderr, "%*c+ _gather_50[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_49")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'")); + D(fprintf(stderr, "%*c%s _gather_50[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_49")); } _res = NULL; done: @@ -36194,11 +22641,11 @@ _tmp_120_rule(Parser *p) return _res; } -// _loop0_121: star_named_expressions +// _loop0_51: ',' keyword_pattern static asdl_seq * -_loop0_121_rule(Parser *p) +_loop0_51_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -36207,51 +22654,51 @@ _loop0_121_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // star_named_expressions + { // ',' keyword_pattern if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); - asdl_expr_seq* star_named_expressions_var; + D(fprintf(stderr, "%*c> _loop0_51[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); + Token * _literal; + KeyPatternPair* elem; while ( - (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = keyword_pattern_rule(p)) // keyword_pattern ) { - _res = star_named_expressions_var; + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_121[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions")); + D(fprintf(stderr, "%*c%s _loop0_51[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -36261,64 +22708,105 @@ _loop0_121_rule(Parser *p) return _seq; } -// _loop0_122: (star_targets '=') +// _gather_52: keyword_pattern _loop0_51 static asdl_seq * -_loop0_122_rule(Parser *p) +_gather_52_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void *_res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); + { // keyword_pattern _loop0_51 + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _gather_52[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_51")); + KeyPatternPair* elem; + asdl_seq * seq; + if ( + (elem = keyword_pattern_rule(p)) // keyword_pattern + && + (seq = _loop0_51_rule(p)) // _loop0_51 + ) + { + D(fprintf(stderr, "%*c+ _gather_52[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_51")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_52[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_51")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop0_53: ',' type_param +static asdl_seq * +_loop0_53_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { p->level--; return NULL; } - Py_ssize_t _children_capacity = 1; + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // (star_targets '=') + { // ',' type_param if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_159_var; + D(fprintf(stderr, "%*c> _loop0_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' type_param")); + Token * _literal; + type_param_ty elem; while ( - (_tmp_159_var = _tmp_159_rule(p)) // star_targets '=' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = type_param_rule(p)) // type_param ) { - _res = _tmp_159_var; + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_122[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); + D(fprintf(stderr, "%*c%s _loop0_53[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' type_param")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -36328,56 +22816,40 @@ _loop0_122_rule(Parser *p) return _seq; } -// _tmp_123: '[' | '{' -static void * -_tmp_123_rule(Parser *p) +// _gather_54: type_param _loop0_53 +static asdl_seq * +_gather_54_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // '[' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - ) - { - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); - } - { // '{' + { // type_param _loop0_53 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); - Token * _literal; + D(fprintf(stderr, "%*c> _gather_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "type_param _loop0_53")); + type_param_ty elem; + asdl_seq * seq; if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' + (elem = type_param_rule(p)) // type_param + && + (seq = _loop0_53_rule(p)) // _loop0_53 ) { - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _gather_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "type_param _loop0_53")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c%s _gather_54[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "type_param _loop0_53")); } _res = NULL; done: @@ -36385,230 +22857,233 @@ _tmp_123_rule(Parser *p) return _res; } -// _tmp_124: slash_no_default | slash_with_default -static void * -_tmp_124_rule(Parser *p) +// _loop1_55: (',' expression) +static asdl_seq * +_loop1_55_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // slash_no_default + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // (',' expression) if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default")); - asdl_arg_seq* slash_no_default_var; - if ( - (slash_no_default_var = slash_no_default_rule(p)) // slash_no_default + D(fprintf(stderr, "%*c> _loop1_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); + void *_tmp_16_var; + while ( + (_tmp_16_var = _tmp_16_rule(p)) // ',' expression ) { - D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default")); - _res = slash_no_default_var; - goto done; + _res = _tmp_16_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default")); + D(fprintf(stderr, "%*c%s _loop1_55[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)")); } - { // slash_with_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); - SlashWithDefault* slash_with_default_var; - if ( - (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default - ) - { - D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); - _res = slash_with_default_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; } - _res = NULL; - done: + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _tmp_125: ',' | param_no_default -static void * -_tmp_125_rule(Parser *p) +// _loop1_56: (',' star_expression) +static asdl_seq * +_loop1_56_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // ',' + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // (',' star_expression) if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + D(fprintf(stderr, "%*c> _loop1_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); + void *_tmp_181_var; + while ( + (_tmp_181_var = _tmp_181_rule(p)) // ',' star_expression ) { - D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; - goto done; + _res = _tmp_181_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + D(fprintf(stderr, "%*c%s _loop1_56[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)")); } - { // param_no_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); - arg_ty param_no_default_var; - if ( - (param_no_default_var = param_no_default_rule(p)) // param_no_default - ) - { - D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); - _res = param_no_default_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; } - _res = NULL; - done: + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _tmp_126: ')' | ',' -static void * -_tmp_126_rule(Parser *p) +// _loop0_57: ',' star_named_expression +static asdl_seq * +_loop0_57_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // ')' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); - } - { // ',' + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' star_named_expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _loop0_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); Token * _literal; - if ( + expr_ty elem; + while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = star_named_expression_rule(p)) // star_named_expression ) { - D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; - goto done; + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + D(fprintf(stderr, "%*c%s _loop0_57[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression")); } - _res = NULL; - done: + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _tmp_127: ')' | ',' (')' | '**') -static void * -_tmp_127_rule(Parser *p) +// _gather_58: star_named_expression _loop0_57 +static asdl_seq * +_gather_58_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // ')' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ _tmp_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_127[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); - } - { // ',' (')' | '**') + { // star_named_expression _loop0_57 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - Token * _literal; - void *_tmp_172_var; + D(fprintf(stderr, "%*c> _gather_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_57")); + expr_ty elem; + asdl_seq * seq; if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (elem = star_named_expression_rule(p)) // star_named_expression && - (_tmp_172_var = _tmp_172_rule(p)) // ')' | '**' + (seq = _loop0_57_rule(p)) // _loop0_57 ) { - D(fprintf(stderr, "%*c+ _tmp_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_172_var); + D(fprintf(stderr, "%*c+ _gather_58[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_57")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_127[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); + D(fprintf(stderr, "%*c%s _gather_58[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_57")); } _res = NULL; done: @@ -36616,144 +23091,200 @@ _tmp_127_rule(Parser *p) return _res; } -// _tmp_128: param_no_default | ',' -static void * -_tmp_128_rule(Parser *p) +// _loop1_59: ('or' conjunction) +static asdl_seq * +_loop1_59_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // param_no_default + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ('or' conjunction) if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); - arg_ty param_no_default_var; - if ( - (param_no_default_var = param_no_default_rule(p)) // param_no_default + D(fprintf(stderr, "%*c> _loop1_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); + void *_tmp_182_var; + while ( + (_tmp_182_var = _tmp_182_rule(p)) // 'or' conjunction ) { - D(fprintf(stderr, "%*c+ _tmp_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); - _res = param_no_default_var; - goto done; + _res = _tmp_182_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_128[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c%s _loop1_59[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); } - { // ',' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ _tmp_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_128[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; } - _res = NULL; - done: + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _tmp_129: '*' | '**' | '/' -static void * -_tmp_129_rule(Parser *p) +// _loop1_60: ('and' inversion) +static asdl_seq * +_loop1_60_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // '*' + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ('and' inversion) if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' + D(fprintf(stderr, "%*c> _loop1_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); + void *_tmp_183_var; + while ( + (_tmp_183_var = _tmp_183_rule(p)) // 'and' inversion ) { - D(fprintf(stderr, "%*c+ _tmp_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); - _res = _literal; - goto done; + _res = _tmp_183_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_129[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); + D(fprintf(stderr, "%*c%s _loop1_60[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); } - { // '**' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' - ) - { - D(fprintf(stderr, "%*c+ _tmp_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_129[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop1_61: compare_op_bitwise_or_pair +static asdl_seq * +_loop1_61_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); } - { // '/' + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // compare_op_bitwise_or_pair if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 17)) // token='/' + D(fprintf(stderr, "%*c> _loop1_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); + CmpopExprPair* compare_op_bitwise_or_pair_var; + while ( + (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair ) { - D(fprintf(stderr, "%*c+ _tmp_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/'")); - _res = _literal; - goto done; + _res = compare_op_bitwise_or_pair_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_129[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'/'")); + D(fprintf(stderr, "%*c%s _loop1_61[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; } - _res = NULL; - done: + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _tmp_130: lambda_slash_no_default | lambda_slash_with_default +// _tmp_62: '!=' static void * -_tmp_130_rule(Parser *p) +_tmp_62_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -36762,43 +23293,29 @@ _tmp_130_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // lambda_slash_no_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); - asdl_arg_seq* lambda_slash_no_default_var; - if ( - (lambda_slash_no_default_var = lambda_slash_no_default_rule(p)) // lambda_slash_no_default - ) - { - D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); - _res = lambda_slash_no_default_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_no_default")); - } - { // lambda_slash_with_default + { // '!=' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); - SlashWithDefault* lambda_slash_with_default_var; + D(fprintf(stderr, "%*c> _tmp_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); + Token * tok; if ( - (lambda_slash_with_default_var = lambda_slash_with_default_rule(p)) // lambda_slash_with_default + (tok = _PyPegen_expect_token(p, 28)) // token='!=' ) { - D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); - _res = lambda_slash_with_default_var; + D(fprintf(stderr, "%*c+ _tmp_62[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); + _res = _PyPegen_check_barry_as_flufl ( p , tok ) ? NULL : tok; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default")); + D(fprintf(stderr, "%*c%s _tmp_62[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); } _res = NULL; done: @@ -36806,11 +23323,11 @@ _tmp_130_rule(Parser *p) return _res; } -// _loop0_131: ',' lambda_param +// _loop0_63: ',' (slice | starred_expression) static asdl_seq * -_loop0_131_rule(Parser *p) +_loop0_63_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -36819,27 +23336,21 @@ _loop0_131_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // ',' lambda_param + { // ',' (slice | starred_expression) if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' lambda_param")); + D(fprintf(stderr, "%*c> _loop0_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (slice | starred_expression)")); Token * _literal; - arg_ty elem; + void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = lambda_param_rule(p)) // lambda_param + (elem = _tmp_184_rule(p)) // slice | starred_expression ) { _res = elem; @@ -36850,29 +23361,26 @@ _loop0_131_rule(Parser *p) return NULL; } if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_131[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' lambda_param")); + D(fprintf(stderr, "%*c%s _loop0_63[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (slice | starred_expression)")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -36882,11 +23390,11 @@ _loop0_131_rule(Parser *p) return _seq; } -// _gather_132: lambda_param _loop0_131 +// _gather_64: (slice | starred_expression) _loop0_63 static asdl_seq * -_gather_132_rule(Parser *p) +_gather_64_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -36895,27 +23403,27 @@ _gather_132_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // lambda_param _loop0_131 + { // (slice | starred_expression) _loop0_63 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_131")); - arg_ty elem; + D(fprintf(stderr, "%*c> _gather_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(slice | starred_expression) _loop0_63")); + void *elem; asdl_seq * seq; if ( - (elem = lambda_param_rule(p)) // lambda_param + (elem = _tmp_184_rule(p)) // slice | starred_expression && - (seq = _loop0_131_rule(p)) // _loop0_131 + (seq = _loop0_63_rule(p)) // _loop0_63 ) { - D(fprintf(stderr, "%*c+ _gather_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_131")); + D(fprintf(stderr, "%*c+ _gather_64[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(slice | starred_expression) _loop0_63")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_132[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param _loop0_131")); + D(fprintf(stderr, "%*c%s _gather_64[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(slice | starred_expression) _loop0_63")); } _res = NULL; done: @@ -36923,11 +23431,11 @@ _gather_132_rule(Parser *p) return _res; } -// _tmp_133: ',' | lambda_param_no_default +// _tmp_65: ':' expression? static void * -_tmp_133_rule(Parser *p) +_tmp_65_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -36936,43 +23444,32 @@ _tmp_133_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ',' + { // ':' expression? if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); Token * _literal; + void *d; if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); - } - { // lambda_param_no_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); - arg_ty lambda_param_no_default_var; - if ( - (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (d = expression_rule(p), !p->error_indicator) // expression? ) { - D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); - _res = lambda_param_no_default_var; + D(fprintf(stderr, "%*c+ _tmp_65[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); + _res = d; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c%s _tmp_65[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); } _res = NULL; done: @@ -36980,11 +23477,11 @@ _tmp_133_rule(Parser *p) return _res; } -// _tmp_134: ':' | ',' (':' | '**') +// _tmp_66: genexp | tuple | group static void * -_tmp_134_rule(Parser *p) +_tmp_66_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -36993,46 +23490,62 @@ _tmp_134_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ':' + { // genexp if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); + expr_ty genexp_var; if ( - (_literal = _PyPegen_expect_token(p, 11)) // token=':' + (genexp_var = genexp_rule(p)) // genexp ) { - D(fprintf(stderr, "%*c+ _tmp_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); + _res = genexp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_134[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c%s _tmp_66[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); } - { // ',' (':' | '**') + { // tuple if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - Token * _literal; - void *_tmp_173_var; + D(fprintf(stderr, "%*c> _tmp_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); + expr_ty tuple_var; if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (_tmp_173_var = _tmp_173_rule(p)) // ':' | '**' + (tuple_var = tuple_rule(p)) // tuple + ) + { + D(fprintf(stderr, "%*c+ _tmp_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + _res = tuple_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_66[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); + } + { // group + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); + expr_ty group_var; + if ( + (group_var = group_rule(p)) // group ) { - D(fprintf(stderr, "%*c+ _tmp_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_173_var); + D(fprintf(stderr, "%*c+ _tmp_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); + _res = group_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_134[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); + D(fprintf(stderr, "%*c%s _tmp_66[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group")); } _res = NULL; done: @@ -37040,11 +23553,11 @@ _tmp_134_rule(Parser *p) return _res; } -// _tmp_135: lambda_param_no_default | ',' +// _tmp_67: listcomp | list static void * -_tmp_135_rule(Parser *p) +_tmp_67_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -37053,43 +23566,43 @@ _tmp_135_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // lambda_param_no_default + { // listcomp if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); - arg_ty lambda_param_no_default_var; + D(fprintf(stderr, "%*c> _tmp_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); + expr_ty listcomp_var; if ( - (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + (listcomp_var = listcomp_rule(p)) // listcomp ) { - D(fprintf(stderr, "%*c+ _tmp_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); - _res = lambda_param_no_default_var; + D(fprintf(stderr, "%*c+ _tmp_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); + _res = listcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_135[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c%s _tmp_67[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp")); } - { // ',' + { // list if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); + expr_ty list_var; if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (list_var = list_rule(p)) // list ) { - D(fprintf(stderr, "%*c+ _tmp_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + _res = list_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_135[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + D(fprintf(stderr, "%*c%s _tmp_67[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); } _res = NULL; done: @@ -37097,11 +23610,11 @@ _tmp_135_rule(Parser *p) return _res; } -// _tmp_136: bitwise_or ((',' bitwise_or))* ','? +// _tmp_68: dictcomp | setcomp | dict | set static void * -_tmp_136_rule(Parser *p) +_tmp_68_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -37110,31 +23623,81 @@ _tmp_136_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // bitwise_or ((',' bitwise_or))* ','? + { // dictcomp if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or ((',' bitwise_or))* ','?")); - asdl_seq * _loop0_174_var; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty bitwise_or_var; + D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); + expr_ty dictcomp_var; if ( - (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or - && - (_loop0_174_var = _loop0_174_rule(p)) // ((',' bitwise_or))* - && - (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? + (dictcomp_var = dictcomp_rule(p)) // dictcomp + ) + { + D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); + _res = dictcomp_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp")); + } + { // setcomp + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); + expr_ty setcomp_var; + if ( + (setcomp_var = setcomp_rule(p)) // setcomp + ) + { + D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); + _res = setcomp_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp")); + } + { // dict + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); + expr_ty dict_var; + if ( + (dict_var = dict_rule(p)) // dict + ) + { + D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); + _res = dict_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict")); + } + { // set + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); + expr_ty set_var; + if ( + (set_var = set_rule(p)) // set ) { - D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or ((',' bitwise_or))* ','?")); - _res = _PyPegen_dummy_name(p, bitwise_or_var, _loop0_174_var, _opt_var); + D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); + _res = set_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or ((',' bitwise_or))* ','?")); + D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set")); } _res = NULL; done: @@ -37142,116 +23705,56 @@ _tmp_136_rule(Parser *p) return _res; } -// _loop0_137: ',' dotted_name -static asdl_seq * -_loop0_137_rule(Parser *p) +// _tmp_69: yield_expr | named_expression +static void * +_tmp_69_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void *_res = NULL; + void * _res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' dotted_name + { // yield_expr if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' dotted_name")); - Token * _literal; - expr_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = dotted_name_rule(p)) // dotted_name + D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + expr_ty yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; + D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + _res = yield_expr_var; + goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_137[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' dotted_name")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_138: dotted_name _loop0_137 -static asdl_seq * -_gather_138_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); - } - if (p->error_indicator) { - p->level--; - return NULL; + D(fprintf(stderr, "%*c%s _tmp_69[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // dotted_name _loop0_137 + { // named_expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_name _loop0_137")); - expr_ty elem; - asdl_seq * seq; + D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); + expr_ty named_expression_var; if ( - (elem = dotted_name_rule(p)) // dotted_name - && - (seq = _loop0_137_rule(p)) // _loop0_137 + (named_expression_var = named_expression_rule(p)) // named_expression ) { - D(fprintf(stderr, "%*c+ _gather_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_name _loop0_137")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); + D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); + _res = named_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_138[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_name _loop0_137")); + D(fprintf(stderr, "%*c%s _tmp_69[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); } _res = NULL; done: @@ -37259,52 +23762,69 @@ _gather_138_rule(Parser *p) return _res; } -// _tmp_139: NAME (',' | ')' | ';' | NEWLINE) -static void * -_tmp_139_rule(Parser *p) +// _loop0_70: lambda_param_no_default +static asdl_seq * +_loop0_70_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // NAME (',' | ')' | ';' | NEWLINE) + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // lambda_param_no_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME (',' | ')' | ';' | NEWLINE)")); - void *_tmp_175_var; - expr_ty name_var; - if ( - (name_var = _PyPegen_name_token(p)) // NAME - && - (_tmp_175_var = _tmp_175_rule(p)) // ',' | ')' | ';' | NEWLINE + D(fprintf(stderr, "%*c> _loop0_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + arg_ty lambda_param_no_default_var; + while ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default ) { - D(fprintf(stderr, "%*c+ _tmp_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME (',' | ')' | ';' | NEWLINE)")); - _res = _PyPegen_dummy_name(p, name_var, _tmp_175_var); - goto done; + _res = lambda_param_no_default_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_139[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME (',' | ')' | ';' | NEWLINE)")); + D(fprintf(stderr, "%*c%s _loop0_70[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } - _res = NULL; - done: + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _loop0_140: ',' (expression ['as' star_target]) +// _loop0_71: lambda_param_with_default static asdl_seq * -_loop0_140_rule(Parser *p) +_loop0_71_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -37313,60 +23833,42 @@ _loop0_140_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // ',' (expression ['as' star_target]) + { // lambda_param_with_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expression ['as' star_target])")); - Token * _literal; - void *elem; + D(fprintf(stderr, "%*c> _loop0_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + NameDefaultPair* lambda_param_with_default_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = _tmp_176_rule(p)) // expression ['as' star_target] + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default ) { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } + _res = lambda_param_with_default_var; if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_140[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expression ['as' star_target])")); + D(fprintf(stderr, "%*c%s _loop0_71[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -37376,52 +23878,74 @@ _loop0_140_rule(Parser *p) return _seq; } -// _gather_141: (expression ['as' star_target]) _loop0_140 +// _loop1_72: lambda_param_no_default static asdl_seq * -_gather_141_rule(Parser *p) +_loop1_72_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - asdl_seq * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // (expression ['as' star_target]) _loop0_140 + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // lambda_param_no_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_140")); - void *elem; - asdl_seq * seq; - if ( - (elem = _tmp_176_rule(p)) // expression ['as' star_target] - && - (seq = _loop0_140_rule(p)) // _loop0_140 + D(fprintf(stderr, "%*c> _loop1_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + arg_ty lambda_param_no_default_var; + while ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default ) { - D(fprintf(stderr, "%*c+ _gather_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_140")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; + _res = lambda_param_no_default_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_141[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expression ['as' star_target]) _loop0_140")); + D(fprintf(stderr, "%*c%s _loop1_72[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } - _res = NULL; - done: + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _loop0_142: ',' (expressions ['as' star_target]) +// _loop1_73: lambda_param_with_default static asdl_seq * -_loop0_142_rule(Parser *p) +_loop1_73_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -37430,60 +23954,47 @@ _loop0_142_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // ',' (expressions ['as' star_target]) + { // lambda_param_with_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expressions ['as' star_target])")); - Token * _literal; - void *elem; + D(fprintf(stderr, "%*c> _loop1_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + NameDefaultPair* lambda_param_with_default_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = _tmp_177_rule(p)) // expressions ['as' star_target] + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default ) { - _res = elem; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } + _res = lambda_param_with_default_var; if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_142[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expressions ['as' star_target])")); + D(fprintf(stderr, "%*c%s _loop1_73[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -37493,109 +24004,132 @@ _loop0_142_rule(Parser *p) return _seq; } -// _gather_143: (expressions ['as' star_target]) _loop0_142 +// _loop0_74: lambda_param_maybe_default static asdl_seq * -_gather_143_rule(Parser *p) +_loop0_74_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - asdl_seq * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // (expressions ['as' star_target]) _loop0_142 + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // lambda_param_maybe_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_142")); - void *elem; - asdl_seq * seq; - if ( - (elem = _tmp_177_rule(p)) // expressions ['as' star_target] - && - (seq = _loop0_142_rule(p)) // _loop0_142 + D(fprintf(stderr, "%*c> _loop0_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + NameDefaultPair* lambda_param_maybe_default_var; + while ( + (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default ) { - D(fprintf(stderr, "%*c+ _gather_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_142")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; + _res = lambda_param_maybe_default_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_143[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expressions ['as' star_target]) _loop0_142")); + D(fprintf(stderr, "%*c%s _loop0_74[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } - _res = NULL; - done: + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _tmp_144: 'except' | 'finally' -static void * -_tmp_144_rule(Parser *p) +// _loop1_75: lambda_param_maybe_default +static asdl_seq * +_loop1_75_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // 'except' + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // lambda_param_maybe_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 695)) // token='except' + D(fprintf(stderr, "%*c> _loop1_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + NameDefaultPair* lambda_param_maybe_default_var; + while ( + (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default ) { - D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except'")); - _res = _keyword; - goto done; + _res = lambda_param_maybe_default_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except'")); + D(fprintf(stderr, "%*c%s _loop1_75[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } - { // 'finally' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'finally'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 691)) // token='finally' - ) - { - D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'finally'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'finally'")); + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; } - _res = NULL; - done: + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _loop0_145: block +// _loop0_76: fstring_format_spec static asdl_seq * -_loop0_145_rule(Parser *p) +_loop0_76_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -37604,51 +24138,42 @@ _loop0_145_rule(Parser *p) } void *_res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; Py_ssize_t _n = 0; - { // block + { // fstring_format_spec if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "block")); - asdl_stmt_seq* block_var; + D(fprintf(stderr, "%*c> _loop0_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring_format_spec")); + expr_ty fstring_format_spec_var; while ( - (block_var = block_rule(p)) // block + (fstring_format_spec_var = fstring_format_spec_rule(p)) // fstring_format_spec ) { - _res = block_var; + _res = fstring_format_spec_var; if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - _children = _new_children; } _children[_n++] = _res; _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_145[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "block")); + D(fprintf(stderr, "%*c%s _loop0_76[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "fstring_format_spec")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { - PyMem_Free(_children); p->error_indicator = 1; PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } @@ -37658,465 +24183,407 @@ _loop0_145_rule(Parser *p) return _seq; } -// _tmp_146: expression ['as' NAME] -static void * -_tmp_146_rule(Parser *p) +// _loop0_77: fstring_middle +static asdl_seq * +_loop0_77_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // expression ['as' NAME] + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // fstring_middle if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' NAME]")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty expression_var; - if ( - (expression_var = expression_rule(p)) // expression - && - (_opt_var = _tmp_21_rule(p), !p->error_indicator) // ['as' NAME] + D(fprintf(stderr, "%*c> _loop0_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring_middle")); + expr_ty fstring_middle_var; + while ( + (fstring_middle_var = fstring_middle_rule(p)) // fstring_middle ) { - D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' NAME]")); - _res = _PyPegen_dummy_name(p, expression_var, _opt_var); - goto done; + _res = fstring_middle_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' NAME]")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_147: NEWLINE | ':' -static void * -_tmp_147_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); + D(fprintf(stderr, "%*c%s _loop0_77[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "fstring_middle")); } - if (p->error_indicator) { + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - void * _res = NULL; - int _mark = p->mark; - { // NEWLINE - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); - Token * newline_var; - if ( - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - ) - { - D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); - _res = newline_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); - } - { // ':' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); - } - _res = NULL; - done: + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _tmp_148: items_pattern ',' -static void * -_tmp_148_rule(Parser *p) +// _loop0_78: tstring_format_spec +static asdl_seq * +_loop0_78_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // items_pattern ',' + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // tstring_format_spec if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "items_pattern ','")); - Token * _literal; - asdl_seq* items_pattern_var; - if ( - (items_pattern_var = items_pattern_rule(p)) // items_pattern - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + D(fprintf(stderr, "%*c> _loop0_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tstring_format_spec")); + expr_ty tstring_format_spec_var; + while ( + (tstring_format_spec_var = tstring_format_spec_rule(p)) // tstring_format_spec ) { - D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "items_pattern ','")); - _res = _PyPegen_dummy_name(p, items_pattern_var, _literal); - goto done; + _res = tstring_format_spec_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "items_pattern ','")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_149: positional_patterns ',' -static void * -_tmp_149_rule(Parser *p) -{ - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { - _Pypegen_stack_overflow(p); + D(fprintf(stderr, "%*c%s _loop0_78[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tstring_format_spec")); } - if (p->error_indicator) { + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); p->level--; return NULL; } - void * _res = NULL; - int _mark = p->mark; - { // positional_patterns ',' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "positional_patterns ','")); - Token * _literal; - asdl_pattern_seq* positional_patterns_var; - if ( - (positional_patterns_var = positional_patterns_rule(p)) // positional_patterns - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "positional_patterns ','")); - _res = _PyPegen_dummy_name(p, positional_patterns_var, _literal); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "positional_patterns ','")); - } - _res = NULL; - done: + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _tmp_150: invalid_kvpair | invalid_kvpair_unpacking -static void * -_tmp_150_rule(Parser *p) +// _loop0_79: tstring_middle +static asdl_seq * +_loop0_79_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - if (p->call_invalid_rules) { // invalid_kvpair + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // tstring_middle if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kvpair")); - void *invalid_kvpair_var; - if ( - (invalid_kvpair_var = invalid_kvpair_rule(p)) // invalid_kvpair + D(fprintf(stderr, "%*c> _loop0_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tstring_middle")); + expr_ty tstring_middle_var; + while ( + (tstring_middle_var = tstring_middle_rule(p)) // tstring_middle ) { - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kvpair")); - _res = invalid_kvpair_var; - goto done; + _res = tstring_middle_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kvpair")); + D(fprintf(stderr, "%*c%s _loop0_79[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tstring_middle")); } - if (p->call_invalid_rules) { // invalid_kvpair_unpacking - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kvpair_unpacking")); - void *invalid_kvpair_unpacking_var; - if ( - (invalid_kvpair_unpacking_var = invalid_kvpair_unpacking_rule(p)) // invalid_kvpair_unpacking - ) - { - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kvpair_unpacking")); - _res = invalid_kvpair_unpacking_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kvpair_unpacking")); + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; } - _res = NULL; - done: + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _tmp_151: '}' | ',' -static void * -_tmp_151_rule(Parser *p) +// _loop1_80: (fstring | string) +static asdl_seq * +_loop1_80_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // '}' + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // (fstring | string) if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 26)) // token='}' + D(fprintf(stderr, "%*c> _loop1_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(fstring | string)")); + void *_tmp_185_var; + while ( + (_tmp_185_var = _tmp_185_rule(p)) // fstring | string ) { - D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); - _res = _literal; - goto done; + _res = _tmp_185_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); + D(fprintf(stderr, "%*c%s _loop1_80[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(fstring | string)")); } - { // ',' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; } - _res = NULL; - done: + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _tmp_152: '=' | '!' | ':' | '}' -static void * -_tmp_152_rule(Parser *p) +// _loop1_81: tstring +static asdl_seq * +_loop1_81_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // '=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); - } - { // '!' + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // tstring if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 54)) // token='!' + D(fprintf(stderr, "%*c> _loop1_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tstring")); + expr_ty tstring_var; + while ( + (tstring_var = tstring_rule(p)) // tstring ) { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!'")); - _res = _literal; - goto done; + _res = tstring_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!'")); + D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tstring")); } - { // ':' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; } - { // '}' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 26)) // token='}' - ) - { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; } - _res = NULL; - done: + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _tmp_153: '!' | ':' | '}' -static void * -_tmp_153_rule(Parser *p) +// _loop0_82: ',' display_item +static asdl_seq * +_loop0_82_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // '!' + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' display_item if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!'")); + D(fprintf(stderr, "%*c> _loop0_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' display_item")); Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 54)) // token='!' + expr_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = display_item_rule(p)) // display_item ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!'")); - _res = _literal; - goto done; + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!'")); + D(fprintf(stderr, "%*c%s _loop0_82[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' display_item")); } - { // ':' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _gather_83: display_item _loop0_82 +static asdl_seq * +_gather_83_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); } - { // '}' + if (p->error_indicator) { + p->level--; + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // display_item _loop0_82 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); - Token * _literal; + D(fprintf(stderr, "%*c> _gather_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "display_item _loop0_82")); + expr_ty elem; + asdl_seq * seq; if ( - (_literal = _PyPegen_expect_token(p, 26)) // token='}' + (elem = display_item_rule(p)) // display_item + && + (seq = _loop0_82_rule(p)) // _loop0_82 ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _gather_83[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "display_item _loop0_82")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); + D(fprintf(stderr, "%*c%s _gather_83[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "display_item _loop0_82")); } _res = NULL; done: @@ -38124,11 +24591,11 @@ _tmp_153_rule(Parser *p) return _res; } -// _tmp_154: '!' NAME +// _tmp_84: display_item ',' display_items? static void * -_tmp_154_rule(Parser *p) +_tmp_84_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -38137,27 +24604,35 @@ _tmp_154_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '!' NAME + { // display_item ',' display_items? if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' NAME")); + D(fprintf(stderr, "%*c> _tmp_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "display_item ',' display_items?")); Token * _literal; - expr_ty name_var; + expr_ty y; + void *z; if ( - (_literal = _PyPegen_expect_token(p, 54)) // token='!' + (y = display_item_rule(p)) // display_item && - (name_var = _PyPegen_name_token(p)) // NAME + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (z = display_items_rule(p), !p->error_indicator) // display_items? ) { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' NAME")); - _res = _PyPegen_dummy_name(p, _literal, name_var); + D(fprintf(stderr, "%*c+ _tmp_84[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "display_item ',' display_items?")); + _res = _PyPegen_seq_insert_in_front ( p , y , z ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!' NAME")); + D(fprintf(stderr, "%*c%s _tmp_84[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "display_item ',' display_items?")); } _res = NULL; done: @@ -38165,56 +24640,107 @@ _tmp_154_rule(Parser *p) return _res; } -// _tmp_155: ':' | '}' -static void * -_tmp_155_rule(Parser *p) +// _loop0_85: ',' double_starred_kvpair +static asdl_seq * +_loop0_85_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // ':' + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' double_starred_kvpair if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _loop0_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 11)) // token=':' + KeyValuePair* elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair ) { - D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); - _res = _literal; - goto done; + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c%s _loop0_85[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _gather_86: double_starred_kvpair _loop0_85 +static asdl_seq * +_gather_86_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; } - { // '}' + asdl_seq * _res = NULL; + int _mark = p->mark; + { // double_starred_kvpair _loop0_85 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); - Token * _literal; + D(fprintf(stderr, "%*c> _gather_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_85")); + KeyValuePair* elem; + asdl_seq * seq; if ( - (_literal = _PyPegen_expect_token(p, 26)) // token='}' + (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair + && + (seq = _loop0_85_rule(p)) // _loop0_85 ) { - D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _gather_86[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_85")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); + D(fprintf(stderr, "%*c%s _gather_86[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_85")); } _res = NULL; done: @@ -38222,208 +24748,198 @@ _tmp_155_rule(Parser *p) return _res; } -// _tmp_156: fstring | string -static void * -_tmp_156_rule(Parser *p) +// _loop1_87: for_if_clause +static asdl_seq * +_loop1_87_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // fstring + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // for_if_clause if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring")); - expr_ty fstring_var; - if ( - (fstring_var = fstring_rule(p)) // fstring + D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); + comprehension_ty for_if_clause_var; + while ( + (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause ) { - D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "fstring")); - _res = fstring_var; - goto done; + _res = for_if_clause_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "fstring")); + D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); } - { // string - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "string")); - expr_ty string_var; - if ( - (string_var = string_rule(p)) // string - ) - { - D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "string")); - _res = string_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "string")); + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; } - _res = NULL; - done: + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _tmp_157: '+' | '-' | '*' | '/' | '%' | '//' | '@' -static void * -_tmp_157_rule(Parser *p) +// _loop0_88: ('if' disjunction) +static asdl_seq * +_loop0_88_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // '+' + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ('if' disjunction) if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 14)) // token='+' + D(fprintf(stderr, "%*c> _loop0_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_186_var; + while ( + (_tmp_186_var = _tmp_186_rule(p)) // 'if' disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+'")); - _res = _literal; - goto done; + _res = _tmp_186_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+'")); + D(fprintf(stderr, "%*c%s _loop0_88[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } - { // '-' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 15)) // token='-' - ) - { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-'")); + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; } - { // '*' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - ) - { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _tmp_89: assignment_expression | expression !':=' | starred_expression +static void * +_tmp_89_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); } - { // '/' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 17)) // token='/' - ) - { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'/'")); + if (p->error_indicator) { + p->level--; + return NULL; } - { // '%' + void * _res = NULL; + int _mark = p->mark; + { // assignment_expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'%'")); - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment_expression")); + expr_ty assignment_expression_var; if ( - (_literal = _PyPegen_expect_token(p, 24)) // token='%' + (assignment_expression_var = assignment_expression_rule(p)) // assignment_expression ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'%'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_89[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment_expression")); + _res = assignment_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'%'")); + D(fprintf(stderr, "%*c%s _tmp_89[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment_expression")); } - { // '//' + { // expression !':=' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'//'")); - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); + expr_ty expression_var; if ( - (_literal = _PyPegen_expect_token(p, 47)) // token='//' + (expression_var = expression_rule(p)) // expression + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'//'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_89[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); + _res = expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'//'")); + D(fprintf(stderr, "%*c%s _tmp_89[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='")); } - { // '@' + { // starred_expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'")); - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); + expr_ty starred_expression_var; if ( - (_literal = _PyPegen_expect_token(p, 49)) // token='@' + (starred_expression_var = starred_expression_rule(p)) // starred_expression ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_89[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); + _res = starred_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'")); + D(fprintf(stderr, "%*c%s _tmp_89[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); } _res = NULL; done: @@ -38431,75 +24947,108 @@ _tmp_157_rule(Parser *p) return _res; } -// _tmp_158: '+' | '-' | '~' -static void * -_tmp_158_rule(Parser *p) +// _loop0_90: ',' (starred_expression | (assignment_expression | expression !':=') !'=') +static asdl_seq * +_loop0_90_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // '+' + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' (starred_expression | (assignment_expression | expression !':=') !'=') if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+'")); + D(fprintf(stderr, "%*c> _loop0_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (starred_expression | (assignment_expression | expression !':=') !'=')")); Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 14)) // token='+' + void *elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = _tmp_187_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+'")); - _res = _literal; - goto done; + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+'")); + D(fprintf(stderr, "%*c%s _loop0_90[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (starred_expression | (assignment_expression | expression !':=') !'=')")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _gather_91: +// | (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_90 +static asdl_seq * +_gather_91_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); } - { // '-' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 15)) // token='-' - ) - { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-'")); + if (p->error_indicator) { + p->level--; + return NULL; } - { // '~' + asdl_seq * _res = NULL; + int _mark = p->mark; + { // (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_90 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'~'")); - Token * _literal; + D(fprintf(stderr, "%*c> _gather_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_90")); + void *elem; + asdl_seq * seq; if ( - (_literal = _PyPegen_expect_token(p, 31)) // token='~' + (elem = _tmp_187_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' + && + (seq = _loop0_90_rule(p)) // _loop0_90 ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'~'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _gather_91[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_90")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'~'")); + D(fprintf(stderr, "%*c%s _gather_91[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_90")); } _res = NULL; done: @@ -38507,11 +25056,11 @@ _tmp_158_rule(Parser *p) return _res; } -// _tmp_159: star_targets '=' +// _tmp_92: ',' kwargs static void * -_tmp_159_rule(Parser *p) +_tmp_92_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -38520,22 +25069,22 @@ _tmp_159_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // star_targets '=' + { // ',' kwargs if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwargs")); Token * _literal; - expr_ty z; + asdl_seq* k; if ( - (z = star_targets_rule(p)) // star_targets + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' + (k = kwargs_rule(p)) // kwargs ) { - D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); - _res = z; + D(fprintf(stderr, "%*c+ _tmp_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' kwargs")); + _res = k; if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -38544,8 +25093,8 @@ _tmp_159_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c%s _tmp_92[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwargs")); } _res = NULL; done: @@ -38553,56 +25102,107 @@ _tmp_159_rule(Parser *p) return _res; } -// _tmp_160: '.' | '...' -static void * -_tmp_160_rule(Parser *p) +// _loop0_93: ',' kwarg_or_starred +static asdl_seq * +_loop0_93_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // '.' + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' kwarg_or_starred if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _loop0_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 23)) // token='.' + KeywordOrStarred* elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred ) { - D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); - _res = _literal; - goto done; + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c%s _loop0_93[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } - { // '...' + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _gather_94: kwarg_or_starred _loop0_93 +static asdl_seq * +_gather_94_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // kwarg_or_starred _loop0_93 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); - Token * _literal; + D(fprintf(stderr, "%*c> _gather_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_93")); + KeywordOrStarred* elem; + asdl_seq * seq; if ( - (_literal = _PyPegen_expect_token(p, 52)) // token='...' + (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred + && + (seq = _loop0_93_rule(p)) // _loop0_93 ) { - D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _gather_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_93")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c%s _gather_94[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_93")); } _res = NULL; done: @@ -38610,11 +25210,11 @@ _tmp_160_rule(Parser *p) return _res; } -// _tmp_161: '@' named_expression NEWLINE +// _tmp_95: ',' ','.kwarg_or_double_starred+ static void * -_tmp_161_rule(Parser *p) +_tmp_95_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -38623,25 +25223,22 @@ _tmp_161_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '@' named_expression NEWLINE + { // ',' ','.kwarg_or_double_starred+ if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.kwarg_or_double_starred+")); Token * _literal; - expr_ty f; - Token * newline_var; + asdl_seq * c; if ( - (_literal = _PyPegen_expect_token(p, 49)) // token='@' - && - (f = named_expression_rule(p)) // named_expression + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + (c = _gather_97_rule(p)) // ','.kwarg_or_double_starred+ ) { - D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); - _res = f; + D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.kwarg_or_double_starred+")); + _res = c; if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -38650,8 +25247,8 @@ _tmp_161_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.kwarg_or_double_starred+")); } _res = NULL; done: @@ -38659,91 +25256,107 @@ _tmp_161_rule(Parser *p) return _res; } -// _tmp_162: ',' star_expression -static void * -_tmp_162_rule(Parser *p) +// _loop0_96: ',' kwarg_or_double_starred +static asdl_seq * +_loop0_96_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // ',' star_expression + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' kwarg_or_double_starred if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _loop0_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; - expr_ty c; - if ( + KeywordOrStarred* elem; + while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (c = star_expression_rule(p)) // star_expression + (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred ) { - D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); - _res = c; + _res = elem; if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; + PyMem_Free(_children); p->level--; return NULL; } - goto done; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c%s _loop0_96[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } - _res = NULL; - done: + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _tmp_163: 'or' conjunction -static void * -_tmp_163_rule(Parser *p) +// _gather_97: kwarg_or_double_starred _loop0_96 +static asdl_seq * +_gather_97_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // 'or' conjunction + { // kwarg_or_double_starred _loop0_96 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); - Token * _keyword; - expr_ty c; + D(fprintf(stderr, "%*c> _gather_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_96")); + KeywordOrStarred* elem; + asdl_seq * seq; if ( - (_keyword = _PyPegen_expect_token(p, 589)) // token='or' + (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (c = conjunction_rule(p)) // conjunction + (seq = _loop0_96_rule(p)) // _loop0_96 ) { - D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); - _res = c; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ _gather_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_96")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c%s _gather_97[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_96")); } _res = NULL; done: @@ -38751,11 +25364,69 @@ _tmp_163_rule(Parser *p) return _res; } -// _tmp_164: 'and' inversion +// _loop0_98: (',' star_target) +static asdl_seq * +_loop0_98_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // (',' star_target) + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); + void *_tmp_188_var; + while ( + (_tmp_188_var = _tmp_188_rule(p)) // ',' star_target + ) + { + _res = _tmp_188_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_98[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _tmp_99: !'*' star_target static void * -_tmp_164_rule(Parser *p) +_tmp_99_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -38764,32 +25435,26 @@ _tmp_164_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // 'and' inversion + { // !'*' star_target if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); - Token * _keyword; - expr_ty c; + D(fprintf(stderr, "%*c> _tmp_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + expr_ty star_target_var; if ( - (_keyword = _PyPegen_expect_token(p, 590)) // token='and' + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' && - (c = inversion_rule(p)) // inversion + (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); - _res = c; - if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_99[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + _res = star_target_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c%s _tmp_99[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); } _res = NULL; done: @@ -38797,11 +25462,11 @@ _tmp_164_rule(Parser *p) return _res; } -// _tmp_165: slice | starred_expression +// _tmp_100: '(' | '[' | '.' static void * -_tmp_165_rule(Parser *p) +_tmp_100_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -38810,43 +25475,62 @@ _tmp_165_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // slice + { // '(' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice")); - expr_ty slice_var; + D(fprintf(stderr, "%*c> _tmp_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + Token * _literal; if ( - (slice_var = slice_rule(p)) // slice + (_literal = _PyPegen_expect_token(p, 7)) // token='(' ) { - D(fprintf(stderr, "%*c+ _tmp_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice")); - _res = slice_var; + D(fprintf(stderr, "%*c+ _tmp_100[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_165[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice")); + D(fprintf(stderr, "%*c%s _tmp_100[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); } - { // starred_expression + { // '[' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); - expr_ty starred_expression_var; + D(fprintf(stderr, "%*c> _tmp_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + Token * _literal; if ( - (starred_expression_var = starred_expression_rule(p)) // starred_expression + (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); - _res = starred_expression_var; + D(fprintf(stderr, "%*c+ _tmp_100[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_165[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); + D(fprintf(stderr, "%*c%s _tmp_100[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); + } + { // '.' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 23)) // token='.' + ) + { + D(fprintf(stderr, "%*c+ _tmp_100[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_100[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } _res = NULL; done: @@ -38854,104 +25538,107 @@ _tmp_165_rule(Parser *p) return _res; } -// _tmp_166: 'if' disjunction -static void * -_tmp_166_rule(Parser *p) +// _loop0_101: ',' del_target +static asdl_seq * +_loop0_101_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // 'if' disjunction + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' del_target if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); - Token * _keyword; - expr_ty z; - if ( - (_keyword = _PyPegen_expect_token(p, 700)) // token='if' + D(fprintf(stderr, "%*c> _loop0_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); + Token * _literal; + expr_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (z = disjunction_rule(p)) // disjunction + (elem = del_target_rule(p)) // del_target ) { - D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); - _res = z; + _res = elem; if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; + PyMem_Free(_children); p->level--; return NULL; } - goto done; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c%s _loop0_101[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); } - _res = NULL; - done: + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _tmp_167: starred_expression | (assignment_expression | expression !':=') !'=' -static void * -_tmp_167_rule(Parser *p) +// _gather_102: del_target _loop0_101 +static asdl_seq * +_gather_102_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // starred_expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); - expr_ty starred_expression_var; - if ( - (starred_expression_var = starred_expression_rule(p)) // starred_expression - ) - { - D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); - _res = starred_expression_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_167[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); - } - { // (assignment_expression | expression !':=') !'=' + { // del_target _loop0_101 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); - void *_tmp_178_var; + D(fprintf(stderr, "%*c> _gather_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_101")); + expr_ty elem; + asdl_seq * seq; if ( - (_tmp_178_var = _tmp_178_rule(p)) // assignment_expression | expression !':=' + (elem = del_target_rule(p)) // del_target && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' + (seq = _loop0_101_rule(p)) // _loop0_101 ) { - D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); - _res = _tmp_178_var; + D(fprintf(stderr, "%*c+ _gather_102[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_101")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_167[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(assignment_expression | expression !':=') !'='")); + D(fprintf(stderr, "%*c%s _gather_102[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_101")); } _res = NULL; done: @@ -38959,90 +25646,107 @@ _tmp_167_rule(Parser *p) return _res; } -// _tmp_168: ',' star_target -static void * -_tmp_168_rule(Parser *p) +// _loop0_103: ',' expression +static asdl_seq * +_loop0_103_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // ',' star_target + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _loop0_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; - expr_ty c; - if ( + expr_ty elem; + while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (c = star_target_rule(p)) // star_target + (elem = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); - _res = c; + _res = elem; if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { p->error_indicator = 1; + PyMem_Free(_children); p->level--; return NULL; } - goto done; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c%s _loop0_103[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } - _res = NULL; - done: + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); p->level--; - return _res; + return _seq; } -// _tmp_169: -// | ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs -static void * -_tmp_169_rule(Parser *p) +// _gather_104: expression _loop0_103 +static asdl_seq * +_gather_104_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs + { // expression _loop0_103 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs")); - asdl_seq * _gather_91_var; - Token * _literal; - asdl_seq* kwargs_var; + D(fprintf(stderr, "%*c> _gather_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_103")); + expr_ty elem; + asdl_seq * seq; if ( - (_gather_91_var = _gather_91_rule(p)) // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (elem = expression_rule(p)) // expression && - (kwargs_var = kwargs_rule(p)) // kwargs + (seq = _loop0_103_rule(p)) // _loop0_103 ) { - D(fprintf(stderr, "%*c+ _tmp_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs")); - _res = _PyPegen_dummy_name(p, _gather_91_var, _literal, kwargs_var); + D(fprintf(stderr, "%*c+ _gather_104[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_103")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_169[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs")); + D(fprintf(stderr, "%*c%s _gather_104[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_103")); } _res = NULL; done: @@ -39050,11 +25754,11 @@ _tmp_169_rule(Parser *p) return _res; } -// _tmp_170: starred_expression !'=' +// _tmp_105: NEWLINE INDENT static void * -_tmp_170_rule(Parser *p) +_tmp_105_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -39063,26 +25767,27 @@ _tmp_170_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // starred_expression !'=' + { // NEWLINE INDENT if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression !'='")); - expr_ty starred_expression_var; + D(fprintf(stderr, "%*c> _tmp_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + Token * indent_var; + Token * newline_var; if ( - (starred_expression_var = starred_expression_rule(p)) // starred_expression + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' + (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' ) { - D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression !'='")); - _res = starred_expression_var; + D(fprintf(stderr, "%*c+ _tmp_105[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + _res = _PyPegen_dummy_name(p, newline_var, indent_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_170[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression !'='")); + D(fprintf(stderr, "%*c%s _tmp_105[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT")); } _res = NULL; done: @@ -39090,11 +25795,11 @@ _tmp_170_rule(Parser *p) return _res; } -// _tmp_171: !STRING expression_without_invalid +// _tmp_178: star_targets '=' static void * -_tmp_171_rule(Parser *p) +_tmp_178_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -39103,26 +25808,32 @@ _tmp_171_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // !STRING expression_without_invalid + { // star_targets '=' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!STRING expression_without_invalid")); - expr_ty expression_without_invalid_var; + D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + Token * _literal; + expr_ty z; if ( - _PyPegen_lookahead(0, _PyPegen_string_token, p) + (z = star_targets_rule(p)) // star_targets && - (expression_without_invalid_var = expression_without_invalid_rule(p)) // expression_without_invalid + (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!STRING expression_without_invalid")); - _res = expression_without_invalid_var; + D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + _res = z; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_171[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!STRING expression_without_invalid")); + D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; done: @@ -39130,11 +25841,11 @@ _tmp_171_rule(Parser *p) return _res; } -// _tmp_172: ')' | '**' +// _tmp_179: '.' | '...' static void * -_tmp_172_rule(Parser *p) +_tmp_179_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -39143,43 +25854,92 @@ _tmp_172_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ')' + { // '.' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( - (_literal = _PyPegen_expect_token(p, 8)) // token=')' + (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_172[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c%s _tmp_179[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } - { // '**' + { // '...' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' + (_literal = _PyPegen_expect_token(p, 52)) // token='...' + ) + { + D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_179[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_180: '@' named_expression NEWLINE +static void * +_tmp_180_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '@' named_expression NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + Token * _literal; + expr_ty f; + Token * newline_var; + if ( + (_literal = _PyPegen_expect_token(p, 49)) // token='@' + && + (f = named_expression_rule(p)) // named_expression + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + _res = f; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_172[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c%s _tmp_180[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE")); } _res = NULL; done: @@ -39187,11 +25947,11 @@ _tmp_172_rule(Parser *p) return _res; } -// _tmp_173: ':' | '**' +// _tmp_181: ',' star_expression static void * -_tmp_173_rule(Parser *p) +_tmp_181_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -39200,43 +25960,32 @@ _tmp_173_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ':' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_173[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); - } - { // '**' + { // ',' star_expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; + expr_ty c; if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (c = star_expression_rule(p)) // star_expression ) { - D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + _res = c; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_173[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c%s _tmp_181[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } _res = NULL; done: @@ -39244,78 +25993,57 @@ _tmp_173_rule(Parser *p) return _res; } -// _loop0_174: (',' bitwise_or) -static asdl_seq * -_loop0_174_rule(Parser *p) +// _tmp_182: 'or' conjunction +static void * +_tmp_182_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { p->level--; return NULL; } - void *_res = NULL; + void * _res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // (',' bitwise_or) + { // 'or' conjunction if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' bitwise_or)")); - void *_tmp_179_var; - while ( - (_tmp_179_var = _tmp_179_rule(p)) // ',' bitwise_or + D(fprintf(stderr, "%*c> _tmp_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + Token * _keyword; + expr_ty c; + if ( + (_keyword = _PyPegen_expect_token(p, 529)) // token='or' + && + (c = conjunction_rule(p)) // conjunction ) { - _res = _tmp_179_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; + D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + _res = c; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; } - _children[_n++] = _res; - _mark = p->mark; + goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_174[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' bitwise_or)")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; + D(fprintf(stderr, "%*c%s _tmp_182[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); } - for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); + _res = NULL; + done: p->level--; - return _seq; + return _res; } -// _tmp_175: ',' | ')' | ';' | NEWLINE +// _tmp_183: 'and' inversion static void * -_tmp_175_rule(Parser *p) +_tmp_183_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -39324,81 +26052,89 @@ _tmp_175_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ',' + { // 'and' inversion if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + Token * _keyword; + expr_ty c; if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (_keyword = _PyPegen_expect_token(p, 530)) // token='and' + && + (c = inversion_rule(p)) // inversion ) { - D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + _res = c; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + D(fprintf(stderr, "%*c%s _tmp_183[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); } - { // ')' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_184: slice | starred_expression +static void * +_tmp_184_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); } - { // ';' + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // slice if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'")); - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_184[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice")); + expr_ty slice_var; if ( - (_literal = _PyPegen_expect_token(p, 13)) // token=';' + (slice_var = slice_rule(p)) // slice ) { - D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_184[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice")); + _res = slice_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'")); + D(fprintf(stderr, "%*c%s _tmp_184[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice")); } - { // NEWLINE + { // starred_expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); - Token * newline_var; + D(fprintf(stderr, "%*c> _tmp_184[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); + expr_ty starred_expression_var; if ( - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + (starred_expression_var = starred_expression_rule(p)) // starred_expression ) { - D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); - _res = newline_var; + D(fprintf(stderr, "%*c+ _tmp_184[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); + _res = starred_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); + D(fprintf(stderr, "%*c%s _tmp_184[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); } _res = NULL; done: @@ -39406,11 +26142,11 @@ _tmp_175_rule(Parser *p) return _res; } -// _tmp_176: expression ['as' star_target] +// _tmp_185: fstring | string static void * -_tmp_176_rule(Parser *p) +_tmp_185_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -39419,28 +26155,43 @@ _tmp_176_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // expression ['as' star_target] + { // fstring if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty expression_var; + D(fprintf(stderr, "%*c> _tmp_185[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring")); + expr_ty fstring_var; if ( - (expression_var = expression_rule(p)) // expression - && - (_opt_var = _tmp_180_rule(p), !p->error_indicator) // ['as' star_target] + (fstring_var = fstring_rule(p)) // fstring + ) + { + D(fprintf(stderr, "%*c+ _tmp_185[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "fstring")); + _res = fstring_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_185[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "fstring")); + } + { // string + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_185[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "string")); + expr_ty string_var; + if ( + (string_var = string_rule(p)) // string ) { - D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); - _res = _PyPegen_dummy_name(p, expression_var, _opt_var); + D(fprintf(stderr, "%*c+ _tmp_185[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "string")); + _res = string_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' star_target]")); + D(fprintf(stderr, "%*c%s _tmp_185[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "string")); } _res = NULL; done: @@ -39448,11 +26199,11 @@ _tmp_176_rule(Parser *p) return _res; } -// _tmp_177: expressions ['as' star_target] +// _tmp_186: 'if' disjunction static void * -_tmp_177_rule(Parser *p) +_tmp_186_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -39461,28 +26212,32 @@ _tmp_177_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // expressions ['as' star_target] + { // 'if' disjunction if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty expressions_var; + D(fprintf(stderr, "%*c> _tmp_186[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + Token * _keyword; + expr_ty z; if ( - (expressions_var = expressions_rule(p)) // expressions + (_keyword = _PyPegen_expect_token(p, 514)) // token='if' && - (_opt_var = _tmp_180_rule(p), !p->error_indicator) // ['as' star_target] + (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); - _res = _PyPegen_dummy_name(p, expressions_var, _opt_var); + D(fprintf(stderr, "%*c+ _tmp_186[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + _res = z; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_177[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expressions ['as' star_target]")); + D(fprintf(stderr, "%*c%s _tmp_186[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; done: @@ -39490,11 +26245,11 @@ _tmp_177_rule(Parser *p) return _res; } -// _tmp_178: assignment_expression | expression !':=' +// _tmp_187: starred_expression | (assignment_expression | expression !':=') !'=' static void * -_tmp_178_rule(Parser *p) +_tmp_187_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -39503,45 +26258,45 @@ _tmp_178_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // assignment_expression + { // starred_expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment_expression")); - expr_ty assignment_expression_var; + D(fprintf(stderr, "%*c> _tmp_187[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); + expr_ty starred_expression_var; if ( - (assignment_expression_var = assignment_expression_rule(p)) // assignment_expression + (starred_expression_var = starred_expression_rule(p)) // starred_expression ) { - D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment_expression")); - _res = assignment_expression_var; + D(fprintf(stderr, "%*c+ _tmp_187[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); + _res = starred_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment_expression")); + D(fprintf(stderr, "%*c%s _tmp_187[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); } - { // expression !':=' + { // (assignment_expression | expression !':=') !'=' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); - expr_ty expression_var; + D(fprintf(stderr, "%*c> _tmp_187[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); + void *_tmp_200_var; if ( - (expression_var = expression_rule(p)) // expression + (_tmp_200_var = _tmp_200_rule(p)) // assignment_expression | expression !':=' && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); - _res = expression_var; + D(fprintf(stderr, "%*c+ _tmp_187[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); + _res = _tmp_200_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='")); + D(fprintf(stderr, "%*c%s _tmp_187[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(assignment_expression | expression !':=') !'='")); } _res = NULL; done: @@ -39549,11 +26304,11 @@ _tmp_178_rule(Parser *p) return _res; } -// _tmp_179: ',' bitwise_or +// _tmp_188: ',' star_target static void * -_tmp_179_rule(Parser *p) +_tmp_188_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -39562,27 +26317,32 @@ _tmp_179_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ',' bitwise_or + { // ',' star_target if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' bitwise_or")); + D(fprintf(stderr, "%*c> _tmp_188[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; - expr_ty bitwise_or_var; + expr_ty c; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + (c = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' bitwise_or")); - _res = _PyPegen_dummy_name(p, _literal, bitwise_or_var); + D(fprintf(stderr, "%*c+ _tmp_188[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); + _res = c; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_179[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' bitwise_or")); + D(fprintf(stderr, "%*c%s _tmp_188[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } _res = NULL; done: @@ -39590,11 +26350,11 @@ _tmp_179_rule(Parser *p) return _res; } -// _tmp_180: 'as' star_target +// _tmp_200: assignment_expression | expression !':=' static void * -_tmp_180_rule(Parser *p) +_tmp_200_rule(Parser *p) { - if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) { + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { _Pypegen_stack_overflow(p); } if (p->error_indicator) { @@ -39603,27 +26363,45 @@ _tmp_180_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // 'as' star_target + { // assignment_expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); - Token * _keyword; - expr_ty star_target_var; + D(fprintf(stderr, "%*c> _tmp_200[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment_expression")); + expr_ty assignment_expression_var; + if ( + (assignment_expression_var = assignment_expression_rule(p)) // assignment_expression + ) + { + D(fprintf(stderr, "%*c+ _tmp_200[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment_expression")); + _res = assignment_expression_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_200[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment_expression")); + } + { // expression !':=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_200[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); + expr_ty expression_var; if ( - (_keyword = _PyPegen_expect_token(p, 698)) // token='as' + (expression_var = expression_rule(p)) // expression && - (star_target_var = star_target_rule(p)) // star_target + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' ) { - D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); - _res = _PyPegen_dummy_name(p, _keyword, star_target_var); + D(fprintf(stderr, "%*c+ _tmp_200[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); + _res = expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_180[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c%s _tmp_200[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='")); } _res = NULL; done: diff --git a/Parser/parser_invalid.c b/Parser/parser_invalid.c new file mode 100644 index 000000000000000..b306b9869a90dd7 --- /dev/null +++ b/Parser/parser_invalid.c @@ -0,0 +1,13389 @@ +// @generated by pegen from invalid.gram +#include "pegen.h" +#include "pycore_ceval.h" + +#if defined(Py_DEBUG) && defined(Py_BUILD_CORE) +# define D(x) if (p->debug) { x; } +#else +# define D(x) +#endif + +#ifdef __wasi__ +# ifdef Py_DEBUG +# define MAXSTACK 1000 +# else +# define MAXSTACK 4000 +# endif +#else +# define MAXSTACK 6000 +#endif +#define invalid_arguments_type 1193 +#define invalid_kwarg_type 1194 +#define expression_without_invalid_type 1195 +#define invalid_legacy_expression_type 1196 +#define invalid_type_param_type 1197 +#define invalid_expression_type 1198 +#define invalid_if_expression_type 1199 +#define invalid_named_expression_type 1200 +#define invalid_assignment_type 1201 +#define invalid_ann_assign_target_type 1202 +#define invalid_raise_stmt_type 1203 +#define invalid_del_stmt_type 1204 +#define invalid_assert_stmt_type 1205 +#define invalid_block_type 1206 +#define invalid_comprehension_type 1207 +#define invalid_parameters_type 1208 +#define invalid_default_type 1209 +#define invalid_star_etc_type 1210 +#define invalid_kwds_type 1211 +#define invalid_parameters_helper_type 1212 +#define invalid_lambda_parameters_type 1213 +#define invalid_lambda_parameters_helper_type 1214 +#define invalid_lambda_star_etc_type 1215 +#define invalid_lambda_kwds_type 1216 +#define invalid_double_type_comments_type 1217 +#define invalid_with_item_type 1218 +#define invalid_for_if_clause_type 1219 +#define invalid_for_target_type 1220 +#define invalid_group_type 1221 +#define invalid_import_type 1222 +#define invalid_dotted_as_name_type 1223 +#define invalid_import_from_as_name_type 1224 +#define invalid_import_from_type 1225 +#define invalid_import_from_targets_type 1226 +#define invalid_with_stmt_type 1227 +#define invalid_with_stmt_indent_type 1228 +#define invalid_try_stmt_type 1229 +#define invalid_except_stmt_type 1230 +#define invalid_except_star_stmt_type 1231 +#define invalid_finally_stmt_type 1232 +#define invalid_except_stmt_indent_type 1233 +#define invalid_except_star_stmt_indent_type 1234 +#define invalid_match_stmt_type 1235 +#define invalid_case_block_type 1236 +#define invalid_as_pattern_type 1237 +#define invalid_class_pattern_type 1238 +#define invalid_mapping_pattern_type 1239 +#define invalid_class_argument_pattern_type 1240 +#define invalid_if_stmt_type 1241 +#define invalid_elif_stmt_type 1242 +#define invalid_else_stmt_type 1243 +#define invalid_while_stmt_type 1244 +#define invalid_for_stmt_type 1245 +#define invalid_def_raw_type 1246 +#define invalid_class_def_raw_type 1247 +#define invalid_double_starred_kvpairs_type 1248 +#define invalid_kvpair_unpacking_type 1249 +#define invalid_kvpair_type 1250 +#define invalid_starred_expression_unpacking_type 1251 +#define invalid_starred_expression_unpacking_sequence_type 1252 +#define invalid_starred_expression_type 1253 +#define invalid_fstring_replacement_field_type 1254 +#define invalid_fstring_conversion_character_type 1255 +#define invalid_tstring_replacement_field_type 1256 +#define invalid_tstring_conversion_character_type 1257 +#define invalid_string_tstring_concat_type 1258 +#define invalid_arithmetic_type 1259 // Left-recursive +#define invalid_factor_type 1260 +#define invalid_type_params_type 1261 +#define invalid_bitwise_and_type 1262 // Left-recursive +#define invalid_bitwise_or_type 1263 // Left-recursive +#define invalid_noteq_type 1264 +#define _tmp_106_type 1370 +#define _loop0_107_type 1371 +#define _gather_108_type 1372 +#define _tmp_109_type 1373 +#define _tmp_110_type 1374 +#define _tmp_111_type 1375 +#define _tmp_112_type 1376 +#define _loop1_113_type 1377 +#define _tmp_114_type 1378 +#define _tmp_115_type 1379 +#define _tmp_116_type 1380 +#define _tmp_117_type 1381 +#define _tmp_118_type 1382 +#define _loop0_119_type 1383 +#define _loop0_120_type 1384 +#define _tmp_121_type 1385 +#define _tmp_122_type 1386 +#define _loop0_123_type 1387 +#define _loop0_124_type 1388 +#define _loop1_125_type 1389 +#define _tmp_126_type 1390 +#define _loop1_127_type 1391 +#define _tmp_128_type 1392 +#define _tmp_129_type 1393 +#define _tmp_130_type 1394 +#define _tmp_131_type 1395 +#define _loop1_132_type 1396 +#define _tmp_133_type 1397 +#define _loop0_134_type 1398 +#define _loop0_135_type 1399 +#define _loop0_136_type 1400 +#define _gather_137_type 1401 +#define _tmp_138_type 1402 +#define _loop1_139_type 1403 +#define _loop1_140_type 1404 +#define _tmp_141_type 1405 +#define _tmp_142_type 1406 +#define _tmp_143_type 1407 +#define _tmp_144_type 1408 +#define _loop0_145_type 1409 +#define _gather_146_type 1410 +#define _tmp_147_type 1411 +#define _loop0_148_type 1412 +#define _loop0_149_type 1413 +#define _gather_150_type 1414 +#define _loop0_151_type 1415 +#define _gather_152_type 1416 +#define _tmp_153_type 1417 +#define _loop0_154_type 1418 +#define _loop1_155_type 1419 +#define _tmp_156_type 1420 +#define _loop1_157_type 1421 +#define _tmp_158_type 1422 +#define _tmp_159_type 1423 +#define _tmp_160_type 1424 +#define _tmp_161_type 1425 +#define _tmp_162_type 1426 +#define _tmp_163_type 1427 +#define _loop0_164_type 1428 +#define _gather_165_type 1429 +#define _tmp_166_type 1430 +#define _tmp_167_type 1431 +#define _tmp_168_type 1432 +#define _tmp_169_type 1433 +#define _tmp_170_type 1434 +#define _tmp_171_type 1435 +#define _loop0_172_type 1436 +#define _loop1_173_type 1437 +#define _loop1_174_type 1438 +#define _tmp_175_type 1439 +#define _tmp_176_type 1440 +#define _tmp_177_type 1441 +#define _tmp_189_type 1453 +#define _tmp_190_type 1454 +#define _tmp_191_type 1455 +#define _tmp_192_type 1456 +#define _tmp_193_type 1457 +#define _tmp_194_type 1458 +#define _loop0_195_type 1459 +#define _tmp_196_type 1460 +#define _tmp_197_type 1461 +#define _tmp_198_type 1462 +#define _tmp_199_type 1463 +#define _loop0_201_type 1465 +#define _gather_202_type 1466 +#define _tmp_203_type 1467 +#define _tmp_204_type 1468 +#define _tmp_205_type 1469 +#define _tmp_206_type 1470 + +// Rules shared between the C files of this parser +#define simple_stmt_rule _PyPegen_simple_stmt_rule +Py_LOCAL_SYMBOL stmt_ty simple_stmt_rule(Parser *p); +#define annotated_rhs_rule _PyPegen_annotated_rhs_rule +Py_LOCAL_SYMBOL expr_ty annotated_rhs_rule(Parser *p); +#define augassign_rule _PyPegen_augassign_rule +Py_LOCAL_SYMBOL AugOperator* augassign_rule(Parser *p); +#define pass_stmt_rule _PyPegen_pass_stmt_rule +Py_LOCAL_SYMBOL stmt_ty pass_stmt_rule(Parser *p); +#define break_stmt_rule _PyPegen_break_stmt_rule +Py_LOCAL_SYMBOL stmt_ty break_stmt_rule(Parser *p); +#define continue_stmt_rule _PyPegen_continue_stmt_rule +Py_LOCAL_SYMBOL stmt_ty continue_stmt_rule(Parser *p); +#define import_from_targets_rule _PyPegen_import_from_targets_rule +Py_LOCAL_SYMBOL asdl_alias_seq* import_from_targets_rule(Parser *p); +#define import_from_as_names_rule _PyPegen_import_from_as_names_rule +Py_LOCAL_SYMBOL asdl_alias_seq* import_from_as_names_rule(Parser *p); +#define dotted_name_rule _PyPegen_dotted_name_rule +Py_LOCAL_SYMBOL expr_ty dotted_name_rule(Parser *p); +#define block_rule _PyPegen_block_rule +Py_LOCAL_SYMBOL asdl_stmt_seq* block_rule(Parser *p); +#define params_rule _PyPegen_params_rule +Py_LOCAL_SYMBOL arguments_ty params_rule(Parser *p); +#define slash_no_default_rule _PyPegen_slash_no_default_rule +Py_LOCAL_SYMBOL asdl_arg_seq* slash_no_default_rule(Parser *p); +#define slash_with_default_rule _PyPegen_slash_with_default_rule +Py_LOCAL_SYMBOL SlashWithDefault* slash_with_default_rule(Parser *p); +#define param_no_default_rule _PyPegen_param_no_default_rule +Py_LOCAL_SYMBOL arg_ty param_no_default_rule(Parser *p); +#define param_with_default_rule _PyPegen_param_with_default_rule +Py_LOCAL_SYMBOL NameDefaultPair* param_with_default_rule(Parser *p); +#define param_maybe_default_rule _PyPegen_param_maybe_default_rule +Py_LOCAL_SYMBOL NameDefaultPair* param_maybe_default_rule(Parser *p); +#define param_rule _PyPegen_param_rule +Py_LOCAL_SYMBOL arg_ty param_rule(Parser *p); +#define except_block_rule _PyPegen_except_block_rule +Py_LOCAL_SYMBOL excepthandler_ty except_block_rule(Parser *p); +#define except_star_block_rule _PyPegen_except_star_block_rule +Py_LOCAL_SYMBOL excepthandler_ty except_star_block_rule(Parser *p); +#define subject_expr_rule _PyPegen_subject_expr_rule +Py_LOCAL_SYMBOL expr_ty subject_expr_rule(Parser *p); +#define guard_rule _PyPegen_guard_rule +Py_LOCAL_SYMBOL expr_ty guard_rule(Parser *p); +#define patterns_rule _PyPegen_patterns_rule +Py_LOCAL_SYMBOL pattern_ty patterns_rule(Parser *p); +#define or_pattern_rule _PyPegen_or_pattern_rule +Py_LOCAL_SYMBOL pattern_ty or_pattern_rule(Parser *p); +#define name_or_attr_rule _PyPegen_name_or_attr_rule +Py_LOCAL_SYMBOL expr_ty name_or_attr_rule(Parser *p); +#define items_pattern_rule _PyPegen_items_pattern_rule +Py_LOCAL_SYMBOL asdl_seq* items_pattern_rule(Parser *p); +#define double_star_pattern_rule _PyPegen_double_star_pattern_rule +Py_LOCAL_SYMBOL expr_ty double_star_pattern_rule(Parser *p); +#define positional_patterns_rule _PyPegen_positional_patterns_rule +Py_LOCAL_SYMBOL asdl_pattern_seq* positional_patterns_rule(Parser *p); +#define keyword_patterns_rule _PyPegen_keyword_patterns_rule +Py_LOCAL_SYMBOL asdl_seq* keyword_patterns_rule(Parser *p); +#define type_params_rule _PyPegen_type_params_rule +Py_LOCAL_SYMBOL asdl_type_param_seq* type_params_rule(Parser *p); +#define expressions_rule _PyPegen_expressions_rule +Py_LOCAL_SYMBOL expr_ty expressions_rule(Parser *p); +#define expression_rule _PyPegen_expression_rule +Py_LOCAL_SYMBOL expr_ty expression_rule(Parser *p); +#define if_expression_rule _PyPegen_if_expression_rule +Py_LOCAL_SYMBOL expr_ty if_expression_rule(Parser *p); +#define yield_expr_rule _PyPegen_yield_expr_rule +Py_LOCAL_SYMBOL expr_ty yield_expr_rule(Parser *p); +#define star_expressions_rule _PyPegen_star_expressions_rule +Py_LOCAL_SYMBOL expr_ty star_expressions_rule(Parser *p); +#define star_named_expressions_rule _PyPegen_star_named_expressions_rule +Py_LOCAL_SYMBOL asdl_expr_seq* star_named_expressions_rule(Parser *p); +#define star_named_expression_rule _PyPegen_star_named_expression_rule +Py_LOCAL_SYMBOL expr_ty star_named_expression_rule(Parser *p); +#define assignment_expression_rule _PyPegen_assignment_expression_rule +Py_LOCAL_SYMBOL expr_ty assignment_expression_rule(Parser *p); +#define named_expression_rule _PyPegen_named_expression_rule +Py_LOCAL_SYMBOL expr_ty named_expression_rule(Parser *p); +#define disjunction_rule _PyPegen_disjunction_rule +Py_LOCAL_SYMBOL expr_ty disjunction_rule(Parser *p); +#define inversion_rule _PyPegen_inversion_rule +Py_LOCAL_SYMBOL expr_ty inversion_rule(Parser *p); +#define bitwise_or_rule _PyPegen_bitwise_or_rule +Py_LOCAL_SYMBOL expr_ty bitwise_or_rule(Parser *p); +#define bitwise_and_rule _PyPegen_bitwise_and_rule +Py_LOCAL_SYMBOL expr_ty bitwise_and_rule(Parser *p); +#define sum_rule _PyPegen_sum_rule +Py_LOCAL_SYMBOL expr_ty sum_rule(Parser *p); +#define factor_rule _PyPegen_factor_rule +Py_LOCAL_SYMBOL expr_ty factor_rule(Parser *p); +#define lambdef_rule _PyPegen_lambdef_rule +Py_LOCAL_SYMBOL expr_ty lambdef_rule(Parser *p); +#define lambda_params_rule _PyPegen_lambda_params_rule +Py_LOCAL_SYMBOL arguments_ty lambda_params_rule(Parser *p); +#define lambda_slash_no_default_rule _PyPegen_lambda_slash_no_default_rule +Py_LOCAL_SYMBOL asdl_arg_seq* lambda_slash_no_default_rule(Parser *p); +#define lambda_slash_with_default_rule _PyPegen_lambda_slash_with_default_rule +Py_LOCAL_SYMBOL SlashWithDefault* lambda_slash_with_default_rule(Parser *p); +#define lambda_param_no_default_rule _PyPegen_lambda_param_no_default_rule +Py_LOCAL_SYMBOL arg_ty lambda_param_no_default_rule(Parser *p); +#define lambda_param_with_default_rule _PyPegen_lambda_param_with_default_rule +Py_LOCAL_SYMBOL NameDefaultPair* lambda_param_with_default_rule(Parser *p); +#define lambda_param_maybe_default_rule _PyPegen_lambda_param_maybe_default_rule +Py_LOCAL_SYMBOL NameDefaultPair* lambda_param_maybe_default_rule(Parser *p); +#define lambda_param_rule _PyPegen_lambda_param_rule +Py_LOCAL_SYMBOL arg_ty lambda_param_rule(Parser *p); +#define fstring_format_spec_rule _PyPegen_fstring_format_spec_rule +Py_LOCAL_SYMBOL expr_ty fstring_format_spec_rule(Parser *p); +#define fstring_rule _PyPegen_fstring_rule +Py_LOCAL_SYMBOL expr_ty fstring_rule(Parser *p); +#define tstring_rule _PyPegen_tstring_rule +Py_LOCAL_SYMBOL expr_ty tstring_rule(Parser *p); +#define string_rule _PyPegen_string_rule +Py_LOCAL_SYMBOL expr_ty string_rule(Parser *p); +#define list_rule _PyPegen_list_rule +Py_LOCAL_SYMBOL expr_ty list_rule(Parser *p); +#define tuple_rule _PyPegen_tuple_rule +Py_LOCAL_SYMBOL expr_ty tuple_rule(Parser *p); +#define double_starred_kvpair_rule _PyPegen_double_starred_kvpair_rule +Py_LOCAL_SYMBOL KeyValuePair* double_starred_kvpair_rule(Parser *p); +#define for_if_clauses_rule _PyPegen_for_if_clauses_rule +Py_LOCAL_SYMBOL asdl_comprehension_seq* for_if_clauses_rule(Parser *p); +#define genexp_rule _PyPegen_genexp_rule +Py_LOCAL_SYMBOL expr_ty genexp_rule(Parser *p); +#define arguments_rule _PyPegen_arguments_rule +Py_LOCAL_SYMBOL expr_ty arguments_rule(Parser *p); +#define args_rule _PyPegen_args_rule +Py_LOCAL_SYMBOL expr_ty args_rule(Parser *p); +#define kwargs_rule _PyPegen_kwargs_rule +Py_LOCAL_SYMBOL asdl_seq* kwargs_rule(Parser *p); +#define starred_expression_rule _PyPegen_starred_expression_rule +Py_LOCAL_SYMBOL expr_ty starred_expression_rule(Parser *p); +#define star_targets_rule _PyPegen_star_targets_rule +Py_LOCAL_SYMBOL expr_ty star_targets_rule(Parser *p); +#define star_target_rule _PyPegen_star_target_rule +Py_LOCAL_SYMBOL expr_ty star_target_rule(Parser *p); +#define func_type_comment_rule _PyPegen_func_type_comment_rule +Py_LOCAL_SYMBOL Token* func_type_comment_rule(Parser *p); +#define invalid_arguments_rule _PyPegen_invalid_arguments_rule +Py_LOCAL_SYMBOL void *invalid_arguments_rule(Parser *p); +#define invalid_kwarg_rule _PyPegen_invalid_kwarg_rule +Py_LOCAL_SYMBOL void *invalid_kwarg_rule(Parser *p); +#define invalid_legacy_expression_rule _PyPegen_invalid_legacy_expression_rule +Py_LOCAL_SYMBOL void *invalid_legacy_expression_rule(Parser *p); +#define invalid_type_param_rule _PyPegen_invalid_type_param_rule +Py_LOCAL_SYMBOL void *invalid_type_param_rule(Parser *p); +#define invalid_expression_rule _PyPegen_invalid_expression_rule +Py_LOCAL_SYMBOL void *invalid_expression_rule(Parser *p); +#define invalid_if_expression_rule _PyPegen_invalid_if_expression_rule +Py_LOCAL_SYMBOL void *invalid_if_expression_rule(Parser *p); +#define invalid_named_expression_rule _PyPegen_invalid_named_expression_rule +Py_LOCAL_SYMBOL void *invalid_named_expression_rule(Parser *p); +#define invalid_assignment_rule _PyPegen_invalid_assignment_rule +Py_LOCAL_SYMBOL void *invalid_assignment_rule(Parser *p); +#define invalid_raise_stmt_rule _PyPegen_invalid_raise_stmt_rule +Py_LOCAL_SYMBOL void *invalid_raise_stmt_rule(Parser *p); +#define invalid_del_stmt_rule _PyPegen_invalid_del_stmt_rule +Py_LOCAL_SYMBOL void *invalid_del_stmt_rule(Parser *p); +#define invalid_assert_stmt_rule _PyPegen_invalid_assert_stmt_rule +Py_LOCAL_SYMBOL void *invalid_assert_stmt_rule(Parser *p); +#define invalid_block_rule _PyPegen_invalid_block_rule +Py_LOCAL_SYMBOL void *invalid_block_rule(Parser *p); +#define invalid_comprehension_rule _PyPegen_invalid_comprehension_rule +Py_LOCAL_SYMBOL void *invalid_comprehension_rule(Parser *p); +#define invalid_parameters_rule _PyPegen_invalid_parameters_rule +Py_LOCAL_SYMBOL void *invalid_parameters_rule(Parser *p); +#define invalid_default_rule _PyPegen_invalid_default_rule +Py_LOCAL_SYMBOL void *invalid_default_rule(Parser *p); +#define invalid_star_etc_rule _PyPegen_invalid_star_etc_rule +Py_LOCAL_SYMBOL void *invalid_star_etc_rule(Parser *p); +#define invalid_kwds_rule _PyPegen_invalid_kwds_rule +Py_LOCAL_SYMBOL void *invalid_kwds_rule(Parser *p); +#define invalid_lambda_parameters_rule _PyPegen_invalid_lambda_parameters_rule +Py_LOCAL_SYMBOL void *invalid_lambda_parameters_rule(Parser *p); +#define invalid_lambda_star_etc_rule _PyPegen_invalid_lambda_star_etc_rule +Py_LOCAL_SYMBOL void *invalid_lambda_star_etc_rule(Parser *p); +#define invalid_lambda_kwds_rule _PyPegen_invalid_lambda_kwds_rule +Py_LOCAL_SYMBOL void *invalid_lambda_kwds_rule(Parser *p); +#define invalid_double_type_comments_rule _PyPegen_invalid_double_type_comments_rule +Py_LOCAL_SYMBOL void *invalid_double_type_comments_rule(Parser *p); +#define invalid_with_item_rule _PyPegen_invalid_with_item_rule +Py_LOCAL_SYMBOL void *invalid_with_item_rule(Parser *p); +#define invalid_for_if_clause_rule _PyPegen_invalid_for_if_clause_rule +Py_LOCAL_SYMBOL void *invalid_for_if_clause_rule(Parser *p); +#define invalid_for_target_rule _PyPegen_invalid_for_target_rule +Py_LOCAL_SYMBOL void *invalid_for_target_rule(Parser *p); +#define invalid_group_rule _PyPegen_invalid_group_rule +Py_LOCAL_SYMBOL void *invalid_group_rule(Parser *p); +#define invalid_import_rule _PyPegen_invalid_import_rule +Py_LOCAL_SYMBOL void *invalid_import_rule(Parser *p); +#define invalid_dotted_as_name_rule _PyPegen_invalid_dotted_as_name_rule +Py_LOCAL_SYMBOL void *invalid_dotted_as_name_rule(Parser *p); +#define invalid_import_from_as_name_rule _PyPegen_invalid_import_from_as_name_rule +Py_LOCAL_SYMBOL void *invalid_import_from_as_name_rule(Parser *p); +#define invalid_import_from_rule _PyPegen_invalid_import_from_rule +Py_LOCAL_SYMBOL void *invalid_import_from_rule(Parser *p); +#define invalid_import_from_targets_rule _PyPegen_invalid_import_from_targets_rule +Py_LOCAL_SYMBOL void *invalid_import_from_targets_rule(Parser *p); +#define invalid_with_stmt_rule _PyPegen_invalid_with_stmt_rule +Py_LOCAL_SYMBOL void *invalid_with_stmt_rule(Parser *p); +#define invalid_with_stmt_indent_rule _PyPegen_invalid_with_stmt_indent_rule +Py_LOCAL_SYMBOL void *invalid_with_stmt_indent_rule(Parser *p); +#define invalid_try_stmt_rule _PyPegen_invalid_try_stmt_rule +Py_LOCAL_SYMBOL void *invalid_try_stmt_rule(Parser *p); +#define invalid_except_stmt_rule _PyPegen_invalid_except_stmt_rule +Py_LOCAL_SYMBOL void *invalid_except_stmt_rule(Parser *p); +#define invalid_except_star_stmt_rule _PyPegen_invalid_except_star_stmt_rule +Py_LOCAL_SYMBOL void *invalid_except_star_stmt_rule(Parser *p); +#define invalid_finally_stmt_rule _PyPegen_invalid_finally_stmt_rule +Py_LOCAL_SYMBOL void *invalid_finally_stmt_rule(Parser *p); +#define invalid_except_stmt_indent_rule _PyPegen_invalid_except_stmt_indent_rule +Py_LOCAL_SYMBOL void *invalid_except_stmt_indent_rule(Parser *p); +#define invalid_except_star_stmt_indent_rule _PyPegen_invalid_except_star_stmt_indent_rule +Py_LOCAL_SYMBOL void *invalid_except_star_stmt_indent_rule(Parser *p); +#define invalid_match_stmt_rule _PyPegen_invalid_match_stmt_rule +Py_LOCAL_SYMBOL void *invalid_match_stmt_rule(Parser *p); +#define invalid_case_block_rule _PyPegen_invalid_case_block_rule +Py_LOCAL_SYMBOL void *invalid_case_block_rule(Parser *p); +#define invalid_as_pattern_rule _PyPegen_invalid_as_pattern_rule +Py_LOCAL_SYMBOL void *invalid_as_pattern_rule(Parser *p); +#define invalid_class_pattern_rule _PyPegen_invalid_class_pattern_rule +Py_LOCAL_SYMBOL void *invalid_class_pattern_rule(Parser *p); +#define invalid_mapping_pattern_rule _PyPegen_invalid_mapping_pattern_rule +Py_LOCAL_SYMBOL void *invalid_mapping_pattern_rule(Parser *p); +#define invalid_if_stmt_rule _PyPegen_invalid_if_stmt_rule +Py_LOCAL_SYMBOL void *invalid_if_stmt_rule(Parser *p); +#define invalid_elif_stmt_rule _PyPegen_invalid_elif_stmt_rule +Py_LOCAL_SYMBOL void *invalid_elif_stmt_rule(Parser *p); +#define invalid_else_stmt_rule _PyPegen_invalid_else_stmt_rule +Py_LOCAL_SYMBOL void *invalid_else_stmt_rule(Parser *p); +#define invalid_while_stmt_rule _PyPegen_invalid_while_stmt_rule +Py_LOCAL_SYMBOL void *invalid_while_stmt_rule(Parser *p); +#define invalid_for_stmt_rule _PyPegen_invalid_for_stmt_rule +Py_LOCAL_SYMBOL void *invalid_for_stmt_rule(Parser *p); +#define invalid_def_raw_rule _PyPegen_invalid_def_raw_rule +Py_LOCAL_SYMBOL void *invalid_def_raw_rule(Parser *p); +#define invalid_class_def_raw_rule _PyPegen_invalid_class_def_raw_rule +Py_LOCAL_SYMBOL void *invalid_class_def_raw_rule(Parser *p); +#define invalid_double_starred_kvpairs_rule _PyPegen_invalid_double_starred_kvpairs_rule +Py_LOCAL_SYMBOL void *invalid_double_starred_kvpairs_rule(Parser *p); +#define invalid_starred_expression_unpacking_rule _PyPegen_invalid_starred_expression_unpacking_rule +Py_LOCAL_SYMBOL void *invalid_starred_expression_unpacking_rule(Parser *p); +#define invalid_starred_expression_unpacking_sequence_rule _PyPegen_invalid_starred_expression_unpacking_sequence_rule +Py_LOCAL_SYMBOL void *invalid_starred_expression_unpacking_sequence_rule(Parser *p); +#define invalid_starred_expression_rule _PyPegen_invalid_starred_expression_rule +Py_LOCAL_SYMBOL void *invalid_starred_expression_rule(Parser *p); +#define invalid_fstring_replacement_field_rule _PyPegen_invalid_fstring_replacement_field_rule +Py_LOCAL_SYMBOL void *invalid_fstring_replacement_field_rule(Parser *p); +#define invalid_tstring_replacement_field_rule _PyPegen_invalid_tstring_replacement_field_rule +Py_LOCAL_SYMBOL void *invalid_tstring_replacement_field_rule(Parser *p); +#define invalid_string_tstring_concat_rule _PyPegen_invalid_string_tstring_concat_rule +Py_LOCAL_SYMBOL void *invalid_string_tstring_concat_rule(Parser *p); +#define invalid_arithmetic_rule _PyPegen_invalid_arithmetic_rule +Py_LOCAL_SYMBOL void *invalid_arithmetic_rule(Parser *p); +#define invalid_factor_rule _PyPegen_invalid_factor_rule +Py_LOCAL_SYMBOL void *invalid_factor_rule(Parser *p); +#define invalid_type_params_rule _PyPegen_invalid_type_params_rule +Py_LOCAL_SYMBOL void *invalid_type_params_rule(Parser *p); +#define invalid_bitwise_and_rule _PyPegen_invalid_bitwise_and_rule +Py_LOCAL_SYMBOL void *invalid_bitwise_and_rule(Parser *p); +#define invalid_bitwise_or_rule _PyPegen_invalid_bitwise_or_rule +Py_LOCAL_SYMBOL void *invalid_bitwise_or_rule(Parser *p); +#define invalid_noteq_rule _PyPegen_invalid_noteq_rule +Py_LOCAL_SYMBOL void *invalid_noteq_rule(Parser *p); + +static expr_ty expression_without_invalid_rule(Parser *p); +static expr_ty invalid_ann_assign_target_rule(Parser *p); +static void *invalid_parameters_helper_rule(Parser *p); +static void *invalid_lambda_parameters_helper_rule(Parser *p); +static asdl_pattern_seq* invalid_class_argument_pattern_rule(Parser *p); +static void *invalid_kvpair_unpacking_rule(Parser *p); +static void *invalid_kvpair_rule(Parser *p); +static void *invalid_fstring_conversion_character_rule(Parser *p); +static void *invalid_tstring_conversion_character_rule(Parser *p); +static void *_tmp_106_rule(Parser *p); +static asdl_seq *_loop0_107_rule(Parser *p); +static asdl_seq *_gather_108_rule(Parser *p); +static void *_tmp_109_rule(Parser *p); +static void *_tmp_110_rule(Parser *p); +static void *_tmp_111_rule(Parser *p); +static void *_tmp_112_rule(Parser *p); +static asdl_seq *_loop1_113_rule(Parser *p); +static void *_tmp_114_rule(Parser *p); +static void *_tmp_115_rule(Parser *p); +static void *_tmp_116_rule(Parser *p); +static void *_tmp_117_rule(Parser *p); +static void *_tmp_118_rule(Parser *p); +static asdl_seq *_loop0_119_rule(Parser *p); +static asdl_seq *_loop0_120_rule(Parser *p); +static void *_tmp_121_rule(Parser *p); +static void *_tmp_122_rule(Parser *p); +static asdl_seq *_loop0_123_rule(Parser *p); +static asdl_seq *_loop0_124_rule(Parser *p); +static asdl_seq *_loop1_125_rule(Parser *p); +static void *_tmp_126_rule(Parser *p); +static asdl_seq *_loop1_127_rule(Parser *p); +static void *_tmp_128_rule(Parser *p); +static void *_tmp_129_rule(Parser *p); +static void *_tmp_130_rule(Parser *p); +static void *_tmp_131_rule(Parser *p); +static asdl_seq *_loop1_132_rule(Parser *p); +static void *_tmp_133_rule(Parser *p); +static asdl_seq *_loop0_134_rule(Parser *p); +static asdl_seq *_loop0_135_rule(Parser *p); +static asdl_seq *_loop0_136_rule(Parser *p); +static asdl_seq *_gather_137_rule(Parser *p); +static void *_tmp_138_rule(Parser *p); +static asdl_seq *_loop1_139_rule(Parser *p); +static asdl_seq *_loop1_140_rule(Parser *p); +static void *_tmp_141_rule(Parser *p); +static void *_tmp_142_rule(Parser *p); +static void *_tmp_143_rule(Parser *p); +static void *_tmp_144_rule(Parser *p); +static asdl_seq *_loop0_145_rule(Parser *p); +static asdl_seq *_gather_146_rule(Parser *p); +static void *_tmp_147_rule(Parser *p); +static asdl_seq *_loop0_148_rule(Parser *p); +static asdl_seq *_loop0_149_rule(Parser *p); +static asdl_seq *_gather_150_rule(Parser *p); +static asdl_seq *_loop0_151_rule(Parser *p); +static asdl_seq *_gather_152_rule(Parser *p); +static void *_tmp_153_rule(Parser *p); +static asdl_seq *_loop0_154_rule(Parser *p); +static asdl_seq *_loop1_155_rule(Parser *p); +static void *_tmp_156_rule(Parser *p); +static asdl_seq *_loop1_157_rule(Parser *p); +static void *_tmp_158_rule(Parser *p); +static void *_tmp_159_rule(Parser *p); +static void *_tmp_160_rule(Parser *p); +static void *_tmp_161_rule(Parser *p); +static void *_tmp_162_rule(Parser *p); +static void *_tmp_163_rule(Parser *p); +static asdl_seq *_loop0_164_rule(Parser *p); +static asdl_seq *_gather_165_rule(Parser *p); +static void *_tmp_166_rule(Parser *p); +static void *_tmp_167_rule(Parser *p); +static void *_tmp_168_rule(Parser *p); +static void *_tmp_169_rule(Parser *p); +static void *_tmp_170_rule(Parser *p); +static void *_tmp_171_rule(Parser *p); +static asdl_seq *_loop0_172_rule(Parser *p); +static asdl_seq *_loop1_173_rule(Parser *p); +static asdl_seq *_loop1_174_rule(Parser *p); +static void *_tmp_175_rule(Parser *p); +static void *_tmp_176_rule(Parser *p); +static void *_tmp_177_rule(Parser *p); +static void *_tmp_189_rule(Parser *p); +static void *_tmp_190_rule(Parser *p); +static void *_tmp_191_rule(Parser *p); +static void *_tmp_192_rule(Parser *p); +static void *_tmp_193_rule(Parser *p); +static void *_tmp_194_rule(Parser *p); +static asdl_seq *_loop0_195_rule(Parser *p); +static void *_tmp_196_rule(Parser *p); +static void *_tmp_197_rule(Parser *p); +static void *_tmp_198_rule(Parser *p); +static void *_tmp_199_rule(Parser *p); +static asdl_seq *_loop0_201_rule(Parser *p); +static asdl_seq *_gather_202_rule(Parser *p); +static void *_tmp_203_rule(Parser *p); +static void *_tmp_204_rule(Parser *p); +static void *_tmp_205_rule(Parser *p); +static void *_tmp_206_rule(Parser *p); + + +// invalid_arguments: +// | ((','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs) ',' ','.(starred_expression !'=')+ +// | expression for_if_clauses ',' [args | expression for_if_clauses] +// | NAME '=' expression for_if_clauses +// | [(args ',')] NAME '=' &(',' | ')') +// | args for_if_clauses +// | args ',' expression for_if_clauses +// | args ',' args +Py_LOCAL_SYMBOL void * +invalid_arguments_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ((','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs) ',' ','.(starred_expression !'=')+ + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs) ',' ','.(starred_expression !'=')+")); + asdl_seq * _gather_108_var; + void *_tmp_106_var; + Token * a; + if ( + (_tmp_106_var = _tmp_106_rule(p)) // (','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs + && + (a = _PyPegen_expect_token(p, 12)) // token=',' + && + (_gather_108_var = _gather_108_rule(p)) // ','.(starred_expression !'=')+ + ) + { + D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs) ',' ','.(starred_expression !'=')+")); + _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( a , "iterable argument unpacking follows keyword argument unpacking" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs) ',' ','.(starred_expression !'=')+")); + } + { // expression for_if_clauses ',' [args | expression for_if_clauses] + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty a; + asdl_comprehension_seq* b; + if ( + (a = expression_rule(p)) // expression + && + (b = for_if_clauses_rule(p)) // for_if_clauses + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (_opt_var = _tmp_109_rule(p), !p->error_indicator) // [args | expression for_if_clauses] + ) + { + D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , _PyPegen_get_last_comprehension_item ( PyPegen_last_item ( b , comprehension_ty ) ) , "Generator expression must be parenthesized" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); + } + { // NAME '=' expression for_if_clauses + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression for_if_clauses")); + expr_ty a; + Token * b; + expr_ty expression_var; + asdl_comprehension_seq* for_if_clauses_var; + if ( + (a = _PyPegen_name_token(p)) // NAME + && + (b = _PyPegen_expect_token(p, 22)) // token='=' + && + (expression_var = expression_rule(p)) // expression + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression for_if_clauses")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "invalid syntax. Maybe you meant '==' or ':=' instead of '='?" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression for_if_clauses")); + } + { // [(args ',')] NAME '=' &(',' | ')') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "[(args ',')] NAME '=' &(',' | ')')")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty a; + Token * b; + if ( + (_opt_var = _tmp_110_rule(p), !p->error_indicator) // [(args ',')] + && + (a = _PyPegen_name_token(p)) // NAME + && + (b = _PyPegen_expect_token(p, 22)) // token='=' + && + _PyPegen_lookahead(1, _tmp_111_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "[(args ',')] NAME '=' &(',' | ')')")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "expected argument value expression" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "[(args ',')] NAME '=' &(',' | ')')")); + } + { // args for_if_clauses + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args for_if_clauses")); + expr_ty a; + asdl_comprehension_seq* b; + if ( + (a = args_rule(p)) // args + && + (b = for_if_clauses_rule(p)) // for_if_clauses + ) + { + D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args for_if_clauses")); + _res = _PyPegen_nonparen_genexp_in_call ( p , a , b ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args for_if_clauses")); + } + { // args ',' expression for_if_clauses + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses")); + Token * _literal; + expr_ty a; + expr_ty args_var; + asdl_comprehension_seq* b; + if ( + (args_var = args_rule(p)) // args + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (a = expression_rule(p)) // expression + && + (b = for_if_clauses_rule(p)) // for_if_clauses + ) + { + D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , _PyPegen_get_last_comprehension_item ( PyPegen_last_item ( b , comprehension_ty ) ) , "Generator expression must be parenthesized" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' expression for_if_clauses")); + } + { // args ',' args + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' args")); + Token * _literal; + expr_ty a; + expr_ty args_var; + if ( + (a = args_rule(p)) // args + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (args_var = args_rule(p)) // args + ) + { + D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' args")); + _res = _PyPegen_arguments_parsing_error ( p , a ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' args")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_kwarg: +// | 'True' '=' +// | 'False' '=' +// | 'None' '=' +// | NAME '=' expression for_if_clauses +// | !(NAME '=') expression '=' +// | '**' expression '=' expression +Py_LOCAL_SYMBOL void * +invalid_kwarg_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'True' '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True' '='")); + Token * a; + Token * b; + if ( + (a = _PyPegen_expect_token(p, 527)) // token='True' + && + (b = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True' '='")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot assign to True" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kwarg[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True' '='")); + } + { // 'False' '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False' '='")); + Token * a; + Token * b; + if ( + (a = _PyPegen_expect_token(p, 528)) // token='False' + && + (b = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False' '='")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot assign to False" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kwarg[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False' '='")); + } + { // 'None' '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None' '='")); + Token * a; + Token * b; + if ( + (a = _PyPegen_expect_token(p, 526)) // token='None' + && + (b = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None' '='")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot assign to None" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kwarg[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None' '='")); + } + { // NAME '=' expression for_if_clauses + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression for_if_clauses")); + expr_ty a; + Token * b; + expr_ty expression_var; + asdl_comprehension_seq* for_if_clauses_var; + if ( + (a = _PyPegen_name_token(p)) // NAME + && + (b = _PyPegen_expect_token(p, 22)) // token='=' + && + (expression_var = expression_rule(p)) // expression + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression for_if_clauses")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "invalid syntax. Maybe you meant '==' or ':=' instead of '='?" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kwarg[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression for_if_clauses")); + } + { // !(NAME '=') expression '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!(NAME '=') expression '='")); + expr_ty a; + Token * b; + if ( + _PyPegen_lookahead(0, _tmp_112_rule, p) + && + (a = expression_rule(p)) // expression + && + (b = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!(NAME '=') expression '='")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "expression cannot contain assignment, perhaps you meant \"==\"?" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kwarg[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!(NAME '=') expression '='")); + } + { // '**' expression '=' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' expression '=' expression")); + Token * _literal; + Token * a; + expr_ty b; + expr_ty expression_var; + if ( + (a = _PyPegen_expect_token(p, 35)) // token='**' + && + (expression_var = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + && + (b = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' expression '=' expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot assign to keyword argument unpacking" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kwarg[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' expression '=' expression")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// expression_without_invalid: +// | disjunction 'if' disjunction 'else' expression +// | disjunction +// | lambdef +static expr_ty +expression_without_invalid_rule(Parser *p) +{ + int _prev_call_invalid = p->call_invalid_rules; + p->call_invalid_rules = 0; + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->call_invalid_rules = _prev_call_invalid; + p->level--; + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + expr_ty _prefix_11_result = NULL; + int _prefix_11_end = 0, _prefix_11_valid = 0; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + p->call_invalid_rules = _prev_call_invalid; + p->level--; + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // disjunction 'if' disjunction 'else' expression + if (p->error_indicator) { + p->call_invalid_rules = _prev_call_invalid; + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> expression_without_invalid[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); + Token * _keyword; + Token * _keyword_1; + expr_ty a; + expr_ty b; + expr_ty c; + if ( + (a = ((!p->call_invalid_rules && _prefix_11_valid) ? (p->mark = _prefix_11_end, _prefix_11_result) : (_prefix_11_result = disjunction_rule(p), _prefix_11_end = p->mark, _prefix_11_valid = 1, _prefix_11_result))) // disjunction + && + (_keyword = _PyPegen_expect_token(p, 514)) // token='if' + && + (b = disjunction_rule(p)) // disjunction + && + (_keyword_1 = _PyPegen_expect_token(p, 522)) // token='else' + && + (c = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ expression_without_invalid[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + p->call_invalid_rules = _prev_call_invalid; + p->level--; + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _PyAST_IfExp ( b , a , c , EXTRA ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->call_invalid_rules = _prev_call_invalid; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s expression_without_invalid[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); + } + { // disjunction + if (p->error_indicator) { + p->call_invalid_rules = _prev_call_invalid; + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> expression_without_invalid[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction")); + expr_ty disjunction_var; + if ( + (disjunction_var = ((!p->call_invalid_rules && _prefix_11_valid) ? (p->mark = _prefix_11_end, _prefix_11_result) : (_prefix_11_result = disjunction_rule(p), _prefix_11_end = p->mark, _prefix_11_valid = 1, _prefix_11_result))) // disjunction + ) + { + D(fprintf(stderr, "%*c+ expression_without_invalid[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction")); + _res = disjunction_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s expression_without_invalid[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction")); + } + { // lambdef + if (p->error_indicator) { + p->call_invalid_rules = _prev_call_invalid; + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> expression_without_invalid[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambdef")); + expr_ty lambdef_var; + if ( + (lambdef_var = lambdef_rule(p)) // lambdef + ) + { + D(fprintf(stderr, "%*c+ expression_without_invalid[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambdef")); + _res = lambdef_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s expression_without_invalid[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambdef")); + } + _res = NULL; + done: + p->call_invalid_rules = _prev_call_invalid; + p->level--; + return _res; +} + +// invalid_legacy_expression: NAME !'(' star_expressions +Py_LOCAL_SYMBOL void * +invalid_legacy_expression_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // NAME !'(' star_expressions + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_legacy_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME !'(' star_expressions")); + expr_ty a; + expr_ty b; + if ( + (a = _PyPegen_name_token(p)) // NAME + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 7) // token='(' + && + (b = star_expressions_rule(p)) // star_expressions + ) + { + D(fprintf(stderr, "%*c+ invalid_legacy_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME !'(' star_expressions")); + _res = _PyPegen_check_legacy_stmt ( p , a ) ? RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "Missing parentheses in call to '%U'. Did you mean %U(...)?" , a -> v . Name . id , a -> v . Name . id ) : NULL; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_legacy_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME !'(' star_expressions")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_type_param: '*' NAME ':' expression | '**' NAME ':' expression +Py_LOCAL_SYMBOL void * +invalid_type_param_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '*' NAME ':' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_type_param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' NAME ':' expression")); + Token * _literal; + expr_ty a; + Token * colon; + expr_ty e; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (a = _PyPegen_name_token(p)) // NAME + && + (colon = _PyPegen_expect_token(p, 11)) // token=':' + && + (e = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_type_param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' NAME ':' expression")); + _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( colon , e -> kind == Tuple_kind ? "cannot use constraints with TypeVarTuple" : "cannot use bound with TypeVarTuple" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_type_param[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' NAME ':' expression")); + } + { // '**' NAME ':' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_type_param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' NAME ':' expression")); + Token * _literal; + expr_ty a; + Token * colon; + expr_ty e; + if ( + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + && + (a = _PyPegen_name_token(p)) // NAME + && + (colon = _PyPegen_expect_token(p, 11)) // token=':' + && + (e = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_type_param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' NAME ':' expression")); + _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( colon , e -> kind == Tuple_kind ? "cannot use constraints with ParamSpec" : "cannot use bound with ParamSpec" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_type_param[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' NAME ':' expression")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_expression: +// | STRING ((!STRING expression_without_invalid))+ STRING +// | !(NAME STRING | SOFT_KEYWORD) disjunction expression_without_invalid +// | disjunction 'if' disjunction !('else' | ':') +// | disjunction 'if' disjunction 'else' !expression +// | (pass_stmt | break_stmt | continue_stmt) 'if' disjunction 'else' simple_stmt +// | 'lambda' lambda_params? ':' &FSTRING_MIDDLE +// | 'lambda' lambda_params? ':' &TSTRING_MIDDLE +Py_LOCAL_SYMBOL void * +invalid_expression_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + expr_ty _prefix_12_result = NULL; + int _prefix_12_end = 0, _prefix_12_valid = 0; + { // STRING ((!STRING expression_without_invalid))+ STRING + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING ((!STRING expression_without_invalid))+ STRING")); + asdl_seq * a; + expr_ty string_var; + expr_ty string_var_1; + if ( + (string_var = _PyPegen_string_token(p)) // STRING + && + (a = _loop1_113_rule(p)) // ((!STRING expression_without_invalid))+ + && + (string_var_1 = _PyPegen_string_token(p)) // STRING + ) + { + D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING ((!STRING expression_without_invalid))+ STRING")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( PyPegen_first_item ( a , expr_ty ) , PyPegen_last_item ( a , expr_ty ) , "invalid syntax. Is this intended to be part of the string?" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING ((!STRING expression_without_invalid))+ STRING")); + } + { // !(NAME STRING | SOFT_KEYWORD) disjunction expression_without_invalid + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!(NAME STRING | SOFT_KEYWORD) disjunction expression_without_invalid")); + expr_ty a; + expr_ty b; + if ( + _PyPegen_lookahead(0, _tmp_114_rule, p) + && + (a = disjunction_rule(p)) // disjunction + && + (b = expression_without_invalid_rule(p)) // expression_without_invalid + ) + { + D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!(NAME STRING | SOFT_KEYWORD) disjunction expression_without_invalid")); + _res = _PyPegen_raise_error_for_missing_comma ( p , a , b ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!(NAME STRING | SOFT_KEYWORD) disjunction expression_without_invalid")); + } + { // disjunction 'if' disjunction !('else' | ':') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction !('else' | ':')")); + Token * _keyword; + expr_ty a; + expr_ty b; + if ( + (a = ((!p->call_invalid_rules && _prefix_12_valid) ? (p->mark = _prefix_12_end, _prefix_12_result) : (_prefix_12_result = disjunction_rule(p), _prefix_12_end = p->mark, _prefix_12_valid = 1, _prefix_12_result))) // disjunction + && + (_keyword = _PyPegen_expect_token(p, 514)) // token='if' + && + (b = disjunction_rule(p)) // disjunction + && + _PyPegen_lookahead(0, _tmp_115_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction !('else' | ':')")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "expected 'else' after 'if' expression" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction !('else' | ':')")); + } + { // disjunction 'if' disjunction 'else' !expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' !expression")); + Token * _keyword; + Token * _keyword_1; + expr_ty a; + expr_ty b; + if ( + (a = ((!p->call_invalid_rules && _prefix_12_valid) ? (p->mark = _prefix_12_end, _prefix_12_result) : (_prefix_12_result = disjunction_rule(p), _prefix_12_end = p->mark, _prefix_12_valid = 1, _prefix_12_result))) // disjunction + && + (_keyword = _PyPegen_expect_token(p, 514)) // token='if' + && + (b = disjunction_rule(p)) // disjunction + && + (_keyword_1 = _PyPegen_expect_token(p, 522)) // token='else' + && + _PyPegen_lookahead_for_expr(0, expression_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' !expression")); + _res = RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "expected expression after 'else', but statement is given" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction 'else' !expression")); + } + { // (pass_stmt | break_stmt | continue_stmt) 'if' disjunction 'else' simple_stmt + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(pass_stmt | break_stmt | continue_stmt) 'if' disjunction 'else' simple_stmt")); + Token * _keyword; + Token * _keyword_1; + stmt_ty a; + expr_ty b; + stmt_ty c; + if ( + (a = (stmt_ty)_tmp_116_rule(p)) // pass_stmt | break_stmt | continue_stmt + && + (_keyword = _PyPegen_expect_token(p, 514)) // token='if' + && + (b = disjunction_rule(p)) // disjunction + && + (_keyword_1 = _PyPegen_expect_token(p, 522)) // token='else' + && + (c = simple_stmt_rule(p)) // simple_stmt + ) + { + D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(pass_stmt | break_stmt | continue_stmt) 'if' disjunction 'else' simple_stmt")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expected expression before 'if', but statement is given" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(pass_stmt | break_stmt | continue_stmt) 'if' disjunction 'else' simple_stmt")); + } + { // 'lambda' lambda_params? ':' &FSTRING_MIDDLE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' &FSTRING_MIDDLE")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * a; + Token * b; + if ( + (a = _PyPegen_expect_token(p, 534)) // token='lambda' + && + (_opt_var = lambda_params_rule(p), !p->error_indicator) // lambda_params? + && + (b = _PyPegen_expect_token(p, 11)) // token=':' + && + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, FSTRING_MIDDLE) // token=FSTRING_MIDDLE + ) + { + D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' &FSTRING_MIDDLE")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "f-string: lambda expressions are not allowed without parentheses" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'lambda' lambda_params? ':' &FSTRING_MIDDLE")); + } + { // 'lambda' lambda_params? ':' &TSTRING_MIDDLE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' &TSTRING_MIDDLE")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * a; + Token * b; + if ( + (a = _PyPegen_expect_token(p, 534)) // token='lambda' + && + (_opt_var = lambda_params_rule(p), !p->error_indicator) // lambda_params? + && + (b = _PyPegen_expect_token(p, 11)) // token=':' + && + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, TSTRING_MIDDLE) // token=TSTRING_MIDDLE + ) + { + D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' &TSTRING_MIDDLE")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "t-string: lambda expressions are not allowed without parentheses" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'lambda' lambda_params? ':' &TSTRING_MIDDLE")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_if_expression: +// | disjunction 'if' disjunction 'else' '*' +// | disjunction 'if' disjunction 'else' '**' +Py_LOCAL_SYMBOL void * +invalid_if_expression_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + expr_ty _prefix_13_result = NULL; + int _prefix_13_end = 0, _prefix_13_valid = 0; + { // disjunction 'if' disjunction 'else' '*' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_if_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' '*'")); + Token * _keyword; + Token * _keyword_1; + Token * a; + expr_ty b; + expr_ty disjunction_var; + if ( + (disjunction_var = ((!p->call_invalid_rules && _prefix_13_valid) ? (p->mark = _prefix_13_end, _prefix_13_result) : (_prefix_13_result = disjunction_rule(p), _prefix_13_end = p->mark, _prefix_13_valid = 1, _prefix_13_result))) // disjunction + && + (_keyword = _PyPegen_expect_token(p, 514)) // token='if' + && + (b = disjunction_rule(p)) // disjunction + && + (_keyword_1 = _PyPegen_expect_token(p, 522)) // token='else' + && + (a = _PyPegen_expect_token(p, 16)) // token='*' + ) + { + D(fprintf(stderr, "%*c+ invalid_if_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' '*'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot unpack only part of a conditional expression" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_if_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction 'else' '*'")); + } + { // disjunction 'if' disjunction 'else' '**' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_if_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' '**'")); + Token * _keyword; + Token * _keyword_1; + Token * a; + expr_ty b; + expr_ty disjunction_var; + if ( + (disjunction_var = ((!p->call_invalid_rules && _prefix_13_valid) ? (p->mark = _prefix_13_end, _prefix_13_result) : (_prefix_13_result = disjunction_rule(p), _prefix_13_end = p->mark, _prefix_13_valid = 1, _prefix_13_result))) // disjunction + && + (_keyword = _PyPegen_expect_token(p, 514)) // token='if' + && + (b = disjunction_rule(p)) // disjunction + && + (_keyword_1 = _PyPegen_expect_token(p, 522)) // token='else' + && + (a = _PyPegen_expect_token(p, 35)) // token='**' + ) + { + D(fprintf(stderr, "%*c+ invalid_if_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' '**'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use dict unpacking on only part of a conditional expression" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_if_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction 'else' '**'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_named_expression: +// | expression ':=' expression +// | NAME '=' bitwise_or !('=' | ':=') +// | !(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=') +Py_LOCAL_SYMBOL void * +invalid_named_expression_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + if (_PyPegen_is_memoized(p, invalid_named_expression_type, &_res)) { + p->level--; + return _res; + } + int _mark = p->mark; + { // expression ':=' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':=' expression")); + Token * _literal; + expr_ty a; + expr_ty expression_var; + if ( + (a = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 53)) // token=':=' + && + (expression_var = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':=' expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_named_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':=' expression")); + } + { // NAME '=' bitwise_or !('=' | ':=') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' bitwise_or !('=' | ':=')")); + Token * _literal; + expr_ty a; + expr_ty b; + if ( + (a = _PyPegen_name_token(p)) // NAME + && + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + && + (b = bitwise_or_rule(p)) // bitwise_or + && + _PyPegen_lookahead(0, _tmp_117_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' bitwise_or !('=' | ':=')")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "invalid syntax. Maybe you meant '==' or ':=' instead of '='?" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_named_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' bitwise_or !('=' | ':=')")); + } + { // !(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=')")); + expr_ty a; + Token * b; + expr_ty bitwise_or_var; + if ( + _PyPegen_lookahead(0, _tmp_118_rule, p) + && + (a = bitwise_or_rule(p)) // bitwise_or + && + (b = _PyPegen_expect_token(p, 22)) // token='=' + && + (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + && + _PyPegen_lookahead(0, _tmp_117_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=')")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot assign to %s here. Maybe you meant '==' instead of '='?" , _PyPegen_get_expr_name ( a ) ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_named_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=')")); + } + _res = NULL; + done: + _PyPegen_insert_memo(p, _mark, invalid_named_expression_type, _res); + p->level--; + return _res; +} + +// invalid_assignment: +// | invalid_ann_assign_target ':' expression +// | star_named_expression ',' star_named_expressions* ':' expression +// | expression ':' expression +// | ((star_targets '='))* star_expressions '=' +// | ((star_targets '='))* yield_expr '=' +// | star_expressions augassign annotated_rhs +Py_LOCAL_SYMBOL void * +invalid_assignment_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // invalid_ann_assign_target ':' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_ann_assign_target ':' expression")); + Token * _literal; + expr_ty a; + expr_ty expression_var; + if ( + (a = invalid_ann_assign_target_rule(p)) // invalid_ann_assign_target + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (expression_var = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_ann_assign_target ':' expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not %s) can be annotated" , _PyPegen_get_expr_name ( a ) ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_ann_assign_target ':' expression")); + } + { // star_named_expression ',' star_named_expressions* ':' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':' expression")); + Token * _literal; + Token * _literal_1; + asdl_seq * _loop0_119_var; + expr_ty a; + expr_ty expression_var; + if ( + (a = star_named_expression_rule(p)) // star_named_expression + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (_loop0_119_var = _loop0_119_rule(p)) // star_named_expressions* + && + (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' + && + (expression_var = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':' expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions* ':' expression")); + } + { // expression ':' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' expression")); + Token * _literal; + expr_ty a; + expr_ty expression_var; + if ( + (a = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (expression_var = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "illegal target for annotation" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' expression")); + } + { // ((star_targets '='))* star_expressions '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='")); + Token * _literal; + asdl_seq * _loop0_120_var; + expr_ty a; + if ( + (_loop0_120_var = _loop0_120_rule(p)) // ((star_targets '='))* + && + (a = star_expressions_rule(p)) // star_expressions + && + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='")); + _res = RAISE_SYNTAX_ERROR_INVALID_TARGET ( STAR_TARGETS , a ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))* star_expressions '='")); + } + { // ((star_targets '='))* yield_expr '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='")); + Token * _literal; + asdl_seq * _loop0_120_var; + expr_ty a; + if ( + (_loop0_120_var = _loop0_120_rule(p)) // ((star_targets '='))* + && + (a = yield_expr_rule(p)) // yield_expr + && + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "assignment to yield expression not possible" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))* yield_expr '='")); + } + { // star_expressions augassign annotated_rhs + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign annotated_rhs")); + expr_ty a; + expr_ty annotated_rhs_var; + AugOperator* augassign_var; + if ( + (a = star_expressions_rule(p)) // star_expressions + && + (augassign_var = augassign_rule(p)) // augassign + && + (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs + ) + { + D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign annotated_rhs")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "'%s' is an illegal expression for augmented assignment" , _PyPegen_get_expr_name ( a ) ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions augassign annotated_rhs")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_ann_assign_target: list | tuple | '(' invalid_ann_assign_target ')' +static expr_ty +invalid_ann_assign_target_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + { // list + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_ann_assign_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); + expr_ty list_var; + if ( + (list_var = list_rule(p)) // list + ) + { + D(fprintf(stderr, "%*c+ invalid_ann_assign_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + _res = list_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_ann_assign_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); + } + { // tuple + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_ann_assign_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); + expr_ty tuple_var; + if ( + (tuple_var = tuple_rule(p)) // tuple + ) + { + D(fprintf(stderr, "%*c+ invalid_ann_assign_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + _res = tuple_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_ann_assign_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); + } + { // '(' invalid_ann_assign_target ')' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_ann_assign_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' invalid_ann_assign_target ')'")); + Token * _literal; + Token * _literal_1; + expr_ty a; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (a = invalid_ann_assign_target_rule(p)) // invalid_ann_assign_target + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ invalid_ann_assign_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' invalid_ann_assign_target ')'")); + _res = a; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_ann_assign_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' invalid_ann_assign_target ')'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_raise_stmt: 'raise' 'from' | 'raise' expression 'from' +Py_LOCAL_SYMBOL void * +invalid_raise_stmt_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'raise' 'from' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise' 'from'")); + Token * a; + Token * b; + if ( + (a = _PyPegen_expect_token(p, 503)) // token='raise' + && + (b = _PyPegen_expect_token(p, 501)) // token='from' + ) + { + D(fprintf(stderr, "%*c+ invalid_raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' 'from'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "did you forget an expression between 'raise' and 'from'?" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise' 'from'")); + } + { // 'raise' expression 'from' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise' expression 'from'")); + Token * _keyword; + Token * a; + expr_ty expression_var; + if ( + (_keyword = _PyPegen_expect_token(p, 503)) // token='raise' + && + (expression_var = expression_rule(p)) // expression + && + (a = _PyPegen_expect_token(p, 501)) // token='from' + ) + { + D(fprintf(stderr, "%*c+ invalid_raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression 'from'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "did you forget an expression after 'from'?" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise' expression 'from'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_del_stmt: 'del' star_expressions +Py_LOCAL_SYMBOL void * +invalid_del_stmt_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'del' star_expressions + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_del_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'del' star_expressions")); + Token * _keyword; + expr_ty a; + if ( + (_keyword = _PyPegen_expect_token(p, 505)) // token='del' + && + (a = star_expressions_rule(p)) // star_expressions + ) + { + D(fprintf(stderr, "%*c+ invalid_del_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'del' star_expressions")); + _res = RAISE_SYNTAX_ERROR_INVALID_TARGET ( DEL_TARGETS , a ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_del_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'del' star_expressions")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_assert_stmt: +// | 'assert' expression '=' expression +// | 'assert' expression ',' expression '=' expression +// | 'assert' expression ':=' expression +// | 'assert' expression ',' expression ':=' expression +Py_LOCAL_SYMBOL void * +invalid_assert_stmt_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'assert' expression '=' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assert_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'assert' expression '=' expression")); + Token * _keyword; + Token * _literal; + expr_ty a; + expr_ty b; + if ( + (_keyword = _PyPegen_expect_token(p, 507)) // token='assert' + && + (a = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + && + (b = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_assert_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'assert' expression '=' expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot assign to %s here. Maybe you meant '==' instead of '='?" , _PyPegen_get_expr_name ( a ) ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_assert_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'assert' expression '=' expression")); + } + { // 'assert' expression ',' expression '=' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assert_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'assert' expression ',' expression '=' expression")); + Token * _keyword; + Token * _literal; + Token * _literal_1; + expr_ty a; + expr_ty b; + expr_ty expression_var; + if ( + (_keyword = _PyPegen_expect_token(p, 507)) // token='assert' + && + (expression_var = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (a = expression_rule(p)) // expression + && + (_literal_1 = _PyPegen_expect_token(p, 22)) // token='=' + && + (b = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_assert_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'assert' expression ',' expression '=' expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot assign to %s here. Maybe you meant '==' instead of '='?" , _PyPegen_get_expr_name ( a ) ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_assert_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'assert' expression ',' expression '=' expression")); + } + { // 'assert' expression ':=' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assert_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'assert' expression ':=' expression")); + Token * _keyword; + Token * _literal; + expr_ty a; + expr_ty b; + if ( + (_keyword = _PyPegen_expect_token(p, 507)) // token='assert' + && + (a = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 53)) // token=':=' + && + (b = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_assert_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'assert' expression ':=' expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use named expression without parentheses here" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_assert_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'assert' expression ':=' expression")); + } + { // 'assert' expression ',' expression ':=' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assert_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'assert' expression ',' expression ':=' expression")); + Token * _keyword; + Token * _literal; + Token * _literal_1; + expr_ty a; + expr_ty b; + expr_ty expression_var; + if ( + (_keyword = _PyPegen_expect_token(p, 507)) // token='assert' + && + (expression_var = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (a = expression_rule(p)) // expression + && + (_literal_1 = _PyPegen_expect_token(p, 53)) // token=':=' + && + (b = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_assert_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'assert' expression ',' expression ':=' expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use named expression without parentheses here" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_assert_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'assert' expression ',' expression ':=' expression")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_block: NEWLINE !INDENT +Py_LOCAL_SYMBOL void * +invalid_block_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT")); + Token * newline_var; + if ( + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_block[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE !INDENT")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_comprehension: +// | '[' '**' expression for_if_clauses +// | '(' '**' expression for_if_clauses +// | ('[' | '{') star_named_expression ',' star_named_expressions for_if_clauses +// | ('[' | '{') star_named_expression ',' for_if_clauses +Py_LOCAL_SYMBOL void * +invalid_comprehension_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '[' '**' expression for_if_clauses + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' '**' expression for_if_clauses")); + Token * _literal; + Token * a; + expr_ty b; + asdl_comprehension_seq* for_if_clauses_var; + if ( + (_literal = _PyPegen_expect_token(p, 9)) // token='[' + && + (a = _PyPegen_expect_token(p, 35)) // token='**' + && + (b = expression_rule(p)) // expression + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + D(fprintf(stderr, "%*c+ invalid_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' '**' expression for_if_clauses")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use dict unpacking in list comprehension" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_comprehension[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' '**' expression for_if_clauses")); + } + { // '(' '**' expression for_if_clauses + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' '**' expression for_if_clauses")); + Token * _literal; + Token * a; + expr_ty b; + asdl_comprehension_seq* for_if_clauses_var; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (a = _PyPegen_expect_token(p, 35)) // token='**' + && + (b = expression_rule(p)) // expression + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + D(fprintf(stderr, "%*c+ invalid_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' '**' expression for_if_clauses")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use dict unpacking in generator expression" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_comprehension[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' '**' expression for_if_clauses")); + } + { // ('[' | '{') star_named_expression ',' star_named_expressions for_if_clauses + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '{') star_named_expression ',' star_named_expressions for_if_clauses")); + Token * _literal; + void *_tmp_121_var; + expr_ty a; + asdl_expr_seq* b; + asdl_comprehension_seq* for_if_clauses_var; + if ( + (_tmp_121_var = _tmp_121_rule(p)) // '[' | '{' + && + (a = star_named_expression_rule(p)) // star_named_expression + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (b = star_named_expressions_rule(p)) // star_named_expressions + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + D(fprintf(stderr, "%*c+ invalid_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('[' | '{') star_named_expression ',' star_named_expressions for_if_clauses")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , PyPegen_last_item ( b , expr_ty ) , "did you forget parentheses around the comprehension target?" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_comprehension[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('[' | '{') star_named_expression ',' star_named_expressions for_if_clauses")); + } + { // ('[' | '{') star_named_expression ',' for_if_clauses + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '{') star_named_expression ',' for_if_clauses")); + void *_tmp_121_var; + expr_ty a; + Token * b; + asdl_comprehension_seq* for_if_clauses_var; + if ( + (_tmp_121_var = _tmp_121_rule(p)) // '[' | '{' + && + (a = star_named_expression_rule(p)) // star_named_expression + && + (b = _PyPegen_expect_token(p, 12)) // token=',' + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + D(fprintf(stderr, "%*c+ invalid_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('[' | '{') star_named_expression ',' for_if_clauses")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "did you forget parentheses around the comprehension target?" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_comprehension[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('[' | '{') star_named_expression ',' for_if_clauses")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_parameters: +// | "/" ',' +// | (slash_no_default | slash_with_default) param_maybe_default* '/' +// | slash_no_default? param_no_default* invalid_parameters_helper param_no_default +// | param_no_default* '(' param_no_default+ ','? ')' +// | [(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/' +// | param_maybe_default+ '/' '*' +Py_LOCAL_SYMBOL void * +invalid_parameters_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // "/" ',' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"/\" ','")); + Token * _literal; + Token * a; + if ( + (a = _PyPegen_expect_token(p, 17)) // token='/' + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"/\" ','")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "at least one parameter must precede /" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"/\" ','")); + } + { // (slash_no_default | slash_with_default) param_maybe_default* '/' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(slash_no_default | slash_with_default) param_maybe_default* '/'")); + asdl_seq * _loop0_123_var; + void *_tmp_122_var; + Token * a; + if ( + (_tmp_122_var = _tmp_122_rule(p)) // slash_no_default | slash_with_default + && + (_loop0_123_var = _loop0_123_rule(p)) // param_maybe_default* + && + (a = _PyPegen_expect_token(p, 17)) // token='/' + ) + { + D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(slash_no_default | slash_with_default) param_maybe_default* '/'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "/ may appear only once" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(slash_no_default | slash_with_default) param_maybe_default* '/'")); + } + { // slash_no_default? param_no_default* invalid_parameters_helper param_no_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default? param_no_default* invalid_parameters_helper param_no_default")); + asdl_seq * _loop0_124_var; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + arg_ty a; + void *invalid_parameters_helper_var; + if ( + (_opt_var = slash_no_default_rule(p), !p->error_indicator) // slash_no_default? + && + (_loop0_124_var = _loop0_124_rule(p)) // param_no_default* + && + (invalid_parameters_helper_var = invalid_parameters_helper_rule(p)) // invalid_parameters_helper + && + (a = param_no_default_rule(p)) // param_no_default + ) + { + D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default? param_no_default* invalid_parameters_helper param_no_default")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "parameter without a default follows parameter with a default" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default? param_no_default* invalid_parameters_helper param_no_default")); + } + { // param_no_default* '(' param_no_default+ ','? ')' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* '(' param_no_default+ ','? ')'")); + asdl_seq * _loop0_124_var; + asdl_seq * _loop1_125_var; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * a; + Token * b; + if ( + (_loop0_124_var = _loop0_124_rule(p)) // param_no_default* + && + (a = _PyPegen_expect_token(p, 7)) // token='(' + && + (_loop1_125_var = _loop1_125_rule(p)) // param_no_default+ + && + (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? + && + (b = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* '(' param_no_default+ ','? ')'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "Function parameters cannot be parenthesized" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* '(' param_no_default+ ','? ')'")); + } + { // [(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "[(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/'")); + Token * _literal; + asdl_seq * _loop0_123_var; + asdl_seq * _loop0_123_var_1; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_tmp_126_var; + Token * a; + if ( + (_opt_var = _tmp_122_rule(p), !p->error_indicator) // [(slash_no_default | slash_with_default)] + && + (_loop0_123_var = _loop0_123_rule(p)) // param_maybe_default* + && + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (_tmp_126_var = _tmp_126_rule(p)) // ',' | param_no_default + && + (_loop0_123_var_1 = _loop0_123_rule(p)) // param_maybe_default* + && + (a = _PyPegen_expect_token(p, 17)) // token='/' + ) + { + D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "[(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "/ must be ahead of *" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "[(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/'")); + } + { // param_maybe_default+ '/' '*' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default+ '/' '*'")); + Token * _literal; + asdl_seq * _loop1_127_var; + Token * a; + if ( + (_loop1_127_var = _loop1_127_rule(p)) // param_maybe_default+ + && + (_literal = _PyPegen_expect_token(p, 17)) // token='/' + && + (a = _PyPegen_expect_token(p, 16)) // token='*' + ) + { + D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_maybe_default+ '/' '*'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expected comma between / and *" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default+ '/' '*'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_default: '=' &(')' | ',') +Py_LOCAL_SYMBOL void * +invalid_default_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '=' &(')' | ',') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' &(')' | ',')")); + Token * a; + if ( + (a = _PyPegen_expect_token(p, 22)) // token='=' + && + _PyPegen_lookahead(1, _tmp_128_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' &(')' | ',')")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expected default value expression" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' &(')' | ',')")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_star_etc: +// | '*' (')' | ',' (')' | '**')) +// | '*' ',' TYPE_COMMENT +// | '*' param '=' +// | '*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',') +Py_LOCAL_SYMBOL void * +invalid_star_etc_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '*' (')' | ',' (')' | '**')) + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); + void *_tmp_129_var; + Token * a; + if ( + (a = _PyPegen_expect_token(p, 16)) // token='*' + && + (_tmp_129_var = _tmp_129_rule(p)) // ')' | ',' (')' | '**') + ) + { + D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "named parameters must follow bare *" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); + } + { // '*' ',' TYPE_COMMENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT")); + Token * _literal; + Token * _literal_1; + Token * type_comment_var; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + && + (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' + ) + { + D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT")); + _res = RAISE_SYNTAX_ERROR ( "bare * has associated type comment" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' TYPE_COMMENT")); + } + { // '*' param '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' param '='")); + Token * _literal; + Token * a; + arg_ty param_var; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (param_var = param_rule(p)) // param + && + (a = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' param '='")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "var-positional parameter cannot have default value" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' param '='")); + } + { // '*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',')")); + Token * _literal; + asdl_seq * _loop0_123_var; + void *_tmp_130_var; + void *_tmp_130_var_1; + Token * a; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (_tmp_130_var = _tmp_130_rule(p)) // param_no_default | ',' + && + (_loop0_123_var = _loop0_123_rule(p)) // param_maybe_default* + && + (a = _PyPegen_expect_token(p, 16)) // token='*' + && + (_tmp_130_var_1 = _tmp_130_rule(p)) // param_no_default | ',' + ) + { + D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',')")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "* may appear only once" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',')")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_kwds: '**' param '=' | '**' param ',' param | '**' param ',' ('*' | '**' | '/') +Py_LOCAL_SYMBOL void * +invalid_kwds_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '**' param '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' param '='")); + Token * _literal; + Token * a; + arg_ty param_var; + if ( + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + && + (param_var = param_rule(p)) // param + && + (a = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ invalid_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' param '='")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "var-keyword parameter cannot have default value" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kwds[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' param '='")); + } + { // '**' param ',' param + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' param ',' param")); + Token * _literal; + Token * _literal_1; + arg_ty a; + arg_ty param_var; + if ( + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + && + (param_var = param_rule(p)) // param + && + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + && + (a = param_rule(p)) // param + ) + { + D(fprintf(stderr, "%*c+ invalid_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' param ',' param")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "parameters cannot follow var-keyword parameter" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kwds[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' param ',' param")); + } + { // '**' param ',' ('*' | '**' | '/') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' param ',' ('*' | '**' | '/')")); + Token * _literal; + Token * _literal_1; + Token* a; + arg_ty param_var; + if ( + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + && + (param_var = param_rule(p)) // param + && + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + && + (a = (Token*)_tmp_131_rule(p)) // '*' | '**' | '/' + ) + { + D(fprintf(stderr, "%*c+ invalid_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' param ',' ('*' | '**' | '/')")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "parameters cannot follow var-keyword parameter" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kwds[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' param ',' ('*' | '**' | '/')")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_parameters_helper: slash_with_default | param_with_default+ +static void * +invalid_parameters_helper_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // slash_with_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + SlashWithDefault* a; + if ( + (a = slash_with_default_rule(p)) // slash_with_default + ) + { + D(fprintf(stderr, "%*c+ invalid_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + _res = _PyPegen_singleton_seq ( p , a ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_parameters_helper[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); + } + { // param_with_default+ + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + asdl_seq * _loop1_132_var; + if ( + (_loop1_132_var = _loop1_132_rule(p)) // param_with_default+ + ) + { + D(fprintf(stderr, "%*c+ invalid_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + _res = _loop1_132_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_parameters_helper[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_lambda_parameters: +// | "/" ',' +// | (lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/' +// | lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default +// | lambda_param_no_default* '(' ','.lambda_param+ ','? ')' +// | [(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/' +// | lambda_param_maybe_default+ '/' '*' +Py_LOCAL_SYMBOL void * +invalid_lambda_parameters_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // "/" ',' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"/\" ','")); + Token * _literal; + Token * a; + if ( + (a = _PyPegen_expect_token(p, 17)) // token='/' + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"/\" ','")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "at least one parameter must precede /" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"/\" ','")); + } + { // (lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'")); + asdl_seq * _loop0_134_var; + void *_tmp_133_var; + Token * a; + if ( + (_tmp_133_var = _tmp_133_rule(p)) // lambda_slash_no_default | lambda_slash_with_default + && + (_loop0_134_var = _loop0_134_rule(p)) // lambda_param_maybe_default* + && + (a = _PyPegen_expect_token(p, 17)) // token='/' + ) + { + D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "/ may appear only once" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'")); + } + { // lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default")); + asdl_seq * _loop0_135_var; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + arg_ty a; + void *invalid_lambda_parameters_helper_var; + if ( + (_opt_var = lambda_slash_no_default_rule(p), !p->error_indicator) // lambda_slash_no_default? + && + (_loop0_135_var = _loop0_135_rule(p)) // lambda_param_no_default* + && + (invalid_lambda_parameters_helper_var = invalid_lambda_parameters_helper_rule(p)) // invalid_lambda_parameters_helper + && + (a = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "parameter without a default follows parameter with a default" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default")); + } + { // lambda_param_no_default* '(' ','.lambda_param+ ','? ')' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* '(' ','.lambda_param+ ','? ')'")); + asdl_seq * _gather_137_var; + asdl_seq * _loop0_135_var; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * a; + Token * b; + if ( + (_loop0_135_var = _loop0_135_rule(p)) // lambda_param_no_default* + && + (a = _PyPegen_expect_token(p, 7)) // token='(' + && + (_gather_137_var = _gather_137_rule(p)) // ','.lambda_param+ + && + (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? + && + (b = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* '(' ','.lambda_param+ ','? ')'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "Lambda expression parameters cannot be parenthesized" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* '(' ','.lambda_param+ ','? ')'")); + } + { // [(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "[(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/'")); + Token * _literal; + asdl_seq * _loop0_134_var; + asdl_seq * _loop0_134_var_1; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_tmp_138_var; + Token * a; + if ( + (_opt_var = _tmp_133_rule(p), !p->error_indicator) // [(lambda_slash_no_default | lambda_slash_with_default)] + && + (_loop0_134_var = _loop0_134_rule(p)) // lambda_param_maybe_default* + && + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (_tmp_138_var = _tmp_138_rule(p)) // ',' | lambda_param_no_default + && + (_loop0_134_var_1 = _loop0_134_rule(p)) // lambda_param_maybe_default* + && + (a = _PyPegen_expect_token(p, 17)) // token='/' + ) + { + D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "[(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "/ must be ahead of *" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "[(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/'")); + } + { // lambda_param_maybe_default+ '/' '*' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default+ '/' '*'")); + Token * _literal; + asdl_seq * _loop1_139_var; + Token * a; + if ( + (_loop1_139_var = _loop1_139_rule(p)) // lambda_param_maybe_default+ + && + (_literal = _PyPegen_expect_token(p, 17)) // token='/' + && + (a = _PyPegen_expect_token(p, 16)) // token='*' + ) + { + D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default+ '/' '*'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expected comma between / and *" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default+ '/' '*'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_lambda_parameters_helper: +// | lambda_slash_with_default +// | lambda_param_with_default+ +static void * +invalid_lambda_parameters_helper_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // lambda_slash_with_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_lambda_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); + SlashWithDefault* a; + if ( + (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default + ) + { + D(fprintf(stderr, "%*c+ invalid_lambda_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); + _res = _PyPegen_singleton_seq ( p , a ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_lambda_parameters_helper[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default")); + } + { // lambda_param_with_default+ + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_lambda_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); + asdl_seq * _loop1_140_var; + if ( + (_loop1_140_var = _loop1_140_rule(p)) // lambda_param_with_default+ + ) + { + D(fprintf(stderr, "%*c+ invalid_lambda_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); + _res = _loop1_140_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_lambda_parameters_helper[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default+")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_lambda_star_etc: +// | '*' (':' | ',' (':' | '**')) +// | '*' lambda_param '=' +// | '*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',') +Py_LOCAL_SYMBOL void * +invalid_lambda_star_etc_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '*' (':' | ',' (':' | '**')) + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); + Token * _literal; + void *_tmp_141_var; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (_tmp_141_var = _tmp_141_rule(p)) // ':' | ',' (':' | '**') + ) + { + D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); + _res = RAISE_SYNTAX_ERROR ( "named parameters must follow bare *" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); + } + { // '*' lambda_param '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' lambda_param '='")); + Token * _literal; + Token * a; + arg_ty lambda_param_var; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (lambda_param_var = lambda_param_rule(p)) // lambda_param + && + (a = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' lambda_param '='")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "var-positional parameter cannot have default value" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' lambda_param '='")); + } + { // '*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',')")); + Token * _literal; + asdl_seq * _loop0_134_var; + void *_tmp_142_var; + void *_tmp_142_var_1; + Token * a; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (_tmp_142_var = _tmp_142_rule(p)) // lambda_param_no_default | ',' + && + (_loop0_134_var = _loop0_134_rule(p)) // lambda_param_maybe_default* + && + (a = _PyPegen_expect_token(p, 16)) // token='*' + && + (_tmp_142_var_1 = _tmp_142_rule(p)) // lambda_param_no_default | ',' + ) + { + D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',')")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "* may appear only once" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',')")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_lambda_kwds: +// | '**' lambda_param '=' +// | '**' lambda_param ',' lambda_param +// | '**' lambda_param ',' ('*' | '**' | '/') +Py_LOCAL_SYMBOL void * +invalid_lambda_kwds_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '**' lambda_param '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_lambda_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' lambda_param '='")); + Token * _literal; + Token * a; + arg_ty lambda_param_var; + if ( + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + && + (lambda_param_var = lambda_param_rule(p)) // lambda_param + && + (a = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ invalid_lambda_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' lambda_param '='")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "var-keyword parameter cannot have default value" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_lambda_kwds[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' lambda_param '='")); + } + { // '**' lambda_param ',' lambda_param + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_lambda_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' lambda_param ',' lambda_param")); + Token * _literal; + Token * _literal_1; + arg_ty a; + arg_ty lambda_param_var; + if ( + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + && + (lambda_param_var = lambda_param_rule(p)) // lambda_param + && + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + && + (a = lambda_param_rule(p)) // lambda_param + ) + { + D(fprintf(stderr, "%*c+ invalid_lambda_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' lambda_param ',' lambda_param")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "parameters cannot follow var-keyword parameter" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_lambda_kwds[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' lambda_param ',' lambda_param")); + } + { // '**' lambda_param ',' ('*' | '**' | '/') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_lambda_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' lambda_param ',' ('*' | '**' | '/')")); + Token * _literal; + Token * _literal_1; + Token* a; + arg_ty lambda_param_var; + if ( + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + && + (lambda_param_var = lambda_param_rule(p)) // lambda_param + && + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + && + (a = (Token*)_tmp_131_rule(p)) // '*' | '**' | '/' + ) + { + D(fprintf(stderr, "%*c+ invalid_lambda_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' lambda_param ',' ('*' | '**' | '/')")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "parameters cannot follow var-keyword parameter" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_lambda_kwds[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' lambda_param ',' ('*' | '**' | '/')")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT +Py_LOCAL_SYMBOL void * +invalid_double_type_comments_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_double_type_comments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); + Token * indent_var; + Token * newline_var; + Token * newline_var_1; + Token * type_comment_var; + Token * type_comment_var_1; + if ( + (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + (type_comment_var_1 = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' + && + (newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' + ) + { + D(fprintf(stderr, "%*c+ invalid_double_type_comments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); + _res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_double_type_comments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_with_item: expression 'as' expression &(',' | ')' | ':') +Py_LOCAL_SYMBOL void * +invalid_with_item_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // expression 'as' expression &(',' | ')' | ':') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_with_item[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression 'as' expression &(',' | ')' | ':')")); + Token * _keyword; + expr_ty a; + expr_ty expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (_keyword = _PyPegen_expect_token(p, 520)) // token='as' + && + (a = expression_rule(p)) // expression + && + _PyPegen_lookahead(1, _tmp_143_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_with_item[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression 'as' expression &(',' | ')' | ':')")); + _res = RAISE_SYNTAX_ERROR_INVALID_TARGET ( STAR_TARGETS , a ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_with_item[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression 'as' expression &(',' | ')' | ':')")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_for_if_clause: 'async'? 'for' (bitwise_or ((',' bitwise_or))* ','?) !'in' +Py_LOCAL_SYMBOL void * +invalid_for_if_clause_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'async'? 'for' (bitwise_or ((',' bitwise_or))* ','?) !'in' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_for_if_clause[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'for' (bitwise_or ((',' bitwise_or))* ','?) !'in'")); + Token * _keyword; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_tmp_144_var; + if ( + (_opt_var = _PyPegen_expect_token(p, 513), !p->error_indicator) // 'async'? + && + (_keyword = _PyPegen_expect_token(p, 517)) // token='for' + && + (_tmp_144_var = _tmp_144_rule(p)) // bitwise_or ((',' bitwise_or))* ','? + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 523) // token='in' + ) + { + D(fprintf(stderr, "%*c+ invalid_for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'for' (bitwise_or ((',' bitwise_or))* ','?) !'in'")); + _res = RAISE_SYNTAX_ERROR ( "'in' expected after for-loop variables" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_for_if_clause[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'for' (bitwise_or ((',' bitwise_or))* ','?) !'in'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_for_target: 'async'? 'for' star_expressions +Py_LOCAL_SYMBOL void * +invalid_for_target_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'async'? 'for' star_expressions + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_for_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'for' star_expressions")); + Token * _keyword; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty a; + if ( + (_opt_var = _PyPegen_expect_token(p, 513), !p->error_indicator) // 'async'? + && + (_keyword = _PyPegen_expect_token(p, 517)) // token='for' + && + (a = star_expressions_rule(p)) // star_expressions + ) + { + D(fprintf(stderr, "%*c+ invalid_for_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'for' star_expressions")); + _res = RAISE_SYNTAX_ERROR_INVALID_TARGET ( FOR_TARGETS , a ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_for_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'for' star_expressions")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_group: '(' starred_expression ')' | '(' '**' expression ')' +Py_LOCAL_SYMBOL void * +invalid_group_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '(' starred_expression ')' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_group[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' starred_expression ')'")); + Token * _literal; + Token * _literal_1; + expr_ty a; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (a = starred_expression_rule(p)) // starred_expression + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ invalid_group[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' starred_expression ')'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use starred expression here" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_group[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' starred_expression ')'")); + } + { // '(' '**' expression ')' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_group[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' '**' expression ')'")); + Token * _literal; + Token * _literal_1; + Token * a; + expr_ty expression_var; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (a = _PyPegen_expect_token(p, 35)) // token='**' + && + (expression_var = expression_rule(p)) // expression + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ invalid_group[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' '**' expression ')'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use double starred expression here" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_group[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' '**' expression ')'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_import: 'import' ','.dotted_name+ 'from' dotted_name | 'import' NEWLINE +Py_LOCAL_SYMBOL void * +invalid_import_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'import' ','.dotted_name+ 'from' dotted_name + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_import[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import' ','.dotted_name+ 'from' dotted_name")); + asdl_seq * _gather_146_var; + Token * _keyword; + Token * a; + expr_ty dotted_name_var; + if ( + (a = _PyPegen_expect_token(p, 500)) // token='import' + && + (_gather_146_var = _gather_146_rule(p)) // ','.dotted_name+ + && + (_keyword = _PyPegen_expect_token(p, 501)) // token='from' + && + (dotted_name_var = dotted_name_rule(p)) // dotted_name + ) + { + D(fprintf(stderr, "%*c+ invalid_import[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import' ','.dotted_name+ 'from' dotted_name")); + _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( a , "Did you mean to use 'from ... import ...' instead?" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_import[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import' ','.dotted_name+ 'from' dotted_name")); + } + { // 'import' NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_import[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import' NEWLINE")); + Token * _keyword; + Token * token; + if ( + (_keyword = _PyPegen_expect_token(p, 500)) // token='import' + && + (token = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ invalid_import[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import' NEWLINE")); + _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( token , "Expected one or more names after 'import'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_import[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import' NEWLINE")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_dotted_as_name: dotted_name 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression +Py_LOCAL_SYMBOL void * +invalid_dotted_as_name_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // dotted_name 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_dotted_as_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_name 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression")); + Token * _keyword; + expr_ty a; + expr_ty dotted_name_var; + if ( + (dotted_name_var = dotted_name_rule(p)) // dotted_name + && + (_keyword = _PyPegen_expect_token(p, 520)) // token='as' + && + _PyPegen_lookahead(0, _tmp_147_rule, p) + && + (a = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_dotted_as_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_name 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use %s as import target" , _PyPegen_get_expr_name ( a ) ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_dotted_as_name[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_name 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_import_from_as_name: NAME 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression +Py_LOCAL_SYMBOL void * +invalid_import_from_as_name_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // NAME 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_import_from_as_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression")); + Token * _keyword; + expr_ty a; + expr_ty name_var; + if ( + (name_var = _PyPegen_name_token(p)) // NAME + && + (_keyword = _PyPegen_expect_token(p, 520)) // token='as' + && + _PyPegen_lookahead(0, _tmp_147_rule, p) + && + (a = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_import_from_as_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use %s as import target" , _PyPegen_get_expr_name ( a ) ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_import_from_as_name[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME 'as' !(NAME (',' | ')' | ';' | NEWLINE)) expression")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_import_from: +// | 'from' (('.' | '...'))* dotted_name "lazy" 'import' import_from_targets +Py_LOCAL_SYMBOL void * +invalid_import_from_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'from' (('.' | '...'))* dotted_name "lazy" 'import' import_from_targets + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))* dotted_name \"lazy\" 'import' import_from_targets")); + Token * _keyword; + Token * _keyword_1; + asdl_seq * _loop0_148_var; + expr_ty a; + expr_ty dotted_name_var; + asdl_alias_seq* import_from_targets_var; + if ( + (_keyword = _PyPegen_expect_token(p, 501)) // token='from' + && + (_loop0_148_var = _loop0_148_rule(p)) // (('.' | '...'))* + && + (dotted_name_var = dotted_name_rule(p)) // dotted_name + && + (a = _PyPegen_expect_soft_keyword(p, "lazy")) // soft_keyword='"lazy"' + && + (_keyword_1 = _PyPegen_expect_token(p, 500)) // token='import' + && + (import_from_targets_var = import_from_targets_rule(p)) // import_from_targets + ) + { + D(fprintf(stderr, "%*c+ invalid_import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))* dotted_name \"lazy\" 'import' import_from_targets")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "use 'lazy from ... ' instead of 'from ... lazy import'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_import_from[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' (('.' | '...'))* dotted_name \"lazy\" 'import' import_from_targets")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_import_from_targets: import_from_as_names ',' NEWLINE | NEWLINE +Py_LOCAL_SYMBOL void * +invalid_import_from_targets_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // import_from_as_names ',' NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_names ',' NEWLINE")); + Token * _literal; + asdl_alias_seq* import_from_as_names_var; + Token * newline_var; + if ( + (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ invalid_import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_names ',' NEWLINE")); + _res = RAISE_SYNTAX_ERROR ( "trailing comma not allowed without surrounding parentheses" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_names ',' NEWLINE")); + } + { // NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + Token * token; + if ( + (token = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ invalid_import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( token , "Expected one or more names after 'import'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_with_stmt: +// | 'async'? 'with' ','.(expression ['as' star_target])+ ',' ':' +// | 'async'? 'with' ','.(expression ['as' star_target])+ NEWLINE +// | 'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE +Py_LOCAL_SYMBOL void * +invalid_with_stmt_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'async'? 'with' ','.(expression ['as' star_target])+ ',' ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ ',' ':'")); + asdl_seq * _gather_150_var; + Token * _keyword; + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * trailing; + if ( + (_opt_var = _PyPegen_expect_token(p, 513), !p->error_indicator) // 'async'? + && + (_keyword = _PyPegen_expect_token(p, 516)) // token='with' + && + (_gather_150_var = _gather_150_rule(p)) // ','.(expression ['as' star_target])+ + && + (trailing = _PyPegen_expect_token(p, 12)) // token=',' + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ invalid_with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ ',' ':'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( trailing , "the last 'with' item has a trailing comma" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_with_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ ',' ':'")); + } + { // 'async'? 'with' ','.(expression ['as' star_target])+ NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ NEWLINE")); + asdl_seq * _gather_150_var; + Token * _keyword; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * newline_var; + if ( + (_opt_var = _PyPegen_expect_token(p, 513), !p->error_indicator) // 'async'? + && + (_keyword = _PyPegen_expect_token(p, 516)) // token='with' + && + (_gather_150_var = _gather_150_rule(p)) // ','.(expression ['as' star_target])+ + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ invalid_with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ NEWLINE")); + _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_with_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ NEWLINE")); + } + { // 'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE")); + asdl_seq * _gather_152_var; + Token * _keyword; + Token * _literal; + Token * _literal_1; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + Token * newline_var; + if ( + (_opt_var = _PyPegen_expect_token(p, 513), !p->error_indicator) // 'async'? + && + (_keyword = _PyPegen_expect_token(p, 516)) // token='with' + && + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (_gather_152_var = _gather_152_rule(p)) // ','.(expressions ['as' star_target])+ + && + (_opt_var_1 = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ invalid_with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE")); + _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_with_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_with_stmt_indent: +// | 'async'? 'with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT +// | 'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' ':' NEWLINE !INDENT +Py_LOCAL_SYMBOL void * +invalid_with_stmt_indent_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'async'? 'with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_with_stmt_indent[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT")); + asdl_seq * _gather_150_var; + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * a; + Token * newline_var; + if ( + (_opt_var = _PyPegen_expect_token(p, 513), !p->error_indicator) // 'async'? + && + (a = _PyPegen_expect_token(p, 516)) // token='with' + && + (_gather_150_var = _gather_150_rule(p)) // ','.(expression ['as' star_target])+ + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_with_stmt_indent[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'with' statement on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_with_stmt_indent[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT")); + } + { // 'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_with_stmt_indent[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' ':' NEWLINE !INDENT")); + asdl_seq * _gather_152_var; + Token * _literal; + Token * _literal_1; + Token * _literal_2; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + Token * a; + Token * newline_var; + if ( + (_opt_var = _PyPegen_expect_token(p, 513), !p->error_indicator) // 'async'? + && + (a = _PyPegen_expect_token(p, 516)) // token='with' + && + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (_gather_152_var = _gather_152_rule(p)) // ','.(expressions ['as' star_target])+ + && + (_opt_var_1 = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + && + (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_with_stmt_indent[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'with' statement on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_with_stmt_indent[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' ':' NEWLINE !INDENT")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_try_stmt: +// | 'try' ':' NEWLINE !INDENT +// | 'try' ':' block !('except' | 'finally') +// | 'try' ':' block* except_block+ 'except' '*' expression ['as' NAME] ':' +// | 'try' ':' block* except_star_block+ 'except' [expression ['as' NAME]] ':' +Py_LOCAL_SYMBOL void * +invalid_try_stmt_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'try' ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_try_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'try' ':' NEWLINE !INDENT")); + Token * _literal; + Token * a; + Token * newline_var; + if ( + (a = _PyPegen_expect_token(p, 518)) // token='try' + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'try' statement on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_try_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' ':' NEWLINE !INDENT")); + } + { // 'try' ':' block !('except' | 'finally') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_try_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'try' ':' block !('except' | 'finally')")); + Token * _keyword; + Token * _literal; + asdl_stmt_seq* block_var; + if ( + (_keyword = _PyPegen_expect_token(p, 518)) // token='try' + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (block_var = block_rule(p)) // block + && + _PyPegen_lookahead(0, _tmp_153_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' ':' block !('except' | 'finally')")); + _res = RAISE_SYNTAX_ERROR ( "expected 'except' or 'finally' block" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_try_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' ':' block !('except' | 'finally')")); + } + { // 'try' ':' block* except_block+ 'except' '*' expression ['as' NAME] ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_try_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'try' ':' block* except_block+ 'except' '*' expression ['as' NAME] ':'")); + Token * _keyword; + Token * _literal; + Token * _literal_1; + asdl_seq * _loop0_154_var; + asdl_seq * _loop1_155_var; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * a; + Token * b; + expr_ty expression_var; + if ( + (_keyword = _PyPegen_expect_token(p, 518)) // token='try' + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (_loop0_154_var = _loop0_154_rule(p)) // block* + && + (_loop1_155_var = _loop1_155_rule(p)) // except_block+ + && + (a = _PyPegen_expect_token(p, 524)) // token='except' + && + (b = _PyPegen_expect_token(p, 16)) // token='*' + && + (expression_var = expression_rule(p)) // expression + && + (_opt_var = _tmp_156_rule(p), !p->error_indicator) // ['as' NAME] + && + (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ invalid_try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' ':' block* except_block+ 'except' '*' expression ['as' NAME] ':'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot have both 'except' and 'except*' on the same 'try'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_try_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' ':' block* except_block+ 'except' '*' expression ['as' NAME] ':'")); + } + { // 'try' ':' block* except_star_block+ 'except' [expression ['as' NAME]] ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_try_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'try' ':' block* except_star_block+ 'except' [expression ['as' NAME]] ':'")); + Token * _keyword; + Token * _literal; + Token * _literal_1; + asdl_seq * _loop0_154_var; + asdl_seq * _loop1_157_var; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * a; + if ( + (_keyword = _PyPegen_expect_token(p, 518)) // token='try' + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (_loop0_154_var = _loop0_154_rule(p)) // block* + && + (_loop1_157_var = _loop1_157_rule(p)) // except_star_block+ + && + (a = _PyPegen_expect_token(p, 524)) // token='except' + && + (_opt_var = _tmp_158_rule(p), !p->error_indicator) // [expression ['as' NAME]] + && + (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ invalid_try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' ':' block* except_star_block+ 'except' [expression ['as' NAME]] ':'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot have both 'except' and 'except*' on the same 'try'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_try_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' ':' block* except_star_block+ 'except' [expression ['as' NAME]] ':'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_except_stmt: +// | 'except' expression ',' expressions 'as' NAME ':' +// | 'except' expression ['as' NAME] NEWLINE +// | 'except' NEWLINE +// | 'except' expression 'as' expression ':' block +Py_LOCAL_SYMBOL void * +invalid_except_stmt_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'except' expression ',' expressions 'as' NAME ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_except_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' expression ',' expressions 'as' NAME ':'")); + Token * _keyword; + Token * _keyword_1; + Token * _literal; + Token * _literal_1; + expr_ty a; + expr_ty expressions_var; + expr_ty name_var; + if ( + (_keyword = _PyPegen_expect_token(p, 524)) // token='except' + && + (a = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (expressions_var = expressions_rule(p)) // expressions + && + (_keyword_1 = _PyPegen_expect_token(p, 520)) // token='as' + && + (name_var = _PyPegen_name_token(p)) // NAME + && + (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ invalid_except_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' expression ',' expressions 'as' NAME ':'")); + _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( a , "multiple exception types must be parenthesized when using 'as'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_except_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' expression ',' expressions 'as' NAME ':'")); + } + { // 'except' expression ['as' NAME] NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_except_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] NEWLINE")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * a; + expr_ty expression_var; + Token * newline_var; + if ( + (a = _PyPegen_expect_token(p, 524)) // token='except' + && + (expression_var = expression_rule(p)) // expression + && + (_opt_var = _tmp_156_rule(p), !p->error_indicator) // ['as' NAME] + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ invalid_except_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] NEWLINE")); + _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_except_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' expression ['as' NAME] NEWLINE")); + } + { // 'except' NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_except_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' NEWLINE")); + Token * a; + Token * newline_var; + if ( + (a = _PyPegen_expect_token(p, 524)) // token='except' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ invalid_except_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' NEWLINE")); + _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_except_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' NEWLINE")); + } + { // 'except' expression 'as' expression ':' block + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_except_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' expression 'as' expression ':' block")); + Token * _keyword; + Token * _keyword_1; + Token * _literal; + expr_ty a; + asdl_stmt_seq* block_var; + expr_ty expression_var; + if ( + (_keyword = _PyPegen_expect_token(p, 524)) // token='except' + && + (expression_var = expression_rule(p)) // expression + && + (_keyword_1 = _PyPegen_expect_token(p, 520)) // token='as' + && + (a = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (block_var = block_rule(p)) // block + ) + { + D(fprintf(stderr, "%*c+ invalid_except_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' expression 'as' expression ':' block")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use except statement with %s" , _PyPegen_get_expr_name ( a ) ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_except_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' expression 'as' expression ':' block")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_except_star_stmt: +// | 'except' '*' expression ',' expressions 'as' NAME ':' +// | 'except' '*' expression ['as' NAME] NEWLINE +// | 'except' '*' (NEWLINE | ':') +// | 'except' '*' expression 'as' expression ':' block +Py_LOCAL_SYMBOL void * +invalid_except_star_stmt_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'except' '*' expression ',' expressions 'as' NAME ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_except_star_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' '*' expression ',' expressions 'as' NAME ':'")); + Token * _keyword; + Token * _keyword_1; + Token * _literal; + Token * _literal_1; + Token * _literal_2; + expr_ty a; + expr_ty expressions_var; + expr_ty name_var; + if ( + (_keyword = _PyPegen_expect_token(p, 524)) // token='except' + && + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (a = expression_rule(p)) // expression + && + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + && + (expressions_var = expressions_rule(p)) // expressions + && + (_keyword_1 = _PyPegen_expect_token(p, 520)) // token='as' + && + (name_var = _PyPegen_name_token(p)) // NAME + && + (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ invalid_except_star_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' '*' expression ',' expressions 'as' NAME ':'")); + _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( a , "multiple exception types must be parenthesized when using 'as'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_except_star_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' '*' expression ',' expressions 'as' NAME ':'")); + } + { // 'except' '*' expression ['as' NAME] NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_except_star_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' '*' expression ['as' NAME] NEWLINE")); + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * a; + expr_ty expression_var; + Token * newline_var; + if ( + (a = _PyPegen_expect_token(p, 524)) // token='except' + && + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (expression_var = expression_rule(p)) // expression + && + (_opt_var = _tmp_156_rule(p), !p->error_indicator) // ['as' NAME] + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ invalid_except_star_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' '*' expression ['as' NAME] NEWLINE")); + _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_except_star_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' '*' expression ['as' NAME] NEWLINE")); + } + { // 'except' '*' (NEWLINE | ':') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_except_star_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' '*' (NEWLINE | ':')")); + Token * _literal; + void *_tmp_159_var; + Token * a; + if ( + (a = _PyPegen_expect_token(p, 524)) // token='except' + && + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (_tmp_159_var = _tmp_159_rule(p)) // NEWLINE | ':' + ) + { + D(fprintf(stderr, "%*c+ invalid_except_star_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' '*' (NEWLINE | ':')")); + _res = RAISE_SYNTAX_ERROR ( "expected one or more exception types" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_except_star_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' '*' (NEWLINE | ':')")); + } + { // 'except' '*' expression 'as' expression ':' block + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_except_star_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' '*' expression 'as' expression ':' block")); + Token * _keyword; + Token * _keyword_1; + Token * _literal; + Token * _literal_1; + expr_ty a; + asdl_stmt_seq* block_var; + expr_ty expression_var; + if ( + (_keyword = _PyPegen_expect_token(p, 524)) // token='except' + && + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (expression_var = expression_rule(p)) // expression + && + (_keyword_1 = _PyPegen_expect_token(p, 520)) // token='as' + && + (a = expression_rule(p)) // expression + && + (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' + && + (block_var = block_rule(p)) // block + ) + { + D(fprintf(stderr, "%*c+ invalid_except_star_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' '*' expression 'as' expression ':' block")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use except* statement with %s" , _PyPegen_get_expr_name ( a ) ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_except_star_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' '*' expression 'as' expression ':' block")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_finally_stmt: 'finally' ':' NEWLINE !INDENT +Py_LOCAL_SYMBOL void * +invalid_finally_stmt_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'finally' ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_finally_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'finally' ':' NEWLINE !INDENT")); + Token * _literal; + Token * a; + Token * newline_var; + if ( + (a = _PyPegen_expect_token(p, 525)) // token='finally' + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_finally_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'finally' ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'finally' statement on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_finally_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'finally' ':' NEWLINE !INDENT")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_except_stmt_indent: +// | 'except' expression ['as' NAME] ':' NEWLINE !INDENT +// | 'except' ':' NEWLINE !INDENT +Py_LOCAL_SYMBOL void * +invalid_except_stmt_indent_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'except' expression ['as' NAME] ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_except_stmt_indent[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] ':' NEWLINE !INDENT")); + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * a; + expr_ty expression_var; + Token * newline_var; + if ( + (a = _PyPegen_expect_token(p, 524)) // token='except' + && + (expression_var = expression_rule(p)) // expression + && + (_opt_var = _tmp_156_rule(p), !p->error_indicator) // ['as' NAME] + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_except_stmt_indent[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'except' statement on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_except_stmt_indent[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' expression ['as' NAME] ':' NEWLINE !INDENT")); + } + { // 'except' ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_except_stmt_indent[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' ':' NEWLINE !INDENT")); + Token * _literal; + Token * a; + Token * newline_var; + if ( + (a = _PyPegen_expect_token(p, 524)) // token='except' + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_except_stmt_indent[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'except' statement on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_except_stmt_indent[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' ':' NEWLINE !INDENT")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_except_star_stmt_indent: +// | 'except' '*' expression ['as' NAME] ':' NEWLINE !INDENT +Py_LOCAL_SYMBOL void * +invalid_except_star_stmt_indent_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'except' '*' expression ['as' NAME] ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_except_star_stmt_indent[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' '*' expression ['as' NAME] ':' NEWLINE !INDENT")); + Token * _literal; + Token * _literal_1; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * a; + expr_ty expression_var; + Token * newline_var; + if ( + (a = _PyPegen_expect_token(p, 524)) // token='except' + && + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (expression_var = expression_rule(p)) // expression + && + (_opt_var = _tmp_156_rule(p), !p->error_indicator) // ['as' NAME] + && + (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_except_star_stmt_indent[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' '*' expression ['as' NAME] ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'except*' statement on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_except_star_stmt_indent[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' '*' expression ['as' NAME] ':' NEWLINE !INDENT")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_match_stmt: +// | "match" subject_expr NEWLINE +// | "match" subject_expr ':' NEWLINE !INDENT +// | "case" patterns guard? ':' block +Py_LOCAL_SYMBOL void * +invalid_match_stmt_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // "match" subject_expr NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"match\" subject_expr NEWLINE")); + expr_ty _keyword; + Token * newline_var; + expr_ty subject_expr_var; + if ( + (_keyword = _PyPegen_expect_soft_keyword(p, "match")) // soft_keyword='"match"' + && + (subject_expr_var = subject_expr_rule(p)) // subject_expr + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ invalid_match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"match\" subject_expr NEWLINE")); + _res = CHECK_VERSION ( void* , 10 , "Pattern matching is" , RAISE_SYNTAX_ERROR ( "expected ':'" ) ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_match_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"match\" subject_expr NEWLINE")); + } + { // "match" subject_expr ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"match\" subject_expr ':' NEWLINE !INDENT")); + Token * _literal; + expr_ty a; + Token * newline_var; + expr_ty subject; + if ( + (a = _PyPegen_expect_soft_keyword(p, "match")) // soft_keyword='"match"' + && + (subject = subject_expr_rule(p)) // subject_expr + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"match\" subject_expr ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'match' statement on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_match_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"match\" subject_expr ':' NEWLINE !INDENT")); + } + { // "case" patterns guard? ':' block + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? ':' block")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty a; + Token * b; + asdl_stmt_seq* block_var; + pattern_ty patterns_var; + if ( + (a = _PyPegen_expect_soft_keyword(p, "case")) // soft_keyword='"case"' + && + (patterns_var = patterns_rule(p)) // patterns + && + (_opt_var = guard_rule(p), !p->error_indicator) // guard? + && + (b = _PyPegen_expect_token(p, 11)) // token=':' + && + (block_var = block_rule(p)) // block + ) + { + D(fprintf(stderr, "%*c+ invalid_match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? ':' block")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "case statement must be inside match statement" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_match_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"case\" patterns guard? ':' block")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_case_block: +// | "case" patterns guard? NEWLINE +// | "case" patterns guard? ':' NEWLINE !INDENT +Py_LOCAL_SYMBOL void * +invalid_case_block_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // "case" patterns guard? NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_case_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? NEWLINE")); + expr_ty _keyword; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * newline_var; + pattern_ty patterns_var; + if ( + (_keyword = _PyPegen_expect_soft_keyword(p, "case")) // soft_keyword='"case"' + && + (patterns_var = patterns_rule(p)) // patterns + && + (_opt_var = guard_rule(p), !p->error_indicator) // guard? + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ invalid_case_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? NEWLINE")); + _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_case_block[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"case\" patterns guard? NEWLINE")); + } + { // "case" patterns guard? ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_case_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? ':' NEWLINE !INDENT")); + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty a; + Token * newline_var; + pattern_ty patterns_var; + if ( + (a = _PyPegen_expect_soft_keyword(p, "case")) // soft_keyword='"case"' + && + (patterns_var = patterns_rule(p)) // patterns + && + (_opt_var = guard_rule(p), !p->error_indicator) // guard? + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_case_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'case' statement on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_case_block[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"case\" patterns guard? ':' NEWLINE !INDENT")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_as_pattern: or_pattern 'as' "_" | or_pattern 'as' expression +Py_LOCAL_SYMBOL void * +invalid_as_pattern_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // or_pattern 'as' "_" + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_as_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' \"_\"")); + Token * _keyword; + expr_ty a; + pattern_ty or_pattern_var; + if ( + (or_pattern_var = or_pattern_rule(p)) // or_pattern + && + (_keyword = _PyPegen_expect_token(p, 520)) // token='as' + && + (a = _PyPegen_expect_soft_keyword(p, "_")) // soft_keyword='"_"' + ) + { + D(fprintf(stderr, "%*c+ invalid_as_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' \"_\"")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use '_' as a target" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_as_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "or_pattern 'as' \"_\"")); + } + { // or_pattern 'as' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_as_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' expression")); + Token * _keyword; + expr_ty a; + pattern_ty or_pattern_var; + if ( + (or_pattern_var = or_pattern_rule(p)) // or_pattern + && + (_keyword = _PyPegen_expect_token(p, 520)) // token='as' + && + (a = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_as_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use %s as pattern target" , _PyPegen_get_expr_name ( a ) ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_as_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "or_pattern 'as' expression")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_class_pattern: name_or_attr '(' invalid_class_argument_pattern +Py_LOCAL_SYMBOL void * +invalid_class_pattern_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // name_or_attr '(' invalid_class_argument_pattern + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' invalid_class_argument_pattern")); + Token * _literal; + asdl_pattern_seq* a; + expr_ty name_or_attr_var; + if ( + (name_or_attr_var = name_or_attr_rule(p)) // name_or_attr + && + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (a = invalid_class_argument_pattern_rule(p)) // invalid_class_argument_pattern + ) + { + D(fprintf(stderr, "%*c+ invalid_class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' invalid_class_argument_pattern")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( PyPegen_first_item ( a , pattern_ty ) , PyPegen_last_item ( a , pattern_ty ) , "positional patterns follow keyword patterns" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_class_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' invalid_class_argument_pattern")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_mapping_pattern: +// | '{' [(items_pattern ',')] double_star_pattern ',' items_pattern ','? '}' +Py_LOCAL_SYMBOL void * +invalid_mapping_pattern_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '{' [(items_pattern ',')] double_star_pattern ',' items_pattern ','? '}' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_mapping_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' [(items_pattern ',')] double_star_pattern ',' items_pattern ','? '}'")); + Token * _literal; + Token * _literal_1; + Token * _literal_2; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + asdl_seq* items_pattern_var; + expr_ty rest; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (_opt_var = _tmp_160_rule(p), !p->error_indicator) // [(items_pattern ',')] + && + (rest = double_star_pattern_rule(p)) // double_star_pattern + && + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + && + (items_pattern_var = items_pattern_rule(p)) // items_pattern + && + (_opt_var_1 = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? + && + (_literal_2 = _PyPegen_expect_token(p, 26)) // token='}' + ) + { + D(fprintf(stderr, "%*c+ invalid_mapping_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' [(items_pattern ',')] double_star_pattern ',' items_pattern ','? '}'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( rest , "double star pattern must be the last (right-most) subpattern in the mapping pattern" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_mapping_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' [(items_pattern ',')] double_star_pattern ',' items_pattern ','? '}'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_class_argument_pattern: +// | [positional_patterns ','] keyword_patterns ',' positional_patterns +static asdl_pattern_seq* +invalid_class_argument_pattern_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + asdl_pattern_seq* _res = NULL; + int _mark = p->mark; + { // [positional_patterns ','] keyword_patterns ',' positional_patterns + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_class_argument_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "[positional_patterns ','] keyword_patterns ',' positional_patterns")); + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_pattern_seq* a; + asdl_seq* keyword_patterns_var; + if ( + (_opt_var = _tmp_161_rule(p), !p->error_indicator) // [positional_patterns ','] + && + (keyword_patterns_var = keyword_patterns_rule(p)) // keyword_patterns + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (a = positional_patterns_rule(p)) // positional_patterns + ) + { + D(fprintf(stderr, "%*c+ invalid_class_argument_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "[positional_patterns ','] keyword_patterns ',' positional_patterns")); + _res = a; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_class_argument_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "[positional_patterns ','] keyword_patterns ',' positional_patterns")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_if_stmt: +// | 'if' named_expression NEWLINE +// | 'if' named_expression ':' NEWLINE !INDENT +Py_LOCAL_SYMBOL void * +invalid_if_stmt_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'if' named_expression NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_if_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression NEWLINE")); + Token * _keyword; + expr_ty named_expression_var; + Token * newline_var; + if ( + (_keyword = _PyPegen_expect_token(p, 514)) // token='if' + && + (named_expression_var = named_expression_rule(p)) // named_expression + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ invalid_if_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression NEWLINE")); + _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_if_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression NEWLINE")); + } + { // 'if' named_expression ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_if_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' NEWLINE !INDENT")); + Token * _literal; + Token * a; + expr_ty a_1; + Token * newline_var; + if ( + (a = _PyPegen_expect_token(p, 514)) // token='if' + && + (a_1 = named_expression_rule(p)) // named_expression + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_if_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'if' statement on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_if_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression ':' NEWLINE !INDENT")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_elif_stmt: +// | 'elif' named_expression NEWLINE +// | 'elif' named_expression ':' NEWLINE !INDENT +Py_LOCAL_SYMBOL void * +invalid_elif_stmt_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'elif' named_expression NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_elif_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'elif' named_expression NEWLINE")); + Token * _keyword; + expr_ty named_expression_var; + Token * newline_var; + if ( + (_keyword = _PyPegen_expect_token(p, 521)) // token='elif' + && + (named_expression_var = named_expression_rule(p)) // named_expression + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ invalid_elif_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'elif' named_expression NEWLINE")); + _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_elif_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'elif' named_expression NEWLINE")); + } + { // 'elif' named_expression ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_elif_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' NEWLINE !INDENT")); + Token * _literal; + Token * a; + expr_ty named_expression_var; + Token * newline_var; + if ( + (a = _PyPegen_expect_token(p, 521)) // token='elif' + && + (named_expression_var = named_expression_rule(p)) // named_expression + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_elif_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'elif' statement on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_elif_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'elif' named_expression ':' NEWLINE !INDENT")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_else_stmt: 'else' ':' NEWLINE !INDENT | 'else' ':' block 'elif' +Py_LOCAL_SYMBOL void * +invalid_else_stmt_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'else' ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_else_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else' ':' NEWLINE !INDENT")); + Token * _literal; + Token * a; + Token * newline_var; + if ( + (a = _PyPegen_expect_token(p, 522)) // token='else' + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_else_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else' ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'else' statement on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_else_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'else' ':' NEWLINE !INDENT")); + } + { // 'else' ':' block 'elif' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_else_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else' ':' block 'elif'")); + Token * _keyword; + Token * _keyword_1; + Token * _literal; + asdl_stmt_seq* block_var; + if ( + (_keyword = _PyPegen_expect_token(p, 522)) // token='else' + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (block_var = block_rule(p)) // block + && + (_keyword_1 = _PyPegen_expect_token(p, 521)) // token='elif' + ) + { + D(fprintf(stderr, "%*c+ invalid_else_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else' ':' block 'elif'")); + _res = RAISE_SYNTAX_ERROR ( "'elif' block follows an 'else' block" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_else_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'else' ':' block 'elif'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_while_stmt: +// | 'while' named_expression NEWLINE +// | 'while' named_expression ':' NEWLINE !INDENT +Py_LOCAL_SYMBOL void * +invalid_while_stmt_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'while' named_expression NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_while_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'while' named_expression NEWLINE")); + Token * _keyword; + expr_ty named_expression_var; + Token * newline_var; + if ( + (_keyword = _PyPegen_expect_token(p, 519)) // token='while' + && + (named_expression_var = named_expression_rule(p)) // named_expression + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ invalid_while_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'while' named_expression NEWLINE")); + _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_while_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'while' named_expression NEWLINE")); + } + { // 'while' named_expression ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_while_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'while' named_expression ':' NEWLINE !INDENT")); + Token * _literal; + Token * a; + expr_ty named_expression_var; + Token * newline_var; + if ( + (a = _PyPegen_expect_token(p, 519)) // token='while' + && + (named_expression_var = named_expression_rule(p)) // named_expression + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_while_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'while' named_expression ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'while' statement on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_while_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'while' named_expression ':' NEWLINE !INDENT")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_for_stmt: +// | 'async'? 'for' star_targets 'in' star_expressions NEWLINE +// | 'async'? 'for' star_targets 'in' star_expressions ':' NEWLINE !INDENT +Py_LOCAL_SYMBOL void * +invalid_for_stmt_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'async'? 'for' star_targets 'in' star_expressions NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_for_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'for' star_targets 'in' star_expressions NEWLINE")); + Token * _keyword; + Token * _keyword_1; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * newline_var; + expr_ty star_expressions_var; + expr_ty star_targets_var; + if ( + (_opt_var = _PyPegen_expect_token(p, 513), !p->error_indicator) // 'async'? + && + (_keyword = _PyPegen_expect_token(p, 517)) // token='for' + && + (star_targets_var = star_targets_rule(p)) // star_targets + && + (_keyword_1 = _PyPegen_expect_token(p, 523)) // token='in' + && + (star_expressions_var = star_expressions_rule(p)) // star_expressions + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ invalid_for_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'for' star_targets 'in' star_expressions NEWLINE")); + _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_for_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'for' star_targets 'in' star_expressions NEWLINE")); + } + { // 'async'? 'for' star_targets 'in' star_expressions ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_for_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'for' star_targets 'in' star_expressions ':' NEWLINE !INDENT")); + Token * _keyword; + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + Token * a; + Token * newline_var; + expr_ty star_expressions_var; + expr_ty star_targets_var; + if ( + (_opt_var = _PyPegen_expect_token(p, 513), !p->error_indicator) // 'async'? + && + (a = _PyPegen_expect_token(p, 517)) // token='for' + && + (star_targets_var = star_targets_rule(p)) // star_targets + && + (_keyword = _PyPegen_expect_token(p, 523)) // token='in' + && + (star_expressions_var = star_expressions_rule(p)) // star_expressions + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_for_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'for' star_targets 'in' star_expressions ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'for' statement on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_for_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'for' star_targets 'in' star_expressions ':' NEWLINE !INDENT")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_def_raw: +// | 'async'? 'def' NAME type_params? '(' params? ')' ['->' expression] ':' NEWLINE !INDENT +// | 'async'? 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block +Py_LOCAL_SYMBOL void * +invalid_def_raw_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'async'? 'def' NAME type_params? '(' params? ')' ['->' expression] ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'def' NAME type_params? '(' params? ')' ['->' expression] ':' NEWLINE !INDENT")); + Token * _literal; + Token * _literal_1; + Token * _literal_2; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + void *_opt_var_2; + UNUSED(_opt_var_2); // Silence compiler warnings + void *_opt_var_3; + UNUSED(_opt_var_3); // Silence compiler warnings + Token * a; + expr_ty name_var; + Token * newline_var; + if ( + (_opt_var = _PyPegen_expect_token(p, 513), !p->error_indicator) // 'async'? + && + (a = _PyPegen_expect_token(p, 512)) // token='def' + && + (name_var = _PyPegen_name_token(p)) // NAME + && + (_opt_var_1 = type_params_rule(p), !p->error_indicator) // type_params? + && + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (_opt_var_2 = params_rule(p), !p->error_indicator) // params? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + && + (_opt_var_3 = _tmp_162_rule(p), !p->error_indicator) // ['->' expression] + && + (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'def' NAME type_params? '(' params? ')' ['->' expression] ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after function definition on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_def_raw[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'def' NAME type_params? '(' params? ')' ['->' expression] ':' NEWLINE !INDENT")); + } + { // 'async'? 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'? 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); + Token * _keyword; + Token * _literal; + Token * _literal_1; + Token * _literal_2; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + void *_opt_var_2; + UNUSED(_opt_var_2); // Silence compiler warnings + void *_opt_var_3; + UNUSED(_opt_var_3); // Silence compiler warnings + void *_opt_var_4; + UNUSED(_opt_var_4); // Silence compiler warnings + asdl_stmt_seq* block_var; + expr_ty name_var; + if ( + (_opt_var = _PyPegen_expect_token(p, 513), !p->error_indicator) // 'async'? + && + (_keyword = _PyPegen_expect_token(p, 512)) // token='def' + && + (name_var = _PyPegen_name_token(p)) // NAME + && + (_opt_var_1 = type_params_rule(p), !p->error_indicator) // type_params? + && + (_literal = _PyPegen_expect_forced_token(p, 7, "(")) // forced_token='(' + && + (_opt_var_2 = params_rule(p), !p->error_indicator) // params? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + && + (_opt_var_3 = _tmp_162_rule(p), !p->error_indicator) // ['->' expression] + && + (_literal_2 = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' + && + (_opt_var_4 = func_type_comment_rule(p), !p->error_indicator) // func_type_comment? + && + (block_var = block_rule(p)) // block + ) + { + D(fprintf(stderr, "%*c+ invalid_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); + _res = _PyPegen_dummy_name(p, _opt_var, _keyword, name_var, _opt_var_1, _literal, _opt_var_2, _literal_1, _opt_var_3, _literal_2, _opt_var_4, block_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_def_raw[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'async'? 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_class_def_raw: +// | 'class' NAME type_params? ['(' arguments? ')'] NEWLINE +// | 'class' NAME type_params? ['(' arguments? ')'] ':' NEWLINE !INDENT +Py_LOCAL_SYMBOL void * +invalid_class_def_raw_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'class' NAME type_params? ['(' arguments? ')'] NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_class_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class' NAME type_params? ['(' arguments? ')'] NEWLINE")); + Token * _keyword; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + expr_ty name_var; + Token * newline_var; + if ( + (_keyword = _PyPegen_expect_token(p, 515)) // token='class' + && + (name_var = _PyPegen_name_token(p)) // NAME + && + (_opt_var = type_params_rule(p), !p->error_indicator) // type_params? + && + (_opt_var_1 = _tmp_163_rule(p), !p->error_indicator) // ['(' arguments? ')'] + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ invalid_class_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class' NAME type_params? ['(' arguments? ')'] NEWLINE")); + _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_class_def_raw[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class' NAME type_params? ['(' arguments? ')'] NEWLINE")); + } + { // 'class' NAME type_params? ['(' arguments? ')'] ':' NEWLINE !INDENT + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_class_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class' NAME type_params? ['(' arguments? ')'] ':' NEWLINE !INDENT")); + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + Token * a; + expr_ty name_var; + Token * newline_var; + if ( + (a = _PyPegen_expect_token(p, 515)) // token='class' + && + (name_var = _PyPegen_name_token(p)) // NAME + && + (_opt_var = type_params_rule(p), !p->error_indicator) // type_params? + && + (_opt_var_1 = _tmp_163_rule(p), !p->error_indicator) // ['(' arguments? ')'] + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_class_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class' NAME type_params? ['(' arguments? ')'] ':' NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block after class definition on line %d" , a -> lineno ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_class_def_raw[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class' NAME type_params? ['(' arguments? ')'] ':' NEWLINE !INDENT")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_double_starred_kvpairs: +// | invalid_kvpair_unpacking ','? +// | ','.double_starred_kvpair+ ',' (invalid_kvpair | invalid_kvpair_unpacking) +// | expression ':' &('}' | ',') +Py_LOCAL_SYMBOL void * +invalid_double_starred_kvpairs_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // invalid_kvpair_unpacking ','? + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kvpair_unpacking ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *invalid_kvpair_unpacking_var; + if ( + (invalid_kvpair_unpacking_var = invalid_kvpair_unpacking_rule(p)) // invalid_kvpair_unpacking + && + (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? + ) + { + D(fprintf(stderr, "%*c+ invalid_double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kvpair_unpacking ','?")); + _res = _PyPegen_dummy_name(p, invalid_kvpair_unpacking_var, _opt_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_double_starred_kvpairs[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kvpair_unpacking ','?")); + } + { // ','.double_starred_kvpair+ ',' (invalid_kvpair | invalid_kvpair_unpacking) + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ',' (invalid_kvpair | invalid_kvpair_unpacking)")); + asdl_seq * _gather_165_var; + Token * _literal; + void *_tmp_166_var; + if ( + (_gather_165_var = _gather_165_rule(p)) // ','.double_starred_kvpair+ + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (_tmp_166_var = _tmp_166_rule(p)) // invalid_kvpair | invalid_kvpair_unpacking + ) + { + D(fprintf(stderr, "%*c+ invalid_double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ',' (invalid_kvpair | invalid_kvpair_unpacking)")); + _res = _PyPegen_dummy_name(p, _gather_165_var, _literal, _tmp_166_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_double_starred_kvpairs[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.double_starred_kvpair+ ',' (invalid_kvpair | invalid_kvpair_unpacking)")); + } + { // expression ':' &('}' | ',') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' &('}' | ',')")); + Token * a; + expr_ty expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (a = _PyPegen_expect_token(p, 11)) // token=':' + && + _PyPegen_lookahead(1, _tmp_167_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' &('}' | ',')")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expression expected after dictionary key and ':'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_double_starred_kvpairs[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' &('}' | ',')")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_kvpair_unpacking: +// | '**' if_expression +// | '*' bitwise_or ':' expression +// | '**' bitwise_or ':' expression +// | expression ':' '*' bitwise_or +// | expression ':' '**' bitwise_or +static void * +invalid_kvpair_unpacking_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + expr_ty _prefix_14_result = NULL; + int _prefix_14_end = 0, _prefix_14_valid = 0; + { // '**' if_expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kvpair_unpacking[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' if_expression")); + Token * a; + expr_ty b; + if ( + (a = _PyPegen_expect_token(p, 35)) // token='**' + && + (b = if_expression_rule(p)) // if_expression + ) + { + D(fprintf(stderr, "%*c+ invalid_kvpair_unpacking[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' if_expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "invalid double starred expression. Did you forget to wrap the conditional expression in parentheses?" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kvpair_unpacking[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' if_expression")); + } + { // '*' bitwise_or ':' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kvpair_unpacking[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or ':' expression")); + Token * _literal; + Token * a; + expr_ty b; + expr_ty expression_var; + if ( + (a = _PyPegen_expect_token(p, 16)) // token='*' + && + (b = bitwise_or_rule(p)) // bitwise_or + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (expression_var = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_kvpair_unpacking[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or ':' expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use a starred expression in a dictionary key" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kvpair_unpacking[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' bitwise_or ':' expression")); + } + { // '**' bitwise_or ':' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kvpair_unpacking[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or ':' expression")); + Token * _literal; + Token * a; + expr_ty b; + expr_ty expression_var; + if ( + (a = _PyPegen_expect_token(p, 35)) // token='**' + && + (b = bitwise_or_rule(p)) // bitwise_or + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (expression_var = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_kvpair_unpacking[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or ':' expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use dict unpacking in a dictionary key" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kvpair_unpacking[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' bitwise_or ':' expression")); + } + { // expression ':' '*' bitwise_or + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kvpair_unpacking[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' '*' bitwise_or")); + Token * _literal; + Token * a; + expr_ty b; + expr_ty expression_var; + if ( + (expression_var = ((!p->call_invalid_rules && _prefix_14_valid) ? (p->mark = _prefix_14_end, _prefix_14_result) : (_prefix_14_result = expression_rule(p), _prefix_14_end = p->mark, _prefix_14_valid = 1, _prefix_14_result))) // expression + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (a = _PyPegen_expect_token(p, 16)) // token='*' + && + (b = bitwise_or_rule(p)) // bitwise_or + ) + { + D(fprintf(stderr, "%*c+ invalid_kvpair_unpacking[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' '*' bitwise_or")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use a starred expression in a dictionary value" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kvpair_unpacking[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' '*' bitwise_or")); + } + { // expression ':' '**' bitwise_or + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kvpair_unpacking[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' '**' bitwise_or")); + Token * _literal; + Token * a; + expr_ty b; + expr_ty expression_var; + if ( + (expression_var = ((!p->call_invalid_rules && _prefix_14_valid) ? (p->mark = _prefix_14_end, _prefix_14_result) : (_prefix_14_result = expression_rule(p), _prefix_14_end = p->mark, _prefix_14_valid = 1, _prefix_14_result))) // expression + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (a = _PyPegen_expect_token(p, 35)) // token='**' + && + (b = bitwise_or_rule(p)) // bitwise_or + ) + { + D(fprintf(stderr, "%*c+ invalid_kvpair_unpacking[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' '**' bitwise_or")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot use dict unpacking in a dictionary value" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kvpair_unpacking[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' '**' bitwise_or")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_kvpair: +// | expression !(':') +// | expression ':' '*' bitwise_or +// | expression ':' '**' bitwise_or +// | expression ':' &('}' | ',') +static void * +invalid_kvpair_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + expr_ty _prefix_15_result = NULL; + int _prefix_15_end = 0, _prefix_15_valid = 0; + { // expression !(':') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !(':')")); + expr_ty a; + if ( + (a = ((!p->call_invalid_rules && _prefix_15_valid) ? (p->mark = _prefix_15_end, _prefix_15_result) : (_prefix_15_result = expression_rule(p), _prefix_15_end = p->mark, _prefix_15_valid = 1, _prefix_15_result))) // expression + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 11) // token=(':') + ) + { + D(fprintf(stderr, "%*c+ invalid_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !(':')")); + _res = RAISE_ERROR_KNOWN_LOCATION ( p , PyExc_SyntaxError , a -> lineno , a -> end_col_offset - 1 , a -> end_lineno , - 1 , "':' expected after dictionary key" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kvpair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !(':')")); + } + { // expression ':' '*' bitwise_or + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' '*' bitwise_or")); + Token * _literal; + Token * a; + expr_ty bitwise_or_var; + expr_ty expression_var; + if ( + (expression_var = ((!p->call_invalid_rules && _prefix_15_valid) ? (p->mark = _prefix_15_end, _prefix_15_result) : (_prefix_15_result = expression_rule(p), _prefix_15_end = p->mark, _prefix_15_valid = 1, _prefix_15_result))) // expression + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (a = _PyPegen_expect_token(p, 16)) // token='*' + && + (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + ) + { + D(fprintf(stderr, "%*c+ invalid_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' '*' bitwise_or")); + _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( a , "cannot use a starred expression in a dictionary value" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kvpair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' '*' bitwise_or")); + } + { // expression ':' '**' bitwise_or + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' '**' bitwise_or")); + Token * _literal; + Token * a; + expr_ty bitwise_or_var; + expr_ty expression_var; + if ( + (expression_var = ((!p->call_invalid_rules && _prefix_15_valid) ? (p->mark = _prefix_15_end, _prefix_15_result) : (_prefix_15_result = expression_rule(p), _prefix_15_end = p->mark, _prefix_15_valid = 1, _prefix_15_result))) // expression + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (a = _PyPegen_expect_token(p, 35)) // token='**' + && + (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + ) + { + D(fprintf(stderr, "%*c+ invalid_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' '**' bitwise_or")); + _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( a , "cannot use dict unpacking in a dictionary value" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kvpair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' '**' bitwise_or")); + } + { // expression ':' &('}' | ',') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' &('}' | ',')")); + Token * a; + expr_ty expression_var; + if ( + (expression_var = ((!p->call_invalid_rules && _prefix_15_valid) ? (p->mark = _prefix_15_end, _prefix_15_result) : (_prefix_15_result = expression_rule(p), _prefix_15_end = p->mark, _prefix_15_valid = 1, _prefix_15_result))) // expression + && + (a = _PyPegen_expect_token(p, 11)) // token=':' + && + _PyPegen_lookahead(1, _tmp_167_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' &('}' | ',')")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expression expected after dictionary key and ':'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_kvpair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' &('}' | ',')")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_starred_expression_unpacking: '*' if_expression | '*' expression '=' expression +Py_LOCAL_SYMBOL void * +invalid_starred_expression_unpacking_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '*' if_expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_starred_expression_unpacking[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' if_expression")); + Token * a; + expr_ty b; + if ( + (a = _PyPegen_expect_token(p, 16)) // token='*' + && + (b = if_expression_rule(p)) // if_expression + ) + { + D(fprintf(stderr, "%*c+ invalid_starred_expression_unpacking[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' if_expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "invalid starred expression. Did you forget to wrap the conditional expression in parentheses?" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_starred_expression_unpacking[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' if_expression")); + } + { // '*' expression '=' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_starred_expression_unpacking[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression '=' expression")); + Token * _literal; + Token * a; + expr_ty b; + expr_ty expression_var; + if ( + (a = _PyPegen_expect_token(p, 16)) // token='*' + && + (expression_var = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + && + (b = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_starred_expression_unpacking[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression '=' expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "cannot assign to iterable argument unpacking" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_starred_expression_unpacking[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression '=' expression")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_starred_expression_unpacking_sequence: +// | '**' bitwise_or +// | invalid_starred_expression_unpacking +Py_LOCAL_SYMBOL void * +invalid_starred_expression_unpacking_sequence_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '**' bitwise_or + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_starred_expression_unpacking_sequence[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or")); + Token * a; + expr_ty bitwise_or_var; + if ( + (a = _PyPegen_expect_token(p, 35)) // token='**' + && + (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + ) + { + D(fprintf(stderr, "%*c+ invalid_starred_expression_unpacking_sequence[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use dict unpacking here" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_starred_expression_unpacking_sequence[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' bitwise_or")); + } + if (p->call_invalid_rules) { // invalid_starred_expression_unpacking + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_starred_expression_unpacking_sequence[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_starred_expression_unpacking")); + void *invalid_starred_expression_unpacking_var; + if ( + (invalid_starred_expression_unpacking_var = invalid_starred_expression_unpacking_rule(p)) // invalid_starred_expression_unpacking + ) + { + D(fprintf(stderr, "%*c+ invalid_starred_expression_unpacking_sequence[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_starred_expression_unpacking")); + _res = invalid_starred_expression_unpacking_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_starred_expression_unpacking_sequence[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_starred_expression_unpacking")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_starred_expression: '*' +Py_LOCAL_SYMBOL void * +invalid_starred_expression_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '*' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_starred_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + ) + { + D(fprintf(stderr, "%*c+ invalid_starred_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); + _res = RAISE_SYNTAX_ERROR ( "Invalid star expression" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_starred_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_fstring_replacement_field: +// | '{' '=' +// | '{' '!' +// | '{' ':' +// | '{' '}' +// | '{' !annotated_rhs +// | '{' annotated_rhs !('=' | '!' | ':' | '}') +// | '{' annotated_rhs '=' !('!' | ':' | '}') +// | '{' annotated_rhs '='? invalid_fstring_conversion_character +// | '{' annotated_rhs '='? ['!' NAME] !(':' | '}') +// | '{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}' +// | '{' annotated_rhs '='? ['!' NAME] !'}' +Py_LOCAL_SYMBOL void * +invalid_fstring_replacement_field_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '{' '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '='")); + Token * _literal; + Token * a; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (a = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '='")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "f-string: valid expression required before '='" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '='")); + } + { // '{' '!' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '!'")); + Token * _literal; + Token * a; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (a = _PyPegen_expect_token(p, 54)) // token='!' + ) + { + D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '!'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "f-string: valid expression required before '!'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '!'")); + } + { // '{' ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' ':'")); + Token * _literal; + Token * a; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (a = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' ':'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "f-string: valid expression required before ':'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' ':'")); + } + { // '{' '}' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '}'")); + Token * _literal; + Token * a; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (a = _PyPegen_expect_token(p, 26)) // token='}' + ) + { + D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '}'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "f-string: valid expression required before '}'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '}'")); + } + { // '{' !annotated_rhs + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' !annotated_rhs")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + _PyPegen_lookahead_for_expr(0, annotated_rhs_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' !annotated_rhs")); + _res = RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting a valid expression after '{'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' !annotated_rhs")); + } + { // '{' annotated_rhs !('=' | '!' | ':' | '}') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs !('=' | '!' | ':' | '}')")); + Token * _literal; + expr_ty annotated_rhs_var; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs + && + _PyPegen_lookahead(0, _tmp_168_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs !('=' | '!' | ':' | '}')")); + _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting '=', or '!', or ':', or '}'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs !('=' | '!' | ':' | '}')")); + } + { // '{' annotated_rhs '=' !('!' | ':' | '}') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '=' !('!' | ':' | '}')")); + Token * _literal; + Token * _literal_1; + expr_ty annotated_rhs_var; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs + && + (_literal_1 = _PyPegen_expect_token(p, 22)) // token='=' + && + _PyPegen_lookahead(0, _tmp_169_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '=' !('!' | ':' | '}')")); + _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting '!', or ':', or '}'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '=' !('!' | ':' | '}')")); + } + { // '{' annotated_rhs '='? invalid_fstring_conversion_character + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? invalid_fstring_conversion_character")); + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty annotated_rhs_var; + void *invalid_fstring_conversion_character_var; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs + && + (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? + && + (invalid_fstring_conversion_character_var = invalid_fstring_conversion_character_rule(p)) // invalid_fstring_conversion_character + ) + { + D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? invalid_fstring_conversion_character")); + _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var, _opt_var, invalid_fstring_conversion_character_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? invalid_fstring_conversion_character")); + } + { // '{' annotated_rhs '='? ['!' NAME] !(':' | '}') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !(':' | '}')")); + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + expr_ty annotated_rhs_var; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs + && + (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? + && + (_opt_var_1 = _tmp_170_rule(p), !p->error_indicator) // ['!' NAME] + && + _PyPegen_lookahead(0, _tmp_171_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !(':' | '}')")); + _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting ':' or '}'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !(':' | '}')")); + } + { // '{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}'")); + Token * _literal; + Token * _literal_1; + asdl_seq * _loop0_172_var; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + expr_ty annotated_rhs_var; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs + && + (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? + && + (_opt_var_1 = _tmp_170_rule(p), !p->error_indicator) // ['!' NAME] + && + (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' + && + (_loop0_172_var = _loop0_172_rule(p)) // fstring_format_spec* + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 26) // token='}' + ) + { + D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}'")); + _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting '}', or format specs" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}'")); + } + { // '{' annotated_rhs '='? ['!' NAME] !'}' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_fstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !'}'")); + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + expr_ty annotated_rhs_var; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs + && + (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? + && + (_opt_var_1 = _tmp_170_rule(p), !p->error_indicator) // ['!' NAME] + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 26) // token='}' + ) + { + D(fprintf(stderr, "%*c+ invalid_fstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !'}'")); + _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting '}'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_fstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !'}'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_fstring_conversion_character: '!' &(':' | '}') | '!' !NAME +static void * +invalid_fstring_conversion_character_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '!' &(':' | '}') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_fstring_conversion_character[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' &(':' | '}')")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 54)) // token='!' + && + _PyPegen_lookahead(1, _tmp_171_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_fstring_conversion_character[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' &(':' | '}')")); + _res = RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: missing conversion character" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_fstring_conversion_character[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!' &(':' | '}')")); + } + { // '!' !NAME + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_fstring_conversion_character[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' !NAME")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 54)) // token='!' + && + _PyPegen_lookahead_for_expr(0, _PyPegen_name_token, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_fstring_conversion_character[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' !NAME")); + _res = RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: invalid conversion character" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_fstring_conversion_character[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!' !NAME")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_tstring_replacement_field: +// | '{' '=' +// | '{' '!' +// | '{' ':' +// | '{' '}' +// | '{' !annotated_rhs +// | '{' annotated_rhs !('=' | '!' | ':' | '}') +// | '{' annotated_rhs '=' !('!' | ':' | '}') +// | '{' annotated_rhs '='? invalid_tstring_conversion_character +// | '{' annotated_rhs '='? ['!' NAME] !(':' | '}') +// | '{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}' +// | '{' annotated_rhs '='? ['!' NAME] !'}' +Py_LOCAL_SYMBOL void * +invalid_tstring_replacement_field_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '{' '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '='")); + Token * _literal; + Token * a; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (a = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '='")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "t-string: valid expression required before '='" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '='")); + } + { // '{' '!' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '!'")); + Token * _literal; + Token * a; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (a = _PyPegen_expect_token(p, 54)) // token='!' + ) + { + D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '!'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "t-string: valid expression required before '!'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '!'")); + } + { // '{' ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' ':'")); + Token * _literal; + Token * a; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (a = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' ':'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "t-string: valid expression required before ':'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' ':'")); + } + { // '{' '}' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '}'")); + Token * _literal; + Token * a; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (a = _PyPegen_expect_token(p, 26)) // token='}' + ) + { + D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '}'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "t-string: valid expression required before '}'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '}'")); + } + { // '{' !annotated_rhs + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' !annotated_rhs")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + _PyPegen_lookahead_for_expr(0, annotated_rhs_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' !annotated_rhs")); + _res = RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: expecting a valid expression after '{'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' !annotated_rhs")); + } + { // '{' annotated_rhs !('=' | '!' | ':' | '}') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs !('=' | '!' | ':' | '}')")); + Token * _literal; + expr_ty annotated_rhs_var; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs + && + _PyPegen_lookahead(0, _tmp_168_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs !('=' | '!' | ':' | '}')")); + _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: expecting '=', or '!', or ':', or '}'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs !('=' | '!' | ':' | '}')")); + } + { // '{' annotated_rhs '=' !('!' | ':' | '}') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '=' !('!' | ':' | '}')")); + Token * _literal; + Token * _literal_1; + expr_ty annotated_rhs_var; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs + && + (_literal_1 = _PyPegen_expect_token(p, 22)) // token='=' + && + _PyPegen_lookahead(0, _tmp_169_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '=' !('!' | ':' | '}')")); + _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: expecting '!', or ':', or '}'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '=' !('!' | ':' | '}')")); + } + { // '{' annotated_rhs '='? invalid_tstring_conversion_character + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? invalid_tstring_conversion_character")); + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty annotated_rhs_var; + void *invalid_tstring_conversion_character_var; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs + && + (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? + && + (invalid_tstring_conversion_character_var = invalid_tstring_conversion_character_rule(p)) // invalid_tstring_conversion_character + ) + { + D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? invalid_tstring_conversion_character")); + _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var, _opt_var, invalid_tstring_conversion_character_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? invalid_tstring_conversion_character")); + } + { // '{' annotated_rhs '='? ['!' NAME] !(':' | '}') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !(':' | '}')")); + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + expr_ty annotated_rhs_var; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs + && + (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? + && + (_opt_var_1 = _tmp_170_rule(p), !p->error_indicator) // ['!' NAME] + && + _PyPegen_lookahead(0, _tmp_171_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !(':' | '}')")); + _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: expecting ':' or '}'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !(':' | '}')")); + } + { // '{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}'")); + Token * _literal; + Token * _literal_1; + asdl_seq * _loop0_172_var; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + expr_ty annotated_rhs_var; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs + && + (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? + && + (_opt_var_1 = _tmp_170_rule(p), !p->error_indicator) // ['!' NAME] + && + (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' + && + (_loop0_172_var = _loop0_172_rule(p)) // fstring_format_spec* + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 26) // token='}' + ) + { + D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}'")); + _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: expecting '}', or format specs" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}'")); + } + { // '{' annotated_rhs '='? ['!' NAME] !'}' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_tstring_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !'}'")); + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + expr_ty annotated_rhs_var; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs + && + (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? + && + (_opt_var_1 = _tmp_170_rule(p), !p->error_indicator) // ['!' NAME] + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 26) // token='}' + ) + { + D(fprintf(stderr, "%*c+ invalid_tstring_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !'}'")); + _res = PyErr_Occurred ( ) ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: expecting '}'" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_tstring_replacement_field[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' annotated_rhs '='? ['!' NAME] !'}'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_tstring_conversion_character: '!' &(':' | '}') | '!' !NAME +static void * +invalid_tstring_conversion_character_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '!' &(':' | '}') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_tstring_conversion_character[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' &(':' | '}')")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 54)) // token='!' + && + _PyPegen_lookahead(1, _tmp_171_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_tstring_conversion_character[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' &(':' | '}')")); + _res = RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: missing conversion character" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_tstring_conversion_character[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!' &(':' | '}')")); + } + { // '!' !NAME + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_tstring_conversion_character[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' !NAME")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 54)) // token='!' + && + _PyPegen_lookahead_for_expr(0, _PyPegen_name_token, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_tstring_conversion_character[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' !NAME")); + _res = RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "t-string: invalid conversion character" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_tstring_conversion_character[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!' !NAME")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_string_tstring_concat: +// | ((fstring | string))+ tstring +// | tstring+ (fstring | string) +Py_LOCAL_SYMBOL void * +invalid_string_tstring_concat_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ((fstring | string))+ tstring + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_string_tstring_concat[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((fstring | string))+ tstring")); + asdl_seq * a; + expr_ty b; + if ( + (a = _loop1_173_rule(p)) // ((fstring | string))+ + && + (b = (expr_ty)tstring_rule(p)) // tstring + ) + { + D(fprintf(stderr, "%*c+ invalid_string_tstring_concat[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((fstring | string))+ tstring")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( PyPegen_last_item ( a , expr_ty ) , b , "cannot mix t-string literals with string or bytes literals" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_string_tstring_concat[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((fstring | string))+ tstring")); + } + { // tstring+ (fstring | string) + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_string_tstring_concat[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tstring+ (fstring | string)")); + asdl_seq * a; + expr_ty b; + if ( + (a = _loop1_174_rule(p)) // tstring+ + && + (b = (expr_ty)_tmp_175_rule(p)) // fstring | string + ) + { + D(fprintf(stderr, "%*c+ invalid_string_tstring_concat[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tstring+ (fstring | string)")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( PyPegen_last_item ( a , expr_ty ) , b , "cannot mix t-string literals with string or bytes literals" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_string_tstring_concat[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tstring+ (fstring | string)")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// Left-recursive +// invalid_arithmetic: sum ('+' | '-' | '*' | '/' | '%' | '//' | '@') 'not' inversion +Py_LOCAL_SYMBOL void * +invalid_arithmetic_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // sum ('+' | '-' | '*' | '/' | '%' | '//' | '@') 'not' inversion + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_arithmetic[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum ('+' | '-' | '*' | '/' | '%' | '//' | '@') 'not' inversion")); + void *_tmp_176_var; + Token * a; + expr_ty b; + expr_ty sum_var; + if ( + (sum_var = sum_rule(p)) // sum + && + (_tmp_176_var = _tmp_176_rule(p)) // '+' | '-' | '*' | '/' | '%' | '//' | '@' + && + (a = _PyPegen_expect_token(p, 531)) // token='not' + && + (b = inversion_rule(p)) // inversion + ) + { + D(fprintf(stderr, "%*c+ invalid_arithmetic[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum ('+' | '-' | '*' | '/' | '%' | '//' | '@') 'not' inversion")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "'not' after an operator must be parenthesized" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_arithmetic[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum ('+' | '-' | '*' | '/' | '%' | '//' | '@') 'not' inversion")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_factor: ('+' | '-' | '~') 'not' factor +Py_LOCAL_SYMBOL void * +invalid_factor_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ('+' | '-' | '~') 'not' factor + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('+' | '-' | '~') 'not' factor")); + void *_tmp_177_var; + Token * a; + expr_ty b; + if ( + (_tmp_177_var = _tmp_177_rule(p)) // '+' | '-' | '~' + && + (a = _PyPegen_expect_token(p, 531)) // token='not' + && + (b = factor_rule(p)) // factor + ) + { + D(fprintf(stderr, "%*c+ invalid_factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('+' | '-' | '~') 'not' factor")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "'not' after an operator must be parenthesized" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_factor[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('+' | '-' | '~') 'not' factor")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_type_params: '[' ']' +Py_LOCAL_SYMBOL void * +invalid_type_params_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '[' ']' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_type_params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' ']'")); + Token * _literal; + Token * token; + if ( + (_literal = _PyPegen_expect_token(p, 9)) // token='[' + && + (token = _PyPegen_expect_token(p, 10)) // token=']' + ) + { + D(fprintf(stderr, "%*c+ invalid_type_params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' ']'")); + _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( token , "Type parameter list cannot be empty" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_type_params[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' ']'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// Left-recursive +// invalid_bitwise_and: bitwise_and '&' '&' +Py_LOCAL_SYMBOL void * +invalid_bitwise_and_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // bitwise_and '&' '&' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' '&'")); + expr_ty a; + Token * b; + Token * c; + if ( + (a = bitwise_and_rule(p)) // bitwise_and + && + (b = _PyPegen_expect_token(p, 19)) // token='&' + && + (c = _PyPegen_expect_token(p, 19)) // token='&' + ) + { + D(fprintf(stderr, "%*c+ invalid_bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' '&'")); + _res = _PyPegen_tokens_are_adjacent ( b , c ) ? RAISE_SYNTAX_ERROR_KNOWN_RANGE ( b , c , "invalid syntax. Maybe you meant 'and' or '&' instead of '&&'?" ) : NULL; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and '&' '&'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// Left-recursive +// invalid_bitwise_or: bitwise_or '|' '|' +Py_LOCAL_SYMBOL void * +invalid_bitwise_or_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // bitwise_or '|' '|' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' '|'")); + expr_ty a; + Token * b; + Token * c; + if ( + (a = bitwise_or_rule(p)) // bitwise_or + && + (b = _PyPegen_expect_token(p, 18)) // token='|' + && + (c = _PyPegen_expect_token(p, 18)) // token='|' + ) + { + D(fprintf(stderr, "%*c+ invalid_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' '|'")); + _res = _PyPegen_tokens_are_adjacent ( b , c ) ? RAISE_SYNTAX_ERROR_KNOWN_RANGE ( b , c , "invalid syntax. Maybe you meant 'or' or '|' instead of '||'?" ) : NULL; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or '|' '|'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// invalid_noteq: '<' '>' +Py_LOCAL_SYMBOL void * +invalid_noteq_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '<' '>' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_noteq[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<' '>'")); + Token * a; + Token * b; + if ( + (a = _PyPegen_expect_token(p, 20)) // token='<' + && + (b = _PyPegen_expect_token(p, 21)) // token='>' + ) + { + D(fprintf(stderr, "%*c+ invalid_noteq[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<' '>'")); + _res = _PyPegen_tokens_are_adjacent ( a , b ) ? RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "invalid syntax. Maybe you meant '!=' instead of '<>'?" ) : NULL; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_noteq[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<' '>'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_106: +// | (','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) +// | kwargs +static void * +_tmp_106_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // (','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs)")); + void *_tmp_189_var; + if ( + (_tmp_189_var = _tmp_189_rule(p)) // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs + ) + { + D(fprintf(stderr, "%*c+ _tmp_106[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs)")); + _res = _tmp_189_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_106[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs)")); + } + { // kwargs + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwargs")); + asdl_seq* kwargs_var; + if ( + (kwargs_var = kwargs_rule(p)) // kwargs + ) + { + D(fprintf(stderr, "%*c+ _tmp_106[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwargs")); + _res = kwargs_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_106[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwargs")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop0_107: ',' (starred_expression !'=') +static asdl_seq * +_loop0_107_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' (starred_expression !'=') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (starred_expression !'=')")); + Token * _literal; + void *elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = _tmp_190_rule(p)) // starred_expression !'=' + ) + { + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_107[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (starred_expression !'=')")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _gather_108: (starred_expression !'=') _loop0_107 +static asdl_seq * +_gather_108_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // (starred_expression !'=') _loop0_107 + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _gather_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression !'=') _loop0_107")); + void *elem; + asdl_seq * seq; + if ( + (elem = _tmp_190_rule(p)) // starred_expression !'=' + && + (seq = _loop0_107_rule(p)) // _loop0_107 + ) + { + D(fprintf(stderr, "%*c+ _gather_108[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression !'=') _loop0_107")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_108[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression !'=') _loop0_107")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_109: args | expression for_if_clauses +static void * +_tmp_109_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // args + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); + expr_ty args_var; + if ( + (args_var = args_rule(p)) // args + ) + { + D(fprintf(stderr, "%*c+ _tmp_109[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); + _res = args_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_109[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); + } + { // expression for_if_clauses + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + expr_ty expression_var; + asdl_comprehension_seq* for_if_clauses_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + D(fprintf(stderr, "%*c+ _tmp_109[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_109[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_110: args ',' +static void * +_tmp_110_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // args ',' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ','")); + Token * _literal; + expr_ty args_var; + if ( + (args_var = args_rule(p)) // args + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_110[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ','")); + _res = _PyPegen_dummy_name(p, args_var, _literal); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_110[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ','")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_111: ',' | ')' +static void * +_tmp_111_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ',' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_111[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + } + { // ')' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ _tmp_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_111[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_112: NAME '=' +static void * +_tmp_112_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // NAME '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '='")); + Token * _literal; + expr_ty name_var; + if ( + (name_var = _PyPegen_name_token(p)) // NAME + && + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ _tmp_112[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '='")); + _res = _PyPegen_dummy_name(p, name_var, _literal); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_112[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '='")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop1_113: (!STRING expression_without_invalid) +static asdl_seq * +_loop1_113_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // (!STRING expression_without_invalid) + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop1_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(!STRING expression_without_invalid)")); + void *_tmp_191_var; + while ( + (_tmp_191_var = _tmp_191_rule(p)) // !STRING expression_without_invalid + ) + { + _res = _tmp_191_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop1_113[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(!STRING expression_without_invalid)")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _tmp_114: NAME STRING | SOFT_KEYWORD +static void * +_tmp_114_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // NAME STRING + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME STRING")); + expr_ty name_var; + expr_ty string_var; + if ( + (name_var = _PyPegen_name_token(p)) // NAME + && + (string_var = _PyPegen_string_token(p)) // STRING + ) + { + D(fprintf(stderr, "%*c+ _tmp_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME STRING")); + _res = _PyPegen_dummy_name(p, name_var, string_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_114[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME STRING")); + } + { // SOFT_KEYWORD + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "SOFT_KEYWORD")); + expr_ty soft_keyword_var; + if ( + (soft_keyword_var = _PyPegen_soft_keyword_token(p)) // SOFT_KEYWORD + ) + { + D(fprintf(stderr, "%*c+ _tmp_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "SOFT_KEYWORD")); + _res = soft_keyword_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_114[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "SOFT_KEYWORD")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_115: 'else' | ':' +static void * +_tmp_115_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'else' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else'")); + Token * _keyword; + if ( + (_keyword = _PyPegen_expect_token(p, 522)) // token='else' + ) + { + D(fprintf(stderr, "%*c+ _tmp_115[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else'")); + _res = _keyword; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_115[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'else'")); + } + { // ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ _tmp_115[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_115[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_116: pass_stmt | break_stmt | continue_stmt +static void * +_tmp_116_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // pass_stmt + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pass_stmt")); + stmt_ty pass_stmt_var; + if ( + (pass_stmt_var = pass_stmt_rule(p)) // pass_stmt + ) + { + D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pass_stmt")); + _res = pass_stmt_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pass_stmt")); + } + { // break_stmt + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "break_stmt")); + stmt_ty break_stmt_var; + if ( + (break_stmt_var = break_stmt_rule(p)) // break_stmt + ) + { + D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "break_stmt")); + _res = break_stmt_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "break_stmt")); + } + { // continue_stmt + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "continue_stmt")); + stmt_ty continue_stmt_var; + if ( + (continue_stmt_var = continue_stmt_rule(p)) // continue_stmt + ) + { + D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "continue_stmt")); + _res = continue_stmt_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "continue_stmt")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_117: '=' | ':=' +static void * +_tmp_117_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); + } + { // ':=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':='")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 53)) // token=':=' + ) + { + D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':='")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':='")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_118: list | tuple | genexp | 'True' | 'None' | 'False' +static void * +_tmp_118_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // list + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); + expr_ty list_var; + if ( + (list_var = list_rule(p)) // list + ) + { + D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + _res = list_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); + } + { // tuple + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); + expr_ty tuple_var; + if ( + (tuple_var = tuple_rule(p)) // tuple + ) + { + D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + _res = tuple_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); + } + { // genexp + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); + expr_ty genexp_var; + if ( + (genexp_var = genexp_rule(p)) // genexp + ) + { + D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); + _res = genexp_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); + } + { // 'True' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); + Token * _keyword; + if ( + (_keyword = _PyPegen_expect_token(p, 527)) // token='True' + ) + { + D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); + _res = _keyword; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); + } + { // 'None' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); + Token * _keyword; + if ( + (_keyword = _PyPegen_expect_token(p, 526)) // token='None' + ) + { + D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); + _res = _keyword; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); + } + { // 'False' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); + Token * _keyword; + if ( + (_keyword = _PyPegen_expect_token(p, 528)) // token='False' + ) + { + D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); + _res = _keyword; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop0_119: star_named_expressions +static asdl_seq * +_loop0_119_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // star_named_expressions + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); + asdl_expr_seq* star_named_expressions_var; + while ( + (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions + ) + { + _res = star_named_expressions_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_119[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop0_120: (star_targets '=') +static asdl_seq * +_loop0_120_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // (star_targets '=') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); + void *_tmp_192_var; + while ( + (_tmp_192_var = _tmp_192_rule(p)) // star_targets '=' + ) + { + _res = _tmp_192_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_120[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _tmp_121: '[' | '{' +static void * +_tmp_121_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '[' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 9)) // token='[' + ) + { + D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); + } + { // '{' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + ) + { + D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_122: slash_no_default | slash_with_default +static void * +_tmp_122_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // slash_no_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default")); + asdl_arg_seq* slash_no_default_var; + if ( + (slash_no_default_var = slash_no_default_rule(p)) // slash_no_default + ) + { + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default")); + _res = slash_no_default_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default")); + } + { // slash_with_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + SlashWithDefault* slash_with_default_var; + if ( + (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default + ) + { + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + _res = slash_with_default_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop0_123: param_maybe_default +static asdl_seq * +_loop0_123_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // param_maybe_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + NameDefaultPair* param_maybe_default_var; + while ( + (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default + ) + { + _res = param_maybe_default_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_123[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop0_124: param_no_default +static asdl_seq * +_loop0_124_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // param_no_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + arg_ty param_no_default_var; + while ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + _res = param_no_default_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_124[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop1_125: param_no_default +static asdl_seq * +_loop1_125_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // param_no_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop1_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + arg_ty param_no_default_var; + while ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + _res = param_no_default_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop1_125[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _tmp_126: ',' | param_no_default +static void * +_tmp_126_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ',' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + } + { // param_no_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + arg_ty param_no_default_var; + if ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); + _res = param_no_default_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop1_127: param_maybe_default +static asdl_seq * +_loop1_127_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // param_maybe_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop1_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + NameDefaultPair* param_maybe_default_var; + while ( + (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default + ) + { + _res = param_maybe_default_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop1_127[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _tmp_128: ')' | ',' +static void * +_tmp_128_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ')' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ _tmp_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_128[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); + } + { // ',' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_128[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_129: ')' | ',' (')' | '**') +static void * +_tmp_129_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ')' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ _tmp_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_129[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); + } + { // ',' (')' | '**') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + Token * _literal; + void *_tmp_193_var; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (_tmp_193_var = _tmp_193_rule(p)) // ')' | '**' + ) + { + D(fprintf(stderr, "%*c+ _tmp_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_193_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_129[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_130: param_no_default | ',' +static void * +_tmp_130_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // param_no_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + arg_ty param_no_default_var; + if ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); + _res = param_no_default_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); + } + { // ',' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_131: '*' | '**' | '/' +static void * +_tmp_131_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '*' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + ) + { + D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); + } + { // '**' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + ) + { + D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); + } + { // '/' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 17)) // token='/' + ) + { + D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'/'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop1_132: param_with_default +static asdl_seq * +_loop1_132_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // param_with_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop1_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + NameDefaultPair* param_with_default_var; + while ( + (param_with_default_var = param_with_default_rule(p)) // param_with_default + ) + { + _res = param_with_default_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop1_132[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _tmp_133: lambda_slash_no_default | lambda_slash_with_default +static void * +_tmp_133_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // lambda_slash_no_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); + asdl_arg_seq* lambda_slash_no_default_var; + if ( + (lambda_slash_no_default_var = lambda_slash_no_default_rule(p)) // lambda_slash_no_default + ) + { + D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); + _res = lambda_slash_no_default_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_no_default")); + } + { // lambda_slash_with_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); + SlashWithDefault* lambda_slash_with_default_var; + if ( + (lambda_slash_with_default_var = lambda_slash_with_default_rule(p)) // lambda_slash_with_default + ) + { + D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); + _res = lambda_slash_with_default_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop0_134: lambda_param_maybe_default +static asdl_seq * +_loop0_134_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // lambda_param_maybe_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + NameDefaultPair* lambda_param_maybe_default_var; + while ( + (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default + ) + { + _res = lambda_param_maybe_default_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_134[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop0_135: lambda_param_no_default +static asdl_seq * +_loop0_135_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // lambda_param_no_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + arg_ty lambda_param_no_default_var; + while ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + _res = lambda_param_no_default_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_135[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop0_136: ',' lambda_param +static asdl_seq * +_loop0_136_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' lambda_param + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' lambda_param")); + Token * _literal; + arg_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = lambda_param_rule(p)) // lambda_param + ) + { + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_136[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' lambda_param")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _gather_137: lambda_param _loop0_136 +static asdl_seq * +_gather_137_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // lambda_param _loop0_136 + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _gather_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_136")); + arg_ty elem; + asdl_seq * seq; + if ( + (elem = lambda_param_rule(p)) // lambda_param + && + (seq = _loop0_136_rule(p)) // _loop0_136 + ) + { + D(fprintf(stderr, "%*c+ _gather_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_136")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_137[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param _loop0_136")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_138: ',' | lambda_param_no_default +static void * +_tmp_138_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ',' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_138[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + } + { // lambda_param_no_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + arg_ty lambda_param_no_default_var; + if ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + D(fprintf(stderr, "%*c+ _tmp_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + _res = lambda_param_no_default_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_138[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop1_139: lambda_param_maybe_default +static asdl_seq * +_loop1_139_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // lambda_param_maybe_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop1_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + NameDefaultPair* lambda_param_maybe_default_var; + while ( + (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default + ) + { + _res = lambda_param_maybe_default_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop1_139[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop1_140: lambda_param_with_default +static asdl_seq * +_loop1_140_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // lambda_param_with_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop1_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + NameDefaultPair* lambda_param_with_default_var; + while ( + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default + ) + { + _res = lambda_param_with_default_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop1_140[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _tmp_141: ':' | ',' (':' | '**') +static void * +_tmp_141_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ _tmp_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_141[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); + } + { // ',' (':' | '**') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + Token * _literal; + void *_tmp_194_var; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (_tmp_194_var = _tmp_194_rule(p)) // ':' | '**' + ) + { + D(fprintf(stderr, "%*c+ _tmp_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_194_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_141[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_142: lambda_param_no_default | ',' +static void * +_tmp_142_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // lambda_param_no_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + arg_ty lambda_param_no_default_var; + if ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + D(fprintf(stderr, "%*c+ _tmp_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + _res = lambda_param_no_default_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_142[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); + } + { // ',' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_142[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_143: ',' | ')' | ':' +static void * +_tmp_143_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ',' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + } + { // ')' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); + } + { // ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_144: bitwise_or ((',' bitwise_or))* ','? +static void * +_tmp_144_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // bitwise_or ((',' bitwise_or))* ','? + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or ((',' bitwise_or))* ','?")); + asdl_seq * _loop0_195_var; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty bitwise_or_var; + if ( + (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + && + (_loop0_195_var = _loop0_195_rule(p)) // ((',' bitwise_or))* + && + (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? + ) + { + D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or ((',' bitwise_or))* ','?")); + _res = _PyPegen_dummy_name(p, bitwise_or_var, _loop0_195_var, _opt_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or ((',' bitwise_or))* ','?")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop0_145: ',' dotted_name +static asdl_seq * +_loop0_145_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' dotted_name + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' dotted_name")); + Token * _literal; + expr_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = dotted_name_rule(p)) // dotted_name + ) + { + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_145[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' dotted_name")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _gather_146: dotted_name _loop0_145 +static asdl_seq * +_gather_146_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // dotted_name _loop0_145 + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _gather_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_name _loop0_145")); + expr_ty elem; + asdl_seq * seq; + if ( + (elem = dotted_name_rule(p)) // dotted_name + && + (seq = _loop0_145_rule(p)) // _loop0_145 + ) + { + D(fprintf(stderr, "%*c+ _gather_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_name _loop0_145")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_146[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_name _loop0_145")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_147: NAME (',' | ')' | ';' | NEWLINE) +static void * +_tmp_147_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // NAME (',' | ')' | ';' | NEWLINE) + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME (',' | ')' | ';' | NEWLINE)")); + void *_tmp_196_var; + expr_ty name_var; + if ( + (name_var = _PyPegen_name_token(p)) // NAME + && + (_tmp_196_var = _tmp_196_rule(p)) // ',' | ')' | ';' | NEWLINE + ) + { + D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME (',' | ')' | ';' | NEWLINE)")); + _res = _PyPegen_dummy_name(p, name_var, _tmp_196_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME (',' | ')' | ';' | NEWLINE)")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop0_148: ('.' | '...') +static asdl_seq * +_loop0_148_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ('.' | '...') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); + void *_tmp_197_var; + while ( + (_tmp_197_var = _tmp_197_rule(p)) // '.' | '...' + ) + { + _res = _tmp_197_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_148[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop0_149: ',' (expression ['as' star_target]) +static asdl_seq * +_loop0_149_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' (expression ['as' star_target]) + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expression ['as' star_target])")); + Token * _literal; + void *elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = _tmp_198_rule(p)) // expression ['as' star_target] + ) + { + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_149[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expression ['as' star_target])")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _gather_150: (expression ['as' star_target]) _loop0_149 +static asdl_seq * +_gather_150_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // (expression ['as' star_target]) _loop0_149 + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _gather_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_149")); + void *elem; + asdl_seq * seq; + if ( + (elem = _tmp_198_rule(p)) // expression ['as' star_target] + && + (seq = _loop0_149_rule(p)) // _loop0_149 + ) + { + D(fprintf(stderr, "%*c+ _gather_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_149")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_150[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expression ['as' star_target]) _loop0_149")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop0_151: ',' (expressions ['as' star_target]) +static asdl_seq * +_loop0_151_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' (expressions ['as' star_target]) + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expressions ['as' star_target])")); + Token * _literal; + void *elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = _tmp_199_rule(p)) // expressions ['as' star_target] + ) + { + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_151[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expressions ['as' star_target])")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _gather_152: (expressions ['as' star_target]) _loop0_151 +static asdl_seq * +_gather_152_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // (expressions ['as' star_target]) _loop0_151 + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _gather_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_151")); + void *elem; + asdl_seq * seq; + if ( + (elem = _tmp_199_rule(p)) // expressions ['as' star_target] + && + (seq = _loop0_151_rule(p)) // _loop0_151 + ) + { + D(fprintf(stderr, "%*c+ _gather_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_151")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_152[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expressions ['as' star_target]) _loop0_151")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_153: 'except' | 'finally' +static void * +_tmp_153_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'except' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except'")); + Token * _keyword; + if ( + (_keyword = _PyPegen_expect_token(p, 524)) // token='except' + ) + { + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except'")); + _res = _keyword; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except'")); + } + { // 'finally' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'finally'")); + Token * _keyword; + if ( + (_keyword = _PyPegen_expect_token(p, 525)) // token='finally' + ) + { + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'finally'")); + _res = _keyword; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'finally'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop0_154: block +static asdl_seq * +_loop0_154_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // block + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "block")); + asdl_stmt_seq* block_var; + while ( + (block_var = block_rule(p)) // block + ) + { + _res = block_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_154[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "block")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop1_155: except_block +static asdl_seq * +_loop1_155_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // except_block + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop1_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block")); + excepthandler_ty except_block_var; + while ( + (except_block_var = except_block_rule(p)) // except_block + ) + { + _res = except_block_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop1_155[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_block")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _tmp_156: 'as' NAME +static void * +_tmp_156_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'as' NAME + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + Token * _keyword; + expr_ty name_var; + if ( + (_keyword = _PyPegen_expect_token(p, 520)) // token='as' + && + (name_var = _PyPegen_name_token(p)) // NAME + ) + { + D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + _res = _PyPegen_dummy_name(p, _keyword, name_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop1_157: except_star_block +static asdl_seq * +_loop1_157_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // except_star_block + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop1_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_star_block")); + excepthandler_ty except_star_block_var; + while ( + (except_star_block_var = except_star_block_rule(p)) // except_star_block + ) + { + _res = except_star_block_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop1_157[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_star_block")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _tmp_158: expression ['as' NAME] +static void * +_tmp_158_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // expression ['as' NAME] + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' NAME]")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (_opt_var = _tmp_156_rule(p), !p->error_indicator) // ['as' NAME] + ) + { + D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' NAME]")); + _res = _PyPegen_dummy_name(p, expression_var, _opt_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' NAME]")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_159: NEWLINE | ':' +static void * +_tmp_159_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + Token * newline_var; + if ( + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + _res = newline_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); + } + { // ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_160: items_pattern ',' +static void * +_tmp_160_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // items_pattern ',' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "items_pattern ','")); + Token * _literal; + asdl_seq* items_pattern_var; + if ( + (items_pattern_var = items_pattern_rule(p)) // items_pattern + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "items_pattern ','")); + _res = _PyPegen_dummy_name(p, items_pattern_var, _literal); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "items_pattern ','")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_161: positional_patterns ',' +static void * +_tmp_161_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // positional_patterns ',' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "positional_patterns ','")); + Token * _literal; + asdl_pattern_seq* positional_patterns_var; + if ( + (positional_patterns_var = positional_patterns_rule(p)) // positional_patterns + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "positional_patterns ','")); + _res = _PyPegen_dummy_name(p, positional_patterns_var, _literal); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "positional_patterns ','")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_162: '->' expression +static void * +_tmp_162_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '->' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + Token * _literal; + expr_ty expression_var; + if ( + (_literal = _PyPegen_expect_token(p, 51)) // token='->' + && + (expression_var = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + _res = _PyPegen_dummy_name(p, _literal, expression_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_163: '(' arguments? ')' +static void * +_tmp_163_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '(' arguments? ')' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + Token * _literal; + Token * _literal_1; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (_opt_var = arguments_rule(p), !p->error_indicator) // arguments? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + _res = _PyPegen_dummy_name(p, _literal, _opt_var, _literal_1); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop0_164: ',' double_starred_kvpair +static asdl_seq * +_loop0_164_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' double_starred_kvpair + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); + Token * _literal; + KeyValuePair* elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair + ) + { + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_164[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _gather_165: double_starred_kvpair _loop0_164 +static asdl_seq * +_gather_165_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // double_starred_kvpair _loop0_164 + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _gather_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_164")); + KeyValuePair* elem; + asdl_seq * seq; + if ( + (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair + && + (seq = _loop0_164_rule(p)) // _loop0_164 + ) + { + D(fprintf(stderr, "%*c+ _gather_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_164")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_165[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_164")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_166: invalid_kvpair | invalid_kvpair_unpacking +static void * +_tmp_166_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + if (p->call_invalid_rules) { // invalid_kvpair + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kvpair")); + void *invalid_kvpair_var; + if ( + (invalid_kvpair_var = invalid_kvpair_rule(p)) // invalid_kvpair + ) + { + D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kvpair")); + _res = invalid_kvpair_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kvpair")); + } + if (p->call_invalid_rules) { // invalid_kvpair_unpacking + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kvpair_unpacking")); + void *invalid_kvpair_unpacking_var; + if ( + (invalid_kvpair_unpacking_var = invalid_kvpair_unpacking_rule(p)) // invalid_kvpair_unpacking + ) + { + D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kvpair_unpacking")); + _res = invalid_kvpair_unpacking_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kvpair_unpacking")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_167: '}' | ',' +static void * +_tmp_167_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '}' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 26)) // token='}' + ) + { + D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_167[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); + } + { // ',' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_167[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_168: '=' | '!' | ':' | '}' +static void * +_tmp_168_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); + } + { // '!' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 54)) // token='!' + ) + { + D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!'")); + } + { // ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); + } + { // '}' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 26)) // token='}' + ) + { + D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_169: '!' | ':' | '}' +static void * +_tmp_169_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '!' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 54)) // token='!' + ) + { + D(fprintf(stderr, "%*c+ _tmp_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_169[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!'")); + } + { // ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ _tmp_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_169[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); + } + { // '}' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 26)) // token='}' + ) + { + D(fprintf(stderr, "%*c+ _tmp_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_169[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_170: '!' NAME +static void * +_tmp_170_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '!' NAME + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' NAME")); + Token * _literal; + expr_ty name_var; + if ( + (_literal = _PyPegen_expect_token(p, 54)) // token='!' + && + (name_var = _PyPegen_name_token(p)) // NAME + ) + { + D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' NAME")); + _res = _PyPegen_dummy_name(p, _literal, name_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_170[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!' NAME")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_171: ':' | '}' +static void * +_tmp_171_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_171[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); + } + { // '}' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 26)) // token='}' + ) + { + D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_171[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop0_172: fstring_format_spec +static asdl_seq * +_loop0_172_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // fstring_format_spec + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring_format_spec")); + expr_ty fstring_format_spec_var; + while ( + (fstring_format_spec_var = fstring_format_spec_rule(p)) // fstring_format_spec + ) + { + _res = fstring_format_spec_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_172[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "fstring_format_spec")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop1_173: (fstring | string) +static asdl_seq * +_loop1_173_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // (fstring | string) + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop1_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(fstring | string)")); + void *_tmp_175_var; + while ( + (_tmp_175_var = _tmp_175_rule(p)) // fstring | string + ) + { + _res = _tmp_175_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop1_173[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(fstring | string)")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop1_174: tstring +static asdl_seq * +_loop1_174_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // tstring + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop1_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tstring")); + expr_ty tstring_var; + while ( + (tstring_var = tstring_rule(p)) // tstring + ) + { + _res = tstring_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop1_174[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tstring")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _tmp_175: fstring | string +static void * +_tmp_175_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // fstring + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring")); + expr_ty fstring_var; + if ( + (fstring_var = fstring_rule(p)) // fstring + ) + { + D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "fstring")); + _res = fstring_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "fstring")); + } + { // string + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "string")); + expr_ty string_var; + if ( + (string_var = string_rule(p)) // string + ) + { + D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "string")); + _res = string_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "string")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_176: '+' | '-' | '*' | '/' | '%' | '//' | '@' +static void * +_tmp_176_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '+' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 14)) // token='+' + ) + { + D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+'")); + } + { // '-' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 15)) // token='-' + ) + { + D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-'")); + } + { // '*' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + ) + { + D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); + } + { // '/' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 17)) // token='/' + ) + { + D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'/'")); + } + { // '%' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'%'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 24)) // token='%' + ) + { + D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'%'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'%'")); + } + { // '//' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'//'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 47)) // token='//' + ) + { + D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'//'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'//'")); + } + { // '@' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 49)) // token='@' + ) + { + D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_177: '+' | '-' | '~' +static void * +_tmp_177_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '+' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 14)) // token='+' + ) + { + D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_177[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+'")); + } + { // '-' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 15)) // token='-' + ) + { + D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_177[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-'")); + } + { // '~' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'~'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 31)) // token='~' + ) + { + D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'~'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_177[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'~'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_189: +// | ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs +static void * +_tmp_189_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_189[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs")); + asdl_seq * _gather_202_var; + Token * _literal; + asdl_seq* kwargs_var; + if ( + (_gather_202_var = _gather_202_rule(p)) // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (kwargs_var = kwargs_rule(p)) // kwargs + ) + { + D(fprintf(stderr, "%*c+ _tmp_189[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs")); + _res = _PyPegen_dummy_name(p, _gather_202_var, _literal, kwargs_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_189[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_190: starred_expression !'=' +static void * +_tmp_190_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // starred_expression !'=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_190[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression !'='")); + expr_ty starred_expression_var; + if ( + (starred_expression_var = starred_expression_rule(p)) // starred_expression + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' + ) + { + D(fprintf(stderr, "%*c+ _tmp_190[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression !'='")); + _res = starred_expression_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_190[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression !'='")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_191: !STRING expression_without_invalid +static void * +_tmp_191_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // !STRING expression_without_invalid + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_191[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!STRING expression_without_invalid")); + expr_ty expression_without_invalid_var; + if ( + _PyPegen_lookahead(0, _PyPegen_string_token, p) + && + (expression_without_invalid_var = expression_without_invalid_rule(p)) // expression_without_invalid + ) + { + D(fprintf(stderr, "%*c+ _tmp_191[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!STRING expression_without_invalid")); + _res = expression_without_invalid_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_191[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!STRING expression_without_invalid")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_192: star_targets '=' +static void * +_tmp_192_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // star_targets '=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_192[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + Token * _literal; + expr_ty star_targets_var; + if ( + (star_targets_var = star_targets_rule(p)) // star_targets + && + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ _tmp_192[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + _res = _PyPegen_dummy_name(p, star_targets_var, _literal); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_192[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_193: ')' | '**' +static void * +_tmp_193_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ')' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_193[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ _tmp_193[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_193[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); + } + { // '**' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_193[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + ) + { + D(fprintf(stderr, "%*c+ _tmp_193[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_193[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_194: ':' | '**' +static void * +_tmp_194_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ':' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_194[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ _tmp_194[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_194[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); + } + { // '**' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_194[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + ) + { + D(fprintf(stderr, "%*c+ _tmp_194[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_194[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop0_195: (',' bitwise_or) +static asdl_seq * +_loop0_195_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // (',' bitwise_or) + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_195[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' bitwise_or)")); + void *_tmp_203_var; + while ( + (_tmp_203_var = _tmp_203_rule(p)) // ',' bitwise_or + ) + { + _res = _tmp_203_var; + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_195[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' bitwise_or)")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _tmp_196: ',' | ')' | ';' | NEWLINE +static void * +_tmp_196_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ',' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_196[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_196[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_196[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + } + { // ')' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_196[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ _tmp_196[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_196[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); + } + { // ';' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_196[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 13)) // token=';' + ) + { + D(fprintf(stderr, "%*c+ _tmp_196[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_196[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'")); + } + { // NEWLINE + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_196[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + Token * newline_var; + if ( + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ _tmp_196[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + _res = newline_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_196[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_197: '.' | '...' +static void * +_tmp_197_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '.' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_197[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 23)) // token='.' + ) + { + D(fprintf(stderr, "%*c+ _tmp_197[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_197[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); + } + { // '...' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_197[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 52)) // token='...' + ) + { + D(fprintf(stderr, "%*c+ _tmp_197[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_197[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_198: expression ['as' star_target] +static void * +_tmp_198_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // expression ['as' star_target] + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_198[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (_opt_var = _tmp_204_rule(p), !p->error_indicator) // ['as' star_target] + ) + { + D(fprintf(stderr, "%*c+ _tmp_198[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); + _res = _PyPegen_dummy_name(p, expression_var, _opt_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_198[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' star_target]")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_199: expressions ['as' star_target] +static void * +_tmp_199_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // expressions ['as' star_target] + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_199[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty expressions_var; + if ( + (expressions_var = expressions_rule(p)) // expressions + && + (_opt_var = _tmp_204_rule(p), !p->error_indicator) // ['as' star_target] + ) + { + D(fprintf(stderr, "%*c+ _tmp_199[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); + _res = _PyPegen_dummy_name(p, expressions_var, _opt_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_199[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expressions ['as' star_target]")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop0_201: ',' (starred_expression | (assignment_expression | expression !':=') !'=') +static asdl_seq * +_loop0_201_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = NULL; + Py_ssize_t _children_capacity = 0; + Py_ssize_t _n = 0; + { // ',' (starred_expression | (assignment_expression | expression !':=') !'=') + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_201[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (starred_expression | (assignment_expression | expression !':=') !'=')")); + Token * _literal; + void *elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = _tmp_205_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' + ) + { + _res = elem; + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + if (_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_201[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (starred_expression | (assignment_expression | expression !':=') !'=')")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + p->error_indicator = 1; + PyErr_NoMemory(); + PyMem_Free(_children); + p->level--; + return NULL; + } + for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _gather_202: +// | (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_201 +static asdl_seq * +_gather_202_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_201 + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _gather_202[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_201")); + void *elem; + asdl_seq * seq; + if ( + (elem = _tmp_205_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' + && + (seq = _loop0_201_rule(p)) // _loop0_201 + ) + { + D(fprintf(stderr, "%*c+ _gather_202[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_201")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_202[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_201")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_203: ',' bitwise_or +static void * +_tmp_203_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ',' bitwise_or + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_203[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' bitwise_or")); + Token * _literal; + expr_ty bitwise_or_var; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + ) + { + D(fprintf(stderr, "%*c+ _tmp_203[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' bitwise_or")); + _res = _PyPegen_dummy_name(p, _literal, bitwise_or_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_203[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' bitwise_or")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_204: 'as' star_target +static void * +_tmp_204_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'as' star_target + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_204[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + Token * _keyword; + expr_ty star_target_var; + if ( + (_keyword = _PyPegen_expect_token(p, 520)) // token='as' + && + (star_target_var = star_target_rule(p)) // star_target + ) + { + D(fprintf(stderr, "%*c+ _tmp_204[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + _res = _PyPegen_dummy_name(p, _keyword, star_target_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_204[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' star_target")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_205: starred_expression | (assignment_expression | expression !':=') !'=' +static void * +_tmp_205_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // starred_expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_205[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); + expr_ty starred_expression_var; + if ( + (starred_expression_var = starred_expression_rule(p)) // starred_expression + ) + { + D(fprintf(stderr, "%*c+ _tmp_205[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); + _res = starred_expression_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_205[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); + } + { // (assignment_expression | expression !':=') !'=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_205[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); + void *_tmp_206_var; + if ( + (_tmp_206_var = _tmp_206_rule(p)) // assignment_expression | expression !':=' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' + ) + { + D(fprintf(stderr, "%*c+ _tmp_205[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); + _res = _tmp_206_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_205[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(assignment_expression | expression !':=') !'='")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _tmp_206: assignment_expression | expression !':=' +static void * +_tmp_206_rule(Parser *p) +{ + if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) { + _Pypegen_stack_overflow(p); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // assignment_expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_206[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment_expression")); + expr_ty assignment_expression_var; + if ( + (assignment_expression_var = assignment_expression_rule(p)) // assignment_expression + ) + { + D(fprintf(stderr, "%*c+ _tmp_206[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment_expression")); + _res = assignment_expression_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_206[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment_expression")); + } + { // expression !':=' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_206[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); + expr_ty expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' + ) + { + D(fprintf(stderr, "%*c+ _tmp_206[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); + _res = expression_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_206[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='")); + } + _res = NULL; + done: + p->level--; + return _res; +} diff --git a/Parser/peg_api.c b/Parser/peg_api.c index e30ca0453bd3e13..6791478ba688a68 100644 --- a/Parser/peg_api.c +++ b/Parser/peg_api.c @@ -5,14 +5,14 @@ mod_ty _PyParser_ASTFromString(const char *str, PyObject* filename, int mode, PyCompilerFlags *flags, PyArena *arena, - PyObject *module) + PyObject *module, PyObject **incomplete) { if (PySys_Audit("compile", "yO", str, filename) < 0) { return NULL; } mod_ty result = _PyPegen_run_parser_from_string(str, mode, filename, flags, - arena, module); + arena, module, incomplete); return result; } @@ -39,4 +39,4 @@ _PyParser_InteractiveASTFromFile(FILE *fp, PyObject *filename_ob, const char *en } return _PyPegen_run_parser_from_file_pointer(fp, mode, filename_ob, enc, ps1, ps2, flags, errcode, interactive_src, arena); -} \ No newline at end of file +} diff --git a/Parser/pegen.c b/Parser/pegen.c index 165dcb9f9950955..edc54c1618d018a 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -7,11 +7,22 @@ #include "pycore_unicodeobject.h" // _PyUnicode_InternImmortal #include -#include "lexer/lexer.h" +#include "lexer/state.h" #include "tokenizer/tokenizer.h" -#include "tokenizer/helpers.h" #include "pegen.h" +#define IDENTIFIER_CACHE_SIZE 2048 // Must be a power of two. +#define IDENTIFIER_CACHE_MAX_PROBES 8 +#define PEGEN_ARRAY_GROWTH_FACTOR 2 +#define TYPE_IGNORE_INITIAL_CAPACITY 10 + +struct _identifier_cache_entry { + const char *key; // Borrowed from arena-owned token bytes. + Py_ssize_t len; + Py_hash_t hash; + PyObject *value; // Borrowed from an arena-owned identifier. +}; + // Internal parser functions asdl_stmt_seq* @@ -27,6 +38,9 @@ Py_ssize_t _PyPegen_byte_offset_to_character_offset_line(PyObject *line, Py_ssize_t col_offset, Py_ssize_t end_col_offset) { const unsigned char *data = (const unsigned char*)PyUnicode_AsUTF8(line); + if (data == NULL) { + return -1; + } Py_ssize_t len = 0; while (col_offset < end_col_offset) { @@ -90,9 +104,21 @@ _PyPegen_insert_memo(Parser *p, int mark, int type, void *node) m->mark = p->mark; m->next = p->tokens[mark]->memo; p->tokens[mark]->memo = m; + p->tokens[mark]->memo_mask |= 1ULL << (type & 63); return 0; } +// Like _PyPegen_insert_memo(), but returns the inserted Memo so callers +// can update it in place without re-walking the token's memo list. +Memo * +_PyPegen_insert_memo_direct(Parser *p, int mark, int type) +{ + if (_PyPegen_insert_memo(p, mark, type, NULL) < 0) { + return NULL; + } + return p->tokens[mark]->memo; +} + // Like _PyPegen_insert_memo(), but updates an existing node if found. int _PyPegen_update_memo(Parser *p, int mark, int type, void *node) @@ -123,21 +149,37 @@ init_normalization(Parser *p) return 1; } -static int -growable_comment_array_init(growable_comment_array *arr, size_t initial_size) { - assert(initial_size > 0); - arr->items = PyMem_Malloc(initial_size * sizeof(*arr->items)); - arr->size = initial_size; - arr->num_items = 0; - - return arr->items != NULL; +int +_PyPegen_grow_loop_buffer(void ***buffer, Py_ssize_t *capacity) +{ + if ((size_t)*capacity > (size_t)PY_SSIZE_T_MAX / + (PEGEN_ARRAY_GROWTH_FACTOR * sizeof(**buffer))) { + return -1; + } + Py_ssize_t new_capacity = *capacity == 0 + ? 1 : *capacity * PEGEN_ARRAY_GROWTH_FACTOR; + void **new_buffer = PyMem_Realloc(*buffer, new_capacity * sizeof(**buffer)); + if (new_buffer == NULL) { + return -1; + } + *buffer = new_buffer; + *capacity = new_capacity; + return 0; } static int -growable_comment_array_add(growable_comment_array *arr, int lineno, char *comment) { +growable_comment_array_add(growable_comment_array *arr, int lineno, char *comment) +{ if (arr->num_items >= arr->size) { - size_t new_size = arr->size * 2; - void *new_items_array = PyMem_Realloc(arr->items, new_size * sizeof(*arr->items)); + if (arr->size > (size_t)PY_SSIZE_T_MAX / + (PEGEN_ARRAY_GROWTH_FACTOR * sizeof(*arr->items))) { + return 0; + } + size_t new_size = arr->size == 0 + ? TYPE_IGNORE_INITIAL_CAPACITY + : arr->size * PEGEN_ARRAY_GROWTH_FACTOR; + void *new_items_array = PyMem_Realloc( + arr->items, new_size * sizeof(*arr->items)); if (!new_items_array) { return 0; } @@ -152,50 +194,83 @@ growable_comment_array_add(growable_comment_array *arr, int lineno, char *commen } static void -growable_comment_array_deallocate(growable_comment_array *arr) { - for (unsigned i = 0; i < arr->num_items; i++) { +growable_comment_array_deallocate(growable_comment_array *arr) +{ + for (size_t i = 0; i < arr->num_items; i++) { PyMem_Free(arr->items[i].comment); } PyMem_Free(arr->items); } static int -_get_keyword_or_name_type(Parser *p, struct token *new_token) +_get_keyword_or_name_type(Parser *p, const char *text, Py_ssize_t length) { - Py_ssize_t name_len = new_token->end_col_offset - new_token->col_offset; - assert(name_len > 0); + assert(length > 0); - if (name_len >= p->n_keyword_lists || - p->keywords[name_len] == NULL || - p->keywords[name_len]->type == -1) { + if (length >= p->n_keyword_lists || + p->keywords[length] == NULL || + p->keywords[length]->type == -1) { return NAME; } - for (KeywordToken *k = p->keywords[name_len]; k != NULL && k->type != -1; k++) { - if (strncmp(k->str, new_token->start, (size_t)name_len) == 0) { + for (KeywordToken *k = p->keywords[length]; k != NULL && k->type != -1; k++) { + if (memcmp(k->str, text, (size_t)length) == 0) { return k->type; } } return NAME; } +// Keep text only where grammar actions or helpers read it. Keyword error +// actions use fixed spellings, so keywords do not need their text. +static inline int +token_needs_text(int type) +{ + switch (type) { + case NAME: + case NUMBER: + case STRING: + case FSTRING_START: + case FSTRING_MIDDLE: + case FSTRING_END: + case TSTRING_START: + case TSTRING_MIDDLE: + case TSTRING_END: + case TYPE_COMMENT: + case NOTEQUAL: // _PyPegen_check_barry_as_flufl() distinguishes != and <>. + return 1; + default: + return 0; + } +} + static int initialize_token(Parser *p, Token *parser_token, struct token *new_token, int token_type) { assert(parser_token != NULL); - parser_token->type = (token_type == NAME) ? _get_keyword_or_name_type(p, new_token) : token_type; - parser_token->bytes = PyBytes_FromStringAndSize(new_token->start, new_token->end - new_token->start); - if (parser_token->bytes == NULL) { - return -1; - } - if (_PyArena_AddPyObject(p->arena, parser_token->bytes) < 0) { - Py_DECREF(parser_token->bytes); - return -1; + parser_token->type = token_type; + parser_token->bytes = NULL; + if (token_needs_text(token_type) && new_token->span.start >= 0) { + Py_ssize_t length; + const char *text = _PyToken_TextView(p->tok, new_token, &length); + if (token_type == NAME) { + parser_token->type = _get_keyword_or_name_type(p, text, length); + } + // A name reclassified as a keyword does not need its text. + if (parser_token->type == token_type) { + parser_token->bytes = PyBytes_FromStringAndSize(text, length); + if (parser_token->bytes == NULL) { + return -1; + } + if (_PyArena_AddPyObject(p->arena, parser_token->bytes) < 0) { + Py_DECREF(parser_token->bytes); + return -1; + } + } } parser_token->metadata = NULL; if (new_token->metadata != NULL) { if (_PyArena_AddPyObject(p->arena, new_token->metadata) < 0) { - Py_DECREF(new_token->metadata); return -1; } parser_token->metadata = new_token->metadata; @@ -203,16 +278,20 @@ initialize_token(Parser *p, Token *parser_token, struct token *new_token, int to } parser_token->level = new_token->level; - parser_token->lineno = new_token->lineno; - parser_token->col_offset = p->tok->lineno == p->starting_lineno ? p->starting_col_offset + new_token->col_offset - : new_token->col_offset; - parser_token->end_lineno = new_token->end_lineno; - parser_token->end_col_offset = p->tok->lineno == p->starting_lineno ? p->starting_col_offset + new_token->end_col_offset - : new_token->end_col_offset; + parser_token->is_raw = new_token->is_raw; + parser_token->is_incomplete = new_token->is_incomplete; + parser_token->lineno = new_token->start_loc.lineno; + parser_token->col_offset = new_token->end_loc.lineno == p->starting_lineno + ? p->starting_col_offset + new_token->start_loc.byte_col + : new_token->start_loc.byte_col; + parser_token->end_lineno = new_token->end_loc.lineno; + parser_token->end_col_offset = new_token->end_loc.lineno == p->starting_lineno + ? p->starting_col_offset + new_token->end_loc.byte_col + : new_token->end_loc.byte_col; p->fill += 1; - if (token_type == ERRORTOKEN && p->tok->done == E_DECODE) { + if (token_type == ERRORTOKEN && _PyTokenizer_GetStatus(p->tok) == E_DECODE) { return _Pypegen_raise_decode_error(p); } @@ -221,7 +300,13 @@ initialize_token(Parser *p, Token *parser_token, struct token *new_token, int to static int _resize_tokens_array(Parser *p) { - int newsize = p->size * 2; + if (p->size > INT_MAX / PEGEN_ARRAY_GROWTH_FACTOR || + (size_t)p->size > PY_SSIZE_T_MAX / + (PEGEN_ARRAY_GROWTH_FACTOR * sizeof(*p->tokens))) { + PyErr_NoMemory(); + return -1; + } + int newsize = p->size * PEGEN_ARRAY_GROWTH_FACTOR; Token **new_tokens = PyMem_Realloc(p->tokens, (size_t)newsize * sizeof(Token *)); if (new_tokens == NULL) { PyErr_NoMemory(); @@ -229,41 +314,98 @@ _resize_tokens_array(Parser *p) { } p->tokens = new_tokens; + // Allocate new tokens together without moving existing ones: parser rules + // may still hold pointers into earlier blocks. Parser_Free frees each block. + Token *chunk = PyMem_Calloc((size_t)(newsize - p->size), sizeof(Token)); + if (chunk == NULL) { + PyErr_NoMemory(); + return -1; + } for (int i = p->size; i < newsize; i++) { - p->tokens[i] = PyMem_Calloc(1, sizeof(Token)); - if (p->tokens[i] == NULL) { - p->size = i; // Needed, in order to cleanup correctly after parser fails - PyErr_NoMemory(); - return -1; - } + p->tokens[i] = &chunk[i - p->size]; } p->size = newsize; return 0; } +// Fast path attached to the expression precedence chain's entry rules. +// A bare NAME/NUMBER atom followed by a token that cannot start or +// continue a binary/postfix expression is a complete expression, so it is +// built directly instead of descending the whole chain. +// +// Returns 1 if it produced a result (stored in *result), 0 to fall through to +// the rule's alternatives. +int +_PyPegen_atom_fast_path(Parser *p, void *result) +{ + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + *(void **)result = NULL; + return 1; + } + Token *t = p->tokens[p->mark]; + if (t->type != NAME && t->type != NUMBER) { + return 0; + } + if (p->mark + 1 == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + *(void **)result = NULL; + return 1; + } + switch (p->tokens[p->mark + 1]->type) { + case COMMA: + case RPAR: + case RSQB: + case RBRACE: + case COLON: + case NEWLINE: + case SEMI: + case EQUAL: + case ENDMARKER: + break; + default: + return 0; + } + expr_ty res = (t->type == NAME) + ? _PyPegen_name_token(p) : _PyPegen_number_token(p); + *(void **)result = res; + return 1; +} + int _PyPegen_fill_token(Parser *p) { struct token new_token; _PyToken_Init(&new_token); - int type = _PyTokenizer_Get(p->tok, &new_token); + _PyTokenizer_Get(p->tok, &new_token); // Record and skip '# type: ignore' comments - while (type == TYPE_IGNORE) { - Py_ssize_t len = new_token.end_col_offset - new_token.col_offset; + while (new_token.type == TYPE_IGNORE) { + Py_ssize_t len; + const char *text = _PyToken_TextView(p->tok, &new_token, &len); char *tag = PyMem_Malloc((size_t)len + 1); if (tag == NULL) { PyErr_NoMemory(); goto error; } - strncpy(tag, new_token.start, (size_t)len); + memcpy(tag, text, (size_t)len); tag[len] = '\0'; // Ownership of tag passes to the growable array - if (!growable_comment_array_add(&p->type_ignore_comments, p->tok->lineno, tag)) { + if (!growable_comment_array_add(&p->type_ignore_comments, new_token.end_loc.lineno, tag)) { + PyMem_Free(tag); PyErr_NoMemory(); goto error; } - type = _PyTokenizer_Get(p->tok, &new_token); + _PyTokenizer_Get(p->tok, &new_token); + } + + int type = new_token.type; + // EOF can finish an ordinary token. Only a boundary token means that + // the grammar requested input beyond the last physical line. + if (type == ENDMARKER || + (type == DEDENT && (p->flags & PyPARSE_ALLOW_INCOMPLETE_INPUT) && + _PyTokenizer_GetStatus(p->tok) == E_EOF)) { + p->input_exhausted = 1; } // If we have reached the end and we are in single input mode we need to insert a newline and reset the parsing @@ -271,9 +413,8 @@ _PyPegen_fill_token(Parser *p) type = NEWLINE; /* Add an extra newline */ p->parsing_started = 0; - if (p->tok->indent && !(p->flags & PyPARSE_DONT_IMPLY_DEDENT)) { - p->tok->pendin = -p->tok->indent; - p->tok->indent = 0; + if (!(p->flags & PyPARSE_DONT_IMPLY_DEDENT)) { + _PyTokenizer_ImplyDedents(p->tok); } } else { @@ -286,7 +427,9 @@ _PyPegen_fill_token(Parser *p) } Token *t = p->tokens[p->fill]; - return initialize_token(p, t, &new_token, type); + int result = initialize_token(p, t, &new_token, type); + _PyToken_Free(&new_token); + return result; error: _PyToken_Free(&new_token); return -1; @@ -350,6 +493,10 @@ _PyPegen_is_memoized(Parser *p, int type, void *pres) Token *t = p->tokens[p->mark]; + if (!(t->memo_mask & (1ULL << (type & 63)))) { + return 0; + } + for (Memo *m = t->memo; m != NULL; m = m->next) { if (m->type == type) { #if defined(Py_DEBUG) @@ -561,24 +708,91 @@ _PyPegen_new_identifier(Parser *p, const char *n) return NULL; } -static expr_ty -_PyPegen_name_from_token(Parser *p, Token* t) +// Return an arena-owned identifier; callers borrow the reference. +static PyObject * +get_cached_identifier(Parser *p, PyObject *bytes) { - if (t == NULL) { + const char *s = PyBytes_AsString(bytes); + if (!s) { + p->error_indicator = 1; return NULL; } - const char *s = PyBytes_AsString(t->bytes); - if (!s) { + // Identifiers repeat constantly; a small span-keyed cache skips the + // UTF-8 decode + intern for repeated occurrences. Keys point into + // arena-owned token bytes and values are arena-owned interned strings, + // so borrowed references are valid for the lifetime of the parse + // (including the second error pass, which reuses parser and arena). + Py_ssize_t len = PyBytes_GET_SIZE(bytes); + Py_hash_t hash = PyObject_Hash(bytes); + if (hash == -1) { p->error_indicator = 1; return NULL; } + // Parses without identifiers do not need this cache. + if (p->identifier_cache == NULL) { + p->identifier_cache = PyMem_Calloc( + IDENTIFIER_CACHE_SIZE, sizeof(*p->identifier_cache)); + if (p->identifier_cache == NULL) { + p->error_indicator = 1; + return PyErr_NoMemory(); + } + } + IdentifierCacheEntry *free_slot = NULL; + size_t idx = (size_t)hash & (IDENTIFIER_CACHE_SIZE - 1); + for (int probe = 0; probe < IDENTIFIER_CACHE_MAX_PROBES; probe++) { + IdentifierCacheEntry *entry = &p->identifier_cache[ + (idx + probe) & (IDENTIFIER_CACHE_SIZE - 1)]; + if (entry->key == NULL) { + free_slot = entry; + break; + } + if (entry->hash == hash && entry->len == len && + memcmp(entry->key, s, len) == 0) + { + return entry->value; + } + } PyObject *id = _PyPegen_new_identifier(p, s); if (id == NULL) { p->error_indicator = 1; return NULL; } - return _PyAST_Name(id, Load, t->lineno, t->col_offset, t->end_lineno, - t->end_col_offset, p->arena); + if (free_slot != NULL) { + free_slot->key = s; + free_slot->len = len; + free_slot->hash = hash; + free_slot->value = id; + } + return id; +} + +static expr_ty +_PyPegen_name_from_token(Parser *p, Token* t) +{ + if (t == NULL) { + return NULL; + } + // Reuse the AST node when backtracking revisits this token. Memo lookup + // starts before the token and restores the position after it on a hit. + // Token kinds can be memo keys: generated grammar rule IDs start at 1000. + int mark = p->mark - 1; + p->mark = mark; + expr_ty cached = NULL; + if (_PyPegen_is_memoized(p, NAME, &cached)) { + return cached; + } + p->mark = mark + 1; + PyObject *id = get_cached_identifier(p, t->bytes); + if (id == NULL) { + return NULL; + } + expr_ty result = _PyAST_Name(id, Load, t->lineno, t->col_offset, + t->end_lineno, t->end_col_offset, p->arena); + if (result != NULL && _PyPegen_insert_memo(p, mark, NAME, result) < 0) { + p->error_indicator = 1; + return NULL; + } + return result; } expr_ty @@ -687,11 +901,21 @@ parsenumber(const char *s) expr_ty _PyPegen_number_token(Parser *p) { + int mark = p->mark; Token *t = _PyPegen_expect_token(p, NUMBER); if (t == NULL) { return NULL; } + // Look up the node at the token's start, as for NAME tokens. A memo hit + // advances the mark; on a miss, restore the position after the token. + p->mark = mark; + expr_ty cached = NULL; + if (_PyPegen_is_memoized(p, NUMBER, &cached)) { + return cached; + } + p->mark = mark + 1; + const char *num_raw = PyBytes_AsString(t->bytes); if (num_raw == NULL) { p->error_indicator = 1; @@ -736,38 +960,16 @@ _PyPegen_number_token(Parser *p) return NULL; } - return _PyAST_Constant(c, NULL, t->lineno, t->col_offset, t->end_lineno, - t->end_col_offset, p->arena); + expr_ty result = _PyAST_Constant(c, NULL, t->lineno, t->col_offset, + t->end_lineno, t->end_col_offset, p->arena); + if (result != NULL && _PyPegen_insert_memo(p, mark, NUMBER, result) < 0) { + p->error_indicator = 1; + return NULL; + } + return result; } -/* Check that the source for a single input statement really is a single - statement by looking at what is left in the buffer after parsing. - Trailing whitespace and comments are OK. */ -static int // bool -bad_single_statement(Parser *p) -{ - char *cur = p->tok->cur; - char c = *cur; - - for (;;) { - while (c == ' ' || c == '\t' || c == '\n' || c == '\014') { - c = *++cur; - } - - if (!c) { - return 0; - } - - if (c != '#') { - return 1; - } - /* Suck up comment. */ - while (c && c != '\n') { - c = *++cur; - } - } -} static int compute_parser_flags(PyCompilerFlags *flags) @@ -805,7 +1007,8 @@ _PyPegen_Parser_New(struct tok_state *tok, int start_rule, int flags, return (Parser *) PyErr_NoMemory(); } assert(tok != NULL); - tok->type_comments = (flags & PyPARSE_TYPE_COMMENTS) > 0; + _PyTokenizer_SetOptions(tok, 0, (flags & PyPARSE_TYPE_COMMENTS) > 0); + _PyTokenizer_AllowIncompleteInput(tok, flags & PyPARSE_ALLOW_INCOMPLETE_INPUT); p->tok = tok; p->keywords = NULL; p->n_keyword_lists = -1; @@ -821,12 +1024,7 @@ _PyPegen_Parser_New(struct tok_state *tok, int start_rule, int flags, PyMem_Free(p); return (Parser *) PyErr_NoMemory(); } - if (!growable_comment_array_init(&p->type_ignore_comments, 10)) { - PyMem_Free(p->tokens[0]); - PyMem_Free(p->tokens); - PyMem_Free(p); - return (Parser *) PyErr_NoMemory(); - } + p->type_ignore_comments = (growable_comment_array){0}; p->mark = 0; p->fill = 0; @@ -844,8 +1042,19 @@ _PyPegen_Parser_New(struct tok_state *tok, int start_rule, int flags, p->flags = flags; p->feature_version = feature_version; p->known_err_token = NULL; + p->identifier_cache = NULL; + p->tstate = PyThreadState_Get(); + // Stack limits are initialized when the thread state is attached. + assert(((_PyThreadStateImpl *)p->tstate)->c_stack_hard_limit != 0); + p->stack_soft_limit = ((_PyThreadStateImpl *)p->tstate)->c_stack_soft_limit; +#if _Py_STACK_GROWS_DOWN + p->stack_soft_limit += _PyOS_STACK_MARGIN_BYTES; +#else + p->stack_soft_limit -= _PyOS_STACK_MARGIN_BYTES; +#endif p->level = 0; p->call_invalid_rules = 0; + p->input_exhausted = 0; p->last_stmt_location.lineno = 0; p->last_stmt_location.col_offset = 0; p->last_stmt_location.end_lineno = 0; @@ -859,8 +1068,11 @@ _PyPegen_Parser_New(struct tok_state *tok, int start_rule, int flags, void _PyPegen_Parser_Free(Parser *p) { + PyMem_Free(p->identifier_cache); Py_XDECREF(p->normalize); - for (int i = 0; i < p->size; i++) { + // Resizes allocate blocks starting at indices 1, 2, 4, and so on. + PyMem_Free(p->tokens[0]); + for (int i = 1; i < p->size; i *= PEGEN_ARRAY_GROWTH_FACTOR) { PyMem_Free(p->tokens[i]); } PyMem_Free(p->tokens); @@ -877,18 +1089,13 @@ reset_parser_state_for_error_pass(Parser *p) p->last_stmt_location.end_col_offset = 0; for (int i = 0; i < p->fill; i++) { p->tokens[i]->memo = NULL; + p->tokens[i]->memo_mask = 0; } p->mark = 0; + p->flags &= ~PyPARSE_ALLOW_INCOMPLETE_INPUT; + _PyTokenizer_AllowIncompleteInput(p->tok, 0); p->call_invalid_rules = 1; - // Don't try to get extra tokens in interactive mode when trying to - // raise specialized errors in the second pass. - p->tok->interactive_underflow = IUNDERFLOW_STOP; -} - -static inline int -_is_end_of_source(Parser *p) { - int err = p->tok->done; - return err == E_EOF || err == E_EOFS || err == E_EOLS; + _PyTokenizer_StopInteractive(p->tok); } static void @@ -898,19 +1105,14 @@ _PyPegen_set_syntax_error_metadata(Parser *p) { PyErr_SetRaisedException(exc); return; } - const char *source = NULL; - if (p->tok->str != NULL) { - source = p->tok->str; - } - if (!source && p->tok->fp_interactive && p->tok->interactive_src_start) { - source = p->tok->interactive_src_start; - } + const char *source = _PyTokenizer_RetainedSource(p->tok); + const char *encoding = _PyTokenizer_GetInfo(p->tok).encoding; PyObject* the_source = NULL; if (source) { - if (p->tok->encoding == NULL) { + if (encoding == NULL) { the_source = PyUnicode_FromString(source); } else { - the_source = PyUnicode_Decode(source, strlen(source), p->tok->encoding, NULL); + the_source = PyUnicode_Decode(source, strlen(source), encoding, NULL); } } if (!the_source) { @@ -926,6 +1128,7 @@ _PyPegen_set_syntax_error_metadata(Parser *p) { ); if (!metadata) { PyErr_Clear(); + PyErr_SetRaisedException(exc); return; } PySyntaxErrorObject *syntax_error = (PySyntaxErrorObject *)exc; @@ -946,13 +1149,15 @@ _PyPegen_run_parser(Parser *p) return NULL; } if (res == NULL) { - if ((p->flags & PyPARSE_ALLOW_INCOMPLETE_INPUT) && _is_end_of_source(p)) { - PyErr_Clear(); - return _PyPegen_raise_error(p, PyExc_IncompleteInputError, 0, "incomplete input"); - } - if (PyErr_Occurred() && !PyErr_ExceptionMatches(PyExc_SyntaxError)) { + if (PyErr_Occurred() && + (PyErr_ExceptionMatches(PyExc_IncompleteInputError) || + !PyErr_ExceptionMatches(PyExc_SyntaxError))) { return NULL; } + if ((p->flags & PyPARSE_ALLOW_INCOMPLETE_INPUT) && + p->input_exhausted && !PyErr_Occurred()) { + return _PyPegen_raise_incomplete_input(p); + } // Make a second parser pass. In this pass we activate heavier and slower checks // to produce better error messages and more complete diagnostics. Extra "invalid_*" // rules will be active during parsing. @@ -971,8 +1176,7 @@ _PyPegen_run_parser(Parser *p) return NULL; } - if (p->start_rule == Py_single_input && bad_single_statement(p)) { - p->tok->done = E_BADSINGLE; // This is not necessary for now, but might be in the future + if (p->start_rule == Py_single_input && _PyTokenizer_HasTrailingStatement(p->tok)) { return RAISE_SYNTAX_ERROR("multiple statements found while compiling a single statement"); } @@ -996,6 +1200,7 @@ _PyPegen_run_parser_from_file_pointer(FILE *fp, int start_rule, PyObject *filena PyCompilerFlags *flags, int *errcode, PyObject **interactive_src, PyArena *arena) { + int parser_flags = compute_parser_flags(flags); struct tok_state *tok = _PyTokenizer_FromFile(fp, enc, ps1, ps2); if (tok == NULL) { if (PyErr_Occurred()) { @@ -1007,22 +1212,18 @@ _PyPegen_run_parser_from_file_pointer(FILE *fp, int start_rule, PyObject *filena } return NULL; } - if (!tok->fp || ps1 != NULL || ps2 != NULL || - PyUnicode_CompareWithASCIIString(filename_ob, "") == 0) { - tok->fp_interactive = 1; - } - // This transfers the ownership to the tokenizer - tok->filename = Py_NewRef(filename_ob); + tok->barry_as_bdfl = parser_flags & PyPARSE_BARRY_AS_BDFL; // From here on we need to clean up even if there's an error mod_ty result = NULL; - tok->module = PyUnicode_FromString("__main__"); - if (tok->module == NULL) { + PyObject *module = PyUnicode_FromString("__main__"); + if (module == NULL) { goto error; } + _PyTokenizer_SetContext(tok, filename_ob, module); + Py_DECREF(module); - int parser_flags = compute_parser_flags(flags); Parser *p = _PyPegen_Parser_New(tok, start_rule, parser_flags, PY_MINOR_VERSION, errcode, NULL, arena); if (p == NULL) { @@ -1032,8 +1233,9 @@ _PyPegen_run_parser_from_file_pointer(FILE *fp, int start_rule, PyObject *filena result = _PyPegen_run_parser(p); _PyPegen_Parser_Free(p); - if (tok->fp_interactive && tok->interactive_src_start && result && interactive_src != NULL) { - *interactive_src = PyUnicode_FromString(tok->interactive_src_start); + const char *source = _PyTokenizer_RetainedSource(tok); + if (source != NULL && result && interactive_src != NULL) { + *interactive_src = PyUnicode_FromString(source); if (!*interactive_src || _PyArena_AddPyObject(arena, *interactive_src) < 0) { Py_XDECREF(*interactive_src); result = NULL; @@ -1048,15 +1250,21 @@ _PyPegen_run_parser_from_file_pointer(FILE *fp, int start_rule, PyObject *filena mod_ty _PyPegen_run_parser_from_string(const char *str, int start_rule, PyObject *filename_ob, - PyCompilerFlags *flags, PyArena *arena, PyObject *module) + PyCompilerFlags *flags, PyArena *arena, PyObject *module, + PyObject **incomplete) { - int exec_input = start_rule == Py_file_input; + _PyTokenizer_Newline newline_mode = start_rule == Py_file_input + ? _PyTokenizer_IMPLY_NEWLINE : _PyTokenizer_KEEP_NEWLINE; + int parser_flags = compute_parser_flags(flags); + if (parser_flags & PyPARSE_ALLOW_INCOMPLETE_INPUT) { + newline_mode = _PyTokenizer_APPEND_NEWLINE; + } struct tok_state *tok; if (flags != NULL && flags->cf_flags & PyCF_IGNORE_COOKIE) { - tok = _PyTokenizer_FromUTF8(str, exec_input, 0); + tok = _PyTokenizer_FromUTF8(str, newline_mode, 0); } else { - tok = _PyTokenizer_FromString(str, exec_input, 0); + tok = _PyTokenizer_FromString(str, newline_mode, 0); } if (tok == NULL) { if (PyErr_Occurred()) { @@ -1068,14 +1276,13 @@ _PyPegen_run_parser_from_string(const char *str, int start_rule, PyObject *filen } return NULL; } - // This transfers the ownership to the tokenizer - tok->filename = Py_NewRef(filename_ob); - tok->module = Py_XNewRef(module); + tok->barry_as_bdfl = parser_flags & PyPARSE_BARRY_AS_BDFL; + + _PyTokenizer_SetContext(tok, filename_ob, module); // We need to clear up from here on mod_ty result = NULL; - int parser_flags = compute_parser_flags(flags); int feature_version = flags && (flags->cf_flags & PyCF_ONLY_AST) ? flags->cf_feature_version : PY_MINOR_VERSION; Parser *p = _PyPegen_Parser_New(tok, start_rule, parser_flags, feature_version, @@ -1085,6 +1292,22 @@ _PyPegen_run_parser_from_string(const char *str, int start_rule, PyObject *filen } result = _PyPegen_run_parser(p); + if (result != NULL && (parser_flags & PyPARSE_ALLOW_INCOMPLETE_INPUT)) { + int needs_newline = _PyTokenizer_GetNewlineRequirements(tok); + if ((needs_newline & _PyTokenizer_NEWLINE_CONTINUATION) || + (start_rule != Py_file_input && + (needs_newline & _PyTokenizer_NEWLINE_INDENT)) || + (start_rule == Py_single_input && p->input_exhausted && + (needs_newline & _PyTokenizer_NEWLINE_STATEMENT))) { + _PyPegen_raise_incomplete_input(p); + if (incomplete != NULL && PyErr_ExceptionMatches(PyExc_IncompleteInputError)) { + *incomplete = PyErr_GetRaisedException(); + } + else { + result = NULL; + } + } + } _PyPegen_Parser_Free(p); error: diff --git a/Parser/pegen.h b/Parser/pegen.h index cbf44ba474fa395..ef865bb0ed345f5 100644 --- a/Parser/pegen.h +++ b/Parser/pegen.h @@ -4,8 +4,11 @@ #include #include #include +#include // _Py_ReachedRecursionLimitWithMargin() +#include // _Py_get_machine_stack_pointer() +#include // _PyOS_STACK_MARGIN_BYTES -#include "lexer/state.h" +#include "tokenizer/tokenizer.h" #if 0 #define PyPARSE_YIELD_IS_KEYWORD 0x0001 @@ -26,22 +29,28 @@ #define CURRENT_POS (-5) -#define TOK_GET_MODE(tok) (&(tok->tok_mode_stack[tok->tok_mode_stack_index])) -#define TOK_GET_STRING_PREFIX(tok) (TOK_GET_MODE(tok)->string_kind == TSTRING ? 't' : 'f') - typedef struct _memo { int type; - void *node; int mark; + void *node; struct _memo *next; } Memo; typedef struct { int type; + // Text required by grammar actions or helpers; otherwise NULL. + // Unfinished f-string and t-string middle tokens retain their text so + // their grammar action can check escapes before requesting more input. PyObject *bytes; int level; + unsigned char is_raw; + unsigned char is_incomplete; int lineno, col_offset, end_lineno, end_col_offset; Memo *memo; + // Filter over the rule types present in `memo` (bit `type & 63` is set + // for every entry): lets lookups skip walking the list on definite + // misses, which are the common case. + uint64_t memo_mask; PyObject *metadata; } Token; @@ -67,6 +76,8 @@ typedef struct { int end_col_offset; } location; +typedef struct _identifier_cache_entry IdentifierCacheEntry; + typedef struct { struct tok_state *tok; Token **tokens; @@ -78,7 +89,8 @@ typedef struct { int n_keyword_lists; int start_rule; int *errcode; - int parsing_started; + unsigned char parsing_started; + unsigned char input_exhausted; PyObject* normalize; int starting_lineno; int starting_col_offset; @@ -91,8 +103,30 @@ typedef struct { int call_invalid_rules; int debug; location last_stmt_location; + IdentifierCacheEntry *identifier_cache; + PyThreadState *tstate; + // Cached copy of tstate->c_stack_soft_limit offset by one margin toward + // the stack top, so the per-rule stack check is a single inline comparison. + uintptr_t stack_soft_limit; } Parser; +// C-stack exhaustion check run on every rule entry. The fast path compares +// the machine stack pointer against the soft limit cached in the Parser; +// only when the stack is nearly exhausted is the full check called. +static inline int +_PyPegen_stack_exhausted(Parser *p) +{ +#if _Py_STACK_GROWS_DOWN + if (_Py_get_machine_stack_pointer() > p->stack_soft_limit) { +#else + if (_Py_get_machine_stack_pointer() <= p->stack_soft_limit) { +#endif + assert(!_Py_ReachedRecursionLimitWithMargin(p->tstate, 1)); + return 0; + } + return _Py_ReachedRecursionLimitWithMargin(p->tstate, 1); +} + typedef struct { cmpop_ty cmpop; expr_ty expr; @@ -143,6 +177,7 @@ PyObject *_PyPegen_get_memo_statistics(void); int _PyPegen_insert_memo(Parser *p, int mark, int type, void *node); int _PyPegen_update_memo(Parser *p, int mark, int type, void *node); +Memo *_PyPegen_insert_memo_direct(Parser *p, int mark, int type); int _PyPegen_is_memoized(Parser *p, int type, void *pres); int _PyPegen_lookahead(int, void *(func)(Parser *), Parser *); @@ -159,6 +194,9 @@ expr_ty _PyPegen_soft_keyword_token(Parser *p); expr_ty _PyPegen_fstring_middle_token(Parser* p); Token *_PyPegen_get_last_nonnwhitespace_token(Parser *); int _PyPegen_fill_token(Parser *p); +// Return -1 on failure, leaving the buffer and capacity unchanged. +int _PyPegen_grow_loop_buffer(void ***buffer, Py_ssize_t *capacity); +int _PyPegen_atom_fast_path(Parser *p, void *result); expr_ty _PyPegen_name_token(Parser *p); expr_ty _PyPegen_number_token(Parser *p); void *_PyPegen_string_token(Parser *p); @@ -166,15 +204,19 @@ Py_ssize_t _PyPegen_byte_offset_to_character_offset_line(PyObject *line, Py_ssiz Py_ssize_t _PyPegen_byte_offset_to_character_offset(PyObject *line, Py_ssize_t col_offset); Py_ssize_t _PyPegen_byte_offset_to_character_offset_raw(const char*, Py_ssize_t col_offset); -// Error handling functions and APIs typedef enum { STAR_TARGETS, DEL_TARGETS, - FOR_TARGETS + FOR_TARGETS, + SINGLE_TARGETS, + ATTRIBUTE_OR_SUBSCRIPT_TARGETS } TARGETS_TYPE; +// Error handling functions and APIs int _Pypegen_raise_decode_error(Parser *p); +int _Pypegen_raise_decode_error_known_location(Parser *p, expr_ty a); int _Pypegen_tokenizer_error(Parser *p); +void *_PyPegen_raise_incomplete_input(Parser *p); void *_PyPegen_raise_error(Parser *p, PyObject *errtype, int use_mark, const char *errmsg, ...); void *_PyPegen_raise_error_known_location(Parser *p, PyObject *errtype, Py_ssize_t lineno, Py_ssize_t col_offset, @@ -325,6 +367,7 @@ CmpopExprPair *_PyPegen_cmpop_expr_pair(Parser *, cmpop_ty, expr_ty); asdl_int_seq *_PyPegen_get_cmpops(Parser *p, asdl_seq *); asdl_expr_seq *_PyPegen_get_exprs(Parser *, asdl_seq *); expr_ty _PyPegen_set_expr_context(Parser *, expr_ty, expr_context_ty); +expr_ty _PyPegen_make_target(Parser *, expr_ty, TARGETS_TYPE); KeyValuePair *_PyPegen_key_value_pair(Parser *, expr_ty, expr_ty); asdl_expr_seq *_PyPegen_get_keys(Parser *, asdl_seq *); asdl_expr_seq *_PyPegen_get_values(Parser *, asdl_seq *); @@ -386,7 +429,7 @@ mod_ty _PyPegen_run_parser_from_file_pointer(FILE *, int, PyObject *, const char const char *, const char *, PyCompilerFlags *, int *, PyObject **, PyArena *); void *_PyPegen_run_parser(Parser *); -mod_ty _PyPegen_run_parser_from_string(const char *, int, PyObject *, PyCompilerFlags *, PyArena *, PyObject *); +mod_ty _PyPegen_run_parser_from_string(const char *, int, PyObject *, PyCompilerFlags *, PyArena *, PyObject *, PyObject **); asdl_stmt_seq *_PyPegen_interactive_exit(Parser *); // Generated function in parse.c - function definition in python.gram diff --git a/Parser/pegen_errors.c b/Parser/pegen_errors.c index b13e1c079220a92..f5dce5ded18eb83 100644 --- a/Parser/pegen_errors.c +++ b/Parser/pegen_errors.c @@ -4,20 +4,30 @@ #include "pycore_pyerrors.h" // _PyErr_ProgramDecodedTextObject() #include "pycore_runtime.h" // _Py_ID() #include "pycore_tuple.h" // _PyTuple_FromPair -#include "lexer/state.h" -#include "lexer/lexer.h" #include "pegen.h" +#include "tokenizer/tokenizer.h" // TOKENIZER ERRORS +void * +_PyPegen_raise_incomplete_input(Parser *p) +{ + if ((p->flags & PyPARSE_ALLOW_INCOMPLETE_INPUT) && !PyErr_Occurred()) { + return _PyPegen_raise_error(p, PyExc_IncompleteInputError, 0, + "incomplete input"); + } + return NULL; +} + static inline void raise_unclosed_parentheses_error(Parser *p) { - int error_lineno = p->tok->parenlinenostack[p->tok->level-1]; - int error_col = p->tok->parencolstack[p->tok->level-1]; + _PyTokenizer_Info info = _PyTokenizer_GetInfo(p->tok); + int error_lineno = info.delimiter_loc.lineno; + int error_col = info.delimiter_loc.byte_col; RAISE_ERROR_KNOWN_LOCATION(p, PyExc_SyntaxError, error_lineno, error_col, error_lineno, -1, "'%c' was never closed", - p->tok->parenstack[p->tok->level-1]); + info.delimiter); } int @@ -31,12 +41,23 @@ _Pypegen_tokenizer_error(Parser *p) PyObject* errtype = PyExc_SyntaxError; Py_ssize_t col_offset = -1; p->error_indicator = 1; - switch (p->tok->done) { + _PyTokenizer_Info info = _PyTokenizer_GetInfo(p->tok); + if ((p->flags & PyPARSE_ALLOW_INCOMPLETE_INPUT) && + (info.status == E_EOF || info.status == E_INCOMPLETE)) + { + _PyPegen_raise_incomplete_input(p); + return -1; + } + switch (info.status) { + case E_INCOMPLETE: + // The diagnostic pass rejected this unfinished token. Let the + // parser report the syntax error at its original failure point. + return -1; case E_TOKEN: msg = "invalid token"; break; case E_EOF: - if (p->tok->level) { + if (info.level) { raise_unclosed_parentheses_error(p); } else { RAISE_SYNTAX_ERROR("unexpected EOF while parsing"); @@ -62,7 +83,7 @@ _Pypegen_tokenizer_error(Parser *p) msg = "too many levels of indentation"; break; case E_LINECONT: { - col_offset = p->tok->cur - p->tok->buf - 1; + col_offset = info.cursor - info.line_span.start - 1; msg = "unexpected character after line continuation character"; break; } @@ -74,14 +95,20 @@ _Pypegen_tokenizer_error(Parser *p) msg = "unknown parsing error"; } - RAISE_ERROR_KNOWN_LOCATION(p, errtype, p->tok->lineno, + RAISE_ERROR_KNOWN_LOCATION(p, errtype, info.location.lineno, col_offset >= 0 ? col_offset : 0, - p->tok->lineno, -1, msg); + info.location.lineno, -1, msg); return -1; } int _Pypegen_raise_decode_error(Parser *p) +{ + return _Pypegen_raise_decode_error_known_location(p, NULL); +} + +int +_Pypegen_raise_decode_error_known_location(Parser *p, expr_ty a) { assert(PyErr_Occurred()); const char *errtype = NULL; @@ -99,12 +126,22 @@ _Pypegen_raise_decode_error(Parser *p) PyErr_Fetch(&type, &value, &tback); errstr = PyObject_Str(value); if (errstr) { - RAISE_SYNTAX_ERROR("(%s) %U", errtype, errstr); + if (a != NULL) { + RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "(%s) %U", errtype, errstr); + } + else { + RAISE_SYNTAX_ERROR("(%s) %U", errtype, errstr); + } Py_DECREF(errstr); } else { PyErr_Clear(); - RAISE_SYNTAX_ERROR("(%s) unknown error", errtype); + if (a != NULL) { + RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "(%s) unknown error", errtype); + } + else { + RAISE_SYNTAX_ERROR("(%s) unknown error", errtype); + } } Py_XDECREF(type); Py_XDECREF(value); @@ -122,7 +159,7 @@ _PyPegen_tokenize_full_source_to_check_for_errors(Parser *p) { // before the one that we had for the generic error. // We don't want to tokenize to the end for interactive input - if (p->tok->prompt != NULL) { + if (_PyTokenizer_IsInteractive(p->tok)) { return 0; } @@ -137,14 +174,16 @@ _PyPegen_tokenize_full_source_to_check_for_errors(Parser *p) { _PyToken_Init(&new_token); for (;;) { - switch (_PyTokenizer_Get(p->tok, &new_token)) { - case ERRORTOKEN: + _PyTokenizer_Get(p->tok, &new_token); + switch (new_token.type) { + case ERRORTOKEN: { if (PyErr_Occurred()) { ret = -1; goto exit; } - if (p->tok->level != 0) { - int error_lineno = p->tok->parenlinenostack[p->tok->level-1]; + _PyTokenizer_Info info = _PyTokenizer_GetInfo(p->tok); + if (info.level != 0) { + int error_lineno = info.delimiter_loc.lineno; if (current_err_line > error_lineno) { raise_unclosed_parentheses_error(p); ret = -1; @@ -152,6 +191,7 @@ _PyPegen_tokenize_full_source_to_check_for_errors(Parser *p) { } } break; + } case ENDMARKER: break; default: @@ -163,10 +203,9 @@ _PyPegen_tokenize_full_source_to_check_for_errors(Parser *p) { exit: _PyToken_Free(&new_token); - // If we're in an f-string, we want the syntax error in the expression part - // to propagate, so that tokenizer errors (like expecting '}') that happen afterwards - // do not swallow it. - if (PyErr_Occurred() && p->tok->tok_mode_stack_index <= 0) { + _PyTokenizer_Info info = _PyTokenizer_GetInfo(p->tok); + // Preserve expression errors over later formatted-string errors. + if (PyErr_Occurred() && !info.in_formatted_string) { Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(traceback); @@ -202,11 +241,14 @@ _PyPegen_raise_error(Parser *p, PyObject *errtype, int use_mark, const char *err Py_ssize_t col_offset; Py_ssize_t end_col_offset = -1; if (t->col_offset == -1) { - if (p->tok->cur == p->tok->buf) { + _PyTokenizer_Info info = _PyTokenizer_GetInfo(p->tok); + if (info.diagnostic.location.lineno != 0) { + col_offset = info.diagnostic.location.byte_col; + } else if (info.cursor == info.input_span.start) { col_offset = 0; } else { - const char* start = p->tok->buf ? p->tok->line_start : p->tok->buf; - col_offset = Py_SAFE_DOWNCAST(p->tok->cur - start, intptr_t, int); + col_offset = Py_SAFE_DOWNCAST( + info.cursor - info.line_span.start, intptr_t, int); } } else { col_offset = t->col_offset + 1; @@ -225,46 +267,15 @@ _PyPegen_raise_error(Parser *p, PyObject *errtype, int use_mark, const char *err } static PyObject * -get_error_line_from_tokenizer_buffers(Parser *p, Py_ssize_t lineno) +get_error_line_from_source(Parser *p, Py_ssize_t lineno) { - /* If the file descriptor is interactive, the source lines of the current - * (multi-line) statement are stored in p->tok->interactive_src_start. - * If not, we're parsing from a string, which means that the whole source - * is stored in p->tok->str. */ - assert((p->tok->fp == NULL && p->tok->str != NULL) || p->tok->fp != NULL); - - char *cur_line = p->tok->fp_interactive ? p->tok->interactive_src_start : p->tok->str; - if (cur_line == NULL) { - assert(p->tok->fp_interactive); - // We can reach this point if the tokenizer buffers for interactive source have not been - // initialized because we failed to decode the original source with the given locale. + if (_PyTokenizer_RetainedSource(p->tok) == NULL) { return Py_GetConstant(Py_CONSTANT_EMPTY_STR); } - Py_ssize_t relative_lineno = p->starting_lineno ? lineno - p->starting_lineno + 1 : lineno; - const char* buf_end = p->tok->fp_interactive ? p->tok->interactive_src_end : p->tok->inp; - - if (buf_end < cur_line) { - buf_end = cur_line + strlen(cur_line); - } - - for (int i = 0; i < relative_lineno - 1; i++) { - char *new_line = strchr(cur_line, '\n'); - // The assert is here for debug builds but the conditional that - // follows is there so in release builds we do not crash at the cost - // to report a potentially wrong line. - assert(new_line != NULL && new_line + 1 < buf_end); - if (new_line == NULL || new_line + 1 > buf_end) { - break; - } - cur_line = new_line + 1; - } - - char *next_newline; - if ((next_newline = strchr(cur_line, '\n')) == NULL) { // This is the last line - next_newline = cur_line + strlen(cur_line); - } - return PyUnicode_DecodeUTF8(cur_line, next_newline - cur_line, "replace"); + Py_ssize_t len; + const char *line = _PyTokenizer_LineView(p->tok, relative_lineno, &len); + return PyUnicode_DecodeUTF8(line, len, "replace"); } void * @@ -282,12 +293,24 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype, PyObject *error_line = NULL; PyObject *tmp = NULL; p->error_indicator = 1; + _PyTokenizer_Info info = _PyTokenizer_GetInfo(p->tok); + _PyTok_Loc location = info.location; + _PyTok_Span text_span = info.line_span; + + if (errtype == PyExc_IncompleteInputError && + info.diagnostic.location.lineno != 0) { + location = info.diagnostic.location; + text_span = info.diagnostic.text_span; + lineno = end_lineno = location.lineno; + col_offset = location.byte_col; + end_col_offset = -1; + } if (end_lineno == CURRENT_POS) { - end_lineno = p->tok->lineno; + end_lineno = location.lineno; } if (end_col_offset == CURRENT_POS) { - end_col_offset = p->tok->cur - p->tok->line_start; + end_col_offset = location.byte_col; } errstr = PyUnicode_FromFormatV(errmsg, va); @@ -295,12 +318,12 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype, goto error; } - if (p->tok->fp_interactive && p->tok->interactive_src_start != NULL) { - error_line = get_error_line_from_tokenizer_buffers(p, lineno); + if (info.is_interactive && _PyTokenizer_RetainedSource(p->tok) != NULL) { + error_line = get_error_line_from_source(p, lineno); } else if (p->start_rule == Py_file_input) { - error_line = _PyErr_ProgramDecodedTextObject(p->tok->filename, - (int) lineno, p->tok->encoding); + error_line = _PyErr_ProgramDecodedTextObject(info.filename, + (int) lineno, info.encoding); } if (!error_line) { @@ -311,14 +334,23 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype, we're actually parsing from a file, which has an E_EOF SyntaxError and in that case `PyErr_ProgramTextObject` fails because lineno points to last_file_line + 1, which does not physically exist */ - assert(p->tok->fp == NULL || p->tok->fp == stdin || p->tok->done == E_EOF); - - if (p->tok->lineno <= lineno && p->tok->inp > p->tok->buf) { - Py_ssize_t size = p->tok->inp - p->tok->line_start; - error_line = PyUnicode_DecodeUTF8(p->tok->line_start, size, "replace"); + assert(!info.is_file || info.status == E_EOF); + + if (location.lineno <= lineno && + info.input_span.end > info.input_span.start) { + Py_ssize_t size; + const char *line = _PyTokenizer_SpanView( + p->tok, text_span, &size); + if (errtype == PyExc_IncompleteInputError && size > 0 && + (info.implicit_newline == _PyTokenizer_APPEND_NEWLINE || + (info.implicit_newline == _PyTokenizer_IMPLY_NEWLINE && + p->start_rule != Py_file_input))) { + size--; + } + error_line = PyUnicode_DecodeUTF8(line, size, "replace"); } - else if (p->tok->fp == NULL || p->tok->fp == stdin) { - error_line = get_error_line_from_tokenizer_buffers(p, lineno); + else if (!info.is_file) { + error_line = get_error_line_from_source(p, lineno); } else { error_line = Py_GetConstant(Py_CONSTANT_EMPTY_STR); @@ -337,13 +369,20 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype, } if (end_col_offset > 0) { - end_col_number = _PyPegen_byte_offset_to_character_offset(error_line, end_col_offset); + PyObject *end_line = end_lineno != lineno && _PyTokenizer_RetainedSource(p->tok) != NULL + ? get_error_line_from_source(p, end_lineno) : Py_NewRef(error_line); + if (end_line == NULL) { + goto error; + } + end_col_number = _PyPegen_byte_offset_to_character_offset(end_line, end_col_offset); + Py_DECREF(end_line); if (end_col_number < 0) { goto error; } } - tmp = Py_BuildValue("(OnnNnn)", p->tok->filename, lineno, col_number, error_line, end_lineno, end_col_number); + tmp = Py_BuildValue("(OnnNnn)", info.filename, lineno, col_number, error_line, end_lineno, end_col_number); + error_line = NULL; if (!tmp) { goto error; } @@ -366,11 +405,12 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype, void _Pypegen_set_syntax_error(Parser* p, Token* last_token) { + _PyTokenizer_Info info = _PyTokenizer_GetInfo(p->tok); // Existing syntax error if (PyErr_Occurred()) { // Prioritize tokenizer errors to custom syntax errors raised // on the second phase only if the errors come from the parser. - int is_tok_ok = (p->tok->done == E_DONE || p->tok->done == E_OK); + int is_tok_ok = (info.status == E_DONE || info.status == E_OK); if (is_tok_ok && PyErr_ExceptionMatches(PyExc_SyntaxError)) { _PyPegen_tokenize_full_source_to_check_for_errors(p); } @@ -382,8 +422,8 @@ _Pypegen_set_syntax_error(Parser* p, Token* last_token) { RAISE_SYNTAX_ERROR("error at start before reading any input"); } // Parser encountered EOF (End of File) unexpectedtly - if (last_token->type == ERRORTOKEN && p->tok->done == E_EOF) { - if (p->tok->level) { + if (last_token->type == ERRORTOKEN && info.status == E_EOF) { + if (info.level) { raise_unclosed_parentheses_error(p); } else { RAISE_SYNTAX_ERROR("unexpected EOF while parsing"); diff --git a/Parser/string_parser.c b/Parser/string_parser.c index b164dfbc81a9339..360d4a161db9b62 100644 --- a/Parser/string_parser.c +++ b/Parser/string_parser.c @@ -2,7 +2,6 @@ #include "pycore_bytesobject.h" // _PyBytes_DecodeEscape() #include "pycore_unicodeobject.h" // _PyUnicode_DecodeUnicodeEscapeInternal() -#include "lexer/state.h" #include "pegen.h" #include "string_parser.h" @@ -70,7 +69,7 @@ warn_invalid_escape_sequence(Parser *p, const char* buffer, const char *first_in char first_quote = 0; if (lineno == t->lineno) { int quote_count = 0; - char* tok = PyBytes_AsString(t->bytes); + const char* tok = PyBytes_AsString(t->bytes); for (int i = 0; i < PyBytes_Size(t->bytes); i++) { if (tok[i] == '\'' || tok[i] == '\"') { if (quote_count == 0) { @@ -87,8 +86,9 @@ warn_invalid_escape_sequence(Parser *p, const char* buffer, const char *first_in col_offset += quote_count; } - if (PyErr_WarnExplicitObject(category, msg, p->tok->filename, - lineno, p->tok->module, NULL) < 0) { + _PyTokenizer_Info info = _PyTokenizer_GetInfo(p->tok); + if (PyErr_WarnExplicitObject(category, msg, info.filename, + lineno, info.module, NULL) < 0) { if (PyErr_ExceptionMatches(category)) { /* Replace the Syntax/DeprecationWarning exception with a SyntaxError to get a more accurate error report */ @@ -135,8 +135,6 @@ static PyObject * decode_unicode_with_escapes(Parser *parser, const char *s, size_t len, Token *t) { PyObject *v; - PyObject *u; - char *buf; char *p; const char *end; @@ -144,22 +142,20 @@ decode_unicode_with_escapes(Parser *parser, const char *s, size_t len, Token *t) if (len > (size_t)PY_SSIZE_T_MAX / 6) { return NULL; } - /* "ä" (2 bytes) may become "\U000000E4" (10 bytes), or 1:5 - "\ä" (3 bytes) may become "\u005c\U000000E4" (16 bytes), or ~1:6 */ - u = PyBytes_FromStringAndSize((char *)NULL, (Py_ssize_t)len * 6); - if (u == NULL) { - return NULL; - } - p = buf = PyBytes_AsString(u); - if (p == NULL) { - return NULL; + /* "ä" (2 bytes) may become "\U000000E4" (10 bytes), or 1:5. + * "\ä" (3 bytes) may become "\u005c\U000000E4" (16 bytes), or ~1:6. */ + Py_ssize_t alloc = (Py_ssize_t)len * 6; + char *buf = PyMem_Malloc(alloc); + if (buf == NULL) { + return PyErr_NoMemory(); } + p = buf; end = s + len; while (s < end) { if (*s == '\\') { *p++ = *s++; if (s >= end || *s & 0x80) { - strcpy(p, "u005c"); + memcpy(p, "u005c", 5); p += 5; if (s >= end) { break; @@ -174,19 +170,20 @@ decode_unicode_with_escapes(Parser *parser, const char *s, size_t len, Token *t) Py_ssize_t i; w = decode_utf8(&s, end); if (w == NULL) { - Py_DECREF(u); + PyMem_Free(buf); return NULL; } kind = PyUnicode_KIND(w); data = PyUnicode_DATA(w); w_len = PyUnicode_GET_LENGTH(w); for (i = 0; i < w_len; i++) { + // sprintf() writes a null byte: the buffer is large enough + // for that thanks to the overallocation. + assert((p + 11 - buf) <= alloc); Py_UCS4 chr = PyUnicode_READ(kind, data, i); sprintf(p, "\\U%08x", chr); p += 10; } - /* Should be impossible to overflow */ - assert(p - buf <= PyBytes_GET_SIZE(u)); Py_DECREF(w); } else { @@ -194,26 +191,29 @@ decode_unicode_with_escapes(Parser *parser, const char *s, size_t len, Token *t) } } len = (size_t)(p - buf); - s = buf; int first_invalid_escape_char; const char *first_invalid_escape_ptr; - v = _PyUnicode_DecodeUnicodeEscapeInternal2(s, (Py_ssize_t)len, NULL, NULL, + // Allow a trailing unfinished escape in a partial token. + int incomplete = t != NULL && t->is_incomplete; + Py_ssize_t consumed; + v = _PyUnicode_DecodeUnicodeEscapeInternal2(buf, (Py_ssize_t)len, NULL, + incomplete ? &consumed : NULL, &first_invalid_escape_char, &first_invalid_escape_ptr); // HACK: later we can simply pass the line no, since we don't preserve the tokens // when we are decoding the string but we preserve the line numbers. - if (v != NULL && first_invalid_escape_ptr != NULL && t != NULL) { - if (warn_invalid_escape_sequence(parser, s, first_invalid_escape_ptr, t) < 0) { - /* We have not decref u before because first_invalid_escape_ptr - points inside u. */ - Py_XDECREF(u); + if (v != NULL && first_invalid_escape_ptr != NULL && t != NULL && !incomplete) { + if (warn_invalid_escape_sequence(parser, buf, first_invalid_escape_ptr, t) < 0) { + /* We have not deallocated the buffer before because + * first_invalid_escape_ptr points inside buf. */ + PyMem_Free(buf); Py_DECREF(v); return NULL; } } - Py_XDECREF(u); + PyMem_Free(buf); return v; } diff --git a/Parser/token.c b/Parser/token.c index a6e7ce35dfad855..0a729e5d8a368b3 100644 --- a/Parser/token.c +++ b/Parser/token.c @@ -113,7 +113,7 @@ _PyToken_OneChar(int c1) } int -_PyToken_TwoChars(int c1, int c2) +_PyToken_TwoChars(int c1, int c2, int BARRY_AS_BDFL) { switch (c1) { case '!': @@ -163,7 +163,7 @@ _PyToken_TwoChars(int c1, int c2) switch (c2) { case '<': return LEFTSHIFT; case '=': return LESSEQUAL; - case '>': return NOTEQUAL; + case '>': return BARRY_AS_BDFL ? NOTEQUAL : OP; } break; case '=': diff --git a/Parser/tokenizer/api.c b/Parser/tokenizer/api.c new file mode 100644 index 000000000000000..99f0e4e0ddc1289 --- /dev/null +++ b/Parser/tokenizer/api.c @@ -0,0 +1,162 @@ +#include "Python.h" +#include "errcode.h" +#include "pycore_token.h" + +#include "tokenizer.h" +#include "reader.h" +#include "reader_internal.h" +#include "../lexer/state.h" + +int +_PyTokenizer_GetStatus(const struct tok_state *tok) +{ + return tok->done; +} + +int +_PyTokenizer_GetNewlineRequirements(const struct tok_state *tok) +{ + return tok->needs_newline; +} + +_PyTokenizer_Info +_PyTokenizer_GetInfo(const struct tok_state *tok) +{ + _PyTokenizer_Info info = { + .status = tok->done, + .implicit_newline = tok->implicit_newline, + .diagnostic = tok->diagnostic, + .location = {tok->lineno, tok->line_start < 0 + ? -1 : (int)(tok->cur - tok->line_start)}, + .cursor = tok->cur, + .input_span = {tok->buf_offset, tok->inp}, + .line_span = {tok->line_start, tok->inp}, + .level = tok->level, + .delimiter_loc = {-1, -1}, + .in_formatted_string = tok->ftstring_depth != 0, + .is_interactive = _PyTok_ReaderIsInteractive(tok), + .is_file = tok->reader->fp != NULL && tok->reader->fp != stdin, + .filename = tok->filename, + .module = tok->module, + .encoding = tok->reader->encoding, + }; + if (tok->level > 0) { + int level = tok->level - 1; + info.delimiter = tok->parenstack[level]; + info.delimiter_loc = (_PyTok_Loc){ + tok->parenlinenostack[level], tok->parencolstack[level]}; + } + return info; +} + +const char * +_PyToken_TextView(const struct tok_state *tok, const struct token *token, + Py_ssize_t *length) +{ + assert(length != NULL); + if (token->span.start < 0) { + assert(token->span.start == -1 && token->span.end == -1); + *length = 0; + return ""; + } + return _PyTok_SourceSpanView(&tok->source, token->span, length); +} + +const char * +_PyTokenizer_SpanView(const struct tok_state *tok, _PyTok_Span span, + Py_ssize_t *length) +{ + return _PyTok_SourceSpanView(&tok->source, span, length); +} + +void +_PyToken_GetView(const struct tok_state *tok, const struct token *token, + _PyToken_View *view) +{ + assert(view != NULL); + view->text = _PyToken_TextView(tok, token, &view->length); + view->end_line_start = tok->line_start; + view->line_span = (_PyTok_Span){ + ISSTRINGLIT(token->type) + ? token->span.start - token->start_loc.byte_col : tok->line_start, + tok->inp, + }; + view->implicit_newline = tok->implicit_newline; + view->at_eof = tok->done == E_EOF; +} + +const char * +_PyTokenizer_LineView(const struct tok_state *tok, Py_ssize_t lineno, + Py_ssize_t *length) +{ + return _PyTok_SourceLineView(&tok->source, lineno, length); +} + +void +_PyTokenizer_SetContext(struct tok_state *tok, PyObject *filename, + PyObject *module) +{ + Py_XINCREF(filename); + Py_XINCREF(module); + Py_XSETREF(tok->filename, filename); + Py_XSETREF(tok->module, module); +} + +void +_PyTokenizer_SetOptions(struct tok_state *tok, int extra_tokens, + int type_comments) +{ + tok->tok_extra_tokens = extra_tokens; + tok->type_comments = type_comments; +} + +void +_PyTokenizer_ImplyDedents(struct tok_state *tok) +{ + _PyLexer_ImplyDedents(tok); +} + +void +_PyTokenizer_AllowIncompleteInput(struct tok_state *tok, int allow) +{ + tok->allow_incomplete_input = allow != 0; +} + +int +_PyTokenizer_HasTrailingStatement(const struct tok_state *tok) +{ + _PyTok_Off cur = tok->cur; + _PyTok_Off end = tok->source.base_offset + tok->source.len; + while (cur < end) { + int c = _PyTok_SourceByte(&tok->source, cur++); + if (c == '\0') { + return 0; + } + if (c == ' ' || c == '\t' || c == '\n' || c == '\014') { + continue; + } + if (c != '#') { + return 1; + } + while (cur < end) { + c = _PyTok_SourceByte(&tok->source, cur); + if (c == '\0' || c == '\n') { + break; + } + cur++; + } + } + return 0; +} + +int +_PyTokenizer_IsInteractive(const struct tok_state *tok) +{ + return _PyTok_ReaderIsInteractive(tok); +} + +void +_PyTokenizer_StopInteractive(struct tok_state *tok) +{ + _PyTok_ReaderStopInteractive(tok); +} diff --git a/Parser/tokenizer/decoder.c b/Parser/tokenizer/decoder.c new file mode 100644 index 000000000000000..6388b71e635cc3f --- /dev/null +++ b/Parser/tokenizer/decoder.c @@ -0,0 +1,509 @@ +#include "Python.h" +#include "pycore_codecs.h" +#include "pycore_global_strings.h" +#include "pycore_runtime.h" +#include "errcode.h" + +#include "reader_internal.h" +#include "helpers.h" +#include "../lexer/state.h" + +#define UNICODE_BOM 0xFEFF +#define UTF16_LE_BOM "\xff\xfe" +#define UTF16_BE_BOM "\xfe\xff" +#define UTF16_BOM_LENGTH ((Py_ssize_t)(sizeof(UTF16_LE_BOM) - 1)) +#define UTF8_BOM "\xef\xbb\xbf" +#define UTF8_BOM_LENGTH ((Py_ssize_t)(sizeof(UTF8_BOM) - 1)) + +char * +_PyTok_CopyBytes(const char *data, Py_ssize_t len) +{ + if (len < 0 || len == PY_SSIZE_T_MAX) { + PyErr_NoMemory(); + return NULL; + } + char *copy = PyMem_Malloc((size_t)len + 1); + if (copy == NULL) { + PyErr_NoMemory(); + return NULL; + } + memcpy(copy, data, (size_t)len); + copy[len] = '\0'; + return copy; +} + +static void +chunk_release_data(_PyTok_Chunk *chunk) +{ + switch (chunk->ownership) { + case _PYTOK_CHUNK_BORROWED: + break; + case _PYTOK_CHUNK_PYMEM: + PyMem_Free(chunk->data); + break; + case _PYTOK_CHUNK_PYOBJECT: + Py_DECREF(chunk->owner); + break; + } +} + +void +_PyTok_ChunkClear(_PyTok_Chunk *chunk) +{ + chunk_release_data(chunk); + *chunk = (_PyTok_Chunk){0}; +} + +static int +chunk_set_unicode(struct tok_state *tok, _PyTok_Chunk *chunk, + PyObject *unicode, int strip_bom) +{ + Py_ssize_t utf8_len; + const char *utf8 = PyUnicode_AsUTF8AndSize(unicode, &utf8_len); + if (utf8 == NULL) { + Py_DECREF(unicode); + tok->done = PyErr_ExceptionMatches(PyExc_MemoryError) + ? E_NOMEM : E_DECODE; + return -1; + } + if (strip_bom && PyUnicode_GET_LENGTH(unicode) > 0 && + PyUnicode_ReadChar(unicode, 0) == UNICODE_BOM) { + utf8 += UTF8_BOM_LENGTH; + utf8_len -= UTF8_BOM_LENGTH; + } + chunk_release_data(chunk); + chunk->owner = unicode; + chunk->data = (char *)utf8; + chunk->len = utf8_len; + chunk->ownership = _PYTOK_CHUNK_PYOBJECT; + return 0; +} + +char * +_PyTok_NormalizeNewlines(const char *data, Py_ssize_t len, + Py_ssize_t *out_len) +{ + if (len < 0 || len == PY_SSIZE_T_MAX) { + PyErr_NoMemory(); + return NULL; + } + char *result = PyMem_Malloc((size_t)len + 1); + if (result == NULL) { + PyErr_NoMemory(); + return NULL; + } + Py_ssize_t write = 0; + for (Py_ssize_t read = 0; read < len; read++) { + char c = data[read]; + if (c == '\r') { + if (read + 1 < len && data[read + 1] == '\n') { + read++; + } + c = '\n'; + } + result[write++] = c; + } + result[write] = '\0'; + *out_len = write; + return result; +} + +int +_PyTok_SetEncoding(struct tok_state *tok, const char *encoding) +{ + char *copy = _PyTok_CopyBytes(encoding, strlen(encoding)); + if (copy == NULL) { + tok->done = E_NOMEM; + return -1; + } + PyMem_Free(tok->reader->encoding); + tok->reader->encoding = copy; + return 0; +} + +static int +find_cookie(const char *line, Py_ssize_t len, char **encoding, int *scan_next) +{ + Py_ssize_t i = 0; + *encoding = NULL; + *scan_next = 1; + for (; i < len; i++) { + if (line[i] == '#') { + break; + } + if (line[i] == '\n' || line[i] == '\r') { + return 0; + } + if (line[i] != ' ' && line[i] != '\t' && line[i] != '\f') { + *scan_next = 0; + return 0; + } + } + const Py_ssize_t marker_len = sizeof("coding") - 1; + for (; i < len - marker_len; i++) { + if (memcmp(line + i, "coding", marker_len) != 0) { + continue; + } + const char *cursor = line + i + marker_len; + if (*cursor != ':' && *cursor != '=') { + continue; + } + do { + cursor++; + } while (cursor < line + len && + (*cursor == ' ' || *cursor == '\t')); + const char *start = cursor; + while (cursor < line + len && + (Py_ISALNUM(*cursor) || *cursor == '-' || + *cursor == '_' || *cursor == '.')) { + cursor++; + } + if (cursor == start) { + continue; + } + Py_ssize_t encoding_len = cursor - start; + // Include the longest recognized prefix and its NUL terminator. + char normalized[sizeof("iso-latin-1-")]; + const Py_ssize_t prefix_len = Py_MIN( + encoding_len, (Py_ssize_t)sizeof(normalized) - 1); + Py_ssize_t n; + for (n = 0; n < prefix_len; n++) { + normalized[n] = start[n] == '_' ? '-' : Py_TOLOWER(start[n]); + } + normalized[n] = '\0'; + const char *canonical = start; + if (strcmp(normalized, "utf-8") == 0 || + strncmp(normalized, "utf-8-", sizeof("utf-8-") - 1) == 0) { + canonical = "utf-8"; + } + else if (strcmp(normalized, "latin-1") == 0 || + strcmp(normalized, "iso-8859-1") == 0 || + strcmp(normalized, "iso-latin-1") == 0 || + strncmp(normalized, "latin-1-", sizeof("latin-1-") - 1) == 0 || + strncmp(normalized, "iso-8859-1-", sizeof("iso-8859-1-") - 1) == 0 || + strncmp(normalized, "iso-latin-1-", sizeof("iso-latin-1-") - 1) == 0) { + canonical = "iso-8859-1"; + } + if (canonical != start) { + encoding_len = strlen(canonical); + } + *encoding = _PyTok_CopyBytes(canonical, encoding_len); + if (*encoding == NULL) { + return -1; + } + *scan_next = 0; + return 0; + } + return 0; +} + +_PyTok_EncodingResult +_PyTok_DetectEncoding(struct tok_state *tok, const _PyTok_Chunk *first, + const _PyTok_Chunk *second, int final, + Py_ssize_t *bom_len) +{ + int bom = first->len >= UTF8_BOM_LENGTH && + memcmp(first->data, UTF8_BOM, UTF8_BOM_LENGTH) == 0; + *bom_len = bom ? UTF8_BOM_LENGTH : 0; + + char *cookie = NULL; + int scan_next = 0; + int cookie_line = 1; + const char *first_data = first->data + *bom_len; + Py_ssize_t first_len = first->len - *bom_len; + if (find_cookie(first_data, first_len, &cookie, &scan_next) < 0) { + return _PYTOK_ENCODING_ERROR; + } + if (cookie == NULL && scan_next && second != NULL) { + if (find_cookie(second->data, second->len, &cookie, &scan_next) < 0) { + return _PYTOK_ENCODING_ERROR; + } + cookie_line = 2; + } + else if (cookie == NULL && scan_next && !final) { + return _PYTOK_ENCODING_NEED_SECOND_LINE; + } + + if (cookie == NULL) { + if (bom && _PyTok_SetEncoding(tok, "utf-8") < 0) { + return _PYTOK_ENCODING_ERROR; + } + return _PYTOK_ENCODING_DONE; + } + if (bom && strcmp(cookie, "utf-8") != 0) { + const _PyTok_Chunk *line = cookie_line == 2 ? second : first; + const char *line_data = line->data + (cookie_line == 1 ? *bom_len : 0); + Py_ssize_t line_len = line->len - (cookie_line == 1 ? *bom_len : 0); + int end_col = (int)Py_MIN(line_len, INT_MAX); + if (end_col > 0 && (line_data[end_col - 1] == '\n' || + line_data[end_col - 1] == '\r')) { + end_col--; + } + _PyTokenizer_syntaxerror_at( + tok, line_data, 0, cookie_line, 0, end_col, + "encoding problem: %s with BOM", cookie); + PyMem_Free(cookie); + return _PYTOK_ENCODING_ERROR; + } + PyMem_Free(tok->reader->encoding); + tok->reader->encoding = cookie; + return _PYTOK_ENCODING_DONE; +} + +int +_PyTok_DecodeOnce(struct tok_state *tok, _PyTok_Chunk *chunk, + const char *encoding, const char *errors) +{ + PyObject *unicode = PyUnicode_Decode( + chunk->data, chunk->len, encoding, errors); + if (unicode == NULL) { + tok->done = PyErr_ExceptionMatches(PyExc_MemoryError) + ? E_NOMEM : E_DECODE; + return -1; + } + return chunk_set_unicode(tok, chunk, unicode, 0); +} + +static Py_ssize_t +raw_line_length(const char *data, Py_ssize_t len) +{ + for (Py_ssize_t i = 0; i < len; i++) { + if (data[i] == '\n') { + return i + 1; + } + if (data[i] == '\r') { + return i + 1 < len && data[i + 1] == '\n' ? i + 2 : i + 1; + } + } + return len; +} + +static int +store_prepared_source(struct tok_state *tok, const char *data, Py_ssize_t len, + int preserve_crlf, int add_final_newline) +{ + Py_ssize_t pos = 0; + while (pos < len) { + Py_ssize_t raw_line_len; + if (preserve_crlf) { + const char *newline = memchr(data + pos, '\n', len - pos); + raw_line_len = newline == NULL + ? len - pos : newline - data - pos + 1; + } + else { + raw_line_len = raw_line_length(data + pos, len - pos); + } + int terminated = preserve_crlf + ? data[pos + raw_line_len - 1] == '\n' + : data[pos + raw_line_len - 1] == '\n' || + data[pos + raw_line_len - 1] == '\r'; + int add_newline = add_final_newline && + pos + raw_line_len == len && !terminated; + const char *line = data + pos; + // raw_line_length stops at the first CR or LF, so any CR is in + // the line terminator. + Py_ssize_t terminator_len = 0; + if (!preserve_crlf) { + if (line[raw_line_len - 1] == '\r') { + terminator_len = 1; + } + else if (raw_line_len > 1 && line[raw_line_len - 2] == '\r') { + terminator_len = 2; + } + } + _PyTok_Off appended; + if (terminator_len || add_newline) { + appended = _PyTok_SourceAppendLineWithNewline( + &tok->source, line, raw_line_len - terminator_len); + } + else { + appended = _PyTok_SourceAppendLine(&tok->source, line, raw_line_len); + } + if (appended < 0) { + tok->done = PyErr_ExceptionMatches(PyExc_MemoryError) + ? E_NOMEM : E_ERROR; + return -1; + } + tok->reader->prepared_final_newline = add_newline; + pos += raw_line_len; + } + // Partial input includes the newline submitted by the next Enter key. + // A final CR pairs with that newline instead of starting a blank line. + if (add_final_newline == _PyTokenizer_APPEND_NEWLINE && + !tok->reader->prepared_final_newline && + (len == 0 || data[len - 1] != '\r')) + { + if (_PyTok_SourceAppendLine(&tok->source, "\n", 1) < 0) { + return -1; + } + tok->reader->prepared_final_newline = _PyTokenizer_APPEND_NEWLINE; + } + return 0; +} + +int +_PyTok_PrepareString(struct tok_state *tok, const char *input, int utf8_only, + int exec_input, int preserve_crlf) +{ + Py_ssize_t raw_len = strlen(input); + char *raw = (char *)input; + + if (utf8_only) { + if (_PyTok_SetEncoding(tok, "utf-8") < 0) { + return -1; + } + } + else { + Py_ssize_t first_original_len = raw_line_length(raw, raw_len); + _PyTok_Chunk first = { + .data = raw, + .len = first_original_len, + .ownership = _PYTOK_CHUNK_BORROWED, + }; + _PyTok_Chunk second = {0}; + int have_second = first_original_len < raw_len; + if (have_second) { + second.data = raw + first_original_len; + second.len = raw_line_length(second.data, + raw_len - first_original_len); + } + Py_ssize_t bom_len; + _PyTok_EncodingResult detection = _PyTok_DetectEncoding( + tok, &first, have_second ? &second : NULL, 1, &bom_len); + if (detection == _PYTOK_ENCODING_ERROR) { + return -1; + } + raw += bom_len; + raw_len -= bom_len; + } + + _PyTok_Chunk decoded = { + .data = raw, + .len = raw_len, + .ownership = _PYTOK_CHUNK_BORROWED, + }; + const char *encoding = tok->reader->encoding; + if (encoding != NULL && strcmp(encoding, "utf-8") != 0) { + if (_PyTok_DecodeOnce( + tok, &decoded, encoding, NULL) < 0) { + return -1; + } + } + + int stored = store_prepared_source( + tok, decoded.data, decoded.len, preserve_crlf, exec_input); + _PyTok_ChunkClear(&decoded); + if (stored < 0) { + return -1; + } + if (!utf8_only && + (encoding == NULL || strcmp(encoding, "utf-8") == 0) && + !_PyTokenizer_ensure_utf8(_PyTok_SourceData(&tok->source), tok, 1)) { + return -1; + } + return 0; +} + +int +_PyTok_StartDecoder(struct tok_state *tok, const char *errors) +{ + _PyTok_Reader *reader = tok->reader; + if (reader->encoding == NULL || reader->decoder != NULL) { + return 0; + } + if (reader->kind == _PYTOK_READER_FILE && + strcmp(reader->encoding, "utf-8") == 0) { + return 0; + } + + PyObject *codec = _PyCodec_LookupTextEncoding(reader->encoding, NULL); + if (codec != NULL) { + reader->decoder = _PyCodecInfo_GetIncrementalDecoder(codec, errors); + Py_DECREF(codec); + } + if (reader->decoder == NULL) { + tok->done = PyErr_ExceptionMatches(PyExc_MemoryError) + ? E_NOMEM : E_DECODE; + if (reader->kind == _PYTOK_READER_FILE) { + _PyTokenizer_raise_init_error( + tok->filename != NULL ? tok->filename : Py_None); + } + return -1; + } + return 0; +} + +int +_PyTok_DecodeChunk(struct tok_state *tok, _PyTok_Chunk *chunk, int final) +{ + _PyTok_Reader *reader = tok->reader; + if (reader->decoder == NULL) { + return 0; + } + int strip_bom = reader->kind == _PYTOK_READER_READLINE && + chunk->len >= UTF16_BOM_LENGTH && + (memcmp(chunk->data, UTF16_LE_BOM, UTF16_BOM_LENGTH) == 0 || + memcmp(chunk->data, UTF16_BE_BOM, UTF16_BOM_LENGTH) == 0); + PyObject *input; + if (chunk->ownership == _PYTOK_CHUNK_PYOBJECT && + PyBytes_Check(chunk->owner) && + chunk->data == PyBytes_AS_STRING(chunk->owner)) { + input = Py_NewRef(chunk->owner); + } + else { + input = PyBytes_FromStringAndSize(chunk->data, chunk->len); + } + if (input == NULL) { + tok->done = E_NOMEM; + return -1; + } + PyObject *unicode = PyObject_CallMethodObjArgs( + reader->decoder, &_Py_ID(decode), input, + final ? Py_True : Py_False, NULL); + Py_DECREF(input); + if (unicode == NULL) { + tok->done = PyErr_ExceptionMatches(PyExc_MemoryError) + ? E_NOMEM : E_DECODE; + if (reader->kind == _PYTOK_READER_FILE) { + _PyTokenizer_raise_init_error( + tok->filename != NULL ? tok->filename : Py_None); + } + return -1; + } + if (!PyUnicode_Check(unicode)) { + PyErr_Format(PyExc_TypeError, + "decoder should return a string result, not '%.200s'", + Py_TYPE(unicode)->tp_name); + Py_DECREF(unicode); + tok->done = E_DECODE; + return -1; + } + return chunk_set_unicode(tok, chunk, unicode, strip_bom); +} + +int +_PyTok_DecoderHasBufferedInput(struct tok_state *tok) +{ + if (tok->reader->decoder == NULL) { + return 0; + } + PyObject *state = PyObject_CallMethodNoArgs( + tok->reader->decoder, &_Py_ID(getstate)); + if (state == NULL) { + tok->done = PyErr_ExceptionMatches(PyExc_MemoryError) + ? E_NOMEM : E_DECODE; + return -1; + } + if (!PyTuple_Check(state) || PyTuple_GET_SIZE(state) != 2 || + !PyBytes_Check(PyTuple_GET_ITEM(state, 0)) || + !PyLong_Check(PyTuple_GET_ITEM(state, 1))) { + Py_DECREF(state); + PyErr_SetString(PyExc_TypeError, + "incremental decoder getstate() must return (bytes, int)"); + tok->done = E_DECODE; + return -1; + } + int pending = PyBytes_GET_SIZE(PyTuple_GET_ITEM(state, 0)) != 0; + Py_DECREF(state); + return pending; +} diff --git a/Parser/tokenizer/file_tokenizer.c b/Parser/tokenizer/file_tokenizer.c deleted file mode 100644 index a11702557a07af3..000000000000000 --- a/Parser/tokenizer/file_tokenizer.c +++ /dev/null @@ -1,494 +0,0 @@ -#include "Python.h" -#include "pycore_call.h" // _PyObject_CallNoArgs() -#include "pycore_fileutils.h" // _Py_UniversalNewlineFgetsWithSize() -#include "pycore_runtime.h" // _Py_ID() - -#include "errcode.h" // E_NOMEM - -#ifdef HAVE_UNISTD_H -# include // lseek(), read() -#endif - -#include "helpers.h" -#include "../lexer/state.h" -#include "../lexer/lexer.h" -#include "../lexer/buffer.h" - - -static int -tok_concatenate_interactive_new_line(struct tok_state *tok, const char *line) { - assert(tok->fp_interactive); - - if (!line) { - return 0; - } - - Py_ssize_t current_size = tok->interactive_src_end - tok->interactive_src_start; - Py_ssize_t line_size = strlen(line); - char last_char = line[line_size > 0 ? line_size - 1 : line_size]; - if (last_char != '\n') { - line_size += 1; - } - char* new_str = tok->interactive_src_start; - - new_str = PyMem_Realloc(new_str, current_size + line_size + 1); - if (!new_str) { - if (tok->interactive_src_start) { - PyMem_Free(tok->interactive_src_start); - } - tok->interactive_src_start = NULL; - tok->interactive_src_end = NULL; - tok->done = E_NOMEM; - return -1; - } - strcpy(new_str + current_size, line); - tok->implicit_newline = 0; - if (last_char != '\n') { - /* Last line does not end in \n, fake one */ - new_str[current_size + line_size - 1] = '\n'; - new_str[current_size + line_size] = '\0'; - tok->implicit_newline = 1; - } - tok->interactive_src_start = new_str; - tok->interactive_src_end = new_str + current_size + line_size; - return 0; -} - -static int -tok_readline_raw(struct tok_state *tok) -{ - do { - if (!_PyLexer_tok_reserve_buf(tok, BUFSIZ)) { - return 0; - } - int n_chars = (int)(tok->end - tok->inp); - size_t line_size = 0; - char *line = _Py_UniversalNewlineFgetsWithSize(tok->inp, n_chars, tok->fp, NULL, &line_size); - if (line == NULL) { - return 1; - } - if (tok->fp_interactive && - tok_concatenate_interactive_new_line(tok, line) == -1) { - return 0; - } - tok->inp += line_size; - if (tok->inp == tok->buf) { - return 0; - } - } while (tok->inp[-1] != '\n'); - return 1; -} - -static int -tok_readline_recode(struct tok_state *tok) { - PyObject *line; - const char *buf; - Py_ssize_t buflen; - line = tok->decoding_buffer; - if (line == NULL) { - line = PyObject_CallNoArgs(tok->decoding_readline); - if (line == NULL) { - _PyTokenizer_error_ret(tok); - goto error; - } - } - else { - tok->decoding_buffer = NULL; - } - buf = PyUnicode_AsUTF8AndSize(line, &buflen); - if (buf == NULL) { - _PyTokenizer_error_ret(tok); - goto error; - } - // Make room for the null terminator *and* potentially - // an extra newline character that we may need to artificially - // add. - size_t buffer_size = buflen + 2; - if (!_PyLexer_tok_reserve_buf(tok, buffer_size)) { - goto error; - } - memcpy(tok->inp, buf, buflen); - tok->inp += buflen; - *tok->inp = '\0'; - if (tok->fp_interactive && - tok_concatenate_interactive_new_line(tok, buf) == -1) { - goto error; - } - Py_DECREF(line); - return 1; -error: - Py_XDECREF(line); - return 0; -} - -/* Fetch the next byte from TOK. */ -static int fp_getc(struct tok_state *tok) { - return getc(tok->fp); -} - -/* Unfetch the last byte back into TOK. */ -static void fp_ungetc(int c, struct tok_state *tok) { - ungetc(c, tok->fp); -} - -/* Set the readline function for TOK to a StreamReader's - readline function. The StreamReader is named ENC. - - This function is called from _PyTokenizer_check_bom and _PyTokenizer_check_coding_spec. - - ENC is usually identical to the future value of tok->encoding, - except for the (currently unsupported) case of UTF-16. - - Return 1 on success, 0 on failure. */ -static int -fp_setreadl(struct tok_state *tok, const char* enc) -{ - PyObject *readline, *open, *stream; - int fd; - long pos; - - fd = fileno(tok->fp); - /* Due to buffering the file offset for fd can be different from the file - * position of tok->fp. If tok->fp was opened in text mode on Windows, - * its file position counts CRLF as one char and can't be directly mapped - * to the file offset for fd. Instead we step back one byte and read to - * the end of line.*/ - pos = ftell(tok->fp); - if (pos == -1 || - lseek(fd, (off_t)(pos > 0 ? pos - 1 : pos), SEEK_SET) == (off_t)-1) { - PyErr_SetFromErrnoWithFilename(PyExc_OSError, NULL); - return 0; - } - - open = PyImport_ImportModuleAttrString("io", "open"); - if (open == NULL) { - return 0; - } - stream = PyObject_CallFunction(open, "isisOOO", - fd, "r", -1, enc, Py_None, Py_None, Py_False); - Py_DECREF(open); - if (stream == NULL) { - return 0; - } - - readline = PyObject_GetAttr(stream, &_Py_ID(readline)); - Py_DECREF(stream); - if (readline == NULL) { - return 0; - } - Py_XSETREF(tok->decoding_readline, readline); - - if (pos > 0) { - PyObject *bufobj = _PyObject_CallNoArgs(readline); - if (bufobj == NULL) { - return 0; - } - Py_DECREF(bufobj); - } - - return 1; -} - -static int -tok_underflow_interactive(struct tok_state *tok) { - if (tok->interactive_underflow == IUNDERFLOW_STOP) { - tok->done = E_INTERACT_STOP; - return 1; - } - char *newtok = PyOS_Readline(tok->fp ? tok->fp : stdin, stdout, tok->prompt); - if (newtok != NULL) { - char *translated = _PyTokenizer_translate_newlines(newtok, 0, 0, tok); - PyMem_Free(newtok); - if (translated == NULL) { - return 0; - } - newtok = translated; - } - if (tok->encoding && newtok && *newtok) { - /* Recode to UTF-8 */ - Py_ssize_t buflen; - const char* buf; - PyObject *u = _PyTokenizer_translate_into_utf8(newtok, tok->encoding); - PyMem_Free(newtok); - if (u == NULL) { - tok->done = E_DECODE; - return 0; - } - buflen = PyBytes_GET_SIZE(u); - buf = PyBytes_AS_STRING(u); - newtok = PyMem_Malloc(buflen+1); - if (newtok == NULL) { - Py_DECREF(u); - tok->done = E_NOMEM; - return 0; - } - strcpy(newtok, buf); - Py_DECREF(u); - } - if (tok->fp_interactive && - tok_concatenate_interactive_new_line(tok, newtok) == -1) { - PyMem_Free(newtok); - return 0; - } - if (tok->nextprompt != NULL) { - tok->prompt = tok->nextprompt; - } - if (newtok == NULL) { - tok->done = E_INTR; - } - else if (*newtok == '\0') { - PyMem_Free(newtok); - tok->done = E_EOF; - } - else if (tok->start != NULL) { - Py_ssize_t cur_multi_line_start = tok->multi_line_start - tok->buf; - _PyLexer_remember_fstring_buffers(tok); - size_t size = strlen(newtok); - ADVANCE_LINENO(); - if (!_PyLexer_tok_reserve_buf(tok, size + 1)) { - PyMem_Free(tok->buf); - tok->buf = NULL; - PyMem_Free(newtok); - return 0; - } - memcpy(tok->cur, newtok, size + 1); - PyMem_Free(newtok); - tok->inp += size; - tok->multi_line_start = tok->buf + cur_multi_line_start; - _PyLexer_restore_fstring_buffers(tok); - } - else { - _PyLexer_remember_fstring_buffers(tok); - ADVANCE_LINENO(); - PyMem_Free(tok->buf); - tok->buf = newtok; - tok->cur = tok->buf; - tok->line_start = tok->buf; - tok->inp = strchr(tok->buf, '\0'); - tok->end = tok->inp + 1; - _PyLexer_restore_fstring_buffers(tok); - } - if (tok->done != E_OK) { - if (tok->prompt != NULL) { - PySys_WriteStderr("\n"); - } - return 0; - } - - if (tok->tok_mode_stack_index && !_PyLexer_update_ftstring_expr(tok, 0)) { - return 0; - } - return 1; -} - -static int -tok_underflow_file(struct tok_state *tok) -{ - if (tok->decoding_state == STATE_INIT) { - /* We have not yet determined the encoding. - If an encoding is found, use the file-pointer - reader functions from now on. */ - if (!_PyTokenizer_check_bom(fp_getc, fp_ungetc, fp_setreadl, tok)) { - _PyTokenizer_error_ret(tok); - return 0; - } - assert(tok->decoding_state != STATE_INIT); - } - int raw = tok->decoding_readline == NULL; - if (raw && tok->decoding_state != STATE_NORMAL) { - /* Keep the first line in the buffer to validate it later if - * the encoding has not yet been determined. */ - } - else if (tok->start == NULL && !INSIDE_FSTRING(tok)) { - tok->cur = tok->inp = tok->buf; - } - /* Read until '\n' or EOF */ - if (!raw) { - /* We already have a codec associated with this input. */ - if (!tok_readline_recode(tok)) { - return 0; - } - } - else { - /* We want a 'raw' read. */ - if (!tok_readline_raw(tok)) { - return 0; - } - } - if (tok->inp == tok->cur) { - tok->done = E_EOF; - return 0; - } - tok->implicit_newline = 0; - if (tok->inp[-1] != '\n') { - assert(tok->inp + 1 < tok->end); - /* Last line does not end in \n, fake one */ - *tok->inp++ = '\n'; - *tok->inp = '\0'; - tok->implicit_newline = 1; - } - - if (tok->tok_mode_stack_index && !_PyLexer_update_ftstring_expr(tok, 0)) { - return 0; - } - - ADVANCE_LINENO(); - if (tok->decoding_state != STATE_NORMAL) { - if (!_PyTokenizer_check_coding_spec(tok->cur, strlen(tok->cur), - tok, fp_setreadl)) - { - return 0; - } - if (tok->lineno >= 2) { - tok->decoding_state = STATE_NORMAL; - } - } - if (raw && tok->decoding_state == STATE_NORMAL) { - const char *line = tok->lineno <= 2 ? tok->buf : tok->cur; - int lineno = tok->lineno <= 2 ? 1 : tok->lineno; - if (!tok->encoding) { - /* The default encoding is UTF-8, so make sure we don't have any - non-UTF-8 sequences in it. */ - if (!_PyTokenizer_ensure_utf8(line, tok, lineno)) { - _PyTokenizer_error_ret(tok); - return 0; - } - } - else { - PyObject *tmp = PyUnicode_Decode(line, strlen(line), - tok->encoding, NULL); - if (tmp == NULL) { - _PyTokenizer_error_ret(tok); - return 0; - } - Py_DECREF(tmp); - } - } - assert(tok->done == E_OK); - return tok->done == E_OK; -} - -/* Set up tokenizer for file */ -struct tok_state * -_PyTokenizer_FromFile(FILE *fp, const char* enc, - const char *ps1, const char *ps2) -{ - struct tok_state *tok = _PyTokenizer_tok_new(); - if (tok == NULL) - return NULL; - if ((tok->buf = (char *)PyMem_Malloc(BUFSIZ)) == NULL) { - _PyTokenizer_Free(tok); - PyErr_NoMemory(); - return NULL; - } - tok->cur = tok->inp = tok->buf; - tok->end = tok->buf + BUFSIZ; - tok->fp = fp; - tok->prompt = ps1; - tok->nextprompt = ps2; - if (ps1 || ps2) { - tok->underflow = &tok_underflow_interactive; - } else { - tok->underflow = &tok_underflow_file; - } - if (enc != NULL) { - /* Must copy encoding declaration since it - gets copied into the parse tree. */ - tok->encoding = _PyTokenizer_new_string(enc, strlen(enc), tok); - if (!tok->encoding) { - _PyTokenizer_Free(tok); - return NULL; - } - tok->decoding_state = STATE_NORMAL; - } - return tok; -} - -#if defined(__wasi__) || (defined(__EMSCRIPTEN__) && (__EMSCRIPTEN_major__ >= 3)) -// fdopen() with borrowed fd. WASI does not provide dup() and Emscripten's -// dup() emulation with open() is slow. -typedef union { - void *cookie; - int fd; -} borrowed; - -static ssize_t -borrow_read(void *cookie, char *buf, size_t size) -{ - borrowed b = {.cookie = cookie}; - return read(b.fd, (void *)buf, size); -} - -static FILE * -fdopen_borrow(int fd) { - // supports only reading. seek fails. close and write are no-ops. - cookie_io_functions_t io_cb = {borrow_read, NULL, NULL, NULL}; - borrowed b = {.fd = fd}; - return fopencookie(b.cookie, "r", io_cb); -} -#else -static FILE * -fdopen_borrow(int fd) { - fd = _Py_dup(fd); - if (fd < 0) { - return NULL; - } - return fdopen(fd, "r"); -} -#endif - -/* Get the encoding of a Python file. Check for the coding cookie and check if - the file starts with a BOM. - - _PyTokenizer_FindEncodingFilename() returns NULL when it can't find the - encoding in the first or second line of the file (in which case the encoding - should be assumed to be UTF-8). - - The char* returned is malloc'ed via PyMem_Malloc() and thus must be freed - by the caller. */ -char * -_PyTokenizer_FindEncodingFilename(int fd, PyObject *filename) -{ - struct tok_state *tok; - FILE *fp; - char *encoding = NULL; - - fp = fdopen_borrow(fd); - if (fp == NULL) { - return NULL; - } - tok = _PyTokenizer_FromFile(fp, NULL, NULL, NULL); - if (tok == NULL) { - fclose(fp); - return NULL; - } - if (filename != NULL) { - tok->filename = Py_NewRef(filename); - } - else { - tok->filename = PyUnicode_FromString(""); - if (tok->filename == NULL) { - fclose(fp); - _PyTokenizer_Free(tok); - return encoding; - } - } - struct token token; - // We don't want to report warnings here because it could cause infinite recursion - // if fetching the encoding shows a warning. - tok->report_warnings = 0; - while (tok->lineno < 2 && tok->done == E_OK) { - _PyToken_Init(&token); - _PyTokenizer_Get(tok, &token); - _PyToken_Free(&token); - } - fclose(fp); - if (tok->encoding) { - encoding = (char *)PyMem_Malloc(strlen(tok->encoding) + 1); - if (encoding) { - strcpy(encoding, tok->encoding); - } - } - _PyTokenizer_Free(tok); - return encoding; -} diff --git a/Parser/tokenizer/helpers.c b/Parser/tokenizer/helpers.c index 62b0971d418c396..c39e6756476b97c 100644 --- a/Parser/tokenizer/helpers.c +++ b/Parser/tokenizer/helpers.c @@ -9,8 +9,23 @@ /* ############## ERRORS ############## */ +/* Convert a 1-based column in bytes into a 1-based column in characters. + The line is UTF-8 encoded, so it is enough to skip continuation bytes. */ static int -_syntaxerror_range(struct tok_state *tok, const char *format, +byte_col_to_char_col(const char *line, int byte_col) +{ + int char_col = 1; + for (int i = 0; i < byte_col - 1; i++) { + if ((line[i] & 0xC0) != 0x80) { + char_col++; + } + } + return char_col; +} + +static int +_syntaxerror_range(struct tok_state *tok, const char *line, + Py_ssize_t cursor, int lineno, const char *format, int col_offset, int end_col_offset, va_list vargs) { @@ -26,7 +41,7 @@ _syntaxerror_range(struct tok_state *tok, const char *format, goto error; } - errtext = PyUnicode_DecodeUTF8(tok->line_start, tok->cur - tok->line_start, + errtext = PyUnicode_DecodeUTF8(line, cursor, "replace"); if (!errtext) { goto error; @@ -35,14 +50,20 @@ _syntaxerror_range(struct tok_state *tok, const char *format, if (col_offset == -1) { col_offset = (int)PyUnicode_GET_LENGTH(errtext); } + else if (col_offset > 0) { + col_offset = byte_col_to_char_col(line, col_offset); + } if (end_col_offset == -1) { end_col_offset = col_offset; } + else if (end_col_offset > 0) { + end_col_offset = byte_col_to_char_col(line, end_col_offset); + } - Py_ssize_t line_len = strcspn(tok->line_start, "\n"); - if (line_len != tok->cur - tok->line_start) { + Py_ssize_t line_len = strcspn(line, "\n"); + if (line_len != cursor) { Py_DECREF(errtext); - errtext = PyUnicode_DecodeUTF8(tok->line_start, line_len, + errtext = PyUnicode_DecodeUTF8(line, line_len, "replace"); } if (!errtext) { @@ -51,8 +72,8 @@ _syntaxerror_range(struct tok_state *tok, const char *format, args = Py_BuildValue("(O(OiiNii))", errmsg, tok->filename ? tok->filename : Py_None, - tok->lineno, col_offset, errtext, - tok->lineno, end_col_offset); + lineno, col_offset, errtext, + lineno, end_col_offset); if (args) { PyErr_SetObject(PyExc_SyntaxError, args); Py_DECREF(args); @@ -70,7 +91,9 @@ _PyTokenizer_syntaxerror(struct tok_state *tok, const char *format, ...) // These errors are cleaned on startup. Todo: Fix it. va_list vargs; va_start(vargs, format); - int ret = _syntaxerror_range(tok, format, -1, -1, vargs); + int ret = _syntaxerror_range( + tok, _PyTok_SourcePointer(&tok->source, tok->line_start), + tok->cur - tok->line_start, tok->lineno, format, -1, -1, vargs); va_end(vargs); return ret; } @@ -82,7 +105,24 @@ _PyTokenizer_syntaxerror_known_range(struct tok_state *tok, { va_list vargs; va_start(vargs, format); - int ret = _syntaxerror_range(tok, format, col_offset, end_col_offset, vargs); + int ret = _syntaxerror_range( + tok, _PyTok_SourcePointer(&tok->source, tok->line_start), + tok->cur - tok->line_start, tok->lineno, + format, col_offset, end_col_offset, vargs); + va_end(vargs); + return ret; +} + +int +_PyTokenizer_syntaxerror_at(struct tok_state *tok, const char *line, + Py_ssize_t cursor, int lineno, + int col_offset, int end_col_offset, + const char *format, ...) +{ + va_list vargs; + va_start(vargs, format); + int ret = _syntaxerror_range(tok, line, cursor, lineno, format, + col_offset, end_col_offset, vargs); va_end(vargs); return ret; } @@ -95,27 +135,9 @@ _PyTokenizer_indenterror(struct tok_state *tok) return ERRORTOKEN; } -char * -_PyTokenizer_error_ret(struct tok_state *tok) /* XXX */ -{ - tok->decoding_erred = 1; - if ((tok->fp != NULL || tok->readline != NULL) && tok->buf != NULL) {/* see _PyTokenizer_Free */ - PyMem_Free(tok->buf); - } - tok->buf = tok->cur = tok->inp = NULL; - tok->start = NULL; - tok->end = NULL; - tok->done = E_DECODE; - return NULL; /* as if it were EOF */ -} - int _PyTokenizer_warn_invalid_escape_sequence(struct tok_state *tok, int first_invalid_escape_char) { - if (!tok->report_warnings) { - return 0; - } - PyObject *msg = PyUnicode_FromFormat( "\"\\%c\" is an invalid escape sequence. " "Such sequences will not work in the future. " @@ -201,10 +223,6 @@ _PyTokenizer_raise_init_error(PyObject *filename) int _PyTokenizer_parser_warn(struct tok_state *tok, PyObject *category, const char *format, ...) { - if (!tok->report_warnings) { - return 0; - } - PyObject *errmsg; va_list vargs; va_start(vargs, format); @@ -234,261 +252,6 @@ _PyTokenizer_parser_warn(struct tok_state *tok, PyObject *category, const char * } -/* ############## STRING MANIPULATION ############## */ - -char * -_PyTokenizer_new_string(const char *s, Py_ssize_t len, struct tok_state *tok) -{ - char* result = (char *)PyMem_Malloc(len + 1); - if (!result) { - tok->done = E_NOMEM; - PyErr_NoMemory(); - return NULL; - } - memcpy(result, s, len); - result[len] = '\0'; - return result; -} - -PyObject * -_PyTokenizer_translate_into_utf8(const char* str, const char* enc) { - PyObject *utf8; - PyObject* buf = PyUnicode_Decode(str, strlen(str), enc, NULL); - if (buf == NULL) - return NULL; - utf8 = PyUnicode_AsUTF8String(buf); - Py_DECREF(buf); - return utf8; -} - -char * -_PyTokenizer_translate_newlines(const char *s, int exec_input, int preserve_crlf, - struct tok_state *tok) { - int skip_next_lf = 0; - size_t needed_length = strlen(s) + 2, final_length; - char *buf, *current; - char c = '\0'; - buf = PyMem_Malloc(needed_length); - if (buf == NULL) { - tok->done = E_NOMEM; - PyErr_NoMemory(); - return NULL; - } - for (current = buf; *s; s++, current++) { - c = *s; - if (skip_next_lf) { - skip_next_lf = 0; - if (c == '\n') { - c = *++s; - if (!c) - break; - } - } - if (!preserve_crlf && c == '\r') { - skip_next_lf = 1; - c = '\n'; - } - *current = c; - } - /* If this is exec input, add a newline to the end of the string if - there isn't one already. */ - if (exec_input && c != '\n' && c != '\0') { - *current = '\n'; - current++; - } - *current = '\0'; - final_length = current - buf + 1; - if (final_length < needed_length && final_length) { - /* should never fail */ - char* result = PyMem_Realloc(buf, final_length); - if (result == NULL) { - PyMem_Free(buf); - } - buf = result; - } - return buf; -} - -/* ############## ENCODING STUFF ############## */ - - -/* See whether the file starts with a BOM. If it does, - invoke the set_readline function with the new encoding. - Return 1 on success, 0 on failure. */ -int -_PyTokenizer_check_bom(int get_char(struct tok_state *), - void unget_char(int, struct tok_state *), - int set_readline(struct tok_state *, const char *), - struct tok_state *tok) -{ - int ch1, ch2, ch3; - ch1 = get_char(tok); - tok->decoding_state = STATE_SEEK_CODING; - if (ch1 == EOF) { - return 1; - } else if (ch1 == 0xEF) { - ch2 = get_char(tok); - if (ch2 != 0xBB) { - unget_char(ch2, tok); - unget_char(ch1, tok); - return 1; - } - ch3 = get_char(tok); - if (ch3 != 0xBF) { - unget_char(ch3, tok); - unget_char(ch2, tok); - unget_char(ch1, tok); - return 1; - } - } else { - unget_char(ch1, tok); - return 1; - } - if (tok->encoding != NULL) - PyMem_Free(tok->encoding); - tok->encoding = _PyTokenizer_new_string("utf-8", 5, tok); - if (!tok->encoding) - return 0; - /* No need to set_readline: input is already utf-8 */ - return 1; -} - -static const char * -get_normal_name(const char *s) /* for utf-8 and latin-1 */ -{ - char buf[13]; - int i; - for (i = 0; i < 12; i++) { - int c = s[i]; - if (c == '\0') - break; - else if (c == '_') - buf[i] = '-'; - else - buf[i] = Py_TOLOWER(c); - } - buf[i] = '\0'; - if (strcmp(buf, "utf-8") == 0 || - strncmp(buf, "utf-8-", 6) == 0) - return "utf-8"; - else if (strcmp(buf, "latin-1") == 0 || - strcmp(buf, "iso-8859-1") == 0 || - strcmp(buf, "iso-latin-1") == 0 || - strncmp(buf, "latin-1-", 8) == 0 || - strncmp(buf, "iso-8859-1-", 11) == 0 || - strncmp(buf, "iso-latin-1-", 12) == 0) - return "iso-8859-1"; - else - return s; -} - -/* Return the coding spec in S, or NULL if none is found. */ -static int -get_coding_spec(const char *s, char **spec, Py_ssize_t size, struct tok_state *tok) -{ - Py_ssize_t i; - *spec = NULL; - /* Coding spec must be in a comment, and that comment must be - * the only statement on the source code line. */ - for (i = 0; i < size - 6; i++) { - if (s[i] == '#') - break; - if (s[i] != ' ' && s[i] != '\t' && s[i] != '\014') - return 1; - } - for (; i < size - 6; i++) { /* XXX inefficient search */ - const char* t = s + i; - if (memcmp(t, "coding", 6) == 0) { - const char* begin = NULL; - t += 6; - if (t[0] != ':' && t[0] != '=') - continue; - do { - t++; - } while (t[0] == ' ' || t[0] == '\t'); - - begin = t; - while (Py_ISALNUM(t[0]) || - t[0] == '-' || t[0] == '_' || t[0] == '.') - t++; - - if (begin < t) { - char* r = _PyTokenizer_new_string(begin, t - begin, tok); - const char* q; - if (!r) - return 0; - q = get_normal_name(r); - if (r != q) { - PyMem_Free(r); - r = _PyTokenizer_new_string(q, strlen(q), tok); - if (!r) - return 0; - } - *spec = r; - break; - } - } - } - return 1; -} - -/* Check whether the line contains a coding spec. If it does, - invoke the set_readline function for the new encoding. - This function receives the tok_state and the new encoding. - Return 1 on success, 0 on failure. */ -int -_PyTokenizer_check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok, - int set_readline(struct tok_state *, const char *)) -{ - char *cs; - if (tok->cont_line) { - /* It's a continuation line, so it can't be a coding spec. */ - tok->decoding_state = STATE_NORMAL; - return 1; - } - if (!get_coding_spec(line, &cs, size, tok)) { - return 0; - } - if (!cs) { - Py_ssize_t i; - for (i = 0; i < size; i++) { - if (line[i] == '#' || line[i] == '\n' || line[i] == '\r') - break; - if (line[i] != ' ' && line[i] != '\t' && line[i] != '\014') { - /* Stop checking coding spec after a line containing - * anything except a comment. */ - tok->decoding_state = STATE_NORMAL; - break; - } - } - return 1; - } - tok->decoding_state = STATE_NORMAL; - if (tok->encoding == NULL) { - assert(tok->decoding_readline == NULL); - if (strcmp(cs, "utf-8") != 0 && !set_readline(tok, cs)) { - _PyTokenizer_raise_init_error(tok->filename); - _PyTokenizer_error_ret(tok); - PyMem_Free(cs); - return 0; - } - tok->encoding = cs; - } else { /* then, compare cs with BOM */ - if (strcmp(tok->encoding, cs) != 0) { - tok->line_start = line; - tok->cur = (char *)line; - assert(size <= INT_MAX); - _PyTokenizer_syntaxerror_known_range(tok, 0, (int)size, - "encoding problem: %s with BOM", cs); - PyMem_Free(cs); - _PyTokenizer_error_ret(tok); - return 0; - } - PyMem_Free(cs); - } - return 1; -} - /* Check whether the characters at s start a valid UTF-8 sequence. Return the number of characters forming the sequence if yes, 0 if not. The special cases match @@ -559,26 +322,21 @@ _PyTokenizer_ensure_utf8(const char *line, struct tok_state *tok, int lineno) const char *badchar = NULL; const char *c; int length; - int col_offset = 0; const char *line_start = line; for (c = line; *c; c += length) { if (!(length = valid_utf8((const unsigned char *)c))) { badchar = c; break; } - col_offset++; if (*c == '\n') { lineno++; - col_offset = 0; line_start = c + 1; } } if (badchar) { - tok->lineno = lineno; - tok->line_start = line_start; - tok->cur = (char *)badchar; - _PyTokenizer_syntaxerror_known_range(tok, - col_offset + 1, col_offset + 1, + _PyTokenizer_syntaxerror_at( + tok, line_start, badchar - line_start + 1, lineno, + -1, -1, "Non-UTF-8 code starting with '\\x%.2x'" "%s%V on line %i, " "but no encoding declared; " @@ -621,12 +379,4 @@ _PyTokenizer_print_escape(FILE *f, const char *s, Py_ssize_t size) } putc('"', f); } - -void -_PyTokenizer_tok_dump(int type, char *start, char *end) -{ - fprintf(stderr, "%s", _PyParser_TokenNames[type]); - if (type == NAME || type == NUMBER || type == STRING || type == OP) - fprintf(stderr, "(%.*s)", (int)(end - start), start); -} #endif diff --git a/Parser/tokenizer/helpers.h b/Parser/tokenizer/helpers.h index 34303999a60aff7..f33d8f55ed1d17c 100644 --- a/Parser/tokenizer/helpers.h +++ b/Parser/tokenizer/helpers.h @@ -5,33 +5,24 @@ #include "../lexer/state.h" -#define ADVANCE_LINENO() \ - tok->lineno++; \ - tok->col_offset = 0; - int _PyTokenizer_syntaxerror(struct tok_state *tok, const char *format, ...); +/* Positive range columns are 1-based byte columns. A start column of -1 + derives the character column from the reporting cursor; an end column of + -1 uses the start column. */ int _PyTokenizer_syntaxerror_known_range(struct tok_state *tok, int col_offset, int end_col_offset, const char *format, ...); +int _PyTokenizer_syntaxerror_at( + struct tok_state *tok, const char *line_start, Py_ssize_t cursor_offset, + int lineno, int col_offset, int end_col_offset, const char *format, ...); int _PyTokenizer_indenterror(struct tok_state *tok); int _PyTokenizer_warn_invalid_escape_sequence(struct tok_state *tok, int first_invalid_escape_char); int _PyTokenizer_parser_warn(struct tok_state *tok, PyObject *category, const char *format, ...); -char *_PyTokenizer_error_ret(struct tok_state *tok); -void _PyTokenizer_raise_init_error(PyObject *filename); -char *_PyTokenizer_new_string(const char *s, Py_ssize_t len, struct tok_state *tok); -char *_PyTokenizer_translate_newlines(const char *s, int exec_input, int preserve_crlf, struct tok_state *tok); -PyObject *_PyTokenizer_translate_into_utf8(const char* str, const char* enc); +void _PyTokenizer_raise_init_error(PyObject *filename); -int _PyTokenizer_check_bom(int get_char(struct tok_state *), - void unget_char(int, struct tok_state *), - int set_readline(struct tok_state *, const char *), - struct tok_state *tok); -int _PyTokenizer_check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok, - int set_readline(struct tok_state *, const char *)); int _PyTokenizer_ensure_utf8(const char *line, struct tok_state *tok, int lineno); #ifdef Py_DEBUG void _PyTokenizer_print_escape(FILE *f, const char *s, Py_ssize_t size); -void _PyTokenizer_tok_dump(int type, char *start, char *end); #endif diff --git a/Parser/tokenizer/reader.c b/Parser/tokenizer/reader.c new file mode 100644 index 000000000000000..86cec96bdcc1249 --- /dev/null +++ b/Parser/tokenizer/reader.c @@ -0,0 +1,850 @@ +#include "Python.h" +#include "pycore_fileutils.h" +#include "pycore_pystate.h" +#include "pycore_runtime.h" + +#include "errcode.h" +#include "helpers.h" +#include "reader.h" +#include "reader_internal.h" +#include "../lexer/state.h" + +#define READER_BUFFER_GROWTH_FACTOR 2 + +#ifdef HAVE_UNISTD_H +# include +#endif + +static inline int +reader_is_streaming(_PyTok_ReaderKind kind) +{ + return kind == _PYTOK_READER_FILE || kind == _PYTOK_READER_READLINE; +} + +void +_PyTok_ReaderFree(struct tok_state *tok) +{ + _PyTok_Reader *reader = tok->reader; + if (reader == NULL) { + return; + } + Py_XDECREF(reader->readline); + Py_XDECREF(reader->decoder); + for (int i = 0; + i < (int)Py_ARRAY_LENGTH(reader->prefetched_lines); i++) { + _PyTok_ChunkClear(&reader->prefetched_lines[i]); + } + PyMem_Free(reader->encoding); + PyMem_Free(reader->file_buffer); + PyMem_Free(reader->decoded); + PyMem_Free(reader); + tok->reader = NULL; +} + +int +_PyTokenizer_Traverse(struct tok_state *tok, visitproc visit, void *arg) +{ + Py_VISIT(tok->filename); + Py_VISIT(tok->module); + _PyTok_Reader *reader = tok->reader; + Py_VISIT(reader->readline); + Py_VISIT(reader->decoder); + for (int i = 0; + i < (int)Py_ARRAY_LENGTH(reader->prefetched_lines); i++) { + _PyTok_Chunk *chunk = &reader->prefetched_lines[i]; + if (chunk->ownership == _PYTOK_CHUNK_PYOBJECT) { + Py_VISIT(chunk->owner); + } + } + return 0; +} + +int +_PyTok_ReserveBuffer(char **buffer, Py_ssize_t *capacity, Py_ssize_t needed, + Py_ssize_t initial_capacity) +{ + assert(initial_capacity > 0); + if (needed <= *capacity) { + return 0; + } + // Grow geometrically to avoid reallocating for every longer line. + Py_ssize_t cap = *capacity > 0 ? *capacity : initial_capacity; + while (cap < needed) { + if (cap > PY_SSIZE_T_MAX / READER_BUFFER_GROWTH_FACTOR) { + cap = needed; + break; + } + cap *= READER_BUFFER_GROWTH_FACTOR; + } + char *resized = PyMem_Realloc(*buffer, cap); + if (resized == NULL) { + PyErr_NoMemory(); + return -1; + } + *buffer = resized; + *capacity = cap; + return 0; +} + +static int +append_decoded(_PyTok_Reader *reader, const char *data, Py_ssize_t len) +{ + if (len == 0) { + return 0; + } + if (reader->decoded_pos > 0) { + Py_ssize_t remaining = reader->decoded_len - reader->decoded_pos; + memmove(reader->decoded, reader->decoded + reader->decoded_pos, + (size_t)remaining); + reader->decoded_scan -= reader->decoded_pos; + reader->decoded_pos = 0; + reader->decoded_len = remaining; + } + if (len < 0 || reader->decoded_len > PY_SSIZE_T_MAX - len - 1 || + _PyTok_ReserveBuffer(&reader->decoded, &reader->decoded_cap, + reader->decoded_len + len + 1, BUFSIZ) < 0) { + PyErr_NoMemory(); + return -1; + } + memcpy(reader->decoded + reader->decoded_len, data, (size_t)len); + reader->decoded_len += len; + reader->decoded[reader->decoded_len] = '\0'; + return 0; +} + +static int +append_implicit_newline(_PyTok_Reader *reader) +{ + if (reader->decoded_pos == reader->decoded_len || + reader->decoded[reader->decoded_len - 1] == '\n') { + return 0; + } + if (append_decoded(reader, "\n", 1) < 0) { + return -1; + } + reader->decoded_tail_is_implicit = 1; + return 0; +} + +static int +pop_decoded_line(_PyTok_Reader *reader, _PyTok_Chunk *chunk) +{ + assert(reader->decoded_pos >= 0 && reader->decoded_pos <= reader->decoded_len); + assert(reader->decoded_scan >= reader->decoded_pos && + reader->decoded_scan <= reader->decoded_len); + if (reader->decoded_pos == reader->decoded_len) { + return 0; + } + char *start = reader->decoded + reader->decoded_pos; + // Previously scanned bytes cannot contain a newline. + char *newline = memchr(reader->decoded + reader->decoded_scan, '\n', + reader->decoded_len - reader->decoded_scan); + if (newline == NULL) { + reader->decoded_scan = reader->decoded_len; + return 0; + } + Py_ssize_t len = newline - start + 1; + chunk->data = start; + chunk->len = len; + chunk->ownership = _PYTOK_CHUNK_BORROWED; + reader->decoded_pos += len; + reader->decoded_scan = reader->decoded_pos; + chunk->implicit_newline = reader->decoded_pos == reader->decoded_len && + reader->decoded_tail_is_implicit; + if (reader->decoded_pos == reader->decoded_len) { + reader->decoded_pos = reader->decoded_len = 0; + reader->decoded_scan = 0; + reader->decoded_tail_is_implicit = 0; + } + return 1; +} + +static int +chunk_is_line(const _PyTok_Chunk *chunk) +{ + if (chunk->len == 0 || chunk->data[chunk->len - 1] != '\n') { + return 0; + } + return memchr(chunk->data, '\n', chunk->len - 1) == NULL; +} + +static _PyTok_ReadResult +next_prepared(struct tok_state *tok, _PyTok_Chunk *chunk) +{ + if (tok->lineno >= tok->source.nlines) { + return _PYTOK_READ_EOF; + } + _PyTok_Span tail = {tok->inp, tok->source.base_offset + tok->source.len}; + _PyTok_Off newline = _PyTok_SourceFindByte(&tok->source, tail, '\n'); + _PyTok_Span line = {tail.start, newline >= 0 ? newline + 1 : tail.end}; + chunk->data = (char *)_PyTok_SourceSpanView( + &tok->source, line, &chunk->len); + chunk->ownership = _PYTOK_CHUNK_BORROWED; + chunk->implicit_newline = line.end == tail.end + ? tok->reader->prepared_final_newline : 0; + return _PYTOK_READ_LINE; +} + +static _PyTok_ReadResult +read_file_line(struct tok_state *tok, _PyTok_Chunk *chunk) +{ + _PyTok_Reader *reader = tok->reader; + Py_ssize_t len = 0; + for (;;) { + if (len > PY_SSIZE_T_MAX - BUFSIZ) { + PyErr_NoMemory(); + return _PYTOK_READ_ERROR; + } + if (_PyTok_ReserveBuffer(&reader->file_buffer, &reader->file_buffer_cap, + len + BUFSIZ, BUFSIZ) < 0) { + return _PYTOK_READ_ERROR; + } + int available = (int)Py_MIN(reader->file_buffer_cap - len, INT_MAX); + size_t read = 0; + char *result = _Py_UniversalNewlineFgetsWithSize( + reader->file_buffer + len, available, reader->fp, NULL, &read); + if (result == NULL) { + if (len == 0) { + return _PYTOK_READ_EOF; + } + break; + } + len += (Py_ssize_t)read; + if (len > 0 && reader->file_buffer[len - 1] == '\n') { + break; + } + } + int implicit = reader->file_buffer[len - 1] != '\n'; + chunk->data = reader->file_buffer; + chunk->len = len; + chunk->implicit_newline = implicit; + chunk->ownership = _PYTOK_CHUNK_BORROWED; + return _PYTOK_READ_LINE; +} + +static int +initialize_file(struct tok_state *tok) +{ + _PyTok_Reader *reader = tok->reader; + reader->file_initialized = 1; + if (reader->encoding != NULL) { + return _PyTok_StartDecoder(tok, "strict"); + } + + _PyTok_ReadResult result = read_file_line( + tok, &reader->prefetched_lines[0]); + if (result == _PYTOK_READ_EOF) { + reader->file_eof = 1; + return 0; + } + if (result != _PYTOK_READ_LINE) { + return -1; + } + Py_ssize_t bom_len; + _PyTok_EncodingResult detection = _PyTok_DetectEncoding( + tok, &reader->prefetched_lines[0], NULL, 0, &bom_len); + if (detection == _PYTOK_ENCODING_ERROR) { + return -1; + } + if (detection == _PYTOK_ENCODING_NEED_SECOND_LINE) { + char *first = _PyTok_CopyBytes( + reader->prefetched_lines[0].data, + reader->prefetched_lines[0].len); + if (first == NULL) { + tok->done = E_NOMEM; + return -1; + } + reader->prefetched_lines[0].data = first; + reader->prefetched_lines[0].ownership = _PYTOK_CHUNK_PYMEM; + result = read_file_line(tok, &reader->prefetched_lines[1]); + if (result == _PYTOK_READ_EOF) { + reader->file_eof = 1; + } + else if (result != _PYTOK_READ_LINE) { + return -1; + } + _PyTok_Chunk *second = reader->prefetched_lines[1].data != NULL + ? &reader->prefetched_lines[1] : NULL; + detection = _PyTok_DetectEncoding( + tok, &reader->prefetched_lines[0], second, 1, &bom_len); + if (detection == _PYTOK_ENCODING_ERROR) { + return -1; + } + } + if (bom_len != 0) { + _PyTok_Chunk *first = &reader->prefetched_lines[0]; + if (first->ownership == _PYTOK_CHUNK_PYMEM) { + memmove(first->data, first->data + bom_len, + (size_t)(first->len - bom_len)); + first->data[first->len - bom_len] = '\0'; + } + else { + first->data += bom_len; + } + first->len -= bom_len; + } + if (_PyTok_StartDecoder(tok, "strict") < 0) { + return -1; + } + return 0; +} + +static int +finalize_decoding(struct tok_state *tok) +{ + _PyTok_Reader *reader = tok->reader; + if (reader->decoder_finalized) { + return 0; + } + reader->decoder_finalized = 1; + if (reader->decoder != NULL) { + _PyTok_Chunk input = { + .data = "", + .ownership = _PYTOK_CHUNK_BORROWED, + }; + int decoded = _PyTok_DecodeChunk(tok, &input, 1); + if (decoded == 0 && + append_decoded(reader, input.data, input.len) < 0) { + tok->done = E_NOMEM; + decoded = -1; + } + _PyTok_ChunkClear(&input); + if (decoded < 0) { + return -1; + } + } + if (append_implicit_newline(reader) < 0) { + tok->done = E_NOMEM; + return -1; + } + return 0; +} + +static _PyTok_ReadResult +next_file(struct tok_state *tok, _PyTok_Chunk *chunk) +{ + _PyTok_Reader *reader = tok->reader; + if (!reader->file_initialized && initialize_file(tok) < 0) { + return _PYTOK_READ_ERROR; + } + for (;;) { + if (pop_decoded_line(reader, chunk)) { + return _PYTOK_READ_LINE; + } + _PyTok_Chunk input = {0}; + if (reader->prefetched_lines[0].data != NULL) { + input = reader->prefetched_lines[0]; + reader->prefetched_lines[0] = (_PyTok_Chunk){0}; + } + else if (reader->prefetched_lines[1].data != NULL) { + input = reader->prefetched_lines[1]; + reader->prefetched_lines[1] = (_PyTok_Chunk){0}; + } + else if (!reader->file_eof) { + _PyTok_ReadResult result = read_file_line(tok, &input); + if (result == _PYTOK_READ_ERROR) { + return result; + } + if (result == _PYTOK_READ_EOF) { + reader->file_eof = 1; + } + } + if (input.data != NULL) { + int implicit = input.implicit_newline; + if (reader->decoder == NULL && !implicit) { + *chunk = input; + return _PYTOK_READ_LINE; + } + int decoded = _PyTok_DecodeChunk(tok, &input, 0); + if (decoded == 0 && reader->decoded_pos == reader->decoded_len && + chunk_is_line(&input)) { + *chunk = input; + return _PYTOK_READ_LINE; + } + if (decoded == 0 && + append_decoded(reader, input.data, input.len) < 0) { + tok->done = E_NOMEM; + decoded = -1; + } + if (decoded == 0 && implicit) { + reader->decoded_tail_is_implicit = 1; + } + _PyTok_ChunkClear(&input); + if (decoded < 0) { + return _PYTOK_READ_ERROR; + } + continue; + } + if (!reader->decoder_finalized) { + if (finalize_decoding(tok) < 0) { + return _PYTOK_READ_ERROR; + } + continue; + } + return _PYTOK_READ_EOF; + } +} + +static _PyTok_ReadResult +next_readline(struct tok_state *tok, _PyTok_Chunk *chunk) +{ + _PyTok_Reader *reader = tok->reader; + for (;;) { + if (pop_decoded_line(reader, chunk)) { + return _PYTOK_READ_LINE; + } + if (reader->decoder_finalized) { + return _PYTOK_READ_EOF; + } + + PyObject *raw = PyObject_CallNoArgs(reader->readline); + if (raw == NULL) { + if (PyErr_ExceptionMatches(PyExc_StopIteration)) { + PyErr_Clear(); + if (finalize_decoding(tok) < 0) { + return _PYTOK_READ_ERROR; + } + continue; + } + return _PYTOK_READ_ERROR; + } + + _PyTok_Chunk input = {0}; + if (reader->encoding != NULL) { + if (!PyBytes_Check(raw)) { + PyErr_SetString(PyExc_TypeError, + "readline() returned a non-bytes object"); + Py_DECREF(raw); + return _PYTOK_READ_ERROR; + } + if (PyBytes_GET_SIZE(raw) == 0) { + Py_DECREF(raw); + if (_PyTok_StartDecoder(tok, "replace") < 0) { + return _PYTOK_READ_ERROR; + } + if (finalize_decoding(tok) < 0) { + return _PYTOK_READ_ERROR; + } + continue; + } + input.owner = raw; + input.data = PyBytes_AS_STRING(raw); + input.len = PyBytes_GET_SIZE(raw); + input.ownership = _PYTOK_CHUNK_PYOBJECT; + int decoded; + if (reader->decoder == NULL && + strcmp(reader->encoding, "utf-8") == 0 && + chunk_is_line(&input)) { + decoded = _PyTok_DecodeOnce( + tok, &input, "utf-8", "replace"); + } + else { + decoded = _PyTok_StartDecoder(tok, "replace"); + if (decoded == 0) { + decoded = _PyTok_DecodeChunk(tok, &input, 0); + } + } + if (decoded < 0) { + _PyTok_ChunkClear(&input); + return _PYTOK_READ_ERROR; + } + } + else { + if (!PyUnicode_Check(raw)) { + PyErr_SetString(PyExc_TypeError, + "readline() returned a non-string object"); + Py_DECREF(raw); + return _PYTOK_READ_ERROR; + } + Py_ssize_t utf8_len; + const char *utf8 = PyUnicode_AsUTF8AndSize(raw, &utf8_len); + if (utf8 == NULL) { + Py_DECREF(raw); + return _PYTOK_READ_ERROR; + } + input.owner = raw; + input.data = (char *)utf8; + input.len = utf8_len; + input.ownership = _PYTOK_CHUNK_PYOBJECT; + if (input.len == 0) { + _PyTok_ChunkClear(&input); + if (finalize_decoding(tok) < 0) { + return _PYTOK_READ_ERROR; + } + continue; + } + } + + if (reader->decoded_pos == reader->decoded_len && + chunk_is_line(&input)) { + *chunk = input; + return _PYTOK_READ_LINE; + } + + if (append_decoded(reader, input.data, input.len) < 0) { + _PyTok_ChunkClear(&input); + tok->done = E_NOMEM; + return _PYTOK_READ_ERROR; + } + _PyTok_ChunkClear(&input); + if (reader->decoded_pos < reader->decoded_len && + reader->decoded[reader->decoded_len - 1] != '\n') { + int pending = _PyTok_DecoderHasBufferedInput(tok); + if (pending < 0) { + return _PYTOK_READ_ERROR; + } + if (!pending && append_implicit_newline(reader) < 0) { + tok->done = E_NOMEM; + return _PYTOK_READ_ERROR; + } + } + } +} + +static _PyTok_ReadResult +next_interactive(struct tok_state *tok, _PyTok_Chunk *chunk) +{ + _PyTok_Reader *reader = tok->reader; + if (reader->stop_interactive) { + return _PYTOK_READ_STOPPED; + } + char *input = PyOS_Readline( + reader->fp != NULL ? reader->fp : stdin, stdout, reader->prompt); + if (reader->nextprompt != NULL) { + reader->prompt = reader->nextprompt; + } + if (input == NULL) { + return _PYTOK_READ_INTERRUPT; + } + Py_ssize_t len = strlen(input); + if (len == 0) { + PyMem_Free(input); + return _PYTOK_READ_EOF; + } + _PyTok_Chunk decoded = { + .data = input, + .len = len, + .ownership = _PYTOK_CHUNK_PYMEM, + }; + if (reader->encoding != NULL && + _PyTok_DecodeOnce( + tok, &decoded, reader->encoding, NULL) < 0) { + _PyTok_ChunkClear(&decoded); + return _PYTOK_READ_ERROR; + } + if (memchr(decoded.data, '\r', decoded.len) == NULL) { + *chunk = decoded; + return _PYTOK_READ_LINE; + } + chunk->data = _PyTok_NormalizeNewlines( + decoded.data, decoded.len, &chunk->len); + _PyTok_ChunkClear(&decoded); + if (chunk->data == NULL) { + tok->done = E_NOMEM; + return _PYTOK_READ_ERROR; + } + chunk->ownership = _PYTOK_CHUNK_PYMEM; + return _PYTOK_READ_LINE; +} + +int +_PyTok_ReaderIsInteractive(const struct tok_state *tok) +{ + return tok->reader->kind == _PYTOK_READER_INTERACTIVE; +} + +const char * +_PyTokenizer_RetainedSource(const struct tok_state *tok) +{ + if (tok->reader->kind == _PYTOK_READER_PREPARED) { + return _PyTok_SourceData(&tok->source); + } + if (tok->reader->kind == _PYTOK_READER_INTERACTIVE) { + return tok->source.bytes; + } + return NULL; +} + +void +_PyTok_ReaderStopInteractive(struct tok_state *tok) +{ + if (_PyTok_ReaderIsInteractive(tok)) { + tok->reader->stop_interactive = 1; + } +} + +static _PyTok_ReadResult +reader_next(struct tok_state *tok, _PyTok_Chunk *chunk) +{ + *chunk = (_PyTok_Chunk){0}; + switch (tok->reader->kind) { + case _PYTOK_READER_PREPARED: + return next_prepared(tok, chunk); + case _PYTOK_READER_FILE: + return next_file(tok, chunk); + case _PYTOK_READER_READLINE: + return next_readline(tok, chunk); + case _PYTOK_READER_INTERACTIVE: + return next_interactive(tok, chunk); + } + Py_UNREACHABLE(); +} + +static void +reset_streaming_buffer(struct tok_state *tok) +{ + assert(tok->cur >= tok->buf_offset && tok->cur <= tok->inp); + _PyTok_SourceDiscard(&tok->source); + tok->buf_offset = tok->source.base_offset; + tok->cur = tok->inp = tok->source.base_offset; + tok->line_start = tok->buf_offset; +} + +int +_PyTok_ReaderUnderflow(struct tok_state *tok) +{ + assert(tok->cur >= tok->buf_offset && tok->cur <= tok->inp); + _PyTok_Reader *reader = tok->reader; + _PyTok_ReaderKind kind = reader->kind; + int prepared = kind == _PYTOK_READER_PREPARED; + int streaming = reader_is_streaming(kind); + int reset_buffer = tok->start < 0 && + _PyLexer_CurrentFTString(tok) == NULL; + + _PyTok_Chunk chunk; + _PyTok_ReadResult result = reader_next(tok, &chunk); + if (result != _PYTOK_READ_LINE) { + if (reset_buffer && streaming) { + reset_streaming_buffer(tok); + } + if (result == _PYTOK_READ_EOF) { + tok->done = E_EOF; + } + else if (result == _PYTOK_READ_STOPPED) { + tok->done = E_INTERACT_STOP; + } + else if (result == _PYTOK_READ_INTERRUPT) { + tok->done = E_INTR; + } + else { + if (tok->done == E_OK) { + tok->done = PyErr_ExceptionMatches(PyExc_MemoryError) + ? E_NOMEM : E_ERROR; + } + } + if (kind == _PYTOK_READER_INTERACTIVE && + result != _PYTOK_READ_STOPPED) { + PySys_WriteStderr("\n"); + } + return 0; + } + if (tok->lineno == INT_MAX) { + PyErr_SetString(PyExc_OverflowError, "too many tokenizer source lines"); + tok->done = E_ERROR; + _PyTok_ChunkClear(&chunk); + return 0; + } + + if (!prepared) { + if (streaming && reset_buffer) { + reset_streaming_buffer(tok); + } + _PyTok_Off source_start = _PyTok_SourceAppendLine( + &tok->source, chunk.data, chunk.len); + if (source_start < 0) { + _PyTok_ChunkClear(&chunk); + tok->done = PyErr_ExceptionMatches(PyExc_MemoryError) + ? E_NOMEM : E_ERROR; + return 0; + } + if (reset_buffer) { + tok->cur = source_start; + tok->buf_offset = source_start; + tok->line_start = tok->buf_offset; + } + tok->inp = source_start + chunk.len; + } + else { + if (reset_buffer) { + tok->buf_offset = tok->inp; + } + tok->inp += chunk.len; + } + tok->implicit_newline = chunk.implicit_newline; + + tok->lineno++; + if (kind == _PYTOK_READER_FILE && + (reader->encoding == NULL || + strcmp(reader->encoding, "utf-8") == 0) && + !_PyTokenizer_ensure_utf8( + _PyTok_SourcePointer(&tok->source, tok->cur), + tok, tok->lineno)) { + _PyTok_ChunkClear(&chunk); + return 0; + } + _PyTok_ChunkClear(&chunk); + return 1; +} + +static struct tok_state * +tokenizer_new_with_reader(_PyTok_ReaderKind kind) +{ + struct tok_state *tok = PyMem_Calloc(1, sizeof(*tok)); + if (tok == NULL) { + PyErr_NoMemory(); + return NULL; + } + tok->start = tok->line_start = -1; + _PyTok_SourceInit(&tok->source); + tok->done = E_OK; + tok->layout.at_bol = 1; + tok->start_loc = (_PyTok_Loc){-1, -1}; + tok->ftstring_stack = tok->ftstring_stack_inline; + tok->ftstring_capacity = FTSTRING_STACK_INLINE_CAPACITY; +#ifdef Py_DEBUG + tok->debug = _Py_GetConfig()->parser_debug; +#endif + tok->reader = PyMem_Calloc(1, sizeof(*tok->reader)); + if (tok->reader == NULL) { + PyErr_NoMemory(); + _PyTokenizer_Free(tok); + return NULL; + } + tok->reader->kind = kind; + if (kind == _PYTOK_READER_PREPARED) { + return tok; + } + if (reader_is_streaming(kind)) { + tok->cur = tok->inp = tok->source.base_offset; + tok->line_start = tok->buf_offset; + } + return tok; +} + +static struct tok_state * +tokenizer_from_string(const char *input, int utf8_only, int exec_input, + int preserve_crlf) +{ + struct tok_state *tok = tokenizer_new_with_reader(_PYTOK_READER_PREPARED); + if (tok == NULL) { + return NULL; + } + if (_PyTok_PrepareString( + tok, input, utf8_only, exec_input, preserve_crlf) < 0) { + _PyTokenizer_Free(tok); + return NULL; + } + tok->cur = tok->inp = tok->source.base_offset; + tok->line_start = tok->source.base_offset; + return tok; +} + +struct tok_state * +_PyTokenizer_FromString(const char *input, int exec_input, int preserve_crlf) +{ + return tokenizer_from_string(input, 0, exec_input, preserve_crlf); +} + +struct tok_state * +_PyTokenizer_FromUTF8(const char *input, int exec_input, int preserve_crlf) +{ + return tokenizer_from_string(input, 1, exec_input, preserve_crlf); +} + +struct tok_state * +_PyTokenizer_FromReadline(PyObject *readline, const char *encoding) +{ + struct tok_state *tok = tokenizer_new_with_reader(_PYTOK_READER_READLINE); + if (tok == NULL) { + return NULL; + } + if (encoding != NULL && _PyTok_SetEncoding(tok, encoding) < 0) { + _PyTokenizer_Free(tok); + return NULL; + } + tok->reader->readline = Py_NewRef(readline); + return tok; +} + +struct tok_state * +_PyTokenizer_FromFile(FILE *fp, const char *encoding, + const char *ps1, const char *ps2) +{ + _PyTok_ReaderKind kind = ps1 != NULL || ps2 != NULL + ? _PYTOK_READER_INTERACTIVE : _PYTOK_READER_FILE; + struct tok_state *tok = tokenizer_new_with_reader(kind); + if (tok == NULL) { + return NULL; + } + if (encoding != NULL && _PyTok_SetEncoding(tok, encoding) < 0) { + _PyTokenizer_Free(tok); + return NULL; + } + tok->reader->fp = fp; + tok->reader->prompt = ps1; + tok->reader->nextprompt = ps2; + return tok; +} + +#if defined(__wasi__) || (defined(__EMSCRIPTEN__) && (__EMSCRIPTEN_major__ >= 3)) +/* WASI has no dup(), and Emscripten's emulation is slow. */ +typedef union { + void *cookie; + int fd; +} borrowed_fd; + +static ssize_t +borrow_read(void *cookie, char *buffer, size_t size) +{ + borrowed_fd borrowed = {.cookie = cookie}; + return read(borrowed.fd, buffer, size); +} + +static FILE * +fdopen_borrow(int fd) +{ + cookie_io_functions_t callbacks = {borrow_read, NULL, NULL, NULL}; + borrowed_fd borrowed = {.fd = fd}; + return fopencookie(borrowed.cookie, "r", callbacks); +} +#else +static FILE * +fdopen_borrow(int fd) +{ + int copy = _Py_dup(fd); + if (copy < 0) { + return NULL; + } + FILE *fp = fdopen(copy, "r"); + if (fp == NULL) { + int saved_errno = errno; + close(copy); + errno = saved_errno; + } + return fp; +} +#endif + +char * +_PyTokenizer_FindEncodingFilename(int fd, PyObject *filename) +{ + FILE *fp = fdopen_borrow(fd); + if (fp == NULL) { + return NULL; + } + struct tok_state *tok = _PyTokenizer_FromFile(fp, NULL, NULL, NULL); + if (tok == NULL) { + fclose(fp); + return NULL; + } + _Py_DECLARE_STR(anon_string, ""); + tok->filename = Py_NewRef(filename != NULL ? filename : &_Py_STR(anon_string)); + char *encoding = NULL; + if (initialize_file(tok) == 0) { + encoding = tok->reader->encoding; + tok->reader->encoding = NULL; + } + fclose(fp); + _PyTokenizer_Free(tok); + return encoding; +} diff --git a/Parser/tokenizer/reader.h b/Parser/tokenizer/reader.h new file mode 100644 index 000000000000000..2913e52b9d563b4 --- /dev/null +++ b/Parser/tokenizer/reader.h @@ -0,0 +1,11 @@ +#ifndef Py_TOKENIZER_READER_H +#define Py_TOKENIZER_READER_H + +struct tok_state; + +void _PyTok_ReaderFree(struct tok_state *); +int _PyTok_ReaderUnderflow(struct tok_state *); +int _PyTok_ReaderIsInteractive(const struct tok_state *); +void _PyTok_ReaderStopInteractive(struct tok_state *); + +#endif diff --git a/Parser/tokenizer/reader_internal.h b/Parser/tokenizer/reader_internal.h new file mode 100644 index 000000000000000..c080af3c05eef52 --- /dev/null +++ b/Parser/tokenizer/reader_internal.h @@ -0,0 +1,87 @@ +#ifndef Py_TOKENIZER_READER_INTERNAL_H +#define Py_TOKENIZER_READER_INTERNAL_H + +#include "Python.h" + +#define _PYTOK_ENCODING_COOKIE_MAX_LINES 2 + +typedef enum { + _PYTOK_READER_PREPARED, + _PYTOK_READER_FILE, + _PYTOK_READER_READLINE, + _PYTOK_READER_INTERACTIVE, +} _PyTok_ReaderKind; + +typedef enum { + _PYTOK_READ_LINE, + _PYTOK_READ_EOF, + _PYTOK_READ_STOPPED, + _PYTOK_READ_INTERRUPT, + _PYTOK_READ_ERROR, +} _PyTok_ReadResult; + +typedef enum { + _PYTOK_ENCODING_ERROR = -1, + _PYTOK_ENCODING_DONE, + _PYTOK_ENCODING_NEED_SECOND_LINE, +} _PyTok_EncodingResult; + +typedef enum { + _PYTOK_CHUNK_BORROWED, + _PYTOK_CHUNK_PYMEM, + _PYTOK_CHUNK_PYOBJECT, +} _PyTok_ChunkOwnership; + +typedef struct { + char *data; + PyObject *owner; + Py_ssize_t len; + _PyTok_ChunkOwnership ownership; + unsigned char implicit_newline; +} _PyTok_Chunk; + +typedef struct _PyTok_Reader { + FILE *fp; // Borrowed input stream; NULL for string and readline input. + char *encoding; // Owned source encoding. + PyObject *readline; + PyObject *decoder; + const char *prompt; + const char *nextprompt; + + char *file_buffer; + Py_ssize_t file_buffer_cap; + _PyTok_Chunk prefetched_lines[_PYTOK_ENCODING_COOKIE_MAX_LINES]; + + char *decoded; + Py_ssize_t decoded_pos; + Py_ssize_t decoded_scan; // First byte not yet scanned for a newline. + Py_ssize_t decoded_len; + Py_ssize_t decoded_cap; + _PyTok_ReaderKind kind; + unsigned char prepared_final_newline; // _PyTokenizer_Newline + unsigned char decoded_tail_is_implicit; + unsigned char file_initialized; + unsigned char file_eof; + unsigned char decoder_finalized; + unsigned char stop_interactive; +} _PyTok_Reader; + +struct tok_state; + +// On failure, the buffer and capacity are unchanged. +int _PyTok_ReserveBuffer(char **, Py_ssize_t *, Py_ssize_t, Py_ssize_t); +char *_PyTok_CopyBytes(const char *, Py_ssize_t); +int _PyTok_DecodeOnce( + struct tok_state *, _PyTok_Chunk *, const char *, const char *); +char *_PyTok_NormalizeNewlines(const char *, Py_ssize_t, Py_ssize_t *); +void _PyTok_ChunkClear(_PyTok_Chunk *); +int _PyTok_SetEncoding(struct tok_state *, const char *); +_PyTok_EncodingResult _PyTok_DetectEncoding( + struct tok_state *, const _PyTok_Chunk *, const _PyTok_Chunk *, int, + Py_ssize_t *); +int _PyTok_PrepareString(struct tok_state *, const char *, int, int, int); +int _PyTok_StartDecoder(struct tok_state *, const char *); +int _PyTok_DecodeChunk(struct tok_state *, _PyTok_Chunk *, int); +int _PyTok_DecoderHasBufferedInput(struct tok_state *); + +#endif diff --git a/Parser/tokenizer/readline_tokenizer.c b/Parser/tokenizer/readline_tokenizer.c deleted file mode 100644 index 917f7b40cfbbfed..000000000000000 --- a/Parser/tokenizer/readline_tokenizer.c +++ /dev/null @@ -1,135 +0,0 @@ -#include "Python.h" -#include "errcode.h" - -#include "helpers.h" -#include "../lexer/lexer.h" -#include "../lexer/state.h" -#include "../lexer/buffer.h" - -static int -tok_readline_string(struct tok_state* tok) { - PyObject* line = NULL; - PyObject* raw_line = PyObject_CallNoArgs(tok->readline); - if (raw_line == NULL) { - if (PyErr_ExceptionMatches(PyExc_StopIteration)) { - PyErr_Clear(); - return 1; - } - _PyTokenizer_error_ret(tok); - goto error; - } - if(tok->encoding != NULL) { - if (!PyBytes_Check(raw_line)) { - PyErr_Format(PyExc_TypeError, "readline() returned a non-bytes object"); - _PyTokenizer_error_ret(tok); - goto error; - } - line = PyUnicode_Decode(PyBytes_AS_STRING(raw_line), PyBytes_GET_SIZE(raw_line), - tok->encoding, "replace"); - Py_CLEAR(raw_line); - if (line == NULL) { - _PyTokenizer_error_ret(tok); - goto error; - } - } else { - if(!PyUnicode_Check(raw_line)) { - PyErr_Format(PyExc_TypeError, "readline() returned a non-string object"); - _PyTokenizer_error_ret(tok); - goto error; - } - line = raw_line; - raw_line = NULL; - } - Py_ssize_t buflen; - const char* buf = PyUnicode_AsUTF8AndSize(line, &buflen); - if (buf == NULL) { - _PyTokenizer_error_ret(tok); - goto error; - } - - // Make room for the null terminator *and* potentially - // an extra newline character that we may need to artificially - // add. - size_t buffer_size = buflen + 2; - if (!_PyLexer_tok_reserve_buf(tok, buffer_size)) { - goto error; - } - memcpy(tok->inp, buf, buflen); - tok->inp += buflen; - *tok->inp = '\0'; - - tok->line_start = tok->cur; - Py_DECREF(line); - return 1; -error: - Py_XDECREF(raw_line); - Py_XDECREF(line); - return 0; -} - -static int -tok_underflow_readline(struct tok_state* tok) { - assert(tok->decoding_state == STATE_NORMAL); - assert(tok->fp == NULL && tok->input == NULL && tok->decoding_readline == NULL); - if (tok->start == NULL && !INSIDE_FSTRING(tok)) { - tok->cur = tok->inp = tok->buf; - } - if (!tok_readline_string(tok)) { - return 0; - } - if (tok->inp == tok->cur) { - tok->done = E_EOF; - return 0; - } - tok->implicit_newline = 0; - if (tok->inp[-1] != '\n') { - assert(tok->inp + 1 < tok->end); - /* Last line does not end in \n, fake one */ - *tok->inp++ = '\n'; - *tok->inp = '\0'; - tok->implicit_newline = 1; - } - - if (tok->tok_mode_stack_index && !_PyLexer_update_ftstring_expr(tok, 0)) { - return 0; - } - - ADVANCE_LINENO(); - /* The default encoding is UTF-8, so make sure we don't have any - non-UTF-8 sequences in it. */ - if (!tok->encoding && !_PyTokenizer_ensure_utf8(tok->cur, tok, tok->lineno)) { - _PyTokenizer_error_ret(tok); - return 0; - } - assert(tok->done == E_OK); - return tok->done == E_OK; -} - -struct tok_state * -_PyTokenizer_FromReadline(PyObject* readline, const char* enc, - int exec_input, int preserve_crlf) -{ - struct tok_state *tok = _PyTokenizer_tok_new(); - if (tok == NULL) - return NULL; - if ((tok->buf = (char *)PyMem_Malloc(BUFSIZ)) == NULL) { - _PyTokenizer_Free(tok); - PyErr_NoMemory(); - return NULL; - } - tok->cur = tok->inp = tok->buf; - tok->end = tok->buf + BUFSIZ; - tok->fp = NULL; - if (enc != NULL) { - tok->encoding = _PyTokenizer_new_string(enc, strlen(enc), tok); - if (!tok->encoding) { - _PyTokenizer_Free(tok); - return NULL; - } - } - tok->decoding_state = STATE_NORMAL; - tok->underflow = &tok_underflow_readline; - Py_INCREF(readline); - tok->readline = readline; - return tok; -} diff --git a/Parser/tokenizer/source.c b/Parser/tokenizer/source.c new file mode 100644 index 000000000000000..8688ef0f06e8302 --- /dev/null +++ b/Parser/tokenizer/source.c @@ -0,0 +1,154 @@ +#include "Python.h" +#include "pycore_pymem.h" // PYMEM_DEADBYTE + +#include "source.h" + +#define SOURCE_BUFFER_GROWTH_FACTOR 2 + +void +_PyTok_SourceInit(_PyTok_SourceText *source) +{ + *source = (_PyTok_SourceText){0}; +} + +void +_PyTok_SourceClear(_PyTok_SourceText *source) +{ + PyMem_Free(source->bytes); + _PyTok_SourceInit(source); +} + +void +_PyTok_SourceDiscard(_PyTok_SourceText *source) +{ + assert(source->base_offset <= PY_SSIZE_T_MAX - source->len); + source->base_offset += source->len; + source->len = 0; + if (source->bytes != NULL) { + source->bytes[0] = '\0'; + } + source->nlines = 0; +} + +static int +reserve_bytes(_PyTok_SourceText *source, Py_ssize_t needed) +{ + if (needed <= source->cap) { + return 0; + } + Py_ssize_t cap = source->cap > 0 ? source->cap : BUFSIZ; + while (cap < needed) { + if (cap > PY_SSIZE_T_MAX / SOURCE_BUFFER_GROWTH_FACTOR) { + cap = needed; + break; + } + cap *= SOURCE_BUFFER_GROWTH_FACTOR; + } + char *bytes; +#ifdef Py_DEBUG + /* Moving on growth makes stale interior pointers fail in debug builds. */ + bytes = PyMem_Malloc(cap); + if (bytes != NULL && source->len > 0) { + memcpy(bytes, source->bytes, source->len); + } +#else + bytes = PyMem_Realloc(source->bytes, cap); +#endif + if (bytes == NULL) { + PyErr_NoMemory(); + return -1; + } +#ifdef Py_DEBUG + if (source->bytes != NULL) { + memset(source->bytes, PYMEM_DEADBYTE, source->cap); + PyMem_Free(source->bytes); + } +#endif + source->bytes = bytes; + source->cap = cap; + return 0; +} + +static int +validate_line(const _PyTok_SourceText *source, const char *bytes, + Py_ssize_t len, int append_newline) +{ + if (len < 0 || (len == 0 && !append_newline) || bytes == NULL || + (source->nlines > 0 && + (source->len == 0 || source->bytes[source->len - 1] != '\n'))) { + PyErr_SetString(PyExc_SystemError, "invalid tokenizer source line"); + return -1; + } + const char *newline = memchr(bytes, '\n', len); + if (newline != NULL && (append_newline || newline != bytes + len - 1)) { + PyErr_SetString(PyExc_SystemError, "invalid tokenizer source line"); + return -1; + } + if (source->nlines == INT_MAX || + (source->nlines == INT_MAX - 1 && (newline != NULL || append_newline))) { + PyErr_SetString(PyExc_OverflowError, "too many tokenizer source lines"); + return -1; + } + return 0; +} + +static _PyTok_Off +append_line(_PyTok_SourceText *source, const char *bytes, + Py_ssize_t len, int append_newline) +{ + if (validate_line(source, bytes, len, append_newline) < 0) { + return -1; + } + if (source->len > PY_SSIZE_T_MAX - len - append_newline - 1 || + source->base_offset > PY_SSIZE_T_MAX - source->len - len - append_newline) { + PyErr_NoMemory(); + return -1; + } + if (reserve_bytes(source, source->len + len + append_newline + 1) < 0) { + return -1; + } + + _PyTok_Off start = source->len; + memcpy(source->bytes + start, bytes, len); + source->len += len; + if (append_newline) { + source->bytes[source->len++] = '\n'; + } + source->bytes[source->len] = '\0'; + source->nlines++; + return source->base_offset + start; +} + +_PyTok_Off +_PyTok_SourceAppendLine(_PyTok_SourceText *source, const char *bytes, + Py_ssize_t len) +{ + return append_line(source, bytes, len, 0); +} + +_PyTok_Off +_PyTok_SourceAppendLineWithNewline(_PyTok_SourceText *source, const char *bytes, + Py_ssize_t len) +{ + return append_line(source, bytes, len, 1); +} + +const char * +_PyTok_SourceLineView(const _PyTok_SourceText *source, Py_ssize_t lineno, + Py_ssize_t *len) +{ + assert(len != NULL); + const char *line = _PyTok_SourceData(source); + const char *end = line + source->len; + while (lineno > 1) { + const char *newline = memchr(line, '\n', end - line); + if (newline == NULL) { + break; + } + line = newline + 1; + lineno--; + } + const char *newline = memchr(line, '\n', end - line); + *len = (newline != NULL ? newline : end) - line; + return line; +} diff --git a/Parser/tokenizer/source.h b/Parser/tokenizer/source.h new file mode 100644 index 000000000000000..d2c202830479523 --- /dev/null +++ b/Parser/tokenizer/source.h @@ -0,0 +1,84 @@ +#ifndef Py_TOKENIZER_SOURCE_H +#define Py_TOKENIZER_SOURCE_H + +#include "Python.h" + +#include "types.h" + +typedef struct { + char *bytes; + _PyTok_Off base_offset; + _PyTok_Off len; + _PyTok_Off cap; + int nlines; +} _PyTok_SourceText; + +static inline const char * +_PyTok_SourceData(const _PyTok_SourceText *source) +{ + return source->bytes != NULL ? source->bytes : ""; +} + +/* Convert positions within the retained source window. Pointers and views + are borrowed; append, discard, and clear invalidate them. */ +static inline const char * +_PyTok_SourcePointer(const _PyTok_SourceText *source, _PyTok_Off offset) +{ + assert(offset >= source->base_offset); + assert(offset - source->base_offset <= source->len); + return _PyTok_SourceData(source) + (offset - source->base_offset); +} + +static inline unsigned char +_PyTok_SourceByte(const _PyTok_SourceText *source, _PyTok_Off offset) +{ + assert(offset >= source->base_offset); + assert(offset - source->base_offset < source->len); + return (unsigned char)source->bytes[offset - source->base_offset]; +} + +static inline const char * +_PyTok_SourceSpanView(const _PyTok_SourceText *source, _PyTok_Span span, + Py_ssize_t *length) +{ + assert(length != NULL); + assert(_PyTok_SpanIsValid(span)); + assert(span.end - source->base_offset <= source->len); + *length = span.end - span.start; + return _PyTok_SourcePointer(source, span.start); +} + +/* Return the first matching offset within span, or -1 if absent. */ +static inline _PyTok_Off +_PyTok_SourceFindByte(const _PyTok_SourceText *source, _PyTok_Span span, + int byte) +{ + Py_ssize_t length; + const char *data = _PyTok_SourceSpanView(source, span, &length); + const char *found = memchr(data, byte, length); + return found != NULL ? span.start + (found - data) : -1; +} + +PyAPI_FUNC(void) _PyTok_SourceInit(_PyTok_SourceText *); +/* Clear invalidates all spans and views for the source. */ +PyAPI_FUNC(void) _PyTok_SourceClear(_PyTok_SourceText *); +/* Discard the retained window and invalidate its spans and views. + Keep its allocation and advance the logical base to the end of the window. */ +PyAPI_FUNC(void) _PyTok_SourceDiscard(_PyTok_SourceText *); +/* Append one nonempty logical line and return its start offset. The input may + contain one newline, as its final byte. An unterminated line must be the + final line. The input must not point into source storage. */ +PyAPI_FUNC(_PyTok_Off) _PyTok_SourceAppendLine( + _PyTok_SourceText *source, const char *bytes, Py_ssize_t len); +/* Append a line payload followed by '\n'. The payload may be empty and must + contain no newline. Other SourceAppendLine constraints still apply. */ +PyAPI_FUNC(_PyTok_Off) _PyTok_SourceAppendLineWithNewline( + _PyTok_SourceText *source, const char *bytes, Py_ssize_t len); +/* Return borrowed bytes excluding '\n', writing the byte length to *len. + Line numbers are 1-based and clamp to the first or final line; a trailing + '\n' adds an empty final line. The view need not be NUL-terminated. + This does not set an exception. Append, discard, and clear invalidate the view. */ +PyAPI_FUNC(const char *) _PyTok_SourceLineView( + const _PyTok_SourceText *source, Py_ssize_t lineno, Py_ssize_t *len); + +#endif diff --git a/Parser/tokenizer/string_tokenizer.c b/Parser/tokenizer/string_tokenizer.c deleted file mode 100644 index 7f07cca37ee0191..000000000000000 --- a/Parser/tokenizer/string_tokenizer.c +++ /dev/null @@ -1,148 +0,0 @@ -#include "Python.h" -#include "errcode.h" - -#include "helpers.h" -#include "../lexer/state.h" - -static int -tok_underflow_string(struct tok_state *tok) { - char *end = strchr(tok->inp, '\n'); - if (end != NULL) { - end++; - } - else { - end = strchr(tok->inp, '\0'); - if (end == tok->inp) { - tok->done = E_EOF; - return 0; - } - } - if (tok->start == NULL) { - tok->buf = tok->cur; - } - tok->line_start = tok->cur; - ADVANCE_LINENO(); - tok->inp = end; - return 1; -} - -/* Fetch a byte from TOK, using the string buffer. */ -static int -buf_getc(struct tok_state *tok) { - return Py_CHARMASK(*tok->str++); -} - -/* Unfetch a byte from TOK, using the string buffer. */ -static void -buf_ungetc(int c, struct tok_state *tok) { - tok->str--; - assert(Py_CHARMASK(*tok->str) == c); /* tok->cur may point to read-only segment */ -} - -/* Set the readline function for TOK to ENC. For the string-based - tokenizer, this means to just record the encoding. */ -static int -buf_setreadl(struct tok_state *tok, const char* enc) { - tok->enc = enc; - return 1; -} - -/* Decode a byte string STR for use as the buffer of TOK. - Look for encoding declarations inside STR, and record them - inside TOK. */ -static char * -decode_str(const char *input, int single, struct tok_state *tok, int preserve_crlf) -{ - PyObject* utf8 = NULL; - char *str; - const char *s; - const char *newl[2] = {NULL, NULL}; - int lineno = 0; - tok->input = str = _PyTokenizer_translate_newlines(input, single, preserve_crlf, tok); - if (str == NULL) - return NULL; - tok->enc = NULL; - tok->str = str; - if (!_PyTokenizer_check_bom(buf_getc, buf_ungetc, buf_setreadl, tok)) - return _PyTokenizer_error_ret(tok); - str = tok->str; /* string after BOM if any */ - assert(str); - if (tok->enc != NULL) { - utf8 = _PyTokenizer_translate_into_utf8(str, tok->enc); - if (utf8 == NULL) - return _PyTokenizer_error_ret(tok); - str = PyBytes_AsString(utf8); - } - for (s = str;; s++) { - if (*s == '\0') break; - else if (*s == '\n') { - assert(lineno < 2); - newl[lineno] = s; - lineno++; - if (lineno == 2) break; - } - } - tok->enc = NULL; - /* need to check line 1 and 2 separately since check_coding_spec - assumes a single line as input */ - if (newl[0]) { - tok->lineno = 1; - if (!_PyTokenizer_check_coding_spec(str, newl[0] - str, tok, buf_setreadl)) { - return NULL; - } - if (tok->enc == NULL && tok->decoding_state != STATE_NORMAL && newl[1]) { - tok->lineno = 2; - if (!_PyTokenizer_check_coding_spec(newl[0]+1, newl[1] - newl[0], - tok, buf_setreadl)) - return NULL; - } - } - tok->lineno = 0; - if (tok->enc != NULL) { - assert(utf8 == NULL); - utf8 = _PyTokenizer_translate_into_utf8(str, tok->enc); - if (utf8 == NULL) - return _PyTokenizer_error_ret(tok); - str = PyBytes_AS_STRING(utf8); - } - else if (!_PyTokenizer_ensure_utf8(str, tok, 1)) { - return _PyTokenizer_error_ret(tok); - } - if (utf8 != NULL) { - char *translated = _PyTokenizer_translate_newlines( - str, single, preserve_crlf, tok); - if (translated == NULL) { - Py_DECREF(utf8); - return _PyTokenizer_error_ret(tok); - } - PyMem_Free(tok->input); - tok->input = translated; - str = translated; - Py_CLEAR(utf8); - } - tok->str = str; - assert(tok->decoding_buffer == NULL); - tok->decoding_buffer = utf8; /* CAUTION */ - return str; -} - -/* Set up tokenizer for string */ -struct tok_state * -_PyTokenizer_FromString(const char *str, int exec_input, int preserve_crlf) -{ - struct tok_state *tok = _PyTokenizer_tok_new(); - char *decoded; - - if (tok == NULL) - return NULL; - decoded = decode_str(str, exec_input, tok, preserve_crlf); - if (decoded == NULL) { - _PyTokenizer_Free(tok); - return NULL; - } - - tok->buf = tok->cur = tok->inp = decoded; - tok->end = decoded; - tok->underflow = &tok_underflow_string; - return tok; -} diff --git a/Parser/tokenizer/tokenizer.h b/Parser/tokenizer/tokenizer.h index 8fbeb2d6ae6df1d..1dba5c6eeb2c22b 100644 --- a/Parser/tokenizer/tokenizer.h +++ b/Parser/tokenizer/tokenizer.h @@ -2,13 +2,131 @@ #define Py_TOKENIZER_H #include "Python.h" +#include "types.h" -struct tok_state *_PyTokenizer_FromString(const char *, int, int); -struct tok_state *_PyTokenizer_FromUTF8(const char *, int, int); -struct tok_state *_PyTokenizer_FromReadline(PyObject*, const char*, int, int); -struct tok_state *_PyTokenizer_FromFile(FILE *, const char*, - const char *, const char *); +struct tok_state; -#define tok_dump _Py_tok_dump +typedef enum { + _PyTokenizer_KEEP_NEWLINE, // Preserve the original line terminator. + _PyTokenizer_IMPLY_NEWLINE, // Add a missing line terminator. + _PyTokenizer_APPEND_NEWLINE, // Also append a blank line to terminated input. +} _PyTokenizer_Newline; + +/* Reasons that the appended newline can change the token stream. */ +enum { + _PyTokenizer_NEWLINE_STATEMENT = 1, + _PyTokenizer_NEWLINE_INDENT = 2, + _PyTokenizer_NEWLINE_CONTINUATION = 4, +}; + +/* Initialize before use. metadata owns a reference released by _PyToken_Free; + a consumer taking that reference must set metadata to NULL. */ +struct token { + int type; + int level; + unsigned char is_raw; + unsigned char is_incomplete; + _PyTok_Span span; + _PyTok_Loc start_loc; + _PyTok_Loc end_loc; + PyObject *metadata; +}; + +typedef struct { + const char *text; + Py_ssize_t length; + _PyTok_Span line_span; + _PyTok_Off end_line_start; + int implicit_newline; + int at_eof; +} _PyToken_View; + +/* Supplemental source context for a terminal error. location is the reporting + cursor, independent of the scanner cursor; lineno == 0 means absent. + The text span may cover multiple physical lines. */ +typedef struct { + _PyTok_Loc location; + _PyTok_Span text_span; +} _PyTokenizer_Diagnostic; + +typedef struct { + int status; + unsigned char implicit_newline; // _PyTokenizer_Newline + _PyTokenizer_Diagnostic diagnostic; + _PyTok_Loc location; + _PyTok_Off cursor; + _PyTok_Span input_span; + _PyTok_Span line_span; + int level; + char delimiter; + _PyTok_Loc delimiter_loc; + int in_formatted_string; + int is_interactive; + int is_file; + PyObject *filename; + PyObject *module; + const char *encoding; +} _PyTokenizer_Info; + +/* Get replaces the initialized token, releasing its previous metadata. + Errors are returned as ERRORTOKEN, with or without a Python exception. + In incomplete-input mode, an unfinished string retains its token type, + sets is_incomplete and has E_INCOMPLETE status. Only f-string and t-string + middle tokens retain their text span. No Python exception is set. */ +void _PyTokenizer_Get(struct tok_state *, struct token *); +void _PyTokenizer_Free(struct tok_state *); +int _PyTokenizer_Traverse(struct tok_state *, visitproc, void *); +void _PyTokenizer_raise_init_error(PyObject *filename); +void _PyToken_Init(struct token *); +static inline void +_PyToken_Free(struct token *token) +{ + Py_CLEAR(token->metadata); +} + +/* Views and borrowed snapshot references remain valid until the tokenizer is + mutated or freed. Source spans may be discarded when reading more input. */ +_PyTokenizer_Info _PyTokenizer_GetInfo(const struct tok_state *); +int _PyTokenizer_GetStatus(const struct tok_state *); +int _PyTokenizer_GetNewlineRequirements(const struct tok_state *); +/* An absent token span has a nonnull empty text view. */ +const char *_PyToken_TextView( + const struct tok_state *, const struct token *, Py_ssize_t *); +/* Use the token from the most recent Get. An absent span has nonnull empty text. + line_span covers the token's complete physical line range. end_line_start + is the logical offset of its final physical line. */ +void _PyToken_GetView( + const struct tok_state *tok, const struct token *token, + _PyToken_View *view); +const char *_PyTokenizer_SpanView( + const struct tok_state *, _PyTok_Span, Py_ssize_t *); +/* For retained input: 1-based lines clamp to the first or final line. + The view excludes the newline and need not be NUL-terminated. */ +const char *_PyTokenizer_LineView( + const struct tok_state *, Py_ssize_t, Py_ssize_t *); +/* Return NUL-terminated retained input, or NULL without setting an exception + for streaming input or interactive input before its first line. */ +const char *_PyTokenizer_RetainedSource(const struct tok_state *); +void _PyTokenizer_SetContext( + struct tok_state *tok, PyObject *filename, PyObject *module); +void _PyTokenizer_SetOptions( + struct tok_state *tok, int extra_tokens, int type_comments); +void _PyTokenizer_AllowIncompleteInput(struct tok_state *, int); +void _PyTokenizer_ImplyDedents(struct tok_state *); +int _PyTokenizer_HasTrailingStatement(const struct tok_state *); +int _PyTokenizer_IsInteractive(const struct tok_state *); +void _PyTokenizer_StopInteractive(struct tok_state *); + +struct tok_state *_PyTokenizer_FromString( + const char *input, int exec_input, int preserve_crlf); +struct tok_state *_PyTokenizer_FromUTF8( + const char *input, int exec_input, int preserve_crlf); +struct tok_state *_PyTokenizer_FromReadline( + PyObject *readline, const char *encoding); +struct tok_state *_PyTokenizer_FromFile( + FILE *fp, const char *encoding, const char *ps1, const char *ps2); +/* Return the declared encoding in PyMem-allocated storage, or NULL. + An exception is set on error. */ +char *_PyTokenizer_FindEncodingFilename(int, PyObject *); #endif /* !Py_TOKENIZER_H */ diff --git a/Parser/tokenizer/types.h b/Parser/tokenizer/types.h new file mode 100644 index 000000000000000..b488cb01618d35f --- /dev/null +++ b/Parser/tokenizer/types.h @@ -0,0 +1,27 @@ +#ifndef Py_TOKENIZER_TYPES_H +#define Py_TOKENIZER_TYPES_H + +#include "Python.h" + +typedef Py_ssize_t _PyTok_Off; + +/* Spans use half-open logical byte offsets into decoded input. Their backing + storage may retain only the current input window. */ +typedef struct { + _PyTok_Off start; + _PyTok_Off end; +} _PyTok_Span; + +/* Lines are 1-based and byte columns are 0-based. */ +typedef struct { + int lineno; + int byte_col; +} _PyTok_Loc; + +static inline int +_PyTok_SpanIsValid(_PyTok_Span span) +{ + return span.start >= 0 && span.end >= span.start; +} + +#endif diff --git a/Parser/tokenizer/utf8_tokenizer.c b/Parser/tokenizer/utf8_tokenizer.c deleted file mode 100644 index 1a925f445400faa..000000000000000 --- a/Parser/tokenizer/utf8_tokenizer.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "Python.h" -#include "errcode.h" - -#include "helpers.h" -#include "../lexer/state.h" - -static int -tok_underflow_string(struct tok_state *tok) { - char *end = strchr(tok->inp, '\n'); - if (end != NULL) { - end++; - } - else { - end = strchr(tok->inp, '\0'); - if (end == tok->inp) { - tok->done = E_EOF; - return 0; - } - } - if (tok->start == NULL) { - tok->buf = tok->cur; - } - tok->line_start = tok->cur; - ADVANCE_LINENO(); - tok->inp = end; - return 1; -} - -/* Set up tokenizer for UTF-8 string */ -struct tok_state * -_PyTokenizer_FromUTF8(const char *str, int exec_input, int preserve_crlf) -{ - struct tok_state *tok = _PyTokenizer_tok_new(); - char *translated; - if (tok == NULL) - return NULL; - tok->input = translated = _PyTokenizer_translate_newlines(str, exec_input, preserve_crlf, tok); - if (translated == NULL) { - _PyTokenizer_Free(tok); - return NULL; - } - tok->decoding_state = STATE_NORMAL; - tok->enc = NULL; - tok->str = translated; - tok->encoding = _PyTokenizer_new_string("utf-8", 5, tok); - if (!tok->encoding) { - _PyTokenizer_Free(tok); - return NULL; - } - - tok->buf = tok->cur = tok->inp = translated; - tok->end = translated; - tok->underflow = &tok_underflow_string; - return tok; -} diff --git a/Platforms/Android/README.md b/Platforms/Android/README.md index 54b7f1c46a59db0..0f96a6fd17ec111 100644 --- a/Platforms/Android/README.md +++ b/Platforms/Android/README.md @@ -31,7 +31,7 @@ The script also requires the following commands to be on the `PATH`: * `curl` * `java` (or set the `JAVA_HOME` environment variable). - Java versions 17 and 21 are supported. + Java versions 17, 21 and 25 are supported. ## Building diff --git a/Platforms/Android/__main__.py b/Platforms/Android/__main__.py index 78f94b317ab0478..c8af1a02cd3e676 100755 --- a/Platforms/Android/__main__.py +++ b/Platforms/Android/__main__.py @@ -158,7 +158,7 @@ def android_env(host): f"PREFIX={prefix}; " f". {ENV_SCRIPT}; " f"export", - check=True, shell=True, capture_output=True, encoding='utf-8', + check=True, shell=True, stdout=subprocess.PIPE, encoding='utf-8', ).stdout env = {} @@ -224,10 +224,10 @@ def unpack_deps(host, prefix_dir, cache_dir): for name_ver in [ "bzip2-1.0.8-3", "libffi-3.4.4-3", - "openssl-3.5.7-0", - "sqlite-3.53.2-0", + "openssl-3.5.9-0", + "sqlite-3.53.4-0", "xz-5.4.6-1", - "zstd-1.5.7-2" + "zstd-1.6.0-0" ]: filename = f"{name_ver}-{host}.tar.gz" out_path = download(f"{deps_url}/{name_ver}/{filename}", cache_dir) @@ -393,10 +393,10 @@ def setup_testbed(): if all((TESTBED_DIR / path).exists() for path in paths): return - # The wrapper version isn't important, as any version of the wrapper can - # download any version of Gradle. The Gradle version actually used for the - # build is specified in testbed/gradle/wrapper/gradle-wrapper.properties. - version = "8.9.0" + # Any version of the wrapper can run any reasonably close version of Gradle, so this + # doesn't need to match the Gradle version used for the build, which is specified in + # testbed/gradle/wrapper/gradle-wrapper.properties. + version = "9.5.0" for path in paths: out_path = TESTBED_DIR / path @@ -625,7 +625,8 @@ async def read_int(size): except ValueError: priority = LogPriority.UNKNOWN - payload_fields = (await read_bytes(payload_len - 1)).split(b"\0") + payload = await read_bytes(payload_len - 1) + payload_fields = payload.split(b"\0") if len(payload_fields) < 2: raise ValueError( f"payload {payload!r} does not contain at least 2 " diff --git a/Platforms/Android/android-env.sh b/Platforms/Android/android-env.sh index 5859c0eac4a88fb..59ce2eeb7d62244 100644 --- a/Platforms/Android/android-env.sh +++ b/Platforms/Android/android-env.sh @@ -7,7 +7,7 @@ : "${PREFIX:-}" # Path in which to find required libraries -# Print all messages on stderr so they're visible when running within build-wheel. +# Print all messages on stderr so they're visible when stdout is captured. log() { echo "$1" >&2 } @@ -27,7 +27,7 @@ fail() { ndk_version=27.3.13750724 ndk=$ANDROID_HOME/ndk/$ndk_version -if ! [ -e "$ndk" ]; then +if ! [ -e "$ndk/package.xml" ]; then log "Installing NDK - this may take several minutes" yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" "ndk;$ndk_version" fi diff --git a/Platforms/Android/testbed/app/build.gradle.kts b/Platforms/Android/testbed/app/build.gradle.kts index a56714406803cbf..4d296799c5da68f 100644 --- a/Platforms/Android/testbed/app/build.gradle.kts +++ b/Platforms/Android/testbed/app/build.gradle.kts @@ -3,7 +3,6 @@ import kotlin.math.max plugins { id("com.android.application") - id("org.jetbrains.kotlin.android") } val ANDROID_DIR = file("../..") @@ -144,18 +143,10 @@ android { path("src/main/c/CMakeLists.txt") } - // Set this property to something nonexistent but non-empty. Otherwise it'll use the - // default list, which ignores asset directories beginning with an underscore, and - // maybe also other files required by tests. - aaptOptions.ignoreAssetsPattern = "android-testbed-dont-ignore-anything" - compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = "1.8" - } testOptions { managedDevices { @@ -192,6 +183,12 @@ android { } } } + androidResources { + // Set this property to something nonexistent but non-empty. Otherwise it'll use + // the default list, which ignores asset directories beginning with an + // underscore, and maybe also other files required by tests. + ignoreAssetsPattern = "android-testbed-dont-ignore-anything" + } } dependencies { diff --git a/Platforms/Android/testbed/app/src/main/java/org/python/testbed/MainActivity.kt b/Platforms/Android/testbed/app/src/main/java/org/python/testbed/MainActivity.kt index dc49cdb9a9f7395..c8fe3acd849ac7a 100644 --- a/Platforms/Android/testbed/app/src/main/java/org/python/testbed/MainActivity.kt +++ b/Platforms/Android/testbed/app/src/main/java/org/python/testbed/MainActivity.kt @@ -28,12 +28,11 @@ class PythonTestRunner(val context: Context) { * @param args Python command-line, encoded as JSON. * @return The Python exit status: zero on success, nonzero on failure. */ fun run(args: String) : Int { - // We leave argument 0 as an empty string, which is a placeholder for the - // executable name in embedded mode. + // Argument 0 is a placeholder for the executable name in embedded mode. val argsJsonArray = JSONArray(args) - val argsStringArray = Array(argsJsonArray.length() + 1) { it -> ""} - for (i in 0..(argsJsonArray.length() + 1) { i -> + if (i == 0) "" + else argsJsonArray.getString(i - 1) } // Python needs this variable to help it find the temporary directory, diff --git a/Platforms/Android/testbed/build.gradle.kts b/Platforms/Android/testbed/build.gradle.kts index 451517b3f1aeab6..3c48be4bb585139 100644 --- a/Platforms/Android/testbed/build.gradle.kts +++ b/Platforms/Android/testbed/build.gradle.kts @@ -1,5 +1,4 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.android.application") version "8.10.0" apply false - id("org.jetbrains.kotlin.android") version "1.9.22" apply false + id("com.android.application") version "9.3.1" apply false } diff --git a/Platforms/Android/testbed/gradle.properties b/Platforms/Android/testbed/gradle.properties index e9f345c8c262501..22821df51100134 100644 --- a/Platforms/Android/testbed/gradle.properties +++ b/Platforms/Android/testbed/gradle.properties @@ -11,16 +11,8 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app's APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official -# Enables namespacing of each library's R class so that its R class includes only the -# resources declared in the library itself and none from the library's dependencies, -# thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true # By default, the app will be uninstalled after the tests finish (apparently # after 10 seconds in case of an unclean shutdown). We disable this, because diff --git a/Platforms/Android/testbed/gradle/wrapper/gradle-wrapper.properties b/Platforms/Android/testbed/gradle/wrapper/gradle-wrapper.properties index 5d42fbae084da1f..6632d9e5c1c4045 100644 --- a/Platforms/Android/testbed/gradle/wrapper/gradle-wrapper.properties +++ b/Platforms/Android/testbed/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Feb 19 20:29:06 GMT 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/Platforms/Apple/__main__.py b/Platforms/Apple/__main__.py index b294d2720a80dfe..b47716527634887 100644 --- a/Platforms/Apple/__main__.py +++ b/Platforms/Apple/__main__.py @@ -5,17 +5,20 @@ # This script simplifies the process of configuring, compiling and packaging an # XCframework for an Apple platform. # -# At present, it only supports iOS, but it has been constructed so that it -# could be used on any Apple platform. +# At present, it supports iOS, tvOS, visionOS and watchOS, but it has been +# constructed so that it could be used on any Apple platform. # # The simplest entry point is: # # $ python Platforms/Apple ci iOS # +# (replace iOS with tvOS, visionOS or watchOS as required.) +# # which will: # * Clean any pre-existing build artefacts # * Configure and make a Python that can be used for the build -# * Configure and make a Python for each supported iOS architecture and ABI +# * Configure and make a Python for each supported iOS/tvOS/watchOS/visionOS +# architecture and ABI # * Combine the outputs of the builds from the previous step into a single # XCframework, merging binaries into a "fat" binary if necessary # * Clone a copy of the testbed, configured to use the XCframework @@ -75,9 +78,79 @@ "x86_64-apple-ios-simulator": "x86_64-iphonesimulator", }, }, + "tvOS": { + "tvos-arm64": { + "arm64-apple-tvos": "arm64-appletvos", + }, + "tvos-arm64_x86_64-simulator": { + "arm64-apple-tvos-simulator": "arm64-appletvsimulator", + "x86_64-apple-tvos-simulator": "x86_64-appletvsimulator", + }, + }, + "visionOS": { + "xros-arm64": { + "arm64-apple-xros": "arm64-xros", + }, + "xros-arm64-simulator": { + "arm64-apple-xros-simulator": "arm64-xrsimulator", + }, + }, + "watchOS": { + "watchos-arm64_32": { + "arm64_32-apple-watchos": "arm64_32-watchos", + }, + "watchos-arm64_x86_64-simulator": { + "arm64-apple-watchos-simulator": "arm64-watchsimulator", + "x86_64-apple-watchos-simulator": "x86_64-watchsimulator", + }, + }, +} + +# The configure arguments needed to produce each ABI flag. Flags are listed in +# the order that configure adds them to ABIFLAGS; any `--abiflags` value must +# use the same order. +ABIFLAG_CONFIGURE_ARGS: dict[str, list[str]] = { + "t": ["--disable-gil"], + "d": ["--with-pydebug"], } +def platform_name(value): + """Return the canonical spelling for a platform name.""" + return {p.lower(): p for p in HOSTS.keys()}.get(value.lower(), value) + + +def validate_abiflags(value: str) -> str: + """Validate an `--abiflags` value (for use as an argparse type).""" + known = "".join(ABIFLAG_CONFIGURE_ARGS) + for flag in value: + if flag not in ABIFLAG_CONFIGURE_ARGS: + raise argparse.ArgumentTypeError( + f"unknown ABI flag {flag!r} (known flags: {known!r})" + ) + positions = [known.index(flag) for flag in value] + if positions != sorted(set(positions)): + raise argparse.ArgumentTypeError( + f"ABI flags must be unique, and in the order {known!r}" + ) + return value + + +def framework_name(abiflags: str) -> str: + """The name of the Python framework for the given ABI flags.""" + return f"Python{abiflags.upper()}" + + +def abiflag_configure_args(abiflags: str) -> list[str]: + """The configure arguments needed to produce the given ABI flags.""" + return [arg for flag in abiflags for arg in ABIFLAG_CONFIGURE_ARGS[flag]] + + +def cross_build_dir(base: Path, abiflags: str) -> Path: + """The cross-build directory for the given base and ABI flags.""" + return base.with_name(f"{base.name}-{abiflags}") if abiflags else base + + def subdir(name: str, create: bool = False) -> Path: """Ensure that a cross-build directory for the given name exists.""" path = CROSS_BUILD_DIR / name @@ -136,11 +209,24 @@ def print_env(env: EnvironmentT) -> None: print(f"export {key}={shlex.quote(value)}") +def platform_for_host(host): + """Determine the platform for a given host triple.""" + for plat, slices in HOSTS.items(): + for _, candidates in slices.items(): + for candidate in candidates: + if candidate == host: + return plat + raise KeyError(host) + + def apple_env(host: str) -> EnvironmentT: """Construct an Apple development environment for the given host.""" env = { "PATH": ":".join([ - str(PYTHON_DIR / "Platforms/Apple/iOS/Resources/bin"), + str( + PYTHON_DIR + / f"Platforms/Apple/{platform_for_host(host)}/Resources/bin" + ), str(subdir(host) / "prefix"), "/usr/bin", "/bin", @@ -258,6 +344,7 @@ def configure_build_python(context: argparse.Namespace) -> None: cwd(subdir("build", create=True)), ): command = [relpath(PYTHON_DIR / "configure")] + command.extend(abiflag_configure_args(context.abiflags)) if context.args: command.extend(context.args) run(command) @@ -314,8 +401,8 @@ def unpack_deps( Downloads binaries if they aren't already present. Downloads will be stored in provided cache directory. - On iOS, as a safety mechanism, any dynamic libraries will be purged from - the unpacked dependencies. + On non-macOS platforms, as a safety mechanism, any dynamic libraries will + be purged from the unpacked dependencies. """ # To create new builds of these dependencies, usually all that's necessary # is to push a tag to the cpython-apple-source-deps repository, and GitHub @@ -328,10 +415,10 @@ def unpack_deps( for name_ver in [ "BZip2-1.0.8-2", "libFFI-3.4.7-2", - "OpenSSL-3.5.7-1", + "OpenSSL-3.5.9-1", "XZ-5.6.4-2", "mpdecimal-4.0.0-2", - "zstd-1.5.7-1", + "zstd-1.6.0-1", ]: filename = f"{name_ver.lower()}-{apple_target(host)}.tar.gz" archive_path = download( @@ -340,9 +427,9 @@ def unpack_deps( ) shutil.unpack_archive(archive_path, prefix_dir) - # Dynamic libraries will be preferentially linked over static; - # On iOS, ensure that no dylibs are available in the prefix folder. - if platform == "iOS": + # Dynamic libraries will be preferentially linked over static; On non-macOS + # platforms, ensure that no dylibs are available in the prefix folder. + if platform != "macOS": for dylib in prefix_dir.glob("**/*.dylib"): dylib.unlink() @@ -408,7 +495,7 @@ def configure_host_python( f"--host={host}", f"--build={sysconfig.get_config_var('BUILD_GNU_TYPE')}", f"--with-build-python={build_python_path()}", - "--with-system-libmpdec", + "--enable-ipv6", "--enable-framework", # Dependent libraries. f"--with-openssl={prefix_dir}", @@ -421,6 +508,11 @@ def configure_host_python( f"LIBZSTD_CFLAGS=-I{prefix_dir}/include", f"LIBZSTD_LIBS=-L{prefix_dir}/lib -lzstd", ] + command.extend(abiflag_configure_args(context.abiflags)) + if context.abiflags: + command.append( + f"--with-framework-name={framework_name(context.abiflags)}" + ) if context.args: command.extend(context.args) @@ -451,7 +543,8 @@ def framework_path(host_triple: str, multiarch: str) -> Path: """ return ( CROSS_BUILD_DIR - / f"{host_triple}/Platforms/Apple/iOS/Frameworks/{multiarch}" + / f"{host_triple}/Platforms/Apple/{platform_for_host(host_triple)}" + / f"Frameworks/{multiarch}" ) @@ -522,11 +615,16 @@ def lib_non_platform_files(dirname, names): return set() -def create_xcframework(platform: str) -> str: +def create_xcframework(platform: str, abiflags: str) -> str: """Build an XCframework from the component parts for the platform. + :param platform: The platform being packaged (e.g., iOS). + :param abiflags: The ABI flags of the build (e.g., "t"). :return: The version number of the Python version that was packaged. """ + fw_name = framework_name(abiflags) + # The stdlib directory only carries the threading ABI flag. + abi_thread = "t" if "t" in abiflags else "" package_path = CROSS_BUILD_DIR / platform try: package_path.mkdir() @@ -548,7 +646,7 @@ def create_xcframework(platform: str) -> str: first_host_triple, first_multiarch = next(iter(slice_parts.items())) first_framework = ( framework_path(first_host_triple, first_multiarch) - / "Python.framework" + / f"{fw_name}.framework" ) if len(slice_parts) == 1: @@ -558,7 +656,7 @@ def create_xcframework(platform: str) -> str: else: print(f"Merging framework for {slice_name}...") slice_path = CROSS_BUILD_DIR / slice_name - slice_framework = slice_path / "Python.framework" + slice_framework = slice_path / f"{fw_name}.framework" slice_framework.mkdir(exist_ok=True, parents=True) # Copy the Info.plist @@ -575,11 +673,11 @@ def create_xcframework(platform: str) -> str: # Create the "fat" library binary for the slice run( - ["lipo", "-create", "-output", slice_framework / "Python"] + ["lipo", "-create", "-output", slice_framework / fw_name] + [ ( framework_path(host_triple, multiarch) - / "Python.framework/Python" + / f"{fw_name}.framework/{fw_name}" ) for host_triple, multiarch in slice_parts.items() ] @@ -594,7 +692,7 @@ def create_xcframework(platform: str) -> str: "xcodebuild", "-create-xcframework", "-output", - package_path / "Python.xcframework", + package_path / f"{fw_name}.xcframework", ] for framework in frameworks: cmd.extend(["-framework", framework]) @@ -602,7 +700,7 @@ def create_xcframework(platform: str) -> str: run(cmd) # Extract the package version from the merged framework - version = package_version(package_path / "Python.xcframework") + version = package_version(package_path / f"{fw_name}.xcframework") version_tag = ".".join(version.split(".")[:2]) # On non-macOS platforms, each framework in XCframework only contains the @@ -617,10 +715,10 @@ def create_xcframework(platform: str) -> str: # host frameworks as the source for the merged version. first_host_triple, first_multiarch = next(iter(slice_parts.items())) first_path = framework_path(first_host_triple, first_multiarch) - first_framework = first_path / "Python.framework" + first_framework = first_path / f"{fw_name}.framework" - slice_path = package_path / f"Python.xcframework/{slice_name}" - slice_framework = slice_path / "Python.framework" + slice_path = package_path / f"{fw_name}.xcframework/{slice_name}" + slice_framework = slice_path / f"{fw_name}.framework" # Copy the binary helpers print(f" - {slice_name} binaries") @@ -642,9 +740,9 @@ def create_xcframework(platform: str) -> str: print(f" - {slice_name} shared library") # Create a simlink for the fat library - shared_lib = slice_path / f"lib/libpython{version_tag}.dylib" + shared_lib = slice_path / f"lib/libpython{version_tag}{abiflags}.dylib" shared_lib.parent.mkdir() - shared_lib.symlink_to("../Python.framework/Python") + shared_lib.symlink_to(f"../{fw_name}.framework/{fw_name}") print(f" - {slice_name} architecture-specific files") for host_triple, multiarch in slice_parts.items(): @@ -655,7 +753,7 @@ def create_xcframework(platform: str) -> str: print(" - using this architecture as the common stdlib") shutil.copytree( framework_path(host_triple, multiarch) / "lib", - package_path / "Python.xcframework/lib", + package_path / f"{fw_name}.xcframework/lib", ignore=lib_platform_files, symlinks=True, ) @@ -673,10 +771,10 @@ def create_xcframework(platform: str) -> str: host_path = ( CROSS_BUILD_DIR / host_triple - / "Platforms/Apple/iOS/Frameworks" + / f"Platforms/Apple/{platform}/Frameworks" / multiarch ) - host_framework = host_path / "Python.framework" + host_framework = host_path / f"{fw_name}.framework" shutil.copy( host_framework / "Headers/pyconfig.h", slice_framework / f"Headers/pyconfig-{arch}.h", @@ -697,14 +795,17 @@ def create_xcframework(platform: str) -> str: shutil.copy( xcprivacy_file[lib], slice_path - / f"lib-{arch}/python{version_tag}" + / f"lib-{arch}/python{version_tag}{abi_thread}" / f"lib-dynload/{module}.xcprivacy", ) print(" - build tools") shutil.copytree( - PYTHON_DIR / "Platforms/Apple/testbed/Python.xcframework/build", - package_path / "Python.xcframework/build", + PYTHON_DIR + / "Platforms/Apple/testbed" + / "Python.xcframework" + / "build", + package_path / f"{fw_name}.xcframework/build", ) return version @@ -717,7 +818,8 @@ def package(context: argparse.Namespace) -> None: with group("Building package"): # Create an XCframework - version = create_xcframework(context.platform) + version = create_xcframework(context.platform, context.abiflags) + fw_name = framework_name(context.abiflags) # Clone testbed print() @@ -728,7 +830,7 @@ def package(context: argparse.Namespace) -> None: "--platform", context.platform, "--framework", - CROSS_BUILD_DIR / context.platform / "Python.xcframework", + CROSS_BUILD_DIR / context.platform / f"{fw_name}.xcframework", CROSS_BUILD_DIR / context.platform / "testbed", ]) @@ -736,7 +838,10 @@ def package(context: argparse.Namespace) -> None: archive_name = ( CROSS_BUILD_DIR / "dist" - / f"python-{version}-{context.platform}-XCframework" + / ( + f"python-{version}{context.abiflags}" + f"-{context.platform}-XCframework" + ) ) print() @@ -800,7 +905,9 @@ def test(context: argparse.Namespace, host: str | None = None) -> None: # noqa: ) if host in {"all", "hosts"}: framework_path = ( - CROSS_BUILD_DIR / context.platform / "Python.xcframework" + CROSS_BUILD_DIR + / context.platform + / f"{framework_name(context.abiflags)}.xcframework" ) else: build_arch = platform.machine() @@ -952,6 +1059,7 @@ def parse_args() -> argparse.Namespace: cmd.add_argument( "platform", choices=HOSTS.keys(), + type=platform_name, help="The target platform to build", ) @@ -975,7 +1083,7 @@ def parse_args() -> argparse.Namespace: ), ) - # --cross-build-dir argument + # --cross-build-dir and --abiflags arguments for cmd in [ clean, configure_build, @@ -995,9 +1103,20 @@ def parse_args() -> argparse.Namespace: dest="cross_build_dir", type=Path, help=( - "Path to the cross-build directory " + "Base path of the cross-build directory " f"(default: {CROSS_BUILD_DIR}). Can also be set " - "with the CROSS_BUILD_DIR environment variable." + "with the CROSS_BUILD_DIR environment variable. If " + "--abiflags is specified, '-' is appended." + ), + ) + cmd.add_argument( + "--abiflags", + default="", + type=validate_abiflags, + help=( + "The ABI flags of the build: 't' (free-threaded; " + "--disable-gil), 'd' (debug; --with-pydebug), or 'td' (both). " + "Defaults to '' (a standard build)." ), ) @@ -1083,10 +1202,12 @@ def signal_handler(*args): # Process command line arguments context = parse_args() - # Set the CROSS_BUILD_DIR if an argument was provided + # Set the CROSS_BUILD_DIR, using any provided base directory, plus any ABI + # flags as a suffix. + global CROSS_BUILD_DIR if context.cross_build_dir: - global CROSS_BUILD_DIR CROSS_BUILD_DIR = context.cross_build_dir.resolve() + CROSS_BUILD_DIR = cross_build_dir(CROSS_BUILD_DIR, context.abiflags) dispatch: dict[str, Callable] = { "clean": clean, diff --git a/Platforms/Apple/iOS/README.md b/Platforms/Apple/iOS/README.md index faeeead1df03a2e..975c3056e98e0ae 100644 --- a/Platforms/Apple/iOS/README.md +++ b/Platforms/Apple/iOS/README.md @@ -7,9 +7,8 @@ Python distribution. These instructions are only needed if you're planning to compile Python for iOS yourself. Most users should *not* need to do this. If you're looking to -experiment with writing an iOS app in Python, tools such as [BeeWare's -Briefcase](https://briefcase.readthedocs.io) and [Kivy's -Buildozer](https://buildozer.readthedocs.io) will provide a much more +experiment with writing an iOS app in Python, use one of the tools listed in +[Using Python on iOS](https://docs.python.org/3/using/ios.html) for a much more approachable user experience. ## Compilers for building on iOS @@ -76,6 +75,39 @@ complete "build and test" CI run. The `--clean` flag can also be used on individual commands to ensure that a stale build product are removed before building. +### Building with ABI flags + +By default, the `Platforms/Apple` build script produces a GIL-enabled, +non-debug build of Python. The `--abiflags` option can be passed to any +command of the build script to build a variant of Python with different +ABI flags: + +* `t` - a free-threaded build (`--disable-gil`) +* `d` - a debug build (`--with-pydebug`) +* `td` - a free-threaded debug build + +For example, to build and test a free-threaded XCframework, run: + + python Platforms/Apple ci iOS --abiflags t + +When ABI flags are specified: + +* The ABI flags are appended to the name of the cross-build directory. The + free-threaded example above uses `cross-build-t`. If you specify a custom + location with `--cross-build-dir` (or the `CROSS_BUILD_DIR` environment + variable), that location is used as the base name, so `--cross-build-dir foo + --abiflags t` uses `foo-t`. This lets builds with different ABI flags + co-exist. +* The framework is named `Python` followed by the uppercased ABI flags. For + example, a free-threaded build produces `PythonT.framework` and + `PythonT.xcframework`, and its headers are included as + `#include `. +* The release archive includes the ABI flags in the version, e.g. + `python-3.X.Yt-iOS-XCframework.tar.gz`. + +The same `--abiflags` value must be passed to every command that operates on a +given build. + ### Building a single-architecture framework If you're using the `Platforms/Apple` build script, you won't need to build @@ -90,19 +122,26 @@ Python build for a single framework, the following options are available. installed. If `DIR` is not specified, the framework will be installed into a subdirectory of the `iOS/Frameworks` folder. - This argument *must* be provided when configuring iOS builds. iOS does not - support non-framework builds. + This argument is required for any iOS build that will be distributed, and + for any build that needs to load binary extension modules. + + Omitting it builds a static `libpython` for embedding directly in an app + binary, instead of a `Python.framework`. That configuration comes with + significant restrictions; see [Building a static + Python](#building-a-static-python) below. * `--with-framework-name=NAME` Specify the name for the Python framework; defaults to `Python`. > [!NOTE] - > Unless you know what you're doing, changing the name of the Python - > framework on iOS is not advised. If you use this option, you won't be able - > to run the `Platforms/Apple` build script without making significant manual - > alterations, and you won't be able to use any binary packages unless you - > compile them yourself using your own framework name. + > Builds that use ABI flags (such as free-threaded or debug builds) should + > use a framework name of `Python`, followed by the uppercased ABI flags + > (e.g., `PythonT` for a free-threaded build). The `Platforms/Apple` build + > script and the testbed rely on this naming convention. Other than this + > convention, changing the name of the Python framework on iOS is not + > advised; you won't be able to use any binary packages unless you compile + > them yourself using your own framework name. #### Building Python for iOS @@ -113,9 +152,11 @@ framework to contain non-library content, so the iOS build will produce a The `lib` folder will be needed at runtime to support the Python library. If you want to use Python in a real iOS project, you need to produce multiple -`Python.framework` builds, one for each ABI and architecture. iOS builds of -Python *must* be constructed as framework builds. To support this, you must -provide the `--enable-framework` flag when configuring the build. The build +`Python.framework` builds, one for each ABI and architecture. Unless you are +statically linking Python into your app (see [Building a static +Python](#building-a-static-python) below), iOS builds of Python *must* be +constructed as framework builds. To support this, you must provide the +`--enable-framework` flag when configuring the build. The build also requires the use of cross-compilation. The minimal commands for building Python for the ARM64 iOS simulator will look something like: ``` @@ -216,6 +257,68 @@ target, provide the version number as part of the `--host` argument - for example, `--host=arm64-apple-ios15.4-simulator` would compile an ARM64 simulator build with a deployment target of 15.4. +### Building a static Python + +The official iOS release artefact is a framework build. However, if you are +embedding Python in an app that links `libpython` at compile time, you can +instead build a static `libpython3.x.a`, and link that archive directly into +your app binary. + +The App Store requirement that binary modules be packaged as signed frameworks +does not apply to a static build, because a static build loads nothing at +runtime; but for the same reason, this configuration cannot use *any* binary +module that isn't compiled into the app binary. The restrictions that follow +from that must be opted into explicitly at configure time: + +* `MODULE_BUILDTYPE=static` is required. There is no framework for a shared + extension module to link against, so every extension module, including the + ones in the standard library, must be linked into `libpython`. + +* `--disable-test-modules` is required. Some test modules must be compiled as + shared libraries (see `Modules/Setup.stdlib.in`), so they cannot be built in + this configuration at all. + +A non-framework build is selected by omitting `--enable-framework`; +`--disable-framework` is accepted as an explicit spelling of the same thing. + +The minimal commands for a static build targeting ARM64 iOS devices are then: +``` +export PATH="$(pwd)/Platforms/Apple/iOS/Resources/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin" +./configure \ + --prefix=/path/to/install/dir \ + --disable-test-modules \ + MODULE_BUILDTYPE=static \ + --host=arm64-apple-ios \ + --build=arm64-apple-darwin \ + --with-build-python=/path/to/python.exe +make +make install +``` +This produces a `libpython3.x.a` containing the interpreter and the standard +library's extension modules; `make install` installs that archive, along with +the standard library's Python source, into the location given by `--prefix`. +Unlike a framework build, `--prefix` is not set for you, so specify it +explicitly - otherwise `libpython` will be installed into `/usr/local`. + +#### Limitations of a static build + +* **Binary wheels cannot be used.** There is no `libpython` dylib for a + third-party extension module to link against, and a static Python has nothing + to `dlopen` in any case. Pure Python wheels work as normal; any package with a + C extension must be compiled into the app binary alongside `libpython`. + +* **The standard library's extension modules are not loadable modules.** They + live in the archive, not in `.framework` bundles in the app's `Frameworks` + folder, so the packaging described in + [Using Python on iOS](https://docs.python.org/3/using/ios.html) does not apply + to them. + +* **The test suite cannot be run as-is**, as the test modules are not built. + +* This configuration is not covered by the `Platforms/Apple` build script, nor + by CPython's CI. It is not the configuration used to produce official + releases. + ## Testing Python on iOS ### Testing a multi-architecture framework @@ -271,10 +374,11 @@ project, and then boot and prepare the iOS simulator. Running `python Platforms/Apple test iOS` generates a standalone version of the `Platforms/Apple/testbed` project, and runs the full test suite. It does this using -`Platforms/Apple/testbed` itself - the folder is an executable module that can be used -to create and run a clone of the testbed project. The standalone version of the -testbed will be created in a directory named -`cross-build/iOS-testbed.`. +`Platforms/Apple/testbed` itself - the folder is a template for an executable module +that can be used to create and run a clone of the testbed project. The standalone +version of the testbed will be created in a directory named +`cross-build/iOS-testbed.`. Builds that use ABI flags use the +`cross-build-` directory instead (e.g., `cross-build-t`). You can generate your own standalone testbed instance by running: ``` @@ -290,9 +394,22 @@ you can construct a standalone testbed instance by running: python Platforms/Apple/testbed clone --platform iOS --framework my-testbed ``` -The framework path can be the path path to a `Python.xcframework`, or the +The framework path can be the path to a `Python.xcframework`, or the path to a folder that contains a single-platform `Python.framework`. +The `Platforms/Apple/testbed` folder is a template. Any reference to the +Python framework uses the placeholder `Python{{abiflags}}`. When the template +project is cloned, the placeholder is replaced with the name of the framework +being installed; the ABI flags are inferred automatically from the +`--framework` argument. For example, to clone a testbed for a free-threaded +framework: +``` +python Platforms/Apple/testbed clone --platform iOS --framework my-testbed +``` + +A cloned testbed is configured for one specific framework. It can be cloned +again, but it can't be re-targeted to a framework with different ABI flags. + You can then use the `my-testbed` folder to run the Python test suite, passing in any command line arguments you may require. For example, if you're trying to diagnose a failure in the `os` module, you might run: diff --git a/Platforms/Apple/iOS/Resources/Info.plist.in b/Platforms/Apple/iOS/Resources/Info.plist.in index c3e261ecd9eff70..1756208de405b13 100644 --- a/Platforms/Apple/iOS/Resources/Info.plist.in +++ b/Platforms/Apple/iOS/Resources/Info.plist.in @@ -5,7 +5,7 @@ CFBundleDevelopmentRegion en CFBundleExecutable - Python + @PYTHONFRAMEWORK@ CFBundleGetInfoString Python Runtime and Library CFBundleIdentifier @@ -13,17 +13,17 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - Python + @PYTHONFRAMEWORK@ CFBundlePackageType FMWK CFBundleShortVersionString - @VERSION@ + %VERSION% CFBundleLongVersionString %VERSION%, (c) 2001-2024 Python Software Foundation. CFBundleSignature ???? CFBundleVersion - 1 + %VERSION% CFBundleSupportedPlatforms iPhoneOS diff --git a/Platforms/Apple/testbed/Python.xcframework/Info.plist b/Platforms/Apple/testbed/Python.xcframework/Info.plist index c6418de6e74a4e9..fa9784c43303b7c 100644 --- a/Platforms/Apple/testbed/Python.xcframework/Info.plist +++ b/Platforms/Apple/testbed/Python.xcframework/Info.plist @@ -6,11 +6,11 @@ BinaryPath - Python.framework/Python + Python{{abiflags}}.framework/Python{{abiflags}} LibraryIdentifier ios-arm64 LibraryPath - Python.framework + Python{{abiflags}}.framework SupportedArchitectures arm64 @@ -20,11 +20,11 @@ BinaryPath - Python.framework/Python + Python{{abiflags}}.framework/Python{{abiflags}} LibraryIdentifier ios-arm64_x86_64-simulator LibraryPath - Python.framework + Python{{abiflags}}.framework SupportedArchitectures arm64 @@ -35,6 +35,98 @@ SupportedPlatformVariant simulator + + BinaryPath + Python.framework/Python + LibraryIdentifier + tvos-arm64 + LibraryPath + Python.framework + SupportedArchitectures + + arm64 + + SupportedPlatform + tvos + + + BinaryPath + Python.framework/Python + LibraryIdentifier + tvos-arm64_x86_64-simulator + LibraryPath + Python.framework + SupportedArchitectures + + arm64 + x86_64 + + SupportedPlatform + tvos + SupportedPlatformVariant + simulator + + + BinaryPath + Python.framework/Python + LibraryIdentifier + xros-arm64-simulator + LibraryPath + Python.framework + SupportedArchitectures + + arm64 + + SupportedPlatform + xros + SupportedPlatformVariant + simulator + + + BinaryPath + Python.framework/Python + LibraryIdentifier + xros-arm64 + LibraryPath + Python.framework + SupportedArchitectures + + arm64 + + SupportedPlatform + xros + + + BinaryPath + Python.framework/Python + LibraryIdentifier + watchos-arm64_x86_64-simulator + LibraryPath + Python.framework + SupportedArchitectures + + arm64 + x86_64 + + SupportedPlatform + watchos + SupportedPlatformVariant + simulator + + + BinaryPath + Python.framework/Python + LibraryIdentifier + watchos-arm64_32 + LibraryPath + Python.framework + SupportedArchitectures + + arm64_32 + + SupportedPlatform + watchos + CFBundlePackageType XFWK diff --git a/Platforms/Apple/testbed/Python.xcframework/build/tvOS-dylib-Info-template.plist b/Platforms/Apple/testbed/Python.xcframework/build/tvOS-dylib-Info-template.plist new file mode 100644 index 000000000000000..a20d476fa7b5524 --- /dev/null +++ b/Platforms/Apple/testbed/Python.xcframework/build/tvOS-dylib-Info-template.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + + CFBundleIdentifier + + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSupportedPlatforms + + tvOS + + MinimumOSVersion + 9.0 + CFBundleVersion + 1 + + diff --git a/Platforms/Apple/testbed/Python.xcframework/build/utils.sh b/Platforms/Apple/testbed/Python.xcframework/build/utils.sh index e54471f68b7cb2c..53801215377fd86 100755 --- a/Platforms/Apple/testbed/Python.xcframework/build/utils.sh +++ b/Platforms/Apple/testbed/Python.xcframework/build/utils.sh @@ -14,7 +14,7 @@ # * There is an `app_packages` folder that contains installed Python packages. # ----- # set -e -# source $PROJECT_DIR/Python.xcframework/build/build_utils.sh +# source "$PROJECT_DIR/Python.xcframework/build/utils.sh" # install_python Python.xcframework app app_packages # ----- @@ -34,9 +34,38 @@ install_stdlib() { else SLICE_FOLDER="ios-arm64_x86_64-simulator" fi - else + elif [ "$EFFECTIVE_PLATFORM_NAME" = "-iphoneos" ]; then echo "Installing Python modules for iOS Device" SLICE_FOLDER="ios-arm64" + elif [ "$EFFECTIVE_PLATFORM_NAME" = "-appletvsimulator" ]; then + echo "Installing Python modules for tvOS Simulator" + if [ -d "$PROJECT_DIR/$PYTHON_XCFRAMEWORK_PATH/tvos-arm64-simulator" ]; then + SLICE_FOLDER="tvos-arm64-simulator" + else + SLICE_FOLDER="tvos-arm64_x86_64-simulator" + fi + elif [ "$EFFECTIVE_PLATFORM_NAME" = "-appletvos" ]; then + echo "Installing Python modules for tvOS Device" + SLICE_FOLDER="tvos-arm64" + elif [ "$EFFECTIVE_PLATFORM_NAME" = "-watchsimulator" ]; then + echo "Installing Python modules for watchOS Simulator" + if [ -d "$PROJECT_DIR/$PYTHON_XCFRAMEWORK_PATH/watchos-arm64-simulator" ]; then + SLICE_FOLDER="watchos-arm64-simulator" + else + SLICE_FOLDER="watchos-arm64_x86_64-simulator" + fi + elif [ "$EFFECTIVE_PLATFORM_NAME" = "-watchos" ]; then + echo "Installing Python modules for watchOS Device" + SLICE_FOLDER="watchos-arm64_32" + elif [ "$EFFECTIVE_PLATFORM_NAME" = "-xrsimulator" ]; then + echo "Installing Python modules for visionOS Simulator" + SLICE_FOLDER="xros-arm64-simulator" + elif [ "$EFFECTIVE_PLATFORM_NAME" = "-xros" ]; then + echo "Installing Python modules for visionOS Device" + SLICE_FOLDER="xros-arm64" + else + echo "Unsupported platform name $EFFECTIVE_PLATFORM_NAME" + exit 1 fi # If the XCframework has a shared lib folder, then it's a full framework. @@ -72,9 +101,9 @@ install_dylib () { MODULE_PATH=$(dirname "$FULL_EXT") MODULE_NAME=$(echo $EXT | cut -d "." -f 1) # The location of the extension file, relative to the bundle - RELATIVE_EXT=${FULL_EXT#$CODESIGNING_FOLDER_PATH/} + RELATIVE_EXT=${FULL_EXT#"$CODESIGNING_FOLDER_PATH"/} # The path to the extension file, relative to the install base - PYTHON_EXT=${RELATIVE_EXT/$INSTALL_BASE/} + PYTHON_EXT=${RELATIVE_EXT/"$INSTALL_BASE"/} # The full dotted name of the extension module, constructed from the file path. FULL_MODULE_NAME=$(echo $PYTHON_EXT | cut -d "." -f 1 | tr "/" "."); # A bundle identifier; not actually used, but required by Xcode framework packaging @@ -123,8 +152,8 @@ install_dylib () { process_dylibs () { PYTHON_XCFRAMEWORK_PATH=$1 LIB_PATH=$2 - find "$CODESIGNING_FOLDER_PATH/$LIB_PATH" -name "*.so" | while read FULL_EXT; do - install_dylib $PYTHON_XCFRAMEWORK_PATH "$LIB_PATH/" "$FULL_EXT" + find "$CODESIGNING_FOLDER_PATH/$LIB_PATH" -name "*.so" | while read -r FULL_EXT; do + install_dylib "$PYTHON_XCFRAMEWORK_PATH" "$LIB_PATH/" "$FULL_EXT" done } @@ -139,13 +168,13 @@ install_python() { PYTHON_XCFRAMEWORK_PATH=$1 shift - install_stdlib $PYTHON_XCFRAMEWORK_PATH - PYTHON_VER=$(ls -1 "$CODESIGNING_FOLDER_PATH/python/lib" | grep -E "^python3\.\d+$") + install_stdlib "$PYTHON_XCFRAMEWORK_PATH" + PYTHON_VER=$(ls -1 "$CODESIGNING_FOLDER_PATH/python/lib" | grep -E "^python3\.\d+[a-z]*$") echo "Install Python $PYTHON_VER standard library extension modules..." - process_dylibs $PYTHON_XCFRAMEWORK_PATH python/lib/$PYTHON_VER/lib-dynload + process_dylibs "$PYTHON_XCFRAMEWORK_PATH" python/lib/$PYTHON_VER/lib-dynload - for package_path in $@; do + for package_path in "$@"; do echo "Installing $package_path extension modules ..." - process_dylibs $PYTHON_XCFRAMEWORK_PATH $package_path + process_dylibs "$PYTHON_XCFRAMEWORK_PATH" "$package_path" done } diff --git a/Platforms/Apple/testbed/Python.xcframework/build/watchOS-dylib-Info-template.plist b/Platforms/Apple/testbed/Python.xcframework/build/watchOS-dylib-Info-template.plist new file mode 100644 index 000000000000000..6f8c0bc20959555 --- /dev/null +++ b/Platforms/Apple/testbed/Python.xcframework/build/watchOS-dylib-Info-template.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + + CFBundleIdentifier + + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSupportedPlatforms + + watchOS + + MinimumOSVersion + 4.0 + CFBundleVersion + 1 + + diff --git a/Platforms/Apple/testbed/Python.xcframework/build/xrOS-dylib-Info-template.plist b/Platforms/Apple/testbed/Python.xcframework/build/xrOS-dylib-Info-template.plist new file mode 100644 index 000000000000000..e91673b4fbcbc45 --- /dev/null +++ b/Platforms/Apple/testbed/Python.xcframework/build/xrOS-dylib-Info-template.plist @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleInfoDictionaryVersion + 6.0 + CFBundleExecutable + + CFBundleIdentifier + + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSupportedPlatforms + + XROS + + CFBundleVersion + 1 + MinimumOSVersion + 2.0 + UIDeviceFamily + + 7 + + + diff --git a/Platforms/Apple/testbed/Python.xcframework/tvos-arm64/README b/Platforms/Apple/testbed/Python.xcframework/tvos-arm64/README new file mode 100644 index 000000000000000..ebd648d04bd6df8 --- /dev/null +++ b/Platforms/Apple/testbed/Python.xcframework/tvos-arm64/README @@ -0,0 +1,4 @@ +This directory is intentionally empty. + +It should be used as a target for `--enable-framework` when compiling a tvOS +on-device build for testing purposes. diff --git a/Platforms/Apple/testbed/Python.xcframework/tvos-arm64_x86_64-simulator/README b/Platforms/Apple/testbed/Python.xcframework/tvos-arm64_x86_64-simulator/README new file mode 100644 index 000000000000000..f8163468d8c557e --- /dev/null +++ b/Platforms/Apple/testbed/Python.xcframework/tvos-arm64_x86_64-simulator/README @@ -0,0 +1,4 @@ +This directory is intentionally empty. + +It should be used as a target for `--enable-framework` when compiling a tvOS +simulator build for testing purposes (either x86_64 or ARM64). diff --git a/Platforms/Apple/testbed/Python.xcframework/watchos-arm64_32/README b/Platforms/Apple/testbed/Python.xcframework/watchos-arm64_32/README new file mode 100644 index 000000000000000..696af231df39d79 --- /dev/null +++ b/Platforms/Apple/testbed/Python.xcframework/watchos-arm64_32/README @@ -0,0 +1,4 @@ +This directory is intentionally empty. + +It should be used as a target for `--enable-framework` when compiling a watchOS on-device +build for testing purposes. diff --git a/Platforms/Apple/testbed/Python.xcframework/watchos-arm64_x86_64-simulator/README b/Platforms/Apple/testbed/Python.xcframework/watchos-arm64_x86_64-simulator/README new file mode 100644 index 000000000000000..d38e1e982766ad1 --- /dev/null +++ b/Platforms/Apple/testbed/Python.xcframework/watchos-arm64_x86_64-simulator/README @@ -0,0 +1,4 @@ +This directory is intentionally empty. + +It should be used as a target for `--enable-framework` when compiling a watchOS +simulator build for testing purposes (either x86_64 or ARM64). diff --git a/Platforms/Apple/testbed/Python.xcframework/xros-arm64-simulator/README b/Platforms/Apple/testbed/Python.xcframework/xros-arm64-simulator/README new file mode 100644 index 000000000000000..7bb0ad4b6baa9c2 --- /dev/null +++ b/Platforms/Apple/testbed/Python.xcframework/xros-arm64-simulator/README @@ -0,0 +1,4 @@ +This directory is intentionally empty. + +It should be used as a target for `--enable-framework` when compiling an visionOS simulator +build for testing purposes (either x86_64 or ARM64). diff --git a/Platforms/Apple/testbed/Python.xcframework/xros-arm64/README b/Platforms/Apple/testbed/Python.xcframework/xros-arm64/README new file mode 100644 index 000000000000000..2fc2112e47757ab --- /dev/null +++ b/Platforms/Apple/testbed/Python.xcframework/xros-arm64/README @@ -0,0 +1,4 @@ +This directory is intentionally empty. + +It should be used as a target for `--enable-framework` when compiling an visionOS on-device +build for testing purposes. diff --git a/Platforms/Apple/testbed/TestbedTests/TestbedTests.m b/Platforms/Apple/testbed/TestbedTests/TestbedTests.m index f7788c47f2c2296..435872e5e162199 100644 --- a/Platforms/Apple/testbed/TestbedTests/TestbedTests.m +++ b/Platforms/Apple/testbed/TestbedTests/TestbedTests.m @@ -1,5 +1,5 @@ #import -#import +#import @interface TestbedTests : XCTestCase diff --git a/Platforms/Apple/testbed/__main__.py b/Platforms/Apple/testbed/__main__.py index 797b522678f9d74..7ae7d8e710373cb 100644 --- a/Platforms/Apple/testbed/__main__.py +++ b/Platforms/Apple/testbed/__main__.py @@ -10,8 +10,20 @@ TEST_SLICES = { "iOS": "ios-arm64_x86_64-simulator", + "tvOS": "tvos-arm64_x86_64-simulator", + "visionOS": "xros-arm64-simulator", + "watchOS": "watchos-arm64_x86_64-simulator", } +# The checked-in testbed is a template. Any file containing this placeholder +# is rewritten by `clone`, replacing the placeholder with the (uppercased) +# ABI flags of the framework being installed. The placeholder is constructed +# so that it doesn't appear literally in this file. +ABIFLAGS_PLACEHOLDER = "{{" + "abiflags" + "}}" + +FRAMEWORK_NAME_RE = re.compile(r"Python([A-Z]*)") + + DECODE_ARGS = ("UTF-8", "backslashreplace") # The system log prefixes each line: @@ -21,7 +33,7 @@ LOG_PREFIX_REGEX = re.compile( r"^\d{4}-\d{2}-\d{2}" # YYYY-MM-DD r"\s+\d+:\d{2}:\d{2}\.\d+\+\d{4}" # HH:MM:SS.ssssss+ZZZZ - r"\s+iOSTestbed\[\d+:\w+\] " # Process/thread ID + r"\s+.*Testbed\[\d+:\w+\] " # Process/thread ID ) @@ -54,6 +66,34 @@ def select_simulator_device(platform): ) ) simulator = se_simulators[-1][1] + elif platform == "tvOS": + # Find the most recent tvOS release. + simulators = sorted( + (devicetype["minRuntimeVersion"], devicetype["name"]) + for devicetype in json_data["devicetypes"] + if devicetype["productFamily"] == "Apple TV" + ) + simulator = simulators[-1][1] + elif platform == "visionOS": + # Find the most recent visionOS release. + simulators = sorted( + (devicetype["minRuntimeVersion"], devicetype["name"]) + for devicetype in json_data["devicetypes"] + if devicetype["productFamily"] == "Apple Vision" + ) + simulator = simulators[-1][1] + elif platform == "watchOS": + # Any watchOS device will do; we'll look for "SE" devices. Select the + # one with the highest minimum runtime version - this is an indicator + # of the "newest" released device, which should always be supported + # on the "most recent" watchOS version. + se_simulators = sorted( + (devicetype["minRuntimeVersion"], devicetype["name"]) + for devicetype in json_data["devicetypes"] + if devicetype["productFamily"] == "Apple Watch" + and "Apple Watch SE" in devicetype["name"] + ) + simulator = se_simulators[-1][1] else: raise ValueError(f"Unknown platform {platform}") @@ -88,10 +128,18 @@ def xcode_test(location: Path, platform: str, simulator: str, verbose: bool): test_env["TEST_RUNNER_GITHUB_ACTIONS"] = os.environ["GITHUB_ACTIONS"] print("Running test project...") - # Test execution *can't* be run -quiet; verbose mode - # is how we see the output of the test output. + # Test execution *can't* be run -quiet; verbose mode is how we see the + # output of the test output. However, we don't need test diagnostics - + # they're large, and the context they contain generally isn't helpful for + # CPython tests. process = subprocess.Popen( - ["xcodebuild", "test-without-building"] + args, + [ + "xcodebuild", + "test-without-building", + "-collect-test-diagnostics", + "never", + ] + + args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=test_env, @@ -119,37 +167,156 @@ def copy(src, tgt): shutil.copytree(src, tgt, symlinks=True) +def framework_name(abiflags: str) -> str: + """The name of the Python framework for the given ABI flags.""" + return f"Python{abiflags.upper()}" + + +def is_template(location: Path) -> bool: + """Is the testbed at the given location an unexpanded template? + + A template's XCframework `Info.plist` still contains the literal + ABIFLAGS_PLACEHOLDER; once expanded, the placeholder is gone. + """ + info_plist = location / "Python.xcframework/Info.plist" + return ( + info_plist.is_file() + and ABIFLAGS_PLACEHOLDER.encode() in info_plist.read_bytes() + ) + + +def abiflags_from_framework(framework: Path) -> str: + """Infer the (lowercase) ABI flags from a `--framework` path. + + `framework` may be a `Python{FLAGS}.xcframework`, or a directory + containing a single simulator-slice `Python{FLAGS}.framework`. + + Raises ValueError if the ABI flags can't be determined. + """ + if framework.suffix == ".xcframework": + match = FRAMEWORK_NAME_RE.fullmatch(framework.stem) + if not match: + raise ValueError(f"{framework} is not a valid Python XCframework.") + return match.group(1).lower() + + candidates = sorted( + path + for path in framework.glob("Python*.framework") + if FRAMEWORK_NAME_RE.fullmatch(path.stem) + ) + if len(candidates) != 1: + raise ValueError( + f"Expected exactly one Python framework in {framework}; " + f"found {len(candidates)}." + ) + return FRAMEWORK_NAME_RE.fullmatch(candidates[0].stem).group(1).lower() + + +def find_xcframework(location: Path) -> Path: + """Find the Python XCframework in a testbed project. + + Raises ValueError if more than one XCframework is found. + """ + candidates = sorted( + path + for path in location.glob("Python*.xcframework") + if re.fullmatch(r"Python[A-Z]*\.xcframework", path.name) + ) + if len(candidates) != 1: + raise ValueError( + f"Expected exactly one Python XCframework in {location}; " + f"found {len(candidates)}." + ) + return candidates[0] + + +def expand_template(location: Path, abiflags: str) -> None: + """Expand the ABI flags placeholder in a cloned testbed template. + + The placeholder is replaced in the content of every template file, then + any file or directory whose name contains the placeholder is renamed. + Symlinks are neither followed nor modified. + """ + placeholder = ABIFLAGS_PLACEHOLDER + replacement = abiflags.upper() + for path in location.rglob("*"): + if ( + path.suffix in {".m", ".pbxproj", ".plist"} + and path.is_file() + and not path.is_symlink() + ): + content = path.read_text(encoding="utf-8") + if placeholder in content: + path.write_text( + content.replace(placeholder, replacement), + encoding="utf-8", + ) + + def clone_testbed( source: Path, target: Path, - framework: Path, + framework: Path | None, platform: str, apps: list[Path], ) -> None: if target.exists(): print(f"{target} already exists; aborting without creating project.") sys.exit(10) + source_is_template = is_template(source) + try: + orig_xc_framework_path = find_xcframework(source) + except ValueError as e: + print(e) + sys.exit(15) + fw_name = orig_xc_framework_path.stem if framework is None: - if not ( - source / "Python.xcframework" / TEST_SLICES[platform] / "bin" - ).is_dir(): + # No --framework; we must be cloning an an already-expanded testbed. + # Raise an error if we're not. + if source_is_template: print( - f"The testbed being cloned ({source}) does not contain " - "a framework with slices. Re-run with --framework" + "The initial testbed clone must provide a framework. " + "Re-run using --framework." ) sys.exit(11) + else: + # Look at the simulator slice in the existing framework; if + # it's a live framework, it will have a `bin` directory. + slice_path = orig_xc_framework_path / TEST_SLICES[platform] + if not (slice_path / "bin").is_dir(): + print( + f"The testbed being cloned ({source}) does not contain " + "a framework with slices. Re-run with --framework" + ) + sys.exit(11) + else: if not framework.is_dir(): print(f"{framework} does not exist.") sys.exit(12) + + if source_is_template: + # Initial testbed clone; the target framework name is + # taken directly from the provided framework, not the + # existing framework in the testbed. + try: + abiflags = abiflags_from_framework(framework) + except ValueError as e: + print(e) + sys.exit(13) + + fw_name = framework_name(abiflags) + elif not ( - framework.suffix == ".xcframework" - or (framework / "Python.framework").is_dir() + framework.name == f"{fw_name}.xcframework" + or (framework / f"{fw_name}.framework").is_dir() ): + # Re-cloning an already-expanded testbed: the ABI for the + # new framework must match the existing testbed. print( - f"{framework} is not an XCframework, " - f"or a simulator slice of a framework build." + f"{framework} is not a {fw_name}.xcframework, " + f"or a simulator slice of a {fw_name}.framework build." ) sys.exit(13) @@ -171,9 +338,23 @@ def clone_testbed( print(" done") - orig_xc_framework_path = source / "Python.xcframework" - xc_framework_path = target / "Python.xcframework" + xc_framework_path = target / f"{fw_name}.xcframework" test_framework_path = xc_framework_path / TEST_SLICES[platform] + + if source_is_template: + # Unless an XCframework is being symlinked in, the testbed uses a copy + # of the template XCframework (either as-is, or with a simulator slice + # installed into it); that copy requires expansion. + if framework.suffix != ".xcframework": + shutil.copytree( + orig_xc_framework_path, + xc_framework_path, + symlinks=True, + ) + print(f" Expanding template for {fw_name}...", end="") + expand_template(target, abiflags) + print(" done") + if framework is not None: if framework.suffix == ".xcframework": print(" Installing XCFramework...", end="") @@ -185,9 +366,18 @@ def clone_testbed( print(" Installing simulator framework...", end="") # We're only installing a slice of a framework; we need # to do a full tree copy to make sure we don't damage - # symlinked content. - shutil.copytree(orig_xc_framework_path, xc_framework_path) - if test_framework_path.is_dir(): + # symlinked content. If this is an initial template clone, + # this copy has already been done as part of rolling out + # the template. + if not source_is_template: + shutil.copytree( + orig_xc_framework_path, xc_framework_path, symlinks=True + ) + + if ( + test_framework_path.is_dir() + and not test_framework_path.is_symlink() + ): shutil.rmtree(test_framework_path) else: test_framework_path.unlink(missing_ok=True) @@ -223,7 +413,7 @@ def clone_testbed( # Simulator framework is a relative symlink. Rewrite the symlink # relative to the new location. orig_test_framework_path = ( - source / "Python.XCframework" / test_framework_path.readlink() + orig_xc_framework_path / test_framework_path.readlink() ).resolve() test_framework_path.unlink() test_framework_path.symlink_to( @@ -295,10 +485,16 @@ def main(): # many platforms, but when cloned, only one platform is preserved. available_platforms = [ platform - for platform in ["iOS"] + for platform in ["iOS", "tvOS", "visionOS", "watchOS"] if (Path(__file__).parent / f"{platform}Testbed").is_dir() ] + def platform_name(value): + """Return the canonical spelling for a platform name.""" + return {p.lower(): p for p in available_platforms}.get( + value.lower(), value + ) + parser = argparse.ArgumentParser( description=( "Manages the process of testing an Apple Python project " @@ -319,7 +515,9 @@ def main(): "--framework", help=( "The location of the XCFramework (or simulator-only slice of an " - "XCFramework) to use when running the testbed" + "XCFramework) to use when running the testbed. The framework's " + "ABI flags (e.g., free-threaded, debug) are inferred from its " + "name." ), ) clone.add_argument( @@ -327,6 +525,7 @@ def main(): dest="platform", choices=available_platforms, default=available_platforms[0], + type=platform_name, help=f"The platform to target (default: {available_platforms[0]})", ) clone.add_argument( @@ -349,7 +548,7 @@ def main(): ), description=( "Run a testbed project. The arguments provided after `--` will be " - "passed to the running iOS process as if they were arguments to " + "passed to the running test process as if they were arguments to " "`python -m`." ), help="Run a testbed project", @@ -359,6 +558,7 @@ def main(): dest="platform", choices=available_platforms, default=available_platforms[0], + type=platform_name, help=f"The platform to target (default: {available_platforms[0]})", ) run.add_argument( @@ -400,12 +600,17 @@ def main(): ) elif context.subcommand == "run": if test_args: + try: + xc_framework_path = find_xcframework(Path(__file__).parent) + except ValueError: + xc_framework_path = None + if not ( - Path(__file__).parent - / "Python.xcframework" - / TEST_SLICES[context.platform] - / "bin" - ).is_dir(): + xc_framework_path + and ( + xc_framework_path / TEST_SLICES[context.platform] / "bin" + ).is_dir() + ): print( "Testbed does not contain a compiled Python framework. " f"Use `python {sys.argv[0]} clone ...` to create a " diff --git a/Platforms/Apple/testbed/iOSTestbed.xcodeproj/project.pbxproj b/Platforms/Apple/testbed/iOSTestbed.xcodeproj/project.pbxproj index f8835a3bc587df5..b2131822424044e 100644 --- a/Platforms/Apple/testbed/iOSTestbed.xcodeproj/project.pbxproj +++ b/Platforms/Apple/testbed/iOSTestbed.xcodeproj/project.pbxproj @@ -3,21 +3,14 @@ archiveVersion = 1; classes = { }; - objectVersion = 56; + objectVersion = 77; objects = { /* Begin PBXBuildFile section */ - 607A66172B0EFA380010BFC8 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 607A66162B0EFA380010BFC8 /* AppDelegate.m */; }; - 607A66222B0EFA390010BFC8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607A66212B0EFA390010BFC8 /* Assets.xcassets */; }; - 607A66252B0EFA390010BFC8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607A66232B0EFA390010BFC8 /* LaunchScreen.storyboard */; }; - 607A66282B0EFA390010BFC8 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 607A66272B0EFA390010BFC8 /* main.m */; }; - 607A66322B0EFA3A0010BFC8 /* TestbedTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 607A66312B0EFA3A0010BFC8 /* TestbedTests.m */; }; - 607A664C2B0EFC080010BFC8 /* Python.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 607A664A2B0EFB310010BFC8 /* Python.xcframework */; }; - 607A664D2B0EFC080010BFC8 /* Python.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 607A664A2B0EFB310010BFC8 /* Python.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 607A66502B0EFFE00010BFC8 /* Python.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 607A664A2B0EFB310010BFC8 /* Python.xcframework */; }; - 607A66512B0EFFE00010BFC8 /* Python.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 607A664A2B0EFB310010BFC8 /* Python.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 608619542CB77BA900F46182 /* app_packages in Resources */ = {isa = PBXBuildFile; fileRef = 608619532CB77BA900F46182 /* app_packages */; }; - 608619562CB7819B00F46182 /* app in Resources */ = {isa = PBXBuildFile; fileRef = 608619552CB7819B00F46182 /* app */; }; + 607A664C2B0EFC080010BFC8 /* Python{{abiflags}}.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 607A664A2B0EFB310010BFC8 /* Python{{abiflags}}.xcframework */; }; + 607A664D2B0EFC080010BFC8 /* Python{{abiflags}}.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 607A664A2B0EFB310010BFC8 /* Python{{abiflags}}.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 607A66502B0EFFE00010BFC8 /* Python{{abiflags}}.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 607A664A2B0EFB310010BFC8 /* Python{{abiflags}}.xcframework */; }; + 607A66512B0EFFE00010BFC8 /* Python{{abiflags}}.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 607A664A2B0EFB310010BFC8 /* Python{{abiflags}}.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -37,7 +30,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 607A664D2B0EFC080010BFC8 /* Python.xcframework in Embed Frameworks */, + 607A664D2B0EFC080010BFC8 /* Python{{abiflags}}.xcframework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -48,7 +41,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 607A66512B0EFFE00010BFC8 /* Python.xcframework in Embed Frameworks */, + 607A66512B0EFFE00010BFC8 /* Python{{abiflags}}.xcframework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -57,26 +50,47 @@ /* Begin PBXFileReference section */ 607A66122B0EFA380010BFC8 /* iOSTestbed.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOSTestbed.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 607A66152B0EFA380010BFC8 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - 607A66162B0EFA380010BFC8 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 607A66212B0EFA390010BFC8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 607A66242B0EFA390010BFC8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - 607A66272B0EFA390010BFC8 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 607A662D2B0EFA3A0010BFC8 /* iOSTestbedTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = iOSTestbedTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 607A66312B0EFA3A0010BFC8 /* TestbedTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestbedTests.m; sourceTree = ""; }; - 607A664A2B0EFB310010BFC8 /* Python.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = Python.xcframework; sourceTree = ""; }; - 607A66592B0F08600010BFC8 /* iOSTestbed-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "iOSTestbed-Info.plist"; sourceTree = ""; }; - 608619532CB77BA900F46182 /* app_packages */ = {isa = PBXFileReference; lastKnownFileType = folder; path = app_packages; sourceTree = ""; }; - 608619552CB7819B00F46182 /* app */ = {isa = PBXFileReference; lastKnownFileType = folder; path = app; sourceTree = ""; }; + 607A664A2B0EFB310010BFC8 /* Python{{abiflags}}.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = "Python{{abiflags}}.xcframework"; sourceTree = ""; }; 60FE0EFB2E56BB6D00524F87 /* iOSTestbed.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = iOSTestbed.xctestplan; sourceTree = ""; }; /* End PBXFileReference section */ +/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ + 691FECCB8963969DDBED592E /* Exceptions for "iOSTestbed" folder in "iOSTestbed" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + "iOSTestbed-Info.plist", + ); + target = 607A66112B0EFA380010BFC8 /* iOSTestbed */; + }; +/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + 607A66142B0EFA380010BFC8 /* iOSTestbed */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + 691FECCB8963969DDBED592E /* Exceptions for "iOSTestbed" folder in "iOSTestbed" target */, + ); + explicitFolders = ( + app, + app_packages, + ); + path = iOSTestbed; + sourceTree = ""; + }; + 607A66302B0EFA3A0010BFC8 /* TestbedTests */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = TestbedTests; + sourceTree = ""; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + /* Begin PBXFrameworksBuildPhase section */ 607A660F2B0EFA380010BFC8 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 607A664C2B0EFC080010BFC8 /* Python.xcframework in Frameworks */, + 607A664C2B0EFC080010BFC8 /* Python{{abiflags}}.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -84,7 +98,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 607A66502B0EFFE00010BFC8 /* Python.xcframework in Frameworks */, + 607A66502B0EFFE00010BFC8 /* Python{{abiflags}}.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -95,11 +109,10 @@ isa = PBXGroup; children = ( 60FE0EFB2E56BB6D00524F87 /* iOSTestbed.xctestplan */, - 607A664A2B0EFB310010BFC8 /* Python.xcframework */, + 607A664A2B0EFB310010BFC8 /* Python{{abiflags}}.xcframework */, 607A66142B0EFA380010BFC8 /* iOSTestbed */, 607A66302B0EFA3A0010BFC8 /* TestbedTests */, 607A66132B0EFA380010BFC8 /* Products */, - 607A664F2B0EFFE00010BFC8 /* Frameworks */, ); sourceTree = ""; }; @@ -112,36 +125,6 @@ name = Products; sourceTree = ""; }; - 607A66142B0EFA380010BFC8 /* iOSTestbed */ = { - isa = PBXGroup; - children = ( - 608619552CB7819B00F46182 /* app */, - 608619532CB77BA900F46182 /* app_packages */, - 607A66592B0F08600010BFC8 /* iOSTestbed-Info.plist */, - 607A66152B0EFA380010BFC8 /* AppDelegate.h */, - 607A66162B0EFA380010BFC8 /* AppDelegate.m */, - 607A66212B0EFA390010BFC8 /* Assets.xcassets */, - 607A66232B0EFA390010BFC8 /* LaunchScreen.storyboard */, - 607A66272B0EFA390010BFC8 /* main.m */, - ); - path = iOSTestbed; - sourceTree = ""; - }; - 607A66302B0EFA3A0010BFC8 /* TestbedTests */ = { - isa = PBXGroup; - children = ( - 607A66312B0EFA3A0010BFC8 /* TestbedTests.m */, - ); - path = TestbedTests; - sourceTree = ""; - }; - 607A664F2B0EFFE00010BFC8 /* Frameworks */ = { - isa = PBXGroup; - children = ( - ); - name = Frameworks; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -159,7 +142,12 @@ ); dependencies = ( ); + fileSystemSynchronizedGroups = ( + 607A66142B0EFA380010BFC8 /* iOSTestbed */, + ); name = iOSTestbed; + packageProductDependencies = ( + ); productName = iOSTestbed; productReference = 607A66122B0EFA380010BFC8 /* iOSTestbed.app */; productType = "com.apple.product-type.application"; @@ -178,7 +166,12 @@ dependencies = ( 607A662F2B0EFA3A0010BFC8 /* PBXTargetDependency */, ); + fileSystemSynchronizedGroups = ( + 607A66302B0EFA3A0010BFC8 /* TestbedTests */, + ); name = iOSTestbedTests; + packageProductDependencies = ( + ); productName = iOSTestbedTests; productReference = 607A662D2B0EFA3A0010BFC8 /* iOSTestbedTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; @@ -210,6 +203,8 @@ Base, ); mainGroup = 607A66092B0EFA380010BFC8; + minimizedProjectReferenceProxies = 1; + preferredProjectObjectVersion = 77; productRefGroup = 607A66132B0EFA380010BFC8 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -225,10 +220,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 607A66252B0EFA390010BFC8 /* LaunchScreen.storyboard in Resources */, - 608619562CB7819B00F46182 /* app in Resources */, - 607A66222B0EFA390010BFC8 /* Assets.xcassets in Resources */, - 608619542CB77BA900F46182 /* app_packages in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -259,7 +250,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "set -e\nsource $PROJECT_DIR/Python.xcframework/build/utils.sh\ninstall_python Python.xcframework app app_packages\n"; + shellScript = "set -e\nsource \"$PROJECT_DIR/Python{{abiflags}}.xcframework/build/utils.sh\"\ninstall_python Python{{abiflags}}.xcframework app app_packages\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -269,8 +260,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 607A66172B0EFA380010BFC8 /* AppDelegate.m in Sources */, - 607A66282B0EFA390010BFC8 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -278,7 +267,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 607A66322B0EFA3A0010BFC8 /* TestbedTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -292,17 +280,6 @@ }; /* End PBXTargetDependency section */ -/* Begin PBXVariantGroup section */ - 607A66232B0EFA390010BFC8 /* LaunchScreen.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 607A66242B0EFA390010BFC8 /* Base */, - ); - name = LaunchScreen.storyboard; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - /* Begin XCBuildConfiguration section */ 607A663F2B0EFA3A0010BFC8 /* Debug */ = { isa = XCBuildConfiguration; @@ -356,7 +333,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -411,7 +388,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; @@ -430,14 +407,14 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = ""; ENABLE_USER_SCRIPT_SANDBOXING = NO; - HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python.framework/Headers\""; + HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python{{abiflags}}.framework/Headers\""; INFOPLIST_FILE = "iOSTestbed/iOSTestbed-Info.plist"; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -461,14 +438,14 @@ DEVELOPMENT_TEAM = ""; ENABLE_TESTABILITY = YES; ENABLE_USER_SCRIPT_SANDBOXING = NO; - HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python.framework/Headers\""; + HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python{{abiflags}}.framework/Headers\""; INFOPLIST_FILE = "iOSTestbed/iOSTestbed-Info.plist"; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -490,8 +467,8 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 3HEZE76D99; GENERATE_INFOPLIST_FILE = YES; - HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python.framework/Headers\""; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python{{abiflags}}.framework/Headers\""; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = org.python.iOSTestbedTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -510,8 +487,8 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 3HEZE76D99; GENERATE_INFOPLIST_FILE = YES; - HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python.framework/Headers\""; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python{{abiflags}}.framework/Headers\""; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = org.python.iOSTestbedTests; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Platforms/Apple/testbed/iOSTestbed/AppDelegate.m b/Platforms/Apple/testbed/iOSTestbed/AppDelegate.m index e5085399d0ca5fb..fbe71bae23b7183 100644 --- a/Platforms/Apple/testbed/iOSTestbed/AppDelegate.m +++ b/Platforms/Apple/testbed/iOSTestbed/AppDelegate.m @@ -4,6 +4,7 @@ // #import "AppDelegate.h" +#import "SceneDelegate.h" @interface AppDelegate () @@ -11,9 +12,13 @@ @interface AppDelegate () @implementation AppDelegate +- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options { + UISceneConfiguration *configuration = [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role]; + configuration.delegateClass = [SceneDelegate class]; + return configuration; +} -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - return YES; +- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet *)sceneSessions { } @end diff --git a/Platforms/Apple/testbed/iOSTestbed/SceneDelegate.h b/Platforms/Apple/testbed/iOSTestbed/SceneDelegate.h new file mode 100644 index 000000000000000..264aacadca16e5d --- /dev/null +++ b/Platforms/Apple/testbed/iOSTestbed/SceneDelegate.h @@ -0,0 +1,12 @@ +// +// SceneDelegate.h +// iOSTestbed +// + +#import + +@interface SceneDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/Platforms/Apple/testbed/iOSTestbed/SceneDelegate.m b/Platforms/Apple/testbed/iOSTestbed/SceneDelegate.m new file mode 100644 index 000000000000000..e82e447985d2e90 --- /dev/null +++ b/Platforms/Apple/testbed/iOSTestbed/SceneDelegate.m @@ -0,0 +1,21 @@ +// +// SceneDelegate.m +// iOSTestbed +// + +#import "SceneDelegate.h" + +@interface SceneDelegate () + +@end + +@implementation SceneDelegate + +- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { + UIWindowScene *windowScene = (UIWindowScene *)scene; + self.window = [[UIWindow alloc] initWithWindowScene:windowScene]; + self.window.rootViewController = [[UIViewController alloc] init]; + [self.window makeKeyAndVisible]; +} + +@end diff --git a/Platforms/Apple/testbed/iOSTestbed/iOSTestbed-Info.plist b/Platforms/Apple/testbed/iOSTestbed/iOSTestbed-Info.plist index fea45e1fad6f6f6..3a560656972aeca 100644 --- a/Platforms/Apple/testbed/iOSTestbed/iOSTestbed-Info.plist +++ b/Platforms/Apple/testbed/iOSTestbed/iOSTestbed-Info.plist @@ -46,7 +46,17 @@ UIApplicationSupportsMultipleScenes UISceneConfigurations - + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + SceneDelegate + + + diff --git a/Platforms/Apple/testbed/tvOSTestbed.xcodeproj/project.pbxproj b/Platforms/Apple/testbed/tvOSTestbed.xcodeproj/project.pbxproj new file mode 100644 index 000000000000000..941f6a266bc42a0 --- /dev/null +++ b/Platforms/Apple/testbed/tvOSTestbed.xcodeproj/project.pbxproj @@ -0,0 +1,506 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXBuildFile section */ + EE7C8A1E2DCD6FF3003206DB /* Python{{abiflags}}.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE7C8A1C2DCD6FF3003206DB /* Python{{abiflags}}.xcframework */; }; + EE7C8A1F2DCD70CD003206DB /* Python{{abiflags}}.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE7C8A1C2DCD6FF3003206DB /* Python{{abiflags}}.xcframework */; }; + EE7C8A202DCD70CD003206DB /* Python{{abiflags}}.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EE7C8A1C2DCD6FF3003206DB /* Python{{abiflags}}.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + EE989E662DCD6E7A0036B268 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = EE989E462DCD6E780036B268 /* Project object */; + proxyType = 1; + remoteGlobalIDString = EE989E4D2DCD6E780036B268; + remoteInfo = tvOSTestbed; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + EE7C8A212DCD70CD003206DB /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + EE7C8A202DCD70CD003206DB /* Python{{abiflags}}.xcframework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 6077B3802E82A4BE00E3D6A3 /* tvOSTestbed.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = tvOSTestbed.xctestplan; sourceTree = ""; }; + EE7C8A1C2DCD6FF3003206DB /* Python{{abiflags}}.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = Python{{abiflags}}.xcframework; sourceTree = ""; }; + EE989E4E2DCD6E780036B268 /* tvOSTestbed.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = tvOSTestbed.app; sourceTree = BUILT_PRODUCTS_DIR; }; + EE989E652DCD6E7A0036B268 /* TestbedTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestbedTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ + 6077B37F2E81892A00E3D6A3 /* Exceptions for "tvOSTestbed" folder in "tvOSTestbed" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + "tvOSTestbed-Info.plist", + ); + target = EE989E4D2DCD6E780036B268 /* tvOSTestbed */; + }; +/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + EE989E502DCD6E780036B268 /* tvOSTestbed */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + 6077B37F2E81892A00E3D6A3 /* Exceptions for "tvOSTestbed" folder in "tvOSTestbed" target */, + ); + explicitFolders = ( + app, + app_packages, + ); + path = tvOSTestbed; + sourceTree = ""; + }; + EE989E682DCD6E7A0036B268 /* TestbedTests */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = TestbedTests; + sourceTree = ""; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + +/* Begin PBXFrameworksBuildPhase section */ + EE989E4B2DCD6E780036B268 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + EE7C8A1F2DCD70CD003206DB /* Python{{abiflags}}.xcframework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + EE989E622DCD6E7A0036B268 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + EE7C8A1E2DCD6FF3003206DB /* Python{{abiflags}}.xcframework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + EE989E452DCD6E780036B268 = { + isa = PBXGroup; + children = ( + 6077B3802E82A4BE00E3D6A3 /* tvOSTestbed.xctestplan */, + EE7C8A1C2DCD6FF3003206DB /* Python{{abiflags}}.xcframework */, + EE989E502DCD6E780036B268 /* tvOSTestbed */, + EE989E682DCD6E7A0036B268 /* TestbedTests */, + EE989E4F2DCD6E780036B268 /* Products */, + ); + sourceTree = ""; + }; + EE989E4F2DCD6E780036B268 /* Products */ = { + isa = PBXGroup; + children = ( + EE989E4E2DCD6E780036B268 /* tvOSTestbed.app */, + EE989E652DCD6E7A0036B268 /* TestbedTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + EE989E4D2DCD6E780036B268 /* tvOSTestbed */ = { + isa = PBXNativeTarget; + buildConfigurationList = EE989E792DCD6E7A0036B268 /* Build configuration list for PBXNativeTarget "tvOSTestbed" */; + buildPhases = ( + EE989E4A2DCD6E780036B268 /* Sources */, + EE989E4B2DCD6E780036B268 /* Frameworks */, + EE989E4C2DCD6E780036B268 /* Resources */, + EE7C8A222DCD70F4003206DB /* Process Python libraries */, + EE7C8A212DCD70CD003206DB /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + EE989E502DCD6E780036B268 /* tvOSTestbed */, + ); + name = tvOSTestbed; + packageProductDependencies = ( + ); + productName = tvOSTestbed; + productReference = EE989E4E2DCD6E780036B268 /* tvOSTestbed.app */; + productType = "com.apple.product-type.application"; + }; + EE989E642DCD6E7A0036B268 /* TestbedTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = EE989E7C2DCD6E7A0036B268 /* Build configuration list for PBXNativeTarget "TestbedTests" */; + buildPhases = ( + EE989E612DCD6E7A0036B268 /* Sources */, + EE989E622DCD6E7A0036B268 /* Frameworks */, + EE989E632DCD6E7A0036B268 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + EE989E672DCD6E7A0036B268 /* PBXTargetDependency */, + ); + fileSystemSynchronizedGroups = ( + EE989E682DCD6E7A0036B268 /* TestbedTests */, + ); + name = TestbedTests; + packageProductDependencies = ( + ); + productName = TestbedTests; + productReference = EE989E652DCD6E7A0036B268 /* TestbedTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + EE989E462DCD6E780036B268 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1620; + TargetAttributes = { + EE989E4D2DCD6E780036B268 = { + CreatedOnToolsVersion = 16.2; + }; + EE989E642DCD6E7A0036B268 = { + CreatedOnToolsVersion = 16.2; + TestTargetID = EE989E4D2DCD6E780036B268; + }; + }; + }; + buildConfigurationList = EE989E492DCD6E780036B268 /* Build configuration list for PBXProject "tvOSTestbed" */; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = EE989E452DCD6E780036B268; + minimizedProjectReferenceProxies = 1; + preferredProjectObjectVersion = 77; + productRefGroup = EE989E4F2DCD6E780036B268 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + EE989E4D2DCD6E780036B268 /* tvOSTestbed */, + EE989E642DCD6E7A0036B268 /* TestbedTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + EE989E4C2DCD6E780036B268 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + EE989E632DCD6E7A0036B268 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + EE7C8A222DCD70F4003206DB /* Process Python libraries */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Process Python libraries"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "set -e\n\nsource \"$PROJECT_DIR/Python{{abiflags}}.xcframework/build/utils.sh\"\n\ninstall_python Python{{abiflags}}.xcframework app app_packages\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + EE989E4A2DCD6E780036B268 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + EE989E612DCD6E7A0036B268 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + EE989E672DCD6E7A0036B268 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = EE989E4D2DCD6E780036B268 /* tvOSTestbed */; + targetProxy = EE989E662DCD6E7A0036B268 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + EE989E772DCD6E7A0036B268 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)"; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/Python{{abiflags}}.framework/Headers"; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = appletvos; + TVOS_DEPLOYMENT_TARGET = 18.2; + }; + name = Debug; + }; + EE989E782DCD6E7A0036B268 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)"; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/Python{{abiflags}}.framework/Headers"; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = appletvos; + TVOS_DEPLOYMENT_TARGET = 18.2; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + EE989E7A2DCD6E7A0036B268 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = NO; + INFOPLIST_FILE = "tvOSTestbed/tvOSTestbed-Info.plist"; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UIUserInterfaceStyle = Automatic; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = org.python.tvOSTestbed; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + TARGETED_DEVICE_FAMILY = 3; + }; + name = Debug; + }; + EE989E7B2DCD6E7A0036B268 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = NO; + INFOPLIST_FILE = "tvOSTestbed/tvOSTestbed-Info.plist"; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UIUserInterfaceStyle = Automatic; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = org.python.tvOSTestbed; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + TARGETED_DEVICE_FAMILY = 3; + }; + name = Release; + }; + EE989E7D2DCD6E7A0036B268 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = org.python.TestbedTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + TARGETED_DEVICE_FAMILY = 3; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/tvOSTestbed.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/tvOSTestbed"; + TVOS_DEPLOYMENT_TARGET = 18.2; + }; + name = Debug; + }; + EE989E7E2DCD6E7A0036B268 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = org.python.TestbedTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + TARGETED_DEVICE_FAMILY = 3; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/tvOSTestbed.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/tvOSTestbed"; + TVOS_DEPLOYMENT_TARGET = 18.2; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + EE989E492DCD6E780036B268 /* Build configuration list for PBXProject "tvOSTestbed" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + EE989E772DCD6E7A0036B268 /* Debug */, + EE989E782DCD6E7A0036B268 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + EE989E792DCD6E7A0036B268 /* Build configuration list for PBXNativeTarget "tvOSTestbed" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + EE989E7A2DCD6E7A0036B268 /* Debug */, + EE989E7B2DCD6E7A0036B268 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + EE989E7C2DCD6E7A0036B268 /* Build configuration list for PBXNativeTarget "TestbedTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + EE989E7D2DCD6E7A0036B268 /* Debug */, + EE989E7E2DCD6E7A0036B268 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = EE989E462DCD6E780036B268 /* Project object */; +} diff --git a/Platforms/Apple/testbed/tvOSTestbed.xcodeproj/xcshareddata/xcschemes/tvOSTestbed.xcscheme b/Platforms/Apple/testbed/tvOSTestbed.xcodeproj/xcshareddata/xcschemes/tvOSTestbed.xcscheme new file mode 100644 index 000000000000000..c3f3f894a1ff95a --- /dev/null +++ b/Platforms/Apple/testbed/tvOSTestbed.xcodeproj/xcshareddata/xcschemes/tvOSTestbed.xcscheme @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Platforms/Apple/testbed/tvOSTestbed.xctestplan b/Platforms/Apple/testbed/tvOSTestbed.xctestplan new file mode 100644 index 000000000000000..f996facc1782b7d --- /dev/null +++ b/Platforms/Apple/testbed/tvOSTestbed.xctestplan @@ -0,0 +1,46 @@ +{ + "configurations" : [ + { + "id" : "F5A95CE4-1ADE-4A6E-A0E1-CDBAE26DF0C5", + "name" : "Test Scheme Action", + "options" : { + + } + } + ], + "defaultOptions" : { + "commandLineArgumentEntries" : [ + { + "argument" : "test" + }, + { + "argument" : "-uall" + }, + { + "argument" : "--single-process" + }, + { + "argument" : "--rerun" + }, + { + "argument" : "-W" + } + ], + "targetForVariableExpansion" : { + "containerPath" : "container:tvOSTestbed.xcodeproj", + "identifier" : "607A66112B0EFA380010BFC8", + "name" : "tvOSTestbed" + } + }, + "testTargets" : [ + { + "parallelizable" : false, + "target" : { + "containerPath" : "container:tvOSTestbed.xcodeproj", + "identifier" : "EE989E642DCD6E7A0036B268", + "name" : "TestbedTests" + } + } + ], + "version" : 1 +} \ No newline at end of file diff --git a/Platforms/Apple/testbed/tvOSTestbed/AppDelegate.h b/Platforms/Apple/testbed/tvOSTestbed/AppDelegate.h new file mode 100644 index 000000000000000..112c9ed64b83fb4 --- /dev/null +++ b/Platforms/Apple/testbed/tvOSTestbed/AppDelegate.h @@ -0,0 +1,11 @@ +// +// AppDelegate.h +// tvOSTestbed +// + +#import + +@interface AppDelegate : UIResponder + + +@end diff --git a/Platforms/Apple/testbed/tvOSTestbed/AppDelegate.m b/Platforms/Apple/testbed/tvOSTestbed/AppDelegate.m new file mode 100644 index 000000000000000..7501ec7b6ef6338 --- /dev/null +++ b/Platforms/Apple/testbed/tvOSTestbed/AppDelegate.m @@ -0,0 +1,24 @@ +// +// AppDelegate.m +// tvOSTestbed +// + +#import "AppDelegate.h" +#import "SceneDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + +- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options { + UISceneConfiguration *configuration = [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role]; + configuration.delegateClass = [SceneDelegate class]; + return configuration; +} + +- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet *)sceneSessions { +} + +@end diff --git a/Platforms/Apple/testbed/tvOSTestbed/Base.lproj/LaunchScreen.storyboard b/Platforms/Apple/testbed/tvOSTestbed/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000000000..660ba53de4f73d9 --- /dev/null +++ b/Platforms/Apple/testbed/tvOSTestbed/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Platforms/Apple/testbed/tvOSTestbed/SceneDelegate.h b/Platforms/Apple/testbed/tvOSTestbed/SceneDelegate.h new file mode 100644 index 000000000000000..264aacadca16e5d --- /dev/null +++ b/Platforms/Apple/testbed/tvOSTestbed/SceneDelegate.h @@ -0,0 +1,12 @@ +// +// SceneDelegate.h +// iOSTestbed +// + +#import + +@interface SceneDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/Platforms/Apple/testbed/tvOSTestbed/SceneDelegate.m b/Platforms/Apple/testbed/tvOSTestbed/SceneDelegate.m new file mode 100644 index 000000000000000..e82e447985d2e90 --- /dev/null +++ b/Platforms/Apple/testbed/tvOSTestbed/SceneDelegate.m @@ -0,0 +1,21 @@ +// +// SceneDelegate.m +// iOSTestbed +// + +#import "SceneDelegate.h" + +@interface SceneDelegate () + +@end + +@implementation SceneDelegate + +- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { + UIWindowScene *windowScene = (UIWindowScene *)scene; + self.window = [[UIWindow alloc] initWithWindowScene:windowScene]; + self.window.rootViewController = [[UIViewController alloc] init]; + [self.window makeKeyAndVisible]; +} + +@end diff --git a/Platforms/Apple/testbed/tvOSTestbed/app/README b/Platforms/Apple/testbed/tvOSTestbed/app/README new file mode 100644 index 000000000000000..46c0e8e2a29a1cc --- /dev/null +++ b/Platforms/Apple/testbed/tvOSTestbed/app/README @@ -0,0 +1,7 @@ +This folder can contain any Python application code. + +During the build, any binary modules found in this folder will be processed into +Framework form. + +When the test suite runs, this folder will be on the PYTHONPATH, and will be the +working directory for the test suite. diff --git a/Platforms/Apple/testbed/tvOSTestbed/app_packages/README b/Platforms/Apple/testbed/tvOSTestbed/app_packages/README new file mode 100644 index 000000000000000..02c2beccfbdaed2 --- /dev/null +++ b/Platforms/Apple/testbed/tvOSTestbed/app_packages/README @@ -0,0 +1,7 @@ +This folder can be a target for installing any Python dependencies needed by the +test suite. + +During the build, any binary modules found in this folder will be processed into +Framework form. + +When the test suite runs, this folder will be on the PYTHONPATH. diff --git a/Platforms/Apple/testbed/tvOSTestbed/main.m b/Platforms/Apple/testbed/tvOSTestbed/main.m new file mode 100644 index 000000000000000..d5808fbb9331b71 --- /dev/null +++ b/Platforms/Apple/testbed/tvOSTestbed/main.m @@ -0,0 +1,16 @@ +// +// main.m +// tvOSTestbed +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + NSString * appDelegateClassName; + @autoreleasepool { + appDelegateClassName = NSStringFromClass([AppDelegate class]); + + return UIApplicationMain(argc, argv, nil, appDelegateClassName); + } +} diff --git a/Platforms/Apple/testbed/tvOSTestbed/tvOSTestbed-Info.plist b/Platforms/Apple/testbed/tvOSTestbed/tvOSTestbed-Info.plist new file mode 100644 index 000000000000000..6d84447c031ebd7 --- /dev/null +++ b/Platforms/Apple/testbed/tvOSTestbed/tvOSTestbed-Info.plist @@ -0,0 +1,62 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + org.python.tvOSTestbed + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIRequiresFullScreen + + UILaunchStoryboardName + Launch Screen + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneDelegateClassName + SceneDelegate + UISceneConfigurationName + Default Configuration + + + + + + diff --git a/Platforms/Apple/testbed/visionOSTestbed.xcodeproj/project.pbxproj b/Platforms/Apple/testbed/visionOSTestbed.xcodeproj/project.pbxproj new file mode 100644 index 000000000000000..53ddec1b6f29e40 --- /dev/null +++ b/Platforms/Apple/testbed/visionOSTestbed.xcodeproj/project.pbxproj @@ -0,0 +1,550 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXBuildFile section */ + EEB367CE2DADF5C900B9A1D7 /* Python{{abiflags}}.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EEE9C80C2DAB5ECA0056F8C6 /* Python{{abiflags}}.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + EEB367CF2DADF5D300B9A1D7 /* Python{{abiflags}}.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EEE9C80C2DAB5ECA0056F8C6 /* Python{{abiflags}}.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + EEE9C80D2DAB5ECA0056F8C6 /* Python{{abiflags}}.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EEE9C80C2DAB5ECA0056F8C6 /* Python{{abiflags}}.xcframework */; }; + EEE9C80E2DAB5ECA0056F8C6 /* Python{{abiflags}}.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EEE9C80C2DAB5ECA0056F8C6 /* Python{{abiflags}}.xcframework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 607A662E2B0EFA3A0010BFC8 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 607A660A2B0EFA380010BFC8 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 607A66112B0EFA380010BFC8; + remoteInfo = iOSTestbed; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 607A664E2B0EFC080010BFC8 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + EEB367CF2DADF5D300B9A1D7 /* Python{{abiflags}}.xcframework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + 607A66522B0EFFE00010BFC8 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + EEB367CE2DADF5C900B9A1D7 /* Python{{abiflags}}.xcframework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 6077B3D62E82E60C00E3D6A3 /* visionOSTestbed.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = visionOSTestbed.xctestplan; sourceTree = ""; }; + 607A66122B0EFA380010BFC8 /* visionOSTestbed.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = visionOSTestbed.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 607A662D2B0EFA3A0010BFC8 /* TestbedTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestbedTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + EEE9C80C2DAB5ECA0056F8C6 /* Python{{abiflags}}.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = Python{{abiflags}}.xcframework; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ + 4172389B57E3372C38B3DB88 /* Exceptions for "visionOSTestbed" folder in "visionOSTestbed" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + "visionOSTestbed-Info.plist", + ); + target = 607A66112B0EFA380010BFC8 /* visionOSTestbed */; + }; +/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + 607A66142B0EFA380010BFC8 /* visionOSTestbed */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + 4172389B57E3372C38B3DB88 /* Exceptions for "visionOSTestbed" folder in "visionOSTestbed" target */, + ); + explicitFolders = ( + app, + app_packages, + ); + path = visionOSTestbed; + sourceTree = ""; + }; + 607A66302B0EFA3A0010BFC8 /* TestbedTests */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = TestbedTests; + sourceTree = ""; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + +/* Begin PBXFrameworksBuildPhase section */ + 607A660F2B0EFA380010BFC8 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + EEE9C80D2DAB5ECA0056F8C6 /* Python{{abiflags}}.xcframework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 607A662A2B0EFA3A0010BFC8 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + EEE9C80E2DAB5ECA0056F8C6 /* Python{{abiflags}}.xcframework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 607A66092B0EFA380010BFC8 = { + isa = PBXGroup; + children = ( + 6077B3D62E82E60C00E3D6A3 /* visionOSTestbed.xctestplan */, + EEE9C80C2DAB5ECA0056F8C6 /* Python{{abiflags}}.xcframework */, + 607A66142B0EFA380010BFC8 /* visionOSTestbed */, + 607A66302B0EFA3A0010BFC8 /* TestbedTests */, + 607A66132B0EFA380010BFC8 /* Products */, + ); + sourceTree = ""; + }; + 607A66132B0EFA380010BFC8 /* Products */ = { + isa = PBXGroup; + children = ( + 607A66122B0EFA380010BFC8 /* visionOSTestbed.app */, + 607A662D2B0EFA3A0010BFC8 /* TestbedTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 607A66112B0EFA380010BFC8 /* visionOSTestbed */ = { + isa = PBXNativeTarget; + buildConfigurationList = 607A66412B0EFA3A0010BFC8 /* Build configuration list for PBXNativeTarget "visionOSTestbed" */; + buildPhases = ( + 607A660E2B0EFA380010BFC8 /* Sources */, + 607A660F2B0EFA380010BFC8 /* Frameworks */, + 607A66102B0EFA380010BFC8 /* Resources */, + 607A66552B0F061D0010BFC8 /* Process Python libraries */, + 607A664E2B0EFC080010BFC8 /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + 607A66142B0EFA380010BFC8 /* visionOSTestbed */, + ); + name = visionOSTestbed; + packageProductDependencies = ( + ); + productName = iOSTestbed; + productReference = 607A66122B0EFA380010BFC8 /* visionOSTestbed.app */; + productType = "com.apple.product-type.application"; + }; + 607A662C2B0EFA3A0010BFC8 /* TestbedTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 607A66442B0EFA3A0010BFC8 /* Build configuration list for PBXNativeTarget "TestbedTests" */; + buildPhases = ( + 607A66292B0EFA3A0010BFC8 /* Sources */, + 607A662A2B0EFA3A0010BFC8 /* Frameworks */, + 607A662B2B0EFA3A0010BFC8 /* Resources */, + 607A66522B0EFFE00010BFC8 /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 607A662F2B0EFA3A0010BFC8 /* PBXTargetDependency */, + ); + fileSystemSynchronizedGroups = ( + 607A66302B0EFA3A0010BFC8 /* TestbedTests */, + ); + name = TestbedTests; + packageProductDependencies = ( + ); + productName = iOSTestbedTests; + productReference = 607A662D2B0EFA3A0010BFC8 /* TestbedTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 607A660A2B0EFA380010BFC8 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1500; + TargetAttributes = { + 607A66112B0EFA380010BFC8 = { + CreatedOnToolsVersion = 15.0.1; + }; + 607A662C2B0EFA3A0010BFC8 = { + CreatedOnToolsVersion = 15.0.1; + TestTargetID = 607A66112B0EFA380010BFC8; + }; + }; + }; + buildConfigurationList = 607A660D2B0EFA380010BFC8 /* Build configuration list for PBXProject "visionOSTestbed" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 607A66092B0EFA380010BFC8; + minimizedProjectReferenceProxies = 1; + preferredProjectObjectVersion = 77; + productRefGroup = 607A66132B0EFA380010BFC8 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 607A66112B0EFA380010BFC8 /* visionOSTestbed */, + 607A662C2B0EFA3A0010BFC8 /* TestbedTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 607A66102B0EFA380010BFC8 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 607A662B2B0EFA3A0010BFC8 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 607A66552B0F061D0010BFC8 /* Process Python libraries */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Process Python libraries"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "set -e\n\nsource \"$PROJECT_DIR/Python{{abiflags}}.xcframework/build/utils.sh\"\n\ninstall_python Python{{abiflags}}.xcframework app app_packages\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 607A660E2B0EFA380010BFC8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 607A66292B0EFA3A0010BFC8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 607A662F2B0EFA3A0010BFC8 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 607A66112B0EFA380010BFC8 /* visionOSTestbed */; + targetProxy = 607A662E2B0EFA3A0010BFC8 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 607A663F2B0EFA3A0010BFC8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = xros; + }; + name = Debug; + }; + 607A66402B0EFA3A0010BFC8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = xros; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 607A66422B0EFA3A0010BFC8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = ""; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python{{abiflags}}.framework/Headers\""; + INFOPLIST_FILE = "visionOSTestbed/visionOSTestbed-Info.plist"; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 3.13.0a1; + PRODUCT_BUNDLE_IDENTIFIER = org.python.visionOSTestbed; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_EMIT_LOC_STRINGS = YES; + TARGETED_DEVICE_FAMILY = 7; + XROS_DEPLOYMENT_TARGET = 2.0; + }; + name = Debug; + }; + 607A66432B0EFA3A0010BFC8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = ""; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python{{abiflags}}.framework/Headers\""; + INFOPLIST_FILE = "visionOSTestbed/visionOSTestbed-Info.plist"; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 3.13.0a1; + PRODUCT_BUNDLE_IDENTIFIER = org.python.visionOSTestbed; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_EMIT_LOC_STRINGS = YES; + TARGETED_DEVICE_FAMILY = 7; + XROS_DEPLOYMENT_TARGET = 2.0; + }; + name = Release; + }; + 607A66452B0EFA3A0010BFC8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 3HEZE76D99; + GENERATE_INFOPLIST_FILE = YES; + HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python{{abiflags}}.framework/Headers\""; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = org.python.TestbedTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_EMIT_LOC_STRINGS = NO; + TARGETED_DEVICE_FAMILY = 7; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/visionOSTestbed.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/visionOSTestbed"; + }; + name = Debug; + }; + 607A66462B0EFA3A0010BFC8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 3HEZE76D99; + GENERATE_INFOPLIST_FILE = YES; + HEADER_SEARCH_PATHS = "\"$(BUILT_PRODUCTS_DIR)/Python{{abiflags}}.framework/Headers\""; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = org.python.TestbedTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_EMIT_LOC_STRINGS = NO; + TARGETED_DEVICE_FAMILY = 7; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/visionOSTestbed.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/visionOSTestbed"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 607A660D2B0EFA380010BFC8 /* Build configuration list for PBXProject "visionOSTestbed" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 607A663F2B0EFA3A0010BFC8 /* Debug */, + 607A66402B0EFA3A0010BFC8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 607A66412B0EFA3A0010BFC8 /* Build configuration list for PBXNativeTarget "visionOSTestbed" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 607A66422B0EFA3A0010BFC8 /* Debug */, + 607A66432B0EFA3A0010BFC8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 607A66442B0EFA3A0010BFC8 /* Build configuration list for PBXNativeTarget "TestbedTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 607A66452B0EFA3A0010BFC8 /* Debug */, + 607A66462B0EFA3A0010BFC8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 607A660A2B0EFA380010BFC8 /* Project object */; +} diff --git a/Platforms/Apple/testbed/visionOSTestbed.xcodeproj/xcshareddata/xcschemes/visionOSTestbed.xcscheme b/Platforms/Apple/testbed/visionOSTestbed.xcodeproj/xcshareddata/xcschemes/visionOSTestbed.xcscheme new file mode 100644 index 000000000000000..b8397ea7cf116d6 --- /dev/null +++ b/Platforms/Apple/testbed/visionOSTestbed.xcodeproj/xcshareddata/xcschemes/visionOSTestbed.xcscheme @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Platforms/Apple/testbed/visionOSTestbed.xctestplan b/Platforms/Apple/testbed/visionOSTestbed.xctestplan new file mode 100644 index 000000000000000..73a2be8c22a70c5 --- /dev/null +++ b/Platforms/Apple/testbed/visionOSTestbed.xctestplan @@ -0,0 +1,46 @@ +{ + "configurations" : [ + { + "id" : "C17FA044-0B70-48CA-AFF8-BC252081002F", + "name" : "Test Scheme Action", + "options" : { + + } + } + ], + "defaultOptions" : { + "commandLineArgumentEntries" : [ + { + "argument" : "test" + }, + { + "argument" : "-uall" + }, + { + "argument" : "--single-process" + }, + { + "argument" : "--rerun" + }, + { + "argument" : "-W" + } + ], + "targetForVariableExpansion" : { + "containerPath" : "container:visionOSTestbed.xcodeproj", + "identifier" : "607A66112B0EFA380010BFC8", + "name" : "visionOSTestbed" + } + }, + "testTargets" : [ + { + "parallelizable" : false, + "target" : { + "containerPath" : "container:visionOSTestbed.xcodeproj", + "identifier" : "607A662C2B0EFA3A0010BFC8", + "name" : "TestbedTests" + } + } + ], + "version" : 1 +} \ No newline at end of file diff --git a/Platforms/Apple/testbed/visionOSTestbed/AppDelegate.h b/Platforms/Apple/testbed/visionOSTestbed/AppDelegate.h new file mode 100644 index 000000000000000..8fe7ec8e64eeb29 --- /dev/null +++ b/Platforms/Apple/testbed/visionOSTestbed/AppDelegate.h @@ -0,0 +1,11 @@ +// +// AppDelegate.h +// visionOSTestbed +// + +#import + +@interface AppDelegate : UIResponder + + +@end diff --git a/Platforms/Apple/testbed/visionOSTestbed/AppDelegate.m b/Platforms/Apple/testbed/visionOSTestbed/AppDelegate.m new file mode 100644 index 000000000000000..f46c65a3834db9c --- /dev/null +++ b/Platforms/Apple/testbed/visionOSTestbed/AppDelegate.m @@ -0,0 +1,24 @@ +// +// AppDelegate.m +// visionOSTestbed +// + +#import "AppDelegate.h" +#import "SceneDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + +- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options { + UISceneConfiguration *configuration = [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role]; + configuration.delegateClass = [SceneDelegate class]; + return configuration; +} + +- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet *)sceneSessions { +} + +@end diff --git a/Platforms/Apple/testbed/visionOSTestbed/Assets.xcassets/AccentColor.colorset/Contents.json b/Platforms/Apple/testbed/visionOSTestbed/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 000000000000000..eb8789700816459 --- /dev/null +++ b/Platforms/Apple/testbed/visionOSTestbed/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Platforms/Apple/testbed/visionOSTestbed/Assets.xcassets/AppIcon.appiconset/Contents.json b/Platforms/Apple/testbed/visionOSTestbed/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000000000..13613e3ee1a9348 --- /dev/null +++ b/Platforms/Apple/testbed/visionOSTestbed/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Platforms/Apple/testbed/visionOSTestbed/Assets.xcassets/Contents.json b/Platforms/Apple/testbed/visionOSTestbed/Assets.xcassets/Contents.json new file mode 100644 index 000000000000000..73c00596a7fca3f --- /dev/null +++ b/Platforms/Apple/testbed/visionOSTestbed/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Platforms/Apple/testbed/visionOSTestbed/SceneDelegate.h b/Platforms/Apple/testbed/visionOSTestbed/SceneDelegate.h new file mode 100644 index 000000000000000..264aacadca16e5d --- /dev/null +++ b/Platforms/Apple/testbed/visionOSTestbed/SceneDelegate.h @@ -0,0 +1,12 @@ +// +// SceneDelegate.h +// iOSTestbed +// + +#import + +@interface SceneDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/Platforms/Apple/testbed/visionOSTestbed/SceneDelegate.m b/Platforms/Apple/testbed/visionOSTestbed/SceneDelegate.m new file mode 100644 index 000000000000000..e82e447985d2e90 --- /dev/null +++ b/Platforms/Apple/testbed/visionOSTestbed/SceneDelegate.m @@ -0,0 +1,21 @@ +// +// SceneDelegate.m +// iOSTestbed +// + +#import "SceneDelegate.h" + +@interface SceneDelegate () + +@end + +@implementation SceneDelegate + +- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { + UIWindowScene *windowScene = (UIWindowScene *)scene; + self.window = [[UIWindow alloc] initWithWindowScene:windowScene]; + self.window.rootViewController = [[UIViewController alloc] init]; + [self.window makeKeyAndVisible]; +} + +@end diff --git a/Platforms/Apple/testbed/visionOSTestbed/app/README b/Platforms/Apple/testbed/visionOSTestbed/app/README new file mode 100644 index 000000000000000..af22c685f87976a --- /dev/null +++ b/Platforms/Apple/testbed/visionOSTestbed/app/README @@ -0,0 +1,7 @@ +This folder can contain any Python application code. + +During the build, any binary modules found in this folder will be processed into +iOS Framework form. + +When the test suite runs, this folder will be on the PYTHONPATH, and will be the +working directory for the test suite. diff --git a/Platforms/Apple/testbed/visionOSTestbed/app_packages/README b/Platforms/Apple/testbed/visionOSTestbed/app_packages/README new file mode 100644 index 000000000000000..42d7fdeb813250f --- /dev/null +++ b/Platforms/Apple/testbed/visionOSTestbed/app_packages/README @@ -0,0 +1,7 @@ +This folder can be a target for installing any Python dependencies needed by the +test suite. + +During the build, any binary modules found in this folder will be processed into +iOS Framework form. + +When the test suite runs, this folder will be on the PYTHONPATH. diff --git a/Platforms/Apple/testbed/visionOSTestbed/main.m b/Platforms/Apple/testbed/visionOSTestbed/main.m new file mode 100644 index 000000000000000..2bb491f25c851bd --- /dev/null +++ b/Platforms/Apple/testbed/visionOSTestbed/main.m @@ -0,0 +1,16 @@ +// +// main.m +// visionOSTestbed +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + NSString * appDelegateClassName; + @autoreleasepool { + appDelegateClassName = NSStringFromClass([AppDelegate class]); + + return UIApplicationMain(argc, argv, nil, appDelegateClassName); + } +} diff --git a/Platforms/Apple/testbed/visionOSTestbed/visionOSTestbed-Info.plist b/Platforms/Apple/testbed/visionOSTestbed/visionOSTestbed-Info.plist new file mode 100644 index 000000000000000..11a8230d1d2cc0c --- /dev/null +++ b/Platforms/Apple/testbed/visionOSTestbed/visionOSTestbed-Info.plist @@ -0,0 +1,66 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + org.python.visionOSTestbed + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + TestArgs + + test + -uall + --single-process + --rerun + -W + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneDelegateClassName + SceneDelegate + UISceneConfigurationName + Default Configuration + + + + + UIRequiresFullScreen + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Platforms/Apple/testbed/watchOSTestbed.xcodeproj/project.pbxproj b/Platforms/Apple/testbed/watchOSTestbed.xcodeproj/project.pbxproj new file mode 100644 index 000000000000000..02b98a685cea6c0 --- /dev/null +++ b/Platforms/Apple/testbed/watchOSTestbed.xcodeproj/project.pbxproj @@ -0,0 +1,490 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXBuildFile section */ + 60F7C0012EB0000000A1B2C3 /* Python{{abiflags}}.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 60F7C0072EB0000000A1B2C3 /* Python{{abiflags}}.xcframework */; }; + 60F7C0022EB0000000A1B2C3 /* Python{{abiflags}}.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 60F7C0072EB0000000A1B2C3 /* Python{{abiflags}}.xcframework */; }; + 60F7C0032EB0000000A1B2C3 /* Python{{abiflags}}.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 60F7C0072EB0000000A1B2C3 /* Python{{abiflags}}.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 60F7C0042EB0000000A1B2C3 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 60F7C0132EB0000000A1B2C3 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 60F7C0112EB0000000A1B2C3; + remoteInfo = watchOSTestbed; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 60F7C0052EB0000000A1B2C3 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 60F7C0032EB0000000A1B2C3 /* Python{{abiflags}}.xcframework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 60F7C0062EB0000000A1B2C3 /* watchOSTestbed.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = watchOSTestbed.xctestplan; sourceTree = ""; }; + 60F7C0072EB0000000A1B2C3 /* Python{{abiflags}}.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = Python{{abiflags}}.xcframework; sourceTree = ""; }; + 60F7C0082EB0000000A1B2C3 /* watchOSTestbed.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = watchOSTestbed.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 60F7C0092EB0000000A1B2C3 /* TestbedTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestbedTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ + 60F7C00A2EB0000000A1B2C3 /* Exceptions for "watchOSTestbed" folder in "watchOSTestbed" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + "watchOSTestbed-Info.plist", + ); + target = 60F7C0112EB0000000A1B2C3 /* watchOSTestbed */; + }; +/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + 60F7C00B2EB0000000A1B2C3 /* watchOSTestbed */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + 60F7C00A2EB0000000A1B2C3 /* Exceptions for "watchOSTestbed" folder in "watchOSTestbed" target */, + ); + explicitFolders = ( + app, + app_packages, + ); + path = watchOSTestbed; + sourceTree = ""; + }; + 60F7C00C2EB0000000A1B2C3 /* TestbedTests */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = TestbedTests; + sourceTree = ""; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + +/* Begin PBXFrameworksBuildPhase section */ + 60F7C00D2EB0000000A1B2C3 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 60F7C0022EB0000000A1B2C3 /* Python{{abiflags}}.xcframework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 60F7C00E2EB0000000A1B2C3 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 60F7C0012EB0000000A1B2C3 /* Python{{abiflags}}.xcframework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 60F7C00F2EB0000000A1B2C3 = { + isa = PBXGroup; + children = ( + 60F7C0062EB0000000A1B2C3 /* watchOSTestbed.xctestplan */, + 60F7C0072EB0000000A1B2C3 /* Python{{abiflags}}.xcframework */, + 60F7C00B2EB0000000A1B2C3 /* watchOSTestbed */, + 60F7C00C2EB0000000A1B2C3 /* TestbedTests */, + 60F7C0102EB0000000A1B2C3 /* Products */, + ); + sourceTree = ""; + }; + 60F7C0102EB0000000A1B2C3 /* Products */ = { + isa = PBXGroup; + children = ( + 60F7C0082EB0000000A1B2C3 /* watchOSTestbed.app */, + 60F7C0092EB0000000A1B2C3 /* TestbedTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 60F7C0112EB0000000A1B2C3 /* watchOSTestbed */ = { + isa = PBXNativeTarget; + buildConfigurationList = 60F7C0212EB0000000A1B2C3 /* Build configuration list for PBXNativeTarget "watchOSTestbed" */; + buildPhases = ( + 60F7C0172EB0000000A1B2C3 /* Sources */, + 60F7C00D2EB0000000A1B2C3 /* Frameworks */, + 60F7C0142EB0000000A1B2C3 /* Resources */, + 60F7C0162EB0000000A1B2C3 /* Process Python libraries */, + 60F7C0052EB0000000A1B2C3 /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + 60F7C00B2EB0000000A1B2C3 /* watchOSTestbed */, + ); + name = watchOSTestbed; + packageProductDependencies = ( + ); + productName = watchOSTestbed; + productReference = 60F7C0082EB0000000A1B2C3 /* watchOSTestbed.app */; + productType = "com.apple.product-type.application"; + }; + 60F7C0122EB0000000A1B2C3 /* TestbedTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 60F7C0222EB0000000A1B2C3 /* Build configuration list for PBXNativeTarget "TestbedTests" */; + buildPhases = ( + 60F7C0182EB0000000A1B2C3 /* Sources */, + 60F7C00E2EB0000000A1B2C3 /* Frameworks */, + 60F7C0152EB0000000A1B2C3 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 60F7C0192EB0000000A1B2C3 /* PBXTargetDependency */, + ); + fileSystemSynchronizedGroups = ( + 60F7C00C2EB0000000A1B2C3 /* TestbedTests */, + ); + name = TestbedTests; + packageProductDependencies = ( + ); + productName = TestbedTests; + productReference = 60F7C0092EB0000000A1B2C3 /* TestbedTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 60F7C0132EB0000000A1B2C3 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1620; + TargetAttributes = { + 60F7C0112EB0000000A1B2C3 = { + CreatedOnToolsVersion = 16.2; + }; + 60F7C0122EB0000000A1B2C3 = { + CreatedOnToolsVersion = 16.2; + TestTargetID = 60F7C0112EB0000000A1B2C3; + }; + }; + }; + buildConfigurationList = 60F7C0202EB0000000A1B2C3 /* Build configuration list for PBXProject "watchOSTestbed" */; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 60F7C00F2EB0000000A1B2C3; + minimizedProjectReferenceProxies = 1; + preferredProjectObjectVersion = 77; + productRefGroup = 60F7C0102EB0000000A1B2C3 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 60F7C0112EB0000000A1B2C3 /* watchOSTestbed */, + 60F7C0122EB0000000A1B2C3 /* TestbedTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 60F7C0142EB0000000A1B2C3 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 60F7C0152EB0000000A1B2C3 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 60F7C0162EB0000000A1B2C3 /* Process Python libraries */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Process Python libraries"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "set -e\n\nsource \"$PROJECT_DIR/Python{{abiflags}}.xcframework/build/utils.sh\"\n\ninstall_python Python{{abiflags}}.xcframework app app_packages\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 60F7C0172EB0000000A1B2C3 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 60F7C0182EB0000000A1B2C3 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 60F7C0192EB0000000A1B2C3 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 60F7C0112EB0000000A1B2C3 /* watchOSTestbed */; + targetProxy = 60F7C0042EB0000000A1B2C3 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 60F7C01A2EB0000000A1B2C3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)"; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/Python{{abiflags}}.framework/Headers"; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = watchos; + WATCHOS_DEPLOYMENT_TARGET = 9.0; + }; + name = Debug; + }; + 60F7C01B2EB0000000A1B2C3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)"; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/Python{{abiflags}}.framework/Headers"; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = watchos; + VALIDATE_PRODUCT = YES; + WATCHOS_DEPLOYMENT_TARGET = 9.0; + }; + name = Release; + }; + 60F7C01C2EB0000000A1B2C3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = NO; + INFOPLIST_FILE = "watchOSTestbed/watchOSTestbed-Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = org.python.watchOSTestbed; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = 4; + }; + name = Debug; + }; + 60F7C01D2EB0000000A1B2C3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = NO; + INFOPLIST_FILE = "watchOSTestbed/watchOSTestbed-Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = org.python.watchOSTestbed; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = 4; + }; + name = Release; + }; + 60F7C01E2EB0000000A1B2C3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = org.python.TestbedTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = 4; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/watchOSTestbed.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/watchOSTestbed"; + WATCHOS_DEPLOYMENT_TARGET = 9.0; + }; + name = Debug; + }; + 60F7C01F2EB0000000A1B2C3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = org.python.TestbedTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = 4; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/watchOSTestbed.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/watchOSTestbed"; + WATCHOS_DEPLOYMENT_TARGET = 9.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 60F7C0202EB0000000A1B2C3 /* Build configuration list for PBXProject "watchOSTestbed" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 60F7C01A2EB0000000A1B2C3 /* Debug */, + 60F7C01B2EB0000000A1B2C3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 60F7C0212EB0000000A1B2C3 /* Build configuration list for PBXNativeTarget "watchOSTestbed" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 60F7C01C2EB0000000A1B2C3 /* Debug */, + 60F7C01D2EB0000000A1B2C3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 60F7C0222EB0000000A1B2C3 /* Build configuration list for PBXNativeTarget "TestbedTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 60F7C01E2EB0000000A1B2C3 /* Debug */, + 60F7C01F2EB0000000A1B2C3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 60F7C0132EB0000000A1B2C3 /* Project object */; +} diff --git a/Platforms/Apple/testbed/watchOSTestbed.xcodeproj/xcshareddata/xcschemes/watchOSTestbed.xcscheme b/Platforms/Apple/testbed/watchOSTestbed.xcodeproj/xcshareddata/xcschemes/watchOSTestbed.xcscheme new file mode 100644 index 000000000000000..96689416946110d --- /dev/null +++ b/Platforms/Apple/testbed/watchOSTestbed.xcodeproj/xcshareddata/xcschemes/watchOSTestbed.xcscheme @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Platforms/Apple/testbed/watchOSTestbed.xctestplan b/Platforms/Apple/testbed/watchOSTestbed.xctestplan new file mode 100644 index 000000000000000..f83ff3a5595074c --- /dev/null +++ b/Platforms/Apple/testbed/watchOSTestbed.xctestplan @@ -0,0 +1,46 @@ +{ + "configurations" : [ + { + "id" : "8E3B1C52-4F0A-4D7E-9B61-2C5A7E0D9F14", + "name" : "Test Scheme Action", + "options" : { + + } + } + ], + "defaultOptions" : { + "commandLineArgumentEntries" : [ + { + "argument" : "test" + }, + { + "argument" : "-uall" + }, + { + "argument" : "--single-process" + }, + { + "argument" : "--rerun" + }, + { + "argument" : "-W" + } + ], + "targetForVariableExpansion" : { + "containerPath" : "container:watchOSTestbed.xcodeproj", + "identifier" : "60F7C0112EB0000000A1B2C3", + "name" : "watchOSTestbed" + } + }, + "testTargets" : [ + { + "parallelizable" : false, + "target" : { + "containerPath" : "container:watchOSTestbed.xcodeproj", + "identifier" : "60F7C0122EB0000000A1B2C3", + "name" : "TestbedTests" + } + } + ], + "version" : 1 +} diff --git a/Platforms/Apple/testbed/watchOSTestbed/AppDelegate.h b/Platforms/Apple/testbed/watchOSTestbed/AppDelegate.h new file mode 100644 index 000000000000000..cc7359048ae4c41 --- /dev/null +++ b/Platforms/Apple/testbed/watchOSTestbed/AppDelegate.h @@ -0,0 +1,11 @@ +// +// AppDelegate.h +// watchOSTestbed +// + +#import + +@interface AppDelegate : NSObject + + +@end diff --git a/Platforms/Apple/testbed/watchOSTestbed/AppDelegate.m b/Platforms/Apple/testbed/watchOSTestbed/AppDelegate.m new file mode 100644 index 000000000000000..3390d2efc879f70 --- /dev/null +++ b/Platforms/Apple/testbed/watchOSTestbed/AppDelegate.m @@ -0,0 +1,21 @@ +// +// AppDelegate.m +// watchOSTestbed +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + +// The testbed has no storyboard (Interface.plist), so WatchKit requires the +// delegate to provide a root interface controller class, or the app crashes +// on launch. +- (Class)applicationRootInterfaceControllerClass { + return [WKInterfaceController class]; +} + +@end diff --git a/Platforms/Apple/testbed/watchOSTestbed/app/README b/Platforms/Apple/testbed/watchOSTestbed/app/README new file mode 100644 index 000000000000000..46c0e8e2a29a1cc --- /dev/null +++ b/Platforms/Apple/testbed/watchOSTestbed/app/README @@ -0,0 +1,7 @@ +This folder can contain any Python application code. + +During the build, any binary modules found in this folder will be processed into +Framework form. + +When the test suite runs, this folder will be on the PYTHONPATH, and will be the +working directory for the test suite. diff --git a/Platforms/Apple/testbed/watchOSTestbed/app_packages/README b/Platforms/Apple/testbed/watchOSTestbed/app_packages/README new file mode 100644 index 000000000000000..02c2beccfbdaed2 --- /dev/null +++ b/Platforms/Apple/testbed/watchOSTestbed/app_packages/README @@ -0,0 +1,7 @@ +This folder can be a target for installing any Python dependencies needed by the +test suite. + +During the build, any binary modules found in this folder will be processed into +Framework form. + +When the test suite runs, this folder will be on the PYTHONPATH. diff --git a/Platforms/Apple/testbed/watchOSTestbed/main.m b/Platforms/Apple/testbed/watchOSTestbed/main.m new file mode 100644 index 000000000000000..b0e43f1a06f59eb --- /dev/null +++ b/Platforms/Apple/testbed/watchOSTestbed/main.m @@ -0,0 +1,16 @@ +// +// main.m +// watchOSTestbed +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + NSString * appDelegateClassName; + @autoreleasepool { + appDelegateClassName = NSStringFromClass([AppDelegate class]); + + return WKApplicationMain(argc, argv, appDelegateClassName); + } +} diff --git a/Platforms/Apple/testbed/watchOSTestbed/watchOSTestbed-Info.plist b/Platforms/Apple/testbed/watchOSTestbed/watchOSTestbed-Info.plist new file mode 100644 index 000000000000000..4f25642a8e22b47 --- /dev/null +++ b/Platforms/Apple/testbed/watchOSTestbed/watchOSTestbed-Info.plist @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + org.python.watchOSTestbed + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + WKApplication + + WKWatchOnly + + + diff --git a/Platforms/Apple/tvOS/README.md b/Platforms/Apple/tvOS/README.md new file mode 100644 index 000000000000000..de4d5e209bf9ff9 --- /dev/null +++ b/Platforms/Apple/tvOS/README.md @@ -0,0 +1,30 @@ +# Python on tvOS README + +This document provides a quick overview of some tvOS specific features in the +Python distribution. + +Python on tvOS is largely the same as Python on iOS; most of the instructions in +the [iOS README](../iOS/README.md) can be used for tvOS builds, substituting: + +- `tvOS` as the identifier for `Platforms/Apple` invocations; e.g., + - `python Platforms/Apple build tvOS` + - `python Platforms/Apple ci tvOS` + - `python Platforms/Apple test tvOS` + +- tvOS resources are stored in the `Platforms/Apple/tvOS/Resources` directory. + +- The tvOS SDK version is controlled with the `TVOS_SDK_VERSION` environment + variable. + +- The minimum supported tvOS SDK version is controlled with the + `TVOS_DEPLOYMENT_TARGET` environment variable. + +- When referencing platforms, the tvOS compiler triples are: + - `arm64-apple-tvos` for AppleTV devices + - `arm64-apple-tvos-simulator` for AppleTV simulators on ARM64 hardware + - `x86_64-apple-tvos-simulator` for AppleTV simulators on x86-64 hardware + +- The tvOS testbed Xcode template project is stored in + `Platforms/Apple/testbed/tvOSTestbed`. + +- `platform.ios_ver()` will return tvOS-relevant version information. diff --git a/Platforms/Apple/tvOS/Resources/Info.plist.in b/Platforms/Apple/tvOS/Resources/Info.plist.in new file mode 100644 index 000000000000000..b913504d69e096a --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/Info.plist.in @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + @PYTHONFRAMEWORK@ + CFBundleGetInfoString + Python Runtime and Library + CFBundleIdentifier + @PYTHONFRAMEWORKIDENTIFIER@ + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + @PYTHONFRAMEWORK@ + CFBundlePackageType + FMWK + CFBundleShortVersionString + %VERSION% + CFBundleLongVersionString + %VERSION%, (c) 2001-2024 Python Software Foundation. + CFBundleSignature + ???? + CFBundleVersion + 1 + CFBundleSupportedPlatforms + + tvOS + + MinimumOSVersion + @TVOS_DEPLOYMENT_TARGET@ + + diff --git a/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-ar b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-ar new file mode 100755 index 000000000000000..482a8da6c64b9cd --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-ar @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvos${TVOS_SDK_VERSION} ar "$@" diff --git a/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-clang b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-clang new file mode 100755 index 000000000000000..c08cefd6067e381 --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-clang @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvos${TVOS_SDK_VERSION} clang -target arm64-apple-tvos${TVOS_DEPLOYMENT_TARGET} "$@" diff --git a/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-clang++ b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-clang++ new file mode 100755 index 000000000000000..3425d57aafa5e02 --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-clang++ @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvos${TVOS_SDK_VERSION} clang++ -target arm64-apple-tvos${TVOS_DEPLOYMENT_TARGET} "$@" diff --git a/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-cpp b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-cpp new file mode 100755 index 000000000000000..8466e9ada39c454 --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-cpp @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvos${TVOS_SDK_VERSION} clang -target arm64-apple-tvos${TVOS_DEPLOYMENT_TARGET} -E "$@" diff --git a/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-ar b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-ar new file mode 100755 index 000000000000000..a0b20edc7a9e67f --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-ar @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} ar "$@" diff --git a/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-clang b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-clang new file mode 100755 index 000000000000000..fa5e7cbd5bcd03d --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-clang @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} clang -target arm64-apple-tvos${TVOS_DEPLOYMENT_TARGET}-simulator "$@" diff --git a/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-clang++ b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-clang++ new file mode 100755 index 000000000000000..b3f82e8ca360692 --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-clang++ @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} clang++ -target arm64-apple-tvos${TVOS_DEPLOYMENT_TARGET}-simulator "$@" diff --git a/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-cpp b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-cpp new file mode 100755 index 000000000000000..aba485f1e239a79 --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-cpp @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} clang -target arm64-apple-tvos${TVOS_DEPLOYMENT_TARGET}-simulator -E "$@" diff --git a/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-strip b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-strip new file mode 100755 index 000000000000000..a8cce95233e75f5 --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} strip -arch arm64 "$@" diff --git a/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-strip b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-strip new file mode 100755 index 000000000000000..ee1d2b95ff1bb49 --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/bin/arm64-apple-tvos-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphoneos${TVOS_SDK_VERSION} strip -arch arm64 "$@" diff --git a/Platforms/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-ar b/Platforms/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-ar new file mode 100755 index 000000000000000..a0b20edc7a9e67f --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-ar @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} ar "$@" diff --git a/Platforms/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-clang b/Platforms/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-clang new file mode 100755 index 000000000000000..6c1a538b64df9e2 --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-clang @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} clang -target x86_64-apple-tvos${TVOS_DEPLOYMENT_TARGET}-simulator "$@" diff --git a/Platforms/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-clang++ b/Platforms/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-clang++ new file mode 100755 index 000000000000000..efa76909c374234 --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-clang++ @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} clang++ -target x86_64-apple-tvos${TVOS_DEPLOYMENT_TARGET}-simulator "$@" diff --git a/Platforms/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-cpp b/Platforms/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-cpp new file mode 100755 index 000000000000000..f6ad1a5c2e2a543 --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-cpp @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} clang -target x86_64-apple-tvos${TVOS_DEPLOYMENT_TARGET}-simulator -E "$@" diff --git a/Platforms/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-strip b/Platforms/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-strip new file mode 100755 index 000000000000000..f6a884b4aef6204 --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} strip -arch x86_64 "$@" diff --git a/Platforms/Apple/tvOS/Resources/pyconfig.h b/Platforms/Apple/tvOS/Resources/pyconfig.h new file mode 100644 index 000000000000000..4acff2c60516377 --- /dev/null +++ b/Platforms/Apple/tvOS/Resources/pyconfig.h @@ -0,0 +1,7 @@ +#ifdef __arm64__ +#include "pyconfig-arm64.h" +#endif + +#ifdef __x86_64__ +#include "pyconfig-x86_64.h" +#endif diff --git a/Platforms/Apple/visionOS/README.md b/Platforms/Apple/visionOS/README.md new file mode 100644 index 000000000000000..45bf0157137f28c --- /dev/null +++ b/Platforms/Apple/visionOS/README.md @@ -0,0 +1,30 @@ +# Python on visionOS README + +This document provides a quick overview of some visionOS specific features in the +Python distribution. + +Python on visionOS is largely the same as Python on iOS; most of the instructions in +the [iOS README](../iOS/README.md) can be used for visionOS builds, substituting: + +- `visionOS` as the identifier for `Platforms/Apple` invocations; e.g., + - `python Platforms/Apple build visionOS` + - `python Platforms/Apple ci visionOS` + - `python Platforms/Apple test visionOS` + +- visionOS resources are stored in the `Platforms/Apple/visionOS/Resources` + directory. + +- The visionOS SDK version is controlled with the `XROS_SDK_VERSION` environment + variable. + +- The minimum supported visionOS SDK version is controlled with the + `XROS_DEPLOYMENT_TARGET` environment variable. + +- When referencing platforms, the visionOS compiler triples are: + - `arm64-apple-xros` for Apple Vision devices + - `arm64-apple-xros-simulator` for Apple Vision simulators + +- The visionOS testbed Xcode template project is stored in + `Platforms/Apple/testbed/visionOSTestbed`. + +- `platform.ios_ver()` will return visionOS-relevant version information. diff --git a/Platforms/Apple/visionOS/Resources/Info.plist.in b/Platforms/Apple/visionOS/Resources/Info.plist.in new file mode 100644 index 000000000000000..c3dd63ced8df89f --- /dev/null +++ b/Platforms/Apple/visionOS/Resources/Info.plist.in @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + @PYTHONFRAMEWORK@ + CFBundleGetInfoString + Python Runtime and Library + CFBundleIdentifier + @PYTHONFRAMEWORKIDENTIFIER@ + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + @PYTHONFRAMEWORK@ + CFBundlePackageType + FMWK + CFBundleShortVersionString + %VERSION% + CFBundleLongVersionString + %VERSION%, (c) 2001-2023 Python Software Foundation. + CFBundleSignature + ???? + CFBundleVersion + %VERSION% + CFBundleSupportedPlatforms + + XROS + + MinimumOSVersion + @XROS_DEPLOYMENT_TARGET@ + + diff --git a/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-ar b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-ar new file mode 100755 index 000000000000000..f31c0fc3b89abd4 --- /dev/null +++ b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-ar @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk xros${XROS_SDK_VERSION} ar "$@" diff --git a/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-clang b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-clang new file mode 100755 index 000000000000000..d2405ac3405a860 --- /dev/null +++ b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-clang @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk xros${XROS_SDK_VERSION} clang -target arm64-apple-xros${XROS_DEPLOYMENT_TARGET} "$@" diff --git a/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-clang++ b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-clang++ new file mode 100755 index 000000000000000..9063f19ef9a9d5f --- /dev/null +++ b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-clang++ @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk xros${XROS_SDK_VERSION} clang++ -target arm64-apple-xros${XROS_DEPLOYMENT_TARGET} "$@" diff --git a/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-cpp b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-cpp new file mode 100755 index 000000000000000..17a40cbbee1b425 --- /dev/null +++ b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-cpp @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk xros${XROS_SDK_VERSION} clang -target arm64-apple-xros${XROS_DEPLOYMENT_TARGET} -E "$@" diff --git a/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-ar b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-ar new file mode 100755 index 000000000000000..cf0468377b3386b --- /dev/null +++ b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-ar @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk xrsimulator${XROS_SDK_VERSION} ar "$@" diff --git a/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-clang b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-clang new file mode 100755 index 000000000000000..ef57a9b76101038 --- /dev/null +++ b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-clang @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk xrsimulator${XROS_SDK_VERSION} clang -target arm64-apple-xros${XROS_DEPLOYMENT_TARGET}-simulator "$@" diff --git a/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-clang++ b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-clang++ new file mode 100755 index 000000000000000..0cc3ec328658624 --- /dev/null +++ b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-clang++ @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk xrsimulator${XROS_SDK_VERSION} clang++ -target arm64-apple-xros${XROS_DEPLOYMENT_TARGET}-simulator "$@" diff --git a/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-cpp b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-cpp new file mode 100755 index 000000000000000..835a54a0f9ead1d --- /dev/null +++ b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-cpp @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk xrsimulator${XROS_SDK_VERSION} clang -target arm64-apple-xros${XROS_DEPLOYMENT_TARGET}-simulator -E "$@" diff --git a/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-strip b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-strip new file mode 100644 index 000000000000000..376aff61a232ef4 --- /dev/null +++ b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk xrsimulator${XROS_SDK_VERSION} strip -arch arm64 "$@" diff --git a/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-strip b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-strip new file mode 100644 index 000000000000000..2de3ba5d31cb10c --- /dev/null +++ b/Platforms/Apple/visionOS/Resources/bin/arm64-apple-xros-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk xros${XROS_SDK_VERSION} strip -arch arm64 "$@" diff --git a/Platforms/Apple/visionOS/Resources/pyconfig.h b/Platforms/Apple/visionOS/Resources/pyconfig.h new file mode 100644 index 000000000000000..2a4330784006dd5 --- /dev/null +++ b/Platforms/Apple/visionOS/Resources/pyconfig.h @@ -0,0 +1,3 @@ +#ifdef __arm64__ +#include "pyconfig-arm64.h" +#endif diff --git a/Platforms/Apple/watchOS/README.md b/Platforms/Apple/watchOS/README.md new file mode 100644 index 000000000000000..6d96ac4855628ee --- /dev/null +++ b/Platforms/Apple/watchOS/README.md @@ -0,0 +1,31 @@ +# Python on watchOS README + +This document provides a quick overview of some watchOS specific features in the +Python distribution. + +Python on watchOS is largely the same as Python on iOS; most of the instructions in +the [iOS README](../iOS/README.md) can be used for watchOS builds, substituting: + +- `watchOS` as the identifier for `Platforms/Apple` invocations; e.g., + - `python Platforms/Apple build watchOS` + - `python Platforms/Apple ci watchOS` + - `python Platforms/Apple test watchOS` + +- watchOS resources are stored in the `Platforms/Apple/watchOS/Resources` + directory + +- The watchOS SDK version is controlled with the `WATCHOS_SDK_VERSION` environment + variable. + +- The minimum supported watchOS SDK version is controlled with the + `WATCHOS_DEPLOYMENT_TARGET` environment variable. + +- When referencing platforms, the watchOS compiler triples are: + - `arm64_32-apple-watchos` for Apple Watch devices + - `arm64-apple-watchos-simulator` for Apple Watch simulators on ARM64 hardware + - `x86_64-apple-watchos-simulator` for Apple Watch simulators on x86_64 hardware + +- The watchOS testbed Xcode template project is stored in + `Platforms/Apple/testbed/watchOSTestbed`. + +- `platform.ios_ver()` will return watchOS-relevant version information. diff --git a/Platforms/Apple/watchOS/Resources/Info.plist.in b/Platforms/Apple/watchOS/Resources/Info.plist.in new file mode 100644 index 000000000000000..b2f64710d704cdc --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/Info.plist.in @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + @PYTHONFRAMEWORK@ + CFBundleGetInfoString + Python Runtime and Library + CFBundleIdentifier + @PYTHONFRAMEWORKIDENTIFIER@ + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + @PYTHONFRAMEWORK@ + CFBundlePackageType + FMWK + CFBundleShortVersionString + %VERSION% + CFBundleLongVersionString + %VERSION%, (c) 2001-2023 Python Software Foundation. + CFBundleSignature + ???? + CFBundleVersion + %VERSION% + CFBundleSupportedPlatforms + + watchOS + + MinimumOSVersion + @WATCHOS_DEPLOYMENT_TARGET@ + + diff --git a/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-ar b/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-ar new file mode 100755 index 000000000000000..0e1b948633ef814 --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-ar @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} ar "$@" diff --git a/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-clang b/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-clang new file mode 100755 index 000000000000000..6911a2e3bf38848 --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-clang @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} clang -target arm64-apple-watchos${WATCHOS_DEPLOYMENT_TARGET}-simulator "$@" diff --git a/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-clang++ b/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-clang++ new file mode 100755 index 000000000000000..7dacb3d858557c4 --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-clang++ @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} clang++ -target arm64-apple-watchos${WATCHOS_DEPLOYMENT_TARGET}-simulator "$@" diff --git a/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-cpp b/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-cpp new file mode 100755 index 000000000000000..a31bc3fb7e49dd8 --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-cpp @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchsimulator clang -target arm64-apple-watchos${WATCHOS_DEPLOYMENT_TARGET}-simulator -E "$@" diff --git a/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-strip b/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-strip new file mode 100755 index 000000000000000..e28e3f7597a83d1 --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} strip -arch arm64 "$@" diff --git a/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-strip b/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-strip new file mode 100755 index 000000000000000..efe5a1260ad910a --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/bin/arm64-apple-watchos-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchos${WATCHOS_SDK_VERSION} strip -arch arm64 "$@" diff --git a/Platforms/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-ar b/Platforms/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-ar new file mode 100755 index 000000000000000..78b647b78e5b86c --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-ar @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchos${WATCHOS_SDK_VERSION} ar "$@" diff --git a/Platforms/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-clang b/Platforms/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-clang new file mode 100755 index 000000000000000..cf7c175b1b0a370 --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-clang @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchos${WATCHOS_SDK_VERSION} clang -target arm64_32-apple-watchos${WATCHOS_DEPLOYMENT_TARGET} "$@" diff --git a/Platforms/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-clang++ b/Platforms/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-clang++ new file mode 100755 index 000000000000000..c3e6ddfa1fe353e --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-clang++ @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchos${WATCHOS_SDK_VERSION} clang++ -target arm64_32-apple-watchos${WATCHOS_DEPLOYMENT_TARGET} "$@" diff --git a/Platforms/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-cpp b/Platforms/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-cpp new file mode 100755 index 000000000000000..d038450a901a176 --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-cpp @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchos${WATCHOS_SDK_VERSION} clang -target arm64_32-apple-watchos${WATCHOS_DEPLOYMENT_TARGET} -E "$@" diff --git a/Platforms/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-ar b/Platforms/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-ar new file mode 100755 index 000000000000000..0e1b948633ef814 --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-ar @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} ar "$@" diff --git a/Platforms/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-clang b/Platforms/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-clang new file mode 100755 index 000000000000000..a839a93ab4711c4 --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-clang @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} clang -target x86_64-apple-watchos${WATCHOS_DEPLOYMENT_TARGET}-simulator "$@" diff --git a/Platforms/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-clang++ b/Platforms/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-clang++ new file mode 100755 index 000000000000000..f0ecc650dfdbbde --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-clang++ @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} clang++ -target x86_64-apple-watchos${WATCHOS_DEPLOYMENT_TARGET}-simulator "$@" diff --git a/Platforms/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-cpp b/Platforms/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-cpp new file mode 100755 index 000000000000000..1fe12659baf3e97 --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-cpp @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} clang -target x86_64-apple-watchos${WATCHOS_DEPLOYMENT_TARGET}-simulator -E "$@" diff --git a/Platforms/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-strip b/Platforms/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-strip new file mode 100755 index 000000000000000..105c78281f9b345 --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} strip -arch x86_64 "$@" diff --git a/Platforms/Apple/watchOS/Resources/pyconfig.h b/Platforms/Apple/watchOS/Resources/pyconfig.h new file mode 100644 index 000000000000000..f842b987b2edba1 --- /dev/null +++ b/Platforms/Apple/watchOS/Resources/pyconfig.h @@ -0,0 +1,11 @@ +#ifdef __arm64__ +# ifdef __LP64__ +#include "pyconfig-arm64.h" +# else +#include "pyconfig-arm64_32.h" +# endif +#endif + +#ifdef __x86_64__ +#include "pyconfig-x86_64.h" +#endif diff --git a/Platforms/WASI/README.md b/Platforms/WASI/README.md index 62c82924d437b15..c99b628d7b88a7e 100644 --- a/Platforms/WASI/README.md +++ b/Platforms/WASI/README.md @@ -9,9 +9,276 @@ use WASM runtimes such as [wasmtime](https://wasmtime.dev/). **NOTE**: If you are looking for general information about WebAssembly that is not directly related to CPython, please see https://github.com/psf/webassembly. -## Build -See [the devguide on how to build and run for WASI](https://devguide.python.org/getting-started/setup-building/#wasi). +## Working on the WASI build + +This directory provides a CLI for building and packaging WASI builds for +distribution. + +Run all commands below from the root of the CPython source checkout. + +To see all the available commands, run: + +```shell +python3 Platforms/WASI --help +``` + +The `python3` interpreter used to run this CLI must be a Python version that +is receiving bugfixes. This requirement does not apply to the build Python, +which the CLI builds from the source checkout. + + +### Prerequisites + +There are some tools that must be available to successfully build. + +1. C compiler +2. `make` +3. WASI SDK +4. Wasmtime (or some other WASI runtime configured via `--host-runner`) + +The default runner requires Wasmtime be on `PATH`. + +The WASI SDK must be the same version as specified in config.toml. The search +for the WASI SDK is done via: + +1. `--wasi-sdk` CLI option +2. `WASI_SDK_PATH` environment variable +3. `/opt` where the WASI SDK has been unpacked from its tarball + +Note that all prerequisites are included and configured appropriately in the +[WASI dev container image](https://github.com/python/cpython-devcontainers/pkgs/container/wasicontainer). +You can download it via: + +```shell +podman pull ghcr.io/python/wasicontainer:latest +``` + +The `latest` image contains the WASI SDK versions required by all supported +CPython branches. + +### Development loop + +The common way to get started is to first do a full build: + +```shell +python3 Platforms/WASI build --quiet --logdir cross-build/logs -- --with-pydebug --config-cache +``` + +In the end, you will end up with a "build Python" which is a local build of +Python used for cross-builds. You will also have the WASI build. + +Once you have the build you can run the test you want. + +Bash: +```bash +"$(python3 Platforms/WASI path)/python.sh" -m test test_os +``` + +Fish: +```fish +set -l wasi_dir (python3 Platforms/WASI path); "$wasi_dir/python.sh" -m test test_os +``` + +If you are working on C code and need a rebuild: + +```shell +python3 Platforms/WASI make-host +``` + + +### Building + +In general, +[the devguide covers how to build and run for WASI](https://devguide.python.org/getting-started/setup-building/#wasi), +but we will cover some of the details here. + +The simplest way to get a pydebug WASI build is: + +```shell +python3 Platforms/WASI build -- --with-pydebug +``` + +This builds the build Python and the WASI build with `--with-pydebug` passed to +`configure` (as is anything that comes after `--`). The builds are placed in +the `cross-build/` directory of the source checkout, each in a subdirectory +matching the compiler triple for the build. + +You can do the two builds separately if you want: + +```shell +python3 Platforms/WASI build-python -- --with-pydebug +python3 Platforms/WASI build-host +``` + +This can be broken down even more to the separate `configure` and `make` steps: + +```shell +python3 Platforms/WASI configure-build-python -- --with-pydebug +python3 Platforms/WASI make-build-python +python3 Platforms/WASI configure-host +python3 Platforms/WASI make-host +``` + +Note that `configure-host` figures out to do a pydebug build by looking at the +build Python. + +There is a `--quiet` flag to redirect output from the underlying commands to a +directory. The `--logdir` flag controls where the log files go (which defaults +to `/tmp`). + +```shell +python3 Platforms/WASI build --quiet --logdir cross-build/logs +``` + + +### Releasing + +The `package` command is used to gather all the files necessary to make a +release and place them in an archive: + +```shell +python3 Platforms/WASI package +``` + +The files are gathered into a versioned directory inside `dist/` in the source +checkout. An archive containing that directory is placed alongside it in +`dist/`. The gathered directory includes a `bin/python3.wasmtime` file to ease +launching the interpreter. + +If you just need to gather the files for a release, you can use the `gather` +command: + +```shell +python3 Platforms/WASI gather +``` + +Both `package` and `gather` require a completed build and delete the entire +existing `dist/` directory before gathering files. + +There is no command just to archive the gathered files. + +To do a release build from `build` to `package`, you can use the `release` +command: + +```shell +python3 Platforms/WASI release +``` + +Any release-specific build flags will be set via `release`. It will also run +`clean`. + + +### Paths + +The `path` command prints the location of the build Python, WASI build, or +gathered distribution files: + +```shell +python3 Platforms/WASI path build-python +python3 Platforms/WASI path wasi +python3 Platforms/WASI path dist +``` + +With no location argument, `path` defaults to `wasi`. The `dist` location +returns the versioned distribution directory inside `dist/`, not the top-level +`dist/` directory. The `build-python` and `wasi` locations can be queried before +building; the `dist` location requires WASI build metadata to determine the +versioned directory name. + + +### Cleanup + +The `clean` command deletes the entire `cross-build/` and `dist/` directories, +including all build files, gathered distribution files, and archives: + +```shell +python3 Platforms/WASI clean +``` + + +### Testing + +After building, you can run the CI tests with: + +```shell +python3 Platforms/WASI test +``` + +The mutually exclusive CI flags to select which tests to run: + +- `--fast-ci` (the default): `make test` +- `--slow-ci`: `make buildbottest` + +The `--target` flag selects the files to test: + +- `build` (the default): the WASI build in `cross-build/`. +- `dist`: the distribution files gathered in `dist/`. +- `archive`: the contents of the release archive, unpacked into `dist/`. + +To thoroughly test the contents of the release archive, use: + +```shell +python3 Platforms/WASI test --slow-ci --target archive +``` + +This requires an archive created by `package` or `release`. It deletes the +selected versioned distribution directory inside `dist/`, then restores it +from the matching `.tar.xz` archive before running the tests. +The archive and other distributions in `dist/` are left untouched. + +You can also run tests more directly. To find out where the WASI build directory +is, you can run: + +```shell +python3 Platforms/WASI path +``` + +From there, you can run the test suite. + +For Bash-like shells: + +```bash +make buildbottest -C "$(python3 Platforms/WASI path)" +``` + +For fish: + +```fish +make buildbottest -C (python3 Platforms/WASI path) +``` + +There is a `python.sh` file in the WASI build directory, so you can also run +tests that way. + +Bash: + +```bash +"$(python3 Platforms/WASI path)/python.sh" -m test +``` + +Fish: + +```fish +set -l wasi_dir (python3 Platforms/WASI path); "$wasi_dir/python.sh" -m test +``` + +If you want to test the files meant for distribution, the directory containing +the files can be found via `python3 Platforms/WASI path dist` and there is a +`bin/python3.wasmtime` shell script. + +Bash: + +```bash +"$(python3 Platforms/WASI path dist)/bin/python3.wasmtime" -m test +``` + +Fish: + +```fish +set -l dist_dir (python3 Platforms/WASI path dist); "$dist_dir/bin/python3.wasmtime" -m test +``` + ## Detecting WASI builds @@ -48,12 +315,19 @@ posix.uname_result( 'wasi' ``` + ### C code -WASI SDK defines several built-in macros. You can dump a full list of built-ins -with ``/path/to/wasi-sdk/bin/clang -dM -E - < /dev/null``. +The following built-in macros identify WebAssembly targets and environments. +For WASI SDK, you can dump a full list of built-ins with +`/path/to/wasi-sdk/bin/clang -dM -E - < /dev/null`. + +#### Shared with Emscripten + +- WebAssembly target: `__wasm__` (also `__wasm`) +- wasm32 target: `__wasm32__` (also `__wasm32`) +- wasm64 target: `__wasm64__` + +#### Unique to WASI -* WebAssembly ``__wasm__`` (also ``__wasm``) -* wasm32 ``__wasm32__`` (also ``__wasm32``) -* wasm64 ``__wasm64__`` -* WASI ``__wasi__`` +- WASI environment: `__wasi__` diff --git a/Platforms/WASI/__main__.py b/Platforms/WASI/__main__.py index 880058bad660be9..2fea2b7d4476cb0 100644 --- a/Platforms/WASI/__main__.py +++ b/Platforms/WASI/__main__.py @@ -1,14 +1,21 @@ -#!/usr/bin/env python3 - -__lazy_modules__ = ["_build"] +__lazy_modules__ = [ + "argparse", + "os", + "pathlib", + "_build", + "_package", + "_shared", + "_test", +] import argparse import os import pathlib import _build - -HERE = pathlib.Path(__file__).parent +import _package +import _shared +import _test def main(): @@ -18,6 +25,8 @@ def main(): "--argv0 {ARGV0} " # Map the checkout to / to load the stdlib from /Lib. "--dir {CHECKOUT}::/ " + # For various I/O-related tests. + "--dir /dev " # Flags involving --optimize, --codegen, --debug, --wasm, and --wasi can be kept # in a config file. # We are using such a file to act as defaults in case a user wants to override @@ -27,6 +36,7 @@ def main(): # may want to use them. "--config {WASMTIME_CONFIG_PATH}" ) + context = _shared.Context() parser = argparse.ArgumentParser() subcommands = parser.add_subparsers(dest="subcommand") @@ -59,6 +69,49 @@ def main(): pythoninfo_host = subcommands.add_parser( "pythoninfo-host", help="Display build info of the host/WASI Python" ) + package = subcommands.add_parser( + "package", help="Package the host/WASI Python into an archive" + ) + gather = subcommands.add_parser( + "gather", help="Gather all the files for distribution" + ) + release = subcommands.add_parser( + "release", help="Build and package for a release" + ) + test = subcommands.add_parser("test", help="Run the tests") + ci_mode = test.add_mutually_exclusive_group() + ci_mode.add_argument( + "--fast-ci", + action="store_const", + dest="ci_mode", + const="fast", + default="fast", + help="Run `make test` (the default)", + ) + ci_mode.add_argument( + "--slow-ci", + action="store_const", + dest="ci_mode", + const="slow", + help="Run `make buildbottest`", + ) + test.add_argument( + "--target", + choices={"build", "dist", "archive"}, + default="build", + help="Test the build (the default), gathered distribution, or release archive; " + "'archive' replaces the distribution directory with the archive's contents", + ) + path = subcommands.add_parser( + "path", help="Print the path to a build or distribution directory" + ) + path.add_argument( + "location", + nargs="?", + choices=("build-python", "wasi", "dist"), + default="wasi", + help="Directory whose path to print", + ) subcommands.add_parser( "clean", help="Delete files and directories created by this script" ) @@ -72,6 +125,8 @@ def main(): make_host, pythoninfo_host, build_host, + release, + test, ): subcommand.add_argument( "--quiet", @@ -84,6 +139,8 @@ def main(): "--logdir", type=pathlib.Path, default=None, + dest="_log_path", + metavar="LOG-DIR", help="Directory to store log files", ) for subcommand in ( @@ -99,6 +156,13 @@ def main(): dest="clean", help="Delete any relevant directories before building", ) + for subcommand in build, configure_build, configure_host: + subcommand.add_argument( + "--release", + help="Configure build for release mode", + action="store_true", + default=False, + ) for subcommand in ( build, configure_build, @@ -107,14 +171,15 @@ def main(): build_host, ): subcommand.add_argument( - "args", nargs="*", help="Extra arguments to pass to `configure`" + "_args", nargs="*", help="Extra arguments to pass to `configure`" ) - for subcommand in build, configure_host, build_host: + for subcommand in build, configure_host, build_host, release: subcommand.add_argument( "--wasi-sdk", type=pathlib.Path, - dest="wasi_sdk_path", + dest="_wasi_sdk_path", default=None, + metavar="WASI-SDK-PATH", help="Path to the WASI SDK; defaults to WASI_SDK_PATH environment variable " "or the appropriate version found in /opt", ) @@ -132,16 +197,23 @@ def main(): make_host, build_host, pythoninfo_host, + gather, + package, + path, + release, + test, ): subcommand.add_argument( "--host-triple", action="store", default=None, + dest="_host_triple", + metavar="WASI-TRIPLE", help="The target triple for the WASI host build; " - f"defaults to the value found in {os.fsdecode(HERE / 'config.toml')}", + f"defaults to the value found in {os.fsdecode(context.here / 'config.toml')}", ) - context = parser.parse_args() + parser.parse_args(namespace=context) match context.subcommand: case "configure-build-python": @@ -166,14 +238,39 @@ def main(): # Configure and build the build Python _build.configure_build_python(context) _build.make_build_python(context) - _build.pythoninfo_build_python(context) + if not context.quiet: + _build.pythoninfo_build_python(context) # Configure and build the host/WASI Python _build.configure_wasi_python(context) _build.make_wasi_python(context) - _build.pythoninfo_wasi_python(context) + if not context.quiet: + _build.pythoninfo_wasi_python(context) case "clean": _build.clean_contents(context) + case "gather": + _package.gather(context) + case "package": + _package.gather(context) + _package.archive(context) + case "release": + context.release = True + _build.clean_contents(context) + _build.configure_build_python(context) + _build.make_build_python(context) + _build.configure_wasi_python(context) + _build.make_wasi_python(context) + _package.gather(context) + _package.archive(context) + case "test": + _test.test(context) + case "path": + paths = { + "build-python": "build_python_path", + "wasi": "wasi_build_path", + "dist": "archive_dir", + } + print(getattr(context, paths[context.location])) case None: parser.print_help() case _: diff --git a/Platforms/WASI/_build.py b/Platforms/WASI/_build.py index 792f8edd9943138..8efda324c4b048a 100644 --- a/Platforms/WASI/_build.py +++ b/Platforms/WASI/_build.py @@ -1,293 +1,56 @@ -#!/usr/bin/env python3 +__lazy_modules__ = [ + "os", + "pathlib", + "shutil", + "subprocess", + "sys", +] -__lazy_modules__ = ["shutil", "sys", "tempfile", "tomllib"] - -import contextlib -import functools import os import pathlib import shutil import subprocess import sys -import sysconfig -import tempfile -import tomllib try: from os import process_cpu_count as cpu_count except ImportError: from os import cpu_count - -CHECKOUT = HERE = pathlib.Path(__file__).parent - -while CHECKOUT != CHECKOUT.parent: - if (CHECKOUT / "configure").is_file(): - break - CHECKOUT = CHECKOUT.parent -else: - raise FileNotFoundError( - "Unable to find the root of the CPython checkout by looking for 'configure'" - ) - -CROSS_BUILD_DIR = CHECKOUT / "cross-build" -# Build platform can also be found via `config.guess`. -BUILD_DIR = CROSS_BUILD_DIR / sysconfig.get_config_var("BUILD_GNU_TYPE") - -LOCAL_SETUP = CHECKOUT / "Modules" / "Setup.local" -LOCAL_SETUP_MARKER = ( - b"# Generated by Platforms/WASI .\n" - b"# Required to statically build extension modules." -) +import _shared WASMTIME_VAR_NAME = "WASMTIME" WASMTIME_HOST_RUNNER_VAR = f"{{{WASMTIME_VAR_NAME}}}" -def separator(): - """Print a separator line across the terminal width.""" - try: - tput_output = subprocess.check_output( - ["tput", "cols"], encoding="utf-8" - ) - except subprocess.CalledProcessError: - terminal_width = 80 - else: - terminal_width = int(tput_output.strip()) - print("⎯" * terminal_width) - - -def log(emoji, message, *, spacing=None): - """Print a notification with an emoji. - - If 'spacing' is None, calculate the spacing based on the number of code points - in the emoji as terminals "eat" a space when the emoji has multiple code points. - """ - if spacing is None: - spacing = " " if len(emoji) == 1 else " " - print("".join([emoji, spacing, message])) - - -def updated_env(updates={}): - """Create a new dict representing the environment to use. - - The changes made to the execution environment are printed out. - """ - env_defaults = {} - # https://reproducible-builds.org/docs/source-date-epoch/ - git_epoch_cmd = ["git", "log", "-1", "--pretty=%ct"] - try: - epoch = subprocess.check_output( - git_epoch_cmd, encoding="utf-8" - ).strip() - env_defaults["SOURCE_DATE_EPOCH"] = epoch - except subprocess.CalledProcessError: - pass # Might be building from a tarball. - # This layering lets SOURCE_DATE_EPOCH from os.environ takes precedence. - environment = env_defaults | os.environ | updates - - env_diff = {} - for key, value in environment.items(): - if os.environ.get(key) != value: - env_diff[key] = value - - env_vars = [ - f"\n {key}={item}" for key, item in sorted(env_diff.items()) - ] - log("🌎", f"Environment changes:{''.join(env_vars)}") - - return environment - - -def subdir(working_dir, *, clean_ok=False): - """Decorator to change to a working directory.""" - - def decorator(func): - @functools.wraps(func) - def wrapper(context): - nonlocal working_dir - - if callable(working_dir): - working_dir = working_dir(context) - separator() - log("📁", os.fsdecode(working_dir)) - if ( - clean_ok - and getattr(context, "clean", False) - and working_dir.exists() - ): - log("🚮", "Deleting directory (--clean)...") - shutil.rmtree(working_dir) - - working_dir.mkdir(parents=True, exist_ok=True) - - with contextlib.chdir(working_dir): - return func(context, working_dir) - - return wrapper - - return decorator - - -def call(command, *, context=None, quiet=False, **kwargs): - """Execute a command. - - If 'quiet' is true, then redirect stdout and stderr to a temporary file. - """ - if context is not None: - quiet = context.quiet - - log("❯", " ".join(map(str, command)), spacing=" ") - if not quiet: - stdout = None - stderr = None - else: - if (logdir := getattr(context, "logdir", None)) is None: - logdir = pathlib.Path(tempfile.gettempdir()) - stdout = tempfile.NamedTemporaryFile( - "w", - encoding="utf-8", - delete=False, - dir=logdir, - prefix="cpython-wasi-", - suffix=".log", - ) - stderr = subprocess.STDOUT - log("📝", f"Logging output to {stdout.name} (--quiet)...") - - subprocess.check_call(command, **kwargs, stdout=stdout, stderr=stderr) - - -def build_python_path(): - """The path to the build Python binary.""" - binary = BUILD_DIR / "python" - if not binary.is_file(): - binary = binary.with_suffix(".exe") - if not binary.is_file(): - raise FileNotFoundError( - f"Unable to find `python(.exe)` in {BUILD_DIR}" - ) - - return binary - - -def build_python_is_pydebug(): - """Find out if the build Python is a pydebug build.""" - test = "import sys, test.support; sys.exit(test.support.Py_DEBUG)" - result = subprocess.run( - [build_python_path(), "-c", test], - capture_output=True, - ) - return bool(result.returncode) - - -@subdir(BUILD_DIR, clean_ok=True) +@_shared.subdir("build_python_path", clean_ok=True) def configure_build_python(context, working_dir): """Configure the build/host Python.""" - if LOCAL_SETUP.exists(): - if LOCAL_SETUP.read_bytes() == LOCAL_SETUP_MARKER: - log("👍", f"{LOCAL_SETUP} exists ...") - else: - log("⚠️", f"{LOCAL_SETUP} exists, but has unexpected contents") - else: - log("📝", f"Creating {LOCAL_SETUP} ...") - LOCAL_SETUP.write_bytes(LOCAL_SETUP_MARKER) + configure = [os.path.relpath(context.checkout / "configure", working_dir)] + configure.extend(context.configure_args) - configure = [os.path.relpath(CHECKOUT / "configure", working_dir)] - if context.args: - configure.extend(context.args) + context.call(configure) - call(configure, context=context) - -@subdir(BUILD_DIR) -def make_build_python(context, working_dir): +@_shared.subdir("build_python_path") +def make_build_python(context, _working_dir): """Make/build the build Python.""" - call(["make", "--jobs", str(cpu_count()), "all"], context=context) + context.call(["make", "--jobs", str(cpu_count()), "all"]) - binary = build_python_path() + binary = context.build_python_interpreter cmd = [ binary, "-c", - "import sys; " - "print(f'{sys.version_info.major}.{sys.version_info.minor}')", + "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')", ] version = subprocess.check_output(cmd, encoding="utf-8").strip() - log("🎉", f"{binary} {version}") - - -def wasi_sdk(context): - """Find the path to the WASI SDK.""" - if wasi_sdk_path := context.wasi_sdk_path: - if not wasi_sdk_path.exists(): - raise ValueError( - "WASI SDK not found at " - f"{os.fsdecode(wasi_sdk_path)!r} (via --wasi-sdk)" - ) - return wasi_sdk_path - - with (HERE / "config.toml").open("rb") as file: - config = tomllib.load(file) - wasi_sdk_version = config["targets"]["wasi-sdk"] - - if wasi_sdk_path_env_var := os.environ.get("WASI_SDK_PATH"): - wasi_sdk_path = pathlib.Path(wasi_sdk_path_env_var) - if not wasi_sdk_path.exists(): - raise ValueError( - f"WASI SDK not found at {os.fsdecode(wasi_sdk_path)!r} " - "(via $WASI_SDK_PATH)" - ) - else: - opt_path = pathlib.Path("/opt") - # WASI SDK versions have a ``.0`` suffix, but it's a constant; the WASI SDK team - # has said they don't plan to ever do a point release and all of their Git tags - # lack the ``.0`` suffix. - # Starting with WASI SDK 23, the tarballs went from containing a directory named - # ``wasi-sdk-{WASI_SDK_VERSION}.0`` to e.g. - # ``wasi-sdk-{WASI_SDK_VERSION}.0-x86_64-linux``. - potential_sdks = [ - path - for path in opt_path.glob(f"wasi-sdk-{wasi_sdk_version}.0*") - if path.is_dir() - ] - if len(potential_sdks) == 1: - wasi_sdk_path = potential_sdks[0] - elif (default_path := opt_path / "wasi-sdk").is_dir(): - wasi_sdk_path = default_path - - # Starting with WASI SDK 25, a VERSION file is included in the root - # of the SDK directory that we can read to warn folks when they are using - # an unsupported version. - if wasi_sdk_path and (version_file := wasi_sdk_path / "VERSION").is_file(): - version_details = version_file.read_text(encoding="utf-8") - found_version = version_details.splitlines()[0] - # Make sure there's a trailing dot to avoid false positives if somehow the - # supported version is a prefix of the found version (e.g. `25` and `2567`). - if not found_version.startswith(f"{wasi_sdk_version}."): - major_version = found_version.partition(".")[0] - log( - "⚠️", - f" Found WASI SDK {major_version}, " - f"but WASI SDK {wasi_sdk_version} is the supported version", - ) - elif not wasi_sdk_path: - raise ValueError( - f"WASI SDK {wasi_sdk_version} not found; " - "download from " - "https://github.com/WebAssembly/wasi-sdk and install in " - f"{os.fsdecode(opt_path)!r} or specify the SDK via " - "$WASI_SDK_PATH or --wasi-sdk" - ) - - # Cache the result. - context.wasi_sdk_path = wasi_sdk_path - return wasi_sdk_path + _shared.log("🎉", f"{binary} {version}") def wasi_sdk_env(context): """Calculate environment variables for building with wasi-sdk.""" - wasi_sdk_path = wasi_sdk(context) + wasi_sdk_path = context.wasi_sdk_path sysroot = wasi_sdk_path / "share" / "wasi-sysroot" env = { "CC": "clang", @@ -300,8 +63,9 @@ def wasi_sdk_env(context): for env_var, binary_name in list(env.items()): env[env_var] = os.fsdecode(wasi_sdk_path / "bin" / binary_name) - if not wasi_sdk_path.name.startswith("wasi-sdk"): - for compiler in ["CC", "CPP", "CXX"]: + for compiler in ["CC", "CPP", "CXX"]: + env[compiler] += f" --target={context.host_triple}" + if not wasi_sdk_path.name.startswith("wasi-sdk"): env[compiler] += f" --sysroot={sysroot}" env["PKG_CONFIG_PATH"] = "" @@ -324,31 +88,18 @@ def wasi_sdk_env(context): return env -def host_triple(context): - """Determine the target triple for the WASI host build.""" - if context.host_triple: - return context.host_triple - - with (HERE / "config.toml").open("rb") as file: - config = tomllib.load(file) - - # Cache the result. - context.host_triple = config["targets"]["host-triple"] - return context.host_triple - - -@subdir(lambda context: CROSS_BUILD_DIR / host_triple(context), clean_ok=True) +@_shared.subdir("wasi_build_path", clean_ok=True) def configure_wasi_python(context, working_dir): """Configure the WASI/host build.""" - config_site = os.fsdecode(HERE / "config.site-wasm32-wasi") + config_site = os.fsdecode(context.here / "config.site-wasm32-wasi") - wasi_build_dir = working_dir.relative_to(CHECKOUT) + wasi_build_dir = working_dir.relative_to(context.checkout) args = { "WASMTIME": "wasmtime", "ARGV0": f"/{wasi_build_dir}/python.wasm", - "CHECKOUT": os.fsdecode(CHECKOUT), - "WASMTIME_CONFIG_PATH": os.fsdecode(HERE / "wasmtime.toml"), + "CHECKOUT": os.fsdecode(context.checkout), + "WASMTIME_CONFIG_PATH": os.fsdecode(context.here / "wasmtime.toml"), } # Check dynamically for wasmtime in case it was specified manually via # `--host-runner`. @@ -361,25 +112,27 @@ def configure_wasi_python(context, working_dir): "https://github.com/bytecodealliance/wasmtime" ) host_runner = context.host_runner.format_map(args) - env_additions = {"CONFIG_SITE": config_site, "HOSTRUNNER": host_runner} - build_python = os.fsdecode(build_python_path()) + env_additions = { + "CONFIG_SITE": config_site, + "HOSTRUNNER": host_runner, + "CFLAGS": f"{os.environ.get('CFLAGS', '')} -DPY_CALL_TRAMPOLINE".strip(), + } + build_python = os.fsdecode(context.build_python_interpreter) # The path to `configure` MUST be relative, else `python.wasm` is unable # to find the stdlib due to Python not recognizing that it's being - # executed from within a checkout. + # executed from within context.checkout. configure = [ - os.path.relpath(CHECKOUT / "configure", working_dir), - f"--host={host_triple(context)}", - f"--build={BUILD_DIR.name}", + os.path.relpath(context.checkout / "configure", working_dir), + f"--host={context.host_triple}", + f"--build={context.build_python_path.name}", f"--with-build-python={build_python}", ] - if build_python_is_pydebug(): + if context.is_debug: configure.append("--with-pydebug") - if context.args: - configure.extend(context.args) - call( + configure.extend(context.configure_args) + context.call( configure, - env=updated_env(env_additions | wasi_sdk_env(context)), - context=context, + env=_shared.updated_env(env_additions | wasi_sdk_env(context)), ) python_wasm = working_dir / "python.wasm" @@ -387,22 +140,23 @@ def configure_wasi_python(context, working_dir): with exec_script.open("w", encoding="utf-8") as file: file.write(f'#!/bin/sh\nexec {host_runner} {python_wasm} "$@"\n') exec_script.chmod(0o755) - log("🏃", f"Created {exec_script} (--host-runner)... ") + _shared.log("🏃", f"Created {exec_script} (--host-runner)... ") sys.stdout.flush() -@subdir(lambda context: CROSS_BUILD_DIR / host_triple(context)) +@_shared.subdir("wasi_build_path") def make_wasi_python(context, working_dir): """Run `make` for the WASI/host build.""" - call( + context.call( ["make", "--jobs", str(cpu_count()), "all"], - env=updated_env(), - context=context, + env=_shared.updated_env(), ) exec_script = working_dir / "python.sh" - call([exec_script, "--version"], quiet=False) - log( + context.call( + [exec_script, "-c", "import sys; print(sys.version)"], quiet=False + ) + _shared.log( "🎉", f"Use `{exec_script.relative_to(pathlib.Path().absolute())}` " "to run CPython w/ the WASI host specified by --host-runner", @@ -411,22 +165,20 @@ def make_wasi_python(context, working_dir): def clean_contents(context): """Delete all files created by this script.""" - if CROSS_BUILD_DIR.exists(): - log("🧹", f"Deleting {CROSS_BUILD_DIR} ...") - shutil.rmtree(CROSS_BUILD_DIR) - - if LOCAL_SETUP.exists(): - if LOCAL_SETUP.read_bytes() == LOCAL_SETUP_MARKER: - log("🧹", f"Deleting generated {LOCAL_SETUP} ...") + context.clean = True + for path in [context.cross_build_path, context.dist_path]: + if path.exists(): + _shared.log("🧹", f"Deleting {path} ...") + shutil.rmtree(path) -@subdir(BUILD_DIR) +@_shared.subdir("build_python_path") def pythoninfo_build_python(context, working_dir): """Display build info of the build Python.""" - call(["make", "pythoninfo"], context=context) + context.call(["make", "pythoninfo"]) -@subdir(lambda context: CROSS_BUILD_DIR / host_triple(context)) +@_shared.subdir("wasi_build_path") def pythoninfo_wasi_python(context, working_dir): """Display build info of the host/WASI Python.""" - call(["make", "pythoninfo"], context=context) + context.call(["make", "pythoninfo"]) diff --git a/Platforms/WASI/_package.py b/Platforms/WASI/_package.py new file mode 100644 index 000000000000000..403247d4734a3d6 --- /dev/null +++ b/Platforms/WASI/_package.py @@ -0,0 +1,402 @@ +__lazy_modules__ = [ + "datetime", + "os", + "pathlib", + "shutil", + "subprocess", + "sys", + "_shared", +] + +import datetime +import os +import pathlib +import shutil +import subprocess +import sys + +import _shared + + +def wasmtime_script(context): + return f"""\ +#!/bin/sh + +set -eu + +script_dir=$(CDPATH= cd "$(dirname "$0")" && pwd -P) +root=$(CDPATH= cd "$script_dir/.." && pwd -P) +wasm_file="$root/lib/python{context.python_version()}/lib-wasm/python{context.python_version(debug_ok=True)}.wasm" + +exec wasmtime run \\ + --argv0 "$wasm_file" \\ + --config "$root/etc/python{context.python_version()}/wasmtime.toml" \\ + --dir "/" \\ + "$wasm_file" "$@" +""" + + +def lib_python(context): + return pathlib.PurePath("lib") / f"python{context.python_version()}" + + +def license_file(context): + """Have /LICENSE end up as lib/pythonXY/LICENSE.txt.""" + return (lib_python(context) / "LICENSE.txt", context.checkout / "LICENSE") + + +def build_dir_files(context): + """Have build/lib.* files end up in lib/pythonXY. + + Symlinks are skipped as those files are covered by handling + /Modules. + """ + return [ + (lib_python(context) / path.name, path) + for path in context.wasi_pybuilddir.iterdir() + if path.is_file(follow_symlinks=False) + ] + + +def stdlib_files(context): + """Have /Lib files end up in lib/pythonXY.""" + lib_dir = context.checkout / "Lib" + lib_files = [] + for root, dirs, files in lib_dir.walk(): + try: + dirs.remove("__pycache__") + except ValueError: + pass + + for file in files: + file_path = pathlib.Path(root) / file + details = ( + lib_python(context) / file_path.relative_to(lib_dir), + file_path, + ) + lib_files.append(details) + return lib_files + + +def pkgconfig_files(context): + """Have /Misc/python*.pc end up in lib/pkgconfig. + + Each file ends up being listed under `python3` and `python-3.N`. + """ + misc_dir = context.wasi_build_path / "Misc" + pkgconfig = pathlib.PurePath("lib") / "pkgconfig" + return [ + ( + pkgconfig / f"python-{context.python_version(debug_ok=True)}.pc", + misc_dir / "python.pc", + ), + ( + pkgconfig + / f"python-{context.python_version(debug_ok=True)}-embed.pc", + misc_dir / "python-embed.pc", + ), + ] + + +def pkgconfig_symlinks(pkgconfig_files, context): + assert len(pkgconfig_files) == 2 + embed, plain = ( + (0, 1) if pkgconfig_files[0].name.endswith("-embed.pc") else (1, 0) + ) + embed_path, plain_path = pkgconfig_files[embed], pkgconfig_files[plain] + major = context.wasi_build_details["language"]["version_info"]["major"] + paths = [ + (embed_path.parent / f"python{major}-embed.pc", embed_path), + (plain_path.parent / f"python{major}.pc", plain_path), + ] + if context.is_debug: + paths += [ + ( + embed_path.parent + / f"python-{context.python_version()}-embed.pc", + embed_path, + ), + ( + plain_path.parent / f"python-{context.python_version()}.pc", + plain_path, + ), + ] + + return paths + + +def pyconfig_file(context): + """Have /pyconfig.h end up in include/pythonXYd?/pyconfig.h.""" + return ( + pathlib.PurePath("include") + / f"python{context.python_version(debug_ok=True)}" + / "pyconfig.h", + context.wasi_build_path / "pyconfig.h", + ) + + +def header_files(context): + """Have /Include/*.h end up in include/pythonXYd?/.""" + include_dir = context.checkout / "Include" + files = [] + for root, dirs, filenames in include_dir.walk(): + for filename in filenames: + file_path = pathlib.Path(root) / filename + details = ( + pathlib.PurePath("include") + / f"python{context.python_version(debug_ok=True)}" + / file_path.relative_to(include_dir), + file_path, + ) + files.append(details) + return files + + +def man_file(context): + """Have Misc/python.man end up in share/man/man1/.""" + man_dir = pathlib.PurePath("share", "man", "man1") + man_file = context.checkout / "Misc" / "python.man" + return ( + man_dir / f"python{context.python_version()}.1", + man_file, + ) + + +def man_symlink(man_path, context): + """Symlink pythonN.M.1 to pythonN.1.""" + major = context.wasi_build_details["language"]["version_info"]["major"] + return (man_path.parent / f"python{major}.1", man_path) + + +def wasmtime_config_file(context): + """Have wasmtime.toml end up in etc/pythonXY/.""" + config = context.checkout / "Platforms" / "WASI" / "wasmtime.toml" + return ( + pathlib.PurePath("etc") + / f"python{context.python_version()}" + / "wasmtime.toml", + config, + ) + + +def wasm_file(context): + """Have python.wasm end up at lib/pythonXY/lib-wasm/pythonX.Yd?.wasm.""" + return ( + lib_python(context) + / "lib-wasm" + / f"python{context.python_version(debug_ok=True)}.wasm", + context.wasi_build_path / "python.wasm", + ) + + +def python_wasmtime_script(context): + """Create bin/pythonN.Md?.wasmtime.""" + script = wasmtime_script(context) + path = context.dist_python_interpreter + path.parent.mkdir(parents=True, exist_ok=True) + with open(path, "w") as f: + f.write(script) + path.chmod(0o755) + + return path + + +def python_wasmtime_symlink(path, context): + """Symlink bin/pythonN.Md?.wasmtime. + + - bin/pythonN.M.wasmtime (if debug build) + - bin/pythonN.wasmtime + """ + symlinks = [ + path.parent / f"python{context.wasi_build_version['major']}.wasmtime" + ] + if context.is_debug: + # The file already has the debug name, so the missing symlink is the non-debug name. + symlinks.append( + path.parent / f"python{context.python_version()}.wasmtime" + ) + + return [(symlink, path) for symlink in symlinks] + + +def config_file(context): + """Have Misc/config.sh end up at bin/pythonN.Md?.config.""" + return ( + pathlib.PurePath("bin") + / f"python{context.python_version(debug_ok=True)}-config", + context.wasi_build_path / "Misc" / "python-config.sh", + ) + + +def config_symlink(config_path, context): + """Symlink bin/pythonN.Md?-config. + + - bin/pythonN.M-config (if debug build) + - bin/pythonNd?-config + - bin/pythonN-config (if debug build) + """ + symlinks = [ + config_path.parent + / f"python{context.wasi_build_version['major']}-config" + ] + if context.is_debug: + # The file already has the debug name, so the missing symlink is the non-debug name. + symlinks.append( + config_path.parent / f"python{context.python_version()}-config" + ) + + return [(symlink, config_path) for symlink in symlinks] + + +def copy_files(files, base): + for dest, src in files: + target = base / dest + target.parent.mkdir(parents=True, exist_ok=True) + src.copy(target) + + +def symlink_files(files, base): + for target, source in files: + target_path = base / target + source_path = base / source + target_path.symlink_to( + os.path.relpath(source_path, start=target_path.parent) + ) + + +def gather(context): + py_version = context.python_version() + py_d_version = context.python_version(debug_ok=True) + + dist = context.dist_path + if dist.exists(): + _shared.log("🧹", f"Deleting {dist} ...") + shutil.rmtree(dist) + + indent = " " + base = context.archive_dir + _shared.log("📝", f"Copying files to {base} ...") + + _shared.log("📁", "bin/", spacing=indent * 2) + _shared.log("📄", f"python{py_d_version}-config", spacing=indent * 3) + config_location = config_file(context) + copy_files([config_location], base) + symlink_files(config_symlink(config_location[0], context), base) + + _shared.log("📄", f"python{py_d_version}.wasmtime", spacing=indent * 3) + script_path = python_wasmtime_script(context) + symlink_files(python_wasmtime_symlink(script_path, context), base) + + _shared.log("📁", "etc/", spacing=indent * 2) + _shared.log("📁", f"python{py_version}/", spacing=indent * 3) + _shared.log("📄", "wasmtime.toml", spacing=indent * 4) + copy_files([wasmtime_config_file(context)], base) + + _shared.log("📁", "include/", spacing=indent * 2) + _shared.log("📁", f"python{py_version}/", spacing=indent * 3) + _shared.log("📄", "pyconfig.h", spacing=indent * 4) + copy_files([pyconfig_file(context)], base) + _shared.log("📄", "**/*.h", spacing=indent * 4) + copy_files(header_files(context), base) + + _shared.log("📁", "lib/", spacing=indent * 2) + _shared.log("📁", f"python{py_version}/", spacing=indent * 3) + _shared.log("📁", "lib-dynload/", spacing=indent * 4) + (base / lib_python(context) / "lib-dynload").mkdir( + parents=True, exist_ok=True + ) + _shared.log("📄", "", spacing=indent * 5) + + _shared.log("📁", "lib-wasm/", spacing=indent * 4) + _shared.log("📄", f"python{py_d_version}.wasm", spacing=indent * 5) + copy_files([wasm_file(context)], base) + _shared.log("📄", "LICENSE.txt", spacing=indent * 4) + copy_files([license_file(context)], base) + _shared.log("📄", "files in `cat pybuilddir.txt`", spacing=indent * 4) + copy_files(build_dir_files(context), base) + _shared.log("📄", "**/*.py", spacing=indent * 4) + copy_files(stdlib_files(context), base) + + _shared.log("📁", "pkgconfig/", spacing=indent * 3) + _shared.log("📄", "python*.pc", spacing=indent * 4) + pkgconfig_paths = pkgconfig_files(context) + copy_files(pkgconfig_paths, base) + symlink_files( + pkgconfig_symlinks([path for path, _ in pkgconfig_paths], context), + base, + ) + _shared.log("📁", "share/", spacing=indent * 2) + _shared.log("📁", "man/", spacing=indent * 3) + _shared.log("📁", "man1/", spacing=indent * 4) + _shared.log("📄", "python*.1", spacing=indent * 5) + man_path = man_file(context) + copy_files([man_path], base) + symlink_files([man_symlink(man_path[0], context)], base) + + return base + + +def archive(context): + file_path = context.archive_path + if file_path.exists(): + _shared.log("🧹", f"Deleting {file_path} ...") + file_path.unlink() + to_compress = context.archive_dir + _shared.log("🗜️", f"Archiving to {file_path} ...") + mtime_format = "%Y-%m-%dT%H:%M:%SZ" + if source_date_epoch := os.environ.get("SOURCE_DATE_EPOCH"): + mtime = datetime.datetime.fromtimestamp( + int(source_date_epoch), datetime.UTC + ).strftime(mtime_format) + else: + try: + mtime = subprocess.run( + [ + "git", + "log", + "-1", + "--format=tformat:%cd", + f"--date=format:{mtime_format}", + os.fsdecode(context.checkout), + ], + env={"TZ": "UTC0"}, + capture_output=True, + text=True, + check=True, + ).stdout.strip() + except subprocess.CalledProcessError as error: + print(error.output) + sys.exit(error.returncode) + + try: + subprocess.run( + [ + "tar", + "-c", + "-f", + os.fsdecode(file_path), + "--sort=name", + "--mtime", + mtime, + "--clamp-mtime", + "--owner=0", + "--group=0", + "--numeric-owner", + "--format=pax", + "--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime", + "--mode=go+u,go-w", + # Explicitly using `-T` because if you don't compress with threads you can't + # uncompress with them and the size difference is negligible when using + # single-threaded compression. + "--use-compress-program", + "xz -T 0", + to_compress.name, + ], + cwd=to_compress.parent, + capture_output=True, + text=True, + check=True, + ) + except subprocess.CalledProcessError as error: + print(error.output) + sys.exit(error.returncode) diff --git a/Platforms/WASI/_shared.py b/Platforms/WASI/_shared.py new file mode 100644 index 000000000000000..8e5f13d03adc57a --- /dev/null +++ b/Platforms/WASI/_shared.py @@ -0,0 +1,364 @@ +__lazy_modules__ = [ + "contextlib", + "functools", + "json", + "os", + "pathlib", + "shutil", + "subprocess", + "sys", + "sysconfig", + "tempfile", + "tomllib", +] + +import contextlib +import functools +import json +import os +import pathlib +import shutil +import subprocess +import sys +import sysconfig +import tempfile +import tomllib + + +class Context: + clean = False + + def __init__(self): + self.here = pathlib.Path(__file__).parent + self.orig_cwd = pathlib.Path.cwd() + + @functools.cached_property + def checkout(self): + checkout = self.here + while checkout != checkout.parent: + if (checkout / "configure").is_file(): + return checkout + checkout = checkout.parent + raise FileNotFoundError( + "Unable to find the root of the CPython checkout by looking for 'configure'" + ) + + def _pybuilddir(self, build_path): + relative_dir = (build_path / "pybuilddir.txt").read_text().strip() + return build_path / relative_dir + + @functools.cached_property + def host_triple(self): + if self._host_triple: + return self._host_triple + + with (self.here / "config.toml").open("rb") as file: + config = tomllib.load(file) + + return config["targets"]["host-triple"] + + @functools.cached_property + def cross_build_path(self): + return self.checkout / "cross-build" + + @functools.cached_property + def build_python_path(self): + # Build platform can also be found via `config.guess`. + return self.cross_build_path / sysconfig.get_config_var( + "BUILD_GNU_TYPE" + ) + + @functools.cached_property + def build_python_interpreter(self): + binary = self.build_python_path / "python" + if not binary.is_file(): + binary = binary.with_suffix(".exe") + if not binary.is_file(): + raise FileNotFoundError( + f"Unable to find `python(.exe)` in {self.build_python_path}" + ) + + return binary + + @functools.cached_property + def is_debug(self): + pybuilddir = self._pybuilddir(self.build_python_path) + if pybuilddir.exists(): + build_details_path = pybuilddir / "build-details.json" + build_details = json.loads(build_details_path.read_text()) + return "d" in build_details["abi"]["flags"] + else: + # Python 3.13 and older. + test = "import sys, test.support; sys.exit(test.support.Py_DEBUG)" + result = subprocess.run( + [self.build_python_interpreter, "-c", test], + capture_output=True, + ) + return bool(result.returncode) + + @functools.cached_property + def wasi_build_path(self): + return self.cross_build_path / self.host_triple + + @functools.cached_property + def wasi_pybuilddir(self): + return self._pybuilddir(self.wasi_build_path) + + @functools.cached_property + def wasi_build_details(self): + with (self.wasi_pybuilddir / "build-details.json").open() as f: + return json.load(f) + + @functools.cached_property + def wasi_build_version(self): + return self.wasi_build_details["language"]["version_info"] + + @functools.cached_property + def wasi_sdk_path(self): + if wasi_sdk_path := self._wasi_sdk_path: + if not wasi_sdk_path.exists(): + raise ValueError( + "WASI SDK not found; " + "download from " + "https://github.com/WebAssembly/wasi-sdk and/or " + "specify via $WASI_SDK_PATH or --wasi-sdk" + ) + return wasi_sdk_path + + with (self.here / "config.toml").open("rb") as file: + config = tomllib.load(file) + wasi_sdk_version = config["targets"]["wasi-sdk"] + + if wasi_sdk_path_env_var := os.environ.get("WASI_SDK_PATH"): + wasi_sdk_path = pathlib.Path(wasi_sdk_path_env_var) + if not wasi_sdk_path.exists(): + raise ValueError( + f"WASI SDK not found at $WASI_SDK_PATH ({wasi_sdk_path})" + ) + else: + opt_path = pathlib.Path("/opt") + # WASI SDK versions have a ``.0`` suffix, but it's a constant; the WASI SDK team + # has said they don't plan to ever do a point release and all of their Git tags + # lack the ``.0`` suffix. + # Starting with WASI SDK 23, the tarballs went from containing a directory named + # ``wasi-sdk-{WASI_SDK_VERSION}.0`` to e.g. + # ``wasi-sdk-{WASI_SDK_VERSION}.0-x86_64-linux``. + potential_sdks = [ + path + for path in opt_path.glob(f"wasi-sdk-{wasi_sdk_version}.0*") + if path.is_dir() + ] + if not potential_sdks: + raise ValueError( + f"WASI SDK {wasi_sdk_version} not found in {opt_path}" + ) + elif len(potential_sdks) == 1: + wasi_sdk_path = potential_sdks[0] + elif (default_path := opt_path / "wasi-sdk").is_dir(): + wasi_sdk_path = default_path + elif potential_sdks: + raise ValueError( + f"Multiple WASI SDKs found in {opt_path} w/o knowing which to use" + ) + else: + raise ValueError(f"WASI SDK not found in {opt_path}") + + # Starting with WASI SDK 25, a VERSION file is included in the root + # of the SDK directory that we can read to warn folks when they are using + # an unsupported version. + if ( + wasi_sdk_path + and (version_file := wasi_sdk_path / "VERSION").is_file() + ): + version_details = version_file.read_text(encoding="utf-8") + found_version = version_details.splitlines()[0] + # Make sure there's a trailing dot to avoid false positives if somehow the + # supported version is a prefix of the found version (e.g. `25` and `2567`). + if not found_version.startswith(f"{wasi_sdk_version}."): + major_version = found_version.partition(".")[0] + log( + "⚠️", + f" Found WASI SDK {major_version}, " + f"but WASI SDK {wasi_sdk_version} is the supported version", + ) + + return wasi_sdk_path + + @functools.cached_property + def configure_args(self): + args = getattr(self, "_args", []) + if self.release: + args.extend(["--without-static-libpython"]) + return args + + @functools.cached_property + def log_path(self): + if self._log_path is not None: + if not (path := self._log_path).is_absolute(): + path = (self.orig_cwd / self._log_path).resolve() + return path + + return pathlib.Path(tempfile.gettempdir()) + + @functools.cached_property + def dist_path(self): + return self.checkout / "dist" + + @functools.cached_property + def archive_stem(self): + version_info = self.wasi_build_details["language"]["version_info"] + version = f"python-{version_info['major']}.{version_info['minor']}.{version_info['micro']}" + if version_info["releaselevel"] != "final": + version += version_info["releaselevel"][0] + str( + version_info["serial"] + ) + + return f"{version}-{self.host_triple}" + + @functools.cached_property + def archive_dir(self): + return self.dist_path / self.archive_stem + + @functools.cached_property + def archive_path(self): + return self.dist_path / f"{self.archive_stem}.tar.xz" + + @functools.cached_property + def dist_python_interpreter(self): + version = self.python_version(debug_ok=True) + return self.archive_dir / "bin" / f"python{version}.wasmtime" + + def python_version(self, debug_ok=False): + """Calculate the M.N part of Python's version. + + If *debug_ok* is True, then "d" is appended as appropriate. + """ + major = self.wasi_build_version["major"] + minor = self.wasi_build_version["minor"] + version = f"{major}.{minor}" + if debug_ok and "d" in self.wasi_build_details["abi"]["flags"]: + version += "d" + return version + + def call(self, command, *, env=None, quiet=None, **kwargs): + """Execute a command. + + Print changes to the execution environment if 'env' is provided. + If 'quiet' is None, use the context's setting. If true, redirect + stdout and stderr to a temporary file. + """ + if quiet is None: + quiet = self.quiet + + if env is not None: + env_diff = {} + for key, value in env.items(): + if os.environ.get(key) != value: + env_diff[key] = value + + env_vars = [ + f"\n {key}={item}" + for key, item in sorted(env_diff.items()) + ] + log("🌎", f"Environment changes:{''.join(env_vars)}") + + log("❯", " ".join(map(str, command)), spacing=" ") + if not quiet: + stdout = None + stderr = None + else: + log_path = self.log_path + log_path.mkdir(parents=True, exist_ok=True) + stdout = tempfile.NamedTemporaryFile( + "w", + encoding="utf-8", + delete=False, + dir=log_path, + prefix="cpython-wasi-", + suffix=".log", + ) + stderr = subprocess.STDOUT + log("📝", f"Logging output to {stdout.name} (--quiet)...") + + try: + subprocess.check_call( + command, **kwargs, env=env, stdout=stdout, stderr=stderr + ) + except subprocess.CalledProcessError as error: + if quiet: + log("❌", f"Exit code {error.returncode}") + separator() + with open(stdout.name, encoding="utf-8") as file: + lines = file.readlines() + # Inefficient, but the log shouldn't be dramatically large. + print("".join(lines[-10:]), end="") + if not lines[-1].endswith("\n"): + print() + sys.exit(error.returncode) + + +def log(emoji, message, *, spacing=None): + """Print a notification with an emoji. + + If 'spacing' is None, calculate the spacing based on the number of code points + in the emoji as terminals "eat" a space when the emoji has multiple code points. + """ + if spacing is None: + spacing = " " if len(emoji) == 1 else " " + print("".join([emoji, spacing, message])) + + +def separator(): + """Print a separator line across the terminal width.""" + try: + tput_output = subprocess.check_output( + ["tput", "cols"], encoding="utf-8" + ) + except subprocess.CalledProcessError: + terminal_width = 80 + else: + terminal_width = int(tput_output.strip()) + print("⎯" * terminal_width) + + +def updated_env(updates={}): + """Create a new dict representing the environment to use.""" + env_defaults = {} + # https://reproducible-builds.org/docs/source-date-epoch/ + git_epoch_cmd = ["git", "log", "-1", "--pretty=%ct"] + try: + epoch = subprocess.check_output( + git_epoch_cmd, encoding="utf-8" + ).strip() + env_defaults["SOURCE_DATE_EPOCH"] = epoch + except subprocess.CalledProcessError: + pass # Might be building from a tarball. + # This layering lets SOURCE_DATE_EPOCH from os.environ takes precedence. + environment = env_defaults | os.environ | updates + + return environment + + +def subdir(context_attr, *, clean_ok=False): + """Decorator to change to a working directory.""" + + def decorator(func): + @functools.wraps(func) + def wrapper(context): + nonlocal context_attr + + working_dir = getattr(context, context_attr) + separator() + log("📁", os.fsdecode(working_dir)) + if clean_ok and context.clean and working_dir.exists(): + log("🚮", "Deleting directory (--clean)...") + shutil.rmtree(working_dir) + + working_dir.mkdir(parents=True, exist_ok=True) + + with contextlib.chdir(working_dir): + return func(context, working_dir) + + return wrapper + + return decorator diff --git a/Platforms/WASI/_test.py b/Platforms/WASI/_test.py new file mode 100644 index 000000000000000..a44838659c70111 --- /dev/null +++ b/Platforms/WASI/_test.py @@ -0,0 +1,73 @@ +__lazy_modules__ = [ + "shlex", + "shutil", + "_shared", +] + +import shlex +import shutil + +import _shared + + +def dist_test_args(context): + runner = context.dist_python_interpreter + if not runner.is_file(): + raise FileNotFoundError( + f"Packaged WASI interpreter not found at {runner}; " + "run `gather`, `package`, or `release` first" + ) + + test_opts = shlex.join(["--python", shlex.quote(str(runner))]) + return [ + "TESTPYTHON=$(RUNSHARED) $(PYTHON_FOR_FREEZE) $(TESTPYTHONOPTS)", + f"TESTOPTS=$(EXTRATESTOPTS) {test_opts}", + ] + + +@_shared.subdir("wasi_build_path") +def test(context, _working_dir): + match context.ci_mode: + case "fast": + make_target = "test" + case "slow": + make_target = "buildbottest" + case _: + raise ValueError(f"Unknown CI mode {context.ci_mode}") + command = ["make", make_target] + match context.target: + case "archive": + archive = context.archive_path + if not archive.is_file(): + raise FileNotFoundError( + f"Release archive not found at {archive}; " + "run `package` or `release` first" + ) + if context.archive_dir.exists(): + _shared.log("🧹", f"Deleting {context.archive_dir} ...") + shutil.rmtree(context.archive_dir) + context.call( + [ + "tar", + "--extract", + "--file", + archive, + "--directory", + context.dist_path, + "--", + context.archive_dir.name, + ], + ) + command.extend(dist_test_args(context)) + case "dist": + if not context.dist_python_interpreter.is_file(): + raise FileNotFoundError( + f"Python not found at {context.dist_python_interpreter}" + ) + command.extend(dist_test_args(context)) + case "build": + pass + case _: + raise ValueError(f"Unknown target {context.target}") + + context.call(command, env=_shared.updated_env()) diff --git a/Platforms/WASI/config.site-wasm32-wasi b/Platforms/WASI/config.site-wasm32-wasi index c5d8b3e205db26f..88c54907880e73b 100644 --- a/Platforms/WASI/config.site-wasm32-wasi +++ b/Platforms/WASI/config.site-wasm32-wasi @@ -57,3 +57,7 @@ ac_cv_func_fchmod=no ac_cv_func_fchmodat=no ac_cv_func_statvfs=no ac_cv_func_fstatvfs=no + +# WASI SDK 34 declares some things that simply error out. +ac_cv_func_pipe2=no +ac_cv_func_pthread_getcpuclockid=no diff --git a/Platforms/WASI/config.toml b/Platforms/WASI/config.toml index 6a6d5713ee96739..3a9dcae6852814b 100644 --- a/Platforms/WASI/config.toml +++ b/Platforms/WASI/config.toml @@ -2,5 +2,5 @@ # This allows for blanket copying of the WASI build code between supported # Python versions. [targets] -wasi-sdk = 33 -host-triple = "wasm32-wasip1" +wasi-sdk = 34 +host-triple = "wasm32-wasip3" diff --git a/Platforms/emscripten/README.md b/Platforms/emscripten/README.md index ce230c4b74a2738..b1fccea0af9f87b 100644 --- a/Platforms/emscripten/README.md +++ b/Platforms/emscripten/README.md @@ -138,7 +138,7 @@ await createEmscriptenModule({ - Threading is disabled by default. The ``configure`` option ``--enable-wasm-pthreads`` adds compiler flag ``-pthread`` and - linker flags ``-sUSE_PTHREADS -sPROXY_TO_PTHREAD``. + linker flags ``-pthread -sPROXY_TO_PTHREAD``. - pthread support requires WASM threads and SharedArrayBuffer (bulk memory). The Node.JS runtime keeps a pool of web workers around. Each web worker uses several file descriptors (eventfd, epoll, pipe). diff --git a/Platforms/emscripten/__main__.py b/Platforms/emscripten/__main__.py index 84a1589b81f6a20..d28d93ce3bada99 100644 --- a/Platforms/emscripten/__main__.py +++ b/Platforms/emscripten/__main__.py @@ -812,12 +812,12 @@ def main(): subcommand.add_argument( "--emsdk-cache", action="store", - default=os.environ.get("EMSDK_CACHE"), + default=os.environ.get("PY_EMSDK_CACHE"), dest="emsdk_cache", help=( "Path to emsdk cache directory. If provided, validates that " "the required emscripten version is installed. " - "Can also be set with the EMSDK_CACHE environment variable." + "Can also be set with the PY_EMSDK_CACHE environment variable." ), ) diff --git a/Platforms/emscripten/browser_test/package-lock.json b/Platforms/emscripten/browser_test/package-lock.json index 67acfba9daf62ea..2ae84ddf800008d 100644 --- a/Platforms/emscripten/browser_test/package-lock.json +++ b/Platforms/emscripten/browser_test/package-lock.json @@ -9,8 +9,8 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@playwright/test": "^1.61.1", - "@types/node": "^24.12.0", + "@playwright/test": "^1.63.0", + "@types/node": "^26.6.3", "get-port-cli": "^3.0.0", "http-server": "^14.1.1", "playwright": "^1.61.1" @@ -40,18 +40,18 @@ } }, "node_modules/@playwright/test": { - "version": "1.61.1", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.61.1.tgz", - "integrity": "sha512-8nKv6+0RJSL9FE4jYOEGXnPeM/Hg12qZpmqzZjRh3qM0Y7c3z1mrOTfFLids72RDQYVh9WpLEfR5WdpNX4fkig==", + "version": "1.63.0", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.63.0.tgz", + "integrity": "sha512-oxMK4vllB9RK5NQ2l1pq1IfOf2AvnEuj/vYGDj0H2nMtmtZpKtCwt/l00GEO6xjGfpBNAvjovvYdCm50dRQkpQ==", "license": "Apache-2.0", "dependencies": { - "playwright": "1.61.1" + "playwright": "1.63.0" }, "bin": { "playwright": "cli.js" }, "engines": { - "node": ">=18" + "node": ">=20" } }, "node_modules/@types/minimist": { @@ -61,12 +61,12 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "24.12.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.12.0.tgz", - "integrity": "sha512-GYDxsZi3ChgmckRT9HPU0WEhKLP08ev/Yfcq2AstjrDASOYCSXeyjDsHg4v5t4jOj7cyDX3vmprafKlWIG9MXQ==", + "version": "26.6.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.3.tgz", + "integrity": "sha512-dsqMQQoeTLqu9wynDD00q573mNzso3IdQOAfHRJqLCcmCFPoGo9A1bDpUcv/9tnKpErQWv9uKeGfl37EIS02Yg==", "license": "MIT", "dependencies": { - "undici-types": "~7.16.0" + "undici-types": "~8.9.0" } }, "node_modules/@types/normalize-package-data": { @@ -358,9 +358,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", - "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", + "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", "funding": [ { "type": "individual", @@ -377,20 +377,6 @@ } } }, - "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -892,33 +878,30 @@ "license": "ISC" }, "node_modules/playwright": { - "version": "1.61.1", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.61.1.tgz", - "integrity": "sha512-DWnY5o3YbLWK4GovuAVwpqL+1VwGNdUGrRr++8j8PtQQzvAVZUIMjKQ90fY689sEJZJBbZVw1rXaOKSTitkzPQ==", + "version": "1.63.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.63.0.tgz", + "integrity": "sha512-+7ziBLidS4NaNCdt57SUDT+wYmmd5fmiQejUic/kb+YsYSCPyOOE9sebzMjNmQrsnNpDJqd4WHvV/8lfKfUDUg==", "license": "Apache-2.0", "dependencies": { - "playwright-core": "1.61.1" + "playwright-core": "1.63.0" }, "bin": { "playwright": "cli.js" }, "engines": { - "node": ">=18" - }, - "optionalDependencies": { - "fsevents": "2.3.2" + "node": ">=20" } }, "node_modules/playwright-core": { - "version": "1.61.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.61.1.tgz", - "integrity": "sha512-h7Qlt6m4REp25qvIdvbDtVmD4LqVXfpRxhORv9L0jzETM05p4fuPJ3dKyuSXQxDSbXnmS79HAgi9589lGSpLkg==", + "version": "1.63.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.63.0.tgz", + "integrity": "sha512-rYCsBF/M5HjUch52bbtVONEFjv6Xu8sm8h72dNlR5bzIE1fvC/bxgspzkjSfU+MweEMmPM8KJebG6nnyxo5mCg==", "license": "Apache-2.0", "bin": { "playwright-core": "cli.js" }, "engines": { - "node": ">=18" + "node": ">=20" } }, "node_modules/portfinder": { @@ -1201,9 +1184,9 @@ } }, "node_modules/undici-types": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", - "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz", + "integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==", "license": "MIT" }, "node_modules/union": { diff --git a/Platforms/emscripten/browser_test/package.json b/Platforms/emscripten/browser_test/package.json index fc8e1ce33975ef6..b62b4c657a706dd 100644 --- a/Platforms/emscripten/browser_test/package.json +++ b/Platforms/emscripten/browser_test/package.json @@ -10,8 +10,8 @@ "license": "ISC", "description": "", "dependencies": { - "@playwright/test": "^1.61.1", - "@types/node": "^24.12.0", + "@playwright/test": "^1.63.0", + "@types/node": "^26.6.3", "get-port-cli": "^3.0.0", "http-server": "^14.1.1", "playwright": "^1.61.1" diff --git a/Platforms/emscripten/config.site-wasm32-emscripten b/Platforms/emscripten/config.site-wasm32-emscripten index f69dbb8e779a426..62640cc772d7e9b 100644 --- a/Platforms/emscripten/config.site-wasm32-emscripten +++ b/Platforms/emscripten/config.site-wasm32-emscripten @@ -19,10 +19,6 @@ ac_cv_func_posix_spawn=no ac_cv_func_posix_spawnp=no ac_cv_func_eventfd=no ac_cv_func_memfd_create=no -ac_cv_func_prlimit=no - -# unsupported syscall, https://github.com/emscripten-core/emscripten/issues/13393 -ac_cv_func_shutdown=no # The rest is based on pyodide # https://github.com/pyodide/pyodide/blob/main/cpython/pyconfig.undefs.h @@ -48,8 +44,6 @@ ac_cv_func_seteuid=no ac_cv_func_setegid=no ac_cv_func_getresuid=no ac_cv_func_getresgid=no -ac_cv_func_setresuid=no -ac_cv_func_setresgid=no # Syscalls not implemented in emscripten # [Errno 52] Function not implemented @@ -92,7 +86,7 @@ ac_cv_func_setresuid=no ac_cv_func_setresgid=no # Emscripten does not support hard links, always fails with errno 34 -# "Too many links". See emscripten_syscall_stubs.c +# "Too many links". ac_cv_func_link=no ac_cv_func_linkat=no diff --git a/Platforms/emscripten/config.toml b/Platforms/emscripten/config.toml index 0c65a6623c9798a..920169be2dba0c3 100644 --- a/Platforms/emscripten/config.toml +++ b/Platforms/emscripten/config.toml @@ -1,7 +1,7 @@ # Any data that can vary between Python versions is to be kept in this file. # This allows for blanket copying of the Emscripten build code between supported # Python versions. -emscripten-version = "6.0.2" +emscripten-version = "7.0.1" node-version = "24" test-args = [ "-m", "test", @@ -17,8 +17,8 @@ pythoninfo-args = [ [dependencies.libffi] url = "https://github.com/libffi/libffi/releases/download/v{version}/libffi-{version}.tar.gz" -version = "3.4.6" -shasum = "b0dea9df23c863a7a50e825440f3ebffabd65df1497108e5d437747843895a4e" +version = "3.8.1" +shasum = "81e879c094cc5ec3186c48510c6385ac6b3e866192e8bc71a35245703757ee40" [dependencies.mpdec] url = "https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-{version}.tar.gz" diff --git a/Platforms/emscripten/make_libffi.sh b/Platforms/emscripten/make_libffi.sh index 3c75c4d51271025..c05e7c92904a811 100755 --- a/Platforms/emscripten/make_libffi.sh +++ b/Platforms/emscripten/make_libffi.sh @@ -1,7 +1,7 @@ #!/bin/bash set +e -export CFLAGS="-O2 -fPIC -DWASM_BIGINT" +export CFLAGS="-O2 -fPIC" export CXXFLAGS="$CFLAGS" # Build paths diff --git a/Platforms/emscripten/node_entry.mjs b/Platforms/emscripten/node_entry.mjs index 110aadc5de10143..a8faccbdd29ca30 100644 --- a/Platforms/emscripten/node_entry.mjs +++ b/Platforms/emscripten/node_entry.mjs @@ -22,7 +22,7 @@ function rootDirsToMount(Module) { function mountDirectories(Module) { for (const dir of rootDirsToMount(Module)) { Module.FS.mkdirTree(dir); - Module.FS.mount(Module.FS.filesystems.NODEFS, { root: dir }, dir); + Module.FS.mount(Module.NODEFS, { root: dir }, dir); } } @@ -57,6 +57,11 @@ try { // Show JavaScript exception and traceback console.warn(e); // Show Python exception and traceback - Module.PyUnstable_DumpTraceback(2, Module._PyGILState_GetThisThreadState()); + try { + Module.PyUnstable_DumpTraceback?.(2, Module._PyGILState_GetThisThreadState()); + } catch(e) { + console.warn("Error occurred while attempting to format a Python traceback:"); + console.warn(e); + } process.exit(1); } diff --git a/Platforms/emscripten/prepare_external_wasm.py b/Platforms/emscripten/prepare_external_wasm.py deleted file mode 100644 index 1b0a9de4b1fe8d8..000000000000000 --- a/Platforms/emscripten/prepare_external_wasm.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import sys -from pathlib import Path - -JS_TEMPLATE = """ -#include "emscripten.h" - -EM_JS(void, {function_name}, (void), {{ - return new WebAssembly.Module(hexStringToUTF8Array("{hex_string}")); -}} -function hexStringToUTF8Array(hex) {{ - const bytes = []; - for (let i = 0; i < hex.length; i += 2) {{ - bytes.push(parseInt(hex.substr(i, 2), 16)); - }} - return new Uint8Array(bytes); -}}); -""" - - -def prepare_wasm(input_file, output_file, function_name): - # Read the compiled WASM as binary and convert to hex - wasm_bytes = Path(input_file).read_bytes() - - hex_string = "".join(f"{byte:02x}" for byte in wasm_bytes) - - # Generate JavaScript module - js_content = JS_TEMPLATE.format( - function_name=function_name, hex_string=hex_string - ) - Path(output_file).write_text(js_content) - - print(f"Successfully compiled {input_file} and generated {output_file}") - return 0 - - -def main(): - parser = argparse.ArgumentParser( - description="Compile WebAssembly text files using wasm-as" - ) - parser.add_argument("input_file", help="Input .wat file to compile") - parser.add_argument("output_file", help="Output file name") - parser.add_argument("function_name", help="Name of the export function") - - args = parser.parse_args() - - return prepare_wasm(args.input_file, args.output_file, args.function_name) - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/Platforms/emscripten/web_embed_test/main.c b/Platforms/emscripten/web_embed_test/main.c new file mode 100644 index 000000000000000..462024d86cb75df --- /dev/null +++ b/Platforms/emscripten/web_embed_test/main.c @@ -0,0 +1,50 @@ +/* Smoke test for libpython linked into a program whose main() is not Python's. */ + +#include +#include + +// Imports come from the preloaded zip, len() goes through the call trampoline +// and poll() through the syscall overrides. +static const char *SCRIPT = + "import json, select\n" + "select.poll().poll(0)\n" + "print(json.dumps({'embedded': len('ok')}))\n"; + +int main(void) +{ + PyStatus status; + PyConfig config; + + PyConfig_InitIsolatedConfig(&config); + config.write_bytecode = 0; + config.module_search_paths_set = 1; + status = PyWideStringList_Append(&config.module_search_paths, + L"/lib/stdlib.zip"); + if (PyStatus_Exception(status)) { + goto exception; + } + status = PyConfig_SetBytesString(&config, &config.executable, "/embed"); + if (PyStatus_Exception(status)) { + goto exception; + } + status = Py_InitializeFromConfig(&config); + if (PyStatus_Exception(status)) { + goto exception; + } + PyConfig_Clear(&config); + + if (PyRun_SimpleString(SCRIPT) != 0) { + puts("web_embed_test: script failed"); + return 1; + } + if (Py_FinalizeEx() < 0) { + puts("web_embed_test: Py_FinalizeEx failed"); + return 1; + } + puts("web_embed_test: ok"); + return 0; + +exception: + PyConfig_Clear(&config); + Py_ExitStatusException(status); +} diff --git a/Platforms/emscripten/web_embed_test/run_test.sh b/Platforms/emscripten/web_embed_test/run_test.sh new file mode 100755 index 000000000000000..ecbbe73efd8b4f5 --- /dev/null +++ b/Platforms/emscripten/web_embed_test/run_test.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Build and run the libpython embedding smoke test. +set -euo pipefail +cd "$(dirname "$0")/../../.." + +BUILD_DIR=${CROSS_BUILD_DIR:-cross-build}/wasm32-emscripten/build/python +make -C "$BUILD_DIR" web_embed_test + +# Node 24 needs JSPI enabled explicitly; it is on by default afterwards. +NODE=${NODE:-node} +NODE_FLAGS= +if [ "$("$NODE" -p 'process.versions.node.split(".")[0]')" = 24 ]; then + NODE_FLAGS=--experimental-wasm-jspi +fi + +# Run from the build directory: Emscripten resolves main.data relative to cwd. +cd "$BUILD_DIR/web_embed_test" +rc=0 +out=$("$NODE" $NODE_FLAGS main.js 2>&1) || rc=$? +echo "$out" +[ "$rc" -eq 0 ] && grep -q "web_embed_test: ok" <<<"$out" diff --git a/Programs/_bootstrap_python.c b/Programs/_bootstrap_python.c index 6443d814a22dabf..c65d616afbd5010 100644 --- a/Programs/_bootstrap_python.c +++ b/Programs/_bootstrap_python.c @@ -13,6 +13,7 @@ #include "Python/frozen_modules/importlib._bootstrap.h" #include "Python/frozen_modules/importlib._bootstrap_external.h" #include "Python/frozen_modules/zipimport.h" +#include "Python/frozen_modules/builtins.h" /* End includes */ /* Note that a negative size indicates a package. */ @@ -21,6 +22,7 @@ static const struct _frozen bootstrap_modules[] = { {"_frozen_importlib", _Py_M__importlib__bootstrap, (int)sizeof(_Py_M__importlib__bootstrap)}, {"_frozen_importlib_external", _Py_M__importlib__bootstrap_external, (int)sizeof(_Py_M__importlib__bootstrap_external)}, {"zipimport", _Py_M__zipimport, (int)sizeof(_Py_M__zipimport)}, + {"_pybuiltins", _Py_M__builtins, (int)sizeof(_Py_M__builtins)}, {0, 0, 0} /* bootstrap sentinel */ }; static const struct _frozen stdlib_modules[] = { @@ -36,6 +38,7 @@ const struct _frozen *_PyImport_FrozenTest = test_modules; static const struct _module_alias aliases[] = { {"_frozen_importlib", "importlib._bootstrap"}, {"_frozen_importlib_external", "importlib._bootstrap_external"}, + {"_pybuiltins", "builtins"}, {0, 0} /* aliases sentinel */ }; const struct _module_alias *_PyImport_FrozenAliases = aliases; @@ -101,9 +104,6 @@ main(int argc, char **argv) error: PyConfig_Clear(&config); - if (PyStatus_IsExit(status)) { - return status.exitcode; - } Py_ExitStatusException(status); } diff --git a/Programs/_freeze_module.c b/Programs/_freeze_module.c index 27a60171f3eca86..ae134f6caef1d59 100644 --- a/Programs/_freeze_module.c +++ b/Programs/_freeze_module.c @@ -122,11 +122,12 @@ read_text(const char *inpath) static PyObject * compile_and_marshal(const char *name, const char *text) { - char *filename = (char *) malloc(strlen(name) + 10); + int text_size = strlen(name) + 10; + char *filename = (char *) malloc(text_size); if (filename == NULL) { return PyErr_NoMemory(); } - sprintf(filename, "", name); + PyOS_snprintf(filename, text_size, "", name); PyObject *code = Py_CompileStringExFlags(text, filename, Py_file_input, NULL, 0); free(filename); diff --git a/Programs/_testembed.c b/Programs/_testembed.c index 418609abc5f6b82..6431bfda53c95c1 100644 --- a/Programs/_testembed.c +++ b/Programs/_testembed.c @@ -23,10 +23,17 @@ extern void PySys_AddWarnOption(const wchar_t *s); extern void PySys_AddXOption(const wchar_t *s); extern void Py_SetPath(const wchar_t *path); +// Functions removed from Python 3.16 API but still exported for the stable +// ABI. +extern void Py_SetPythonHome(const wchar_t *); + // These functions were removed from Python 3.15 API but are still exported // for the stable ABI. We want to test them in this program. extern void PySys_ResetWarnOptions(void); +// Variable removed from Python 3.16 limited C API, but kept in the stable ABI +PyAPI_DATA(int) Py_UTF8Mode; + int main_argc; char **main_argv; @@ -261,6 +268,23 @@ static int test_repeated_init_exec(void) return 0; } + +static int test_interpreter_clear_and_delete(void) +{ + assert(main_argc == 3); + _testembed_initialize(); + if (PyRun_SimpleString(main_argv[2]) < 0) { + return 1; + } + + PyInterpreterState *interp = PyInterpreterState_Get(); + PyInterpreterState_Clear(interp); + PyThreadState_Swap(NULL); + PyInterpreterState_Delete(interp); + // The interpreter has already been deleted, so don't call Py_FinalizeEx(). + return 0; +} + /**************************************************************************** * Test the Py_Initialize(Ex) convenience/compatibility wrappers ***************************************************************************/ @@ -597,43 +621,9 @@ static int test_init_compat_config(void) static int test_init_global_config(void) { - /* FIXME: test Py_IgnoreEnvironmentFlag */ - putenv("PYTHONUTF8=0"); Py_UTF8Mode = 1; - /* Py_IsolatedFlag is not tested */ - Py_NoSiteFlag = 1; - Py_BytesWarningFlag = 1; - - putenv("PYTHONINSPECT="); - Py_InspectFlag = 1; - - putenv("PYTHONOPTIMIZE=0"); - Py_InteractiveFlag = 1; - - putenv("PYTHONDEBUG=0"); - Py_OptimizeFlag = 2; - - /* Py_DebugFlag is not tested */ - - putenv("PYTHONDONTWRITEBYTECODE="); - Py_DontWriteBytecodeFlag = 1; - - putenv("PYTHONVERBOSE=0"); - Py_VerboseFlag = 1; - - Py_QuietFlag = 1; - Py_NoUserSiteDirectory = 1; - - putenv("PYTHONUNBUFFERED="); - Py_UnbufferedStdioFlag = 1; - - Py_FrozenFlag = 1; - - /* FIXME: test Py_LegacyWindowsFSEncodingFlag */ - /* FIXME: test Py_LegacyWindowsStdioFlag */ - _testembed_initialize(); dump_config(); Py_Finalize(); @@ -734,39 +724,30 @@ static int test_init_from_config(void) config_set_string(&config, &config.platlibdir, L"my_platlibdir"); putenv("PYTHONVERBOSE=0"); - Py_VerboseFlag = 0; config.verbose = 1; - Py_NoSiteFlag = 0; config.site_import = 0; - Py_BytesWarningFlag = 0; config.bytes_warning = 1; putenv("PYTHONINSPECT="); - Py_InspectFlag = 0; config.inspect = 1; - Py_InteractiveFlag = 0; config.interactive = 1; putenv("PYTHONOPTIMIZE=0"); - Py_OptimizeFlag = 1; config.optimization_level = 2; /* FIXME: test parser_debug */ putenv("PYTHONDONTWRITEBYTECODE="); - Py_DontWriteBytecodeFlag = 0; config.write_bytecode = 0; - Py_QuietFlag = 0; config.quiet = 1; config.configure_c_stdio = 1; putenv("PYTHONUNBUFFERED="); - Py_UnbufferedStdioFlag = 0; config.buffered_stdio = 0; putenv("PYTHONIOENCODING=cp424"); @@ -774,12 +755,10 @@ static int test_init_from_config(void) config_set_string(&config, &config.stdio_errors, L"replace"); putenv("PYTHONNOUSERSITE="); - Py_NoUserSiteDirectory = 0; config.user_site_directory = 0; config_set_string(&config, &config.check_hash_pycs_mode, L"always"); - Py_FrozenFlag = 0; config.pathconfig_warnings = 0; config.safe_path = 1; @@ -882,7 +861,6 @@ static void set_all_env_vars(void) static int test_init_compat_env(void) { /* Test initialization from environment variables */ - Py_IgnoreEnvironmentFlag = 0; set_all_env_vars(); _testembed_initialize(); dump_config(); @@ -918,7 +896,6 @@ static void set_all_env_vars_dev_mode(void) static int test_init_env_dev_mode(void) { /* Test initialization from environment variables */ - Py_IgnoreEnvironmentFlag = 0; set_all_env_vars_dev_mode(); _testembed_initialize(); dump_config(); @@ -930,7 +907,6 @@ static int test_init_env_dev_mode(void) static int test_init_env_dev_mode_alloc(void) { /* Test initialization from environment variables */ - Py_IgnoreEnvironmentFlag = 0; set_all_env_vars_dev_mode(); #ifndef Py_GIL_DISABLED putenv("PYTHONMALLOC=malloc"); @@ -950,7 +926,6 @@ static int test_init_isolated_flag(void) PyConfig config; PyConfig_InitPythonConfig(&config); - Py_IsolatedFlag = 0; config.isolated = 1; // These options are set to 1 by isolated=1 config.safe_path = 0; @@ -1010,7 +985,6 @@ static int test_preinit_isolated2(void) PyConfig config; _PyConfig_InitCompatConfig(&config); - Py_IsolatedFlag = 0; config.isolated = 1; config_set_program_name(&config); @@ -1081,28 +1055,6 @@ static int test_preinit_parse_argv(void) -static void set_all_global_config_variables(void) -{ - Py_IsolatedFlag = 0; - Py_IgnoreEnvironmentFlag = 0; - Py_BytesWarningFlag = 2; - Py_InspectFlag = 1; - Py_InteractiveFlag = 1; - Py_OptimizeFlag = 1; - Py_DebugFlag = 1; - Py_VerboseFlag = 1; - Py_QuietFlag = 1; - Py_FrozenFlag = 0; - Py_UnbufferedStdioFlag = 1; - Py_NoSiteFlag = 1; - Py_DontWriteBytecodeFlag = 1; - Py_NoUserSiteDirectory = 1; -#ifdef MS_WINDOWS - Py_LegacyWindowsStdioFlag = 1; -#endif -} - - static int check_preinit_isolated_config(int preinit) { PyStatus status; @@ -1111,9 +1063,6 @@ static int check_preinit_isolated_config(int preinit) /* environment variables must be ignored */ set_all_env_vars(); - /* global configuration variables must be ignored */ - set_all_global_config_variables(); - if (preinit) { PyPreConfig preconfig; PyPreConfig_InitIsolatedConfig(&preconfig); @@ -1158,19 +1107,6 @@ static int test_init_isolated_config(void) static int check_init_python_config(int preinit) { - /* global configuration variables must be ignored */ - set_all_global_config_variables(); - Py_IsolatedFlag = 1; - Py_IgnoreEnvironmentFlag = 1; - Py_FrozenFlag = 1; - Py_UnbufferedStdioFlag = 1; - Py_NoSiteFlag = 1; - Py_DontWriteBytecodeFlag = 1; - Py_NoUserSiteDirectory = 1; -#ifdef MS_WINDOWS - Py_LegacyWindowsStdioFlag = 1; -#endif - if (preinit) { PyPreConfig preconfig; PyPreConfig_InitPythonConfig(&preconfig); @@ -1276,7 +1212,6 @@ static int test_open_code_hook(void) return 2; } - Py_IgnoreEnvironmentFlag = 0; _testembed_initialize(); result = 0; @@ -1339,7 +1274,6 @@ static int _test_audit(Py_ssize_t setValue) { Py_ssize_t sawSet = 0; - Py_IgnoreEnvironmentFlag = 0; PySys_AddAuditHook(_audit_hook, &sawSet); _testembed_initialize(); @@ -1451,7 +1385,6 @@ static int _audit_subinterpreter_hook(const char *event, PyObject *args, void *u static int test_audit_subinterpreter(void) { - Py_IgnoreEnvironmentFlag = 0; PySys_AddAuditHook(_audit_subinterpreter_hook, NULL); _testembed_initialize(); @@ -1501,7 +1434,6 @@ static int test_audit_run_command(void) AuditRunCommandTest test = {"cpython.run_command"}; wchar_t *argv[] = {PROGRAM_NAME, L"-c", L"pass"}; - Py_IgnoreEnvironmentFlag = 0; PySys_AddAuditHook(_audit_hook_run, (void*)&test); return Py_Main(Py_ARRAY_LENGTH(argv), argv); @@ -1512,7 +1444,6 @@ static int test_audit_run_file(void) AuditRunCommandTest test = {"cpython.run_file"}; wchar_t *argv[] = {PROGRAM_NAME, L"filename.py"}; - Py_IgnoreEnvironmentFlag = 0; PySys_AddAuditHook(_audit_hook_run, (void*)&test); return Py_Main(Py_ARRAY_LENGTH(argv), argv); @@ -1789,6 +1720,7 @@ static int test_initconfig_api(void) goto error; } + // Set an integer option if (PyInitConfig_SetInt(config, "hash_seed", 10) < 0) { goto error; } @@ -1808,13 +1740,18 @@ static int test_initconfig_api(void) goto error; } - // Set a list of UTF-8 strings (argv) + // Set a list of UTF-8 strings (xoptions) char* xoptions[] = {"faulthandler"}; if (PyInitConfig_SetStrList(config, "xoptions", Py_ARRAY_LENGTH(xoptions), xoptions) < 0) { goto error; } + // Set an optional string to NULL explicitly (must not crash). + if (PyInitConfig_SetStr(config, "prefix", NULL) < 0) { + goto error; + } + if (Py_InitializeFromInitConfig(config) < 0) { goto error; } @@ -1835,6 +1772,99 @@ static int test_initconfig_api(void) } +static void +check_initconfig_error(PyInitConfig *config, const char *expected) +{ + const char *err_msg; + assert(PyInitConfig_GetError(config, &err_msg) == 1); + assert(strcmp(err_msg, expected) == 0); +} + + +// Test errors of PyInitConfig_Set*() functions +static int test_initconfig_set_errors(void) +{ + char* strlist[] = {"value"}; + + PyInitConfig *config = PyInitConfig_Create(); + if (config == NULL) { + printf("Init allocation error\n"); + return 1; + } + + // Unknown option + assert(PyInitConfig_SetInt(config, "non-existent", 123) < 0); + check_initconfig_error(config, "unknown config option name"); + assert(PyInitConfig_SetStr(config, "non-existent", "abc") < 0); + check_initconfig_error(config, "unknown config option name"); + assert(PyInitConfig_SetStrList(config, "non-existent", + Py_ARRAY_LENGTH(strlist), strlist) < 0); + check_initconfig_error(config, "unknown config option name"); + + + // Wrong type + assert(PyInitConfig_SetInt(config, "platlibdir", 123) == -1); + check_initconfig_error(config, "config option type is not int"); + + assert(PyInitConfig_SetStr(config, "cpu_count", "abc") == -1); + check_initconfig_error(config, "config option type is not string"); + + assert(PyInitConfig_SetStrList(config, "cpu_count", + Py_ARRAY_LENGTH(strlist), strlist) < 0); + check_initconfig_error(config, "config option type is not strings list"); + + + // Test SetInt() range: cpu_count option type is PyConfig_MEMBER_INT + assert(PyInitConfig_SetInt(config, "cpu_count", INT_MIN) == 0); + assert(PyInitConfig_SetInt(config, "cpu_count", INT_MAX) == 0); + + assert(PyInitConfig_SetInt(config, "cpu_count", INT64_MIN) == -1); + check_initconfig_error(config, "config option value is out of int range"); + assert(PyInitConfig_SetInt(config, "cpu_count", INT64_MAX) == -1); + check_initconfig_error(config, "config option value is out of int range"); + + + // Test SetInt() range: verbose option type is PyConfig_MEMBER_UINT + assert(PyInitConfig_SetInt(config, "verbose", 0) == 0); + assert(PyInitConfig_SetInt(config, "verbose", UINT_MAX) == 0); + + assert(PyInitConfig_SetInt(config, "verbose", -1) == -1); + check_initconfig_error(config, "config option value is out of unsigned int range"); + assert(PyInitConfig_SetInt(config, "verbose", INT64_MAX) == -1); + check_initconfig_error(config, "config option value is out of unsigned int range"); + + + // SetStr() decode error + assert(PyInitConfig_SetStr(config, "platlibdir", "\xff") == -1); + check_initconfig_error(config, "decoding error"); + + + // Setting a non-optional string to NULL fails with an error, + // but leaves the optional unchanged. + if (PyInitConfig_SetStr(config, "program_name", PROGRAM_NAME_UTF8) < 0) { + goto error; + } + assert(PyInitConfig_SetStr(config, "program_name", NULL) < 0); + check_initconfig_error(config, "config option string cannot be NULL"); + char *str; + assert(PyInitConfig_GetStr(config, "program_name", &str) == 0); + assert(strcmp(str, PROGRAM_NAME_UTF8) == 0); + free(str); + + + PyInitConfig_Free(config); + return 0; + +error: + { + const char *err_msg; + (void)PyInitConfig_GetError(config, &err_msg); + printf("Python init failed: %s\n", err_msg); + exit(1); + } +} + + static int test_initconfig_get_api(void) { PyInitConfig *config = PyInitConfig_Create(); @@ -1847,6 +1877,7 @@ static int test_initconfig_get_api(void) assert(PyInitConfig_HasOption(config, "verbose") == 1); assert(PyInitConfig_HasOption(config, "utf8_mode") == 1); assert(PyInitConfig_HasOption(config, "non-existent") == 0); + assert(PyInitConfig_HasOption(config, "") == 0); // test PyInitConfig_GetInt() assert(initconfig_getint(config, "dev_mode") == 0); @@ -1858,7 +1889,7 @@ static int test_initconfig_get_api(void) assert(PyInitConfig_SetInt(config, "utf8_mode", 0) == 0); assert(initconfig_getint(config, "utf8_mode") == 0); - // test PyInitConfig_GetStr() + // test PyInitConfig_GetStr() on an unset string (NULL by default) char *str; assert(PyInitConfig_GetStr(config, "program_name", &str) == 0); assert(str == NULL); @@ -1884,8 +1915,11 @@ static int test_initconfig_get_api(void) // Setting hash_seed sets use_hash_seed assert(initconfig_getint(config, "use_hash_seed") == 0); + assert(initconfig_getint(config, "hash_seed") == 0); + assert(PyInitConfig_SetInt(config, "hash_seed", 123) == 0); assert(initconfig_getint(config, "use_hash_seed") == 1); + assert(initconfig_getint(config, "hash_seed") == 123); // Setting module_search_paths sets module_search_paths_set assert(initconfig_getint(config, "module_search_paths_set") == 0); @@ -1894,35 +1928,32 @@ static int test_initconfig_get_api(void) Py_ARRAY_LENGTH(paths), paths) == 0); assert(initconfig_getint(config, "module_search_paths_set") == 1); + PyInitConfig_Free(config); return 0; } static int test_initconfig_exit(void) { + // -h command line option is stored as PyConfig._deferred_cmdline_option PyInitConfig *config = PyInitConfig_Create(); if (config == NULL) { printf("Init allocation error\n"); return 1; } - char *argv[] = {PROGRAM_NAME_UTF8, "--help"}; + char *argv[] = {PROGRAM_NAME_UTF8, "-h"}; assert(PyInitConfig_SetStrList(config, "argv", Py_ARRAY_LENGTH(argv), argv) == 0); - assert(PyInitConfig_SetInt(config, "parse_argv", 1) == 0); - assert(Py_InitializeFromInitConfig(config) < 0); - - int exitcode; - assert(PyInitConfig_GetExitCode(config, &exitcode) == 1); - assert(exitcode == 0); + assert(Py_InitializeFromInitConfig(config) == 0); + PyInitConfig_Free(config); - const char *err_msg; - assert(PyInitConfig_GetError(config, &err_msg) == 1); - assert(strcmp(err_msg, "exit code 0") == 0); + const PyConfig *rt_config = _Py_GetConfig(); + assert(rt_config->_deferred_cmdline_option == 'h'); - PyInitConfig_Free(config); + Py_Finalize(); return 0; } @@ -2357,6 +2388,43 @@ static int test_isinitialized_false_during_site_import(void) } +static int test_py_getenv(void) +{ + const char *name = "PYTHON_TESTEMBED_VARIABLE"; + const char *expected = "expected_value"; + putenv("PYTHON_TESTEMBED_VARIABLE=expected_value"); + + const char *var = Py_GETENV(name); + if (var == NULL || strcmp(var, expected) != 0) { + error_fmt("%s is not set before Python initialization", name); + return 1; + } + + // Initialize Python with use_environment=0 + PyConfig config; + _PyConfig_InitCompatConfig(&config); + config_set_program_name(&config); + config.use_environment = 0; + init_from_config_clear(&config); + + var = Py_GETENV(name); + if (var != NULL) { + error_fmt("Py_GETENV() doesn't ignore %s after Python init", name); + return 1; + } + + Py_Finalize(); + var = Py_GETENV(name); + if (var == NULL || strcmp(var, expected) != 0) { + error_fmt("%s is not set after Python finalization", name); + return 1; + } + + printf("OK\n"); + return 0; +} + + #ifndef MS_WINDOWS #include "test_frozenmain.h" // M_test_frozenmain @@ -2410,6 +2478,126 @@ static int test_repeated_init_and_inittab(void) return 0; } +// Two different single-phase init functions for the same module name. +static int cmfi_initfunc_a_calls = 0; +static int cmfi_initfunc_b_calls = 0; + +static PyModuleDef cmfi_same_name_a_def = { + PyModuleDef_HEAD_INIT, + .m_name = "same_name", + .m_size = -1, +}; + +static PyModuleDef cmfi_same_name_b_def = { + PyModuleDef_HEAD_INIT, + .m_name = "same_name", + .m_size = -1, +}; + +static PyObject* +PyInit_cmfi_same_name_a(void) +{ + cmfi_initfunc_a_calls++; + PyObject *mod = PyModule_Create(&cmfi_same_name_a_def); + if (mod == NULL || PyModule_AddStringConstant(mod, "which", "A") < 0) { + Py_XDECREF(mod); + return NULL; + } + return mod; +} + +static PyObject* +PyInit_cmfi_same_name_b(void) +{ + cmfi_initfunc_b_calls++; + PyObject *mod = PyModule_Create(&cmfi_same_name_b_def); + if (mod == NULL || PyModule_AddStringConstant(mod, "which", "B") < 0) { + Py_XDECREF(mod); + return NULL; + } + return mod; +} + +static PyObject* +create_same_name_b(PyObject* self, PyObject* spec) +{ + return PyImport_CreateModuleFromInitfunc(spec, PyInit_cmfi_same_name_b); +} + +static PyObject* +initfunc_calls(PyObject* self, PyObject* Py_UNUSED(args)) +{ + return Py_BuildValue("(ii)", cmfi_initfunc_a_calls, cmfi_initfunc_b_calls); +} + +// A single-phase init submodule that only knows its short name, +// like pybind11's PYBIND11_MODULE(sp_submod, m) would. +static PyModuleDef cmfi_sp_submod_def = { + PyModuleDef_HEAD_INIT, + .m_name = "sp_submod", + .m_size = -1, +}; + +static PyObject* +PyInit_cmfi_sp_submod(void) +{ + return PyModule_Create(&cmfi_sp_submod_def); +} + +// A multi-phase init package for the submodule above. +static PyModuleDef_Slot cmfi_sp_pkg_slots[] = { + {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED}, + {Py_mod_gil, Py_MOD_GIL_NOT_USED}, + {0, NULL}, +}; + +static PyModuleDef cmfi_sp_pkg_def = { + PyModuleDef_HEAD_INIT, + .m_name = "sp_pkg", + .m_size = 0, + .m_slots = cmfi_sp_pkg_slots, +}; + +static PyObject* +PyInit_cmfi_sp_pkg(void) +{ + return PyModuleDef_Init(&cmfi_sp_pkg_def); +} + + +// Modules with non-ASCII names: multi-phase init is supported, +// single-phase init is not. +static PyModuleDef_Slot cmfi_nonascii_mp_slots[] = { + {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED}, + {Py_mod_gil, Py_MOD_GIL_NOT_USED}, + {0, NULL}, +}; + +static PyModuleDef cmfi_nonascii_mp_def = { + PyModuleDef_HEAD_INIT, + .m_name = "nonascii_mp_\xf0\x9f\x90\x8d", + .m_size = 0, + .m_slots = cmfi_nonascii_mp_slots, +}; + +static PyObject* +PyInit_cmfi_nonascii_mp(void) +{ + return PyModuleDef_Init(&cmfi_nonascii_mp_def); +} + +static PyModuleDef cmfi_nonascii_sp_def = { + PyModuleDef_HEAD_INIT, + .m_name = "nonascii_sp_\xf0\x9f\x90\x8d", + .m_size = -1, +}; + +static PyObject* +PyInit_cmfi_nonascii_sp(void) +{ + return PyModule_Create(&cmfi_nonascii_sp_def); +} + static PyObject* create_module(PyObject* self, PyObject* spec) { @@ -2425,6 +2613,26 @@ create_module(PyObject* self, PyObject* spec) Py_DECREF(name); return PyImport_CreateModuleFromInitfunc(spec, PyInit_embedded_ext); } + if (PyUnicode_EqualToUTF8(name, "same_name")) { + Py_DECREF(name); + return PyImport_CreateModuleFromInitfunc(spec, PyInit_cmfi_same_name_a); + } + if (PyUnicode_EqualToUTF8(name, "sp_pkg")) { + Py_DECREF(name); + return PyImport_CreateModuleFromInitfunc(spec, PyInit_cmfi_sp_pkg); + } + if (PyUnicode_EqualToUTF8(name, "sp_pkg.sp_submod")) { + Py_DECREF(name); + return PyImport_CreateModuleFromInitfunc(spec, PyInit_cmfi_sp_submod); + } + if (PyUnicode_EqualToUTF8(name, "nonascii_mp_\xf0\x9f\x90\x8d")) { + Py_DECREF(name); + return PyImport_CreateModuleFromInitfunc(spec, PyInit_cmfi_nonascii_mp); + } + if (PyUnicode_EqualToUTF8(name, "nonascii_sp_\xf0\x9f\x90\x8d")) { + Py_DECREF(name); + return PyImport_CreateModuleFromInitfunc(spec, PyInit_cmfi_nonascii_sp); + } PyErr_Format(PyExc_LookupError, "static module %R not found", name); Py_DECREF(name); return NULL; @@ -2441,6 +2649,8 @@ exec_module(PyObject* self, PyObject* mod) static PyMethodDef create_static_module_methods[] = { {"create_module", create_module, METH_O, NULL}, + {"create_same_name_b", create_same_name_b, METH_O, NULL}, + {"initfunc_calls", initfunc_calls, METH_NOARGS, NULL}, {"exec_module", exec_module, METH_O, NULL}, {NULL} }; @@ -2472,6 +2682,23 @@ test_create_module_from_initfunc(void) L"import embedded_ext;" L"print(embedded_ext);" L"print(f'{embedded_ext.executed=}');" + // Same name, different initfuncs: the first one wins + L"spec = spec_from_loader('same_name', StaticExtensionImporter);" + L"a = create_static_module.create_module(spec);" + L"b = create_static_module.create_same_name_b(spec);" + L"print(f'{a.which=} {b.which=} {a is b=}');" + L"print(f'{create_static_module.initfunc_calls()=}');" + // Single-phase submodule whose init only knows its short name + L"import sp_pkg.sp_submod;" + L"print(sp_pkg.sp_submod);" + L"print(f'{sp_pkg.sp_submod.__name__=}');" + L"print(f'{sys.modules[\"sp_pkg.sp_submod\"] is sp_pkg.sp_submod=}');" + L"print(f'{\"sp_submod\" in sys.modules=}');" + // Non-ASCII names: multi-phase init works, single-phase init doesn't + L"import importlib;" + L"mp = importlib.import_module('nonascii_mp_\\N{SNAKE}');" + L"print(f'{ascii(mp.__name__)=} {mp.executed=}');" + L"try_import('nonascii_sp_\\N{SNAKE}');" }; PyConfig config; if (PyImport_AppendInittab("create_static_module", @@ -2491,17 +2718,32 @@ test_create_module_from_initfunc(void) " _ORIGIN = \"static-extension\"\n" " @classmethod\n" " def find_spec(cls, fullname, path, target=None):\n" - " if fullname in {'my_test_extension', 'embedded_ext'}:\n" - " return spec_from_loader(fullname, cls, origin=cls._ORIGIN)\n" + " if fullname in {'my_test_extension', 'embedded_ext',\n" + " 'sp_pkg', 'sp_pkg.sp_submod',\n" + " 'nonascii_mp_\\N{SNAKE}',\n" + " 'nonascii_sp_\\N{SNAKE}',\n" + " }:\n" + " return spec_from_loader(fullname, cls, origin=cls._ORIGIN,\n" + " is_package=(fullname == 'sp_pkg'))\n" " return None\n" " @staticmethod\n" " def create_module(spec):\n" - " return create_static_module.create_module(spec)\n" + " mod = create_static_module.create_module(spec)\n" + " print(f'created {spec.name}: '\n" + " f'in sys.modules={spec.name in sys.modules}')\n" + " return mod\n" " @staticmethod\n" " def exec_module(module):\n" " create_static_module.exec_module(module)\n" " module.executed = 'yes'\n" "sys.meta_path.append(StaticExtensionImporter)\n" + "def try_import(name):\n" + " try:\n" + " importlib.import_module(name)\n" + " except SystemError as exc:\n" + " print(f'SystemError: {ascii(str(exc))}')\n" + " else:\n" + " print(f'no SystemError for {ascii(name)}!')\n" ); if (result < 0) { fprintf(stderr, "PyRun_SimpleString() failed\n"); @@ -3004,6 +3246,7 @@ struct TestCase static struct TestCase TestCases[] = { // Python initialization {"test_repeated_init_exec", test_repeated_init_exec}, + {"test_interpreter_clear_and_delete", test_interpreter_clear_and_delete}, {"test_repeated_simple_init", test_repeated_simple_init}, {"test_forced_io_encoding", test_forced_io_encoding}, {"test_import_in_subinterpreters", test_import_in_subinterpreters}, @@ -3049,6 +3292,7 @@ static struct TestCase TestCases[] = { {"test_init_is_python_build", test_init_is_python_build}, {"test_init_warnoptions", test_init_warnoptions}, {"test_initconfig_api", test_initconfig_api}, + {"test_initconfig_set_errors", test_initconfig_set_errors}, {"test_initconfig_get_api", test_initconfig_get_api}, {"test_initconfig_exit", test_initconfig_exit}, {"test_initconfig_module", test_initconfig_module}, @@ -3059,6 +3303,7 @@ static struct TestCase TestCases[] = { {"test_init_main_interpreter_settings", test_init_main_interpreter_settings}, {"test_init_in_background_thread", test_init_in_background_thread}, {"test_isinitialized_false_during_site_import", test_isinitialized_false_during_site_import}, + {"test_py_getenv", test_py_getenv}, // Audit {"test_open_code_hook", test_open_code_hook}, diff --git a/Programs/emscripten_beforemain.c b/Programs/emscripten_beforemain.c new file mode 100644 index 000000000000000..445470237ea8b80 --- /dev/null +++ b/Programs/emscripten_beforemain.c @@ -0,0 +1,14 @@ +/* Emscripten setup for when Python is the program. Linked into the + * interpreter only, never into libpython. + * + * Runs main() under WebAssembly.promising so that libpython can suspend the + * wasm stack in a syscall (see Python/emscripten_syscalls.c). + */ + +void _PyEmscripten_BeforeMain_js(void); + +__attribute__((constructor)) void +_PyEmscripten_BeforeMain(void) +{ + _PyEmscripten_BeforeMain_js(); +} diff --git a/Programs/test_frozenmain.h b/Programs/test_frozenmain.h index c82b791439a3fa1..ebcb38b18dec90c 100644 --- a/Programs/test_frozenmain.h +++ b/Programs/test_frozenmain.h @@ -1,7 +1,7 @@ // Auto-generated by Programs/freeze_test_frozenmain.py unsigned char M_test_frozenmain[] = { - 227,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0, - 0,0,0,0,0,243,188,0,0,0,128,0,0,0,90,0, + 99,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0, + 0,0,0,0,0,115,188,0,0,0,128,0,0,0,90,0, 77,7,69,0,112,0,90,0,77,7,69,4,112,1,89,2, 31,0,78,1,50,1,0,0,0,0,0,0,29,0,89,2, 31,0,78,2,89,0,76,6,0,0,0,0,0,0,0,0, @@ -13,27 +13,27 @@ unsigned char M_test_frozenmain[] = { 89,2,31,0,78,4,89,6,12,0,78,5,89,5,89,6, 42,26,0,0,0,0,0,0,0,0,0,0,12,0,48,4, 50,1,0,0,0,0,0,0,29,0,71,26,0,0,9,0, - 28,0,77,7,33,0,41,7,233,0,0,0,0,122,18,70, + 28,0,77,7,33,0,41,7,105,0,0,0,0,122,18,70, 114,111,122,101,110,32,72,101,108,108,111,32,87,111,114,108, 100,122,8,115,121,115,46,97,114,103,118,218,6,99,111,110, 102,105,103,122,7,99,111,110,102,105,103,32,122,2,58,32, - 41,5,218,12,112,114,111,103,114,97,109,95,110,97,109,101, - 218,10,101,120,101,99,117,116,97,98,108,101,218,15,117,115, - 101,95,101,110,118,105,114,111,110,109,101,110,116,218,17,99, + 41,5,90,12,112,114,111,103,114,97,109,95,110,97,109,101, + 90,10,101,120,101,99,117,116,97,98,108,101,90,15,117,115, + 101,95,101,110,118,105,114,111,110,109,101,110,116,90,17,99, 111,110,102,105,103,117,114,101,95,99,95,115,116,100,105,111, - 218,14,98,117,102,102,101,114,101,100,95,115,116,100,105,111, - 41,7,218,3,115,121,115,218,17,95,116,101,115,116,105,110, - 116,101,114,110,97,108,99,97,112,105,218,5,112,114,105,110, - 116,218,4,97,114,103,118,218,11,103,101,116,95,99,111,110, - 102,105,103,115,114,3,0,0,0,218,3,107,101,121,169,0, - 243,0,0,0,0,218,18,116,101,115,116,95,102,114,111,122, + 90,14,98,117,102,102,101,114,101,100,95,115,116,100,105,111, + 41,7,90,3,115,121,115,90,17,95,116,101,115,116,105,110, + 116,101,114,110,97,108,99,97,112,105,90,5,112,114,105,110, + 116,90,4,97,114,103,118,90,11,103,101,116,95,99,111,110, + 102,105,103,115,114,0,0,0,0,90,3,107,101,121,41,0, + 243,0,0,0,0,90,18,116,101,115,116,95,102,114,111,122, 101,110,109,97,105,110,46,112,121,218,8,60,109,111,100,117, - 108,101,62,114,18,0,0,0,1,0,0,0,115,94,0,0, + 108,101,62,114,2,0,0,0,1,0,0,0,115,94,0,0, 0,241,3,1,1,1,243,8,0,1,11,219,0,24,225,0, 5,208,6,26,212,0,27,217,0,5,128,106,144,35,151,40, 145,40,212,0,27,216,9,26,215,9,38,210,9,38,211,9, 40,168,24,213,9,50,128,6,244,2,6,12,2,128,67,241, 14,0,5,10,136,71,144,67,144,53,152,2,152,54,160,35, 157,59,152,45,208,10,40,214,4,41,243,15,6,12,2,114, - 16,0,0,0, + 1,0,0,0, }; diff --git a/Python/Python-ast.c b/Python/Python-ast.c index f36072dfce098c6..2c020e6c2070fc4 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -33,255 +33,261 @@ void _PyAST_Fini(PyInterpreterState *interp) { struct ast_state *state = &interp->ast; - Py_CLEAR(state->AST_type); - Py_CLEAR(state->Add_singleton); - Py_CLEAR(state->Add_type); - Py_CLEAR(state->And_singleton); - Py_CLEAR(state->And_type); - Py_CLEAR(state->AnnAssign_type); - Py_CLEAR(state->Assert_type); - Py_CLEAR(state->Assign_type); - Py_CLEAR(state->AsyncFor_type); - Py_CLEAR(state->AsyncFunctionDef_type); - Py_CLEAR(state->AsyncWith_type); - Py_CLEAR(state->Attribute_type); - Py_CLEAR(state->AugAssign_type); - Py_CLEAR(state->Await_type); - Py_CLEAR(state->BinOp_type); - Py_CLEAR(state->BitAnd_singleton); - Py_CLEAR(state->BitAnd_type); - Py_CLEAR(state->BitOr_singleton); - Py_CLEAR(state->BitOr_type); - Py_CLEAR(state->BitXor_singleton); - Py_CLEAR(state->BitXor_type); - Py_CLEAR(state->BoolOp_type); - Py_CLEAR(state->Break_type); - Py_CLEAR(state->Call_type); - Py_CLEAR(state->ClassDef_type); - Py_CLEAR(state->Compare_type); - Py_CLEAR(state->Constant_type); - Py_CLEAR(state->Continue_type); - Py_CLEAR(state->Del_singleton); - Py_CLEAR(state->Del_type); - Py_CLEAR(state->Delete_type); - Py_CLEAR(state->DictComp_type); - Py_CLEAR(state->Dict_type); - Py_CLEAR(state->Div_singleton); - Py_CLEAR(state->Div_type); - Py_CLEAR(state->Eq_singleton); - Py_CLEAR(state->Eq_type); - Py_CLEAR(state->ExceptHandler_type); - Py_CLEAR(state->Expr_type); - Py_CLEAR(state->Expression_type); - Py_CLEAR(state->FloorDiv_singleton); - Py_CLEAR(state->FloorDiv_type); - Py_CLEAR(state->For_type); - Py_CLEAR(state->FormattedValue_type); - Py_CLEAR(state->FunctionDef_type); - Py_CLEAR(state->FunctionType_type); - Py_CLEAR(state->GeneratorExp_type); - Py_CLEAR(state->Global_type); - Py_CLEAR(state->GtE_singleton); - Py_CLEAR(state->GtE_type); - Py_CLEAR(state->Gt_singleton); - Py_CLEAR(state->Gt_type); - Py_CLEAR(state->IfExp_type); - Py_CLEAR(state->If_type); - Py_CLEAR(state->ImportFrom_type); - Py_CLEAR(state->Import_type); - Py_CLEAR(state->In_singleton); - Py_CLEAR(state->In_type); - Py_CLEAR(state->Interactive_type); - Py_CLEAR(state->Interpolation_type); - Py_CLEAR(state->Invert_singleton); - Py_CLEAR(state->Invert_type); - Py_CLEAR(state->IsNot_singleton); - Py_CLEAR(state->IsNot_type); - Py_CLEAR(state->Is_singleton); - Py_CLEAR(state->Is_type); - Py_CLEAR(state->JoinedStr_type); - Py_CLEAR(state->LShift_singleton); - Py_CLEAR(state->LShift_type); - Py_CLEAR(state->Lambda_type); - Py_CLEAR(state->ListComp_type); - Py_CLEAR(state->List_type); - Py_CLEAR(state->Load_singleton); - Py_CLEAR(state->Load_type); - Py_CLEAR(state->LtE_singleton); - Py_CLEAR(state->LtE_type); - Py_CLEAR(state->Lt_singleton); - Py_CLEAR(state->Lt_type); - Py_CLEAR(state->MatMult_singleton); - Py_CLEAR(state->MatMult_type); - Py_CLEAR(state->MatchAs_type); - Py_CLEAR(state->MatchClass_type); - Py_CLEAR(state->MatchMapping_type); - Py_CLEAR(state->MatchOr_type); - Py_CLEAR(state->MatchSequence_type); - Py_CLEAR(state->MatchSingleton_type); - Py_CLEAR(state->MatchStar_type); - Py_CLEAR(state->MatchValue_type); - Py_CLEAR(state->Match_type); - Py_CLEAR(state->Mod_singleton); - Py_CLEAR(state->Mod_type); - Py_CLEAR(state->Module_type); - Py_CLEAR(state->Mult_singleton); - Py_CLEAR(state->Mult_type); - Py_CLEAR(state->Name_type); - Py_CLEAR(state->NamedExpr_type); - Py_CLEAR(state->Nonlocal_type); - Py_CLEAR(state->NotEq_singleton); - Py_CLEAR(state->NotEq_type); - Py_CLEAR(state->NotIn_singleton); - Py_CLEAR(state->NotIn_type); - Py_CLEAR(state->Not_singleton); - Py_CLEAR(state->Not_type); - Py_CLEAR(state->Or_singleton); - Py_CLEAR(state->Or_type); - Py_CLEAR(state->ParamSpec_type); - Py_CLEAR(state->Pass_type); - Py_CLEAR(state->Pow_singleton); - Py_CLEAR(state->Pow_type); - Py_CLEAR(state->RShift_singleton); - Py_CLEAR(state->RShift_type); - Py_CLEAR(state->Raise_type); - Py_CLEAR(state->Return_type); - Py_CLEAR(state->SetComp_type); - Py_CLEAR(state->Set_type); - Py_CLEAR(state->Slice_type); - Py_CLEAR(state->Starred_type); - Py_CLEAR(state->Store_singleton); - Py_CLEAR(state->Store_type); - Py_CLEAR(state->Sub_singleton); - Py_CLEAR(state->Sub_type); - Py_CLEAR(state->Subscript_type); - Py_CLEAR(state->TemplateStr_type); - Py_CLEAR(state->TryStar_type); - Py_CLEAR(state->Try_type); - Py_CLEAR(state->Tuple_type); - Py_CLEAR(state->TypeAlias_type); - Py_CLEAR(state->TypeIgnore_type); - Py_CLEAR(state->TypeVarTuple_type); - Py_CLEAR(state->TypeVar_type); - Py_CLEAR(state->UAdd_singleton); - Py_CLEAR(state->UAdd_type); - Py_CLEAR(state->USub_singleton); - Py_CLEAR(state->USub_type); - Py_CLEAR(state->UnaryOp_type); - Py_CLEAR(state->While_type); - Py_CLEAR(state->With_type); - Py_CLEAR(state->YieldFrom_type); - Py_CLEAR(state->Yield_type); - Py_CLEAR(state->__dict__); - Py_CLEAR(state->__doc__); - Py_CLEAR(state->__match_args__); - Py_CLEAR(state->__module__); - Py_CLEAR(state->_attributes); - Py_CLEAR(state->_fields); - Py_CLEAR(state->abstract_types); - Py_CLEAR(state->alias_type); - Py_CLEAR(state->annotation); - Py_CLEAR(state->arg); - Py_CLEAR(state->arg_type); - Py_CLEAR(state->args); - Py_CLEAR(state->argtypes); - Py_CLEAR(state->arguments_type); - Py_CLEAR(state->asname); - Py_CLEAR(state->ast); - Py_CLEAR(state->attr); - Py_CLEAR(state->bases); - Py_CLEAR(state->body); - Py_CLEAR(state->boolop_type); - Py_CLEAR(state->bound); - Py_CLEAR(state->cases); - Py_CLEAR(state->cause); - Py_CLEAR(state->cls); - Py_CLEAR(state->cmpop_type); - Py_CLEAR(state->col_offset); - Py_CLEAR(state->comparators); - Py_CLEAR(state->comprehension_type); - Py_CLEAR(state->context_expr); - Py_CLEAR(state->conversion); - Py_CLEAR(state->ctx); - Py_CLEAR(state->decorator_list); - Py_CLEAR(state->default_value); - Py_CLEAR(state->defaults); - Py_CLEAR(state->elt); - Py_CLEAR(state->elts); - Py_CLEAR(state->end_col_offset); - Py_CLEAR(state->end_lineno); - Py_CLEAR(state->exc); - Py_CLEAR(state->excepthandler_type); - Py_CLEAR(state->expr_context_type); - Py_CLEAR(state->expr_type); - Py_CLEAR(state->finalbody); - Py_CLEAR(state->format_spec); - Py_CLEAR(state->func); - Py_CLEAR(state->generators); - Py_CLEAR(state->guard); - Py_CLEAR(state->handlers); - Py_CLEAR(state->id); - Py_CLEAR(state->ifs); - Py_CLEAR(state->is_async); - Py_CLEAR(state->is_lazy); - Py_CLEAR(state->items); - Py_CLEAR(state->iter); - Py_CLEAR(state->key); - Py_CLEAR(state->keys); - Py_CLEAR(state->keyword_type); - Py_CLEAR(state->keywords); - Py_CLEAR(state->kind); - Py_CLEAR(state->kw_defaults); - Py_CLEAR(state->kwarg); - Py_CLEAR(state->kwd_attrs); - Py_CLEAR(state->kwd_patterns); - Py_CLEAR(state->kwonlyargs); - Py_CLEAR(state->left); - Py_CLEAR(state->level); - Py_CLEAR(state->lineno); - Py_CLEAR(state->lower); - Py_CLEAR(state->match_case_type); - Py_CLEAR(state->mod_type); - Py_CLEAR(state->module); - Py_CLEAR(state->msg); - Py_CLEAR(state->name); - Py_CLEAR(state->names); - Py_CLEAR(state->op); - Py_CLEAR(state->operand); - Py_CLEAR(state->operator_type); - Py_CLEAR(state->ops); - Py_CLEAR(state->optional_vars); - Py_CLEAR(state->orelse); - Py_CLEAR(state->pattern); - Py_CLEAR(state->pattern_type); - Py_CLEAR(state->patterns); - Py_CLEAR(state->posonlyargs); - Py_CLEAR(state->rest); - Py_CLEAR(state->returns); - Py_CLEAR(state->right); - Py_CLEAR(state->simple); - Py_CLEAR(state->slice); - Py_CLEAR(state->step); - Py_CLEAR(state->stmt_type); - Py_CLEAR(state->str); - Py_CLEAR(state->subject); - Py_CLEAR(state->tag); - Py_CLEAR(state->target); - Py_CLEAR(state->targets); - Py_CLEAR(state->test); - Py_CLEAR(state->type); - Py_CLEAR(state->type_comment); - Py_CLEAR(state->type_ignore_type); - Py_CLEAR(state->type_ignores); - Py_CLEAR(state->type_param_type); - Py_CLEAR(state->type_params); - Py_CLEAR(state->unaryop_type); - Py_CLEAR(state->upper); - Py_CLEAR(state->value); - Py_CLEAR(state->values); - Py_CLEAR(state->vararg); - Py_CLEAR(state->withitem_type); - + static const size_t offsets[] = { + offsetof(struct ast_state, AST_type), + offsetof(struct ast_state, Add_singleton), + offsetof(struct ast_state, Add_type), + offsetof(struct ast_state, And_singleton), + offsetof(struct ast_state, And_type), + offsetof(struct ast_state, AnnAssign_type), + offsetof(struct ast_state, Assert_type), + offsetof(struct ast_state, Assign_type), + offsetof(struct ast_state, AsyncFor_type), + offsetof(struct ast_state, AsyncFunctionDef_type), + offsetof(struct ast_state, AsyncWith_type), + offsetof(struct ast_state, Attribute_type), + offsetof(struct ast_state, AugAssign_type), + offsetof(struct ast_state, Await_type), + offsetof(struct ast_state, BinOp_type), + offsetof(struct ast_state, BitAnd_singleton), + offsetof(struct ast_state, BitAnd_type), + offsetof(struct ast_state, BitOr_singleton), + offsetof(struct ast_state, BitOr_type), + offsetof(struct ast_state, BitXor_singleton), + offsetof(struct ast_state, BitXor_type), + offsetof(struct ast_state, BoolOp_type), + offsetof(struct ast_state, Break_type), + offsetof(struct ast_state, Call_type), + offsetof(struct ast_state, ClassDef_type), + offsetof(struct ast_state, Compare_type), + offsetof(struct ast_state, Constant_type), + offsetof(struct ast_state, Continue_type), + offsetof(struct ast_state, Del_singleton), + offsetof(struct ast_state, Del_type), + offsetof(struct ast_state, Delete_type), + offsetof(struct ast_state, DictComp_type), + offsetof(struct ast_state, Dict_type), + offsetof(struct ast_state, Div_singleton), + offsetof(struct ast_state, Div_type), + offsetof(struct ast_state, Eq_singleton), + offsetof(struct ast_state, Eq_type), + offsetof(struct ast_state, ExceptHandler_type), + offsetof(struct ast_state, Expr_type), + offsetof(struct ast_state, Expression_type), + offsetof(struct ast_state, FloorDiv_singleton), + offsetof(struct ast_state, FloorDiv_type), + offsetof(struct ast_state, For_type), + offsetof(struct ast_state, FormattedValue_type), + offsetof(struct ast_state, FunctionDef_type), + offsetof(struct ast_state, FunctionType_type), + offsetof(struct ast_state, GeneratorExp_type), + offsetof(struct ast_state, Global_type), + offsetof(struct ast_state, GtE_singleton), + offsetof(struct ast_state, GtE_type), + offsetof(struct ast_state, Gt_singleton), + offsetof(struct ast_state, Gt_type), + offsetof(struct ast_state, IfExp_type), + offsetof(struct ast_state, If_type), + offsetof(struct ast_state, ImportFrom_type), + offsetof(struct ast_state, Import_type), + offsetof(struct ast_state, In_singleton), + offsetof(struct ast_state, In_type), + offsetof(struct ast_state, Interactive_type), + offsetof(struct ast_state, Interpolation_type), + offsetof(struct ast_state, Invert_singleton), + offsetof(struct ast_state, Invert_type), + offsetof(struct ast_state, IsNot_singleton), + offsetof(struct ast_state, IsNot_type), + offsetof(struct ast_state, Is_singleton), + offsetof(struct ast_state, Is_type), + offsetof(struct ast_state, JoinedStr_type), + offsetof(struct ast_state, LShift_singleton), + offsetof(struct ast_state, LShift_type), + offsetof(struct ast_state, Lambda_type), + offsetof(struct ast_state, ListComp_type), + offsetof(struct ast_state, List_type), + offsetof(struct ast_state, Load_singleton), + offsetof(struct ast_state, Load_type), + offsetof(struct ast_state, LtE_singleton), + offsetof(struct ast_state, LtE_type), + offsetof(struct ast_state, Lt_singleton), + offsetof(struct ast_state, Lt_type), + offsetof(struct ast_state, MatMult_singleton), + offsetof(struct ast_state, MatMult_type), + offsetof(struct ast_state, MatchAs_type), + offsetof(struct ast_state, MatchClass_type), + offsetof(struct ast_state, MatchMapping_type), + offsetof(struct ast_state, MatchOr_type), + offsetof(struct ast_state, MatchSequence_type), + offsetof(struct ast_state, MatchSingleton_type), + offsetof(struct ast_state, MatchStar_type), + offsetof(struct ast_state, MatchValue_type), + offsetof(struct ast_state, Match_type), + offsetof(struct ast_state, Mod_singleton), + offsetof(struct ast_state, Mod_type), + offsetof(struct ast_state, Module_type), + offsetof(struct ast_state, Mult_singleton), + offsetof(struct ast_state, Mult_type), + offsetof(struct ast_state, Name_type), + offsetof(struct ast_state, NamedExpr_type), + offsetof(struct ast_state, Nonlocal_type), + offsetof(struct ast_state, NotEq_singleton), + offsetof(struct ast_state, NotEq_type), + offsetof(struct ast_state, NotIn_singleton), + offsetof(struct ast_state, NotIn_type), + offsetof(struct ast_state, Not_singleton), + offsetof(struct ast_state, Not_type), + offsetof(struct ast_state, Or_singleton), + offsetof(struct ast_state, Or_type), + offsetof(struct ast_state, ParamSpec_type), + offsetof(struct ast_state, Pass_type), + offsetof(struct ast_state, Pow_singleton), + offsetof(struct ast_state, Pow_type), + offsetof(struct ast_state, RShift_singleton), + offsetof(struct ast_state, RShift_type), + offsetof(struct ast_state, Raise_type), + offsetof(struct ast_state, Return_type), + offsetof(struct ast_state, SetComp_type), + offsetof(struct ast_state, Set_type), + offsetof(struct ast_state, Slice_type), + offsetof(struct ast_state, Starred_type), + offsetof(struct ast_state, Store_singleton), + offsetof(struct ast_state, Store_type), + offsetof(struct ast_state, Sub_singleton), + offsetof(struct ast_state, Sub_type), + offsetof(struct ast_state, Subscript_type), + offsetof(struct ast_state, TemplateStr_type), + offsetof(struct ast_state, TryStar_type), + offsetof(struct ast_state, Try_type), + offsetof(struct ast_state, Tuple_type), + offsetof(struct ast_state, TypeAlias_type), + offsetof(struct ast_state, TypeIgnore_type), + offsetof(struct ast_state, TypeVarTuple_type), + offsetof(struct ast_state, TypeVar_type), + offsetof(struct ast_state, UAdd_singleton), + offsetof(struct ast_state, UAdd_type), + offsetof(struct ast_state, USub_singleton), + offsetof(struct ast_state, USub_type), + offsetof(struct ast_state, UnaryOp_type), + offsetof(struct ast_state, While_type), + offsetof(struct ast_state, With_type), + offsetof(struct ast_state, YieldFrom_type), + offsetof(struct ast_state, Yield_type), + offsetof(struct ast_state, __dict__), + offsetof(struct ast_state, __doc__), + offsetof(struct ast_state, __match_args__), + offsetof(struct ast_state, __module__), + offsetof(struct ast_state, _attributes), + offsetof(struct ast_state, _fields), + offsetof(struct ast_state, abstract_types), + offsetof(struct ast_state, alias_type), + offsetof(struct ast_state, annotation), + offsetof(struct ast_state, arg), + offsetof(struct ast_state, arg_type), + offsetof(struct ast_state, args), + offsetof(struct ast_state, argtypes), + offsetof(struct ast_state, arguments_type), + offsetof(struct ast_state, asname), + offsetof(struct ast_state, ast), + offsetof(struct ast_state, attr), + offsetof(struct ast_state, bases), + offsetof(struct ast_state, body), + offsetof(struct ast_state, boolop_type), + offsetof(struct ast_state, bound), + offsetof(struct ast_state, cases), + offsetof(struct ast_state, cause), + offsetof(struct ast_state, cls), + offsetof(struct ast_state, cmpop_type), + offsetof(struct ast_state, col_offset), + offsetof(struct ast_state, comparators), + offsetof(struct ast_state, comprehension_type), + offsetof(struct ast_state, context_expr), + offsetof(struct ast_state, conversion), + offsetof(struct ast_state, ctx), + offsetof(struct ast_state, decorator_list), + offsetof(struct ast_state, default_value), + offsetof(struct ast_state, defaults), + offsetof(struct ast_state, elt), + offsetof(struct ast_state, elts), + offsetof(struct ast_state, end_col_offset), + offsetof(struct ast_state, end_lineno), + offsetof(struct ast_state, exc), + offsetof(struct ast_state, excepthandler_type), + offsetof(struct ast_state, expr_context_type), + offsetof(struct ast_state, expr_type), + offsetof(struct ast_state, finalbody), + offsetof(struct ast_state, format_spec), + offsetof(struct ast_state, func), + offsetof(struct ast_state, generators), + offsetof(struct ast_state, guard), + offsetof(struct ast_state, handlers), + offsetof(struct ast_state, id), + offsetof(struct ast_state, ifs), + offsetof(struct ast_state, is_async), + offsetof(struct ast_state, is_lazy), + offsetof(struct ast_state, items), + offsetof(struct ast_state, iter), + offsetof(struct ast_state, key), + offsetof(struct ast_state, keys), + offsetof(struct ast_state, keyword_type), + offsetof(struct ast_state, keywords), + offsetof(struct ast_state, kind), + offsetof(struct ast_state, kw_defaults), + offsetof(struct ast_state, kwarg), + offsetof(struct ast_state, kwd_attrs), + offsetof(struct ast_state, kwd_patterns), + offsetof(struct ast_state, kwonlyargs), + offsetof(struct ast_state, left), + offsetof(struct ast_state, level), + offsetof(struct ast_state, lineno), + offsetof(struct ast_state, lower), + offsetof(struct ast_state, match_case_type), + offsetof(struct ast_state, mod_type), + offsetof(struct ast_state, module), + offsetof(struct ast_state, msg), + offsetof(struct ast_state, name), + offsetof(struct ast_state, names), + offsetof(struct ast_state, op), + offsetof(struct ast_state, operand), + offsetof(struct ast_state, operator_type), + offsetof(struct ast_state, ops), + offsetof(struct ast_state, optional_vars), + offsetof(struct ast_state, orelse), + offsetof(struct ast_state, pattern), + offsetof(struct ast_state, pattern_type), + offsetof(struct ast_state, patterns), + offsetof(struct ast_state, posonlyargs), + offsetof(struct ast_state, rest), + offsetof(struct ast_state, returns), + offsetof(struct ast_state, right), + offsetof(struct ast_state, simple), + offsetof(struct ast_state, slice), + offsetof(struct ast_state, step), + offsetof(struct ast_state, stmt_type), + offsetof(struct ast_state, str), + offsetof(struct ast_state, subject), + offsetof(struct ast_state, tag), + offsetof(struct ast_state, target), + offsetof(struct ast_state, targets), + offsetof(struct ast_state, test), + offsetof(struct ast_state, type), + offsetof(struct ast_state, type_comment), + offsetof(struct ast_state, type_ignore_type), + offsetof(struct ast_state, type_ignores), + offsetof(struct ast_state, type_param_type), + offsetof(struct ast_state, type_params), + offsetof(struct ast_state, unaryop_type), + offsetof(struct ast_state, upper), + offsetof(struct ast_state, value), + offsetof(struct ast_state, values), + offsetof(struct ast_state, vararg), + offsetof(struct ast_state, withitem_type), + }; + + for (size_t i = 0; i < Py_ARRAY_LENGTH(offsets); i++) { + PyObject **field = (PyObject **)((char *)state + offsets[i]); + Py_CLEAR(*field); + } state->finalized = 1; state->once = (_PyOnceFlag){0}; } @@ -633,4538 +639,781 @@ static const char * const Interpolation_fields[]={ "str", "conversion", "format_spec", -}; -static const char * const JoinedStr_fields[]={ - "values", -}; -static const char * const TemplateStr_fields[]={ - "values", -}; -static const char * const Constant_fields[]={ - "value", - "kind", -}; -static const char * const Attribute_fields[]={ - "value", - "attr", - "ctx", -}; -static const char * const Subscript_fields[]={ - "value", - "slice", - "ctx", -}; -static const char * const Starred_fields[]={ - "value", - "ctx", -}; -static const char * const Name_fields[]={ - "id", - "ctx", -}; -static const char * const List_fields[]={ - "elts", - "ctx", -}; -static const char * const Tuple_fields[]={ - "elts", - "ctx", -}; -static const char * const Slice_fields[]={ - "lower", - "upper", - "step", -}; -static PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty); -static PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty); -static PyObject* ast2obj_operator(struct ast_state *state, operator_ty); -static PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty); -static PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty); -static PyObject* ast2obj_comprehension(struct ast_state *state, void*); -static const char * const comprehension_fields[]={ - "target", - "iter", - "ifs", - "is_async", -}; -static const char * const excepthandler_attributes[] = { - "lineno", - "col_offset", - "end_lineno", - "end_col_offset", -}; -static PyObject* ast2obj_excepthandler(struct ast_state *state, void*); -static const char * const ExceptHandler_fields[]={ - "type", - "name", - "body", -}; -static PyObject* ast2obj_arguments(struct ast_state *state, void*); -static const char * const arguments_fields[]={ - "posonlyargs", - "args", - "vararg", - "kwonlyargs", - "kw_defaults", - "kwarg", - "defaults", -}; -static PyObject* ast2obj_arg(struct ast_state *state, void*); -static const char * const arg_attributes[] = { - "lineno", - "col_offset", - "end_lineno", - "end_col_offset", -}; -static const char * const arg_fields[]={ - "arg", - "annotation", - "type_comment", -}; -static PyObject* ast2obj_keyword(struct ast_state *state, void*); -static const char * const keyword_attributes[] = { - "lineno", - "col_offset", - "end_lineno", - "end_col_offset", -}; -static const char * const keyword_fields[]={ - "arg", - "value", -}; -static PyObject* ast2obj_alias(struct ast_state *state, void*); -static const char * const alias_attributes[] = { - "lineno", - "col_offset", - "end_lineno", - "end_col_offset", -}; -static const char * const alias_fields[]={ - "name", - "asname", -}; -static PyObject* ast2obj_withitem(struct ast_state *state, void*); -static const char * const withitem_fields[]={ - "context_expr", - "optional_vars", -}; -static PyObject* ast2obj_match_case(struct ast_state *state, void*); -static const char * const match_case_fields[]={ - "pattern", - "guard", - "body", -}; -static const char * const pattern_attributes[] = { - "lineno", - "col_offset", - "end_lineno", - "end_col_offset", -}; -static PyObject* ast2obj_pattern(struct ast_state *state, void*); -static const char * const MatchValue_fields[]={ - "value", -}; -static const char * const MatchSingleton_fields[]={ - "value", -}; -static const char * const MatchSequence_fields[]={ - "patterns", -}; -static const char * const MatchMapping_fields[]={ - "keys", - "patterns", - "rest", -}; -static const char * const MatchClass_fields[]={ - "cls", - "patterns", - "kwd_attrs", - "kwd_patterns", -}; -static const char * const MatchStar_fields[]={ - "name", -}; -static const char * const MatchAs_fields[]={ - "pattern", - "name", -}; -static const char * const MatchOr_fields[]={ - "patterns", -}; -static PyObject* ast2obj_type_ignore(struct ast_state *state, void*); -static const char * const TypeIgnore_fields[]={ - "lineno", - "tag", -}; -static const char * const type_param_attributes[] = { - "lineno", - "col_offset", - "end_lineno", - "end_col_offset", -}; -static PyObject* ast2obj_type_param(struct ast_state *state, void*); -static const char * const TypeVar_fields[]={ - "name", - "bound", - "default_value", -}; -static const char * const ParamSpec_fields[]={ - "name", - "default_value", -}; -static const char * const TypeVarTuple_fields[]={ - "name", - "default_value", -}; - - -static int -add_ast_annotations(struct ast_state *state) -{ - bool cond; - PyObject *Module_annotations = PyDict_New(); - if (!Module_annotations) return 0; - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Module_annotations); - return 0; - } - cond = PyDict_SetItemString(Module_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Module_annotations); - return 0; - } - } - { - PyObject *type = state->type_ignore_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Module_annotations); - return 0; - } - cond = PyDict_SetItemString(Module_annotations, "type_ignores", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Module_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Module_type, "_field_types", - Module_annotations) == 0; - if (!cond) { - Py_DECREF(Module_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Module_type, "__annotations__", - Module_annotations) == 0; - if (!cond) { - Py_DECREF(Module_annotations); - return 0; - } - Py_DECREF(Module_annotations); - PyObject *Interactive_annotations = PyDict_New(); - if (!Interactive_annotations) return 0; - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Interactive_annotations); - return 0; - } - cond = PyDict_SetItemString(Interactive_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Interactive_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Interactive_type, "_field_types", - Interactive_annotations) == 0; - if (!cond) { - Py_DECREF(Interactive_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Interactive_type, "__annotations__", - Interactive_annotations) == 0; - if (!cond) { - Py_DECREF(Interactive_annotations); - return 0; - } - Py_DECREF(Interactive_annotations); - PyObject *Expression_annotations = PyDict_New(); - if (!Expression_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Expression_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Expression_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Expression_type, "_field_types", - Expression_annotations) == 0; - if (!cond) { - Py_DECREF(Expression_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Expression_type, "__annotations__", - Expression_annotations) == 0; - if (!cond) { - Py_DECREF(Expression_annotations); - return 0; - } - Py_DECREF(Expression_annotations); - PyObject *FunctionType_annotations = PyDict_New(); - if (!FunctionType_annotations) return 0; - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(FunctionType_annotations); - return 0; - } - cond = PyDict_SetItemString(FunctionType_annotations, "argtypes", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(FunctionType_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(FunctionType_annotations, "returns", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(FunctionType_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->FunctionType_type, "_field_types", - FunctionType_annotations) == 0; - if (!cond) { - Py_DECREF(FunctionType_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->FunctionType_type, "__annotations__", - FunctionType_annotations) == 0; - if (!cond) { - Py_DECREF(FunctionType_annotations); - return 0; - } - Py_DECREF(FunctionType_annotations); - PyObject *FunctionDef_annotations = PyDict_New(); - if (!FunctionDef_annotations) return 0; - { - PyObject *type = (PyObject *)&PyUnicode_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(FunctionDef_annotations, "name", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(FunctionDef_annotations); - return 0; - } - } - { - PyObject *type = state->arguments_type; - Py_INCREF(type); - cond = PyDict_SetItemString(FunctionDef_annotations, "args", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(FunctionDef_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(FunctionDef_annotations); - return 0; - } - cond = PyDict_SetItemString(FunctionDef_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(FunctionDef_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(FunctionDef_annotations); - return 0; - } - cond = PyDict_SetItemString(FunctionDef_annotations, "decorator_list", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(FunctionDef_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(FunctionDef_annotations); - return 0; - } - cond = PyDict_SetItemString(FunctionDef_annotations, "returns", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(FunctionDef_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(FunctionDef_annotations); - return 0; - } - cond = PyDict_SetItemString(FunctionDef_annotations, "type_comment", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(FunctionDef_annotations); - return 0; - } - } - { - PyObject *type = state->type_param_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(FunctionDef_annotations); - return 0; - } - cond = PyDict_SetItemString(FunctionDef_annotations, "type_params", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(FunctionDef_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->FunctionDef_type, "_field_types", - FunctionDef_annotations) == 0; - if (!cond) { - Py_DECREF(FunctionDef_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->FunctionDef_type, "__annotations__", - FunctionDef_annotations) == 0; - if (!cond) { - Py_DECREF(FunctionDef_annotations); - return 0; - } - Py_DECREF(FunctionDef_annotations); - PyObject *AsyncFunctionDef_annotations = PyDict_New(); - if (!AsyncFunctionDef_annotations) return 0; - { - PyObject *type = (PyObject *)&PyUnicode_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "name", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AsyncFunctionDef_annotations); - return 0; - } - } - { - PyObject *type = state->arguments_type; - Py_INCREF(type); - cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "args", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AsyncFunctionDef_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(AsyncFunctionDef_annotations); - return 0; - } - cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "body", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AsyncFunctionDef_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(AsyncFunctionDef_annotations); - return 0; - } - cond = PyDict_SetItemString(AsyncFunctionDef_annotations, - "decorator_list", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AsyncFunctionDef_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(AsyncFunctionDef_annotations); - return 0; - } - cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "returns", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AsyncFunctionDef_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(AsyncFunctionDef_annotations); - return 0; - } - cond = PyDict_SetItemString(AsyncFunctionDef_annotations, - "type_comment", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AsyncFunctionDef_annotations); - return 0; - } - } - { - PyObject *type = state->type_param_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(AsyncFunctionDef_annotations); - return 0; - } - cond = PyDict_SetItemString(AsyncFunctionDef_annotations, - "type_params", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AsyncFunctionDef_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->AsyncFunctionDef_type, "_field_types", - AsyncFunctionDef_annotations) == 0; - if (!cond) { - Py_DECREF(AsyncFunctionDef_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->AsyncFunctionDef_type, - "__annotations__", - AsyncFunctionDef_annotations) == 0; - if (!cond) { - Py_DECREF(AsyncFunctionDef_annotations); - return 0; - } - Py_DECREF(AsyncFunctionDef_annotations); - PyObject *ClassDef_annotations = PyDict_New(); - if (!ClassDef_annotations) return 0; - { - PyObject *type = (PyObject *)&PyUnicode_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(ClassDef_annotations, "name", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ClassDef_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(ClassDef_annotations); - return 0; - } - cond = PyDict_SetItemString(ClassDef_annotations, "bases", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ClassDef_annotations); - return 0; - } - } - { - PyObject *type = state->keyword_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(ClassDef_annotations); - return 0; - } - cond = PyDict_SetItemString(ClassDef_annotations, "keywords", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ClassDef_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(ClassDef_annotations); - return 0; - } - cond = PyDict_SetItemString(ClassDef_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ClassDef_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(ClassDef_annotations); - return 0; - } - cond = PyDict_SetItemString(ClassDef_annotations, "decorator_list", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ClassDef_annotations); - return 0; - } - } - { - PyObject *type = state->type_param_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(ClassDef_annotations); - return 0; - } - cond = PyDict_SetItemString(ClassDef_annotations, "type_params", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ClassDef_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->ClassDef_type, "_field_types", - ClassDef_annotations) == 0; - if (!cond) { - Py_DECREF(ClassDef_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->ClassDef_type, "__annotations__", - ClassDef_annotations) == 0; - if (!cond) { - Py_DECREF(ClassDef_annotations); - return 0; - } - Py_DECREF(ClassDef_annotations); - PyObject *Return_annotations = PyDict_New(); - if (!Return_annotations) return 0; - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(Return_annotations); - return 0; - } - cond = PyDict_SetItemString(Return_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Return_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Return_type, "_field_types", - Return_annotations) == 0; - if (!cond) { - Py_DECREF(Return_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Return_type, "__annotations__", - Return_annotations) == 0; - if (!cond) { - Py_DECREF(Return_annotations); - return 0; - } - Py_DECREF(Return_annotations); - PyObject *Delete_annotations = PyDict_New(); - if (!Delete_annotations) return 0; - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Delete_annotations); - return 0; - } - cond = PyDict_SetItemString(Delete_annotations, "targets", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Delete_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Delete_type, "_field_types", - Delete_annotations) == 0; - if (!cond) { - Py_DECREF(Delete_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Delete_type, "__annotations__", - Delete_annotations) == 0; - if (!cond) { - Py_DECREF(Delete_annotations); - return 0; - } - Py_DECREF(Delete_annotations); - PyObject *Assign_annotations = PyDict_New(); - if (!Assign_annotations) return 0; - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Assign_annotations); - return 0; - } - cond = PyDict_SetItemString(Assign_annotations, "targets", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Assign_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Assign_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Assign_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(Assign_annotations); - return 0; - } - cond = PyDict_SetItemString(Assign_annotations, "type_comment", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Assign_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Assign_type, "_field_types", - Assign_annotations) == 0; - if (!cond) { - Py_DECREF(Assign_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Assign_type, "__annotations__", - Assign_annotations) == 0; - if (!cond) { - Py_DECREF(Assign_annotations); - return 0; - } - Py_DECREF(Assign_annotations); - PyObject *TypeAlias_annotations = PyDict_New(); - if (!TypeAlias_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(TypeAlias_annotations, "name", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(TypeAlias_annotations); - return 0; - } - } - { - PyObject *type = state->type_param_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(TypeAlias_annotations); - return 0; - } - cond = PyDict_SetItemString(TypeAlias_annotations, "type_params", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(TypeAlias_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(TypeAlias_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(TypeAlias_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->TypeAlias_type, "_field_types", - TypeAlias_annotations) == 0; - if (!cond) { - Py_DECREF(TypeAlias_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->TypeAlias_type, "__annotations__", - TypeAlias_annotations) == 0; - if (!cond) { - Py_DECREF(TypeAlias_annotations); - return 0; - } - Py_DECREF(TypeAlias_annotations); - PyObject *AugAssign_annotations = PyDict_New(); - if (!AugAssign_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(AugAssign_annotations, "target", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AugAssign_annotations); - return 0; - } - } - { - PyObject *type = state->operator_type; - Py_INCREF(type); - cond = PyDict_SetItemString(AugAssign_annotations, "op", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AugAssign_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(AugAssign_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AugAssign_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->AugAssign_type, "_field_types", - AugAssign_annotations) == 0; - if (!cond) { - Py_DECREF(AugAssign_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->AugAssign_type, "__annotations__", - AugAssign_annotations) == 0; - if (!cond) { - Py_DECREF(AugAssign_annotations); - return 0; - } - Py_DECREF(AugAssign_annotations); - PyObject *AnnAssign_annotations = PyDict_New(); - if (!AnnAssign_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(AnnAssign_annotations, "target", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AnnAssign_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(AnnAssign_annotations, "annotation", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AnnAssign_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(AnnAssign_annotations); - return 0; - } - cond = PyDict_SetItemString(AnnAssign_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AnnAssign_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyLong_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(AnnAssign_annotations, "simple", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AnnAssign_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->AnnAssign_type, "_field_types", - AnnAssign_annotations) == 0; - if (!cond) { - Py_DECREF(AnnAssign_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->AnnAssign_type, "__annotations__", - AnnAssign_annotations) == 0; - if (!cond) { - Py_DECREF(AnnAssign_annotations); - return 0; - } - Py_DECREF(AnnAssign_annotations); - PyObject *For_annotations = PyDict_New(); - if (!For_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(For_annotations, "target", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(For_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(For_annotations, "iter", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(For_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(For_annotations); - return 0; - } - cond = PyDict_SetItemString(For_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(For_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(For_annotations); - return 0; - } - cond = PyDict_SetItemString(For_annotations, "orelse", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(For_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(For_annotations); - return 0; - } - cond = PyDict_SetItemString(For_annotations, "type_comment", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(For_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->For_type, "_field_types", - For_annotations) == 0; - if (!cond) { - Py_DECREF(For_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->For_type, "__annotations__", - For_annotations) == 0; - if (!cond) { - Py_DECREF(For_annotations); - return 0; - } - Py_DECREF(For_annotations); - PyObject *AsyncFor_annotations = PyDict_New(); - if (!AsyncFor_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(AsyncFor_annotations, "target", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AsyncFor_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(AsyncFor_annotations, "iter", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AsyncFor_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(AsyncFor_annotations); - return 0; - } - cond = PyDict_SetItemString(AsyncFor_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AsyncFor_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(AsyncFor_annotations); - return 0; - } - cond = PyDict_SetItemString(AsyncFor_annotations, "orelse", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AsyncFor_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(AsyncFor_annotations); - return 0; - } - cond = PyDict_SetItemString(AsyncFor_annotations, "type_comment", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AsyncFor_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->AsyncFor_type, "_field_types", - AsyncFor_annotations) == 0; - if (!cond) { - Py_DECREF(AsyncFor_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->AsyncFor_type, "__annotations__", - AsyncFor_annotations) == 0; - if (!cond) { - Py_DECREF(AsyncFor_annotations); - return 0; - } - Py_DECREF(AsyncFor_annotations); - PyObject *While_annotations = PyDict_New(); - if (!While_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(While_annotations, "test", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(While_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(While_annotations); - return 0; - } - cond = PyDict_SetItemString(While_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(While_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(While_annotations); - return 0; - } - cond = PyDict_SetItemString(While_annotations, "orelse", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(While_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->While_type, "_field_types", - While_annotations) == 0; - if (!cond) { - Py_DECREF(While_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->While_type, "__annotations__", - While_annotations) == 0; - if (!cond) { - Py_DECREF(While_annotations); - return 0; - } - Py_DECREF(While_annotations); - PyObject *If_annotations = PyDict_New(); - if (!If_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(If_annotations, "test", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(If_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(If_annotations); - return 0; - } - cond = PyDict_SetItemString(If_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(If_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(If_annotations); - return 0; - } - cond = PyDict_SetItemString(If_annotations, "orelse", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(If_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->If_type, "_field_types", - If_annotations) == 0; - if (!cond) { - Py_DECREF(If_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->If_type, "__annotations__", - If_annotations) == 0; - if (!cond) { - Py_DECREF(If_annotations); - return 0; - } - Py_DECREF(If_annotations); - PyObject *With_annotations = PyDict_New(); - if (!With_annotations) return 0; - { - PyObject *type = state->withitem_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(With_annotations); - return 0; - } - cond = PyDict_SetItemString(With_annotations, "items", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(With_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(With_annotations); - return 0; - } - cond = PyDict_SetItemString(With_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(With_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(With_annotations); - return 0; - } - cond = PyDict_SetItemString(With_annotations, "type_comment", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(With_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->With_type, "_field_types", - With_annotations) == 0; - if (!cond) { - Py_DECREF(With_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->With_type, "__annotations__", - With_annotations) == 0; - if (!cond) { - Py_DECREF(With_annotations); - return 0; - } - Py_DECREF(With_annotations); - PyObject *AsyncWith_annotations = PyDict_New(); - if (!AsyncWith_annotations) return 0; - { - PyObject *type = state->withitem_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(AsyncWith_annotations); - return 0; - } - cond = PyDict_SetItemString(AsyncWith_annotations, "items", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AsyncWith_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(AsyncWith_annotations); - return 0; - } - cond = PyDict_SetItemString(AsyncWith_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AsyncWith_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(AsyncWith_annotations); - return 0; - } - cond = PyDict_SetItemString(AsyncWith_annotations, "type_comment", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(AsyncWith_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->AsyncWith_type, "_field_types", - AsyncWith_annotations) == 0; - if (!cond) { - Py_DECREF(AsyncWith_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->AsyncWith_type, "__annotations__", - AsyncWith_annotations) == 0; - if (!cond) { - Py_DECREF(AsyncWith_annotations); - return 0; - } - Py_DECREF(AsyncWith_annotations); - PyObject *Match_annotations = PyDict_New(); - if (!Match_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Match_annotations, "subject", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Match_annotations); - return 0; - } - } - { - PyObject *type = state->match_case_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Match_annotations); - return 0; - } - cond = PyDict_SetItemString(Match_annotations, "cases", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Match_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Match_type, "_field_types", - Match_annotations) == 0; - if (!cond) { - Py_DECREF(Match_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Match_type, "__annotations__", - Match_annotations) == 0; - if (!cond) { - Py_DECREF(Match_annotations); - return 0; - } - Py_DECREF(Match_annotations); - PyObject *Raise_annotations = PyDict_New(); - if (!Raise_annotations) return 0; - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(Raise_annotations); - return 0; - } - cond = PyDict_SetItemString(Raise_annotations, "exc", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Raise_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(Raise_annotations); - return 0; - } - cond = PyDict_SetItemString(Raise_annotations, "cause", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Raise_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Raise_type, "_field_types", - Raise_annotations) == 0; - if (!cond) { - Py_DECREF(Raise_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Raise_type, "__annotations__", - Raise_annotations) == 0; - if (!cond) { - Py_DECREF(Raise_annotations); - return 0; - } - Py_DECREF(Raise_annotations); - PyObject *Try_annotations = PyDict_New(); - if (!Try_annotations) return 0; - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Try_annotations); - return 0; - } - cond = PyDict_SetItemString(Try_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Try_annotations); - return 0; - } - } - { - PyObject *type = state->excepthandler_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Try_annotations); - return 0; - } - cond = PyDict_SetItemString(Try_annotations, "handlers", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Try_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Try_annotations); - return 0; - } - cond = PyDict_SetItemString(Try_annotations, "orelse", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Try_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Try_annotations); - return 0; - } - cond = PyDict_SetItemString(Try_annotations, "finalbody", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Try_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Try_type, "_field_types", - Try_annotations) == 0; - if (!cond) { - Py_DECREF(Try_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Try_type, "__annotations__", - Try_annotations) == 0; - if (!cond) { - Py_DECREF(Try_annotations); - return 0; - } - Py_DECREF(Try_annotations); - PyObject *TryStar_annotations = PyDict_New(); - if (!TryStar_annotations) return 0; - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(TryStar_annotations); - return 0; - } - cond = PyDict_SetItemString(TryStar_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(TryStar_annotations); - return 0; - } - } - { - PyObject *type = state->excepthandler_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(TryStar_annotations); - return 0; - } - cond = PyDict_SetItemString(TryStar_annotations, "handlers", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(TryStar_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(TryStar_annotations); - return 0; - } - cond = PyDict_SetItemString(TryStar_annotations, "orelse", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(TryStar_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(TryStar_annotations); - return 0; - } - cond = PyDict_SetItemString(TryStar_annotations, "finalbody", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(TryStar_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->TryStar_type, "_field_types", - TryStar_annotations) == 0; - if (!cond) { - Py_DECREF(TryStar_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->TryStar_type, "__annotations__", - TryStar_annotations) == 0; - if (!cond) { - Py_DECREF(TryStar_annotations); - return 0; - } - Py_DECREF(TryStar_annotations); - PyObject *Assert_annotations = PyDict_New(); - if (!Assert_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Assert_annotations, "test", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Assert_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(Assert_annotations); - return 0; - } - cond = PyDict_SetItemString(Assert_annotations, "msg", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Assert_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Assert_type, "_field_types", - Assert_annotations) == 0; - if (!cond) { - Py_DECREF(Assert_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Assert_type, "__annotations__", - Assert_annotations) == 0; - if (!cond) { - Py_DECREF(Assert_annotations); - return 0; - } - Py_DECREF(Assert_annotations); - PyObject *Import_annotations = PyDict_New(); - if (!Import_annotations) return 0; - { - PyObject *type = state->alias_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Import_annotations); - return 0; - } - cond = PyDict_SetItemString(Import_annotations, "names", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Import_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyLong_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(Import_annotations); - return 0; - } - cond = PyDict_SetItemString(Import_annotations, "is_lazy", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Import_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Import_type, "_field_types", - Import_annotations) == 0; - if (!cond) { - Py_DECREF(Import_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Import_type, "__annotations__", - Import_annotations) == 0; - if (!cond) { - Py_DECREF(Import_annotations); - return 0; - } - Py_DECREF(Import_annotations); - PyObject *ImportFrom_annotations = PyDict_New(); - if (!ImportFrom_annotations) return 0; - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(ImportFrom_annotations); - return 0; - } - cond = PyDict_SetItemString(ImportFrom_annotations, "module", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ImportFrom_annotations); - return 0; - } - } - { - PyObject *type = state->alias_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(ImportFrom_annotations); - return 0; - } - cond = PyDict_SetItemString(ImportFrom_annotations, "names", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ImportFrom_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyLong_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(ImportFrom_annotations); - return 0; - } - cond = PyDict_SetItemString(ImportFrom_annotations, "level", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ImportFrom_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyLong_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(ImportFrom_annotations); - return 0; - } - cond = PyDict_SetItemString(ImportFrom_annotations, "is_lazy", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ImportFrom_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->ImportFrom_type, "_field_types", - ImportFrom_annotations) == 0; - if (!cond) { - Py_DECREF(ImportFrom_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->ImportFrom_type, "__annotations__", - ImportFrom_annotations) == 0; - if (!cond) { - Py_DECREF(ImportFrom_annotations); - return 0; - } - Py_DECREF(ImportFrom_annotations); - PyObject *Global_annotations = PyDict_New(); - if (!Global_annotations) return 0; - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Global_annotations); - return 0; - } - cond = PyDict_SetItemString(Global_annotations, "names", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Global_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Global_type, "_field_types", - Global_annotations) == 0; - if (!cond) { - Py_DECREF(Global_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Global_type, "__annotations__", - Global_annotations) == 0; - if (!cond) { - Py_DECREF(Global_annotations); - return 0; - } - Py_DECREF(Global_annotations); - PyObject *Nonlocal_annotations = PyDict_New(); - if (!Nonlocal_annotations) return 0; - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Nonlocal_annotations); - return 0; - } - cond = PyDict_SetItemString(Nonlocal_annotations, "names", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Nonlocal_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Nonlocal_type, "_field_types", - Nonlocal_annotations) == 0; - if (!cond) { - Py_DECREF(Nonlocal_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Nonlocal_type, "__annotations__", - Nonlocal_annotations) == 0; - if (!cond) { - Py_DECREF(Nonlocal_annotations); - return 0; - } - Py_DECREF(Nonlocal_annotations); - PyObject *Expr_annotations = PyDict_New(); - if (!Expr_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Expr_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Expr_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Expr_type, "_field_types", - Expr_annotations) == 0; - if (!cond) { - Py_DECREF(Expr_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Expr_type, "__annotations__", - Expr_annotations) == 0; - if (!cond) { - Py_DECREF(Expr_annotations); - return 0; - } - Py_DECREF(Expr_annotations); - PyObject *Pass_annotations = PyDict_New(); - if (!Pass_annotations) return 0; - cond = PyObject_SetAttrString(state->Pass_type, "_field_types", - Pass_annotations) == 0; - if (!cond) { - Py_DECREF(Pass_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Pass_type, "__annotations__", - Pass_annotations) == 0; - if (!cond) { - Py_DECREF(Pass_annotations); - return 0; - } - Py_DECREF(Pass_annotations); - PyObject *Break_annotations = PyDict_New(); - if (!Break_annotations) return 0; - cond = PyObject_SetAttrString(state->Break_type, "_field_types", - Break_annotations) == 0; - if (!cond) { - Py_DECREF(Break_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Break_type, "__annotations__", - Break_annotations) == 0; - if (!cond) { - Py_DECREF(Break_annotations); - return 0; - } - Py_DECREF(Break_annotations); - PyObject *Continue_annotations = PyDict_New(); - if (!Continue_annotations) return 0; - cond = PyObject_SetAttrString(state->Continue_type, "_field_types", - Continue_annotations) == 0; - if (!cond) { - Py_DECREF(Continue_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Continue_type, "__annotations__", - Continue_annotations) == 0; - if (!cond) { - Py_DECREF(Continue_annotations); - return 0; - } - Py_DECREF(Continue_annotations); - PyObject *BoolOp_annotations = PyDict_New(); - if (!BoolOp_annotations) return 0; - { - PyObject *type = state->boolop_type; - Py_INCREF(type); - cond = PyDict_SetItemString(BoolOp_annotations, "op", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(BoolOp_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(BoolOp_annotations); - return 0; - } - cond = PyDict_SetItemString(BoolOp_annotations, "values", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(BoolOp_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->BoolOp_type, "_field_types", - BoolOp_annotations) == 0; - if (!cond) { - Py_DECREF(BoolOp_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->BoolOp_type, "__annotations__", - BoolOp_annotations) == 0; - if (!cond) { - Py_DECREF(BoolOp_annotations); - return 0; - } - Py_DECREF(BoolOp_annotations); - PyObject *NamedExpr_annotations = PyDict_New(); - if (!NamedExpr_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(NamedExpr_annotations, "target", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(NamedExpr_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(NamedExpr_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(NamedExpr_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->NamedExpr_type, "_field_types", - NamedExpr_annotations) == 0; - if (!cond) { - Py_DECREF(NamedExpr_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->NamedExpr_type, "__annotations__", - NamedExpr_annotations) == 0; - if (!cond) { - Py_DECREF(NamedExpr_annotations); - return 0; - } - Py_DECREF(NamedExpr_annotations); - PyObject *BinOp_annotations = PyDict_New(); - if (!BinOp_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(BinOp_annotations, "left", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(BinOp_annotations); - return 0; - } - } - { - PyObject *type = state->operator_type; - Py_INCREF(type); - cond = PyDict_SetItemString(BinOp_annotations, "op", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(BinOp_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(BinOp_annotations, "right", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(BinOp_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->BinOp_type, "_field_types", - BinOp_annotations) == 0; - if (!cond) { - Py_DECREF(BinOp_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->BinOp_type, "__annotations__", - BinOp_annotations) == 0; - if (!cond) { - Py_DECREF(BinOp_annotations); - return 0; - } - Py_DECREF(BinOp_annotations); - PyObject *UnaryOp_annotations = PyDict_New(); - if (!UnaryOp_annotations) return 0; - { - PyObject *type = state->unaryop_type; - Py_INCREF(type); - cond = PyDict_SetItemString(UnaryOp_annotations, "op", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(UnaryOp_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(UnaryOp_annotations, "operand", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(UnaryOp_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->UnaryOp_type, "_field_types", - UnaryOp_annotations) == 0; - if (!cond) { - Py_DECREF(UnaryOp_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->UnaryOp_type, "__annotations__", - UnaryOp_annotations) == 0; - if (!cond) { - Py_DECREF(UnaryOp_annotations); - return 0; - } - Py_DECREF(UnaryOp_annotations); - PyObject *Lambda_annotations = PyDict_New(); - if (!Lambda_annotations) return 0; - { - PyObject *type = state->arguments_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Lambda_annotations, "args", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Lambda_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Lambda_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Lambda_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Lambda_type, "_field_types", - Lambda_annotations) == 0; - if (!cond) { - Py_DECREF(Lambda_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Lambda_type, "__annotations__", - Lambda_annotations) == 0; - if (!cond) { - Py_DECREF(Lambda_annotations); - return 0; - } - Py_DECREF(Lambda_annotations); - PyObject *IfExp_annotations = PyDict_New(); - if (!IfExp_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(IfExp_annotations, "test", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(IfExp_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(IfExp_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(IfExp_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(IfExp_annotations, "orelse", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(IfExp_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->IfExp_type, "_field_types", - IfExp_annotations) == 0; - if (!cond) { - Py_DECREF(IfExp_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->IfExp_type, "__annotations__", - IfExp_annotations) == 0; - if (!cond) { - Py_DECREF(IfExp_annotations); - return 0; - } - Py_DECREF(IfExp_annotations); - PyObject *Dict_annotations = PyDict_New(); - if (!Dict_annotations) return 0; - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Dict_annotations); - return 0; - } - cond = PyDict_SetItemString(Dict_annotations, "keys", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Dict_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Dict_annotations); - return 0; - } - cond = PyDict_SetItemString(Dict_annotations, "values", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Dict_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Dict_type, "_field_types", - Dict_annotations) == 0; - if (!cond) { - Py_DECREF(Dict_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Dict_type, "__annotations__", - Dict_annotations) == 0; - if (!cond) { - Py_DECREF(Dict_annotations); - return 0; - } - Py_DECREF(Dict_annotations); - PyObject *Set_annotations = PyDict_New(); - if (!Set_annotations) return 0; - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Set_annotations); - return 0; - } - cond = PyDict_SetItemString(Set_annotations, "elts", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Set_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Set_type, "_field_types", - Set_annotations) == 0; - if (!cond) { - Py_DECREF(Set_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Set_type, "__annotations__", - Set_annotations) == 0; - if (!cond) { - Py_DECREF(Set_annotations); - return 0; - } - Py_DECREF(Set_annotations); - PyObject *ListComp_annotations = PyDict_New(); - if (!ListComp_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(ListComp_annotations, "elt", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ListComp_annotations); - return 0; - } - } - { - PyObject *type = state->comprehension_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(ListComp_annotations); - return 0; - } - cond = PyDict_SetItemString(ListComp_annotations, "generators", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ListComp_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->ListComp_type, "_field_types", - ListComp_annotations) == 0; - if (!cond) { - Py_DECREF(ListComp_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->ListComp_type, "__annotations__", - ListComp_annotations) == 0; - if (!cond) { - Py_DECREF(ListComp_annotations); - return 0; - } - Py_DECREF(ListComp_annotations); - PyObject *SetComp_annotations = PyDict_New(); - if (!SetComp_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(SetComp_annotations, "elt", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(SetComp_annotations); - return 0; - } - } - { - PyObject *type = state->comprehension_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(SetComp_annotations); - return 0; - } - cond = PyDict_SetItemString(SetComp_annotations, "generators", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(SetComp_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->SetComp_type, "_field_types", - SetComp_annotations) == 0; - if (!cond) { - Py_DECREF(SetComp_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->SetComp_type, "__annotations__", - SetComp_annotations) == 0; - if (!cond) { - Py_DECREF(SetComp_annotations); - return 0; - } - Py_DECREF(SetComp_annotations); - PyObject *DictComp_annotations = PyDict_New(); - if (!DictComp_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(DictComp_annotations, "key", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(DictComp_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(DictComp_annotations); - return 0; - } - cond = PyDict_SetItemString(DictComp_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(DictComp_annotations); - return 0; - } - } - { - PyObject *type = state->comprehension_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(DictComp_annotations); - return 0; - } - cond = PyDict_SetItemString(DictComp_annotations, "generators", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(DictComp_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->DictComp_type, "_field_types", - DictComp_annotations) == 0; - if (!cond) { - Py_DECREF(DictComp_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->DictComp_type, "__annotations__", - DictComp_annotations) == 0; - if (!cond) { - Py_DECREF(DictComp_annotations); - return 0; - } - Py_DECREF(DictComp_annotations); - PyObject *GeneratorExp_annotations = PyDict_New(); - if (!GeneratorExp_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(GeneratorExp_annotations, "elt", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(GeneratorExp_annotations); - return 0; - } - } - { - PyObject *type = state->comprehension_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(GeneratorExp_annotations); - return 0; - } - cond = PyDict_SetItemString(GeneratorExp_annotations, "generators", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(GeneratorExp_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->GeneratorExp_type, "_field_types", - GeneratorExp_annotations) == 0; - if (!cond) { - Py_DECREF(GeneratorExp_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->GeneratorExp_type, "__annotations__", - GeneratorExp_annotations) == 0; - if (!cond) { - Py_DECREF(GeneratorExp_annotations); - return 0; - } - Py_DECREF(GeneratorExp_annotations); - PyObject *Await_annotations = PyDict_New(); - if (!Await_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Await_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Await_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Await_type, "_field_types", - Await_annotations) == 0; - if (!cond) { - Py_DECREF(Await_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Await_type, "__annotations__", - Await_annotations) == 0; - if (!cond) { - Py_DECREF(Await_annotations); - return 0; - } - Py_DECREF(Await_annotations); - PyObject *Yield_annotations = PyDict_New(); - if (!Yield_annotations) return 0; - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(Yield_annotations); - return 0; - } - cond = PyDict_SetItemString(Yield_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Yield_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Yield_type, "_field_types", - Yield_annotations) == 0; - if (!cond) { - Py_DECREF(Yield_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Yield_type, "__annotations__", - Yield_annotations) == 0; - if (!cond) { - Py_DECREF(Yield_annotations); - return 0; - } - Py_DECREF(Yield_annotations); - PyObject *YieldFrom_annotations = PyDict_New(); - if (!YieldFrom_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(YieldFrom_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(YieldFrom_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->YieldFrom_type, "_field_types", - YieldFrom_annotations) == 0; - if (!cond) { - Py_DECREF(YieldFrom_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->YieldFrom_type, "__annotations__", - YieldFrom_annotations) == 0; - if (!cond) { - Py_DECREF(YieldFrom_annotations); - return 0; - } - Py_DECREF(YieldFrom_annotations); - PyObject *Compare_annotations = PyDict_New(); - if (!Compare_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Compare_annotations, "left", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Compare_annotations); - return 0; - } - } - { - PyObject *type = state->cmpop_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Compare_annotations); - return 0; - } - cond = PyDict_SetItemString(Compare_annotations, "ops", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Compare_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Compare_annotations); - return 0; - } - cond = PyDict_SetItemString(Compare_annotations, "comparators", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Compare_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Compare_type, "_field_types", - Compare_annotations) == 0; - if (!cond) { - Py_DECREF(Compare_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Compare_type, "__annotations__", - Compare_annotations) == 0; - if (!cond) { - Py_DECREF(Compare_annotations); - return 0; - } - Py_DECREF(Compare_annotations); - PyObject *Call_annotations = PyDict_New(); - if (!Call_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Call_annotations, "func", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Call_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Call_annotations); - return 0; - } - cond = PyDict_SetItemString(Call_annotations, "args", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Call_annotations); - return 0; - } - } - { - PyObject *type = state->keyword_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Call_annotations); - return 0; - } - cond = PyDict_SetItemString(Call_annotations, "keywords", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Call_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Call_type, "_field_types", - Call_annotations) == 0; - if (!cond) { - Py_DECREF(Call_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Call_type, "__annotations__", - Call_annotations) == 0; - if (!cond) { - Py_DECREF(Call_annotations); - return 0; - } - Py_DECREF(Call_annotations); - PyObject *FormattedValue_annotations = PyDict_New(); - if (!FormattedValue_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(FormattedValue_annotations, "value", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(FormattedValue_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyLong_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(FormattedValue_annotations, "conversion", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(FormattedValue_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(FormattedValue_annotations); - return 0; - } - cond = PyDict_SetItemString(FormattedValue_annotations, "format_spec", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(FormattedValue_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->FormattedValue_type, "_field_types", - FormattedValue_annotations) == 0; - if (!cond) { - Py_DECREF(FormattedValue_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->FormattedValue_type, - "__annotations__", - FormattedValue_annotations) == 0; - if (!cond) { - Py_DECREF(FormattedValue_annotations); - return 0; - } - Py_DECREF(FormattedValue_annotations); - PyObject *Interpolation_annotations = PyDict_New(); - if (!Interpolation_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Interpolation_annotations, "value", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Interpolation_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyBaseObject_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(Interpolation_annotations, "str", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Interpolation_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyLong_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(Interpolation_annotations, "conversion", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Interpolation_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(Interpolation_annotations); - return 0; - } - cond = PyDict_SetItemString(Interpolation_annotations, "format_spec", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Interpolation_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Interpolation_type, "_field_types", - Interpolation_annotations) == 0; - if (!cond) { - Py_DECREF(Interpolation_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Interpolation_type, "__annotations__", - Interpolation_annotations) == 0; - if (!cond) { - Py_DECREF(Interpolation_annotations); - return 0; - } - Py_DECREF(Interpolation_annotations); - PyObject *JoinedStr_annotations = PyDict_New(); - if (!JoinedStr_annotations) return 0; - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(JoinedStr_annotations); - return 0; - } - cond = PyDict_SetItemString(JoinedStr_annotations, "values", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(JoinedStr_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->JoinedStr_type, "_field_types", - JoinedStr_annotations) == 0; - if (!cond) { - Py_DECREF(JoinedStr_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->JoinedStr_type, "__annotations__", - JoinedStr_annotations) == 0; - if (!cond) { - Py_DECREF(JoinedStr_annotations); - return 0; - } - Py_DECREF(JoinedStr_annotations); - PyObject *TemplateStr_annotations = PyDict_New(); - if (!TemplateStr_annotations) return 0; - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(TemplateStr_annotations); - return 0; - } - cond = PyDict_SetItemString(TemplateStr_annotations, "values", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(TemplateStr_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->TemplateStr_type, "_field_types", - TemplateStr_annotations) == 0; - if (!cond) { - Py_DECREF(TemplateStr_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->TemplateStr_type, "__annotations__", - TemplateStr_annotations) == 0; - if (!cond) { - Py_DECREF(TemplateStr_annotations); - return 0; - } - Py_DECREF(TemplateStr_annotations); - PyObject *Constant_annotations = PyDict_New(); - if (!Constant_annotations) return 0; - { - PyObject *type = (PyObject *)&PyBaseObject_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(Constant_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Constant_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(Constant_annotations); - return 0; - } - cond = PyDict_SetItemString(Constant_annotations, "kind", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Constant_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Constant_type, "_field_types", - Constant_annotations) == 0; - if (!cond) { - Py_DECREF(Constant_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Constant_type, "__annotations__", - Constant_annotations) == 0; - if (!cond) { - Py_DECREF(Constant_annotations); - return 0; - } - Py_DECREF(Constant_annotations); - PyObject *Attribute_annotations = PyDict_New(); - if (!Attribute_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Attribute_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Attribute_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(Attribute_annotations, "attr", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Attribute_annotations); - return 0; - } - } - { - PyObject *type = state->expr_context_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Attribute_annotations, "ctx", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Attribute_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Attribute_type, "_field_types", - Attribute_annotations) == 0; - if (!cond) { - Py_DECREF(Attribute_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Attribute_type, "__annotations__", - Attribute_annotations) == 0; - if (!cond) { - Py_DECREF(Attribute_annotations); - return 0; - } - Py_DECREF(Attribute_annotations); - PyObject *Subscript_annotations = PyDict_New(); - if (!Subscript_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Subscript_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Subscript_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Subscript_annotations, "slice", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Subscript_annotations); - return 0; - } - } - { - PyObject *type = state->expr_context_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Subscript_annotations, "ctx", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Subscript_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Subscript_type, "_field_types", - Subscript_annotations) == 0; - if (!cond) { - Py_DECREF(Subscript_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Subscript_type, "__annotations__", - Subscript_annotations) == 0; - if (!cond) { - Py_DECREF(Subscript_annotations); - return 0; - } - Py_DECREF(Subscript_annotations); - PyObject *Starred_annotations = PyDict_New(); - if (!Starred_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Starred_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Starred_annotations); - return 0; - } - } - { - PyObject *type = state->expr_context_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Starred_annotations, "ctx", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Starred_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Starred_type, "_field_types", - Starred_annotations) == 0; - if (!cond) { - Py_DECREF(Starred_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Starred_type, "__annotations__", - Starred_annotations) == 0; - if (!cond) { - Py_DECREF(Starred_annotations); - return 0; - } - Py_DECREF(Starred_annotations); - PyObject *Name_annotations = PyDict_New(); - if (!Name_annotations) return 0; - { - PyObject *type = (PyObject *)&PyUnicode_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(Name_annotations, "id", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Name_annotations); - return 0; - } - } - { - PyObject *type = state->expr_context_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Name_annotations, "ctx", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Name_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Name_type, "_field_types", - Name_annotations) == 0; - if (!cond) { - Py_DECREF(Name_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Name_type, "__annotations__", - Name_annotations) == 0; - if (!cond) { - Py_DECREF(Name_annotations); - return 0; - } - Py_DECREF(Name_annotations); - PyObject *List_annotations = PyDict_New(); - if (!List_annotations) return 0; - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(List_annotations); - return 0; - } - cond = PyDict_SetItemString(List_annotations, "elts", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(List_annotations); - return 0; - } - } - { - PyObject *type = state->expr_context_type; - Py_INCREF(type); - cond = PyDict_SetItemString(List_annotations, "ctx", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(List_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->List_type, "_field_types", - List_annotations) == 0; - if (!cond) { - Py_DECREF(List_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->List_type, "__annotations__", - List_annotations) == 0; - if (!cond) { - Py_DECREF(List_annotations); - return 0; - } - Py_DECREF(List_annotations); - PyObject *Tuple_annotations = PyDict_New(); - if (!Tuple_annotations) return 0; - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(Tuple_annotations); - return 0; - } - cond = PyDict_SetItemString(Tuple_annotations, "elts", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Tuple_annotations); - return 0; - } - } - { - PyObject *type = state->expr_context_type; - Py_INCREF(type); - cond = PyDict_SetItemString(Tuple_annotations, "ctx", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Tuple_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Tuple_type, "_field_types", - Tuple_annotations) == 0; - if (!cond) { - Py_DECREF(Tuple_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Tuple_type, "__annotations__", - Tuple_annotations) == 0; - if (!cond) { - Py_DECREF(Tuple_annotations); - return 0; - } - Py_DECREF(Tuple_annotations); - PyObject *Slice_annotations = PyDict_New(); - if (!Slice_annotations) return 0; - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(Slice_annotations); - return 0; - } - cond = PyDict_SetItemString(Slice_annotations, "lower", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Slice_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(Slice_annotations); - return 0; - } - cond = PyDict_SetItemString(Slice_annotations, "upper", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Slice_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(Slice_annotations); - return 0; - } - cond = PyDict_SetItemString(Slice_annotations, "step", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(Slice_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->Slice_type, "_field_types", - Slice_annotations) == 0; - if (!cond) { - Py_DECREF(Slice_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Slice_type, "__annotations__", - Slice_annotations) == 0; - if (!cond) { - Py_DECREF(Slice_annotations); - return 0; - } - Py_DECREF(Slice_annotations); - PyObject *Load_annotations = PyDict_New(); - if (!Load_annotations) return 0; - cond = PyObject_SetAttrString(state->Load_type, "_field_types", - Load_annotations) == 0; - if (!cond) { - Py_DECREF(Load_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Load_type, "__annotations__", - Load_annotations) == 0; - if (!cond) { - Py_DECREF(Load_annotations); - return 0; - } - Py_DECREF(Load_annotations); - PyObject *Store_annotations = PyDict_New(); - if (!Store_annotations) return 0; - cond = PyObject_SetAttrString(state->Store_type, "_field_types", - Store_annotations) == 0; - if (!cond) { - Py_DECREF(Store_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Store_type, "__annotations__", - Store_annotations) == 0; - if (!cond) { - Py_DECREF(Store_annotations); - return 0; - } - Py_DECREF(Store_annotations); - PyObject *Del_annotations = PyDict_New(); - if (!Del_annotations) return 0; - cond = PyObject_SetAttrString(state->Del_type, "_field_types", - Del_annotations) == 0; - if (!cond) { - Py_DECREF(Del_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Del_type, "__annotations__", - Del_annotations) == 0; - if (!cond) { - Py_DECREF(Del_annotations); - return 0; - } - Py_DECREF(Del_annotations); - PyObject *And_annotations = PyDict_New(); - if (!And_annotations) return 0; - cond = PyObject_SetAttrString(state->And_type, "_field_types", - And_annotations) == 0; - if (!cond) { - Py_DECREF(And_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->And_type, "__annotations__", - And_annotations) == 0; - if (!cond) { - Py_DECREF(And_annotations); - return 0; - } - Py_DECREF(And_annotations); - PyObject *Or_annotations = PyDict_New(); - if (!Or_annotations) return 0; - cond = PyObject_SetAttrString(state->Or_type, "_field_types", - Or_annotations) == 0; - if (!cond) { - Py_DECREF(Or_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Or_type, "__annotations__", - Or_annotations) == 0; - if (!cond) { - Py_DECREF(Or_annotations); - return 0; - } - Py_DECREF(Or_annotations); - PyObject *Add_annotations = PyDict_New(); - if (!Add_annotations) return 0; - cond = PyObject_SetAttrString(state->Add_type, "_field_types", - Add_annotations) == 0; - if (!cond) { - Py_DECREF(Add_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Add_type, "__annotations__", - Add_annotations) == 0; - if (!cond) { - Py_DECREF(Add_annotations); - return 0; - } - Py_DECREF(Add_annotations); - PyObject *Sub_annotations = PyDict_New(); - if (!Sub_annotations) return 0; - cond = PyObject_SetAttrString(state->Sub_type, "_field_types", - Sub_annotations) == 0; - if (!cond) { - Py_DECREF(Sub_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Sub_type, "__annotations__", - Sub_annotations) == 0; - if (!cond) { - Py_DECREF(Sub_annotations); - return 0; - } - Py_DECREF(Sub_annotations); - PyObject *Mult_annotations = PyDict_New(); - if (!Mult_annotations) return 0; - cond = PyObject_SetAttrString(state->Mult_type, "_field_types", - Mult_annotations) == 0; - if (!cond) { - Py_DECREF(Mult_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Mult_type, "__annotations__", - Mult_annotations) == 0; - if (!cond) { - Py_DECREF(Mult_annotations); - return 0; - } - Py_DECREF(Mult_annotations); - PyObject *MatMult_annotations = PyDict_New(); - if (!MatMult_annotations) return 0; - cond = PyObject_SetAttrString(state->MatMult_type, "_field_types", - MatMult_annotations) == 0; - if (!cond) { - Py_DECREF(MatMult_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->MatMult_type, "__annotations__", - MatMult_annotations) == 0; - if (!cond) { - Py_DECREF(MatMult_annotations); - return 0; - } - Py_DECREF(MatMult_annotations); - PyObject *Div_annotations = PyDict_New(); - if (!Div_annotations) return 0; - cond = PyObject_SetAttrString(state->Div_type, "_field_types", - Div_annotations) == 0; - if (!cond) { - Py_DECREF(Div_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Div_type, "__annotations__", - Div_annotations) == 0; - if (!cond) { - Py_DECREF(Div_annotations); - return 0; - } - Py_DECREF(Div_annotations); - PyObject *Mod_annotations = PyDict_New(); - if (!Mod_annotations) return 0; - cond = PyObject_SetAttrString(state->Mod_type, "_field_types", - Mod_annotations) == 0; - if (!cond) { - Py_DECREF(Mod_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Mod_type, "__annotations__", - Mod_annotations) == 0; - if (!cond) { - Py_DECREF(Mod_annotations); - return 0; - } - Py_DECREF(Mod_annotations); - PyObject *Pow_annotations = PyDict_New(); - if (!Pow_annotations) return 0; - cond = PyObject_SetAttrString(state->Pow_type, "_field_types", - Pow_annotations) == 0; - if (!cond) { - Py_DECREF(Pow_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Pow_type, "__annotations__", - Pow_annotations) == 0; - if (!cond) { - Py_DECREF(Pow_annotations); - return 0; - } - Py_DECREF(Pow_annotations); - PyObject *LShift_annotations = PyDict_New(); - if (!LShift_annotations) return 0; - cond = PyObject_SetAttrString(state->LShift_type, "_field_types", - LShift_annotations) == 0; - if (!cond) { - Py_DECREF(LShift_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->LShift_type, "__annotations__", - LShift_annotations) == 0; - if (!cond) { - Py_DECREF(LShift_annotations); - return 0; - } - Py_DECREF(LShift_annotations); - PyObject *RShift_annotations = PyDict_New(); - if (!RShift_annotations) return 0; - cond = PyObject_SetAttrString(state->RShift_type, "_field_types", - RShift_annotations) == 0; - if (!cond) { - Py_DECREF(RShift_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->RShift_type, "__annotations__", - RShift_annotations) == 0; - if (!cond) { - Py_DECREF(RShift_annotations); - return 0; - } - Py_DECREF(RShift_annotations); - PyObject *BitOr_annotations = PyDict_New(); - if (!BitOr_annotations) return 0; - cond = PyObject_SetAttrString(state->BitOr_type, "_field_types", - BitOr_annotations) == 0; - if (!cond) { - Py_DECREF(BitOr_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->BitOr_type, "__annotations__", - BitOr_annotations) == 0; - if (!cond) { - Py_DECREF(BitOr_annotations); - return 0; - } - Py_DECREF(BitOr_annotations); - PyObject *BitXor_annotations = PyDict_New(); - if (!BitXor_annotations) return 0; - cond = PyObject_SetAttrString(state->BitXor_type, "_field_types", - BitXor_annotations) == 0; - if (!cond) { - Py_DECREF(BitXor_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->BitXor_type, "__annotations__", - BitXor_annotations) == 0; - if (!cond) { - Py_DECREF(BitXor_annotations); - return 0; - } - Py_DECREF(BitXor_annotations); - PyObject *BitAnd_annotations = PyDict_New(); - if (!BitAnd_annotations) return 0; - cond = PyObject_SetAttrString(state->BitAnd_type, "_field_types", - BitAnd_annotations) == 0; - if (!cond) { - Py_DECREF(BitAnd_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->BitAnd_type, "__annotations__", - BitAnd_annotations) == 0; - if (!cond) { - Py_DECREF(BitAnd_annotations); - return 0; - } - Py_DECREF(BitAnd_annotations); - PyObject *FloorDiv_annotations = PyDict_New(); - if (!FloorDiv_annotations) return 0; - cond = PyObject_SetAttrString(state->FloorDiv_type, "_field_types", - FloorDiv_annotations) == 0; - if (!cond) { - Py_DECREF(FloorDiv_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->FloorDiv_type, "__annotations__", - FloorDiv_annotations) == 0; - if (!cond) { - Py_DECREF(FloorDiv_annotations); - return 0; - } - Py_DECREF(FloorDiv_annotations); - PyObject *Invert_annotations = PyDict_New(); - if (!Invert_annotations) return 0; - cond = PyObject_SetAttrString(state->Invert_type, "_field_types", - Invert_annotations) == 0; - if (!cond) { - Py_DECREF(Invert_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Invert_type, "__annotations__", - Invert_annotations) == 0; - if (!cond) { - Py_DECREF(Invert_annotations); - return 0; - } - Py_DECREF(Invert_annotations); - PyObject *Not_annotations = PyDict_New(); - if (!Not_annotations) return 0; - cond = PyObject_SetAttrString(state->Not_type, "_field_types", - Not_annotations) == 0; - if (!cond) { - Py_DECREF(Not_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Not_type, "__annotations__", - Not_annotations) == 0; - if (!cond) { - Py_DECREF(Not_annotations); - return 0; - } - Py_DECREF(Not_annotations); - PyObject *UAdd_annotations = PyDict_New(); - if (!UAdd_annotations) return 0; - cond = PyObject_SetAttrString(state->UAdd_type, "_field_types", - UAdd_annotations) == 0; - if (!cond) { - Py_DECREF(UAdd_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->UAdd_type, "__annotations__", - UAdd_annotations) == 0; - if (!cond) { - Py_DECREF(UAdd_annotations); - return 0; - } - Py_DECREF(UAdd_annotations); - PyObject *USub_annotations = PyDict_New(); - if (!USub_annotations) return 0; - cond = PyObject_SetAttrString(state->USub_type, "_field_types", - USub_annotations) == 0; - if (!cond) { - Py_DECREF(USub_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->USub_type, "__annotations__", - USub_annotations) == 0; - if (!cond) { - Py_DECREF(USub_annotations); - return 0; - } - Py_DECREF(USub_annotations); - PyObject *Eq_annotations = PyDict_New(); - if (!Eq_annotations) return 0; - cond = PyObject_SetAttrString(state->Eq_type, "_field_types", - Eq_annotations) == 0; - if (!cond) { - Py_DECREF(Eq_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Eq_type, "__annotations__", - Eq_annotations) == 0; - if (!cond) { - Py_DECREF(Eq_annotations); - return 0; - } - Py_DECREF(Eq_annotations); - PyObject *NotEq_annotations = PyDict_New(); - if (!NotEq_annotations) return 0; - cond = PyObject_SetAttrString(state->NotEq_type, "_field_types", - NotEq_annotations) == 0; - if (!cond) { - Py_DECREF(NotEq_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->NotEq_type, "__annotations__", - NotEq_annotations) == 0; - if (!cond) { - Py_DECREF(NotEq_annotations); - return 0; - } - Py_DECREF(NotEq_annotations); - PyObject *Lt_annotations = PyDict_New(); - if (!Lt_annotations) return 0; - cond = PyObject_SetAttrString(state->Lt_type, "_field_types", - Lt_annotations) == 0; - if (!cond) { - Py_DECREF(Lt_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Lt_type, "__annotations__", - Lt_annotations) == 0; - if (!cond) { - Py_DECREF(Lt_annotations); - return 0; - } - Py_DECREF(Lt_annotations); - PyObject *LtE_annotations = PyDict_New(); - if (!LtE_annotations) return 0; - cond = PyObject_SetAttrString(state->LtE_type, "_field_types", - LtE_annotations) == 0; - if (!cond) { - Py_DECREF(LtE_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->LtE_type, "__annotations__", - LtE_annotations) == 0; - if (!cond) { - Py_DECREF(LtE_annotations); - return 0; - } - Py_DECREF(LtE_annotations); - PyObject *Gt_annotations = PyDict_New(); - if (!Gt_annotations) return 0; - cond = PyObject_SetAttrString(state->Gt_type, "_field_types", - Gt_annotations) == 0; - if (!cond) { - Py_DECREF(Gt_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Gt_type, "__annotations__", - Gt_annotations) == 0; - if (!cond) { - Py_DECREF(Gt_annotations); - return 0; - } - Py_DECREF(Gt_annotations); - PyObject *GtE_annotations = PyDict_New(); - if (!GtE_annotations) return 0; - cond = PyObject_SetAttrString(state->GtE_type, "_field_types", - GtE_annotations) == 0; - if (!cond) { - Py_DECREF(GtE_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->GtE_type, "__annotations__", - GtE_annotations) == 0; - if (!cond) { - Py_DECREF(GtE_annotations); - return 0; - } - Py_DECREF(GtE_annotations); - PyObject *Is_annotations = PyDict_New(); - if (!Is_annotations) return 0; - cond = PyObject_SetAttrString(state->Is_type, "_field_types", - Is_annotations) == 0; - if (!cond) { - Py_DECREF(Is_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->Is_type, "__annotations__", - Is_annotations) == 0; - if (!cond) { - Py_DECREF(Is_annotations); - return 0; - } - Py_DECREF(Is_annotations); - PyObject *IsNot_annotations = PyDict_New(); - if (!IsNot_annotations) return 0; - cond = PyObject_SetAttrString(state->IsNot_type, "_field_types", - IsNot_annotations) == 0; - if (!cond) { - Py_DECREF(IsNot_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->IsNot_type, "__annotations__", - IsNot_annotations) == 0; - if (!cond) { - Py_DECREF(IsNot_annotations); - return 0; - } - Py_DECREF(IsNot_annotations); - PyObject *In_annotations = PyDict_New(); - if (!In_annotations) return 0; - cond = PyObject_SetAttrString(state->In_type, "_field_types", - In_annotations) == 0; - if (!cond) { - Py_DECREF(In_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->In_type, "__annotations__", - In_annotations) == 0; - if (!cond) { - Py_DECREF(In_annotations); - return 0; - } - Py_DECREF(In_annotations); - PyObject *NotIn_annotations = PyDict_New(); - if (!NotIn_annotations) return 0; - cond = PyObject_SetAttrString(state->NotIn_type, "_field_types", - NotIn_annotations) == 0; - if (!cond) { - Py_DECREF(NotIn_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->NotIn_type, "__annotations__", - NotIn_annotations) == 0; - if (!cond) { - Py_DECREF(NotIn_annotations); - return 0; - } - Py_DECREF(NotIn_annotations); - PyObject *comprehension_annotations = PyDict_New(); - if (!comprehension_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(comprehension_annotations, "target", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(comprehension_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(comprehension_annotations, "iter", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(comprehension_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(comprehension_annotations); - return 0; - } - cond = PyDict_SetItemString(comprehension_annotations, "ifs", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(comprehension_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyLong_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(comprehension_annotations, "is_async", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(comprehension_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->comprehension_type, "_field_types", - comprehension_annotations) == 0; - if (!cond) { - Py_DECREF(comprehension_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->comprehension_type, "__annotations__", - comprehension_annotations) == 0; - if (!cond) { - Py_DECREF(comprehension_annotations); - return 0; - } - Py_DECREF(comprehension_annotations); - PyObject *ExceptHandler_annotations = PyDict_New(); - if (!ExceptHandler_annotations) return 0; - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(ExceptHandler_annotations); - return 0; - } - cond = PyDict_SetItemString(ExceptHandler_annotations, "type", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ExceptHandler_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(ExceptHandler_annotations); - return 0; - } - cond = PyDict_SetItemString(ExceptHandler_annotations, "name", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ExceptHandler_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(ExceptHandler_annotations); - return 0; - } - cond = PyDict_SetItemString(ExceptHandler_annotations, "body", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ExceptHandler_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->ExceptHandler_type, "_field_types", - ExceptHandler_annotations) == 0; - if (!cond) { - Py_DECREF(ExceptHandler_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->ExceptHandler_type, "__annotations__", - ExceptHandler_annotations) == 0; - if (!cond) { - Py_DECREF(ExceptHandler_annotations); - return 0; - } - Py_DECREF(ExceptHandler_annotations); - PyObject *arguments_annotations = PyDict_New(); - if (!arguments_annotations) return 0; - { - PyObject *type = state->arg_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - cond = PyDict_SetItemString(arguments_annotations, "posonlyargs", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - } - { - PyObject *type = state->arg_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - cond = PyDict_SetItemString(arguments_annotations, "args", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - } - { - PyObject *type = state->arg_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - cond = PyDict_SetItemString(arguments_annotations, "vararg", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - } - { - PyObject *type = state->arg_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - cond = PyDict_SetItemString(arguments_annotations, "kwonlyargs", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - cond = PyDict_SetItemString(arguments_annotations, "kw_defaults", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - } - { - PyObject *type = state->arg_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - cond = PyDict_SetItemString(arguments_annotations, "kwarg", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - cond = PyDict_SetItemString(arguments_annotations, "defaults", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->arguments_type, "_field_types", - arguments_annotations) == 0; - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->arguments_type, "__annotations__", - arguments_annotations) == 0; - if (!cond) { - Py_DECREF(arguments_annotations); - return 0; - } - Py_DECREF(arguments_annotations); - PyObject *arg_annotations = PyDict_New(); - if (!arg_annotations) return 0; - { - PyObject *type = (PyObject *)&PyUnicode_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(arg_annotations, "arg", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(arg_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(arg_annotations); - return 0; - } - cond = PyDict_SetItemString(arg_annotations, "annotation", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(arg_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(arg_annotations); - return 0; - } - cond = PyDict_SetItemString(arg_annotations, "type_comment", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(arg_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->arg_type, "_field_types", - arg_annotations) == 0; - if (!cond) { - Py_DECREF(arg_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->arg_type, "__annotations__", - arg_annotations) == 0; - if (!cond) { - Py_DECREF(arg_annotations); - return 0; - } - Py_DECREF(arg_annotations); - PyObject *keyword_annotations = PyDict_New(); - if (!keyword_annotations) return 0; - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(keyword_annotations); - return 0; - } - cond = PyDict_SetItemString(keyword_annotations, "arg", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(keyword_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(keyword_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(keyword_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->keyword_type, "_field_types", - keyword_annotations) == 0; - if (!cond) { - Py_DECREF(keyword_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->keyword_type, "__annotations__", - keyword_annotations) == 0; - if (!cond) { - Py_DECREF(keyword_annotations); - return 0; - } - Py_DECREF(keyword_annotations); - PyObject *alias_annotations = PyDict_New(); - if (!alias_annotations) return 0; - { - PyObject *type = (PyObject *)&PyUnicode_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(alias_annotations, "name", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(alias_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(alias_annotations); - return 0; - } - cond = PyDict_SetItemString(alias_annotations, "asname", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(alias_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->alias_type, "_field_types", - alias_annotations) == 0; - if (!cond) { - Py_DECREF(alias_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->alias_type, "__annotations__", - alias_annotations) == 0; - if (!cond) { - Py_DECREF(alias_annotations); - return 0; - } - Py_DECREF(alias_annotations); - PyObject *withitem_annotations = PyDict_New(); - if (!withitem_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(withitem_annotations, "context_expr", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(withitem_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(withitem_annotations); - return 0; - } - cond = PyDict_SetItemString(withitem_annotations, "optional_vars", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(withitem_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->withitem_type, "_field_types", - withitem_annotations) == 0; - if (!cond) { - Py_DECREF(withitem_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->withitem_type, "__annotations__", - withitem_annotations) == 0; - if (!cond) { - Py_DECREF(withitem_annotations); - return 0; - } - Py_DECREF(withitem_annotations); - PyObject *match_case_annotations = PyDict_New(); - if (!match_case_annotations) return 0; - { - PyObject *type = state->pattern_type; - Py_INCREF(type); - cond = PyDict_SetItemString(match_case_annotations, "pattern", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(match_case_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(match_case_annotations); - return 0; - } - cond = PyDict_SetItemString(match_case_annotations, "guard", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(match_case_annotations); - return 0; - } - } - { - PyObject *type = state->stmt_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(match_case_annotations); - return 0; - } - cond = PyDict_SetItemString(match_case_annotations, "body", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(match_case_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->match_case_type, "_field_types", - match_case_annotations) == 0; - if (!cond) { - Py_DECREF(match_case_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->match_case_type, "__annotations__", - match_case_annotations) == 0; - if (!cond) { - Py_DECREF(match_case_annotations); - return 0; - } - Py_DECREF(match_case_annotations); - PyObject *MatchValue_annotations = PyDict_New(); - if (!MatchValue_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(MatchValue_annotations, "value", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(MatchValue_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->MatchValue_type, "_field_types", - MatchValue_annotations) == 0; - if (!cond) { - Py_DECREF(MatchValue_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->MatchValue_type, "__annotations__", - MatchValue_annotations) == 0; - if (!cond) { - Py_DECREF(MatchValue_annotations); - return 0; - } - Py_DECREF(MatchValue_annotations); - PyObject *MatchSingleton_annotations = PyDict_New(); - if (!MatchSingleton_annotations) return 0; - { - PyObject *type = (PyObject *)&PyBaseObject_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(MatchSingleton_annotations, "value", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(MatchSingleton_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->MatchSingleton_type, "_field_types", - MatchSingleton_annotations) == 0; - if (!cond) { - Py_DECREF(MatchSingleton_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->MatchSingleton_type, - "__annotations__", - MatchSingleton_annotations) == 0; - if (!cond) { - Py_DECREF(MatchSingleton_annotations); - return 0; - } - Py_DECREF(MatchSingleton_annotations); - PyObject *MatchSequence_annotations = PyDict_New(); - if (!MatchSequence_annotations) return 0; - { - PyObject *type = state->pattern_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(MatchSequence_annotations); - return 0; - } - cond = PyDict_SetItemString(MatchSequence_annotations, "patterns", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(MatchSequence_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->MatchSequence_type, "_field_types", - MatchSequence_annotations) == 0; - if (!cond) { - Py_DECREF(MatchSequence_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->MatchSequence_type, "__annotations__", - MatchSequence_annotations) == 0; - if (!cond) { - Py_DECREF(MatchSequence_annotations); - return 0; - } - Py_DECREF(MatchSequence_annotations); - PyObject *MatchMapping_annotations = PyDict_New(); - if (!MatchMapping_annotations) return 0; - { - PyObject *type = state->expr_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(MatchMapping_annotations); - return 0; - } - cond = PyDict_SetItemString(MatchMapping_annotations, "keys", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(MatchMapping_annotations); - return 0; - } - } - { - PyObject *type = state->pattern_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(MatchMapping_annotations); - return 0; - } - cond = PyDict_SetItemString(MatchMapping_annotations, "patterns", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(MatchMapping_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(MatchMapping_annotations); - return 0; - } - cond = PyDict_SetItemString(MatchMapping_annotations, "rest", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(MatchMapping_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->MatchMapping_type, "_field_types", - MatchMapping_annotations) == 0; - if (!cond) { - Py_DECREF(MatchMapping_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->MatchMapping_type, "__annotations__", - MatchMapping_annotations) == 0; - if (!cond) { - Py_DECREF(MatchMapping_annotations); - return 0; - } - Py_DECREF(MatchMapping_annotations); - PyObject *MatchClass_annotations = PyDict_New(); - if (!MatchClass_annotations) return 0; - { - PyObject *type = state->expr_type; - Py_INCREF(type); - cond = PyDict_SetItemString(MatchClass_annotations, "cls", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(MatchClass_annotations); - return 0; - } - } - { - PyObject *type = state->pattern_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(MatchClass_annotations); - return 0; - } - cond = PyDict_SetItemString(MatchClass_annotations, "patterns", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(MatchClass_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(MatchClass_annotations); - return 0; - } - cond = PyDict_SetItemString(MatchClass_annotations, "kwd_attrs", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(MatchClass_annotations); - return 0; - } - } - { - PyObject *type = state->pattern_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(MatchClass_annotations); - return 0; - } - cond = PyDict_SetItemString(MatchClass_annotations, "kwd_patterns", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(MatchClass_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->MatchClass_type, "_field_types", - MatchClass_annotations) == 0; - if (!cond) { - Py_DECREF(MatchClass_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->MatchClass_type, "__annotations__", - MatchClass_annotations) == 0; - if (!cond) { - Py_DECREF(MatchClass_annotations); - return 0; - } - Py_DECREF(MatchClass_annotations); - PyObject *MatchStar_annotations = PyDict_New(); - if (!MatchStar_annotations) return 0; - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(MatchStar_annotations); - return 0; - } - cond = PyDict_SetItemString(MatchStar_annotations, "name", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(MatchStar_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->MatchStar_type, "_field_types", - MatchStar_annotations) == 0; - if (!cond) { - Py_DECREF(MatchStar_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->MatchStar_type, "__annotations__", - MatchStar_annotations) == 0; - if (!cond) { - Py_DECREF(MatchStar_annotations); - return 0; - } - Py_DECREF(MatchStar_annotations); - PyObject *MatchAs_annotations = PyDict_New(); - if (!MatchAs_annotations) return 0; - { - PyObject *type = state->pattern_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(MatchAs_annotations); - return 0; - } - cond = PyDict_SetItemString(MatchAs_annotations, "pattern", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(MatchAs_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(MatchAs_annotations); - return 0; - } - cond = PyDict_SetItemString(MatchAs_annotations, "name", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(MatchAs_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->MatchAs_type, "_field_types", - MatchAs_annotations) == 0; - if (!cond) { - Py_DECREF(MatchAs_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->MatchAs_type, "__annotations__", - MatchAs_annotations) == 0; - if (!cond) { - Py_DECREF(MatchAs_annotations); - return 0; - } - Py_DECREF(MatchAs_annotations); - PyObject *MatchOr_annotations = PyDict_New(); - if (!MatchOr_annotations) return 0; - { - PyObject *type = state->pattern_type; - type = Py_GenericAlias((PyObject *)&PyList_Type, type); - cond = type != NULL; - if (!cond) { - Py_DECREF(MatchOr_annotations); - return 0; - } - cond = PyDict_SetItemString(MatchOr_annotations, "patterns", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(MatchOr_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->MatchOr_type, "_field_types", - MatchOr_annotations) == 0; - if (!cond) { - Py_DECREF(MatchOr_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->MatchOr_type, "__annotations__", - MatchOr_annotations) == 0; - if (!cond) { - Py_DECREF(MatchOr_annotations); - return 0; - } - Py_DECREF(MatchOr_annotations); - PyObject *TypeIgnore_annotations = PyDict_New(); - if (!TypeIgnore_annotations) return 0; - { - PyObject *type = (PyObject *)&PyLong_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(TypeIgnore_annotations, "lineno", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(TypeIgnore_annotations); - return 0; - } - } - { - PyObject *type = (PyObject *)&PyUnicode_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(TypeIgnore_annotations, "tag", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(TypeIgnore_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->TypeIgnore_type, "_field_types", - TypeIgnore_annotations) == 0; - if (!cond) { - Py_DECREF(TypeIgnore_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->TypeIgnore_type, "__annotations__", - TypeIgnore_annotations) == 0; - if (!cond) { - Py_DECREF(TypeIgnore_annotations); - return 0; - } - Py_DECREF(TypeIgnore_annotations); - PyObject *TypeVar_annotations = PyDict_New(); - if (!TypeVar_annotations) return 0; - { - PyObject *type = (PyObject *)&PyUnicode_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(TypeVar_annotations, "name", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(TypeVar_annotations); - return 0; - } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(TypeVar_annotations); - return 0; - } - cond = PyDict_SetItemString(TypeVar_annotations, "bound", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(TypeVar_annotations); - return 0; +}; +static const char * const JoinedStr_fields[]={ + "values", +}; +static const char * const TemplateStr_fields[]={ + "values", +}; +static const char * const Constant_fields[]={ + "value", + "kind", +}; +static const char * const Attribute_fields[]={ + "value", + "attr", + "ctx", +}; +static const char * const Subscript_fields[]={ + "value", + "slice", + "ctx", +}; +static const char * const Starred_fields[]={ + "value", + "ctx", +}; +static const char * const Name_fields[]={ + "id", + "ctx", +}; +static const char * const List_fields[]={ + "elts", + "ctx", +}; +static const char * const Tuple_fields[]={ + "elts", + "ctx", +}; +static const char * const Slice_fields[]={ + "lower", + "upper", + "step", +}; +static PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty); +static PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty); +static PyObject* ast2obj_operator(struct ast_state *state, operator_ty); +static PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty); +static PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty); +static PyObject* ast2obj_comprehension(struct ast_state *state, void*); +static const char * const comprehension_fields[]={ + "target", + "iter", + "ifs", + "is_async", +}; +static const char * const excepthandler_attributes[] = { + "lineno", + "col_offset", + "end_lineno", + "end_col_offset", +}; +static PyObject* ast2obj_excepthandler(struct ast_state *state, void*); +static const char * const ExceptHandler_fields[]={ + "type", + "name", + "body", +}; +static PyObject* ast2obj_arguments(struct ast_state *state, void*); +static const char * const arguments_fields[]={ + "posonlyargs", + "args", + "vararg", + "kwonlyargs", + "kw_defaults", + "kwarg", + "defaults", +}; +static PyObject* ast2obj_arg(struct ast_state *state, void*); +static const char * const arg_attributes[] = { + "lineno", + "col_offset", + "end_lineno", + "end_col_offset", +}; +static const char * const arg_fields[]={ + "arg", + "annotation", + "type_comment", +}; +static PyObject* ast2obj_keyword(struct ast_state *state, void*); +static const char * const keyword_attributes[] = { + "lineno", + "col_offset", + "end_lineno", + "end_col_offset", +}; +static const char * const keyword_fields[]={ + "arg", + "value", +}; +static PyObject* ast2obj_alias(struct ast_state *state, void*); +static const char * const alias_attributes[] = { + "lineno", + "col_offset", + "end_lineno", + "end_col_offset", +}; +static const char * const alias_fields[]={ + "name", + "asname", +}; +static PyObject* ast2obj_withitem(struct ast_state *state, void*); +static const char * const withitem_fields[]={ + "context_expr", + "optional_vars", +}; +static PyObject* ast2obj_match_case(struct ast_state *state, void*); +static const char * const match_case_fields[]={ + "pattern", + "guard", + "body", +}; +static const char * const pattern_attributes[] = { + "lineno", + "col_offset", + "end_lineno", + "end_col_offset", +}; +static PyObject* ast2obj_pattern(struct ast_state *state, void*); +static const char * const MatchValue_fields[]={ + "value", +}; +static const char * const MatchSingleton_fields[]={ + "value", +}; +static const char * const MatchSequence_fields[]={ + "patterns", +}; +static const char * const MatchMapping_fields[]={ + "keys", + "patterns", + "rest", +}; +static const char * const MatchClass_fields[]={ + "cls", + "patterns", + "kwd_attrs", + "kwd_patterns", +}; +static const char * const MatchStar_fields[]={ + "name", +}; +static const char * const MatchAs_fields[]={ + "pattern", + "name", +}; +static const char * const MatchOr_fields[]={ + "patterns", +}; +static PyObject* ast2obj_type_ignore(struct ast_state *state, void*); +static const char * const TypeIgnore_fields[]={ + "lineno", + "tag", +}; +static const char * const type_param_attributes[] = { + "lineno", + "col_offset", + "end_lineno", + "end_col_offset", +}; +static PyObject* ast2obj_type_param(struct ast_state *state, void*); +static const char * const TypeVar_fields[]={ + "name", + "bound", + "default_value", +}; +static const char * const ParamSpec_fields[]={ + "name", + "default_value", +}; +static const char * const TypeVarTuple_fields[]={ + "name", + "default_value", +}; + + +static int +add_ast_annotations(struct ast_state *state) +{ + enum { + FIELD_OPTIONAL = 1, + FIELD_SEQUENCE = 2, + FIELD_BUILTIN = 4, + }; + PyTypeObject *const builtin_types[] = { + &PyUnicode_Type, + &PyLong_Type, + &PyBaseObject_Type, + }; + // Offsets refer to this interpreter's AST state, not global types. + static_assert(sizeof(struct ast_state) <= UINT16_MAX, + "ast_state offsets must fit in uint16_t"); + static const struct { + uint16_t name_offset; + uint16_t type_offset; // An index into builtin_types for builtins. + uint8_t flags; + } fields[] = { + {offsetof(struct ast_state, body), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, type_ignores), + offsetof(struct ast_state, type_ignore_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, argtypes), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, returns), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, name), + 0, FIELD_BUILTIN}, + {offsetof(struct ast_state, args), + offsetof(struct ast_state, arguments_type), 0}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, decorator_list), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, returns), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, type_comment), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, type_params), + offsetof(struct ast_state, type_param_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, name), + 0, FIELD_BUILTIN}, + {offsetof(struct ast_state, args), + offsetof(struct ast_state, arguments_type), 0}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, decorator_list), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, returns), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, type_comment), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, type_params), + offsetof(struct ast_state, type_param_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, name), + 0, FIELD_BUILTIN}, + {offsetof(struct ast_state, bases), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, keywords), + offsetof(struct ast_state, keyword_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, decorator_list), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, type_params), + offsetof(struct ast_state, type_param_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, targets), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, targets), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, type_comment), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, name), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, type_params), + offsetof(struct ast_state, type_param_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, target), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, op), + offsetof(struct ast_state, operator_type), 0}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, target), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, annotation), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, simple), + 1, FIELD_BUILTIN}, + {offsetof(struct ast_state, target), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, iter), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, orelse), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, type_comment), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, target), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, iter), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, orelse), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, type_comment), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, test), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, orelse), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, test), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, orelse), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, items), + offsetof(struct ast_state, withitem_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, type_comment), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, items), + offsetof(struct ast_state, withitem_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, type_comment), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, subject), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, cases), + offsetof(struct ast_state, match_case_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, exc), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, cause), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, handlers), + offsetof(struct ast_state, excepthandler_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, orelse), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, finalbody), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, handlers), + offsetof(struct ast_state, excepthandler_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, orelse), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, finalbody), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, test), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, msg), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, names), + offsetof(struct ast_state, alias_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, is_lazy), + 1, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, module), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, names), + offsetof(struct ast_state, alias_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, level), + 1, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, is_lazy), + 1, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, names), + 0, FIELD_SEQUENCE | FIELD_BUILTIN}, + {offsetof(struct ast_state, names), + 0, FIELD_SEQUENCE | FIELD_BUILTIN}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, op), + offsetof(struct ast_state, boolop_type), 0}, + {offsetof(struct ast_state, values), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, target), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, left), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, op), + offsetof(struct ast_state, operator_type), 0}, + {offsetof(struct ast_state, right), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, op), + offsetof(struct ast_state, unaryop_type), 0}, + {offsetof(struct ast_state, operand), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, args), + offsetof(struct ast_state, arguments_type), 0}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, test), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, orelse), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, keys), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, values), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, elts), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, elt), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, generators), + offsetof(struct ast_state, comprehension_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, elt), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, generators), + offsetof(struct ast_state, comprehension_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, key), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, generators), + offsetof(struct ast_state, comprehension_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, elt), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, generators), + offsetof(struct ast_state, comprehension_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, left), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, ops), + offsetof(struct ast_state, cmpop_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, comparators), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, func), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, args), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, keywords), + offsetof(struct ast_state, keyword_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, conversion), + 1, FIELD_BUILTIN}, + {offsetof(struct ast_state, format_spec), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, str), + 2, FIELD_BUILTIN}, + {offsetof(struct ast_state, conversion), + 1, FIELD_BUILTIN}, + {offsetof(struct ast_state, format_spec), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, values), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, values), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, value), + 2, FIELD_BUILTIN}, + {offsetof(struct ast_state, kind), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, attr), + 0, FIELD_BUILTIN}, + {offsetof(struct ast_state, ctx), + offsetof(struct ast_state, expr_context_type), 0}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, slice), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, ctx), + offsetof(struct ast_state, expr_context_type), 0}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, ctx), + offsetof(struct ast_state, expr_context_type), 0}, + {offsetof(struct ast_state, id), + 0, FIELD_BUILTIN}, + {offsetof(struct ast_state, ctx), + offsetof(struct ast_state, expr_context_type), 0}, + {offsetof(struct ast_state, elts), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, ctx), + offsetof(struct ast_state, expr_context_type), 0}, + {offsetof(struct ast_state, elts), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, ctx), + offsetof(struct ast_state, expr_context_type), 0}, + {offsetof(struct ast_state, lower), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, upper), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, step), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, target), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, iter), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, ifs), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, is_async), + 1, FIELD_BUILTIN}, + {offsetof(struct ast_state, type), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, name), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, posonlyargs), + offsetof(struct ast_state, arg_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, args), + offsetof(struct ast_state, arg_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, vararg), + offsetof(struct ast_state, arg_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, kwonlyargs), + offsetof(struct ast_state, arg_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, kw_defaults), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, kwarg), + offsetof(struct ast_state, arg_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, defaults), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, arg), + 0, FIELD_BUILTIN}, + {offsetof(struct ast_state, annotation), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, type_comment), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, arg), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, name), + 0, FIELD_BUILTIN}, + {offsetof(struct ast_state, asname), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, context_expr), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, optional_vars), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, pattern), + offsetof(struct ast_state, pattern_type), 0}, + {offsetof(struct ast_state, guard), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, body), + offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, value), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, value), + 2, FIELD_BUILTIN}, + {offsetof(struct ast_state, patterns), + offsetof(struct ast_state, pattern_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, keys), + offsetof(struct ast_state, expr_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, patterns), + offsetof(struct ast_state, pattern_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, rest), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, cls), + offsetof(struct ast_state, expr_type), 0}, + {offsetof(struct ast_state, patterns), + offsetof(struct ast_state, pattern_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, kwd_attrs), + 0, FIELD_SEQUENCE | FIELD_BUILTIN}, + {offsetof(struct ast_state, kwd_patterns), + offsetof(struct ast_state, pattern_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, name), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, pattern), + offsetof(struct ast_state, pattern_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, name), + 0, FIELD_OPTIONAL | FIELD_BUILTIN}, + {offsetof(struct ast_state, patterns), + offsetof(struct ast_state, pattern_type), FIELD_SEQUENCE}, + {offsetof(struct ast_state, lineno), + 1, FIELD_BUILTIN}, + {offsetof(struct ast_state, tag), + 0, FIELD_BUILTIN}, + {offsetof(struct ast_state, name), + 0, FIELD_BUILTIN}, + {offsetof(struct ast_state, bound), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, default_value), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, name), + 0, FIELD_BUILTIN}, + {offsetof(struct ast_state, default_value), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + {offsetof(struct ast_state, name), + 0, FIELD_BUILTIN}, + {offsetof(struct ast_state, default_value), + offsetof(struct ast_state, expr_type), FIELD_OPTIONAL}, + }; + static const struct { + uint16_t type_offset; + uint16_t first_field; + uint16_t nfields; + } nodes[] = { + {offsetof(struct ast_state, Module_type), 0, 2}, + {offsetof(struct ast_state, Interactive_type), 2, 1}, + {offsetof(struct ast_state, Expression_type), 3, 1}, + {offsetof(struct ast_state, FunctionType_type), 4, 2}, + {offsetof(struct ast_state, FunctionDef_type), 6, 7}, + {offsetof(struct ast_state, AsyncFunctionDef_type), 13, 7}, + {offsetof(struct ast_state, ClassDef_type), 20, 6}, + {offsetof(struct ast_state, Return_type), 26, 1}, + {offsetof(struct ast_state, Delete_type), 27, 1}, + {offsetof(struct ast_state, Assign_type), 28, 3}, + {offsetof(struct ast_state, TypeAlias_type), 31, 3}, + {offsetof(struct ast_state, AugAssign_type), 34, 3}, + {offsetof(struct ast_state, AnnAssign_type), 37, 4}, + {offsetof(struct ast_state, For_type), 41, 5}, + {offsetof(struct ast_state, AsyncFor_type), 46, 5}, + {offsetof(struct ast_state, While_type), 51, 3}, + {offsetof(struct ast_state, If_type), 54, 3}, + {offsetof(struct ast_state, With_type), 57, 3}, + {offsetof(struct ast_state, AsyncWith_type), 60, 3}, + {offsetof(struct ast_state, Match_type), 63, 2}, + {offsetof(struct ast_state, Raise_type), 65, 2}, + {offsetof(struct ast_state, Try_type), 67, 4}, + {offsetof(struct ast_state, TryStar_type), 71, 4}, + {offsetof(struct ast_state, Assert_type), 75, 2}, + {offsetof(struct ast_state, Import_type), 77, 2}, + {offsetof(struct ast_state, ImportFrom_type), 79, 4}, + {offsetof(struct ast_state, Global_type), 83, 1}, + {offsetof(struct ast_state, Nonlocal_type), 84, 1}, + {offsetof(struct ast_state, Expr_type), 85, 1}, + {offsetof(struct ast_state, Pass_type), 86, 0}, + {offsetof(struct ast_state, Break_type), 86, 0}, + {offsetof(struct ast_state, Continue_type), 86, 0}, + {offsetof(struct ast_state, BoolOp_type), 86, 2}, + {offsetof(struct ast_state, NamedExpr_type), 88, 2}, + {offsetof(struct ast_state, BinOp_type), 90, 3}, + {offsetof(struct ast_state, UnaryOp_type), 93, 2}, + {offsetof(struct ast_state, Lambda_type), 95, 2}, + {offsetof(struct ast_state, IfExp_type), 97, 3}, + {offsetof(struct ast_state, Dict_type), 100, 2}, + {offsetof(struct ast_state, Set_type), 102, 1}, + {offsetof(struct ast_state, ListComp_type), 103, 2}, + {offsetof(struct ast_state, SetComp_type), 105, 2}, + {offsetof(struct ast_state, DictComp_type), 107, 3}, + {offsetof(struct ast_state, GeneratorExp_type), 110, 2}, + {offsetof(struct ast_state, Await_type), 112, 1}, + {offsetof(struct ast_state, Yield_type), 113, 1}, + {offsetof(struct ast_state, YieldFrom_type), 114, 1}, + {offsetof(struct ast_state, Compare_type), 115, 3}, + {offsetof(struct ast_state, Call_type), 118, 3}, + {offsetof(struct ast_state, FormattedValue_type), 121, 3}, + {offsetof(struct ast_state, Interpolation_type), 124, 4}, + {offsetof(struct ast_state, JoinedStr_type), 128, 1}, + {offsetof(struct ast_state, TemplateStr_type), 129, 1}, + {offsetof(struct ast_state, Constant_type), 130, 2}, + {offsetof(struct ast_state, Attribute_type), 132, 3}, + {offsetof(struct ast_state, Subscript_type), 135, 3}, + {offsetof(struct ast_state, Starred_type), 138, 2}, + {offsetof(struct ast_state, Name_type), 140, 2}, + {offsetof(struct ast_state, List_type), 142, 2}, + {offsetof(struct ast_state, Tuple_type), 144, 2}, + {offsetof(struct ast_state, Slice_type), 146, 3}, + {offsetof(struct ast_state, Load_type), 149, 0}, + {offsetof(struct ast_state, Store_type), 149, 0}, + {offsetof(struct ast_state, Del_type), 149, 0}, + {offsetof(struct ast_state, And_type), 149, 0}, + {offsetof(struct ast_state, Or_type), 149, 0}, + {offsetof(struct ast_state, Add_type), 149, 0}, + {offsetof(struct ast_state, Sub_type), 149, 0}, + {offsetof(struct ast_state, Mult_type), 149, 0}, + {offsetof(struct ast_state, MatMult_type), 149, 0}, + {offsetof(struct ast_state, Div_type), 149, 0}, + {offsetof(struct ast_state, Mod_type), 149, 0}, + {offsetof(struct ast_state, Pow_type), 149, 0}, + {offsetof(struct ast_state, LShift_type), 149, 0}, + {offsetof(struct ast_state, RShift_type), 149, 0}, + {offsetof(struct ast_state, BitOr_type), 149, 0}, + {offsetof(struct ast_state, BitXor_type), 149, 0}, + {offsetof(struct ast_state, BitAnd_type), 149, 0}, + {offsetof(struct ast_state, FloorDiv_type), 149, 0}, + {offsetof(struct ast_state, Invert_type), 149, 0}, + {offsetof(struct ast_state, Not_type), 149, 0}, + {offsetof(struct ast_state, UAdd_type), 149, 0}, + {offsetof(struct ast_state, USub_type), 149, 0}, + {offsetof(struct ast_state, Eq_type), 149, 0}, + {offsetof(struct ast_state, NotEq_type), 149, 0}, + {offsetof(struct ast_state, Lt_type), 149, 0}, + {offsetof(struct ast_state, LtE_type), 149, 0}, + {offsetof(struct ast_state, Gt_type), 149, 0}, + {offsetof(struct ast_state, GtE_type), 149, 0}, + {offsetof(struct ast_state, Is_type), 149, 0}, + {offsetof(struct ast_state, IsNot_type), 149, 0}, + {offsetof(struct ast_state, In_type), 149, 0}, + {offsetof(struct ast_state, NotIn_type), 149, 0}, + {offsetof(struct ast_state, comprehension_type), 149, 4}, + {offsetof(struct ast_state, ExceptHandler_type), 153, 3}, + {offsetof(struct ast_state, arguments_type), 156, 7}, + {offsetof(struct ast_state, arg_type), 163, 3}, + {offsetof(struct ast_state, keyword_type), 166, 2}, + {offsetof(struct ast_state, alias_type), 168, 2}, + {offsetof(struct ast_state, withitem_type), 170, 2}, + {offsetof(struct ast_state, match_case_type), 172, 3}, + {offsetof(struct ast_state, MatchValue_type), 175, 1}, + {offsetof(struct ast_state, MatchSingleton_type), 176, 1}, + {offsetof(struct ast_state, MatchSequence_type), 177, 1}, + {offsetof(struct ast_state, MatchMapping_type), 178, 3}, + {offsetof(struct ast_state, MatchClass_type), 181, 4}, + {offsetof(struct ast_state, MatchStar_type), 185, 1}, + {offsetof(struct ast_state, MatchAs_type), 186, 2}, + {offsetof(struct ast_state, MatchOr_type), 188, 1}, + {offsetof(struct ast_state, TypeIgnore_type), 189, 2}, + {offsetof(struct ast_state, TypeVar_type), 191, 3}, + {offsetof(struct ast_state, ParamSpec_type), 194, 2}, + {offsetof(struct ast_state, TypeVarTuple_type), 196, 2}, + }; + char *base = (char *)state; + PyObject *annotations = NULL; + for (size_t i = 0; i < Py_ARRAY_LENGTH(nodes); i++) { + annotations = PyDict_New(); + if (annotations == NULL) { + goto error; } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(TypeVar_annotations); - return 0; - } - cond = PyDict_SetItemString(TypeVar_annotations, "default_value", type) - == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(TypeVar_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->TypeVar_type, "_field_types", - TypeVar_annotations) == 0; - if (!cond) { - Py_DECREF(TypeVar_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->TypeVar_type, "__annotations__", - TypeVar_annotations) == 0; - if (!cond) { - Py_DECREF(TypeVar_annotations); - return 0; - } - Py_DECREF(TypeVar_annotations); - PyObject *ParamSpec_annotations = PyDict_New(); - if (!ParamSpec_annotations) return 0; - { - PyObject *type = (PyObject *)&PyUnicode_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(ParamSpec_annotations, "name", type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ParamSpec_annotations); - return 0; + size_t end = nodes[i].first_field + nodes[i].nfields; + for (size_t j = nodes[i].first_field; j < end; j++) { + PyObject *name = *(PyObject **)(base + fields[j].name_offset); + PyObject *type; + if (fields[j].flags & FIELD_BUILTIN) { + type = (PyObject *)builtin_types[fields[j].type_offset]; + } + else { + type = *(PyObject **)(base + fields[j].type_offset); + } + if (fields[j].flags & FIELD_OPTIONAL) { + type = _Py_union_type_or(type, Py_None); + } + else if (fields[j].flags & FIELD_SEQUENCE) { + type = Py_GenericAlias((PyObject *)&PyList_Type, type); + } + else { + Py_INCREF(type); + } + if (type == NULL) { + goto error; + } + int res = PyDict_SetItem(annotations, name, type); + Py_DECREF(type); + if (res < 0) { + goto error; + } } - } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(ParamSpec_annotations); - return 0; - } - cond = PyDict_SetItemString(ParamSpec_annotations, "default_value", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(ParamSpec_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->ParamSpec_type, "_field_types", - ParamSpec_annotations) == 0; - if (!cond) { - Py_DECREF(ParamSpec_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->ParamSpec_type, "__annotations__", - ParamSpec_annotations) == 0; - if (!cond) { - Py_DECREF(ParamSpec_annotations); - return 0; - } - Py_DECREF(ParamSpec_annotations); - PyObject *TypeVarTuple_annotations = PyDict_New(); - if (!TypeVarTuple_annotations) return 0; - { - PyObject *type = (PyObject *)&PyUnicode_Type; - Py_INCREF(type); - cond = PyDict_SetItemString(TypeVarTuple_annotations, "name", type) == - 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(TypeVarTuple_annotations); - return 0; + PyObject *node = *(PyObject **)(base + nodes[i].type_offset); + if (PyObject_SetAttrString(node, "_field_types", annotations) < 0 || + PyObject_SetAttrString(node, "__annotations__", annotations) < 0) + { + goto error; } + Py_CLEAR(annotations); } - { - PyObject *type = state->expr_type; - type = _Py_union_type_or(type, Py_None); - cond = type != NULL; - if (!cond) { - Py_DECREF(TypeVarTuple_annotations); - return 0; - } - cond = PyDict_SetItemString(TypeVarTuple_annotations, "default_value", - type) == 0; - Py_DECREF(type); - if (!cond) { - Py_DECREF(TypeVarTuple_annotations); - return 0; - } - } - cond = PyObject_SetAttrString(state->TypeVarTuple_type, "_field_types", - TypeVarTuple_annotations) == 0; - if (!cond) { - Py_DECREF(TypeVarTuple_annotations); - return 0; - } - cond = PyObject_SetAttrString(state->TypeVarTuple_type, "__annotations__", - TypeVarTuple_annotations) == 0; - if (!cond) { - Py_DECREF(TypeVarTuple_annotations); - return 0; - } - Py_DECREF(TypeVarTuple_annotations); - return 1; +error: + Py_XDECREF(annotations); + return 0; } typedef struct { PyObject_HEAD - PyObject *dict; } AST_object; static void @@ -5174,7 +1423,7 @@ ast_dealloc(PyObject *op) /* bpo-31095: UnTrack is needed before calling any callbacks */ PyTypeObject *tp = Py_TYPE(self); PyObject_GC_UnTrack(self); - Py_CLEAR(self->dict); + PyObject_ClearManagedDict(op); freefunc free_func = PyType_GetSlot(tp, Py_tp_free); assert(free_func != NULL); free_func(self); @@ -5186,15 +1435,13 @@ ast_traverse(PyObject *op, visitproc visit, void *arg) { AST_object *self = (AST_object*)op; Py_VISIT(Py_TYPE(self)); - Py_VISIT(self->dict); - return 0; + return PyObject_VisitManagedDict(op, visit, arg); } static int ast_clear(PyObject *op) { - AST_object *self = (AST_object*)op; - Py_CLEAR(self->dict); + PyObject_ClearManagedDict(op); return 0; } @@ -5670,11 +1917,6 @@ ast_type_replace(PyObject *self, PyObject *args, PyObject *kwargs) return result; } -static PyMemberDef ast_type_members[] = { - {"__dictoffset__", Py_T_PYSSIZET, offsetof(AST_object, dict), Py_READONLY}, - {NULL} /* Sentinel */ -}; - static PyMethodDef ast_type_methods[] = { {"__reduce__", ast_type_reduce, METH_NOARGS, NULL}, {"__replace__", _PyCFunction_CAST(ast_type_replace), METH_VARARGS | METH_KEYWORDS, @@ -5792,37 +2034,36 @@ ast_repr_max_depth(AST_object *self, int depth) return NULL; } - if (depth <= 0) { - return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name); - } - - int status = Py_ReprEnter((PyObject *)self); - if (status != 0) { - if (status < 0) { - return NULL; - } - return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name); - } - - PyObject *fields; - if (PyObject_GetOptionalAttr((PyObject *)Py_TYPE(self), state->_fields, &fields) < 0) { - Py_ReprLeave((PyObject *)self); + PyObject *fields = PyObject_GetAttr((PyObject *)Py_TYPE(self), state->_fields); + if (!fields) { return NULL; } Py_ssize_t numfields = PySequence_Size(fields); if (numfields < 0) { - Py_ReprLeave((PyObject *)self); Py_DECREF(fields); return NULL; } if (numfields == 0) { - Py_ReprLeave((PyObject *)self); Py_DECREF(fields); return PyUnicode_FromFormat("%s()", Py_TYPE(self)->tp_name); } + if (depth <= 0) { + Py_DECREF(fields); + return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name); + } + + int status = Py_ReprEnter((PyObject *)self); + if (status != 0) { + Py_DECREF(fields); + if (status < 0) { + return NULL; + } + return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name); + } + const char* tp_name = Py_TYPE(self)->tp_name; PyUnicodeWriter *writer = PyUnicodeWriter_Create(0); if (writer == NULL) { @@ -5920,7 +2161,6 @@ static PyType_Slot AST_type_slots[] = { {Py_tp_setattro, PyObject_GenericSetAttr}, {Py_tp_traverse, ast_traverse}, {Py_tp_clear, ast_clear}, - {Py_tp_members, ast_type_members}, {Py_tp_methods, ast_type_methods}, {Py_tp_getset, ast_type_getsets}, {Py_tp_init, ast_type_init}, @@ -5934,7 +2174,8 @@ static PyType_Spec AST_type_spec = { "ast.AST", sizeof(AST_object), 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_MANAGED_DICT, AST_type_slots }; @@ -18549,22 +14790,25 @@ PyObject* PyAST_mod2obj(mod_ty t) return result; } -/* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */ +/* mode is 0 for "exec", 1 for "eval", 2 for "single" and 3 for "func_type" + input */ int PyAst_CheckMode(PyObject *ast, int mode) { - const char * const req_name[] = {"Module", "Expression", "Interactive"}; + const char * const req_name[] = {"Module", "Expression", "Interactive", + "FunctionType"}; struct ast_state *state = get_ast_state(); if (state == NULL) { return -1; } - PyObject *req_type[3]; + PyObject *req_type[4]; req_type[0] = state->Module_type; req_type[1] = state->Expression_type; req_type[2] = state->Interactive_type; + req_type[3] = state->FunctionType_type; - assert(0 <= mode && mode <= 2); + assert(0 <= mode && mode <= 3); int isinstance = PyObject_IsInstance(ast, req_type[mode]); if (isinstance == -1) { return -1; diff --git a/Python/Python-tokenize.c b/Python/Python-tokenize.c index e6d39e4c7dc8235..951d4976c147c03 100644 --- a/Python/Python-tokenize.c +++ b/Python/Python-tokenize.c @@ -1,9 +1,6 @@ #include "Python.h" #include "errcode.h" #include "internal/pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION -#include "internal/pycore_tuple.h" // _PyTuple_FromPair -#include "../Parser/lexer/state.h" -#include "../Parser/lexer/lexer.h" #include "../Parser/tokenizer/tokenizer.h" #include "../Parser/pegen.h" // _PyPegen_byte_offset_to_character_offset() @@ -22,7 +19,6 @@ get_tokenize_state(PyObject *module) { get_tokenize_state(PyType_GetModuleByDef(type, &_tokenizemodule)) #include "pycore_runtime.h" -#include "clinic/Python-tokenize.c.h" /*[clinic input] module _tokenizer @@ -34,14 +30,16 @@ typedef struct { PyObject_HEAD struct tok_state *tok; int done; + int extra_tokens; /* Needed to cache line for performance */ PyObject *last_line; Py_ssize_t last_lineno; - Py_ssize_t last_end_lineno; Py_ssize_t byte_col_offset_diff; } tokenizeriterobject; +#include "clinic/Python-tokenize.c.h" + /*[clinic input] @classmethod _tokenizer.tokenizeriter.__new__ as tokenizeriter_new @@ -58,65 +56,59 @@ tokenizeriter_new_impl(PyTypeObject *type, PyObject *readline, int extra_tokens, const char *encoding) /*[clinic end generated code: output=7501a1211683ce16 input=f7dddf8a613ae8bd]*/ { - tokenizeriterobject *self = (tokenizeriterobject *)type->tp_alloc(type, 0); - if (self == NULL) { - return NULL; - } - PyObject *filename = PyUnicode_FromString(""); - if (filename == NULL) { + struct tok_state *tok = _PyTokenizer_FromReadline(readline, encoding); + if (tok == NULL) { return NULL; } - self->tok = _PyTokenizer_FromReadline(readline, encoding, 1, 1); - if (self->tok == NULL) { - Py_DECREF(filename); + _Py_DECLARE_STR(anon_string, ""); + _PyTokenizer_SetContext(tok, &_Py_STR(anon_string), NULL); + tokenizeriterobject *self = (tokenizeriterobject *)type->tp_alloc(type, 0); + if (self == NULL) { + _PyTokenizer_Free(tok); return NULL; } - self->tok->filename = filename; - if (extra_tokens) { - self->tok->tok_extra_tokens = 1; - } + self->tok = tok; + _PyTokenizer_SetOptions(self->tok, extra_tokens, 0); + self->extra_tokens = extra_tokens; self->done = 0; self->last_line = NULL; self->byte_col_offset_diff = 0; self->last_lineno = 0; - self->last_end_lineno = 0; return (PyObject *)self; } -static int +static void _tokenizer_error(tokenizeriterobject *it) { _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(it); - if (PyErr_Occurred()) { - return -1; - } + assert(!PyErr_Occurred()); const char *msg = NULL; PyObject* errtype = PyExc_SyntaxError; struct tok_state *tok = it->tok; - switch (tok->done) { + _PyTokenizer_Info info = _PyTokenizer_GetInfo(tok); + switch (info.status) { case E_TOKEN: msg = "invalid token"; break; case E_EOF: PyErr_SetString(PyExc_SyntaxError, "unexpected EOF in multi-line statement"); - PyErr_SyntaxLocationObject(tok->filename, tok->lineno, - tok->inp - tok->buf < 0 ? 0 : (int)(tok->inp - tok->buf)); - return -1; + PyErr_SyntaxLocationObject( + info.filename, info.location.lineno, + (int)Py_MAX(0, info.input_span.end - info.input_span.start)); + return; case E_DEDENT: msg = "unindent does not match any outer indentation level"; errtype = PyExc_IndentationError; break; case E_INTR: - if (!PyErr_Occurred()) { - PyErr_SetNone(PyExc_KeyboardInterrupt); - } - return -1; + PyErr_SetNone(PyExc_KeyboardInterrupt); + return; case E_NOMEM: PyErr_NoMemory(); - return -1; + return; case E_TABSPACE: errtype = PyExc_TabError; msg = "inconsistent use of tabs and spaces in indentation"; @@ -133,86 +125,78 @@ _tokenizer_error(tokenizeriterobject *it) msg = "unknown tokenization error"; } - PyObject* errstr = NULL; PyObject* error_line = NULL; - PyObject* tmp = NULL; PyObject* value = NULL; - int result = 0; - Py_ssize_t size = tok->inp - tok->buf; - assert(tok->buf[size-1] == '\n'); + Py_ssize_t input_size; + const char *input = _PyTokenizer_SpanView( + tok, info.input_span, &input_size); + Py_ssize_t size = input_size; + assert(input[size-1] == '\n'); size -= 1; // Remove the newline character from the end of the line - error_line = PyUnicode_DecodeUTF8(tok->buf, size, "replace"); + error_line = PyUnicode_DecodeUTF8(input, size, "replace"); if (!error_line) { - result = -1; goto exit; } - Py_ssize_t offset = _PyPegen_byte_offset_to_character_offset(error_line, tok->inp - tok->buf); + Py_ssize_t offset = _PyPegen_byte_offset_to_character_offset(error_line, input_size); if (offset == -1) { - result = -1; - goto exit; - } - tmp = Py_BuildValue("(OnnOOO)", tok->filename, tok->lineno, offset, error_line, Py_None, Py_None); - if (!tmp) { - result = -1; goto exit; } - - errstr = PyUnicode_FromString(msg); - if (!errstr) { - result = -1; - goto exit; - } - - value = _PyTuple_FromPair(errstr, tmp); + value = Py_BuildValue("(s(OinOOO))", msg, info.filename, + info.location.lineno, offset, error_line, + Py_None, Py_None); if (!value) { - result = -1; goto exit; } PyErr_SetObject(errtype, value); exit: - Py_XDECREF(errstr); Py_XDECREF(error_line); - Py_XDECREF(tmp); Py_XDECREF(value); - return result; } static PyObject * -_get_current_line(tokenizeriterobject *it, const char *line_start, Py_ssize_t size, - int *line_changed) +_get_current_line(tokenizeriterobject *it, int current_lineno, + const _PyToken_View *view, int *line_changed) { _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(it); - PyObject *line; - if (it->tok->lineno != it->last_lineno) { - // Line has changed since last token, so we fetch the new line and cache it - // in the iter object. + if (current_lineno != it->last_lineno) { + Py_ssize_t size; + const char *line_start = _PyTokenizer_SpanView( + it->tok, view->line_span, &size); + if (size > 0 && view->implicit_newline) { + size--; + } Py_XDECREF(it->last_line); - line = PyUnicode_DecodeUTF8(line_start, size, "replace"); - it->last_line = line; + it->last_line = PyUnicode_DecodeUTF8(line_start, size, "replace"); it->byte_col_offset_diff = 0; } else { - line = it->last_line; *line_changed = 0; } - return line; + return it->last_line; } -static void -_get_col_offsets(tokenizeriterobject *it, struct token token, const char *line_start, - PyObject *line, int line_changed, Py_ssize_t lineno, Py_ssize_t end_lineno, +static int +_get_col_offsets(tokenizeriterobject *it, const struct token *token, + const _PyToken_View *view, PyObject *line, int line_changed, Py_ssize_t *col_offset, Py_ssize_t *end_col_offset) { _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(it); + _PyTok_Off token_start = token->span.start; + _PyTok_Off token_end = token->span.end; + Py_ssize_t lineno = token->start_loc.lineno; + Py_ssize_t end_lineno = token->end_loc.lineno; Py_ssize_t byte_offset = -1; - if (token.start != NULL && token.start >= line_start) { - byte_offset = token.start - line_start; + if (token_start >= view->line_span.start) { + byte_offset = token_start - view->line_span.start; if (line_changed) { *col_offset = _PyPegen_byte_offset_to_character_offset_line(line, 0, byte_offset); + if (*col_offset < 0) { + return -1; + } it->byte_col_offset_diff = byte_offset - *col_offset; } else { @@ -220,37 +204,53 @@ _get_col_offsets(tokenizeriterobject *it, struct token token, const char *line_s } } - if (token.end != NULL && token.end >= it->tok->line_start) { - Py_ssize_t end_byte_offset = token.end - it->tok->line_start; + if (token_end >= view->end_line_start) { + Py_ssize_t end_byte_offset = token_end - view->end_line_start; if (lineno == end_lineno) { - // If the whole token is at the same line, we can just use the token.start - // buffer for figuring out the new column offset, since using line is not - // performant for very long lines. + // Avoid rescanning the prefix of a very long line. Py_ssize_t token_col_offset = _PyPegen_byte_offset_to_character_offset_line(line, byte_offset, end_byte_offset); + if (token_col_offset < 0) { + return -1; + } *end_col_offset = *col_offset + token_col_offset; - it->byte_col_offset_diff += token.end - token.start - token_col_offset; + it->byte_col_offset_diff += token_end - token_start - token_col_offset; } else { - *end_col_offset = _PyPegen_byte_offset_to_character_offset_raw(it->tok->line_start, end_byte_offset); + *end_col_offset = _PyPegen_byte_offset_to_character_offset_line( + line, view->end_line_start - view->line_span.start, + token_end - view->line_span.start); + if (*end_col_offset < 0) { + return -1; + } it->byte_col_offset_diff += end_byte_offset - *end_col_offset; } } it->last_lineno = lineno; - it->last_end_lineno = end_lineno; + return 0; } +/*[clinic input] +@critical_section +_tokenizer.tokenizeriter.__next__ as tokenizeriter_next +[clinic start generated code]*/ + static PyObject * -tokenizeriter_next(PyObject *op) +tokenizeriter_next_impl(tokenizeriterobject *self) +/*[clinic end generated code: output=745c9c646781ff45 input=66f70c965ba8ccfe]*/ { - tokenizeriterobject *it = (tokenizeriterobject*)op; + tokenizeriterobject *it = self; PyObject* result = NULL; - Py_BEGIN_CRITICAL_SECTION(it); + if (it->done) { + PyErr_SetString(PyExc_StopIteration, "EOF"); + return NULL; + } struct token token; _PyToken_Init(&token); - int type = _PyTokenizer_Get(it->tok, &token); + _PyTokenizer_Get(it->tok, &token); + int type = token.type; if (type == ERRORTOKEN) { if(!PyErr_Occurred()) { _tokenizer_error(it); @@ -258,53 +258,39 @@ tokenizeriter_next(PyObject *op) } goto exit; } - if (it->done || type == ERRORTOKEN) { - PyErr_SetString(PyExc_StopIteration, "EOF"); - it->done = 1; - goto exit; - } - PyObject *str = NULL; - if (token.start == NULL || token.end == NULL) { - str = Py_GetConstant(Py_CONSTANT_EMPTY_STR); - } - else { - str = PyUnicode_FromStringAndSize(token.start, token.end - token.start); - } + _PyToken_View view; + _PyToken_GetView(it->tok, &token, &view); + PyObject *str = PyUnicode_FromStringAndSize(view.text, view.length); if (str == NULL) { goto exit; } - int is_trailing_token = 0; - if (type == ENDMARKER || (type == DEDENT && it->tok->done == E_EOF)) { - is_trailing_token = 1; - } + int is_trailing_token = type == ENDMARKER || (type == DEDENT && view.at_eof); - const char *line_start = ISSTRINGLIT(type) ? it->tok->multi_line_start : it->tok->line_start; PyObject* line = NULL; int line_changed = 1; - if (it->tok->tok_extra_tokens && is_trailing_token) { + if (it->extra_tokens && is_trailing_token) { line = Py_GetConstant(Py_CONSTANT_EMPTY_STR); } else { - Py_ssize_t size = it->tok->inp - line_start; - if (size >= 1 && it->tok->implicit_newline) { - size -= 1; - } - - line = _get_current_line(it, line_start, size, &line_changed); + line = _get_current_line( + it, token.end_loc.lineno, &view, &line_changed); } if (line == NULL) { Py_DECREF(str); goto exit; } - Py_ssize_t lineno = ISSTRINGLIT(type) ? it->tok->first_lineno : it->tok->lineno; - Py_ssize_t end_lineno = it->tok->lineno; + Py_ssize_t lineno = token.start_loc.lineno; + Py_ssize_t end_lineno = token.end_loc.lineno; Py_ssize_t col_offset = -1; Py_ssize_t end_col_offset = -1; - _get_col_offsets(it, token, line_start, line, line_changed, - lineno, end_lineno, &col_offset, &end_col_offset); + if (_get_col_offsets(it, &token, &view, line, + line_changed, &col_offset, &end_col_offset) < 0) { + Py_DECREF(str); + goto exit; + } - if (it->tok->tok_extra_tokens) { + if (it->extra_tokens) { if (is_trailing_token) { lineno = end_lineno = lineno + 1; col_offset = end_col_offset = 0; @@ -315,9 +301,9 @@ tokenizeriter_next(PyObject *op) type = OP; } else if (type == NEWLINE) { - Py_DECREF(str); - if (!it->tok->implicit_newline) { - if (it->tok->start[0] == '\r') { + if (!view.implicit_newline) { + Py_DECREF(str); + if (view.text[0] == '\r') { str = PyUnicode_FromString("\r\n"); } else { str = PyUnicode_FromString("\n"); @@ -326,14 +312,13 @@ tokenizeriter_next(PyObject *op) end_col_offset++; } else if (type == NL) { - if (it->tok->implicit_newline) { + if (view.implicit_newline) { Py_DECREF(str); str = Py_GetConstant(Py_CONSTANT_EMPTY_STR); } } if (str == NULL) { - Py_DECREF(line); goto exit; } } @@ -344,8 +329,6 @@ tokenizeriter_next(PyObject *op) if (type == ENDMARKER) { it->done = 1; } - - Py_END_CRITICAL_SECTION(); return result; } @@ -354,15 +337,26 @@ tokenizeriter_dealloc(PyObject *op) { tokenizeriterobject *it = (tokenizeriterobject*)op; PyTypeObject *tp = Py_TYPE(it); + PyObject_GC_UnTrack(it); Py_XDECREF(it->last_line); _PyTokenizer_Free(it->tok); tp->tp_free(it); Py_DECREF(tp); } +static int +tokenizeriter_traverse(PyObject *op, visitproc visit, void *arg) +{ + tokenizeriterobject *it = (tokenizeriterobject *)op; + Py_VISIT(Py_TYPE(it)); + Py_VISIT(it->last_line); + return _PyTokenizer_Traverse(it->tok, visit, arg); +} + static PyType_Slot tokenizeriter_slots[] = { {Py_tp_new, tokenizeriter_new}, {Py_tp_dealloc, tokenizeriter_dealloc}, + {Py_tp_traverse, tokenizeriter_traverse}, {Py_tp_getattro, PyObject_GenericGetAttr}, {Py_tp_iter, PyObject_SelfIter}, {Py_tp_iternext, tokenizeriter_next}, @@ -372,7 +366,7 @@ static PyType_Slot tokenizeriter_slots[] = { static PyType_Spec tokenizeriter_spec = { .name = "_tokenize.TokenizerIter", .basicsize = sizeof(tokenizeriterobject), - .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE), + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_HAVE_GC), .slots = tokenizeriter_slots, }; diff --git a/Python/README b/Python/README index 153b628bd5b42d6..625f0afe5febd55 100644 --- a/Python/README +++ b/Python/README @@ -1 +1 @@ -Miscellaneous source files for the main Python shared library +Miscellaneous source files for the main Python shared library. diff --git a/Python/_strptime.c b/Python/_strptime.c new file mode 100644 index 000000000000000..3770abfa07d559e --- /dev/null +++ b/Python/_strptime.c @@ -0,0 +1,250 @@ +#include "Python.h" +#include "pycore_time.h" + + +/* Implement common parts of strptime in C to improve performance. Callers + * fall back to Lib/_strptime.py for a full parse when this doesn't match. + * + * Supported inputs are exact str objects containing only ASCII, with: + * - numeric %Y, %y, %m, %d, %H, %M, %S, and %f fields; + * - a terminal %z: empty, Z, or +/-HHMM or +/-HH:MM with hours below 24; + * - literal characters, %%, and ASCII whitespace. + * + * Duplicate directives, mixed %Y/%y, and day-of-month without a year use the + * fallback. So do other directives (including locale-dependent names and + * week/day-of-year calculations), and offsets with seconds or fractions. + */ + +static int +strptime_digits(const unsigned char *data, Py_ssize_t length, Py_ssize_t pos, + int minimum, int maximum, int *value) +{ + int count = 0; + *value = 0; + while (count < maximum && pos + count < length) { + unsigned char c = data[pos + count]; + if (c < '0' || c > '9') { + break; + } + *value = *value * 10 + c - '0'; + count++; + } + return count >= minimum ? count : 0; +} + +static int +strptime_offset(const unsigned char *data, Py_ssize_t length, Py_ssize_t pos, + _PyTime_StrptimeFields *fields) +{ + Py_ssize_t remaining = length - pos; + if (remaining == 0) { + return 1; + } + if (remaining == 1 && data[pos] == 'Z') { + fields->gmtoff = 0; + return 1; + } + /* Offsets containing seconds or fractions fall back to _strptime.py. */ + if ((remaining != 5 && remaining != 6) || + (data[pos] != '+' && data[pos] != '-')) { + return 0; + } + int hours, minutes; + int colon = remaining == 6; + if ((colon && data[pos + 3] != ':') || + strptime_digits(data, length, pos + 1, 2, 2, &hours) != 2 || + strptime_digits(data, length, pos + 3 + colon, 2, 2, &minutes) != 2 || + hours > 23 || minutes > 59) { + return 0; + } + fields->gmtoff = (hours * 3600 + minutes * 60) * + (data[pos] == '-' ? -1 : 1); + return 1; +} + +/* Return 1 for a complete numeric match, or 0 if fallback is required. + * + * Parsing doesn't allocate or set exceptions. Some mismatches require regex + * backtracking, but even inputs known to be invalid use the Python parser: + * it owns the exception messages and error precedence. For example, month 13 + * and empty input can't be repaired by backtracking, but diagnosing them here + * would duplicate the Python parser's error handling. A return value of 0 + * therefore doesn't distinguish invalid input from an unsupported format. + */ +int +_PyTime_Strptime(PyObject *string, PyObject *format, _PyTime_StrptimeFields *fields) +{ + enum { + YEAR = 1U << 0, + SHORT_YEAR = 1U << 1, + MONTH = 1U << 2, + DAY = 1U << 3, + HOUR = 1U << 4, + MINUTE = 1U << 5, + SECOND = 1U << 6, + FRACTION = 1U << 7, + OFFSET = 1U << 8, + ANY_YEAR = YEAR | SHORT_YEAR, + }; + static const unsigned short directive_bits[128] = { + ['Y'] = YEAR, + ['y'] = SHORT_YEAR, + ['m'] = MONTH, + ['d'] = DAY, + ['H'] = HOUR, + ['M'] = MINUTE, + ['S'] = SECOND, + ['f'] = FRACTION, + ['z'] = OFFSET, + }; + /* String subclasses and non-ASCII input retain Python's behavior. */ + if (!PyUnicode_CheckExact(string) || !PyUnicode_CheckExact(format) || + !PyUnicode_IS_ASCII(string) || !PyUnicode_IS_ASCII(format)) { + return 0; + } + const unsigned char *data = PyUnicode_1BYTE_DATA(string); + const unsigned char *fmt = PyUnicode_1BYTE_DATA(format); + Py_ssize_t length = PyUnicode_GET_LENGTH(string); + Py_ssize_t fmt_length = PyUnicode_GET_LENGTH(format); + *fields = (_PyTime_StrptimeFields){.year = 1900, .month = 1, .day = 1, .gmtoff = INT_MIN}; + unsigned int seen = 0; + Py_ssize_t pos = 0; + + for (Py_ssize_t i = 0; i < fmt_length; i++) { + unsigned char c = fmt[i]; + /* Match regex \s, including ASCII separators U+001C through U+001F. */ + if (Py_UNICODE_ISSPACE(c)) { + if (pos == length || !Py_UNICODE_ISSPACE(data[pos])) { + return 0; + } + while (i + 1 < fmt_length && Py_UNICODE_ISSPACE(fmt[i + 1])) { + i++; + } + do { + pos++; + } while (pos < length && Py_UNICODE_ISSPACE(data[pos])); + continue; + } + if (c != '%') { + if (pos == length || data[pos++] != c) { + return 0; + } + continue; + } + if (++i == fmt_length) { + return 0; + } + c = fmt[i]; + if (c == '%') { + if (pos == length || data[pos++] != '%') { + return 0; + } + continue; + } + + /* Reject duplicate groups, aliases, and locale-dependent directives. */ + unsigned int bit = directive_bits[c]; + if (bit == 0) { + return 0; + } + if (seen & bit) { + return 0; + } + seen |= bit; + + if (c == 'z') { + if (i != fmt_length - 1 || + !strptime_offset(data, length, pos, fields)) { + return 0; + } + pos = length; + continue; + } + + int minimum = 1; + int maximum = 2; + if (c == 'Y') { + minimum = maximum = 4; + } + else if (c == 'y') { + minimum = maximum = 2; + } + else if (c == 'f') { + maximum = 6; + } + else if ((c == 'd' || c == 'H') && pos < length && data[pos] == ' ') { + pos++; + maximum = 1; + } + int value; + int count = strptime_digits(data, length, pos, minimum, maximum, &value); + if (count == 0) { + return 0; + } + pos += count; + switch (c) { + case 'Y': + fields->year = value; + break; + case 'y': + fields->year = value + (value <= 68 ? 2000 : 1900); + break; + case 'm': + if (value < 1 || value > 12) { + return 0; + } + fields->month = value; + break; + case 'd': + if (value < 1 || value > 31) { + return 0; + } + fields->day = value; + break; + case 'H': + if (value > 23) { + return 0; + } + fields->hour = value; + break; + case 'M': + if (value > 59) { + return 0; + } + fields->minute = value; + break; + case 'S': + if (value > 61) { + return 0; + } + fields->second = value; + break; + case 'f': + for (; count < 6; count++) { + value *= 10; + } + fields->fraction = value; + break; + } + } + static const int days_before_month[] = { + 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 + }; + int leap = fields->year % 4 == 0 && + (fields->year % 100 != 0 || fields->year % 400 == 0); + int month_days = days_before_month[fields->month + 1] - + days_before_month[fields->month]; + if (fields->month == 2) { + month_days += leap; + } + /* Mixed %Y/%y and day-without-year diagnostics belong to Python. */ + if (pos != length || (seen & ANY_YEAR) == ANY_YEAR || + ((seen & DAY) && !(seen & ANY_YEAR)) || + fields->year < 1 || + fields->day > month_days) { + return 0; + } + fields->yday = days_before_month[fields->month] + fields->day + + (fields->month > 2 && leap); + return 1; +} diff --git a/Python/_warnings.c b/Python/_warnings.c index 4f6de50efa14a8e..c6a2441ec937cfa 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -1,14 +1,18 @@ #include "Python.h" +#include "pycore_critical_section.h" // _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED() #include "pycore_frame.h" // PyFrameObject #include "pycore_genobject.h" // PyAsyncGenObject #include "pycore_import.h" // _PyImport_GetModules() #include "pycore_interpframe.h" // _PyFrame_GetCode() #include "pycore_long.h" // _PyLong_GetZero() +#include "pycore_object.h" // _Py_XGetRef() +#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_SSIZE_ACQUIRE() #include "pycore_pylifecycle.h" // _Py_IsInterpreterFinalizing() #include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_traceback.h" // _Py_DisplaySourceLine() #include "pycore_tuple.h" // _PyTuple_FromPair #include "pycore_unicodeobject.h" // _PyUnicode_EqualToASCIIString() +#include "pycore_warnings.h" // _PyWarnings_AfterFork() #include #include "clinic/_warnings.c.h" @@ -141,6 +145,7 @@ _PyWarnings_InitState(PyInterpreterState *interp) if (st->filters == NULL) { return -1; } + PyUnstable_EnableTryIncRef(st->filters); } if (st->once_registry == NULL) { @@ -148,6 +153,7 @@ _PyWarnings_InitState(PyInterpreterState *interp) if (st->once_registry == NULL) { return -1; } + PyUnstable_EnableTryIncRef(st->once_registry); } if (st->default_action == NULL) { @@ -155,6 +161,7 @@ _PyWarnings_InitState(PyInterpreterState *interp) if (st->default_action == NULL) { return -1; } + PyUnstable_EnableTryIncRef(st->default_action); } if (st->context == NULL) { @@ -276,6 +283,23 @@ warnings_lock_held(WarningsState *st) return PyMutex_IsLocked(&st->lock.mutex); } +#ifdef HAVE_FORK +void +_PyWarnings_BeforeFork(PyInterpreterState *interp) +{ + WarningsState *st = warnings_get_state(interp); + st->lock_held_at_fork = _PyRecursiveMutex_IsLockedByCurrentThread(&st->lock); +} + +void +_PyWarnings_AfterFork(PyInterpreterState *interp) +{ + WarningsState *st = warnings_get_state(interp); + _PyRecursiveMutex_at_fork_reinit(&st->lock, st->lock_held_at_fork); + st->lock_held_at_fork = false; +} +#endif + static PyObject * get_warnings_context(PyInterpreterState *interp) { @@ -315,7 +339,30 @@ get_warnings_context_filters(PyInterpreterState *interp) return context_filters; } -// Returns a borrowed reference to the list. +/* Store 'value' in the warnings state field '*ptr'. */ +static void +update_state_ref(PyObject **ptr, PyObject *value) +{ + if (FT_ATOMIC_LOAD_PTR_ACQUIRE(*ptr) == value) { + return; + } + PyUnstable_EnableTryIncRef(value); + PyObject *old = _Py_atomic_exchange_ptr(ptr, Py_NewRef(value)); + Py_XDECREF(old); +} + +/* Return a new reference to the warnings state field '*ptr'. */ +static PyObject * +get_state_ref(PyObject **ptr) +{ +#ifdef Py_GIL_DISABLED + return _Py_XGetRef(ptr); +#else + return Py_XNewRef(*ptr); +#endif +} + +// Returns a new reference to the list. static PyObject * get_warnings_filters(PyInterpreterState *interp) { @@ -324,15 +371,17 @@ get_warnings_filters(PyInterpreterState *interp) if (warnings_filters == NULL) { if (PyErr_Occurred()) return NULL; + warnings_filters = get_state_ref(&st->filters); } else { - Py_SETREF(st->filters, warnings_filters); + update_state_ref(&st->filters, warnings_filters); } - PyObject *filters = st->filters; + PyObject *filters = warnings_filters; if (filters == NULL || !PyList_Check(filters)) { PyErr_SetString(PyExc_ValueError, MODULE_NAME ".filters must be a list"); + Py_XDECREF(filters); return NULL; } return filters; @@ -375,20 +424,20 @@ warnings_release_lock_impl(PyObject *module) Py_RETURN_NONE; } +// Returns a new reference. static PyObject * get_once_registry(PyInterpreterState *interp) { WarningsState *st = warnings_get_state(interp); assert(st != NULL); - assert(warnings_lock_held(st)); - PyObject *registry = GET_WARNINGS_ATTR(interp, onceregistry, 0); if (registry == NULL) { if (PyErr_Occurred()) return NULL; - assert(st->once_registry); - return st->once_registry; + registry = get_state_ref(&st->once_registry); + assert(registry != NULL); + return registry; } if (!PyDict_Check(registry)) { PyErr_Format(PyExc_TypeError, @@ -398,26 +447,26 @@ get_once_registry(PyInterpreterState *interp) Py_DECREF(registry); return NULL; } - Py_SETREF(st->once_registry, registry); + update_state_ref(&st->once_registry, registry); return registry; } +// Returns a new reference. static PyObject * get_default_action(PyInterpreterState *interp) { WarningsState *st = warnings_get_state(interp); assert(st != NULL); - assert(warnings_lock_held(st)); - PyObject *default_action = GET_WARNINGS_ATTR(interp, defaultaction, 0); if (default_action == NULL) { if (PyErr_Occurred()) { return NULL; } - assert(st->default_action); - return st->default_action; + default_action = get_state_ref(&st->default_action); + assert(default_action != NULL); + return default_action; } if (!PyUnicode_Check(default_action)) { PyErr_Format(PyExc_TypeError, @@ -427,7 +476,7 @@ get_default_action(PyInterpreterState *interp) Py_DECREF(default_action); return NULL; } - Py_SETREF(st->default_action, default_action); + update_state_ref(&st->default_action, default_action); return default_action; } @@ -513,18 +562,12 @@ filter_search(PyInterpreterState *interp, PyObject *category, return result; } -/* The item is a new reference. */ +/* The returned action and the item are new references. */ static PyObject* get_filter(PyInterpreterState *interp, PyObject *category, PyObject *text, Py_ssize_t lineno, PyObject *module, PyObject *filename, PyObject **item) { -#ifdef Py_DEBUG - WarningsState *st = warnings_get_state(interp); - assert(st != NULL); - assert(warnings_lock_held(st)); -#endif - /* check _warning_context _filters list */ PyObject *context_filters = get_warnings_context_filters(interp); if (context_filters == NULL) { @@ -542,7 +585,7 @@ get_filter(PyInterpreterState *interp, PyObject *category, } Py_DECREF(context_filters); if (context_action != NULL) { - return context_action; + return Py_NewRef(context_action); } } @@ -554,12 +597,14 @@ get_filter(PyInterpreterState *interp, PyObject *category, if (filters == NULL) { return NULL; } - if (!filter_search(interp, category, text, lineno, module, filename, "filters", - filters, item, &action)) { + bool ok = filter_search(interp, category, text, lineno, module, + filename, "filters", filters, item, &action); + Py_DECREF(filters); + if (!ok) { return NULL; } if (action != NULL) { - return action; + return Py_NewRef(action); } } @@ -573,72 +618,143 @@ get_filter(PyInterpreterState *interp, PyObject *category, } +/* Returns 1 if 'registry' is stamped with 'version', 0 if not, -1 on error. */ static int -already_warned(PyInterpreterState *interp, PyObject *registry, PyObject *key, - int should_set) +registry_version_matches(PyObject *registry, Py_ssize_t version) { - PyObject *already_warned; + PyObject *version_obj; + if (PyDict_GetItemRef(registry, &_Py_ID(version), &version_obj) < 0) { + return -1; + } + int rc = 0; + if (version_obj != NULL && PyLong_CheckExact(version_obj)) { + int overflow; + long long v = PyLong_AsLongLongAndOverflow(version_obj, &overflow); + rc = (!overflow && v == version); + } + Py_XDECREF(version_obj); + return rc; +} - if (key == NULL) +static int +set_registry_version(PyObject *registry, Py_ssize_t version) +{ + PyObject *version_obj = PyLong_FromSsize_t(version); + if (version_obj == NULL) { return -1; + } + int rc = PyDict_SetItem(registry, &_Py_ID(version), version_obj); + Py_DECREF(version_obj); + return rc; +} +/* Make 'registry' usable for filters 'version', clearing it if it is stamped + with a different version. Returns 1 if it can be used, 0 if 'version' is + no longer current, -1 on error. */ +static int +check_registry_version(PyInterpreterState *interp, PyObject *registry, + Py_ssize_t version) +{ + _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(registry); WarningsState *st = warnings_get_state(interp); - assert(st != NULL); - assert(warnings_lock_held(st)); - PyObject *version_obj; - if (PyDict_GetItemRef(registry, &_Py_ID(version), &version_obj) < 0) { + int rc = registry_version_matches(registry, version); + if (rc != 0) { + return rc; + } + if (version != FT_ATOMIC_LOAD_SSIZE_ACQUIRE(st->filters_version)) { + // The caller's filter search is stale, don't record its result. + return 0; + } + + PyDict_Clear(registry); + return set_registry_version(registry, version) < 0 ? -1 : 1; +} + +static int +registry_contains(PyObject *registry, PyObject *key) +{ + PyObject *value; + if (PyDict_GetItemRef(registry, key, &value) < 0) { return -1; } - bool should_update_version = ( - version_obj == NULL - || !PyLong_CheckExact(version_obj) - || PyLong_AsLong(version_obj) != st->filters_version - ); - Py_XDECREF(version_obj); - if (should_update_version) { - PyDict_Clear(registry); - version_obj = PyLong_FromLong(st->filters_version); - if (version_obj == NULL) - return -1; - if (PyDict_SetItem(registry, &_Py_ID(version), version_obj) < 0) { - Py_DECREF(version_obj); - return -1; - } - Py_DECREF(version_obj); + if (value == NULL) { + return 0; } - else { - if (PyDict_GetItemRef(registry, key, &already_warned) < 0) { - return -1; - } - if (already_warned != NULL) { - int rc = PyObject_IsTrue(already_warned); - Py_DECREF(already_warned); - if (rc != 0) - return rc; + int rc = PyObject_IsTrue(value); + Py_DECREF(value); + return rc; +} + +/* Returns 1 if 'key' is recorded in 'registry' for the current filters version, + 0 if not, -1 on error. Stores the version checked in '*pversion'. */ +static int +already_warned(PyInterpreterState *interp, PyObject *registry, PyObject *key, + Py_ssize_t *pversion) +{ + int rc; + Py_BEGIN_CRITICAL_SECTION(registry); + WarningsState *st = warnings_get_state(interp); + Py_ssize_t version = FT_ATOMIC_LOAD_SSIZE_ACQUIRE(st->filters_version); + *pversion = version; + rc = registry_version_matches(registry, version); + if (rc > 0) { + rc = registry_contains(registry, key); + } + else if (rc == 0) { + /* Stamped with an old version, reset it. 'key' can't be present. */ + PyDict_Clear(registry); + if (set_registry_version(registry, version) < 0) { + rc = -1; } } + Py_END_CRITICAL_SECTION(); + return rc; +} - /* This warning wasn't found in the registry, set it. */ - if (should_set) - return PyDict_SetItem(registry, key, Py_True); - return 0; +/* Returns 1 if 'key' was already in 'registry', 0 if it was added, -1 on + error. */ +static int +registry_add(PyObject *registry, PyObject *key) +{ + int rc = registry_contains(registry, key); + if (rc == 0 && PyDict_SetItem(registry, key, Py_True) < 0) { + rc = -1; + } + return rc; } +/* Record 'key' and 'altkey' (either may be NULL) in 'registry' for filters + 'version'. Returns 0 if the warning should be shown, 1 if it was already + recorded, -1 on error. */ static int -update_registry(PyInterpreterState *interp, PyObject *registry, PyObject *text, - PyObject *category, int add_zero) +record_warning(PyInterpreterState *interp, PyObject *registry, + PyObject *key, PyObject *altkey, Py_ssize_t version) { - PyObject *altkey; int rc; - - if (add_zero) - altkey = PyTuple_Pack(3, text, category, _PyLong_GetZero()); - else - altkey = _PyTuple_FromPair(text, category); - - rc = already_warned(interp, registry, altkey, 1); - Py_XDECREF(altkey); + Py_BEGIN_CRITICAL_SECTION(registry); + rc = check_registry_version(interp, registry, version); + if (rc > 0) { + rc = 0; + if (key != NULL) { + rc = registry_add(registry, key); + } + if (rc == 0 && altkey != NULL) { + rc = registry_add(registry, altkey); + } + if (rc >= 0) { + /* The critical section may have been suspended while the keys + were added, letting another thread clear and re-stamp the + registry. If so, invalidate it. */ + int match = registry_version_matches(registry, version); + if (match < 0 || + (match == 0 && set_registry_version(registry, -1) < 0)) + { + rc = -1; + } + } + } + Py_END_CRITICAL_SECTION(); return rc; } @@ -747,7 +863,8 @@ call_show_warning(PyThreadState *tstate, PyObject *category, } msg = PyObject_CallFunctionObjArgs(warnmsg_cls, message, category, - filename, lineno_obj, Py_None, Py_None, + filename, lineno_obj, Py_None, + sourceline ? sourceline : Py_None, source ? source : Py_None, module, NULL); Py_DECREF(warnmsg_cls); @@ -776,8 +893,8 @@ warn_explicit(PyThreadState *tstate, PyObject *category, PyObject *message, PyObject *source) { PyObject *key = NULL, *text = NULL, *result = NULL, *lineno_obj = NULL; - PyObject *item = NULL; - PyObject *action; + PyObject *item = NULL, *action = NULL; + PyObject *altkey = NULL, *once_registry = NULL; int rc; PyInterpreterState *interp = tstate->interp; @@ -821,14 +938,23 @@ warn_explicit(PyThreadState *tstate, PyObject *category, PyObject *message, if (key == NULL) goto cleanup; + /* The warnings lock is not held. 'version' ties the registry updates + to the filters searched; a result from filters that changed since is + never recorded. */ + Py_ssize_t version; if ((registry != NULL) && (registry != Py_None)) { - rc = already_warned(interp, registry, key, 0); + rc = already_warned(interp, registry, key, &version); if (rc == -1) goto cleanup; else if (rc == 1) goto return_none; /* Else this warning hasn't been generated before. */ } + else { + registry = NULL; + WarningsState *st = warnings_get_state(interp); + version = FT_ATOMIC_LOAD_SSIZE_ACQUIRE(st->filters_version); + } action = get_filter(interp, category, text, lineno, module, filename, &item); if (action == NULL) @@ -845,50 +971,58 @@ warn_explicit(PyThreadState *tstate, PyObject *category, PyObject *message, /* Store in the registry that we've been here, *except* when the action is "always" or "all". */ - rc = 0; if (!_PyUnicode_EqualToASCIIString(action, "always") && !_PyUnicode_EqualToASCIIString(action, "all")) { - if (registry != NULL && registry != Py_None && - PyDict_SetItem(registry, key, Py_True) < 0) + bool is_once = _PyUnicode_EqualToASCIIString(action, "once"); + bool is_module = _PyUnicode_EqualToASCIIString(action, "module"); + if (!is_once && !is_module && + !_PyUnicode_EqualToASCIIString(action, "default")) { + PyErr_Format(PyExc_RuntimeError, + "Unrecognized action (%R) in warnings.filters:\n %R", + action, item); goto cleanup; } - if (_PyUnicode_EqualToASCIIString(action, "once")) { - if (registry == NULL || registry == Py_None) { - registry = get_once_registry(interp); - if (registry == NULL) + if (is_once && registry == NULL) { + /* WarningsState.once_registry[(text, category)] = 1 */ + once_registry = get_once_registry(interp); + if (once_registry == NULL) + goto cleanup; + altkey = _PyTuple_FromPair(text, category); + if (altkey == NULL) + goto cleanup; + rc = record_warning(interp, once_registry, NULL, altkey, version); + } + else if (registry != NULL) { + /* registry[key] = 1, and for "once" and "module" also + registry[(text, category)] = 1 */ + if (is_once || is_module) { + altkey = _PyTuple_FromPair(text, category); + if (altkey == NULL) goto cleanup; } - /* WarningsState.once_registry[(text, category)] = 1 */ - rc = update_registry(interp, registry, text, category, 0); + rc = record_warning(interp, registry, key, altkey, version); } - else if (_PyUnicode_EqualToASCIIString(action, "module")) { - /* registry[(text, category, 0)] = 1 */ - if (registry != NULL && registry != Py_None) - rc = update_registry(interp, registry, text, category, 0); + else { + rc = 0; } - else if (!_PyUnicode_EqualToASCIIString(action, "default")) { - PyErr_Format(PyExc_RuntimeError, - "Unrecognized action (%R) in warnings.filters:\n %R", - action, item); + if (rc == -1) goto cleanup; - } + if (rc == 1) /* Already warned for this module. */ + goto return_none; } - if (rc == 1) /* Already warned for this module. */ - goto return_none; - if (rc == 0) { - if (call_show_warning(tstate, category, text, message, filename, - lineno, lineno_obj, sourceline, source, module) < 0) - goto cleanup; - } - else /* if (rc == -1) */ + if (call_show_warning(tstate, category, text, message, filename, + lineno, lineno_obj, sourceline, source, module) < 0) goto cleanup; return_none: result = Py_NewRef(Py_None); cleanup: + Py_XDECREF(once_registry); + Py_XDECREF(altkey); + Py_XDECREF(action); Py_XDECREF(item); Py_XDECREF(key); Py_XDECREF(text); @@ -1034,6 +1168,9 @@ setup_context(Py_ssize_t stack_level, if (f == NULL) { globals = interp->sysdict; *filename = PyUnicode_FromString(""); + if (*filename == NULL) { + return 0; + } *lineno = 0; } else { @@ -1132,10 +1269,8 @@ do_warn(PyObject *message, PyObject *category, Py_ssize_t stack_level, &filename, &lineno, &module, ®istry)) return NULL; - warnings_lock(tstate->interp); res = warn_explicit(tstate, category, message, filename, lineno, module, registry, NULL, source); - warnings_unlock(tstate->interp); Py_DECREF(filename); Py_DECREF(registry); Py_DECREF(module); @@ -1155,7 +1290,7 @@ warn as warnings_warn source: object = None If supplied, the destroyed object which emitted a ResourceWarning * - skip_file_prefixes: object(type='PyTupleObject *', subclass_of='&PyTuple_Type') = NULL + skip_file_prefixes: object(type='PyTupleObject *', subclass_of='&PyTuple_Type', c_default='NULL') = () An optional tuple of module filename prefixes indicating frames to skip during stacklevel computations for stack frame attribution. @@ -1166,7 +1301,7 @@ static PyObject * warnings_warn_impl(PyObject *module, PyObject *message, PyObject *category, Py_ssize_t stacklevel, PyObject *source, PyTupleObject *skip_file_prefixes) -/*[clinic end generated code: output=a68e0f6906c65f80 input=eb37c6a18bec4ea1]*/ +/*[clinic end generated code: output=a68e0f6906c65f80 input=2b52e8b20f508f51]*/ { category = get_category(message, category); if (category == NULL) @@ -1177,7 +1312,6 @@ warnings_warn_impl(PyObject *module, PyObject *message, PyObject *category, stacklevel = 2; } } else { - Py_DECREF((PyObject *)skip_file_prefixes); skip_file_prefixes = NULL; } } @@ -1200,12 +1334,33 @@ get_source_line(PyInterpreterState *interp, PyObject *module_globals, int lineno return NULL; } - int rc = PyDict_GetItemRef(module_globals, &_Py_ID(__name__), - &module_name); - if (rc < 0 || rc == 0) { + /* Prefer __spec__.name: __name__ is "__main__" for the module executed + as a script, but the loader can only handle its own module name. */ + PyObject *spec; + if (PyDict_GetItemRef(module_globals, &_Py_ID(__spec__), &spec) < 0) { Py_DECREF(loader); return NULL; } + module_name = NULL; + if (spec != NULL) { + int rc = PyObject_GetOptionalAttr(spec, &_Py_ID(name), &module_name); + Py_DECREF(spec); + if (rc < 0) { + Py_DECREF(loader); + return NULL; + } + if (module_name == Py_None) { + Py_CLEAR(module_name); + } + } + if (module_name == NULL) { + int rc = PyDict_GetItemRef(module_globals, &_Py_ID(__name__), + &module_name); + if (rc <= 0) { // not found or error + Py_DECREF(loader); + return NULL; + } + } /* Make sure the loader implements the optional get_source() method. */ (void)PyObject_GetOptionalAttr(loader, &_Py_ID(get_source), &get_source); @@ -1219,6 +1374,11 @@ get_source_line(PyInterpreterState *interp, PyObject *module_globals, int lineno Py_DECREF(get_source); Py_DECREF(module_name); if (!source) { + /* The source line is optional: the loader can be unable to provide + the source of the module, for example if it is not its loader. */ + if (PyErr_ExceptionMatches(PyExc_ImportError)) { + PyErr_Clear(); + } return NULL; } if (source == Py_None) { @@ -1234,8 +1394,11 @@ get_source_line(PyInterpreterState *interp, PyObject *module_globals, int lineno } /* Get the source line. */ - source_line = PyList_GetItem(source_list, lineno-1); - Py_XINCREF(source_line); + if (lineno < 1 || lineno > PyList_GET_SIZE(source_list)) { + Py_DECREF(source_list); + return NULL; + } + source_line = Py_NewRef(PyList_GET_ITEM(source_list, lineno-1)); Py_DECREF(source_list); return source_line; } @@ -1285,10 +1448,8 @@ warnings_warn_explicit_impl(PyObject *module, PyObject *message, } } - warnings_lock(tstate->interp); returned = warn_explicit(tstate, category, message, filename, lineno, mod, registry, source_line, sourceobj); - warnings_unlock(tstate->interp); Py_XDECREF(source_line); return returned; } @@ -1316,7 +1477,7 @@ warnings_filters_mutated_lock_held_impl(PyObject *module) return NULL; } - st->filters_version++; + FT_ATOMIC_ADD_SSIZE(st->filters_version, 1); Py_RETURN_NONE; } @@ -1435,10 +1596,8 @@ PyErr_WarnExplicitObject(PyObject *category, PyObject *message, return -1; } - warnings_lock(tstate->interp); res = warn_explicit(tstate, category, message, filename, lineno, module, registry, NULL, NULL); - warnings_unlock(tstate->interp); if (res == NULL) return -1; Py_DECREF(res); @@ -1503,10 +1662,8 @@ PyErr_WarnExplicitFormat(PyObject *category, PyObject *res; PyThreadState *tstate = get_current_tstate(); if (tstate != NULL) { - warnings_lock(tstate->interp); res = warn_explicit(tstate, category, message, filename, lineno, module, registry, NULL, NULL); - warnings_unlock(tstate->interp); Py_DECREF(message); if (res != NULL) { Py_DECREF(res); diff --git a/Python/asm_trampoline_aarch64.S b/Python/asm_trampoline_aarch64.S index b3aeb728de200c6..4052ea6e13edecc 100644 --- a/Python/asm_trampoline_aarch64.S +++ b/Python/asm_trampoline_aarch64.S @@ -35,7 +35,12 @@ #define GNU_PROPERTY_AARCH64_GCS 0 #endif +/* CPython copies this template into executable memory. */ +#if defined(__ELF__) + .section .rodata +#else .text +#endif #if defined(__aarch64__) && defined(__AARCH64EL__) && !defined(__ILP32__) #if defined(__APPLE__) .globl __Py_trampoline_func_start diff --git a/Python/asm_trampoline_riscv64.S b/Python/asm_trampoline_riscv64.S index 6125ba95373f954..7d32c904c995ece 100644 --- a/Python/asm_trampoline_riscv64.S +++ b/Python/asm_trampoline_riscv64.S @@ -1,4 +1,5 @@ - .text +/* CPython copies this template into executable memory. */ + .section .rodata .globl _Py_trampoline_func_start _Py_trampoline_func_start: addi sp,sp,-16 diff --git a/Python/asm_trampoline_x86_64.S b/Python/asm_trampoline_x86_64.S index 0e6b11589eafc82..0f83a4575828c23 100644 --- a/Python/asm_trampoline_x86_64.S +++ b/Python/asm_trampoline_x86_64.S @@ -1,4 +1,9 @@ +/* CPython copies this template into executable memory. */ +#if defined(__ELF__) + .section .rodata +#else .text +#endif #ifdef __x86_64__ #if defined(__APPLE__) .globl __Py_trampoline_func_start diff --git a/Python/assemble.c b/Python/assemble.c index 8bcb4c7bf3a9aa4..9f4ffb4050d2598 100644 --- a/Python/assemble.c +++ b/Python/assemble.c @@ -4,7 +4,10 @@ #include "pycore_instruction_sequence.h" #include "pycore_opcode_utils.h" // IS_BACKWARDS_JUMP_OPCODE #include "pycore_opcode_metadata.h" // is_pseudo_target, _PyOpcode_Caches +#include "pycore_pystate.h" // _PyInterpreterState_GET() #include "pycore_symtable.h" // _Py_SourceLocation +#include "pycore_tuple.h" // _PyTuple_ITEMS() +#include "pycore_unicodeobject.h" // _PyUnicode_InternImmortal() #include @@ -48,13 +51,16 @@ instr_size(instruction *instr) } struct assembler { - PyObject *a_bytecode; /* bytes containing bytecode */ + PyBytesWriter *a_bytecode_writer; /* writer containing bytecode */ + PyObject *a_bytecode; /* bytes containing bytecode */ int a_offset; /* offset into bytecode */ + PyBytesWriter *a_except_table_writer; /* writer containing exception table */ PyObject *a_except_table; /* bytes containing exception table */ int a_except_table_off; /* offset into exception table */ /* Location Info */ int a_lineno; /* lineno of last emitted instruction */ - PyObject* a_linetable; /* bytes containing location info */ + PyBytesWriter *a_linetable_writer; /* writer containing location info */ + PyObject *a_linetable; /* bytes object containing location info */ int a_location_off; /* offset of last written location info frame */ }; @@ -63,32 +69,35 @@ assemble_init(struct assembler *a, int firstlineno) { memset(a, 0, sizeof(struct assembler)); a->a_lineno = firstlineno; - a->a_linetable = NULL; - a->a_location_off = 0; - a->a_except_table = NULL; - a->a_bytecode = PyBytes_FromStringAndSize(NULL, DEFAULT_CODE_SIZE); - if (a->a_bytecode == NULL) { + a->a_bytecode_writer = PyBytesWriter_Create(DEFAULT_CODE_SIZE); + if (a->a_bytecode_writer == NULL) { goto error; } - a->a_linetable = PyBytes_FromStringAndSize(NULL, DEFAULT_CNOTAB_SIZE); - if (a->a_linetable == NULL) { + a->a_linetable_writer = PyBytesWriter_Create(DEFAULT_CNOTAB_SIZE); + if (a->a_linetable_writer == NULL) { goto error; } - a->a_except_table = PyBytes_FromStringAndSize(NULL, DEFAULT_LNOTAB_SIZE); - if (a->a_except_table == NULL) { + a->a_except_table_writer = PyBytesWriter_Create(DEFAULT_LNOTAB_SIZE); + if (a->a_except_table_writer == NULL) { goto error; } return SUCCESS; error: - Py_CLEAR(a->a_bytecode); - Py_CLEAR(a->a_linetable); - Py_CLEAR(a->a_except_table); + PyBytesWriter_Discard(a->a_bytecode_writer); + a->a_bytecode_writer = NULL; + PyBytesWriter_Discard(a->a_linetable_writer); + a->a_linetable_writer = NULL; + PyBytesWriter_Discard(a->a_except_table_writer); + a->a_except_table_writer = NULL; return ERROR; } static void assemble_free(struct assembler *a) { + PyBytesWriter_Discard(a->a_bytecode_writer); + PyBytesWriter_Discard(a->a_linetable_writer); + PyBytesWriter_Discard(a->a_except_table_writer); Py_XDECREF(a->a_bytecode); Py_XDECREF(a->a_linetable); Py_XDECREF(a->a_except_table); @@ -96,7 +105,7 @@ assemble_free(struct assembler *a) static inline void write_except_byte(struct assembler *a, int byte) { - unsigned char *p = (unsigned char *) PyBytes_AS_STRING(a->a_except_table); + unsigned char *p = PyBytesWriter_GetData(a->a_except_table_writer); p[a->a_except_table_off++] = byte; } @@ -134,9 +143,9 @@ assemble_emit_exception_table_entry(struct assembler *a, int start, int end, int handler_offset, _PyExceptHandlerInfo *handler) { - Py_ssize_t len = PyBytes_GET_SIZE(a->a_except_table); + Py_ssize_t len = PyBytesWriter_GetSize(a->a_except_table_writer); if (a->a_except_table_off + MAX_SIZE_OF_ENTRY >= len) { - RETURN_IF_ERROR(_PyBytes_Resize(&a->a_except_table, len * 2)); + RETURN_IF_ERROR(PyBytesWriter_Resize(a->a_except_table_writer, len * 2)); } int size = end-start; assert(end > start); @@ -195,7 +204,8 @@ assemble_exception_table(struct assembler *a, instr_sequence *instrs) static void write_location_byte(struct assembler* a, int val) { - PyBytes_AS_STRING(a->a_linetable)[a->a_location_off] = val&255; + uint8_t *linetable = PyBytesWriter_GetData(a->a_linetable_writer); + linetable[a->a_location_off] = val & 255; a->a_location_off++; } @@ -203,8 +213,8 @@ write_location_byte(struct assembler* a, int val) static uint8_t * location_pointer(struct assembler* a) { - return (uint8_t *)PyBytes_AS_STRING(a->a_linetable) + - a->a_location_off; + uint8_t *linetable = PyBytesWriter_GetData(a->a_linetable_writer); + return linetable + a->a_location_off; } static void @@ -285,10 +295,10 @@ write_location_info_no_column(struct assembler* a, int length, int line_delta) static int write_location_info_entry(struct assembler* a, location loc, int isize) { - Py_ssize_t len = PyBytes_GET_SIZE(a->a_linetable); + Py_ssize_t len = PyBytesWriter_GetSize(a->a_linetable_writer); if (a->a_location_off + THEORETICAL_MAX_ENTRY_SIZE >= len) { assert(len > THEORETICAL_MAX_ENTRY_SIZE); - RETURN_IF_ERROR(_PyBytes_Resize(&a->a_linetable, len*2)); + RETURN_IF_ERROR(PyBytesWriter_Resize(a->a_linetable_writer, len * 2)); } if (loc.lineno == NO_LOCATION.lineno) { write_location_info_none(a, isize); @@ -412,7 +422,7 @@ write_instr(_Py_CODEUNIT *codestr, instruction *instr, int ilen) static int assemble_emit_instr(struct assembler *a, instruction *instr) { - Py_ssize_t len = PyBytes_GET_SIZE(a->a_bytecode); + Py_ssize_t len = PyBytesWriter_GetSize(a->a_bytecode_writer); _Py_CODEUNIT *code; int size = instr_size(instr); @@ -421,9 +431,9 @@ assemble_emit_instr(struct assembler *a, instruction *instr) PyErr_NoMemory(); return ERROR; } - RETURN_IF_ERROR(_PyBytes_Resize(&a->a_bytecode, len * 2)); + RETURN_IF_ERROR(PyBytesWriter_Resize(a->a_bytecode_writer, len * 2)); } - code = (_Py_CODEUNIT *)PyBytes_AS_STRING(a->a_bytecode) + a->a_offset; + code = (_Py_CODEUNIT *)PyBytesWriter_GetData(a->a_bytecode_writer) + a->a_offset; a->a_offset += size; write_instr(code, instr, size); return SUCCESS; @@ -444,13 +454,28 @@ assemble_emit(struct assembler *a, instr_sequence *instrs, RETURN_IF_ERROR(assemble_exception_table(a, instrs)); - RETURN_IF_ERROR(_PyBytes_Resize(&a->a_except_table, a->a_except_table_off)); + a->a_except_table = PyBytesWriter_FinishWithSize(a->a_except_table_writer, + a->a_except_table_off); + a->a_except_table_writer = NULL; + if (a->a_except_table == NULL) { + return ERROR; + } RETURN_IF_ERROR(_PyCompile_ConstCacheMergeOne(const_cache, &a->a_except_table)); - RETURN_IF_ERROR(_PyBytes_Resize(&a->a_linetable, a->a_location_off)); + a->a_linetable = PyBytesWriter_FinishWithSize(a->a_linetable_writer, + a->a_location_off); + a->a_linetable_writer = NULL; + if (a->a_linetable == NULL) { + return ERROR; + } RETURN_IF_ERROR(_PyCompile_ConstCacheMergeOne(const_cache, &a->a_linetable)); - RETURN_IF_ERROR(_PyBytes_Resize(&a->a_bytecode, a->a_offset * sizeof(_Py_CODEUNIT))); + a->a_bytecode = PyBytesWriter_FinishWithSize(a->a_bytecode_writer, + a->a_offset * sizeof(_Py_CODEUNIT)); + a->a_bytecode_writer = NULL; + if (a->a_bytecode == NULL) { + return ERROR; + } RETURN_IF_ERROR(_PyCompile_ConstCacheMergeOne(const_cache, &a->a_bytecode)); return SUCCESS; } @@ -481,6 +506,27 @@ dict_keys_inorder(PyObject *dict, Py_ssize_t offset) extern void _Py_set_localsplus_info(int, PyObject *, unsigned char, PyObject *, PyObject *); +/* Intern the names in *tuple*, as _PyCode_New() does, before the tuple is + * merged with the constant cache. + * + * The merge can replace the tuple by an equal tuple constant of another + * code object, whose items _PyCode_New() then interns in place. A string + * of that constant would become the interned string or be replaced by it, + * depending on whether an equal string was already interned in the process, + * and so would the output of marshal for the same source. Names which the + * parser did not create, such as mangled private names or the identifiers + * of an AST passed to compile(), may not be interned yet. + */ +static void +intern_names(PyObject *tuple) +{ + PyInterpreterState *interp = _PyInterpreterState_GET(); + for (Py_ssize_t i = 0; i < PyTuple_GET_SIZE(tuple); i++) { + assert(PyUnicode_CheckExact(PyTuple_GET_ITEM(tuple, i))); + _PyUnicode_InternImmortal(interp, &_PyTuple_ITEMS(tuple)[i]); + } +} + static int compute_localsplus_info(_PyCompile_CodeUnitMetadata *umd, int nlocalsplus, int flags, PyObject *names, PyObject *kinds) @@ -515,13 +561,15 @@ compute_localsplus_info(_PyCompile_CodeUnitMetadata *umd, int nlocalsplus, _PyLocals_Kind kind = CO_FAST_LOCAL | argvarkinds[i].kind; - int has_key = PyDict_Contains(umd->u_fasthidden, k); - RETURN_IF_ERROR(has_key); - if (has_key) { - kind |= CO_FAST_HIDDEN; + if (umd->u_fasthidden != NULL) { + int hidden = PySet_Contains(umd->u_fasthidden, k); + RETURN_IF_ERROR(hidden); + if (hidden) { + kind |= CO_FAST_HIDDEN; + } } - has_key = PyDict_Contains(umd->u_cellvars, k); + int has_key = PyDict_Contains(umd->u_cellvars, k); RETURN_IF_ERROR(has_key); if (has_key) { kind |= CO_FAST_CELL; @@ -586,6 +634,7 @@ makecode(_PyCompile_CodeUnitMetadata *umd, struct assembler *a, PyObject *const_ if (!names) { goto error; } + intern_names(names); if (_PyCompile_ConstCacheMergeOne(const_cache, &names) < 0) { goto error; } @@ -650,6 +699,7 @@ makecode(_PyCompile_CodeUnitMetadata *umd, struct assembler *a, PyObject *const_ goto error; } + intern_names(localsplusnames); if (_PyCompile_ConstCacheMergeOne(const_cache, &localsplusnames) < 0) { goto error; } diff --git a/Python/ast.c b/Python/ast.c index 4cfa2ff559a5f7d..1befd1778114927 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -426,11 +426,11 @@ ensure_literal_number(expr_ty exp, bool allow_real, bool allow_imaginary) } static int -ensure_literal_negative(expr_ty exp, bool allow_real, bool allow_imaginary) +ensure_literal_signed(expr_ty exp, bool allow_real, bool allow_imaginary) { assert(exp->kind == UnaryOp_kind); - // Must be negation ... - if (exp->v.UnaryOp.op != USub) { + // Must be negation or positive ... + if (exp->v.UnaryOp.op != USub && exp->v.UnaryOp.op != UAdd) { return 0; } // ... of a constant ... @@ -461,7 +461,7 @@ ensure_literal_complex(expr_ty exp) } break; case UnaryOp_kind: - if (!ensure_literal_negative(left, /*real=*/true, /*imaginary=*/false)) { + if (!ensure_literal_signed(left, /*real=*/true, /*imaginary=*/false)) { return 0; } break; @@ -512,9 +512,9 @@ validate_pattern_match_value(expr_ty exp) // Constants and attribute lookups are always permitted return 1; case UnaryOp_kind: - // Negated numbers are permitted (whether real or imaginary) + // Signed numbers are permitted (whether real or imaginary) // Compiler will complain if AST folding doesn't create a constant - if (ensure_literal_negative(exp, /*real=*/true, /*imaginary=*/true)) { + if (ensure_literal_signed(exp, /*real=*/true, /*imaginary=*/true)) { return 1; } break; @@ -710,6 +710,23 @@ _validate_nonempty_seq(asdl_seq *seq, const char *what, const char *owner) } #define validate_nonempty_seq(seq, what, owner) _validate_nonempty_seq((asdl_seq*)seq, what, owner) +static int +validate_import_names(asdl_alias_seq *seq, const char *what, const char *owner) +{ + if (!validate_nonempty_seq(seq, what, owner)) { + return 0; + } + Py_ssize_t n = asdl_seq_LEN(seq); + for (Py_ssize_t i = 0; i < n; i++) { + alias_ty alias = asdl_seq_GET(seq, i); + if (!validate_name(alias->name) || + (alias->asname && !validate_name(alias->asname))) { + return 0; + } + } + return 1; +} + static int validate_assignlist(asdl_expr_seq *targets, expr_context_ty ctx) { @@ -735,6 +752,7 @@ validate_stmt(stmt_ty stmt) switch (stmt->kind) { case FunctionDef_kind: ret = validate_body(stmt->v.FunctionDef.body, "FunctionDef") && + validate_name(stmt->v.FunctionDef.name) && validate_type_params(stmt->v.FunctionDef.type_params) && validate_arguments(stmt->v.FunctionDef.args) && validate_exprs(stmt->v.FunctionDef.decorator_list, Load, 0) && @@ -743,6 +761,7 @@ validate_stmt(stmt_ty stmt) break; case ClassDef_kind: ret = validate_body(stmt->v.ClassDef.body, "ClassDef") && + validate_name(stmt->v.ClassDef.name) && validate_type_params(stmt->v.ClassDef.type_params) && validate_exprs(stmt->v.ClassDef.bases, Load, 0) && validate_keywords(stmt->v.ClassDef.keywords) && @@ -873,6 +892,8 @@ validate_stmt(stmt_ty stmt) VALIDATE_POSITIONS(handler); if ((handler->v.ExceptHandler.type && !validate_expr(handler->v.ExceptHandler.type, Load)) || + (handler->v.ExceptHandler.name && + !validate_name(handler->v.ExceptHandler.name)) || !validate_body(handler->v.ExceptHandler.body, "ExceptHandler")) return 0; } @@ -911,14 +932,14 @@ validate_stmt(stmt_ty stmt) (!stmt->v.Assert.msg || validate_expr(stmt->v.Assert.msg, Load)); break; case Import_kind: - ret = validate_nonempty_seq(stmt->v.Import.names, "names", "Import"); + ret = validate_import_names(stmt->v.Import.names, "names", "Import"); break; case ImportFrom_kind: if (stmt->v.ImportFrom.level < 0) { PyErr_SetString(PyExc_ValueError, "Negative ImportFrom level"); return 0; } - ret = validate_nonempty_seq(stmt->v.ImportFrom.names, "names", "ImportFrom"); + ret = validate_import_names(stmt->v.ImportFrom.names, "names", "ImportFrom"); break; case Global_kind: ret = validate_nonempty_seq(stmt->v.Global.names, "names", "Global"); @@ -931,6 +952,7 @@ validate_stmt(stmt_ty stmt) break; case AsyncFunctionDef_kind: ret = validate_body(stmt->v.AsyncFunctionDef.body, "AsyncFunctionDef") && + validate_name(stmt->v.AsyncFunctionDef.name) && validate_type_params(stmt->v.AsyncFunctionDef.type_params) && validate_arguments(stmt->v.AsyncFunctionDef.args) && validate_exprs(stmt->v.AsyncFunctionDef.decorator_list, Load, 0) && diff --git a/Python/ast_preprocess.c b/Python/ast_preprocess.c index 54dec3dfe042686..951b3f71522b254 100644 --- a/Python/ast_preprocess.c +++ b/Python/ast_preprocess.c @@ -867,11 +867,11 @@ fold_const_match_patterns(expr_ty node, PyArena *ctx_, _PyASTPreprocessState *st { case UnaryOp_kind: { - if (node->v.UnaryOp.op == USub && + if ((node->v.UnaryOp.op == USub || node->v.UnaryOp.op == UAdd) && node->v.UnaryOp.operand->kind == Constant_kind) { PyObject *operand = node->v.UnaryOp.operand->v.Constant.value; - PyObject *folded = PyNumber_Negative(operand); + PyObject *folded = node->v.UnaryOp.op == USub ? PyNumber_Negative(operand) : PyNumber_Positive(operand); return make_const(node, folded, ctx_); } break; diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index cbe59c8883d5a57..72f2e356c34f7c8 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -10,6 +10,7 @@ #include "pycore_floatobject.h" // _PyFloat_ExactDealloc() #include "pycore_interp.h" // _PyInterpreterState_GetConfig() #include "pycore_import.h" // _PyImport_LazyImportModuleLevelObject () +#include "pycore_iterobject.h" // _PyCallIter_NewEx() #include "pycore_long.h" // _PyLong_CompactValue #include "pycore_modsupport.h" // _PyArg_NoKwnames() #include "pycore_object.h" // _Py_AddToAllObjects() @@ -311,7 +312,7 @@ builtin___lazy_import___impl(PyObject *module, PyObject *name, { PyObject *builtins; PyThreadState *tstate = PyThreadState_GET(); - if (globals == NULL) { + if (globals == NULL || globals == Py_None) { globals = PyEval_GetGlobals(); if (globals == NULL) { PyErr_SetString(PyExc_TypeError, @@ -320,7 +321,7 @@ builtin___lazy_import___impl(PyObject *module, PyObject *name, return NULL; } } - if (locals == NULL) { + if (locals == NULL || locals == Py_None) { locals = globals; } @@ -565,65 +566,37 @@ typedef struct { #define _filterobject_CAST(op) ((filterobject *)(op)) -static PyObject * -filter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyObject *func, *seq; - PyObject *it; - filterobject *lz; - - if ((type == &PyFilter_Type || type->tp_init == PyFilter_Type.tp_init) && - !_PyArg_NoKeywords("filter", kwds)) - return NULL; - - if (!PyArg_UnpackTuple(args, "filter", 2, 2, &func, &seq)) - return NULL; - - /* Get iterator. */ - it = PyObject_GetIter(seq); - if (it == NULL) - return NULL; +/*[clinic input] +class filter "filterobject *" "&PyFilter_Type" +@vectorcall +@classmethod +filter.__new__ as filter_new - /* create filterobject structure */ - lz = (filterobject *)type->tp_alloc(type, 0); - if (lz == NULL) { - Py_DECREF(it); - return NULL; - } + function as func: object + iterable as seq: object + / - lz->func = Py_NewRef(func); - lz->it = it; +Return an iterator over items of iterable where function(item) is true. - return (PyObject *)lz; -} +If function is None, return the items that are true. +[clinic start generated code]*/ static PyObject * -filter_vectorcall(PyObject *type, PyObject * const*args, - size_t nargsf, PyObject *kwnames) +filter_new_impl(PyTypeObject *type, PyObject *func, PyObject *seq) +/*[clinic end generated code: output=2134a9f0032a6037 input=57836123a59c4d91]*/ { - PyTypeObject *tp = _PyType_CAST(type); - if (tp == &PyFilter_Type && !_PyArg_NoKwnames("filter", kwnames)) { - return NULL; - } - - Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); - if (!_PyArg_CheckPositional("filter", nargs, 2, 2)) { - return NULL; - } - - PyObject *it = PyObject_GetIter(args[1]); + PyObject *it = PyObject_GetIter(seq); if (it == NULL) { return NULL; } - filterobject *lz = (filterobject *)tp->tp_alloc(tp, 0); - + filterobject *lz = (filterobject *)type->tp_alloc(type, 0); if (lz == NULL) { Py_DECREF(it); return NULL; } - lz->func = Py_NewRef(args[0]); + lz->func = Py_NewRef(func); lz->it = it; return (PyObject *)lz; @@ -698,14 +671,6 @@ static PyMethodDef filter_methods[] = { {NULL, NULL} /* sentinel */ }; -PyDoc_STRVAR(filter_doc, -"filter(function, iterable, /)\n\ ---\n\ -\n\ -Return an iterator yielding those items of iterable for which\n\ -function(item) is true. If function is None, return the items that\n\ -are true."); - PyTypeObject PyFilter_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "filter", /* tp_name */ @@ -729,7 +694,7 @@ PyTypeObject PyFilter_Type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ - filter_doc, /* tp_doc */ + filter_new__doc__, /* tp_doc */ filter_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -748,7 +713,7 @@ PyTypeObject PyFilter_Type = { PyType_GenericAlloc, /* tp_alloc */ filter_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ - .tp_vectorcall = filter_vectorcall + .tp_vectorcall = filter_vectorcall, }; @@ -941,8 +906,17 @@ builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename, _PyArena_Free(arena); goto error; } +#ifdef Py_GIL_DISABLED + // Disable immortalization of code constants, as for a source + // string below. + _PyThreadStateImpl *tstate = (_PyThreadStateImpl *)_PyThreadState_GET(); + tstate->suppress_co_const_immortalization++; +#endif result = (PyObject*)_PyAST_Compile(mod, filename, &cf, optimize, arena, modname); +#ifdef Py_GIL_DISABLED + tstate->suppress_co_const_immortalization--; +#endif } _PyArena_Free(arena); goto finally; @@ -955,7 +929,10 @@ builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename, #ifdef Py_GIL_DISABLED // Disable immortalization of code constants for explicit // compile() calls to get consistent frozen outputs between the default - // and free-threaded builds. + // and free-threaded builds. It also keeps the output independent of + // what the process compiled before: a constant is otherwise replaced + // by an equal one of an earlier code object, and is then no longer the + // same object as, for example, the equal co_names of its code object. _PyThreadStateImpl *tstate = (_PyThreadStateImpl *)_PyThreadState_GET(); tstate->suppress_co_const_immortalization++; #endif @@ -978,30 +955,33 @@ builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename, } /* AC: cannot convert yet, as needs PEP 457 group support in inspect */ +/*[clinic input] +dir as builtin_dir + + object as arg: object = NULL + / + +Return an alphabetized list of the attributes of the object. + +If called without an argument, return the names in the current scope. +Else, return an alphabetized list of names comprising (some of) the +attributes of the given object, and of attributes reachable from it. +If the object supplies a method named __dir__, it will be used; +otherwise the default dir() logic is used and returns: + for a module object: the module's attributes. + for a class object: its attributes, and recursively the attributes + of its bases. + for any other object: its attributes, its class's attributes, and + recursively the attributes of its class's base classes. +[clinic start generated code]*/ + static PyObject * -builtin_dir(PyObject *self, PyObject *args) +builtin_dir_impl(PyObject *module, PyObject *arg) +/*[clinic end generated code: output=24f2c7a52c1e3b08 input=7fe1b2a5ca9ae355]*/ { - PyObject *arg = NULL; - - if (!PyArg_UnpackTuple(args, "dir", 0, 1, &arg)) - return NULL; return PyObject_Dir(arg); } -PyDoc_STRVAR(dir_doc, -"dir([object]) -> list of strings\n" -"\n" -"If called without an argument, return the names in the current scope.\n" -"Else, return an alphabetized list of names comprising (some of) the\n" -"attributes of the given object, and of attributes reachable from it.\n" -"If the object supplies a method named __dir__, it will be used;\n" -"otherwise the default dir() logic is used and returns:\n" -" for a module object: the module's attributes.\n" -" for a class object: its attributes, and recursively the attributes\n" -" of its bases.\n" -" for any other object: its attributes, its class's attributes, and\n" -" recursively the attributes of its class's base classes."); - /*[clinic input] divmod as builtin_divmod @@ -1893,95 +1873,37 @@ builtin_hex(PyObject *module, PyObject *integer) } -/* AC: cannot convert yet, as needs PEP 457 group support in inspect */ -static PyObject * -builtin_iter(PyObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *v; - - if (!_PyArg_CheckPositional("iter", nargs, 1, 2)) - return NULL; - v = args[0]; - if (nargs == 1) - return PyObject_GetIter(v); - if (!PyCallable_Check(v)) { - PyErr_SetString(PyExc_TypeError, - "iter(v, w): v must be callable"); - return NULL; - } - PyObject *sentinel = args[1]; - return PyCallIter_New(v, sentinel); -} - -PyDoc_STRVAR(iter_doc, -"iter(iterable) -> iterator\n\ -iter(callable, sentinel) -> iterator\n\ -\n\ -Get an iterator from an object. In the first form, the argument must\n\ -supply its own iterator, or be a sequence.\n\ -In the second form, the callable is called until it returns the\n\ -sentinel."); - - -/*[clinic input] -aiter as builtin_aiter - - async_iterable: object - / - -Return an AsyncIterator for an AsyncIterable object. -[clinic start generated code]*/ - -static PyObject * -builtin_aiter(PyObject *module, PyObject *async_iterable) -/*[clinic end generated code: output=1bae108d86f7960e input=473993d0cacc7d23]*/ -{ - return PyObject_GetAIter(async_iterable); -} - -PyObject *PyAnextAwaitable_New(PyObject *, PyObject *); - /*[clinic input] -anext as builtin_anext +@text_signature "($module, object, /, [stop_value], *, stop_exception=StopIteration)" +iter as builtin_iter - async_iterator as aiterator: object - default: object = NULL + object: object / + stop_value: object = NULL + * + stop_exception: object = NULL -Return the next item from the async iterator. +Get an iterator from an object. -If default is given and the async iterator is exhausted, -it is returned instead of raising StopAsyncIteration. +In the first form, the argument must supply its own iterator, or be a +sequence. In the second form, the callable is called until it returns +the stop value or raises the specified exception. [clinic start generated code]*/ static PyObject * -builtin_anext_impl(PyObject *module, PyObject *aiterator, - PyObject *default_value) -/*[clinic end generated code: output=f02c060c163a81fa input=f3dc5a93f073e5ac]*/ +builtin_iter_impl(PyObject *module, PyObject *object, PyObject *stop_value, + PyObject *stop_exception) +/*[clinic end generated code: output=eb9c9ae8f77bf400 input=d3a2f767f29d9ae6]*/ { - PyTypeObject *t; - PyObject *awaitable; - - t = Py_TYPE(aiterator); - if (t->tp_as_async == NULL || t->tp_as_async->am_anext == NULL) { - PyErr_Format(PyExc_TypeError, - "'%.200s' object is not an async iterator", - t->tp_name); - return NULL; + if (stop_value == NULL && stop_exception == NULL) { + return PyObject_GetIter(object); } - - awaitable = (*t->tp_as_async->am_anext)(aiterator); - if (awaitable == NULL) { + if (!PyCallable_Check(object)) { + PyErr_SetString(PyExc_TypeError, + "iter(): the first argument must be callable"); return NULL; } - if (default_value == NULL) { - return awaitable; - } - - PyObject* new_awaitable = PyAnextAwaitable_New( - awaitable, default_value); - Py_DECREF(awaitable); - return new_awaitable; + return _PyCallIter_NewEx(object, stop_value, stop_exception); } @@ -2318,7 +2240,7 @@ builtin_print_impl(PyObject *module, PyObject * const *objects, PyObject *file, int flush) /*[clinic end generated code: output=38d8def56c837bcc input=ff35cb3d59ee8115]*/ { - int i, err; + int i; if (file == Py_None) { file = PySys_GetAttr(&_Py_ID(stdout)); @@ -2337,7 +2259,7 @@ builtin_print_impl(PyObject *module, PyObject * const *objects, } if (sep == Py_None) { - sep = NULL; + sep = _Py_LATIN1_CHR(' '); } else if (sep && !PyUnicode_Check(sep)) { PyErr_Format(PyExc_TypeError, @@ -2347,7 +2269,7 @@ builtin_print_impl(PyObject *module, PyObject * const *objects, return NULL; } if (end == Py_None) { - end = NULL; + end = _Py_LATIN1_CHR('\n'); } else if (end && !PyUnicode_Check(end)) { PyErr_Format(PyExc_TypeError, @@ -2358,32 +2280,16 @@ builtin_print_impl(PyObject *module, PyObject * const *objects, } for (i = 0; i < objects_length; i++) { - if (i > 0) { - if (sep == NULL) { - err = PyFile_WriteString(" ", file); - } - else { - err = PyFile_WriteObject(sep, file, Py_PRINT_RAW); - } - if (err) { - Py_DECREF(file); - return NULL; - } + if (i > 0 && PyFile_WriteObject(sep, file, Py_PRINT_RAW) < 0) { + Py_DECREF(file); + return NULL; } - err = PyFile_WriteObject(objects[i], file, Py_PRINT_RAW); - if (err) { + if (PyFile_WriteObject(objects[i], file, Py_PRINT_RAW) < 0) { Py_DECREF(file); return NULL; } } - - if (end == NULL) { - err = PyFile_WriteString("\n", file); - } - else { - err = PyFile_WriteObject(end, file, Py_PRINT_RAW); - } - if (err) { + if (PyFile_WriteObject(end, file, Py_PRINT_RAW) < 0) { Py_DECREF(file); return NULL; } @@ -2774,14 +2680,24 @@ builtin_sorted(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject /* AC: cannot convert yet, as needs PEP 457 group support in inspect */ +/*[clinic input] +vars as builtin_vars + + object as v: object = NULL + / + +Show vars. + +Without arguments, equivalent to locals(). +With an argument, equivalent to object.__dict__. +[clinic start generated code]*/ + static PyObject * -builtin_vars(PyObject *self, PyObject *args) +builtin_vars_impl(PyObject *module, PyObject *v) +/*[clinic end generated code: output=a64017e4a4dc53fc input=577550318240f012]*/ { - PyObject *v = NULL; PyObject *d; - if (!PyArg_UnpackTuple(args, "vars", 0, 1, &v)) - return NULL; if (v == NULL) { if (_PyEval_GetFrame() != NULL) { d = _PyEval_GetFrameLocals(); @@ -2809,12 +2725,6 @@ builtin_vars(PyObject *self, PyObject *args) return d; } -PyDoc_STRVAR(vars_doc, -"vars([object]) -> dictionary\n\ -\n\ -Without arguments, equivalent to locals().\n\ -With an argument, equivalent to object.__dict__."); - /* Improved Kahan–Babuška algorithm by Arnold Neumaier Neumaier, A. (1974), Rundungsfehleranalyse einiger Verfahren @@ -2987,15 +2897,15 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start) _Py_DECREF_SPECIALIZED(item, _PyFloat_ExactDealloc); continue; } - if (PyLong_Check(item)) { + if (PyLong_CheckExact(item)) { double value = PyLong_AsDouble(item); if (value != -1.0 || !PyErr_Occurred()) { re_sum = cs_add(re_sum, value); - Py_DECREF(item); + _Py_DECREF_SPECIALIZED(item, _PyLong_ExactDealloc); continue; } else { - Py_DECREF(item); + _Py_DECREF_SPECIALIZED(item, _PyLong_ExactDealloc); Py_DECREF(iter); return NULL; } @@ -3039,20 +2949,20 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start) Py_DECREF(item); continue; } - if (PyLong_Check(item)) { + if (PyLong_CheckExact(item)) { double value = PyLong_AsDouble(item); if (value != -1.0 || !PyErr_Occurred()) { re_sum = cs_add(re_sum, value); - Py_DECREF(item); + _Py_DECREF_SPECIALIZED(item, _PyLong_ExactDealloc); continue; } else { - Py_DECREF(item); + _Py_DECREF_SPECIALIZED(item, _PyLong_ExactDealloc); Py_DECREF(iter); return NULL; } } - if (PyFloat_Check(item)) { + if (PyFloat_CheckExact(item)) { double value = PyFloat_AS_DOUBLE(item); re_sum = cs_add(re_sum, value); _Py_DECREF_SPECIALIZED(item, _PyFloat_ExactDealloc); @@ -3177,41 +3087,45 @@ typedef struct { #define _zipobject_CAST(op) ((zipobject *)(op)) +/*[clinic input] +class zip "zipobject *" "&PyZip_Type" +@vectorcall +@classmethod +zip.__new__ as zip_new + + *iterables: array + strict: bool = False + +Iterate over several iterables in parallel, yielding tuples. + +The zip object yields n-length tuples, where n is the number of +iterables passed as positional arguments to zip(). The i-th element +in every tuple comes from the i-th iterable argument to zip(). This +continues until the shortest argument is exhausted. + +If strict is true and one of the arguments is exhausted before the +others, raise a ValueError. + + >>> list(zip('abcdefg', range(3), range(4))) + [('a', 0, 0), ('b', 1, 1), ('c', 2, 2)] +[clinic start generated code]*/ + static PyObject * -zip_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +zip_new_impl(PyTypeObject *type, PyObject * const *iterables, + Py_ssize_t iterables_length, int strict) +/*[clinic end generated code: output=5e1a30829ce1f6ab input=4bd8e6a24e4bfb2e]*/ { zipobject *lz; Py_ssize_t i; PyObject *ittuple; /* tuple of iterators */ PyObject *result; - Py_ssize_t tuplesize; - int strict = 0; - - if (kwds) { - PyObject *empty = PyTuple_New(0); - if (empty == NULL) { - return NULL; - } - static char *kwlist[] = {"strict", NULL}; - int parsed = PyArg_ParseTupleAndKeywords( - empty, kwds, "|$p:zip", kwlist, &strict); - Py_DECREF(empty); - if (!parsed) { - return NULL; - } - } - - /* args must be a tuple */ - assert(PyTuple_Check(args)); - tuplesize = PyTuple_GET_SIZE(args); /* obtain iterators */ - ittuple = PyTuple_New(tuplesize); + ittuple = PyTuple_New(iterables_length); if (ittuple == NULL) return NULL; - for (i=0; i < tuplesize; ++i) { - PyObject *item = PyTuple_GET_ITEM(args, i); - PyObject *it = PyObject_GetIter(item); + for (i=0; i < iterables_length; ++i) { + PyObject *it = PyObject_GetIter(iterables[i]); if (it == NULL) { Py_DECREF(ittuple); return NULL; @@ -3220,12 +3134,12 @@ zip_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } /* create a result holder */ - result = PyTuple_New(tuplesize); + result = PyTuple_New(iterables_length); if (result == NULL) { Py_DECREF(ittuple); return NULL; } - for (i=0 ; i < tuplesize ; i++) { + for (i=0 ; i < iterables_length ; i++) { PyTuple_SET_ITEM(result, i, Py_NewRef(Py_None)); } @@ -3237,7 +3151,7 @@ zip_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; } lz->ittuple = ittuple; - lz->tuplesize = tuplesize; + lz->tuplesize = iterables_length; lz->result = result; lz->strict = strict; @@ -3383,21 +3297,6 @@ static PyMethodDef zip_methods[] = { {NULL} /* sentinel */ }; -PyDoc_STRVAR(zip_doc, -"zip(*iterables, strict=False)\n\ ---\n\ -\n\ -The zip object yields n-length tuples, where n is the number of\n\ -iterables passed as positional arguments to zip(). The i-th element\n\ -in every tuple comes from the i-th iterable argument to zip(). This\n\ -continues until the shortest argument is exhausted.\n\ -\n\ -If strict is true and one of the arguments is exhausted before the\n\ -others, raise a ValueError.\n\ -\n\ - >>> list(zip('abcdefg', range(3), range(4)))\n\ - [('a', 0, 0), ('b', 1, 1), ('c', 2, 2)]"); - PyTypeObject PyZip_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "zip", /* tp_name */ @@ -3421,7 +3320,7 @@ PyTypeObject PyZip_Type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ - zip_doc, /* tp_doc */ + zip_new__doc__, /* tp_doc */ zip_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -3440,6 +3339,7 @@ PyTypeObject PyZip_Type = { PyType_GenericAlloc, /* tp_alloc */ zip_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ + .tp_vectorcall = zip_vectorcall, }; @@ -3458,7 +3358,7 @@ static PyMethodDef builtin_methods[] = { BUILTIN_CHR_METHODDEF BUILTIN_COMPILE_METHODDEF BUILTIN_DELATTR_METHODDEF - {"dir", builtin_dir, METH_VARARGS, dir_doc}, + BUILTIN_DIR_METHODDEF BUILTIN_DIVMOD_METHODDEF BUILTIN_EVAL_METHODDEF BUILTIN_EXEC_METHODDEF @@ -3472,14 +3372,12 @@ static PyMethodDef builtin_methods[] = { BUILTIN_INPUT_METHODDEF BUILTIN_ISINSTANCE_METHODDEF BUILTIN_ISSUBCLASS_METHODDEF - {"iter", _PyCFunction_CAST(builtin_iter), METH_FASTCALL, iter_doc}, - BUILTIN_AITER_METHODDEF + BUILTIN_ITER_METHODDEF BUILTIN_LEN_METHODDEF BUILTIN_LOCALS_METHODDEF {"max", _PyCFunction_CAST(builtin_max), METH_FASTCALL | METH_KEYWORDS, max_doc}, {"min", _PyCFunction_CAST(builtin_min), METH_FASTCALL | METH_KEYWORDS, min_doc}, {"next", _PyCFunction_CAST(builtin_next), METH_FASTCALL, next_doc}, - BUILTIN_ANEXT_METHODDEF BUILTIN_OCT_METHODDEF BUILTIN_ORD_METHODDEF BUILTIN_POW_METHODDEF @@ -3489,7 +3387,7 @@ static PyMethodDef builtin_methods[] = { BUILTIN_SETATTR_METHODDEF BUILTIN_SORTED_METHODDEF BUILTIN_SUM_METHODDEF - {"vars", builtin_vars, METH_VARARGS, vars_doc}, + BUILTIN_VARS_METHODDEF {NULL, NULL}, }; @@ -3518,6 +3416,57 @@ static struct PyModuleDef builtinsmodule = { }; +/* Builtins implemented in Python. + + Lib/_pybuiltins.py is frozen into the interpreter as a bootstrap module + (see Tools/build/freeze_modules.py), so it can be imported here before + the import system exists. The names in its __all__ are copied into the + builtins dict. */ + +int +_PyBuiltin_InitPythonFunctions(PyObject *dict) +{ + if (PyImport_ImportFrozenModule("_pybuiltins") <= 0) { + if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, + "frozen module _pybuiltins not found"); + } + return -1; + } + PyObject *mod = PyImport_AddModuleRef("_pybuiltins"); + if (mod == NULL) { + return -1; + } + + int rc = -1; + PyObject *all = PyObject_GetAttr(mod, &_Py_ID(__all__)); + if (all == NULL) { + goto done; + } + Py_ssize_t n = PyList_Size(all); + if (n < 0) { + goto done; + } + for (Py_ssize_t i = 0; i < n; i++) { + PyObject *name = PyList_GET_ITEM(all, i); + PyObject *func = PyObject_GetAttr(mod, name); + if (func == NULL) { + goto done; + } + int r = PyDict_SetItem(dict, name, func); + Py_DECREF(func); + if (r < 0) { + goto done; + } + } + rc = 0; + +done: + Py_XDECREF(all); + Py_DECREF(mod); + return rc; +} + PyObject * _PyBuiltin_Init(PyInterpreterState *interp) { diff --git a/Python/bootstrap_hash.c b/Python/bootstrap_hash.c index f0fb87c4a5d15e2..a22688827612657 100644 --- a/Python/bootstrap_hash.c +++ b/Python/bootstrap_hash.c @@ -23,7 +23,10 @@ # include // getrandom() # endif # if !defined(HAVE_GETRANDOM) && defined(HAVE_GETRANDOM_SYSCALL) -# include // SYS_getrandom +# include // __NR_getrandom, SYS_getrandom +# if !defined(SYS_getrandom) && defined(__NR_getrandom) +# define SYS_getrandom __NR_getrandom +# endif # endif #endif @@ -126,9 +129,6 @@ py_getrandom(void *buffer, Py_ssize_t size, int blocking, int raise) n = getrandom(dest, n, flags); } #else - /* On Linux, use the syscall() function because the GNU libc doesn't - expose the Linux getrandom() syscall yet. See: - https://sourceware.org/bugzilla/show_bug.cgi?id=17252 */ if (raise) { Py_BEGIN_ALLOW_THREADS n = syscall(SYS_getrandom, dest, n, flags); diff --git a/Python/brc.c b/Python/brc.c index d27687052aec190..aeef74b922b86e6 100644 --- a/Python/brc.c +++ b/Python/brc.c @@ -48,6 +48,28 @@ find_thread_state(struct _brc_bucket *bucket, uintptr_t thread_id) return NULL; } +// Merge the refcounts of all objects in `stack`, keeping the queue's reference. +static void +merge_queued_refcounts(_PyObjectStack *stack) +{ + for (_PyObjectStackChunk *buf = stack->head; buf != NULL; buf = buf->prev) { + for (Py_ssize_t i = 0; i < buf->n; i++) { + _Py_ExplicitMergeRefcount(buf->objs[i], 0); + } + } +} + +// Release the queue's reference to each merged object. This may run +// destructors, so the bucket mutex must not be held. +static void +decref_merged_objects(_PyObjectStack *stack) +{ + PyObject *ob; + while ((ob = _PyObjectStack_Pop(stack)) != NULL) { + Py_DECREF(ob); + } +} + // Enqueue an object to be merged by the owning thread. This steals a // reference to the object. void @@ -93,6 +115,22 @@ _Py_brc_queue_object(PyObject *ob) return; } + if (_PyThreadState_TrySuspendDetached(&tstate->base)) { + // The owning thread is detached (e.g. blocked on a lock or in a + // system call) and may not run Python code again for a long time, + // so merge its queue on its behalf instead of waiting for it. While + // it is held in the "suspended" state it cannot attach and therefore + // cannot touch ob_ref_local or ob_tid. + _PyObjectStack merged = {0}; + _PyObjectStack_Merge(&merged, &tstate->brc.objects_to_merge); + merge_queued_refcounts(&merged); + _PyThreadState_ResumeDetached(&tstate->base); + PyMutex_Unlock(&bucket->mutex); + + decref_merged_objects(&merged); + return; + } + // Notify owning thread _Py_set_eval_breaker_bit(&tstate->base, _PY_EVAL_EXPLICIT_MERGE_BIT); diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 4d7b338e2dbd4c3..c6f1f61f3e08fe1 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -10,6 +10,7 @@ #include "pycore_abstract.h" // _PyIndex_Check() #include "pycore_audit.h" // _PySys_Audit() #include "pycore_backoff.h" +#include "pycore_call.h" // _Py_METH_CALL_FLAGS #include "pycore_cell.h" // PyCell_GetRef() #include "pycore_ceval.h" // _PyEval_LazyImportName(), _PyEval_LazyImportFrom() #include "pycore_code.h" @@ -526,7 +527,7 @@ dummy_func( } macro(TO_BOOL_INT) = - _GUARD_TOS_INT + unused/1 + unused/2 + _TO_BOOL_INT + _POP_TOP_INT; + _GUARD_TOS_EXACT_INT + unused/1 + unused/2 + _TO_BOOL_INT + _POP_TOP_INT; op(_GUARD_NOS_LIST, (nos, unused -- nos, unused)) { PyObject *o = PyStackRef_AsPyObjectBorrow(nos); @@ -643,6 +644,11 @@ dummy_func( EXIT_IF(!_PyLong_CheckExactAndCompact(value_o)); } + op(_GUARD_TOS_EXACT_INT, (value -- value)) { + PyObject *value_o = PyStackRef_AsPyObjectBorrow(value); + EXIT_IF(!PyLong_CheckExact(value_o)); + } + op(_GUARD_NOS_OVERFLOWED, (left, unused -- left, unused)) { PyObject *left_o = PyStackRef_AsPyObjectBorrow(left); assert(Py_TYPE(left_o) == &PyLong_Type); @@ -1635,19 +1641,23 @@ dummy_func( iter = PyStackRef_FromPyObjectSteal(iter_o); } - inst(GET_ANEXT, (aiter -- aiter, awaitable)) { + inst(GET_ANEXT, (aiter -- aiter, awaitable, null, none)) { PyObject *awaitable_o = _PyEval_GetANext(PyStackRef_AsPyObjectBorrow(aiter)); if (awaitable_o == NULL) { ERROR_NO_POP(); } awaitable = PyStackRef_FromPyObjectSteal(awaitable_o); + null = PyStackRef_NULL; + none = PyStackRef_None; } - inst(GET_AWAITABLE, (iterable -- iter)) { + inst(GET_AWAITABLE, (iterable -- iter, null, none)) { PyObject *iter_o = _PyEval_GetAwaitable(PyStackRef_AsPyObjectBorrow(iterable), oparg); PyStackRef_CLOSE(iterable); ERROR_IF(iter_o == NULL); iter = PyStackRef_FromPyObjectSteal(iter_o); + null = PyStackRef_NULL; + none = PyStackRef_None; } family(SEND, INLINE_CACHE_ENTRIES_SEND) = { @@ -1780,8 +1790,6 @@ dummy_func( if (index < 0) { ERROR_NO_POP(); } - next = none; - DEAD(none); EXIT_IF(true); } DEAD(none); @@ -2188,80 +2196,30 @@ dummy_func( inst(LOAD_FROM_DICT_OR_GLOBALS, (mod_or_class_dict -- v)) { PyObject *name = GETITEM(FRAME_CO_NAMES, oparg); + PyObject *namespace = PyStackRef_AsPyObjectBorrow(mod_or_class_dict); int err; - PyObject *v_o = _PyMapping_GetOptionalItem2(PyStackRef_AsPyObjectBorrow(mod_or_class_dict), name, &err); - + PyObject *v_o = _PyMapping_GetOptionalItem2(namespace, name, &err); + if (v_o != NULL && PyLazyImport_CheckExact(v_o)) { + Py_SETREF(v_o, _PyLazyImport_Reify(tstate, v_o, name, namespace)); + if (v_o == NULL) { + err = -1; + } + } PyStackRef_CLOSE(mod_or_class_dict); ERROR_IF(err < 0); if (v_o == NULL) { - if (PyDict_CheckExact(GLOBALS()) - && PyDict_CheckExact(BUILTINS())) - { - v_o = _PyDict_LoadGlobal((PyDictObject *)GLOBALS(), - (PyDictObject *)BUILTINS(), - name); - if (v_o == NULL) { - if (!_PyErr_Occurred(tstate)) { - /* _PyDict_LoadGlobal() returns NULL without raising - * an exception if the key doesn't exist */ - _PyEval_FormatExcCheckArg(tstate, PyExc_NameError, - NAME_ERROR_MSG, name); - } - ERROR_NO_POP(); - } - - if (PyLazyImport_CheckExact(v_o)) { - PyObject *l_v = _PyImport_LoadLazyImportTstate(tstate, v_o); - Py_SETREF(v_o, l_v); - ERROR_IF(v_o == NULL); - } - } - else { - /* Slow-path if globals or builtins is not a dict */ - /* namespace 1: globals */ - v_o = _PyMapping_GetOptionalItem2(GLOBALS(), name, &err); - ERROR_IF(err < 0); - if (v_o == NULL) { - /* namespace 2: builtins */ - v_o = _PyMapping_GetOptionalItem2(BUILTINS(), name, &err); - ERROR_IF(err < 0); - if (v_o == NULL) { - _PyEval_FormatExcCheckArg( - tstate, PyExc_NameError, - NAME_ERROR_MSG, name); - ERROR_IF(true); - } - } - if (PyLazyImport_CheckExact(v_o)) { - PyObject *l_v = _PyImport_LoadLazyImportTstate(tstate, v_o); - Py_SETREF(v_o, l_v); - ERROR_IF(v_o == NULL); - } - } + _PyEval_LoadGlobalStackRef(GLOBALS(), BUILTINS(), name, &v); + ERROR_IF(PyStackRef_IsNull(v)); + } + else { + v = PyStackRef_FromPyObjectSteal(v_o); } - v = PyStackRef_FromPyObjectSteal(v_o); } inst(LOAD_NAME, (-- v)) { PyObject *name = GETITEM(FRAME_CO_NAMES, oparg); PyObject *v_o = _PyEval_LoadName(tstate, frame, name); ERROR_IF(v_o == NULL); - if (PyLazyImport_CheckExact(v_o)) { - PyObject *l_v = _PyImport_LoadLazyImportTstate(tstate, v_o); - // cannot early-decref v_o as it may cause a side-effect on l_v - if (l_v == NULL) { - Py_DECREF(v_o); - ERROR_IF(true); - } - int err = PyDict_SetItem(GLOBALS(), name, l_v); - if (err < 0) { - Py_DECREF(v_o); - Py_DECREF(l_v); - ERROR_IF(true); - } - Py_SETREF(v_o, l_v); - } - v = PyStackRef_FromPyObjectSteal(v_o); } @@ -2324,7 +2282,7 @@ dummy_func( assert(index < DK_SIZE(keys)); PyObject *res_o = FT_ATOMIC_LOAD_PTR_CONSUME(entries[index].me_value); DEOPT_IF(res_o == NULL); - #if Py_GIL_DISABLED + #ifdef Py_GIL_DISABLED int increfed = _Py_TryIncrefCompareStackRef(&entries[index].me_value, res_o, &res); DEOPT_IF(!increfed); #else @@ -2343,7 +2301,7 @@ dummy_func( PyDictUnicodeEntry *entries = DK_UNICODE_ENTRIES(keys); PyObject *res_o = FT_ATOMIC_LOAD_PTR_CONSUME(entries[index].me_value); DEOPT_IF(res_o == NULL); - #if Py_GIL_DISABLED + #ifdef Py_GIL_DISABLED int increfed = _Py_TryIncrefCompareStackRef(&entries[index].me_value, res_o, &res); DEOPT_IF(!increfed); #else @@ -2352,6 +2310,10 @@ dummy_func( STAT_INC(LOAD_GLOBAL, hit); } + tier2 op(_GUARD_BUILTINS_IS_CANONICAL, (--)) { + DEOPT_IF(BUILTINS() != tstate->interp->builtins); + } + macro(LOAD_GLOBAL_MODULE) = unused/1 + // Skip over the counter NOP + // For guard insertion in the JIT optimizer @@ -2423,6 +2385,13 @@ dummy_func( ERROR_NO_POP(); } } + else if (PyLazyImport_CheckExact(value_o)) { + Py_SETREF(value_o, _PyLazyImport_Reify( + tstate, value_o, name, class_dict)); + if (value_o == NULL) { + ERROR_NO_POP(); + } + } PyStackRef_CLOSE(class_dict_st); value = PyStackRef_FromPyObjectSteal(value_o); } @@ -2923,7 +2892,7 @@ dummy_func( op(_LOAD_ATTR_MODULE, (dict_version/2, index/1, owner -- attr, o)) { PyObject *owner_o = PyStackRef_AsPyObjectBorrow(owner); - EXIT_IF(Py_TYPE(owner_o)->tp_getattro != PyModule_Type.tp_getattro); + EXIT_IF(!PyModule_CheckExact(owner_o)); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner_o)->md_dict; assert(dict != NULL); PyDictKeysObject *keys = FT_ATOMIC_LOAD_PTR_ACQUIRE(dict->ma_keys); @@ -3841,9 +3810,9 @@ dummy_func( next = item; } - tier2 op(_GUARD_TYPE_ITER, (expected_type/4, iter, null_or_index -- iter, null_or_index)) { - PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter); - EXIT_IF(Py_TYPE(iter_o) != (PyTypeObject *)expected_type); + tier2 op(_GUARD_NOS_TYPE, (expected_type/4, nos, unused -- nos, unused)) { + PyObject *nos_o = PyStackRef_AsPyObjectBorrow(nos); + EXIT_IF(Py_TYPE(nos_o) != (PyTypeObject *)expected_type); } tier2 op(_ITER_NEXT_INLINE, (iternext_fn/4, iter, null_or_index -- iter, null_or_index, next)) { @@ -4136,7 +4105,8 @@ dummy_func( op(_LOAD_SPECIAL, (method_and_self[2] -- method_and_self[2])) { PyObject *name = _Py_SpecialMethods[oparg].name; - int err = _PyObject_LookupSpecialMethod(name, method_and_self); + int err = _PyObject_LookupSpecialMethod(name, &method_and_self[0], + &method_and_self[1]); if (err <= 0) { if (err == 0) { PyObject *owner = PyStackRef_AsPyObjectBorrow(method_and_self[1]); @@ -4866,7 +4836,8 @@ dummy_func( op(_GUARD_CALLABLE_BUILTIN_O, (callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) { PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable); EXIT_IF(!PyCFunction_CheckExact(callable_o)); - EXIT_IF(PyCFunction_GET_FLAGS(callable_o) != METH_O); + EXIT_IF((PyCFunction_GET_FLAGS(callable_o) & + _Py_METH_CALL_FLAGS) != METH_O); int total_args = oparg; if (!PyStackRef_IsNull(self_or_null)) { total_args++; @@ -4910,7 +4881,8 @@ dummy_func( op(_GUARD_CALLABLE_BUILTIN_FAST, (callable, unused, unused[oparg] -- callable, unused, unused[oparg])) { PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable); EXIT_IF(!PyCFunction_CheckExact(callable_o)); - EXIT_IF(PyCFunction_GET_FLAGS(callable_o) != METH_FASTCALL); + EXIT_IF((PyCFunction_GET_FLAGS(callable_o) & + _Py_METH_CALL_FLAGS) != METH_FASTCALL); } op(_CALL_BUILTIN_FAST, (callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) { @@ -4948,7 +4920,8 @@ dummy_func( op(_GUARD_CALLABLE_BUILTIN_FAST_WITH_KEYWORDS, (callable, unused, unused[oparg] -- callable, unused, unused[oparg])) { PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable); EXIT_IF(!PyCFunction_CheckExact(callable_o)); - EXIT_IF(PyCFunction_GET_FLAGS(callable_o) != (METH_FASTCALL | METH_KEYWORDS)); + EXIT_IF((PyCFunction_GET_FLAGS(callable_o) & + _Py_METH_CALL_FLAGS) != (METH_FASTCALL | METH_KEYWORDS)); } op(_CALL_BUILTIN_FAST_WITH_KEYWORDS, (callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) { @@ -5069,7 +5042,10 @@ dummy_func( int err = _PyList_AppendTakeRef((PyListObject *)self_o, PyStackRef_AsPyObjectSteal(arg)); UNLOCK_OBJECT(self_o); if (err) { - ERROR_NO_POP(); + // arg is consumed even on failure: close the other inputs + // and pop them all, so that arg is not closed a second time. + DECREF_INPUTS(); + ERROR_IF(true); } c = callable; s = self; @@ -5082,7 +5058,8 @@ dummy_func( PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable); PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o; EXIT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type)); - EXIT_IF(method->d_method->ml_flags != METH_O); + EXIT_IF((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + METH_O); int total_args = oparg; if (!PyStackRef_IsNull(self_or_null)) { total_args++; @@ -5157,7 +5134,8 @@ dummy_func( PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable); PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o; EXIT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type)); - EXIT_IF(method->d_method->ml_flags != (METH_FASTCALL|METH_KEYWORDS)); + EXIT_IF((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + (METH_FASTCALL | METH_KEYWORDS)); int total_args = oparg; _PyStackRef *arguments = args; if (!PyStackRef_IsNull(self_or_null)) { @@ -5231,7 +5209,8 @@ dummy_func( PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable); PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o; EXIT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type)); - EXIT_IF(method->d_method->ml_flags != METH_NOARGS); + EXIT_IF((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + METH_NOARGS); int total_args = oparg; if (!PyStackRef_IsNull(self_or_null)) { total_args++; @@ -5300,7 +5279,8 @@ dummy_func( PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o; /* Builtin METH_FASTCALL methods, without keywords */ EXIT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type)); - EXIT_IF(method->d_method->ml_flags != METH_FASTCALL); + EXIT_IF((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + METH_FASTCALL); int total_args = oparg; if (!PyStackRef_IsNull(self_or_null)) { total_args++; @@ -6262,6 +6242,10 @@ dummy_func( if (target->op.code == ENTER_EXECUTOR) { PyCodeObject *code = _PyFrame_GetCode(frame); executor = code->co_executors->executors[target->op.arg]; + if (executor == _PyExecutor_FromExit(exit)) { + _Py_ExecutorDetach(executor); + GOTO_TIER_ONE(target); + } Py_INCREF(executor); assert(tstate->jit_exit == exit); exit->executor = executor; diff --git a/Python/ceval.c b/Python/ceval.c index 3f636c3416e1207..ccc0edca2fc7940 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3,6 +3,11 @@ #include "ceval.h" #include "pycore_long.h" +#ifdef HAVE_PTHREAD_NP_H +# include // pthread_attr_get_np() +#endif + + int Py_GetRecursionLimit(void) { @@ -65,64 +70,6 @@ _Py_ReachedRecursionLimitWithMargin(PyThreadState *tstate, int margin_count) # define Py_C_STACK_SIZE 4000000 #endif -#if defined(__EMSCRIPTEN__) - -// Temporary workaround to make `pthread_getattr_np` work on Emscripten. -// Emscripten 4.0.6 will contain a fix: -// https://github.com/emscripten-core/emscripten/pull/23887 - -#include "emscripten/stack.h" - -#define pthread_attr_t workaround_pthread_attr_t -#define pthread_getattr_np workaround_pthread_getattr_np -#define pthread_attr_getguardsize workaround_pthread_attr_getguardsize -#define pthread_attr_getstack workaround_pthread_attr_getstack -#define pthread_attr_destroy workaround_pthread_attr_destroy - -typedef struct { - void *_a_stackaddr; - size_t _a_stacksize, _a_guardsize; -} pthread_attr_t; - -extern __attribute__((__visibility__("hidden"))) unsigned __default_guardsize; - -// Modified version of pthread_getattr_np from the upstream PR. - -int pthread_getattr_np(pthread_t thread, pthread_attr_t *attr) { - attr->_a_stackaddr = (void*)emscripten_stack_get_base(); - attr->_a_stacksize = emscripten_stack_get_base() - emscripten_stack_get_end(); - attr->_a_guardsize = __default_guardsize; - return 0; -} - -// These three functions copied without any changes from Emscripten libc. - -int pthread_attr_getguardsize(const pthread_attr_t *restrict a, size_t *restrict size) -{ - *size = a->_a_guardsize; - return 0; -} - -int pthread_attr_getstack(const pthread_attr_t *restrict a, void **restrict addr, size_t *restrict size) -{ -/// XXX musl is not standard-conforming? It should not report EINVAL if _a_stackaddr is zero, and it should -/// report EINVAL if a is null: http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_attr_getstack.html - if (!a) return EINVAL; -// if (!a->_a_stackaddr) -// return EINVAL; - - *size = a->_a_stacksize; - *addr = (void *)(a->_a_stackaddr - *size); - return 0; -} - -int pthread_attr_destroy(pthread_attr_t *a) -{ - return 0; -} - -#endif - static void hardware_stack_limits(uintptr_t *base, uintptr_t *top, uintptr_t sp) { @@ -131,7 +78,9 @@ hardware_stack_limits(uintptr_t *base, uintptr_t *top, uintptr_t sp) GetCurrentThreadStackLimits(&low, &high); *top = (uintptr_t)high; ULONG guarantee = 0; +#ifdef MS_WINDOWS_DESKTOP SetThreadStackGuarantee(&guarantee); +#endif *base = (uintptr_t)low + guarantee; #elif defined(__APPLE__) pthread_t this_thread = pthread_self(); @@ -140,15 +89,24 @@ hardware_stack_limits(uintptr_t *base, uintptr_t *top, uintptr_t sp) *top = (uintptr_t)stack_addr; *base = ((uintptr_t)stack_addr) - stack_size; #else - /// XXX musl supports HAVE_PTHRED_GETATTR_NP, but the resulting stack size - /// (on alpine at least) is much smaller than expected and imposes undue limits - /// compared to the old stack size estimation. (We assume musl is not glibc.) -# if defined(HAVE_PTHREAD_GETATTR_NP) && !defined(_AIX) && \ - !defined(__NetBSD__) && (defined(__GLIBC__) || !defined(__linux__)) + // musl supports HAVE_PTHREAD_GETATTR_NP, but the resulting stack size + // (on alpine at least) is much smaller than expected and imposes undue + // limits compared to the old stack size estimation. musl doesn't give + // us a way to detect it, so we have to assume any non-glibc, + // non-Android Linux is musl and mustn't rely on pthread_getattr_np. +# if (defined(HAVE_PTHREAD_GETATTR_NP) || defined(_Py_HAVE_PTHREAD_ATTR_GET_NP)) \ + && !defined(_AIX) && !defined(__NetBSD__) \ + && (defined(__GLIBC__) || defined(__ANDROID__) || !defined(__linux__)) size_t stack_size, guard_size; void *stack_addr; pthread_attr_t attr; - int err = pthread_getattr_np(pthread_self(), &attr); + + int err = pthread_attr_init(&attr); +#ifdef _Py_HAVE_PTHREAD_ATTR_GET_NP + err |= pthread_attr_get_np(pthread_self(), &attr); +#else + err |= pthread_getattr_np(pthread_self(), &attr); +#endif if (err == 0) { err = pthread_attr_getguardsize(&attr, &guard_size); err |= pthread_attr_getstack(&attr, &stack_addr, &stack_size); @@ -160,6 +118,7 @@ hardware_stack_limits(uintptr_t *base, uintptr_t *top, uintptr_t sp) return; } # endif + // Add some space for caller function then round to minimum page size // This is a guess at the top of the stack, but should be a reasonably // good guess if called from _PyThreadState_Attach when creating a thread. @@ -1202,8 +1161,16 @@ dtrace_function_entry(_PyInterpreterFrame *frame) int lineno; PyCodeObject *code = _PyFrame_GetCode(frame); + PyObject *exc = PyErr_GetRaisedException(); filename = PyUnicode_AsUTF8(code->co_filename); funcname = PyUnicode_AsUTF8(code->co_name); + PyErr_SetRaisedException(exc); + if (filename == NULL) { + filename = ""; + } + if (funcname == NULL) { + funcname = ""; + } lineno = PyUnstable_InterpreterFrame_GetLine(frame); PyDTrace_FUNCTION_ENTRY(filename, funcname, lineno); @@ -1217,15 +1184,29 @@ dtrace_function_return(_PyInterpreterFrame *frame) int lineno; PyCodeObject *code = _PyFrame_GetCode(frame); + PyObject *exc = PyErr_GetRaisedException(); filename = PyUnicode_AsUTF8(code->co_filename); funcname = PyUnicode_AsUTF8(code->co_name); + PyErr_SetRaisedException(exc); + if (filename == NULL) { + filename = ""; + } + if (funcname == NULL) { + funcname = ""; + } lineno = PyUnstable_InterpreterFrame_GetLine(frame); PyDTrace_FUNCTION_RETURN(filename, funcname, lineno); } #endif -PyObject* _Py_HOT_FUNCTION DONT_SLP_VECTORIZE +/* + * _PyEval_EvalFrameDefault must remain a separate frame in the C call stack: + * stack unwinders, profilers and other tools that walk the stack use it to + * find the interpreter loop. With the tail-calling interpreter it is small + * enough to be inlined into its callers, e.g. by Clang with PGO. + */ +Py_NO_INLINE PyObject* _Py_HOT_FUNCTION DONT_SLP_VECTORIZE _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag) { _Py_EnsureTstateNotNULL(tstate); @@ -1605,12 +1586,14 @@ missing_arguments(PyThreadState *tstate, PyCodeObject *co, static void too_many_positional(PyThreadState *tstate, PyCodeObject *co, Py_ssize_t given, PyObject *defaults, - _PyStackRef *localsplus, PyObject *qualname) + _PyStackRef *localsplus, PyObject *qualname, + int should_suggest_missing_self) { int plural; Py_ssize_t kwonly_given = 0; Py_ssize_t i; PyObject *sig, *kwonly_sig; + const char *self_hint = ""; Py_ssize_t co_argcount = co->co_argcount; assert((co->co_flags & CO_VARARGS) == 0); @@ -1648,22 +1631,59 @@ too_many_positional(PyThreadState *tstate, PyCodeObject *co, kwonly_sig = Py_GetConstant(Py_CONSTANT_EMPTY_STR); assert(kwonly_sig != NULL); } + if (should_suggest_missing_self) { + self_hint = ". Did you forget the 'self' parameter " + "in the function definition?"; + } _PyErr_Format(tstate, PyExc_TypeError, - "%U() takes %U positional argument%s but %zd%U %s given", + "%U() takes %U positional argument%s but %zd%U %s given%s", qualname, sig, plural ? "s" : "", given, kwonly_sig, - given == 1 && !kwonly_given ? "was" : "were"); + given == 1 && !kwonly_given ? "was" : "were", + self_hint + ); Py_DECREF(sig); Py_DECREF(kwonly_sig); } +static int +suggest_missing_self(PyFunctionObject *func, PyCodeObject *co, + PyObject *first_argument, Py_ssize_t argcount) +{ + /* Missing self shows up as exactly one extra positional argument. */ + if ((co->co_argcount + 1) != argcount) { + return 0; + } + + if (first_argument == NULL || PyType_Check(first_argument)) { + /* When first arg is NULL, it's not really about self. + If it's a type object, then it's a classmethod. */ + return 0; + } + + if (co->co_argcount > 0) { + PyObject *first_parameter_name = PyTuple_GET_ITEM(co->co_localsplusnames, 0); + /* If the receiver parameter is already declared, another hint would be misleading. */ + if (PyUnicode_CompareWithASCIIString(first_parameter_name, "self") == 0 || + PyUnicode_CompareWithASCIIString(first_parameter_name, "cls") == 0) + { + return 0; + } + } + /* If the current function matches on the type, it's likely worth adding the hint. */ + PyTypeObject *self_cls = Py_TYPE(first_argument); + PyFunctionObject *possibly_current_function = + (PyFunctionObject *)_PyType_Lookup(self_cls, co->co_name); + return possibly_current_function == func; +} + static int positional_only_passed_as_keyword(PyThreadState *tstate, PyCodeObject *co, Py_ssize_t kwcount, PyObject* kwnames, - PyObject *qualname) + PyFunctionObject *func) { int posonly_conflicts = 0; PyObject* posonly_names = PyList_New(0); @@ -1710,7 +1730,8 @@ positional_only_passed_as_keyword(PyThreadState *tstate, PyCodeObject *co, _PyErr_Format(tstate, PyExc_TypeError, "%U() got some positional-only arguments passed" " as keyword arguments: '%U'", - qualname, error_names); + FT_ATOMIC_LOAD_PTR_ACQUIRE(func->func_qualname), + error_names); Py_DECREF(error_names); goto fail; } @@ -1734,6 +1755,7 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func, /* Create a dictionary for keyword parameters (**kwags) */ PyObject *kwdict; Py_ssize_t i; + PyObject *first_argument = NULL; if (co->co_flags & CO_VARKEYWORDS) { kwdict = PyDict_New(); if (kwdict == NULL) { @@ -1750,6 +1772,10 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func, kwdict = NULL; } + if (argcount > co->co_argcount && !(co->co_flags & CO_VARARGS)) { + first_argument = PyStackRef_AsPyObjectNew(args[0]); + } + /* Copy all positional arguments into local variables */ Py_ssize_t j, n; if (argcount > co->co_argcount) { @@ -1801,8 +1827,8 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func, if (keyword == NULL || !PyUnicode_Check(keyword)) { _PyErr_Format(tstate, PyExc_TypeError, - "%U() keywords must be strings", - func->func_qualname); + "%U() keywords must be strings", + FT_ATOMIC_LOAD_PTR_ACQUIRE(func->func_qualname)); goto kw_fail; } @@ -1834,7 +1860,7 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func, if (co->co_posonlyargcount && positional_only_passed_as_keyword(tstate, co, kwcount, kwnames, - func->func_qualname)) + func)) { goto kw_fail; } @@ -1855,15 +1881,16 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func, } } + PyObject *qualname = FT_ATOMIC_LOAD_PTR_ACQUIRE(func->func_qualname); if (suggestion_keyword) { _PyErr_Format(tstate, PyExc_TypeError, "%U() got an unexpected keyword argument '%S'. Did you mean '%S'?", - func->func_qualname, keyword, suggestion_keyword); + qualname, keyword, suggestion_keyword); Py_DECREF(suggestion_keyword); } else { _PyErr_Format(tstate, PyExc_TypeError, "%U() got an unexpected keyword argument '%S'", - func->func_qualname, keyword); + qualname, keyword); } goto kw_fail; @@ -1884,8 +1911,9 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func, kw_found: if (PyStackRef_AsPyObjectBorrow(localsplus[j]) != NULL) { _PyErr_Format(tstate, PyExc_TypeError, - "%U() got multiple values for argument '%S'", - func->func_qualname, keyword); + "%U() got multiple values for argument '%S'", + FT_ATOMIC_LOAD_PTR_ACQUIRE(func->func_qualname), + keyword); goto kw_fail; } localsplus[j] = value_stackref; @@ -1894,8 +1922,10 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func, /* Check the number of positional arguments */ if ((argcount > co->co_argcount) && !(co->co_flags & CO_VARARGS)) { + int missing_self_hint = suggest_missing_self(func, co, first_argument, argcount); too_many_positional(tstate, co, argcount, func->func_defaults, localsplus, - func->func_qualname); + FT_ATOMIC_LOAD_PTR_ACQUIRE(func->func_qualname), + missing_self_hint); goto fail_post_args; } @@ -1911,7 +1941,7 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func, } if (missing) { missing_arguments(tstate, co, missing, defcount, localsplus, - func->func_qualname); + FT_ATOMIC_LOAD_PTR_ACQUIRE(func->func_qualname)); goto fail_post_args; } if (n > m) @@ -1950,10 +1980,11 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func, } if (missing) { missing_arguments(tstate, co, missing, -1, localsplus, - func->func_qualname); + FT_ATOMIC_LOAD_PTR_ACQUIRE(func->func_qualname)); goto fail_post_args; } } + Py_XDECREF(first_argument); return 0; fail_pre_positional: @@ -1970,6 +2001,7 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func, } /* fall through */ fail_post_args: + Py_XDECREF(first_argument); return -1; } @@ -1996,9 +2028,11 @@ clear_gen_frame(PyThreadState *tstate, _PyInterpreterFrame * frame) assert(tstate->exc_info == &gen->gi_exc_state); tstate->exc_info = gen->gi_exc_state.previous_item; gen->gi_exc_state.previous_item = NULL; - assert(frame->frame_obj == NULL || frame->frame_obj->f_frame == frame); frame->previous = NULL; + Py_BEGIN_CRITICAL_SECTION(gen); + assert(frame->frame_obj == NULL || frame->frame_obj->f_frame == frame); _PyFrame_ClearExceptCode(frame); + Py_END_CRITICAL_SECTION(); _PyErr_ClearExcState(&gen->gi_exc_state); // gh-143939: There must not be any escaping calls between setting // the generator return kind and returning from _PyEval_EvalFrame. @@ -2150,15 +2184,9 @@ _PyEval_Vector(PyThreadState *tstate, PyFunctionObject *func, /* _PyEvalFramePushAndInit consumes the references * to func, locals and all its arguments */ Py_XINCREF(locals); - for (size_t i = 0; i < argcount; i++) { + for (size_t i = 0; i < total_args; i++) { arguments[i] = PyStackRef_FromPyObjectNew(args[i]); } - if (kwnames) { - Py_ssize_t kwcount = PyTuple_GET_SIZE(kwnames); - for (Py_ssize_t i = 0; i < kwcount; i++) { - arguments[i+argcount] = PyStackRef_FromPyObjectNew(args[i+argcount]); - } - } _PyInterpreterFrame *frame = _PyEvalFramePushAndInit( tstate, PyStackRef_FromPyObjectNew(func), locals, arguments, argcount, kwnames, NULL); @@ -2902,14 +2930,40 @@ PyEval_MergeCompilerFlags(PyCompilerFlags *cf) return result; } +static const char * +functionobject_get_name(PyFunctionObject *f) +{ +#ifdef Py_GIL_DISABLED + for (;;) { + PyObject *name = Py_NewRef(FT_ATOMIC_LOAD_PTR_ACQUIRE(f->func_name)); + // UTF-8 conversion may detach while acquiring the string's lock. + // This could result in func_name being freed if func_name was + // recently replaced using _PyObject_XSetRefDelayed(). The returned + // char* is only valid until the next quiescent point. + const char *result = PyUnicode_AsUTF8(name); + if (result == NULL) { + Py_DECREF(name); + return NULL; + } + int unchanged = name == FT_ATOMIC_LOAD_PTR_ACQUIRE(f->func_name); + Py_DECREF(name); + if (unchanged) { + return result; + } + } +#else + return PyUnicode_AsUTF8(f->func_name); +#endif +} const char * PyEval_GetFuncName(PyObject *func) { if (PyMethod_Check(func)) return PyEval_GetFuncName(PyMethod_GET_FUNCTION(func)); - else if (PyFunction_Check(func)) - return PyUnicode_AsUTF8(((PyFunctionObject*)func)->func_name); + else if (PyFunction_Check(func)) { + return functionobject_get_name((PyFunctionObject *)func); + } else if (PyCFunction_Check(func)) return ((PyCFunctionObject*)func)->m_ml->ml_name; else @@ -3146,8 +3200,8 @@ _PyEval_LazyImportName(PyThreadState *tstate, PyObject *builtins, goto error; } - PyObject *args[6] = {name, globals, locals, fromlist, level, builtins}; - res = PyObject_Vectorcall(lazy_import_func, args, 6, NULL); + PyObject *args[5] = {name, globals, locals, fromlist, level}; + res = PyObject_Vectorcall(lazy_import_func, args, 5, NULL); error: Py_XDECREF(lazy_import_func); return res; @@ -3321,64 +3375,6 @@ _PyEval_ImportFrom(PyThreadState *tstate, PyObject *v, PyObject *name) return NULL; } -PyObject * -_PyEval_LazyImportFrom(PyThreadState *tstate, _PyInterpreterFrame *frame, PyObject *v, PyObject *name) -{ - assert(PyLazyImport_CheckExact(v)); - assert(name); - assert(PyUnicode_Check(name)); - PyObject *ret; - PyLazyImportObject *d = (PyLazyImportObject *)v; - PyObject *mod = PyImport_GetModule(d->lz_from); - if (mod != NULL) { - // Check if the module already has the attribute, if so, resolve it - // eagerly. - if (PyModule_Check(mod)) { - PyObject *mod_dict = PyModule_GetDict(mod); - if (mod_dict != NULL) { - if (PyDict_GetItemRef(mod_dict, name, &ret) < 0) { - Py_DECREF(mod); - return NULL; - } - if (ret != NULL) { - Py_DECREF(mod); - return ret; - } - } - } - Py_DECREF(mod); - } - - if (d->lz_attr != NULL) { - if (PyUnicode_Check(d->lz_attr)) { - PyObject *from = PyUnicode_FromFormat( - "%U.%U", d->lz_from, d->lz_attr); - if (from == NULL) { - return NULL; - } - ret = _PyLazyImport_New(frame, d->lz_builtins, from, name); - Py_DECREF(from); - return ret; - } - } - else { - Py_ssize_t dot = PyUnicode_FindChar( - d->lz_from, '.', 0, PyUnicode_GET_LENGTH(d->lz_from), 1 - ); - if (dot >= 0) { - PyObject *from = PyUnicode_Substring(d->lz_from, 0, dot); - if (from == NULL) { - return NULL; - } - ret = _PyLazyImport_New(frame, d->lz_builtins, from, name); - Py_DECREF(from); - return ret; - } - } - ret = _PyLazyImport_New(frame, d->lz_builtins, d->lz_from, name); - return ret; -} - #define CANNOT_CATCH_MSG "catching classes that do not inherit from "\ "BaseException is not allowed" @@ -3644,13 +3640,13 @@ _PyEval_GetANext(PyObject *aiter) void _PyEval_LoadGlobalStackRef(PyObject *globals, PyObject *builtins, PyObject *name, _PyStackRef *writeto) { + PyObject *namespace = globals; if (PyAnyDict_CheckExact(globals) && PyAnyDict_CheckExact(builtins)) { - _PyDict_LoadGlobalStackRef((PyDictObject *)globals, - (PyDictObject *)builtins, - name, writeto); + namespace = _PyDict_LoadGlobalStackRef((PyDictObject *)globals, + (PyDictObject *)builtins, + name, writeto); if (PyStackRef_IsNull(*writeto) && !PyErr_Occurred()) { - /* _PyDict_LoadGlobal() returns NULL without raising - * an exception if the key doesn't exist */ + // A missing key does not set an exception in the dictionary helper. _PyEval_FormatExcCheckArg(PyThreadState_GET(), PyExc_NameError, NAME_ERROR_MSG, name); } @@ -3665,6 +3661,7 @@ _PyEval_LoadGlobalStackRef(PyObject *globals, PyObject *builtins, PyObject *name } if (res == NULL) { /* namespace 2: builtins */ + namespace = builtins; if (PyMapping_GetOptionalItem(builtins, name, &res) < 0) { *writeto = PyStackRef_NULL; return; @@ -3682,20 +3679,10 @@ _PyEval_LoadGlobalStackRef(PyObject *globals, PyObject *builtins, PyObject *name PyObject *res_o = PyStackRef_AsPyObjectBorrow(*writeto); if (res_o != NULL && PyLazyImport_CheckExact(res_o)) { - PyObject *l_v = _PyImport_LoadLazyImportTstate(PyThreadState_GET(), res_o); + PyObject *l_v = _PyLazyImport_Reify( + PyThreadState_GET(), res_o, name, namespace); PyStackRef_CLOSE(writeto[0]); - if (l_v == NULL) { - assert(PyErr_Occurred()); - *writeto = PyStackRef_NULL; - return; - } - int err = PyDict_SetItem(globals, name, l_v); - if (err < 0) { - Py_DECREF(l_v); - *writeto = PyStackRef_NULL; - return; - } - *writeto = PyStackRef_FromPyObjectSteal(l_v); + *writeto = l_v == NULL ? PyStackRef_NULL : PyStackRef_FromPyObjectSteal(l_v); } } @@ -3726,32 +3713,39 @@ _PyEval_GetAwaitable(PyObject *iterable, int oparg) PyObject * _PyEval_LoadName(PyThreadState *tstate, _PyInterpreterFrame *frame, PyObject *name) { - PyObject *value; - if (frame->f_locals == NULL) { + PyObject *namespace = frame->f_locals; + if (namespace == NULL) { _PyErr_SetString(tstate, PyExc_SystemError, "no locals found"); return NULL; } - if (PyMapping_GetOptionalItem(frame->f_locals, name, &value) < 0) { + if (PyMapping_GetOptionalItem(namespace, name, &value) < 0) { return NULL; } if (value != NULL) { - return value; + goto found; } - if (PyDict_GetItemRef(frame->f_globals, name, &value) < 0) { + namespace = frame->f_globals; + if (PyDict_GetItemRef(namespace, name, &value) < 0) { return NULL; } if (value != NULL) { - return value; + goto found; } - if (PyMapping_GetOptionalItem(frame->f_builtins, name, &value) < 0) { + namespace = frame->f_builtins; + if (PyMapping_GetOptionalItem(namespace, name, &value) < 0) { return NULL; } if (value == NULL) { _PyEval_FormatExcCheckArg( tstate, PyExc_NameError, - NAME_ERROR_MSG, name); + NAME_ERROR_MSG, name); + return NULL; + } +found: + if (PyLazyImport_CheckExact(value)) { + Py_SETREF(value, _PyLazyImport_Reify(tstate, value, name, namespace)); } return value; } diff --git a/Python/ceval.h b/Python/ceval.h index 0437ab85c5a6682..00db67265a4f3a1 100644 --- a/Python/ceval.h +++ b/Python/ceval.h @@ -257,9 +257,9 @@ lltrace_resume_frame(_PyInterpreterFrame *frame) } PyFunctionObject *f = (PyFunctionObject *)fobj; PyObject *exc = PyErr_GetRaisedException(); - PyObject *name = f->func_qualname; + PyObject *name = Py_XNewRef(FT_ATOMIC_LOAD_PTR_ACQUIRE(f->func_qualname)); if (name == NULL) { - name = f->func_name; + name = Py_XNewRef(FT_ATOMIC_LOAD_PTR_ACQUIRE(f->func_name)); } printf("\nResuming frame"); if (name) { @@ -267,12 +267,15 @@ lltrace_resume_frame(_PyInterpreterFrame *frame) if (PyObject_Print(name, stdout, 0) < 0) { PyErr_Clear(); } + Py_DECREF(name); } - if (f->func_module) { + PyObject *module = Py_XNewRef(FT_ATOMIC_LOAD_PTR_ACQUIRE(f->func_module)); + if (module) { printf(" in module "); - if (PyObject_Print(f->func_module, stdout, 0) < 0) { + if (PyObject_Print(module, stdout, 0) < 0) { PyErr_Clear(); } + Py_DECREF(module); } printf("\n"); fflush(stdout); diff --git a/Python/ceval_gil.c b/Python/ceval_gil.c index 2425bc1b39f0dcc..a06eb4f72ece37a 100644 --- a/Python/ceval_gil.c +++ b/Python/ceval_gil.c @@ -550,7 +550,8 @@ _PyEval_FiniGIL(PyInterpreterState *interp) interp->ceval.gil = NULL; } -void +// Function removed in Python 3.16 limited C API, but kept in the stable ABI +PyAPI_FUNC(void) PyEval_InitThreads(void) { /* Do nothing: kept for backward compatibility */ @@ -829,9 +830,6 @@ handle_signals(PyThreadState *tstate) { assert(_PyThreadState_CheckConsistency(tstate)); _Py_unset_eval_breaker_bit(tstate, _PY_SIGNALS_PENDING_BIT); - if (!_Py_ThreadCanHandleSignals(tstate->interp)) { - return 0; - } if (_PyErr_CheckSignalsTstate(tstate) < 0) { /* On failure, re-schedule a call to handle_signals(). */ _Py_set_eval_breaker_bit(tstate, _PY_SIGNALS_PENDING_BIT); @@ -1257,10 +1255,11 @@ static inline void run_remote_debugger_script(PyObject *path) int _PyRunRemoteDebugger(PyThreadState *tstate) { + if (tstate->remote_debugger_support.debugger_pending_call != 1) { + return 0; + } const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp); - if (config->remote_debug == 1 - && tstate->remote_debugger_support.debugger_pending_call == 1) - { + if (config->remote_debug == 1) { tstate->remote_debugger_support.debugger_pending_call = 0; // Immediately make a copy in case of a race with another debugger @@ -1388,7 +1387,7 @@ _Py_HandlePending(PyThreadState *tstate) _Py_brc_merge_refcounts(tstate); } /* Process deferred memory frees held by QSBR */ - if (_Py_qsbr_should_process(((_PyThreadStateImpl *)tstate)->qsbr)) { + if ((breaker & _PY_EVAL_PROCESS_DELAYED_BIT) != 0) { _PyMem_ProcessDelayed(tstate); } #endif diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h index f19adfa0cfcfc15..36921e35533433d 100644 --- a/Python/ceval_macros.h +++ b/Python/ceval_macros.h @@ -354,6 +354,25 @@ static void dtrace_function_return(_PyInterpreterFrame *); #define ADAPTIVE_COUNTER_TRIGGERS(COUNTER) \ backoff_counter_triggers(forge_backoff_counter((COUNTER))) +#ifdef Py_GIL_DISABLED +/* Counters are unreachable when thread-local bytecode is disabled, + * so there is no need to update them. */ +#define ADVANCE_ADAPTIVE_COUNTER(COUNTER) \ + do { \ + _Py_BackoffCounter cnt = (COUNTER); \ + if (!backoff_counter_is_unreachable(cnt)) { \ + (COUNTER) = advance_backoff_counter(cnt); \ + } \ + } while (0); + +#define PAUSE_ADAPTIVE_COUNTER(COUNTER) \ + do { \ + _Py_BackoffCounter cnt = (COUNTER); \ + if (!backoff_counter_is_unreachable(cnt)) { \ + (COUNTER) = pause_backoff_counter(cnt); \ + } \ + } while (0); +#else #define ADVANCE_ADAPTIVE_COUNTER(COUNTER) \ do { \ (COUNTER) = advance_backoff_counter((COUNTER)); \ @@ -363,6 +382,7 @@ static void dtrace_function_return(_PyInterpreterFrame *); do { \ (COUNTER) = pause_backoff_counter((COUNTER)); \ } while (0); +#endif #ifdef ENABLE_SPECIALIZATION /* Multiple threads may execute these concurrently if thread-local bytecode is diff --git a/Python/clinic/Python-tokenize.c.h b/Python/clinic/Python-tokenize.c.h index 9e64c2055a8db6d..d0311a9374d1a55 100644 --- a/Python/clinic/Python-tokenize.c.h +++ b/Python/clinic/Python-tokenize.c.h @@ -6,7 +6,9 @@ preserve # include "pycore_gc.h" // PyGC_Head # include "pycore_runtime.h" // _Py_ID() #endif +#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() static PyObject * tokenizeriter_new_impl(PyTypeObject *type, PyObject *readline, @@ -68,19 +70,29 @@ tokenizeriter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("tokenizeriter", "argument 'encoding'", "str", fastargs[2]); goto exit; } - Py_ssize_t encoding_length; - encoding = PyUnicode_AsUTF8AndSize(fastargs[2], &encoding_length); + encoding = _PyUnicode_AsUTF8NoNUL(fastargs[2]); if (encoding == NULL) { goto exit; } - if (strlen(encoding) != (size_t)encoding_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } skip_optional_kwonly: return_value = tokenizeriter_new_impl(type, readline, extra_tokens, encoding); exit: return return_value; } -/*[clinic end generated code: output=4c448f34d9c835c0 input=a9049054013a1b77]*/ + +static PyObject * +tokenizeriter_next_impl(tokenizeriterobject *self); + +static PyObject * +tokenizeriter_next(PyObject *self) +{ + PyObject *return_value = NULL; + + Py_BEGIN_CRITICAL_SECTION(self); + return_value = tokenizeriter_next_impl((tokenizeriterobject *)self); + Py_END_CRITICAL_SECTION(); + + return return_value; +} +/*[clinic end generated code: output=67cc510ef85272ba input=a9049054013a1b77]*/ diff --git a/Python/clinic/_warnings.c.h b/Python/clinic/_warnings.c.h index 8bda830ccb924eb..a64418be0a830ba 100644 --- a/Python/clinic/_warnings.c.h +++ b/Python/clinic/_warnings.c.h @@ -45,7 +45,7 @@ warnings_release_lock(PyObject *module, PyObject *Py_UNUSED(ignored)) PyDoc_STRVAR(warnings_warn__doc__, "warn($module, /, message, category=None, stacklevel=1, source=None, *,\n" -" skip_file_prefixes=)\n" +" skip_file_prefixes=())\n" "--\n" "\n" "Issue a warning, or maybe ignore it or raise an exception.\n" @@ -284,4 +284,4 @@ warnings_filters_mutated_lock_held(PyObject *module, PyObject *Py_UNUSED(ignored { return warnings_filters_mutated_lock_held_impl(module); } -/*[clinic end generated code: output=610ed5764bf40bb5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=fc026d6a21e12170 input=a9049054013a1b77]*/ diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h index 4a38e0df61708c0..46d24cbcecdb2c5 100644 --- a/Python/clinic/bltinmodule.c.h +++ b/Python/clinic/bltinmodule.c.h @@ -7,6 +7,7 @@ preserve # include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(builtin___import____doc__, "__import__($module, /, name, globals=None, locals=None, fromlist=(),\n" @@ -278,6 +279,67 @@ PyDoc_STRVAR(builtin_callable__doc__, #define BUILTIN_CALLABLE_METHODDEF \ {"callable", (PyCFunction)builtin_callable, METH_O, builtin_callable__doc__}, +PyDoc_STRVAR(filter_new__doc__, +"filter(function, iterable, /)\n" +"--\n" +"\n" +"Return an iterator over items of iterable where function(item) is true.\n" +"\n" +"If function is None, return the items that are true."); + +static PyObject * +filter_new_impl(PyTypeObject *type, PyObject *func, PyObject *seq); + +static PyObject * +filter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyTypeObject *base_tp = &PyFilter_Type; + PyObject *func; + PyObject *seq; + + if ((type == base_tp || type->tp_init == base_tp->tp_init) && + !_PyArg_NoKeywords("filter", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("filter", PyTuple_GET_SIZE(args), 2, 2)) { + goto exit; + } + func = PyTuple_GET_ITEM(args, 0); + seq = PyTuple_GET_ITEM(args, 1); + return_value = filter_new_impl(type, func, seq); + +exit: + return return_value; +} + +static PyObject * +filter_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + PyObject *func; + PyObject *seq; + + assert(_PyType_CAST(type)->tp_new == filter_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + if (!_PyArg_NoKwnames("filter", kwnames)) { + goto exit; + } + if (!_PyArg_CheckPositional("filter", nargs, 2, 2)) { + goto exit; + } + func = args[0]; + seq = args[1]; + return_value = filter_new_impl(_PyType_CAST(type), func, seq); + +exit: + return return_value; +} + PyDoc_STRVAR(builtin_format__doc__, "format($module, value, format_spec=\'\', /)\n" "--\n" @@ -415,15 +477,10 @@ builtin_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj _PyArg_BadArgument("compile", "argument 'mode'", "str", args[2]); goto exit; } - Py_ssize_t mode_length; - mode = PyUnicode_AsUTF8AndSize(args[2], &mode_length); + mode = _PyUnicode_AsUTF8NoNUL(args[2]); if (mode == NULL) { goto exit; } - if (strlen(mode) != (size_t)mode_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } if (!noptargs) { goto skip_optional_pos; } @@ -478,6 +535,49 @@ builtin_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj return return_value; } +PyDoc_STRVAR(builtin_dir__doc__, +"dir($module, object=, /)\n" +"--\n" +"\n" +"Return an alphabetized list of the attributes of the object.\n" +"\n" +"If called without an argument, return the names in the current scope.\n" +"Else, return an alphabetized list of names comprising (some of) the\n" +"attributes of the given object, and of attributes reachable from it.\n" +"If the object supplies a method named __dir__, it will be used;\n" +"otherwise the default dir() logic is used and returns:\n" +" for a module object: the module\'s attributes.\n" +" for a class object: its attributes, and recursively the attributes\n" +" of its bases.\n" +" for any other object: its attributes, its class\'s attributes, and\n" +" recursively the attributes of its class\'s base classes."); + +#define BUILTIN_DIR_METHODDEF \ + {"dir", _PyCFunction_CAST(builtin_dir), METH_FASTCALL, builtin_dir__doc__}, + +static PyObject * +builtin_dir_impl(PyObject *module, PyObject *arg); + +static PyObject * +builtin_dir(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *arg = NULL; + + if (!_PyArg_CheckPositional("dir", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + arg = args[0]; +skip_optional: + return_value = builtin_dir_impl(module, arg); + +exit: + return return_value; +} + PyDoc_STRVAR(builtin_divmod__doc__, "divmod($module, x, y, /)\n" "--\n" @@ -850,48 +950,82 @@ PyDoc_STRVAR(builtin_hex__doc__, #define BUILTIN_HEX_METHODDEF \ {"hex", (PyCFunction)builtin_hex, METH_O, builtin_hex__doc__}, -PyDoc_STRVAR(builtin_aiter__doc__, -"aiter($module, async_iterable, /)\n" -"--\n" -"\n" -"Return an AsyncIterator for an AsyncIterable object."); - -#define BUILTIN_AITER_METHODDEF \ - {"aiter", (PyCFunction)builtin_aiter, METH_O, builtin_aiter__doc__}, - -PyDoc_STRVAR(builtin_anext__doc__, -"anext($module, async_iterator, default=, /)\n" +PyDoc_STRVAR(builtin_iter__doc__, +"iter($module, object, /, [stop_value], *, stop_exception=StopIteration)\n" "--\n" "\n" -"Return the next item from the async iterator.\n" +"Get an iterator from an object.\n" "\n" -"If default is given and the async iterator is exhausted,\n" -"it is returned instead of raising StopAsyncIteration."); +"In the first form, the argument must supply its own iterator, or be a\n" +"sequence. In the second form, the callable is called until it returns\n" +"the stop value or raises the specified exception."); -#define BUILTIN_ANEXT_METHODDEF \ - {"anext", _PyCFunction_CAST(builtin_anext), METH_FASTCALL, builtin_anext__doc__}, +#define BUILTIN_ITER_METHODDEF \ + {"iter", _PyCFunction_CAST(builtin_iter), METH_FASTCALL|METH_KEYWORDS, builtin_iter__doc__}, static PyObject * -builtin_anext_impl(PyObject *module, PyObject *aiterator, - PyObject *default_value); +builtin_iter_impl(PyObject *module, PyObject *object, PyObject *stop_value, + PyObject *stop_exception); static PyObject * -builtin_anext(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +builtin_iter(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - PyObject *aiterator; - PyObject *default_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 2 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(stop_value), &_Py_ID(stop_exception), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE - if (!_PyArg_CheckPositional("anext", nargs, 1, 2)) { + static const char * const _keywords[] = {"", "stop_value", "stop_exception", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "iter", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *object; + PyObject *stop_value = NULL; + PyObject *stop_exception = NULL; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { goto exit; } - aiterator = args[0]; - if (nargs < 2) { - goto skip_optional; + object = args[0]; + if (!noptargs) { + goto skip_optional_pos; } - default_value = args[1]; -skip_optional: - return_value = builtin_anext_impl(module, aiterator, default_value); + if (args[1]) { + stop_value = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + stop_exception = args[2]; +skip_optional_kwonly: + return_value = builtin_iter_impl(module, object, stop_value, stop_exception); exit: return return_value; @@ -1249,6 +1383,41 @@ builtin_round(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec return return_value; } +PyDoc_STRVAR(builtin_vars__doc__, +"vars($module, object=, /)\n" +"--\n" +"\n" +"Show vars.\n" +"\n" +"Without arguments, equivalent to locals().\n" +"With an argument, equivalent to object.__dict__."); + +#define BUILTIN_VARS_METHODDEF \ + {"vars", _PyCFunction_CAST(builtin_vars), METH_FASTCALL, builtin_vars__doc__}, + +static PyObject * +builtin_vars_impl(PyObject *module, PyObject *v); + +static PyObject * +builtin_vars(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *v = NULL; + + if (!_PyArg_CheckPositional("vars", nargs, 0, 1)) { + goto exit; + } + if (nargs < 1) { + goto skip_optional; + } + v = args[0]; +skip_optional: + return_value = builtin_vars_impl(module, v); + +exit: + return return_value; +} + PyDoc_STRVAR(builtin_sum__doc__, "sum($module, iterable, /, start=0)\n" "--\n" @@ -1387,4 +1556,109 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=84efa9c5cc737ce5 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(zip_new__doc__, +"zip(*iterables, strict=False)\n" +"--\n" +"\n" +"Iterate over several iterables in parallel, yielding tuples.\n" +"\n" +"The zip object yields n-length tuples, where n is the number of\n" +"iterables passed as positional arguments to zip(). The i-th element\n" +"in every tuple comes from the i-th iterable argument to zip(). This\n" +"continues until the shortest argument is exhausted.\n" +"\n" +"If strict is true and one of the arguments is exhausted before the\n" +"others, raise a ValueError.\n" +"\n" +" >>> list(zip(\'abcdefg\', range(3), range(4)))\n" +" [(\'a\', 0, 0), (\'b\', 1, 1), (\'c\', 2, 2)]"); + +static PyObject * +zip_new_impl(PyTypeObject *type, PyObject * const *iterables, + Py_ssize_t iterables_length, int strict); + +static PyObject * +zip_new_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(strict), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"strict", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "zip", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t noptargs = 0 + nkw - 0; + PyObject * const *iterables; + Py_ssize_t iterables_length; + int strict = 0; + + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, + /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 1, argsbuf); + if (!fastargs) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + strict = PyObject_IsTrue(fastargs[0]); + if (strict < 0) { + goto exit; + } +skip_optional_kwonly: + iterables = args; + iterables_length = nargs; + return_value = zip_new_impl(type, iterables, iterables_length, strict); + +exit: + return return_value; +} + +static PyObject * +zip_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return zip_new_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +zip_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + + assert(_PyType_CAST(type)->tp_new == zip_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + return zip_new_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); +} +/*[clinic end generated code: output=a67fa5cf74c85d07 input=a9049054013a1b77]*/ diff --git a/Python/clinic/context.c.h b/Python/clinic/context.c.h index ece7341d65d5fb6..700e2ae3711309d 100644 --- a/Python/clinic/context.c.h +++ b/Python/clinic/context.c.h @@ -2,6 +2,10 @@ preserve [clinic start generated code]*/ +#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) +# include "pycore_gc.h" // PyGC_Head +# include "pycore_runtime.h" // _Py_ID() +#endif #include "pycore_modsupport.h" // _PyArg_CheckPositional() PyDoc_STRVAR(_contextvars_Context_get__doc__, @@ -116,6 +120,88 @@ _contextvars_Context_copy(PyObject *self, PyObject *Py_UNUSED(ignored)) return _contextvars_Context_copy_impl((PyContext *)self); } +static PyObject * +contextvar_tp_new_impl(PyTypeObject *type, PyObject *name, PyObject *def); + +static PyObject * +contextvar_tp_new_helper(PyTypeObject *type, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(default), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"", "default", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "ContextVar", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t noptargs = nargs + nkw - 1; + PyObject *name; + PyObject *def = NULL; + + fastargs = _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!fastargs) { + goto exit; + } + name = fastargs[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + def = fastargs[1]; +skip_optional_kwonly: + return_value = contextvar_tp_new_impl(type, name, def); + +exit: + return return_value; +} + +static PyObject * +contextvar_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + return contextvar_tp_new_helper(type, _PyTuple_CAST(args)->ob_item, + PyTuple_GET_SIZE(args), + kwargs ? PyDict_GET_SIZE(kwargs) : 0, + kwargs, NULL); +} + +static PyObject * +contextvar_tp_vectorcall(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + + assert(_PyType_CAST(type)->tp_new == contextvar_tp_new); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + return contextvar_tp_new_helper(_PyType_CAST(type), args, nargs, + kwnames ? PyTuple_GET_SIZE(kwnames) : 0, + NULL, kwnames); +} + PyDoc_STRVAR(_contextvars_ContextVar_get__doc__, "get($self, default=, /)\n" "--\n" @@ -259,4 +345,4 @@ token_exit(PyObject *self, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=90ec3e4375804e9b input=a9049054013a1b77]*/ +/*[clinic end generated code: output=488efab9f3932fbb input=a9049054013a1b77]*/ diff --git a/Python/clinic/hamt.c.h b/Python/clinic/hamt.c.h new file mode 100644 index 000000000000000..c35df925bb4ea60 --- /dev/null +++ b/Python/clinic/hamt.c.h @@ -0,0 +1,70 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#include "pycore_modsupport.h" // _PyArg_CheckPositional() + +PyDoc_STRVAR(hamt_set__doc__, +"set($self, key, val, /)\n" +"--\n" +"\n" +"Return a copy of the mapping with the key set to the value."); + +#define HAMT_SET_METHODDEF \ + {"set", _PyCFunction_CAST(hamt_set), METH_FASTCALL, hamt_set__doc__}, + +static PyObject * +hamt_set_impl(PyHamtObject *self, PyObject *key, PyObject *val); + +static PyObject * +hamt_set(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *key; + PyObject *val; + + if (!_PyArg_CheckPositional("set", nargs, 2, 2)) { + goto exit; + } + key = args[0]; + val = args[1]; + return_value = hamt_set_impl((PyHamtObject *)self, key, val); + +exit: + return return_value; +} + +PyDoc_STRVAR(hamt_get__doc__, +"get($self, key, default=None, /)\n" +"--\n" +"\n" +"Return the value for the key, or the default if it is not found."); + +#define HAMT_GET_METHODDEF \ + {"get", _PyCFunction_CAST(hamt_get), METH_FASTCALL, hamt_get__doc__}, + +static PyObject * +hamt_get_impl(PyHamtObject *self, PyObject *key, PyObject *def); + +static PyObject * +hamt_get(PyObject *self, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *key; + PyObject *def = Py_None; + + if (!_PyArg_CheckPositional("get", nargs, 1, 2)) { + goto exit; + } + key = args[0]; + if (nargs < 2) { + goto skip_optional; + } + def = args[1]; +skip_optional: + return_value = hamt_get_impl((PyHamtObject *)self, key, def); + +exit: + return return_value; +} +/*[clinic end generated code: output=2531b93a9a37546f input=a9049054013a1b77]*/ diff --git a/Python/clinic/import.c.h b/Python/clinic/import.c.h index 2e4e178b3084063..749eaebca19dc53 100644 --- a/Python/clinic/import.c.h +++ b/Python/clinic/import.c.h @@ -627,7 +627,7 @@ PyDoc_STRVAR(_imp__set_lazy_attributes__doc__, "_set_lazy_attributes($module, modobj, name, /)\n" "--\n" "\n" -"Sets attributes to lazy submodules on the module, as side effects."); +"Remove the resolved module name from sys.lazy_modules."); #define _IMP__SET_LAZY_ATTRIBUTES_METHODDEF \ {"_set_lazy_attributes", _PyCFunction_CAST(_imp__set_lazy_attributes), METH_FASTCALL, _imp__set_lazy_attributes__doc__}, @@ -665,4 +665,4 @@ _imp__set_lazy_attributes(PyObject *module, PyObject *const *args, Py_ssize_t na #ifndef _IMP_EXEC_DYNAMIC_METHODDEF #define _IMP_EXEC_DYNAMIC_METHODDEF #endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */ -/*[clinic end generated code: output=0974db098d601372 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ae9cf67e39955555 input=a9049054013a1b77]*/ diff --git a/Python/clinic/sysmodule.c.h b/Python/clinic/sysmodule.c.h index 0c72760f69a4c41..11bd8ba5bc2d5f2 100644 --- a/Python/clinic/sysmodule.c.h +++ b/Python/clinic/sysmodule.c.h @@ -7,6 +7,7 @@ preserve # include "pycore_runtime.h" // _Py_ID() #endif #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() PyDoc_STRVAR(sys_addaudithook__doc__, "addaudithook($module, /, hook)\n" @@ -92,15 +93,10 @@ sys_audit(PyObject *module, PyObject *const *args, Py_ssize_t nargs) _PyArg_BadArgument("audit", "argument 1", "str", args[0]); goto exit; } - Py_ssize_t event_length; - event = PyUnicode_AsUTF8AndSize(args[0], &event_length); + event = _PyUnicode_AsUTF8NoNUL(args[0]); if (event == NULL) { goto exit; } - if (strlen(event) != (size_t)event_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } __clinic_args = PyTuple_FromArray(args + 1, nargs - 1); if (__clinic_args == NULL) { goto exit; @@ -687,6 +683,78 @@ sys_get_coroutine_origin_tracking_depth(PyObject *module, PyObject *Py_UNUSED(ig return return_value; } +PyDoc_STRVAR(sys_set_asyncgen_hooks__doc__, +"set_asyncgen_hooks($module, /, firstiter=,\n" +" finalizer=)\n" +"--\n" +"\n" +"Set a finalizer for async generators objects."); + +#define SYS_SET_ASYNCGEN_HOOKS_METHODDEF \ + {"set_asyncgen_hooks", _PyCFunction_CAST(sys_set_asyncgen_hooks), METH_FASTCALL|METH_KEYWORDS, sys_set_asyncgen_hooks__doc__}, + +static PyObject * +sys_set_asyncgen_hooks_impl(PyObject *module, PyObject *firstiter, + PyObject *finalizer); + +static PyObject * +sys_set_asyncgen_hooks(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 2 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(firstiter), &_Py_ID(finalizer), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"firstiter", "finalizer", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "set_asyncgen_hooks", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; + PyObject *firstiter = NULL; + PyObject *finalizer = NULL; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 0, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + firstiter = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + finalizer = args[1]; +skip_optional_pos: + return_value = sys_set_asyncgen_hooks_impl(module, firstiter, finalizer); + +exit: + return return_value; +} + PyDoc_STRVAR(sys_get_asyncgen_hooks__doc__, "get_asyncgen_hooks($module, /)\n" "--\n" @@ -935,6 +1003,71 @@ sys_set_int_max_str_digits(PyObject *module, PyObject *const *args, Py_ssize_t n return return_value; } +PyDoc_STRVAR(sys_getsizeof__doc__, +"getsizeof($module, /, object, default=)\n" +"--\n" +"\n" +"Return the size of object in bytes."); + +#define SYS_GETSIZEOF_METHODDEF \ + {"getsizeof", _PyCFunction_CAST(sys_getsizeof), METH_FASTCALL|METH_KEYWORDS, sys_getsizeof__doc__}, + +static PyObject * +sys_getsizeof_impl(PyObject *module, PyObject *o, PyObject *dflt); + +static PyObject * +sys_getsizeof(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 2 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(object), &_Py_ID(default), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"object", "default", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "getsizeof", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *o; + PyObject *dflt = NULL; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + o = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + dflt = args[1]; +skip_optional_pos: + return_value = sys_getsizeof_impl(module, o, dflt); + +exit: + return return_value; +} + PyDoc_STRVAR(sys_getrefcount__doc__, "getrefcount($module, object, /)\n" "--\n" @@ -1438,15 +1571,10 @@ sys_activate_stack_trampoline(PyObject *module, PyObject *arg) _PyArg_BadArgument("activate_stack_trampoline", "argument", "str", arg); goto exit; } - Py_ssize_t backend_length; - backend = PyUnicode_AsUTF8AndSize(arg, &backend_length); + backend = _PyUnicode_AsUTF8NoNUL(arg); if (backend == NULL) { goto exit; } - if (strlen(backend) != (size_t)backend_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = sys_activate_stack_trampoline_impl(module, backend); exit: @@ -2089,4 +2217,4 @@ _jit_is_active(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef SYS_GETANDROIDAPILEVEL_METHODDEF #define SYS_GETANDROIDAPILEVEL_METHODDEF #endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */ -/*[clinic end generated code: output=8a4482f9c5c493e5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=dbca81c5072bd0e8 input=a9049054013a1b77]*/ diff --git a/Python/clinic/traceback.c.h b/Python/clinic/traceback.c.h index deae2efa3eb28d2..8df082c5df831a6 100644 --- a/Python/clinic/traceback.c.h +++ b/Python/clinic/traceback.c.h @@ -83,16 +83,6 @@ tb_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } -#if !defined(traceback_tb_next_DOCSTR) -# define traceback_tb_next_DOCSTR NULL -#endif -#if defined(TRACEBACK_TB_NEXT_GETSETDEF) -# undef TRACEBACK_TB_NEXT_GETSETDEF -# define TRACEBACK_TB_NEXT_GETSETDEF {"tb_next", (getter)traceback_tb_next_get, (setter)traceback_tb_next_set, traceback_tb_next_DOCSTR}, -#else -# define TRACEBACK_TB_NEXT_GETSETDEF {"tb_next", (getter)traceback_tb_next_get, NULL, traceback_tb_next_DOCSTR}, -#endif - static PyObject * traceback_tb_next_get_impl(PyTracebackObject *self); @@ -108,28 +98,28 @@ traceback_tb_next_get(PyObject *self, void *Py_UNUSED(context)) return return_value; } -#if !defined(traceback_tb_next_DOCSTR) -# define traceback_tb_next_DOCSTR NULL -#endif -#if defined(TRACEBACK_TB_NEXT_GETSETDEF) -# undef TRACEBACK_TB_NEXT_GETSETDEF -# define TRACEBACK_TB_NEXT_GETSETDEF {"tb_next", (getter)traceback_tb_next_get, (setter)traceback_tb_next_set, traceback_tb_next_DOCSTR}, -#else -# define TRACEBACK_TB_NEXT_GETSETDEF {"tb_next", NULL, (setter)traceback_tb_next_set, NULL}, -#endif - static int traceback_tb_next_set_impl(PyTracebackObject *self, PyObject *value); static int -traceback_tb_next_set(PyObject *self, PyObject *value, void *Py_UNUSED(context)) +traceback_tb_next_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context)) { - int return_value; - + int return_value = -1; + PyObject *value; + + if (arg == NULL) { + PyErr_Format(PyExc_AttributeError, + "attribute 'tb_next' of '%.100s' objects cannot be deleted", + Py_TYPE(self)->tp_name); + return -1; + } + value = arg; Py_BEGIN_CRITICAL_SECTION(self); return_value = traceback_tb_next_set_impl((PyTracebackObject *)self, value); Py_END_CRITICAL_SECTION(); return return_value; } -/*[clinic end generated code: output=5361141395da963e input=a9049054013a1b77]*/ +#define TRACEBACK_TB_NEXT_GETSETDEF {"tb_next", (getter)traceback_tb_next_get, (setter)traceback_tb_next_set, NULL}, + +/*[clinic end generated code: output=0f7bb7a58d9f8d65 input=a9049054013a1b77]*/ diff --git a/Python/codecs.c b/Python/codecs.c index 6d1ae651fa00058..6eb728e7f9f202a 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -64,24 +64,21 @@ PyCodec_Unregister(PyObject *search_function) PyObject *codec_search_path = interp->codecs.search_path; assert(PyList_CheckExact(codec_search_path)); + FT_MUTEX_LOCK(&interp->codecs.search_path_mutex); for (Py_ssize_t i = 0; i < PyList_GET_SIZE(codec_search_path); i++) { - FT_MUTEX_LOCK(&interp->codecs.search_path_mutex); - PyObject *item = PyList_GetItemRef(codec_search_path, i); - int ret = 1; - if (item == search_function) { - // We hold a reference to the item, so its destructor can't run - // while we hold search_path_mutex. - ret = PyList_SetSlice(codec_search_path, i, i+1, NULL); - } - FT_MUTEX_UNLOCK(&interp->codecs.search_path_mutex); - Py_DECREF(item); - if (ret != 1) { + if (PyList_GET_ITEM(codec_search_path, i) == search_function) { + // Keep the function alive until after releasing the mutex. + Py_INCREF(search_function); + int ret = PyList_SetSlice(codec_search_path, i, i+1, NULL); + FT_MUTEX_UNLOCK(&interp->codecs.search_path_mutex); + Py_DECREF(search_function); assert(interp->codecs.search_cache != NULL); assert(PyDict_CheckExact(interp->codecs.search_cache)); PyDict_Clear(interp->codecs.search_cache); return ret; } } + FT_MUTEX_UNLOCK(&interp->codecs.search_path_mutex); return 0; } @@ -142,7 +139,10 @@ PyObject *_PyCodec_Lookup(const char *encoding) } PyInterpreterState *interp = _PyInterpreterState_GET(); - assert(interp->codecs.initialized); + if (!interp->codecs.initialized) { + PyErr_SetString(PyExc_SystemError, "Codecs are not initialized"); + return NULL; + } /* Convert the encoding to a normalized Python string: all ASCII letters are converted to lower case, spaces are @@ -272,9 +272,9 @@ PyObject *codec_getitem(const char *encoding, int index) codecs = _PyCodec_Lookup(encoding); if (codecs == NULL) return NULL; - v = PyTuple_GET_ITEM(codecs, index); + v = Py_NewRef(PyTuple_GET_ITEM(codecs, index)); Py_DECREF(codecs); - return Py_NewRef(v); + return v; } /* Helper functions to create an incremental codec. */ @@ -1173,7 +1173,8 @@ get_standard_encoding_impl(const char *encoding, int *bytelength) } if (*encoding == '-' || *encoding == '_' ) encoding++; - if (Py_TOLOWER(encoding[1]) == 'e' && encoding[2] == '\0') { + if (encoding[0] != '\0' && + Py_TOLOWER(encoding[1]) == 'e' && encoding[2] == '\0') { if (Py_TOLOWER(encoding[0]) == 'b') return ENC_UTF16BE; if (Py_TOLOWER(encoding[0]) == 'l') @@ -1192,7 +1193,8 @@ get_standard_encoding_impl(const char *encoding, int *bytelength) } if (*encoding == '-' || *encoding == '_' ) encoding++; - if (Py_TOLOWER(encoding[1]) == 'e' && encoding[2] == '\0') { + if (encoding[0] != '\0' && + Py_TOLOWER(encoding[1]) == 'e' && encoding[2] == '\0') { if (Py_TOLOWER(encoding[0]) == 'b') return ENC_UTF32BE; if (Py_TOLOWER(encoding[0]) == 'l') @@ -1426,19 +1428,19 @@ _PyCodec_SurrogateEscapeUnicodeEncodeError(PyObject *exc) return NULL; } - PyObject *res = PyBytes_FromStringAndSize(NULL, slen); - if (res == NULL) { + PyBytesWriter *writer = PyBytesWriter_Create(slen); + if (writer == NULL) { Py_DECREF(obj); return NULL; } - char *outp = PyBytes_AsString(res); + char *outp = PyBytesWriter_GetData(writer); for (Py_ssize_t i = start; i < end; i++) { Py_UCS4 ch = PyUnicode_READ_CHAR(obj, i); if (ch < 0xdc80 || ch > 0xdcff) { /* Not a UTF-8b surrogate, fail with original exception. */ Py_DECREF(obj); - Py_DECREF(res); + PyBytesWriter_Discard(writer); PyErr_SetObject(PyExceptionInstance_Class(exc), exc); return NULL; } @@ -1446,6 +1448,8 @@ _PyCodec_SurrogateEscapeUnicodeEncodeError(PyObject *exc) } Py_DECREF(obj); + PyObject *res = PyBytesWriter_Finish(writer); + // Py_BuildValue() propagates the exception if res is NULL return Py_BuildValue("(Nn)", res, end); } @@ -1689,7 +1693,9 @@ _PyCodec_InitRegistry(PyInterpreterState *interp) if (mod == NULL) { PyThreadState *tstate = _PyThreadState_GET(); _Py_DumpPathConfig(tstate); - return PyStatus_Error("Failed to import encodings module"); + return PyStatus_Error("Failed to import encodings module. " + "Your environment probably has misconfigured variables! " + "Please check PYTHONHOME otherwise refer to `--help-env`"); } Py_DECREF(mod); diff --git a/Python/codegen.c b/Python/codegen.c index f2c2b21d106fbdd..ae60caf195f23ca 100644 --- a/Python/codegen.c +++ b/Python/codegen.c @@ -87,6 +87,9 @@ typedef _PyCompile_FBlockInfo fblockinfo; #define LOC(x) SRC_LOCATION_FROM_AST(x) +#define CALL_STACK_USE(nargs, nkwds) \ + ((nargs) + (nkwds) + ((nkwds) != 0)) + #define NEW_JUMP_TARGET_LABEL(C, NAME) \ jump_target_label NAME = _PyInstructionSequence_NewLabel(INSTR_SEQUENCE(C)); \ if (!IS_JUMP_TARGET_LABEL(NAME)) { \ @@ -310,19 +313,23 @@ codegen_addop_load_const(compiler *c, location loc, PyObject *o) #define ADDOP_LOAD_CONST_IN_SCOPE(C, LOC, O) \ RETURN_IF_ERROR_IN_SCOPE((C), codegen_addop_load_const((C), (LOC), (O))) +static int +codegen_addop_load_const_new(compiler *c, location loc, PyObject *o) +{ + if (o == NULL) { + return ERROR; + } + int ret = codegen_addop_load_const(c, loc, o); + Py_DECREF(o); + return ret; +} + /* Same as ADDOP_LOAD_CONST, but steals a reference. */ -#define ADDOP_LOAD_CONST_NEW(C, LOC, O) \ - do { \ - PyObject *__new_const = (O); \ - if (__new_const == NULL) { \ - return ERROR; \ - } \ - if (codegen_addop_load_const((C), (LOC), __new_const) < 0) { \ - Py_DECREF(__new_const); \ - return ERROR; \ - } \ - Py_DECREF(__new_const); \ - } while (0) +#define ADDOP_LOAD_CONST_NEW(C, LOC, O) \ + RETURN_IF_ERROR(codegen_addop_load_const_new((C), (LOC), (O))) + +#define ADDOP_LOAD_CONST_NEW_IN_SCOPE(C, LOC, O) \ + RETURN_IF_ERROR_IN_SCOPE((C), codegen_addop_load_const_new((C), (LOC), (O))) static int codegen_addop_o(compiler *c, location loc, @@ -544,6 +551,7 @@ codegen_unwind_fblock(compiler *c, location *ploc, case COMPILE_FBLOCK_EXCEPTION_HANDLER: case COMPILE_FBLOCK_EXCEPTION_GROUP_HANDLER: case COMPILE_FBLOCK_ASYNC_COMPREHENSION_GENERATOR: + case COMPILE_FBLOCK_INLINED_COMPREHENSION: case COMPILE_FBLOCK_STOP_ITERATION: return SUCCESS; @@ -610,8 +618,6 @@ codegen_unwind_fblock(compiler *c, location *ploc, RETURN_IF_ERROR(codegen_call_exit_with_nones(c, *ploc)); if (info->fb_type == COMPILE_FBLOCK_ASYNC_WITH) { ADDOP_I(c, *ploc, GET_AWAITABLE, 2); - ADDOP(c, *ploc, PUSH_NULL); - ADDOP_LOAD_CONST(c, *ploc, Py_None); ADD_YIELD_FROM(c, *ploc, 1); } ADDOP(c, *ploc, POP_TOP); @@ -683,6 +689,7 @@ codegen_enter_scope(compiler *c, identifier name, int scope_type, { RETURN_IF_ERROR( _PyCompile_EnterScope(c, name, scope_type, key, lineno, private, umd)); + RETURN_IF_ERROR_IN_SCOPE(c, _PyCompile_SetQualname(c)); location loc = LOCATION(lineno, lineno, 0, 0); if (scope_type == COMPILE_SCOPE_MODULE) { loc.lineno = 0; @@ -695,28 +702,20 @@ codegen_enter_scope(compiler *c, identifier name, int scope_type, * of 0. This is because RETURN_GENERATOR pushes the generator before returning. */ location loc = LOCATION(lineno, lineno, -1, -1); - ADDOP(c, loc, RETURN_GENERATOR); - ADDOP(c, loc, POP_TOP); + ADDOP_IN_SCOPE(c, loc, RETURN_GENERATOR); + ADDOP_IN_SCOPE(c, loc, POP_TOP); } - ADDOP_I(c, loc, RESUME, RESUME_AT_FUNC_START); + ADDOP_I_IN_SCOPE(c, loc, RESUME, RESUME_AT_FUNC_START); if (scope_type == COMPILE_SCOPE_MODULE) { - ADDOP(c, loc, ANNOTATIONS_PLACEHOLDER); + ADDOP_IN_SCOPE(c, loc, ANNOTATIONS_PLACEHOLDER); } return SUCCESS; } static int -codegen_setup_annotations_scope(compiler *c, location loc, - void *key, PyObject *name) +codegen_emit_annotations_prologue(compiler *c, location loc) { - _PyCompile_CodeUnitMetadata umd = { - .u_posonlyargcount = 1, - }; - RETURN_IF_ERROR( - codegen_enter_scope(c, name, COMPILE_SCOPE_ANNOTATIONS, - key, loc.lineno, NULL, &umd)); - // if .format > VALUE_WITH_FAKE_GLOBALS: raise NotImplementedError PyObject *value_with_fake_globals = PyLong_FromLong(_Py_ANNOTATE_FORMAT_VALUE_WITH_FAKE_GLOBALS); if (value_with_fake_globals == NULL) { @@ -728,6 +727,7 @@ codegen_setup_annotations_scope(compiler *c, location loc, ADDOP_I(c, loc, LOAD_FAST, 0); ADDOP_LOAD_CONST_NEW(c, loc, value_with_fake_globals); ADDOP_I(c, loc, COMPARE_OP, (Py_GT << 5) | compare_masks[Py_GT]); + ADDOP(c, loc, TO_BOOL); NEW_JUMP_TARGET_LABEL(c, body); ADDOP_JUMP(c, loc, POP_JUMP_IF_FALSE, body); ADDOP_I(c, loc, LOAD_COMMON_CONSTANT, CONSTANT_NOTIMPLEMENTEDERROR); @@ -736,6 +736,21 @@ codegen_setup_annotations_scope(compiler *c, location loc, return SUCCESS; } +static int +codegen_setup_annotations_scope(compiler *c, location loc, + void *key, PyObject *name) +{ + _PyCompile_CodeUnitMetadata umd = { + .u_posonlyargcount = 1, + }; + RETURN_IF_ERROR( + codegen_enter_scope(c, name, COMPILE_SCOPE_ANNOTATIONS, + key, loc.lineno, NULL, &umd)); + + RETURN_IF_ERROR_IN_SCOPE(c, codegen_emit_annotations_prologue(c, loc)); + return SUCCESS; +} + static int codegen_rename_annotations_format_param(PyCodeObject *co) { @@ -768,10 +783,11 @@ codegen_rename_annotations_format_param(PyCodeObject *co) } static int -codegen_leave_annotations_scope(compiler *c, location loc) +codegen_finish_annotations_scope(compiler *c, location loc) { ADDOP_IN_SCOPE(c, loc, RETURN_VALUE); PyCodeObject *co = _PyCompile_OptimizeAndAssemble(c, 1); + _PyCompile_ExitScope(c); if (co == NULL) { return ERROR; } @@ -781,7 +797,6 @@ codegen_leave_annotations_scope(compiler *c, location loc) return ERROR; } - _PyCompile_ExitScope(c); int ret = codegen_make_closure(c, loc, co, 0); Py_DECREF(co); RETURN_IF_ERROR(ret); @@ -884,7 +899,7 @@ codegen_process_deferred_annotations(compiler *c, location loc) Py_DECREF(deferred_anno); Py_DECREF(conditional_annotation_indices); - RETURN_IF_ERROR(codegen_leave_annotations_scope(c, loc)); + RETURN_IF_ERROR(codegen_finish_annotations_scope(c, loc)); RETURN_IF_ERROR(codegen_nameop( c, loc, ste->ste_type == ClassBlock ? &_Py_ID(__annotate_func__) : &_Py_ID(__annotate__), @@ -1189,8 +1204,8 @@ codegen_function_annotations(compiler *c, location loc, RETURN_IF_ERROR_IN_SCOPE( c, codegen_annotations_in_scope(c, loc, args, returns, &annotations_len) ); - ADDOP_I(c, loc, BUILD_MAP, annotations_len); - RETURN_IF_ERROR(codegen_leave_annotations_scope(c, loc)); + ADDOP_I_IN_SCOPE(c, loc, BUILD_MAP, annotations_len); + RETURN_IF_ERROR(codegen_finish_annotations_scope(c, loc)); return MAKE_FUNCTION_ANNOTATE; } else { @@ -1379,6 +1394,44 @@ codegen_type_params(compiler *c, asdl_type_param_seq *type_params) return SUCCESS; } +static int +codegen_emit_function_body(compiler *c, asdl_stmt_seq *body) +{ + PySTEntryObject *ste = SYMTABLE_ENTRY(c); + Py_ssize_t first_instr = 0; + if (ste->ste_has_docstring) { + PyObject *docstring = _PyAST_GetDocString(body); + assert(docstring); + first_instr = 1; + docstring = _PyCompile_CleanDoc(docstring); + if (docstring == NULL) { + return ERROR; + } + Py_ssize_t idx = _PyCompile_AddConst(c, docstring); + Py_DECREF(docstring); + RETURN_IF_ERROR(idx < 0 ? ERROR : SUCCESS); + } + + NEW_JUMP_TARGET_LABEL(c, start); + USE_LABEL(c, start); + bool add_stopiteration_handler = ste->ste_coroutine || ste->ste_generator; + if (add_stopiteration_handler) { + /* codegen_wrap_in_stopiteration_handler will push a block, so we need to account for that */ + RETURN_IF_ERROR( + _PyCompile_PushFBlock(c, NO_LOCATION, COMPILE_FBLOCK_STOP_ITERATION, + start, NO_LABEL, NULL)); + } + + for (Py_ssize_t i = first_instr; i < asdl_seq_LEN(body); i++) { + VISIT(c, stmt, (stmt_ty)asdl_seq_GET(body, i)); + } + if (add_stopiteration_handler) { + RETURN_IF_ERROR(codegen_wrap_in_stopiteration_handler(c)); + _PyCompile_PopFBlock(c, COMPILE_FBLOCK_STOP_ITERATION, start); + } + return SUCCESS; +} + static int codegen_function_body(compiler *c, stmt_ty s, int is_async, Py_ssize_t funcflags, int firstlineno) @@ -1414,39 +1467,8 @@ codegen_function_body(compiler *c, stmt_ty s, int is_async, Py_ssize_t funcflags RETURN_IF_ERROR( codegen_enter_scope(c, name, scope_type, (void *)s, firstlineno, NULL, &umd)); - PySTEntryObject *ste = SYMTABLE_ENTRY(c); - Py_ssize_t first_instr = 0; - if (ste->ste_has_docstring) { - PyObject *docstring = _PyAST_GetDocString(body); - assert(docstring); - first_instr = 1; - docstring = _PyCompile_CleanDoc(docstring); - if (docstring == NULL) { - _PyCompile_ExitScope(c); - return ERROR; - } - Py_ssize_t idx = _PyCompile_AddConst(c, docstring); - Py_DECREF(docstring); - RETURN_IF_ERROR_IN_SCOPE(c, idx < 0 ? ERROR : SUCCESS); - } + RETURN_IF_ERROR_IN_SCOPE(c, codegen_emit_function_body(c, body)); - NEW_JUMP_TARGET_LABEL(c, start); - USE_LABEL(c, start); - bool add_stopiteration_handler = ste->ste_coroutine || ste->ste_generator; - if (add_stopiteration_handler) { - /* codegen_wrap_in_stopiteration_handler will push a block, so we need to account for that */ - RETURN_IF_ERROR( - _PyCompile_PushFBlock(c, NO_LOCATION, COMPILE_FBLOCK_STOP_ITERATION, - start, NO_LABEL, NULL)); - } - - for (Py_ssize_t i = first_instr; i < asdl_seq_LEN(body); i++) { - VISIT_IN_SCOPE(c, stmt, (stmt_ty)asdl_seq_GET(body, i)); - } - if (add_stopiteration_handler) { - RETURN_IF_ERROR_IN_SCOPE(c, codegen_wrap_in_stopiteration_handler(c)); - _PyCompile_PopFBlock(c, COMPILE_FBLOCK_STOP_ITERATION, start); - } PyCodeObject *co = _PyCompile_OptimizeAndAssemble(c, 1); _PyCompile_ExitScope(c); if (co == NULL) { @@ -1606,16 +1628,16 @@ codegen_class_body(compiler *c, stmt_ty s, int firstlineno) RETURN_IF_ERROR_IN_SCOPE(c, codegen_nameop(c, loc, &_Py_ID(__name__), Load)); /* ... and store it as __module__ */ RETURN_IF_ERROR_IN_SCOPE(c, codegen_nameop(c, loc, &_Py_ID(__module__), Store)); - ADDOP_LOAD_CONST(c, loc, QUALNAME(c)); + ADDOP_LOAD_CONST_IN_SCOPE(c, loc, QUALNAME(c)); RETURN_IF_ERROR_IN_SCOPE(c, codegen_nameop(c, loc, &_Py_ID(__qualname__), Store)); - ADDOP_LOAD_CONST_NEW(c, loc, PyLong_FromLong(METADATA(c)->u_firstlineno)); + ADDOP_LOAD_CONST_NEW_IN_SCOPE(c, loc, PyLong_FromLong(METADATA(c)->u_firstlineno)); RETURN_IF_ERROR_IN_SCOPE(c, codegen_nameop(c, loc, &_Py_ID(__firstlineno__), Store)); asdl_type_param_seq *type_params = s->v.ClassDef.type_params; if (asdl_seq_LEN(type_params) > 0) { RETURN_IF_ERROR_IN_SCOPE(c, codegen_set_type_params_in_class(c, loc)); } if (SYMTABLE_ENTRY(c)->ste_needs_classdict) { - ADDOP(c, loc, LOAD_LOCALS); + ADDOP_IN_SCOPE(c, loc, LOAD_LOCALS); // We can't use codegen_nameop here because we need to generate a // STORE_DEREF in a class namespace, and codegen_nameop() won't do @@ -1623,18 +1645,12 @@ codegen_class_body(compiler *c, stmt_ty s, int firstlineno) ADDOP_N_IN_SCOPE(c, loc, STORE_DEREF, &_Py_ID(__classdict__), cellvars); } if (SYMTABLE_ENTRY(c)->ste_has_conditional_annotations) { - ADDOP_I(c, loc, BUILD_SET, 0); + ADDOP_I_IN_SCOPE(c, loc, BUILD_SET, 0); ADDOP_N_IN_SCOPE(c, loc, STORE_DEREF, &_Py_ID(__conditional_annotations__), cellvars); } /* compile the body proper */ RETURN_IF_ERROR_IN_SCOPE(c, codegen_body(c, loc, s->v.ClassDef.body, false)); - PyObject *static_attributes = _PyCompile_StaticAttributesAsTuple(c); - if (static_attributes == NULL) { - _PyCompile_ExitScope(c); - return ERROR; - } - ADDOP_LOAD_CONST(c, NO_LOCATION, static_attributes); - Py_CLEAR(static_attributes); + ADDOP_LOAD_CONST_NEW_IN_SCOPE(c, NO_LOCATION, _PyCompile_StaticAttributesAsTuple(c)); RETURN_IF_ERROR_IN_SCOPE( c, codegen_nameop(c, NO_LOCATION, &_Py_ID(__static_attributes__), Store)); /* The following code is artificial */ @@ -1643,7 +1659,7 @@ codegen_class_body(compiler *c, stmt_ty s, int firstlineno) /* Store __classdictcell__ into class namespace */ int i = _PyCompile_LookupCellvar(c, &_Py_ID(__classdict__)); RETURN_IF_ERROR_IN_SCOPE(c, i); - ADDOP_I(c, NO_LOCATION, LOAD_CLOSURE, i); + ADDOP_I_IN_SCOPE(c, NO_LOCATION, LOAD_CLOSURE, i); RETURN_IF_ERROR_IN_SCOPE( c, codegen_nameop(c, NO_LOCATION, &_Py_ID(__classdictcell__), Store)); } @@ -1652,14 +1668,14 @@ codegen_class_body(compiler *c, stmt_ty s, int firstlineno) /* Store __classcell__ into class namespace & return it */ int i = _PyCompile_LookupCellvar(c, &_Py_ID(__class__)); RETURN_IF_ERROR_IN_SCOPE(c, i); - ADDOP_I(c, NO_LOCATION, LOAD_CLOSURE, i); - ADDOP_I(c, NO_LOCATION, COPY, 1); + ADDOP_I_IN_SCOPE(c, NO_LOCATION, LOAD_CLOSURE, i); + ADDOP_I_IN_SCOPE(c, NO_LOCATION, COPY, 1); RETURN_IF_ERROR_IN_SCOPE( c, codegen_nameop(c, NO_LOCATION, &_Py_ID(__classcell__), Store)); } else { /* No methods referenced __class__, so just return None */ - ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None); + ADDOP_LOAD_CONST_IN_SCOPE(c, NO_LOCATION, Py_None); } ADDOP_IN_SCOPE(c, NO_LOCATION, RETURN_VALUE); /* create the code object */ @@ -2207,8 +2223,6 @@ codegen_async_for(compiler *c, stmt_ty s) /* SETUP_FINALLY to guard the __anext__ call */ ADDOP_JUMP(c, loc, SETUP_FINALLY, except); ADDOP(c, loc, GET_ANEXT); - ADDOP(c, loc, PUSH_NULL); - ADDOP_LOAD_CONST(c, loc, Py_None); USE_LABEL(c, send); ADD_YIELD_FROM(c, loc, 1); ADDOP(c, loc, POP_BLOCK); /* for SETUP_FINALLY */ @@ -3309,27 +3323,20 @@ codegen_nameop(compiler *c, location loc, return ERROR; } - int scope = _PyST_GetScope(SYMTABLE_ENTRY(c), mangled); - if (scope == -1) { - goto error; - } - _PyCompile_optype optype; Py_ssize_t arg = 0; - if (_PyCompile_ResolveNameop(c, mangled, scope, &optype, &arg) < 0) { + int scope = _PyCompile_ResolveNameop(c, mangled, &optype, &arg); + if (scope < 0) { Py_DECREF(mangled); return ERROR; } - /* XXX Leave assert here, but handle __doc__ and the like better */ - assert(scope || PyUnicode_READ_CHAR(name, 0) == '_'); - int op = 0; switch (optype) { case COMPILE_OP_DEREF: switch (ctx) { case Load: - if (SYMTABLE_ENTRY(c)->ste_type == ClassBlock && !_PyCompile_IsInInlinedComp(c)) { + if (SYMTABLE_ENTRY(c)->ste_type == ClassBlock) { op = LOAD_FROM_DICT_OR_DEREF; // First load the locals if (codegen_addop_noarg(INSTR_SEQUENCE(c), LOAD_LOCALS, loc) < 0) { @@ -3382,8 +3389,9 @@ codegen_nameop(compiler *c, location loc, case COMPILE_OP_NAME: switch (ctx) { case Load: - op = (SYMTABLE_ENTRY(c)->ste_type == ClassBlock - && _PyCompile_IsInInlinedComp(c)) + /* LOAD_NAME in a class reads the class dict; inlined comps must not. */ + op = (SCOPE_TYPE(c) == COMPILE_SCOPE_CLASS + && SYMTABLE_ENTRY(c)->ste_type == InlinedComprehensionBlock) ? LOAD_GLOBAL : LOAD_NAME; break; @@ -3437,24 +3445,46 @@ codegen_boolop(compiler *c, expr_ty e) return SUCCESS; } +static bool +is_empty_starred_literal(expr_ty elt) +{ + if (elt->kind != Starred_kind) { + return false; + } + expr_ty value = elt->v.Starred.value; + return (value->kind == Tuple_kind && + asdl_seq_LEN(value->v.Tuple.elts) == 0) || + (value->kind == List_kind && + asdl_seq_LEN(value->v.List.elts) == 0) || + (value->kind == Dict_kind && + asdl_seq_LEN(value->v.Dict.keys) == 0); +} + static int starunpack_helper_impl(compiler *c, location loc, asdl_expr_seq *elts, PyObject *injected_arg, int pushed, int build, int add, int extend, int tuple) { - Py_ssize_t n = asdl_seq_LEN(elts); - int big = n + pushed + (injected_arg ? 1 : 0) > _PY_STACK_USE_GUIDELINE; + Py_ssize_t end = asdl_seq_LEN(elts); + Py_ssize_t n = 0; int seen_star = 0; - for (Py_ssize_t i = 0; i < n; i++) { + for (Py_ssize_t i = 0; i < end; i++) { expr_ty elt = asdl_seq_GET(elts, i); if (elt->kind == Starred_kind) { + if (is_empty_starred_literal(elt)) { + continue; + } seen_star = 1; - break; } + n++; } + int big = n + pushed + (injected_arg ? 1 : 0) > _PY_STACK_USE_GUIDELINE; if (!seen_star && !big) { - for (Py_ssize_t i = 0; i < n; i++) { + for (Py_ssize_t i = 0; i < end; i++) { expr_ty elt = asdl_seq_GET(elts, i); + if (is_empty_starred_literal(elt)) { + continue; + } VISIT(c, expr, elt); } if (injected_arg) { @@ -3469,15 +3499,20 @@ starunpack_helper_impl(compiler *c, location loc, return SUCCESS; } int sequence_built = 0; + Py_ssize_t nitems = 0; if (big) { ADDOP_I(c, loc, build, pushed); sequence_built = 1; } - for (Py_ssize_t i = 0; i < n; i++) { + for (Py_ssize_t i = 0; i < end; i++) { expr_ty elt = asdl_seq_GET(elts, i); + if (elt->kind == Starred_kind) { + if (is_empty_starred_literal(elt)) { + continue; + } if (sequence_built == 0) { - ADDOP_I(c, loc, build, i+pushed); + ADDOP_I(c, loc, build, nitems+pushed); sequence_built = 1; } VISIT(c, expr, elt->v.Starred.value); @@ -3489,6 +3524,7 @@ starunpack_helper_impl(compiler *c, location loc, ADDOP_I(c, loc, add, 1); } } + nitems++; } assert(sequence_built); if (injected_arg) { @@ -4134,7 +4170,7 @@ maybe_optimize_method_call(compiler *c, expr_ty e) /* Check that there aren't too many arguments */ argsl = asdl_seq_LEN(args); kwdsl = asdl_seq_LEN(kwds); - if (argsl + kwdsl + (kwdsl != 0) >= _PY_STACK_USE_GUIDELINE) { + if (CALL_STACK_USE(argsl, kwdsl) >= _PY_STACK_USE_GUIDELINE) { return 0; } /* Check that there are no *varargs types of arguments. */ @@ -4427,7 +4463,7 @@ codegen_call_helper_impl(compiler *c, location loc, nelts = asdl_seq_LEN(args); nkwelts = asdl_seq_LEN(keywords); - if (nelts + nkwelts*2 > _PY_STACK_USE_GUIDELINE) { + if (CALL_STACK_USE(nelts, nkwelts) > _PY_STACK_USE_GUIDELINE) { goto ex_call; } for (i = 0; i < nelts; i++) { @@ -4586,6 +4622,78 @@ codegen_unpack_starred(compiler *c, location loc, expr_ty value, bool yield) return SUCCESS; } +static int +codegen_comprehension_generator_helper(compiler *c, location elt_loc, int depth, + expr_ty elt, expr_ty val, int type, + bool avoid_creation) +{ + switch (type) { + case COMP_GENEXP: + assert(!avoid_creation); + if (elt->kind == Starred_kind) { + RETURN_IF_ERROR(codegen_unpack_starred(c, elt_loc, elt->v.Starred.value, /*yield=*/true)); + } + else { + VISIT(c, expr, elt); + ADDOP_YIELD(c, elt_loc); + ADDOP(c, elt_loc, POP_TOP); + } + break; + case COMP_LISTCOMP: + if (avoid_creation) { + if (elt->kind == Starred_kind) { + RETURN_IF_ERROR(codegen_unpack_starred(c, elt_loc, elt->v.Starred.value, /*yield=*/false)); + } else { + VISIT(c, expr, elt); + ADDOP(c, elt_loc, POP_TOP); + } + break; + } + if (elt->kind == Starred_kind) { + VISIT(c, expr, elt->v.Starred.value); + ADDOP_I(c, elt_loc, LIST_EXTEND, depth + 1); + } + else { + VISIT(c, expr, elt); + ADDOP_I(c, elt_loc, LIST_APPEND, depth + 1); + } + break; + case COMP_SETCOMP: + assert(!avoid_creation); + if (elt->kind == Starred_kind) { + VISIT(c, expr, elt->v.Starred.value); + ADDOP_I(c, elt_loc, SET_UPDATE, depth + 1); + } + else { + VISIT(c, expr, elt); + ADDOP_I(c, elt_loc, SET_ADD, depth + 1); + } + break; + case COMP_DICTCOMP: + assert(!avoid_creation); + if (val == NULL) { + /* unpacking (**) case */ + VISIT(c, expr, elt); + ADDOP_I(c, elt_loc, DICT_UPDATE, depth + 1); + } + else { + /* With '{k: v}', k is evaluated before v, so we do + the same. */ + VISIT(c, expr, elt); + VISIT(c, expr, val); + elt_loc = LOCATION(elt->lineno, + val->end_lineno, + elt->col_offset, + val->end_col_offset); + ADDOP_I(c, elt_loc, MAP_ADD, depth + 1); + } + break; + default: + return ERROR; + } + return SUCCESS; +} + static int codegen_sync_comprehension_generator(compiler *c, location loc, asdl_comprehension_seq *generators, @@ -4667,67 +4775,14 @@ codegen_sync_comprehension_generator(compiler *c, location loc, /* only append after the last for generator */ if (gen_index >= asdl_seq_LEN(generators)) { /* comprehension specific code */ - switch (type) { - case COMP_GENEXP: - assert(!avoid_creation); - if (elt->kind == Starred_kind) { - RETURN_IF_ERROR(codegen_unpack_starred(c, elt_loc, elt->v.Starred.value, /*yield=*/true)); - } - else { - VISIT(c, expr, elt); - ADDOP_YIELD(c, elt_loc); - ADDOP(c, elt_loc, POP_TOP); - } - break; - case COMP_LISTCOMP: - if (avoid_creation) { - if (elt->kind == Starred_kind) { - RETURN_IF_ERROR(codegen_unpack_starred(c, elt_loc, elt->v.Starred.value, /*yield=*/false)); - } else { - VISIT(c, expr, elt); - ADDOP(c, elt_loc, POP_TOP); - } - break; - } - if (elt->kind == Starred_kind) { - VISIT(c, expr, elt->v.Starred.value); - ADDOP_I(c, elt_loc, LIST_EXTEND, depth + 1); - } - else { - VISIT(c, expr, elt); - ADDOP_I(c, elt_loc, LIST_APPEND, depth + 1); - } - break; - case COMP_SETCOMP: - if (elt->kind == Starred_kind) { - VISIT(c, expr, elt->v.Starred.value); - ADDOP_I(c, elt_loc, SET_UPDATE, depth + 1); - } - else { - VISIT(c, expr, elt); - ADDOP_I(c, elt_loc, SET_ADD, depth + 1); - } - break; - case COMP_DICTCOMP: - if (val == NULL) { - /* unpacking (**) case */ - VISIT(c, expr, elt); - ADDOP_I(c, elt_loc, DICT_UPDATE, depth+1); - } - else { - /* With '{k: v}', k is evaluated before v, so we do - the same. */ - VISIT(c, expr, elt); - VISIT(c, expr, val); - elt_loc = LOCATION(elt->lineno, - val->end_lineno, - elt->col_offset, - val->end_col_offset); - ADDOP_I(c, elt_loc, MAP_ADD, depth + 1); - } - break; - default: - return ERROR; + RETURN_IF_ERROR(codegen_comprehension_generator_helper(c, elt_loc, depth, + elt, val, type, + avoid_creation)); + if (type == COMP_DICTCOMP && val != NULL) { + elt_loc = LOCATION(elt->lineno, + val->end_lineno, + elt->col_offset, + val->end_col_offset); } } @@ -4784,8 +4839,6 @@ codegen_async_comprehension_generator(compiler *c, location loc, ADDOP_JUMP(c, loc, SETUP_FINALLY, except); ADDOP(c, loc, GET_ANEXT); - ADDOP(c, loc, PUSH_NULL); - ADDOP_LOAD_CONST(c, loc, Py_None); USE_LABEL(c, send); ADD_YIELD_FROM(c, loc, 1); ADDOP(c, loc, POP_BLOCK); @@ -4809,81 +4862,14 @@ codegen_async_comprehension_generator(compiler *c, location loc, /* only append after the last for generator */ if (gen_index >= asdl_seq_LEN(generators)) { /* comprehension specific code */ - switch (type) { - case COMP_GENEXP: - assert(!avoid_creation); - if (elt->kind == Starred_kind) { - NEW_JUMP_TARGET_LABEL(c, unpack_start); - NEW_JUMP_TARGET_LABEL(c, unpack_end); - VISIT(c, expr, elt->v.Starred.value); - ADDOP_I(c, elt_loc, GET_ITER, 0); - USE_LABEL(c, unpack_start); - ADDOP_JUMP(c, elt_loc, FOR_ITER, unpack_end); - ADDOP_YIELD(c, elt_loc); - ADDOP(c, elt_loc, POP_TOP); - ADDOP_JUMP(c, NO_LOCATION, JUMP, unpack_start); - USE_LABEL(c, unpack_end); - ADDOP(c, NO_LOCATION, END_FOR); - ADDOP(c, NO_LOCATION, POP_ITER); - } - else { - VISIT(c, expr, elt); - ADDOP_YIELD(c, elt_loc); - ADDOP(c, elt_loc, POP_TOP); - } - break; - case COMP_LISTCOMP: - if (avoid_creation) { - if (elt->kind == Starred_kind) { - RETURN_IF_ERROR(codegen_unpack_starred(c, elt_loc, elt->v.Starred.value, /*yield=*/false)); - } else { - VISIT(c, expr, elt); - ADDOP(c, elt_loc, POP_TOP); - } - break; - } - - if (elt->kind == Starred_kind) { - VISIT(c, expr, elt->v.Starred.value); - ADDOP_I(c, elt_loc, LIST_EXTEND, depth + 1); - } - else { - VISIT(c, expr, elt); - ADDOP_I(c, elt_loc, LIST_APPEND, depth + 1); - } - break; - case COMP_SETCOMP: - assert(!avoid_creation); - if (elt->kind == Starred_kind) { - VISIT(c, expr, elt->v.Starred.value); - ADDOP_I(c, elt_loc, SET_UPDATE, depth + 1); - } - else { - VISIT(c, expr, elt); - ADDOP_I(c, elt_loc, SET_ADD, depth + 1); - } - break; - case COMP_DICTCOMP: - assert(!avoid_creation); - if (val == NULL) { - /* unpacking (**) case */ - VISIT(c, expr, elt); - ADDOP_I(c, elt_loc, DICT_UPDATE, depth+1); - } - else { - /* With '{k: v}', k is evaluated before v, so we do - the same. */ - VISIT(c, expr, elt); - VISIT(c, expr, val); - elt_loc = LOCATION(elt->lineno, - val->end_lineno, - elt->col_offset, - val->end_col_offset); - ADDOP_I(c, elt_loc, MAP_ADD, depth + 1); - } - break; - default: - return ERROR; + RETURN_IF_ERROR(codegen_comprehension_generator_helper(c, elt_loc, depth, + elt, val, type, + avoid_creation)); + if (type == COMP_DICTCOMP && val != NULL) { + elt_loc = LOCATION(elt->lineno, + val->end_lineno, + elt->col_offset, + val->end_col_offset); } } @@ -4904,9 +4890,6 @@ codegen_push_inlined_comprehension_locals(compiler *c, location loc, PySTEntryObject *comp, _PyCompile_InlinedComprehensionState *state) { - int in_class_block = (SYMTABLE_ENTRY(c)->ste_type == ClassBlock) && - !_PyCompile_IsInInlinedComp(c); - PySTEntryObject *outer = SYMTABLE_ENTRY(c); // iterate over names bound in the comprehension and ensure we isolate // them from the outer scope as needed PyObject *k, *v; @@ -4917,11 +4900,7 @@ codegen_push_inlined_comprehension_locals(compiler *c, location loc, RETURN_IF_ERROR(symbol); long scope = SYMBOL_TO_SCOPE(symbol); - long outsymbol = _PyST_GetSymbol(outer, k); - RETURN_IF_ERROR(outsymbol); - long outsc = SYMBOL_TO_SCOPE(outsymbol); - - if ((symbol & DEF_LOCAL && !(symbol & DEF_NONLOCAL)) || in_class_block) { + if ((symbol & DEF_LOCAL) && !(symbol & DEF_NONLOCAL)) { // local names bound in comprehension must be isolated from // outer scope; push existing value (which may be NULL if // not defined) on stack @@ -4936,15 +4915,17 @@ codegen_push_inlined_comprehension_locals(compiler *c, location loc, // comprehension and restore the original one after ADDOP_NAME(c, loc, LOAD_FAST_AND_CLEAR, k, varnames); if (scope == CELL) { - if (outsc == FREE) { - ADDOP_NAME(c, loc, MAKE_CELL, k, freevars); - } else { - ADDOP_NAME(c, loc, MAKE_CELL, k, cellvars); - } + ADDOP_NAME(c, loc, MAKE_CELL, k, cellvars); } if (PyList_Append(state->pushed_locals, k) < 0) { return ERROR; } + if (METADATA(c)->u_fasthidden != NULL) { + /* For Module/Class scopes, assemble needs to set CO_FAST_HIDDEN on these names */ + if (PySet_Add(METADATA(c)->u_fasthidden, k) < 0) { + return ERROR; + } + } } } if (state->pushed_locals) { @@ -4960,8 +4941,11 @@ codegen_push_inlined_comprehension_locals(compiler *c, location loc, NEW_JUMP_TARGET_LABEL(c, cleanup); state->cleanup = cleanup; - // no need to push an fblock for this "virtual" try/finally; there can't - // be return/continue/break inside a comprehension + // Count against CO_MAXBLOCKS: SETUP_FINALLY consumes an except-stack + // slot even though return/continue/break cannot appear here. + RETURN_IF_ERROR(_PyCompile_PushFBlock( + c, loc, COMPILE_FBLOCK_INLINED_COMPREHENSION, + cleanup, NO_LABEL, NULL)); ADDOP_JUMP(c, loc, SETUP_FINALLY, cleanup); } return SUCCESS; @@ -4973,9 +4957,11 @@ push_inlined_comprehension_state(compiler *c, location loc, _PyCompile_InlinedComprehensionState *state) { RETURN_IF_ERROR( - _PyCompile_TweakInlinedComprehensionScopes(c, loc, comp, state)); - RETURN_IF_ERROR( - codegen_push_inlined_comprehension_locals(c, loc, comp, state)); + _PyCompile_EnterInlinedComprehensionScope(c, comp, state)); + if (codegen_push_inlined_comprehension_locals(c, loc, comp, state) < 0){ + _PyCompile_ExitInlinedComprehensionScope(c, state); + return ERROR; + } return SUCCESS; } @@ -5007,6 +4993,8 @@ codegen_pop_inlined_comprehension_locals(compiler *c, location loc, { if (state->pushed_locals) { ADDOP(c, NO_LOCATION, POP_BLOCK); + _PyCompile_PopFBlock(c, COMPILE_FBLOCK_INLINED_COMPREHENSION, + state->cleanup); NEW_JUMP_TARGET_LABEL(c, end); ADDOP_JUMP(c, NO_LOCATION, JUMP_NO_INTERRUPT, end); @@ -5030,8 +5018,40 @@ static int pop_inlined_comprehension_state(compiler *c, location loc, _PyCompile_InlinedComprehensionState *state) { - RETURN_IF_ERROR(codegen_pop_inlined_comprehension_locals(c, loc, state)); - RETURN_IF_ERROR(_PyCompile_RevertInlinedComprehensionScopes(c, loc, state)); + int result = codegen_pop_inlined_comprehension_locals(c, loc, state); + RETURN_IF_ERROR(_PyCompile_ExitInlinedComprehensionScope(c, state)); + return result; +} + +static int +codegen_comprehension_init_container(compiler *c, location loc, int type, + int is_inlined, bool avoid_creation) +{ + int op; + switch (type) { + case COMP_LISTCOMP: + op = BUILD_LIST; + break; + case COMP_SETCOMP: + op = BUILD_SET; + break; + case COMP_DICTCOMP: + op = BUILD_MAP; + break; + default: + PyErr_Format(PyExc_SystemError, + "unknown comprehension type %d", type); + return ERROR; + } + + if (!avoid_creation) { + ADDOP_I(c, loc, op, 0); + if (is_inlined) { + ADDOP_I(c, loc, SWAP, 2); + } + } else { + ADDOP_I(c, loc, COPY, 1); + } return SUCCESS; } @@ -5041,13 +5061,13 @@ codegen_comprehension(compiler *c, expr_ty e, int type, expr_ty val, bool avoid_creation) { PyCodeObject *co = NULL; - _PyCompile_InlinedComprehensionState inline_state = {NULL, NULL, NULL, NO_LABEL}; + _PyCompile_InlinedComprehensionState inline_state = {NULL, NO_LABEL, NULL}; comprehension_ty outermost; PySTEntryObject *entry = _PySymtable_Lookup(SYMTABLE(c), (void *)e); if (entry == NULL) { goto error; } - int is_inlined = entry->ste_comp_inlined; + int is_inlined = (entry->ste_type == InlinedComprehensionBlock); int is_async_comprehension = entry->ste_coroutine; location loc = LOC(e); @@ -5056,7 +5076,7 @@ codegen_comprehension(compiler *c, expr_ty e, int type, IterStackPosition iter_state; if (is_inlined) { VISIT(c, expr, outermost->iter); - if (push_inlined_comprehension_state(c, loc, entry, &inline_state)) { + if (push_inlined_comprehension_state(c, loc, entry, &inline_state) < 0) { goto error; } iter_state = ITERABLE_ON_STACK; @@ -5073,19 +5093,22 @@ codegen_comprehension(compiler *c, expr_ty e, int type, if (type == COMP_GENEXP) { /* Insert GET_ITER before RETURN_GENERATOR. https://docs.python.org/3/reference/expressions.html#generator-expressions */ - RETURN_IF_ERROR( - _PyInstructionSequence_InsertInstruction( + if(_PyInstructionSequence_InsertInstruction( INSTR_SEQUENCE(c), 0, - RESUME, RESUME_AT_GEN_EXPR_START, NO_LOCATION)); - RETURN_IF_ERROR( - _PyInstructionSequence_InsertInstruction( + RESUME, RESUME_AT_GEN_EXPR_START, NO_LOCATION) < 0) { + goto error_in_scope; + } + if(_PyInstructionSequence_InsertInstruction( INSTR_SEQUENCE(c), 1, - LOAD_FAST, 0, LOC(outermost->iter))); - RETURN_IF_ERROR( - _PyInstructionSequence_InsertInstruction( + LOAD_FAST, 0, LOC(outermost->iter)) < 0) { + goto error_in_scope; + } + if(_PyInstructionSequence_InsertInstruction( INSTR_SEQUENCE(c), 2, outermost->is_async ? GET_AITER : GET_ITER, - 0, LOC(outermost->iter))); + 0, LOC(outermost->iter)) < 0) { + goto error_in_scope; + } iter_state = ITERATOR_ON_STACK; } else { @@ -5095,31 +5118,10 @@ codegen_comprehension(compiler *c, expr_ty e, int type, Py_CLEAR(entry); if (type != COMP_GENEXP) { - int op; - switch (type) { - case COMP_LISTCOMP: - op = BUILD_LIST; - break; - case COMP_SETCOMP: - op = BUILD_SET; - break; - case COMP_DICTCOMP: - op = BUILD_MAP; - break; - default: - PyErr_Format(PyExc_SystemError, - "unknown comprehension type %d", type); + if (codegen_comprehension_init_container( + c, loc, type, is_inlined, avoid_creation) < 0) { goto error_in_scope; } - - if (!avoid_creation) { - ADDOP_I(c, loc, op, 0); - if (is_inlined) { - ADDOP_I(c, loc, SWAP, 2); - } - } else { - ADDOP_I(c, loc, COPY, 1); - } } if (codegen_comprehension_generator(c, loc, generators, 0, 0, elt, val, type, iter_state, avoid_creation) < 0) { @@ -5127,14 +5129,14 @@ codegen_comprehension(compiler *c, expr_ty e, int type, } if (is_inlined) { - if (pop_inlined_comprehension_state(c, loc, &inline_state)) { - goto error; + if (pop_inlined_comprehension_state(c, loc, &inline_state) < 0) { + goto error_in_scope; } return SUCCESS; } if (type != COMP_GENEXP) { - ADDOP(c, LOC(e), RETURN_VALUE); + ADDOP_IN_SCOPE(c, LOC(e), RETURN_VALUE); } if (type == COMP_GENEXP) { if (codegen_wrap_in_stopiteration_handler(c) < 0) { @@ -5159,8 +5161,6 @@ codegen_comprehension(compiler *c, expr_ty e, int type, if (is_async_comprehension && type != COMP_GENEXP) { ADDOP_I(c, loc, GET_AWAITABLE, 0); - ADDOP(c, loc, PUSH_NULL); - ADDOP_LOAD_CONST(c, loc, Py_None); ADD_YIELD_FROM(c, loc, 1); } @@ -5168,15 +5168,18 @@ codegen_comprehension(compiler *c, expr_ty e, int type, return SUCCESS; error_in_scope: - if (!is_inlined) { + if (is_inlined) { + if (inline_state.saved_ste != NULL) { + _PyCompile_ExitInlinedComprehensionScope(c, &inline_state); + } + } + else { _PyCompile_ExitScope(c); } error: Py_XDECREF(co); Py_XDECREF(entry); Py_XDECREF(inline_state.pushed_locals); - Py_XDECREF(inline_state.temp_symbols); - Py_XDECREF(inline_state.fast_hidden); return ERROR; } @@ -5301,8 +5304,6 @@ codegen_async_with_inner(compiler *c, stmt_ty s, int pos) ADDOP_I(c, loc, LOAD_SPECIAL, SPECIAL___AENTER__); ADDOP_I(c, loc, CALL, 0); ADDOP_I(c, loc, GET_AWAITABLE, 1); - ADDOP(c, loc, PUSH_NULL); - ADDOP_LOAD_CONST(c, loc, Py_None); ADD_YIELD_FROM(c, loc, 1); ADDOP_JUMP(c, loc, SETUP_WITH, final); @@ -5338,8 +5339,6 @@ codegen_async_with_inner(compiler *c, stmt_ty s, int pos) */ RETURN_IF_ERROR(codegen_call_exit_with_nones(c, loc)); ADDOP_I(c, loc, GET_AWAITABLE, 2); - ADDOP(c, loc, PUSH_NULL); - ADDOP_LOAD_CONST(c, loc, Py_None); ADD_YIELD_FROM(c, loc, 1); ADDOP(c, loc, POP_TOP); @@ -5353,8 +5352,6 @@ codegen_async_with_inner(compiler *c, stmt_ty s, int pos) ADDOP(c, loc, PUSH_EXC_INFO); ADDOP(c, loc, WITH_EXCEPT_START); ADDOP_I(c, loc, GET_AWAITABLE, 2); - ADDOP(c, loc, PUSH_NULL); - ADDOP_LOAD_CONST(c, loc, Py_None); ADD_YIELD_FROM(c, loc, 1); RETURN_IF_ERROR(codegen_with_except_finish(c, cleanup)); @@ -5541,8 +5538,6 @@ codegen_visit_expr_impl(compiler *c, expr_ty e, bool result_is_unused) case Await_kind: VISIT(c, expr, e->v.Await.value); ADDOP_I(c, loc, GET_AWAITABLE, 0); - ADDOP(c, loc, PUSH_NULL); - ADDOP_LOAD_CONST(c, loc, Py_None); ADD_YIELD_FROM(c, loc, 1); break; case Compare_kind: @@ -5807,7 +5802,9 @@ codegen_annassign(compiler *c, stmt_ty s) ADDOP_NAME(c, loc, LOAD_NAME, &_Py_ID(__conditional_annotations__), names); } ADDOP_LOAD_CONST_NEW(c, loc, conditional_annotation_index); - ADDOP_I(c, loc, SET_ADD, 1); + // gh-154902: change SET_ADD to new INTRINSIC_ADD_CONDITIONAL_ANNOTATION intrinsic + ADDOP_I(c, loc, CALL_INTRINSIC_2, + INTRINSIC_ADD_CONDITIONAL_ANNOTATION); ADDOP(c, loc, POP_TOP); } } @@ -6233,6 +6230,13 @@ codegen_pattern_class(compiler *c, pattern_ty p, pattern_context *pc) if (nattrs) { RETURN_IF_ERROR(validate_kwd_attrs(c, kwd_attrs, kwd_patterns)); } + if (nargs + nattrs == 0) { + // Fast path if there are no sub-patterns + VISIT(c, expr, p->v.MatchClass.cls); + ADDOP_I(c, LOC(p), CALL_INTRINSIC_2, INTRINSIC_MATCH_CLASS_ISINSTANCE); + RETURN_IF_ERROR(jump_to_fail_pop(c, LOC(p), pc, POP_JUMP_IF_FALSE)); + return SUCCESS; + } VISIT(c, expr, p->v.MatchClass.cls); PyObject *attr_names = PyTuple_New(nattrs); if (attr_names == NULL) { @@ -6412,6 +6416,8 @@ codegen_pattern_or(compiler *c, pattern_ty p, pattern_context *pc) NEW_JUMP_TARGET_LABEL(c, end); Py_ssize_t size = asdl_seq_LEN(p->v.MatchOr.patterns); assert(size > 1); + PyObject *mismatched_names = NULL; + Py_ssize_t mismatch_index = 0; // We're going to be messing with pc. Keep the original info handy: pattern_context old_pc = *pc; Py_INCREF(pc->stores); @@ -6446,6 +6452,8 @@ codegen_pattern_or(compiler *c, pattern_ty p, pattern_context *pc) control = Py_NewRef(pc->stores); } else if (nstores != PyList_GET_SIZE(control)) { + mismatch_index = i; + mismatched_names = Py_NewRef(pc->stores); goto diff; } else if (nstores) { @@ -6456,6 +6464,8 @@ codegen_pattern_or(compiler *c, pattern_ty p, pattern_context *pc) Py_ssize_t istores = PySequence_Index(pc->stores, name); if (istores < 0) { PyErr_Clear(); + mismatch_index = i; + mismatched_names = Py_NewRef(pc->stores); goto diff; } if (icontrol != istores) { @@ -6547,10 +6557,24 @@ codegen_pattern_or(compiler *c, pattern_ty p, pattern_context *pc) // Pop the copy of the subject: ADDOP(c, LOC(p), POP_TOP); return SUCCESS; -diff: - _PyCompile_Error(c, LOC(p), "alternative patterns bind different names"); +diff:; + int control_is_empty = PyList_GET_SIZE(control) == 0; + int pattern_is_empty = ( + mismatched_names == NULL + || PyList_GET_SIZE(mismatched_names) == 0 + ); + + _PyCompile_Error( + c, LOC(p), + "alternative patterns bind different names " + "(pattern 1 binds %S, pattern %zd binds %S)", + control_is_empty ? &_Py_ID(nothing) : control, + mismatch_index + 1, + pattern_is_empty ? &_Py_ID(nothing) : mismatched_names + ); error: PyMem_Free(old_pc.fail_pop); + Py_XDECREF(mismatched_names); Py_DECREF(old_pc.stores); Py_XDECREF(control); return ERROR; diff --git a/Python/compile.c b/Python/compile.c index fefb2b04b78db86..b574767a9180b1a 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -68,7 +68,6 @@ struct compiler_unit { instr_sequence *u_stashed_instr_sequence; /* temporarily stashed parent instruction sequence */ int u_nfblocks; - int u_in_inlined_comp; int u_in_conditional_block; _PyCompile_FBlockInfo u_fblock[CO_MAXBLOCKS]; @@ -233,13 +232,17 @@ _PyCompile_MaybeAddStaticAttributeToClass(compiler *c, expr_ty e) return SUCCESS; } -static int -compiler_set_qualname(compiler *c) +int +_PyCompile_SetQualname(compiler *c) { Py_ssize_t stack_size; struct compiler_unit *u = c->u; PyObject *name, *base; + if (u->u_scope_type == COMPILE_SCOPE_MODULE) { + return SUCCESS; + } + base = NULL; stack_size = PyList_GET_SIZE(c->c_stack); assert(stack_size >= 1); @@ -327,6 +330,14 @@ compiler_set_qualname(compiler *c) else { name = Py_NewRef(u->u_metadata.u_name); } + // The qualified name is interned when the code object is created, + // whatever its content. The body of a class also has it as a constant, + // and intern_final_constants() only interns the constants selected by + // _PyCode_ShouldInternString(). Intern the other qualified names now, + // so that the same object is always used for both. + if (!_PyCode_ShouldInternString(name)) { + _PyUnicode_InternMortal(_PyInterpreterState_GET(), &name); + } u->u_metadata.u_qualname = name; return SUCCESS; @@ -592,6 +603,75 @@ dictbytype(PyObject *src, int scope_type, int flag, Py_ssize_t offset) return dest; } +static int +add_cell_names_from_symbols(PyObject *symbols, PyObject *names) +{ + Py_ssize_t pos = 0; + PyObject *k, *v; + while (PyDict_Next(symbols, &pos, &k, &v)) { + long flags = PyLong_AsLong(v); + if (flags == -1 && PyErr_Occurred()) { + return ERROR; + } + if (SYMBOL_TO_SCOPE(flags) == CELL) { + if (PySet_Add(names, k) < 0) { + return ERROR; + } + } + } + return SUCCESS; +} + +static int +add_inlined_comprehension_cell_names(PySTEntryObject *ste, PyObject *names) +{ + for (Py_ssize_t i = 0; i < PyList_GET_SIZE(ste->ste_children); i++) { + PySTEntryObject *child = + (PySTEntryObject *)PyList_GET_ITEM(ste->ste_children, i); + if (child->ste_type != InlinedComprehensionBlock) { + continue; + } + if (add_cell_names_from_symbols(child->ste_symbols, names) < 0) { + return ERROR; + } + if (add_inlined_comprehension_cell_names(child, names) < 0) { + return ERROR; + } + } + return SUCCESS; +} + +/* Cells of the shared unit: this table's CELL names, plus cells that live + * only on inlined comprehension children. */ +static PyObject * +compiler_cellvars(PySTEntryObject *ste) +{ + PyObject *names = PySet_New(NULL); + if (names == NULL) { + return NULL; + } + if (add_cell_names_from_symbols(ste->ste_symbols, names) < 0) { + Py_DECREF(names); + return NULL; + } + if (add_inlined_comprehension_cell_names(ste, names) < 0) { + Py_DECREF(names); + return NULL; + } + PyObject *sorted = PySequence_List(names); + Py_DECREF(names); + if (sorted == NULL) { + return NULL; + } + if (PyList_Sort(sorted) < 0) { + Py_DECREF(sorted); + return NULL; + } + PyObject *cellvars = list2dict(sorted); + Py_DECREF(sorted); + return cellvars; +} + int _PyCompile_EnterScope(compiler *c, identifier name, int scope_type, void *key, int lineno, PyObject *private, @@ -623,7 +703,7 @@ _PyCompile_EnterScope(compiler *c, identifier name, int scope_type, compiler_unit_free(u); return ERROR; } - u->u_metadata.u_cellvars = dictbytype(u->u_ste->ste_symbols, CELL, DEF_COMP_CELL, 0); + u->u_metadata.u_cellvars = compiler_cellvars(u->u_ste); if (!u->u_metadata.u_cellvars) { compiler_unit_free(u); return ERROR; @@ -666,14 +746,18 @@ _PyCompile_EnterScope(compiler *c, identifier name, int scope_type, return ERROR; } - u->u_metadata.u_fasthidden = PyDict_New(); - if (!u->u_metadata.u_fasthidden) { - compiler_unit_free(u); - return ERROR; + if (scope_type == COMPILE_SCOPE_MODULE || scope_type == COMPILE_SCOPE_CLASS) { + u->u_metadata.u_fasthidden = PySet_New(NULL); + if (!u->u_metadata.u_fasthidden) { + compiler_unit_free(u); + return ERROR; + } + } + else { + u->u_metadata.u_fasthidden = NULL; } u->u_nfblocks = 0; - u->u_in_inlined_comp = 0; u->u_metadata.u_firstlineno = lineno; u->u_metadata.u_consts = PyDict_New(); if (!u->u_metadata.u_consts) { @@ -724,9 +808,6 @@ _PyCompile_EnterScope(compiler *c, identifier name, int scope_type, u->u_private = Py_XNewRef(private); c->u = u; - if (scope_type != COMPILE_SCOPE_MODULE) { - RETURN_IF_ERROR(compiler_set_qualname(c)); - } return SUCCESS; } @@ -906,17 +987,46 @@ compiler_mod(compiler *c, mod_ty mod) return co; } +/* Inlined comprehensions are compiled in the enclosing unit. If a name is + * FREE in the comprehension, or is absent from its table (scope 0), resolve + * it in enclosing tables until it is bound. Stop if the next table is a class: + * nested scopes (including inlined comprehensions) do not see class locals, so + * the name stays FREE. __class__ and friends are not allowed to be free + * through a class; treat those loads as implicit globals. + * + * Names with no entry (scope 0) include loads synthesized by codegen, such as + * the implicit receiver for zero-arg super(). */ +static int +compiler_resolve_inlined_free(PySTEntryObject **ste, PyObject *name) +{ + int scope = _PyST_GetScope(*ste, name); + RETURN_IF_ERROR(scope); + while ((*ste)->ste_type == InlinedComprehensionBlock && + (scope == FREE || scope == 0)) { + PySTEntryObject *parent = (*ste)->ste_parent; + assert(parent != NULL); + if (parent->ste_type == ClassBlock) { + if (_PyST_IsClassClosureName(name)) { + return GLOBAL_IMPLICIT; + } + break; + } + *ste = parent; + scope = _PyST_GetScope(*ste, name); + RETURN_IF_ERROR(scope); + } + return scope; +} + int _PyCompile_GetRefType(compiler *c, PyObject *name) { - if (c->u->u_scope_type == COMPILE_SCOPE_CLASS && - (_PyUnicode_EqualToASCIIString(name, "__class__") || - _PyUnicode_EqualToASCIIString(name, "__classdict__") || - _PyUnicode_EqualToASCIIString(name, "__conditional_annotations__"))) { + if (c->u->u_scope_type == COMPILE_SCOPE_CLASS && _PyST_IsClassClosureName(name)) { return CELL; } PySTEntryObject *ste = c->u->u_ste; - int scope = _PyST_GetScope(ste, name); + int scope = compiler_resolve_inlined_free(&ste, name); + RETURN_IF_ERROR(scope); if (scope == 0) { PyErr_Format(PyExc_SystemError, "_PyST_GetScope(name=%R) failed: " @@ -1006,13 +1116,18 @@ _PyCompile_StaticAttributesAsTuple(compiler *c) } int -_PyCompile_ResolveNameop(compiler *c, PyObject *mangled, int scope, +_PyCompile_ResolveNameop(compiler *c, PyObject *mangled, _PyCompile_optype *optype, Py_ssize_t *arg) { PyObject *dict = c->u->u_metadata.u_names; *optype = COMPILE_OP_NAME; - assert(scope >= 0); + PySTEntryObject *ste = c->u->u_ste; + assert(ste != NULL); + + int scope = compiler_resolve_inlined_free(&ste, mangled); + RETURN_IF_ERROR(scope); + switch (scope) { case FREE: dict = c->u->u_metadata.u_freevars; @@ -1023,24 +1138,24 @@ _PyCompile_ResolveNameop(compiler *c, PyObject *mangled, int scope, *optype = COMPILE_OP_DEREF; break; case LOCAL: - if (_PyST_IsFunctionLike(c->u->u_ste)) { + /* Inlined comprehensions isolate their locals as FAST, even when + * nested in class or module scope. */ + if (_PyST_IsFunctionLike(ste) || ste->ste_type == InlinedComprehensionBlock) { *optype = COMPILE_OP_FAST; } - else { - PyObject *item; - RETURN_IF_ERROR(PyDict_GetItemRef(c->u->u_metadata.u_fasthidden, mangled, - &item)); - if (item == Py_True) { - *optype = COMPILE_OP_FAST; - } - Py_XDECREF(item); - } break; - case GLOBAL_IMPLICIT: - if (_PyST_IsFunctionLike(c->u->u_ste)) { + case GLOBAL_IMPLICIT: { + /* Opcode depends on the enclosing non-inlined scope. */ + PySTEntryObject *enclosing = ste; + while (enclosing->ste_parent != NULL) { + assert(enclosing->ste_type == InlinedComprehensionBlock); + enclosing = enclosing->ste_parent; + } + if (_PyST_IsFunctionLike(enclosing)) { *optype = COMPILE_OP_GLOBAL; } break; + } case GLOBAL_EXPLICIT: *optype = COMPILE_OP_GLOBAL; break; @@ -1048,128 +1163,33 @@ _PyCompile_ResolveNameop(compiler *c, PyObject *mangled, int scope, /* scope can be 0 */ break; } + /* XXX Handle __doc__ and the like better */ + assert(scope || PyUnicode_READ_CHAR(mangled, 0) == '_'); if (*optype != COMPILE_OP_FAST) { *arg = _PyCompile_DictAddObj(dict, mangled); RETURN_IF_ERROR(*arg); } - return SUCCESS; + return scope; } int -_PyCompile_TweakInlinedComprehensionScopes(compiler *c, location loc, - PySTEntryObject *entry, - _PyCompile_InlinedComprehensionState *state) +_PyCompile_EnterInlinedComprehensionScope(compiler *c, PySTEntryObject *entry, + _PyCompile_InlinedComprehensionState *state) { - int in_class_block = (c->u->u_ste->ste_type == ClassBlock) && !c->u->u_in_inlined_comp; - c->u->u_in_inlined_comp++; - - PyObject *k, *v; - Py_ssize_t pos = 0; - while (PyDict_Next(entry->ste_symbols, &pos, &k, &v)) { - long symbol = PyLong_AsLong(v); - assert(symbol >= 0 || PyErr_Occurred()); - RETURN_IF_ERROR(symbol); - long scope = SYMBOL_TO_SCOPE(symbol); - - long outsymbol = _PyST_GetSymbol(c->u->u_ste, k); - RETURN_IF_ERROR(outsymbol); - long outsc = SYMBOL_TO_SCOPE(outsymbol); - - // If a name has different scope inside than outside the comprehension, - // we need to temporarily handle it with the right scope while - // compiling the comprehension. If it's free in the comprehension - // scope, no special handling; it should be handled the same as the - // enclosing scope. (If it's free in outer scope and cell in inner - // scope, we can't treat it as both cell and free in the same function, - // but treating it as free throughout is fine; it's *_DEREF - // either way.) - if ((scope != outsc && scope != FREE && !(scope == CELL && outsc == FREE)) - || in_class_block) { - if (state->temp_symbols == NULL) { - state->temp_symbols = PyDict_New(); - if (state->temp_symbols == NULL) { - return ERROR; - } - } - // update the symbol to the in-comprehension version and save - // the outer version; we'll restore it after running the - // comprehension - if (PyDict_SetItem(c->u->u_ste->ste_symbols, k, v) < 0) { - return ERROR; - } - PyObject *outv = PyLong_FromLong(outsymbol); - if (outv == NULL) { - return ERROR; - } - int res = PyDict_SetItem(state->temp_symbols, k, outv); - Py_DECREF(outv); - RETURN_IF_ERROR(res); - } - // locals handling for names bound in comprehension (DEF_LOCAL | - // DEF_NONLOCAL occurs in assignment expression to nonlocal) - if ((symbol & DEF_LOCAL && !(symbol & DEF_NONLOCAL)) || in_class_block) { - if (!_PyST_IsFunctionLike(c->u->u_ste)) { - // non-function scope: override this name to use fast locals - PyObject *orig; - if (PyDict_GetItemRef(c->u->u_metadata.u_fasthidden, k, &orig) < 0) { - return ERROR; - } - assert(orig == NULL || orig == Py_True || orig == Py_False); - if (orig != Py_True) { - if (PyDict_SetItem(c->u->u_metadata.u_fasthidden, k, Py_True) < 0) { - Py_XDECREF(orig); - return ERROR; - } - if (state->fast_hidden == NULL) { - state->fast_hidden = PySet_New(NULL); - if (state->fast_hidden == NULL) { - Py_XDECREF(orig); - return ERROR; - } - } - if (PySet_Add(state->fast_hidden, k) < 0) { - Py_XDECREF(orig); - return ERROR; - } - } - Py_XDECREF(orig); - } - } - } + assert(state->saved_ste == NULL); + state->saved_ste = c->u->u_ste; + c->u->u_ste = (PySTEntryObject *)Py_NewRef(entry); return SUCCESS; } int -_PyCompile_RevertInlinedComprehensionScopes(compiler *c, location loc, - _PyCompile_InlinedComprehensionState *state) -{ - c->u->u_in_inlined_comp--; - if (state->temp_symbols) { - PyObject *k, *v; - Py_ssize_t pos = 0; - while (PyDict_Next(state->temp_symbols, &pos, &k, &v)) { - if (PyDict_SetItem(c->u->u_ste->ste_symbols, k, v)) { - return ERROR; - } - } - Py_CLEAR(state->temp_symbols); - } - if (state->fast_hidden) { - while (PySet_Size(state->fast_hidden) > 0) { - PyObject *k = PySet_Pop(state->fast_hidden); - if (k == NULL) { - return ERROR; - } - // we set to False instead of clearing, so we can track which names - // were temporarily fast-locals and should use CO_FAST_HIDDEN - if (PyDict_SetItem(c->u->u_metadata.u_fasthidden, k, Py_False)) { - Py_DECREF(k); - return ERROR; - } - Py_DECREF(k); - } - Py_CLEAR(state->fast_hidden); - } +_PyCompile_ExitInlinedComprehensionScope(compiler *c, + _PyCompile_InlinedComprehensionState *state) +{ + assert(state->saved_ste != NULL); + Py_DECREF(c->u->u_ste); + c->u->u_ste = state->saved_ste; + state->saved_ste = NULL; return SUCCESS; } @@ -1361,12 +1381,6 @@ _PyCompile_ScopeType(compiler *c) return c->u->u_scope_type; } -int -_PyCompile_IsInInlinedComp(compiler *c) -{ - return c->u->u_in_inlined_comp; -} - PyObject * _PyCompile_Qualname(compiler *c) { @@ -1424,6 +1438,147 @@ consts_dict_keys_inorder(PyObject *dict) return consts; } +/* Intern the strings of the constant *o* which intern_constants() in + * codeobject.c would intern when a code object is created. + * + * The strings of a slice are interned in all builds, although + * intern_constants() only looks into slices in the free-threaded build, + * so that the constants of a compilation are the same objects in both + * builds. + * + * Return a new reference to the constant to use instead of *o*. The items + * of a tuple are replaced in place. A frozenset or a slice with an item + * to replace cannot be modified: a new object is created and stored in its + * entry of *const_cache*, which is where the other users of *o* find it. + */ +static PyObject * +intern_constant(PyObject *const_cache, PyObject *o) +{ + if (PyUnicode_CheckExact(o)) { + Py_INCREF(o); + if (_PyCode_ShouldInternString(o)) { + _PyUnicode_InternMortal(_PyInterpreterState_GET(), &o); + } + return o; + } + if (PyTuple_CheckExact(o)) { + Py_ssize_t len = PyTuple_GET_SIZE(o); + for (Py_ssize_t i = 0; i < len; i++) { + PyObject *item = PyTuple_GET_ITEM(o, i); + PyObject *v = intern_constant(const_cache, item); + if (v == NULL) { + return NULL; + } + if (v != item) { + // intern_constants() makes the same replacement in the + // tuple if it is not made here. + PyTuple_SET_ITEM(o, i, v); + Py_DECREF(item); + } + else { + Py_DECREF(v); + } + } + return Py_NewRef(o); + } + if (!PyFrozenSet_CheckExact(o) && !PySlice_Check(o)) { + return Py_NewRef(o); + } + + // The key of a frozenset or of a slice is a pair whose second item is + // the object which stands for all the equal constants. + // See _PyCode_ConstantKey(). + PyObject *key = const_cache_insert(const_cache, o, false); + if (key == NULL) { + return NULL; + } + assert(PyTuple_CheckExact(key)); + assert(PyTuple_GET_SIZE(key) == 2); + o = PyTuple_GET_ITEM(key, 1); + + PyObject *items; + if (PyFrozenSet_CheckExact(o)) { + items = PySequence_Tuple(o); + } + else { + PySliceObject *slice = (PySliceObject *)o; + items = PyTuple_Pack(3, slice->start, slice->stop, slice->step); + } + if (items == NULL) { + Py_DECREF(key); + return NULL; + } + bool modified = false; + Py_ssize_t len = PyTuple_GET_SIZE(items); + for (Py_ssize_t i = 0; i < len; i++) { + PyObject *item = PyTuple_GET_ITEM(items, i); + PyObject *v = intern_constant(const_cache, item); + if (v == NULL) { + Py_DECREF(items); + Py_DECREF(key); + return NULL; + } + if (v != item) { + modified = true; + } + PyTuple_SET_ITEM(items, i, v); + Py_DECREF(item); + } + if (modified) { + PyObject *new; + if (PyFrozenSet_CheckExact(o)) { + new = PyFrozenSet_New(items); + } + else { + new = PySlice_New(PyTuple_GET_ITEM(items, 0), + PyTuple_GET_ITEM(items, 1), + PyTuple_GET_ITEM(items, 2)); + } + if (new == NULL) { + Py_DECREF(items); + Py_DECREF(key); + return NULL; + } + PyTuple_SET_ITEM(key, 1, new); + Py_DECREF(o); + o = new; + } + Py_DECREF(items); + Py_INCREF(o); + Py_DECREF(key); + return o; +} + +/* Intern the strings of the constants of a code unit, once the optimizer + * has removed the constants which are not used. + * + * intern_constants() in codeobject.c interns the string constants of each + * new code object. When it has to replace a string of a frozenset (or, in + * the free-threaded build, of a slice) by a string which is already + * interned, it makes a copy of the container for that code object only. + * The constants of a code object would then be shared with the other code + * objects of the compilation or not depending on which strings happen to + * be interned in the process, and so would the output of marshal + * (gh-129724). Replace the strings here instead, where all the code units + * get the same container from the constant cache. + */ +static int +intern_final_constants(PyObject *const_cache, PyObject *consts) +{ + assert(PyList_CheckExact(consts)); + Py_ssize_t len = PyList_GET_SIZE(consts); + for (Py_ssize_t i = 0; i < len; i++) { + PyObject *item = PyList_GET_ITEM(consts, i); + PyObject *v = intern_constant(const_cache, item); + if (v == NULL) { + return ERROR; + } + PyList_SET_ITEM(consts, i, v); + Py_DECREF(item); + } + return SUCCESS; +} + static int compute_code_flags(compiler *c) { @@ -1491,6 +1646,10 @@ optimize_and_assemble_code_unit(struct compiler_unit *u, PyObject *const_cache, goto error; } + if (intern_final_constants(const_cache, consts) < 0) { + goto error; + } + /** Assembly **/ co = _PyAssemble_MakeCodeObject(&u->u_metadata, const_cache, consts, stackdepth, &optimized_instrs, nlocalsplus, @@ -1512,10 +1671,7 @@ _PyCompile_OptimizeAndAssemble(compiler *c, int addNone) PyObject *filename = c->c_filename; int code_flags = compute_code_flags(c); - if (code_flags < 0) { - return NULL; - } - + assert(code_flags >= 0); if (_PyCodegen_AddReturnAtEnd(c, addNone) < 0) { return NULL; } @@ -1735,7 +1891,9 @@ _PyCompile_CodeGen(PyObject *ast, PyObject *filename, PyCompilerFlags *pflags, finally: Py_XDECREF(consts_list); Py_XDECREF(metadata); - _PyCompile_ExitScope(c); + if (c->u != NULL) { + _PyCompile_ExitScope(c); + } compiler_free(c); _PyArena_Free(arena); return res; diff --git a/Python/context.c b/Python/context.c index 4678054ff3ad743..0d931ef74b56461 100644 --- a/Python/context.c +++ b/Python/context.c @@ -1,11 +1,13 @@ #include "Python.h" #include "pycore_call.h" // _PyObject_VectorcallTstate() #include "pycore_context.h" +#include "pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION() #include "pycore_freelist.h" // _Py_FREELIST_FREE(), _Py_FREELIST_POP() #include "pycore_gc.h" // _PyObject_GC_MAY_BE_TRACKED() #include "pycore_hamt.h" #include "pycore_initconfig.h" // _PyStatus_OK() #include "pycore_object.h" +#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_INT_RELAXED() #include "pycore_pyerrors.h" #include "pycore_pystate.h" // _PyThreadState_GET() @@ -64,6 +66,41 @@ contextvar_set(PyContextVar *var, PyObject *val); static int contextvar_del(PyContextVar *var); +static inline PyHamtObject * +context_get_vars(PyContext *ctx) +{ + PyHamtObject *vars; + Py_BEGIN_CRITICAL_SECTION(ctx); + vars = ctx->ctx_vars; + assert(vars != NULL); + Py_INCREF(vars); + Py_END_CRITICAL_SECTION(); + return vars; +} + +static inline PyHamtObject * +context_get_current_vars(PyContext *ctx) +{ + // ctx_vars written only by the owning thread, and read by other threads + // only under the context's lock, a plain (non-atomic) load is okay + PyHamtObject *vars = ctx->ctx_vars; + assert(vars != NULL); + return vars; +} + +// Note: steals a reference to new_vars and must only be called by the thread +// that has `ctx` as its current context. +static inline void +context_set_vars(PyContext *ctx, PyHamtObject *new_vars) +{ + PyHamtObject *old_vars; + Py_BEGIN_CRITICAL_SECTION(ctx); + old_vars = ctx->ctx_vars; + ctx->ctx_vars = new_vars; + Py_END_CRITICAL_SECTION(); + Py_XDECREF(old_vars); +} + PyObject * _PyContext_NewHamtForTests(void) @@ -84,7 +121,10 @@ PyContext_Copy(PyObject * octx) { ENSURE_Context(octx, NULL) PyContext *ctx = (PyContext *)octx; - return (PyObject *)context_new_from_vars(ctx->ctx_vars); + PyHamtObject *vars = context_get_vars(ctx); + PyObject *res = (PyObject *)context_new_from_vars(vars); + Py_DECREF(vars); + return res; } @@ -96,7 +136,7 @@ PyContext_CopyCurrent(void) return NULL; } - return (PyObject *)context_new_from_vars(ctx->ctx_vars); + return (PyObject *)context_new_from_vars(context_get_current_vars(ctx)); } static const char * @@ -129,8 +169,8 @@ notify_context_watchers(PyThreadState *ts, PyContextEvent event, PyObject *ctx) assert(i < CONTEXT_MAX_WATCHERS); if (bits & 1) { PyContext_WatchCallback cb = interp->context_watchers[i]; - assert(cb != NULL); - if (cb(event, ctx) < 0) { + // A previous callback may have cleared this watcher. + if (cb != NULL && cb(event, ctx) < 0) { PyErr_FormatUnraisable( "Exception ignored in %s watcher callback for %R", context_event_name(event), ctx); @@ -298,7 +338,7 @@ PyContextVar_Get(PyObject *ovar, PyObject *def, PyObject **val) #endif assert(PyContext_CheckExact(ts->context)); - PyHamtObject *vars = ((PyContext *)ts->context)->ctx_vars; + PyHamtObject *vars = context_get_current_vars((PyContext *)ts->context); PyObject *found = NULL; int res = _PyHamt_Find(vars, (PyObject*)var, &found); @@ -354,7 +394,8 @@ PyContextVar_Set(PyObject *ovar, PyObject *val) } PyObject *old_val = NULL; - int found = _PyHamt_Find(ctx->ctx_vars, (PyObject *)var, &old_val); + int found = _PyHamt_Find(context_get_current_vars(ctx), (PyObject *)var, + &old_val); if (found < 0) { return NULL; } @@ -552,7 +593,10 @@ static PyObject * context_tp_iter(PyObject *op) { PyContext *self = _PyContext_CAST(op); - return _PyHamt_NewIterKeys(self->ctx_vars); + PyHamtObject *vars = context_get_vars(self); + PyObject *res = _PyHamt_NewIterKeys(vars); + Py_DECREF(vars); + return res; } static PyObject * @@ -564,8 +608,11 @@ context_tp_richcompare(PyObject *v, PyObject *w, int op) Py_RETURN_NOTIMPLEMENTED; } - int res = _PyHamt_Eq( - ((PyContext *)v)->ctx_vars, ((PyContext *)w)->ctx_vars); + PyHamtObject *v_vars = context_get_vars((PyContext *)v); + PyHamtObject *w_vars = context_get_vars((PyContext *)w); + int res = _PyHamt_Eq(v_vars, w_vars); + Py_DECREF(v_vars); + Py_DECREF(w_vars); if (res < 0) { return NULL; } @@ -586,7 +633,10 @@ static Py_ssize_t context_tp_len(PyObject *op) { PyContext *self = _PyContext_CAST(op); - return _PyHamt_Len(self->ctx_vars); + PyHamtObject *vars = context_get_vars(self); + Py_ssize_t res = _PyHamt_Len(vars); + Py_DECREF(vars); + return res; } static PyObject * @@ -597,7 +647,10 @@ context_tp_subscript(PyObject *op, PyObject *key) } PyObject *val = NULL; PyContext *self = _PyContext_CAST(op); - int found = _PyHamt_Find(self->ctx_vars, key, &val); + PyHamtObject *vars = context_get_vars(self); + int found = _PyHamt_Find(vars, key, &val); + Py_XINCREF(val); + Py_DECREF(vars); if (found < 0) { return NULL; } @@ -605,7 +658,7 @@ context_tp_subscript(PyObject *op, PyObject *key) PyErr_SetObject(PyExc_KeyError, key); return NULL; } - return Py_NewRef(val); + return val; } static int @@ -616,7 +669,10 @@ context_tp_contains(PyObject *op, PyObject *key) } PyObject *val = NULL; PyContext *self = _PyContext_CAST(op); - return _PyHamt_Find(self->ctx_vars, key, &val); + PyHamtObject *vars = context_get_vars(self); + int res = _PyHamt_Find(vars, key, &val); + Py_DECREF(vars); + return res; } @@ -643,14 +699,17 @@ _contextvars_Context_get_impl(PyContext *self, PyObject *key, } PyObject *val = NULL; - int found = _PyHamt_Find(self->ctx_vars, key, &val); + PyHamtObject *vars = context_get_vars(self); + int found = _PyHamt_Find(vars, key, &val); + Py_XINCREF(val); + Py_DECREF(vars); if (found < 0) { return NULL; } if (found == 0) { return Py_NewRef(default_value); } - return Py_NewRef(val); + return val; } @@ -666,7 +725,10 @@ static PyObject * _contextvars_Context_items_impl(PyContext *self) /*[clinic end generated code: output=fa1655c8a08502af input=00db64ae379f9f42]*/ { - return _PyHamt_NewIterItems(self->ctx_vars); + PyHamtObject *vars = context_get_vars(self); + PyObject *res = _PyHamt_NewIterItems(vars); + Py_DECREF(vars); + return res; } @@ -680,7 +742,10 @@ static PyObject * _contextvars_Context_keys_impl(PyContext *self) /*[clinic end generated code: output=177227c6b63ec0e2 input=114b53aebca3449c]*/ { - return _PyHamt_NewIterKeys(self->ctx_vars); + PyHamtObject *vars = context_get_vars(self); + PyObject *res = _PyHamt_NewIterKeys(vars); + Py_DECREF(vars); + return res; } @@ -694,7 +759,10 @@ static PyObject * _contextvars_Context_values_impl(PyContext *self) /*[clinic end generated code: output=d286dabfc8db6dde input=ce8075d04a6ea526]*/ { - return _PyHamt_NewIterValues(self->ctx_vars); + PyHamtObject *vars = context_get_vars(self); + PyObject *res = _PyHamt_NewIterValues(vars); + Py_DECREF(vars); + return res; } @@ -708,7 +776,10 @@ static PyObject * _contextvars_Context_copy_impl(PyContext *self) /*[clinic end generated code: output=30ba8896c4707a15 input=ebafdbdd9c72d592]*/ { - return (PyObject *)context_new_from_vars(self->ctx_vars); + PyHamtObject *vars = context_get_vars(self); + PyObject *res = (PyObject *)context_new_from_vars(vars); + Py_DECREF(vars); + return res; } @@ -795,19 +866,24 @@ contextvar_set(PyContextVar *var, PyObject *val) return -1; } + // gh-148891: Make a strong reference so a GC during _PyHamt_Assoc will + // not free the HAMT during traversal. + PyHamtObject *old_vars = context_get_current_vars(ctx); + Py_INCREF(old_vars); PyHamtObject *new_vars = _PyHamt_Assoc( - ctx->ctx_vars, (PyObject *)var, val); + old_vars, (PyObject *)var, val); + Py_DECREF(old_vars); if (new_vars == NULL) { return -1; } - Py_SETREF(ctx->ctx_vars, new_vars); - #ifndef Py_GIL_DISABLED var->var_cached = val; /* borrow */ var->var_cached_tsid = ts->id; var->var_cached_tsver = ts->context_ver; #endif + /* Releasing the old variables may run a finalizer that updates the cache. */ + context_set_vars(ctx, new_vars); return 0; } @@ -823,8 +899,12 @@ contextvar_del(PyContextVar *var) return -1; } - PyHamtObject *vars = ctx->ctx_vars; + // gh-148891: Make a strong reference so a GC during _PyHamt_Without will + // not free the HAMT during traversal. + PyHamtObject *vars = context_get_current_vars(ctx); + Py_INCREF(vars); PyHamtObject *new_vars = _PyHamt_Without(vars, (PyObject *)var); + Py_DECREF(vars); if (new_vars == NULL) { return -1; } @@ -835,7 +915,7 @@ contextvar_del(PyContextVar *var) return -1; } - Py_SETREF(ctx->ctx_vars, new_vars); + context_set_vars(ctx, new_vars); return 0; } @@ -914,19 +994,20 @@ class _contextvars.ContextVar "PyContextVar *" "&PyContextVar_Type" #define _PyContextVar_CAST(op) ((PyContextVar *)(op)) +/*[clinic input] +@vectorcall +@classmethod +_contextvars.ContextVar.__new__ as contextvar_tp_new + name: object + / + * + default as def: object = NULL +[clinic start generated code]*/ + static PyObject * -contextvar_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +contextvar_tp_new_impl(PyTypeObject *type, PyObject *name, PyObject *def) +/*[clinic end generated code: output=1c8af17a14fc9dc2 input=d5e8cf845a1ddc27]*/ { - static char *kwlist[] = {"", "default", NULL}; - PyObject *name; - PyObject *def = NULL; - - if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O|$O:ContextVar", kwlist, &name, &def)) - { - return NULL; - } - return (PyObject *)contextvar_new(name, def); } @@ -1120,6 +1201,7 @@ PyTypeObject PyContextVar_Type = { .tp_traverse = contextvar_tp_traverse, .tp_clear = contextvar_tp_clear, .tp_new = contextvar_tp_new, + .tp_vectorcall = contextvar_tp_vectorcall, .tp_free = PyObject_GC_Del, .tp_hash = contextvar_tp_hash, .tp_repr = contextvar_tp_repr, diff --git a/Python/crossinterp.c b/Python/crossinterp.c index ed77c1be646e275..a91b45ba2cbcf45 100644 --- a/Python/crossinterp.c +++ b/Python/crossinterp.c @@ -388,6 +388,8 @@ _PyXIData_InitWithSize(_PyXIData_t *xidata, _PyXIData_Init(xidata, interp, NULL, obj, new_object); xidata->data = PyMem_RawCalloc(1, size); if (xidata->data == NULL) { + Py_CLEAR(xidata->obj); + PyErr_NoMemory(); return -1; } xidata->free = PyMem_RawFree; @@ -664,6 +666,11 @@ check_missing___main___attr(PyObject *exc) } } const char *err = PyUnicode_AsUTF8(msgobj); + if (err == NULL) { + PyErr_Clear(); + Py_DECREF(msgobj); + return 0; + } // Check if it's a missing __main__ attr. int cmp = strncmp(err, "module '__main__' has no attribute '", 36); @@ -2011,6 +2018,14 @@ _PyXI_ApplyError(_PyXI_error *error, const char *failure) PyThreadState *tstate = PyThreadState_Get(); if (failure != NULL) { + if (error->override != NULL + && error->override->code == _PyXI_ERR_NO_MEMORY) + { + PyErr_NoMemory(); + } + else { + PyErr_SetString(PyExc_InterpreterError, failure); + } xi_error_clear(error); return NULL; } diff --git a/Python/dtoa.c b/Python/dtoa.c index 89fadd33391cb42..f412278765c8e32 100644 --- a/Python/dtoa.c +++ b/Python/dtoa.c @@ -67,6 +67,10 @@ * 8. A corner case where _Py_dg_dtoa didn't strip trailing zeros has been * fixed. (bugs.python.org/issue40780) * + * 9. _Py_dg_dtoa clamps ndigits in modes 3 and 5 so that its buffer size + * arithmetic cannot exceed the int range, and rv_alloc's size doubling + * uses size_t. (gh-158446) + * ***************************************************************/ /* Please send bug reports for the original dtoa.c code to David M. Gay (dmg @@ -2108,7 +2112,8 @@ _Py_dg_strtod(const char *s00, char **se) static char * rv_alloc(int i) { - int j, k, *r; + int k, *r; + size_t j; /* size_t so that j <<= 1 cannot overflow for i near INT_MAX */ j = sizeof(ULong); for(k = 0; @@ -2372,6 +2377,15 @@ _Py_dg_dtoa(double dd, int mode, int ndigits, leftright = 0; _Py_FALLTHROUGH; case 5: + /* -330 < k < 330 for any finite nonzero double. Clamp ndigits so + that ndigits + k + 1 stays within int range; no double has + anywhere near this many decimal digits so the digits returned + are unaffected (*decpt saturates in the no_digits case). Same + bound as DOUBLE_TO_STRING_PRECISION_MAX in pystrtod.c. */ + if (ndigits > INT_MAX - 1024) + ndigits = INT_MAX - 1024; + else if (ndigits < -(INT_MAX - 1024)) + ndigits = -(INT_MAX - 1024); i = ndigits + k + 1; ilim = i; ilim1 = i - 1; diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c index 0ff88ad330fd09c..4a1f9898675a2ca 100644 --- a/Python/dynload_shlib.c +++ b/Python/dynload_shlib.c @@ -11,15 +11,6 @@ #include #include -#if defined(__NetBSD__) -#include -#if (NetBSD < 199712) -#include -#include -#define dlerror() "error in dynamic linking" -#endif -#endif /* NetBSD */ - #ifdef HAVE_DLFCN_H #include #endif @@ -46,8 +37,14 @@ const char *_PyImport_DynLoadFiletab[] = { "." ALT_SOABI ".so", #endif #ifndef Py_GIL_DISABLED +#ifdef SOABI_PLATFORM + ".abi" PYTHON_ABI_STRING "-" SOABI_PLATFORM ".so", +#endif /* SOABI_PLATFORM */ ".abi" PYTHON_ABI_STRING ".so", #endif /* Py_GIL_DISABLED */ +#ifdef SOABI_PLATFORM + ".abi" PYTHON_ABI_STRING "t-" SOABI_PLATFORM ".so", +#endif /* SOABI_PLATFORM */ ".abi" PYTHON_ABI_STRING "t.so", ".so", #endif /* __CYGWIN__ */ diff --git a/Python/dynload_win.c b/Python/dynload_win.c index 1c2544e94160ac2..423a2d2ef21e903 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -164,12 +164,16 @@ _Py_CheckPython3(void) static int python3_checked = 0; static HANDLE hPython3; #define MAXPATHLEN 512 - wchar_t py3path[MAXPATHLEN+1]; if (python3_checked) { return hPython3 != NULL; } python3_checked = 1; +#ifndef MS_WINDOWS_DESKTOP + // LoadPackagedLibrary doesn't accept absolute paths so load dll name from current app dir + hPython3 = LoadPackagedLibrary(PY3_DLLNAME, 0); +#else + wchar_t py3path[MAXPATHLEN + 1]; /* If there is a python3.dll next to the python3y.dll, use that DLL */ if (PyWin_DLLhModule && GetModuleFileNameW(PyWin_DLLhModule, py3path, MAXPATHLEN)) { @@ -202,6 +206,8 @@ _Py_CheckPython3(void) hPython3 = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); } } +#endif + return hPython3 != NULL; #undef MAXPATHLEN #endif /* PY3_DLLNAME */ @@ -272,6 +278,20 @@ _Py_CheckPython3t(void) #endif /* Py_ENABLE_SHARED */ +static wchar_t* _Py_AbsolutePath_To_RelativePath(wchar_t* abs_path) +{ + wchar_t* rel_path = NULL; + wchar_t process_path[512] = { 0 }; + if (GetModuleFileNameW(NULL, process_path, 512)) + { + wchar_t* path = wcsrchr(process_path, L'\\'); + path[1] = L'\0'; // strip process name + if (wcsstr(abs_path, process_path)) + rel_path = &abs_path[wcslen(process_path)]; + } + return rel_path; +} + dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix, const char *shortname, PyObject *pathname, FILE *fp) @@ -299,14 +319,24 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix, old_mode = SetErrorMode(SEM_FAILCRITICALERRORS); #endif + Py_BEGIN_ALLOW_THREADS +#ifndef MS_WINDOWS_DESKTOP + // UWP does not allow absolute paths due security restrictions. + // If path is contained inside process path (sub folder), use the relative path instead. + wchar_t* rel_path = _Py_AbsolutePath_To_RelativePath(wpathname); + if (rel_path) + hDLL = LoadPackagedLibrary(rel_path, 0); + else + hDLL = LoadPackagedLibrary(wpathname, 0); +#else /* bpo-36085: We use LoadLibraryEx with restricted search paths to avoid DLL preloading attacks and enable use of the AddDllDirectory function. We add SEARCH_DLL_LOAD_DIR to ensure DLLs adjacent to the PYD are preferred. */ - Py_BEGIN_ALLOW_THREADS hDLL = LoadLibraryExW(wpathname, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR); +#endif Py_END_ALLOW_THREADS PyMem_Free(wpathname); diff --git a/Python/emscripten_syscalls.c b/Python/emscripten_syscalls.c index 48ca208dedb14bb..f0c677fa883a231 100644 --- a/Python/emscripten_syscalls.c +++ b/Python/emscripten_syscalls.c @@ -54,13 +54,40 @@ __attribute__((constructor)) void __syscall_init_umask(void) { #define EM_JS_MACROS(ret, func_name, args, body...) \ EM_JS(ret, func_name, args, body) -EM_JS_MACROS(void, _emscripten_promising_main_js, (void), { - // Define FS.createAsyncInputDevice(), This is quite similar to - // FS.createDevice() defined here: - // https://github.com/emscripten-core/emscripten/blob/4.0.11/src/lib/libfs.js?plain=1#L1642 - // but instead of returning one byte at a time, the input() function should - // return a Uint8Array. This makes the handler code simpler, the - // `createAsyncInputDevice` simpler, and everything faster. +EM_JS(void, _PyEmscripten_BeforeMain_js, (void), { + if (!WebAssembly.promising) { + // No stack switching support =( + return; + } + if (ENVIRONMENT_IS_NODE && !Module.onExit) { + Module.onExit = (code) => process.exit(code); + } + // promising() needs the raw export; _main may be a JS wrapper around it. + const main = WebAssembly.promising(wasmExports.__main_argc_argv); + _main = (...args) => { + Module._Py_EmscriptenStackSwitching = true; + (async () => { + const ret = await main(...args); + Module.onExit?.(ret); + })(); + _emscripten_exit_with_live_runtime(); + }; + // callMain() takes the entry point from _main, or from wasmImports.main + // when linked with -sMAIN_MODULE. + if ("main" in wasmImports) { + wasmImports.main = _main; + } +}) + +EM_JS_DEPS(_PyEmscripten_BeforeMain, "emscripten_exit_with_live_runtime"); + +// Define FS.createAsyncInputDevice(), This is quite similar to +// FS.createDevice() defined here: +// https://github.com/emscripten-core/emscripten/blob/4.0.11/src/lib/libfs.js?plain=1#L1642 +// but instead of returning one byte at a time, the input() function should +// return a Uint8Array. This makes the handler code simpler, the +// `createAsyncInputDevice` simpler, and everything faster. +EM_JS_MACROS(void, __fs_init_async_input_device_js, (void), { FS.createAsyncInputDevice = function(parent, name, input) { parent = typeof parent == 'string' ? parent : FS.getPath(parent); var path = PATH.join2(parent, name); @@ -103,39 +130,13 @@ EM_JS_MACROS(void, _emscripten_promising_main_js, (void), { FS.registerDevice(dev, ops); return FS.mkdev(path, mode, dev); }; - if (!WebAssembly.promising) { - // No stack switching support =( - return; - } - const origResolveGlobalSymbol = resolveGlobalSymbol; - if (ENVIRONMENT_IS_NODE && !Module.onExit) { - Module.onExit = (code) => process.exit(code); - } - // * wrap the main symbol with WebAssembly.promising, - // * call exit_with_live_runtime() to prevent emscripten from shutting down - // the runtime before the promise resolves, - // * call onExit / process.exit ourselves, since exit_with_live_runtime() - // prevented Emscripten from calling it normally. - resolveGlobalSymbol = function (name, direct = false) { - const orig = origResolveGlobalSymbol(name, direct); - if (name === "main") { - const main = WebAssembly.promising(orig.sym); - orig.sym = (...args) => { - (async () => { - const ret = await main(...args); - Module.onExit?.(ret); - })(); - _emscripten_exit_with_live_runtime(); - }; - } - return orig; - }; }) -__attribute__((constructor)) void _emscripten_promising_main(void) { - _emscripten_promising_main_js(); -} +EM_JS_DEPS(__fs_init_async_input_device, "$FS,$PATH,$FS_getMode"); +__attribute__((constructor)) void __fs_init_async_input_device(void) { + __fs_init_async_input_device_js(); +} #define IOVEC_T_BUF_OFFSET 0 #define IOVEC_T_BUF_LEN_OFFSET 4 @@ -150,13 +151,20 @@ _Static_assert(sizeof(__wasi_iovec_t) == IOVEC_T_SIZE, // If the stream has a readAsync handler, read to buffer defined in iovs, write // number of bytes read to *nread, and return a promise that resolves to the // errno. Otherwise, return null. +// +// Reading from an async input device and poll() suspend the wasm stack +// instead of blocking when main() runs under WebAssembly.promising, which +// Programs/emscripten_beforemain.c arranges for the interpreter. An embedder +// running its own promising entry point opts in with +// Module._Py_EmscriptenStackSwitching = true; +// Otherwise these calls keep their synchronous behavior. EM_JS_MACROS(__externref_t, __maybe_fd_read_async, ( __wasi_fd_t fd, const __wasi_iovec_t *iovs, size_t iovcnt, __wasi_size_t *nread ), { - if (!WebAssembly.promising) { + if (!Module._Py_EmscriptenStackSwitching) { return null; } var stream; @@ -199,6 +207,8 @@ EM_JS_MACROS(__externref_t, __maybe_fd_read_async, ( }; ); +EM_JS_DEPS(__maybe_fd_read_async, "$SYSCALLS"); + // Bind original fd_read syscall to __wasi_fd_read_orig(). __wasi_errno_t __wasi_fd_read_orig(__wasi_fd_t fd, const __wasi_iovec_t *iovs, size_t iovs_len, __wasi_size_t *nread) @@ -238,7 +248,7 @@ _Static_assert(offsetof(struct pollfd, revents) == 6, "Unepxected pollfd struct _Static_assert(sizeof(struct pollfd) == 8, "Unepxected pollfd struct layout"); EM_JS_MACROS(__externref_t, __maybe_poll_async, (intptr_t fds, int nfds, int timeout), { - if (!WebAssembly.promising) { + if (!Module._Py_EmscriptenStackSwitching) { return null; } return (async function() { @@ -280,6 +290,8 @@ EM_JS_MACROS(__externref_t, __maybe_poll_async, (intptr_t fds, int nfds, int tim })(); }); +EM_JS_DEPS(__maybe_poll_async, "$FS"); + // Bind original poll syscall to syscall_poll_orig(). int syscall_poll_orig(intptr_t fds, int nfds, int timeout) __attribute__((__import_module__("env"), diff --git a/Python/emscripten_trampoline.c b/Python/emscripten_trampoline.c deleted file mode 100644 index 1833311ca74d9dd..000000000000000 --- a/Python/emscripten_trampoline.c +++ /dev/null @@ -1,118 +0,0 @@ -#if defined(PY_CALL_TRAMPOLINE) - -#include // EM_JS, EM_JS_DEPS -#include -#include "pycore_runtime.h" // _PyRuntime - -// We use the _PyRuntime.emscripten_trampoline field to store a function pointer -// for a wasm-gc based trampoline if it works. Otherwise fall back to JS -// trampoline. The JS trampoline breaks stack switching but every runtime that -// supports stack switching also supports wasm-gc. -// -// We'd like to make the trampoline call into a direct call but currently we -// need to import the wasmTable to compile trampolineModule. emcc >= 4.0.19 -// defines the table in WebAssembly and exports it so we won't have access to it -// until after the main module is compiled. -// -// To fix this, one natural solution would be to pass a funcref to the -// trampoline instead of a table index. Several PRs would be needed to fix -// things in llvm and emscripten in order to make this possible. -// -// The performance costs of an extra call_indirect aren't that large anyways. -// The JIT should notice that the target is always the same and turn into a -// check -// -// if (call_target != expected) deoptimize; -// direct_call(call_target, args); - -// Offset of emscripten_trampoline in _PyRuntimeState. There's a couple of -// alternatives: -// -// 1. Just make emscripten_trampoline a real C global variable instead of a -// field of _PyRuntimeState. This would violate our rule against mutable -// globals. -// -// 2. #define a preprocessor constant equal to a hard coded number and make a -// _Static_assert(offsetof(_PyRuntimeState, emscripten_trampoline) == OURCONSTANT) -// This has the disadvantage that we have to update the hard coded constant -// when _PyRuntimeState changes -// -// So putting the mutable constant in _PyRuntime and using a immutable global to -// record the offset so we can access it from JS is probably the best way. -EMSCRIPTEN_KEEPALIVE const int _PyEM_EMSCRIPTEN_TRAMPOLINE_OFFSET = offsetof(_PyRuntimeState, emscripten_trampoline); - -typedef PyObject* (*TrampolineFunc)(int* success, - PyCFunctionWithKeywords func, - PyObject* self, - PyObject* args, - PyObject* kw); - -/** - * Backwards compatible trampoline works with all JS runtimes - */ -EM_JS(PyObject*, _PyEM_TrampolineCall_JS, (PyCFunctionWithKeywords func, PyObject *arg1, PyObject *arg2, PyObject *arg3), { - return wasmTable.get(func)(arg1, arg2, arg3); -} -// Try to compile wasm-gc trampoline if possible. -function getPyEMTrampolinePtr() { - // Starting with iOS 18.3.1, WebKit on iOS has an issue with the garbage - // collector that breaks the call trampoline. See #130418 and - // https://bugs.webkit.org/show_bug.cgi?id=293113 for details. - let isIOS = globalThis.navigator && ( - /iPad|iPhone|iPod/.test(navigator.userAgent) || - // Starting with iPadOS 13, iPads might send a platform string that looks like a desktop Mac. - // To differentiate, we check if the platform is 'MacIntel' (common for Macs and newer iPads) - // AND if the device has multi-touch capabilities (navigator.maxTouchPoints > 1) - (navigator.platform === 'MacIntel' && typeof navigator.maxTouchPoints !== 'undefined' && navigator.maxTouchPoints > 1) - ); - if (isIOS) { - return 0; - } - let trampolineModule; - try { - trampolineModule = getWasmTrampolineModule(); - } catch (e) { - // Compilation error due to missing wasm-gc support, fall back to JS - // trampoline - return 0; - } - const trampolineInstance = new WebAssembly.Instance(trampolineModule, { - env: { __indirect_function_table: wasmTable, memory: wasmMemory }, - }); - return addFunction(trampolineInstance.exports.trampoline_call); -} -// We have to be careful to work correctly with memory snapshots -- the value of -// _PyRuntimeState.emscripten_trampoline needs to reflect whether wasm-gc is -// available in the current runtime, not in the runtime the snapshot was taken -// in. This writes the appropriate value to -// _PyRuntimeState.emscripten_trampoline from JS startup code that runs every -// time, whether we are restoring a snapshot or not. -addOnPreRun(function setEmscriptenTrampoline() { - const ptr = getPyEMTrampolinePtr(); - const offset = HEAP32[__PyEM_EMSCRIPTEN_TRAMPOLINE_OFFSET / 4]; - HEAP32[(__PyRuntime + offset) / 4] = ptr; -}); -); - -PyObject* -_PyEM_TrampolineCall(PyCFunctionWithKeywords func, - PyObject* self, - PyObject* args, - PyObject* kw) -{ - TrampolineFunc trampoline = _PyRuntime.emscripten_trampoline; - if (trampoline == 0) { - return _PyEM_TrampolineCall_JS(func, self, args, kw); - } - int success = 1; - PyObject *result = trampoline(&success, func, self, args, kw); - if (!success) { - PyErr_SetString(PyExc_SystemError, "Handler takes too many arguments"); - } - return result; -} - -#else -// This is exported so we need to define it even when it isn't used -__attribute__((used)) const int _PyEM_EMSCRIPTEN_TRAMPOLINE_OFFSET = 0; -#endif diff --git a/Python/emscripten_trampoline_inner.c b/Python/emscripten_trampoline_inner.c deleted file mode 100644 index a2bad4857ed089c..000000000000000 --- a/Python/emscripten_trampoline_inner.c +++ /dev/null @@ -1,38 +0,0 @@ -// This file must be compiled with -mgc to enable the extra wasm-gc -// instructions. It has to be compiled separately because not enough JS runtimes -// support wasm-gc yet. If the JS runtime does not support wasm-gc (or has buggy -// support like iOS), we will use the JS trampoline fallback. - -// We can't import Python.h here because it is compiled/linked with -nostdlib. -// We don't need to know what's inside PyObject* anyways. We could just call it -// void* everywhere. There are two reasons to do this: -// 1. to improve readability -// 2. eventually when we are comfortable requiring wasm-gc, we can merge this -// into emscripten_trampoline.c without worrying about it. -typedef void PyObject; - -typedef PyObject* (*three_arg)(PyObject*, PyObject*, PyObject*); -typedef PyObject* (*two_arg)(PyObject*, PyObject*); -typedef PyObject* (*one_arg)(PyObject*); -typedef PyObject* (*zero_arg)(void); - -#define TRY_RETURN_CALL(ty, args...) \ - if (__builtin_wasm_test_function_pointer_signature((ty)func)) { \ - return ((ty)func)(args); \ - } - -__attribute__((export_name("trampoline_call"))) PyObject* -trampoline_call(int* success, - void* func, - PyObject* self, - PyObject* args, - PyObject* kw) -{ - *success = 1; - TRY_RETURN_CALL(three_arg, self, args, kw); - TRY_RETURN_CALL(two_arg, self, args); - TRY_RETURN_CALL(one_arg, self); - TRY_RETURN_CALL(zero_arg); - *success = 0; - return 0; -} diff --git a/Python/errors.c b/Python/errors.c index 48b03e5fd714b18..74fd2f0502f69c6 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -4,6 +4,7 @@ #include "Python.h" #include "pycore_audit.h" // _PySys_Audit() #include "pycore_call.h" // _PyObject_CallNoArgs() +#include "pycore_ceval.h" // _Py_ReachedRecursionLimitWithMargin() #include "pycore_fileutils.h" // _PyFile_Flush #include "pycore_initconfig.h" // _PyStatus_ERR() #include "pycore_pyerrors.h" // _PyErr_Format() @@ -13,6 +14,8 @@ #include "pycore_traceback.h" // _PyTraceBack_FromFrame() #include "pycore_unicodeobject.h" // _PyUnicode_Equal() +#include "../Parser/tokenizer/tokenizer.h" + #ifdef MS_WINDOWS # include # include @@ -151,7 +154,6 @@ void _PyErr_SetObject(PyThreadState *tstate, PyObject *exception, PyObject *value) { PyObject *exc_value; - PyObject *tb = NULL; if (exception != NULL && !PyExceptionClass_Check(exception)) { @@ -234,9 +236,8 @@ _PyErr_SetObject(PyThreadState *tstate, PyObject *exception, PyObject *value) } } assert(value != NULL); - if (PyExceptionInstance_Check(value)) - tb = PyException_GetTraceback(value); - _PyErr_Restore(tstate, Py_NewRef(Py_TYPE(value)), value, tb); + assert(PyExceptionInstance_Check(value)); + _PyErr_SetRaisedException(tstate, value); } void @@ -335,17 +336,27 @@ PyErr_GivenExceptionMatches(PyObject *err, PyObject *exc) return 0; } if (PyTuple_Check(exc)) { - Py_ssize_t i, n; - n = PyTuple_Size(exc); - for (i = 0; i < n; i++) { + PyThreadState *tstate = _PyThreadState_GET(); + if (_Py_ReachedRecursionLimitWithMargin(tstate, 2)) { + PyObject *exc_value = _PyErr_GetRaisedException(tstate); + _PyErr_SetString(tstate, PyExc_RecursionError, + "maximum recursion depth exceeded while " + "checking exception tuple"); + PyErr_FormatUnraisable("Exception ignored while " + "checking exception tuple"); + _PyErr_SetRaisedException(tstate, exc_value); + return 0; + } + int res = 0; + Py_ssize_t n = PyTuple_GET_SIZE(exc); + for (Py_ssize_t i = 0; i < n; i++) { /* Test recursively */ - if (PyErr_GivenExceptionMatches( - err, PyTuple_GET_ITEM(exc, i))) - { - return 1; - } + if (PyErr_GivenExceptionMatches(err, PyTuple_GET_ITEM(exc, i))) { + res = 1; + break; + } } - return 0; + return res; } /* err might be an instance, so check its class. */ if (PyExceptionInstance_Check(err)) @@ -829,8 +840,7 @@ PyErr_SetFromErrnoWithFilenameObjects(PyObject *exc, PyObject *filenameObject, P #ifndef MS_WINDOWS if (i != 0) { - const char *s = strerror(i); - message = PyUnicode_DecodeLocale(s, "surrogateescape"); + message = _Py_strerror(i); } else { /* Sometimes errno didn't get set */ @@ -2050,9 +2060,6 @@ PyErr_ProgramText(const char *filename, int lineno) return res; } -/* Function from Parser/tokenizer/file_tokenizer.c */ -extern char* _PyTokenizer_FindEncodingFilename(int, PyObject *); - PyObject * _PyErr_ProgramDecodedTextObject(PyObject *filename, int lineno, const char* encoding) { diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index e45bbd7cceb295f..5df8120e7424b93 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -4009,6 +4009,91 @@ break; } + case _GUARD_TOS_EXACT_INT_r01: { + CHECK_CURRENT_CACHED_VALUES(0); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + _PyStackRef value; + value = stack_pointer[-1]; + PyObject *value_o = PyStackRef_AsPyObjectBorrow(value); + if (!PyLong_CheckExact(value_o)) { + UOP_STAT_INC(uopcode, miss); + SET_CURRENT_CACHED_VALUES(0); + JUMP_TO_JUMP_TARGET(); + } + _tos_cache0 = value; + SET_CURRENT_CACHED_VALUES(1); + stack_pointer += -1; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + break; + } + + case _GUARD_TOS_EXACT_INT_r11: { + CHECK_CURRENT_CACHED_VALUES(1); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + _PyStackRef value; + _PyStackRef _stack_item_0 = _tos_cache0; + value = _stack_item_0; + PyObject *value_o = PyStackRef_AsPyObjectBorrow(value); + if (!PyLong_CheckExact(value_o)) { + UOP_STAT_INC(uopcode, miss); + _tos_cache0 = value; + SET_CURRENT_CACHED_VALUES(1); + JUMP_TO_JUMP_TARGET(); + } + _tos_cache0 = value; + SET_CURRENT_CACHED_VALUES(1); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + break; + } + + case _GUARD_TOS_EXACT_INT_r22: { + CHECK_CURRENT_CACHED_VALUES(2); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + _PyStackRef value; + _PyStackRef _stack_item_0 = _tos_cache0; + _PyStackRef _stack_item_1 = _tos_cache1; + value = _stack_item_1; + PyObject *value_o = PyStackRef_AsPyObjectBorrow(value); + if (!PyLong_CheckExact(value_o)) { + UOP_STAT_INC(uopcode, miss); + _tos_cache1 = value; + _tos_cache0 = _stack_item_0; + SET_CURRENT_CACHED_VALUES(2); + JUMP_TO_JUMP_TARGET(); + } + _tos_cache1 = value; + _tos_cache0 = _stack_item_0; + SET_CURRENT_CACHED_VALUES(2); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + break; + } + + case _GUARD_TOS_EXACT_INT_r33: { + CHECK_CURRENT_CACHED_VALUES(3); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + _PyStackRef value; + _PyStackRef _stack_item_0 = _tos_cache0; + _PyStackRef _stack_item_1 = _tos_cache1; + _PyStackRef _stack_item_2 = _tos_cache2; + value = _stack_item_2; + PyObject *value_o = PyStackRef_AsPyObjectBorrow(value); + if (!PyLong_CheckExact(value_o)) { + UOP_STAT_INC(uopcode, miss); + _tos_cache2 = value; + _tos_cache1 = _stack_item_1; + _tos_cache0 = _stack_item_0; + SET_CURRENT_CACHED_VALUES(3); + JUMP_TO_JUMP_TARGET(); + } + _tos_cache2 = value; + _tos_cache1 = _stack_item_1; + _tos_cache0 = _stack_item_0; + SET_CURRENT_CACHED_VALUES(3); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + break; + } + case _GUARD_NOS_OVERFLOWED_r02: { CHECK_CURRENT_CACHED_VALUES(0); ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); @@ -8792,11 +8877,13 @@ break; } - case _GET_ANEXT_r12: { + case _GET_ANEXT_r13: { CHECK_CURRENT_CACHED_VALUES(1); ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); _PyStackRef aiter; _PyStackRef awaitable; + _PyStackRef null; + _PyStackRef none; _PyStackRef _stack_item_0 = _tos_cache0; aiter = _stack_item_0; stack_pointer[0] = aiter; @@ -8811,21 +8898,23 @@ JUMP_TO_ERROR(); } awaitable = PyStackRef_FromPyObjectSteal(awaitable_o); - _tos_cache1 = awaitable; - _tos_cache0 = aiter; - _tos_cache2 = PyStackRef_ZERO_BITS; - SET_CURRENT_CACHED_VALUES(2); - stack_pointer += -1; - ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + null = PyStackRef_NULL; + none = PyStackRef_None; + _tos_cache2 = none; + _tos_cache1 = null; + _tos_cache0 = awaitable; + SET_CURRENT_CACHED_VALUES(3); ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); break; } - case _GET_AWAITABLE_r11: { + case _GET_AWAITABLE_r13: { CHECK_CURRENT_CACHED_VALUES(1); ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); _PyStackRef iterable; _PyStackRef iter; + _PyStackRef null; + _PyStackRef none; _PyStackRef _stack_item_0 = _tos_cache0; oparg = CURRENT_OPARG(); iterable = _stack_item_0; @@ -8847,10 +8936,12 @@ JUMP_TO_ERROR(); } iter = PyStackRef_FromPyObjectSteal(iter_o); + null = PyStackRef_NULL; + none = PyStackRef_None; + _tos_cache2 = none; + _tos_cache1 = null; _tos_cache0 = iter; - _tos_cache1 = PyStackRef_ZERO_BITS; - _tos_cache2 = PyStackRef_ZERO_BITS; - SET_CURRENT_CACHED_VALUES(1); + SET_CURRENT_CACHED_VALUES(3); ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); break; } @@ -9090,7 +9181,6 @@ SET_CURRENT_CACHED_VALUES(0); JUMP_TO_ERROR(); } - next = none; if (true) { UOP_STAT_INC(uopcode, miss); SET_CURRENT_CACHED_VALUES(0); @@ -9134,10 +9224,9 @@ SET_CURRENT_CACHED_VALUES(0); JUMP_TO_ERROR(); } - next = none; if (true) { UOP_STAT_INC(uopcode, miss); - _tos_cache0 = stack_pointer[0]; + _tos_cache0 = none; SET_CURRENT_CACHED_VALUES(1); JUMP_TO_JUMP_TARGET(); } @@ -9181,10 +9270,9 @@ SET_CURRENT_CACHED_VALUES(0); JUMP_TO_ERROR(); } - next = none; if (true) { UOP_STAT_INC(uopcode, miss); - _tos_cache1 = stack_pointer[1]; + _tos_cache1 = none; _tos_cache0 = null_or_index; SET_CURRENT_CACHED_VALUES(2); JUMP_TO_JUMP_TARGET(); @@ -9231,10 +9319,9 @@ SET_CURRENT_CACHED_VALUES(0); JUMP_TO_ERROR(); } - next = none; if (true) { UOP_STAT_INC(uopcode, miss); - _tos_cache2 = stack_pointer[2]; + _tos_cache2 = none; _tos_cache1 = null_or_index; _tos_cache0 = iter; SET_CURRENT_CACHED_VALUES(3); @@ -10098,55 +10185,77 @@ break; } - /* _LOAD_FROM_DICT_OR_GLOBALS is not a viable micro-op for tier 2 because it has both popping and not-popping errors */ - - case _LOAD_NAME_r01: { - CHECK_CURRENT_CACHED_VALUES(0); + case _LOAD_FROM_DICT_OR_GLOBALS_r11: { + CHECK_CURRENT_CACHED_VALUES(1); ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + _PyStackRef mod_or_class_dict; _PyStackRef v; + _PyStackRef _stack_item_0 = _tos_cache0; oparg = CURRENT_OPARG(); + mod_or_class_dict = _stack_item_0; PyObject *name = GETITEM(FRAME_CO_NAMES, oparg); + PyObject *namespace = PyStackRef_AsPyObjectBorrow(mod_or_class_dict); + int err; + stack_pointer[0] = mod_or_class_dict; + stack_pointer += 1; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); _PyFrame_StackPointerValidate(frame); - PyObject *v_o = _PyEval_LoadName(tstate, frame, name); + PyObject *v_o = _PyMapping_GetOptionalItem2(namespace, name, &err); _PyFrame_StackPointerInvalidate(frame); - if (v_o == NULL) { - SET_CURRENT_CACHED_VALUES(0); - JUMP_TO_ERROR(); - } - if (PyLazyImport_CheckExact(v_o)) { + if (v_o != NULL && PyLazyImport_CheckExact(v_o)) { assert(stack_pointer == _PyFrame_GetStackPointer(frame)); _PyFrame_StackPointerValidate(frame); - PyObject *l_v = _PyImport_LoadLazyImportTstate(tstate, v_o); + Py_SETREF(v_o, _PyLazyImport_Reify(tstate, v_o, name, namespace)); _PyFrame_StackPointerInvalidate(frame); - if (l_v == NULL) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_DECREF(v_o); - _PyFrame_StackPointerInvalidate(frame); - SET_CURRENT_CACHED_VALUES(0); - JUMP_TO_ERROR(); + if (v_o == NULL) { + err = -1; } + } + stack_pointer += -1; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + _PyFrame_SetStackPointer(frame, stack_pointer); + _PyFrame_StackPointerValidate(frame); + PyStackRef_CLOSE(mod_or_class_dict); + _PyFrame_StackPointerInvalidate(frame); + if (err < 0) { + SET_CURRENT_CACHED_VALUES(0); + JUMP_TO_ERROR(); + } + if (v_o == NULL) { assert(stack_pointer == _PyFrame_GetStackPointer(frame)); _PyFrame_StackPointerValidate(frame); - int err = PyDict_SetItem(GLOBALS(), name, l_v); + _PyEval_LoadGlobalStackRef(GLOBALS(), BUILTINS(), name, &v); _PyFrame_StackPointerInvalidate(frame); - if (err < 0) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_DECREF(v_o); - _PyFrame_StackPointerInvalidate(frame); - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_DECREF(l_v); - _PyFrame_StackPointerInvalidate(frame); + if (PyStackRef_IsNull(v)) { SET_CURRENT_CACHED_VALUES(0); JUMP_TO_ERROR(); } - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_SETREF(v_o, l_v); - _PyFrame_StackPointerInvalidate(frame); + } + else { + v = PyStackRef_FromPyObjectSteal(v_o); + } + _tos_cache0 = v; + _tos_cache1 = PyStackRef_ZERO_BITS; + _tos_cache2 = PyStackRef_ZERO_BITS; + SET_CURRENT_CACHED_VALUES(1); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + break; + } + + case _LOAD_NAME_r01: { + CHECK_CURRENT_CACHED_VALUES(0); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + _PyStackRef v; + oparg = CURRENT_OPARG(); + PyObject *name = GETITEM(FRAME_CO_NAMES, oparg); + _PyFrame_SetStackPointer(frame, stack_pointer); + _PyFrame_StackPointerValidate(frame); + PyObject *v_o = _PyEval_LoadName(tstate, frame, name); + _PyFrame_StackPointerInvalidate(frame); + if (v_o == NULL) { + SET_CURRENT_CACHED_VALUES(0); + JUMP_TO_ERROR(); } v = PyStackRef_FromPyObjectSteal(v_o); _tos_cache0 = v; @@ -10337,7 +10446,7 @@ SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); } - #if Py_GIL_DISABLED + #ifdef Py_GIL_DISABLED int increfed = _Py_TryIncrefCompareStackRef(&entries[index].me_value, res_o, &res); if (!increfed) { UOP_STAT_INC(uopcode, miss); @@ -10382,7 +10491,7 @@ SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); } - #if Py_GIL_DISABLED + #ifdef Py_GIL_DISABLED int increfed = _Py_TryIncrefCompareStackRef(&entries[index].me_value, res_o, &res); if (!increfed) { UOP_STAT_INC(uopcode, miss); @@ -10401,6 +10510,76 @@ break; } + case _GUARD_BUILTINS_IS_CANONICAL_r00: { + CHECK_CURRENT_CACHED_VALUES(0); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + if (BUILTINS() != tstate->interp->builtins) { + UOP_STAT_INC(uopcode, miss); + SET_CURRENT_CACHED_VALUES(0); + JUMP_TO_JUMP_TARGET(); + } + SET_CURRENT_CACHED_VALUES(0); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + break; + } + + case _GUARD_BUILTINS_IS_CANONICAL_r11: { + CHECK_CURRENT_CACHED_VALUES(1); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + _PyStackRef _stack_item_0 = _tos_cache0; + if (BUILTINS() != tstate->interp->builtins) { + UOP_STAT_INC(uopcode, miss); + _tos_cache0 = _stack_item_0; + SET_CURRENT_CACHED_VALUES(1); + JUMP_TO_JUMP_TARGET(); + } + _tos_cache0 = _stack_item_0; + SET_CURRENT_CACHED_VALUES(1); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + break; + } + + case _GUARD_BUILTINS_IS_CANONICAL_r22: { + CHECK_CURRENT_CACHED_VALUES(2); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + _PyStackRef _stack_item_0 = _tos_cache0; + _PyStackRef _stack_item_1 = _tos_cache1; + if (BUILTINS() != tstate->interp->builtins) { + UOP_STAT_INC(uopcode, miss); + _tos_cache1 = _stack_item_1; + _tos_cache0 = _stack_item_0; + SET_CURRENT_CACHED_VALUES(2); + JUMP_TO_JUMP_TARGET(); + } + _tos_cache1 = _stack_item_1; + _tos_cache0 = _stack_item_0; + SET_CURRENT_CACHED_VALUES(2); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + break; + } + + case _GUARD_BUILTINS_IS_CANONICAL_r33: { + CHECK_CURRENT_CACHED_VALUES(3); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + _PyStackRef _stack_item_0 = _tos_cache0; + _PyStackRef _stack_item_1 = _tos_cache1; + _PyStackRef _stack_item_2 = _tos_cache2; + if (BUILTINS() != tstate->interp->builtins) { + UOP_STAT_INC(uopcode, miss); + _tos_cache2 = _stack_item_2; + _tos_cache1 = _stack_item_1; + _tos_cache0 = _stack_item_0; + SET_CURRENT_CACHED_VALUES(3); + JUMP_TO_JUMP_TARGET(); + } + _tos_cache2 = _stack_item_2; + _tos_cache1 = _stack_item_1; + _tos_cache0 = _stack_item_0; + SET_CURRENT_CACHED_VALUES(3); + ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); + break; + } + case _DELETE_FAST_r00: { CHECK_CURRENT_CACHED_VALUES(0); ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); @@ -10518,6 +10697,17 @@ JUMP_TO_ERROR(); } } + else if (PyLazyImport_CheckExact(value_o)) { + assert(stack_pointer == _PyFrame_GetStackPointer(frame)); + _PyFrame_StackPointerValidate(frame); + Py_SETREF(value_o, _PyLazyImport_Reify( + tstate, value_o, name, class_dict)); + _PyFrame_StackPointerInvalidate(frame); + if (value_o == NULL) { + SET_CURRENT_CACHED_VALUES(0); + JUMP_TO_ERROR(); + } + } stack_pointer += -1; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); @@ -12239,7 +12429,7 @@ uint32_t dict_version = (uint32_t)CURRENT_OPERAND0_32(); uint16_t index = (uint16_t)CURRENT_OPERAND1_16(); PyObject *owner_o = PyStackRef_AsPyObjectBorrow(owner); - if (Py_TYPE(owner_o)->tp_getattro != PyModule_Type.tp_getattro) { + if (!PyModule_CheckExact(owner_o)) { UOP_STAT_INC(uopcode, miss); _tos_cache0 = owner; SET_CURRENT_CACHED_VALUES(1); @@ -14731,20 +14921,20 @@ break; } - case _GUARD_TYPE_ITER_r02: { + case _GUARD_NOS_TYPE_r02: { CHECK_CURRENT_CACHED_VALUES(0); ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); - _PyStackRef iter; - iter = stack_pointer[-2]; + _PyStackRef nos; + nos = stack_pointer[-2]; PyObject *expected_type = (PyObject *)CURRENT_OPERAND0_64(); - PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter); - if (Py_TYPE(iter_o) != (PyTypeObject *)expected_type) { + PyObject *nos_o = PyStackRef_AsPyObjectBorrow(nos); + if (Py_TYPE(nos_o) != (PyTypeObject *)expected_type) { UOP_STAT_INC(uopcode, miss); SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); } _tos_cache1 = stack_pointer[-1]; - _tos_cache0 = iter; + _tos_cache0 = nos; SET_CURRENT_CACHED_VALUES(2); stack_pointer += -2; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); @@ -14752,22 +14942,22 @@ break; } - case _GUARD_TYPE_ITER_r12: { + case _GUARD_NOS_TYPE_r12: { CHECK_CURRENT_CACHED_VALUES(1); ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); - _PyStackRef iter; + _PyStackRef nos; _PyStackRef _stack_item_0 = _tos_cache0; - iter = stack_pointer[-1]; + nos = stack_pointer[-1]; PyObject *expected_type = (PyObject *)CURRENT_OPERAND0_64(); - PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter); - if (Py_TYPE(iter_o) != (PyTypeObject *)expected_type) { + PyObject *nos_o = PyStackRef_AsPyObjectBorrow(nos); + if (Py_TYPE(nos_o) != (PyTypeObject *)expected_type) { UOP_STAT_INC(uopcode, miss); _tos_cache0 = _stack_item_0; SET_CURRENT_CACHED_VALUES(1); JUMP_TO_JUMP_TARGET(); } _tos_cache1 = _stack_item_0; - _tos_cache0 = iter; + _tos_cache0 = nos; SET_CURRENT_CACHED_VALUES(2); stack_pointer += -1; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); @@ -14775,49 +14965,49 @@ break; } - case _GUARD_TYPE_ITER_r22: { + case _GUARD_NOS_TYPE_r22: { CHECK_CURRENT_CACHED_VALUES(2); ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); - _PyStackRef iter; + _PyStackRef nos; _PyStackRef _stack_item_0 = _tos_cache0; _PyStackRef _stack_item_1 = _tos_cache1; - iter = _stack_item_0; + nos = _stack_item_0; PyObject *expected_type = (PyObject *)CURRENT_OPERAND0_64(); - PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter); - if (Py_TYPE(iter_o) != (PyTypeObject *)expected_type) { + PyObject *nos_o = PyStackRef_AsPyObjectBorrow(nos); + if (Py_TYPE(nos_o) != (PyTypeObject *)expected_type) { UOP_STAT_INC(uopcode, miss); _tos_cache1 = _stack_item_1; - _tos_cache0 = iter; + _tos_cache0 = nos; SET_CURRENT_CACHED_VALUES(2); JUMP_TO_JUMP_TARGET(); } _tos_cache1 = _stack_item_1; - _tos_cache0 = iter; + _tos_cache0 = nos; SET_CURRENT_CACHED_VALUES(2); ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); break; } - case _GUARD_TYPE_ITER_r33: { + case _GUARD_NOS_TYPE_r33: { CHECK_CURRENT_CACHED_VALUES(3); ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); - _PyStackRef iter; + _PyStackRef nos; _PyStackRef _stack_item_0 = _tos_cache0; _PyStackRef _stack_item_1 = _tos_cache1; _PyStackRef _stack_item_2 = _tos_cache2; - iter = _stack_item_1; + nos = _stack_item_1; PyObject *expected_type = (PyObject *)CURRENT_OPERAND0_64(); - PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter); - if (Py_TYPE(iter_o) != (PyTypeObject *)expected_type) { + PyObject *nos_o = PyStackRef_AsPyObjectBorrow(nos); + if (Py_TYPE(nos_o) != (PyTypeObject *)expected_type) { UOP_STAT_INC(uopcode, miss); _tos_cache2 = _stack_item_2; - _tos_cache1 = iter; + _tos_cache1 = nos; _tos_cache0 = _stack_item_0; SET_CURRENT_CACHED_VALUES(3); JUMP_TO_JUMP_TARGET(); } _tos_cache2 = _stack_item_2; - _tos_cache1 = iter; + _tos_cache1 = nos; _tos_cache0 = _stack_item_0; SET_CURRENT_CACHED_VALUES(3); ASSERT_WITHIN_STACK_BOUNDS_IGNORING_CACHE(__FILE__, __LINE__); @@ -16139,7 +16329,8 @@ PyObject *name = _Py_SpecialMethods[oparg].name; _PyFrame_SetStackPointer(frame, stack_pointer); _PyFrame_StackPointerValidate(frame); - int err = _PyObject_LookupSpecialMethod(name, method_and_self); + int err = _PyObject_LookupSpecialMethod(name, &method_and_self[0], + &method_and_self[1]); _PyFrame_StackPointerInvalidate(frame); if (err <= 0) { if (err == 0) { @@ -18280,7 +18471,8 @@ SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); } - if (PyCFunction_GET_FLAGS(callable_o) != METH_O) { + if ((PyCFunction_GET_FLAGS(callable_o) & + _Py_METH_CALL_FLAGS) != METH_O) { UOP_STAT_INC(uopcode, miss); SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); @@ -18354,7 +18546,8 @@ SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); } - if (PyCFunction_GET_FLAGS(callable_o) != METH_FASTCALL) { + if ((PyCFunction_GET_FLAGS(callable_o) & + _Py_METH_CALL_FLAGS) != METH_FASTCALL) { UOP_STAT_INC(uopcode, miss); SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); @@ -18420,7 +18613,8 @@ SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); } - if (PyCFunction_GET_FLAGS(callable_o) != (METH_FASTCALL | METH_KEYWORDS)) { + if ((PyCFunction_GET_FLAGS(callable_o) & + _Py_METH_CALL_FLAGS) != (METH_FASTCALL | METH_KEYWORDS)) { UOP_STAT_INC(uopcode, miss); SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); @@ -18895,6 +19089,22 @@ int err = _PyList_AppendTakeRef((PyListObject *)self_o, PyStackRef_AsPyObjectSteal(arg)); UNLOCK_OBJECT(self_o); if (err) { + _PyFrame_SetStackPointer(frame, stack_pointer); + _PyFrame_StackPointerValidate(frame); + _PyStackRef tmp = self; + self = PyStackRef_NULL; + stack_pointer[-2] = self; + PyStackRef_CLOSE(tmp); + _PyFrame_StackPointerInvalidate(frame); + assert(stack_pointer == _PyFrame_GetStackPointer(frame)); + _PyFrame_StackPointerValidate(frame); + tmp = callable; + callable = PyStackRef_NULL; + stack_pointer[-3] = callable; + PyStackRef_CLOSE(tmp); + _PyFrame_StackPointerInvalidate(frame); + stack_pointer += -3; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); SET_CURRENT_CACHED_VALUES(0); JUMP_TO_ERROR(); } @@ -18937,7 +19147,21 @@ int err = _PyList_AppendTakeRef((PyListObject *)self_o, PyStackRef_AsPyObjectSteal(arg)); UNLOCK_OBJECT(self_o); if (err) { - stack_pointer += 1; + _PyFrame_SetStackPointer(frame, stack_pointer); + _PyFrame_StackPointerValidate(frame); + _PyStackRef tmp = self; + self = PyStackRef_NULL; + stack_pointer[-1] = self; + PyStackRef_CLOSE(tmp); + _PyFrame_StackPointerInvalidate(frame); + assert(stack_pointer == _PyFrame_GetStackPointer(frame)); + _PyFrame_StackPointerValidate(frame); + tmp = callable; + callable = PyStackRef_NULL; + stack_pointer[-2] = callable; + PyStackRef_CLOSE(tmp); + _PyFrame_StackPointerInvalidate(frame); + stack_pointer += -2; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); SET_CURRENT_CACHED_VALUES(0); JUMP_TO_ERROR(); @@ -18983,8 +19207,21 @@ int err = _PyList_AppendTakeRef((PyListObject *)self_o, PyStackRef_AsPyObjectSteal(arg)); UNLOCK_OBJECT(self_o); if (err) { + _PyFrame_SetStackPointer(frame, stack_pointer); + _PyFrame_StackPointerValidate(frame); + _PyStackRef tmp = self; + self = PyStackRef_NULL; stack_pointer[0] = self; - stack_pointer += 2; + PyStackRef_CLOSE(tmp); + _PyFrame_StackPointerInvalidate(frame); + assert(stack_pointer == _PyFrame_GetStackPointer(frame)); + _PyFrame_StackPointerValidate(frame); + tmp = callable; + callable = PyStackRef_NULL; + stack_pointer[-1] = callable; + PyStackRef_CLOSE(tmp); + _PyFrame_StackPointerInvalidate(frame); + stack_pointer += -1; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); SET_CURRENT_CACHED_VALUES(0); JUMP_TO_ERROR(); @@ -19032,10 +19269,21 @@ int err = _PyList_AppendTakeRef((PyListObject *)self_o, PyStackRef_AsPyObjectSteal(arg)); UNLOCK_OBJECT(self_o); if (err) { + _PyFrame_SetStackPointer(frame, stack_pointer); + _PyFrame_StackPointerValidate(frame); + _PyStackRef tmp = self; + self = PyStackRef_NULL; stack_pointer[0] = callable; stack_pointer[1] = self; - stack_pointer += 3; - ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + PyStackRef_CLOSE(tmp); + _PyFrame_StackPointerInvalidate(frame); + assert(stack_pointer == _PyFrame_GetStackPointer(frame)); + _PyFrame_StackPointerValidate(frame); + tmp = callable; + callable = PyStackRef_NULL; + stack_pointer[0] = callable; + PyStackRef_CLOSE(tmp); + _PyFrame_StackPointerInvalidate(frame); SET_CURRENT_CACHED_VALUES(0); JUMP_TO_ERROR(); } @@ -19067,7 +19315,8 @@ SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); } - if (method->d_method->ml_flags != METH_O) { + if ((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + METH_O) { UOP_STAT_INC(uopcode, miss); SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); @@ -19272,7 +19521,8 @@ SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); } - if (method->d_method->ml_flags != (METH_FASTCALL|METH_KEYWORDS)) { + if ((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + (METH_FASTCALL | METH_KEYWORDS)) { UOP_STAT_INC(uopcode, miss); SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); @@ -19416,7 +19666,8 @@ SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); } - if (method->d_method->ml_flags != METH_NOARGS) { + if ((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + METH_NOARGS) { UOP_STAT_INC(uopcode, miss); SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); @@ -19545,7 +19796,8 @@ SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); } - if (method->d_method->ml_flags != METH_FASTCALL) { + if ((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + METH_FASTCALL) { UOP_STAT_INC(uopcode, miss); SET_CURRENT_CACHED_VALUES(0); JUMP_TO_JUMP_TARGET(); @@ -23789,6 +24041,14 @@ if (target->op.code == ENTER_EXECUTOR) { PyCodeObject *code = _PyFrame_GetCode(frame); executor = code->co_executors->executors[target->op.arg]; + if (executor == _PyExecutor_FromExit(exit)) { + _PyFrame_SetStackPointer(frame, stack_pointer); + _PyFrame_StackPointerValidate(frame); + _Py_ExecutorDetach(executor); + _PyFrame_StackPointerInvalidate(frame); + SET_CURRENT_CACHED_VALUES(0); + GOTO_TIER_ONE(target); + } Py_INCREF(executor); assert(tstate->jit_exit == exit); exit->executor = executor; diff --git a/Python/fileutils.c b/Python/fileutils.c index 98ed66eff94ee10..3ea0f59f69ad1ef 100644 --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -51,13 +51,19 @@ extern int winerror_to_errno(int); int _Py_open_cloexec_works = -1; #endif +// wcstombs() error +static const size_t ENCODE_ERROR = (size_t)-1; // mbstowcs() and mbrtowc() errors -static const size_t DECODE_ERROR = ((size_t)-1); +static const size_t DECODE_ERROR = (size_t)-1; #ifdef HAVE_MBRTOWC static const size_t INCOMPLETE_CHARACTER = (size_t)-2; #endif +// Get the error handler as 'int surrogateescape'. +// Set '*surrogateescape' and return 0 on success. +// Return -1 if the error handler is not supported: other than "strict" and +// "surrogateescape". static int get_surrogateescape(_Py_error_handler errors, int *surrogateescape) { @@ -78,34 +84,59 @@ get_surrogateescape(_Py_error_handler errors, int *surrogateescape) PyObject * _Py_device_encoding(int fd) { - int valid; - Py_BEGIN_ALLOW_THREADS +#if defined(MS_WINDOWS) && defined(HAVE_WINDOWS_CONSOLE_IO) + HANDLE handle; + DWORD temp; + UINT cp = 0; + _Py_BEGIN_SUPPRESS_IPH - valid = isatty(fd); + handle = (HANDLE)_get_osfhandle(fd); _Py_END_SUPPRESS_IPH - Py_END_ALLOW_THREADS - if (!valid) + if (handle == INVALID_HANDLE_VALUE) { Py_RETURN_NONE; + } + + Py_BEGIN_ALLOW_THREADS + if (GetFileType(handle) == FILE_TYPE_CHAR) { + /* GetConsoleMode() only succeeds for a console handle. */ + if (!GetConsoleMode(handle, &temp)) { + /* Assume that access denied implies an output handle. */ + if (GetLastError() == ERROR_ACCESS_DENIED) { + cp = GetConsoleOutputCP(); + } + } + else if (GetNumberOfConsoleInputEvents(handle, &temp)) { + cp = GetConsoleCP(); + } + else { + cp = GetConsoleOutputCP(); + } + } + Py_END_ALLOW_THREADS -#ifdef MS_WINDOWS -#ifdef HAVE_WINDOWS_CONSOLE_IO - UINT cp; - if (fd == 0) - cp = GetConsoleCP(); - else if (fd == 1 || fd == 2) - cp = GetConsoleOutputCP(); - else - cp = 0; /* GetConsoleCP() and GetConsoleOutputCP() return 0 if the application has no console */ + if (cp == CP_UTF8) { + _Py_DECLARE_STR(utf_8, "utf-8"); + return &_Py_STR(utf_8); + } if (cp == 0) { Py_RETURN_NONE; } - return PyUnicode_FromFormat("cp%u", (unsigned int)cp); #else + int valid; + Py_BEGIN_ALLOW_THREADS + _Py_BEGIN_SUPPRESS_IPH + valid = isatty(fd); + _Py_END_SUPPRESS_IPH + Py_END_ALLOW_THREADS + if (!valid) { + Py_RETURN_NONE; + } + +#ifdef MS_WINDOWS Py_RETURN_NONE; -#endif /* HAVE_WINDOWS_CONSOLE_IO */ #else if (_PyRuntime.preconfig.utf8_mode) { _Py_DECLARE_STR(utf_8, "utf-8"); @@ -113,6 +144,7 @@ _Py_device_encoding(int fd) } return _Py_GetLocaleEncodingObject(); #endif +#endif /* MS_WINDOWS && HAVE_WINDOWS_CONSOLE_IO */ } @@ -201,8 +233,7 @@ extern int _Py_normalize_encoding(const char *, char *, size_t, int); Values of force_ascii: 1: the workaround is used: Py_EncodeLocale() uses - encode_ascii_surrogateescape() and Py_DecodeLocale() uses - decode_ascii() + encode_ascii() and Py_DecodeLocale() uses decode_ascii() 0: the workaround is not used: Py_EncodeLocale() uses wcstombs() and Py_DecodeLocale() uses mbstowcs() -1: unknown, need to call check_force_ascii() to get the value @@ -327,36 +358,41 @@ _Py_ResetForceASCII(void) } +// Encode a wide string to the ASCII encoding. If errors is +// _Py_ERROR_SURROGATEESCAPE, handle non-ASCII character using the +// surrogateescape error handler. In that case, the output is non-ASCII. +// +// Set *str to a newly allocated string on success. +// Return a negative number on error: _Py_CODEC_MEMORY_ERROR, +// _Py_CODEC_ENCODE_ERROR or _Py_CODEC_UNSUPPORTED_ERROR_HANDLER. +// +// str and output_length must not be NULL static int -encode_ascii(const wchar_t *text, char **str, - size_t *error_pos, const char **reason, - int raw_malloc, _Py_error_handler errors) +encode_ascii(const wchar_t *text, char **str, size_t *output_length, + size_t *error_pos, int raw_malloc, _Py_error_handler errors) { - char *result = NULL, *out; - size_t len, i; - wchar_t ch; + assert(str != NULL); + assert(output_length != NULL); int surrogateescape; if (get_surrogateescape(errors, &surrogateescape) < 0) { - return -3; + // Only support "strict" and "surrogateescape" + return _Py_CODEC_UNSUPPORTED_ERROR_HANDLER; } - len = wcslen(text); + size_t len = wcslen(text); + *output_length = len; /* +1 for NULL byte */ - if (raw_malloc) { - result = PyMem_RawMalloc(len + 1); - } - else { - result = PyMem_Malloc(len + 1); - } + char *result; + result = raw_malloc ? PyMem_RawMalloc(len + 1) : PyMem_Malloc(len + 1); if (result == NULL) { - return -1; + return _Py_CODEC_MEMORY_ERROR; } - out = result; - for (i=0; i PY_SSIZE_T_MAX / sizeof(wchar_t)) { - return -1; + return _Py_CODEC_MEMORY_ERROR; } res = PyMem_RawMalloc(argsize * sizeof(wchar_t)); if (!res) { - return -1; + return _Py_CODEC_MEMORY_ERROR; } out = res; for (in = (unsigned char*)arg; *in; in++) { unsigned char ch = *in; - if (ch < 128) { + if (ch <= 127) { *out++ = ch; } else { @@ -436,10 +483,7 @@ decode_ascii(const char *arg, wchar_t **wstr, size_t *wlen, if (wlen) { *wlen = in - (unsigned char*)arg; } - if (reason) { - *reason = "decoding error"; - } - return -2; + return _Py_CODEC_DECODE_ERROR; } *out++ = 0xdc00 + ch; } @@ -454,22 +498,22 @@ decode_ascii(const char *arg, wchar_t **wstr, size_t *wlen, } #endif /* !HAVE_MBRTOWC */ +// Decode a bytes string from the current locale encoding. +// On success, set *wstr and *wlen (if set) and return 0. +// On error, return a negative number: _Py_CODEC_MEMORY_ERROR, +// _Py_CODEC_DECODE_ERROR or _Py_CODEC_UNSUPPORTED_ERROR_HANDLER. +// On decode, set *wlen (if set). static int decode_current_locale(const char* arg, wchar_t **wstr, size_t *wlen, - const char **reason, _Py_error_handler errors) + _Py_error_handler errors) { - wchar_t *res; - size_t argsize; - size_t count; -#ifdef HAVE_MBRTOWC - unsigned char *in; - wchar_t *out; - mbstate_t mbs; -#endif + assert(arg != NULL); + assert(wstr != NULL); int surrogateescape; if (get_surrogateescape(errors, &surrogateescape) < 0) { - return -3; + // Only support "strict" and "surrogateescape" + return _Py_CODEC_UNSUPPORTED_ERROR_HANDLER; } #ifdef HAVE_BROKEN_MBSTOWCS @@ -477,21 +521,31 @@ decode_current_locale(const char* arg, wchar_t **wstr, size_t *wlen, * mbstowcs which does not count the characters that * would result from conversion. Use an upper bound. */ - argsize = strlen(arg); + size_t argsize = strlen(arg); #else - argsize = _Py_mbstowcs(NULL, arg, 0); + size_t argsize = _Py_mbstowcs(NULL, arg, 0); #endif + wchar_t *res; if (argsize != DECODE_ERROR) { if (argsize > PY_SSIZE_T_MAX / sizeof(wchar_t) - 1) { - return -1; + return _Py_CODEC_MEMORY_ERROR; } res = (wchar_t *)PyMem_RawMalloc((argsize + 1) * sizeof(wchar_t)); if (!res) { - return -1; + return _Py_CODEC_MEMORY_ERROR; } - count = _Py_mbstowcs(res, arg, argsize + 1); + // +1 to write also the trailing NUL character + size_t count = _Py_mbstowcs(res, arg, argsize + 1); if (count != DECODE_ERROR) { + // String decoded successfully. + + // gh-158893: This assertion can fail if the input string was + // mutated during this function call. For example, the assertion + // fails on decoding strerror() result if another thread mutated + // the string in-place by calling strerror() in parallel. + assert(count == argsize); + *wstr = res; if (wlen != NULL) { *wlen = count; @@ -509,15 +563,16 @@ decode_current_locale(const char* arg, wchar_t **wstr, size_t *wlen, actual output could use less memory. */ argsize = strlen(arg) + 1; if (argsize > PY_SSIZE_T_MAX / sizeof(wchar_t)) { - return -1; + return _Py_CODEC_MEMORY_ERROR; } res = (wchar_t*)PyMem_RawMalloc(argsize * sizeof(wchar_t)); if (!res) { - return -1; + return _Py_CODEC_MEMORY_ERROR; } - in = (unsigned char*)arg; - out = res; + unsigned char *in = (unsigned char*)arg; + wchar_t *out = res; + mbstate_t mbs; memset(&mbs, 0, sizeof mbs); while (argsize) { size_t converted = _Py_mbrtowc(out, (char*)in, argsize, &mbs); @@ -549,6 +604,7 @@ decode_current_locale(const char* arg, wchar_t **wstr, size_t *wlen, } if (wlen != NULL) { *wlen = out - res; + assert(res[*wlen] == 0); } *wstr = res; return 0; @@ -558,66 +614,37 @@ decode_current_locale(const char* arg, wchar_t **wstr, size_t *wlen, if (wlen) { *wlen = in - (unsigned char*)arg; } - if (reason) { - *reason = "decoding error"; - } - return -2; + return _Py_CODEC_DECODE_ERROR; #else /* HAVE_MBRTOWC */ /* Cannot use C locale for escaping; manually escape as if charset is ASCII (i.e. escape all bytes > 128. This will still roundtrip correctly in the locale's charset, which must be an ASCII superset. */ - return decode_ascii(arg, wstr, wlen, reason, errors); + return decode_ascii(arg, wstr, wlen, errors); #endif /* HAVE_MBRTOWC */ } -/* Decode a byte string from the locale encoding. - - Use the strict error handler if 'surrogateescape' is zero. Use the - surrogateescape error handler if 'surrogateescape' is non-zero: undecodable - bytes are decoded as characters in range U+DC80..U+DCFF. If a byte sequence - can be decoded as a surrogate character, escape the bytes using the - surrogateescape error handler instead of decoding them. - - On success, return 0 and write the newly allocated wide character string into - *wstr (use PyMem_RawFree() to free the memory). If wlen is not NULL, write - the number of wide characters excluding the null character into *wlen. - - On memory allocation failure, return -1. - - On decoding error, return -2. If wlen is not NULL, write the start of - invalid byte sequence in the input string into *wlen. If reason is not NULL, - write the decoding error message into *reason. - - Return -3 if the error handler 'errors' is not supported. - - Use the Py_EncodeLocaleEx() function to encode the character string back to - a byte string. */ -int -_Py_DecodeLocaleEx(const char* arg, wchar_t **wstr, size_t *wlen, - const char **reason, +static int +decode_locale_impl(const char* arg, wchar_t **wstr, size_t *wlen, int current_locale, _Py_error_handler errors) { if (current_locale) { #ifdef _Py_FORCE_UTF8_LOCALE - return _Py_DecodeUTF8Ex(arg, strlen(arg), wstr, wlen, reason, - errors); + return _Py_DecodeUTF8(arg, strlen(arg), wstr, wlen, errors); #else - return decode_current_locale(arg, wstr, wlen, reason, errors); + return decode_current_locale(arg, wstr, wlen, errors); #endif } #ifdef _Py_FORCE_UTF8_FS_ENCODING - return _Py_DecodeUTF8Ex(arg, strlen(arg), wstr, wlen, reason, - errors); + return _Py_DecodeUTF8(arg, strlen(arg), wstr, wlen, errors); #else int use_utf8 = (_PyRuntime.preconfig.utf8_mode >= 1); #ifdef MS_WINDOWS use_utf8 |= (_PyRuntime.preconfig.legacy_windows_fs_encoding == 0); #endif if (use_utf8) { - return _Py_DecodeUTF8Ex(arg, strlen(arg), wstr, wlen, reason, - errors); + return _Py_DecodeUTF8(arg, strlen(arg), wstr, wlen, errors); } #ifdef USE_FORCE_ASCII @@ -627,45 +654,118 @@ _Py_DecodeLocaleEx(const char* arg, wchar_t **wstr, size_t *wlen, if (force_ascii) { /* force ASCII encoding to workaround mbstowcs() issue */ - return decode_ascii(arg, wstr, wlen, reason, errors); + return decode_ascii(arg, wstr, wlen, errors); } #endif - return decode_current_locale(arg, wstr, wlen, reason, errors); + return decode_current_locale(arg, wstr, wlen, errors); #endif /* !_Py_FORCE_UTF8_FS_ENCODING */ } -/* Decode a byte string from the locale encoding with the - surrogateescape error handler: undecodable bytes are decoded as characters - in range U+DC80..U+DCFF. If a byte sequence can be decoded as a surrogate - character, escape the bytes using the surrogateescape error handler instead - of decoding them. +// Decode a byte string from the locale encoding. +// +// Supported error handlers are _Py_ERROR_STRICT and _Py_ERROR_SURROGATEESCAPE. +// The UTF-8 decoder also supports _Py_ERROR_SURROGATEPASS. +// +// If errors is _Py_ERROR_SURROGATEESCAPE, undecodable bytes are decoded as +// characters in range U+DC80..U+DCFF. If a byte sequence can be decoded as a +// surrogate character, escape the bytes using the surrogateescape error +// handler instead of decoding them. +// +// On success, return 0 and write the newly allocated wide character string into +// *wstr (use PyMem_RawFree() to free the memory). If wlen is not NULL, write +// the number of wide characters excluding the null character into *wlen. +// +// On error, return a negative number. +// +// On memory allocation failure, return _Py_CODEC_MEMORY_ERROR. +// +// On decoding error, return _Py_CODEC_DECODE_ERROR. If wlen is not NULL, +// write the start of invalid byte sequence in the input string into *wlen. If +// reason is not NULL, write the decoding error message into *reason. +// +// Return _Py_CODEC_UNSUPPORTED_ERROR_HANDLER if the 'errors' error +// handler is not supported: other than "strict" and "surrogateescape". +// +// Use the _Py_EncodeLocale() function to encode the character string back to +// a byte string. +// +// arg and wstr must not be NULL. +int +_Py_DecodeLocale(const char* arg, wchar_t **wstr, size_t *wlen, + int current_locale, _Py_error_handler errors) +{ + assert(arg != NULL); + assert(wstr != NULL); - Return a pointer to a newly allocated wide character string, use - PyMem_RawFree() to free the memory. If size is not NULL, write the number of - wide characters excluding the null character into *size +#ifdef Py_DEBUG + size_t arglen = strlen(arg); + size_t wlen_canary = (size_t)-2; + if (wlen) { + *wlen = wlen_canary; + } +#endif - Return NULL on decoding error or memory allocation error. If *size* is not - NULL, *size is set to (size_t)-1 on memory error or set to (size_t)-2 on - decoding error. + int res = decode_locale_impl(arg, wstr, wlen, current_locale, errors); + if (res < 0) { + // Error + *wstr = NULL; + if (res == _Py_CODEC_DECODE_ERROR) { +#ifdef Py_DEBUG + assert(wlen == NULL || *wlen != wlen_canary); +#endif + } + else { + if (wlen) { + *wlen = 0; + } + } + } + else { + // Success + assert(*wstr != NULL); +#ifdef Py_DEBUG + // gh-158893: Detect if the input string was mutated during the + // function call. For example, the assertion fails on decoding + // strerror() result if another thread mutated the string in-place by + // calling strerror() in parallel. + assert(strlen(arg) == arglen); + if (wlen != NULL) { + assert(*wlen == wcslen(*wstr)); + } +#endif + } + return res; +} - Decoding errors should never happen, unless there is a bug in the C - library. - Use the Py_EncodeLocale() function to encode the character string back to a - byte string. */ +// Decode a byte string from the locale encoding with the +// surrogateescape error handler. Undecodable bytes are decoded as characters +// in range U+DC80..U+DCFF. If a byte sequence can be decoded as a surrogate +// character, escape the bytes using the surrogateescape error handler instead +// of decoding them. +// +// Return a pointer to a newly allocated wide character string, use +// PyMem_RawFree() to free the memory. If size is not NULL, write the number of +// wide characters excluding the null character into *size. +// +// On memory allocation failure, set *size to (size_t)-1 and return NULL. +// +// On decode error, set *size to (size_t)-2 and return NULL. +// Decoding errors should never happen, unless there is a bug in the C library. +// +// Use the Py_EncodeLocale() function to encode the character string back to a +// byte string. wchar_t* -Py_DecodeLocale(const char* arg, size_t *wlen) +Py_DecodeLocale(const char* arg, size_t *size) { wchar_t *wstr; - int res = _Py_DecodeLocaleEx(arg, &wstr, wlen, - NULL, 0, - _Py_ERROR_SURROGATEESCAPE); + int res = _Py_DecodeLocale(arg, &wstr, size, 0, _Py_ERROR_SURROGATEESCAPE); if (res != 0) { - assert(res != -3); - if (wlen != NULL) { - *wlen = (size_t)res; + assert(res == _Py_CODEC_MEMORY_ERROR || res == _Py_CODEC_DECODE_ERROR); + if (size != NULL) { + *size = (size_t)res; } return NULL; } @@ -673,143 +773,154 @@ Py_DecodeLocale(const char* arg, size_t *wlen) } -static int -encode_current_locale(const wchar_t *text, char **str, - size_t *error_pos, const char **reason, - int raw_malloc, _Py_error_handler errors) +// If bytes is NULL, compute the length in 'bytes' of the encoded string. +// Otherwise, encode the wide string into 'bytes', decrements 'size', and +// return 0 on success. +// On encoding error, set 'error_pos' (if set) and return ENCODE_ERROR. +static size_t +encode_current_locale_impl(const wchar_t *text, const size_t len, + int surrogateescape, + char *bytes, size_t size, + size_t *error_pos) { - const size_t len = wcslen(text); - char *result = NULL, *bytes = NULL; - size_t i, size, converted; - wchar_t c, buf[2]; - - int surrogateescape; - if (get_surrogateescape(errors, &surrogateescape) < 0) { - return -3; - } - - /* The function works in two steps: - 1. compute the length of the output buffer in bytes (size) - 2. outputs the bytes */ - size = 0; + wchar_t buf[2]; + // The second character is always the NUL character buf[1] = 0; - while (1) { - for (i=0; i < len; i++) { - c = text[i]; - if (c >= 0xdc80 && c <= 0xdcff) { - if (!surrogateescape) { - goto encode_error; - } - /* UTF-8b surrogate */ - if (bytes != NULL) { - *bytes++ = c - 0xdc00; - size--; - } - else { - size++; + + for (size_t i=0; i < len; i++) { + wchar_t c = text[i]; + if (c >= 0xdc80 && c <= 0xdcff) { + if (!surrogateescape) { + if (error_pos != NULL) { + *error_pos = i; } - continue; + return ENCODE_ERROR; + } + /* UTF-8b surrogate */ + if (bytes != NULL) { + *bytes++ = c - 0xdc00; + size--; } else { - buf[0] = c; - if (bytes != NULL) { - converted = wcstombs(bytes, buf, size); - } - else { - converted = wcstombs(NULL, buf, 0); - } - if (converted == DECODE_ERROR) { - goto encode_error; - } - if (bytes != NULL) { - bytes += converted; - size -= converted; - } - else { - size += converted; - } + size++; } } - if (result != NULL) { - *bytes = '\0'; - break; + else { + // Encode a single character using wcstombs() + buf[0] = c; + size_t converted; + if (bytes != NULL) { + converted = wcstombs(bytes, buf, size); + } + else { + converted = wcstombs(NULL, buf, 0); + } + if (converted == ENCODE_ERROR) { + if (error_pos != NULL) { + *error_pos = i; + } + return ENCODE_ERROR; + } + if (bytes != NULL) { + bytes += converted; + size -= converted; + } + else { + size += converted; + } } + } + if (bytes) { + *bytes = '\0'; + } + // Sanity check, it cannot happen in practice + assert(size != ENCODE_ERROR); + return size; +} + + +// Encode a wide string to the current locale encoding. +// Set *str to a newly allocated string on success. +// Return a negative number on error: _Py_CODEC_MEMORY_ERROR, +// _Py_CODEC_ENCODE_ERROR or _Py_CODEC_UNSUPPORTED_ERROR_HANDLER. +// +// str and output_length must not be NULL +static int +encode_current_locale(const wchar_t *text, char **str, size_t *output_length, + size_t *error_pos, int raw_malloc, + _Py_error_handler errors) +{ + assert(str != NULL); + assert(output_length != NULL); - size += 1; /* nul byte at the end */ + int surrogateescape; + if (get_surrogateescape(errors, &surrogateescape) < 0) { + // Only support "strict" and "surrogateescape" + return _Py_CODEC_UNSUPPORTED_ERROR_HANDLER; + } + + // First, compute the output length + const size_t len = wcslen(text); + // Sanity check, it cannot happen in practice + assert(len != ENCODE_ERROR); + size_t size = encode_current_locale_impl(text, len, surrogateescape, + NULL, 0, error_pos); + if (size == ENCODE_ERROR) { + return _Py_CODEC_ENCODE_ERROR; + } + + *output_length = size; + char *result; + result = raw_malloc ? PyMem_RawMalloc(size + 1) : PyMem_Malloc(size + 1); + if (result == NULL) { + return _Py_CODEC_MEMORY_ERROR; + } + + // Second, encode characters + size = encode_current_locale_impl(text, len, surrogateescape, + result, size, error_pos); + if (size == ENCODE_ERROR) { if (raw_malloc) { - result = PyMem_RawMalloc(size); + PyMem_RawFree(result); } else { - result = PyMem_Malloc(size); - } - if (result == NULL) { - return -1; + PyMem_Free(result); } - bytes = result; + return _Py_CODEC_ENCODE_ERROR; } + assert(size == 0); + *str = result; return 0; - -encode_error: - if (raw_malloc) { - PyMem_RawFree(result); - } - else { - PyMem_Free(result); - } - if (error_pos != NULL) { - *error_pos = i; - } - if (reason) { - *reason = "encoding error"; - } - return -2; } -/* Encode a string to the locale encoding. - - Parameters: - - * raw_malloc: if non-zero, allocate memory using PyMem_RawMalloc() instead - of PyMem_Malloc(). - * current_locale: if non-zero, use the current LC_CTYPE, otherwise use - Python filesystem encoding. - * errors: error handler like "strict" or "surrogateescape". - - Return value: - - 0: success, *str is set to a newly allocated decoded string. - -1: memory allocation failure - -2: encoding error, set *error_pos and *reason (if set). - -3: the error handler 'errors' is not supported. - */ static int -encode_locale_ex(const wchar_t *text, char **str, size_t *error_pos, - const char **reason, - int raw_malloc, int current_locale, _Py_error_handler errors) +encode_locale_inner(const wchar_t *text, char **str, size_t *output_length, + size_t *error_pos, int raw_malloc, + int current_locale, _Py_error_handler errors) { if (current_locale) { #ifdef _Py_FORCE_UTF8_LOCALE - return _Py_EncodeUTF8Ex(text, str, error_pos, reason, - raw_malloc, errors); + return _Py_EncodeUTF8(text, str, output_length, + error_pos, raw_malloc, errors); #else - return encode_current_locale(text, str, error_pos, reason, - raw_malloc, errors); + return encode_current_locale(text, str, output_length, + error_pos, raw_malloc, errors); #endif } #ifdef _Py_FORCE_UTF8_FS_ENCODING - return _Py_EncodeUTF8Ex(text, str, error_pos, reason, - raw_malloc, errors); + return _Py_EncodeUTF8(text, str, output_length, + error_pos, raw_malloc, errors); #else int use_utf8 = (_PyRuntime.preconfig.utf8_mode >= 1); #ifdef MS_WINDOWS use_utf8 |= (_PyRuntime.preconfig.legacy_windows_fs_encoding == 0); #endif if (use_utf8) { - return _Py_EncodeUTF8Ex(text, str, error_pos, reason, - raw_malloc, errors); + return _Py_EncodeUTF8(text, str, output_length, + error_pos, raw_malloc, errors); } #ifdef USE_FORCE_ASCII @@ -818,45 +929,101 @@ encode_locale_ex(const wchar_t *text, char **str, size_t *error_pos, } if (force_ascii) { - return encode_ascii(text, str, error_pos, reason, - raw_malloc, errors); + return encode_ascii(text, str, output_length, + error_pos, raw_malloc, errors); } #endif - return encode_current_locale(text, str, error_pos, reason, - raw_malloc, errors); + return encode_current_locale(text, str, output_length, + error_pos, raw_malloc, errors); #endif /* _Py_FORCE_UTF8_FS_ENCODING */ } + +// Encode a wide string to the locale encoding. +// +// Parameters: +// +// * raw_malloc: if non-zero, allocate memory using PyMem_RawMalloc() instead +// of PyMem_Malloc(). +// * current_locale: if non-zero, use the current LC_CTYPE, otherwise use +// Python filesystem encoding. +// * errors: supported error handlers are _Py_ERROR_STRICT and +// _Py_ERROR_SURROGATEESCAPE. The UTF-8 encoder also supports +// _Py_ERROR_SURROGATEPASS. +// +// Set *str to a newly allocated decoded string and return 0 on success. +// Return a negative result on error: +// +// * _Py_CODEC_MEMORY_ERROR: memory allocation failure +// * _Py_CODEC_ENCODE_ERROR: encoding error, set *error_pos. +// * _Py_CODEC_UNSUPPORTED_ERROR_HANDLER: the 'errors' error handler +// is not supported. +// +// text, str and output_length must not be NULL. +static int +encode_locale_impl(const wchar_t *text, char **str, size_t *output_length, + size_t *error_pos, int raw_malloc, + int current_locale, _Py_error_handler errors) +{ + assert(text != NULL); + assert(str != NULL); + assert(output_length != NULL); + + int res = encode_locale_inner(text, str, output_length, + error_pos, raw_malloc, + current_locale, errors); + if (res < 0) { + // Error + *str = NULL; + *output_length = 0; + if (res != _Py_CODEC_ENCODE_ERROR) { + if (error_pos) { + *error_pos = 0; + } + } + } + else { + assert(*str != NULL); + assert(*output_length == strlen(*str)); + // *error_pos is left unchanged + } + return res; +} + static char* encode_locale(const wchar_t *text, size_t *error_pos, int raw_malloc, int current_locale) { char *str; - int res = encode_locale_ex(text, &str, error_pos, NULL, - raw_malloc, current_locale, - _Py_ERROR_SURROGATEESCAPE); - if (res != -2 && error_pos) { - *error_pos = (size_t)-1; - } + size_t unused_output_length; + int res = encode_locale_impl(text, &str, &unused_output_length, + error_pos, raw_malloc, current_locale, + _Py_ERROR_SURROGATEESCAPE); if (res != 0) { + assert(res == _Py_CODEC_MEMORY_ERROR || res == _Py_CODEC_ENCODE_ERROR); + if (res == _Py_CODEC_MEMORY_ERROR && error_pos != NULL) { + *error_pos = (size_t)-1; + } return NULL; } return str; } -/* Encode a wide character string to the locale encoding with the - surrogateescape error handler: surrogate characters in the range - U+DC80..U+DCFF are converted to bytes 0x80..0xFF. - - Return a pointer to a newly allocated byte string, use PyMem_Free() to free - the memory. Return NULL on encoding or memory allocation error. - - If error_pos is not NULL, *error_pos is set to (size_t)-1 on success, or set - to the index of the invalid character on encoding error. - - Use the Py_DecodeLocale() function to decode the bytes string back to a wide - character string. */ +// Encode a wide character string to the locale encoding with the +// surrogateescape error handler. Surrogate characters in the range +// U+DC80..U+DCFF are encoded to bytes 0x80..0xFF. +// +// Return a pointer to a newly allocated byte string, use PyMem_Free() to free +// the memory. Return NULL on encoding or memory allocation error. +// +// On memory allocation failure, set *error_pos to (size_t)-1 and return NULL. +// +// On encoding error, set *error_pos to the index of the first unencodable +// character and return NULL. +// +// Use the Py_DecodeLocale() function to decode the bytes string back to a wide +// character string. char* Py_EncodeLocale(const wchar_t *text, size_t *error_pos) { @@ -866,7 +1033,7 @@ Py_EncodeLocale(const wchar_t *text, size_t *error_pos) /* Similar to Py_EncodeLocale(), but result must be freed by PyMem_RawFree() instead of PyMem_Free(). */ -char* +static char* _Py_EncodeLocaleRaw(const wchar_t *text, size_t *error_pos) { return encode_locale(text, error_pos, 1, 0); @@ -874,12 +1041,12 @@ _Py_EncodeLocaleRaw(const wchar_t *text, size_t *error_pos) int -_Py_EncodeLocaleEx(const wchar_t *text, char **str, - size_t *error_pos, const char **reason, - int current_locale, _Py_error_handler errors) +_Py_EncodeLocale(const wchar_t *text, char **str, size_t *output_length, + size_t *error_pos, int current_locale, + _Py_error_handler errors) { - return encode_locale_ex(text, str, error_pos, reason, 1, - current_locale, errors); + return encode_locale_impl(text, str, output_length, + error_pos, 1, current_locale, errors); } @@ -918,9 +1085,8 @@ _Py_GetLocaleEncoding(void) } wchar_t *wstr; - int res = decode_current_locale(encoding, &wstr, NULL, - NULL, _Py_ERROR_SURROGATEESCAPE); - if (res < 0) { + if (decode_current_locale(encoding, &wstr, NULL, + _Py_ERROR_SURROGATEESCAPE) < 0) { return NULL; } return wstr; @@ -1103,50 +1269,41 @@ typedef union { void -_Py_attribute_data_to_stat(BY_HANDLE_FILE_INFORMATION *info, ULONG reparse_tag, +_Py_attribute_data_to_stat(FILE_STANDARD_INFO* standard_info, ULONG reparse_tag, FILE_BASIC_INFO *basic_info, FILE_ID_INFO *id_info, struct _Py_stat_struct *result) { memset(result, 0, sizeof(*result)); - result->st_mode = attributes_to_mode(info->dwFileAttributes); - result->st_size = (((__int64)info->nFileSizeHigh)<<32) + info->nFileSizeLow; - result->st_dev = id_info ? id_info->VolumeSerialNumber : info->dwVolumeSerialNumber; - result->st_rdev = 0; + + result->st_size = standard_info->EndOfFile.QuadPart; + result->st_nlink = standard_info->NumberOfLinks; + /* st_ctime is deprecated, but we preserve the legacy value in our caller, not here */ - if (basic_info) { - LARGE_INTEGER_to_time_t_nsec(&basic_info->CreationTime, &result->st_birthtime, &result->st_birthtime_nsec); - LARGE_INTEGER_to_time_t_nsec(&basic_info->ChangeTime, &result->st_ctime, &result->st_ctime_nsec); - LARGE_INTEGER_to_time_t_nsec(&basic_info->LastWriteTime, &result->st_mtime, &result->st_mtime_nsec); - LARGE_INTEGER_to_time_t_nsec(&basic_info->LastAccessTime, &result->st_atime, &result->st_atime_nsec); - } else { - FILE_TIME_to_time_t_nsec(&info->ftCreationTime, &result->st_birthtime, &result->st_birthtime_nsec); - FILE_TIME_to_time_t_nsec(&info->ftLastWriteTime, &result->st_mtime, &result->st_mtime_nsec); - FILE_TIME_to_time_t_nsec(&info->ftLastAccessTime, &result->st_atime, &result->st_atime_nsec); - } - result->st_nlink = info->nNumberOfLinks; + LARGE_INTEGER_to_time_t_nsec(&basic_info->CreationTime, &result->st_birthtime, &result->st_birthtime_nsec); + LARGE_INTEGER_to_time_t_nsec(&basic_info->ChangeTime, &result->st_ctime, &result->st_ctime_nsec); + LARGE_INTEGER_to_time_t_nsec(&basic_info->LastWriteTime, &result->st_mtime, &result->st_mtime_nsec); + LARGE_INTEGER_to_time_t_nsec(&basic_info->LastAccessTime, &result->st_atime, &result->st_atime_nsec); if (id_info) { + result->st_dev = id_info->VolumeSerialNumber; id_128_to_ino file_id; file_id.id = id_info->FileId; result->st_ino = file_id.st_ino; result->st_ino_high = file_id.st_ino_high; } - if (!result->st_ino && !result->st_ino_high) { - /* should only occur for DirEntry_from_find_data, in which case the - index is likely to be zero anyway. */ - result->st_ino = (((uint64_t)info->nFileIndexHigh) << 32) + info->nFileIndexLow; - } + + result->st_file_attributes = basic_info->FileAttributes; + result->st_mode = attributes_to_mode(result->st_file_attributes); /* bpo-37834: Only actual symlinks set the S_IFLNK flag. But lstat() will open other name surrogate reparse points without traversing them. To detect/handle these, check st_file_attributes and st_reparse_tag. */ result->st_reparse_tag = reparse_tag; - if (info->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && + if (result->st_file_attributes & FILE_ATTRIBUTE_REPARSE_POINT && reparse_tag == IO_REPARSE_TAG_SYMLINK) { /* set the bits that make this a symlink */ result->st_mode = (result->st_mode & ~S_IFMT) | S_IFLNK; } - result->st_file_attributes = info->dwFileAttributes; } void @@ -1231,9 +1388,9 @@ int _Py_fstat_noraise(int fd, struct _Py_stat_struct *status) { #ifdef MS_WINDOWS - BY_HANDLE_FILE_INFORMATION info; - FILE_BASIC_INFO basicInfo; - FILE_ID_INFO idInfo; + FILE_STANDARD_INFO standardInfo = {0}; + FILE_BASIC_INFO basicInfo = {0}; + FILE_ID_INFO idInfo = {0}; FILE_ID_INFO *pIdInfo = &idInfo; HANDLE h; int type; @@ -1266,7 +1423,7 @@ _Py_fstat_noraise(int fd, struct _Py_stat_struct *status) return 0; } - if (!GetFileInformationByHandle(h, &info) || + if (!GetFileInformationByHandleEx(h,FileStandardInfo, &standardInfo, sizeof(standardInfo)) || !GetFileInformationByHandleEx(h, FileBasicInfo, &basicInfo, sizeof(basicInfo))) { /* The Win32 error is already set, but we also set errno for callers who expect it */ @@ -1279,7 +1436,7 @@ _Py_fstat_noraise(int fd, struct _Py_stat_struct *status) pIdInfo = NULL; } - _Py_attribute_data_to_stat(&info, 0, &basicInfo, pIdInfo, status); + _Py_attribute_data_to_stat(&standardInfo, 0, &basicInfo, pIdInfo, status); return 0; #else return fstat(fd, status); @@ -3145,3 +3302,97 @@ _Py_IsValidFD(int fd) return (fstat(fd, &st) == 0); #endif } + + +// Call strerror_r(code) if available, or use strerror() otherwise. Decode the +// result from the locale encoding using surrogateescape error handler. +// +// On success, return a Unicode string. On error, set an exception and return +// NULL. +PyObject* +_Py_strerror(int code) +/*[clinic end generated code: output=baebf09fa02a78f2 input=75a8673d97915a91]*/ +{ + const char *errors = "surrogateescape"; + +#ifdef _Py_HAVE_STRERROR_R + // Check which strerror_r() API is used +# if defined(__GLIBC__) && !((_POSIX_C_SOURCE >= 200112L) && !defined(_GNU_SOURCE)) +# define Py_STRERROR_R_GNU +# elif defined(__ANDROID__) && defined(_GNU_SOURCE) +# define Py_STRERROR_R_GNU +# endif +#endif + +#ifdef Py_STRERROR_R_GNU + // Implementation for the GNU flavor of strerror_r() + + // On Linux, the longest translated strerror() message is 86 bytes + // (including the NUL byte). + char buffer[100]; + char *message = strerror_r(code, buffer, Py_ARRAY_LENGTH(buffer)); + // The strerror_r() GNU flavor doesn't provide a way to check if the error + // message was truncated or not. + // + // When the buffer is used, a trailing NUL byte is always written. + assert(message != buffer || memchr(buffer, 0, Py_ARRAY_LENGTH(buffer)) != NULL); + return PyUnicode_DecodeLocale(message, errors); + +#elif defined(_Py_HAVE_STRERROR_R) + // Implementation for the XSI-compliant flavor of strerror_r() + + // On Linux and FreeBSD, the longest translated strerror() message is 86 + // bytes (including the NUL byte). + char small_buffer[100]; + size_t buflen = Py_ARRAY_LENGTH(small_buffer); + char *buffer = NULL; +#ifndef NDEBUG + // Make sure that strerror_r() writes a trailing null byte + small_buffer[buflen - 1] = '#'; +#endif + int len = strerror_r(code, small_buffer, buflen); + if (len == ERANGE) { + while (len == ERANGE) { + if (buflen > (size_t)PY_SSIZE_T_MAX / 2) { + PyMem_Free(buffer); + PyErr_NoMemory(); + return NULL; + } + buflen = buflen * 2; + + char *new_buffer = PyMem_Realloc(buffer, buflen); + if (new_buffer == NULL) { + PyMem_Free(buffer); + PyErr_NoMemory(); + return NULL; + } + buffer = new_buffer; +#ifndef NDEBUG + buffer[buflen - 1] = '#'; +#endif + len = strerror_r(code, buffer, buflen); + } + } + else { + buffer = small_buffer; + } + + // strerror_r() always writes a trailing NUL byte + assert(memchr(buffer, 0, buflen) != NULL); + PyObject *result = PyUnicode_DecodeLocale(buffer, errors); + if (buffer != small_buffer) { + PyMem_Free(buffer); + } + return result; + +#else + // strerror() implementation (usually not thread-safe) + char *message = strerror(code); + if (message == NULL) { + PyErr_SetString(PyExc_ValueError, + "strerror() argument out of range"); + return NULL; + } + return PyUnicode_DecodeLocale(message, errors); +#endif +} diff --git a/Python/flowgraph.c b/Python/flowgraph.c index f135f243c74e2f6..fc676dc6feb1674 100644 --- a/Python/flowgraph.c +++ b/Python/flowgraph.c @@ -41,12 +41,22 @@ typedef struct _PyCfgInstruction { typedef struct _PyCfgBasicblock { /* Each basicblock in a compilation unit is linked via b_list in the - reverse order that the block are allocated. b_list points to the next - block in this list, not to be confused with b_next, which is next by - control flow. */ + reverse order that blocks are allocated. b_list points to the + previously allocated block, not to be confused with b_next, which is + next by control flow. */ struct _PyCfgBasicblock *b_list; /* The label of this block if it is a jump target, -1 otherwise */ _PyJumpTargetLabel b_label; + /* Basic block is an exception handler that preserves lasti */ + unsigned b_preserve_lasti : 1; + /* Used by compiler passes to mark whether they have visited a basic block. */ + unsigned b_visited : 1; + /* b_except_handler is used by the cold-detection algorithm to mark exception targets */ + unsigned b_except_handler : 1; + /* b_cold is true if this block is not perf critical (like an exception handler) */ + unsigned b_cold : 1; + /* b_warm is used by the cold-detection algorithm to mark blocks which are definitely not cold */ + unsigned b_warm : 1; /* Exception stack at start of block, used by assembler to create the exception handling table */ struct _PyCfgExceptStack *b_exceptstack; /* pointer to an array of instructions, initially NULL */ @@ -64,16 +74,6 @@ typedef struct _PyCfgBasicblock { int b_predecessors; /* depth of stack upon entry of block, computed by stackdepth() */ int b_startdepth; - /* Basic block is an exception handler that preserves lasti */ - unsigned b_preserve_lasti : 1; - /* Used by compiler passes to mark whether they have visited a basic block. */ - unsigned b_visited : 1; - /* b_except_handler is used by the cold-detection algorithm to mark exception targets */ - unsigned b_except_handler : 1; - /* b_cold is true if this block is not perf critical (like an exception handler) */ - unsigned b_cold : 1; - /* b_warm is used by the cold-detection algorithm to mark blocks which are definitely not cold */ - unsigned b_warm : 1; } basicblock; @@ -188,7 +188,8 @@ cfg_builder_new_block(cfg_builder *g) } static int -basicblock_addop(basicblock *b, int opcode, int oparg, location loc) +basicblock_addop(basicblock *b, int opcode, int oparg, location loc, + basicblock *except) { assert(IS_WITHIN_OPCODE_RANGE(opcode)); assert(!IS_ASSEMBLER_OPCODE(opcode)); @@ -203,15 +204,16 @@ basicblock_addop(basicblock *b, int opcode, int oparg, location loc) i->i_opcode = opcode; i->i_oparg = oparg; i->i_loc = loc; + i->i_except = except; // memory is already zero initialized assert(i->i_target == NULL); - assert(i->i_except == NULL); return SUCCESS; } static int -basicblock_add_jump(basicblock *b, int opcode, basicblock *target, location loc) +basicblock_add_jump(basicblock *b, int opcode, basicblock *target, location loc, + basicblock *except) { cfg_instr *last = basicblock_last_instr(b); if (last && is_jump(last)) { @@ -219,7 +221,7 @@ basicblock_add_jump(basicblock *b, int opcode, basicblock *target, location loc) } RETURN_IF_ERROR( - basicblock_addop(b, opcode, target->b_label.id, loc)); + basicblock_addop(b, opcode, target->b_label.id, loc, except)); last = basicblock_last_instr(b); assert(last && last->i_opcode == opcode); last->i_target = target; @@ -493,7 +495,7 @@ int _PyCfgBuilder_Addop(cfg_builder *g, int opcode, int oparg, location loc) { RETURN_IF_ERROR(cfg_builder_maybe_start_new_block(g)); - return basicblock_addop(g->g_curblock, opcode, oparg, loc); + return basicblock_addop(g->g_curblock, opcode, oparg, loc, NULL); } @@ -554,7 +556,7 @@ normalize_jumps_in_block(cfg_builder *g, basicblock *b) { bool is_forward = last->i_target->b_visited == 0; if (is_forward) { RETURN_IF_ERROR( - basicblock_addop(b, NOT_TAKEN, 0, last->i_loc)); + basicblock_addop(b, NOT_TAKEN, 0, last->i_loc, last->i_except)); return SUCCESS; } @@ -583,9 +585,11 @@ normalize_jumps_in_block(cfg_builder *g, basicblock *b) { return ERROR; } RETURN_IF_ERROR( - basicblock_addop(backwards_jump, NOT_TAKEN, 0, last->i_loc)); + basicblock_addop(backwards_jump, NOT_TAKEN, 0, last->i_loc, + last->i_except)); RETURN_IF_ERROR( - basicblock_add_jump(backwards_jump, JUMP, target, last->i_loc)); + basicblock_add_jump(backwards_jump, JUMP, target, last->i_loc, + last->i_except)); backwards_jump->b_startdepth = target->b_startdepth; last->i_opcode = reversed_opcode; last->i_target = b->b_next; @@ -1293,7 +1297,8 @@ jump_thread(basicblock *bb, cfg_instr *inst, cfg_instr *target, int opcode) RETURN_IF_ERROR( basicblock_add_jump( - bb, opcode, target->i_target, target->i_loc)); + bb, opcode, target->i_target, target->i_loc, + target->i_except)); return true; } @@ -1569,34 +1574,48 @@ fold_tuple_of_constants(basicblock *bb, int i, PyObject *consts, } /* Replace: - BUILD_LIST 0 + BUILD_LIST/BUILD_SET 0 LOAD_CONST c1 - LIST_APPEND 1 + LIST_APPEND/SET_ADD 1 LOAD_CONST c2 - LIST_APPEND 1 + LIST_APPEND/SET_ADD 1 ... LOAD_CONST cN - LIST_APPEND 1 - CALL_INTRINSIC_1 INTRINSIC_LIST_TO_TUPLE + LIST_APPEND/SET_ADD 1 + [CALL_INTRINSIC_1 INTRINSIC_LIST_TO_TUPLE] <-- optional with: LOAD_CONST (c1, c2, ... cN) + The instruction at `i` is either the LIST_TO_TUPLE intrinsic (so the + immediately preceding non-NOP instruction is expected to be a + LIST_APPEND, and only the BUILD_LIST/LIST_APPEND form is considered), + or the trailing LIST_APPEND or SET_ADD itself, in which case the + matching BUILD_LIST/BUILD_SET start is selected from its opcode, and + for sets the result is wrapped in a frozenset. */ static int -fold_constant_intrinsic_list_to_tuple(basicblock *bb, int i, - PyObject *consts, PyObject *const_cache, - _Py_hashtable_t *consts_index) +fold_constant_seq_into_load_const(basicblock *bb, int i, + PyObject *consts, PyObject *const_cache, + _Py_hashtable_t *consts_index) { assert(PyDict_CheckExact(const_cache)); assert(PyList_CheckExact(consts)); assert(i >= 0); assert(i < bb->b_iused); - cfg_instr *intrinsic = &bb->b_instr[i]; - assert(intrinsic->i_opcode == CALL_INTRINSIC_1); - assert(intrinsic->i_oparg == INTRINSIC_LIST_TO_TUPLE); - + cfg_instr *target = &bb->b_instr[i]; + assert(target->i_opcode == LIST_APPEND || target->i_opcode == SET_ADD || + (target->i_opcode == CALL_INTRINSIC_1 && + target->i_oparg == INTRINSIC_LIST_TO_TUPLE)); + bool expected_append = target->i_opcode == CALL_INTRINSIC_1; + int append_op = expected_append ? LIST_APPEND : target->i_opcode; + assert(append_op == LIST_APPEND || append_op == SET_ADD); + int build_op = append_op == LIST_APPEND ? BUILD_LIST : BUILD_SET; int consts_found = 0; - bool expect_append = true; + /* Walking backward from `i`, we expect LIST_APPEND/SET_ADD and + LOAD_CONST to alternate. If `i` is the trailing LIST_TO_TUPLE + intrinsic, the next instruction back is an APPEND. If `i` is the + trailing APPEND itself, the next instruction back is a LOAD_CONST. */ + bool expect_append = expected_append; for (int pos = i - 1; pos >= 0; pos--) { cfg_instr *instr = &bb->b_instr[pos]; @@ -1607,7 +1626,7 @@ fold_constant_intrinsic_list_to_tuple(basicblock *bb, int i, continue; } - if (opcode == BUILD_LIST && oparg == 0) { + if (opcode == build_op && oparg == 0) { if (!expect_append) { /* Not a sequence start. */ return SUCCESS; @@ -1619,7 +1638,8 @@ fold_constant_intrinsic_list_to_tuple(basicblock *bb, int i, return ERROR; } - for (int newpos = i - 1; newpos >= pos; newpos--) { + int newpos_start = expected_append ? i - 1 : i; + for (int newpos = newpos_start; newpos >= pos; newpos--) { instr = &bb->b_instr[newpos]; if (instr->i_opcode == NOP) { continue; @@ -1636,11 +1656,20 @@ fold_constant_intrinsic_list_to_tuple(basicblock *bb, int i, nop_out(&instr, 1); } assert(consts_found == 0); - return instr_make_load_const(intrinsic, newconst, consts, const_cache, consts_index); + + if (build_op == BUILD_SET) { + PyObject *frozen = PyFrozenSet_New(newconst); + Py_DECREF(newconst); + if (frozen == NULL) { + return ERROR; + } + newconst = frozen; + } + return instr_make_load_const(target, newconst, consts, const_cache, consts_index); } if (expect_append) { - if (opcode != LIST_APPEND || oparg != 1) { + if (opcode != append_op || oparg != 1) { return SUCCESS; } } @@ -2579,17 +2608,22 @@ optimize_basic_block(PyObject *const_cache, basicblock *bb, PyObject *consts, break; case CALL_INTRINSIC_1: if (oparg == INTRINSIC_LIST_TO_TUPLE) { - if (nextop == GET_ITER) { + RETURN_IF_ERROR(fold_constant_seq_into_load_const(bb, i, consts, const_cache, consts_index)); + if (inst->i_opcode == CALL_INTRINSIC_1 && nextop == GET_ITER) { INSTR_SET_OP0(inst, NOP); } - else { - RETURN_IF_ERROR(fold_constant_intrinsic_list_to_tuple(bb, i, consts, const_cache, consts_index)); - } } else if (oparg == INTRINSIC_UNARY_POSITIVE) { RETURN_IF_ERROR(fold_const_unaryop(bb, i, consts, const_cache, consts_index)); } break; + case LIST_APPEND: + case SET_ADD: + if (oparg == 1 && (nextop == GET_ITER || nextop == CONTAINS_OP)) { + RETURN_IF_ERROR(fold_constant_seq_into_load_const( + bb, i, consts, const_cache, consts_index)); + } + break; case BINARY_OP: RETURN_IF_ERROR(fold_const_binop(bb, i, consts, const_cache, consts_index)); break; @@ -2685,6 +2719,12 @@ insert_superinstructions(cfg_builder *g) make_super_instruction(inst, &b->b_instr[i + 1], LOAD_FAST_LOAD_FAST); } break; + case LOAD_FAST_BORROW: + if (nextop == LOAD_FAST_BORROW) { + make_super_instruction(inst, &b->b_instr[i + 1], + LOAD_FAST_BORROW_LOAD_FAST_BORROW); + } + break; case STORE_FAST: switch (nextop) { case LOAD_FAST: @@ -2698,9 +2738,9 @@ insert_superinstructions(cfg_builder *g) } } } - int res = remove_redundant_nops(g); + RETURN_IF_ERROR(remove_redundant_nops(g)); assert(no_redundant_nops(g)); - return res; + return SUCCESS; } #define NOT_LOCAL -1 @@ -3517,8 +3557,9 @@ push_cold_blocks_to_end(cfg_builder *g) { if (!IS_LABEL(b->b_next->b_label)) { b->b_next->b_label.id = next_lbl++; } - basicblock_addop(explicit_jump, JUMP_NO_INTERRUPT, b->b_next->b_label.id, - NO_LOCATION); + RETURN_IF_ERROR( + basicblock_addop(explicit_jump, JUMP_NO_INTERRUPT, + b->b_next->b_label.id, NO_LOCATION, NULL)); explicit_jump->b_cold = 1; explicit_jump->b_next = b->b_next; explicit_jump->b_predecessors = 1; @@ -3800,8 +3841,6 @@ _PyCfg_OptimizeCodeUnit(cfg_builder *g, PyObject *consts, PyObject *const_cache, RETURN_IF_ERROR( add_checks_for_loads_of_uninitialized_variables( g->g_entryblock, nlocals, nparams)); - RETURN_IF_ERROR(insert_superinstructions(g)); - RETURN_IF_ERROR(push_cold_blocks_to_end(g)); RETURN_IF_ERROR(resolve_line_numbers(g, firstlineno)); // temporarily remove assert. See https://github.com/python/cpython/issues/125845 @@ -4123,11 +4162,19 @@ _PyCfg_OptimizedCfgToInstructionSequence(cfg_builder *g, RETURN_IF_ERROR(normalize_jumps(g)); assert(no_redundant_jumps(g)); - /* Can't modify the bytecode after inserting instructions that produce - * borrowed references. + /* After this point the bytecode may only be modified in ways that + * preserve the borrowed references computed here. + * + * NOTE: keep the passes below in sync with _PyCompile_OptimizeCfg(). */ RETURN_IF_ERROR(optimize_load_fast(g)); + /* Superinstructions are inserted after optimize_load_fast() so that a + * LOAD_FAST which can be borrowed is converted to LOAD_FAST_BORROW + * instead of being fused into a STORE_FAST_LOAD_FAST. Fusing adjacent + * instructions does not change which references are borrowed. */ + RETURN_IF_ERROR(insert_superinstructions(g)); + /* Can't modify the bytecode after computing jump offsets. */ if (_PyCfg_ToInstructionSequence(g, seq) < 0) { return ERROR; @@ -4220,10 +4267,15 @@ _PyCompile_OptimizeCfg(PyObject *seq, PyObject *consts, int nlocals) goto error; } + /* NOTE: keep in sync with _PyCfg_OptimizedCfgToInstructionSequence(). */ if (optimize_load_fast(g) != SUCCESS) { goto error; } + if (insert_superinstructions(g) < 0) { + goto error; + } + res = cfg_to_instruction_sequence(g); error: Py_DECREF(const_cache); diff --git a/Python/frame.c b/Python/frame.c index ff81eb0b3020c78..79522b00b47f118 100644 --- a/Python/frame.c +++ b/Python/frame.c @@ -20,7 +20,6 @@ _PyFrame_Traverse(_PyInterpreterFrame *frame, visitproc visit, void *arg) PyFrameObject * _PyFrame_MakeAndSetFrameObject(_PyInterpreterFrame *frame) { - assert(frame->frame_obj == NULL); PyObject *exc = PyErr_GetRaisedException(); PyFrameObject *f = _PyFrame_New_NoTrack(_PyFrame_GetCode(frame)); @@ -37,10 +36,18 @@ _PyFrame_MakeAndSetFrameObject(_PyInterpreterFrame *frame) // Notice that _PyFrame_New_NoTrack() can potentially raise a MemoryError, // but it won't allocate a traceback until the frame unwinds, so we are safe // here. - assert(frame->frame_obj == NULL); assert(frame->owner != FRAME_OWNED_BY_FRAME_OBJECT); f->f_frame = frame; +#ifdef Py_GIL_DISABLED + PyFrameObject *expected = NULL; + if (!_Py_atomic_compare_exchange_ptr(&frame->frame_obj, &expected, f)) { + Py_DECREF(f); + return expected; + } +#else + assert(frame->frame_obj == NULL); frame->frame_obj = f; +#endif return f; } @@ -113,9 +120,9 @@ _PyFrame_ClearExceptCode(_PyInterpreterFrame *frame) // GH-99729: Clearing this frame can expose the stack (via finalizers). It's // crucial that this frame has been unlinked, and is no longer visible: assert(_PyThreadState_GET()->current_frame != frame); - if (frame->frame_obj) { - PyFrameObject *f = frame->frame_obj; - frame->frame_obj = NULL; + PyFrameObject *f = FT_ATOMIC_LOAD_PTR_RELAXED(frame->frame_obj); + if (f != NULL) { + FT_ATOMIC_STORE_PTR_RELAXED(frame->frame_obj, NULL); if (!_PyObject_IsUniquelyReferenced((PyObject *)f)) { take_ownership(f, frame); Py_DECREF(f); @@ -149,11 +156,3 @@ PyUnstable_InterpreterFrame_GetLine(_PyInterpreterFrame *frame) int addr = _PyInterpreterFrame_LASTI(frame) * sizeof(_Py_CODEUNIT); return PyCode_Addr2Line(_PyFrame_GetCode(frame), addr); } - -const PyTypeObject *const PyUnstable_ExecutableKinds[PyUnstable_EXECUTABLE_KINDS+1] = { - [PyUnstable_EXECUTABLE_KIND_SKIP] = &_PyNone_Type, - [PyUnstable_EXECUTABLE_KIND_PY_FUNCTION] = &PyCode_Type, - [PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION] = &PyMethod_Type, - [PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR] = &PyMethodDescr_Type, - [PyUnstable_EXECUTABLE_KINDS] = NULL, -}; diff --git a/Python/frozen.c b/Python/frozen.c index 03ee612252343d8..1f92ea01dc38bbc 100644 --- a/Python/frozen.c +++ b/Python/frozen.c @@ -44,13 +44,9 @@ #include "frozen_modules/importlib._bootstrap.h" #include "frozen_modules/importlib._bootstrap_external.h" #include "frozen_modules/zipimport.h" +#include "frozen_modules/builtins.h" #include "frozen_modules/abc.h" #include "frozen_modules/codecs.h" -#include "frozen_modules/encodings.h" -#include "frozen_modules/encodings.aliases.h" -#include "frozen_modules/encodings.utf_8.h" -#include "frozen_modules/encodings._win_cp_codecs.h" -#include "frozen_modules/encodings._iconv_codecs.h" #include "frozen_modules/io.h" #include "frozen_modules/_collections_abc.h" #include "frozen_modules/_sitebuiltins.h" @@ -76,17 +72,13 @@ static const struct _frozen bootstrap_modules[] = { {"_frozen_importlib", _Py_M__importlib__bootstrap, (int)sizeof(_Py_M__importlib__bootstrap), false}, {"_frozen_importlib_external", _Py_M__importlib__bootstrap_external, (int)sizeof(_Py_M__importlib__bootstrap_external), false}, {"zipimport", _Py_M__zipimport, (int)sizeof(_Py_M__zipimport), false}, + {"_pybuiltins", _Py_M__builtins, (int)sizeof(_Py_M__builtins), false}, {0, 0, 0} /* bootstrap sentinel */ }; static const struct _frozen stdlib_modules[] = { /* stdlib - startup, without site (python -S) */ {"abc", _Py_M__abc, (int)sizeof(_Py_M__abc), false}, {"codecs", _Py_M__codecs, (int)sizeof(_Py_M__codecs), false}, - {"encodings", _Py_M__encodings, (int)sizeof(_Py_M__encodings), true}, - {"encodings.aliases", _Py_M__encodings_aliases, (int)sizeof(_Py_M__encodings_aliases), false}, - {"encodings.utf_8", _Py_M__encodings_utf_8, (int)sizeof(_Py_M__encodings_utf_8), false}, - {"encodings._win_cp_codecs", _Py_M__encodings__win_cp_codecs, (int)sizeof(_Py_M__encodings__win_cp_codecs), false}, - {"encodings._iconv_codecs", _Py_M__encodings__iconv_codecs, (int)sizeof(_Py_M__encodings__iconv_codecs), false}, {"io", _Py_M__io, (int)sizeof(_Py_M__io), false}, /* stdlib - startup, with site */ @@ -129,6 +121,7 @@ const struct _frozen *_PyImport_FrozenTest = test_modules; static const struct _module_alias aliases[] = { {"_frozen_importlib", "importlib._bootstrap"}, {"_frozen_importlib_external", "importlib._bootstrap_external"}, + {"_pybuiltins", "builtins"}, {"__hello_alias__", "__hello__"}, {"__phello_alias__", "__hello__"}, {"__phello_alias__.spam", "__hello__"}, diff --git a/Python/future.c b/Python/future.c index 79b6c0c503bace1..41c4fa07916189a 100644 --- a/Python/future.c +++ b/Python/future.c @@ -1,9 +1,10 @@ #include "Python.h" #include "pycore_ast.h" // _PyAST_GetDocString() +#include "pycore_pyerrors.h" // _Py_CalculateSuggestions() #include "pycore_symtable.h" // _PyFutureFeatures #include "pycore_unicodeobject.h" // _PyUnicode_EqualToASCIIString() -#define UNDEFINED_FUTURE_FEATURE "future feature %.100s is not defined" +#define UNDEFINED_FUTURE_FEATURE "future feature '%.100s' is not defined" static int future_check_features(_PyFutureFeatures *ff, stmt_ty s, PyObject *filename) @@ -48,8 +49,37 @@ future_check_features(_PyFutureFeatures *ff, stmt_ty s, PyObject *filename) name->end_col_offset + 1); return 0; } else { - PyErr_Format(PyExc_SyntaxError, - UNDEFINED_FUTURE_FEATURE, feature); + // Keep this list in sync with the feature checks above. + PyObject *future_features = Py_BuildValue("[ssssssssss]", + FUTURE_NESTED_SCOPES, + FUTURE_GENERATORS, + FUTURE_DIVISION, + FUTURE_ABSOLUTE_IMPORT, + FUTURE_WITH_STATEMENT, + FUTURE_PRINT_FUNCTION, + FUTURE_UNICODE_LITERALS, + FUTURE_BARRY_AS_BDFL, + FUTURE_GENERATOR_STOP, + FUTURE_ANNOTATIONS); + PyObject *suggestion = NULL; + if (future_features != NULL) { + suggestion = _Py_CalculateSuggestions(future_features, + name->name); + } + if (suggestion != NULL) { + PyErr_Format(PyExc_SyntaxError, + UNDEFINED_FUTURE_FEATURE ". Did you mean: %R?", + feature, suggestion); + Py_DECREF(suggestion); + } + else { + // Do not fail on missing suggestion, + // just show the default message. + PyErr_Format(PyExc_SyntaxError, + UNDEFINED_FUTURE_FEATURE, + feature); + } + Py_XDECREF(future_features); PyErr_RangedSyntaxLocationObject(filename, name->lineno, name->col_offset + 1, diff --git a/Python/gc.c b/Python/gc.c index 201c621bcc3cb9b..aa727fc7a77d6a3 100644 --- a/Python/gc.c +++ b/Python/gc.c @@ -5,6 +5,7 @@ #include "Python.h" #include "pycore_ceval.h" // _Py_set_eval_breaker_bit() #include "pycore_dict.h" // _PyInlineValuesSize() +#include "pycore_genobject.h" // _PyGen_FinalizerIsNoop() #include "pycore_initconfig.h" // _PyStatus_OK() #include "pycore_context.h" #include "pycore_interp.h" // PyInterpreterState.gc @@ -575,9 +576,10 @@ visit_reachable(PyObject *op, void *arg) * But _gc_next in unreachable list has NEXT_MASK_UNREACHABLE flag. * So we can not gc_list_* functions for unreachable until we remove the flag. */ -static void +static Py_ssize_t move_unreachable(PyGC_Head *young, PyGC_Head *unreachable) { + Py_ssize_t reachable = 0; // previous elem in the young list, used for restore gc_prev. PyGC_Head *prev = young; PyGC_Head *gc = GC_NEXT(young); @@ -614,7 +616,21 @@ move_unreachable(PyGC_Head *young, PyGC_Head *unreachable) _PyGCHead_SET_PREV(gc, prev); // gc is not COLLECTING state after here. gc_clear_collecting(gc); - prev = gc; + if (PyTuple_CheckExact(op)) { + // Untracking gc overwrites the gc_refs of the next object. + PyGC_Head *next = GC_NEXT(gc); + uintptr_t next_refs = next->_gc_prev; + _PyTuple_MaybeUntrack(op); + next->_gc_prev = next_refs; + if (gc->_gc_next != 0) { + prev = gc; + reachable++; + } + } + else { + prev = gc; + reachable++; + } } else { /* This *may* be unreachable. To make progress, @@ -647,32 +663,7 @@ move_unreachable(PyGC_Head *young, PyGC_Head *unreachable) young->_gc_prev = (uintptr_t)prev; // don't let the pollution of the list head's next pointer leak unreachable->_gc_next &= ~NEXT_MASK_UNREACHABLE; -} - -/* In theory, all tuples should be younger than the -* objects they refer to, as tuples are immortal. -* Therefore, untracking tuples in oldest-first order in the -* young generation before promoting them should have tracked -* all the tuples that can be untracked. -* -* Unfortunately, the C API allows tuples to be created -* and then filled in. So this won't untrack all tuples -* that can be untracked. It should untrack most of them -* and is much faster than a more complex approach that -* would untrack all relevant tuples. -*/ -static void -untrack_tuples(PyGC_Head *head) -{ - PyGC_Head *gc = GC_NEXT(head); - while (gc != head) { - PyObject *op = FROM_GC(gc); - PyGC_Head *next = GC_NEXT(gc); - if (PyTuple_CheckExact(op)) { - _PyTuple_MaybeUntrack(op); - } - gc = next; - } + return reachable; } /* Return true if object has a pre-PEP 442 finalization method. */ @@ -805,7 +796,8 @@ move_legacy_finalizer_reachable(PyGC_Head *finalizers) * Python-level code. See bpo-38006 as an example bug. */ static int -handle_weakref_callbacks(PyGC_Head *unreachable, PyGC_Head *old) +handle_weakref_callbacks(PyGC_Head *unreachable, PyGC_Head *old, + bool *needs_resurrection_check) { PyGC_Head *gc; PyGC_Head wrcb_to_call; /* weakrefs with callbacks to call */ @@ -906,6 +898,9 @@ handle_weakref_callbacks(PyGC_Head *unreachable, PyGC_Head *old) /* Invoke the callbacks we decided to honor. It's safe to invoke them * because they can't reference unreachable objects. */ + if (!*needs_resurrection_check) { + *needs_resurrection_check = !gc_list_is_empty(&wrcb_to_call); + } while (! gc_list_is_empty(&wrcb_to_call)) { PyObject *temp; PyObject *callback; @@ -1001,11 +996,55 @@ clear_weakrefs(PyGC_Head *unreachable) } } -static void +/* "gc: " + " <" + " 0x" + 16 hex digits + ">\n" + NUL, excluding msg and + * tp_name */ +#define DEBUG_LINE_FIXED_LEN 32 + +static char * debug_cycle(const char *msg, PyObject *op) { - PySys_FormatStderr("gc: %s <%s %p>\n", - msg, Py_TYPE(op)->tp_name, op); + const char *name = Py_TYPE(op)->tp_name; + size_t size = strlen(msg) + strlen(name) + DEBUG_LINE_FIXED_LEN; + char *line = PyMem_RawMalloc(size); + if (line == NULL) { + return NULL; + } + /* Not %p: its output is platform-specific (no "0x" prefix on Windows). */ + PyOS_snprintf(line, size, "gc: %s <%s 0x%" PRIxPTR ">\n", + msg, name, (uintptr_t)op); + return line; +} + +/* Format a line for each object in `list` before printing any of them, + * since sys.stderr.write() can run Python code that frees objects in the + * list. + */ +static Py_ssize_t +debug_cycles(const char *msg, PyGC_Head *list) +{ + Py_ssize_t n = gc_list_size(list); + if (n == 0) { + return n; + } + + char **lines = PyMem_RawCalloc(n, sizeof(char *)); + if (lines == NULL) { + return n; + } + + Py_ssize_t i = 0; + for (PyGC_Head *gc = GC_NEXT(list); gc != list; gc = GC_NEXT(gc), i++) { + lines[i] = debug_cycle(msg, FROM_GC(gc)); + } + + for (i = 0; i < n; i++) { + if (lines[i] != NULL) { + PySys_FormatStderr("%s", lines[i]); + } + PyMem_RawFree(lines[i]); + } + PyMem_RawFree(lines); + return n; } /* Handle uncollectable garbage (cycles with tp_del slots, and stuff reachable @@ -1043,7 +1082,8 @@ handle_legacy_finalizers(PyThreadState *tstate, * list, due to refcounts falling to 0. */ static void -finalize_garbage(PyThreadState *tstate, PyGC_Head *collectable) +finalize_garbage(PyThreadState *tstate, PyGC_Head *collectable, + bool *needs_resurrection_check) { destructor finalize; PyGC_Head seen; @@ -1065,6 +1105,9 @@ finalize_garbage(PyThreadState *tstate, PyGC_Head *collectable) if (!_PyGC_FINALIZED(op) && (finalize = Py_TYPE(op)->tp_finalize) != NULL) { + if (!_PyGen_FinalizerIsNoop(op)) { + *needs_resurrection_check = true; + } _PyGC_SET_FINALIZED(op); Py_INCREF(op); finalize(op); @@ -1166,7 +1209,8 @@ flag is cleared (for example, by using 'clear_unreachable_mask' function or by a call to 'move_legacy_finalizers'), the 'unreachable' list is not a normal list and we can not use most gc_list_* functions for it. */ static inline Py_ssize_t -deduce_unreachable(PyGC_Head *base, PyGC_Head *unreachable) { +deduce_unreachable(PyGC_Head *base, PyGC_Head *unreachable, + Py_ssize_t *reachable) { validate_list(base, collecting_clear_unreachable_clear); /* Using ob_refcnt and gc_refs, calculate which objects in the * container set are reachable from outside the set (i.e., have a @@ -1212,7 +1256,8 @@ deduce_unreachable(PyGC_Head *base, PyGC_Head *unreachable) { * worth complicating the code to speed just a little. */ gc_list_init(unreachable); - move_unreachable(base, unreachable); // gc_prev is pointer again + // gc_prev is pointer again + *reachable = move_unreachable(base, unreachable); validate_list(base, collecting_clear_unreachable_clear); validate_list(unreachable, collecting_set_unreachable_set); return candidates; @@ -1243,7 +1288,8 @@ handle_resurrected_objects(PyGC_Head *unreachable, PyGC_Head* still_unreachable, // have the PREV_MARK_COLLECTING set, but the objects are going to be // removed so we can skip the expense of clearing the flag. PyGC_Head* resurrected = unreachable; - deduce_unreachable(resurrected, still_unreachable); + Py_ssize_t reachable; + deduce_unreachable(resurrected, still_unreachable, &reachable); clear_unreachable_mask(still_unreachable); // Move the resurrected objects to the old generation for future collection. @@ -1399,6 +1445,13 @@ gc_get_prev_stats(GCState *gcstate, int gen) static void add_stats(GCState *gcstate, int gen, struct gc_generation_stats *stats) { + struct gc_stats *generation_stats = gcstate->generation_stats; + uint32_t seq = _Py_atomic_load_uint32_relaxed(&generation_stats->update_seq); + assert((seq & 1) == 0); + /* Odd seq tells the reader that an update is in progress. */ + _Py_atomic_store_uint32_relaxed(&generation_stats->update_seq, seq + 1); + _Py_atomic_fence_seq_cst(); + struct gc_generation_stats *prev_stats = gc_get_prev_stats(gcstate, gen); struct gc_generation_stats *cur_stats = gc_get_stats(gcstate, gen); @@ -1412,9 +1465,8 @@ add_stats(GCState *gcstate, int gen, struct gc_generation_stats *stats) cur_stats->duration += stats->duration; cur_stats->heap_size = stats->heap_size; - /* Publish ts_stop last so remote readers do not select a partially - updated stats record as the latest collection. */ cur_stats->ts_stop = stats->ts_stop; + _Py_atomic_store_uint32_release(&generation_stats->update_seq, seq + 2); } /* This is the main function. Read this to understand how the @@ -1427,7 +1479,6 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason) PyGC_Head *old; /* next older generation */ PyGC_Head unreachable; /* non-problematic unreachable trash */ PyGC_Head finalizers; /* objects with, & reachable from, __del__ */ - PyGC_Head *gc; GCState *gcstate = &tstate->interp->gc; // gc_collect_main() must not be called before _PyGC_Init @@ -1506,13 +1557,13 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason) } validate_list(old, collecting_clear_unreachable_clear); - stats.candidates = deduce_unreachable(young, &unreachable); + Py_ssize_t reachable; + stats.candidates = deduce_unreachable(young, &unreachable, &reachable); - untrack_tuples(young); /* Move reachable objects to next generation. */ if (young != old) { if (generation == NUM_GENERATIONS - 2) { - gcstate->long_lived_pending += gc_list_size(young); + gcstate->long_lived_pending += reachable; } gc_list_merge(young, old); } @@ -1525,7 +1576,7 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason) // site; the cost is slightly more work for full collections on dicts // with only atomic values. gcstate->long_lived_pending = 0; - gcstate->long_lived_total = gc_list_size(young); + gcstate->long_lived_total = reachable; } /* All objects in unreachable are trash, but objects reachable from @@ -1544,26 +1595,37 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason) validate_list(&finalizers, collecting_clear_unreachable_clear); validate_list(&unreachable, collecting_set_unreachable_clear); + bool needs_resurrection_check = false; + /* Print debugging information. */ if (gcstate->debug & _PyGC_DEBUG_COLLECTABLE) { - for (gc = GC_NEXT(&unreachable); gc != &unreachable; gc = GC_NEXT(gc)) { - debug_cycle("collectable", FROM_GC(gc)); - } + /* sys.stderr.write() can resurrect objects. */ + needs_resurrection_check = true; + debug_cycles("collectable", &unreachable); } /* Clear weakrefs and invoke callbacks as necessary. */ - stats.collected += handle_weakref_callbacks(&unreachable, old); + stats.collected += handle_weakref_callbacks(&unreachable, old, + &needs_resurrection_check); validate_list(old, collecting_clear_unreachable_clear); validate_list(&unreachable, collecting_set_unreachable_clear); /* Call tp_finalize on objects which have one. */ - finalize_garbage(tstate, &unreachable); + finalize_garbage(tstate, &unreachable, &needs_resurrection_check); /* Handle any objects that may have resurrected after the call * to 'finalize_garbage' and continue the collection with the * objects that are still unreachable */ PyGC_Head final_unreachable; - handle_resurrected_objects(&unreachable, &final_unreachable, old); + if (needs_resurrection_check) { + handle_resurrected_objects(&unreachable, &final_unreachable, old); + } + else { + /* No Python code ran during finalization, so the original + * unreachable set is still valid. */ + gc_list_init(&final_unreachable); + gc_list_merge(&unreachable, &final_unreachable); + } /* Clear weakrefs to objects in the unreachable set. No Python-level * code must be allowed to access those unreachable objects. During @@ -1582,13 +1644,12 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason) /* Collect statistics on uncollectable objects found and print * debugging information. */ - Py_ssize_t n = 0; - for (gc = GC_NEXT(&finalizers); gc != &finalizers; gc = GC_NEXT(gc)) { - n++; - if (gcstate->debug & _PyGC_DEBUG_UNCOLLECTABLE) - debug_cycle("uncollectable", FROM_GC(gc)); + if (gcstate->debug & _PyGC_DEBUG_UNCOLLECTABLE) { + stats.uncollectable = debug_cycles("uncollectable", &finalizers); + } + else { + stats.uncollectable = gc_list_size(&finalizers); } - stats.uncollectable = n; (void)PyTime_PerfCounterRaw(&stats.ts_stop); stats.duration = PyTime_AsSecondsDouble(stats.ts_stop - stats.ts_start); if (gcstate->debug & _PyGC_DEBUG_STATS) { @@ -2006,7 +2067,7 @@ static PyObject * gc_alloc(PyTypeObject *tp, size_t basicsize, size_t presize) { PyThreadState *tstate = _PyThreadState_GET(); - if (basicsize > PY_SSIZE_T_MAX - presize) { + if (basicsize > (size_t)PY_SSIZE_T_MAX - presize) { return _PyErr_NoMemory(tstate); } size_t size = presize + basicsize; @@ -2077,6 +2138,13 @@ PyUnstable_Object_GC_NewWithExtraData(PyTypeObject *tp, size_t extra_size) PyVarObject * _PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems) { +#ifdef Py_DEBUG + if (nitems < 0) { + PyErr_BadInternalCall(); + return NULL; + } +#endif + const size_t basicsize = _PyObject_VAR_SIZE(Py_TYPE(op), nitems); const size_t presize = _PyType_PreHeaderSize(Py_TYPE(op)); _PyObject_ASSERT((PyObject *)op, !_PyObject_GC_IS_TRACKED(op)); diff --git a/Python/gc_free_threading.c b/Python/gc_free_threading.c index 99f1a1eb47e3ddc..0d27224e59b3da8 100644 --- a/Python/gc_free_threading.c +++ b/Python/gc_free_threading.c @@ -9,7 +9,9 @@ #include "pycore_initconfig.h" // _PyStatus_NO_MEMORY() #include "pycore_interp.h" // PyInterpreterState.gc #include "pycore_interpframe.h" // _PyFrame_GetLocalsArray() +#include "pycore_list.h" // _PyList_GetItemRef() #include "pycore_object_alloc.h" // _PyObject_MallocWithType() +#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_INT_RELAXED() #include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_tstate.h" // _PyThreadStateImpl #include "pycore_tuple.h" // _PyTuple_MaybeUntrack() @@ -398,16 +400,17 @@ gc_visit_heaps_lock_held(PyInterpreterState *interp, mi_block_visit_fun *visitor } } - // visit blocks in the per-interpreter abandoned pool (from dead threads) - mi_abandoned_pool_t *pool = &interp->mimalloc.abandoned_pool; + // visit blocks in abandoned segments (from dead threads) of the + // per-interpreter mimalloc sub-process. + mi_subproc_t *subproc = interp->mimalloc.subproc; arg->offset = offset_base; - if (!_mi_abandoned_pool_visit_blocks(pool, _Py_MIMALLOC_HEAP_GC, true, - visitor, arg)) { + if (!mi_abandoned_visit_blocks(subproc, _Py_MIMALLOC_HEAP_GC, true, + visitor, arg)) { return -1; } arg->offset = offset_pre; - if (!_mi_abandoned_pool_visit_blocks(pool, _Py_MIMALLOC_HEAP_GC_PRE, true, - visitor, arg)) { + if (!mi_abandoned_visit_blocks(subproc, _Py_MIMALLOC_HEAP_GC_PRE, true, + visitor, arg)) { return -1; } return 0; @@ -467,6 +470,7 @@ gc_visit_thread_stacks(PyInterpreterState *interp, struct collection_state *stat continue; } + gc_visit_stackref(f->f_funcobj); gc_visit_stackref(f->f_executable); while (top != f->localsplus) { --top; @@ -547,7 +551,7 @@ static_assert(BUFFER_HI < BUFFER_SIZE && #define PREFETCH_T1(ptr) __builtin_prefetch(ptr, 0, 2) #define PREFETCH_T2(ptr) __builtin_prefetch(ptr, 0, 1) #define PREFETCH_NTA(ptr) __builtin_prefetch(ptr, 0, 0) -#elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) && !defined(_M_ARM64EC) +#elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) && !defined(_M_ARM64EC) #include #define PREFETCH_T0(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0) #define PREFETCH_T1(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1) @@ -863,6 +867,10 @@ gc_visit_thread_stacks_mark_alive(PyInterpreterState *interp, gc_mark_args_t *ar } _PyStackRef *top = f->stackpointer; + if (gc_visit_stackref_mark_alive(args, f->f_funcobj) < 0) { + err = -1; + goto exit; + } if (gc_visit_stackref_mark_alive(args, f->f_executable) < 0) { err = -1; goto exit; @@ -1541,11 +1549,19 @@ move_legacy_finalizer_reachable(struct collection_state *state) // or missing `tp_traverse` methods. When that object goes away, the callback // for weakref can be executed and that could reveal unreachable objects to // Python-level code. See bpo-38006 as an example bug. -static void -find_weakref_callbacks(struct collection_state *state) +static bool +prepare_finalization(struct collection_state *state, + bool *needs_resurrection_check) { + bool has_finalizers = false; PyObject *op; WORKSTACK_FOR_EACH(&state->unreachable, op) { + if (!_PyGC_FINALIZED(op) && Py_TYPE(op)->tp_finalize != NULL) { + has_finalizers = true; + if (!_PyGen_FinalizerIsNoop(op)) { + *needs_resurrection_check = true; + } + } if (!_PyType_SUPPORTS_WEAKREFS(Py_TYPE(op))) { continue; } @@ -1589,12 +1605,14 @@ find_weakref_callbacks(struct collection_state *state) // Enqueue weakref to be called later. worklist_push(&state->wrcb_to_call, (PyObject *)wr); + *needs_resurrection_check = true; } } + return has_finalizers; } // Clear weakrefs to objects in the unreachable set. See comments -// above find_weakref_callbacks() for why this clearing is required. +// above prepare_finalization() for why this clearing is required. static void clear_weakrefs(struct collection_state *state) { @@ -1727,6 +1745,7 @@ delete_garbage(struct collection_state *state) { PyThreadState *tstate = _PyThreadState_GET(); GCState *gcstate = state->gcstate; + int debug = FT_ATOMIC_LOAD_INT_RELAXED(gcstate->debug); assert(!_PyErr_Occurred(tstate)); @@ -1749,7 +1768,7 @@ delete_garbage(struct collection_state *state) state->collected++; - if (gcstate->debug & _PyGC_DEBUG_SAVEALL) { + if (debug & _PyGC_DEBUG_SAVEALL) { assert(gcstate->garbage != NULL); if (PyList_Append(gcstate->garbage, op) < 0) { _PyErr_Clear(tstate); @@ -1775,16 +1794,17 @@ handle_legacy_finalizers(struct collection_state *state) { GCState *gcstate = state->gcstate; assert(gcstate->garbage != NULL); + int debug = FT_ATOMIC_LOAD_INT_RELAXED(gcstate->debug); PyObject *op; while ((op = worklist_pop(&state->legacy_finalizers)) != NULL) { state->uncollectable++; - if (gcstate->debug & _PyGC_DEBUG_UNCOLLECTABLE) { + if (debug & _PyGC_DEBUG_UNCOLLECTABLE) { debug_cycle("uncollectable", op); } - if ((gcstate->debug & _PyGC_DEBUG_SAVEALL) || has_legacy_finalizer(op)) { + if ((debug & _PyGC_DEBUG_SAVEALL) || has_legacy_finalizer(op)) { if (PyList_Append(gcstate->garbage, op) < 0) { PyErr_Clear(); } @@ -1940,24 +1960,25 @@ invoke_gc_callback(PyThreadState *tstate, const char *phase, /* The local variable cannot be rebound, check it for sanity */ assert(PyList_CheckExact(gcstate->callbacks)); - PyObject *info = NULL; - if (PyList_GET_SIZE(gcstate->callbacks) != 0) { - info = Py_BuildValue("{sisnsnsnsd}", - "generation", generation, - "collected", collected, - "uncollectable", uncollectable, - "candidates", candidates, - "duration", duration); - if (info == NULL) { - PyErr_FormatUnraisable("Exception ignored while " - "invoking gc callbacks"); - return; - } + if (PyList_GET_SIZE(gcstate->callbacks) == 0) { + return; + } + + PyObject *info = Py_BuildValue("{sisnsnsnsd}", + "generation", generation, + "collected", collected, + "uncollectable", uncollectable, + "candidates", candidates, + "duration", duration); + if (info == NULL) { + PyErr_FormatUnraisable("Exception ignored while " + "invoking gc callbacks"); + return; } PyObject *phase_obj = PyUnicode_FromString(phase); if (phase_obj == NULL) { - Py_XDECREF(info); + Py_DECREF(info); PyErr_FormatUnraisable("Exception ignored while " "invoking gc callbacks"); return; @@ -1965,8 +1986,10 @@ invoke_gc_callback(PyThreadState *tstate, const char *phase, PyObject *stack[] = {phase_obj, info}; for (Py_ssize_t i=0; icallbacks); i++) { - PyObject *r, *cb = PyList_GET_ITEM(gcstate->callbacks, i); - Py_INCREF(cb); /* make sure cb doesn't go away */ + PyObject *r, *cb = _PyList_GetItemRef((PyListObject *)gcstate->callbacks, i); + if (cb == NULL) { + break; + } r = PyObject_Vectorcall(cb, stack, 2, NULL); if (r == NULL) { PyErr_FormatUnraisable("Exception ignored while " @@ -1978,7 +2001,7 @@ invoke_gc_callback(PyThreadState *tstate, const char *phase, Py_DECREF(cb); } Py_DECREF(phase_obj); - Py_XDECREF(info); + Py_DECREF(info); assert(!_PyErr_Occurred(tstate)); } @@ -2109,6 +2132,7 @@ gc_collect_internal(PyInterpreterState *interp, struct collection_state *state, int err = gc_mark_alive_from_roots(interp, state); if (err < 0) { _PyEval_StartTheWorld(interp); + cleanup_worklist(&state->objs_to_decref); PyErr_NoMemory(); return; } @@ -2119,6 +2143,9 @@ gc_collect_internal(PyInterpreterState *interp, struct collection_state *state, int err = deduce_unreachable_heap(interp, state); if (err < 0) { _PyEval_StartTheWorld(interp); + cleanup_worklist(&state->unreachable); + cleanup_worklist(&state->legacy_finalizers); + cleanup_worklist(&state->objs_to_decref); PyErr_NoMemory(); return; } @@ -2128,29 +2155,44 @@ gc_collect_internal(PyInterpreterState *interp, struct collection_state *state, gc_visit_heaps(interp, &validate_alive_bits, &state->base); #endif - // Print debugging information. - if (interp->gc.debug & _PyGC_DEBUG_COLLECTABLE) { - PyObject *op; - WORKSTACK_FOR_EACH(&state->unreachable, op) { - debug_cycle("collectable", op); - } - } + // Deallocations after the refcount merge may run Python code. + bool needs_resurrection_check = state->objs_to_decref.head != 0; - // Find weakref callbacks we will honor (but do not call them). - find_weakref_callbacks(state); - _PyEval_StartTheWorld(interp); + // The debug output is written with sys.stderr.write(), which may run + // Python code, so it is printed below after the world is started. + bool debug_print = (FT_ATOMIC_LOAD_INT_RELAXED(interp->gc.debug) & + _PyGC_DEBUG_COLLECTABLE) != 0; - // Deallocate any object from the refcount merge step - cleanup_worklist(&state->objs_to_decref); + // Find weakref callbacks and pending finalizers (but do not call them). + bool has_finalizers = prepare_finalization(state, &needs_resurrection_check); + if (needs_resurrection_check || debug_print) { + _PyEval_StartTheWorld(interp); - // Call weakref callbacks and finalizers after unpausing other threads to - // avoid potential deadlocks. - call_weakref_callbacks(state); - finalize_garbage(state); + // Print debugging information. + if (debug_print) { + PyObject *op; + WORKSTACK_FOR_EACH(&state->unreachable, op) { + debug_cycle("collectable", op); + } + } - _PyEval_StopTheWorld(interp); - // Handle any objects that may have resurrected after the finalization. - err = handle_resurrected_objects(state); + // Deallocate any object from the refcount merge step + cleanup_worklist(&state->objs_to_decref); + + // Call weakref callbacks and finalizers after unpausing other threads to + // avoid potential deadlocks. + call_weakref_callbacks(state); + finalize_garbage(state); + + _PyEval_StopTheWorld(interp); + // Handle any objects that may have resurrected after the finalization. + err = handle_resurrected_objects(state); + } + else if (has_finalizers) { + // Only no-op generator finalizers remain; keep other threads paused. + finalize_garbage(state); + } + // Otherwise, keep other threads paused so the unreachable set stays valid. // Clear free lists in all threads _PyGC_ClearAllFreeLists(interp); if (err == 0) { @@ -2235,7 +2277,8 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason) invoke_gc_callback(tstate, "start", generation, 0, 0, 0, 0.0); } - if (gcstate->debug & _PyGC_DEBUG_STATS) { + int debug = FT_ATOMIC_LOAD_INT_RELAXED(gcstate->debug); + if (debug & _PyGC_DEBUG_STATS) { PySys_WriteStderr("gc: collecting generation %d...\n", generation); show_stats_each_generations(gcstate); } @@ -2262,7 +2305,7 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason) (void)PyTime_PerfCounterRaw(&stop); double duration = PyTime_AsSecondsDouble(stop - start); - if (gcstate->debug & _PyGC_DEBUG_STATS) { + if (debug & _PyGC_DEBUG_STATS) { PySys_WriteStderr( "gc: done, %zd unreachable, %zd uncollectable, %.4fs elapsed\n", n+m, n, duration); @@ -2283,6 +2326,12 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason) /* Update stats. */ PyMutex_Lock(&gcstate->stats_mutex); + struct gc_stats *generation_stats = gcstate->generation_stats; + uint32_t seq = _Py_atomic_load_uint32_relaxed(&generation_stats->update_seq); + assert((seq & 1) == 0); + /* Odd seq tells the reader that an update is in progress. */ + _Py_atomic_store_uint32_relaxed(&generation_stats->update_seq, seq + 1); + _Py_atomic_fence_seq_cst(); struct gc_generation_stats *stats = get_stats(gcstate, generation); stats->ts_start = start; stats->ts_stop = stop; @@ -2291,6 +2340,7 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason) stats->uncollectable += n; stats->duration += duration; stats->candidates += state.candidates; + _Py_atomic_store_uint32_release(&generation_stats->update_seq, seq + 2); PyMutex_Unlock(&gcstate->stats_mutex); GC_STAT_ADD(generation, objects_collected, m); @@ -2380,9 +2430,10 @@ visit_get_referrers(const mi_heap_t *heap, const mi_heap_area_t *area, return true; } if (Py_TYPE(op)->tp_traverse(op, referrersvisit, arg->objs)) { - if (_PyObjectStack_Push(&arg->results, Py_NewRef(op)) < 0) { + if (_PyObjectStack_Push(&arg->results, op) < 0) { return false; } + Py_INCREF(op); } return true; @@ -2427,9 +2478,10 @@ visit_get_objects(const mi_heap_t *heap, const mi_heap_area_t *area, } struct get_objects_args *arg = (struct get_objects_args *)args; - if (_PyObjectStack_Push(&arg->objects, Py_NewRef(op)) < 0) { + if (_PyObjectStack_Push(&arg->objects, op) < 0) { return false; } + Py_INCREF(op); return true; } @@ -2586,10 +2638,11 @@ void _PyGC_DumpShutdownStats(PyInterpreterState *interp) { GCState *gcstate = &interp->gc; - if (!(gcstate->debug & _PyGC_DEBUG_SAVEALL) + int debug = FT_ATOMIC_LOAD_INT_RELAXED(gcstate->debug); + if (!(debug & _PyGC_DEBUG_SAVEALL) && gcstate->garbage != NULL && PyList_GET_SIZE(gcstate->garbage) > 0) { const char *message; - if (gcstate->debug & _PyGC_DEBUG_UNCOLLECTABLE) { + if (debug & _PyGC_DEBUG_UNCOLLECTABLE) { message = "gc: %zd uncollectable objects at shutdown"; } else { @@ -2605,7 +2658,7 @@ _PyGC_DumpShutdownStats(PyInterpreterState *interp) { PyErr_FormatUnraisable("Exception ignored in GC shutdown"); } - if (gcstate->debug & _PyGC_DEBUG_UNCOLLECTABLE) { + if (debug & _PyGC_DEBUG_UNCOLLECTABLE) { PyObject *repr = NULL, *bytes = NULL; repr = PyObject_Repr(gcstate->garbage); if (!repr || !(bytes = PyUnicode_EncodeFSDefault(repr))) { @@ -2722,7 +2775,7 @@ static PyObject * gc_alloc(PyTypeObject *tp, size_t basicsize, size_t presize) { PyThreadState *tstate = _PyThreadState_GET(); - if (basicsize > PY_SSIZE_T_MAX - presize) { + if (basicsize > (size_t)PY_SSIZE_T_MAX - presize) { return _PyErr_NoMemory(tstate); } size_t size = presize + basicsize; @@ -2794,6 +2847,13 @@ PyUnstable_Object_GC_NewWithExtraData(PyTypeObject *tp, size_t extra_size) PyVarObject * _PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems) { +#ifdef Py_DEBUG + if (nitems < 0) { + PyErr_BadInternalCall(); + return NULL; + } +#endif + const size_t basicsize = _PyObject_VAR_SIZE(Py_TYPE(op), nitems); const size_t presize = _PyType_PreHeaderSize(((PyObject *)op)->ob_type); _PyObject_ASSERT((PyObject *)op, !_PyObject_GC_IS_TRACKED(op)); @@ -2856,7 +2916,7 @@ static bool custom_visitor_wrapper(const mi_heap_t *heap, const mi_heap_area_t *area, void *block, size_t block_size, void *args) { - PyObject *op = op_from_block(block, args, false); + PyObject *op = op_from_block(block, args, true); if (op == NULL) { return true; } diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 6178dc70c1b80e7..3af7863e80d2c6a 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -2488,7 +2488,8 @@ assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); } - if (PyCFunction_GET_FLAGS(callable_o) != METH_FASTCALL) { + if ((PyCFunction_GET_FLAGS(callable_o) & + _Py_METH_CALL_FLAGS) != METH_FASTCALL) { UPDATE_MISS_STATS(CALL); assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); @@ -2581,7 +2582,8 @@ assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); } - if (PyCFunction_GET_FLAGS(callable_o) != (METH_FASTCALL | METH_KEYWORDS)) { + if ((PyCFunction_GET_FLAGS(callable_o) & + _Py_METH_CALL_FLAGS) != (METH_FASTCALL | METH_KEYWORDS)) { UPDATE_MISS_STATS(CALL); assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); @@ -2674,7 +2676,8 @@ assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); } - if (PyCFunction_GET_FLAGS(callable_o) != METH_O) { + if ((PyCFunction_GET_FLAGS(callable_o) & + _Py_METH_CALL_FLAGS) != METH_O) { UPDATE_MISS_STATS(CALL); assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); @@ -3981,6 +3984,22 @@ int err = _PyList_AppendTakeRef((PyListObject *)self_o, PyStackRef_AsPyObjectSteal(arg)); UNLOCK_OBJECT(self_o); if (err) { + _PyFrame_SetStackPointer(frame, stack_pointer); + _PyFrame_StackPointerValidate(frame); + _PyStackRef tmp = self; + self = PyStackRef_NULL; + stack_pointer[-2] = self; + PyStackRef_CLOSE(tmp); + _PyFrame_StackPointerInvalidate(frame); + assert(stack_pointer == _PyFrame_GetStackPointer(frame)); + _PyFrame_StackPointerValidate(frame); + tmp = callable; + callable = PyStackRef_NULL; + stack_pointer[-3] = callable; + PyStackRef_CLOSE(tmp); + _PyFrame_StackPointerInvalidate(frame); + stack_pointer += -3; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); JUMP_TO_LABEL(error); } c = callable; @@ -4041,7 +4060,8 @@ assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); } - if (method->d_method->ml_flags != METH_FASTCALL) { + if ((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + METH_FASTCALL) { UPDATE_MISS_STATS(CALL); assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); @@ -4160,7 +4180,8 @@ assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); } - if (method->d_method->ml_flags != (METH_FASTCALL|METH_KEYWORDS)) { + if ((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + (METH_FASTCALL | METH_KEYWORDS)) { UPDATE_MISS_STATS(CALL); assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); @@ -4283,7 +4304,8 @@ assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); } - if (method->d_method->ml_flags != METH_NOARGS) { + if ((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + METH_NOARGS) { UPDATE_MISS_STATS(CALL); assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); @@ -4406,7 +4428,8 @@ assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); } - if (method->d_method->ml_flags != METH_O) { + if ((method->d_method->ml_flags & _Py_METH_CALL_FLAGS) != + METH_O) { UPDATE_MISS_STATS(CALL); assert(_PyOpcode_Deopt[opcode] == (CALL)); JUMP_TO_PREDICTED(CALL); @@ -6776,6 +6799,8 @@ INSTRUCTION_STATS(GET_ANEXT); _PyStackRef aiter; _PyStackRef awaitable; + _PyStackRef null; + _PyStackRef none; aiter = stack_pointer[-1]; _PyFrame_SetStackPointer(frame, stack_pointer); _PyFrame_StackPointerValidate(frame); @@ -6785,8 +6810,12 @@ JUMP_TO_LABEL(error); } awaitable = PyStackRef_FromPyObjectSteal(awaitable_o); + null = PyStackRef_NULL; + none = PyStackRef_None; stack_pointer[0] = awaitable; - stack_pointer += 1; + stack_pointer[1] = null; + stack_pointer[2] = none; + stack_pointer += 3; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); DISPATCH(); } @@ -6801,6 +6830,8 @@ INSTRUCTION_STATS(GET_AWAITABLE); _PyStackRef iterable; _PyStackRef iter; + _PyStackRef null; + _PyStackRef none; iterable = stack_pointer[-1]; _PyFrame_SetStackPointer(frame, stack_pointer); _PyFrame_StackPointerValidate(frame); @@ -6816,8 +6847,12 @@ JUMP_TO_LABEL(error); } iter = PyStackRef_FromPyObjectSteal(iter_o); + null = PyStackRef_NULL; + none = PyStackRef_None; stack_pointer[0] = iter; - stack_pointer += 1; + stack_pointer[1] = null; + stack_pointer[2] = none; + stack_pointer += 3; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); DISPATCH(); } @@ -9206,7 +9241,7 @@ uint32_t dict_version = read_u32(&this_instr[2].cache); uint16_t index = read_u16(&this_instr[4].cache); PyObject *owner_o = PyStackRef_AsPyObjectBorrow(owner); - if (Py_TYPE(owner_o)->tp_getattro != PyModule_Type.tp_getattro) { + if (!PyModule_CheckExact(owner_o)) { UPDATE_MISS_STATS(LOAD_ATTR); assert(_PyOpcode_Deopt[opcode] == (LOAD_ATTR)); JUMP_TO_PREDICTED(LOAD_ATTR); @@ -9905,6 +9940,16 @@ JUMP_TO_LABEL(error); } } + else if (PyLazyImport_CheckExact(value_o)) { + assert(stack_pointer == _PyFrame_GetStackPointer(frame)); + _PyFrame_StackPointerValidate(frame); + Py_SETREF(value_o, _PyLazyImport_Reify( + tstate, value_o, name, class_dict)); + _PyFrame_StackPointerInvalidate(frame); + if (value_o == NULL) { + JUMP_TO_LABEL(error); + } + } stack_pointer += -1; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); @@ -9930,11 +9975,21 @@ _PyStackRef v; mod_or_class_dict = stack_pointer[-1]; PyObject *name = GETITEM(FRAME_CO_NAMES, oparg); + PyObject *namespace = PyStackRef_AsPyObjectBorrow(mod_or_class_dict); int err; _PyFrame_SetStackPointer(frame, stack_pointer); _PyFrame_StackPointerValidate(frame); - PyObject *v_o = _PyMapping_GetOptionalItem2(PyStackRef_AsPyObjectBorrow(mod_or_class_dict), name, &err); + PyObject *v_o = _PyMapping_GetOptionalItem2(namespace, name, &err); _PyFrame_StackPointerInvalidate(frame); + if (v_o != NULL && PyLazyImport_CheckExact(v_o)) { + assert(stack_pointer == _PyFrame_GetStackPointer(frame)); + _PyFrame_StackPointerValidate(frame); + Py_SETREF(v_o, _PyLazyImport_Reify(tstate, v_o, name, namespace)); + _PyFrame_StackPointerInvalidate(frame); + if (v_o == NULL) { + err = -1; + } + } stack_pointer += -1; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); @@ -9945,81 +10000,17 @@ JUMP_TO_LABEL(error); } if (v_o == NULL) { - if (PyDict_CheckExact(GLOBALS()) - && PyDict_CheckExact(BUILTINS())) - { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - v_o = _PyDict_LoadGlobal((PyDictObject *)GLOBALS(), - (PyDictObject *)BUILTINS(), - name); - _PyFrame_StackPointerInvalidate(frame); - if (v_o == NULL) { - if (!_PyErr_Occurred(tstate)) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - _PyEval_FormatExcCheckArg(tstate, PyExc_NameError, - NAME_ERROR_MSG, name); - _PyFrame_StackPointerInvalidate(frame); - } - JUMP_TO_LABEL(error); - } - if (PyLazyImport_CheckExact(v_o)) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - PyObject *l_v = _PyImport_LoadLazyImportTstate(tstate, v_o); - _PyFrame_StackPointerInvalidate(frame); - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_SETREF(v_o, l_v); - _PyFrame_StackPointerInvalidate(frame); - if (v_o == NULL) { - JUMP_TO_LABEL(error); - } - } - } - else { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - v_o = _PyMapping_GetOptionalItem2(GLOBALS(), name, &err); - _PyFrame_StackPointerInvalidate(frame); - if (err < 0) { - JUMP_TO_LABEL(error); - } - if (v_o == NULL) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - v_o = _PyMapping_GetOptionalItem2(BUILTINS(), name, &err); - _PyFrame_StackPointerInvalidate(frame); - if (err < 0) { - JUMP_TO_LABEL(error); - } - if (v_o == NULL) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - _PyEval_FormatExcCheckArg( - tstate, PyExc_NameError, - NAME_ERROR_MSG, name); - _PyFrame_StackPointerInvalidate(frame); - JUMP_TO_LABEL(error); - } - } - if (PyLazyImport_CheckExact(v_o)) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - PyObject *l_v = _PyImport_LoadLazyImportTstate(tstate, v_o); - _PyFrame_StackPointerInvalidate(frame); - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_SETREF(v_o, l_v); - _PyFrame_StackPointerInvalidate(frame); - if (v_o == NULL) { - JUMP_TO_LABEL(error); - } - } + assert(stack_pointer == _PyFrame_GetStackPointer(frame)); + _PyFrame_StackPointerValidate(frame); + _PyEval_LoadGlobalStackRef(GLOBALS(), BUILTINS(), name, &v); + _PyFrame_StackPointerInvalidate(frame); + if (PyStackRef_IsNull(v)) { + JUMP_TO_LABEL(error); } } - v = PyStackRef_FromPyObjectSteal(v_o); + else { + v = PyStackRef_FromPyObjectSteal(v_o); + } stack_pointer[0] = v; stack_pointer += 1; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); @@ -10139,7 +10130,7 @@ assert(_PyOpcode_Deopt[opcode] == (LOAD_GLOBAL)); JUMP_TO_PREDICTED(LOAD_GLOBAL); } - #if Py_GIL_DISABLED + #ifdef Py_GIL_DISABLED int increfed = _Py_TryIncrefCompareStackRef(&entries[index].me_value, res_o, &res); if (!increfed) { UPDATE_MISS_STATS(LOAD_GLOBAL); @@ -10206,7 +10197,7 @@ assert(_PyOpcode_Deopt[opcode] == (LOAD_GLOBAL)); JUMP_TO_PREDICTED(LOAD_GLOBAL); } - #if Py_GIL_DISABLED + #ifdef Py_GIL_DISABLED int increfed = _Py_TryIncrefCompareStackRef(&entries[index].me_value, res_o, &res); if (!increfed) { UPDATE_MISS_STATS(LOAD_GLOBAL); @@ -10273,38 +10264,6 @@ if (v_o == NULL) { JUMP_TO_LABEL(error); } - if (PyLazyImport_CheckExact(v_o)) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - PyObject *l_v = _PyImport_LoadLazyImportTstate(tstate, v_o); - _PyFrame_StackPointerInvalidate(frame); - if (l_v == NULL) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_DECREF(v_o); - _PyFrame_StackPointerInvalidate(frame); - JUMP_TO_LABEL(error); - } - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - int err = PyDict_SetItem(GLOBALS(), name, l_v); - _PyFrame_StackPointerInvalidate(frame); - if (err < 0) { - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_DECREF(v_o); - _PyFrame_StackPointerInvalidate(frame); - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_DECREF(l_v); - _PyFrame_StackPointerInvalidate(frame); - JUMP_TO_LABEL(error); - } - assert(stack_pointer == _PyFrame_GetStackPointer(frame)); - _PyFrame_StackPointerValidate(frame); - Py_SETREF(v_o, l_v); - _PyFrame_StackPointerInvalidate(frame); - } v = PyStackRef_FromPyObjectSteal(v_o); stack_pointer[0] = v; stack_pointer += 1; @@ -10355,7 +10314,8 @@ ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); _PyFrame_StackPointerValidate(frame); - int err = _PyObject_LookupSpecialMethod(name, method_and_self); + int err = _PyObject_LookupSpecialMethod(name, &method_and_self[0], + &method_and_self[1]); _PyFrame_StackPointerInvalidate(frame); if (err <= 0) { if (err == 0) { @@ -12993,11 +12953,11 @@ _PyStackRef value; _PyStackRef res; _PyStackRef v; - // _GUARD_TOS_INT + // _GUARD_TOS_EXACT_INT { value = stack_pointer[-1]; PyObject *value_o = PyStackRef_AsPyObjectBorrow(value); - if (!_PyLong_CheckExactAndCompact(value_o)) { + if (!PyLong_CheckExact(value_o)) { UPDATE_MISS_STATS(TO_BOOL); assert(_PyOpcode_Deopt[opcode] == (TO_BOOL)); JUMP_TO_PREDICTED(TO_BOOL); diff --git a/Python/getargs.c b/Python/getargs.c index 3f423266bff7f47..70bd54a23e939ce 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -124,18 +124,6 @@ _PyArg_ParseTuple_SizeT(PyObject *args, const char *format, ...) } -int -_PyArg_ParseStack(PyObject *const *args, Py_ssize_t nargs, const char *format, ...) -{ - int retval; - va_list va; - - va_start(va, format); - retval = vgetargs1_impl(NULL, args, nargs, format, &va, 0); - va_end(va); - return retval; -} - int PyArg_ParseArray(PyObject *const *args, Py_ssize_t nargs, const char *format, ...) { @@ -2933,6 +2921,7 @@ _PyArg_UnpackStack(PyObject *const *args, Py_ssize_t nargs, const char *name, #undef _PyArg_NoKeywords #undef _PyArg_NoKwnames #undef _PyArg_NoPositional +#undef _PyArg_NoPositionalStack /* For type constructors that don't take keyword args * @@ -2967,8 +2956,15 @@ _PyArg_NoPositional(const char *funcname, PyObject *args) PyErr_BadInternalCall(); return 0; } - if (PyTuple_GET_SIZE(args) == 0) + return _PyArg_NoPositionalStack(funcname, PyTuple_GET_SIZE(args)); +} + +int +_PyArg_NoPositionalStack(const char *funcname, Py_ssize_t nargs) +{ + if (nargs == 0) { return 1; + } PyErr_Format(PyExc_TypeError, "%.200s() takes no positional arguments", funcname); diff --git a/Python/getopt.c b/Python/getopt.c index 79bea2359ffffcf..c64d6e65c2740ad 100644 --- a/Python/getopt.c +++ b/Python/getopt.c @@ -27,135 +27,159 @@ #include #include #include -#include "pycore_getopt.h" +#include "pycore_getopt.h" // struct _PyOS_GetOpt -int _PyOS_opterr = 1; /* generate error messages */ -Py_ssize_t _PyOS_optind = 1; /* index into argv array */ -const wchar_t *_PyOS_optarg = NULL; /* optional argument */ - -static const wchar_t *opt_ptr = L""; /* Python command line short and long options */ #define SHORT_OPTS L"bBc:dEhiIm:OPqRsStuvVW:xX:?" +typedef struct { + const wchar_t *name; + int has_arg; + int val; +} _PyOS_LongOption; + static const _PyOS_LongOption longopts[] = { /* name, has_arg, val (used in switch in initconfig.c) */ - {L"check-hash-based-pycs", 1, 0}, - {L"help-all", 0, 1}, - {L"help-env", 0, 2}, - {L"help-xoptions", 0, 3}, + {L"check-hash-based-pycs", 1, 1}, + {L"help-all", 0, 2}, + {L"help-env", 0, 3}, + {L"help-xoptions", 0, 4}, {NULL, 0, -1}, /* sentinel */ }; -void _PyOS_ResetGetOpt(void) +void +_PyOS_GetOpt_Init(struct _PyOS_GetOpt *getopt, + Py_ssize_t argc, wchar_t * const *argv) { - _PyOS_opterr = 1; - _PyOS_optind = 1; - _PyOS_optarg = NULL; - opt_ptr = L""; + getopt->error = 1; + getopt->index = 1; + getopt->arg = NULL; + getopt->ptr = L""; + getopt->argc = argc; + getopt->argv = argv; } -int _PyOS_GetOpt(Py_ssize_t argc, wchar_t * const *argv, int *longindex) +// Parse a command line option. +// +// Return a character for short option (ex: return 'h' for -h). +// Return a number for long options (see 'longopts' array). +// Return '_' on unknown option or missing argument. +// Return -1 when done. +// +// Return 'h' for --help and return 'V' for --version. +// +// If an option has an argument, set getopt->arg to the argument. +// If getopt->error is non-error, write error messages to stderr. +int +_PyOS_GetOpt(struct _PyOS_GetOpt *getopt) { - wchar_t *ptr; - wchar_t option; + // Local copy of read-only members to omit "getopt->" + const Py_ssize_t argc = getopt->argc; + wchar_t * const *argv = getopt->argv; + const int error = getopt->error; - if (*opt_ptr == '\0') { - - if (_PyOS_optind >= argc) + if (*getopt->ptr == '\0') { + if (getopt->index >= argc) { return -1; + } + + const wchar_t *arg = argv[getopt->index]; #ifdef MS_WINDOWS - else if (wcscmp(argv[_PyOS_optind], L"/?") == 0) { - ++_PyOS_optind; + if (wcscmp(arg, L"/?") == 0) { + ++getopt->index; return 'h'; } #endif - else if (argv[_PyOS_optind][0] != L'-' || - argv[_PyOS_optind][1] == L'\0' /* lone dash */ ) + if (arg[0] != L'-' || arg[1] == L'\0' /* lone dash */ ) { return -1; + } - else if (wcscmp(argv[_PyOS_optind], L"--") == 0) { - ++_PyOS_optind; + if (wcscmp(arg, L"--") == 0) { + ++getopt->index; return -1; } - - else if (wcscmp(argv[_PyOS_optind], L"--help") == 0) { - ++_PyOS_optind; + if (wcscmp(arg, L"--help") == 0) { + ++getopt->index; return 'h'; } - - else if (wcscmp(argv[_PyOS_optind], L"--version") == 0) { - ++_PyOS_optind; + if (wcscmp(arg, L"--version") == 0) { + ++getopt->index; return 'V'; } - opt_ptr = &argv[_PyOS_optind++][1]; + getopt->ptr = &argv[getopt->index++][1]; } - if ((option = *opt_ptr++) == L'\0') + wchar_t option = *getopt->ptr++; + if (option == L'\0') { return -1; + } if (option == L'-') { // Parse long option. - if (*opt_ptr == L'\0') { - if (_PyOS_opterr) { + if (*getopt->ptr == L'\0') { + if (error) { fprintf(stderr, "Expected long option\n"); } return -1; } - *longindex = 0; + int longindex = 0; const _PyOS_LongOption *opt; - for (opt = &longopts[*longindex]; opt->name; opt = &longopts[++(*longindex)]) { - if (!wcscmp(opt->name, opt_ptr)) + for (opt = &longopts[longindex]; opt->name; opt = &longopts[++longindex]) { + if (wcscmp(opt->name, getopt->ptr) == 0) { break; + } } + if (!opt->name) { - if (_PyOS_opterr) { - fprintf(stderr, "Unknown option: %ls\n", argv[_PyOS_optind - 1]); + if (error) { + fprintf(stderr, "Invalid option '%ls'\n", argv[getopt->index - 1]); } return '_'; } - opt_ptr = L""; + + getopt->ptr = L""; if (!opt->has_arg) { return opt->val; } - if (_PyOS_optind >= argc) { - if (_PyOS_opterr) { + if (getopt->index >= argc) { + if (error) { fprintf(stderr, "Argument expected for the %ls options\n", - argv[_PyOS_optind - 1]); + argv[getopt->index - 1]); } return '_'; } - _PyOS_optarg = argv[_PyOS_optind++]; + getopt->arg = argv[getopt->index++]; return opt->val; } - if ((ptr = wcschr(SHORT_OPTS, option)) == NULL) { - if (_PyOS_opterr) { - fprintf(stderr, "Unknown option: -%c\n", (char)option); + wchar_t *ptr = wcschr(SHORT_OPTS, option); + if (ptr == NULL) { + if (error) { + fprintf(stderr, "Invalid option '-%lc'\n", (wint_t)option); } return '_'; } if (*(ptr + 1) == L':') { - if (*opt_ptr != L'\0') { - _PyOS_optarg = opt_ptr; - opt_ptr = L""; + if (*getopt->ptr != L'\0') { + getopt->arg = getopt->ptr; + getopt->ptr = L""; } - else { - if (_PyOS_optind >= argc) { - if (_PyOS_opterr) { + if (getopt->index >= argc) { + if (error) { fprintf(stderr, - "Argument expected for the -%c option\n", (char)option); + "Argument expected for the -%lc option\n", (wint_t)option); } return '_'; } - _PyOS_optarg = argv[_PyOS_optind++]; + getopt->arg = argv[getopt->index++]; } } diff --git a/Python/hamt.c b/Python/hamt.c index 95998ae5062ac7e..68bb11c0964e621 100644 --- a/Python/hamt.c +++ b/Python/hamt.c @@ -8,6 +8,13 @@ #include // offsetof() +/*[clinic input] +class hamt "PyHamtObject *" "&_PyHamt_Type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=ab743c139c849b8e]*/ + +#include "clinic/hamt.c.h" + /* This file provides an implementation of an immutable mapping using the Hash Array Mapped Trie (or HAMT) datastructure. @@ -2451,6 +2458,10 @@ hamt_baseiter_tp_clear(PyObject *op) { PyHamtIterator *it = (PyHamtIterator*)op; Py_CLEAR(it->hi_obj); + /* i_nodes holds borrowed pointers into the tree that hi_obj was keeping + alive, so the cursor must not be used again. A negative i_level makes + hamt_iterator_next() report I_END without touching i_nodes. */ + it->hi_iter.i_level = -1; return 0; } @@ -2497,6 +2508,10 @@ static Py_ssize_t hamt_baseiter_tp_len(PyObject *op) { PyHamtIterator *it = (PyHamtIterator*)op; + if (it->hi_obj == NULL) { + /* tp_clear() ran on this iterator. */ + return 0; + } return it->hi_obj->h_count; } @@ -2517,6 +2532,7 @@ hamt_baseiter_new(PyTypeObject *type, binaryfunc yield, PyHamtObject *o) hamt_iterator_init(&it->hi_iter, o->h_root); + PyObject_GC_Track(it); return (PyObject*)it; } @@ -2723,32 +2739,38 @@ hamt_tp_iter(PyObject *op) return _PyHamt_NewIterKeys(self); } -static PyObject * -hamt_py_set(PyObject *op, PyObject *args) -{ - PyObject *key; - PyObject *val; +/*[clinic input] +hamt.set - if (!PyArg_UnpackTuple(args, "set", 2, 2, &key, &val)) { - return NULL; - } + key: object + val: object + / - PyHamtObject *self = _PyHamtObject_CAST(op); - return (PyObject *)_PyHamt_Assoc(self, key, val); -} +Return a copy of the mapping with the key set to the value. +[clinic start generated code]*/ static PyObject * -hamt_py_get(PyObject *op, PyObject *args) +hamt_set_impl(PyHamtObject *self, PyObject *key, PyObject *val) +/*[clinic end generated code: output=2256fa2f6cf80a86 input=d0775605f5ad8fc1]*/ { - PyObject *key; - PyObject *def = NULL; + return (PyObject *)_PyHamt_Assoc(self, key, val); +} - if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &def)) { - return NULL; - } +/*[clinic input] +hamt.get + key: object + default as def: object = None + / + +Return the value for the key, or the default if it is not found. +[clinic start generated code]*/ + +static PyObject * +hamt_get_impl(PyHamtObject *self, PyObject *key, PyObject *def) +/*[clinic end generated code: output=32bfe9cfd2ac5b22 input=2636859ec1bf5912]*/ +{ PyObject *val = NULL; - PyHamtObject *self = _PyHamtObject_CAST(op); hamt_find_t res = hamt_find(self, key, &val); switch (res) { case F_ERROR: @@ -2756,9 +2778,6 @@ hamt_py_get(PyObject *op, PyObject *args) case F_FOUND: return Py_NewRef(val); case F_NOT_FOUND: - if (def == NULL) { - Py_RETURN_NONE; - } return Py_NewRef(def); default: Py_UNREACHABLE(); @@ -2804,8 +2823,8 @@ hamt_py_dump(PyObject *op, PyObject *Py_UNUSED(args)) static PyMethodDef PyHamt_methods[] = { - {"set", hamt_py_set, METH_VARARGS, NULL}, - {"get", hamt_py_get, METH_VARARGS, NULL}, + HAMT_SET_METHODDEF + HAMT_GET_METHODDEF {"delete", hamt_py_delete, METH_O, NULL}, {"items", hamt_py_items, METH_NOARGS, NULL}, {"keys", hamt_py_keys, METH_NOARGS, NULL}, diff --git a/Python/import.c b/Python/import.c index 63e23e21beb1266..7334be2e8f78004 100644 --- a/Python/import.c +++ b/Python/import.c @@ -11,7 +11,6 @@ #include "pycore_interp.h" // struct _import_runtime_state #include "pycore_interpframe.h" #include "pycore_lazyimportobject.h" -#include "pycore_long.h" // _PyLong_GetZero #include "pycore_magic_number.h" // PYC_MAGIC_NUMBER_TOKEN #include "pycore_moduleobject.h" // _PyModule_GetDef() #include "pycore_namespace.h" // _PyNamespace_Type @@ -25,7 +24,6 @@ #include "pycore_setobject.h" // _PySet_NextEntry() #include "pycore_sysmodule.h" // _PySys_ClearAttrString() #include "pycore_time.h" // _PyTime_AsMicroseconds() -#include "pycore_traceback.h" #include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() #include "pycore_weakref.h" // _PyWeakref_GET_REF() @@ -286,6 +284,29 @@ _PyImport_ClearLazyModules(PyInterpreterState *interp) Py_CLEAR(LAZY_PENDING_SUBMODULES(interp)); } +int +_PyImport_DiscardLazyModule(PyInterpreterState *interp, PyObject *name) +{ + if (LAZY_MODULES(interp) == NULL) { + return 0; + } + return PySet_Discard(LAZY_MODULES(interp), name); +} + +static PyObject * +get_importtime_name(PyObject *name) +{ + PyObject *exc = PyErr_GetRaisedException(); + PyObject *encoded = PyUnicode_AsEncodedString(name, "utf-8", + "backslashreplace"); + if (encoded == NULL) { + PyErr_Clear(); + } + PyErr_SetRaisedException(exc); + return encoded; +} + +// Return whether the cached module was still initializing. static int import_ensure_initialized(PyInterpreterState *interp, PyObject *mod, PyObject *name) { @@ -323,12 +344,15 @@ import_ensure_initialized(PyInterpreterState *interp, PyObject *mod, PyObject *n if (_PyInterpreterState_GetConfig(interp)->import_time == 2) { _IMPORT_TIME_HEADER(interp); #define import_level FIND_AND_LOAD(interp).import_level + PyObject *encoded_name = get_importtime_name(name); fprintf(stderr, "import time: cached | cached | %*s\n", - import_level*2, PyUnicode_AsUTF8(name)); + import_level*2, + encoded_name != NULL ? PyBytes_AS_STRING(encoded_name) : "?"); + Py_XDECREF(encoded_name); #undef import_level } - return 0; + return rc; } static void remove_importlib_frames(PyThreadState *tstate); @@ -1276,50 +1300,68 @@ del_extensions_cache_value(void *raw) } } +/* The key of the extensions cache: the raw content of two strings. + + The UTF-8 encoding is not used, because the strings can contain lone + surrogates, e.g. a file name undecodable in the filesystem encoding. */ +struct hashtable_key { + size_t size; /* the total size of the key */ + unsigned char kind1; + unsigned char kind2; + Py_ssize_t len1; + /* followed by the raw content of both strings */ +}; + static void * -hashtable_key_from_2_strings(PyObject *str1, PyObject *str2, const char sep) +hashtable_key_from_2_strings(PyObject *str1, PyObject *str2) { - const char *str1_data = _PyUnicode_AsUTF8NoNUL(str1); - const char *str2_data = _PyUnicode_AsUTF8NoNUL(str2); - if (str1_data == NULL || str2_data == NULL) { - return NULL; - } - Py_ssize_t str1_len = strlen(str1_data); - Py_ssize_t str2_len = strlen(str2_data); + Py_ssize_t len1 = PyUnicode_GET_LENGTH(str1); + Py_ssize_t len2 = PyUnicode_GET_LENGTH(str2); + int kind1 = PyUnicode_KIND(str1); + int kind2 = PyUnicode_KIND(str2); + size_t size1 = (size_t)len1 * kind1; + size_t size2 = (size_t)len2 * kind2; - /* Make sure sep and the NULL byte won't cause an overflow. */ - assert(SIZE_MAX - str1_len - str2_len > 2); - size_t size = str1_len + 1 + str2_len + 1; + assert(SIZE_MAX - sizeof(struct hashtable_key) - size1 > size2); + size_t size = sizeof(struct hashtable_key) + size1 + size2; // XXX Use a buffer if it's a temp value (every case but "set"). - char *key = PyMem_RawMalloc(size); + struct hashtable_key *key = PyMem_RawMalloc(size); if (key == NULL) { PyErr_NoMemory(); return NULL; } - memcpy(key, str1_data, str1_len); - key[str1_len] = sep; - memcpy(key + str1_len + 1, str2_data, str2_len); - key[size - 1] = '\0'; - assert(strlen(key) == size - 1); + /* Clear the padding: the key is hashed and compared as raw bytes. */ + memset(key, 0, sizeof(struct hashtable_key)); + key->size = size; + key->kind1 = (unsigned char)kind1; + key->kind2 = (unsigned char)kind2; + key->len1 = len1; + char *data = (char *)(key + 1); + memcpy(data, PyUnicode_DATA(str1), size1); + memcpy(data + size1, PyUnicode_DATA(str2), size2); return key; } static Py_uhash_t -hashtable_hash_str(const void *key) +hashtable_hash_key(const void *key) { - return Py_HashBuffer(key, strlen((const char *)key)); + return Py_HashBuffer(key, ((const struct hashtable_key *)key)->size); } static int -hashtable_compare_str(const void *key1, const void *key2) +hashtable_compare_key(const void *key1, const void *key2) { - return strcmp((const char *)key1, (const char *)key2) == 0; + size_t size = ((const struct hashtable_key *)key1)->size; + if (size != ((const struct hashtable_key *)key2)->size) { + return 0; + } + return memcmp(key1, key2, size) == 0; } static void -hashtable_destroy_str(void *ptr) +hashtable_destroy_key(void *ptr) { PyMem_RawFree(ptr); } @@ -1359,16 +1401,15 @@ _find_cached_def(PyModuleDef *def) } #endif -#define HTSEP ':' static int _extensions_cache_init(void) { _Py_hashtable_allocator_t alloc = {PyMem_RawMalloc, PyMem_RawFree}; EXTENSIONS.hashtable = _Py_hashtable_new_full( - hashtable_hash_str, - hashtable_compare_str, - hashtable_destroy_str, // key + hashtable_hash_key, + hashtable_compare_key, + hashtable_destroy_key, // key del_extensions_cache_value, // value &alloc ); @@ -1386,7 +1427,7 @@ _extensions_cache_find_unlocked(PyObject *path, PyObject *name, if (EXTENSIONS.hashtable == NULL) { return NULL; } - void *key = hashtable_key_from_2_strings(path, name, HTSEP); + void *key = hashtable_key_from_2_strings(path, name); if (key == NULL) { return NULL; } @@ -1396,7 +1437,7 @@ _extensions_cache_find_unlocked(PyObject *path, PyObject *name, *p_key = key; } else { - hashtable_destroy_str(key); + hashtable_destroy_key(key); } return entry; } @@ -1534,7 +1575,7 @@ _extensions_cache_set(PyObject *path, PyObject *name, finally_oldvalue: extensions_lock_release(); if (key != NULL) { - hashtable_destroy_str(key); + hashtable_destroy_key(key); } return value; @@ -1578,7 +1619,6 @@ _extensions_cache_clear_all(void) EXTENSIONS.hashtable = NULL; } -#undef HTSEP static bool @@ -2483,12 +2523,14 @@ lookup_inittab_entry(const struct _Py_ext_module_loader_info* info) static PyObject* create_builtin( - PyThreadState *tstate, PyObject *name, + PyThreadState *tstate, + PyObject *name, /* if NULL, get from spec */ PyObject *spec, PyModInitFunction initfunc) { struct _Py_ext_module_loader_info info; - if (_Py_ext_module_loader_info_init_for_builtin(&info, name) < 0) { + _Py_ext_module_origin origin = _Py_ext_module_origin_BUILTIN; + if (_Py_ext_module_loader_info_init(&info, name, spec, origin) < 0) { return NULL; } @@ -2521,7 +2563,7 @@ create_builtin( struct _inittab *entry = lookup_inittab_entry(&info); if (entry == NULL) { mod = NULL; - _PyErr_SetModuleNotFoundError(name); + _PyErr_SetModuleNotFoundError(info.name); goto finally; } @@ -2573,20 +2615,7 @@ PyImport_CreateModuleFromInitfunc( PyThreadState *tstate = _PyThreadState_GET(); - PyObject *name = PyObject_GetAttr(spec, &_Py_ID(name)); - if (name == NULL) { - return NULL; - } - - if (!PyUnicode_Check(name)) { - PyErr_Format(PyExc_TypeError, - "spec name must be string, not %T", name); - Py_DECREF(name); - return NULL; - } - - PyObject *mod = create_builtin(tstate, name, spec, initfunc); - Py_DECREF(name); + PyObject *mod = create_builtin(tstate, NULL, spec, initfunc); return mod; } @@ -2798,8 +2827,8 @@ PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co, Py_FatalError("no current interpreter"); } - external= PyObject_GetAttrString(IMPORTLIB(interp), - "_bootstrap_external"); + external= PyObject_GetAttr(IMPORTLIB(interp), + &_Py_ID(_bootstrap_external)); if (external != NULL) { pathobj = PyObject_CallMethodOneArg( external, &_Py_ID(_get_sourcefile), cpathobj); @@ -2883,8 +2912,8 @@ PyImport_ExecCodeModuleObject(PyObject *name, PyObject *co, PyObject *pathname, if (pathname == NULL) { pathname = ((PyCodeObject *)co)->co_filename; } - external = PyObject_GetAttrString(IMPORTLIB(tstate->interp), - "_bootstrap_external"); + external = PyObject_GetAttr(IMPORTLIB(tstate->interp), + &_Py_ID(_bootstrap_external)); if (external == NULL) { Py_DECREF(d); return NULL; @@ -3462,8 +3491,8 @@ PyObject * _PyImport_GetImportlibExternalLoader(PyInterpreterState *interp, const char *loader_name) { - PyObject *bootstrap = PyObject_GetAttrString(IMPORTLIB(interp), - "_bootstrap_external"); + PyObject *bootstrap = PyObject_GetAttr(IMPORTLIB(interp), + &_Py_ID(_bootstrap_external)); if (bootstrap == NULL) { return NULL; } @@ -3476,8 +3505,8 @@ _PyImport_GetImportlibExternalLoader(PyInterpreterState *interp, PyObject * _PyImport_BlessMyLoader(PyInterpreterState *interp, PyObject *module_globals) { - PyObject *external = PyObject_GetAttrString(IMPORTLIB(interp), - "_bootstrap_external"); + PyObject *external = PyObject_GetAttr(IMPORTLIB(interp), + &_Py_ID(_bootstrap_external)); if (external == NULL) { return NULL; } @@ -3875,235 +3904,10 @@ resolve_name(PyThreadState *tstate, PyObject *name, PyObject *globals, int level return NULL; } -PyObject * -_PyImport_ResolveName(PyThreadState *tstate, PyObject *name, - PyObject *globals, int level) -{ - return resolve_name(tstate, name, globals, level); -} - -PyObject * -_PyImport_LoadLazyImportTstate(PyThreadState *tstate, PyObject *lazy_import) -{ - PyObject *obj = NULL; - PyObject *fromlist = Py_None; - PyObject *import_func = NULL; - assert(lazy_import != NULL); - assert(PyLazyImport_CheckExact(lazy_import)); - - PyLazyImportObject *lz = (PyLazyImportObject *)lazy_import; - PyInterpreterState *interp = tstate->interp; - - // Acquire the global import lock to serialize reification - _PyImport_AcquireLock(interp); - - // Check if we are already importing this module, if so, then we want to - // return an error that indicates we've hit a cycle which will indicate - // the value isn't yet available. - PyObject *importing = interp->imports.lazy_importing_modules; - if (importing == NULL) { - importing = interp->imports.lazy_importing_modules = PySet_New(NULL); - if (importing == NULL) { - _PyImport_ReleaseLock(interp); - return NULL; - } - } - - assert(PyAnySet_CheckExact(importing)); - int is_loading = _PySet_Contains((PySetObject *)importing, lazy_import); - if (is_loading < 0) { - _PyImport_ReleaseLock(interp); - return NULL; - } - else if (is_loading == 1) { - PyObject *name = _PyLazyImport_GetName(lazy_import); - if (name == NULL) { - _PyImport_ReleaseLock(interp); - return NULL; - } - PyObject *errmsg = PyUnicode_FromFormat( - "cannot import name %R (most likely due to a circular import)", - name); - if (errmsg == NULL) { - Py_DECREF(name); - _PyImport_ReleaseLock(interp); - return NULL; - } - PyErr_SetImportErrorSubclass(PyExc_ImportCycleError, errmsg, - lz->lz_from, NULL); - Py_DECREF(errmsg); - Py_DECREF(name); - _PyImport_ReleaseLock(interp); - return NULL; - } - else if (PySet_Add(importing, lazy_import) < 0) { - goto error; - } - - Py_ssize_t dot = -1; - int full = 0; - if (lz->lz_attr != NULL) { - full = 1; - } - if (!full) { - dot = PyUnicode_FindChar(lz->lz_from, '.', 0, - PyUnicode_GET_LENGTH(lz->lz_from), 1); - } - if (dot < 0) { - full = 1; - } - - if (lz->lz_attr != NULL) { - if (PyUnicode_Check(lz->lz_attr)) { - fromlist = PyTuple_New(1); - if (fromlist == NULL) { - goto error; - } - Py_INCREF(lz->lz_attr); - PyTuple_SET_ITEM(fromlist, 0, lz->lz_attr); - } - else { - Py_INCREF(lz->lz_attr); - fromlist = lz->lz_attr; - } - } - - PyObject *globals = PyEval_GetGlobals(); - - if (PyMapping_GetOptionalItem(lz->lz_builtins, &_Py_ID(__import__), - &import_func) < 0) { - goto error; - } - if (import_func == NULL) { - PyErr_SetString(PyExc_ImportError, "__import__ not found"); - goto error; - } - if (full) { - obj = _PyEval_ImportNameWithImport( - tstate, import_func, globals, globals, - lz->lz_from, fromlist, _PyLong_GetZero() - ); - } - else { - PyObject *name = PyUnicode_Substring(lz->lz_from, 0, dot); - if (name == NULL) { - goto error; - } - obj = _PyEval_ImportNameWithImport( - tstate, import_func, globals, globals, - name, fromlist, _PyLong_GetZero() - ); - Py_DECREF(name); - } - if (obj == NULL) { - goto error; - } - - if (lz->lz_attr != NULL && PyUnicode_Check(lz->lz_attr)) { - PyObject *from = obj; - obj = _PyEval_ImportFrom(tstate, from, lz->lz_attr); - Py_DECREF(from); - if (obj == NULL) { - goto error; - } - } - - assert(!PyLazyImport_CheckExact(obj)); - - goto ok; - -error: - Py_CLEAR(obj); - - // If an error occurred and we have frame information, add it to the - // exception. - if (PyErr_Occurred() && lz->lz_code != NULL && lz->lz_instr_offset >= 0) { - // Get the current exception - this already has the full traceback - // from the access point. - PyObject *exc = _PyErr_GetRaisedException(tstate); - - // Get import name - this can fail and set an exception. - PyObject *import_name = _PyLazyImport_GetName(lazy_import); - if (!import_name) { - // Failed to get import name, just restore original exception. - _PyErr_SetRaisedException(tstate, exc); - goto ok; - } - - // Resolve line number from instruction offset on demand. - int lineno = PyCode_Addr2Line((PyCodeObject *)lz->lz_code, - lz->lz_instr_offset*2); - - // Get strings - these can return NULL on encoding errors. - const char *filename_str = PyUnicode_AsUTF8(lz->lz_code->co_filename); - if (!filename_str) { - // Unicode conversion failed - clear error and restore original - // exception. - PyErr_Clear(); - Py_DECREF(import_name); - _PyErr_SetRaisedException(tstate, exc); - goto ok; - } - - const char *funcname_str = PyUnicode_AsUTF8(lz->lz_code->co_name); - if (!funcname_str) { - // Unicode conversion failed - clear error and restore original - // exception. - PyErr_Clear(); - Py_DECREF(import_name); - _PyErr_SetRaisedException(tstate, exc); - goto ok; - } - - // Create a cause exception showing where the lazy import was declared. - PyObject *msg = PyUnicode_FromFormat( - "lazy import of '%U' raised an exception during resolution", - import_name - ); - Py_DECREF(import_name); // Done with import_name. - - if (!msg) { - // Failed to create message - restore original exception. - _PyErr_SetRaisedException(tstate, exc); - goto ok; - } - - PyObject *cause_exc = PyObject_CallOneArg(PyExc_ImportError, msg); - Py_DECREF(msg); // Done with msg. - - if (!cause_exc) { - // Failed to create exception - restore original. - _PyErr_SetRaisedException(tstate, exc); - goto ok; - } - - // Add traceback entry for the lazy import declaration. - _PyErr_SetRaisedException(tstate, cause_exc); - _PyTraceback_Add(funcname_str, filename_str, lineno); - PyObject *cause_with_tb = _PyErr_GetRaisedException(tstate); - - // Set the cause on the original exception. - PyException_SetCause(exc, cause_with_tb); // Steals ref to cause_with_tb. - - // Restore the original exception with its full traceback. - _PyErr_SetRaisedException(tstate, exc); - } - -ok: - if (PySet_Discard(importing, lazy_import) < 0) { - Py_CLEAR(obj); - } - - // Release the global import lock. - _PyImport_ReleaseLock(interp); - - Py_XDECREF(fromlist); - Py_XDECREF(import_func); - return obj; -} - static PyObject * -import_find_and_load(PyThreadState *tstate, PyObject *abs_name) +import_find_and_load_with_name(PyThreadState *tstate, PyObject *abs_name, + PyObject *find_and_load, + PyObject *not_found) { PyObject *mod = NULL; PyInterpreterState *interp = tstate->interp; @@ -4130,12 +3934,14 @@ import_find_and_load(PyThreadState *tstate, PyObject *abs_name) if (PyDTrace_IMPORT_FIND_LOAD_START_ENABLED()) PyDTrace_IMPORT_FIND_LOAD_START(PyUnicode_AsUTF8(abs_name)); - mod = PyObject_CallMethodObjArgs(IMPORTLIB(interp), &_Py_ID(_find_and_load), + mod = PyObject_CallMethodObjArgs(IMPORTLIB(interp), find_and_load, abs_name, IMPORT_FUNC(interp), NULL); - if (PyDTrace_IMPORT_FIND_LOAD_DONE_ENABLED()) + if (PyDTrace_IMPORT_FIND_LOAD_DONE_ENABLED()) { + int found = mod != NULL && mod != not_found; PyDTrace_IMPORT_FIND_LOAD_DONE(PyUnicode_AsUTF8(abs_name), - mod != NULL); + found); + } if (import_time) { PyTime_t t2; @@ -4143,10 +3949,13 @@ import_find_and_load(PyThreadState *tstate, PyObject *abs_name) PyTime_t cum = t2 - t1; import_level--; + PyObject *encoded_name = get_importtime_name(abs_name); fprintf(stderr, "import time: %9ld | %10ld | %*s%s\n", (long)_PyTime_AsMicroseconds(cum - accumulated, _PyTime_ROUND_CEILING), (long)_PyTime_AsMicroseconds(cum, _PyTime_ROUND_CEILING), - import_level*2, "", PyUnicode_AsUTF8(abs_name)); + import_level*2, "", + encoded_name != NULL ? PyBytes_AS_STRING(encoded_name) : "?"); + Py_XDECREF(encoded_name); accumulated = accumulated_copy + cum; } @@ -4157,8 +3966,15 @@ import_find_and_load(PyThreadState *tstate, PyObject *abs_name) } static PyObject * -get_abs_name(PyThreadState *tstate, PyObject *name, PyObject *globals, - int level) +import_find_and_load(PyThreadState *tstate, PyObject *abs_name) +{ + return import_find_and_load_with_name( + tstate, abs_name, &_Py_ID(_find_and_load), NULL); +} + +PyObject * +_PyImport_GetAbsName(PyThreadState *tstate, PyObject *name, PyObject *globals, + int level) { if (level > 0) { return resolve_name(tstate, name, globals, level); @@ -4170,13 +3986,6 @@ get_abs_name(PyThreadState *tstate, PyObject *name, PyObject *globals, return Py_NewRef(name); } -PyObject * -_PyImport_GetAbsName(PyThreadState *tstate, PyObject *name, - PyObject *globals, int level) -{ - return get_abs_name(tstate, name, globals, level); -} - PyObject * PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals, @@ -4208,7 +4017,7 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals, goto error; } - abs_name = get_abs_name(tstate, name, globals, level); + abs_name = _PyImport_GetAbsName(tstate, name, globals, level); if (abs_name == NULL) { goto error; } @@ -4219,7 +4028,8 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals, } if (mod != NULL && mod != Py_None) { - if (import_ensure_initialized(tstate->interp, mod, abs_name) < 0) { + int initializing = import_ensure_initialized(tstate->interp, mod, abs_name); + if (initializing < 0) { goto error; } /* Verify the module is still in sys.modules. Another thread may have @@ -4242,6 +4052,11 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals, } else { Py_DECREF(mod_check); + if (!initializing && + FT_ATOMIC_LOAD_INT_RELAXED(interp->imports.has_lazy_submodules) && + _PyImport_ClearLazySubmodule(tstate, abs_name, 1) < 0) { + goto error; + } } } else { @@ -4334,7 +4149,51 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals, return final_mod; } -// ensure we have the set for the parent module name in sys.lazy_modules. +// Add *name* to `sys.lazy_modules`. +// Skip the registration if *name* is already imported, and fully initialized. +// If *existing_mod_p* is not NULL, set it to the already imported object (or +// NULL if not found), for use by register_lazy_on_parent. +static int +lazy_modules_add(PyThreadState *tstate, PyObject *name, + PyObject **existing_mod_p) +{ + PyObject *mod = import_get_module(tstate, name); + if (mod == NULL && PyErr_Occurred()) { + return -1; + } + int loaded = mod != NULL && mod != Py_None; + if (loaded && PyModule_Check(mod)) { + PyObject *spec; + if (PyDict_GetItemRef(_PyModule_GetDict(mod), &_Py_ID(__spec__), &spec) < 0) { + Py_DECREF(mod); + return -1; + } + loaded = spec == NULL || spec == Py_None; + if (!loaded) { + // Read the usual flag without callbacks or dictionary allocation. + // Unsupported spec representations stay conservatively tracked. + PyObject *initializing = NULL; + if ((Py_TYPE(spec)->tp_flags & Py_TPFLAGS_INLINE_VALUES) && + _PyObject_TryGetInstanceAttribute(spec, &_Py_ID(_initializing), &initializing)) { + loaded = initializing == NULL || initializing == Py_False; + } + Py_XDECREF(initializing); + } + Py_XDECREF(spec); + } + if (existing_mod_p != NULL) { + *existing_mod_p = mod; + } + else { + Py_XDECREF(mod); + } + if (loaded || LAZY_MODULES(tstate->interp) == NULL) { + return 0; + } + return PySet_Add(LAZY_MODULES(tstate->interp), name); +} + +// Ensure a dict of pending submodule names exists for the parent. // Returns a new reference. static PyObject * ensure_lazy_pending_submodules(PyDictObject *lazy_modules, PyObject *parent) @@ -4345,7 +4204,7 @@ ensure_lazy_pending_submodules(PyDictObject *lazy_modules, PyObject *parent) &lazy_submodules); if (err == 0) { // value isn't present - lazy_submodules = PySet_New(NULL); + lazy_submodules = PyDict_New(); if (lazy_submodules != NULL && _PyDict_SetItem_LockHeld(lazy_modules, parent, lazy_submodules) < 0) { @@ -4361,130 +4220,237 @@ ensure_lazy_pending_submodules(PyDictObject *lazy_modules, PyObject *parent) // is accessed, _Py_module_getattro_impl will check lazy_pending_submodules // and trigger the import. static int -register_lazy_on_parent(PyThreadState *tstate, PyObject *name) +register_lazy_on_parent(PyThreadState *tstate, PyObject *name, PyObject *source) { - int ret = -1; - PyObject *parent = NULL; - PyObject *child = NULL; - - PyInterpreterState *interp = tstate->interp; - PyObject *lazy_pending_submodules = LAZY_PENDING_SUBMODULES(interp); - assert(lazy_pending_submodules != NULL); - - Py_INCREF(name); + PyDictObject *pending = + (PyDictObject *)LAZY_PENDING_SUBMODULES(tstate->interp); + // Finalizers can still run after finalize_modules() cleared the dict. + if (pending == NULL) { + return 0; + } + Py_ssize_t end = PyUnicode_GET_LENGTH(name); while (true) { - Py_ssize_t dot = PyUnicode_FindChar(name, '.', 0, - PyUnicode_GET_LENGTH(name), -1); + Py_ssize_t dot = PyUnicode_FindChar(name, '.', 0, end, -1); if (dot < 0) { - PyObject *lazy_submodules = ensure_lazy_pending_submodules( - (PyDictObject *)lazy_pending_submodules, name); - if (lazy_submodules == NULL) { - goto done; - } - Py_DECREF(lazy_submodules); - ret = 0; - goto done; + return dot == -1 ? 0 : -1; } - parent = PyUnicode_Substring(name, 0, dot); + PyObject *parent = PyUnicode_Substring(name, 0, dot); if (parent == NULL) { - goto done; + return -1; } - Py_XDECREF(child); - child = PyUnicode_Substring(name, dot + 1, PyUnicode_GET_LENGTH(name)); + PyObject *child = PyUnicode_Substring(name, dot + 1, end); if (child == NULL) { - goto done; - } - - PyObject *lazy_submodules = ensure_lazy_pending_submodules( - (PyDictObject *)lazy_pending_submodules, parent); - if (lazy_submodules == NULL) { - goto done; + Py_DECREF(parent); + return -1; } - if (PySet_Add(lazy_submodules, child) < 0) { - Py_DECREF(lazy_submodules); - goto done; + PyObject *submodules = ensure_lazy_pending_submodules(pending, parent); + Py_DECREF(parent); + PyObject *fullname = PyUnicode_Substring(name, 0, end); + PyObject *cached = fullname == NULL ? NULL : + import_get_module(tstate, fullname); + Py_XDECREF(fullname); + PyObject *value = cached != NULL && cached != Py_None ? Py_None : source; + int err = -1; + if (submodules != NULL && !PyErr_Occurred()) { + err = source == Py_None ? + PyDict_SetDefaultRef(submodules, child, value, NULL) : + PyDict_SetItem(submodules, child, value); + } + Py_XDECREF(cached); + Py_DECREF(child); + Py_XDECREF(submodules); + if (err < 0) { + return -1; } - Py_DECREF(lazy_submodules); - - Py_SETREF(name, parent); - parent = NULL; + end = dot; } - -done: - Py_XDECREF(child); - Py_XDECREF(parent); - Py_XDECREF(name); - return ret; } static int -register_from_lazy_on_parent(PyThreadState *tstate, PyObject *abs_name, - PyObject *from) +register_from_lazy_on_parent(PyThreadState *tstate, PyObject *existing_module, + PyObject *abs_name, PyObject *from) { + // IMPORT_FROM returns stored attributes directly. Their imports are + // already resolved or tracked by their own placeholders, so skip the alias. + int rc = 0; + if (existing_module != NULL && PyModule_Check(existing_module)) { + rc = PyDict_Contains(_PyModule_GetDict(existing_module), from); + if (rc != 0) { + return rc < 0 ? -1 : 0; + } + } + PyObject *fromname = PyUnicode_FromFormat("%U.%U", abs_name, from); if (fromname == NULL) { return -1; } - // Add the module name to sys.lazy_modules set (PEP 810). - PyObject *lazy_modules = LAZY_MODULES(tstate->interp); - if (PySet_Add(lazy_modules, fromname) < 0) { - Py_DECREF(fromname); - return -1; + rc = lazy_modules_add(tstate, fromname, NULL); + if (rc == 0) { + rc = register_lazy_on_parent(tstate, fromname, Py_None); } - - int res = register_lazy_on_parent(tstate, fromname); Py_DECREF(fromname); - return res; + return rc; } -PyObject * -_PyImport_TryLoadLazySubmodule(PyObject *mod_name, PyObject *attr_name) +// Release completed declarations, retaining names while their parent may fail. +// Cached eager imports also restore a child removed after failed validation. +int +_PyImport_ClearLazySubmodule(PyThreadState *tstate, PyObject *name, int bind) { - PyInterpreterState *interp = _PyInterpreterState_GET(); - PyObject *lazy_pending = LAZY_PENDING_SUBMODULES(interp); - if (lazy_pending == NULL) { - return NULL; + if (LAZY_PENDING_SUBMODULES(tstate->interp) == NULL || + PyDict_GET_SIZE(LAZY_PENDING_SUBMODULES(tstate->interp)) == 0) { + return 0; } - - PyObject *pending_set; - int rc = PyDict_GetItemRef(lazy_pending, mod_name, &pending_set); - if (rc <= 0) { - return NULL; + Py_ssize_t end = PyUnicode_GET_LENGTH(name); + Py_ssize_t dot = PyUnicode_FindChar(name, '.', 0, end, -1); + if (dot < 0) { + return dot == -2 ? -1 : 0; + } + PyObject *parent = PyUnicode_Substring(name, 0, dot); + PyObject *child = PyUnicode_Substring(name, dot + 1, end); + PyObject *pending = NULL; + int rc = -1; + if (parent != NULL && child != NULL) { + rc = PyDict_GetItemRef(LAZY_PENDING_SUBMODULES(tstate->interp), + parent, &pending); + if (rc > 0) { + rc = PyDict_Contains(pending, child); + } + if (rc > 0) { + PyObject *loaded = import_get_module(tstate, name), *loaded_spec = NULL; + int loading = loaded == NULL ? (PyErr_Occurred() ? -1 : 0) : + PyObject_GetOptionalAttr(loaded, &_Py_ID(__spec__), &loaded_spec); + if (loading > 0) { + loading = _PyModuleSpec_IsInitializing(loaded_spec); + } + Py_XDECREF(loaded_spec); + Py_XDECREF(loaded); + if (loading != 0) { + if (PyErr_ExceptionMatches(PyExc_Exception)) { + PyErr_Clear(); + loading = 1; + } + rc = loading < 0 ? -1 : 0; + goto done; + } + PyObject *module = import_get_module(tstate, parent); + PyObject *spec = NULL; + int initializing = module == NULL ? (PyErr_Occurred() ? -1 : 0) : + PyObject_GetOptionalAttr(module, &_Py_ID(__spec__), &spec); + if (initializing > 0) { + initializing = _PyModuleSpec_IsInitializing(spec); + } + Py_XDECREF(spec); + if (bind && initializing == 0 && module != NULL && + PyModule_CheckExact(module) && PyDict_Contains(pending, child) > 0) { + PyObject *value = import_get_module(tstate, name); + if (value != NULL && value != Py_None) { + initializing = PyDict_SetDefaultRef( + _PyModule_GetDict(module), child, value, NULL) < 0 ? -1 : 0; + } + Py_XDECREF(value); + } + Py_XDECREF(module); + rc = initializing < 0 ? -1 : + (initializing ? PyDict_SetItem(pending, child, Py_None) : + PyDict_Pop(pending, child, NULL)); + } } +done: + Py_XDECREF(pending); + Py_XDECREF(parent); + Py_XDECREF(child); + return rc < 0 ? -1 : 0; +} - int contains = PySet_Contains(pending_set, attr_name); - if (contains <= 0) { - Py_DECREF(pending_set); +static int +lazy_submodule_matches(PyObject *value, void *expected) +{ + return value == expected; +} + +PyObject * +_PyImport_TryLoadLazySubmodule(PyObject *module, PyObject *attr_name, + int suppress, int *recheck_dict) +{ + *recheck_dict = 0; + PyObject *mod_dict = _PyModule_GetDict(module); + PyObject *mod_name; + if (PyDict_GetItemRef(mod_dict, &_Py_ID(__name__), &mod_name) <= 0) { return NULL; } + PyObject *mod = NULL, *pending_set = NULL, *source = NULL; + if (!PyUnicode_Check(mod_name)) { + goto done; + } + PyThreadState *tstate = _PyThreadState_GET(); + PyObject *lazy_pending = LAZY_PENDING_SUBMODULES(tstate->interp); + if (lazy_pending == NULL || + PyDict_GetItemRef(lazy_pending, mod_name, &pending_set) <= 0) { + goto done; + } + *recheck_dict = 1; + if (PyDict_GetItemRef(pending_set, attr_name, &source) <= 0) { + goto done; + } PyObject *full_name = PyUnicode_FromFormat("%U.%U", mod_name, attr_name); if (full_name == NULL) { - Py_DECREF(pending_set); - return NULL; + goto done; + } + // Match eager from-imports: accept a partial module in an import cycle. + if (source != Py_None && !suppress && + (_PyLazyImport_IsActive(source) || + !PyDict_Contains(mod_dict, &_Py_ID(__getattr__)))) { + mod = _PyLazyImport_LoadChild(tstate, source, full_name); + } + else { + mod = PyImport_GetModule(full_name); + if ((mod == NULL && !PyErr_Occurred()) || mod == Py_None) { + Py_XDECREF(mod); + mod = import_find_and_load_with_name( + tstate, full_name, &_Py_ID(_find_and_load_lazy_submodule), Py_None); + } } - - PyObject *mod = PyImport_ImportModuleLevelObject( - full_name, NULL, NULL, NULL, 0); if (mod == NULL) { - Py_DECREF(pending_set); - Py_DECREF(full_name); - return NULL; + PyObject *exc = PyErr_GetRaisedException(); + PyObject *loaded = import_get_module(tstate, full_name); + if (loaded != NULL && loaded != Py_None) { + (void)_PyDict_DelItemIf(mod_dict, attr_name, + lazy_submodule_matches, loaded); + (void)PyDict_SetDefaultRef(pending_set, attr_name, source, NULL); + } + Py_XDECREF(loaded); + PyErr_SetRaisedException(exc); + remove_importlib_frames(tstate); } - Py_DECREF(mod); - - if (PySet_Discard(pending_set, attr_name) < 0) { - Py_DECREF(pending_set); - Py_DECREF(full_name); - return NULL; + /* Keep missing children pending: a finder may provide them later. */ + else { + PyObject *spec = NULL; + int rc = mod == Py_None ? 0 : + PyObject_GetOptionalAttr(mod, &_Py_ID(__spec__), &spec); + int initializing = rc > 0 ? _PyModuleSpec_IsInitializing(spec) : rc; + Py_XDECREF(spec); + if (initializing < 0 && PyErr_ExceptionMatches(PyExc_Exception)) { + PyErr_Clear(); + initializing = 0; + } + if (mod == Py_None || initializing < 0 || + (initializing == 0 && + (PyDict_SetItem(mod_dict, attr_name, mod) < 0 || + PyDict_Pop(pending_set, attr_name, NULL) < 0))) { + Py_CLEAR(mod); + } } - Py_DECREF(pending_set); - - PyObject *submod = PyImport_GetModule(full_name); Py_DECREF(full_name); - return submod; + +done: + Py_XDECREF(source); + Py_XDECREF(pending_set); + Py_DECREF(mod_name); + return mod; } PyObject * @@ -4504,12 +4470,11 @@ _PyImport_LazyImportModuleLevelObject(PyThreadState *tstate, return NULL; } - PyObject *abs_name = get_abs_name(tstate, name, globals, level); + PyObject *abs_name = _PyImport_GetAbsName(tstate, name, globals, level); if (abs_name == NULL) { return NULL; } - PyInterpreterState *interp = tstate->interp; _PyInterpreterFrame *frame = _PyEval_GetFrame(); if (frame == NULL || frame->f_globals != frame->f_locals) { Py_DECREF(abs_name); @@ -4518,100 +4483,98 @@ _PyImport_LazyImportModuleLevelObject(PyThreadState *tstate, return NULL; } + PyObject *res = NULL; + PyObject *existing_module = NULL; + + if (fromlist != NULL && PyUnicode_Check(fromlist)) { + fromlist = PyTuple_Pack(1, fromlist); + if (fromlist == NULL) { + goto done; + } + } + else { + fromlist = Py_NewRef(fromlist != NULL ? fromlist : Py_None); + } + // Check if the filter disables the lazy import. - // We must hold a reference to the filter while calling it to prevent - // use-after-free if another thread replaces it via - // PyImport_SetLazyImportsFilter. - LAZY_IMPORTS_LOCK(interp); - PyObject *filter = Py_XNewRef(LAZY_IMPORTS_FILTER(interp)); - LAZY_IMPORTS_UNLOCK(interp); + PyObject *filter = PyImport_GetLazyImportsFilter(); if (filter != NULL) { PyObject *modname; if (PyDict_GetItemRef(globals, &_Py_ID(__name__), &modname) < 0) { Py_DECREF(filter); - Py_DECREF(abs_name); - return NULL; + goto done; } if (modname == NULL) { assert(!PyErr_Occurred()); modname = Py_NewRef(Py_None); } - if (fromlist == NULL) { - assert(!PyErr_Occurred()); - fromlist = Py_None; - } PyObject *args[] = {modname, abs_name, fromlist}; - PyObject *res = PyObject_Vectorcall(filter, args, 3, NULL); + PyObject *decision = PyObject_Vectorcall(filter, args, 3, NULL); Py_DECREF(modname); Py_DECREF(filter); - if (res == NULL) { - Py_DECREF(abs_name); - return NULL; + if (decision == NULL) { + goto done; } - int is_true = PyObject_IsTrue(res); - Py_DECREF(res); + int is_true = PyObject_IsTrue(decision); + Py_DECREF(decision); if (is_true < 0) { - Py_DECREF(abs_name); - return NULL; + goto done; } if (!is_true) { - Py_DECREF(abs_name); - return PyImport_ImportModuleLevelObject( + res = PyImport_ImportModuleLevelObject( name, globals, locals, fromlist, level ); + goto done; } } - // here, 'filter' is either NULL or is equivalent to a borrowed reference - if (fromlist && PyUnicode_Check(fromlist)) { - fromlist = PyTuple_Pack(1, fromlist); - if (fromlist == NULL) { - Py_DECREF(abs_name); - return NULL; + // Validate the entire fromlist before registering any pending imports. + if (PyTuple_Check(fromlist)) { + for (Py_ssize_t i = 0; i < PyTuple_GET_SIZE(fromlist); i++) { + PyObject *item = PyTuple_GET_ITEM(fromlist, i); + if (!PyUnicode_Check(item)) { + _PyErr_Format(tstate, PyExc_TypeError, + "Item in ``from list'' must be str, not %.200s", + Py_TYPE(item)->tp_name); + goto done; + } } } - else { - Py_XINCREF(fromlist); - } - PyObject *res = _PyLazyImport_New(frame, builtins, abs_name, fromlist); + res = _PyLazyImport_New(frame, builtins, abs_name, fromlist); if (res == NULL) { - Py_XDECREF(fromlist); - Py_DECREF(abs_name); - return NULL; + goto done; } - // Add the module name to sys.lazy_modules set (PEP 810). - PyObject *lazy_modules = LAZY_MODULES(tstate->interp); - if (PySet_Add(lazy_modules, abs_name) < 0) { + if (lazy_modules_add(tstate, abs_name, &existing_module) < 0) { goto error; } - if (fromlist && PyTuple_Check(fromlist) && PyTuple_GET_SIZE(fromlist)) { + if (PyTuple_Check(fromlist) && PyTuple_GET_SIZE(fromlist)) { for (Py_ssize_t i = 0; i < PyTuple_GET_SIZE(fromlist); i++) { - if (register_from_lazy_on_parent(tstate, abs_name, + if (register_from_lazy_on_parent(tstate, existing_module, abs_name, PyTuple_GET_ITEM(fromlist, i)) < 0) { goto error; } } } - else if (register_lazy_on_parent(tstate, abs_name) < 0) { + else if (register_lazy_on_parent(tstate, abs_name, res) < 0) { goto error; } - Py_XDECREF(fromlist); - Py_DECREF(abs_name); - return res; + goto done; error: + Py_CLEAR(res); +done: Py_XDECREF(fromlist); Py_DECREF(abs_name); - Py_DECREF(res); - return NULL; + Py_XDECREF(existing_module); + return res; } PyObject * @@ -4823,7 +4786,6 @@ _PyImport_ClearCore(PyInterpreterState *interp) Py_CLEAR(LAZY_IMPORT_FUNC(interp)); Py_CLEAR(interp->imports.lazy_pending_submodules); Py_CLEAR(interp->imports.lazy_modules); - Py_CLEAR(interp->imports.lazy_importing_modules); Py_CLEAR(interp->imports.lazy_imports_filter); } @@ -5047,8 +5009,15 @@ static PyObject * _imp_acquire_lock_impl(PyObject *module) /*[clinic end generated code: output=1aff58cb0ee1b026 input=60e9c1b4ab471ead]*/ { - PyInterpreterState *interp = _PyInterpreterState_GET(); - _PyImport_AcquireLock(interp); + PyThreadState *tstate = _PyThreadState_GET(); + // Leave enough stack for importlib to release the lock. + if (_Py_ReachedRecursionLimitWithMargin(tstate, 2)) { + _PyErr_SetString(tstate, PyExc_RecursionError, + "maximum recursion depth exceeded while " + "acquiring the import lock"); + return NULL; + } + _PyImport_AcquireLock(tstate->interp); Py_RETURN_NONE; } @@ -5115,27 +5084,7 @@ _imp_create_builtin(PyObject *module, PyObject *spec) { PyThreadState *tstate = _PyThreadState_GET(); - PyObject *name = PyObject_GetAttrString(spec, "name"); - if (name == NULL) { - return NULL; - } - - if (!PyUnicode_Check(name)) { - PyErr_Format(PyExc_TypeError, - "name must be string, not %.200s", - Py_TYPE(name)->tp_name); - Py_DECREF(name); - return NULL; - } - - if (PyUnicode_GetLength(name) == 0) { - PyErr_Format(PyExc_ValueError, "name must not be empty"); - Py_DECREF(name); - return NULL; - } - - PyObject *mod = create_builtin(tstate, name, spec, NULL); - Py_DECREF(name); + PyObject *mod = create_builtin(tstate, NULL, spec, NULL); return mod; } @@ -5467,7 +5416,8 @@ _imp_create_dynamic_impl(PyObject *module, PyObject *spec, PyObject *file) PyThreadState *tstate = _PyThreadState_GET(); struct _Py_ext_module_loader_info info; - if (_Py_ext_module_loader_info_init_from_spec(&info, spec) < 0) { + _Py_ext_module_origin origin = _Py_ext_module_origin_DYNAMIC; + if (_Py_ext_module_loader_info_init(&info, NULL, spec, origin) < 0) { return NULL; } @@ -5618,16 +5568,19 @@ _imp._set_lazy_attributes modobj: object name: unicode / -Sets attributes to lazy submodules on the module, as side effects. +Remove the resolved module name from sys.lazy_modules. [clinic start generated code]*/ static PyObject * _imp__set_lazy_attributes_impl(PyObject *module, PyObject *modobj, PyObject *name) -/*[clinic end generated code: output=3369bb3242b1f043 input=38ea6f30956dd7d6]*/ +/*[clinic end generated code: output=3369bb3242b1f043 input=900339e013ab2b82]*/ { PyInterpreterState *interp = _PyInterpreterState_GET(); - if (PySet_Discard(LAZY_MODULES(interp), name) < 0) { + if (_PyImport_DiscardLazyModule(interp, name) < 0) { + return NULL; + } + if (_PyImport_ClearLazySubmodule(_PyThreadState_GET(), name, 0) < 0) { return NULL; } Py_RETURN_NONE; diff --git a/Python/importdl.c b/Python/importdl.c index 537e8d869dc93ca..0f843988c0cfc2c 100644 --- a/Python/importdl.c +++ b/Python/importdl.c @@ -8,6 +8,8 @@ #include "pycore_moduleobject.h" // _PyModule_GetDefOrNull() #include "pycore_pyerrors.h" // _PyErr_FormatFromCause() #include "pycore_runtime.h" // _Py_ID() +#include "pycore_global_objects.h" // _Py_SINGLETON() +#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8NoNUL() /***********************************/ @@ -28,8 +30,6 @@ static const struct hook_prefixes nonascii_prefixes = { static PyObject * get_encoded_name(PyObject *name, const struct hook_prefixes **hook_prefixes) { PyObject *tmp; - PyObject *encoded = NULL; - PyObject *modname = NULL; Py_ssize_t name_len, lastdot; /* Get the short name (substring after last dot) */ @@ -51,33 +51,38 @@ get_encoded_name(PyObject *name, const struct hook_prefixes **hook_prefixes) { } /* Encode to ASCII or Punycode, as needed */ - encoded = PyUnicode_AsEncodedString(name, "ascii", NULL); - if (encoded != NULL) { + PyObject *encoded; + if (PyUnicode_IS_ASCII(name)) { *hook_prefixes = &ascii_only_prefixes; + encoded = PyUnicode_AsASCIIString(name); } else { - if (PyErr_ExceptionMatches(PyExc_UnicodeEncodeError)) { - PyErr_Clear(); - encoded = PyUnicode_AsEncodedString(name, "punycode", NULL); - if (encoded == NULL) { - goto error; - } - *hook_prefixes = &nonascii_prefixes; - } else { - goto error; - } + *hook_prefixes = &nonascii_prefixes; + encoded = PyUnicode_AsEncodedString(name, "punycode", NULL); + } + if (encoded == NULL) { + goto error; } - /* Replace '-' by '_' */ - modname = _PyObject_CallMethod(encoded, &_Py_ID(replace), "cc", '-', '_'); - if (modname == NULL) + /* Call encoded.replace('-', '_') */ + PyObject *modname = PyObject_VectorcallMethod( + &_Py_ID(replace), + (PyObject*[3]) { + encoded, + (PyObject *)&_Py_SINGLETON(bytes_characters)['-'], + (PyObject *)&_Py_SINGLETON(bytes_characters)['_'], + }, + 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, + NULL); + Py_CLEAR(encoded); + + if (modname == NULL) { goto error; + } Py_DECREF(name); - Py_DECREF(encoded); return modname; error: Py_DECREF(name); - Py_XDECREF(encoded); return NULL; } @@ -94,122 +99,86 @@ _Py_ext_module_loader_info_clear(struct _Py_ext_module_loader_info *info) int _Py_ext_module_loader_info_init(struct _Py_ext_module_loader_info *p_info, - PyObject *name, PyObject *filename, + PyObject *name, + PyObject *spec, _Py_ext_module_origin origin) { struct _Py_ext_module_loader_info info = { .origin=origin, }; - assert(name != NULL); - if (!PyUnicode_Check(name)) { - PyErr_SetString(PyExc_TypeError, - "module name must be a string"); - _Py_ext_module_loader_info_clear(&info); - return -1; + if (name == NULL) { + assert(spec != NULL); + info.name = PyObject_GetAttr(spec, &_Py_ID(name)); + if (info.name == NULL) { + goto error; + } + } + else { + info.name = Py_NewRef(name); + } + + if (!PyUnicode_Check(info.name)) { + PyErr_Format(PyExc_TypeError, + "module name must be a string, not %T", + info.name); + goto error; + } + + if (PyUnicode_GetLength(info.name) == 0) { + PyErr_Format(PyExc_ValueError, "module name must not be empty"); + goto error; } - assert(PyUnicode_GetLength(name) > 0); - info.name = Py_NewRef(name); info.name_encoded = get_encoded_name(info.name, &info.hook_prefixes); if (info.name_encoded == NULL) { - _Py_ext_module_loader_info_clear(&info); - return -1; + goto error; } - info.newcontext = PyUnicode_AsUTF8(info.name); + info.newcontext = _PyUnicode_AsUTF8NoNUL(info.name); if (info.newcontext == NULL) { - _Py_ext_module_loader_info_clear(&info); - return -1; + goto error; } - if (filename != NULL) { - if (!PyUnicode_Check(filename)) { + if (origin == _Py_ext_module_origin_DYNAMIC) { + assert(spec != NULL); + info.filename = PyObject_GetAttr(spec, &_Py_ID(origin)); + if (info.filename == NULL) { + goto error; + } + + if (!PyUnicode_Check(info.filename)) { PyErr_SetString(PyExc_TypeError, "module filename must be a string"); - _Py_ext_module_loader_info_clear(&info); - return -1; + goto error; + } + if (PyUnicode_FindChar(info.filename, 0, 0, + PyUnicode_GET_LENGTH(info.filename), 1) != -1) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto error; } - info.filename = Py_NewRef(filename); #ifndef MS_WINDOWS info.filename_encoded = PyUnicode_EncodeFSDefault(info.filename); if (info.filename_encoded == NULL) { - _Py_ext_module_loader_info_clear(&info); - return -1; + goto error; } #endif info.path = info.filename; } else { + info.filename = NULL; info.path = info.name; } *p_info = info; return 0; -} -int -_Py_ext_module_loader_info_init_for_builtin( - struct _Py_ext_module_loader_info *info, - PyObject *name) -{ - assert(PyUnicode_Check(name)); - assert(PyUnicode_GetLength(name) > 0); - - PyObject *name_encoded = PyUnicode_AsEncodedString(name, "ascii", NULL); - if (name_encoded == NULL) { - return -1; - } - - *info = (struct _Py_ext_module_loader_info){ - .name=Py_NewRef(name), - .name_encoded=name_encoded, - /* We won't need filename. */ - .path=name, - .origin=_Py_ext_module_origin_BUILTIN, - .hook_prefixes=&ascii_only_prefixes, - .newcontext=NULL, - }; - return 0; -} - -int -_Py_ext_module_loader_info_init_for_core( - struct _Py_ext_module_loader_info *info, - PyObject *name) -{ - if (_Py_ext_module_loader_info_init_for_builtin(info, name) < 0) { - return -1; - } - info->origin = _Py_ext_module_origin_CORE; - return 0; -} - -#ifdef HAVE_DYNAMIC_LOADING -int -_Py_ext_module_loader_info_init_from_spec( - struct _Py_ext_module_loader_info *p_info, - PyObject *spec) -{ - PyObject *name = PyObject_GetAttrString(spec, "name"); - if (name == NULL) { - return -1; - } - PyObject *filename = PyObject_GetAttrString(spec, "origin"); - if (filename == NULL) { - Py_DECREF(name); - return -1; - } - /* We could also accommodate builtin modules here without much trouble. */ - _Py_ext_module_origin origin = _Py_ext_module_origin_DYNAMIC; - int err = _Py_ext_module_loader_info_init(p_info, name, filename, origin); - Py_DECREF(name); - Py_DECREF(filename); - return err; +error: + _Py_ext_module_loader_info_clear(&info); + return -1; } -#endif /* HAVE_DYNAMIC_LOADING */ /********************************/ diff --git a/Python/initconfig.c b/Python/initconfig.c index b9bacb17a66454a..a768fdf0ca61c4d 100644 --- a/Python/initconfig.c +++ b/Python/initconfig.c @@ -95,128 +95,116 @@ typedef struct { PyConfigMemberType type; PyConfigMemberVisibility visibility; PyConfigSysSpec sys; - PyConfigGlobalVar global_var; } PyConfigSpec; -#define SPEC(MEMBER, TYPE, VISIBILITY, sys, global_var) \ +#define SPEC(MEMBER, TYPE, VISIBILITY, sys) \ {#MEMBER, offsetof(PyConfig, MEMBER), \ - PyConfig_MEMBER_##TYPE, PyConfig_MEMBER_##VISIBILITY, sys, global_var} + PyConfig_MEMBER_##TYPE, PyConfig_MEMBER_##VISIBILITY, sys} #define SYS_ATTR(name) {name, -1, NULL} #define SYS_FLAG_SETTER(index, setter) {NULL, index, setter} #define SYS_FLAG(index) SYS_FLAG_SETTER(index, NULL) #define NO_SYS SYS_ATTR(NULL) -#define GLOBAL(ptr, not) {ptr, not} -#define NO_GLOBAL GLOBAL(NULL, 0) - -// Ignore deprecations on global variables such as Py_IsolatedFlag -_Py_COMP_DIAG_PUSH -_Py_COMP_DIAG_IGNORE_DEPR_DECLS - // Update _test_embed_set_config when adding new members static const PyConfigSpec PYCONFIG_SPEC[] = { // --- Public options ----------- - SPEC(argv, WSTR_LIST, PUBLIC, SYS_ATTR("argv"), NO_GLOBAL), - SPEC(base_exec_prefix, WSTR_OPT, PUBLIC, SYS_ATTR("base_exec_prefix"), NO_GLOBAL), - SPEC(base_executable, WSTR_OPT, PUBLIC, SYS_ATTR("_base_executable"), NO_GLOBAL), - SPEC(base_prefix, WSTR_OPT, PUBLIC, SYS_ATTR("base_prefix"), NO_GLOBAL), - SPEC(bytes_warning, UINT, PUBLIC, SYS_FLAG(9), GLOBAL(&Py_BytesWarningFlag, 0)), - SPEC(cpu_count, INT, PUBLIC, NO_SYS, NO_GLOBAL), - SPEC(lazy_imports, INT, PUBLIC, NO_SYS, NO_GLOBAL), - SPEC(exec_prefix, WSTR_OPT, PUBLIC, SYS_ATTR("exec_prefix"), NO_GLOBAL), - SPEC(executable, WSTR_OPT, PUBLIC, SYS_ATTR("executable"), NO_GLOBAL), - SPEC(inspect, BOOL, PUBLIC, SYS_FLAG(1), GLOBAL(&Py_InspectFlag, 0)), - SPEC(int_max_str_digits, UINT, PUBLIC, NO_SYS, NO_GLOBAL), - SPEC(interactive, BOOL, PUBLIC, SYS_FLAG(2), GLOBAL(&Py_InteractiveFlag, 0)), - SPEC(module_search_paths, WSTR_LIST, PUBLIC, SYS_ATTR("path"), NO_GLOBAL), - SPEC(optimization_level, UINT, PUBLIC, SYS_FLAG(3), GLOBAL(&Py_OptimizeFlag, 0)), - SPEC(parser_debug, BOOL, PUBLIC, SYS_FLAG(0), GLOBAL(&Py_DebugFlag, 0)), - SPEC(platlibdir, WSTR, PUBLIC, SYS_ATTR("platlibdir"), NO_GLOBAL), - SPEC(prefix, WSTR_OPT, PUBLIC, SYS_ATTR("prefix"), NO_GLOBAL), - SPEC(pycache_prefix, WSTR_OPT, PUBLIC, SYS_ATTR("pycache_prefix"), NO_GLOBAL), - SPEC(quiet, BOOL, PUBLIC, SYS_FLAG(10), GLOBAL(&Py_QuietFlag, 0)), - SPEC(stdlib_dir, WSTR_OPT, PUBLIC, SYS_ATTR("_stdlib_dir"), NO_GLOBAL), + SPEC(argv, WSTR_LIST, PUBLIC, SYS_ATTR("argv")), + SPEC(base_exec_prefix, WSTR_OPT, PUBLIC, SYS_ATTR("base_exec_prefix")), + SPEC(base_executable, WSTR_OPT, PUBLIC, SYS_ATTR("_base_executable")), + SPEC(base_prefix, WSTR_OPT, PUBLIC, SYS_ATTR("base_prefix")), + SPEC(bytes_warning, UINT, PUBLIC, SYS_FLAG(9)), + SPEC(cpu_count, INT, PUBLIC, NO_SYS), + SPEC(lazy_imports, INT, PUBLIC, NO_SYS), + SPEC(exec_prefix, WSTR_OPT, PUBLIC, SYS_ATTR("exec_prefix")), + SPEC(executable, WSTR_OPT, PUBLIC, SYS_ATTR("executable")), + SPEC(inspect, BOOL, PUBLIC, SYS_FLAG(1)), + SPEC(int_max_str_digits, UINT, PUBLIC, NO_SYS), + SPEC(interactive, BOOL, PUBLIC, SYS_FLAG(2)), + SPEC(module_search_paths, WSTR_LIST, PUBLIC, SYS_ATTR("path")), + SPEC(optimization_level, UINT, PUBLIC, SYS_FLAG(3)), + SPEC(parser_debug, BOOL, PUBLIC, SYS_FLAG(0)), + SPEC(platlibdir, WSTR, PUBLIC, SYS_ATTR("platlibdir")), + SPEC(prefix, WSTR_OPT, PUBLIC, SYS_ATTR("prefix")), + SPEC(pycache_prefix, WSTR_OPT, PUBLIC, SYS_ATTR("pycache_prefix")), + SPEC(quiet, BOOL, PUBLIC, SYS_FLAG(10)), + SPEC(stdlib_dir, WSTR_OPT, PUBLIC, SYS_ATTR("_stdlib_dir")), SPEC(use_environment, BOOL, PUBLIC, - SYS_FLAG_SETTER(7, config_sys_flag_not), GLOBAL(&Py_IgnoreEnvironmentFlag, 1)), - SPEC(verbose, UINT, PUBLIC, SYS_FLAG(8), GLOBAL(&Py_VerboseFlag, 0)), - SPEC(warnoptions, WSTR_LIST, PUBLIC, SYS_ATTR("warnoptions"), NO_GLOBAL), - SPEC(write_bytecode, BOOL, PUBLIC, SYS_FLAG_SETTER(4, config_sys_flag_not), - GLOBAL(&Py_DontWriteBytecodeFlag, 1)), - SPEC(xoptions, WSTR_LIST, PUBLIC, SYS_ATTR("_xoptions"), NO_GLOBAL), + SYS_FLAG_SETTER(7, config_sys_flag_not)), + SPEC(verbose, UINT, PUBLIC, SYS_FLAG(8)), + SPEC(warnoptions, WSTR_LIST, PUBLIC, SYS_ATTR("warnoptions")), + SPEC(write_bytecode, BOOL, PUBLIC, SYS_FLAG_SETTER(4, config_sys_flag_not)), + SPEC(xoptions, WSTR_LIST, PUBLIC, SYS_ATTR("_xoptions")), // --- Read-only options ----------- #ifdef Py_STATS - SPEC(_pystats, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), + SPEC(_pystats, BOOL, READ_ONLY, NO_SYS), #endif - SPEC(buffered_stdio, BOOL, READ_ONLY, NO_SYS, - GLOBAL(&Py_UnbufferedStdioFlag, 1)), - SPEC(check_hash_pycs_mode, WSTR, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(code_debug_ranges, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(configure_c_stdio, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(dev_mode, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), // sys.flags.dev_mode - SPEC(dump_refs, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(dump_refs_file, WSTR_OPT, READ_ONLY, NO_SYS, NO_GLOBAL), + SPEC(buffered_stdio, BOOL, READ_ONLY, NO_SYS), + SPEC(check_hash_pycs_mode, WSTR, READ_ONLY, NO_SYS), + SPEC(code_debug_ranges, BOOL, READ_ONLY, NO_SYS), + SPEC(configure_c_stdio, BOOL, READ_ONLY, NO_SYS), + SPEC(dev_mode, BOOL, READ_ONLY, NO_SYS), // sys.flags.dev_mode + SPEC(dump_refs, BOOL, READ_ONLY, NO_SYS), + SPEC(dump_refs_file, WSTR_OPT, READ_ONLY, NO_SYS), #ifdef Py_GIL_DISABLED - SPEC(enable_gil, INT, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(tlbc_enabled, INT, READ_ONLY, NO_SYS, NO_GLOBAL), + SPEC(enable_gil, INT, READ_ONLY, NO_SYS), + SPEC(tlbc_enabled, INT, READ_ONLY, NO_SYS), #endif - SPEC(faulthandler, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(filesystem_encoding, WSTR, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(filesystem_errors, WSTR, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(hash_seed, ULONG, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(home, WSTR_OPT, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(thread_inherit_context, INT, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(context_aware_warnings, INT, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(import_time, UINT, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(install_signal_handlers, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(isolated, BOOL, READ_ONLY, NO_SYS, GLOBAL(&Py_IsolatedFlag, 0)), // sys.flags.isolated + SPEC(faulthandler, BOOL, READ_ONLY, NO_SYS), + SPEC(filesystem_encoding, WSTR, READ_ONLY, NO_SYS), + SPEC(filesystem_errors, WSTR, READ_ONLY, NO_SYS), + SPEC(hash_seed, ULONG, READ_ONLY, NO_SYS), + SPEC(home, WSTR_OPT, READ_ONLY, NO_SYS), + SPEC(thread_inherit_context, INT, READ_ONLY, NO_SYS), + SPEC(context_aware_warnings, INT, READ_ONLY, NO_SYS), + SPEC(import_time, UINT, READ_ONLY, NO_SYS), + SPEC(install_signal_handlers, BOOL, READ_ONLY, NO_SYS), + SPEC(isolated, BOOL, READ_ONLY, NO_SYS), // sys.flags.isolated #ifdef MS_WINDOWS - SPEC(legacy_windows_stdio, BOOL, READ_ONLY, NO_SYS, - GLOBAL(&Py_LegacyWindowsStdioFlag, 0)), + SPEC(legacy_windows_stdio, BOOL, READ_ONLY, NO_SYS), #endif - SPEC(malloc_stats, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(pymalloc_hugepages, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(orig_argv, WSTR_LIST, READ_ONLY, SYS_ATTR("orig_argv"), NO_GLOBAL), - SPEC(parse_argv, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(pathconfig_warnings, BOOL, READ_ONLY, NO_SYS, - GLOBAL(&Py_FrozenFlag, 1)), - SPEC(perf_profiling, UINT, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(remote_debug, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(program_name, WSTR, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(run_command, WSTR_OPT, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(run_filename, WSTR_OPT, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(run_module, WSTR_OPT, READ_ONLY, NO_SYS, NO_GLOBAL), + SPEC(malloc_stats, BOOL, READ_ONLY, NO_SYS), + SPEC(pymalloc_hugepages, BOOL, READ_ONLY, NO_SYS), + SPEC(orig_argv, WSTR_LIST, READ_ONLY, SYS_ATTR("orig_argv")), + SPEC(parse_argv, BOOL, READ_ONLY, NO_SYS), + SPEC(pathconfig_warnings, BOOL, READ_ONLY, NO_SYS), + SPEC(perf_profiling, UINT, READ_ONLY, NO_SYS), + SPEC(remote_debug, BOOL, READ_ONLY, NO_SYS), + SPEC(program_name, WSTR, READ_ONLY, NO_SYS), + SPEC(run_command, WSTR_OPT, READ_ONLY, NO_SYS), + SPEC(run_filename, WSTR_OPT, READ_ONLY, NO_SYS), + SPEC(run_module, WSTR_OPT, READ_ONLY, NO_SYS), #ifdef Py_DEBUG - SPEC(run_presite, WSTR_OPT, READ_ONLY, NO_SYS, NO_GLOBAL), + SPEC(run_presite, WSTR_OPT, READ_ONLY, NO_SYS), #endif - SPEC(safe_path, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(show_ref_count, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(site_import, BOOL, READ_ONLY, NO_SYS, GLOBAL(&Py_NoSiteFlag, 1)), // sys.flags.no_site - SPEC(skip_source_first_line, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(stdio_encoding, WSTR, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(stdio_errors, WSTR, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(tracemalloc, UINT, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(use_frozen_modules, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), - SPEC(use_hash_seed, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), + SPEC(safe_path, BOOL, READ_ONLY, NO_SYS), + SPEC(show_ref_count, BOOL, READ_ONLY, NO_SYS), + SPEC(site_import, BOOL, READ_ONLY, NO_SYS), // sys.flags.no_site + SPEC(skip_source_first_line, BOOL, READ_ONLY, NO_SYS), + SPEC(stdio_encoding, WSTR_OPT, READ_ONLY, NO_SYS), + SPEC(stdio_errors, WSTR, READ_ONLY, NO_SYS), + SPEC(tracemalloc, UINT, READ_ONLY, NO_SYS), + SPEC(use_frozen_modules, BOOL, READ_ONLY, NO_SYS), + SPEC(use_hash_seed, BOOL, READ_ONLY, NO_SYS), #ifdef __APPLE__ - SPEC(use_system_logger, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), + SPEC(use_system_logger, BOOL, READ_ONLY, NO_SYS), #endif - SPEC(user_site_directory, BOOL, READ_ONLY, NO_SYS, - GLOBAL(&Py_NoUserSiteDirectory, 1)), // sys.flags.no_user_site - SPEC(warn_default_encoding, BOOL, READ_ONLY, NO_SYS, NO_GLOBAL), + SPEC(user_site_directory, BOOL, READ_ONLY, NO_SYS), // sys.flags.no_user_site + SPEC(warn_default_encoding, BOOL, READ_ONLY, NO_SYS), // --- Init-only options ----------- - SPEC(_config_init, UINT, INIT_ONLY, NO_SYS, NO_GLOBAL), - SPEC(_init_main, BOOL, INIT_ONLY, NO_SYS, NO_GLOBAL), - SPEC(_install_importlib, BOOL, INIT_ONLY, NO_SYS, NO_GLOBAL), - SPEC(_is_python_build, BOOL, INIT_ONLY, NO_SYS, NO_GLOBAL), - SPEC(module_search_paths_set, BOOL, INIT_ONLY, NO_SYS, NO_GLOBAL), - SPEC(pythonpath_env, WSTR_OPT, INIT_ONLY, NO_SYS, NO_GLOBAL), - SPEC(sys_path_0, WSTR_OPT, INIT_ONLY, NO_SYS, NO_GLOBAL), + SPEC(_config_init, UINT, INIT_ONLY, NO_SYS), + SPEC(_init_main, BOOL, INIT_ONLY, NO_SYS), + SPEC(_install_importlib, BOOL, INIT_ONLY, NO_SYS), + SPEC(_is_python_build, BOOL, INIT_ONLY, NO_SYS), + SPEC(module_search_paths_set, BOOL, INIT_ONLY, NO_SYS), + SPEC(pythonpath_env, WSTR_OPT, INIT_ONLY, NO_SYS), + SPEC(sys_path_0, WSTR_OPT, INIT_ONLY, NO_SYS), + SPEC(_deferred_cmdline_option, INT, INIT_ONLY, NO_SYS), // Array terminator {NULL, 0, 0, 0, NO_SYS}, @@ -252,16 +240,11 @@ static const PyConfigSpec PYPRECONFIG_SPEC[] = { {NULL, 0, 0, 0, NO_SYS}, }; -// End of ignoring deprecations on global variables -_Py_COMP_DIAG_POP - #undef SPEC #undef SYS_ATTR #undef SYS_FLAG_SETTER #undef SYS_FLAG #undef NO_SYS -#undef GLOBAL -#undef NO_GLOBAL // Forward declarations @@ -611,45 +594,30 @@ static const char usage_envvars[] = /* --- Global configuration variables ----------------------------- */ +// Variable removed from Python limited C API 3.16, but kept in the stable ABI +PyAPI_DATA(int) Py_UTF8Mode; + /* UTF-8 mode (PEP 540): if equal to 1, use the UTF-8 encoding, and change stdin and stdout error handler to "surrogateescape". */ int Py_UTF8Mode = 0; -int Py_DebugFlag = 0; /* Needed by parser.c */ -int Py_VerboseFlag = 0; /* Needed by import.c */ -int Py_QuietFlag = 0; /* Needed by sysmodule.c */ -int Py_InteractiveFlag = 0; /* Previously, was used by Py_FdIsInteractive() */ -int Py_InspectFlag = 0; /* Needed to determine whether to exit at SystemExit */ -int Py_OptimizeFlag = 0; /* Needed by compile.c */ -int Py_NoSiteFlag = 0; /* Suppress 'import site' */ -int Py_BytesWarningFlag = 0; /* Warn on str(bytes) and str(buffer) */ -int Py_FrozenFlag = 0; /* Needed by getpath.c */ -int Py_IgnoreEnvironmentFlag = 0; /* e.g. PYTHONPATH, PYTHONHOME */ -int Py_DontWriteBytecodeFlag = 0; /* Suppress writing bytecode files (*.pyc) */ -int Py_NoUserSiteDirectory = 0; /* for -s and site.py */ -int Py_UnbufferedStdioFlag = 0; /* Unbuffered binary std{in,out,err} */ -int Py_HashRandomizationFlag = 0; /* for -R and PYTHONHASHSEED */ -int Py_IsolatedFlag = 0; /* for -I, isolate from user's env */ -#ifdef MS_WINDOWS -int Py_LegacyWindowsFSEncodingFlag = 0; /* Uses mbcs instead of utf-8 */ -int Py_LegacyWindowsStdioFlag = 0; /* Uses FileIO instead of WindowsConsoleIO */ -#endif static PyObject * _Py_GetGlobalVariablesAsDict(void) { -_Py_COMP_DIAG_PUSH -_Py_COMP_DIAG_IGNORE_DEPR_DECLS - PyObject *dict, *obj; + extern const char *Py_FileSystemDefaultEncoding; + extern const char *Py_FileSystemDefaultEncodeErrors; + extern int Py_HasFileSystemDefaultEncoding; + extern int _Py_HasFileSystemDefaultEncodeErrors; - dict = PyDict_New(); + PyObject *dict = PyDict_New(); if (dict == NULL) { return NULL; } #define SET_ITEM(KEY, EXPR) \ do { \ - obj = (EXPR); \ + PyObject *obj = (EXPR); \ if (obj == NULL) { \ goto fail; \ } \ @@ -674,27 +642,6 @@ _Py_COMP_DIAG_IGNORE_DEPR_DECLS SET_ITEM_INT(_Py_HasFileSystemDefaultEncodeErrors); SET_ITEM_INT(Py_UTF8Mode); - SET_ITEM_INT(Py_DebugFlag); - SET_ITEM_INT(Py_VerboseFlag); - SET_ITEM_INT(Py_QuietFlag); - SET_ITEM_INT(Py_InteractiveFlag); - SET_ITEM_INT(Py_InspectFlag); - - SET_ITEM_INT(Py_OptimizeFlag); - SET_ITEM_INT(Py_NoSiteFlag); - SET_ITEM_INT(Py_BytesWarningFlag); - SET_ITEM_INT(Py_FrozenFlag); - SET_ITEM_INT(Py_IgnoreEnvironmentFlag); - SET_ITEM_INT(Py_DontWriteBytecodeFlag); - SET_ITEM_INT(Py_NoUserSiteDirectory); - SET_ITEM_INT(Py_UnbufferedStdioFlag); - SET_ITEM_INT(Py_HashRandomizationFlag); - SET_ITEM_INT(Py_IsolatedFlag); - -#ifdef MS_WINDOWS - SET_ITEM_INT(Py_LegacyWindowsFSEncodingFlag); - SET_ITEM_INT(Py_LegacyWindowsStdioFlag); -#endif return dict; @@ -706,19 +653,22 @@ _Py_COMP_DIAG_IGNORE_DEPR_DECLS #undef SET_ITEM #undef SET_ITEM_INT #undef SET_ITEM_STR -_Py_COMP_DIAG_POP } char* Py_GETENV(const char *name) { -_Py_COMP_DIAG_PUSH -_Py_COMP_DIAG_IGNORE_DEPR_DECLS - if (Py_IgnoreEnvironmentFlag) { + int use_environment = 1; + PyThreadState *tstate = PyThreadState_GetUnchecked(); + if (tstate != NULL) { + const PyConfig *config = &tstate->interp->config; + use_environment = config->use_environment; + } + + if (!use_environment) { return NULL; } return getenv(name); -_Py_COMP_DIAG_POP } /* --- PyStatus ----------------------------------------------- */ @@ -1074,11 +1024,14 @@ config_check_consistency(const PyConfig *config) assert(config->module_search_paths_set >= 0); assert(config->filesystem_encoding != NULL); assert(config->filesystem_errors != NULL); - assert(config->stdio_encoding != NULL); - assert(config->stdio_errors != NULL); #ifdef MS_WINDOWS + /* stdio_encoding can be NULL in the legacy Windows stdio mode. */ + assert(config->stdio_encoding != NULL || config->legacy_windows_stdio); assert(config->legacy_windows_stdio >= 0); +#else + assert(config->stdio_encoding != NULL); #endif + assert(config->stdio_errors != NULL); /* -c and -m options are exclusive */ assert(!(config->run_command != NULL && config->run_module != NULL)); assert(config->check_hash_pycs_mode != NULL); @@ -1811,63 +1764,19 @@ config_get_env_dup(PyConfig *config, static void -config_get_global_vars(PyConfig *config) +config_read_preconfig(PyConfig *config) { - if (config->_config_init != _PyConfig_INIT_COMPAT) { - /* Python and Isolated configuration ignore global variables */ - return; - } - - const PyConfigSpec *spec = PYCONFIG_SPEC; - for (; spec->name != NULL; spec++) { - if (spec->global_var.ptr == NULL) { - continue; - } - assert(spec->type == PyConfig_MEMBER_INT - || spec->type == PyConfig_MEMBER_UINT - || spec->type == PyConfig_MEMBER_BOOL); - int *member = config_get_spec_member(config, spec); - if (*member != -1) { - continue; - } - int value = *spec->global_var.ptr; - if (spec->global_var.not) { - value = !value; +#define COPY_FLAG(ATTR) \ + if (config->ATTR == -1) { \ + config->ATTR = preconfig->ATTR; \ } - *member = value; - } -} + const PyPreConfig *preconfig = &_PyRuntime.preconfig; + COPY_FLAG(isolated); + COPY_FLAG(use_environment); + COPY_FLAG(dev_mode); -/* Set Py_xxx global configuration variables from 'config' configuration. */ -static void -config_set_global_vars(const PyConfig *config) -{ - const PyConfigSpec *spec = PYCONFIG_SPEC; - for (; spec->name != NULL; spec++) { - if (spec->global_var.ptr == NULL) { - continue; - } - assert(spec->type == PyConfig_MEMBER_INT - || spec->type == PyConfig_MEMBER_UINT - || spec->type == PyConfig_MEMBER_BOOL); - int *member = config_get_spec_member(config, spec); - int value = *member; - if (value == -1) { - continue; - } - if (spec->global_var.not) { - value = !value; - } - *spec->global_var.ptr = value; - } - -_Py_COMP_DIAG_PUSH -_Py_COMP_DIAG_IGNORE_DEPR_DECLS - /* Random or non-zero hash seed */ - Py_HashRandomizationFlag = (config->use_hash_seed == 0 || - config->hash_seed != 0); -_Py_COMP_DIAG_POP +#undef COPY_FLAG } @@ -2709,7 +2618,13 @@ config_init_stdio_encoding(PyConfig *config, } /* Choose the default error handler based on the current locale. */ - if (config->stdio_encoding == NULL) { + if (config->stdio_encoding == NULL +#ifdef MS_WINDOWS + /* gh-86427: it is determined for each stream: create_stdio() uses + _Py_device_encoding(), falling back to the locale encoding. */ + && !config->legacy_windows_stdio +#endif + ) { status = config_get_locale_encoding(config, preconfig, &config->stdio_encoding); if (_PyStatus_EXCEPTION(status)) { @@ -3011,8 +2926,6 @@ config_init_stdio(const PyConfig *config) PyStatus _PyConfig_Write(const PyConfig *config, _PyRuntimeState *runtime) { - config_set_global_vars(config); - if (config->configure_c_stdio) { config_init_stdio(config); } @@ -3084,19 +2997,23 @@ static PyStatus config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions, Py_ssize_t *opt_index) { + // Only store the first option +#define DEFER_OPTION(OPTION) \ + do { \ + if (config->_deferred_cmdline_option == 0) { \ + config->_deferred_cmdline_option = (OPTION); \ + } \ + } while (0) + PyStatus status; const PyWideStringList *argv = &config->argv; int print_version = 0; - const wchar_t* program = config->program_name; - if (!program && argv->length >= 1) { - program = argv->items[0]; - } - _PyOS_ResetGetOpt(); + struct _PyOS_GetOpt getopt; + _PyOS_GetOpt_Init(&getopt, argv->length, argv->items); do { - int longindex = -1; - int c = _PyOS_GetOpt(argv->length, argv->items, &longindex); - if (c == EOF) { + int c = _PyOS_GetOpt(&getopt); + if (c == -1) { break; } @@ -3105,12 +3022,12 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions, /* -c is the last option; following arguments that look like options are left for the command to interpret. */ - size_t len = wcslen(_PyOS_optarg) + 1 + 1; + size_t len = wcslen(getopt.arg) + 1 + 1; wchar_t *command = PyMem_RawMalloc(sizeof(wchar_t) * len); if (command == NULL) { return _PyStatus_NO_MEMORY(); } - memcpy(command, _PyOS_optarg, (len - 2) * sizeof(wchar_t)); + memcpy(command, getopt.arg, (len - 2) * sizeof(wchar_t)); command[len - 2] = '\n'; command[len - 1] = 0; config->run_command = command; @@ -3123,7 +3040,7 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions, that look like options are left for the module to interpret. */ if (config->run_module == NULL) { - config->run_module = _PyMem_RawWcsdup(_PyOS_optarg); + config->run_module = _PyMem_RawWcsdup(getopt.arg); if (config->run_module == NULL) { return _PyStatus_NO_MEMORY(); } @@ -3133,39 +3050,36 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions, switch (c) { // Integers represent long options, see Python/getopt.c - case 0: - // check-hash-based-pycs - if (wcscmp(_PyOS_optarg, L"always") == 0 - || wcscmp(_PyOS_optarg, L"never") == 0 - || wcscmp(_PyOS_optarg, L"default") == 0) + case 1: + // --check-hash-based-pycs option + if (wcscmp(getopt.arg, L"always") == 0 + || wcscmp(getopt.arg, L"never") == 0 + || wcscmp(getopt.arg, L"default") == 0) { status = PyConfig_SetString(config, &config->check_hash_pycs_mode, - _PyOS_optarg); + getopt.arg); if (_PyStatus_EXCEPTION(status)) { return status; } } else { - fprintf(stderr, "--check-hash-based-pycs must be one of " - "'default', 'always', or 'never'\n"); - config_usage(1, program); - return _PyStatus_EXIT(2); + DEFER_OPTION(c); } break; - case 1: - // help-all - config_complete_usage(program); - return _PyStatus_EXIT(0); - case 2: - // help-env - config_envvars_usage(); - return _PyStatus_EXIT(0); + // --help-all option + DEFER_OPTION(c); + break; case 3: - // help-xoptions - config_xoptions_usage(); - return _PyStatus_EXIT(0); + // --help-env option + DEFER_OPTION(c); + break; + + case 4: + // --help-xoptions option + DEFER_OPTION(c); + break; case 'b': config->bytes_warning++; @@ -3224,15 +3138,15 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions, case 'h': case '?': - config_usage(0, program); - return _PyStatus_EXIT(0); + DEFER_OPTION(c); + break; case 'V': print_version++; break; case 'W': - status = PyWideStringList_Append(warnoptions, _PyOS_optarg); + status = PyWideStringList_Append(warnoptions, getopt.arg); if (_PyStatus_EXCEPTION(status)) { return status; } @@ -3250,36 +3164,106 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions, default: /* unknown argument: parsing failed */ - config_usage(1, program); - return _PyStatus_EXIT(2); + DEFER_OPTION(c); + break; } - } while (1); + } while (config->_deferred_cmdline_option == 0); - if (print_version) { - printf("Python %s\n", - (print_version >= 2) ? Py_GetVersion() : PY_VERSION); - return _PyStatus_EXIT(0); + if (print_version >= 2) { + DEFER_OPTION('W'); + } + else if (print_version >= 1) { + DEFER_OPTION('V'); } if (config->run_command == NULL && config->run_module == NULL - && _PyOS_optind < argv->length - && wcscmp(argv->items[_PyOS_optind], L"-") != 0 + && getopt.index < argv->length + && wcscmp(argv->items[getopt.index], L"-") != 0 && config->run_filename == NULL) { - config->run_filename = _PyMem_RawWcsdup(argv->items[_PyOS_optind]); + config->run_filename = _PyMem_RawWcsdup(argv->items[getopt.index]); if (config->run_filename == NULL) { return _PyStatus_NO_MEMORY(); } } if (config->run_command != NULL || config->run_module != NULL) { - /* Backup _PyOS_optind */ - _PyOS_optind--; + /* Backup getopt.index */ + getopt.index--; } - *opt_index = _PyOS_optind; + *opt_index = getopt.index; return _PyStatus_OK(); + +#undef DEFER_OPTION +} + + +int +_PyConfig_ProcessDeferredCmdlineOption(PyConfig *config) +{ + int c = config->_deferred_cmdline_option; + config->_deferred_cmdline_option = 0; + if (c == 0) { + // There is no deferred option + return -1; + } + + // Select the program name + const PyWideStringList *argv = &config->argv; + const wchar_t* program = config->program_name; + if (!program && argv->length >= 1) { + program = argv->items[0]; + } + if (!program) { + program = L"python"; + } + + switch (c) { + case 'h': + case '?': + config_usage(0, program); + return 0; + + case 'V': + printf("Python %s\n", PY_VERSION); + return 0; + + case 'W': // -VV or more -V options + printf("Python %s\n", Py_GetVersion()); + return 0; + + // Integers represent long options, see Python/getopt.c + case 1: + // check-hash-based-pycs + fprintf(stderr, "--check-hash-based-pycs must be one of " + "'default', 'always', or 'never'\n"); + config_usage(1, program); + return 2; + + case 2: + // help-all + config_complete_usage(program); + return 0; + + case 3: + // help-env + config_envvars_usage(); + return 0; + + case 4: + // help-xoptions + config_xoptions_usage(); + return 0; + + case '_': + // Unknown option or missing argument + _Py_FALLTHROUGH; + default: + config_usage(1, program); + return 2; + } } @@ -3722,7 +3706,6 @@ config_argv0_add_exe(PyConfig *config) * Command line arguments * Environment variables - * Py_xxx global configuration variables The only side effects are to modify config and to call _Py_SetArgcArgv(). */ PyStatus @@ -3735,7 +3718,56 @@ _PyConfig_Read(PyConfig *config, int compute_path_config) return status; } - config_get_global_vars(config); + config_read_preconfig(config); + + // Set default values + if (config->bytes_warning < 0) { + config->bytes_warning = 0; + } + if (config->inspect < 0) { + config->inspect = 0; + } + if (config->interactive < 0) { + config->interactive = 0; + } + if (config->optimization_level < 0) { + config->optimization_level = 0; + } + if (config->parser_debug < 0) { + config->parser_debug = 0; + } + if (config->quiet < 0) { + config->quiet = 0; + } + if (config->use_environment < 0) { + config->use_environment = 0; + } + if (config->verbose < 0) { + config->verbose = 0; + } + if (config->write_bytecode < 0) { + config->write_bytecode = 1; + } + if (config->buffered_stdio < 0) { + config->buffered_stdio = 1; + } + if (config->isolated < 0) { + config->isolated = 0; + } +#ifdef MS_WINDOWS + if (config->legacy_windows_stdio < 0) { + config->legacy_windows_stdio = 0; + } +#endif + if (config->pathconfig_warnings < 0) { + config->pathconfig_warnings = 1; + } + if (config->site_import < 0) { + config->site_import = 1; + } + if (config->user_site_directory < 0) { + config->user_site_directory = 1; + } #ifdef __CYGWIN__ status = config_argv0_add_exe(config); @@ -4005,22 +4037,7 @@ PyInitConfig_Free(PyInitConfig *config) int PyInitConfig_GetError(PyInitConfig* config, const char **perr_msg) { - if (_PyStatus_IS_EXIT(config->status)) { - char buffer[22]; // len("exit code -2147483648\0") - PyOS_snprintf(buffer, sizeof(buffer), - "exit code %i", - config->status.exitcode); - - if (config->err_msg != NULL) { - free(config->err_msg); - } - config->err_msg = strdup(buffer); - if (config->err_msg != NULL) { - *perr_msg = config->err_msg; - return 1; - } - config->status = _PyStatus_NO_MEMORY(); - } + assert(!_PyStatus_IS_EXIT(config->status)); if (_PyStatus_IS_ERROR(config->status) && config->status.err_msg != NULL) { *perr_msg = config->status.err_msg; @@ -4036,13 +4053,8 @@ PyInitConfig_GetError(PyInitConfig* config, const char **perr_msg) int PyInitConfig_GetExitCode(PyInitConfig* config, int *exitcode) { - if (_PyStatus_IS_EXIT(config->status)) { - *exitcode = config->status.exitcode; - return 1; - } - else { - return 0; - } + assert(!_PyStatus_IS_EXIT(config->status)); + return 0; } @@ -4141,7 +4153,9 @@ static char* wstr_to_utf8(PyInitConfig *config, wchar_t *wstr) { char *utf8; - int res = _Py_EncodeUTF8Ex(wstr, &utf8, NULL, NULL, 1, _Py_ERROR_STRICT); + size_t utf8_len; + int res = _Py_EncodeUTF8(wstr, &utf8, &utf8_len, + NULL, 1, _Py_ERROR_STRICT); if (res == -2) { initconfig_set_error(config, "encoding error"); return NULL; @@ -4152,7 +4166,7 @@ wstr_to_utf8(PyInitConfig *config, wchar_t *wstr) } // Copy to use the malloc() memory allocator - size_t size = strlen(utf8) + 1; + size_t size = utf8_len + 1; char *str = malloc(size); if (str == NULL) { PyMem_RawFree(utf8); @@ -4311,12 +4325,13 @@ utf8_to_wstr(PyInitConfig *config, const char *str) { wchar_t *wstr; size_t wlen; - int res = _Py_DecodeUTF8Ex(str, strlen(str), &wstr, &wlen, NULL, _Py_ERROR_STRICT); - if (res == -2) { + int res = _Py_DecodeUTF8(str, strlen(str), &wstr, &wlen, _Py_ERROR_STRICT); + if (res == _Py_CODEC_DECODE_ERROR) { initconfig_set_error(config, "decoding error"); return NULL; } if (res < 0) { + assert(res == _Py_CODEC_MEMORY_ERROR); config->status = _PyStatus_NO_MEMORY(); return NULL; } @@ -4353,14 +4368,22 @@ PyInitConfig_SetStr(PyInitConfig *config, const char *name, const char* value) if (value == NULL && spec->type != PyConfig_MEMBER_WSTR_OPT) { initconfig_set_error(config, "config option string cannot be NULL"); + return -1; } wchar_t **member = raw_member; - - *member = utf8_to_wstr(config, value); - if (*member == NULL) { - return -1; + wchar_t *wstr; + if (value != NULL) { + wstr = utf8_to_wstr(config, value); + if (wstr == NULL) { + return -1; + } + } + else { + wstr = NULL; } + free(*member); + *member = wstr; return 0; } @@ -4993,16 +5016,6 @@ PyConfig_Set(const char *name, PyObject *value) Py_UNREACHABLE(); } - // Set the global variable - if (spec->global_var.ptr != NULL) { - assert(has_int_value); - int value = int_value; - if (spec->global_var.not) { - value = !value; - } - *spec->global_var.ptr = value; - } - if (spec->sys.attr != NULL) { // Set the sys attribute, but don't set PyInterpreterState.config // to keep the code simple. diff --git a/Python/instrumentation.c b/Python/instrumentation.c index 0af2070b5cd983a..48daa91259d3c9e 100644 --- a/Python/instrumentation.c +++ b/Python/instrumentation.c @@ -715,9 +715,6 @@ de_instrument_line(PyCodeObject *code, _Py_CODEUNIT *bytecode, _PyCoMonitoringDa } _PyCoLineInstrumentationData *lines = monitoring->lines; int original_opcode = _PyCode_GetOriginalOpcode(lines, i); - if (original_opcode == INSTRUMENTED_INSTRUCTION) { - set_original_opcode(lines, i, monitoring->per_instruction_opcodes[i]); - } CHECK(original_opcode != 0); CHECK(original_opcode == _PyOpcode_Deopt[original_opcode]); FT_ATOMIC_STORE_UINT8(instr->op.code, original_opcode); @@ -882,7 +879,15 @@ remove_line_tools(PyCodeObject * code, int offset, int tools) should_de_instrument = ((single_tool & tools) == single_tool); } if (should_de_instrument) { + /* Restore all thread-local bytecodes before updating the shared + * original opcode. */ MODIFY_BYTECODE(code, de_instrument_line, monitoring, offset); + if (_PyCode_GetOriginalOpcode(monitoring->lines, offset) == + INSTRUMENTED_INSTRUCTION) + { + set_original_opcode(monitoring->lines, offset, + monitoring->per_instruction_opcodes[offset]); + } } } @@ -989,8 +994,12 @@ call_one_instrument( if (res == NULL) { return -1; } + if (res == &_PyInstrumentation_DISABLE) { + assert(_Py_IsImmortal(res)); + return 1; + } Py_DECREF(res); - return (res == &_PyInstrumentation_DISABLE); + return 0; } static const int8_t MOST_SIGNIFICANT_BITS[16] = { @@ -1420,6 +1429,11 @@ _Py_call_instrumentation_line(PyThreadState *tstate, _PyInterpreterFrame* frame, uint8_t original_opcode; done: original_opcode = _PyCode_GetOriginalOpcode(line_data, i); + if (instr->op.code == INSTRUMENTED_INSTRUCTION) { + /* A LINE callback may have disabled the last LINE tool while + * leaving INSTRUCTION monitoring enabled. */ + original_opcode = INSTRUMENTED_INSTRUCTION; + } assert(original_opcode != 0); assert(original_opcode != INSTRUMENTED_LINE); assert(_PyOpcode_Deopt[original_opcode] == original_opcode); @@ -1686,6 +1700,7 @@ allocate_instrumentation_data(PyCodeObject *code) } monitoring->local_monitors = (_Py_LocalMonitors){ 0 }; monitoring->active_monitors = (_Py_LocalMonitors){ 0 }; + memset(monitoring->tool_versions, 0, sizeof(monitoring->tool_versions)); monitoring->tools = NULL; monitoring->lines = NULL; monitoring->line_tools = NULL; @@ -2026,7 +2041,7 @@ check_tool(PyInterpreterState *interp, int tool_id) } /* We share the eval-breaker with flags, so the monitoring - * version goes in the top 24 bits */ + * version goes in the bits above _PY_EVAL_EVENTS_BITS */ #define MONITORING_VERSION_INCREMENT (1 << _PY_EVAL_EVENTS_BITS) int diff --git a/Python/interpconfig.c b/Python/interpconfig.c index a37bd3f5b23a01e..9ff28f881343181 100644 --- a/Python/interpconfig.c +++ b/Python/interpconfig.c @@ -133,7 +133,12 @@ _config_dict_copy_str(PyObject *dict, const char *name, config_dict_invalid_type(name); return -1; } - strncpy(buf, PyUnicode_AsUTF8(item), bufsize-1); + const char *str = PyUnicode_AsUTF8(item); + if (str == NULL) { + Py_DECREF(item); + return -1; + } + strncpy(buf, str, bufsize-1); buf[bufsize-1] = '\0'; Py_DECREF(item); return 0; diff --git a/Python/intrinsics.c b/Python/intrinsics.c index f081f33cc83b88c..dfa81baa654e123 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -270,6 +270,42 @@ make_typevar_with_constraints(PyThreadState* Py_UNUSED(ignored), PyObject *name, return _Py_make_typevar(name, NULL, evaluate_constraints); } +static PyObject * +add_conditional_annotation(PyThreadState* tstate, PyObject *conditional_annotations, + PyObject *index) +{ + // gh-154902: user code can rebind __conditional_annotations__ to any object + if (!PySet_CheckExact(conditional_annotations)) { + _PyErr_Format(tstate, PyExc_TypeError, + "__conditional_annotations__ must be a set, not %T", + conditional_annotations); + return NULL; + } + if (PySet_Add(conditional_annotations, index) < 0) { + return NULL; + } + Py_RETURN_NONE; +} + +static PyObject * +match_class_isinstance(PyThreadState* tstate, PyObject *subject, PyObject *type) +{ + /* Fast path for class patterns with no sub-patterns, e.g. `case C():` + Equivalent to the isinstance check performed by _PyEval_MatchClass, + including the same TypeError when the pattern does not refer to a + class. */ + if (!PyType_Check(type)) { + _PyErr_SetString(tstate, PyExc_TypeError, + "class pattern must refer to a class"); + return NULL; + } + int res = PyObject_IsInstance(subject, type); + if (res < 0) { + return NULL; + } + return res ? Py_True : Py_False; +} + const intrinsic_func2_info _PyIntrinsics_BinaryFunctions[] = { INTRINSIC_FUNC_ENTRY(INTRINSIC_2_INVALID, no_intrinsic2) @@ -278,6 +314,8 @@ _PyIntrinsics_BinaryFunctions[] = { INTRINSIC_FUNC_ENTRY(INTRINSIC_TYPEVAR_WITH_CONSTRAINTS, make_typevar_with_constraints) INTRINSIC_FUNC_ENTRY(INTRINSIC_SET_FUNCTION_TYPE_PARAMS, _Py_set_function_type_params) INTRINSIC_FUNC_ENTRY(INTRINSIC_SET_TYPEPARAM_DEFAULT, _Py_set_typeparam_default) + INTRINSIC_FUNC_ENTRY(INTRINSIC_ADD_CONDITIONAL_ANNOTATION, add_conditional_annotation) + INTRINSIC_FUNC_ENTRY(INTRINSIC_MATCH_CLASS_ISINSTANCE, match_class_isinstance) }; #undef INTRINSIC_FUNC_ENTRY diff --git a/Python/lock.c b/Python/lock.c index af136fefd299d37..59dfe772a0365f1 100644 --- a/Python/lock.c +++ b/Python/lock.c @@ -25,12 +25,10 @@ static const PyTime_t TIME_TO_BE_FAIR_NS = 1000*1000; // Spin for a bit before parking the thread. This is only enabled for // `--disable-gil` builds because it is unlikely to be helpful if the GIL is // enabled. -#if Py_GIL_DISABLED +#ifdef Py_GIL_DISABLED static const int MAX_SPIN_COUNT = 40; -static const int RELOAD_SPIN_MASK = 3; #else static const int MAX_SPIN_COUNT = 0; -static const int RELOAD_SPIN_MASK = 1; #endif struct mutex_entry { @@ -81,16 +79,6 @@ _PyMutex_LockTimed(PyMutex *m, PyTime_t timeout, _PyLockFlags flags) }; Py_ssize_t spin_count = 0; -#ifdef Py_GIL_DISABLED - // Using thread-id as a way of reducing contention further in the reload below. - // It adds a pseudo-random starting offset to the recurrence, so that threads - // are less likely to try and run compare-exchange at the same time. - // The lower bits of platform thread ids are likely to not be random, - // hence the right shift. - const Py_ssize_t tid = (Py_ssize_t)(_Py_ThreadId() >> 12); -#else - const Py_ssize_t tid = 0; -#endif for (;;) { if ((v & _Py_LOCKED) == 0) { // The lock is unlocked. Try to grab it. @@ -104,9 +92,6 @@ _PyMutex_LockTimed(PyMutex *m, PyTime_t timeout, _PyLockFlags flags) // Spin for a bit. _Py_yield(); spin_count++; - if (((spin_count + tid) & RELOAD_SPIN_MASK) == 0) { - v = _Py_atomic_load_uint8_relaxed(&m->_bits); - } continue; } @@ -468,6 +453,25 @@ _PyRecursiveMutex_TryUnlock(_PyRecursiveMutex *m) return 0; } +#ifdef HAVE_FORK +// Reinitialize the mutex in the child process after fork(). The caller must +// record before fork() whether the forking thread owns the mutex, since the +// thread ident can change in the child (gh-126688). If it does, the child +// keeps the mutex with the same recursion level; otherwise the owner and any +// waiters no longer exist in the child and the mutex is reset. +void +_PyRecursiveMutex_at_fork_reinit(_PyRecursiveMutex *m, int owned) +{ + if (owned) { + m->mutex = (PyMutex){._bits = _Py_LOCKED}; + _Py_atomic_store_ullong_relaxed(&m->thread, PyThread_get_thread_ident_ex()); + } + else { + memset(m, 0, sizeof(*m)); + } +} +#endif + #define _Py_WRITE_LOCKED 1 #define _PyRWMutex_READER_SHIFT 2 #define _Py_RWMUTEX_MAX_READERS (UINTPTR_MAX >> _PyRWMutex_READER_SHIFT) @@ -574,81 +578,6 @@ _PyRWMutex_Unlock(_PyRWMutex *rwmutex) } } -#define SEQLOCK_IS_UPDATING(sequence) (sequence & 0x01) - -void _PySeqLock_LockWrite(_PySeqLock *seqlock) -{ - // lock by moving to an odd sequence number - uint32_t prev = _Py_atomic_load_uint32_relaxed(&seqlock->sequence); - while (1) { - if (SEQLOCK_IS_UPDATING(prev)) { - // Someone else is currently updating the cache - _Py_yield(); - prev = _Py_atomic_load_uint32_relaxed(&seqlock->sequence); - } - else if (_Py_atomic_compare_exchange_uint32(&seqlock->sequence, &prev, prev + 1)) { - // We've locked the cache - _Py_atomic_fence_release(); - break; - } - else { - _Py_yield(); - } - } -} - -void _PySeqLock_AbandonWrite(_PySeqLock *seqlock) -{ - uint32_t new_seq = _Py_atomic_load_uint32_relaxed(&seqlock->sequence) - 1; - assert(!SEQLOCK_IS_UPDATING(new_seq)); - _Py_atomic_store_uint32(&seqlock->sequence, new_seq); -} - -void _PySeqLock_UnlockWrite(_PySeqLock *seqlock) -{ - uint32_t new_seq = _Py_atomic_load_uint32_relaxed(&seqlock->sequence) + 1; - assert(!SEQLOCK_IS_UPDATING(new_seq)); - _Py_atomic_store_uint32(&seqlock->sequence, new_seq); -} - -uint32_t _PySeqLock_BeginRead(_PySeqLock *seqlock) -{ - uint32_t sequence = _Py_atomic_load_uint32_acquire(&seqlock->sequence); - while (SEQLOCK_IS_UPDATING(sequence)) { - _Py_yield(); - sequence = _Py_atomic_load_uint32_acquire(&seqlock->sequence); - } - - return sequence; -} - -int _PySeqLock_EndRead(_PySeqLock *seqlock, uint32_t previous) -{ - // gh-121368: We need an explicit acquire fence here to ensure that - // this load of the sequence number is not reordered before any loads - // within the read lock. - _Py_atomic_fence_acquire(); - - if (_Py_atomic_load_uint32_relaxed(&seqlock->sequence) == previous) { - return 1; - } - - _Py_yield(); - return 0; -} - -int _PySeqLock_AfterFork(_PySeqLock *seqlock) -{ - // Synchronize again and validate that the entry hasn't been updated - // while we were readying the values. - if (SEQLOCK_IS_UPDATING(seqlock->sequence)) { - seqlock->sequence = 0; - return 1; - } - - return 0; -} - #undef PyMutex_Lock void PyMutex_Lock(PyMutex *m) diff --git a/Python/marshal.c b/Python/marshal.c index 25353f6e6896249..ca0468aa6765a41 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -14,7 +14,6 @@ #include "pycore_object.h" // _PyObject_IsUniquelyReferenced #include "pycore_pystate.h" // _PyInterpreterState_GET() #include "pycore_setobject.h" // _PySet_NextEntryRef() -#include "pycore_tuple.h" // _PyTuple_FromPairSteal #include "pycore_unicodeobject.h" // _PyUnicode_InternImmortal() #include "marshal.h" // Py_MARSHAL_VERSION @@ -44,7 +43,7 @@ module marshal */ #if defined(MS_WINDOWS) # define MAX_MARSHAL_STACK_DEPTH 1000 -#elif defined(__wasi__) +#elif defined(__wasm__) # define MAX_MARSHAL_STACK_DEPTH 1500 // TARGET_OS_IPHONE covers any non-macOS Apple platform. // It won't be defined on older macOS SDKs @@ -100,22 +99,52 @@ module marshal #define FLAG_REF '\x80' /* with a type, add obj to index */ -// Error codes: -#define WFERR_OK 0 -#define WFERR_UNMARSHALLABLE 1 -#define WFERR_NESTEDTOODEEP 2 -#define WFERR_NOMEMORY 3 -#define WFERR_CODE_NOT_ALLOWED 4 +/* State of an object which can be the target of a TYPE_REF (version 3+), + see w_ref() and w_resolve_refs(). + + WFILE.hashtable maps the object to its index in WFILE.refs, shifted left + by W_ENTRY_SHIFT bits, plus the flags: + - W_ENTRY_ACTIVE: the object is being written (used to detect recursion, + see w_complete()); + - W_ENTRY_SHARED: the object has been written more than once; + - W_ENTRY_TIED: the object is a set element which cannot be told from + other elements of the set yet. The value is then an index in + WFILE.ties instead, see w_tie_set_items(). + + The item of WFILE.refs is the offset of the type byte of the object in + the output, shifted left by one bit, plus W_REF_SHARED if the object has + been written more than once. */ +#define W_ENTRY_ACTIVE ((uintptr_t)1) +#define W_ENTRY_SHARED ((uintptr_t)2) +#define W_ENTRY_TIED ((uintptr_t)4) +#define W_ENTRY_SHIFT 3 +#define W_REF_SHARED ((size_t)1) + +/* Maximum number of items in WFILE.refs. TYPE_REF has a signed 32-bit + argument. */ +#define W_MAX_REFS Py_MIN((uintptr_t)0x7fffffff, UINTPTR_MAX >> W_ENTRY_SHIFT) typedef struct { - FILE *fp; - int error; /* see WFERR_* values */ + bool error; /* An exception has been raised. */ int depth; PyObject *str; char *ptr; const char *end; char *buf; - _Py_hashtable_t *hashtable; + _Py_hashtable_t *hashtable; /* object -> index in refs, flags */ + size_t *refs; /* In order of the first occurrence. */ + size_t refs_allocated; + unsigned char *refpos; /* Where the TYPE_REFs are in the + output, see w_add_refpos(). */ + size_t refpos_size; + size_t refpos_allocated; + size_t refpos_run; /* Index in refpos of the length of + the current run, or 0. */ + size_t refpos_end; /* Offset of the end of the last + TYPE_REF in the output. */ + size_t *ties; /* See w_tie_set_items(). */ + size_t nties; + size_t ties_allocated; int version; int allow_code; } WFILE; @@ -125,24 +154,12 @@ typedef struct { *(p)->ptr++ = (c); \ } while(0) -static void -w_flush(WFILE *p) -{ - assert(p->fp != NULL); - fwrite(p->buf, 1, p->ptr - p->buf, p->fp); - p->ptr = p->buf; -} - static int w_reserve(WFILE *p, Py_ssize_t needed) { Py_ssize_t pos, size, delta; if (p->ptr == NULL) return 0; /* An error already occurred */ - if (p->fp != NULL) { - w_flush(p); - return needed <= p->end - p->ptr; - } assert(p->str != NULL); pos = p->ptr - p->buf; size = PyBytes_GET_SIZE(p->str); @@ -152,12 +169,14 @@ w_reserve(WFILE *p, Py_ssize_t needed) delta = size + 1024; delta = Py_MAX(delta, needed); if (delta > PY_SSIZE_T_MAX - size) { - p->error = WFERR_NOMEMORY; + PyErr_NoMemory(); + p->error = true; return 0; } size += delta; if (_PyBytes_Resize(&p->str, size) != 0) { p->end = p->ptr = p->buf = NULL; + p->error = true; return 0; } else { @@ -175,21 +194,9 @@ w_string(const void *s, Py_ssize_t n, WFILE *p) if (!n || p->ptr == NULL) return; m = p->end - p->ptr; - if (p->fp != NULL) { - if (n <= m) { - memcpy(p->ptr, s, n); - p->ptr += n; - } - else { - w_flush(p); - fwrite(s, 1, n, p->fp); - } - } - else { - if (n <= m || w_reserve(p, n - m)) { - memcpy(p->ptr, s, n); - p->ptr += n; - } + if (n <= m || w_reserve(p, n - m)) { + memcpy(p->ptr, s, n); + p->ptr += n; } } @@ -209,16 +216,35 @@ w_long(long x, WFILE *p) w_byte((char)((x>>24) & 0xff), p); } +/* Read and write a 32-bit value in place. */ +static inline uint32_t +w_get_uint32(const char *ptr) +{ + const unsigned char *b = (const unsigned char *)ptr; + return b[0] | (b[1] << 8) | (b[2] << 16) | ((uint32_t)b[3] << 24); +} + +static inline void +w_put_uint32(char *ptr, uint32_t x) +{ + ptr[0] = (char)( x & 0xff); + ptr[1] = (char)((x>> 8) & 0xff); + ptr[2] = (char)((x>>16) & 0xff); + ptr[3] = (char)((x>>24) & 0xff); +} + #define SIZE32_MAX 0x7FFFFFFF #if SIZEOF_SIZE_T > 4 -# define W_SIZE(n, p) do { \ - if ((n) > SIZE32_MAX) { \ - (p)->depth--; \ - (p)->error = WFERR_UNMARSHALLABLE; \ - return; \ - } \ - w_long((long)(n), p); \ +# define W_SIZE(n, p) do { \ + if ((n) > SIZE32_MAX) { \ + (p)->depth--; \ + PyErr_SetString(PyExc_ValueError, \ + "object too large to marshal"); \ + (p)->error = true; \ + return; \ + } \ + w_long((long)(n), p); \ } while(0) #else # define W_SIZE w_long @@ -246,9 +272,10 @@ w_short_pstring(const void *s, Py_ssize_t n, WFILE *p) #define PyLong_MARSHAL_BASE ((short)1 << PyLong_MARSHAL_SHIFT) #define PyLong_MARSHAL_MASK (PyLong_MARSHAL_BASE - 1) -#define W_TYPE(t, p) do { \ - w_byte((t) | flag, (p)); \ -} while(0) +/* Write the type code of an object. It must be the first byte written for + an object passed to w_ref(): w_resolve_refs() adds FLAG_REF to that byte + if the object turns out to be referenced more than once. */ +#define W_TYPE(t, p) w_byte((t), (p)) static PyObject * _PyMarshal_WriteObjectToString(PyObject *x, int version, int allow_code); @@ -271,7 +298,8 @@ _r_digits##bitsize(const uint ## bitsize ## _t *digits, Py_ssize_t n, \ } while (d != 0); \ if (l > SIZE32_MAX) { \ p->depth--; \ - p->error = WFERR_UNMARSHALLABLE; \ + PyErr_SetString(PyExc_ValueError, "int too large to marshal"); \ + p->error = true; \ return; \ } \ w_long((long)(negative ? -l : l), p); \ @@ -295,7 +323,7 @@ _r_digits(32) #undef _r_digits static void -w_PyLong(const PyLongObject *ob, char flag, WFILE *p) +w_PyLong(const PyLongObject *ob, WFILE *p) { W_TYPE(TYPE_LONG, p); if (_PyLong_IsZero(ob)) { @@ -307,7 +335,7 @@ w_PyLong(const PyLongObject *ob, char flag, WFILE *p) if (PyLong_Export((PyObject *)ob, &long_export) < 0) { p->depth--; - p->error = WFERR_UNMARSHALLABLE; + p->error = true; return; } if (!long_export.digits) { @@ -360,7 +388,7 @@ w_float_bin(double v, WFILE *p) { char buf[8]; if (PyFloat_Pack8(v, buf, 1) < 0) { - p->error = WFERR_UNMARSHALLABLE; + p->error = true; return; } w_string(buf, 8, p); @@ -371,27 +399,123 @@ w_float_str(double v, WFILE *p) { char *buf = PyOS_double_to_string(v, 'g', 17, 0, NULL); if (!buf) { - p->error = WFERR_NOMEMORY; + p->error = true; return; } w_short_pstring(buf, strlen(buf), p); PyMem_Free(buf); } +/* Make room for one more item in a dynamic array of n items. + Return the array, which may have moved, or NULL on memory error. */ +static void * +w_array_grow(void *items, size_t n, size_t *allocated, size_t itemsize) +{ + if (n < *allocated) { + return items; + } + size_t new_allocated = *allocated ? *allocated * 2 : 16; + if (new_allocated > (size_t)PY_SSIZE_T_MAX / itemsize) { + return NULL; + } + items = PyMem_Realloc(items, new_allocated * itemsize); + if (items != NULL) { + *allocated = new_allocated; + } + return items; +} + +/* Remember that a TYPE_REF is being written at the current end of the + output. Return 0 on memory error. + + p->refpos lists the TYPE_REFs in the order of the output, as a sequence + of items which start with the byte: + - 1 to 254: a TYPE_REF follows that number of other bytes of output; + - 255, followed by a size_t: the same for a larger number of bytes; + - 0, followed by a byte n: n more TYPE_REFs directly follow the previous + one. + This takes one byte for most TYPE_REFs, and much less when the output + mostly consists of TYPE_REFs. */ +static int +w_add_refpos(WFILE *p) +{ + size_t pos = (size_t)(p->ptr - p->buf); + size_t gap = pos - p->refpos_end; + p->refpos_end = pos + 5; + if (gap == 0 && p->refpos_run != 0 && p->refpos[p->refpos_run] < 255) { + p->refpos[p->refpos_run]++; + return 1; + } + unsigned char *refpos = w_array_grow(p->refpos, + p->refpos_size + sizeof(size_t), + &p->refpos_allocated, 1); + if (refpos == NULL) { + PyErr_NoMemory(); + return 0; + } + p->refpos = refpos; + size_t size = p->refpos_size; + if (gap == 0) { + refpos[size++] = 0; + p->refpos_run = size; + refpos[size++] = 1; + } + else { + p->refpos_run = 0; + if (gap < 255) { + refpos[size++] = (unsigned char)gap; + } + else { + refpos[size++] = 255; + memcpy(refpos + size, &gap, sizeof(gap)); + size += sizeof(gap); + } + } + p->refpos_size = size; + return 1; +} + +/* Object references (version 3+). + + The reader keeps a list of the objects whose type byte has FLAG_REF, in + the order in which they start in the stream, and TYPE_REF refers to an + object by its index in that list. + + Whether an object is flagged must only depend on the object graph being + written, not on how many other references to the object happen to exist + in the process, otherwise the output is not reproducible. So an object + is flagged if and only if it is written more than once. That is not + known when the object is seen for the first time, so: + + - on the first occurrence, w_ref() records the offset of the type byte + (the next byte to be written, see W_TYPE) in p->refs and the object is + written without FLAG_REF; + - on a later occurrence, w_ref() marks the object as shared and writes + a TYPE_REF whose argument is provisional: the index of the object in + p->refs. The position of the TYPE_REF is recorded in p->refpos; + - once everything is written, w_resolve_refs() adds FLAG_REF to the + type byte of each shared object, numbers these objects in the order + of their first occurrence and fixes up the arguments of all + TYPE_REFs. + + Return 1 if the object has been dealt with (TYPE_REF written or error), + 0 if the caller has to write it. + */ static int -w_ref(PyObject *v, char *flag, WFILE *p) +w_ref(PyObject *v, WFILE *p) { _Py_hashtable_entry_t *entry; if (p->version < 3 || p->hashtable == NULL) return 0; /* not writing object references */ - /* If it has only one reference, it definitely isn't shared. - * But we use TYPE_REF always for interned string, to PYC file stable - * as possible. + /* An object with only one reference cannot occur twice in the object + * graph, so there is no need to remember it. This is only a shortcut: + * an object occurring twice has at least two references each time it is + * seen, so it is never skipped and the output does not depend on this + * test. */ - if (_PyObject_IsUniquelyReferenced(v) && - !(PyUnicode_CheckExact(v) && PyUnicode_CHECK_INTERNED(v))) { + if (_PyObject_IsUniquelyReferenced(v)) { return 0; } @@ -399,40 +523,124 @@ w_ref(PyObject *v, char *flag, WFILE *p) if (entry != NULL) { /* write the reference index to the stream */ uintptr_t w = (uintptr_t)entry->value; - if (w & 0x80000000LU) { + if (w & W_ENTRY_ACTIVE) { PyErr_Format(PyExc_ValueError, "cannot marshal recursion %T objects", v); goto err; } - /* we don't store "long" indices in the dict */ - assert(w <= 0x7fffffff); - w_byte(TYPE_REF, p); - w_long((int)w, p); + if (w & W_ENTRY_TIED) { + /* Take the first object which is still available in the group + of interchangeable set elements, see w_tie_set_items(). */ + size_t i = p->ties[w >> W_ENTRY_SHIFT]++; + w = (uintptr_t)i << W_ENTRY_SHIFT; + } + if (!(w & W_ENTRY_SHARED)) { + entry->value = (void *)(w | W_ENTRY_SHARED); + p->refs[w >> W_ENTRY_SHIFT] |= W_REF_SHARED; + } + w >>= W_ENTRY_SHIFT; + assert(w < p->hashtable->nentries); + if (p->end - p->ptr < 5 && !w_reserve(p, 5)) { + return 1; + } + if (!w_add_refpos(p)) { + goto err; + } + *p->ptr++ = TYPE_REF; + /* The index in the reader's reference list is not known yet. + Write the index in p->refs, w_resolve_refs() will replace it. */ + w_put_uint32(p->ptr, (uint32_t)w); + p->ptr += 4; return 1; } else { size_t w = p->hashtable->nentries; /* we don't support long indices */ - if (w >= 0x7fffffff) { + if (w >= W_MAX_REFS) { PyErr_SetString(PyExc_ValueError, "too many objects"); goto err; } + size_t *refs = w_array_grow(p->refs, w, &p->refs_allocated, + sizeof(*refs)); + if (refs == NULL) { + PyErr_NoMemory(); + goto err; + } + p->refs = refs; + refs[w] = (size_t)(p->ptr - p->buf) << 1; + uintptr_t value = (uintptr_t)w << W_ENTRY_SHIFT; // Corresponding code should call w_complete() after // writing the object. - if (PyCode_Check(v) || PySlice_Check(v) || PyFrozenDict_CheckExact(v)) { - w |= 0x80000000LU; + if (PyTuple_CheckExact(v) || PyCode_Check(v) || PySlice_Check(v) || + PyFrozenDict_CheckExact(v)) + { + value |= W_ENTRY_ACTIVE; } if (_Py_hashtable_set(p->hashtable, Py_NewRef(v), - (void *)(uintptr_t)w) < 0) { + (void *)value) < 0) { Py_DECREF(v); + PyErr_NoMemory(); goto err; } - *flag |= FLAG_REF; return 0; } err: - p->error = WFERR_UNMARSHALLABLE; + p->error = true; return 1; } +/* Finish the output: flag the objects which are the target of a TYPE_REF + and replace the provisional argument of each TYPE_REF. See w_ref(). */ +static void +w_resolve_refs(WFILE *p) +{ + if (p->error || p->refpos == NULL) { + return; + } + assert(p->hashtable != NULL); + /* Replace the state of each object in p->refs with its index in the + reader's reference list (only used for the shared objects). */ + size_t nrefs = p->hashtable->nentries; + size_t *refs = p->refs; + uint32_t index = 0; + for (size_t i = 0; i < nrefs; i++) { + size_t shared = refs[i] & W_REF_SHARED; + char *type = p->buf + (refs[i] >> 1); + assert(!(*type & FLAG_REF)); + /* No branch on shared: it would not be predictable. */ + *type |= (char)(-(int)shared & FLAG_REF); + refs[i] = index; + index += (uint32_t)shared; +#ifdef Py_DEBUG + if (!shared) { + refs[i] = (size_t)-1; + } +#endif + } + const unsigned char *pos = p->refpos; + const unsigned char *end = pos + p->refpos_size; + char *ptr = p->buf; + while (pos < end) { + size_t gap = *pos++; + size_t count = 1; + if (gap == 0) { + count = *pos++; + } + else if (gap == 255) { + memcpy(&gap, pos, sizeof(gap)); + pos += sizeof(gap); + } + ptr += gap; + do { + assert(ptr + 5 <= p->ptr); + assert(*ptr == TYPE_REF); + uint32_t w = w_get_uint32(ptr + 1); + assert(w < nrefs); + assert(refs[w] < index); + w_put_uint32(ptr + 1, (uint32_t)refs[w]); + ptr += 5; + } while (--count); + } +} + static void w_complete(PyObject *v, WFILE *p) { @@ -449,27 +657,284 @@ w_complete(PyObject *v, WFILE *p) } assert(entry != NULL); uintptr_t w = (uintptr_t)entry->value; - assert(w & 0x80000000LU); - w &= ~0x80000000LU; - entry->value = (void *)(uintptr_t)w; + assert(w & W_ENTRY_ACTIVE); + w &= ~W_ENTRY_ACTIVE; + entry->value = (void *)w; } static void -w_complex_object(PyObject *v, char flag, WFILE *p); +w_complex_object(PyObject *v, WFILE *p); static void -w_object(PyObject *v, WFILE *p) +w_object(PyObject *v, WFILE *p); + +/* An element of a set which is being written. */ +typedef struct { + PyObject *value; + PyObject *dump; /* The element marshalled on its own. */ + size_t order; /* Order among the elements with the same dump. */ +} w_set_item; + +/* Order of the elements which have not been written yet (plus their index + in the set): it sorts them after the elements written before, whose order + is their index in WFILE.refs. */ +#define W_SET_ITEM_NEW ((size_t)1 << (8 * SIZEOF_SIZE_T - 1)) + +static int +w_set_item_compare(const void *left, const void *right) +{ + const w_set_item *a = (const w_set_item *)left; + const w_set_item *b = (const w_set_item *)right; + Py_ssize_t asize = PyBytes_GET_SIZE(a->dump); + Py_ssize_t bsize = PyBytes_GET_SIZE(b->dump); + int c = memcmp(PyBytes_AS_STRING(a->dump), PyBytes_AS_STRING(b->dump), + Py_MIN(asize, bsize)); + if (c != 0) { + return c; + } + if (asize != bsize) { + return asize < bsize ? -1 : 1; + } + if (a->order != b->order) { + return a->order < b->order ? -1 : 1; + } + return 0; +} + +/* The count elements of a set starting at items are floats or complex + numbers which have the same dump and have just been written, as the + objects number first to first + count - 1 in p->refs or as references to + them. Since the same bytes would have been written for these elements + in any order, it is not decided yet which element is which of these + objects. The elements which are written again later take these objects + one by one, in the order in which that happens (see w_ref()), so that the + output does not depend on the order of the elements in the set. + + The entries of these elements in p->hashtable get W_ENTRY_TIED and the + index of a new item of p->ties, which is the number of the first of + these objects that has not been taken yet. */ +static void +w_tie_set_items(w_set_item *items, Py_ssize_t count, size_t first, WFILE *p) { - char flag = '\0'; + size_t *ties = w_array_grow(p->ties, p->nties, &p->ties_allocated, + sizeof(*ties)); + if (ties == NULL) { + PyErr_NoMemory(); + p->error = true; + return; + } + p->ties = ties; + ties[p->nties] = first; + uintptr_t value = ((uintptr_t)p->nties << W_ENTRY_SHIFT) | W_ENTRY_TIED; + p->nties++; + for (Py_ssize_t i = 0; i < count; i++) { + _Py_hashtable_entry_t *entry = _Py_hashtable_get_entry( + p->hashtable, items[i].value); + if (entry == NULL) { + /* The element was removed from the set (and another one added) + by code run while a later element was dumped, so it was only + referenced by items when it was written: w_ref() has not + remembered it, and it cannot be written again. */ + continue; + } + assert(!((uintptr_t)entry->value & (W_ENTRY_ACTIVE | W_ENTRY_TIED))); + assert( + ((uintptr_t)entry->value >> W_ENTRY_SHIFT) - first < (size_t)count + ); + entry->value = (void *)value; + } +} + +/* Return true if two elements of a set have the same dump. */ +static bool +w_set_item_same_dump(const w_set_item *a, const w_set_item *b) +{ + Py_ssize_t size = PyBytes_GET_SIZE(a->dump); + return (PyBytes_GET_SIZE(b->dump) == size + && memcmp(PyBytes_AS_STRING(a->dump), + PyBytes_AS_STRING(b->dump), size) == 0); +} - if (p->error != WFERR_OK) { +/* Write the elements of a set which have the same dump: the count + elements starting at items. + + Distinct elements have the same dump if they contain NaNs which are + distinct objects. The order of these elements matters if they are also + written elsewhere in the output, since references to them or to the + objects they contain are then written. That order is made independent + of the order of the elements in the set (which depends on the addresses + of the objects) as follows: + + - the elements which have already been written before come first, in + the order in which they were written; + - floats and complex numbers which cannot be told from each other by + what has been written so far are kept interchangeable: which of them + are written again later does not change the output, see + w_tie_set_items(); + - the other ones (containers, for example tuples or frozensets of NaNs) + are written in the order of the set. This is the only case in which + the output still depends on that order, and only if these elements or + the objects they contain are also written elsewhere in the output: + the element which is written first gets the lowest reference indexes + for the objects it contains, or the first objects of the group if + these objects are interchangeable. + */ +static void +w_same_set_items(w_set_item *items, Py_ssize_t count, WFILE *p) +{ + if (p->version < 3 || p->hashtable == NULL) { + /* Not writing object references. */ + for (Py_ssize_t i = 0; i < count; i++) { + w_object(items[i].value, p); + } + return; + } + + for (Py_ssize_t i = 0; i < count; i++) { + _Py_hashtable_entry_t *entry = _Py_hashtable_get_entry( + p->hashtable, items[i].value); + if (entry == NULL) { + items[i].order = W_SET_ITEM_NEW + (size_t)i; + continue; + } + uintptr_t w = (uintptr_t)entry->value; + items[i].order = w >> W_ENTRY_SHIFT; + if (w & W_ENTRY_TIED) { + /* The first object that the element can take. It is the + same for all the elements it is interchangeable with. */ + items[i].order = p->ties[items[i].order]; + } + } + qsort(items, count, sizeof(w_set_item), w_set_item_compare); + + Py_ssize_t start = 0; + while (start < count && !p->error) { + /* Write together the interchangeable elements: floats and complex + numbers which either have not been written yet, or are already + interchangeable (they are the only elements already written + which have the same order). */ + w_set_item *item = &items[start]; + Py_ssize_t stop = start + 1; + /* The first object written or referenced below. */ + size_t first = item->order; + if (first >= W_SET_ITEM_NEW) { + first = p->hashtable->nentries; + if (PyFloat_CheckExact(item->value) + || PyComplex_CheckExact(item->value)) + { + stop = count; + } + } + else { + while (stop < count && items[stop].order == item->order) { + stop++; + } + } + for (Py_ssize_t i = start; i < stop; i++) { + w_object(items[i].value, p); + } + if (stop - start > 1 && !p->error) { + w_tie_set_items(item, stop - start, first, p); + } + start = stop; + } +} + +/* Write the n elements of a set or a frozenset. + + bpo-37596: To support reproducible builds, the elements need to be + written in a consistent order, even when they have been scrambled by hash + randomization. They are written in the order of sorted(v, + key=marshal.dumps). The elements themselves are never compared: they + may not support it. See w_same_set_items() for the elements which have + the same dump. + + Marshalling an element can run arbitrary code (an audit hook, or the + __buffer__() method of the element), which can add elements to the set + or remove some: n is not trusted to still be the size of the set. + + This function is not inlined, to keep its code and its local variables + out of w_complex_object(), which is recursive and mostly used for other + types. + */ +static Py_NO_INLINE void +w_set_items(PyObject *v, Py_ssize_t n, WFILE *p) +{ + w_set_item *items = PyMem_New(w_set_item, n ? n : 1); + if (items == NULL) { + PyErr_NoMemory(); + p->error = true; + return; + } + PyObject *value; + Py_ssize_t pos = 0; + Py_hash_t hash; + Py_ssize_t i = 0; + bool changed = false; + Py_BEGIN_CRITICAL_SECTION(v); + while (_PySet_NextEntryRef(v, &pos, &value, &hash)) { + if (i == n) { + changed = true; + Py_DECREF(value); + break; + } + PyObject *dump = _PyMarshal_WriteObjectToString(value, + p->version, p->allow_code); + if (dump == NULL) { + p->error = true; + Py_DECREF(value); + break; + } + items[i].value = value; + items[i].dump = dump; + items[i].order = (size_t)i; + i++; + } + Py_END_CRITICAL_SECTION(); + if (!p->error && (changed || i != n)) { + PyErr_SetString(PyExc_RuntimeError, + "set changed size during iteration"); + p->error = true; + } + if (!p->error) { + qsort(items, n, sizeof(w_set_item), w_set_item_compare); + Py_ssize_t start = 0; + while (start < n && !p->error) { + Py_ssize_t stop = start + 1; + while (stop < n && w_set_item_same_dump(&items[start], + &items[stop])) + { + stop++; + } + if (stop - start == 1) { + w_object(items[start].value, p); + } + else { + w_same_set_items(items + start, stop - start, p); + } + start = stop; + } + } + while (--i >= 0) { + Py_DECREF(items[i].value); + Py_DECREF(items[i].dump); + } + PyMem_Free(items); +} + +static void +w_object(PyObject *v, WFILE *p) +{ + if (p->error) { return; } p->depth++; if (p->depth > MAX_MARSHAL_STACK_DEPTH) { - p->error = WFERR_NESTEDTOODEEP; + PyErr_SetString(PyExc_ValueError, + "object too deeply nested to marshal"); + p->error = true; } else if (v == NULL) { w_byte(TYPE_NULL, p); @@ -489,14 +954,14 @@ w_object(PyObject *v, WFILE *p) else if (v == Py_True) { w_byte(TYPE_TRUE, p); } - else if (!w_ref(v, &flag, p)) - w_complex_object(v, flag, p); + else if (!w_ref(v, p)) + w_complex_object(v, p); p->depth--; } static void -w_complex_object(PyObject *v, char flag, WFILE *p) +w_complex_object(PyObject *v, WFILE *p) { Py_ssize_t i, n; @@ -504,14 +969,14 @@ w_complex_object(PyObject *v, char flag, WFILE *p) int overflow; long x = PyLong_AsLongAndOverflow(v, &overflow); if (overflow) { - w_PyLong((PyLongObject *)v, flag, p); + w_PyLong((PyLongObject *)v, p); } else { #if SIZEOF_LONG > 4 long y = Py_ARITHMETIC_RIGHT_SHIFT(long, x, 31); if (y && y != -1) { /* Too large for TYPE_INT */ - w_PyLong((PyLongObject*)v, flag, p); + w_PyLong((PyLongObject*)v, p); } else #endif @@ -572,7 +1037,7 @@ w_complex_object(PyObject *v, char flag, WFILE *p) utf8 = PyUnicode_AsEncodedString(v, "utf8", "surrogatepass"); if (utf8 == NULL) { p->depth--; - p->error = WFERR_UNMARSHALLABLE; + p->error = true; return; } if (p->version >= 3 && PyUnicode_CHECK_INTERNED(v)) @@ -596,6 +1061,7 @@ w_complex_object(PyObject *v, char flag, WFILE *p) for (i = 0; i < n; i++) { w_object(PyTuple_GET_ITEM(v, i), p); } + w_complete(v, p); } else if (PyList_CheckExact(v)) { W_TYPE(TYPE_LIST, p); @@ -611,7 +1077,10 @@ w_complex_object(PyObject *v, char flag, WFILE *p) if (PyFrozenDict_CheckExact(v)) { if (p->version < 6) { w_byte(TYPE_UNKNOWN, p); - p->error = WFERR_UNMARSHALLABLE; + PyErr_Format(PyExc_ValueError, + "marshalling %T objects requires version 6 " + "or higher", v); + p->error = true; return; } @@ -632,69 +1101,25 @@ w_complex_object(PyObject *v, char flag, WFILE *p) } } else if (PyAnySet_CheckExact(v)) { - PyObject *value; - Py_ssize_t pos = 0; - Py_hash_t hash; - if (PyFrozenSet_CheckExact(v)) W_TYPE(TYPE_FROZENSET, p); else W_TYPE(TYPE_SET, p); n = PySet_GET_SIZE(v); W_SIZE(n, p); - // bpo-37596: To support reproducible builds, sets and frozensets need - // to have their elements serialized in a consistent order (even when - // they have been scrambled by hash randomization). To ensure this, we - // use an order equivalent to sorted(v, key=marshal.dumps): - PyObject *pairs = PyList_New(n); - if (pairs == NULL) { - p->error = WFERR_NOMEMORY; - return; - } - Py_ssize_t i = 0; - Py_BEGIN_CRITICAL_SECTION(v); - while (_PySet_NextEntryRef(v, &pos, &value, &hash)) { - PyObject *dump = _PyMarshal_WriteObjectToString(value, - p->version, p->allow_code); - if (dump == NULL) { - p->error = WFERR_UNMARSHALLABLE; - Py_DECREF(value); - break; - } - PyObject *pair = _PyTuple_FromPairSteal(dump, value); - if (pair == NULL) { - p->error = WFERR_NOMEMORY; - break; - } - PyList_SET_ITEM(pairs, i++, pair); - } - Py_END_CRITICAL_SECTION(); - if (p->error == WFERR_UNMARSHALLABLE || p->error == WFERR_NOMEMORY) { - Py_DECREF(pairs); - return; - } - assert(i == n); - if (PyList_Sort(pairs)) { - p->error = WFERR_NOMEMORY; - Py_DECREF(pairs); - return; - } - for (Py_ssize_t i = 0; i < n; i++) { - PyObject *pair = PyList_GET_ITEM(pairs, i); - value = PyTuple_GET_ITEM(pair, 1); - w_object(value, p); - } - Py_DECREF(pairs); + w_set_items(v, n, p); } else if (PyCode_Check(v)) { if (!p->allow_code) { - p->error = WFERR_CODE_NOT_ALLOWED; + PyErr_SetString(PyExc_ValueError, + "marshalling code objects is disallowed"); + p->error = true; return; } PyCodeObject *co = (PyCodeObject *)v; PyObject *co_code = _PyCode_GetCode(co); if (co_code == NULL) { - p->error = WFERR_NOMEMORY; + p->error = true; return; } W_TYPE(TYPE_CODE, p); @@ -723,7 +1148,7 @@ w_complex_object(PyObject *v, char flag, WFILE *p) if (PyObject_GetBuffer(v, &view, PyBUF_SIMPLE) != 0) { w_byte(TYPE_UNKNOWN, p); p->depth--; - p->error = WFERR_UNMARSHALLABLE; + p->error = true; return; } W_TYPE(TYPE_STRING, p); @@ -733,7 +1158,10 @@ w_complex_object(PyObject *v, char flag, WFILE *p) else if (PySlice_Check(v)) { if (p->version < 5) { w_byte(TYPE_UNKNOWN, p); - p->error = WFERR_UNMARSHALLABLE; + PyErr_Format(PyExc_ValueError, + "marshalling %T objects requires version 5 " + "or higher", v); + p->error = true; return; } PySliceObject *slice = (PySliceObject *)v; @@ -745,7 +1173,8 @@ w_complex_object(PyObject *v, char flag, WFILE *p) } else { W_TYPE(TYPE_UNKNOWN, p); - p->error = WFERR_UNMARSHALLABLE; + PyErr_Format(PyExc_ValueError, "cannot marshal %T objects", v); + p->error = true; } } @@ -777,49 +1206,47 @@ w_clear_refs(WFILE *wf) if (wf->hashtable != NULL) { _Py_hashtable_destroy(wf->hashtable); } + PyMem_Free(wf->refs); + PyMem_Free(wf->refpos); + PyMem_Free(wf->ties); +} + +/* Write a buffer to a file. Set an exception on failure. */ +static void +w_fwrite(const char *buf, size_t n, FILE *fp) +{ + if (fwrite(buf, 1, n, fp) != n) { + int saved_errno = errno; + if (PyErr_CheckSignals()) { + /* The signal handler has raised an exception. */ + return; + } + errno = saved_errno; + PyErr_SetFromErrno(PyExc_OSError); + } } /* version currently has no effect for writing ints. */ -/* Note that while the documentation states that this function - * can error, currently it never does. Setting an exception in - * this function should be regarded as an API-breaking change. - */ void -PyMarshal_WriteLongToFile(long x, FILE *fp, int version) +PyMarshal_WriteLongToFile(long x, FILE *fp, int Py_UNUSED(version)) { char buf[4]; - WFILE wf; - memset(&wf, 0, sizeof(wf)); - wf.fp = fp; - wf.ptr = wf.buf = buf; - wf.end = wf.ptr + sizeof(buf); - wf.error = WFERR_OK; - wf.version = version; - w_long(x, &wf); - w_flush(&wf); + w_put_uint32(buf, (uint32_t)x); + w_fwrite(buf, sizeof(buf), fp); } void PyMarshal_WriteObjectToFile(PyObject *x, FILE *fp, int version) { - char buf[BUFSIZ]; - WFILE wf; - if (PySys_Audit("marshal.dumps", "Oi", x, version) < 0) { - return; /* caller must check PyErr_Occurred() */ - } - memset(&wf, 0, sizeof(wf)); - wf.fp = fp; - wf.ptr = wf.buf = buf; - wf.end = wf.ptr + sizeof(buf); - wf.error = WFERR_OK; - wf.version = version; - wf.allow_code = 1; - if (w_init_refs(&wf, version)) { + /* Object references are resolved once the whole object is written + (see w_ref()), so the output cannot be written to the file piece by + piece. */ + PyObject *str = _PyMarshal_WriteObjectToString(x, version, 1); + if (str == NULL) { return; /* caller must check PyErr_Occurred() */ } - w_object(x, &wf); - w_clear_refs(&wf); - w_flush(&wf); + w_fwrite(PyBytes_AS_STRING(str), (size_t)PyBytes_GET_SIZE(str), fp); + Py_DECREF(str); } typedef struct { @@ -872,6 +1299,14 @@ r_string(Py_ssize_t n, RFILE *p) if (!p->readable) { assert(p->fp != NULL); read = fread(p->buf, 1, n, p->fp); + if (read != n) { + assert(read < n); + int saved_errno = errno; + if (!PyErr_CheckSignals() && ferror(p->fp)) { + errno = saved_errno; + PyErr_SetFromErrno(PyExc_OSError); + } + } } else { PyObject *res, *mview; @@ -884,21 +1319,26 @@ r_string(Py_ssize_t n, RFILE *p) return NULL; res = _PyObject_CallMethod(p->readable, &_Py_ID(readinto), "N", mview); - if (res != NULL) { - read = PyNumber_AsSsize_t(res, PyExc_ValueError); - Py_DECREF(res); + if (res == NULL) { + return NULL; + } + read = PyNumber_AsSsize_t(res, PyExc_ValueError); + Py_DECREF(res); + if (read == -1 && PyErr_Occurred()) { + return NULL; + } + if (read > n) { + PyErr_Format(PyExc_ValueError, + "read() returned too much data: " + "%zd bytes requested, %zd returned", + n, read); + return NULL; } } if (read != n) { if (!PyErr_Occurred()) { - if (read > n) - PyErr_Format(PyExc_ValueError, - "read() returned too much data: " - "%zd bytes requested, %zd returned", - n, read); - else - PyErr_SetString(PyExc_EOFError, - "EOF read where not expected"); + PyErr_SetString(PyExc_EOFError, + "EOF read where not expected"); } return NULL; } @@ -919,6 +1359,15 @@ r_byte(RFILE *p) if (c != EOF) { return c; } + int saved_errno = errno; + if (PyErr_CheckSignals()) { + return EOF; + } + if (ferror(p->fp)) { + errno = saved_errno; + PyErr_SetFromErrno(PyExc_OSError); + return EOF; + } } else { const char *ptr = r_string(1, p); @@ -1308,16 +1757,12 @@ r_object(RFILE *p) } break; } - v = PyBytes_FromStringAndSize((char *)NULL, n); - if (v == NULL) - break; ptr = r_string(n, p); if (ptr == NULL) { - Py_DECREF(v); break; } - memcpy(PyBytes_AS_STRING(v), ptr, n); - retval = v; + // Get a singleton for 1-byte string + retval = PyBytes_FromStringAndSize(ptr, n); // can be NULL R_REF(retval); break; } @@ -1417,8 +1862,10 @@ r_object(RFILE *p) break; } _read_tuple: + idx = r_ref_reserve(flag, p); + if (idx < 0) + break; v = PyTuple_New(n); - R_REF(v); if (v == NULL) break; @@ -1433,7 +1880,7 @@ r_object(RFILE *p) } PyTuple_SET_ITEM(v, i, v2); } - retval = v; + retval = r_ref_insert(v, idx, flag, p); break; case TYPE_LIST: @@ -1471,6 +1918,9 @@ r_object(RFILE *p) } if (type == TYPE_DICT) { R_REF(v); + if (v == NULL) { + break; + } } else { idx = r_ref_reserve(flag, p); @@ -1501,7 +1951,8 @@ r_object(RFILE *p) Py_CLEAR(v); } if (type == TYPE_FROZENDICT && v != NULL) { - Py_SETREF(v, PyFrozenDict_New(v)); + Py_SETREF(v, PyDict_AsFrozenDictAndClear(v)); + v = r_ref_insert(v, idx, flag, p); } retval = v; break; @@ -1841,8 +2292,18 @@ PyMarshal_ReadLastObjectFromFile(FILE *fp) if (filesize > 0 && filesize <= REASONABLE_FILE_LIMIT) { char* pBuf = (char *)PyMem_Malloc(filesize); if (pBuf != NULL) { + PyObject *v = NULL; size_t n = fread(pBuf, 1, (size_t)filesize, fp); - PyObject* v = PyMarshal_ReadObjectFromString(pBuf, n); + int saved_errno = errno; + if (!PyErr_CheckSignals()) { + if (ferror(fp)) { + errno = saved_errno; + PyErr_SetFromErrno(PyExc_OSError); + } + else { + v = PyMarshal_ReadObjectFromString(pBuf, n); + } + } PyMem_Free(pBuf); return v; } @@ -1913,7 +2374,7 @@ _PyMarshal_WriteObjectToString(PyObject *x, int version, int allow_code) return NULL; wf.ptr = wf.buf = PyBytes_AS_STRING(wf.str); wf.end = wf.ptr + PyBytes_GET_SIZE(wf.str); - wf.error = WFERR_OK; + wf.error = false; wf.version = version; wf.allow_code = allow_code; if (w_init_refs(&wf, version)) { @@ -1921,32 +2382,16 @@ _PyMarshal_WriteObjectToString(PyObject *x, int version, int allow_code) return NULL; } w_object(x, &wf); + w_resolve_refs(&wf); w_clear_refs(&wf); if (wf.str != NULL) { const char *base = PyBytes_AS_STRING(wf.str); if (_PyBytes_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base)) < 0) return NULL; } - if (wf.error != WFERR_OK) { + if (wf.error) { + assert(PyErr_Occurred()); Py_XDECREF(wf.str); - switch (wf.error) { - case WFERR_NOMEMORY: - PyErr_NoMemory(); - break; - case WFERR_NESTEDTOODEEP: - PyErr_SetString(PyExc_ValueError, - "object too deeply nested to marshal"); - break; - case WFERR_CODE_NOT_ALLOWED: - PyErr_SetString(PyExc_ValueError, - "marshalling code objects is disallowed"); - break; - default: - case WFERR_UNMARSHALLABLE: - PyErr_SetString(PyExc_ValueError, - "unmarshallable object"); - break; - } return NULL; } return wf.str; diff --git a/Python/modsupport.c b/Python/modsupport.c index bab21d1b2be5b51..f944b1c05ba9889 100644 --- a/Python/modsupport.c +++ b/Python/modsupport.c @@ -767,7 +767,7 @@ int PyABIInfo_Check(PyABIInfo *info, const char *module_name) /* Free-threading/GIL */ uint16_t gilflags = info->flags & (PyABIInfo_GIL | PyABIInfo_FREETHREADED); -#if Py_GIL_DISABLED +#ifdef Py_GIL_DISABLED if (gilflags == PyABIInfo_GIL) { return _abiinfo_raise(module_name, "incompatible with free-threaded CPython"); diff --git a/Python/mystrtoul.c b/Python/mystrtoul.c index fcd3e27f17f4e92..06802dffdc5410e 100644 --- a/Python/mystrtoul.c +++ b/Python/mystrtoul.c @@ -8,10 +8,6 @@ #include "Python.h" #include "pycore_long.h" // _PyLong_DigitValue -#if defined(__sgi) && !defined(_SGI_MP_SOURCE) -# define _SGI_MP_SOURCE -#endif - /* strtol and strtoul, renamed to avoid conflicts */ diff --git a/Python/optimizer.c b/Python/optimizer.c index c9f6ebdb62f07b2..e05adb344c8d06d 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -1797,6 +1797,11 @@ make_cold_executor(uint16_t opcode) Py_FatalError("Cannot allocate core JIT code"); } ((_PyUOpInstruction *)cold->trace)->opcode = opcode; + // Cold executors bypass _Py_ExecutorInit(). + cold->vm_data.valid = true; + cold->vm_data.pending_deletion = 0; + cold->vm_data.code = NULL; + // This is initialized to false so we can prevent the executor // from being immediately detected as cold and invalidated. cold->vm_data.cold = false; @@ -1804,7 +1809,7 @@ make_cold_executor(uint16_t opcode) cold->jit_code = NULL; cold->jit_size = 0; if (_PyJIT_Compile(cold, cold->trace, 1)) { - Py_DECREF(cold); + _PyExecutor_Free(cold); Py_FatalError("Cannot allocate core JIT code"); } #endif diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c index e726dc0e6fd1114..9b70874b35a009e 100644 --- a/Python/optimizer_analysis.c +++ b/Python/optimizer_analysis.c @@ -13,6 +13,7 @@ * */ #include "Python.h" #include "opcode.h" +#include "pycore_call.h" // _Py_METH_CALL_FLAGS #include "pycore_dict.h" #include "pycore_interp.h" #include "pycore_opcode_metadata.h" diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c index edb4c644bccbf6f..6648b72e66e281d 100644 --- a/Python/optimizer_bytecodes.c +++ b/Python/optimizer_bytecodes.c @@ -1,4 +1,5 @@ #include "Python.h" +#include "pycore_call.h" // _Py_METH_CALL_FLAGS #include "pycore_long.h" #include "pycore_opcode_utils.h" #include "pycore_optimizer.h" @@ -217,6 +218,13 @@ dummy_func(void) { } } + op(_GUARD_TOS_EXACT_INT, (value -- value)) { + if (sym_matches_type(value, &PyLong_Type)) { + ADD_OP(_NOP, 0, 0); + } + sym_set_type(value, &PyLong_Type); + } + op(_GUARD_NOS_INT, (left, unused -- left, unused)) { if (sym_is_compact_int(left)) { ADD_OP(_NOP, 0, 0); @@ -1465,7 +1473,7 @@ dummy_func(void) { sym_set_type(iter, type); assert((this_instr - 1)->opcode == _RECORD_NOS_TYPE); int32_t orig_target = (this_instr - 1)->target; - ADD_OP(_GUARD_TYPE_ITER, 0, (uintptr_t)type); + ADD_OP(_GUARD_NOS_TYPE, 0, (uintptr_t)type); uop_buffer_last(&ctx->out_buffer)->target = orig_target; } ADD_OP(_ITER_NEXT_INLINE, 0, (uintptr_t)type->tp_iternext); @@ -1704,7 +1712,9 @@ dummy_func(void) { if (sym_is_not_null(self_or_null)) { total_args++; } - if (total_args == 1 && PyCFunction_GET_FLAGS(callable_o) == METH_O) { + if (total_args == 1 && + (PyCFunction_GET_FLAGS(callable_o) & + _Py_METH_CALL_FLAGS) == METH_O) { ADD_OP(_NOP, 0, 0); } } @@ -1716,7 +1726,8 @@ dummy_func(void) { op(_GUARD_CALLABLE_BUILTIN_FAST, (callable, unused, unused[oparg] -- callable, unused, unused[oparg])) { PyObject *callable_o = sym_get_const(ctx, callable); if (callable_o && sym_matches_type(callable, &PyCFunction_Type)) { - if (PyCFunction_GET_FLAGS(callable_o) == METH_FASTCALL) { + if ((PyCFunction_GET_FLAGS(callable_o) & _Py_METH_CALL_FLAGS) == + METH_FASTCALL) { ADD_OP(_NOP, 0, 0); } } @@ -1728,7 +1739,8 @@ dummy_func(void) { op(_GUARD_CALLABLE_BUILTIN_FAST_WITH_KEYWORDS, (callable, unused, unused[oparg] -- callable, unused, unused[oparg])) { PyObject *callable_o = sym_get_const(ctx, callable); if (callable_o && sym_matches_type(callable, &PyCFunction_Type)) { - if (PyCFunction_GET_FLAGS(callable_o) == (METH_FASTCALL | METH_KEYWORDS)) { + if ((PyCFunction_GET_FLAGS(callable_o) & _Py_METH_CALL_FLAGS) == + (METH_FASTCALL | METH_KEYWORDS)) { ADD_OP(_NOP, 0, 0); } } @@ -1779,9 +1791,10 @@ dummy_func(void) { else { self_type = sym_get_type(args[0]); } - PyTypeObject *d_type = ((PyMethodDescrObject *)callable_o)->d_common.d_type; + PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o; + PyTypeObject *d_type = method->d_common.d_type; if (total_args == 2 && - ((PyMethodDescrObject *)callable_o)->d_method->ml_flags == METH_O && + (method->d_method->ml_flags & _Py_METH_CALL_FLAGS) == METH_O && self_type == d_type) { ADD_OP(_NOP, 0, 0); } @@ -1806,9 +1819,11 @@ dummy_func(void) { else { self_type = sym_get_type(args[0]); } - PyTypeObject *d_type = ((PyMethodDescrObject *)callable_o)->d_common.d_type; + PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o; + PyTypeObject *d_type = method->d_common.d_type; if (total_args != 0 && - ((PyMethodDescrObject *)callable_o)->d_method->ml_flags == (METH_FASTCALL|METH_KEYWORDS) && + (method->d_method->ml_flags & _Py_METH_CALL_FLAGS) == + (METH_FASTCALL | METH_KEYWORDS) && self_type == d_type) { ADD_OP(_NOP, 0, 0); } @@ -1833,9 +1848,11 @@ dummy_func(void) { else { self_type = sym_get_type(args[0]); } - PyTypeObject *d_type = ((PyMethodDescrObject *)callable_o)->d_common.d_type; + PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o; + PyTypeObject *d_type = method->d_common.d_type; if (total_args == 1 && - ((PyMethodDescrObject *)callable_o)->d_method->ml_flags == METH_NOARGS && + (method->d_method->ml_flags & _Py_METH_CALL_FLAGS) == + METH_NOARGS && self_type == d_type) { ADD_OP(_NOP, 0, 0); } @@ -1911,9 +1928,11 @@ dummy_func(void) { else { self_type = sym_get_type(args[0]); } - PyTypeObject *d_type = ((PyMethodDescrObject *)callable_o)->d_common.d_type; + PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o; + PyTypeObject *d_type = method->d_common.d_type; if (total_args != 0 && - ((PyMethodDescrObject *)callable_o)->d_method->ml_flags == METH_FASTCALL && + (method->d_method->ml_flags & _Py_METH_CALL_FLAGS) == + METH_FASTCALL && self_type == d_type) { ADD_OP(_NOP, 0, 0); } @@ -2209,7 +2228,7 @@ dummy_func(void) { ADD_OP(_NOP, 0, 0); } else { - ADD_OP(_GUARD_TYPE, 0, (uintptr_t)tp); + ADD_OP(_GUARD_NOS_TYPE, 0, (uintptr_t)tp); sym_set_type(nos, tp); } PyType_Watch(TYPE_WATCHER_ID, (PyObject *)tp); @@ -2230,7 +2249,7 @@ dummy_func(void) { ADD_OP(_NOP, 0, 0); } else { - ADD_OP(_GUARD_TYPE, 0, (uintptr_t)tp); + ADD_OP(_GUARD_NOS_TYPE, 0, (uintptr_t)tp); sym_set_type(nos, tp); } PyType_Watch(TYPE_WATCHER_ID, (PyObject *)tp); @@ -2512,13 +2531,24 @@ dummy_func(void) { else if (interp->rare_events.builtin_dict >= _Py_MAX_ALLOWED_BUILTINS_MODIFICATIONS) { /* Do nothing */ } + else if (ctx->frame->func == NULL || + ctx->frame->func->func_builtins != builtins) { + /* Do nothing */ + } else { if (!ctx->builtins_watched) { PyDict_Watch(BUILTINS_WATCHER_ID, builtins); ctx->builtins_watched = true; } - if (ctx->frame->globals_checked_version != 0 && ctx->frame->globals_watched) { + if (ctx->frame->globals_checked_version != 0 && + ctx->frame->globals_watched) + { cnst = convert_global_to_const(this_instr, builtins); + if (cnst != NULL && !ctx->frame->builtins_checked) { + ctx->frame->builtins_checked = true; + ADD_OP(_GUARD_BUILTINS_IS_CANONICAL, 0, 0); + ADD_OP(this_instr->opcode, 0, (uintptr_t)cnst); + } } } if (cnst == NULL) { @@ -2733,13 +2763,21 @@ dummy_func(void) { } } - op(_GET_ANEXT, (aiter -- aiter, awaitable)) { + op(_GET_ANEXT, (aiter -- aiter, awaitable, null, none)) { if (sym_matches_type(aiter, &PyAsyncGen_Type)) { awaitable = sym_new_type(ctx, &_PyAsyncGenASend_Type); } else { awaitable = sym_new_not_null(ctx); } + null = PyJitRef_Borrow(sym_new_null(ctx)); + none = PyJitRef_Borrow(sym_new_const(ctx, Py_None)); + } + + op(_GET_AWAITABLE, (iterable -- iter, null, none)) { + iter = sym_new_not_null(ctx); + null = PyJitRef_Borrow(sym_new_null(ctx)); + none = PyJitRef_Borrow(sym_new_const(ctx, Py_None)); } // END BYTECODES // diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h index 5e110360b81b445..c86121fcfc0e79a 100644 --- a/Python/optimizer_cases.c.h +++ b/Python/optimizer_cases.c.h @@ -581,6 +581,16 @@ break; } + case _GUARD_TOS_EXACT_INT: { + JitOptRef value; + value = stack_pointer[-1]; + if (sym_matches_type(value, &PyLong_Type)) { + ADD_OP(_NOP, 0, 0); + } + sym_set_type(value, &PyLong_Type); + break; + } + case _GUARD_NOS_OVERFLOWED: { break; } @@ -1490,7 +1500,7 @@ ADD_OP(_NOP, 0, 0); } else { - ADD_OP(_GUARD_TYPE, 0, (uintptr_t)tp); + ADD_OP(_GUARD_NOS_TYPE, 0, (uintptr_t)tp); sym_set_type(nos, tp); } PyType_Watch(TYPE_WATCHER_ID, (PyObject *)tp); @@ -1514,7 +1524,7 @@ ADD_OP(_NOP, 0, 0); } else { - ADD_OP(_GUARD_TYPE, 0, (uintptr_t)tp); + ADD_OP(_GUARD_NOS_TYPE, 0, (uintptr_t)tp); sym_set_type(nos, tp); } PyType_Watch(TYPE_WATCHER_ID, (PyObject *)tp); @@ -1862,6 +1872,8 @@ case _GET_ANEXT: { JitOptRef aiter; JitOptRef awaitable; + JitOptRef null; + JitOptRef none; aiter = stack_pointer[-1]; if (sym_matches_type(aiter, &PyAsyncGen_Type)) { awaitable = sym_new_type(ctx, &_PyAsyncGenASend_Type); @@ -1869,17 +1881,30 @@ else { awaitable = sym_new_not_null(ctx); } - CHECK_STACK_BOUNDS(1); + null = PyJitRef_Borrow(sym_new_null(ctx)); + none = PyJitRef_Borrow(sym_new_const(ctx, Py_None)); + CHECK_STACK_BOUNDS(3); stack_pointer[0] = awaitable; - stack_pointer += 1; + stack_pointer[1] = null; + stack_pointer[2] = none; + stack_pointer += 3; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); break; } case _GET_AWAITABLE: { JitOptRef iter; + JitOptRef null; + JitOptRef none; iter = sym_new_not_null(ctx); + null = PyJitRef_Borrow(sym_new_null(ctx)); + none = PyJitRef_Borrow(sym_new_const(ctx, Py_None)); + CHECK_STACK_BOUNDS(2); stack_pointer[-1] = iter; + stack_pointer[0] = null; + stack_pointer[1] = none; + stack_pointer += 2; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); break; } @@ -2166,7 +2191,12 @@ break; } - /* _LOAD_FROM_DICT_OR_GLOBALS is not a viable micro-op for tier 2 */ + case _LOAD_FROM_DICT_OR_GLOBALS: { + JitOptRef v; + v = sym_new_not_null(ctx); + stack_pointer[-1] = v; + break; + } case _LOAD_NAME: { JitOptRef v; @@ -2291,13 +2321,23 @@ } else if (interp->rare_events.builtin_dict >= _Py_MAX_ALLOWED_BUILTINS_MODIFICATIONS) { } + else if (ctx->frame->func == NULL || + ctx->frame->func->func_builtins != builtins) { + } else { if (!ctx->builtins_watched) { PyDict_Watch(BUILTINS_WATCHER_ID, builtins); ctx->builtins_watched = true; } - if (ctx->frame->globals_checked_version != 0 && ctx->frame->globals_watched) { + if (ctx->frame->globals_checked_version != 0 && + ctx->frame->globals_watched) + { cnst = convert_global_to_const(this_instr, builtins); + if (cnst != NULL && !ctx->frame->builtins_checked) { + ctx->frame->builtins_checked = true; + ADD_OP(_GUARD_BUILTINS_IS_CANONICAL, 0, 0); + ADD_OP(this_instr->opcode, 0, (uintptr_t)cnst); + } } } if (cnst == NULL) { @@ -2318,6 +2358,10 @@ break; } + case _GUARD_BUILTINS_IS_CANONICAL: { + break; + } + case _DELETE_FAST: { break; } @@ -3695,7 +3739,7 @@ sym_set_type(iter, type); assert((this_instr - 1)->opcode == _RECORD_NOS_TYPE); int32_t orig_target = (this_instr - 1)->target; - ADD_OP(_GUARD_TYPE_ITER, 0, (uintptr_t)type); + ADD_OP(_GUARD_NOS_TYPE, 0, (uintptr_t)type); uop_buffer_last(&ctx->out_buffer)->target = orig_target; } ADD_OP(_ITER_NEXT_INLINE, 0, (uintptr_t)type->tp_iternext); @@ -3708,7 +3752,7 @@ break; } - case _GUARD_TYPE_ITER: { + case _GUARD_NOS_TYPE: { break; } @@ -4490,7 +4534,9 @@ if (sym_is_not_null(self_or_null)) { total_args++; } - if (total_args == 1 && PyCFunction_GET_FLAGS(callable_o) == METH_O) { + if (total_args == 1 && + (PyCFunction_GET_FLAGS(callable_o) & + _Py_METH_CALL_FLAGS) == METH_O) { ADD_OP(_NOP, 0, 0); } } @@ -4536,7 +4582,8 @@ callable = stack_pointer[-2 - oparg]; PyObject *callable_o = sym_get_const(ctx, callable); if (callable_o && sym_matches_type(callable, &PyCFunction_Type)) { - if (PyCFunction_GET_FLAGS(callable_o) == METH_FASTCALL) { + if ((PyCFunction_GET_FLAGS(callable_o) & _Py_METH_CALL_FLAGS) == + METH_FASTCALL) { ADD_OP(_NOP, 0, 0); } } @@ -4559,7 +4606,8 @@ callable = stack_pointer[-2 - oparg]; PyObject *callable_o = sym_get_const(ctx, callable); if (callable_o && sym_matches_type(callable, &PyCFunction_Type)) { - if (PyCFunction_GET_FLAGS(callable_o) == (METH_FASTCALL | METH_KEYWORDS)) { + if ((PyCFunction_GET_FLAGS(callable_o) & _Py_METH_CALL_FLAGS) == + (METH_FASTCALL | METH_KEYWORDS)) { ADD_OP(_NOP, 0, 0); } } @@ -4745,9 +4793,10 @@ else { self_type = sym_get_type(args[0]); } - PyTypeObject *d_type = ((PyMethodDescrObject *)callable_o)->d_common.d_type; + PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o; + PyTypeObject *d_type = method->d_common.d_type; if (total_args == 2 && - ((PyMethodDescrObject *)callable_o)->d_method->ml_flags == METH_O && + (method->d_method->ml_flags & _Py_METH_CALL_FLAGS) == METH_O && self_type == d_type) { ADD_OP(_NOP, 0, 0); } @@ -4845,9 +4894,11 @@ else { self_type = sym_get_type(args[0]); } - PyTypeObject *d_type = ((PyMethodDescrObject *)callable_o)->d_common.d_type; + PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o; + PyTypeObject *d_type = method->d_common.d_type; if (total_args != 0 && - ((PyMethodDescrObject *)callable_o)->d_method->ml_flags == (METH_FASTCALL|METH_KEYWORDS) && + (method->d_method->ml_flags & _Py_METH_CALL_FLAGS) == + (METH_FASTCALL | METH_KEYWORDS) && self_type == d_type) { ADD_OP(_NOP, 0, 0); } @@ -4900,9 +4951,11 @@ else { self_type = sym_get_type(args[0]); } - PyTypeObject *d_type = ((PyMethodDescrObject *)callable_o)->d_common.d_type; + PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o; + PyTypeObject *d_type = method->d_common.d_type; if (total_args == 1 && - ((PyMethodDescrObject *)callable_o)->d_method->ml_flags == METH_NOARGS && + (method->d_method->ml_flags & _Py_METH_CALL_FLAGS) == + METH_NOARGS && self_type == d_type) { ADD_OP(_NOP, 0, 0); } @@ -4988,9 +5041,11 @@ else { self_type = sym_get_type(args[0]); } - PyTypeObject *d_type = ((PyMethodDescrObject *)callable_o)->d_common.d_type; + PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o; + PyTypeObject *d_type = method->d_common.d_type; if (total_args != 0 && - ((PyMethodDescrObject *)callable_o)->d_method->ml_flags == METH_FASTCALL && + (method->d_method->ml_flags & _Py_METH_CALL_FLAGS) == + METH_FASTCALL && self_type == d_type) { ADD_OP(_NOP, 0, 0); } diff --git a/Python/optimizer_symbols.c b/Python/optimizer_symbols.c index 79f81482d247e37..eaa4c8dbbdc5de1 100644 --- a/Python/optimizer_symbols.c +++ b/Python/optimizer_symbols.c @@ -1378,6 +1378,7 @@ _Py_uop_frame_new( frame->stack_pointer = frame->stack; frame->globals_checked_version = 0; frame->globals_watched = false; + frame->builtins_checked = false; frame->func = NULL; frame->caller = false; frame->is_c_recursion_checked = false; @@ -1388,17 +1389,27 @@ _Py_uop_frame_new( } // Initialize with the initial state of all local variables + arg_len = Py_MIN(arg_len, co->co_argcount); for (int i = 0; i < arg_len; i++) { frame->locals[i] = PyJitRef_RemoveUnique(args[i]); } - // If the args are known, then it's safe to just initialize - // every other non-set local to null symbol. - bool default_null = args != NULL; + // When args is available, missing parameters get defaults or *args/**kwargs. + // Other locals start as NULL. When args is NULL, treat all locals as unknown. + int parameter_count = co->co_argcount + co->co_kwonlyargcount; + parameter_count += (co->co_flags & CO_VARARGS) != 0; + parameter_count += (co->co_flags & CO_VARKEYWORDS) != 0; for (int i = arg_len; i < co->co_nlocalsplus; i++) { - JitOptRef local = default_null ? _Py_uop_sym_new_null(ctx) : _Py_uop_sym_new_unknown(ctx); - frame->locals[i] = local; + if (args == NULL) { + frame->locals[i] = _Py_uop_sym_new_unknown(ctx); + } + else if (i < parameter_count) { + frame->locals[i] = _Py_uop_sym_new_not_null(ctx); + } + else { + frame->locals[i] = _Py_uop_sym_new_null(ctx); + } } frame->callable = _Py_uop_sym_new_not_null(ctx); diff --git a/Python/parking_lot.c b/Python/parking_lot.c index 8823d77719cb9a2..8431b9bb24ec445 100644 --- a/Python/parking_lot.c +++ b/Python/parking_lot.c @@ -10,6 +10,18 @@ #include +#if defined(_Py_USE_SEMAPHORES) && defined(CLOCK_MONOTONIC) && !defined(_Py_THREAD_SANITIZER) +# ifdef HAVE_SEM_CLOCKWAIT +# define _Py_SEM_CLOCKWAIT_AVAILABLE 1 +# elif defined(__linux__) && (defined(__GNUC__) || defined(__clang__)) +/* Older glibc headers do not declare sem_clockwait. A weak reference allows + such builds to use monotonic waits on newer runtimes. */ +extern int sem_clockwait(sem_t *, clockid_t, const struct timespec *) + __attribute__((weak)); +# define _Py_SEM_CLOCKWAIT_AVAILABLE (sem_clockwait != NULL) +# endif +#endif + typedef struct { // The mutex protects the waiter queue and the num_waiters counter. @@ -151,24 +163,27 @@ _PySemaphore_Wait(_PySemaphore *sema, PyTime_t timeout) if (timeout >= 0) { struct timespec ts; -#if defined(CLOCK_MONOTONIC) && defined(HAVE_SEM_CLOCKWAIT) && !defined(_Py_THREAD_SANITIZER) - PyTime_t now; - // silently ignore error: cannot report error to the caller - (void)PyTime_MonotonicRaw(&now); - PyTime_t deadline = _PyTime_Add(now, timeout); - _PyTime_AsTimespec_clamp(deadline, &ts); - - err = sem_clockwait(&sema->platform_sem, CLOCK_MONOTONIC, &ts); -#else - PyTime_t now; - // silently ignore error: cannot report error to the caller - (void)PyTime_TimeRaw(&now); - PyTime_t deadline = _PyTime_Add(now, timeout); - - _PyTime_AsTimespec_clamp(deadline, &ts); +#ifdef _Py_SEM_CLOCKWAIT_AVAILABLE + if (_Py_SEM_CLOCKWAIT_AVAILABLE) { + PyTime_t now; + // Silently ignore error: cannot report error to the caller. + (void)PyTime_MonotonicRaw(&now); + PyTime_t deadline = _PyTime_Add(now, timeout); + _PyTime_AsTimespec_clamp(deadline, &ts); - err = sem_timedwait(&sema->platform_sem, &ts); + err = sem_clockwait(&sema->platform_sem, CLOCK_MONOTONIC, &ts); + } + else #endif + { + PyTime_t now; + // Silently ignore error: cannot report error to the caller. + (void)PyTime_TimeRaw(&now); + PyTime_t deadline = _PyTime_Add(now, timeout); + _PyTime_AsTimespec_clamp(deadline, &ts); + + err = sem_timedwait(&sema->platform_sem, &ts); + } } else { err = sem_wait(&sema->platform_sem); diff --git a/Python/pathconfig.c b/Python/pathconfig.c index d034562c43f23c3..89684d9da8e6291 100644 --- a/Python/pathconfig.c +++ b/Python/pathconfig.c @@ -236,7 +236,8 @@ Py_SetPath(const wchar_t *path) } -void +// Function removed from Python 3.16 limited C API, but kept in the stable ABI +PyAPI_FUNC(void) Py_SetPythonHome(const wchar_t *home) { int has_value = home && home[0]; @@ -254,7 +255,8 @@ Py_SetPythonHome(const wchar_t *home) } -void +// Function removed from Python 3.16 limited C API, but kept in the stable ABI +PyAPI_FUNC(void) Py_SetProgramName(const wchar_t *program_name) { int has_value = program_name && program_name[0]; @@ -338,7 +340,7 @@ Py_GetProgramName(void) /* Compute module search path from argv[0] or the current working - directory ("-m module" case) which will be prepended to sys.argv: + directory ("-m module" case) which will be prepended to sys.path: sys.path[0]. Return 1 if the path is correctly resolved and written into *path0_p. diff --git a/Python/perf_jit_trampoline.c b/Python/perf_jit_trampoline.c index 32b147199544cfc..da6a7e69633db52 100644 --- a/Python/perf_jit_trampoline.c +++ b/Python/perf_jit_trampoline.c @@ -672,6 +672,8 @@ static void perf_map_jit_write_entry_with_name( uint64_t thread_id = 0; pthread_threadid_np(NULL, &thread_id); ev.thread_id = (uint32_t)thread_id; +#elif defined(_Py_HAVE_GETTID) + ev.thread_id = gettid(); #else ev.thread_id = syscall(SYS_gettid); // Get thread ID via system call #endif @@ -749,9 +751,15 @@ static void perf_map_jit_write_entry(void *state, const void *code_addr, if (co != NULL) { if (co->co_qualname != NULL) { entry = PyUnicode_AsUTF8(co->co_qualname); + if (entry == NULL) { + PyErr_Clear(); + } } if (co->co_filename != NULL) { filename = PyUnicode_AsUTF8(co->co_filename); + if (filename == NULL) { + PyErr_Clear(); + } } } perf_map_jit_write_entry_with_name(state, code_addr, code_size, diff --git a/Python/perf_trampoline.c b/Python/perf_trampoline.c index d90b789c2b57126..5e6f3b213eb81fa 100644 --- a/Python/perf_trampoline.c +++ b/Python/perf_trampoline.c @@ -254,10 +254,18 @@ perf_map_write_entry(void *state, const void *code_addr, const char *entry = ""; if (co->co_qualname != NULL) { entry = PyUnicode_AsUTF8(co->co_qualname); + if (entry == NULL) { + PyErr_Clear(); + entry = ""; + } } const char *filename = ""; if (co->co_filename != NULL) { filename = PyUnicode_AsUTF8(co->co_filename); + if (filename == NULL) { + PyErr_Clear(); + filename = ""; + } } size_t perf_map_entry_size = snprintf(NULL, 0, "py::%s:%s", entry, filename) + 1; char* perf_map_entry = (char*) PyMem_RawMalloc(perf_map_entry_size); @@ -426,7 +434,8 @@ compile_trampoline(void) return code_arena_new_code(perf_code_arena); } -static PyObject * +// gh-161288: the trampoline has no -fsanitize=function type signature +static PyObject * _Py_NO_SANITIZE_FUNCTION py_trampoline_evaluator(PyThreadState *ts, _PyInterpreterFrame *frame, int throw) { diff --git a/Python/preconfig.c b/Python/preconfig.c index 2c8c18284c1d2db..c8005ccdce1a73e 100644 --- a/Python/preconfig.c +++ b/Python/preconfig.c @@ -13,10 +13,18 @@ /* Forward declarations */ static void preconfig_copy(PyPreConfig *config, const PyPreConfig *config2); +extern int Py_UTF8Mode; /* --- File system encoding/errors -------------------------------- */ +// Variables removed from Python limited C API 3.16, but kept in the stable ABI +PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding; +PyAPI_DATA(const char *) Py_FileSystemDefaultEncodeErrors; +PyAPI_DATA(int) Py_HasFileSystemDefaultEncoding; + +// The default encoding used by the platform file system APIs. +// If non-NULL, this is different than the default encoding for strings. const char *Py_FileSystemDefaultEncoding = NULL; int Py_HasFileSystemDefaultEncoding = 0; const char *Py_FileSystemDefaultEncodeErrors = NULL; @@ -25,8 +33,6 @@ int _Py_HasFileSystemDefaultEncodeErrors = 0; void _Py_ClearFileSystemEncoding(void) { -_Py_COMP_DIAG_PUSH -_Py_COMP_DIAG_IGNORE_DEPR_DECLS if (!Py_HasFileSystemDefaultEncoding && Py_FileSystemDefaultEncoding) { PyMem_RawFree((char*)Py_FileSystemDefaultEncoding); Py_FileSystemDefaultEncoding = NULL; @@ -35,7 +41,6 @@ _Py_COMP_DIAG_IGNORE_DEPR_DECLS PyMem_RawFree((char*)Py_FileSystemDefaultEncodeErrors); Py_FileSystemDefaultEncodeErrors = NULL; } -_Py_COMP_DIAG_POP } @@ -60,14 +65,11 @@ _Py_SetFileSystemEncoding(const char *encoding, const char *errors) _Py_ClearFileSystemEncoding(); -_Py_COMP_DIAG_PUSH -_Py_COMP_DIAG_IGNORE_DEPR_DECLS Py_FileSystemDefaultEncoding = encoding2; Py_HasFileSystemDefaultEncoding = 0; Py_FileSystemDefaultEncodeErrors = errors2; _Py_HasFileSystemDefaultEncodeErrors = 0; -_Py_COMP_DIAG_POP return 0; } @@ -185,15 +187,14 @@ precmdline_parse_cmdline(_PyPreCmdline *cmdline) { const PyWideStringList *argv = &cmdline->argv; - _PyOS_ResetGetOpt(); + struct _PyOS_GetOpt getopt; + _PyOS_GetOpt_Init(&getopt, argv->length, argv->items); /* Don't log parsing errors into stderr here: PyConfig_Read() is responsible for that */ - _PyOS_opterr = 0; + getopt.error = 0; do { - int longindex = -1; - int c = _PyOS_GetOpt(argv->length, argv->items, &longindex); - - if (c == EOF || c == 'c' || c == 'm') { + int c = _PyOS_GetOpt(&getopt); + if (c == -1 || c == 'c' || c == 'm') { break; } @@ -209,7 +210,7 @@ precmdline_parse_cmdline(_PyPreCmdline *cmdline) case 'X': { PyStatus status = PyWideStringList_Append(&cmdline->xoptions, - _PyOS_optarg); + getopt.arg); if (_PyStatus_EXCEPTION(status)) { return status; } @@ -463,63 +464,25 @@ _PyPreConfig_GetConfig(PyPreConfig *preconfig, const PyConfig *config) static void -preconfig_get_global_vars(PyPreConfig *config) +preconfig_get_global_var(PyPreConfig *config) { if (config->_config_init != _PyConfig_INIT_COMPAT) { /* Python and Isolated configuration ignore global variables */ return; } -#define COPY_FLAG(ATTR, VALUE) \ - if (config->ATTR < 0) { \ - config->ATTR = VALUE; \ - } -#define COPY_NOT_FLAG(ATTR, VALUE) \ - if (config->ATTR < 0) { \ - config->ATTR = !(VALUE); \ - } - -_Py_COMP_DIAG_PUSH -_Py_COMP_DIAG_IGNORE_DEPR_DECLS - COPY_FLAG(isolated, Py_IsolatedFlag); - COPY_NOT_FLAG(use_environment, Py_IgnoreEnvironmentFlag); if (Py_UTF8Mode > 0) { config->utf8_mode = Py_UTF8Mode; } -#ifdef MS_WINDOWS - COPY_FLAG(legacy_windows_fs_encoding, Py_LegacyWindowsFSEncodingFlag); -#endif -_Py_COMP_DIAG_POP - -#undef COPY_FLAG -#undef COPY_NOT_FLAG } static void -preconfig_set_global_vars(const PyPreConfig *config) +preconfig_set_global_var(const PyPreConfig *config) { -#define COPY_FLAG(ATTR, VAR) \ - if (config->ATTR >= 0) { \ - VAR = config->ATTR; \ - } -#define COPY_NOT_FLAG(ATTR, VAR) \ - if (config->ATTR >= 0) { \ - VAR = !config->ATTR; \ + if (config->utf8_mode >= 0) { + Py_UTF8Mode = config->utf8_mode; } - -_Py_COMP_DIAG_PUSH -_Py_COMP_DIAG_IGNORE_DEPR_DECLS - COPY_FLAG(isolated, Py_IsolatedFlag); - COPY_NOT_FLAG(use_environment, Py_IgnoreEnvironmentFlag); -#ifdef MS_WINDOWS - COPY_FLAG(legacy_windows_fs_encoding, Py_LegacyWindowsFSEncodingFlag); -#endif - COPY_FLAG(utf8_mode, Py_UTF8Mode); -_Py_COMP_DIAG_POP - -#undef COPY_FLAG -#undef COPY_NOT_FLAG } @@ -776,7 +739,7 @@ preconfig_read(PyPreConfig *config, _PyPreCmdline *cmdline) - command line arguments - environment variables - - Py_xxx global configuration variables + - Py_UTF8Mode global configuration variable - the LC_CTYPE locale */ PyStatus _PyPreConfig_Read(PyPreConfig *config, const _PyArgv *args) @@ -788,7 +751,18 @@ _PyPreConfig_Read(PyPreConfig *config, const _PyArgv *args) return status; } - preconfig_get_global_vars(config); + preconfig_get_global_var(config); + if (config->use_environment < 0) { + config->use_environment = 1; + } + if (config->isolated < 0) { + config->isolated = 0; + } +#ifdef MS_WINDOWS + if (config->legacy_windows_fs_encoding < 0) { + config->legacy_windows_fs_encoding = 0; + } +#endif /* Copy LC_CTYPE locale, since it's modified later */ const char *loc = setlocale(LC_CTYPE, NULL); @@ -941,7 +915,7 @@ _PyPreConfig_Write(const PyPreConfig *src_config) } } - preconfig_set_global_vars(&config); + preconfig_set_global_var(&config); if (config.configure_locale) { if (config.coerce_c_locale) { diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 01ca459b2eb2b8f..876e52604c7f8e7 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -11,7 +11,7 @@ #include "pycore_fileutils.h" // _Py_ResetForceASCII() #include "pycore_floatobject.h" // _PyFloat_InitTypes() #include "pycore_freelist.h" // _PyObject_ClearFreeLists() -#include "pycore_global_objects_fini_generated.h" // _PyStaticObjects_CheckRefcnt() +#include "pycore_global_objects_fini_generated.h" // _PyStaticObjects_CheckAll() #include "pycore_initconfig.h" // _PyStatus_OK() #include "pycore_interpolation.h" // _PyInterpolation_InitTypes() #include "pycore_long.h" // _PyLong_InitTypes() @@ -924,6 +924,16 @@ pycore_init_builtins(PyThreadState *tstate) return _PyStatus_ERR("failed to add exceptions to builtins"); } + /* The Python-implemented builtins live in the frozen _pybuiltins module. + Programs/_freeze_module has no frozen modules (it's what creates + them) and opts out via _install_importlib, like the import system. */ + const PyConfig *config = _PyInterpreterState_GetConfig(interp); + if (config->_install_importlib) { + if (_PyBuiltin_InitPythonFunctions(builtins_dict) < 0) { + return _PyStatus_ERR("failed to add Python-implemented builtins"); + } + } + interp->builtins_copy = PyDict_Copy(interp->builtins); if (interp->builtins_copy == NULL) { goto error; @@ -2104,7 +2114,7 @@ finalize_interp_types(PyInterpreterState *interp) #endif #ifdef Py_DEBUG - _PyStaticObjects_CheckRefcnt(interp); + _PyStaticObjects_CheckAll(interp); #endif } @@ -3070,7 +3080,18 @@ create_stdio(const PyConfig *config, PyObject* io, newline = "\n"; #endif - PyObject *encoding_str = PyUnicode_FromWideChar(encoding, -1); + PyObject *encoding_str; + if (encoding != NULL) { + encoding_str = PyUnicode_FromWideChar(encoding, -1); + } + else { + /* gh-86427: use the encoding of the device. */ + encoding_str = _Py_device_encoding(fd); + if (encoding_str == Py_None) { + Py_DECREF(encoding_str); + encoding_str = _Py_GetLocaleEncodingObject(); + } + } if (encoding_str == NULL) { Py_CLEAR(buf); goto error; @@ -3190,8 +3211,14 @@ init_sys_streams(PyThreadState *tstate) config->stdio_errors); if (std == NULL) goto error; - PySys_SetObject("__stdin__", std); - _PySys_SetAttr(&_Py_ID(stdin), std); + if (PySys_SetObject("__stdin__", std) < 0) { + Py_DECREF(std); + goto error; + } + if (_PySys_SetAttr(&_Py_ID(stdin), std) < 0) { + Py_DECREF(std); + goto error; + } Py_DECREF(std); /* Set sys.stdout */ @@ -3201,8 +3228,14 @@ init_sys_streams(PyThreadState *tstate) config->stdio_errors); if (std == NULL) goto error; - PySys_SetObject("__stdout__", std); - _PySys_SetAttr(&_Py_ID(stdout), std); + if (PySys_SetObject("__stdout__", std) < 0) { + Py_DECREF(std); + goto error; + } + if (_PySys_SetAttr(&_Py_ID(stdout), std) < 0) { + Py_DECREF(std); + goto error; + } Py_DECREF(std); #if 1 /* Disable this if you have trouble debugging bootstrap stuff */ @@ -3809,10 +3842,9 @@ _Py_FatalRefcountErrorFunc(const char *func, const char *msg) void _Py_NO_RETURN Py_ExitStatusException(PyStatus status) { - if (_PyStatus_IS_EXIT(status)) { - exit(status.exitcode); - } - else if (_PyStatus_IS_ERROR(status)) { + assert(!_PyStatus_IS_EXIT(status)); + + if (_PyStatus_IS_ERROR(status)) { fatal_error(fileno(stderr), 1, status.func, status.err_msg, 1); } else { @@ -3827,8 +3859,8 @@ handle_thread_shutdown_exception(PyThreadState *tstate) assert(tstate != NULL); assert(_PyErr_Occurred(tstate)); PyInterpreterState *interp = tstate->interp; - assert(interp->threads.head != NULL); _PyEval_StopTheWorld(interp); + assert(interp->threads.head != NULL); // We don't have to worry about locking this because the // world is stopped. @@ -3967,8 +3999,8 @@ PyOS_getsig(int sig) return context.sa_handler; #else PyOS_sighandler_t handler; -/* Special signal handling for the secure CRT in Visual Studio 2005 */ -#if defined(_MSC_VER) && _MSC_VER >= 1400 +/* Special signal handling for the secure CRT */ +#if defined(_MSC_VER) switch (sig) { /* Only these signals are valid */ case SIGINT: @@ -3983,7 +4015,7 @@ PyOS_getsig(int sig) default: return SIG_ERR; } -#endif /* _MSC_VER && _MSC_VER >= 1400 */ +#endif /* _MSC_VER */ handler = signal(sig, SIG_IGN); if (handler != SIG_ERR) signal(sig, handler); diff --git a/Python/pystate.c b/Python/pystate.c index e90642fa882db72..4c95669f9fa1b09 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -12,7 +12,7 @@ #include "pycore_freelist.h" // _PyObject_ClearFreeLists() #include "pycore_initconfig.h" // _PyStatus_OK() #include "pycore_interpframe.h" // _PyThreadState_HasStackSpace() -#include "pycore_object.h" // _PyType_InitCache(), _Py_ClearImmortal() +#include "pycore_object.h" // _Py_ClearImmortal() #include "pycore_obmalloc.h" // _PyMem_obmalloc_state_on_heap() #include "pycore_opcode_utils.h" // NUM_COMMON_CONSTANTS #include "pycore_optimizer.h" // JIT_CLEANUP_THRESHOLD @@ -309,9 +309,25 @@ _Py_COMP_DIAG_IGNORE_DEPR_DECLS static const _PyRuntimeState initial = _PyRuntimeState_INIT(_PyRuntime, ""); _Py_COMP_DIAG_POP +/* Remote profilers access interpreter and thread states without synchronizing + with their lifetime. Until the runtime is finalized, keep deleted states in + per-type free lists, so that a stale access only reaches a state of the same + type. */ +typedef struct state_header { + struct state_header *next; // Next entry in the free list + void *mem; // Block to free at finalization +} state_header; + +static struct { + PyMutex mutex; + state_header *tstates; + state_header *interpreters; +} state_freelists; + #define LOCKS_INIT(runtime) \ { \ &(runtime)->interpreters.mutex, \ + &state_freelists.mutex, \ &(runtime)->xi.data_lookup.registry.mutex, \ &(runtime)->unicode_state.ids.mutex, \ &(runtime)->imports.extensions.mutex, \ @@ -390,6 +406,19 @@ _PyRuntimeState_Fini(_PyRuntimeState *runtime) assert(runtime->object_state.interpreter_leaks == 0); #endif gilstate_clear(); + + state_header **lists[] = {&state_freelists.tstates, &state_freelists.interpreters}; + for (size_t i = 0; i < Py_ARRAY_LENGTH(lists); i++) { + PyMutex_LockFlags(&state_freelists.mutex, _Py_LOCK_DONT_DETACH); + state_header *entry = *lists[i]; + *lists[i] = NULL; + PyMutex_Unlock(&state_freelists.mutex); + while (entry != NULL) { + state_header *next = entry->next; + PyMem_RawFree(entry->mem); + entry = next; + } + } } #ifdef HAVE_FORK @@ -420,8 +449,6 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime) } #endif - _PyTypes_AfterFork(); - _PyThread_AfterFork(&runtime->threads); return _PyStatus_OK(); @@ -447,27 +474,63 @@ _PyInterpreterState_Enable(_PyRuntimeState *runtime) return _PyStatus_OK(); } -static PyInterpreterState * -alloc_interpreter(void) +static void * +alloc_state(state_header **freelist, size_t size, size_t alignment) { - // Aligned allocation for PyInterpreterState. - // the first word of the memory block is used to store - // the original pointer to be used later to free the memory. - size_t alignment = _Alignof(PyInterpreterState); - size_t allocsize = sizeof(PyInterpreterState) + sizeof(void *) + alignment - 1; + PyMutex_LockFlags(&state_freelists.mutex, _Py_LOCK_DONT_DETACH); + state_header *entry = *freelist; + if (entry != NULL) { + *freelist = entry->next; + } + PyMutex_Unlock(&state_freelists.mutex); + if (entry != NULL) { + return entry + 1; + } + + size_t allocsize = size + sizeof(state_header) + alignment - 1; void *mem = PyMem_RawCalloc(1, allocsize); if (mem == NULL) { return NULL; } - void *ptr = _Py_ALIGN_UP((char *)mem + sizeof(void *), alignment); - ((void **)ptr)[-1] = mem; + void *ptr = _Py_ALIGN_UP((char *)mem + sizeof(state_header), alignment); + ((state_header *)ptr - 1)->mem = mem; assert(_Py_IS_ALIGNED(ptr, alignment)); return ptr; } +static void +recycle_state(state_header **freelist, void *state, size_t size) +{ + memset(state, 0, size); + state_header *entry = (state_header *)state - 1; + + PyMutex_LockFlags(&state_freelists.mutex, _Py_LOCK_DONT_DETACH); + entry->next = *freelist; + // Keep the list consistent for a child forked by another thread. + _Py_atomic_store_ptr_release(freelist, entry); + PyMutex_Unlock(&state_freelists.mutex); +} + +static PyInterpreterState * +alloc_interpreter(void) +{ + return alloc_state(&state_freelists.interpreters, sizeof(PyInterpreterState), + _Alignof(PyInterpreterState)); +} + static void free_interpreter(PyInterpreterState *interp) { +#ifdef Py_GIL_DISABLED + mi_subproc_t *subproc = interp->mimalloc.subproc; + if (subproc != NULL) { + // Delete the sub-process only when no abandoned segment points to it. + if (mi_atomic_load_relaxed(&subproc->abandoned_count) == 0) { + mi_subproc_delete(subproc); + } + interp->mimalloc.subproc = NULL; + } +#endif #ifdef Py_STATS if (interp->pystats_struct) { PyMem_RawFree(interp->pystats_struct); @@ -483,7 +546,13 @@ free_interpreter(PyInterpreterState *interp) interp->obmalloc = NULL; } assert(_Py_IS_ALIGNED(interp, _Alignof(PyInterpreterState))); - PyMem_RawFree(((void **)interp)[-1]); + // A daemon thread may still own the embedded initial thread state. + if (interp->_initialized + && _Py_atomic_load_ptr(&interp->threads.preallocated) == NULL) + { + return; + } + recycle_state(&state_freelists.interpreters, interp, sizeof(*interp)); } } @@ -573,9 +642,13 @@ init_interpreter(PyInterpreterState *interp, _PyEval_InitState(interp); _PyGC_InitState(&interp->gc); PyConfig_InitPythonConfig(&interp->config); - _PyType_InitCache(interp); #ifdef Py_GIL_DISABLED _Py_brc_init_state(interp); + + interp->mimalloc.subproc = mi_subproc_new(); + if (interp->mimalloc.subproc == NULL) { + return _PyStatus_NO_MEMORY(); + } #endif llist_init(&interp->mem_free_queue.head); @@ -1505,12 +1578,15 @@ alloc_threadstate(PyInterpreterState *interp) // Fall back to the allocator. if (tstate == NULL) { - tstate = PyMem_RawCalloc(1, sizeof(_PyThreadStateImpl)); + tstate = alloc_state(&state_freelists.tstates, sizeof(*tstate), + _Alignof(_PyThreadStateImpl)); if (tstate == NULL) { return NULL; } reset_threadstate(tstate); } + // Set the interpreter before any later initialization can fail. + tstate->base.interp = interp; return tstate; } @@ -1530,7 +1606,7 @@ free_threadstate(_PyThreadStateImpl *tstate) _Py_atomic_store_ptr(&interp->threads.preallocated, tstate); } else { - PyMem_RawFree(tstate); + recycle_state(&state_freelists.tstates, tstate, sizeof(*tstate)); } } @@ -1631,6 +1707,7 @@ init_threadstate(_PyThreadStateImpl *_tstate, _tstate->asyncio_running_loop = NULL; _tstate->asyncio_running_task = NULL; + _tstate->lazy_imports = NULL; #ifdef _Py_TIER2 _tstate->jit_tracer_state = NULL; @@ -1670,21 +1747,23 @@ new_threadstate(PyInterpreterState *interp, int whence) return NULL; } -#ifdef Py_GIL_DISABLED - Py_ssize_t qsbr_idx = _Py_qsbr_reserve(interp); - if (qsbr_idx < 0) { +#ifdef Py_STATS + // The PyStats structure is quite large and is allocated separated from + // tstate. + if (!_PyStats_ThreadInit(interp, tstate)) { free_threadstate(tstate); return NULL; } +#endif +#ifdef Py_GIL_DISABLED int32_t tlbc_idx = _Py_ReserveTLBCIndex(interp); if (tlbc_idx < 0) { free_threadstate(tstate); return NULL; } -#endif -#ifdef Py_STATS - // The PyStats structure is quite large and is allocated separated from tstate. - if (!_PyStats_ThreadInit(interp, tstate)) { + Py_ssize_t qsbr_idx = _Py_qsbr_reserve(interp); + if (qsbr_idx < 0) { + _Py_UnreserveTLBCIndex(interp, tlbc_idx); free_threadstate(tstate); return NULL; } @@ -1835,13 +1914,6 @@ PyThreadState_Clear(PyThreadState *tstate) Py_CLEAR(((_PyThreadStateImpl *)tstate)->asyncio_running_task); - PyMutex_Lock(&tstate->interp->asyncio_tasks_lock); - // merge any lingering tasks from thread state to interpreter's - // tasks list - llist_concat(&tstate->interp->asyncio_tasks_head, - &((_PyThreadStateImpl *)tstate)->asyncio_tasks_head); - PyMutex_Unlock(&tstate->interp->asyncio_tasks_lock); - Py_CLEAR(tstate->dict); Py_CLEAR(tstate->async_exc); @@ -1872,6 +1944,9 @@ PyThreadState_Clear(PyThreadState *tstate) Py_CLEAR(tstate->context); + // Finalizers above may resolve imports and create this set. + Py_CLEAR(((_PyThreadStateImpl *)tstate)->lazy_imports); + #ifdef Py_GIL_DISABLED // Each thread should clear own freelists in free-threading builds. struct _Py_freelists *freelists = _Py_freelists_GET(); @@ -1914,11 +1989,30 @@ PyThreadState_Clear(PyThreadState *tstate) static void decrement_stoptheworld_countdown(struct _stoptheworld_state *stw); -/* Common code for PyThreadState_Delete() and PyThreadState_DeleteCurrent() */ +// `release_gil` releases the current thread's GIL. For states already removed +// by _PyThreadState_RemoveExcept(), `is_unlinked` limits cleanup to task transfer. static void -tstate_delete_common(PyThreadState *tstate, int release_gil) +tstate_delete_common(PyThreadState *tstate, int release_gil, int is_unlinked) { assert(tstate->_status.cleared && !tstate->_status.finalized); + assert(!is_unlinked || !release_gil); + + _PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate; + // Finalizers may register tasks during or after PyThreadState_Clear(). + // Transfer them before normal unlinking or GIL release: cross-thread task + // removal uses stop-the-world or the GIL, not asyncio_tasks_lock. + if (!llist_empty(&tstate_impl->asyncio_tasks_head)) { + // Serialize transfers from concurrently exiting threads. + PyMutex_Lock(&tstate->interp->asyncio_tasks_lock); + llist_concat(&tstate->interp->asyncio_tasks_head, + &tstate_impl->asyncio_tasks_head); + PyMutex_Unlock(&tstate->interp->asyncio_tasks_lock); + } + assert(llist_empty(&tstate_impl->asyncio_tasks_head)); + if (is_unlinked) { + return; + } + tstate_verify_not_active(tstate); assert(!_PyThreadState_IsRunningMain(tstate)); @@ -1938,7 +2032,10 @@ tstate_delete_common(PyThreadState *tstate, int release_gil) if (tstate->next) { tstate->next->prev = tstate->prev; } - if (tstate->state != _Py_THREAD_SUSPENDED) { + int state = _Py_atomic_load_int_relaxed(&tstate->state); + if (state != _Py_THREAD_SUSPENDED && + state != _Py_THREAD_SUSPENDED_WAITING) + { // Any ongoing stop-the-world request should not wait for us because // our thread is getting deleted. if (interp->stoptheworld.requested) { @@ -1951,7 +2048,6 @@ tstate_delete_common(PyThreadState *tstate, int release_gil) #if defined(Py_REF_DEBUG) && defined(Py_GIL_DISABLED) // Add our portion of the total refcount to the interpreter's total. - _PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate; tstate->interp->object_state.reftotal += tstate_impl->reftotal; tstate_impl->reftotal = 0; assert(tstate_impl->refcounts.values == NULL); @@ -1998,7 +2094,7 @@ zapthreads(PyInterpreterState *interp) */ while ((tstate = interp->threads.head) != NULL) { tstate_verify_not_active(tstate); - tstate_delete_common(tstate, 0); + tstate_delete_common(tstate, /*release_gil=*/0, /*is_unlinked=*/0); free_threadstate((_PyThreadStateImpl *)tstate); } } @@ -2009,7 +2105,7 @@ PyThreadState_Delete(PyThreadState *tstate) { _Py_EnsureTstateNotNULL(tstate); tstate_verify_not_active(tstate); - tstate_delete_common(tstate, 0); + tstate_delete_common(tstate, /*release_gil=*/0, /*is_unlinked=*/0); free_threadstate((_PyThreadStateImpl *)tstate); } @@ -2025,7 +2121,7 @@ _PyThreadState_DeleteCurrent(PyThreadState *tstate) _PyStats_Detach((_PyThreadStateImpl *)tstate); #endif current_fast_clear(tstate->interp->runtime); - tstate_delete_common(tstate, 1); // release GIL as part of call + tstate_delete_common(tstate, /*release_gil=*/1, /*is_unlinked=*/0); free_threadstate((_PyThreadStateImpl *)tstate); } @@ -2095,6 +2191,7 @@ _PyThreadState_DeleteList(PyThreadState *list, int is_after_fork) for (p = list; p; p = next) { next = p->next; PyThreadState_Clear(p); + tstate_delete_common(p, /*release_gil=*/0, /*is_unlinked=*/1); if (is_after_fork) { free_threadstate((_PyThreadStateImpl *)p); } @@ -2197,7 +2294,7 @@ tstate_deactivate(PyThreadState *tstate) assert(tstate_is_bound(tstate)); assert(tstate->_status.active); -#if Py_STATS +#ifdef Py_STATS _PyStats_Detach((_PyThreadStateImpl *)tstate); #endif @@ -2222,6 +2319,22 @@ tstate_try_attach(PyThreadState *tstate) #endif } +static int +tstate_try_attach_detached(PyThreadState *tstate, int *state) +{ +#ifdef Py_GIL_DISABLED + assert(*state == _Py_THREAD_DETACHED || + *state == _Py_THREAD_DETACHED_WAITING); + return _Py_atomic_compare_exchange_int(&tstate->state, + state, + _Py_THREAD_ATTACHED); +#else + assert(tstate->state == _Py_THREAD_DETACHED); + tstate->state = _Py_THREAD_ATTACHED; + return 1; +#endif +} + static void tstate_set_detached(PyThreadState *tstate, int detached_state) { @@ -2236,10 +2349,20 @@ tstate_set_detached(PyThreadState *tstate, int detached_state) static void tstate_wait_attach(PyThreadState *tstate) { - do { + for (;;) { int state = _Py_atomic_load_int_relaxed(&tstate->state); if (state == _Py_THREAD_SUSPENDED) { - // Wait until we're switched out of SUSPENDED to DETACHED. + // Register an active attach waiter. The next stop-the-world + // request must let this thread attach before suspending it again. + if (!_Py_atomic_compare_exchange_int( + &tstate->state, &state, _Py_THREAD_SUSPENDED_WAITING)) + { + continue; + } + state = _Py_THREAD_SUSPENDED_WAITING; + } + if (state == _Py_THREAD_SUSPENDED_WAITING) { + // Park rechecks the state before sleeping, in case we were resumed. _PyParkingLot_Park(&tstate->state, &state, sizeof(tstate->state), /*timeout=*/-1, NULL, /*detach=*/0); } @@ -2248,10 +2371,13 @@ tstate_wait_attach(PyThreadState *tstate) _PyThreadState_HangThread(tstate); } else { - assert(state == _Py_THREAD_DETACHED); + assert(state == _Py_THREAD_DETACHED || + state == _Py_THREAD_DETACHED_WAITING); + if (tstate_try_attach_detached(tstate, &state)) { + return; + } } - // Once we're back in DETACHED we can re-attach - } while (!tstate_try_attach(tstate)); + } } void @@ -2379,6 +2505,41 @@ _PyThreadState_SetShuttingDown(PyThreadState *tstate) #endif } +#ifdef Py_GIL_DISABLED +int +_PyThreadState_TrySuspendDetached(PyThreadState *tstate) +{ + assert(tstate != _PyThreadState_GET()); + int expected = _Py_THREAD_DETACHED; + return _Py_atomic_compare_exchange_int(&tstate->state, &expected, + _Py_THREAD_SUSPENDED); +} + +void +_PyThreadState_ResumeDetached(PyThreadState *tstate) +{ + assert(tstate != _PyThreadState_GET()); + int state = _Py_atomic_load_int_relaxed(&tstate->state); + int next_state; + do { + assert(state == _Py_THREAD_SUSPENDED || + state == _Py_THREAD_SUSPENDED_WAITING); + if (state == _Py_THREAD_SUSPENDED_WAITING) { + next_state = _Py_THREAD_DETACHED_WAITING; + } + else { + next_state = _Py_THREAD_DETACHED; + } + // Retry if an attach waiter registered concurrently. + } while (!_Py_atomic_compare_exchange_int( + &tstate->state, &state, next_state)); + // Wake the thread if it is parked in tstate_wait_attach(). + if (state == _Py_THREAD_SUSPENDED_WAITING) { + _PyParkingLot_UnparkAll(&tstate->state); + } +} +#endif + // Decrease stop-the-world counter of remaining number of threads that need to // pause. If we are the final thread to pause, notify the requesting thread. static void @@ -2420,6 +2581,8 @@ park_detached_threads(struct _stoptheworld_state *stw) _Py_FOR_EACH_STW_INTERP(stw, i) { _Py_FOR_EACH_TSTATE_UNLOCKED(i, t) { int state = _Py_atomic_load_int_relaxed(&t->state); + // DETACHED_WAITING threads remain counted until they attach and + // stop, so repeated pauses cannot prevent them from attaching. if (state == _Py_THREAD_DETACHED) { // Atomically transition to "suspended" if in "detached" state. if (_Py_atomic_compare_exchange_int( @@ -2508,10 +2671,7 @@ start_the_world(struct _stoptheworld_state *stw) _Py_FOR_EACH_STW_INTERP(stw, i) { _Py_FOR_EACH_TSTATE_UNLOCKED(i, t) { if (t != stw->requester) { - assert(_Py_atomic_load_int_relaxed(&t->state) == - _Py_THREAD_SUSPENDED); - _Py_atomic_store_int(&t->state, _Py_THREAD_DETACHED); - _PyParkingLot_UnparkAll(&t->state); + _PyThreadState_ResumeDetached(t); } } } @@ -2734,36 +2894,33 @@ _PyThread_CurrentFrames(void) return NULL; } - /* for i in all interpreters: - * for t in all of i's thread states: - * if t's frame isn't NULL, map t's id to its frame + /* for t in all of the current interpreter's thread states: + * if t's frame isn't NULL, map t's id to its frame * Because these lists can mutate even when the GIL is held, we * need to grab head_mutex for the duration. */ - _PyEval_StopTheWorldAll(runtime); + PyInterpreterState *interp = tstate->interp; + _PyEval_StopTheWorld(interp); HEAD_LOCK(runtime); - PyInterpreterState *i; - for (i = runtime->interpreters.head; i != NULL; i = i->next) { - _Py_FOR_EACH_TSTATE_UNLOCKED(i, t) { - _PyInterpreterFrame *frame = t->current_frame; - frame = _PyFrame_GetFirstComplete(frame); - if (frame == NULL) { - continue; - } - PyObject *id = PyLong_FromUnsignedLong(t->thread_id); - if (id == NULL) { - goto fail; - } - PyObject *frameobj = (PyObject *)_PyFrame_GetFrameObject(frame); - if (frameobj == NULL) { - Py_DECREF(id); - goto fail; - } - int stat = PyDict_SetItem(result, id, frameobj); + _Py_FOR_EACH_TSTATE_UNLOCKED(interp, t) { + _PyInterpreterFrame *frame = t->current_frame; + frame = _PyFrame_GetFirstComplete(frame); + if (frame == NULL) { + continue; + } + PyObject *id = PyLong_FromUnsignedLong(t->thread_id); + if (id == NULL) { + goto fail; + } + PyObject *frameobj = (PyObject *)_PyFrame_GetFrameObject(frame); + if (frameobj == NULL) { Py_DECREF(id); - if (stat < 0) { - goto fail; - } + goto fail; + } + int stat = PyDict_SetItem(result, id, frameobj); + Py_DECREF(id); + if (stat < 0) { + goto fail; } } goto done; @@ -2773,7 +2930,7 @@ _PyThread_CurrentFrames(void) done: HEAD_UNLOCK(runtime); - _PyEval_StartTheWorldAll(runtime); + _PyEval_StartTheWorld(interp); return result; } @@ -2799,35 +2956,32 @@ _PyThread_CurrentExceptions(void) return NULL; } - /* for i in all interpreters: - * for t in all of i's thread states: - * if t's frame isn't NULL, map t's id to its frame + /* for t in all of the current interpreter's thread states: + * if t's frame isn't NULL, map t's id to its exception * Because these lists can mutate even when the GIL is held, we * need to grab head_mutex for the duration. */ - _PyEval_StopTheWorldAll(runtime); + PyInterpreterState *interp = tstate->interp; + _PyEval_StopTheWorld(interp); HEAD_LOCK(runtime); - PyInterpreterState *i; - for (i = runtime->interpreters.head; i != NULL; i = i->next) { - _Py_FOR_EACH_TSTATE_UNLOCKED(i, t) { - _PyErr_StackItem *err_info = _PyErr_GetTopmostException(t); - if (err_info == NULL) { - continue; - } - PyObject *id = PyLong_FromUnsignedLong(t->thread_id); - if (id == NULL) { - goto fail; - } - PyObject *exc = err_info->exc_value; - assert(exc == NULL || - exc == Py_None || - PyExceptionInstance_Check(exc)); - - int stat = PyDict_SetItem(result, id, exc == NULL ? Py_None : exc); - Py_DECREF(id); - if (stat < 0) { - goto fail; - } + _Py_FOR_EACH_TSTATE_UNLOCKED(interp, t) { + _PyErr_StackItem *err_info = _PyErr_GetTopmostException(t); + if (err_info == NULL) { + continue; + } + PyObject *id = PyLong_FromUnsignedLong(t->thread_id); + if (id == NULL) { + goto fail; + } + PyObject *exc = err_info->exc_value; + assert(exc == NULL || + exc == Py_None || + PyExceptionInstance_Check(exc)); + + int stat = PyDict_SetItem(result, id, exc == NULL ? Py_None : exc); + Py_DECREF(id); + if (stat < 0) { + goto fail; } } goto done; @@ -2837,7 +2991,7 @@ _PyThread_CurrentExceptions(void) done: HEAD_UNLOCK(runtime); - _PyEval_StartTheWorldAll(runtime); + _PyEval_StartTheWorld(interp); return result; } @@ -3260,10 +3414,11 @@ tstate_mimalloc_bind(PyThreadState *tstate) _mi_tld_init(tld, &mts->heaps[_Py_MIMALLOC_HEAP_MEM]); llist_init(&mts->page_list); - // Exiting threads push any remaining in-use segments to the abandoned - // pool to be re-claimed later by other threads. We use per-interpreter - // pools to keep Python objects from different interpreters separate. - tld->segments.abandoned = &tstate->interp->mimalloc.abandoned_pool; + // Exiting threads abandon any remaining in-use segments to be re-claimed + // later by other threads. We use a per-interpreter mimalloc sub-process + // to keep Python objects from different interpreters separate. + assert(tstate->interp->mimalloc.subproc != NULL); + tld->segments.subproc = tstate->interp->mimalloc.subproc; // Don't fill in the first N bytes up to ob_type in debug builds. We may // access ob_tid and the refcount fields in the dict and list lock-less @@ -3281,7 +3436,7 @@ tstate_mimalloc_bind(PyThreadState *tstate) // Initialize each heap for (uint8_t i = 0; i < _Py_MIMALLOC_HEAP_COUNT; i++) { - _mi_heap_init_ex(&mts->heaps[i], tld, _mi_arena_id_none(), false, i); + _mi_heap_init(&mts->heaps[i], tld, _mi_arena_id_none(), false, i); mts->heaps[i].debug_offset = (uint8_t)debug_offsets[i]; } @@ -3418,8 +3573,8 @@ PyInterpreterGuard_FromCurrent(void) return guard; } -void -PyInterpreterGuard_Close(PyInterpreterGuard *guard) +static void +release_interp_guard(PyInterpreterGuard *guard) { PyInterpreterState *interp = guard->interp; assert(interp != NULL); @@ -3431,9 +3586,28 @@ PyInterpreterGuard_Close(PyInterpreterGuard *guard) } assert(old_value > 0); +} + +void +PyInterpreterGuard_Close(PyInterpreterGuard *guard) +{ + release_interp_guard(guard); PyMem_RawFree(guard); } +int +_PyInterpreterGuard_TryAcquire(PyInterpreterState *interp, + PyInterpreterGuard *guard) +{ + return try_acquire_interp_guard(interp, guard); +} + +void +_PyInterpreterGuard_Release(PyInterpreterGuard *guard) +{ + release_interp_guard(guard); +} + PyInterpreterView * PyInterpreterView_FromCurrent(void) { diff --git a/Python/pystats.c b/Python/pystats.c index 2fac2db1b738c7e..6862521f659f202 100644 --- a/Python/pystats.c +++ b/Python/pystats.c @@ -230,9 +230,11 @@ print_object_stats(FILE *out, ObjectStats *stats) fprintf(out, "Object materialize dict (str subclass): %" PRIu64 "\n", stats->dict_materialized_str_subclass); fprintf(out, "Object method cache hits: %" PRIu64 "\n", stats->type_cache_hits); fprintf(out, "Object method cache misses: %" PRIu64 "\n", stats->type_cache_misses); - fprintf(out, "Object method cache collisions: %" PRIu64 "\n", stats->type_cache_collisions); + fprintf(out, "Object method cache too big: %" PRIu64 "\n", stats->type_cache_too_big); fprintf(out, "Object method cache dunder hits: %" PRIu64 "\n", stats->type_cache_dunder_hits); fprintf(out, "Object method cache dunder misses: %" PRIu64 "\n", stats->type_cache_dunder_misses); + fprintf(out, "Object method cache invalidations: %" PRIu64 "\n", stats->type_cache_invalidations); + fprintf(out, "Object method cache resizes: %" PRIu64 "\n", stats->type_cache_resizes); } static void @@ -439,7 +441,9 @@ merge_object_stats(ObjectStats *dest, const ObjectStats *src) dest->type_cache_misses += src->type_cache_misses; dest->type_cache_dunder_hits += src->type_cache_dunder_hits; dest->type_cache_dunder_misses += src->type_cache_dunder_misses; - dest->type_cache_collisions += src->type_cache_collisions; + dest->type_cache_too_big += src->type_cache_too_big; + dest->type_cache_invalidations += src->type_cache_invalidations; + dest->type_cache_resizes += src->type_cache_resizes; dest->object_visits += src->object_visits; } diff --git a/Python/pystrhex.c b/Python/pystrhex.c index 8fb1fa36f85e739..ff6ee830fea7abc 100644 --- a/Python/pystrhex.c +++ b/Python/pystrhex.c @@ -168,15 +168,16 @@ _Py_strhex_impl(const char* argbuf, Py_ssize_t arglen, abs_bytes_per_sep = 0; } - PyObject *retval; + PyObject *retval = NULL; + PyBytesWriter *bytes_writer = NULL; Py_UCS1 *retbuf; if (return_bytes) { /* If _PyBytes_FromSize() were public we could avoid malloc+copy. */ - retval = PyBytes_FromStringAndSize(NULL, resultlen); - if (!retval) { + bytes_writer = PyBytesWriter_Create(resultlen); + if (!bytes_writer) { return NULL; } - retbuf = (Py_UCS1 *)PyBytes_AS_STRING(retval); + retbuf = PyBytesWriter_GetData(bytes_writer); } else { retval = PyUnicode_New(resultlen, 127); @@ -244,13 +245,15 @@ _Py_strhex_impl(const char* argbuf, Py_ssize_t arglen, } } + if (return_bytes) { + return PyBytesWriter_Finish(bytes_writer); + } + else { #ifdef Py_DEBUG - if (!return_bytes) { assert(_PyUnicode_CheckConsistency(retval, 1)); - } #endif - - return retval; + return retval; + } } PyObject * _Py_strhex(const char* argbuf, Py_ssize_t arglen) diff --git a/Python/pystrtod.c b/Python/pystrtod.c index e8aca939d1fb98c..7753d1732cf78cb 100644 --- a/Python/pystrtod.c +++ b/Python/pystrtod.c @@ -401,6 +401,15 @@ _Py_string_to_number_with_underscores( return NULL; } +/* Largest precision magnitude accepted by PyOS_double_to_string(). The + output buffer sizes computed below and within _Py_dg_dtoa() use int and + Py_ssize_t arithmetic on roughly precision + (digits before the point, at + most DBL_MAX_10_EXP + 1 == 309) + a few bytes of sign, point and exponent. + Staying this far inside the int range keeps all of those sums in range. + (Only C callers can pass a negative precision.) _Py_dg_dtoa() applies + the same bound to its ndigits argument. */ +#define DOUBLE_TO_STRING_PRECISION_MAX (INT_MAX - 1024) + #if _PY_SHORT_FLOAT_REPR == 0 /* Given a string that may have a decimal point in the current @@ -766,6 +775,13 @@ char * PyOS_double_to_string(double val, int t, exp; int upper = 0; + if (precision > DOUBLE_TO_STRING_PRECISION_MAX + || precision < -DOUBLE_TO_STRING_PRECISION_MAX) + { + PyErr_SetString(PyExc_ValueError, "precision too big"); + return NULL; + } + /* Validate format_code, and map upper and lower case */ switch (format_code) { case 'e': /* exponent */ @@ -1227,6 +1243,13 @@ char * PyOS_double_to_string(double val, const char * const *float_strings = lc_float_strings; int mode; + if (precision > DOUBLE_TO_STRING_PRECISION_MAX + || precision < -DOUBLE_TO_STRING_PRECISION_MAX) + { + PyErr_SetString(PyExc_ValueError, "precision too big"); + return NULL; + } + /* Validate format_code, and map upper and lower case. Compute the mode and make any adjustments as needed. */ switch (format_code) { diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 049eaea4994ac46..38003e60e985ca2 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1157,6 +1157,13 @@ _PyErr_Display(PyObject *file, PyObject *unused, PyObject *value, PyObject *tb) } } + // gh-161863: Interpreter can be not fully initialized + // when calling this function. May be not safe to call the import. + PyInterpreterState *interp = _PyInterpreterState_GET(); + if (interp->imports.importlib == NULL) { + goto fallback; + } + // Try first with the stdlib traceback module PyObject *print_exception_fn = PyImport_ImportModuleAttrString( "traceback", @@ -1285,7 +1292,7 @@ _PyRun_String(const char *str, PyObject* name, int start, goto done; } - mod = _PyParser_ASTFromString(str, name, start, flags, arena, module); + mod = _PyParser_ASTFromString(str, name, start, flags, arena, module, NULL); Py_XDECREF(module); if (mod != NULL) { @@ -1569,32 +1576,43 @@ _Py_CompileString(const char *str, PyObject *filename, int start, return NULL; } - PyCodeObject *co; - mod_ty mod; PyArena *arena = _PyArena_New(); if (arena == NULL) return NULL; - mod = _PyParser_ASTFromString(str, filename, start, flags, arena, module); + PyObject *result = NULL; + PyObject *incomplete = NULL; + mod_ty mod = _PyParser_ASTFromString(str, filename, start, flags, arena, + module, &incomplete); if (mod == NULL) { - _PyArena_Free(arena); - return NULL; + goto done; } if (flags && (flags->cf_flags & PyCF_ONLY_AST)) { int syntax_check_only = ((flags->cf_flags & PyCF_OPTIMIZED_AST) == PyCF_ONLY_AST); /* unoptiomized AST */ if (_PyCompile_AstPreprocess(mod, filename, flags, optimize, arena, syntax_check_only, module) < 0) { - _PyArena_Free(arena); - return NULL; + goto done; + } + if (incomplete != NULL) { + goto done; } - PyObject *result = PyAST_mod2obj(mod); + result = PyAST_mod2obj(mod); _PyArena_Free(arena); return result; } - co = _PyAST_Compile(mod, filename, flags, optimize, arena, module); + result = (PyObject *)_PyAST_Compile(mod, filename, flags, optimize, arena, module); + +done: _PyArena_Free(arena); - return (PyObject *)co; + if (incomplete != NULL && !PyErr_Occurred()) { + Py_CLEAR(result); + PyErr_SetRaisedException(incomplete); + } + else { + Py_XDECREF(incomplete); + } + return result; } PyObject * diff --git a/Python/qsbr.c b/Python/qsbr.c index e9d935bfb40d84e..a50d66e3e9e7ae4 100644 --- a/Python/qsbr.c +++ b/Python/qsbr.c @@ -85,10 +85,10 @@ grow_thread_array(struct _qsbr_shared *shared) new_size = MIN_ARRAY_SIZE; } - // Overallocate by 63 bytes so we can align to a 64-byte boundary. + // Overallocate so we can align to a cache line boundary. // This avoids potential false sharing between the first entry and other // allocations. - size_t alignment = 64; + size_t alignment = _Py_QSBR_CACHE_LINE_SIZE; size_t alloc_size = (size_t)new_size * sizeof(struct _qsbr_pad) + alignment - 1; void *raw = PyMem_RawCalloc(1, alloc_size); if (raw == NULL) { diff --git a/Python/remote_debug.h b/Python/remote_debug.h index 7b7380d25bf496f..0c55fd3a0354e3a 100644 --- a/Python/remote_debug.h +++ b/Python/remote_debug.h @@ -60,19 +60,13 @@ extern "C" { #endif #if defined(__APPLE__) && defined(TARGET_OS_OSX) && TARGET_OS_OSX -# include -# include +# include # include -# include # include # include # include -# include # include # include -# include -# include -# include #endif #ifdef MS_WINDOWS @@ -107,9 +101,18 @@ _Py_RemoteDebug_HasPermissionError(void) && PyErr_ExceptionMatches(PyExc_PermissionError); } +static inline int +_Py_RemoteDebug_IsFatalReadError(void) +{ + return _Py_RemoteDebug_HasPermissionError() + || PyErr_ExceptionMatches(PyExc_MemoryError) + || PyErr_ExceptionMatches(PyExc_ProcessLookupError) + || (PyErr_Occurred() && !PyErr_ExceptionMatches(PyExc_Exception)); +} + #define _set_debug_exception_cause(exception, format, ...) \ do { \ - if (!_Py_RemoteDebug_HasPermissionError()) { \ + if (!_Py_RemoteDebug_IsFatalReadError()) { \ PyThreadState *tstate = _PyThreadState_GET(); \ if (!_PyErr_Occurred(tstate)) { \ _PyErr_Format(tstate, exception, format, ##__VA_ARGS__); \ @@ -142,7 +145,8 @@ get_page_size(void) { GetSystemInfo(&si); page_size = si.dwPageSize; #else - page_size = (size_t)getpagesize(); + long n = sysconf(_SC_PAGESIZE); + page_size = (n > 0) ? (size_t)n : 4096; #endif } return page_size; @@ -151,8 +155,6 @@ get_page_size(void) { typedef struct page_cache_entry { uintptr_t page_addr; // page-aligned base address char *data; - int valid; - struct page_cache_entry *next; } page_cache_entry_t; #define MAX_PAGES 1024 @@ -183,7 +185,7 @@ _Py_RemoteDebug_ReadRemoteMemory(proc_handle_t *handle, uintptr_t remote_address typedef int (*section_validator_t)(proc_handle_t *handle, uintptr_t address); // Validate that a candidate address starts with _Py_Debug_Cookie. -static int +UNUSED static int _Py_RemoteDebug_ValidatePyRuntimeCookie(proc_handle_t *handle, uintptr_t address) { if (address == 0) { @@ -191,7 +193,7 @@ _Py_RemoteDebug_ValidatePyRuntimeCookie(proc_handle_t *handle, uintptr_t address } char buf[sizeof(_Py_Debug_Cookie) - 1]; if (_Py_RemoteDebug_ReadRemoteMemory(handle, address, sizeof(buf), buf) != 0) { - if (!_Py_RemoteDebug_HasPermissionError()) { + if (!_Py_RemoteDebug_IsFatalReadError()) { PyErr_Clear(); } return 0; @@ -207,7 +209,6 @@ _Py_RemoteDebug_FreePageCache(proc_handle_t *handle) PyMem_RawFree(handle->pages[i].data); } handle->pages[i].data = NULL; - handle->pages[i].valid = 0; } handle->page_cache_count = 0; } @@ -215,9 +216,6 @@ _Py_RemoteDebug_FreePageCache(proc_handle_t *handle) UNUSED static void _Py_RemoteDebug_ClearCache(proc_handle_t *handle) { - for (int i = 0; i < handle->page_cache_count; i++) { - handle->pages[i].valid = 0; - } handle->page_cache_count = 0; } @@ -240,7 +238,6 @@ _Py_RemoteDebug_InitProcHandle(proc_handle_t *handle, pid_t pid) { handle->page_cache_count = 0; for (int i = 0; i < MAX_PAGES; i++) { handle->pages[i].data = NULL; - handle->pages[i].valid = 0; } handle->pid = pid; @@ -272,6 +269,11 @@ _Py_RemoteDebug_CleanupProcHandle(proc_handle_t *handle) { CloseHandle(handle->hProcess); handle->hProcess = NULL; } +#elif defined(__APPLE__) && defined(TARGET_OS_OSX) && TARGET_OS_OSX + if (handle->task != MACH_PORT_NULL) { + mach_port_deallocate(mach_task_self(), handle->task); + handle->task = MACH_PORT_NULL; + } #elif defined(__linux__) if (handle->memfd != -1) { close(handle->memfd); @@ -284,284 +286,134 @@ _Py_RemoteDebug_CleanupProcHandle(proc_handle_t *handle) { #if defined(__APPLE__) && defined(TARGET_OS_OSX) && TARGET_OS_OSX -static uintptr_t -return_section_address64( - const char* section, - mach_port_t proc_ref, - uintptr_t base, - void* map -) { - struct mach_header_64* hdr = (struct mach_header_64*)map; - int ncmds = hdr->ncmds; - - int cmd_cnt = 0; - struct segment_command_64* cmd = map + sizeof(struct mach_header_64); - - mach_vm_size_t size = 0; - mach_msg_type_number_t count = sizeof(vm_region_basic_info_data_64_t); - mach_vm_address_t address = (mach_vm_address_t)base; - vm_region_basic_info_data_64_t r_info; - mach_port_t object_name; - uintptr_t vmaddr = 0; - - for (int i = 0; cmd_cnt < 2 && i < ncmds; i++) { - if (cmd->cmd == LC_SEGMENT_64 && strcmp(cmd->segname, "__TEXT") == 0) { - vmaddr = cmd->vmaddr; - } - if (cmd->cmd == LC_SEGMENT_64 && strcmp(cmd->segname, "__DATA") == 0) { - while (cmd->filesize != size) { - address += size; - kern_return_t ret = mach_vm_region( - proc_ref, - &address, - &size, - VM_REGION_BASIC_INFO_64, - (vm_region_info_t)&r_info, // cppcheck-suppress [uninitvar] - &count, - &object_name - ); - if (ret != KERN_SUCCESS) { - PyErr_Format(PyExc_RuntimeError, - "mach_vm_region failed while parsing 64-bit Mach-O binary " - "at base address 0x%lx (kern_return_t: %d)", - base, ret); - return 0; - } - } +enum { + MACHO_NAME_SIZE = 16, + MACHO_MAX_LOAD_COMMAND_BYTES = 16 * 1024 * 1024, + DYLD_MAX_IMAGE_COUNT = 65536, +}; - int nsects = cmd->nsects; - struct section_64* sec = (struct section_64*)( - (void*)cmd + sizeof(struct segment_command_64) - ); - for (int j = 0; j < nsects; j++) { - if (strcmp(sec[j].sectname, section) == 0) { - return base + sec[j].addr - vmaddr; - } - } - cmd_cnt++; - } +/* These 64-bit little-endian layouts work on both arm64 and x86_64 (Rosetta). */ +static_assert(sizeof(uintptr_t) == sizeof(uint64_t), "64-bit macOS required"); - cmd = (struct segment_command_64*)((void*)cmd + cmd->cmdsize); +static uintptr_t +macho_section_address(const void *image, size_t image_size, + uintptr_t base, const char *name) +{ + struct mach_header_64 header; + if (image_size < sizeof(header)) { + return 0; + } + memcpy(&header, image, sizeof(header)); + if (header.magic != MH_MAGIC_64 || + header.sizeofcmds > image_size - sizeof(header)) + { + return 0; } - return 0; -} - -static uintptr_t -return_section_address32( - const char* section, - mach_port_t proc_ref, - uintptr_t base, - void* map -) { - struct mach_header* hdr = (struct mach_header*)map; - int ncmds = hdr->ncmds; - - int cmd_cnt = 0; - struct segment_command* cmd = map + sizeof(struct mach_header); - - mach_vm_size_t size = 0; - mach_msg_type_number_t count = sizeof(vm_region_basic_info_data_t); - mach_vm_address_t address = (mach_vm_address_t)base; - vm_region_basic_info_data_t r_info; - mach_port_t object_name; - uintptr_t vmaddr = 0; - - for (int i = 0; cmd_cnt < 2 && i < ncmds; i++) { - if (cmd->cmd == LC_SEGMENT && strcmp(cmd->segname, "__TEXT") == 0) { - vmaddr = cmd->vmaddr; + const unsigned char *cursor = (const unsigned char *)image + sizeof(header); + size_t remaining = header.sizeofcmds; + uint64_t header_address = 0, section_address = 0; + int have_header = 0, have_section = 0; + for (uint32_t index = 0; index < header.ncmds; index++) { + struct load_command command; + if (remaining < sizeof(command)) { + return 0; } - if (cmd->cmd == LC_SEGMENT && strcmp(cmd->segname, "__DATA") == 0) { - while (cmd->filesize != size) { - address += size; - kern_return_t ret = mach_vm_region( - proc_ref, - &address, - &size, - VM_REGION_BASIC_INFO, - (vm_region_info_t)&r_info, // cppcheck-suppress [uninitvar] - &count, - &object_name - ); - if (ret != KERN_SUCCESS) { - PyErr_Format(PyExc_RuntimeError, - "mach_vm_region failed while parsing 32-bit Mach-O binary " - "at base address 0x%lx (kern_return_t: %d)", - base, ret); - return 0; - } + memcpy(&command, cursor, sizeof(command)); + size_t command_size = command.cmdsize; + if (command_size < sizeof(command) || command_size > remaining) { + return 0; + } + if (command.cmd == LC_SEGMENT_64) { + struct segment_command_64 segment; + if (command_size < sizeof(segment)) { + return 0; } - - int nsects = cmd->nsects; - struct section* sec = (struct section*)( - (void*)cmd + sizeof(struct segment_command) - ); - for (int j = 0; j < nsects; j++) { - if (strcmp(sec[j].sectname, section) == 0) { - return base + sec[j].addr - vmaddr; + memcpy(&segment, cursor, sizeof(segment)); + if (segment.nsects > + (command_size - sizeof(segment)) / sizeof(struct section_64)) + { + return 0; + } + /* __PAGEZERO has no file contents and does not define the slide. */ + if (segment.fileoff == 0 && segment.filesize != 0) { + header_address = segment.vmaddr; + have_header = 1; + } + if (strncmp(segment.segname, "__DATA", MACHO_NAME_SIZE) == 0) { + const unsigned char *record = cursor + sizeof(segment); + for (uint32_t item = 0; item < segment.nsects; + item++, record += sizeof(struct section_64)) + { + struct section_64 section; + memcpy(§ion, record, sizeof(section)); + if (strncmp(section.sectname, name, MACHO_NAME_SIZE) == 0) { + section_address = section.addr; + have_section = 1; + } } } - cmd_cnt++; } - - cmd = (struct segment_command*)((void*)cmd + cmd->cmdsize); - } - - return 0; -} - -static uintptr_t -return_section_address_fat( - const char* section, - mach_port_t proc_ref, - uintptr_t base, - void* map -) { - struct fat_header* fat_hdr = (struct fat_header*)map; - - // Determine host CPU type for architecture selection - cpu_type_t cpu; - int is_abi64; - size_t cpu_size = sizeof(cpu), abi64_size = sizeof(is_abi64); - - if (sysctlbyname("hw.cputype", &cpu, &cpu_size, NULL, 0) != 0) { - int err = errno; - _set_debug_oserror_from_errno(err, - "Failed to determine CPU type via sysctlbyname " - "for fat binary analysis at 0x%lx: %s", - base, strerror(err)); - return 0; + cursor += command_size; + remaining -= command_size; } - if (sysctlbyname("hw.cpu64bit_capable", &is_abi64, &abi64_size, NULL, 0) != 0) { - int err = errno; - _set_debug_oserror_from_errno(err, - "Failed to determine CPU ABI capability via sysctlbyname " - "for fat binary analysis at 0x%lx: %s", - base, strerror(err)); + if (!have_header || !have_section || section_address < header_address || + section_address - header_address > UINTPTR_MAX - base) + { return 0; } - - cpu |= is_abi64 * CPU_ARCH_ABI64; - - // Check endianness - int swap = fat_hdr->magic == FAT_CIGAM; - struct fat_arch* arch = (struct fat_arch*)(map + sizeof(struct fat_header)); - - // Get number of architectures in fat binary - uint32_t nfat_arch = swap ? __builtin_bswap32(fat_hdr->nfat_arch) : fat_hdr->nfat_arch; - - // Search for matching architecture - for (uint32_t i = 0; i < nfat_arch; i++) { - cpu_type_t arch_cpu = swap ? __builtin_bswap32(arch[i].cputype) : arch[i].cputype; - - if (arch_cpu == cpu) { - // Found matching architecture, now process it - uint32_t offset = swap ? __builtin_bswap32(arch[i].offset) : arch[i].offset; - struct mach_header_64* hdr = (struct mach_header_64*)(map + offset); - - // Determine which type of Mach-O it is and process accordingly - switch (hdr->magic) { - case MH_MAGIC: - case MH_CIGAM: - return return_section_address32(section, proc_ref, base, (void*)hdr); - - case MH_MAGIC_64: - case MH_CIGAM_64: - return return_section_address64(section, proc_ref, base, (void*)hdr); - - default: - PyErr_Format(PyExc_RuntimeError, - "Unknown Mach-O magic number 0x%x in fat binary architecture %u at base 0x%lx", - hdr->magic, i, base); - return 0; - } - } - } - - PyErr_Format(PyExc_RuntimeError, - "No matching architecture found for CPU type 0x%x " - "in fat binary at base 0x%lx (%u architectures examined)", - cpu, base, nfat_arch); - return 0; + return base + (uintptr_t)(section_address - header_address); } static uintptr_t -search_section_in_file(const char* secname, char* path, uintptr_t base, mach_vm_size_t size, mach_port_t proc_ref) +search_section_in_memory(proc_handle_t *handle, uintptr_t base, + const char *section) { - int fd = open(path, O_RDONLY); - if (fd == -1) { - int err = errno; - _set_debug_oserror_from_errno_with_filename(err, path, - "Cannot open binary file '%s' for section '%s' search: %s", - path, secname, strerror(err)); - return 0; + /* Most images fit in one read. Stay within the smallest macOS page size. */ + unsigned char prefix[4096]; + size_t prefix_size = sizeof(prefix) - base % sizeof(prefix); + struct mach_header_64 header; + if (prefix_size < sizeof(header) || + _Py_RemoteDebug_ReadRemoteMemory(handle, base, prefix_size, prefix) < 0) + { + if (_Py_RemoteDebug_IsFatalReadError()) { + return 0; + } + PyErr_Clear(); + prefix_size = sizeof(header); + if (_Py_RemoteDebug_ReadRemoteMemory(handle, base, prefix_size, prefix) < 0) { + return 0; + } } - - struct stat fs; - if (fstat(fd, &fs) == -1) { - int err = errno; - _set_debug_oserror_from_errno_with_filename(err, path, - "Cannot get file size for binary '%s' during section '%s' search: %s", - path, secname, strerror(err)); - close(fd); + memcpy(&header, prefix, sizeof(header)); + if (header.magic != MH_MAGIC_64 || + header.sizeofcmds > MACHO_MAX_LOAD_COMMAND_BYTES) + { return 0; } - - void* map = mmap(0, fs.st_size, PROT_READ, MAP_SHARED, fd, 0); - if (map == MAP_FAILED) { - int err = errno; - _set_debug_oserror_from_errno_with_filename(err, path, - "Cannot memory map binary file '%s' (size: %lld bytes) for section '%s' search: %s", - path, (long long)fs.st_size, secname, strerror(err)); - close(fd); + size_t size = sizeof(header) + header.sizeofcmds; + if (base > UINTPTR_MAX - size) { return 0; } - - uintptr_t result = 0; - uint32_t magic = *(uint32_t*)map; - - switch (magic) { - case MH_MAGIC: - case MH_CIGAM: - result = return_section_address32(secname, proc_ref, base, map); - break; - case MH_MAGIC_64: - case MH_CIGAM_64: - result = return_section_address64(secname, proc_ref, base, map); - break; - case FAT_MAGIC: - case FAT_CIGAM: - result = return_section_address_fat(secname, proc_ref, base, map); - break; - default: - PyErr_Format(PyExc_RuntimeError, - "Unrecognized Mach-O magic number 0x%x in binary file '%s' for section '%s' search", - magic, path, secname); - break; + if (size <= prefix_size) { + return macho_section_address(prefix, size, base, section); } - - if (munmap(map, fs.st_size) != 0) { - if (!PyErr_Occurred()) { - int err = errno; - _set_debug_oserror_from_errno_with_filename(err, path, - "Failed to unmap binary file '%s' (size: %lld bytes): %s", - path, (long long)fs.st_size, strerror(err)); - } - result = 0; + unsigned char *image = PyMem_Malloc(size); + if (image == NULL) { + PyErr_NoMemory(); + return 0; } - if (close(fd) != 0) { - if (!PyErr_Occurred()) { - int err = errno; - _set_debug_oserror_from_errno_with_filename(err, path, - "Failed to close binary file '%s': %s", - path, strerror(err)); - } - result = 0; + memcpy(image, prefix, prefix_size); + uintptr_t result = 0; + if (_Py_RemoteDebug_ReadRemoteMemory(handle, base + prefix_size, + size - prefix_size, image + prefix_size) == 0) + { + result = macho_section_address(image, size, base, section); } + PyMem_Free(image); return result; } - static mach_port_t pid_to_task(pid_t pid) { @@ -579,86 +431,166 @@ pid_to_task(pid_t pid) return task; } -static uintptr_t -search_map_for_section(proc_handle_t *handle, const char* secname, const char* substr, - section_validator_t validator) { - mach_vm_address_t address = 0; - mach_vm_size_t size = 0; - mach_msg_type_number_t count = sizeof(vm_region_basic_info_data_64_t); - vm_region_basic_info_data_64_t region_info; - mach_port_t object_name; - - mach_port_t proc_ref = pid_to_task(handle->pid); - if (proc_ref == 0) { - if (!PyErr_Occurred()) { - PyErr_Format(PyExc_PermissionError, - "Cannot get task port for PID %d during section search", - handle->pid); - } - return 0; +static int +read_dyld_image_metadata(proc_handle_t *handle, struct dyld_all_image_infos *images) +{ + task_dyld_info_data_t info = {0}; + mach_msg_type_number_t count = TASK_DYLD_INFO_COUNT; + kern_return_t status = task_info(handle->task, TASK_DYLD_INFO, + (task_info_t)&info, &count); + if (status != KERN_SUCCESS) { + PyErr_Format(status == KERN_PROTECTION_FAILURE + ? PyExc_PermissionError : PyExc_RuntimeError, + "Cannot read dyld information for PID %d (Mach error %d)", + handle->pid, status); + return -1; } - - char map_filename[MAXPATHLEN + 1]; - - kern_return_t kr; - while ((kr = mach_vm_region( - proc_ref, - &address, - &size, - VM_REGION_BASIC_INFO_64, - (vm_region_info_t)®ion_info, - &count, - &object_name)) == KERN_SUCCESS) + if (count < TASK_DYLD_INFO_COUNT || + info.all_image_info_format != TASK_DYLD_ALL_IMAGE_INFO_64) + { + PyErr_SetString(PyExc_RuntimeError, "Unsupported dyld image-info format"); + return -1; + } + size_t uuid_end = offsetof(struct dyld_all_image_infos, uuidArray) + + sizeof(images->uuidArray); + size_t size = (size_t)Py_MIN(info.all_image_info_size, uuid_end); + if (size < offsetof(struct dyld_all_image_infos, infoArray) + + sizeof(images->infoArray) || + info.all_image_info_addr > UINTPTR_MAX - size) + { + PyErr_SetString(PyExc_RuntimeError, "Invalid dyld image information"); + return -1; + } + if (_Py_RemoteDebug_ReadRemoteMemory(handle, info.all_image_info_addr, + size, images) < 0) { + return -1; + } + /* The UUID array was added in version 8 of dyld_all_image_infos. */ + if (images->version < 8 || size < uuid_end) { + images->uuidArray = NULL; + images->uuidArrayCount = 0; + } + return 0; +} - if ((region_info.protection & VM_PROT_READ) == 0 - || (region_info.protection & VM_PROT_EXECUTE) == 0) { - address += size; - continue; +static uintptr_t +search_memory_regions_for_section(proc_handle_t *handle, const char *section, + section_validator_t validator) +{ + mach_vm_address_t address = 0; + while (1) { + mach_vm_size_t size = 0; + vm_region_basic_info_data_64_t region; + mach_msg_type_number_t count = VM_REGION_BASIC_INFO_COUNT_64; + mach_port_t object = MACH_PORT_NULL; + kern_return_t status = mach_vm_region( + handle->task, &address, &size, VM_REGION_BASIC_INFO_64, + (vm_region_info_t)®ion, &count, &object); + if (object != MACH_PORT_NULL) { + mach_port_deallocate(mach_task_self(), object); } - - int path_len = proc_regionfilename( - handle->pid, address, map_filename, MAXPATHLEN); - if (path_len == 0) { - address += size; - continue; + if (status == KERN_INVALID_ADDRESS) { + return 0; } - - char* filename = strrchr(map_filename, '/'); - if (filename != NULL) { - filename++; // Move past the '/' - } else { - filename = map_filename; // No path, use the whole string + if (status != KERN_SUCCESS) { + PyErr_Format(status == KERN_PROTECTION_FAILURE + ? PyExc_PermissionError : PyExc_RuntimeError, + "Cannot read memory regions for PID %d (Mach error %d)", + handle->pid, status); + return 0; } - - if (strncmp(filename, substr, strlen(substr)) == 0) { - PyErr_Clear(); - uintptr_t result = search_section_in_file( - secname, map_filename, address, size, proc_ref); - if (result != 0) { - if (validator == NULL || validator(handle, result)) { - return result; - } - if (_Py_RemoteDebug_HasPermissionError()) { - return 0; - } + vm_prot_t required = VM_PROT_READ | VM_PROT_EXECUTE; + if ((region.protection & required) == required) { + uintptr_t candidate = search_section_in_memory(handle, address, section); + if (candidate != 0 && (validator == NULL || validator(handle, candidate))) { + return candidate; } - else if (_Py_RemoteDebug_HasPermissionError()) { + if (_Py_RemoteDebug_IsFatalReadError()) { return 0; } + PyErr_Clear(); + } + if (size == 0 || size > UINT64_MAX - address) { + return 0; } - address += size; } +} - if (kr != KERN_INVALID_ADDRESS && !PyErr_Occurred()) { - PyErr_Format(PyExc_RuntimeError, - "mach_vm_region failed while searching PID %d for section '%s' " - "(kern_return_t: %d)", - handle->pid, secname, kr); +static uintptr_t +search_dyld_image_array(proc_handle_t *handle, uintptr_t array_address, + size_t count, size_t record_size, + const char *section, section_validator_t validator) +{ + if (array_address == 0 || count == 0 || count > DYLD_MAX_IMAGE_COUNT || + array_address > UINTPTR_MAX - count * record_size) + { + return 0; } + size_t size = count * record_size; + unsigned char *images = PyMem_Malloc(size); + if (images == NULL) { + PyErr_NoMemory(); + return 0; + } + uintptr_t result = 0; + if (_Py_RemoteDebug_ReadRemoteMemory(handle, array_address, size, images) < 0) { + goto done; + } + for (size_t index = 0; index < count; index++) { + /* Both dyld_image_info and dyld_uuid_info begin with imageLoadAddress. */ + uintptr_t address; + memcpy(&address, images + index * record_size, sizeof(address)); + if (address == 0) { + continue; + } + uintptr_t candidate = search_section_in_memory(handle, address, section); + if (candidate != 0 && (validator == NULL || validator(handle, candidate))) { + result = candidate; + break; + } + if (_Py_RemoteDebug_IsFatalReadError()) { + break; + } + /* A library can unload after the image list is read. */ + PyErr_Clear(); + } +done: + PyMem_Free(images); + if (!_Py_RemoteDebug_IsFatalReadError()) { + PyErr_Clear(); + } + return result; +} - return 0; +static uintptr_t +search_loaded_images_for_section(proc_handle_t *handle, const char *section, + section_validator_t validator) +{ + struct dyld_all_image_infos images = {0}; + if (read_dyld_image_metadata(handle, &images) == 0) { + /* Python is normally outside the shared cache: try the shorter list. */ + uintptr_t result = search_dyld_image_array( + handle, (uintptr_t)images.uuidArray, images.uuidArrayCount, + sizeof(struct dyld_uuid_info), section, validator); + if (result != 0 || _Py_RemoteDebug_IsFatalReadError()) { + return result; + } + result = search_dyld_image_array( + handle, (uintptr_t)images.infoArray, images.infoArrayCount, + sizeof(struct dyld_image_info), section, validator); + if (result != 0 || _Py_RemoteDebug_IsFatalReadError()) { + return result; + } + } + if (_Py_RemoteDebug_IsFatalReadError()) { + return 0; + } + /* dyld can leave both lists unavailable while a stopped target is loading + a library. Treat copied lists as hints and fall back to mapped images. */ + PyErr_Clear(); + return search_memory_regions_for_section(handle, section, validator); } #endif // (__APPLE__ && defined(TARGET_OS_OSX) && TARGET_OS_OSX) @@ -1210,22 +1142,14 @@ _Py_RemoteDebug_GetPyRuntimeAddress(proc_handle_t* handle) } } #elif defined(__APPLE__) && defined(TARGET_OS_OSX) && TARGET_OS_OSX - // On macOS, try libpython first, then fall back to python - const char* candidates[] = {"libpython", "python", "Python", NULL}; - for (const char** candidate = candidates; *candidate; candidate++) { - PyErr_Clear(); - address = search_map_for_section(handle, "PyRuntime", *candidate, - _Py_RemoteDebug_ValidatePyRuntimeCookie); - if (address != 0 || _Py_RemoteDebug_HasPermissionError()) { - break; - } - } + address = search_loaded_images_for_section( + handle, "PyRuntime", _Py_RemoteDebug_ValidatePyRuntimeCookie); if (address == 0) { if (!_Py_RemoteDebug_HasPermissionError()) { PyObject *exc = PyErr_GetRaisedException(); PyErr_Format(PyExc_RuntimeError, "Failed to find the PyRuntime section in process %d " - "on macOS platform (tried both libpython and python)", + "on macOS platform", handle->pid); _PyErr_ChainExceptions1(exc); } @@ -1608,7 +1532,7 @@ _Py_RemoteDebug_PagedReadRemoteMemory(proc_handle_t *handle, // between profiler samples, so entries are packed at the front. for (int i = 0; i < handle->page_cache_count; i++) { page_cache_entry_t *entry = &handle->pages[i]; - if (entry->valid && entry->page_addr == page_base) { + if (entry->page_addr == page_base) { memcpy(out, entry->data + offset_in_page, size); return 0; } @@ -1635,7 +1559,6 @@ _Py_RemoteDebug_PagedReadRemoteMemory(proc_handle_t *handle, } entry->page_addr = page_base; - entry->valid = 1; handle->page_cache_count++; memcpy(out, entry->data + offset_in_page, size); return 0; @@ -1702,7 +1625,6 @@ _Py_RemoteDebug_ReadDebugOffsets( "Failed to locate PyRuntime address for PID %d", handle->pid); } - _set_debug_exception_cause(PyExc_RuntimeError, "PyRuntime address lookup failed during debug offsets initialization"); return -1; } size_t size = sizeof(struct _Py_DebugOffsets); diff --git a/Python/specialize.c b/Python/specialize.c index 773b55c329c7720..b5cf4ebc31142ab 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -3,6 +3,7 @@ #include "opcode.h" #include "pycore_bytesobject.h" // _PyBytes_Concat +#include "pycore_call.h" // _Py_METH_CALL_FLAGS #include "pycore_code.h" #include "pycore_critical_section.h" #include "pycore_descrobject.h" // _PyMethodWrapper_Type @@ -29,7 +30,7 @@ * InternalDocs/interpreter.md `Specialization` section. */ -#if Py_STATS +#ifdef Py_STATS #define SPECIALIZATION_FAIL(opcode, kind) \ do { \ PyStats *s = _PyStats_GET(); \ @@ -41,7 +42,7 @@ do { \ } while (0) #else # define SPECIALIZATION_FAIL(opcode, kind) ((void)0) -#endif // Py_STATS +#endif // !Py_STATS static void fixup_getiter(_Py_CODEUNIT *instruction, int flags) @@ -1010,7 +1011,7 @@ _Py_Specialize_LoadAttr(_PyStackRef owner_st, _Py_CODEUNIT *instr, PyObject *nam SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_OTHER); fail = true; } - else if (Py_TYPE(owner)->tp_getattro == PyModule_Type.tp_getattro) { + else if (PyModule_CheckExact(owner)) { fail = specialize_module_load_attr(owner, instr, name); } else if (PyType_Check(owner)) { @@ -1457,6 +1458,14 @@ _Py_Specialize_LoadGlobal( PyObject *globals, PyObject *builtins, _Py_CODEUNIT *instr, PyObject *name) { +#ifdef Py_GIL_DISABLED + if (PyMutex_IsLocked(&globals->ob_mutex) || PyMutex_IsLocked(&builtins->ob_mutex)) { + // Skip specialization if either dictionary is locked to avoid lock + // contention. + unspecialize(instr); + return; + } +#endif Py_BEGIN_CRITICAL_SECTION2(globals, builtins); specialize_load_global_lock_held(globals, builtins, instr, name); Py_END_CRITICAL_SECTION2(); @@ -1702,9 +1711,7 @@ static int specialize_method_descriptor(PyMethodDescrObject *descr, PyObject *self_or_null, _Py_CODEUNIT *instr, int nargs) { - switch (descr->d_method->ml_flags & - (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | - METH_KEYWORDS | METH_METHOD)) { + switch (descr->d_method->ml_flags & _Py_METH_CALL_FLAGS) { case METH_NOARGS: { if (nargs != 1) { SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); @@ -1824,9 +1831,7 @@ specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) SPECIALIZATION_FAIL(CALL, SPEC_FAIL_OTHER); return 1; } - switch (PyCFunction_GET_FLAGS(callable) & - (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | - METH_KEYWORDS | METH_METHOD)) { + switch (PyCFunction_GET_FLAGS(callable) & _Py_METH_CALL_FLAGS) { case METH_O: { if (nargs != 1) { SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); @@ -2340,7 +2345,7 @@ _Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *in assert(_PyOpcode_Caches[BINARY_OP] == INLINE_CACHE_ENTRIES_BINARY_OP); _PyBinaryOpCache *cache = (_PyBinaryOpCache *)(instr + 1); - if (instr->op.code == BINARY_OP_EXTEND) { + if (FT_ATOMIC_LOAD_UINT8_RELAXED(instr->op.code) == BINARY_OP_EXTEND) { write_ptr(cache->external_cache, NULL); } @@ -2946,7 +2951,8 @@ _Py_Specialize_GetIter(_PyStackRef iterable, _Py_CODEUNIT *instr) void _Py_Specialize_Resume(_Py_CODEUNIT *instr, PyThreadState *tstate, _PyInterpreterFrame *frame) { - if (tstate->tracing == 0 && instr->op.code == RESUME) { + if (tstate->tracing == 0 && + FT_ATOMIC_LOAD_UINT8_RELAXED(instr->op.code) == RESUME) { if (tstate->interp->jit) { PyCodeObject *co = (PyCodeObject *)PyStackRef_AsPyObjectBorrow(frame->f_executable); if (co != NULL && diff --git a/Python/stdlib_module_names.h b/Python/stdlib_module_names.h index 8937e666bbbdd5b..565be27b7cebda5 100644 --- a/Python/stdlib_module_names.h +++ b/Python/stdlib_module_names.h @@ -65,6 +65,7 @@ static const char* _Py_stdlib_module_names[] = { "_posixsubprocess", "_py_abc", "_py_warnings", +"_pybuiltins", "_pydatetime", "_pydecimal", "_pyio", diff --git a/Python/symtable.c b/Python/symtable.c index e3e89ab403a607e..429c204dba29b94 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -5,8 +5,10 @@ #include "pycore_runtime.h" // _Py_ID() #include "pycore_symtable.h" // PySTEntryObject #include "pycore_unicodeobject.h" // _PyUnicode_EqualToASCIIString +#include "setobject.h" #include // offsetof() +#include // Set this to 1 to dump all symtables to stdout for debugging @@ -89,6 +91,12 @@ #define IS_ASYNC_DEF(st) ((st)->st_cur->ste_type == FunctionBlock && (st)->st_cur->ste_coroutine) +static int +ste_uses_fast_locals(PySTEntryObject *ste) +{ + return _PyST_IsFunctionLike(ste) || ste->ste_type == InlinedComprehensionBlock; +} + static PySTEntryObject * ste_new(struct symtable *st, identifier name, _Py_block_ty block, void *key, _Py_SourceLocation loc) @@ -128,14 +136,14 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block, if (st->st_cur != NULL && (st->st_cur->ste_nested || - _PyST_IsFunctionLike(st->st_cur))) + ste_uses_fast_locals(st->st_cur))) ste->ste_nested = 1; ste->ste_generator = 0; ste->ste_coroutine = 0; ste->ste_comprehension = NoComprehension; ste->ste_returns_value = 0; ste->ste_needs_class_closure = 0; - ste->ste_comp_inlined = 0; + ste->ste_parent = (block == InlinedComprehensionBlock) ? st->st_cur : NULL; ste->ste_comp_iter_target = 0; ste->ste_can_see_class_scope = 0; ste->ste_comp_iter_expr = 0; @@ -295,6 +303,7 @@ static void _dump_symtable(PySTEntryObject* ste, PyObject* prefix) case TypeVariableBlock: blocktype = "TypeVariableBlock"; break; case TypeAliasBlock: blocktype = "TypeAliasBlock"; break; case TypeParametersBlock: blocktype = "TypeParametersBlock"; break; + case InlinedComprehensionBlock: blocktype = "InlinedComprehensionBlock"; break; } const char *comptype = ""; switch (ste->ste_comprehension) { @@ -308,7 +317,7 @@ static void _dump_symtable(PySTEntryObject* ste, PyObject* prefix) ( "%U=== Symtable for %U ===\n" "%U%s%s\n" - "%U%s%s%s%s%s%s%s%s%s%s%s\n" + "%U%s%s%s%s%s%s%s%s%s%s\n" "%Ulineno: %d col_offset: %d\n" "%U--- Symbols ---\n" ), @@ -326,7 +335,6 @@ static void _dump_symtable(PySTEntryObject* ste, PyObject* prefix) ste->ste_returns_value ? " returns_value" : "", ste->ste_needs_class_closure ? " needs_class_closure" : "", ste->ste_needs_classdict ? " needs_classdict" : "", - ste->ste_comp_inlined ? " comp_inlined" : "", ste->ste_comp_iter_target ? " comp_iter_target" : "", ste->ste_can_see_class_scope ? " can_see_class_scope" : "", prefix, @@ -353,7 +361,6 @@ static void _dump_symtable(PySTEntryObject* ste, PyObject* prefix) if (flags & DEF_ANNOT) printf(" DEF_ANNOT"); if (flags & DEF_COMP_ITER) printf(" DEF_COMP_ITER"); if (flags & DEF_TYPE_PARAM) printf(" DEF_TYPE_PARAM"); - if (flags & DEF_COMP_CELL) printf(" DEF_COMP_CELL"); switch (scope) { case LOCAL: printf(" LOCAL"); break; case GLOBAL_EXPLICIT: printf(" GLOBAL_EXPLICIT"); break; @@ -541,7 +548,7 @@ _PyST_GetSymbol(PySTEntryObject *ste, PyObject *name) if (PyDict_GetItemRef(ste->ste_symbols, name, &v) < 0) { return -1; } - if (!v) { + if (v == NULL) { return 0; } long symbol = PyLong_AsLong(v); @@ -575,6 +582,14 @@ _PyST_IsFunctionLike(PySTEntryObject *ste) || ste->ste_type == TypeParametersBlock; } +int +_PyST_IsClassClosureName(PyObject *name) +{ + return _PyUnicode_EqualToASCIIString(name, "__class__") + || _PyUnicode_EqualToASCIIString(name, "__classdict__") + || _PyUnicode_EqualToASCIIString(name, "__conditional_annotations__"); +} + static int error_at_directive(PySTEntryObject *ste, PyObject *name) { @@ -738,7 +753,9 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, // namespace and the globals (not the namespace providing the bound). // Similarly, if the name is explicitly global in the class namespace (through the // global statement), we want to also treat it as a global in this scope. - if (class_entry != NULL) { + // __classdict__ is the exception: these scopes load it from the cell that + // the class creates for them, whatever the class body does with that name. + if (class_entry != NULL && !_PyUnicode_Equal(name, &_Py_ID(__classdict__))) { long class_flags = _PyST_GetSymbol(class_entry, name); if (class_flags < 0) { return 0; @@ -784,12 +801,22 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, return 1; } +/* See InternalDocs/inlined_comprehensions.md. */ + static int is_free_in_any_child(PySTEntryObject *entry, PyObject *key) { for (Py_ssize_t i = 0; i < PyList_GET_SIZE(entry->ste_children); i++) { PySTEntryObject *child_ste = (PySTEntryObject *)PyList_GET_ITEM( entry->ste_children, i); + if (child_ste->ste_type == InlinedComprehensionBlock) { + /* this is the same scope, so we check its children */ + int nested = is_free_in_any_child(child_ste, key); + if (nested != 0) { + return nested; + } + continue; + } long scope = _PyST_GetScope(child_ste, key); if (scope < 0) { return -1; @@ -802,109 +829,115 @@ is_free_in_any_child(PySTEntryObject *entry, PyObject *key) } static int -inline_comprehension(PySTEntryObject *ste, PySTEntryObject *comp, - PyObject *scopes, PyObject *comp_free, - PyObject *inlined_cells) +symtable_add_flag(PyObject *dict, PyObject *name, int flag) +{ + PyObject *o = PyDict_GetItemWithError(dict, name); + long val; + if (o != NULL) { + val = PyLong_AsLong(o); + if (val == -1 && PyErr_Occurred()) { + return 0; + } + val |= flag; + } + else if (PyErr_Occurred()) { + return 0; + } + else { + val = flag; + } + o = PyLong_FromLong(val); + if (o == NULL) { + return 0; + } + int rc = PyDict_SetItem(dict, name, o); + Py_DECREF(o); + return rc >= 0; +} + +static int +finalize_inlined_comprehension(PySTEntryObject *ste, PySTEntryObject *comp, + PyObject *comp_free, PyObject *outer_newfree, + PyObject *inlined_cells) { PyObject *k, *v; Py_ssize_t pos = 0; - int remove_dunder_class = 0; - int remove_dunder_classdict = 0; - int remove_dunder_cond_annotations = 0; + + assert(comp->ste_type == InlinedComprehensionBlock); + assert(comp->ste_parent != NULL); while (PyDict_Next(comp->ste_symbols, &pos, &k, &v)) { - // skip comprehension parameter long comp_flags = PyLong_AsLong(v); if (comp_flags == -1 && PyErr_Occurred()) { - return 0; - } - if (comp_flags & DEF_PARAM) { - assert(_PyUnicode_EqualToASCIIString(k, ".0")); - continue; + goto error; } int scope = SYMBOL_TO_SCOPE(comp_flags); - int only_flags = comp_flags & ((1 << SCOPE_OFFSET) - 1); - if (scope == CELL || only_flags & DEF_COMP_CELL) { + if (scope == CELL) { if (PySet_Add(inlined_cells, k) < 0) { - return 0; + goto error; } } PyObject *existing = PyDict_GetItemWithError(ste->ste_symbols, k); if (existing == NULL && PyErr_Occurred()) { - return 0; + goto error; } - // __class__, __classdict__ and __conditional_annotations__ are - // not allowed to be free through a class scope (see - // drop_class_free) unless children scopes need it + // These names are not allowed to be free through a class (see + // drop_class_free) unless a nested child needs them. Keep FREE + // on this table; compile treats the load as a global. if (scope == FREE && ste->ste_type == ClassBlock && - (_PyUnicode_EqualToASCIIString(k, "__class__") || - _PyUnicode_EqualToASCIIString(k, "__classdict__") || - _PyUnicode_EqualToASCIIString(k, "__conditional_annotations__"))) { - scope = GLOBAL_IMPLICIT; + _PyST_IsClassClosureName(k)) { int child_needs_free = is_free_in_any_child(comp, k); if (child_needs_free < 0) { - return 0; + goto error; } if (!child_needs_free) { if (PySet_Discard(comp_free, k) < 0) { - return 0; + goto error; } } - if (_PyUnicode_EqualToASCIIString(k, "__class__")) { - remove_dunder_class = 1; - } - else if (_PyUnicode_EqualToASCIIString(k, "__conditional_annotations__")) { - remove_dunder_cond_annotations = 1; - } - else { - remove_dunder_classdict = 1; - } - } - if (!existing) { - // name does not exist in scope, copy from comprehension - assert(scope != FREE || PySet_Contains(comp_free, k) == 1); - PyObject *v_flags = PyLong_FromLong(only_flags); - if (v_flags == NULL) { - return 0; - } - int ok = PyDict_SetItem(ste->ste_symbols, k, v_flags); - Py_DECREF(v_flags); - if (ok < 0) { - return 0; - } - SET_SCOPE(scopes, k, scope); + continue; } - else { + int is_def_bound = 0; + if (existing) { long flags = PyLong_AsLong(existing); if (flags == -1 && PyErr_Occurred()) { - return 0; + goto error; } - if ((flags & DEF_BOUND) && ste->ste_type != ClassBlock) { - // free vars in comprehension that are locals in outer scope can - // now simply be locals, unless they are free in comp children, - // or if the outer scope is a class block - int ok = is_free_in_any_child(comp, k); - if (ok < 0) { - return 0; + is_def_bound = flags & DEF_BOUND; + } + // Loads here are in the enclosing compilation unit. + if (scope == FREE && (comp_flags & USE) && + !symtable_add_flag(ste->ste_symbols, k, USE)) { + goto error; + } + if (is_def_bound && ste->ste_type != ClassBlock) { + // free vars in comprehension that are locals in outer scope can + // now simply be locals, unless they are free in comp children, + // needed as cells by sibling nested scopes, or if the outer + // scope is a class block + int ok = is_free_in_any_child(comp, k); + if (ok < 0) { + goto error; + } + if (!ok) { + int in_newfree = PySet_Contains(outer_newfree, k); + if (in_newfree < 0) { + goto error; } - if (!ok) { + if (!in_newfree) { if (PySet_Discard(comp_free, k) < 0) { - return 0; + goto error; } } } } - } - if (remove_dunder_class && PyDict_DelItemString(comp->ste_symbols, "__class__") < 0) { - return 0; - } - if (remove_dunder_classdict && PyDict_DelItemString(comp->ste_symbols, "__classdict__") < 0) { - return 0; - } - if (remove_dunder_cond_annotations && PyDict_DelItemString(comp->ste_symbols, "__conditional_annotations__") < 0) { - return 0; + else if (!existing) { + assert(scope != FREE || PySet_Contains(comp_free, k) == 1); + } } return 1; +error: + return 0; } #undef SET_SCOPE @@ -992,7 +1025,7 @@ drop_class_free(PySTEntryObject *ste, PyObject *free) static int update_symbols(PyObject *symbols, PyObject *scopes, PyObject *bound, PyObject *free, - PyObject *inlined_cells, int classflag) + int classflag) { PyObject *name = NULL, *itr = NULL; PyObject *v = NULL, *v_scope = NULL, *v_new = NULL, *v_free = NULL; @@ -1004,13 +1037,6 @@ update_symbols(PyObject *symbols, PyObject *scopes, if (flags == -1 && PyErr_Occurred()) { return 0; } - int contains = PySet_Contains(inlined_cells, name); - if (contains < 0) { - return 0; - } - if (contains) { - flags |= DEF_COMP_CELL; - } if (PyDict_GetItemRef(scopes, name, &v_scope) < 0) { return 0; } @@ -1158,7 +1184,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, ClassBlocks, the bound and global names are initialized before analyzing names, because class bindings aren't visible in methods. For other blocks, they are initialized - after names are analyzed. + after this block's declarations are recorded. */ /* TODO(jhylton): Package these dicts in a struct so that we @@ -1176,7 +1202,6 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, inlined_cells = PySet_New(NULL); if (!inlined_cells) goto error; - /* Class namespace has no effect on names visible in nested functions, so populate the global and bound sets to be passed to child blocks before analyzing @@ -1197,11 +1222,17 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, } } + /* Record bindings and global/nonlocal declarations first so child + blocks see this scope's locals. Uses are classified after children + so inlined comprehensions can add USE flags to this table. */ while (PyDict_Next(ste->ste_symbols, &pos, &name, &v)) { long flags = PyLong_AsLong(v); if (flags == -1 && PyErr_Occurred()) { goto error; } + if (!(flags & (DEF_GLOBAL | DEF_NONLOCAL | DEF_BOUND))) { + continue; + } if (!analyze_name(ste, scopes, name, flags, bound, local, free, global, type_params, class_entry)) goto error; @@ -1210,7 +1241,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, /* Populate global and bound sets to be passed to children. */ if (ste->ste_type != ClassBlock) { /* Add function locals to bound set */ - if (_PyST_IsFunctionLike(ste)) { + if (ste_uses_fast_locals(ste)) { temp = PyNumber_InPlaceOr(newbound, local); if (!temp) goto error; @@ -1262,24 +1293,20 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, } } - // we inline all non-generator-expression comprehensions, - // except those in annotation scopes that are nested in classes - int inline_comp = - entry->ste_comprehension && - !entry->ste_generator && - !ste->ste_can_see_class_scope; - + // Finalize inlined children before classifying this block's uses + // and analyze_cells, so their loads are USE here and do not force + // a cell unless a real nested unit needs one. if (!analyze_child_block(entry, newbound, newfree, newglobal, type_params, new_class_entry, &child_free)) { goto error; } - if (inline_comp) { - if (!inline_comprehension(ste, entry, scopes, child_free, inlined_cells)) { + if (entry->ste_type == InlinedComprehensionBlock) { + if (!finalize_inlined_comprehension(ste, entry, child_free, newfree, + inlined_cells)) { Py_DECREF(child_free); goto error; } - entry->ste_comp_inlined = 1; } temp = PyNumber_InPlaceOr(newfree, child_free); Py_DECREF(child_free); @@ -1288,30 +1315,36 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, Py_DECREF(temp); } - /* Splice children of inlined comprehensions into our children list */ - for (i = PyList_GET_SIZE(ste->ste_children) - 1; i >= 0; --i) { - PyObject* c = PyList_GET_ITEM(ste->ste_children, i); - PySTEntryObject* entry; - assert(c && PySTEntry_Check(c)); - entry = (PySTEntryObject*)c; - if (entry->ste_comp_inlined && - PyList_SetSlice(ste->ste_children, i, i + 1, - entry->ste_children) < 0) - { + /* Complete the classification. */ + pos = 0; + while (PyDict_Next(ste->ste_symbols, &pos, &name, &v)) { + long flags = PyLong_AsLong(v); + if (flags == -1 && PyErr_Occurred()) { goto error; } + int contains = PyDict_Contains(scopes, name); + if (contains < 0) { + goto error; + } + if (contains) { + continue; + } + if (!analyze_name(ste, scopes, name, flags, + bound, local, free, global, type_params, class_entry)) + goto error; } /* Check if any local variables must be converted to cell variables */ - if (_PyST_IsFunctionLike(ste) && !analyze_cells(scopes, newfree, inlined_cells)) + if (ste_uses_fast_locals(ste) && !analyze_cells(scopes, newfree, inlined_cells)) { goto error; - else if (ste->ste_type == ClassBlock && !drop_class_free(ste, newfree)) + } + else if (ste->ste_type == ClassBlock && !drop_class_free(ste, newfree)) { goto error; + } /* Records the results of the analysis in the symbol table entry */ - if (!update_symbols(ste->ste_symbols, scopes, bound, newfree, inlined_cells, + if (!update_symbols(ste->ste_symbols, scopes, bound, newfree, (ste->ste_type == ClassBlock) || ste->ste_can_see_class_scope)) goto error; - temp = PyNumber_InPlaceOr(free, newfree); if (!temp) goto error; @@ -1455,6 +1488,7 @@ symtable_enter_existing_block(struct symtable *st, PySTEntryObject* ste, bool ad if (add_to_children && prev) { if (PyList_Append(prev->ste_children, (PyObject *)ste) < 0) { + symtable_exit_block(st); return 0; } } @@ -1466,21 +1500,27 @@ symtable_enter_block(struct symtable *st, identifier name, _Py_block_ty block, void *ast, _Py_SourceLocation loc) { PySTEntryObject *ste = ste_new(st, name, block, ast, loc); - if (ste == NULL) + if (ste == NULL) { return 0; + } int result = symtable_enter_existing_block(st, ste, /* add_to_children */true); Py_DECREF(ste); + if (result == 0) { + return 0; + } if (block == AnnotationBlock || block == TypeVariableBlock || block == TypeAliasBlock) { _Py_DECLARE_STR(format, ".format"); // We need to insert code that reads this "parameter" to the function. if (!symtable_add_def(st, &_Py_STR(format), DEF_PARAM, loc)) { + symtable_exit_block(st); return 0; } if (!symtable_add_def(st, &_Py_STR(format), USE, loc)) { + symtable_exit_block(st); return 0; } } - return result; + return 1; } static long @@ -1508,14 +1548,12 @@ symtable_add_def_helper(struct symtable *st, PyObject *name, int flag, struct _s _Py_SourceLocation loc) { PyObject *o; - PyObject *dict; - long val; + long val = 0; PyObject *mangled = _Py_MaybeMangle(st->st_private, st->st_cur, name); if (!mangled) return 0; - dict = ste->ste_symbols; - if ((o = PyDict_GetItemWithError(dict, mangled))) { + if ((o = PyDict_GetItemWithError(ste->ste_symbols, mangled))) { val = PyLong_AsLong(o); if (val == -1 && PyErr_Occurred()) { goto error; @@ -1531,62 +1569,40 @@ symtable_add_def_helper(struct symtable *st, PyObject *name, int flag, struct _s SET_ERROR_LOCATION(st->st_filename, loc); goto error; } - val |= flag; } else if (PyErr_Occurred()) { goto error; } - else { - val = flag; - } + + int to_add = flag; if (ste->ste_comp_iter_target) { /* This name is an iteration variable in a comprehension, * so check for a binding conflict with any named expressions. * Otherwise, mark it as an iteration variable so subsequent * named expressions can check for conflicts. */ - if (val & (DEF_GLOBAL | DEF_NONLOCAL)) { + if ((val | flag) & (DEF_GLOBAL | DEF_NONLOCAL)) { PyErr_Format(PyExc_SyntaxError, NAMED_EXPR_COMP_INNER_LOOP_CONFLICT, name); SET_ERROR_LOCATION(st->st_filename, loc); goto error; } - val |= DEF_COMP_ITER; + to_add |= DEF_COMP_ITER; } - o = PyLong_FromLong(val); - if (o == NULL) - goto error; - if (PyDict_SetItem(dict, mangled, o) < 0) { - Py_DECREF(o); + if (!symtable_add_flag(ste->ste_symbols, mangled, to_add)) { goto error; } - Py_DECREF(o); if (flag & DEF_PARAM) { if (PyList_Append(ste->ste_varnames, mangled) < 0) goto error; - } else if (flag & DEF_GLOBAL) { + } + else if (flag & DEF_GLOBAL) { /* XXX need to update DEF_GLOBAL for other flags too; perhaps only DEF_FREE_GLOBAL */ - val = 0; - if ((o = PyDict_GetItemWithError(st->st_global, mangled))) { - val = PyLong_AsLong(o); - if (val == -1 && PyErr_Occurred()) { - goto error; - } - } - else if (PyErr_Occurred()) { - goto error; - } - val |= flag; - o = PyLong_FromLong(val); - if (o == NULL) - goto error; - if (PyDict_SetItem(st->st_global, mangled, o) < 0) { - Py_DECREF(o); + if (!symtable_add_flag(st->st_global, mangled, flag)) { goto error; } - Py_DECREF(o); } Py_DECREF(mangled); return 1; @@ -1676,7 +1692,7 @@ symtable_enter_type_param_block(struct symtable *st, identifier name, if (current_type == ClassBlock) { st->st_cur->ste_can_see_class_scope = 1; if (!symtable_add_def(st, &_Py_ID(__classdict__), USE, loc)) { - return 0; + goto error; } } if (kind == ClassDef_kind) { @@ -1684,33 +1700,36 @@ symtable_enter_type_param_block(struct symtable *st, identifier name, // It gets "set" when we create the type params tuple and // "used" when we build up the bases. if (!symtable_add_def(st, &_Py_STR(type_params), DEF_LOCAL, loc)) { - return 0; + goto error; } if (!symtable_add_def(st, &_Py_STR(type_params), USE, loc)) { - return 0; + goto error; } // This is used for setting the generic base _Py_DECLARE_STR(generic_base, ".generic_base"); if (!symtable_add_def(st, &_Py_STR(generic_base), DEF_LOCAL, loc)) { - return 0; + goto error; } if (!symtable_add_def(st, &_Py_STR(generic_base), USE, loc)) { - return 0; + goto error; } } if (has_defaults) { _Py_DECLARE_STR(defaults, ".defaults"); if (!symtable_add_def(st, &_Py_STR(defaults), DEF_PARAM, loc)) { - return 0; + goto error; } } if (has_kwdefaults) { _Py_DECLARE_STR(kwdefaults, ".kwdefaults"); if (!symtable_add_def(st, &_Py_STR(kwdefaults), DEF_PARAM, loc)) { - return 0; + goto error; } } return 1; +error: + symtable_exit_block(st); + return 0; } /* VISIT, VISIT_SEQ and VISIT_SEQ_TAIL take an ASDL type as their second argument. @@ -2572,7 +2591,7 @@ symtable_visit_expr(struct symtable *st, expr_ty e) return 0; } if (!allows_top_level_await(st)) { - if (!_PyST_IsFunctionLike(st->st_cur)) { + if (!ste_uses_fast_locals(st->st_cur)) { PyErr_SetString(PyExc_SyntaxError, "'await' outside function"); SET_ERROR_LOCATION(st->st_filename, LOCATION(e)); @@ -2650,7 +2669,7 @@ symtable_visit_expr(struct symtable *st, expr_ty e) } /* Special-case super: it counts as a use of __class__ */ if (e->v.Name.ctx == Load && - _PyST_IsFunctionLike(st->st_cur) && + ste_uses_fast_locals(st->st_cur) && _PyUnicode_EqualToASCIIString(e->v.Name.id, "super")) { if (!symtable_add_def(st, &_Py_ID(__class__), USE, LOCATION(e))) return 0; @@ -3093,9 +3112,16 @@ symtable_handle_comprehension(struct symtable *st, expr_ty e, st->st_cur->ste_comp_iter_expr++; VISIT(st, expr, outermost->iter); st->st_cur->ste_comp_iter_expr--; + + /* Non-generator comprehensions are inlined into the enclosing compilation + * unit (including generator expressions), except in annotation scopes + * that can see a class. */ + int will_inline = !is_generator && !st->st_cur->ste_can_see_class_scope; + _Py_block_ty block = will_inline ? InlinedComprehensionBlock : FunctionBlock; + /* Create comprehension scope for the rest */ if (!scope_name || - !symtable_enter_block(st, scope_name, FunctionBlock, (void *)e, LOCATION(e))) { + !symtable_enter_block(st, scope_name, block, (void *)e, LOCATION(e))) { return 0; } switch(e->kind) { @@ -3116,8 +3142,8 @@ symtable_handle_comprehension(struct symtable *st, expr_ty e, st->st_cur->ste_coroutine = 1; } - /* Outermost iter is received as an argument */ - if (!symtable_implicit_arg(st, 0)) { + /* Outermost iter is received as an argument for non-inlined comps */ + if (!will_inline && !symtable_implicit_arg(st, 0)) { symtable_exit_block(st); return 0; } @@ -3247,7 +3273,7 @@ _Py_SymtableStringObjectFlags(const char *str, PyObject *filename, if (arena == NULL) return NULL; - mod = _PyParser_ASTFromString(str, filename, start, flags, arena, module); + mod = _PyParser_ASTFromString(str, filename, start, flags, arena, module, NULL); if (mod == NULL) { _PyArena_Free(arena); return NULL; diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 9442472b53abbe1..f8c72b096eb4529 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -64,6 +64,10 @@ extern const char *PyWin_DLLVersionString; # include #endif +#ifdef __wasi__ +# include +#endif + #ifdef HAVE_FCNTL_H # include #endif @@ -444,7 +448,7 @@ _PySys_ClearAuditHooks(PyThreadState *ts) runtime->audit_hooks.head = NULL; while (e) { n = e->next; - PyMem_RawFree(e); + free(e); e = n; } } @@ -492,7 +496,11 @@ PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData) } } - _Py_AuditHookEntry *e = (_Py_AuditHookEntry*)PyMem_RawMalloc( + /* Use malloc(), not PyMem_RawMalloc(): a hook can be added before + Py_Initialize(), and the entry is freed during finalization, after + PYTHONMALLOC may have changed the raw allocator (and, in debug builds, + the allocator under the debug hooks). */ + _Py_AuditHookEntry *e = (_Py_AuditHookEntry*)malloc( sizeof(_Py_AuditHookEntry)); if (!e) { if (tstate != NULL) { @@ -527,8 +535,8 @@ sys_addaudithook_impl(PyObject *module, PyObject *hook) /* Invoke existing audit hooks to allow them an opportunity to abort. */ if (_PySys_Audit(tstate, "sys.addaudithook", NULL) < 0) { - if (_PyErr_ExceptionMatches(tstate, PyExc_Exception)) { - /* We do not report errors derived from Exception */ + if (_PyErr_ExceptionMatches(tstate, PyExc_RuntimeError)) { + /* We do not report errors derived from RuntimeError */ _PyErr_Clear(tstate); Py_RETURN_NONE; } @@ -1435,19 +1443,20 @@ static PyStructSequence_Desc asyncgen_hooks_desc = { 2 }; -static PyObject * -sys_set_asyncgen_hooks(PyObject *self, PyObject *args, PyObject *kw) -{ - static char *keywords[] = {"firstiter", "finalizer", NULL}; - PyObject *firstiter = NULL; - PyObject *finalizer = NULL; +/*[clinic input] +sys.set_asyncgen_hooks - if (!PyArg_ParseTupleAndKeywords( - args, kw, "|OO", keywords, - &firstiter, &finalizer)) { - return NULL; - } + firstiter: object = NULL + finalizer: object = NULL + +Set a finalizer for async generators objects. +[clinic start generated code]*/ +static PyObject * +sys_set_asyncgen_hooks_impl(PyObject *module, PyObject *firstiter, + PyObject *finalizer) +/*[clinic end generated code: output=6fe3b2dd3f9a9db5 input=ef6a1e96361234be]*/ +{ if (finalizer && finalizer != Py_None) { if (!PyCallable_Check(finalizer)) { PyErr_Format(PyExc_TypeError, @@ -1493,12 +1502,6 @@ sys_set_asyncgen_hooks(PyObject *self, PyObject *args, PyObject *kw) return NULL; } -PyDoc_STRVAR(set_asyncgen_hooks_doc, -"set_asyncgen_hooks([firstiter] [, finalizer])\n\ -\n\ -Set a finalizer for async generators objects." -); - /*[clinic input] sys.get_asyncgen_hooks @@ -1633,6 +1636,7 @@ static PyStructSequence_Field windows_version_fields[] = { {"suite_mask", "Bit mask identifying available product suites"}, {"product_type", "System product type"}, {"platform_version", "Diagnostic version number"}, + {"device_family", "'Desktop', 'Xbox' or 'UWP'"}, {0} }; @@ -1645,13 +1649,10 @@ static PyStructSequence_Desc windows_version_desc = { via indexing, the rest are name only */ }; +#ifdef MS_WINDOWS_DESKTOP static PyObject * _sys_getwindowsversion_from_kernel32(void) { -#ifndef MS_WINDOWS_DESKTOP - PyErr_SetString(PyExc_OSError, "cannot read version info on this platform"); - return NULL; -#else HANDLE hKernel32; wchar_t kernel32_path[MAX_PATH]; LPVOID verblock; @@ -1688,8 +1689,8 @@ _sys_getwindowsversion_from_kernel32(void) realBuild = HIWORD(ffi->dwProductVersionLS); PyMem_RawFree(verblock); return Py_BuildValue("(kkk)", realMajor, realMinor, realBuild); -#endif /* !MS_WINDOWS_DESKTOP */ } +#endif /* MS_WINDOWS_DESKTOP */ /* Disable deprecation warnings about GetVersionEx as the result is being passed straight through to the caller, who is responsible for @@ -1719,7 +1720,6 @@ sys_getwindowsversion_impl(PyObject *module) { PyObject *version; int pos = 0; - OSVERSIONINFOEXW ver; if (PyObject_GetOptionalAttrString(module, "_cached_windows_version", &version) < 0) { return NULL; @@ -1729,6 +1729,8 @@ sys_getwindowsversion_impl(PyObject *module) } Py_XDECREF(version); + OSVERSIONINFOEXW ver; + ZeroMemory(&ver, sizeof(ver)); ver.dwOSVersionInfoSize = sizeof(ver); if (!GetVersionExW((OSVERSIONINFOW*) &ver)) return PyErr_SetFromWindowsErr(0); @@ -1756,6 +1758,7 @@ sys_getwindowsversion_impl(PyObject *module) SET_VERSION_INFO(PyLong_FromLong(ver.wSuiteMask)); SET_VERSION_INFO(PyLong_FromLong(ver.wProductType)); +#if defined(MS_WINDOWS_DESKTOP) // GetVersion will lie if we are running in a compatibility mode. // We need to read the version info from a system file resource // to accurately identify the OS version. If we fail for any reason, @@ -1775,6 +1778,14 @@ sys_getwindowsversion_impl(PyObject *module) } SET_VERSION_INFO(realVersion); + SET_VERSION_INFO(PyUnicode_FromString("Desktop")); +#elif defined(MS_WINDOWS_GAMES) + SET_VERSION_INFO(Py_BuildValue("(kkk)", ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber)); + SET_VERSION_INFO(PyUnicode_FromString("Xbox")); +#else + SET_VERSION_INFO(Py_BuildValue("(kkk)", ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber)); + SET_VERSION_INFO(PyUnicode_FromString("UWP")); +#endif #undef SET_VERSION_INFO @@ -1949,19 +1960,22 @@ _PySys_GetSizeOf(PyObject *o) return (size_t)size + presize; } +/*[clinic input] +sys.getsizeof + + object as o: object + default as dflt: object = NULL + +Return the size of object in bytes. +[clinic start generated code]*/ + static PyObject * -sys_getsizeof(PyObject *self, PyObject *args, PyObject *kwds) +sys_getsizeof_impl(PyObject *module, PyObject *o, PyObject *dflt) +/*[clinic end generated code: output=c9dee8179ae2a973 input=fd71e98f0e3ae131]*/ { - static char *kwlist[] = {"object", "default", 0}; size_t size; - PyObject *o, *dflt = NULL; PyThreadState *tstate = _PyThreadState_GET(); - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:getsizeof", - kwlist, &o, &dflt)) { - return NULL; - } - size = _PySys_GetSizeOf(o); if (size == (size_t)-1 && _PyErr_Occurred(tstate)) { @@ -1977,11 +1991,6 @@ sys_getsizeof(PyObject *self, PyObject *args, PyObject *kwds) return PyLong_FromSize_t(size); } -PyDoc_STRVAR(getsizeof_doc, -"getsizeof(object [, default]) -> int\n\ -\n\ -Return the size of object in bytes."); - /*[clinic input] sys.getrefcount -> Py_ssize_t @@ -2340,7 +2349,9 @@ sys_activate_stack_trampoline_impl(PyObject *module, const char *backend) { #ifdef PY_HAVE_PERF_TRAMPOLINE #ifdef _Py_JIT - if (_PyInterpreterState_GET()->jit) { + // Perf state is process-wide, and only the main interpreter can enable + // the JIT. Check it even when called from a subinterpreter (gh-157247). + if (_PyInterpreterState_Main()->jit) { PyErr_SetString(PyExc_ValueError, "Cannot activate the perf trampoline if the JIT is active"); return NULL; } @@ -2904,8 +2915,7 @@ static PyMethodDef sys_methods[] = { SYS_GETTOTALREFCOUNT_METHODDEF SYS_GETREFCOUNT_METHODDEF SYS_GETRECURSIONLIMIT_METHODDEF - {"getsizeof", _PyCFunction_CAST(sys_getsizeof), - METH_VARARGS | METH_KEYWORDS, getsizeof_doc}, + SYS_GETSIZEOF_METHODDEF SYS__GETFRAME_METHODDEF SYS__GETFRAMEMODULENAME_METHODDEF SYS_GETWINDOWSVERSION_METHODDEF @@ -2928,8 +2938,7 @@ static PyMethodDef sys_methods[] = { SYS__DEBUGMALLOCSTATS_METHODDEF SYS_SET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF SYS_GET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF - {"set_asyncgen_hooks", _PyCFunction_CAST(sys_set_asyncgen_hooks), - METH_VARARGS | METH_KEYWORDS, set_asyncgen_hooks_doc}, + SYS_SET_ASYNCGEN_HOOKS_METHODDEF SYS_GET_ASYNCGEN_HOOKS_METHODDEF SYS_GETANDROIDAPILEVEL_METHODDEF SYS_ACTIVATE_STACK_TRAMPOLINE_METHODDEF @@ -3836,6 +3845,49 @@ make_abi_info(void) } +#ifdef __wasi__ + +static PyObject * +make_wasi_info(void) +{ +#if defined(__wasip1__) + const char *wasi_version = "p1"; +#elif defined(__wasip2__) + const char *wasi_version = "p2"; +#elif defined(__wasip3__) + const char *wasi_version = "p3"; +#else +# error "Unknown WASI target version" +#endif + + // The SDK version is only defined for SDK builds of wasi-libc. +#ifdef __wasi_sdk_version__ + const char *wasi_sdk_version = __wasi_sdk_version__; +#else +# error "Unknown WASI SDK version" +#endif + +#ifdef __wasi_cooperative_threads__ + PyObject *cooperative_threads = Py_True; +#else + PyObject *cooperative_threads = Py_False; +#endif + + PyObject *wasi_info = Py_BuildValue( + "{s:s,s:s,s:O}", + "wasi_version", wasi_version, + "wasi_sdk_version", wasi_sdk_version, + "cooperative_threads", cooperative_threads); + if (wasi_info == NULL) { + return NULL; + } + PyObject *ns = _PyNamespace_New(wasi_info); + Py_DECREF(wasi_info); + return ns; +} + +#endif // __wasi__ + #ifdef __EMSCRIPTEN__ PyDoc_STRVAR(emscripten_info__doc__, @@ -3860,6 +3912,8 @@ static PyStructSequence_Desc emscripten_info_desc = { 4 }; +EM_JS_DEPS(_Py_emscripten_runtime, "$stringToNewUTF8") + EM_JS(char *, _Py_emscripten_runtime, (void), { var info; if (typeof process === "object") { @@ -4081,6 +4135,10 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict) SET_SYS("abi_info", make_abi_info()); +#ifdef __wasi__ + SET_SYS("_wasi_info", make_wasi_info()); +#endif + /* initialize asyncgen_hooks */ if (_PyStructSequence_InitBuiltin(interp, &AsyncGenHooksType, &asyncgen_hooks_desc) < 0) @@ -4103,6 +4161,8 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict) SET_SYS("path_importer_cache", PyDict_New()); SET_SYS("path_hooks", PyList_New(0)); + SET_SYS("_path0", Py_None); + if (_PyErr_Occurred(tstate)) { goto err_occurred; } @@ -4326,6 +4386,13 @@ _PySys_Create(PyThreadState *tstate, PyObject **sysmod_p) PyUnstable_Module_SetGIL(sysmod, Py_MOD_GIL_NOT_USED); #endif + if (PyModule_AddIntMacro(sysmod, EXIT_SUCCESS) < 0) { + goto error; + } + if (PyModule_AddIntMacro(sysmod, EXIT_FAILURE) < 0) { + goto error; + } + PyObject *sysdict = PyModule_GetDict(sysmod); if (sysdict == NULL) { goto error; @@ -4478,7 +4545,8 @@ make_sys_argv(int argc, wchar_t * const * argv) return list; } -void +// Function removed from Python 3.16 limited C API, but kept in the stable ABI +PyAPI_FUNC(void) PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath) { wchar_t* empty_argv[1] = {L""}; @@ -4525,13 +4593,18 @@ PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath) } } -void +// Function removed from Python 3.16 limited C API, but kept in the stable ABI +PyAPI_FUNC(void) PySys_SetArgv(int argc, wchar_t **argv) { -_Py_COMP_DIAG_PUSH -_Py_COMP_DIAG_IGNORE_DEPR_DECLS - PySys_SetArgvEx(argc, argv, Py_IsolatedFlag == 0); -_Py_COMP_DIAG_POP + int isolated = 0; + PyThreadState *tstate = PyThreadState_GetUnchecked(); + if (tstate != NULL) { + const PyConfig *config = &tstate->interp->config; + isolated = config->isolated; + } + + PySys_SetArgvEx(argc, argv, isolated == 0); } /* Reimplementation of PyFile_WriteString() no calling indirectly diff --git a/Python/thread_nt.h b/Python/thread_nt.h index 9a29d14ef67678d..086dab912ecfd71 100644 --- a/Python/thread_nt.h +++ b/Python/thread_nt.h @@ -11,142 +11,6 @@ #include #endif -/* options */ -#ifndef _PY_USE_CV_LOCKS -#define _PY_USE_CV_LOCKS 1 /* use locks based on cond vars */ -#endif - -/* Now, define a non-recursive mutex using either condition variables - * and critical sections (fast) or using operating system mutexes - * (slow) - */ - -#if _PY_USE_CV_LOCKS - -#include "condvar.h" - -typedef struct _NRMUTEX -{ - PyMUTEX_T cs; - PyCOND_T cv; - int locked; -} NRMUTEX; -typedef NRMUTEX *PNRMUTEX; - -static PNRMUTEX -AllocNonRecursiveMutex(void) -{ - PNRMUTEX m = (PNRMUTEX)PyMem_RawMalloc(sizeof(NRMUTEX)); - if (!m) - return NULL; - if (PyCOND_INIT(&m->cv)) - goto fail; - if (PyMUTEX_INIT(&m->cs)) { - PyCOND_FINI(&m->cv); - goto fail; - } - m->locked = 0; - return m; -fail: - PyMem_RawFree(m); - return NULL; -} - -static VOID -FreeNonRecursiveMutex(PNRMUTEX mutex) -{ - if (mutex) { - PyCOND_FINI(&mutex->cv); - PyMUTEX_FINI(&mutex->cs); - PyMem_RawFree(mutex); - } -} - -static DWORD -EnterNonRecursiveMutex(PNRMUTEX mutex, DWORD milliseconds) -{ - DWORD result = WAIT_OBJECT_0; - if (PyMUTEX_LOCK(&mutex->cs)) - return WAIT_FAILED; - if (milliseconds == INFINITE) { - while (mutex->locked) { - if (PyCOND_WAIT(&mutex->cv, &mutex->cs)) { - result = WAIT_FAILED; - break; - } - } - } else if (milliseconds != 0) { - /* wait at least until the deadline */ - PyTime_t timeout = (PyTime_t)milliseconds * (1000 * 1000); - PyTime_t deadline = _PyDeadline_Init(timeout); - while (mutex->locked) { - PyTime_t microseconds = _PyTime_AsMicroseconds(timeout, - _PyTime_ROUND_TIMEOUT); - if (PyCOND_TIMEDWAIT(&mutex->cv, &mutex->cs, microseconds) < 0) { - result = WAIT_FAILED; - break; - } - - timeout = _PyDeadline_Get(deadline); - if (timeout <= 0) { - break; - } - } - } - if (!mutex->locked) { - mutex->locked = 1; - result = WAIT_OBJECT_0; - } else if (result == WAIT_OBJECT_0) - result = WAIT_TIMEOUT; - /* else, it is WAIT_FAILED */ - PyMUTEX_UNLOCK(&mutex->cs); /* must ignore result here */ - return result; -} - -static BOOL -LeaveNonRecursiveMutex(PNRMUTEX mutex) -{ - BOOL result; - if (PyMUTEX_LOCK(&mutex->cs)) - return FALSE; - mutex->locked = 0; - /* condvar APIs return 0 on success. We need to return TRUE on success. */ - result = !PyCOND_SIGNAL(&mutex->cv); - PyMUTEX_UNLOCK(&mutex->cs); - return result; -} - -#else /* if ! _PY_USE_CV_LOCKS */ - -/* NR-locks based on a kernel mutex */ -#define PNRMUTEX HANDLE - -static PNRMUTEX -AllocNonRecursiveMutex(void) -{ - return CreateSemaphore(NULL, 1, 1, NULL); -} - -static VOID -FreeNonRecursiveMutex(PNRMUTEX mutex) -{ - /* No in-use check */ - CloseHandle(mutex); -} - -static DWORD -EnterNonRecursiveMutex(PNRMUTEX mutex, DWORD milliseconds) -{ - return WaitForSingleObjectEx(mutex, milliseconds, FALSE); -} - -static BOOL -LeaveNonRecursiveMutex(PNRMUTEX mutex) -{ - return ReleaseSemaphore(mutex, 1, NULL); -} -#endif /* _PY_USE_CV_LOCKS */ - unsigned long PyThread_get_thread_ident(void); #ifdef PY_HAVE_THREAD_NATIVE_ID diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h index 8496f91db2eec2b..c7f245acddb290c 100644 --- a/Python/thread_pthread.h +++ b/Python/thread_pthread.h @@ -18,7 +18,9 @@ #include #include /* pause(), also getthrid() on OpenBSD */ -#if defined(__linux__) +#ifdef _Py_HAVE_GETTID +# include // gettid() +#elif defined(__linux__) # include /* syscall(SYS_gettid) */ #elif defined(__FreeBSD__) # include /* pthread_getthreadid_np() */ @@ -229,7 +231,7 @@ pythread_wrapper(void *arg) pythread_callback *callback = arg; void (*func)(void *) = callback->func; void *func_arg = callback->arg; - PyMem_RawFree(arg); + free(callback); func(func_arg); return NULL; @@ -269,7 +271,9 @@ do_start_joinable_thread(void (*func)(void *), void *arg, pthread_t* out_id) pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM); #endif - pythread_callback *callback = PyMem_RawMalloc(sizeof(pythread_callback)); + // Use free() instead of PyMem_RawFree() in pythread_wrapper() to avoid a + // data race if another thread calls PyMem_SetAllocator() in parallel. + pythread_callback *callback = malloc(sizeof(pythread_callback)); if (callback == NULL) { return -1; @@ -291,7 +295,7 @@ do_start_joinable_thread(void (*func)(void *), void *arg, pthread_t* out_id) #endif if (status != 0) { - PyMem_RawFree(callback); + free(callback); return -1; } *out_id = th; @@ -380,6 +384,9 @@ PyThread_get_thread_native_id(void) #ifdef __APPLE__ uint64_t native_id; (void) pthread_threadid_np(NULL, &native_id); +#elif defined(_Py_HAVE_GETTID) + pid_t native_id; + native_id = gettid(); #elif defined(__linux__) pid_t native_id; native_id = syscall(SYS_gettid); @@ -399,8 +406,8 @@ PyThread_get_thread_native_id(void) lwpid_t native_id; native_id = _lwp_self(); #elif defined(__DragonFly__) - lwpid_t native_id; - native_id = lwp_gettid(); + // lwp_gettid() is only unique within a process, so combine it with the pid. + unsigned long native_id = (unsigned long)getpid() << 32 | lwp_gettid(); #elif defined(__sun__) && SIZEOF_LONG >= 8 unsigned long native_id = (unsigned long)getpid() << 32 | thr_self(); #endif diff --git a/Python/traceback.c b/Python/traceback.c index 5bfa28f9c7dc8b6..7e99dcb5a99249a 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -2,8 +2,9 @@ /* Traceback implementation */ #include "Python.h" -#include "pycore_call.h" // _PyObject_CallMethodFormat() +#include "pycore_call.h" // _PyObject_CallMethod() #include "pycore_fileutils.h" // _Py_BEGIN_SUPPRESS_IPH +#include "pycore_freelist.h" // _Py_FREELIST_POP() #include "pycore_frame.h" // PyFrameObject #include "pycore_interp.h" // PyInterpreterState.gc #include "pycore_interpframe.h" // _PyFrame_GetCode() @@ -12,6 +13,7 @@ #include "pycore_traceback.h" // EXCEPTION_TB_HEADER #include "frameobject.h" // PyFrame_New() +#include "../Parser/tokenizer/tokenizer.h" #include "osdefs.h" // SEP #ifdef HAVE_UNISTD_H @@ -57,9 +59,6 @@ #define MAX_FRAME_DEPTH 100 #define DEFAULT_MAX_NTHREADS 100 -/* Function from Parser/tokenizer/file_tokenizer.c */ -extern char* _PyTokenizer_FindEncodingFilename(int, PyObject *); - /*[clinic input] class traceback "PyTracebackObject *" "&PyTraceback_Type" [clinic start generated code]*/ @@ -81,15 +80,16 @@ tb_create_raw(PyTracebackObject *next, PyFrameObject *frame, int lasti, int lineno) { PyTracebackObject *tb; - if ((next != NULL && !PyTraceBack_Check(next)) || - frame == NULL || !PyFrame_Check(frame)) { - PyErr_BadInternalCall(); - return NULL; + assert(next == NULL || PyTraceBack_Check(next)); + assert(frame != NULL); + assert(PyFrame_Check(frame)); + tb = _Py_FREELIST_POP(PyTracebackObject, tracebacks); + if (tb == NULL) { + tb = PyObject_GC_New(PyTracebackObject, &PyTraceBack_Type); } - tb = PyObject_GC_New(PyTracebackObject, &PyTraceBack_Type); if (tb != NULL) { tb->tb_next = (PyTracebackObject*)Py_XNewRef(next); - tb->tb_frame = (PyFrameObject*)Py_XNewRef(frame); + tb->tb_frame = (PyFrameObject*)Py_NewRef(frame); tb->tb_lasti = lasti; tb->tb_lineno = lineno; PyObject_GC_Track(tb); @@ -183,11 +183,6 @@ static int traceback_tb_next_set_impl(PyTracebackObject *self, PyObject *value) /*[clinic end generated code: output=d4868cbc48f2adac input=ce66367f85e3c443]*/ { - if (!value) { - PyErr_Format(PyExc_TypeError, "can't delete tb_next attribute"); - return -1; - } - /* We accept None or a traceback object, and map None -> NULL (inverse of tb_next_get) */ if (value == Py_None) { @@ -244,7 +239,7 @@ tb_dealloc(PyObject *op) PyObject_GC_UnTrack(tb); Py_XDECREF(tb->tb_next); Py_XDECREF(tb->tb_frame); - PyObject_GC_Del(tb); + _Py_FREELIST_FREE(tracebacks, tb, PyObject_GC_Del); } static int @@ -404,7 +399,6 @@ _Py_FindSourceFile(PyObject *filename, char* namebuf, size_t namelen, PyObject * tail++; taillen = strlen(tail); - PyThreadState *tstate = _PyThreadState_GET(); if (PySys_GetOptionalAttr(&_Py_ID(path), &syspath) < 0) { PyErr_Clear(); goto error; @@ -444,7 +438,7 @@ _Py_FindSourceFile(PyObject *filename, char* namebuf, size_t namelen, PyObject * namebuf[len++] = SEP; strcpy(namebuf+len, tail); - binary = _PyObject_CallMethodFormat(tstate, open, "ss", namebuf, "rb"); + binary = PyObject_CallFunction(open, "ss", namebuf, "rb"); if (binary != NULL) { result = binary; goto finally; diff --git a/Python/tracemalloc.c b/Python/tracemalloc.c index 0afc84e021817cf..8ca2134921ff913 100644 --- a/Python/tracemalloc.c +++ b/Python/tracemalloc.c @@ -7,8 +7,9 @@ #include "pycore_lock.h" // PyMutex_LockFlags() #include "pycore_object.h" // _PyType_PreHeaderSize() #include "pycore_pymem.h" // _Py_tracemalloc_config +#include "pycore_pystate.h" // _PyInterpreterGuard_TryAcquire() #include "pycore_runtime.h" // _Py_ID() -#include "pycore_traceback.h" // _Py_DumpASCII() +#include "pycore_traceback.h" // _Py_DumpHexadecimal() #include // malloc() @@ -32,9 +33,10 @@ static int _PyTraceMalloc_TraceRef(PyObject *op, PyRefTracerEvent event, #define allocators _PyRuntime.tracemalloc.allocators -/* This lock is needed because tracemalloc_free() is called without - the GIL held from PyMem_RawFree(). It cannot acquire the lock because it - would introduce a deadlock in _PyThreadState_DeleteCurrent(). */ +/* This lock protects the trace tables. It is acquired by threads which may + not have an attached thread state, such as tracemalloc_free() called from + PyMem_RawFree(): tracing never acquires the GIL nor attaches a thread + state. */ #define tables_lock _PyRuntime.tracemalloc.tables_lock #define TABLES_LOCK() PyMutex_LockFlags(&tables_lock, _Py_LOCK_DONT_DETACH) #define TABLES_UNLOCK() PyMutex_Unlock(&tables_lock) @@ -45,6 +47,10 @@ static int _PyTraceMalloc_TraceRef(PyObject *op, PyRefTracerEvent event, typedef struct tracemalloc_frame frame_t; typedef struct tracemalloc_traceback traceback_t; +/* Filename used when the Python frame filename cannot be captured */ +static const char tracemalloc_unknown_filename[] = ""; +#define UNKNOWN_FILENAME tracemalloc_unknown_filename + #define TRACEBACK_SIZE(NFRAME) \ (sizeof(traceback_t) + sizeof(frame_t) * (NFRAME)) @@ -126,24 +132,19 @@ set_reentrant(int reentrant) static Py_uhash_t -hashtable_hash_pyobject(const void *key) +hashtable_hash_filename(const void *key) { - PyObject *obj = (PyObject *)key; - return PyObject_Hash(obj); + const char *filename = (const char *)key; + return (Py_uhash_t)Py_HashBuffer(filename, (Py_ssize_t)strlen(filename)); } static int -hashtable_compare_unicode(const void *key1, const void *key2) +hashtable_compare_filename(const void *key1, const void *key2) { - PyObject *obj1 = (PyObject *)key1; - PyObject *obj2 = (PyObject *)key2; - if (obj1 != NULL && obj2 != NULL) { - return (PyUnicode_Compare(obj1, obj2) == 0); - } - else { - return obj1 == obj2; - } + const char *filename1 = (const char *)key1; + const char *filename2 = (const char *)key2; + return (strcmp(filename1, filename2) == 0); } @@ -181,6 +182,100 @@ raw_free(void *ptr) } +/* Encode a str object to a NUL terminated UTF-8 (surrogatepass) string, + without using the Python C API. Return NULL on allocation failure. */ +static char * +tracemalloc_encode_filename(PyObject *obj) +{ + int kind = PyUnicode_KIND(obj); + const void *data = PyUnicode_DATA(obj); + Py_ssize_t length = PyUnicode_GET_LENGTH(obj); + + // worst case: 4 UTF-8 bytes per code point, plus the NUL terminator + if ((size_t)length > (SIZE_MAX - 1) / 4) { + return NULL; + } + char *buffer = raw_malloc((size_t)length * 4 + 1); + if (buffer == NULL) { + return NULL; + } + + char *p = buffer; + for (Py_ssize_t i = 0; i < length; i++) { + Py_UCS4 ch = PyUnicode_READ(kind, data, i); + if (ch < 0x80) { + *p++ = (char)ch; + } + else if (ch < 0x800) { + *p++ = (char)(0xc0 | (ch >> 6)); + *p++ = (char)(0x80 | (ch & 0x3f)); + } + else if (ch < 0x10000) { + *p++ = (char)(0xe0 | (ch >> 12)); + *p++ = (char)(0x80 | ((ch >> 6) & 0x3f)); + *p++ = (char)(0x80 | (ch & 0x3f)); + } + else { + *p++ = (char)(0xf0 | (ch >> 18)); + *p++ = (char)(0x80 | ((ch >> 12) & 0x3f)); + *p++ = (char)(0x80 | ((ch >> 6) & 0x3f)); + *p++ = (char)(0x80 | (ch & 0x3f)); + } + } + *p = '\0'; + return buffer; +} + + +/* Intern a str object in the tracemalloc_filenames hash table as a NUL + terminated UTF-8 string. Return NULL on allocation failure. + The caller must hold the TABLES_LOCK(). */ +static const char * +tracemalloc_intern_filename(PyObject *obj) +{ + assert(PyUnicode_Check(obj)); + + const char *utf8; + char *encoded = NULL; + if (PyUnicode_IS_COMPACT_ASCII(obj)) { + // ASCII string data is valid UTF-8 and is NUL terminated + utf8 = (const char *)PyUnicode_DATA(obj); + } + else { + encoded = tracemalloc_encode_filename(obj); + if (encoded == NULL) { + return NULL; + } + utf8 = encoded; + } + + const char *result; + _Py_hashtable_entry_t *entry; + entry = _Py_hashtable_get_entry(tracemalloc_filenames, utf8); + if (entry != NULL) { + result = (const char *)entry->key; + } + else { + size_t size = strlen(utf8) + 1; + char *filename = raw_malloc(size); + if (filename == NULL) { + raw_free(encoded); + return NULL; + } + memcpy(filename, utf8, size); + + if (_Py_hashtable_set(tracemalloc_filenames, filename, NULL) < 0) { + raw_free(filename); + raw_free(encoded); + return NULL; + } + result = filename; + } + raw_free(encoded); + return result; +} + + static Py_uhash_t hashtable_hash_traceback(const void *key) { @@ -209,8 +304,8 @@ hashtable_compare_traceback(const void *key1, const void *key2) if (frame1->lineno != frame2->lineno) { return 0; } + // Filenames are interned: compare by pointer if (frame1->filename != frame2->filename) { - assert(PyUnicode_Compare(frame1->filename, frame2->filename) != 0); return 0; } } @@ -222,7 +317,7 @@ static void tracemalloc_get_frame(_PyInterpreterFrame *pyframe, frame_t *frame) { assert(PyStackRef_CodeCheck(pyframe->f_executable)); - frame->filename = &_Py_STR(anon_unknown); + frame->filename = UNKNOWN_FILENAME; int lineno = -1; PyCodeObject *code = _PyFrame_GetCode(pyframe); @@ -253,26 +348,15 @@ tracemalloc_get_frame(_PyInterpreterFrame *pyframe, frame_t *frame) } /* intern the filename */ - _Py_hashtable_entry_t *entry; - entry = _Py_hashtable_get_entry(tracemalloc_filenames, filename); - if (entry != NULL) { - filename = (PyObject *)entry->key; - } - else { - /* tracemalloc_filenames is responsible to keep a reference - to the filename */ - if (_Py_hashtable_set(tracemalloc_filenames, Py_NewRef(filename), - NULL) < 0) { - Py_DECREF(filename); + const char *filename_copy = tracemalloc_intern_filename(filename); + if (filename_copy == NULL) { #ifdef TRACE_DEBUG - tracemalloc_error("failed to intern the filename"); + tracemalloc_error("failed to intern the filename"); #endif - return; - } + return; } - /* the tracemalloc_filenames table keeps a reference to the filename */ - frame->filename = filename; + frame->filename = filename_copy; } @@ -288,7 +372,8 @@ traceback_hash(traceback_t *traceback) x = 0x345678UL; frame = traceback->frames; while (--len >= 0) { - y = (Py_uhash_t)PyObject_Hash(frame->filename); + // Filenames are interned: hash the pointer + y = (Py_uhash_t)Py_HashPointer(frame->filename); y ^= (Py_uhash_t)frame->lineno; frame++; @@ -303,11 +388,8 @@ traceback_hash(traceback_t *traceback) static void -traceback_get_frames(traceback_t *traceback) +traceback_get_frames(traceback_t *traceback, PyThreadState *tstate) { - PyThreadState *tstate = _PyThreadState_GET(); - assert(tstate != NULL); - _PyInterpreterFrame *pyframe = _PyThreadState_GetFrame(tstate); while (pyframe) { if (traceback->nframe < tracemalloc_config.max_nframe) { @@ -329,13 +411,36 @@ traceback_new(void) traceback_t *traceback; _Py_hashtable_entry_t *entry; - _Py_AssertHoldsTstate(); + // Capturing a traceback needs a thread state to walk the frame stack, + // but the thread state doesn't need to be attached: only the thread + // itself pushes and pops its own frames, and no Python object is used + // or modified. If not attached (e.g. the GIL was released), fall back + // to the thread state most recently bound to the thread, if any. + int detached = 0; + PyInterpreterGuard guard = {NULL}; + PyThreadState *tstate = _PyThreadState_GET(); + if (tstate == NULL) { + if (_PyInterpreterGuard_TryAcquire(_PyInterpreterState_Main(), + &guard) < 0) { + return tracemalloc_empty_traceback; + } + detached = 1; + tstate = PyGILState_GetThisThreadState(); + if (tstate == NULL) { + // the thread never had a thread state: no frames to capture + _PyInterpreterGuard_Release(&guard); + return tracemalloc_empty_traceback; + } + } /* get frames */ traceback = tracemalloc_traceback; traceback->nframe = 0; traceback->total_nframe = 0; - traceback_get_frames(traceback); + traceback_get_frames(traceback, tstate); + if (detached) { + _PyInterpreterGuard_Release(&guard); + } if (traceback->nframe == 0) { return tracemalloc_empty_traceback; } @@ -497,8 +602,7 @@ tracemalloc_add_trace_unlocked(unsigned int domain, uintptr_t ptr, static void* -tracemalloc_alloc(int need_gil, int use_calloc, - void *ctx, size_t nelem, size_t elsize) +tracemalloc_alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize) { assert(elsize == 0 || nelem <= SIZE_MAX / elsize); @@ -506,12 +610,9 @@ tracemalloc_alloc(int need_gil, int use_calloc, // Ignore reentrant call. // - // For example, PyObjet_Malloc() calls + // For example, PyObject_Malloc() calls // PyMem_Malloc() for allocations larger than 512 bytes: don't trace the // same memory allocation twice. - // - // If reentrant calls are not ignored, PyGILState_Ensure() can call - // PyMem_RawMalloc() which would call PyGILState_Ensure() again in a loop. if (!reentrant) { set_reentrant(1); } @@ -532,10 +633,6 @@ tracemalloc_alloc(int need_gil, int use_calloc, goto done; } - PyGILState_STATE gil_state; - if (need_gil) { - gil_state = PyGILState_Ensure(); - } TABLES_LOCK(); if (tracemalloc_config.tracing) { @@ -548,9 +645,6 @@ tracemalloc_alloc(int need_gil, int use_calloc, // else: gh-128679: tracemalloc.stop() was called by another thread TABLES_UNLOCK(); - if (need_gil) { - PyGILState_Release(gil_state); - } done: if (!reentrant) { @@ -561,7 +655,7 @@ tracemalloc_alloc(int need_gil, int use_calloc, static void* -tracemalloc_realloc(int need_gil, void *ctx, void *ptr, size_t new_size) +tracemalloc_realloc(void *ctx, void *ptr, size_t new_size) { int reentrant = get_reentrant(); @@ -582,10 +676,6 @@ tracemalloc_realloc(int need_gil, void *ctx, void *ptr, size_t new_size) goto done; } - PyGILState_STATE gil_state; - if (need_gil) { - gil_state = PyGILState_Ensure(); - } TABLES_LOCK(); if (!tracemalloc_config.tracing) { @@ -610,8 +700,8 @@ tracemalloc_realloc(int need_gil, void *ctx, void *ptr, size_t new_size) // This case is very unlikely: a hash entry has just been released, // so the hash table should have at least one free entry. // - // The GIL and the table lock ensures that only one thread is - // allocating memory. + // The table lock ensures that no other thread touched the trace + // tables in the meantime. Py_FatalError("tracemalloc_realloc() failed to allocate a trace"); } } @@ -627,9 +717,6 @@ tracemalloc_realloc(int need_gil, void *ctx, void *ptr, size_t new_size) unlock: TABLES_UNLOCK(); - if (need_gil) { - PyGILState_Release(gil_state); - } done: if (!reentrant) { @@ -665,61 +752,22 @@ tracemalloc_free(void *ctx, void *ptr) static void* -tracemalloc_malloc_gil(void *ctx, size_t size) -{ - return tracemalloc_alloc(0, 0, ctx, 1, size); -} - - -static void* -tracemalloc_calloc_gil(void *ctx, size_t nelem, size_t elsize) -{ - return tracemalloc_alloc(0, 1, ctx, nelem, elsize); -} - - -static void* -tracemalloc_realloc_gil(void *ctx, void *ptr, size_t new_size) -{ - return tracemalloc_realloc(0, ctx, ptr, new_size); -} - - -static void* -tracemalloc_raw_malloc(void *ctx, size_t size) +tracemalloc_malloc(void *ctx, size_t size) { - return tracemalloc_alloc(1, 0, ctx, 1, size); + return tracemalloc_alloc(0, ctx, 1, size); } static void* -tracemalloc_raw_calloc(void *ctx, size_t nelem, size_t elsize) +tracemalloc_calloc(void *ctx, size_t nelem, size_t elsize) { - return tracemalloc_alloc(1, 1, ctx, nelem, elsize); -} - - -static void* -tracemalloc_raw_realloc(void *ctx, void *ptr, size_t new_size) -{ - return tracemalloc_realloc(1, ctx, ptr, new_size); -} - - -static void -tracemalloc_clear_filename(void *value) -{ - PyObject *filename = (PyObject *)value; - Py_DECREF(filename); + return tracemalloc_alloc(1, ctx, nelem, elsize); } static void tracemalloc_clear_traces_unlocked(void) { - // Clearing tracemalloc_filenames requires the GIL to call Py_DECREF() - _Py_AssertHoldsTstate(); - set_reentrant(1); _Py_hashtable_clear(tracemalloc_traces); @@ -745,9 +793,9 @@ _PyTraceMalloc_Init(void) return _PyStatus_NO_MEMORY(); } - tracemalloc_filenames = hashtable_new(hashtable_hash_pyobject, - hashtable_compare_unicode, - tracemalloc_clear_filename, NULL); + tracemalloc_filenames = hashtable_new(hashtable_hash_filename, + hashtable_compare_filename, + raw_free, NULL); tracemalloc_tracebacks = hashtable_new(hashtable_hash_traceback, hashtable_compare_traceback, @@ -770,8 +818,7 @@ _PyTraceMalloc_Init(void) tracemalloc_empty_traceback->nframe = 1; tracemalloc_empty_traceback->total_nframe = 1; - /* borrowed reference */ - tracemalloc_empty_traceback->frames[0].filename = &_Py_STR(anon_unknown); + tracemalloc_empty_traceback->frames[0].filename = UNKNOWN_FILENAME; tracemalloc_empty_traceback->frames[0].lineno = 0; tracemalloc_empty_traceback->hash = traceback_hash(tracemalloc_empty_traceback); @@ -829,20 +876,15 @@ _PyTraceMalloc_Start(int max_nframe) } PyMemAllocatorEx alloc; - alloc.malloc = tracemalloc_raw_malloc; - alloc.calloc = tracemalloc_raw_calloc; - alloc.realloc = tracemalloc_raw_realloc; + alloc.malloc = tracemalloc_malloc; + alloc.calloc = tracemalloc_calloc; + alloc.realloc = tracemalloc_realloc; alloc.free = tracemalloc_free; alloc.ctx = &allocators.raw; PyMem_GetAllocator(PYMEM_DOMAIN_RAW, &allocators.raw); PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &alloc); - alloc.malloc = tracemalloc_malloc_gil; - alloc.calloc = tracemalloc_calloc_gil; - alloc.realloc = tracemalloc_realloc_gil; - alloc.free = tracemalloc_free; - alloc.ctx = &allocators.mem; PyMem_GetAllocator(PYMEM_DOMAIN_MEM, &allocators.mem); PyMem_SetAllocator(PYMEM_DOMAIN_MEM, &alloc); @@ -898,17 +940,62 @@ _PyTraceMalloc_Stop(void) +/* Convert an interned filename to a str object. intern_filenames + (const char* => str object, can be NULL) shares the str objects. */ static PyObject* -frame_to_pyobject(frame_t *frame) +filename_to_pyobject(const char *filename, _Py_hashtable_t *intern_filenames) +{ + PyObject *filename_obj; + if (intern_filenames != NULL) { + filename_obj = _Py_hashtable_get(intern_filenames, filename); + if (filename_obj != NULL) { + return Py_NewRef(filename_obj); + } + } + + if (filename == UNKNOWN_FILENAME) { + filename_obj = Py_NewRef(&_Py_STR(anon_unknown)); + } + else { + filename_obj = PyUnicode_DecodeUTF8(filename, + (Py_ssize_t)strlen(filename), + "surrogatepass"); + if (filename_obj == NULL) { + return NULL; + } + } + + if (intern_filenames != NULL) { + if (_Py_hashtable_set(intern_filenames, filename, filename_obj) < 0) { + Py_DECREF(filename_obj); + PyErr_NoMemory(); + return NULL; + } + /* intern_filenames keeps a new reference to filename_obj */ + Py_INCREF(filename_obj); + } + return filename_obj; +} + + +static PyObject* +frame_to_pyobject(frame_t *frame, _Py_hashtable_t *intern_filenames) { assert(get_reentrant()); + PyObject *filename_obj = filename_to_pyobject(frame->filename, + intern_filenames); + if (filename_obj == NULL) { + return NULL; + } + PyObject *frame_obj = PyTuple_New(2); if (frame_obj == NULL) { + Py_DECREF(filename_obj); return NULL; } - PyTuple_SET_ITEM(frame_obj, 0, Py_NewRef(frame->filename)); + PyTuple_SET_ITEM(frame_obj, 0, filename_obj); PyObject *lineno_obj = PyLong_FromUnsignedLong(frame->lineno); if (lineno_obj == NULL) { @@ -922,7 +1009,8 @@ frame_to_pyobject(frame_t *frame) static PyObject* -traceback_to_pyobject(traceback_t *traceback, _Py_hashtable_t *intern_table) +traceback_to_pyobject(traceback_t *traceback, _Py_hashtable_t *intern_table, + _Py_hashtable_t *intern_filenames) { PyObject *frames; if (intern_table != NULL) { @@ -938,7 +1026,8 @@ traceback_to_pyobject(traceback_t *traceback, _Py_hashtable_t *intern_table) } for (int i=0; i < traceback->nframe; i++) { - PyObject *frame = frame_to_pyobject(&traceback->frames[i]); + PyObject *frame = frame_to_pyobject(&traceback->frames[i], + intern_filenames); if (frame == NULL) { Py_DECREF(frames); return NULL; @@ -961,7 +1050,8 @@ traceback_to_pyobject(traceback_t *traceback, _Py_hashtable_t *intern_table) static PyObject* trace_to_pyobject(unsigned int domain, const trace_t *trace, - _Py_hashtable_t *intern_tracebacks) + _Py_hashtable_t *intern_tracebacks, + _Py_hashtable_t *intern_filenames) { assert(get_reentrant()); @@ -984,7 +1074,8 @@ trace_to_pyobject(unsigned int domain, const trace_t *trace, } PyTuple_SET_ITEM(trace_obj, 1, obj); - obj = traceback_to_pyobject(trace->traceback, intern_tracebacks); + obj = traceback_to_pyobject(trace->traceback, intern_tracebacks, + intern_filenames); if (obj == NULL) { Py_DECREF(trace_obj); return NULL; @@ -1006,6 +1097,7 @@ typedef struct { _Py_hashtable_t *traces; _Py_hashtable_t *domains; _Py_hashtable_t *tracebacks; + _Py_hashtable_t *filenames; PyObject *list; unsigned int domain; } get_traces_t; @@ -1100,7 +1192,8 @@ tracemalloc_get_traces_fill(_Py_hashtable_t *traces, const trace_t *trace = (const trace_t *)value; PyObject *tuple = trace_to_pyobject(get_traces->domain, trace, - get_traces->tracebacks); + get_traces->tracebacks, + get_traces->filenames); if (tuple == NULL) { return 1; } @@ -1160,11 +1253,41 @@ tracemalloc_get_traceback_unlocked(unsigned int domain, uintptr_t ptr) #define PUTS(fd, str) (void)_Py_write_noraise(fd, str, (int)strlen(str)) +/* Dump an interned filename: write printable ASCII characters as-is, + escape the other bytes. The function is signal-safe. */ +static void +_PyMem_DumpFilename(int fd, const char *filename) +{ + const size_t max_length = 500; + size_t length = strlen(filename); + int truncated = 0; + if (length > max_length) { + length = max_length; + truncated = 1; + } + + for (size_t i = 0; i < length; i++) { + unsigned char ch = (unsigned char)filename[i]; + if (' ' <= ch && ch <= 126) { + /* printable ASCII character */ + char c = (char)ch; + (void)_Py_write_noraise(fd, &c, 1); + } + else { + PUTS(fd, "\\x"); + _Py_DumpHexadecimal(fd, ch, 2); + } + } + if (truncated) { + PUTS(fd, "..."); + } +} + static void _PyMem_DumpFrame(int fd, frame_t * frame) { PUTS(fd, " File \""); - _Py_DumpASCII(fd, frame->filename); + _PyMem_DumpFilename(fd, frame->filename); PUTS(fd, "\", line "); _Py_DumpDecimal(fd, frame->lineno); PUTS(fd, "\n"); @@ -1221,7 +1344,6 @@ PyTraceMalloc_Track(unsigned int domain, uintptr_t ptr, /* tracemalloc is not tracing: do nothing */ return -2; } - PyGILState_STATE gil_state = PyGILState_Ensure(); TABLES_LOCK(); int result; @@ -1234,7 +1356,6 @@ PyTraceMalloc_Track(unsigned int domain, uintptr_t ptr, } TABLES_UNLOCK(); - PyGILState_Release(gil_state); return result; } @@ -1324,7 +1445,7 @@ _PyTraceMalloc_GetTraceback(unsigned int domain, uintptr_t ptr) PyObject *result; if (traceback) { set_reentrant(1); - result = traceback_to_pyobject(traceback, NULL); + result = traceback_to_pyobject(traceback, NULL, NULL); set_reentrant(0); } else { @@ -1365,6 +1486,7 @@ _PyTraceMalloc_GetTraces(void) get_traces.traces = NULL; get_traces.domains = NULL; get_traces.tracebacks = NULL; + get_traces.filenames = NULL; get_traces.list = PyList_New(0); if (get_traces.list == NULL) { goto finally; @@ -1383,6 +1505,15 @@ _PyTraceMalloc_GetTraces(void) goto no_memory; } + /* the filename hash table is used temporarily to share filename + str objects between tracebacks */ + get_traces.filenames = hashtable_new(_Py_hashtable_hash_ptr, + _Py_hashtable_compare_direct, + NULL, tracemalloc_pyobject_decref); + if (get_traces.filenames == NULL) { + goto no_memory; + } + // Copy all traces so tracemalloc_get_traces_fill() doesn't have to disable // temporarily tracemalloc which would impact other threads and so would // miss allocations while get_traces() is called. @@ -1424,6 +1555,9 @@ _PyTraceMalloc_GetTraces(void) if (get_traces.tracebacks != NULL) { _Py_hashtable_destroy(get_traces.tracebacks); } + if (get_traces.filenames != NULL) { + _Py_hashtable_destroy(get_traces.filenames); + } if (get_traces.traces != NULL) { _Py_hashtable_destroy(get_traces.traces); } diff --git a/Python/typecache.c b/Python/typecache.c new file mode 100644 index 000000000000000..26079de5ce341f7 --- /dev/null +++ b/Python/typecache.c @@ -0,0 +1,246 @@ +// Per-type method cache implementation + +// The cache is used for method and attribute lookups on type objects. +// The stored names are always interned strings, and the +// stored values are borrowed references to the corresponding method or attribute object. +// For static types, the cache is stored on the per-interpreter managed_static_type_state, +// and for heap types the cache is stored in the `PyTypeObject._tp_cache` field. + +#include "Python.h" +#include "pycore_typecache.h" +#include "pycore_interp.h" // PyInterpreterState +#include "pycore_pymem.h" +#include "pycore_pystate.h" // _PyInterpreterState_GET() +#include "pycore_pyatomic_ft_wrappers.h" +#include "pycore_typeobject.h" // _PyStaticType_GetState() +#include "pycore_stats.h" // OBJECT_STAT_INC + + +// The empty cache is statically allocated and shared across all the types, +// when a type is modified, the cache of type is set to the empty cache +// and when a cache entry is inserted to the empty cache, a new cache is +// allocated for the type and the entry is inserted to the new cache. +static struct type_cache empty_cache = { + .mask = _Py_TYPECACHE_MINSIZE - 1, + .version_tag = 0, + .available = 0, + .used = 0, +}; + +static inline uint32_t +cache_size(struct type_cache *cache) +{ + return cache->mask + 1; +} + +static inline size_t +cache_nbytes(struct type_cache *cache) +{ + return offsetof(struct type_cache, hashtable) + + (size_t)cache_size(cache) * sizeof(struct type_cache_entry); +} + +static struct type_cache * +cache_allocate(uint32_t size) +{ + // size must be a power of two + assert((size & (size - 1)) == 0); + size_t nbytes = offsetof(struct type_cache, hashtable) + + (size_t)size * sizeof(struct type_cache_entry); + struct type_cache *cache = PyMem_Calloc(1, nbytes); + if (cache == NULL) { + return NULL; + } + cache->mask = size - 1; + // load factor of 0.75 + cache->available = size - (size >> 2); + cache->used = 0; + return cache; +} + +static void +cache_free_delayed(struct type_cache *cache) +{ + if (cache == NULL || cache == &empty_cache) { + return; + } +#ifndef Py_GIL_DISABLED + // On gil-enabled builds, the cache owns strong references to the interned strings, + // so we need to decref them before freeing the cache memory. + for (uint32_t i = 0; i < cache_size(cache); i++) { + if (cache->hashtable[i].name != NULL) { + Py_DECREF(cache->hashtable[i].name); + } + } +#endif + // Delay the freeing of old cache for concurrent lock-free readers + _PyMem_FreeDelayed(cache, cache_nbytes(cache)); +} + + +static inline void ** +cache_slot(PyTypeObject *type) +{ + if (type->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN) { + PyInterpreterState *interp = _PyInterpreterState_GET(); + managed_static_type_state *state = _PyStaticType_GetState(interp, type); + assert(state != NULL); + return &state->_tp_cache; + } + return &type->_tp_cache; +} + +static inline struct type_cache * +cache_get(PyTypeObject *type) +{ + return (struct type_cache *)FT_ATOMIC_LOAD_PTR_ACQUIRE(*cache_slot(type)); +} + +static inline void +cache_set(PyTypeObject *type, struct type_cache *cache) +{ + FT_ATOMIC_STORE_PTR_RELEASE(*cache_slot(type), cache); +} + +void +_PyTypeCache_InitType(PyTypeObject *type) +{ + *cache_slot(type) = &empty_cache; +} + +static inline void +cache_insert(struct type_cache *cache, PyObject *name, + PyObject *value) +{ + Py_hash_t hash = PyUnstable_Unicode_GET_CACHED_HASH(name); + assert(hash != -1); + uint32_t index = hash & cache->mask; + for (;;) { + if (cache->hashtable[index].name == NULL) { +#ifndef Py_GIL_DISABLED + // On free-threading, all interned strings are immortal. + Py_INCREF(name); +#endif + cache->hashtable[index].value = value; + FT_ATOMIC_STORE_PTR_RELEASE(cache->hashtable[index].name, name); + cache->used++; + cache->available--; + return; + } + else if (cache->hashtable[index].name == name) { + /* someone else added the entry before us. */ + return; + } + index = (index + 1) & cache->mask; + } +} + +static inline int +cache_resize(PyTypeObject *type, struct type_cache *cache) +{ + uint32_t old_size = cache_size(cache); + uint32_t new_size; + if (cache->used == 0) { + // the cache is the empty cache, we need to allocate a new cache with the minimum size + new_size = _Py_TYPECACHE_MINSIZE; + } + else { + // double the cache size when resizing + new_size = old_size * 2; + } + if (new_size > _Py_TYPECACHE_MAXSIZE) { + // The new size is too big, don't resize and just return. + OBJECT_STAT_INC(type_cache_too_big); + return -1; + } + struct type_cache *new_cache = cache_allocate(new_size); + if (new_cache == NULL) { + return -1; + } + OBJECT_STAT_INC(type_cache_resizes); + for (uint32_t i = 0; i < old_size; i++) { + if (cache->hashtable[i].name != NULL) { + cache_insert(new_cache, cache->hashtable[i].name, cache->hashtable[i].value); + } + } + new_cache->version_tag = type->tp_version_tag; + cache_set(type, new_cache); + cache_free_delayed(cache); + return 0; +} + +// Insert a new entry to the type cache. +// The TYPE_LOCK should be held while calling this function. +void +_PyTypeCache_Insert(PyTypeObject *type, PyObject *name, PyObject *value) +{ + struct type_cache *cache = cache_get(type); + // If the cache is full, resize it before inserting the new entry. + // this also handles the case of empty cache where available is 0 but there are no entries. + if (cache->available == 0) { + if (cache_resize(type, cache) == -1) { + // out of memory, don't cache the value + return; + } + cache = cache_get(type); + assert(cache->available > 0); + } + assert(cache->version_tag == type->tp_version_tag); + cache_insert(cache, name, value); +} + + +// Lookup the given name in the type cache. +// The cache is lock-free so it is possible that cache becomes stale during the lookup, +// to prevent returning stale cache entry, the cache version is compared with the type version tag. +struct _PyTypeCacheLookupResult +_PyTypeCache_Lookup(PyTypeObject *type, PyObject *name) +{ + assert(PyUnicode_CheckExact(name) && PyUnicode_CHECK_INTERNED(name)); + struct _PyTypeCacheLookupResult miss = {PyStackRef_NULL, 0, 0}; + struct type_cache *cache = cache_get(type); + if (cache == NULL) { + return miss; + } + Py_hash_t hash = PyUnstable_Unicode_GET_CACHED_HASH(name); + assert(hash != -1); + uint32_t index = hash & cache->mask; + _PyStackRef out_ref; + for (;;) { + PyObject *entry_name = FT_ATOMIC_LOAD_PTR_ACQUIRE(cache->hashtable[index].name); + if (entry_name == name) { +#ifdef Py_GIL_DISABLED + if (!_Py_TryXGetStackRef(&cache->hashtable[index].value, &out_ref)) { + return miss; + } +#else + PyObject *v = cache->hashtable[index].value; + out_ref = v ? PyStackRef_FromPyObjectNew(v) : PyStackRef_NULL; +#endif + break; + } + else if (entry_name == NULL) { + return miss; + } + index = (index + 1) & cache->mask; + } + // Check the cache version against the type version tag to maintain + // consistency with find_name_in_mro and prevent stale cache reads + if (cache->version_tag != FT_ATOMIC_LOAD_UINT_RELAXED(type->tp_version_tag)) { + PyStackRef_XCLOSE(out_ref); + return miss; + } + return (struct _PyTypeCacheLookupResult){out_ref, 1, cache->version_tag}; +} + +// Invalidate the type cache of the type. +// The cache is set to the empty cache and the old cache is freed with QSBR. +// The TYPE_LOCK should be held while calling this function. +void +_PyTypeCache_Invalidate(PyTypeObject *type) +{ + OBJECT_STAT_INC(type_cache_invalidations); + struct type_cache *cache = cache_get(type); + cache_set(type, &empty_cache); + cache_free_delayed(cache); +} diff --git a/Python/wasm_trampoline.c b/Python/wasm_trampoline.c new file mode 100644 index 000000000000000..ceef8e803387cc8 --- /dev/null +++ b/Python/wasm_trampoline.c @@ -0,0 +1,48 @@ +#if defined(__wasm__) && defined(PY_CALL_TRAMPOLINE) + +#include + +typedef PyObject* (*three_arg)(PyObject*, PyObject*, PyObject*); +typedef PyObject* (*two_arg)(PyObject*, PyObject*); +typedef PyObject* (*one_arg)(PyObject*); +typedef PyObject* (*zero_arg)(void); + +#define RETCALL_IF_SIG_MATCHES(ty, args...) \ + if (__builtin_wasm_test_function_pointer_signature((ty)func)) { \ + return ((ty)func)(args); \ + } + +PyObject* +_PyWasm_TrampolineCall(PyCFunctionWithKeywords func, + PyObject* self, + PyObject* args, + PyObject* kw) +{ + RETCALL_IF_SIG_MATCHES(three_arg, self, args, kw); + RETCALL_IF_SIG_MATCHES(two_arg, self, args); + RETCALL_IF_SIG_MATCHES(one_arg, self); + RETCALL_IF_SIG_MATCHES(zero_arg); + PyErr_SetString(PyExc_SystemError, "Handler has incorrect signature"); + return NULL; +} + +typedef int (*setter_three_arg)(PyObject*, PyObject*, void*); +typedef int (*setter_two_arg)(PyObject*, PyObject*); +typedef int (*setter_one_arg)(PyObject*); +typedef int (*setter_zero_arg)(void); + +int +_PyWasm_TrampolineCallSetter(setter func, + PyObject* self, + PyObject* val, + void* closure) +{ + RETCALL_IF_SIG_MATCHES(setter_three_arg, self, val, closure); + RETCALL_IF_SIG_MATCHES(setter_two_arg, self, val); + RETCALL_IF_SIG_MATCHES(setter_one_arg, self); + RETCALL_IF_SIG_MATCHES(setter_zero_arg); + PyErr_SetString(PyExc_SystemError, "Handler has incorrect signature"); + return -1; +} + +#endif // defined(__wasm__) && defined(PY_CALL_TRAMPOLINE) diff --git a/README.rst b/README.rst index 48f86cdb86ed1d2..b3058f63c27a120 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,5 @@ -This is Python version 3.16.0 alpha 0 -===================================== +This is Python version 3.16.0 alpha 2+dev +========================================= .. image:: https://github.com/python/cpython/actions/workflows/build.yml/badge.svg?branch=main&event=push :alt: CPython build status on GitHub Actions @@ -76,8 +76,8 @@ to macOS framework and universal builds. Refer to `Mac/README.rst On Windows, see `PCbuild/readme.txt `_. -To build Windows installer, see `Tools/msi/README.txt -`_. +To build Windows packages, see `PC/layout/README.md +`_. If you wish, you can create a subdirectory and invoke configure from there. For example:: @@ -91,7 +91,7 @@ For example:: (This will fail if you *also* built at the top-level directory. You should do a ``make clean`` at the top-level first.) -To get an optimized build of Python, ``configure --enable-optimizations`` +To get an optimized build of Python, run ``configure --enable-optimizations`` before you run ``make``. This sets the default make targets up to enable Profile Guided Optimization (PGO) and may be used to auto-enable Link Time Optimization (LTO) on some platforms. For more details, see the sections diff --git a/Tools/README b/Tools/README index 90acb2614820ee4..3984bce6b9b6768 100644 --- a/Tools/README +++ b/Tools/README @@ -34,10 +34,6 @@ jit Tooling for building the JIT. lockbench Benchmarks for PyMutex and critical sections. -msi Support for packaging Python as an MSI package on Windows. - -nuget Files for the NuGet package manager for .NET. - patchcheck Tools for checking and applying patches to the Python source code and verifying the integrity of patch files. diff --git a/Tools/build/check_capi_macros.py b/Tools/build/check_capi_macros.py new file mode 100755 index 000000000000000..86c433a11683487 --- /dev/null +++ b/Tools/build/check_capi_macros.py @@ -0,0 +1,172 @@ +#! /usr/bin/env python3 +""" +Check that all macros defined by the Python C API have a name starting with +"Py". Ignore names listed by check_capi_macros_ignored.txt: macros with an +invalid name, added before this script was created. + +Python C API: + +* Include/*.h +* Include/cpython/*.h +* pyconfig.h.in +""" + +import difflib +import glob +import os.path +import re +import sys + +EXCLUDE_HEADERS = { + # Header files not included by Python.h and ignored by this script + 'dynamic_annotations.h', + 'errcode.h', + 'opcode.h', + 'opcode_ids.h', + 'osdefs.h', + 'pyexpat.h', + 'structmember.h', + + # Header files not included by Python.h but parsed by this script: + # - datetime.h + # - frameobject.h + # - marshal.h + # - py_curses.h + # - pydtrace.h +} + +TOOLS_BUILD_DIR = os.path.abspath(os.path.dirname(__file__)) +SRC_DIR = os.path.dirname(os.path.dirname(TOOLS_BUILD_DIR)) +IGNORED_FILENAME = os.path.join(TOOLS_BUILD_DIR, 'check_capi_macros_ignored.txt') + +DEFINE_REGEX = re.compile(r'\s*#\s*(?Pdefine|undef)\s+(?P.*)') +PYTHON_PREFIX = re.compile(r'(Py|PY|_Py|_PY)') +NAME_REGEX = re.compile(r'([A-Za-z_][A-Za-z0-9_]*)\b') + +CAUSES_BY_DIRECTIVE = { + "define": "defined", + "undef": "undefined", +} + + +def parse_file(filename, names): + with open(filename, encoding='utf8') as fp: + for lineno, line in enumerate(fp, start=1): + # Check for '#define MACRO' + match = DEFINE_REGEX.match(line) + if not match: + continue + macro = match['macro'] + directive = match['directive'] + cause = CAUSES_BY_DIRECTIVE.get(directive, directive) + + if PYTHON_PREFIX.match(macro): + continue + + match = NAME_REGEX.match(macro) + if not match: + print(f"ERROR: {filename}: Unable to parse {line!r}") + sys.exit(1) + name = match[1] + names.append((name, filename, lineno, cause)) + + +def get_ignored_names(): + ignored = [] + with open(IGNORED_FILENAME, encoding='utf8') as fp: + for line in fp: + name = line.strip() + if name.startswith('#'): + # Ignore comment + continue + if name: + ignored.append(name) + return ignored + + +def main(): + failure = False + + # Parse header files + include_dir = os.path.join(SRC_DIR, 'Include') + files = glob.glob(os.path.join(include_dir, '*.h')) + files = [filename for filename in files + if os.path.basename(filename) not in EXCLUDE_HEADERS] + files.extend(glob.glob(os.path.join(include_dir, 'cpython', '*.h'))) + files.append(os.path.join(SRC_DIR, 'pyconfig.h.in')) + files.append(os.path.join(SRC_DIR, 'PC/pyconfig.h')) + names = [] # list of (name: str, filename: str, lineno: int, cause: str) + for filename in files: + parse_file(filename, names) + + # Parse ignore list + ignored = get_ignored_names() + + # Check if the sorted list has duplicated entries + if len(set(ignored)) != len(ignored): + print(f"ERROR: {IGNORED_FILENAME} list contains duplicated entries:") + print() + seen = set() + for name in ignored: + if name not in seen: + seen.add(name) + continue + print(f"- {name}") + print() + failure = True + + # Check if the sorted list is sorted + ignored_sorted = sorted(ignored) + if ignored_sorted != ignored: + print(f"ERROR: {IGNORED_FILENAME} list is not sorted") + print() + diff = difflib.unified_diff(ignored, ignored_sorted, + fromfile=IGNORED_FILENAME, + tofile=IGNORED_FILENAME, + lineterm='') + for line in diff: + print(line) + print() + failure = True + + # Check for outdated ignore list + names_set = {name for name, filename, lineno, cause in names} + ignored = set(ignored) + outdated = ignored - names_set + if outdated: + print(f"ERROR: {IGNORED_FILENAME} is outdated, " + "the following macros can be removed:") + print() + for name in sorted(outdated): + print(f"- {name}") + print() + print(f"Total: {len(outdated)} macros") + print() + failure = True + + # Check for new macros + new_macros = names_set - ignored + if new_macros: + print('ERROR: the Python C API defines the following new macros:') + print() + count = 0 + for name, filename, lineno, cause in sorted(names): + if name in ignored: + continue + print(f"- {name} {cause} at {filename}:{lineno}") + count += 1 + print() + print(f"Total: {count} macros") + failure = True + + if not failure: + print("OK: the ignore list is up to date and sorted") + print("OK: the Python C API only defines macros with names " + f"starting with Py (ignoring {len(ignored)} macros)") + sys.exit(0) + + sys.exit(1) + + +if __name__ == "__main__": + main() diff --git a/Tools/build/check_capi_macros_ignored.txt b/Tools/build/check_capi_macros_ignored.txt new file mode 100644 index 000000000000000..154f1dbfca039c9 --- /dev/null +++ b/Tools/build/check_capi_macros_ignored.txt @@ -0,0 +1,782 @@ +# Old C API macros with a name which doesn't start with "Py". If a macro +# is removed from the C API, it should be removed from this list as well. +# +# Adding a new macro to this ignore list requires the approval of the C API +# Working Group. Open an issue at: +# https://github.com/capi-workgroup/decisions/issues/ + +AC_APPLE_UNIVERSAL_BUILD +AIX_BUILDDATE +AIX_GENUINE_CPLUSPLUS +ALIGNOF_LONG +ALIGNOF_MAX_ALIGN_T +ALIGNOF_SIZE_T +ALT_SOABI +ANDROID_API_LEVEL +CODESET +CO_ASYNC_GENERATOR +CO_COROUTINE +CO_FUTURE_ABSOLUTE_IMPORT +CO_FUTURE_ANNOTATIONS +CO_FUTURE_BARRY_AS_BDFL +CO_FUTURE_DIVISION +CO_FUTURE_GENERATOR_STOP +CO_FUTURE_PRINT_FUNCTION +CO_FUTURE_UNICODE_LITERALS +CO_FUTURE_WITH_STATEMENT +CO_GENERATOR +CO_HAS_DOCSTRING +CO_ITERABLE_COROUTINE +CO_MAXBLOCKS +CO_METHOD +CO_NESTED +CO_NEWLOCALS +CO_NO_MONITORING_EVENTS +CO_OPTIMIZED +CO_VARARGS +CO_VARKEYWORDS +CURSES_ERROR_FORMAT +CURSES_ERROR_MUST_CALL_FORMAT +CURSES_ERROR_VERBOSE_FORMAT +DONT_HAVE_SIG_ALARM +DONT_HAVE_SIG_PAUSE +DOUBLE_IS_BIG_ENDIAN_IEEE754 +DOUBLE_IS_LITTLE_ENDIAN_IEEE754 +ENABLE_IPV6 +EVAL_CALL_API +EVAL_CALL_BUILD_CLASS +EVAL_CALL_FUNCTION_EX +EVAL_CALL_FUNCTION_VECTORCALL +EVAL_CALL_GENERATOR +EVAL_CALL_KINDS +EVAL_CALL_LEGACY +EVAL_CALL_METHOD +EVAL_CALL_SLOT +EVAL_CALL_TOTAL +EVAL_CALL_VECTOR +FUTURE_ABSOLUTE_IMPORT +FUTURE_ANNOTATIONS +FUTURE_BARRY_AS_BDFL +FUTURE_DIVISION +FUTURE_GENERATORS +FUTURE_GENERATOR_STOP +FUTURE_NESTED_SCOPES +FUTURE_PRINT_FUNCTION +FUTURE_UNICODE_LITERALS +FUTURE_WITH_STATEMENT +FVC_ASCII +FVC_MASK +FVC_NONE +FVC_REPR +FVC_STR +GETPGRP_HAVE_ARG +HAVE_ACCEPT +HAVE_ACCEPT4 +HAVE_ACOSH +HAVE_ADDRINFO +HAVE_ALARM +HAVE_ALIGNED_REQUIRED +HAVE_ALLOCA_H +HAVE_ALTZONE +HAVE_ASINH +HAVE_ASM_TYPES_H +HAVE_ATANH +HAVE_BACKTRACE +HAVE_BIND +HAVE_BIND_TEXTDOMAIN_CODESET +HAVE_BLUETOOTH_BLUETOOTH_H +HAVE_BLUETOOTH_H +HAVE_BROKEN_MBSTOWCS +HAVE_BROKEN_NICE +HAVE_BROKEN_PIPE_BUF +HAVE_BROKEN_POLL +HAVE_BROKEN_POSIX_SEMAPHORES +HAVE_BROKEN_PTHREAD_SIGMASK +HAVE_BROKEN_SEM_GETVALUE +HAVE_BROKEN_UNSETENV +HAVE_BUILTIN_ATOMIC +HAVE_BZLIB_H +HAVE_CHFLAGS +HAVE_CHMOD +HAVE_CHOWN +HAVE_CHROOT +HAVE_CLEARENV +HAVE_CLOCK +HAVE_CLOCK_GETRES +HAVE_CLOCK_GETTIME +HAVE_CLOCK_NANOSLEEP +HAVE_CLOCK_SETTIME +HAVE_CLOCK_T +HAVE_CLOSEFROM +HAVE_CLOSE_RANGE +HAVE_COMPUTED_GOTOS +HAVE_CONFSTR +HAVE_CONIO_H +HAVE_CONNECT +HAVE_COPY_FILE_RANGE +HAVE_CTERMID +HAVE_CTERMID_R +HAVE_CURSES_ESCDELAY +HAVE_CURSES_FILTER +HAVE_CURSES_GETMOUSE +HAVE_CURSES_H +HAVE_CURSES_HAS_KEY +HAVE_CURSES_IMMEDOK +HAVE_CURSES_IS_PAD +HAVE_CURSES_IS_TERM_RESIZED +HAVE_CURSES_RESIZETERM +HAVE_CURSES_RESIZE_TERM +HAVE_CURSES_SET_ESCDELAY +HAVE_CURSES_SET_TABSIZE +HAVE_CURSES_SYNCOK +HAVE_CURSES_TABSIZE +HAVE_CURSES_TYPEAHEAD +HAVE_CURSES_USE_ENV +HAVE_CURSES_WCHGAT +HAVE_DB_H +HAVE_DECLSPEC_DLL +HAVE_DECL_PR_SET_VMA_ANON_NAME +HAVE_DECL_RTLD_DEEPBIND +HAVE_DECL_RTLD_GLOBAL +HAVE_DECL_RTLD_LAZY +HAVE_DECL_RTLD_LOCAL +HAVE_DECL_RTLD_MEMBER +HAVE_DECL_RTLD_NODELETE +HAVE_DECL_RTLD_NOLOAD +HAVE_DECL_RTLD_NOW +HAVE_DECL_TZNAME +HAVE_DECL_UT_NAMESIZE +HAVE_DEVICE_MACROS +HAVE_DEV_PTC +HAVE_DEV_PTMX +HAVE_DIRECT_H +HAVE_DIRENT_D_TYPE +HAVE_DIRENT_H +HAVE_DIRFD +HAVE_DLADDR +HAVE_DLADDR1 +HAVE_DLFCN_H +HAVE_DLOPEN +HAVE_DL_ITERATE_PHDR +HAVE_DUP +HAVE_DUP2 +HAVE_DUP3 +HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH +HAVE_DYNAMIC_LOADING +HAVE_EDITLINE_READLINE_H +HAVE_ENDIAN_H +HAVE_EPOLL +HAVE_EPOLL_CREATE1 +HAVE_ERF +HAVE_ERFC +HAVE_ERRNO_H +HAVE_EVENTFD +HAVE_EXECINFO_H +HAVE_EXECV +HAVE_EXPLICIT_BZERO +HAVE_EXPLICIT_MEMSET +HAVE_EXPM1 +HAVE_FACCESSAT +HAVE_FCHDIR +HAVE_FCHMOD +HAVE_FCHMODAT +HAVE_FCHOWN +HAVE_FCHOWNAT +HAVE_FCNTL_H +HAVE_FDATASYNC +HAVE_FDOPENDIR +HAVE_FDWALK +HAVE_FEXECVE +HAVE_FFI_CLOSURE_ALLOC +HAVE_FFI_PREP_CIF_VAR +HAVE_FFI_PREP_CLOSURE_LOC +HAVE_FLOCK +HAVE_FORK +HAVE_FORK1 +HAVE_FORKPTY +HAVE_FPATHCONF +HAVE_FSEEKO +HAVE_FSTATAT +HAVE_FSTATVFS +HAVE_FSYNC +HAVE_FTELLO +HAVE_FTRUNCATE +HAVE_FUTIMENS +HAVE_FUTIMES +HAVE_FUTIMESAT +HAVE_GAI_STRERROR +HAVE_GCC_ASM_FOR_MC68881 +HAVE_GCC_ASM_FOR_X87 +HAVE_GCC_UINT128_T +HAVE_GDBM_DASH_NDBM_H +HAVE_GDBM_H +HAVE_GDBM_NDBM_H +HAVE_GETADDRINFO +HAVE_GETC_UNLOCKED +HAVE_GETEGID +HAVE_GETENTROPY +HAVE_GETEUID +HAVE_GETGID +HAVE_GETGRENT +HAVE_GETGRGID +HAVE_GETGRGID_R +HAVE_GETGRNAM_R +HAVE_GETGROUPLIST +HAVE_GETGROUPS +HAVE_GETHOSTBYADDR +HAVE_GETHOSTBYNAME +HAVE_GETHOSTBYNAME_R +HAVE_GETHOSTBYNAME_R_3_ARG +HAVE_GETHOSTBYNAME_R_5_ARG +HAVE_GETHOSTBYNAME_R_6_ARG +HAVE_GETHOSTNAME +HAVE_GETITIMER +HAVE_GETLOADAVG +HAVE_GETLOGIN +HAVE_GETLOGIN_R +HAVE_GETNAMEINFO +HAVE_GETPAGESIZE +HAVE_GETPEERNAME +HAVE_GETPGID +HAVE_GETPGRP +HAVE_GETPID +HAVE_GETPPID +HAVE_GETPRIORITY +HAVE_GETPROTOBYNAME +HAVE_GETPWENT +HAVE_GETPWNAM_R +HAVE_GETPWUID +HAVE_GETPWUID_R +HAVE_GETRANDOM +HAVE_GETRANDOM_SYSCALL +HAVE_GETRESGID +HAVE_GETRESUID +HAVE_GETRUSAGE +HAVE_GETSERVBYNAME +HAVE_GETSERVBYPORT +HAVE_GETSID +HAVE_GETSOCKNAME +HAVE_GETUID +HAVE_GRANTPT +HAVE_GRP_H +HAVE_HSTRERROR +HAVE_HTOLE64 +HAVE_ICONV_H +HAVE_IF_NAMEINDEX +HAVE_INET_ATON +HAVE_INET_NTOA +HAVE_INET_PTON +HAVE_INITGROUPS +HAVE_INTPTR_T +HAVE_INTTYPES_H +HAVE_IO_H +HAVE_KILL +HAVE_KILLPG +HAVE_KQUEUE +HAVE_LANGINFO_H +HAVE_LARGEFILE_SUPPORT +HAVE_LCHFLAGS +HAVE_LCHMOD +HAVE_LCHOWN +HAVE_LIBDB +HAVE_LIBDL +HAVE_LIBDLD +HAVE_LIBIEEE +HAVE_LIBINTL_H +HAVE_LIBSENDFILE +HAVE_LIBSOCKET +HAVE_LIBSQLITE3 +HAVE_LIBUTIL_H +HAVE_LINK +HAVE_LINKAT +HAVE_LINK_H +HAVE_LINUX_AUXVEC_H +HAVE_LINUX_CAN_BCM_H +HAVE_LINUX_CAN_H +HAVE_LINUX_CAN_ISOTP_H +HAVE_LINUX_CAN_J1939_H +HAVE_LINUX_CAN_RAW_FD_FRAMES +HAVE_LINUX_CAN_RAW_H +HAVE_LINUX_CAN_RAW_JOIN_FILTERS +HAVE_LINUX_FS_H +HAVE_LINUX_LIMITS_H +HAVE_LINUX_MEMFD_H +HAVE_LINUX_NETFILTER_IPV4_H +HAVE_LINUX_NETLINK_H +HAVE_LINUX_QRTR_H +HAVE_LINUX_RANDOM_H +HAVE_LINUX_SCHED_H +HAVE_LINUX_TIPC_H +HAVE_LINUX_VM_SOCKETS_H +HAVE_LINUX_WAIT_H +HAVE_LISTEN +HAVE_LOCKF +HAVE_LOG1P +HAVE_LOG2 +HAVE_LOGIN_TTY +HAVE_LONG_DOUBLE +HAVE_LONG_LONG +HAVE_LSTAT +HAVE_LUTIMES +HAVE_LZMA_H +HAVE_MADVISE +HAVE_MAKEDEV +HAVE_MAXLOGNAME +HAVE_MBRTOWC +HAVE_MEMFD_CREATE +HAVE_MEMRCHR +HAVE_MINIX_CONFIG_H +HAVE_MKDIRAT +HAVE_MKFIFO +HAVE_MKFIFOAT +HAVE_MKNOD +HAVE_MKNODAT +HAVE_MKTIME +HAVE_MMAP +HAVE_MREMAP +HAVE_NANOSLEEP +HAVE_NCURSES +HAVE_NCURSESW +HAVE_NCURSESW_CURSES_H +HAVE_NCURSESW_NCURSES_H +HAVE_NCURSESW_PANEL_H +HAVE_NCURSES_CURSES_H +HAVE_NCURSES_H +HAVE_NCURSES_NCURSES_H +HAVE_NCURSES_PANEL_H +HAVE_NDBM_H +HAVE_NDIR_H +HAVE_NETCAN_CAN_H +HAVE_NETDB_H +HAVE_NETINET_IN_H +HAVE_NETLINK_NETLINK_H +HAVE_NETPACKET_PACKET_H +HAVE_NET_ETHERNET_H +HAVE_NET_IF_H +HAVE_NICE +HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION +HAVE_OPENAT +HAVE_OPENDIR +HAVE_OPENPTY +HAVE_PANEL +HAVE_PANELW +HAVE_PANEL_H +HAVE_PATHCONF +HAVE_PAUSE +HAVE_PIPE +HAVE_PIPE2 +HAVE_PLOCK +HAVE_POLL +HAVE_POLL_H +HAVE_POSIX_FADVISE +HAVE_POSIX_FALLOCATE +HAVE_POSIX_OPENPT +HAVE_POSIX_SPAWN +HAVE_POSIX_SPAWNP +HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSEFROM_NP +HAVE_PPOLL +HAVE_PREAD +HAVE_PREADV +HAVE_PREADV2 +HAVE_PRLIMIT +HAVE_PROCESS_H +HAVE_PROCESS_VM_READV +HAVE_PTHREAD_CONDATTR_SETCLOCK +HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP +HAVE_PTHREAD_DESTRUCTOR +HAVE_PTHREAD_GETATTR_NP +HAVE_PTHREAD_GETCPUCLOCKID +HAVE_PTHREAD_GETNAME_NP +HAVE_PTHREAD_GET_NAME_NP +HAVE_PTHREAD_H +HAVE_PTHREAD_INIT +HAVE_PTHREAD_KILL +HAVE_PTHREAD_NP_H +HAVE_PTHREAD_SETNAME_NP +HAVE_PTHREAD_SET_NAME_NP +HAVE_PTHREAD_SIGMASK +HAVE_PTHREAD_STUBS +HAVE_PTSNAME +HAVE_PTSNAME_R +HAVE_PTY_H +HAVE_PUTENV +HAVE_PWRITE +HAVE_PWRITEV +HAVE_PWRITEV2 +HAVE_PY_SSIZE_T +HAVE_READLINE_READLINE_H +HAVE_READLINK +HAVE_READLINKAT +HAVE_READV +HAVE_REALPATH +HAVE_RECVFROM +HAVE_RENAMEAT +HAVE_RL_APPEND_HISTORY +HAVE_RL_CATCH_SIGNAL +HAVE_RL_COMPDISP_FUNC_T +HAVE_RL_COMPLETION_APPEND_CHARACTER +HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK +HAVE_RL_COMPLETION_MATCHES +HAVE_RL_COMPLETION_SUPPRESS_APPEND +HAVE_RL_PRE_INPUT_HOOK +HAVE_RL_RESIZE_TERMINAL +HAVE_RTPSPAWN +HAVE_SCHED_GET_PRIORITY_MAX +HAVE_SCHED_H +HAVE_SCHED_RR_GET_INTERVAL +HAVE_SCHED_SETAFFINITY +HAVE_SCHED_SETPARAM +HAVE_SCHED_SETSCHEDULER +HAVE_SEM_CLOCKWAIT +HAVE_SEM_GETVALUE +HAVE_SEM_OPEN +HAVE_SEM_TIMEDWAIT +HAVE_SEM_UNLINK +HAVE_SENDFILE +HAVE_SENDTO +HAVE_SETEGID +HAVE_SETEUID +HAVE_SETGID +HAVE_SETGROUPS +HAVE_SETHOSTNAME +HAVE_SETITIMER +HAVE_SETJMP_H +HAVE_SETLOCALE +HAVE_SETNS +HAVE_SETPGID +HAVE_SETPGRP +HAVE_SETPRIORITY +HAVE_SETREGID +HAVE_SETRESGID +HAVE_SETRESUID +HAVE_SETREUID +HAVE_SETSID +HAVE_SETSOCKOPT +HAVE_SETUID +HAVE_SETVBUF +HAVE_SHM_OPEN +HAVE_SHM_UNLINK +HAVE_SHUTDOWN +HAVE_SIGACTION +HAVE_SIGALTSTACK +HAVE_SIGFILLSET +HAVE_SIGINFO_T_SI_BAND +HAVE_SIGINTERRUPT +HAVE_SIGNAL_H +HAVE_SIGPENDING +HAVE_SIGTIMEDWAIT +HAVE_SIGWAIT +HAVE_SIGWAITINFO +HAVE_SNPRINTF +HAVE_SOCKADDR_ALG +HAVE_SOCKADDR_SA_LEN +HAVE_SOCKADDR_STORAGE +HAVE_SOCKET +HAVE_SOCKETPAIR +HAVE_SOCKLEN_T +HAVE_SPAWN_H +HAVE_SPLICE +HAVE_SSIZE_T +HAVE_STATVFS +HAVE_STATX +HAVE_STAT_TV_NSEC +HAVE_STAT_TV_NSEC2 +HAVE_STDDEF_H +HAVE_STDINT_H +HAVE_STDIO_H +HAVE_STDLIB_H +HAVE_STD_ATOMIC +HAVE_STRERROR +HAVE_STRFTIME +HAVE_STRINGS_H +HAVE_STRING_H +HAVE_STRLCPY +HAVE_STROPTS_H +HAVE_STRSIGNAL +HAVE_STRUCT_PASSWD_PW_GECOS +HAVE_STRUCT_PASSWD_PW_PASSWD +HAVE_STRUCT_STATX_STX_ATOMIC_WRITE_UNIT_MAX_OPT +HAVE_STRUCT_STATX_STX_ATOMIC_WRITE_UNIT_MIN +HAVE_STRUCT_STATX_STX_DIO_MEM_ALIGN +HAVE_STRUCT_STATX_STX_DIO_READ_OFFSET_ALIGN +HAVE_STRUCT_STATX_STX_MNT_ID +HAVE_STRUCT_STATX_STX_SUBVOL +HAVE_STRUCT_STAT_ST_BIRTHTIME +HAVE_STRUCT_STAT_ST_BLKSIZE +HAVE_STRUCT_STAT_ST_BLOCKS +HAVE_STRUCT_STAT_ST_FLAGS +HAVE_STRUCT_STAT_ST_GEN +HAVE_STRUCT_STAT_ST_RDEV +HAVE_STRUCT_TM_TM_ZONE +HAVE_SYMLINK +HAVE_SYMLINKAT +HAVE_SYNC +HAVE_SYSCONF +HAVE_SYSCTLBYNAME +HAVE_SYSEXITS_H +HAVE_SYSLOG_H +HAVE_SYSTEM +HAVE_SYS_AUXV_H +HAVE_SYS_BSDTTY_H +HAVE_SYS_DEVPOLL_H +HAVE_SYS_DIR_H +HAVE_SYS_ENDIAN_H +HAVE_SYS_EPOLL_H +HAVE_SYS_EVENTFD_H +HAVE_SYS_EVENT_H +HAVE_SYS_FILE_H +HAVE_SYS_IOCTL_H +HAVE_SYS_KERN_CONTROL_H +HAVE_SYS_LOADAVG_H +HAVE_SYS_LOCK_H +HAVE_SYS_MEMFD_H +HAVE_SYS_MKDEV_H +HAVE_SYS_MMAN_H +HAVE_SYS_MODEM_H +HAVE_SYS_NDIR_H +HAVE_SYS_PARAM_H +HAVE_SYS_PIDFD_H +HAVE_SYS_POLL_H +HAVE_SYS_RANDOM_H +HAVE_SYS_RESOURCE_H +HAVE_SYS_SELECT_H +HAVE_SYS_SENDFILE_H +HAVE_SYS_SOCKET_H +HAVE_SYS_STATVFS_H +HAVE_SYS_STAT_H +HAVE_SYS_SYSCALL_H +HAVE_SYS_SYSCTL_H +HAVE_SYS_SYSMACROS_H +HAVE_SYS_SYS_DOMAIN_H +HAVE_SYS_TERMIO_H +HAVE_SYS_TIMERFD_H +HAVE_SYS_TIMES_H +HAVE_SYS_TIME_H +HAVE_SYS_TYPES_H +HAVE_SYS_UIO_H +HAVE_SYS_UN_H +HAVE_SYS_UTIME_H +HAVE_SYS_UTSNAME_H +HAVE_SYS_WAIT_H +HAVE_SYS_XATTR_H +HAVE_TCGETPGRP +HAVE_TCSETPGRP +HAVE_TERMIOS_H +HAVE_TERM_H +HAVE_THREAD_LOCAL +HAVE_TIMEGM +HAVE_TIMERFD_CREATE +HAVE_TIMES +HAVE_TMPFILE +HAVE_TM_ZONE +HAVE_TRUNCATE +HAVE_TTYNAME_R +HAVE_TZNAME +HAVE_UINTPTR_T +HAVE_UMASK +HAVE_UNAME +HAVE_UNISTD_H +HAVE_UNLINKAT +HAVE_UNLOCKPT +HAVE_UNSHARE +HAVE_USABLE_WCHAR_T +HAVE_UTIL_H +HAVE_UTIMENSAT +HAVE_UTIMES +HAVE_UTIME_H +HAVE_UTMP_H +HAVE_UT_NAMESIZE +HAVE_UUID_CREATE +HAVE_UUID_ENC_BE +HAVE_UUID_GENERATE_TIME_SAFE +HAVE_UUID_GENERATE_TIME_SAFE_STABLE_MAC +HAVE_UUID_H +HAVE_UUID_UUID_H +HAVE_VFORK +HAVE_WAIT +HAVE_WAIT3 +HAVE_WAIT4 +HAVE_WAITID +HAVE_WAITPID +HAVE_WCHAR_H +HAVE_WCSCOLL +HAVE_WCSFTIME +HAVE_WCSXFRM +HAVE_WINDOWS_CONSOLE_IO +HAVE_WMEMCMP +HAVE_WORKING_TZSET +HAVE_WRITEV +HAVE_X509_VERIFY_PARAM_SET1_HOST +HAVE_ZDICT_H +HAVE_ZLIB_COPY +HAVE_ZLIB_H +HAVE_ZSTD_H +HAVE__GETPTY +HAVE___UINT128_T +INT_MAX +LONG_BIT +LONG_MAX +LONG_MIN +MAJOR_IN_MKDEV +MAJOR_IN_SYSMACROS +MAX_CO_EXTRA_USERS +METH_CLASS +METH_COEXIST +METH_FASTCALL +METH_KEYWORDS +METH_METHOD +METH_NOARGS +METH_O +METH_STACKLESS +METH_STATIC +METH_VARARGS +MS_COREDLL +MS_WIN32 +MS_WIN64 +MS_WINDOWS +MS_WINDOWS_APP +MS_WINDOWS_DESKTOP +MS_WINDOWS_GAMES +MS_WINDOWS_SYSTEM +MVWDELCH_IS_EXPRESSION +NATIVE_TSS_KEY_T +NCURSES_OPAQUE +NOWAIT_LOCK +NTDDI_VERSION +NT_THREADS +PACKAGE_BUGREPORT +PACKAGE_NAME +PACKAGE_STRING +PACKAGE_TARNAME +PACKAGE_URL +PACKAGE_VERSION +PDC_NCMOUSE +PLATFORM +POSIX_SEMAPHORES_NOT_ENABLED +PTHREAD_KEYS_MAX +PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT +PTHREAD_SYSTEM_SCHED_SUPPORTED +RETSIGTYPE +SETPGRP_HAVE_ARG +SIGNED_RIGHT_SHIFT_ZERO_FILLS +SIZEOF_DOUBLE +SIZEOF_FLOAT +SIZEOF_FPOS_T +SIZEOF_HKEY +SIZEOF_INT +SIZEOF_LONG +SIZEOF_LONG_DOUBLE +SIZEOF_LONG_LONG +SIZEOF_OFF_T +SIZEOF_PID_T +SIZEOF_PTHREAD_KEY_T +SIZEOF_PTHREAD_T +SIZEOF_PY_HASH_T +SIZEOF_PY_UHASH_T +SIZEOF_SHORT +SIZEOF_SIZE_T +SIZEOF_TIME_T +SIZEOF_UINTPTR_T +SIZEOF_VOID_P +SIZEOF_WCHAR_T +SIZEOF__BOOL +SOABI_PLATFORM +SPECIALIZATION_FAILURE_KINDS +SSTATE_INTERNED_IMMORTAL +SSTATE_INTERNED_IMMORTAL_STATIC +SSTATE_INTERNED_MORTAL +SSTATE_NOT_INTERNED +STDC_HEADERS +SYS_SELECT_WITH_SYS_TIME +S_IFLNK +S_IFMT +S_ISCHR +S_ISDIR +S_ISLNK +S_ISREG +THREAD_STACK_SIZE +TIMEMODULE_LIB +TM_IN_SYS_TIME +USE_COMPUTED_GOTOS +USE_SOCKET +USE_STACKCHECK +VA_LIST_IS_ARRAY +WAIT_LOCK +WINDOW_HAS_FLAGS +WINVER +WITH_DECIMAL_CONTEXTVAR +WITH_DOC_STRINGS +WITH_DTRACE +WITH_DYLD +WITH_EDITLINE +WITH_LIBINTL +WITH_MIMALLOC +WITH_NEXT_FRAMEWORK +WITH_PYMALLOC +WITH_THREAD +WITH_VALGRIND +WORDS_BIGENDIAN +WORD_BIT +X87_DOUBLE_ROUNDING +_ALL_SOURCE +_Atomic +_BOOL +_BSD_SOURCE +_CRT_NONSTDC_NO_DEPRECATE +_CRT_SECURE_NO_DEPRECATE +_DARWIN_C_SOURCE +_FILE_OFFSET_BITS +_GNU_SOURCE +_HPUX_ALT_XOPEN_SOCKET_API +_INCLUDE__STDC_A1_SOURCE +_ISOC23_SOURCE +_LARGEFILE_SOURCE +_LARGE_FILES +_MINIX +_NETBSD_SOURCE +_OPENBSD_SOURCE +_POSIX_1_SOURCE +_POSIX_C_SOURCE +_POSIX_PTHREAD_SEMANTICS +_POSIX_SOURCE +_POSIX_THREADS +_REENTRANT +_TANDEM_SOURCE +_W64 +_WASI_EMULATED_GETPID +_WASI_EMULATED_PROCESS_CLOCKS +_WASI_EMULATED_SIGNAL +_WCHAR_T +_WIN32_WINNT +_XOPEN_SOURCE +_XOPEN_SOURCE_EXTENDED +__BSD_VISIBLE +__EXTENSIONS__ +__NEED_pthread_attr_t +__NEED_pthread_cond_t +__NEED_pthread_condattr_t +__NEED_pthread_key_t +__NEED_pthread_mutex_t +__NEED_pthread_mutexattr_t +__NEED_pthread_t +__STDC_WANT_IEC_60559_ATTRIBS_EXT__ +__STDC_WANT_IEC_60559_BFP_EXT__ +__STDC_WANT_IEC_60559_DFP_EXT__ +__STDC_WANT_IEC_60559_EXT__ +__STDC_WANT_IEC_60559_FUNCS_EXT__ +__STDC_WANT_IEC_60559_TYPES_EXT__ +__STDC_WANT_LIB_EXT2__ +__STDC_WANT_MATH_SPEC_FUNCS__ +__bool__ +__wchar_t +__wint_t +clock_t +gid_t +import_curses +mode_t +off_t +pid_t +size_t +socklen_t +static_assert +uid_t diff --git a/Tools/build/check_extension_modules.py b/Tools/build/check_extension_modules.py index c619a9a0c1c5a1b..e907442b61ea22f 100644 --- a/Tools/build/check_extension_modules.py +++ b/Tools/build/check_extension_modules.py @@ -421,7 +421,7 @@ def parse_setup_file(self, setup_file: pathlib.Path) -> Iterable[ModuleInfo]: state = ModuleState.BUILTIN case ["*disabled*"]: state = ModuleState.DISABLED - case ["*noconfig*"]: + case ["*noconfig*"] | ["*bootstrap*"]: continue case [*items]: if state == ModuleState.DISABLED: diff --git a/Tools/build/compute-changes.py b/Tools/build/compute-changes.py index 53d7b8fe32f89e6..4d491cc79ad0c8e 100644 --- a/Tools/build/compute-changes.py +++ b/Tools/build/compute-changes.py @@ -117,7 +117,6 @@ class Outputs: run_tests: bool = False run_ubuntu: bool = False run_wasi: bool = False - run_windows_msi: bool = False run_windows_tests: bool = False @@ -160,9 +159,6 @@ def compute_changes() -> None: if outputs.run_docs: print("Build documentation") - if outputs.run_windows_msi: - print("Build Windows MSI") - print(outputs) write_github_output(outputs) @@ -223,7 +219,6 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs: run_ci_fuzz_stdlib = False run_docs = False run_windows_tests = False - run_windows_msi = False platforms_changed = set() has_platform_specific_change = True @@ -245,9 +240,6 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs: run_tests = True run_windows_tests = True continue - if file.name == "reusable-windows-msi.yml": - run_windows_msi = True - continue if file.name == "reusable-macos.yml": run_tests = True platforms_changed.add("macos") @@ -288,10 +280,6 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs: if doc_file: run_docs = True - # Check for changed MSI installer-related files - if file.parts[:2] == ("Tools", "msi"): - run_windows_msi = True - # Check which platform specific tests to run if run_tests: if not has_platform_specific_change or not platforms_changed: @@ -327,7 +315,6 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs: run_tests=run_tests, run_ubuntu=run_ubuntu, run_wasi=run_wasi, - run_windows_msi=run_windows_msi, run_windows_tests=run_windows_tests, ) @@ -342,7 +329,6 @@ def process_target_branch(outputs: Outputs, git_branch: str) -> Outputs: if os.environ.get("GITHUB_EVENT_NAME", "").lower() == "workflow_dispatch": outputs.run_docs = True - outputs.run_windows_msi = True return outputs diff --git a/Tools/build/freeze_modules.py b/Tools/build/freeze_modules.py index b29cc730ca8b24a..8c817daec0f0b37 100644 --- a/Tools/build/freeze_modules.py +++ b/Tools/build/freeze_modules.py @@ -16,6 +16,9 @@ FROZEN_ONLY = os.path.join(ROOT_DIR, 'Tools', 'freeze', 'flag.py') STDLIB_DIR = os.path.join(ROOT_DIR, 'Lib') +# Frozen under the "builtins" ID rather than its own name, so that the frames +# of the builtins it defines show up as "" in tracebacks. +PYBUILTINS = os.path.join(STDLIB_DIR, '_pybuiltins.py') # If FROZEN_MODULES_DIR or DEEPFROZEN_MODULES_DIR is changed then the # .gitattributes and .gitignore files needs to be updated. FROZEN_MODULES_DIR = os.path.join(ROOT_DIR, 'Python', 'frozen_modules') @@ -45,16 +48,20 @@ # This module is important because some Python builds rely # on a builtin zip file instead of a filesystem. 'zipimport', + # Builtins implemented in Python; loaded while builtins is set up. + f'builtins : _pybuiltins = {PYBUILTINS}', ]), # (You can delete entries from here down to the end of the list.) ('stdlib - startup, without site (python -S)', [ 'abc', 'codecs', - '', - 'encodings.aliases', - 'encodings.utf_8', - 'encodings._win_cp_codecs', - 'encodings._iconv_codecs', + # gh-148750: Partially freezing encodings causes import errors of + # submodules when using a zipped standard library. + #'', + #'encodings.aliases', + #'encodings.utf_8', + #'encodings._win_cp_codecs', + #'encodings._iconv_codecs', 'io', ]), ('stdlib - startup, with site', [ @@ -89,6 +96,7 @@ 'importlib._bootstrap', 'importlib._bootstrap_external', 'zipimport', + 'builtins', } diff --git a/Tools/build/generate-build-details.py b/Tools/build/generate-build-details.py index 8272635bc627d6a..a6f537fc0d020da 100644 --- a/Tools/build/generate-build-details.py +++ b/Tools/build/generate-build-details.py @@ -10,6 +10,7 @@ import importlib.machinery import json import os +import re import sys import sysconfig @@ -18,17 +19,98 @@ from typing import Any +PATCHLEVEL_H = os.path.join( + os.path.dirname(__file__), '..', '..', 'Include', 'patchlevel.h', +) +RELEASE_LEVELS = {0xA: 'alpha', 0xB: 'beta', 0xC: 'candidate', 0xF: 'final'} + + def version_info_to_dict(obj: sys._version_info) -> dict[str, Any]: field_names = ('major', 'minor', 'micro', 'releaselevel', 'serial') return {field: getattr(obj, field) for field in field_names} +def get_version_info() -> dict[str, Any]: + """Return the target's version as a version_info dict. + + sys.version_info describes the running interpreter, which under + --with-build-python can differ from the target in micro version and + release level. Read Include/patchlevel.h instead when it is available. + """ + try: + with open(PATCHLEVEL_H, encoding='utf-8') as f: + patchlevel = f.read() + except FileNotFoundError: + return version_info_to_dict(sys.version_info) + defines = dict(re.findall(r'^#define\s+(PY_\w+)\s+(\S+)', patchlevel, re.M)) + # PY_RELEASE_LEVEL is defined as another macro, e.g. PY_RELEASE_LEVEL_ALPHA. + level = int(defines[defines['PY_RELEASE_LEVEL']], 16) + return { + 'major': int(defines['PY_MAJOR_VERSION']), + 'minor': int(defines['PY_MINOR_VERSION']), + 'micro': int(defines['PY_MICRO_VERSION']), + 'releaselevel': RELEASE_LEVELS[level], + 'serial': int(defines['PY_RELEASE_SERIAL']), + } + + +def hexversion(version_info: dict[str, Any]) -> int: + level = {name: value for value, name in RELEASE_LEVELS.items()} + return int( + version_info['major'] << 24 + | version_info['minor'] << 16 + | version_info['micro'] << 8 + | level[version_info['releaselevel']] << 4 + | version_info['serial'] + ) + + def get_dict_key(container: dict[str, Any], key: str) -> dict[str, Any]: for part in key.split('.'): container = container[part] return container +def get_extension_suffixes() -> list[str]: + """Return the extension module suffixes of the target interpreter. + + importlib.machinery.EXTENSION_SUFFIXES describes the running interpreter, + which is not the target under --with-build-python. On POSIX, rebuild the + list from the target configuration instead, following + _PyImport_DynLoadFiletab in Python/dynload_*.c. The two are kept in sync + by test_build_details.BuildDetailsTargetTests.test_native_extension_suffixes. + """ + if os.name != 'posix': + return importlib.machinery.EXTENSION_SUFFIXES + + dynloadfile = sysconfig.get_config_var('DYNLOADFILE') + if dynloadfile == 'dynload_stub.o': + return [] + if dynloadfile == 'dynload_hpux.o': + return [sysconfig.get_config_var('EXT_SUFFIX'), '.sl'] + if dynloadfile != 'dynload_shlib.o': + raise ValueError(f'Unsupported DYNLOADFILE: {dynloadfile!r}') + + soabi = sysconfig.get_config_var('SOABI') + if sysconfig.get_config_var('MACHDEP') == 'cygwin': + return [f'.{soabi}.dll', '.dll'] + + suffixes = [f'.{soabi}.so'] + alt_soabi = sysconfig.get_config_var('ALT_SOABI') + if alt_soabi: + suffixes.append(f'.{alt_soabi}.so') + platform = sysconfig.get_config_var('SOABI_PLATFORM') + if not sysconfig.get_config_var('Py_GIL_DISABLED'): + if platform: + suffixes.append(f'.abi3-{platform}.so') + suffixes.append('.abi3.so') + if platform: + suffixes.append(f'.abi3t-{platform}.so') + suffixes.append('.abi3t.so') + suffixes.append('.so') + return suffixes + + def generate_data(schema_version: str) -> collections.defaultdict[str, Any]: """Generate the build-details.json data (PEP 739). @@ -54,24 +136,33 @@ def generate_data(schema_version: str) -> collections.defaultdict[str, Any]: ) data['platform'] = sysconfig.get_platform() + version_info = get_version_info() data['language']['version'] = sysconfig.get_python_version() - data['language']['version_info'] = version_info_to_dict(sys.version_info) + data['language']['version_info'] = version_info data['implementation'] = vars(sys.implementation).copy() - data['implementation']['version'] = version_info_to_dict(sys.implementation.version) + data['implementation']['version'] = version_info + data['implementation']['hexversion'] = hexversion(version_info) # Fix cross-compilation if '_multiarch' in data['implementation']: data['implementation']['_multiarch'] = sysconfig.get_config_var('MULTIARCH') + if 'supports_isolated_interpreters' in data['implementation']: + # Mirrors Python/sysmodule.c. + data['implementation']['supports_isolated_interpreters'] = ( + sysconfig.get_config_var('MACHDEP') not in ('wasi', 'emscripten') + ) - data['abi']['flags'] = list(sys.abiflags) + data['abi']['flags'] = list(sysconfig.get_config_var('ABIFLAGS')) data['suffixes']['source'] = importlib.machinery.SOURCE_SUFFIXES data['suffixes']['bytecode'] = importlib.machinery.BYTECODE_SUFFIXES #data['suffixes']['optimized_bytecode'] = importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES #data['suffixes']['debug_bytecode'] = importlib.machinery.DEBUG_BYTECODE_SUFFIXES - data['suffixes']['extensions'] = importlib.machinery.EXTENSION_SUFFIXES + extension_suffixes = get_extension_suffixes() + data['suffixes']['extensions'] = extension_suffixes LIBDIR = sysconfig.get_config_var('LIBDIR') + LIBPL = sysconfig.get_config_var('LIBPL') LDLIBRARY = sysconfig.get_config_var('LDLIBRARY') LIBRARY = sysconfig.get_config_var('LIBRARY') PY3LIBRARY = sysconfig.get_config_var('PY3LIBRARY') @@ -84,7 +175,21 @@ def generate_data(schema_version: str) -> collections.defaultdict[str, Any]: # dynamic library if enabled, otherwise it's the static library. # If LIBRARY != LDLIBRARY, support for the dynamic library is enabled. has_dynamic_library = LDLIBRARY != LIBRARY - has_static_library = sysconfig.get_config_var('STATIC_LIBPYTHON') + # Framework builds don't install the static library (see libainstall). + has_static_library = ( + sysconfig.get_config_var('STATIC_LIBPYTHON') + and not sysconfig.get_config_var('PYTHONFRAMEWORK') + ) + # The static library is only installed into LIBDIR when it is also + # LDLIBRARY; otherwise it is only installed into LIBPL. + static_library_dir = LIBPL if has_dynamic_library else LIBDIR + # In framework builds, LDLIBRARY is the path of the framework library + # relative to PYTHONFRAMEWORKPREFIX (e.g. + # Python.framework/Versions/3.X/Python), not a file in LIBDIR. + if sysconfig.get_config_var('PYTHONFRAMEWORK'): + dynamic_library_dir = sysconfig.get_config_var('PYTHONFRAMEWORKPREFIX') + else: + dynamic_library_dir = LIBDIR elif os.name == 'nt': # Windows can only use a dynamic library or a static library. # If it's using a dynamic library, sys.dllhandle will be set. @@ -92,6 +197,8 @@ def generate_data(schema_version: str) -> collections.defaultdict[str, Any]: # More context: https://github.com/python/cpython/issues/110234 has_dynamic_library = hasattr(sys, 'dllhandle') has_static_library = not has_dynamic_library + static_library_dir = LIBDIR + dynamic_library_dir = LIBDIR else: raise NotADirectoryError(f'Unknown platform: {os.name}') @@ -101,18 +208,17 @@ def generate_data(schema_version: str) -> collections.defaultdict[str, Any]: # regardless. # # We only want to set abi.extension_suffix and stable_abi_suffix if - # extension modules are supported. - if has_dynamic_library: + # extension modules are supported, regardless of how libpython is built. + if extension_suffixes: data['abi']['extension_suffix'] = sysconfig.get_config_var('EXT_SUFFIX') - # EXTENSION_SUFFIXES has been constant for a long time, and currently we - # don't have a better information source to find the stable ABI suffix. - for suffix in importlib.machinery.EXTENSION_SUFFIXES: + for suffix in extension_suffixes: if suffix.startswith('.abi'): data['abi']['stable_abi_suffix'] = suffix break - data['libpython']['dynamic'] = os.path.join(LIBDIR, LDLIBRARY) + if has_dynamic_library: + data['libpython']['dynamic'] = os.path.join(dynamic_library_dir, LDLIBRARY) # FIXME: Not sure if windows has a different dll for the stable ABI, and # even if it does, currently we don't have a way to get its name. if PY3LIBRARY: @@ -123,7 +229,7 @@ def generate_data(schema_version: str) -> collections.defaultdict[str, Any]: data['libpython']['link_extensions'] = bool(LIBPYTHON) if has_static_library: - data['libpython']['static'] = os.path.join(LIBDIR, LIBRARY) + data['libpython']['static'] = os.path.join(static_library_dir, LIBRARY) data['c_api']['headers'] = INCLUDEPY if LIBPC: @@ -133,11 +239,12 @@ def generate_data(schema_version: str) -> collections.defaultdict[str, Any]: def make_paths_relative(data: dict[str, Any], config_path: str | None = None) -> None: - # Make base_prefix relative to the config_path directory + base_prefix = data['base_prefix'] + # Make base_prefix relative to the config_path directory. The other paths + # are still made relative to the absolute base_prefix below. if config_path: - data['base_prefix'] = relative_path(data['base_prefix'], + data['base_prefix'] = relative_path(base_prefix, os.path.dirname(config_path)) - base_prefix = data['base_prefix'] # Update path values to make them relative to base_prefix PATH_KEYS = ( diff --git a/Tools/build/generate_global_objects.py b/Tools/build/generate_global_objects.py index 5b188e338bab360..86a8d9711e666a9 100644 --- a/Tools/build/generate_global_objects.py +++ b/Tools/build/generate_global_objects.py @@ -137,11 +137,34 @@ NON_GENERATED_IMMORTAL_OBJECTS = [ # The generated ones come from generate_runtime_init(). - '(PyObject *)&_Py_SINGLETON(bytes_empty)', - '(PyObject *)&_Py_SINGLETON(tuple_empty)', - '(PyObject *)&_Py_SINGLETON(hamt_bitmap_node_empty)', - '(PyObject *)&_Py_INTERP_SINGLETON(interp, hamt_empty)', - '(PyObject *)&_Py_SINGLETON(context_token_missing)', + + # b'' (empty bytes string) + ('_PyStaticObject_CheckBytesSingleton({}, 0, 0);', + '(PyObject *)&_Py_SINGLETON(bytes_empty)'), + # () (empty tuple) + ('_PyStaticObject_CheckSingleton({}, &PyTuple_Type);', + '(PyObject *)&_Py_SINGLETON(tuple_empty)'), + ('_PyStaticObject_CheckSingleton({}, &_PyHamt_BitmapNode_Type);', + '(PyObject *)&_Py_SINGLETON(hamt_bitmap_node_empty)'), + ('_PyStaticObject_CheckSingleton({}, &_PyHamt_Type);', + '(PyObject *)&_Py_INTERP_SINGLETON(interp, hamt_empty)'), + ('_PyStaticObject_CheckSingleton({}, &_PyContextTokenMissing_Type);', + '(PyObject *)&_Py_SINGLETON(context_token_missing)'), + # False + ('_PyStaticObject_CheckLongSingleton({}, 0, 1);', + '(PyObject *)&_Py_FalseStruct '), + # True + ('_PyStaticObject_CheckLongSingleton({}, 1, 1);', + '(PyObject *)&_Py_TrueStruct'), + # None + ('_PyStaticObject_CheckSingleton({}, &_PyNone_Type);', + '(PyObject *)&_Py_NoneStruct'), + # Ellipsis (...) + ('_PyStaticObject_CheckSingleton({}, &PyEllipsis_Type);', + '(PyObject *)&_Py_EllipsisObject'), + # Py_NotImplemented + ('_PyStaticObject_CheckSingleton({}, &_PyNotImplemented_Type);', + '(PyObject *)&_Py_NotImplementedStruct'), ] @@ -220,8 +243,11 @@ def block(self, prefix, suffix="", *, continuation=None): @contextlib.contextmanager -def open_for_changes(filename, orig): +def open_for_changes(filename): """Like open() but only write to the file if it changed.""" + with open(filename) as infile: + orig = infile.read() + outfile = io.StringIO() yield outfile text = outfile.getvalue() @@ -252,7 +278,7 @@ def generate_global_strings(identifiers, strings): after = '\n'.join(lines) # Generate the file. - with open_for_changes(filename, orig) as outfile: + with open_for_changes(filename) as outfile: printer = Printer(outfile) printer.write(before) printer.write(START) @@ -291,7 +317,7 @@ def generate_runtime_init(identifiers, strings): after = '\n'.join(lines) # Generate the file. - with open_for_changes(filename, orig) as outfile: + with open_for_changes(filename) as outfile: immortal_objects = [] printer = Printer(outfile) printer.write(before) @@ -299,28 +325,45 @@ def generate_runtime_init(identifiers, strings): with printer.block('#define _Py_small_ints_INIT', continuation=True): for i in range(-nsmallnegints, nsmallposints): printer.write(f'_PyLong_DIGIT_INIT({i}),') - immortal_objects.append(f'(PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + {i}]') + immortal_objects.append(( + None, + f'(PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + {i}]', + )) printer.write('') with printer.block('#define _Py_bytes_characters_INIT', continuation=True): for i in range(256): printer.write(f'_PyBytes_CHAR_INIT({i}),') - immortal_objects.append(f'(PyObject *)&_Py_SINGLETON(bytes_characters)[{i}]') + immortal_objects.append(( + None, + f'(PyObject *)&_Py_SINGLETON(bytes_characters)[{i}]', + )) printer.write('') with printer.block('#define _Py_str_literals_INIT', continuation=True): for literal, name in sorted(strings.items(), key=lambda x: x[1]): printer.write(f'INIT_STR({name}, "{literal}"),') - immortal_objects.append(f'(PyObject *)&_Py_STR({name})') + escaped = literal.replace("{", "{{").replace("}", "}}") + immortal_objects.append(( + f'_PyStaticObject_CheckUnicodeSingleton({{}}, "{escaped}", {len(literal)});', + f'(PyObject *)&_Py_STR({name})', + )) printer.write('') with printer.block('#define _Py_str_identifiers_INIT', continuation=True): for name in sorted(identifiers): assert name.isidentifier(), name printer.write(f'INIT_ID({name}),') - immortal_objects.append(f'(PyObject *)&_Py_ID({name})') + assert all(ch not in "{}" for ch in name) + immortal_objects.append(( + f'_PyStaticObject_CheckUnicodeSingleton({{}}, "{name}", {len(name)});', + f'(PyObject *)&_Py_ID({name})', + )) printer.write('') with printer.block('#define _Py_str_ascii_INIT', continuation=True): for i in range(128): printer.write(f'_PyASCIIObject_INIT("\\x{i:02x}"),') - immortal_objects.append(f'(PyObject *)&_Py_SINGLETON(strings).ascii[{i}]') + immortal_objects.append(( + None, + f'(PyObject *)&_Py_SINGLETON(strings).ascii[{i}]', + )) printer.write('') with printer.block('#define _Py_str_latin1_INIT', continuation=True): for i in range(128, 256): @@ -329,7 +372,10 @@ def generate_runtime_init(identifiers, strings): utf8.append(f"\\x{c:02x}") utf8.append('"') printer.write(f'_PyUnicode_LATIN1_INIT("\\x{i:02x}", {"".join(utf8)}),') - immortal_objects.append(f'(PyObject *)&_Py_SINGLETON(strings).latin1[{i} - 128]') + immortal_objects.append(( + None, + f'(PyObject *)&_Py_SINGLETON(strings).latin1[{i} - 128]', + )) printer.write(END) printer.write(after) return immortal_objects @@ -349,61 +395,99 @@ def generate_static_strings_initializer(identifiers, strings): after = '\n'.join(lines) # Generate the file. - with open_for_changes(filename, orig) as outfile: + with open_for_changes(filename ) as outfile: printer = Printer(outfile) printer.write(before) printer.write(START) printer.write("static inline void") with printer.block("_PyUnicode_InitStaticStrings(PyInterpreterState *interp)"): - printer.write(f'PyObject *string;') - for i in sorted(identifiers): - # This use of _Py_ID() is ignored by iter_global_strings() - # since iter_files() ignores .h files. - printer.write(f'string = &_Py_ID({i});') - printer.write(f'_PyUnicode_InternStatic(interp, &string);') - printer.write(f'assert(_PyUnicode_CheckConsistency(string, 1));') - printer.write(f'assert(PyUnicode_GET_LENGTH(string) != 1);') - for value, name in sorted(strings.items()): - printer.write(f'string = &_Py_STR({name});') - printer.write(f'_PyUnicode_InternStatic(interp, &string);') - printer.write(f'assert(_PyUnicode_CheckConsistency(string, 1));') - printer.write(f'assert(PyUnicode_GET_LENGTH(string) != 1);') + printer.write('// Offsets avoid a pointer relocation for each string.') + with printer.block('static const uint32_t offsets[] =', ';'): + for i in sorted(identifiers): + printer.write('offsetof(struct _Py_global_strings, ' + f'identifiers._py_{i}._ascii.ob_base),') + for value, name in sorted(strings.items()): + printer.write('offsetof(struct _Py_global_strings, ' + f'literals._py_{name}._ascii.ob_base),') + printer.write('char *base = (char *)&_Py_SINGLETON(strings);') + with printer.block('for (size_t i = 0; i < Py_ARRAY_LENGTH(offsets); i++)'): + printer.write('PyObject *string = (PyObject *)(base + offsets[i]);') + printer.write('_PyUnicode_InternStatic(interp, &string);') + printer.write('assert(_PyUnicode_CheckConsistency(string, 1));') + printer.write('assert(PyUnicode_GET_LENGTH(string) != 1);') printer.write(END) printer.write(after) def generate_global_object_finalizers(generated_immortal_objects): + nsmallnegints, nsmallposints = consts_getter.get_nsmallnegints_and_nsmallposints() + # Target the runtime initializer. filename = os.path.join(INTERNAL, 'pycore_global_objects_fini_generated.h') - # Read the non-generated part of the file. - with open(filename) as infile: - orig = infile.read() - lines = iter(orig.rstrip().splitlines()) - before = '\n'.join(iter_to_marker(lines, START)) - for _ in iter_to_marker(lines, END): - pass - after = '\n'.join(lines) - # Generate the file. - with open_for_changes(filename, orig) as outfile: + with open_for_changes(filename) as outfile: printer = Printer(outfile) - printer.write(before) - printer.write(START) - printer.write('#ifdef Py_DEBUG') + printer.write(""" +// File automatically generated by %s + +#ifndef Py_INTERNAL_GLOBAL_OBJECTS_FINI_GENERATED_INIT_H +#define Py_INTERNAL_GLOBAL_OBJECTS_FINI_GENERATED_INIT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#include "pycore_global_objects_fini.h" // _PyStaticObject_CheckSingleton() +#include "pycore_hamt.h" // _PyHamt_BitmapNode_Type + +#ifdef Py_DEBUG + """.strip() % SCRIPT_NAME) + printer.write('') + printer.write('// Check static objects consistency: detect if a C extension modified') + printer.write('// an immutable singleton by mistake.') printer.write("static inline void") with printer.block( - "_PyStaticObjects_CheckRefcnt(PyInterpreterState *interp)"): + "_PyStaticObjects_CheckAll(PyInterpreterState *interp)"): printer.write('/* generated runtime-global */') printer.write('// (see pycore_runtime_init_generated.h)') - for ref in generated_immortal_objects: - printer.write(f'_PyStaticObject_CheckRefcnt({ref});') + for fmt, ref in generated_immortal_objects: + if fmt is not None: + printer.write(fmt.format(ref)) + + with printer.block(f'for (int i={-nsmallnegints}; i < {nsmallposints}; i++)'): + obj = '(PyObject *)&_Py_SINGLETON(small_ints)[_PY_NSMALLNEGINTS + i]' + printer.write(f'_PyStaticObject_CheckLongSingleton({obj}, i, 0);') + + with printer.block(f'for (int i=0; i <= 255; i++)'): + obj = '(PyObject *)&_Py_SINGLETON(bytes_characters)[i]' + printer.write(f'_PyStaticObject_CheckBytesSingleton({obj}, 1, i);') + + with printer.block(f'for (int i=0; i <= 127; i++)'): + obj = '(PyObject *)&_Py_SINGLETON(strings).ascii[i]' + printer.write(f'_PyStaticObject_CheckUnicodeCharSingleton({obj}, i);') + + with printer.block(f'for (int i=128; i <= 255; i++)'): + obj = '(PyObject *)&_Py_SINGLETON(strings).latin1[i - 128]' + printer.write(f'_PyStaticObject_CheckUnicodeCharSingleton({obj}, i);') + printer.write('/* non-generated */') - for ref in NON_GENERATED_IMMORTAL_OBJECTS: - printer.write(f'_PyStaticObject_CheckRefcnt({ref});') + for fmt, ref in NON_GENERATED_IMMORTAL_OBJECTS: + printer.write(fmt.format(ref)) + printer.write('') printer.write('#endif // Py_DEBUG') - printer.write(END) - printer.write(after) + printer.write('') + printer.write(""" +/* End auto-generated code */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_GLOBAL_OBJECTS_FINI_GENERATED_INIT_H */ + """.strip()) def get_identifiers_and_strings() -> 'tuple[set[str], dict[str, str]]': diff --git a/Tools/build/generate_token.py b/Tools/build/generate_token.py index 9ee5ec86e75d472..ae9e69ab9cef425 100755 --- a/Tools/build/generate_token.py +++ b/Tools/build/generate_token.py @@ -5,7 +5,7 @@ # Doc/library/token-list.inc # Doc/library/token.rst (checked, not generated) # make_h: -# Include/token.h +# Include/internal/pycore_token.h # make_c: # Parser/token.c # make_py: @@ -94,7 +94,7 @@ def update_file(file, content): // Export these 4 symbols for 'test_peg_generator' PyAPI_DATA(const char * const) _PyParser_TokenNames[]; /* Token names */ PyAPI_FUNC(int) _PyToken_OneChar(int); -PyAPI_FUNC(int) _PyToken_TwoChars(int, int); +PyAPI_FUNC(int) _PyToken_TwoChars(int, int, int); PyAPI_FUNC(int) _PyToken_ThreeChars(int, int, int); #ifdef __cplusplus @@ -142,7 +142,7 @@ def make_h(infile, outfile='Include/internal/pycore_token.h'): } int -_PyToken_TwoChars(int c1, int c2) +_PyToken_TwoChars(int c1, int c2, int BARRY_AS_BDFL) { %s\ return OP; @@ -171,7 +171,10 @@ def generate_chars_to_token(mapping, n=1): write(indent) write(' break;\n') else: - write("case '%s': return %s;\n" % (c, value)) + if c == '>' and value == 'NOTEQUAL': + write("case '%s': return BARRY_AS_BDFL ? %s : OP;\n" % (c, value)) + else: + write("case '%s': return %s;\n" % (c, value)) write(indent) write('}\n') return ''.join(result) diff --git a/Tools/build/regen-configure.sh b/Tools/build/regen-configure.sh index c7683eb36763aff..a7a95b7878dc79a 100755 --- a/Tools/build/regen-configure.sh +++ b/Tools/build/regen-configure.sh @@ -26,4 +26,27 @@ if command -v selinuxenabled >/dev/null && selinuxenabled; then PATH_OPT=":Z" fi -"$RUNTIME" run --rm -v "$abs_srcdir:$WORK_DIR$PATH_OPT" "$IMAGE" +# Run the container as the invoking user so that generated files are owned by +# that user and not by root. Rootless runtimes already map root to the invoking +# user, so a user mapping is only needed for rootful Docker. +USER_OPT="" +case "$RUNTIME" in + podman) + USER_OPT="--userns=keep-id" + ;; + docker) + if ! docker info --format '{{.SecurityOptions}}' | grep -q rootless; then + USER_OPT="-u $(id -u):$(id -g)" + fi + ;; +esac + +purge_autom4te_cache() { + [ -d "$abs_srcdir/autom4te.cache" ] || return 0 + "$RUNTIME" run --rm -v "$abs_srcdir:$WORK_DIR$PATH_OPT" \ + "$IMAGE" sh -c "rm -rf $WORK_DIR/autom4te.cache" +} + +purge_autom4te_cache +trap 'purge_autom4te_cache || true' EXIT +"$RUNTIME" run --rm $USER_OPT -v "$abs_srcdir:$WORK_DIR$PATH_OPT" "$IMAGE" diff --git a/Tools/build/stable_abi.py b/Tools/build/stable_abi.py index 39115b331ba6428..5f70a706d139b64 100644 --- a/Tools/build/stable_abi.py +++ b/Tools/build/stable_abi.py @@ -116,7 +116,6 @@ def decorator(cls): return decorator @itemclass('function') -@itemclass('macro') @itemclass('data') @itemclass('const') @itemclass('typedef') @@ -144,6 +143,11 @@ class Struct(ABIItem): struct_abi_kind: str members: list = None +@itemclass('macro') +@dataclasses.dataclass +class Macro(ABIItem): + is_static_inline_function: bool = False + def parse_manifest(file): """Parse the given file (iterable of lines) to a Manifest""" @@ -227,13 +231,13 @@ def sort_key(item): key=sort_key): write(f'EXPORT_DATA({item.name})') -ITEM_KIND_TO_DOC_ROLE = { - 'function': 'func', - 'data': 'data', - 'struct': 'type', - 'macro': 'macro', - 'const': 'macro', - 'typedef': 'type', +DOC_KINDS = { + 'function', + 'data', + 'struct', + 'macro', + 'const', + 'typedef', } @generator("doc_list", 'Doc/data/stable_abi.dat') @@ -245,17 +249,16 @@ def gen_doc_annotations(manifest, args, outfile): """ writer = csv.DictWriter( outfile, - ['role', 'name', 'added', 'ifdef_note', 'struct_abi_kind'], + ['kind', 'name', 'added', 'ifdef_note', 'struct_abi_kind'], lineterminator='\n') writer.writeheader() - kinds = set(ITEM_KIND_TO_DOC_ROLE) - for item in manifest.select(kinds, include_abi_only=False): + for item in manifest.select(DOC_KINDS, include_abi_only=False): if item.ifdef: ifdef_note = manifest.contents[item.ifdef].doc else: ifdef_note = None row = { - 'role': ITEM_KIND_TO_DOC_ROLE[item.kind], + 'kind': item.kind, 'name': item.name, 'added': item.added, 'ifdef_note': ifdef_note, @@ -265,7 +268,7 @@ def gen_doc_annotations(manifest, args, outfile): row['struct_abi_kind'] = item.struct_abi_kind for member_name in item.members or (): rows.append({ - 'role': 'member', + 'kind': 'member', 'name': f'{item.name}.{member_name}', 'added': item.added, }) @@ -408,7 +411,10 @@ def do_unixy_check(manifest, args): feature_macros &= present_macros # Check that we have all needed macros - expected_macros = {item.name for item in manifest.select({'macro'})} + expected_macros = { + item.name for item in manifest.select({'macro'}) + if not item.is_static_inline_function + } missing_macros = expected_macros - present_macros okay &= _report_unexpected_items( missing_macros, diff --git a/Tools/buildbot/buildmsi.bat b/Tools/buildbot/buildmsi.bat index 6804d794799509b..b0e196df2649be6 100644 --- a/Tools/buildbot/buildmsi.bat +++ b/Tools/buildbot/buildmsi.bat @@ -3,7 +3,9 @@ setlocal pushd -@rem build both snapshot MSIs -call "%~dp0..\msi\build.bat" -x86 -x64 +@rem The MSI project is gone, so instead we will just +@rem build and then do a default layout. +call "%~dp0..\..\PCbuild\build.bat" -e -k -v %* +call "%~dp0..\..\python.exe" "%~dp0..\..\PC\layout" --preset-default -o "%~dp0..\..\PCbuild\output" popd \ No newline at end of file diff --git a/Tools/c-analyzer/TODO b/Tools/c-analyzer/TODO index 2077534ccf41286..ec07ea6aa9ff7dc 100644 --- a/Tools/c-analyzer/TODO +++ b/Tools/c-analyzer/TODO @@ -427,8 +427,6 @@ Objects/typeobject.c:type_new():PyId___slots__ _Py_IDENTIFIER( Objects/unicodeobject.c:unicodeiter_reduce():PyId_iter _Py_IDENTIFIER(iter) Objects/weakrefobject.c:proxy_bytes():PyId___bytes__ _Py_IDENTIFIER(__bytes__) Objects/weakrefobject.c:weakref_repr():PyId___name__ _Py_IDENTIFIER(__name__) -Parser/tokenizer/file_tokenizer.c:fp_setreadl():PyId_open _Py_IDENTIFIER(open) -Parser/tokenizer/file_tokenizer.c:fp_setreadl():PyId_readline _Py_IDENTIFIER(readline) Python/Python-ast.c:ast_type_reduce():PyId___dict__ _Py_IDENTIFIER(__dict__) Python/Python-ast.c:make_type():PyId___module__ _Py_IDENTIFIER(__module__) Python/_warnings.c:PyId_stderr _Py_IDENTIFIER(stderr) diff --git a/Tools/c-analyzer/c_common/fsutil.py b/Tools/c-analyzer/c_common/fsutil.py index a8cf8d0537e40db..eb9b74d552ece00 100644 --- a/Tools/c-analyzer/c_common/fsutil.py +++ b/Tools/c-analyzer/c_common/fsutil.py @@ -411,7 +411,7 @@ def _get_user_info(user): if user is None: uid = os.geteuid() #username = os.getlogin() - username = pwd.getpwuid(uid)[0] + username = pwd.getpwuid(uid).pw_name gid = os.getgid() groups = os.getgroups() else: diff --git a/Tools/c-analyzer/c_parser/parser/_regexes.py b/Tools/c-analyzer/c_parser/parser/_regexes.py index c1a8ab3ad2f15da..65fe2f929a942e3 100644 --- a/Tools/c-analyzer/c_parser/parser/_regexes.py +++ b/Tools/c-analyzer/c_parser/parser/_regexes.py @@ -340,7 +340,10 @@ def _ind(text, level=1, edges='both'): # This is actually a "constant expression". \d+ | - [^'",}}]+ + [^'",(}}]+ + | + # Parens may hold commas (e.g. from offsetof()). + [^'";}}]+ (?= ; ) ) )? \s* diff --git a/Tools/c-analyzer/cpython/_parser.py b/Tools/c-analyzer/cpython/_parser.py index 2875f45cb8d3756..caac194d3b7efb6 100644 --- a/Tools/c-analyzer/cpython/_parser.py +++ b/Tools/c-analyzer/cpython/_parser.py @@ -63,7 +63,6 @@ def format_tsv_lines(lines): 'Python/dynload_hpux.c', # dl.h 'Python/emscripten_signal.c', 'Python/emscripten_syscalls.c', - 'Python/emscripten_trampoline_inner.c', 'Python/thread_pthread.h', 'Python/thread_pthread_stubs.h', @@ -318,7 +317,8 @@ def format_tsv_lines(lines): _abs('Modules/_remote_debugging/debug_offsets_validation.h'): (25_000, 1000), _abs('Modules/_remote_debugging/*.h'): (20_000, 1000), _abs('Modules/_testcapimodule.c'): (20_000, 400), - _abs('Modules/expat/expat.h'): (10_000, 400), + _abs('Modules/_testclinic.c'): (20_000, 400), + _abs('Modules/expat/expat.h'): (10_000, 500), _abs('Objects/stringlib/unicode_format.h'): (10_000, 400), _abs('Objects/typeobject.c'): (380_000, 13_000), _abs('Python/compile.c'): (20_000, 500), @@ -334,6 +334,8 @@ def format_tsv_lines(lines): _abs('Include/internal/pycore_opcode.h'): (10_000, 1000), _abs('Include/internal/pycore_global_strings.h'): (5_000, 1000), _abs('Include/internal/pycore_runtime_init_generated.h'): (5_000, 1000), + _abs('Include/internal/pycore_unicodeobject_generated.h'): (100_000, 1500), + _abs('Python/Python-ast.c'): (20_000, 500), _abs('Python/deepfreeze/*.c'): (20_000, 500), _abs('Python/frozen_modules/*.h'): (20_000, 500), _abs('Python/opcode_targets.h'): (10_000, 500), @@ -344,7 +346,7 @@ def format_tsv_lines(lines): _abs('Modules/_ssl_data_300.h'): (80_000, 10_000), _abs('Modules/_ssl_data_111.h'): (80_000, 10_000), _abs('Modules/cjkcodecs/mappings_*.h'): (160_000, 2_000), - _abs('Modules/clinic/_testclinic.c.h'): (125_000, 5_000), + _abs('Modules/clinic/_testclinic.c.h'): (180_000, 5_500), _abs('Modules/unicodedata_db.h'): (180_000, 3_000), _abs('Modules/unicodename_db.h'): (1_200_000, 15_000), _abs('Objects/unicodetype_db.h'): (240_000, 3_000), diff --git a/Tools/c-analyzer/cpython/globals-to-fix.tsv b/Tools/c-analyzer/cpython/globals-to-fix.tsv index db575d870be5c53..3695208a09f0d5d 100644 --- a/Tools/c-analyzer/cpython/globals-to-fix.tsv +++ b/Tools/c-analyzer/cpython/globals-to-fix.tsv @@ -58,7 +58,6 @@ Objects/genobject.c - _PyCoroWrapper_Type - Objects/interpolationobject.c - _PyInterpolation_Type - Objects/iterobject.c - PyCallIter_Type - Objects/iterobject.c - PySeqIter_Type - -Objects/iterobject.c - _PyAnextAwaitable_Type - Objects/lazyimportobject.c - PyLazyImport_Type - Objects/listobject.c - PyListIter_Type - Objects/listobject.c - PyListRevIter_Type - @@ -73,7 +72,6 @@ Objects/moduleobject.c - PyModule_Type - Objects/namespaceobject.c - _PyNamespace_Type - Objects/object.c - _PyNone_Type - Objects/object.c - _PyNotImplemented_Type - -Objects/object.c - _PyAnextAwaitable_Type - Objects/odictobject.c - PyODictItems_Type - Objects/odictobject.c - PyODictIter_Type - Objects/odictobject.c - PyODictKeys_Type - @@ -346,13 +344,10 @@ Modules/_testcapi/vectorcall.c - MethodDescriptorBase_Type - Modules/_testcapi/vectorcall.c - MethodDescriptorDerived_Type - Modules/_testcapi/vectorcall.c - MethodDescriptorNopGet_Type - Modules/_testcapi/vectorcall.c - MethodDescriptor2_Type - -Modules/_testclinic.c - DeprStarInit - -Modules/_testclinic.c - DeprStarInitNoInline - -Modules/_testclinic.c - DeprStarNew - -Modules/_testclinic.c - DeprKwdInit - -Modules/_testclinic.c - DeprKwdInitNoInline - -Modules/_testclinic.c - DeprKwdNew - Modules/_testclinic.c - TestClass - +Modules/_testclinic.c - VcKwOnly_Type - +Modules/_testclinic.c - VcNew_Type - +Modules/_testclinic.c - VcNewBase_Type - ################################## @@ -400,10 +395,6 @@ Modules/xxmodule.c - ErrorObject - ## state Modules/_datetimemodule.c - _datetime_global_state - -Modules/_tkinter.c - tcl_lock - -Modules/_tkinter.c - excInCmd - -Modules/_tkinter.c - valInCmd - -Modules/_tkinter.c - trbInCmd - Modules/socketmodule.c - netdb_lock - @@ -434,15 +425,14 @@ Modules/readline.c - libedit_history_start - Modules/_ctypes/malloc_closure.c - free_list - Modules/_curses_panel.c - lop - Modules/_ssl/debughelpers.c _PySSL_keylog_callback lock - -Modules/_tkinter.c - quitMainLoop - -Modules/_tkinter.c - errorInCmd - Modules/_tkinter.c - Tkinter_busywaitinterval - Modules/_tkinter.c - call_mutex - Modules/_tkinter.c - var_mutex - Modules/_tkinter.c - command_mutex - Modules/_tkinter.c - HeadFHCD - Modules/_tkinter.c - stdin_ready - -Modules/_tkinter.c - event_tstate - +Modules/_tkinter.c - event_hook_users - +Modules/_tkinter.c - event_hook_mutex - Modules/readline.c - completer_word_break_characters - Modules/readline.c - _history_length - Modules/readline.c - should_auto_add_history - diff --git a/Tools/c-analyzer/cpython/ignored.tsv b/Tools/c-analyzer/cpython/ignored.tsv index 6e18593ad698570..4b1039269377dfa 100644 --- a/Tools/c-analyzer/cpython/ignored.tsv +++ b/Tools/c-analyzer/cpython/ignored.tsv @@ -19,13 +19,14 @@ Python/bootstrap_hash.c py_getrandom getrandom_works - Python/bootstrap_hash.c py_getentropy getentropy_works - Python/fileutils.c - _Py_open_cloexec_works - Python/fileutils.c set_inheritable ioctl_works - -# (set lazily, *after* first init) -# XXX Is this thread-safe? -Modules/posixmodule.c os_dup2_impl dup3_works - +# (set lazily, atomically, *after* first init) +Modules/posixmodule.c os_dup2_impl dup3_works_atomic - +Modules/posixmodule.c os_pipe_impl pipe2_works_atomic - ## guards around resource init Python/thread_pthread.h PyThread__init_thread lib_initialized - Modules/_struct.c - endian_tables_init_once - +Modules/_ctypes/callbacks.c - closure_alloc_init_once - ##----------------------- ## other values (not Python-specific) @@ -56,6 +57,10 @@ Python/pyhash.c - _Py_HashSecret - ## thread-safe hashtable (internal locks) Python/parking_lot.c - buckets - +Python/pystate.c - state_freelists - + +## shared empty sentinel for the per-type method cache +Python/typecache.c - empty_cache - ## data needed for introspecting asyncio state from debuggers and profilers Modules/_asynciomodule.c - _Py_AsyncioDebug - @@ -236,11 +241,8 @@ Modules/_decimal/_decimal.c - cond_map_template - Modules/_decimal/_decimal.c - dec_signal_string - Modules/_decimal/_decimal.c - dflt_ctx - Modules/_decimal/_decimal.c - int_constants - -Modules/_decimal/_decimal.c - invalid_rounding_err - -Modules/_decimal/_decimal.c - invalid_signals_err - Modules/_decimal/_decimal.c - signal_map_template - Modules/_decimal/_decimal.c - ssize_constants - -Modules/_decimal/_decimal.c - INVALID_SIGNALDICT_ERROR_MSG - Modules/_elementtree.c - ExpatMemoryHandler - Modules/_hashopenssl.c - py_hashes - Modules/_hacl/Hacl_Hash_SHA1.c - _h0 - @@ -261,6 +263,7 @@ Modules/_struct.c - bigendian_table - Modules/_struct.c - lilendian_table - Modules/_struct.c - native_table - Modules/_tkinter.c - state_key - +Modules/_tkinter.c - excInCmd_key - Modules/_interpchannelsmodule.c - _channelid_end_recv - Modules/_interpchannelsmodule.c - _channelid_end_send - Modules/_zoneinfo.c - DAYS_BEFORE_MONTH - @@ -314,6 +317,7 @@ Modules/cmathmodule.c - sinh_special_values - Modules/cmathmodule.c - sqrt_special_values - Modules/cmathmodule.c - tanh_special_values - Modules/config.c - _PyImport_Inittab - +Modules/config_bootstrap.c - _PyImport_Inittab - Modules/faulthandler.c - faulthandler_handlers - Modules/getnameinfo.c - gni_afdl - Modules/hmacmodule.c - py_hmac_static_hinfo - @@ -362,6 +366,7 @@ Objects/unicodeobject.c unicode_translate_call_errorhandler argparse - Parser/parser.c - reserved_keywords - Parser/parser.c - soft_keywords - Parser/lexer/lexer.c - type_comment_prefix - +Python/Python-ast.c add_ast_annotations builtin_types const array of pointers to static builtin types Python/ceval.c - _PyEval_BinaryOps - Python/ceval.c - _Py_INTERPRETER_TRAMPOLINE_INSTRUCTIONS - Python/ceval.c - _Py_INTERPRETER_TRAMPOLINE_INSTRUCTIONS_PTR - @@ -460,6 +465,13 @@ Modules/_testcapi/datetime.c - test_run_counter - Modules/_testcapi/docstring.c - DocStringNoSignatureTest - Modules/_testcapi/docstring.c - DocStringUnrepresentableSignatureTest - Modules/_testcapi/exceptions.c - PyRecursingInfinitelyError_Type - +Modules/_testcapi/fpcast.c - last_set_value - +Modules/_testcapi/fpcast.c - FpcastTestType - +Modules/_testcapi/fpcast.c - FpcastCallable0 - +Modules/_testcapi/fpcast.c - FpcastCallable1 - +Modules/_testcapi/fpcast.c - FpcastCallable2 - +Modules/_testcapi/fpcast.c - FpcastCallable3 - +Modules/_testcapi/fpcast.c - FpcastCallable4 - Modules/_testcapi/heaptype.c - _testcapimodule - Modules/_testcapi/mem.c - FmData - Modules/_testcapi/mem.c - FmHook - @@ -516,6 +528,7 @@ Modules/_testcapimodule.c - MethodDescriptor2_Type - Modules/_testcapimodule.c - MethodDescriptorBase_Type - Modules/_testcapimodule.c - MethodDescriptorDerived_Type - Modules/_testcapimodule.c - MethodDescriptorNopGet_Type - +Modules/_testcapimodule.c - MyListDictSubclass_Type - Modules/_testcapimodule.c - MyList_Type - Modules/_testcapimodule.c - PyRecursingInfinitelyError_Type - Modules/_testcapimodule.c - TestError - @@ -774,6 +787,7 @@ Modules/expat/xmlrole.c - condSect1 - Modules/expat/xmlrole.c - condSect2 - Modules/expat/xmlrole.c - declClose - Modules/expat/xmlrole.c - error - +Python/preconfig.c - Py_UTF8Mode - ## other Modules/_io/_iomodule.c - _PyIO_Module - @@ -784,7 +798,9 @@ Modules/clinic/grpmodule.c.h grp_getgrgid _keywords - Modules/clinic/grpmodule.c.h grp_getgrnam _keywords - Objects/object.c - constants static PyObject*[] Objects/dictobject.c - PyFrozenDict_Type - - +Modules/_testcapi/unicode.c test_py_identifier PyId_hello - +Modules/_testcapi/unicode.c test_py_identifier to_bytes_id - +Modules/_testcapi/unicode.c test_py_identifier real_id - ## False positives Python/specialize.c - _Py_InitCleanup - diff --git a/Tools/c-analyzer/distutils/dep_util.py b/Tools/c-analyzer/distutils/dep_util.py index 318c830f2eab3e3..a97f925d9ee4187 100644 --- a/Tools/c-analyzer/distutils/dep_util.py +++ b/Tools/c-analyzer/distutils/dep_util.py @@ -20,9 +20,8 @@ def newer (source, target): if not os.path.exists(target): return 1 - from stat import ST_MTIME - mtime1 = os.stat(source)[ST_MTIME] - mtime2 = os.stat(target)[ST_MTIME] + mtime1 = os.stat(source).st_mtime + mtime2 = os.stat(target).st_mtime return mtime1 > mtime2 diff --git a/Tools/cases_generator/analyzer.py b/Tools/cases_generator/analyzer.py index 4eed4d8d60e4856..c3e0b0dbff21993 100644 --- a/Tools/cases_generator/analyzer.py +++ b/Tools/cases_generator/analyzer.py @@ -480,64 +480,6 @@ def error(tkn: lexer.Token) -> None: return res -#def analyze_deferred_refs(node: parser.InstDef) -> dict[lexer.Token, str | None]: - #"""Look for PyStackRef_FromPyObjectNew() calls""" - - #def in_frame_push(idx: int) -> bool: - #for tkn in reversed(node.block.tokens[: idx - 1]): - #if tkn.kind in {"SEMI", "LBRACE", "RBRACE"}: - #return False - #if tkn.kind == "IDENTIFIER" and tkn.text == "_PyFrame_PushUnchecked": - #return True - #return False - - #refs: dict[lexer.Token, str | None] = {} - #for idx, tkn in enumerate(node.block.tokens): - #if tkn.kind != "IDENTIFIER" or tkn.text != "PyStackRef_FromPyObjectNew": - #continue - - #if idx == 0 or node.block.tokens[idx - 1].kind != "EQUALS": - #if in_frame_push(idx): - ## PyStackRef_FromPyObjectNew() is called in _PyFrame_PushUnchecked() - #refs[tkn] = None - #continue - #raise analysis_error("Expected '=' before PyStackRef_FromPyObjectNew", tkn) - - #lhs = find_assignment_target(node, idx - 1) - #if len(lhs) == 0: - #raise analysis_error( - #"PyStackRef_FromPyObjectNew() must be assigned to an output", tkn - #) - - #if lhs[0].kind == "TIMES" or any( - #t.kind == "ARROW" or t.kind == "LBRACKET" for t in lhs[1:] - #): - ## Don't handle: *ptr = ..., ptr->field = ..., or ptr[field] = ... - ## Assume that they are visible to the GC. - #refs[tkn] = None - #continue - - #if len(lhs) != 1 or lhs[0].kind != "IDENTIFIER": - #raise analysis_error( - #"PyStackRef_FromPyObjectNew() must be assigned to an output", tkn - #) - - #name = lhs[0].text - #match = ( - #any(var.name == name for var in node.inputs) - #or any(var.name == name for var in node.outputs) - #) - #if not match: - #raise analysis_error( - #f"PyStackRef_FromPyObjectNew() must be assigned to an input or output, not '{name}'", - #tkn, - #) - - #refs[tkn] = name - - #return refs - - def variable_used(node: parser.CodeDef, name: str) -> bool: """Determine whether a variable with a given name is used in a node.""" return any( @@ -971,6 +913,7 @@ def compute_properties(op: parser.CodeDef) -> Properties: or variable_used(op, "PyCell_GetRef") or variable_used(op, "PyCell_SetTakeRef") or variable_used(op, "PyCell_SwapTakeRef") + or variable_used(op, "_PyCell_GetStackRef") ) deopts_if = variable_used(op, "DEOPT_IF") exits_if = variable_used(op, "EXIT_IF") diff --git a/Tools/check-c-api-docs/ignored_c_api.txt b/Tools/check-c-api-docs/ignored_c_api.txt index fa53b205c4ff6af..6e1b77ba2786cb0 100644 --- a/Tools/check-c-api-docs/ignored_c_api.txt +++ b/Tools/check-c-api-docs/ignored_c_api.txt @@ -1,89 +1 @@ -# pydtrace_probes.h -PyDTrace_AUDIT -PyDTrace_FUNCTION_ENTRY -PyDTrace_FUNCTION_RETURN -PyDTrace_GC_DONE -PyDTrace_GC_START -PyDTrace_IMPORT_FIND_LOAD_DONE -PyDTrace_IMPORT_FIND_LOAD_START -PyDTrace_INSTANCE_DELETE_DONE -PyDTrace_INSTANCE_DELETE_START -PyDTrace_INSTANCE_NEW_DONE -PyDTrace_INSTANCE_NEW_START -PyDTrace_LINE -# fileobject.h -Py_FileSystemDefaultEncodeErrors -Py_FileSystemDefaultEncoding -Py_HasFileSystemDefaultEncoding -Py_UTF8Mode -# pyhash.h -Py_HASH_EXTERNAL -# object.h -Py_INVALID_SIZE -# pyexpat.h -PyExpat_CAPI_MAGIC -PyExpat_CAPSULE_NAME -# pyport.h -PYLONG_BITS_IN_DIGIT -PY_DWORD_MAX -PY_BIG_ENDIAN -# cpython/methodobject.h -PyCFunction_GET_CLASS -# cpython/compile.h -PyCF_ALLOW_INCOMPLETE_INPUT -PyCF_COMPILE_MASK -PyCF_DONT_IMPLY_DEDENT -PyCF_IGNORE_COOKIE -PyCF_MASK -PyCF_MASK_OBSOLETE -PyCF_SOURCE_IS_UTF8 -# cpython/descrobject.h -PyDescr_NAME -PyDescr_TYPE -PyWrapperFlag_KEYWORDS -# cpython/fileobject.h -Py_UniversalNewlineFgets -# cpython/pyframe.h -PyUnstable_EXECUTABLE_KINDS -PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION -PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR -PyUnstable_EXECUTABLE_KIND_PY_FUNCTION -PyUnstable_EXECUTABLE_KIND_SKIP -# cpython/pylifecycle.h -Py_FrozenMain -# pythonrun.h -PyErr_Display -# cpython/objimpl.h -PyObject_GET_WEAKREFS_LISTPTR -# cpython/pythonrun.h -PyOS_Readline -# cpython/warnings.h -PyErr_Warn -# fileobject.h -PY_STDIOTEXTMODE -# structmember.h -PY_WRITE_RESTRICTED -# pythread.h -PY_TIMEOUT_T -PY_TIMEOUT_MAX -# cpython/pyctype.h -PY_CTF_ALNUM -PY_CTF_ALPHA -PY_CTF_DIGIT -PY_CTF_LOWER -PY_CTF_SPACE -PY_CTF_UPPER -PY_CTF_XDIGIT -# cpython/code.h -PY_DEF_EVENT -PY_FOREACH_CODE_EVENT -# cpython/funcobject.h -PY_DEF_EVENT -PY_FOREACH_FUNC_EVENT -# cpython/monitoring.h -PY_MONITORING_EVENT_BRANCH -# cpython/dictobject.h -PY_DEF_EVENT -PY_FOREACH_DICT_EVENT -# cpython/pystats.h -PYSTATS_MAX_UOP_ID +# Nothing here :) diff --git a/Tools/clinic/libclinic/__init__.py b/Tools/clinic/libclinic/__init__.py index 5ee165d0c138a85..ff8f44be0b774ff 100644 --- a/Tools/clinic/libclinic/__init__.py +++ b/Tools/clinic/libclinic/__init__.py @@ -26,6 +26,8 @@ is_legal_py_identifier, ) from .utils import ( + FileChange, + FileWriter, FormatCounterFormatter, NULL, NullType, @@ -33,6 +35,7 @@ VersionTuple, compute_checksum, create_regex, + read_file, unknown, unspecified, write_file, @@ -66,6 +69,8 @@ "is_legal_py_identifier", # Utility functions + "FileChange", + "FileWriter", "FormatCounterFormatter", "NULL", "NullType", @@ -73,6 +78,7 @@ "VersionTuple", "compute_checksum", "create_regex", + "read_file", "unknown", "unspecified", "write_file", diff --git a/Tools/clinic/libclinic/app.py b/Tools/clinic/libclinic/app.py index 9e8cec5320f8772..8cb9d38ebe4a2b3 100644 --- a/Tools/clinic/libclinic/app.py +++ b/Tools/clinic/libclinic/app.py @@ -15,7 +15,7 @@ if TYPE_CHECKING: from libclinic.clanguage import CLanguage from libclinic.function import ( - Module, Function, ClassDict, ModuleDict) + Module, Function, Property, ClassDict, ModuleDict) from libclinic.codegen import DestinationDict @@ -87,6 +87,7 @@ def __init__( filename: str, limited_capi: bool, verify: bool = True, + writer: libclinic.FileWriter | None = None, ) -> None: # maps strings to Parser objects. # (instantiated from the "parsers" global.) @@ -95,12 +96,15 @@ def __init__( if printer: fail("Custom printers are broken right now") self.printer = printer or BlockPrinter(language) + self.writer = writer or libclinic.FileWriter() self.verify = verify self.limited_capi = limited_capi self.filename = filename self.modules: ModuleDict = {} self.classes: ClassDict = {} self.functions: list[Function] = [] + # The attributes implemented by accessors, in the order of definition. + self.properties: list[Property] = [] self.codegen = CodeGen(self.limited_capi) self.line_prefix = self.line_suffix = '' @@ -120,7 +124,9 @@ def __init__( 'methoddef_define': d('file'), 'impl_prototype': d('file'), 'parser_prototype': d('suppress'), + 'parser_helper': d('file'), 'parser_definition': d('file'), + 'vectorcall_definition': d('file'), 'cpp_endif': d('file'), 'methoddef_ifndef': d('file', 1), 'impl_definition': d('block'), @@ -193,6 +199,10 @@ def parse(self, input: str) -> str: parser.parse(block) printer.print_block(block) + # The entry of an attribute is composed of all its accessors, so it + # is rendered when the whole file is parsed. + self.language.render_properties(self) + # these are destinations not buffers for name, destination in self.destinations.items(): if destination.type == 'suppress': @@ -213,7 +223,7 @@ def parse(self, input: str) -> str: try: dirname = os.path.dirname(destination.filename) try: - os.makedirs(dirname) + self.writer.makedirs(dirname) except FileExistsError: if not os.path.isdir(dirname): fail(f"Can't write to destination " @@ -234,8 +244,8 @@ def parse(self, input: str) -> str: printer_2 = BlockPrinter(self.language) printer_2.print_block(block, header_includes=includes) - libclinic.write_file(destination.filename, - printer_2.f.getvalue()) + self.writer.write(destination.filename, + printer_2.f.getvalue()) continue return printer.f.getvalue() diff --git a/Tools/clinic/libclinic/clanguage.py b/Tools/clinic/libclinic/clanguage.py index 7f02c7790f015aa..f8ab2fd25154614 100644 --- a/Tools/clinic/libclinic/clanguage.py +++ b/Tools/clinic/libclinic/clanguage.py @@ -1,22 +1,23 @@ from __future__ import annotations import itertools -import sys import textwrap -from typing import TYPE_CHECKING, Literal, Final +from typing import TYPE_CHECKING, Final from operator import attrgetter from collections.abc import Iterable import libclinic.cpp -from libclinic import ( - unspecified, fail, Sentinels, VersionTuple) -from libclinic.codegen import CRenderData, TemplateDict, CodeGen +from libclinic import unspecified, fail, VersionTuple +from libclinic.codegen import CRenderData, CodeGen from libclinic.language import Language from libclinic.function import ( - Module, Class, Function, Parameter, - permute_optional_groups, - GETTER, SETTER, METHOD_INIT) + Module, Class, Property, Function, Parameter, + group_to_variable_name, + METHOD_INIT, METHOD_NEW, SLOT, + ACCESSORS, SETTERS) from libclinic.converters import self_converter -from libclinic.parse_args import ParseArgsCodeGen +from libclinic.parse_args import ( + ParseArgsCodeGen, + GETSETDEF_PROTOTYPE_COMBINE, GETSETDEF_PROTOTYPE_DEFINE) if TYPE_CHECKING: from libclinic.app import Clinic @@ -78,10 +79,68 @@ def render( for o in signatures: if isinstance(o, Function): if function: - fail("You may specify at most one function per block.\nFound a block containing at least two:\n\t" + repr(function) + " and " + repr(o)) + fail("You may specify at most one function per block.\n" + "Found a block containing at least two:\n\t" + + repr(function) + " and " + repr(o), + line_number=o.line_number) function = o return self.render_function(clinic, function) + def render_properties(self, clinic: Clinic) -> None: + """Compose the PyGetSetDef entry of every attribute not composed yet. + + All accessors of an attribute are only known when all blocks of the + file are rendered or the destination is dumped. + """ + destination = clinic.destination_buffers['methoddef_ifndef'] + for prop in clinic.properties: + if prop.rendered: + continue + prop.rendered = True + s = self.render_property(prop) + '\n' + if clinic.line_prefix: + s = libclinic.indent_all_lines(s, clinic.line_prefix) + if clinic.line_suffix: + s = libclinic.suffix_all_lines(s, clinic.line_suffix) + destination.append(s) + + def render_property(self, prop: Property) -> str: + getset_name = prop.getset_name + template_dict = { + 'name': prop.name, + 'getset_name': getset_name, + } + parts: list[str] = [] + if prop.is_plain: + getter = prop.getter[0] if prop.getter else None + setter = prop.setter[0] if prop.setter else None + template_dict['getter'] = (getter.accessor_basename if getter + else 'NULL') + template_dict['setter'] = (setter.accessor_basename if setter + else 'NULL') + template_dict['docstr'] = (f'{getter.c_basename}__doc__' + if getter and getter.docstring + else 'NULL') + parts.append(GETSETDEF_PROTOTYPE_DEFINE.format_map(template_dict) + + '\n') + else: + # Which of the conditionally compiled accessors are compiled is + # only known to the preprocessor. They announce themselves, so + # only the unconditional ones are announced here. + for suffix, funcs in (('GETTER', prop.getter), + ('SETTER', prop.setter)): + for func in funcs: + if func.condition: + continue + parts.append(f"#define {getset_name}_{suffix} " + f"{func.accessor_basename}\n") + if suffix == 'GETTER' and func.docstring: + parts.append(f"#define {getset_name}_DOCSTR " + f"{func.c_basename}__doc__\n") + parts.append(GETSETDEF_PROTOTYPE_COMBINE.format_map(template_dict) + + '\n') + return ''.join(parts) + def compiler_deprecated_warning( self, func: Function, @@ -89,7 +148,8 @@ def compiler_deprecated_warning( ) -> str | None: minversion: VersionTuple | None = None for p in parameters: - for version in p.deprecated_positional, p.deprecated_keyword: + for version in (p.deprecated_positional, p.deprecated_keyword, + p.deprecated_until): if version and (not minversion or minversion > version): minversion = version if not minversion: @@ -247,116 +307,6 @@ def output_templates( args = ParseArgsCodeGen(f, codegen) return args.parse_args(self) - @staticmethod - def group_to_variable_name(group: int) -> str: - adjective = "left_" if group < 0 else "right_" - return "group_" + adjective + str(abs(group)) - - def render_option_group_parsing( - self, - f: Function, - template_dict: TemplateDict, - limited_capi: bool, - ) -> None: - # positional only, grouped, optional arguments! - # can be optional on the left or right. - # here's an example: - # - # [ [ [ A1 A2 ] B1 B2 B3 ] C1 C2 ] D1 D2 D3 [ E1 E2 E3 [ F1 F2 F3 ] ] - # - # Here group D are required, and all other groups are optional. - # (Group D's "group" is actually None.) - # We can figure out which sets of arguments we have based on - # how many arguments are in the tuple. - # - # Note that you need to count up on both sides. For example, - # you could have groups C+D, or C+D+E, or C+D+E+F. - # - # What if the number of arguments leads us to an ambiguous result? - # Clinic prefers groups on the left. So in the above example, - # five arguments would map to B+C, not C+D. - - out = [] - parameters = list(f.parameters.values()) - if isinstance(parameters[0].converter, self_converter): - del parameters[0] - - group: list[Parameter] | None = None - left = [] - right = [] - required: list[Parameter] = [] - last: int | Literal[Sentinels.unspecified] = unspecified - - for p in parameters: - group_id = p.group - if group_id != last: - last = group_id - group = [] - if group_id < 0: - left.append(group) - elif group_id == 0: - group = required - else: - right.append(group) - assert group is not None - group.append(p) - - count_min = sys.maxsize - count_max = -1 - - if limited_capi: - nargs = 'PyTuple_Size(args)' - else: - nargs = 'PyTuple_GET_SIZE(args)' - out.append(f"switch ({nargs}) {{\n") - for subset in permute_optional_groups(left, required, right): - count = len(subset) - count_min = min(count_min, count) - count_max = max(count_max, count) - - if count == 0: - out.append(""" case 0: - break; -""") - continue - - group_ids = {p.group for p in subset} # eliminate duplicates - d: dict[str, str | int] = {} - d['count'] = count - d['name'] = f.name - d['format_units'] = "".join(p.converter.format_unit for p in subset) - - parse_arguments: list[str] = [] - for p in subset: - p.converter.parse_argument(parse_arguments) - d['parse_arguments'] = ", ".join(parse_arguments) - - group_ids.discard(0) - lines = "\n".join([ - self.group_to_variable_name(g) + " = 1;" - for g in group_ids - ]) - - s = """\ - case {count}: - if (!PyArg_ParseTuple(args, "{format_units}:{name}", {parse_arguments})) {{ - goto exit; - }} - {group_booleans} - break; -""" - s = libclinic.linear_format(s, group_booleans=lines) - s = s.format_map(d) - out.append(s) - - out.append(" default:\n") - s = ' PyErr_SetString(PyExc_TypeError, "{} requires {} to {} arguments");\n' - out.append(s.format(f.full_name, count_min, count_max)) - out.append(' goto exit;\n') - out.append("}") - - template_dict['option_group_parsing'] = libclinic.format_escape("".join(out)) - def render_function( self, clinic: Clinic, @@ -409,7 +359,7 @@ def render_function( if last_group != group: last_group = group if group: - group_name = self.group_to_variable_name(group) + group_name = group_to_variable_name(group) data.impl_arguments.append(group_name) data.declarations.append("int " + group_name + " = 0;") data.impl_parameters.append("int " + group_name) @@ -419,7 +369,8 @@ def render_function( if has_option_groups and (not positional): fail("You cannot use optional groups ('[' and ']') " - "unless all parameters are positional-only ('/').") + "unless all parameters are positional-only ('/').", + line_number=f.line_number) # HACK # when we're METH_O, but have a custom return converter, @@ -432,20 +383,21 @@ def render_function( if ("METH_O" in templates['methoddef_define'] and '{parser_parameters}' in templates['parser_prototype']): data.declarations.pop(0) + # A slot function receives its arguments as parameters, see + # parse_slot(): there is nothing to declare or parse. + if f.kind is SLOT: + data.declarations.clear() full_name = f.full_name template_dict = {'full_name': full_name} template_dict['name'] = f.displayname - if f.kind in {GETTER, SETTER}: - template_dict['getset_name'] = f.c_basename.upper() + if f.kind in ACCESSORS: + # The accessors of the same attribute are rendered into a single + # PyGetSetDef entry, which is identified by the Python name. + assert f.property is not None + template_dict['getset_name'] = f.property.getset_name template_dict['getset_basename'] = f.c_basename - if f.kind is GETTER: - template_dict['c_basename'] = f.c_basename + "_get" - elif f.kind is SETTER: - template_dict['c_basename'] = f.c_basename + "_set" - # Implicitly add the setter value parameter. - data.impl_parameters.append("PyObject *value") - data.impl_arguments.append("value") + template_dict['c_basename'] = f.accessor_basename else: template_dict['methoddef_name'] = f.c_basename.upper() + "_METHODDEF" template_dict['c_basename'] = f.c_basename @@ -456,9 +408,17 @@ def render_function( for converter in converters: converter.set_template_dict(template_dict) - if f.kind not in {SETTER, METHOD_INIT}: + if f.kind not in SETTERS | {METHOD_INIT, SLOT}: f.return_converter.render(f, data) template_dict['impl_return_type'] = f.return_converter.type + # tp_init returns int, a slot function returns what its slot + # declares, every other parser returns an object. + if f.kind is SLOT: + assert f.slot is not None + template_dict['return_type'] = f.slot.return_type + else: + template_dict['return_type'] = ( + 'int' if f.kind is METHOD_INIT else 'PyObject *') template_dict['declarations'] = libclinic.format_escape("\n".join(data.declarations)) template_dict['initializers'] = "\n\n".join(data.initializers) @@ -478,11 +438,27 @@ def render_function( template_dict['parser_parameters'] = ", ".join(data.impl_parameters[1:]) template_dict['impl_arguments'] = ", ".join(data.impl_arguments) + # First vectorcall argument depends on method. + if f.vectorcall and f.cls: + if f.kind is METHOD_INIT: + vc_first = f"({f.cls.typedef})self" + elif f.kind is METHOD_NEW: + vc_first = "_PyType_CAST(type)" + else: + raise AssertionError( + f"Unhandled function kind for vectorcall: {f.kind!r}" + ) + vc_impl_args = [vc_first] + data.impl_arguments[1:] + template_dict['vectorcall_impl_arguments'] = ", ".join(vc_impl_args) + else: + pass + template_dict['return_conversion'] = libclinic.format_escape("".join(data.return_conversion).rstrip()) template_dict['post_parsing'] = libclinic.format_escape("".join(data.post_parsing).rstrip()) template_dict['cleanup'] = libclinic.format_escape("".join(data.cleanup)) template_dict['return_value'] = data.return_value + template_dict['parser_retval'] = data.parser_retval template_dict['lock'] = "\n".join(data.lock) template_dict['unlock'] = "\n".join(data.unlock) @@ -492,16 +468,9 @@ def render_function( template_dict['unpack_min'] = str(unpack_min) template_dict['unpack_max'] = str(unpack_max) - if has_option_groups: - self.render_option_group_parsing(f, template_dict, - limited_capi=codegen.limited_capi) - # buffers, not destination for name, destination in clinic.destination_buffers.items(): template = templates[name] - if has_option_groups: - template = libclinic.linear_format(template, - option_group_parsing=template_dict['option_group_parsing']) template = libclinic.linear_format(template, declarations=template_dict['declarations'], return_conversion=template_dict['return_conversion'], diff --git a/Tools/clinic/libclinic/cli.py b/Tools/clinic/libclinic/cli.py index f36c6d04efd3835..9629c1731779454 100644 --- a/Tools/clinic/libclinic/cli.py +++ b/Tools/clinic/libclinic/cli.py @@ -1,11 +1,12 @@ from __future__ import annotations import argparse +import difflib import inspect import os import re import sys -from collections.abc import Callable +from collections.abc import Callable, Iterable, Iterator, Mapping from typing import NoReturn @@ -21,6 +22,9 @@ return_converters, ReturnConverterType) from libclinic.clanguage import CLanguage from libclinic.app import Clinic +from libclinic.dsl_parser import render_text_signature +from libclinic.function import ( + Class, Definition, Module, GETTER, SETTER, walk_definitions) # TODO: @@ -52,9 +56,12 @@ def parse_file( limited_capi: bool, output: str | None = None, verify: bool = True, -) -> None: + writer: libclinic.FileWriter | None = None, +) -> Clinic | None: if not output: output = filename + if writer is None: + writer = libclinic.FileWriter() extension = os.path.splitext(filename)[1][1:] if not extension: @@ -65,13 +72,16 @@ def parse_file( except KeyError: raise ClinicError(f"Can't identify file type for file {filename!r}") + if os.path.isdir(filename): + raise ClinicError(f"Can't read file {filename!r}: it is a directory") + with open(filename, encoding="utf-8") as f: raw = f.read() # exit quickly if there are no clinic markers in the file find_start_re = BlockParser("", language).find_start_re if not find_start_re.search(raw): - return + return None if LIMITED_CAPI_REGEX.search(raw): limited_capi = True @@ -80,10 +90,41 @@ def parse_file( clinic = Clinic(language, verify=verify, filename=filename, - limited_capi=limited_capi) + limited_capi=limited_capi, + writer=writer) + index = len(writer.files) cooked = clinic.parse(raw) - - libclinic.write_file(output, cooked) + writer.write(output, cooked) + + files = writer.files[index:] + writer.update_times(output, + [fn for fn, _ in files if fn != output], + any(changed for _, changed in files)) + return clinic + + +def format_definition(depth: int, name: str, definition: Definition) -> str: + indent = " " * (depth + 1) + if isinstance(definition, Module): + return f"{indent}module {name}" + if isinstance(definition, Class): + return f"{indent}class {name}" + if definition.kind is GETTER: + return f"{indent}getter {name}" + if definition.kind is SETTER: + return f"{indent}setter {name}" + signature = render_text_signature(definition, definition.render_parameters, + name=name, line_width=None) + return indent + signature + + +def print_definitions(clinic: Clinic) -> None: + """Print the modules, classes and functions defined in the parsed file.""" + lines = [format_definition(depth, name, definition) + for depth, name, definition in walk_definitions(clinic)] + if lines: + print(clinic.filename) + print("\n".join(lines)) def create_cli() -> argparse.ArgumentParser: @@ -102,9 +143,21 @@ def create_cli() -> argparse.ArgumentParser: help="redirect file output to OUTPUT") cmdline.add_argument("-v", "--verbose", action='store_true', help="enable verbose mode") + cmdline.add_argument("--dry-run", action='store_true', + help=("don't write any file, only list the files " + "which would be changed")) + cmdline.add_argument("--diff", action='store_true', + help=("don't write any file, write a unified diff " + "of the changes to the standard output")) cmdline.add_argument("--converters", action='store_true', help=("print a list of all supported converters " - "and return converters")) + "and return converters; if files are " + "specified, print only the converters " + "which they define")) + cmdline.add_argument("--list", action='store_true', + help=("don't write any file, only list the modules, " + "classes and functions which the specified " + "files define, with their signatures")) cmdline.add_argument("--make", action='store_true', help="walk --srcdir to run over all relevant files") cmdline.add_argument("--srcdir", type=str, default=os.curdir, @@ -119,104 +172,169 @@ def create_cli() -> argparse.ArgumentParser: return cmdline -def run_clinic(parser: argparse.ArgumentParser, ns: argparse.Namespace) -> None: - if ns.converters: - if ns.filename: - parser.error( - "can't specify --converters and a filename at the same time" - ) - AnyConverterType = ConverterType | ReturnConverterType - converter_list: list[tuple[str, AnyConverterType]] = [] - return_converter_list: list[tuple[str, AnyConverterType]] = [] - - for name, converter in converters.items(): - converter_list.append(( - name, - converter, - )) - for name, return_converter in return_converters.items(): - return_converter_list.append(( - name, - return_converter - )) +def print_diff(change: libclinic.FileChange) -> None: + if change.old_contents is None: + fromfile = "/dev/null" + old_lines: list[str] = [] + else: + fromfile = change.filename + old_lines = change.old_contents.splitlines(keepends=True) + sys.stdout.writelines(difflib.unified_diff( + old_lines, + change.new_contents.splitlines(keepends=True), + fromfile=fromfile, + tofile=change.filename, + )) + + +def report_changes(writer: libclinic.FileWriter, *, diff: bool) -> None: + for change in sorted(writer.changes, key=lambda change: change.filename): + if diff: + print_diff(change) + else: + action = "create" if change.old_contents is None else "update" + print(f"would {action} {change.filename}") + + +AnyConverterType = ConverterType | ReturnConverterType - print() +def defined_in_files( + registry: Mapping[str, AnyConverterType], + builtin: Mapping[str, AnyConverterType], +) -> dict[str, AnyConverterType]: + """Return the converters which the parsed files define or redefine.""" + return {name: cls for name, cls in registry.items() + if builtin.get(name) is not cls} + + +def print_converter_list( + title: str, + attribute: str, + registry: Mapping[str, AnyConverterType], +) -> None: + print(title + ":") + for name, cls in sorted(registry.items(), key=lambda item: item[0].lower()): + callable = getattr(cls, attribute, None) + if not callable: + continue + signature = inspect.signature(callable) + parameters = [] + for parameter_name, parameter in signature.parameters.items(): + if parameter.kind == inspect.Parameter.KEYWORD_ONLY: + if parameter.default != inspect.Parameter.empty: + s = f'{parameter_name}={parameter.default!r}' + else: + s = parameter_name + parameters.append(s) + print(' {}({})'.format(name, ', '.join(parameters))) + print() + + +def print_converters( + converters: Mapping[str, AnyConverterType], + legacy_converters: Mapping[str, AnyConverterType], + return_converters: Mapping[str, AnyConverterType], +) -> None: + if not (converters or legacy_converters or return_converters): + return + print() + if legacy_converters: print("Legacy converters:") legacy = sorted(legacy_converters) - print(' ' + ' '.join(c for c in legacy if c[0].isupper())) - print(' ' + ' '.join(c for c in legacy if c[0].islower())) + # A converter defined in a file can use any string, even a C + # expression, as its format unit, not only a letter. + groups = ([c for c in legacy if c[0].isupper()], + [c for c in legacy if c[0].islower()], + [c for c in legacy if not c[0].isalpha()]) + for group in groups: + if group: + print(' ' + ' '.join(group)) print() + if converters: + print_converter_list("Converters", 'converter_init', converters) + if return_converters: + print_converter_list("Return converters", 'return_converter_init', + return_converters) + print("All converters also accept (c_default=None, py_default=None, annotation=None).") + print("All return converters also accept (py_default=None).") + + +def walk_srcdir(srcdir: str, exclude: list[str] | None) -> Iterator[str]: + """Yield the C files in the source directory tree.""" + if exclude: + excludes = [os.path.normpath(os.path.join(srcdir, f)) for f in exclude] + else: + excludes = [] + for root, dirs, files in os.walk(srcdir): + for rcs_dir in ('.svn', '.git', '.hg', 'build', 'externals'): + if rcs_dir in dirs: + dirs.remove(rcs_dir) + for filename in files: + # handle .c, .cpp and .h files + if not filename.endswith(('.c', '.cpp', '.h')): + continue + path = os.path.normpath(os.path.join(root, filename)) + if path in excludes: + continue + yield path - for title, attribute, ids in ( - ("Converters", 'converter_init', converter_list), - ("Return converters", 'return_converter_init', return_converter_list), - ): - print(title + ":") - - ids.sort(key=lambda item: item[0].lower()) - longest = -1 - for name, _ in ids: - longest = max(longest, len(name)) - - for name, cls in ids: - callable = getattr(cls, attribute, None) - if not callable: - continue - signature = inspect.signature(callable) - parameters = [] - for parameter_name, parameter in signature.parameters.items(): - if parameter.kind == inspect.Parameter.KEYWORD_ONLY: - if parameter.default != inspect.Parameter.empty: - s = f'{parameter_name}={parameter.default!r}' - else: - s = parameter_name - parameters.append(s) - print(' {}({})'.format(name, ', '.join(parameters))) - print() - print("All converters also accept (c_default=None, py_default=None, annotation=None).") - print("All return converters also accept (py_default=None).") - return +def run_clinic(parser: argparse.ArgumentParser, ns: argparse.Namespace) -> None: + dry_run = ns.dry_run or ns.diff + # The report is written to the standard output, so the progress + # is written to the standard error stream to not mix them. + verbose_file = sys.stderr if dry_run or ns.list else sys.stdout + + filenames: Iterable[str] if ns.make: if ns.output or ns.filename: parser.error("can't use -o or filenames with --make") if not ns.srcdir: parser.error("--srcdir must not be empty with --make") - if ns.exclude: - excludes = [os.path.join(ns.srcdir, f) for f in ns.exclude] - excludes = [os.path.normpath(f) for f in excludes] - else: - excludes = [] - for root, dirs, files in os.walk(ns.srcdir): - for rcs_dir in ('.svn', '.git', '.hg', 'build', 'externals'): - if rcs_dir in dirs: - dirs.remove(rcs_dir) - for filename in files: - # handle .c, .cpp and .h files - if not filename.endswith(('.c', '.cpp', '.h')): - continue - path = os.path.join(root, filename) - path = os.path.normpath(path) - if path in excludes: - continue - if ns.verbose: - print(path) - parse_file(path, - verify=not ns.force, limited_capi=ns.limited_capi) - return - - if not ns.filename: - parser.error("no input files") - - if ns.output and len(ns.filename) > 1: - parser.error("can't use -o with multiple filenames") + filenames = walk_srcdir(ns.srcdir, ns.exclude) + else: + if not ns.filename and not ns.converters: + parser.error("no input files") + if ns.output and len(ns.filename) > 1: + parser.error("can't use -o with multiple filenames") + filenames = ns.filename + + if ns.list: + if dry_run: + parser.error("can't use --dry-run or --diff with --list") + if ns.converters: + parser.error("can't use --converters with --list") - for filename in ns.filename: + if ns.converters: + if dry_run: + parser.error("can't use --dry-run or --diff with --converters") + if not ns.make and not ns.filename: + print_converters(converters, legacy_converters, return_converters) + return + # Converters defined in a file are added to the same registries + # as the built-in ones, so remember the latter to tell them apart. + builtin_converters = dict(converters) + builtin_legacy_converters = dict(legacy_converters) + builtin_return_converters = dict(return_converters) + + writer = libclinic.FileWriter(dry_run=dry_run or ns.converters or ns.list) + for filename in filenames: if ns.verbose: - print(filename) - parse_file(filename, output=ns.output, - verify=not ns.force, limited_capi=ns.limited_capi) + print(filename, file=verbose_file) + clinic = parse_file(filename, output=ns.output, + verify=not ns.force, limited_capi=ns.limited_capi, + writer=writer) + if ns.list and clinic is not None: + print_definitions(clinic) + + if ns.converters: + print_converters( + defined_in_files(converters, builtin_converters), + defined_in_files(legacy_converters, builtin_legacy_converters), + defined_in_files(return_converters, builtin_return_converters)) + elif not ns.list: + report_changes(writer, diff=ns.diff) def main(argv: list[str] | None = None) -> NoReturn: diff --git a/Tools/clinic/libclinic/codegen.py b/Tools/clinic/libclinic/codegen.py index b2f1db6f8ef8da7..3ca8c4a1b6859db 100644 --- a/Tools/clinic/libclinic/codegen.py +++ b/Tools/clinic/libclinic/codegen.py @@ -47,14 +47,17 @@ def __init__(self) -> None: # The arguments to the impl function at the time it's called. self.impl_arguments: list[str] = [] + # The name of the variable which is returned by the parser. + self.parser_retval = "return_value" + # For return converters: the name of the variable that # should receive the value returned by the impl. self.return_value = "return_value" # For return converters: the code to convert the return # value from the parse function. This is also where - # you should check the _return_value for errors, and - # "goto exit" if there are any. + # you should check the value returned by the impl for errors, + # and "goto exit" if there are any. self.return_conversion: list[str] = [] self.converter_retval = "_return_value" diff --git a/Tools/clinic/libclinic/converter.py b/Tools/clinic/libclinic/converter.py index c10235237d4b716..2f9f54f7e29df41 100644 --- a/Tools/clinic/libclinic/converter.py +++ b/Tools/clinic/libclinic/converter.py @@ -8,7 +8,7 @@ from libclinic import fail from libclinic import Sentinels, unspecified, unknown, NULL from libclinic.codegen import CRenderData, Include, TemplateDict -from libclinic.function import Function, Parameter +from libclinic.function import Function, Parameter, SETTERS CConverterClassT = TypeVar("CConverterClassT", bound=type["CConverter"]) @@ -44,7 +44,10 @@ def add_default_legacy_c_converter(cls: CConverterClassT) -> CConverterClassT: # automatically add converter for default format unit # (but without stomping on the existing one if it's already # set, in case you subclass) + # A format unit which contains a quote is a C expression, not a legacy + # format unit which can be used as an annotation. if ((cls.format_unit not in ('O&', '')) and + ('"' not in cls.format_unit) and (cls.format_unit not in legacy_converters)): legacy_converters[cls.format_unit] = cls return cls @@ -272,17 +275,29 @@ def __getattr__(self, attr): else: # pragma: no cover pass + @classmethod + def dsl_name(cls) -> str: + """The name of the converter in the DSL, e.g. 'object'.""" + return cls.__name__.removesuffix('_converter') + def converter_init(self) -> None: pass def c_default_init(self) -> None: return + # An alternative name of a preceding parameter: they share + # the same C variable. + alias_of: Parameter | None = None + def is_optional(self) -> bool: return (self.default is not unspecified) def _render_self(self, parameter: Parameter, data: CRenderData) -> None: self.parameter = parameter + if self.alias_of is not None: + # Everything is rendered for the aliased parameter. + return name = self.parser_name # impl_arguments @@ -304,6 +319,13 @@ def _render_non_self( self.parameter = parameter name = self.name + if self.alias_of is not None: + # Only the keyword is new, the rest is rendered for the + # aliased parameter. + data.keywords.append(parameter.name) + data.format_units.append(self.format_unit) + return + # declarations d = self.declaration(in_parser=True) data.declarations.append(d) @@ -468,6 +490,16 @@ def pre_render(self) -> None: def bad_argument(self, displayname: str, expected: str, *, limited_capi: bool, expected_literal: bool = True) -> str: assert '"' not in expected + if self.function.kind in SETTERS: + # The value of an attribute, not an argument of a function. + if expected_literal: + return (f'PyErr_Format(PyExc_TypeError, ' + f'"attribute \'{{{{name}}}}\' must be {expected}, not %T", ' + f'{{argname}});') + else: + return (f'PyErr_Format(PyExc_TypeError, ' + f'"attribute \'{{{{name}}}}\' must be %s, not %T", ' + f'"{expected}", {{argname}});') if limited_capi: if expected_literal: return (f'PyErr_Format(PyExc_TypeError, ' diff --git a/Tools/clinic/libclinic/converters.py b/Tools/clinic/libclinic/converters.py index 76091a9eedc1bff..014486f7f469def 100644 --- a/Tools/clinic/libclinic/converters.py +++ b/Tools/clinic/libclinic/converters.py @@ -4,11 +4,12 @@ from types import NoneType from typing import Any +import libclinic from libclinic import fail, NullType, unspecified, NULL, c_bytes_repr, c_unichar_repr from libclinic.function import ( Function, Parameter, - CALLABLE, STATIC_METHOD, CLASS_METHOD, METHOD_INIT, METHOD_NEW, - GETTER, SETTER) + CALLABLE, STATIC_METHOD, CLASS_METHOD, METHOD_INIT, METHOD_NEW, SLOT, + ACCESSORS) from libclinic.codegen import CRenderData, TemplateDict from libclinic.converter import ( CConverter, legacy_converters, add_legacy_c_converter) @@ -601,6 +602,60 @@ def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> st argname=argname) +class gid_t_converter(CConverter): + type = 'gid_t' + converter = '_Py_Gid_Converter' + + +class uid_t_converter(CConverter): + type = 'uid_t' + converter = '_Py_Uid_Converter' + + +class pid_t_converter(CConverter): + type = 'pid_t' + format_unit = '" _Py_PARSE_PID "' + + def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: + return self.format_code(""" + {paramname} = PyLong_AsPid({argname}); + if ({paramname} == (pid_t)(-1) && PyErr_Occurred()) {{{{ + goto exit; + }}}} + """, + argname=argname) + + +class Py_off_t_converter(CConverter): + type = 'Py_off_t' + converter = '_Py_Off_t_Converter' + + def use_converter(self) -> None: + self.add_include('pycore_fileutils.h', '_Py_Off_t_Converter()') + + +class BOOL_converter(int_converter): + type = 'BOOL' + + +class DWORD_converter(unsigned_long_converter): + type = 'DWORD' + + +class HANDLE_converter(CConverter): + type = 'HANDLE' + format_unit = '"_Py_PARSE_UINTPTR"' + + def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: + return self.format_code(""" + {paramname} = PyLong_AsVoidPtr({argname}); + if (!{paramname} && PyErr_Occurred()) {{{{ + goto exit; + }}}} + """, + argname=argname) + + class float_converter(CConverter): type = 'float' default_type = float @@ -781,12 +836,13 @@ def post_parsing(self) -> str: return "" def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: - if self.format_unit == 's': - return self.format_code(""" - if (!PyUnicode_Check({argname})) {{{{ - {bad_argument} - goto exit; - }}}} + if self.format_unit not in ('s', 'z'): + return super().parse_arg(argname, displayname, limited_capi=limited_capi) + + # Decode a value already known to be a str. Shared by 's' and 'z', + # which differ only in whether None is also accepted. + if limited_capi: + decode = """ Py_ssize_t {length_name}; {paramname} = PyUnicode_AsUTF8AndSize({argname}, &{length_name}); if ({paramname} == NULL) {{{{ @@ -796,35 +852,52 @@ def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> st PyErr_SetString(PyExc_ValueError, "embedded null character"); goto exit; }}}} - """, - argname=argname, - bad_argument=self.bad_argument(displayname, 'str', limited_capi=limited_capi), - length_name=self.length_name) + """ + else: + # _PyUnicode_AsUTF8NoNUL() is the same code, but its Py_ssize_t + # stays in the callee's frame. An address-taken local here would + # give every generated parser a stack protector canary. + self.add_include('pycore_unicodeobject.h', + '_PyUnicode_AsUTF8NoNUL()') + decode = """ + {paramname} = _PyUnicode_AsUTF8NoNUL({argname}); + if ({paramname} == NULL) {{{{ + goto exit; + }}}} + """ + if self.format_unit == 'z': - return self.format_code(""" + expected = 'str or None' + code = """ if ({argname} == Py_None) {{{{ {paramname} = NULL; }}}} else if (PyUnicode_Check({argname})) {{{{ - Py_ssize_t {length_name}; - {paramname} = PyUnicode_AsUTF8AndSize({argname}, &{length_name}); - if ({paramname} == NULL) {{{{ - goto exit; - }}}} - if (strlen({paramname}) != (size_t){length_name}) {{{{ - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - }}}} + {decode} }}}} else {{{{ {bad_argument} goto exit; }}}} - """, - argname=argname, - bad_argument=self.bad_argument(displayname, 'str or None', limited_capi=limited_capi), - length_name=self.length_name) - return super().parse_arg(argname, displayname, limited_capi=limited_capi) + """ + else: + expected = 'str' + code = """ + if (!PyUnicode_Check({argname})) {{{{ + {bad_argument} + goto exit; + }}}} + {decode} + """ + + return self.format_code( + libclinic.linear_format( + libclinic.normalize_snippet(code), + decode=libclinic.normalize_snippet(decode)), + argname=argname, + bad_argument=self.bad_argument(displayname, expected, + limited_capi=limited_capi), + length_name=self.length_name) # # This is the fourth or fifth rewrite of registering all the @@ -1124,7 +1197,7 @@ def correct_name_for_self( f: Function, parser: bool = False ) -> tuple[str, str]: - if f.kind in {CALLABLE, METHOD_INIT, GETTER, SETTER}: + if f.kind in {CALLABLE, METHOD_INIT, SLOT} | ACCESSORS: if f.cls: return "PyObject *", "self" return "PyObject *", "module" @@ -1364,7 +1437,7 @@ class VarKeywordCConverter(CConverter): def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: raise AssertionError('should never be called') - def parse_var_keyword(self) -> str: + def parse_var_keyword(self, *, stackargs: bool) -> str: raise NotImplementedError @@ -1375,16 +1448,16 @@ class var_keyword_dict_converter(VarKeywordCConverter): def cleanup(self) -> str: return f'Py_XDECREF({self.parser_name});\n' - def parse_var_keyword(self) -> str: + def parse_var_keyword(self, *, stackargs: bool) -> str: + # NULL when there are no keywords: no call allocates an empty dict. param_name = self.parser_name - return f""" - if (kwargs == NULL) {{{{ - {param_name} = PyDict_New(); - if ({param_name} == NULL) {{{{ - goto exit; + if stackargs: + return f""" + if (kwnames != NULL) {{{{ + {param_name} = _PyStack_AsDict(args + nargs, kwnames); + if ({param_name} == NULL) {{{{ + goto exit; + }}}} }}}} - }}}} - else {{{{ - {param_name} = Py_NewRef(kwargs); - }}}} - """ + """ + return f"{param_name} = Py_XNewRef(kwargs);\n" diff --git a/Tools/clinic/libclinic/dsl_parser.py b/Tools/clinic/libclinic/dsl_parser.py index 90e2e0d3d9c928c..c514844bb8866de 100644 --- a/Tools/clinic/libclinic/dsl_parser.py +++ b/Tools/clinic/libclinic/dsl_parser.py @@ -15,28 +15,31 @@ ClinicError, VersionTuple, fail, warn, unspecified, unknown, NULL) from libclinic.function import ( - Module, Class, Function, Parameter, + Module, Class, Property, Function, Parameter, FunctionKind, CALLABLE, STATIC_METHOD, CLASS_METHOD, METHOD_INIT, METHOD_NEW, - GETTER, SETTER) + GETTER, SETTER, SETTER_AND_DELETER, SLOT, + ACCESSORS, SETTERS) from libclinic.converter import ( converters, legacy_converters) from libclinic.converters import ( - self_converter, defining_class_converter, + self_converter, defining_class_converter, object_converter, correct_name_for_self) from libclinic.return_converters import ( CReturnConverter, return_converters, int_return_converter) +from libclinic.slots import SlotSpec, SLOTS from libclinic.parser import create_parser_namespace if TYPE_CHECKING: from libclinic.block_parser import Block from libclinic.app import Clinic +# Special methods which Argument Clinic cannot convert. The type slots +# which it supports are listed in libclinic.slots. unsupported_special_methods: set[str] = set(""" __abs__ -__add__ __and__ __call__ __delitem__ @@ -47,16 +50,12 @@ __ge__ __getattr__ __getattribute__ -__getitem__ __gt__ -__hash__ -__iadd__ __iand__ __ifloordiv__ __ilshift__ __imatmul__ __imod__ -__imul__ __index__ __int__ __invert__ @@ -68,21 +67,17 @@ __itruediv__ __ixor__ __le__ -__len__ __lshift__ __lt__ __matmul__ __mod__ -__mul__ __neg__ -__next__ __or__ __pos__ __pow__ __radd__ __rand__ __rdivmod__ -__repr__ __rfloordiv__ __rlshift__ __rmatmul__ @@ -96,8 +91,6 @@ __rtruediv__ __rxor__ __setattr__ -__setitem__ -__str__ __sub__ __truediv__ __xor__ @@ -112,8 +105,8 @@ class ParamState(enum.IntEnum): """Parameter parsing state. - [ [ a, b, ] c, ] d, e, f=3, [ g, h, [ i ] ] <- line - 01 2 3 4 5 6 <- state transitions + [ [ a, b, ] c, ] [ d, ] e, f=3, [ g, h, [ i ] ] [ j ] <- line + 01 2 3 12 3 4 5 6 5 6 <- state transitions """ # Before we've seen anything. # Legal transitions: to LEFT_SQUARE_BEFORE or REQUIRED @@ -251,7 +244,9 @@ class DSLParser: positional_only: bool deprecated_positional: VersionTuple | None deprecated_keyword: VersionTuple | None - group: int + deprecated_until: VersionTuple | None + group_stack: list[int] + group_count: int parameter_state: ParamState indent: IndentStack kind: FunctionKind @@ -262,7 +257,11 @@ class DSLParser: critical_section: bool target_critical_section: list[str] disable_fastcall: bool + slot: SlotSpec | None + # Line of the file which is being parsed. + line_number: int | None from_version_re = re.compile(r'([*/]) +\[from +(.+)\]') + until_version_re = re.compile(r'\[until +(.+?)\] +(.+)') permit_long_summary = False permit_long_docstring_body = False @@ -285,13 +284,16 @@ def __init__(self, clinic: Clinic) -> None: def reset(self) -> None: self.function = None + self.line_number = None self.state = self.state_dsl_start self.expecting_parameters = True self.keyword_only = False self.positional_only = False self.deprecated_positional = None self.deprecated_keyword = None - self.group = 0 + self.deprecated_until = None + self.group_stack = [] + self.group_count = 0 self.parameter_state: ParamState = ParamState.START self.indent = IndentStack() self.kind = CALLABLE @@ -302,6 +304,8 @@ def reset(self) -> None: self.critical_section = False self.target_critical_section = [] self.disable_fastcall = False + self.vectorcall: bool = False + self.slot = None self.permit_long_summary = False self.permit_long_docstring_body = False @@ -409,6 +413,8 @@ def directive_output( fd[command_or_name] = d def directive_dump(self, name: str) -> None: + # The entries of attributes are composed before they are dumped. + self.clinic.language.render_properties(self.clinic) self.block.output.append(self.clinic.get_destination(name).dump()) def directive_printout(self, *args: str) -> None: @@ -445,27 +451,42 @@ def at_disable(self, *args: str) -> None: def at_getter(self) -> None: match self.kind: + case FunctionKind.CALLABLE: + self.kind = FunctionKind.GETTER case FunctionKind.GETTER: fail("Cannot apply @getter twice to the same function!") - case FunctionKind.SETTER: - fail("Cannot apply both @getter and @setter to the same function!") case _: - self.kind = FunctionKind.GETTER + fail("Can't set @getter, function is not a normal callable") def at_setter(self) -> None: match self.kind: - case FunctionKind.SETTER: + case FunctionKind.CALLABLE: + self.kind = FunctionKind.SETTER + case FunctionKind.SETTER | FunctionKind.SETTER_AND_DELETER: fail("Cannot apply @setter twice to the same function!") - case FunctionKind.GETTER: - fail("Cannot apply both @getter and @setter to the same function!") case _: - self.kind = FunctionKind.SETTER + fail("Can't set @setter, function is not a normal callable") + + def at_deleter(self) -> None: + match self.kind: + case FunctionKind.SETTER: + # The setter is called with NULL to delete the attribute. + self.kind = FunctionKind.SETTER_AND_DELETER + case FunctionKind.SETTER_AND_DELETER: + fail("Cannot apply @deleter twice to the same function!") + case _: + fail("Can't set @deleter, @setter is not applied") def at_staticmethod(self) -> None: if self.kind is not CALLABLE: fail("Can't set @staticmethod, function is not a normal callable") self.kind = STATIC_METHOD + def at_vectorcall(self) -> None: + if self.vectorcall: + fail("Called @vectorcall twice!") + self.vectorcall = True + def at_coexist(self) -> None: if self.coexist: fail("Called @coexist twice!") @@ -497,6 +518,7 @@ def parse(self, block: Block) -> None: if '\t' in line: fail(f'Tab characters are illegal in the Clinic DSL: {line!r}', line_number=block_start) + self.line_number = line_number try: self.state(line) except ClinicError as exc: @@ -505,7 +527,14 @@ def parse(self, block: Block) -> None: raise self.do_post_block_processing_cleanup(line_number) - block.output.extend(self.clinic.language.render(self.clinic, block.signatures)) + try: + block.output.extend( + self.clinic.language.render(self.clinic, block.signatures)) + except ClinicError as exc: + if exc.lineno is None: + exc.lineno = line_number + exc.filename = self.clinic.filename + raise if self.preserve_output: if block.output: @@ -568,6 +597,9 @@ def parse_function_names(self, line: str) -> FunctionNames: fields = full_name.split(".") if fields[-1] == '__new__': fields.pop() + elif fields[-1] in SLOTS and not self.coexist: + # list.__repr__ -> list_repr + fields[-1] = fields[-1].strip('_') c_basename = "_".join(fields) if not libclinic.is_legal_py_identifier(full_name): fail(f"Illegal function name: {full_name!r}") @@ -590,23 +622,43 @@ def normalize_function_kind(self, fullname: str) -> None: fail(f"{name!r} must be a normal method; got '{self.kind}'!") if name == '__new__' and (self.kind is not CLASS_METHOD or not cls): fail("'__new__' must be a class method!") - if self.kind in {GETTER, SETTER} and not cls: + if self.kind in ACCESSORS and not cls: fail("@getter and @setter must be methods") + # A @coexist method named like a slot is a method which coexists + # with the slot (e.g. dict.__contains__), not the slot itself. + slot = None if self.coexist else SLOTS.get(name) + if slot is not None: + if self.kind is not CALLABLE: + fail(f"{name!r} must be a normal method; got '{self.kind}'!") + if not cls: + fail(f"{name!r} must be a method!") # Normalise self.kind. if name == '__new__': self.kind = METHOD_NEW elif name == '__init__': self.kind = METHOD_INIT + elif slot is not None: + self.kind = SLOT + self.slot = slot + + # Validate @vectorcall usage. + if self.vectorcall: + if not self.kind.new_or_init: + fail("@vectorcall can only be used with __init__ and __new__ " + "methods currently") def resolve_return_converter( self, full_name: str, forced_converter: str ) -> CReturnConverter: if forced_converter: - if self.kind in {GETTER, SETTER}: - fail(f"@{self.kind.name.lower()} method cannot define a return type") + if self.kind in SETTERS: + fail("@setter methods cannot define a return type") if self.kind is METHOD_INIT: fail("__init__ methods cannot define a return type") + if self.kind is SLOT: + fail(f"{full_name!r} cannot define a return type; " + "its type slot defines it") ast_input = f"def x() -> {forced_converter}: pass" try: module_node = ast.parse(ast_input) @@ -624,8 +676,11 @@ def resolve_return_converter( except ValueError: fail(f"Badly formed annotation for {full_name!r}: {forced_converter!r}") - if self.kind in {METHOD_INIT, SETTER}: + if self.kind in {METHOD_INIT} | SETTERS: return int_return_converter() + if self.kind is SLOT: + assert self.slot is not None + return self.slot.make_return_converter() return CReturnConverter() def parse_cloned_function(self, names: FunctionNames, existing: str) -> None: @@ -654,7 +709,11 @@ def parse_cloned_function(self, names: FunctionNames, existing: str) -> None: "cls": cls, "c_basename": c_basename, "docstring": "", + "docstring_line_number": None, + "line_number": self.line_number, } + if existing_function.kind is SLOT or self.slot is not None: + fail("Type slot methods cannot be cloned") if not (existing_function.kind is self.kind and existing_function.coexist == self.coexist): # Allow __new__ or __init__ methods. @@ -666,6 +725,9 @@ def parse_cloned_function(self, names: FunctionNames, existing: str) -> None: fail("'kind' of function and cloned function don't match! " "(@classmethod/@staticmethod/@coexist)") function = existing_function.copy(**overrides) + function.condition = self.clinic.language.cpp.condition() + if function.kind in ACCESSORS: + self.add_accessor(function) self.function = function self.block.signatures.append(function) (cls or module).functions.append(function) @@ -723,13 +785,20 @@ def state_modulename_name(self, line: str) -> None: critical_section=self.critical_section, disable_fastcall=self.disable_fastcall, target_critical_section=self.target_critical_section, - forced_text_signature=self.forced_text_signature + forced_text_signature=self.forced_text_signature, + line_number=self.line_number, + vectorcall=self.vectorcall, + slot=self.slot, ) self.add_function(func) self.next(self.state_parameters_start) def add_function(self, func: Function) -> None: + func.condition = self.clinic.language.cpp.condition() + if func.kind in ACCESSORS: + self.add_accessor(func) + # Insert a self converter automatically. tp, name = correct_name_for_self(func) if func.cls and tp == "PyObject *": @@ -748,6 +817,28 @@ def add_function(self, func: Function) -> None: self.function = func (func.cls or func.module).functions.append(func) + def add_accessor(self, func: Function) -> None: + """Add an accessor to the attribute which it implements.""" + assert func.cls is not None + prop = func.cls.properties.get(func.name) + if prop is not None and prop.rendered: + fail(f"All accessors of {func.full_name!r} must be defined " + f"before its PyGetSetDef entry is dumped") + if prop is None: + prop = Property(func.name, func.full_name, func.cls) + func.cls.properties[func.name] = prop + self.clinic.properties.append(prop) + func.property = prop + slot = prop.getter if func.kind is GETTER else prop.setter + # Several implementations of the same accessor can share the slot if + # each of them is compiled under its own preprocessor condition. + if slot and (not func.condition + or any(not other.condition for other in slot)): + if func.kind is GETTER: + fail(f"Cannot apply @getter to {func.full_name!r} twice") + fail(f"The setter of {func.full_name!r} is already defined") + slot.append(func) + # Now entering the parameters section. The rules, formally stated: # # * All lines must be indented with spaces only. @@ -812,10 +903,8 @@ def state_parameters_start(self, line: str) -> None: return self.next(self.state_function_docstring, line) assert self.function is not None - if self.function.kind in {GETTER, SETTER}: - getset = self.function.kind.name.lower() - fail(f"@{getset} methods cannot define parameters") - + if self.function.kind is GETTER: + fail("@getter methods cannot define parameters") self.parameter_continuation = '' return self.next(self.state_parameter, line) @@ -829,6 +918,7 @@ def to_required(self) -> None: assert self.function is not None for p in self.function.parameters.values(): p.group = -p.group + self.group_count = 0 def state_parameter(self, line: str) -> None: assert isinstance(self.function, Function) @@ -836,6 +926,10 @@ def state_parameter(self, line: str) -> None: if not self.valid_line(line): return + if self.function.kind in SETTERS and len(self.function.parameters) > 1: + # The only parameter of a setter is the new value. + fail("@setter methods must define exactly one parameter") + if self.parameter_continuation: line = self.parameter_continuation + ' ' + line.lstrip() self.parameter_continuation = '' @@ -862,6 +956,15 @@ def state_parameter(self, line: str) -> None: line = match[1] version = self.parse_version(match[2]) + self.deprecated_until = None + match = self.until_version_re.fullmatch(line) + if match: + self.deprecated_until = self.parse_version(match[1], 'until') + line = match[2] + + if not self.expecting_parameters: + fail(f'parameters cannot follow var-keyword parameter: {line!r}') + func = self.function match line: case '*': @@ -878,17 +981,13 @@ def state_parameter(self, line: str) -> None: def parse_parameter(self, line: str) -> None: assert self.function is not None - if not self.expecting_parameters: - fail('Encountered parameter line when not expecting ' - f'parameters: {line}') - match self.parameter_state: case ParamState.START | ParamState.REQUIRED: self.to_required() case ParamState.LEFT_SQUARE_BEFORE: self.parameter_state = ParamState.GROUP_BEFORE case ParamState.GROUP_BEFORE: - if not self.group: + if not self.group_stack: self.to_required() case ParamState.GROUP_AFTER | ParamState.OPTIONAL: pass @@ -897,7 +996,7 @@ def parse_parameter(self, line: str) -> None: # handle "as" for parameters too c_name = None - m = re.match(r'(?:\* *)?\w+( +as +(\w+))', line) + m = re.match(r'(?:\*{1,2} *)?\w+( +as +(\w+))', line) if m: c_name = m[2] line = line[:m.start(1)] + line[m.end(1):] @@ -932,8 +1031,9 @@ def parse_parameter(self, line: str) -> None: for p in self.function.parameters.values() ) if has_non_positional_param: - fail(f"Function {self.function.name!r} has an " - f"invalid parameter declaration (**kwargs?): {line!r}") + fail(f'Function {self.function.name!r} cannot use a var-keyword ' + f'parameter with pos-or-keyword or keyword-only ' + f'parameters.') is_var_keyword = True parameter = function_args.kwarg else: @@ -1072,8 +1172,20 @@ def bad_node(self, node: ast.AST) -> None: kind: inspect._ParameterKind if is_vararg: + if self.group_stack: + fail("A var-positional parameter cannot be in an optional " + "group.") + if any(p.group for p in self.function.parameters.values()): + # With "foo([a, b], *args)" the number of arguments does not + # tell whether the group is passed or all arguments belong + # to the var-positional parameter. + fail(f"Function {self.function.name!r} cannot use optional " + f"groups with a var-positional parameter.") kind = inspect.Parameter.VAR_POSITIONAL elif is_var_keyword: + if self.group_stack: + fail("A var-keyword parameter cannot be in an optional " + "group.") kind = inspect.Parameter.VAR_KEYWORD elif self.keyword_only: kind = inspect.Parameter.KEYWORD_ONLY @@ -1082,7 +1194,7 @@ def bad_node(self, node: ast.AST) -> None: if isinstance(converter, self_converter): if len(self.function.parameters) == 1: - if self.group: + if self.group_stack: fail("A 'self' parameter cannot be in an optional group.") assert self.parameter_state is ParamState.REQUIRED assert value is unspecified @@ -1096,7 +1208,7 @@ def bad_node(self, node: ast.AST) -> None: if isinstance(converter, defining_class_converter): _lp = len(self.function.parameters) if _lp == 1: - if self.group: + if self.group_stack: fail("A 'defining_class' parameter cannot be in an optional group.") if self.function.cls is None: fail("A 'defining_class' parameter cannot be defined at module level.") @@ -1110,8 +1222,12 @@ def bad_node(self, node: ast.AST) -> None: p = Parameter(parameter_name, kind, function=self.function, - converter=converter, default=value, group=self.group, - deprecated_positional=self.deprecated_positional) + converter=converter, default=value, + deprecated_until=self.deprecated_until, + group=self.group_stack[-1] if self.group_stack else 0, + group_depth=len(self.group_stack), + deprecated_positional=self.deprecated_positional, + line_number=self.line_number) names = [k.name for k in self.function.parameters.values()] if parameter_name in names[1:]: @@ -1119,6 +1235,26 @@ def bad_node(self, node: ast.AST) -> None: elif names and parameter_name == names[0] and c_name is None: fail(f"Parameter {parameter_name!r} requires a custom C name") + # A parameter which shares the C variable of a preceding parameter + # is an alternative name (an alias) of it. + for existing in self.function.parameters.values(): + if existing.converter.name == converter.name: + if not self.keyword_only: + fail(f"Alias {parameter_name!r} of the parameter " + f"{existing.name!r} must be keyword-only.") + if value is unspecified: + fail(f"Alias {parameter_name!r} of the parameter " + f"{existing.name!r} must have a default value.") + converter.alias_of = existing + break + + # A deprecated parameter is going away, so calls which do not pass + # it must already be valid. + if self.deprecated_until is not None and value is unspecified: + fail(f"Deprecated parameter {parameter_name!r} " + f"must have a default value.") + + key = f"{parameter_name}_as_{c_name}" if c_name else parameter_name self.function.parameters[key] = p @@ -1148,17 +1284,18 @@ def parse_converter( "Annotations must be either a name, a function call, or a string." ) - def parse_version(self, thenceforth: str) -> VersionTuple: - """Parse Python version in `[from ...]` marker.""" + def parse_version(self, version: str, marker: str = 'from') -> VersionTuple: + """Parse Python version in `[from ...]` or `[until ...]` marker.""" assert isinstance(self.function, Function) try: - major, minor = thenceforth.split(".") + major, minor = version.split(".") return int(major), int(minor) except ValueError: fail( - f"Function {self.function.name!r}: expected format '[from major.minor]' " - f"where 'major' and 'minor' are integers; got {thenceforth!r}" + f"Function {self.function.name!r}: expected format " + f"'[{marker} major.minor]' where 'major' and 'minor' are " + f"integers; got {version!r}" ) def parse_star(self, function: Function, version: VersionTuple | None) -> None: @@ -1167,9 +1304,6 @@ def parse_star(self, function: Function, version: VersionTuple | None) -> None: The 'version' parameter signifies the future version from which the marker will take effect (None means it is already in effect). """ - if not self.expecting_parameters: - fail("Encountered '*' when not expecting parameters") - if version is None: self.check_previous_star() self.check_remaining_star() @@ -1189,26 +1323,37 @@ def parse_star(self, function: Function, version: VersionTuple | None) -> None: def parse_opening_square_bracket(self, function: Function) -> None: """Parse opening parameter group symbol '['.""" + if any(p.is_vararg() for p in function.parameters.values()): + fail(f"Function {function.name!r} cannot use optional groups " + f"with a var-positional parameter.") + # A group can only be nested in a group which does not contain + # parameters yet, but two groups on the same nesting level can + # follow each other. match self.parameter_state: case ParamState.START | ParamState.LEFT_SQUARE_BEFORE: self.parameter_state = ParamState.LEFT_SQUARE_BEFORE + case ParamState.GROUP_BEFORE if not self.group_stack: + self.parameter_state = ParamState.LEFT_SQUARE_BEFORE case ParamState.REQUIRED | ParamState.GROUP_AFTER: self.parameter_state = ParamState.GROUP_AFTER + case ParamState.RIGHT_SQUARE_AFTER if not self.group_stack: + self.parameter_state = ParamState.GROUP_AFTER case st: fail(f"Function {function.name!r} " f"has an unsupported group configuration. " f"(Unexpected state {st}.b)") - self.group += 1 + self.group_count += 1 + self.group_stack.append(self.group_count) function.docstring_only = True def parse_closing_square_bracket(self, function: Function) -> None: """Parse closing parameter group symbol ']'.""" - if not self.group: + if not self.group_stack: fail(f"Function {function.name!r} has a ']' without a matching '['.") - if not any(p.group == self.group for p in function.parameters.values()): + group = self.group_stack.pop() + if not any(p.group == group for p in function.parameters.values()): fail(f"Function {function.name!r} has an empty group. " "All groups must contain at least one parameter.") - self.group -= 1 match self.parameter_state: case ParamState.LEFT_SQUARE_BEFORE | ParamState.GROUP_BEFORE: self.parameter_state = ParamState.GROUP_BEFORE @@ -1225,9 +1370,6 @@ def parse_slash(self, function: Function, version: VersionTuple | None) -> None: The 'version' parameter signifies the future version from which the marker will take effect (None means it is already in effect). """ - if not self.expecting_parameters: - fail("Encountered '/' when not expecting parameters") - if version is None: if self.deprecated_keyword: fail(f"Function {function.name!r}: '/' must precede '/ [from ...]'") @@ -1268,16 +1410,27 @@ def parse_slash(self, function: Function, version: VersionTuple | None) -> None: ParamState.RIGHT_SQUARE_AFTER, ParamState.GROUP_BEFORE, } - if (self.parameter_state not in allowed) or self.group: + if (self.parameter_state not in allowed) or self.group_stack: fail(f"Function {function.name!r} has an unsupported group configuration. " f"(Unexpected state {self.parameter_state}.d)") # fixup preceding parameters + deprecated = None for p in function.parameters.values(): if p.kind is inspect.Parameter.POSITIONAL_OR_KEYWORD: if version is None: p.kind = inspect.Parameter.POSITIONAL_ONLY elif p.deprecated_keyword is None: p.deprecated_keyword = version + if p.kind is inspect.Parameter.POSITIONAL_ONLY: + # A positional-only argument can only be passed after all + # preceding ones, so removing a parameter would leave no + # way to pass those which follow it. + if p.deprecated_until is not None: + deprecated = p + elif deprecated is not None: + fail(f"Parameter {p.name!r} cannot follow the deprecated " + f"parameter {deprecated.name!r}: only the last " + f"positional-only parameters can be deprecated.") def state_parameter_docstring_start(self, line: str) -> None: assert self.indent.margin is not None, "self.margin.infer() has not yet been called to set the margin" @@ -1300,6 +1453,8 @@ def docstring_append(self, obj: Function | Parameter, line: str) -> None: docstring = obj.docstring if docstring: docstring += "\n" + elif isinstance(obj, Function) and line.rstrip(): + obj.docstring_line_number = self.line_number if stripped := line.rstrip(): docstring += self.indent.dedent(stripped) obj.docstring = docstring @@ -1329,7 +1484,7 @@ def state_parameter_docstring(self, line: str) -> None: def state_function_docstring(self, line: str) -> None: assert self.function is not None - if self.group: + if self.group_stack: fail(f"Function {self.function.name!r} has a ']' without a matching '['.") if not self.valid_line(line): @@ -1341,174 +1496,10 @@ def state_function_docstring(self, line: str) -> None: def format_docstring_signature( f: Function, parameters: list[Parameter] ) -> str: - lines = [] - lines.append(f.displayname) - if f.forced_text_signature: - lines.append(f.forced_text_signature) - elif f.kind in {GETTER, SETTER}: - # @getter and @setter do not need signatures like a method or a function. - return '' - else: - lines.append('(') - - # populate "right_bracket_count" field for every parameter - assert parameters, "We should always have a self parameter. " + repr(f) - assert isinstance(parameters[0].converter, self_converter) - # self is always positional-only. - assert parameters[0].is_positional_only() - assert parameters[0].right_bracket_count == 0 - positional_only = True - for p in parameters[1:]: - if not p.is_positional_only(): - positional_only = False - else: - assert positional_only - if positional_only: - p.right_bracket_count = abs(p.group) - else: - # don't put any right brackets around non-positional-only parameters, ever. - p.right_bracket_count = 0 - - right_bracket_count = 0 - - def fix_right_bracket_count(desired: int) -> str: - nonlocal right_bracket_count - s = '' - while right_bracket_count < desired: - s += '[' - right_bracket_count += 1 - while right_bracket_count > desired: - s += ']' - right_bracket_count -= 1 - return s - - need_slash = False - added_slash = False - need_a_trailing_slash = False - - # we only need a trailing slash: - # * if this is not a "docstring_only" signature - # * and if the last *shown* parameter is - # positional only - if not f.docstring_only: - for p in reversed(parameters): - if not p.converter.show_in_signature: - continue - if p.is_positional_only(): - need_a_trailing_slash = True - break - - - added_star = False - - first_parameter = True - last_p = parameters[-1] - line_length = len(''.join(lines)) - indent = " " * line_length - def add_parameter(text: str) -> None: - nonlocal line_length - nonlocal first_parameter - if first_parameter: - s = text - first_parameter = False - else: - s = ' ' + text - if line_length + len(s) >= 72: - lines.extend(["\n", indent]) - line_length = len(indent) - s = text - line_length += len(s) - lines.append(s) - - for p in parameters: - if not p.converter.show_in_signature: - continue - assert p.name - - is_self = isinstance(p.converter, self_converter) - if is_self and f.docstring_only: - # this isn't a real machine-parsable signature, - # so let's not print the "self" parameter - continue - - if p.is_positional_only(): - need_slash = not f.docstring_only - elif need_slash and not (added_slash or p.is_positional_only()): - added_slash = True - add_parameter('/,') - - if p.is_keyword_only() and not added_star: - added_star = True - add_parameter('*,') - - p_lines = [fix_right_bracket_count(p.right_bracket_count)] - - if isinstance(p.converter, self_converter): - # annotate first parameter as being a "self". - # - # if inspect.Signature gets this function, - # and it's already bound, the self parameter - # will be stripped off. - # - # if it's not bound, it should be marked - # as positional-only. - # - # note: we don't print "self" for __init__, - # because this isn't actually the signature - # for __init__. (it can't be, __init__ doesn't - # have a docstring.) if this is an __init__ - # (or __new__), then this signature is for - # calling the class to construct a new instance. - p_lines.append('$') - - if p.is_vararg(): - p_lines.append("*") - added_star = True - if p.is_var_keyword(): - p_lines.append("**") - - name = p.converter.signature_name or p.name - p_lines.append(name) - - if not p.is_variable_length() and p.converter.is_optional(): - p_lines.append('=') - value = p.converter.py_default - if not value: - value = repr(p.converter.default) - p_lines.append(value) - - if (p != last_p) or need_a_trailing_slash: - p_lines.append(',') - - p_output = "".join(p_lines) - add_parameter(p_output) - - lines.append(fix_right_bracket_count(0)) - if need_a_trailing_slash: - add_parameter('/') - lines.append(')') - - # PEP 8 says: - # - # The Python standard library will not use function annotations - # as that would result in a premature commitment to a particular - # annotation style. Instead, the annotations are left for users - # to discover and experiment with useful annotation styles. - # - # therefore this is commented out: - # - # if f.return_converter.py_default: - # lines.append(' -> ') - # lines.append(f.return_converter.py_default) - - if not f.docstring_only: - lines.append("\n" + libclinic.SIG_END_MARKER + "\n") - - signature_line = "".join(lines) - - # now fix up the places where the brackets look wrong - return signature_line.replace(', ]', ',] ') - + signature = render_text_signature(f, parameters) + if signature and not f.docstring_only: + signature += "\n" + libclinic.SIG_END_MARKER + "\n" + return signature @staticmethod def format_docstring_parameters(params: list[Parameter]) -> str: """Create substitution text for {parameters}""" @@ -1518,7 +1509,13 @@ def format_docstring(self) -> str: assert self.function is not None f = self.function # For the following special cases, it does not make sense to render a docstring. - if f.kind in {METHOD_INIT, METHOD_NEW, GETTER, SETTER} and not f.docstring: + if f.kind is SLOT: + # A slot function has no docstring (there is no PyMethodDef). + if f.docstring: + fail(f"{f.name!r} methods cannot have a docstring", + line_number=f.docstring_line_number) + return f.docstring + if f.kind in {METHOD_INIT, METHOD_NEW} | ACCESSORS and not f.docstring: return f.docstring # Enforce the summary line! @@ -1533,12 +1530,19 @@ def format_docstring(self) -> str: # Guido said Clinic should enforce this: # http://mail.python.org/pipermail/python-dev/2013-June/127110.html + def docstring_line(index: int) -> int | None: + """Return the line of the file which holds the index-th line.""" + if f.docstring_line_number is None: + return None + return f.docstring_line_number + index + lines = f.docstring.split('\n') if len(lines) >= 2: if lines[1]: fail(f"Docstring for {f.full_name!r} does not have a summary line!\n" "Every non-blank function docstring must start with " - "a single line summary followed by an empty line.") + "a single line summary followed by an empty line.", + line_number=docstring_line(1)) elif len(lines) == 1: # the docstring is only one line right now--the summary line. # add an empty line after the summary line so we have space @@ -1550,28 +1554,36 @@ def format_docstring(self) -> str: # Existing violations are recorded in OVERLONG_{SUMMARY,BODY}. max_width = f.docstring_line_width summary_len = len(lines[0]) - max_body = max(map(len, lines[1:])) + long_body = [i for i, line in enumerate(lines) + if i and len(line) > max_width] if summary_len > max_width: if not self.permit_long_summary: fail(f"Summary line for {f.full_name!r} is too long!\n" - f"The summary line must be no longer than {max_width} characters.") + f"The summary line must be no longer than {max_width} characters.", + line_number=docstring_line(0)) else: if self.permit_long_summary: warn("Remove the @permit_long_summary decorator from " - f"{f.full_name!r}!\n") + f"{f.full_name!r}!\n", filename=self.clinic.filename, + line_number=f.line_number) - if max_body > max_width: + if long_body: if not self.permit_long_docstring_body: warn(f"Docstring lines for {f.full_name!r} are too long!\n" - f"Lines should be no longer than {max_width} characters.") + f"Lines should be no longer than {max_width} characters.", + filename=self.clinic.filename, + line_number=docstring_line(long_body[0])) else: if self.permit_long_docstring_body: warn("Remove the @permit_long_docstring_body decorator from " - f"{f.full_name!r}!\n") + f"{f.full_name!r}!\n", filename=self.clinic.filename, + line_number=f.line_number) + markers = [i for i, line in enumerate(lines) if '{parameters}' in line] parameters_marker_count = len(f.docstring.split('{parameters}')) - 1 if parameters_marker_count > 1: - fail('You may not specify {parameters} more than once in a docstring!') + fail('You may not specify {parameters} more than once in a docstring!', + line_number=docstring_line(markers[-1])) # insert signature at front and params after the summary line if not parameters_marker_count: @@ -1579,7 +1591,10 @@ def format_docstring(self) -> str: lines.insert(0, '{signature}') # finalize docstring - params = f.render_parameters + # An alias is not shown in the signature: only one of the + # alternative names can be used in a call. + params = [p for p in f.render_parameters + if p.converter.alias_of is None] parameters = self.format_docstring_parameters(params) signature = self.format_docstring_signature(f, params) docstring = "\n".join(lines) @@ -1620,6 +1635,38 @@ def check_previous_star(self) -> None: fail(f"Function {self.function.name!r} uses '*' more than once.") + def check_vectorcall_parameters(self, lineno: int) -> None: + assert self.function is not None + if not self.function.vectorcall: + return + for i, p in enumerate(self.function.parameters.values()): + if p.group: + fail("@vectorcall does not support optional groups", + line_number=lineno) + if p.deprecated_positional or p.deprecated_keyword: + fail("@vectorcall does not support deprecated parameters", + line_number=lineno) + if p.is_vararg() or p.is_var_keyword(): + continue + if isinstance(p.converter, (self_converter, + defining_class_converter)): + continue + parse_arg = p.converter.parse_arg(f'args[{i}]', + p.get_displayname(i), + limited_capi=False) + if parse_arg is None: + fail("@vectorcall requires all converters to support " + f"parse_arg(); parameter {p.name!r} does not", + line_number=lineno) + + def check_slot_parameters(self, func: Function) -> None: + """Check that the parameters of a slot method fit a C signature.""" + for p in list(func.parameters.values())[1:]: + if not p.is_positional_only(): + fail(f"The parameters of {func.name!r} must be positional-only") + if p.default is not unspecified: + fail(f"The parameters of {func.name!r} cannot have a default value") + def do_post_block_processing_cleanup(self, lineno: int) -> None: """ Called when processing the block is done. @@ -1627,10 +1674,230 @@ def do_post_block_processing_cleanup(self, lineno: int) -> None: if not self.function: return + func = self.function + if func.kind is SLOT: + self.check_slot_parameters(func) + if func.kind in (SETTER, SETTER_AND_DELETER): + # The new value is the only parameter of a setter. The setter + # of a deletable attribute is also called with NULL to delete it, + # hence the default value. + optional = func.kind is SETTER_AND_DELETER + if len(func.parameters) == 1: + # It is optional to declare the value, which is usually + # a plain object. + default = NULL if optional else unspecified + converter = object_converter('value', 'value', func, default) + func.parameters['value'] = Parameter( + 'value', inspect.Parameter.POSITIONAL_ONLY, + function=func, converter=converter, default=default) + else: + p = list(func.parameters.values())[1] + if p.is_keyword_only() or p.is_variable_length(): + fail("the value of @setter must be a positional parameter") + if p.is_optional() != optional: + if optional: + fail("the value of @setter with @deleter must have " + "a default value, used to delete the attribute") + else: + fail("the value of @setter cannot have a default value") + if optional and p.default is not NULL: + fail("the value of @setter with @deleter can only have " + "NULL as a default value") + self.check_remaining_star(lineno) + self.check_vectorcall_parameters(lineno) try: self.function.docstring = self.format_docstring() except ClinicError as exc: - exc.lineno = lineno + if exc.lineno is None: + exc.lineno = lineno exc.filename = self.clinic.filename raise + + +def render_text_signature( + f: Function, + parameters: list[Parameter], + *, + name: str | None = None, + line_width: int | None = 72, +) -> str: + """Render the text signature of the function. + + *name* replaces the name of the function. *line_width* is the width + at which the signature is wrapped, None disables wrapping. + """ + lines = [] + lines.append(f.displayname if name is None else name) + if f.forced_text_signature: + lines.append(f.forced_text_signature) + elif f.kind in ACCESSORS: + # Accessors do not need signatures like a method or a function. + return '' + else: + lines.append('(') + + # populate "right_bracket_count" field for every parameter + assert parameters, "We should always have a self parameter. " + repr(f) + assert isinstance(parameters[0].converter, self_converter) + # self is always positional-only. + assert parameters[0].is_positional_only() + assert parameters[0].right_bracket_count == 0 + positional_only = True + for p in parameters[1:]: + if not p.is_positional_only(): + positional_only = False + else: + assert positional_only + if positional_only: + p.right_bracket_count = p.group_depth + else: + # don't put any right brackets around non-positional-only parameters, ever. + p.right_bracket_count = 0 + + right_bracket_count = 0 + last_group = 0 + + def fix_right_bracket_count(desired: int, group: int = 0) -> str: + nonlocal right_bracket_count, last_group + s = '' + if (group != last_group and right_bracket_count and + ((desired >= right_bracket_count) if group < 0 else + (desired <= right_bracket_count))): + # The group is not nested in the previous group, + # close the brackets of the latter first. + s += ']' * right_bracket_count + right_bracket_count = 0 + last_group = group + while right_bracket_count < desired: + s += '[' + right_bracket_count += 1 + while right_bracket_count > desired: + s += ']' + right_bracket_count -= 1 + return s + + need_slash = False + added_slash = False + need_a_trailing_slash = False + + # we only need a trailing slash: + # * if this is not a "docstring_only" signature + # * and if the last *shown* parameter is + # positional only + if not f.docstring_only: + for p in reversed(parameters): + if not p.converter.show_in_signature: + continue + if p.is_positional_only(): + need_a_trailing_slash = True + break + + + added_star = False + + first_parameter = True + last_p = parameters[-1] + line_length = len(''.join(lines)) + indent = " " * line_length + def add_parameter(text: str) -> None: + nonlocal line_length + nonlocal first_parameter + if first_parameter: + s = text + first_parameter = False + else: + s = ' ' + text + if line_width is not None and line_length + len(s) >= line_width: + lines.extend(["\n", indent]) + line_length = len(indent) + s = text + line_length += len(s) + lines.append(s) + + for p in parameters: + if not p.converter.show_in_signature: + continue + assert p.name + + is_self = isinstance(p.converter, self_converter) + if is_self and f.docstring_only: + # this isn't a real machine-parsable signature, + # so let's not print the "self" parameter + continue + + if p.is_positional_only(): + need_slash = not f.docstring_only + elif need_slash and not (added_slash or p.is_positional_only()): + added_slash = True + add_parameter('/,') + + if p.is_keyword_only() and not added_star: + added_star = True + add_parameter('*,') + + p_lines = [fix_right_bracket_count(p.right_bracket_count, + p.group)] + + if isinstance(p.converter, self_converter): + # annotate first parameter as being a "self". + # + # if inspect.Signature gets this function, + # and it's already bound, the self parameter + # will be stripped off. + # + # if it's not bound, it should be marked + # as positional-only. + # + # note: we don't print "self" for __init__, + # because this isn't actually the signature + # for __init__. (it can't be, __init__ doesn't + # have a docstring.) if this is an __init__ + # (or __new__), then this signature is for + # calling the class to construct a new instance. + p_lines.append('$') + + if p.is_vararg(): + p_lines.append("*") + added_star = True + if p.is_var_keyword(): + p_lines.append("**") + + name = p.converter.signature_name or p.name + p_lines.append(name) + + if not p.is_variable_length() and p.converter.is_optional(): + p_lines.append('=') + value = p.converter.py_default + if not value: + value = repr(p.converter.default) + p_lines.append(value) + + if (p != last_p) or need_a_trailing_slash: + p_lines.append(',') + + p_output = "".join(p_lines) + add_parameter(p_output) + + lines.append(fix_right_bracket_count(0)) + if need_a_trailing_slash: + add_parameter('/') + lines.append(')') + + # PEP 8 says: + # + # The Python standard library will not use function annotations + # as that would result in a premature commitment to a particular + # annotation style. Instead, the annotations are left for users + # to discover and experiment with useful annotation styles. + # + # therefore this is commented out: + # + # if f.return_converter.py_default: + # lines.append(' -> ') + # lines.append(f.return_converter.py_default) + + signature_line = "".join(lines) + + # now fix up the places where the brackets look wrong + return signature_line.replace(', ]', ',] ') diff --git a/Tools/clinic/libclinic/function.py b/Tools/clinic/libclinic/function.py index 1c643caea98e3b5..5270f4520180d41 100644 --- a/Tools/clinic/libclinic/function.py +++ b/Tools/clinic/libclinic/function.py @@ -11,6 +11,7 @@ from libclinic.converters import self_converter from libclinic.return_converters import CReturnConverter from libclinic.app import Clinic + from libclinic.slots import SlotSpec from libclinic import VersionTuple, unspecified @@ -18,6 +19,7 @@ ClassDict = dict[str, "Class"] ModuleDict = dict[str, "Module"] ParamDict = dict[str, "Parameter"] +PropertyDict = dict[str, "Property"] @dc.dataclass(repr=False) @@ -47,11 +49,43 @@ def __post_init__(self) -> None: self.parent = self.cls or self.module self.classes: ClassDict = {} self.functions: list[Function] = [] + self.properties: PropertyDict = {} def __repr__(self) -> str: return "" +@dc.dataclass(repr=False) +class Property: + """An attribute implemented by accessors, rendered into a PyGetSetDef entry. + + A slot can contain several implementations if they are guarded by + preprocessor conditions. + """ + name: str + full_name: str + cls: Class + + def __post_init__(self) -> None: + self.getter: list[Function] = [] + self.setter: list[Function] = [] + self.rendered = False + + def __repr__(self) -> str: + return "" + + @property + def is_plain(self) -> bool: + """Can the entry be composed without the help of the preprocessor?""" + return all(len(funcs) <= 1 and not (funcs and funcs[0].condition) + for funcs in (self.getter, self.setter)) + + @property + def getset_name(self) -> str: + """The prefix of the names of the macros of the entry.""" + return self.full_name.replace('.', '_').upper() + + class FunctionKind(enum.Enum): CALLABLE = enum.auto() STATIC_METHOD = enum.auto() @@ -60,6 +94,9 @@ class FunctionKind(enum.Enum): METHOD_NEW = enum.auto() GETTER = enum.auto() SETTER = enum.auto() + SETTER_AND_DELETER = enum.auto() + # A type slot ("tp slot"), see libclinic.slots. + SLOT = enum.auto() @functools.cached_property def new_or_init(self) -> bool: @@ -76,6 +113,13 @@ def __repr__(self) -> str: METHOD_NEW: Final = FunctionKind.METHOD_NEW GETTER: Final = FunctionKind.GETTER SETTER: Final = FunctionKind.SETTER +SETTER_AND_DELETER: Final = FunctionKind.SETTER_AND_DELETER +SLOT: Final = FunctionKind.SLOT + +# The kinds which implement the setter of an entry of PyGetSetDef. +SETTERS: Final = frozenset({SETTER, SETTER_AND_DELETER}) +# The kinds which implement an entry of PyGetSetDef. +ACCESSORS: Final = SETTERS | {GETTER} @dc.dataclass(repr=False) @@ -111,12 +155,31 @@ class Function: critical_section: bool = False disable_fastcall: bool = False target_critical_section: list[str] = dc.field(default_factory=list) + # Line of the file on which the function is declared. + line_number: int | None = None + # Line on which the docstring starts (`None` if there is no docstring). + docstring_line_number: int | None = None + vectorcall: bool = False + # The type slot which the function implements (kind is SLOT). + slot: SlotSpec | None = None def __post_init__(self) -> None: self.parent = self.cls or self.module self.self_converter: self_converter | None = None + # The attribute implemented by an accessor, and the preprocessor + # condition under which it is compiled. + self.property: Property | None = None + self.condition: str = '' self.__render_parameters__: list[Parameter] | None = None + @functools.cached_property + def accessor_basename(self) -> str: + """The name of the C function which implements this accessor.""" + assert self.kind in ACCESSORS + if self.kind is GETTER: + return self.c_basename + "_get" + return self.c_basename + "_set" + @functools.cached_property def displayname(self) -> str: """Pretty-printable name.""" @@ -126,6 +189,21 @@ def displayname(self) -> str: else: return self.name + @functools.cached_property + def c_basename_vectorcall(self) -> str: + """C function name for vectorcall parser. + + Strips the __init__/__new__ suffix from c_basename and appends + _vectorcall. Respects 'as' renaming in clinic input, e.g. + 'str.__new__ as unicode_new' produces 'unicode_vectorcall'. + """ + name = self.c_basename + for suffix in ('___init__', '___new__', '_new', '_init'): + if name.endswith(suffix): + name = name.removesuffix(suffix) + break + return f'{name}_vectorcall' + @functools.cached_property def fulldisplayname(self) -> str: parent: Class | Module | Clinic | None @@ -152,7 +230,8 @@ def render_parameters(self) -> list[Parameter]: @property def methoddef_flags(self) -> str | None: - if self.kind.new_or_init: + if self.kind.new_or_init or self.kind is SLOT: + # Slot functions are not stored in a PyMethodDef. return None flags = [] match self.kind: @@ -161,7 +240,7 @@ def methoddef_flags(self) -> str | None: case FunctionKind.STATIC_METHOD: flags.append('METH_STATIC') case _ as kind: - acceptable_kinds = {FunctionKind.CALLABLE, FunctionKind.GETTER, FunctionKind.SETTER} + acceptable_kinds = {FunctionKind.CALLABLE} | ACCESSORS assert kind in acceptable_kinds, f"unknown kind: {kind!r}" if self.coexist: flags.append('METH_COEXIST') @@ -205,10 +284,18 @@ class Parameter: converter: CConverter annotation: object = inspect.Parameter.empty docstring: str = '' + # Identifier of the optional group containing the parameter (0 if none). + # It is negative for groups before the required parameters. group: int = 0 + # Nesting level of that group (0 if none). + group_depth: int = 0 # (`None` signifies that there is no deprecation) deprecated_positional: VersionTuple | None = None deprecated_keyword: VersionTuple | None = None + # The release in which the parameter will be removed. + deprecated_until: VersionTuple | None = None + # Line of the file on which the parameter is declared. + line_number: int | None = None right_bracket_count: int = dc.field(init=False, default=0) def __repr__(self) -> str: @@ -265,6 +352,55 @@ def render_docstring(self) -> str: ParamTuple = tuple["Parameter", ...] +Definition = Module | Class | Function + + +def walk_definitions( + parent: Clinic | Module | Class, + prefix: str = '', + depth: int = 0, +) -> Iterator[tuple[int, str, Definition]]: + """Yield (depth, dotted name, definition) for every nested definition. + + The name of a module is already fully qualified, but the name of + a class is not, hence the prefix. + """ + for function in parent.functions: + if function.kind.new_or_init: + # __new__() and __init__() are called as the class itself. + name = prefix + else: + name = f'{prefix}.{function.name}' if prefix else function.name + yield depth, name, function + for cls in parent.classes.values(): + name = f'{prefix}.{cls.name}' if prefix else cls.name + yield depth, name, cls + yield from walk_definitions(cls, name, depth + 1) + if not isinstance(parent, Class): + # Only a module can contain modules. + for module in parent.modules.values(): + yield depth, module.name, module + yield from walk_definitions(module, module.name, depth + 1) + + +def group_to_variable_name(group: int) -> str: + adjective = "left_" if group < 0 else "right_" + return "group_" + adjective + str(abs(group)) + + +def count_required(subset: ParamTuple) -> int: + """Return the number of arguments which cannot be omitted. + + A parameter in an optional group is passed together with its group, + so only trailing parameters with a default value can be omitted. + """ + count = len(subset) + for p in reversed(subset): + if p.group or not p.is_optional(): + break + count -= 1 + return count + def permute_left_option_groups( l: Sequence[Iterable[Parameter]] @@ -301,15 +437,18 @@ def permute_right_option_groups( def permute_optional_groups( - left: Sequence[Iterable[Parameter]], + left: Sequence[Sequence[Iterable[Parameter]]], required: Iterable[Parameter], - right: Sequence[Iterable[Parameter]] + right: Sequence[Sequence[Iterable[Parameter]]] ) -> tuple[ParamTuple, ...]: """ Generator function that computes the set of acceptable argument lists for the provided iterables of argument groups. (Actually it generates a tuple of tuples.) + "left" and "right" are sequences of chains of nested groups. + Groups of different chains are independent of each other. + Algorithm: prefer left options over right options. If required is empty, left must also be empty. @@ -319,10 +458,21 @@ def permute_optional_groups( if left: raise ValueError("required is empty but left is not") + left_options: list[ParamTuple] = [()] + for chain in left: + left_options = [option + t + for option in left_options + for t in permute_left_option_groups(chain)] + right_options: list[ParamTuple] = [()] + for chain in reversed(right): + right_options = [t + option + for option in right_options + for t in permute_right_option_groups(chain)] + accumulator: list[ParamTuple] = [] counts = set() - for r in permute_right_option_groups(right): - for l in permute_left_option_groups(left): + for r in right_options: + for l in left_options: t = l + required + r if len(t) in counts: continue diff --git a/Tools/clinic/libclinic/language.py b/Tools/clinic/libclinic/language.py index 15975430c160220..c8da0c724f45ba2 100644 --- a/Tools/clinic/libclinic/language.py +++ b/Tools/clinic/libclinic/language.py @@ -35,6 +35,9 @@ def render( def parse_line(self, line: str) -> None: ... + def render_properties(self, clinic: Clinic) -> None: + ... + def validate(self) -> None: def assert_only_one( attr: str, diff --git a/Tools/clinic/libclinic/parse_args.py b/Tools/clinic/libclinic/parse_args.py index bca87ecd75100ce..4608947cb7fff7c 100644 --- a/Tools/clinic/libclinic/parse_args.py +++ b/Tools/clinic/libclinic/parse_args.py @@ -1,11 +1,13 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Final +from typing import TYPE_CHECKING, Final, Literal import libclinic -from libclinic import fail, warn +from libclinic import fail, warn, unspecified, Sentinels from libclinic.function import ( - Function, Parameter, - GETTER, SETTER, METHOD_NEW) + Function, Parameter, ParamTuple, + count_required, group_to_variable_name, permute_optional_groups, + GETTER, SETTER, SETTER_AND_DELETER, METHOD_INIT, METHOD_NEW, SLOT, + ACCESSORS, SETTERS) from libclinic.converter import CConverter from libclinic.converters import ( defining_class_converter, object_converter, self_converter) @@ -99,12 +101,13 @@ def declare_parser( NO_VARARG: Final[str] = "PY_SSIZE_T_MAX" PARSER_PROTOTYPE_KEYWORD: Final[str] = libclinic.normalize_snippet(""" - static PyObject * + static {return_type} {c_basename}({self_type}{self_name}, PyObject *args, PyObject *kwargs) """) -PARSER_PROTOTYPE_KEYWORD___INIT__: Final[str] = libclinic.normalize_snippet(""" - static int - {c_basename}({self_type}{self_name}, PyObject *args, PyObject *kwargs) +PARSER_PROTOTYPE_KEYWORD_HELPER: Final[str] = libclinic.normalize_snippet(""" + static {return_type} + {c_basename}_helper({self_type}{self_name}, PyObject *const *args, + Py_ssize_t nargs, Py_ssize_t nkw, PyObject *kwargs, PyObject *kwnames) """) PARSER_PROTOTYPE_VARARGS: Final[str] = libclinic.normalize_snippet(""" static PyObject * @@ -118,6 +121,11 @@ def declare_parser( static PyObject * {c_basename}({self_type}{self_name}, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) """) +PARSER_PROTOTYPE_VECTORCALL: Final[str] = libclinic.normalize_snippet(""" + static PyObject * + {vc_basename}(PyObject *type, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +""") PARSER_PROTOTYPE_DEF_CLASS: Final[str] = libclinic.normalize_snippet(""" static PyObject * {c_basename}({self_type}{self_name}, PyTypeObject *{defining_class_name}, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) @@ -132,7 +140,15 @@ def declare_parser( """) PARSER_PROTOTYPE_SETTER: Final[str] = libclinic.normalize_snippet(""" static int - {c_basename}({self_type}{self_name}, PyObject *value, void *Py_UNUSED(context)) + {c_basename}({self_type}{self_name}, PyObject *arg, void *Py_UNUSED(context)) +""") +PARSER_PROTOTYPE_SLOT: Final[str] = libclinic.normalize_snippet(""" + static {return_type} + {c_basename}({self_type}{self_name}) +""") +PARSER_PROTOTYPE_SLOT_ARGS: Final[str] = libclinic.normalize_snippet(""" + static {return_type} + {c_basename}({self_type}{self_name}, {parser_parameters}) """) METH_O_PROTOTYPE: Final[str] = libclinic.normalize_snippet(""" static PyObject * @@ -145,13 +161,20 @@ def declare_parser( PyDoc_STRVAR({c_basename}__doc__, {docstring}); """) +# The docstring of an attribute is defined by its getter. GETSET_DOCSTRING_PROTOTYPE_STRVAR: Final[str] = libclinic.normalize_snippet(""" PyDoc_STRVAR({getset_basename}__doc__, {docstring}); - #if defined({getset_basename}_DOCSTR) - # undef {getset_basename}_DOCSTR +""") +# If the getter is compiled conditionally, the entry refers to the docstring +# by a macro, because only the preprocessor knows which one is defined. +GETSET_DOCSTRING_PROTOTYPE_DEFINE: Final[str] = libclinic.normalize_snippet(""" + PyDoc_STRVAR({getset_basename}__doc__, + {docstring}); + #if defined({getset_name}_DOCSTR) + # undef {getset_name}_DOCSTR #endif - #define {getset_basename}_DOCSTR {getset_basename}__doc__ + #define {getset_name}_DOCSTR {getset_basename}__doc__ """) IMPL_DEFINITION_PROTOTYPE: Final[str] = libclinic.normalize_snippet(""" static {impl_return_type} @@ -161,33 +184,97 @@ def declare_parser( #define {methoddef_name} \ {{"{name}", {methoddef_cast}{c_basename}{methoddef_cast_end}, {methoddef_flags}, {c_basename}__doc__}}, """) -GETTERDEF_PROTOTYPE_DEFINE: Final[str] = libclinic.normalize_snippet(r""" - #if !defined({getset_basename}_DOCSTR) - # define {getset_basename}_DOCSTR NULL - #endif - #if defined({getset_name}_GETSETDEF) - # undef {getset_name}_GETSETDEF - # define {getset_name}_GETSETDEF {{"{name}", (getter){getset_basename}_get, (setter){getset_basename}_set, {getset_basename}_DOCSTR}}, - #else - # define {getset_name}_GETSETDEF {{"{name}", (getter){getset_basename}_get, NULL, {getset_basename}_DOCSTR}}, - #endif +# An accessor which is compiled conditionally announces the function which +# implements it. Only the preprocessor knows which of them are compiled, so +# the entry is composed of these announcements +# (see GETSETDEF_PROTOTYPE_COMBINE). +GETTERDEF_PROTOTYPE_DEFINE: Final[str] = libclinic.normalize_snippet(""" + #define {getset_name}_GETTER {c_basename} """) -SETTERDEF_PROTOTYPE_DEFINE: Final[str] = libclinic.normalize_snippet(r""" - #if !defined({getset_basename}_DOCSTR) - # define {getset_basename}_DOCSTR NULL - #endif - #if defined({getset_name}_GETSETDEF) - # undef {getset_name}_GETSETDEF - # define {getset_name}_GETSETDEF {{"{name}", (getter){getset_basename}_get, (setter){getset_basename}_set, {getset_basename}_DOCSTR}}, - #else - # define {getset_name}_GETSETDEF {{"{name}", NULL, (setter){getset_basename}_set, NULL}}, - #endif +SETTER_PREAMBLE: Final[str] = libclinic.normalize_snippet(""" + if (arg == NULL) {{ + PyErr_Format(PyExc_AttributeError, + "attribute '{name}' of '%.100s' objects cannot be deleted", + Py_TYPE({self_name})->tp_name); + return -1; + }} +""", indent=4) +SETTERDEF_PROTOTYPE_DEFINE: Final[str] = libclinic.normalize_snippet(""" + #define {getset_name}_SETTER {c_basename} """) METHODDEF_PROTOTYPE_IFNDEF: Final[str] = libclinic.normalize_snippet(""" #ifndef {methoddef_name} #define {methoddef_name} #endif /* !defined({methoddef_name}) */ """) +# The entry of an attribute whose accessors are all compiled unconditionally. +GETSETDEF_PROTOTYPE_DEFINE: Final[str] = libclinic.normalize_snippet(""" + #define {getset_name}_GETSETDEF {{"{name}", (getter){getter}, (setter){setter}, {docstr}}}, +""") +# Composes the PyGetSetDef entry of an attribute. It must be rendered after +# all accessors of that attribute, so it is written to the same destination as +# the "ifndef" of a method, which is emptied at the end of the file. +GETSETDEF_PROTOTYPE_COMBINE: Final[str] = libclinic.normalize_snippet(""" + #if defined({getset_name}_GETTER) || defined({getset_name}_SETTER) + # if !defined({getset_name}_GETTER) + # define {getset_name}_GETTER NULL + # endif + # if !defined({getset_name}_SETTER) + # define {getset_name}_SETTER NULL + # endif + # if !defined({getset_name}_DOCSTR) + # define {getset_name}_DOCSTR NULL + # endif + # define {getset_name}_GETSETDEF {{"{name}", (getter){getset_name}_GETTER, (setter){getset_name}_SETTER, {getset_name}_DOCSTR}}, + #else + # define {getset_name}_GETSETDEF + #endif +""") +# Every parser body ends with this shape; parser_body() and +# _assemble_vectorcall() fill the assembly-time markers. +PARSER_FINALE_SKELETON: Final[str] = libclinic.normalize_snippet(""" + {modifications} + {self_alloc} + {lock} + {impl_call} + {unlock} + {init_result_check} + {return_conversion} + {post_parsing} + + {exit_label} + {cleanup} + return {parser_retval}; + }} +""") +VECTORCALL_FINALE_MARKERS_NEW: Final[dict[str, str]] = { + "init_declarations": "", + "self_alloc": "", + "impl_call": + "{return_value} = {c_basename}_impl({vectorcall_impl_arguments});", + "init_result_check": "", +} +# METHOD_INIT: Create self through tp_new. In vectorcall we have no tuple of +# args and want to void constructing one so pass the empty tuple. This is okay +# for PyType_GenericNew which ignores args. +VECTORCALL_FINALE_MARKERS_INIT: Final[dict[str, str]] = { + "init_declarations": "PyObject *self;\nint _result;", + "self_alloc": libclinic.normalize_snippet(""" + self = _PyType_CAST(type)->tp_new(_PyType_CAST(type), + (PyObject *)&_Py_SINGLETON(tuple_empty), NULL); + if (self == NULL) {{ + goto exit; + }} + """), + "impl_call": "_result = {c_basename}_impl({vectorcall_impl_arguments});", + "init_result_check": libclinic.normalize_snippet(""" + if (_result != 0) {{ + Py_DECREF(self); + goto exit; + }} + return_value = self; + """), +} class ParseArgsCodeGen: @@ -229,6 +316,7 @@ class ParseArgsCodeGen: methoddef_define: str parser_prototype: str parser_definition: str + parser_helper: str cpp_if: str cpp_endif: str methoddef_ifndef: str @@ -282,6 +370,9 @@ def __init__(self, func: Function, codegen: CodeGen) -> None: self.max_pos = 0 self.min_kw_only = 0 for i, p in enumerate(self.parameters, 1): + if p.converter.alias_of is not None: + # An alias fills the slot of the parameter which it aliases. + continue if p.is_keyword_only(): assert not p.is_positional_only() if not p.is_optional(): @@ -303,14 +394,18 @@ def has_option_groups(self) -> bool: def use_meth_o(self) -> bool: return (len(self.parameters) == 1 and self.parameters[0].is_positional_only() + and not self.has_option_groups() and not self.converters[0].is_optional() and not self.varpos and not self.requires_defining_class and not self.is_new_or_init()) def use_simple_return(self) -> bool: + if self.func.critical_section: + return False + # A slot function returns the result of the impl unchanged. return (self.func.return_converter.type == 'PyObject *' - and not self.func.critical_section) + or self.func.kind is SLOT) def use_pyobject_self(self) -> bool: return self.self_parameter_converter.use_pyobject_self(self.func) @@ -319,19 +414,39 @@ def select_prototypes(self) -> None: self.docstring_prototype = '' self.docstring_definition = '' self.methoddef_define = METHODDEF_PROTOTYPE_DEFINE - self.return_value_declaration = "PyObject *return_value = NULL;" + self.return_value_declaration = "PyObject *{parser_retval} = NULL;" if self.is_new_or_init() and not self.func.docstring: pass + elif self.func.kind is SLOT: + # A slot function is not stored in a PyMethodDef and has no + # docstring (the DSL parser rejects one). It returns what its + # slot declares. + assert not self.func.docstring + assert self.func.slot is not None + self.methoddef_define = '' + return_type = self.func.slot.return_type + if not return_type.endswith('*'): + return_type += ' ' + self.return_value_declaration = ( + f"{return_type}{{parser_retval}} = " + f"{self.func.slot.error_value};") elif self.func.kind is GETTER: - self.methoddef_define = GETTERDEF_PROTOTYPE_DEFINE + # Only an accessor compiled conditionally announces itself. + self.methoddef_define = (GETTERDEF_PROTOTYPE_DEFINE + if self.func.condition else '') if self.func.docstring: - self.docstring_definition = GETSET_DOCSTRING_PROTOTYPE_STRVAR - elif self.func.kind is SETTER: + self.docstring_definition = ( + GETSET_DOCSTRING_PROTOTYPE_DEFINE if self.func.condition + else GETSET_DOCSTRING_PROTOTYPE_STRVAR) + elif self.func.kind in SETTERS: if self.func.docstring: - fail("docstrings are only supported for @getter, not @setter") - self.return_value_declaration = "int {return_value};" - self.methoddef_define = SETTERDEF_PROTOTYPE_DEFINE + fail("docstrings are only supported for @getter", + line_number=self.func.line_number) + # The conversion of the value can fail before it is set. + self.return_value_declaration = "int {parser_retval} = -1;" + self.methoddef_define = (SETTERDEF_PROTOTYPE_DEFINE + if self.func.condition else '') else: self.docstring_prototype = DOCSTRING_PROTOTYPE_VAR self.docstring_definition = DOCSTRING_PROTOTYPE_STRVAR @@ -346,11 +461,7 @@ def init_limited_capi(self) -> None: warn(f"Function {self.func.full_name} cannot use limited C API") self.limited_capi = False - def parser_body( - self, - *fields: str, - declarations: str = '' - ) -> None: + def parser_body(self, *fields: str) -> None: lines = [self.parser_prototype] self.parser_body_fields = fields @@ -361,35 +472,71 @@ def parser_body( {declarations} {initializers} """) + "\n" - finale = libclinic.normalize_snippet(""" - {modifications} - {lock} - {return_value} = {c_basename}_impl({impl_arguments}); - {unlock} - {return_conversion} - {post_parsing} - - {exit_label} - {cleanup} - return return_value; - }} - """) + finale = PARSER_FINALE_SKELETON for field in preamble, *fields, finale: lines.append(field) - code = libclinic.linear_format("\n".join(lines), - parser_declarations=self.declarations) + code = libclinic.linear_format( + "\n".join(lines), + parser_declarations=self.declarations, + self_alloc="", + impl_call="{return_value} = {c_basename}_impl({impl_arguments});", + init_result_check="") self.parser_definition = code - def parse_no_args(self) -> None: - parser_code: list[str] | None - simple_return = self.use_simple_return() + def render_setter_value(self) -> str: + """Return the code which converts the new value of the attribute.""" + # The parser guarantees that the value is the only parameter. + assert len(self.parameters) == 1 + p = self.parameters[0] + parsearg = p.converter.parse_arg('arg', p.get_displayname(0), + limited_capi=self.limited_capi) + if parsearg is None: + p.converter.use_converter() + parsearg = """ + if (!PyArg_Parse(arg, "{format_units}:{name}", {parse_arguments})) {{ + goto exit; + }} + """ + if self.func.kind is not SETTER_AND_DELETER: + return libclinic.normalize_snippet(parsearg, indent=4) + # The value is only converted if the attribute is not deleted. + return "\n".join([ + libclinic.normalize_snippet("if (arg != NULL) {{", indent=4), + libclinic.normalize_snippet(parsearg, indent=8), + libclinic.normalize_snippet("}}", indent=4), + ]) + + def parse_slot(self) -> None: + """Generate the slot function. + + It does not parse anything: it forwards its arguments to the impl + and, with @critical_section, holds the lock while doing so. + """ + if self.parameters: + self.parser_prototype = PARSER_PROTOTYPE_SLOT_ARGS + else: + self.parser_prototype = PARSER_PROTOTYPE_SLOT + self.finish_parser_body([]) + + def parse_accessor(self) -> None: + """Generate the code of a getter or a setter.""" + parser_code: list[str] = [] if self.func.kind is GETTER: self.parser_prototype = PARSER_PROTOTYPE_GETTER - parser_code = [] - elif self.func.kind is SETTER: + else: self.parser_prototype = PARSER_PROTOTYPE_SETTER - parser_code = [] - elif not self.requires_defining_class: + # The setter is called with NULL to delete the attribute, which + # is checked before parsing, because NULL is not a value. + if self.func.kind is SETTER: + # The setter which is not the deleter rejects the deletion. + parser_code.append(SETTER_PREAMBLE) + parser_code.append(self.render_setter_value()) + self.finish_parser_body(parser_code) + + def parse_no_args(self) -> None: + parser_code: list[str] | None + simple_return = self.use_simple_return() + if not self.requires_defining_class: # no self.parameters, METH_NOARGS self.flags = "METH_NOARGS" self.parser_prototype = PARSER_PROTOTYPE_NOARGS @@ -408,7 +555,12 @@ def parse_no_args(self) -> None: }} """ % return_error, indent=4)] - if simple_return: + self.finish_parser_body(parser_code) + + def finish_parser_body(self, parser_code: list[str]) -> None: + """Generate the parsing function from the code which parses + the arguments.""" + if self.use_simple_return(): self.parser_definition = '\n'.join([ self.parser_prototype, '{{', @@ -461,53 +613,442 @@ def parse_one_arg(self) -> None: parser_code = libclinic.normalize_snippet(parsearg, indent=4) self.parser_body(parser_code) + def option_group_subsets(self) -> dict[int, ParamTuple]: + # positional only, grouped, optional arguments! + # can be optional on the left or right. + # here's an example: + # + # [ [ [ A1 A2 ] B1 B2 B3 ] C1 C2 ] D1 D2 D3 [ E1 E2 E3 [ F1 F2 F3 ] ] + # + # Here group D are required, and all other groups are optional. + # (Group D's "group" is actually None.) + # We can figure out which sets of arguments we have based on + # how many arguments are in the tuple. + # + # Note that you need to count up on both sides. For example, + # you could have groups C+D, or C+D+E, or C+D+E+F. + # + # What if the number of arguments leads us to an ambiguous result? + # Clinic prefers groups on the left. So in the above example, + # five arguments would map to B+C, not C+D. + # + # A nested group can only be omitted together with the group + # containing it, but groups on the same level, like G and H in + # + # [ G1 G2 ] [ H1 ] I1 I2 + # + # can be omitted independently of each other. + + # Groups are collected into chains of nested groups. A group which + # is not nested in the preceding one starts a new chain. + group: list[Parameter] | None = None + left: list[list[list[Parameter]]] = [] + right: list[list[list[Parameter]]] = [] + required: list[Parameter] = [] + last: int | Literal[Sentinels.unspecified] = unspecified + last_depth = 0 + + for p in self.parameters: + group_id = p.group + if group_id != last: + last = group_id + group = [] + if group_id == 0: + group = required + else: + chains = left if group_id < 0 else right + nested = ((p.group_depth < last_depth) if group_id < 0 + else (p.group_depth > last_depth)) + if chains and nested: + chains[-1].append(group) + else: + chains.append([group]) + last_depth = p.group_depth + assert group is not None + group.append(p) + + # Map the number of arguments to the subset which accepts it. + subsets: dict[int, ParamTuple] = {} + for subset in permute_optional_groups(left, required, right): + for count in range(count_required(subset), len(subset) + 1): + if count in subsets: + fail(f"Function {self.func.full_name!r} has an ambiguous " + f"group configuration: a call with {count} " + f"argument(s) can be parsed in more than one way.", + line_number=self.func.line_number) + subsets[count] = subset + return subsets + def parse_option_groups(self) -> None: # positional parameters with option groups - # (we have to generate lots of PyArg_ParseTuple calls - # in a big switch statement) + # (which groups are passed is determined by the number of arguments) + + nargs, argname_fmt = self.select_positional_convention() + # With the stack convention "nargs" is already a parameter. + size_expr = None if self.fastcall else nargs + + subsets = self.option_group_subsets() + parser_code = self.render_option_groups(subsets, argname_fmt, size_expr) + if parser_code is None: + # The code of some converter cannot be inlined, so the + # arguments of every combination of groups are parsed at once. + parser_code = self.render_option_groups_parse_tuple(subsets) + self.parser_body(*parser_code) - self.flags = "METH_VARARGS" - self.parser_prototype = PARSER_PROTOTYPE_VARARGS - parser_code = ' {option_group_parsing}' - self.parser_body(parser_code) + def render_option_groups( + self, + subsets: dict[int, ParamTuple], + argname_fmt: str, + size_expr: str | None, + ) -> list[str] | None: + """Return the code which parses the arguments of all groups. + + Every parameter is parsed once, in a block guarded by the number of + arguments. Return None if the code of some converter cannot be + inlined. + """ + # Split the parameters into the groups, in the order in which + # they are passed. + groups: list[tuple[int, list[Parameter]]] = [] + for p in self.parameters: + if not groups or groups[-1][0] != p.group: + groups.append((p.group, [])) + groups[-1][1].append(p) + + indices, shifting = self.render_option_group_indices(subsets, groups) + + parser_code = [] + if size_expr is not None: + parser_code.append(libclinic.normalize_snippet( + f"Py_ssize_t nargs = {size_expr};", indent=4)) + if shifting: + parser_code.append(libclinic.normalize_snippet( + "Py_ssize_t offset = 0;", indent=4)) + parser_code.append(self.render_option_group_check(subsets)) - def _parse_vararg(self) -> str: + has_optional = False + for group_id, params in groups: + body = [] + for p in params: + index_expr = indices[p.name] + if index_expr.isdigit(): + displayname = p.get_displayname(int(index_expr) + 1) + else: + # The position of the argument differs between the calls. + displayname = p.get_displayname(0) + parsearg = p.converter.parse_arg(argname_fmt % index_expr, + displayname, + limited_capi=self.limited_capi) + if parsearg is None: + return None + if not group_id and (has_optional or p.is_optional()): + # Such parameter is omitted on its own, and nothing + # can follow it, so the rest is simply skipped. + has_optional = True + body.append(libclinic.normalize_snippet(""" + if (nargs <= %s) {{ + goto skip_optional; + }} + """, indent=4) % index_expr) + body.append(libclinic.normalize_snippet(parsearg, indent=4)) + + if not group_id: + parser_code.extend(body) + continue + + if group_id in shifting: + # The arguments of this group shift the following ones. + body.append(libclinic.normalize_snippet( + f"offset += {len(params)};", indent=4)) + body.append(libclinic.normalize_snippet( + f"{group_to_variable_name(group_id)} = 1;", indent=4)) + condition = self.render_option_group_condition(subsets, group_id) + parser_code.append(libclinic.normalize_snippet( + f"if ({condition}) {{{{", indent=4)) + parser_code.extend(libclinic.normalize_snippet(line, indent=8) + for line in body) + parser_code.append(libclinic.normalize_snippet("}}", indent=4)) + + if has_optional: + parser_code.append("skip_optional:") + return parser_code + + @staticmethod + def render_option_group_indices( + subsets: dict[int, ParamTuple], + groups: list[tuple[int, list[Parameter]]], + ) -> tuple[dict[str, str], set[int]]: + """Return the index of the argument of every parameter, as C code, + and the groups which have to add their size to "offset". + + A group which is not passed shifts the following arguments. Their + index can still be fixed if it is counted from the end; otherwise it + is counted at run time, in "offset". + """ + forward: dict[str, set[int]] = {} + backward: dict[str, set[int]] = {} + for count, subset in subsets.items(): + for i, p in enumerate(subset[:count]): + forward.setdefault(p.name, set()).add(i) + backward.setdefault(p.name, set()).add(count - i) + # A parameter with a default value can be omitted on its own, so + # its index from the end is not fixed. + for group_id, params in groups: + if not group_id: + for p in params: + if p.is_optional(): + backward.pop(p.name) + + def counted_at_run_time(p: Parameter) -> bool: + return (len(forward[p.name]) != 1 + and len(backward.get(p.name, ())) != 1) + + # A group adds its size to "offset" if it shifts an argument + # which is counted at run time. + shifting: set[int] = set() + seen: list[int] = [] + for group_id, params in groups: + if any(counted_at_run_time(p) for p in params): + shifting.update(g for g in seen if g) + seen.append(group_id) + + indices = {} + # The number of the parameters before the current one, and how many + # of them are counted in "offset". + pos = 0 + in_offset = 0 + for group_id, params in groups: + for i, p in enumerate(params): + if not counted_at_run_time(p): + if len(forward[p.name]) == 1: + indices[p.name] = str(min(forward[p.name])) + else: + indices[p.name] = f"nargs - {min(backward[p.name])}" + else: + index = pos + i - in_offset + indices[p.name] = ("offset" if index == 0 + else f"offset + {index}") + pos += len(params) + if group_id in shifting: + in_offset += len(params) + return indices, shifting + + @staticmethod + def render_option_group_condition( + subsets: dict[int, ParamTuple], + group_id: int, + ) -> str: + """Return the condition on which the group is passed.""" + counts = sorted(count for count, subset in subsets.items() + if any(p.group == group_id for p in subset)) + if counts == list(range(counts[0], max(subsets) + 1)): + return f"nargs >= {counts[0]}" + return " || ".join(f"nargs == {count}" for count in counts) + + def render_option_group_check( + self, + subsets: dict[int, ParamTuple], + ) -> str: + """Return the code which rejects an unsupported number of arguments.""" + error = ('PyErr_SetString(PyExc_TypeError, "%s requires %d to %d ' + 'arguments");' % (self.func.full_name, min(subsets), + max(subsets))) + counts = sorted(subsets) + if counts == list(range(counts[0], counts[-1] + 1)): + tests = [f"nargs > {counts[-1]}"] + if counts[0]: + tests.insert(0, f"nargs < {counts[0]}") + lines = [ + f"if ({' || '.join(tests)}) {{{{", + f" {error}", + " goto exit;", + "}}", + ] + else: + # Some numbers of arguments in between are not supported. + lines = ["switch (nargs) {{"] + lines += [f" case {count}:" for count in counts] + lines += [ + " break;", + " default:", + f" {error}", + " goto exit;", + "}}", + ] + return libclinic.normalize_snippet("\n".join(lines), indent=4) + + def render_option_groups_parse_tuple( + self, + subsets: dict[int, ParamTuple], + ) -> list[str]: + """Return the code which parses the arguments of every group at once.""" + parse_call = self.render_parse_all_arguments() + # The convention can have changed, so ask for it again. + size_expr, _ = self.select_positional_convention() + parser_code = [libclinic.normalize_snippet(f"switch ({size_expr}) {{{{", + indent=4)] + for count, subset in sorted(subsets.items()): + parser_code.append(f" case {count}:") + if count != len(subset): + # The omitted parameters are parsed by the following case. + continue + if count: + format_units = [p.converter.format_unit for p in subset] + n_required = count_required(subset) + if n_required < count: + format_units.insert(n_required, '|') + parse_arguments: list[str] = [] + for p in subset: + p.converter.parse_argument(parse_arguments) + parser_code.append(libclinic.normalize_snippet(""" + if (!%s"%s:%s", %s)) {{ + goto exit; + }} + """, indent=12) % (parse_call, "".join(format_units), + self.func.name, + ", ".join(parse_arguments))) + # A set would eliminate duplicates too, but the iteration + # order of small negative integers depends on the platform. + group_ids = dict.fromkeys(p.group for p in subset) + group_ids.pop(0, None) + for group_id in group_ids: + parser_code.append( + f" {group_to_variable_name(group_id)} = 1;") + parser_code.append(" break;") + parser_code.append(" default:") + parser_code.append( + ' PyErr_SetString(PyExc_TypeError, "%s requires %d to %d arguments");' + % (self.func.full_name, min(subsets), max(subsets))) + parser_code.append(" goto exit;") + parser_code.append(" }}") + return parser_code + + def _parse_vararg(self, *, fastcall: bool) -> str: assert self.varpos is not None c = self.varpos.converter assert isinstance(c, libclinic.converters.VarPosCConverter) return c.parse_vararg(pos_only=self.pos_only, min_pos=self.min_pos, max_pos=self.max_pos, - fastcall=self.fastcall, + fastcall=fastcall, limited_capi=self.limited_capi) - def _parse_kwarg(self) -> str: + def _parse_kwarg(self, *, stackargs: bool) -> str: assert self.var_keyword is not None c = self.var_keyword.converter assert isinstance(c, libclinic.converters.VarKeywordCConverter) - return c.parse_var_keyword() + return c.parse_var_keyword(stackargs=stackargs) - def parse_pos_only(self) -> None: - if self.fastcall: - # positional-only, but no option groups - # we only need one call to _PyArg_ParseStack + def _check_positional(self, nargs: str, *, + indent: int = 4) -> list[str]: + """Emit an argument count check when needed. + + Varpos functions have no upper bound but still need a check when a + minimum number of positional arguments are required. + """ + max_args = NO_VARARG if self.varpos else self.max_pos + if not self.min_pos and max_args == NO_VARARG: + return [] + self.codegen.add_include('pycore_modsupport.h', + '_PyArg_CheckPositional()') + return [libclinic.normalize_snippet(f""" + if (!_PyArg_CheckPositional("{{name}}", {nargs}, {self.min_pos}, {max_args})) {{{{ + goto exit; + }}}} + """, indent=indent)] + + def _parse_positional_args( + self, + *, + argname_fmt: str, + nargs: str, + limited_capi: bool, + fastcall: bool, + ) -> list[str] | None: + """Emit per-parameter positional argument parsing. + + Returns the code snippets, or None if a converter doesn't support + parse_arg (the caller must fall back to a tuple/stack parser). + """ + parser_code: list[str] = [] + for i, p in enumerate(self.parameters): + parsearg = p.converter.parse_arg(argname_fmt % i, + p.get_displayname(i + 1), + limited_capi=limited_capi) + if parsearg is None: + if self.varpos: + raise ValueError( + f"Using converter {p.converter} is not supported " + f"in function with var-positional parameter") + return None + if p.deprecated_until is not None: + parsearg = self.render_deprecated(p, parsearg) + if i >= self.min_pos: + # p and everything after it is optional. + parser_code.append(libclinic.normalize_snippet(f""" + if ({nargs} < {i + 1}) {{{{ + goto skip_optional; + }}}} + """, indent=4)) + parser_code.append(libclinic.normalize_snippet(parsearg, indent=4)) + + if self.min_pos < len(self.parameters): + parser_code.append("skip_optional:") + if self.varpos: + parser_code.append(libclinic.normalize_snippet( + self._parse_vararg(fastcall=fastcall), indent=4)) + if self.var_keyword: + parser_code.append(libclinic.normalize_snippet( + self._parse_kwarg(stackargs=fastcall), indent=4)) + return parser_code + def select_positional_convention(self) -> tuple[str, str]: + """Select the calling convention of a positional-only function. + + Set the method flags and the prototype, and return the expression of + the number of arguments and the format of an argument expression. + """ + if self.requires_defining_class: + # METH_METHOD only supports the METH_FASTCALL|METH_KEYWORDS + # calling convention, so the wrapper still receives kwnames. + # A positional-only function simply rejects any keywords + # instead of setting up a _PyArg_Parser. + assert self.fastcall + self.flags = "METH_METHOD|METH_FASTCALL|METH_KEYWORDS" + self.parser_prototype = PARSER_PROTOTYPE_DEF_CLASS + return 'nargs', 'args[%s]' + if self.fastcall: self.flags = "METH_FASTCALL" self.parser_prototype = PARSER_PROTOTYPE_FASTCALL - nargs = 'nargs' - argname_fmt = 'args[%d]' - else: - # positional-only, but no option groups - # we only need one call to PyArg_ParseTuple + return 'nargs', 'args[%s]' - self.flags = "METH_VARARGS" - self.parser_prototype = PARSER_PROTOTYPE_VARARGS - if self.limited_capi: - nargs = 'PyTuple_Size(args)' - argname_fmt = 'PyTuple_GetItem(args, %d)' - else: - nargs = 'PyTuple_GET_SIZE(args)' - argname_fmt = 'PyTuple_GET_ITEM(args, %d)' + self.flags = "METH_VARARGS" + self.parser_prototype = PARSER_PROTOTYPE_VARARGS + if self.limited_capi: + return 'PyTuple_Size(args)', 'PyTuple_GetItem(args, %s)' + return 'PyTuple_GET_SIZE(args)', 'PyTuple_GET_ITEM(args, %s)' + + def render_parse_all_arguments(self) -> str: + """Return the beginning of the call which parses all arguments. + + Fall back to the tuple convention if the stack one cannot be used. + """ + self.use_converters() + if self.limited_capi: + # PyArg_ParseArray() is not part of the limited C API. + self.fastcall = False + if self.fastcall: + self.codegen.add_include('pycore_modsupport.h', + 'PyArg_ParseArray()') + return 'PyArg_ParseArray(args, nargs, ' + self.flags = "METH_VARARGS" + self.parser_prototype = PARSER_PROTOTYPE_VARARGS + return 'PyArg_ParseTuple(args, ' + + def parse_pos_only(self) -> None: + # positional-only, but no option groups: we only need one call + # to PyArg_ParseArray or PyArg_ParseTuple + nargs, argname_fmt = self.select_positional_convention() parser_code = [] max_args = NO_VARARG if self.varpos else self.max_pos @@ -544,113 +1085,131 @@ def parse_pos_only(self) -> None: }}}} """, indent=4)) - elif self.min_pos or max_args != NO_VARARG: + else: + parser_code.extend(self._check_positional(nargs)) + + pos_code = self._parse_positional_args( + argname_fmt=argname_fmt, nargs=nargs, + limited_capi=self.limited_capi, fastcall=self.fastcall) + if pos_code is not None: + parser_code.extend(pos_code) + else: + parse_call = self.render_parse_all_arguments() + parser_code = [libclinic.normalize_snippet(""" + if (!%s"{format_units}:{name}", + {parse_arguments})) {{ + goto exit; + }} + """, indent=4) % parse_call] + if self.requires_defining_class: self.codegen.add_include('pycore_modsupport.h', - '_PyArg_CheckPositional()') - parser_code.append(libclinic.normalize_snippet(f""" - if (!_PyArg_CheckPositional("{{name}}", {nargs}, {self.min_pos}, {max_args})) {{{{ + '_PyArg_NoKwnames()') + parser_code.insert(0, libclinic.normalize_snippet(""" + if (!_PyArg_NoKwnames("{name}", kwnames)) {{ goto exit; - }}}} + }} """, indent=4)) - - has_optional = False - use_parser_code = True - for i, p in enumerate(self.parameters): - displayname = p.get_displayname(i+1) - argname = argname_fmt % i - parsearg: str | None - parsearg = p.converter.parse_arg(argname, displayname, limited_capi=self.limited_capi) - if parsearg is None: - if self.varpos: - raise ValueError( - f"Using converter {p.converter} is not supported " - f"in function with var-positional parameter") - use_parser_code = False - parser_code = [] - break - if has_optional or p.is_optional(): - has_optional = True - parser_code.append(libclinic.normalize_snippet(""" - if (%s < %d) {{ - goto skip_optional; - }} - """, indent=4) % (nargs, i + 1)) - parser_code.append(libclinic.normalize_snippet(parsearg, indent=4)) - - if use_parser_code: - if has_optional: - parser_code.append("skip_optional:") - if self.varpos: - parser_code.append(libclinic.normalize_snippet(self._parse_vararg(), indent=4)) - elif self.var_keyword: - parser_code.append(libclinic.normalize_snippet(self._parse_kwarg(), indent=4)) - else: - for parameter in self.parameters: - parameter.converter.use_converter() - - if self.limited_capi: - self.fastcall = False - if self.fastcall: - self.codegen.add_include('pycore_modsupport.h', - '_PyArg_ParseStack()') - parser_code = [libclinic.normalize_snippet(""" - if (!_PyArg_ParseStack(args, nargs, "{format_units}:{name}", - {parse_arguments})) {{ - goto exit; - }} - """, indent=4)] - else: - self.flags = "METH_VARARGS" - self.parser_prototype = PARSER_PROTOTYPE_VARARGS - parser_code = [libclinic.normalize_snippet(""" - if (!PyArg_ParseTuple(args, "{format_units}:{name}", - {parse_arguments})) {{ - goto exit; - }} - """, indent=4)] self.parser_body(*parser_code) - def parse_var_keyword(self) -> None: + def parse_var_keyword(self, *, vectorcall: bool = False) -> None: self.flags = "METH_VARARGS|METH_KEYWORDS" - self.parser_prototype = PARSER_PROTOTYPE_KEYWORD - nargs = 'PyTuple_GET_SIZE(args)' + # The vectorcall gets an array of arguments and kwnames, not a tuple + # and a dict: use the converters' fastcall convention, which handles + # that. + if vectorcall: + nargs, argname_fmt = 'nargs', 'args[%d]' + check, arg = '_PyArg_NoPositionalStack', 'nargs' + parser_code = self._vectorcall_type_check() + else: + self.parser_prototype = PARSER_PROTOTYPE_KEYWORD + nargs, argname_fmt = 'PyTuple_GET_SIZE(args)', 'PyTuple_GET_ITEM(args, %d)' + check, arg = '_PyArg_NoPositional', 'args' + parser_code = [] - parser_code = [] - max_args = NO_VARARG if self.varpos else self.max_pos if self.varpos is None and self.min_pos == self.max_pos == 0: - self.codegen.add_include('pycore_modsupport.h', - '_PyArg_NoPositional()') - parser_code.append(libclinic.normalize_snippet(""" - if (!_PyArg_NoPositional("{name}", args)) {{ - goto exit; - }} - """, indent=4)) - elif self.min_pos or max_args != NO_VARARG: - self.codegen.add_include('pycore_modsupport.h', - '_PyArg_CheckPositional()') + self.codegen.add_include('pycore_modsupport.h', f'{check}()') parser_code.append(libclinic.normalize_snippet(f""" - if (!_PyArg_CheckPositional("{{name}}", {nargs}, {self.min_pos}, {max_args})) {{{{ + if (!{check}("{{name}}", {arg})) {{{{ goto exit; }}}} """, indent=4)) + else: + parser_code.extend(self._check_positional(nargs)) - for i, p in enumerate(self.parameters): - parse_arg = p.converter.parse_arg( - f'PyTuple_GET_ITEM(args, {i})', - p.get_displayname(i+1), - limited_capi=self.limited_capi, - ) - assert parse_arg is not None - parser_code.append(libclinic.normalize_snippet(parse_arg, indent=4)) + pos_code = self._parse_positional_args( + argname_fmt=argname_fmt, nargs=nargs, + limited_capi=self.limited_capi, fastcall=vectorcall) + assert pos_code is not None + parser_code.extend(pos_code) + body = self.vectorcall_body if vectorcall else self.parser_body + body(*parser_code) - if self.varpos: - parser_code.append(libclinic.normalize_snippet(self._parse_vararg(), indent=4)) - if self.var_keyword: - parser_code.append(libclinic.normalize_snippet(self._parse_kwarg(), indent=4)) - self.parser_body(*parser_code) + def use_converters(self) -> None: + """Prepare for parsing all arguments by a single call. + + Such call leaves nowhere to put the code checking a particular + argument. + """ + for p in self.parameters: + if p.converter.alias_of is not None: + fail(f"Parameter {p.name!r} cannot be an alias: " + f"the arguments are not parsed one by one.") + if p.deprecated_until is not None: + fail(f"Parameter {p.name!r} cannot be deprecated: " + f"the arguments are not parsed one by one.") + p.converter.use_converter() + + def render_alias(self, p: Parameter, argname_fmt: str, + parsearg: str) -> str: + """Prepend the code checking that the alias is not in conflict. + + Only one of the alternative names can be used in a call. + """ + aliased = p.converter.alias_of + assert aliased is not None + i = self.parameters.index(aliased) + other = f"name ('{aliased.name}')" + arg = '' + if i < self.max_pos: + # The other name can be used for a positional argument too. + arg = f', {i} < nargs ? "position ({i + 1})" : "{other}"' + other = '%s' + return '\n'.join([ + libclinic.normalize_snippet(f""" + if ({argname_fmt % i}) {{{{ + PyErr_Format(PyExc_TypeError, + "argument for {self.func.name}() given by " + "name ('{p.name}') and {other}"{arg}); + goto exit; + }}}} + """), + libclinic.normalize_snippet(parsearg), + ]) + + def render_deprecated(self, p: Parameter, parsearg: str) -> str: + """Prepend the code warning that the parameter is going away.""" + assert p.deprecated_until is not None + major, minor = p.deprecated_until + aliased = p.converter.alias_of + instead = "" if aliased is None else f"Use {aliased.name!r} instead. " + message = (f"Passing the argument {p.name!r} to " + f"{self.func.fulldisplayname}() is deprecated. {instead}" + f"It will be removed in Python {major}.{minor}.") + code = [ + libclinic.normalize_snippet(""" + if (PyErr_WarnEx(PyExc_DeprecationWarning, + {}, 1)) + {{{{ + goto exit; + }}}} + """.format( + libclinic.wrapped_c_string_literal( + message, width=64, subsequent_indent=24))), + libclinic.normalize_snippet(parsearg), + ] + return '\n'.join(code) def parse_general(self, clang: CLanguage) -> None: - parsearg: str | None deprecated_positionals: dict[int, Parameter] = {} deprecated_keywords: dict[int, Parameter] = {} for i, p in enumerate(self.parameters): @@ -692,6 +1251,21 @@ def parse_general(self, clang: CLanguage) -> None: if has_optional_kw: self.declarations += "\nPy_ssize_t noptargs = %s + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - %d;" % (nargs, self.min_pos + self.min_kw_only) unpack_args = 'args, nargs, NULL, kwnames' + elif self.func.vectorcall: + # Emit parsing body as a helper that takes both vectorcall and + # fastcall calling conventions. + self.flags = "METH_VARARGS|METH_KEYWORDS" + self.parser_prototype = PARSER_PROTOTYPE_KEYWORD_HELPER + argsname = 'fastargs' + argname_fmt = 'fastargs[%d]' + self.declarations = declare_parser(self.func, codegen=self.codegen) + self.declarations += "\nPyObject *argsbuf[%s];" % (len(self.converters) or 1) + self.declarations += "\nPyObject * const *fastargs;" + if has_optional_kw: + self.declarations += ( + "\nPy_ssize_t noptargs = %s + nkw - %d;" + % (nargs, self.min_pos + self.min_kw_only)) + unpack_args = 'args, nargs, kwargs, kwnames' else: # positional-or-keyword arguments self.flags = "METH_VARARGS|METH_KEYWORDS" @@ -732,6 +1306,13 @@ def parse_general(self, clang: CLanguage) -> None: "parameter (after clang)") displayname = p.get_displayname(i+1) parsearg = p.converter.parse_arg(argname_fmt % i, displayname, limited_capi=self.limited_capi) + if parsearg is not None: + # The conflict is reported before warning about the + # deprecated name which caused it. + if p.deprecated_until is not None: + parsearg = self.render_deprecated(p, parsearg) + if p.converter.alias_of is not None: + parsearg = self.render_alias(p, argname_fmt, parsearg) if parsearg is None: parser_code = [] use_parser_code = False @@ -786,10 +1367,14 @@ def parse_general(self, clang: CLanguage) -> None: if add_label: parser_code.append("%s:" % add_label) if self.varpos: - parser_code.append(libclinic.normalize_snippet(self._parse_vararg(), indent=4)) + # The vectorcall helper gets an array of arguments, not a + # tuple: use the converters' fastcall convention, which + # handles that. + fastcall = True if self.func.vectorcall else self.fastcall + parser_code.append(libclinic.normalize_snippet( + self._parse_vararg(fastcall=fastcall), indent=4)) else: - for parameter in self.parameters: - parameter.converter.use_converter() + self.use_converters() self.declarations = declare_parser(self.func, codegen=self.codegen, hasformat=True) @@ -839,7 +1424,7 @@ def parse_general(self, clang: CLanguage) -> None: parser_code.insert(0, code) assert self.parser_prototype is not None - self.parser_body(*parser_code, declarations=self.declarations) + self.parser_body(*parser_code) def copy_includes(self) -> None: # Copy includes from parameters to Clinic after parse_arg() @@ -857,15 +1442,41 @@ def copy_includes(self) -> None: def handle_new_or_init(self) -> None: self.methoddef_define = '' - if self.func.kind is METHOD_NEW: - self.parser_prototype = PARSER_PROTOTYPE_KEYWORD + if self.func.kind is METHOD_INIT: + self.return_value_declaration = "int {parser_retval} = -1;" + + if self.parser_prototype == PARSER_PROTOTYPE_KEYWORD_HELPER: + self._new_or_init_delegate_to_helper() else: - self.return_value_declaration = "int return_value = -1;" - self.parser_prototype = PARSER_PROTOTYPE_KEYWORD___INIT__ + self._new_or_init_parser_body() + + def _new_or_init_delegate_to_helper(self) -> None: + """Change the parser to a helper that call and vectorcall can use. + + The parsing code is almost identical with slightly different args so + share the parser body as a {c_basename}_helper helper and the slot + entry point is a thin wrapper around it. + """ + self.parser_helper = self.parser_definition + self.parser_prototype = PARSER_PROTOTYPE_KEYWORD + self.parser_definition = '\n'.join([ + self.parser_prototype, + '{{', + ' return {c_basename}_helper({self_name}, ' + '_PyTuple_CAST(args)->ob_item,', + ' PyTuple_GET_SIZE(args),', + ' kwargs ? PyDict_GET_SIZE(kwargs) : 0,', + ' kwargs, NULL);', + '}}', + ]) + + def _new_or_init_parser_body(self) -> None: + """Rebuild the parser body with the checks tp_new / tp_init need.""" + self.parser_prototype = PARSER_PROTOTYPE_KEYWORD fields: list[str] = list(self.parser_body_fields) - parses_positional = 'METH_NOARGS' not in self.flags parses_keywords = 'METH_KEYWORDS' in self.flags + parses_positional = 'METH_NOARGS' not in self.flags if parses_keywords: assert parses_positional @@ -890,7 +1501,7 @@ def handle_new_or_init(self) -> None: }} """, indent=4)) - self.parser_body(*fields, declarations=self.declarations) + self.parser_body(*fields) def process_methoddef(self, clang: CLanguage) -> None: methoddef_cast_end = "" @@ -911,15 +1522,19 @@ def process_methoddef(self, clang: CLanguage) -> None: self.methoddef_define = self.methoddef_define.replace('{methoddef_cast}', methoddef_cast) self.methoddef_define = self.methoddef_define.replace('{methoddef_cast_end}', methoddef_cast_end) + # The entry of an attribute is composed when all its accessors are + # known (see render_properties). self.methoddef_ifndef = '' - conditional = clang.cpp.condition() + conditional = self.func.condition if not conditional: self.cpp_if = self.cpp_endif = '' else: self.cpp_if = "#if " + conditional self.cpp_endif = "#endif /* " + conditional + " */" - if self.methoddef_define and self.codegen.add_ifndef_symbol(self.func.full_name): + if (self.func.kind not in ACCESSORS + and self.methoddef_define + and self.codegen.add_ifndef_symbol(self.func.full_name)): self.methoddef_ifndef = METHODDEF_PROTOTYPE_IFNDEF def finalize(self, clang: CLanguage) -> None: @@ -936,6 +1551,9 @@ def finalize(self, clang: CLanguage) -> None: self.impl_prototype += ";" self.parser_definition = self.parser_definition.replace("{return_value_declaration}", self.return_value_declaration) + if self.parser_helper: + self.parser_helper = self.parser_helper.replace( + "{return_value_declaration}", self.return_value_declaration) compiler_warning = clang.compiler_deprecated_warning(self.func, self.parameters) if compiler_warning: @@ -949,10 +1567,12 @@ def create_template_dict(self) -> dict[str, str]: "methoddef_define" : self.methoddef_define, "parser_prototype" : self.parser_prototype, "parser_definition" : self.parser_definition, + "parser_helper" : self.parser_helper, "impl_definition" : self.impl_definition, "cpp_if" : self.cpp_if, "cpp_endif" : self.cpp_endif, "methoddef_ifndef" : self.methoddef_ifndef, + "vectorcall_definition" : self.vectorcall_definition, } # make sure we didn't forget to assign something, @@ -965,6 +1585,197 @@ def create_template_dict(self) -> dict[str, str]: d2[name] = value return d2 + def _vectorcall_type_check(self) -> list[str]: + """Check dispatch function hasn't changed. + + The generated code is only correct for a type whose tp_new / tp_init is + the parser this vectorcall shadows. + """ + func = self.func + if func.kind is METHOD_INIT: + check = f"_PyType_CAST(type)->tp_init == {func.c_basename}" + elif func.kind is METHOD_NEW: + check = f"_PyType_CAST(type)->tp_new == {func.c_basename}" + else: + raise AssertionError( + f"Unhandled function kind for vectorcall: {func.kind!r}" + ) + return [libclinic.normalize_snippet(f""" + assert({check}); + /* Make sure the type object is immutable: the generated + * vectorcall doesn't deal e.g. with users reassigning __init__. */ + assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE)); + """, indent=4)] + + def _vectorcall_positional(self, *, + arity_checked: bool = False) -> list[str]: + """Positional argument parsing for vectorcall. + + arity_checked: Already have a number of arguments check. + """ + pos_code = self._parse_positional_args( + argname_fmt='args[%d]', nargs='nargs', limited_capi=False, + fastcall=True) + # Converter support was validated when @vectorcall was parsed. + assert pos_code is not None + if arity_checked: + return pos_code + return [*self._check_positional('nargs'), *pos_code] + + def _assemble_vectorcall(self, preamble: str, fields: tuple[str, ...], + finale: str) -> None: + """Wrap parser code in the vectorcall prototype.""" + prototype = PARSER_PROTOTYPE_VECTORCALL.replace( + "{vc_basename}", self.func.c_basename_vectorcall) + lines = [prototype, preamble, *fields, finale] + + if self.func.kind is METHOD_INIT: + markers = VECTORCALL_FINALE_MARKERS_INIT + self.codegen.add_include('pycore_runtime.h', '_Py_SINGLETON()') + else: + markers = VECTORCALL_FINALE_MARKERS_NEW + code = libclinic.linear_format("\n".join(lines), **markers) + self.vectorcall_definition = code + + def vectorcall_body(self, *fields: str) -> None: + """Assemble a vectorcall function that parses inline and calls the impl. + + The preamble declares return_value and the per-arg locals, and the + finale calls {c_basename}_impl before running the exit/cleanup + block. + """ + preamble = libclinic.normalize_snippet(""" + {{ + PyObject *return_value = NULL; + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + {init_declarations} + {declarations} + {initializers} + """) + "\n" + self._assemble_vectorcall(preamble, fields, PARSER_FINALE_SKELETON) + + def parse_vectorcall_pos_only(self) -> None: + """All positional sometimes optional arguments.""" + parser_code = self._vectorcall_type_check() + self.codegen.add_include('pycore_modsupport.h', + '_PyArg_NoKwnames()') + parser_code.append(libclinic.normalize_snippet(""" + if (!_PyArg_NoKwnames("{name}", kwnames)) {{ + goto exit; + }} + """, indent=4)) + + parser_code.extend(self._vectorcall_positional()) + self.vectorcall_body(*parser_code) + + def _vectorcall_guarded_delegate(self, condition: str, nkw: str) -> str: + """Emit `if (condition) { }`.""" + return libclinic.linear_format( + libclinic.normalize_snippet(f""" + if ({condition}) {{{{ + {{delegate}} + }}}} + """, indent=4), + delegate=self._vectorcall_delegate_to_helper(nkw)) + + def _vectorcall_delegate_to_helper(self, nkw: str) -> str: + """Hand off to the {c_basename}_helper helper and return. + + nkw: Number of keyword arguments. + """ + if self.func.kind is METHOD_INIT: + receiver = "self" + bind_result = "_result = " + prologue = libclinic.normalize_snippet(""" + self = _PyType_CAST(type)->tp_new(_PyType_CAST(type), + (PyObject *)&_Py_SINGLETON(tuple_empty), NULL); + if (self == NULL) {{ + return NULL; + }} + """, indent=4) + epilogue = libclinic.normalize_snippet(""" + if (_result != 0) {{ + Py_DECREF(self); + return NULL; + }} + return self; + """, indent=4) + else: + receiver = "_PyType_CAST(type)" + bind_result = "return " + prologue = epilogue = "" + helper_call = libclinic.normalize_snippet(f""" + {bind_result}{{c_basename}}_helper({receiver}, args, nargs, + {nkw}, + NULL, kwnames); + """, indent=4) + parts = [prologue, helper_call, epilogue] + return "\n".join(part for part in parts if part) + + def parse_vectorcall_kw_required(self) -> None: + """Required keyword arguemnts; always delegate to helper.""" + parser_code = self._vectorcall_type_check() + parser_code.append(self._vectorcall_delegate_to_helper( + 'kwnames ? PyTuple_GET_SIZE(kwnames) : 0')) + preamble = libclinic.normalize_snippet(""" + {{ + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + {init_declarations} + """) + "\n" + self._assemble_vectorcall(preamble, tuple(parser_code), "}}") + + def parse_vectorcall_pos_or_kw(self) -> None: + """Optional positional and keyword argument vectorcall. + + Delegate to the helper if keywords present or if position count is out + of range. Position count so the error messages match the non-vectorcall. + """ + assert not self.varpos + checks = ['kwnames != NULL'] + if self.min_pos: + checks.append(f"nargs < {self.min_pos}") + checks.append(f"nargs > {self.max_pos}") + + parser_code = self._vectorcall_type_check() + parser_code.append(self._vectorcall_guarded_delegate( + " || ".join(checks), 'kwnames ? PyTuple_GET_SIZE(kwnames) : 0')) + parser_code.extend(self._vectorcall_positional(arity_checked=True)) + self.vectorcall_body(*parser_code) + + def parse_vectorcall_no_args(self) -> None: + """No keyword or positional arguments.""" + parser_code = self._vectorcall_type_check() + self.codegen.add_include('pycore_modsupport.h', + '_PyArg_NoPositionalStack()') + parser_code.append(libclinic.normalize_snippet(""" + if (!_PyArg_NoPositionalStack("{name}", nargs) || + !_PyArg_NoKwnames("{name}", kwnames)) {{ + goto exit; + }} + """, indent=4)) + self.vectorcall_body(*parser_code) + + def parse_vectorcall(self) -> None: + """Generate the vectorcall entry point for __new__ / __init__. + + Dispatch to specific parser-code builders based on parameter shape. + """ + # Branches ordered to mirror parse_args(). The DSL parser rejects + # @vectorcall with optional groups, and METH_O never applies to + # __new__/__init__. + assert not self.has_option_groups() + assert not self.use_meth_o() + if not self.parameters and not self.varpos and not self.var_keyword: + self.parse_vectorcall_no_args() + elif self.var_keyword is not None: + self.parse_var_keyword(vectorcall=True) + elif self.pos_only == len(self.parameters): + self.parse_vectorcall_pos_only() + elif any(p.is_keyword_only() for p in self.parameters) or self.varpos: + self.parse_vectorcall_kw_required() + else: + self.parse_vectorcall_pos_or_kw() + def parse_args(self, clang: CLanguage) -> dict[str, str]: self.select_prototypes() self.init_limited_capi() @@ -973,14 +1784,20 @@ def parse_args(self, clang: CLanguage) -> dict[str, str]: self.declarations = "" self.parser_prototype = "" self.parser_definition = "" + self.parser_helper = "" self.impl_prototype = None self.impl_definition = IMPL_DEFINITION_PROTOTYPE + self.vectorcall_definition = "" # parser_body_fields remembers the fields passed in to the # previous call to parser_body. this is used for an awful hack. self.parser_body_fields: tuple[str, ...] = () - if not self.parameters and not self.varpos and not self.var_keyword: + if self.func.kind is SLOT: + self.parse_slot() + elif self.func.kind in ACCESSORS: + self.parse_accessor() + elif not self.parameters and not self.varpos and not self.var_keyword: self.parse_no_args() elif self.use_meth_o(): self.parse_one_arg() @@ -988,8 +1805,9 @@ def parse_args(self, clang: CLanguage) -> dict[str, str]: self.parse_option_groups() elif self.var_keyword is not None: self.parse_var_keyword() - elif (not self.requires_defining_class - and self.pos_only == len(self.parameters)): + elif (self.pos_only == len(self.parameters) + and (not self.requires_defining_class + or (self.fastcall and not self.limited_capi))): self.parse_pos_only() else: self.parse_general(clang) @@ -1000,4 +1818,8 @@ def parse_args(self, clang: CLanguage) -> dict[str, str]: self.process_methoddef(clang) self.finalize(clang) + # Generate vectorcall function if requested + if self.func.vectorcall: + self.parse_vectorcall() + return self.create_template_dict() diff --git a/Tools/clinic/libclinic/return_converters.py b/Tools/clinic/libclinic/return_converters.py index b41e053bae5f3a7..6747f85e63f8585 100644 --- a/Tools/clinic/libclinic/return_converters.py +++ b/Tools/clinic/libclinic/return_converters.py @@ -110,7 +110,8 @@ def render(self, function: Function, data: CRenderData) -> None: self.declare(data) self.err_occurred_if(f"{data.converter_retval} == -1", data) data.return_conversion.append( - f'return_value = PyBool_FromLong((long){data.converter_retval});\n' + f'{data.parser_retval} = ' + f'PyBool_FromLong((long){data.converter_retval});\n' ) @@ -124,7 +125,8 @@ def render(self, function: Function, data: CRenderData) -> None: self.declare(data) self.err_occurred_if(f"{data.converter_retval} == {self.unsigned_cast}-1", data) data.return_conversion.append( - f'return_value = {self.conversion_fn}({self.cast}{data.converter_retval});\n' + f'{data.parser_retval} = ' + f'{self.conversion_fn}({self.cast}{data.converter_retval});\n' ) @@ -150,6 +152,12 @@ class Py_ssize_t_return_converter(long_return_converter): conversion_fn = 'PyLong_FromSsize_t' +class Py_hash_t_return_converter(long_return_converter): + type = 'Py_hash_t' + conversion_fn = 'PyLong_FromSsize_t' + cast = '(Py_ssize_t)' + + class size_t_return_converter(long_return_converter): type = 'size_t' conversion_fn = 'PyLong_FromSize_t' @@ -164,7 +172,8 @@ def render(self, function: Function, data: CRenderData) -> None: self.declare(data) self.err_occurred_if(f"{data.converter_retval} == -1.0", data) data.return_conversion.append( - f'return_value = PyFloat_FromDouble({self.cast}{data.converter_retval});\n' + f'{data.parser_retval} = ' + f'PyFloat_FromDouble({self.cast}{data.converter_retval});\n' ) diff --git a/Tools/clinic/libclinic/slots.py b/Tools/clinic/libclinic/slots.py new file mode 100644 index 000000000000000..5b8c2ed9faf484e --- /dev/null +++ b/Tools/clinic/libclinic/slots.py @@ -0,0 +1,54 @@ +"""Type slots ("tp slots") for which Argument Clinic generates the slot function. + +A slot function does not parse arguments: Argument Clinic generates a thin +wrapper with the C signature of the slot, which forwards its arguments to +the implementation function. The wrapper is the place where +``@critical_section`` acquires the lock. + +The parameters declared in the DSL only give the C signature of the slot; +they must be positional-only, without a default value. +""" +from __future__ import annotations +import dataclasses as dc +from typing import Final + +from libclinic.return_converters import CReturnConverter, return_converters + + +@dc.dataclass(frozen=True, slots=True, kw_only=True) +class SlotSpec: + # The name of the return converter of the implementation function, + # which declares the C return type of the slot function. + return_converter: str + + @property + def return_type(self) -> str: + """The C return type of the slot function.""" + return self.make_return_converter().type + + @property + def error_value(self) -> str: + """The value returned by the slot function on error.""" + return 'NULL' if self.return_type.endswith('*') else '-1' + + def make_return_converter(self) -> CReturnConverter: + return return_converters[self.return_converter]() + + +# Maps the name of a special method to its slot. A name listed here must +# not be in dsl_parser.unsupported_special_methods. +SLOTS: Final[dict[str, SlotSpec]] = { + '__add__': SlotSpec(return_converter='object'), + '__bool__': SlotSpec(return_converter='int'), + '__contains__': SlotSpec(return_converter='int'), + '__getitem__': SlotSpec(return_converter='object'), + '__hash__': SlotSpec(return_converter='Py_hash_t'), + '__iadd__': SlotSpec(return_converter='object'), + '__imul__': SlotSpec(return_converter='object'), + '__len__': SlotSpec(return_converter='Py_ssize_t'), + '__mul__': SlotSpec(return_converter='object'), + '__next__': SlotSpec(return_converter='object'), + '__repr__': SlotSpec(return_converter='object'), + '__setitem__': SlotSpec(return_converter='int'), + '__str__': SlotSpec(return_converter='object'), +} diff --git a/Tools/clinic/libclinic/utils.py b/Tools/clinic/libclinic/utils.py index 3df64f270dd074a..01015ff1237656b 100644 --- a/Tools/clinic/libclinic/utils.py +++ b/Tools/clinic/libclinic/utils.py @@ -1,23 +1,31 @@ import collections +import dataclasses as dc import enum import hashlib import os import re import string +from collections.abc import Iterable from typing import Literal, Final -def write_file(filename: str, new_contents: str) -> None: - """Write new content to file, iff the content changed.""" +def read_file(filename: str) -> str | None: + """Return the content of the file, or None if it does not exist.""" try: with open(filename, encoding="utf-8") as fp: - old_contents = fp.read() - - if old_contents == new_contents: - # no change: avoid modifying the file modification time - return + return fp.read() except FileNotFoundError: - pass + return None + + +def write_file(filename: str, new_contents: str) -> bool: + """Write new content to file, iff the content changed. + + Return True if the file was written. + """ + if read_file(filename) == new_contents: + # no change: avoid modifying the file modification time + return False # Atomic write using a temporary file and os.replace() filename_new = f"{filename}.new" with open(filename_new, "w", encoding="utf-8") as fp: @@ -27,6 +35,67 @@ def write_file(filename: str, new_contents: str) -> None: except: os.unlink(filename_new) raise + return True + + +@dc.dataclass(slots=True, frozen=True) +class FileChange: + filename: str + # None if the file does not exist yet. + old_contents: str | None + new_contents: str + + +@dc.dataclass(slots=True) +class FileWriter: + """Write the generated files. + + In the dry run mode no file is written, the changes are only recorded. + """ + + dry_run: bool = False + changes: list[FileChange] = dc.field(default_factory=list) + # (filename, changed) for every file which was passed to write(). + files: list[tuple[str, bool]] = dc.field(default_factory=list) + + def makedirs(self, dirname: str) -> None: + if not self.dry_run: + os.makedirs(dirname) + elif os.path.exists(dirname): + # Create nothing, but fail as os.makedirs() does, so that + # the caller can report an existing non-directory. + raise FileExistsError(dirname) + + def write(self, filename: str, new_contents: str) -> None: + if not self.dry_run: + changed = write_file(filename, new_contents) + else: + old_contents = read_file(filename) + changed = old_contents != new_contents + if changed: + self.changes.append( + FileChange(filename, old_contents, new_contents)) + self.files.append((filename, changed)) + + def update_times(self, source: str, generated: Iterable[str], + changed: bool) -> None: + """Keep the generated files newer than the source file. + + The build system does not know that the source file depends on + the files generated from it, so the source file is touched to + force its recompilation. + """ + if self.dry_run: + return + if changed: + os.utime(source) + for filename in generated: + os.utime(filename) + else: + mtime = os.stat(source).st_mtime_ns + for filename in generated: + if os.stat(filename).st_mtime_ns <= mtime: + os.utime(filename) def compute_checksum(input_: str, length: int | None = None) -> str: diff --git a/Tools/freeze/test/freeze.py b/Tools/freeze/test/freeze.py index 1e3687dbb807a69..f4330076f225b52 100644 --- a/Tools/freeze/test/freeze.py +++ b/Tools/freeze/test/freeze.py @@ -64,6 +64,16 @@ def find_opt(args, name): return -1 +def remove_opt(args: list[str], name: str) -> None: + opt = f'--{name}' + optstart = f'{opt}=' + args[:] = [ + arg + for arg in args + if arg != opt and not arg.startswith(optstart) + ] + + def ensure_opt(args, name, value): opt = f'--{name}' pos = find_opt(args, name) @@ -128,6 +138,10 @@ def prepare(script=None, outdir=None): # Run configure. print(f'configuring python in {builddir}...') config_args = shlex.split(sysconfig.get_config_var('CONFIG_ARGS') or '') + # Optimisations such as LTO and PGO only slow down the build of this + # throwaway interpreter without affecting what the test checks. + remove_opt(config_args, 'enable-optimizations') + remove_opt(config_args, 'with-lto') cmd = [os.path.join(srcdir, 'configure'), *config_args] ensure_opt(cmd, 'cache-file', os.path.join(outdir, 'python-config.cache')) prefix = os.path.join(outdir, 'python-installation') diff --git a/Tools/ftscalingbench/ftscalingbench.py b/Tools/ftscalingbench/ftscalingbench.py index c8a914c22a9e137..a79242e740371ba 100644 --- a/Tools/ftscalingbench/ftscalingbench.py +++ b/Tools/ftscalingbench/ftscalingbench.py @@ -325,6 +325,19 @@ def enum_attr(): MyEnum.Y MyEnum.Z +_MCACHE_NUM_TYPES = 1 << 14 +_MCACHE_PAIRS = [ + (type(f"C{i}", (), {f"m{i}": i % 256})(), sys.intern(f"m{i}")) + for i in range(_MCACHE_NUM_TYPES) +] + +@register_benchmark +def type_lookup(): + pairs = _MCACHE_PAIRS + for _ in range(WORK_SCALE // 10): + for inst, name in pairs: + getattr(inst, name) + def bench_one_thread(func): t0 = time.perf_counter_ns() diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py index ba52ea2a30e0be1..a7f89442dd21dba 100755 --- a/Tools/gdb/libpython.py +++ b/Tools/gdb/libpython.py @@ -43,10 +43,12 @@ import gdb import os -import locale import sys +MAX_UNICODE = 0x10_ffff + + # Look up the gdb.Type for some standard types: # Those need to be refreshed as types (pointer sizes) may change when # gdb loads different executables @@ -107,8 +109,6 @@ def interp_frame_has_tlbc_index(): USED_TAGS = 0b11 -ENCODING = locale.getpreferredencoding() - FRAME_INFO_OPTIMIZED_OUT = '(frame information optimized out)' UNABLE_READ_INFO_PYTHON_FRAME = 'Unable to read information on python frame' EVALFRAME = '_PyEval_EvalFrameDefault' @@ -1381,11 +1381,15 @@ def write_repr(self, out, visited): class PyBytesObjectPtr(PyObjectPtr): _typename = 'PyBytesObject' - def __str__(self): + def get_bytes(self): field_ob_size = self.field('ob_size') field_ob_sval = self.field('ob_sval') char_ptr = field_ob_sval.address.cast(_type_unsigned_char_ptr()) - return ''.join([chr(char_ptr[i]) for i in safe_range(field_ob_size)]) + return [char_ptr[i] for i in safe_range(field_ob_size)] + + def __str__(self): + as_bytes = self.get_bytes() + return ''.join([chr(byte) for byte in as_bytes]) def proxyval(self, visited): return str(self) @@ -1393,17 +1397,17 @@ def proxyval(self, visited): def write_repr(self, out, visited): # Write this out as a Python bytes literal, i.e. with a "b" prefix - # Get a PyStringObject* within the Python gdb process: - proxy = self.proxyval(visited) + as_bytes = self.get_bytes() # Transliteration of Python's Objects/bytesobject.c:PyBytes_Repr # to Python code: quote = "'" - if "'" in proxy and not '"' in proxy: + if ord("'") in as_bytes and ord('"') not in as_bytes: quote = '"' out.write('b') out.write(quote) - for byte in proxy: + for value in as_bytes: + byte = chr(value) if byte == quote or byte == '\\': out.write('\\') out.write(byte) @@ -1413,10 +1417,10 @@ def write_repr(self, out, visited): out.write('\\n') elif byte == '\r': out.write('\\r') - elif byte < ' ' or ord(byte) >= 0x7f: + elif value < ord(' ') or value >= 0x7f: out.write('\\x') - out.write(hexdigits[(ord(byte) & 0xf0) >> 4]) - out.write(hexdigits[ord(byte) & 0xf]) + out.write(hexdigits[(value & 0xf0) >> 4]) + out.write(hexdigits[value & 0xf]) else: out.write(byte) out.write(quote) @@ -1469,10 +1473,17 @@ def _unichr_is_printable(char): return unicodedata.category(char) not in ("C", "Z") +def safe_chr(i): + if i <= MAX_UNICODE: + return chr(i) + else: + return f'\\U{i:08x}' + + class PyUnicodeObjectPtr(PyObjectPtr): _typename = 'PyUnicodeObject' - def proxyval(self, visited): + def get_code_points(self): compact = self.field('_base') ascii = compact['_base'] state = ascii['state'] @@ -1494,31 +1505,35 @@ def proxyval(self, visited): # Gather a list of ints from the code point array; these are either # UCS-1, UCS-2 or UCS-4 code points: - code_points = [int(field_str[i]) for i in safe_range(field_length)] + return [int(field_str[i]) for i in safe_range(field_length)] + def proxyval(self, visited): + code_points = self.get_code_points() # Convert the int code points to unicode characters, and generate a # local unicode instance. - result = ''.join(map(chr, code_points)) + result = ''.join(map(safe_chr, code_points)) return result def write_repr(self, out, visited): # Write this out as a Python str literal + # gdb writes its output in the host charset, so a character is escaped + # unless it is printable and encodable in that charset. + encoding = gdb.host_charset() + # Get a PyUnicodeObject* within the Python gdb process: - proxy = self.proxyval(visited) + code_points = self.get_code_points() # Transliteration of Python's Object/unicodeobject.c:unicode_repr # to Python: - if "'" in proxy and '"' not in proxy: + if ord("'") in code_points and ord('"') not in code_points: quote = '"' else: quote = "'" out.write(quote) - i = 0 - while i < len(proxy): - ch = proxy[i] - i += 1 + for code_point in code_points: + ch = safe_chr(code_point) # Escape quotes and backslashes if ch == quote or ch == '\\': @@ -1534,38 +1549,33 @@ def write_repr(self, out, visited): out.write('\\r') # Map non-printable US ASCII to '\xhh' */ - elif ch < ' ' or ord(ch) == 0x7F: + elif ch < ' ' or code_point == 0x7F: out.write('\\x') - out.write(hexdigits[(ord(ch) >> 4) & 0x000F]) - out.write(hexdigits[ord(ch) & 0x000F]) + out.write(hexdigits[(code_point >> 4) & 0x000F]) + out.write(hexdigits[code_point & 0x000F]) # Copy ASCII characters as-is - elif ord(ch) < 0x7F: + elif code_point < 0x7F: out.write(ch) # Non-ASCII characters else: - ucs = ch - ch2 = None - - printable = ucs.isprintable() + if code_point <= MAX_UNICODE: + printable = ch.isprintable() + else: + printable = False if printable: try: - ucs.encode(ENCODING) - except UnicodeEncodeError: + ch.encode(encoding) + # LookupError or ValueError if the host charset is unknown + # or invalid. + except (UnicodeEncodeError, LookupError, ValueError): printable = False # Map Unicode whitespace and control characters # (categories Z* and C* except ASCII space) if not printable: - if ch2 is not None: - # Match Python's representation of non-printable - # wide characters. - code = (ord(ch) & 0x03FF) << 10 - code |= ord(ch2) & 0x03FF - code += 0x00010000 - else: - code = ord(ucs) + code = code_point # Map 8-bit characters to '\\xhh' if code <= 0xff: @@ -1593,8 +1603,6 @@ def write_repr(self, out, visited): else: # Copy characters as-is out.write(ch) - if ch2 is not None: - out.write(ch2) out.write(quote) diff --git a/Tools/i18n/msgfmt.py b/Tools/i18n/msgfmt.py index 3351511bbc8f2b7..0ca61a0af9e35a1 100755 --- a/Tools/i18n/msgfmt.py +++ b/Tools/i18n/msgfmt.py @@ -59,21 +59,39 @@ def add(ctxt, id, str, fuzzy): def generate(): "Return the generated output." global MESSAGES + + # The hash table uses open addressing with double hashing, as in GNU + # gettext's write-mo.c: the first probe is V % M and each following probe + # adds 1 + V % (M - 2), where V is the hash of the string and M is the + # table size. M is the smallest prime greater than 4/3 * N (N being the + # number of strings), which keeps the expected number of probes small. + # See Knuth, The Art of Computer Programming, Volume 3, section 6.4. + hash_tab_size = _next_prime((len(MESSAGES) * 4) // 3) + if hash_tab_size <= 2: + hash_tab_size = 3 + hash_table = array.array("I", [0] * hash_tab_size) + # the keys are sorted in the .mo file keys = sorted(MESSAGES.keys()) offsets = [] ids = strs = b'' - for id in keys: + for i, id in enumerate(keys): + hash_val = _hashpjw(id) + idx = hash_val % hash_tab_size + inc = 1 + (hash_val % (hash_tab_size - 2)) + while hash_table[idx]: + idx = (idx + inc) % hash_tab_size + hash_table[idx] = i + 1 # For each string, we need size and file offset. Each string is NUL # terminated; the NUL does not count into the size. offsets.append((len(ids), len(id), len(strs), len(MESSAGES[id]))) ids += id + b'\0' strs += MESSAGES[id] + b'\0' - output = '' - # The header is 7 32-bit unsigned integers. We don't use hash tables, so - # the keys start right after the index tables. - # translated string. - keystart = 7*4+16*len(keys) + + # The header is 7 32-bit unsigned integers, followed by the index tables, + # then the hash table, then the keys. + hashstart = 7*4+16*len(keys) + keystart = hashstart+hash_tab_size*4 # and the values start after the keys valuestart = keystart + len(ids) koffsets = [] @@ -85,13 +103,15 @@ def generate(): voffsets += [l2, o2+valuestart] offsets = koffsets + voffsets output = struct.pack("Iiiiiii", - 0x950412de, # Magic + 0x950412de, # Magic 0, # Version len(keys), # # of entries 7*4, # start of key index 7*4+len(keys)*8, # start of value index - 0, 0) # size and offset of hash table + hash_tab_size, # size of hash table + hashstart) # offset of hash table output += array.array("i", offsets).tobytes() + output += hash_table.tobytes() output += ids output += strs return output @@ -257,5 +277,39 @@ def main(): make(filename, outfile) +# Utilities for writing hash table + +# Peter J. Weinberger hash function +# See: https://www.drdobbs.com/database/hashing-rehashed/184409859 +def _hashpjw(strs): + hval = 0 + for s in strs: + if not s: + break + hval <<= 4 + hval += s + g = hval & (0xF << 28) + if g: + hval ^= g >> 24 + hval ^= g + return hval & 0xFFFFFFFF + + +def _next_prime(start): + def is_prime(num): + divn = 3 + sq = divn * divn + while sq < num and num % divn != 0: + divn += 1 + sq += 4 * divn + divn += 1 + + return num % divn != 0 + + candidate = start | 1 + while not is_prime(candidate): + candidate += 2 + return candidate + if __name__ == '__main__': main() diff --git a/Tools/i18n/pygettext.py b/Tools/i18n/pygettext.py index ddf4474d2bce55f..9d0fc184b84eca9 100755 --- a/Tools/i18n/pygettext.py +++ b/Tools/i18n/pygettext.py @@ -124,6 +124,15 @@ --width=columns Set width of output to columns. + --omit-header + Do not write header to file. + + This is useful for testing purposes because it eliminates a source of + variance for generated .mo files. + + Note: Using this option may lead to an error during compilation or other + manipulation if the resulting file is not entirely in ASCII. + -x filename --exclude-file=filename Specify a file that contains a list of strings that are not be @@ -629,9 +638,11 @@ def _is_string_const(self, node): def write_pot_file(messages, options, fp): timestamp = time.strftime('%Y-%m-%d %H:%M%z') encoding = fp.encoding if fp.encoding else 'UTF-8' - print(pot_header % {'time': timestamp, 'version': __version__, - 'charset': encoding, - 'encoding': '8bit'}, file=fp) + + if not options.omit_header: + print(pot_header % {'time': timestamp, 'version': __version__, + 'charset': encoding, + 'encoding': '8bit'}, file=fp) # Sort locations within each message by filename and lineno sorted_keys = [ @@ -691,7 +702,7 @@ def main(): ['extract-all', 'add-comments=?', 'default-domain=', 'escape', 'help', 'keyword=', 'no-default-keywords', 'add-location', 'no-location', 'output=', 'output-dir=', - 'style=', 'verbose', 'version', 'width=', 'exclude-file=', + 'style=', 'verbose', 'version', 'width=', 'omit-header', 'exclude-file=', 'docstrings', 'no-docstrings', ]) except getopt.error as msg: @@ -712,6 +723,7 @@ class Options: locationstyle = GNU verbose = 0 width = 78 + omit_header = False excludefilename = '' docstrings = 0 nodocstrings = {} @@ -764,6 +776,8 @@ class Options: options.width = int(arg) except ValueError: usage(1, f'--width argument must be an integer: {arg}') + elif opt in ('--omit-header',): + options.omit_header = True elif opt in ('-x', '--exclude-file'): options.excludefilename = arg elif opt in ('-X', '--no-docstrings'): diff --git a/Tools/inspection/benchmark_external_inspection.py b/Tools/inspection/benchmark_external_inspection.py index b7aa0e5de7ed99b..5c491e3cfc6211c 100644 --- a/Tools/inspection/benchmark_external_inspection.py +++ b/Tools/inspection/benchmark_external_inspection.py @@ -7,206 +7,8 @@ import argparse from _colorize import get_colors, can_colorize -CODE = '''\ -import time -import os -import sys -import math - -def slow_fibonacci(n): - """Intentionally slow recursive fibonacci - should show up prominently in profiler""" - if n <= 1: - return n - return slow_fibonacci(n-1) + slow_fibonacci(n-2) - -def medium_computation(): - """Medium complexity function""" - result = 0 - for i in range(1000): - result += math.sqrt(i) * math.sin(i) - return result - -def fast_loop(): - """Fast simple loop""" - total = 0 - for i in range(100): - total += i - return total - -def string_operations(): - """String manipulation that should be visible in profiler""" - text = "hello world " * 100 - words = text.split() - return " ".join(reversed(words)) - -def nested_calls(): - """Nested function calls to test call stack depth""" - def level1(): - def level2(): - def level3(): - return medium_computation() - return level3() - return level2() - return level1() - -def main_loop(): - """Main computation loop with different execution paths""" - iteration = 0 - - while True: - iteration += 1 - - # Different execution paths with different frequencies - if iteration % 50 == 0: - # Expensive operation - should show high per-call time - result = slow_fibonacci(20) - - elif iteration % 10 == 0: - # Medium operation - result = nested_calls() - - elif iteration % 5 == 0: - # String operations - result = string_operations() - - else: - # Fast operation - most common - result = fast_loop() - - # Small delay to make sampling more interesting - time.sleep(0.001) - -if __name__ == "__main__": - main_loop() -''' - -DEEP_STATIC_CODE = """\ -import time -def factorial(n): - if n <= 1: - time.sleep(10000) - return 1 - return n * factorial(n-1) - -factorial(900) -""" +from snippets import CODE_EXAMPLES, CODE -CODE_WITH_TONS_OF_THREADS = '''\ -import time -import threading -import random -import math - -def cpu_intensive_work(): - """Do some CPU intensive calculations""" - result = 0 - for _ in range(10000): - result += math.sin(random.random()) * math.cos(random.random()) - return result - -def io_intensive_work(): - """Simulate IO intensive work with sleeps""" - time.sleep(0.1) - -def mixed_workload(): - """Mix of CPU and IO work""" - while True: - if random.random() < 0.3: - cpu_intensive_work() - else: - io_intensive_work() - -def create_threads(n): - """Create n threads doing mixed workloads""" - threads = [] - for _ in range(n): - t = threading.Thread(target=mixed_workload, daemon=True) - t.start() - threads.append(t) - return threads - -# Start with 5 threads -active_threads = create_threads(5) -thread_count = 5 - -# Main thread manages threads and does work -while True: - # Randomly add or remove threads - if random.random() < 0.1: # 10% chance each iteration - if random.random() < 0.5 and thread_count < 100: - # Add 1-5 new threads - new_count = random.randint(1, 5) - new_threads = create_threads(new_count) - active_threads.extend(new_threads) - thread_count += new_count - elif thread_count > 10: - # Remove 1-3 threads - remove_count = random.randint(1, 5) - # The threads will terminate naturally since they're daemons - active_threads = active_threads[remove_count:] - thread_count -= remove_count - - cpu_intensive_work() - time.sleep(0.05) -''' - -ASYNC_CODE = '''\ -import asyncio -import contextlib -import math - -def compute_slice(seed): - result = 0.0 - for i in range(2000): - result += math.sin(seed + i) * math.sqrt(i + 1) - return result - -async def leaf_task(seed): - total = 0.0 - while True: - total += compute_slice(seed) - await asyncio.sleep(0) - -async def parent_task(seed): - child = asyncio.create_task(leaf_task(seed + 1000), name=f"leaf-{seed}") - try: - while True: - compute_slice(seed) - await asyncio.sleep(0.001) - finally: - child.cancel() - with contextlib.suppress(asyncio.CancelledError): - await child - -async def main(): - tasks = [ - asyncio.create_task(parent_task(i), name=f"parent-{i}") - for i in range(8) - ] - await asyncio.gather(*tasks) - -if __name__ == "__main__": - asyncio.run(main()) -''' - -CODE_EXAMPLES = { - "basic": { - "code": CODE, - "description": "Mixed workload with fibonacci, computations, and string operations", - }, - "deep_static": { - "code": DEEP_STATIC_CODE, - "description": "Deep recursive call stack with 900+ frames (factorial)", - }, - "threads": { - "code": CODE_WITH_TONS_OF_THREADS, - "description": "Tons of threads doing mixed CPU/IO work", - }, - "asyncio": { - "code": ASYNC_CODE, - "description": "Asyncio tasks with active and awaited coroutine chains", - }, -} OPERATIONS = { "stack_trace": { diff --git a/Tools/inspection/oracle_external_inspection.py b/Tools/inspection/oracle_external_inspection.py new file mode 100644 index 000000000000000..ec5060a1c9a4a51 --- /dev/null +++ b/Tools/inspection/oracle_external_inspection.py @@ -0,0 +1,436 @@ +"""Compare external inspection modes against a reference mode ("Oracle"). + +This script reports the following validation metrics: + +- impossible: Number of stacks matching a known impossible pattern. The + classifiers are not exhaustive. + +- raw_tvd: Total variation distance between this mode's stack distribution + and the reference's distribution. Stacks classified as impossible are + excluded. + +- tvd_excess: raw_tvd minus tvd_floor. + +- tvd_floor: IID heuristic for the TVD expected from finite sampling of both + distributions. This is not a lower bound. +""" + +import argparse +import contextlib +import math +import os +import random +import subprocess +import statistics +import sys +import tempfile +import time +from collections import Counter + +import _remote_debugging + +from snippets import CASES, _get_lineno + + +TRANSIENT_ERRORS = (OSError, RuntimeError, UnicodeDecodeError) + +MODES = { + "live-cache": (False, True), + "live-nocache": (False, False), + "blocking-cache": (True, True), + "blocking-nocache": (True, False), +} + + +def collapse_cache(mode): + blocking, _ = MODES[mode] + return "blocking-nocache" if blocking else "live-nocache" + + +def tvd(left, right): + lt, rt = sum(left.values()), sum(right.values()) + if not lt or not rt: + return None + return 0.5 * sum( + abs(left[k] / lt - right[k] / rt) for k in set(left) | set(right) + ) + + +def tvd_floor(reference_obs, n_live): + n_ref = sum(reference_obs.values()) + if not n_ref or not n_live: + return None + spread = sum( + math.sqrt(p * (1 - p)) + for p in (c / n_ref for c in reference_obs.values()) + ) + return ( + 0.5 + * math.sqrt(2 / math.pi) + * math.sqrt(1 / n_live + 1 / n_ref) + * spread + ) + + +def print_run_info(args, cases): + print(sys.version.replace("\n", " ")) + print( + f"cases={','.join(cases)} runs={args.runs} " + f"duration={args.duration} " + f"rate_khz={args.rate_khz} warmup={args.warmup} " + f"poisson_sampling={args.poisson_sampling}" + ) + + +def terminate_process(proc): + if proc.poll() is not None: + return + proc.terminate() + try: + proc.wait(timeout=5) + except subprocess.TimeoutExpired: + proc.kill() + proc.wait() + + +@contextlib.contextmanager +def target_process(code, warmup): + with tempfile.NamedTemporaryFile("w", suffix=".py", delete=False) as tmp: + tmp.write(code) + tmp.flush() + tmp_name = tmp.name + proc = None + try: + proc = subprocess.Popen( + [sys.executable, tmp_name], + stdout=subprocess.DEVNULL, + ) + time.sleep(warmup) + if proc.poll() is not None: + raise RuntimeError( + f"target exited unexpectedly with code {proc.returncode}" + ) + yield proc + finally: + with contextlib.suppress(Exception): + if proc is not None: + terminate_process(proc) + with contextlib.suppress(OSError): + os.unlink(tmp_name) + + +def get_trace(unwinder, blocking, op="get_stack_trace"): + call = getattr(unwinder, op) + if not blocking: + return call() + unwinder.pause_threads() + try: + return call() + finally: + unwinder.resume_threads() + + +def iter_units(raw, op): + if op == "get_stack_trace": + for interp in raw: + for thread in interp.threads: + yield ( + thread.thread_id, + None, + thread.status, + thread.frame_info, + ) + else: + for awaited_info in raw: + for task in awaited_info.awaited_by: + frames = [ + frame + for coro in task.coroutine_stack + for frame in coro.call_stack + ] + if frames: + yield (task.task_id, task.task_name, None, frames) + + +def run_mode(case, mode_name, args): + code, classify, *rest = case + op = rest[0] if rest else "get_stack_trace" + classify_units = op != "get_stack_trace" + blocking, cache_frames = MODES[mode_name] + result = { + "attempts": 0, + "samples": 0, + "stacks": 0, + "errors": 0, + "observations": Counter(), + "impossible": 0, + "work_time": 0.0, + } + with target_process(code, args.warmup) as proc: + unwinder = _remote_debugging.RemoteUnwinder( + proc.pid, + all_threads=True, + cache_frames=cache_frames, + ) + rate_hz = args.rate_khz * 1000 + period = 1.0 / rate_hz if rate_hz else 0 + next_sample = time.perf_counter() + deadline = next_sample + args.duration + + while time.perf_counter() < deadline: + if period: + if args.poisson_sampling: + next_sample += random.expovariate(rate_hz) + if next_sample >= deadline: + break + now = time.perf_counter() + if next_sample > now: + time.sleep(next_sample - now) + if not args.poisson_sampling: + next_sample += period + + if time.perf_counter() >= deadline: + break + + result["attempts"] += 1 + work_start = time.perf_counter() + try: + trace = get_trace(unwinder, blocking, op) + except TRANSIENT_ERRORS: + trace = None + result["errors"] += 1 + result["work_time"] += time.perf_counter() - work_start + + if not trace: + continue + + result["samples"] += 1 + for unit in iter_units(trace, op): + frames = unit[3] + impossible = classify is not None and ( + classify(unit) if classify_units else classify(frames) + ) + result["stacks"] += 1 + if impossible: + result["impossible"] += 1 + else: + result["observations"][ + ";".join( + f"{frame.funcname}:{_get_lineno(frame)}" + for frame in frames + ) + ] += 1 + return result + + +def result_metrics(result, reference_obs, is_reference, op): + skip_tvd = is_reference or op != "get_stack_trace" + n_live = sum(result["observations"].values()) + raw_tvd = None if skip_tvd else tvd(result["observations"], reference_obs) + # IID heuristic, not a calibrated noise bound. + floor = None if skip_tvd else tvd_floor(reference_obs, n_live) + return { + "samples": result["samples"], + "stacks": result["stacks"], + "empty": result["attempts"] - result["samples"] - result["errors"], + "impossible": result["impossible"], + "error_percent": ( + 100.0 * result["errors"] / result["attempts"] + if result["attempts"] + else 0.0 + ), + "impossible_percent": ( + 100.0 * result["impossible"] / result["stacks"] + if result["stacks"] + else 0.0 + ), + "avg_us": ( + 1e6 * result["work_time"] / result["attempts"] + if result["attempts"] + else 0.0 + ), + "raw_tvd": raw_tvd, + "tvd_floor": floor, + "tvd_excess": ( + None if (raw_tvd is None or floor is None) else raw_tvd - floor + ), + } + + +def fmt_stat(values, precision): + vals = [value for value in values if value is not None] + if not vals: + return "n/a" + mean = statistics.mean(vals) + if len(vals) > 1: + return f"{mean:.{precision}f}±{statistics.stdev(vals):.{precision}f}" + return f"{mean:.{precision}f}" + + +def fmt_floor(values): + vals = [value for value in values if value is not None] + return "n/a" if not vals else f"{statistics.median(vals):.3f}" + + +def print_results( + case_name, run_results, modes, reference_mode, op, has_classify +): + is_sync = op == "get_stack_trace" + ref_keys = len(run_results[0][reference_mode]["observations"]) + rows = {} + for mode in modes: + metrics = [ + result_metrics( + results[mode], + results[reference_mode]["observations"], + mode == reference_mode, + op, + ) + for results in run_results + ] + rows[mode] = { + "mode": mode, + "samples": sum(item["samples"] for item in metrics), + "stacks": sum(item["stacks"] for item in metrics), + "empty": sum(item["empty"] for item in metrics), + "impossible": sum(item["impossible"] for item in metrics), + "errors": fmt_stat([item["error_percent"] for item in metrics], 2), + "us": fmt_stat([item["avg_us"] for item in metrics], 2), + "impossible_pct": fmt_stat( + [item["impossible_percent"] for item in metrics], 2 + ), + "raw_tvd": "ref" + if mode == reference_mode + else fmt_stat([item["raw_tvd"] for item in metrics], 3), + "tvd_excess": "ref" + if mode == reference_mode + else fmt_stat([item["tvd_excess"] for item in metrics], 3), + "tvd_floor": "-" + if mode == reference_mode + else fmt_floor([item["tvd_floor"] for item in metrics]), + } + + show_stacks = any(row["stacks"] != row["samples"] for row in rows.values()) + ordered = [reference_mode] + [m for m in modes if m != reference_mode] + + columns = [("mode", "<18", "mode"), ("samples", ">9", "samples")] + if show_stacks: + columns.append(("stacks", ">9", "stacks")) + if not is_sync: + columns.append(("empty", ">9", "empty")) + columns += [("µs", ">12", "us"), ("errors%", ">12", "errors")] + if has_classify: + columns += [ + ("impossible", ">10", "impossible"), + ("impossible%", ">12", "impossible_pct"), + ] + if is_sync: + columns += [ + ("raw_tvd", ">12", "raw_tvd"), + ("tvd_excess", ">12", "tvd_excess"), + ("tvd_floor", ">10", "tvd_floor"), + ] + + print(f"\n{case_name} ({op}) ref_keys={ref_keys}") + print(" ".join(f"{label:{spec}}" for label, spec, _ in columns)) + for mode in ordered: + row = rows[mode] + print(" ".join(f"{row[key]:{spec}}" for _, spec, key in columns)) + + +def parse_args(): + parser = argparse.ArgumentParser( + formatter_class=argparse.ArgumentDefaultsHelpFormatter + ) + parser.add_argument( + "--snippet", + action="append", + help="snippet name or Python file; may be passed more than once", + ) + parser.add_argument( + "--mode", + choices=sorted(MODES), + action="append", + help="mode to run; may be passed more than once; omit to run all modes", + ) + parser.add_argument( + "--reference-mode", + choices=sorted(MODES), + default="blocking-nocache", + help="mode used as the distribution reference", + ) + parser.add_argument( + "--duration", + type=float, + default=3.0, + help="seconds to sample each mode", + ) + parser.add_argument( + "--runs", + type=int, + default=1, + help="number of independent runs per case", + ) + parser.add_argument( + "--rate-khz", + type=float, + default=100.0, + help="target sampling rate in kHz; 0 samples as fast as possible", + ) + parser.add_argument( + "--warmup", + type=float, + default=0.7, + help="seconds to let the target run before sampling", + ) + parser.add_argument( + "--poisson-sampling", + action="store_true", + help=( + "sample with exponential inter-arrival times instead of a fixed " + "period" + ), + ) + args = parser.parse_args() + if args.runs < 1: + parser.error("--runs must be greater than zero") + return args + + +def main(): + args = parse_args() + cases = list(args.snippet) if args.snippet else sorted(CASES) + modes = list(args.mode) if args.mode else sorted(MODES) + if args.reference_mode not in modes: + modes.append(args.reference_mode) + + print_run_info(args, cases) + + for name in cases: + if name in CASES: + case = CASES[name] + else: + with open(name, encoding="utf-8") as file: + case = (file.read(), None) + op = case[2] if len(case) > 2 else "get_stack_trace" + case_ref = args.reference_mode + case_modes = list(modes) + if op != "get_stack_trace": + case_ref = collapse_cache(case_ref) + case_modes = list( + dict.fromkeys(collapse_cache(m) for m in case_modes) + ) + if case_ref not in case_modes: + case_modes.append(case_ref) + run_results = [ + {mode: run_mode(case, mode, args) for mode in case_modes} + for _ in range(args.runs) + ] + print_results( + name, run_results, case_modes, case_ref, op, case[1] is not None + ) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/Tools/inspection/snippets.py b/Tools/inspection/snippets.py new file mode 100644 index 000000000000000..47173c4fd125438 --- /dev/null +++ b/Tools/inspection/snippets.py @@ -0,0 +1,601 @@ +"""Scripts and classifiers for external inspection validation. + +Classifiers detect only recognized impossible patterns. They do not validate +entire stacks. False does not imply that the stack as a whole is valid. +""" +import os + + +def _get_lineno(frame, default=None): + if frame is None: + return default + loc = getattr(frame, "location", None) + return getattr(loc, "lineno", default) if loc is not None else default + + +CODE = '''\ +import time +import os +import sys +import math + +def slow_fibonacci(n): + """Intentionally slow recursive fibonacci - should show up prominently in profiler""" + if n <= 1: + return n + return slow_fibonacci(n-1) + slow_fibonacci(n-2) + +def medium_computation(): + """Medium complexity function""" + result = 0 + for i in range(1000): + result += math.sqrt(i) * math.sin(i) + return result + +def fast_loop(): + """Fast simple loop""" + total = 0 + for i in range(100): + total += i + return total + +def string_operations(): + """String manipulation that should be visible in profiler""" + text = "hello world " * 100 + words = text.split() + return " ".join(reversed(words)) + +def nested_calls(): + """Nested function calls to test call stack depth""" + def level1(): + def level2(): + def level3(): + return medium_computation() + return level3() + return level2() + return level1() + +def main_loop(): + """Main computation loop with different execution paths""" + iteration = 0 + + while True: + iteration += 1 + + # Different execution paths with different frequencies + if iteration % 50 == 0: + # Expensive operation - should show high per-call time + result = slow_fibonacci(20) + + elif iteration % 10 == 0: + # Medium operation + result = nested_calls() + + elif iteration % 5 == 0: + # String operations + result = string_operations() + + else: + # Fast operation - most common + result = fast_loop() + + # Small delay to make sampling more interesting + time.sleep(0.001) + +if __name__ == "__main__": + main_loop() +''' + +DEEP_STATIC_CODE = """\ +import time +def factorial(n): + if n <= 1: + time.sleep(10000) + return 1 + return n * factorial(n-1) + +factorial(900) +""" + +CODE_WITH_TONS_OF_THREADS = '''\ +import time +import threading +import random +import math + +def cpu_intensive_work(): + """Do some CPU intensive calculations""" + result = 0 + for _ in range(10000): + result += math.sin(random.random()) * math.cos(random.random()) + return result + +def io_intensive_work(): + """Simulate IO intensive work with sleeps""" + time.sleep(0.1) + +def mixed_workload(): + """Mix of CPU and IO work""" + while True: + if random.random() < 0.3: + cpu_intensive_work() + else: + io_intensive_work() + +def create_threads(n): + """Create n threads doing mixed workloads""" + threads = [] + for _ in range(n): + t = threading.Thread(target=mixed_workload, daemon=True) + t.start() + threads.append(t) + return threads + +# Start with 5 threads +active_threads = create_threads(5) + +# Main thread manages threads and does work +while True: + # Randomly add threads up to the limit + if random.random() < 0.1: # 10% chance each iteration + if random.random() < 0.5 and len(active_threads) < 100: + new_count = min( + random.randint(1, 5), + 100 - len(active_threads), + ) + new_threads = create_threads(new_count) + active_threads.extend(new_threads) + + cpu_intensive_work() + time.sleep(0.05) +''' + +ASYNC_CODE = '''\ +import asyncio +import contextlib +import math + +def compute_slice(seed): + result = 0.0 + for i in range(2000): + result += math.sin(seed + i) * math.sqrt(i + 1) + return result + +async def leaf_task(seed): + total = 0.0 + while True: + total += compute_slice(seed) + await asyncio.sleep(0) + +async def parent_task(seed): + child = asyncio.create_task(leaf_task(seed + 1000), name=f"leaf-{seed}") + try: + while True: + compute_slice(seed) + await asyncio.sleep(0.001) + finally: + child.cancel() + with contextlib.suppress(asyncio.CancelledError): + await child + +async def main(): + tasks = [ + asyncio.create_task(parent_task(i), name=f"parent-{i}") + for i in range(8) + ] + await asyncio.gather(*tasks) + +if __name__ == "__main__": + asyncio.run(main()) +''' + + +FLAT_ALTERNATING_CODE = """\ +def leaf_a(): return sum(range(50)) +def leaf_b(): return sum(range(50)) +def hot_a(): return leaf_a() +def hot_b(): return leaf_b() +while True: + hot_a(); hot_b() +""" + + +def _expected_lines(code): + expected = {} + for number, line in enumerate(code.splitlines(), 1): + stripped = line.strip() + if stripped.startswith("def "): + expected[stripped[4:].split("(")[0].strip()] = number + return expected + + +FLAT_ALTERNATING_LINES = _expected_lines(FLAT_ALTERNATING_CODE) + + +def classify_flat(frames): + present = {} + for frame in frames: + if frame.funcname in FLAT_ALTERNATING_LINES: + present[frame.funcname] = _get_lineno(frame, -1) + if not present: + return False + for name, lineno in present.items(): + if lineno != FLAT_ALTERNATING_LINES[name]: + return True + hot_a, hot_b = "hot_a" in present, "hot_b" in present + leaf_a, leaf_b = "leaf_a" in present, "leaf_b" in present + any_a = leaf_a or hot_a + any_b = leaf_b or hot_b + return (any_a and any_b) or (leaf_a and not hot_a) or (leaf_b and not hot_b) + + +NESTED_ALTERNATING_CODE = """\ +def burn_a(): + total = 0 + for i in range(20000): + total += i + return total + +def burn_b(): + total = 0 + for i in range(20000): + total += i + return total + +def a_leaf(): + return burn_a() + +def b_leaf(): + return burn_b() + +def a_parent(): + return a_leaf() + +def b_parent(): + return b_leaf() + +while True: + a_parent() + b_parent() +""" + + +NESTED_ALTERNATING_BRANCHES = { + "a": ["a_parent", "a_leaf", "burn_a"], + "b": ["b_parent", "b_leaf", "burn_b"], +} + + +def classify_nested(frames): + frame_names = [frame.funcname for frame in frames] + names = set(frame_names) + present = [ + family + for family, chain in NESTED_ALTERNATING_BRANCHES.items() + if names.intersection(chain) + ] + if len(present) > 1: + return True + if not present: + return False + chain = NESTED_ALTERNATING_BRANCHES[present[0]] + active = [name for name in chain if name in names] + depth = chain.index(active[-1]) + if len(active) != depth + 1: + return True + indices = [frame_names.index(name) for name in reversed(active)] + return indices != sorted(indices) + + +SHARED_LEAF_CODE = """\ +def shared_leaf(long_run): + total = 0 + if long_run: + for i in range(50000): + total += i + else: + for i in range(200): + total += i + return total + +def a_wrapper(): + return shared_leaf(False) + +def b_wrapper(): + return shared_leaf(True) + +while True: + a_wrapper() + b_wrapper() +""" + + +def _branch_lines(code, marker): + for number, line in enumerate(code.splitlines(), 1): + if marker in line: + return {number, number + 1} + return set() + + +SHARED_LEAF_LONG_LINES = _branch_lines(SHARED_LEAF_CODE, "range(50000)") +SHARED_LEAF_SHORT_LINES = _branch_lines(SHARED_LEAF_CODE, "range(200)") + + +def classify_shared(frames): + frame_names = [frame.funcname for frame in frames] + names = set(frame_names) + if "a_wrapper" in names and "b_wrapper" in names: + return True + if "shared_leaf" not in names: + return False + index = frame_names.index("shared_leaf") + parent = frame_names[index + 1] if index + 1 < len(frame_names) else None + if parent not in ("a_wrapper", "b_wrapper"): + return True + lineno = _get_lineno(frames[index], -1) + if lineno in SHARED_LEAF_LONG_LINES: + return parent != "b_wrapper" + if lineno in SHARED_LEAF_SHORT_LINES: + return parent != "a_wrapper" + return False + + +GEN_ALTERNATING_CODE = """\ +def agen(n): + total = 0 + for i in range(n): + total += i + yield i + +def bgen(n): + total = 0 + for i in range(n): + total += i + yield i + +def drv_a(): + for _ in agen(60): + pass + +def drv_b(): + for _ in bgen(60): + pass + +while True: + drv_a() + drv_b() +""" + + +def classify_gen(frames): + names = {frame.funcname for frame in frames} + return ("agen" in names and "drv_b" in names) or ( + "bgen" in names and "drv_a" in names + ) + + +DEEP_RECURSION_CODE = """\ +def leaf(): + total = 0 + for i in range(40): + total += i + +def a(n): + return a(n - 1) if n else leaf() + +def b(n): + return b(n - 1) if n else leaf() + +while True: + a(300) + b(300) +""" + + +def classify_recursion(frames): + names = {frame.funcname for frame in frames} + return "a" in names and "b" in names + + +ASYNC_RUNNING_TASK_CODE = """\ +import asyncio + + +def leaf_hot(n): + return sum(range(n)) + + +def leaf_rare(n): + return sum(range(n)) + + +async def run_hot(): + while True: + leaf_hot(50000) + await asyncio.sleep(0) + + +async def run_rare(k): + while True: + leaf_rare(500) + await asyncio.sleep(0) + + +async def main(): + tasks = [asyncio.create_task(run_hot(), name="hot")] + for k in range(8): + tasks.append(asyncio.create_task(run_rare(k), name=f"rare{k}")) + await asyncio.gather(*tasks) + + +asyncio.run(main()) +""" + + +def _name_tag(label): + label = (label or "").lower() + return "hot" if "hot" in label else "rare" if "rare" in label else None + + +def _frame_tag(frames): + fns = {frame.funcname for frame in frames} + hot = bool(fns & {"run_hot", "leaf_hot"}) + rare = bool(fns & {"run_rare", "leaf_rare"}) + return ( + "mixed" + if (hot and rare) + else "hot" + if hot + else "rare" + if rare + else None + ) + + +def classify_async_running_task(unit): + name = _name_tag(unit[1]) + frame = _frame_tag(unit[3]) + return name is not None and frame is not None and frame != name + + +CODE_OBJECT_REUSE_CODE = """\ +SRC_A = "def func_a(n):\\n total=0\\n for i in range(n): total+=i*i\\n return total\\n" +SRC_B = "def func_b(n):\\n total=0\\n for i in range(n): total+=i*i\\n return total\\n" +WORK = 60000 + + +def build_a(): + ns = {} + code = compile(SRC_A, "A_file.py", "exec") + exec(code, ns) + return ns["func_a"], code + + +def build_b(): + ns = {} + code = compile(SRC_B, "B_file.py", "exec") + exec(code, ns) + return ns["func_b"], code + + +while True: + fa, ca = build_a() + fa(WORK) # call_a + del fa, ca + fb, cb = build_b() + fb(WORK) # call_b + del fb, cb +""" + + +def _marker_line(code, marker): + for number, line in enumerate(code.splitlines(), 1): + if marker in line: + return number + return None + + +CALL_A_LINE = _marker_line(CODE_OBJECT_REUSE_CODE, "# call_a") +CALL_B_LINE = _marker_line(CODE_OBJECT_REUSE_CODE, "# call_b") + + +def classify_code_object_reuse(frames): + real = [f for f in frames if f.funcname != ""] + leaf = next((f for f in real if f.funcname in ("func_a", "func_b")), None) + if leaf is None: + return False + base = os.path.basename(leaf.filename) + fn = leaf.funcname + if (fn == "func_a" and base == "B_file.py") or ( + fn == "func_b" and base == "A_file.py" + ): + return True + index = real.index(leaf) + caller = real[index + 1] if index + 1 < len(real) else None + line = _get_lineno(caller) + if line == CALL_A_LINE and fn == "func_b": + return True + if line == CALL_B_LINE and fn == "func_a": + return True + return False + + +OVERSIZED_CHUNK_CODE = """\ +NLOCALS = 1800 + +def make(name, tag, hotbody): + params = ", ".join(f"x{i}=0" for i in range(NLOCALS)) + src = ( + f"def hot_{tag}():\\n{hotbody}\\n" + f"def {name}({params}):\\n return hot_{tag}()\\n" + ) + exec(compile(src, f"{tag}.py", "exec"), globals()) + +make("big_a", "a", " s=0\\n for i in range(2000):\\n s+=i*3\\n return s") +make("big_b", "b", " s=1\\n for i in range(2000):\\n s^=(i<<1)\\n return s") + +while True: + big_a() + big_b() +""" + + +OVERSIZED_A_FUNCS = {"big_a", "hot_a"} +OVERSIZED_B_FUNCS = {"big_b", "hot_b"} + + +def classify_oversized_chunk(frames): + saw_a = saw_b = False + for frame in frames: + base = os.path.basename(frame.filename) + fn = frame.funcname + if base == "a.py": + if fn in OVERSIZED_A_FUNCS: + saw_a = True + elif fn in OVERSIZED_B_FUNCS: + return True + elif base == "b.py": + if fn in OVERSIZED_B_FUNCS: + saw_b = True + elif fn in OVERSIZED_A_FUNCS: + return True + return saw_a and saw_b + + +CODE_EXAMPLES = { + "basic": { + "code": CODE, + "description": "Mixed workload with fibonacci, computations, and string operations", + }, + "deep_static": { + "code": DEEP_STATIC_CODE, + "description": "Deep recursive call stack with 900+ frames (factorial)", + }, + "threads": { + "code": CODE_WITH_TONS_OF_THREADS, + "description": "Tons of threads doing mixed CPU/IO work", + }, + "asyncio": { + "code": ASYNC_CODE, + "description": "Asyncio tasks with active and awaited coroutine chains", + }, +} + +CASES = { + "basic": (CODE, None), + "deep_static": (DEEP_STATIC_CODE, None), + "threads": (CODE_WITH_TONS_OF_THREADS, None), + "asyncio": (ASYNC_CODE, None, "get_async_stack_trace"), + "flat_alternating": (FLAT_ALTERNATING_CODE, classify_flat), + "nested_alternating": (NESTED_ALTERNATING_CODE, classify_nested), + "shared_leaf": (SHARED_LEAF_CODE, classify_shared), + "gen_alternating": (GEN_ALTERNATING_CODE, classify_gen), + "deep_recursion": (DEEP_RECURSION_CODE, classify_recursion), + "async_running_task": ( + ASYNC_RUNNING_TASK_CODE, + classify_async_running_task, + "get_async_stack_trace", + ), + "code_object_reuse": (CODE_OBJECT_REUSE_CODE, classify_code_object_reuse), + "oversized_chunk": (OVERSIZED_CHUNK_CODE, classify_oversized_chunk), +} diff --git a/Tools/msi/README.txt b/Tools/msi/README.txt deleted file mode 100644 index 4b3de9e82f6f1ac..000000000000000 --- a/Tools/msi/README.txt +++ /dev/null @@ -1,530 +0,0 @@ -Quick Build Info -================ - -For testing, the installer should be built with the Tools/msi/build.bat -script: - - build.bat [-x86] [-x64] [-ARM64] [--doc] - -For an official release, the installer should be built with the -Tools/msi/buildrelease.bat script and environment variables: - - set PYTHON= - set SPHINXBUILD= - set PATH=;%PATH% - - buildrelease.bat [-x86] [-x64] [-ARM64] [-D] [-B] - [-o ] [-c ] - -See the Building the Installer section for more information. - -Overview -======== - -Python is distributed on Windows as an installer that will configure the -user's system. This allows users to have a functioning copy of Python -without having to build it themselves. - -The main tasks of the installer are: - -* copy required files into the expected layout -* configure system settings so the installation can be located by - other programs -* add entry points for modifying, repairing and uninstalling Python -* make it easy to launch Python, its documentation, and IDLE - -Each of these is discussed in a later section of this document. - -Structure of the Installer -========================== - -The installer is structured as a 'layout', which consists of a number of -CAB and MSI files and a single EXE. - -The EXE is the main entry point into the installer. It contains the UI -and command-line logic, as well as the ability to locate and optionally -download other parts of the layout. - -Each MSI contains the logic required to install a component or feature -of Python. These MSIs should not be launched directly by users. MSIs can -be embedded into the EXE or automatically downloaded as needed. - -Each CAB contains the files making up a Python installation. CABs are -embedded into their associated MSI and are never seen by users. - -MSIs are only required when the related feature or component is being -installed. When components are not selected for installation, the -associated MSI is not downloaded. This allows the installer to offer -options to install debugging symbols and binaries without increasing -the initial download size by separating them into their own MSIs. - -Building the Installer -====================== - -Before building the installer, download the extra build dependencies -using Tools\msi\get_externals.bat. (Note that this is in addition to the -similarly named file in PCbuild.) - -One of the dependencies used in the build process is WiX, a toolset that -allows developers to create installers for Windows Installer, the -Windows installation engine. If you're not using the copy of WiX -installed by Tools\msi\get_externals.bat, you'll need to set the -"WixInstallPath" environment variable before building. - -Additionally, ensure that "MSVC v14x - VS 20xx C++ ARM64/ARM64EC build tools" -is selected under "Desktop Development with C++" in the "Visual Studio Installer", -even if you're not building on ARM64. This is required because we've upgraded -to WiX 3.14, which requires these tools for Python 3.10 and later versions. - -For testing, the installer should be built with the Tools/msi/build.bat -script: - - build.bat [-x86] [-x64] [-ARM64] [--doc] [--test-marker] [--pack] - -This script will build the required configurations of Python and -generate an installer layout in PCbuild/(win32|amd64)/en-us. - -Specify -x86, -x64 and/or -ARM64 to build for each platform. If none are -specified, both x64 and x86 will be built. Currently, both the debug and -release versions of Python are required for the installer. - -Specify --doc to include the documentation files. Ensure %PYTHON% and -%SPHINXBUILD% are set when passing this option. - -Specify --test-marker to build an installer that works side-by-side with -an official Python release. All registry keys and install locations will -include an extra marker to avoid overwriting files. This marker is -currently an 'x' prefix, but may change at any time. - -Specify --pack to build an installer that does not require all MSIs to -be available alongside. This takes longer, but is easier to share. - - -For an official release, the installer should be built with the -Tools/msi/buildrelease.bat script: - - set PYTHON= - set SPHINXBUILD= - set PATH=;%PATH% - - buildrelease.bat [-x86] [-x64] [-ARM64] [-D] [-B] - [-o ] [-c ] - -Specify -x86, -x64 and/or -ARM64 to build for each platform. If none are -specified, both x64 and x86 will be built. Currently, both the debug and -release versions of Python are required for the installer. - -Specify -D to skip rebuilding the documentation. The documentation is -required for a release and the build will fail if it is not available. -Ensure %PYTHON% and %SPHINXBUILD% are set if you omit this option. - -Specify -B to skip rebuilding Python. This is useful to only rebuild the -installer layout after a previous call to buildrelease.bat. - -Specify -o to set an output directory. The installer layouts will be -copied to platform-specific subdirectories of this path. - -Specify -c to choose a code-signing certificate to be used for all the -signable binaries in Python as well as each file making up the -installer. Official releases of Python must be signed. - - -If WiX is not found on your system, it will be automatically downloaded -and extracted to the externals/ directory. - -To manually build layouts of the installer, build one of the projects in -the bundle folder. - - msbuild bundle\snapshot.wixproj - msbuild bundle\releaseweb.wixproj - msbuild bundle\releaselocal.wixproj - msbuild bundle\full.wixproj - -snapshot.wixproj produces a test installer versioned based on the date. - -releaseweb.wixproj produces a release installer that does not embed any -of the layout. - -releaselocal.wixproj produces a release installer that embeds the files -required for a default installation. - -full.wixproj produces a test installer that embeds the entire layout. - -The following properties may be passed when building these projects. - - /p:BuildForRelease=(true|false) - When true, adds extra verification to ensure a complete installer is - produced. Defaults to false. - - /p:ReleaseUri=(any URI) - Used to generate unique IDs for the installers to allow side-by-side - installation. Forks of Python can use the same installer infrastructure - by providing a unique URI for this property. It does not need to be an - active internet address. Defaults to $(ComputerName). - - Official releases use https://www.python.org/(architecture name) - - /p:DownloadUrlBase=(any URI) - Specifies the base of a URL where missing parts of the installer layout - can be downloaded from. The build version and architecture will be - appended to create the full address. If omitted, missing components will - not be automatically downloaded. - - /p:DownloadUrl=(any URI) - Specifies the full URL where missing parts of the installer layout can - be downloaded from. Should normally include '{2}', which will be - substituted for the filename. If omitted, missing components will not be - automatically downloaded. If specified, this value overrides - DownloadUrlBase. - - /p:SigningCertificate=(certificate name) - Specifies the certificate to sign the installer layout with. If omitted, - the layout will not be signed. - - /p:RebuildAll=(true|false) - When true, rebuilds all of the MSIs making up the layout. Defaults to - true. - -Uploading the Installer -======================= - -For official releases, the uploadrelease.bat script should be used. - -You will require PuTTY so that plink.exe and pscp.exe can be used, and your -SSH key can be activated in pageant.exe. PuTTY should be either on your path -or in %ProgramFiles(x86)%\PuTTY. - -To include signatures for each uploaded file, you will need gpg2.exe on your -path or have run get_externals.bat. You may also need to "gpg2.exe --import" -your key before running the upload script. - - uploadrelease.bat --host --user [--dry-run] [--no-gpg] - -The host is the URL to the server. This can be provided by the Release -Manager. You should be able to SSH to this address. - -The username is your own username, which you have permission to SSH into -the server containing downloads. - -Use --dry-run to display the generated upload commands without executing -them. Signatures for each file will be generated but not uploaded unless ---no-gpg is also passed. - -Use --no-gpg to suppress signature generation and upload. - -The default target directory (which appears in uploadrelease.proj) is -correct for official Python releases, but may be overridden with ---target for other purposes. This path should generally not include -any version specifier, as that will be added automatically. - -Modifying the Installer -======================= - -The code for the installer is divided into three main groups: packages, -the bundle and the bootstrap application. - -Packages --------- - -Packages appear as subdirectories of Tools/msi (other than the bundle/ -directory). The project file is a .wixproj and the build output is a -single MSI. Packages are built with the WiX Toolset. Some project files -share source files and use preprocessor directives to enable particular -features. These are typically used to keep the sources close when the -files are related, but produce multiple independent packages. - -A package is the smallest element that may be independently installed or -uninstalled (as used in this installer). For example, the test suite has -its own package, as users can choose to add or remove it after the -initial installation. - -All the files installed by a single package should be related, though -some packages may not install any files. For example, the pip package -executes the ensurepip package, but does not add or remove any of its -own files. (It is represented as a package because of its -installed/uninstalled nature, as opposed to the "precompile standard -library" option, for example.) Dependencies between packages are handled -by the bundle, but packages should detect when dependencies are missing -and raise an error. - -Packages that include a lot of files may use an InstallFiles element in -the .wixproj file to generate sources. See lib/lib.wixproj for an -example, and msi.targets and csv_to_wxs.py for the implementation. This -element is also responsible for generating the code for cleaning up and -removing __pycache__ folders in any directory containing .py files. - -All packages are built with the Tools/msi/common.wxs file, and so any -directory or property in this file may be referenced. Of particular -interest: - - REGISTRYKEY (property) - The registry key for the current installation. - - InstallDirectory (directory) - The root install directory for the current installation. Subdirectories - are also specified in this file (DLLs, Lib, etc.) - - MenuDir (directory) - The Start Menu folder for the current installation. - - UpgradeTable (property) - Every package should reference this property to include upgrade - information. - - OptionalFeature (Component) - Packages that may be enabled or disabled should reference this component - and have an OPTIONAL_FEATURES entry in the bootstrap application to - properly handle Modify and Upgrade. - -The .wxl_template file is specially handled by the build system for this -project to perform {{substitutions}} as defined in msi.targets. They -should be included in projects as items, where .wxl files -are normally included as items. - -Bundle ------- - -The bundle is compiled to the main EXE entry point that for most users -will represent the Python installer. It is built from Tools/msi/bundle -with packages references in Tools/msi/bundle/packagegroups. - -Build logic for the bundle is in bundle.targets, but should be invoked -through one of the .wixproj files as described in Building the -Installer. - -The UI is separated between Default.thm (UI layout), Default.wxl -(strings), bundle.wxs (properties) and the bootstrap application. -Bundle.wxs also contains the chain, which is the list of packages to -install and the order they should be installed in. These refer to named -package groups in bundle/packagegroups. - -Each package group specifies one or more packages to install. Most -packages require two separate entries to support both per-user and -all-users installations. Because these reuse the same package, it does -not increase the overall size of the package. - -Package groups refer to payload groups, which allow better control over -embedding and downloading files than the default settings. Whether files -are embedded and where they are downloaded from depends on settings -created by the project files. - -Package references can include install conditions that determine when to -install the package. When a package is a dependency for others, the -condition should be crafted to ensure it is installed. - -MSI packages are installed or uninstalled based on their current state -and the install condition. This makes them most suitable for features -that are clearly present or absent from the user's machine. - -EXE packages are executed based on a customisable condition that can be -omitted. This makes them suitable for pre- or post-install tasks that -need to run regardless of whether features have been added or removed. - -Bootstrap Application ---------------------- - -The bootstrap application is a C++ application that controls the UI and -installation. While it does not directly compile into the main EXE of -the installer, it forms the main active component. Most of the -installation functionality is provided by WiX, and so the bootstrap -application is predominantly responsible for the code behind the UI that -is defined in the Default.thm file. The bootstrap application code is in -bundle/bootstrap and is built automatically when building the bundle. - -Installation Layout -=================== - -There are two installation layouts for Python on Windows, with the only -differences being supporting files. A layout is selected implicitly -based on whether the install is for all users of the machine or just for -the user performing the installation. - -The default installation location when installing for all users is -"%ProgramFiles%\Python3X" for the 64-bit interpreter and -"%ProgramFiles(x86)%\Python3X-32" for the 32-bit interpreter. (Note that -the latter path is equivalent to "%ProgramFiles%\Python3X-32" when -running a 32-bit version of Windows.) This location requires -administrative privileges to install or later modify the installation. - -The default installation location when installing for the current user -is "%LocalAppData%\Programs\Python\Python3X" for the 64-bit interpreter -and "%LocalAppData%\Programs\Python\Python3X-32" for the 32-bit -interpreter. Only the current user can access this location. This -provides a suitable level of protection against malicious modification -of Python's files. - -(Default installation locations are set in Tools\msi\bundle\bundle.wxs.) - -Within this install directory is the following approximate layout: - -.\python[w].exe The core executable files -.\python3x.dll The core interpreter -.\python3.dll The stable ABI reference -.\DLLs Stdlib extensions (*.pyd) and dependencies -.\Doc Documentation (*.html) -.\include Development headers (*.h) -.\Lib Standard library -.\Lib\test Test suite -.\libs Development libraries (*.lib) -.\Scripts Launcher scripts (*.exe, *.py) -.\tcl Tcl dependencies (*.dll, *.tcl and others) -.\Tools Tool scripts (*.py) - -When installed for all users, the following files are installed to -"%SystemRoot%" (typically "C:\Windows") to ensure they are always -available on PATH. (See Launching Python below.) For the current user, -they are installed in "%LocalAppData%\Programs\Python\PyLauncher". - -.\py[w].exe PEP 397 launcher - - -System Settings -=============== - -On installation, registry keys are created so that other applications -can locate and identify installations of Python. The locations of these -keys vary based on the install type. - -For 64-bit interpreters installed for all users, the root key is: - HKEY_LOCAL_MACHINE\Software\Python\PythonCore\3.X - -For 32-bit interpreters installed for all users on a 64-bit operating -system, the root key is: - HKEY_LOCAL_MACHINE\Software\Wow6432Node\Python\PythonCore\3.X-32 - -For 32-bit interpreters installed for all users on a 32-bit operating -system, the root key is: - HKEY_LOCAL_MACHINE\Software\Python\PythonCore\3.X-32 - -For 64-bit interpreters installed for the current user: - HKEY_CURRENT_USER\Software\Python\PythonCore\3.X - -For 32-bit interpreters installed for the current user: - HKEY_CURRENT_USER\Software\Python\PythonCore\3.X-32 - -When the core Python executables are installed, a key "InstallPath" is -created within the root key with its default value set to the -executable's install directory. A value named "ExecutablePath" is added -with the full path to the main Python interpreter, and a key -"InstallGroup" is created with its default value set to the product -name "Python 3.X". - -When the Python standard library is installed, a key "PythonPath" is -created within the root key with its default value set to the full path -to the Lib folder followed by the path to the DLLs folder, separated by -a semicolon. - -When the documentation is installed, a key "Help" is created within the -root key, with a subkey "Main Python Documentation" with its default -value set to the full path to the main index.html file. - - -The py.exe launcher is installed as part of a regular Python install, -but using a separate mechanism that allows it to more easily span -versions of Python. As a result, it has different root keys for its -registry entries: - -When installed for all users on a 64-bit operating system, the -launcher's root key is: - HKEY_LOCAL_MACHINE\Software\Wow6432Node\Python\Launcher - -When installed for all users on a 32-bit operating system, the -launcher's root key is: - HKEY_LOCAL_MACHINE\Software\Python\Launcher - -When installed for the current user: - HKEY_CURRENT_USER\Software\Python\Launcher - -When the launcher is installed, a key "InstallPath" is created within -its root key with its default value set to the launcher's install -directory. File associations are also created for .py, .pyw, .pyc and -.pyo files. - -Launching Python -================ - -When a feature offering user entry points in the Start Menu is -installed, a folder "Python 3.X" is created. Every shortcut should be -created within this folder, and each shortcut should include the version -and platform to allow users to identify the shortcut in a search results -page. - -The core Python executables creates a shortcut "Python 3.X (32-bit)" or -"Python 3.X (64-bit)" depending on the interpreter. - -The documentation creates a shortcut "Python 3.X 32-bit Manuals" or -"Python 3.X 64-bit Manuals". The documentation is identical for all -platforms, but the shortcuts need to be separate to avoid uninstallation -conflicts. - -Installing IDLE creates a shortcut "IDLE (Python 3.X 32-bit)" or "IDLE -(Python 3.X 64-bit)" depending on the interpreter. - - -For users who often launch Python from a Command Prompt, an option is -provided to add the directory containing python.exe to the user or -system PATH variable. If the option is selected, the install directory -and the Scripts directory will be added at the start of the system PATH -for an all users install and the user PATH for a per-user install. - -When the user only has one version of Python installed, this will behave -as expected. However, because Windows searches the system PATH before -the user PATH, users cannot override a system-wide installation of -Python on their PATH. Further, because the installer can only prepend to -the path, later installations of Python will take precedence over -earlier installations, regardless of interpreter version. - -Because it is not possible to automatically create a sensible PATH -configuration, users are recommended to use the py.exe launcher and -manually modify their PATH variable to add Scripts directories in their -preferred order. System-wide installations of Python should consider not -modifying PATH, or using an alternative technology to modify their -users' PATH variables. - - -The py.exe launcher is recommended because it uses a consistent and -sensible search order for Python installations. User installations are -preferred over system-wide installs, and later versions are preferred -regardless of installation order (with the exception that py.exe -currently prefers 2.x versions over 3.x versions without the -3 command -line argument). - -For both 32-bit and 64-bit interpreters, the 32-bit version of the -launcher is installed. This ensures that the search order is always -consistent (as the 64-bit launcher is subtly different from the 32-bit -launcher) and also avoids the need to install it multiple times. Future -versions of Python will upgrade the launcher in-place, using Windows -Installer's upgrade functionality to avoid conflicts with earlier -installed versions. - -When installed, file associations are created for .py, .pyc and .pyo -files to launch with py.exe and .pyw files to launch with pyw.exe. This -makes Python files respect shebang lines by default and also avoids -conflicts between multiple Python installations. - - -Repair, Modify and Uninstall -============================ - -After installation, Python may be modified, repaired or uninstalled by -running the original EXE again or via the Programs and Features applet -(formerly known as Add or Remove Programs). - -Modifications allow features to be added or removed. The install -directory and kind (all users/single user) cannot be modified. Because -Windows Installer caches installation packages, removing features will -not require internet access unless the package cache has been corrupted -or deleted. Adding features that were not previously installed and are -not embedded or otherwise available will require internet access. - -Repairing will rerun the installation for all currently installed -features, restoring files and registry keys that have been modified or -removed. This operation generally will not redownload any files unless -the cached packages have been corrupted or deleted. - -Removing Python will clean up all the files and registry keys that were -created by the installer, as well as __pycache__ folders that are -explicitly handled by the installer. Python packages installed later -using a tool like pip will not be removed. Some components may be -installed by other installers and these will not be removed if another -product has a dependency on them. diff --git a/Tools/msi/appendpath/appendpath.wixproj b/Tools/msi/appendpath/appendpath.wixproj deleted file mode 100644 index 897087678c56f63..000000000000000 --- a/Tools/msi/appendpath/appendpath.wixproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - {12B59A06-37CC-4558-A9C8-DAE922E64EF3} - 2.0 - appendpath - Package - ICE71 - - - - - - - - - - - diff --git a/Tools/msi/appendpath/appendpath.wxs b/Tools/msi/appendpath/appendpath.wxs deleted file mode 100644 index bba186cf60fd10a..000000000000000 --- a/Tools/msi/appendpath/appendpath.wxs +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - NOT ALLUSERS=1 - - - - - - - - - - - - ALLUSERS=1 - - - - - - - - - - - - - - - - diff --git a/Tools/msi/appendpath/appendpath_en-US.wxl b/Tools/msi/appendpath/appendpath_en-US.wxl deleted file mode 100644 index 19a2e7734f8c31e..000000000000000 --- a/Tools/msi/appendpath/appendpath_en-US.wxl +++ /dev/null @@ -1,6 +0,0 @@ - - - Append to Path - AppendPath - No !(loc.ProductName) installation was detected. - diff --git a/Tools/msi/build.bat b/Tools/msi/build.bat deleted file mode 100644 index 2fe8a475e7e3a30..000000000000000 --- a/Tools/msi/build.bat +++ /dev/null @@ -1,103 +0,0 @@ -@echo off -setlocal -set D=%~dp0 -set PCBUILD=%D%..\..\PCbuild\ - -set BUILDX86= -set BUILDX64= -set BUILDARM64= -set BUILDDOC= -set BUILDTEST= -set BUILDPACK= -set REBUILD= - -:CheckOpts -if "%~1" EQU "-h" goto Help -if /I "%~1" EQU "-x86" (set BUILDX86=1) && shift && goto CheckOpts -if /I "%~1" EQU "-Win32" (set BUILDX86=1) && shift && goto CheckOpts -if /I "%~1" EQU "-x64" (set BUILDX64=1) && shift && goto CheckOpts -if /I "%~1" EQU "-arm64" (set BUILDARM64=1) && shift && goto CheckOpts -if "%~1" EQU "--doc" (set BUILDDOC=1) && shift && goto CheckOpts -if "%~1" EQU "--no-test-marker" (set BUILDTEST=) && shift && goto CheckOpts -if "%~1" EQU "--test-marker" (set BUILDTEST=--test-marker) && shift && goto CheckOpts -if "%~1" EQU "--pack" (set BUILDPACK=1) && shift && goto CheckOpts -if "%~1" EQU "-r" (set REBUILD=-r) && shift && goto CheckOpts -rem %IncludeFreethreaded% is recognised by the MSI build, but not the regular build. -rem We use it to build twice and then build the installer with its extra option -if /I "%~1" EQU "--disable-gil" (set IncludeFreethreaded=true) && shift && goto CheckOpts - -if not defined BUILDX86 if not defined BUILDX64 if not defined BUILDARM64 (set BUILDX86=1) && (set BUILDX64=1) - -call "%D%get_externals.bat" -call "%PCBUILD%find_msbuild.bat" %MSBUILD% -if ERRORLEVEL 1 (echo Cannot locate MSBuild.exe on PATH or as MSBUILD variable & exit /b 2) - -if defined BUILDX86 call "%PCBUILD%build.bat" -p Win32 -d -e %REBUILD% %BUILDTEST% -if errorlevel 1 exit /B %ERRORLEVEL% -if defined BUILDX86 call "%PCBUILD%build.bat" -p Win32 -e %REBUILD% %BUILDTEST% -if errorlevel 1 exit /B %ERRORLEVEL% - -if defined BUILDX64 call "%PCBUILD%build.bat" -p x64 -d -e %REBUILD% %BUILDTEST% -if errorlevel 1 exit /B %ERRORLEVEL% -if defined BUILDX64 call "%PCBUILD%build.bat" -p x64 -e %REBUILD% %BUILDTEST% -if errorlevel 1 exit /B %ERRORLEVEL% - -if defined BUILDARM64 call "%PCBUILD%build.bat" -p ARM64 -d -e %REBUILD% %BUILDTEST% -if errorlevel 1 exit /B %ERRORLEVEL% -if defined BUILDARM64 call "%PCBUILD%build.bat" -p ARM64 -e %REBUILD% %BUILDTEST% -if errorlevel 1 exit /B %ERRORLEVEL% - -if /I "%IncludeFreethreaded%"=="true" ( - rem Cannot "exit /B" inside an if block because %ERRORLEVEL% will be wrong. - rem We just skip everything after the first "errorlevel 1" and then exit after - if defined BUILDX86 call "%PCBUILD%build.bat" -p Win32 -d -e %REBUILD% %BUILDTEST% --disable-gil - if not errorlevel 1 if defined BUILDX86 call "%PCBUILD%build.bat" -p Win32 -e %REBUILD% %BUILDTEST% --disable-gil - - if not errorlevel 1 if defined BUILDX64 call "%PCBUILD%build.bat" -p x64 -d -e %REBUILD% %BUILDTEST% --disable-gil - if not errorlevel 1 if defined BUILDX64 call "%PCBUILD%build.bat" -p x64 -e %REBUILD% %BUILDTEST% --disable-gil - - if not errorlevel 1 if defined BUILDARM64 call "%PCBUILD%build.bat" -p ARM64 -d -e %REBUILD% %BUILDTEST% --disable-gil - if not errorlevel 1 if defined BUILDARM64 call "%PCBUILD%build.bat" -p ARM64 -e %REBUILD% %BUILDTEST% --disable-gil -) -if errorlevel 1 exit /B %ERRORLEVEL% - -if defined BUILDDOC call "%PCBUILD%..\Doc\make.bat" html -if errorlevel 1 exit /B %ERRORLEVEL% - -rem Build the launcher MSI separately -%MSBUILD% "%D%launcher\launcher.wixproj" /p:Platform=x86 -if errorlevel 1 exit /B %ERRORLEVEL% - -set BUILD_CMD="%D%bundle\snapshot.wixproj" -if defined BUILDTEST ( - set BUILD_CMD=%BUILD_CMD% /p:UseTestMarker=true -) -if defined BUILDPACK ( - set BUILD_CMD=%BUILD_CMD% /p:Pack=true -) -if defined REBUILD ( - set BUILD_CMD=%BUILD_CMD% /t:Rebuild -) - -if defined BUILDX86 %MSBUILD% /p:Platform=x86 %BUILD_CMD% -if errorlevel 1 exit /B %ERRORLEVEL% - -if defined BUILDX64 %MSBUILD% /p:Platform=x64 %BUILD_CMD% -if errorlevel 1 exit /B %ERRORLEVEL% - -if defined BUILDARM64 %MSBUILD% /p:Platform=ARM64 %BUILD_CMD% -if errorlevel 1 exit /B %ERRORLEVEL% - -exit /B 0 - -:Help -echo build.bat [-x86] [-x64] [-arm64] [--doc] [-h] [--test-marker] [--pack] [-r] -echo. -echo -x86 Build x86 installers -echo -x64 Build x64 installers -echo -ARM64 Build ARM64 installers -echo --doc Build documentation -echo --test-marker Build with test markers -echo --no-test-marker Build without test markers (default) -echo --pack Embed core MSIs into installer -echo -r Rebuild rather than incremental build diff --git a/Tools/msi/buildrelease.bat b/Tools/msi/buildrelease.bat deleted file mode 100644 index 77fb47792088531..000000000000000 --- a/Tools/msi/buildrelease.bat +++ /dev/null @@ -1,261 +0,0 @@ -@setlocal -@echo off - -rem This script is intended for building official releases of Python. -rem To use it to build alternative releases, you should clone this file -rem and modify the following three URIs. - -rem These two will ensure that your release can be installed -rem alongside an official Python release, by modifying the GUIDs used -rem for all components. -rem -rem The following substitutions will be applied to the release URI: -rem Variable Description Example -rem {arch} architecture amd64, win32 -rem Do not change the scheme to https. Otherwise, releases built with this -rem script will not be upgradable to/from official releases of Python. -set RELEASE_URI=http://www.python.org/{arch} - -rem This is the URL that will be used to download installation files. -rem The files available from the default URL *will* conflict with your -rem installer. Trust me, you don't want them, even if it seems like a -rem good idea. -rem -rem The following substitutions will be applied to the download URL: -rem Variable Description Example -rem {version} version number 3.5.0 -rem {arch} architecture amd64, win32 -rem {releasename} release name a1, b2, rc3 (or blank for final) -rem {msi} MSI filename core.msi -set DOWNLOAD_URL=https://www.python.org/ftp/python/{version}/{arch}{releasename}/{msi} - -set D=%~dp0 -set PCBUILD=%D%..\..\PCbuild\ -if NOT DEFINED Py_OutDir set Py_OutDir=%PCBUILD% -set EXTERNALS=%D%..\..\externals\windows-installer\ - -set BUILDX86= -set BUILDX64= -set BUILDARM64= -set TARGET=Rebuild -set TESTTARGETDIR= -set PGO=-m test -q --pgo -set BUILDMSI=1 -set BUILDNUGET=1 -set BUILDZIP=1 - - -:CheckOpts -if "%1" EQU "-h" goto Help -if "%1" EQU "-c" (set CERTNAME=%~2) && shift && shift && goto CheckOpts -if "%1" EQU "--certificate" (set CERTNAME=%~2) && shift && shift && goto CheckOpts -if "%1" EQU "-o" (set OUTDIR=%~2) && shift && shift && goto CheckOpts -if "%1" EQU "--out" (set OUTDIR=%~2) && shift && shift && goto CheckOpts -if "%1" EQU "-D" (set SKIPDOC=1) && shift && goto CheckOpts -if "%1" EQU "--skip-doc" (set SKIPDOC=1) && shift && goto CheckOpts -if "%1" EQU "-B" (set SKIPBUILD=1) && shift && goto CheckOpts -if "%1" EQU "--skip-build" (set SKIPBUILD=1) && shift && goto CheckOpts -if "%1" EQU "--download" (set DOWNLOAD_URL=%~2) && shift && shift && goto CheckOpts -if "%1" EQU "--test" (set TESTTARGETDIR=%~2) && shift && shift && goto CheckOpts -if "%1" EQU "-b" (set TARGET=Build) && shift && goto CheckOpts -if "%1" EQU "--build" (set TARGET=Build) && shift && goto CheckOpts -if /I "%1" EQU "-x86" (set BUILDX86=1) && shift && goto CheckOpts -if /I "%1" EQU "-Win32" (set BUILDX86=1) && shift && goto CheckOpts -if /I "%1" EQU "-x64" (set BUILDX64=1) && shift && goto CheckOpts -if /I "%1" EQU "-arm64" (set BUILDARM64=1) && shift && goto CheckOpts -if "%1" EQU "--pgo" (set PGO=%~2) && shift && shift && goto CheckOpts -if "%1" EQU "--skip-pgo" (set PGO=) && shift && goto CheckOpts -if "%1" EQU "--skip-nuget" (set BUILDNUGET=) && shift && goto CheckOpts -if "%1" EQU "--skip-zip" (set BUILDZIP=) && shift && goto CheckOpts -if "%1" EQU "--skip-msi" (set BUILDMSI=) && shift && goto CheckOpts - -if "%1" NEQ "" echo Invalid option: "%1" && exit /B 1 - -if not defined BUILDX86 if not defined BUILDX64 if not defined BUILDARM64 (set BUILDX86=1) && (set BUILDX64=1) - -if not exist "%GIT%" where git > "%TEMP%\git.loc" 2> nul && set /P GIT= < "%TEMP%\git.loc" & del "%TEMP%\git.loc" -if not exist "%GIT%" echo Cannot find Git on PATH && exit /B 1 - -call "%D%get_externals.bat" -call "%PCBUILD%find_msbuild.bat" %MSBUILD% -if ERRORLEVEL 1 (echo Cannot locate MSBuild.exe on PATH or as MSBUILD variable & exit /b 2) - -:builddoc -if "%SKIPBUILD%" EQU "1" goto skipdoc -if "%SKIPDOC%" EQU "1" goto skipdoc - -call "%D%..\..\doc\make.bat" html -if errorlevel 1 exit /B %ERRORLEVEL% -:skipdoc - -if defined BUILDX86 ( - call :build x86 - if errorlevel 1 exit /B %ERRORLEVEL% -) - -if defined BUILDX64 ( - call :build x64 "%PGO%" - if errorlevel 1 exit /B %ERRORLEVEL% -) - -if defined BUILDARM64 ( - call :build ARM64 - if errorlevel 1 exit /B %ERRORLEVEL% -) - -if defined TESTTARGETDIR ( - call "%D%testrelease.bat" -t "%TESTTARGETDIR%" - if errorlevel 1 exit /B %ERRORLEVEL% -) - -exit /B 0 - -:build -@setlocal -@echo off - -if "%1" EQU "x86" ( - set PGO= - set BUILD=%Py_OutDir%win32\ - set BUILD_PLAT=Win32 - set OUTDIR_PLAT=win32 - set OBJDIR_PLAT=x86 -) else if "%1" EQU "x64" ( - set BUILD=%Py_OutDir%amd64\ - set PGO=%~2 - set BUILD_PLAT=x64 - set OUTDIR_PLAT=amd64 - set OBJDIR_PLAT=x64 -) else if "%1" EQU "ARM64" ( - set BUILD=%Py_OutDir%arm64\ - set PGO=%~2 - set BUILD_PLAT=ARM64 - set OUTDIR_PLAT=arm64 - set OBJDIR_PLAT=arm64 -) else ( - echo Unknown platform %1 - exit /B 1 -) - -if exist "%BUILD%en-us" ( - echo Deleting %BUILD%en-us - rmdir /q/s "%BUILD%en-us" - if errorlevel 1 exit /B %ERRORLEVEL% -) - -if exist "%D%obj\Debug_%OBJDIR_PLAT%" ( - echo Deleting "%D%obj\Debug_%OBJDIR_PLAT%" - rmdir /q/s "%D%obj\Debug_%OBJDIR_PLAT%" - if errorlevel 1 exit /B %ERRORLEVEL% -) - -if exist "%D%obj\Release_%OBJDIR_PLAT%" ( - echo Deleting "%D%obj\Release_%OBJDIR_PLAT%" - rmdir /q/s "%D%obj\Release_%OBJDIR_PLAT%" - if errorlevel 1 exit /B %ERRORLEVEL% -) - -if not "%CERTNAME%" EQU "" ( - set CERTOPTS="/p:SigningCertificate=%CERTNAME%" -) else ( - set CERTOPTS= -) -if not "%PGO%" EQU "" ( - set PGOOPTS=--pgo-job "%PGO%" -) else ( - set PGOOPTS= -) -if not "%SKIPBUILD%" EQU "1" ( - @echo call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -t %TARGET% %PGOOPTS% %CERTOPTS% - @call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -t %TARGET% %PGOOPTS% %CERTOPTS% - @if errorlevel 1 exit /B %ERRORLEVEL% - @rem build.bat turns echo back on, so we disable it again - @echo off - - @echo call "%PCBUILD%build.bat" -d -e -p %BUILD_PLAT% -t %TARGET% - @call "%PCBUILD%build.bat" -d -e -p %BUILD_PLAT% -t %TARGET% - @if errorlevel 1 exit /B %ERRORLEVEL% - @rem build.bat turns echo back on, so we disable it again - @echo off -) - -if "%OUTDIR_PLAT%" EQU "win32" ( - %MSBUILD% "%D%launcher\launcher.wixproj" /p:Platform=x86 %CERTOPTS% /p:ReleaseUri=%RELEASE_URI% - if errorlevel 1 exit /B %ERRORLEVEL% -) else if not exist "%Py_OutDir%win32\en-us\launcher.msi" ( - %MSBUILD% "%D%launcher\launcher.wixproj" /p:Platform=x86 %CERTOPTS% /p:ReleaseUri=%RELEASE_URI% - if errorlevel 1 exit /B %ERRORLEVEL% -) - -set BUILDOPTS=/p:Platform=%1 /p:BuildForRelease=true /p:DownloadUrl=%DOWNLOAD_URL% /p:DownloadUrlBase=%DOWNLOAD_URL_BASE% /p:ReleaseUri=%RELEASE_URI% -if defined BUILDMSI ( - %MSBUILD% "%D%bundle\releaselocal.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=true - if errorlevel 1 exit /B %ERRORLEVEL% -) - -if defined BUILDZIP ( - if "%BUILD_PLAT%" EQU "ARM64" ( - echo Skipping embeddable ZIP generation for ARM64 platform - ) else ( - %MSBUILD% "%D%make_zip.proj" /t:Build %BUILDOPTS% %CERTOPTS% /p:OutputPath="%BUILD%en-us" - if errorlevel 1 exit /B %ERRORLEVEL% - ) -) - -if defined BUILDNUGET ( - if "%BUILD_PLAT%" EQU "ARM64" ( - echo Skipping Nuget package generation for ARM64 platform - ) else ( - %MSBUILD% "%D%..\nuget\make_pkg.proj" /t:Build /p:Configuration=Release /p:Platform=%1 /p:OutputPath="%BUILD%en-us" - if errorlevel 1 exit /B %ERRORLEVEL% - ) -) - -if not "%OUTDIR%" EQU "" ( - mkdir "%OUTDIR%\%OUTDIR_PLAT%" - mkdir "%OUTDIR%\%OUTDIR_PLAT%\binaries" - mkdir "%OUTDIR%\%OUTDIR_PLAT%\symbols" - robocopy "%BUILD%en-us" "%OUTDIR%\%OUTDIR_PLAT%" /XF "*.wixpdb" - robocopy "%BUILD%\" "%OUTDIR%\%OUTDIR_PLAT%\binaries" *.exe *.dll *.pyd /XF "_test*" /XF "*_d.*" /XF "_freeze*" /XF "tcl*" /XF "tk*" /XF "*_test.*" - robocopy "%BUILD%\" "%OUTDIR%\%OUTDIR_PLAT%\symbols" *.pdb /XF "_test*" /XF "*_d.*" /XF "_freeze*" /XF "tcl*" /XF "tk*" /XF "*_test.*" -) - -exit /B 0 - -:Help -echo buildrelease.bat [--out DIR] [-x86] [-x64] [-arm64] [--certificate CERTNAME] [--build] [--pgo COMMAND] -echo [--skip-build] [--skip-doc] [--skip-nuget] [--skip-zip] [--skip-pgo] -echo [--download DOWNLOAD URL] [--test TARGETDIR] -echo [-h] -echo. -echo --out (-o) Specify an additional output directory for installers -echo -x86 Build x86 installers -echo -x64 Build x64 installers -echo -arm64 Build ARM64 installers -echo --build (-b) Incrementally build Python rather than rebuilding -echo --skip-build (-B) Do not build Python (just do the installers) -echo --skip-doc (-D) Do not build documentation -echo --pgo Specify PGO command for x64 installers -echo --skip-pgo Build x64 installers without using PGO -echo --skip-msi Do not build executable/MSI packages -echo --skip-nuget Do not build Nuget packages -echo --skip-zip Do not build embeddable package -echo --download Specify the full download URL for MSIs -echo --test Specify the test directory to run the installer tests -echo -h Display this help information -echo. -echo If no architecture is specified, all architectures will be built. -echo If --test is not specified, the installer tests are not run. -echo. -echo For the --pgo option, any Python command line can be used, or 'default' to -echo use the default task (-m test --pgo). -echo. -echo x86 and ARM64 builds will never use PGO. ARM64 builds will never generate -echo embeddable or Nuget packages. -echo. -echo The following substitutions will be applied to the download URL: -echo Variable Description Example -echo {version} version number 3.5.0 -echo {arch} architecture amd64, win32 -echo {releasename} release name a1, b2, rc3 (or blank for final) -echo {msi} MSI filename core.msi diff --git a/Tools/msi/bundle/Default.ARM64.xsl b/Tools/msi/bundle/Default.ARM64.xsl deleted file mode 100644 index b28b3f264adbc2d..000000000000000 --- a/Tools/msi/bundle/Default.ARM64.xsl +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/Default.thm b/Tools/msi/bundle/Default.thm deleted file mode 100644 index 6e908ac373442d9..000000000000000 --- a/Tools/msi/bundle/Default.thm +++ /dev/null @@ -1,141 +0,0 @@ - - - #(loc.Caption) - Segoe UI - Segoe UI - Segoe UI - Segoe UI - Segoe UI - Segoe UI - Segoe UI - - - #(loc.HelpHeader) - - - #(loc.HelpText) - - - - #(loc.InstallHeader) - - - #(loc.InstallMessage) - - #(loc.DeprecationMessage) - - - - - #(loc.ShortInstallLauncherAllUsersLabel) - #(loc.ShortPrependPathLabel) - - - - - #(loc.InstallUpgradeHeader) - - - #(loc.InstallUpgradeMessage) - - - - - - - - #(loc.InstallHeader) - - - - - - - - #(loc.Custom1Header) - - - #(loc.Include_docLabel) - #(loc.Include_docHelpLabel) - - #(loc.Include_pipLabel) - #(loc.Include_pipHelpLabel) - - #(loc.Include_tcltkLabel) - #(loc.Include_tcltkHelpLabel) - - #(loc.Include_testLabel) - #(loc.Include_testHelpLabel) - - #(loc.Include_launcherLabel) - #(loc.InstallLauncherAllUsersLabel) - - - - - - - - #(loc.Custom2Header) - - - #(loc.InstallAllUsersLabel) - #(loc.AssociateFilesLabel) - #(loc.ShortcutsLabel) - #(loc.PrependPathLabel) - #(loc.PrecompileLabel) - #(loc.Include_symbolsLabel) - #(loc.Include_debugLabel) - #(loc.Include_freethreadedLabel) - - #(loc.CustomLocationLabel) - - - #(loc.CustomLocationHelpLabel) - - - - - - - #(loc.ProgressHeader) - - - #(loc.ProgressLabel) - #(loc.OverallProgressPackageText) - - - - - #(loc.ModifyHeader) - - - - - - - - - - #(loc.SuccessHeader) - - - - - - - #(loc.SuccessRestartText) - - - - - #(loc.FailureHeader) - - - #(loc.FailureHyperlinkLogText) - - #(loc.FailureRestartText) - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/Default.wxl b/Tools/msi/bundle/Default.wxl deleted file mode 100644 index 335c1d922d97b52..000000000000000 --- a/Tools/msi/bundle/Default.wxl +++ /dev/null @@ -1,133 +0,0 @@ - - - [WixBundleName] Setup - Installing - Setup - Updating - Modify - Repairing - Repair - Removing - Uninstall - - You will be prompted for Administrator privileges to install a C Runtime Library update (KB2999226). - - -Continue? - - &Cancel - &Close - Install [WixBundleName] - Select Install Now to install Python with default settings, or choose Customize to enable or disable features. - Version [WixBundleVersion] - Upgrade to [WixBundleName] - Select Upgrade Now to keep your current settings, or choose Customize to enable or disable features. - Are you sure you want to cancel? - Previous version - Setup Help - Visit <a href="http://docs.python.org/[ShortVersion]/using/windows.html">docs.python.org/[ShortVersion]/using/windows.html</a> for the full list of options, including the ability to enable and disable specific features. - -"/passive" to display progress without requiring user interaction - -"/quiet" to install/uninstall without displaying any UI - -"/simple" to prevent user customization - -"/uninstall" to remove Python (without confirmation) - -"/layout [\[]directory[\]]" to pre-download all components - -"/log [\[]filename[\]]" to specify log files location - [WixBundleName] <a href="#">license terms</a>. - I &agree to the license terms and conditions - &Install Now - [TargetDir] - -Includes IDLE, pip and documentation -Creates shortcuts and file associations - C&ustomize installation - Choose location and features - &Install - Use settings preselected by your administrator - -[SimpleInstallDescription] - Up&grade Now - [TargetDir] - -Replaces your existing installation without changing settings. -Select Customize to review current options. - C&ustomize installation - Choose location and features - Optional Features - Advanced Options - Customize install location - You will require write permissions for the selected location. - &Install - &Next - &Back - B&rowse - &Documentation - Installs the Python documentation files. - &pip - Installs pip, which can download and install other Python packages. - Tcl/Tk, turtle and &IDLE - Installs tkinter, turtle and the IDLE development environment. - Python &test suite - Installs the standard library test suite. - py &launcher - Installs the global 'py' launcher to make it easier to start Python. - Use Programs and Features to remove the 'py' launcher. - Upgrades the global 'py' launcher from the previous version. - - Associate &files with Python (requires the 'py' launcher) - Create shortcuts for installed applications - Add Python to &environment variables - Add &python.exe to PATH - Append Python to &environment variables - Append &python.exe to PATH - Install Python [ShortVersion] for &all users - for &all users (requires admin privileges) - Use admin privi&leges when installing py.exe - Python Launcher is already installed - &Precompile standard library - Download debugging &symbols - Download debu&g binaries (requires VS 2017 or later) - Download &free-threaded binaries - - [ActionLikeInstallation] Progress - [ActionLikeInstalling]: - Initializing... - Modify Setup - &Modify - Add or remove individual features. - &Repair - Ensure all current features are correctly installed. - &Uninstall - Remove the entire [WixBundleName] installation. - [ActionLikeInstallation] was successful - &Launch - You may need to restart your computer to finish updating files. - &Restart - New to Python? Start with the <a href="https://docs.python.org/[ShortVersion]/tutorial/index.html">online tutorial</a> and <a href="https://docs.python.org/[ShortVersion]/index.html">documentation</a>. At your terminal, type "py" to launch Python, or search for Python in your Start menu. - -See <a href="https://docs.python.org/[ShortVersion]/whatsnew/[ShortVersion].html">what's new</a> in this release, or find more info about <a href="https://docs.python.org/[ShortVersion]/using/windows.html">using Python on Windows</a>. - Thank you for using [WixBundleName]. - Thank you for using [WixBundleName]. - -Feel free to post at <a href="https://discuss.python.org/c/users/7">discuss.python.org</a> if you continue to encounter issues. - Thank you for using [WixBundleName]. - -Feel free to post at <a href="https://discuss.python.org/c/users/7">discuss.python.org</a> if you encountered problems. - Setup failed - One or more issues caused the setup to fail. Please fix the issues and then retry setup. For more information see the <a href="#">log file</a>. - You must restart your computer to complete the rollback of the software. - &Restart - Unable to install [WixBundleName] due to an existing install. Use Programs and Features to modify, repair or remove [WixBundleName]. - At least Windows 10 or Windows Server 2016 are required to install [WixBundleName] - -Visit <a href="https://www.python.org/downloads/">python.org</a> to download an earlier version of Python. - Disable path length limit - Changes your machine configuration to allow programs, including Python, to bypass the 260 character "MAX_PATH" limitation. - - NOTE: This installer is being retired and will no longer be available after Python 3.15. <a href="https://docs.python.org/using/windows">More info</a> - diff --git a/Tools/msi/bundle/SideBar.png b/Tools/msi/bundle/SideBar.png deleted file mode 100644 index 52f15dd46c18fe5..000000000000000 Binary files a/Tools/msi/bundle/SideBar.png and /dev/null differ diff --git a/Tools/msi/bundle/bootstrap/LICENSE.txt b/Tools/msi/bundle/bootstrap/LICENSE.txt deleted file mode 100644 index 5791a7e81d74ff8..000000000000000 --- a/Tools/msi/bundle/bootstrap/LICENSE.txt +++ /dev/null @@ -1,25 +0,0 @@ -This license applies to the bootstrapper application that is embedded within the installer. It has no impact on the licensing for the rest of the installer or Python itself, as no code covered by this license exists in any other part of the product. - ---- - -Microsoft Reciprocal License (MS-RL) - -This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software. - -1. Definitions - The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law. - A "contribution" is the original software, or any additions or changes to the software. - A "contributor" is any person that distributes its contribution under this license. - "Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights - (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. - (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. - -3. Conditions and Limitations - (A) Reciprocal Grants- For any file you distribute that contains code from the software (in source code or binary format), you must provide recipients the source code to that file along with a copy of this license, which license will govern that file. You may license other files that are entirely your own work and do not contain code from the software under any terms you choose. - (B) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. - (C) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. - (D) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. - (E) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. - (F) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. diff --git a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp deleted file mode 100644 index 1e0df5084ff0795..000000000000000 --- a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp +++ /dev/null @@ -1,3323 +0,0 @@ -//------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2004, Outercurve Foundation. -// This software is released under Microsoft Reciprocal License (MS-RL). -// The license and further copyright text can be found in the file -// LICENSE.TXT at the root directory of the distribution. -// -//------------------------------------------------------------------------------------------------- - - -#include "pch.h" - -static const LPCWSTR PYBA_WINDOW_CLASS = L"PythonBA"; -static const DWORD PYBA_ACQUIRE_PERCENTAGE = 30; -static const LPCWSTR PYBA_VARIABLE_BUNDLE_FILE_VERSION = L"WixBundleFileVersion"; - -enum PYBA_STATE { - PYBA_STATE_INITIALIZING, - PYBA_STATE_INITIALIZED, - PYBA_STATE_HELP, - PYBA_STATE_DETECTING, - PYBA_STATE_DETECTED, - PYBA_STATE_PLANNING, - PYBA_STATE_PLANNED, - PYBA_STATE_APPLYING, - PYBA_STATE_CACHING, - PYBA_STATE_CACHED, - PYBA_STATE_EXECUTING, - PYBA_STATE_EXECUTED, - PYBA_STATE_APPLIED, - PYBA_STATE_FAILED, -}; - -static const int WM_PYBA_SHOW_HELP = WM_APP + 100; -static const int WM_PYBA_DETECT_PACKAGES = WM_APP + 101; -static const int WM_PYBA_PLAN_PACKAGES = WM_APP + 102; -static const int WM_PYBA_APPLY_PACKAGES = WM_APP + 103; -static const int WM_PYBA_CHANGE_STATE = WM_APP + 104; -static const int WM_PYBA_SHOW_FAILURE = WM_APP + 105; - -// This enum must be kept in the same order as the PAGE_NAMES array. -enum PAGE { - PAGE_LOADING, - PAGE_HELP, - PAGE_INSTALL, - PAGE_UPGRADE, - PAGE_SIMPLE_INSTALL, - PAGE_CUSTOM1, - PAGE_CUSTOM2, - PAGE_MODIFY, - PAGE_PROGRESS, - PAGE_PROGRESS_PASSIVE, - PAGE_SUCCESS, - PAGE_FAILURE, - COUNT_PAGE, -}; - -// This array must be kept in the same order as the PAGE enum. -static LPCWSTR PAGE_NAMES[] = { - L"Loading", - L"Help", - L"Install", - L"Upgrade", - L"SimpleInstall", - L"Custom1", - L"Custom2", - L"Modify", - L"Progress", - L"ProgressPassive", - L"Success", - L"Failure", -}; - -enum CONTROL_ID { - // Non-paged controls - ID_CLOSE_BUTTON = THEME_FIRST_ASSIGN_CONTROL_ID, - ID_MINIMIZE_BUTTON, - - // Welcome page - ID_INSTALL_BUTTON, - ID_INSTALL_CUSTOM_BUTTON, - ID_INSTALL_SIMPLE_BUTTON, - ID_INSTALL_UPGRADE_BUTTON, - ID_INSTALL_UPGRADE_CUSTOM_BUTTON, - ID_INSTALL_CANCEL_BUTTON, - ID_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX, - - // Customize Page - ID_TARGETDIR_EDITBOX, - ID_CUSTOM_ASSOCIATE_FILES_CHECKBOX, - ID_CUSTOM_INSTALL_ALL_USERS_CHECKBOX, - ID_CUSTOM_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX, - ID_CUSTOM_INCLUDE_LAUNCHER_HELP_LABEL, - ID_CUSTOM_COMPILE_ALL_CHECKBOX, - ID_CUSTOM_BROWSE_BUTTON, - ID_CUSTOM_BROWSE_BUTTON_LABEL, - ID_CUSTOM_INSTALL_BUTTON, - ID_CUSTOM_NEXT_BUTTON, - ID_CUSTOM1_BACK_BUTTON, - ID_CUSTOM2_BACK_BUTTON, - ID_CUSTOM1_CANCEL_BUTTON, - ID_CUSTOM2_CANCEL_BUTTON, - - // Modify page - ID_MODIFY_BUTTON, - ID_REPAIR_BUTTON, - ID_UNINSTALL_BUTTON, - ID_MODIFY_CANCEL_BUTTON, - - // Progress page - ID_CACHE_PROGRESS_PACKAGE_TEXT, - ID_CACHE_PROGRESS_BAR, - ID_CACHE_PROGRESS_TEXT, - - ID_EXECUTE_PROGRESS_PACKAGE_TEXT, - ID_EXECUTE_PROGRESS_BAR, - ID_EXECUTE_PROGRESS_TEXT, - ID_EXECUTE_PROGRESS_ACTIONDATA_TEXT, - - ID_OVERALL_PROGRESS_PACKAGE_TEXT, - ID_OVERALL_PROGRESS_BAR, - ID_OVERALL_CALCULATED_PROGRESS_BAR, - ID_OVERALL_PROGRESS_TEXT, - - ID_PROGRESS_CANCEL_BUTTON, - - // Success page - ID_SUCCESS_TEXT, - ID_SUCCESS_RESTART_TEXT, - ID_SUCCESS_RESTART_BUTTON, - ID_SUCCESS_CANCEL_BUTTON, - ID_SUCCESS_MAX_PATH_BUTTON, - - // Failure page - ID_FAILURE_LOGFILE_LINK, - ID_FAILURE_MESSAGE_TEXT, - ID_FAILURE_RESTART_TEXT, - ID_FAILURE_RESTART_BUTTON, - ID_FAILURE_CANCEL_BUTTON -}; - -static THEME_ASSIGN_CONTROL_ID CONTROL_ID_NAMES[] = { - { ID_CLOSE_BUTTON, L"CloseButton" }, - { ID_MINIMIZE_BUTTON, L"MinimizeButton" }, - - { ID_INSTALL_BUTTON, L"InstallButton" }, - { ID_INSTALL_CUSTOM_BUTTON, L"InstallCustomButton" }, - { ID_INSTALL_SIMPLE_BUTTON, L"InstallSimpleButton" }, - { ID_INSTALL_UPGRADE_BUTTON, L"InstallUpgradeButton" }, - { ID_INSTALL_UPGRADE_CUSTOM_BUTTON, L"InstallUpgradeCustomButton" }, - { ID_INSTALL_CANCEL_BUTTON, L"InstallCancelButton" }, - { ID_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX, L"InstallLauncherAllUsers" }, - - { ID_TARGETDIR_EDITBOX, L"TargetDir" }, - { ID_CUSTOM_ASSOCIATE_FILES_CHECKBOX, L"AssociateFiles" }, - { ID_CUSTOM_INSTALL_ALL_USERS_CHECKBOX, L"InstallAllUsers" }, - { ID_CUSTOM_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX, L"CustomInstallLauncherAllUsers" }, - { ID_CUSTOM_INCLUDE_LAUNCHER_HELP_LABEL, L"Include_launcherHelp" }, - { ID_CUSTOM_COMPILE_ALL_CHECKBOX, L"CompileAll" }, - { ID_CUSTOM_BROWSE_BUTTON, L"CustomBrowseButton" }, - { ID_CUSTOM_BROWSE_BUTTON_LABEL, L"CustomBrowseButtonLabel" }, - { ID_CUSTOM_INSTALL_BUTTON, L"CustomInstallButton" }, - { ID_CUSTOM_NEXT_BUTTON, L"CustomNextButton" }, - { ID_CUSTOM1_BACK_BUTTON, L"Custom1BackButton" }, - { ID_CUSTOM2_BACK_BUTTON, L"Custom2BackButton" }, - { ID_CUSTOM1_CANCEL_BUTTON, L"Custom1CancelButton" }, - { ID_CUSTOM2_CANCEL_BUTTON, L"Custom2CancelButton" }, - - { ID_MODIFY_BUTTON, L"ModifyButton" }, - { ID_REPAIR_BUTTON, L"RepairButton" }, - { ID_UNINSTALL_BUTTON, L"UninstallButton" }, - { ID_MODIFY_CANCEL_BUTTON, L"ModifyCancelButton" }, - - { ID_CACHE_PROGRESS_PACKAGE_TEXT, L"CacheProgressPackageText" }, - { ID_CACHE_PROGRESS_BAR, L"CacheProgressbar" }, - { ID_CACHE_PROGRESS_TEXT, L"CacheProgressText" }, - { ID_EXECUTE_PROGRESS_PACKAGE_TEXT, L"ExecuteProgressPackageText" }, - { ID_EXECUTE_PROGRESS_BAR, L"ExecuteProgressbar" }, - { ID_EXECUTE_PROGRESS_TEXT, L"ExecuteProgressText" }, - { ID_EXECUTE_PROGRESS_ACTIONDATA_TEXT, L"ExecuteProgressActionDataText" }, - { ID_OVERALL_PROGRESS_PACKAGE_TEXT, L"OverallProgressPackageText" }, - { ID_OVERALL_PROGRESS_BAR, L"OverallProgressbar" }, - { ID_OVERALL_CALCULATED_PROGRESS_BAR, L"OverallCalculatedProgressbar" }, - { ID_OVERALL_PROGRESS_TEXT, L"OverallProgressText" }, - { ID_PROGRESS_CANCEL_BUTTON, L"ProgressCancelButton" }, - - { ID_SUCCESS_TEXT, L"SuccessText" }, - { ID_SUCCESS_RESTART_TEXT, L"SuccessRestartText" }, - { ID_SUCCESS_RESTART_BUTTON, L"SuccessRestartButton" }, - { ID_SUCCESS_CANCEL_BUTTON, L"SuccessCancelButton" }, - { ID_SUCCESS_MAX_PATH_BUTTON, L"SuccessMaxPathButton" }, - - { ID_FAILURE_LOGFILE_LINK, L"FailureLogFileLink" }, - { ID_FAILURE_MESSAGE_TEXT, L"FailureMessageText" }, - { ID_FAILURE_RESTART_TEXT, L"FailureRestartText" }, - { ID_FAILURE_RESTART_BUTTON, L"FailureRestartButton" }, - { ID_FAILURE_CANCEL_BUTTON, L"FailureCancelButton" }, -}; - -static struct { LPCWSTR regName; LPCWSTR variableName; } OPTIONAL_FEATURES[] = { - { L"core_d", L"Include_debug" }, - { L"core_pdb", L"Include_symbols" }, - { L"dev", L"Include_dev" }, - { L"doc", L"Include_doc" }, - { L"exe", L"Include_exe" }, - { L"lib", L"Include_lib" }, - { L"path", L"PrependPath" }, - { L"appendpath", L"AppendPath" }, - { L"pip", L"Include_pip" }, - { L"tcltk", L"Include_tcltk" }, - { L"test", L"Include_test" }, - { L"tools", L"Include_tools" }, - { L"Shortcuts", L"Shortcuts" }, - // Include_launcher and AssociateFiles are handled separately and so do - // not need to be included in this list. - { L"freethreaded", L"Include_freethreaded" }, - { nullptr, nullptr } -}; - - - -class PythonBootstrapperApplication : public CBalBaseBootstrapperApplication { - void ShowPage(DWORD newPageId) { - // Process each control for special handling in the new page. - ProcessPageControls(ThemeGetPage(_theme, newPageId)); - - // Enable disable controls per-page. - if (_pageIds[PAGE_INSTALL] == newPageId || - _pageIds[PAGE_SIMPLE_INSTALL] == newPageId || - _pageIds[PAGE_UPGRADE] == newPageId) { - InstallPage_Show(); - } else if (_pageIds[PAGE_CUSTOM1] == newPageId) { - Custom1Page_Show(); - } else if (_pageIds[PAGE_CUSTOM2] == newPageId) { - Custom2Page_Show(); - } else if (_pageIds[PAGE_MODIFY] == newPageId) { - ModifyPage_Show(); - } else if (_pageIds[PAGE_SUCCESS] == newPageId) { - SuccessPage_Show(); - } else if (_pageIds[PAGE_FAILURE] == newPageId) { - FailurePage_Show(); - } - - // Prevent repainting while switching page to avoid ugly flickering - _suppressPaint = TRUE; - ThemeShowPage(_theme, newPageId, SW_SHOW); - ThemeShowPage(_theme, _visiblePageId, SW_HIDE); - _suppressPaint = FALSE; - InvalidateRect(_theme->hwndParent, nullptr, TRUE); - _visiblePageId = newPageId; - - // On the install page set the focus to the install button or - // the next enabled control if install is disabled - if (_pageIds[PAGE_INSTALL] == newPageId) { - ThemeSetFocus(_theme, ID_INSTALL_BUTTON); - } else if (_pageIds[PAGE_SIMPLE_INSTALL] == newPageId) { - ThemeSetFocus(_theme, ID_INSTALL_SIMPLE_BUTTON); - } - } - - // - // Handles control clicks - // - void OnCommand(CONTROL_ID id) { - LPWSTR defaultDir = nullptr; - LPWSTR targetDir = nullptr; - LONGLONG elevated, crtInstalled, installAllUsers; - BOOL checked, launcherChecked; - WCHAR wzPath[MAX_PATH] = { }; - BROWSEINFOW browseInfo = { }; - PIDLIST_ABSOLUTE pidl = nullptr; - DWORD pageId; - HRESULT hr = S_OK; - - switch(id) { - case ID_CLOSE_BUTTON: - OnClickCloseButton(); - break; - - // Install commands - case ID_INSTALL_SIMPLE_BUTTON: __fallthrough; - case ID_INSTALL_UPGRADE_BUTTON: __fallthrough; - case ID_INSTALL_BUTTON: - SavePageSettings(); - - hr = BalGetNumericVariable(L"InstallAllUsers", &installAllUsers); - ExitOnFailure(hr, L"Failed to get install scope"); - - hr = _engine->SetVariableNumeric(L"CompileAll", installAllUsers); - ExitOnFailure(hr, L"Failed to update CompileAll"); - - hr = EnsureTargetDir(); - ExitOnFailure(hr, L"Failed to set TargetDir"); - - OnPlan(BOOTSTRAPPER_ACTION_INSTALL); - break; - - case ID_CUSTOM1_BACK_BUTTON: - SavePageSettings(); - if (_modifying) { - GoToPage(PAGE_MODIFY); - } else if (_upgrading) { - GoToPage(PAGE_UPGRADE); - } else { - GoToPage(PAGE_INSTALL); - } - break; - - case ID_INSTALL_CUSTOM_BUTTON: __fallthrough; - case ID_INSTALL_UPGRADE_CUSTOM_BUTTON: __fallthrough; - case ID_CUSTOM2_BACK_BUTTON: - SavePageSettings(); - GoToPage(PAGE_CUSTOM1); - break; - - case ID_CUSTOM_NEXT_BUTTON: - SavePageSettings(); - GoToPage(PAGE_CUSTOM2); - break; - - case ID_CUSTOM_INSTALL_BUTTON: - SavePageSettings(); - - hr = EnsureTargetDir(); - ExitOnFailure(hr, L"Failed to set TargetDir"); - - hr = BalGetStringVariable(L"TargetDir", &targetDir); - if (SUCCEEDED(hr)) { - // TODO: Check whether directory exists and contains another installation - ReleaseStr(targetDir); - } - - OnPlan(_command.action); - break; - - case ID_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX: - checked = ThemeIsControlChecked(_theme, ID_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX); - _engine->SetVariableNumeric(L"InstallLauncherAllUsers", checked); - - ThemeControlElevates(_theme, ID_INSTALL_BUTTON, WillElevate()); - break; - - case ID_CUSTOM_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX: - checked = ThemeIsControlChecked(_theme, ID_CUSTOM_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX); - _engine->SetVariableNumeric(L"InstallLauncherAllUsers", checked); - - ThemeControlElevates(_theme, ID_CUSTOM_INSTALL_BUTTON, WillElevate()); - break; - - case ID_CUSTOM_INSTALL_ALL_USERS_CHECKBOX: - checked = ThemeIsControlChecked(_theme, ID_CUSTOM_INSTALL_ALL_USERS_CHECKBOX); - _engine->SetVariableNumeric(L"InstallAllUsers", checked); - - ThemeControlElevates(_theme, ID_CUSTOM_INSTALL_BUTTON, WillElevate()); - ThemeControlEnable(_theme, ID_CUSTOM_BROWSE_BUTTON_LABEL, !checked); - if (checked) { - _engine->SetVariableNumeric(L"CompileAll", 1); - ThemeSendControlMessage(_theme, ID_CUSTOM_COMPILE_ALL_CHECKBOX, BM_SETCHECK, BST_CHECKED, 0); - } - ThemeGetTextControl(_theme, ID_TARGETDIR_EDITBOX, &targetDir); - if (targetDir) { - // Check the current value against the default to see - // if we should switch it automatically. - hr = BalGetStringVariable( - checked ? L"DefaultJustForMeTargetDir" : L"DefaultAllUsersTargetDir", - &defaultDir - ); - - if (SUCCEEDED(hr) && defaultDir) { - LPWSTR formatted = nullptr; - if (defaultDir[0] && SUCCEEDED(BalFormatString(defaultDir, &formatted))) { - if (wcscmp(formatted, targetDir) == 0) { - ReleaseStr(defaultDir); - defaultDir = nullptr; - ReleaseStr(formatted); - formatted = nullptr; - - hr = BalGetStringVariable( - checked ? L"DefaultAllUsersTargetDir" : L"DefaultJustForMeTargetDir", - &defaultDir - ); - if (SUCCEEDED(hr) && defaultDir && defaultDir[0] && SUCCEEDED(BalFormatString(defaultDir, &formatted))) { - ThemeSetTextControl(_theme, ID_TARGETDIR_EDITBOX, formatted); - ReleaseStr(formatted); - } - } else { - ReleaseStr(formatted); - } - } - - ReleaseStr(defaultDir); - } - } - break; - - case ID_CUSTOM_BROWSE_BUTTON: - browseInfo.hwndOwner = _hWnd; - browseInfo.pszDisplayName = wzPath; - browseInfo.lpszTitle = _theme->sczCaption; - browseInfo.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI; - pidl = ::SHBrowseForFolderW(&browseInfo); - if (pidl && ::SHGetPathFromIDListW(pidl, wzPath)) { - ThemeSetTextControl(_theme, ID_TARGETDIR_EDITBOX, wzPath); - } - - if (pidl) { - ::CoTaskMemFree(pidl); - } - break; - - // Modify commands - case ID_MODIFY_BUTTON: - // Some variables cannot be modified - _engine->SetVariableString(L"InstallAllUsersState", L"disable"); - _engine->SetVariableString(L"InstallLauncherAllUsersState", L"disable"); - _engine->SetVariableString(L"TargetDirState", L"disable"); - _engine->SetVariableString(L"CustomBrowseButtonState", L"disable"); - _modifying = TRUE; - GoToPage(PAGE_CUSTOM1); - break; - - case ID_REPAIR_BUTTON: - OnPlan(BOOTSTRAPPER_ACTION_REPAIR); - break; - - case ID_UNINSTALL_BUTTON: - OnPlan(BOOTSTRAPPER_ACTION_UNINSTALL); - break; - - case ID_SUCCESS_MAX_PATH_BUTTON: - EnableMaxPathSupport(); - ThemeControlEnable(_theme, ID_SUCCESS_MAX_PATH_BUTTON, FALSE); - break; - } - - LExit: - return; - } - - void InstallPage_Show() { - // Ensure the All Users install button has a UAC shield - BOOL elevated = WillElevate(); - ThemeControlElevates(_theme, ID_INSTALL_BUTTON, elevated); - ThemeControlElevates(_theme, ID_INSTALL_SIMPLE_BUTTON, elevated); - ThemeControlElevates(_theme, ID_INSTALL_UPGRADE_BUTTON, elevated); - - LONGLONG blockedLauncher; - if (SUCCEEDED(BalGetNumericVariable(L"BlockedLauncher", &blockedLauncher)) && blockedLauncher) { - LOC_STRING *pLocString = nullptr; - if (SUCCEEDED(LocGetString(_wixLoc, L"#(loc.ShortInstallLauncherBlockedLabel)", &pLocString)) && pLocString) { - ThemeSetTextControl(_theme, ID_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX, pLocString->wzText); - } - } - } - - void Custom1Page_Show() { - LONGLONG installLauncherAllUsers; - - if (FAILED(BalGetNumericVariable(L"InstallLauncherAllUsers", &installLauncherAllUsers))) { - installLauncherAllUsers = 0; - } - - ThemeSendControlMessage(_theme, ID_CUSTOM_INSTALL_LAUNCHER_ALL_USERS_CHECKBOX, BM_SETCHECK, - installLauncherAllUsers ? BST_CHECKED : BST_UNCHECKED, 0); - - LOC_STRING *pLocString = nullptr; - LPCWSTR locKey = L"#(loc.Include_launcherHelp)"; - LONGLONG blockedLauncher; - - if (SUCCEEDED(BalGetNumericVariable(L"BlockedLauncher", &blockedLauncher)) && blockedLauncher) { - locKey = L"#(loc.Include_launcherRemove)"; - } else if (SUCCEEDED(BalGetNumericVariable(L"DetectedOldLauncher", &blockedLauncher)) && blockedLauncher) { - locKey = L"#(loc.Include_launcherUpgrade)"; - } - - if (SUCCEEDED(LocGetString(_wixLoc, locKey, &pLocString)) && pLocString) { - ThemeSetTextControl(_theme, ID_CUSTOM_INCLUDE_LAUNCHER_HELP_LABEL, pLocString->wzText); - } - } - - void Custom2Page_Show() { - HRESULT hr; - LONGLONG installAll, includeLauncher; - - if (FAILED(BalGetNumericVariable(L"InstallAllUsers", &installAll))) { - installAll = 0; - } - - if (WillElevate()) { - ThemeControlElevates(_theme, ID_CUSTOM_INSTALL_BUTTON, TRUE); - ThemeShowControl(_theme, ID_CUSTOM_BROWSE_BUTTON_LABEL, SW_HIDE); - } else { - ThemeControlElevates(_theme, ID_CUSTOM_INSTALL_BUTTON, FALSE); - ThemeShowControl(_theme, ID_CUSTOM_BROWSE_BUTTON_LABEL, SW_SHOW); - } - - if (SUCCEEDED(BalGetNumericVariable(L"Include_launcher", &includeLauncher)) && includeLauncher) { - ThemeControlEnable(_theme, ID_CUSTOM_ASSOCIATE_FILES_CHECKBOX, TRUE); - } else { - ThemeSendControlMessage(_theme, ID_CUSTOM_ASSOCIATE_FILES_CHECKBOX, BM_SETCHECK, BST_UNCHECKED, 0); - ThemeControlEnable(_theme, ID_CUSTOM_ASSOCIATE_FILES_CHECKBOX, FALSE); - } - - LPWSTR targetDir = nullptr; - hr = BalGetStringVariable(L"TargetDir", &targetDir); - if (SUCCEEDED(hr) && targetDir && targetDir[0]) { - ThemeSetTextControl(_theme, ID_TARGETDIR_EDITBOX, targetDir); - StrFree(targetDir); - } else if (SUCCEEDED(hr)) { - StrFree(targetDir); - targetDir = nullptr; - - LPWSTR defaultTargetDir = nullptr; - hr = BalGetStringVariable(L"DefaultCustomTargetDir", &defaultTargetDir); - if (SUCCEEDED(hr) && defaultTargetDir && !defaultTargetDir[0]) { - StrFree(defaultTargetDir); - defaultTargetDir = nullptr; - - hr = BalGetStringVariable( - installAll ? L"DefaultAllUsersTargetDir" : L"DefaultJustForMeTargetDir", - &defaultTargetDir - ); - } - if (SUCCEEDED(hr) && defaultTargetDir) { - if (defaultTargetDir[0] && SUCCEEDED(BalFormatString(defaultTargetDir, &targetDir))) { - ThemeSetTextControl(_theme, ID_TARGETDIR_EDITBOX, targetDir); - StrFree(targetDir); - } - StrFree(defaultTargetDir); - } - } - } - - void ModifyPage_Show() { - ThemeControlEnable(_theme, ID_REPAIR_BUTTON, !_suppressRepair); - } - - void SuccessPage_Show() { - // on the "Success" page, check if the restart button should be enabled. - BOOL showRestartButton = FALSE; - LOC_STRING *successText = nullptr; - HRESULT hr = S_OK; - - if (_restartRequired) { - if (BOOTSTRAPPER_RESTART_PROMPT == _command.restart) { - showRestartButton = TRUE; - } - } - - switch (_plannedAction) { - case BOOTSTRAPPER_ACTION_INSTALL: - hr = LocGetString(_wixLoc, L"#(loc.SuccessInstallMessage)", &successText); - break; - case BOOTSTRAPPER_ACTION_MODIFY: - hr = LocGetString(_wixLoc, L"#(loc.SuccessModifyMessage)", &successText); - break; - case BOOTSTRAPPER_ACTION_REPAIR: - hr = LocGetString(_wixLoc, L"#(loc.SuccessRepairMessage)", &successText); - break; - case BOOTSTRAPPER_ACTION_UNINSTALL: - hr = LocGetString(_wixLoc, L"#(loc.SuccessRemoveMessage)", &successText); - break; - } - - if (successText) { - LPWSTR formattedString = nullptr; - BalFormatString(successText->wzText, &formattedString); - if (formattedString) { - ThemeSetTextControl(_theme, ID_SUCCESS_TEXT, formattedString); - StrFree(formattedString); - } - } - - ThemeControlEnable(_theme, ID_SUCCESS_RESTART_TEXT, showRestartButton); - ThemeControlEnable(_theme, ID_SUCCESS_RESTART_BUTTON, showRestartButton); - - if (_command.action != BOOTSTRAPPER_ACTION_INSTALL || - !IsWindowsVersionOrGreater(10, 0, 0)) { - ThemeControlEnable(_theme, ID_SUCCESS_MAX_PATH_BUTTON, FALSE); - } else { - DWORD dataType = 0, buffer = 0, bufferLen = sizeof(buffer); - HKEY hKey; - LRESULT res = RegOpenKeyExW( - HKEY_LOCAL_MACHINE, - L"SYSTEM\\CurrentControlSet\\Control\\FileSystem", - 0, - KEY_READ, - &hKey - ); - if (res == ERROR_SUCCESS) { - res = RegQueryValueExW(hKey, L"LongPathsEnabled", nullptr, &dataType, - (LPBYTE)&buffer, &bufferLen); - RegCloseKey(hKey); - } - else { - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Failed to open SYSTEM\\CurrentControlSet\\Control\\FileSystem: error code %d", res); - } - if (res == ERROR_SUCCESS && dataType == REG_DWORD && buffer == 0) { - ThemeControlElevates(_theme, ID_SUCCESS_MAX_PATH_BUTTON, TRUE); - } - else { - if (res == ERROR_SUCCESS) - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Failed to read LongPathsEnabled value: error code %d", res); - else - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Hiding MAX_PATH button because it is already enabled"); - ThemeControlEnable(_theme, ID_SUCCESS_MAX_PATH_BUTTON, FALSE); - } - } - } - - void FailurePage_Show() { - // on the "Failure" page, show error message and check if the restart button should be enabled. - - // if there is a log file variable then we'll assume the log file exists. - BOOL showLogLink = (_bundle.sczLogVariable && *_bundle.sczLogVariable); - BOOL showErrorMessage = FALSE; - BOOL showRestartButton = FALSE; - - if (FAILED(_hrFinal)) { - LPWSTR unformattedText = nullptr; - LPWSTR text = nullptr; - - // If we know the failure message, use that. - if (_failedMessage && *_failedMessage) { - StrAllocString(&unformattedText, _failedMessage, 0); - } else { - // try to get the error message from the error code. - StrAllocFromError(&unformattedText, _hrFinal, nullptr); - if (!unformattedText || !*unformattedText) { - StrAllocFromError(&unformattedText, E_FAIL, nullptr); - } - } - - if (E_WIXSTDBA_CONDITION_FAILED == _hrFinal) { - if (unformattedText) { - StrAllocString(&text, unformattedText, 0); - } - } else { - StrAllocFormatted(&text, L"0x%08x - %ls", _hrFinal, unformattedText); - } - - if (text) { - ThemeSetTextControl(_theme, ID_FAILURE_MESSAGE_TEXT, text); - showErrorMessage = TRUE; - } - - ReleaseStr(text); - ReleaseStr(unformattedText); - } - - if (_restartRequired && BOOTSTRAPPER_RESTART_PROMPT == _command.restart) { - showRestartButton = TRUE; - } - - ThemeControlEnable(_theme, ID_FAILURE_LOGFILE_LINK, showLogLink); - ThemeControlEnable(_theme, ID_FAILURE_MESSAGE_TEXT, showErrorMessage); - ThemeControlEnable(_theme, ID_FAILURE_RESTART_TEXT, showRestartButton); - ThemeControlEnable(_theme, ID_FAILURE_RESTART_BUTTON, showRestartButton); - } - - static void EnableMaxPathSupport() { - LPWSTR targetDir = nullptr, defaultDir = nullptr; - HRESULT hr = BalGetStringVariable(L"TargetDir", &targetDir); - if (FAILED(hr) || !targetDir || !targetDir[0]) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Failed to get TargetDir"); - return; - } - - LPWSTR pythonw = nullptr; - StrAllocFormatted(&pythonw, L"%ls\\pythonw.exe", targetDir); - if (!pythonw || !pythonw[0]) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Failed to construct pythonw.exe path"); - return; - } - - LPCWSTR arguments = L"-c \"import winreg; " - "winreg.SetValueEx(" - "winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, " - "r'SYSTEM\\CurrentControlSet\\Control\\FileSystem'), " - "'LongPathsEnabled', " - "None, " - "winreg.REG_DWORD, " - "1" - ")\""; - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Executing %ls %ls", pythonw, arguments); - HINSTANCE res = ShellExecuteW(0, L"runas", pythonw, arguments, NULL, SW_HIDE); - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "return code 0x%08x", res); - } - -public: // IBootstrapperApplication - virtual STDMETHODIMP OnStartup() { - HRESULT hr = S_OK; - DWORD dwUIThreadId = 0; - - // create UI thread - _hUiThread = ::CreateThread(nullptr, 0, UiThreadProc, this, 0, &dwUIThreadId); - if (!_hUiThread) { - ExitWithLastError(hr, "Failed to create UI thread."); - } - - LExit: - return hr; - } - - - virtual STDMETHODIMP_(int) OnShutdown() { - int nResult = IDNOACTION; - - // wait for UI thread to terminate - if (_hUiThread) { - ::WaitForSingleObject(_hUiThread, INFINITE); - ReleaseHandle(_hUiThread); - } - - // If a restart was required. - if (_restartRequired && _allowRestart) { - nResult = IDRESTART; - } - - return nResult; - } - - virtual STDMETHODIMP_(int) OnDetectRelatedMsiPackage( - __in_z LPCWSTR wzPackageId, - __in_z LPCWSTR /*wzProductCode*/, - __in BOOL fPerMachine, - __in DWORD64 /*dw64Version*/, - __in BOOTSTRAPPER_RELATED_OPERATION operation - ) { - // Only check launcher_AllUsers because we'll find the same packages - // twice if we check launcher_JustForMe as well. - if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPackageId, -1, L"launcher_AllUsers", -1)) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Detected existing launcher install"); - - LONGLONG blockedLauncher, detectedLauncher; - if (FAILED(BalGetNumericVariable(L"BlockedLauncher", &blockedLauncher))) { - blockedLauncher = 0; - } - - // Get the prior DetectedLauncher value so we can see if we've - // detected more than one, and then update the stored variable - // (we use the original value later on via the local). - if (FAILED(BalGetNumericVariable(L"DetectedLauncher", &detectedLauncher))) { - detectedLauncher = 0; - } - if (!detectedLauncher) { - _engine->SetVariableNumeric(L"DetectedLauncher", 1); - } - - if (blockedLauncher) { - // Nothing else to do, we're already blocking - } - else if (BOOTSTRAPPER_RELATED_OPERATION_DOWNGRADE == operation) { - // Found a higher version, so we can't install ours. - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Higher version launcher has been detected."); - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Launcher will not be installed"); - _engine->SetVariableNumeric(L"BlockedLauncher", 1); - } - else if (detectedLauncher) { - if (!blockedLauncher) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Multiple launcher installs have been detected."); - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "No launcher will be installed or upgraded until one has been removed."); - _engine->SetVariableNumeric(L"BlockedLauncher", 1); - } - } - else if (BOOTSTRAPPER_RELATED_OPERATION_MAJOR_UPGRADE == operation) { - // Found an older version, so let's run the equivalent as an upgrade - // This overrides "unknown" all users options, but will leave alone - // any that have already been set/detected. - // User can deselect the option to include the launcher, but cannot - // change it from the current per user/machine setting. - LONGLONG includeLauncher, includeLauncherAllUsers; - if (FAILED(BalGetNumericVariable(L"Include_launcher", &includeLauncher))) { - includeLauncher = -1; - } - if (FAILED(BalGetNumericVariable(L"InstallLauncherAllUsers", &includeLauncherAllUsers))) { - includeLauncherAllUsers = -1; - } - - if (includeLauncher < 0) { - _engine->SetVariableNumeric(L"Include_launcher", 1); - } - if (includeLauncherAllUsers < 0) { - _engine->SetVariableNumeric(L"InstallLauncherAllUsers", fPerMachine ? 1 : 0); - } else if (includeLauncherAllUsers != fPerMachine ? 1 : 0) { - // Requested AllUsers option is inconsistent, so block - _engine->SetVariableNumeric(L"BlockedLauncher", 1); - } - _engine->SetVariableNumeric(L"DetectedOldLauncher", 1); - } - } - return CheckCanceled() ? IDCANCEL : IDNOACTION; - } - - virtual STDMETHODIMP_(int) OnDetectRelatedBundle( - __in LPCWSTR wzBundleId, - __in BOOTSTRAPPER_RELATION_TYPE relationType, - __in LPCWSTR /*wzBundleTag*/, - __in BOOL fPerMachine, - __in DWORD64 /*dw64Version*/, - __in BOOTSTRAPPER_RELATED_OPERATION operation - ) { - BalInfoAddRelatedBundleAsPackage(&_bundle.packages, wzBundleId, relationType, fPerMachine); - - // Remember when our bundle would cause a downgrade. - if (BOOTSTRAPPER_RELATED_OPERATION_DOWNGRADE == operation) { - _downgradingOtherVersion = TRUE; - } else if (BOOTSTRAPPER_RELATED_OPERATION_MAJOR_UPGRADE == operation) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Detected previous version - planning upgrade"); - _upgrading = TRUE; - - LoadOptionalFeatureStates(_engine); - } else if (BOOTSTRAPPER_RELATED_OPERATION_NONE == operation) { - if (_command.action == BOOTSTRAPPER_ACTION_INSTALL) { - LOC_STRING *pLocString = nullptr; - if (SUCCEEDED(LocGetString(_wixLoc, L"#(loc.FailureExistingInstall)", &pLocString)) && pLocString) { - BalFormatString(pLocString->wzText, &_failedMessage); - } else { - BalFormatString(L"Cannot install [WixBundleName] because it is already installed.", &_failedMessage); - } - BalLog( - BOOTSTRAPPER_LOG_LEVEL_ERROR, - "Related bundle %ls is preventing install", - wzBundleId - ); - SetState(PYBA_STATE_FAILED, E_WIXSTDBA_CONDITION_FAILED); - } - } - - return CheckCanceled() ? IDCANCEL : IDOK; - } - - - virtual STDMETHODIMP_(void) OnDetectPackageComplete( - __in LPCWSTR wzPackageId, - __in HRESULT hrStatus, - __in BOOTSTRAPPER_PACKAGE_STATE state - ) { } - - - virtual STDMETHODIMP_(void) OnDetectComplete(__in HRESULT hrStatus) { - if (SUCCEEDED(hrStatus) && _baFunction) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Running detect complete BA function"); - _baFunction->OnDetectComplete(); - } - - if (SUCCEEDED(hrStatus)) { - // Update launcher install states - // If we didn't detect any existing installs, Include_launcher and - // InstallLauncherAllUsers will both be -1, so we will set to their - // defaults and leave the options enabled. - // Otherwise, if we detected an existing install, we disable the - // options so they remain fixed. - // The code in OnDetectRelatedMsiPackage is responsible for figuring - // out whether existing installs are compatible with the settings in - // place during detection. - LONGLONG blockedLauncher; - if (SUCCEEDED(BalGetNumericVariable(L"BlockedLauncher", &blockedLauncher)) - && blockedLauncher) { - _engine->SetVariableNumeric(L"Include_launcher", 0); - _engine->SetVariableNumeric(L"InstallLauncherAllUsers", 0); - _engine->SetVariableString(L"InstallLauncherAllUsersState", L"disable"); - _engine->SetVariableString(L"Include_launcherState", L"disable"); - } - else { - LONGLONG includeLauncher, includeLauncherAllUsers, associateFiles; - - if (FAILED(BalGetNumericVariable(L"Include_launcher", &includeLauncher))) { - includeLauncher = -1; - } - if (FAILED(BalGetNumericVariable(L"InstallLauncherAllUsers", &includeLauncherAllUsers))) { - includeLauncherAllUsers = -1; - } - if (FAILED(BalGetNumericVariable(L"AssociateFiles", &associateFiles))) { - associateFiles = -1; - } - - if (includeLauncherAllUsers < 0) { - includeLauncherAllUsers = 0; - _engine->SetVariableNumeric(L"InstallLauncherAllUsers", includeLauncherAllUsers); - } - - if (includeLauncher < 0) { - if (BOOTSTRAPPER_ACTION_LAYOUT == _command.action || - (BOOTSTRAPPER_ACTION_INSTALL == _command.action && !_upgrading)) { - // When installing/downloading, we include the launcher - // (though downloads should ignore this setting anyway) - _engine->SetVariableNumeric(L"Include_launcher", 1); - } else { - // Any other action, we should have detected an existing - // install (e.g. on remove/modify), so if we didn't, we - // assume it's not selected. - _engine->SetVariableNumeric(L"Include_launcher", 0); - _engine->SetVariableNumeric(L"AssociateFiles", 0); - } - } - - if (associateFiles < 0) { - auto hr = LoadAssociateFilesStateFromKey( - _engine, - includeLauncherAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER - ); - if (FAILED(hr)) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Failed to load AssociateFiles state: error code 0x%08X", hr); - } else if (hr == S_OK) { - associateFiles = 1; - } - _engine->SetVariableNumeric(L"AssociateFiles", associateFiles); - } - } - } - - if (SUCCEEDED(hrStatus)) { - hrStatus = EvaluateConditions(); - } - - if (SUCCEEDED(hrStatus)) { - // Ensure the default path has been set - hrStatus = EnsureTargetDir(); - } - - SetState(PYBA_STATE_DETECTED, hrStatus); - - // If we're not interacting with the user or we're doing a layout or we're just after a force restart - // then automatically start planning. - if (BOOTSTRAPPER_DISPLAY_FULL > _command.display || - BOOTSTRAPPER_ACTION_LAYOUT == _command.action || - BOOTSTRAPPER_ACTION_UNINSTALL == _command.action || - BOOTSTRAPPER_RESUME_TYPE_REBOOT == _command.resumeType) { - if (SUCCEEDED(hrStatus)) { - ::PostMessageW(_hWnd, WM_PYBA_PLAN_PACKAGES, 0, _command.action); - } - } - } - - - virtual STDMETHODIMP_(int) OnPlanRelatedBundle( - __in_z LPCWSTR /*wzBundleId*/, - __inout_z BOOTSTRAPPER_REQUEST_STATE* pRequestedState - ) { - return CheckCanceled() ? IDCANCEL : IDOK; - } - - - virtual STDMETHODIMP_(int) OnPlanPackageBegin( - __in_z LPCWSTR wzPackageId, - __inout BOOTSTRAPPER_REQUEST_STATE *pRequestState - ) { - HRESULT hr = S_OK; - BAL_INFO_PACKAGE* pPackage = nullptr; - - if (_nextPackageAfterRestart) { - // After restart we need to finish the dependency registration for our package so allow the package - // to go present. - if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPackageId, -1, _nextPackageAfterRestart, -1)) { - // Do not allow a repair because that could put us in a perpetual restart loop. - if (BOOTSTRAPPER_REQUEST_STATE_REPAIR == *pRequestState) { - *pRequestState = BOOTSTRAPPER_REQUEST_STATE_PRESENT; - } - - ReleaseNullStr(_nextPackageAfterRestart); // no more skipping now. - } else { - // not the matching package, so skip it. - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Skipping package: %ls, after restart because it was applied before the restart.", wzPackageId); - - *pRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE; - } - } else if ((_plannedAction == BOOTSTRAPPER_ACTION_INSTALL || _plannedAction == BOOTSTRAPPER_ACTION_MODIFY) && - SUCCEEDED(BalInfoFindPackageById(&_bundle.packages, wzPackageId, &pPackage))) { - BOOL f = FALSE; - if (SUCCEEDED(_engine->EvaluateCondition(pPackage->sczInstallCondition, &f)) && f) { - *pRequestState = BOOTSTRAPPER_REQUEST_STATE_PRESENT; - } - } - - return CheckCanceled() ? IDCANCEL : IDOK; - } - - virtual STDMETHODIMP_(int) OnPlanMsiFeature( - __in_z LPCWSTR wzPackageId, - __in_z LPCWSTR wzFeatureId, - __inout BOOTSTRAPPER_FEATURE_STATE* pRequestedState - ) { - LONGLONG install; - - if (wcscmp(wzFeatureId, L"AssociateFiles") == 0 || wcscmp(wzFeatureId, L"Shortcuts") == 0) { - if (SUCCEEDED(_engine->GetVariableNumeric(wzFeatureId, &install)) && install) { - *pRequestedState = BOOTSTRAPPER_FEATURE_STATE_LOCAL; - } else { - *pRequestedState = BOOTSTRAPPER_FEATURE_STATE_ABSENT; - } - } else { - *pRequestedState = BOOTSTRAPPER_FEATURE_STATE_LOCAL; - } - return CheckCanceled() ? IDCANCEL : IDNOACTION; - } - - virtual STDMETHODIMP_(void) OnPlanComplete(__in HRESULT hrStatus) { - if (SUCCEEDED(hrStatus) && _baFunction) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Running plan complete BA function"); - _baFunction->OnPlanComplete(); - } - - SetState(PYBA_STATE_PLANNED, hrStatus); - - if (SUCCEEDED(hrStatus)) { - ::PostMessageW(_hWnd, WM_PYBA_APPLY_PACKAGES, 0, 0); - } - - _startedExecution = FALSE; - _calculatedCacheProgress = 0; - _calculatedExecuteProgress = 0; - } - - - virtual STDMETHODIMP_(int) OnCachePackageBegin( - __in_z LPCWSTR wzPackageId, - __in DWORD cCachePayloads, - __in DWORD64 dw64PackageCacheSize - ) { - if (wzPackageId && *wzPackageId) { - BAL_INFO_PACKAGE* pPackage = nullptr; - HRESULT hr = BalInfoFindPackageById(&_bundle.packages, wzPackageId, &pPackage); - LPCWSTR wz = (SUCCEEDED(hr) && pPackage->sczDisplayName) ? pPackage->sczDisplayName : wzPackageId; - - ThemeSetTextControl(_theme, ID_CACHE_PROGRESS_PACKAGE_TEXT, wz); - - // If something started executing, leave it in the overall progress text. - if (!_startedExecution) { - ThemeSetTextControl(_theme, ID_OVERALL_PROGRESS_PACKAGE_TEXT, wz); - } - } - - return __super::OnCachePackageBegin(wzPackageId, cCachePayloads, dw64PackageCacheSize); - } - - - virtual STDMETHODIMP_(int) OnCacheAcquireProgress( - __in_z LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in DWORD64 dw64Progress, - __in DWORD64 dw64Total, - __in DWORD dwOverallPercentage - ) { - WCHAR wzProgress[5] = { }; - -#ifdef DEBUG - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "PYBA: OnCacheAcquireProgress() - container/package: %ls, payload: %ls, progress: %I64u, total: %I64u, overall progress: %u%%", wzPackageOrContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage); -#endif - - ::StringCchPrintfW(wzProgress, countof(wzProgress), L"%u%%", dwOverallPercentage); - ThemeSetTextControl(_theme, ID_CACHE_PROGRESS_TEXT, wzProgress); - - ThemeSetProgressControl(_theme, ID_CACHE_PROGRESS_BAR, dwOverallPercentage); - - _calculatedCacheProgress = dwOverallPercentage * PYBA_ACQUIRE_PERCENTAGE / 100; - ThemeSetProgressControl(_theme, ID_OVERALL_CALCULATED_PROGRESS_BAR, _calculatedCacheProgress + _calculatedExecuteProgress); - - SetTaskbarButtonProgress(_calculatedCacheProgress + _calculatedExecuteProgress); - - return __super::OnCacheAcquireProgress(wzPackageOrContainerId, wzPayloadId, dw64Progress, dw64Total, dwOverallPercentage); - } - - - virtual STDMETHODIMP_(int) OnCacheAcquireComplete( - __in_z LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in HRESULT hrStatus, - __in int nRecommendation - ) { - SetProgressState(hrStatus); - return __super::OnCacheAcquireComplete(wzPackageOrContainerId, wzPayloadId, hrStatus, nRecommendation); - } - - - virtual STDMETHODIMP_(int) OnCacheVerifyComplete( - __in_z LPCWSTR wzPackageId, - __in_z LPCWSTR wzPayloadId, - __in HRESULT hrStatus, - __in int nRecommendation - ) { - SetProgressState(hrStatus); - return __super::OnCacheVerifyComplete(wzPackageId, wzPayloadId, hrStatus, nRecommendation); - } - - - virtual STDMETHODIMP_(void) OnCacheComplete(__in HRESULT /*hrStatus*/) { - ThemeSetTextControl(_theme, ID_CACHE_PROGRESS_PACKAGE_TEXT, L""); - SetState(PYBA_STATE_CACHED, S_OK); // we always return success here and let OnApplyComplete() deal with the error. - } - - - virtual STDMETHODIMP_(int) OnError( - __in BOOTSTRAPPER_ERROR_TYPE errorType, - __in LPCWSTR wzPackageId, - __in DWORD dwCode, - __in_z LPCWSTR wzError, - __in DWORD dwUIHint, - __in DWORD /*cData*/, - __in_ecount_z_opt(cData) LPCWSTR* /*rgwzData*/, - __in int nRecommendation - ) { - int nResult = nRecommendation; - LPWSTR sczError = nullptr; - - if (BOOTSTRAPPER_DISPLAY_EMBEDDED == _command.display) { - HRESULT hr = _engine->SendEmbeddedError(dwCode, wzError, dwUIHint, &nResult); - if (FAILED(hr)) { - nResult = IDERROR; - } - } else if (BOOTSTRAPPER_DISPLAY_FULL == _command.display) { - // If this is an authentication failure, let the engine try to handle it for us. - if (BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_SERVER == errorType || BOOTSTRAPPER_ERROR_TYPE_HTTP_AUTH_PROXY == errorType) { - nResult = IDTRYAGAIN; - } else // show a generic error message box. - { - BalRetryErrorOccurred(wzPackageId, dwCode); - - if (!_showingInternalUIThisPackage) { - // If no error message was provided, use the error code to try and get an error message. - if (!wzError || !*wzError || BOOTSTRAPPER_ERROR_TYPE_WINDOWS_INSTALLER != errorType) { - HRESULT hr = StrAllocFromError(&sczError, dwCode, nullptr); - if (FAILED(hr) || !sczError || !*sczError) { - StrAllocFormatted(&sczError, L"0x%x", dwCode); - } - } - - nResult = ::MessageBoxW(_hWnd, sczError ? sczError : wzError, _theme->sczCaption, dwUIHint); - } - } - - SetProgressState(HRESULT_FROM_WIN32(dwCode)); - } else { - // just take note of the error code and let things continue. - BalRetryErrorOccurred(wzPackageId, dwCode); - } - - ReleaseStr(sczError); - return nResult; - } - - - virtual STDMETHODIMP_(int) OnExecuteMsiMessage( - __in_z LPCWSTR wzPackageId, - __in INSTALLMESSAGE mt, - __in UINT uiFlags, - __in_z LPCWSTR wzMessage, - __in DWORD cData, - __in_ecount_z_opt(cData) LPCWSTR* rgwzData, - __in int nRecommendation - ) { -#ifdef DEBUG - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "PYBA: OnExecuteMsiMessage() - package: %ls, message: %ls", wzPackageId, wzMessage); -#endif - if (BOOTSTRAPPER_DISPLAY_FULL == _command.display && (INSTALLMESSAGE_WARNING == mt || INSTALLMESSAGE_USER == mt)) { - int nResult = ::MessageBoxW(_hWnd, wzMessage, _theme->sczCaption, uiFlags); - return nResult; - } - - if (INSTALLMESSAGE_ACTIONSTART == mt) { - ThemeSetTextControl(_theme, ID_EXECUTE_PROGRESS_ACTIONDATA_TEXT, wzMessage); - } - - return __super::OnExecuteMsiMessage(wzPackageId, mt, uiFlags, wzMessage, cData, rgwzData, nRecommendation); - } - - - virtual STDMETHODIMP_(int) OnProgress(__in DWORD dwProgressPercentage, __in DWORD dwOverallProgressPercentage) { - WCHAR wzProgress[5] = { }; - -#ifdef DEBUG - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "PYBA: OnProgress() - progress: %u%%, overall progress: %u%%", dwProgressPercentage, dwOverallProgressPercentage); -#endif - - ::StringCchPrintfW(wzProgress, countof(wzProgress), L"%u%%", dwOverallProgressPercentage); - ThemeSetTextControl(_theme, ID_OVERALL_PROGRESS_TEXT, wzProgress); - - ThemeSetProgressControl(_theme, ID_OVERALL_PROGRESS_BAR, dwOverallProgressPercentage); - SetTaskbarButtonProgress(dwOverallProgressPercentage); - - return __super::OnProgress(dwProgressPercentage, dwOverallProgressPercentage); - } - - - virtual STDMETHODIMP_(int) OnExecutePackageBegin(__in_z LPCWSTR wzPackageId, __in BOOL fExecute) { - LPWSTR sczFormattedString = nullptr; - - _startedExecution = TRUE; - - if (wzPackageId && *wzPackageId) { - BAL_INFO_PACKAGE* pPackage = nullptr; - BalInfoFindPackageById(&_bundle.packages, wzPackageId, &pPackage); - - LPCWSTR wz = wzPackageId; - if (pPackage) { - LOC_STRING* pLocString = nullptr; - - switch (pPackage->type) { - case BAL_INFO_PACKAGE_TYPE_BUNDLE_ADDON: - LocGetString(_wixLoc, L"#(loc.ExecuteAddonRelatedBundleMessage)", &pLocString); - break; - - case BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH: - LocGetString(_wixLoc, L"#(loc.ExecutePatchRelatedBundleMessage)", &pLocString); - break; - - case BAL_INFO_PACKAGE_TYPE_BUNDLE_UPGRADE: - LocGetString(_wixLoc, L"#(loc.ExecuteUpgradeRelatedBundleMessage)", &pLocString); - break; - } - - if (pLocString) { - // If the wix developer is showing a hidden variable in the UI, then obviously they don't care about keeping it safe - // so don't go down the rabbit hole of making sure that this is securely freed. - BalFormatString(pLocString->wzText, &sczFormattedString); - } - - wz = sczFormattedString ? sczFormattedString : pPackage->sczDisplayName ? pPackage->sczDisplayName : wzPackageId; - } - - _showingInternalUIThisPackage = pPackage && pPackage->fDisplayInternalUI; - - ThemeSetTextControl(_theme, ID_EXECUTE_PROGRESS_PACKAGE_TEXT, wz); - ThemeSetTextControl(_theme, ID_OVERALL_PROGRESS_PACKAGE_TEXT, wz); - } else { - _showingInternalUIThisPackage = FALSE; - } - - ReleaseStr(sczFormattedString); - return __super::OnExecutePackageBegin(wzPackageId, fExecute); - } - - - virtual int __stdcall OnExecuteProgress( - __in_z LPCWSTR wzPackageId, - __in DWORD dwProgressPercentage, - __in DWORD dwOverallProgressPercentage - ) { - WCHAR wzProgress[8] = { }; - -#ifdef DEBUG - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "PYBA: OnExecuteProgress() - package: %ls, progress: %u%%, overall progress: %u%%", wzPackageId, dwProgressPercentage, dwOverallProgressPercentage); -#endif - - ::StringCchPrintfW(wzProgress, countof(wzProgress), L"%u%%", dwOverallProgressPercentage); - ThemeSetTextControl(_theme, ID_EXECUTE_PROGRESS_TEXT, wzProgress); - - ThemeSetProgressControl(_theme, ID_EXECUTE_PROGRESS_BAR, dwOverallProgressPercentage); - - _calculatedExecuteProgress = dwOverallProgressPercentage * (100 - PYBA_ACQUIRE_PERCENTAGE) / 100; - ThemeSetProgressControl(_theme, ID_OVERALL_CALCULATED_PROGRESS_BAR, _calculatedCacheProgress + _calculatedExecuteProgress); - - SetTaskbarButtonProgress(_calculatedCacheProgress + _calculatedExecuteProgress); - - return __super::OnExecuteProgress(wzPackageId, dwProgressPercentage, dwOverallProgressPercentage); - } - - - virtual STDMETHODIMP_(int) OnExecutePackageComplete( - __in_z LPCWSTR wzPackageId, - __in HRESULT hrExitCode, - __in BOOTSTRAPPER_APPLY_RESTART restart, - __in int nRecommendation - ) { - SetProgressState(hrExitCode); - - if (_wcsnicmp(wzPackageId, L"path_", 5) == 0 && SUCCEEDED(hrExitCode)) { - SendMessageTimeoutW( - HWND_BROADCAST, - WM_SETTINGCHANGE, - 0, - reinterpret_cast(L"Environment"), - SMTO_ABORTIFHUNG, - 1000, - nullptr - ); - } - - int nResult = __super::OnExecutePackageComplete(wzPackageId, hrExitCode, restart, nRecommendation); - - return nResult; - } - - - virtual STDMETHODIMP_(void) OnExecuteComplete(__in HRESULT hrStatus) { - ThemeSetTextControl(_theme, ID_EXECUTE_PROGRESS_PACKAGE_TEXT, L""); - ThemeSetTextControl(_theme, ID_EXECUTE_PROGRESS_ACTIONDATA_TEXT, L""); - ThemeSetTextControl(_theme, ID_OVERALL_PROGRESS_PACKAGE_TEXT, L""); - ThemeControlEnable(_theme, ID_PROGRESS_CANCEL_BUTTON, FALSE); // no more cancel. - - SetState(PYBA_STATE_EXECUTED, S_OK); // we always return success here and let OnApplyComplete() deal with the error. - SetProgressState(hrStatus); - } - - - virtual STDMETHODIMP_(int) OnResolveSource( - __in_z LPCWSTR wzPackageOrContainerId, - __in_z_opt LPCWSTR wzPayloadId, - __in_z LPCWSTR wzLocalSource, - __in_z_opt LPCWSTR wzDownloadSource - ) { - int nResult = IDERROR; // assume we won't resolve source and that is unexpected. - - if (BOOTSTRAPPER_DISPLAY_FULL == _command.display) { - if (wzDownloadSource) { - nResult = IDDOWNLOAD; - } else { - // prompt to change the source location. - OPENFILENAMEW ofn = { }; - WCHAR wzFile[MAX_PATH] = { }; - - ::StringCchCopyW(wzFile, countof(wzFile), wzLocalSource); - - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = _hWnd; - ofn.lpstrFile = wzFile; - ofn.nMaxFile = countof(wzFile); - ofn.lpstrFilter = L"All Files\0*.*\0"; - ofn.nFilterIndex = 1; - ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; - ofn.lpstrTitle = _theme->sczCaption; - - if (::GetOpenFileNameW(&ofn)) { - HRESULT hr = _engine->SetLocalSource(wzPackageOrContainerId, wzPayloadId, ofn.lpstrFile); - nResult = SUCCEEDED(hr) ? IDRETRY : IDERROR; - } else { - nResult = IDCANCEL; - } - } - } else if (wzDownloadSource) { - // If doing a non-interactive install and download source is available, let's try downloading the package silently - nResult = IDDOWNLOAD; - } - // else there's nothing more we can do in non-interactive mode - - return CheckCanceled() ? IDCANCEL : nResult; - } - - - virtual STDMETHODIMP_(int) OnApplyComplete(__in HRESULT hrStatus, __in BOOTSTRAPPER_APPLY_RESTART restart) { - _restartResult = restart; // remember the restart result so we return the correct error code no matter what the user chooses to do in the UI. - - // If a restart was encountered and we are not suppressing restarts, then restart is required. - _restartRequired = (BOOTSTRAPPER_APPLY_RESTART_NONE != restart && BOOTSTRAPPER_RESTART_NEVER < _command.restart); - // If a restart is required and we're not displaying a UI or we are not supposed to prompt for restart then allow the restart. - _allowRestart = _restartRequired && (BOOTSTRAPPER_DISPLAY_FULL > _command.display || BOOTSTRAPPER_RESTART_PROMPT < _command.restart); - - // If we are showing UI, wait a beat before moving to the final screen. - if (BOOTSTRAPPER_DISPLAY_NONE < _command.display) { - ::Sleep(250); - } - - SetState(PYBA_STATE_APPLIED, hrStatus); - SetTaskbarButtonProgress(100); // show full progress bar, green, yellow, or red - - return IDNOACTION; - } - - virtual STDMETHODIMP_(void) OnLaunchApprovedExeComplete(__in HRESULT hrStatus, __in DWORD /*processId*/) { - } - - -private: - // - // UiThreadProc - entrypoint for UI thread. - // - static DWORD WINAPI UiThreadProc(__in LPVOID pvContext) { - HRESULT hr = S_OK; - PythonBootstrapperApplication* pThis = (PythonBootstrapperApplication*)pvContext; - BOOL comInitialized = FALSE; - BOOL ret = FALSE; - MSG msg = { }; - - // Initialize COM and theme. - hr = ::CoInitialize(nullptr); - BalExitOnFailure(hr, "Failed to initialize COM."); - comInitialized = TRUE; - - hr = ThemeInitialize(pThis->_hModule); - BalExitOnFailure(hr, "Failed to initialize theme manager."); - - hr = pThis->InitializeData(); - BalExitOnFailure(hr, "Failed to initialize data in bootstrapper application."); - - // Create main window. - pThis->InitializeTaskbarButton(); - hr = pThis->CreateMainWindow(); - BalExitOnFailure(hr, "Failed to create main window."); - - pThis->ValidateOperatingSystem(); - - if (FAILED(pThis->_hrFinal)) { - pThis->SetState(PYBA_STATE_FAILED, hr); - ::PostMessageW(pThis->_hWnd, WM_PYBA_SHOW_FAILURE, 0, 0); - } else { - // Okay, we're ready for packages now. - pThis->SetState(PYBA_STATE_INITIALIZED, hr); - ::PostMessageW(pThis->_hWnd, BOOTSTRAPPER_ACTION_HELP == pThis->_command.action ? WM_PYBA_SHOW_HELP : WM_PYBA_DETECT_PACKAGES, 0, 0); - } - - // message pump - while (0 != (ret = ::GetMessageW(&msg, nullptr, 0, 0))) { - if (-1 == ret) { - hr = E_UNEXPECTED; - BalExitOnFailure(hr, "Unexpected return value from message pump."); - } else if (!ThemeHandleKeyboardMessage(pThis->_theme, msg.hwnd, &msg)) { - ::TranslateMessage(&msg); - ::DispatchMessageW(&msg); - } - } - - // Succeeded thus far, check to see if anything went wrong while actually - // executing changes. - if (FAILED(pThis->_hrFinal)) { - hr = pThis->_hrFinal; - } else if (pThis->CheckCanceled()) { - hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT); - } - - LExit: - // destroy main window - pThis->DestroyMainWindow(); - - // initiate engine shutdown - DWORD dwQuit = HRESULT_CODE(hr); - if (BOOTSTRAPPER_APPLY_RESTART_INITIATED == pThis->_restartResult) { - dwQuit = ERROR_SUCCESS_REBOOT_INITIATED; - } else if (BOOTSTRAPPER_APPLY_RESTART_REQUIRED == pThis->_restartResult) { - dwQuit = ERROR_SUCCESS_REBOOT_REQUIRED; - } - pThis->_engine->Quit(dwQuit); - - ReleaseTheme(pThis->_theme); - ThemeUninitialize(); - - // uninitialize COM - if (comInitialized) { - ::CoUninitialize(); - } - - return hr; - } - - // - // ParseVariablesFromUnattendXml - reads options from unattend.xml if it - // exists - // - HRESULT ParseVariablesFromUnattendXml() { - HRESULT hr = S_OK; - LPWSTR sczUnattendXmlPath = nullptr; - IXMLDOMDocument *pixdUnattend = nullptr; - IXMLDOMNodeList *pNodes = nullptr; - IXMLDOMNode *pNode = nullptr; - long cNodes; - DWORD dwAttr; - LPWSTR scz = nullptr; - BOOL bValue; - int iValue; - BOOL tryConvert; - BSTR bstrValue = nullptr; - - hr = BalFormatString(L"[WixBundleOriginalSourceFolder]unattend.xml", &sczUnattendXmlPath); - BalExitOnFailure(hr, "Failed to calculate path to unattend.xml"); - - if (!FileExistsEx(sczUnattendXmlPath, &dwAttr)) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_VERBOSE, "Did not find %ls", sczUnattendXmlPath); - hr = S_FALSE; - goto LExit; - } - - hr = XmlLoadDocumentFromFile(sczUnattendXmlPath, &pixdUnattend); - BalExitOnFailure1(hr, "Failed to read %ls", sczUnattendXmlPath); - - // get the list of variables users have overridden - hr = XmlSelectNodes(pixdUnattend, L"/Options/Option", &pNodes); - if (S_FALSE == hr) { - ExitFunction1(hr = S_OK); - } - BalExitOnFailure(hr, "Failed to select option nodes."); - - hr = pNodes->get_length((long*)&cNodes); - BalExitOnFailure(hr, "Failed to get option node count."); - - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Reading settings from %ls", sczUnattendXmlPath); - - for (DWORD i = 0; i < cNodes; ++i) { - hr = XmlNextElement(pNodes, &pNode, nullptr); - BalExitOnFailure(hr, "Failed to get next node."); - - // @Name - hr = XmlGetAttributeEx(pNode, L"Name", &scz); - BalExitOnFailure(hr, "Failed to get @Name."); - - tryConvert = TRUE; - hr = XmlGetAttribute(pNode, L"Value", &bstrValue); - if (FAILED(hr) || !bstrValue || !*bstrValue) { - hr = XmlGetText(pNode, &bstrValue); - tryConvert = FALSE; - } - BalExitOnFailure(hr, "Failed to get @Value."); - - if (tryConvert && - CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, bstrValue, -1, L"yes", -1)) { - _engine->SetVariableNumeric(scz, 1); - } else if (tryConvert && - CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, bstrValue, -1, L"no", -1)) { - _engine->SetVariableNumeric(scz, 0); - } else if (tryConvert && ::StrToIntExW(bstrValue, STIF_DEFAULT, &iValue)) { - _engine->SetVariableNumeric(scz, iValue); - } else { - _engine->SetVariableString(scz, bstrValue); - } - - ReleaseNullBSTR(bstrValue); - ReleaseNullStr(scz); - ReleaseNullObject(pNode); - } - - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Finished reading from %ls", sczUnattendXmlPath); - - LExit: - ReleaseObject(pNode); - ReleaseObject(pNodes); - ReleaseObject(pixdUnattend); - ReleaseStr(sczUnattendXmlPath); - - return hr; - } - - - // - // InitializeData - initializes all the package information. - // - HRESULT InitializeData() { - HRESULT hr = S_OK; - LPWSTR sczModulePath = nullptr; - IXMLDOMDocument *pixdManifest = nullptr; - - hr = BalManifestLoad(_hModule, &pixdManifest); - BalExitOnFailure(hr, "Failed to load bootstrapper application manifest."); - - hr = ParseOverridableVariablesFromXml(pixdManifest); - BalExitOnFailure(hr, "Failed to read overridable variables."); - - if (_command.action == BOOTSTRAPPER_ACTION_MODIFY) { - LoadOptionalFeatureStates(_engine); - } - - hr = ParseVariablesFromUnattendXml(); - ExitOnFailure(hr, "Failed to read unattend.ini file."); - - hr = ProcessCommandLine(&_language); - ExitOnFailure(hr, "Unknown commandline parameters."); - - hr = PathRelativeToModule(&sczModulePath, nullptr, _hModule); - BalExitOnFailure(hr, "Failed to get module path."); - - hr = LoadLocalization(sczModulePath, _language); - ExitOnFailure(hr, "Failed to load localization."); - - hr = LoadTheme(sczModulePath, _language); - ExitOnFailure(hr, "Failed to load theme."); - - hr = BalInfoParseFromXml(&_bundle, pixdManifest); - BalExitOnFailure(hr, "Failed to load bundle information."); - - hr = BalConditionsParseFromXml(&_conditions, pixdManifest, _wixLoc); - BalExitOnFailure(hr, "Failed to load conditions from XML."); - - hr = LoadBootstrapperBAFunctions(); - BalExitOnFailure(hr, "Failed to load bootstrapper functions."); - - hr = UpdateUIStrings(_command.action); - BalExitOnFailure(hr, "Failed to load UI strings."); - - GetBundleFileVersion(); - // don't fail if we couldn't get the version info; best-effort only - LExit: - ReleaseObject(pixdManifest); - ReleaseStr(sczModulePath); - - return hr; - } - - - // - // ProcessCommandLine - process the provided command line arguments. - // - HRESULT ProcessCommandLine(__inout LPWSTR* psczLanguage) { - HRESULT hr = S_OK; - int argc = 0; - LPWSTR* argv = nullptr; - LPWSTR sczVariableName = nullptr; - LPWSTR sczVariableValue = nullptr; - - if (_command.wzCommandLine && *_command.wzCommandLine) { - argv = ::CommandLineToArgvW(_command.wzCommandLine, &argc); - ExitOnNullWithLastError(argv, hr, "Failed to get command line."); - - for (int i = 0; i < argc; ++i) { - if (argv[i][0] == L'-' || argv[i][0] == L'/') { - if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"lang", -1)) { - if (i + 1 >= argc) { - hr = E_INVALIDARG; - BalExitOnFailure(hr, "Must specify a language."); - } - - ++i; - - hr = StrAllocString(psczLanguage, &argv[i][0], 0); - BalExitOnFailure(hr, "Failed to copy language."); - } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"simple", -1)) { - _engine->SetVariableNumeric(L"SimpleInstall", 1); - } - } else if (_overridableVariables) { - int value; - const wchar_t* pwc = wcschr(argv[i], L'='); - if (pwc) { - hr = StrAllocString(&sczVariableName, argv[i], pwc - argv[i]); - BalExitOnFailure(hr, "Failed to copy variable name."); - - hr = DictKeyExists(_overridableVariables, sczVariableName); - if (E_NOTFOUND == hr) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Ignoring attempt to set non-overridable variable: '%ls'.", sczVariableName); - hr = S_OK; - continue; - } - ExitOnFailure(hr, "Failed to check the dictionary of overridable variables."); - - hr = StrAllocString(&sczVariableValue, ++pwc, 0); - BalExitOnFailure(hr, "Failed to copy variable value."); - - if (::StrToIntEx(sczVariableValue, STIF_DEFAULT, &value)) { - hr = _engine->SetVariableNumeric(sczVariableName, value); - } else { - hr = _engine->SetVariableString(sczVariableName, sczVariableValue); - } - BalExitOnFailure(hr, "Failed to set variable."); - } else { - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Ignoring unknown argument: %ls", argv[i]); - } - } - } - } - - LExit: - if (argv) { - ::LocalFree(argv); - } - - ReleaseStr(sczVariableName); - ReleaseStr(sczVariableValue); - - return hr; - } - - HRESULT LoadLocalization(__in_z LPCWSTR wzModulePath, __in_z_opt LPCWSTR wzLanguage) { - HRESULT hr = S_OK; - LPWSTR sczLocPath = nullptr; - LPCWSTR wzLocFileName = L"Default.wxl"; - - hr = LocProbeForFile(wzModulePath, wzLocFileName, wzLanguage, &sczLocPath); - BalExitOnFailure2(hr, "Failed to probe for loc file: %ls in path: %ls", wzLocFileName, wzModulePath); - - hr = LocLoadFromFile(sczLocPath, &_wixLoc); - BalExitOnFailure1(hr, "Failed to load loc file from path: %ls", sczLocPath); - - if (WIX_LOCALIZATION_LANGUAGE_NOT_SET != _wixLoc->dwLangId) { - ::SetThreadLocale(_wixLoc->dwLangId); - } - - hr = StrAllocString(&_confirmCloseMessage, L"#(loc.ConfirmCancelMessage)", 0); - ExitOnFailure(hr, "Failed to initialize confirm message loc identifier."); - - hr = LocLocalizeString(_wixLoc, &_confirmCloseMessage); - BalExitOnFailure1(hr, "Failed to localize confirm close message: %ls", _confirmCloseMessage); - - LExit: - ReleaseStr(sczLocPath); - - return hr; - } - - - HRESULT LoadTheme(__in_z LPCWSTR wzModulePath, __in_z_opt LPCWSTR wzLanguage) { - HRESULT hr = S_OK; - LPWSTR sczThemePath = nullptr; - LPCWSTR wzThemeFileName = L"Default.thm"; - LPWSTR sczCaption = nullptr; - - hr = LocProbeForFile(wzModulePath, wzThemeFileName, wzLanguage, &sczThemePath); - BalExitOnFailure2(hr, "Failed to probe for theme file: %ls in path: %ls", wzThemeFileName, wzModulePath); - - hr = ThemeLoadFromFile(sczThemePath, &_theme); - BalExitOnFailure1(hr, "Failed to load theme from path: %ls", sczThemePath); - - hr = ThemeLocalize(_theme, _wixLoc); - BalExitOnFailure1(hr, "Failed to localize theme: %ls", sczThemePath); - - // Update the caption if there are any formatted strings in it. - // If the wix developer is showing a hidden variable in the UI, then - // obviously they don't care about keeping it safe so don't go down the - // rabbit hole of making sure that this is securely freed. - hr = BalFormatString(_theme->sczCaption, &sczCaption); - if (SUCCEEDED(hr)) { - ThemeUpdateCaption(_theme, sczCaption); - } - - LExit: - ReleaseStr(sczCaption); - ReleaseStr(sczThemePath); - - return hr; - } - - - HRESULT ParseOverridableVariablesFromXml(__in IXMLDOMDocument* pixdManifest) { - HRESULT hr = S_OK; - IXMLDOMNode* pNode = nullptr; - IXMLDOMNodeList* pNodes = nullptr; - DWORD cNodes = 0; - LPWSTR scz = nullptr; - BOOL hidden = FALSE; - - // get the list of variables users can override on the command line - hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixStdbaOverridableVariable", &pNodes); - if (S_FALSE == hr) { - ExitFunction1(hr = S_OK); - } - ExitOnFailure(hr, "Failed to select overridable variable nodes."); - - hr = pNodes->get_length((long*)&cNodes); - ExitOnFailure(hr, "Failed to get overridable variable node count."); - - if (cNodes) { - hr = DictCreateStringList(&_overridableVariables, 32, DICT_FLAG_NONE); - ExitOnFailure(hr, "Failed to create the string dictionary."); - - for (DWORD i = 0; i < cNodes; ++i) { - hr = XmlNextElement(pNodes, &pNode, nullptr); - ExitOnFailure(hr, "Failed to get next node."); - - // @Name - hr = XmlGetAttributeEx(pNode, L"Name", &scz); - ExitOnFailure(hr, "Failed to get @Name."); - - hr = XmlGetYesNoAttribute(pNode, L"Hidden", &hidden); - - if (!hidden) { - hr = DictAddKey(_overridableVariables, scz); - ExitOnFailure1(hr, "Failed to add \"%ls\" to the string dictionary.", scz); - } - - // prepare next iteration - ReleaseNullObject(pNode); - } - } - - LExit: - ReleaseObject(pNode); - ReleaseObject(pNodes); - ReleaseStr(scz); - return hr; - } - - - // - // Get the file version of the bootstrapper and record in bootstrapper log file - // - HRESULT GetBundleFileVersion() { - HRESULT hr = S_OK; - ULARGE_INTEGER uliVersion = { }; - LPWSTR sczCurrentPath = nullptr; - - hr = PathForCurrentProcess(&sczCurrentPath, nullptr); - BalExitOnFailure(hr, "Failed to get bundle path."); - - hr = FileVersion(sczCurrentPath, &uliVersion.HighPart, &uliVersion.LowPart); - BalExitOnFailure(hr, "Failed to get bundle file version."); - - hr = _engine->SetVariableVersion(PYBA_VARIABLE_BUNDLE_FILE_VERSION, uliVersion.QuadPart); - BalExitOnFailure(hr, "Failed to set WixBundleFileVersion variable."); - - LExit: - ReleaseStr(sczCurrentPath); - - return hr; - } - - - // - // CreateMainWindow - creates the main install window. - // - HRESULT CreateMainWindow() { - HRESULT hr = S_OK; - HICON hIcon = reinterpret_cast(_theme->hIcon); - WNDCLASSW wc = { }; - DWORD dwWindowStyle = 0; - int x = CW_USEDEFAULT; - int y = CW_USEDEFAULT; - POINT ptCursor = { }; - HMONITOR hMonitor = nullptr; - MONITORINFO mi = { }; - COLORREF fg, bg; - HBRUSH bgBrush; - - // If the theme did not provide an icon, try using the icon from the bundle engine. - if (!hIcon) { - HMODULE hBootstrapperEngine = ::GetModuleHandleW(nullptr); - if (hBootstrapperEngine) { - hIcon = ::LoadIconW(hBootstrapperEngine, MAKEINTRESOURCEW(1)); - } - } - - fg = RGB(0, 0, 0); - bg = RGB(255, 255, 255); - bgBrush = (HBRUSH)(COLOR_WINDOW+1); - if (_theme->dwFontId < _theme->cFonts) { - THEME_FONT *font = &_theme->rgFonts[_theme->dwFontId]; - fg = font->crForeground; - bg = font->crBackground; - bgBrush = font->hBackground; - RemapColor(&fg, &bg, &bgBrush); - } - - // Register the window class and create the window. - wc.lpfnWndProc = PythonBootstrapperApplication::WndProc; - wc.hInstance = _hModule; - wc.hIcon = hIcon; - wc.hCursor = ::LoadCursorW(nullptr, (LPCWSTR)IDC_ARROW); - wc.hbrBackground = bgBrush; - wc.lpszMenuName = nullptr; - wc.lpszClassName = PYBA_WINDOW_CLASS; - if (!::RegisterClassW(&wc)) { - ExitWithLastError(hr, "Failed to register window."); - } - - _registered = TRUE; - - // Calculate the window style based on the theme style and command display value. - dwWindowStyle = _theme->dwStyle; - if (BOOTSTRAPPER_DISPLAY_NONE >= _command.display) { - dwWindowStyle &= ~WS_VISIBLE; - } - - // Don't show the window if there is a splash screen (it will be made visible when the splash screen is hidden) - if (::IsWindow(_command.hwndSplashScreen)) { - dwWindowStyle &= ~WS_VISIBLE; - } - - // Center the window on the monitor with the mouse. - if (::GetCursorPos(&ptCursor)) { - hMonitor = ::MonitorFromPoint(ptCursor, MONITOR_DEFAULTTONEAREST); - if (hMonitor) { - mi.cbSize = sizeof(mi); - if (::GetMonitorInfoW(hMonitor, &mi)) { - x = mi.rcWork.left + (mi.rcWork.right - mi.rcWork.left - _theme->nWidth) / 2; - y = mi.rcWork.top + (mi.rcWork.bottom - mi.rcWork.top - _theme->nHeight) / 2; - } - } - } - - _hWnd = ::CreateWindowExW( - 0, - wc.lpszClassName, - _theme->sczCaption, - dwWindowStyle, - x, - y, - _theme->nWidth, - _theme->nHeight, - HWND_DESKTOP, - nullptr, - _hModule, - this - ); - ExitOnNullWithLastError(_hWnd, hr, "Failed to create window."); - - hr = S_OK; - - LExit: - return hr; - } - - - // - // InitializeTaskbarButton - initializes taskbar button for progress. - // - void InitializeTaskbarButton() { - HRESULT hr = S_OK; - - hr = ::CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_ALL, __uuidof(ITaskbarList3), reinterpret_cast(&_taskbarList)); - if (REGDB_E_CLASSNOTREG == hr) { - // not supported before Windows 7 - ExitFunction1(hr = S_OK); - } - BalExitOnFailure(hr, "Failed to create ITaskbarList3. Continuing."); - - _taskbarButtonCreatedMessage = ::RegisterWindowMessageW(L"TaskbarButtonCreated"); - BalExitOnNullWithLastError(_taskbarButtonCreatedMessage, hr, "Failed to get TaskbarButtonCreated message. Continuing."); - - LExit: - return; - } - - // - // DestroyMainWindow - clean up all the window registration. - // - void DestroyMainWindow() { - if (::IsWindow(_hWnd)) { - ::DestroyWindow(_hWnd); - _hWnd = nullptr; - _taskbarButtonOK = FALSE; - } - - if (_registered) { - ::UnregisterClassW(PYBA_WINDOW_CLASS, _hModule); - _registered = FALSE; - } - } - - - // - // WndProc - standard windows message handler. - // - static LRESULT CALLBACK WndProc( - __in HWND hWnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam - ) { -#pragma warning(suppress:4312) - auto pBA = reinterpret_cast(::GetWindowLongPtrW(hWnd, GWLP_USERDATA)); - - switch (uMsg) { - case WM_NCCREATE: { - LPCREATESTRUCT lpcs = reinterpret_cast(lParam); - pBA = reinterpret_cast(lpcs->lpCreateParams); -#pragma warning(suppress:4244) - ::SetWindowLongPtrW(hWnd, GWLP_USERDATA, reinterpret_cast(pBA)); - break; - } - - case WM_NCDESTROY: { - LRESULT lres = ThemeDefWindowProc(pBA ? pBA->_theme : nullptr, hWnd, uMsg, wParam, lParam); - ::SetWindowLongPtrW(hWnd, GWLP_USERDATA, 0); - return lres; - } - - case WM_CREATE: - if (!pBA->OnCreate(hWnd)) { - return -1; - } - break; - - case WM_QUERYENDSESSION: - return IDCANCEL != pBA->OnSystemShutdown(static_cast(lParam), IDCANCEL); - - case WM_CLOSE: - // If the user chose not to close, do *not* let the default window proc handle the message. - if (!pBA->OnClose()) { - return 0; - } - break; - - case WM_DESTROY: - ::PostQuitMessage(0); - break; - - case WM_PAINT: __fallthrough; - case WM_ERASEBKGND: - if (pBA && pBA->_suppressPaint) { - return TRUE; - } - break; - - case WM_PYBA_SHOW_HELP: - pBA->OnShowHelp(); - return 0; - - case WM_PYBA_DETECT_PACKAGES: - pBA->OnDetect(); - return 0; - - case WM_PYBA_PLAN_PACKAGES: - pBA->OnPlan(static_cast(lParam)); - return 0; - - case WM_PYBA_APPLY_PACKAGES: - pBA->OnApply(); - return 0; - - case WM_PYBA_CHANGE_STATE: - pBA->OnChangeState(static_cast(lParam)); - return 0; - - case WM_PYBA_SHOW_FAILURE: - pBA->OnShowFailure(); - return 0; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - // Customize commands - // Success/failure commands - case ID_SUCCESS_RESTART_BUTTON: __fallthrough; - case ID_FAILURE_RESTART_BUTTON: - pBA->OnClickRestartButton(); - return 0; - - case IDCANCEL: __fallthrough; - case ID_INSTALL_CANCEL_BUTTON: __fallthrough; - case ID_CUSTOM1_CANCEL_BUTTON: __fallthrough; - case ID_CUSTOM2_CANCEL_BUTTON: __fallthrough; - case ID_MODIFY_CANCEL_BUTTON: __fallthrough; - case ID_PROGRESS_CANCEL_BUTTON: __fallthrough; - case ID_SUCCESS_CANCEL_BUTTON: __fallthrough; - case ID_FAILURE_CANCEL_BUTTON: __fallthrough; - case ID_CLOSE_BUTTON: - pBA->OnCommand(ID_CLOSE_BUTTON); - return 0; - - default: - pBA->OnCommand((CONTROL_ID)LOWORD(wParam)); - } - break; - - case WM_NOTIFY: - if (lParam) { - LPNMHDR pnmhdr = reinterpret_cast(lParam); - switch (pnmhdr->code) { - case NM_CLICK: __fallthrough; - case NM_RETURN: - switch (static_cast(pnmhdr->idFrom)) { - case ID_FAILURE_LOGFILE_LINK: - pBA->OnClickLogFileLink(); - return 1; - } - } - } - break; - - case WM_CTLCOLORSTATIC: - case WM_CTLCOLORBTN: - if (pBA) { - HBRUSH brush = nullptr; - if (pBA->SetControlColor((HWND)lParam, (HDC)wParam, &brush)) { - return (LRESULT)brush; - } - } - break; - } - - if (pBA && pBA->_taskbarList && uMsg == pBA->_taskbarButtonCreatedMessage) { - pBA->_taskbarButtonOK = TRUE; - return 0; - } - - return ThemeDefWindowProc(pBA ? pBA->_theme : nullptr, hWnd, uMsg, wParam, lParam); - } - - // - // OnCreate - finishes loading the theme. - // - BOOL OnCreate(__in HWND hWnd) { - HRESULT hr = S_OK; - - hr = ThemeLoadControls(_theme, hWnd, CONTROL_ID_NAMES, countof(CONTROL_ID_NAMES)); - BalExitOnFailure(hr, "Failed to load theme controls."); - - C_ASSERT(COUNT_PAGE == countof(PAGE_NAMES)); - C_ASSERT(countof(_pageIds) == countof(PAGE_NAMES)); - - ThemeGetPageIds(_theme, PAGE_NAMES, _pageIds, countof(_pageIds)); - - // Initialize the text on all "application" (non-page) controls. - for (DWORD i = 0; i < _theme->cControls; ++i) { - THEME_CONTROL* pControl = _theme->rgControls + i; - LPWSTR text = nullptr; - - if (!pControl->wPageId && pControl->sczText && *pControl->sczText) { - HRESULT hrFormat; - - // If the wix developer is showing a hidden variable in the UI, - // then obviously they don't care about keeping it safe so don't - // go down the rabbit hole of making sure that this is securely - // freed. - hrFormat = BalFormatString(pControl->sczText, &text); - if (SUCCEEDED(hrFormat)) { - ThemeSetTextControl(_theme, pControl->wId, text); - ReleaseStr(text); - } - } - } - - LExit: - return SUCCEEDED(hr); - } - - void RemapColor(COLORREF *fg, COLORREF *bg, HBRUSH *bgBrush) { - if (*fg == RGB(0, 0, 0)) { - *fg = GetSysColor(COLOR_WINDOWTEXT); - } else if (*fg == RGB(128, 128, 128)) { - *fg = GetSysColor(COLOR_GRAYTEXT); - } - if (*bgBrush && *bg == RGB(255, 255, 255)) { - *bg = GetSysColor(COLOR_WINDOW); - *bgBrush = GetSysColorBrush(COLOR_WINDOW); - } - } - - BOOL SetControlColor(HWND hWnd, HDC hDC, HBRUSH *brush) { - for (int i = 0; i < _theme->cControls; ++i) { - if (_theme->rgControls[i].hWnd != hWnd) { - continue; - } - - DWORD fontId = _theme->rgControls[i].dwFontId; - if (fontId > _theme->cFonts) { - fontId = 0; - } - THEME_FONT *fnt = &_theme->rgFonts[fontId]; - - COLORREF fg = fnt->crForeground, bg = fnt->crBackground; - *brush = fnt->hBackground; - RemapColor(&fg, &bg, brush); - ::SetTextColor(hDC, fg); - ::SetBkColor(hDC, bg); - - return TRUE; - } - return FALSE; - } - - // - // OnShowFailure - display the failure page. - // - void OnShowFailure() { - SetState(PYBA_STATE_FAILED, S_OK); - - // If the UI should be visible, display it now and hide the splash screen - if (BOOTSTRAPPER_DISPLAY_NONE < _command.display) { - ::ShowWindow(_theme->hwndParent, SW_SHOW); - } - - _engine->CloseSplashScreen(); - - return; - } - - - // - // OnShowHelp - display the help page. - // - void OnShowHelp() { - SetState(PYBA_STATE_HELP, S_OK); - - // If the UI should be visible, display it now and hide the splash screen - if (BOOTSTRAPPER_DISPLAY_NONE < _command.display) { - ::ShowWindow(_theme->hwndParent, SW_SHOW); - } - - _engine->CloseSplashScreen(); - - return; - } - - - // - // OnDetect - start the processing of packages. - // - void OnDetect() { - HRESULT hr = S_OK; - - if (_baFunction) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Running detect BA function"); - hr = _baFunction->OnDetect(); - BalExitOnFailure(hr, "Failed calling detect BA function."); - } - - SetState(PYBA_STATE_DETECTING, hr); - - // If the UI should be visible, display it now and hide the splash screen - if (BOOTSTRAPPER_DISPLAY_NONE < _command.display) { - ::ShowWindow(_theme->hwndParent, SW_SHOW); - } - - _engine->CloseSplashScreen(); - - // Tell the core we're ready for the packages to be processed now. - hr = _engine->Detect(); - BalExitOnFailure(hr, "Failed to start detecting chain."); - - LExit: - if (FAILED(hr)) { - SetState(PYBA_STATE_DETECTING, hr); - } - - return; - } - - HRESULT UpdateUIStrings(__in BOOTSTRAPPER_ACTION action) { - HRESULT hr = S_OK; - LPCWSTR likeInstalling = nullptr; - LPCWSTR likeInstallation = nullptr; - switch (action) { - case BOOTSTRAPPER_ACTION_INSTALL: - likeInstalling = L"Installing"; - likeInstallation = L"Installation"; - break; - case BOOTSTRAPPER_ACTION_MODIFY: - // For modify, we actually want to pass INSTALL - action = BOOTSTRAPPER_ACTION_INSTALL; - likeInstalling = L"Modifying"; - likeInstallation = L"Modification"; - break; - case BOOTSTRAPPER_ACTION_REPAIR: - likeInstalling = L"Repairing"; - likeInstallation = L"Repair"; - break; - case BOOTSTRAPPER_ACTION_UNINSTALL: - likeInstalling = L"Uninstalling"; - likeInstallation = L"Uninstallation"; - break; - } - - if (likeInstalling) { - LPWSTR locName = nullptr; - LOC_STRING *locText = nullptr; - hr = StrAllocFormatted(&locName, L"#(loc.%ls)", likeInstalling); - if (SUCCEEDED(hr)) { - hr = LocGetString(_wixLoc, locName, &locText); - ReleaseStr(locName); - } - _engine->SetVariableString( - L"ActionLikeInstalling", - SUCCEEDED(hr) && locText ? locText->wzText : likeInstalling - ); - } - - if (likeInstallation) { - LPWSTR locName = nullptr; - LOC_STRING *locText = nullptr; - hr = StrAllocFormatted(&locName, L"#(loc.%ls)", likeInstallation); - if (SUCCEEDED(hr)) { - hr = LocGetString(_wixLoc, locName, &locText); - ReleaseStr(locName); - } - _engine->SetVariableString( - L"ActionLikeInstallation", - SUCCEEDED(hr) && locText ? locText->wzText : likeInstallation - ); - } - return hr; - } - - // - // OnPlan - plan the detected changes. - // - void OnPlan(__in BOOTSTRAPPER_ACTION action) { - HRESULT hr = S_OK; - - _plannedAction = action; - - hr = UpdateUIStrings(action); - BalExitOnFailure(hr, "Failed to update strings"); - - // If we are going to apply a downgrade, bail. - if (_downgradingOtherVersion && BOOTSTRAPPER_ACTION_UNINSTALL < action) { - if (_suppressDowngradeFailure) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "A newer version of this product is installed but downgrade failure has been suppressed; continuing..."); - } else { - hr = HRESULT_FROM_WIN32(ERROR_PRODUCT_VERSION); - BalExitOnFailure(hr, "Cannot install a product when a newer version is installed."); - } - } - - SetState(PYBA_STATE_PLANNING, hr); - - if (_baFunction) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Running plan BA function"); - _baFunction->OnPlan(); - } - - hr = _engine->Plan(action); - BalExitOnFailure(hr, "Failed to start planning packages."); - - LExit: - if (FAILED(hr)) { - SetState(PYBA_STATE_PLANNING, hr); - } - - return; - } - - - // - // OnApply - apply the packages. - // - void OnApply() { - HRESULT hr = S_OK; - - SetState(PYBA_STATE_APPLYING, hr); - SetProgressState(hr); - SetTaskbarButtonProgress(0); - - hr = _engine->Apply(_hWnd); - BalExitOnFailure(hr, "Failed to start applying packages."); - - ThemeControlEnable(_theme, ID_PROGRESS_CANCEL_BUTTON, TRUE); // ensure the cancel button is enabled before starting. - - LExit: - if (FAILED(hr)) { - SetState(PYBA_STATE_APPLYING, hr); - } - - return; - } - - - // - // OnChangeState - change state. - // - void OnChangeState(__in PYBA_STATE state) { - LPWSTR unformattedText = nullptr; - - _state = state; - - // If our install is at the end (success or failure) and we're not showing full UI - // then exit (prompt for restart if required). - if ((PYBA_STATE_APPLIED <= _state && BOOTSTRAPPER_DISPLAY_FULL > _command.display)) { - // If a restart was required but we were not automatically allowed to - // accept the reboot then do the prompt. - if (_restartRequired && !_allowRestart) { - StrAllocFromError(&unformattedText, HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_REQUIRED), nullptr); - - _allowRestart = IDOK == ::MessageBoxW( - _hWnd, - unformattedText ? unformattedText : L"The requested operation is successful. Changes will not be effective until the system is rebooted.", - _theme->sczCaption, - MB_ICONEXCLAMATION | MB_OKCANCEL - ); - } - - // Quietly exit. - ::PostMessageW(_hWnd, WM_CLOSE, 0, 0); - } else { // try to change the pages. - DWORD newPageId = 0; - DeterminePageId(_state, &newPageId); - - if (_visiblePageId != newPageId) { - ShowPage(newPageId); - } - } - - ReleaseStr(unformattedText); - } - - // - // Called before showing a page to handle all controls. - // - void ProcessPageControls(THEME_PAGE *pPage) { - if (!pPage) { - return; - } - - for (DWORD i = 0; i < pPage->cControlIndices; ++i) { - THEME_CONTROL* pControl = _theme->rgControls + pPage->rgdwControlIndices[i]; - BOOL enableControl = TRUE; - - // If this is a named control, try to set its default state. - if (pControl->sczName && *pControl->sczName) { - // If this is a checkable control, try to set its default state - // to the state of a matching named Burn variable. - if (IsCheckable(pControl)) { - LONGLONG llValue = 0; - HRESULT hr = BalGetNumericVariable(pControl->sczName, &llValue); - - // If the control value isn't set then disable it. - if (!SUCCEEDED(hr)) { - enableControl = FALSE; - } else { - ThemeSendControlMessage( - _theme, - pControl->wId, - BM_SETCHECK, - SUCCEEDED(hr) && llValue ? BST_CHECKED : BST_UNCHECKED, - 0 - ); - } - } - - // Hide or disable controls based on the control name with 'State' appended - LPWSTR controlName = nullptr; - HRESULT hr = StrAllocFormatted(&controlName, L"%lsState", pControl->sczName); - if (SUCCEEDED(hr)) { - LPWSTR controlState = nullptr; - hr = BalGetStringVariable(controlName, &controlState); - if (SUCCEEDED(hr) && controlState && *controlState) { - if (controlState[0] == '[') { - LPWSTR formatted = nullptr; - if (SUCCEEDED(BalFormatString(controlState, &formatted))) { - StrFree(controlState); - controlState = formatted; - } - } - - if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, controlState, -1, L"disable", -1)) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Disable control %ls", pControl->sczName); - enableControl = FALSE; - } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, controlState, -1, L"hide", -1)) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Hide control %ls", pControl->sczName); - // TODO: This doesn't work - ThemeShowControl(_theme, pControl->wId, SW_HIDE); - } else { - // An explicit state can override the lack of a - // backing variable. - enableControl = TRUE; - } - } - StrFree(controlState); - } - StrFree(controlName); - controlName = nullptr; - - - // If a command link has a note, then add it. - if ((pControl->dwStyle & BS_TYPEMASK) == BS_COMMANDLINK || - (pControl->dwStyle & BS_TYPEMASK) == BS_DEFCOMMANDLINK) { - hr = StrAllocFormatted(&controlName, L"#(loc.%lsNote)", pControl->sczName); - if (SUCCEEDED(hr)) { - LOC_STRING *locText = nullptr; - hr = LocGetString(_wixLoc, controlName, &locText); - if (SUCCEEDED(hr) && locText && locText->wzText && locText->wzText[0]) { - LPWSTR text = nullptr; - hr = BalFormatString(locText->wzText, &text); - if (SUCCEEDED(hr) && text && text[0]) { - ThemeSendControlMessage(_theme, pControl->wId, BCM_SETNOTE, 0, (LPARAM)text); - ReleaseStr(text); - text = nullptr; - } - } - ReleaseStr(controlName); - controlName = nullptr; - } - hr = S_OK; - } - } - - ThemeControlEnable(_theme, pControl->wId, enableControl); - - // Format the text in each of the new page's controls - if (pControl->sczText && *pControl->sczText) { - // If the wix developer is showing a hidden variable - // in the UI, then obviously they don't care about - // keeping it safe so don't go down the rabbit hole - // of making sure that this is securely freed. - LPWSTR text = nullptr; - HRESULT hr = BalFormatString(pControl->sczText, &text); - if (SUCCEEDED(hr)) { - ThemeSetTextControl(_theme, pControl->wId, text); - } - } - } - } - - // - // OnClose - called when the window is trying to be closed. - // - BOOL OnClose() { - BOOL close = FALSE; - - // If we've already succeeded or failed or showing the help page, just close (prompts are annoying if the bootstrapper is done). - if (PYBA_STATE_APPLIED <= _state || PYBA_STATE_HELP == _state) { - close = TRUE; - } else { - // prompt the user or force the cancel if there is no UI. - close = PromptCancel( - _hWnd, - BOOTSTRAPPER_DISPLAY_FULL != _command.display, - _confirmCloseMessage ? _confirmCloseMessage : L"Are you sure you want to cancel?", - _theme->sczCaption - ); - } - - // If we're doing progress then we never close, we just cancel to let rollback occur. - if (PYBA_STATE_APPLYING <= _state && PYBA_STATE_APPLIED > _state) { - // If we canceled disable cancel button since clicking it again is silly. - if (close) { - ThemeControlEnable(_theme, ID_PROGRESS_CANCEL_BUTTON, FALSE); - } - - close = FALSE; - } - - return close; - } - - // - // OnClickCloseButton - close the application. - // - void OnClickCloseButton() { - ::SendMessageW(_hWnd, WM_CLOSE, 0, 0); - } - - - - // - // OnClickRestartButton - allows the restart and closes the app. - // - void OnClickRestartButton() { - AssertSz(_restartRequired, "Restart must be requested to be able to click on the restart button."); - - _allowRestart = TRUE; - ::SendMessageW(_hWnd, WM_CLOSE, 0, 0); - - return; - } - - - // - // OnClickLogFileLink - show the log file. - // - void OnClickLogFileLink() { - HRESULT hr = S_OK; - LPWSTR sczLogFile = nullptr; - - hr = BalGetStringVariable(_bundle.sczLogVariable, &sczLogFile); - BalExitOnFailure1(hr, "Failed to get log file variable '%ls'.", _bundle.sczLogVariable); - - hr = ShelExec(L"notepad.exe", sczLogFile, L"open", nullptr, SW_SHOWDEFAULT, _hWnd, nullptr); - BalExitOnFailure1(hr, "Failed to open log file target: %ls", sczLogFile); - - LExit: - ReleaseStr(sczLogFile); - - return; - } - - - // - // SetState - // - void SetState(__in PYBA_STATE state, __in HRESULT hrStatus) { - if (FAILED(hrStatus)) { - _hrFinal = hrStatus; - } - - if (FAILED(_hrFinal)) { - state = PYBA_STATE_FAILED; - } - - if (_state != state) { - ::PostMessageW(_hWnd, WM_PYBA_CHANGE_STATE, 0, state); - } - } - - // - // GoToPage - // - void GoToPage(__in PAGE page) { - _installPage = page; - ::PostMessageW(_hWnd, WM_PYBA_CHANGE_STATE, 0, _state); - } - - void DeterminePageId(__in PYBA_STATE state, __out DWORD* pdwPageId) { - LONGLONG simple; - - if (BOOTSTRAPPER_DISPLAY_PASSIVE == _command.display) { - switch (state) { - case PYBA_STATE_INITIALIZED: - *pdwPageId = BOOTSTRAPPER_ACTION_HELP == _command.action - ? _pageIds[PAGE_HELP] - : _pageIds[PAGE_LOADING]; - break; - - case PYBA_STATE_HELP: - *pdwPageId = _pageIds[PAGE_HELP]; - break; - - case PYBA_STATE_DETECTING: - *pdwPageId = _pageIds[PAGE_LOADING] - ? _pageIds[PAGE_LOADING] - : _pageIds[PAGE_PROGRESS_PASSIVE] - ? _pageIds[PAGE_PROGRESS_PASSIVE] - : _pageIds[PAGE_PROGRESS]; - break; - - case PYBA_STATE_DETECTED: __fallthrough; - case PYBA_STATE_PLANNING: __fallthrough; - case PYBA_STATE_PLANNED: __fallthrough; - case PYBA_STATE_APPLYING: __fallthrough; - case PYBA_STATE_CACHING: __fallthrough; - case PYBA_STATE_CACHED: __fallthrough; - case PYBA_STATE_EXECUTING: __fallthrough; - case PYBA_STATE_EXECUTED: - *pdwPageId = _pageIds[PAGE_PROGRESS_PASSIVE] - ? _pageIds[PAGE_PROGRESS_PASSIVE] - : _pageIds[PAGE_PROGRESS]; - break; - - default: - *pdwPageId = 0; - break; - } - } else if (BOOTSTRAPPER_DISPLAY_FULL == _command.display) { - switch (state) { - case PYBA_STATE_INITIALIZING: - *pdwPageId = 0; - break; - - case PYBA_STATE_INITIALIZED: - *pdwPageId = BOOTSTRAPPER_ACTION_HELP == _command.action - ? _pageIds[PAGE_HELP] - : _pageIds[PAGE_LOADING]; - break; - - case PYBA_STATE_HELP: - *pdwPageId = _pageIds[PAGE_HELP]; - break; - - case PYBA_STATE_DETECTING: - *pdwPageId = _pageIds[PAGE_LOADING]; - break; - - case PYBA_STATE_DETECTED: - if (_installPage == PAGE_LOADING) { - switch (_command.action) { - case BOOTSTRAPPER_ACTION_INSTALL: - if (_upgrading) { - _installPage = PAGE_UPGRADE; - } else if (SUCCEEDED(BalGetNumericVariable(L"SimpleInstall", &simple)) && simple) { - _installPage = PAGE_SIMPLE_INSTALL; - } else { - _installPage = PAGE_INSTALL; - } - break; - - case BOOTSTRAPPER_ACTION_MODIFY: __fallthrough; - case BOOTSTRAPPER_ACTION_REPAIR: __fallthrough; - case BOOTSTRAPPER_ACTION_UNINSTALL: - _installPage = PAGE_MODIFY; - break; - } - } - *pdwPageId = _pageIds[_installPage]; - break; - - case PYBA_STATE_PLANNING: __fallthrough; - case PYBA_STATE_PLANNED: __fallthrough; - case PYBA_STATE_APPLYING: __fallthrough; - case PYBA_STATE_CACHING: __fallthrough; - case PYBA_STATE_CACHED: __fallthrough; - case PYBA_STATE_EXECUTING: __fallthrough; - case PYBA_STATE_EXECUTED: - *pdwPageId = _pageIds[PAGE_PROGRESS]; - break; - - case PYBA_STATE_APPLIED: - *pdwPageId = _pageIds[PAGE_SUCCESS]; - break; - - case PYBA_STATE_FAILED: - *pdwPageId = _pageIds[PAGE_FAILURE]; - break; - } - } - } - - BOOL WillElevate() { - static BAL_CONDITION WILL_ELEVATE_CONDITION = { - L"not WixBundleElevated and (" - /*Elevate when installing for all users*/ - L"InstallAllUsers or " - /*Elevate when installing the launcher for all users and it was not detected*/ - L"(Include_launcher and InstallLauncherAllUsers and not BlockedLauncher)" - L")", - L"" - }; - BOOL result; - - return SUCCEEDED(BalConditionEvaluate(&WILL_ELEVATE_CONDITION, _engine, &result, nullptr)) && result; - } - - BOOL IsCrtInstalled() { - if (_crtInstalledToken > 0) { - return TRUE; - } else if (_crtInstalledToken == 0) { - return FALSE; - } - - // Check whether at least CRT v10.0.10137.0 is available. - // It should only be installed as a Windows Update package, which means - // we don't need to worry about 32-bit/64-bit. - LPCWSTR crtFile = L"ucrtbase.dll"; - - DWORD cbVer = GetFileVersionInfoSizeW(crtFile, nullptr); - if (!cbVer) { - _crtInstalledToken = 0; - return FALSE; - } - - void *pData = malloc(cbVer); - if (!pData) { - _crtInstalledToken = 0; - return FALSE; - } - - if (!GetFileVersionInfoW(crtFile, 0, cbVer, pData)) { - free(pData); - _crtInstalledToken = 0; - return FALSE; - } - - VS_FIXEDFILEINFO *ffi; - UINT cb; - BOOL result = FALSE; - - if (VerQueryValueW(pData, L"\\", (LPVOID*)&ffi, &cb) && - ffi->dwFileVersionMS == 0x000A0000 && ffi->dwFileVersionLS >= 0x27990000) { - result = TRUE; - } - - free(pData); - _crtInstalledToken = result ? 1 : 0; - return result; - } - - HRESULT EvaluateConditions() { - HRESULT hr = S_OK; - BOOL result = FALSE; - - for (DWORD i = 0; i < _conditions.cConditions; ++i) { - BAL_CONDITION* pCondition = _conditions.rgConditions + i; - - hr = BalConditionEvaluate(pCondition, _engine, &result, &_failedMessage); - BalExitOnFailure(hr, "Failed to evaluate condition."); - - if (!result) { - // Hope they didn't have hidden variables in their message, because it's going in the log in plaintext. - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "%ls", _failedMessage); - - hr = E_WIXSTDBA_CONDITION_FAILED; - // todo: remove in WiX v4, in case people are relying on v3.x logging behavior - BalExitOnFailure1(hr, "Bundle condition evaluated to false: %ls", pCondition->sczCondition); - } - } - - ReleaseNullStrSecure(_failedMessage); - - LExit: - return hr; - } - - - void SetTaskbarButtonProgress(__in DWORD dwOverallPercentage) { - HRESULT hr = S_OK; - - if (_taskbarButtonOK) { - hr = _taskbarList->SetProgressValue(_hWnd, dwOverallPercentage, 100UL); - BalExitOnFailure1(hr, "Failed to set taskbar button progress to: %d%%.", dwOverallPercentage); - } - - LExit: - return; - } - - - void SetTaskbarButtonState(__in TBPFLAG tbpFlags) { - HRESULT hr = S_OK; - - if (_taskbarButtonOK) { - hr = _taskbarList->SetProgressState(_hWnd, tbpFlags); - BalExitOnFailure1(hr, "Failed to set taskbar button state.", tbpFlags); - } - - LExit: - return; - } - - - void SetProgressState(__in HRESULT hrStatus) { - TBPFLAG flag = TBPF_NORMAL; - - if (IsCanceled() || HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT) == hrStatus) { - flag = TBPF_PAUSED; - } else if (IsRollingBack() || FAILED(hrStatus)) { - flag = TBPF_ERROR; - } - - SetTaskbarButtonState(flag); - } - - - HRESULT LoadBootstrapperBAFunctions() { - HRESULT hr = S_OK; - LPWSTR sczBafPath = nullptr; - - hr = PathRelativeToModule(&sczBafPath, L"bafunctions.dll", _hModule); - BalExitOnFailure(hr, "Failed to get path to BA function DLL."); - -#ifdef DEBUG - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "PYBA: LoadBootstrapperBAFunctions() - BA function DLL %ls", sczBafPath); -#endif - - _hBAFModule = ::LoadLibraryW(sczBafPath); - if (_hBAFModule) { - auto pfnBAFunctionCreate = reinterpret_cast(::GetProcAddress(_hBAFModule, "CreateBootstrapperBAFunction")); - BalExitOnNullWithLastError1(pfnBAFunctionCreate, hr, "Failed to get CreateBootstrapperBAFunction entry-point from: %ls", sczBafPath); - - hr = pfnBAFunctionCreate(_engine, _hBAFModule, &_baFunction); - BalExitOnFailure(hr, "Failed to create BA function."); - } -#ifdef DEBUG - else { - BalLogError(HRESULT_FROM_WIN32(::GetLastError()), "PYBA: LoadBootstrapperBAFunctions() - Failed to load DLL %ls", sczBafPath); - } -#endif - - LExit: - if (_hBAFModule && !_baFunction) { - ::FreeLibrary(_hBAFModule); - _hBAFModule = nullptr; - } - ReleaseStr(sczBafPath); - - return hr; - } - - BOOL IsCheckable(THEME_CONTROL* pControl) { - if (!pControl->sczName || !pControl->sczName[0]) { - return FALSE; - } - - if (pControl->type == THEME_CONTROL_TYPE_CHECKBOX) { - return TRUE; - } - - if (pControl->type == THEME_CONTROL_TYPE_BUTTON) { - if ((pControl->dwStyle & BS_TYPEMASK) == BS_AUTORADIOBUTTON) { - return TRUE; - } - } - - return FALSE; - } - - void SavePageSettings() { - DWORD pageId = 0; - THEME_PAGE* pPage = nullptr; - - DeterminePageId(_state, &pageId); - pPage = ThemeGetPage(_theme, pageId); - if (!pPage) { - return; - } - - for (DWORD i = 0; i < pPage->cControlIndices; ++i) { - // Loop through all the checkable controls and set a Burn variable - // with that name to true or false. - THEME_CONTROL* pControl = _theme->rgControls + pPage->rgdwControlIndices[i]; - if (IsCheckable(pControl) && ThemeControlEnabled(_theme, pControl->wId)) { - BOOL checked = ThemeIsControlChecked(_theme, pControl->wId); - _engine->SetVariableNumeric(pControl->sczName, checked ? 1 : 0); - } - - // Loop through all the editbox controls with names and set a - // Burn variable with that name to the contents. - if (THEME_CONTROL_TYPE_EDITBOX == pControl->type && pControl->sczName && *pControl->sczName) { - LPWSTR sczValue = nullptr; - ThemeGetTextControl(_theme, pControl->wId, &sczValue); - _engine->SetVariableString(pControl->sczName, sczValue); - } - } - } - - static bool IsTargetPlatformx64(__in IBootstrapperEngine* pEngine) { - WCHAR platform[8]; - DWORD platformLen = 8; - - if (FAILED(pEngine->GetVariableString(L"TargetPlatform", platform, &platformLen))) { - return S_FALSE; - } - - return ::CompareStringW(LOCALE_NEUTRAL, 0, platform, -1, L"x64", -1) == CSTR_EQUAL; - } - - static bool IsTargetPlatformARM64(__in IBootstrapperEngine* pEngine) { - WCHAR platform[8]; - DWORD platformLen = 8; - - if (FAILED(pEngine->GetVariableString(L"TargetPlatform", platform, &platformLen))) { - return S_FALSE; - } - - return ::CompareStringW(LOCALE_NEUTRAL, 0, platform, -1, L"ARM64", -1) == CSTR_EQUAL; - } - - static HRESULT LoadOptionalFeatureStatesFromKey( - __in IBootstrapperEngine* pEngine, - __in HKEY hkHive, - __in LPCWSTR subkey - ) { - HKEY hKey; - LRESULT res; - - if (IsTargetPlatformx64(pEngine) || IsTargetPlatformARM64(pEngine)) { - res = RegOpenKeyExW(hkHive, subkey, 0, KEY_READ | KEY_WOW64_64KEY, &hKey); - } else { - res = RegOpenKeyExW(hkHive, subkey, 0, KEY_READ | KEY_WOW64_32KEY, &hKey); - } - if (res == ERROR_FILE_NOT_FOUND) { - return S_FALSE; - } - if (res != ERROR_SUCCESS) { - return HRESULT_FROM_WIN32(res); - } - - for (auto p = OPTIONAL_FEATURES; p->regName; ++p) { - res = RegQueryValueExW(hKey, p->regName, nullptr, nullptr, nullptr, nullptr); - if (res == ERROR_FILE_NOT_FOUND) { - pEngine->SetVariableNumeric(p->variableName, 0); - } else if (res == ERROR_SUCCESS) { - pEngine->SetVariableNumeric(p->variableName, 1); - } else { - RegCloseKey(hKey); - return HRESULT_FROM_WIN32(res); - } - } - - RegCloseKey(hKey); - return S_OK; - } - - static HRESULT LoadTargetDirFromKey( - __in IBootstrapperEngine* pEngine, - __in HKEY hkHive, - __in LPCWSTR subkey - ) { - HKEY hKey; - LRESULT res; - DWORD dataType; - BYTE buffer[1024]; - DWORD bufferLen = sizeof(buffer); - - if (IsTargetPlatformx64(pEngine) || IsTargetPlatformARM64(pEngine)) { - res = RegOpenKeyExW(hkHive, subkey, 0, KEY_READ | KEY_WOW64_64KEY, &hKey); - } else { - res = RegOpenKeyExW(hkHive, subkey, 0, KEY_READ | KEY_WOW64_32KEY, &hKey); - } - if (res == ERROR_FILE_NOT_FOUND) { - return S_FALSE; - } - if (res != ERROR_SUCCESS) { - return HRESULT_FROM_WIN32(res); - } - - res = RegQueryValueExW(hKey, nullptr, nullptr, &dataType, buffer, &bufferLen); - if (res == ERROR_SUCCESS && dataType == REG_SZ && bufferLen < sizeof(buffer)) { - pEngine->SetVariableString(L"TargetDir", reinterpret_cast(buffer)); - } - RegCloseKey(hKey); - return HRESULT_FROM_WIN32(res); - } - - static HRESULT LoadAssociateFilesStateFromKey( - __in IBootstrapperEngine* pEngine, - __in HKEY hkHive - ) { - const LPCWSTR subkey = L"Software\\Python\\PyLauncher"; - HKEY hKey; - LRESULT res; - HRESULT hr; - - res = RegOpenKeyExW(hkHive, subkey, 0, KEY_READ | KEY_WOW64_32KEY, &hKey); - - if (res == ERROR_FILE_NOT_FOUND) { - return S_FALSE; - } - if (res != ERROR_SUCCESS) { - return HRESULT_FROM_WIN32(res); - } - - res = RegQueryValueExW(hKey, L"AssociateFiles", nullptr, nullptr, nullptr, nullptr); - if (res == ERROR_FILE_NOT_FOUND) { - hr = S_FALSE; - } else if (res == ERROR_SUCCESS) { - hr = S_OK; - } else { - hr = HRESULT_FROM_WIN32(res); - } - - RegCloseKey(hKey); - return hr; - } - - static void LoadOptionalFeatureStates(__in IBootstrapperEngine* pEngine) { - WCHAR subkeyFmt[256]; - WCHAR subkey[256]; - DWORD subkeyLen; - HRESULT hr; - HKEY hkHive; - - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Loading state of optional features"); - - // Get the registry key from the bundle, to save having to duplicate it - // in multiple places. - subkeyLen = sizeof(subkeyFmt) / sizeof(subkeyFmt[0]); - hr = pEngine->GetVariableString(L"OptionalFeaturesRegistryKey", subkeyFmt, &subkeyLen); - BalExitOnFailure(hr, "Failed to locate registry key"); - subkeyLen = sizeof(subkey) / sizeof(subkey[0]); - hr = pEngine->FormatString(subkeyFmt, subkey, &subkeyLen); - BalExitOnFailure1(hr, "Failed to format %ls", subkeyFmt); - - // Check the current user's registry for existing features - hkHive = HKEY_CURRENT_USER; - hr = LoadOptionalFeatureStatesFromKey(pEngine, hkHive, subkey); - BalExitOnFailure1(hr, "Failed to read from HKCU\\%ls", subkey); - if (hr == S_FALSE) { - // Now check the local machine registry - hkHive = HKEY_LOCAL_MACHINE; - hr = LoadOptionalFeatureStatesFromKey(pEngine, hkHive, subkey); - BalExitOnFailure1(hr, "Failed to read from HKLM\\%ls", subkey); - if (hr == S_OK) { - // Found a system-wide install, so enable these settings. - pEngine->SetVariableNumeric(L"InstallAllUsers", 1); - pEngine->SetVariableNumeric(L"CompileAll", 1); - } - } - - if (hr == S_OK) { - // Cannot change InstallAllUsersState when upgrading. While there's - // no good reason to not allow installing a per-user and an all-user - // version simultaneously, Burn can't handle the state management - // and will need to uninstall the old one. - pEngine->SetVariableString(L"InstallAllUsersState", L"disable"); - - // Get the previous install directory. This can be changed by the - // user. - subkeyLen = sizeof(subkeyFmt) / sizeof(subkeyFmt[0]); - hr = pEngine->GetVariableString(L"TargetDirRegistryKey", subkeyFmt, &subkeyLen); - BalExitOnFailure(hr, "Failed to locate registry key"); - subkeyLen = sizeof(subkey) / sizeof(subkey[0]); - hr = pEngine->FormatString(subkeyFmt, subkey, &subkeyLen); - BalExitOnFailure1(hr, "Failed to format %ls", subkeyFmt); - LoadTargetDirFromKey(pEngine, hkHive, subkey); - } - - LExit: - return; - } - - HRESULT EnsureTargetDir() { - LONGLONG installAllUsers; - LPWSTR targetDir = nullptr, defaultDir = nullptr; - HRESULT hr = BalGetStringVariable(L"TargetDir", &targetDir); - if (FAILED(hr) || !targetDir || !targetDir[0]) { - ReleaseStr(targetDir); - targetDir = nullptr; - - hr = BalGetNumericVariable(L"InstallAllUsers", &installAllUsers); - ExitOnFailure(hr, L"Failed to get install scope"); - - hr = BalGetStringVariable( - installAllUsers ? L"DefaultAllUsersTargetDir" : L"DefaultJustForMeTargetDir", - &defaultDir - ); - BalExitOnFailure(hr, "Failed to get the default install directory"); - - if (!defaultDir || !defaultDir[0]) { - BalLogError(E_INVALIDARG, "Default install directory is blank"); - } - - hr = BalFormatString(defaultDir, &targetDir); - BalExitOnFailure1(hr, "Failed to format '%ls'", defaultDir); - - hr = _engine->SetVariableString(L"TargetDir", targetDir); - BalExitOnFailure(hr, "Failed to set install target directory"); - } - LExit: - ReleaseStr(defaultDir); - ReleaseStr(targetDir); - return hr; - } - - void ValidateOperatingSystem() { - LOC_STRING *pLocString = nullptr; - - if (IsWindowsServer()) { - if (IsWindowsVersionOrGreater(10, 0, 0)) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Target OS is Windows Server 2016 or later"); - return; - } else if (IsWindowsVersionOrGreater(6, 2, 0)) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Detected Windows Server 2012"); - } else if (IsWindowsVersionOrGreater(6, 1, 1)) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Detected Windows Server 2008 R2"); - } else if (IsWindowsVersionOrGreater(6, 1, 0)) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Detected Windows Server 2008 R2"); - } else if (IsWindowsVersionOrGreater(6, 0, 0)) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Detected Windows Server 2008"); - } else { - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Detected Windows Server 2003 or earlier"); - } - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Windows Server 2016 or later is required to continue installation"); - } else { - if (IsWindows10OrGreater()) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Target OS is Windows 10 or later"); - return; - } else if (IsWindows8Point1OrGreater()) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Detected Windows 8.1"); - } else if (IsWindows8OrGreater()) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Detected Windows 8"); - } else if (IsWindows7OrGreater()) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Detected Windows 7"); - } else if (IsWindowsVistaOrGreater()) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Detected Windows Vista"); - } else { - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Detected Windows XP or earlier"); - } - BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Windows 10 or later is required to continue installation"); - } - - LocGetString(_wixLoc, L"#(loc.FailureOldOS)", &pLocString); - if (pLocString && pLocString->wzText) { - BalFormatString(pLocString->wzText, &_failedMessage); - } - - _hrFinal = E_WIXSTDBA_CONDITION_FAILED; - } - -public: - // - // Constructor - initialize member variables. - // - PythonBootstrapperApplication( - __in HMODULE hModule, - __in BOOL fPrereq, - __in HRESULT hrHostInitialization, - __in IBootstrapperEngine* pEngine, - __in const BOOTSTRAPPER_COMMAND* pCommand - ) : CBalBaseBootstrapperApplication(pEngine, pCommand, 3, 3000) { - _hModule = hModule; - memcpy_s(&_command, sizeof(_command), pCommand, sizeof(BOOTSTRAPPER_COMMAND)); - - LONGLONG llInstalled = 0; - HRESULT hr = BalGetNumericVariable(L"WixBundleInstalled", &llInstalled); - if (SUCCEEDED(hr) && BOOTSTRAPPER_RESUME_TYPE_REBOOT != _command.resumeType && 0 < llInstalled && BOOTSTRAPPER_ACTION_INSTALL == _command.action) { - _command.action = BOOTSTRAPPER_ACTION_MODIFY; - } else if (0 == llInstalled && (BOOTSTRAPPER_ACTION_MODIFY == _command.action || BOOTSTRAPPER_ACTION_REPAIR == _command.action)) { - _command.action = BOOTSTRAPPER_ACTION_INSTALL; - } - - _plannedAction = BOOTSTRAPPER_ACTION_UNKNOWN; - - - // When resuming from restart doing some install-like operation, try to find the package that forced the - // restart. We'll use this information during planning. - _nextPackageAfterRestart = nullptr; - - if (BOOTSTRAPPER_RESUME_TYPE_REBOOT == _command.resumeType && BOOTSTRAPPER_ACTION_UNINSTALL < _command.action) { - // Ensure the forced restart package variable is null when it is an empty string. - HRESULT hr = BalGetStringVariable(L"WixBundleForcedRestartPackage", &_nextPackageAfterRestart); - if (FAILED(hr) || !_nextPackageAfterRestart || !*_nextPackageAfterRestart) { - ReleaseNullStr(_nextPackageAfterRestart); - } - } - - _crtInstalledToken = -1; - pEngine->SetVariableNumeric(L"CRTInstalled", IsCrtInstalled() ? 1 : 0); - - _wixLoc = nullptr; - memset(&_bundle, 0, sizeof(_bundle)); - memset(&_conditions, 0, sizeof(_conditions)); - _confirmCloseMessage = nullptr; - _failedMessage = nullptr; - - _language = nullptr; - _theme = nullptr; - memset(_pageIds, 0, sizeof(_pageIds)); - _hUiThread = nullptr; - _registered = FALSE; - _hWnd = nullptr; - - _state = PYBA_STATE_INITIALIZING; - _visiblePageId = 0; - _installPage = PAGE_LOADING; - _hrFinal = hrHostInitialization; - - _downgradingOtherVersion = FALSE; - _restartResult = BOOTSTRAPPER_APPLY_RESTART_NONE; - _restartRequired = FALSE; - _allowRestart = FALSE; - - _suppressDowngradeFailure = FALSE; - _suppressRepair = FALSE; - _modifying = FALSE; - _upgrading = FALSE; - - _overridableVariables = nullptr; - _taskbarList = nullptr; - _taskbarButtonCreatedMessage = UINT_MAX; - _taskbarButtonOK = FALSE; - _showingInternalUIThisPackage = FALSE; - - _suppressPaint = FALSE; - - pEngine->AddRef(); - _engine = pEngine; - - _hBAFModule = nullptr; - _baFunction = nullptr; - } - - - // - // Destructor - release member variables. - // - ~PythonBootstrapperApplication() { - AssertSz(!::IsWindow(_hWnd), "Window should have been destroyed before destructor."); - AssertSz(!_theme, "Theme should have been released before destructor."); - - ReleaseObject(_taskbarList); - ReleaseDict(_overridableVariables); - ReleaseStr(_failedMessage); - ReleaseStr(_confirmCloseMessage); - BalConditionsUninitialize(&_conditions); - BalInfoUninitialize(&_bundle); - LocFree(_wixLoc); - - ReleaseStr(_language); - ReleaseStr(_nextPackageAfterRestart); - ReleaseNullObject(_engine); - - if (_hBAFModule) { - ::FreeLibrary(_hBAFModule); - _hBAFModule = nullptr; - } - } - -private: - HMODULE _hModule; - BOOTSTRAPPER_COMMAND _command; - IBootstrapperEngine* _engine; - BOOTSTRAPPER_ACTION _plannedAction; - - LPWSTR _nextPackageAfterRestart; - - WIX_LOCALIZATION* _wixLoc; - BAL_INFO_BUNDLE _bundle; - BAL_CONDITIONS _conditions; - LPWSTR _failedMessage; - LPWSTR _confirmCloseMessage; - - LPWSTR _language; - THEME* _theme; - DWORD _pageIds[countof(PAGE_NAMES)]; - HANDLE _hUiThread; - BOOL _registered; - HWND _hWnd; - - PYBA_STATE _state; - HRESULT _hrFinal; - DWORD _visiblePageId; - PAGE _installPage; - - BOOL _startedExecution; - DWORD _calculatedCacheProgress; - DWORD _calculatedExecuteProgress; - - BOOL _downgradingOtherVersion; - BOOTSTRAPPER_APPLY_RESTART _restartResult; - BOOL _restartRequired; - BOOL _allowRestart; - - BOOL _suppressDowngradeFailure; - BOOL _suppressRepair; - BOOL _modifying; - BOOL _upgrading; - - int _crtInstalledToken; - - STRINGDICT_HANDLE _overridableVariables; - - ITaskbarList3* _taskbarList; - UINT _taskbarButtonCreatedMessage; - BOOL _taskbarButtonOK; - BOOL _showingInternalUIThisPackage; - - BOOL _suppressPaint; - - HMODULE _hBAFModule; - IBootstrapperBAFunction* _baFunction; -}; - -// -// CreateBootstrapperApplication - creates a new IBootstrapperApplication object. -// -HRESULT CreateBootstrapperApplication( - __in HMODULE hModule, - __in BOOL fPrereq, - __in HRESULT hrHostInitialization, - __in IBootstrapperEngine* pEngine, - __in const BOOTSTRAPPER_COMMAND* pCommand, - __out IBootstrapperApplication** ppApplication - ) { - HRESULT hr = S_OK; - - if (fPrereq) { - hr = E_INVALIDARG; - ExitWithLastError(hr, "Failed to create UI thread."); - } - - PythonBootstrapperApplication* pApplication = nullptr; - - pApplication = new PythonBootstrapperApplication(hModule, fPrereq, hrHostInitialization, pEngine, pCommand); - ExitOnNull(pApplication, hr, E_OUTOFMEMORY, "Failed to create new standard bootstrapper application object."); - - *ppApplication = pApplication; - pApplication = nullptr; - -LExit: - ReleaseObject(pApplication); - return hr; -} diff --git a/Tools/msi/bundle/bootstrap/pch.cpp b/Tools/msi/bundle/bootstrap/pch.cpp deleted file mode 100644 index 1d9f38c57d63f19..000000000000000 --- a/Tools/msi/bundle/bootstrap/pch.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "pch.h" diff --git a/Tools/msi/bundle/bootstrap/pch.h b/Tools/msi/bundle/bootstrap/pch.h deleted file mode 100644 index 6d0974b34c61e79..000000000000000 --- a/Tools/msi/bundle/bootstrap/pch.h +++ /dev/null @@ -1,60 +0,0 @@ -//------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2004, Outercurve Foundation. -// This software is released under Microsoft Reciprocal License (MS-RL). -// The license and further copyright text can be found in the file -// LICENSE.TXT at the root directory of the distribution. -// -// -// -// Precompiled header for standard bootstrapper application. -// -//------------------------------------------------------------------------------------------------- - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "dutil.h" -#include "memutil.h" -#include "dictutil.h" -#include "dirutil.h" -#include "fileutil.h" -#include "locutil.h" -#include "logutil.h" -#include "pathutil.h" -#include "resrutil.h" -#include "shelutil.h" -#include "strutil.h" -#include "thmutil.h" -#include "uriutil.h" -#include "xmlutil.h" - -#include "IBootstrapperEngine.h" -#include "IBootstrapperApplication.h" - -#include "BalBaseBootstrapperApplication.h" -#include "balinfo.h" -#include "balcondition.h" - -HRESULT CreateBootstrapperApplication( - __in HMODULE hModule, - __in BOOL fPrereq, - __in HRESULT hrHostInitialization, - __in IBootstrapperEngine* pEngine, - __in const BOOTSTRAPPER_COMMAND* pCommand, - __out IBootstrapperApplication** ppApplication -); - -#include "IBootstrapperBAFunction.h" - diff --git a/Tools/msi/bundle/bootstrap/pythonba.cpp b/Tools/msi/bundle/bootstrap/pythonba.cpp deleted file mode 100644 index 0ce45ad31d958a5..000000000000000 --- a/Tools/msi/bundle/bootstrap/pythonba.cpp +++ /dev/null @@ -1,76 +0,0 @@ -//------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2004, Outercurve Foundation. -// This software is released under Microsoft Reciprocal License (MS-RL). -// The license and further copyright text can be found in the file -// LICENSE.TXT at the root directory of the distribution. -// -// -// -// Setup chainer/bootstrapper standard UI for WiX toolset. -// -//------------------------------------------------------------------------------------------------- - -#include "pch.h" - -static HINSTANCE vhInstance = NULL; - -extern "C" BOOL WINAPI DllMain( - IN HINSTANCE hInstance, - IN DWORD dwReason, - IN LPVOID /* pvReserved */ - ) -{ - switch(dwReason) - { - case DLL_PROCESS_ATTACH: - ::DisableThreadLibraryCalls(hInstance); - vhInstance = hInstance; - break; - - case DLL_PROCESS_DETACH: - vhInstance = NULL; - break; - } - - return TRUE; -} - - -extern "C" HRESULT WINAPI BootstrapperApplicationCreate( - __in IBootstrapperEngine* pEngine, - __in const BOOTSTRAPPER_COMMAND* pCommand, - __out IBootstrapperApplication** ppApplication - ) -{ - HRESULT hr = S_OK; - - BalInitialize(pEngine); - - hr = CreateBootstrapperApplication(vhInstance, FALSE, S_OK, pEngine, pCommand, ppApplication); - BalExitOnFailure(hr, "Failed to create bootstrapper application interface."); - -LExit: - return hr; -} - - -extern "C" void WINAPI BootstrapperApplicationDestroy() -{ - BalUninitialize(); -} - - -extern "C" HRESULT WINAPI MbaPrereqBootstrapperApplicationCreate( - __in HRESULT hrHostInitialization, - __in IBootstrapperEngine* pEngine, - __in const BOOTSTRAPPER_COMMAND* pCommand, - __out IBootstrapperApplication** ppApplication - ) -{ - return E_NOTIMPL; -} - - -extern "C" void WINAPI MbaPrereqBootstrapperApplicationDestroy() -{ } diff --git a/Tools/msi/bundle/bootstrap/pythonba.def b/Tools/msi/bundle/bootstrap/pythonba.def deleted file mode 100644 index 29b3fa50dfa9f70..000000000000000 --- a/Tools/msi/bundle/bootstrap/pythonba.def +++ /dev/null @@ -1,18 +0,0 @@ -;------------------------------------------------------------------------------------------------- -; -; Copyright (c) 2004, Outercurve Foundation. -; This software is released under Microsoft Reciprocal License (MS-RL). -; The license and further copyright text can be found in the file -; LICENSE.TXT at the root directory of the distribution. -; -; -; -; WiX Standard Bootstrapper Application DLL entry points. -; -;------------------------------------------------------------------------------------------------- - -EXPORTS - BootstrapperApplicationCreate - BootstrapperApplicationDestroy - MbaPrereqBootstrapperApplicationCreate - MbaPrereqBootstrapperApplicationDestroy diff --git a/Tools/msi/bundle/bootstrap/pythonba.sln b/Tools/msi/bundle/bootstrap/pythonba.sln deleted file mode 100644 index bf43fed9018e4f3..000000000000000 --- a/Tools/msi/bundle/bootstrap/pythonba.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30501.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythonba", "pythonba.vcxproj", "{7A09B132-B3EE-499B-A700-A4B2157FEA3D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7A09B132-B3EE-499B-A700-A4B2157FEA3D}.Debug|Win32.ActiveCfg = Debug|Win32 - {7A09B132-B3EE-499B-A700-A4B2157FEA3D}.Debug|Win32.Build.0 = Debug|Win32 - {7A09B132-B3EE-499B-A700-A4B2157FEA3D}.Release|Win32.ActiveCfg = Release|Win32 - {7A09B132-B3EE-499B-A700-A4B2157FEA3D}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Tools/msi/bundle/bootstrap/pythonba.vcxproj b/Tools/msi/bundle/bootstrap/pythonba.vcxproj deleted file mode 100644 index 4b38582f0d31e51..000000000000000 --- a/Tools/msi/bundle/bootstrap/pythonba.vcxproj +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - Debug - Win32 - - - Release - Win32 - - - - Release - Win32 - v145 - v143 - v142 - v141 - {7A09B132-B3EE-499B-A700-A4B2157FEA3D} - PythonBA - - - - - DynamicLibrary - Unicode - $(PySourcePath)PCbuild\obj\ - $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\msi_$(ProjectName)\ - $(IntDir.Replace(`\\`, `\`)) - $(IntDir) - - - - - ARM64=1;%(PreprocessorDefinitions) - _CRT_STDIO_LEGACY_WIDE_SPECIFIERS=1;%(PreprocessorDefinitions) - $(WixInstallPath)sdk\inc - Use - pch.h - MultiThreaded - - - comctl32.lib;gdiplus.lib;msimg32.lib;shlwapi.lib;wininet.lib;dutil.lib;balutil.lib;version.lib;uxtheme.lib;%(AdditionalDependencies) - $(WixInstallPath)sdk\vs2017\lib\x86 - pythonba.def - true - - - - - - - Create - - - - - - - - - - - diff --git a/Tools/msi/bundle/bootstrap/resource.h b/Tools/msi/bundle/bootstrap/resource.h deleted file mode 100644 index d951e651f6d20d7..000000000000000 --- a/Tools/msi/bundle/bootstrap/resource.h +++ /dev/null @@ -1,25 +0,0 @@ -//------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2004, Outercurve Foundation. -// This software is released under Microsoft Reciprocal License (MS-RL). -// The license and further copyright text can be found in the file -// LICENSE.TXT at the root directory of the distribution. -// -//------------------------------------------------------------------------------------------------- - -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// -#define IDC_STATIC -1 - - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1003 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/Tools/msi/bundle/bundle.targets b/Tools/msi/bundle/bundle.targets deleted file mode 100644 index cb3effb4434843a..000000000000000 --- a/Tools/msi/bundle/bundle.targets +++ /dev/null @@ -1,129 +0,0 @@ - - - - 2.0 - Bundle - - Release - 1132;1135;1140 - $(OutputName)-$(PythonVersion) - $(OutputName)-$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber).$(RevisionNumber) - $(OutputName)-amd64 - $(OutputName)-arm64 - $(OutputName)-$(OutputSuffix) - $(OutputName)-d - $(OutputName) - - $(OutputPath)en-us\ - $(OutputPath) - - - $(DownloadUrlBase.TrimEnd(`/`))/{version}/{arch}{releasename}/{msi} - $(DefineConstants);DownloadUrl=$(DownloadUrl.Replace(`{version}`, `$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)`).Replace(`{arch}`, `$(ArchName)`).Replace(`{releasename}`, `$(ReleaseLevelName)`).Replace(`{msi}`, `{2}`)) - $(DefineConstants);DownloadUrl={2} - - - - - WixUtilExtension - WixUtilExtension - - - WixDependencyExtension - WixDependencyExtension - - - WixBalExtension - WixBalExtension - - - - - - - - - - - - - - - - - - - - - - - BuildForRelease=$(BuildForRelease) - - - - - - - - - - - - - - - - - - - Build - - - - - Rebuild - - - - - - - - - - - - - - - - $(DefineConstants);BootstrapApp=$(BootstrapAppPath) - - - - - - - - - $(DefineConstants);DefaultWxl=Default.wxl - - - - - - - - - $(DefineConstants);DefaultWxl=$(IntermediateOutputPath)Default.wxl - - - - - diff --git a/Tools/msi/bundle/bundle.wxl b/Tools/msi/bundle/bundle.wxl deleted file mode 100644 index d7a65c48dc4dc53..000000000000000 --- a/Tools/msi/bundle/bundle.wxl +++ /dev/null @@ -1,7 +0,0 @@ - - - C Runtime Update (KB2999226) - Precompiling standard library - Precompiling standard library (-O) - Precompiling standard library (-OO) - diff --git a/Tools/msi/bundle/bundle.wxs b/Tools/msi/bundle/bundle.wxs deleted file mode 100644 index 3fcb00553f5edd3..000000000000000 --- a/Tools/msi/bundle/bundle.wxs +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/bundle/full.wixproj b/Tools/msi/bundle/full.wixproj deleted file mode 100644 index bdbdd8e175c0332..000000000000000 --- a/Tools/msi/bundle/full.wixproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - {3E204ADD-238D-4D10-852C-4F859325C839} - python - full - - - - - - - $(DefineConstants); - CompressMSI=yes; - CompressPDB=yes; - CompressMSI_D=yes; - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/packagegroups/core.wxs b/Tools/msi/bundle/packagegroups/core.wxs deleted file mode 100644 index eb3d0b7733cf0fd..000000000000000 --- a/Tools/msi/bundle/packagegroups/core.wxs +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/packagegroups/crt.wxs b/Tools/msi/bundle/packagegroups/crt.wxs deleted file mode 100644 index f931da1403b2278..000000000000000 --- a/Tools/msi/bundle/packagegroups/crt.wxs +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/packagegroups/dev.wxs b/Tools/msi/bundle/packagegroups/dev.wxs deleted file mode 100644 index 4284dba2c205b73..000000000000000 --- a/Tools/msi/bundle/packagegroups/dev.wxs +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/packagegroups/doc.wxs b/Tools/msi/bundle/packagegroups/doc.wxs deleted file mode 100644 index 6639ff5c25b24be..000000000000000 --- a/Tools/msi/bundle/packagegroups/doc.wxs +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/packagegroups/exe.wxs b/Tools/msi/bundle/packagegroups/exe.wxs deleted file mode 100644 index 79464c4aca66222..000000000000000 --- a/Tools/msi/bundle/packagegroups/exe.wxs +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/packagegroups/freethreaded.wxs b/Tools/msi/bundle/packagegroups/freethreaded.wxs deleted file mode 100644 index 121ca34ab661578..000000000000000 --- a/Tools/msi/bundle/packagegroups/freethreaded.wxs +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/packagegroups/launcher.wxs b/Tools/msi/bundle/packagegroups/launcher.wxs deleted file mode 100644 index 080598a0a486ef4..000000000000000 --- a/Tools/msi/bundle/packagegroups/launcher.wxs +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/packagegroups/lib.wxs b/Tools/msi/bundle/packagegroups/lib.wxs deleted file mode 100644 index 0b3fbc00c4a35db..000000000000000 --- a/Tools/msi/bundle/packagegroups/lib.wxs +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/packagegroups/packageinstall.wxs b/Tools/msi/bundle/packagegroups/packageinstall.wxs deleted file mode 100644 index e5e7d4d1a94cd1f..000000000000000 --- a/Tools/msi/bundle/packagegroups/packageinstall.wxs +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/packagegroups/pip.wxs b/Tools/msi/bundle/packagegroups/pip.wxs deleted file mode 100644 index 201a6c445b23691..000000000000000 --- a/Tools/msi/bundle/packagegroups/pip.wxs +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/packagegroups/postinstall.wxs b/Tools/msi/bundle/packagegroups/postinstall.wxs deleted file mode 100644 index 24c72e6357ab082..000000000000000 --- a/Tools/msi/bundle/packagegroups/postinstall.wxs +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/bundle/packagegroups/tcltk.wxs b/Tools/msi/bundle/packagegroups/tcltk.wxs deleted file mode 100644 index 0d029a90cd966ed..000000000000000 --- a/Tools/msi/bundle/packagegroups/tcltk.wxs +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/packagegroups/test.wxs b/Tools/msi/bundle/packagegroups/test.wxs deleted file mode 100644 index 32acaef64efea07..000000000000000 --- a/Tools/msi/bundle/packagegroups/test.wxs +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/releaselocal.wixproj b/Tools/msi/bundle/releaselocal.wixproj deleted file mode 100644 index 0c3dee7ad81ea19..000000000000000 --- a/Tools/msi/bundle/releaselocal.wixproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - {FCD43AC9-969F-49A1-8AC5-EDC27599D1EB} - python - - - - - - - - $(DefineConstants); - CompressMSI=yes; - CompressPDB=no; - CompressMSI_D=no - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/releaseweb.wixproj b/Tools/msi/bundle/releaseweb.wixproj deleted file mode 100644 index 350c735878c0b4a..000000000000000 --- a/Tools/msi/bundle/releaseweb.wixproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - {71CDE213-CB39-4BD9-B89D-BBB878689144} - python - webinstall - - - - - - - $(DefineConstants); - CompressMSI=no; - CompressPDB=no; - CompressMSI_D=no - - - - - \ No newline at end of file diff --git a/Tools/msi/bundle/snapshot.wixproj b/Tools/msi/bundle/snapshot.wixproj deleted file mode 100644 index cc450432990635e..000000000000000 --- a/Tools/msi/bundle/snapshot.wixproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - {8A4A1162-4BF9-4FF6-9A98-315F01E44932} - python - - - - - - - - $(DefineConstants);CompressMSI=no; - - - $(DefineConstants);CompressMSI=yes; - - - $(DefineConstants); - CompressPDB=no; - CompressMSI_D=no; - - - - - \ No newline at end of file diff --git a/Tools/msi/common.wxs b/Tools/msi/common.wxs deleted file mode 100644 index 73da474e4181f11..000000000000000 --- a/Tools/msi/common.wxs +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - OPTIONALFEATURESREGISTRYKEY - - - - - - - - - - - - - - - - - - - - - Installed OR NOT MISSING_CORE - - - - Installed OR NOT DOWNGRADE - Installed OR TARGETDIR OR Suppress_TARGETDIR_Check - - - UPGRADE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/common_en-US.wxl_template b/Tools/msi/common_en-US.wxl_template deleted file mode 100644 index adb8f40be9a8e23..000000000000000 --- a/Tools/msi/common_en-US.wxl_template +++ /dev/null @@ -1,18 +0,0 @@ - - - 1033 - en-us - Python {{ShortVersion}} - Python {{LongVersion}} ({{Bitness}}) - Python {{LongVersion}} !(loc.Descriptor) ({{Bitness}}) - Python {{LongVersion}} !(loc.Descriptor) ({{Bitness}}) - Python {{LongVersion}} !(loc.Descriptor) ({{Bitness}} symbols) - Python {{LongVersion}} !(loc.Descriptor) ({{Bitness}} symbols) - Python {{LongVersion}} !(loc.Descriptor) ({{Bitness}} debug) - Python {{LongVersion}} !(loc.Descriptor) ({{Bitness}} debug) - Python Software Foundation - A newer version of !(loc.ProductName) is already installed. - An incorrect version of a prerequisite package is installed. Please uninstall any other versions of !(loc.ProductName) and try installing this again. - The TARGETDIR variable must be provided when invoking this installer. - https://www.python.org/ - diff --git a/Tools/msi/core/core.wixproj b/Tools/msi/core/core.wixproj deleted file mode 100644 index 68e8bab3109dcce..000000000000000 --- a/Tools/msi/core/core.wixproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - {1B4502D5-B627-4F50-ABEA-4CC5A8E88265} - 2.0 - core - Package - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/core/core.wxs b/Tools/msi/core/core.wxs deleted file mode 100644 index 21a8bcdf9710174..000000000000000 --- a/Tools/msi/core/core.wxs +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Tools/msi/core/core_d.wixproj b/Tools/msi/core/core_d.wixproj deleted file mode 100644 index 5b296bf35f95807..000000000000000 --- a/Tools/msi/core/core_d.wixproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - {D3677DCF-098A-4398-9FA5-8E74AC37E0DF} - 2.0 - core_d - Package - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/core/core_d.wxs b/Tools/msi/core/core_d.wxs deleted file mode 100644 index 1cee0973aac312f..000000000000000 --- a/Tools/msi/core/core_d.wxs +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/Tools/msi/core/core_en-US.wxl b/Tools/msi/core/core_en-US.wxl deleted file mode 100644 index 7977470d7c1c0eb..000000000000000 --- a/Tools/msi/core/core_en-US.wxl +++ /dev/null @@ -1,5 +0,0 @@ - - - Core Interpreter - core - diff --git a/Tools/msi/core/core_files.wxs b/Tools/msi/core/core_files.wxs deleted file mode 100644 index 8b21501078ea2e6..000000000000000 --- a/Tools/msi/core/core_files.wxs +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/core/core_pdb.wixproj b/Tools/msi/core/core_pdb.wixproj deleted file mode 100644 index 9c8838970b6fee9..000000000000000 --- a/Tools/msi/core/core_pdb.wixproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - {E98E7539-64E7-4DCE-AACD-01E3ADE40EFD} - 2.0 - core_pdb - Package - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/core/core_pdb.wxs b/Tools/msi/core/core_pdb.wxs deleted file mode 100644 index 1fe7d1e7a944cb9..000000000000000 --- a/Tools/msi/core/core_pdb.wxs +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/Tools/msi/csv_to_wxs.py b/Tools/msi/csv_to_wxs.py deleted file mode 100644 index 235c8f8b0be5812..000000000000000 --- a/Tools/msi/csv_to_wxs.py +++ /dev/null @@ -1,127 +0,0 @@ -''' -Processes a CSV file containing a list of files into a WXS file with -components for each listed file. - -The CSV columns are: - source of file, target for file, group name - -Usage:: - py txt_to_wxs.py [path to file list .csv] [path to destination .wxs] - -This is necessary to handle structures where some directories only -contain other directories. MSBuild is not able to generate the -Directory entries in the WXS file correctly, as it operates on files. -Python, however, can easily fill in the gap. -''' - -__author__ = "Steve Dower " - -import csv -import re -import sys - -from collections import defaultdict -from itertools import chain, zip_longest -from pathlib import PureWindowsPath -from uuid import uuid1 - -ID_CHAR_SUBS = { - '-': '_', - '+': '_P', -} - -def make_id(path): - return re.sub( - r'[^A-Za-z0-9_.]', - lambda m: ID_CHAR_SUBS.get(m.group(0), '_'), - str(path).rstrip('/\\'), - flags=re.I - ) - -DIRECTORIES = set() - -def main(file_source, install_target): - with open(file_source, 'r', newline='') as f: - files = list(csv.reader(f)) - - assert len(files) == len(set(make_id(f[1]) for f in files)), "Duplicate file IDs exist" - - directories = defaultdict(set) - cache_directories = defaultdict(set) - groups = defaultdict(list) - for source, target, group, disk_id, condition in files: - target = PureWindowsPath(target) - groups[group].append((source, target, disk_id, condition)) - - if target.suffix.lower() in {".py", ".pyw"}: - cache_directories[group].add(target.parent) - - for dirname in target.parents: - parent = make_id(dirname.parent) - if parent and parent != '.': - directories[parent].add(dirname.name) - - lines = [ - '', - ' ', - ] - for dir_parent in sorted(directories): - lines.append(' '.format(dir_parent)) - for dir_name in sorted(directories[dir_parent]): - lines.append(' '.format(dir_parent, make_id(dir_name), dir_name)) - lines.append(' ') - for dir_parent in (make_id(d) for group in cache_directories.values() for d in group): - lines.append(' '.format(dir_parent)) - lines.append(' '.format(dir_parent)) - lines.append(' ') - lines.append(' ') - - for group in sorted(groups): - lines.extend([ - ' ', - ' '.format(group), - ]) - for source, target, disk_id, condition in groups[group]: - lines.append(' '.format(make_id(target), make_id(target.parent))) - if condition: - lines.append(' {}'.format(condition)) - - if disk_id: - lines.append(' '.format(make_id(target), target.name, source, disk_id)) - else: - lines.append(' '.format(make_id(target), target.name, source)) - lines.append(' ') - - create_folders = {make_id(p) + "___pycache__" for p in cache_directories[group]} - remove_folders = {make_id(p2) for p1 in cache_directories[group] for p2 in chain((p1,), p1.parents)} - create_folders.discard(".") - remove_folders.discard(".") - if create_folders or remove_folders: - lines.append(' '.format(group, uuid1())) - lines.extend(' '.format(p) for p in create_folders) - lines.extend(' '.format(p) for p in create_folders) - lines.extend(' '.format(p) for p in create_folders | remove_folders) - lines.append(' ') - - lines.extend([ - ' ', - ' ', - ]) - lines.append('') - - # Check if the file matches. If so, we don't want to touch it so - # that we can skip rebuilding. - try: - with open(install_target, 'r') as f: - if all(x.rstrip('\r\n') == y for x, y in zip_longest(f, lines)): - print('File is up to date') - return - except IOError: - pass - - with open(install_target, 'w') as f: - f.writelines(line + '\n' for line in lines) - print('Wrote {} lines to {}'.format(len(lines), install_target)) - -if __name__ == '__main__': - main(sys.argv[1], sys.argv[2]) diff --git a/Tools/msi/dev/dev.wixproj b/Tools/msi/dev/dev.wixproj deleted file mode 100644 index 4052e4b5368273a..000000000000000 --- a/Tools/msi/dev/dev.wixproj +++ /dev/null @@ -1,29 +0,0 @@ - - - - {5F23F608-D74B-4259-A0CE-8DC65CC7FE53} - 2.0 - dev - Package - - - - - - - - - - - - $(PySourcePath) - !(bindpath.src) - $(PySourcePath) - - dev_include - - - - - diff --git a/Tools/msi/dev/dev.wxs b/Tools/msi/dev/dev.wxs deleted file mode 100644 index 15a08364bead043..000000000000000 --- a/Tools/msi/dev/dev.wxs +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/dev/dev_d.wixproj b/Tools/msi/dev/dev_d.wixproj deleted file mode 100644 index b3b05326d41963f..000000000000000 --- a/Tools/msi/dev/dev_d.wixproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - {C11B4945-76BD-4137-B2E3-649460117A77} - 2.0 - dev_d - Package - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/dev/dev_d.wxs b/Tools/msi/dev/dev_d.wxs deleted file mode 100644 index 20bf9ee256f2f85..000000000000000 --- a/Tools/msi/dev/dev_d.wxs +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Tools/msi/dev/dev_en-US.wxl b/Tools/msi/dev/dev_en-US.wxl deleted file mode 100644 index 2546e13e47a091d..000000000000000 --- a/Tools/msi/dev/dev_en-US.wxl +++ /dev/null @@ -1,5 +0,0 @@ - - - Development Libraries - dev - diff --git a/Tools/msi/dev/dev_files.wxs b/Tools/msi/dev/dev_files.wxs deleted file mode 100644 index a9039d03f5f6fa1..000000000000000 --- a/Tools/msi/dev/dev_files.wxs +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/doc/doc.wixproj b/Tools/msi/doc/doc.wixproj deleted file mode 100644 index 83687968faebea8..000000000000000 --- a/Tools/msi/doc/doc.wixproj +++ /dev/null @@ -1,37 +0,0 @@ - - - - {0D62A2BB-5F71-4447-8C8C-9708407B3674} - 2.0 - doc - Package - - ICE43 - - - - $(PySourcePath)Doc\build\html\ - $(DocHtmlPath)\ - - - - doc_html - - - - - - - - - $(DocHtmlPath) - !(bindpath.doc_html) - $(DocHtmlPath)..\ - Doc_ - doc_html - - - - - \ No newline at end of file diff --git a/Tools/msi/doc/doc.wxs b/Tools/msi/doc/doc.wxs deleted file mode 100644 index 49798c752633fb2..000000000000000 --- a/Tools/msi/doc/doc.wxs +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/doc/doc_en-US.wxl_template b/Tools/msi/doc/doc_en-US.wxl_template deleted file mode 100644 index 809556e29fb9b13..000000000000000 --- a/Tools/msi/doc/doc_en-US.wxl_template +++ /dev/null @@ -1,7 +0,0 @@ - - - doc - Documentation - Python {{ShortVersion}} Manuals ({{Bitness}}) - View the !(loc.ProductName) documentation. - diff --git a/Tools/msi/exe/exe.wixproj b/Tools/msi/exe/exe.wixproj deleted file mode 100644 index 592c8d2f65ae6e0..000000000000000 --- a/Tools/msi/exe/exe.wixproj +++ /dev/null @@ -1,41 +0,0 @@ - - - - {6BD53305-B03E-49DC-85FB-5551B8CCC843} - 2.0 - exe - Package - - - - ICE43 - - - - $(DefineConstants);Include_Vcruntime140_1_dll=1 - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/exe/exe.wxs b/Tools/msi/exe/exe.wxs deleted file mode 100644 index 05a8d775193e38f..000000000000000 --- a/Tools/msi/exe/exe.wxs +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/exe/exe_d.wixproj b/Tools/msi/exe/exe_d.wixproj deleted file mode 100644 index cf085bed4ddcf95..000000000000000 --- a/Tools/msi/exe/exe_d.wixproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - {B1CA739C-8DB0-403B-9010-D79507507CE9} - 2.0 - exe_d - Package - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/exe/exe_d.wxs b/Tools/msi/exe/exe_d.wxs deleted file mode 100644 index 3b327bc26d7893c..000000000000000 --- a/Tools/msi/exe/exe_d.wxs +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Tools/msi/exe/exe_en-US.wxl_template b/Tools/msi/exe/exe_en-US.wxl_template deleted file mode 100644 index 4cd9e3e654b2a1e..000000000000000 --- a/Tools/msi/exe/exe_en-US.wxl_template +++ /dev/null @@ -1,8 +0,0 @@ - - - Executables - executable - Python {{ShortVersion}} ({{Bitness}}) - Launches the !(loc.ProductName) interpreter. - https://www.python.org/ - diff --git a/Tools/msi/exe/exe_files.wxs b/Tools/msi/exe/exe_files.wxs deleted file mode 100644 index 15bf6a06634bf20..000000000000000 --- a/Tools/msi/exe/exe_files.wxs +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/exe/exe_pdb.wixproj b/Tools/msi/exe/exe_pdb.wixproj deleted file mode 100644 index bf1213e9d499680..000000000000000 --- a/Tools/msi/exe/exe_pdb.wixproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - {4A1F7045-8EE2-4276-ABB8-5E0C40E5F38B} - 2.0 - exe_pdb - Package - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/exe/exe_pdb.wxs b/Tools/msi/exe/exe_pdb.wxs deleted file mode 100644 index f706cf3b0e0cf3f..000000000000000 --- a/Tools/msi/exe/exe_pdb.wxs +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Tools/msi/exe/exe_reg.wxs b/Tools/msi/exe/exe_reg.wxs deleted file mode 100644 index 4443c2155485bec..000000000000000 --- a/Tools/msi/exe/exe_reg.wxs +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/freethreaded/freethreaded.wixproj b/Tools/msi/freethreaded/freethreaded.wixproj deleted file mode 100644 index 0b4bd055d779773..000000000000000 --- a/Tools/msi/freethreaded/freethreaded.wixproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - {1B4502D5-B627-4F50-ABEA-4CC5A8E88265} - 2.0 - freethreaded - Package - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/freethreaded/freethreaded.wxs b/Tools/msi/freethreaded/freethreaded.wxs deleted file mode 100644 index 063aa28bf09fceb..000000000000000 --- a/Tools/msi/freethreaded/freethreaded.wxs +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/freethreaded/freethreaded_d.wixproj b/Tools/msi/freethreaded/freethreaded_d.wixproj deleted file mode 100644 index e1563d4f907126f..000000000000000 --- a/Tools/msi/freethreaded/freethreaded_d.wixproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - {D3677DCF-098A-4398-9FA5-8E74AC37E0DF} - 2.0 - freethreaded_d - Package - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/freethreaded/freethreaded_d.wxs b/Tools/msi/freethreaded/freethreaded_d.wxs deleted file mode 100644 index cddf22a6c803d3e..000000000000000 --- a/Tools/msi/freethreaded/freethreaded_d.wxs +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/Tools/msi/freethreaded/freethreaded_en-US.wxl_template b/Tools/msi/freethreaded/freethreaded_en-US.wxl_template deleted file mode 100644 index b9747eb256d24b1..000000000000000 --- a/Tools/msi/freethreaded/freethreaded_en-US.wxl_template +++ /dev/null @@ -1,8 +0,0 @@ - - - Freethreaded Interpreter - freethreaded - Python {{ShortVersion}} ({{Bitness}}, freethreaded) - Launches the !(loc.ProductName) freethreaded interpreter. - https://www.python.org/ - diff --git a/Tools/msi/freethreaded/freethreaded_files.wxs b/Tools/msi/freethreaded/freethreaded_files.wxs deleted file mode 100644 index fdbcaea38eb3175..000000000000000 --- a/Tools/msi/freethreaded/freethreaded_files.wxs +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/freethreaded/freethreaded_pdb.wixproj b/Tools/msi/freethreaded/freethreaded_pdb.wixproj deleted file mode 100644 index 789a4f55ae51918..000000000000000 --- a/Tools/msi/freethreaded/freethreaded_pdb.wixproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - {E98E7539-64E7-4DCE-AACD-01E3ADE40EFD} - 2.0 - freethreaded_pdb - Package - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/freethreaded/freethreaded_pdb.wxs b/Tools/msi/freethreaded/freethreaded_pdb.wxs deleted file mode 100644 index 302ac416fe92753..000000000000000 --- a/Tools/msi/freethreaded/freethreaded_pdb.wxs +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Tools/msi/generate_md5.py b/Tools/msi/generate_md5.py deleted file mode 100644 index 9e4c14731bd11db..000000000000000 --- a/Tools/msi/generate_md5.py +++ /dev/null @@ -1,27 +0,0 @@ -import hashlib -import os -import sys - -def main(): - filenames, hashes, sizes = [], [], [] - - for file in sys.argv[1:]: - if not os.path.isfile(file): - continue - - with open(file, 'rb') as f: - data = f.read() - md5 = hashlib.md5() - md5.update(data) - filenames.append(os.path.split(file)[1]) - hashes.append(md5.hexdigest()) - sizes.append(str(len(data))) - - print('{:40s} {:<32s} {:<9s}'.format('File', 'MD5', 'Size')) - for f, h, s in zip(filenames, hashes, sizes): - print('{:40s} {:>32s} {:>9s}'.format(f, h, s)) - - - -if __name__ == "__main__": - sys.exit(int(main() or 0)) diff --git a/Tools/msi/get_externals.bat b/Tools/msi/get_externals.bat deleted file mode 100644 index c7c7e9f470bc250..000000000000000 --- a/Tools/msi/get_externals.bat +++ /dev/null @@ -1,91 +0,0 @@ -@echo off -setlocal -rem Simple script to fetch source for external libraries - -set HERE=%~dp0 -if "%PCBUILD%"=="" (set PCBUILD=%HERE%..\..\PCbuild\) -if "%EXTERNALS_DIR%"=="" (set EXTERNALS_DIR=%HERE%..\..\externals\windows-installer) -if "%NUGET%"=="" (set NUGET=%EXTERNALS_DIR%\..\nuget.exe) -if "%NUGET_URL%"=="" (set NUGET_URL=https://dist.nuget.org/win-x86-commandline/latest/nuget.exe) - -set DO_FETCH=true -set DO_CLEAN=false - -:CheckOpts -if "%~1"=="--python" (set PYTHON=%2) & shift & shift & goto CheckOpts -if "%~1"=="--organization" (set ORG=%2) & shift & shift & goto CheckOpts -if "%~1"=="-c" (set DO_CLEAN=true) & shift & goto CheckOpts -if "%~1"=="--clean" (set DO_CLEAN=true) & shift & goto CheckOpts -if "%~1"=="--clean-only" (set DO_FETCH=false) & goto clean -if "x%~1" NEQ "x" goto usage - -if "%DO_CLEAN%"=="false" goto fetch -:clean -echo.Cleaning up external libraries. -if exist "%EXTERNALS_DIR%" ( - rem Sometimes this fails the first time; try it twice - rmdir /s /q "%EXTERNALS_DIR%" || rmdir /s /q "%EXTERNALS_DIR%" -) - -if "%DO_FETCH%"=="false" goto end -:fetch - -if "%ORG%"=="" (set ORG=python) - -call "%PCBUILD%\find_python.bat" "%PYTHON%" - -echo.Fetching external libraries... - -set libraries= - -for %%e in (%libraries%) do ( - if exist "%EXTERNALS_DIR%\%%e" ( - echo.%%e already exists, skipping. - ) else ( - echo.Fetching %%e... - %PYTHON% "%PCBUILD%get_external.py" -e "%EXTERNALS_DIR%" -O %ORG% %%e - ) -) - -echo.Fetching external tools... - -set binaries= -rem We always use whatever's latest in the repo for these -set binaries=%binaries% binutils -set binaries=%binaries% gpg -set binaries=%binaries% htmlhelp -set binaries=%binaries% nuget -set binaries=%binaries% redist-1 -set binaries=%binaries% wix-314 - -for %%b in (%binaries%) do ( - if exist "%EXTERNALS_DIR%\%%b" ( - echo.%%b already exists, skipping. - ) else ( - echo.Fetching %%b... - %PYTHON% "%PCBUILD%get_external.py" -e "%EXTERNALS_DIR%" -b -O %ORG% %%b - ) -) - -echo Finished. -goto end - -:usage -echo.Valid options: -c, --clean, --clean-only, --organization, --python, -echo.--no-tkinter, --no-openssl -echo. -echo.Pull all sources and binaries necessary for compiling optional extension -echo.modules that rely on external libraries. -echo. -echo.The --organization option determines which github organization to download -echo.from, the --python option determines which Python 3.6+ interpreter to use -echo.with PCbuild\get_external.py. -echo. -echo.Use the -c or --clean option to remove the entire externals directory. -echo. -echo.Use the --clean-only option to do the same cleaning, without pulling in -echo.anything new. -echo. -exit /b -1 - -:end diff --git a/Tools/msi/launcher/launcher.wixproj b/Tools/msi/launcher/launcher.wixproj deleted file mode 100644 index de770bdd3006c22..000000000000000 --- a/Tools/msi/launcher/launcher.wixproj +++ /dev/null @@ -1,46 +0,0 @@ - - - - {921CF0E6-AEBC-4376-BA1D-CD46EBFE6DA5} - 2.0 - launcher - Package - UpgradeCode=1B68A0EC-4DD3-5134-840E-73854B0863F1;SuppressUpgradeTable=1;$(DefineConstants) - true - ICE80 - <_Rebuild>Build - - - - - - - - - - - - - - <_Rebuild>Rebuild - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/launcher/launcher.wxs b/Tools/msi/launcher/launcher.wxs deleted file mode 100644 index 49f1f7b8c1762ee..000000000000000 --- a/Tools/msi/launcher/launcher.wxs +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NOT Installed AND NOT ALLUSERS=1 - NOT Installed AND ALLUSERS=1 - - - UPGRADE or REMOVE_350_LAUNCHER or REMOVE_360A1_LAUNCHER or UPGRADE_3_11_0 or UPGRADE_3_11_1 - - UPGRADE or REMOVE_350_LAUNCHER or REMOVE_360A1_LAUNCHER - - - - - Installed OR NOT DOWNGRADE OR UPGRADE_3_11_0 OR UPGRADE_3_11_1 - - Installed OR NOT DOWNGRADE - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/launcher/launcher_en-US.wxl b/Tools/msi/launcher/launcher_en-US.wxl deleted file mode 100644 index a7e3827c528bb07..000000000000000 --- a/Tools/msi/launcher/launcher_en-US.wxl +++ /dev/null @@ -1,17 +0,0 @@ - - - 1033 - en-us - Python Launcher - Python Launcher - Python Launcher - Python Software Foundation - A newer version of the Python launcher is already installed. - The TARGETDIR variable must be provided when invoking this installer. - Python File - Python File (no console) - Compiled Python File - Python Extension Module - Python Zip Application File - Python Zip Application File (no console) - diff --git a/Tools/msi/launcher/launcher_files.wxs b/Tools/msi/launcher/launcher_files.wxs deleted file mode 100644 index d9a230e2d35ace2..000000000000000 --- a/Tools/msi/launcher/launcher_files.wxs +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - NOT ALLUSERS=1 - - - - - - ALLUSERS=1 - - - - - VersionNT64 AND NOT ARM64_SHELLEXT - - - - - - NOT VersionNT64 AND NOT ARM64_SHELLEXT - - - - - - ARM64_SHELLEXT - - - - - - - diff --git a/Tools/msi/launcher/launcher_reg.wxs b/Tools/msi/launcher/launcher_reg.wxs deleted file mode 100644 index e8d9d24d43fa8ce..000000000000000 --- a/Tools/msi/launcher/launcher_reg.wxs +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/lib/lib.wixproj b/Tools/msi/lib/lib.wixproj deleted file mode 100644 index 3ea46dd40ea4ce9..000000000000000 --- a/Tools/msi/lib/lib.wixproj +++ /dev/null @@ -1,35 +0,0 @@ - - - - {11367E76-3337-4602-8F1E-77DB4F370D7E} - 2.0 - lib - Package - - - - - - - - - - - - - $(PySourcePath)Lib - !(bindpath.src)Lib\ - $(PySourcePath)Lib - Lib\ - lib_py - true - - - - - diff --git a/Tools/msi/lib/lib.wxs b/Tools/msi/lib/lib.wxs deleted file mode 100644 index e417e31b33783ed..000000000000000 --- a/Tools/msi/lib/lib.wxs +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/lib/lib_d.wixproj b/Tools/msi/lib/lib_d.wixproj deleted file mode 100644 index 587a82c1929da7d..000000000000000 --- a/Tools/msi/lib/lib_d.wixproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - {6C443CD3-8258-4335-BA03-49DA9C34CE4D} - 2.0 - lib_d - Package - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/lib/lib_d.wxs b/Tools/msi/lib/lib_d.wxs deleted file mode 100644 index 7968d179743a009..000000000000000 --- a/Tools/msi/lib/lib_d.wxs +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Tools/msi/lib/lib_en-US.wxl b/Tools/msi/lib/lib_en-US.wxl deleted file mode 100644 index 305bcc73afc8082..000000000000000 --- a/Tools/msi/lib/lib_en-US.wxl +++ /dev/null @@ -1,5 +0,0 @@ - - - Standard Library - lib - diff --git a/Tools/msi/lib/lib_files.wxs b/Tools/msi/lib/lib_files.wxs deleted file mode 100644 index 4d44299f7839099..000000000000000 --- a/Tools/msi/lib/lib_files.wxs +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/lib/lib_pdb.wixproj b/Tools/msi/lib/lib_pdb.wixproj deleted file mode 100644 index db1b5bb316cfead..000000000000000 --- a/Tools/msi/lib/lib_pdb.wixproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - {5E0BCE93-D1AC-4591-BBCB-3A2BE5A4B3D1} - 2.0 - lib_pdb - Package - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/lib/lib_pdb.wxs b/Tools/msi/lib/lib_pdb.wxs deleted file mode 100644 index 7918893a9a25050..000000000000000 --- a/Tools/msi/lib/lib_pdb.wxs +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Tools/msi/make_appx.ps1 b/Tools/msi/make_appx.ps1 deleted file mode 100644 index e32bd76a37f135a..000000000000000 --- a/Tools/msi/make_appx.ps1 +++ /dev/null @@ -1,71 +0,0 @@ -<# -.Synopsis - Compiles and signs an APPX package -.Description - Given the file listing, ensures all the contents are signed - and builds and signs the final package. -.Parameter mapfile - The location on disk of the text mapping file. -.Parameter msix - The path and name to store the APPX/MSIX. -.Parameter sign - When set, signs the APPX/MSIX. Packages to be published to - the store should not be signed. -.Parameter description - Description to embed in the signature (optional). -.Parameter certname - The name of the certificate to sign with (optional). -.Parameter certsha1 - The SHA1 hash of the certificate to sign with (optional). -#> -param( - [Parameter(Mandatory=$true)][string]$layout, - [Parameter(Mandatory=$true)][string]$msix, - [switch]$sign, - [string]$description, - [string]$certname, - [string]$certsha1, - [string]$certfile -) - -$tools = $script:MyInvocation.MyCommand.Path | Split-Path -parent; -Import-Module $tools\sdktools.psm1 -WarningAction SilentlyContinue -Force - -Set-Alias makeappx (Find-Tool "makeappx.exe") -Scope Script -Set-Alias makepri (Find-Tool "makepri.exe") -Scope Script - -$msixdir = Split-Path $msix -Parent -if ($msixdir) { - $msixdir = (mkdir -Force $msixdir).FullName -} else { - $msixdir = Get-Location -} -$msix = Join-Path $msixdir (Split-Path $msix -Leaf) - -pushd $layout -try { - if (Test-Path resources.pri) { - del resources.pri - } - $name = ([xml](gc AppxManifest.xml)).Package.Identity.Name - makepri new /pr . /mn AppxManifest.xml /in $name /cf _resources.xml /of _resources.pri /mf appx /o - if (-not $? -or -not (Test-Path _resources.map.txt)) { - throw "makepri step failed" - } - $lines = gc _resources.map.txt - $lines | ?{ -not ($_ -match '"_resources[\w\.]+?"') } | Out-File _resources.map.txt -Encoding utf8 - makeappx pack /f _resources.map.txt /m AppxManifest.xml /o /p $msix - if (-not $?) { - throw "makeappx step failed" - } -} finally { - popd -} - -if ($sign) { - Sign-File -certname $certname -certsha1 $certsha1 -certfile $certfile -description $description -files $msix - - if (-not $?) { - throw "Package signing failed" - } -} diff --git a/Tools/msi/make_cat.ps1 b/Tools/msi/make_cat.ps1 deleted file mode 100644 index 9ea3ddd495719e6..000000000000000 --- a/Tools/msi/make_cat.ps1 +++ /dev/null @@ -1,45 +0,0 @@ -<# -.Synopsis - Compiles and signs a catalog file. -.Description - Given the CDF definition file, builds and signs a catalog. -.Parameter catalog - The path to the catalog definition file to compile and - sign. It is assumed that the .cat file will be the same - name with a new extension. -.Parameter outfile - The path to move the built .cat file to (optional). -.Parameter description - The description to add to the signature (optional). -.Parameter certname - The name of the certificate to sign with (optional). -.Parameter certsha1 - The SHA1 hash of the certificate to sign with (optional). -#> -param( - [Parameter(Mandatory=$true)][string]$catalog, - [string]$outfile, - [switch]$sign, - [string]$description, - [string]$certname, - [string]$certsha1, - [string]$certfile -) - -$tools = $script:MyInvocation.MyCommand.Path | Split-Path -parent; -Import-Module $tools\sdktools.psm1 -WarningAction SilentlyContinue -Force - -Set-Alias MakeCat (Find-Tool "makecat.exe") -Scope Script - -MakeCat $catalog -if (-not $?) { - throw "Catalog compilation failed" -} -if ($sign) { - Sign-File -certname $certname -certsha1 $certsha1 -certfile $certfile -description $description -files @($catalog -replace 'cdf$', 'cat') -} - -if ($outfile) { - Split-Path -Parent $outfile | ?{ $_ } | %{ mkdir -Force $_; } - Move-Item ($catalog -replace 'cdf$', 'cat') $outfile -} diff --git a/Tools/msi/make_zip.proj b/Tools/msi/make_zip.proj deleted file mode 100644 index 125a434e51f4147..000000000000000 --- a/Tools/msi/make_zip.proj +++ /dev/null @@ -1,40 +0,0 @@ - - - - {10487945-15D1-4092-A214-338395C4116B} - python - - false - - - - - - false - python-$(PythonVersion)-embed-$(ArchName) - .zip - $(OutputPath)\$(TargetName)$(TargetExt) - rmdir /q/s "$(IntermediateOutputPath)\zip_$(ArchName)" - "$(PythonExe)" "$(PySourcePath)PC\layout" - $(Arguments) -b "$(BuildPath.TrimEnd(`\`))" -s "$(PySourcePath.TrimEnd(`\`))" - $(Arguments) -t "$(IntermediateOutputPath)\zip_$(ArchName)" - $(Arguments) --zip "$(TargetPath)" - $(Arguments) --precompile --zip-lib --include-underpth --include-stable --flat-dlls - $(Environment)%0D%0Aset PYTHONPATH=$(PySourcePath)Lib - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/msi.props b/Tools/msi/msi.props deleted file mode 100644 index 097af60715448f1..000000000000000 --- a/Tools/msi/msi.props +++ /dev/null @@ -1,234 +0,0 @@ - - - - $(OutputName) - false - false - $(SuppressIces);ICE03;ICE57;ICE61 - 1026 - false - true - Release - x86 - perUser - <_MakeCatCommand Condition="'$(_MakeCatCommand)' == ''">makecat - true - - - - - - - - - $(ComputerName)/$(ArchName)/ - $(ReleaseUri)/ - - - - - - - - WixUtilExtension - WixUtilExtension - - - - - $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\msi_$(OutputName) - $(IntermediateOutputPath)_$(OutputSuffix) - $(BuildPath) - $(OutputPath)\ - $(OutputPath) - true - $(ExternalsDir)\windows-installer\redist-1\$(Platform) - $([System.IO.Path]::GetFullPath($(CRTRedist))) - $(tcltkDir)lib - python$(MajorVersionNumber)$(MinorVersionNumber)$(MicroVersionNumber)$(ReleaseLevelName).chm - - $(MajorVersionNumber).$(MinorVersionNumber).$(Field3Value).0 - - - - false - - - - $([System.Math]::Floor($([System.DateTime]::Now.Subtract($([System.DateTime]::new(2001, 1, 1))).TotalDays))) - $(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)dev$(RevisionNumber) - $(MajorVersionNumber).$(MinorVersionNumber).$(RevisionNumber).0 - - - - 32-bit - 64-bit - ARM64 - 32bit - 64bit - ARM64 - - $(DefineConstants); - Version=$(InstallerVersion); - ShortVersion=$(MajorVersionNumber).$(MinorVersionNumber); - LongVersion=$(PythonVersion); - MajorVersionNumber=$(MajorVersionNumber); - MinorVersionNumber=$(MinorVersionNumber); - UpgradeMinimumVersion=$(MajorVersionNumber).$(MinorVersionNumber).0.0; - NextMajorVersionNumber=$(MajorVersionNumber).$([msbuild]::Add($(MinorVersionNumber), 1)).0.0; - Bitness=$(Bitness); - PlatformArchitecture=$(PlatformArchitecture); - PyDebugExt=$(PyDebugExt); - PyArchExt=$(PyArchExt); - PyTestExt=$(PyTestExt); - PydTag=$(PydTag); - FreethreadedPydTag=$(FreethreadedPydTag); - OptionalFeatureName=$(OutputName); - ssltag=$(OpenSSLDLLSuffix); - Suffix32=$(PyArchExt); - IncludeFreethreaded=$(IncludeFreethreaded); - - - $(DefineConstants);CRTRedist=$(CRTRedist); - - - - - - generated_filelist - - - false - - - false - - - - - - - - - build - - - build - - - build - - - build_t - - - build_t - - - build_t - - - - src - - - tcltk - - - redist - - - - build32 - - - build64 - - - buildarm64 - - - build32t - - - build64t - - - buildarm64t - - - - - - - - - <_Uuid Include="CoreUpgradeCode"> - upgradecode - - <_Uuid Include="UpgradeCode"> - upgradecode/$(OutputName) - - <_Uuid Include="InstallDirectoryGuidSeed"> - installdirectoryseed - - <_Uuid Include="PythonExeComponentGuid"> - python.exe - - <_Uuid Include="PythonwExeComponentGuid"> - pythonw.exe - - <_Uuid Include="CommonPythonRegComponentGuid"> - registry - - <_Uuid Include="PythonRegComponentGuid"> - registry/$(OutputName) - - <_Uuid Include="FreethreadedPythonExeComponentGuid" Condition="$(IncludeFreethreaded)"> - freethreaded/python.exe - - <_Uuid Include="FreethreadedPythonwExeComponentGuid" Condition="$(IncludeFreethreaded)"> - freethreaded/pythonw.exe - - - - - <_Uuids>@(_Uuid->'("%(Identity)", "$(MajorVersionNumber).$(MinorVersionNumber)/%(Uri)")',',') - <_GenerateCommand>import uuid; print('\n'.join('{}={}'.format(i, uuid.uuid5(uuid.UUID('c8d9733e-a70c-43ff-ab0c-e26456f11083'), '$(ReleaseUri.Replace(`{arch}`, `$(ArchName)`))' + j)) for i,j in [$(_Uuids.Replace(`"`,`'`))])) - - - - - - - - - - $(DefineConstants);@(_UuidValue,';'); - - - diff --git a/Tools/msi/msi.targets b/Tools/msi/msi.targets deleted file mode 100644 index 99d1de4d9d83f58..000000000000000 --- a/Tools/msi/msi.targets +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - <_FileListTarget>$(IntermediateOutputPath)$(MSBuildProjectName).g.csv - <_InstallFilesTarget>$(IntermediateOutputPath)$(MSBuildProjectName).g.wxs - - - - - <_Source>%(Source)$([msbuild]::MakeRelative(%(SourceBase), %(FullPath))) - <_Target>%(Target_)$([msbuild]::MakeRelative(%(TargetBase), %(FullPath))) - - - <_CatalogFiles Include="@(InstallFiles)" Condition="%(InstallFiles.IncludeInCat) and ''!=$([System.IO.File]::ReadAllText(%(InstallFiles.FullPath)))" /> - - - - - - - - - - - - - - <_CatFileSourceTarget>$(IntermediateOutputPath)$(MSBuildProjectName).cdf - <_CatFileTarget>$(IntermediateOutputPath)python_$(MSBuildProjectName).cat - <_CatFile>[CatalogHeader] -Name=$([System.IO.Path]::GetFileName($(_CatFileTarget))) -ResultDir=$([System.IO.Path]::GetDirectoryName($(_CatFileTarget))) -PublicVersion=1 -CatalogVersion=2 -HashAlgorithms=SHA256 -PageHashes=false -EncodingType= - -[CatalogFiles] -@(_CatalogFiles->'<HASH>%(Filename)%(Extension)=%(FullPath)',' -') - - - - - - - - - - - - - - - <_Content>$([System.IO.File]::ReadAllText(%(WxlTemplate.FullPath)).Replace(`{{ShortVersion}}`, `$(MajorVersionNumber).$(MinorVersionNumber)$(PyTestExt)`).Replace(`{{LongVersion}}`, `$(PythonVersion)$(PyTestExt)`).Replace(`{{Bitness}}`, `$(Bitness)`)) - <_ExistingContent Condition="Exists('$(IntermediateOutputPath)%(WxlTemplate.Filename).wxl')">$([System.IO.File]::ReadAllText($(IntermediateOutputPath)%(WxlTemplate.Filename).wxl)) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/path/path.wixproj b/Tools/msi/path/path.wixproj deleted file mode 100644 index 2792e14666d3845..000000000000000 --- a/Tools/msi/path/path.wixproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - {91C99298-8E2E-4422-A5AF-CC4FFF9A58D3} - 2.0 - path - Package - ICE71 - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/path/path.wxs b/Tools/msi/path/path.wxs deleted file mode 100644 index 32854392e8bee3f..000000000000000 --- a/Tools/msi/path/path.wxs +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - NOT ALLUSERS=1 - - - - - - - - - - - - ALLUSERS=1 - - - - - - - - - - - - - - - - diff --git a/Tools/msi/path/path_en-US.wxl b/Tools/msi/path/path_en-US.wxl deleted file mode 100644 index 33a7886fe2d6e20..000000000000000 --- a/Tools/msi/path/path_en-US.wxl +++ /dev/null @@ -1,6 +0,0 @@ - - - Add to Path - Path - No !(loc.ProductName) installation was detected. - diff --git a/Tools/msi/pip/pip.wixproj b/Tools/msi/pip/pip.wixproj deleted file mode 100644 index 718c02c032b73b3..000000000000000 --- a/Tools/msi/pip/pip.wixproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - {91C99298-8E2E-4422-A5AF-CC4FFF9A58D3} - 2.0 - pip - Package - ICE71 - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/pip/pip.wxs b/Tools/msi/pip/pip.wxs deleted file mode 100644 index 627c4710a9fdfaa..000000000000000 --- a/Tools/msi/pip/pip.wxs +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - PYTHON_EXE - - - - - - - - - - - - - - - - - (&DefaultFeature=3) AND NOT (!DefaultFeature=3) - (&DefaultFeature=2) AND (!DefaultFeature=3) - - UpdatePip - - - - diff --git a/Tools/msi/pip/pip_en-US.wxl b/Tools/msi/pip/pip_en-US.wxl deleted file mode 100644 index cd0d9edf3a6b6fd..000000000000000 --- a/Tools/msi/pip/pip_en-US.wxl +++ /dev/null @@ -1,6 +0,0 @@ - - - pip Bootstrap - pip - No !(loc.ProductName) installation was detected. - diff --git a/Tools/msi/purge.py b/Tools/msi/purge.py deleted file mode 100644 index 4a13d368d7c744e..000000000000000 --- a/Tools/msi/purge.py +++ /dev/null @@ -1,76 +0,0 @@ -# Purges the Fastly cache for Windows download files -# -# Usage: -# py -3 purge.py 3.5.1rc1 -# - -__author__ = 'Steve Dower ' -__version__ = '1.0.0' - -import re -import sys - -from urllib.request import Request, urlopen - -VERSION_RE = re.compile(r'(\d+\.\d+\.\d+)([A-Za-z_]+\d+)?$') - -try: - m = VERSION_RE.match(sys.argv[1]) - if not m: - print('Invalid version:', sys.argv[1]) - print('Expected something like "3.5.1rc1"') - sys.exit(1) -except LookupError: - print('Missing version argument. Expected something like "3.5.1rc1"') - sys.exit(1) - -URL = "https://www.python.org/ftp/python/{}/".format(m.group(1)) -REL = m.group(2) or '' - -FILES = [ - "core.msi", - "core_d.msi", - "core_pdb.msi", - "dev.msi", - "dev_d.msi", - "doc.msi", - "exe.msi", - "exe_d.msi", - "exe_pdb.msi", - "launcher.msi", - "lib.msi", - "lib_d.msi", - "lib_pdb.msi", - "path.msi", - "pip.msi", - "tcltk.msi", - "tcltk_d.msi", - "tcltk_pdb.msi", - "test.msi", - "test_d.msi", - "test_pdb.msi", - "tools.msi", - "ucrt.msi", -] -PATHS = [ - "python-{}.exe".format(m.group(0)), - "python-{}-webinstall.exe".format(m.group(0)), - "python-{}-amd64.exe".format(m.group(0)), - "python-{}-amd64-webinstall.exe".format(m.group(0)), - "python-{}-arm64.exe".format(m.group(0)), - "python-{}-arm64-webinstall.exe".format(m.group(0)), - "python-{}-embed-amd64.zip".format(m.group(0)), - "python-{}-embed-win32.zip".format(m.group(0)), - "python-{}-embed-arm64.zip".format(m.group(0)), - *["win32{}/{}".format(REL, f) for f in FILES], - *["amd64{}/{}".format(REL, f) for f in FILES], - *["arm64{}/{}".format(REL, f) for f in FILES], -] -PATHS = PATHS + [p + ".asc" for p in PATHS] - -print('Purged:') -for n in PATHS: - u = URL + n - with urlopen(Request(u, method='PURGE', headers={'Fastly-Soft-Purge': 1})) as r: - r.read() - print(' ', u) diff --git a/Tools/msi/sdktools.psm1 b/Tools/msi/sdktools.psm1 deleted file mode 100644 index c5973f9abc6abf0..000000000000000 --- a/Tools/msi/sdktools.psm1 +++ /dev/null @@ -1,48 +0,0 @@ -function Find-Tool { - param([string]$toolname) - - $kitroot = (gp 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\').KitsRoot10 - $tool = (gci -r "$kitroot\Bin\*\x64\$toolname" | sort FullName -Desc | select -First 1) - if (-not $tool) { - throw "$toolname is not available" - } - Write-Host "Found $toolname at $($tool.FullName)" - return $tool.FullName -} - -Set-Alias SignTool (Find-Tool "signtool.exe") -Scope Script - -function Sign-File { - param([string]$certname, [string]$certsha1, [string]$certfile, [string]$description, [string[]]$files) - - if (-not $description) { - $description = $env:SigningDescription; - if (-not $description) { - $description = "Python"; - } - } - if (-not $certsha1) { - $certsha1 = $env:SigningCertificateSha1; - } - if (-not $certname) { - $certname = $env:SigningCertificate; - } - if (-not $certfile) { - $certfile = $env:SigningCertificateFile; - } - - if (-not ($certsha1 -or $certname -or $certfile)) { - throw "No signing certificate specified" - } - - foreach ($a in $files) { - if ($certsha1) { - SignTool sign /sha1 $certsha1 /fd sha256 /tr http://timestamp.digicert.com/ /td sha256 /d $description $a - } elseif ($certname) { - SignTool sign /a /n $certname /fd sha256 /tr http://timestamp.digicert.com/ /td sha256 /d $description $a - } elseif ($certfile) { - SignTool sign /f $certfile /fd sha256 /tr http://timestamp.digicert.com/ /td sha256 /d $description $a - } - } -} - diff --git a/Tools/msi/sign_build.ps1 b/Tools/msi/sign_build.ps1 deleted file mode 100644 index d3f750454f522b0..000000000000000 --- a/Tools/msi/sign_build.ps1 +++ /dev/null @@ -1,34 +0,0 @@ -<# -.Synopsis - Recursively signs the contents of a directory. -.Description - Given the file patterns, code signs the contents. -.Parameter root - The root directory to sign. -.Parameter patterns - The file patterns to sign -.Parameter description - The description to add to the signature (optional). -.Parameter certname - The name of the certificate to sign with (optional). -.Parameter certsha1 - The SHA1 hash of the certificate to sign with (optional). -#> -param( - [Parameter(Mandatory=$true)][string]$root, - [string[]]$patterns=@("*.exe", "*.dll", "*.pyd", "*.cat"), - [string]$description, - [string]$certname, - [string]$certsha1, - [string]$certfile -) - -$tools = $script:MyInvocation.MyCommand.Path | Split-Path -parent; -Import-Module $tools\sdktools.psm1 -WarningAction SilentlyContinue -Force - -pushd $root -try { - Sign-File -certname $certname -certsha1 $certsha1 -certfile $certfile -description $description -files (gci -r $patterns) -} finally { - popd -} \ No newline at end of file diff --git a/Tools/msi/tcltk/tcltk.wixproj b/Tools/msi/tcltk/tcltk.wixproj deleted file mode 100644 index c8b7ab77c4dc6b7..000000000000000 --- a/Tools/msi/tcltk/tcltk.wixproj +++ /dev/null @@ -1,42 +0,0 @@ - - - - {DB350600-186C-4E52-BA98-26A7CECB067F} - 2.0 - tcltk - Package - - - - ICE43 - - - - - - - - - - - - - $(TclTkLibraryDir) - !(bindpath.tcltk) - $(TclTkLibraryDir) - tcl\ - tcltk_lib - - - - $(PySourcePath) - !(bindpath.src) - $(PySourcePath) - - tkinter_lib - - - - - diff --git a/Tools/msi/tcltk/tcltk.wxs b/Tools/msi/tcltk/tcltk.wxs deleted file mode 100644 index bad56d55cce3723..000000000000000 --- a/Tools/msi/tcltk/tcltk.wxs +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - PYTHON_EXE and PYTHONW_EXE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/tcltk/tcltk_d.wixproj b/Tools/msi/tcltk/tcltk_d.wixproj deleted file mode 100644 index 3266190da0c9a6a..000000000000000 --- a/Tools/msi/tcltk/tcltk_d.wixproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - {EDA1FA5A-E2AA-4EAF-B49B-87D981CD0F16} - 2.0 - tcltk_d - Package - - - - - - - - - - - - $(tcltkDir) - !(bindpath.tcltk) - $(tcltkDir)bin - DLLs\ - tcltk_dlls_d - - - - - \ No newline at end of file diff --git a/Tools/msi/tcltk/tcltk_d.wxs b/Tools/msi/tcltk/tcltk_d.wxs deleted file mode 100644 index 38aacd929995efa..000000000000000 --- a/Tools/msi/tcltk/tcltk_d.wxs +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Tools/msi/tcltk/tcltk_en-US.wxl_template b/Tools/msi/tcltk/tcltk_en-US.wxl_template deleted file mode 100644 index f40fd6239deaa36..000000000000000 --- a/Tools/msi/tcltk/tcltk_en-US.wxl_template +++ /dev/null @@ -1,12 +0,0 @@ - - - Tcl/Tk Support - tcltk - No !(loc.ProductName) installation was detected. - IDLE (Python {{ShortVersion}} {{Bitness}}) - Launches IDLE, the interactive environment for !(loc.ProductName). - Python {{ShortVersion}} Module Docs ({{Bitness}}) - Start the !(loc.ProductName) documentation server. - &Edit with IDLE - Edit with IDLE {{ShortVersion}} ({{Bitness}}) - diff --git a/Tools/msi/tcltk/tcltk_files.wxs b/Tools/msi/tcltk/tcltk_files.wxs deleted file mode 100644 index 7c7784741d9178d..000000000000000 --- a/Tools/msi/tcltk/tcltk_files.wxs +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/tcltk/tcltk_pdb.wixproj b/Tools/msi/tcltk/tcltk_pdb.wixproj deleted file mode 100644 index 3370798a0559dba..000000000000000 --- a/Tools/msi/tcltk/tcltk_pdb.wixproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - {02053AFA-1831-499A-B3EA-D8B223D3C40D} - 2.0 - tcltk_pdb - Package - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/tcltk/tcltk_pdb.wxs b/Tools/msi/tcltk/tcltk_pdb.wxs deleted file mode 100644 index 55f209162553eb0..000000000000000 --- a/Tools/msi/tcltk/tcltk_pdb.wxs +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Tools/msi/tcltk/tcltk_reg.wxs b/Tools/msi/tcltk/tcltk_reg.wxs deleted file mode 100644 index 2778bcc80669b6d..000000000000000 --- a/Tools/msi/tcltk/tcltk_reg.wxs +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - VersionNT > 600 - - - - - VersionNT > 600 - - - - - - VersionNT > 600 - - - - - - - VersionNT > 600 - - - - - - - - VersionNT = 600 - - - - - - - VersionNT = 600 - - - - - - - - diff --git a/Tools/msi/test/test.wixproj b/Tools/msi/test/test.wixproj deleted file mode 100644 index 8347e3f1d3db65b..000000000000000 --- a/Tools/msi/test/test.wixproj +++ /dev/null @@ -1,29 +0,0 @@ - - - - {DE0B7CC2-4358-4131-B3F4-C31C7F2CD468} - 2.0 - test - Package - - - - - - - - - - - - $(PySourcePath) - !(bindpath.src) - $(PySourcePath) - - test_py - - - - - \ No newline at end of file diff --git a/Tools/msi/test/test.wxs b/Tools/msi/test/test.wxs deleted file mode 100644 index 9e497e73a94f5b5..000000000000000 --- a/Tools/msi/test/test.wxs +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/test/test_d.wixproj b/Tools/msi/test/test_d.wixproj deleted file mode 100644 index 33b04be1fe60d63..000000000000000 --- a/Tools/msi/test/test_d.wixproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - {41F5AE8D-24CD-4D03-BE75-AA6F7FAB4097} - 2.0 - test_d - Package - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/test/test_d.wxs b/Tools/msi/test/test_d.wxs deleted file mode 100644 index 9b26ff6a4bf4cc3..000000000000000 --- a/Tools/msi/test/test_d.wxs +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Tools/msi/test/test_en-US.wxl b/Tools/msi/test/test_en-US.wxl deleted file mode 100644 index e615c7a6b7f7062..000000000000000 --- a/Tools/msi/test/test_en-US.wxl +++ /dev/null @@ -1,7 +0,0 @@ - - - Test Suite - test - !(loc.FullProductName) native libtest - !(loc.ProductName) Native Test Modules - diff --git a/Tools/msi/test/test_files.wxs b/Tools/msi/test/test_files.wxs deleted file mode 100644 index 6862a5899db2bac..000000000000000 --- a/Tools/msi/test/test_files.wxs +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/test/test_pdb.wixproj b/Tools/msi/test/test_pdb.wixproj deleted file mode 100644 index 965f0edd9b49924..000000000000000 --- a/Tools/msi/test/test_pdb.wixproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - {7CF48ADD-CFAA-499F-9A05-BA18440A3344} - 2.0 - test_pdb - Package - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/msi/test/test_pdb.wxs b/Tools/msi/test/test_pdb.wxs deleted file mode 100644 index 5a2ef3668400756..000000000000000 --- a/Tools/msi/test/test_pdb.wxs +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Tools/msi/testrelease.bat b/Tools/msi/testrelease.bat deleted file mode 100644 index db98f690151196c..000000000000000 --- a/Tools/msi/testrelease.bat +++ /dev/null @@ -1,115 +0,0 @@ -@setlocal enableextensions -@echo off - -set D=%~dp0 -set PCBUILD=%D%..\..\PCbuild\ - -set TARGETDIR=%TEMP% -set TESTX86= -set TESTX64= -set TESTALLUSER= -set TESTPERUSER= - -:CheckOpts -if "%1" EQU "-h" goto Help -if "%1" EQU "-x86" (set TESTX86=1) && shift && goto CheckOpts -if "%1" EQU "-x64" (set TESTX64=1) && shift && goto CheckOpts -if "%1" EQU "-t" (set TARGETDIR=%~2) && shift && shift && goto CheckOpts -if "%1" EQU "--target" (set TARGETDIR=%~2) && shift && shift && goto CheckOpts -if "%1" EQU "-a" (set TESTALLUSER=1) && shift && goto CheckOpts -if "%1" EQU "--alluser" (set TESTALLUSER=1) && shift && goto CheckOpts -if "%1" EQU "-p" (set TESTPERUSER=1) && shift && goto CheckOpts -if "%1" EQU "--peruser" (set TESTPERUSER=1) && shift && goto CheckOpts - -if not defined TESTX86 if not defined TESTX64 (set TESTX86=1) && (set TESTX64=1) -if not defined TESTALLUSER if not defined TESTPERUSER (set TESTALLUSER=1) && (set TESTPERUSER=1) - - -if defined TESTX86 ( - for %%f in ("%PCBUILD%win32\en-us\*.exe") do ( - if defined TESTALLUSER call :test "%%~ff" "%TARGETDIR%\%%~nf-alluser" "InstallAllUsers=1 CompileAll=1" - if errorlevel 1 exit /B - if defined TESTPERUSER call :test "%%~ff" "%TARGETDIR%\%%~nf-peruser" "InstallAllUsers=0 CompileAll=0" - if errorlevel 1 exit /B - ) -) - -if defined TESTX64 ( - for %%f in ("%PCBUILD%amd64\en-us\*.exe") do ( - if defined TESTALLUSER call :test "%%~ff" "%TARGETDIR%\%%~nf-alluser" "InstallAllUsers=1 CompileAll=1" - if errorlevel 1 exit /B - if defined TESTPERUSER call :test "%%~ff" "%TARGETDIR%\%%~nf-peruser" "InstallAllUsers=0 CompileAll=0" - if errorlevel 1 exit /B - ) -) - -exit /B 0 - -:test -@setlocal -@echo on - -@if not exist "%~1" exit /B 1 - -@set EXE=%~1 -@if not "%EXE:embed=%"=="%EXE%" exit /B 0 - -@set EXITCODE=0 -@echo Installing %1 into %2 -"%~1" /passive /log "%~2\install\log.txt" TargetDir="%~2\Python" Include_debug=1 Include_symbols=1 %~3 - -@if not errorlevel 1 ( - @echo Printing version - "%~2\Python\python.exe" -c "import sys; print(sys.version)" > "%~2\version.txt" 2>&1 -) - -@if not errorlevel 1 ( - @echo Capturing Start Menu - @dir /s/b "%PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs" | findstr /ic:"python" > "%~2\startmenu.txt" 2>&1 - @dir /s/b "%APPDATA%\Microsoft\Windows\Start Menu\Programs" | findstr /ic:"python" >> "%~2\startmenu.txt" 2>&1 - - @echo Capturing registry - @for /F "usebackq" %%f in (`reg query HKCR /s /f python /k`) do @( - echo %%f >> "%~2\hkcr.txt" - reg query "%%f" /s >> "%~2\hkcr.txt" 2>&1 - ) - @reg query HKCU\Software\Python /s > "%~2\hkcu.txt" 2>&1 - @reg query HKLM\Software\Python /reg:32 /s > "%~2\hklm.txt" 2>&1 - @reg query HKLM\Software\Python /reg:64 /s >> "%~2\hklm.txt" 2>&1 - cmd /k exit 0 -) - -@if not errorlevel 1 ( - @echo Installing package - "%~2\Python\python.exe" -m pip install "azure<0.10" > "%~2\pip.txt" 2>&1 - @if not errorlevel 1 ( - "%~2\Python\python.exe" -m pip uninstall -y azure python-dateutil six >> "%~2\pip.txt" 2>&1 - ) -) -@if not errorlevel 1 ( - @echo Testing Tcl/tk - "%~2\Python\python.exe" -m test -uall -v test_ttk_guionly test_tk test_idle > "%~2\tcltk.txt" 2>&1 -) - -@set EXITCODE=%ERRORLEVEL% - -@echo Result was %EXITCODE% -@echo Removing %1 -"%~1" /passive /uninstall /log "%~2\uninstall\log.txt" - -@echo off -exit /B %EXITCODE% - -:Help -echo testrelease.bat [--target TARGET] [-x86] [-x64] [--alluser] [--peruser] [-h] -echo. -echo --target (-t) Specify the target directory for installs and logs -echo -x86 Run tests for x86 installers -echo -x64 Run tests for x64 installers -echo --alluser (-a) Run tests for all-user installs (requires Administrator) -echo --peruser (-p) Run tests for per-user installs -echo -h Display this help information -echo. -echo If no test architecture is specified, all architectures will be tested. -echo If no install type is selected, all install types will be tested. -echo. diff --git a/Tools/msi/ucrt/ucrt.wixproj b/Tools/msi/ucrt/ucrt.wixproj deleted file mode 100644 index 52a7e0e672b9aff..000000000000000 --- a/Tools/msi/ucrt/ucrt.wixproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - {E233091D-2EE3-49D8-A7F1-6E266CE1B6B1} - 2.0 - ucrt - Package - - - - - - - - - - - $(CRTRedist) - !(bindpath.redist)\ - $(CRTRedist)\ucrt - InstallDirectory\ - ucrt_dll - false - - - - - \ No newline at end of file diff --git a/Tools/msi/ucrt/ucrt.wxs b/Tools/msi/ucrt/ucrt.wxs deleted file mode 100644 index e9e2a9a9045115b..000000000000000 --- a/Tools/msi/ucrt/ucrt.wxs +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Tools/msi/ucrt/ucrt_en-US.wxl b/Tools/msi/ucrt/ucrt_en-US.wxl deleted file mode 100644 index f42dd5fe44cd590..000000000000000 --- a/Tools/msi/ucrt/ucrt_en-US.wxl +++ /dev/null @@ -1,5 +0,0 @@ - - - C Runtime Library - ucrt - diff --git a/Tools/msi/uploadrelease.bat b/Tools/msi/uploadrelease.bat deleted file mode 100644 index f262489cce60857..000000000000000 --- a/Tools/msi/uploadrelease.bat +++ /dev/null @@ -1,109 +0,0 @@ -@setlocal -@echo off - -set D=%~dp0 -set PCBUILD=%D%..\..\PCbuild\ - -set HOST= -set USER= -set TARGET= -set DRYRUN=false -set NOUPLOAD= -set NOGPG= -set NOPURGE= -set NOTEST= - -:CheckOpts -if "%1" EQU "-h" goto Help -if "%1" EQU "-o" (set HOST=%~2) && shift && shift && goto CheckOpts -if "%1" EQU "--host" (set HOST=%~2) && shift && shift && goto CheckOpts -if "%1" EQU "-u" (set USER=%~2) && shift && shift && goto CheckOpts -if "%1" EQU "--user" (set USER=%~2) && shift && shift && goto CheckOpts -if "%1" EQU "-t" (set TARGET=%~2) && shift && shift && goto CheckOpts -if "%1" EQU "--target" (set TARGET=%~2) && shift && shift && goto CheckOpts -if "%1" EQU "--dry-run" (set DRYRUN=true) && shift && goto CheckOpts -if "%1" EQU "--skip-upload" (set NOUPLOAD=true) && shift && goto CheckOpts -if "%1" EQU "--skip-gpg" (set NOGPG=true) && shift && goto CheckOpts -if "%1" EQU "--skip-purge" (set NOPURGE=true) && shift && goto CheckOpts -if "%1" EQU "--skip-test" (set NOTEST=true) && shift && goto CheckOpts -if "%1" EQU "-T" (set NOTEST=true) && shift && goto CheckOpts -if "%1" NEQ "" echo Unexpected argument "%1" & exit /B 1 - -if not defined PLINK where plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc" -if not defined PLINK where /R "%ProgramFiles(x86)%\PuTTY" plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc" -if not defined PLINK where /R "%ProgramFiles%\PuTTY" plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc" -if not defined PLINK where /R "%ProgramFiles(x86)%" plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc" -if not defined PLINK where /R "%ProgramFiles%" plink > "%TEMP%\plink.loc" 2> nul && set /P PLINK= < "%TEMP%\plink.loc" & del "%TEMP%\plink.loc" -if not defined PLINK echo Cannot locate plink.exe & exit /B 1 -echo Found plink.exe at %PLINK% - -if not defined PSCP where pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc" -if not defined PSCP where /R "%ProgramFiles(x86)%\PuTTY" pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc" -if not defined PSCP where /R "%ProgramFiles%\PuTTY" pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc" -if not defined PSCP where /R "%ProgramFiles(x86)%" pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc" -if not defined PSCP where /R "%ProgramFiles%" pscp > "%TEMP%\pscp.loc" 2> nul && set /P pscp= < "%TEMP%\pscp.loc" & del "%TEMP%\pscp.loc" -if not defined PSCP echo Cannot locate pscp.exe & exit /B 1 -echo Found pscp.exe at %PSCP% - -if defined NOGPG ( - set GPG= - echo Skipping GPG signature generation because of --skip-gpg -) else ( - if not defined GPG where gpg2 > "%TEMP%\gpg.loc" 2> nul && set /P GPG= < "%TEMP%\gpg.loc" & del "%TEMP%\gpg.loc" - if not defined GPG where /R "%PCBUILD%..\externals\windows-installer" gpg2 > "%TEMP%\gpg.loc" 2> nul && set /P GPG= < "%TEMP%\gpg.loc" & del "%TEMP%\gpg.loc" - if not defined GPG echo Cannot locate gpg2.exe. Signatures will not be uploaded & pause - echo Found gpg2.exe at %GPG% -) - -call "%PCBUILD%find_msbuild.bat" %MSBUILD% -if ERRORLEVEL 1 (echo Cannot locate MSBuild.exe on PATH or as MSBUILD variable & exit /b 2) -pushd "%D%" -if not defined NOUPLOAD ( - %MSBUILD% /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x86 - if errorlevel 1 goto :failed - %MSBUILD% /v:m /nologo uploadrelease.proj /t:Upload /p:Platform=x64 /p:IncludeDoc=false - if errorlevel 1 goto :failed -) -if not defined NOPURGE ( - %MSBUILD% /v:m /nologo uploadrelease.proj /t:Purge -) -if not defined NOTEST ( - call :test x86 - if errorlevel 1 goto :failed - call :test x64 - if errorlevel 1 goto :failed -) -%MSBUILD% /v:m /nologo uploadrelease.proj /t:ShowHashes /p:Platform=x86 -if errorlevel 1 goto :failed -%MSBUILD% /v:m /nologo uploadrelease.proj /t:ShowHashes /p:Platform=x64 /p:IncludeDoc=false -if errorlevel 1 goto :failed - -popd -exit /B 0 - -:test -%MSBUILD% /v:m /nologo uploadrelease.proj /t:Test /p:Platform=%1 -if errorlevel 1 ( - echo Test failed - purging and retrying - %MSBUILD% /v:m /nologo uploadrelease.proj /t:Purge - if errorlevel 1 exit /B - %MSBUILD% /v:m /nologo uploadrelease.proj /t:Test /p:Platform=%1 -) -exit /B - -:failed -popd -exit /B - -:Help -echo uploadrelease.bat --host HOST --user USERNAME [--target TARGET] [--dry-run] [-h] -echo. -echo --host (-o) Specify the upload host (required) -echo --user (-u) Specify the user on the host (required) -echo --target (-t) Specify the target directory on the host -echo --dry-run Display commands and filenames without executing them -echo --skip-gpg Does not generate GPG signatures before uploading -echo --skip-purge Does not perform CDN purge after uploading -echo --skip-test (-T) Does not perform post-upload tests -echo -h Display this help information -echo. diff --git a/Tools/msi/uploadrelease.proj b/Tools/msi/uploadrelease.proj deleted file mode 100644 index e70ae1de22fa78b..000000000000000 --- a/Tools/msi/uploadrelease.proj +++ /dev/null @@ -1,113 +0,0 @@ - - - - {2D69F2AB-D5D0-4344-84B5-EF6DB34A9BC9} - python - - - $(TARGET) - /srv/www.python.org/ftp/python - true - true - false - - - - - - - $(DownloadUrlBase.TrimEnd(`/`))/$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber) - $(DownloadUrl.Replace(`{version}`, `$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)`).Replace(`{arch}`, `$(ArchName)`).Replace(`{releasename}`, `$(ReleaseLevelName)`).Replace(`{msi}`, ``).TrimEnd(`/`)) - - - - - $(MSITarget) - - - $(EXETarget) - - - $(EXETarget) - - - - - - - - - - - - - - - - - %(File.CopyTo) - - - - - - - - - - - - - - - - - - - - - $(TEMP)\%(Filename)_source - $(TEMP)\%(Filename)_source\%(Filename)%(Extension) - $(TEMP)\%(Filename)_layout - $(OutputPath)\%(Filename)_layoutlog - $(OutputPath)\%(Filename)_layoutlog\%(Filename).log - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/msi/uploadrelease.ps1 b/Tools/msi/uploadrelease.ps1 deleted file mode 100644 index a8669e5d65ed14b..000000000000000 --- a/Tools/msi/uploadrelease.ps1 +++ /dev/null @@ -1,171 +0,0 @@ -<# -.Synopsis - Uploads from a VSTS release build layout to python.org -.Description - Given the downloaded/extracted build artifact from a release - build run on python.visualstudio.com, this script uploads - the files to the correct locations. -.Parameter build - The location on disk of the extracted build artifact. -.Parameter user - The username to use when logging into the host. -.Parameter server - The host or PuTTY session name. -.Parameter target - The subdirectory on the host to copy files to. -.Parameter tests - The path to run download tests in. -.Parameter doc_htmlhelp - Optional path besides -build to locate CHM files. -.Parameter embed - Optional path besides -build to locate ZIP files. -.Parameter skipupload - Skip uploading -.Parameter skippurge - Skip purging the CDN -.Parameter skiptest - Skip the download tests -.Parameter skiphash - Skip displaying hashes -#> -param( - [Parameter(Mandatory=$true)][string]$build, - [Parameter(Mandatory=$true)][string]$user, - [string]$server="python-downloads", - [string]$target="/srv/www.python.org/ftp/python", - [string]$tests=${env:TEMP}, - [string]$doc_htmlhelp=$null, - [string]$embed=$null, - [switch]$skipupload, - [switch]$skippurge, - [switch]$skiptest, - [switch]$skiphash -) - -if (-not $build) { throw "-build option is required" } -if (-not $user) { throw "-user option is required" } - -$tools = $script:MyInvocation.MyCommand.Path | Split-Path -parent; - -if (-not ((Test-Path "$build\win32\python-*.exe") -or (Test-Path "$build\amd64\python-*.exe"))) { - throw "-build argument does not look like a 'build' directory" -} - -function find-putty-tool { - param ([string]$n) - $t = gcm $n -EA 0 - if (-not $t) { $t = gcm ".\$n" -EA 0 } - if (-not $t) { $t = gcm "${env:ProgramFiles}\PuTTY\$n" -EA 0 } - if (-not $t) { $t = gcm "${env:ProgramFiles(x86)}\PuTTY\$n" -EA 0 } - if (-not $t) { throw "Unable to locate $n.exe. Please put it on $PATH" } - return gi $t.Path -} - -$p = gci -r "$build\python-*.exe" | ` - ?{ $_.Name -match '^python-(\d+\.\d+\.\d+)((a|b|rc)\d+)?-.+' } | ` - select -first 1 | ` - %{ $Matches[1], $Matches[2] } - -"Uploading version $($p[0]) $($p[1])" -" from: $build" -" to: $($server):$target/$($p[0])" -"" - -if (-not $skipupload) { - # Upload files to the server - $pscp = find-putty-tool "pscp" - $plink = find-putty-tool "plink" - - "Upload using $pscp and $plink" - "" - - if ($doc_htmlhelp) { - $chm = gci -EA 0 $doc_htmlhelp\python*.chm, $doc_htmlhelp\python*.chm.asc - } else { - $chm = gci -EA 0 $build\python*.chm, $build\python*.chm.asc - } - - $d = "$target/$($p[0])/" - & $plink -batch $user@$server mkdir $d - & $plink -batch $user@$server chgrp downloads $d - & $plink -batch $user@$server chmod o+rx $d - if ($chm) { - & $pscp -batch $chm.FullName "$user@${server}:$d" - if (-not $?) { throw "Failed to upload $chm" } - } - - $dirs = gci "$build" -Directory - if ($embed) { - $dirs = ($dirs, (gi $embed)) | %{ $_ } - } - - foreach ($a in $dirs) { - "Uploading files from $($a.FullName)" - pushd "$($a.FullName)" - $exe = gci *.exe, *.exe.asc, *.zip, *.zip.asc - $msi = gci *.msi, *.msi.asc, *.msu, *.msu.asc - popd - - if ($exe) { - & $pscp -batch $exe.FullName "$user@${server}:$d" - if (-not $?) { throw "Failed to upload $exe" } - } - - if ($msi) { - $sd = "$d$($a.Name)$($p[1])/" - & $plink -batch $user@$server mkdir $sd - & $plink -batch $user@$server chgrp downloads $sd - & $plink -batch $user@$server chmod o+rx $sd - & $pscp -batch $msi.FullName "$user@${server}:$sd" - if (-not $?) { throw "Failed to upload $msi" } - & $plink -batch $user@$server chgrp downloads $sd* - & $plink -batch $user@$server chmod g-x,o+r $sd* - } - } - - & $plink -batch $user@$server chgrp downloads $d* - & $plink -batch $user@$server chmod g-x,o+r $d* - & $pscp -ls "$user@${server}:$d" -} - -if (-not $skippurge) { - # Run a CDN purge - py $tools\purge.py "$($p[0])$($p[1])" -} - -if (-not $skiptest) { - # Use each web installer to produce a layout. This will download - # each referenced file and validate their signatures/hashes. - gci "$build\*-webinstall.exe" -r -File | %{ - $d = mkdir "$tests\$($_.BaseName)" -Force - gci $d -r -File | del - $ic = copy $_ $d -PassThru - "Checking layout for $($ic.Name)" - Start-Process -wait $ic "/passive", "/layout", "$d\layout", "/log", "$d\log\install.log" - if (-not $?) { - Write-Error "Failed to validate layout of $($inst.Name)" - } - } -} - -if (-not $skiphash) { - # Display MD5 hash and size of each downloadable file - pushd $build - $files = gci python*.chm, *\*.exe, *\*.zip - if ($doc_htmlhelp) { - cd $doc_htmlhelp - $files = ($files, (gci python*.chm)) | %{ $_ } - } - if ($embed) { - cd $embed - $files = ($files, (gci *.zip)) | %{ $_ } - } - popd - - $hashes = $files | ` - Sort-Object Name | ` - Format-Table Name, @{Label="MD5"; Expression={(Get-FileHash $_ -Algorithm MD5).Hash}}, Length -AutoSize | ` - Out-String -Width 4096 - $hashes | clip - $hashes -} diff --git a/Tools/msi/wix.props b/Tools/msi/wix.props deleted file mode 100644 index 707c8aeacb648dc..000000000000000 --- a/Tools/msi/wix.props +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - $(MSBuildThisFileDirectory)\Wix\ - $(ExternalsDir)\windows-installer\wix-314\ - $(WixInstallPath)\Wix.targets - - \ No newline at end of file diff --git a/Tools/nuget/build.bat b/Tools/nuget/build.bat deleted file mode 100644 index b532bd74216831e..000000000000000 --- a/Tools/nuget/build.bat +++ /dev/null @@ -1,70 +0,0 @@ -@echo off -setlocal -set D=%~dp0 -set PCBUILD=%D%..\..\PCbuild\ -if "%Py_OutDir%"=="" set Py_OutDir=%PCBUILD% - -set BUILDX86= -set BUILDX64= -set BUILDARM32= -set REBUILD= -set OUTPUT= -set PACKAGES= -set PYTHON_EXE= - -:CheckOpts -if "%~1" EQU "-h" goto Help -if "%~1" EQU "-x86" (set BUILDX86=1) && shift && goto CheckOpts -if "%~1" EQU "-x64" (set BUILDX64=1) && shift && goto CheckOpts -if "%~1" EQU "-arm32" (set BUILDARM32=1) && shift && goto CheckOpts -if "%~1" EQU "-r" (set REBUILD=-r) && shift && goto CheckOpts -if "%~1" EQU "-o" (set OUTPUT="/p:OutputPath=%~2") && shift && shift && goto CheckOpts -if "%~1" EQU "--out" (set OUTPUT="/p:OutputPath=%~2") && shift && shift && goto CheckOpts -if "%~1" EQU "-p" (set PACKAGES=%PACKAGES% %~2) && shift && shift && goto CheckOpts -if "%~1" EQU "--python-exe" (set PYTHON_EXE="/p:PythonExe=%~2") && shift && shift && goto CheckOpts - -if not defined BUILDX86 if not defined BUILDX64 if not defined BUILDARM32 (set BUILDX86=1) && (set BUILDX64=1) && (set BUILDARM32=1) - -call "%D%..\msi\get_externals.bat" -call "%PCBUILD%find_msbuild.bat" %MSBUILD% -if ERRORLEVEL 1 (echo Cannot locate MSBuild.exe on PATH or as MSBUILD variable & exit /b 2) - -if defined PACKAGES set PACKAGES="/p:Packages=%PACKAGES%" - -if defined BUILDX86 ( - if defined REBUILD ( call "%PCBUILD%build.bat" -e -r - ) else if not exist "%Py_OutDir%win32\python.exe" call "%PCBUILD%build.bat" -e - if errorlevel 1 goto :eof - - %MSBUILD% "%D%make_pkg.proj" /p:Configuration=Release /p:Platform=x86 %OUTPUT% %PACKAGES% %PYTHON_EXE% - if errorlevel 1 goto :eof -) - -if defined BUILDX64 ( - if defined REBUILD ( call "%PCBUILD%build.bat" -p x64 -e -r - ) else if not exist "%Py_OutDir%amd64\python.exe" call "%PCBUILD%build.bat" -p x64 -e - if errorlevel 1 goto :eof - - %MSBUILD% "%D%make_pkg.proj" /p:Configuration=Release /p:Platform=x64 %OUTPUT% %PACKAGES% %PYTHON_EXE% - if errorlevel 1 goto :eof -) - -if defined BUILDARM32 ( - if defined REBUILD ( call "%PCBUILD%build.bat" -p ARM -e -r --no-tkinter - ) else if not exist "%Py_OutDir%arm32\python.exe" call "%PCBUILD%build.bat" -p ARM -e --no-tkinter - if errorlevel 1 goto :eof - - %MSBUILD% "%D%make_pkg.proj" /p:Configuration=Release /p:Platform=ARM %OUTPUT% %PACKAGES% %PYTHON_EXE% - if errorlevel 1 goto :eof -) - -exit /B 0 - -:Help -echo build.bat [-x86] [-x64] [--out DIR] [-r] [-h] -echo. -echo -x86 Build x86 installers -echo -x64 Build x64 installers -echo -r Rebuild rather than incremental build -echo --out [DIR] Override output directory -echo -h Show usage diff --git a/Tools/nuget/make_pkg.proj b/Tools/nuget/make_pkg.proj deleted file mode 100644 index 710ef3dcb5c01de..000000000000000 --- a/Tools/nuget/make_pkg.proj +++ /dev/null @@ -1,63 +0,0 @@ - - - - {10487945-15D1-4092-A214-338395C4116B} - python - $(OutputName)x86 - $(OutputName)arm32 - $(OutputName)daily - - false - true - - - - - - $(ExternalsDir)\windows-installer\nuget\nuget.exe - $(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber) - $(NuspecVersion)-$(ReleaseLevelName) - $(MajorVersionNumber).$(MinorVersionNumber).$(DailyBuildVersion) - false - $(OutputName).$(NuspecVersion) - .nupkg - $(IntermediateOutputPath)\nuget_$(ArchName)\ - - rmdir /q/s "$(IntermediateOutputPath.TrimEnd(`\`))" - - "$(PythonExe)" "$(PySourcePath)PC\layout" - $(PythonArguments) -b "$(BuildPath.TrimEnd(`\`))" -s "$(PySourcePath.TrimEnd(`\`))" - $(PythonArguments) -t "$(IntermediateOutputPath)obj" - $(PythonArguments) --copy "$(IntermediateOutputPath)pkg" - $(PythonArguments) --preset-nuget - - "$(IntermediateOutputPath)pkg\pip.exe" -B -m pip install -U $(Packages) - - "$(Nuget)" pack "$(IntermediateOutputPath)pkg\python.nuspec" -BasePath "$(IntermediateOutputPath)pkg" - "$(Nuget)" pack "$(MSBuildThisFileDirectory)\$(OutputName).symbols.nuspec" -BasePath "$(BuildPath.TrimEnd(`\`))" - $(NugetArguments) -OutputDirectory "$(OutputPath.Trim(`\`))" - $(NugetArguments) -Version "$(NuspecVersion)" - $(NugetArguments) -NoPackageAnalysis -NonInteractive - - $(Environment)%0D%0Aset PYTHONPATH=$(PySourcePath)Lib - $(Environment)%0D%0Aset PYTHON_NUSPEC_VERSION=$(NuspecVersion) - $(Environment)%0D%0Aset PYTHON_PROPS_PLATFORM=$(Platform) - $(Environment)%0D%0Aset PYTHON_PROPS_PLATFORM=Win32 - $(Environment)%0D%0Amkdir "$(OutputPath.Trim(`\`))" >nul 2>nul - - - - - - - - - - - - - - - - - diff --git a/Tools/nuget/python.nuspec b/Tools/nuget/python.nuspec deleted file mode 100644 index 2da5f2037eb2342..000000000000000 --- a/Tools/nuget/python.nuspec +++ /dev/null @@ -1,18 +0,0 @@ - - - - python - Python - 0.0.0.0 - Python Software Foundation - tools\LICENSE.txt - https://www.python.org/ - Installs 64-bit Python for use in build scenarios. - https://www.python.org/static/favicon.ico - python - - - - - - diff --git a/Tools/nuget/pythonarm32.nuspec b/Tools/nuget/pythonarm32.nuspec deleted file mode 100644 index 2d197931edb32c3..000000000000000 --- a/Tools/nuget/pythonarm32.nuspec +++ /dev/null @@ -1,20 +0,0 @@ - - - - pythonarm32 - Python (ARM32) - Python Software Foundation - 0.0.0.0 - https://docs.python.org/3/license.html - https://www.python.org/ - false - Installs Python ARM32 for use in build scenarios. - https://www.python.org/static/favicon.ico - python - - - - - - - diff --git a/Tools/nuget/pythondaily.nuspec b/Tools/nuget/pythondaily.nuspec deleted file mode 100644 index 7df1983f42a6fe2..000000000000000 --- a/Tools/nuget/pythondaily.nuspec +++ /dev/null @@ -1,19 +0,0 @@ - - - - pythondaily - Python (Daily build) - Python Software Foundation - 0.0.0.0 - tools\LICENSE.txt - https://www.python.org/ - Installs an unsigned, untested build of Python for test purposes only. - https://www.python.org/static/favicon.ico - python - - - - - - - diff --git a/Tools/nuget/pythondaily.symbols.nuspec b/Tools/nuget/pythondaily.symbols.nuspec deleted file mode 100644 index 608e15c50e02d2d..000000000000000 --- a/Tools/nuget/pythondaily.symbols.nuspec +++ /dev/null @@ -1,22 +0,0 @@ - - - - pythondaily.symbols - Python (Daily build) - 0.0.0.0 - Python Software Foundation - https://www.python.org/ - Contains symbols for the daily build of Python. - https://www.python.org/static/favicon.ico - python - - - - - - - - - - - diff --git a/Tools/nuget/pythonx86.nuspec b/Tools/nuget/pythonx86.nuspec deleted file mode 100644 index ea878ba0bf390b6..000000000000000 --- a/Tools/nuget/pythonx86.nuspec +++ /dev/null @@ -1,19 +0,0 @@ - - - - pythonx86 - Python (32-bit) - Python Software Foundation - 0.0.0.0 - tools\LICENSE.txt - https://www.python.org/ - Installs 32-bit Python for use in build scenarios. - https://www.python.org/static/favicon.ico - python - - - - - - - diff --git a/Tools/peg_generator/.gitignore b/Tools/peg_generator/.gitignore index 04b68be855d8d9c..56c8a824fc7cd54 100644 --- a/Tools/peg_generator/.gitignore +++ b/Tools/peg_generator/.gitignore @@ -1,2 +1,3 @@ peg_extension/parse.c +peg_extension/parse_invalid.c venv/ diff --git a/Tools/peg_generator/Makefile b/Tools/peg_generator/Makefile index 7f695defa0ed41a..455c06e9baff88e 100644 --- a/Tools/peg_generator/Makefile +++ b/Tools/peg_generator/Makefile @@ -12,15 +12,16 @@ MYPY ?= ./venv/bin/mypy BLACK ?= ./venv/bin/black GRAMMAR = ../../Grammar/python.gram +INCLUDED_GRAMMARS = ../../Grammar/invalid.gram TOKENS = ../../Grammar/Tokens build: peg_extension/parse.c -peg_extension/parse.c: $(GRAMMAR) $(TOKENS) pegen/*.py peg_extension/peg_extension.c ../../Parser/pegen.c ../../Parser/pegen_errors.c ../../Parser/string_parser.c ../../Parser/action_helpers.c ../../Parser/*.h pegen/grammar_parser.py +peg_extension/parse.c: $(GRAMMAR) $(INCLUDED_GRAMMARS) $(TOKENS) pegen/*.py peg_extension/peg_extension.c ../../Parser/pegen.c ../../Parser/pegen_errors.c ../../Parser/string_parser.c ../../Parser/action_helpers.c ../../Parser/*.h pegen/grammar_parser.py $(VENVPYTHON) -m pegen -q c $(GRAMMAR) $(TOKENS) -o peg_extension/parse.c --compile-extension clean: - -rm -f peg_extension/*.o peg_extension/*.so peg_extension/parse.c + -rm -f peg_extension/*.o peg_extension/*.so peg_extension/parse.c peg_extension/parse_invalid.c -rm -rf $(VENVDIR) regen-metaparser: pegen/metagrammar.gram pegen/*.py diff --git a/Tools/peg_generator/peg_extension/peg_extension.c b/Tools/peg_generator/peg_extension/peg_extension.c index 2fec5b0512940f3..83dd668a06987eb 100644 --- a/Tools/peg_generator/peg_extension/peg_extension.c +++ b/Tools/peg_generator/peg_extension/peg_extension.c @@ -93,7 +93,7 @@ parse_string(PyObject *self, PyObject *args, PyObject *kwds) PyCompilerFlags flags = _PyCompilerFlags_INIT; mod_ty res = _PyPegen_run_parser_from_string(the_string, Py_file_input, filename_ob, - &flags, arena, NULL); + &flags, arena, NULL, NULL); if (res == NULL) { goto error; } diff --git a/Tools/peg_generator/pegen/__main__.py b/Tools/peg_generator/pegen/__main__.py index 7a82ad861b4cb54..e275c17334d8833 100755 --- a/Tools/peg_generator/pegen/__main__.py +++ b/Tools/peg_generator/pegen/__main__.py @@ -6,6 +6,7 @@ """ import argparse +import pathlib import sys import time import token @@ -87,10 +88,15 @@ def generate_python_code( c_parser = subparsers.add_parser("c", help="Generate C code for inclusion into CPython") c_parser.set_defaults(func=generate_c_code) -c_parser.add_argument("grammar_filename", help="Grammar description") -c_parser.add_argument("tokens_filename", help="Tokens description") +c_parser.add_argument("grammar_filename", type=pathlib.Path, help="Grammar description") +c_parser.add_argument("tokens_filename", type=pathlib.Path, help="Tokens description") c_parser.add_argument( - "-o", "--output", metavar="OUT", default="parse.c", help="Where to write the generated parser" + "-o", + "--output", + metavar="OUT", + type=pathlib.Path, + default=pathlib.Path("parse.c"), + help="Where to write the generated parser", ) c_parser.add_argument( "--compile-extension", @@ -111,12 +117,13 @@ def generate_python_code( help="Generate Python code, needs grammar definition with Python actions", ) python_parser.set_defaults(func=generate_python_code) -python_parser.add_argument("grammar_filename", help="Grammar description") +python_parser.add_argument("grammar_filename", type=pathlib.Path, help="Grammar description") python_parser.add_argument( "-o", "--output", metavar="OUT", - default="parse.py", + type=pathlib.Path, + default=pathlib.Path("parse.py"), help="Where to write the generated parser", ) python_parser.add_argument( diff --git a/Tools/peg_generator/pegen/build.py b/Tools/peg_generator/pegen/build.py index 37883afeffcb472..52d1933ceecdbdf 100644 --- a/Tools/peg_generator/pegen/build.py +++ b/Tools/peg_generator/pegen/build.py @@ -1,3 +1,4 @@ +import contextlib import itertools import logging import os @@ -6,10 +7,11 @@ import sysconfig import tempfile import tokenize +from collections.abc import Sequence from typing import IO, Any from pegen.c_generator import CParserGenerator -from pegen.grammar import Grammar +from pegen.grammar import Grammar, GrammarError from pegen.grammar_parser import GeneratedParser as GrammarParser from pegen.parser import Parser from pegen.parser_generator import ParserGenerator @@ -70,12 +72,13 @@ def fixup_build_ext(cmd: Incomplete) -> None: def compile_c_extension( - generated_source_path: str, + generated_source_path: pathlib.Path, build_dir: str | None = None, verbose: bool = False, keep_asserts: bool = True, disable_optimization: bool = False, library_dir: str | None = None, + extra_generated_sources: Sequence[pathlib.Path] = (), ) -> pathlib.Path: """Compile the generated source for a parser generator into an extension module. @@ -90,6 +93,9 @@ def compile_c_extension( If *library_dir* is provided, that path will be used as the directory for a static library of the common parser sources (this is useful in case you are creating multiple extensions). + + *extra_generated_sources* are the C files generated for the included + grammar files (see included_output_files()). """ import setuptools.command.build_ext import setuptools.logging @@ -101,8 +107,7 @@ def compile_c_extension( if verbose: setuptools.logging.set_threshold(logging.DEBUG) - source_file_path = pathlib.Path(generated_source_path) - extension_name = source_file_path.stem + extension_name = generated_source_path.stem extra_compile_args = get_extra_flags("CFLAGS", "PY_CFLAGS_NODIST") extra_compile_args.append("-DPy_BUILD_CORE_MODULE") # Define _Py_TEST_PEGEN to not call PyAST_Validate() in Parser/pegen.c @@ -122,43 +127,43 @@ def compile_c_extension( extra_link_args.append("-fno-lto") common_sources = [ - str(MOD_DIR.parent.parent.parent / "Python" / "Python-ast.c"), - str(MOD_DIR.parent.parent.parent / "Python" / "asdl.c"), - str(MOD_DIR.parent.parent.parent / "Parser" / "lexer" / "lexer.c"), - str(MOD_DIR.parent.parent.parent / "Parser" / "lexer" / "number.c"), - str(MOD_DIR.parent.parent.parent / "Parser" / "lexer" / "state.c"), - str(MOD_DIR.parent.parent.parent / "Parser" / "lexer" / "string.c"), - str(MOD_DIR.parent.parent.parent / "Parser" / "lexer" / "buffer.c"), - str(MOD_DIR.parent.parent.parent / "Parser" / "tokenizer" / "string_tokenizer.c"), - str(MOD_DIR.parent.parent.parent / "Parser" / "tokenizer" / "file_tokenizer.c"), - str(MOD_DIR.parent.parent.parent / "Parser" / "tokenizer" / "utf8_tokenizer.c"), - str(MOD_DIR.parent.parent.parent / "Parser" / "tokenizer" / "readline_tokenizer.c"), - str(MOD_DIR.parent.parent.parent / "Parser" / "tokenizer" / "helpers.c"), - str(MOD_DIR.parent.parent.parent / "Parser" / "pegen.c"), - str(MOD_DIR.parent.parent.parent / "Parser" / "pegen_errors.c"), - str(MOD_DIR.parent.parent.parent / "Parser" / "action_helpers.c"), - str(MOD_DIR.parent.parent.parent / "Parser" / "string_parser.c"), - str(MOD_DIR.parent / "peg_extension" / "peg_extension.c"), + MOD_DIR.parent.parent.parent / "Python" / "Python-ast.c", + MOD_DIR.parent.parent.parent / "Python" / "asdl.c", + MOD_DIR.parent.parent.parent / "Parser" / "lexer" / "lexer.c", + MOD_DIR.parent.parent.parent / "Parser" / "lexer" / "layout.c", + MOD_DIR.parent.parent.parent / "Parser" / "lexer" / "number.c", + MOD_DIR.parent.parent.parent / "Parser" / "lexer" / "state.c", + MOD_DIR.parent.parent.parent / "Parser" / "lexer" / "string.c", + MOD_DIR.parent.parent.parent / "Parser" / "tokenizer" / "decoder.c", + MOD_DIR.parent.parent.parent / "Parser" / "tokenizer" / "api.c", + MOD_DIR.parent.parent.parent / "Parser" / "tokenizer" / "reader.c", + MOD_DIR.parent.parent.parent / "Parser" / "tokenizer" / "helpers.c", + MOD_DIR.parent.parent.parent / "Parser" / "pegen.c", + MOD_DIR.parent.parent.parent / "Parser" / "pegen_errors.c", + MOD_DIR.parent.parent.parent / "Parser" / "action_helpers.c", + MOD_DIR.parent.parent.parent / "Parser" / "string_parser.c", + MOD_DIR.parent / "peg_extension" / "peg_extension.c", ] include_dirs = [ - str(MOD_DIR.parent.parent.parent / "Include" / "internal"), - str(MOD_DIR.parent.parent.parent / "Include" / "internal" / "mimalloc"), - str(MOD_DIR.parent.parent.parent / "Parser"), - str(MOD_DIR.parent.parent.parent / "Parser" / "lexer"), - str(MOD_DIR.parent.parent.parent / "Parser" / "tokenizer"), + MOD_DIR.parent.parent.parent / "Include" / "internal", + MOD_DIR.parent.parent.parent / "Include" / "internal" / "mimalloc", + MOD_DIR.parent.parent.parent / "Parser", + MOD_DIR.parent.parent.parent / "Parser" / "lexer", + MOD_DIR.parent.parent.parent / "Parser" / "tokenizer", ] - library_dirs: list[str] = [] + library_dirs: list[pathlib.Path] = [] if sys.platform == "win32": # HACK: The location of pyconfig.h has moved within our build, and # setuptools hasn't updated for it yet. So add the path manually for now - include_dirs.append(str(pathlib.Path(sysconfig.get_config_h_filename()).parent)) + include_dirs.append(pathlib.Path(sysconfig.get_config_h_filename()).parent) if sysconfig.is_python_build(): # HACK: Our output directory for free-threaded builds has moved, and so # tests running in-tree require our sys.executable directory for libs - library_dirs.append(str(pathlib.Path(sys.executable).parent)) + library_dirs.append(pathlib.Path(sys.executable).parent) + sources = [generated_source_path, *extra_generated_sources] extension = Extension( extension_name, - sources=[generated_source_path], + sources=sources, extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, ) @@ -166,9 +171,9 @@ def compile_c_extension( cmd = dist.get_command_obj("build_ext") assert isinstance(cmd, setuptools.command.build_ext.build_ext) fixup_build_ext(cmd) - cmd.build_lib = str(source_file_path.parent) - cmd.include_dirs = include_dirs - cmd.library_dirs = library_dirs + cmd.build_lib = str(generated_source_path.parent) + cmd.include_dirs = [str(d) for d in include_dirs] + cmd.library_dirs = [str(d) for d in library_dirs] if build_dir: cmd.build_temp = build_dir cmd.ensure_finalized() @@ -216,19 +221,19 @@ def compile_c_extension( ] ) else: - extension.sources[0:0] = common_sources + sources[0:0] = common_sources # Compile the source code to object files. ext_path = cmd.get_ext_fullpath(extension_name) - if newer_group(extension.sources, ext_path, "newer"): + if newer_group(sources, ext_path, "newer"): objects = compiler.compile( - extension.sources, + sources, output_dir=cmd.build_temp, debug=cmd.debug, extra_postargs=extra_compile_args, ) else: - objects = compiler.object_filenames(extension.sources, output_dir=cmd.build_temp) + objects = compiler.object_filenames(sources, output_dir=cmd.build_temp) # The cmd.get_libraries() call needs a valid compiler attribute or we will # get an incorrect library name on the free-threaded Windows build. cmd.compiler = compiler @@ -246,8 +251,8 @@ def compile_c_extension( return pathlib.Path(ext_path) -def build_parser( - grammar_file: str, verbose_tokenizer: bool = False, verbose_parser: bool = False +def _parse_grammar_file( + grammar_file: pathlib.Path, verbose_tokenizer: bool, verbose_parser: bool ) -> tuple[Grammar, Parser, Tokenizer]: with open(grammar_file) as file: tokenizer = Tokenizer(tokenize.generate_tokens(file.readline), verbose=verbose_tokenizer) @@ -255,11 +260,95 @@ def build_parser( grammar = parser.start() if not grammar: - raise parser.make_syntax_error(grammar_file) + raise parser.make_syntax_error(str(grammar_file)) return grammar, parser, tokenizer +def _include_rules( + root_grammar: Grammar, + root_dir: pathlib.Path, + includes: list[str], + including_file: pathlib.Path, + rule_files: dict[str, pathlib.Path], + include_stack: list[pathlib.Path], + included_from: dict[pathlib.Path, pathlib.Path], + verbose_tokenizer: bool, + verbose_parser: bool, +) -> None: + # Append the rules of each included file (and, depth-first, of the files + # it includes) to *root_grammar*, in order. + for include in includes: + path = (including_file.parent / include).resolve() + if path in include_stack: + raise GrammarError(f"Circular @include of '{path!s}' in '{including_file!s}'") + if path in included_from: + raise GrammarError( + f"'{path}' is included more than once: " + f"from '{included_from[path]}' and from '{including_file}'" + ) + included_from[path] = including_file + new_grammar, _, _ = _parse_grammar_file(path, verbose_tokenizer, verbose_parser) + if new_grammar.metas: + names = ", ".join(f"@{name}" for name in new_grammar.metas) + raise GrammarError(f"Included grammar '{path!s}' cannot define metas: {names}") + for name, rule in new_grammar.rules.items(): + if name in root_grammar.rules: + raise GrammarError( + f"Repeated rule {name!r} in '{path!s}' " + f"(first defined in '{rule_files[name]!s}')" + ) + rule.source = pathlib.Path(os.path.relpath(path, root_dir)) + root_grammar.rules[name] = rule + rule_files[name] = path + _include_rules( + root_grammar, + root_dir, + new_grammar.includes, + path, + rule_files, + include_stack + [path], + included_from, + verbose_tokenizer, + verbose_parser, + ) + + +def build_parser( + grammar_file: pathlib.Path, verbose_tokenizer: bool = False, verbose_parser: bool = False +) -> tuple[Grammar, Parser, Tokenizer]: + grammar, parser, tokenizer = _parse_grammar_file( + grammar_file, verbose_tokenizer, verbose_parser + ) + resolve_includes(grammar, grammar_file, verbose_tokenizer, verbose_parser) + return grammar, parser, tokenizer + + +def resolve_includes( + grammar: Grammar, + grammar_file: pathlib.Path, + verbose_tokenizer: bool = False, + verbose_parser: bool = False, +) -> None: + """Add the rules of the files that *grammar* includes, and clear its includes. + + *grammar_file* is the file *grammar* was parsed from: its @include paths + are relative to that file's directory. + """ + _include_rules( + grammar, + grammar_file.resolve().parent, + grammar.includes, + grammar_file, + dict.fromkeys(grammar.rules, grammar_file), + [grammar_file.resolve()], + {}, + verbose_tokenizer, + verbose_parser, + ) + grammar.includes = [] + + def generate_token_definitions(tokens: IO[str]) -> TokenDefinitions: all_tokens = {} exact_tokens = {} @@ -289,11 +378,39 @@ def generate_token_definitions(tokens: IO[str]) -> TokenDefinitions: return all_tokens, exact_tokens, non_exact_tokens +def included_output_files( + grammar: Grammar, output_file: pathlib.Path +) -> dict[pathlib.Path, pathlib.Path]: + stem, dot, rest = output_file.name.partition(".") + outputs: dict[pathlib.Path, pathlib.Path] = {} + for rule in grammar.rules.values(): + if rule.source is None or rule.source in outputs: + continue + if rule.source.is_absolute() or ".." in rule.source.parts: + raise GrammarError( + f"The C file for '{rule.source}' would be outside the output directory; " + "included grammar files must be in the root grammar file's directory " + "or its subdirectories" + ) + path = ( + output_file.parent + / rule.source.parent + / f"{stem}_{rule.source.stem}{dot}{rest}" + ) + if path in outputs.values(): + raise GrammarError( + f"The C file for '{rule.source}' would be '{path}', " + "which is already used by another grammar file" + ) + outputs[rule.source] = path + return outputs + + def build_c_generator( grammar: Grammar, - grammar_file: str, - tokens_file: str, - output_file: str, + grammar_file: pathlib.Path, + tokens_file: pathlib.Path, + output_file: pathlib.Path, compile_extension: bool = False, verbose_c_extension: bool = False, keep_asserts_in_extension: bool = True, @@ -301,9 +418,23 @@ def build_c_generator( ) -> ParserGenerator: with open(tokens_file) as tok_file: all_tokens, exact_tok, non_exact_tok = generate_token_definitions(tok_file) - with open(output_file, "w") as file: + included_outputs = included_output_files(grammar, output_file) + with contextlib.ExitStack() as stack: + file: IO[str] = stack.enter_context(open(output_file, "w")) + for path in included_outputs.values(): + path.parent.mkdir(parents=True, exist_ok=True) + included_files: dict[pathlib.Path, IO[str]] = { + source: stack.enter_context(open(path, "w")) + for source, path in included_outputs.items() + } gen: ParserGenerator = CParserGenerator( - grammar, all_tokens, exact_tok, non_exact_tok, file, skip_actions=skip_actions + grammar, + all_tokens, + exact_tok, + non_exact_tok, + file, + skip_actions=skip_actions, + included_files=included_files, ) gen.generate(grammar_file) @@ -314,14 +445,15 @@ def build_c_generator( build_dir=build_dir, verbose=verbose_c_extension, keep_asserts=keep_asserts_in_extension, + extra_generated_sources=list(included_outputs.values()), ) return gen def build_python_generator( grammar: Grammar, - grammar_file: str, - output_file: str, + grammar_file: pathlib.Path, + output_file: pathlib.Path, skip_actions: bool = False, ) -> ParserGenerator: with open(output_file, "w") as file: @@ -331,9 +463,9 @@ def build_python_generator( def build_c_parser_and_generator( - grammar_file: str, - tokens_file: str, - output_file: str, + grammar_file: pathlib.Path, + tokens_file: pathlib.Path, + output_file: pathlib.Path, compile_extension: bool = False, verbose_tokenizer: bool = False, verbose_parser: bool = False, @@ -375,8 +507,8 @@ def build_c_parser_and_generator( def build_python_parser_and_generator( - grammar_file: str, - output_file: str, + grammar_file: pathlib.Path, + output_file: pathlib.Path, verbose_tokenizer: bool = False, verbose_parser: bool = False, skip_actions: bool = False, diff --git a/Tools/peg_generator/pegen/c_generator.py b/Tools/peg_generator/pegen/c_generator.py index d9236dfb22835bd..721327bcfb59aeb 100644 --- a/Tools/peg_generator/pegen/c_generator.py +++ b/Tools/peg_generator/pegen/c_generator.py @@ -1,32 +1,24 @@ -import ast -import os.path +"""Prepare a complete C parser description and emit it.""" + +import pathlib import re -from collections.abc import Callable -from dataclasses import dataclass, field -from enum import Enum -from typing import IO, Any +from typing import IO from pegen import grammar -from pegen.grammar import ( - Alt, - Cut, - Forced, - Gather, - GrammarVisitor, - Group, - Leaf, - Lookahead, - NamedItem, - NameLeaf, - NegativeLookahead, - Opt, - PositiveLookahead, - Repeat0, - Repeat1, - Rhs, - Rule, - StringLeaf, +from pegen.c_generator_calls import ( + CCallMakerVisitor as CCallMakerVisitor, +) +from pegen.c_generator_calls import ( + FunctionCall as FunctionCall, +) +from pegen.c_generator_calls import ( + NodeTypes as NodeTypes, +) +from pegen.c_generator_calls import ( + consuming_rules as consuming_rules, ) +from pegen.c_generator_file import CParserEmitter +from pegen.c_generator_model import CParser, CRule, CRuleSignature from pegen.parser_generator import ParserGenerator EXTENSION_PREFIX = """\ @@ -66,316 +58,7 @@ """ -class NodeTypes(Enum): - NAME_TOKEN = 0 - NUMBER_TOKEN = 1 - STRING_TOKEN = 2 - GENERIC_TOKEN = 3 - KEYWORD = 4 - SOFT_KEYWORD = 5 - CUT_OPERATOR = 6 - F_STRING_CHUNK = 7 - - -BASE_NODETYPES = { - "NAME": NodeTypes.NAME_TOKEN, - "NUMBER": NodeTypes.NUMBER_TOKEN, - "STRING": NodeTypes.STRING_TOKEN, - "SOFT_KEYWORD": NodeTypes.SOFT_KEYWORD, -} - - -@dataclass -class FunctionCall: - function: str - arguments: list[Any] = field(default_factory=list) - assigned_variable: str | None = None - assigned_variable_type: str | None = None - return_type: str | None = None - nodetype: NodeTypes | None = None - force_true: bool = False - comment: str | None = None - - def __str__(self) -> str: - parts = [] - parts.append(self.function) - if self.arguments: - parts.append(f"({', '.join(map(str, self.arguments))})") - if self.force_true: - parts.append(", !p->error_indicator") - if self.assigned_variable: - if self.assigned_variable_type: - parts = [ - "(", - self.assigned_variable, - " = ", - "(", - self.assigned_variable_type, - ")", - *parts, - ")", - ] - else: - parts = ["(", self.assigned_variable, " = ", *parts, ")"] - if self.comment: - parts.append(f" // {self.comment}") - return "".join(parts) - - -class CCallMakerVisitor(GrammarVisitor): - def __init__( - self, - parser_generator: ParserGenerator, - exact_tokens: dict[str, int], - non_exact_tokens: set[str], - ): - self.gen = parser_generator - self.exact_tokens = exact_tokens - self.non_exact_tokens = non_exact_tokens - self.cache: dict[str, str] = {} - self.cleanup_statements: list[str] = [] - - def keyword_helper(self, keyword: str) -> FunctionCall: - return FunctionCall( - assigned_variable="_keyword", - function="_PyPegen_expect_token", - arguments=["p", self.gen.keywords[keyword]], - return_type="Token *", - nodetype=NodeTypes.KEYWORD, - comment=f"token='{keyword}'", - ) - - def soft_keyword_helper(self, value: str) -> FunctionCall: - return FunctionCall( - assigned_variable="_keyword", - function="_PyPegen_expect_soft_keyword", - arguments=["p", value], - return_type="expr_ty", - nodetype=NodeTypes.SOFT_KEYWORD, - comment=f"soft_keyword='{value}'", - ) - - def visit_NameLeaf(self, node: NameLeaf) -> FunctionCall: - name = node.value - if name in self.non_exact_tokens: - if name in BASE_NODETYPES: - return FunctionCall( - assigned_variable=f"{name.lower()}_var", - function=f"_PyPegen_{name.lower()}_token", - arguments=["p"], - nodetype=BASE_NODETYPES[name], - return_type="expr_ty", - comment=name, - ) - return FunctionCall( - assigned_variable=f"{name.lower()}_var", - function="_PyPegen_expect_token", - arguments=["p", name], - nodetype=NodeTypes.GENERIC_TOKEN, - return_type="Token *", - comment=f"token='{name}'", - ) - - type = None - rule = self.gen.all_rules.get(name.lower()) - if rule is not None: - type = "asdl_seq *" if rule.is_loop() or rule.is_gather() else rule.type - - return FunctionCall( - assigned_variable=f"{name}_var", - function=f"{name}_rule", - arguments=["p"], - return_type=type, - comment=f"{node}", - ) - - def visit_StringLeaf(self, node: StringLeaf) -> FunctionCall: - val = ast.literal_eval(node.value) - if re.match(r"[a-zA-Z_]\w*\Z", val): # This is a keyword - if node.value.endswith("'"): - return self.keyword_helper(val) - else: - return self.soft_keyword_helper(node.value) - else: - assert val in self.exact_tokens, f"{node.value} is not a known literal" - type = self.exact_tokens[val] - return FunctionCall( - assigned_variable="_literal", - function="_PyPegen_expect_token", - arguments=["p", type], - nodetype=NodeTypes.GENERIC_TOKEN, - return_type="Token *", - comment=f"token='{val}'", - ) - - def visit_NamedItem(self, node: NamedItem) -> FunctionCall: - call = self.generate_call(node.item) - if node.name: - call.assigned_variable = node.name - if node.type: - call.assigned_variable_type = node.type - return call - - def assert_no_undefined_behavior( - self, call: FunctionCall, wrapper: str, expected_rtype: str | None, - ) -> None: - if call.return_type != expected_rtype: - raise RuntimeError( - f"{call.function} return type is incompatible with {wrapper}: " - f"expect: {expected_rtype}, actual: {call.return_type}" - ) - - def lookahead_call_helper(self, node: Lookahead, positive: int) -> FunctionCall: - call = self.generate_call(node.node) - comment = None - if call.nodetype is NodeTypes.NAME_TOKEN: - function = "_PyPegen_lookahead_for_expr" - self.assert_no_undefined_behavior(call, function, "expr_ty") - elif call.nodetype is NodeTypes.STRING_TOKEN: - # _PyPegen_string_token() returns 'void *' instead of 'Token *'; - # in addition, the overall function call would return 'expr_ty'. - assert call.function == "_PyPegen_string_token" - function = "_PyPegen_lookahead" - self.assert_no_undefined_behavior(call, function, "expr_ty") - elif call.nodetype == NodeTypes.SOFT_KEYWORD: - function = "_PyPegen_lookahead_with_string" - self.assert_no_undefined_behavior(call, function, "expr_ty") - elif call.nodetype in {NodeTypes.GENERIC_TOKEN, NodeTypes.KEYWORD}: - function = "_PyPegen_lookahead_with_int" - self.assert_no_undefined_behavior(call, function, "Token *") - comment = f"token={node.node}" - elif call.return_type == "expr_ty": - function = "_PyPegen_lookahead_for_expr" - elif call.return_type == "stmt_ty": - function = "_PyPegen_lookahead_for_stmt" - else: - function = "_PyPegen_lookahead" - self.assert_no_undefined_behavior(call, function, None) - return FunctionCall( - function=function, - arguments=[positive, call.function, *call.arguments], - return_type="int", - comment=comment, - ) - - def visit_PositiveLookahead(self, node: PositiveLookahead) -> FunctionCall: - return self.lookahead_call_helper(node, 1) - - def visit_NegativeLookahead(self, node: NegativeLookahead) -> FunctionCall: - return self.lookahead_call_helper(node, 0) - - def visit_Forced(self, node: Forced) -> FunctionCall: - call = self.generate_call(node.node) - if isinstance(node.node, Leaf): - assert isinstance(node.node, Leaf) - val = ast.literal_eval(node.node.value) - assert val in self.exact_tokens, f"{node.node.value} is not a known literal" - type = self.exact_tokens[val] - return FunctionCall( - assigned_variable="_literal", - function="_PyPegen_expect_forced_token", - arguments=["p", type, f'"{val}"'], - nodetype=NodeTypes.GENERIC_TOKEN, - return_type="Token *", - comment=f"forced_token='{val}'", - ) - if isinstance(node.node, Group): - call = self.visit(node.node.rhs) - call.assigned_variable = None - call.comment = None - return FunctionCall( - assigned_variable="_literal", - function="_PyPegen_expect_forced_result", - arguments=["p", str(call), f'"{node.node.rhs!s}"'], - return_type="void *", - comment=f"forced_token=({node.node.rhs!s})", - ) - else: - raise NotImplementedError(f"Forced tokens don't work with {node.node} nodes") - - def visit_Opt(self, node: Opt) -> FunctionCall: - call = self.generate_call(node.node) - return FunctionCall( - assigned_variable="_opt_var", - function=call.function, - arguments=call.arguments, - force_true=True, - comment=f"{node}", - ) - - def _generate_artificial_rule_call( - self, - node: Any, - prefix: str, - rule_generation_func: Callable[[], str], - return_type: str | None = None, - ) -> FunctionCall: - node_str = f"{node}" - key = f"{prefix}_{node_str}" - if key in self.cache: - name = self.cache[key] - else: - name = rule_generation_func() - self.cache[key] = name - - return FunctionCall( - assigned_variable=f"{name}_var", - function=f"{name}_rule", - arguments=["p"], - return_type=return_type, - comment=node_str, - ) - - def visit_Rhs(self, node: Rhs) -> FunctionCall: - if node.can_be_inlined: - return self.generate_call(node.alts[0].items[0]) - - return self._generate_artificial_rule_call( - node, - "rhs", - lambda: self.gen.artificial_rule_from_rhs(node), - ) - - def visit_Repeat0(self, node: Repeat0) -> FunctionCall: - return self._generate_artificial_rule_call( - node, - "repeat0", - lambda: self.gen.artificial_rule_from_repeat(node.node, is_repeat1=False), - "asdl_seq *", - ) - - def visit_Repeat1(self, node: Repeat1) -> FunctionCall: - return self._generate_artificial_rule_call( - node, - "repeat1", - lambda: self.gen.artificial_rule_from_repeat(node.node, is_repeat1=True), - "asdl_seq *", - ) - - def visit_Gather(self, node: Gather) -> FunctionCall: - return self._generate_artificial_rule_call( - node, - "gather", - lambda: self.gen.artificial_rule_from_gather(node), - "asdl_seq *", - ) - - def visit_Group(self, node: Group) -> FunctionCall: - return self.generate_call(node.rhs) - - def visit_Cut(self, node: Cut) -> FunctionCall: - return FunctionCall( - assigned_variable="_cut_var", - return_type="int", - function="1", - nodetype=NodeTypes.CUT_OPERATOR, - ) - - def generate_call(self, node: Any) -> FunctionCall: - return super().visit(node) - - -class CParserGenerator(ParserGenerator, GrammarVisitor): +class CParserGenerator(ParserGenerator): def __init__( self, grammar: grammar.Grammar, @@ -385,510 +68,121 @@ def __init__( file: IO[str] | None, debug: bool = False, skip_actions: bool = False, + included_files: dict[pathlib.Path, IO[str]] | None = None, ): super().__init__(grammar, set(tokens.values()), file) + self.included_files = included_files or {} self.callmakervisitor: CCallMakerVisitor = CCallMakerVisitor( self, exact_tokens, non_exact_tokens ) - self._varname_counter = 0 + self._collected = False self.debug = debug self.skip_actions = skip_actions - self.cleanup_statements: list[str] = [] - - def add_level(self) -> None: - self.print("if (p->level++ == MAXSTACK || _Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) {") - with self.indent(): - self.print("_Pypegen_stack_overflow(p);") - self.print("}") - - def remove_level(self) -> None: - self.print("p->level--;") - - def add_return(self, ret_val: str) -> None: - for stmt in self.cleanup_statements: - self.print(stmt) - self.remove_level() - self.print(f"return {ret_val};") - - def unique_varname(self, name: str = "tmpvar") -> str: - new_var = name + "_" + str(self._varname_counter) - self._varname_counter += 1 - return new_var - - def call_with_errorcheck_return(self, call_text: str, returnval: str) -> None: - error_var = self.unique_varname() - self.print(f"int {error_var} = {call_text};") - self.print(f"if ({error_var}) {{") - with self.indent(): - self.add_return(returnval) - self.print("}") - def call_with_errorcheck_goto(self, call_text: str, goto_target: str) -> None: - error_var = self.unique_varname() - self.print(f"int {error_var} = {call_text};") - self.print(f"if ({error_var}) {{") - with self.indent(): - self.print(f"goto {goto_target};") - self.print("}") - - def out_of_memory_return( - self, - expr: str, - cleanup_code: str | None = None, - ) -> None: - self.print(f"if ({expr}) {{") - with self.indent(): - if cleanup_code is not None: - self.print(cleanup_code) - self.print("p->error_indicator = 1;") - self.print("PyErr_NoMemory();") - self.add_return("NULL") - self.print("}") - - def out_of_memory_goto(self, expr: str, goto_target: str) -> None: - self.print(f"if ({expr}) {{") - with self.indent(): - self.print("PyErr_NoMemory();") - self.print(f"goto {goto_target};") - self.print("}") + def generate(self, filename: pathlib.PurePath) -> None: + sources = {rule.source for rule in self.rules.values() if rule.source is not None} + if missing := sources - self.included_files.keys(): + raise grammar.GrammarError( + "No output file for the rules of " + + ", ".join(f"'{source}'" for source in sorted(missing)) + ) + parser = self.prepare(filename) + CParserEmitter(parser, self.file).emit() + for source, file in self.included_files.items(): + CParserEmitter(parser, file, source).emit() - def generate(self, filename: str) -> None: + def prepare(self, filename: pathlib.PurePath) -> CParser: self.collect_rules() - basename = os.path.basename(filename) - self.print(f"// @generated by pegen from {basename}") - header = self.grammar.metas.get("header", EXTENSION_PREFIX) - if header: - self.print(header.rstrip("\n")) - subheader = self.grammar.metas.get("subheader", "") - if subheader: - self.print(subheader) - self._setup_keywords() - self._setup_soft_keywords() - for i, (rulename, rule) in enumerate(self.all_rules.items(), 1000): - comment = " // Left-recursive" if rule.left_recursive else "" - self.print(f"#define {rulename}_type {i}{comment}") - self.print() - for rulename, rule in self.all_rules.items(): - if rule.is_loop() or rule.is_gather(): - type = "asdl_seq *" - elif rule.type: - type = rule.type + " " - else: - type = "void *" - self.print(f"static {type}{rulename}_rule(Parser *p);") - self.print() - for rulename, rule in list(self.all_rules.items()): - self.print() - if rule.left_recursive: - self.print("// Left-recursive") - self.visit(rule) + lowerer = self.callmakervisitor.make_lowerer() + shared = self._shared_rules() + rules = tuple( + lowerer.prepare_rule( + rule, skip_actions=self.skip_actions, shared=rule.name in shared + ) + for rule in self.all_rules.values() + ) + headers = [] + if header := self.grammar.metas.get("header", EXTENSION_PREFIX): + headers.append(header.rstrip("\n")) + if subheader := self.grammar.metas.get("subheader", ""): + headers.append(subheader) + return CParser( + source_name=filename.name, + headers=tuple(headers), + keyword_groups=self._prepare_keywords(), + soft_keywords=tuple(sorted(self.soft_keywords)), + rules=rules, + trailer=self._prepare_trailer(rules), + debug=self.debug, + ) + + def collect_rules(self) -> None: + # Keyword generation also uses this entry point without emitting C. + if not self._collected: + super().collect_rules() + self._collected = True + + def _shared_rules(self) -> set[str]: + # Rules called from a rule (or its actions) whose code goes in + # another C file. + shared = set() + for rule in self.all_rules.values(): + collector = _NameCollector() + collector.visit(rule) + for name in collector.names: + callee = self.all_rules.get(name) + if callee is None or callee.source == rule.source: + continue + # Artificial rules are only reused within one grammar file. + assert name in self.rules, f"{name} is used outside its grammar file" + shared.add(name) + # The trailer is C code in the root file that calls rules by their + # function name (the default one calls start_rule()). + trailer = self.grammar.metas.get("trailer", EXTENSION_SUFFIX) or "" + for name in _RULE_CALL.findall(trailer): + callee = self.rules.get(name) + if callee is not None and callee.source is not None: + shared.add(name) + return shared + + def _prepare_keywords(self) -> tuple[tuple[tuple[str, int], ...], ...]: + if not self.keywords: + return () + groups: list[list[tuple[str, int]]] = [ + [] for _ in range(max(map(len, self.keywords)) + 1) + ] + for keyword, token_type in self.keywords.items(): + groups[len(keyword)].append((keyword, token_type)) + return tuple(tuple(group) for group in groups) + + def _prepare_trailer(self, rules: tuple[CRule, ...]) -> str | None: if self.skip_actions: mode = 0 else: - mode = int(self.rules["start"].type == "mod_ty") if "start" in self.rules else 1 - if mode == 1 and self.grammar.metas.get("bytecode"): - mode += 1 + start = next((rule.signature for rule in rules if rule.signature.name == "start"), None) + match start: + case None | CRuleSignature(return_type="mod_ty"): + mode = 2 if self.grammar.metas.get("bytecode") else 1 + case _: + mode = 0 modulename = self.grammar.metas.get("modulename", "parse") - trailer = self.grammar.metas.get("trailer", EXTENSION_SUFFIX) - if trailer: - self.print(trailer.rstrip("\n") % dict(mode=mode, modulename=modulename)) - - def _group_keywords_by_length(self) -> dict[int, list[tuple[str, int]]]: - groups: dict[int, list[tuple[str, int]]] = {} - for keyword_str, keyword_type in self.keywords.items(): - length = len(keyword_str) - if length in groups: - groups[length].append((keyword_str, keyword_type)) - else: - groups[length] = [(keyword_str, keyword_type)] - return groups - - def _setup_keywords(self) -> None: - n_keyword_lists = ( - len(max(self.keywords.keys(), key=len)) + 1 if len(self.keywords) > 0 else 0 - ) - self.print(f"static const int n_keyword_lists = {n_keyword_lists};") - groups = self._group_keywords_by_length() - self.print("static KeywordToken *reserved_keywords[] = {") - with self.indent(): - num_groups = max(groups) + 1 if groups else 1 - for keywords_length in range(num_groups): - if keywords_length not in groups.keys(): - self.print("(KeywordToken[]) {{NULL, -1}},") - else: - self.print("(KeywordToken[]) {") - with self.indent(): - for keyword_str, keyword_type in groups[keywords_length]: - self.print(f'{{"{keyword_str}", {keyword_type}}},') - self.print("{NULL, -1},") - self.print("},") - self.print("};") - - def _setup_soft_keywords(self) -> None: - soft_keywords = sorted(self.soft_keywords) - self.print("static char *soft_keywords[] = {") - with self.indent(): - for keyword in soft_keywords: - self.print(f'"{keyword}",') - self.print("NULL,") - self.print("};") - - def _set_up_token_start_metadata_extraction(self) -> None: - self.print("if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {") - with self.indent(): - self.print("p->error_indicator = 1;") - self.add_return("NULL") - self.print("}") - self.print("int _start_lineno = p->tokens[_mark]->lineno;") - self.print("UNUSED(_start_lineno); // Only used by EXTRA macro") - self.print("int _start_col_offset = p->tokens[_mark]->col_offset;") - self.print("UNUSED(_start_col_offset); // Only used by EXTRA macro") - - def _set_up_token_end_metadata_extraction(self) -> None: - self.print("Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);") - self.print("if (_token == NULL) {") - with self.indent(): - self.add_return("NULL") - self.print("}") - self.print("int _end_lineno = _token->end_lineno;") - self.print("UNUSED(_end_lineno); // Only used by EXTRA macro") - self.print("int _end_col_offset = _token->end_col_offset;") - self.print("UNUSED(_end_col_offset); // Only used by EXTRA macro") - - def _check_for_errors(self) -> None: - self.print("if (p->error_indicator) {") - with self.indent(): - self.add_return("NULL") - self.print("}") + if trailer := self.grammar.metas.get("trailer", EXTENSION_SUFFIX): + return trailer.rstrip("\n") % dict(mode=mode, modulename=modulename) + return None - def _set_up_rule_memoization(self, node: Rule, result_type: str) -> None: - self.print("{") - with self.indent(): - self.add_level() - self.print(f"{result_type} _res = NULL;") - self.print(f"if (_PyPegen_is_memoized(p, {node.name}_type, &_res)) {{") - with self.indent(): - self.add_return("_res") - self.print("}") - self.print("int _mark = p->mark;") - self.print("int _resmark = p->mark;") - self.print("while (1) {") - with self.indent(): - self.call_with_errorcheck_return( - f"_PyPegen_update_memo(p, _mark, {node.name}_type, _res)", "_res" - ) - self.print("p->mark = _mark;") - self.print(f"void *_raw = {node.name}_raw(p);") - self.print("if (p->error_indicator) {") - with self.indent(): - self.add_return("NULL") - self.print("}") - self.print("if (_raw == NULL || p->mark <= _resmark)") - with self.indent(): - self.print("break;") - self.print("_resmark = p->mark;") - self.print("_res = _raw;") - self.print("}") - self.print("p->mark = _resmark;") - self.add_return("_res") - self.print("}") - self.print(f"static {result_type}") - self.print(f"{node.name}_raw(Parser *p)") - def _should_memoize(self, node: Rule) -> bool: - return "memo" in node.flags and not node.left_recursive +# A call to a rule's C function, as written in actions and the trailer. +_RULE_CALL = re.compile(r"\b(\w+)_rule\b") - def _handle_default_rule_body(self, node: Rule, rhs: Rhs, result_type: str) -> None: - memoize = self._should_memoize(node) - - with self.indent(): - self.add_level() - self._check_for_errors() - self.print(f"{result_type} _res = NULL;") - if memoize: - self.print(f"if (_PyPegen_is_memoized(p, {node.name}_type, &_res)) {{") - with self.indent(): - self.add_return("_res") - self.print("}") - self.print("int _mark = p->mark;") - if any(alt.action and "EXTRA" in alt.action for alt in rhs.alts): - self._set_up_token_start_metadata_extraction() - self.visit( - rhs, - is_loop=False, - is_gather=node.is_gather(), - rulename=node.name, - ) - if self.debug: - self.print(f'D(fprintf(stderr, "Fail at %d: {node.name}\\n", p->mark));') - self.print("_res = NULL;") - self.print(" done:") - with self.indent(): - if memoize: - self.print(f"_PyPegen_insert_memo(p, _mark, {node.name}_type, _res);") - self.add_return("_res") - - def _handle_loop_rule_body(self, node: Rule, rhs: Rhs) -> None: - memoize = self._should_memoize(node) - is_repeat1 = node.name.startswith("_loop1") - - with self.indent(): - self.add_level() - self._check_for_errors() - self.print("void *_res = NULL;") - if memoize: - self.print(f"if (_PyPegen_is_memoized(p, {node.name}_type, &_res)) {{") - with self.indent(): - self.add_return("_res") - self.print("}") - self.print("int _mark = p->mark;") - if memoize: - self.print("int _start_mark = p->mark;") - self.print("void **_children = PyMem_Malloc(sizeof(void *));") - self.out_of_memory_return("!_children") - self.print("Py_ssize_t _children_capacity = 1;") - self.print("Py_ssize_t _n = 0;") - if any(alt.action and "EXTRA" in alt.action for alt in rhs.alts): - self._set_up_token_start_metadata_extraction() - self.visit( - rhs, - is_loop=True, - is_gather=node.is_gather(), - rulename=node.name, - ) - if is_repeat1: - self.print("if (_n == 0 || p->error_indicator) {") - with self.indent(): - self.print("PyMem_Free(_children);") - self.add_return("NULL") - self.print("}") - self.print("asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);") - self.out_of_memory_return("!_seq", cleanup_code="PyMem_Free(_children);") - self.print("for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);") - self.print("PyMem_Free(_children);") - if memoize and node.name: - self.print(f"_PyPegen_insert_memo(p, _start_mark, {node.name}_type, _seq);") - self.add_return("_seq") - - def visit_Rule(self, node: Rule) -> None: - is_loop = node.is_loop() - is_gather = node.is_gather() - rhs = node.flatten() - if is_loop or is_gather: - result_type = "asdl_seq *" - elif node.type: - result_type = node.type - else: - result_type = "void *" - for line in str(node).splitlines(): - self.print(f"// {line}") - if node.left_recursive and node.leader: - self.print(f"static {result_type} {node.name}_raw(Parser *);") - - self.print(f"static {result_type}") - self.print(f"{node.name}_rule(Parser *p)") - - if node.left_recursive and node.leader: - self._set_up_rule_memoization(node, result_type) - - self.print("{") - - if node.name.endswith("without_invalid"): - with self.indent(): - self.print("int _prev_call_invalid = p->call_invalid_rules;") - self.print("p->call_invalid_rules = 0;") - self.cleanup_statements.append("p->call_invalid_rules = _prev_call_invalid;") - - if is_loop: - self._handle_loop_rule_body(node, rhs) - else: - self._handle_default_rule_body(node, rhs, result_type) - - if node.name.endswith("without_invalid"): - self.cleanup_statements.pop() - - self.print("}") - - def visit_NamedItem(self, node: NamedItem) -> None: - call = self.callmakervisitor.generate_call(node) - if call.assigned_variable: - call.assigned_variable = self.dedupe(call.assigned_variable) - self.print(call) - - def visit_Rhs( - self, node: Rhs, is_loop: bool, is_gather: bool, rulename: str | None - ) -> None: - if is_loop: - assert len(node.alts) == 1 - for alt in node.alts: - self.visit(alt, is_loop=is_loop, is_gather=is_gather, rulename=rulename) - - def join_conditions(self, keyword: str, node: Any) -> None: - self.print(f"{keyword} (") - with self.indent(): - first = True - for item in node.items: - if first: - first = False - else: - self.print("&&") - self.visit(item) - self.print(")") - - def emit_action(self, node: Alt, cleanup_code: str | None = None) -> None: - self.print(f"_res = {node.action};") - - self.print("if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) {") - with self.indent(): - self.print("p->error_indicator = 1;") - if cleanup_code: - self.print(cleanup_code) - self.add_return("NULL") - self.print("}") - - if self.debug: - self.print( - f'D(fprintf(stderr, "Hit with action [%d-%d]: %s\\n", _mark, p->mark, "{node}"));' - ) - - def emit_default_action(self, is_gather: bool, node: Alt) -> None: - if len(self.local_variable_names) > 1: - if is_gather: - assert len(self.local_variable_names) == 2 - self.print( - f"_res = _PyPegen_seq_insert_in_front(p, " - f"{self.local_variable_names[0]}, {self.local_variable_names[1]});" - ) - else: - if self.debug: - self.print( - f'D(fprintf(stderr, "Hit without action [%d:%d]: %s\\n", _mark, p->mark, "{node}"));' - ) - self.print( - f"_res = _PyPegen_dummy_name(p, {', '.join(self.local_variable_names)});" - ) - else: - if self.debug: - self.print( - f'D(fprintf(stderr, "Hit with default action [%d:%d]: %s\\n", _mark, p->mark, "{node}"));' - ) - self.print(f"_res = {self.local_variable_names[0]};") - - def emit_dummy_action(self) -> None: - self.print("_res = _PyPegen_dummy_name(p);") - - def handle_alt_normal(self, node: Alt, is_gather: bool, rulename: str | None) -> None: - self.join_conditions(keyword="if", node=node) - self.print("{") - # We have parsed successfully all the conditions for the option. - with self.indent(): - node_str = str(node).replace('"', '\\"') - self.print( - f'D(fprintf(stderr, "%*c+ {rulename}[%d-%d]: %s succeeded!\\n", p->level, \' \', _mark, p->mark, "{node_str}"));' - ) - # Prepare to emit the rule action and do so - if node.action and "EXTRA" in node.action: - self._set_up_token_end_metadata_extraction() - if self.skip_actions: - self.emit_dummy_action() - elif node.action: - self.emit_action(node) - else: - self.emit_default_action(is_gather, node) - - # As the current option has parsed correctly, do not continue with the rest. - self.print("goto done;") - self.print("}") - - def handle_alt_loop(self, node: Alt, is_gather: bool, rulename: str | None) -> None: - # Condition of the main body of the alternative - self.join_conditions(keyword="while", node=node) - self.print("{") - # We have parsed successfully one item! - with self.indent(): - # Prepare to emit the rule action and do so - if node.action and "EXTRA" in node.action: - self._set_up_token_end_metadata_extraction() - if self.skip_actions: - self.emit_dummy_action() - elif node.action: - self.emit_action(node, cleanup_code="PyMem_Free(_children);") - else: - self.emit_default_action(is_gather, node) - - # Add the result of rule to the temporary buffer of children. This buffer - # will populate later an asdl_seq with all elements to return. - self.print("if (_n == _children_capacity) {") - with self.indent(): - self.print("_children_capacity *= 2;") - self.print( - "void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));" - ) - self.out_of_memory_return("!_new_children", cleanup_code="PyMem_Free(_children);") - self.print("_children = _new_children;") - self.print("}") - self.print("_children[_n++] = _res;") - self.print("_mark = p->mark;") - self.print("}") - - def visit_Alt( - self, node: Alt, is_loop: bool, is_gather: bool, rulename: str | None - ) -> None: - if len(node.items) == 1 and str(node.items[0]).startswith("invalid_"): - self.print(f"if (p->call_invalid_rules) {{ // {node}") - else: - self.print(f"{{ // {node}") - with self.indent(): - self._check_for_errors() - node_str = str(node).replace('"', '\\"') - self.print( - f'D(fprintf(stderr, "%*c> {rulename}[%d-%d]: %s\\n", p->level, \' \', _mark, p->mark, "{node_str}"));' - ) - # Prepare variable declarations for the alternative - vars = self.collect_vars(node) - for v, var_type in sorted(item for item in vars.items() if item[0] is not None): - if not var_type: - var_type = "void *" - else: - var_type += " " - if v == "_cut_var": - v += " = 0" # cut_var must be initialized - self.print(f"{var_type}{v};") - if v and v.startswith("_opt_var"): - self.print(f"UNUSED({v}); // Silence compiler warnings") - - with self.local_variable_context(): - if is_loop: - self.handle_alt_loop(node, is_gather, rulename) - else: - self.handle_alt_normal(node, is_gather, rulename) - - self.print("p->mark = _mark;") - node_str = str(node).replace('"', '\\"') - self.print( - f"D(fprintf(stderr, \"%*c%s {rulename}[%d-%d]: %s failed!\\n\", p->level, ' ',\n" - f' p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "{node_str}"));' - ) - if "_cut_var" in vars: - self.print("if (_cut_var) {") - with self.indent(): - self.add_return("NULL") - self.print("}") - self.print("}") +class _NameCollector(grammar.GrammarVisitor): + def __init__(self) -> None: + self.names: set[str] = set() - def collect_vars(self, node: Alt) -> dict[str | None, str | None]: - types = {} - with self.local_variable_context(): - for item in node.items: - name, type = self.add_var(item) - types[name] = type - return types + def visit_NameLeaf(self, node: grammar.NameLeaf) -> None: + self.names.add(node.value) - def add_var(self, node: NamedItem) -> tuple[str | None, str | None]: - call = self.callmakervisitor.generate_call(node.item) - name = node.name if node.name else call.assigned_variable - if name is not None: - name = self.dedupe(name) - return_type = call.return_type if node.type is None else node.type - return name, return_type + def visit_Alt(self, node: grammar.Alt) -> None: + if node.action: + self.names.update(_RULE_CALL.findall(node.action)) + self.generic_visit(node) diff --git a/Tools/peg_generator/pegen/c_generator_calls.py b/Tools/peg_generator/pegen/c_generator_calls.py new file mode 100644 index 000000000000000..ffc4a3c01aabf71 --- /dev/null +++ b/Tools/peg_generator/pegen/c_generator_calls.py @@ -0,0 +1,561 @@ +"""Discover calls and helper rules, then prepare rules from resolved calls.""" + +import ast +import pathlib +import re +from collections.abc import Mapping +from dataclasses import replace +from types import MappingProxyType +from typing import TYPE_CHECKING, Any + +from pegen.c_generator_model import ( + CAction, + CAlternative, + CBindingKind, + CPrefix, + CRule, + CRuleSignature, + CVariable, +) +from pegen.c_generator_model import ( + FunctionCall as FunctionCall, +) +from pegen.c_generator_model import ( + NodeTypes as NodeTypes, +) +from pegen.grammar import ( + Alt, + Cut, + Forced, + Gather, + GrammarVisitor, + Group, + Item, + Leaf, + Lookahead, + NamedItem, + NameLeaf, + NegativeLookahead, + Opt, + PositiveLookahead, + Repeat0, + Repeat1, + Rhs, + Rule, + RuleKind, + StringLeaf, +) + +if TYPE_CHECKING: + from pegen.parser_generator import ParserGenerator + + +BASE_NODETYPES = { + "NAME": NodeTypes.NAME_TOKEN, + "NUMBER": NodeTypes.NUMBER_TOKEN, + "STRING": NodeTypes.STRING_TOKEN, + "SOFT_KEYWORD": NodeTypes.SOFT_KEYWORD, +} + +_HelperNode = Rhs | Repeat0 | Repeat1 | Gather + + +def rule_signature(rule: Rule) -> CRuleSignature: + return_type = rule.type if rule.kind is RuleKind.NORMAL else "asdl_seq *" + return CRuleSignature(rule.name, rule.kind, return_type) + + +def bind_call(node: NamedItem, call: FunctionCall) -> FunctionCall: + if not node.name and not node.type: + return call + return replace( + call, + assigned_variable=node.name or call.assigned_variable, + assigned_variable_type=node.type or call.assigned_variable_type, + binding_kind=CBindingKind.NORMAL if node.name else call.binding_kind, + ) + + +def consuming_rules(rules: dict[str, Rule]) -> set[str]: + """Conservatively prove which rules consume a token whenever they succeed.""" + consuming: set[str] = set() + + def consumes(node: Any) -> bool: + if isinstance(node, NamedItem): + return consumes(node.item) + if isinstance(node, NameLeaf): + return node.value not in rules or node.value in consuming + if isinstance(node, StringLeaf): + return True + if isinstance(node, Group): + return consumes(node.rhs) + if isinstance(node, Rhs): + return bool(node.alts) and all(any(consumes(i) for i in alt.items) for alt in node.alts) + if isinstance(node, (Forced, Repeat1, Gather)): + return consumes(node.node) + # Predicates, cuts, optional items, and zero-or-more items can succeed + # without consuming. Actions are assumed not to rewrite parser marks. + return False + + while True: + added = {name for name, rule in rules.items() + if name not in consuming and consumes(rule.rhs)} + if not added: + return consuming + consuming.update(added) + + +class CCallMakerVisitor(GrammarVisitor): + def __init__( + self, + parser_generator: "ParserGenerator", + exact_tokens: dict[str, int], + non_exact_tokens: set[str], + ): + self._registry = parser_generator + self._keywords = parser_generator.keywords + self._exact_tokens = exact_tokens + self._non_exact_tokens = non_exact_tokens + self._helper_cache: dict[tuple[pathlib.Path | None, type, str], str] = {} + self._calls: dict[NamedItem, tuple[Item, FunctionCall]] = {} + + def visit(self, node: Any, *args: Any, **kwargs: Any) -> FunctionCall: + match node: + case NamedItem(item=item): + call = self.visit(item) + self._calls[node] = (item, call) + return bind_call(node, call) + case NameLeaf(): + return self._name_call(node) + case StringLeaf(): + return self._string_call(node) + case PositiveLookahead(): + return self._lookahead_call(node, 1) + case NegativeLookahead(): + return self._lookahead_call(node, 0) + case Forced(): + return self._forced_call(node) + case Opt(): + return self._optional_call(node) + case Rhs(can_be_inlined=True): + return self.visit(node.alts[0].items[0]) + case Rhs() | Repeat0() | Repeat1() | Gather(): + return self._helper_call(node) + case Group(rhs=rhs): + return self.visit(rhs) + case Cut(): + return FunctionCall( + assigned_variable="_cut_var", + return_type="int", + function="1", + nodetype=NodeTypes.CUT_OPERATOR, + binding_kind=CBindingKind.CUT, + ) + case _: + return self.generic_visit(node, *args, **kwargs) + + def _keyword_call(self, keyword: str) -> FunctionCall: + return FunctionCall( + assigned_variable="_keyword", + function="_PyPegen_expect_token", + arguments=("p", self._keywords[keyword]), + return_type="Token *", + nodetype=NodeTypes.KEYWORD, + comment=f"token='{keyword}'", + ) + + def _soft_keyword_call(self, value: str) -> FunctionCall: + return FunctionCall( + assigned_variable="_keyword", + function="_PyPegen_expect_soft_keyword", + arguments=("p", value), + return_type="expr_ty", + nodetype=NodeTypes.SOFT_KEYWORD, + comment=f"soft_keyword='{value}'", + ) + + def _name_call(self, node: NameLeaf) -> FunctionCall: + name = node.value + if name in self._non_exact_tokens: + if name in BASE_NODETYPES: + return FunctionCall( + assigned_variable=f"{name.lower()}_var", + function=f"_PyPegen_{name.lower()}_token", + arguments=("p",), + nodetype=BASE_NODETYPES[name], + return_type="expr_ty", + comment=name, + ) + return FunctionCall( + assigned_variable=f"{name.lower()}_var", + function="_PyPegen_expect_token", + arguments=("p", name), + nodetype=NodeTypes.GENERIC_TOKEN, + return_type="Token *", + comment=f"token='{name}'", + ) + + type = None + if (signature := self._lookup_rule(name)) is not None: + type = signature.return_type + + return FunctionCall( + assigned_variable=f"{name}_var", + function=f"{name}_rule", + arguments=("p",), + return_type=type, + comment=f"{node}", + ) + + def _string_call(self, node: StringLeaf) -> FunctionCall: + val = ast.literal_eval(node.value) + if re.match(r"[a-zA-Z_]\w*\Z", val): # This is a keyword + if node.value.endswith("'"): + return self._keyword_call(val) + else: + return self._soft_keyword_call(node.value) + else: + assert val in self._exact_tokens, f"{node.value} is not a known literal" + type = self._exact_tokens[val] + return FunctionCall( + assigned_variable="_literal", + function="_PyPegen_expect_token", + arguments=("p", type), + nodetype=NodeTypes.GENERIC_TOKEN, + return_type="Token *", + comment=f"token='{val}'", + ) + + def _assert_compatible_return_type( + self, call: FunctionCall, wrapper: str, expected_rtype: str | None, + ) -> None: + if call.return_type != expected_rtype: + raise RuntimeError( + f"{call.function} return type is incompatible with {wrapper}: " + f"expect: {expected_rtype}, actual: {call.return_type}" + ) + + def _lookahead_call(self, node: Lookahead, positive: int) -> FunctionCall: + call = self.visit(node.node) + comment = None + match call: + case FunctionCall(nodetype=NodeTypes.NAME_TOKEN): + function = "_PyPegen_lookahead_for_expr" + self._assert_compatible_return_type(call, function, "expr_ty") + case FunctionCall(nodetype=NodeTypes.STRING_TOKEN): + # _PyPegen_string_token() returns 'void *' instead of 'Token *'; + # in addition, the overall function call would return 'expr_ty'. + assert call.function == "_PyPegen_string_token" + function = "_PyPegen_lookahead" + self._assert_compatible_return_type(call, function, "expr_ty") + case FunctionCall(nodetype=NodeTypes.SOFT_KEYWORD): + function = "_PyPegen_lookahead_with_string" + self._assert_compatible_return_type(call, function, "expr_ty") + case FunctionCall(nodetype=NodeTypes.GENERIC_TOKEN | NodeTypes.KEYWORD): + function = "_PyPegen_lookahead_with_int" + self._assert_compatible_return_type(call, function, "Token *") + comment = f"token={node.node}" + case FunctionCall(return_type="expr_ty"): + function = "_PyPegen_lookahead_for_expr" + case FunctionCall(return_type="stmt_ty"): + function = "_PyPegen_lookahead_for_stmt" + case _: + function = "_PyPegen_lookahead" + self._assert_compatible_return_type(call, function, None) + return FunctionCall( + function=function, + arguments=(positive, call.function, *call.arguments), + return_type="int", + comment=comment, + ) + + def _forced_call(self, node: Forced) -> FunctionCall: + call = self.visit(node.node) + match node.node: + case Leaf(value=value): + val = ast.literal_eval(value) + assert val in self._exact_tokens, f"{value} is not a known literal" + return FunctionCall( + assigned_variable="_literal", + function="_PyPegen_expect_forced_token", + arguments=("p", self._exact_tokens[val], f'"{val}"'), + nodetype=NodeTypes.GENERIC_TOKEN, + return_type="Token *", + comment=f"forced_token='{val}'", + ) + case Group(rhs=rhs): + return FunctionCall( + assigned_variable="_literal", + function="_PyPegen_expect_forced_result", + arguments=("p", call.expression(), f'"{rhs!s}"'), + return_type="void *", + comment=f"forced_token=({rhs!s})", + ) + case _: + raise NotImplementedError(f"Forced tokens don't work with {node.node} nodes") + + def _optional_call(self, node: Opt) -> FunctionCall: + call = self.visit(node.node) + return FunctionCall( + assigned_variable="_opt_var", + function=call.function, + arguments=call.arguments, + force_true=True, + comment=f"{node}", + binding_kind=CBindingKind.OPTIONAL, + ) + + def _helper_call( + self, + node: _HelperNode, + ) -> FunctionCall: + node_str = f"{node}" + signature = self._resolve_artificial_rule(node) + name = signature.name + return FunctionCall( + assigned_variable=f"{name}_var", + function=f"{name}_rule", + arguments=("p",), + return_type=signature.return_type, + comment=node_str, + ) + + def _lookup_rule(self, name: str) -> CRuleSignature | None: + if (rule := self._registry.all_rules.get(name.lower())) is not None: + return rule_signature(rule) + return None + + def _resolve_artificial_rule(self, node: _HelperNode) -> CRuleSignature: + # Preserve helper reuse and numbering from the fixed-point traversal. + # Helpers are only reused within one grammar file, so that each + # generated C file has its own (static) copy. + key = (self._registry.current_source, type(node), str(node)) + if (name := self._helper_cache.get(key)) is None: + match node: + case Rhs(): + name = self._registry.artificial_rule_from_rhs(node) + case Repeat0(node=child): + name = self._registry.artificial_rule_from_repeat(child, is_repeat1=False) + case Repeat1(node=child): + name = self._registry.artificial_rule_from_repeat(child, is_repeat1=True) + case Gather(): + name = self._registry.artificial_rule_from_gather(node) + self._helper_cache[key] = name + return rule_signature(self._registry.all_rules[name]) + + def make_lowerer(self) -> "CCallLowerer": + return CCallLowerer( + calls=self._calls, + rules=self._registry.all_rules, + original_rules=self._registry.rules, + signatures={ + name: rule_signature(rule) for name, rule in self._registry.all_rules.items() + }, + ) + + +class CCallLowerer: + """Resolve bindings, actions and control flow without registering rules. + + Discovery and lowering operate on the same, unchanged grammar. + """ + + def __init__( + self, + *, + calls: Mapping[NamedItem, tuple[Item, FunctionCall]], + rules: Mapping[str, Rule], + original_rules: dict[str, Rule], + signatures: Mapping[str, CRuleSignature], + ): + self._calls = MappingProxyType(dict(calls)) + self._signatures = MappingProxyType(dict(signatures)) + self._prefixes: dict[str, tuple[CPrefix, ...]] = {} + self._prefix_calls: dict[NamedItem, CPrefix] = {} + consuming = consuming_rules(original_rules) + counter = 0 + + def candidate(alt: Alt) -> Rule | None: + if not alt.items or not isinstance(alt.items[0].item, NameLeaf): + return None + rule = original_rules.get(alt.items[0].item.value) + if rule is None or rule.name not in consuming: + return None + if (rule.memo and not rule.left_recursive) or ( + rule.left_recursive and rule.leader + ): + return rule + return None + + for rule in rules.values(): + if rule.kind in {RuleKind.LOOP0, RuleKind.LOOP1}: + continue + # Reuse a consuming prefix only within a consecutive group. + # Diagnostic calls still invoke the original rule. + prefixes = [] + alts = rule.flatten().alts + i = 0 + while i < len(alts): + prefix_rule = candidate(alts[i]) + j = i + 1 + while prefix_rule is not None and j < len(alts) and candidate(alts[j]) is prefix_rule: + j += 1 + if prefix_rule is not None and j - i > 1: + prefix = CPrefix(f"_prefix_{counter}", prefix_rule.type or "void *") + counter += 1 + prefixes.append(prefix) + for alt in alts[i:j]: + self._prefix_calls[alt.items[0]] = prefix + i = j + self._prefixes[rule.name] = tuple(prefixes) + + def prepare_rule( + self, rule: Rule, *, skip_actions: bool = False, shared: bool = False + ) -> CRule: + if (signature := self._signatures.get(rule.name)) is None: + raise RuntimeError(f"Rule {rule.name!r} was not discovered") + rhs = rule.flatten() + if signature.kind in {RuleKind.LOOP0, RuleKind.LOOP1}: + assert len(rhs.alts) == 1 + return CRule( + signature=signature, + text=str(rule), + alternatives=tuple( + self.prepare_alt(alt, kind=signature.kind, skip_actions=skip_actions) + for alt in rhs.alts + ), + left_recursive=rule.left_recursive, + leader=rule.leader, + memoize=rule.memo and not rule.left_recursive, + fastpath=rule.fastpath, + disable_invalid_rules=rule.name.endswith("without_invalid"), + prefixes=self._prefixes.get(rule.name, ()), + source=rule.source, + shared=shared, + ) + + def prepare_alt( + self, + node: Alt, + *, + kind: RuleKind = RuleKind.NORMAL, + skip_actions: bool = False, + ) -> CAlternative: + calls: list[FunctionCall] = [] + variables: dict[str, CVariable] = {} + cut_variable = None + for item in node.items: + recorded = self._calls.get(item) + if recorded is None or recorded[0] is not item.item: + raise RuntimeError(f"Item {item} was not discovered") + call = bind_call(item, recorded[1]) + if (prefix := self._prefix_calls.get(item)) is not None: + result, end, valid = prefix.result, prefix.end, prefix.valid + original = call.expression() + call = replace( + call, + function=( + f"((!p->call_invalid_rules && {valid}) ? " + f"(p->mark = {end}, {result}) : " + f"({result} = {original}, {end} = p->mark, {valid} = 1, {result}))" + ), + arguments=(), + ) + if original_name := call.assigned_variable: + name = original_name + counter = 0 + while name in variables: + counter += 1 + name = f"{original_name}_{counter}" + if name != original_name: + call = replace(call, assigned_variable=name) + initializer = ( + "0" if call.binding_kind is CBindingKind.CUT and cut_variable is None + else None + ) + if initializer is not None: + cut_variable = name + variables[name] = CVariable( + name=name, + type=call.return_type if item.type is None else item.type, + initializer=initializer, + unused=call.binding_kind is CBindingKind.OPTIONAL, + ) + calls.append(call) + return CAlternative( + text=str(node), + action=self._prepare_action(node, list(variables), kind, skip_actions), + calls=tuple(calls), + variables=tuple(variables.values()), + cut_variable=cut_variable, + requires_invalid_rules=self._requires_invalid_rules(node), + uses_locations=bool(node.action and "EXTRA" in node.action), + ) + + def _requires_invalid_rules(self, node: Alt) -> bool: + match node.items: + case [NamedItem(item=item)]: + pass + case _: + return False + # Preserve the source convention for bare, optional and repeated + # invalid references, including an invalid gather separator. + while True: + match item: + case Rhs(alts=[Alt(items=[NamedItem(item=child)])]): + item = child + case Gather(separator=separator): + item = separator + case Opt(node=child) | Repeat0(node=child) | Repeat1(node=child): + # A compound optional may match empty, so an invalid + # reference inside it must not gate the whole alternative. + if self._is_compound(child): + return False + item = child + case NameLeaf(value=name): + return name.startswith("invalid_") + case _: + return False + + def _is_compound(self, item: Item) -> bool: + match item: + case Rhs(alts=alts): + return len(alts) > 1 or any( + len(alt.items) > 1 or any(self._is_compound(part.item) for part in alt.items) + for alt in alts + ) + case Group(rhs=rhs): + return self._is_compound(rhs) + case Gather(separator=separator, node=child): + return self._is_compound(separator) or self._is_compound(child) + case ( + Opt(node=child) | Repeat0(node=child) | Repeat1(node=child) + | Forced(node=child) | Lookahead(node=child) + ): + return self._is_compound(child) + case StringLeaf(value=value): + return " " in value + case _: + return False + + @staticmethod + def _prepare_action( + node: Alt, names: list[str], kind: RuleKind, skip_actions: bool, + ) -> CAction: + if skip_actions: + return CAction("_PyPegen_dummy_name(p)") + if action := node.action: + return CAction( + action, checked=True, debug_message="Hit with action [%d-%d]: %s", + ) + match names: + case [first, rest] if kind is RuleKind.GATHER: + return CAction(f"_PyPegen_seq_insert_in_front(p, {first}, {rest})") + case [_, _, *_]: + assert kind is not RuleKind.GATHER + return CAction( + f"_PyPegen_dummy_name(p, {', '.join(names)})", + debug_message="Hit without action [%d:%d]: %s", + ) + case _: + return CAction(names[0], debug_message="Hit with default action [%d:%d]: %s") diff --git a/Tools/peg_generator/pegen/c_generator_file.py b/Tools/peg_generator/pegen/c_generator_file.py new file mode 100644 index 000000000000000..83b5a38c2cb14b4 --- /dev/null +++ b/Tools/peg_generator/pegen/c_generator_file.py @@ -0,0 +1,107 @@ +"""Emit a complete C parser from an immutable plan and local output state.""" + +import pathlib +from collections.abc import Iterator +from contextlib import contextmanager +from typing import IO + +from pegen.c_generator_model import CParser, CRule +from pegen.c_generator_rules import CRuleEmitter + +SHARED_RULE_PREFIX = "_PyPegen_" + + +class CParserEmitter: + def __init__(self, parser: CParser, file: IO[str] | None, source: pathlib.Path | None = None): + self._parser = parser + self._file = file + self._source = source + self._level = 0 + + def emit(self) -> None: + self._emit_headers() + if self._source is None: + self._emit_keywords() + self._emit_declarations() + self._emit_rules() + if self._source is None and self._parser.trailer is not None: + self.print(self._parser.trailer) + + def _own_rules(self) -> Iterator[tuple[int, CRule]]: + # Rule type ids number all rules of the parser, so that they stay + # unique across its C files. + for rule_id, rule in enumerate(self._parser.rules, 1000): + if rule.source == self._source: + yield rule_id, rule + + def _emit_headers(self) -> None: + if self._source is None: + source_name = self._parser.source_name + else: + source_name = self._source.name + self.print(f"// @generated by pegen from {source_name}") + for header in self._parser.headers: + self.print(header) + + def _emit_keywords(self) -> None: + groups = self._parser.keyword_groups + self.print(f"static const int n_keyword_lists = {len(groups)};") + self.print("static KeywordToken *reserved_keywords[] = {") + with self.indent(): + for group in groups or ((),): + if not group: + self.print("(KeywordToken[]) {{NULL, -1}},") + else: + self.print("(KeywordToken[]) {") + with self.indent(): + for keyword, token_type in group: + self.print(f'{{"{keyword}", {token_type}}},') + self.print("{NULL, -1},") + self.print("},") + self.print("};") + self.print("static char *soft_keywords[] = {") + with self.indent(): + for keyword in self._parser.soft_keywords: + self.print(f'"{keyword}",') + self.print("NULL,") + self.print("};") + + def _emit_declarations(self) -> None: + for rule_id, rule in self._own_rules(): + comment = " // Left-recursive" if rule.left_recursive else "" + self.print(f"#define {rule.signature.name}_type {rule_id}{comment}") + self.print() + shared_rules = [rule for rule in self._parser.rules if rule.shared] + if shared_rules: + self.print("// Rules shared between the C files of this parser") + for rule in shared_rules: + name = f"{rule.signature.name}_rule" + self.print(f"#define {name} {SHARED_RULE_PREFIX}{name}") + self.print(f"Py_LOCAL_SYMBOL {rule.signature.declaration(static=False)}") + self.print() + for _, rule in self._own_rules(): + if not rule.shared: + self.print(rule.signature.declaration()) + self.print() + + def _emit_rules(self) -> None: + for _, rule in self._own_rules(): + self.print() + if rule.left_recursive: + self.print("// Left-recursive") + CRuleEmitter(self, rule, debug=self._parser.debug).emit() + + def print(self, *args: object) -> None: + if not args: + print(file=self._file) + else: + print(" " * self._level, end="", file=self._file) + print(*args, file=self._file) + + @contextmanager + def indent(self) -> Iterator[None]: + self._level += 1 + try: + yield + finally: + self._level -= 1 diff --git a/Tools/peg_generator/pegen/c_generator_model.py b/Tools/peg_generator/pegen/c_generator_model.py new file mode 100644 index 000000000000000..2c2298e3238519d --- /dev/null +++ b/Tools/peg_generator/pegen/c_generator_model.py @@ -0,0 +1,147 @@ +"""Immutable C parser descriptions shared by lowering and emission.""" + +import pathlib +from dataclasses import dataclass +from enum import Enum, auto + +from pegen.grammar import RuleKind + + +class NodeTypes(Enum): + NAME_TOKEN = 0 + NUMBER_TOKEN = 1 + STRING_TOKEN = 2 + GENERIC_TOKEN = 3 + KEYWORD = 4 + SOFT_KEYWORD = 5 + CUT_OPERATOR = 6 + F_STRING_CHUNK = 7 + + +class CBindingKind(Enum): + NORMAL = auto() + OPTIONAL = auto() + CUT = auto() + + +@dataclass(frozen=True, slots=True) +class FunctionCall: + function: str + arguments: tuple[str | int, ...] = () + assigned_variable: str | None = None + assigned_variable_type: str | None = None + return_type: str | None = None + nodetype: NodeTypes | None = None + force_true: bool = False + comment: str | None = None + binding_kind: CBindingKind = CBindingKind.NORMAL + + def expression(self) -> str: + """Render the invocation without its alternative-local binding or comment.""" + expression = self.function + if arguments := self.arguments: + expression += f"({', '.join(map(str, arguments))})" + if self.force_true: + expression += ", !p->error_indicator" + return expression + + def __str__(self) -> str: + expression = self.expression() + if variable := self.assigned_variable: + cast = f"({self.assigned_variable_type})" if self.assigned_variable_type else "" + expression = f"({variable} = {cast}{expression})" + if comment := self.comment: + expression += f" // {comment}" + return expression + + +@dataclass(frozen=True, slots=True) +class CRuleSignature: + name: str + kind: RuleKind + return_type: str | None + + @property + def c_return_type(self) -> str: + return self.return_type or "void *" + + def declaration(self, *, static: bool = True) -> str: + separator = " " if self.kind is RuleKind.NORMAL and self.return_type else "" + storage = "static " if static else "" + return f"{storage}{self.c_return_type}{separator}{self.name}_rule(Parser *p);" + + +@dataclass(frozen=True, slots=True) +class CVariable: + name: str + type: str | None + initializer: str | None = None + unused: bool = False + + +@dataclass(frozen=True, slots=True) +class CAction: + expression: str + checked: bool = False + debug_message: str | None = None + + +@dataclass(frozen=True, slots=True) +class CAlternative: + text: str + action: CAction + calls: tuple[FunctionCall, ...] + variables: tuple[CVariable, ...] + cut_variable: str | None + requires_invalid_rules: bool + uses_locations: bool + + +@dataclass(frozen=True, slots=True) +class CPrefix: + name: str + type: str + + @property + def result(self) -> str: + return self.name + "_result" + + @property + def end(self) -> str: + return self.name + "_end" + + @property + def valid(self) -> str: + return self.name + "_valid" + + +@dataclass(frozen=True, slots=True) +class CRule: + signature: CRuleSignature + text: str + alternatives: tuple[CAlternative, ...] + left_recursive: bool + leader: bool + memoize: bool + fastpath: str | None + disable_invalid_rules: bool + prefixes: tuple[CPrefix, ...] = () + source: pathlib.Path | None = None + shared: bool = False + + @property + def uses_locations(self) -> bool: + return any(alt.uses_locations for alt in self.alternatives) + + +@dataclass(frozen=True, slots=True) +class CParser: + """Complete file-emission input, independent of compilation state.""" + + source_name: str + headers: tuple[str, ...] + keyword_groups: tuple[tuple[tuple[str, int], ...], ...] + soft_keywords: tuple[str, ...] + rules: tuple[CRule, ...] + trailer: str | None + debug: bool diff --git a/Tools/peg_generator/pegen/c_generator_rules.py b/Tools/peg_generator/pegen/c_generator_rules.py new file mode 100644 index 000000000000000..cc252ba30d291f0 --- /dev/null +++ b/Tools/peg_generator/pegen/c_generator_rules.py @@ -0,0 +1,356 @@ +"""Render prepared C rules with rule-local output and cleanup state.""" + +from collections.abc import Iterator +from contextlib import AbstractContextManager, contextmanager +from dataclasses import dataclass +from typing import Protocol + +from pegen.c_generator_model import CAlternative, CRule +from pegen.grammar import RuleKind + + +class CWriter(Protocol): + def print(self, *args: object) -> None: + ... + + def indent(self) -> AbstractContextManager[None]: + ... + + +@dataclass(frozen=True, slots=True) +class _CReturnEmitter: + writer: CWriter + cleanups: tuple[str, ...] = () + + def with_cleanup(self, cleanup: str) -> "_CReturnEmitter": + return _CReturnEmitter(self.writer, (cleanup, *self.cleanups)) + + def emit(self, value: str) -> None: + for cleanup in self.cleanups: + self.writer.print(cleanup) + self.writer.print("p->level--;") + self.writer.print(f"return {value};") + + def no_memory(self) -> None: + self.writer.print("p->error_indicator = 1;") + self.writer.print("PyErr_NoMemory();") + self.emit("NULL") + + +class _LoopBuffer: + """Temporary repetition storage and the exits that release it.""" + + _release = "PyMem_Free(_children);" + + def __init__(self, writer: CWriter, returns: _CReturnEmitter): + self._print = writer.print + self._indent = writer.indent + self.error_returns = returns.with_cleanup(self._release) + + def initialize(self) -> None: + self._print("void **_children = NULL;") + self._print("Py_ssize_t _children_capacity = 0;") + self._print("Py_ssize_t _n = 0;") + + def append(self, value: str) -> None: + self._print("if (_n == _children_capacity) {") + with self._indent(): + self._check_memory( + "_PyPegen_grow_loop_buffer(&_children, &_children_capacity) < 0" + ) + self._print("}") + self._print(f"_children[_n++] = {value};") + + def finish(self, *, require_one: bool) -> str: + if require_one: + self._print("if (_n == 0 || p->error_indicator) {") + with self._indent(): + self.error_returns.emit("NULL") + self._print("}") + self._print("asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);") + self._check_memory("!_seq") + self._print("for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);") + self._print(self._release) + return "_seq" + + def _check_memory(self, expr: str) -> None: + self._print(f"if ({expr}) {{") + with self._indent(): + self.error_returns.no_memory() + self._print("}") + + +class CRuleEmitter: + def __init__(self, writer: CWriter, rule: CRule, *, debug: bool = False): + self._writer = writer + self._print = writer.print + self._indent = writer.indent + self._rule = rule + self._debug = debug + self._returns = _CReturnEmitter(writer) + + def emit(self) -> None: + rule = self._rule + signature = rule.signature + result_type = signature.c_return_type + for line in rule.text.splitlines(): + self._print(f"// {line}") + if rule.left_recursive and rule.leader: + self._print(f"static {result_type} {signature.name}_raw(Parser *);") + self._print(f"Py_LOCAL_SYMBOL {result_type}" if rule.shared else f"static {result_type}") + self._print(f"{signature.name}_rule(Parser *p)") + if rule.left_recursive and rule.leader: + self._emit_left_recursive_wrapper() + self._print("{") + with self._invalid_rule_context(): + match signature.kind: + case RuleKind.LOOP0 | RuleKind.LOOP1: + self._emit_loop_body() + case RuleKind.NORMAL | RuleKind.GATHER: + self._emit_rule_body() + self._print("}") + + @contextmanager + def _invalid_rule_context(self) -> Iterator[None]: + if not self._rule.disable_invalid_rules: + yield + return + with self._indent(): + self._print("int _prev_call_invalid = p->call_invalid_rules;") + self._print("p->call_invalid_rules = 0;") + previous_returns = self._returns + self._returns = previous_returns.with_cleanup( + "p->call_invalid_rules = _prev_call_invalid;" + ) + try: + yield + finally: + self._returns = previous_returns + + def _emit_left_recursive_wrapper(self) -> None: + signature = self._rule.signature + result_type = signature.c_return_type + self._print("{") + with self._indent(): + self._emit_recursion_check() + self._print(f"{result_type} _res = NULL;") + self._print(f"if (_PyPegen_is_memoized(p, {signature.name}_type, &_res)) {{") + with self._indent(): + self._returns.emit("_res") + self._print("}") + self._print("int _mark = p->mark;") + self._print("int _resmark = p->mark;") + self._print(f"Memo *_memo = _PyPegen_insert_memo_direct(p, _mark, {signature.name}_type);") + self._print("if (_memo == NULL) {") + with self._indent(): + self._returns.emit("NULL") + self._print("}") + self._print("while (1) {") + with self._indent(): + self._print("_memo->node = _res;") + self._print("_memo->mark = p->mark;") + self._print("p->mark = _mark;") + self._print(f"void *_raw = {signature.name}_raw(p);") + self._print("if (p->error_indicator) {") + with self._indent(): + self._returns.emit("NULL") + self._print("}") + self._print("if (_raw == NULL || p->mark <= _resmark)") + with self._indent(): + self._print("break;") + self._print("_resmark = p->mark;") + self._print("_res = _raw;") + self._print("}") + self._print("p->mark = _resmark;") + self._returns.emit("_res") + self._print("}") + self._print(f"static {result_type}") + self._print(f"{signature.name}_raw(Parser *p)") + + def _emit_rule_body(self) -> None: + signature = self._rule.signature + memoize = self._rule.memoize + result_type = signature.c_return_type + + with self._indent(): + self._emit_recursion_check() + self._emit_error_check() + self._print(f"{result_type} _res = NULL;") + if fastpath := self._rule.fastpath: + self._print(f"if ({fastpath}(p, &_res)) {{") + with self._indent(): + self._returns.emit("_res") + self._print("}") + if memoize: + self._print(f"if (_PyPegen_is_memoized(p, {signature.name}_type, &_res)) {{") + with self._indent(): + self._returns.emit("_res") + self._print("}") + self._print("int _mark = p->mark;") + for prefix in self._rule.prefixes: + self._print(f"{prefix.type} {prefix.result} = NULL;") + self._print(f"int {prefix.end} = 0, {prefix.valid} = 0;") + if self._rule.uses_locations: + self._emit_token_start_metadata() + for alt in self._rule.alternatives: + with self._alternative(alt): + self._emit_normal_alt(alt) + if self._debug: + self._print(f'D(fprintf(stderr, "Fail at %d: {signature.name}\\n", p->mark));') + self._print("_res = NULL;") + self._print(" done:") + with self._indent(): + if memoize: + self._print(f"_PyPegen_insert_memo(p, _mark, {signature.name}_type, _res);") + self._returns.emit("_res") + + def _emit_loop_body(self) -> None: + rule = self._rule + signature = rule.signature + buffer = _LoopBuffer(self._writer, self._returns) + with self._indent(): + self._emit_recursion_check() + self._emit_error_check() + self._print("void *_res = NULL;") + if rule.memoize: + self._print(f"if (_PyPegen_is_memoized(p, {signature.name}_type, &_res)) {{") + with self._indent(): + self._returns.emit("_res") + self._print("}") + self._print("int _mark = p->mark;") + if rule.memoize: + self._print("int _start_mark = p->mark;") + buffer.initialize() + if rule.uses_locations: + self._emit_token_start_metadata() + alt, = rule.alternatives + with self._alternative(alt): + self._emit_loop_alt(alt, buffer) + result = buffer.finish(require_one=signature.kind is RuleKind.LOOP1) + if rule.memoize: + self._print(f"_PyPegen_insert_memo(p, _start_mark, {signature.name}_type, {result});") + self._returns.emit(result) + + @contextmanager + def _alternative(self, alt: CAlternative) -> Iterator[None]: + rulename = self._rule.signature.name + if alt.requires_invalid_rules: + self._print(f"if (p->call_invalid_rules) {{ // {alt.text}") + else: + self._print(f"{{ // {alt.text}") + with self._indent(): + self._emit_error_check() + node_str = alt.text.replace('"', '\\"') + self._print( + f'D(fprintf(stderr, "%*c> {rulename}[%d-%d]: %s\\n", p->level, \' \', _mark, p->mark, "{node_str}"));' + ) + for variable in sorted(alt.variables, key=lambda var: var.name): + ctype = variable.type + " " if variable.type else "void *" + initializer = ( + f" = {variable.initializer}" if variable.initializer is not None else "" + ) + self._print(f"{ctype}{variable.name}{initializer};") + if variable.unused: + self._print(f"UNUSED({variable.name}); // Silence compiler warnings") + + yield + + self._print("p->mark = _mark;") + self._print( + f"D(fprintf(stderr, \"%*c%s {rulename}[%d-%d]: %s failed!\\n\", p->level, ' ',\n" + f' p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "{node_str}"));' + ) + if alt.cut_variable is not None: + self._print(f"if ({alt.cut_variable}) {{") + with self._indent(): + self._returns.emit("NULL") + self._print("}") + self._print("}") + + def _emit_conditions(self, keyword: str, alt: CAlternative) -> None: + self._print(f"{keyword} (") + with self._indent(): + for index, call in enumerate(alt.calls): + if index: + self._print("&&") + self._print(call) + self._print(")") + + def _emit_normal_alt(self, alt: CAlternative) -> None: + rulename = self._rule.signature.name + self._emit_conditions(keyword="if", alt=alt) + self._print("{") + with self._indent(): + node_str = alt.text.replace('"', '\\"') + self._print( + f'D(fprintf(stderr, "%*c+ {rulename}[%d-%d]: %s succeeded!\\n", p->level, \' \', _mark, p->mark, "{node_str}"));' + ) + self._emit_alt_action(alt, self._returns) + + self._print("goto done;") + self._print("}") + + def _emit_loop_alt(self, alt: CAlternative, buffer: _LoopBuffer) -> None: + self._emit_conditions(keyword="while", alt=alt) + self._print("{") + with self._indent(): + self._emit_alt_action(alt, buffer.error_returns) + buffer.append("_res") + self._print("_mark = p->mark;") + self._print("}") + + def _emit_alt_action(self, alt: CAlternative, error_returns: _CReturnEmitter) -> None: + # Location failures and explicit-action failures have distinct cleanup + # paths in the generated parser. Keep their return contexts separate. + if alt.uses_locations: + self._emit_token_end_metadata() + if not alt.action.checked: + self._emit_action_debug(alt) + self._print(f"_res = {alt.action.expression};") + if alt.action.checked: + self._print("if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) {") + with self._indent(): + self._print("p->error_indicator = 1;") + error_returns.emit("NULL") + self._print("}") + self._emit_action_debug(alt) + + def _emit_action_debug(self, alt: CAlternative) -> None: + if self._debug and alt.action.debug_message: + self._print( + f'D(fprintf(stderr, "{alt.action.debug_message}\\n", _mark, p->mark, "{alt.text}"));' + ) + + def _emit_token_start_metadata(self) -> None: + self._print("if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {") + with self._indent(): + self._print("p->error_indicator = 1;") + self._returns.emit("NULL") + self._print("}") + self._print("int _start_lineno = p->tokens[_mark]->lineno;") + self._print("UNUSED(_start_lineno); // Only used by EXTRA macro") + self._print("int _start_col_offset = p->tokens[_mark]->col_offset;") + self._print("UNUSED(_start_col_offset); // Only used by EXTRA macro") + + def _emit_token_end_metadata(self) -> None: + self._print("Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);") + self._print("if (_token == NULL) {") + with self._indent(): + self._returns.emit("NULL") + self._print("}") + self._print("int _end_lineno = _token->end_lineno;") + self._print("UNUSED(_end_lineno); // Only used by EXTRA macro") + self._print("int _end_col_offset = _token->end_col_offset;") + self._print("UNUSED(_end_col_offset); // Only used by EXTRA macro") + + def _emit_error_check(self) -> None: + self._print("if (p->error_indicator) {") + with self._indent(): + self._returns.emit("NULL") + self._print("}") + + def _emit_recursion_check(self) -> None: + self._print("if (p->level++ == MAXSTACK || _PyPegen_stack_exhausted(p)) {") + with self._indent(): + self._print("_Pypegen_stack_overflow(p);") + self._print("}") diff --git a/Tools/peg_generator/pegen/first_sets.py b/Tools/peg_generator/pegen/first_sets.py index f6b83c0ca31e3f4..9980f76666518d7 100755 --- a/Tools/peg_generator/pegen/first_sets.py +++ b/Tools/peg_generator/pegen/first_sets.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3.8 import argparse +import pathlib import pprint import sys @@ -28,7 +29,7 @@ prog="calculate_first_sets", description="Calculate the first sets of a grammar", ) -argparser.add_argument("grammar_file", help="The grammar file") +argparser.add_argument("grammar_file", type=pathlib.Path, help="The grammar file") class FirstSetCalculator(GrammarVisitor): diff --git a/Tools/peg_generator/pegen/grammar.py b/Tools/peg_generator/pegen/grammar.py index d3c2eca6615a9fb..b64fdbf9120b702 100644 --- a/Tools/peg_generator/pegen/grammar.py +++ b/Tools/peg_generator/pegen/grammar.py @@ -1,6 +1,8 @@ from __future__ import annotations +import pathlib from collections.abc import Iterable, Iterator, Set +from enum import Enum, auto from typing import Any @@ -34,7 +36,16 @@ def __init__(self, rules: Iterable[Rule], metas: Iterable[tuple[str, str | None] raise GrammarError(f"Repeated rule {rule.name!r}") all_rules[rule.name] = rule self.rules = all_rules - self.metas = dict(metas) + # "@include" can appear more than once, so it is kept apart from the + # other metas. + metas = list(metas) + self.includes: list[str] = [] + for name, value in metas: + if name == "include": + if value is None: + raise GrammarError("@include requires a file name") + self.includes.append(value) + self.metas = {name: value for name, value in metas if name != "include"} def __str__(self) -> str: return "\n".join(str(rule) for name, rule in self.rules.items()) @@ -57,20 +68,51 @@ def __iter__(self) -> Iterator[Rule]: SIMPLE_STR = True +class RuleKind(Enum): + NORMAL = auto() + LOOP0 = auto() + LOOP1 = auto() + GATHER = auto() + + class Rule: - def __init__(self, name: str, type: str | None, rhs: Rhs, flags: frozenset[str] | None = None): + def __init__( + self, + name: str, + type: str | None, + rhs: Rhs, + flags: frozenset[str] | None = None, + *, + kind: RuleKind = RuleKind.NORMAL, + source: pathlib.Path | None = None, + ): self.name = name self.type = type self.rhs = rhs self.flags = flags or frozenset() + self.memo = "memo" in self.flags + self.fastpath: str | None = None + for flag in self.flags: + name, _, function = flag.partition("=") + if name == "fastpath": + if not function: + raise ValueError( + f"rule {self.name!r}: fastpath flag needs a function" + ) + self.fastpath = function + break + self.kind = kind + # The included grammar file that defines this rule, relative to the + # root grammar file's directory, or None for the root grammar file itself. + self.source: pathlib.Path | None = source self.left_recursive = False self.leader = False def is_loop(self) -> bool: - return self.name.startswith("_loop") + return self.kind in (RuleKind.LOOP0, RuleKind.LOOP1) def is_gather(self) -> bool: - return self.name.startswith("_gather") + return self.kind is RuleKind.GATHER def __str__(self) -> str: if SIMPLE_STR or self.type is None: @@ -84,22 +126,18 @@ def __str__(self) -> str: return "\n".join(lines) def __repr__(self) -> str: - return f"Rule({self.name!r}, {self.type!r}, {self.rhs!r})" + kind = f", kind=RuleKind.{self.kind.name}" if self.kind is not RuleKind.NORMAL else "" + return f"Rule({self.name!r}, {self.type!r}, {self.rhs!r}{kind})" def __iter__(self) -> Iterator[Rhs]: yield self.rhs def flatten(self) -> Rhs: # If it's a single parenthesized group, flatten it. - rhs = self.rhs - if ( - not self.is_loop() - and len(rhs.alts) == 1 - and len(rhs.alts[0].items) == 1 - and isinstance(rhs.alts[0].items[0].item, Group) - ): - rhs = rhs.alts[0].items[0].item.rhs - return rhs + match self.rhs: + case Rhs(alts=[Alt(items=[NamedItem(item=Group(rhs=rhs))])]) if not self.is_loop(): + return rhs + return self.rhs class Leaf: @@ -147,12 +185,11 @@ def __iter__(self) -> Iterator[list[Alt]]: @property def can_be_inlined(self) -> bool: - if len(self.alts) != 1 or len(self.alts[0].items) != 1: - return False - # If the alternative has an action we cannot inline - if getattr(self.alts[0], "action", None) is not None: - return False - return True + match self.alts: + case [Alt(items=[_], action=None)]: + return True + case _: + return False class Alt: diff --git a/Tools/peg_generator/pegen/grammar_analysis.py b/Tools/peg_generator/pegen/grammar_analysis.py new file mode 100644 index 000000000000000..5b716cf209e000a --- /dev/null +++ b/Tools/peg_generator/pegen/grammar_analysis.py @@ -0,0 +1,155 @@ +"""Nullable and left-recursion analysis for source grammar rules.""" + +from collections.abc import Iterable, Set +from typing import Any + +from pegen import sccutils +from pegen.grammar import ( + Alt, + Cut, + Forced, + Gather, + GrammarVisitor, + Group, + NamedItem, + NameLeaf, + Opt, + Repeat0, + Repeat1, + Rhs, + Rule, + StringLeaf, +) + + +class NullableVisitor(GrammarVisitor): + def __init__(self, rules: dict[str, Rule]) -> None: + self.rules = rules + self.visited: set[Any] = set() + self.nullables: set[Rule | NamedItem] = set() + + def visit(self, node: Any, *args: Any, **kwargs: Any) -> bool | None: + match node: + case Rule(rhs=rhs): + if node in self.visited: + return False + self.visited.add(node) + if self.visit(rhs): + self.nullables.add(node) + return node in self.nullables + case NamedItem(item=item): + if self.visit(item): + self.nullables.add(node) + return node in self.nullables + case Rhs(alts=alts): + return any(self.visit(alt) for alt in alts) + case Alt(items=items): + return all(self.visit(item) for item in items) + case Forced() | Opt() | Repeat0(): + return True + case Repeat1() | Gather() | Cut(): + return False + case Group(rhs=rhs): + return self.visit(rhs) + case NameLeaf(value=name): + if (rule := self.rules.get(name)) is not None: + return self.visit(rule) + # Token or unknown; never empty. + return False + case StringLeaf(value=value): + # The string token '' is considered empty. + return not value + case _: + return self.generic_visit(node, *args, **kwargs) + + +def compute_nullables(rules: dict[str, Rule]) -> set[Any]: + """Compute which rules in a grammar are nullable. + + Thanks to TatSu (tatsu/leftrec.py) for inspiration. + """ + nullable_visitor = NullableVisitor(rules) + for rule in rules.values(): + nullable_visitor.visit(rule) + return nullable_visitor.nullables + + +class InitialNamesVisitor(GrammarVisitor): + def __init__(self, rules: dict[str, Rule]) -> None: + self.rules = rules + self.nullables = compute_nullables(rules) + + def generic_visit(self, node: Iterable[Any], *args: Any, **kwargs: Any) -> set[Any]: + names: set[str] = set() + for value in node: + if isinstance(value, list): + for item in value: + names |= self.visit(item, *args, **kwargs) + else: + names |= self.visit(value, *args, **kwargs) + return names + + def visit(self, node: Any, *args: Any, **kwargs: Any) -> set[Any]: + match node: + case Alt(items=items): + names: set[str] = set() + for item in items: + names |= self.visit(item) + if item not in self.nullables: + break + return names + case Forced() | Cut() | StringLeaf(): + return set() + case NameLeaf(value=name): + return {name} + case _: + return self.generic_visit(node, *args, **kwargs) + + +def compute_left_recursives( + rules: dict[str, Rule] +) -> tuple[dict[str, Set[str]], list[Set[str]]]: + graph = make_first_graph(rules) + sccs = list(sccutils.strongly_connected_components(graph.keys(), graph)) + for scc in sccs: + if len(scc) > 1: + for name in scc: + rules[name].left_recursive = True + # Try to find a leader such that all cycles go through it. + leaders = set(scc) + for start in scc: + for cycle in sccutils.find_cycles_in_scc(graph, scc, start): + # print("Cycle:", " -> ".join(cycle)) + leaders -= scc - set(cycle) + if not leaders: + raise ValueError( + f"SCC {scc} has no leadership candidate (no element is included in all cycles)" + ) + # print("Leaders:", leaders) + leader = min(leaders) # Pick an arbitrary leader from the candidates. + rules[leader].leader = True + else: + name = min(scc) # The only element. + if name in graph[name]: + rules[name].left_recursive = True + rules[name].leader = True + return graph, sccs + + +def make_first_graph(rules: dict[str, Rule]) -> dict[str, Set[str]]: + """Compute the graph of left-invocations. + + There's an edge from A to B if A may invoke B at its initial + position. + + Note that this requires the nullable flags to have been computed. + """ + initial_name_visitor = InitialNamesVisitor(rules) + graph: dict[str, Set[str]] = {} + vertices: set[str] = set() + for rulename, rhs in rules.items(): + graph[rulename] = names = initial_name_visitor.visit(rhs) + vertices |= names + for vertex in vertices: + graph.setdefault(vertex, set()) + return graph diff --git a/Tools/peg_generator/pegen/grammar_parser.py b/Tools/peg_generator/pegen/grammar_parser.py index 4fa2739270773fe..a70de352944cc0f 100644 --- a/Tools/peg_generator/pegen/grammar_parser.py +++ b/Tools/peg_generator/pegen/grammar_parser.py @@ -235,8 +235,17 @@ def flags(self) -> Optional[frozenset [str]]: @memoize def flag(self) -> Optional[str]: - # flag: NAME + # flag: NAME '=' NAME | NAME mark = self._mark() + if ( + (a := self.name()) + and + (literal := self.expect('=')) + and + (b := self.name()) + ): + return a . string + "=" + b . string + self._reset(mark) if ( (name := self.name()) ): diff --git a/Tools/peg_generator/pegen/grammar_visualizer.py b/Tools/peg_generator/pegen/grammar_visualizer.py index eadb6987389b887..77a5bc7443d25b0 100644 --- a/Tools/peg_generator/pegen/grammar_visualizer.py +++ b/Tools/peg_generator/pegen/grammar_visualizer.py @@ -1,4 +1,5 @@ import argparse +import pathlib import sys from collections.abc import Callable, Iterator from typing import Any @@ -9,7 +10,7 @@ argparser = argparse.ArgumentParser( prog="pegen", description="Pretty print the AST for a given PEG grammar" ) -argparser.add_argument("filename", help="Grammar description") +argparser.add_argument("filename", type=pathlib.Path, help="Grammar description") class ASTGrammarPrinter: diff --git a/Tools/peg_generator/pegen/keywordgen.py b/Tools/peg_generator/pegen/keywordgen.py index 52611eae044e581..1ded1d3c39ce269 100644 --- a/Tools/peg_generator/pegen/keywordgen.py +++ b/Tools/peg_generator/pegen/keywordgen.py @@ -1,6 +1,7 @@ """Generate Lib/keyword.py from the Grammar and Tokens files using pgen""" import argparse +import pathlib from .build import build_parser, generate_token_definitions from .c_generator import CParserGenerator @@ -41,13 +42,14 @@ def main() -> None: description="Generate the Lib/keywords.py file from the grammar." ) parser.add_argument( - "grammar", help="The file with the grammar definition in PEG format" + "grammar", type=pathlib.Path, help="The file with the grammar definition in PEG format" ) parser.add_argument( - "tokens_file", help="The file with the token definitions" + "tokens_file", type=pathlib.Path, help="The file with the token definitions" ) parser.add_argument( "keyword_file", + type=pathlib.Path, help="The path to write the keyword definitions", ) args = parser.parse_args() diff --git a/Tools/peg_generator/pegen/metagrammar.gram b/Tools/peg_generator/pegen/metagrammar.gram index cae91ab9c4165bb..93864a2b43fe206 100644 --- a/Tools/peg_generator/pegen/metagrammar.gram +++ b/Tools/peg_generator/pegen/metagrammar.gram @@ -64,6 +64,7 @@ flags[frozenset[str]]: | '(' a=','.flag+ ')' { frozenset(a) } flag[str]: + | a=NAME '=' b=NAME { a.string + "=" + b.string } | NAME { name.string } alts[Rhs]: diff --git a/Tools/peg_generator/pegen/parser_generator.py b/Tools/peg_generator/pegen/parser_generator.py index 81314b0cc073f9c..b603b6f837b8e92 100644 --- a/Tools/peg_generator/pegen/parser_generator.py +++ b/Tools/peg_generator/pegen/parser_generator.py @@ -1,32 +1,41 @@ import ast import contextlib +import pathlib import re import sys from abc import abstractmethod -from collections.abc import Iterable, Iterator, Set -from typing import IO, Any +from collections.abc import Generator +from typing import IO -from pegen import sccutils from pegen.grammar import ( Alt, - Cut, - Forced, Gather, Grammar, GrammarError, GrammarVisitor, - Group, - Lookahead, NamedItem, NameLeaf, - Opt, Plain, - Repeat0, - Repeat1, Rhs, Rule, + RuleKind, StringLeaf, ) +from pegen.grammar_analysis import ( + InitialNamesVisitor as InitialNamesVisitor, +) +from pegen.grammar_analysis import ( + NullableVisitor as NullableVisitor, +) +from pegen.grammar_analysis import ( + compute_left_recursives as compute_left_recursives, +) +from pegen.grammar_analysis import ( + compute_nullables as compute_nullables, +) +from pegen.grammar_analysis import ( + make_first_graph as make_first_graph, +) class RuleCollectorVisitor(GrammarVisitor): @@ -53,8 +62,9 @@ def __init__(self, gen: "ParserGenerator", keywords: dict[str, int], soft_keywor def visit_StringLeaf(self, node: StringLeaf) -> None: val = ast.literal_eval(node.value) if re.match(r"[a-zA-Z_]\w*\Z", val): # This is a keyword - if node.value.endswith("'") and node.value not in self.keywords: - self.keywords[val] = self.generator.keyword_type() + if node.value.endswith("'"): + if val not in self.keywords: + self.keywords[val] = self.generator.keyword_type() else: return self.soft_keywords.add(node.value.replace('"', "")) @@ -93,12 +103,7 @@ def __init__(self, grammar: Grammar, tokens: set[str], file: IO[str] | None): self.keywords: dict[str, int] = {} self.soft_keywords: set[str] = set() self.rules = grammar.rules - self.validate_rule_names() - if "trailer" not in grammar.metas and "start" not in self.rules: - raise GrammarError("Grammar without a trailer must have a 'start' rule") - checker = RuleCheckingVisitor(self.rules, self.tokens) - for rule in self.rules.values(): - checker.visit(rule) + self._validate_grammar() self.file = file self.level = 0 self.first_graph, self.first_sccs = compute_left_recursives(self.rules) @@ -107,13 +112,31 @@ def __init__(self, grammar: Grammar, tokens: set[str], file: IO[str] | None): self.all_rules: dict[str, Rule] = self.rules.copy() # Rules + temporal rules self._local_variable_stack: list[list[str]] = [] + # Source of the rule being visited; artificial rules created for it + # belong to the same grammar file. + self.current_source: pathlib.Path | None = None + + def _validate_grammar(self) -> None: + if self.grammar.includes: + raise GrammarError( + f"Unresolved @include of {', '.join(map(repr, self.grammar.includes))}; " + "load the grammar with pegen.build.build_parser() or call " + "pegen.build.resolve_includes() on it" + ) + self.validate_rule_names() + if "trailer" not in self.grammar.metas and "start" not in self.rules: + raise GrammarError("Grammar without a trailer must have a 'start' rule") + checker = RuleCheckingVisitor(self.rules, self.tokens) + for rule in self.rules.values(): + checker.visit(rule) + def validate_rule_names(self) -> None: for rule in self.rules: if rule.startswith("_"): raise GrammarError(f"Rule names cannot start with underscore: '{rule}'") @contextlib.contextmanager - def local_variable_context(self) -> Iterator[None]: + def local_variable_context(self) -> Generator[None]: self._local_variable_stack.append([]) yield self._local_variable_stack.pop() @@ -123,17 +146,26 @@ def local_variable_names(self) -> list[str]: return self._local_variable_stack[-1] @abstractmethod - def generate(self, filename: str) -> None: + def generate(self, filename: pathlib.PurePath) -> None: raise NotImplementedError @contextlib.contextmanager - def indent(self) -> Iterator[None]: + def indent(self) -> Generator[None]: self.level += 1 try: yield finally: self.level -= 1 + @contextlib.contextmanager + def current_source_context(self, current_source: pathlib.Path | None) -> Generator[None]: + previous = self.current_source + self.current_source = current_source + try: + yield + finally: + self.current_source = previous + def print(self, *args: object) -> None: if not args: print(file=self.file) @@ -159,7 +191,9 @@ def collect_rules(self) -> None: break done = set(self.all_rules) for rulename in todo: - rule_collector.visit(self.all_rules[rulename]) + rule = self.all_rules[rulename] + with self.current_source_context(rule.source): + rule_collector.visit(rule) def keyword_type(self) -> int: self.keyword_counter += 1 @@ -168,17 +202,19 @@ def keyword_type(self) -> int: def artificial_rule_from_rhs(self, rhs: Rhs) -> str: self.counter += 1 name = f"_tmp_{self.counter}" # TODO: Pick a nicer name. - self.all_rules[name] = Rule(name, None, rhs) + self._add_artificial_rule(name, rhs) return name def artificial_rule_from_repeat(self, node: Plain, is_repeat1: bool) -> str: self.counter += 1 if is_repeat1: prefix = "_loop1_" + kind = RuleKind.LOOP1 else: prefix = "_loop0_" + kind = RuleKind.LOOP0 name = f"{prefix}{self.counter}" - self.all_rules[name] = Rule(name, None, Rhs([Alt([NamedItem(None, node)])])) + self._add_artificial_rule(name, Rhs([Alt([NamedItem(None, node)])]), kind) return name def artificial_rule_from_gather(self, node: Gather) -> str: @@ -188,23 +224,18 @@ def artificial_rule_from_gather(self, node: Gather) -> str: [NamedItem(None, node.separator), NamedItem("elem", node.node)], action="elem", ) - self.all_rules[extra_function_name] = Rule( - extra_function_name, - None, - Rhs([extra_function_alt]), - ) + self._add_artificial_rule(extra_function_name, Rhs([extra_function_alt]), RuleKind.LOOP0) self.counter += 1 name = f"_gather_{self.counter}" alt = Alt( [NamedItem("elem", node.node), NamedItem("seq", NameLeaf(extra_function_name))], ) - self.all_rules[name] = Rule( - name, - None, - Rhs([alt]), - ) + self._add_artificial_rule(name, Rhs([alt]), RuleKind.GATHER) return name + def _add_artificial_rule(self, name: str, rhs: Rhs, kind: RuleKind = RuleKind.NORMAL) -> None: + self.all_rules[name] = Rule(name, None, rhs, kind=kind, source=self.current_source) + def dedupe(self, name: str) -> str: origname = name counter = 0 @@ -213,168 +244,3 @@ def dedupe(self, name: str) -> str: name = f"{origname}_{counter}" self.local_variable_names.append(name) return name - - -class NullableVisitor(GrammarVisitor): - def __init__(self, rules: dict[str, Rule]) -> None: - self.rules = rules - self.visited: set[Any] = set() - self.nullables: set[Rule | NamedItem] = set() - - def visit_Rule(self, rule: Rule) -> bool: - if rule in self.visited: - return False - self.visited.add(rule) - if self.visit(rule.rhs): - self.nullables.add(rule) - return rule in self.nullables - - def visit_Rhs(self, rhs: Rhs) -> bool: - for alt in rhs.alts: - if self.visit(alt): - return True - return False - - def visit_Alt(self, alt: Alt) -> bool: - for item in alt.items: - if not self.visit(item): - return False - return True - - def visit_Forced(self, force: Forced) -> bool: - return True - - def visit_LookAhead(self, lookahead: Lookahead) -> bool: - return True - - def visit_Opt(self, opt: Opt) -> bool: - return True - - def visit_Repeat0(self, repeat: Repeat0) -> bool: - return True - - def visit_Repeat1(self, repeat: Repeat1) -> bool: - return False - - def visit_Gather(self, gather: Gather) -> bool: - return False - - def visit_Cut(self, cut: Cut) -> bool: - return False - - def visit_Group(self, group: Group) -> bool: - return self.visit(group.rhs) - - def visit_NamedItem(self, item: NamedItem) -> bool: - if self.visit(item.item): - self.nullables.add(item) - return item in self.nullables - - def visit_NameLeaf(self, node: NameLeaf) -> bool: - if node.value in self.rules: - return self.visit(self.rules[node.value]) - # Token or unknown; never empty. - return False - - def visit_StringLeaf(self, node: StringLeaf) -> bool: - # The string token '' is considered empty. - return not node.value - - -def compute_nullables(rules: dict[str, Rule]) -> set[Any]: - """Compute which rules in a grammar are nullable. - - Thanks to TatSu (tatsu/leftrec.py) for inspiration. - """ - nullable_visitor = NullableVisitor(rules) - for rule in rules.values(): - nullable_visitor.visit(rule) - return nullable_visitor.nullables - - -class InitialNamesVisitor(GrammarVisitor): - def __init__(self, rules: dict[str, Rule]) -> None: - self.rules = rules - self.nullables = compute_nullables(rules) - - def generic_visit(self, node: Iterable[Any], *args: Any, **kwargs: Any) -> set[Any]: - names: set[str] = set() - for value in node: - if isinstance(value, list): - for item in value: - names |= self.visit(item, *args, **kwargs) - else: - names |= self.visit(value, *args, **kwargs) - return names - - def visit_Alt(self, alt: Alt) -> set[Any]: - names: set[str] = set() - for item in alt.items: - names |= self.visit(item) - if item not in self.nullables: - break - return names - - def visit_Forced(self, force: Forced) -> set[Any]: - return set() - - def visit_LookAhead(self, lookahead: Lookahead) -> set[Any]: - return set() - - def visit_Cut(self, cut: Cut) -> set[Any]: - return set() - - def visit_NameLeaf(self, node: NameLeaf) -> set[Any]: - return {node.value} - - def visit_StringLeaf(self, node: StringLeaf) -> set[Any]: - return set() - - -def compute_left_recursives( - rules: dict[str, Rule] -) -> tuple[dict[str, Set[str]], list[Set[str]]]: - graph = make_first_graph(rules) - sccs = list(sccutils.strongly_connected_components(graph.keys(), graph)) - for scc in sccs: - if len(scc) > 1: - for name in scc: - rules[name].left_recursive = True - # Try to find a leader such that all cycles go through it. - leaders = set(scc) - for start in scc: - for cycle in sccutils.find_cycles_in_scc(graph, scc, start): - # print("Cycle:", " -> ".join(cycle)) - leaders -= scc - set(cycle) - if not leaders: - raise ValueError( - f"SCC {scc} has no leadership candidate (no element is included in all cycles)" - ) - # print("Leaders:", leaders) - leader = min(leaders) # Pick an arbitrary leader from the candidates. - rules[leader].leader = True - else: - name = min(scc) # The only element. - if name in graph[name]: - rules[name].left_recursive = True - rules[name].leader = True - return graph, sccs - - -def make_first_graph(rules: dict[str, Rule]) -> dict[str, Set[str]]: - """Compute the graph of left-invocations. - - There's an edge from A to B if A may invoke B at its initial - position. - - Note that this requires the nullable flags to have been computed. - """ - initial_name_visitor = InitialNamesVisitor(rules) - graph = {} - vertices: set[str] = set() - for rulename, rhs in rules.items(): - graph[rulename] = names = initial_name_visitor.visit(rhs) - vertices |= names - for vertex in vertices: - graph.setdefault(vertex, set()) - return graph diff --git a/Tools/peg_generator/pegen/python_generator.py b/Tools/peg_generator/pegen/python_generator.py index e69ea4b5f4e14c4..cf3eb8692544719 100644 --- a/Tools/peg_generator/pegen/python_generator.py +++ b/Tools/peg_generator/pegen/python_generator.py @@ -1,4 +1,4 @@ -import os.path +import pathlib import token from collections.abc import Callable, Sequence from typing import IO, Any @@ -232,12 +232,11 @@ def __init__( "end_lineno=end_lineno, end_col_offset=end_col_offset" ) - def generate(self, filename: str) -> None: + def generate(self, filename: pathlib.PurePath) -> None: self.collect_rules() header = self.grammar.metas.get("header", MODULE_PREFIX) if header is not None: - basename = os.path.basename(filename) - self.print(header.rstrip("\n").format(filename=basename)) + self.print(header.rstrip("\n").format(filename=filename.name)) subheader = self.grammar.metas.get("subheader", "") if subheader: self.print(subheader) diff --git a/Tools/peg_generator/pegen/testutil.py b/Tools/peg_generator/pegen/testutil.py index 46f6c7fec1bda05..b5d05beb251b944 100644 --- a/Tools/peg_generator/pegen/testutil.py +++ b/Tools/peg_generator/pegen/testutil.py @@ -1,14 +1,19 @@ +import contextlib import importlib.util import io import os -import pathlib import sys import textwrap import token import tokenize +from pathlib import Path, PurePath from typing import IO, Any, Final, cast -from pegen.build import compile_c_extension +from pegen.build import ( + compile_c_extension, + included_output_files, + resolve_includes, +) from pegen.c_generator import CParserGenerator from pegen.grammar import Grammar from pegen.grammar_parser import GeneratedParser as GrammarParser @@ -27,7 +32,7 @@ def generate_parser(grammar: Grammar) -> type[Parser]: # Generate a parser. out = io.StringIO() genr = PythonParserGenerator(grammar, out) - genr.generate("") + genr.generate(PurePath("")) # Load the generated parser class. ns: dict[str, Any] = {} @@ -46,13 +51,22 @@ def run_parser(file: IO[bytes], parser_class: type[Parser], *, verbose: bool = F def parse_string( - source: str, parser_class: type[Parser], *, dedent: bool = True, verbose: bool = False + source: str, + parser_class: type[Parser], + *, + dedent: bool = True, + verbose: bool = False, + base_dir: Path | None = None, ) -> Any: - # Run the parser on a string. + # Run the parser on a string. A grammar's @include paths are relative + # to *base_dir* (the current directory by default). if dedent: source = textwrap.dedent(source) file = io.StringIO(source) - return run_parser(file, parser_class, verbose=verbose) # type: ignore[arg-type] # typeshed issue #3515 + result = run_parser(file, parser_class, verbose=verbose) # type: ignore[arg-type] # typeshed issue #3515 + if isinstance(result, Grammar): + resolve_includes(result, (base_dir or Path.cwd()) / "") + return result def make_parser(source: str) -> type[Parser]: @@ -78,13 +92,13 @@ def import_file(full_name: str, path: str) -> Any: def generate_c_parser_source(grammar: Grammar) -> str: out = io.StringIO() genr = CParserGenerator(grammar, ALL_TOKENS, EXACT_TOKENS, NON_EXACT_TOKENS, out) - genr.generate("") + genr.generate(PurePath("")) return out.getvalue() def generate_parser_c_extension( grammar: Grammar, - path: pathlib.PurePath, + path: Path, debug: bool = False, library_dir: str | None = None, ) -> Any: @@ -99,17 +113,32 @@ def generate_parser_c_extension( # context. assert not os.listdir(path) source = path / "parse.c" - with open(source, "w", encoding="utf-8") as file: + included_outputs = included_output_files(grammar, source) + with contextlib.ExitStack() as stack: + file = stack.enter_context(open(source, "w", encoding="utf-8")) + for output in included_outputs.values(): + output.parent.mkdir(parents=True, exist_ok=True) + included_files: dict[Path, IO[str]] = { + include: stack.enter_context(open(output, "w", encoding="utf-8")) + for include, output in included_outputs.items() + } genr = CParserGenerator( - grammar, ALL_TOKENS, EXACT_TOKENS, NON_EXACT_TOKENS, file, debug=debug + grammar, + ALL_TOKENS, + EXACT_TOKENS, + NON_EXACT_TOKENS, + file, + debug=debug, + included_files=included_files, ) - genr.generate("parse.c") + genr.generate(PurePath("parse.c")) compile_c_extension( - str(source), + source, build_dir=str(path), # Significant test_peg_generator speedups disable_optimization=True, library_dir=library_dir, + extra_generated_sources=list(included_outputs.values()), ) diff --git a/Tools/requirements-dev.txt b/Tools/requirements-dev.txt index 46381ea58a12382..06f4d61e11135e5 100644 --- a/Tools/requirements-dev.txt +++ b/Tools/requirements-dev.txt @@ -1,7 +1,7 @@ # Requirements file for external linters and checks we run on # Tools/clinic, Tools/cases_generator/, and Tools/peg_generator/ in CI -mypy==2.1.0 +mypy==2.4.0 # needed for peg_generator: -types-psutil==7.2.2.20260508 -types-setuptools==82.0.0.20260508 +types-psutil==7.2.2.20260906 +types-setuptools==84.0.0.20261006 diff --git a/Tools/requirements-hypothesis.txt b/Tools/requirements-hypothesis.txt index aff7e3b0e224b9c..7ee849530c3fe60 100644 --- a/Tools/requirements-hypothesis.txt +++ b/Tools/requirements-hypothesis.txt @@ -1,4 +1,4 @@ # Requirements file for hypothesis that # we use to run our property-based tests in CI. -hypothesis==6.155.3 +hypothesis==6.168.3 diff --git a/Tools/ssl/multissltests.py b/Tools/ssl/multissltests.py index d5e38993d971dfe..8f01246150bd340 100755 --- a/Tools/ssl/multissltests.py +++ b/Tools/ssl/multissltests.py @@ -44,17 +44,17 @@ OPENSSL_OLD_VERSIONS = [ "1.1.1w", + "3.0.22", "3.1.8", "3.2.6", "3.3.7", ] OPENSSL_RECENT_VERSIONS = [ - "3.0.21", - "3.4.6", - "3.5.7", - "3.6.3", - "4.0.1", + "3.4.8", + "3.5.9", + "3.6.5", + "4.0.3", # See make_ssl_data.py for notes on adding a new version. ] @@ -65,7 +65,7 @@ ] AWSLC_RECENT_VERSIONS = [ - "5.0.0", + "5.10.0", ] # store files in ../multissl diff --git a/Tools/unicode/makeunicodedata.py b/Tools/unicode/makeunicodedata.py index b91bc539616f41e..bba652ef89d61f3 100644 --- a/Tools/unicode/makeunicodedata.py +++ b/Tools/unicode/makeunicodedata.py @@ -28,6 +28,7 @@ import dataclasses import os +import subprocess import sys import re import zipfile @@ -39,16 +40,19 @@ SCRIPT = os.path.normpath(sys.argv[0]) VERSION = "3.3" +# Local cache location +DATA_DIR = os.path.join('Tools', 'unicode', 'data') + # The Unicode Database # -------------------- # When changing UCD version please update -# * Doc/library/stdtypes.rst (four occurrences) +# * Doc/builtins/stdtypes.rst (four occurrences) # * Doc/library/unicodedata.rst # * Doc/library/re.rst # * Doc/reference/lexical_analysis.rst (three occurrences) # and optionally (comments) # * Lib/re/_properties.py (three occurrences) -UNIDATA_VERSION = "17.0.0" +UNIDATA_VERSION = "18.0.0" UNICODE_DATA = "UnicodeData%s.txt" COMPOSITION_EXCLUSIONS = "CompositionExclusions%s.txt" EASTASIAN_WIDTH = "EastAsianWidth%s.txt" @@ -149,6 +153,8 @@ ("Hangul Syllable", "HANGUL SYLLABLE "), ("CJK Ideograph", "CJK UNIFIED IDEOGRAPH-"), ("Tangut Ideograph", "TANGUT IDEOGRAPH-"), + ("Jurchen Character", "JURCHEN CHARACTER-"), + ("Seal Character", "SMALL SEAL CHARACTER-"), ] @@ -169,6 +175,7 @@ def maketables(trace=0): makeunicodename(unicode, trace) makeunicodedata(unicode, trace) makeunicodetype(unicode, trace) + makestringprep() # -------------------------------------------------------------------- @@ -810,6 +817,40 @@ def makeunicodename(unicode, trace): fprint(' "%s",' % prefix) fprint('};') + +def makestringprep(): + FILE = "Lib/stringprep.py" + + RFC_LOCAL = os.path.join(DATA_DIR, "rfc3454.txt") + RFC_URL = "https://www.rfc-editor.org/rfc/rfc3454.txt" + + print("--- Preparing", FILE, "...") + + # mkstringprep expects a local copy of RFC 3454. Download it now. + # (stringprep is used for URL handling, and if it's not matched + # with the compiled unicodedata, downloads would fail.) + if not os.path.exists(RFC_LOCAL): + download_data(RFC_LOCAL, RFC_URL) + + MKSTRINGPREP = "Tools/unicode/mkstringprep.py" + + # mkstringprep needs to be run with a Python version that has "its" + # unicode data, since it uses str.lower() and similar. + import unicodedata + if unicodedata.unidata_version != UNIDATA_VERSION: + print() + print("!! Skipping mkstringprep -- mismatched Unicode version !!") + print() + print("Please compile CPython with the updated Unicode database,") + print("then use that interpreter to run:") + print(f" python {MKSTRINGPREP} > {FILE}") + return + + with open(FILE, "w") as f: + f.truncate() + subprocess.check_call([sys.executable, MKSTRINGPREP], stdout=f) + + def merge_old_version(version, new, old): # Changes to exclusion file not implemented yet if old.exclusions != new.exclusions: @@ -831,6 +872,10 @@ def merge_old_version(version, new, old): # Characters unassigned in the new version ought to # be unassigned in the old one assert old.table[i] is None + # Without a change record the old view would fall + # through to the new default, so record the old value + if old.bidi_classes[i] != new.bidi_classes[i]: + bidir_changes[i] = BIDIRECTIONAL_NAMES.index(old.bidi_classes[i] or '') continue # check characters unassigned in the old version if old.table[i] is None: @@ -910,19 +955,15 @@ class Difference(Exception):pass normalization_changes)) -DATA_DIR = os.path.join('Tools', 'unicode', 'data') - def open_data(template, version): local = os.path.join(DATA_DIR, template % ('-'+version,)) if not os.path.exists(local): - import urllib.request if version == '3.2.0': # irregular url structure url = ('https://www.unicode.org/Public/3.2-Update/'+template) % ('-'+version,) else: url = ('https://www.unicode.org/Public/%s/ucd/'+template) % (version, '') - os.makedirs(os.path.dirname(local), exist_ok=True) - urllib.request.urlretrieve(url, filename=local) + download_data(local, url) if local.endswith('.txt'): return open(local, encoding='utf-8') else: @@ -930,6 +971,13 @@ def open_data(template, version): return open(local, 'rb') +def download_data(local, url): + import urllib.request + os.makedirs(os.path.dirname(local), exist_ok=True) + print(f'Downloading {url} to {local}') + urllib.request.urlretrieve(url, filename=local) + + def expand_range(char_range: str) -> Iterator[int]: ''' Parses ranges of code points, as described in UAX #44: diff --git a/Tools/unicode/mkstringprep.py b/Tools/unicode/mkstringprep.py index 427188389a3b87c..60052aae3b62983 100644 --- a/Tools/unicode/mkstringprep.py +++ b/Tools/unicode/mkstringprep.py @@ -1,15 +1,16 @@ import re -from unicodedata import ucd_3_2_0 as unicodedata +import unicodedata as unicodedata_current +from unicodedata import ucd_3_2_0 as unicodedata_320 def gen_category(cats): for i in range(0, 0x110000): - if unicodedata.category(chr(i)) in cats: - yield(i) + if unicodedata_320.category(chr(i)) in cats: + yield i def gen_bidirectional(cats): for i in range(0, 0x110000): - if unicodedata.bidirectional(chr(i)) in cats: - yield(i) + if unicodedata_320.bidirectional(chr(i)) in cats: + yield i def compact_set(l): single = [] @@ -47,8 +48,8 @@ def compact_set(l): ############## Read the tables in the RFC ####################### -with open("rfc3454.txt") as f: - data = f.readlines() +with open("Tools/unicode/data/rfc3454.txt", encoding='utf-8') as data_file: + data = data_file.readlines() tables = [] curname = None @@ -116,10 +117,18 @@ def compact_set(l): and mappings, for which a mapping function is provided. \"\"\" -from unicodedata import ucd_3_2_0 as unicodedata +# This check asserts that mkstringprep.py has been run +# when unicodedata is modified to ensure conformant behavior. +import unicodedata """) -print("assert unicodedata.unidata_version == %r" % (unicodedata.unidata_version,)) +print("assert unicodedata.unidata_version == %r" % (unicodedata_current.unidata_version,)) + +print(""" +from unicodedata import ucd_3_2_0 as unicodedata_320 +""") + +print("assert unicodedata_320.unidata_version == %r" % (unicodedata_320.unidata_version,)) # A.1 is the table of unassigned characters # XXX Plane 15 PUA is listed as unassigned in Python. @@ -139,7 +148,7 @@ def compact_set(l): print(""" def in_table_a1(code): - if unicodedata.category(code) != 'Cn': return False + if unicodedata_320.category(code) != 'Cn': return False c = ord(code) if 0xFDD0 <= c < 0xFDF0: return False return (c & 0xFFFF) not in (0xFFFE, 0xFFFF) @@ -172,21 +181,33 @@ def in_table_b1(code): # B.3 is mostly Python's .lower, except for a number # of special cases, e.g. considering canonical forms. +# To enforce Unicode 3.2.0 behavior of .lower instead of +# whatever Unicode version is included with Python we +# add unassigned or newly case-folding codepoints to +# the exception map, too. b3_exceptions = {} for k,v in table_b2.items(): if list(map(ord, chr(k).lower())) != v: b3_exceptions[k] = "".join(map(chr,v)) +for cp in range(0x110000): + ch = chr(cp) + # Assigned in current Unicode version + # and supports case folding, but not + # explicitly in B.2 or B.3 tables. + if (unicodedata_current.category(ch) != "Cn" + and ch.lower() != ch + and cp not in table_b2 + and cp not in table_b3): + b3_exceptions[cp] = ch # Identity. b3 = sorted(b3_exceptions.items()) print(""" b3_exceptions = {""") for i, kv in enumerate(b3): - print("0x%x:%a," % kv, end=' ') - if i % 4 == 3: - print() + print("0x%x:%a," % kv, end='\n' if i % 4 == 3 else ' ') print("}") print(""" @@ -207,9 +228,9 @@ def map_table_b3(code): def map_table_b2(a): al = map_table_b3(a) - b = unicodedata.normalize("NFKC", al) + b = unicodedata_320.normalize("NFKC", al) bl = "".join([map_table_b3(ch) for ch in b]) - c = unicodedata.normalize("NFKC", bl) + c = unicodedata_320.normalize("NFKC", bl) if b != c: return c else: @@ -226,9 +247,9 @@ def map_table_b2(a): print(""" def map_table_b2(a): al = map_table_b3(a) - b = unicodedata.normalize("NFKC", al) + b = unicodedata_320.normalize("NFKC", al) bl = "".join([map_table_b3(ch) for ch in b]) - c = unicodedata.normalize("NFKC", bl) + c = unicodedata_320.normalize("NFKC", bl) if b != c: return c else: @@ -251,16 +272,16 @@ def in_table_c11(code): del tables[0] assert name == "C.1.2" -# table = set(table.keys()) -# Zs = set(gen_category(["Zs"])) - {0x20} -# assert Zs == table +table = set(table.keys()) +Zs = set(gen_category(["Zs"])) - {0x20} +assert Zs == table print(""" def in_table_c12(code): - return unicodedata.category(code) == "Zs" and code != " " + return unicodedata_320.category(code) == "Zs" and code != " " def in_table_c11_c12(code): - return unicodedata.category(code) == "Zs" + return unicodedata_320.category(code) == "Zs" """) # C.2.1 ASCII control characters @@ -275,7 +296,7 @@ def in_table_c11_c12(code): print(""" def in_table_c21(code): - return ord(code) < 128 and unicodedata.category(code) == "Cc" + return ord(code) < 128 and unicodedata_320.category(code) == "Cc" """) # C.2.2 Non-ASCII control characters. It also includes @@ -295,11 +316,11 @@ def in_table_c21(code): def in_table_c22(code): c = ord(code) if c < 128: return False - if unicodedata.category(code) == "Cc": return True + if unicodedata_320.category(code) == "Cc": return True return c in c22_specials def in_table_c21_c22(code): - return unicodedata.category(code) == "Cc" or \\ + return unicodedata_320.category(code) == "Cc" or \\ ord(code) in c22_specials """) @@ -313,7 +334,7 @@ def in_table_c21_c22(code): print(""" def in_table_c3(code): - return unicodedata.category(code) == "Co" + return unicodedata_320.category(code) == "Co" """) # C.4 Non-character code points, xFFFE, xFFFF @@ -346,7 +367,7 @@ def in_table_c4(code): print(""" def in_table_c5(code): - return unicodedata.category(code) == "Cs" + return unicodedata_320.category(code) == "Cs" """) # C.6 Inappropriate for plain text @@ -411,7 +432,7 @@ def in_table_c9(code): print(""" def in_table_d1(code): - return unicodedata.bidirectional(code) in ("R","AL") + return unicodedata_320.bidirectional(code) in ("R","AL") """) # D.2 Characters with bidirectional property "L" @@ -424,5 +445,5 @@ def in_table_d1(code): print(""" def in_table_d2(code): - return unicodedata.bidirectional(code) == "L" -""") + return unicodedata_320.bidirectional(code) == "L" +""", end="") diff --git a/config.sub b/config.sub index 1bb6a05dc11026c..49febd56a37cc00 100755 --- a/config.sub +++ b/config.sub @@ -1743,7 +1743,7 @@ case $os in | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ | hiux* | abug | nacl* | netware* | windows* \ - | os9* | macos* | osx* | ios* | tvos* | watchos* \ + | os9* | macos* | osx* | ios* | tvos* | watchos* | xros* \ | mpw* | magic* | mmixware* | mon960* | lnews* \ | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ | aos* | aros* | cloudabi* | sortix* | twizzler* \ @@ -1867,7 +1867,7 @@ case $kernel-$os-$obj in ;; *-eabi*- | *-gnueabi*-) ;; - ios*-simulator- | tvos*-simulator- | watchos*-simulator- ) + ios*-simulator- | tvos*-simulator- | watchos*-simulator- | xros*-simulator-) ;; none--*) # None (no kernel, i.e. freestanding / bare metal), diff --git a/configure b/configure index c8494891087d045..da44380d27a1ab0 100755 --- a/configure +++ b/configure @@ -642,7 +642,6 @@ ac_includes_default="\ #endif" ac_header_c_list= -ac_func_c_list= ac_subst_vars='LTLIBOBJS MODULE_BLOCK JIT_SHIM_BUILD_O @@ -879,6 +878,7 @@ TRUE MACHDEP_OBJS DYNLOADFILE DLINCLDIR +PLATFORM_MAIN_OBJS PLATFORM_OBJS PLATFORM_HEADERS DTRACE_OBJS @@ -938,6 +938,7 @@ LLVM_PROF_FOUND LLVM_PROFDATA LLVM_PROF_ERR LLVM_PROF_FILE +LLVM_PROF_SHOW LLVM_PROF_MERGER PGO_PROF_USE_FLAG PGO_PROF_GEN_FLAG @@ -995,6 +996,10 @@ LDFLAGS CFLAGS CC HAS_XCRUN +EXPORT_XROS_DEPLOYMENT_TARGET +WATCHOS_DEPLOYMENT_TARGET +XROS_DEPLOYMENT_TARGET +TVOS_DEPLOYMENT_TARGET IPHONEOS_DEPLOYMENT_TARGET EXPORT_MACOSX_DEPLOYMENT_TARGET CONFIGURE_MACOSX_DEPLOYMENT_TARGET @@ -1030,12 +1035,14 @@ CONFIG_ARGS SOVERSION VERSION PYTHON_FOR_REGEN +RUNSHARED_FOR_BUILD PYTHON_FOR_BUILD_DEPS FREEZE_MODULE_DEPS FREEZE_MODULE FREEZE_MODULE_BOOTSTRAP_DEPS FREEZE_MODULE_BOOTSTRAP PYTHON_FOR_FREEZE +MODULE_CHECK_COMMAND PYTHON_FOR_BUILD host_os host_vendor @@ -1102,6 +1109,7 @@ enable_framework with_app_store_compliance enable_wasm_dynamic_linking enable_wasm_pthreads +enable_emscripten_syscalls with_suffix enable_shared with_static_libpython @@ -1122,6 +1130,7 @@ with_frame_pointers enable_experimental_jit with_dsymutil with_address_sanitizer +with_hwaddress_sanitizer with_memory_sanitizer with_undefined_behavior_sanitizer with_thread_sanitizer @@ -1141,12 +1150,15 @@ with_c_locale_coercion with_valgrind with_dtrace enable_epoll +with_zlib +with_bzip2 with_libm with_libc enable_big_digits with_platlibdir with_wheel_pkg_dir with_readline +with_curses with_computed_gotos with_tail_call_interp with_remote_debug @@ -1171,6 +1183,7 @@ LDFLAGS LIBS CPPFLAGS CPP +CXX PROFILE_TASK BOLT_COMMON_FLAGS BOLT_INSTRUMENT_FLAGS @@ -1842,6 +1855,10 @@ Optional Features: loader to handle imports --enable-wasm-pthreads Enable pthread emulation for WebAssembly (default is no) + --disable-emscripten-syscalls + Disable the Emscripten syscall overrides in + Python/emscripten_syscalls.c (default is enabled for + Emscripten) --enable-shared enable building a shared Python library (default is no) --enable-static-libpython-for-interpreter @@ -1923,6 +1940,9 @@ Optional Packages: --with-address-sanitizer enable AddressSanitizer memory error detector, 'asan' (default is no) + --with-hwaddress-sanitizer + enable HWAddressSanitizer memory error detector, + 'hwasan' (default is no) --with-memory-sanitizer enable MemorySanitizer allocation error detector, 'msan' (default is no) --with-undefined-behavior-sanitizer @@ -1958,6 +1978,12 @@ Optional Packages: (default is yes) --with-valgrind enable Valgrind support (default is no) --with-dtrace enable DTrace support (default is no) + --with(out)-zlib[=zlib|zlib-ng|zlib-rs|no] + select the zlib implementation to link against, or + disable zlib support (default: auto) + --with(out)-bzip2[=bzip2|bzip2-rs|no] + select the bzip2 implementation to link against, or + disable bzip2 support (default: auto) --with-libm=STRING override libm math library to STRING (default is system-dependent) --with-libc=STRING override libc C library to STRING (default is @@ -1969,6 +1995,10 @@ Optional Packages: (default: none) --with(out)-readline[=editline|readline|no] use libedit for backend or disable readline module + --with(out)-curses[=ncursesw|ncurses|curses|no] + select the curses backend for the curses and + _curses_panel modules, or disable them (default: + auto) --with-computed-gotos enable computed gotos in evaluation loop (enabled by default on supported compilers) --with-tail-call-interp enable tail-calling interpreter in evaluation loop @@ -2012,6 +2042,7 @@ Some influential environment variables: CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor + CXX C++ compiler command PROFILE_TASK Python args for PGO generation task BOLT_COMMON_FLAGS @@ -3422,13 +3453,6 @@ as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H" as_fn_append ac_header_c_list " wchar.h wchar_h HAVE_WCHAR_H" as_fn_append ac_header_c_list " minix/config.h minix_config_h HAVE_MINIX_CONFIG_H" -as_fn_append ac_func_c_list " acospi HAVE_ACOSPI" -as_fn_append ac_func_c_list " asinpi HAVE_ASINPI" -as_fn_append ac_func_c_list " atanpi HAVE_ATANPI" -as_fn_append ac_func_c_list " atan2pi HAVE_ATAN2PI" -as_fn_append ac_func_c_list " cospi HAVE_COSPI" -as_fn_append ac_func_c_list " sinpi HAVE_SINPI" -as_fn_append ac_func_c_list " tanpi HAVE_TANPI" # Auxiliary files required by this configure script. ac_aux_files="install-sh config.guess config.sub" @@ -3607,6 +3631,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$srcdir" != . -a "$srcdir" != "$(pwd)"; then # If we're building out-of-tree, we need to make sure the following # resources get picked up before their $srcdir counterparts. @@ -3676,9 +3702,9 @@ HAS_GIT=no-repository fi if test $HAS_GIT = found then - GITVERSION="git --git-dir \$(srcdir)/.git rev-parse --short HEAD" - GITTAG="git --git-dir \$(srcdir)/.git describe --all --always --dirty" - GITBRANCH="git --git-dir \$(srcdir)/.git name-rev --name-only HEAD" + GITVERSION="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) rev-parse --short HEAD" + GITTAG="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) describe --all --always --dirty" + GITBRANCH="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) name-rev --name-only HEAD" else GITVERSION="" GITTAG="" @@ -3805,7 +3831,12 @@ fi fi ac_cv_prog_PYTHON_FOR_REGEN=$with_build_python PYTHON_FOR_FREEZE="$with_build_python" - PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) _PYTHON_SYSCONFIGDATA_PATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`) '$with_build_python + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) PYTHONPATH=$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) _PYTHON_SYSCONFIGDATA_PATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`) '$with_build_python + if test "x$cross_compiling" = xyes +then : + PYTHON_FOR_BUILD='_PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) '"$PYTHON_FOR_BUILD" + +fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_build_python" >&5 printf "%s\n" "$with_build_python" >&6; } @@ -3825,6 +3856,17 @@ fi +# Module import checks must run with the target interpreter on native builds. +if test "x$cross_compiling" = xyes +then : + MODULE_CHECK_COMMAND='$(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/check_extension_modules.py --cross-compiling' +else case e in #( + e) MODULE_CHECK_COMMAND='$(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/Tools/build/check_extension_modules.py --no-cross-compiling' + ;; +esac +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Python interpreter freezing" >&5 printf %s "checking for Python interpreter freezing... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PYTHON_FOR_FREEZE" >&5 @@ -3839,6 +3881,9 @@ then : FREEZE_MODULE='$(FREEZE_MODULE_BOOTSTRAP)' FREEZE_MODULE_DEPS='$(FREEZE_MODULE_BOOTSTRAP_DEPS)' PYTHON_FOR_BUILD_DEPS='' + # The build Python is a separate interpreter. RUNSHARED would make it + # load the in-tree libpython, which may need a different libc. + RUNSHARED_FOR_BUILD='' else case e in #( e) @@ -3847,6 +3892,7 @@ else case e in #( FREEZE_MODULE='$(PYTHON_FOR_FREEZE) $(srcdir)/Programs/_freeze_module.py' FREEZE_MODULE_DEPS="_bootstrap_python \$(srcdir)/Programs/_freeze_module.py" PYTHON_FOR_BUILD_DEPS='$(BUILDPYTHON)' + RUNSHARED_FOR_BUILD='$(RUNSHARED)' ;; esac @@ -3857,6 +3903,7 @@ fi + for ac_prog in python$PACKAGE_VERSION python3.16 python3.15 python3.14 python3.13 python3.12 python3.11 python3.10 python3 python do # Extract the first word of "$ac_prog", so it can be a program name with args. @@ -4170,6 +4217,15 @@ then *-apple-ios*) ac_sys_system=iOS ;; + *-apple-tvos*) + ac_sys_system=tvOS + ;; + *-apple-xros*) + ac_sys_system=visionOS + ;; + *-apple-watchos*) + ac_sys_system=watchOS + ;; *-*-darwin*) ac_sys_system=Darwin ;; @@ -4193,8 +4249,7 @@ then ac_sys_release= else ac_sys_system=`uname -s` - if test "$ac_sys_system" = "AIX" \ - -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then + if test "$ac_sys_system" = "AIX"; then ac_sys_release=`uname -v` else ac_sys_release=`uname -r` @@ -4254,7 +4309,7 @@ fi # On cross-compile builds, configure will look for a host-specific compiler by # prepending the user-provided host triple to the required binary name. # -# On iOS, this results in binaries like "arm64-apple-ios13.0-simulator-gcc", +# On iOS/tvOS/visionOS/watchOS, this results in binaries like "arm64-apple-ios13.0-simulator-gcc", # which isn't a binary that exists, and isn't very convenient, as it contains the # iOS version. As the default cross-compiler name won't exist, configure falls # back to gcc, which *definitely* won't work. We're providing wrapper scripts for @@ -4269,14 +4324,36 @@ if test -z "$AR"; then aarch64-apple-ios*-simulator) AR=arm64-apple-ios-simulator-ar ;; aarch64-apple-ios*) AR=arm64-apple-ios-ar ;; x86_64-apple-ios*-simulator) AR=x86_64-apple-ios-simulator-ar ;; + + aarch64-apple-tvos*-simulator) AR=arm64-apple-tvos-simulator-ar ;; + aarch64-apple-tvos*) AR=arm64-apple-tvos-ar ;; + x86_64-apple-tvos*-simulator) AR=x86_64-apple-tvos-simulator-ar ;; + + aarch64-apple-xros*-simulator) AR=arm64-apple-xros-simulator-ar ;; + aarch64-apple-xros*) AR=arm64-apple-xros-ar ;; + + aarch64-apple-watchos*-simulator) AR=arm64-apple-watchos-simulator-ar ;; + aarch64-apple-watchos*) AR=arm64_32-apple-watchos-ar ;; + x86_64-apple-watchos*-simulator) AR=x86_64-apple-watchos-simulator-ar ;; *) - esac + esac fi if test -z "$CC"; then case "$host" in aarch64-apple-ios*-simulator) CC=arm64-apple-ios-simulator-clang ;; aarch64-apple-ios*) CC=arm64-apple-ios-clang ;; x86_64-apple-ios*-simulator) CC=x86_64-apple-ios-simulator-clang ;; + + aarch64-apple-tvos*-simulator) CC=arm64-apple-tvos-simulator-clang ;; + aarch64-apple-tvos*) CC=arm64-apple-tvos-clang ;; + x86_64-apple-tvos*-simulator) CC=x86_64-apple-tvos-simulator-clang ;; + + aarch64-apple-xros*-simulator) CC=arm64-apple-xros-simulator-clang ;; + aarch64-apple-xros*) CC=arm64-apple-xros-clang ;; + + aarch64-apple-watchos*-simulator) CC=arm64-apple-watchos-simulator-clang ;; + aarch64-apple-watchos*) CC=arm64_32-apple-watchos-clang ;; + x86_64-apple-watchos*-simulator) CC=x86_64-apple-watchos-simulator-clang ;; *) esac fi @@ -4285,6 +4362,17 @@ if test -z "$CPP"; then aarch64-apple-ios*-simulator) CPP=arm64-apple-ios-simulator-cpp ;; aarch64-apple-ios*) CPP=arm64-apple-ios-cpp ;; x86_64-apple-ios*-simulator) CPP=x86_64-apple-ios-simulator-cpp ;; + + aarch64-apple-tvos*-simulator) CPP=arm64-apple-tvos-simulator-cpp ;; + aarch64-apple-tvos*) CPP=arm64-apple-tvos-cpp ;; + x86_64-apple-tvos*-simulator) CPP=x86_64-apple-tvos-simulator-cpp ;; + + aarch64-apple-xros*-simulator) CPP=arm64-apple-xros-simulator-cpp ;; + aarch64-apple-xros*) CPP=arm64-apple-xros-cpp ;; + + aarch64-apple-watchos*-simulator) CPP=arm64-apple-watchos-simulator-cpp ;; + aarch64-apple-watchos*) CPP=arm64_32-apple-watchos-cpp ;; + x86_64-apple-watchos*-simulator) CPP=x86_64-apple-watchos-simulator-cpp ;; *) esac fi @@ -4293,6 +4381,17 @@ if test -z "$CXX"; then aarch64-apple-ios*-simulator) CXX=arm64-apple-ios-simulator-clang++ ;; aarch64-apple-ios*) CXX=arm64-apple-ios-clang++ ;; x86_64-apple-ios*-simulator) CXX=x86_64-apple-ios-simulator-clang++ ;; + + aarch64-apple-tvos*-simulator) CXX=arm64-apple-tvos-simulator-clang++ ;; + aarch64-apple-tvos*) CXX=arm64-apple-tvos-clang++ ;; + x86_64-apple-tvos*-simulator) CXX=x86_64-apple-tvos-simulator-clang++ ;; + + aarch64-apple-xros*-simulator) CXX=arm64-apple-xros-simulator-clang++ ;; + aarch64-apple-xros*) CXX=arm64-apple-xros-clang++ ;; + + aarch64-apple-watchos*-simulator) CXX=arm64-apple-watchos-simulator-clang++ ;; + aarch64-apple-watchos*) CXX=arm64_32-apple-watchos-clang++ ;; + x86_64-apple-watchos*-simulator) CXX=x86_64-apple-watchos-simulator-clang++ ;; *) esac fi @@ -4415,37 +4514,36 @@ then : case $enableval in yes) case $ac_sys_system in - Darwin) enableval=/Library/Frameworks ;; - iOS) enableval=Platforms/Apple/iOS/Frameworks/\$\(MULTIARCH\) ;; + Darwin) enableval=/Library/Frameworks ;; + iOS) enableval=Platforms/Apple/iOS/Frameworks/\$\(MULTIARCH\) ;; + tvOS) enableval=Platforms/Apple/tvOS/Frameworks/\$\(MULTIARCH\) ;; + visionOS) enableval=Platforms/Apple/visionOS/Frameworks/\$\(MULTIARCH\) ;; + watchOS) enableval=Platforms/Apple/watchOS/Frameworks/\$\(MULTIARCH\) ;; *) as_fn_error $? "Unknown platform for framework build" "$LINENO" 5 esac esac case $enableval in no) - case $ac_sys_system in - iOS) as_fn_error $? "iOS builds must use --enable-framework" "$LINENO" 5 ;; - *) - PYTHONFRAMEWORK= - PYTHONFRAMEWORKDIR=no-framework - PYTHONFRAMEWORKPREFIX= - PYTHONFRAMEWORKINSTALLDIR= - PYTHONFRAMEWORKINSTALLNAMEPREFIX= - RESSRCDIR= - FRAMEWORKINSTALLFIRST= - FRAMEWORKINSTALLLAST= - FRAMEWORKALTINSTALLFIRST= - FRAMEWORKALTINSTALLLAST= - FRAMEWORKPYTHONW= - INSTALLTARGETS="commoninstall bininstall maninstall" - - if test "x${prefix}" = "xNONE"; then - FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" - else - FRAMEWORKUNIXTOOLSPREFIX="${prefix}" - fi - enable_framework= - esac + PYTHONFRAMEWORK= + PYTHONFRAMEWORKDIR=no-framework + PYTHONFRAMEWORKPREFIX= + PYTHONFRAMEWORKINSTALLDIR= + PYTHONFRAMEWORKINSTALLNAMEPREFIX= + RESSRCDIR= + FRAMEWORKINSTALLFIRST= + FRAMEWORKINSTALLLAST= + FRAMEWORKALTINSTALLFIRST= + FRAMEWORKALTINSTALLLAST= + FRAMEWORKPYTHONW= + INSTALLTARGETS="commoninstall bininstall maninstall" + + if test "x${prefix}" = "xNONE"; then + FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" + else + FRAMEWORKUNIXTOOLSPREFIX="${prefix}" + fi + enable_framework= ;; *) PYTHONFRAMEWORKPREFIX="${enableval}" @@ -4531,6 +4629,51 @@ then : ac_config_files="$ac_config_files Platforms/Apple/iOS/Resources/Info.plist" + ;; + tvOS) : + FRAMEWORKINSTALLFIRST="frameworkinstallunversionedstructure" + FRAMEWORKALTINSTALLFIRST="frameworkinstallunversionedstructure " + FRAMEWORKINSTALLLAST="frameworkinstallmobileheaders" + FRAMEWORKALTINSTALLLAST="frameworkinstallmobileheaders" + FRAMEWORKPYTHONW= + INSTALLTARGETS="libinstall inclinstall sharedinstall" + + prefix=$PYTHONFRAMEWORKPREFIX + PYTHONFRAMEWORKINSTALLNAMEPREFIX="@rpath/$PYTHONFRAMEWORKDIR" + RESSRCDIR=Platforms/Apple/tvOS/Resources + + ac_config_files="$ac_config_files Platforms/Apple/tvOS/Resources/Info.plist" + + ;; + visionOS) : + FRAMEWORKINSTALLFIRST="frameworkinstallunversionedstructure" + FRAMEWORKALTINSTALLFIRST="frameworkinstallunversionedstructure " + FRAMEWORKINSTALLLAST="frameworkinstallmobileheaders" + FRAMEWORKALTINSTALLLAST="frameworkinstallmobileheaders" + FRAMEWORKPYTHONW= + INSTALLTARGETS="libinstall inclinstall sharedinstall" + + prefix=$PYTHONFRAMEWORKPREFIX + PYTHONFRAMEWORKINSTALLNAMEPREFIX="@rpath/$PYTHONFRAMEWORKDIR" + RESSRCDIR=Platforms/Apple/visionOS/Resources + + ac_config_files="$ac_config_files Platforms/Apple/visionOS/Resources/Info.plist" + + ;; + watchOS) : + FRAMEWORKINSTALLFIRST="frameworkinstallunversionedstructure" + FRAMEWORKALTINSTALLFIRST="frameworkinstallunversionedstructure " + FRAMEWORKINSTALLLAST="frameworkinstallmobileheaders" + FRAMEWORKALTINSTALLLAST="frameworkinstallmobileheaders" + FRAMEWORKPYTHONW= + INSTALLTARGETS="libinstall inclinstall sharedinstall" + + prefix=$PYTHONFRAMEWORKPREFIX + PYTHONFRAMEWORKINSTALLNAMEPREFIX="@rpath/$PYTHONFRAMEWORKDIR" + RESSRCDIR=Platforms/Apple/watchOS/Resources + + ac_config_files="$ac_config_files Platforms/Apple/watchOS/Resources/Info.plist" + ;; *) as_fn_error $? "Unknown platform for framework build" "$LINENO" 5 @@ -4540,28 +4683,24 @@ then : else case e in #( e) - case $ac_sys_system in - iOS) as_fn_error $? "iOS builds must use --enable-framework" "$LINENO" 5 ;; - *) - PYTHONFRAMEWORK= - PYTHONFRAMEWORKDIR=no-framework - PYTHONFRAMEWORKPREFIX= - PYTHONFRAMEWORKINSTALLDIR= - PYTHONFRAMEWORKINSTALLNAMEPREFIX= - RESSRCDIR= - FRAMEWORKINSTALLFIRST= - FRAMEWORKINSTALLLAST= - FRAMEWORKALTINSTALLFIRST= - FRAMEWORKALTINSTALLLAST= - FRAMEWORKPYTHONW= - INSTALLTARGETS="commoninstall bininstall maninstall" - if test "x${prefix}" = "xNONE" ; then - FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" - else - FRAMEWORKUNIXTOOLSPREFIX="${prefix}" - fi - enable_framework= - esac + PYTHONFRAMEWORK= + PYTHONFRAMEWORKDIR=no-framework + PYTHONFRAMEWORKPREFIX= + PYTHONFRAMEWORKINSTALLDIR= + PYTHONFRAMEWORKINSTALLNAMEPREFIX= + RESSRCDIR= + FRAMEWORKINSTALLFIRST= + FRAMEWORKINSTALLLAST= + FRAMEWORKALTINSTALLFIRST= + FRAMEWORKALTINSTALLLAST= + FRAMEWORKPYTHONW= + INSTALLTARGETS="commoninstall bininstall maninstall" + if test "x${prefix}" = "xNONE" ; then + FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" + else + FRAMEWORKUNIXTOOLSPREFIX="${prefix}" + fi + enable_framework= ;; esac fi @@ -4596,8 +4735,8 @@ then : case "$withval" in yes) case $ac_sys_system in - Darwin|iOS) - # iOS is able to share the macOS patch + Darwin|iOS|tvOS|visionOS|watchOS) + # iOS/tvOS/visionOS/watchOS is able to share the macOS patch APP_STORE_COMPLIANCE_PATCH="Mac/Resources/app-store-compliance.patch" ;; *) as_fn_error $? "no default app store compliance patch available for $ac_sys_system" "$LINENO" 5 ;; @@ -4615,8 +4754,8 @@ printf "%s\n" "applying custom app store compliance patch" >&6; } else case e in #( e) case $ac_sys_system in - iOS) - # Always apply the compliance patch on iOS; we can use the macOS patch + iOS|tvOS|visionOS|watchOS) + # Always apply the compliance patch on iOS/tvOS/visionOS/watchOS; we can use the macOS patch APP_STORE_COMPLIANCE_PATCH="Mac/Resources/app-store-compliance.patch" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: applying default app store compliance patch" >&5 printf "%s\n" "applying default app store compliance patch" >&6; } @@ -4634,6 +4773,8 @@ fi +EXPORT_XROS_DEPLOYMENT_TARGET='#' + if test "$cross_compiling" = yes; then case "$host" in @@ -4674,6 +4815,78 @@ printf "%s\n" "$IPHONEOS_DEPLOYMENT_TARGET" >&6; } ;; esac ;; + *-apple-tvos*) + _host_os=`echo $host | cut -d '-' -f3` + _host_device=`echo $host | cut -d '-' -f4` + _host_device=${_host_device:=os} + + # TVOS_DEPLOYMENT_TARGET is the minimum supported tvOS version + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking tvOS deployment target" >&5 +printf %s "checking tvOS deployment target... " >&6; } + TVOS_DEPLOYMENT_TARGET=${_host_os:4} + TVOS_DEPLOYMENT_TARGET=${TVOS_DEPLOYMENT_TARGET:=12.0} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $TVOS_DEPLOYMENT_TARGET" >&5 +printf "%s\n" "$TVOS_DEPLOYMENT_TARGET" >&6; } + + case "$host_cpu" in + aarch64) + _host_ident=${TVOS_DEPLOYMENT_TARGET}-arm64-appletv${_host_device} + ;; + *) + _host_ident=${TVOS_DEPLOYMENT_TARGET}-$host_cpu-appletv${_host_device} + ;; + esac + ;; + *-apple-xros*) + _host_os=`echo $host | cut -d '-' -f3` + _host_device=`echo $host | cut -d '-' -f4` + _host_device=${_host_device:=os} + + # XROS_DEPLOYMENT_TARGET is the minimum supported visionOS version + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking visionOS deployment target" >&5 +printf %s "checking visionOS deployment target... " >&6; } + XROS_DEPLOYMENT_TARGET=${_host_os:8} + XROS_DEPLOYMENT_TARGET=${XROS_DEPLOYMENT_TARGET:=2.0} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $XROS_DEPLOYMENT_TARGET" >&5 +printf "%s\n" "$XROS_DEPLOYMENT_TARGET" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking exporting flag of visionOS deployment target" >&5 +printf %s "checking exporting flag of visionOS deployment target... " >&6; } + export XROS_DEPLOYMENT_TARGET + EXPORT_XROS_DEPLOYMENT_TARGET='' + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $EXPORT_XROS_DEPLOYMENT_TARGET" >&5 +printf "%s\n" "$EXPORT_XROS_DEPLOYMENT_TARGET" >&6; } + + case "$host_cpu" in + aarch64) + _host_ident=${XROS_DEPLOYMENT_TARGET}-arm64-xr${_host_device} + ;; + *) + _host_ident=${XROS_DEPLOYMENT_TARGET}-$host_cpu-xr${_host_device} + ;; + esac + ;; + *-apple-watchos*) + _host_os=`echo $host | cut -d '-' -f3` + _host_device=`echo $host | cut -d '-' -f4` + _host_device=${_host_device:=os} + + # WATCHOS_DEPLOYMENT_TARGET is the minimum supported watchOS version + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking watchOS deployment target" >&5 +printf %s "checking watchOS deployment target... " >&6; } + WATCHOS_DEPLOYMENT_TARGET=${_host_os:7} + WATCHOS_DEPLOYMENT_TARGET=${WATCHOS_DEPLOYMENT_TARGET:=9.0} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $WATCHOS_DEPLOYMENT_TARGET" >&5 +printf "%s\n" "$WATCHOS_DEPLOYMENT_TARGET" >&6; } + + case "$host_cpu" in + aarch64) + _host_ident=${WATCHOS_DEPLOYMENT_TARGET}-arm64-watch${_host_device} + ;; + *) + _host_ident=${WATCHOS_DEPLOYMENT_TARGET}-$host_cpu-watch${_host_device} + ;; + esac + ;; *-*-darwin*) case "$host_cpu" in arm*) @@ -4710,20 +4923,6 @@ fi # wildcard, and that the wildcard does not include future systems # (which may remove their limitations). case $ac_sys_system/$ac_sys_release in - # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, - # even though select is a POSIX function. Reported by J. Ribbens. - # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. - # In addition, Stefan Krah confirms that issue #1244610 exists through - # OpenBSD 4.6, but is fixed in 4.7. - OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.[0123456]) - define_xopen_source=no - # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is - # also defined. This can be overridden by defining _BSD_SOURCE - # As this has a different meaning on Linux, only define it on OpenBSD - -printf "%s\n" "#define _BSD_SOURCE 1" >>confdefs.h - - ;; OpenBSD/*) # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is # also defined. This can be overridden by defining _BSD_SOURCE @@ -4732,27 +4931,10 @@ printf "%s\n" "#define _BSD_SOURCE 1" >>confdefs.h printf "%s\n" "#define _BSD_SOURCE 1" >>confdefs.h ;; - # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of - # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by - # Marc Recht - NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6[A-S]) - define_xopen_source=no;; - # From the perspective of Solaris, _XOPEN_SOURCE is not so much a - # request to enable features supported by the standard as a request - # to disable features not supported by the standard. The best way - # for Python to use Solaris is simply to leave _XOPEN_SOURCE out - # entirely and define __EXTENSIONS__ instead. + # On Solaris, _XOPEN_SOURCE=800 hides platform specific features. + # A lower level is defined below. SunOS/*) define_xopen_source=no;; - # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE, - # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice. - # Reconfirmed for 7.1.4 by Martin v. Loewis. - OpenUNIX/8.0.0| UnixWare/7.1.[0-4]) - define_xopen_source=no;; - # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE, - # but used in struct sockaddr.sa_family. Reported by Tim Rice. - SCO_SV/3.2) - define_xopen_source=no;; # On MacOS X 10.2, a bug in ncurses.h means that it craps out if # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which # identifies itself as Darwin/7.* @@ -4764,9 +4946,15 @@ printf "%s\n" "#define _BSD_SOURCE 1" >>confdefs.h define_xopen_source=no;; Darwin/[12][0-9].*) define_xopen_source=no;; - # On iOS, defining _POSIX_C_SOURCE also disables platform specific features. + # On iOS/tvOS/visionOS/watchOS, defining _POSIX_C_SOURCE also disables platform specific features. iOS/*) define_xopen_source=no;; + tvOS/*) + define_xopen_source=no;; + visionOS/*) + define_xopen_source=no;; + watchOS/*) + define_xopen_source=no;; # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from # defining NI_NUMERICHOST. QNX/6.3.2) @@ -4804,6 +4992,22 @@ printf "%s\n" "#define _XOPEN_SOURCE_EXTENDED 1" >>confdefs.h printf "%s\n" "#define _POSIX_C_SOURCE 202405L" >>confdefs.h + + # Defining _POSIX_C_SOURCE and _XOPEN_SOURCE hides C23 library + # declarations on FreeBSD (e.g. sinpi() in math.h) when compiling + # with -std=c11. Defining _ISOC23_SOURCE makes them visible again. + +printf "%s\n" "#define _ISOC23_SOURCE 1" >>confdefs.h + +elif test "$ac_sys_system" = "SunOS" +then + # On illumos the socket ancillary-data API (CMSG_*, sendmsg(), recvmsg()) + # is declared only with _XOPEN_SOURCE >= 600; Solaris declares it anyway. + # __EXTENSIONS__ keeps the platform specific features which _XOPEN_SOURCE + # would otherwise hide. See gh-57208. + +printf "%s\n" "#define _XOPEN_SOURCE 600" >>confdefs.h + fi # On HP-UX mbstate_t requires _INCLUDE__STDC_A1_SOURCE @@ -4829,7 +5033,14 @@ fi CONFIGURE_MACOSX_DEPLOYMENT_TARGET= EXPORT_MACOSX_DEPLOYMENT_TARGET='#' -# Record the value of IPHONEOS_DEPLOYMENT_TARGET enforced by the selected host triple. +# Record the value of IPHONEOS_DEPLOYMENT_TARGET / TVOS_DEPLOYMENT_TARGET / +# XROS_DEPLOYMENT_TARGET / WATCHOS_DEPLOYMENT_TARGET enforced by the selected host triple. + + + + + +# XROS_DEPLOYMENT_TARGET should get exported # checks for alternative programs @@ -4857,19 +5068,44 @@ fi case $host in #( wasm64-*-emscripten) : - as_fn_append CFLAGS " -sMEMORY64=1" - as_fn_append LDFLAGS " -sMEMORY64=1" + as_fn_append CFLAGS " -m64" + as_fn_append LDFLAGS " -m64" ;; #( *) : ;; esac -case $ac_sys_system in #( - iOS) : +case $host in #( + *-apple-ios*-simulator) : + + as_fn_append CFLAGS " -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET}" + as_fn_append LDFLAGS " -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET}" + ;; #( + *-apple-ios*) : as_fn_append CFLAGS " -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET}" as_fn_append LDFLAGS " -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET}" ;; #( + *-apple-tvos*-simulator) : + + as_fn_append CFLAGS " -mtvos-simulator-version-min=${TVOS_DEPLOYMENT_TARGET}" + as_fn_append LDFLAGS " -mtvos-simulator-version-min=${TVOS_DEPLOYMENT_TARGET}" + ;; #( + *-apple-tvos*) : + + as_fn_append CFLAGS " -mtvos-version-min=${TVOS_DEPLOYMENT_TARGET}" + as_fn_append LDFLAGS " -mtvos-version-min=${TVOS_DEPLOYMENT_TARGET}" + ;; #( + *-apple-watchos*-simulator) : + + as_fn_append CFLAGS " -mwatchos-simulator-version-min=${WATCHOS_DEPLOYMENT_TARGET}" + as_fn_append LDFLAGS " -mwatchos-simulator-version-min=${WATCHOS_DEPLOYMENT_TARGET}" + ;; #( + *-apple-watchos*) : + + as_fn_append CFLAGS " -mwatchos-version-min=${WATCHOS_DEPLOYMENT_TARGET}" + as_fn_append LDFLAGS " -mwatchos-version-min=${WATCHOS_DEPLOYMENT_TARGET}" + ;; #( *) : ;; esac @@ -6390,6 +6626,8 @@ else case e in #( cat > conftest.c <&5 @@ -6969,7 +7207,117 @@ else CXX="$ac_cv_path_CXX" fi ;; - icc) if test -n "$ac_tool_prefix"; then + icx) if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}icpx", so it can be a program name with args. +set dummy ${ac_tool_prefix}icpx; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_path_CXX+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) case $CXX in + [\\/]* | ?:[\\/]*) + ac_cv_path_CXX="$CXX" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_path_CXX="$as_dir$ac_word$ac_exec_ext" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac ;; +esac +fi +CXX=$ac_cv_path_CXX +if test -n "$CXX"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +printf "%s\n" "$CXX" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_path_CXX"; then + ac_pt_CXX=$CXX + # Extract the first word of "icpx", so it can be a program name with args. +set dummy icpx; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_path_ac_pt_CXX+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) case $ac_pt_CXX in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_CXX="$ac_pt_CXX" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_CXX="$as_dir$ac_word$ac_exec_ext" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac ;; +esac +fi +ac_pt_CXX=$ac_cv_path_ac_pt_CXX +if test -n "$ac_pt_CXX"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_pt_CXX" >&5 +printf "%s\n" "$ac_pt_CXX" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_pt_CXX" = x; then + CXX="notfound" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_pt_CXX + fi +else + CXX="$ac_cv_path_CXX" +fi + ;; + icc) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}icpc", so it can be a program name with args. set dummy ${ac_tool_prefix}icpc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -7239,8 +7587,16 @@ case $ac_sys_system in #( MULTIARCH="" ;; #( iOS) : MULTIARCH="" ;; #( + tvOS) : + MULTIARCH="" ;; #( + visionOS) : + MULTIARCH="" ;; #( + watchOS) : + MULTIARCH="" ;; #( FreeBSD*) : MULTIARCH="" ;; #( + OpenBSD*) : + MULTIARCH="" ;; #( *) : MULTIARCH=$($CC --print-multiarch 2>/dev/null) ;; @@ -7259,13 +7615,19 @@ fi printf "%s\n" "$MULTIARCH" >&6; } case $ac_sys_system in #( - iOS) : + iOS|tvOS|visionOS|watchOS) : SOABI_PLATFORM=`echo "$PLATFORM_TRIPLET" | cut -d '-' -f2` ;; #( *) : SOABI_PLATFORM=$PLATFORM_TRIPLET ;; esac +if test x$SOABI_PLATFORM != x; then + +printf "%s\n" "#define SOABI_PLATFORM \"${SOABI_PLATFORM}\"" >>confdefs.h + +fi + if test x$MULTIARCH != x; then MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\"" fi @@ -7287,34 +7649,38 @@ printf "%s\n" "#define _Py_STACK_GROWS_DOWN $_Py_STACK_GROWS_DOWN" >>confdefs.h printf %s "checking for PEP 11 support tier... " >&6; } case $host/$ac_cv_cc_name in #( x86_64-*-linux-gnu/gcc) : - PY_SUPPORT_TIER=1 ;; #( - x86_64-apple-darwin*/clang) : PY_SUPPORT_TIER=1 ;; #( aarch64-apple-darwin*/clang) : PY_SUPPORT_TIER=1 ;; #( + aarch64-*-linux-gnu/gcc) : + PY_SUPPORT_TIER=1 ;; #( i686-pc-windows-msvc/msvc) : PY_SUPPORT_TIER=1 ;; #( x86_64-pc-windows-msvc/msvc) : PY_SUPPORT_TIER=1 ;; #( - aarch64-*-linux-gnu/gcc) : - PY_SUPPORT_TIER=2 ;; #( - aarch64-*-linux-gnu/clang) : + aarch64-*-linux-gnu/clang) : PY_SUPPORT_TIER=2 ;; #( - powerpc64le-*-linux-gnu/gcc) : + aarch64-pc-windows-msvc/msvc) : PY_SUPPORT_TIER=2 ;; #( wasm32-unknown-wasip1/clang) : PY_SUPPORT_TIER=2 ;; #( + x86_64-apple-darwin*/clang) : + PY_SUPPORT_TIER=2 ;; #( x86_64-*-linux-gnu/clang) : PY_SUPPORT_TIER=2 ;; #( - aarch64-pc-windows-msvc/msvc) : + armv7l-*-linux-gnueabihf/gcc) : PY_SUPPORT_TIER=3 ;; #( - armv7l-*-linux-gnueabihf/gcc) : + powerpc64le-*-linux-gnu/gcc) : PY_SUPPORT_TIER=3 ;; #( powerpc64le-*-linux-gnu/clang) : PY_SUPPORT_TIER=3 ;; #( - s390x-*-linux-gnu/gcc) : + riscv64-*-linux-gnu/gcc) : + PY_SUPPORT_TIER=3 ;; #( + riscv64-*-linux-gnu/clang) : + PY_SUPPORT_TIER=3 ;; #( + s390x-*-linux-gnu/gcc) : PY_SUPPORT_TIER=3 ;; #( x86_64-*-freebsd*/clang) : PY_SUPPORT_TIER=3 ;; #( @@ -7496,6 +7862,30 @@ fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_wasm_pthreads" >&5 printf "%s\n" "$enable_wasm_pthreads" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --enable-emscripten-syscalls" >&5 +printf %s "checking for --enable-emscripten-syscalls... " >&6; } +# Check whether --enable-emscripten-syscalls was given. +if test ${enable_emscripten_syscalls+y} +then : + enableval=$enable_emscripten_syscalls; + case $ac_sys_system in #( + Emscripten) : + ;; #( + *) : + as_fn_error $? "--enable-emscripten-syscalls only applies to Emscripten" "$LINENO" 5 + ;; +esac + +else case e in #( + e) + enable_emscripten_syscalls=yes + ;; +esac +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_emscripten_syscalls" >&5 +printf "%s\n" "$enable_emscripten_syscalls" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --with-suffix" >&5 printf %s "checking for --with-suffix... " >&6; } @@ -7776,7 +8166,7 @@ then case $ac_sys_system in Darwin) LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)';; - iOS) + iOS|tvOS|visionOS|watchOS) LDLIBRARY='$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)';; *) as_fn_error $? "Unknown platform for framework build" "$LINENO" 5;; @@ -7842,7 +8232,10 @@ printf "%s\n" "#define Py_ENABLE_SHARED 1" >>confdefs.h BLDLIBRARY='-L. -lpython$(LDVERSION)' RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}} ;; - iOS) + iOS|tvOS|visionOS|watchOS) + if test -z "$PYTHONFRAMEWORK"; then + as_fn_error $? "iOS shared builds must use --enable-framework; an iOS app can only load a signed framework, never a bare dylib" "$LINENO" 5 + fi LDLIBRARY='libpython$(LDVERSION).dylib' ;; AIX*) @@ -8938,6 +9331,92 @@ fi else LTOFLAGS="-flto=${Py_LTO_POLICY}" fi + LTOCFLAGS="$LTOFLAGS" + # GNU ld needs LLVMgold.so for Clang LTO. If the configured linker + # cannot link LTO objects, try lld, which does not need that plugin. + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + LDFLAGS="$LDFLAGS $LDFLAGS_NODIST $LTOFLAGS" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether Clang LTO works with the configured linker" >&5 +printf %s "checking whether Clang LTO works with the configured linker... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + clang_lto_link=yes +else case e in #( + e) clang_lto_link=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $clang_lto_link" >&5 +printf "%s\n" "$clang_lto_link" >&6; } + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + + if test "$clang_lto_link" = no; then + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + LDFLAGS="$LDFLAGS -fuse-ld=lld" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether Clang LTO works with lld" >&5 +printf %s "checking whether Clang LTO works with lld... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + clang_lto_link=yes +else case e in #( + e) clang_lto_link=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $clang_lto_link" >&5 +printf "%s\n" "$clang_lto_link" >&6; } + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + + if test "$clang_lto_link" = no; then + as_fn_error $? "Clang LTO requires a working LTO-aware linker. Install lld or the LLVMgold.so plugin, select a linker with LDFLAGS, or disable LTO with --without-lto." "$LINENO" 5 + fi + LTOFLAGS="$LTOFLAGS -fuse-ld=lld" + LDFLAGS_NOLTO="$LDFLAGS_NOLTO -fuse-ld=lld" + fi ;; esac ;; @@ -8984,6 +9463,7 @@ fi + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}llvm-profdata", so it can be a program name with args. set dummy ${ac_tool_prefix}llvm-profdata; ac_word=$2 @@ -9115,14 +9595,16 @@ printf "%s\n" "$as_me: llvm-profdata found via xcrun: ${LLVM_PROFDATA}" >&6;} fi fi LLVM_PROF_ERR=no +LLVM_PROF_SHOW=true case "$ac_cv_cc_name" in - clang) + clang|icx) # Any changes made here should be reflected in the GCC+Darwin case below PGO_PROF_GEN_FLAG="-fprofile-instr-generate" PGO_PROF_USE_FLAG="-fprofile-instr-use=\"\$(shell pwd)/code.profclangd\"" LLVM_PROF_MERGER=" ${LLVM_PROFDATA} merge -output=\"\$(shell pwd)/code.profclangd\" \"\$(shell pwd)\"/*.profclangr " LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"\$(shell pwd)/code-%p.profclangr\"" + LLVM_PROF_SHOW=" ${LLVM_PROFDATA} show --detailed-summary --topn=500 \"\$(shell pwd)/code.profclangd\" " if test $LLVM_PROF_FOUND = not-found then LLVM_PROF_ERR=yes @@ -9316,6 +9798,33 @@ esac fi + # BOLT rejects binaries with Cortex-A53 erratum 843419 workaround veneers, + # see https://github.com/llvm/llvm-project/pull/187955 + # Check explicit flags here to provide a friendlier error. Recent BOLT + # versions reject workaround veneers by default, including those + # from compiler defaults, so we do not perform exhaustive detection. + case $host_cpu in #( + aarch64*) : + + case "$CC $CFLAGS $CPPFLAGS $CFLAGS_NODIST $LDFLAGS $LDFLAGS_NODIST $LIBS" in #( + *-mfix-cortex-a53-843419*|*--fix-cortex-a53-843419*) : + + as_fn_error $? "--enable-bolt is incompatible with the Cortex-A53 erratum 843419 workaround. +BOLT does not preserve protection against this erratum. Its output must not run +on affected Cortex-A53 processors, including during the build. +If the generated binaries will never run on affected processors, disable the +workaround explicitly. With GCC, configure with +LDFLAGS_NODIST=\"-mno-fix-cortex-a53-843419\". Also remove any explicit +-mfix-cortex-a53-843419 or -Wl,--fix-cortex-a53-843419 flags." "$LINENO" 5 + ;; #( + *) : + ;; +esac + ;; #( + *) : + ;; +esac + # These flags are required for bolt to work: LDFLAGS_NODIST="$LDFLAGS_NODIST -Wl,--emit-relocs" @@ -9601,7 +10110,14 @@ printf "%s\n" "$BOLT_INSTRUMENT_FLAGS" >&6; } printf %s "checking BOLT_APPLY_FLAGS... " >&6; } if test -z "${BOLT_APPLY_FLAGS}" then - BOLT_APPLY_FLAGS=" ${BOLT_COMMON_FLAGS} -reorder-blocks=ext-tsp -reorder-functions=cdsort -split-functions -icf=0 -inline-all -split-eh -reorder-functions-use-hot-size -peepholes=none -jump-tables=aggressive -inline-ap -indirect-call-promotion=all -dyno-stats -use-gnu-stack -frame-opt=hot " + case $host_cpu in #( + x86_64) : + bolt_frame_opt_flags="-frame-opt=hot" ;; #( + *) : + bolt_frame_opt_flags="" + ;; +esac + BOLT_APPLY_FLAGS=" ${BOLT_COMMON_FLAGS} -reorder-blocks=ext-tsp -reorder-functions=cdsort -split-functions -icf=0 -inline-all -split-eh -reorder-functions-use-hot-size -peepholes=none -jump-tables=aggressive -inline-ap -indirect-call-promotion=all -dyno-stats -use-gnu-stack ${bolt_frame_opt_flags} " fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $BOLT_APPLY_FLAGS" >&5 @@ -9768,11 +10284,6 @@ then OPT="-O3 -Wall" ;; esac - - case $ac_sys_system in - SCO_SV*) OPT="$OPT -m486 -DSCO5" - ;; - esac ;; *) @@ -9795,14 +10306,11 @@ fi as_fn_append LINKFORSHARED " -sALLOW_MEMORY_GROWTH -sINITIAL_MEMORY=20971520" - as_fn_append LDFLAGS_NODIST " -sWASM_BIGINT" - as_fn_append LINKFORSHARED " -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js" as_fn_append LINKFORSHARED " -sEXPORTED_RUNTIME_METHODS=FS,callMain,ENV,HEAPU32,TTY,ERRNO_CODES" - as_fn_append LINKFORSHARED " -sEXPORTED_FUNCTIONS=_main,_Py_Version,__PyRuntime,_PyGILState_GetThisThreadState,__PyEM_EMSCRIPTEN_TRAMPOLINE_OFFSET" + as_fn_append LINKFORSHARED " -sEXPORTED_FUNCTIONS=_main,_Py_Version,_PyGILState_GetThisThreadState,NODEFS" as_fn_append LINKFORSHARED " -sSTACK_SIZE=5MB" as_fn_append LINKFORSHARED " -sTEXTDECODER=2" - as_fn_append LINKFORSHARED " -sGROWABLE_ARRAYBUFFERS=0" if test "x$enable_wasm_dynamic_linking" = xyes then : @@ -9815,7 +10323,7 @@ fi then : as_fn_append CFLAGS_NODIST " -pthread" - as_fn_append LDFLAGS_NODIST " -sUSE_PTHREADS" + as_fn_append LDFLAGS_NODIST " -pthread" as_fn_append LINKFORSHARED " -sPROXY_TO_PTHREAD" fi @@ -11117,10 +11625,6 @@ fi esac case $ac_sys_system in - SCO_SV*) - BASECFLAGS="$BASECFLAGS -m486 -DSCO5" - ;; - Darwin*) # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd # used to be here, but non-Apple gcc doesn't accept them. @@ -11336,18 +11840,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ ;; esac -else case e in #( - e) - case $ac_sys_system in - OpenUNIX*|UnixWare*) - BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca " - ;; - SCO_SV*) - BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5" - ;; - esac - ;; -esac fi # Check for --enable-experimental-jit: @@ -11404,6 +11896,10 @@ case "$ac_cv_cc_name" in mpicc) CFLAGS_NODIST="$CFLAGS_NODIST" ;; +icx) + # ICX needs fp-model=precise (the default in clang) or floats behave badly + CFLAGS_NODIST="$CFLAGS_NODIST -ffp-model=precise" + ;; icc) # ICC needs -fp-model strict or floats behave badly CFLAGS_NODIST="$CFLAGS_NODIST -fp-model strict" @@ -11827,12 +12323,6 @@ if test "x$ac_cv_header_linux_random_h" = xyes then : printf "%s\n" "#define HAVE_LINUX_RANDOM_H 1" >>confdefs.h -fi -ac_fn_c_check_header_compile "$LINENO" "linux/soundcard.h" "ac_cv_header_linux_soundcard_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_soundcard_h" = xyes -then : - printf "%s\n" "#define HAVE_LINUX_SOUNDCARD_H 1" >>confdefs.h - fi ac_fn_c_check_header_compile "$LINENO" "linux/sched.h" "ac_cv_header_linux_sched_h" "$ac_includes_default" if test "x$ac_cv_header_linux_sched_h" = xyes @@ -11893,6 +12383,12 @@ if test "x$ac_cv_header_pthread_h" = xyes then : printf "%s\n" "#define HAVE_PTHREAD_H 1" >>confdefs.h +fi +ac_fn_c_check_header_compile "$LINENO" "pthread_np.h" "ac_cv_header_pthread_np_h" "$ac_includes_default" +if test "x$ac_cv_header_pthread_np_h" = xyes +then : + printf "%s\n" "#define HAVE_PTHREAD_NP_H 1" >>confdefs.h + fi ac_fn_c_check_header_compile "$LINENO" "pty.h" "ac_cv_header_pty_h" "$ac_includes_default" if test "x$ac_cv_header_pty_h" = xyes @@ -11911,12 +12407,6 @@ if test "x$ac_cv_header_setjmp_h" = xyes then : printf "%s\n" "#define HAVE_SETJMP_H 1" >>confdefs.h -fi -ac_fn_c_check_header_compile "$LINENO" "shadow.h" "ac_cv_header_shadow_h" "$ac_includes_default" -if test "x$ac_cv_header_shadow_h" = xyes -then : - printf "%s\n" "#define HAVE_SHADOW_H 1" >>confdefs.h - fi ac_fn_c_check_header_compile "$LINENO" "signal.h" "ac_cv_header_signal_h" "$ac_includes_default" if test "x$ac_cv_header_signal_h" = xyes @@ -11929,12 +12419,6 @@ if test "x$ac_cv_header_spawn_h" = xyes then : printf "%s\n" "#define HAVE_SPAWN_H 1" >>confdefs.h -fi -ac_fn_c_check_header_compile "$LINENO" "sys/audioio.h" "ac_cv_header_sys_audioio_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_audioio_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_AUDIOIO_H 1" >>confdefs.h - fi ac_fn_c_check_header_compile "$LINENO" "sys/bsdtty.h" "ac_cv_header_sys_bsdtty_h" "$ac_includes_default" if test "x$ac_cv_header_sys_bsdtty_h" = xyes @@ -12073,12 +12557,6 @@ if test "x$ac_cv_header_sys_socket_h" = xyes then : printf "%s\n" "#define HAVE_SYS_SOCKET_H 1" >>confdefs.h -fi -ac_fn_c_check_header_compile "$LINENO" "sys/soundcard.h" "ac_cv_header_sys_soundcard_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_soundcard_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_SOUNDCARD_H 1" >>confdefs.h - fi ac_fn_c_check_header_compile "$LINENO" "sys/stat.h" "ac_cv_header_sys_stat_h" "$ac_includes_default" if test "x$ac_cv_header_sys_stat_h" = xyes @@ -12823,13 +13301,6 @@ printf "%s\n" "#define _FILE_OFFSET_BITS 64" >>confdefs.h fi -# Add some code to confdefs.h so that the test for off_t works on SCO -cat >> confdefs.h <<\EOF -#if defined(SCO_DS) -#undef _OFF_T -#endif -EOF - # Type availability checks ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" if test "x$ac_cv_type_mode_t" = xyes @@ -13969,39 +14440,84 @@ printf %s "checking for --with-address-sanitizer... " >&6; } if test ${with_address_sanitizer+y} then : withval=$with_address_sanitizer; -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $withval" >&5 -printf "%s\n" "$withval" >&6; } +else case e in #( + e) with_address_sanitizer=no ;; +esac +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_address_sanitizer" >&5 +printf "%s\n" "$with_address_sanitizer" >&6; } +if test "x$with_address_sanitizer" = xno +then : + +else case e in #( + e) BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS" LDFLAGS="-fsanitize=address $LDFLAGS" -# ASan works by controlling memory allocation, our own malloc interferes. -with_pymalloc="no" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a program links with -fsanitize=address" >&5 +printf %s "checking whether a program links with -fsanitize=address... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } else case e in #( e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } ;; +printf "%s\n" "no" >&6; } + as_fn_error $? "cannot link with -fsanitize=address: the compiler does not support AddressSanitizer or its runtime library is not installed; see config.log" "$LINENO" 5 ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ;; esac fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --with-hwaddress-sanitizer" >&5 +printf %s "checking for --with-hwaddress-sanitizer... " >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --with-memory-sanitizer" >&5 -printf %s "checking for --with-memory-sanitizer... " >&6; } - -# Check whether --with-memory_sanitizer was given. -if test ${with_memory_sanitizer+y} +# Check whether --with-hwaddress_sanitizer was given. +if test ${with_hwaddress_sanitizer+y} then : - withval=$with_memory_sanitizer; -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $withval" >&5 -printf "%s\n" "$withval" >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fsanitize=memory" >&5 -printf %s "checking whether C compiler accepts -fsanitize=memory... " >&6; } -if test ${ax_cv_check_cflags___fsanitize_memory+y} + withval=$with_hwaddress_sanitizer; +else case e in #( + e) with_hwaddress_sanitizer=no ;; +esac +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_hwaddress_sanitizer" >&5 +printf "%s\n" "$with_hwaddress_sanitizer" >&6; } +if test "x$with_hwaddress_sanitizer" = xno then : - printf %s "(cached) " >&6 + else case e in #( e) - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS -fsanitize=memory" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +hwasan_flags="-fsanitize=hwaddress" +# x86-64 lacks address tagging, so HWASan needs the page aliasing mode there. +# See gh-156049 and +# https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html#supported-architectures +case $host_cpu in #( + x86_64|amd64) : + hwasan_flags="$hwasan_flags -fsanitize-hwaddress-experimental-aliasing" + ;; #( + *) : + ;; +esac +BASECFLAGS="$hwasan_flags -fno-omit-frame-pointer $BASECFLAGS" +LDFLAGS="$hwasan_flags $LDFLAGS" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a program links with $hwasan_flags" >&5 +printf %s "checking whether a program links with $hwasan_flags... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -14012,39 +14528,71 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ax_cv_check_cflags___fsanitize_memory=yes + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } else case e in #( - e) ax_cv_check_cflags___fsanitize_memory=no ;; + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + as_fn_error $? "cannot link with $hwasan_flags: the compiler does not support HWAddressSanitizer or its runtime library is not installed; see config.log" "$LINENO" 5 ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - CFLAGS=$ax_check_save_flags ;; +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fsanitize_memory" >&5 -printf "%s\n" "$ax_cv_check_cflags___fsanitize_memory" >&6; } -if test "x$ax_cv_check_cflags___fsanitize_memory" = xyes -then : -BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS" -LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --with-memory-sanitizer" >&5 +printf %s "checking for --with-memory-sanitizer... " >&6; } +# Check whether --with-memory_sanitizer was given. +if test ${with_memory_sanitizer+y} +then : + withval=$with_memory_sanitizer; else case e in #( - e) as_fn_error $? "The selected compiler doesn't support memory sanitizer" "$LINENO" 5 ;; + e) with_memory_sanitizer=no ;; esac fi -# MSan works by controlling memory allocation, our own malloc interferes. -with_pymalloc="no" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_memory_sanitizer" >&5 +printf "%s\n" "$with_memory_sanitizer" >&6; } +if test "x$with_memory_sanitizer" = xno +then : + +else case e in #( + e) +BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS" +LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a program links with -fsanitize=memory" >&5 +printf %s "checking whether a program links with -fsanitize=memory... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } else case e in #( e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } ;; +printf "%s\n" "no" >&6; } + as_fn_error $? "cannot link with -fsanitize=memory: the compiler does not support MemorySanitizer or its runtime library is not installed; see config.log" "$LINENO" 5 ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ;; esac fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --with-undefined-behavior-sanitizer" >&5 printf %s "checking for --with-undefined-behavior-sanitizer... " >&6; } @@ -14053,22 +14601,52 @@ printf %s "checking for --with-undefined-behavior-sanitizer... " >&6; } if test ${with_undefined_behavior_sanitizer+y} then : withval=$with_undefined_behavior_sanitizer; -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $withval" >&5 -printf "%s\n" "$withval" >&6; } +else case e in #( + e) with_undefined_behavior_sanitizer=no ;; +esac +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_undefined_behavior_sanitizer" >&5 +printf "%s\n" "$with_undefined_behavior_sanitizer" >&6; } +if test "x$with_undefined_behavior_sanitizer" = xno +then : + +with_ubsan="no" + +else case e in #( + e) BASECFLAGS="-fsanitize=undefined $BASECFLAGS" LDFLAGS="-fsanitize=undefined $LDFLAGS" with_ubsan="yes" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a program links with -fsanitize=undefined" >&5 +printf %s "checking whether a program links with -fsanitize=undefined... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } else case e in #( - e) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } -with_ubsan="no" + as_fn_error $? "cannot link with -fsanitize=undefined: the compiler does not support UndefinedBehaviorSanitizer or its runtime library is not installed; see config.log" "$LINENO" 5 ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --with-thread-sanitizer" >&5 printf %s "checking for --with-thread-sanitizer... " >&6; } @@ -14076,22 +14654,52 @@ printf %s "checking for --with-thread-sanitizer... " >&6; } if test ${with_thread_sanitizer+y} then : withval=$with_thread_sanitizer; -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $withval" >&5 -printf "%s\n" "$withval" >&6; } +else case e in #( + e) with_thread_sanitizer=no ;; +esac +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_thread_sanitizer" >&5 +printf "%s\n" "$with_thread_sanitizer" >&6; } +if test "x$with_thread_sanitizer" = xno +then : + +with_tsan="no" + +else case e in #( + e) BASECFLAGS="-fsanitize=thread $BASECFLAGS" LDFLAGS="-fsanitize=thread $LDFLAGS" with_tsan="yes" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a program links with -fsanitize=thread" >&5 +printf %s "checking whether a program links with -fsanitize=thread... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } else case e in #( - e) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } -with_tsan="no" + as_fn_error $? "cannot link with -fsanitize=thread: the compiler does not support ThreadSanitizer or its runtime library is not installed; see config.log" "$LINENO" 5 ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi - # Set info about shared libraries. @@ -14195,7 +14803,7 @@ then BLDSHARED="$LDSHARED" fi ;; - iOS/*) + iOS/*|tvOS/*|visionOS/*|watchOS/*) LDSHARED='$(CC) -dynamiclib -F . -framework $(PYTHONFRAMEWORK)' LDCXXSHARED='$(CXX) -dynamiclib -F . -framework $(PYTHONFRAMEWORK)' BLDSHARED="$LDSHARED" @@ -14233,17 +14841,6 @@ then NetBSD*|DragonFly*) LDSHARED='$(CC) -shared' LDCXXSHARED='$(CXX) -shared';; - OpenUNIX*|UnixWare*) - if test "$ac_cv_gcc_compat" = "yes" ; then - LDSHARED='$(CC) -shared' - LDCXXSHARED='$(CXX) -shared' - else - LDSHARED='$(CC) -G' - LDCXXSHARED='$(CXX) -G' - fi;; - SCO_SV*) - LDSHARED='$(CC) -Wl,-G,-Bexport' - LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';; WASI*) if test "x$enable_wasm_dynamic_linking" = xyes then : @@ -14298,16 +14895,6 @@ then : fi;; FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";; Haiku*) CCSHARED="-fPIC";; - OpenUNIX*|UnixWare*) - if test "$ac_cv_gcc_compat" = "yes" - then CCSHARED="-fPIC" - else CCSHARED="-KPIC" - fi;; - SCO_SV*) - if test "$ac_cv_gcc_compat" = "yes" - then CCSHARED="-fPIC" - else CCSHARED="-Kpic -belf" - fi;; VxWorks*) CCSHARED="-fpic -D__SO_PICABILINUX__ -ftls-model=global-dynamic" esac @@ -14328,7 +14915,7 @@ then Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";; Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; # -u libsys_s pulls in all symbols in libsys - Darwin/*|iOS/*) + Darwin/*|iOS/*|tvOS/*|visionOS/*|watchOS/*) LINKFORSHARED="$extra_undefs -framework CoreFoundation" # Issue #18075: the default maximum stack size (8MBytes) is too @@ -14352,13 +14939,14 @@ printf "%s\n" "#define THREAD_STACK_SIZE 0x$stack_size" >>confdefs.h LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' fi LINKFORSHARED="$LINKFORSHARED" - elif test $ac_sys_system = "iOS"; then - LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)' + elif test "$ac_sys_system" = "iOS" -o "$ac_sys_system" = "tvOS" -o "$ac_sys_system" = "visionOS" -o "$ac_sys_system" = "watchOS"; then + LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED" + + if test "$enable_framework"; then + LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)' + fi fi ;; - OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";; - SCO_SV*) LINKFORSHARED="-Wl,-Bexport";; - ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";; FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) if [ "`$CC -dM -E - &6; } if test "$ac_cv_have_iconv" != no; then -printf "%s\n" "#define HAVE_ICONV 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_ICONV 1" >>confdefs.h if test "$ac_cv_have_iconv" = -liconv; then LIBS="-liconv $LIBS" @@ -15283,9 +15871,10 @@ then : fi -# gh-124228: While the libuuid library is available on NetBSD, it supports only UUID version 4. +# gh-124228: While the libuuid library is available on NetBSD and OpenBSD, +# it supports only UUID version 4. # This restriction inhibits the proper generation of time-based UUIDs. -if test "$ac_sys_system" = "NetBSD"; then +if test "$ac_sys_system" = "NetBSD" || test "$ac_sys_system" = "OpenBSD"; then have_uuid=missing printf "%s\n" "#define HAVE_UUID_H 0" >>confdefs.h @@ -15649,6 +16238,11 @@ else case e in #( e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#ifdef __has_attribute +# if __has_attribute(no_sanitize) +__attribute__((no_sanitize("alignment"))) +# endif +#endif int main(void) { char s[16]; @@ -16032,8 +16626,8 @@ if test "x$ac_cv_lib_ffi_ffi_call" = xyes then : have_libffi=yes - LIBFFI_CFLAGS="-I${SDKROOT}/usr/include/ffi -DUSING_APPLE_OS_LIBFFI=1" - LIBFFI_LIBS="-lffi" + LIBFFI_CFLAGS=${LIBFFI_CFLAGS-"-I${SDKROOT}/usr/include/ffi -DUSING_APPLE_OS_LIBFFI=1"} + LIBFFI_LIBS=${LIBFFI_LIBS-"-lffi"} fi @@ -16291,7 +16885,7 @@ then : ctypes_malloc_closure=yes ;; #( - iOS) : + iOS|tvOS|visionOS|watchOS) : ctypes_malloc_closure=yes ;; #( @@ -16338,7 +16932,7 @@ else case e in #( int main (void) { -void *x=ffi_prep_cif_var +(void)ffi_prep_cif_var ; return 0; } @@ -16379,7 +16973,7 @@ else case e in #( int main (void) { -void *x=ffi_prep_closure_loc +(void)ffi_prep_closure_loc ; return 0; } @@ -16420,7 +17014,7 @@ else case e in #( int main (void) { -void *x=ffi_closure_alloc +(void)ffi_closure_alloc ; return 0; } @@ -16501,7 +17095,7 @@ int main(void) { return 2; } - ffi_arg rc; + ffi_arg rc = 0; ffi_call(&cif, FFI_FN(z_is_expected), &rc, values); return !rc; } @@ -16536,6 +17130,67 @@ printf "%s\n" "#define _Py_FFI_SUPPORT_C_COMPLEX 1" >>confdefs.h fi +# Check for native half-float type (_Float16). +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for _Float16 support" >&5 +printf %s "checking for _Float16 support... " >&6; } +if test ${ac_cv_float16_supported+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + +CFLAGS="$CFLAGS -O0" +if test "$cross_compiling" = yes +then : + ac_cv_float16_supported=no +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +int main(void) +{ + _Float16 val = 1.0f16; + int test = isinf(val) || isnan(val); /* basic support from libm */ + double d = 3.14; + val = d; + return test; +} + +_ACEOF +if ac_fn_c_try_run "$LINENO" +then : + ac_cv_float16_supported=yes +else case e in #( + e) ac_cv_float16_supported=no ;; +esac +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_float16_supported" >&5 +printf "%s\n" "$ac_cv_float16_supported" >&6; } +if test "x$ac_cv_float16_supported" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_FLOAT16 1" >>confdefs.h + +fi + pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libmpdec >= 2.5.0" >&5 @@ -17698,35 +18353,42 @@ printf %s "checking for --enable-loadable-sqlite-extensions... " >&6; } if test ${enable_loadable_sqlite_extensions+y} then : enableval=$enable_loadable_sqlite_extensions; - if test "x$have_sqlite3_load_extension" = xno +else case e in #( + e) enable_loadable_sqlite_extensions=no + ;; +esac +fi + +if test "x$enable_loadable_sqlite_extensions" = xyes +then : + + if test "x$have_sqlite3_load_extension" = xno then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: n/a" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: n/a" >&5 printf "%s\n" "n/a" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Your version of SQLite does not support loadable extensions" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Your version of SQLite does not support loadable extensions" >&5 printf "%s\n" "$as_me: WARNING: Your version of SQLite does not support loadable extensions" >&2;} else case e in #( e) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } printf "%s\n" "#define PY_SQLITE_ENABLE_LOAD_EXTENSION 1" >>confdefs.h - ;; + ;; esac fi else case e in #( e) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } - ;; esac fi - found_tcltk=no for _QUERY in \ "tcl >= 8.5.12 tk >= 8.5.12" \ @@ -18206,6 +18868,34 @@ esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_ndbm ($dbm_ndbm)" >&5 printf "%s\n" "$have_ndbm ($dbm_ndbm)" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ndbm.h is provided by gdbm" >&5 +printf %s "checking whether ndbm.h is provided by gdbm... " >&6; } +if test ${ac_cv_ndbm_h_is_gdbm+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #ifndef _GDBM_H_ + #error "not gdbm" + #endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_ndbm_h_is_gdbm=yes +else case e in #( + e) ac_cv_ndbm_h_is_gdbm=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_ndbm_h_is_gdbm" >&5 +printf "%s\n" "$ac_cv_ndbm_h_is_gdbm" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gdbm/ndbm.h" >&5 printf %s "checking for gdbm/ndbm.h... " >&6; } if test ${ac_cv_header_gdbm_slash_ndbm_h+y} @@ -18481,6 +19171,10 @@ for db in $with_dbmliborder; do if test "$have_ndbm" = yes; then DBM_CFLAGS="-DUSE_NDBM" DBM_LIBS="$dbm_ndbm" + if test "x$ac_cv_ndbm_h_is_gdbm" = xyes +then : + DBM_LIBS="$DBM_LIBS $GDBM_LIBS" +fi have_dbm=yes break fi @@ -18488,7 +19182,7 @@ for db in $with_dbmliborder; do gdbm) if test "$have_gdbm_compat" = yes; then DBM_CFLAGS="-DUSE_GDBM_COMPAT" - DBM_LIBS="-lgdbm_compat" + DBM_LIBS="-lgdbm_compat $GDBM_LIBS" have_dbm=yes break fi @@ -20027,12 +20721,27 @@ fi PLATFORM_HEADERS= PLATFORM_OBJS= +PLATFORM_MAIN_OBJS= case $ac_sys_system in #( Emscripten) : - as_fn_append PLATFORM_OBJS ' Python/emscripten_signal.o Python/emscripten_trampoline.o Python/emscripten_trampoline_wasm.o Python/emscripten_syscalls.o' - as_fn_append PLATFORM_HEADERS ' $(srcdir)/Include/internal/pycore_emscripten_signal.h $(srcdir)/Include/internal/pycore_emscripten_trampoline.h' + as_fn_append PLATFORM_OBJS ' Python/emscripten_signal.o Python/wasm_trampoline.o' + as_fn_append CFLAGS_NODIST " -mgc" + + if test "x$enable_emscripten_syscalls" = xyes +then : + + as_fn_append PLATFORM_MAIN_OBJS ' Programs/emscripten_beforemain.o' + as_fn_append PLATFORM_OBJS ' Python/emscripten_syscalls.o' + +fi + as_fn_append PLATFORM_HEADERS ' $(srcdir)/Include/internal/pycore_emscripten_signal.h' + ;; #( + WASI) : + + as_fn_append PLATFORM_OBJS ' Python/wasm_trampoline.o' + as_fn_append CFLAGS_NODIST " -mgc" ;; #( *) : ;; @@ -20040,6 +20749,7 @@ esac + # -I${DLINCLDIR} is added to the compile rule for importdl.o DLINCLDIR=. @@ -20054,6 +20764,15 @@ then : fi +# Used by ctypes.util.dllist(). +ac_fn_c_check_func "$LINENO" "dl_iterate_phdr" "ac_cv_func_dl_iterate_phdr" +if test "x$ac_cv_func_dl_iterate_phdr" = xyes +then : + printf "%s\n" "#define HAVE_DL_ITERATE_PHDR 1" >>confdefs.h + +fi + + # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic # loading of modules. @@ -20102,14 +20821,9 @@ printf "%s\n" "$MACHDEP_OBJS" >&6; } fi if test "$ac_sys_system" = "Linux-android"; then - # When these functions are used in an unprivileged process, they crash rather - # than returning an error. - blocked_funcs="chroot initgroups setegid seteuid setgid sethostname - setregid setresgid setresuid setreuid setuid" - # These functions are unimplemented and always return an error # (https://android.googlesource.com/platform/system/sepolicy/+/refs/heads/android13-release/public/domain.te#1044) - blocked_funcs="$blocked_funcs sem_open sem_unlink" + blocked_funcs="sem_open sem_unlink" # Before API level 23, when fchmodat is called with the unimplemented flag # AT_SYMLINK_NOFOLLOW, instead of returning ENOTSUP as it should, it actually @@ -20210,12 +20924,6 @@ if test "x$ac_cv_func_dup" = xyes then : printf "%s\n" "#define HAVE_DUP 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "execv" "ac_cv_func_execv" -if test "x$ac_cv_func_execv" = xyes -then : - printf "%s\n" "#define HAVE_EXECV 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "explicit_bzero" "ac_cv_func_explicit_bzero" if test "x$ac_cv_func_explicit_bzero" = xyes @@ -20276,18 +20984,6 @@ if test "x$ac_cv_func_fexecve" = xyes then : printf "%s\n" "#define HAVE_FEXECVE 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "fork" "ac_cv_func_fork" -if test "x$ac_cv_func_fork" = xyes -then : - printf "%s\n" "#define HAVE_FORK 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "fork1" "ac_cv_func_fork1" -if test "x$ac_cv_func_fork1" = xyes -then : - printf "%s\n" "#define HAVE_FORK1 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "fpathconf" "ac_cv_func_fpathconf" if test "x$ac_cv_func_fpathconf" = xyes @@ -20300,12 +20996,6 @@ if test "x$ac_cv_func_fstatat" = xyes then : printf "%s\n" "#define HAVE_FSTATAT 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "ftime" "ac_cv_func_ftime" -if test "x$ac_cv_func_ftime" = xyes -then : - printf "%s\n" "#define HAVE_FTIME 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "ftruncate" "ac_cv_func_ftruncate" if test "x$ac_cv_func_ftruncate" = xyes @@ -20498,30 +21188,12 @@ if test "x$ac_cv_func_getsid" = xyes then : printf "%s\n" "#define HAVE_GETSID 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "getspent" "ac_cv_func_getspent" -if test "x$ac_cv_func_getspent" = xyes -then : - printf "%s\n" "#define HAVE_GETSPENT 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "getspnam" "ac_cv_func_getspnam" -if test "x$ac_cv_func_getspnam" = xyes -then : - printf "%s\n" "#define HAVE_GETSPNAM 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "getuid" "ac_cv_func_getuid" if test "x$ac_cv_func_getuid" = xyes then : printf "%s\n" "#define HAVE_GETUID 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "getwd" "ac_cv_func_getwd" -if test "x$ac_cv_func_getwd" = xyes -then : - printf "%s\n" "#define HAVE_GETWD 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "grantpt" "ac_cv_func_grantpt" if test "x$ac_cv_func_grantpt" = xyes @@ -20720,24 +21392,6 @@ if test "x$ac_cv_func_posix_openpt" = xyes then : printf "%s\n" "#define HAVE_POSIX_OPENPT 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "posix_spawn" "ac_cv_func_posix_spawn" -if test "x$ac_cv_func_posix_spawn" = xyes -then : - printf "%s\n" "#define HAVE_POSIX_SPAWN 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "posix_spawnp" "ac_cv_func_posix_spawnp" -if test "x$ac_cv_func_posix_spawnp" = xyes -then : - printf "%s\n" "#define HAVE_POSIX_SPAWNP 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "posix_spawn_file_actions_addclosefrom_np" "ac_cv_func_posix_spawn_file_actions_addclosefrom_np" -if test "x$ac_cv_func_posix_spawn_file_actions_addclosefrom_np" = xyes -then : - printf "%s\n" "#define HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSEFROM_NP 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "pread" "ac_cv_func_pread" if test "x$ac_cv_func_pread" = xyes @@ -21056,12 +21710,6 @@ if test "x$ac_cv_func_sigaction" = xyes then : printf "%s\n" "#define HAVE_SIGACTION 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "sigaltstack" "ac_cv_func_sigaltstack" -if test "x$ac_cv_func_sigaltstack" = xyes -then : - printf "%s\n" "#define HAVE_SIGALTSTACK 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "sigfillset" "ac_cv_func_sigfillset" if test "x$ac_cv_func_sigfillset" = xyes @@ -21080,12 +21728,6 @@ if test "x$ac_cv_func_sigpending" = xyes then : printf "%s\n" "#define HAVE_SIGPENDING 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "sigrelse" "ac_cv_func_sigrelse" -if test "x$ac_cv_func_sigrelse" = xyes -then : - printf "%s\n" "#define HAVE_SIGRELSE 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "sigtimedwait" "ac_cv_func_sigtimedwait" if test "x$ac_cv_func_sigtimedwait" = xyes @@ -21170,12 +21812,6 @@ if test "x$ac_cv_func_tcsetpgrp" = xyes then : printf "%s\n" "#define HAVE_TCSETPGRP 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "tempnam" "ac_cv_func_tempnam" -if test "x$ac_cv_func_tempnam" = xyes -then : - printf "%s\n" "#define HAVE_TEMPNAM 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "timegm" "ac_cv_func_timegm" if test "x$ac_cv_func_timegm" = xyes @@ -21194,18 +21830,6 @@ if test "x$ac_cv_func_tmpfile" = xyes then : printf "%s\n" "#define HAVE_TMPFILE 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "tmpnam" "ac_cv_func_tmpnam" -if test "x$ac_cv_func_tmpnam" = xyes -then : - printf "%s\n" "#define HAVE_TMPNAM 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "tmpnam_r" "ac_cv_func_tmpnam_r" -if test "x$ac_cv_func_tmpnam_r" = xyes -then : - printf "%s\n" "#define HAVE_TMPNAM_R 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "truncate" "ac_cv_func_truncate" if test "x$ac_cv_func_truncate" = xyes @@ -21323,6 +21947,428 @@ then : fi + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for freadlink" >&5 +printf %s "checking for freadlink... " >&6; } +if test ${ac_cv_func_freadlink+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)freadlink + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_freadlink=yes +else case e in #( + e) ac_cv_func_freadlink=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_freadlink" >&5 +printf "%s\n" "$ac_cv_func_freadlink" >&6; } + if test "x$ac_cv_func_freadlink" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_FREADLINK 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for strerror_r" >&5 +printf %s "checking for strerror_r... " >&6; } +if test ${ac_cv_func_strerror_r+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)strerror_r + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_strerror_r=yes +else case e in #( + e) ac_cv_func_strerror_r=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strerror_r" >&5 +printf "%s\n" "$ac_cv_func_strerror_r" >&6; } + if test "x$ac_cv_func_strerror_r" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_STRERROR_R 1" >>confdefs.h + +fi + + + + +# FreeBSD pthread_attr_get_np() + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_attr_get_np" >&5 +printf %s "checking for pthread_attr_get_np... " >&6; } +if test ${ac_cv_func_pthread_attr_get_np+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)pthread_attr_get_np + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_pthread_attr_get_np=yes +else case e in #( + e) ac_cv_func_pthread_attr_get_np=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_pthread_attr_get_np" >&5 +printf "%s\n" "$ac_cv_func_pthread_attr_get_np" >&6; } + if test "x$ac_cv_func_pthread_attr_get_np" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_PTHREAD_ATTR_GET_NP 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getdents64" >&5 +printf %s "checking for getdents64... " >&6; } +if test ${ac_cv_func_getdents64+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)getdents64 + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_getdents64=yes +else case e in #( + e) ac_cv_func_getdents64=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getdents64" >&5 +printf "%s\n" "$ac_cv_func_getdents64" >&6; } + if test "x$ac_cv_func_getdents64" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_GETDENTS64 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gettid" >&5 +printf %s "checking for gettid... " >&6; } +if test ${ac_cv_func_gettid+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)gettid + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_gettid=yes +else case e in #( + e) ac_cv_func_gettid=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_gettid" >&5 +printf "%s\n" "$ac_cv_func_gettid" >&6; } + if test "x$ac_cv_func_gettid" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_GETTID 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for if_indextoname" >&5 +printf %s "checking for if_indextoname... " >&6; } +if test ${ac_cv_func_if_indextoname+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)if_indextoname + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_if_indextoname=yes +else case e in #( + e) ac_cv_func_if_indextoname=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_if_indextoname" >&5 +printf "%s\n" "$ac_cv_func_if_indextoname" >&6; } + if test "x$ac_cv_func_if_indextoname" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_IF_INDEXTONAME 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for if_nametoindex" >&5 +printf %s "checking for if_nametoindex... " >&6; } +if test ${ac_cv_func_if_nametoindex+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)if_nametoindex + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_if_nametoindex=yes +else case e in #( + e) ac_cv_func_if_nametoindex=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_if_nametoindex" >&5 +printf "%s\n" "$ac_cv_func_if_nametoindex" >&6; } + if test "x$ac_cv_func_if_nametoindex" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_IF_NAMETOINDEX 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pidfd_open" >&5 +printf %s "checking for pidfd_open... " >&6; } +if test ${ac_cv_func_pidfd_open+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)pidfd_open + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_pidfd_open=yes +else case e in #( + e) ac_cv_func_pidfd_open=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_pidfd_open" >&5 +printf "%s\n" "$ac_cv_func_pidfd_open" >&6; } + if test "x$ac_cv_func_pidfd_open" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_PIDFD_OPEN 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pidfd_getfd" >&5 +printf %s "checking for pidfd_getfd... " >&6; } +if test ${ac_cv_func_pidfd_getfd+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)pidfd_getfd + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_pidfd_getfd=yes +else case e in #( + e) ac_cv_func_pidfd_getfd=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_pidfd_getfd" >&5 +printf "%s\n" "$ac_cv_func_pidfd_getfd" >&6; } + if test "x$ac_cv_func_pidfd_getfd" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_PIDFD_GETFD 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pidfd_send_signal" >&5 +printf %s "checking for pidfd_send_signal... " >&6; } +if test ${ac_cv_func_pidfd_send_signal+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)pidfd_send_signal + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_pidfd_send_signal=yes +else case e in #( + e) ac_cv_func_pidfd_send_signal=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_pidfd_send_signal" >&5 +printf "%s\n" "$ac_cv_func_pidfd_send_signal" >&6; } + if test "x$ac_cv_func_pidfd_send_signal" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_PIDFD_SEND_SIGNAL 1" >>confdefs.h + +fi + + + + + # os.statx uses Linux's statx function. AIX also has a function named statx, # but it's unrelated. Check only on Linux (including Android). case $ac_sys_system in #( @@ -21352,12 +22398,41 @@ fi fi -# iOS defines some system methods that can be linked (so they are +# iOS/tvOS/visionOS/watchOS define some system methods that can be linked (so they are # found by configure), but either raise a compilation error (because the # header definition prevents usage - autoconf doesn't use the headers), or # raise an error if used at runtime. Force these symbols off. -if test "$ac_sys_system" != "iOS" ; then - ac_fn_c_check_func "$LINENO" "dup3" "ac_cv_func_dup3" +# In particular, dup3 and pipe2 are available as of iOS/tvOS/watchOS/visionOS 27 but were +# incorrectly detected in older simulator versions. +case "$ac_sys_system" in + iOS|tvOS|watchOS|visionOS) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if iOS SDK is older than 27" >&5 +printf %s "checking if iOS SDK is older than 27... " >&6; } + ios_sdk_version=$(xcrun --sdk iphoneos --show-sdk-version 2>/dev/null | cut -d. -f1) + if test -n "$ios_sdk_version" && test "$ios_sdk_version" -ge 27; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + ac_fn_c_check_func "$LINENO" "dup3" "ac_cv_func_dup3" +if test "x$ac_cv_func_dup3" = xyes +then : + printf "%s\n" "#define HAVE_DUP3 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "pipe2" "ac_cv_func_pipe2" +if test "x$ac_cv_func_pipe2" = xyes +then : + printf "%s\n" "#define HAVE_PIPE2 1" >>confdefs.h + +fi + + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + fi + ;; + *) + # not iOS/tvOS/watchOS/visionOS + ac_fn_c_check_func "$LINENO" "dup3" "ac_cv_func_dup3" if test "x$ac_cv_func_dup3" = xyes then : printf "%s\n" "#define HAVE_DUP3 1" >>confdefs.h @@ -21386,6 +22461,54 @@ if test "x$ac_cv_func_system" = xyes then : printf "%s\n" "#define HAVE_SYSTEM 1" >>confdefs.h +fi + + ;; +esac + +# tvOS/watchOS have some additional methods that can be found, but not used. +if test "$ac_sys_system" != "tvOS" -a "$ac_sys_system" != "watchOS" ; then + ac_fn_c_check_func "$LINENO" "execv" "ac_cv_func_execv" +if test "x$ac_cv_func_execv" = xyes +then : + printf "%s\n" "#define HAVE_EXECV 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "fork" "ac_cv_func_fork" +if test "x$ac_cv_func_fork" = xyes +then : + printf "%s\n" "#define HAVE_FORK 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "fork1" "ac_cv_func_fork1" +if test "x$ac_cv_func_fork1" = xyes +then : + printf "%s\n" "#define HAVE_FORK1 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "posix_spawn" "ac_cv_func_posix_spawn" +if test "x$ac_cv_func_posix_spawn" = xyes +then : + printf "%s\n" "#define HAVE_POSIX_SPAWN 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "posix_spawnp" "ac_cv_func_posix_spawnp" +if test "x$ac_cv_func_posix_spawnp" = xyes +then : + printf "%s\n" "#define HAVE_POSIX_SPAWNP 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "posix_spawn_file_actions_addclosefrom_np" "ac_cv_func_posix_spawn_file_actions_addclosefrom_np" +if test "x$ac_cv_func_posix_spawn_file_actions_addclosefrom_np" = xyes +then : + printf "%s\n" "#define HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSEFROM_NP 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "sigaltstack" "ac_cv_func_sigaltstack" +if test "x$ac_cv_func_sigaltstack" = xyes +then : + printf "%s\n" "#define HAVE_SIGALTSTACK 1" >>confdefs.h + fi fi @@ -21416,7 +22539,7 @@ else case e in #( int main (void) { -void *x=chroot +(void)chroot ; return 0; } @@ -21457,7 +22580,7 @@ else case e in #( int main (void) { -void *x=link +(void)link ; return 0; } @@ -21498,7 +22621,7 @@ else case e in #( int main (void) { -void *x=symlink +(void)symlink ; return 0; } @@ -21539,7 +22662,7 @@ else case e in #( int main (void) { -void *x=fchdir +(void)fchdir ; return 0; } @@ -21580,7 +22703,7 @@ else case e in #( int main (void) { -void *x=fsync +(void)fsync ; return 0; } @@ -21621,7 +22744,7 @@ else case e in #( int main (void) { -void *x=fdatasync +(void)fdatasync ; return 0; } @@ -21685,7 +22808,7 @@ else case e in #( int main (void) { -void *x=epoll_create +(void)epoll_create ; return 0; } @@ -21726,7 +22849,7 @@ else case e in #( int main (void) { -void *x=epoll_create1 +(void)epoll_create1 ; return 0; } @@ -21772,7 +22895,7 @@ else case e in #( int main (void) { -void *x=kqueue +(void)kqueue ; return 0; } @@ -21816,7 +22939,7 @@ else case e in #( int main (void) { -void *x=prlimit +(void)prlimit ; return 0; } @@ -21858,7 +22981,7 @@ else case e in #( int main (void) { -void *x=_dyld_shared_cache_contains_path +(void)_dyld_shared_cache_contains_path ; return 0; } @@ -21907,7 +23030,7 @@ else case e in #( int main (void) { -void *x=memfd_create +(void)memfd_create ; return 0; } @@ -21953,7 +23076,7 @@ else case e in #( int main (void) { -void *x=eventfd +(void)eventfd ; return 0; } @@ -21999,7 +23122,7 @@ else case e in #( int main (void) { -void *x=timerfd_create +(void)timerfd_create ; return 0; } @@ -22047,7 +23170,7 @@ else case e in #( int main (void) { -void *x=ctermid_r +(void)ctermid_r ; return 0; } @@ -22186,7 +23309,7 @@ else case e in #( int main (void) { -void *x=getpagesize +(void)getpagesize ; return 0; } @@ -22621,6 +23744,30 @@ fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --with-zlib" >&5 +printf %s "checking for --with-zlib... " >&6; } + +# Check whether --with-zlib was given. +if test ${with_zlib+y} +then : + withval=$with_zlib; case $with_zlib in #( + yes|auto) : + with_zlib=auto ;; #( + zlib|zlib-ng|zlib-rs|no) : + ;; #( + *) : + as_fn_error $? "proper usage is --with(out)-zlib[=zlib|zlib-ng|zlib-rs|no]" "$LINENO" 5 ;; +esac +else case e in #( + e) with_zlib=auto ;; +esac +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_zlib" >&5 +printf "%s\n" "$with_zlib" >&6; } + +case $with_zlib in #( + auto|zlib) : @@ -22633,23 +23780,47 @@ then : fi + ;; #( + *) : + ;; +esac + +if test "x$with_zlib" = xzlib-rs +then : + + zlib_name="libz_rs" + zlib_version="0.6.0" + zlib_libname="z_rs" +else case e in #( + e) + zlib_name="zlib" + zlib_version="1.2.2.1" + zlib_libname="z" + ;; +esac +fi +if test "x$with_zlib" = xno +then : + have_zlib=no +else case e in #( + e) pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib >= 1.2.2.1" >&5 -printf %s "checking for zlib >= 1.2.2.1... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $zlib_name >= $zlib_version" >&5 +printf %s "checking for $zlib_name >= $zlib_version... " >&6; } if test -n "$ZLIB_CFLAGS"; then pkg_cv_ZLIB_CFLAGS="$ZLIB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib >= 1.2.2.1\""; } >&5 - ($PKG_CONFIG --exists --print-errors "zlib >= 1.2.2.1") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$zlib_name >= \$zlib_version\""; } >&5 + ($PKG_CONFIG --exists --print-errors "$zlib_name >= $zlib_version") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_ZLIB_CFLAGS=`$PKG_CONFIG --cflags "zlib >= 1.2.2.1" 2>/dev/null` + pkg_cv_ZLIB_CFLAGS=`$PKG_CONFIG --cflags "$zlib_name >= $zlib_version" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -22661,12 +23832,12 @@ if test -n "$ZLIB_LIBS"; then pkg_cv_ZLIB_LIBS="$ZLIB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib >= 1.2.2.1\""; } >&5 - ($PKG_CONFIG --exists --print-errors "zlib >= 1.2.2.1") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$zlib_name >= \$zlib_version\""; } >&5 + ($PKG_CONFIG --exists --print-errors "$zlib_name >= $zlib_version") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_ZLIB_LIBS=`$PKG_CONFIG --libs "zlib >= 1.2.2.1" 2>/dev/null` + pkg_cv_ZLIB_LIBS=`$PKG_CONFIG --libs "$zlib_name >= $zlib_version" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -22687,9 +23858,9 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - ZLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "zlib >= 1.2.2.1" 2>&1` + ZLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$zlib_name >= $zlib_version" 2>&1` else - ZLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "zlib >= 1.2.2.1" 2>&1` + ZLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$zlib_name >= $zlib_version" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$ZLIB_PKG_ERRORS" >&5 @@ -22711,14 +23882,15 @@ then : printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h py_check_lib_save_LIBS=$LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 -printf %s "checking for gzread in -lz... " >&6; } -if test ${ac_cv_lib_z_gzread+y} +as_ac_Lib=`printf "%s\n" "ac_cv_lib_$zlib_libname""_gzread" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -l$zlib_libname" >&5 +printf %s "checking for gzread in -l$zlib_libname... " >&6; } +if eval test \${$as_ac_Lib+y} then : printf %s "(cached) " >&6 else case e in #( e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" +LIBS="-l$zlib_libname $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -22742,9 +23914,9 @@ return gzread (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_z_gzread=yes + eval "$as_ac_Lib=yes" else case e in #( - e) ac_cv_lib_z_gzread=no ;; + e) eval "$as_ac_Lib=no" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ @@ -22752,9 +23924,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ LIBS=$ac_check_lib_save_LIBS ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzread" >&5 -printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } -if test "x$ac_cv_lib_z_gzread" = xyes +eval ac_res=\$$as_ac_Lib + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes" then : have_zlib=yes else case e in #( @@ -22775,16 +23948,17 @@ done then : ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + ZLIB_LIBS=${ZLIB_LIBS-"-l$zlib_libname"} py_check_lib_save_LIBS=$LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 -printf %s "checking for inflateCopy in -lz... " >&6; } -if test ${ac_cv_lib_z_inflateCopy+y} +as_ac_Lib=`printf "%s\n" "ac_cv_lib_$zlib_libname""_inflateCopy" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -l$zlib_libname" >&5 +printf %s "checking for inflateCopy in -l$zlib_libname... " >&6; } +if eval test \${$as_ac_Lib+y} then : printf %s "(cached) " >&6 else case e in #( e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" +LIBS="-l$zlib_libname $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -22808,9 +23982,9 @@ return inflateCopy (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_z_inflateCopy=yes + eval "$as_ac_Lib=yes" else case e in #( - e) ac_cv_lib_z_inflateCopy=no ;; + e) eval "$as_ac_Lib=no" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ @@ -22818,9 +23992,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ LIBS=$ac_check_lib_save_LIBS ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflateCopy" >&5 -printf "%s\n" "$ac_cv_lib_z_inflateCopy" >&6; } -if test "x$ac_cv_lib_z_inflateCopy" = xyes +eval ac_res=\$$as_ac_Lib + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes" then : printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h @@ -22858,14 +24033,15 @@ then : printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h py_check_lib_save_LIBS=$LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 -printf %s "checking for gzread in -lz... " >&6; } -if test ${ac_cv_lib_z_gzread+y} +as_ac_Lib=`printf "%s\n" "ac_cv_lib_$zlib_libname""_gzread" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -l$zlib_libname" >&5 +printf %s "checking for gzread in -l$zlib_libname... " >&6; } +if eval test \${$as_ac_Lib+y} then : printf %s "(cached) " >&6 else case e in #( e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" +LIBS="-l$zlib_libname $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -22889,9 +24065,9 @@ return gzread (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_z_gzread=yes + eval "$as_ac_Lib=yes" else case e in #( - e) ac_cv_lib_z_gzread=no ;; + e) eval "$as_ac_Lib=no" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ @@ -22899,9 +24075,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ LIBS=$ac_check_lib_save_LIBS ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzread" >&5 -printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } -if test "x$ac_cv_lib_z_gzread" = xyes +eval ac_res=\$$as_ac_Lib + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes" then : have_zlib=yes else case e in #( @@ -22922,16 +24099,17 @@ done then : ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + ZLIB_LIBS=${ZLIB_LIBS-"-l$zlib_libname"} py_check_lib_save_LIBS=$LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 -printf %s "checking for inflateCopy in -lz... " >&6; } -if test ${ac_cv_lib_z_inflateCopy+y} +as_ac_Lib=`printf "%s\n" "ac_cv_lib_$zlib_libname""_inflateCopy" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -l$zlib_libname" >&5 +printf %s "checking for inflateCopy in -l$zlib_libname... " >&6; } +if eval test \${$as_ac_Lib+y} then : printf %s "(cached) " >&6 else case e in #( e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" +LIBS="-l$zlib_libname $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -22955,9 +24133,9 @@ return inflateCopy (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_z_inflateCopy=yes + eval "$as_ac_Lib=yes" else case e in #( - e) ac_cv_lib_z_inflateCopy=no ;; + e) eval "$as_ac_Lib=no" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ @@ -22965,9 +24143,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ LIBS=$ac_check_lib_save_LIBS ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflateCopy" >&5 -printf "%s\n" "$ac_cv_lib_z_inflateCopy" >&6; } -if test "x$ac_cv_lib_z_inflateCopy" = xyes +eval ac_res=\$$as_ac_Lib + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes" then : printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h @@ -22995,8 +24174,53 @@ printf "%s\n" "yes" >&6; } printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h +fi + ;; +esac fi +if test "x$with_zlib" = xzlib-ng +then : + if test "x$have_zlib" = xyes +then : + + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" + ac_fn_check_decl "$LINENO" "ZLIBNG_VERSION" "ac_cv_have_decl_ZLIBNG_VERSION" "#include +" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_ZLIBNG_VERSION" = xyes +then : + +else case e in #( + e) as_fn_error $? "--with-zlib=zlib-ng: the detected zlib library is not zlib-ng" "$LINENO" 5 ;; +esac +fi + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + + +fi +fi + +case $with_zlib in #( + auto|no) : + ;; #( + *) : + if test "x$have_zlib" = xno +then : + as_fn_error $? "--with-zlib=$with_zlib requested but $zlib_name was not found" "$LINENO" 5 +fi ;; +esac + if test "x$have_zlib" = xyes then : @@ -23005,6 +24229,30 @@ then : fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --with-bzip2" >&5 +printf %s "checking for --with-bzip2... " >&6; } + +# Check whether --with-bzip2 was given. +if test ${with_bzip2+y} +then : + withval=$with_bzip2; case $with_bzip2 in #( + yes|auto) : + with_bzip2=auto ;; #( + bzip2|bzip2-rs|no) : + ;; #( + *) : + as_fn_error $? "proper usage is --with(out)-bzip2[=bzip2|bzip2-rs|no]" "$LINENO" 5 ;; +esac +else case e in #( + e) with_bzip2=auto ;; +esac +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_bzip2" >&5 +printf "%s\n" "$with_bzip2" >&6; } + +case $with_bzip2 in #( + auto|bzip2) : @@ -23017,23 +24265,45 @@ then : fi + ;; #( + *) : + ;; +esac + +if test "x$with_bzip2" = xbzip2-rs +then : + + bzip2_name="libbz2_rs" + bzip2_libname="bz2_rs" +else case e in #( + e) + bzip2_name="bzip2" + bzip2_libname="bz2" + ;; +esac +fi +if test "x$with_bzip2" = xno +then : + have_bzip2=no +else case e in #( + e) pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bzip2" >&5 -printf %s "checking for bzip2... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $bzip2_name" >&5 +printf %s "checking for $bzip2_name... " >&6; } if test -n "$BZIP2_CFLAGS"; then pkg_cv_BZIP2_CFLAGS="$BZIP2_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bzip2\""; } >&5 - ($PKG_CONFIG --exists --print-errors "bzip2") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$bzip2_name\""; } >&5 + ($PKG_CONFIG --exists --print-errors "$bzip2_name") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_BZIP2_CFLAGS=`$PKG_CONFIG --cflags "bzip2" 2>/dev/null` + pkg_cv_BZIP2_CFLAGS=`$PKG_CONFIG --cflags "$bzip2_name" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -23045,12 +24315,12 @@ if test -n "$BZIP2_LIBS"; then pkg_cv_BZIP2_LIBS="$BZIP2_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bzip2\""; } >&5 - ($PKG_CONFIG --exists --print-errors "bzip2") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$bzip2_name\""; } >&5 + ($PKG_CONFIG --exists --print-errors "$bzip2_name") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_BZIP2_LIBS=`$PKG_CONFIG --libs "bzip2" 2>/dev/null` + pkg_cv_BZIP2_LIBS=`$PKG_CONFIG --libs "$bzip2_name" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -23071,9 +24341,9 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - BZIP2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "bzip2" 2>&1` + BZIP2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$bzip2_name" 2>&1` else - BZIP2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "bzip2" 2>&1` + BZIP2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$bzip2_name" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$BZIP2_PKG_ERRORS" >&5 @@ -23094,14 +24364,15 @@ if test "x$ac_cv_header_bzlib_h" = xyes then : printf "%s\n" "#define HAVE_BZLIB_H 1" >>confdefs.h - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -lbz2" >&5 -printf %s "checking for BZ2_bzCompress in -lbz2... " >&6; } -if test ${ac_cv_lib_bz2_BZ2_bzCompress+y} + as_ac_Lib=`printf "%s\n" "ac_cv_lib_$bzip2_libname""_BZ2_bzCompress" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -l$bzip2_libname" >&5 +printf %s "checking for BZ2_bzCompress in -l$bzip2_libname... " >&6; } +if eval test \${$as_ac_Lib+y} then : printf %s "(cached) " >&6 else case e in #( e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lbz2 $LIBS" +LIBS="-l$bzip2_libname $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -23125,9 +24396,9 @@ return BZ2_bzCompress (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_bz2_BZ2_bzCompress=yes + eval "$as_ac_Lib=yes" else case e in #( - e) ac_cv_lib_bz2_BZ2_bzCompress=no ;; + e) eval "$as_ac_Lib=no" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ @@ -23135,9 +24406,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ LIBS=$ac_check_lib_save_LIBS ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bz2_BZ2_bzCompress" >&5 -printf "%s\n" "$ac_cv_lib_bz2_BZ2_bzCompress" >&6; } -if test "x$ac_cv_lib_bz2_BZ2_bzCompress" = xyes +eval ac_res=\$$as_ac_Lib + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes" then : have_bzip2=yes else case e in #( @@ -23156,7 +24428,7 @@ done then : BZIP2_CFLAGS=${BZIP2_CFLAGS-""} - BZIP2_LIBS=${BZIP2_LIBS-"-lbz2"} + BZIP2_LIBS=${BZIP2_LIBS-"-l$bzip2_libname"} fi @@ -23186,14 +24458,15 @@ if test "x$ac_cv_header_bzlib_h" = xyes then : printf "%s\n" "#define HAVE_BZLIB_H 1" >>confdefs.h - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -lbz2" >&5 -printf %s "checking for BZ2_bzCompress in -lbz2... " >&6; } -if test ${ac_cv_lib_bz2_BZ2_bzCompress+y} + as_ac_Lib=`printf "%s\n" "ac_cv_lib_$bzip2_libname""_BZ2_bzCompress" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -l$bzip2_libname" >&5 +printf %s "checking for BZ2_bzCompress in -l$bzip2_libname... " >&6; } +if eval test \${$as_ac_Lib+y} then : printf %s "(cached) " >&6 else case e in #( e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lbz2 $LIBS" +LIBS="-l$bzip2_libname $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -23217,9 +24490,9 @@ return BZ2_bzCompress (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_bz2_BZ2_bzCompress=yes + eval "$as_ac_Lib=yes" else case e in #( - e) ac_cv_lib_bz2_BZ2_bzCompress=no ;; + e) eval "$as_ac_Lib=no" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ @@ -23227,9 +24500,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ LIBS=$ac_check_lib_save_LIBS ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bz2_BZ2_bzCompress" >&5 -printf "%s\n" "$ac_cv_lib_bz2_BZ2_bzCompress" >&6; } -if test "x$ac_cv_lib_bz2_BZ2_bzCompress" = xyes +eval ac_res=\$$as_ac_Lib + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes" then : have_bzip2=yes else case e in #( @@ -23248,7 +24522,7 @@ done then : BZIP2_CFLAGS=${BZIP2_CFLAGS-""} - BZIP2_LIBS=${BZIP2_LIBS-"-lbz2"} + BZIP2_LIBS=${BZIP2_LIBS-"-l$bzip2_libname"} fi @@ -23266,6 +24540,19 @@ else printf "%s\n" "yes" >&6; } have_bzip2=yes fi + ;; +esac +fi + +case $with_bzip2 in #( + auto|no) : + ;; #( + *) : + if test "x$have_bzip2" = xno +then : + as_fn_error $? "--with-bzip2=$with_bzip2 requested but $bzip2_name was not found" "$LINENO" 5 +fi ;; +esac pkg_failed=no @@ -23909,7 +25196,7 @@ else case e in #( int main (void) { -void *x=hstrerror +(void)hstrerror ; return 0; } @@ -23950,7 +25237,7 @@ else case e in #( int main (void) { -void *x=getservbyname +(void)getservbyname ; return 0; } @@ -23991,7 +25278,7 @@ else case e in #( int main (void) { -void *x=getservbyport +(void)getservbyport ; return 0; } @@ -24032,7 +25319,7 @@ else case e in #( int main (void) { -void *x=gethostbyname +(void)gethostbyname ; return 0; } @@ -24073,7 +25360,7 @@ else case e in #( int main (void) { -void *x=gethostbyaddr +(void)gethostbyaddr ; return 0; } @@ -24114,7 +25401,7 @@ else case e in #( int main (void) { -void *x=getprotobyname +(void)getprotobyname ; return 0; } @@ -24163,7 +25450,7 @@ else case e in #( int main (void) { -void *x=inet_aton +(void)inet_aton ; return 0; } @@ -24209,7 +25496,7 @@ else case e in #( int main (void) { -void *x=inet_ntoa +(void)inet_ntoa ; return 0; } @@ -24255,7 +25542,7 @@ else case e in #( int main (void) { -void *x=inet_pton +(void)inet_pton ; return 0; } @@ -24301,7 +25588,7 @@ else case e in #( int main (void) { -void *x=getpeername +(void)getpeername ; return 0; } @@ -24347,7 +25634,7 @@ else case e in #( int main (void) { -void *x=getsockname +(void)getsockname ; return 0; } @@ -24393,7 +25680,7 @@ else case e in #( int main (void) { -void *x=accept +(void)accept ; return 0; } @@ -24439,7 +25726,7 @@ else case e in #( int main (void) { -void *x=bind +(void)bind ; return 0; } @@ -24485,7 +25772,7 @@ else case e in #( int main (void) { -void *x=connect +(void)connect ; return 0; } @@ -24531,7 +25818,7 @@ else case e in #( int main (void) { -void *x=listen +(void)listen ; return 0; } @@ -24577,7 +25864,7 @@ else case e in #( int main (void) { -void *x=recvfrom +(void)recvfrom ; return 0; } @@ -24623,7 +25910,7 @@ else case e in #( int main (void) { -void *x=sendto +(void)sendto ; return 0; } @@ -24669,7 +25956,7 @@ else case e in #( int main (void) { -void *x=setsockopt +(void)setsockopt ; return 0; } @@ -24715,7 +26002,7 @@ else case e in #( int main (void) { -void *x=socket +(void)socket ; return 0; } @@ -24763,7 +26050,7 @@ else case e in #( int main (void) { -void *x=setgroups +(void)setgroups ; return 0; } @@ -24817,12 +26104,14 @@ printf "%s\n" "#define HAVE_UT_NAMESIZE 1" >>confdefs.h fi -# musl libc redefines struct prctl_mm_map and conflicts with linux/prctl.h -if test "$ac_cv_libc" != musl -then : - -ac_fn_check_decl "$LINENO" "PR_SET_VMA_ANON_NAME" "ac_cv_have_decl_PR_SET_VMA_ANON_NAME" "#include - #include +# musl libc redefines struct prctl_mm_map and conflicts with linux/prctl.h. +# The conftest does not reliably catch this, so skip the check on musl. +case $host in #( + *-musl*) : + ;; #( + *) : + ac_fn_check_decl "$LINENO" "PR_SET_VMA_ANON_NAME" "ac_cv_have_decl_PR_SET_VMA_ANON_NAME" "#include + #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_PR_SET_VMA_ANON_NAME" = xyes then : @@ -24839,10 +26128,11 @@ printf "%s\n" "#define _Py_HAVE_PR_SET_VMA_ANON_NAME 1" >>confdefs.h fi - -fi + ;; +esac # check for openpty, login_tty, and forkpty - +# tvOS/watchOS have functions for tty, but can't use them +if test "$ac_sys_system" != "tvOS" -a "$ac_sys_system" != "watchOS" ; then for ac_func in openpty do : @@ -24956,7 +26246,7 @@ esac fi done -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing login_tty" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing login_tty" >&5 printf %s "checking for library containing login_tty... " >&6; } if test ${ac_cv_search_login_tty+y} then : @@ -25139,14 +26429,9 @@ esac fi done +fi # check for long file support functions -ac_fn_c_check_func "$LINENO" "fseek64" "ac_cv_func_fseek64" -if test "x$ac_cv_func_fseek64" = xyes -then : - printf "%s\n" "#define HAVE_FSEEK64 1" >>confdefs.h - -fi ac_fn_c_check_func "$LINENO" "fseeko" "ac_cv_func_fseeko" if test "x$ac_cv_func_fseeko" = xyes then : @@ -25158,12 +26443,6 @@ if test "x$ac_cv_func_fstatvfs" = xyes then : printf "%s\n" "#define HAVE_FSTATVFS 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "ftell64" "ac_cv_func_ftell64" -if test "x$ac_cv_func_ftell64" = xyes -then : - printf "%s\n" "#define HAVE_FTELL64 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "ftello" "ac_cv_func_ftello" if test "x$ac_cv_func_ftello" = xyes @@ -25404,10 +26683,10 @@ fi done -# On Android and iOS, clock_settime can be linked (so it is found by +# On Android, iOS, tvOS, visionOS, and watchOS, clock_settime can be linked (so it is found by # configure), but when used in an unprivileged process, it crashes rather than # returning an error. Force the symbol off. -if test "$ac_sys_system" != "Linux-android" && test "$ac_sys_system" != "iOS" +if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "iOS" -a "$ac_sys_system" != "tvOS" -a "$ac_sys_system" != "visionOS" -a "$ac_sys_system" != "watchOS" then for ac_func in clock_settime @@ -25724,7 +27003,7 @@ else case e in #( e) if test "$cross_compiling" = yes then : -if test "$ac_sys_system" = "Linux-android" || test "$ac_sys_system" = "iOS"; then +if test "$ac_sys_system" = "Linux-android" || test "$ac_sys_system" = "iOS" || test "$ac_sys_system" = "tvOS" || test "$ac_sys_system" = "visionOS" || test "$ac_sys_system" = "watchOS"; then ac_cv_buggy_getaddrinfo="no" elif test "${enable_ipv6+set}" = set; then ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6" @@ -26280,175 +27559,6 @@ printf "%s\n" "#define HAVE_SOCKADDR_ALG 1" >>confdefs.h fi -# checks for compiler characteristics - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 -printf %s "checking for an ANSI C-conforming const... " >&6; } -if test ${ac_cv_c_const+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - -#ifndef __cplusplus - /* Ultrix mips cc rejects this sort of thing. */ - typedef int charset[2]; - const charset cs = { 0, 0 }; - /* SunOS 4.1.1 cc rejects this. */ - char const *const *pcpcc; - char **ppc; - /* NEC SVR4.0.2 mips cc rejects this. */ - struct point {int x, y;}; - static struct point const zero = {0,0}; - /* IBM XL C 1.02.0.0 rejects this. - It does not let you subtract one const X* pointer from another in - an arm of an if-expression whose if-part is not a constant - expression */ - const char *g = "string"; - pcpcc = &g + (g ? g-g : 0); - /* HPUX 7.0 cc rejects these. */ - ++pcpcc; - ppc = (char**) pcpcc; - pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this sort of thing. */ - char tx; - char *t = &tx; - char const *s = 0 ? (char *) 0 : (char const *) 0; - - *t++ = 0; - if (s) return 0; - } - { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ - int x[] = {25, 17}; - const int *foo = &x[0]; - ++foo; - } - { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ - typedef const int *iptr; - iptr p = 0; - ++p; - } - { /* IBM XL C 1.02.0.0 rejects this sort of thing, saying - "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; } bx; - struct s *b = &bx; b->j = 5; - } - { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; - if (!foo) return 0; - } - return !cs[0] && !zero.x; -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_c_const=yes -else case e in #( - e) ac_cv_c_const=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 -printf "%s\n" "$ac_cv_c_const" >&6; } -if test $ac_cv_c_const = no; then - -printf "%s\n" "#define const /**/" >>confdefs.h - -fi - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working signed char" >&5 -printf %s "checking for working signed char... " >&6; } -if test ${ac_cv_working_signed_char_c+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ -signed char c; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_working_signed_char_c=yes -else case e in #( - e) ac_cv_working_signed_char_c=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_signed_char_c" >&5 -printf "%s\n" "$ac_cv_working_signed_char_c" >&6; } -if test "x$ac_cv_working_signed_char_c" = xno -then : - - -printf "%s\n" "#define signed /**/" >>confdefs.h - - -fi - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for prototypes" >&5 -printf %s "checking for prototypes... " >&6; } -if test ${ac_cv_function_prototypes+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int foo(int x) { return 0; } -int -main (void) -{ -return foo(10); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_function_prototypes=yes -else case e in #( - e) ac_cv_function_prototypes=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_function_prototypes" >&5 -printf "%s\n" "$ac_cv_function_prototypes" >&6; } -if test "x$ac_cv_function_prototypes" = xyes -then : - - -printf "%s\n" "#define HAVE_PROTOTYPES 1" >>confdefs.h - - -fi - - # check for socketpair @@ -26467,7 +27577,7 @@ else case e in #( int main (void) { -void *x=socketpair +(void)socketpair ; return 0; } @@ -26814,55 +27924,6 @@ esac fi -# ************************************** -# * Check for gcc x64 inline assembler * -# ************************************** - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for x64 gcc inline assembler" >&5 -printf %s "checking for x64 gcc inline assembler... " >&6; } -if test ${ac_cv_gcc_asm_for_x64+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - __asm__ __volatile__ ("movq %rcx, %rax"); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_gcc_asm_for_x64=yes -else case e in #( - e) ac_cv_gcc_asm_for_x64=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_gcc_asm_for_x64" >&5 -printf "%s\n" "$ac_cv_gcc_asm_for_x64" >&6; } - -if test "x$ac_cv_gcc_asm_for_x64" = xyes -then : - - -printf "%s\n" "#define HAVE_GCC_ASM_FOR_X64 1" >>confdefs.h - - -fi - # ************************************************** # * Check for various properties of floating point * # ************************************************** @@ -26938,8 +27999,8 @@ esac # rounding precision of 64 bits. For gcc/x86, we can fix this by # using inline assembler to get and set the x87 FPU control word. -# This inline assembler syntax may also work for suncc and icc, -# so we try it on all platforms. +# This inline assembler syntax works for icx and may also work for +# suncc and icc, so we try it on all platforms. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we can use gcc inline assembler to get and set x87 control word" >&5 printf %s "checking whether we can use gcc inline assembler to get and set x87 control word... " >&6; } @@ -27127,24 +28188,298 @@ fi done -ac_func= -for ac_item in $ac_func_c_list -do - if test $ac_func; then - ac_fn_c_check_func "$LINENO" $ac_func ac_cv_func_$ac_func - if eval test \"x\$ac_cv_func_$ac_func\" = xyes; then - echo "#define $ac_item 1" >> confdefs.h - fi - ac_func= - else - ac_func=$ac_item - fi -done + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for acospi" >&5 +printf %s "checking for acospi... " >&6; } +if test ${ac_cv_func_acospi+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)acospi + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_acospi=yes +else case e in #( + e) ac_cv_func_acospi=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_acospi" >&5 +printf "%s\n" "$ac_cv_func_acospi" >&6; } + if test "x$ac_cv_func_acospi" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_ACOSPI 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for asinpi" >&5 +printf %s "checking for asinpi... " >&6; } +if test ${ac_cv_func_asinpi+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)asinpi + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_asinpi=yes +else case e in #( + e) ac_cv_func_asinpi=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_asinpi" >&5 +printf "%s\n" "$ac_cv_func_asinpi" >&6; } + if test "x$ac_cv_func_asinpi" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_ASINPI 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for atanpi" >&5 +printf %s "checking for atanpi... " >&6; } +if test ${ac_cv_func_atanpi+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)atanpi + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_atanpi=yes +else case e in #( + e) ac_cv_func_atanpi=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_atanpi" >&5 +printf "%s\n" "$ac_cv_func_atanpi" >&6; } + if test "x$ac_cv_func_atanpi" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_ATANPI 1" >>confdefs.h + +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for atan2pi" >&5 +printf %s "checking for atan2pi... " >&6; } +if test ${ac_cv_func_atan2pi+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)atan2pi + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_atan2pi=yes +else case e in #( + e) ac_cv_func_atan2pi=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_atan2pi" >&5 +printf "%s\n" "$ac_cv_func_atan2pi" >&6; } + if test "x$ac_cv_func_atan2pi" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_ATAN2PI 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for cospi" >&5 +printf %s "checking for cospi... " >&6; } +if test ${ac_cv_func_cospi+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)cospi + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_cospi=yes +else case e in #( + e) ac_cv_func_cospi=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_cospi" >&5 +printf "%s\n" "$ac_cv_func_cospi" >&6; } + if test "x$ac_cv_func_cospi" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_COSPI 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sinpi" >&5 +printf %s "checking for sinpi... " >&6; } +if test ${ac_cv_func_sinpi+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)sinpi + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_sinpi=yes +else case e in #( + e) ac_cv_func_sinpi=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_sinpi" >&5 +printf "%s\n" "$ac_cv_func_sinpi" >&6; } + if test "x$ac_cv_func_sinpi" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_SINPI 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tanpi" >&5 +printf %s "checking for tanpi... " >&6; } +if test ${ac_cv_func_tanpi+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +(void)tanpi + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_tanpi=yes +else case e in #( + e) ac_cv_func_tanpi=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_tanpi" >&5 +printf "%s\n" "$ac_cv_func_tanpi" >&6; } + if test "x$ac_cv_func_tanpi" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_TANPI 1" >>confdefs.h + +fi + + LIBS=$LIBS_SAVE @@ -27806,22 +29141,25 @@ LDVERSION='$(VERSION)$(ABIFLAGS)' printf "%s\n" "$LDVERSION" >&6; } # Configure the flags and dependencies used when compiling shared modules. -# Do not rename LIBPYTHON - it's accessed via sysconfig by package build -# systems (e.g. Meson) to decide whether to link extension modules against -# libpython. MODULE_DEPS_SHARED='$(MODULE_DEPS_STATIC) $(EXPORTSYMS)' + +# On most platforms, extension modules aren't linked against libpython, so +# LIBPYTHON must be empty. LIBPYTHON='' # On Android and Cygwin the shared libraries must be linked with libpython. +# LIBPYTHON is used by python-config, python3.pc, the commands for building the +# stdlib's own extension modules, and external package build systems via +# sysconfig, so its value must be suitable for all those contexts. if test "$PY_ENABLE_SHARED" = "1" && ( test -n "$ANDROID_API_LEVEL" || test "$MACHDEP" = "cygwin"); then MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(LDLIBRARY)" - LIBPYTHON="\$(BLDLIBRARY)" + LIBPYTHON="-lpython${VERSION}${ABIFLAGS}" fi -# On iOS the shared libraries must be linked with the Python framework -if test "$ac_sys_system" = "iOS"; then +# On iOS/tvOS/watchOS the shared libraries must be linked with the framework, when built +if test "$ac_sys_system" = "iOS" -o "$ac_sys_system" = "tvOS" -o "$ac_sys_system" = "visionOS" -o "$ac_sys_system" = "watchOS" && test "$enable_framework"; then MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(PYTHONFRAMEWORKDIR)/\$(PYTHONFRAMEWORK)" fi @@ -28783,7 +30121,7 @@ printf "%s\n" "$ac_cv_readline_rl_change_environment" >&6; } then : -printf "%s\n" "#define HAVE_RL_CHANGE_ENVIRONMENT 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_RL_CHANGE_ENVIRONMENT 1" >>confdefs.h fi @@ -29281,9 +30619,36 @@ fi have_curses=no have_panel=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --with-curses" >&5 +printf %s "checking for --with-curses... " >&6; } + +# Check whether --with-curses was given. +if test ${with_curses+y} +then : + withval=$with_curses; case $with_curses in #( + yes|auto) : + with_curses=auto ;; #( + ncursesw|ncurses|curses|no) : + ;; #( + *) : + as_fn_error $? "proper usage is --with(out)-curses[=ncursesw|ncurses|curses|no]" "$LINENO" 5 ;; +esac +else case e in #( + e) with_curses=auto ;; +esac +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_curses" >&5 +printf "%s\n" "$with_curses" >&6; } -# Check for ncursesw/panelw first. If that fails, try ncurses/panel. + +# Detect the selected backend. ncursesw/ncurses are found via pkg-config; +# native curses has no .pc file and is left to the header/link probes below. +# curses_libs/panel_libs drive the AC_SEARCH_LIBS fallback; for "no" they are +# empty so nothing links and have_curses stays "no". +case $with_curses in #( + ncursesw) : @@ -29418,11 +30783,151 @@ fi # Put the nasty error message in config.log where it belongs echo "$PANEL_PKG_ERRORS" >&5 + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gnupanel" >&5 +printf %s "checking for gnupanel... " >&6; } + +if test -n "$PANEL_CFLAGS"; then + pkg_cv_PANEL_CFLAGS="$PANEL_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_CFLAGS=`$PKG_CONFIG --cflags "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$PANEL_LIBS"; then + pkg_cv_PANEL_LIBS="$PANEL_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_LIBS=`$PKG_CONFIG --libs "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + PANEL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gnupanel" 2>&1` + else + PANEL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gnupanel" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$PANEL_PKG_ERRORS" >&5 + + have_panel=no +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + have_panel=no +else + PANEL_CFLAGS=$pkg_cv_PANEL_CFLAGS + PANEL_LIBS=$pkg_cv_PANEL_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + have_panel=yes +fi +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gnupanel" >&5 +printf %s "checking for gnupanel... " >&6; } + +if test -n "$PANEL_CFLAGS"; then + pkg_cv_PANEL_CFLAGS="$PANEL_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_CFLAGS=`$PKG_CONFIG --cflags "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$PANEL_LIBS"; then + pkg_cv_PANEL_LIBS="$PANEL_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_LIBS=`$PKG_CONFIG --libs "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + PANEL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gnupanel" 2>&1` + else + PANEL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gnupanel" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$PANEL_PKG_ERRORS" >&5 + have_panel=no elif test $pkg_failed = untried; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } have_panel=no +else + PANEL_CFLAGS=$pkg_cv_PANEL_CFLAGS + PANEL_LIBS=$pkg_cv_PANEL_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + have_panel=yes +fi else PANEL_CFLAGS=$pkg_cv_PANEL_CFLAGS PANEL_LIBS=$pkg_cv_PANEL_LIBS @@ -29436,8 +30941,8 @@ fi fi -if test "x$have_curses" = xno -then : + curses_libs="ncursesw"; panel_libs="panelw gnupanel" ;; #( + ncurses) : @@ -29572,6 +31077,65 @@ fi # Put the nasty error message in config.log where it belongs echo "$PANEL_PKG_ERRORS" >&5 + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gnupanel" >&5 +printf %s "checking for gnupanel... " >&6; } + +if test -n "$PANEL_CFLAGS"; then + pkg_cv_PANEL_CFLAGS="$PANEL_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_CFLAGS=`$PKG_CONFIG --cflags "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$PANEL_LIBS"; then + pkg_cv_PANEL_LIBS="$PANEL_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_LIBS=`$PKG_CONFIG --libs "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + PANEL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gnupanel" 2>&1` + else + PANEL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gnupanel" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$PANEL_PKG_ERRORS" >&5 + have_panel=no elif test $pkg_failed = untried; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 @@ -29582,249 +31146,1011 @@ else PANEL_LIBS=$pkg_cv_PANEL_LIBS { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } + have_panel=yes +fi +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } -printf "%s\n" "#define HAVE_PANEL 1" >>confdefs.h +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gnupanel" >&5 +printf %s "checking for gnupanel... " >&6; } - have_panel=yes +if test -n "$PANEL_CFLAGS"; then + pkg_cv_PANEL_CFLAGS="$PANEL_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_CFLAGS=`$PKG_CONFIG --cflags "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes fi + else + pkg_failed=untried fi - - +if test -n "$PANEL_LIBS"; then + pkg_cv_PANEL_LIBS="$PANEL_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_LIBS=`$PKG_CONFIG --libs "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes fi - -save_CFLAGS=$CFLAGS -save_CPPFLAGS=$CPPFLAGS -save_LDFLAGS=$LDFLAGS -save_LIBS=$LIBS - - - # Make sure we've got the header defines. - as_fn_append CPPFLAGS " $CURSES_CFLAGS $PANEL_CFLAGS" - ac_fn_c_check_header_compile "$LINENO" "ncursesw/curses.h" "ac_cv_header_ncursesw_curses_h" "$ac_includes_default" -if test "x$ac_cv_header_ncursesw_curses_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSESW_CURSES_H 1" >>confdefs.h - + else + pkg_failed=untried fi -ac_fn_c_check_header_compile "$LINENO" "ncursesw/ncurses.h" "ac_cv_header_ncursesw_ncurses_h" "$ac_includes_default" -if test "x$ac_cv_header_ncursesw_ncurses_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSESW_NCURSES_H 1" >>confdefs.h -fi -ac_fn_c_check_header_compile "$LINENO" "ncursesw/panel.h" "ac_cv_header_ncursesw_panel_h" "$ac_includes_default" -if test "x$ac_cv_header_ncursesw_panel_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSESW_PANEL_H 1" >>confdefs.h -fi -ac_fn_c_check_header_compile "$LINENO" "ncurses/curses.h" "ac_cv_header_ncurses_curses_h" "$ac_includes_default" -if test "x$ac_cv_header_ncurses_curses_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSES_CURSES_H 1" >>confdefs.h -fi -ac_fn_c_check_header_compile "$LINENO" "ncurses/ncurses.h" "ac_cv_header_ncurses_ncurses_h" "$ac_includes_default" -if test "x$ac_cv_header_ncurses_ncurses_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSES_NCURSES_H 1" >>confdefs.h +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no fi -ac_fn_c_check_header_compile "$LINENO" "ncurses/panel.h" "ac_cv_header_ncurses_panel_h" "$ac_includes_default" -if test "x$ac_cv_header_ncurses_panel_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSES_PANEL_H 1" >>confdefs.h + if test $_pkg_short_errors_supported = yes; then + PANEL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gnupanel" 2>&1` + else + PANEL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gnupanel" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$PANEL_PKG_ERRORS" >&5 + have_panel=no +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + have_panel=no +else + PANEL_CFLAGS=$pkg_cv_PANEL_CFLAGS + PANEL_LIBS=$pkg_cv_PANEL_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + have_panel=yes fi -ac_fn_c_check_header_compile "$LINENO" "curses.h" "ac_cv_header_curses_h" "$ac_includes_default" -if test "x$ac_cv_header_curses_h" = xyes -then : - printf "%s\n" "#define HAVE_CURSES_H 1" >>confdefs.h +else + PANEL_CFLAGS=$pkg_cv_PANEL_CFLAGS + PANEL_LIBS=$pkg_cv_PANEL_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } -fi -ac_fn_c_check_header_compile "$LINENO" "ncurses.h" "ac_cv_header_ncurses_h" "$ac_includes_default" -if test "x$ac_cv_header_ncurses_h" = xyes -then : - printf "%s\n" "#define HAVE_NCURSES_H 1" >>confdefs.h +printf "%s\n" "#define HAVE_PANEL 1" >>confdefs.h + have_panel=yes fi -ac_fn_c_check_header_compile "$LINENO" "panel.h" "ac_cv_header_panel_h" "$ac_includes_default" -if test "x$ac_cv_header_panel_h" = xyes -then : - printf "%s\n" "#define HAVE_PANEL_H 1" >>confdefs.h - fi - # Check that we're able to link with crucial curses/panel functions. This - # also serves as a fallback in case pkg-config failed. - as_fn_append LIBS " $CURSES_LIBS $PANEL_LIBS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing initscr" >&5 -printf %s "checking for library containing initscr... " >&6; } -if test ${ac_cv_search_initscr+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char initscr (void); -int -main (void) -{ -return initscr (); - ; - return 0; -} -_ACEOF -for ac_lib in '' ncursesw ncurses -do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO" -then : - ac_cv_search_initscr=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext - if test ${ac_cv_search_initscr+y} -then : - break -fi -done -if test ${ac_cv_search_initscr+y} -then : + curses_libs="ncurses"; panel_libs="panel gnupanel" ;; #( + curses) : + curses_libs="curses"; panel_libs="panel" ;; #( + no) : + curses_libs=""; panel_libs="" ;; #( + *) : -else case e in #( - e) ac_cv_search_initscr=no ;; -esac -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_initscr" >&5 -printf "%s\n" "$ac_cv_search_initscr" >&6; } -ac_res=$ac_cv_search_initscr -if test "$ac_res" != no -then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - if test "x$have_curses" = xno -then : - have_curses=yes - CURSES_LIBS=${CURSES_LIBS-"$ac_cv_search_initscr"} -fi -else case e in #( - e) have_curses=no ;; -esac -fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing update_panels" >&5 -printf %s "checking for library containing update_panels... " >&6; } -if test ${ac_cv_search_update_panels+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char update_panels (void); -int -main (void) -{ -return update_panels (); - ; - return 0; -} -_ACEOF -for ac_lib in '' panelw panel -do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO" -then : - ac_cv_search_update_panels=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext - if test ${ac_cv_search_update_panels+y} -then : - break -fi -done -if test ${ac_cv_search_update_panels+y} -then : +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ncursesw" >&5 +printf %s "checking for ncursesw... " >&6; } -else case e in #( - e) ac_cv_search_update_panels=no ;; -esac +if test -n "$CURSES_CFLAGS"; then + pkg_cv_CURSES_CFLAGS="$CURSES_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ncursesw\""; } >&5 + ($PKG_CONFIG --exists --print-errors "ncursesw") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_CURSES_CFLAGS=`$PKG_CONFIG --cflags "ncursesw" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS ;; -esac + else + pkg_failed=untried fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_update_panels" >&5 -printf "%s\n" "$ac_cv_search_update_panels" >&6; } -ac_res=$ac_cv_search_update_panels -if test "$ac_res" != no -then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - if test "x$have_panel" = xno -then : - have_panel=yes - PANEL_LIBS=${PANEL_LIBS-"$ac_cv_search_update_panels"} +if test -n "$CURSES_LIBS"; then + pkg_cv_CURSES_LIBS="$CURSES_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ncursesw\""; } >&5 + ($PKG_CONFIG --exists --print-errors "ncursesw") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_CURSES_LIBS=`$PKG_CONFIG --libs "ncursesw" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes fi -else case e in #( - e) have_panel=no ;; -esac + else + pkg_failed=untried fi +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } -if test "have_curses" != "no" -then : +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + CURSES_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "ncursesw" 2>&1` + else + CURSES_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "ncursesw" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$CURSES_PKG_ERRORS" >&5 -CURSES_CFLAGS=$(echo $CURSES_CFLAGS | sed 's/-D_XOPEN_SOURCE=600//g') + have_curses=no +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + have_curses=no +else + CURSES_CFLAGS=$pkg_cv_CURSES_CFLAGS + CURSES_LIBS=$pkg_cv_CURSES_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } -if test "x$ac_sys_system" = xDarwin -then : +printf "%s\n" "#define HAVE_NCURSESW 1" >>confdefs.h + have_curses=yes - as_fn_append CURSES_CFLAGS " -D_XOPEN_SOURCE_EXTENDED=1" +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for panelw" >&5 +printf %s "checking for panelw... " >&6; } +if test -n "$PANEL_CFLAGS"; then + pkg_cv_PANEL_CFLAGS="$PANEL_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"panelw\""; } >&5 + ($PKG_CONFIG --exists --print-errors "panelw") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_CFLAGS=`$PKG_CONFIG --cflags "panelw" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes fi - + else + pkg_failed=untried +fi +if test -n "$PANEL_LIBS"; then + pkg_cv_PANEL_LIBS="$PANEL_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"panelw\""; } >&5 + ($PKG_CONFIG --exists --print-errors "panelw") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_LIBS=`$PKG_CONFIG --libs "panelw" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + PANEL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "panelw" 2>&1` + else + PANEL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "panelw" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$PANEL_PKG_ERRORS" >&5 + + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gnupanel" >&5 +printf %s "checking for gnupanel... " >&6; } + +if test -n "$PANEL_CFLAGS"; then + pkg_cv_PANEL_CFLAGS="$PANEL_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_CFLAGS=`$PKG_CONFIG --cflags "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$PANEL_LIBS"; then + pkg_cv_PANEL_LIBS="$PANEL_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_LIBS=`$PKG_CONFIG --libs "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + PANEL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gnupanel" 2>&1` + else + PANEL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gnupanel" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$PANEL_PKG_ERRORS" >&5 + + have_panel=no +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + have_panel=no +else + PANEL_CFLAGS=$pkg_cv_PANEL_CFLAGS + PANEL_LIBS=$pkg_cv_PANEL_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + have_panel=yes +fi +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gnupanel" >&5 +printf %s "checking for gnupanel... " >&6; } + +if test -n "$PANEL_CFLAGS"; then + pkg_cv_PANEL_CFLAGS="$PANEL_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_CFLAGS=`$PKG_CONFIG --cflags "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$PANEL_LIBS"; then + pkg_cv_PANEL_LIBS="$PANEL_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_LIBS=`$PKG_CONFIG --libs "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + PANEL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gnupanel" 2>&1` + else + PANEL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gnupanel" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$PANEL_PKG_ERRORS" >&5 + + have_panel=no +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + have_panel=no +else + PANEL_CFLAGS=$pkg_cv_PANEL_CFLAGS + PANEL_LIBS=$pkg_cv_PANEL_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + have_panel=yes +fi +else + PANEL_CFLAGS=$pkg_cv_PANEL_CFLAGS + PANEL_LIBS=$pkg_cv_PANEL_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + +printf "%s\n" "#define HAVE_PANELW 1" >>confdefs.h + + have_panel=yes +fi +fi + + + if test "x$have_curses" = xno +then : + + + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ncurses" >&5 +printf %s "checking for ncurses... " >&6; } + +if test -n "$CURSES_CFLAGS"; then + pkg_cv_CURSES_CFLAGS="$CURSES_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ncurses\""; } >&5 + ($PKG_CONFIG --exists --print-errors "ncurses") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_CURSES_CFLAGS=`$PKG_CONFIG --cflags "ncurses" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$CURSES_LIBS"; then + pkg_cv_CURSES_LIBS="$CURSES_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ncurses\""; } >&5 + ($PKG_CONFIG --exists --print-errors "ncurses") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_CURSES_LIBS=`$PKG_CONFIG --libs "ncurses" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + CURSES_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "ncurses" 2>&1` + else + CURSES_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "ncurses" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$CURSES_PKG_ERRORS" >&5 + + have_curses=no +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + have_curses=no +else + CURSES_CFLAGS=$pkg_cv_CURSES_CFLAGS + CURSES_LIBS=$pkg_cv_CURSES_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + +printf "%s\n" "#define HAVE_NCURSES 1" >>confdefs.h + + have_curses=yes + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for panel" >&5 +printf %s "checking for panel... " >&6; } + +if test -n "$PANEL_CFLAGS"; then + pkg_cv_PANEL_CFLAGS="$PANEL_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"panel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "panel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_CFLAGS=`$PKG_CONFIG --cflags "panel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$PANEL_LIBS"; then + pkg_cv_PANEL_LIBS="$PANEL_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"panel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "panel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_LIBS=`$PKG_CONFIG --libs "panel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + PANEL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "panel" 2>&1` + else + PANEL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "panel" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$PANEL_PKG_ERRORS" >&5 + + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gnupanel" >&5 +printf %s "checking for gnupanel... " >&6; } + +if test -n "$PANEL_CFLAGS"; then + pkg_cv_PANEL_CFLAGS="$PANEL_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_CFLAGS=`$PKG_CONFIG --cflags "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$PANEL_LIBS"; then + pkg_cv_PANEL_LIBS="$PANEL_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_LIBS=`$PKG_CONFIG --libs "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + PANEL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gnupanel" 2>&1` + else + PANEL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gnupanel" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$PANEL_PKG_ERRORS" >&5 + + have_panel=no +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + have_panel=no +else + PANEL_CFLAGS=$pkg_cv_PANEL_CFLAGS + PANEL_LIBS=$pkg_cv_PANEL_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + have_panel=yes +fi +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gnupanel" >&5 +printf %s "checking for gnupanel... " >&6; } + +if test -n "$PANEL_CFLAGS"; then + pkg_cv_PANEL_CFLAGS="$PANEL_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_CFLAGS=`$PKG_CONFIG --cflags "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$PANEL_LIBS"; then + pkg_cv_PANEL_LIBS="$PANEL_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnupanel\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gnupanel") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PANEL_LIBS=`$PKG_CONFIG --libs "gnupanel" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + PANEL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gnupanel" 2>&1` + else + PANEL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gnupanel" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$PANEL_PKG_ERRORS" >&5 + + have_panel=no +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + have_panel=no +else + PANEL_CFLAGS=$pkg_cv_PANEL_CFLAGS + PANEL_LIBS=$pkg_cv_PANEL_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + have_panel=yes +fi +else + PANEL_CFLAGS=$pkg_cv_PANEL_CFLAGS + PANEL_LIBS=$pkg_cv_PANEL_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + +printf "%s\n" "#define HAVE_PANEL 1" >>confdefs.h + + have_panel=yes +fi +fi + + +fi + curses_libs="ncursesw ncurses"; panel_libs="panelw panel gnupanel" ;; +esac + +save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + # Make sure we've got the header defines. For the native "curses" backend, + # probe only the plain headers: a system may also have ncurses headers (e.g. + # ncurses/curses.h), and picking those while linking the native library mixes + # incompatible declarations (e.g. tparm()) with the native . + as_fn_append CPPFLAGS " $CURSES_CFLAGS $PANEL_CFLAGS" + if test "x$with_curses" = xcurses +then : + ac_fn_c_check_header_compile "$LINENO" "curses.h" "ac_cv_header_curses_h" "$ac_includes_default" +if test "x$ac_cv_header_curses_h" = xyes +then : + printf "%s\n" "#define HAVE_CURSES_H 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "panel.h" "ac_cv_header_panel_h" "$ac_includes_default" +if test "x$ac_cv_header_panel_h" = xyes +then : + printf "%s\n" "#define HAVE_PANEL_H 1" >>confdefs.h + +fi + +else case e in #( + e) ac_fn_c_check_header_compile "$LINENO" "ncursesw/curses.h" "ac_cv_header_ncursesw_curses_h" "$ac_includes_default" +if test "x$ac_cv_header_ncursesw_curses_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSESW_CURSES_H 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "ncursesw/ncurses.h" "ac_cv_header_ncursesw_ncurses_h" "$ac_includes_default" +if test "x$ac_cv_header_ncursesw_ncurses_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSESW_NCURSES_H 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "ncursesw/panel.h" "ac_cv_header_ncursesw_panel_h" "$ac_includes_default" +if test "x$ac_cv_header_ncursesw_panel_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSESW_PANEL_H 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "ncurses/curses.h" "ac_cv_header_ncurses_curses_h" "$ac_includes_default" +if test "x$ac_cv_header_ncurses_curses_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSES_CURSES_H 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "ncurses/ncurses.h" "ac_cv_header_ncurses_ncurses_h" "$ac_includes_default" +if test "x$ac_cv_header_ncurses_ncurses_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSES_NCURSES_H 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "ncurses/panel.h" "ac_cv_header_ncurses_panel_h" "$ac_includes_default" +if test "x$ac_cv_header_ncurses_panel_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSES_PANEL_H 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "curses.h" "ac_cv_header_curses_h" "$ac_includes_default" +if test "x$ac_cv_header_curses_h" = xyes +then : + printf "%s\n" "#define HAVE_CURSES_H 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "ncurses.h" "ac_cv_header_ncurses_h" "$ac_includes_default" +if test "x$ac_cv_header_ncurses_h" = xyes +then : + printf "%s\n" "#define HAVE_NCURSES_H 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "panel.h" "ac_cv_header_panel_h" "$ac_includes_default" +if test "x$ac_cv_header_panel_h" = xyes +then : + printf "%s\n" "#define HAVE_PANEL_H 1" >>confdefs.h + +fi + ;; +esac +fi + + # Check that we're able to link with crucial curses/panel functions. This + # also serves as a fallback in case pkg-config failed. Extension modules are + # not linked with LIBS, so exclude it to get the required libraries. + LIBS="$CURSES_LIBS $PANEL_LIBS" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing initscr" >&5 +printf %s "checking for library containing initscr... " >&6; } +if test ${ac_cv_search_initscr+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char initscr (void); +int +main (void) +{ +return initscr (); + ; + return 0; +} +_ACEOF +for ac_lib in '' $curses_libs +do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO" +then : + ac_cv_search_initscr=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext + if test ${ac_cv_search_initscr+y} +then : + break +fi +done +if test ${ac_cv_search_initscr+y} +then : + +else case e in #( + e) ac_cv_search_initscr=no ;; +esac +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_initscr" >&5 +printf "%s\n" "$ac_cv_search_initscr" >&6; } +ac_res=$ac_cv_search_initscr +if test "$ac_res" != no +then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + if test "x$have_curses" = xno +then : + have_curses=yes + CURSES_LIBS=${CURSES_LIBS-"$ac_cv_search_initscr"} +fi +else case e in #( + e) have_curses=no ;; +esac +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing update_panels" >&5 +printf %s "checking for library containing update_panels... " >&6; } +if test ${ac_cv_search_update_panels+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char update_panels (void); +int +main (void) +{ +return update_panels (); + ; + return 0; +} +_ACEOF +for ac_lib in '' $panel_libs +do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO" +then : + ac_cv_search_update_panels=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext + if test ${ac_cv_search_update_panels+y} +then : + break +fi +done +if test ${ac_cv_search_update_panels+y} +then : + +else case e in #( + e) ac_cv_search_update_panels=no ;; +esac +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_update_panels" >&5 +printf "%s\n" "$ac_cv_search_update_panels" >&6; } +ac_res=$ac_cv_search_update_panels +if test "$ac_res" != no +then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + if test "x$have_panel" = xno +then : + have_panel=yes + PANEL_LIBS=${PANEL_LIBS-"$ac_cv_search_update_panels"} +fi +else case e in #( + e) have_panel=no ;; +esac +fi + + + + +if test "$have_curses" != "no" +then : + +CURSES_CFLAGS=$(echo $CURSES_CFLAGS | sed 's/-D_XOPEN_SOURCE=600//g') + +if test "x$ac_sys_system" = xDarwin +then : + + + as_fn_append CURSES_CFLAGS " -D_XOPEN_SOURCE_EXTENDED=1" + +fi + PANEL_CFLAGS=$(echo $PANEL_CFLAGS | sed 's/-D_XOPEN_SOURCE=600//g') +case $with_curses in #( + ncursesw|no) : + ;; #( + *) : + + save_curses_cppflags=$CPPFLAGS + as_fn_append CPPFLAGS " $CURSES_CFLAGS" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether curses supports wide characters" >&5 +printf %s "checking whether curses supports wide characters... " >&6; } +if test ${ac_cv_curses_wide+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define NCURSES_OPAQUE 0 +#if defined(HAVE_NCURSESW_NCURSES_H) +# include +#elif defined(HAVE_NCURSESW_CURSES_H) +# include +#elif defined(HAVE_NCURSES_NCURSES_H) +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +#elif defined(HAVE_NCURSES_H) +# include +#elif defined(HAVE_CURSES_H) +# include +#endif + +int +main (void) +{ + + cchar_t wcval; + setcchar(&wcval, L"x", A_NORMAL, 0, NULL); + add_wch(&wcval); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_curses_wide=yes +else case e in #( + e) ac_cv_curses_wide=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_curses_wide" >&5 +printf "%s\n" "$ac_cv_curses_wide" >&6; } + CPPFLAGS=$save_curses_cppflags + if test "x$ac_cv_curses_wide" = xyes +then : + printf "%s\n" "#define HAVE_NCURSESW 1" >>confdefs.h + +fi + ;; +esac + # On Solaris, term.h requires curses.h ac_fn_c_check_header_compile "$LINENO" "term.h" "ac_cv_header_term_h" " #define NCURSES_OPAQUE 0 @@ -29934,31 +32260,531 @@ int main (void) { - WINDOW *w; - w->_flags = 0; + WINDOW *w; + w->_flags = 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_window_has_flags=yes +else case e in #( + e) ac_cv_window_has_flags=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_window_has_flags" >&5 +printf "%s\n" "$ac_cv_window_has_flags" >&6; } + + +if test "$ac_cv_window_has_flags" = yes +then + +printf "%s\n" "#define WINDOW_HAS_FLAGS 1" >>confdefs.h + +fi + + + + + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function is_pad" >&5 +printf %s "checking for curses function is_pad... " >&6; } +if test ${ac_cv_lib_curses_is_pad+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define NCURSES_OPAQUE 0 +#if defined(HAVE_NCURSESW_NCURSES_H) +# include +#elif defined(HAVE_NCURSESW_CURSES_H) +# include +#elif defined(HAVE_NCURSES_NCURSES_H) +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +#elif defined(HAVE_NCURSES_H) +# include +#elif defined(HAVE_CURSES_H) +# include +#endif + +int +main (void) +{ + + #ifndef is_pad + void * volatile x = (void *)is_pad; (void)x; + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_curses_is_pad=yes +else case e in #( + e) ac_cv_lib_curses_is_pad=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_is_pad" >&5 +printf "%s\n" "$ac_cv_lib_curses_is_pad" >&6; } + if test "x$ac_cv_lib_curses_is_pad" = xyes +then : + +printf "%s\n" "#define HAVE_CURSES_IS_PAD 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function is_term_resized" >&5 +printf %s "checking for curses function is_term_resized... " >&6; } +if test ${ac_cv_lib_curses_is_term_resized+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define NCURSES_OPAQUE 0 +#if defined(HAVE_NCURSESW_NCURSES_H) +# include +#elif defined(HAVE_NCURSESW_CURSES_H) +# include +#elif defined(HAVE_NCURSES_NCURSES_H) +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +#elif defined(HAVE_NCURSES_H) +# include +#elif defined(HAVE_CURSES_H) +# include +#endif + +int +main (void) +{ + + #ifndef is_term_resized + void * volatile x = (void *)is_term_resized; (void)x; + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_curses_is_term_resized=yes +else case e in #( + e) ac_cv_lib_curses_is_term_resized=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_is_term_resized" >&5 +printf "%s\n" "$ac_cv_lib_curses_is_term_resized" >&6; } + if test "x$ac_cv_lib_curses_is_term_resized" = xyes +then : + +printf "%s\n" "#define HAVE_CURSES_IS_TERM_RESIZED 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function resize_term" >&5 +printf %s "checking for curses function resize_term... " >&6; } +if test ${ac_cv_lib_curses_resize_term+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define NCURSES_OPAQUE 0 +#if defined(HAVE_NCURSESW_NCURSES_H) +# include +#elif defined(HAVE_NCURSESW_CURSES_H) +# include +#elif defined(HAVE_NCURSES_NCURSES_H) +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +#elif defined(HAVE_NCURSES_H) +# include +#elif defined(HAVE_CURSES_H) +# include +#endif + +int +main (void) +{ + + #ifndef resize_term + void * volatile x = (void *)resize_term; (void)x; + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_curses_resize_term=yes +else case e in #( + e) ac_cv_lib_curses_resize_term=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_resize_term" >&5 +printf "%s\n" "$ac_cv_lib_curses_resize_term" >&6; } + if test "x$ac_cv_lib_curses_resize_term" = xyes +then : + +printf "%s\n" "#define HAVE_CURSES_RESIZE_TERM 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function resizeterm" >&5 +printf %s "checking for curses function resizeterm... " >&6; } +if test ${ac_cv_lib_curses_resizeterm+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define NCURSES_OPAQUE 0 +#if defined(HAVE_NCURSESW_NCURSES_H) +# include +#elif defined(HAVE_NCURSESW_CURSES_H) +# include +#elif defined(HAVE_NCURSES_NCURSES_H) +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +#elif defined(HAVE_NCURSES_H) +# include +#elif defined(HAVE_CURSES_H) +# include +#endif + +int +main (void) +{ + + #ifndef resizeterm + void * volatile x = (void *)resizeterm; (void)x; + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_curses_resizeterm=yes +else case e in #( + e) ac_cv_lib_curses_resizeterm=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_resizeterm" >&5 +printf "%s\n" "$ac_cv_lib_curses_resizeterm" >&6; } + if test "x$ac_cv_lib_curses_resizeterm" = xyes +then : + +printf "%s\n" "#define HAVE_CURSES_RESIZETERM 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function immedok" >&5 +printf %s "checking for curses function immedok... " >&6; } +if test ${ac_cv_lib_curses_immedok+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define NCURSES_OPAQUE 0 +#if defined(HAVE_NCURSESW_NCURSES_H) +# include +#elif defined(HAVE_NCURSESW_CURSES_H) +# include +#elif defined(HAVE_NCURSES_NCURSES_H) +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +#elif defined(HAVE_NCURSES_H) +# include +#elif defined(HAVE_CURSES_H) +# include +#endif + +int +main (void) +{ + + #ifndef immedok + void * volatile x = (void *)immedok; (void)x; + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_curses_immedok=yes +else case e in #( + e) ac_cv_lib_curses_immedok=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_immedok" >&5 +printf "%s\n" "$ac_cv_lib_curses_immedok" >&6; } + if test "x$ac_cv_lib_curses_immedok" = xyes +then : + +printf "%s\n" "#define HAVE_CURSES_IMMEDOK 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function syncok" >&5 +printf %s "checking for curses function syncok... " >&6; } +if test ${ac_cv_lib_curses_syncok+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define NCURSES_OPAQUE 0 +#if defined(HAVE_NCURSESW_NCURSES_H) +# include +#elif defined(HAVE_NCURSESW_CURSES_H) +# include +#elif defined(HAVE_NCURSES_NCURSES_H) +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +#elif defined(HAVE_NCURSES_H) +# include +#elif defined(HAVE_CURSES_H) +# include +#endif + +int +main (void) +{ + + #ifndef syncok + void * volatile x = (void *)syncok; (void)x; + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_curses_syncok=yes +else case e in #( + e) ac_cv_lib_curses_syncok=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_syncok" >&5 +printf "%s\n" "$ac_cv_lib_curses_syncok" >&6; } + if test "x$ac_cv_lib_curses_syncok" = xyes +then : + +printf "%s\n" "#define HAVE_CURSES_SYNCOK 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function wchgat" >&5 +printf %s "checking for curses function wchgat... " >&6; } +if test ${ac_cv_lib_curses_wchgat+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define NCURSES_OPAQUE 0 +#if defined(HAVE_NCURSESW_NCURSES_H) +# include +#elif defined(HAVE_NCURSESW_CURSES_H) +# include +#elif defined(HAVE_NCURSES_NCURSES_H) +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +#elif defined(HAVE_NCURSES_H) +# include +#elif defined(HAVE_CURSES_H) +# include +#endif + +int +main (void) +{ + + #ifndef wchgat + void * volatile x = (void *)wchgat; (void)x; + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_curses_wchgat=yes +else case e in #( + e) ac_cv_lib_curses_wchgat=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_wchgat" >&5 +printf "%s\n" "$ac_cv_lib_curses_wchgat" >&6; } + if test "x$ac_cv_lib_curses_wchgat" = xyes +then : + +printf "%s\n" "#define HAVE_CURSES_WCHGAT 1" >>confdefs.h + +fi + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function filter" >&5 +printf %s "checking for curses function filter... " >&6; } +if test ${ac_cv_lib_curses_filter+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define NCURSES_OPAQUE 0 +#if defined(HAVE_NCURSESW_NCURSES_H) +# include +#elif defined(HAVE_NCURSESW_CURSES_H) +# include +#elif defined(HAVE_NCURSES_NCURSES_H) +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +#elif defined(HAVE_NCURSES_H) +# include +#elif defined(HAVE_CURSES_H) +# include +#endif + +int +main (void) +{ + + #ifndef filter + void * volatile x = (void *)filter; (void)x; + #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_window_has_flags=yes + ac_cv_lib_curses_filter=yes else case e in #( - e) ac_cv_window_has_flags=no ;; + e) ac_cv_lib_curses_filter=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_window_has_flags" >&5 -printf "%s\n" "$ac_cv_window_has_flags" >&6; } - - -if test "$ac_cv_window_has_flags" = yes -then +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_filter" >&5 +printf "%s\n" "$ac_cv_lib_curses_filter" >&6; } + if test "x$ac_cv_lib_curses_filter" = xyes +then : -printf "%s\n" "#define WINDOW_HAS_FLAGS 1" >>confdefs.h +printf "%s\n" "#define HAVE_CURSES_FILTER 1" >>confdefs.h fi @@ -29967,10 +32793,9 @@ fi - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function is_pad" >&5 -printf %s "checking for curses function is_pad... " >&6; } -if test ${ac_cv_lib_curses_is_pad+y} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function has_key" >&5 +printf %s "checking for curses function has_key... " >&6; } +if test ${ac_cv_lib_curses_has_key+y} then : printf %s "(cached) " >&6 else case e in #( @@ -29996,31 +32821,32 @@ int main (void) { - #ifndef is_pad - void *x=is_pad + #ifndef has_key + void * volatile x = (void *)has_key; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_is_pad=yes + ac_cv_lib_curses_has_key=yes else case e in #( - e) ac_cv_lib_curses_is_pad=no ;; + e) ac_cv_lib_curses_has_key=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_is_pad" >&5 -printf "%s\n" "$ac_cv_lib_curses_is_pad" >&6; } - if test "x$ac_cv_lib_curses_is_pad" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_has_key" >&5 +printf "%s\n" "$ac_cv_lib_curses_has_key" >&6; } + if test "x$ac_cv_lib_curses_has_key" = xyes then : -printf "%s\n" "#define HAVE_CURSES_IS_PAD 1" >>confdefs.h +printf "%s\n" "#define HAVE_CURSES_HAS_KEY 1" >>confdefs.h fi @@ -30028,9 +32854,10 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function is_term_resized" >&5 -printf %s "checking for curses function is_term_resized... " >&6; } -if test ${ac_cv_lib_curses_is_term_resized+y} + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function typeahead" >&5 +printf %s "checking for curses function typeahead... " >&6; } +if test ${ac_cv_lib_curses_typeahead+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30056,31 +32883,32 @@ int main (void) { - #ifndef is_term_resized - void *x=is_term_resized + #ifndef typeahead + void * volatile x = (void *)typeahead; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_is_term_resized=yes + ac_cv_lib_curses_typeahead=yes else case e in #( - e) ac_cv_lib_curses_is_term_resized=no ;; + e) ac_cv_lib_curses_typeahead=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_is_term_resized" >&5 -printf "%s\n" "$ac_cv_lib_curses_is_term_resized" >&6; } - if test "x$ac_cv_lib_curses_is_term_resized" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_typeahead" >&5 +printf "%s\n" "$ac_cv_lib_curses_typeahead" >&6; } + if test "x$ac_cv_lib_curses_typeahead" = xyes then : -printf "%s\n" "#define HAVE_CURSES_IS_TERM_RESIZED 1" >>confdefs.h +printf "%s\n" "#define HAVE_CURSES_TYPEAHEAD 1" >>confdefs.h fi @@ -30088,9 +32916,10 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function resize_term" >&5 -printf %s "checking for curses function resize_term... " >&6; } -if test ${ac_cv_lib_curses_resize_term+y} + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function use_env" >&5 +printf %s "checking for curses function use_env... " >&6; } +if test ${ac_cv_lib_curses_use_env+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30116,31 +32945,32 @@ int main (void) { - #ifndef resize_term - void *x=resize_term + #ifndef use_env + void * volatile x = (void *)use_env; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_resize_term=yes + ac_cv_lib_curses_use_env=yes else case e in #( - e) ac_cv_lib_curses_resize_term=no ;; + e) ac_cv_lib_curses_use_env=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_resize_term" >&5 -printf "%s\n" "$ac_cv_lib_curses_resize_term" >&6; } - if test "x$ac_cv_lib_curses_resize_term" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_use_env" >&5 +printf "%s\n" "$ac_cv_lib_curses_use_env" >&6; } + if test "x$ac_cv_lib_curses_use_env" = xyes then : -printf "%s\n" "#define HAVE_CURSES_RESIZE_TERM 1" >>confdefs.h +printf "%s\n" "#define HAVE_CURSES_USE_ENV 1" >>confdefs.h fi @@ -30148,9 +32978,10 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function resizeterm" >&5 -printf %s "checking for curses function resizeterm... " >&6; } -if test ${ac_cv_lib_curses_resizeterm+y} + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function set_escdelay" >&5 +printf %s "checking for curses function set_escdelay... " >&6; } +if test ${ac_cv_lib_curses_set_escdelay+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30176,31 +33007,32 @@ int main (void) { - #ifndef resizeterm - void *x=resizeterm + #ifndef set_escdelay + void * volatile x = (void *)set_escdelay; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_resizeterm=yes + ac_cv_lib_curses_set_escdelay=yes else case e in #( - e) ac_cv_lib_curses_resizeterm=no ;; + e) ac_cv_lib_curses_set_escdelay=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_resizeterm" >&5 -printf "%s\n" "$ac_cv_lib_curses_resizeterm" >&6; } - if test "x$ac_cv_lib_curses_resizeterm" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_set_escdelay" >&5 +printf "%s\n" "$ac_cv_lib_curses_set_escdelay" >&6; } + if test "x$ac_cv_lib_curses_set_escdelay" = xyes then : -printf "%s\n" "#define HAVE_CURSES_RESIZETERM 1" >>confdefs.h +printf "%s\n" "#define HAVE_CURSES_SET_ESCDELAY 1" >>confdefs.h fi @@ -30208,9 +33040,10 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function immedok" >&5 -printf %s "checking for curses function immedok... " >&6; } -if test ${ac_cv_lib_curses_immedok+y} + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function set_tabsize" >&5 +printf %s "checking for curses function set_tabsize... " >&6; } +if test ${ac_cv_lib_curses_set_tabsize+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30236,31 +33069,32 @@ int main (void) { - #ifndef immedok - void *x=immedok + #ifndef set_tabsize + void * volatile x = (void *)set_tabsize; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_immedok=yes + ac_cv_lib_curses_set_tabsize=yes else case e in #( - e) ac_cv_lib_curses_immedok=no ;; + e) ac_cv_lib_curses_set_tabsize=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_immedok" >&5 -printf "%s\n" "$ac_cv_lib_curses_immedok" >&6; } - if test "x$ac_cv_lib_curses_immedok" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_set_tabsize" >&5 +printf "%s\n" "$ac_cv_lib_curses_set_tabsize" >&6; } + if test "x$ac_cv_lib_curses_set_tabsize" = xyes then : -printf "%s\n" "#define HAVE_CURSES_IMMEDOK 1" >>confdefs.h +printf "%s\n" "#define HAVE_CURSES_SET_TABSIZE 1" >>confdefs.h fi @@ -30268,9 +33102,9 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function syncok" >&5 -printf %s "checking for curses function syncok... " >&6; } -if test ${ac_cv_lib_curses_syncok+y} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses variable ESCDELAY" >&5 +printf %s "checking for curses variable ESCDELAY... " >&6; } +if test ${ac_cv_lib_curses_ESCDELAY+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30296,9 +33130,7 @@ int main (void) { - #ifndef syncok - void *x=syncok - #endif + int x = ESCDELAY; (void)x; ; return 0; @@ -30306,21 +33138,21 @@ main (void) _ACEOF if ac_fn_c_try_compile "$LINENO" then : - ac_cv_lib_curses_syncok=yes + ac_cv_lib_curses_ESCDELAY=yes else case e in #( - e) ac_cv_lib_curses_syncok=no ;; + e) ac_cv_lib_curses_ESCDELAY=no ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_syncok" >&5 -printf "%s\n" "$ac_cv_lib_curses_syncok" >&6; } - if test "x$ac_cv_lib_curses_syncok" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_ESCDELAY" >&5 +printf "%s\n" "$ac_cv_lib_curses_ESCDELAY" >&6; } + if test "x$ac_cv_lib_curses_ESCDELAY" = xyes then : -printf "%s\n" "#define HAVE_CURSES_SYNCOK 1" >>confdefs.h +printf "%s\n" "#define HAVE_CURSES_ESCDELAY 1" >>confdefs.h fi @@ -30328,9 +33160,9 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function wchgat" >&5 -printf %s "checking for curses function wchgat... " >&6; } -if test ${ac_cv_lib_curses_wchgat+y} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses variable TABSIZE" >&5 +printf %s "checking for curses variable TABSIZE... " >&6; } +if test ${ac_cv_lib_curses_TABSIZE+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30356,9 +33188,7 @@ int main (void) { - #ifndef wchgat - void *x=wchgat - #endif + int x = TABSIZE; (void)x; ; return 0; @@ -30366,21 +33196,21 @@ main (void) _ACEOF if ac_fn_c_try_compile "$LINENO" then : - ac_cv_lib_curses_wchgat=yes + ac_cv_lib_curses_TABSIZE=yes else case e in #( - e) ac_cv_lib_curses_wchgat=no ;; + e) ac_cv_lib_curses_TABSIZE=no ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_wchgat" >&5 -printf "%s\n" "$ac_cv_lib_curses_wchgat" >&6; } - if test "x$ac_cv_lib_curses_wchgat" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_TABSIZE" >&5 +printf "%s\n" "$ac_cv_lib_curses_TABSIZE" >&6; } + if test "x$ac_cv_lib_curses_TABSIZE" = xyes then : -printf "%s\n" "#define HAVE_CURSES_WCHGAT 1" >>confdefs.h +printf "%s\n" "#define HAVE_CURSES_TABSIZE 1" >>confdefs.h fi @@ -30388,9 +33218,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function filter" >&5 -printf %s "checking for curses function filter... " >&6; } -if test ${ac_cv_lib_curses_filter+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function define_key" >&5 +printf %s "checking for curses function define_key... " >&6; } +if test ${ac_cv_lib_curses_define_key+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30416,31 +33248,32 @@ int main (void) { - #ifndef filter - void *x=filter + #ifndef define_key + void * volatile x = (void *)define_key; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_filter=yes + ac_cv_lib_curses_define_key=yes else case e in #( - e) ac_cv_lib_curses_filter=no ;; + e) ac_cv_lib_curses_define_key=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_filter" >&5 -printf "%s\n" "$ac_cv_lib_curses_filter" >&6; } - if test "x$ac_cv_lib_curses_filter" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_define_key" >&5 +printf "%s\n" "$ac_cv_lib_curses_define_key" >&6; } + if test "x$ac_cv_lib_curses_define_key" = xyes then : -printf "%s\n" "#define HAVE_CURSES_FILTER 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_DEFINE_KEY 1" >>confdefs.h fi @@ -30448,9 +33281,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function nofilter" >&5 -printf %s "checking for curses function nofilter... " >&6; } -if test ${ac_cv_lib_curses_nofilter+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function has_mouse" >&5 +printf %s "checking for curses function has_mouse... " >&6; } +if test ${ac_cv_lib_curses_has_mouse+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30476,31 +33311,32 @@ int main (void) { - #ifndef nofilter - void *x=nofilter + #ifndef has_mouse + void * volatile x = (void *)has_mouse; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_nofilter=yes + ac_cv_lib_curses_has_mouse=yes else case e in #( - e) ac_cv_lib_curses_nofilter=no ;; + e) ac_cv_lib_curses_has_mouse=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_nofilter" >&5 -printf "%s\n" "$ac_cv_lib_curses_nofilter" >&6; } - if test "x$ac_cv_lib_curses_nofilter" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_has_mouse" >&5 +printf "%s\n" "$ac_cv_lib_curses_has_mouse" >&6; } + if test "x$ac_cv_lib_curses_has_mouse" = xyes then : -printf "%s\n" "#define HAVE_CURSES_NOFILTER 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_HAS_MOUSE 1" >>confdefs.h fi @@ -30508,9 +33344,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function has_key" >&5 -printf %s "checking for curses function has_key... " >&6; } -if test ${ac_cv_lib_curses_has_key+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function is_keypad" >&5 +printf %s "checking for curses function is_keypad... " >&6; } +if test ${ac_cv_lib_curses_is_keypad+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30536,31 +33374,32 @@ int main (void) { - #ifndef has_key - void *x=has_key + #ifndef is_keypad + void * volatile x = (void *)is_keypad; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_has_key=yes + ac_cv_lib_curses_is_keypad=yes else case e in #( - e) ac_cv_lib_curses_has_key=no ;; + e) ac_cv_lib_curses_is_keypad=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_has_key" >&5 -printf "%s\n" "$ac_cv_lib_curses_has_key" >&6; } - if test "x$ac_cv_lib_curses_has_key" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_is_keypad" >&5 +printf "%s\n" "$ac_cv_lib_curses_is_keypad" >&6; } + if test "x$ac_cv_lib_curses_is_keypad" = xyes then : -printf "%s\n" "#define HAVE_CURSES_HAS_KEY 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_IS_KEYPAD 1" >>confdefs.h fi @@ -30568,9 +33407,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function has_mouse" >&5 -printf %s "checking for curses function has_mouse... " >&6; } -if test ${ac_cv_lib_curses_has_mouse+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function is_leaveok" >&5 +printf %s "checking for curses function is_leaveok... " >&6; } +if test ${ac_cv_lib_curses_is_leaveok+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30596,31 +33437,32 @@ int main (void) { - #ifndef has_mouse - void *x=has_mouse + #ifndef is_leaveok + void * volatile x = (void *)is_leaveok; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_has_mouse=yes + ac_cv_lib_curses_is_leaveok=yes else case e in #( - e) ac_cv_lib_curses_has_mouse=no ;; + e) ac_cv_lib_curses_is_leaveok=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_has_mouse" >&5 -printf "%s\n" "$ac_cv_lib_curses_has_mouse" >&6; } - if test "x$ac_cv_lib_curses_has_mouse" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_is_leaveok" >&5 +printf "%s\n" "$ac_cv_lib_curses_is_leaveok" >&6; } + if test "x$ac_cv_lib_curses_is_leaveok" = xyes then : -printf "%s\n" "#define HAVE_CURSES_HAS_MOUSE 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_IS_LEAVEOK 1" >>confdefs.h fi @@ -30628,9 +33470,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function is_keypad" >&5 -printf %s "checking for curses function is_keypad... " >&6; } -if test ${ac_cv_lib_curses_is_keypad+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function key_defined" >&5 +printf %s "checking for curses function key_defined... " >&6; } +if test ${ac_cv_lib_curses_key_defined+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30656,31 +33500,32 @@ int main (void) { - #ifndef is_keypad - void *x=is_keypad + #ifndef key_defined + void * volatile x = (void *)key_defined; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_is_keypad=yes + ac_cv_lib_curses_key_defined=yes else case e in #( - e) ac_cv_lib_curses_is_keypad=no ;; + e) ac_cv_lib_curses_key_defined=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_is_keypad" >&5 -printf "%s\n" "$ac_cv_lib_curses_is_keypad" >&6; } - if test "x$ac_cv_lib_curses_is_keypad" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_key_defined" >&5 +printf "%s\n" "$ac_cv_lib_curses_key_defined" >&6; } + if test "x$ac_cv_lib_curses_key_defined" = xyes then : -printf "%s\n" "#define HAVE_CURSES_IS_KEYPAD 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_KEY_DEFINED 1" >>confdefs.h fi @@ -30688,9 +33533,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function is_leaveok" >&5 -printf %s "checking for curses function is_leaveok... " >&6; } -if test ${ac_cv_lib_curses_is_leaveok+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function keyok" >&5 +printf %s "checking for curses function keyok... " >&6; } +if test ${ac_cv_lib_curses_keyok+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30716,31 +33563,32 @@ int main (void) { - #ifndef is_leaveok - void *x=is_leaveok + #ifndef keyok + void * volatile x = (void *)keyok; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_is_leaveok=yes + ac_cv_lib_curses_keyok=yes else case e in #( - e) ac_cv_lib_curses_is_leaveok=no ;; + e) ac_cv_lib_curses_keyok=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_is_leaveok" >&5 -printf "%s\n" "$ac_cv_lib_curses_is_leaveok" >&6; } - if test "x$ac_cv_lib_curses_is_leaveok" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_keyok" >&5 +printf "%s\n" "$ac_cv_lib_curses_keyok" >&6; } + if test "x$ac_cv_lib_curses_keyok" = xyes then : -printf "%s\n" "#define HAVE_CURSES_IS_LEAVEOK 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_KEYOK 1" >>confdefs.h fi @@ -30748,9 +33596,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function typeahead" >&5 -printf %s "checking for curses function typeahead... " >&6; } -if test ${ac_cv_lib_curses_typeahead+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function new_prescr" >&5 +printf %s "checking for curses function new_prescr... " >&6; } +if test ${ac_cv_lib_curses_new_prescr+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30776,31 +33626,32 @@ int main (void) { - #ifndef typeahead - void *x=typeahead + #ifndef new_prescr + void * volatile x = (void *)new_prescr; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_typeahead=yes + ac_cv_lib_curses_new_prescr=yes else case e in #( - e) ac_cv_lib_curses_typeahead=no ;; + e) ac_cv_lib_curses_new_prescr=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_typeahead" >&5 -printf "%s\n" "$ac_cv_lib_curses_typeahead" >&6; } - if test "x$ac_cv_lib_curses_typeahead" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_new_prescr" >&5 +printf "%s\n" "$ac_cv_lib_curses_new_prescr" >&6; } + if test "x$ac_cv_lib_curses_new_prescr" = xyes then : -printf "%s\n" "#define HAVE_CURSES_TYPEAHEAD 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_NEW_PRESCR 1" >>confdefs.h fi @@ -30808,9 +33659,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function use_env" >&5 -printf %s "checking for curses function use_env... " >&6; } -if test ${ac_cv_lib_curses_use_env+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function nofilter" >&5 +printf %s "checking for curses function nofilter... " >&6; } +if test ${ac_cv_lib_curses_nofilter+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30836,31 +33689,32 @@ int main (void) { - #ifndef use_env - void *x=use_env + #ifndef nofilter + void * volatile x = (void *)nofilter; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_use_env=yes + ac_cv_lib_curses_nofilter=yes else case e in #( - e) ac_cv_lib_curses_use_env=no ;; + e) ac_cv_lib_curses_nofilter=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_use_env" >&5 -printf "%s\n" "$ac_cv_lib_curses_use_env" >&6; } - if test "x$ac_cv_lib_curses_use_env" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_nofilter" >&5 +printf "%s\n" "$ac_cv_lib_curses_nofilter" >&6; } + if test "x$ac_cv_lib_curses_nofilter" = xyes then : -printf "%s\n" "#define HAVE_CURSES_USE_ENV 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_NOFILTER 1" >>confdefs.h fi @@ -30868,9 +33722,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function new_prescr" >&5 -printf %s "checking for curses function new_prescr... " >&6; } -if test ${ac_cv_lib_curses_new_prescr+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function slk_attr_off" >&5 +printf %s "checking for curses function slk_attr_off... " >&6; } +if test ${ac_cv_lib_curses_slk_attr_off+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30896,31 +33752,32 @@ int main (void) { - #ifndef new_prescr - void *x=new_prescr + #ifndef slk_attr_off + void * volatile x = (void *)slk_attr_off; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_new_prescr=yes + ac_cv_lib_curses_slk_attr_off=yes else case e in #( - e) ac_cv_lib_curses_new_prescr=no ;; + e) ac_cv_lib_curses_slk_attr_off=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_new_prescr" >&5 -printf "%s\n" "$ac_cv_lib_curses_new_prescr" >&6; } - if test "x$ac_cv_lib_curses_new_prescr" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_slk_attr_off" >&5 +printf "%s\n" "$ac_cv_lib_curses_slk_attr_off" >&6; } + if test "x$ac_cv_lib_curses_slk_attr_off" = xyes then : -printf "%s\n" "#define HAVE_CURSES_NEW_PRESCR 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_SLK_ATTR_OFF 1" >>confdefs.h fi @@ -30928,9 +33785,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function use_screen" >&5 -printf %s "checking for curses function use_screen... " >&6; } -if test ${ac_cv_lib_curses_use_screen+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function slk_attr_on" >&5 +printf %s "checking for curses function slk_attr_on... " >&6; } +if test ${ac_cv_lib_curses_slk_attr_on+y} then : printf %s "(cached) " >&6 else case e in #( @@ -30956,31 +33815,32 @@ int main (void) { - #ifndef use_screen - void *x=use_screen + #ifndef slk_attr_on + void * volatile x = (void *)slk_attr_on; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_use_screen=yes + ac_cv_lib_curses_slk_attr_on=yes else case e in #( - e) ac_cv_lib_curses_use_screen=no ;; + e) ac_cv_lib_curses_slk_attr_on=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_use_screen" >&5 -printf "%s\n" "$ac_cv_lib_curses_use_screen" >&6; } - if test "x$ac_cv_lib_curses_use_screen" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_slk_attr_on" >&5 +printf "%s\n" "$ac_cv_lib_curses_slk_attr_on" >&6; } + if test "x$ac_cv_lib_curses_slk_attr_on" = xyes then : -printf "%s\n" "#define HAVE_CURSES_USE_SCREEN 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_SLK_ATTR_ON 1" >>confdefs.h fi @@ -30988,9 +33848,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function use_window" >&5 -printf %s "checking for curses function use_window... " >&6; } -if test ${ac_cv_lib_curses_use_window+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function slk_attr_set" >&5 +printf %s "checking for curses function slk_attr_set... " >&6; } +if test ${ac_cv_lib_curses_slk_attr_set+y} then : printf %s "(cached) " >&6 else case e in #( @@ -31016,31 +33878,32 @@ int main (void) { - #ifndef use_window - void *x=use_window + #ifndef slk_attr_set + void * volatile x = (void *)slk_attr_set; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_use_window=yes + ac_cv_lib_curses_slk_attr_set=yes else case e in #( - e) ac_cv_lib_curses_use_window=no ;; + e) ac_cv_lib_curses_slk_attr_set=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_use_window" >&5 -printf "%s\n" "$ac_cv_lib_curses_use_window" >&6; } - if test "x$ac_cv_lib_curses_use_window" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_slk_attr_set" >&5 +printf "%s\n" "$ac_cv_lib_curses_slk_attr_set" >&6; } + if test "x$ac_cv_lib_curses_slk_attr_set" = xyes then : -printf "%s\n" "#define HAVE_CURSES_USE_WINDOW 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_SLK_ATTR_SET 1" >>confdefs.h fi @@ -31048,9 +33911,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function key_defined" >&5 -printf %s "checking for curses function key_defined... " >&6; } -if test ${ac_cv_lib_curses_key_defined+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function slk_color" >&5 +printf %s "checking for curses function slk_color... " >&6; } +if test ${ac_cv_lib_curses_slk_color+y} then : printf %s "(cached) " >&6 else case e in #( @@ -31076,31 +33941,32 @@ int main (void) { - #ifndef key_defined - void *x=key_defined + #ifndef slk_color + void * volatile x = (void *)slk_color; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_key_defined=yes + ac_cv_lib_curses_slk_color=yes else case e in #( - e) ac_cv_lib_curses_key_defined=no ;; + e) ac_cv_lib_curses_slk_color=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_key_defined" >&5 -printf "%s\n" "$ac_cv_lib_curses_key_defined" >&6; } - if test "x$ac_cv_lib_curses_key_defined" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_slk_color" >&5 +printf "%s\n" "$ac_cv_lib_curses_slk_color" >&6; } + if test "x$ac_cv_lib_curses_slk_color" = xyes then : -printf "%s\n" "#define HAVE_CURSES_KEY_DEFINED 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_SLK_COLOR 1" >>confdefs.h fi @@ -31108,6 +33974,8 @@ fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function term_attrs" >&5 printf %s "checking for curses function term_attrs... " >&6; } if test ${ac_cv_lib_curses_term_attrs+y} @@ -31137,21 +34005,22 @@ main (void) { #ifndef term_attrs - void *x=term_attrs + void * volatile x = (void *)term_attrs; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_curses_term_attrs=yes else case e in #( e) ac_cv_lib_curses_term_attrs=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi @@ -31160,7 +34029,7 @@ printf "%s\n" "$ac_cv_lib_curses_term_attrs" >&6; } if test "x$ac_cv_lib_curses_term_attrs" = xyes then : -printf "%s\n" "#define HAVE_CURSES_TERM_ATTRS 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_TERM_ATTRS 1" >>confdefs.h fi @@ -31168,9 +34037,74 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function define_key" >&5 -printf %s "checking for curses function define_key... " >&6; } -if test ${ac_cv_lib_curses_define_key+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function use_screen" >&5 +printf %s "checking for curses function use_screen... " >&6; } +if test ${ac_cv_lib_curses_use_screen+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define NCURSES_OPAQUE 0 +#if defined(HAVE_NCURSESW_NCURSES_H) +# include +#elif defined(HAVE_NCURSESW_CURSES_H) +# include +#elif defined(HAVE_NCURSES_NCURSES_H) +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +#elif defined(HAVE_NCURSES_H) +# include +#elif defined(HAVE_CURSES_H) +# include +#endif + +int +main (void) +{ + + #ifndef use_screen + void * volatile x = (void *)use_screen; (void)x; + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_curses_use_screen=yes +else case e in #( + e) ac_cv_lib_curses_use_screen=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_use_screen" >&5 +printf "%s\n" "$ac_cv_lib_curses_use_screen" >&6; } + if test "x$ac_cv_lib_curses_use_screen" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_CURSES_USE_SCREEN 1" >>confdefs.h + +fi + + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function use_window" >&5 +printf %s "checking for curses function use_window... " >&6; } +if test ${ac_cv_lib_curses_use_window+y} then : printf %s "(cached) " >&6 else case e in #( @@ -31196,31 +34130,32 @@ int main (void) { - #ifndef define_key - void *x=define_key + #ifndef use_window + void * volatile x = (void *)use_window; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_define_key=yes + ac_cv_lib_curses_use_window=yes else case e in #( - e) ac_cv_lib_curses_define_key=no ;; + e) ac_cv_lib_curses_use_window=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_define_key" >&5 -printf "%s\n" "$ac_cv_lib_curses_define_key" >&6; } - if test "x$ac_cv_lib_curses_define_key" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_use_window" >&5 +printf "%s\n" "$ac_cv_lib_curses_use_window" >&6; } + if test "x$ac_cv_lib_curses_use_window" = xyes then : -printf "%s\n" "#define HAVE_CURSES_DEFINE_KEY 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_USE_WINDOW 1" >>confdefs.h fi @@ -31228,9 +34163,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function keyok" >&5 -printf %s "checking for curses function keyok... " >&6; } -if test ${ac_cv_lib_curses_keyok+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function wattr_get" >&5 +printf %s "checking for curses function wattr_get... " >&6; } +if test ${ac_cv_lib_curses_wattr_get+y} then : printf %s "(cached) " >&6 else case e in #( @@ -31256,31 +34193,32 @@ int main (void) { - #ifndef keyok - void *x=keyok + #ifndef wattr_get + void * volatile x = (void *)wattr_get; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_keyok=yes + ac_cv_lib_curses_wattr_get=yes else case e in #( - e) ac_cv_lib_curses_keyok=no ;; + e) ac_cv_lib_curses_wattr_get=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_keyok" >&5 -printf "%s\n" "$ac_cv_lib_curses_keyok" >&6; } - if test "x$ac_cv_lib_curses_keyok" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_wattr_get" >&5 +printf "%s\n" "$ac_cv_lib_curses_wattr_get" >&6; } + if test "x$ac_cv_lib_curses_wattr_get" = xyes then : -printf "%s\n" "#define HAVE_CURSES_KEYOK 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_WATTR_GET 1" >>confdefs.h fi @@ -31288,9 +34226,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function set_escdelay" >&5 -printf %s "checking for curses function set_escdelay... " >&6; } -if test ${ac_cv_lib_curses_set_escdelay+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function wattr_off" >&5 +printf %s "checking for curses function wattr_off... " >&6; } +if test ${ac_cv_lib_curses_wattr_off+y} then : printf %s "(cached) " >&6 else case e in #( @@ -31316,31 +34256,32 @@ int main (void) { - #ifndef set_escdelay - void *x=set_escdelay + #ifndef wattr_off + void * volatile x = (void *)wattr_off; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_set_escdelay=yes + ac_cv_lib_curses_wattr_off=yes else case e in #( - e) ac_cv_lib_curses_set_escdelay=no ;; + e) ac_cv_lib_curses_wattr_off=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_set_escdelay" >&5 -printf "%s\n" "$ac_cv_lib_curses_set_escdelay" >&6; } - if test "x$ac_cv_lib_curses_set_escdelay" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_wattr_off" >&5 +printf "%s\n" "$ac_cv_lib_curses_wattr_off" >&6; } + if test "x$ac_cv_lib_curses_wattr_off" = xyes then : -printf "%s\n" "#define HAVE_CURSES_SET_ESCDELAY 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_WATTR_OFF 1" >>confdefs.h fi @@ -31348,9 +34289,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function set_tabsize" >&5 -printf %s "checking for curses function set_tabsize... " >&6; } -if test ${ac_cv_lib_curses_set_tabsize+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function wattr_on" >&5 +printf %s "checking for curses function wattr_on... " >&6; } +if test ${ac_cv_lib_curses_wattr_on+y} then : printf %s "(cached) " >&6 else case e in #( @@ -31376,31 +34319,32 @@ int main (void) { - #ifndef set_tabsize - void *x=set_tabsize + #ifndef wattr_on + void * volatile x = (void *)wattr_on; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_set_tabsize=yes + ac_cv_lib_curses_wattr_on=yes else case e in #( - e) ac_cv_lib_curses_set_tabsize=no ;; + e) ac_cv_lib_curses_wattr_on=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_set_tabsize" >&5 -printf "%s\n" "$ac_cv_lib_curses_set_tabsize" >&6; } - if test "x$ac_cv_lib_curses_set_tabsize" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_wattr_on" >&5 +printf "%s\n" "$ac_cv_lib_curses_wattr_on" >&6; } + if test "x$ac_cv_lib_curses_wattr_on" = xyes then : -printf "%s\n" "#define HAVE_CURSES_SET_TABSIZE 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_WATTR_ON 1" >>confdefs.h fi @@ -31408,9 +34352,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses variable ESCDELAY" >&5 -printf %s "checking for curses variable ESCDELAY... " >&6; } -if test ${ac_cv_lib_curses_ESCDELAY+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function wattr_set" >&5 +printf %s "checking for curses function wattr_set... " >&6; } +if test ${ac_cv_lib_curses_wattr_set+y} then : printf %s "(cached) " >&6 else case e in #( @@ -31436,29 +34382,32 @@ int main (void) { - int x = ESCDELAY; (void)x; + #ifndef wattr_set + void * volatile x = (void *)wattr_set; (void)x; + #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_ESCDELAY=yes + ac_cv_lib_curses_wattr_set=yes else case e in #( - e) ac_cv_lib_curses_ESCDELAY=no ;; + e) ac_cv_lib_curses_wattr_set=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_ESCDELAY" >&5 -printf "%s\n" "$ac_cv_lib_curses_ESCDELAY" >&6; } - if test "x$ac_cv_lib_curses_ESCDELAY" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_wattr_set" >&5 +printf "%s\n" "$ac_cv_lib_curses_wattr_set" >&6; } + if test "x$ac_cv_lib_curses_wattr_set" = xyes then : -printf "%s\n" "#define HAVE_CURSES_ESCDELAY 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_WATTR_SET 1" >>confdefs.h fi @@ -31466,9 +34415,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses variable TABSIZE" >&5 -printf %s "checking for curses variable TABSIZE... " >&6; } -if test ${ac_cv_lib_curses_TABSIZE+y} + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function wcolor_set" >&5 +printf %s "checking for curses function wcolor_set... " >&6; } +if test ${ac_cv_lib_curses_wcolor_set+y} then : printf %s "(cached) " >&6 else case e in #( @@ -31494,35 +34445,39 @@ int main (void) { - int x = TABSIZE; (void)x; + #ifndef wcolor_set + void * volatile x = (void *)wcolor_set; (void)x; + #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_curses_TABSIZE=yes + ac_cv_lib_curses_wcolor_set=yes else case e in #( - e) ac_cv_lib_curses_TABSIZE=no ;; + e) ac_cv_lib_curses_wcolor_set=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_TABSIZE" >&5 -printf "%s\n" "$ac_cv_lib_curses_TABSIZE" >&6; } - if test "x$ac_cv_lib_curses_TABSIZE" = xyes +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_wcolor_set" >&5 +printf "%s\n" "$ac_cv_lib_curses_wcolor_set" >&6; } + if test "x$ac_cv_lib_curses_wcolor_set" = xyes then : -printf "%s\n" "#define HAVE_CURSES_TABSIZE 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_WCOLOR_SET 1" >>confdefs.h fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ncurses-style curses function getmouse" >&5 printf %s "checking for ncurses-style curses function getmouse... " >&6; } if test ${ac_cv_lib_curses_getmouse+y} @@ -31576,6 +34531,7 @@ fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function scr_dump" >&5 printf %s "checking for curses function scr_dump... " >&6; } if test ${ac_cv_lib_curses_scr_dump+y} @@ -31605,21 +34561,22 @@ main (void) { #ifndef scr_dump - void *x=scr_dump + void * volatile x = (void *)scr_dump; (void)x; #endif ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" +if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_curses_scr_dump=yes else case e in #( e) ac_cv_lib_curses_scr_dump=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext ;; esac fi @@ -31628,12 +34585,77 @@ printf "%s\n" "$ac_cv_lib_curses_scr_dump" >&6; } if test "x$ac_cv_lib_curses_scr_dump" = xyes then : -printf "%s\n" "#define HAVE_CURSES_SCR_DUMP 1" >>confdefs.h +printf "%s\n" "#define _Py_HAVE_CURSES_SCR_DUMP 1" >>confdefs.h + +fi + + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function scr_set" >&5 +printf %s "checking for curses function scr_set... " >&6; } +if test ${ac_cv_lib_curses_scr_set+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define NCURSES_OPAQUE 0 +#if defined(HAVE_NCURSESW_NCURSES_H) +# include +#elif defined(HAVE_NCURSESW_CURSES_H) +# include +#elif defined(HAVE_NCURSES_NCURSES_H) +# include +#elif defined(HAVE_NCURSES_CURSES_H) +# include +#elif defined(HAVE_NCURSES_H) +# include +#elif defined(HAVE_CURSES_H) +# include +#endif + +int +main (void) +{ + + #ifndef scr_set + void * volatile x = (void *)scr_set; (void)x; + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_curses_scr_set=yes +else case e in #( + e) ac_cv_lib_curses_scr_set=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_scr_set" >&5 +printf "%s\n" "$ac_cv_lib_curses_scr_set" >&6; } + if test "x$ac_cv_lib_curses_scr_set" = xyes +then : + +printf "%s\n" "#define _Py_HAVE_CURSES_SCR_SET 1" >>confdefs.h fi + + CPPFLAGS=$ac_save_cppflags fi @@ -31646,7 +34668,7 @@ LIBS=$save_LIBS { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for device files" >&5 printf "%s\n" "$as_me: checking for device files" >&6;} -if test "$ac_sys_system" = "Linux-android" || test "$ac_sys_system" = "iOS"; then +if test "$ac_sys_system" = "Linux-android" -o "$ac_sys_system" = "iOS" -o "$ac_sys_system" = "tvOS" -o "$ac_sys_system" = "visionOS" -o "$ac_sys_system" = "watchOS" ; then ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no else @@ -31991,95 +35013,6 @@ done { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: done" >&5 printf "%s\n" "done" >&6; } -# Availability of -O2: -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -O2" >&5 -printf %s "checking for -O2... " >&6; } -if test ${ac_cv_compile_o2+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) -saved_cflags="$CFLAGS" -CFLAGS="-O2" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_compile_o2=yes -else case e in #( - e) ac_cv_compile_o2=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -CFLAGS="$saved_cflags" - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_compile_o2" >&5 -printf "%s\n" "$ac_cv_compile_o2" >&6; } - -# _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect: -# http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for glibc _FORTIFY_SOURCE/memmove bug" >&5 -printf %s "checking for glibc _FORTIFY_SOURCE/memmove bug... " >&6; } -saved_cflags="$CFLAGS" -CFLAGS="-O2 -D_FORTIFY_SOURCE=2" -if test "$ac_cv_compile_o2" = no; then - CFLAGS="" -fi -if test "$cross_compiling" = yes -then : - have_glibc_memmove_bug=undefined -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -void foo(void *p, void *q) { memmove(p, q, 19); } -int main(void) { - char a[32] = "123456789000000000"; - foo(&a[9], a); - if (strcmp(a, "123456789123456789000000000") != 0) - return 1; - foo(a, &a[9]); - if (strcmp(a, "123456789000000000") != 0) - return 1; - return 0; -} - -_ACEOF -if ac_fn_c_try_run "$LINENO" -then : - have_glibc_memmove_bug=no -else case e in #( - e) have_glibc_memmove_bug=yes ;; -esac -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext ;; -esac -fi - -CFLAGS="$saved_cflags" -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_glibc_memmove_bug" >&5 -printf "%s\n" "$have_glibc_memmove_bug" >&6; } -if test "$have_glibc_memmove_bug" = yes; then - -printf "%s\n" "#define HAVE_GLIBC_MEMMOVE_BUG 1" >>confdefs.h - -fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we need to manually block large inlining in ceval.c" >&5 printf %s "checking if we need to manually block large inlining in ceval.c... " >&6; } if test "$cross_compiling" = yes @@ -32126,64 +35059,6 @@ if test "$block_huge_inlining_in_ceval" = yes && test "$ac_cv_computed_gotos" = fi -if test "$ac_cv_gcc_asm_for_x87" = yes; then - # Some versions of gcc miscompile inline asm: - # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491 - # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html - case $ac_cv_cc_name in - gcc) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gcc ipa-pure-const bug" >&5 -printf %s "checking for gcc ipa-pure-const bug... " >&6; } - saved_cflags="$CFLAGS" - CFLAGS="-O2" - if test "$cross_compiling" = yes -then : - have_ipa_pure_const_bug=undefined -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - __attribute__((noinline)) int - foo(int *p) { - int r; - asm ( "movl \$6, (%1)\n\t" - "xorl %0, %0\n\t" - : "=r" (r) : "r" (p) : "memory" - ); - return r; - } - int main(void) { - int p = 8; - if ((foo(&p) ? : p) != 6) - return 1; - return 0; - } - -_ACEOF -if ac_fn_c_try_run "$LINENO" -then : - have_ipa_pure_const_bug=no -else case e in #( - e) have_ipa_pure_const_bug=yes ;; -esac -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext ;; -esac -fi - - CFLAGS="$saved_cflags" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_ipa_pure_const_bug" >&5 -printf "%s\n" "$have_ipa_pure_const_bug" >&6; } - if test "$have_ipa_pure_const_bug" = yes; then - -printf "%s\n" "#define HAVE_IPA_PURE_CONST_BUG 1" >>confdefs.h - - fi - ;; - esac -fi - # ensurepip option { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ensurepip" >&5 printf %s "checking for ensurepip... " >&6; } @@ -32199,7 +35074,7 @@ else case e in #( with_ensurepip=no ;; #( WASI) : with_ensurepip=no ;; #( - iOS) : + iOS|tvOS|visionOS|watchOS) : with_ensurepip=no ;; #( *) : with_ensurepip=upgrade @@ -32283,7 +35158,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #include #include #include - #include + #include // GRND_NONBLOCK + + #if !defined(SYS_getrandom) && defined(__NR_getrandom) + # define SYS_getrandom __NR_getrandom + #endif int main(void) { char buffer[1]; @@ -33055,6 +35934,13 @@ fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $TEST_MODULES" >&5 printf "%s\n" "$TEST_MODULES" >&6; } +if test "$ac_sys_system" = "iOS" && test -z "$PYTHONFRAMEWORK" +then : + if test "$TEST_MODULES" != "no" +then : + as_fn_error $? "iOS non-framework builds must use --disable-test-modules" "$LINENO" 5 +fi +fi # Check for --with-build-details-suffix @@ -33193,6 +36079,9 @@ case "$ac_sys_system" in NetBSD*) _PYTHREAD_NAME_MAXLEN=15;; # gh-131268 Darwin) _PYTHREAD_NAME_MAXLEN=63;; iOS) _PYTHREAD_NAME_MAXLEN=63;; + tvOS) _PYTHREAD_NAME_MAXLEN=63;; + visionOS) _PYTHREAD_NAME_MAXLEN=63;; + watchOS) _PYTHREAD_NAME_MAXLEN=63;; FreeBSD*) _PYTHREAD_NAME_MAXLEN=19;; # gh-131268 OpenBSD*) _PYTHREAD_NAME_MAXLEN=23;; # gh-131268 CYGWIN*) _PYTHREAD_NAME_MAXLEN=16;; @@ -33225,7 +36114,7 @@ case $ac_sys_system in #( ;; #( Darwin) : ;; #( - iOS) : + iOS|tvOS|visionOS|watchOS) : @@ -33345,6 +36234,14 @@ case $host_cpu in #( esac +if test "$ac_sys_system" = "iOS" && test -z "$PYTHONFRAMEWORK" +then : + if test "$MODULE_BUILDTYPE" != "static" +then : + as_fn_error $? "iOS non-framework builds must use MODULE_BUILDTYPE=static" "$LINENO" 5 +fi +fi + MODULE_BLOCK= @@ -37532,6 +40429,9 @@ do "Mac/Resources/framework/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/framework/Info.plist" ;; "Mac/Resources/app/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/app/Info.plist" ;; "Platforms/Apple/iOS/Resources/Info.plist") CONFIG_FILES="$CONFIG_FILES Platforms/Apple/iOS/Resources/Info.plist" ;; + "Platforms/Apple/tvOS/Resources/Info.plist") CONFIG_FILES="$CONFIG_FILES Platforms/Apple/tvOS/Resources/Info.plist" ;; + "Platforms/Apple/visionOS/Resources/Info.plist") CONFIG_FILES="$CONFIG_FILES Platforms/Apple/visionOS/Resources/Info.plist" ;; + "Platforms/Apple/watchOS/Resources/Info.plist") CONFIG_FILES="$CONFIG_FILES Platforms/Apple/watchOS/Resources/Info.plist" ;; "Makefile.pre") CONFIG_FILES="$CONFIG_FILES Makefile.pre" ;; "Misc/python.pc") CONFIG_FILES="$CONFIG_FILES Misc/python.pc" ;; "Misc/python-embed.pc") CONFIG_FILES="$CONFIG_FILES Misc/python-embed.pc" ;; @@ -38148,12 +41048,12 @@ fi printf "%s\n" "$as_me: creating Makefile" >&6;} $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \ -s Modules \ - Modules/Setup.local Modules/Setup.stdlib Modules/Setup.bootstrap $srcdir/Modules/Setup + Modules/Setup.local Modules/Setup.stdlib -b Modules/Setup.bootstrap $srcdir/Modules/Setup if test $? -ne 0; then as_fn_error $? "makesetup failed" "$LINENO" 5 fi -mv config.c Modules +mv config.c config_bootstrap.c Modules if test -z "$PKG_CONFIG"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config is missing. Some dependencies may not be detected correctly." >&5 diff --git a/configure.ac b/configure.ac index ad8280349466e06..c73f8f2fd28a1c3 100644 --- a/configure.ac +++ b/configure.ac @@ -61,7 +61,7 @@ AC_DEFUN([PY_CHECK_FUNC], [for $1], [py_var], [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([$2], [void *x=$1])], + [AC_LANG_PROGRAM([$2], [(void)$1])], [AS_VAR_SET([py_var], [yes])], [AS_VAR_SET([py_var], [no])])] ) @@ -73,6 +73,12 @@ AC_DEFUN([PY_CHECK_FUNC], AS_VAR_POPDEF([py_define]) ]) +dnl PY_CHECK_FUNC_PRIVATE(FUNCTION, [INCLUDES], [AC_DEFINE-VAR]) +dnl Similar to PY_CHECK_FUNC but define macro _Py_HAVE_xxx instead of HAVE_xxx +AC_DEFUN([PY_CHECK_FUNC_PRIVATE], +[ PY_CHECK_FUNC([$1], [$2], m4_ifblank([$3], [[_Py_HAVE_]m4_toupper($1)], [$3])) +]) + dnl PY_CHECK_LIB(LIBRARY, FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES]) dnl Like AC_CHECK_LIB() but does not modify LIBS AC_DEFUN([PY_CHECK_LIB], @@ -122,9 +128,9 @@ HAS_GIT=no-repository fi if test $HAS_GIT = found then - GITVERSION="git --git-dir \$(srcdir)/.git rev-parse --short HEAD" - GITTAG="git --git-dir \$(srcdir)/.git describe --all --always --dirty" - GITBRANCH="git --git-dir \$(srcdir)/.git name-rev --name-only HEAD" + GITVERSION="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) rev-parse --short HEAD" + GITTAG="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) describe --all --always --dirty" + GITBRANCH="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) name-rev --name-only HEAD" else GITVERSION="" GITTAG="" @@ -164,7 +170,11 @@ AC_ARG_WITH([build-python], dnl Build Python interpreter is used for regeneration and freezing. ac_cv_prog_PYTHON_FOR_REGEN=$with_build_python PYTHON_FOR_FREEZE="$with_build_python" - PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) _PYTHON_SYSCONFIGDATA_PATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`) '$with_build_python + PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) PYTHONPATH=$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) _PYTHON_SYSCONFIGDATA_PATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`) '$with_build_python + dnl _PYTHON_HOST_PLATFORM is only set when cross compiling. + AS_VAR_IF([cross_compiling], [yes], + [PYTHON_FOR_BUILD='_PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) '"$PYTHON_FOR_BUILD"] + ) AC_MSG_RESULT([$with_build_python]) ], [ AS_VAR_IF([cross_compiling], [yes], @@ -176,6 +186,13 @@ AC_ARG_WITH([build-python], ) AC_SUBST([PYTHON_FOR_BUILD]) +# Module import checks must run with the target interpreter on native builds. +AS_VAR_IF([cross_compiling], [yes], + [MODULE_CHECK_COMMAND='$(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/check_extension_modules.py --cross-compiling'], + [MODULE_CHECK_COMMAND='$(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/Tools/build/check_extension_modules.py --no-cross-compiling'] +) +AC_SUBST([MODULE_CHECK_COMMAND]) + AC_MSG_CHECKING([for Python interpreter freezing]) AC_MSG_RESULT([$PYTHON_FOR_FREEZE]) AC_SUBST([PYTHON_FOR_FREEZE]) @@ -188,6 +205,9 @@ AS_VAR_IF([cross_compiling], [yes], FREEZE_MODULE='$(FREEZE_MODULE_BOOTSTRAP)' FREEZE_MODULE_DEPS='$(FREEZE_MODULE_BOOTSTRAP_DEPS)' PYTHON_FOR_BUILD_DEPS='' + # The build Python is a separate interpreter. RUNSHARED would make it + # load the in-tree libpython, which may need a different libc. + RUNSHARED_FOR_BUILD='' ], [ dnl internal build tools also depend on Programs/_freeze_module and _bootstrap_python. @@ -196,6 +216,7 @@ AS_VAR_IF([cross_compiling], [yes], FREEZE_MODULE='$(PYTHON_FOR_FREEZE) $(srcdir)/Programs/_freeze_module.py' FREEZE_MODULE_DEPS="_bootstrap_python \$(srcdir)/Programs/_freeze_module.py" PYTHON_FOR_BUILD_DEPS='$(BUILDPYTHON)' + RUNSHARED_FOR_BUILD='$(RUNSHARED)' ] ) AC_SUBST([FREEZE_MODULE_BOOTSTRAP]) @@ -203,6 +224,7 @@ AC_SUBST([FREEZE_MODULE_BOOTSTRAP_DEPS]) AC_SUBST([FREEZE_MODULE]) AC_SUBST([FREEZE_MODULE_DEPS]) AC_SUBST([PYTHON_FOR_BUILD_DEPS]) +AC_SUBST([RUNSHARED_FOR_BUILD]) AC_CHECK_PROGS([PYTHON_FOR_REGEN], [python$PACKAGE_VERSION python3.16 python3.15 python3.14 python3.13 python3.12 python3.11 python3.10 python3 python], @@ -232,11 +254,6 @@ AH_TOP([ #define Py_PYCONFIG_H ]) AH_BOTTOM([ -/* Define the macros needed if on a UnixWare 7.x system. */ -#if defined(__USLC__) && defined(__SCO_VERSION__) -#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ -#endif - #endif /*Py_PYCONFIG_H*/ ]) @@ -339,6 +356,15 @@ then *-apple-ios*) ac_sys_system=iOS ;; + *-apple-tvos*) + ac_sys_system=tvOS + ;; + *-apple-xros*) + ac_sys_system=visionOS + ;; + *-apple-watchos*) + ac_sys_system=watchOS + ;; *-*-darwin*) ac_sys_system=Darwin ;; @@ -362,8 +388,7 @@ then ac_sys_release= else ac_sys_system=`uname -s` - if test "$ac_sys_system" = "AIX" \ - -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then + if test "$ac_sys_system" = "AIX"; then ac_sys_release=`uname -v` else ac_sys_release=`uname -r` @@ -417,7 +442,7 @@ AC_SUBST([host_exec_prefix]) # On cross-compile builds, configure will look for a host-specific compiler by # prepending the user-provided host triple to the required binary name. # -# On iOS, this results in binaries like "arm64-apple-ios13.0-simulator-gcc", +# On iOS/tvOS/visionOS/watchOS, this results in binaries like "arm64-apple-ios13.0-simulator-gcc", # which isn't a binary that exists, and isn't very convenient, as it contains the # iOS version. As the default cross-compiler name won't exist, configure falls # back to gcc, which *definitely* won't work. We're providing wrapper scripts for @@ -432,14 +457,36 @@ if test -z "$AR"; then aarch64-apple-ios*-simulator) AR=arm64-apple-ios-simulator-ar ;; aarch64-apple-ios*) AR=arm64-apple-ios-ar ;; x86_64-apple-ios*-simulator) AR=x86_64-apple-ios-simulator-ar ;; + + aarch64-apple-tvos*-simulator) AR=arm64-apple-tvos-simulator-ar ;; + aarch64-apple-tvos*) AR=arm64-apple-tvos-ar ;; + x86_64-apple-tvos*-simulator) AR=x86_64-apple-tvos-simulator-ar ;; + + aarch64-apple-xros*-simulator) AR=arm64-apple-xros-simulator-ar ;; + aarch64-apple-xros*) AR=arm64-apple-xros-ar ;; + + aarch64-apple-watchos*-simulator) AR=arm64-apple-watchos-simulator-ar ;; + aarch64-apple-watchos*) AR=arm64_32-apple-watchos-ar ;; + x86_64-apple-watchos*-simulator) AR=x86_64-apple-watchos-simulator-ar ;; *) - esac + esac fi if test -z "$CC"; then case "$host" in aarch64-apple-ios*-simulator) CC=arm64-apple-ios-simulator-clang ;; aarch64-apple-ios*) CC=arm64-apple-ios-clang ;; x86_64-apple-ios*-simulator) CC=x86_64-apple-ios-simulator-clang ;; + + aarch64-apple-tvos*-simulator) CC=arm64-apple-tvos-simulator-clang ;; + aarch64-apple-tvos*) CC=arm64-apple-tvos-clang ;; + x86_64-apple-tvos*-simulator) CC=x86_64-apple-tvos-simulator-clang ;; + + aarch64-apple-xros*-simulator) CC=arm64-apple-xros-simulator-clang ;; + aarch64-apple-xros*) CC=arm64-apple-xros-clang ;; + + aarch64-apple-watchos*-simulator) CC=arm64-apple-watchos-simulator-clang ;; + aarch64-apple-watchos*) CC=arm64_32-apple-watchos-clang ;; + x86_64-apple-watchos*-simulator) CC=x86_64-apple-watchos-simulator-clang ;; *) esac fi @@ -448,6 +495,17 @@ if test -z "$CPP"; then aarch64-apple-ios*-simulator) CPP=arm64-apple-ios-simulator-cpp ;; aarch64-apple-ios*) CPP=arm64-apple-ios-cpp ;; x86_64-apple-ios*-simulator) CPP=x86_64-apple-ios-simulator-cpp ;; + + aarch64-apple-tvos*-simulator) CPP=arm64-apple-tvos-simulator-cpp ;; + aarch64-apple-tvos*) CPP=arm64-apple-tvos-cpp ;; + x86_64-apple-tvos*-simulator) CPP=x86_64-apple-tvos-simulator-cpp ;; + + aarch64-apple-xros*-simulator) CPP=arm64-apple-xros-simulator-cpp ;; + aarch64-apple-xros*) CPP=arm64-apple-xros-cpp ;; + + aarch64-apple-watchos*-simulator) CPP=arm64-apple-watchos-simulator-cpp ;; + aarch64-apple-watchos*) CPP=arm64_32-apple-watchos-cpp ;; + x86_64-apple-watchos*-simulator) CPP=x86_64-apple-watchos-simulator-cpp ;; *) esac fi @@ -456,6 +514,17 @@ if test -z "$CXX"; then aarch64-apple-ios*-simulator) CXX=arm64-apple-ios-simulator-clang++ ;; aarch64-apple-ios*) CXX=arm64-apple-ios-clang++ ;; x86_64-apple-ios*-simulator) CXX=x86_64-apple-ios-simulator-clang++ ;; + + aarch64-apple-tvos*-simulator) CXX=arm64-apple-tvos-simulator-clang++ ;; + aarch64-apple-tvos*) CXX=arm64-apple-tvos-clang++ ;; + x86_64-apple-tvos*-simulator) CXX=x86_64-apple-tvos-simulator-clang++ ;; + + aarch64-apple-xros*-simulator) CXX=arm64-apple-xros-simulator-clang++ ;; + aarch64-apple-xros*) CXX=arm64-apple-xros-clang++ ;; + + aarch64-apple-watchos*-simulator) CXX=arm64-apple-watchos-simulator-clang++ ;; + aarch64-apple-watchos*) CXX=arm64_32-apple-watchos-clang++ ;; + x86_64-apple-watchos*-simulator) CXX=x86_64-apple-watchos-simulator-clang++ ;; *) esac fi @@ -570,37 +639,36 @@ AC_ARG_ENABLE([framework], case $enableval in yes) case $ac_sys_system in - Darwin) enableval=/Library/Frameworks ;; - iOS) enableval=Platforms/Apple/iOS/Frameworks/\$\(MULTIARCH\) ;; + Darwin) enableval=/Library/Frameworks ;; + iOS) enableval=Platforms/Apple/iOS/Frameworks/\$\(MULTIARCH\) ;; + tvOS) enableval=Platforms/Apple/tvOS/Frameworks/\$\(MULTIARCH\) ;; + visionOS) enableval=Platforms/Apple/visionOS/Frameworks/\$\(MULTIARCH\) ;; + watchOS) enableval=Platforms/Apple/watchOS/Frameworks/\$\(MULTIARCH\) ;; *) AC_MSG_ERROR([Unknown platform for framework build]) esac esac case $enableval in no) - case $ac_sys_system in - iOS) AC_MSG_ERROR([iOS builds must use --enable-framework]) ;; - *) - PYTHONFRAMEWORK= - PYTHONFRAMEWORKDIR=no-framework - PYTHONFRAMEWORKPREFIX= - PYTHONFRAMEWORKINSTALLDIR= - PYTHONFRAMEWORKINSTALLNAMEPREFIX= - RESSRCDIR= - FRAMEWORKINSTALLFIRST= - FRAMEWORKINSTALLLAST= - FRAMEWORKALTINSTALLFIRST= - FRAMEWORKALTINSTALLLAST= - FRAMEWORKPYTHONW= - INSTALLTARGETS="commoninstall bininstall maninstall" - - if test "x${prefix}" = "xNONE"; then - FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" - else - FRAMEWORKUNIXTOOLSPREFIX="${prefix}" - fi - enable_framework= - esac + PYTHONFRAMEWORK= + PYTHONFRAMEWORKDIR=no-framework + PYTHONFRAMEWORKPREFIX= + PYTHONFRAMEWORKINSTALLDIR= + PYTHONFRAMEWORKINSTALLNAMEPREFIX= + RESSRCDIR= + FRAMEWORKINSTALLFIRST= + FRAMEWORKINSTALLLAST= + FRAMEWORKALTINSTALLFIRST= + FRAMEWORKALTINSTALLLAST= + FRAMEWORKPYTHONW= + INSTALLTARGETS="commoninstall bininstall maninstall" + + if test "x${prefix}" = "xNONE"; then + FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" + else + FRAMEWORKUNIXTOOLSPREFIX="${prefix}" + fi + enable_framework= ;; *) PYTHONFRAMEWORKPREFIX="${enableval}" @@ -682,34 +750,72 @@ AC_ARG_ENABLE([framework], AC_CONFIG_FILES([Platforms/Apple/iOS/Resources/Info.plist]) ;; + tvOS) : + FRAMEWORKINSTALLFIRST="frameworkinstallunversionedstructure" + FRAMEWORKALTINSTALLFIRST="frameworkinstallunversionedstructure " + FRAMEWORKINSTALLLAST="frameworkinstallmobileheaders" + FRAMEWORKALTINSTALLLAST="frameworkinstallmobileheaders" + FRAMEWORKPYTHONW= + INSTALLTARGETS="libinstall inclinstall sharedinstall" + + prefix=$PYTHONFRAMEWORKPREFIX + PYTHONFRAMEWORKINSTALLNAMEPREFIX="@rpath/$PYTHONFRAMEWORKDIR" + RESSRCDIR=Platforms/Apple/tvOS/Resources + + AC_CONFIG_FILES([Platforms/Apple/tvOS/Resources/Info.plist]) + ;; + visionOS) : + FRAMEWORKINSTALLFIRST="frameworkinstallunversionedstructure" + FRAMEWORKALTINSTALLFIRST="frameworkinstallunversionedstructure " + FRAMEWORKINSTALLLAST="frameworkinstallmobileheaders" + FRAMEWORKALTINSTALLLAST="frameworkinstallmobileheaders" + FRAMEWORKPYTHONW= + INSTALLTARGETS="libinstall inclinstall sharedinstall" + + prefix=$PYTHONFRAMEWORKPREFIX + PYTHONFRAMEWORKINSTALLNAMEPREFIX="@rpath/$PYTHONFRAMEWORKDIR" + RESSRCDIR=Platforms/Apple/visionOS/Resources + + AC_CONFIG_FILES([Platforms/Apple/visionOS/Resources/Info.plist]) + ;; + watchOS) : + FRAMEWORKINSTALLFIRST="frameworkinstallunversionedstructure" + FRAMEWORKALTINSTALLFIRST="frameworkinstallunversionedstructure " + FRAMEWORKINSTALLLAST="frameworkinstallmobileheaders" + FRAMEWORKALTINSTALLLAST="frameworkinstallmobileheaders" + FRAMEWORKPYTHONW= + INSTALLTARGETS="libinstall inclinstall sharedinstall" + + prefix=$PYTHONFRAMEWORKPREFIX + PYTHONFRAMEWORKINSTALLNAMEPREFIX="@rpath/$PYTHONFRAMEWORKDIR" + RESSRCDIR=Platforms/Apple/watchOS/Resources + + AC_CONFIG_FILES([Platforms/Apple/watchOS/Resources/Info.plist]) + ;; *) AC_MSG_ERROR([Unknown platform for framework build]) ;; esac esac ],[ - case $ac_sys_system in - iOS) AC_MSG_ERROR([iOS builds must use --enable-framework]) ;; - *) - PYTHONFRAMEWORK= - PYTHONFRAMEWORKDIR=no-framework - PYTHONFRAMEWORKPREFIX= - PYTHONFRAMEWORKINSTALLDIR= - PYTHONFRAMEWORKINSTALLNAMEPREFIX= - RESSRCDIR= - FRAMEWORKINSTALLFIRST= - FRAMEWORKINSTALLLAST= - FRAMEWORKALTINSTALLFIRST= - FRAMEWORKALTINSTALLLAST= - FRAMEWORKPYTHONW= - INSTALLTARGETS="commoninstall bininstall maninstall" - if test "x${prefix}" = "xNONE" ; then - FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" - else - FRAMEWORKUNIXTOOLSPREFIX="${prefix}" - fi - enable_framework= - esac + PYTHONFRAMEWORK= + PYTHONFRAMEWORKDIR=no-framework + PYTHONFRAMEWORKPREFIX= + PYTHONFRAMEWORKINSTALLDIR= + PYTHONFRAMEWORKINSTALLNAMEPREFIX= + RESSRCDIR= + FRAMEWORKINSTALLFIRST= + FRAMEWORKINSTALLLAST= + FRAMEWORKALTINSTALLFIRST= + FRAMEWORKALTINSTALLLAST= + FRAMEWORKPYTHONW= + INSTALLTARGETS="commoninstall bininstall maninstall" + if test "x${prefix}" = "xNONE" ; then + FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" + else + FRAMEWORKUNIXTOOLSPREFIX="${prefix}" + fi + enable_framework= ]) AC_SUBST([PYTHONFRAMEWORK]) AC_SUBST([PYTHONFRAMEWORKIDENTIFIER]) @@ -742,8 +848,8 @@ AC_ARG_WITH( case "$withval" in yes) case $ac_sys_system in - Darwin|iOS) - # iOS is able to share the macOS patch + Darwin|iOS|tvOS|visionOS|watchOS) + # iOS/tvOS/visionOS/watchOS is able to share the macOS patch APP_STORE_COMPLIANCE_PATCH="Mac/Resources/app-store-compliance.patch" ;; *) AC_MSG_ERROR([no default app store compliance patch available for $ac_sys_system]) ;; @@ -757,8 +863,8 @@ AC_ARG_WITH( esac ],[ case $ac_sys_system in - iOS) - # Always apply the compliance patch on iOS; we can use the macOS patch + iOS|tvOS|visionOS|watchOS) + # Always apply the compliance patch on iOS/tvOS/visionOS/watchOS; we can use the macOS patch APP_STORE_COMPLIANCE_PATCH="Mac/Resources/app-store-compliance.patch" AC_MSG_RESULT([applying default app store compliance patch]) ;; @@ -771,6 +877,8 @@ AC_ARG_WITH( ]) AC_SUBST([APP_STORE_COMPLIANCE_PATCH]) +EXPORT_XROS_DEPLOYMENT_TARGET='#' + AC_SUBST([_PYTHON_HOST_PLATFORM]) if test "$cross_compiling" = yes; then case "$host" in @@ -809,6 +917,70 @@ if test "$cross_compiling" = yes; then ;; esac ;; + *-apple-tvos*) + _host_os=`echo $host | cut -d '-' -f3` + _host_device=`echo $host | cut -d '-' -f4` + _host_device=${_host_device:=os} + + # TVOS_DEPLOYMENT_TARGET is the minimum supported tvOS version + AC_MSG_CHECKING([tvOS deployment target]) + TVOS_DEPLOYMENT_TARGET=${_host_os:4} + TVOS_DEPLOYMENT_TARGET=${TVOS_DEPLOYMENT_TARGET:=12.0} + AC_MSG_RESULT([$TVOS_DEPLOYMENT_TARGET]) + + case "$host_cpu" in + aarch64) + _host_ident=${TVOS_DEPLOYMENT_TARGET}-arm64-appletv${_host_device} + ;; + *) + _host_ident=${TVOS_DEPLOYMENT_TARGET}-$host_cpu-appletv${_host_device} + ;; + esac + ;; + *-apple-xros*) + _host_os=`echo $host | cut -d '-' -f3` + _host_device=`echo $host | cut -d '-' -f4` + _host_device=${_host_device:=os} + + # XROS_DEPLOYMENT_TARGET is the minimum supported visionOS version + AC_MSG_CHECKING([visionOS deployment target]) + XROS_DEPLOYMENT_TARGET=${_host_os:8} + XROS_DEPLOYMENT_TARGET=${XROS_DEPLOYMENT_TARGET:=2.0} + AC_MSG_RESULT([$XROS_DEPLOYMENT_TARGET]) + AC_MSG_CHECKING([exporting flag of visionOS deployment target]) + export XROS_DEPLOYMENT_TARGET + EXPORT_XROS_DEPLOYMENT_TARGET='' + AC_MSG_RESULT([$EXPORT_XROS_DEPLOYMENT_TARGET]) + + case "$host_cpu" in + aarch64) + _host_ident=${XROS_DEPLOYMENT_TARGET}-arm64-xr${_host_device} + ;; + *) + _host_ident=${XROS_DEPLOYMENT_TARGET}-$host_cpu-xr${_host_device} + ;; + esac + ;; + *-apple-watchos*) + _host_os=`echo $host | cut -d '-' -f3` + _host_device=`echo $host | cut -d '-' -f4` + _host_device=${_host_device:=os} + + # WATCHOS_DEPLOYMENT_TARGET is the minimum supported watchOS version + AC_MSG_CHECKING([watchOS deployment target]) + WATCHOS_DEPLOYMENT_TARGET=${_host_os:7} + WATCHOS_DEPLOYMENT_TARGET=${WATCHOS_DEPLOYMENT_TARGET:=9.0} + AC_MSG_RESULT([$WATCHOS_DEPLOYMENT_TARGET]) + + case "$host_cpu" in + aarch64) + _host_ident=${WATCHOS_DEPLOYMENT_TARGET}-arm64-watch${_host_device} + ;; + *) + _host_ident=${WATCHOS_DEPLOYMENT_TARGET}-$host_cpu-watch${_host_device} + ;; + esac + ;; *-*-darwin*) case "$host_cpu" in arm*) @@ -846,19 +1018,6 @@ fi # (which may remove their limitations). dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output case $ac_sys_system/$ac_sys_release in - # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, - # even though select is a POSIX function. Reported by J. Ribbens. - # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. - # In addition, Stefan Krah confirms that issue #1244610 exists through - # OpenBSD 4.6, but is fixed in 4.7. - OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@) - define_xopen_source=no - # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is - # also defined. This can be overridden by defining _BSD_SOURCE - # As this has a different meaning on Linux, only define it on OpenBSD - AC_DEFINE([_BSD_SOURCE], [1], - [Define on OpenBSD to activate all library features]) - ;; OpenBSD/*) # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is # also defined. This can be overridden by defining _BSD_SOURCE @@ -866,27 +1025,10 @@ case $ac_sys_system/$ac_sys_release in AC_DEFINE([_BSD_SOURCE], [1], [Define on OpenBSD to activate all library features]) ;; - # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of - # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by - # Marc Recht - NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@) - define_xopen_source=no;; - # From the perspective of Solaris, _XOPEN_SOURCE is not so much a - # request to enable features supported by the standard as a request - # to disable features not supported by the standard. The best way - # for Python to use Solaris is simply to leave _XOPEN_SOURCE out - # entirely and define __EXTENSIONS__ instead. + # On Solaris, _XOPEN_SOURCE=800 hides platform specific features. + # A lower level is defined below. SunOS/*) define_xopen_source=no;; - # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE, - # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice. - # Reconfirmed for 7.1.4 by Martin v. Loewis. - OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@) - define_xopen_source=no;; - # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE, - # but used in struct sockaddr.sa_family. Reported by Tim Rice. - SCO_SV/3.2) - define_xopen_source=no;; # On MacOS X 10.2, a bug in ncurses.h means that it craps out if # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which # identifies itself as Darwin/7.* @@ -898,9 +1040,15 @@ case $ac_sys_system/$ac_sys_release in define_xopen_source=no;; Darwin/@<:@[12]@:>@@<:@0-9@:>@.*) define_xopen_source=no;; - # On iOS, defining _POSIX_C_SOURCE also disables platform specific features. + # On iOS/tvOS/visionOS/watchOS, defining _POSIX_C_SOURCE also disables platform specific features. iOS/*) define_xopen_source=no;; + tvOS/*) + define_xopen_source=no;; + visionOS/*) + define_xopen_source=no;; + watchOS/*) + define_xopen_source=no;; # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from # defining NI_NUMERICHOST. QNX/6.3.2) @@ -935,6 +1083,20 @@ then AC_DEFINE([_POSIX_C_SOURCE], [202405L], [Define to activate features from IEEE Std 1003.1-2024]) + + # Defining _POSIX_C_SOURCE and _XOPEN_SOURCE hides C23 library + # declarations on FreeBSD (e.g. sinpi() in math.h) when compiling + # with -std=c11. Defining _ISOC23_SOURCE makes them visible again. + AC_DEFINE([_ISOC23_SOURCE], [1], + [Define to activate ISO C23 library declarations]) +elif test "$ac_sys_system" = "SunOS" +then + # On illumos the socket ancillary-data API (CMSG_*, sendmsg(), recvmsg()) + # is declared only with _XOPEN_SOURCE >= 600; Solaris declares it anyway. + # __EXTENSIONS__ keeps the platform specific features which _XOPEN_SOURCE + # would otherwise hide. See gh-57208. + AC_DEFINE([_XOPEN_SOURCE], [600], + [Define to the level of X/Open that your system supports]) fi # On HP-UX mbstate_t requires _INCLUDE__STDC_A1_SOURCE @@ -959,8 +1121,15 @@ AC_SUBST([EXPORT_MACOSX_DEPLOYMENT_TARGET]) CONFIGURE_MACOSX_DEPLOYMENT_TARGET= EXPORT_MACOSX_DEPLOYMENT_TARGET='#' -# Record the value of IPHONEOS_DEPLOYMENT_TARGET enforced by the selected host triple. +# Record the value of IPHONEOS_DEPLOYMENT_TARGET / TVOS_DEPLOYMENT_TARGET / +# XROS_DEPLOYMENT_TARGET / WATCHOS_DEPLOYMENT_TARGET enforced by the selected host triple. AC_SUBST([IPHONEOS_DEPLOYMENT_TARGET]) +AC_SUBST([TVOS_DEPLOYMENT_TARGET]) +AC_SUBST([XROS_DEPLOYMENT_TARGET]) +AC_SUBST([WATCHOS_DEPLOYMENT_TARGET]) + +# XROS_DEPLOYMENT_TARGET should get exported +AC_SUBST([EXPORT_XROS_DEPLOYMENT_TARGET]) # checks for alternative programs @@ -985,20 +1154,37 @@ if test -z "$CFLAGS"; then fi dnl Emscripten SDK and WASI SDK default to wasm32. -dnl On Emscripten use MEMORY64 setting to build target wasm64-emscripten. +dnl On Emscripten use -m64 to build target wasm64-emscripten. dnl for wasm64. AS_CASE([$host], [wasm64-*-emscripten], [ - AS_VAR_APPEND([CFLAGS], [" -sMEMORY64=1"]) - AS_VAR_APPEND([LDFLAGS], [" -sMEMORY64=1"]) + AS_VAR_APPEND([CFLAGS], [" -m64"]) + AS_VAR_APPEND([LDFLAGS], [" -m64"]) ], ) -dnl Add the compiler flag for the iOS minimum supported OS version. -AS_CASE([$ac_sys_system], - [iOS], [ +dnl Add the compiler flag for the iOS/tvOS/watchOS minimum supported OS +dnl version. visionOS doesn't use an explicit -mxros-version-min option - +dnl it encodes the min version into the target triple. +AS_CASE([$host], + [*-apple-ios*-simulator], [ + AS_VAR_APPEND([CFLAGS], [" -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"]) + AS_VAR_APPEND([LDFLAGS], [" -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"]) + ],[*-apple-ios*], [ AS_VAR_APPEND([CFLAGS], [" -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"]) AS_VAR_APPEND([LDFLAGS], [" -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"]) + ],[*-apple-tvos*-simulator], [ + AS_VAR_APPEND([CFLAGS], [" -mtvos-simulator-version-min=${TVOS_DEPLOYMENT_TARGET}"]) + AS_VAR_APPEND([LDFLAGS], [" -mtvos-simulator-version-min=${TVOS_DEPLOYMENT_TARGET}"]) + ],[*-apple-tvos*], [ + AS_VAR_APPEND([CFLAGS], [" -mtvos-version-min=${TVOS_DEPLOYMENT_TARGET}"]) + AS_VAR_APPEND([LDFLAGS], [" -mtvos-version-min=${TVOS_DEPLOYMENT_TARGET}"]) + ],[*-apple-watchos*-simulator], [ + AS_VAR_APPEND([CFLAGS], [" -mwatchos-simulator-version-min=${WATCHOS_DEPLOYMENT_TARGET}"]) + AS_VAR_APPEND([LDFLAGS], [" -mwatchos-simulator-version-min=${WATCHOS_DEPLOYMENT_TARGET}"]) + ],[*-apple-watchos*], [ + AS_VAR_APPEND([CFLAGS], [" -mwatchos-version-min=${WATCHOS_DEPLOYMENT_TARGET}"]) + AS_VAR_APPEND([LDFLAGS], [" -mwatchos-version-min=${WATCHOS_DEPLOYMENT_TARGET}"]) ], ) @@ -1090,6 +1276,8 @@ AC_CACHE_CHECK([for CC compiler name], [ac_cv_cc_name], [ cat > conftest.c </dev/null)] ) AC_SUBST([MULTIARCH]) @@ -1208,10 +1401,14 @@ dnl will have multiple sysconfig modules (one for each CPU architecture), but dnl use a single "fat" binary at runtime. SOABI_PLATFORM is the component of dnl the PLATFORM_TRIPLET that will be used in binary module extensions. AS_CASE([$ac_sys_system], - [iOS], [SOABI_PLATFORM=`echo "$PLATFORM_TRIPLET" | cut -d '-' -f2`], + [iOS|tvOS|visionOS|watchOS], [SOABI_PLATFORM=`echo "$PLATFORM_TRIPLET" | cut -d '-' -f2`], [SOABI_PLATFORM=$PLATFORM_TRIPLET] ) +if test x$SOABI_PLATFORM != x; then + AC_DEFINE_UNQUOTED([SOABI_PLATFORM], ["${SOABI_PLATFORM}"], [Platform tag, used in binary module extension filenames.]) +fi + if test x$MULTIARCH != x; then MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\"" fi @@ -1232,20 +1429,22 @@ dnl AC_MSG_CHECKING([for PEP 11 support tier]) AS_CASE([$host/$ac_cv_cc_name], [x86_64-*-linux-gnu/gcc], [PY_SUPPORT_TIER=1], dnl Linux on AMD64, any vendor, glibc, gcc - [x86_64-apple-darwin*/clang], [PY_SUPPORT_TIER=1], dnl macOS on Intel, any version [aarch64-apple-darwin*/clang], [PY_SUPPORT_TIER=1], dnl macOS on M1, any version + [aarch64-*-linux-gnu/gcc], [PY_SUPPORT_TIER=1], dnl Linux ARM64, glibc, gcc [i686-pc-windows-msvc/msvc], [PY_SUPPORT_TIER=1], dnl 32bit Windows on Intel, MSVC [x86_64-pc-windows-msvc/msvc], [PY_SUPPORT_TIER=1], dnl 64bit Windows on AMD64, MSVC - [aarch64-*-linux-gnu/gcc], [PY_SUPPORT_TIER=2], dnl Linux ARM64, glibc, gcc+clang - [aarch64-*-linux-gnu/clang], [PY_SUPPORT_TIER=2], - [powerpc64le-*-linux-gnu/gcc], [PY_SUPPORT_TIER=2], dnl Linux on PPC64 little endian, glibc, gcc + [aarch64-*-linux-gnu/clang], [PY_SUPPORT_TIER=2], dnl Linux ARM64, glibc, clang + [aarch64-pc-windows-msvc/msvc], [PY_SUPPORT_TIER=2], dnl Windows ARM64, MSVC [wasm32-unknown-wasip1/clang], [PY_SUPPORT_TIER=2], dnl WebAssembly System Interface preview1, clang + [x86_64-apple-darwin*/clang], [PY_SUPPORT_TIER=2], dnl macOS on Intel, any version [x86_64-*-linux-gnu/clang], [PY_SUPPORT_TIER=2], dnl Linux on AMD64, any vendor, glibc, clang - [aarch64-pc-windows-msvc/msvc], [PY_SUPPORT_TIER=3], dnl Windows ARM64, MSVC [armv7l-*-linux-gnueabihf/gcc], [PY_SUPPORT_TIER=3], dnl ARMv7 LE with hardware floats, any vendor, glibc, gcc + [powerpc64le-*-linux-gnu/gcc], [PY_SUPPORT_TIER=3], dnl Linux on PPC64 little endian, glibc, gcc [powerpc64le-*-linux-gnu/clang], [PY_SUPPORT_TIER=3], dnl Linux on PPC64 little endian, glibc, clang + [riscv64-*-linux-gnu/gcc], [PY_SUPPORT_TIER=3], dnl Linux on RISC-V 64bit, glibc, gcc+clang + [riscv64-*-linux-gnu/clang], [PY_SUPPORT_TIER=3], [s390x-*-linux-gnu/gcc], [PY_SUPPORT_TIER=3], dnl Linux on 64bit s390x (big endian), glibc, gcc [x86_64-*-freebsd*/clang], [PY_SUPPORT_TIER=3], dnl FreeBSD on AMD64 [aarch64-apple-ios*-simulator/clang], [PY_SUPPORT_TIER=3], dnl iOS Simulator on arm64 @@ -1356,6 +1555,20 @@ AC_ARG_ENABLE([wasm-pthreads], ]) AC_MSG_RESULT([$enable_wasm_pthreads]) +AC_MSG_CHECKING([for --enable-emscripten-syscalls]) +AC_ARG_ENABLE([emscripten-syscalls], + [AS_HELP_STRING([--disable-emscripten-syscalls], + [Disable the Emscripten syscall overrides in Python/emscripten_syscalls.c (default is enabled for Emscripten)])], +[ + AS_CASE([$ac_sys_system], + [Emscripten], [], + [AC_MSG_ERROR([--enable-emscripten-syscalls only applies to Emscripten])] + ) +], [ + enable_emscripten_syscalls=yes +]) +AC_MSG_RESULT([$enable_emscripten_syscalls]) + AC_MSG_CHECKING([for --with-suffix]) AC_ARG_WITH([suffix], [AS_HELP_STRING([--with-suffix=SUFFIX], [set executable suffix to SUFFIX (default is empty, yes is mapped to '.exe')])], @@ -1571,7 +1784,7 @@ then case $ac_sys_system in Darwin) LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)';; - iOS) + iOS|tvOS|visionOS|watchOS) LDLIBRARY='$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)';; *) AC_MSG_ERROR([Unknown platform for framework build]);; @@ -1636,7 +1849,10 @@ if test $enable_shared = "yes"; then BLDLIBRARY='-L. -lpython$(LDVERSION)' RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}} ;; - iOS) + iOS|tvOS|visionOS|watchOS) + if test -z "$PYTHONFRAMEWORK"; then + AC_MSG_ERROR([iOS shared builds must use --enable-framework; an iOS app can only load a signed framework, never a bare dylib]) + fi LDLIBRARY='libpython$(LDVERSION).dylib' ;; AIX*) @@ -2015,6 +2231,32 @@ if test "$Py_LTO" = 'true' ; then else LTOFLAGS="-flto=${Py_LTO_POLICY}" fi + LTOCFLAGS="$LTOFLAGS" + # GNU ld needs LLVMgold.so for Clang LTO. If the configured linker + # cannot link LTO objects, try lld, which does not need that plugin. + WITH_SAVE_ENV([ + LDFLAGS="$LDFLAGS $LDFLAGS_NODIST $LTOFLAGS" + AC_MSG_CHECKING([whether Clang LTO works with the configured linker]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [clang_lto_link=yes], [clang_lto_link=no]) + AC_MSG_RESULT([$clang_lto_link]) + ]) + if test "$clang_lto_link" = no; then + WITH_SAVE_ENV([ + LDFLAGS="$LDFLAGS -fuse-ld=lld" + AC_MSG_CHECKING([whether Clang LTO works with lld]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [clang_lto_link=yes], [clang_lto_link=no]) + AC_MSG_RESULT([$clang_lto_link]) + ]) + if test "$clang_lto_link" = no; then + AC_MSG_ERROR([m4_normalize([ + Clang LTO requires a working LTO-aware linker. + Install lld or the LLVMgold.so plugin, select a linker + with LDFLAGS, or disable LTO with --without-lto. + ])]) + fi + LTOFLAGS="$LTOFLAGS -fuse-ld=lld" + LDFLAGS_NOLTO="$LDFLAGS_NOLTO -fuse-ld=lld" + fi ;; esac ;; @@ -2059,6 +2301,7 @@ fi AC_SUBST([PGO_PROF_GEN_FLAG]) AC_SUBST([PGO_PROF_USE_FLAG]) AC_SUBST([LLVM_PROF_MERGER]) +AC_SUBST([LLVM_PROF_SHOW]) AC_SUBST([LLVM_PROF_FILE]) AC_SUBST([LLVM_PROF_ERR]) AC_SUBST([LLVM_PROFDATA]) @@ -2083,9 +2326,10 @@ then fi fi LLVM_PROF_ERR=no +LLVM_PROF_SHOW=true case "$ac_cv_cc_name" in - clang) + clang|icx) # Any changes made here should be reflected in the GCC+Darwin case below PGO_PROF_GEN_FLAG="-fprofile-instr-generate" PGO_PROF_USE_FLAG="-fprofile-instr-use=\"\$(shell pwd)/code.profclangd\"" @@ -2095,6 +2339,10 @@ case "$ac_cv_cc_name" in \"\$(shell pwd)\"/*.profclangr ") LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"\$(shell pwd)/code-%p.profclangr\"" + LLVM_PROF_SHOW=m4_normalize(" + ${LLVM_PROFDATA} show --detailed-summary --topn=500 + \"\$(shell pwd)/code.profclangd\" + ") if test $LLVM_PROF_FOUND = not-found then LLVM_PROF_ERR=yes @@ -2172,6 +2420,24 @@ if test "$Py_BOLT" = 'true' ; then CFLAGS_NODIST="$CFLAGS_NODIST -fno-reorder-blocks-and-partition" ]) + # BOLT rejects binaries with Cortex-A53 erratum 843419 workaround veneers, + # see https://github.com/llvm/llvm-project/pull/187955 + # Check explicit flags here to provide a friendlier error. Recent BOLT + # versions reject workaround veneers by default, including those + # from compiler defaults, so we do not perform exhaustive detection. + AS_CASE([$host_cpu], [aarch64*], [ + AS_CASE(["$CC $CFLAGS $CPPFLAGS $CFLAGS_NODIST $LDFLAGS $LDFLAGS_NODIST $LIBS"], + [*-mfix-cortex-a53-843419*|*--fix-cortex-a53-843419*], [ + AC_MSG_ERROR([--enable-bolt is incompatible with the Cortex-A53 erratum 843419 workaround. +BOLT does not preserve protection against this erratum. Its output must not run +on affected Cortex-A53 processors, including during the build. +If the generated binaries will never run on affected processors, disable the +workaround explicitly. With GCC, configure with +LDFLAGS_NODIST="-mno-fix-cortex-a53-843419". Also remove any explicit +-mfix-cortex-a53-843419 or -Wl,--fix-cortex-a53-843419 flags.]) + ]) + ]) + # These flags are required for bolt to work: LDFLAGS_NODIST="$LDFLAGS_NODIST -Wl,--emit-relocs" @@ -2248,6 +2514,12 @@ AC_ARG_VAR( AC_MSG_CHECKING([BOLT_APPLY_FLAGS]) if test -z "${BOLT_APPLY_FLAGS}" then + dnl The frame optimizer is only implemented for x86. BOLT 22 and newer + dnl refuse to run it on other architectures. + AS_CASE([$host_cpu], + [x86_64], [bolt_frame_opt_flags="-frame-opt=hot"], + [bolt_frame_opt_flags=""] + ) AS_VAR_SET( [BOLT_APPLY_FLAGS], [m4_normalize(" @@ -2265,7 +2537,7 @@ then -indirect-call-promotion=all -dyno-stats -use-gnu-stack - -frame-opt=hot + ${bolt_frame_opt_flags} ")] ) fi @@ -2377,11 +2649,6 @@ then OPT="-O3 -Wall" ;; esac - - case $ac_sys_system in - SCO_SV*) OPT="$OPT -m486 -DSCO5" - ;; - esac ;; *) @@ -2400,18 +2667,13 @@ AS_CASE([$ac_sys_system], dnl Start with 20 MB and allow to grow AS_VAR_APPEND([LINKFORSHARED], [" -sALLOW_MEMORY_GROWTH -sINITIAL_MEMORY=20971520"]) - dnl map int64_t and uint64_t to JS bigint - AS_VAR_APPEND([LDFLAGS_NODIST], [" -sWASM_BIGINT"]) - dnl Include file system support AS_VAR_APPEND([LINKFORSHARED], [" -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js"]) AS_VAR_APPEND([LINKFORSHARED], [" -sEXPORTED_RUNTIME_METHODS=FS,callMain,ENV,HEAPU32,TTY,ERRNO_CODES"]) - AS_VAR_APPEND([LINKFORSHARED], [" -sEXPORTED_FUNCTIONS=_main,_Py_Version,__PyRuntime,_PyGILState_GetThisThreadState,__PyEM_EMSCRIPTEN_TRAMPOLINE_OFFSET"]) + AS_VAR_APPEND([LINKFORSHARED], [" -sEXPORTED_FUNCTIONS=_main,_Py_Version,_PyGILState_GetThisThreadState,NODEFS"]) AS_VAR_APPEND([LINKFORSHARED], [" -sSTACK_SIZE=5MB"]) dnl Avoid bugs in JS fallback string decoding path AS_VAR_APPEND([LINKFORSHARED], [" -sTEXTDECODER=2"]) - dnl workaround for emscripten#27241, can remove when we update to emscripten 6.0.3 - AS_VAR_APPEND([LINKFORSHARED], [" -sGROWABLE_ARRAYBUFFERS=0"]) AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [ AS_VAR_APPEND([LINKFORSHARED], [" -sMAIN_MODULE"]) @@ -2419,7 +2681,7 @@ AS_CASE([$ac_sys_system], AS_VAR_IF([enable_wasm_pthreads], [yes], [ AS_VAR_APPEND([CFLAGS_NODIST], [" -pthread"]) - AS_VAR_APPEND([LDFLAGS_NODIST], [" -sUSE_PTHREADS"]) + AS_VAR_APPEND([LDFLAGS_NODIST], [" -pthread"]) AS_VAR_APPEND([LINKFORSHARED], [" -sPROXY_TO_PTHREAD"]) ]) dnl not completely sure whether or not we want -sEXIT_RUNTIME, keeping it for now. @@ -2754,10 +3016,6 @@ AS_VAR_IF([ac_cv_gcc_compat], [yes], [ esac case $ac_sys_system in - SCO_SV*) - BASECFLAGS="$BASECFLAGS -m486 -DSCO5" - ;; - Darwin*) # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd # used to be here, but non-Apple gcc doesn't accept them. @@ -2911,15 +3169,6 @@ AS_VAR_IF([ac_cv_gcc_compat], [yes], [ # end of Darwin* tests ;; esac -], [ - case $ac_sys_system in - OpenUNIX*|UnixWare*) - BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca " - ;; - SCO_SV*) - BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5" - ;; - esac ]) # Check for --enable-experimental-jit: @@ -2965,6 +3214,10 @@ case "$ac_cv_cc_name" in mpicc) CFLAGS_NODIST="$CFLAGS_NODIST" ;; +icx) + # ICX needs fp-model=precise (the default in clang) or floats behave badly + CFLAGS_NODIST="$CFLAGS_NODIST -ffp-model=precise" + ;; icc) # ICC needs -fp-model strict or floats behave badly CFLAGS_NODIST="$CFLAGS_NODIST -fp-model strict" @@ -3155,12 +3408,13 @@ AC_DEFINE([STDC_HEADERS], [1], AC_CHECK_HEADERS([ \ alloca.h asm/types.h bluetooth.h conio.h direct.h dlfcn.h endian.h errno.h fcntl.h grp.h \ io.h langinfo.h libintl.h libutil.h linux/auxvec.h sys/auxv.h linux/fs.h linux/limits.h linux/memfd.h \ - linux/netfilter_ipv4.h linux/random.h linux/soundcard.h linux/sched.h \ - linux/tipc.h linux/wait.h netdb.h net/ethernet.h netinet/in.h netpacket/packet.h poll.h process.h pthread.h pty.h \ - sched.h setjmp.h shadow.h signal.h spawn.h sys/audioio.h sys/bsdtty.h sys/devpoll.h \ + linux/netfilter_ipv4.h linux/random.h linux/sched.h \ + linux/tipc.h linux/wait.h netdb.h net/ethernet.h netinet/in.h netpacket/packet.h \ + poll.h process.h pthread.h pthread_np.h pty.h \ + sched.h setjmp.h signal.h spawn.h sys/bsdtty.h sys/devpoll.h \ sys/endian.h sys/epoll.h sys/event.h sys/eventfd.h sys/file.h sys/ioctl.h sys/kern_control.h \ sys/loadavg.h sys/lock.h sys/memfd.h sys/mkdev.h sys/mman.h sys/modem.h sys/param.h sys/pidfd.h sys/poll.h \ - sys/random.h sys/resource.h sys/select.h sys/sendfile.h sys/socket.h sys/soundcard.h sys/stat.h \ + sys/random.h sys/resource.h sys/select.h sys/sendfile.h sys/socket.h sys/stat.h \ sys/statvfs.h sys/sys_domain.h sys/syscall.h sys/sysctl.h \ sys/sysmacros.h sys/termio.h sys/time.h sys/times.h sys/timerfd.h \ sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h sys/xattr.h sysexits.h syslog.h \ @@ -3297,13 +3551,6 @@ AC_DEFINE([_FILE_OFFSET_BITS], [64], [This must be set to 64 on some systems to enable large file support.]) fi -# Add some code to confdefs.h so that the test for off_t works on SCO -cat >> confdefs.h <<\EOF -#if defined(SCO_DS) -#undef _OFF_T -#endif -EOF - # Type availability checks AC_TYPE_MODE_T AC_TYPE_OFF_T @@ -3483,14 +3730,43 @@ AC_MSG_CHECKING([for --with-address-sanitizer]) AC_ARG_WITH([address_sanitizer], AS_HELP_STRING([--with-address-sanitizer], [enable AddressSanitizer memory error detector, 'asan' (default is no)]), -[ -AC_MSG_RESULT([$withval]) +[], [with_address_sanitizer=no]) +AC_MSG_RESULT([$with_address_sanitizer]) +AS_VAR_IF([with_address_sanitizer], [no], [], [ BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS" LDFLAGS="-fsanitize=address $LDFLAGS" -# ASan works by controlling memory allocation, our own malloc interferes. -with_pymalloc="no" -], -[AC_MSG_RESULT([no])]) +AC_MSG_CHECKING([whether a program links with -fsanitize=address]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([cannot link with -fsanitize=address: the compiler does not support AddressSanitizer or its runtime library is not installed; see config.log])]) +]) + +AC_MSG_CHECKING([for --with-hwaddress-sanitizer]) +AC_ARG_WITH( + [hwaddress_sanitizer], + [AS_HELP_STRING( + [--with-hwaddress-sanitizer], + [enable HWAddressSanitizer memory error detector, 'hwasan' (default is no)] + )], +[], [with_hwaddress_sanitizer=no]) +AC_MSG_RESULT([$with_hwaddress_sanitizer]) +AS_VAR_IF([with_hwaddress_sanitizer], [no], [], [ +hwasan_flags="-fsanitize=hwaddress" +# x86-64 lacks address tagging, so HWASan needs the page aliasing mode there. +# See gh-156049 and +# https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html#supported-architectures +AS_CASE([$host_cpu], + [x86_64|amd64], [hwasan_flags="$hwasan_flags -fsanitize-hwaddress-experimental-aliasing"] +) +BASECFLAGS="$hwasan_flags -fno-omit-frame-pointer $BASECFLAGS" +LDFLAGS="$hwasan_flags $LDFLAGS" +AC_MSG_CHECKING([whether a program links with $hwasan_flags]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([cannot link with $hwasan_flags: the compiler does not support HWAddressSanitizer or its runtime library is not installed; see config.log])]) +]) AC_MSG_CHECKING([for --with-memory-sanitizer]) AC_ARG_WITH( @@ -3499,16 +3775,17 @@ AC_ARG_WITH( [--with-memory-sanitizer], [enable MemorySanitizer allocation error detector, 'msan' (default is no)] )], -[ -AC_MSG_RESULT([$withval]) -AX_CHECK_COMPILE_FLAG([-fsanitize=memory],[ +[], [with_memory_sanitizer=no]) +AC_MSG_RESULT([$with_memory_sanitizer]) +AS_VAR_IF([with_memory_sanitizer], [no], [], [ BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS" LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS" -],[AC_MSG_ERROR([The selected compiler doesn't support memory sanitizer])]) -# MSan works by controlling memory allocation, our own malloc interferes. -with_pymalloc="no" -], -[AC_MSG_RESULT([no])]) +AC_MSG_CHECKING([whether a program links with -fsanitize=memory]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([cannot link with -fsanitize=memory: the compiler does not support MemorySanitizer or its runtime library is not installed; see config.log])]) +]) AC_MSG_CHECKING([for --with-undefined-behavior-sanitizer]) AC_ARG_WITH( @@ -3517,15 +3794,19 @@ AC_ARG_WITH( [--with-undefined-behavior-sanitizer], [enable UndefinedBehaviorSanitizer undefined behaviour detector, 'ubsan' (default is no)] )], -[ -AC_MSG_RESULT([$withval]) +[], [with_undefined_behavior_sanitizer=no]) +AC_MSG_RESULT([$with_undefined_behavior_sanitizer]) +AS_VAR_IF([with_undefined_behavior_sanitizer], [no], [ +with_ubsan="no" +], [ BASECFLAGS="-fsanitize=undefined $BASECFLAGS" LDFLAGS="-fsanitize=undefined $LDFLAGS" with_ubsan="yes" -], -[ -AC_MSG_RESULT([no]) -with_ubsan="no" +AC_MSG_CHECKING([whether a program links with -fsanitize=undefined]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([cannot link with -fsanitize=undefined: the compiler does not support UndefinedBehaviorSanitizer or its runtime library is not installed; see config.log])]) ]) AC_MSG_CHECKING([for --with-thread-sanitizer]) @@ -3535,15 +3816,19 @@ AC_ARG_WITH( [--with-thread-sanitizer], [enable ThreadSanitizer data race detector, 'tsan' (default is no)] )], -[ -AC_MSG_RESULT([$withval]) +[], [with_thread_sanitizer=no]) +AC_MSG_RESULT([$with_thread_sanitizer]) +AS_VAR_IF([with_thread_sanitizer], [no], [ +with_tsan="no" +], [ BASECFLAGS="-fsanitize=thread $BASECFLAGS" LDFLAGS="-fsanitize=thread $LDFLAGS" with_tsan="yes" -], -[ -AC_MSG_RESULT([no]) -with_tsan="no" +AC_MSG_CHECKING([whether a program links with -fsanitize=thread]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([cannot link with -fsanitize=thread: the compiler does not support ThreadSanitizer or its runtime library is not installed; see config.log])]) ]) # Set info about shared libraries. @@ -3646,7 +3931,7 @@ then BLDSHARED="$LDSHARED" fi ;; - iOS/*) + iOS/*|tvOS/*|visionOS/*|watchOS/*) LDSHARED='$(CC) -dynamiclib -F . -framework $(PYTHONFRAMEWORK)' LDCXXSHARED='$(CXX) -dynamiclib -F . -framework $(PYTHONFRAMEWORK)' BLDSHARED="$LDSHARED" @@ -3684,17 +3969,6 @@ then NetBSD*|DragonFly*) LDSHARED='$(CC) -shared' LDCXXSHARED='$(CXX) -shared';; - OpenUNIX*|UnixWare*) - if test "$ac_cv_gcc_compat" = "yes" ; then - LDSHARED='$(CC) -shared' - LDCXXSHARED='$(CXX) -shared' - else - LDSHARED='$(CC) -G' - LDCXXSHARED='$(CXX) -G' - fi;; - SCO_SV*) - LDSHARED='$(CC) -Wl,-G,-Bexport' - LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';; WASI*) AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [ dnl not implemented yet @@ -3742,16 +4016,6 @@ then ]);; FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";; Haiku*) CCSHARED="-fPIC";; - OpenUNIX*|UnixWare*) - if test "$ac_cv_gcc_compat" = "yes" - then CCSHARED="-fPIC" - else CCSHARED="-KPIC" - fi;; - SCO_SV*) - if test "$ac_cv_gcc_compat" = "yes" - then CCSHARED="-fPIC" - else CCSHARED="-Kpic -belf" - fi;; VxWorks*) CCSHARED="-fpic -D__SO_PICABILINUX__ -ftls-model=global-dynamic" esac @@ -3770,7 +4034,7 @@ then Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";; Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; # -u libsys_s pulls in all symbols in libsys - Darwin/*|iOS/*) + Darwin/*|iOS/*|tvOS/*|visionOS/*|watchOS/*) LINKFORSHARED="$extra_undefs -framework CoreFoundation" # Issue #18075: the default maximum stack size (8MBytes) is too @@ -3794,13 +4058,14 @@ then LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' fi LINKFORSHARED="$LINKFORSHARED" - elif test $ac_sys_system = "iOS"; then - LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)' + elif test "$ac_sys_system" = "iOS" -o "$ac_sys_system" = "tvOS" -o "$ac_sys_system" = "visionOS" -o "$ac_sys_system" = "watchOS"; then + LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED" + + if test "$enable_framework"; then + LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)' + fi fi ;; - OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";; - SCO_SV*) LINKFORSHARED="-Wl,-Bexport";; - ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";; FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) if [[ "`$CC -dM -E - +int main(void) +{ + _Float16 val = 1.0f16; + int test = isinf(val) || isnan(val); /* basic support from libm */ + double d = 3.14; + val = d; + return test; +} +]])], [ac_cv_float16_supported=yes], +[ac_cv_float16_supported=no], +[ac_cv_float16_supported=no])])) +AS_VAR_IF([ac_cv_float16_supported], [yes], + [AC_DEFINE([_Py_HAVE_FLOAT16], [1], + [Defined if _Float16 C type is supported])]) + dnl Check for libmpdec >= 2.5.0 PKG_CHECK_MODULES([LIBMPDEC], [libmpdec >= 2.5.0], [have_mpdec=yes], [ WITH_SAVE_ENV([ @@ -4546,21 +4838,22 @@ AC_ARG_ENABLE([loadable-sqlite-extensions], support loadable extensions in the sqlite3 module, see Doc/library/sqlite3.rst (default is no) ] - ), [ - AS_VAR_IF([have_sqlite3_load_extension], [no], [ - AC_MSG_RESULT([n/a]) - AC_MSG_WARN([Your version of SQLite does not support loadable extensions]) - ], [ - AC_MSG_RESULT([yes]) - AC_DEFINE( - [PY_SQLITE_ENABLE_LOAD_EXTENSION], [1], - [Define to 1 to build the sqlite module with loadable extensions support.] - ) - ]) - ], [ - AC_MSG_RESULT([no]) - ] + ), [], [enable_loadable_sqlite_extensions=no] ) +AS_VAR_IF([enable_loadable_sqlite_extensions], [yes], [ + AS_VAR_IF([have_sqlite3_load_extension], [no], [ + AC_MSG_RESULT([n/a]) + AC_MSG_WARN([Your version of SQLite does not support loadable extensions]) + ], [ + AC_MSG_RESULT([yes]) + AC_DEFINE( + [PY_SQLITE_ENABLE_LOAD_EXTENSION], [1], + [Define to 1 to build the sqlite module with loadable extensions support.] + ) + ]) +], [ + AC_MSG_RESULT([no]) +]) dnl dnl Detect Tcl/Tk. Use pkg-config if available. @@ -4671,6 +4964,15 @@ AS_CASE([$ac_cv_search_dbm_open], ) AC_MSG_RESULT([$have_ndbm ($dbm_ndbm)]) +dnl gdbm's ndbm.h includes gdbm.h; libgdbm is then needed for the version info. +AC_CACHE_CHECK([whether ndbm.h is provided by gdbm], [ac_cv_ndbm_h_is_gdbm], + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ + #include + #ifndef _GDBM_H_ + #error "not gdbm" + #endif + ]])], [ac_cv_ndbm_h_is_gdbm=yes], [ac_cv_ndbm_h_is_gdbm=no])]) + dnl "gdbm-ndbm.h" and "gdbm/ndbm.h" are both normalized to "gdbm_ndbm_h" AC_CACHE_CHECK([for gdbm/ndbm.h], [ac_cv_header_gdbm_slash_ndbm_h], [AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include ])], @@ -4753,6 +5055,7 @@ for db in $with_dbmliborder; do if test "$have_ndbm" = yes; then DBM_CFLAGS="-DUSE_NDBM" DBM_LIBS="$dbm_ndbm" + AS_VAR_IF([ac_cv_ndbm_h_is_gdbm], [yes], [DBM_LIBS="$DBM_LIBS $GDBM_LIBS"]) have_dbm=yes break fi @@ -4760,7 +5063,7 @@ for db in $with_dbmliborder; do gdbm) if test "$have_gdbm_compat" = yes; then DBM_CFLAGS="-DUSE_GDBM_COMPAT" - DBM_LIBS="-lgdbm_compat" + DBM_LIBS="-lgdbm_compat $GDBM_LIBS" have_dbm=yes break fi @@ -5365,15 +5668,27 @@ fi dnl Platform-specific C and header files. PLATFORM_HEADERS= PLATFORM_OBJS= +PLATFORM_MAIN_OBJS= AS_CASE([$ac_sys_system], [Emscripten], [ - AS_VAR_APPEND([PLATFORM_OBJS], [' Python/emscripten_signal.o Python/emscripten_trampoline.o Python/emscripten_trampoline_wasm.o Python/emscripten_syscalls.o']) - AS_VAR_APPEND([PLATFORM_HEADERS], [' $(srcdir)/Include/internal/pycore_emscripten_signal.h $(srcdir)/Include/internal/pycore_emscripten_trampoline.h']) + AS_VAR_APPEND([PLATFORM_OBJS], [' Python/emscripten_signal.o Python/wasm_trampoline.o']) + AS_VAR_APPEND([CFLAGS_NODIST], [" -mgc"]) + + AS_VAR_IF([enable_emscripten_syscalls], [yes], [ + AS_VAR_APPEND([PLATFORM_MAIN_OBJS], [' Programs/emscripten_beforemain.o']) + AS_VAR_APPEND([PLATFORM_OBJS], [' Python/emscripten_syscalls.o']) + ]) + AS_VAR_APPEND([PLATFORM_HEADERS], [' $(srcdir)/Include/internal/pycore_emscripten_signal.h']) + ], + [WASI], [ + AS_VAR_APPEND([PLATFORM_OBJS], [' Python/wasm_trampoline.o']) + AS_VAR_APPEND([CFLAGS_NODIST], [" -mgc"]) ], ) AC_SUBST([PLATFORM_HEADERS]) AC_SUBST([PLATFORM_OBJS]) +AC_SUBST([PLATFORM_MAIN_OBJS]) # -I${DLINCLDIR} is added to the compile rule for importdl.o AC_SUBST([DLINCLDIR]) @@ -5383,6 +5698,9 @@ DLINCLDIR=. # platforms have dlopen(), but don't want to use it. AC_CHECK_FUNCS([dlopen]) +# Used by ctypes.util.dllist(). +AC_CHECK_FUNCS([dl_iterate_phdr]) + # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic # loading of modules. AC_SUBST([DYNLOADFILE]) @@ -5425,14 +5743,9 @@ else fi if test "$ac_sys_system" = "Linux-android"; then - # When these functions are used in an unprivileged process, they crash rather - # than returning an error. - blocked_funcs="chroot initgroups setegid seteuid setgid sethostname - setregid setresgid setresuid setreuid setuid" - # These functions are unimplemented and always return an error # (https://android.googlesource.com/platform/system/sepolicy/+/refs/heads/android13-release/public/domain.te#1044) - blocked_funcs="$blocked_funcs sem_open sem_unlink" + blocked_funcs="sem_open sem_unlink" # Before API level 23, when fchmodat is called with the unimplemented flag # AT_SYMLINK_NOFOLLOW, instead of returning ENOTSUP as it should, it actually @@ -5452,18 +5765,19 @@ fi AC_CHECK_FUNCS([ \ accept4 alarm bind_textdomain_codeset chmod chown clearenv \ clock closefrom close_range confstr \ - copy_file_range ctermid dladdr dup execv explicit_bzero explicit_memset \ + copy_file_range ctermid dladdr dup explicit_bzero explicit_memset \ faccessat fchmod fchmodat fchown fchownat fdopendir fdwalk fexecve \ - fork fork1 fpathconf fstatat ftime ftruncate futimens futimes futimesat \ + fpathconf fstatat ftruncate futimens futimes futimesat \ gai_strerror getegid geteuid getgid getgrent getgrgid getgrgid_r \ getgrnam_r getgrouplist gethostname getitimer getloadavg getlogin getlogin_r \ getpeername getpgid getpid getppid getpriority _getpty \ - getpwent getpwnam_r getpwuid getpwuid_r getresgid getresuid getrusage getsid getspent \ - getspnam getuid getwd grantpt if_nameindex initgroups kill killpg lchown linkat \ + getpwent getpwnam_r getpwuid getpwuid_r getresgid getresuid getrusage getsid \ + getuid grantpt if_nameindex \ + initgroups kill killpg lchown linkat \ lockf lstat lutimes madvise mbrtowc memrchr mkdirat mkfifo mkfifoat \ - mknod mknodat mktime mmap mremap nice openat opendir pathconf pause pipe \ - plock poll ppoll posix_fadvise posix_fallocate posix_openpt posix_spawn posix_spawnp \ - posix_spawn_file_actions_addclosefrom_np \ + mknod mknodat mktime mmap mremap nice openat opendir pathconf pause \ + pipe \ + plock poll ppoll posix_fadvise posix_fallocate posix_openpt \ pread preadv preadv2 process_vm_readv \ pthread_cond_timedwait_relative_np pthread_condattr_setclock pthread_init \ pthread_kill pthread_get_name_np pthread_getname_np pthread_set_name_np \ @@ -5473,14 +5787,26 @@ AC_CHECK_FUNCS([ \ sched_setparam sched_setscheduler sem_clockwait sem_getvalue sem_open \ sem_timedwait sem_unlink sendfile setegid seteuid setgid sethostname \ setitimer setlocale setpgid setpgrp setpriority setregid setresgid \ - setresuid setreuid setsid setuid setvbuf shutdown sigaction sigaltstack \ - sigfillset siginterrupt sigpending sigrelse sigtimedwait sigwait \ + setresuid setreuid setsid setuid setvbuf shutdown sigaction \ + sigfillset siginterrupt sigpending sigtimedwait sigwait \ sigwaitinfo snprintf splice strftime strlcpy strsignal symlinkat sync \ - sysconf sysctlbyname tcgetpgrp tcsetpgrp tempnam timegm times tmpfile \ - tmpnam tmpnam_r truncate ttyname_r umask uname unlinkat unlockpt utimensat utimes vfork \ + sysconf sysctlbyname tcgetpgrp tcsetpgrp timegm times tmpfile \ + truncate ttyname_r umask uname unlinkat unlockpt utimensat utimes vfork \ wait wait3 wait4 waitid waitpid wcscoll wcsftime wcsxfrm wmemcmp writev \ ]) +PY_CHECK_FUNC_PRIVATE([freadlink], [@%:@include ]) +PY_CHECK_FUNC_PRIVATE([strerror_r], [@%:@include ]) +# FreeBSD pthread_attr_get_np() +PY_CHECK_FUNC_PRIVATE([pthread_attr_get_np], [@%:@include ]) +PY_CHECK_FUNC_PRIVATE([getdents64], [@%:@include ]) +PY_CHECK_FUNC_PRIVATE([gettid], [@%:@include ]) +PY_CHECK_FUNC_PRIVATE([if_indextoname], [@%:@include ]) +PY_CHECK_FUNC_PRIVATE([if_nametoindex], [@%:@include ]) +PY_CHECK_FUNC_PRIVATE([pidfd_open], [@%:@include ]) +PY_CHECK_FUNC_PRIVATE([pidfd_getfd], [@%:@include ]) +PY_CHECK_FUNC_PRIVATE([pidfd_send_signal], [@%:@include ]) + # os.statx uses Linux's statx function. AIX also has a function named statx, # but it's unrelated. Check only on Linux (including Android). AS_CASE([$ac_sys_system], @@ -5494,12 +5820,35 @@ if test "$MACHDEP" != linux; then AC_CHECK_FUNCS([lchmod]) fi -# iOS defines some system methods that can be linked (so they are +# iOS/tvOS/visionOS/watchOS define some system methods that can be linked (so they are # found by configure), but either raise a compilation error (because the # header definition prevents usage - autoconf doesn't use the headers), or # raise an error if used at runtime. Force these symbols off. -if test "$ac_sys_system" != "iOS" ; then - AC_CHECK_FUNCS([dup3 getentropy getgroups pipe2 system]) +# In particular, dup3 and pipe2 are available as of iOS/tvOS/watchOS/visionOS 27 but were +# incorrectly detected in older simulator versions. +case "$ac_sys_system" in + iOS|tvOS|watchOS|visionOS) + AC_MSG_CHECKING([if iOS SDK is older than 27]) + ios_sdk_version=$(xcrun --sdk iphoneos --show-sdk-version 2>/dev/null | cut -d. -f1) + if test -n "$ios_sdk_version" && test "$ios_sdk_version" -ge 27; then + AC_MSG_RESULT([no]) + AC_CHECK_FUNCS([dup3 pipe2]) + else + AC_MSG_RESULT([yes]) + fi + ;; + *) + # not iOS/tvOS/watchOS/visionOS + AC_CHECK_FUNCS([dup3 getentropy getgroups pipe2 system]) + ;; +esac + +# tvOS/watchOS have some additional methods that can be found, but not used. +if test "$ac_sys_system" != "tvOS" -a "$ac_sys_system" != "watchOS" ; then + AC_CHECK_FUNCS([ \ + execv fork fork1 posix_spawn posix_spawnp posix_spawn_file_actions_addclosefrom_np \ + sigaltstack \ + ]) fi AC_CHECK_DECL([dirfd], @@ -5663,10 +6012,34 @@ fi dnl Check for compression libraries AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy]) +AC_MSG_CHECKING([for --with-zlib]) +AC_ARG_WITH( + [zlib], + [AS_HELP_STRING([--with(out)-zlib@<:@=zlib|zlib-ng|zlib-rs|no@:>@], + [select the zlib implementation to link against, or disable + zlib support (default: auto)])], + [AS_CASE([$with_zlib], + [yes|auto], [with_zlib=auto], + [zlib|zlib-ng|zlib-rs|no], [], + [AC_MSG_ERROR([proper usage is --with(out)-zlib@<:@=zlib|zlib-ng|zlib-rs|no@:>@])])], + [with_zlib=auto]) +AC_MSG_RESULT([$with_zlib]) + dnl detect zlib from Emscripten emport -PY_CHECK_EMSCRIPTEN_PORT([ZLIB], [-sUSE_ZLIB]) +AS_CASE([$with_zlib], [auto|zlib], [PY_CHECK_EMSCRIPTEN_PORT([ZLIB], [-sUSE_ZLIB])]) -PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.2.1], [ +AS_VAR_IF([with_zlib], [zlib-rs], [ + AS_VAR_SET([zlib_name], ["libz_rs"]) + AS_VAR_SET([zlib_version], ["0.6.0"]) + AS_VAR_SET([zlib_libname], ["z_rs"]) +], [ + AS_VAR_SET([zlib_name], ["zlib"]) + AS_VAR_SET([zlib_version], ["1.2.2.1"]) + AS_VAR_SET([zlib_libname], ["z"]) +]) + +AS_VAR_IF([with_zlib], [no], [have_zlib=no], [ +PKG_CHECK_MODULES([ZLIB], [$zlib_name >= $zlib_version], [ have_zlib=yes dnl zlib 1.2.0 (2003) added inflateCopy AC_DEFINE([HAVE_ZLIB_COPY], [1]) @@ -5675,15 +6048,30 @@ PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.2.1], [ CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" LIBS="$LIBS $ZLIB_LIBS" AC_CHECK_HEADERS([zlib.h], [ - PY_CHECK_LIB([z], [gzread], [have_zlib=yes], [have_zlib=no]) + PY_CHECK_LIB([$zlib_libname], [gzread], [have_zlib=yes], [have_zlib=no]) ], [have_zlib=no]) AS_VAR_IF([have_zlib], [yes], [ ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - PY_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])]) + ZLIB_LIBS=${ZLIB_LIBS-"-l$zlib_libname"} + PY_CHECK_LIB([$zlib_libname], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])]) ]) ]) ]) +]) + +AS_VAR_IF([with_zlib], [zlib-ng], [AS_VAR_IF([have_zlib], [yes], [ + WITH_SAVE_ENV([ + CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" + AC_CHECK_DECL([ZLIBNG_VERSION], [], + [AC_MSG_ERROR([--with-zlib=zlib-ng: the detected zlib library is not zlib-ng])], + [@%:@include ]) + ]) +])]) + +AS_CASE([$with_zlib], + [auto|no], [], + [AS_VAR_IF([have_zlib], [no], + [AC_MSG_ERROR([--with-zlib=$with_zlib requested but $zlib_name was not found])])]) dnl binascii can use zlib for optimized crc32. AS_VAR_IF([have_zlib], [yes], [ @@ -5691,22 +6079,50 @@ AS_VAR_IF([have_zlib], [yes], [ BINASCII_LIBS="$ZLIB_LIBS" ]) +AC_MSG_CHECKING([for --with-bzip2]) +AC_ARG_WITH( + [bzip2], + [AS_HELP_STRING([--with(out)-bzip2@<:@=bzip2|bzip2-rs|no@:>@], + [select the bzip2 implementation to link against, or disable + bzip2 support (default: auto)])], + [AS_CASE([$with_bzip2], + [yes|auto], [with_bzip2=auto], + [bzip2|bzip2-rs|no], [], + [AC_MSG_ERROR([proper usage is --with(out)-bzip2@<:@=bzip2|bzip2-rs|no@:>@])])], + [with_bzip2=auto]) +AC_MSG_RESULT([$with_bzip2]) + dnl detect bzip2 from Emscripten emport -PY_CHECK_EMSCRIPTEN_PORT([BZIP2], [-sUSE_BZIP2]) +AS_CASE([$with_bzip2], [auto|bzip2], [PY_CHECK_EMSCRIPTEN_PORT([BZIP2], [-sUSE_BZIP2])]) -PKG_CHECK_MODULES([BZIP2], [bzip2], [have_bzip2=yes], [ +AS_VAR_IF([with_bzip2], [bzip2-rs], [ + AS_VAR_SET([bzip2_name], ["libbz2_rs"]) + AS_VAR_SET([bzip2_libname], ["bz2_rs"]) +], [ + AS_VAR_SET([bzip2_name], ["bzip2"]) + AS_VAR_SET([bzip2_libname], ["bz2"]) +]) + +AS_VAR_IF([with_bzip2], [no], [have_bzip2=no], [ +PKG_CHECK_MODULES([BZIP2], [$bzip2_name], [have_bzip2=yes], [ WITH_SAVE_ENV([ CPPFLAGS="$CPPFLAGS $BZIP2_CFLAGS" LIBS="$LIBS $BZIP2_LIBS" AC_CHECK_HEADERS([bzlib.h], [ - AC_CHECK_LIB([bz2], [BZ2_bzCompress], [have_bzip2=yes], [have_bzip2=no]) + AC_CHECK_LIB([$bzip2_libname], [BZ2_bzCompress], [have_bzip2=yes], [have_bzip2=no]) ], [have_bzip2=no]) AS_VAR_IF([have_bzip2], [yes], [ BZIP2_CFLAGS=${BZIP2_CFLAGS-""} - BZIP2_LIBS=${BZIP2_LIBS-"-lbz2"} + BZIP2_LIBS=${BZIP2_LIBS-"-l$bzip2_libname"} ]) ]) ]) +]) + +AS_CASE([$with_bzip2], + [auto|no], [], + [AS_VAR_IF([have_bzip2], [no], + [AC_MSG_ERROR([--with-bzip2=$with_bzip2 requested but $bzip2_name was not found])])]) PKG_CHECK_MODULES([LIBLZMA], [liblzma], [have_liblzma=yes], [ WITH_SAVE_ENV([ @@ -5816,33 +6232,37 @@ AC_CHECK_DECLS([UT_NAMESIZE], [Define if you have the 'HAVE_UT_NAMESIZE' constant.])], [], [@%:@include ]) -# musl libc redefines struct prctl_mm_map and conflicts with linux/prctl.h -AS_IF([test "$ac_cv_libc" != musl], [ -AC_CHECK_DECLS([PR_SET_VMA_ANON_NAME], - [AC_DEFINE([_Py_HAVE_PR_SET_VMA_ANON_NAME], [1], - [Define if you have the 'PR_SET_VMA_ANON_NAME' constant.])], - [], - [@%:@include - @%:@include ]) -]) -# check for openpty, login_tty, and forkpty - -AC_CHECK_FUNCS([openpty], [], - [AC_CHECK_LIB([util], [openpty], - [AC_DEFINE([HAVE_OPENPTY]) LIBS="$LIBS -lutil"], - [AC_CHECK_LIB([bsd], [openpty], - [AC_DEFINE([HAVE_OPENPTY]) LIBS="$LIBS -lbsd"])])]) -AC_SEARCH_LIBS([login_tty], [util], - [AC_DEFINE([HAVE_LOGIN_TTY], [1], [Define to 1 if you have the `login_tty' function.])] +# musl libc redefines struct prctl_mm_map and conflicts with linux/prctl.h. +# The conftest does not reliably catch this, so skip the check on musl. +AS_CASE([$host], + [*-musl*], [], + [AC_CHECK_DECLS([PR_SET_VMA_ANON_NAME], + [AC_DEFINE([_Py_HAVE_PR_SET_VMA_ANON_NAME], [1], + [Define if you have the 'PR_SET_VMA_ANON_NAME' constant.])], + [], + [@%:@include + @%:@include ])] ) -AC_CHECK_FUNCS([forkpty], [], - [AC_CHECK_LIB([util], [forkpty], - [AC_DEFINE([HAVE_FORKPTY]) LIBS="$LIBS -lutil"], - [AC_CHECK_LIB([bsd], [forkpty], - [AC_DEFINE([HAVE_FORKPTY]) LIBS="$LIBS -lbsd"])])]) +# check for openpty, login_tty, and forkpty +# tvOS/watchOS have functions for tty, but can't use them +if test "$ac_sys_system" != "tvOS" -a "$ac_sys_system" != "watchOS" ; then + AC_CHECK_FUNCS([openpty], [], + [AC_CHECK_LIB([util], [openpty], + [AC_DEFINE([HAVE_OPENPTY]) LIBS="$LIBS -lutil"], + [AC_CHECK_LIB([bsd], [openpty], + [AC_DEFINE([HAVE_OPENPTY]) LIBS="$LIBS -lbsd"])])]) + AC_SEARCH_LIBS([login_tty], [util], + [AC_DEFINE([HAVE_LOGIN_TTY], [1], [Define to 1 if you have the `login_tty' function.])] + ) + AC_CHECK_FUNCS([forkpty], [], + [AC_CHECK_LIB([util], [forkpty], + [AC_DEFINE([HAVE_FORKPTY]) LIBS="$LIBS -lutil"], + [AC_CHECK_LIB([bsd], [forkpty], + [AC_DEFINE([HAVE_FORKPTY]) LIBS="$LIBS -lbsd"])])]) +fi # check for long file support functions -AC_CHECK_FUNCS([fseek64 fseeko fstatvfs ftell64 ftello statvfs]) +AC_CHECK_FUNCS([fseeko fstatvfs ftello statvfs]) AC_REPLACE_FUNCS([dup2]) AC_CHECK_FUNCS([getpgrp], @@ -5878,10 +6298,10 @@ AC_CHECK_FUNCS([clock_getres], [], [ ]) ]) -# On Android and iOS, clock_settime can be linked (so it is found by +# On Android, iOS, tvOS, visionOS, and watchOS, clock_settime can be linked (so it is found by # configure), but when used in an unprivileged process, it crashes rather than # returning an error. Force the symbol off. -if test "$ac_sys_system" != "Linux-android" && test "$ac_sys_system" != "iOS" +if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "iOS" -a "$ac_sys_system" != "tvOS" -a "$ac_sys_system" != "visionOS" -a "$ac_sys_system" != "watchOS" then AC_CHECK_FUNCS([clock_settime], [], [ AC_CHECK_LIB([rt], [clock_settime], [ @@ -5928,8 +6348,7 @@ AS_VAR_IF([ac_cv_device_macros], [yes], [ dnl no longer used, now always defined for backwards compatibility AC_DEFINE([SYS_SELECT_WITH_SYS_TIME], [1], - [Define if you can safely include both and - (which you can't on SCO ODT 3.0).]) + [Define if you can safely include both and ]) # On OSF/1 V5.1, getaddrinfo is available, but a define # for [no]getaddrinfo in netdb.h. @@ -6039,7 +6458,7 @@ int main(void) [ac_cv_buggy_getaddrinfo=no], [ac_cv_buggy_getaddrinfo=yes], [ -if test "$ac_sys_system" = "Linux-android" || test "$ac_sys_system" = "iOS"; then +if test "$ac_sys_system" = "Linux-android" || test "$ac_sys_system" = "iOS" || test "$ac_sys_system" = "tvOS" || test "$ac_sys_system" = "visionOS" || test "$ac_sys_system" = "watchOS"; then ac_cv_buggy_getaddrinfo="no" elif test "${enable_ipv6+set}" = set; then ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6" @@ -6140,28 +6559,6 @@ if test $ac_cv_struct_sockaddr_alg = yes; then [struct sockaddr_alg (linux/if_alg.h)]) fi -# checks for compiler characteristics - -AC_C_CONST - -AC_CACHE_CHECK([for working signed char], [ac_cv_working_signed_char_c], [ -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])], - [ac_cv_working_signed_char_c=yes], [ac_cv_working_signed_char_c=no]) -]) -AS_VAR_IF([ac_cv_working_signed_char_c], [no], [ - AC_DEFINE([signed], [], [Define to empty if the keyword does not work.]) -]) - -AC_CACHE_CHECK([for prototypes], [ac_cv_function_prototypes], [ -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])], - [ac_cv_function_prototypes=yes], [ac_cv_function_prototypes=no]) -]) -AS_VAR_IF([ac_cv_function_prototypes], [yes], [ - AC_DEFINE([HAVE_PROTOTYPES], [1], - [Define if your compiler supports function prototype]) -]) - - # check for socketpair PY_CHECK_FUNC([socketpair], [ #include @@ -6300,22 +6697,6 @@ else AC_MSG_ERROR([proper usage is --with-libc=STRING]) fi], [AC_MSG_RESULT([default LIBC="$LIBC"])]) -# ************************************** -# * Check for gcc x64 inline assembler * -# ************************************** - - -AC_CACHE_CHECK([for x64 gcc inline assembler], [ac_cv_gcc_asm_for_x64], [ -AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ - __asm__ __volatile__ ("movq %rcx, %rax"); -]])],[ac_cv_gcc_asm_for_x64=yes],[ac_cv_gcc_asm_for_x64=no]) -]) - -AS_VAR_IF([ac_cv_gcc_asm_for_x64], [yes], [ - AC_DEFINE([HAVE_GCC_ASM_FOR_X64], [1], - [Define if we can use x64 gcc inline assembler]) -]) - # ************************************************** # * Check for various properties of floating point * # ************************************************** @@ -6340,8 +6721,8 @@ AX_C_FLOAT_WORDS_BIGENDIAN( # rounding precision of 64 bits. For gcc/x86, we can fix this by # using inline assembler to get and set the x87 FPU control word. -# This inline assembler syntax may also work for suncc and icc, -# so we try it on all platforms. +# This inline assembler syntax works for icx and may also work for +# suncc and icc, so we try it on all platforms. AC_CACHE_CHECK([whether we can use gcc inline assembler to get and set x87 control word], [ac_cv_gcc_asm_for_x87], [ AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[ @@ -6420,7 +6801,13 @@ AC_CHECK_FUNCS( [AC_MSG_ERROR([Python requires C99 compatible libm])] ) -AC_CHECK_FUNCS_ONCE(acospi asinpi atanpi atan2pi cospi sinpi tanpi) +PY_CHECK_FUNC_PRIVATE([acospi], [@%:@include ]) +PY_CHECK_FUNC_PRIVATE([asinpi], [@%:@include ]) +PY_CHECK_FUNC_PRIVATE([atanpi], [@%:@include ]) +PY_CHECK_FUNC_PRIVATE([atan2pi], [@%:@include ]) +PY_CHECK_FUNC_PRIVATE([cospi], [@%:@include ]) +PY_CHECK_FUNC_PRIVATE([sinpi], [@%:@include ]) +PY_CHECK_FUNC_PRIVATE([tanpi], [@%:@include ]) LIBS=$LIBS_SAVE dnl For multiprocessing module, check that sem_open @@ -6628,22 +7015,25 @@ LDVERSION='$(VERSION)$(ABIFLAGS)' AC_MSG_RESULT([$LDVERSION]) # Configure the flags and dependencies used when compiling shared modules. -# Do not rename LIBPYTHON - it's accessed via sysconfig by package build -# systems (e.g. Meson) to decide whether to link extension modules against -# libpython. AC_SUBST([MODULE_DEPS_SHARED]) AC_SUBST([LIBPYTHON]) MODULE_DEPS_SHARED='$(MODULE_DEPS_STATIC) $(EXPORTSYMS)' + +# On most platforms, extension modules aren't linked against libpython, so +# LIBPYTHON must be empty. LIBPYTHON='' # On Android and Cygwin the shared libraries must be linked with libpython. +# LIBPYTHON is used by python-config, python3.pc, the commands for building the +# stdlib's own extension modules, and external package build systems via +# sysconfig, so its value must be suitable for all those contexts. if test "$PY_ENABLE_SHARED" = "1" && ( test -n "$ANDROID_API_LEVEL" || test "$MACHDEP" = "cygwin"); then MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(LDLIBRARY)" - LIBPYTHON="\$(BLDLIBRARY)" + LIBPYTHON="-lpython${VERSION}${ABIFLAGS}" fi -# On iOS the shared libraries must be linked with the Python framework -if test "$ac_sys_system" = "iOS"; then +# On iOS/tvOS/watchOS the shared libraries must be linked with the framework, when built +if test "$ac_sys_system" = "iOS" -o "$ac_sys_system" = "tvOS" -o "$ac_sys_system" = "visionOS" -o "$ac_sys_system" = "watchOS" && test "$enable_framework"; then MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(PYTHONFRAMEWORKDIR)/\$(PYTHONFRAMEWORK)" fi @@ -6882,7 +7272,7 @@ AS_VAR_IF([with_readline], [no], [ ) ]) AS_VAR_IF([ac_cv_readline_rl_change_environment], [yes], [ - AC_DEFINE([HAVE_RL_CHANGE_ENVIRONMENT], [1], [Define if you have readline 6.3]) + AC_DEFINE([_Py_HAVE_RL_CHANGE_ENVIRONMENT], [1], [Define if you have readline 6.3]) ]) # check for readline 4.2 @@ -7088,12 +7478,28 @@ then fi dnl check for ncursesw/ncurses and panelw/panel -dnl NOTE: old curses is not detected. dnl have_curses=[no, yes] dnl have_panel=[no, yes] have_curses=no have_panel=no +dnl Select the curses backend, or disable the curses and _curses_panel modules. +dnl "auto" (the default) prefers ncursesw and falls back to ncurses, both via +dnl pkg-config. "curses" links the system's native curses (e.g. on NetBSD or +dnl Solaris), which has no pkg-config file and is never chosen by "auto". +AC_MSG_CHECKING([for --with-curses]) +AC_ARG_WITH( + [curses], + [AS_HELP_STRING([--with(out)-curses@<:@=ncursesw|ncurses|curses|no@:>@], + [select the curses backend for the curses and _curses_panel + modules, or disable them (default: auto)])], + [AS_CASE([$with_curses], + [yes|auto], [with_curses=auto], + [ncursesw|ncurses|curses|no], [], + [AC_MSG_ERROR([proper usage is --with(out)-curses@<:@=ncursesw|ncurses|curses|no@:>@])])], + [with_curses=auto]) +AC_MSG_RESULT([$with_curses]) + dnl PY_CHECK_CURSES(LIBCURSES, LIBPANEL) dnl Sets 'have_curses' and 'have_panel'. dnl For the PKG_CHECK_MODULES() calls, we can safely reuse the first variable @@ -7108,34 +7514,55 @@ PKG_CHECK_MODULES([CURSES], [$1], PKG_CHECK_MODULES([PANEL], [$2], [AC_DEFINE([HAVE_]panel_var, [1], [Define if you have the '$2' library]) AS_VAR_SET([have_panel], [yes])], - [AS_VAR_SET([have_panel], [no])])], + [dnl pkgsrc renames the ncurses panel to "gnupanel" so it does not clash + dnl with a system libpanel; it Requires the same ncurses, so it matches. + PKG_CHECK_MODULES([PANEL], [gnupanel], + [AS_VAR_SET([have_panel], [yes])], + [AS_VAR_SET([have_panel], [no])])])], [AS_VAR_SET([have_curses], [no])]) AS_VAR_POPDEF([curses_var]) AS_VAR_POPDEF([panel_var])]) -# Check for ncursesw/panelw first. If that fails, try ncurses/panel. -PY_CHECK_CURSES([ncursesw], [panelw]) -AS_VAR_IF([have_curses], [no], - [PY_CHECK_CURSES([ncurses], [panel])]) +# Detect the selected backend. ncursesw/ncurses are found via pkg-config; +# native curses has no .pc file and is left to the header/link probes below. +# curses_libs/panel_libs drive the AC_SEARCH_LIBS fallback; for "no" they are +# empty so nothing links and have_curses stays "no". +AS_CASE([$with_curses], + [ncursesw], [PY_CHECK_CURSES([ncursesw], [panelw]) + curses_libs="ncursesw"; panel_libs="panelw gnupanel"], + [ncurses], [PY_CHECK_CURSES([ncurses], [panel]) + curses_libs="ncurses"; panel_libs="panel gnupanel"], + [curses], [curses_libs="curses"; panel_libs="panel"], + [no], [curses_libs=""; panel_libs=""], + [dnl auto: prefer ncursesw, fall back to ncurses; never native curses. + PY_CHECK_CURSES([ncursesw], [panelw]) + AS_VAR_IF([have_curses], [no], [PY_CHECK_CURSES([ncurses], [panel])]) + curses_libs="ncursesw ncurses"; panel_libs="panelw panel gnupanel"]) WITH_SAVE_ENV([ - # Make sure we've got the header defines. + # Make sure we've got the header defines. For the native "curses" backend, + # probe only the plain headers: a system may also have ncurses headers (e.g. + # ncurses/curses.h), and picking those while linking the native library mixes + # incompatible declarations (e.g. tparm()) with the native . AS_VAR_APPEND([CPPFLAGS], [" $CURSES_CFLAGS $PANEL_CFLAGS"]) - AC_CHECK_HEADERS(m4_normalize([ - ncursesw/curses.h ncursesw/ncurses.h ncursesw/panel.h - ncurses/curses.h ncurses/ncurses.h ncurses/panel.h - curses.h ncurses.h panel.h - ])) + AS_VAR_IF([with_curses], [curses], + [AC_CHECK_HEADERS([curses.h panel.h])], + [AC_CHECK_HEADERS(m4_normalize([ + ncursesw/curses.h ncursesw/ncurses.h ncursesw/panel.h + ncurses/curses.h ncurses/ncurses.h ncurses/panel.h + curses.h ncurses.h panel.h + ]))]) # Check that we're able to link with crucial curses/panel functions. This - # also serves as a fallback in case pkg-config failed. - AS_VAR_APPEND([LIBS], [" $CURSES_LIBS $PANEL_LIBS"]) - AC_SEARCH_LIBS([initscr], [ncursesw ncurses], + # also serves as a fallback in case pkg-config failed. Extension modules are + # not linked with LIBS, so exclude it to get the required libraries. + LIBS="$CURSES_LIBS $PANEL_LIBS" + AC_SEARCH_LIBS([initscr], [$curses_libs], [AS_VAR_IF([have_curses], [no], [AS_VAR_SET([have_curses], [yes]) CURSES_LIBS=${CURSES_LIBS-"$ac_cv_search_initscr"}])], [AS_VAR_SET([have_curses], [no])]) - AC_SEARCH_LIBS([update_panels], [panelw panel], + AC_SEARCH_LIBS([update_panels], [$panel_libs], [AS_VAR_IF([have_panel], [no], [AS_VAR_SET([have_panel], [yes]) PANEL_LIBS=${PANEL_LIBS-"$ac_cv_search_update_panels"}])], @@ -7163,7 +7590,7 @@ AC_DEFUN([_CURSES_INCLUDES],dnl #endif ]) -AS_IF([test "have_curses" != "no"], [ +AS_IF([test "$have_curses" != "no"], [ dnl remove _XOPEN_SOURCE macro from curses cflags. pyconfig.h sets dnl the macro to 700. CURSES_CFLAGS=$(echo $CURSES_CFLAGS | sed 's/-D_XOPEN_SOURCE=600//g') @@ -7183,6 +7610,34 @@ AS_VAR_IF([ac_sys_system], [Darwin], [ dnl pyconfig.h defines _XOPEN_SOURCE=700 PANEL_CFLAGS=$(echo $PANEL_CFLAGS | sed 's/-D_XOPEN_SOURCE=600//g') +dnl A curses that is not named "ncursesw" can still be wide-character capable: +dnl the system curses of NetBSD, or an ncurses built with --enable-widec that +dnl keeps the plain name (pkgsrc, macOS). Probe for the wide API and, if +dnl present, build the module wide by defining HAVE_NCURSESW. The "ncursesw" +dnl backend already defines it, so only the other backends are probed. +AS_CASE([$with_curses], [ncursesw|no], [], [ + dnl Use the adjusted CURSES_CFLAGS (e.g. macOS's -D_XOPEN_SOURCE_EXTENDED) + dnl so the wide-character declarations are visible to the probe. This runs + dnl inside an outer WITH_SAVE_ENV, whose single CPPFLAGS save slot is not + dnl reentrant, so save and restore CPPFLAGS with a dedicated variable here. + save_curses_cppflags=$CPPFLAGS + AS_VAR_APPEND([CPPFLAGS], [" $CURSES_CFLAGS"]) + AC_CACHE_CHECK([whether curses supports wide characters], + [ac_cv_curses_wide], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM([_CURSES_INCLUDES], [[ + cchar_t wcval; + setcchar(&wcval, L"x", A_NORMAL, 0, NULL); + add_wch(&wcval); + ]])], + [ac_cv_curses_wide=yes], + [ac_cv_curses_wide=no])]) + CPPFLAGS=$save_curses_cppflags + dnl HAVE_NCURSESW marks the wide (cchar_t) curses API; its template comes + dnl from the ncursesw pkg-config check above, so no description here. + AS_VAR_IF([ac_cv_curses_wide], [yes], [AC_DEFINE([HAVE_NCURSESW], [1])]) +]) + # On Solaris, term.h requires curses.h AC_CHECK_HEADERS([term.h], [], [], _CURSES_INCLUDES) @@ -7217,16 +7672,19 @@ then fi dnl PY_CHECK_CURSES_FUNC(FUNCTION) +dnl Link, not just compile: a header can declare a function that the library +dnl lacks, for example term_attrs() in the narrow ncurses library. AC_DEFUN([PY_CHECK_CURSES_FUNC], [ AS_VAR_PUSHDEF([py_var], [ac_cv_lib_curses_$1]) AS_VAR_PUSHDEF([py_define], [HAVE_CURSES_]m4_toupper($1)) + AS_VAR_PUSHDEF([py_define], m4_ifblank([$3], [[HAVE_CURSES_]m4_toupper($1)], [$3])) AC_CACHE_CHECK( [for curses function $1], [py_var], - [AC_COMPILE_IFELSE( + [AC_LINK_IFELSE( [AC_LANG_PROGRAM(_CURSES_INCLUDES, [ #ifndef $1 - void *x=$1 + void * volatile x = (void *)$1; (void)x; #endif ])], [AS_VAR_SET([py_var], [yes])], @@ -7240,6 +7698,13 @@ AC_DEFUN([PY_CHECK_CURSES_FUNC], AS_VAR_POPDEF([py_define]) ]) +dnl PY_CHECK_CURSES_FUNC_PRIVATE(FUNCTION, [INCLUDES], [AC_DEFINE-VAR]) +dnl Similar to PY_CHECK_CURSES_FUNC but define macro _Py_HAVE_CURSES_xxx, +dnl instead of HAVE_CURSES_xxx +AC_DEFUN([PY_CHECK_CURSES_FUNC_PRIVATE], +[ PY_CHECK_CURSES_FUNC([$1], [$2], m4_ifblank([$3], [[_Py_HAVE_CURSES_]m4_toupper($1)], [$3])) +]) + dnl PY_CHECK_CURSES_VAR(VARIABLE) dnl Like PY_CHECK_CURSES_FUNC, but for an integer variable (or macro), such as dnl ESCDELAY, which a function probe cannot detect. @@ -7272,25 +7737,37 @@ PY_CHECK_CURSES_FUNC([immedok]) PY_CHECK_CURSES_FUNC([syncok]) PY_CHECK_CURSES_FUNC([wchgat]) PY_CHECK_CURSES_FUNC([filter]) -PY_CHECK_CURSES_FUNC([nofilter]) PY_CHECK_CURSES_FUNC([has_key]) -PY_CHECK_CURSES_FUNC([has_mouse]) -PY_CHECK_CURSES_FUNC([is_keypad]) -PY_CHECK_CURSES_FUNC([is_leaveok]) PY_CHECK_CURSES_FUNC([typeahead]) PY_CHECK_CURSES_FUNC([use_env]) -PY_CHECK_CURSES_FUNC([new_prescr]) -PY_CHECK_CURSES_FUNC([use_screen]) -PY_CHECK_CURSES_FUNC([use_window]) -PY_CHECK_CURSES_FUNC([key_defined]) -PY_CHECK_CURSES_FUNC([term_attrs]) -PY_CHECK_CURSES_FUNC([define_key]) -PY_CHECK_CURSES_FUNC([keyok]) PY_CHECK_CURSES_FUNC([set_escdelay]) PY_CHECK_CURSES_FUNC([set_tabsize]) +dnl The X/Open attr_t and soft-label attribute functions are absent on old +dnl SVr4 curses (e.g. illumos). PY_CHECK_CURSES_VAR([ESCDELAY]) PY_CHECK_CURSES_VAR([TABSIZE]) +PY_CHECK_CURSES_FUNC_PRIVATE([define_key]) +PY_CHECK_CURSES_FUNC_PRIVATE([has_mouse]) +PY_CHECK_CURSES_FUNC_PRIVATE([is_keypad]) +PY_CHECK_CURSES_FUNC_PRIVATE([is_leaveok]) +PY_CHECK_CURSES_FUNC_PRIVATE([key_defined]) +PY_CHECK_CURSES_FUNC_PRIVATE([keyok]) +PY_CHECK_CURSES_FUNC_PRIVATE([new_prescr]) +PY_CHECK_CURSES_FUNC_PRIVATE([nofilter]) +PY_CHECK_CURSES_FUNC_PRIVATE([slk_attr_off]) +PY_CHECK_CURSES_FUNC_PRIVATE([slk_attr_on]) +PY_CHECK_CURSES_FUNC_PRIVATE([slk_attr_set]) +PY_CHECK_CURSES_FUNC_PRIVATE([slk_color]) +PY_CHECK_CURSES_FUNC_PRIVATE([term_attrs]) +PY_CHECK_CURSES_FUNC_PRIVATE([use_screen]) +PY_CHECK_CURSES_FUNC_PRIVATE([use_window]) +PY_CHECK_CURSES_FUNC_PRIVATE([wattr_get]) +PY_CHECK_CURSES_FUNC_PRIVATE([wattr_off]) +PY_CHECK_CURSES_FUNC_PRIVATE([wattr_on]) +PY_CHECK_CURSES_FUNC_PRIVATE([wattr_set]) +PY_CHECK_CURSES_FUNC_PRIVATE([wcolor_set]) + dnl Probe for the X/Open getmouse(MEVENT *) signature specifically: PDCurses dnl declares an incompatible getmouse(void) unless built for the ncurses mouse API. AC_CACHE_CHECK([for ncurses-style curses function getmouse], @@ -7303,9 +7780,11 @@ AS_VAR_IF([ac_cv_lib_curses_getmouse], [yes], [AC_DEFINE([HAVE_CURSES_GETMOUSE], [1], [Define if you have the 'getmouse' function with the X/Open signature.])]) -dnl scr_dump and its companions scr_restore/scr_init/scr_set are an inseparable -dnl group; probing scr_dump alone gates the whole family. -PY_CHECK_CURSES_FUNC([scr_dump]) +dnl scr_dump gates scr_dump/scr_restore/scr_init; scr_set is separate, since +dnl old SVr4 curses (e.g. illumos) has the former but not scr_set. +PY_CHECK_CURSES_FUNC_PRIVATE([scr_dump]) +PY_CHECK_CURSES_FUNC_PRIVATE([scr_set]) + CPPFLAGS=$ac_save_cppflags ])dnl have_curses != no ])dnl save env @@ -7315,7 +7794,7 @@ AC_MSG_NOTICE([checking for device files]) dnl NOTE: Inform user how to proceed with files when cross compiling. dnl Some cross-compile builds are predictable; they won't ever dnl have /dev/ptmx or /dev/ptc, so we can set them explicitly. -if test "$ac_sys_system" = "Linux-android" || test "$ac_sys_system" = "iOS"; then +if test "$ac_sys_system" = "Linux-android" -o "$ac_sys_system" = "iOS" -o "$ac_sys_system" = "tvOS" -o "$ac_sys_system" = "visionOS" -o "$ac_sys_system" = "watchOS" ; then ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no else @@ -7523,49 +8002,6 @@ for dir in $SRCDIRS; do done AC_MSG_RESULT([done]) -# Availability of -O2: -AC_CACHE_CHECK([for -O2], [ac_cv_compile_o2], [ -saved_cflags="$CFLAGS" -CFLAGS="-O2" -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [ac_cv_compile_o2=yes], [ac_cv_compile_o2=no]) -CFLAGS="$saved_cflags" -]) - -# _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect: -# http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html -AC_MSG_CHECKING([for glibc _FORTIFY_SOURCE/memmove bug]) -saved_cflags="$CFLAGS" -CFLAGS="-O2 -D_FORTIFY_SOURCE=2" -if test "$ac_cv_compile_o2" = no; then - CFLAGS="" -fi -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include -#include -void foo(void *p, void *q) { memmove(p, q, 19); } -int main(void) { - char a[32] = "123456789000000000"; - foo(&a[9], a); - if (strcmp(a, "123456789123456789000000000") != 0) - return 1; - foo(a, &a[9]); - if (strcmp(a, "123456789000000000") != 0) - return 1; - return 0; -} -]])], -[have_glibc_memmove_bug=no], -[have_glibc_memmove_bug=yes], -[have_glibc_memmove_bug=undefined]) -CFLAGS="$saved_cflags" -AC_MSG_RESULT([$have_glibc_memmove_bug]) -if test "$have_glibc_memmove_bug" = yes; then - AC_DEFINE([HAVE_GLIBC_MEMMOVE_BUG], [1], - [Define if glibc has incorrect _FORTIFY_SOURCE wrappers - for memmove and bcopy.]) -fi - AC_MSG_CHECKING([if we need to manually block large inlining in ceval.c]) AC_RUN_IFELSE([AC_LANG_SOURCE([[ int main(void) { @@ -7594,45 +8030,6 @@ if test "$block_huge_inlining_in_ceval" = yes && test "$ac_cv_computed_gotos" = fi AC_SUBST([CFLAGS_CEVAL]) -if test "$ac_cv_gcc_asm_for_x87" = yes; then - # Some versions of gcc miscompile inline asm: - # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491 - # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html - case $ac_cv_cc_name in - gcc) - AC_MSG_CHECKING([for gcc ipa-pure-const bug]) - saved_cflags="$CFLAGS" - CFLAGS="-O2" - AC_RUN_IFELSE([AC_LANG_SOURCE([[ - __attribute__((noinline)) int - foo(int *p) { - int r; - asm ( "movl \$6, (%1)\n\t" - "xorl %0, %0\n\t" - : "=r" (r) : "r" (p) : "memory" - ); - return r; - } - int main(void) { - int p = 8; - if ((foo(&p) ? : p) != 6) - return 1; - return 0; - } - ]])], - [have_ipa_pure_const_bug=no], - [have_ipa_pure_const_bug=yes], - [have_ipa_pure_const_bug=undefined]) - CFLAGS="$saved_cflags" - AC_MSG_RESULT([$have_ipa_pure_const_bug]) - if test "$have_ipa_pure_const_bug" = yes; then - AC_DEFINE([HAVE_IPA_PURE_CONST_BUG], [1], - [Define if gcc has the ipa-pure-const bug.]) - fi - ;; - esac -fi - # ensurepip option AC_MSG_CHECKING([for ensurepip]) AC_ARG_WITH([ensurepip], @@ -7643,7 +8040,7 @@ AC_ARG_WITH([ensurepip], AS_CASE([$ac_sys_system], [Emscripten], [with_ensurepip=no], [WASI], [with_ensurepip=no], - [iOS], [with_ensurepip=no], + [iOS|tvOS|visionOS|watchOS], [with_ensurepip=no], [with_ensurepip=upgrade] ) ]) @@ -7683,7 +8080,11 @@ AC_LINK_IFELSE( #include #include #include - #include + #include // GRND_NONBLOCK + + #if !defined(SYS_getrandom) && defined(__NR_getrandom) + # define SYS_getrandom __NR_getrandom + #endif int main(void) { char buffer[1]; @@ -7956,6 +8357,11 @@ AC_ARG_ENABLE([test-modules], AS_VAR_IF([enable_test_modules], [yes], [TEST_MODULES=yes], [TEST_MODULES=no]) ], [TEST_MODULES=yes]) AC_MSG_RESULT([$TEST_MODULES]) +dnl Some test modules can only be built as shared libraries (see +dnl Modules/Setup.stdlib.in), which a non-framework iOS build cannot do. +AS_IF([test "$ac_sys_system" = "iOS" && test -z "$PYTHONFRAMEWORK"], + [AS_IF([test "$TEST_MODULES" != "no"], + [AC_MSG_ERROR([iOS non-framework builds must use --disable-test-modules])])]) AC_SUBST([TEST_MODULES]) # Check for --with-build-details-suffix @@ -8065,6 +8471,9 @@ case "$ac_sys_system" in NetBSD*) _PYTHREAD_NAME_MAXLEN=15;; # gh-131268 Darwin) _PYTHREAD_NAME_MAXLEN=63;; iOS) _PYTHREAD_NAME_MAXLEN=63;; + tvOS) _PYTHREAD_NAME_MAXLEN=63;; + visionOS) _PYTHREAD_NAME_MAXLEN=63;; + watchOS) _PYTHREAD_NAME_MAXLEN=63;; FreeBSD*) _PYTHREAD_NAME_MAXLEN=19;; # gh-131268 OpenBSD*) _PYTHREAD_NAME_MAXLEN=23;; # gh-131268 CYGWIN*) _PYTHREAD_NAME_MAXLEN=16;; @@ -8090,7 +8499,7 @@ AS_CASE([$ac_sys_system], [VxWorks*], [PY_STDLIB_MOD_SET_NA([_scproxy], [termios], [grp])], dnl The _scproxy module is available on macOS [Darwin], [], - [iOS], [ + [iOS|tvOS|visionOS|watchOS], [ dnl subprocess and multiprocessing are not supported (no fork syscall). dnl curses and tkinter user interface are not available. dnl gdbm and nis aren't available @@ -8195,6 +8604,12 @@ AS_CASE([$host_cpu], ) AC_SUBST([MODULE_BUILDTYPE]) +dnl A non-framework iOS build has no framework for a shared extension module +dnl to link against, so every extension module must be built into libpython. +AS_IF([test "$ac_sys_system" = "iOS" && test -z "$PYTHONFRAMEWORK"], + [AS_IF([test "$MODULE_BUILDTYPE" != "static"], + [AC_MSG_ERROR([iOS non-framework builds must use MODULE_BUILDTYPE=static])])]) + dnl _MODULE_BLOCK_ADD([VAR], [VALUE]) dnl internal: adds $1=quote($2) to MODULE_BLOCK AC_DEFUN([_MODULE_BLOCK_ADD], [AS_VAR_APPEND([MODULE_BLOCK], ["$1=_AS_QUOTE([$2])$as_nl"])]) @@ -8653,12 +9068,12 @@ fi AC_MSG_NOTICE([creating Makefile]) $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \ -s Modules \ - Modules/Setup.local Modules/Setup.stdlib Modules/Setup.bootstrap $srcdir/Modules/Setup + Modules/Setup.local Modules/Setup.stdlib -b Modules/Setup.bootstrap $srcdir/Modules/Setup if test $? -ne 0; then AC_MSG_ERROR([makesetup failed]) fi -mv config.c Modules +mv config.c config_bootstrap.c Modules if test -z "$PKG_CONFIG"; then AC_MSG_WARN([pkg-config is missing. Some dependencies may not be detected correctly.]) diff --git a/pyconfig.h.in b/pyconfig.h.in index 2f9b2140d9f191a..1d4f445a8b1fdaa 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -55,9 +55,6 @@ /* Define to 1 if you have the 'acosh' function. */ #undef HAVE_ACOSH -/* Define to 1 if you have the 'acospi' function. */ -#undef HAVE_ACOSPI - /* struct addrinfo (netdb.h) */ #undef HAVE_ADDRINFO @@ -76,21 +73,12 @@ /* Define to 1 if you have the 'asinh' function. */ #undef HAVE_ASINH -/* Define to 1 if you have the 'asinpi' function. */ -#undef HAVE_ASINPI - /* Define to 1 if you have the header file. */ #undef HAVE_ASM_TYPES_H -/* Define to 1 if you have the 'atan2pi' function. */ -#undef HAVE_ATAN2PI - /* Define to 1 if you have the 'atanh' function. */ #undef HAVE_ATANH -/* Define to 1 if you have the 'atanpi' function. */ -#undef HAVE_ATANPI - /* Define to 1 if you have the 'backtrace' function. */ #undef HAVE_BACKTRACE @@ -191,18 +179,12 @@ /* Define to 1 if you have the 'copy_file_range' function. */ #undef HAVE_COPY_FILE_RANGE -/* Define to 1 if you have the 'cospi' function. */ -#undef HAVE_COSPI - /* Define to 1 if you have the 'ctermid' function. */ #undef HAVE_CTERMID /* Define if you have the 'ctermid_r' function. */ #undef HAVE_CTERMID_R -/* Define if you have the 'define_key' function. */ -#undef HAVE_CURSES_DEFINE_KEY - /* Define if you have the 'ESCDELAY' variable. */ #undef HAVE_CURSES_ESCDELAY @@ -218,45 +200,21 @@ /* Define if you have the 'has_key' function. */ #undef HAVE_CURSES_HAS_KEY -/* Define if you have the 'has_mouse' function. */ -#undef HAVE_CURSES_HAS_MOUSE - /* Define if you have the 'immedok' function. */ #undef HAVE_CURSES_IMMEDOK -/* Define if you have the 'is_keypad' function. */ -#undef HAVE_CURSES_IS_KEYPAD - -/* Define if you have the 'is_leaveok' function. */ -#undef HAVE_CURSES_IS_LEAVEOK - /* Define if you have the 'is_pad' function. */ #undef HAVE_CURSES_IS_PAD /* Define if you have the 'is_term_resized' function. */ #undef HAVE_CURSES_IS_TERM_RESIZED -/* Define if you have the 'keyok' function. */ -#undef HAVE_CURSES_KEYOK - -/* Define if you have the 'key_defined' function. */ -#undef HAVE_CURSES_KEY_DEFINED - -/* Define if you have the 'new_prescr' function. */ -#undef HAVE_CURSES_NEW_PRESCR - -/* Define if you have the 'nofilter' function. */ -#undef HAVE_CURSES_NOFILTER - /* Define if you have the 'resizeterm' function. */ #undef HAVE_CURSES_RESIZETERM /* Define if you have the 'resize_term' function. */ #undef HAVE_CURSES_RESIZE_TERM -/* Define if you have the 'scr_dump' function. */ -#undef HAVE_CURSES_SCR_DUMP - /* Define if you have the 'set_escdelay' function. */ #undef HAVE_CURSES_SET_ESCDELAY @@ -269,21 +227,12 @@ /* Define if you have the 'TABSIZE' variable. */ #undef HAVE_CURSES_TABSIZE -/* Define if you have the 'term_attrs' function. */ -#undef HAVE_CURSES_TERM_ATTRS - /* Define if you have the 'typeahead' function. */ #undef HAVE_CURSES_TYPEAHEAD /* Define if you have the 'use_env' function. */ #undef HAVE_CURSES_USE_ENV -/* Define if you have the 'use_screen' function. */ -#undef HAVE_CURSES_USE_SCREEN - -/* Define if you have the 'use_window' function. */ -#undef HAVE_CURSES_USE_WINDOW - /* Define if you have the 'wchgat' function. */ #undef HAVE_CURSES_WCHGAT @@ -368,6 +317,9 @@ /* Define to 1 if you have the 'dlopen' function. */ #undef HAVE_DLOPEN +/* Define to 1 if you have the 'dl_iterate_phdr' function. */ +#undef HAVE_DL_ITERATE_PHDR + /* Define to 1 if you have the 'dup' function. */ #undef HAVE_DUP @@ -479,9 +431,6 @@ /* Define to 1 if you have the 'fpathconf' function. */ #undef HAVE_FPATHCONF -/* Define to 1 if you have the 'fseek64' function. */ -#undef HAVE_FSEEK64 - /* Define to 1 if you have the 'fseeko' function. */ #undef HAVE_FSEEKO @@ -494,15 +443,9 @@ /* Define if you have the 'fsync' function. */ #undef HAVE_FSYNC -/* Define to 1 if you have the 'ftell64' function. */ -#undef HAVE_FTELL64 - /* Define to 1 if you have the 'ftello' function. */ #undef HAVE_FTELLO -/* Define to 1 if you have the 'ftime' function. */ -#undef HAVE_FTIME - /* Define to 1 if you have the 'ftruncate' function. */ #undef HAVE_FTRUNCATE @@ -521,9 +464,6 @@ /* Define if we can use gcc inline assembler to get and set mc68881 fpcr */ #undef HAVE_GCC_ASM_FOR_MC68881 -/* Define if we can use x64 gcc inline assembler */ -#undef HAVE_GCC_ASM_FOR_X64 - /* Define if we can use gcc inline assembler to get and set x87 control word */ #undef HAVE_GCC_ASM_FOR_X87 @@ -675,22 +615,9 @@ /* Define if you have the 'getsockname' function. */ #undef HAVE_GETSOCKNAME -/* Define to 1 if you have the 'getspent' function. */ -#undef HAVE_GETSPENT - -/* Define to 1 if you have the 'getspnam' function. */ -#undef HAVE_GETSPNAM - /* Define to 1 if you have the 'getuid' function. */ #undef HAVE_GETUID -/* Define to 1 if you have the 'getwd' function. */ -#undef HAVE_GETWD - -/* Define if glibc has incorrect _FORTIFY_SOURCE wrappers for memmove and - bcopy. */ -#undef HAVE_GLIBC_MEMMOVE_BUG - /* Define to 1 if you have the 'grantpt' function. */ #undef HAVE_GRANTPT @@ -703,9 +630,6 @@ /* Define this if you have le64toh() */ #undef HAVE_HTOLE64 -/* Define if you have a working iconv() function. */ -#undef HAVE_ICONV - /* Define to 1 if you have the header file. */ #undef HAVE_ICONV_H @@ -730,9 +654,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_IO_H -/* Define if gcc has the ipa-pure-const bug. */ -#undef HAVE_IPA_PURE_CONST_BUG - /* Define to 1 if you have the 'kill' function. */ #undef HAVE_KILL @@ -841,9 +762,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_SCHED_H -/* Define to 1 if you have the header file. */ -#undef HAVE_LINUX_SOUNDCARD_H - /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_TIPC_H @@ -1068,9 +986,6 @@ /* Define to 1 if you have the 'process_vm_readv' function. */ #undef HAVE_PROCESS_VM_READV -/* Define if your compiler supports function prototype */ -#undef HAVE_PROTOTYPES - /* Define to 1 if you have the 'pthread_condattr_setclock' function. */ #undef HAVE_PTHREAD_CONDATTR_SETCLOCK @@ -1102,6 +1017,9 @@ /* Define to 1 if you have the 'pthread_kill' function. */ #undef HAVE_PTHREAD_KILL +/* Define to 1 if you have the header file. */ +#undef HAVE_PTHREAD_NP_H + /* Define to 1 if you have the 'pthread_setname_np' function. */ #undef HAVE_PTHREAD_SETNAME_NP @@ -1159,9 +1077,6 @@ /* Define if you can turn off readline's signal handling. */ #undef HAVE_RL_CATCH_SIGNAL -/* Define if you have readline 6.3 */ -#undef HAVE_RL_CHANGE_ENVIRONMENT - /* Define to 1 if the system has the type 'rl_compdisp_func_t'. */ #undef HAVE_RL_COMPDISP_FUNC_T @@ -1285,9 +1200,6 @@ /* Define to 1 if you have the 'setvbuf' function. */ #undef HAVE_SETVBUF -/* Define to 1 if you have the header file. */ -#undef HAVE_SHADOW_H - /* Define to 1 if you have the 'shm_open' function. */ #undef HAVE_SHM_OPEN @@ -1318,9 +1230,6 @@ /* Define to 1 if you have the 'sigpending' function. */ #undef HAVE_SIGPENDING -/* Define to 1 if you have the 'sigrelse' function. */ -#undef HAVE_SIGRELSE - /* Define to 1 if you have the 'sigtimedwait' function. */ #undef HAVE_SIGTIMEDWAIT @@ -1330,9 +1239,6 @@ /* Define to 1 if you have the 'sigwaitinfo' function. */ #undef HAVE_SIGWAITINFO -/* Define to 1 if you have the 'sinpi' function. */ -#undef HAVE_SINPI - /* Define to 1 if you have the 'snprintf' function. */ #undef HAVE_SNPRINTF @@ -1477,9 +1383,6 @@ /* Define to 1 if you have the 'system' function. */ #undef HAVE_SYSTEM -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_AUDIOIO_H - /* Define to 1 if you have the header file. */ #undef HAVE_SYS_AUXV_H @@ -1560,9 +1463,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SOUNDCARD_H - /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STATVFS_H @@ -1611,18 +1511,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_XATTR_H -/* Define to 1 if you have the 'tanpi' function. */ -#undef HAVE_TANPI - /* Define to 1 if you have the 'tcgetpgrp' function. */ #undef HAVE_TCGETPGRP /* Define to 1 if you have the 'tcsetpgrp' function. */ #undef HAVE_TCSETPGRP -/* Define to 1 if you have the 'tempnam' function. */ -#undef HAVE_TEMPNAM - /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H @@ -1641,12 +1535,6 @@ /* Define to 1 if you have the 'tmpfile' function. */ #undef HAVE_TMPFILE -/* Define to 1 if you have the 'tmpnam' function. */ -#undef HAVE_TMPNAM - -/* Define to 1 if you have the 'tmpnam_r' function. */ -#undef HAVE_TMPNAM_R - /* Define to 1 if your 'struct tm' has 'tm_zone'. Deprecated, use 'HAVE_STRUCT_TM_TM_ZONE' instead. */ #undef HAVE_TM_ZONE @@ -1938,11 +1826,13 @@ /* The size of '_Bool', as computed by sizeof. */ #undef SIZEOF__BOOL +/* Platform tag, used in binary module extension filenames. */ +#undef SOABI_PLATFORM + /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS -/* Define if you can safely include both and - (which you can't on SCO ODT 3.0). */ +/* Define if you can safely include both and */ #undef SYS_SELECT_WITH_SYS_TIME /* Custom thread stack size depending on chosen sanitizer runtimes. */ @@ -2113,6 +2003,9 @@ /* Define to include mbstate_t for mbrtowc */ #undef _INCLUDE__STDC_A1_SOURCE +/* Define to activate ISO C23 library declarations */ +#undef _ISOC23_SOURCE + /* This must be defined on some systems to enable large file support. */ #undef _LARGEFILE_SOURCE @@ -2143,17 +2036,143 @@ /* HACL* library can compile SIMD256 implementations */ #undef _Py_HACL_CAN_COMPILE_VEC256 +/* Define if you have the 'acospi' function. */ +#undef _Py_HAVE_ACOSPI + +/* Define if you have the 'asinpi' function. */ +#undef _Py_HAVE_ASINPI + +/* Define if you have the 'atan2pi' function. */ +#undef _Py_HAVE_ATAN2PI + +/* Define if you have the 'atanpi' function. */ +#undef _Py_HAVE_ATANPI + +/* Define if you have the 'cospi' function. */ +#undef _Py_HAVE_COSPI + +/* Define if you have the 'define_key' function. */ +#undef _Py_HAVE_CURSES_DEFINE_KEY + +/* Define if you have the 'has_mouse' function. */ +#undef _Py_HAVE_CURSES_HAS_MOUSE + +/* Define if you have the 'is_keypad' function. */ +#undef _Py_HAVE_CURSES_IS_KEYPAD + +/* Define if you have the 'is_leaveok' function. */ +#undef _Py_HAVE_CURSES_IS_LEAVEOK + +/* Define if you have the 'keyok' function. */ +#undef _Py_HAVE_CURSES_KEYOK + +/* Define if you have the 'key_defined' function. */ +#undef _Py_HAVE_CURSES_KEY_DEFINED + +/* Define if you have the 'new_prescr' function. */ +#undef _Py_HAVE_CURSES_NEW_PRESCR + +/* Define if you have the 'nofilter' function. */ +#undef _Py_HAVE_CURSES_NOFILTER + +/* Define if you have the 'scr_dump' function. */ +#undef _Py_HAVE_CURSES_SCR_DUMP + +/* Define if you have the 'scr_set' function. */ +#undef _Py_HAVE_CURSES_SCR_SET + +/* Define if you have the 'slk_attr_off' function. */ +#undef _Py_HAVE_CURSES_SLK_ATTR_OFF + +/* Define if you have the 'slk_attr_on' function. */ +#undef _Py_HAVE_CURSES_SLK_ATTR_ON + +/* Define if you have the 'slk_attr_set' function. */ +#undef _Py_HAVE_CURSES_SLK_ATTR_SET + +/* Define if you have the 'slk_color' function. */ +#undef _Py_HAVE_CURSES_SLK_COLOR + +/* Define if you have the 'term_attrs' function. */ +#undef _Py_HAVE_CURSES_TERM_ATTRS + +/* Define if you have the 'use_screen' function. */ +#undef _Py_HAVE_CURSES_USE_SCREEN + +/* Define if you have the 'use_window' function. */ +#undef _Py_HAVE_CURSES_USE_WINDOW + +/* Define if you have the 'wattr_get' function. */ +#undef _Py_HAVE_CURSES_WATTR_GET + +/* Define if you have the 'wattr_off' function. */ +#undef _Py_HAVE_CURSES_WATTR_OFF + +/* Define if you have the 'wattr_on' function. */ +#undef _Py_HAVE_CURSES_WATTR_ON + +/* Define if you have the 'wattr_set' function. */ +#undef _Py_HAVE_CURSES_WATTR_SET + +/* Define if you have the 'wcolor_set' function. */ +#undef _Py_HAVE_CURSES_WCOLOR_SET + /* Define if compiler supports __builtin_shufflevector with 128-bit vectors AND the target architecture has native SIMD (not just API availability) */ #undef _Py_HAVE_EFFICIENT_BUILTIN_SHUFFLEVECTOR +/* Defined if _Float16 C type is supported */ +#undef _Py_HAVE_FLOAT16 + +/* Define if you have the 'freadlink' function. */ +#undef _Py_HAVE_FREADLINK + +/* Define if you have the 'getdents64' function. */ +#undef _Py_HAVE_GETDENTS64 + +/* Define if you have the 'gettid' function. */ +#undef _Py_HAVE_GETTID + +/* Define if you have a working iconv() function. */ +#undef _Py_HAVE_ICONV + +/* Define if you have the 'if_indextoname' function. */ +#undef _Py_HAVE_IF_INDEXTONAME + +/* Define if you have the 'if_nametoindex' function. */ +#undef _Py_HAVE_IF_NAMETOINDEX + /* Define to 1 if libgcc __register_frame and __deregister_frame are linkable. */ #undef _Py_HAVE_LIBGCC_EH_FRAME_REGISTRATION +/* Define if you have the 'pidfd_getfd' function. */ +#undef _Py_HAVE_PIDFD_GETFD + +/* Define if you have the 'pidfd_open' function. */ +#undef _Py_HAVE_PIDFD_OPEN + +/* Define if you have the 'pidfd_send_signal' function. */ +#undef _Py_HAVE_PIDFD_SEND_SIGNAL + /* Define if you have the 'PR_SET_VMA_ANON_NAME' constant. */ #undef _Py_HAVE_PR_SET_VMA_ANON_NAME +/* Define if you have the 'pthread_attr_get_np' function. */ +#undef _Py_HAVE_PTHREAD_ATTR_GET_NP + +/* Define if you have readline 6.3 */ +#undef _Py_HAVE_RL_CHANGE_ENVIRONMENT + +/* Define if you have the 'sinpi' function. */ +#undef _Py_HAVE_SINPI + +/* Define if you have the 'strerror_r' function. */ +#undef _Py_HAVE_STRERROR_R + +/* Define if you have the 'tanpi' function. */ +#undef _Py_HAVE_TANPI + /* Thread stack size set by the linker (in bytes). */ #undef _Py_LINKER_THREAD_STACK_SIZE @@ -2191,9 +2210,6 @@ /* Define to 'long' if does not define clock_t. */ #undef clock_t -/* Define to empty if 'const' does not conform to ANSI C. */ -#undef const - /* Define as 'int' if doesn't define. */ #undef gid_t @@ -2206,9 +2222,6 @@ /* Define as a signed integer type capable of holding a process identifier. */ #undef pid_t -/* Define to empty if the keyword does not work. */ -#undef signed - /* Define as 'unsigned int' if doesn't define. */ #undef size_t @@ -2219,10 +2232,5 @@ #undef uid_t -/* Define the macros needed if on a UnixWare 7.x system. */ -#if defined(__USLC__) && defined(__SCO_VERSION__) -#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ -#endif - #endif /*Py_PYCONFIG_H*/